summaryrefslogtreecommitdiffstats
path: root/grub-core
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--grub-core/Makefile.am506
-rw-r--r--grub-core/Makefile.core.am23794
-rw-r--r--grub-core/Makefile.core.def2529
-rw-r--r--grub-core/Makefile.gcry.def157
-rw-r--r--grub-core/Makefile.in47508
-rw-r--r--grub-core/boot/decompressor/minilib.c93
-rw-r--r--grub-core/boot/decompressor/none.c42
-rw-r--r--grub-core/boot/decompressor/xz.c60
-rw-r--r--grub-core/boot/i386/pc/boot.S542
-rw-r--r--grub-core/boot/i386/pc/cdboot.S173
-rw-r--r--grub-core/boot/i386/pc/diskboot.S378
-rw-r--r--grub-core/boot/i386/pc/lnxboot.S295
-rw-r--r--grub-core/boot/i386/pc/lzma_decode.S614
-rw-r--r--grub-core/boot/i386/pc/pxeboot.S42
-rw-r--r--grub-core/boot/i386/pc/startup_raw.S369
-rw-r--r--grub-core/boot/i386/qemu/boot.S74
-rw-r--r--grub-core/boot/mips/loongson/fuloong2f.S2
-rw-r--r--grub-core/boot/mips/loongson/fwstart.S756
-rw-r--r--grub-core/boot/mips/startup_raw.S300
-rw-r--r--grub-core/boot/powerpc/bootinfo.txt.in73
-rw-r--r--grub-core/boot/powerpc/grub.chrp.in172
-rw-r--r--grub-core/boot/sparc64/ieee1275/boot.S262
-rw-r--r--grub-core/boot/sparc64/ieee1275/diskboot.S145
-rw-r--r--grub-core/bus/bonito.c176
-rw-r--r--grub-core/bus/cs5536.c381
-rw-r--r--grub-core/bus/emu/pci.c78
-rw-r--r--grub-core/bus/fdt.c256
-rw-r--r--grub-core/bus/i386/ieee1275/pci.c42
-rw-r--r--grub-core/bus/pci.c173
-rw-r--r--grub-core/bus/spi/rk3288_spi.c103
-rw-r--r--grub-core/bus/usb/ehci-fdt.c45
-rw-r--r--grub-core/bus/usb/ehci-pci.c208
-rw-r--r--grub-core/bus/usb/ehci.c1839
-rw-r--r--grub-core/bus/usb/ohci.c1468
-rw-r--r--grub-core/bus/usb/serial/common.c139
-rw-r--r--grub-core/bus/usb/serial/ftdi.c218
-rw-r--r--grub-core/bus/usb/serial/pl2303.c231
-rw-r--r--grub-core/bus/usb/serial/usbdebug_late.c93
-rw-r--r--grub-core/bus/usb/uhci.c871
-rw-r--r--grub-core/bus/usb/usb.c346
-rw-r--r--grub-core/bus/usb/usbhub.c756
-rw-r--r--grub-core/bus/usb/usbtrans.c462
-rw-r--r--grub-core/commands/acpi.c791
-rw-r--r--grub-core/commands/acpihalt.c454
-rw-r--r--grub-core/commands/arc/lsdev.c57
-rw-r--r--grub-core/commands/blocklist.c160
-rw-r--r--grub-core/commands/boot.c195
-rw-r--r--grub-core/commands/boottime.c65
-rw-r--r--grub-core/commands/cacheinfo.c62
-rw-r--r--grub-core/commands/cat.c170
-rw-r--r--grub-core/commands/cmp.c119
-rw-r--r--grub-core/commands/configfile.c98
-rw-r--r--grub-core/commands/date.c149
-rw-r--r--grub-core/commands/echo.c141
-rw-r--r--grub-core/commands/efi/efifwsetup.c90
-rw-r--r--grub-core/commands/efi/fixvideo.c114
-rw-r--r--grub-core/commands/efi/loadbios.c222
-rw-r--r--grub-core/commands/efi/lsefi.c155
-rw-r--r--grub-core/commands/efi/lsefimmap.c160
-rw-r--r--grub-core/commands/efi/lsefisystab.c125
-rw-r--r--grub-core/commands/efi/lssal.c169
-rw-r--r--grub-core/commands/efi/smbios.c61
-rw-r--r--grub-core/commands/efi/tpm.c241
-rw-r--r--grub-core/commands/eval.c71
-rw-r--r--grub-core/commands/extcmd.c141
-rw-r--r--grub-core/commands/file.c694
-rw-r--r--grub-core/commands/file32.c5
-rw-r--r--grub-core/commands/file64.c5
-rw-r--r--grub-core/commands/fileXX.c74
-rw-r--r--grub-core/commands/gptsync.c266
-rw-r--r--grub-core/commands/halt.c47
-rw-r--r--grub-core/commands/hashsum.c334
-rw-r--r--grub-core/commands/hdparm.c447
-rw-r--r--grub-core/commands/help.c153
-rw-r--r--grub-core/commands/hexdump.c133
-rw-r--r--grub-core/commands/i386/cmosdump.c64
-rw-r--r--grub-core/commands/i386/cmostest.c124
-rw-r--r--grub-core/commands/i386/coreboot/cb_timestamps.c126
-rw-r--r--grub-core/commands/i386/coreboot/cbls.c143
-rw-r--r--grub-core/commands/i386/cpuid.c125
-rw-r--r--grub-core/commands/i386/pc/drivemap.c428
-rw-r--r--grub-core/commands/i386/pc/drivemap_int13h.S124
-rw-r--r--grub-core/commands/i386/pc/halt.c126
-rw-r--r--grub-core/commands/i386/pc/lsapm.c115
-rw-r--r--grub-core/commands/i386/pc/play.c197
-rw-r--r--grub-core/commands/i386/pc/sendkey.c387
-rw-r--r--grub-core/commands/i386/pc/smbios.c52
-rw-r--r--grub-core/commands/i386/rdmsr.c102
-rw-r--r--grub-core/commands/i386/wrmsr.c94
-rw-r--r--grub-core/commands/ieee1275/suspend.c51
-rw-r--r--grub-core/commands/iorw.c156
-rw-r--r--grub-core/commands/keylayouts.c307
-rw-r--r--grub-core/commands/keystatus.c95
-rw-r--r--grub-core/commands/legacycfg.c912
-rw-r--r--grub-core/commands/loadenv.c470
-rw-r--r--grub-core/commands/ls.c302
-rw-r--r--grub-core/commands/lsacpi.c314
-rw-r--r--grub-core/commands/lsmmap.c85
-rw-r--r--grub-core/commands/lspci.c238
-rw-r--r--grub-core/commands/macbless.c235
-rw-r--r--grub-core/commands/memrw.c158
-rw-r--r--grub-core/commands/menuentry.c337
-rw-r--r--grub-core/commands/minicmd.c227
-rw-r--r--grub-core/commands/mips/loongson/lsspd.c103
-rw-r--r--grub-core/commands/nativedisk.c332
-rw-r--r--grub-core/commands/parttool.c357
-rw-r--r--grub-core/commands/password.c93
-rw-r--r--grub-core/commands/password_pbkdf2.c209
-rw-r--r--grub-core/commands/pcidump.c174
-rw-r--r--grub-core/commands/pgp.c1018
-rw-r--r--grub-core/commands/probe.c225
-rw-r--r--grub-core/commands/read.c92
-rw-r--r--grub-core/commands/reboot.c46
-rw-r--r--grub-core/commands/regexp.c168
-rw-r--r--grub-core/commands/search.c337
-rw-r--r--grub-core/commands/search_file.c5
-rw-r--r--grub-core/commands/search_label.c5
-rw-r--r--grub-core/commands/search_uuid.c5
-rw-r--r--grub-core/commands/search_wrap.c220
-rw-r--r--grub-core/commands/setpci.c340
-rw-r--r--grub-core/commands/sleep.c117
-rw-r--r--grub-core/commands/smbios.c398
-rw-r--r--grub-core/commands/syslinuxcfg.c217
-rw-r--r--grub-core/commands/terminal.c285
-rw-r--r--grub-core/commands/test.c455
-rw-r--r--grub-core/commands/testload.c170
-rw-r--r--grub-core/commands/testspeed.c115
-rw-r--r--grub-core/commands/time.c68
-rw-r--r--grub-core/commands/tpm.c95
-rw-r--r--grub-core/commands/tr.c126
-rw-r--r--grub-core/commands/true.c61
-rw-r--r--grub-core/commands/usbtest.c227
-rw-r--r--grub-core/commands/videoinfo.c262
-rw-r--r--grub-core/commands/videotest.c241
-rw-r--r--grub-core/commands/wildcard.c652
-rw-r--r--grub-core/commands/xen/lsxen.c90
-rw-r--r--grub-core/commands/xnu_uuid.c119
-rw-r--r--grub-core/disk/AFSplitter.c95
-rw-r--r--grub-core/disk/ahci.c1163
-rw-r--r--grub-core/disk/arc/arcdisk.c325
-rw-r--r--grub-core/disk/ata.c685
-rw-r--r--grub-core/disk/cryptodisk.c1331
-rw-r--r--grub-core/disk/diskfilter.c1351
-rw-r--r--grub-core/disk/dmraid_nvidia.c196
-rw-r--r--grub-core/disk/efi/efidisk.c902
-rw-r--r--grub-core/disk/geli.c595
-rw-r--r--grub-core/disk/host.c103
-rw-r--r--grub-core/disk/i386/pc/biosdisk.c688
-rw-r--r--grub-core/disk/ieee1275/nand.c242
-rw-r--r--grub-core/disk/ieee1275/obdisk.c1076
-rw-r--r--grub-core/disk/ieee1275/ofdisk.c741
-rw-r--r--grub-core/disk/ldm.c1110
-rw-r--r--grub-core/disk/loopback.c240
-rw-r--r--grub-core/disk/luks.c329
-rw-r--r--grub-core/disk/luks2.c791
-rw-r--r--grub-core/disk/lvm.c1091
-rw-r--r--grub-core/disk/mdraid1x_linux.c233
-rw-r--r--grub-core/disk/mdraid_linux.c298
-rw-r--r--grub-core/disk/mdraid_linux_be.c2
-rw-r--r--grub-core/disk/memdisk.c116
-rw-r--r--grub-core/disk/pata.c556
-rw-r--r--grub-core/disk/raid5_recover.c76
-rw-r--r--grub-core/disk/raid6_recover.c218
-rw-r--r--grub-core/disk/scsi.c766
-rw-r--r--grub-core/disk/uboot/ubootdisk.c307
-rw-r--r--grub-core/disk/usbms.c660
-rw-r--r--grub-core/disk/xen/xendisk.c485
-rw-r--r--grub-core/efiemu/i386/coredetect.c27
-rw-r--r--grub-core/efiemu/i386/loadcore32.c121
-rw-r--r--grub-core/efiemu/i386/loadcore64.c138
-rw-r--r--grub-core/efiemu/i386/nocfgtables.c30
-rw-r--r--grub-core/efiemu/i386/pc/cfgtables.c69
-rw-r--r--grub-core/efiemu/loadcore.c387
-rw-r--r--grub-core/efiemu/loadcore32.c22
-rw-r--r--grub-core/efiemu/loadcore64.c22
-rw-r--r--grub-core/efiemu/loadcore_common.c196
-rw-r--r--grub-core/efiemu/main.c328
-rw-r--r--grub-core/efiemu/mm.c677
-rw-r--r--grub-core/efiemu/pnvram.c269
-rw-r--r--grub-core/efiemu/prepare.c169
-rw-r--r--grub-core/efiemu/prepare32.c22
-rw-r--r--grub-core/efiemu/prepare64.c22
-rw-r--r--grub-core/efiemu/runtime/config.h36
-rw-r--r--grub-core/efiemu/runtime/efiemu.S159
-rw-r--r--grub-core/efiemu/runtime/efiemu.c636
-rw-r--r--grub-core/efiemu/symbols.c272
-rw-r--r--grub-core/font/font.c1611
-rw-r--r--grub-core/font/font_cmd.c92
-rw-r--r--grub-core/fs/affs.c709
-rw-r--r--grub-core/fs/afs.c3
-rw-r--r--grub-core/fs/archelp.c301
-rw-r--r--grub-core/fs/bfs.c1117
-rw-r--r--grub-core/fs/btrfs.c2216
-rw-r--r--grub-core/fs/cbfs.c402
-rw-r--r--grub-core/fs/cpio.c61
-rw-r--r--grub-core/fs/cpio_be.c61
-rw-r--r--grub-core/fs/cpio_common.c253
-rw-r--r--grub-core/fs/exfat.c2
-rw-r--r--grub-core/fs/ext2.c1107
-rw-r--r--grub-core/fs/f2fs.c1328
-rw-r--r--grub-core/fs/fat.c1329
-rw-r--r--grub-core/fs/fshelp.c441
-rw-r--r--grub-core/fs/hfs.c1446
-rw-r--r--grub-core/fs/hfsplus.c1160
-rw-r--r--grub-core/fs/hfspluscomp.c317
-rw-r--r--grub-core/fs/iso9660.c1162
-rw-r--r--grub-core/fs/jfs.c973
-rw-r--r--grub-core/fs/minix.c758
-rw-r--r--grub-core/fs/minix2.c2
-rw-r--r--grub-core/fs/minix2_be.c3
-rw-r--r--grub-core/fs/minix3.c2
-rw-r--r--grub-core/fs/minix3_be.c3
-rw-r--r--grub-core/fs/minix_be.c2
-rw-r--r--grub-core/fs/newc.c73
-rw-r--r--grub-core/fs/nilfs2.c1241
-rw-r--r--grub-core/fs/ntfs.c1237
-rw-r--r--grub-core/fs/ntfscomp.c443
-rw-r--r--grub-core/fs/odc.c61
-rw-r--r--grub-core/fs/proc.c203
-rw-r--r--grub-core/fs/reiserfs.c1427
-rw-r--r--grub-core/fs/romfs.c484
-rw-r--r--grub-core/fs/sfs.c789
-rw-r--r--grub-core/fs/squash4.c1042
-rw-r--r--grub-core/fs/tar.c345
-rw-r--r--grub-core/fs/udf.c1392
-rw-r--r--grub-core/fs/ufs.c918
-rw-r--r--grub-core/fs/ufs2.c3
-rw-r--r--grub-core/fs/ufs_be.c2
-rw-r--r--grub-core/fs/xfs.c1211
-rw-r--r--grub-core/fs/zfs/zfs.c4406
-rw-r--r--grub-core/fs/zfs/zfs_fletcher.c84
-rw-r--r--grub-core/fs/zfs/zfs_lz4.c285
-rw-r--r--grub-core/fs/zfs/zfs_lzjb.c93
-rw-r--r--grub-core/fs/zfs/zfs_sha256.c143
-rw-r--r--grub-core/fs/zfs/zfscrypt.c491
-rw-r--r--grub-core/fs/zfs/zfsinfo.c441
-rw-r--r--grub-core/gdb/cstub.c366
-rw-r--r--grub-core/gdb/gdb.c104
-rw-r--r--grub-core/gdb/i386/idt.c78
-rw-r--r--grub-core/gdb/i386/machdep.S245
-rw-r--r--grub-core/gdb/i386/signal.c53
-rw-r--r--grub-core/gdb_grub.in85
-rw-r--r--grub-core/genemuinit.sh72
-rw-r--r--grub-core/genemuinitheader.sh52
-rw-r--r--grub-core/genmod.sh.in103
-rw-r--r--grub-core/genmoddep.awk102
-rw-r--r--grub-core/gensyminfo.sh.in37
-rw-r--r--grub-core/gensymlist.sh73
-rw-r--r--grub-core/gentrigtables.c57
-rw-r--r--grub-core/gettext/gettext.c542
-rw-r--r--grub-core/gfxmenu/font.c116
-rw-r--r--grub-core/gfxmenu/gfxmenu.c150
-rw-r--r--grub-core/gfxmenu/gui_box.c428
-rw-r--r--grub-core/gfxmenu/gui_canvas.c278
-rw-r--r--grub-core/gfxmenu/gui_circular_progress.c331
-rw-r--r--grub-core/gfxmenu/gui_image.c270
-rw-r--r--grub-core/gfxmenu/gui_label.c277
-rw-r--r--grub-core/gfxmenu/gui_list.c953
-rw-r--r--grub-core/gfxmenu/gui_progress_bar.c457
-rw-r--r--grub-core/gfxmenu/gui_string_util.c206
-rw-r--r--grub-core/gfxmenu/gui_util.c101
-rw-r--r--grub-core/gfxmenu/icon_manager.c257
-rw-r--r--grub-core/gfxmenu/theme_loader.c828
-rw-r--r--grub-core/gfxmenu/view.c647
-rw-r--r--grub-core/gfxmenu/widget-box.c360
-rw-r--r--grub-core/gmodule.pl.in30
-rw-r--r--grub-core/hello/hello.c51
-rw-r--r--grub-core/hook/datehook.c110
-rw-r--r--grub-core/io/bufio.c214
-rw-r--r--grub-core/io/gzio.c1444
-rw-r--r--grub-core/io/lzopio.c546
-rw-r--r--grub-core/io/offset.c112
-rw-r--r--grub-core/io/xzio.c346
-rw-r--r--grub-core/kern/acpi.c119
-rw-r--r--grub-core/kern/arm/cache.S123
-rw-r--r--grub-core/kern/arm/cache.c311
-rw-r--r--grub-core/kern/arm/cache_armv6.S72
-rw-r--r--grub-core/kern/arm/cache_armv7.S138
-rw-r--r--grub-core/kern/arm/compiler-rt.S86
-rw-r--r--grub-core/kern/arm/coreboot/cbtable.c40
-rw-r--r--grub-core/kern/arm/coreboot/coreboot.S44
-rw-r--r--grub-core/kern/arm/coreboot/dma.c59
-rw-r--r--grub-core/kern/arm/coreboot/init.c151
-rw-r--r--grub-core/kern/arm/coreboot/timer.c101
-rw-r--r--grub-core/kern/arm/dl.c280
-rw-r--r--grub-core/kern/arm/dl_helper.c245
-rw-r--r--grub-core/kern/arm/efi/init.c77
-rw-r--r--grub-core/kern/arm/efi/startup.S36
-rw-r--r--grub-core/kern/arm/startup.S177
-rw-r--r--grub-core/kern/arm/uboot/init.c70
-rw-r--r--grub-core/kern/arm/uboot/uboot.S73
-rw-r--r--grub-core/kern/arm64/cache.c63
-rw-r--r--grub-core/kern/arm64/cache_flush.S55
-rw-r--r--grub-core/kern/arm64/dl.c198
-rw-r--r--grub-core/kern/arm64/dl_helper.c134
-rw-r--r--grub-core/kern/arm64/efi/init.c63
-rw-r--r--grub-core/kern/arm64/efi/startup.S39
-rw-r--r--grub-core/kern/buffer.c117
-rw-r--r--grub-core/kern/command.c111
-rw-r--r--grub-core/kern/compiler-rt.c464
-rw-r--r--grub-core/kern/coreboot/cbtable.c72
-rw-r--r--grub-core/kern/coreboot/mmap.c100
-rw-r--r--grub-core/kern/corecmd.c189
-rw-r--r--grub-core/kern/device.c191
-rw-r--r--grub-core/kern/disk.c544
-rw-r--r--grub-core/kern/disk_common.c66
-rw-r--r--grub-core/kern/dl.c825
-rw-r--r--grub-core/kern/efi/acpi.c59
-rw-r--r--grub-core/kern/efi/efi.c1017
-rw-r--r--grub-core/kern/efi/fdt.c43
-rw-r--r--grub-core/kern/efi/init.c149
-rw-r--r--grub-core/kern/efi/mm.c691
-rw-r--r--grub-core/kern/efi/sb.c188
-rw-r--r--grub-core/kern/elf.c212
-rw-r--r--grub-core/kern/elfXX.c207
-rw-r--r--grub-core/kern/emu/argp_common.c41
-rw-r--r--grub-core/kern/emu/cache.c35
-rw-r--r--grub-core/kern/emu/cache_s.S15
-rw-r--r--grub-core/kern/emu/full.c69
-rw-r--r--grub-core/kern/emu/hostdisk.c686
-rw-r--r--grub-core/kern/emu/hostfs.c200
-rw-r--r--grub-core/kern/emu/lite.c47
-rw-r--r--grub-core/kern/emu/main.c286
-rw-r--r--grub-core/kern/emu/misc.c216
-rw-r--r--grub-core/kern/emu/mm.c75
-rw-r--r--grub-core/kern/emu/time.c46
-rw-r--r--grub-core/kern/env.c238
-rw-r--r--grub-core/kern/err.c122
-rw-r--r--grub-core/kern/file.c218
-rw-r--r--grub-core/kern/fs.c253
-rw-r--r--grub-core/kern/generic/millisleep.c39
-rw-r--r--grub-core/kern/generic/rtc_get_time_ms.c38
-rw-r--r--grub-core/kern/i386/coreboot/cbtable.c44
-rw-r--r--grub-core/kern/i386/coreboot/init.c143
-rw-r--r--grub-core/kern/i386/coreboot/startup.S62
-rw-r--r--grub-core/kern/i386/dl.c81
-rw-r--r--grub-core/kern/i386/efi/init.c48
-rw-r--r--grub-core/kern/i386/efi/startup.S36
-rw-r--r--grub-core/kern/i386/efi/tsc.c40
-rw-r--r--grub-core/kern/i386/ieee1275/startup.S40
-rw-r--r--grub-core/kern/i386/int.S134
-rw-r--r--grub-core/kern/i386/multiboot_mmap.c73
-rw-r--r--grub-core/kern/i386/pc/acpi.c83
-rw-r--r--grub-core/kern/i386/pc/init.c271
-rw-r--r--grub-core/kern/i386/pc/mmap.c193
-rw-r--r--grub-core/kern/i386/pc/startup.S217
-rw-r--r--grub-core/kern/i386/qemu/init.c276
-rw-r--r--grub-core/kern/i386/qemu/mmap.c107
-rw-r--r--grub-core/kern/i386/qemu/startup.S75
-rw-r--r--grub-core/kern/i386/realmode.S281
-rw-r--r--grub-core/kern/i386/tsc.c78
-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/hypercall.S43
-rw-r--r--grub-core/kern/i386/xen/pvh.c369
-rw-r--r--grub-core/kern/i386/xen/startup.S38
-rw-r--r--grub-core/kern/i386/xen/startup_pvh.S81
-rw-r--r--grub-core/kern/i386/xen/tsc.c40
-rw-r--r--grub-core/kern/ia64/cache.c35
-rw-r--r--grub-core/kern/ia64/dl.c150
-rw-r--r--grub-core/kern/ia64/dl_helper.c241
-rw-r--r--grub-core/kern/ia64/efi/init.c80
-rw-r--r--grub-core/kern/ia64/efi/startup.S44
-rw-r--r--grub-core/kern/ieee1275/cmain.c220
-rw-r--r--grub-core/kern/ieee1275/ieee1275.c809
-rw-r--r--grub-core/kern/ieee1275/init.c322
-rw-r--r--grub-core/kern/ieee1275/mmap.c83
-rw-r--r--grub-core/kern/ieee1275/openfw.c593
-rw-r--r--grub-core/kern/list.c55
-rw-r--r--grub-core/kern/lockdown.c84
-rw-r--r--grub-core/kern/main.c316
-rw-r--r--grub-core/kern/mips/arc/init.c463
-rw-r--r--grub-core/kern/mips/cache.S70
-rw-r--r--grub-core/kern/mips/cache_flush.S54
-rw-r--r--grub-core/kern/mips/dl.c274
-rw-r--r--grub-core/kern/mips/init.c38
-rw-r--r--grub-core/kern/mips/loongson/init.c320
-rw-r--r--grub-core/kern/mips/qemu_mips/init.c105
-rw-r--r--grub-core/kern/mips/startup.S126
-rw-r--r--grub-core/kern/misc.c1267
-rw-r--r--grub-core/kern/mm.c664
-rw-r--r--grub-core/kern/parser.c342
-rw-r--r--grub-core/kern/partition.c279
-rw-r--r--grub-core/kern/powerpc/cache.S26
-rw-r--r--grub-core/kern/powerpc/cache_flush.S43
-rw-r--r--grub-core/kern/powerpc/compiler-rt.S130
-rw-r--r--grub-core/kern/powerpc/dl.c169
-rw-r--r--grub-core/kern/powerpc/ieee1275/startup.S67
-rw-r--r--grub-core/kern/rescue_parser.c84
-rw-r--r--grub-core/kern/rescue_reader.c98
-rw-r--r--grub-core/kern/riscv/cache.c63
-rw-r--r--grub-core/kern/riscv/cache_flush.S44
-rw-r--r--grub-core/kern/riscv/dl.c345
-rw-r--r--grub-core/kern/riscv/efi/init.c79
-rw-r--r--grub-core/kern/riscv/efi/startup.S48
-rw-r--r--grub-core/kern/sparc64/cache.S41
-rw-r--r--grub-core/kern/sparc64/dl.c191
-rw-r--r--grub-core/kern/sparc64/ieee1275/crt0.S104
-rw-r--r--grub-core/kern/sparc64/ieee1275/ieee1275.c147
-rw-r--r--grub-core/kern/term.c169
-rw-r--r--grub-core/kern/time.c37
-rw-r--r--grub-core/kern/uboot/hw.c112
-rw-r--r--grub-core/kern/uboot/init.c172
-rw-r--r--grub-core/kern/uboot/uboot.c307
-rw-r--r--grub-core/kern/verifiers.c228
-rw-r--r--grub-core/kern/vga_init.c128
-rw-r--r--grub-core/kern/x86_64/dl.c121
-rw-r--r--grub-core/kern/x86_64/efi/callwrap.S129
-rw-r--r--grub-core/kern/x86_64/efi/startup.S35
-rw-r--r--grub-core/kern/x86_64/xen/hypercall.S53
-rw-r--r--grub-core/kern/x86_64/xen/startup.S39
-rw-r--r--grub-core/kern/xen/init.c601
-rw-r--r--grub-core/lib/LzFind.c777
-rw-r--r--grub-core/lib/LzmaDec.c1037
-rw-r--r--grub-core/lib/LzmaEnc.c2250
-rw-r--r--grub-core/lib/adler32.c102
-rw-r--r--grub-core/lib/arc/datetime.c48
-rw-r--r--grub-core/lib/arg.c492
-rw-r--r--grub-core/lib/arm/setjmp.S53
-rw-r--r--grub-core/lib/arm64/setjmp.S56
-rw-r--r--grub-core/lib/backtrace.c70
-rw-r--r--grub-core/lib/cmdline.c109
-rw-r--r--grub-core/lib/cmos_datetime.c194
-rw-r--r--grub-core/lib/crc.c76
-rw-r--r--grub-core/lib/crc64.c114
-rw-r--r--grub-core/lib/crypto.c493
-rw-r--r--grub-core/lib/datetime.c117
-rw-r--r--grub-core/lib/disk.c161
-rw-r--r--grub-core/lib/division.c74
-rw-r--r--grub-core/lib/dummy/datetime.c40
-rw-r--r--grub-core/lib/dummy/halt.c32
-rw-r--r--grub-core/lib/dummy/reboot.c32
-rw-r--r--grub-core/lib/efi/datetime.c82
-rw-r--r--grub-core/lib/efi/halt.c41
-rw-r--r--grub-core/lib/efi/relocator.c119
-rw-r--r--grub-core/lib/emu/halt.c25
-rw-r--r--grub-core/lib/envblk.c297
-rw-r--r--grub-core/lib/fake_module.c4
-rw-r--r--grub-core/lib/fdt.c531
-rw-r--r--grub-core/lib/getline.c92
-rw-r--r--grub-core/lib/gnulib-patches/fix-base64.patch21
-rw-r--r--grub-core/lib/gnulib-patches/fix-null-deref.patch13
-rw-r--r--grub-core/lib/gnulib-patches/fix-null-state-deref.patch12
-rw-r--r--grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch15
-rw-r--r--grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch12
-rw-r--r--grub-core/lib/gnulib-patches/fix-uninit-structure.patch11
-rw-r--r--grub-core/lib/gnulib-patches/fix-unused-value.patch14
-rw-r--r--grub-core/lib/gnulib-patches/fix-width.patch217
-rw-r--r--grub-core/lib/gnulib-patches/no-abort.patch26
-rw-r--r--grub-core/lib/gnulib/Makefile.am2221
-rw-r--r--grub-core/lib/gnulib/Makefile.in3071
-rw-r--r--grub-core/lib/gnulib/_Noreturn.h14
-rw-r--r--grub-core/lib/gnulib/alloca.c478
-rw-r--r--grub-core/lib/gnulib/alloca.in.h65
-rw-r--r--grub-core/lib/gnulib/arg-nonnull.h26
-rw-r--r--grub-core/lib/gnulib/argp-ba.c34
-rw-r--r--grub-core/lib/gnulib/argp-eexst.c30
-rw-r--r--grub-core/lib/gnulib/argp-fmtstream.c488
-rw-r--r--grub-core/lib/gnulib/argp-fmtstream.h310
-rw-r--r--grub-core/lib/gnulib/argp-fs-xinl.c46
-rw-r--r--grub-core/lib/gnulib/argp-help.c1912
-rw-r--r--grub-core/lib/gnulib/argp-namefrob.h157
-rw-r--r--grub-core/lib/gnulib/argp-parse.c957
-rw-r--r--grub-core/lib/gnulib/argp-pin.c33
-rw-r--r--grub-core/lib/gnulib/argp-pv.c33
-rw-r--r--grub-core/lib/gnulib/argp-pvh.c30
-rw-r--r--grub-core/lib/gnulib/argp-xinl.c46
-rw-r--r--grub-core/lib/gnulib/argp.h631
-rw-r--r--grub-core/lib/gnulib/asnprintf.c34
-rw-r--r--grub-core/lib/gnulib/assure.h37
-rw-r--r--grub-core/lib/gnulib/base64.c605
-rw-r--r--grub-core/lib/gnulib/base64.h74
-rw-r--r--grub-core/lib/gnulib/basename-lgpl.c75
-rw-r--r--grub-core/lib/gnulib/btowc.c39
-rw-r--r--grub-core/lib/gnulib/c++defs.h316
-rw-r--r--grub-core/lib/gnulib/cdefs.h514
-rw-r--r--grub-core/lib/gnulib/chdir-long.c264
-rw-r--r--grub-core/lib/gnulib/chdir-long.h30
-rw-r--r--grub-core/lib/gnulib/cloexec.c83
-rw-r--r--grub-core/lib/gnulib/cloexec.h38
-rw-r--r--grub-core/lib/gnulib/close.c71
-rw-r--r--grub-core/lib/gnulib/dirent.in.h267
-rw-r--r--grub-core/lib/gnulib/dirfd.c98
-rw-r--r--grub-core/lib/gnulib/dirname-lgpl.c86
-rw-r--r--grub-core/lib/gnulib/dirname.h54
-rw-r--r--grub-core/lib/gnulib/dosname.h52
-rw-r--r--grub-core/lib/gnulib/dup-safer-flag.c38
-rw-r--r--grub-core/lib/gnulib/dup-safer.c34
-rw-r--r--grub-core/lib/gnulib/dup2.c235
-rw-r--r--grub-core/lib/gnulib/errno.in.h279
-rw-r--r--grub-core/lib/gnulib/error.c411
-rw-r--r--grub-core/lib/gnulib/error.h75
-rw-r--r--grub-core/lib/gnulib/exitfail.c24
-rw-r--r--grub-core/lib/gnulib/exitfail.h18
-rw-r--r--grub-core/lib/gnulib/fchdir.c208
-rw-r--r--grub-core/lib/gnulib/fcntl.c626
-rw-r--r--grub-core/lib/gnulib/fcntl.in.h366
-rw-r--r--grub-core/lib/gnulib/fd-hook.c116
-rw-r--r--grub-core/lib/gnulib/fd-hook.h119
-rw-r--r--grub-core/lib/gnulib/fd-safer-flag.c52
-rw-r--r--grub-core/lib/gnulib/fd-safer.c49
-rw-r--r--grub-core/lib/gnulib/filename.h54
-rw-r--r--grub-core/lib/gnulib/filenamecat-lgpl.c87
-rw-r--r--grub-core/lib/gnulib/filenamecat.h27
-rw-r--r--grub-core/lib/gnulib/flexmember.h45
-rw-r--r--grub-core/lib/gnulib/float+.h147
-rw-r--r--grub-core/lib/gnulib/float.c33
-rw-r--r--grub-core/lib/gnulib/float.in.h188
-rw-r--r--grub-core/lib/gnulib/fnmatch.c356
-rw-r--r--grub-core/lib/gnulib/fnmatch.in.h110
-rw-r--r--grub-core/lib/gnulib/fnmatch_loop.c1217
-rw-r--r--grub-core/lib/gnulib/fstat.c90
-rw-r--r--grub-core/lib/gnulib/getcwd-lgpl.c126
-rw-r--r--grub-core/lib/gnulib/getdelim.c147
-rw-r--r--grub-core/lib/gnulib/getdtablesize.c124
-rw-r--r--grub-core/lib/gnulib/getline.c27
-rw-r--r--grub-core/lib/gnulib/getopt-cdefs.in.h67
-rw-r--r--grub-core/lib/gnulib/getopt-core.h96
-rw-r--r--grub-core/lib/gnulib/getopt-ext.h77
-rw-r--r--grub-core/lib/gnulib/getopt-pfx-core.h59
-rw-r--r--grub-core/lib/gnulib/getopt-pfx-ext.h71
-rw-r--r--grub-core/lib/gnulib/getopt.c811
-rw-r--r--grub-core/lib/gnulib/getopt.in.h61
-rw-r--r--grub-core/lib/gnulib/getopt1.c159
-rw-r--r--grub-core/lib/gnulib/getopt_int.h118
-rw-r--r--grub-core/lib/gnulib/getprogname.c255
-rw-r--r--grub-core/lib/gnulib/getprogname.h40
-rw-r--r--grub-core/lib/gnulib/gettext.h294
-rw-r--r--grub-core/lib/gnulib/glthread/lock.c1221
-rw-r--r--grub-core/lib/gnulib/glthread/lock.h988
-rw-r--r--grub-core/lib/gnulib/glthread/threadlib.c73
-rw-r--r--grub-core/lib/gnulib/hard-locale.c72
-rw-r--r--grub-core/lib/gnulib/hard-locale.h25
-rw-r--r--grub-core/lib/gnulib/intprops.h455
-rw-r--r--grub-core/lib/gnulib/itold.c28
-rw-r--r--grub-core/lib/gnulib/langinfo.in.h222
-rw-r--r--grub-core/lib/gnulib/libc-config.h174
-rw-r--r--grub-core/lib/gnulib/limits.in.h104
-rw-r--r--grub-core/lib/gnulib/localcharset.c996
-rw-r--r--grub-core/lib/gnulib/localcharset.h134
-rw-r--r--grub-core/lib/gnulib/locale.in.h272
-rw-r--r--grub-core/lib/gnulib/localeconv.c103
-rw-r--r--grub-core/lib/gnulib/malloc.c56
-rw-r--r--grub-core/lib/gnulib/malloca.c105
-rw-r--r--grub-core/lib/gnulib/malloca.h127
-rw-r--r--grub-core/lib/gnulib/mbrtowc.c458
-rw-r--r--grub-core/lib/gnulib/mbsinit.c73
-rw-r--r--grub-core/lib/gnulib/mbsrtowcs-impl.h122
-rw-r--r--grub-core/lib/gnulib/mbsrtowcs-state.c37
-rw-r--r--grub-core/lib/gnulib/mbsrtowcs.c32
-rw-r--r--grub-core/lib/gnulib/mbswidth.c208
-rw-r--r--grub-core/lib/gnulib/mbswidth.h64
-rw-r--r--grub-core/lib/gnulib/mbtowc-impl.h44
-rw-r--r--grub-core/lib/gnulib/mbtowc.c26
-rw-r--r--grub-core/lib/gnulib/memchr.c172
-rw-r--r--grub-core/lib/gnulib/memchr.valgrind14
-rw-r--r--grub-core/lib/gnulib/mempcpy.c28
-rw-r--r--grub-core/lib/gnulib/memrchr.c161
-rw-r--r--grub-core/lib/gnulib/msvc-inval.c129
-rw-r--r--grub-core/lib/gnulib/msvc-inval.h222
-rw-r--r--grub-core/lib/gnulib/msvc-nothrow.c51
-rw-r--r--grub-core/lib/gnulib/msvc-nothrow.h43
-rw-r--r--grub-core/lib/gnulib/nl_langinfo.c366
-rw-r--r--grub-core/lib/gnulib/open.c208
-rw-r--r--grub-core/lib/gnulib/openat-die.c62
-rw-r--r--grub-core/lib/gnulib/openat-priv.h64
-rw-r--r--grub-core/lib/gnulib/openat-proc.c134
-rw-r--r--grub-core/lib/gnulib/openat.c314
-rw-r--r--grub-core/lib/gnulib/openat.h123
-rw-r--r--grub-core/lib/gnulib/pathmax.h83
-rw-r--r--grub-core/lib/gnulib/pipe-safer.c56
-rw-r--r--grub-core/lib/gnulib/printf-args.c187
-rw-r--r--grub-core/lib/gnulib/printf-args.h158
-rw-r--r--grub-core/lib/gnulib/printf-parse.c638
-rw-r--r--grub-core/lib/gnulib/printf-parse.h193
-rw-r--r--grub-core/lib/gnulib/progname.c92
-rw-r--r--grub-core/lib/gnulib/progname.h62
-rw-r--r--grub-core/lib/gnulib/rawmemchr.c136
-rw-r--r--grub-core/lib/gnulib/rawmemchr.valgrind12
-rw-r--r--grub-core/lib/gnulib/realloc.c79
-rw-r--r--grub-core/lib/gnulib/regcomp.c3930
-rw-r--r--grub-core/lib/gnulib/regex.c81
-rw-r--r--grub-core/lib/gnulib/regex.h658
-rw-r--r--grub-core/lib/gnulib/regex_internal.c1746
-rw-r--r--grub-core/lib/gnulib/regex_internal.h874
-rw-r--r--grub-core/lib/gnulib/regexec.c4341
-rw-r--r--grub-core/lib/gnulib/save-cwd.c97
-rw-r--r--grub-core/lib/gnulib/save-cwd.h34
-rw-r--r--grub-core/lib/gnulib/size_max.h30
-rw-r--r--grub-core/lib/gnulib/sleep.c76
-rw-r--r--grub-core/lib/gnulib/stat-time.c3
-rw-r--r--grub-core/lib/gnulib/stat-time.h252
-rw-r--r--grub-core/lib/gnulib/stat-w32.c425
-rw-r--r--grub-core/lib/gnulib/stat-w32.h37
-rw-r--r--grub-core/lib/gnulib/stat.c429
-rw-r--r--grub-core/lib/gnulib/stdalign.in.h121
-rw-r--r--grub-core/lib/gnulib/stdbool.in.h132
-rw-r--r--grub-core/lib/gnulib/stddef.in.h114
-rw-r--r--grub-core/lib/gnulib/stdint.in.h726
-rw-r--r--grub-core/lib/gnulib/stdio.in.h1377
-rw-r--r--grub-core/lib/gnulib/stdlib.in.h1013
-rw-r--r--grub-core/lib/gnulib/strcasecmp.c62
-rw-r--r--grub-core/lib/gnulib/strchrnul.c142
-rw-r--r--grub-core/lib/gnulib/strchrnul.valgrind12
-rw-r--r--grub-core/lib/gnulib/strdup.c54
-rw-r--r--grub-core/lib/gnulib/streq.h176
-rw-r--r--grub-core/lib/gnulib/strerror-override.c302
-rw-r--r--grub-core/lib/gnulib/strerror-override.h56
-rw-r--r--grub-core/lib/gnulib/strerror.c71
-rw-r--r--grub-core/lib/gnulib/string.in.h1063
-rw-r--r--grub-core/lib/gnulib/strings.in.h122
-rw-r--r--grub-core/lib/gnulib/stripslash.c45
-rw-r--r--grub-core/lib/gnulib/strncasecmp.c62
-rw-r--r--grub-core/lib/gnulib/strndup.c36
-rw-r--r--grub-core/lib/gnulib/strnlen.c30
-rw-r--r--grub-core/lib/gnulib/strnlen1.c35
-rw-r--r--grub-core/lib/gnulib/strnlen1.h40
-rw-r--r--grub-core/lib/gnulib/sys_stat.in.h816
-rw-r--r--grub-core/lib/gnulib/sys_types.in.h106
-rw-r--r--grub-core/lib/gnulib/sysexits.in.h72
-rw-r--r--grub-core/lib/gnulib/time.in.h350
-rw-r--r--grub-core/lib/gnulib/unistd--.h32
-rw-r--r--grub-core/lib/gnulib/unistd-safer.h31
-rw-r--r--grub-core/lib/gnulib/unistd.c4
-rw-r--r--grub-core/lib/gnulib/unistd.in.h1668
-rw-r--r--grub-core/lib/gnulib/unitypes.in.h46
-rw-r--r--grub-core/lib/gnulib/uniwidth.in.h72
-rw-r--r--grub-core/lib/gnulib/uniwidth/cjk.h37
-rw-r--r--grub-core/lib/gnulib/uniwidth/width.c468
-rw-r--r--grub-core/lib/gnulib/vasnprintf.c5621
-rw-r--r--grub-core/lib/gnulib/vasnprintf.h79
-rw-r--r--grub-core/lib/gnulib/verify.h285
-rw-r--r--grub-core/lib/gnulib/vsnprintf.c70
-rw-r--r--grub-core/lib/gnulib/warn-on-use.h131
-rw-r--r--grub-core/lib/gnulib/wchar.in.h1072
-rw-r--r--grub-core/lib/gnulib/wcrtomb.c53
-rw-r--r--grub-core/lib/gnulib/wctype-h.c4
-rw-r--r--grub-core/lib/gnulib/wctype.in.h533
-rw-r--r--grub-core/lib/gnulib/wcwidth.c73
-rw-r--r--grub-core/lib/gnulib/xalloc-oversized.h60
-rw-r--r--grub-core/lib/gnulib/xsize.c3
-rw-r--r--grub-core/lib/gnulib/xsize.h117
-rw-r--r--grub-core/lib/hexdump.c85
-rw-r--r--grub-core/lib/i386/backtrace.c66
-rw-r--r--grub-core/lib/i386/halt.c82
-rw-r--r--grub-core/lib/i386/pc/biosnum.c47
-rw-r--r--grub-core/lib/i386/pc/vesa_modes_table.c127
-rw-r--r--grub-core/lib/i386/random.c103
-rw-r--r--grub-core/lib/i386/reboot.c64
-rw-r--r--grub-core/lib/i386/reboot_trampoline.S34
-rw-r--r--grub-core/lib/i386/relocator.c210
-rw-r--r--grub-core/lib/i386/relocator16.S341
-rw-r--r--grub-core/lib/i386/relocator32.S134
-rw-r--r--grub-core/lib/i386/relocator64.S210
-rw-r--r--grub-core/lib/i386/relocator_asm.S80
-rw-r--r--grub-core/lib/i386/relocator_common.S111
-rw-r--r--grub-core/lib/i386/relocator_common_c.c109
-rw-r--r--grub-core/lib/i386/setjmp.S59
-rw-r--r--grub-core/lib/i386/xen/relocator.S165
-rw-r--r--grub-core/lib/ia64/longjmp.S162
-rw-r--r--grub-core/lib/ia64/setjmp.S177
-rw-r--r--grub-core/lib/ieee1275/cmos.c77
-rw-r--r--grub-core/lib/ieee1275/datetime.c156
-rw-r--r--grub-core/lib/ieee1275/halt.c33
-rw-r--r--grub-core/lib/ieee1275/reboot.c27
-rw-r--r--grub-core/lib/ieee1275/relocator.c114
-rw-r--r--grub-core/lib/json/jsmn.h471
-rw-r--r--grub-core/lib/json/json.c264
-rw-r--r--grub-core/lib/json/json.h128
-rw-r--r--grub-core/lib/legacy_parse.c875
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/ChangeLog4357
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/arcfour.c143
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/bithelp.h57
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/blowfish.c592
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/bufhelp.h435
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/camellia-glue.c211
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/camellia.c1463
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/camellia.h94
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/cast5.c590
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/cipher.h2
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/crc.c826
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/crypto.lst45
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/des.c929
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/dsa.c292
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/g10lib.h1
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/hash-common.h36
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/idea.c322
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/init.c91
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/md4.c344
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/md5.c372
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/memory.h1
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/rfc2268.c285
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/rijndael-tables.h1689
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/rijndael.c1478
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/rmd.h39
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/rmd160.c565
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/rsa.c395
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/seed.c461
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/serpent.c903
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/sha1.c419
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/sha256.c463
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/sha512.c525
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/tiger.c944
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/twofish.c1001
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/types.h2
-rw-r--r--grub-core/lib/libgcrypt-grub/cipher/whirlpool.c1422
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/Manifest29
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/distfiles11
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/mpi-asm-defs.h10
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/mpih-add1.c65
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/mpih-lshift.c68
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul1.c62
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul2.c68
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul3.c68
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/mpih-rshift.c67
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/mpih-sub1.c66
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/generic/udiv-w-sdiv.c133
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/longlong.h1615
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-add.c237
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-asm-defs.h10
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-bit.c366
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-cmp.c109
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-div.c357
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-gcd.c53
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-inline.c37
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-inline.h163
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-internal.h279
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-inv.c269
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-mod.c186
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-mpow.c225
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-mul.c214
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpi-pow.c340
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpicoder.c755
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpih-add1.c65
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpih-div.c536
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpih-lshift.c68
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpih-mul.c530
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpih-mul1.c62
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpih-mul2.c68
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpih-mul3.c68
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpih-rshift.c67
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpih-sub1.c66
-rw-r--r--grub-core/lib/libgcrypt-grub/mpi/mpiutil.c435
-rw-r--r--grub-core/lib/libgcrypt-grub/src/ath.h147
-rw-r--r--grub-core/lib/libgcrypt-grub/src/cipher-proto.h124
-rw-r--r--grub-core/lib/libgcrypt-grub/src/cipher.h182
-rw-r--r--grub-core/lib/libgcrypt-grub/src/g10lib.h302
-rw-r--r--grub-core/lib/libgcrypt-grub/src/gcrypt-module.h0
-rw-r--r--grub-core/lib/libgcrypt-grub/src/hmac256.h36
-rw-r--r--grub-core/lib/libgcrypt-grub/src/mpi.h266
-rw-r--r--grub-core/lib/libgcrypt-grub/src/secmem.h39
-rw-r--r--grub-core/lib/libgcrypt-grub/src/stdmem.h32
-rw-r--r--grub-core/lib/libgcrypt-grub/src/types.h128
-rw-r--r--grub-core/lib/libgcrypt-grub/src/visibility.h1
-rw-r--r--grub-core/lib/libgcrypt/cipher/ChangeLog3990
-rw-r--r--grub-core/lib/libgcrypt/cipher/ChangeLog-20114247
-rw-r--r--grub-core/lib/libgcrypt/cipher/Makefile.am83
-rw-r--r--grub-core/lib/libgcrypt/cipher/Manifest73
-rw-r--r--grub-core/lib/libgcrypt/cipher/ac.c3301
-rw-r--r--grub-core/lib/libgcrypt/cipher/arcfour.c155
-rw-r--r--grub-core/lib/libgcrypt/cipher/bithelp.h54
-rw-r--r--grub-core/lib/libgcrypt/cipher/blowfish.c605
-rw-r--r--grub-core/lib/libgcrypt/cipher/bufhelp.h432
-rw-r--r--grub-core/lib/libgcrypt/cipher/camellia-glue.c253
-rw-r--r--grub-core/lib/libgcrypt/cipher/camellia.c1461
-rw-r--r--grub-core/lib/libgcrypt/cipher/camellia.h81
-rw-r--r--grub-core/lib/libgcrypt/cipher/cast5.c620
-rw-r--r--grub-core/lib/libgcrypt/cipher/cipher.c2217
-rw-r--r--grub-core/lib/libgcrypt/cipher/crc.c793
-rw-r--r--grub-core/lib/libgcrypt/cipher/des.c1196
-rw-r--r--grub-core/lib/libgcrypt/cipher/dsa.c1193
-rw-r--r--grub-core/lib/libgcrypt/cipher/ecc.c1793
-rw-r--r--grub-core/lib/libgcrypt/cipher/elgamal.c845
-rw-r--r--grub-core/lib/libgcrypt/cipher/hash-common.c93
-rw-r--r--grub-core/lib/libgcrypt/cipher/hash-common.h33
-rw-r--r--grub-core/lib/libgcrypt/cipher/hmac-tests.c732
-rw-r--r--grub-core/lib/libgcrypt/cipher/idea.c378
-rw-r--r--grub-core/lib/libgcrypt/cipher/kdf.c278
-rw-r--r--grub-core/lib/libgcrypt/cipher/md.c1383
-rw-r--r--grub-core/lib/libgcrypt/cipher/md4.c327
-rw-r--r--grub-core/lib/libgcrypt/cipher/md5.c355
-rw-r--r--grub-core/lib/libgcrypt/cipher/primegen.c1861
-rw-r--r--grub-core/lib/libgcrypt/cipher/pubkey.c4212
-rw-r--r--grub-core/lib/libgcrypt/cipher/rfc2268.c344
-rw-r--r--grub-core/lib/libgcrypt/cipher/rijndael-tables.h1686
-rw-r--r--grub-core/lib/libgcrypt/cipher/rijndael.c2092
-rw-r--r--grub-core/lib/libgcrypt/cipher/rmd.h36
-rw-r--r--grub-core/lib/libgcrypt/cipher/rmd160.c572
-rw-r--r--grub-core/lib/libgcrypt/cipher/rsa.c1390
-rw-r--r--grub-core/lib/libgcrypt/cipher/seed.c478
-rw-r--r--grub-core/lib/libgcrypt/cipher/serpent.c953
-rw-r--r--grub-core/lib/libgcrypt/cipher/sha1.c477
-rw-r--r--grub-core/lib/libgcrypt/cipher/sha256.c554
-rw-r--r--grub-core/lib/libgcrypt/cipher/sha512.c629
-rw-r--r--grub-core/lib/libgcrypt/cipher/test-getrusage.c105
-rw-r--r--grub-core/lib/libgcrypt/cipher/tiger.c911
-rw-r--r--grub-core/lib/libgcrypt/cipher/twofish.c1040
-rw-r--r--grub-core/lib/libgcrypt/cipher/whirlpool.c1405
-rw-r--r--grub-core/lib/libgcrypt/mpi/ChangeLog-2011822
-rw-r--r--grub-core/lib/libgcrypt/mpi/Makefile.am177
-rw-r--r--grub-core/lib/libgcrypt/mpi/Manifest41
-rw-r--r--grub-core/lib/libgcrypt/mpi/alpha/README53
-rw-r--r--grub-core/lib/libgcrypt/mpi/alpha/distfiles11
-rw-r--r--grub-core/lib/libgcrypt/mpi/alpha/mpih-add1.S124
-rw-r--r--grub-core/lib/libgcrypt/mpi/alpha/mpih-lshift.S122
-rw-r--r--grub-core/lib/libgcrypt/mpi/alpha/mpih-mul1.S90
-rw-r--r--grub-core/lib/libgcrypt/mpi/alpha/mpih-mul2.S97
-rw-r--r--grub-core/lib/libgcrypt/mpi/alpha/mpih-mul3.S95
-rw-r--r--grub-core/lib/libgcrypt/mpi/alpha/mpih-rshift.S118
-rw-r--r--grub-core/lib/libgcrypt/mpi/alpha/mpih-sub1.S124
-rw-r--r--grub-core/lib/libgcrypt/mpi/alpha/udiv-qrnnd.S159
-rw-r--r--grub-core/lib/libgcrypt/mpi/amd64/distfiles8
-rw-r--r--grub-core/lib/libgcrypt/mpi/amd64/mpi-asm-defs.h4
-rw-r--r--grub-core/lib/libgcrypt/mpi/amd64/mpih-add1.S63
-rw-r--r--grub-core/lib/libgcrypt/mpi/amd64/mpih-lshift.S77
-rw-r--r--grub-core/lib/libgcrypt/mpi/amd64/mpih-mul1.S65
-rw-r--r--grub-core/lib/libgcrypt/mpi/amd64/mpih-mul2.S107
-rw-r--r--grub-core/lib/libgcrypt/mpi/amd64/mpih-mul3.S66
-rw-r--r--grub-core/lib/libgcrypt/mpi/amd64/mpih-rshift.S80
-rw-r--r--grub-core/lib/libgcrypt/mpi/amd64/mpih-sub1.S61
-rw-r--r--grub-core/lib/libgcrypt/mpi/config.links360
-rw-r--r--grub-core/lib/libgcrypt/mpi/ec.c721
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/Manifest29
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/distfiles11
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/mpi-asm-defs.h10
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/mpih-add1.c65
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/mpih-lshift.c68
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/mpih-mul1.c62
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/mpih-mul2.c68
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/mpih-mul3.c68
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/mpih-rshift.c67
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/mpih-sub1.c66
-rw-r--r--grub-core/lib/libgcrypt/mpi/generic/udiv-w-sdiv.c133
-rw-r--r--grub-core/lib/libgcrypt/mpi/hppa/README84
-rw-r--r--grub-core/lib/libgcrypt/mpi/hppa/distfiles7
-rw-r--r--grub-core/lib/libgcrypt/mpi/hppa/mpih-add1.S70
-rw-r--r--grub-core/lib/libgcrypt/mpi/hppa/mpih-lshift.S77
-rw-r--r--grub-core/lib/libgcrypt/mpi/hppa/mpih-rshift.S73
-rw-r--r--grub-core/lib/libgcrypt/mpi/hppa/mpih-sub1.S78
-rw-r--r--grub-core/lib/libgcrypt/mpi/hppa/udiv-qrnnd.S297
-rw-r--r--grub-core/lib/libgcrypt/mpi/i386/Manifest28
-rw-r--r--grub-core/lib/libgcrypt/mpi/i386/distfiles10
-rw-r--r--grub-core/lib/libgcrypt/mpi/i386/mpih-add1.S116
-rw-r--r--grub-core/lib/libgcrypt/mpi/i386/mpih-lshift.S94
-rw-r--r--grub-core/lib/libgcrypt/mpi/i386/mpih-mul1.S84
-rw-r--r--grub-core/lib/libgcrypt/mpi/i386/mpih-mul2.S86
-rw-r--r--grub-core/lib/libgcrypt/mpi/i386/mpih-mul3.S86
-rw-r--r--grub-core/lib/libgcrypt/mpi/i386/mpih-rshift.S97
-rw-r--r--grub-core/lib/libgcrypt/mpi/i386/mpih-sub1.S117
-rw-r--r--grub-core/lib/libgcrypt/mpi/i386/syntax.h68
-rw-r--r--grub-core/lib/libgcrypt/mpi/i586/Manifest27
-rw-r--r--grub-core/lib/libgcrypt/mpi/i586/README26
-rw-r--r--grub-core/lib/libgcrypt/mpi/i586/distfiles10
-rw-r--r--grub-core/lib/libgcrypt/mpi/i586/mpih-add1.S135
-rw-r--r--grub-core/lib/libgcrypt/mpi/i586/mpih-lshift.S229
-rw-r--r--grub-core/lib/libgcrypt/mpi/i586/mpih-mul1.S89
-rw-r--r--grub-core/lib/libgcrypt/mpi/i586/mpih-mul2.S93
-rw-r--r--grub-core/lib/libgcrypt/mpi/i586/mpih-mul3.S93
-rw-r--r--grub-core/lib/libgcrypt/mpi/i586/mpih-rshift.S228
-rw-r--r--grub-core/lib/libgcrypt/mpi/i586/mpih-sub1.S142
-rw-r--r--grub-core/lib/libgcrypt/mpi/longlong.h1613
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/Manifest25
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/distfiles9
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/mc68020/Manifest23
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/mc68020/distfiles4
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul1.S104
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul2.S94
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul3.S97
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/mpih-add1.S92
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/mpih-lshift.S164
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/mpih-rshift.S162
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/mpih-sub1.S91
-rw-r--r--grub-core/lib/libgcrypt/mpi/m68k/syntax.h185
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/Manifest28
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/README23
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/distfiles11
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/mpi-asm-defs.h10
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/mpih-add1.S124
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/mpih-lshift.S97
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/mpih-mul1.S89
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/mpih-mul2.S101
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/mpih-mul3.S101
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/mpih-rshift.S95
-rw-r--r--grub-core/lib/libgcrypt/mpi/mips3/mpih-sub1.S125
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-add.c235
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-bit.c364
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-cmp.c107
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-div.c355
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-gcd.c51
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-inline.c35
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-inline.h161
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-internal.h277
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-inv.c267
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-mod.c184
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-mpow.c223
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-mul.c212
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-pow.c338
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpi-scan.c130
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpicoder.c753
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpih-div.c534
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpih-mul.c528
-rw-r--r--grub-core/lib/libgcrypt/mpi/mpiutil.c460
-rw-r--r--grub-core/lib/libgcrypt/mpi/pa7100/Manifest22
-rw-r--r--grub-core/lib/libgcrypt/mpi/pa7100/distfiles4
-rw-r--r--grub-core/lib/libgcrypt/mpi/pa7100/mpih-lshift.S96
-rw-r--r--grub-core/lib/libgcrypt/mpi/pa7100/mpih-rshift.S92
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/README115
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/distfiles3
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/mmx/distfiles2
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/mmx/mpih-lshift.S457
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/mmx/mpih-rshift.S453
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/sse2/distfiles5
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-add1.S91
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul1.S96
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul2.S136
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul3.S127
-rw-r--r--grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-sub1.S112
-rw-r--r--grub-core/lib/libgcrypt/mpi/power/Manifest27
-rw-r--r--grub-core/lib/libgcrypt/mpi/power/distfiles8
-rw-r--r--grub-core/lib/libgcrypt/mpi/power/mpih-add1.S87
-rw-r--r--grub-core/lib/libgcrypt/mpi/power/mpih-lshift.S64
-rw-r--r--grub-core/lib/libgcrypt/mpi/power/mpih-mul1.S115
-rw-r--r--grub-core/lib/libgcrypt/mpi/power/mpih-mul2.S130
-rw-r--r--grub-core/lib/libgcrypt/mpi/power/mpih-mul3.S135
-rw-r--r--grub-core/lib/libgcrypt/mpi/power/mpih-rshift.S64
-rw-r--r--grub-core/lib/libgcrypt/mpi/power/mpih-sub1.S88
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc32/Manifest28
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc32/distfiles10
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc32/mpih-add1.S136
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc32/mpih-lshift.S198
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul1.S120
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul2.S127
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul3.S130
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc32/mpih-rshift.S131
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc32/mpih-sub1.S133
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc32/syntax.h75
-rw-r--r--grub-core/lib/libgcrypt/mpi/powerpc64/distfiles0
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32/Manifest24
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32/distfiles6
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32/mpih-add1.S239
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32/mpih-lshift.S97
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32/mpih-rshift.S93
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32/udiv.S195
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32v8/Manifest23
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32v8/distfiles5
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul1.S109
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul2.S132
-rw-r--r--grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul3.S67
-rw-r--r--grub-core/lib/libgcrypt/mpi/supersparc/Manifest21
-rw-r--r--grub-core/lib/libgcrypt/mpi/supersparc/distfiles3
-rw-r--r--grub-core/lib/libgcrypt/mpi/supersparc/udiv.S118
-rw-r--r--grub-core/lib/libgcrypt/src/ChangeLog-20112335
-rw-r--r--grub-core/lib/libgcrypt/src/Makefile.am143
-rw-r--r--grub-core/lib/libgcrypt/src/Manifest58
-rw-r--r--grub-core/lib/libgcrypt/src/ath.c344
-rw-r--r--grub-core/lib/libgcrypt/src/ath.h147
-rw-r--r--grub-core/lib/libgcrypt/src/cipher-proto.h124
-rw-r--r--grub-core/lib/libgcrypt/src/cipher.h182
-rw-r--r--grub-core/lib/libgcrypt/src/dumpsexp.c766
-rw-r--r--grub-core/lib/libgcrypt/src/fips.c860
-rw-r--r--grub-core/lib/libgcrypt/src/g10lib.h302
-rw-r--r--grub-core/lib/libgcrypt/src/gcrypt-module.h240
-rw-r--r--grub-core/lib/libgcrypt/src/gcrypt.h.in1760
-rw-r--r--grub-core/lib/libgcrypt/src/gcryptrnd.c680
-rw-r--r--grub-core/lib/libgcrypt/src/getrandom.c326
-rw-r--r--grub-core/lib/libgcrypt/src/global.c1123
-rw-r--r--grub-core/lib/libgcrypt/src/hmac256.c793
-rw-r--r--grub-core/lib/libgcrypt/src/hmac256.h36
-rw-r--r--grub-core/lib/libgcrypt/src/hwfeatures.c192
-rw-r--r--grub-core/lib/libgcrypt/src/libgcrypt-config.in189
-rw-r--r--grub-core/lib/libgcrypt/src/libgcrypt.def239
-rw-r--r--grub-core/lib/libgcrypt/src/libgcrypt.m4123
-rw-r--r--grub-core/lib/libgcrypt/src/libgcrypt.vers111
-rw-r--r--grub-core/lib/libgcrypt/src/misc.c298
-rw-r--r--grub-core/lib/libgcrypt/src/missing-string.c54
-rw-r--r--grub-core/lib/libgcrypt/src/module.c212
-rw-r--r--grub-core/lib/libgcrypt/src/mpi.h266
-rw-r--r--grub-core/lib/libgcrypt/src/secmem.c696
-rw-r--r--grub-core/lib/libgcrypt/src/secmem.h39
-rw-r--r--grub-core/lib/libgcrypt/src/sexp.c2045
-rw-r--r--grub-core/lib/libgcrypt/src/stdmem.c242
-rw-r--r--grub-core/lib/libgcrypt/src/stdmem.h32
-rw-r--r--grub-core/lib/libgcrypt/src/types.h128
-rw-r--r--grub-core/lib/libgcrypt/src/versioninfo.rc.in51
-rw-r--r--grub-core/lib/libgcrypt/src/visibility.c1486
-rw-r--r--grub-core/lib/libgcrypt/src/visibility.h807
-rw-r--r--grub-core/lib/libgcrypt_wrap/cipher_wrap.h77
-rw-r--r--grub-core/lib/libgcrypt_wrap/mem.c140
-rw-r--r--grub-core/lib/minilzo/lzoconf.h444
-rw-r--r--grub-core/lib/minilzo/lzodefs.h2998
-rw-r--r--grub-core/lib/minilzo/minilzo.c6053
-rw-r--r--grub-core/lib/minilzo/minilzo.h94
-rw-r--r--grub-core/lib/mips/arc/reboot.c35
-rw-r--r--grub-core/lib/mips/loongson/reboot.c64
-rw-r--r--grub-core/lib/mips/qemu_mips/reboot.c27
-rw-r--r--grub-core/lib/mips/relocator.c147
-rw-r--r--grub-core/lib/mips/relocator_asm.S61
-rw-r--r--grub-core/lib/mips/setjmp.S71
-rw-r--r--grub-core/lib/pbkdf2.c109
-rw-r--r--grub-core/lib/posix_wrap/assert.h33
-rw-r--r--grub-core/lib/posix_wrap/ctype.h108
-rw-r--r--grub-core/lib/posix_wrap/errno.h29
-rw-r--r--grub-core/lib/posix_wrap/inttypes.h1
-rw-r--r--grub-core/lib/posix_wrap/langinfo.h38
-rw-r--r--grub-core/lib/posix_wrap/limits.h41
-rw-r--r--grub-core/lib/posix_wrap/localcharset.h28
-rw-r--r--grub-core/lib/posix_wrap/locale.h3
-rw-r--r--grub-core/lib/posix_wrap/stdint.h1
-rw-r--r--grub-core/lib/posix_wrap/stdio.h43
-rw-r--r--grub-core/lib/posix_wrap/stdlib.h61
-rw-r--r--grub-core/lib/posix_wrap/string.h92
-rw-r--r--grub-core/lib/posix_wrap/sys/types.h65
-rw-r--r--grub-core/lib/posix_wrap/unistd.h1
-rw-r--r--grub-core/lib/posix_wrap/wchar.h119
-rw-r--r--grub-core/lib/posix_wrap/wctype.h110
-rw-r--r--grub-core/lib/powerpc/relocator.c140
-rw-r--r--grub-core/lib/powerpc/relocator_asm.S60
-rw-r--r--grub-core/lib/powerpc/setjmp.S89
-rw-r--r--grub-core/lib/priority_queue.c163
-rw-r--r--grub-core/lib/progress.c145
-rw-r--r--grub-core/lib/random.c120
-rw-r--r--grub-core/lib/reed_solomon.c493
-rw-r--r--grub-core/lib/relocator.c1657
-rw-r--r--grub-core/lib/riscv/setjmp.S84
-rw-r--r--grub-core/lib/setjmp.S22
-rw-r--r--grub-core/lib/sparc64/setjmp.S54
-rw-r--r--grub-core/lib/syslinux_parse.c1555
-rw-r--r--grub-core/lib/uboot/reboot.c31
-rw-r--r--grub-core/lib/x86_64/efi/relocator.c79
-rw-r--r--grub-core/lib/x86_64/relocator_asm.S85
-rw-r--r--grub-core/lib/x86_64/setjmp.S68
-rw-r--r--grub-core/lib/x86_64/xen/relocator.S133
-rw-r--r--grub-core/lib/xen/datetime.c40
-rw-r--r--grub-core/lib/xen/halt.c32
-rw-r--r--grub-core/lib/xen/reboot.c32
-rw-r--r--grub-core/lib/xen/relocator.c137
-rw-r--r--grub-core/lib/xzembed/xz.h188
-rw-r--r--grub-core/lib/xzembed/xz_config.h152
-rw-r--r--grub-core/lib/xzembed/xz_dec_bcj.c578
-rw-r--r--grub-core/lib/xzembed/xz_dec_lzma2.c1188
-rw-r--r--grub-core/lib/xzembed/xz_dec_stream.c1042
-rw-r--r--grub-core/lib/xzembed/xz_lzma2.h236
-rw-r--r--grub-core/lib/xzembed/xz_private.h96
-rw-r--r--grub-core/lib/xzembed/xz_stream.h53
-rw-r--r--grub-core/lib/zstd/bitstream.h458
-rw-r--r--grub-core/lib/zstd/compiler.h133
-rw-r--r--grub-core/lib/zstd/cpu.h215
-rw-r--r--grub-core/lib/zstd/debug.c44
-rw-r--r--grub-core/lib/zstd/debug.h123
-rw-r--r--grub-core/lib/zstd/entropy_common.c236
-rw-r--r--grub-core/lib/zstd/error_private.c48
-rw-r--r--grub-core/lib/zstd/error_private.h76
-rw-r--r--grub-core/lib/zstd/fse.h708
-rw-r--r--grub-core/lib/zstd/fse_decompress.c309
-rw-r--r--grub-core/lib/zstd/huf.h334
-rw-r--r--grub-core/lib/zstd/huf_decompress.c1096
-rw-r--r--grub-core/lib/zstd/mem.h374
-rw-r--r--grub-core/lib/zstd/module.c21
-rw-r--r--grub-core/lib/zstd/xxhash.c876
-rw-r--r--grub-core/lib/zstd/xxhash.h305
-rw-r--r--grub-core/lib/zstd/zstd.h1516
-rw-r--r--grub-core/lib/zstd/zstd_common.c81
-rw-r--r--grub-core/lib/zstd/zstd_decompress.c3108
-rw-r--r--grub-core/lib/zstd/zstd_errors.h92
-rw-r--r--grub-core/lib/zstd/zstd_internal.h257
-rw-r--r--grub-core/loader/aout.c62
-rw-r--r--grub-core/loader/arm/linux.c509
-rw-r--r--grub-core/loader/arm64/linux.c393
-rw-r--r--grub-core/loader/arm64/xen_boot.c527
-rw-r--r--grub-core/loader/efi/appleloader.c242
-rw-r--r--grub-core/loader/efi/chainloader.c444
-rw-r--r--grub-core/loader/efi/fdt.c179
-rw-r--r--grub-core/loader/i386/bsd.c2191
-rw-r--r--grub-core/loader/i386/bsd32.c6
-rw-r--r--grub-core/loader/i386/bsd64.c6
-rw-r--r--grub-core/loader/i386/bsdXX.c679
-rw-r--r--grub-core/loader/i386/bsd_pagetable.c92
-rw-r--r--grub-core/loader/i386/coreboot/chainloader.c517
-rw-r--r--grub-core/loader/i386/linux.c1141
-rw-r--r--grub-core/loader/i386/multiboot_mbi.c756
-rw-r--r--grub-core/loader/i386/pc/chainloader.c310
-rw-r--r--grub-core/loader/i386/pc/freedos.c190
-rw-r--r--grub-core/loader/i386/pc/linux.c494
-rw-r--r--grub-core/loader/i386/pc/ntldr.c162
-rw-r--r--grub-core/loader/i386/pc/plan9.c607
-rw-r--r--grub-core/loader/i386/pc/pxechainloader.c168
-rw-r--r--grub-core/loader/i386/pc/truecrypt.c233
-rw-r--r--grub-core/loader/i386/xen.c986
-rw-r--r--grub-core/loader/i386/xen_file.c117
-rw-r--r--grub-core/loader/i386/xen_file32.c7
-rw-r--r--grub-core/loader/i386/xen_file64.c7
-rw-r--r--grub-core/loader/i386/xen_fileXX.c395
-rw-r--r--grub-core/loader/i386/xnu.c1166
-rw-r--r--grub-core/loader/ia64/efi/linux.c607
-rw-r--r--grub-core/loader/linux.c335
-rw-r--r--grub-core/loader/lzss.c56
-rw-r--r--grub-core/loader/macho.c205
-rw-r--r--grub-core/loader/macho32.c22
-rw-r--r--grub-core/loader/macho64.c22
-rw-r--r--grub-core/loader/machoXX.c384
-rw-r--r--grub-core/loader/mips/linux.c508
-rw-r--r--grub-core/loader/multiboot.c469
-rw-r--r--grub-core/loader/multiboot_elfxx.c298
-rw-r--r--grub-core/loader/multiboot_mbi2.c1128
-rw-r--r--grub-core/loader/powerpc/ieee1275/linux.c393
-rw-r--r--grub-core/loader/riscv/linux.c59
-rw-r--r--grub-core/loader/sparc64/ieee1275/linux.c521
-rw-r--r--grub-core/loader/xnu.c1555
-rw-r--r--grub-core/loader/xnu_resume.c188
-rw-r--r--grub-core/mmap/efi/mmap.c318
-rw-r--r--grub-core/mmap/i386/mmap.c113
-rw-r--r--grub-core/mmap/i386/pc/mmap.c211
-rw-r--r--grub-core/mmap/i386/pc/mmap_helper.S163
-rw-r--r--grub-core/mmap/i386/uppermem.c98
-rw-r--r--grub-core/mmap/mips/uppermem.c72
-rw-r--r--grub-core/mmap/mmap.c554
-rw-r--r--grub-core/modinfo.sh.in40
-rw-r--r--grub-core/net/arp.c189
-rw-r--r--grub-core/net/bootp.c925
-rw-r--r--grub-core/net/dns.c785
-rw-r--r--grub-core/net/drivers/efi/efinet.c404
-rw-r--r--grub-core/net/drivers/emu/emunet.c116
-rw-r--r--grub-core/net/drivers/i386/pc/pxe.c419
-rw-r--r--grub-core/net/drivers/ieee1275/ofnet.c565
-rw-r--r--grub-core/net/drivers/uboot/ubootnet.c161
-rw-r--r--grub-core/net/ethernet.c171
-rw-r--r--grub-core/net/http.c562
-rw-r--r--grub-core/net/icmp.c112
-rw-r--r--grub-core/net/icmp6.c679
-rw-r--r--grub-core/net/ip.c739
-rw-r--r--grub-core/net/net.c1952
-rw-r--r--grub-core/net/netbuff.c133
-rw-r--r--grub-core/net/tcp.c1020
-rw-r--r--grub-core/net/tftp.c479
-rw-r--r--grub-core/net/udp.c211
-rw-r--r--grub-core/normal/auth.c278
-rw-r--r--grub-core/normal/autofs.c148
-rw-r--r--grub-core/normal/charset.c1312
-rw-r--r--grub-core/normal/cmdline.c691
-rw-r--r--grub-core/normal/color.c145
-rw-r--r--grub-core/normal/completion.c526
-rw-r--r--grub-core/normal/context.c214
-rw-r--r--grub-core/normal/crypto.c163
-rw-r--r--grub-core/normal/dyncmd.c210
-rw-r--r--grub-core/normal/main.c587
-rw-r--r--grub-core/normal/menu.c912
-rw-r--r--grub-core/normal/menu_entry.c1460
-rw-r--r--grub-core/normal/menu_text.c602
-rw-r--r--grub-core/normal/misc.c194
-rw-r--r--grub-core/normal/term.c1098
-rw-r--r--grub-core/osdep/apple/getroot.c109
-rw-r--r--grub-core/osdep/apple/hostdisk.c95
-rw-r--r--grub-core/osdep/aros/config.c94
-rw-r--r--grub-core/osdep/aros/getroot.c228
-rw-r--r--grub-core/osdep/aros/hostdisk.c617
-rw-r--r--grub-core/osdep/aros/relpath.c75
-rw-r--r--grub-core/osdep/basic/compress.c21
-rw-r--r--grub-core/osdep/basic/emunet.c50
-rw-r--r--grub-core/osdep/basic/getroot.c82
-rw-r--r--grub-core/osdep/basic/hostdisk.c58
-rw-r--r--grub-core/osdep/basic/init.c38
-rw-r--r--grub-core/osdep/basic/no_platform.c46
-rw-r--r--grub-core/osdep/basic/ofpath.c29
-rw-r--r--grub-core/osdep/basic/platform.c32
-rw-r--r--grub-core/osdep/basic/random.c43
-rw-r--r--grub-core/osdep/blocklist.c7
-rw-r--r--grub-core/osdep/bsd/getroot.c204
-rw-r--r--grub-core/osdep/bsd/hostdisk.c130
-rw-r--r--grub-core/osdep/compress.c5
-rw-r--r--grub-core/osdep/config.c7
-rw-r--r--grub-core/osdep/cputime.c5
-rw-r--r--grub-core/osdep/devmapper/getroot.c347
-rw-r--r--grub-core/osdep/devmapper/hostdisk.c230
-rw-r--r--grub-core/osdep/dl.c5
-rw-r--r--grub-core/osdep/emuconsole.c5
-rw-r--r--grub-core/osdep/emunet.c5
-rw-r--r--grub-core/osdep/exec.c3
-rw-r--r--grub-core/osdep/freebsd/getroot.c364
-rw-r--r--grub-core/osdep/freebsd/hostdisk.c128
-rw-r--r--grub-core/osdep/generic/blocklist.c132
-rw-r--r--grub-core/osdep/getroot.c22
-rw-r--r--grub-core/osdep/haiku/getroot.c105
-rw-r--r--grub-core/osdep/haiku/hostdisk.c69
-rw-r--r--grub-core/osdep/hostdisk.c22
-rw-r--r--grub-core/osdep/hurd/getroot.c247
-rw-r--r--grub-core/osdep/hurd/hostdisk.c146
-rw-r--r--grub-core/osdep/init.c5
-rw-r--r--grub-core/osdep/linux/blocklist.c136
-rw-r--r--grub-core/osdep/linux/emunet.c74
-rw-r--r--grub-core/osdep/linux/getroot.c1164
-rw-r--r--grub-core/osdep/linux/hostdisk.c465
-rw-r--r--grub-core/osdep/linux/ofpath.c769
-rw-r--r--grub-core/osdep/linux/platform.c156
-rw-r--r--grub-core/osdep/ofpath.c5
-rw-r--r--grub-core/osdep/password.c5
-rw-r--r--grub-core/osdep/platform.c9
-rw-r--r--grub-core/osdep/platform_unix.c3
-rw-r--r--grub-core/osdep/random.c10
-rw-r--r--grub-core/osdep/relpath.c7
-rw-r--r--grub-core/osdep/sleep.c5
-rw-r--r--grub-core/osdep/sun/getroot.c126
-rw-r--r--grub-core/osdep/sun/hostdisk.c73
-rw-r--r--grub-core/osdep/unix/compress.c41
-rw-r--r--grub-core/osdep/unix/config.c139
-rw-r--r--grub-core/osdep/unix/cputime.c22
-rw-r--r--grub-core/osdep/unix/dl.c61
-rw-r--r--grub-core/osdep/unix/emuconsole.c184
-rw-r--r--grub-core/osdep/unix/exec.c245
-rw-r--r--grub-core/osdep/unix/getroot.c787
-rw-r--r--grub-core/osdep/unix/hostdisk.c319
-rw-r--r--grub-core/osdep/unix/password.c75
-rw-r--r--grub-core/osdep/unix/platform.c241
-rw-r--r--grub-core/osdep/unix/random.c48
-rw-r--r--grub-core/osdep/unix/relpath.c151
-rw-r--r--grub-core/osdep/unix/sleep.c30
-rw-r--r--grub-core/osdep/windows/blocklist.c118
-rw-r--r--grub-core/osdep/windows/config.c57
-rw-r--r--grub-core/osdep/windows/cputime.c19
-rw-r--r--grub-core/osdep/windows/dl.c59
-rw-r--r--grub-core/osdep/windows/emuconsole.c308
-rw-r--r--grub-core/osdep/windows/getroot.c355
-rw-r--r--grub-core/osdep/windows/hostdisk.c689
-rw-r--r--grub-core/osdep/windows/init.c190
-rw-r--r--grub-core/osdep/windows/password.c51
-rw-r--r--grub-core/osdep/windows/platform.c426
-rw-r--r--grub-core/osdep/windows/random.c55
-rw-r--r--grub-core/osdep/windows/relpath.c96
-rw-r--r--grub-core/osdep/windows/sleep.c31
-rw-r--r--grub-core/partmap/acorn.c154
-rw-r--r--grub-core/partmap/amiga.c183
-rw-r--r--grub-core/partmap/apple.c199
-rw-r--r--grub-core/partmap/bsdlabel.c271
-rw-r--r--grub-core/partmap/dfly.c132
-rw-r--r--grub-core/partmap/dvh.c127
-rw-r--r--grub-core/partmap/gpt.c238
-rw-r--r--grub-core/partmap/msdos.c435
-rw-r--r--grub-core/partmap/plan.c120
-rw-r--r--grub-core/partmap/sun.c154
-rw-r--r--grub-core/partmap/sunpc.c151
-rw-r--r--grub-core/parttool/msdospart.c161
-rw-r--r--grub-core/script/argv.c165
-rw-r--r--grub-core/script/execute.c1192
-rw-r--r--grub-core/script/function.c123
-rw-r--r--grub-core/script/lexer.c356
-rw-r--r--grub-core/script/main.c98
-rw-r--r--grub-core/script/parser.y356
-rw-r--r--grub-core/script/script.c396
-rw-r--r--grub-core/script/yylex.l393
-rw-r--r--grub-core/term/arc/console.c209
-rw-r--r--grub-core/term/arc/serial.c147
-rw-r--r--grub-core/term/arm/cros.c125
-rw-r--r--grub-core/term/arm/cros_ec.c238
-rw-r--r--grub-core/term/arm/pl050.c189
-rw-r--r--grub-core/term/at_keyboard.c332
-rw-r--r--grub-core/term/efi/console.c470
-rw-r--r--grub-core/term/efi/serial.c195
-rw-r--r--grub-core/term/gfxterm.c1160
-rw-r--r--grub-core/term/gfxterm_background.c190
-rw-r--r--grub-core/term/i386/coreboot/cbmemc.c147
-rw-r--r--grub-core/term/i386/pc/console.c310
-rw-r--r--grub-core/term/i386/pc/mda_text.c13
-rw-r--r--grub-core/term/i386/pc/vga_text.c288
-rw-r--r--grub-core/term/ieee1275/console.c267
-rw-r--r--grub-core/term/ieee1275/escc.c319
-rw-r--r--grub-core/term/ieee1275/serial.c287
-rw-r--r--grub-core/term/morse.c133
-rw-r--r--grub-core/term/ns8250.c318
-rw-r--r--grub-core/term/ps2.c387
-rw-r--r--grub-core/term/serial.c463
-rw-r--r--grub-core/term/spkmodem.c141
-rw-r--r--grub-core/term/terminfo.c796
-rw-r--r--grub-core/term/tparm.c767
-rw-r--r--grub-core/term/uboot/console.c132
-rw-r--r--grub-core/term/usb_keyboard.c471
-rw-r--r--grub-core/term/xen/console.c122
-rw-r--r--grub-core/tests/boot/kbsd.init-i386.S107
-rw-r--r--grub-core/tests/boot/kbsd.init-x86_64.S94
-rw-r--r--grub-core/tests/boot/kbsd.spec.txt3
-rw-r--r--grub-core/tests/boot/kernel-8086.S50
-rw-r--r--grub-core/tests/boot/kernel-i386.S72
-rw-r--r--grub-core/tests/boot/kfreebsd-aout.cfg4
-rw-r--r--grub-core/tests/boot/kfreebsd.cfg8
-rw-r--r--grub-core/tests/boot/kfreebsd.init-i386.S109
-rw-r--r--grub-core/tests/boot/kfreebsd.init-x86_64.S90
-rw-r--r--grub-core/tests/boot/knetbsd.cfg5
-rw-r--r--grub-core/tests/boot/kopenbsd.cfg5
-rw-r--r--grub-core/tests/boot/kopenbsdlabel.txt3
-rw-r--r--grub-core/tests/boot/linux-ppc.cfg5
-rw-r--r--grub-core/tests/boot/linux.cfg5
-rw-r--r--grub-core/tests/boot/linux.init-i386.S61
-rw-r--r--grub-core/tests/boot/linux.init-mips.S61
-rw-r--r--grub-core/tests/boot/linux.init-ppc.S61
-rw-r--r--grub-core/tests/boot/linux.init-x86_64.S60
-rw-r--r--grub-core/tests/boot/linux16.cfg5
-rw-r--r--grub-core/tests/boot/multiboot.cfg4
-rw-r--r--grub-core/tests/boot/multiboot2.cfg4
-rw-r--r--grub-core/tests/boot/ntldr.cfg4
-rw-r--r--grub-core/tests/boot/pc-chainloader.cfg4
-rw-r--r--grub-core/tests/boot/qemu-shutdown-x86.S17
-rw-r--r--grub-core/tests/bswap_test.c121
-rw-r--r--grub-core/tests/checksums.h129
-rw-r--r--grub-core/tests/cmdline_cat_test.c125
-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.c189
-rw-r--r--grub-core/tests/example_functional_test.c38
-rw-r--r--grub-core/tests/fake_input.c75
-rw-r--r--grub-core/tests/gfxterm_menu.c180
-rw-r--r--grub-core/tests/legacy_password_test.c68
-rw-r--r--grub-core/tests/lib/functional_test.c105
-rw-r--r--grub-core/tests/lib/test.c239
-rw-r--r--grub-core/tests/mul_test.c73
-rw-r--r--grub-core/tests/pbkdf2_test.c97
-rw-r--r--grub-core/tests/setjmp_test.c80
-rw-r--r--grub-core/tests/shift_test.c157
-rw-r--r--grub-core/tests/signature_test.c170
-rw-r--r--grub-core/tests/signatures.h211
-rw-r--r--grub-core/tests/sleep_test.c51
-rw-r--r--grub-core/tests/strtoull_test.c63
-rw-r--r--grub-core/tests/test_blockarg.c55
-rw-r--r--grub-core/tests/video_checksum.c813
-rw-r--r--grub-core/tests/videotest_checksum.c80
-rw-r--r--grub-core/tests/xnu_uuid_test.c58
-rw-r--r--grub-core/unidata.c1538
-rw-r--r--grub-core/video/bitmap.c238
-rw-r--r--grub-core/video/bitmap_scale.c515
-rw-r--r--grub-core/video/bochs.c439
-rw-r--r--grub-core/video/capture.c140
-rw-r--r--grub-core/video/cirrus.c520
-rw-r--r--grub-core/video/colors.c333
-rw-r--r--grub-core/video/coreboot/cbfb.c190
-rw-r--r--grub-core/video/efi_gop.c621
-rw-r--r--grub-core/video/efi_uga.c369
-rw-r--r--grub-core/video/emu/sdl.c252
-rw-r--r--grub-core/video/fb/fbblit.c2227
-rw-r--r--grub-core/video/fb/fbfill.c212
-rw-r--r--grub-core/video/fb/fbutil.c151
-rw-r--r--grub-core/video/fb/video_fb.c1709
-rw-r--r--grub-core/video/i386/pc/vbe.c1250
-rw-r--r--grub-core/video/i386/pc/vga.c404
-rw-r--r--grub-core/video/ieee1275.c370
-rw-r--r--grub-core/video/radeon_fuloong2e.c239
-rw-r--r--grub-core/video/radeon_yeeloong3a.c237
-rw-r--r--grub-core/video/readers/jpeg.c879
-rw-r--r--grub-core/video/readers/png.c1166
-rw-r--r--grub-core/video/readers/tga.c511
-rw-r--r--grub-core/video/sis315_init.c158
-rw-r--r--grub-core/video/sis315pro.c459
-rw-r--r--grub-core/video/sm712.c818
-rw-r--r--grub-core/video/sm712_init.c14
-rw-r--r--grub-core/video/video.c763
1351 files changed, 499605 insertions, 0 deletions
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
new file mode 100644
index 0000000..ee88e44
--- /dev/null
+++ b/grub-core/Makefile.am
@@ -0,0 +1,506 @@
+AUTOMAKE_OPTIONS = subdir-objects -Wno-portability
+
+DEPDIR=.deps-core
+
+include $(top_srcdir)/conf/Makefile.common
+
+CC=$(TARGET_CC)
+CPP=$(TARGET_CC)
+CCAS=$(TARGET_CC)
+RANLIB=$(TARGET_RANLIB)
+STRIP=$(TARGET_STRIP)
+
+MACHO2IMG=$(top_builddir)/grub-macho2img
+
+AM_CFLAGS = $(TARGET_CFLAGS)
+AM_LDFLAGS = $(TARGET_LDFLAGS)
+AM_CPPFLAGS = $(TARGET_CPPFLAGS) $(CPPFLAGS_DEFAULT)
+AM_CCASFLAGS = $(TARGET_CCASFLAGS) $(CCASFLAGS_DEFAULT)
+
+CFLAGS_PROGRAM += $(CFLAGS_PLATFORM)
+LDFLAGS_PROGRAM += $(LDFLAGS_PLATFORM)
+CPPFLAGS_PROGRAM += $(CPPFLAGS_PLATFORM)
+CCASFLAGS_PROGRAM += $(CCASFLAGS_PLATFORM)
+
+CFLAGS_LIBRARY += $(CFLAGS_PLATFORM) -fno-builtin
+CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM)
+CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)
+
+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$(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$(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$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac
+ ./gentrigtables$(BUILD_EXEEXT) > $@
+CLEANFILES += trigtables.c
+
+# XXX Use Automake's LEX & YACC support
+grub_script.tab.h: script/parser.y
+ $(YACC) -d -p grub_script_yy -b grub_script $<
+grub_script.tab.c: grub_script.tab.h
+CLEANFILES += grub_script.tab.c grub_script.tab.h
+
+# For the lexer.
+grub_script.yy.h: script/yylex.l
+ $(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h $<
+grub_script.yy.c: grub_script.yy.h
+
+rs_decoder.h: $(srcdir)/lib/reed_solomon.c
+ $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Os -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3 -ffreestanding
+
+CLEANFILES += grub_script.yy.c grub_script.yy.h
+
+include $(srcdir)/Makefile.core.am
+
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cache.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/disk.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dl.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/sb.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/file.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fs.h
+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/lockdown.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
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/stack_protector.h
+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/verify.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
+
+if COND_i386_pc
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pxe.h
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/int.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
+endif
+
+if COND_i386_xen_pvh
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/int.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/xen/hypercall.h
+endif
+
+if COND_i386_efi
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.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/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
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/coreboot/lbio.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
+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_builddir)/include/grub/machine/kernel.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
+endif
+
+if COND_i386_qemu
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
+endif
+
+if COND_i386_ieee1275
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.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/i386/tsc.h
+endif
+
+if COND_i386_xen
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/xen/hypercall.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.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/loader.h
+endif
+
+if COND_x86_64_xen
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/x86_64/xen/hypercall.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.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/loader.h
+endif
+
+if COND_x86_64_efi
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.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/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
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/kernel.h
+endif
+
+if COND_mips_arc
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arc/arc.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
+endif
+
+if COND_mips_qemu_mips
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/serial.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
+endif
+
+if COND_mips_loongson
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/time.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
+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/pci.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cs5536.h
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pci.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/serial.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
+endif
+
+if COND_mips_qemu_mips
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
+endif
+
+if COND_powerpc_ieee1275
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
+endif
+
+if COND_sparc64_ieee1275
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sparc64/ieee1275/ieee1275.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
+endif
+
+if COND_arm_uboot
+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_coreboot
+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
+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/fdt.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dma.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/coreboot/kernel.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdtbus.h
+endif
+
+if COND_arm_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/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_riscv32_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_riscv64_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
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/net.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostdisk.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostfile.h
+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_PCI
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h
+endif
+endif
+
+symlist.h: $(top_builddir)/config.h $(KERNEL_HEADER_FILES)
+ @list='$^'; \
+ for p in $$list; do \
+ echo "#include <$$p>" >> $@ || (rm -f $@; exit 1); \
+ done
+CLEANFILES += symlist.h
+BUILT_SOURCES += symlist.h
+
+symlist.c: symlist.h gensymlist.sh
+ $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) -DGRUB_SYMBOL_GENERATOR=1 symlist.h > symlist.p || (rm -f symlist.p; exit 1)
+ cat symlist.p | $(SHELL) $(srcdir)/gensymlist.sh $(top_builddir)/config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1)
+ rm -f symlist.p
+CLEANFILES += symlist.c
+BUILT_SOURCES += symlist.c
+
+if COND_HAVE_ASM_USCORE
+ASM_PREFIX=_
+else
+ASM_PREFIX=
+endif
+
+noinst_DATA += kernel_syms.lst
+
+kernel_syms.lst: $(KERNEL_HEADER_FILES) $(top_builddir)/config.h
+ $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) $(CFLAGS) -DGRUB_SYMBOL_GENERATOR=1 $^ >kernel_syms.input
+ cat kernel_syms.input | grep -v '^#' | sed -n \
+ -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \
+ -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \
+ | sort -u >$@
+ rm -f kernel_syms.input
+CLEANFILES += kernel_syms.lst
+
+if COND_emu
+kern/emu/grub_emu-main.$(OBJEXT):grub_emu_init.h
+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 $(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 $(MODULE_FILES)
+ rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinit.sh $(TARGET_NM) > $@
+CLEANFILES += grub_emu_init.c
+endif
+
+# List files
+
+fs.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ if grep 'FS_LIST_MARKER' $$pp >/dev/null 2>&1; then \
+ echo $$b; \
+ fi; \
+ done) | sort -u > $@
+platform_DATA += fs.lst
+CLEANFILES += fs.lst
+
+command.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ sed -n \
+ -e "/EXTCOMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
+ -e "/EXTCOMMAND_LOCKDOWN_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
+ -e "/P1COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
+ -e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" \
+ -e "/COMMAND_LOCKDOWN_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
+ done) | sort -u > $@
+platform_DATA += command.lst
+CLEANFILES += command.lst
+
+partmap.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ if grep 'PARTMAP_LIST_MARKER' $$pp >/dev/null 2>&1; then \
+ echo $$b; \
+ fi; \
+ done) | sort -u > $@
+platform_DATA += partmap.lst
+CLEANFILES += partmap.lst
+
+terminal.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ sed -n \
+ -e "/INPUT_TERMINAL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $$b/;p;}" \
+ -e "/OUTPUT_TERMINAL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $$b/;p;}" $$pp; \
+ done) | sort -u > $@
+platform_DATA += terminal.lst
+CLEANFILES += terminal.lst
+
+fdt.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ sed -n \
+ -e "/FDT_DRIVER_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $$b/;p;}" \
+ -e "/FDT_DRIVER_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $$b/;p;}" $$pp; \
+ done) | sort -u > $@
+platform_DATA += fdt.lst
+CLEANFILES += fdt.lst
+
+parttool.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ sed -n \
+ -e "/PARTTOOL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
+ done) | sort -u > $@
+platform_DATA += parttool.lst
+CLEANFILES += parttool.lst
+
+video.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ if grep 'VIDEO_LIST_MARKER' $$pp >/dev/null 2>&1; then \
+ echo $$b; \
+ fi; \
+ done) | sort -u > $@
+platform_DATA += video.lst
+CLEANFILES += video.lst
+
+# but, crypto.lst is simply copied
+crypto.lst: $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst
+ cp $^ $@
+platform_DATA += crypto.lst
+CLEANFILES += crypto.lst
+
+syminfo.lst: gensyminfo.sh kernel_syms.lst $(MODULE_FILES)
+ cat kernel_syms.lst > $@.new
+ for m in $(MODULE_FILES); do \
+ sh $< $$m >> $@.new || exit 1; \
+ done
+ mv $@.new $@
+
+# generate global module dependencies list
+moddep.lst: syminfo.lst genmoddep.awk video.lst
+ cat $< | sort | $(AWK) -f $(srcdir)/genmoddep.awk > $@ || (rm -f $@; exit 1)
+platform_DATA += moddep.lst
+CLEANFILES += config.log syminfo.lst moddep.lst
+
+$(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
+CLEANFILES += $(MOD_FILES)
+
+if COND_ENABLE_EFIEMU
+efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
+ -rm -f $@
+ -rm -f $@.bin
+ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -static -O2 -c -o $@.bin $<
+ if test "x$(TARGET_APPLE_LINKER)" = x1; then \
+ $(TARGET_OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
+ rm -f $@.bin ; \
+ elif test ! -z "$(TARGET_OBJ2ELF)"; then \
+ $(TARGET_OBJ2ELF) $@.bin || (rm -f $@.bin; exit 1); \
+ mv $@.bin $@ ; \
+ else \
+ mv $@.bin $@ ; \
+ fi
+
+# Link format -arch,x86_64 means Apple linker
+efiemu64_c.o: efiemu/runtime/efiemu.c
+ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
+
+efiemu64_s.o: efiemu/runtime/efiemu.S
+ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
+
+efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
+ -rm -f $@
+ -rm -f $@.bin
+ $(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -static -Wl,-r -o $@.bin $^
+ if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \
+ $(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
+ rm -f $@.bin; \
+ else \
+ mv $@.bin $@ ; \
+ fi
+
+platform_DATA += efiemu32.o efiemu64.o
+CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
+endif
+
+windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows
+windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
+ test -d $(windowsdir)/$(target_cpu)-$(platform) || mkdir $(windowsdir)/$(target_cpu)-$(platform)
+ for x in $(platform_DATA); do \
+ cp -fp $$x $(windowsdir)/$(target_cpu)-$(platform)/$$x; \
+ done
diff --git a/grub-core/Makefile.core.am b/grub-core/Makefile.core.am
new file mode 100644
index 0000000..e822f60
--- /dev/null
+++ b/grub-core/Makefile.core.am
@@ -0,0 +1,23794 @@
+platform_PROGRAMS += disk.module
+MODULE_FILES += disk.module$(EXEEXT)
+disk_module_SOURCES = lib/disk.c ## platform sources
+nodist_disk_module_SOURCES = ## platform nodist sources
+disk_module_LDADD =
+disk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+disk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+disk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+disk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+disk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += kern/disk_common.c
+BUILT_SOURCES += $(nodist_disk_module_SOURCES)
+CLEANFILES += $(nodist_disk_module_SOURCES)
+MOD_FILES += disk.mod
+MARKER_FILES += disk.marker
+CLEANFILES += disk.marker
+
+disk.marker: $(disk_module_SOURCES) $(nodist_disk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(disk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += trig.module
+MODULE_FILES += trig.module$(EXEEXT)
+trig_module_SOURCES = ## platform sources
+nodist_trig_module_SOURCES = trigtables.c ## platform nodist sources
+trig_module_LDADD =
+trig_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+trig_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+trig_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+trig_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+trig_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += gentrigtables.c
+BUILT_SOURCES += $(nodist_trig_module_SOURCES)
+CLEANFILES += $(nodist_trig_module_SOURCES)
+MOD_FILES += trig.mod
+MARKER_FILES += trig.marker
+CLEANFILES += trig.marker
+
+trig.marker: $(trig_module_SOURCES) $(nodist_trig_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(trig_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += cs5536.module
+MODULE_FILES += cs5536.module$(EXEEXT)
+cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+nodist_cs5536_module_SOURCES = ## platform nodist sources
+cs5536_module_LDADD =
+cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cs5536_module_SOURCES)
+CLEANFILES += $(nodist_cs5536_module_SOURCES)
+MOD_FILES += cs5536.mod
+MARKER_FILES += cs5536.marker
+CLEANFILES += cs5536.marker
+
+cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += cs5536.module
+MODULE_FILES += cs5536.module$(EXEEXT)
+cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+nodist_cs5536_module_SOURCES = ## platform nodist sources
+cs5536_module_LDADD =
+cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cs5536_module_SOURCES)
+CLEANFILES += $(nodist_cs5536_module_SOURCES)
+MOD_FILES += cs5536.mod
+MARKER_FILES += cs5536.marker
+CLEANFILES += cs5536.marker
+
+cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += cs5536.module
+MODULE_FILES += cs5536.module$(EXEEXT)
+cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+nodist_cs5536_module_SOURCES = ## platform nodist sources
+cs5536_module_LDADD =
+cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cs5536_module_SOURCES)
+CLEANFILES += $(nodist_cs5536_module_SOURCES)
+MOD_FILES += cs5536.mod
+MARKER_FILES += cs5536.marker
+CLEANFILES += cs5536.marker
+
+cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += cs5536.module
+MODULE_FILES += cs5536.module$(EXEEXT)
+cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+nodist_cs5536_module_SOURCES = ## platform nodist sources
+cs5536_module_LDADD =
+cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cs5536_module_SOURCES)
+CLEANFILES += $(nodist_cs5536_module_SOURCES)
+MOD_FILES += cs5536.mod
+MARKER_FILES += cs5536.marker
+CLEANFILES += cs5536.marker
+
+cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += cs5536.module
+MODULE_FILES += cs5536.module$(EXEEXT)
+cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+nodist_cs5536_module_SOURCES = ## platform nodist sources
+cs5536_module_LDADD =
+cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cs5536_module_SOURCES)
+CLEANFILES += $(nodist_cs5536_module_SOURCES)
+MOD_FILES += cs5536.mod
+MARKER_FILES += cs5536.marker
+CLEANFILES += cs5536.marker
+
+cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += cs5536.module
+MODULE_FILES += cs5536.module$(EXEEXT)
+cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+nodist_cs5536_module_SOURCES = ## platform nodist sources
+cs5536_module_LDADD =
+cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cs5536_module_SOURCES)
+CLEANFILES += $(nodist_cs5536_module_SOURCES)
+MOD_FILES += cs5536.mod
+MARKER_FILES += cs5536.marker
+CLEANFILES += cs5536.marker
+
+cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += cs5536.module
+MODULE_FILES += cs5536.module$(EXEEXT)
+cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+nodist_cs5536_module_SOURCES = ## platform nodist sources
+cs5536_module_LDADD =
+cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cs5536_module_SOURCES)
+CLEANFILES += $(nodist_cs5536_module_SOURCES)
+MOD_FILES += cs5536.mod
+MARKER_FILES += cs5536.marker
+CLEANFILES += cs5536.marker
+
+cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += lsspd.module
+MODULE_FILES += lsspd.module$(EXEEXT)
+lsspd_module_SOURCES = commands/mips/loongson/lsspd.c ## platform sources
+nodist_lsspd_module_SOURCES = ## platform nodist sources
+lsspd_module_LDADD =
+lsspd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsspd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsspd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsspd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsspd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsspd_module_SOURCES)
+CLEANFILES += $(nodist_lsspd_module_SOURCES)
+MOD_FILES += lsspd.mod
+MARKER_FILES += lsspd.marker
+CLEANFILES += lsspd.marker
+
+lsspd.marker: $(lsspd_module_SOURCES) $(nodist_lsspd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsspd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += usb.module
+MODULE_FILES += usb.module$(EXEEXT)
+usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+nodist_usb_module_SOURCES = ## platform nodist sources
+usb_module_LDADD =
+usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_module_SOURCES)
+CLEANFILES += $(nodist_usb_module_SOURCES)
+MOD_FILES += usb.mod
+MARKER_FILES += usb.marker
+CLEANFILES += usb.marker
+
+usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += usb.module
+MODULE_FILES += usb.module$(EXEEXT)
+usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+nodist_usb_module_SOURCES = ## platform nodist sources
+usb_module_LDADD =
+usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_module_SOURCES)
+CLEANFILES += $(nodist_usb_module_SOURCES)
+MOD_FILES += usb.mod
+MARKER_FILES += usb.marker
+CLEANFILES += usb.marker
+
+usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += usb.module
+MODULE_FILES += usb.module$(EXEEXT)
+usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+nodist_usb_module_SOURCES = ## platform nodist sources
+usb_module_LDADD =
+usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_module_SOURCES)
+CLEANFILES += $(nodist_usb_module_SOURCES)
+MOD_FILES += usb.mod
+MARKER_FILES += usb.marker
+CLEANFILES += usb.marker
+
+usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += usb.module
+MODULE_FILES += usb.module$(EXEEXT)
+usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+nodist_usb_module_SOURCES = ## platform nodist sources
+usb_module_LDADD =
+usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_module_SOURCES)
+CLEANFILES += $(nodist_usb_module_SOURCES)
+MOD_FILES += usb.mod
+MARKER_FILES += usb.marker
+CLEANFILES += usb.marker
+
+usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += usb.module
+MODULE_FILES += usb.module$(EXEEXT)
+usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+nodist_usb_module_SOURCES = ## platform nodist sources
+usb_module_LDADD =
+usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_module_SOURCES)
+CLEANFILES += $(nodist_usb_module_SOURCES)
+MOD_FILES += usb.mod
+MARKER_FILES += usb.marker
+CLEANFILES += usb.marker
+
+usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += usb.module
+MODULE_FILES += usb.module$(EXEEXT)
+usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+nodist_usb_module_SOURCES = ## platform nodist sources
+usb_module_LDADD =
+usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_module_SOURCES)
+CLEANFILES += $(nodist_usb_module_SOURCES)
+MOD_FILES += usb.mod
+MARKER_FILES += usb.marker
+CLEANFILES += usb.marker
+
+usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += usb.module
+MODULE_FILES += usb.module$(EXEEXT)
+usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+nodist_usb_module_SOURCES = ## platform nodist sources
+usb_module_LDADD =
+usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_module_SOURCES)
+CLEANFILES += $(nodist_usb_module_SOURCES)
+MOD_FILES += usb.mod
+MARKER_FILES += usb.marker
+CLEANFILES += usb.marker
+
+usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += usb.module
+MODULE_FILES += usb.module$(EXEEXT)
+usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+nodist_usb_module_SOURCES = ## platform nodist sources
+usb_module_LDADD =
+usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_module_SOURCES)
+CLEANFILES += $(nodist_usb_module_SOURCES)
+MOD_FILES += usb.mod
+MARKER_FILES += usb.marker
+CLEANFILES += usb.marker
+
+usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += usb.module
+MODULE_FILES += usb.module$(EXEEXT)
+usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+nodist_usb_module_SOURCES = ## platform nodist sources
+usb_module_LDADD =
+usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_module_SOURCES)
+CLEANFILES += $(nodist_usb_module_SOURCES)
+MOD_FILES += usb.mod
+MARKER_FILES += usb.marker
+CLEANFILES += usb.marker
+
+usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += usbserial_common.module
+MODULE_FILES += usbserial_common.module$(EXEEXT)
+usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+usbserial_common_module_LDADD =
+usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_common_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_common_module_SOURCES)
+MOD_FILES += usbserial_common.mod
+MARKER_FILES += usbserial_common.marker
+CLEANFILES += usbserial_common.marker
+
+usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += usbserial_common.module
+MODULE_FILES += usbserial_common.module$(EXEEXT)
+usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+usbserial_common_module_LDADD =
+usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_common_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_common_module_SOURCES)
+MOD_FILES += usbserial_common.mod
+MARKER_FILES += usbserial_common.marker
+CLEANFILES += usbserial_common.marker
+
+usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += usbserial_common.module
+MODULE_FILES += usbserial_common.module$(EXEEXT)
+usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+usbserial_common_module_LDADD =
+usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_common_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_common_module_SOURCES)
+MOD_FILES += usbserial_common.mod
+MARKER_FILES += usbserial_common.marker
+CLEANFILES += usbserial_common.marker
+
+usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += usbserial_common.module
+MODULE_FILES += usbserial_common.module$(EXEEXT)
+usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+usbserial_common_module_LDADD =
+usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_common_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_common_module_SOURCES)
+MOD_FILES += usbserial_common.mod
+MARKER_FILES += usbserial_common.marker
+CLEANFILES += usbserial_common.marker
+
+usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += usbserial_common.module
+MODULE_FILES += usbserial_common.module$(EXEEXT)
+usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+usbserial_common_module_LDADD =
+usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_common_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_common_module_SOURCES)
+MOD_FILES += usbserial_common.mod
+MARKER_FILES += usbserial_common.marker
+CLEANFILES += usbserial_common.marker
+
+usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += usbserial_common.module
+MODULE_FILES += usbserial_common.module$(EXEEXT)
+usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+usbserial_common_module_LDADD =
+usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_common_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_common_module_SOURCES)
+MOD_FILES += usbserial_common.mod
+MARKER_FILES += usbserial_common.marker
+CLEANFILES += usbserial_common.marker
+
+usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += usbserial_common.module
+MODULE_FILES += usbserial_common.module$(EXEEXT)
+usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+usbserial_common_module_LDADD =
+usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_common_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_common_module_SOURCES)
+MOD_FILES += usbserial_common.mod
+MARKER_FILES += usbserial_common.marker
+CLEANFILES += usbserial_common.marker
+
+usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += usbserial_common.module
+MODULE_FILES += usbserial_common.module$(EXEEXT)
+usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+usbserial_common_module_LDADD =
+usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_common_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_common_module_SOURCES)
+MOD_FILES += usbserial_common.mod
+MARKER_FILES += usbserial_common.marker
+CLEANFILES += usbserial_common.marker
+
+usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += usbserial_common.module
+MODULE_FILES += usbserial_common.module$(EXEEXT)
+usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+usbserial_common_module_LDADD =
+usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_common_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_common_module_SOURCES)
+MOD_FILES += usbserial_common.mod
+MARKER_FILES += usbserial_common.marker
+CLEANFILES += usbserial_common.marker
+
+usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += usbserial_pl2303.module
+MODULE_FILES += usbserial_pl2303.module$(EXEEXT)
+usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+usbserial_pl2303_module_LDADD =
+usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_pl2303_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_pl2303_module_SOURCES)
+MOD_FILES += usbserial_pl2303.mod
+MARKER_FILES += usbserial_pl2303.marker
+CLEANFILES += usbserial_pl2303.marker
+
+usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += usbserial_pl2303.module
+MODULE_FILES += usbserial_pl2303.module$(EXEEXT)
+usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+usbserial_pl2303_module_LDADD =
+usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_pl2303_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_pl2303_module_SOURCES)
+MOD_FILES += usbserial_pl2303.mod
+MARKER_FILES += usbserial_pl2303.marker
+CLEANFILES += usbserial_pl2303.marker
+
+usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += usbserial_pl2303.module
+MODULE_FILES += usbserial_pl2303.module$(EXEEXT)
+usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+usbserial_pl2303_module_LDADD =
+usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_pl2303_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_pl2303_module_SOURCES)
+MOD_FILES += usbserial_pl2303.mod
+MARKER_FILES += usbserial_pl2303.marker
+CLEANFILES += usbserial_pl2303.marker
+
+usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += usbserial_pl2303.module
+MODULE_FILES += usbserial_pl2303.module$(EXEEXT)
+usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+usbserial_pl2303_module_LDADD =
+usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_pl2303_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_pl2303_module_SOURCES)
+MOD_FILES += usbserial_pl2303.mod
+MARKER_FILES += usbserial_pl2303.marker
+CLEANFILES += usbserial_pl2303.marker
+
+usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += usbserial_pl2303.module
+MODULE_FILES += usbserial_pl2303.module$(EXEEXT)
+usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+usbserial_pl2303_module_LDADD =
+usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_pl2303_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_pl2303_module_SOURCES)
+MOD_FILES += usbserial_pl2303.mod
+MARKER_FILES += usbserial_pl2303.marker
+CLEANFILES += usbserial_pl2303.marker
+
+usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += usbserial_pl2303.module
+MODULE_FILES += usbserial_pl2303.module$(EXEEXT)
+usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+usbserial_pl2303_module_LDADD =
+usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_pl2303_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_pl2303_module_SOURCES)
+MOD_FILES += usbserial_pl2303.mod
+MARKER_FILES += usbserial_pl2303.marker
+CLEANFILES += usbserial_pl2303.marker
+
+usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += usbserial_pl2303.module
+MODULE_FILES += usbserial_pl2303.module$(EXEEXT)
+usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+usbserial_pl2303_module_LDADD =
+usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_pl2303_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_pl2303_module_SOURCES)
+MOD_FILES += usbserial_pl2303.mod
+MARKER_FILES += usbserial_pl2303.marker
+CLEANFILES += usbserial_pl2303.marker
+
+usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += usbserial_pl2303.module
+MODULE_FILES += usbserial_pl2303.module$(EXEEXT)
+usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+usbserial_pl2303_module_LDADD =
+usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_pl2303_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_pl2303_module_SOURCES)
+MOD_FILES += usbserial_pl2303.mod
+MARKER_FILES += usbserial_pl2303.marker
+CLEANFILES += usbserial_pl2303.marker
+
+usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += usbserial_pl2303.module
+MODULE_FILES += usbserial_pl2303.module$(EXEEXT)
+usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+usbserial_pl2303_module_LDADD =
+usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_pl2303_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_pl2303_module_SOURCES)
+MOD_FILES += usbserial_pl2303.mod
+MARKER_FILES += usbserial_pl2303.marker
+CLEANFILES += usbserial_pl2303.marker
+
+usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += usbserial_ftdi.module
+MODULE_FILES += usbserial_ftdi.module$(EXEEXT)
+usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+usbserial_ftdi_module_LDADD =
+usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_ftdi_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_ftdi_module_SOURCES)
+MOD_FILES += usbserial_ftdi.mod
+MARKER_FILES += usbserial_ftdi.marker
+CLEANFILES += usbserial_ftdi.marker
+
+usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += usbserial_ftdi.module
+MODULE_FILES += usbserial_ftdi.module$(EXEEXT)
+usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+usbserial_ftdi_module_LDADD =
+usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_ftdi_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_ftdi_module_SOURCES)
+MOD_FILES += usbserial_ftdi.mod
+MARKER_FILES += usbserial_ftdi.marker
+CLEANFILES += usbserial_ftdi.marker
+
+usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += usbserial_ftdi.module
+MODULE_FILES += usbserial_ftdi.module$(EXEEXT)
+usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+usbserial_ftdi_module_LDADD =
+usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_ftdi_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_ftdi_module_SOURCES)
+MOD_FILES += usbserial_ftdi.mod
+MARKER_FILES += usbserial_ftdi.marker
+CLEANFILES += usbserial_ftdi.marker
+
+usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += usbserial_ftdi.module
+MODULE_FILES += usbserial_ftdi.module$(EXEEXT)
+usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+usbserial_ftdi_module_LDADD =
+usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_ftdi_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_ftdi_module_SOURCES)
+MOD_FILES += usbserial_ftdi.mod
+MARKER_FILES += usbserial_ftdi.marker
+CLEANFILES += usbserial_ftdi.marker
+
+usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += usbserial_ftdi.module
+MODULE_FILES += usbserial_ftdi.module$(EXEEXT)
+usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+usbserial_ftdi_module_LDADD =
+usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_ftdi_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_ftdi_module_SOURCES)
+MOD_FILES += usbserial_ftdi.mod
+MARKER_FILES += usbserial_ftdi.marker
+CLEANFILES += usbserial_ftdi.marker
+
+usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += usbserial_ftdi.module
+MODULE_FILES += usbserial_ftdi.module$(EXEEXT)
+usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+usbserial_ftdi_module_LDADD =
+usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_ftdi_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_ftdi_module_SOURCES)
+MOD_FILES += usbserial_ftdi.mod
+MARKER_FILES += usbserial_ftdi.marker
+CLEANFILES += usbserial_ftdi.marker
+
+usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += usbserial_ftdi.module
+MODULE_FILES += usbserial_ftdi.module$(EXEEXT)
+usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+usbserial_ftdi_module_LDADD =
+usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_ftdi_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_ftdi_module_SOURCES)
+MOD_FILES += usbserial_ftdi.mod
+MARKER_FILES += usbserial_ftdi.marker
+CLEANFILES += usbserial_ftdi.marker
+
+usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += usbserial_ftdi.module
+MODULE_FILES += usbserial_ftdi.module$(EXEEXT)
+usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+usbserial_ftdi_module_LDADD =
+usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_ftdi_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_ftdi_module_SOURCES)
+MOD_FILES += usbserial_ftdi.mod
+MARKER_FILES += usbserial_ftdi.marker
+CLEANFILES += usbserial_ftdi.marker
+
+usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += usbserial_ftdi.module
+MODULE_FILES += usbserial_ftdi.module$(EXEEXT)
+usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+usbserial_ftdi_module_LDADD =
+usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_ftdi_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_ftdi_module_SOURCES)
+MOD_FILES += usbserial_ftdi.mod
+MARKER_FILES += usbserial_ftdi.marker
+CLEANFILES += usbserial_ftdi.marker
+
+usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += usbserial_usbdebug.module
+MODULE_FILES += usbserial_usbdebug.module$(EXEEXT)
+usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+usbserial_usbdebug_module_LDADD =
+usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_usbdebug_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_usbdebug_module_SOURCES)
+MOD_FILES += usbserial_usbdebug.mod
+MARKER_FILES += usbserial_usbdebug.marker
+CLEANFILES += usbserial_usbdebug.marker
+
+usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += usbserial_usbdebug.module
+MODULE_FILES += usbserial_usbdebug.module$(EXEEXT)
+usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+usbserial_usbdebug_module_LDADD =
+usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_usbdebug_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_usbdebug_module_SOURCES)
+MOD_FILES += usbserial_usbdebug.mod
+MARKER_FILES += usbserial_usbdebug.marker
+CLEANFILES += usbserial_usbdebug.marker
+
+usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += usbserial_usbdebug.module
+MODULE_FILES += usbserial_usbdebug.module$(EXEEXT)
+usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+usbserial_usbdebug_module_LDADD =
+usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_usbdebug_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_usbdebug_module_SOURCES)
+MOD_FILES += usbserial_usbdebug.mod
+MARKER_FILES += usbserial_usbdebug.marker
+CLEANFILES += usbserial_usbdebug.marker
+
+usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += usbserial_usbdebug.module
+MODULE_FILES += usbserial_usbdebug.module$(EXEEXT)
+usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+usbserial_usbdebug_module_LDADD =
+usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_usbdebug_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_usbdebug_module_SOURCES)
+MOD_FILES += usbserial_usbdebug.mod
+MARKER_FILES += usbserial_usbdebug.marker
+CLEANFILES += usbserial_usbdebug.marker
+
+usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += usbserial_usbdebug.module
+MODULE_FILES += usbserial_usbdebug.module$(EXEEXT)
+usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+usbserial_usbdebug_module_LDADD =
+usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_usbdebug_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_usbdebug_module_SOURCES)
+MOD_FILES += usbserial_usbdebug.mod
+MARKER_FILES += usbserial_usbdebug.marker
+CLEANFILES += usbserial_usbdebug.marker
+
+usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += usbserial_usbdebug.module
+MODULE_FILES += usbserial_usbdebug.module$(EXEEXT)
+usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+usbserial_usbdebug_module_LDADD =
+usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_usbdebug_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_usbdebug_module_SOURCES)
+MOD_FILES += usbserial_usbdebug.mod
+MARKER_FILES += usbserial_usbdebug.marker
+CLEANFILES += usbserial_usbdebug.marker
+
+usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += usbserial_usbdebug.module
+MODULE_FILES += usbserial_usbdebug.module$(EXEEXT)
+usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+usbserial_usbdebug_module_LDADD =
+usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_usbdebug_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_usbdebug_module_SOURCES)
+MOD_FILES += usbserial_usbdebug.mod
+MARKER_FILES += usbserial_usbdebug.marker
+CLEANFILES += usbserial_usbdebug.marker
+
+usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += usbserial_usbdebug.module
+MODULE_FILES += usbserial_usbdebug.module$(EXEEXT)
+usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+usbserial_usbdebug_module_LDADD =
+usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_usbdebug_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_usbdebug_module_SOURCES)
+MOD_FILES += usbserial_usbdebug.mod
+MARKER_FILES += usbserial_usbdebug.marker
+CLEANFILES += usbserial_usbdebug.marker
+
+usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += usbserial_usbdebug.module
+MODULE_FILES += usbserial_usbdebug.module$(EXEEXT)
+usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+usbserial_usbdebug_module_LDADD =
+usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbserial_usbdebug_module_SOURCES)
+CLEANFILES += $(nodist_usbserial_usbdebug_module_SOURCES)
+MOD_FILES += usbserial_usbdebug.mod
+MARKER_FILES += usbserial_usbdebug.marker
+CLEANFILES += usbserial_usbdebug.marker
+
+usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += uhci.module
+MODULE_FILES += uhci.module$(EXEEXT)
+uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+nodist_uhci_module_SOURCES = ## platform nodist sources
+uhci_module_LDADD =
+uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_uhci_module_SOURCES)
+CLEANFILES += $(nodist_uhci_module_SOURCES)
+MOD_FILES += uhci.mod
+MARKER_FILES += uhci.marker
+CLEANFILES += uhci.marker
+
+uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += uhci.module
+MODULE_FILES += uhci.module$(EXEEXT)
+uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+nodist_uhci_module_SOURCES = ## platform nodist sources
+uhci_module_LDADD =
+uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_uhci_module_SOURCES)
+CLEANFILES += $(nodist_uhci_module_SOURCES)
+MOD_FILES += uhci.mod
+MARKER_FILES += uhci.marker
+CLEANFILES += uhci.marker
+
+uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += uhci.module
+MODULE_FILES += uhci.module$(EXEEXT)
+uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+nodist_uhci_module_SOURCES = ## platform nodist sources
+uhci_module_LDADD =
+uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_uhci_module_SOURCES)
+CLEANFILES += $(nodist_uhci_module_SOURCES)
+MOD_FILES += uhci.mod
+MARKER_FILES += uhci.marker
+CLEANFILES += uhci.marker
+
+uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += uhci.module
+MODULE_FILES += uhci.module$(EXEEXT)
+uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+nodist_uhci_module_SOURCES = ## platform nodist sources
+uhci_module_LDADD =
+uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_uhci_module_SOURCES)
+CLEANFILES += $(nodist_uhci_module_SOURCES)
+MOD_FILES += uhci.mod
+MARKER_FILES += uhci.marker
+CLEANFILES += uhci.marker
+
+uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += uhci.module
+MODULE_FILES += uhci.module$(EXEEXT)
+uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+nodist_uhci_module_SOURCES = ## platform nodist sources
+uhci_module_LDADD =
+uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_uhci_module_SOURCES)
+CLEANFILES += $(nodist_uhci_module_SOURCES)
+MOD_FILES += uhci.mod
+MARKER_FILES += uhci.marker
+CLEANFILES += uhci.marker
+
+uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += uhci.module
+MODULE_FILES += uhci.module$(EXEEXT)
+uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+nodist_uhci_module_SOURCES = ## platform nodist sources
+uhci_module_LDADD =
+uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_uhci_module_SOURCES)
+CLEANFILES += $(nodist_uhci_module_SOURCES)
+MOD_FILES += uhci.mod
+MARKER_FILES += uhci.marker
+CLEANFILES += uhci.marker
+
+uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += uhci.module
+MODULE_FILES += uhci.module$(EXEEXT)
+uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+nodist_uhci_module_SOURCES = ## platform nodist sources
+uhci_module_LDADD =
+uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_uhci_module_SOURCES)
+CLEANFILES += $(nodist_uhci_module_SOURCES)
+MOD_FILES += uhci.mod
+MARKER_FILES += uhci.marker
+CLEANFILES += uhci.marker
+
+uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += uhci.module
+MODULE_FILES += uhci.module$(EXEEXT)
+uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+nodist_uhci_module_SOURCES = ## platform nodist sources
+uhci_module_LDADD =
+uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_uhci_module_SOURCES)
+CLEANFILES += $(nodist_uhci_module_SOURCES)
+MOD_FILES += uhci.mod
+MARKER_FILES += uhci.marker
+CLEANFILES += uhci.marker
+
+uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += ohci.module
+MODULE_FILES += ohci.module$(EXEEXT)
+ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+nodist_ohci_module_SOURCES = ## platform nodist sources
+ohci_module_LDADD =
+ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ohci_module_SOURCES)
+CLEANFILES += $(nodist_ohci_module_SOURCES)
+MOD_FILES += ohci.mod
+MARKER_FILES += ohci.marker
+CLEANFILES += ohci.marker
+
+ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += ohci.module
+MODULE_FILES += ohci.module$(EXEEXT)
+ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+nodist_ohci_module_SOURCES = ## platform nodist sources
+ohci_module_LDADD =
+ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ohci_module_SOURCES)
+CLEANFILES += $(nodist_ohci_module_SOURCES)
+MOD_FILES += ohci.mod
+MARKER_FILES += ohci.marker
+CLEANFILES += ohci.marker
+
+ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += ohci.module
+MODULE_FILES += ohci.module$(EXEEXT)
+ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+nodist_ohci_module_SOURCES = ## platform nodist sources
+ohci_module_LDADD =
+ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ohci_module_SOURCES)
+CLEANFILES += $(nodist_ohci_module_SOURCES)
+MOD_FILES += ohci.mod
+MARKER_FILES += ohci.marker
+CLEANFILES += ohci.marker
+
+ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += ohci.module
+MODULE_FILES += ohci.module$(EXEEXT)
+ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+nodist_ohci_module_SOURCES = ## platform nodist sources
+ohci_module_LDADD =
+ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ohci_module_SOURCES)
+CLEANFILES += $(nodist_ohci_module_SOURCES)
+MOD_FILES += ohci.mod
+MARKER_FILES += ohci.marker
+CLEANFILES += ohci.marker
+
+ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += ohci.module
+MODULE_FILES += ohci.module$(EXEEXT)
+ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+nodist_ohci_module_SOURCES = ## platform nodist sources
+ohci_module_LDADD =
+ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ohci_module_SOURCES)
+CLEANFILES += $(nodist_ohci_module_SOURCES)
+MOD_FILES += ohci.mod
+MARKER_FILES += ohci.marker
+CLEANFILES += ohci.marker
+
+ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += ohci.module
+MODULE_FILES += ohci.module$(EXEEXT)
+ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+nodist_ohci_module_SOURCES = ## platform nodist sources
+ohci_module_LDADD =
+ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ohci_module_SOURCES)
+CLEANFILES += $(nodist_ohci_module_SOURCES)
+MOD_FILES += ohci.mod
+MARKER_FILES += ohci.marker
+CLEANFILES += ohci.marker
+
+ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += ohci.module
+MODULE_FILES += ohci.module$(EXEEXT)
+ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+nodist_ohci_module_SOURCES = ## platform nodist sources
+ohci_module_LDADD =
+ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ohci_module_SOURCES)
+CLEANFILES += $(nodist_ohci_module_SOURCES)
+MOD_FILES += ohci.mod
+MARKER_FILES += ohci.marker
+CLEANFILES += ohci.marker
+
+ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += ohci.module
+MODULE_FILES += ohci.module$(EXEEXT)
+ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+nodist_ohci_module_SOURCES = ## platform nodist sources
+ohci_module_LDADD =
+ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ohci_module_SOURCES)
+CLEANFILES += $(nodist_ohci_module_SOURCES)
+MOD_FILES += ohci.mod
+MARKER_FILES += ohci.marker
+CLEANFILES += ohci.marker
+
+ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += ehci.module
+MODULE_FILES += ehci.module$(EXEEXT)
+ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+nodist_ehci_module_SOURCES = ## platform nodist sources
+ehci_module_LDADD =
+ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ehci_module_SOURCES)
+CLEANFILES += $(nodist_ehci_module_SOURCES)
+MOD_FILES += ehci.mod
+MARKER_FILES += ehci.marker
+CLEANFILES += ehci.marker
+
+ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += ehci.module
+MODULE_FILES += ehci.module$(EXEEXT)
+ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+nodist_ehci_module_SOURCES = ## platform nodist sources
+ehci_module_LDADD =
+ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ehci_module_SOURCES)
+CLEANFILES += $(nodist_ehci_module_SOURCES)
+MOD_FILES += ehci.mod
+MARKER_FILES += ehci.marker
+CLEANFILES += ehci.marker
+
+ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += ehci.module
+MODULE_FILES += ehci.module$(EXEEXT)
+ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+nodist_ehci_module_SOURCES = ## platform nodist sources
+ehci_module_LDADD =
+ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ehci_module_SOURCES)
+CLEANFILES += $(nodist_ehci_module_SOURCES)
+MOD_FILES += ehci.mod
+MARKER_FILES += ehci.marker
+CLEANFILES += ehci.marker
+
+ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += ehci.module
+MODULE_FILES += ehci.module$(EXEEXT)
+ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+nodist_ehci_module_SOURCES = ## platform nodist sources
+ehci_module_LDADD =
+ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ehci_module_SOURCES)
+CLEANFILES += $(nodist_ehci_module_SOURCES)
+MOD_FILES += ehci.mod
+MARKER_FILES += ehci.marker
+CLEANFILES += ehci.marker
+
+ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += ehci.module
+MODULE_FILES += ehci.module$(EXEEXT)
+ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+nodist_ehci_module_SOURCES = ## platform nodist sources
+ehci_module_LDADD =
+ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ehci_module_SOURCES)
+CLEANFILES += $(nodist_ehci_module_SOURCES)
+MOD_FILES += ehci.mod
+MARKER_FILES += ehci.marker
+CLEANFILES += ehci.marker
+
+ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += ehci.module
+MODULE_FILES += ehci.module$(EXEEXT)
+ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+nodist_ehci_module_SOURCES = ## platform nodist sources
+ehci_module_LDADD =
+ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ehci_module_SOURCES)
+CLEANFILES += $(nodist_ehci_module_SOURCES)
+MOD_FILES += ehci.mod
+MARKER_FILES += ehci.marker
+CLEANFILES += ehci.marker
+
+ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += ehci.module
+MODULE_FILES += ehci.module$(EXEEXT)
+ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+nodist_ehci_module_SOURCES = ## platform nodist sources
+ehci_module_LDADD =
+ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ehci_module_SOURCES)
+CLEANFILES += $(nodist_ehci_module_SOURCES)
+MOD_FILES += ehci.mod
+MARKER_FILES += ehci.marker
+CLEANFILES += ehci.marker
+
+ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += ehci.module
+MODULE_FILES += ehci.module$(EXEEXT)
+ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+nodist_ehci_module_SOURCES = ## platform nodist sources
+ehci_module_LDADD =
+ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ehci_module_SOURCES)
+CLEANFILES += $(nodist_ehci_module_SOURCES)
+MOD_FILES += ehci.mod
+MARKER_FILES += ehci.marker
+CLEANFILES += ehci.marker
+
+ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += ehci.module
+MODULE_FILES += ehci.module$(EXEEXT)
+ehci_module_SOURCES = bus/usb/ehci-fdt.c bus/usb/ehci.c ## platform sources
+nodist_ehci_module_SOURCES = ## platform nodist sources
+ehci_module_LDADD =
+ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ehci_module_SOURCES)
+CLEANFILES += $(nodist_ehci_module_SOURCES)
+MOD_FILES += ehci.mod
+MARKER_FILES += ehci.marker
+CLEANFILES += ehci.marker
+
+ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += pci.module
+MODULE_FILES += pci.module$(EXEEXT)
+pci_module_SOURCES = bus/pci.c ## platform sources
+nodist_pci_module_SOURCES = ## platform nodist sources
+pci_module_LDADD =
+pci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pci_module_SOURCES)
+CLEANFILES += $(nodist_pci_module_SOURCES)
+MOD_FILES += pci.mod
+MARKER_FILES += pci.marker
+CLEANFILES += pci.marker
+
+pci.marker: $(pci_module_SOURCES) $(nodist_pci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += pci.module
+MODULE_FILES += pci.module$(EXEEXT)
+pci_module_SOURCES = bus/pci.c ## platform sources
+nodist_pci_module_SOURCES = ## platform nodist sources
+pci_module_LDADD =
+pci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pci_module_SOURCES)
+CLEANFILES += $(nodist_pci_module_SOURCES)
+MOD_FILES += pci.mod
+MARKER_FILES += pci.marker
+CLEANFILES += pci.marker
+
+pci.marker: $(pci_module_SOURCES) $(nodist_pci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += pci.module
+MODULE_FILES += pci.module$(EXEEXT)
+pci_module_SOURCES = bus/pci.c ## platform sources
+nodist_pci_module_SOURCES = ## platform nodist sources
+pci_module_LDADD =
+pci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pci_module_SOURCES)
+CLEANFILES += $(nodist_pci_module_SOURCES)
+MOD_FILES += pci.mod
+MARKER_FILES += pci.marker
+CLEANFILES += pci.marker
+
+pci.marker: $(pci_module_SOURCES) $(nodist_pci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += pci.module
+MODULE_FILES += pci.module$(EXEEXT)
+pci_module_SOURCES = bus/i386/ieee1275/pci.c bus/pci.c ## platform sources
+nodist_pci_module_SOURCES = ## platform nodist sources
+pci_module_LDADD =
+pci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pci_module_SOURCES)
+CLEANFILES += $(nodist_pci_module_SOURCES)
+MOD_FILES += pci.mod
+MARKER_FILES += pci.marker
+CLEANFILES += pci.marker
+
+pci.marker: $(pci_module_SOURCES) $(nodist_pci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += nativedisk.module
+MODULE_FILES += nativedisk.module$(EXEEXT)
+nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+nodist_nativedisk_module_SOURCES = ## platform nodist sources
+nativedisk_module_LDADD =
+nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nativedisk_module_SOURCES)
+CLEANFILES += $(nodist_nativedisk_module_SOURCES)
+MOD_FILES += nativedisk.mod
+MARKER_FILES += nativedisk.marker
+CLEANFILES += nativedisk.marker
+
+nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += nativedisk.module
+MODULE_FILES += nativedisk.module$(EXEEXT)
+nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+nodist_nativedisk_module_SOURCES = ## platform nodist sources
+nativedisk_module_LDADD =
+nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nativedisk_module_SOURCES)
+CLEANFILES += $(nodist_nativedisk_module_SOURCES)
+MOD_FILES += nativedisk.mod
+MARKER_FILES += nativedisk.marker
+CLEANFILES += nativedisk.marker
+
+nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += nativedisk.module
+MODULE_FILES += nativedisk.module$(EXEEXT)
+nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+nodist_nativedisk_module_SOURCES = ## platform nodist sources
+nativedisk_module_LDADD =
+nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nativedisk_module_SOURCES)
+CLEANFILES += $(nodist_nativedisk_module_SOURCES)
+MOD_FILES += nativedisk.mod
+MARKER_FILES += nativedisk.marker
+CLEANFILES += nativedisk.marker
+
+nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += nativedisk.module
+MODULE_FILES += nativedisk.module$(EXEEXT)
+nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+nodist_nativedisk_module_SOURCES = ## platform nodist sources
+nativedisk_module_LDADD =
+nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nativedisk_module_SOURCES)
+CLEANFILES += $(nodist_nativedisk_module_SOURCES)
+MOD_FILES += nativedisk.mod
+MARKER_FILES += nativedisk.marker
+CLEANFILES += nativedisk.marker
+
+nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += nativedisk.module
+MODULE_FILES += nativedisk.module$(EXEEXT)
+nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+nodist_nativedisk_module_SOURCES = ## platform nodist sources
+nativedisk_module_LDADD =
+nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nativedisk_module_SOURCES)
+CLEANFILES += $(nodist_nativedisk_module_SOURCES)
+MOD_FILES += nativedisk.mod
+MARKER_FILES += nativedisk.marker
+CLEANFILES += nativedisk.marker
+
+nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += nativedisk.module
+MODULE_FILES += nativedisk.module$(EXEEXT)
+nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+nodist_nativedisk_module_SOURCES = ## platform nodist sources
+nativedisk_module_LDADD =
+nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nativedisk_module_SOURCES)
+CLEANFILES += $(nodist_nativedisk_module_SOURCES)
+MOD_FILES += nativedisk.mod
+MARKER_FILES += nativedisk.marker
+CLEANFILES += nativedisk.marker
+
+nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += nativedisk.module
+MODULE_FILES += nativedisk.module$(EXEEXT)
+nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+nodist_nativedisk_module_SOURCES = ## platform nodist sources
+nativedisk_module_LDADD =
+nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nativedisk_module_SOURCES)
+CLEANFILES += $(nodist_nativedisk_module_SOURCES)
+MOD_FILES += nativedisk.mod
+MARKER_FILES += nativedisk.marker
+CLEANFILES += nativedisk.marker
+
+nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += nativedisk.module
+MODULE_FILES += nativedisk.module$(EXEEXT)
+nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+nodist_nativedisk_module_SOURCES = ## platform nodist sources
+nativedisk_module_LDADD =
+nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nativedisk_module_SOURCES)
+CLEANFILES += $(nodist_nativedisk_module_SOURCES)
+MOD_FILES += nativedisk.mod
+MARKER_FILES += nativedisk.marker
+CLEANFILES += nativedisk.marker
+
+nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += nativedisk.module
+MODULE_FILES += nativedisk.module$(EXEEXT)
+nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+nodist_nativedisk_module_SOURCES = ## platform nodist sources
+nativedisk_module_LDADD =
+nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nativedisk_module_SOURCES)
+CLEANFILES += $(nodist_nativedisk_module_SOURCES)
+MOD_FILES += nativedisk.mod
+MARKER_FILES += nativedisk.marker
+CLEANFILES += nativedisk.marker
+
+nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+if COND_GRUB_EMU_PCI
+platform_PROGRAMS += emupci.module
+MODULE_FILES += emupci.module$(EXEEXT)
+emupci_module_SOURCES = bus/emu/pci.c commands/lspci.c ## platform sources
+nodist_emupci_module_SOURCES = ## platform nodist sources
+emupci_module_LDADD =
+emupci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+emupci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+emupci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+emupci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+emupci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_emupci_module_SOURCES)
+CLEANFILES += $(nodist_emupci_module_SOURCES)
+MOD_FILES += emupci.mod
+MARKER_FILES += emupci.marker
+CLEANFILES += emupci.marker
+
+emupci.marker: $(emupci_module_SOURCES) $(nodist_emupci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emupci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif COND_GRUB_EMU_PCI
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += lsdev.module
+MODULE_FILES += lsdev.module$(EXEEXT)
+lsdev_module_SOURCES = commands/arc/lsdev.c ## platform sources
+nodist_lsdev_module_SOURCES = ## platform nodist sources
+lsdev_module_LDADD =
+lsdev_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsdev_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsdev_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsdev_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsdev_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsdev_module_SOURCES)
+CLEANFILES += $(nodist_lsdev_module_SOURCES)
+MOD_FILES += lsdev.mod
+MARKER_FILES += lsdev.marker
+CLEANFILES += lsdev.marker
+
+lsdev.marker: $(lsdev_module_SOURCES) $(nodist_lsdev_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsdev_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += lsxen.module
+MODULE_FILES += lsxen.module$(EXEEXT)
+lsxen_module_SOURCES = commands/xen/lsxen.c ## platform sources
+nodist_lsxen_module_SOURCES = ## platform nodist sources
+lsxen_module_LDADD =
+lsxen_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsxen_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsxen_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsxen_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsxen_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsxen_module_SOURCES)
+CLEANFILES += $(nodist_lsxen_module_SOURCES)
+MOD_FILES += lsxen.mod
+MARKER_FILES += lsxen.marker
+CLEANFILES += lsxen.marker
+
+lsxen.marker: $(lsxen_module_SOURCES) $(nodist_lsxen_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsxen_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += lsxen.module
+MODULE_FILES += lsxen.module$(EXEEXT)
+lsxen_module_SOURCES = commands/xen/lsxen.c ## platform sources
+nodist_lsxen_module_SOURCES = ## platform nodist sources
+lsxen_module_LDADD =
+lsxen_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsxen_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsxen_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsxen_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsxen_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsxen_module_SOURCES)
+CLEANFILES += $(nodist_lsxen_module_SOURCES)
+MOD_FILES += lsxen.mod
+MARKER_FILES += lsxen.marker
+CLEANFILES += lsxen.marker
+
+lsxen.marker: $(lsxen_module_SOURCES) $(nodist_lsxen_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsxen_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += cmostest.module
+MODULE_FILES += cmostest.module$(EXEEXT)
+cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+nodist_cmostest_module_SOURCES = ## platform nodist sources
+cmostest_module_LDADD =
+cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmostest_module_SOURCES)
+CLEANFILES += $(nodist_cmostest_module_SOURCES)
+MOD_FILES += cmostest.mod
+MARKER_FILES += cmostest.marker
+CLEANFILES += cmostest.marker
+
+cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += cmostest.module
+MODULE_FILES += cmostest.module$(EXEEXT)
+cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+nodist_cmostest_module_SOURCES = ## platform nodist sources
+cmostest_module_LDADD =
+cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmostest_module_SOURCES)
+CLEANFILES += $(nodist_cmostest_module_SOURCES)
+MOD_FILES += cmostest.mod
+MARKER_FILES += cmostest.marker
+CLEANFILES += cmostest.marker
+
+cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += cmostest.module
+MODULE_FILES += cmostest.module$(EXEEXT)
+cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+nodist_cmostest_module_SOURCES = ## platform nodist sources
+cmostest_module_LDADD =
+cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmostest_module_SOURCES)
+CLEANFILES += $(nodist_cmostest_module_SOURCES)
+MOD_FILES += cmostest.mod
+MARKER_FILES += cmostest.marker
+CLEANFILES += cmostest.marker
+
+cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += cmostest.module
+MODULE_FILES += cmostest.module$(EXEEXT)
+cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+nodist_cmostest_module_SOURCES = ## platform nodist sources
+cmostest_module_LDADD =
+cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmostest_module_SOURCES)
+CLEANFILES += $(nodist_cmostest_module_SOURCES)
+MOD_FILES += cmostest.mod
+MARKER_FILES += cmostest.marker
+CLEANFILES += cmostest.marker
+
+cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += cmostest.module
+MODULE_FILES += cmostest.module$(EXEEXT)
+cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+nodist_cmostest_module_SOURCES = ## platform nodist sources
+cmostest_module_LDADD =
+cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmostest_module_SOURCES)
+CLEANFILES += $(nodist_cmostest_module_SOURCES)
+MOD_FILES += cmostest.mod
+MARKER_FILES += cmostest.marker
+CLEANFILES += cmostest.marker
+
+cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += cmostest.module
+MODULE_FILES += cmostest.module$(EXEEXT)
+cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+nodist_cmostest_module_SOURCES = ## platform nodist sources
+cmostest_module_LDADD =
+cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmostest_module_SOURCES)
+CLEANFILES += $(nodist_cmostest_module_SOURCES)
+MOD_FILES += cmostest.mod
+MARKER_FILES += cmostest.marker
+CLEANFILES += cmostest.marker
+
+cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += cmostest.module
+MODULE_FILES += cmostest.module$(EXEEXT)
+cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+nodist_cmostest_module_SOURCES = ## platform nodist sources
+cmostest_module_LDADD =
+cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmostest_module_SOURCES)
+CLEANFILES += $(nodist_cmostest_module_SOURCES)
+MOD_FILES += cmostest.mod
+MARKER_FILES += cmostest.marker
+CLEANFILES += cmostest.marker
+
+cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += cmostest.module
+MODULE_FILES += cmostest.module$(EXEEXT)
+cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+nodist_cmostest_module_SOURCES = ## platform nodist sources
+cmostest_module_LDADD =
+cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmostest_module_SOURCES)
+CLEANFILES += $(nodist_cmostest_module_SOURCES)
+MOD_FILES += cmostest.mod
+MARKER_FILES += cmostest.marker
+CLEANFILES += cmostest.marker
+
+cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += cmostest.module
+MODULE_FILES += cmostest.module$(EXEEXT)
+cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+nodist_cmostest_module_SOURCES = ## platform nodist sources
+cmostest_module_LDADD =
+cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmostest_module_SOURCES)
+CLEANFILES += $(nodist_cmostest_module_SOURCES)
+MOD_FILES += cmostest.mod
+MARKER_FILES += cmostest.marker
+CLEANFILES += cmostest.marker
+
+cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += cmosdump.module
+MODULE_FILES += cmosdump.module$(EXEEXT)
+cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+nodist_cmosdump_module_SOURCES = ## platform nodist sources
+cmosdump_module_LDADD =
+cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmosdump_module_SOURCES)
+CLEANFILES += $(nodist_cmosdump_module_SOURCES)
+MOD_FILES += cmosdump.mod
+MARKER_FILES += cmosdump.marker
+CLEANFILES += cmosdump.marker
+
+cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += cmosdump.module
+MODULE_FILES += cmosdump.module$(EXEEXT)
+cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+nodist_cmosdump_module_SOURCES = ## platform nodist sources
+cmosdump_module_LDADD =
+cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmosdump_module_SOURCES)
+CLEANFILES += $(nodist_cmosdump_module_SOURCES)
+MOD_FILES += cmosdump.mod
+MARKER_FILES += cmosdump.marker
+CLEANFILES += cmosdump.marker
+
+cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += cmosdump.module
+MODULE_FILES += cmosdump.module$(EXEEXT)
+cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+nodist_cmosdump_module_SOURCES = ## platform nodist sources
+cmosdump_module_LDADD =
+cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmosdump_module_SOURCES)
+CLEANFILES += $(nodist_cmosdump_module_SOURCES)
+MOD_FILES += cmosdump.mod
+MARKER_FILES += cmosdump.marker
+CLEANFILES += cmosdump.marker
+
+cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += cmosdump.module
+MODULE_FILES += cmosdump.module$(EXEEXT)
+cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+nodist_cmosdump_module_SOURCES = ## platform nodist sources
+cmosdump_module_LDADD =
+cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmosdump_module_SOURCES)
+CLEANFILES += $(nodist_cmosdump_module_SOURCES)
+MOD_FILES += cmosdump.mod
+MARKER_FILES += cmosdump.marker
+CLEANFILES += cmosdump.marker
+
+cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += cmosdump.module
+MODULE_FILES += cmosdump.module$(EXEEXT)
+cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+nodist_cmosdump_module_SOURCES = ## platform nodist sources
+cmosdump_module_LDADD =
+cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmosdump_module_SOURCES)
+CLEANFILES += $(nodist_cmosdump_module_SOURCES)
+MOD_FILES += cmosdump.mod
+MARKER_FILES += cmosdump.marker
+CLEANFILES += cmosdump.marker
+
+cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += cmosdump.module
+MODULE_FILES += cmosdump.module$(EXEEXT)
+cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+nodist_cmosdump_module_SOURCES = ## platform nodist sources
+cmosdump_module_LDADD =
+cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmosdump_module_SOURCES)
+CLEANFILES += $(nodist_cmosdump_module_SOURCES)
+MOD_FILES += cmosdump.mod
+MARKER_FILES += cmosdump.marker
+CLEANFILES += cmosdump.marker
+
+cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += cmosdump.module
+MODULE_FILES += cmosdump.module$(EXEEXT)
+cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+nodist_cmosdump_module_SOURCES = ## platform nodist sources
+cmosdump_module_LDADD =
+cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmosdump_module_SOURCES)
+CLEANFILES += $(nodist_cmosdump_module_SOURCES)
+MOD_FILES += cmosdump.mod
+MARKER_FILES += cmosdump.marker
+CLEANFILES += cmosdump.marker
+
+cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += cmosdump.module
+MODULE_FILES += cmosdump.module$(EXEEXT)
+cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+nodist_cmosdump_module_SOURCES = ## platform nodist sources
+cmosdump_module_LDADD =
+cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmosdump_module_SOURCES)
+CLEANFILES += $(nodist_cmosdump_module_SOURCES)
+MOD_FILES += cmosdump.mod
+MARKER_FILES += cmosdump.marker
+CLEANFILES += cmosdump.marker
+
+cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += cmosdump.module
+MODULE_FILES += cmosdump.module$(EXEEXT)
+cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+nodist_cmosdump_module_SOURCES = ## platform nodist sources
+cmosdump_module_LDADD =
+cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmosdump_module_SOURCES)
+CLEANFILES += $(nodist_cmosdump_module_SOURCES)
+MOD_FILES += cmosdump.mod
+MARKER_FILES += cmosdump.marker
+CLEANFILES += cmosdump.marker
+
+cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += iorw.module
+MODULE_FILES += iorw.module$(EXEEXT)
+iorw_module_SOURCES = commands/iorw.c ## platform sources
+nodist_iorw_module_SOURCES = ## platform nodist sources
+iorw_module_LDADD =
+iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_iorw_module_SOURCES)
+CLEANFILES += $(nodist_iorw_module_SOURCES)
+MOD_FILES += iorw.mod
+MARKER_FILES += iorw.marker
+CLEANFILES += iorw.marker
+
+iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += iorw.module
+MODULE_FILES += iorw.module$(EXEEXT)
+iorw_module_SOURCES = commands/iorw.c ## platform sources
+nodist_iorw_module_SOURCES = ## platform nodist sources
+iorw_module_LDADD =
+iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_iorw_module_SOURCES)
+CLEANFILES += $(nodist_iorw_module_SOURCES)
+MOD_FILES += iorw.mod
+MARKER_FILES += iorw.marker
+CLEANFILES += iorw.marker
+
+iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += iorw.module
+MODULE_FILES += iorw.module$(EXEEXT)
+iorw_module_SOURCES = commands/iorw.c ## platform sources
+nodist_iorw_module_SOURCES = ## platform nodist sources
+iorw_module_LDADD =
+iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_iorw_module_SOURCES)
+CLEANFILES += $(nodist_iorw_module_SOURCES)
+MOD_FILES += iorw.mod
+MARKER_FILES += iorw.marker
+CLEANFILES += iorw.marker
+
+iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += iorw.module
+MODULE_FILES += iorw.module$(EXEEXT)
+iorw_module_SOURCES = commands/iorw.c ## platform sources
+nodist_iorw_module_SOURCES = ## platform nodist sources
+iorw_module_LDADD =
+iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_iorw_module_SOURCES)
+CLEANFILES += $(nodist_iorw_module_SOURCES)
+MOD_FILES += iorw.mod
+MARKER_FILES += iorw.marker
+CLEANFILES += iorw.marker
+
+iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += iorw.module
+MODULE_FILES += iorw.module$(EXEEXT)
+iorw_module_SOURCES = commands/iorw.c ## platform sources
+nodist_iorw_module_SOURCES = ## platform nodist sources
+iorw_module_LDADD =
+iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_iorw_module_SOURCES)
+CLEANFILES += $(nodist_iorw_module_SOURCES)
+MOD_FILES += iorw.mod
+MARKER_FILES += iorw.marker
+CLEANFILES += iorw.marker
+
+iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += iorw.module
+MODULE_FILES += iorw.module$(EXEEXT)
+iorw_module_SOURCES = commands/iorw.c ## platform sources
+nodist_iorw_module_SOURCES = ## platform nodist sources
+iorw_module_LDADD =
+iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_iorw_module_SOURCES)
+CLEANFILES += $(nodist_iorw_module_SOURCES)
+MOD_FILES += iorw.mod
+MARKER_FILES += iorw.marker
+CLEANFILES += iorw.marker
+
+iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += iorw.module
+MODULE_FILES += iorw.module$(EXEEXT)
+iorw_module_SOURCES = commands/iorw.c ## platform sources
+nodist_iorw_module_SOURCES = ## platform nodist sources
+iorw_module_LDADD =
+iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_iorw_module_SOURCES)
+CLEANFILES += $(nodist_iorw_module_SOURCES)
+MOD_FILES += iorw.mod
+MARKER_FILES += iorw.marker
+CLEANFILES += iorw.marker
+
+iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += cbtable.module
+MODULE_FILES += cbtable.module$(EXEEXT)
+cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+nodist_cbtable_module_SOURCES = ## platform nodist sources
+cbtable_module_LDADD =
+cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtable_module_SOURCES)
+CLEANFILES += $(nodist_cbtable_module_SOURCES)
+MOD_FILES += cbtable.mod
+MARKER_FILES += cbtable.marker
+CLEANFILES += cbtable.marker
+
+cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += cbtable.module
+MODULE_FILES += cbtable.module$(EXEEXT)
+cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+nodist_cbtable_module_SOURCES = ## platform nodist sources
+cbtable_module_LDADD =
+cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtable_module_SOURCES)
+CLEANFILES += $(nodist_cbtable_module_SOURCES)
+MOD_FILES += cbtable.mod
+MARKER_FILES += cbtable.marker
+CLEANFILES += cbtable.marker
+
+cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += cbtable.module
+MODULE_FILES += cbtable.module$(EXEEXT)
+cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+nodist_cbtable_module_SOURCES = ## platform nodist sources
+cbtable_module_LDADD =
+cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtable_module_SOURCES)
+CLEANFILES += $(nodist_cbtable_module_SOURCES)
+MOD_FILES += cbtable.mod
+MARKER_FILES += cbtable.marker
+CLEANFILES += cbtable.marker
+
+cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += cbtable.module
+MODULE_FILES += cbtable.module$(EXEEXT)
+cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+nodist_cbtable_module_SOURCES = ## platform nodist sources
+cbtable_module_LDADD =
+cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtable_module_SOURCES)
+CLEANFILES += $(nodist_cbtable_module_SOURCES)
+MOD_FILES += cbtable.mod
+MARKER_FILES += cbtable.marker
+CLEANFILES += cbtable.marker
+
+cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += cbtable.module
+MODULE_FILES += cbtable.module$(EXEEXT)
+cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+nodist_cbtable_module_SOURCES = ## platform nodist sources
+cbtable_module_LDADD =
+cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtable_module_SOURCES)
+CLEANFILES += $(nodist_cbtable_module_SOURCES)
+MOD_FILES += cbtable.mod
+MARKER_FILES += cbtable.marker
+CLEANFILES += cbtable.marker
+
+cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += cbtable.module
+MODULE_FILES += cbtable.module$(EXEEXT)
+cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+nodist_cbtable_module_SOURCES = ## platform nodist sources
+cbtable_module_LDADD =
+cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtable_module_SOURCES)
+CLEANFILES += $(nodist_cbtable_module_SOURCES)
+MOD_FILES += cbtable.mod
+MARKER_FILES += cbtable.marker
+CLEANFILES += cbtable.marker
+
+cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += cbtime.module
+MODULE_FILES += cbtime.module$(EXEEXT)
+cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+nodist_cbtime_module_SOURCES = ## platform nodist sources
+cbtime_module_LDADD =
+cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtime_module_SOURCES)
+CLEANFILES += $(nodist_cbtime_module_SOURCES)
+MOD_FILES += cbtime.mod
+MARKER_FILES += cbtime.marker
+CLEANFILES += cbtime.marker
+
+cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += cbtime.module
+MODULE_FILES += cbtime.module$(EXEEXT)
+cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+nodist_cbtime_module_SOURCES = ## platform nodist sources
+cbtime_module_LDADD =
+cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtime_module_SOURCES)
+CLEANFILES += $(nodist_cbtime_module_SOURCES)
+MOD_FILES += cbtime.mod
+MARKER_FILES += cbtime.marker
+CLEANFILES += cbtime.marker
+
+cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += cbtime.module
+MODULE_FILES += cbtime.module$(EXEEXT)
+cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+nodist_cbtime_module_SOURCES = ## platform nodist sources
+cbtime_module_LDADD =
+cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtime_module_SOURCES)
+CLEANFILES += $(nodist_cbtime_module_SOURCES)
+MOD_FILES += cbtime.mod
+MARKER_FILES += cbtime.marker
+CLEANFILES += cbtime.marker
+
+cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += cbtime.module
+MODULE_FILES += cbtime.module$(EXEEXT)
+cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+nodist_cbtime_module_SOURCES = ## platform nodist sources
+cbtime_module_LDADD =
+cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtime_module_SOURCES)
+CLEANFILES += $(nodist_cbtime_module_SOURCES)
+MOD_FILES += cbtime.mod
+MARKER_FILES += cbtime.marker
+CLEANFILES += cbtime.marker
+
+cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += cbtime.module
+MODULE_FILES += cbtime.module$(EXEEXT)
+cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+nodist_cbtime_module_SOURCES = ## platform nodist sources
+cbtime_module_LDADD =
+cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtime_module_SOURCES)
+CLEANFILES += $(nodist_cbtime_module_SOURCES)
+MOD_FILES += cbtime.mod
+MARKER_FILES += cbtime.marker
+CLEANFILES += cbtime.marker
+
+cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += cbtime.module
+MODULE_FILES += cbtime.module$(EXEEXT)
+cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+nodist_cbtime_module_SOURCES = ## platform nodist sources
+cbtime_module_LDADD =
+cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtime_module_SOURCES)
+CLEANFILES += $(nodist_cbtime_module_SOURCES)
+MOD_FILES += cbtime.mod
+MARKER_FILES += cbtime.marker
+CLEANFILES += cbtime.marker
+
+cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += cbtime.module
+MODULE_FILES += cbtime.module$(EXEEXT)
+cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+nodist_cbtime_module_SOURCES = ## platform nodist sources
+cbtime_module_LDADD =
+cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbtime_module_SOURCES)
+CLEANFILES += $(nodist_cbtime_module_SOURCES)
+MOD_FILES += cbtime.mod
+MARKER_FILES += cbtime.marker
+CLEANFILES += cbtime.marker
+
+cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += cbls.module
+MODULE_FILES += cbls.module$(EXEEXT)
+cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+nodist_cbls_module_SOURCES = ## platform nodist sources
+cbls_module_LDADD =
+cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbls_module_SOURCES)
+CLEANFILES += $(nodist_cbls_module_SOURCES)
+MOD_FILES += cbls.mod
+MARKER_FILES += cbls.marker
+CLEANFILES += cbls.marker
+
+cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += cbls.module
+MODULE_FILES += cbls.module$(EXEEXT)
+cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+nodist_cbls_module_SOURCES = ## platform nodist sources
+cbls_module_LDADD =
+cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbls_module_SOURCES)
+CLEANFILES += $(nodist_cbls_module_SOURCES)
+MOD_FILES += cbls.mod
+MARKER_FILES += cbls.marker
+CLEANFILES += cbls.marker
+
+cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += cbls.module
+MODULE_FILES += cbls.module$(EXEEXT)
+cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+nodist_cbls_module_SOURCES = ## platform nodist sources
+cbls_module_LDADD =
+cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbls_module_SOURCES)
+CLEANFILES += $(nodist_cbls_module_SOURCES)
+MOD_FILES += cbls.mod
+MARKER_FILES += cbls.marker
+CLEANFILES += cbls.marker
+
+cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += cbls.module
+MODULE_FILES += cbls.module$(EXEEXT)
+cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+nodist_cbls_module_SOURCES = ## platform nodist sources
+cbls_module_LDADD =
+cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbls_module_SOURCES)
+CLEANFILES += $(nodist_cbls_module_SOURCES)
+MOD_FILES += cbls.mod
+MARKER_FILES += cbls.marker
+CLEANFILES += cbls.marker
+
+cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += cbls.module
+MODULE_FILES += cbls.module$(EXEEXT)
+cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+nodist_cbls_module_SOURCES = ## platform nodist sources
+cbls_module_LDADD =
+cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbls_module_SOURCES)
+CLEANFILES += $(nodist_cbls_module_SOURCES)
+MOD_FILES += cbls.mod
+MARKER_FILES += cbls.marker
+CLEANFILES += cbls.marker
+
+cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += cbls.module
+MODULE_FILES += cbls.module$(EXEEXT)
+cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+nodist_cbls_module_SOURCES = ## platform nodist sources
+cbls_module_LDADD =
+cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbls_module_SOURCES)
+CLEANFILES += $(nodist_cbls_module_SOURCES)
+MOD_FILES += cbls.mod
+MARKER_FILES += cbls.marker
+CLEANFILES += cbls.marker
+
+cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += cbls.module
+MODULE_FILES += cbls.module$(EXEEXT)
+cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+nodist_cbls_module_SOURCES = ## platform nodist sources
+cbls_module_LDADD =
+cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbls_module_SOURCES)
+CLEANFILES += $(nodist_cbls_module_SOURCES)
+MOD_FILES += cbls.mod
+MARKER_FILES += cbls.marker
+CLEANFILES += cbls.marker
+
+cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += cbmemc.module
+MODULE_FILES += cbmemc.module$(EXEEXT)
+cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+nodist_cbmemc_module_SOURCES = ## platform nodist sources
+cbmemc_module_LDADD =
+cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbmemc_module_SOURCES)
+CLEANFILES += $(nodist_cbmemc_module_SOURCES)
+MOD_FILES += cbmemc.mod
+MARKER_FILES += cbmemc.marker
+CLEANFILES += cbmemc.marker
+
+cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += cbmemc.module
+MODULE_FILES += cbmemc.module$(EXEEXT)
+cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+nodist_cbmemc_module_SOURCES = ## platform nodist sources
+cbmemc_module_LDADD =
+cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbmemc_module_SOURCES)
+CLEANFILES += $(nodist_cbmemc_module_SOURCES)
+MOD_FILES += cbmemc.mod
+MARKER_FILES += cbmemc.marker
+CLEANFILES += cbmemc.marker
+
+cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += cbmemc.module
+MODULE_FILES += cbmemc.module$(EXEEXT)
+cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+nodist_cbmemc_module_SOURCES = ## platform nodist sources
+cbmemc_module_LDADD =
+cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbmemc_module_SOURCES)
+CLEANFILES += $(nodist_cbmemc_module_SOURCES)
+MOD_FILES += cbmemc.mod
+MARKER_FILES += cbmemc.marker
+CLEANFILES += cbmemc.marker
+
+cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += cbmemc.module
+MODULE_FILES += cbmemc.module$(EXEEXT)
+cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+nodist_cbmemc_module_SOURCES = ## platform nodist sources
+cbmemc_module_LDADD =
+cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbmemc_module_SOURCES)
+CLEANFILES += $(nodist_cbmemc_module_SOURCES)
+MOD_FILES += cbmemc.mod
+MARKER_FILES += cbmemc.marker
+CLEANFILES += cbmemc.marker
+
+cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += cbmemc.module
+MODULE_FILES += cbmemc.module$(EXEEXT)
+cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+nodist_cbmemc_module_SOURCES = ## platform nodist sources
+cbmemc_module_LDADD =
+cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbmemc_module_SOURCES)
+CLEANFILES += $(nodist_cbmemc_module_SOURCES)
+MOD_FILES += cbmemc.mod
+MARKER_FILES += cbmemc.marker
+CLEANFILES += cbmemc.marker
+
+cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += cbmemc.module
+MODULE_FILES += cbmemc.module$(EXEEXT)
+cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+nodist_cbmemc_module_SOURCES = ## platform nodist sources
+cbmemc_module_LDADD =
+cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbmemc_module_SOURCES)
+CLEANFILES += $(nodist_cbmemc_module_SOURCES)
+MOD_FILES += cbmemc.mod
+MARKER_FILES += cbmemc.marker
+CLEANFILES += cbmemc.marker
+
+cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += cbmemc.module
+MODULE_FILES += cbmemc.module$(EXEEXT)
+cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+nodist_cbmemc_module_SOURCES = ## platform nodist sources
+cbmemc_module_LDADD =
+cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbmemc_module_SOURCES)
+CLEANFILES += $(nodist_cbmemc_module_SOURCES)
+MOD_FILES += cbmemc.mod
+MARKER_FILES += cbmemc.marker
+CLEANFILES += cbmemc.marker
+
+cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += regexp.module
+MODULE_FILES += regexp.module$(EXEEXT)
+regexp_module_SOURCES = commands/regexp.c commands/wildcard.c lib/gnulib/regex.c ## platform sources
+nodist_regexp_module_SOURCES = ## platform nodist sources
+regexp_module_LDADD =
+regexp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) $(CFLAGS_GNULIB)
+regexp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+regexp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)
+regexp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+regexp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_regexp_module_SOURCES)
+CLEANFILES += $(nodist_regexp_module_SOURCES)
+MOD_FILES += regexp.mod
+MARKER_FILES += regexp.marker
+CLEANFILES += regexp.marker
+
+regexp.marker: $(regexp_module_SOURCES) $(nodist_regexp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += acpi.module
+MODULE_FILES += acpi.module$(EXEEXT)
+acpi_module_SOURCES = kern/acpi.c kern/i386/pc/acpi.c commands/acpi.c ## platform sources
+nodist_acpi_module_SOURCES = ## platform nodist sources
+acpi_module_LDADD =
+acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_acpi_module_SOURCES)
+CLEANFILES += $(nodist_acpi_module_SOURCES)
+MOD_FILES += acpi.mod
+MARKER_FILES += acpi.marker
+CLEANFILES += acpi.marker
+
+acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += acpi.module
+MODULE_FILES += acpi.module$(EXEEXT)
+acpi_module_SOURCES = commands/acpi.c ## platform sources
+nodist_acpi_module_SOURCES = ## platform nodist sources
+acpi_module_LDADD =
+acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_acpi_module_SOURCES)
+CLEANFILES += $(nodist_acpi_module_SOURCES)
+MOD_FILES += acpi.mod
+MARKER_FILES += acpi.marker
+CLEANFILES += acpi.marker
+
+acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += acpi.module
+MODULE_FILES += acpi.module$(EXEEXT)
+acpi_module_SOURCES = commands/acpi.c ## platform sources
+nodist_acpi_module_SOURCES = ## platform nodist sources
+acpi_module_LDADD =
+acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_acpi_module_SOURCES)
+CLEANFILES += $(nodist_acpi_module_SOURCES)
+MOD_FILES += acpi.mod
+MARKER_FILES += acpi.marker
+CLEANFILES += acpi.marker
+
+acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += acpi.module
+MODULE_FILES += acpi.module$(EXEEXT)
+acpi_module_SOURCES = commands/acpi.c ## platform sources
+nodist_acpi_module_SOURCES = ## platform nodist sources
+acpi_module_LDADD =
+acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_acpi_module_SOURCES)
+CLEANFILES += $(nodist_acpi_module_SOURCES)
+MOD_FILES += acpi.mod
+MARKER_FILES += acpi.marker
+CLEANFILES += acpi.marker
+
+acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += acpi.module
+MODULE_FILES += acpi.module$(EXEEXT)
+acpi_module_SOURCES = commands/acpi.c ## platform sources
+nodist_acpi_module_SOURCES = ## platform nodist sources
+acpi_module_LDADD =
+acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_acpi_module_SOURCES)
+CLEANFILES += $(nodist_acpi_module_SOURCES)
+MOD_FILES += acpi.mod
+MARKER_FILES += acpi.marker
+CLEANFILES += acpi.marker
+
+acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += acpi.module
+MODULE_FILES += acpi.module$(EXEEXT)
+acpi_module_SOURCES = commands/acpi.c ## platform sources
+nodist_acpi_module_SOURCES = ## platform nodist sources
+acpi_module_LDADD =
+acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_acpi_module_SOURCES)
+CLEANFILES += $(nodist_acpi_module_SOURCES)
+MOD_FILES += acpi.mod
+MARKER_FILES += acpi.marker
+CLEANFILES += acpi.marker
+
+acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += acpi.module
+MODULE_FILES += acpi.module$(EXEEXT)
+acpi_module_SOURCES = commands/acpi.c ## platform sources
+nodist_acpi_module_SOURCES = ## platform nodist sources
+acpi_module_LDADD =
+acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_acpi_module_SOURCES)
+CLEANFILES += $(nodist_acpi_module_SOURCES)
+MOD_FILES += acpi.mod
+MARKER_FILES += acpi.marker
+CLEANFILES += acpi.marker
+
+acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += acpi.module
+MODULE_FILES += acpi.module$(EXEEXT)
+acpi_module_SOURCES = commands/acpi.c ## platform sources
+nodist_acpi_module_SOURCES = ## platform nodist sources
+acpi_module_LDADD =
+acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_acpi_module_SOURCES)
+CLEANFILES += $(nodist_acpi_module_SOURCES)
+MOD_FILES += acpi.mod
+MARKER_FILES += acpi.marker
+CLEANFILES += acpi.marker
+
+acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += acpi.module
+MODULE_FILES += acpi.module$(EXEEXT)
+acpi_module_SOURCES = commands/acpi.c ## platform sources
+nodist_acpi_module_SOURCES = ## platform nodist sources
+acpi_module_LDADD =
+acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_acpi_module_SOURCES)
+CLEANFILES += $(nodist_acpi_module_SOURCES)
+MOD_FILES += acpi.mod
+MARKER_FILES += acpi.marker
+CLEANFILES += acpi.marker
+
+acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += acpi.module
+MODULE_FILES += acpi.module$(EXEEXT)
+acpi_module_SOURCES = commands/acpi.c ## platform sources
+nodist_acpi_module_SOURCES = ## platform nodist sources
+acpi_module_LDADD =
+acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_acpi_module_SOURCES)
+CLEANFILES += $(nodist_acpi_module_SOURCES)
+MOD_FILES += acpi.mod
+MARKER_FILES += acpi.marker
+CLEANFILES += acpi.marker
+
+acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += lsacpi.module
+MODULE_FILES += lsacpi.module$(EXEEXT)
+lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+nodist_lsacpi_module_SOURCES = ## platform nodist sources
+lsacpi_module_LDADD =
+lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsacpi_module_SOURCES)
+CLEANFILES += $(nodist_lsacpi_module_SOURCES)
+MOD_FILES += lsacpi.mod
+MARKER_FILES += lsacpi.marker
+CLEANFILES += lsacpi.marker
+
+lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += lsacpi.module
+MODULE_FILES += lsacpi.module$(EXEEXT)
+lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+nodist_lsacpi_module_SOURCES = ## platform nodist sources
+lsacpi_module_LDADD =
+lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsacpi_module_SOURCES)
+CLEANFILES += $(nodist_lsacpi_module_SOURCES)
+MOD_FILES += lsacpi.mod
+MARKER_FILES += lsacpi.marker
+CLEANFILES += lsacpi.marker
+
+lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += lsacpi.module
+MODULE_FILES += lsacpi.module$(EXEEXT)
+lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+nodist_lsacpi_module_SOURCES = ## platform nodist sources
+lsacpi_module_LDADD =
+lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsacpi_module_SOURCES)
+CLEANFILES += $(nodist_lsacpi_module_SOURCES)
+MOD_FILES += lsacpi.mod
+MARKER_FILES += lsacpi.marker
+CLEANFILES += lsacpi.marker
+
+lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += lsacpi.module
+MODULE_FILES += lsacpi.module$(EXEEXT)
+lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+nodist_lsacpi_module_SOURCES = ## platform nodist sources
+lsacpi_module_LDADD =
+lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsacpi_module_SOURCES)
+CLEANFILES += $(nodist_lsacpi_module_SOURCES)
+MOD_FILES += lsacpi.mod
+MARKER_FILES += lsacpi.marker
+CLEANFILES += lsacpi.marker
+
+lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += lsacpi.module
+MODULE_FILES += lsacpi.module$(EXEEXT)
+lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+nodist_lsacpi_module_SOURCES = ## platform nodist sources
+lsacpi_module_LDADD =
+lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsacpi_module_SOURCES)
+CLEANFILES += $(nodist_lsacpi_module_SOURCES)
+MOD_FILES += lsacpi.mod
+MARKER_FILES += lsacpi.marker
+CLEANFILES += lsacpi.marker
+
+lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += lsacpi.module
+MODULE_FILES += lsacpi.module$(EXEEXT)
+lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+nodist_lsacpi_module_SOURCES = ## platform nodist sources
+lsacpi_module_LDADD =
+lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsacpi_module_SOURCES)
+CLEANFILES += $(nodist_lsacpi_module_SOURCES)
+MOD_FILES += lsacpi.mod
+MARKER_FILES += lsacpi.marker
+CLEANFILES += lsacpi.marker
+
+lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += lsacpi.module
+MODULE_FILES += lsacpi.module$(EXEEXT)
+lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+nodist_lsacpi_module_SOURCES = ## platform nodist sources
+lsacpi_module_LDADD =
+lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsacpi_module_SOURCES)
+CLEANFILES += $(nodist_lsacpi_module_SOURCES)
+MOD_FILES += lsacpi.mod
+MARKER_FILES += lsacpi.marker
+CLEANFILES += lsacpi.marker
+
+lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += lsacpi.module
+MODULE_FILES += lsacpi.module$(EXEEXT)
+lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+nodist_lsacpi_module_SOURCES = ## platform nodist sources
+lsacpi_module_LDADD =
+lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsacpi_module_SOURCES)
+CLEANFILES += $(nodist_lsacpi_module_SOURCES)
+MOD_FILES += lsacpi.mod
+MARKER_FILES += lsacpi.marker
+CLEANFILES += lsacpi.marker
+
+lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += lsacpi.module
+MODULE_FILES += lsacpi.module$(EXEEXT)
+lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+nodist_lsacpi_module_SOURCES = ## platform nodist sources
+lsacpi_module_LDADD =
+lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsacpi_module_SOURCES)
+CLEANFILES += $(nodist_lsacpi_module_SOURCES)
+MOD_FILES += lsacpi.mod
+MARKER_FILES += lsacpi.marker
+CLEANFILES += lsacpi.marker
+
+lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += lsacpi.module
+MODULE_FILES += lsacpi.module$(EXEEXT)
+lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+nodist_lsacpi_module_SOURCES = ## platform nodist sources
+lsacpi_module_LDADD =
+lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsacpi_module_SOURCES)
+CLEANFILES += $(nodist_lsacpi_module_SOURCES)
+MOD_FILES += lsacpi.mod
+MARKER_FILES += lsacpi.marker
+CLEANFILES += lsacpi.marker
+
+lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += lsefisystab.module
+MODULE_FILES += lsefisystab.module$(EXEEXT)
+lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+lsefisystab_module_LDADD =
+lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefisystab_module_SOURCES)
+CLEANFILES += $(nodist_lsefisystab_module_SOURCES)
+MOD_FILES += lsefisystab.mod
+MARKER_FILES += lsefisystab.marker
+CLEANFILES += lsefisystab.marker
+
+lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += lsefisystab.module
+MODULE_FILES += lsefisystab.module$(EXEEXT)
+lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+lsefisystab_module_LDADD =
+lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefisystab_module_SOURCES)
+CLEANFILES += $(nodist_lsefisystab_module_SOURCES)
+MOD_FILES += lsefisystab.mod
+MARKER_FILES += lsefisystab.marker
+CLEANFILES += lsefisystab.marker
+
+lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += lsefisystab.module
+MODULE_FILES += lsefisystab.module$(EXEEXT)
+lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+lsefisystab_module_LDADD =
+lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefisystab_module_SOURCES)
+CLEANFILES += $(nodist_lsefisystab_module_SOURCES)
+MOD_FILES += lsefisystab.mod
+MARKER_FILES += lsefisystab.marker
+CLEANFILES += lsefisystab.marker
+
+lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += lsefisystab.module
+MODULE_FILES += lsefisystab.module$(EXEEXT)
+lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+lsefisystab_module_LDADD =
+lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefisystab_module_SOURCES)
+CLEANFILES += $(nodist_lsefisystab_module_SOURCES)
+MOD_FILES += lsefisystab.mod
+MARKER_FILES += lsefisystab.marker
+CLEANFILES += lsefisystab.marker
+
+lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += lsefisystab.module
+MODULE_FILES += lsefisystab.module$(EXEEXT)
+lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+lsefisystab_module_LDADD =
+lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefisystab_module_SOURCES)
+CLEANFILES += $(nodist_lsefisystab_module_SOURCES)
+MOD_FILES += lsefisystab.mod
+MARKER_FILES += lsefisystab.marker
+CLEANFILES += lsefisystab.marker
+
+lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += lsefisystab.module
+MODULE_FILES += lsefisystab.module$(EXEEXT)
+lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+lsefisystab_module_LDADD =
+lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefisystab_module_SOURCES)
+CLEANFILES += $(nodist_lsefisystab_module_SOURCES)
+MOD_FILES += lsefisystab.mod
+MARKER_FILES += lsefisystab.marker
+CLEANFILES += lsefisystab.marker
+
+lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += lsefisystab.module
+MODULE_FILES += lsefisystab.module$(EXEEXT)
+lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+lsefisystab_module_LDADD =
+lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefisystab_module_SOURCES)
+CLEANFILES += $(nodist_lsefisystab_module_SOURCES)
+MOD_FILES += lsefisystab.mod
+MARKER_FILES += lsefisystab.marker
+CLEANFILES += lsefisystab.marker
+
+lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += lssal.module
+MODULE_FILES += lssal.module$(EXEEXT)
+lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+nodist_lssal_module_SOURCES = ## platform nodist sources
+lssal_module_LDADD =
+lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lssal_module_SOURCES)
+CLEANFILES += $(nodist_lssal_module_SOURCES)
+MOD_FILES += lssal.mod
+MARKER_FILES += lssal.marker
+CLEANFILES += lssal.marker
+
+lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += lssal.module
+MODULE_FILES += lssal.module$(EXEEXT)
+lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+nodist_lssal_module_SOURCES = ## platform nodist sources
+lssal_module_LDADD =
+lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lssal_module_SOURCES)
+CLEANFILES += $(nodist_lssal_module_SOURCES)
+MOD_FILES += lssal.mod
+MARKER_FILES += lssal.marker
+CLEANFILES += lssal.marker
+
+lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += lssal.module
+MODULE_FILES += lssal.module$(EXEEXT)
+lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+nodist_lssal_module_SOURCES = ## platform nodist sources
+lssal_module_LDADD =
+lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lssal_module_SOURCES)
+CLEANFILES += $(nodist_lssal_module_SOURCES)
+MOD_FILES += lssal.mod
+MARKER_FILES += lssal.marker
+CLEANFILES += lssal.marker
+
+lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += lssal.module
+MODULE_FILES += lssal.module$(EXEEXT)
+lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+nodist_lssal_module_SOURCES = ## platform nodist sources
+lssal_module_LDADD =
+lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lssal_module_SOURCES)
+CLEANFILES += $(nodist_lssal_module_SOURCES)
+MOD_FILES += lssal.mod
+MARKER_FILES += lssal.marker
+CLEANFILES += lssal.marker
+
+lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += lssal.module
+MODULE_FILES += lssal.module$(EXEEXT)
+lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+nodist_lssal_module_SOURCES = ## platform nodist sources
+lssal_module_LDADD =
+lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lssal_module_SOURCES)
+CLEANFILES += $(nodist_lssal_module_SOURCES)
+MOD_FILES += lssal.mod
+MARKER_FILES += lssal.marker
+CLEANFILES += lssal.marker
+
+lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += lssal.module
+MODULE_FILES += lssal.module$(EXEEXT)
+lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+nodist_lssal_module_SOURCES = ## platform nodist sources
+lssal_module_LDADD =
+lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lssal_module_SOURCES)
+CLEANFILES += $(nodist_lssal_module_SOURCES)
+MOD_FILES += lssal.mod
+MARKER_FILES += lssal.marker
+CLEANFILES += lssal.marker
+
+lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += lssal.module
+MODULE_FILES += lssal.module$(EXEEXT)
+lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+nodist_lssal_module_SOURCES = ## platform nodist sources
+lssal_module_LDADD =
+lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lssal_module_SOURCES)
+CLEANFILES += $(nodist_lssal_module_SOURCES)
+MOD_FILES += lssal.mod
+MARKER_FILES += lssal.marker
+CLEANFILES += lssal.marker
+
+lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += lsefimmap.module
+MODULE_FILES += lsefimmap.module$(EXEEXT)
+lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+lsefimmap_module_LDADD =
+lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefimmap_module_SOURCES)
+CLEANFILES += $(nodist_lsefimmap_module_SOURCES)
+MOD_FILES += lsefimmap.mod
+MARKER_FILES += lsefimmap.marker
+CLEANFILES += lsefimmap.marker
+
+lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += lsefimmap.module
+MODULE_FILES += lsefimmap.module$(EXEEXT)
+lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+lsefimmap_module_LDADD =
+lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefimmap_module_SOURCES)
+CLEANFILES += $(nodist_lsefimmap_module_SOURCES)
+MOD_FILES += lsefimmap.mod
+MARKER_FILES += lsefimmap.marker
+CLEANFILES += lsefimmap.marker
+
+lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += lsefimmap.module
+MODULE_FILES += lsefimmap.module$(EXEEXT)
+lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+lsefimmap_module_LDADD =
+lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefimmap_module_SOURCES)
+CLEANFILES += $(nodist_lsefimmap_module_SOURCES)
+MOD_FILES += lsefimmap.mod
+MARKER_FILES += lsefimmap.marker
+CLEANFILES += lsefimmap.marker
+
+lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += lsefimmap.module
+MODULE_FILES += lsefimmap.module$(EXEEXT)
+lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+lsefimmap_module_LDADD =
+lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefimmap_module_SOURCES)
+CLEANFILES += $(nodist_lsefimmap_module_SOURCES)
+MOD_FILES += lsefimmap.mod
+MARKER_FILES += lsefimmap.marker
+CLEANFILES += lsefimmap.marker
+
+lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += lsefimmap.module
+MODULE_FILES += lsefimmap.module$(EXEEXT)
+lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+lsefimmap_module_LDADD =
+lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefimmap_module_SOURCES)
+CLEANFILES += $(nodist_lsefimmap_module_SOURCES)
+MOD_FILES += lsefimmap.mod
+MARKER_FILES += lsefimmap.marker
+CLEANFILES += lsefimmap.marker
+
+lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += lsefimmap.module
+MODULE_FILES += lsefimmap.module$(EXEEXT)
+lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+lsefimmap_module_LDADD =
+lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefimmap_module_SOURCES)
+CLEANFILES += $(nodist_lsefimmap_module_SOURCES)
+MOD_FILES += lsefimmap.mod
+MARKER_FILES += lsefimmap.marker
+CLEANFILES += lsefimmap.marker
+
+lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += lsefimmap.module
+MODULE_FILES += lsefimmap.module$(EXEEXT)
+lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+lsefimmap_module_LDADD =
+lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefimmap_module_SOURCES)
+CLEANFILES += $(nodist_lsefimmap_module_SOURCES)
+MOD_FILES += lsefimmap.mod
+MARKER_FILES += lsefimmap.marker
+CLEANFILES += lsefimmap.marker
+
+lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += lsefi.module
+MODULE_FILES += lsefi.module$(EXEEXT)
+lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+nodist_lsefi_module_SOURCES = ## platform nodist sources
+lsefi_module_LDADD =
+lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefi_module_SOURCES)
+CLEANFILES += $(nodist_lsefi_module_SOURCES)
+MOD_FILES += lsefi.mod
+MARKER_FILES += lsefi.marker
+CLEANFILES += lsefi.marker
+
+lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += lsefi.module
+MODULE_FILES += lsefi.module$(EXEEXT)
+lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+nodist_lsefi_module_SOURCES = ## platform nodist sources
+lsefi_module_LDADD =
+lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefi_module_SOURCES)
+CLEANFILES += $(nodist_lsefi_module_SOURCES)
+MOD_FILES += lsefi.mod
+MARKER_FILES += lsefi.marker
+CLEANFILES += lsefi.marker
+
+lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += lsefi.module
+MODULE_FILES += lsefi.module$(EXEEXT)
+lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+nodist_lsefi_module_SOURCES = ## platform nodist sources
+lsefi_module_LDADD =
+lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefi_module_SOURCES)
+CLEANFILES += $(nodist_lsefi_module_SOURCES)
+MOD_FILES += lsefi.mod
+MARKER_FILES += lsefi.marker
+CLEANFILES += lsefi.marker
+
+lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += lsefi.module
+MODULE_FILES += lsefi.module$(EXEEXT)
+lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+nodist_lsefi_module_SOURCES = ## platform nodist sources
+lsefi_module_LDADD =
+lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefi_module_SOURCES)
+CLEANFILES += $(nodist_lsefi_module_SOURCES)
+MOD_FILES += lsefi.mod
+MARKER_FILES += lsefi.marker
+CLEANFILES += lsefi.marker
+
+lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += lsefi.module
+MODULE_FILES += lsefi.module$(EXEEXT)
+lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+nodist_lsefi_module_SOURCES = ## platform nodist sources
+lsefi_module_LDADD =
+lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefi_module_SOURCES)
+CLEANFILES += $(nodist_lsefi_module_SOURCES)
+MOD_FILES += lsefi.mod
+MARKER_FILES += lsefi.marker
+CLEANFILES += lsefi.marker
+
+lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += lsefi.module
+MODULE_FILES += lsefi.module$(EXEEXT)
+lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+nodist_lsefi_module_SOURCES = ## platform nodist sources
+lsefi_module_LDADD =
+lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefi_module_SOURCES)
+CLEANFILES += $(nodist_lsefi_module_SOURCES)
+MOD_FILES += lsefi.mod
+MARKER_FILES += lsefi.marker
+CLEANFILES += lsefi.marker
+
+lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += lsefi.module
+MODULE_FILES += lsefi.module$(EXEEXT)
+lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+nodist_lsefi_module_SOURCES = ## platform nodist sources
+lsefi_module_LDADD =
+lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsefi_module_SOURCES)
+CLEANFILES += $(nodist_lsefi_module_SOURCES)
+MOD_FILES += lsefi.mod
+MARKER_FILES += lsefi.marker
+CLEANFILES += lsefi.marker
+
+lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += efifwsetup.module
+MODULE_FILES += efifwsetup.module$(EXEEXT)
+efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+efifwsetup_module_LDADD =
+efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efifwsetup_module_SOURCES)
+CLEANFILES += $(nodist_efifwsetup_module_SOURCES)
+MOD_FILES += efifwsetup.mod
+MARKER_FILES += efifwsetup.marker
+CLEANFILES += efifwsetup.marker
+
+efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += efifwsetup.module
+MODULE_FILES += efifwsetup.module$(EXEEXT)
+efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+efifwsetup_module_LDADD =
+efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efifwsetup_module_SOURCES)
+CLEANFILES += $(nodist_efifwsetup_module_SOURCES)
+MOD_FILES += efifwsetup.mod
+MARKER_FILES += efifwsetup.marker
+CLEANFILES += efifwsetup.marker
+
+efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += efifwsetup.module
+MODULE_FILES += efifwsetup.module$(EXEEXT)
+efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+efifwsetup_module_LDADD =
+efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efifwsetup_module_SOURCES)
+CLEANFILES += $(nodist_efifwsetup_module_SOURCES)
+MOD_FILES += efifwsetup.mod
+MARKER_FILES += efifwsetup.marker
+CLEANFILES += efifwsetup.marker
+
+efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += efifwsetup.module
+MODULE_FILES += efifwsetup.module$(EXEEXT)
+efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+efifwsetup_module_LDADD =
+efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efifwsetup_module_SOURCES)
+CLEANFILES += $(nodist_efifwsetup_module_SOURCES)
+MOD_FILES += efifwsetup.mod
+MARKER_FILES += efifwsetup.marker
+CLEANFILES += efifwsetup.marker
+
+efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += efifwsetup.module
+MODULE_FILES += efifwsetup.module$(EXEEXT)
+efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+efifwsetup_module_LDADD =
+efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efifwsetup_module_SOURCES)
+CLEANFILES += $(nodist_efifwsetup_module_SOURCES)
+MOD_FILES += efifwsetup.mod
+MARKER_FILES += efifwsetup.marker
+CLEANFILES += efifwsetup.marker
+
+efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += efifwsetup.module
+MODULE_FILES += efifwsetup.module$(EXEEXT)
+efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+efifwsetup_module_LDADD =
+efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efifwsetup_module_SOURCES)
+CLEANFILES += $(nodist_efifwsetup_module_SOURCES)
+MOD_FILES += efifwsetup.mod
+MARKER_FILES += efifwsetup.marker
+CLEANFILES += efifwsetup.marker
+
+efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += efifwsetup.module
+MODULE_FILES += efifwsetup.module$(EXEEXT)
+efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+efifwsetup_module_LDADD =
+efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efifwsetup_module_SOURCES)
+CLEANFILES += $(nodist_efifwsetup_module_SOURCES)
+MOD_FILES += efifwsetup.mod
+MARKER_FILES += efifwsetup.marker
+CLEANFILES += efifwsetup.marker
+
+efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += blocklist.module
+MODULE_FILES += blocklist.module$(EXEEXT)
+blocklist_module_SOURCES = commands/blocklist.c ## platform sources
+nodist_blocklist_module_SOURCES = ## platform nodist sources
+blocklist_module_LDADD =
+blocklist_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+blocklist_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+blocklist_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+blocklist_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+blocklist_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_blocklist_module_SOURCES)
+CLEANFILES += $(nodist_blocklist_module_SOURCES)
+MOD_FILES += blocklist.mod
+MARKER_FILES += blocklist.marker
+CLEANFILES += blocklist.marker
+
+blocklist.marker: $(blocklist_module_SOURCES) $(nodist_blocklist_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(blocklist_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_emu
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = lib/i386/pc/biosnum.c commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += boot.module
+MODULE_FILES += boot.module$(EXEEXT)
+boot_module_SOURCES = commands/boot.c ## platform sources
+nodist_boot_module_SOURCES = ## platform nodist sources
+boot_module_LDADD =
+boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_module_SOURCES)
+CLEANFILES += $(nodist_boot_module_SOURCES)
+MOD_FILES += boot.mod
+MARKER_FILES += boot.marker
+CLEANFILES += boot.marker
+
+boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += cat.module
+MODULE_FILES += cat.module$(EXEEXT)
+cat_module_SOURCES = commands/cat.c ## platform sources
+nodist_cat_module_SOURCES = ## platform nodist sources
+cat_module_LDADD =
+cat_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cat_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cat_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cat_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cat_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cat_module_SOURCES)
+CLEANFILES += $(nodist_cat_module_SOURCES)
+MOD_FILES += cat.mod
+MARKER_FILES += cat.marker
+CLEANFILES += cat.marker
+
+cat.marker: $(cat_module_SOURCES) $(nodist_cat_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cat_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += cmp.module
+MODULE_FILES += cmp.module$(EXEEXT)
+cmp_module_SOURCES = commands/cmp.c ## platform sources
+nodist_cmp_module_SOURCES = ## platform nodist sources
+cmp_module_LDADD =
+cmp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmp_module_SOURCES)
+CLEANFILES += $(nodist_cmp_module_SOURCES)
+MOD_FILES += cmp.mod
+MARKER_FILES += cmp.marker
+CLEANFILES += cmp.marker
+
+cmp.marker: $(cmp_module_SOURCES) $(nodist_cmp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += configfile.module
+MODULE_FILES += configfile.module$(EXEEXT)
+configfile_module_SOURCES = commands/configfile.c ## platform sources
+nodist_configfile_module_SOURCES = ## platform nodist sources
+configfile_module_LDADD =
+configfile_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+configfile_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+configfile_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+configfile_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+configfile_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_configfile_module_SOURCES)
+CLEANFILES += $(nodist_configfile_module_SOURCES)
+MOD_FILES += configfile.mod
+MARKER_FILES += configfile.marker
+CLEANFILES += configfile.marker
+
+configfile.marker: $(configfile_module_SOURCES) $(nodist_configfile_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(configfile_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += cpuid.module
+MODULE_FILES += cpuid.module$(EXEEXT)
+cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+nodist_cpuid_module_SOURCES = ## platform nodist sources
+cpuid_module_LDADD =
+cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpuid_module_SOURCES)
+CLEANFILES += $(nodist_cpuid_module_SOURCES)
+MOD_FILES += cpuid.mod
+MARKER_FILES += cpuid.marker
+CLEANFILES += cpuid.marker
+
+cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += cpuid.module
+MODULE_FILES += cpuid.module$(EXEEXT)
+cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+nodist_cpuid_module_SOURCES = ## platform nodist sources
+cpuid_module_LDADD =
+cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpuid_module_SOURCES)
+CLEANFILES += $(nodist_cpuid_module_SOURCES)
+MOD_FILES += cpuid.mod
+MARKER_FILES += cpuid.marker
+CLEANFILES += cpuid.marker
+
+cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += cpuid.module
+MODULE_FILES += cpuid.module$(EXEEXT)
+cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+nodist_cpuid_module_SOURCES = ## platform nodist sources
+cpuid_module_LDADD =
+cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpuid_module_SOURCES)
+CLEANFILES += $(nodist_cpuid_module_SOURCES)
+MOD_FILES += cpuid.mod
+MARKER_FILES += cpuid.marker
+CLEANFILES += cpuid.marker
+
+cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += cpuid.module
+MODULE_FILES += cpuid.module$(EXEEXT)
+cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+nodist_cpuid_module_SOURCES = ## platform nodist sources
+cpuid_module_LDADD =
+cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpuid_module_SOURCES)
+CLEANFILES += $(nodist_cpuid_module_SOURCES)
+MOD_FILES += cpuid.mod
+MARKER_FILES += cpuid.marker
+CLEANFILES += cpuid.marker
+
+cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += cpuid.module
+MODULE_FILES += cpuid.module$(EXEEXT)
+cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+nodist_cpuid_module_SOURCES = ## platform nodist sources
+cpuid_module_LDADD =
+cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpuid_module_SOURCES)
+CLEANFILES += $(nodist_cpuid_module_SOURCES)
+MOD_FILES += cpuid.mod
+MARKER_FILES += cpuid.marker
+CLEANFILES += cpuid.marker
+
+cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += cpuid.module
+MODULE_FILES += cpuid.module$(EXEEXT)
+cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+nodist_cpuid_module_SOURCES = ## platform nodist sources
+cpuid_module_LDADD =
+cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpuid_module_SOURCES)
+CLEANFILES += $(nodist_cpuid_module_SOURCES)
+MOD_FILES += cpuid.mod
+MARKER_FILES += cpuid.marker
+CLEANFILES += cpuid.marker
+
+cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += cpuid.module
+MODULE_FILES += cpuid.module$(EXEEXT)
+cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+nodist_cpuid_module_SOURCES = ## platform nodist sources
+cpuid_module_LDADD =
+cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpuid_module_SOURCES)
+CLEANFILES += $(nodist_cpuid_module_SOURCES)
+MOD_FILES += cpuid.mod
+MARKER_FILES += cpuid.marker
+CLEANFILES += cpuid.marker
+
+cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += cpuid.module
+MODULE_FILES += cpuid.module$(EXEEXT)
+cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+nodist_cpuid_module_SOURCES = ## platform nodist sources
+cpuid_module_LDADD =
+cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpuid_module_SOURCES)
+CLEANFILES += $(nodist_cpuid_module_SOURCES)
+MOD_FILES += cpuid.mod
+MARKER_FILES += cpuid.marker
+CLEANFILES += cpuid.marker
+
+cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += cpuid.module
+MODULE_FILES += cpuid.module$(EXEEXT)
+cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+nodist_cpuid_module_SOURCES = ## platform nodist sources
+cpuid_module_LDADD =
+cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpuid_module_SOURCES)
+CLEANFILES += $(nodist_cpuid_module_SOURCES)
+MOD_FILES += cpuid.mod
+MARKER_FILES += cpuid.marker
+CLEANFILES += cpuid.marker
+
+cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += cpuid.module
+MODULE_FILES += cpuid.module$(EXEEXT)
+cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+nodist_cpuid_module_SOURCES = ## platform nodist sources
+cpuid_module_LDADD =
+cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpuid_module_SOURCES)
+CLEANFILES += $(nodist_cpuid_module_SOURCES)
+MOD_FILES += cpuid.mod
+MARKER_FILES += cpuid.marker
+CLEANFILES += cpuid.marker
+
+cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += date.module
+MODULE_FILES += date.module$(EXEEXT)
+date_module_SOURCES = commands/date.c ## platform sources
+nodist_date_module_SOURCES = ## platform nodist sources
+date_module_LDADD =
+date_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+date_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+date_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+date_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+date_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_date_module_SOURCES)
+CLEANFILES += $(nodist_date_module_SOURCES)
+MOD_FILES += date.mod
+MARKER_FILES += date.marker
+CLEANFILES += date.marker
+
+date.marker: $(date_module_SOURCES) $(nodist_date_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(date_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += drivemap.module
+MODULE_FILES += drivemap.module$(EXEEXT)
+drivemap_module_SOURCES = commands/i386/pc/drivemap.c commands/i386/pc/drivemap_int13h.S ## platform sources
+nodist_drivemap_module_SOURCES = ## platform nodist sources
+drivemap_module_LDADD =
+drivemap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+drivemap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+drivemap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+drivemap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+drivemap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_drivemap_module_SOURCES)
+CLEANFILES += $(nodist_drivemap_module_SOURCES)
+MOD_FILES += drivemap.mod
+MARKER_FILES += drivemap.marker
+CLEANFILES += drivemap.marker
+
+drivemap.marker: $(drivemap_module_SOURCES) $(nodist_drivemap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(drivemap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += echo.module
+MODULE_FILES += echo.module$(EXEEXT)
+echo_module_SOURCES = commands/echo.c ## platform sources
+nodist_echo_module_SOURCES = ## platform nodist sources
+echo_module_LDADD =
+echo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+echo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+echo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+echo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+echo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_echo_module_SOURCES)
+CLEANFILES += $(nodist_echo_module_SOURCES)
+MOD_FILES += echo.mod
+MARKER_FILES += echo.marker
+CLEANFILES += echo.marker
+
+echo.marker: $(echo_module_SOURCES) $(nodist_echo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(echo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += eval.module
+MODULE_FILES += eval.module$(EXEEXT)
+eval_module_SOURCES = commands/eval.c ## platform sources
+nodist_eval_module_SOURCES = ## platform nodist sources
+eval_module_LDADD =
+eval_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+eval_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+eval_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+eval_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+eval_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_eval_module_SOURCES)
+CLEANFILES += $(nodist_eval_module_SOURCES)
+MOD_FILES += eval.mod
+MARKER_FILES += eval.marker
+CLEANFILES += eval.marker
+
+eval.marker: $(eval_module_SOURCES) $(nodist_eval_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(eval_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += extcmd.module
+MODULE_FILES += extcmd.module$(EXEEXT)
+extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+nodist_extcmd_module_SOURCES = ## platform nodist sources
+extcmd_module_LDADD =
+extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_extcmd_module_SOURCES)
+CLEANFILES += $(nodist_extcmd_module_SOURCES)
+MOD_FILES += extcmd.mod
+MARKER_FILES += extcmd.marker
+CLEANFILES += extcmd.marker
+
+extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += fixvideo.module
+MODULE_FILES += fixvideo.module$(EXEEXT)
+fixvideo_module_SOURCES = commands/efi/fixvideo.c ## platform sources
+nodist_fixvideo_module_SOURCES = ## platform nodist sources
+fixvideo_module_LDADD =
+fixvideo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fixvideo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fixvideo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fixvideo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fixvideo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fixvideo_module_SOURCES)
+CLEANFILES += $(nodist_fixvideo_module_SOURCES)
+MOD_FILES += fixvideo.mod
+MARKER_FILES += fixvideo.marker
+CLEANFILES += fixvideo.marker
+
+fixvideo.marker: $(fixvideo_module_SOURCES) $(nodist_fixvideo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fixvideo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += fixvideo.module
+MODULE_FILES += fixvideo.module$(EXEEXT)
+fixvideo_module_SOURCES = commands/efi/fixvideo.c ## platform sources
+nodist_fixvideo_module_SOURCES = ## platform nodist sources
+fixvideo_module_LDADD =
+fixvideo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fixvideo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fixvideo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fixvideo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fixvideo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fixvideo_module_SOURCES)
+CLEANFILES += $(nodist_fixvideo_module_SOURCES)
+MOD_FILES += fixvideo.mod
+MARKER_FILES += fixvideo.marker
+CLEANFILES += fixvideo.marker
+
+fixvideo.marker: $(fixvideo_module_SOURCES) $(nodist_fixvideo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fixvideo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += gptsync.module
+MODULE_FILES += gptsync.module$(EXEEXT)
+gptsync_module_SOURCES = commands/gptsync.c ## platform sources
+nodist_gptsync_module_SOURCES = ## platform nodist sources
+gptsync_module_LDADD =
+gptsync_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gptsync_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gptsync_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gptsync_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gptsync_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gptsync_module_SOURCES)
+CLEANFILES += $(nodist_gptsync_module_SOURCES)
+MOD_FILES += gptsync.mod
+MARKER_FILES += gptsync.marker
+CLEANFILES += gptsync.marker
+
+gptsync.marker: $(gptsync_module_SOURCES) $(nodist_gptsync_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gptsync_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_emu
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/emu/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = commands/i386/pc/halt.c commands/acpihalt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = commands/acpihalt.c lib/efi/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/i386/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = commands/acpihalt.c lib/i386/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = commands/acpihalt.c lib/i386/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/ieee1275/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = commands/acpihalt.c lib/efi/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/xen/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/xen/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/xen/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/ieee1275/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/ieee1275/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/efi/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/dummy/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/efi/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/efi/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/dummy/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/efi/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += halt.module
+MODULE_FILES += halt.module$(EXEEXT)
+halt_module_SOURCES = lib/efi/halt.c commands/halt.c ## platform sources
+nodist_halt_module_SOURCES = ## platform nodist sources
+halt_module_LDADD =
+halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_halt_module_SOURCES)
+CLEANFILES += $(nodist_halt_module_SOURCES)
+MOD_FILES += halt.mod
+MARKER_FILES += halt.marker
+CLEANFILES += halt.marker
+
+halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/xen/reboot.c commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/xen/reboot.c commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/xen/reboot.c commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/mips/loongson/reboot.c commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/ieee1275/reboot.c commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/ieee1275/reboot.c commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/mips/arc/reboot.c commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/mips/qemu_mips/reboot.c commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/uboot/reboot.c commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = lib/dummy/reboot.c commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += reboot.module
+MODULE_FILES += reboot.module$(EXEEXT)
+reboot_module_SOURCES = commands/reboot.c ## platform sources
+nodist_reboot_module_SOURCES = ## platform nodist sources
+reboot_module_LDADD =
+reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reboot_module_SOURCES)
+CLEANFILES += $(nodist_reboot_module_SOURCES)
+MOD_FILES += reboot.mod
+MARKER_FILES += reboot.marker
+CLEANFILES += reboot.marker
+
+reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += hashsum.module
+MODULE_FILES += hashsum.module$(EXEEXT)
+hashsum_module_SOURCES = commands/hashsum.c ## platform sources
+nodist_hashsum_module_SOURCES = ## platform nodist sources
+hashsum_module_LDADD =
+hashsum_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hashsum_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hashsum_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hashsum_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hashsum_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hashsum_module_SOURCES)
+CLEANFILES += $(nodist_hashsum_module_SOURCES)
+MOD_FILES += hashsum.mod
+MARKER_FILES += hashsum.marker
+CLEANFILES += hashsum.marker
+
+hashsum.marker: $(hashsum_module_SOURCES) $(nodist_hashsum_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hashsum_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += pgp.module
+MODULE_FILES += pgp.module$(EXEEXT)
+pgp_module_SOURCES = commands/pgp.c ## platform sources
+nodist_pgp_module_SOURCES = ## platform nodist sources
+pgp_module_LDADD =
+pgp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX)
+pgp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pgp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap
+pgp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pgp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pgp_module_SOURCES)
+CLEANFILES += $(nodist_pgp_module_SOURCES)
+MOD_FILES += pgp.mod
+MARKER_FILES += pgp.marker
+CLEANFILES += pgp.marker
+
+pgp.marker: $(pgp_module_SOURCES) $(nodist_pgp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pgp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += hdparm.module
+MODULE_FILES += hdparm.module$(EXEEXT)
+hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+nodist_hdparm_module_SOURCES = ## platform nodist sources
+hdparm_module_LDADD =
+hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hdparm_module_SOURCES)
+CLEANFILES += $(nodist_hdparm_module_SOURCES)
+MOD_FILES += hdparm.mod
+MARKER_FILES += hdparm.marker
+CLEANFILES += hdparm.marker
+
+hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += hdparm.module
+MODULE_FILES += hdparm.module$(EXEEXT)
+hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+nodist_hdparm_module_SOURCES = ## platform nodist sources
+hdparm_module_LDADD =
+hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hdparm_module_SOURCES)
+CLEANFILES += $(nodist_hdparm_module_SOURCES)
+MOD_FILES += hdparm.mod
+MARKER_FILES += hdparm.marker
+CLEANFILES += hdparm.marker
+
+hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += hdparm.module
+MODULE_FILES += hdparm.module$(EXEEXT)
+hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+nodist_hdparm_module_SOURCES = ## platform nodist sources
+hdparm_module_LDADD =
+hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hdparm_module_SOURCES)
+CLEANFILES += $(nodist_hdparm_module_SOURCES)
+MOD_FILES += hdparm.mod
+MARKER_FILES += hdparm.marker
+CLEANFILES += hdparm.marker
+
+hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += hdparm.module
+MODULE_FILES += hdparm.module$(EXEEXT)
+hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+nodist_hdparm_module_SOURCES = ## platform nodist sources
+hdparm_module_LDADD =
+hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hdparm_module_SOURCES)
+CLEANFILES += $(nodist_hdparm_module_SOURCES)
+MOD_FILES += hdparm.mod
+MARKER_FILES += hdparm.marker
+CLEANFILES += hdparm.marker
+
+hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += hdparm.module
+MODULE_FILES += hdparm.module$(EXEEXT)
+hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+nodist_hdparm_module_SOURCES = ## platform nodist sources
+hdparm_module_LDADD =
+hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hdparm_module_SOURCES)
+CLEANFILES += $(nodist_hdparm_module_SOURCES)
+MOD_FILES += hdparm.mod
+MARKER_FILES += hdparm.marker
+CLEANFILES += hdparm.marker
+
+hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += hdparm.module
+MODULE_FILES += hdparm.module$(EXEEXT)
+hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+nodist_hdparm_module_SOURCES = ## platform nodist sources
+hdparm_module_LDADD =
+hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hdparm_module_SOURCES)
+CLEANFILES += $(nodist_hdparm_module_SOURCES)
+MOD_FILES += hdparm.mod
+MARKER_FILES += hdparm.marker
+CLEANFILES += hdparm.marker
+
+hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += hdparm.module
+MODULE_FILES += hdparm.module$(EXEEXT)
+hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+nodist_hdparm_module_SOURCES = ## platform nodist sources
+hdparm_module_LDADD =
+hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hdparm_module_SOURCES)
+CLEANFILES += $(nodist_hdparm_module_SOURCES)
+MOD_FILES += hdparm.mod
+MARKER_FILES += hdparm.marker
+CLEANFILES += hdparm.marker
+
+hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += hdparm.module
+MODULE_FILES += hdparm.module$(EXEEXT)
+hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+nodist_hdparm_module_SOURCES = ## platform nodist sources
+hdparm_module_LDADD =
+hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hdparm_module_SOURCES)
+CLEANFILES += $(nodist_hdparm_module_SOURCES)
+MOD_FILES += hdparm.mod
+MARKER_FILES += hdparm.marker
+CLEANFILES += hdparm.marker
+
+hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += hdparm.module
+MODULE_FILES += hdparm.module$(EXEEXT)
+hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+nodist_hdparm_module_SOURCES = ## platform nodist sources
+hdparm_module_LDADD =
+hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hdparm_module_SOURCES)
+CLEANFILES += $(nodist_hdparm_module_SOURCES)
+MOD_FILES += hdparm.mod
+MARKER_FILES += hdparm.marker
+CLEANFILES += hdparm.marker
+
+hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += help.module
+MODULE_FILES += help.module$(EXEEXT)
+help_module_SOURCES = commands/help.c ## platform sources
+nodist_help_module_SOURCES = ## platform nodist sources
+help_module_LDADD =
+help_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+help_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+help_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+help_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+help_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_help_module_SOURCES)
+CLEANFILES += $(nodist_help_module_SOURCES)
+MOD_FILES += help.mod
+MARKER_FILES += help.marker
+CLEANFILES += help.marker
+
+help.marker: $(help_module_SOURCES) $(nodist_help_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(help_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += hexdump.module
+MODULE_FILES += hexdump.module$(EXEEXT)
+hexdump_module_SOURCES = commands/hexdump.c lib/hexdump.c ## platform sources
+nodist_hexdump_module_SOURCES = ## platform nodist sources
+hexdump_module_LDADD =
+hexdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hexdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hexdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hexdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hexdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hexdump_module_SOURCES)
+CLEANFILES += $(nodist_hexdump_module_SOURCES)
+MOD_FILES += hexdump.mod
+MARKER_FILES += hexdump.marker
+CLEANFILES += hexdump.marker
+
+hexdump.marker: $(hexdump_module_SOURCES) $(nodist_hexdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hexdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += keystatus.module
+MODULE_FILES += keystatus.module$(EXEEXT)
+keystatus_module_SOURCES = commands/keystatus.c ## platform sources
+nodist_keystatus_module_SOURCES = ## platform nodist sources
+keystatus_module_LDADD =
+keystatus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+keystatus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+keystatus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+keystatus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+keystatus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_keystatus_module_SOURCES)
+CLEANFILES += $(nodist_keystatus_module_SOURCES)
+MOD_FILES += keystatus.mod
+MARKER_FILES += keystatus.marker
+CLEANFILES += keystatus.marker
+
+keystatus.marker: $(keystatus_module_SOURCES) $(nodist_keystatus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keystatus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_efi
+platform_PROGRAMS += loadbios.module
+MODULE_FILES += loadbios.module$(EXEEXT)
+loadbios_module_SOURCES = commands/efi/loadbios.c ## platform sources
+nodist_loadbios_module_SOURCES = ## platform nodist sources
+loadbios_module_LDADD =
+loadbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+loadbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+loadbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+loadbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+loadbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_loadbios_module_SOURCES)
+CLEANFILES += $(nodist_loadbios_module_SOURCES)
+MOD_FILES += loadbios.mod
+MARKER_FILES += loadbios.marker
+CLEANFILES += loadbios.marker
+
+loadbios.marker: $(loadbios_module_SOURCES) $(nodist_loadbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += loadbios.module
+MODULE_FILES += loadbios.module$(EXEEXT)
+loadbios_module_SOURCES = commands/efi/loadbios.c ## platform sources
+nodist_loadbios_module_SOURCES = ## platform nodist sources
+loadbios_module_LDADD =
+loadbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+loadbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+loadbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+loadbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+loadbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_loadbios_module_SOURCES)
+CLEANFILES += $(nodist_loadbios_module_SOURCES)
+MOD_FILES += loadbios.mod
+MARKER_FILES += loadbios.marker
+CLEANFILES += loadbios.marker
+
+loadbios.marker: $(loadbios_module_SOURCES) $(nodist_loadbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += loadenv.module
+MODULE_FILES += loadenv.module$(EXEEXT)
+loadenv_module_SOURCES = commands/loadenv.c lib/envblk.c ## platform sources
+nodist_loadenv_module_SOURCES = ## platform nodist sources
+loadenv_module_LDADD =
+loadenv_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+loadenv_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+loadenv_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+loadenv_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+loadenv_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_loadenv_module_SOURCES)
+CLEANFILES += $(nodist_loadenv_module_SOURCES)
+MOD_FILES += loadenv.mod
+MARKER_FILES += loadenv.marker
+CLEANFILES += loadenv.marker
+
+loadenv.marker: $(loadenv_module_SOURCES) $(nodist_loadenv_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadenv_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += ls.module
+MODULE_FILES += ls.module$(EXEEXT)
+ls_module_SOURCES = commands/ls.c ## platform sources
+nodist_ls_module_SOURCES = ## platform nodist sources
+ls_module_LDADD =
+ls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ls_module_SOURCES)
+CLEANFILES += $(nodist_ls_module_SOURCES)
+MOD_FILES += ls.mod
+MARKER_FILES += ls.marker
+CLEANFILES += ls.marker
+
+ls.marker: $(ls_module_SOURCES) $(nodist_ls_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += lsmmap.module
+MODULE_FILES += lsmmap.module$(EXEEXT)
+lsmmap_module_SOURCES = commands/lsmmap.c ## platform sources
+nodist_lsmmap_module_SOURCES = ## platform nodist sources
+lsmmap_module_LDADD =
+lsmmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsmmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsmmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsmmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsmmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsmmap_module_SOURCES)
+CLEANFILES += $(nodist_lsmmap_module_SOURCES)
+MOD_FILES += lsmmap.mod
+MARKER_FILES += lsmmap.marker
+CLEANFILES += lsmmap.marker
+
+lsmmap.marker: $(lsmmap_module_SOURCES) $(nodist_lsmmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsmmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += lspci.module
+MODULE_FILES += lspci.module$(EXEEXT)
+lspci_module_SOURCES = commands/lspci.c ## platform sources
+nodist_lspci_module_SOURCES = ## platform nodist sources
+lspci_module_LDADD =
+lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lspci_module_SOURCES)
+CLEANFILES += $(nodist_lspci_module_SOURCES)
+MOD_FILES += lspci.mod
+MARKER_FILES += lspci.marker
+CLEANFILES += lspci.marker
+
+lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += lspci.module
+MODULE_FILES += lspci.module$(EXEEXT)
+lspci_module_SOURCES = commands/lspci.c ## platform sources
+nodist_lspci_module_SOURCES = ## platform nodist sources
+lspci_module_LDADD =
+lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lspci_module_SOURCES)
+CLEANFILES += $(nodist_lspci_module_SOURCES)
+MOD_FILES += lspci.mod
+MARKER_FILES += lspci.marker
+CLEANFILES += lspci.marker
+
+lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += lspci.module
+MODULE_FILES += lspci.module$(EXEEXT)
+lspci_module_SOURCES = commands/lspci.c ## platform sources
+nodist_lspci_module_SOURCES = ## platform nodist sources
+lspci_module_LDADD =
+lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lspci_module_SOURCES)
+CLEANFILES += $(nodist_lspci_module_SOURCES)
+MOD_FILES += lspci.mod
+MARKER_FILES += lspci.marker
+CLEANFILES += lspci.marker
+
+lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += lspci.module
+MODULE_FILES += lspci.module$(EXEEXT)
+lspci_module_SOURCES = commands/lspci.c ## platform sources
+nodist_lspci_module_SOURCES = ## platform nodist sources
+lspci_module_LDADD =
+lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lspci_module_SOURCES)
+CLEANFILES += $(nodist_lspci_module_SOURCES)
+MOD_FILES += lspci.mod
+MARKER_FILES += lspci.marker
+CLEANFILES += lspci.marker
+
+lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += lspci.module
+MODULE_FILES += lspci.module$(EXEEXT)
+lspci_module_SOURCES = commands/lspci.c ## platform sources
+nodist_lspci_module_SOURCES = ## platform nodist sources
+lspci_module_LDADD =
+lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lspci_module_SOURCES)
+CLEANFILES += $(nodist_lspci_module_SOURCES)
+MOD_FILES += lspci.mod
+MARKER_FILES += lspci.marker
+CLEANFILES += lspci.marker
+
+lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += lspci.module
+MODULE_FILES += lspci.module$(EXEEXT)
+lspci_module_SOURCES = commands/lspci.c ## platform sources
+nodist_lspci_module_SOURCES = ## platform nodist sources
+lspci_module_LDADD =
+lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lspci_module_SOURCES)
+CLEANFILES += $(nodist_lspci_module_SOURCES)
+MOD_FILES += lspci.mod
+MARKER_FILES += lspci.marker
+CLEANFILES += lspci.marker
+
+lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += lspci.module
+MODULE_FILES += lspci.module$(EXEEXT)
+lspci_module_SOURCES = commands/lspci.c ## platform sources
+nodist_lspci_module_SOURCES = ## platform nodist sources
+lspci_module_LDADD =
+lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lspci_module_SOURCES)
+CLEANFILES += $(nodist_lspci_module_SOURCES)
+MOD_FILES += lspci.mod
+MARKER_FILES += lspci.marker
+CLEANFILES += lspci.marker
+
+lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += lspci.module
+MODULE_FILES += lspci.module$(EXEEXT)
+lspci_module_SOURCES = commands/lspci.c ## platform sources
+nodist_lspci_module_SOURCES = ## platform nodist sources
+lspci_module_LDADD =
+lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lspci_module_SOURCES)
+CLEANFILES += $(nodist_lspci_module_SOURCES)
+MOD_FILES += lspci.mod
+MARKER_FILES += lspci.marker
+CLEANFILES += lspci.marker
+
+lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += memrw.module
+MODULE_FILES += memrw.module$(EXEEXT)
+memrw_module_SOURCES = commands/memrw.c ## platform sources
+nodist_memrw_module_SOURCES = ## platform nodist sources
+memrw_module_LDADD =
+memrw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+memrw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+memrw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+memrw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+memrw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_memrw_module_SOURCES)
+CLEANFILES += $(nodist_memrw_module_SOURCES)
+MOD_FILES += memrw.mod
+MARKER_FILES += memrw.marker
+CLEANFILES += memrw.marker
+
+memrw.marker: $(memrw_module_SOURCES) $(nodist_memrw_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memrw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += minicmd.module
+MODULE_FILES += minicmd.module$(EXEEXT)
+minicmd_module_SOURCES = commands/minicmd.c ## platform sources
+nodist_minicmd_module_SOURCES = ## platform nodist sources
+minicmd_module_LDADD =
+minicmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minicmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minicmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minicmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minicmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_minicmd_module_SOURCES)
+CLEANFILES += $(nodist_minicmd_module_SOURCES)
+MOD_FILES += minicmd.mod
+MARKER_FILES += minicmd.marker
+CLEANFILES += minicmd.marker
+
+minicmd.marker: $(minicmd_module_SOURCES) $(nodist_minicmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minicmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += parttool.module
+MODULE_FILES += parttool.module$(EXEEXT)
+parttool_module_SOURCES = commands/parttool.c ## platform sources
+nodist_parttool_module_SOURCES = ## platform nodist sources
+parttool_module_LDADD =
+parttool_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+parttool_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+parttool_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+parttool_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+parttool_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_parttool_module_SOURCES)
+CLEANFILES += $(nodist_parttool_module_SOURCES)
+MOD_FILES += parttool.mod
+MARKER_FILES += parttool.marker
+CLEANFILES += parttool.marker
+
+parttool.marker: $(parttool_module_SOURCES) $(nodist_parttool_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(parttool_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += password.module
+MODULE_FILES += password.module$(EXEEXT)
+password_module_SOURCES = commands/password.c ## platform sources
+nodist_password_module_SOURCES = ## platform nodist sources
+password_module_LDADD =
+password_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+password_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+password_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+password_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+password_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_password_module_SOURCES)
+CLEANFILES += $(nodist_password_module_SOURCES)
+MOD_FILES += password.mod
+MARKER_FILES += password.marker
+CLEANFILES += password.marker
+
+password.marker: $(password_module_SOURCES) $(nodist_password_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += password_pbkdf2.module
+MODULE_FILES += password_pbkdf2.module$(EXEEXT)
+password_pbkdf2_module_SOURCES = commands/password_pbkdf2.c ## platform sources
+nodist_password_pbkdf2_module_SOURCES = ## platform nodist sources
+password_pbkdf2_module_LDADD =
+password_pbkdf2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+password_pbkdf2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+password_pbkdf2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+password_pbkdf2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+password_pbkdf2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_password_pbkdf2_module_SOURCES)
+CLEANFILES += $(nodist_password_pbkdf2_module_SOURCES)
+MOD_FILES += password_pbkdf2.mod
+MARKER_FILES += password_pbkdf2.marker
+CLEANFILES += password_pbkdf2.marker
+
+password_pbkdf2.marker: $(password_pbkdf2_module_SOURCES) $(nodist_password_pbkdf2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += play.module
+MODULE_FILES += play.module$(EXEEXT)
+play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+nodist_play_module_SOURCES = ## platform nodist sources
+play_module_LDADD =
+play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_play_module_SOURCES)
+CLEANFILES += $(nodist_play_module_SOURCES)
+MOD_FILES += play.mod
+MARKER_FILES += play.marker
+CLEANFILES += play.marker
+
+play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += play.module
+MODULE_FILES += play.module$(EXEEXT)
+play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+nodist_play_module_SOURCES = ## platform nodist sources
+play_module_LDADD =
+play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_play_module_SOURCES)
+CLEANFILES += $(nodist_play_module_SOURCES)
+MOD_FILES += play.mod
+MARKER_FILES += play.marker
+CLEANFILES += play.marker
+
+play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += play.module
+MODULE_FILES += play.module$(EXEEXT)
+play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+nodist_play_module_SOURCES = ## platform nodist sources
+play_module_LDADD =
+play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_play_module_SOURCES)
+CLEANFILES += $(nodist_play_module_SOURCES)
+MOD_FILES += play.mod
+MARKER_FILES += play.marker
+CLEANFILES += play.marker
+
+play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += play.module
+MODULE_FILES += play.module$(EXEEXT)
+play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+nodist_play_module_SOURCES = ## platform nodist sources
+play_module_LDADD =
+play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_play_module_SOURCES)
+CLEANFILES += $(nodist_play_module_SOURCES)
+MOD_FILES += play.mod
+MARKER_FILES += play.marker
+CLEANFILES += play.marker
+
+play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += play.module
+MODULE_FILES += play.module$(EXEEXT)
+play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+nodist_play_module_SOURCES = ## platform nodist sources
+play_module_LDADD =
+play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_play_module_SOURCES)
+CLEANFILES += $(nodist_play_module_SOURCES)
+MOD_FILES += play.mod
+MARKER_FILES += play.marker
+CLEANFILES += play.marker
+
+play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += play.module
+MODULE_FILES += play.module$(EXEEXT)
+play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+nodist_play_module_SOURCES = ## platform nodist sources
+play_module_LDADD =
+play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_play_module_SOURCES)
+CLEANFILES += $(nodist_play_module_SOURCES)
+MOD_FILES += play.mod
+MARKER_FILES += play.marker
+CLEANFILES += play.marker
+
+play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += play.module
+MODULE_FILES += play.module$(EXEEXT)
+play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+nodist_play_module_SOURCES = ## platform nodist sources
+play_module_LDADD =
+play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_play_module_SOURCES)
+CLEANFILES += $(nodist_play_module_SOURCES)
+MOD_FILES += play.mod
+MARKER_FILES += play.marker
+CLEANFILES += play.marker
+
+play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += spkmodem.module
+MODULE_FILES += spkmodem.module$(EXEEXT)
+spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+nodist_spkmodem_module_SOURCES = ## platform nodist sources
+spkmodem_module_LDADD =
+spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_spkmodem_module_SOURCES)
+CLEANFILES += $(nodist_spkmodem_module_SOURCES)
+MOD_FILES += spkmodem.mod
+MARKER_FILES += spkmodem.marker
+CLEANFILES += spkmodem.marker
+
+spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += spkmodem.module
+MODULE_FILES += spkmodem.module$(EXEEXT)
+spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+nodist_spkmodem_module_SOURCES = ## platform nodist sources
+spkmodem_module_LDADD =
+spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_spkmodem_module_SOURCES)
+CLEANFILES += $(nodist_spkmodem_module_SOURCES)
+MOD_FILES += spkmodem.mod
+MARKER_FILES += spkmodem.marker
+CLEANFILES += spkmodem.marker
+
+spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += spkmodem.module
+MODULE_FILES += spkmodem.module$(EXEEXT)
+spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+nodist_spkmodem_module_SOURCES = ## platform nodist sources
+spkmodem_module_LDADD =
+spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_spkmodem_module_SOURCES)
+CLEANFILES += $(nodist_spkmodem_module_SOURCES)
+MOD_FILES += spkmodem.mod
+MARKER_FILES += spkmodem.marker
+CLEANFILES += spkmodem.marker
+
+spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += spkmodem.module
+MODULE_FILES += spkmodem.module$(EXEEXT)
+spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+nodist_spkmodem_module_SOURCES = ## platform nodist sources
+spkmodem_module_LDADD =
+spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_spkmodem_module_SOURCES)
+CLEANFILES += $(nodist_spkmodem_module_SOURCES)
+MOD_FILES += spkmodem.mod
+MARKER_FILES += spkmodem.marker
+CLEANFILES += spkmodem.marker
+
+spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += spkmodem.module
+MODULE_FILES += spkmodem.module$(EXEEXT)
+spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+nodist_spkmodem_module_SOURCES = ## platform nodist sources
+spkmodem_module_LDADD =
+spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_spkmodem_module_SOURCES)
+CLEANFILES += $(nodist_spkmodem_module_SOURCES)
+MOD_FILES += spkmodem.mod
+MARKER_FILES += spkmodem.marker
+CLEANFILES += spkmodem.marker
+
+spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += spkmodem.module
+MODULE_FILES += spkmodem.module$(EXEEXT)
+spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+nodist_spkmodem_module_SOURCES = ## platform nodist sources
+spkmodem_module_LDADD =
+spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_spkmodem_module_SOURCES)
+CLEANFILES += $(nodist_spkmodem_module_SOURCES)
+MOD_FILES += spkmodem.mod
+MARKER_FILES += spkmodem.marker
+CLEANFILES += spkmodem.marker
+
+spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += spkmodem.module
+MODULE_FILES += spkmodem.module$(EXEEXT)
+spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+nodist_spkmodem_module_SOURCES = ## platform nodist sources
+spkmodem_module_LDADD =
+spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_spkmodem_module_SOURCES)
+CLEANFILES += $(nodist_spkmodem_module_SOURCES)
+MOD_FILES += spkmodem.mod
+MARKER_FILES += spkmodem.marker
+CLEANFILES += spkmodem.marker
+
+spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += morse.module
+MODULE_FILES += morse.module$(EXEEXT)
+morse_module_SOURCES = term/morse.c ## platform sources
+nodist_morse_module_SOURCES = ## platform nodist sources
+morse_module_LDADD =
+morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_morse_module_SOURCES)
+CLEANFILES += $(nodist_morse_module_SOURCES)
+MOD_FILES += morse.mod
+MARKER_FILES += morse.marker
+CLEANFILES += morse.marker
+
+morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += morse.module
+MODULE_FILES += morse.module$(EXEEXT)
+morse_module_SOURCES = term/morse.c ## platform sources
+nodist_morse_module_SOURCES = ## platform nodist sources
+morse_module_LDADD =
+morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_morse_module_SOURCES)
+CLEANFILES += $(nodist_morse_module_SOURCES)
+MOD_FILES += morse.mod
+MARKER_FILES += morse.marker
+CLEANFILES += morse.marker
+
+morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += morse.module
+MODULE_FILES += morse.module$(EXEEXT)
+morse_module_SOURCES = term/morse.c ## platform sources
+nodist_morse_module_SOURCES = ## platform nodist sources
+morse_module_LDADD =
+morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_morse_module_SOURCES)
+CLEANFILES += $(nodist_morse_module_SOURCES)
+MOD_FILES += morse.mod
+MARKER_FILES += morse.marker
+CLEANFILES += morse.marker
+
+morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += morse.module
+MODULE_FILES += morse.module$(EXEEXT)
+morse_module_SOURCES = term/morse.c ## platform sources
+nodist_morse_module_SOURCES = ## platform nodist sources
+morse_module_LDADD =
+morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_morse_module_SOURCES)
+CLEANFILES += $(nodist_morse_module_SOURCES)
+MOD_FILES += morse.mod
+MARKER_FILES += morse.marker
+CLEANFILES += morse.marker
+
+morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += morse.module
+MODULE_FILES += morse.module$(EXEEXT)
+morse_module_SOURCES = term/morse.c ## platform sources
+nodist_morse_module_SOURCES = ## platform nodist sources
+morse_module_LDADD =
+morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_morse_module_SOURCES)
+CLEANFILES += $(nodist_morse_module_SOURCES)
+MOD_FILES += morse.mod
+MARKER_FILES += morse.marker
+CLEANFILES += morse.marker
+
+morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += morse.module
+MODULE_FILES += morse.module$(EXEEXT)
+morse_module_SOURCES = term/morse.c ## platform sources
+nodist_morse_module_SOURCES = ## platform nodist sources
+morse_module_LDADD =
+morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_morse_module_SOURCES)
+CLEANFILES += $(nodist_morse_module_SOURCES)
+MOD_FILES += morse.mod
+MARKER_FILES += morse.marker
+CLEANFILES += morse.marker
+
+morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += morse.module
+MODULE_FILES += morse.module$(EXEEXT)
+morse_module_SOURCES = term/morse.c ## platform sources
+nodist_morse_module_SOURCES = ## platform nodist sources
+morse_module_LDADD =
+morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_morse_module_SOURCES)
+CLEANFILES += $(nodist_morse_module_SOURCES)
+MOD_FILES += morse.mod
+MARKER_FILES += morse.marker
+CLEANFILES += morse.marker
+
+morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += probe.module
+MODULE_FILES += probe.module$(EXEEXT)
+probe_module_SOURCES = commands/probe.c ## platform sources
+nodist_probe_module_SOURCES = ## platform nodist sources
+probe_module_LDADD =
+probe_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+probe_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+probe_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+probe_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+probe_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_probe_module_SOURCES)
+CLEANFILES += $(nodist_probe_module_SOURCES)
+MOD_FILES += probe.mod
+MARKER_FILES += probe.marker
+CLEANFILES += probe.marker
+
+probe.marker: $(probe_module_SOURCES) $(nodist_probe_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(probe_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += read.module
+MODULE_FILES += read.module$(EXEEXT)
+read_module_SOURCES = commands/read.c ## platform sources
+nodist_read_module_SOURCES = ## platform nodist sources
+read_module_LDADD =
+read_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+read_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+read_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+read_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+read_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_read_module_SOURCES)
+CLEANFILES += $(nodist_read_module_SOURCES)
+MOD_FILES += read.mod
+MARKER_FILES += read.marker
+CLEANFILES += read.marker
+
+read.marker: $(read_module_SOURCES) $(nodist_read_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(read_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += search.module
+MODULE_FILES += search.module$(EXEEXT)
+search_module_SOURCES = commands/search_wrap.c ## platform sources
+nodist_search_module_SOURCES = ## platform nodist sources
+search_module_LDADD =
+search_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+search_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+search_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+search_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+search_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += commands/search.c
+BUILT_SOURCES += $(nodist_search_module_SOURCES)
+CLEANFILES += $(nodist_search_module_SOURCES)
+MOD_FILES += search.mod
+MARKER_FILES += search.marker
+CLEANFILES += search.marker
+
+search.marker: $(search_module_SOURCES) $(nodist_search_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += search_fs_file.module
+MODULE_FILES += search_fs_file.module$(EXEEXT)
+search_fs_file_module_SOURCES = commands/search_file.c ## platform sources
+nodist_search_fs_file_module_SOURCES = ## platform nodist sources
+search_fs_file_module_LDADD =
+search_fs_file_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+search_fs_file_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+search_fs_file_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+search_fs_file_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+search_fs_file_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_search_fs_file_module_SOURCES)
+CLEANFILES += $(nodist_search_fs_file_module_SOURCES)
+MOD_FILES += search_fs_file.mod
+MARKER_FILES += search_fs_file.marker
+CLEANFILES += search_fs_file.marker
+
+search_fs_file.marker: $(search_fs_file_module_SOURCES) $(nodist_search_fs_file_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_file_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += search_fs_uuid.module
+MODULE_FILES += search_fs_uuid.module$(EXEEXT)
+search_fs_uuid_module_SOURCES = commands/search_uuid.c ## platform sources
+nodist_search_fs_uuid_module_SOURCES = ## platform nodist sources
+search_fs_uuid_module_LDADD =
+search_fs_uuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+search_fs_uuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+search_fs_uuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+search_fs_uuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+search_fs_uuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_search_fs_uuid_module_SOURCES)
+CLEANFILES += $(nodist_search_fs_uuid_module_SOURCES)
+MOD_FILES += search_fs_uuid.mod
+MARKER_FILES += search_fs_uuid.marker
+CLEANFILES += search_fs_uuid.marker
+
+search_fs_uuid.marker: $(search_fs_uuid_module_SOURCES) $(nodist_search_fs_uuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_uuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += search_label.module
+MODULE_FILES += search_label.module$(EXEEXT)
+search_label_module_SOURCES = commands/search_label.c ## platform sources
+nodist_search_label_module_SOURCES = ## platform nodist sources
+search_label_module_LDADD =
+search_label_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+search_label_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+search_label_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+search_label_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+search_label_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_search_label_module_SOURCES)
+CLEANFILES += $(nodist_search_label_module_SOURCES)
+MOD_FILES += search_label.mod
+MARKER_FILES += search_label.marker
+CLEANFILES += search_label.marker
+
+search_label.marker: $(search_label_module_SOURCES) $(nodist_search_label_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_label_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += setpci.module
+MODULE_FILES += setpci.module$(EXEEXT)
+setpci_module_SOURCES = commands/setpci.c ## platform sources
+nodist_setpci_module_SOURCES = ## platform nodist sources
+setpci_module_LDADD =
+setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_setpci_module_SOURCES)
+CLEANFILES += $(nodist_setpci_module_SOURCES)
+MOD_FILES += setpci.mod
+MARKER_FILES += setpci.marker
+CLEANFILES += setpci.marker
+
+setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += setpci.module
+MODULE_FILES += setpci.module$(EXEEXT)
+setpci_module_SOURCES = commands/setpci.c ## platform sources
+nodist_setpci_module_SOURCES = ## platform nodist sources
+setpci_module_LDADD =
+setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_setpci_module_SOURCES)
+CLEANFILES += $(nodist_setpci_module_SOURCES)
+MOD_FILES += setpci.mod
+MARKER_FILES += setpci.marker
+CLEANFILES += setpci.marker
+
+setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += setpci.module
+MODULE_FILES += setpci.module$(EXEEXT)
+setpci_module_SOURCES = commands/setpci.c ## platform sources
+nodist_setpci_module_SOURCES = ## platform nodist sources
+setpci_module_LDADD =
+setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_setpci_module_SOURCES)
+CLEANFILES += $(nodist_setpci_module_SOURCES)
+MOD_FILES += setpci.mod
+MARKER_FILES += setpci.marker
+CLEANFILES += setpci.marker
+
+setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += setpci.module
+MODULE_FILES += setpci.module$(EXEEXT)
+setpci_module_SOURCES = commands/setpci.c ## platform sources
+nodist_setpci_module_SOURCES = ## platform nodist sources
+setpci_module_LDADD =
+setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_setpci_module_SOURCES)
+CLEANFILES += $(nodist_setpci_module_SOURCES)
+MOD_FILES += setpci.mod
+MARKER_FILES += setpci.marker
+CLEANFILES += setpci.marker
+
+setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += setpci.module
+MODULE_FILES += setpci.module$(EXEEXT)
+setpci_module_SOURCES = commands/setpci.c ## platform sources
+nodist_setpci_module_SOURCES = ## platform nodist sources
+setpci_module_LDADD =
+setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_setpci_module_SOURCES)
+CLEANFILES += $(nodist_setpci_module_SOURCES)
+MOD_FILES += setpci.mod
+MARKER_FILES += setpci.marker
+CLEANFILES += setpci.marker
+
+setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += setpci.module
+MODULE_FILES += setpci.module$(EXEEXT)
+setpci_module_SOURCES = commands/setpci.c ## platform sources
+nodist_setpci_module_SOURCES = ## platform nodist sources
+setpci_module_LDADD =
+setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_setpci_module_SOURCES)
+CLEANFILES += $(nodist_setpci_module_SOURCES)
+MOD_FILES += setpci.mod
+MARKER_FILES += setpci.marker
+CLEANFILES += setpci.marker
+
+setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += setpci.module
+MODULE_FILES += setpci.module$(EXEEXT)
+setpci_module_SOURCES = commands/setpci.c ## platform sources
+nodist_setpci_module_SOURCES = ## platform nodist sources
+setpci_module_LDADD =
+setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_setpci_module_SOURCES)
+CLEANFILES += $(nodist_setpci_module_SOURCES)
+MOD_FILES += setpci.mod
+MARKER_FILES += setpci.marker
+CLEANFILES += setpci.marker
+
+setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += setpci.module
+MODULE_FILES += setpci.module$(EXEEXT)
+setpci_module_SOURCES = commands/setpci.c ## platform sources
+nodist_setpci_module_SOURCES = ## platform nodist sources
+setpci_module_LDADD =
+setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_setpci_module_SOURCES)
+CLEANFILES += $(nodist_setpci_module_SOURCES)
+MOD_FILES += setpci.mod
+MARKER_FILES += setpci.marker
+CLEANFILES += setpci.marker
+
+setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += pcidump.module
+MODULE_FILES += pcidump.module$(EXEEXT)
+pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+nodist_pcidump_module_SOURCES = ## platform nodist sources
+pcidump_module_LDADD =
+pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pcidump_module_SOURCES)
+CLEANFILES += $(nodist_pcidump_module_SOURCES)
+MOD_FILES += pcidump.mod
+MARKER_FILES += pcidump.marker
+CLEANFILES += pcidump.marker
+
+pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += pcidump.module
+MODULE_FILES += pcidump.module$(EXEEXT)
+pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+nodist_pcidump_module_SOURCES = ## platform nodist sources
+pcidump_module_LDADD =
+pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pcidump_module_SOURCES)
+CLEANFILES += $(nodist_pcidump_module_SOURCES)
+MOD_FILES += pcidump.mod
+MARKER_FILES += pcidump.marker
+CLEANFILES += pcidump.marker
+
+pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += pcidump.module
+MODULE_FILES += pcidump.module$(EXEEXT)
+pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+nodist_pcidump_module_SOURCES = ## platform nodist sources
+pcidump_module_LDADD =
+pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pcidump_module_SOURCES)
+CLEANFILES += $(nodist_pcidump_module_SOURCES)
+MOD_FILES += pcidump.mod
+MARKER_FILES += pcidump.marker
+CLEANFILES += pcidump.marker
+
+pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += pcidump.module
+MODULE_FILES += pcidump.module$(EXEEXT)
+pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+nodist_pcidump_module_SOURCES = ## platform nodist sources
+pcidump_module_LDADD =
+pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pcidump_module_SOURCES)
+CLEANFILES += $(nodist_pcidump_module_SOURCES)
+MOD_FILES += pcidump.mod
+MARKER_FILES += pcidump.marker
+CLEANFILES += pcidump.marker
+
+pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += pcidump.module
+MODULE_FILES += pcidump.module$(EXEEXT)
+pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+nodist_pcidump_module_SOURCES = ## platform nodist sources
+pcidump_module_LDADD =
+pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pcidump_module_SOURCES)
+CLEANFILES += $(nodist_pcidump_module_SOURCES)
+MOD_FILES += pcidump.mod
+MARKER_FILES += pcidump.marker
+CLEANFILES += pcidump.marker
+
+pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += pcidump.module
+MODULE_FILES += pcidump.module$(EXEEXT)
+pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+nodist_pcidump_module_SOURCES = ## platform nodist sources
+pcidump_module_LDADD =
+pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pcidump_module_SOURCES)
+CLEANFILES += $(nodist_pcidump_module_SOURCES)
+MOD_FILES += pcidump.mod
+MARKER_FILES += pcidump.marker
+CLEANFILES += pcidump.marker
+
+pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += pcidump.module
+MODULE_FILES += pcidump.module$(EXEEXT)
+pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+nodist_pcidump_module_SOURCES = ## platform nodist sources
+pcidump_module_LDADD =
+pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pcidump_module_SOURCES)
+CLEANFILES += $(nodist_pcidump_module_SOURCES)
+MOD_FILES += pcidump.mod
+MARKER_FILES += pcidump.marker
+CLEANFILES += pcidump.marker
+
+pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += pcidump.module
+MODULE_FILES += pcidump.module$(EXEEXT)
+pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+nodist_pcidump_module_SOURCES = ## platform nodist sources
+pcidump_module_LDADD =
+pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pcidump_module_SOURCES)
+CLEANFILES += $(nodist_pcidump_module_SOURCES)
+MOD_FILES += pcidump.mod
+MARKER_FILES += pcidump.marker
+CLEANFILES += pcidump.marker
+
+pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += sleep.module
+MODULE_FILES += sleep.module$(EXEEXT)
+sleep_module_SOURCES = commands/sleep.c ## platform sources
+nodist_sleep_module_SOURCES = ## platform nodist sources
+sleep_module_LDADD =
+sleep_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+sleep_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+sleep_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+sleep_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+sleep_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_sleep_module_SOURCES)
+CLEANFILES += $(nodist_sleep_module_SOURCES)
+MOD_FILES += sleep.mod
+MARKER_FILES += sleep.marker
+CLEANFILES += sleep.marker
+
+sleep.marker: $(sleep_module_SOURCES) $(nodist_sleep_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += smbios.module
+MODULE_FILES += smbios.module$(EXEEXT)
+smbios_module_SOURCES = commands/i386/pc/smbios.c commands/smbios.c ## platform sources
+nodist_smbios_module_SOURCES = ## platform nodist sources
+smbios_module_LDADD =
+smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_smbios_module_SOURCES)
+CLEANFILES += $(nodist_smbios_module_SOURCES)
+MOD_FILES += smbios.mod
+MARKER_FILES += smbios.marker
+CLEANFILES += smbios.marker
+
+smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += smbios.module
+MODULE_FILES += smbios.module$(EXEEXT)
+smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+nodist_smbios_module_SOURCES = ## platform nodist sources
+smbios_module_LDADD =
+smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_smbios_module_SOURCES)
+CLEANFILES += $(nodist_smbios_module_SOURCES)
+MOD_FILES += smbios.mod
+MARKER_FILES += smbios.marker
+CLEANFILES += smbios.marker
+
+smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += smbios.module
+MODULE_FILES += smbios.module$(EXEEXT)
+smbios_module_SOURCES = commands/i386/pc/smbios.c commands/smbios.c ## platform sources
+nodist_smbios_module_SOURCES = ## platform nodist sources
+smbios_module_LDADD =
+smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_smbios_module_SOURCES)
+CLEANFILES += $(nodist_smbios_module_SOURCES)
+MOD_FILES += smbios.mod
+MARKER_FILES += smbios.marker
+CLEANFILES += smbios.marker
+
+smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += smbios.module
+MODULE_FILES += smbios.module$(EXEEXT)
+smbios_module_SOURCES = commands/i386/pc/smbios.c commands/smbios.c ## platform sources
+nodist_smbios_module_SOURCES = ## platform nodist sources
+smbios_module_LDADD =
+smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_smbios_module_SOURCES)
+CLEANFILES += $(nodist_smbios_module_SOURCES)
+MOD_FILES += smbios.mod
+MARKER_FILES += smbios.marker
+CLEANFILES += smbios.marker
+
+smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += smbios.module
+MODULE_FILES += smbios.module$(EXEEXT)
+smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+nodist_smbios_module_SOURCES = ## platform nodist sources
+smbios_module_LDADD =
+smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_smbios_module_SOURCES)
+CLEANFILES += $(nodist_smbios_module_SOURCES)
+MOD_FILES += smbios.mod
+MARKER_FILES += smbios.marker
+CLEANFILES += smbios.marker
+
+smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += smbios.module
+MODULE_FILES += smbios.module$(EXEEXT)
+smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+nodist_smbios_module_SOURCES = ## platform nodist sources
+smbios_module_LDADD =
+smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_smbios_module_SOURCES)
+CLEANFILES += $(nodist_smbios_module_SOURCES)
+MOD_FILES += smbios.mod
+MARKER_FILES += smbios.marker
+CLEANFILES += smbios.marker
+
+smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += smbios.module
+MODULE_FILES += smbios.module$(EXEEXT)
+smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+nodist_smbios_module_SOURCES = ## platform nodist sources
+smbios_module_LDADD =
+smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_smbios_module_SOURCES)
+CLEANFILES += $(nodist_smbios_module_SOURCES)
+MOD_FILES += smbios.mod
+MARKER_FILES += smbios.marker
+CLEANFILES += smbios.marker
+
+smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += smbios.module
+MODULE_FILES += smbios.module$(EXEEXT)
+smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+nodist_smbios_module_SOURCES = ## platform nodist sources
+smbios_module_LDADD =
+smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_smbios_module_SOURCES)
+CLEANFILES += $(nodist_smbios_module_SOURCES)
+MOD_FILES += smbios.mod
+MARKER_FILES += smbios.marker
+CLEANFILES += smbios.marker
+
+smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += smbios.module
+MODULE_FILES += smbios.module$(EXEEXT)
+smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+nodist_smbios_module_SOURCES = ## platform nodist sources
+smbios_module_LDADD =
+smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_smbios_module_SOURCES)
+CLEANFILES += $(nodist_smbios_module_SOURCES)
+MOD_FILES += smbios.mod
+MARKER_FILES += smbios.marker
+CLEANFILES += smbios.marker
+
+smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += smbios.module
+MODULE_FILES += smbios.module$(EXEEXT)
+smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+nodist_smbios_module_SOURCES = ## platform nodist sources
+smbios_module_LDADD =
+smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_smbios_module_SOURCES)
+CLEANFILES += $(nodist_smbios_module_SOURCES)
+MOD_FILES += smbios.mod
+MARKER_FILES += smbios.marker
+CLEANFILES += smbios.marker
+
+smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += suspend.module
+MODULE_FILES += suspend.module$(EXEEXT)
+suspend_module_SOURCES = commands/ieee1275/suspend.c ## platform sources
+nodist_suspend_module_SOURCES = ## platform nodist sources
+suspend_module_LDADD =
+suspend_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+suspend_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+suspend_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+suspend_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+suspend_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_suspend_module_SOURCES)
+CLEANFILES += $(nodist_suspend_module_SOURCES)
+MOD_FILES += suspend.mod
+MARKER_FILES += suspend.marker
+CLEANFILES += suspend.marker
+
+suspend.marker: $(suspend_module_SOURCES) $(nodist_suspend_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += suspend.module
+MODULE_FILES += suspend.module$(EXEEXT)
+suspend_module_SOURCES = commands/ieee1275/suspend.c ## platform sources
+nodist_suspend_module_SOURCES = ## platform nodist sources
+suspend_module_LDADD =
+suspend_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+suspend_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+suspend_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+suspend_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+suspend_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_suspend_module_SOURCES)
+CLEANFILES += $(nodist_suspend_module_SOURCES)
+MOD_FILES += suspend.mod
+MARKER_FILES += suspend.marker
+CLEANFILES += suspend.marker
+
+suspend.marker: $(suspend_module_SOURCES) $(nodist_suspend_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += escc.module
+MODULE_FILES += escc.module$(EXEEXT)
+escc_module_SOURCES = term/ieee1275/escc.c ## platform sources
+nodist_escc_module_SOURCES = ## platform nodist sources
+escc_module_LDADD =
+escc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+escc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+escc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+escc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+escc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_escc_module_SOURCES)
+CLEANFILES += $(nodist_escc_module_SOURCES)
+MOD_FILES += escc.mod
+MARKER_FILES += escc.marker
+CLEANFILES += escc.marker
+
+escc.marker: $(escc_module_SOURCES) $(nodist_escc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(escc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += terminal.module
+MODULE_FILES += terminal.module$(EXEEXT)
+terminal_module_SOURCES = commands/terminal.c ## platform sources
+nodist_terminal_module_SOURCES = ## platform nodist sources
+terminal_module_LDADD =
+terminal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminal_module_SOURCES)
+CLEANFILES += $(nodist_terminal_module_SOURCES)
+MOD_FILES += terminal.mod
+MARKER_FILES += terminal.marker
+CLEANFILES += terminal.marker
+
+terminal.marker: $(terminal_module_SOURCES) $(nodist_terminal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += test.module
+MODULE_FILES += test.module$(EXEEXT)
+test_module_SOURCES = commands/test.c ## platform sources
+nodist_test_module_SOURCES = ## platform nodist sources
+test_module_LDADD =
+test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_test_module_SOURCES)
+CLEANFILES += $(nodist_test_module_SOURCES)
+MOD_FILES += test.mod
+MARKER_FILES += test.marker
+CLEANFILES += test.marker
+
+test.marker: $(test_module_SOURCES) $(nodist_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += true.module
+MODULE_FILES += true.module$(EXEEXT)
+true_module_SOURCES = commands/true.c ## platform sources
+nodist_true_module_SOURCES = ## platform nodist sources
+true_module_LDADD =
+true_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+true_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+true_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+true_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+true_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_true_module_SOURCES)
+CLEANFILES += $(nodist_true_module_SOURCES)
+MOD_FILES += true.mod
+MARKER_FILES += true.marker
+CLEANFILES += true.marker
+
+true.marker: $(true_module_SOURCES) $(nodist_true_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(true_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += usbtest.module
+MODULE_FILES += usbtest.module$(EXEEXT)
+usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+nodist_usbtest_module_SOURCES = ## platform nodist sources
+usbtest_module_LDADD =
+usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbtest_module_SOURCES)
+CLEANFILES += $(nodist_usbtest_module_SOURCES)
+MOD_FILES += usbtest.mod
+MARKER_FILES += usbtest.marker
+CLEANFILES += usbtest.marker
+
+usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += usbtest.module
+MODULE_FILES += usbtest.module$(EXEEXT)
+usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+nodist_usbtest_module_SOURCES = ## platform nodist sources
+usbtest_module_LDADD =
+usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbtest_module_SOURCES)
+CLEANFILES += $(nodist_usbtest_module_SOURCES)
+MOD_FILES += usbtest.mod
+MARKER_FILES += usbtest.marker
+CLEANFILES += usbtest.marker
+
+usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += usbtest.module
+MODULE_FILES += usbtest.module$(EXEEXT)
+usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+nodist_usbtest_module_SOURCES = ## platform nodist sources
+usbtest_module_LDADD =
+usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbtest_module_SOURCES)
+CLEANFILES += $(nodist_usbtest_module_SOURCES)
+MOD_FILES += usbtest.mod
+MARKER_FILES += usbtest.marker
+CLEANFILES += usbtest.marker
+
+usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += usbtest.module
+MODULE_FILES += usbtest.module$(EXEEXT)
+usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+nodist_usbtest_module_SOURCES = ## platform nodist sources
+usbtest_module_LDADD =
+usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbtest_module_SOURCES)
+CLEANFILES += $(nodist_usbtest_module_SOURCES)
+MOD_FILES += usbtest.mod
+MARKER_FILES += usbtest.marker
+CLEANFILES += usbtest.marker
+
+usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += usbtest.module
+MODULE_FILES += usbtest.module$(EXEEXT)
+usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+nodist_usbtest_module_SOURCES = ## platform nodist sources
+usbtest_module_LDADD =
+usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbtest_module_SOURCES)
+CLEANFILES += $(nodist_usbtest_module_SOURCES)
+MOD_FILES += usbtest.mod
+MARKER_FILES += usbtest.marker
+CLEANFILES += usbtest.marker
+
+usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += usbtest.module
+MODULE_FILES += usbtest.module$(EXEEXT)
+usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+nodist_usbtest_module_SOURCES = ## platform nodist sources
+usbtest_module_LDADD =
+usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbtest_module_SOURCES)
+CLEANFILES += $(nodist_usbtest_module_SOURCES)
+MOD_FILES += usbtest.mod
+MARKER_FILES += usbtest.marker
+CLEANFILES += usbtest.marker
+
+usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += usbtest.module
+MODULE_FILES += usbtest.module$(EXEEXT)
+usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+nodist_usbtest_module_SOURCES = ## platform nodist sources
+usbtest_module_LDADD =
+usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbtest_module_SOURCES)
+CLEANFILES += $(nodist_usbtest_module_SOURCES)
+MOD_FILES += usbtest.mod
+MARKER_FILES += usbtest.marker
+CLEANFILES += usbtest.marker
+
+usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += usbtest.module
+MODULE_FILES += usbtest.module$(EXEEXT)
+usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+nodist_usbtest_module_SOURCES = ## platform nodist sources
+usbtest_module_LDADD =
+usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbtest_module_SOURCES)
+CLEANFILES += $(nodist_usbtest_module_SOURCES)
+MOD_FILES += usbtest.mod
+MARKER_FILES += usbtest.marker
+CLEANFILES += usbtest.marker
+
+usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += usbtest.module
+MODULE_FILES += usbtest.module$(EXEEXT)
+usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+nodist_usbtest_module_SOURCES = ## platform nodist sources
+usbtest_module_LDADD =
+usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbtest_module_SOURCES)
+CLEANFILES += $(nodist_usbtest_module_SOURCES)
+MOD_FILES += usbtest.mod
+MARKER_FILES += usbtest.marker
+CLEANFILES += usbtest.marker
+
+usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += videoinfo.module
+MODULE_FILES += videoinfo.module$(EXEEXT)
+videoinfo_module_SOURCES = commands/videoinfo.c ## platform sources
+nodist_videoinfo_module_SOURCES = ## platform nodist sources
+videoinfo_module_LDADD =
+videoinfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+videoinfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+videoinfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+videoinfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+videoinfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_videoinfo_module_SOURCES)
+CLEANFILES += $(nodist_videoinfo_module_SOURCES)
+MOD_FILES += videoinfo.mod
+MARKER_FILES += videoinfo.marker
+CLEANFILES += videoinfo.marker
+
+videoinfo.marker: $(videoinfo_module_SOURCES) $(nodist_videoinfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videoinfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += videotest.module
+MODULE_FILES += videotest.module$(EXEEXT)
+videotest_module_SOURCES = commands/videotest.c ## platform sources
+nodist_videotest_module_SOURCES = ## platform nodist sources
+videotest_module_LDADD =
+videotest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+videotest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+videotest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+videotest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+videotest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_videotest_module_SOURCES)
+CLEANFILES += $(nodist_videotest_module_SOURCES)
+MOD_FILES += videotest.mod
+MARKER_FILES += videotest.marker
+CLEANFILES += videotest.marker
+
+videotest.marker: $(videotest_module_SOURCES) $(nodist_videotest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += xnu_uuid.module
+MODULE_FILES += xnu_uuid.module$(EXEEXT)
+xnu_uuid_module_SOURCES = commands/xnu_uuid.c ## platform sources
+nodist_xnu_uuid_module_SOURCES = ## platform nodist sources
+xnu_uuid_module_LDADD =
+xnu_uuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xnu_uuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xnu_uuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xnu_uuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xnu_uuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xnu_uuid_module_SOURCES)
+CLEANFILES += $(nodist_xnu_uuid_module_SOURCES)
+MOD_FILES += xnu_uuid.mod
+MARKER_FILES += xnu_uuid.marker
+CLEANFILES += xnu_uuid.marker
+
+xnu_uuid.marker: $(xnu_uuid_module_SOURCES) $(nodist_xnu_uuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += dm_nv.module
+MODULE_FILES += dm_nv.module$(EXEEXT)
+dm_nv_module_SOURCES = disk/dmraid_nvidia.c ## platform sources
+nodist_dm_nv_module_SOURCES = ## platform nodist sources
+dm_nv_module_LDADD =
+dm_nv_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+dm_nv_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+dm_nv_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+dm_nv_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+dm_nv_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_dm_nv_module_SOURCES)
+CLEANFILES += $(nodist_dm_nv_module_SOURCES)
+MOD_FILES += dm_nv.mod
+MARKER_FILES += dm_nv.marker
+CLEANFILES += dm_nv.marker
+
+dm_nv.marker: $(dm_nv_module_SOURCES) $(nodist_dm_nv_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dm_nv_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += loopback.module
+MODULE_FILES += loopback.module$(EXEEXT)
+loopback_module_SOURCES = disk/loopback.c ## platform sources
+nodist_loopback_module_SOURCES = ## platform nodist sources
+loopback_module_LDADD =
+loopback_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+loopback_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+loopback_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+loopback_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+loopback_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_loopback_module_SOURCES)
+CLEANFILES += $(nodist_loopback_module_SOURCES)
+MOD_FILES += loopback.mod
+MARKER_FILES += loopback.marker
+CLEANFILES += loopback.marker
+
+loopback.marker: $(loopback_module_SOURCES) $(nodist_loopback_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loopback_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += cryptodisk.module
+MODULE_FILES += cryptodisk.module$(EXEEXT)
+cryptodisk_module_SOURCES = disk/cryptodisk.c ## platform sources
+nodist_cryptodisk_module_SOURCES = ## platform nodist sources
+cryptodisk_module_LDADD =
+cryptodisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cryptodisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cryptodisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cryptodisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cryptodisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cryptodisk_module_SOURCES)
+CLEANFILES += $(nodist_cryptodisk_module_SOURCES)
+MOD_FILES += cryptodisk.mod
+MARKER_FILES += cryptodisk.marker
+CLEANFILES += cryptodisk.marker
+
+cryptodisk.marker: $(cryptodisk_module_SOURCES) $(nodist_cryptodisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cryptodisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += json.module
+MODULE_FILES += json.module$(EXEEXT)
+json_module_SOURCES = lib/json/json.c ## platform sources
+nodist_json_module_SOURCES = ## platform nodist sources
+json_module_LDADD =
+json_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+json_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+json_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+json_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+json_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_json_module_SOURCES)
+CLEANFILES += $(nodist_json_module_SOURCES)
+MOD_FILES += json.mod
+MARKER_FILES += json.marker
+CLEANFILES += json.marker
+
+json.marker: $(json_module_SOURCES) $(nodist_json_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(json_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += afsplitter.module
+MODULE_FILES += afsplitter.module$(EXEEXT)
+afsplitter_module_SOURCES = disk/AFSplitter.c ## platform sources
+nodist_afsplitter_module_SOURCES = ## platform nodist sources
+afsplitter_module_LDADD =
+afsplitter_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+afsplitter_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+afsplitter_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+afsplitter_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+afsplitter_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_afsplitter_module_SOURCES)
+CLEANFILES += $(nodist_afsplitter_module_SOURCES)
+MOD_FILES += afsplitter.mod
+MARKER_FILES += afsplitter.marker
+CLEANFILES += afsplitter.marker
+
+afsplitter.marker: $(afsplitter_module_SOURCES) $(nodist_afsplitter_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afsplitter_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += luks.module
+MODULE_FILES += luks.module$(EXEEXT)
+luks_module_SOURCES = disk/luks.c ## platform sources
+nodist_luks_module_SOURCES = ## platform nodist sources
+luks_module_LDADD =
+luks_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+luks_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+luks_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+luks_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+luks_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_luks_module_SOURCES)
+CLEANFILES += $(nodist_luks_module_SOURCES)
+MOD_FILES += luks.mod
+MARKER_FILES += luks.marker
+CLEANFILES += luks.marker
+
+luks.marker: $(luks_module_SOURCES) $(nodist_luks_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += luks2.module
+MODULE_FILES += luks2.module$(EXEEXT)
+luks2_module_SOURCES = disk/luks2.c lib/gnulib/base64.c ## platform sources
+nodist_luks2_module_SOURCES = ## platform nodist sources
+luks2_module_LDADD =
+luks2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) $(CFLAGS_GNULIB)
+luks2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+luks2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB) -I$(srcdir)/lib/json
+luks2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+luks2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_luks2_module_SOURCES)
+CLEANFILES += $(nodist_luks2_module_SOURCES)
+MOD_FILES += luks2.mod
+MARKER_FILES += luks2.marker
+CLEANFILES += luks2.marker
+
+luks2.marker: $(luks2_module_SOURCES) $(nodist_luks2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += geli.module
+MODULE_FILES += geli.module$(EXEEXT)
+geli_module_SOURCES = disk/geli.c ## platform sources
+nodist_geli_module_SOURCES = ## platform nodist sources
+geli_module_LDADD =
+geli_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+geli_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+geli_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+geli_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+geli_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_geli_module_SOURCES)
+CLEANFILES += $(nodist_geli_module_SOURCES)
+MOD_FILES += geli.mod
+MARKER_FILES += geli.marker
+CLEANFILES += geli.marker
+
+geli.marker: $(geli_module_SOURCES) $(nodist_geli_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(geli_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += lvm.module
+MODULE_FILES += lvm.module$(EXEEXT)
+lvm_module_SOURCES = disk/lvm.c ## platform sources
+nodist_lvm_module_SOURCES = ## platform nodist sources
+lvm_module_LDADD =
+lvm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lvm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lvm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lvm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lvm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lvm_module_SOURCES)
+CLEANFILES += $(nodist_lvm_module_SOURCES)
+MOD_FILES += lvm.mod
+MARKER_FILES += lvm.marker
+CLEANFILES += lvm.marker
+
+lvm.marker: $(lvm_module_SOURCES) $(nodist_lvm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lvm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += ldm.module
+MODULE_FILES += ldm.module$(EXEEXT)
+ldm_module_SOURCES = disk/ldm.c ## platform sources
+nodist_ldm_module_SOURCES = ## platform nodist sources
+ldm_module_LDADD =
+ldm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ldm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ldm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ldm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ldm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ldm_module_SOURCES)
+CLEANFILES += $(nodist_ldm_module_SOURCES)
+MOD_FILES += ldm.mod
+MARKER_FILES += ldm.marker
+CLEANFILES += ldm.marker
+
+ldm.marker: $(ldm_module_SOURCES) $(nodist_ldm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ldm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += mdraid09.module
+MODULE_FILES += mdraid09.module$(EXEEXT)
+mdraid09_module_SOURCES = disk/mdraid_linux.c ## platform sources
+nodist_mdraid09_module_SOURCES = ## platform nodist sources
+mdraid09_module_LDADD =
+mdraid09_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mdraid09_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mdraid09_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mdraid09_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mdraid09_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mdraid09_module_SOURCES)
+CLEANFILES += $(nodist_mdraid09_module_SOURCES)
+MOD_FILES += mdraid09.mod
+MARKER_FILES += mdraid09.marker
+CLEANFILES += mdraid09.marker
+
+mdraid09.marker: $(mdraid09_module_SOURCES) $(nodist_mdraid09_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += mdraid09_be.module
+MODULE_FILES += mdraid09_be.module$(EXEEXT)
+mdraid09_be_module_SOURCES = disk/mdraid_linux_be.c ## platform sources
+nodist_mdraid09_be_module_SOURCES = ## platform nodist sources
+mdraid09_be_module_LDADD =
+mdraid09_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mdraid09_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mdraid09_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mdraid09_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mdraid09_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mdraid09_be_module_SOURCES)
+CLEANFILES += $(nodist_mdraid09_be_module_SOURCES)
+MOD_FILES += mdraid09_be.mod
+MARKER_FILES += mdraid09_be.marker
+CLEANFILES += mdraid09_be.marker
+
+mdraid09_be.marker: $(mdraid09_be_module_SOURCES) $(nodist_mdraid09_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += mdraid1x.module
+MODULE_FILES += mdraid1x.module$(EXEEXT)
+mdraid1x_module_SOURCES = disk/mdraid1x_linux.c ## platform sources
+nodist_mdraid1x_module_SOURCES = ## platform nodist sources
+mdraid1x_module_LDADD =
+mdraid1x_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mdraid1x_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mdraid1x_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mdraid1x_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mdraid1x_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mdraid1x_module_SOURCES)
+CLEANFILES += $(nodist_mdraid1x_module_SOURCES)
+MOD_FILES += mdraid1x.mod
+MARKER_FILES += mdraid1x.marker
+CLEANFILES += mdraid1x.marker
+
+mdraid1x.marker: $(mdraid1x_module_SOURCES) $(nodist_mdraid1x_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid1x_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += diskfilter.module
+MODULE_FILES += diskfilter.module$(EXEEXT)
+diskfilter_module_SOURCES = disk/diskfilter.c ## platform sources
+nodist_diskfilter_module_SOURCES = ## platform nodist sources
+diskfilter_module_LDADD =
+diskfilter_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+diskfilter_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+diskfilter_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+diskfilter_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+diskfilter_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_diskfilter_module_SOURCES)
+CLEANFILES += $(nodist_diskfilter_module_SOURCES)
+MOD_FILES += diskfilter.mod
+MARKER_FILES += diskfilter.marker
+CLEANFILES += diskfilter.marker
+
+diskfilter.marker: $(diskfilter_module_SOURCES) $(nodist_diskfilter_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskfilter_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += raid5rec.module
+MODULE_FILES += raid5rec.module$(EXEEXT)
+raid5rec_module_SOURCES = disk/raid5_recover.c ## platform sources
+nodist_raid5rec_module_SOURCES = ## platform nodist sources
+raid5rec_module_LDADD =
+raid5rec_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+raid5rec_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+raid5rec_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+raid5rec_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+raid5rec_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_raid5rec_module_SOURCES)
+CLEANFILES += $(nodist_raid5rec_module_SOURCES)
+MOD_FILES += raid5rec.mod
+MARKER_FILES += raid5rec.marker
+CLEANFILES += raid5rec.marker
+
+raid5rec.marker: $(raid5rec_module_SOURCES) $(nodist_raid5rec_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid5rec_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += raid6rec.module
+MODULE_FILES += raid6rec.module$(EXEEXT)
+raid6rec_module_SOURCES = disk/raid6_recover.c ## platform sources
+nodist_raid6rec_module_SOURCES = ## platform nodist sources
+raid6rec_module_LDADD =
+raid6rec_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+raid6rec_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+raid6rec_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+raid6rec_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+raid6rec_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_raid6rec_module_SOURCES)
+CLEANFILES += $(nodist_raid6rec_module_SOURCES)
+MOD_FILES += raid6rec.mod
+MARKER_FILES += raid6rec.marker
+CLEANFILES += raid6rec.marker
+
+raid6rec.marker: $(raid6rec_module_SOURCES) $(nodist_raid6rec_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid6rec_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += scsi.module
+MODULE_FILES += scsi.module$(EXEEXT)
+scsi_module_SOURCES = disk/scsi.c ## platform sources
+nodist_scsi_module_SOURCES = ## platform nodist sources
+scsi_module_LDADD =
+scsi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+scsi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+scsi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+scsi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+scsi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_scsi_module_SOURCES)
+CLEANFILES += $(nodist_scsi_module_SOURCES)
+MOD_FILES += scsi.mod
+MARKER_FILES += scsi.marker
+CLEANFILES += scsi.marker
+
+scsi.marker: $(scsi_module_SOURCES) $(nodist_scsi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(scsi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += memdisk.module
+MODULE_FILES += memdisk.module$(EXEEXT)
+memdisk_module_SOURCES = disk/memdisk.c ## platform sources
+nodist_memdisk_module_SOURCES = ## platform nodist sources
+memdisk_module_LDADD =
+memdisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+memdisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+memdisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+memdisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+memdisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_memdisk_module_SOURCES)
+CLEANFILES += $(nodist_memdisk_module_SOURCES)
+MOD_FILES += memdisk.mod
+MARKER_FILES += memdisk.marker
+CLEANFILES += memdisk.marker
+
+memdisk.marker: $(memdisk_module_SOURCES) $(nodist_memdisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memdisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += ata.module
+MODULE_FILES += ata.module$(EXEEXT)
+ata_module_SOURCES = disk/ata.c ## platform sources
+nodist_ata_module_SOURCES = ## platform nodist sources
+ata_module_LDADD =
+ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ata_module_SOURCES)
+CLEANFILES += $(nodist_ata_module_SOURCES)
+MOD_FILES += ata.mod
+MARKER_FILES += ata.marker
+CLEANFILES += ata.marker
+
+ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += ata.module
+MODULE_FILES += ata.module$(EXEEXT)
+ata_module_SOURCES = disk/ata.c ## platform sources
+nodist_ata_module_SOURCES = ## platform nodist sources
+ata_module_LDADD =
+ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ata_module_SOURCES)
+CLEANFILES += $(nodist_ata_module_SOURCES)
+MOD_FILES += ata.mod
+MARKER_FILES += ata.marker
+CLEANFILES += ata.marker
+
+ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += ata.module
+MODULE_FILES += ata.module$(EXEEXT)
+ata_module_SOURCES = disk/ata.c ## platform sources
+nodist_ata_module_SOURCES = ## platform nodist sources
+ata_module_LDADD =
+ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ata_module_SOURCES)
+CLEANFILES += $(nodist_ata_module_SOURCES)
+MOD_FILES += ata.mod
+MARKER_FILES += ata.marker
+CLEANFILES += ata.marker
+
+ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += ata.module
+MODULE_FILES += ata.module$(EXEEXT)
+ata_module_SOURCES = disk/ata.c ## platform sources
+nodist_ata_module_SOURCES = ## platform nodist sources
+ata_module_LDADD =
+ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ata_module_SOURCES)
+CLEANFILES += $(nodist_ata_module_SOURCES)
+MOD_FILES += ata.mod
+MARKER_FILES += ata.marker
+CLEANFILES += ata.marker
+
+ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += ata.module
+MODULE_FILES += ata.module$(EXEEXT)
+ata_module_SOURCES = disk/ata.c ## platform sources
+nodist_ata_module_SOURCES = ## platform nodist sources
+ata_module_LDADD =
+ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ata_module_SOURCES)
+CLEANFILES += $(nodist_ata_module_SOURCES)
+MOD_FILES += ata.mod
+MARKER_FILES += ata.marker
+CLEANFILES += ata.marker
+
+ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += ata.module
+MODULE_FILES += ata.module$(EXEEXT)
+ata_module_SOURCES = disk/ata.c ## platform sources
+nodist_ata_module_SOURCES = ## platform nodist sources
+ata_module_LDADD =
+ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ata_module_SOURCES)
+CLEANFILES += $(nodist_ata_module_SOURCES)
+MOD_FILES += ata.mod
+MARKER_FILES += ata.marker
+CLEANFILES += ata.marker
+
+ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += ata.module
+MODULE_FILES += ata.module$(EXEEXT)
+ata_module_SOURCES = disk/ata.c ## platform sources
+nodist_ata_module_SOURCES = ## platform nodist sources
+ata_module_LDADD =
+ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ata_module_SOURCES)
+CLEANFILES += $(nodist_ata_module_SOURCES)
+MOD_FILES += ata.mod
+MARKER_FILES += ata.marker
+CLEANFILES += ata.marker
+
+ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += ata.module
+MODULE_FILES += ata.module$(EXEEXT)
+ata_module_SOURCES = disk/ata.c ## platform sources
+nodist_ata_module_SOURCES = ## platform nodist sources
+ata_module_LDADD =
+ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ata_module_SOURCES)
+CLEANFILES += $(nodist_ata_module_SOURCES)
+MOD_FILES += ata.mod
+MARKER_FILES += ata.marker
+CLEANFILES += ata.marker
+
+ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += ata.module
+MODULE_FILES += ata.module$(EXEEXT)
+ata_module_SOURCES = disk/ata.c ## platform sources
+nodist_ata_module_SOURCES = ## platform nodist sources
+ata_module_LDADD =
+ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ata_module_SOURCES)
+CLEANFILES += $(nodist_ata_module_SOURCES)
+MOD_FILES += ata.mod
+MARKER_FILES += ata.marker
+CLEANFILES += ata.marker
+
+ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += ahci.module
+MODULE_FILES += ahci.module$(EXEEXT)
+ahci_module_SOURCES = disk/ahci.c ## platform sources
+nodist_ahci_module_SOURCES = ## platform nodist sources
+ahci_module_LDADD =
+ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ahci_module_SOURCES)
+CLEANFILES += $(nodist_ahci_module_SOURCES)
+MOD_FILES += ahci.mod
+MARKER_FILES += ahci.marker
+CLEANFILES += ahci.marker
+
+ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += ahci.module
+MODULE_FILES += ahci.module$(EXEEXT)
+ahci_module_SOURCES = disk/ahci.c ## platform sources
+nodist_ahci_module_SOURCES = ## platform nodist sources
+ahci_module_LDADD =
+ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ahci_module_SOURCES)
+CLEANFILES += $(nodist_ahci_module_SOURCES)
+MOD_FILES += ahci.mod
+MARKER_FILES += ahci.marker
+CLEANFILES += ahci.marker
+
+ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += ahci.module
+MODULE_FILES += ahci.module$(EXEEXT)
+ahci_module_SOURCES = disk/ahci.c ## platform sources
+nodist_ahci_module_SOURCES = ## platform nodist sources
+ahci_module_LDADD =
+ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ahci_module_SOURCES)
+CLEANFILES += $(nodist_ahci_module_SOURCES)
+MOD_FILES += ahci.mod
+MARKER_FILES += ahci.marker
+CLEANFILES += ahci.marker
+
+ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += ahci.module
+MODULE_FILES += ahci.module$(EXEEXT)
+ahci_module_SOURCES = disk/ahci.c ## platform sources
+nodist_ahci_module_SOURCES = ## platform nodist sources
+ahci_module_LDADD =
+ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ahci_module_SOURCES)
+CLEANFILES += $(nodist_ahci_module_SOURCES)
+MOD_FILES += ahci.mod
+MARKER_FILES += ahci.marker
+CLEANFILES += ahci.marker
+
+ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += ahci.module
+MODULE_FILES += ahci.module$(EXEEXT)
+ahci_module_SOURCES = disk/ahci.c ## platform sources
+nodist_ahci_module_SOURCES = ## platform nodist sources
+ahci_module_LDADD =
+ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ahci_module_SOURCES)
+CLEANFILES += $(nodist_ahci_module_SOURCES)
+MOD_FILES += ahci.mod
+MARKER_FILES += ahci.marker
+CLEANFILES += ahci.marker
+
+ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += ahci.module
+MODULE_FILES += ahci.module$(EXEEXT)
+ahci_module_SOURCES = disk/ahci.c ## platform sources
+nodist_ahci_module_SOURCES = ## platform nodist sources
+ahci_module_LDADD =
+ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ahci_module_SOURCES)
+CLEANFILES += $(nodist_ahci_module_SOURCES)
+MOD_FILES += ahci.mod
+MARKER_FILES += ahci.marker
+CLEANFILES += ahci.marker
+
+ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += ahci.module
+MODULE_FILES += ahci.module$(EXEEXT)
+ahci_module_SOURCES = disk/ahci.c ## platform sources
+nodist_ahci_module_SOURCES = ## platform nodist sources
+ahci_module_LDADD =
+ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ahci_module_SOURCES)
+CLEANFILES += $(nodist_ahci_module_SOURCES)
+MOD_FILES += ahci.mod
+MARKER_FILES += ahci.marker
+CLEANFILES += ahci.marker
+
+ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += ahci.module
+MODULE_FILES += ahci.module$(EXEEXT)
+ahci_module_SOURCES = disk/ahci.c ## platform sources
+nodist_ahci_module_SOURCES = ## platform nodist sources
+ahci_module_LDADD =
+ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ahci_module_SOURCES)
+CLEANFILES += $(nodist_ahci_module_SOURCES)
+MOD_FILES += ahci.mod
+MARKER_FILES += ahci.marker
+CLEANFILES += ahci.marker
+
+ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += pata.module
+MODULE_FILES += pata.module$(EXEEXT)
+pata_module_SOURCES = disk/pata.c ## platform sources
+nodist_pata_module_SOURCES = ## platform nodist sources
+pata_module_LDADD =
+pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pata_module_SOURCES)
+CLEANFILES += $(nodist_pata_module_SOURCES)
+MOD_FILES += pata.mod
+MARKER_FILES += pata.marker
+CLEANFILES += pata.marker
+
+pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += pata.module
+MODULE_FILES += pata.module$(EXEEXT)
+pata_module_SOURCES = disk/pata.c ## platform sources
+nodist_pata_module_SOURCES = ## platform nodist sources
+pata_module_LDADD =
+pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pata_module_SOURCES)
+CLEANFILES += $(nodist_pata_module_SOURCES)
+MOD_FILES += pata.mod
+MARKER_FILES += pata.marker
+CLEANFILES += pata.marker
+
+pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += pata.module
+MODULE_FILES += pata.module$(EXEEXT)
+pata_module_SOURCES = disk/pata.c ## platform sources
+nodist_pata_module_SOURCES = ## platform nodist sources
+pata_module_LDADD =
+pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pata_module_SOURCES)
+CLEANFILES += $(nodist_pata_module_SOURCES)
+MOD_FILES += pata.mod
+MARKER_FILES += pata.marker
+CLEANFILES += pata.marker
+
+pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += pata.module
+MODULE_FILES += pata.module$(EXEEXT)
+pata_module_SOURCES = disk/pata.c ## platform sources
+nodist_pata_module_SOURCES = ## platform nodist sources
+pata_module_LDADD =
+pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pata_module_SOURCES)
+CLEANFILES += $(nodist_pata_module_SOURCES)
+MOD_FILES += pata.mod
+MARKER_FILES += pata.marker
+CLEANFILES += pata.marker
+
+pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += pata.module
+MODULE_FILES += pata.module$(EXEEXT)
+pata_module_SOURCES = disk/pata.c ## platform sources
+nodist_pata_module_SOURCES = ## platform nodist sources
+pata_module_LDADD =
+pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pata_module_SOURCES)
+CLEANFILES += $(nodist_pata_module_SOURCES)
+MOD_FILES += pata.mod
+MARKER_FILES += pata.marker
+CLEANFILES += pata.marker
+
+pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += pata.module
+MODULE_FILES += pata.module$(EXEEXT)
+pata_module_SOURCES = disk/pata.c ## platform sources
+nodist_pata_module_SOURCES = ## platform nodist sources
+pata_module_LDADD =
+pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pata_module_SOURCES)
+CLEANFILES += $(nodist_pata_module_SOURCES)
+MOD_FILES += pata.mod
+MARKER_FILES += pata.marker
+CLEANFILES += pata.marker
+
+pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += pata.module
+MODULE_FILES += pata.module$(EXEEXT)
+pata_module_SOURCES = disk/pata.c ## platform sources
+nodist_pata_module_SOURCES = ## platform nodist sources
+pata_module_LDADD =
+pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pata_module_SOURCES)
+CLEANFILES += $(nodist_pata_module_SOURCES)
+MOD_FILES += pata.mod
+MARKER_FILES += pata.marker
+CLEANFILES += pata.marker
+
+pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += pata.module
+MODULE_FILES += pata.module$(EXEEXT)
+pata_module_SOURCES = disk/pata.c ## platform sources
+nodist_pata_module_SOURCES = ## platform nodist sources
+pata_module_LDADD =
+pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pata_module_SOURCES)
+CLEANFILES += $(nodist_pata_module_SOURCES)
+MOD_FILES += pata.mod
+MARKER_FILES += pata.marker
+CLEANFILES += pata.marker
+
+pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += pata.module
+MODULE_FILES += pata.module$(EXEEXT)
+pata_module_SOURCES = disk/pata.c ## platform sources
+nodist_pata_module_SOURCES = ## platform nodist sources
+pata_module_LDADD =
+pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pata_module_SOURCES)
+CLEANFILES += $(nodist_pata_module_SOURCES)
+MOD_FILES += pata.mod
+MARKER_FILES += pata.marker
+CLEANFILES += pata.marker
+
+pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += biosdisk.module
+MODULE_FILES += biosdisk.module$(EXEEXT)
+biosdisk_module_SOURCES = disk/i386/pc/biosdisk.c ## platform sources
+nodist_biosdisk_module_SOURCES = ## platform nodist sources
+biosdisk_module_LDADD =
+biosdisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+biosdisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+biosdisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+biosdisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+biosdisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_biosdisk_module_SOURCES)
+CLEANFILES += $(nodist_biosdisk_module_SOURCES)
+MOD_FILES += biosdisk.mod
+MARKER_FILES += biosdisk.marker
+CLEANFILES += biosdisk.marker
+
+biosdisk.marker: $(biosdisk_module_SOURCES) $(nodist_biosdisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(biosdisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += usbms.module
+MODULE_FILES += usbms.module$(EXEEXT)
+usbms_module_SOURCES = disk/usbms.c ## platform sources
+nodist_usbms_module_SOURCES = ## platform nodist sources
+usbms_module_LDADD =
+usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbms_module_SOURCES)
+CLEANFILES += $(nodist_usbms_module_SOURCES)
+MOD_FILES += usbms.mod
+MARKER_FILES += usbms.marker
+CLEANFILES += usbms.marker
+
+usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += usbms.module
+MODULE_FILES += usbms.module$(EXEEXT)
+usbms_module_SOURCES = disk/usbms.c ## platform sources
+nodist_usbms_module_SOURCES = ## platform nodist sources
+usbms_module_LDADD =
+usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbms_module_SOURCES)
+CLEANFILES += $(nodist_usbms_module_SOURCES)
+MOD_FILES += usbms.mod
+MARKER_FILES += usbms.marker
+CLEANFILES += usbms.marker
+
+usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += usbms.module
+MODULE_FILES += usbms.module$(EXEEXT)
+usbms_module_SOURCES = disk/usbms.c ## platform sources
+nodist_usbms_module_SOURCES = ## platform nodist sources
+usbms_module_LDADD =
+usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbms_module_SOURCES)
+CLEANFILES += $(nodist_usbms_module_SOURCES)
+MOD_FILES += usbms.mod
+MARKER_FILES += usbms.marker
+CLEANFILES += usbms.marker
+
+usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += usbms.module
+MODULE_FILES += usbms.module$(EXEEXT)
+usbms_module_SOURCES = disk/usbms.c ## platform sources
+nodist_usbms_module_SOURCES = ## platform nodist sources
+usbms_module_LDADD =
+usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbms_module_SOURCES)
+CLEANFILES += $(nodist_usbms_module_SOURCES)
+MOD_FILES += usbms.mod
+MARKER_FILES += usbms.marker
+CLEANFILES += usbms.marker
+
+usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += usbms.module
+MODULE_FILES += usbms.module$(EXEEXT)
+usbms_module_SOURCES = disk/usbms.c ## platform sources
+nodist_usbms_module_SOURCES = ## platform nodist sources
+usbms_module_LDADD =
+usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbms_module_SOURCES)
+CLEANFILES += $(nodist_usbms_module_SOURCES)
+MOD_FILES += usbms.mod
+MARKER_FILES += usbms.marker
+CLEANFILES += usbms.marker
+
+usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += usbms.module
+MODULE_FILES += usbms.module$(EXEEXT)
+usbms_module_SOURCES = disk/usbms.c ## platform sources
+nodist_usbms_module_SOURCES = ## platform nodist sources
+usbms_module_LDADD =
+usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbms_module_SOURCES)
+CLEANFILES += $(nodist_usbms_module_SOURCES)
+MOD_FILES += usbms.mod
+MARKER_FILES += usbms.marker
+CLEANFILES += usbms.marker
+
+usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += usbms.module
+MODULE_FILES += usbms.module$(EXEEXT)
+usbms_module_SOURCES = disk/usbms.c ## platform sources
+nodist_usbms_module_SOURCES = ## platform nodist sources
+usbms_module_LDADD =
+usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbms_module_SOURCES)
+CLEANFILES += $(nodist_usbms_module_SOURCES)
+MOD_FILES += usbms.mod
+MARKER_FILES += usbms.marker
+CLEANFILES += usbms.marker
+
+usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += usbms.module
+MODULE_FILES += usbms.module$(EXEEXT)
+usbms_module_SOURCES = disk/usbms.c ## platform sources
+nodist_usbms_module_SOURCES = ## platform nodist sources
+usbms_module_LDADD =
+usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbms_module_SOURCES)
+CLEANFILES += $(nodist_usbms_module_SOURCES)
+MOD_FILES += usbms.mod
+MARKER_FILES += usbms.marker
+CLEANFILES += usbms.marker
+
+usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += usbms.module
+MODULE_FILES += usbms.module$(EXEEXT)
+usbms_module_SOURCES = disk/usbms.c ## platform sources
+nodist_usbms_module_SOURCES = ## platform nodist sources
+usbms_module_LDADD =
+usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usbms_module_SOURCES)
+CLEANFILES += $(nodist_usbms_module_SOURCES)
+MOD_FILES += usbms.mod
+MARKER_FILES += usbms.marker
+CLEANFILES += usbms.marker
+
+usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += nand.module
+MODULE_FILES += nand.module$(EXEEXT)
+nand_module_SOURCES = disk/ieee1275/nand.c ## platform sources
+nodist_nand_module_SOURCES = ## platform nodist sources
+nand_module_LDADD =
+nand_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nand_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nand_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nand_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nand_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nand_module_SOURCES)
+CLEANFILES += $(nodist_nand_module_SOURCES)
+MOD_FILES += nand.mod
+MARKER_FILES += nand.marker
+CLEANFILES += nand.marker
+
+nand.marker: $(nand_module_SOURCES) $(nodist_nand_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nand_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += efiemu.module
+MODULE_FILES += efiemu.module$(EXEEXT)
+efiemu_module_SOURCES = efiemu/i386/pc/cfgtables.c efiemu/main.c efiemu/i386/loadcore32.c efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c efiemu/i386/coredetect.c ## platform sources
+nodist_efiemu_module_SOURCES = ## platform nodist sources
+efiemu_module_LDADD =
+efiemu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efiemu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efiemu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efiemu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efiemu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += efiemu/prepare.c efiemu/loadcore.c efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c
+BUILT_SOURCES += $(nodist_efiemu_module_SOURCES)
+CLEANFILES += $(nodist_efiemu_module_SOURCES)
+MOD_FILES += efiemu.mod
+MARKER_FILES += efiemu.marker
+CLEANFILES += efiemu.marker
+
+efiemu.marker: $(efiemu_module_SOURCES) $(nodist_efiemu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += efiemu.module
+MODULE_FILES += efiemu.module$(EXEEXT)
+efiemu_module_SOURCES = efiemu/i386/nocfgtables.c efiemu/main.c efiemu/i386/loadcore32.c efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c efiemu/i386/coredetect.c ## platform sources
+nodist_efiemu_module_SOURCES = ## platform nodist sources
+efiemu_module_LDADD =
+efiemu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efiemu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efiemu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efiemu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efiemu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += efiemu/prepare.c efiemu/loadcore.c efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c
+BUILT_SOURCES += $(nodist_efiemu_module_SOURCES)
+CLEANFILES += $(nodist_efiemu_module_SOURCES)
+MOD_FILES += efiemu.mod
+MARKER_FILES += efiemu.marker
+CLEANFILES += efiemu.marker
+
+efiemu.marker: $(efiemu_module_SOURCES) $(nodist_efiemu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += efiemu.module
+MODULE_FILES += efiemu.module$(EXEEXT)
+efiemu_module_SOURCES = efiemu/i386/pc/cfgtables.c efiemu/main.c efiemu/i386/loadcore32.c efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c efiemu/i386/coredetect.c ## platform sources
+nodist_efiemu_module_SOURCES = ## platform nodist sources
+efiemu_module_LDADD =
+efiemu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efiemu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efiemu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efiemu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efiemu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += efiemu/prepare.c efiemu/loadcore.c efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c
+BUILT_SOURCES += $(nodist_efiemu_module_SOURCES)
+CLEANFILES += $(nodist_efiemu_module_SOURCES)
+MOD_FILES += efiemu.mod
+MARKER_FILES += efiemu.marker
+CLEANFILES += efiemu.marker
+
+efiemu.marker: $(efiemu_module_SOURCES) $(nodist_efiemu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += efiemu.module
+MODULE_FILES += efiemu.module$(EXEEXT)
+efiemu_module_SOURCES = efiemu/i386/pc/cfgtables.c efiemu/main.c efiemu/i386/loadcore32.c efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c efiemu/i386/coredetect.c ## platform sources
+nodist_efiemu_module_SOURCES = ## platform nodist sources
+efiemu_module_LDADD =
+efiemu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efiemu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efiemu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efiemu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efiemu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += efiemu/prepare.c efiemu/loadcore.c efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c
+BUILT_SOURCES += $(nodist_efiemu_module_SOURCES)
+CLEANFILES += $(nodist_efiemu_module_SOURCES)
+MOD_FILES += efiemu.mod
+MARKER_FILES += efiemu.marker
+CLEANFILES += efiemu.marker
+
+efiemu.marker: $(efiemu_module_SOURCES) $(nodist_efiemu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += efiemu.module
+MODULE_FILES += efiemu.module$(EXEEXT)
+efiemu_module_SOURCES = efiemu/i386/nocfgtables.c efiemu/main.c efiemu/i386/loadcore32.c efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c efiemu/i386/coredetect.c ## platform sources
+nodist_efiemu_module_SOURCES = ## platform nodist sources
+efiemu_module_LDADD =
+efiemu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efiemu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efiemu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efiemu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efiemu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += efiemu/prepare.c efiemu/loadcore.c efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c
+BUILT_SOURCES += $(nodist_efiemu_module_SOURCES)
+CLEANFILES += $(nodist_efiemu_module_SOURCES)
+MOD_FILES += efiemu.mod
+MARKER_FILES += efiemu.marker
+CLEANFILES += efiemu.marker
+
+efiemu.marker: $(efiemu_module_SOURCES) $(nodist_efiemu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += font.module
+MODULE_FILES += font.module$(EXEEXT)
+font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+nodist_font_module_SOURCES = ## platform nodist sources
+font_module_LDADD =
+font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_font_module_SOURCES)
+CLEANFILES += $(nodist_font_module_SOURCES)
+MOD_FILES += font.mod
+MARKER_FILES += font.marker
+CLEANFILES += font.marker
+
+font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += procfs.module
+MODULE_FILES += procfs.module$(EXEEXT)
+procfs_module_SOURCES = fs/proc.c ## platform sources
+nodist_procfs_module_SOURCES = ## platform nodist sources
+procfs_module_LDADD =
+procfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+procfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+procfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+procfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+procfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_procfs_module_SOURCES)
+CLEANFILES += $(nodist_procfs_module_SOURCES)
+MOD_FILES += procfs.mod
+MARKER_FILES += procfs.marker
+CLEANFILES += procfs.marker
+
+procfs.marker: $(procfs_module_SOURCES) $(nodist_procfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(procfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += affs.module
+MODULE_FILES += affs.module$(EXEEXT)
+affs_module_SOURCES = fs/affs.c ## platform sources
+nodist_affs_module_SOURCES = ## platform nodist sources
+affs_module_LDADD =
+affs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+affs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+affs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+affs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+affs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_affs_module_SOURCES)
+CLEANFILES += $(nodist_affs_module_SOURCES)
+MOD_FILES += affs.mod
+MARKER_FILES += affs.marker
+CLEANFILES += affs.marker
+
+affs.marker: $(affs_module_SOURCES) $(nodist_affs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(affs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += afs.module
+MODULE_FILES += afs.module$(EXEEXT)
+afs_module_SOURCES = fs/afs.c ## platform sources
+nodist_afs_module_SOURCES = ## platform nodist sources
+afs_module_LDADD =
+afs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+afs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+afs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+afs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+afs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_afs_module_SOURCES)
+CLEANFILES += $(nodist_afs_module_SOURCES)
+MOD_FILES += afs.mod
+MARKER_FILES += afs.marker
+CLEANFILES += afs.marker
+
+afs.marker: $(afs_module_SOURCES) $(nodist_afs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += bfs.module
+MODULE_FILES += bfs.module$(EXEEXT)
+bfs_module_SOURCES = fs/bfs.c ## platform sources
+nodist_bfs_module_SOURCES = ## platform nodist sources
+bfs_module_LDADD =
+bfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bfs_module_SOURCES)
+CLEANFILES += $(nodist_bfs_module_SOURCES)
+MOD_FILES += bfs.mod
+MARKER_FILES += bfs.marker
+CLEANFILES += bfs.marker
+
+bfs.marker: $(bfs_module_SOURCES) $(nodist_bfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += zstd.module
+MODULE_FILES += zstd.module$(EXEEXT)
+zstd_module_SOURCES = lib/zstd/debug.c lib/zstd/entropy_common.c lib/zstd/error_private.c lib/zstd/fse_decompress.c lib/zstd/huf_decompress.c lib/zstd/module.c lib/zstd/xxhash.c lib/zstd/zstd_common.c lib/zstd/zstd_decompress.c ## platform sources
+nodist_zstd_module_SOURCES = ## platform nodist sources
+zstd_module_LDADD =
+zstd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) -Wno-undef
+zstd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+zstd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/zstd
+zstd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+zstd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_zstd_module_SOURCES)
+CLEANFILES += $(nodist_zstd_module_SOURCES)
+MOD_FILES += zstd.mod
+MARKER_FILES += zstd.marker
+CLEANFILES += zstd.marker
+
+zstd.marker: $(zstd_module_SOURCES) $(nodist_zstd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += btrfs.module
+MODULE_FILES += btrfs.module$(EXEEXT)
+btrfs_module_SOURCES = fs/btrfs.c lib/crc.c ## platform sources
+nodist_btrfs_module_SOURCES = ## platform nodist sources
+btrfs_module_LDADD =
+btrfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) -Wno-undef
+btrfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+btrfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -I$(srcdir)/lib/zstd -DMINILZO_HAVE_CONFIG_H
+btrfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+btrfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_btrfs_module_SOURCES)
+CLEANFILES += $(nodist_btrfs_module_SOURCES)
+MOD_FILES += btrfs.mod
+MARKER_FILES += btrfs.marker
+CLEANFILES += btrfs.marker
+
+btrfs.marker: $(btrfs_module_SOURCES) $(nodist_btrfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(btrfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += archelp.module
+MODULE_FILES += archelp.module$(EXEEXT)
+archelp_module_SOURCES = fs/archelp.c ## platform sources
+nodist_archelp_module_SOURCES = ## platform nodist sources
+archelp_module_LDADD =
+archelp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+archelp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+archelp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+archelp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+archelp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_archelp_module_SOURCES)
+CLEANFILES += $(nodist_archelp_module_SOURCES)
+MOD_FILES += archelp.mod
+MARKER_FILES += archelp.marker
+CLEANFILES += archelp.marker
+
+archelp.marker: $(archelp_module_SOURCES) $(nodist_archelp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(archelp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += cbfs.module
+MODULE_FILES += cbfs.module$(EXEEXT)
+cbfs_module_SOURCES = fs/cbfs.c ## platform sources
+nodist_cbfs_module_SOURCES = ## platform nodist sources
+cbfs_module_LDADD =
+cbfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cbfs_module_SOURCES)
+CLEANFILES += $(nodist_cbfs_module_SOURCES)
+MOD_FILES += cbfs.mod
+MARKER_FILES += cbfs.marker
+CLEANFILES += cbfs.marker
+
+cbfs.marker: $(cbfs_module_SOURCES) $(nodist_cbfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += cpio.module
+MODULE_FILES += cpio.module$(EXEEXT)
+cpio_module_SOURCES = fs/cpio.c ## platform sources
+nodist_cpio_module_SOURCES = ## platform nodist sources
+cpio_module_LDADD =
+cpio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpio_module_SOURCES)
+CLEANFILES += $(nodist_cpio_module_SOURCES)
+MOD_FILES += cpio.mod
+MARKER_FILES += cpio.marker
+CLEANFILES += cpio.marker
+
+cpio.marker: $(cpio_module_SOURCES) $(nodist_cpio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += cpio_be.module
+MODULE_FILES += cpio_be.module$(EXEEXT)
+cpio_be_module_SOURCES = fs/cpio_be.c ## platform sources
+nodist_cpio_be_module_SOURCES = ## platform nodist sources
+cpio_be_module_LDADD =
+cpio_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpio_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpio_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpio_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpio_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cpio_be_module_SOURCES)
+CLEANFILES += $(nodist_cpio_be_module_SOURCES)
+MOD_FILES += cpio_be.mod
+MARKER_FILES += cpio_be.marker
+CLEANFILES += cpio_be.marker
+
+cpio_be.marker: $(cpio_be_module_SOURCES) $(nodist_cpio_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += newc.module
+MODULE_FILES += newc.module$(EXEEXT)
+newc_module_SOURCES = fs/newc.c ## platform sources
+nodist_newc_module_SOURCES = ## platform nodist sources
+newc_module_LDADD =
+newc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+newc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+newc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+newc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+newc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_newc_module_SOURCES)
+CLEANFILES += $(nodist_newc_module_SOURCES)
+MOD_FILES += newc.mod
+MARKER_FILES += newc.marker
+CLEANFILES += newc.marker
+
+newc.marker: $(newc_module_SOURCES) $(nodist_newc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(newc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += odc.module
+MODULE_FILES += odc.module$(EXEEXT)
+odc_module_SOURCES = fs/odc.c ## platform sources
+nodist_odc_module_SOURCES = ## platform nodist sources
+odc_module_LDADD =
+odc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+odc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+odc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+odc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+odc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_odc_module_SOURCES)
+CLEANFILES += $(nodist_odc_module_SOURCES)
+MOD_FILES += odc.mod
+MARKER_FILES += odc.marker
+CLEANFILES += odc.marker
+
+odc.marker: $(odc_module_SOURCES) $(nodist_odc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(odc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += ext2.module
+MODULE_FILES += ext2.module$(EXEEXT)
+ext2_module_SOURCES = fs/ext2.c ## platform sources
+nodist_ext2_module_SOURCES = ## platform nodist sources
+ext2_module_LDADD =
+ext2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ext2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ext2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ext2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ext2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ext2_module_SOURCES)
+CLEANFILES += $(nodist_ext2_module_SOURCES)
+MOD_FILES += ext2.mod
+MARKER_FILES += ext2.marker
+CLEANFILES += ext2.marker
+
+ext2.marker: $(ext2_module_SOURCES) $(nodist_ext2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ext2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += fat.module
+MODULE_FILES += fat.module$(EXEEXT)
+fat_module_SOURCES = fs/fat.c ## platform sources
+nodist_fat_module_SOURCES = ## platform nodist sources
+fat_module_LDADD =
+fat_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fat_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fat_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fat_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fat_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fat_module_SOURCES)
+CLEANFILES += $(nodist_fat_module_SOURCES)
+MOD_FILES += fat.mod
+MARKER_FILES += fat.marker
+CLEANFILES += fat.marker
+
+fat.marker: $(fat_module_SOURCES) $(nodist_fat_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fat_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += exfat.module
+MODULE_FILES += exfat.module$(EXEEXT)
+exfat_module_SOURCES = fs/exfat.c ## platform sources
+nodist_exfat_module_SOURCES = ## platform nodist sources
+exfat_module_LDADD =
+exfat_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+exfat_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+exfat_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+exfat_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+exfat_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_exfat_module_SOURCES)
+CLEANFILES += $(nodist_exfat_module_SOURCES)
+MOD_FILES += exfat.mod
+MARKER_FILES += exfat.marker
+CLEANFILES += exfat.marker
+
+exfat.marker: $(exfat_module_SOURCES) $(nodist_exfat_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfat_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += f2fs.module
+MODULE_FILES += f2fs.module$(EXEEXT)
+f2fs_module_SOURCES = fs/f2fs.c ## platform sources
+nodist_f2fs_module_SOURCES = ## platform nodist sources
+f2fs_module_LDADD =
+f2fs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+f2fs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+f2fs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+f2fs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+f2fs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_f2fs_module_SOURCES)
+CLEANFILES += $(nodist_f2fs_module_SOURCES)
+MOD_FILES += f2fs.mod
+MARKER_FILES += f2fs.marker
+CLEANFILES += f2fs.marker
+
+f2fs.marker: $(f2fs_module_SOURCES) $(nodist_f2fs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(f2fs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += fshelp.module
+MODULE_FILES += fshelp.module$(EXEEXT)
+fshelp_module_SOURCES = fs/fshelp.c ## platform sources
+nodist_fshelp_module_SOURCES = ## platform nodist sources
+fshelp_module_LDADD =
+fshelp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fshelp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fshelp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fshelp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fshelp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fshelp_module_SOURCES)
+CLEANFILES += $(nodist_fshelp_module_SOURCES)
+MOD_FILES += fshelp.mod
+MARKER_FILES += fshelp.marker
+CLEANFILES += fshelp.marker
+
+fshelp.marker: $(fshelp_module_SOURCES) $(nodist_fshelp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fshelp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += hfs.module
+MODULE_FILES += hfs.module$(EXEEXT)
+hfs_module_SOURCES = fs/hfs.c ## platform sources
+nodist_hfs_module_SOURCES = ## platform nodist sources
+hfs_module_LDADD =
+hfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hfs_module_SOURCES)
+CLEANFILES += $(nodist_hfs_module_SOURCES)
+MOD_FILES += hfs.mod
+MARKER_FILES += hfs.marker
+CLEANFILES += hfs.marker
+
+hfs.marker: $(hfs_module_SOURCES) $(nodist_hfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += hfsplus.module
+MODULE_FILES += hfsplus.module$(EXEEXT)
+hfsplus_module_SOURCES = fs/hfsplus.c ## platform sources
+nodist_hfsplus_module_SOURCES = ## platform nodist sources
+hfsplus_module_LDADD =
+hfsplus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hfsplus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hfsplus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hfsplus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hfsplus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hfsplus_module_SOURCES)
+CLEANFILES += $(nodist_hfsplus_module_SOURCES)
+MOD_FILES += hfsplus.mod
+MARKER_FILES += hfsplus.marker
+CLEANFILES += hfsplus.marker
+
+hfsplus.marker: $(hfsplus_module_SOURCES) $(nodist_hfsplus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfsplus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += hfspluscomp.module
+MODULE_FILES += hfspluscomp.module$(EXEEXT)
+hfspluscomp_module_SOURCES = fs/hfspluscomp.c ## platform sources
+nodist_hfspluscomp_module_SOURCES = ## platform nodist sources
+hfspluscomp_module_LDADD =
+hfspluscomp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hfspluscomp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hfspluscomp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hfspluscomp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hfspluscomp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hfspluscomp_module_SOURCES)
+CLEANFILES += $(nodist_hfspluscomp_module_SOURCES)
+MOD_FILES += hfspluscomp.mod
+MARKER_FILES += hfspluscomp.marker
+CLEANFILES += hfspluscomp.marker
+
+hfspluscomp.marker: $(hfspluscomp_module_SOURCES) $(nodist_hfspluscomp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfspluscomp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += iso9660.module
+MODULE_FILES += iso9660.module$(EXEEXT)
+iso9660_module_SOURCES = fs/iso9660.c ## platform sources
+nodist_iso9660_module_SOURCES = ## platform nodist sources
+iso9660_module_LDADD =
+iso9660_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+iso9660_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+iso9660_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+iso9660_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+iso9660_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_iso9660_module_SOURCES)
+CLEANFILES += $(nodist_iso9660_module_SOURCES)
+MOD_FILES += iso9660.mod
+MARKER_FILES += iso9660.marker
+CLEANFILES += iso9660.marker
+
+iso9660.marker: $(iso9660_module_SOURCES) $(nodist_iso9660_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iso9660_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += jfs.module
+MODULE_FILES += jfs.module$(EXEEXT)
+jfs_module_SOURCES = fs/jfs.c ## platform sources
+nodist_jfs_module_SOURCES = ## platform nodist sources
+jfs_module_LDADD =
+jfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+jfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+jfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+jfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+jfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_jfs_module_SOURCES)
+CLEANFILES += $(nodist_jfs_module_SOURCES)
+MOD_FILES += jfs.mod
+MARKER_FILES += jfs.marker
+CLEANFILES += jfs.marker
+
+jfs.marker: $(jfs_module_SOURCES) $(nodist_jfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += minix.module
+MODULE_FILES += minix.module$(EXEEXT)
+minix_module_SOURCES = fs/minix.c ## platform sources
+nodist_minix_module_SOURCES = ## platform nodist sources
+minix_module_LDADD =
+minix_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_minix_module_SOURCES)
+CLEANFILES += $(nodist_minix_module_SOURCES)
+MOD_FILES += minix.mod
+MARKER_FILES += minix.marker
+CLEANFILES += minix.marker
+
+minix.marker: $(minix_module_SOURCES) $(nodist_minix_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += minix2.module
+MODULE_FILES += minix2.module$(EXEEXT)
+minix2_module_SOURCES = fs/minix2.c ## platform sources
+nodist_minix2_module_SOURCES = ## platform nodist sources
+minix2_module_LDADD =
+minix2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_minix2_module_SOURCES)
+CLEANFILES += $(nodist_minix2_module_SOURCES)
+MOD_FILES += minix2.mod
+MARKER_FILES += minix2.marker
+CLEANFILES += minix2.marker
+
+minix2.marker: $(minix2_module_SOURCES) $(nodist_minix2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += minix3.module
+MODULE_FILES += minix3.module$(EXEEXT)
+minix3_module_SOURCES = fs/minix3.c ## platform sources
+nodist_minix3_module_SOURCES = ## platform nodist sources
+minix3_module_LDADD =
+minix3_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix3_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix3_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix3_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix3_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_minix3_module_SOURCES)
+CLEANFILES += $(nodist_minix3_module_SOURCES)
+MOD_FILES += minix3.mod
+MARKER_FILES += minix3.marker
+CLEANFILES += minix3.marker
+
+minix3.marker: $(minix3_module_SOURCES) $(nodist_minix3_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += minix_be.module
+MODULE_FILES += minix_be.module$(EXEEXT)
+minix_be_module_SOURCES = fs/minix_be.c ## platform sources
+nodist_minix_be_module_SOURCES = ## platform nodist sources
+minix_be_module_LDADD =
+minix_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_minix_be_module_SOURCES)
+CLEANFILES += $(nodist_minix_be_module_SOURCES)
+MOD_FILES += minix_be.mod
+MARKER_FILES += minix_be.marker
+CLEANFILES += minix_be.marker
+
+minix_be.marker: $(minix_be_module_SOURCES) $(nodist_minix_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += minix2_be.module
+MODULE_FILES += minix2_be.module$(EXEEXT)
+minix2_be_module_SOURCES = fs/minix2_be.c ## platform sources
+nodist_minix2_be_module_SOURCES = ## platform nodist sources
+minix2_be_module_LDADD =
+minix2_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix2_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix2_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix2_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix2_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_minix2_be_module_SOURCES)
+CLEANFILES += $(nodist_minix2_be_module_SOURCES)
+MOD_FILES += minix2_be.mod
+MARKER_FILES += minix2_be.marker
+CLEANFILES += minix2_be.marker
+
+minix2_be.marker: $(minix2_be_module_SOURCES) $(nodist_minix2_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += minix3_be.module
+MODULE_FILES += minix3_be.module$(EXEEXT)
+minix3_be_module_SOURCES = fs/minix3_be.c ## platform sources
+nodist_minix3_be_module_SOURCES = ## platform nodist sources
+minix3_be_module_LDADD =
+minix3_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix3_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix3_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix3_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix3_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_minix3_be_module_SOURCES)
+CLEANFILES += $(nodist_minix3_be_module_SOURCES)
+MOD_FILES += minix3_be.mod
+MARKER_FILES += minix3_be.marker
+CLEANFILES += minix3_be.marker
+
+minix3_be.marker: $(minix3_be_module_SOURCES) $(nodist_minix3_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += nilfs2.module
+MODULE_FILES += nilfs2.module$(EXEEXT)
+nilfs2_module_SOURCES = fs/nilfs2.c ## platform sources
+nodist_nilfs2_module_SOURCES = ## platform nodist sources
+nilfs2_module_LDADD =
+nilfs2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nilfs2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nilfs2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nilfs2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nilfs2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_nilfs2_module_SOURCES)
+CLEANFILES += $(nodist_nilfs2_module_SOURCES)
+MOD_FILES += nilfs2.mod
+MARKER_FILES += nilfs2.marker
+CLEANFILES += nilfs2.marker
+
+nilfs2.marker: $(nilfs2_module_SOURCES) $(nodist_nilfs2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nilfs2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += ntfs.module
+MODULE_FILES += ntfs.module$(EXEEXT)
+ntfs_module_SOURCES = fs/ntfs.c ## platform sources
+nodist_ntfs_module_SOURCES = ## platform nodist sources
+ntfs_module_LDADD =
+ntfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ntfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ntfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ntfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ntfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ntfs_module_SOURCES)
+CLEANFILES += $(nodist_ntfs_module_SOURCES)
+MOD_FILES += ntfs.mod
+MARKER_FILES += ntfs.marker
+CLEANFILES += ntfs.marker
+
+ntfs.marker: $(ntfs_module_SOURCES) $(nodist_ntfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += ntfscomp.module
+MODULE_FILES += ntfscomp.module$(EXEEXT)
+ntfscomp_module_SOURCES = fs/ntfscomp.c ## platform sources
+nodist_ntfscomp_module_SOURCES = ## platform nodist sources
+ntfscomp_module_LDADD =
+ntfscomp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ntfscomp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ntfscomp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ntfscomp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ntfscomp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ntfscomp_module_SOURCES)
+CLEANFILES += $(nodist_ntfscomp_module_SOURCES)
+MOD_FILES += ntfscomp.mod
+MARKER_FILES += ntfscomp.marker
+CLEANFILES += ntfscomp.marker
+
+ntfscomp.marker: $(ntfscomp_module_SOURCES) $(nodist_ntfscomp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfscomp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += reiserfs.module
+MODULE_FILES += reiserfs.module$(EXEEXT)
+reiserfs_module_SOURCES = fs/reiserfs.c ## platform sources
+nodist_reiserfs_module_SOURCES = ## platform nodist sources
+reiserfs_module_LDADD =
+reiserfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reiserfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reiserfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reiserfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reiserfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_reiserfs_module_SOURCES)
+CLEANFILES += $(nodist_reiserfs_module_SOURCES)
+MOD_FILES += reiserfs.mod
+MARKER_FILES += reiserfs.marker
+CLEANFILES += reiserfs.marker
+
+reiserfs.marker: $(reiserfs_module_SOURCES) $(nodist_reiserfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reiserfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += romfs.module
+MODULE_FILES += romfs.module$(EXEEXT)
+romfs_module_SOURCES = fs/romfs.c ## platform sources
+nodist_romfs_module_SOURCES = ## platform nodist sources
+romfs_module_LDADD =
+romfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+romfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+romfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+romfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+romfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_romfs_module_SOURCES)
+CLEANFILES += $(nodist_romfs_module_SOURCES)
+MOD_FILES += romfs.mod
+MARKER_FILES += romfs.marker
+CLEANFILES += romfs.marker
+
+romfs.marker: $(romfs_module_SOURCES) $(nodist_romfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(romfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += sfs.module
+MODULE_FILES += sfs.module$(EXEEXT)
+sfs_module_SOURCES = fs/sfs.c ## platform sources
+nodist_sfs_module_SOURCES = ## platform nodist sources
+sfs_module_LDADD =
+sfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+sfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+sfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+sfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+sfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_sfs_module_SOURCES)
+CLEANFILES += $(nodist_sfs_module_SOURCES)
+MOD_FILES += sfs.mod
+MARKER_FILES += sfs.marker
+CLEANFILES += sfs.marker
+
+sfs.marker: $(sfs_module_SOURCES) $(nodist_sfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += squash4.module
+MODULE_FILES += squash4.module$(EXEEXT)
+squash4_module_SOURCES = fs/squash4.c ## platform sources
+nodist_squash4_module_SOURCES = ## platform nodist sources
+squash4_module_LDADD =
+squash4_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) -Wno-undef
+squash4_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+squash4_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H
+squash4_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+squash4_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_squash4_module_SOURCES)
+CLEANFILES += $(nodist_squash4_module_SOURCES)
+MOD_FILES += squash4.mod
+MARKER_FILES += squash4.marker
+CLEANFILES += squash4.marker
+
+squash4.marker: $(squash4_module_SOURCES) $(nodist_squash4_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(squash4_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += tar.module
+MODULE_FILES += tar.module$(EXEEXT)
+tar_module_SOURCES = fs/tar.c ## platform sources
+nodist_tar_module_SOURCES = ## platform nodist sources
+tar_module_LDADD =
+tar_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tar_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tar_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tar_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tar_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tar_module_SOURCES)
+CLEANFILES += $(nodist_tar_module_SOURCES)
+MOD_FILES += tar.mod
+MARKER_FILES += tar.marker
+CLEANFILES += tar.marker
+
+tar.marker: $(tar_module_SOURCES) $(nodist_tar_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tar_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += udf.module
+MODULE_FILES += udf.module$(EXEEXT)
+udf_module_SOURCES = fs/udf.c ## platform sources
+nodist_udf_module_SOURCES = ## platform nodist sources
+udf_module_LDADD =
+udf_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+udf_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+udf_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+udf_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+udf_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_udf_module_SOURCES)
+CLEANFILES += $(nodist_udf_module_SOURCES)
+MOD_FILES += udf.mod
+MARKER_FILES += udf.marker
+CLEANFILES += udf.marker
+
+udf.marker: $(udf_module_SOURCES) $(nodist_udf_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(udf_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += ufs1.module
+MODULE_FILES += ufs1.module$(EXEEXT)
+ufs1_module_SOURCES = fs/ufs.c ## platform sources
+nodist_ufs1_module_SOURCES = ## platform nodist sources
+ufs1_module_LDADD =
+ufs1_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ufs1_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ufs1_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ufs1_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ufs1_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ufs1_module_SOURCES)
+CLEANFILES += $(nodist_ufs1_module_SOURCES)
+MOD_FILES += ufs1.mod
+MARKER_FILES += ufs1.marker
+CLEANFILES += ufs1.marker
+
+ufs1.marker: $(ufs1_module_SOURCES) $(nodist_ufs1_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += ufs1_be.module
+MODULE_FILES += ufs1_be.module$(EXEEXT)
+ufs1_be_module_SOURCES = fs/ufs_be.c ## platform sources
+nodist_ufs1_be_module_SOURCES = ## platform nodist sources
+ufs1_be_module_LDADD =
+ufs1_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ufs1_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ufs1_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ufs1_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ufs1_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ufs1_be_module_SOURCES)
+CLEANFILES += $(nodist_ufs1_be_module_SOURCES)
+MOD_FILES += ufs1_be.mod
+MARKER_FILES += ufs1_be.marker
+CLEANFILES += ufs1_be.marker
+
+ufs1_be.marker: $(ufs1_be_module_SOURCES) $(nodist_ufs1_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += ufs2.module
+MODULE_FILES += ufs2.module$(EXEEXT)
+ufs2_module_SOURCES = fs/ufs2.c ## platform sources
+nodist_ufs2_module_SOURCES = ## platform nodist sources
+ufs2_module_LDADD =
+ufs2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ufs2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ufs2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ufs2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ufs2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ufs2_module_SOURCES)
+CLEANFILES += $(nodist_ufs2_module_SOURCES)
+MOD_FILES += ufs2.mod
+MARKER_FILES += ufs2.marker
+CLEANFILES += ufs2.marker
+
+ufs2.marker: $(ufs2_module_SOURCES) $(nodist_ufs2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += xfs.module
+MODULE_FILES += xfs.module$(EXEEXT)
+xfs_module_SOURCES = fs/xfs.c ## platform sources
+nodist_xfs_module_SOURCES = ## platform nodist sources
+xfs_module_LDADD =
+xfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xfs_module_SOURCES)
+CLEANFILES += $(nodist_xfs_module_SOURCES)
+MOD_FILES += xfs.mod
+MARKER_FILES += xfs.marker
+CLEANFILES += xfs.marker
+
+xfs.marker: $(xfs_module_SOURCES) $(nodist_xfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += zfs.module
+MODULE_FILES += zfs.module$(EXEEXT)
+zfs_module_SOURCES = fs/zfs/zfs.c fs/zfs/zfs_lzjb.c fs/zfs/zfs_lz4.c fs/zfs/zfs_sha256.c fs/zfs/zfs_fletcher.c ## platform sources
+nodist_zfs_module_SOURCES = ## platform nodist sources
+zfs_module_LDADD =
+zfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+zfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+zfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+zfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+zfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_zfs_module_SOURCES)
+CLEANFILES += $(nodist_zfs_module_SOURCES)
+MOD_FILES += zfs.mod
+MARKER_FILES += zfs.marker
+CLEANFILES += zfs.marker
+
+zfs.marker: $(zfs_module_SOURCES) $(nodist_zfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += zfscrypt.module
+MODULE_FILES += zfscrypt.module$(EXEEXT)
+zfscrypt_module_SOURCES = fs/zfs/zfscrypt.c ## platform sources
+nodist_zfscrypt_module_SOURCES = ## platform nodist sources
+zfscrypt_module_LDADD =
+zfscrypt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+zfscrypt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+zfscrypt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+zfscrypt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+zfscrypt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_zfscrypt_module_SOURCES)
+CLEANFILES += $(nodist_zfscrypt_module_SOURCES)
+MOD_FILES += zfscrypt.mod
+MARKER_FILES += zfscrypt.marker
+CLEANFILES += zfscrypt.marker
+
+zfscrypt.marker: $(zfscrypt_module_SOURCES) $(nodist_zfscrypt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfscrypt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += zfsinfo.module
+MODULE_FILES += zfsinfo.module$(EXEEXT)
+zfsinfo_module_SOURCES = fs/zfs/zfsinfo.c ## platform sources
+nodist_zfsinfo_module_SOURCES = ## platform nodist sources
+zfsinfo_module_LDADD =
+zfsinfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+zfsinfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+zfsinfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+zfsinfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+zfsinfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_zfsinfo_module_SOURCES)
+CLEANFILES += $(nodist_zfsinfo_module_SOURCES)
+MOD_FILES += zfsinfo.mod
+MARKER_FILES += zfsinfo.marker
+CLEANFILES += zfsinfo.marker
+
+zfsinfo.marker: $(zfsinfo_module_SOURCES) $(nodist_zfsinfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfsinfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += macbless.module
+MODULE_FILES += macbless.module$(EXEEXT)
+macbless_module_SOURCES = commands/macbless.c ## platform sources
+nodist_macbless_module_SOURCES = ## platform nodist sources
+macbless_module_LDADD =
+macbless_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+macbless_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+macbless_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+macbless_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+macbless_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_macbless_module_SOURCES)
+CLEANFILES += $(nodist_macbless_module_SOURCES)
+MOD_FILES += macbless.mod
+MARKER_FILES += macbless.marker
+CLEANFILES += macbless.marker
+
+macbless.marker: $(macbless_module_SOURCES) $(nodist_macbless_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macbless_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += pxe.module
+MODULE_FILES += pxe.module$(EXEEXT)
+pxe_module_SOURCES = net/drivers/i386/pc/pxe.c ## platform sources
+nodist_pxe_module_SOURCES = ## platform nodist sources
+pxe_module_LDADD =
+pxe_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pxe_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pxe_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pxe_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pxe_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pxe_module_SOURCES)
+CLEANFILES += $(nodist_pxe_module_SOURCES)
+MOD_FILES += pxe.mod
+MARKER_FILES += pxe.marker
+CLEANFILES += pxe.marker
+
+pxe.marker: $(pxe_module_SOURCES) $(nodist_pxe_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxe_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += gettext.module
+MODULE_FILES += gettext.module$(EXEEXT)
+gettext_module_SOURCES = gettext/gettext.c ## platform sources
+nodist_gettext_module_SOURCES = ## platform nodist sources
+gettext_module_LDADD =
+gettext_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gettext_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gettext_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gettext_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gettext_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gettext_module_SOURCES)
+CLEANFILES += $(nodist_gettext_module_SOURCES)
+MOD_FILES += gettext.mod
+MARKER_FILES += gettext.marker
+CLEANFILES += gettext.marker
+
+gettext.marker: $(gettext_module_SOURCES) $(nodist_gettext_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gettext_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gfxmenu.module
+MODULE_FILES += gfxmenu.module$(EXEEXT)
+gfxmenu_module_SOURCES = gfxmenu/gfxmenu.c gfxmenu/view.c gfxmenu/font.c gfxmenu/icon_manager.c gfxmenu/theme_loader.c gfxmenu/widget-box.c gfxmenu/gui_canvas.c gfxmenu/gui_circular_progress.c gfxmenu/gui_box.c gfxmenu/gui_label.c gfxmenu/gui_list.c gfxmenu/gui_image.c gfxmenu/gui_progress_bar.c gfxmenu/gui_util.c gfxmenu/gui_string_util.c ## platform sources
+nodist_gfxmenu_module_SOURCES = ## platform nodist sources
+gfxmenu_module_LDADD =
+gfxmenu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxmenu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxmenu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxmenu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxmenu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxmenu_module_SOURCES)
+CLEANFILES += $(nodist_gfxmenu_module_SOURCES)
+MOD_FILES += gfxmenu.mod
+MARKER_FILES += gfxmenu.marker
+CLEANFILES += gfxmenu.marker
+
+gfxmenu.marker: $(gfxmenu_module_SOURCES) $(nodist_gfxmenu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += hello.module
+MODULE_FILES += hello.module$(EXEEXT)
+hello_module_SOURCES = hello/hello.c ## platform sources
+nodist_hello_module_SOURCES = ## platform nodist sources
+hello_module_LDADD =
+hello_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hello_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hello_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hello_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hello_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_hello_module_SOURCES)
+CLEANFILES += $(nodist_hello_module_SOURCES)
+MOD_FILES += hello.mod
+MARKER_FILES += hello.marker
+CLEANFILES += hello.marker
+
+hello.marker: $(hello_module_SOURCES) $(nodist_hello_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hello_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gzio.module
+MODULE_FILES += gzio.module$(EXEEXT)
+gzio_module_SOURCES = io/gzio.c ## platform sources
+nodist_gzio_module_SOURCES = ## platform nodist sources
+gzio_module_LDADD =
+gzio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gzio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gzio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gzio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gzio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gzio_module_SOURCES)
+CLEANFILES += $(nodist_gzio_module_SOURCES)
+MOD_FILES += gzio.mod
+MARKER_FILES += gzio.marker
+CLEANFILES += gzio.marker
+
+gzio.marker: $(gzio_module_SOURCES) $(nodist_gzio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gzio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += offsetio.module
+MODULE_FILES += offsetio.module$(EXEEXT)
+offsetio_module_SOURCES = io/offset.c ## platform sources
+nodist_offsetio_module_SOURCES = ## platform nodist sources
+offsetio_module_LDADD =
+offsetio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+offsetio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+offsetio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+offsetio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+offsetio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_offsetio_module_SOURCES)
+CLEANFILES += $(nodist_offsetio_module_SOURCES)
+MOD_FILES += offsetio.mod
+MARKER_FILES += offsetio.marker
+CLEANFILES += offsetio.marker
+
+offsetio.marker: $(offsetio_module_SOURCES) $(nodist_offsetio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offsetio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_emu
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += bufio.module
+MODULE_FILES += bufio.module$(EXEEXT)
+bufio_module_SOURCES = io/bufio.c ## platform sources
+nodist_bufio_module_SOURCES = ## platform nodist sources
+bufio_module_LDADD =
+bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bufio_module_SOURCES)
+CLEANFILES += $(nodist_bufio_module_SOURCES)
+MOD_FILES += bufio.mod
+MARKER_FILES += bufio.marker
+CLEANFILES += bufio.marker
+
+bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += elf.module
+MODULE_FILES += elf.module$(EXEEXT)
+elf_module_SOURCES = kern/elf.c ## platform sources
+nodist_elf_module_SOURCES = ## platform nodist sources
+elf_module_LDADD =
+elf_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+elf_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+elf_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+elf_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+elf_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += kern/elfXX.c
+BUILT_SOURCES += $(nodist_elf_module_SOURCES)
+CLEANFILES += $(nodist_elf_module_SOURCES)
+MOD_FILES += elf.mod
+MARKER_FILES += elf.marker
+CLEANFILES += elf.marker
+
+elf.marker: $(elf_module_SOURCES) $(nodist_elf_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elf_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += crypto.module
+MODULE_FILES += crypto.module$(EXEEXT)
+crypto_module_SOURCES = lib/crypto.c ## platform sources
+nodist_crypto_module_SOURCES = ## platform nodist sources
+crypto_module_LDADD =
+crypto_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+crypto_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+crypto_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+crypto_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+crypto_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/libgcrypt-grub/cipher/crypto.lst
+BUILT_SOURCES += $(nodist_crypto_module_SOURCES)
+CLEANFILES += $(nodist_crypto_module_SOURCES)
+MOD_FILES += crypto.mod
+MARKER_FILES += crypto.marker
+CLEANFILES += crypto.marker
+
+crypto.marker: $(crypto_module_SOURCES) $(nodist_crypto_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crypto_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += pbkdf2.module
+MODULE_FILES += pbkdf2.module$(EXEEXT)
+pbkdf2_module_SOURCES = lib/pbkdf2.c ## platform sources
+nodist_pbkdf2_module_SOURCES = ## platform nodist sources
+pbkdf2_module_LDADD =
+pbkdf2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pbkdf2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pbkdf2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pbkdf2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pbkdf2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pbkdf2_module_SOURCES)
+CLEANFILES += $(nodist_pbkdf2_module_SOURCES)
+MOD_FILES += pbkdf2.mod
+MARKER_FILES += pbkdf2.marker
+CLEANFILES += pbkdf2.marker
+
+pbkdf2.marker: $(pbkdf2_module_SOURCES) $(nodist_pbkdf2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/efi/relocator.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/ieee1275/relocator.c lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/x86_64/efi/relocator.c lib/x86_64/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/efi/relocator.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/xen/relocator.S lib/xen/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/x86_64/relocator_asm.S lib/x86_64/xen/relocator.S lib/xen/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator_asm.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/mips/relocator_asm.S lib/mips/relocator.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/powerpc/relocator_asm.S lib/powerpc/relocator.c lib/ieee1275/relocator.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/mips/relocator_asm.S lib/mips/relocator.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += relocator.module
+MODULE_FILES += relocator.module$(EXEEXT)
+relocator_module_SOURCES = lib/mips/relocator_asm.S lib/mips/relocator.c lib/relocator.c ## platform sources
+nodist_relocator_module_SOURCES = ## platform nodist sources
+relocator_module_LDADD =
+relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+BUILT_SOURCES += $(nodist_relocator_module_SOURCES)
+CLEANFILES += $(nodist_relocator_module_SOURCES)
+MOD_FILES += relocator.mod
+MARKER_FILES += relocator.marker
+CLEANFILES += relocator.marker
+
+relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/xen/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/xen/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/xen/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/ieee1275/datetime.c lib/ieee1275/cmos.c lib/cmos_datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/ieee1275/datetime.c lib/ieee1275/cmos.c lib/cmos_datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/arc/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/dummy/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/dummy/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += datetime.module
+MODULE_FILES += datetime.module$(EXEEXT)
+datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+nodist_datetime_module_SOURCES = ## platform nodist sources
+datetime_module_LDADD =
+datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datetime_module_SOURCES)
+CLEANFILES += $(nodist_datetime_module_SOURCES)
+MOD_FILES += datetime.mod
+MARKER_FILES += datetime.marker
+CLEANFILES += datetime.marker
+
+datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += setjmp.module
+MODULE_FILES += setjmp.module$(EXEEXT)
+setjmp_module_SOURCES = lib/setjmp.S ## platform sources
+nodist_setjmp_module_SOURCES = ## platform nodist sources
+setjmp_module_LDADD =
+setjmp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setjmp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setjmp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setjmp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setjmp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += lib/i386/setjmp.S lib/mips/setjmp.S lib/x86_64/setjmp.S lib/sparc64/setjmp.S lib/powerpc/setjmp.S lib/ia64/setjmp.S lib/ia64/longjmp.S lib/arm/setjmp.S lib/arm64/setjmp.S lib/riscv/setjmp.S
+BUILT_SOURCES += $(nodist_setjmp_module_SOURCES)
+CLEANFILES += $(nodist_setjmp_module_SOURCES)
+MOD_FILES += setjmp.mod
+MARKER_FILES += setjmp.marker
+CLEANFILES += setjmp.marker
+
+setjmp.marker: $(setjmp_module_SOURCES) $(nodist_setjmp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += aout.module
+MODULE_FILES += aout.module$(EXEEXT)
+aout_module_SOURCES = loader/aout.c ## platform sources
+nodist_aout_module_SOURCES = ## platform nodist sources
+aout_module_LDADD =
+aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_aout_module_SOURCES)
+CLEANFILES += $(nodist_aout_module_SOURCES)
+MOD_FILES += aout.mod
+MARKER_FILES += aout.marker
+CLEANFILES += aout.marker
+
+aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += aout.module
+MODULE_FILES += aout.module$(EXEEXT)
+aout_module_SOURCES = loader/aout.c ## platform sources
+nodist_aout_module_SOURCES = ## platform nodist sources
+aout_module_LDADD =
+aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_aout_module_SOURCES)
+CLEANFILES += $(nodist_aout_module_SOURCES)
+MOD_FILES += aout.mod
+MARKER_FILES += aout.marker
+CLEANFILES += aout.marker
+
+aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += aout.module
+MODULE_FILES += aout.module$(EXEEXT)
+aout_module_SOURCES = loader/aout.c ## platform sources
+nodist_aout_module_SOURCES = ## platform nodist sources
+aout_module_LDADD =
+aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_aout_module_SOURCES)
+CLEANFILES += $(nodist_aout_module_SOURCES)
+MOD_FILES += aout.mod
+MARKER_FILES += aout.marker
+CLEANFILES += aout.marker
+
+aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += aout.module
+MODULE_FILES += aout.module$(EXEEXT)
+aout_module_SOURCES = loader/aout.c ## platform sources
+nodist_aout_module_SOURCES = ## platform nodist sources
+aout_module_LDADD =
+aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_aout_module_SOURCES)
+CLEANFILES += $(nodist_aout_module_SOURCES)
+MOD_FILES += aout.mod
+MARKER_FILES += aout.marker
+CLEANFILES += aout.marker
+
+aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += aout.module
+MODULE_FILES += aout.module$(EXEEXT)
+aout_module_SOURCES = loader/aout.c ## platform sources
+nodist_aout_module_SOURCES = ## platform nodist sources
+aout_module_LDADD =
+aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_aout_module_SOURCES)
+CLEANFILES += $(nodist_aout_module_SOURCES)
+MOD_FILES += aout.mod
+MARKER_FILES += aout.marker
+CLEANFILES += aout.marker
+
+aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += aout.module
+MODULE_FILES += aout.module$(EXEEXT)
+aout_module_SOURCES = loader/aout.c ## platform sources
+nodist_aout_module_SOURCES = ## platform nodist sources
+aout_module_LDADD =
+aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_aout_module_SOURCES)
+CLEANFILES += $(nodist_aout_module_SOURCES)
+MOD_FILES += aout.mod
+MARKER_FILES += aout.marker
+CLEANFILES += aout.marker
+
+aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += aout.module
+MODULE_FILES += aout.module$(EXEEXT)
+aout_module_SOURCES = loader/aout.c ## platform sources
+nodist_aout_module_SOURCES = ## platform nodist sources
+aout_module_LDADD =
+aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_aout_module_SOURCES)
+CLEANFILES += $(nodist_aout_module_SOURCES)
+MOD_FILES += aout.mod
+MARKER_FILES += aout.marker
+CLEANFILES += aout.marker
+
+aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += bsd.module
+MODULE_FILES += bsd.module$(EXEEXT)
+bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+nodist_bsd_module_SOURCES = ## platform nodist sources
+bsd_module_LDADD =
+bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+BUILT_SOURCES += $(nodist_bsd_module_SOURCES)
+CLEANFILES += $(nodist_bsd_module_SOURCES)
+MOD_FILES += bsd.mod
+MARKER_FILES += bsd.marker
+CLEANFILES += bsd.marker
+
+bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += bsd.module
+MODULE_FILES += bsd.module$(EXEEXT)
+bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+nodist_bsd_module_SOURCES = ## platform nodist sources
+bsd_module_LDADD =
+bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+BUILT_SOURCES += $(nodist_bsd_module_SOURCES)
+CLEANFILES += $(nodist_bsd_module_SOURCES)
+MOD_FILES += bsd.mod
+MARKER_FILES += bsd.marker
+CLEANFILES += bsd.marker
+
+bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += bsd.module
+MODULE_FILES += bsd.module$(EXEEXT)
+bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+nodist_bsd_module_SOURCES = ## platform nodist sources
+bsd_module_LDADD =
+bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+BUILT_SOURCES += $(nodist_bsd_module_SOURCES)
+CLEANFILES += $(nodist_bsd_module_SOURCES)
+MOD_FILES += bsd.mod
+MARKER_FILES += bsd.marker
+CLEANFILES += bsd.marker
+
+bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += bsd.module
+MODULE_FILES += bsd.module$(EXEEXT)
+bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+nodist_bsd_module_SOURCES = ## platform nodist sources
+bsd_module_LDADD =
+bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+BUILT_SOURCES += $(nodist_bsd_module_SOURCES)
+CLEANFILES += $(nodist_bsd_module_SOURCES)
+MOD_FILES += bsd.mod
+MARKER_FILES += bsd.marker
+CLEANFILES += bsd.marker
+
+bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += bsd.module
+MODULE_FILES += bsd.module$(EXEEXT)
+bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+nodist_bsd_module_SOURCES = ## platform nodist sources
+bsd_module_LDADD =
+bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+BUILT_SOURCES += $(nodist_bsd_module_SOURCES)
+CLEANFILES += $(nodist_bsd_module_SOURCES)
+MOD_FILES += bsd.mod
+MARKER_FILES += bsd.marker
+CLEANFILES += bsd.marker
+
+bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += bsd.module
+MODULE_FILES += bsd.module$(EXEEXT)
+bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+nodist_bsd_module_SOURCES = ## platform nodist sources
+bsd_module_LDADD =
+bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+BUILT_SOURCES += $(nodist_bsd_module_SOURCES)
+CLEANFILES += $(nodist_bsd_module_SOURCES)
+MOD_FILES += bsd.mod
+MARKER_FILES += bsd.marker
+CLEANFILES += bsd.marker
+
+bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += bsd.module
+MODULE_FILES += bsd.module$(EXEEXT)
+bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+nodist_bsd_module_SOURCES = ## platform nodist sources
+bsd_module_LDADD =
+bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+BUILT_SOURCES += $(nodist_bsd_module_SOURCES)
+CLEANFILES += $(nodist_bsd_module_SOURCES)
+MOD_FILES += bsd.mod
+MARKER_FILES += bsd.marker
+CLEANFILES += bsd.marker
+
+bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += plan9.module
+MODULE_FILES += plan9.module$(EXEEXT)
+plan9_module_SOURCES = loader/i386/pc/plan9.c ## platform sources
+nodist_plan9_module_SOURCES = ## platform nodist sources
+plan9_module_LDADD =
+plan9_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+plan9_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+plan9_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+plan9_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+plan9_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_plan9_module_SOURCES)
+CLEANFILES += $(nodist_plan9_module_SOURCES)
+MOD_FILES += plan9.mod
+MARKER_FILES += plan9.marker
+CLEANFILES += plan9.marker
+
+plan9.marker: $(plan9_module_SOURCES) $(nodist_plan9_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(plan9_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += linux16.module
+MODULE_FILES += linux16.module$(EXEEXT)
+linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+nodist_linux16_module_SOURCES = ## platform nodist sources
+linux16_module_LDADD =
+linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux16_module_SOURCES)
+CLEANFILES += $(nodist_linux16_module_SOURCES)
+MOD_FILES += linux16.mod
+MARKER_FILES += linux16.marker
+CLEANFILES += linux16.marker
+
+linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += linux16.module
+MODULE_FILES += linux16.module$(EXEEXT)
+linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+nodist_linux16_module_SOURCES = ## platform nodist sources
+linux16_module_LDADD =
+linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux16_module_SOURCES)
+CLEANFILES += $(nodist_linux16_module_SOURCES)
+MOD_FILES += linux16.mod
+MARKER_FILES += linux16.marker
+CLEANFILES += linux16.marker
+
+linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += linux16.module
+MODULE_FILES += linux16.module$(EXEEXT)
+linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+nodist_linux16_module_SOURCES = ## platform nodist sources
+linux16_module_LDADD =
+linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux16_module_SOURCES)
+CLEANFILES += $(nodist_linux16_module_SOURCES)
+MOD_FILES += linux16.mod
+MARKER_FILES += linux16.marker
+CLEANFILES += linux16.marker
+
+linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += linux16.module
+MODULE_FILES += linux16.module$(EXEEXT)
+linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+nodist_linux16_module_SOURCES = ## platform nodist sources
+linux16_module_LDADD =
+linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux16_module_SOURCES)
+CLEANFILES += $(nodist_linux16_module_SOURCES)
+MOD_FILES += linux16.mod
+MARKER_FILES += linux16.marker
+CLEANFILES += linux16.marker
+
+linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += linux16.module
+MODULE_FILES += linux16.module$(EXEEXT)
+linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+nodist_linux16_module_SOURCES = ## platform nodist sources
+linux16_module_LDADD =
+linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux16_module_SOURCES)
+CLEANFILES += $(nodist_linux16_module_SOURCES)
+MOD_FILES += linux16.mod
+MARKER_FILES += linux16.marker
+CLEANFILES += linux16.marker
+
+linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += linux16.module
+MODULE_FILES += linux16.module$(EXEEXT)
+linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+nodist_linux16_module_SOURCES = ## platform nodist sources
+linux16_module_LDADD =
+linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux16_module_SOURCES)
+CLEANFILES += $(nodist_linux16_module_SOURCES)
+MOD_FILES += linux16.mod
+MARKER_FILES += linux16.marker
+CLEANFILES += linux16.marker
+
+linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += linux16.module
+MODULE_FILES += linux16.module$(EXEEXT)
+linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+nodist_linux16_module_SOURCES = ## platform nodist sources
+linux16_module_LDADD =
+linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux16_module_SOURCES)
+CLEANFILES += $(nodist_linux16_module_SOURCES)
+MOD_FILES += linux16.mod
+MARKER_FILES += linux16.marker
+CLEANFILES += linux16.marker
+
+linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += ntldr.module
+MODULE_FILES += ntldr.module$(EXEEXT)
+ntldr_module_SOURCES = loader/i386/pc/ntldr.c ## platform sources
+nodist_ntldr_module_SOURCES = ## platform nodist sources
+ntldr_module_LDADD =
+ntldr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ntldr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ntldr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ntldr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ntldr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ntldr_module_SOURCES)
+CLEANFILES += $(nodist_ntldr_module_SOURCES)
+MOD_FILES += ntldr.mod
+MARKER_FILES += ntldr.marker
+CLEANFILES += ntldr.marker
+
+ntldr.marker: $(ntldr_module_SOURCES) $(nodist_ntldr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntldr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += truecrypt.module
+MODULE_FILES += truecrypt.module$(EXEEXT)
+truecrypt_module_SOURCES = loader/i386/pc/truecrypt.c ## platform sources
+nodist_truecrypt_module_SOURCES = ## platform nodist sources
+truecrypt_module_LDADD =
+truecrypt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+truecrypt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+truecrypt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+truecrypt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+truecrypt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_truecrypt_module_SOURCES)
+CLEANFILES += $(nodist_truecrypt_module_SOURCES)
+MOD_FILES += truecrypt.mod
+MARKER_FILES += truecrypt.marker
+CLEANFILES += truecrypt.marker
+
+truecrypt.marker: $(truecrypt_module_SOURCES) $(nodist_truecrypt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(truecrypt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += freedos.module
+MODULE_FILES += freedos.module$(EXEEXT)
+freedos_module_SOURCES = loader/i386/pc/freedos.c ## platform sources
+nodist_freedos_module_SOURCES = ## platform nodist sources
+freedos_module_LDADD =
+freedos_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+freedos_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+freedos_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+freedos_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+freedos_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_freedos_module_SOURCES)
+CLEANFILES += $(nodist_freedos_module_SOURCES)
+MOD_FILES += freedos.mod
+MARKER_FILES += freedos.marker
+CLEANFILES += freedos.marker
+
+freedos.marker: $(freedos_module_SOURCES) $(nodist_freedos_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(freedos_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += pxechain.module
+MODULE_FILES += pxechain.module$(EXEEXT)
+pxechain_module_SOURCES = loader/i386/pc/pxechainloader.c ## platform sources
+nodist_pxechain_module_SOURCES = ## platform nodist sources
+pxechain_module_LDADD =
+pxechain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pxechain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pxechain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pxechain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pxechain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pxechain_module_SOURCES)
+CLEANFILES += $(nodist_pxechain_module_SOURCES)
+MOD_FILES += pxechain.mod
+MARKER_FILES += pxechain.marker
+CLEANFILES += pxechain.marker
+
+pxechain.marker: $(pxechain_module_SOURCES) $(nodist_pxechain_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxechain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += multiboot2.module
+MODULE_FILES += multiboot2.module$(EXEEXT)
+multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+nodist_multiboot2_module_SOURCES = ## platform nodist sources
+multiboot2_module_LDADD =
+multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_multiboot2_module_SOURCES)
+CLEANFILES += $(nodist_multiboot2_module_SOURCES)
+MOD_FILES += multiboot2.mod
+MARKER_FILES += multiboot2.marker
+CLEANFILES += multiboot2.marker
+
+multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += multiboot.module
+MODULE_FILES += multiboot.module$(EXEEXT)
+multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+nodist_multiboot_module_SOURCES = ## platform nodist sources
+multiboot_module_LDADD =
+multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/multiboot_elfxx.c
+BUILT_SOURCES += $(nodist_multiboot_module_SOURCES)
+CLEANFILES += $(nodist_multiboot_module_SOURCES)
+MOD_FILES += multiboot.mod
+MARKER_FILES += multiboot.marker
+CLEANFILES += multiboot.marker
+
+multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += multiboot.module
+MODULE_FILES += multiboot.module$(EXEEXT)
+multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+nodist_multiboot_module_SOURCES = ## platform nodist sources
+multiboot_module_LDADD =
+multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/multiboot_elfxx.c
+BUILT_SOURCES += $(nodist_multiboot_module_SOURCES)
+CLEANFILES += $(nodist_multiboot_module_SOURCES)
+MOD_FILES += multiboot.mod
+MARKER_FILES += multiboot.marker
+CLEANFILES += multiboot.marker
+
+multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += multiboot.module
+MODULE_FILES += multiboot.module$(EXEEXT)
+multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+nodist_multiboot_module_SOURCES = ## platform nodist sources
+multiboot_module_LDADD =
+multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/multiboot_elfxx.c
+BUILT_SOURCES += $(nodist_multiboot_module_SOURCES)
+CLEANFILES += $(nodist_multiboot_module_SOURCES)
+MOD_FILES += multiboot.mod
+MARKER_FILES += multiboot.marker
+CLEANFILES += multiboot.marker
+
+multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += multiboot.module
+MODULE_FILES += multiboot.module$(EXEEXT)
+multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+nodist_multiboot_module_SOURCES = ## platform nodist sources
+multiboot_module_LDADD =
+multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/multiboot_elfxx.c
+BUILT_SOURCES += $(nodist_multiboot_module_SOURCES)
+CLEANFILES += $(nodist_multiboot_module_SOURCES)
+MOD_FILES += multiboot.mod
+MARKER_FILES += multiboot.marker
+CLEANFILES += multiboot.marker
+
+multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += multiboot.module
+MODULE_FILES += multiboot.module$(EXEEXT)
+multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+nodist_multiboot_module_SOURCES = ## platform nodist sources
+multiboot_module_LDADD =
+multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/multiboot_elfxx.c
+BUILT_SOURCES += $(nodist_multiboot_module_SOURCES)
+CLEANFILES += $(nodist_multiboot_module_SOURCES)
+MOD_FILES += multiboot.mod
+MARKER_FILES += multiboot.marker
+CLEANFILES += multiboot.marker
+
+multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += multiboot.module
+MODULE_FILES += multiboot.module$(EXEEXT)
+multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+nodist_multiboot_module_SOURCES = ## platform nodist sources
+multiboot_module_LDADD =
+multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/multiboot_elfxx.c
+BUILT_SOURCES += $(nodist_multiboot_module_SOURCES)
+CLEANFILES += $(nodist_multiboot_module_SOURCES)
+MOD_FILES += multiboot.mod
+MARKER_FILES += multiboot.marker
+CLEANFILES += multiboot.marker
+
+multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += multiboot.module
+MODULE_FILES += multiboot.module$(EXEEXT)
+multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+nodist_multiboot_module_SOURCES = ## platform nodist sources
+multiboot_module_LDADD =
+multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/multiboot_elfxx.c
+BUILT_SOURCES += $(nodist_multiboot_module_SOURCES)
+CLEANFILES += $(nodist_multiboot_module_SOURCES)
+MOD_FILES += multiboot.mod
+MARKER_FILES += multiboot.marker
+CLEANFILES += multiboot.marker
+
+multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += multiboot.module
+MODULE_FILES += multiboot.module$(EXEEXT)
+multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+nodist_multiboot_module_SOURCES = ## platform nodist sources
+multiboot_module_LDADD =
+multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/multiboot_elfxx.c
+BUILT_SOURCES += $(nodist_multiboot_module_SOURCES)
+CLEANFILES += $(nodist_multiboot_module_SOURCES)
+MOD_FILES += multiboot.mod
+MARKER_FILES += multiboot.marker
+CLEANFILES += multiboot.marker
+
+multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += xen_boot.module
+MODULE_FILES += xen_boot.module$(EXEEXT)
+xen_boot_module_SOURCES = loader/arm64/xen_boot.c ## platform sources
+nodist_xen_boot_module_SOURCES = ## platform nodist sources
+xen_boot_module_LDADD =
+xen_boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xen_boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xen_boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xen_boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xen_boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xen_boot_module_SOURCES)
+CLEANFILES += $(nodist_xen_boot_module_SOURCES)
+MOD_FILES += xen_boot.mod
+MARKER_FILES += xen_boot.marker
+CLEANFILES += xen_boot.marker
+
+xen_boot.marker: $(xen_boot_module_SOURCES) $(nodist_xen_boot_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xen_boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = lib/i386/pc/vesa_modes_table.c loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/i386/xen.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/i386/xen.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/i386/linux.c lib/i386/pc/vesa_modes_table.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/mips/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/sparc64/ieee1275/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/powerpc/ieee1275/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/mips/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/ia64/efi/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/mips/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/arm/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/arm64/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/arm64/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/arm/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/riscv/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += linux.module
+MODULE_FILES += linux.module$(EXEEXT)
+linux_module_SOURCES = loader/riscv/linux.c loader/linux.c lib/cmdline.c ## platform sources
+nodist_linux_module_SOURCES = ## platform nodist sources
+linux_module_LDADD =
+linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_linux_module_SOURCES)
+CLEANFILES += $(nodist_linux_module_SOURCES)
+MOD_FILES += linux.mod
+MARKER_FILES += linux.marker
+CLEANFILES += linux.marker
+
+linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += fdt.module
+MODULE_FILES += fdt.module$(EXEEXT)
+fdt_module_SOURCES = lib/fdt.c ## platform sources
+nodist_fdt_module_SOURCES = ## platform nodist sources
+fdt_module_LDADD =
+fdt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fdt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fdt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fdt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fdt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fdt_module_SOURCES)
+CLEANFILES += $(nodist_fdt_module_SOURCES)
+MOD_FILES += fdt.mod
+MARKER_FILES += fdt.marker
+CLEANFILES += fdt.marker
+
+fdt.marker: $(fdt_module_SOURCES) $(nodist_fdt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += fdt.module
+MODULE_FILES += fdt.module$(EXEEXT)
+fdt_module_SOURCES = loader/efi/fdt.c lib/fdt.c ## platform sources
+nodist_fdt_module_SOURCES = ## platform nodist sources
+fdt_module_LDADD =
+fdt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fdt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fdt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fdt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fdt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fdt_module_SOURCES)
+CLEANFILES += $(nodist_fdt_module_SOURCES)
+MOD_FILES += fdt.mod
+MARKER_FILES += fdt.marker
+CLEANFILES += fdt.marker
+
+fdt.marker: $(fdt_module_SOURCES) $(nodist_fdt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += fdt.module
+MODULE_FILES += fdt.module$(EXEEXT)
+fdt_module_SOURCES = loader/efi/fdt.c lib/fdt.c ## platform sources
+nodist_fdt_module_SOURCES = ## platform nodist sources
+fdt_module_LDADD =
+fdt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fdt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fdt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fdt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fdt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fdt_module_SOURCES)
+CLEANFILES += $(nodist_fdt_module_SOURCES)
+MOD_FILES += fdt.mod
+MARKER_FILES += fdt.marker
+CLEANFILES += fdt.marker
+
+fdt.marker: $(fdt_module_SOURCES) $(nodist_fdt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += fdt.module
+MODULE_FILES += fdt.module$(EXEEXT)
+fdt_module_SOURCES = loader/efi/fdt.c lib/fdt.c ## platform sources
+nodist_fdt_module_SOURCES = ## platform nodist sources
+fdt_module_LDADD =
+fdt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fdt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fdt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fdt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fdt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fdt_module_SOURCES)
+CLEANFILES += $(nodist_fdt_module_SOURCES)
+MOD_FILES += fdt.mod
+MARKER_FILES += fdt.marker
+CLEANFILES += fdt.marker
+
+fdt.marker: $(fdt_module_SOURCES) $(nodist_fdt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += fdt.module
+MODULE_FILES += fdt.module$(EXEEXT)
+fdt_module_SOURCES = loader/efi/fdt.c lib/fdt.c ## platform sources
+nodist_fdt_module_SOURCES = ## platform nodist sources
+fdt_module_LDADD =
+fdt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fdt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fdt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fdt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fdt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fdt_module_SOURCES)
+CLEANFILES += $(nodist_fdt_module_SOURCES)
+MOD_FILES += fdt.mod
+MARKER_FILES += fdt.marker
+CLEANFILES += fdt.marker
+
+fdt.marker: $(fdt_module_SOURCES) $(nodist_fdt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += xnu.module
+MODULE_FILES += xnu.module$(EXEEXT)
+xnu_module_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/xnu.c ## platform sources
+nodist_xnu_module_SOURCES = ## platform nodist sources
+xnu_module_LDADD =
+xnu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xnu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xnu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xnu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xnu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xnu_module_SOURCES)
+CLEANFILES += $(nodist_xnu_module_SOURCES)
+MOD_FILES += xnu.mod
+MARKER_FILES += xnu.marker
+CLEANFILES += xnu.marker
+
+xnu.marker: $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += xnu.module
+MODULE_FILES += xnu.module$(EXEEXT)
+xnu_module_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/xnu.c ## platform sources
+nodist_xnu_module_SOURCES = ## platform nodist sources
+xnu_module_LDADD =
+xnu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xnu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xnu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xnu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xnu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xnu_module_SOURCES)
+CLEANFILES += $(nodist_xnu_module_SOURCES)
+MOD_FILES += xnu.mod
+MARKER_FILES += xnu.marker
+CLEANFILES += xnu.marker
+
+xnu.marker: $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += xnu.module
+MODULE_FILES += xnu.module$(EXEEXT)
+xnu_module_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/xnu.c ## platform sources
+nodist_xnu_module_SOURCES = ## platform nodist sources
+xnu_module_LDADD =
+xnu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xnu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xnu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xnu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xnu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xnu_module_SOURCES)
+CLEANFILES += $(nodist_xnu_module_SOURCES)
+MOD_FILES += xnu.mod
+MARKER_FILES += xnu.marker
+CLEANFILES += xnu.marker
+
+xnu.marker: $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += xnu.module
+MODULE_FILES += xnu.module$(EXEEXT)
+xnu_module_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/xnu.c ## platform sources
+nodist_xnu_module_SOURCES = ## platform nodist sources
+xnu_module_LDADD =
+xnu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xnu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xnu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xnu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xnu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xnu_module_SOURCES)
+CLEANFILES += $(nodist_xnu_module_SOURCES)
+MOD_FILES += xnu.mod
+MARKER_FILES += xnu.marker
+CLEANFILES += xnu.marker
+
+xnu.marker: $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += xnu.module
+MODULE_FILES += xnu.module$(EXEEXT)
+xnu_module_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/xnu.c ## platform sources
+nodist_xnu_module_SOURCES = ## platform nodist sources
+xnu_module_LDADD =
+xnu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xnu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xnu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xnu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xnu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xnu_module_SOURCES)
+CLEANFILES += $(nodist_xnu_module_SOURCES)
+MOD_FILES += xnu.mod
+MARKER_FILES += xnu.marker
+CLEANFILES += xnu.marker
+
+xnu.marker: $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += random.module
+MODULE_FILES += random.module$(EXEEXT)
+random_module_SOURCES = kern/i386/tsc_pmtimer.c lib/i386/random.c lib/random.c ## platform sources
+nodist_random_module_SOURCES = ## platform nodist sources
+random_module_LDADD =
+random_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+random_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+random_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+random_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+random_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_random_module_SOURCES)
+CLEANFILES += $(nodist_random_module_SOURCES)
+MOD_FILES += random.mod
+MARKER_FILES += random.marker
+CLEANFILES += random.marker
+
+random.marker: $(random_module_SOURCES) $(nodist_random_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += random.module
+MODULE_FILES += random.module$(EXEEXT)
+random_module_SOURCES = lib/i386/random.c lib/random.c ## platform sources
+nodist_random_module_SOURCES = ## platform nodist sources
+random_module_LDADD =
+random_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+random_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+random_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+random_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+random_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_random_module_SOURCES)
+CLEANFILES += $(nodist_random_module_SOURCES)
+MOD_FILES += random.mod
+MARKER_FILES += random.marker
+CLEANFILES += random.marker
+
+random.marker: $(random_module_SOURCES) $(nodist_random_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += random.module
+MODULE_FILES += random.module$(EXEEXT)
+random_module_SOURCES = kern/i386/tsc_pmtimer.c lib/i386/random.c lib/random.c ## platform sources
+nodist_random_module_SOURCES = ## platform nodist sources
+random_module_LDADD =
+random_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+random_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+random_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+random_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+random_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_random_module_SOURCES)
+CLEANFILES += $(nodist_random_module_SOURCES)
+MOD_FILES += random.mod
+MARKER_FILES += random.marker
+CLEANFILES += random.marker
+
+random.marker: $(random_module_SOURCES) $(nodist_random_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += random.module
+MODULE_FILES += random.module$(EXEEXT)
+random_module_SOURCES = kern/i386/tsc_pmtimer.c lib/i386/random.c lib/random.c ## platform sources
+nodist_random_module_SOURCES = ## platform nodist sources
+random_module_LDADD =
+random_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+random_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+random_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+random_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+random_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_random_module_SOURCES)
+CLEANFILES += $(nodist_random_module_SOURCES)
+MOD_FILES += random.mod
+MARKER_FILES += random.marker
+CLEANFILES += random.marker
+
+random.marker: $(random_module_SOURCES) $(nodist_random_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += random.module
+MODULE_FILES += random.module$(EXEEXT)
+random_module_SOURCES = lib/i386/random.c lib/random.c ## platform sources
+nodist_random_module_SOURCES = ## platform nodist sources
+random_module_LDADD =
+random_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+random_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+random_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+random_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+random_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_random_module_SOURCES)
+CLEANFILES += $(nodist_random_module_SOURCES)
+MOD_FILES += random.mod
+MARKER_FILES += random.marker
+CLEANFILES += random.marker
+
+random.marker: $(random_module_SOURCES) $(nodist_random_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += macho.module
+MODULE_FILES += macho.module$(EXEEXT)
+macho_module_SOURCES = loader/macho.c loader/macho32.c loader/macho64.c loader/lzss.c ## platform sources
+nodist_macho_module_SOURCES = ## platform nodist sources
+macho_module_LDADD =
+macho_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+macho_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+macho_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+macho_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+macho_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += loader/machoXX.c
+BUILT_SOURCES += $(nodist_macho_module_SOURCES)
+CLEANFILES += $(nodist_macho_module_SOURCES)
+MOD_FILES += macho.mod
+MARKER_FILES += macho.marker
+CLEANFILES += macho.marker
+
+macho.marker: $(macho_module_SOURCES) $(nodist_macho_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_efi
+platform_PROGRAMS += appleldr.module
+MODULE_FILES += appleldr.module$(EXEEXT)
+appleldr_module_SOURCES = loader/efi/appleloader.c ## platform sources
+nodist_appleldr_module_SOURCES = ## platform nodist sources
+appleldr_module_LDADD =
+appleldr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+appleldr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+appleldr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+appleldr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+appleldr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_appleldr_module_SOURCES)
+CLEANFILES += $(nodist_appleldr_module_SOURCES)
+MOD_FILES += appleldr.mod
+MARKER_FILES += appleldr.marker
+CLEANFILES += appleldr.marker
+
+appleldr.marker: $(appleldr_module_SOURCES) $(nodist_appleldr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(appleldr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += appleldr.module
+MODULE_FILES += appleldr.module$(EXEEXT)
+appleldr_module_SOURCES = loader/efi/appleloader.c ## platform sources
+nodist_appleldr_module_SOURCES = ## platform nodist sources
+appleldr_module_LDADD =
+appleldr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+appleldr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+appleldr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+appleldr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+appleldr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_appleldr_module_SOURCES)
+CLEANFILES += $(nodist_appleldr_module_SOURCES)
+MOD_FILES += appleldr.mod
+MARKER_FILES += appleldr.marker
+CLEANFILES += appleldr.marker
+
+appleldr.marker: $(appleldr_module_SOURCES) $(nodist_appleldr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(appleldr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += chain.module
+MODULE_FILES += chain.module$(EXEEXT)
+chain_module_SOURCES = loader/i386/pc/chainloader.c ## platform sources
+nodist_chain_module_SOURCES = ## platform nodist sources
+chain_module_LDADD =
+chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_chain_module_SOURCES)
+CLEANFILES += $(nodist_chain_module_SOURCES)
+MOD_FILES += chain.mod
+MARKER_FILES += chain.marker
+CLEANFILES += chain.marker
+
+chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += chain.module
+MODULE_FILES += chain.module$(EXEEXT)
+chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+nodist_chain_module_SOURCES = ## platform nodist sources
+chain_module_LDADD =
+chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_chain_module_SOURCES)
+CLEANFILES += $(nodist_chain_module_SOURCES)
+MOD_FILES += chain.mod
+MARKER_FILES += chain.marker
+CLEANFILES += chain.marker
+
+chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += chain.module
+MODULE_FILES += chain.module$(EXEEXT)
+chain_module_SOURCES = loader/i386/coreboot/chainloader.c lib/LzmaDec.c ## platform sources
+nodist_chain_module_SOURCES = ## platform nodist sources
+chain_module_LDADD =
+chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_chain_module_SOURCES)
+CLEANFILES += $(nodist_chain_module_SOURCES)
+MOD_FILES += chain.mod
+MARKER_FILES += chain.marker
+CLEANFILES += chain.marker
+
+chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += chain.module
+MODULE_FILES += chain.module$(EXEEXT)
+chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+nodist_chain_module_SOURCES = ## platform nodist sources
+chain_module_LDADD =
+chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_chain_module_SOURCES)
+CLEANFILES += $(nodist_chain_module_SOURCES)
+MOD_FILES += chain.mod
+MARKER_FILES += chain.marker
+CLEANFILES += chain.marker
+
+chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += chain.module
+MODULE_FILES += chain.module$(EXEEXT)
+chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+nodist_chain_module_SOURCES = ## platform nodist sources
+chain_module_LDADD =
+chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_chain_module_SOURCES)
+CLEANFILES += $(nodist_chain_module_SOURCES)
+MOD_FILES += chain.mod
+MARKER_FILES += chain.marker
+CLEANFILES += chain.marker
+
+chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += chain.module
+MODULE_FILES += chain.module$(EXEEXT)
+chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+nodist_chain_module_SOURCES = ## platform nodist sources
+chain_module_LDADD =
+chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_chain_module_SOURCES)
+CLEANFILES += $(nodist_chain_module_SOURCES)
+MOD_FILES += chain.mod
+MARKER_FILES += chain.marker
+CLEANFILES += chain.marker
+
+chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += chain.module
+MODULE_FILES += chain.module$(EXEEXT)
+chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+nodist_chain_module_SOURCES = ## platform nodist sources
+chain_module_LDADD =
+chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_chain_module_SOURCES)
+CLEANFILES += $(nodist_chain_module_SOURCES)
+MOD_FILES += chain.mod
+MARKER_FILES += chain.marker
+CLEANFILES += chain.marker
+
+chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += chain.module
+MODULE_FILES += chain.module$(EXEEXT)
+chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+nodist_chain_module_SOURCES = ## platform nodist sources
+chain_module_LDADD =
+chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_chain_module_SOURCES)
+CLEANFILES += $(nodist_chain_module_SOURCES)
+MOD_FILES += chain.mod
+MARKER_FILES += chain.marker
+CLEANFILES += chain.marker
+
+chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += chain.module
+MODULE_FILES += chain.module$(EXEEXT)
+chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+nodist_chain_module_SOURCES = ## platform nodist sources
+chain_module_LDADD =
+chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_chain_module_SOURCES)
+CLEANFILES += $(nodist_chain_module_SOURCES)
+MOD_FILES += chain.mod
+MARKER_FILES += chain.marker
+CLEANFILES += chain.marker
+
+chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/i386/pc/mmap.c mmap/i386/pc/mmap_helper.S mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/efi/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/efi/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/mips/uppermem.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/mips/uppermem.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/efi/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/mips/uppermem.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/efi/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/efi/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/efi/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += mmap.module
+MODULE_FILES += mmap.module$(EXEEXT)
+mmap_module_SOURCES = mmap/efi/mmap.c mmap/mmap.c ## platform sources
+nodist_mmap_module_SOURCES = ## platform nodist sources
+mmap_module_LDADD =
+mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mmap_module_SOURCES)
+CLEANFILES += $(nodist_mmap_module_SOURCES)
+MOD_FILES += mmap.mod
+MARKER_FILES += mmap.marker
+CLEANFILES += mmap.marker
+
+mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += normal.module
+MODULE_FILES += normal.module$(EXEEXT)
+normal_module_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c normal/auth.c normal/autofs.c normal/color.c normal/completion.c normal/menu.c normal/menu_entry.c normal/menu_text.c normal/misc.c normal/crypto.c normal/term.c normal/context.c normal/charset.c lib/getline.c script/main.c script/script.c script/execute.c script/function.c script/lexer.c script/argv.c commands/menuentry.c unidata.c ## platform sources
+nodist_normal_module_SOURCES = grub_script.tab.c grub_script.yy.c grub_script.tab.h grub_script.yy.h ## platform nodist sources
+normal_module_LDADD =
+normal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) -Wno-redundant-decls
+normal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+normal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_POSIX)
+normal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+normal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += script/yylex.l script/parser.y
+BUILT_SOURCES += $(nodist_normal_module_SOURCES)
+CLEANFILES += $(nodist_normal_module_SOURCES)
+MOD_FILES += normal.mod
+MARKER_FILES += normal.marker
+CLEANFILES += normal.marker
+
+normal.marker: $(normal_module_SOURCES) $(nodist_normal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_acorn.module
+MODULE_FILES += part_acorn.module$(EXEEXT)
+part_acorn_module_SOURCES = partmap/acorn.c ## platform sources
+nodist_part_acorn_module_SOURCES = ## platform nodist sources
+part_acorn_module_LDADD =
+part_acorn_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_acorn_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_acorn_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_acorn_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_acorn_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_acorn_module_SOURCES)
+CLEANFILES += $(nodist_part_acorn_module_SOURCES)
+MOD_FILES += part_acorn.mod
+MARKER_FILES += part_acorn.marker
+CLEANFILES += part_acorn.marker
+
+part_acorn.marker: $(part_acorn_module_SOURCES) $(nodist_part_acorn_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_acorn_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_amiga.module
+MODULE_FILES += part_amiga.module$(EXEEXT)
+part_amiga_module_SOURCES = partmap/amiga.c ## platform sources
+nodist_part_amiga_module_SOURCES = ## platform nodist sources
+part_amiga_module_LDADD =
+part_amiga_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_amiga_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_amiga_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_amiga_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_amiga_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_amiga_module_SOURCES)
+CLEANFILES += $(nodist_part_amiga_module_SOURCES)
+MOD_FILES += part_amiga.mod
+MARKER_FILES += part_amiga.marker
+CLEANFILES += part_amiga.marker
+
+part_amiga.marker: $(part_amiga_module_SOURCES) $(nodist_part_amiga_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_amiga_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_apple.module
+MODULE_FILES += part_apple.module$(EXEEXT)
+part_apple_module_SOURCES = partmap/apple.c ## platform sources
+nodist_part_apple_module_SOURCES = ## platform nodist sources
+part_apple_module_LDADD =
+part_apple_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_apple_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_apple_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_apple_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_apple_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_apple_module_SOURCES)
+CLEANFILES += $(nodist_part_apple_module_SOURCES)
+MOD_FILES += part_apple.mod
+MARKER_FILES += part_apple.marker
+CLEANFILES += part_apple.marker
+
+part_apple.marker: $(part_apple_module_SOURCES) $(nodist_part_apple_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_apple_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_gpt.module
+MODULE_FILES += part_gpt.module$(EXEEXT)
+part_gpt_module_SOURCES = partmap/gpt.c ## platform sources
+nodist_part_gpt_module_SOURCES = ## platform nodist sources
+part_gpt_module_LDADD =
+part_gpt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_gpt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_gpt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_gpt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_gpt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_gpt_module_SOURCES)
+CLEANFILES += $(nodist_part_gpt_module_SOURCES)
+MOD_FILES += part_gpt.mod
+MARKER_FILES += part_gpt.marker
+CLEANFILES += part_gpt.marker
+
+part_gpt.marker: $(part_gpt_module_SOURCES) $(nodist_part_gpt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_gpt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_msdos.module
+MODULE_FILES += part_msdos.module$(EXEEXT)
+part_msdos_module_SOURCES = partmap/msdos.c ## platform sources
+nodist_part_msdos_module_SOURCES = ## platform nodist sources
+part_msdos_module_LDADD =
+part_msdos_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_msdos_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_msdos_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_msdos_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_msdos_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_msdos_module_SOURCES)
+CLEANFILES += $(nodist_part_msdos_module_SOURCES)
+MOD_FILES += part_msdos.mod
+MARKER_FILES += part_msdos.marker
+CLEANFILES += part_msdos.marker
+
+part_msdos.marker: $(part_msdos_module_SOURCES) $(nodist_part_msdos_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_msdos_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_sun.module
+MODULE_FILES += part_sun.module$(EXEEXT)
+part_sun_module_SOURCES = partmap/sun.c ## platform sources
+nodist_part_sun_module_SOURCES = ## platform nodist sources
+part_sun_module_LDADD =
+part_sun_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_sun_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_sun_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_sun_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_sun_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_sun_module_SOURCES)
+CLEANFILES += $(nodist_part_sun_module_SOURCES)
+MOD_FILES += part_sun.mod
+MARKER_FILES += part_sun.marker
+CLEANFILES += part_sun.marker
+
+part_sun.marker: $(part_sun_module_SOURCES) $(nodist_part_sun_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sun_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_plan.module
+MODULE_FILES += part_plan.module$(EXEEXT)
+part_plan_module_SOURCES = partmap/plan.c ## platform sources
+nodist_part_plan_module_SOURCES = ## platform nodist sources
+part_plan_module_LDADD =
+part_plan_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_plan_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_plan_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_plan_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_plan_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_plan_module_SOURCES)
+CLEANFILES += $(nodist_part_plan_module_SOURCES)
+MOD_FILES += part_plan.mod
+MARKER_FILES += part_plan.marker
+CLEANFILES += part_plan.marker
+
+part_plan.marker: $(part_plan_module_SOURCES) $(nodist_part_plan_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_plan_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_dvh.module
+MODULE_FILES += part_dvh.module$(EXEEXT)
+part_dvh_module_SOURCES = partmap/dvh.c ## platform sources
+nodist_part_dvh_module_SOURCES = ## platform nodist sources
+part_dvh_module_LDADD =
+part_dvh_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_dvh_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_dvh_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_dvh_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_dvh_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_dvh_module_SOURCES)
+CLEANFILES += $(nodist_part_dvh_module_SOURCES)
+MOD_FILES += part_dvh.mod
+MARKER_FILES += part_dvh.marker
+CLEANFILES += part_dvh.marker
+
+part_dvh.marker: $(part_dvh_module_SOURCES) $(nodist_part_dvh_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dvh_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_bsd.module
+MODULE_FILES += part_bsd.module$(EXEEXT)
+part_bsd_module_SOURCES = partmap/bsdlabel.c ## platform sources
+nodist_part_bsd_module_SOURCES = ## platform nodist sources
+part_bsd_module_LDADD =
+part_bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_bsd_module_SOURCES)
+CLEANFILES += $(nodist_part_bsd_module_SOURCES)
+MOD_FILES += part_bsd.mod
+MARKER_FILES += part_bsd.marker
+CLEANFILES += part_bsd.marker
+
+part_bsd.marker: $(part_bsd_module_SOURCES) $(nodist_part_bsd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_sunpc.module
+MODULE_FILES += part_sunpc.module$(EXEEXT)
+part_sunpc_module_SOURCES = partmap/sunpc.c ## platform sources
+nodist_part_sunpc_module_SOURCES = ## platform nodist sources
+part_sunpc_module_LDADD =
+part_sunpc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_sunpc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_sunpc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_sunpc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_sunpc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_sunpc_module_SOURCES)
+CLEANFILES += $(nodist_part_sunpc_module_SOURCES)
+MOD_FILES += part_sunpc.mod
+MARKER_FILES += part_sunpc.marker
+CLEANFILES += part_sunpc.marker
+
+part_sunpc.marker: $(part_sunpc_module_SOURCES) $(nodist_part_sunpc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sunpc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += part_dfly.module
+MODULE_FILES += part_dfly.module$(EXEEXT)
+part_dfly_module_SOURCES = partmap/dfly.c ## platform sources
+nodist_part_dfly_module_SOURCES = ## platform nodist sources
+part_dfly_module_LDADD =
+part_dfly_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_dfly_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_dfly_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_dfly_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_dfly_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_part_dfly_module_SOURCES)
+CLEANFILES += $(nodist_part_dfly_module_SOURCES)
+MOD_FILES += part_dfly.mod
+MARKER_FILES += part_dfly.marker
+CLEANFILES += part_dfly.marker
+
+part_dfly.marker: $(part_dfly_module_SOURCES) $(nodist_part_dfly_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dfly_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += msdospart.module
+MODULE_FILES += msdospart.module$(EXEEXT)
+msdospart_module_SOURCES = parttool/msdospart.c ## platform sources
+nodist_msdospart_module_SOURCES = ## platform nodist sources
+msdospart_module_LDADD =
+msdospart_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+msdospart_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+msdospart_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+msdospart_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+msdospart_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_msdospart_module_SOURCES)
+CLEANFILES += $(nodist_msdospart_module_SOURCES)
+MOD_FILES += msdospart.mod
+MARKER_FILES += msdospart.marker
+CLEANFILES += msdospart.marker
+
+msdospart.marker: $(msdospart_module_SOURCES) $(nodist_msdospart_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(msdospart_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += at_keyboard.module
+MODULE_FILES += at_keyboard.module$(EXEEXT)
+at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+at_keyboard_module_LDADD =
+at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_at_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_at_keyboard_module_SOURCES)
+MOD_FILES += at_keyboard.mod
+MARKER_FILES += at_keyboard.marker
+CLEANFILES += at_keyboard.marker
+
+at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += at_keyboard.module
+MODULE_FILES += at_keyboard.module$(EXEEXT)
+at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+at_keyboard_module_LDADD =
+at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_at_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_at_keyboard_module_SOURCES)
+MOD_FILES += at_keyboard.mod
+MARKER_FILES += at_keyboard.marker
+CLEANFILES += at_keyboard.marker
+
+at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += at_keyboard.module
+MODULE_FILES += at_keyboard.module$(EXEEXT)
+at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+at_keyboard_module_LDADD =
+at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_at_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_at_keyboard_module_SOURCES)
+MOD_FILES += at_keyboard.mod
+MARKER_FILES += at_keyboard.marker
+CLEANFILES += at_keyboard.marker
+
+at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += at_keyboard.module
+MODULE_FILES += at_keyboard.module$(EXEEXT)
+at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+at_keyboard_module_LDADD =
+at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_at_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_at_keyboard_module_SOURCES)
+MOD_FILES += at_keyboard.mod
+MARKER_FILES += at_keyboard.marker
+CLEANFILES += at_keyboard.marker
+
+at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += at_keyboard.module
+MODULE_FILES += at_keyboard.module$(EXEEXT)
+at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+at_keyboard_module_LDADD =
+at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_at_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_at_keyboard_module_SOURCES)
+MOD_FILES += at_keyboard.mod
+MARKER_FILES += at_keyboard.marker
+CLEANFILES += at_keyboard.marker
+
+at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += at_keyboard.module
+MODULE_FILES += at_keyboard.module$(EXEEXT)
+at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+at_keyboard_module_LDADD =
+at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_at_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_at_keyboard_module_SOURCES)
+MOD_FILES += at_keyboard.mod
+MARKER_FILES += at_keyboard.marker
+CLEANFILES += at_keyboard.marker
+
+at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += at_keyboard.module
+MODULE_FILES += at_keyboard.module$(EXEEXT)
+at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+at_keyboard_module_LDADD =
+at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_at_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_at_keyboard_module_SOURCES)
+MOD_FILES += at_keyboard.mod
+MARKER_FILES += at_keyboard.marker
+CLEANFILES += at_keyboard.marker
+
+at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += gfxterm.module
+MODULE_FILES += gfxterm.module$(EXEEXT)
+gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+nodist_gfxterm_module_SOURCES = ## platform nodist sources
+gfxterm_module_LDADD =
+gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_module_SOURCES)
+MOD_FILES += gfxterm.mod
+MARKER_FILES += gfxterm.marker
+CLEANFILES += gfxterm.marker
+
+gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += gfxterm_background.module
+MODULE_FILES += gfxterm_background.module$(EXEEXT)
+gfxterm_background_module_SOURCES = term/gfxterm_background.c ## platform sources
+nodist_gfxterm_background_module_SOURCES = ## platform nodist sources
+gfxterm_background_module_LDADD =
+gfxterm_background_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_background_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_background_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_background_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_background_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_background_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_background_module_SOURCES)
+MOD_FILES += gfxterm_background.mod
+MARKER_FILES += gfxterm_background.marker
+CLEANFILES += gfxterm_background.marker
+
+gfxterm_background.marker: $(gfxterm_background_module_SOURCES) $(nodist_gfxterm_background_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_background_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/ns8250.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/ns8250.c term/efi/serial.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/ns8250.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/ns8250.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/ns8250.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/ieee1275/serial.c term/ns8250.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/ns8250.c term/efi/serial.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/ieee1275/serial.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/ieee1275/serial.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/arc/serial.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/efi/serial.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/efi/serial.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/efi/serial.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/efi/serial.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += serial.module
+MODULE_FILES += serial.module$(EXEEXT)
+serial_module_SOURCES = term/efi/serial.c term/serial.c ## platform sources
+nodist_serial_module_SOURCES = ## platform nodist sources
+serial_module_LDADD =
+serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_serial_module_SOURCES)
+CLEANFILES += $(nodist_serial_module_SOURCES)
+MOD_FILES += serial.mod
+MARKER_FILES += serial.marker
+CLEANFILES += serial.marker
+
+serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += sendkey.module
+MODULE_FILES += sendkey.module$(EXEEXT)
+sendkey_module_SOURCES = commands/i386/pc/sendkey.c ## platform sources
+nodist_sendkey_module_SOURCES = ## platform nodist sources
+sendkey_module_LDADD =
+sendkey_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+sendkey_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+sendkey_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+sendkey_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+sendkey_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_sendkey_module_SOURCES)
+CLEANFILES += $(nodist_sendkey_module_SOURCES)
+MOD_FILES += sendkey.mod
+MARKER_FILES += sendkey.marker
+CLEANFILES += sendkey.marker
+
+sendkey.marker: $(sendkey_module_SOURCES) $(nodist_sendkey_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sendkey_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += terminfo.module
+MODULE_FILES += terminfo.module$(EXEEXT)
+terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+nodist_terminfo_module_SOURCES = ## platform nodist sources
+terminfo_module_LDADD =
+terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_terminfo_module_SOURCES)
+CLEANFILES += $(nodist_terminfo_module_SOURCES)
+MOD_FILES += terminfo.mod
+MARKER_FILES += terminfo.marker
+CLEANFILES += terminfo.marker
+
+terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += usb_keyboard.module
+MODULE_FILES += usb_keyboard.module$(EXEEXT)
+usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+usb_keyboard_module_LDADD =
+usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_usb_keyboard_module_SOURCES)
+MOD_FILES += usb_keyboard.mod
+MARKER_FILES += usb_keyboard.marker
+CLEANFILES += usb_keyboard.marker
+
+usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += usb_keyboard.module
+MODULE_FILES += usb_keyboard.module$(EXEEXT)
+usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+usb_keyboard_module_LDADD =
+usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_usb_keyboard_module_SOURCES)
+MOD_FILES += usb_keyboard.mod
+MARKER_FILES += usb_keyboard.marker
+CLEANFILES += usb_keyboard.marker
+
+usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += usb_keyboard.module
+MODULE_FILES += usb_keyboard.module$(EXEEXT)
+usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+usb_keyboard_module_LDADD =
+usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_usb_keyboard_module_SOURCES)
+MOD_FILES += usb_keyboard.mod
+MARKER_FILES += usb_keyboard.marker
+CLEANFILES += usb_keyboard.marker
+
+usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += usb_keyboard.module
+MODULE_FILES += usb_keyboard.module$(EXEEXT)
+usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+usb_keyboard_module_LDADD =
+usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_usb_keyboard_module_SOURCES)
+MOD_FILES += usb_keyboard.mod
+MARKER_FILES += usb_keyboard.marker
+CLEANFILES += usb_keyboard.marker
+
+usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += usb_keyboard.module
+MODULE_FILES += usb_keyboard.module$(EXEEXT)
+usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+usb_keyboard_module_LDADD =
+usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_usb_keyboard_module_SOURCES)
+MOD_FILES += usb_keyboard.mod
+MARKER_FILES += usb_keyboard.marker
+CLEANFILES += usb_keyboard.marker
+
+usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += usb_keyboard.module
+MODULE_FILES += usb_keyboard.module$(EXEEXT)
+usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+usb_keyboard_module_LDADD =
+usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_usb_keyboard_module_SOURCES)
+MOD_FILES += usb_keyboard.mod
+MARKER_FILES += usb_keyboard.marker
+CLEANFILES += usb_keyboard.marker
+
+usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += usb_keyboard.module
+MODULE_FILES += usb_keyboard.module$(EXEEXT)
+usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+usb_keyboard_module_LDADD =
+usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_usb_keyboard_module_SOURCES)
+MOD_FILES += usb_keyboard.mod
+MARKER_FILES += usb_keyboard.marker
+CLEANFILES += usb_keyboard.marker
+
+usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += usb_keyboard.module
+MODULE_FILES += usb_keyboard.module$(EXEEXT)
+usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+usb_keyboard_module_LDADD =
+usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_usb_keyboard_module_SOURCES)
+MOD_FILES += usb_keyboard.mod
+MARKER_FILES += usb_keyboard.marker
+CLEANFILES += usb_keyboard.marker
+
+usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += usb_keyboard.module
+MODULE_FILES += usb_keyboard.module$(EXEEXT)
+usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+usb_keyboard_module_LDADD =
+usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_usb_keyboard_module_SOURCES)
+CLEANFILES += $(nodist_usb_keyboard_module_SOURCES)
+MOD_FILES += usb_keyboard.mod
+MARKER_FILES += usb_keyboard.marker
+CLEANFILES += usb_keyboard.marker
+
+usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += vga.module
+MODULE_FILES += vga.module$(EXEEXT)
+vga_module_SOURCES = video/i386/pc/vga.c ## platform sources
+nodist_vga_module_SOURCES = ## platform nodist sources
+vga_module_LDADD =
+vga_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+vga_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+vga_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+vga_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+vga_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_vga_module_SOURCES)
+CLEANFILES += $(nodist_vga_module_SOURCES)
+MOD_FILES += vga.mod
+MARKER_FILES += vga.marker
+CLEANFILES += vga.marker
+
+vga.marker: $(vga_module_SOURCES) $(nodist_vga_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += vga_text.module
+MODULE_FILES += vga_text.module$(EXEEXT)
+vga_text_module_SOURCES = term/i386/pc/vga_text.c ## platform sources
+nodist_vga_text_module_SOURCES = ## platform nodist sources
+vga_text_module_LDADD =
+vga_text_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+vga_text_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+vga_text_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+vga_text_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+vga_text_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_vga_text_module_SOURCES)
+CLEANFILES += $(nodist_vga_text_module_SOURCES)
+MOD_FILES += vga_text.mod
+MARKER_FILES += vga_text.marker
+CLEANFILES += vga_text.marker
+
+vga_text.marker: $(vga_text_module_SOURCES) $(nodist_vga_text_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_text_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += mda_text.module
+MODULE_FILES += mda_text.module$(EXEEXT)
+mda_text_module_SOURCES = term/i386/pc/mda_text.c ## platform sources
+nodist_mda_text_module_SOURCES = ## platform nodist sources
+mda_text_module_LDADD =
+mda_text_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mda_text_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mda_text_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mda_text_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mda_text_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mda_text_module_SOURCES)
+CLEANFILES += $(nodist_mda_text_module_SOURCES)
+MOD_FILES += mda_text.mod
+MARKER_FILES += mda_text.marker
+CLEANFILES += mda_text.marker
+
+mda_text.marker: $(mda_text_module_SOURCES) $(nodist_mda_text_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += mda_text.module
+MODULE_FILES += mda_text.module$(EXEEXT)
+mda_text_module_SOURCES = term/i386/pc/mda_text.c ## platform sources
+nodist_mda_text_module_SOURCES = ## platform nodist sources
+mda_text_module_LDADD =
+mda_text_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mda_text_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mda_text_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mda_text_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mda_text_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mda_text_module_SOURCES)
+CLEANFILES += $(nodist_mda_text_module_SOURCES)
+MOD_FILES += mda_text.mod
+MARKER_FILES += mda_text.marker
+CLEANFILES += mda_text.marker
+
+mda_text.marker: $(mda_text_module_SOURCES) $(nodist_mda_text_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += mda_text.module
+MODULE_FILES += mda_text.module$(EXEEXT)
+mda_text_module_SOURCES = term/i386/pc/mda_text.c ## platform sources
+nodist_mda_text_module_SOURCES = ## platform nodist sources
+mda_text_module_LDADD =
+mda_text_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mda_text_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mda_text_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mda_text_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mda_text_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mda_text_module_SOURCES)
+CLEANFILES += $(nodist_mda_text_module_SOURCES)
+MOD_FILES += mda_text.mod
+MARKER_FILES += mda_text.marker
+CLEANFILES += mda_text.marker
+
+mda_text.marker: $(mda_text_module_SOURCES) $(nodist_mda_text_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += mda_text.module
+MODULE_FILES += mda_text.module$(EXEEXT)
+mda_text_module_SOURCES = term/i386/pc/mda_text.c ## platform sources
+nodist_mda_text_module_SOURCES = ## platform nodist sources
+mda_text_module_LDADD =
+mda_text_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mda_text_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mda_text_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mda_text_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mda_text_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mda_text_module_SOURCES)
+CLEANFILES += $(nodist_mda_text_module_SOURCES)
+MOD_FILES += mda_text.mod
+MARKER_FILES += mda_text.marker
+CLEANFILES += mda_text.marker
+
+mda_text.marker: $(mda_text_module_SOURCES) $(nodist_mda_text_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += video_cirrus.module
+MODULE_FILES += video_cirrus.module$(EXEEXT)
+video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+video_cirrus_module_LDADD =
+video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_cirrus_module_SOURCES)
+CLEANFILES += $(nodist_video_cirrus_module_SOURCES)
+MOD_FILES += video_cirrus.mod
+MARKER_FILES += video_cirrus.marker
+CLEANFILES += video_cirrus.marker
+
+video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += video_cirrus.module
+MODULE_FILES += video_cirrus.module$(EXEEXT)
+video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+video_cirrus_module_LDADD =
+video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_cirrus_module_SOURCES)
+CLEANFILES += $(nodist_video_cirrus_module_SOURCES)
+MOD_FILES += video_cirrus.mod
+MARKER_FILES += video_cirrus.marker
+CLEANFILES += video_cirrus.marker
+
+video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += video_cirrus.module
+MODULE_FILES += video_cirrus.module$(EXEEXT)
+video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+video_cirrus_module_LDADD =
+video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_cirrus_module_SOURCES)
+CLEANFILES += $(nodist_video_cirrus_module_SOURCES)
+MOD_FILES += video_cirrus.mod
+MARKER_FILES += video_cirrus.marker
+CLEANFILES += video_cirrus.marker
+
+video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += video_cirrus.module
+MODULE_FILES += video_cirrus.module$(EXEEXT)
+video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+video_cirrus_module_LDADD =
+video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_cirrus_module_SOURCES)
+CLEANFILES += $(nodist_video_cirrus_module_SOURCES)
+MOD_FILES += video_cirrus.mod
+MARKER_FILES += video_cirrus.marker
+CLEANFILES += video_cirrus.marker
+
+video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += video_cirrus.module
+MODULE_FILES += video_cirrus.module$(EXEEXT)
+video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+video_cirrus_module_LDADD =
+video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_cirrus_module_SOURCES)
+CLEANFILES += $(nodist_video_cirrus_module_SOURCES)
+MOD_FILES += video_cirrus.mod
+MARKER_FILES += video_cirrus.marker
+CLEANFILES += video_cirrus.marker
+
+video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += video_cirrus.module
+MODULE_FILES += video_cirrus.module$(EXEEXT)
+video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+video_cirrus_module_LDADD =
+video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_cirrus_module_SOURCES)
+CLEANFILES += $(nodist_video_cirrus_module_SOURCES)
+MOD_FILES += video_cirrus.mod
+MARKER_FILES += video_cirrus.marker
+CLEANFILES += video_cirrus.marker
+
+video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += video_cirrus.module
+MODULE_FILES += video_cirrus.module$(EXEEXT)
+video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+video_cirrus_module_LDADD =
+video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_cirrus_module_SOURCES)
+CLEANFILES += $(nodist_video_cirrus_module_SOURCES)
+MOD_FILES += video_cirrus.mod
+MARKER_FILES += video_cirrus.marker
+CLEANFILES += video_cirrus.marker
+
+video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += video_bochs.module
+MODULE_FILES += video_bochs.module$(EXEEXT)
+video_bochs_module_SOURCES = video/bochs.c ## platform sources
+nodist_video_bochs_module_SOURCES = ## platform nodist sources
+video_bochs_module_LDADD =
+video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_bochs_module_SOURCES)
+CLEANFILES += $(nodist_video_bochs_module_SOURCES)
+MOD_FILES += video_bochs.mod
+MARKER_FILES += video_bochs.marker
+CLEANFILES += video_bochs.marker
+
+video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += video_bochs.module
+MODULE_FILES += video_bochs.module$(EXEEXT)
+video_bochs_module_SOURCES = video/bochs.c ## platform sources
+nodist_video_bochs_module_SOURCES = ## platform nodist sources
+video_bochs_module_LDADD =
+video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_bochs_module_SOURCES)
+CLEANFILES += $(nodist_video_bochs_module_SOURCES)
+MOD_FILES += video_bochs.mod
+MARKER_FILES += video_bochs.marker
+CLEANFILES += video_bochs.marker
+
+video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += video_bochs.module
+MODULE_FILES += video_bochs.module$(EXEEXT)
+video_bochs_module_SOURCES = video/bochs.c ## platform sources
+nodist_video_bochs_module_SOURCES = ## platform nodist sources
+video_bochs_module_LDADD =
+video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_bochs_module_SOURCES)
+CLEANFILES += $(nodist_video_bochs_module_SOURCES)
+MOD_FILES += video_bochs.mod
+MARKER_FILES += video_bochs.marker
+CLEANFILES += video_bochs.marker
+
+video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += video_bochs.module
+MODULE_FILES += video_bochs.module$(EXEEXT)
+video_bochs_module_SOURCES = video/bochs.c ## platform sources
+nodist_video_bochs_module_SOURCES = ## platform nodist sources
+video_bochs_module_LDADD =
+video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_bochs_module_SOURCES)
+CLEANFILES += $(nodist_video_bochs_module_SOURCES)
+MOD_FILES += video_bochs.mod
+MARKER_FILES += video_bochs.marker
+CLEANFILES += video_bochs.marker
+
+video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += video_bochs.module
+MODULE_FILES += video_bochs.module$(EXEEXT)
+video_bochs_module_SOURCES = video/bochs.c ## platform sources
+nodist_video_bochs_module_SOURCES = ## platform nodist sources
+video_bochs_module_LDADD =
+video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_bochs_module_SOURCES)
+CLEANFILES += $(nodist_video_bochs_module_SOURCES)
+MOD_FILES += video_bochs.mod
+MARKER_FILES += video_bochs.marker
+CLEANFILES += video_bochs.marker
+
+video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += video_bochs.module
+MODULE_FILES += video_bochs.module$(EXEEXT)
+video_bochs_module_SOURCES = video/bochs.c ## platform sources
+nodist_video_bochs_module_SOURCES = ## platform nodist sources
+video_bochs_module_LDADD =
+video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_bochs_module_SOURCES)
+CLEANFILES += $(nodist_video_bochs_module_SOURCES)
+MOD_FILES += video_bochs.mod
+MARKER_FILES += video_bochs.marker
+CLEANFILES += video_bochs.marker
+
+video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += video_bochs.module
+MODULE_FILES += video_bochs.module$(EXEEXT)
+video_bochs_module_SOURCES = video/bochs.c ## platform sources
+nodist_video_bochs_module_SOURCES = ## platform nodist sources
+video_bochs_module_LDADD =
+video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_bochs_module_SOURCES)
+CLEANFILES += $(nodist_video_bochs_module_SOURCES)
+MOD_FILES += video_bochs.mod
+MARKER_FILES += video_bochs.marker
+CLEANFILES += video_bochs.marker
+
+video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += functional_test.module
+MODULE_FILES += functional_test.module$(EXEEXT)
+functional_test_module_SOURCES = tests/lib/functional_test.c tests/lib/test.c tests/checksums.h tests/video_checksum.c tests/fake_input.c video/capture.c ## platform sources
+nodist_functional_test_module_SOURCES = ## platform nodist sources
+functional_test_module_LDADD =
+functional_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+functional_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+functional_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+functional_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+functional_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_functional_test_module_SOURCES)
+CLEANFILES += $(nodist_functional_test_module_SOURCES)
+MOD_FILES += functional_test.mod
+MARKER_FILES += functional_test.marker
+CLEANFILES += functional_test.marker
+
+functional_test.marker: $(functional_test_module_SOURCES) $(nodist_functional_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += exfctest.module
+MODULE_FILES += exfctest.module$(EXEEXT)
+exfctest_module_SOURCES = tests/example_functional_test.c ## platform sources
+nodist_exfctest_module_SOURCES = ## platform nodist sources
+exfctest_module_LDADD =
+exfctest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+exfctest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+exfctest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+exfctest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+exfctest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_exfctest_module_SOURCES)
+CLEANFILES += $(nodist_exfctest_module_SOURCES)
+MOD_FILES += exfctest.mod
+MARKER_FILES += exfctest.marker
+CLEANFILES += exfctest.marker
+
+exfctest.marker: $(exfctest_module_SOURCES) $(nodist_exfctest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfctest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += strtoull_test.module
+MODULE_FILES += strtoull_test.module$(EXEEXT)
+strtoull_test_module_SOURCES = tests/strtoull_test.c ## platform sources
+nodist_strtoull_test_module_SOURCES = ## platform nodist sources
+strtoull_test_module_LDADD =
+strtoull_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+strtoull_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+strtoull_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+strtoull_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+strtoull_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_strtoull_test_module_SOURCES)
+CLEANFILES += $(nodist_strtoull_test_module_SOURCES)
+MOD_FILES += strtoull_test.mod
+MARKER_FILES += strtoull_test.marker
+CLEANFILES += strtoull_test.marker
+
+strtoull_test.marker: $(strtoull_test_module_SOURCES) $(nodist_strtoull_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(strtoull_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += setjmp_test.module
+MODULE_FILES += setjmp_test.module$(EXEEXT)
+setjmp_test_module_SOURCES = tests/setjmp_test.c ## platform sources
+nodist_setjmp_test_module_SOURCES = ## platform nodist sources
+setjmp_test_module_LDADD =
+setjmp_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setjmp_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setjmp_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setjmp_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setjmp_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_setjmp_test_module_SOURCES)
+CLEANFILES += $(nodist_setjmp_test_module_SOURCES)
+MOD_FILES += setjmp_test.mod
+MARKER_FILES += setjmp_test.marker
+CLEANFILES += setjmp_test.marker
+
+setjmp_test.marker: $(setjmp_test_module_SOURCES) $(nodist_setjmp_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += signature_test.module
+MODULE_FILES += signature_test.module$(EXEEXT)
+signature_test_module_SOURCES = tests/signature_test.c tests/signatures.h ## platform sources
+nodist_signature_test_module_SOURCES = ## platform nodist sources
+signature_test_module_LDADD =
+signature_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+signature_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+signature_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+signature_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+signature_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_signature_test_module_SOURCES)
+CLEANFILES += $(nodist_signature_test_module_SOURCES)
+MOD_FILES += signature_test.mod
+MARKER_FILES += signature_test.marker
+CLEANFILES += signature_test.marker
+
+signature_test.marker: $(signature_test_module_SOURCES) $(nodist_signature_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(signature_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += sleep_test.module
+MODULE_FILES += sleep_test.module$(EXEEXT)
+sleep_test_module_SOURCES = tests/sleep_test.c ## platform sources
+nodist_sleep_test_module_SOURCES = ## platform nodist sources
+sleep_test_module_LDADD =
+sleep_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+sleep_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+sleep_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+sleep_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+sleep_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_sleep_test_module_SOURCES)
+CLEANFILES += $(nodist_sleep_test_module_SOURCES)
+MOD_FILES += sleep_test.mod
+MARKER_FILES += sleep_test.marker
+CLEANFILES += sleep_test.marker
+
+sleep_test.marker: $(sleep_test_module_SOURCES) $(nodist_sleep_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += xnu_uuid_test.module
+MODULE_FILES += xnu_uuid_test.module$(EXEEXT)
+xnu_uuid_test_module_SOURCES = tests/xnu_uuid_test.c ## platform sources
+nodist_xnu_uuid_test_module_SOURCES = ## platform nodist sources
+xnu_uuid_test_module_LDADD =
+xnu_uuid_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xnu_uuid_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xnu_uuid_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xnu_uuid_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xnu_uuid_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xnu_uuid_test_module_SOURCES)
+CLEANFILES += $(nodist_xnu_uuid_test_module_SOURCES)
+MOD_FILES += xnu_uuid_test.mod
+MARKER_FILES += xnu_uuid_test.marker
+CLEANFILES += xnu_uuid_test.marker
+
+xnu_uuid_test.marker: $(xnu_uuid_test_module_SOURCES) $(nodist_xnu_uuid_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += pbkdf2_test.module
+MODULE_FILES += pbkdf2_test.module$(EXEEXT)
+pbkdf2_test_module_SOURCES = tests/pbkdf2_test.c ## platform sources
+nodist_pbkdf2_test_module_SOURCES = ## platform nodist sources
+pbkdf2_test_module_LDADD =
+pbkdf2_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pbkdf2_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pbkdf2_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pbkdf2_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pbkdf2_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pbkdf2_test_module_SOURCES)
+CLEANFILES += $(nodist_pbkdf2_test_module_SOURCES)
+MOD_FILES += pbkdf2_test.mod
+MARKER_FILES += pbkdf2_test.marker
+CLEANFILES += pbkdf2_test.marker
+
+pbkdf2_test.marker: $(pbkdf2_test_module_SOURCES) $(nodist_pbkdf2_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_emu
+platform_PROGRAMS += legacy_password_test.module
+MODULE_FILES += legacy_password_test.module$(EXEEXT)
+legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+legacy_password_test_module_LDADD =
+legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacy_password_test_module_SOURCES)
+CLEANFILES += $(nodist_legacy_password_test_module_SOURCES)
+MOD_FILES += legacy_password_test.mod
+MARKER_FILES += legacy_password_test.marker
+CLEANFILES += legacy_password_test.marker
+
+legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += legacy_password_test.module
+MODULE_FILES += legacy_password_test.module$(EXEEXT)
+legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+legacy_password_test_module_LDADD =
+legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacy_password_test_module_SOURCES)
+CLEANFILES += $(nodist_legacy_password_test_module_SOURCES)
+MOD_FILES += legacy_password_test.mod
+MARKER_FILES += legacy_password_test.marker
+CLEANFILES += legacy_password_test.marker
+
+legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += legacy_password_test.module
+MODULE_FILES += legacy_password_test.module$(EXEEXT)
+legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+legacy_password_test_module_LDADD =
+legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacy_password_test_module_SOURCES)
+CLEANFILES += $(nodist_legacy_password_test_module_SOURCES)
+MOD_FILES += legacy_password_test.mod
+MARKER_FILES += legacy_password_test.marker
+CLEANFILES += legacy_password_test.marker
+
+legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += legacy_password_test.module
+MODULE_FILES += legacy_password_test.module$(EXEEXT)
+legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+legacy_password_test_module_LDADD =
+legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacy_password_test_module_SOURCES)
+CLEANFILES += $(nodist_legacy_password_test_module_SOURCES)
+MOD_FILES += legacy_password_test.mod
+MARKER_FILES += legacy_password_test.marker
+CLEANFILES += legacy_password_test.marker
+
+legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += legacy_password_test.module
+MODULE_FILES += legacy_password_test.module$(EXEEXT)
+legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+legacy_password_test_module_LDADD =
+legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacy_password_test_module_SOURCES)
+CLEANFILES += $(nodist_legacy_password_test_module_SOURCES)
+MOD_FILES += legacy_password_test.mod
+MARKER_FILES += legacy_password_test.marker
+CLEANFILES += legacy_password_test.marker
+
+legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += legacy_password_test.module
+MODULE_FILES += legacy_password_test.module$(EXEEXT)
+legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+legacy_password_test_module_LDADD =
+legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacy_password_test_module_SOURCES)
+CLEANFILES += $(nodist_legacy_password_test_module_SOURCES)
+MOD_FILES += legacy_password_test.mod
+MARKER_FILES += legacy_password_test.marker
+CLEANFILES += legacy_password_test.marker
+
+legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += legacy_password_test.module
+MODULE_FILES += legacy_password_test.module$(EXEEXT)
+legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+legacy_password_test_module_LDADD =
+legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacy_password_test_module_SOURCES)
+CLEANFILES += $(nodist_legacy_password_test_module_SOURCES)
+MOD_FILES += legacy_password_test.mod
+MARKER_FILES += legacy_password_test.marker
+CLEANFILES += legacy_password_test.marker
+
+legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += div.module
+MODULE_FILES += div.module$(EXEEXT)
+div_module_SOURCES = lib/division.c ## platform sources
+nodist_div_module_SOURCES = ## platform nodist sources
+div_module_LDADD =
+div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_module_SOURCES)
+CLEANFILES += $(nodist_div_module_SOURCES)
+MOD_FILES += div.mod
+MARKER_FILES += div.marker
+CLEANFILES += div.marker
+
+div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += div_test.module
+MODULE_FILES += div_test.module$(EXEEXT)
+div_test_module_SOURCES = tests/div_test.c ## platform sources
+nodist_div_test_module_SOURCES = ## platform nodist sources
+div_test_module_LDADD =
+div_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_div_test_module_SOURCES)
+CLEANFILES += $(nodist_div_test_module_SOURCES)
+MOD_FILES += div_test.mod
+MARKER_FILES += div_test.marker
+CLEANFILES += div_test.marker
+
+div_test.marker: $(div_test_module_SOURCES) $(nodist_div_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += mul_test.module
+MODULE_FILES += mul_test.module$(EXEEXT)
+mul_test_module_SOURCES = tests/mul_test.c ## platform sources
+nodist_mul_test_module_SOURCES = ## platform nodist sources
+mul_test_module_LDADD =
+mul_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mul_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mul_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mul_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mul_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mul_test_module_SOURCES)
+CLEANFILES += $(nodist_mul_test_module_SOURCES)
+MOD_FILES += mul_test.mod
+MARKER_FILES += mul_test.marker
+CLEANFILES += mul_test.marker
+
+mul_test.marker: $(mul_test_module_SOURCES) $(nodist_mul_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mul_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += shift_test.module
+MODULE_FILES += shift_test.module$(EXEEXT)
+shift_test_module_SOURCES = tests/shift_test.c ## platform sources
+nodist_shift_test_module_SOURCES = ## platform nodist sources
+shift_test_module_LDADD =
+shift_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+shift_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+shift_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+shift_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+shift_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_shift_test_module_SOURCES)
+CLEANFILES += $(nodist_shift_test_module_SOURCES)
+MOD_FILES += shift_test.mod
+MARKER_FILES += shift_test.marker
+CLEANFILES += shift_test.marker
+
+shift_test.marker: $(shift_test_module_SOURCES) $(nodist_shift_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(shift_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += cmp_test.module
+MODULE_FILES += cmp_test.module$(EXEEXT)
+cmp_test_module_SOURCES = tests/cmp_test.c ## platform sources
+nodist_cmp_test_module_SOURCES = ## platform nodist sources
+cmp_test_module_LDADD =
+cmp_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmp_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmp_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmp_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmp_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmp_test_module_SOURCES)
+CLEANFILES += $(nodist_cmp_test_module_SOURCES)
+MOD_FILES += cmp_test.mod
+MARKER_FILES += cmp_test.marker
+CLEANFILES += cmp_test.marker
+
+cmp_test.marker: $(cmp_test_module_SOURCES) $(nodist_cmp_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += ctz_test.module
+MODULE_FILES += ctz_test.module$(EXEEXT)
+ctz_test_module_SOURCES = tests/ctz_test.c ## platform sources
+nodist_ctz_test_module_SOURCES = ## platform nodist sources
+ctz_test_module_LDADD =
+ctz_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ctz_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ctz_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ctz_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ctz_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ctz_test_module_SOURCES)
+CLEANFILES += $(nodist_ctz_test_module_SOURCES)
+MOD_FILES += ctz_test.mod
+MARKER_FILES += ctz_test.marker
+CLEANFILES += ctz_test.marker
+
+ctz_test.marker: $(ctz_test_module_SOURCES) $(nodist_ctz_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ctz_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += bswap_test.module
+MODULE_FILES += bswap_test.module$(EXEEXT)
+bswap_test_module_SOURCES = tests/bswap_test.c ## platform sources
+nodist_bswap_test_module_SOURCES = ## platform nodist sources
+bswap_test_module_LDADD =
+bswap_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bswap_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bswap_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bswap_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bswap_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bswap_test_module_SOURCES)
+CLEANFILES += $(nodist_bswap_test_module_SOURCES)
+MOD_FILES += bswap_test.mod
+MARKER_FILES += bswap_test.marker
+CLEANFILES += bswap_test.marker
+
+bswap_test.marker: $(bswap_test_module_SOURCES) $(nodist_bswap_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bswap_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += videotest_checksum.module
+MODULE_FILES += videotest_checksum.module$(EXEEXT)
+videotest_checksum_module_SOURCES = tests/videotest_checksum.c ## platform sources
+nodist_videotest_checksum_module_SOURCES = ## platform nodist sources
+videotest_checksum_module_LDADD =
+videotest_checksum_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+videotest_checksum_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+videotest_checksum_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+videotest_checksum_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+videotest_checksum_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_videotest_checksum_module_SOURCES)
+CLEANFILES += $(nodist_videotest_checksum_module_SOURCES)
+MOD_FILES += videotest_checksum.mod
+MARKER_FILES += videotest_checksum.marker
+CLEANFILES += videotest_checksum.marker
+
+videotest_checksum.marker: $(videotest_checksum_module_SOURCES) $(nodist_videotest_checksum_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_checksum_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gfxterm_menu.module
+MODULE_FILES += gfxterm_menu.module$(EXEEXT)
+gfxterm_menu_module_SOURCES = tests/gfxterm_menu.c ## platform sources
+nodist_gfxterm_menu_module_SOURCES = ## platform nodist sources
+gfxterm_menu_module_LDADD =
+gfxterm_menu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_menu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_menu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_menu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_menu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gfxterm_menu_module_SOURCES)
+CLEANFILES += $(nodist_gfxterm_menu_module_SOURCES)
+MOD_FILES += gfxterm_menu.mod
+MARKER_FILES += gfxterm_menu.marker
+CLEANFILES += gfxterm_menu.marker
+
+gfxterm_menu.marker: $(gfxterm_menu_module_SOURCES) $(nodist_gfxterm_menu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_menu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += cmdline_cat_test.module
+MODULE_FILES += cmdline_cat_test.module$(EXEEXT)
+cmdline_cat_test_module_SOURCES = tests/cmdline_cat_test.c ## platform sources
+nodist_cmdline_cat_test_module_SOURCES = ## platform nodist sources
+cmdline_cat_test_module_LDADD =
+cmdline_cat_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmdline_cat_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmdline_cat_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmdline_cat_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmdline_cat_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cmdline_cat_test_module_SOURCES)
+CLEANFILES += $(nodist_cmdline_cat_test_module_SOURCES)
+MOD_FILES += cmdline_cat_test.mod
+MARKER_FILES += cmdline_cat_test.marker
+CLEANFILES += cmdline_cat_test.marker
+
+cmdline_cat_test.marker: $(cmdline_cat_test_module_SOURCES) $(nodist_cmdline_cat_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmdline_cat_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += bitmap.module
+MODULE_FILES += bitmap.module$(EXEEXT)
+bitmap_module_SOURCES = video/bitmap.c ## platform sources
+nodist_bitmap_module_SOURCES = ## platform nodist sources
+bitmap_module_LDADD =
+bitmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bitmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bitmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bitmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bitmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bitmap_module_SOURCES)
+CLEANFILES += $(nodist_bitmap_module_SOURCES)
+MOD_FILES += bitmap.mod
+MARKER_FILES += bitmap.marker
+CLEANFILES += bitmap.marker
+
+bitmap.marker: $(bitmap_module_SOURCES) $(nodist_bitmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += bitmap_scale.module
+MODULE_FILES += bitmap_scale.module$(EXEEXT)
+bitmap_scale_module_SOURCES = video/bitmap_scale.c ## platform sources
+nodist_bitmap_scale_module_SOURCES = ## platform nodist sources
+bitmap_scale_module_LDADD =
+bitmap_scale_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bitmap_scale_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bitmap_scale_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bitmap_scale_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bitmap_scale_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_bitmap_scale_module_SOURCES)
+CLEANFILES += $(nodist_bitmap_scale_module_SOURCES)
+MOD_FILES += bitmap_scale.mod
+MARKER_FILES += bitmap_scale.marker
+CLEANFILES += bitmap_scale.marker
+
+bitmap_scale.marker: $(bitmap_scale_module_SOURCES) $(nodist_bitmap_scale_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_scale_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_efi
+platform_PROGRAMS += efi_gop.module
+MODULE_FILES += efi_gop.module$(EXEEXT)
+efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+nodist_efi_gop_module_SOURCES = ## platform nodist sources
+efi_gop_module_LDADD =
+efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efi_gop_module_SOURCES)
+CLEANFILES += $(nodist_efi_gop_module_SOURCES)
+MOD_FILES += efi_gop.mod
+MARKER_FILES += efi_gop.marker
+CLEANFILES += efi_gop.marker
+
+efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += efi_gop.module
+MODULE_FILES += efi_gop.module$(EXEEXT)
+efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+nodist_efi_gop_module_SOURCES = ## platform nodist sources
+efi_gop_module_LDADD =
+efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efi_gop_module_SOURCES)
+CLEANFILES += $(nodist_efi_gop_module_SOURCES)
+MOD_FILES += efi_gop.mod
+MARKER_FILES += efi_gop.marker
+CLEANFILES += efi_gop.marker
+
+efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += efi_gop.module
+MODULE_FILES += efi_gop.module$(EXEEXT)
+efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+nodist_efi_gop_module_SOURCES = ## platform nodist sources
+efi_gop_module_LDADD =
+efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efi_gop_module_SOURCES)
+CLEANFILES += $(nodist_efi_gop_module_SOURCES)
+MOD_FILES += efi_gop.mod
+MARKER_FILES += efi_gop.marker
+CLEANFILES += efi_gop.marker
+
+efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += efi_gop.module
+MODULE_FILES += efi_gop.module$(EXEEXT)
+efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+nodist_efi_gop_module_SOURCES = ## platform nodist sources
+efi_gop_module_LDADD =
+efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efi_gop_module_SOURCES)
+CLEANFILES += $(nodist_efi_gop_module_SOURCES)
+MOD_FILES += efi_gop.mod
+MARKER_FILES += efi_gop.marker
+CLEANFILES += efi_gop.marker
+
+efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += efi_gop.module
+MODULE_FILES += efi_gop.module$(EXEEXT)
+efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+nodist_efi_gop_module_SOURCES = ## platform nodist sources
+efi_gop_module_LDADD =
+efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efi_gop_module_SOURCES)
+CLEANFILES += $(nodist_efi_gop_module_SOURCES)
+MOD_FILES += efi_gop.mod
+MARKER_FILES += efi_gop.marker
+CLEANFILES += efi_gop.marker
+
+efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += efi_gop.module
+MODULE_FILES += efi_gop.module$(EXEEXT)
+efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+nodist_efi_gop_module_SOURCES = ## platform nodist sources
+efi_gop_module_LDADD =
+efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efi_gop_module_SOURCES)
+CLEANFILES += $(nodist_efi_gop_module_SOURCES)
+MOD_FILES += efi_gop.mod
+MARKER_FILES += efi_gop.marker
+CLEANFILES += efi_gop.marker
+
+efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += efi_gop.module
+MODULE_FILES += efi_gop.module$(EXEEXT)
+efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+nodist_efi_gop_module_SOURCES = ## platform nodist sources
+efi_gop_module_LDADD =
+efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efi_gop_module_SOURCES)
+CLEANFILES += $(nodist_efi_gop_module_SOURCES)
+MOD_FILES += efi_gop.mod
+MARKER_FILES += efi_gop.marker
+CLEANFILES += efi_gop.marker
+
+efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += efi_uga.module
+MODULE_FILES += efi_uga.module$(EXEEXT)
+efi_uga_module_SOURCES = video/efi_uga.c ## platform sources
+nodist_efi_uga_module_SOURCES = ## platform nodist sources
+efi_uga_module_LDADD =
+efi_uga_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efi_uga_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efi_uga_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efi_uga_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efi_uga_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efi_uga_module_SOURCES)
+CLEANFILES += $(nodist_efi_uga_module_SOURCES)
+MOD_FILES += efi_uga.mod
+MARKER_FILES += efi_uga.marker
+CLEANFILES += efi_uga.marker
+
+efi_uga.marker: $(efi_uga_module_SOURCES) $(nodist_efi_uga_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_uga_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += efi_uga.module
+MODULE_FILES += efi_uga.module$(EXEEXT)
+efi_uga_module_SOURCES = video/efi_uga.c ## platform sources
+nodist_efi_uga_module_SOURCES = ## platform nodist sources
+efi_uga_module_LDADD =
+efi_uga_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efi_uga_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efi_uga_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efi_uga_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efi_uga_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efi_uga_module_SOURCES)
+CLEANFILES += $(nodist_efi_uga_module_SOURCES)
+MOD_FILES += efi_uga.mod
+MARKER_FILES += efi_uga.marker
+CLEANFILES += efi_uga.marker
+
+efi_uga.marker: $(efi_uga_module_SOURCES) $(nodist_efi_uga_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_uga_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += jpeg.module
+MODULE_FILES += jpeg.module$(EXEEXT)
+jpeg_module_SOURCES = video/readers/jpeg.c ## platform sources
+nodist_jpeg_module_SOURCES = ## platform nodist sources
+jpeg_module_LDADD =
+jpeg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+jpeg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+jpeg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+jpeg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+jpeg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_jpeg_module_SOURCES)
+CLEANFILES += $(nodist_jpeg_module_SOURCES)
+MOD_FILES += jpeg.mod
+MARKER_FILES += jpeg.marker
+CLEANFILES += jpeg.marker
+
+jpeg.marker: $(jpeg_module_SOURCES) $(nodist_jpeg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jpeg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += png.module
+MODULE_FILES += png.module$(EXEEXT)
+png_module_SOURCES = video/readers/png.c ## platform sources
+nodist_png_module_SOURCES = ## platform nodist sources
+png_module_LDADD =
+png_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+png_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+png_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+png_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+png_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_png_module_SOURCES)
+CLEANFILES += $(nodist_png_module_SOURCES)
+MOD_FILES += png.mod
+MARKER_FILES += png.marker
+CLEANFILES += png.marker
+
+png.marker: $(png_module_SOURCES) $(nodist_png_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(png_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += tga.module
+MODULE_FILES += tga.module$(EXEEXT)
+tga_module_SOURCES = video/readers/tga.c ## platform sources
+nodist_tga_module_SOURCES = ## platform nodist sources
+tga_module_LDADD =
+tga_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tga_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tga_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tga_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tga_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tga_module_SOURCES)
+CLEANFILES += $(nodist_tga_module_SOURCES)
+MOD_FILES += tga.mod
+MARKER_FILES += tga.marker
+CLEANFILES += tga.marker
+
+tga.marker: $(tga_module_SOURCES) $(nodist_tga_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tga_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += vbe.module
+MODULE_FILES += vbe.module$(EXEEXT)
+vbe_module_SOURCES = video/i386/pc/vbe.c ## platform sources
+nodist_vbe_module_SOURCES = ## platform nodist sources
+vbe_module_LDADD =
+vbe_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+vbe_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+vbe_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+vbe_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+vbe_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_vbe_module_SOURCES)
+CLEANFILES += $(nodist_vbe_module_SOURCES)
+MOD_FILES += vbe.mod
+MARKER_FILES += vbe.marker
+CLEANFILES += vbe.marker
+
+vbe.marker: $(vbe_module_SOURCES) $(nodist_vbe_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vbe_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += video_fb.module
+MODULE_FILES += video_fb.module$(EXEEXT)
+video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+nodist_video_fb_module_SOURCES = ## platform nodist sources
+video_fb_module_LDADD =
+video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_fb_module_SOURCES)
+CLEANFILES += $(nodist_video_fb_module_SOURCES)
+MOD_FILES += video_fb.mod
+MARKER_FILES += video_fb.marker
+CLEANFILES += video_fb.marker
+
+video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += video.module
+MODULE_FILES += video.module$(EXEEXT)
+video_module_SOURCES = video/video.c ## platform sources
+nodist_video_module_SOURCES = ## platform nodist sources
+video_module_LDADD =
+video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_module_SOURCES)
+CLEANFILES += $(nodist_video_module_SOURCES)
+MOD_FILES += video.mod
+MARKER_FILES += video.marker
+CLEANFILES += video.marker
+
+video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += video_colors.module
+MODULE_FILES += video_colors.module$(EXEEXT)
+video_colors_module_SOURCES = video/colors.c ## platform sources
+nodist_video_colors_module_SOURCES = ## platform nodist sources
+video_colors_module_LDADD =
+video_colors_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_colors_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_colors_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_colors_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_colors_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_video_colors_module_SOURCES)
+CLEANFILES += $(nodist_video_colors_module_SOURCES)
+MOD_FILES += video_colors.mod
+MARKER_FILES += video_colors.marker
+CLEANFILES += video_colors.marker
+
+video_colors.marker: $(video_colors_module_SOURCES) $(nodist_video_colors_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_colors_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += ieee1275_fb.module
+MODULE_FILES += ieee1275_fb.module$(EXEEXT)
+ieee1275_fb_module_SOURCES = video/ieee1275.c ## platform sources
+nodist_ieee1275_fb_module_SOURCES = ## platform nodist sources
+ieee1275_fb_module_LDADD =
+ieee1275_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ieee1275_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ieee1275_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ieee1275_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ieee1275_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ieee1275_fb_module_SOURCES)
+CLEANFILES += $(nodist_ieee1275_fb_module_SOURCES)
+MOD_FILES += ieee1275_fb.mod
+MARKER_FILES += ieee1275_fb.marker
+CLEANFILES += ieee1275_fb.marker
+
+ieee1275_fb.marker: $(ieee1275_fb_module_SOURCES) $(nodist_ieee1275_fb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ieee1275_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+if COND_GRUB_EMU_SDL
+platform_PROGRAMS += sdl.module
+MODULE_FILES += sdl.module$(EXEEXT)
+sdl_module_SOURCES = video/emu/sdl.c ## platform sources
+nodist_sdl_module_SOURCES = ## platform nodist sources
+sdl_module_LDADD =
+sdl_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+sdl_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+sdl_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+sdl_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+sdl_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_sdl_module_SOURCES)
+CLEANFILES += $(nodist_sdl_module_SOURCES)
+MOD_FILES += sdl.mod
+MARKER_FILES += sdl.marker
+CLEANFILES += sdl.marker
+
+sdl.marker: $(sdl_module_SOURCES) $(nodist_sdl_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sdl_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif COND_GRUB_EMU_SDL
+endif
+platform_PROGRAMS += datehook.module
+MODULE_FILES += datehook.module$(EXEEXT)
+datehook_module_SOURCES = hook/datehook.c ## platform sources
+nodist_datehook_module_SOURCES = ## platform nodist sources
+datehook_module_LDADD =
+datehook_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datehook_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datehook_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datehook_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datehook_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_datehook_module_SOURCES)
+CLEANFILES += $(nodist_datehook_module_SOURCES)
+MOD_FILES += datehook.mod
+MARKER_FILES += datehook.marker
+CLEANFILES += datehook.marker
+
+datehook.marker: $(datehook_module_SOURCES) $(nodist_datehook_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datehook_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += net.module
+MODULE_FILES += net.module$(EXEEXT)
+net_module_SOURCES = net/net.c net/dns.c net/bootp.c net/ip.c net/udp.c net/tcp.c net/icmp.c net/icmp6.c net/ethernet.c net/arp.c net/netbuff.c ## platform sources
+nodist_net_module_SOURCES = ## platform nodist sources
+net_module_LDADD =
+net_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+net_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+net_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+net_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+net_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_net_module_SOURCES)
+CLEANFILES += $(nodist_net_module_SOURCES)
+MOD_FILES += net.mod
+MARKER_FILES += net.marker
+CLEANFILES += net.marker
+
+net.marker: $(net_module_SOURCES) $(nodist_net_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += tftp.module
+MODULE_FILES += tftp.module$(EXEEXT)
+tftp_module_SOURCES = net/tftp.c ## platform sources
+nodist_tftp_module_SOURCES = ## platform nodist sources
+tftp_module_LDADD =
+tftp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tftp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tftp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tftp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tftp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tftp_module_SOURCES)
+CLEANFILES += $(nodist_tftp_module_SOURCES)
+MOD_FILES += tftp.mod
+MARKER_FILES += tftp.marker
+CLEANFILES += tftp.marker
+
+tftp.marker: $(tftp_module_SOURCES) $(nodist_tftp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tftp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += http.module
+MODULE_FILES += http.module$(EXEEXT)
+http_module_SOURCES = net/http.c ## platform sources
+nodist_http_module_SOURCES = ## platform nodist sources
+http_module_LDADD =
+http_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+http_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+http_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+http_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+http_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_http_module_SOURCES)
+CLEANFILES += $(nodist_http_module_SOURCES)
+MOD_FILES += http.mod
+MARKER_FILES += http.marker
+CLEANFILES += http.marker
+
+http.marker: $(http_module_SOURCES) $(nodist_http_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(http_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_ieee1275
+platform_PROGRAMS += ofnet.module
+MODULE_FILES += ofnet.module$(EXEEXT)
+ofnet_module_SOURCES = net/drivers/ieee1275/ofnet.c ## platform sources
+nodist_ofnet_module_SOURCES = ## platform nodist sources
+ofnet_module_LDADD =
+ofnet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ofnet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ofnet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ofnet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ofnet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ofnet_module_SOURCES)
+CLEANFILES += $(nodist_ofnet_module_SOURCES)
+MOD_FILES += ofnet.mod
+MARKER_FILES += ofnet.marker
+CLEANFILES += ofnet.marker
+
+ofnet.marker: $(ofnet_module_SOURCES) $(nodist_ofnet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ofnet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += ofnet.module
+MODULE_FILES += ofnet.module$(EXEEXT)
+ofnet_module_SOURCES = net/drivers/ieee1275/ofnet.c ## platform sources
+nodist_ofnet_module_SOURCES = ## platform nodist sources
+ofnet_module_LDADD =
+ofnet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ofnet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ofnet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ofnet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ofnet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ofnet_module_SOURCES)
+CLEANFILES += $(nodist_ofnet_module_SOURCES)
+MOD_FILES += ofnet.mod
+MARKER_FILES += ofnet.marker
+CLEANFILES += ofnet.marker
+
+ofnet.marker: $(ofnet_module_SOURCES) $(nodist_ofnet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ofnet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += ofnet.module
+MODULE_FILES += ofnet.module$(EXEEXT)
+ofnet_module_SOURCES = net/drivers/ieee1275/ofnet.c ## platform sources
+nodist_ofnet_module_SOURCES = ## platform nodist sources
+ofnet_module_LDADD =
+ofnet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ofnet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ofnet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ofnet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ofnet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ofnet_module_SOURCES)
+CLEANFILES += $(nodist_ofnet_module_SOURCES)
+MOD_FILES += ofnet.mod
+MARKER_FILES += ofnet.marker
+CLEANFILES += ofnet.marker
+
+ofnet.marker: $(ofnet_module_SOURCES) $(nodist_ofnet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ofnet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += ubootnet.module
+MODULE_FILES += ubootnet.module$(EXEEXT)
+ubootnet_module_SOURCES = net/drivers/uboot/ubootnet.c ## platform sources
+nodist_ubootnet_module_SOURCES = ## platform nodist sources
+ubootnet_module_LDADD =
+ubootnet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ubootnet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ubootnet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ubootnet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ubootnet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_ubootnet_module_SOURCES)
+CLEANFILES += $(nodist_ubootnet_module_SOURCES)
+MOD_FILES += ubootnet.mod
+MARKER_FILES += ubootnet.marker
+CLEANFILES += ubootnet.marker
+
+ubootnet.marker: $(ubootnet_module_SOURCES) $(nodist_ubootnet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ubootnet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += efinet.module
+MODULE_FILES += efinet.module$(EXEEXT)
+efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+nodist_efinet_module_SOURCES = ## platform nodist sources
+efinet_module_LDADD =
+efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efinet_module_SOURCES)
+CLEANFILES += $(nodist_efinet_module_SOURCES)
+MOD_FILES += efinet.mod
+MARKER_FILES += efinet.marker
+CLEANFILES += efinet.marker
+
+efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += efinet.module
+MODULE_FILES += efinet.module$(EXEEXT)
+efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+nodist_efinet_module_SOURCES = ## platform nodist sources
+efinet_module_LDADD =
+efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efinet_module_SOURCES)
+CLEANFILES += $(nodist_efinet_module_SOURCES)
+MOD_FILES += efinet.mod
+MARKER_FILES += efinet.marker
+CLEANFILES += efinet.marker
+
+efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += efinet.module
+MODULE_FILES += efinet.module$(EXEEXT)
+efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+nodist_efinet_module_SOURCES = ## platform nodist sources
+efinet_module_LDADD =
+efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efinet_module_SOURCES)
+CLEANFILES += $(nodist_efinet_module_SOURCES)
+MOD_FILES += efinet.mod
+MARKER_FILES += efinet.marker
+CLEANFILES += efinet.marker
+
+efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += efinet.module
+MODULE_FILES += efinet.module$(EXEEXT)
+efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+nodist_efinet_module_SOURCES = ## platform nodist sources
+efinet_module_LDADD =
+efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efinet_module_SOURCES)
+CLEANFILES += $(nodist_efinet_module_SOURCES)
+MOD_FILES += efinet.mod
+MARKER_FILES += efinet.marker
+CLEANFILES += efinet.marker
+
+efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += efinet.module
+MODULE_FILES += efinet.module$(EXEEXT)
+efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+nodist_efinet_module_SOURCES = ## platform nodist sources
+efinet_module_LDADD =
+efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efinet_module_SOURCES)
+CLEANFILES += $(nodist_efinet_module_SOURCES)
+MOD_FILES += efinet.mod
+MARKER_FILES += efinet.marker
+CLEANFILES += efinet.marker
+
+efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += efinet.module
+MODULE_FILES += efinet.module$(EXEEXT)
+efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+nodist_efinet_module_SOURCES = ## platform nodist sources
+efinet_module_LDADD =
+efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efinet_module_SOURCES)
+CLEANFILES += $(nodist_efinet_module_SOURCES)
+MOD_FILES += efinet.mod
+MARKER_FILES += efinet.marker
+CLEANFILES += efinet.marker
+
+efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += efinet.module
+MODULE_FILES += efinet.module$(EXEEXT)
+efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+nodist_efinet_module_SOURCES = ## platform nodist sources
+efinet_module_LDADD =
+efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_efinet_module_SOURCES)
+CLEANFILES += $(nodist_efinet_module_SOURCES)
+MOD_FILES += efinet.mod
+MARKER_FILES += efinet.marker
+CLEANFILES += efinet.marker
+
+efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+platform_PROGRAMS += emunet.module
+MODULE_FILES += emunet.module$(EXEEXT)
+emunet_module_SOURCES = net/drivers/emu/emunet.c ## platform sources
+nodist_emunet_module_SOURCES = ## platform nodist sources
+emunet_module_LDADD =
+emunet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+emunet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+emunet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+emunet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+emunet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_emunet_module_SOURCES)
+CLEANFILES += $(nodist_emunet_module_SOURCES)
+MOD_FILES += emunet.mod
+MARKER_FILES += emunet.marker
+CLEANFILES += emunet.marker
+
+emunet.marker: $(emunet_module_SOURCES) $(nodist_emunet_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emunet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_emu
+platform_PROGRAMS += legacycfg.module
+MODULE_FILES += legacycfg.module$(EXEEXT)
+legacycfg_module_SOURCES = lib/i386/pc/vesa_modes_table.c commands/legacycfg.c lib/legacy_parse.c ## platform sources
+nodist_legacycfg_module_SOURCES = ## platform nodist sources
+legacycfg_module_LDADD =
+legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacycfg_module_SOURCES)
+CLEANFILES += $(nodist_legacycfg_module_SOURCES)
+MOD_FILES += legacycfg.mod
+MARKER_FILES += legacycfg.marker
+CLEANFILES += legacycfg.marker
+
+legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += legacycfg.module
+MODULE_FILES += legacycfg.module$(EXEEXT)
+legacycfg_module_SOURCES = commands/legacycfg.c lib/legacy_parse.c ## platform sources
+nodist_legacycfg_module_SOURCES = ## platform nodist sources
+legacycfg_module_LDADD =
+legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacycfg_module_SOURCES)
+CLEANFILES += $(nodist_legacycfg_module_SOURCES)
+MOD_FILES += legacycfg.mod
+MARKER_FILES += legacycfg.marker
+CLEANFILES += legacycfg.marker
+
+legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += legacycfg.module
+MODULE_FILES += legacycfg.module$(EXEEXT)
+legacycfg_module_SOURCES = lib/i386/pc/vesa_modes_table.c commands/legacycfg.c lib/legacy_parse.c ## platform sources
+nodist_legacycfg_module_SOURCES = ## platform nodist sources
+legacycfg_module_LDADD =
+legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacycfg_module_SOURCES)
+CLEANFILES += $(nodist_legacycfg_module_SOURCES)
+MOD_FILES += legacycfg.mod
+MARKER_FILES += legacycfg.marker
+CLEANFILES += legacycfg.marker
+
+legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += legacycfg.module
+MODULE_FILES += legacycfg.module$(EXEEXT)
+legacycfg_module_SOURCES = lib/i386/pc/vesa_modes_table.c commands/legacycfg.c lib/legacy_parse.c ## platform sources
+nodist_legacycfg_module_SOURCES = ## platform nodist sources
+legacycfg_module_LDADD =
+legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacycfg_module_SOURCES)
+CLEANFILES += $(nodist_legacycfg_module_SOURCES)
+MOD_FILES += legacycfg.mod
+MARKER_FILES += legacycfg.marker
+CLEANFILES += legacycfg.marker
+
+legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += legacycfg.module
+MODULE_FILES += legacycfg.module$(EXEEXT)
+legacycfg_module_SOURCES = lib/i386/pc/vesa_modes_table.c commands/legacycfg.c lib/legacy_parse.c ## platform sources
+nodist_legacycfg_module_SOURCES = ## platform nodist sources
+legacycfg_module_LDADD =
+legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacycfg_module_SOURCES)
+CLEANFILES += $(nodist_legacycfg_module_SOURCES)
+MOD_FILES += legacycfg.mod
+MARKER_FILES += legacycfg.marker
+CLEANFILES += legacycfg.marker
+
+legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += legacycfg.module
+MODULE_FILES += legacycfg.module$(EXEEXT)
+legacycfg_module_SOURCES = lib/i386/pc/vesa_modes_table.c commands/legacycfg.c lib/legacy_parse.c ## platform sources
+nodist_legacycfg_module_SOURCES = ## platform nodist sources
+legacycfg_module_LDADD =
+legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacycfg_module_SOURCES)
+CLEANFILES += $(nodist_legacycfg_module_SOURCES)
+MOD_FILES += legacycfg.mod
+MARKER_FILES += legacycfg.marker
+CLEANFILES += legacycfg.marker
+
+legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += legacycfg.module
+MODULE_FILES += legacycfg.module$(EXEEXT)
+legacycfg_module_SOURCES = commands/legacycfg.c lib/legacy_parse.c ## platform sources
+nodist_legacycfg_module_SOURCES = ## platform nodist sources
+legacycfg_module_LDADD =
+legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_legacycfg_module_SOURCES)
+CLEANFILES += $(nodist_legacycfg_module_SOURCES)
+MOD_FILES += legacycfg.mod
+MARKER_FILES += legacycfg.marker
+CLEANFILES += legacycfg.marker
+
+legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += syslinuxcfg.module
+MODULE_FILES += syslinuxcfg.module$(EXEEXT)
+syslinuxcfg_module_SOURCES = lib/syslinux_parse.c commands/syslinuxcfg.c ## platform sources
+nodist_syslinuxcfg_module_SOURCES = ## platform nodist sources
+syslinuxcfg_module_LDADD =
+syslinuxcfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+syslinuxcfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+syslinuxcfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+syslinuxcfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+syslinuxcfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_syslinuxcfg_module_SOURCES)
+CLEANFILES += $(nodist_syslinuxcfg_module_SOURCES)
+MOD_FILES += syslinuxcfg.mod
+MARKER_FILES += syslinuxcfg.marker
+CLEANFILES += syslinuxcfg.marker
+
+syslinuxcfg.marker: $(syslinuxcfg_module_SOURCES) $(nodist_syslinuxcfg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(syslinuxcfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += test_blockarg.module
+MODULE_FILES += test_blockarg.module$(EXEEXT)
+test_blockarg_module_SOURCES = tests/test_blockarg.c ## platform sources
+nodist_test_blockarg_module_SOURCES = ## platform nodist sources
+test_blockarg_module_LDADD =
+test_blockarg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+test_blockarg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+test_blockarg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+test_blockarg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+test_blockarg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_test_blockarg_module_SOURCES)
+CLEANFILES += $(nodist_test_blockarg_module_SOURCES)
+MOD_FILES += test_blockarg.mod
+MARKER_FILES += test_blockarg.marker
+CLEANFILES += test_blockarg.marker
+
+test_blockarg.marker: $(test_blockarg_module_SOURCES) $(nodist_test_blockarg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_blockarg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += xzio.module
+MODULE_FILES += xzio.module$(EXEEXT)
+xzio_module_SOURCES = io/xzio.c lib/xzembed/xz_dec_bcj.c lib/xzembed/xz_dec_lzma2.c lib/xzembed/xz_dec_stream.c ## platform sources
+nodist_xzio_module_SOURCES = ## platform nodist sources
+xzio_module_LDADD =
+xzio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) -Wno-unreachable-code
+xzio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xzio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed
+xzio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xzio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xzio_module_SOURCES)
+CLEANFILES += $(nodist_xzio_module_SOURCES)
+MOD_FILES += xzio.mod
+MARKER_FILES += xzio.marker
+CLEANFILES += xzio.marker
+
+xzio.marker: $(xzio_module_SOURCES) $(nodist_xzio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += lzopio.module
+MODULE_FILES += lzopio.module$(EXEEXT)
+lzopio_module_SOURCES = io/lzopio.c lib/minilzo/minilzo.c ## platform sources
+nodist_lzopio_module_SOURCES = ## platform nodist sources
+lzopio_module_LDADD =
+lzopio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) -Wno-undef -Wno-redundant-decls -Wno-error
+lzopio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lzopio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H
+lzopio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lzopio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lzopio_module_SOURCES)
+CLEANFILES += $(nodist_lzopio_module_SOURCES)
+MOD_FILES += lzopio.mod
+MARKER_FILES += lzopio.marker
+CLEANFILES += lzopio.marker
+
+lzopio.marker: $(lzopio_module_SOURCES) $(nodist_lzopio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzopio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += testload.module
+MODULE_FILES += testload.module$(EXEEXT)
+testload_module_SOURCES = commands/testload.c ## platform sources
+nodist_testload_module_SOURCES = ## platform nodist sources
+testload_module_LDADD =
+testload_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+testload_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+testload_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+testload_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+testload_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_testload_module_SOURCES)
+CLEANFILES += $(nodist_testload_module_SOURCES)
+MOD_FILES += testload.mod
+MARKER_FILES += testload.marker
+CLEANFILES += testload.marker
+
+testload.marker: $(testload_module_SOURCES) $(nodist_testload_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testload_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += backtrace.module
+MODULE_FILES += backtrace.module$(EXEEXT)
+backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+nodist_backtrace_module_SOURCES = ## platform nodist sources
+backtrace_module_LDADD =
+backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_backtrace_module_SOURCES)
+CLEANFILES += $(nodist_backtrace_module_SOURCES)
+MOD_FILES += backtrace.mod
+MARKER_FILES += backtrace.marker
+CLEANFILES += backtrace.marker
+
+backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += backtrace.module
+MODULE_FILES += backtrace.module$(EXEEXT)
+backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+nodist_backtrace_module_SOURCES = ## platform nodist sources
+backtrace_module_LDADD =
+backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_backtrace_module_SOURCES)
+CLEANFILES += $(nodist_backtrace_module_SOURCES)
+MOD_FILES += backtrace.mod
+MARKER_FILES += backtrace.marker
+CLEANFILES += backtrace.marker
+
+backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += backtrace.module
+MODULE_FILES += backtrace.module$(EXEEXT)
+backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+nodist_backtrace_module_SOURCES = ## platform nodist sources
+backtrace_module_LDADD =
+backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_backtrace_module_SOURCES)
+CLEANFILES += $(nodist_backtrace_module_SOURCES)
+MOD_FILES += backtrace.mod
+MARKER_FILES += backtrace.marker
+CLEANFILES += backtrace.marker
+
+backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += backtrace.module
+MODULE_FILES += backtrace.module$(EXEEXT)
+backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+nodist_backtrace_module_SOURCES = ## platform nodist sources
+backtrace_module_LDADD =
+backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_backtrace_module_SOURCES)
+CLEANFILES += $(nodist_backtrace_module_SOURCES)
+MOD_FILES += backtrace.mod
+MARKER_FILES += backtrace.marker
+CLEANFILES += backtrace.marker
+
+backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += backtrace.module
+MODULE_FILES += backtrace.module$(EXEEXT)
+backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+nodist_backtrace_module_SOURCES = ## platform nodist sources
+backtrace_module_LDADD =
+backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_backtrace_module_SOURCES)
+CLEANFILES += $(nodist_backtrace_module_SOURCES)
+MOD_FILES += backtrace.mod
+MARKER_FILES += backtrace.marker
+CLEANFILES += backtrace.marker
+
+backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += backtrace.module
+MODULE_FILES += backtrace.module$(EXEEXT)
+backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+nodist_backtrace_module_SOURCES = ## platform nodist sources
+backtrace_module_LDADD =
+backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_backtrace_module_SOURCES)
+CLEANFILES += $(nodist_backtrace_module_SOURCES)
+MOD_FILES += backtrace.mod
+MARKER_FILES += backtrace.marker
+CLEANFILES += backtrace.marker
+
+backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += backtrace.module
+MODULE_FILES += backtrace.module$(EXEEXT)
+backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+nodist_backtrace_module_SOURCES = ## platform nodist sources
+backtrace_module_LDADD =
+backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_backtrace_module_SOURCES)
+CLEANFILES += $(nodist_backtrace_module_SOURCES)
+MOD_FILES += backtrace.mod
+MARKER_FILES += backtrace.marker
+CLEANFILES += backtrace.marker
+
+backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += backtrace.module
+MODULE_FILES += backtrace.module$(EXEEXT)
+backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+nodist_backtrace_module_SOURCES = ## platform nodist sources
+backtrace_module_LDADD =
+backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_backtrace_module_SOURCES)
+CLEANFILES += $(nodist_backtrace_module_SOURCES)
+MOD_FILES += backtrace.mod
+MARKER_FILES += backtrace.marker
+CLEANFILES += backtrace.marker
+
+backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += backtrace.module
+MODULE_FILES += backtrace.module$(EXEEXT)
+backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+nodist_backtrace_module_SOURCES = ## platform nodist sources
+backtrace_module_LDADD =
+backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_backtrace_module_SOURCES)
+CLEANFILES += $(nodist_backtrace_module_SOURCES)
+MOD_FILES += backtrace.mod
+MARKER_FILES += backtrace.marker
+CLEANFILES += backtrace.marker
+
+backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += backtrace.module
+MODULE_FILES += backtrace.module$(EXEEXT)
+backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+nodist_backtrace_module_SOURCES = ## platform nodist sources
+backtrace_module_LDADD =
+backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_backtrace_module_SOURCES)
+CLEANFILES += $(nodist_backtrace_module_SOURCES)
+MOD_FILES += backtrace.mod
+MARKER_FILES += backtrace.marker
+CLEANFILES += backtrace.marker
+
+backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += lsapm.module
+MODULE_FILES += lsapm.module$(EXEEXT)
+lsapm_module_SOURCES = commands/i386/pc/lsapm.c ## platform sources
+nodist_lsapm_module_SOURCES = ## platform nodist sources
+lsapm_module_LDADD =
+lsapm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsapm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsapm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsapm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsapm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lsapm_module_SOURCES)
+CLEANFILES += $(nodist_lsapm_module_SOURCES)
+MOD_FILES += lsapm.mod
+MARKER_FILES += lsapm.marker
+CLEANFILES += lsapm.marker
+
+lsapm.marker: $(lsapm_module_SOURCES) $(nodist_lsapm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsapm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += keylayouts.module
+MODULE_FILES += keylayouts.module$(EXEEXT)
+keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+nodist_keylayouts_module_SOURCES = ## platform nodist sources
+keylayouts_module_LDADD =
+keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_keylayouts_module_SOURCES)
+CLEANFILES += $(nodist_keylayouts_module_SOURCES)
+MOD_FILES += keylayouts.mod
+MARKER_FILES += keylayouts.marker
+CLEANFILES += keylayouts.marker
+
+keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += keylayouts.module
+MODULE_FILES += keylayouts.module$(EXEEXT)
+keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+nodist_keylayouts_module_SOURCES = ## platform nodist sources
+keylayouts_module_LDADD =
+keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_keylayouts_module_SOURCES)
+CLEANFILES += $(nodist_keylayouts_module_SOURCES)
+MOD_FILES += keylayouts.mod
+MARKER_FILES += keylayouts.marker
+CLEANFILES += keylayouts.marker
+
+keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += keylayouts.module
+MODULE_FILES += keylayouts.module$(EXEEXT)
+keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+nodist_keylayouts_module_SOURCES = ## platform nodist sources
+keylayouts_module_LDADD =
+keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_keylayouts_module_SOURCES)
+CLEANFILES += $(nodist_keylayouts_module_SOURCES)
+MOD_FILES += keylayouts.mod
+MARKER_FILES += keylayouts.marker
+CLEANFILES += keylayouts.marker
+
+keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += keylayouts.module
+MODULE_FILES += keylayouts.module$(EXEEXT)
+keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+nodist_keylayouts_module_SOURCES = ## platform nodist sources
+keylayouts_module_LDADD =
+keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_keylayouts_module_SOURCES)
+CLEANFILES += $(nodist_keylayouts_module_SOURCES)
+MOD_FILES += keylayouts.mod
+MARKER_FILES += keylayouts.marker
+CLEANFILES += keylayouts.marker
+
+keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += keylayouts.module
+MODULE_FILES += keylayouts.module$(EXEEXT)
+keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+nodist_keylayouts_module_SOURCES = ## platform nodist sources
+keylayouts_module_LDADD =
+keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_keylayouts_module_SOURCES)
+CLEANFILES += $(nodist_keylayouts_module_SOURCES)
+MOD_FILES += keylayouts.mod
+MARKER_FILES += keylayouts.marker
+CLEANFILES += keylayouts.marker
+
+keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += keylayouts.module
+MODULE_FILES += keylayouts.module$(EXEEXT)
+keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+nodist_keylayouts_module_SOURCES = ## platform nodist sources
+keylayouts_module_LDADD =
+keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_keylayouts_module_SOURCES)
+CLEANFILES += $(nodist_keylayouts_module_SOURCES)
+MOD_FILES += keylayouts.mod
+MARKER_FILES += keylayouts.marker
+CLEANFILES += keylayouts.marker
+
+keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += keylayouts.module
+MODULE_FILES += keylayouts.module$(EXEEXT)
+keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+nodist_keylayouts_module_SOURCES = ## platform nodist sources
+keylayouts_module_LDADD =
+keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_keylayouts_module_SOURCES)
+CLEANFILES += $(nodist_keylayouts_module_SOURCES)
+MOD_FILES += keylayouts.mod
+MARKER_FILES += keylayouts.marker
+CLEANFILES += keylayouts.marker
+
+keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += priority_queue.module
+MODULE_FILES += priority_queue.module$(EXEEXT)
+priority_queue_module_SOURCES = lib/priority_queue.c ## platform sources
+nodist_priority_queue_module_SOURCES = ## platform nodist sources
+priority_queue_module_LDADD =
+priority_queue_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+priority_queue_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+priority_queue_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+priority_queue_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+priority_queue_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_priority_queue_module_SOURCES)
+CLEANFILES += $(nodist_priority_queue_module_SOURCES)
+MOD_FILES += priority_queue.mod
+MARKER_FILES += priority_queue.marker
+CLEANFILES += priority_queue.marker
+
+priority_queue.marker: $(priority_queue_module_SOURCES) $(nodist_priority_queue_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(priority_queue_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += time.module
+MODULE_FILES += time.module$(EXEEXT)
+time_module_SOURCES = commands/time.c ## platform sources
+nodist_time_module_SOURCES = ## platform nodist sources
+time_module_LDADD =
+time_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+time_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+time_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+time_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+time_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_time_module_SOURCES)
+CLEANFILES += $(nodist_time_module_SOURCES)
+MOD_FILES += time.mod
+MARKER_FILES += time.marker
+CLEANFILES += time.marker
+
+time.marker: $(time_module_SOURCES) $(nodist_time_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(time_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+if COND_ENABLE_CACHE_STATS
+platform_PROGRAMS += cacheinfo.module
+MODULE_FILES += cacheinfo.module$(EXEEXT)
+cacheinfo_module_SOURCES = commands/cacheinfo.c ## platform sources
+nodist_cacheinfo_module_SOURCES = ## platform nodist sources
+cacheinfo_module_LDADD =
+cacheinfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cacheinfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cacheinfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cacheinfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cacheinfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cacheinfo_module_SOURCES)
+CLEANFILES += $(nodist_cacheinfo_module_SOURCES)
+MOD_FILES += cacheinfo.mod
+MARKER_FILES += cacheinfo.marker
+CLEANFILES += cacheinfo.marker
+
+cacheinfo.marker: $(cacheinfo_module_SOURCES) $(nodist_cacheinfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cacheinfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif COND_ENABLE_CACHE_STATS
+if COND_ENABLE_BOOT_TIME_STATS
+platform_PROGRAMS += boottime.module
+MODULE_FILES += boottime.module$(EXEEXT)
+boottime_module_SOURCES = commands/boottime.c ## platform sources
+nodist_boottime_module_SOURCES = ## platform nodist sources
+boottime_module_LDADD =
+boottime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+boottime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+boottime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+boottime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+boottime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boottime_module_SOURCES)
+CLEANFILES += $(nodist_boottime_module_SOURCES)
+MOD_FILES += boottime.mod
+MARKER_FILES += boottime.marker
+CLEANFILES += boottime.marker
+
+boottime.marker: $(boottime_module_SOURCES) $(nodist_boottime_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boottime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif COND_ENABLE_BOOT_TIME_STATS
+platform_PROGRAMS += adler32.module
+MODULE_FILES += adler32.module$(EXEEXT)
+adler32_module_SOURCES = lib/adler32.c ## platform sources
+nodist_adler32_module_SOURCES = ## platform nodist sources
+adler32_module_LDADD =
+adler32_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+adler32_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+adler32_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+adler32_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+adler32_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_adler32_module_SOURCES)
+CLEANFILES += $(nodist_adler32_module_SOURCES)
+MOD_FILES += adler32.mod
+MARKER_FILES += adler32.marker
+CLEANFILES += adler32.marker
+
+adler32.marker: $(adler32_module_SOURCES) $(nodist_adler32_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adler32_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += crc64.module
+MODULE_FILES += crc64.module$(EXEEXT)
+crc64_module_SOURCES = lib/crc64.c ## platform sources
+nodist_crc64_module_SOURCES = ## platform nodist sources
+crc64_module_LDADD =
+crc64_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+crc64_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+crc64_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+crc64_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+crc64_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_crc64_module_SOURCES)
+CLEANFILES += $(nodist_crc64_module_SOURCES)
+MOD_FILES += crc64.mod
+MARKER_FILES += crc64.marker
+CLEANFILES += crc64.marker
+
+crc64.marker: $(crc64_module_SOURCES) $(nodist_crc64_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crc64_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += mpi.module
+MODULE_FILES += mpi.module$(EXEEXT)
+mpi_module_SOURCES = lib/libgcrypt-grub/mpi/mpiutil.c lib/libgcrypt-grub/mpi/mpi-bit.c lib/libgcrypt-grub/mpi/mpi-add.c lib/libgcrypt-grub/mpi/mpi-mul.c lib/libgcrypt-grub/mpi/mpi-mod.c lib/libgcrypt-grub/mpi/mpi-gcd.c lib/libgcrypt-grub/mpi/mpi-div.c lib/libgcrypt-grub/mpi/mpi-cmp.c lib/libgcrypt-grub/mpi/mpi-inv.c lib/libgcrypt-grub/mpi/mpi-pow.c lib/libgcrypt-grub/mpi/mpi-mpow.c lib/libgcrypt-grub/mpi/mpih-lshift.c lib/libgcrypt-grub/mpi/mpih-mul.c lib/libgcrypt-grub/mpi/mpih-mul1.c lib/libgcrypt-grub/mpi/mpih-mul2.c lib/libgcrypt-grub/mpi/mpih-mul3.c lib/libgcrypt-grub/mpi/mpih-add1.c lib/libgcrypt-grub/mpi/mpih-sub1.c lib/libgcrypt-grub/mpi/mpih-div.c lib/libgcrypt-grub/mpi/mpicoder.c lib/libgcrypt-grub/mpi/mpih-rshift.c lib/libgcrypt-grub/mpi/mpi-inline.c lib/libgcrypt_wrap/mem.c ## platform sources
+nodist_mpi_module_SOURCES = ## platform nodist sources
+mpi_module_LDADD =
+mpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-redundant-decls -Wno-sign-compare
+mpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+mpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_mpi_module_SOURCES)
+CLEANFILES += $(nodist_mpi_module_SOURCES)
+MOD_FILES += mpi.mod
+MARKER_FILES += mpi.marker
+CLEANFILES += mpi.marker
+
+mpi.marker: $(mpi_module_SOURCES) $(nodist_mpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += all_video.module
+MODULE_FILES += all_video.module$(EXEEXT)
+all_video_module_SOURCES = lib/fake_module.c ## platform sources
+nodist_all_video_module_SOURCES = ## platform nodist sources
+all_video_module_LDADD =
+all_video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+all_video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+all_video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+all_video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+all_video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_all_video_module_SOURCES)
+CLEANFILES += $(nodist_all_video_module_SOURCES)
+MOD_FILES += all_video.mod
+MARKER_FILES += all_video.marker
+CLEANFILES += all_video.marker
+
+all_video.marker: $(all_video_module_SOURCES) $(nodist_all_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(all_video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += gdb.module
+MODULE_FILES += gdb.module$(EXEEXT)
+gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+nodist_gdb_module_SOURCES = ## platform nodist sources
+gdb_module_LDADD =
+gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gdb_module_SOURCES)
+CLEANFILES += $(nodist_gdb_module_SOURCES)
+MOD_FILES += gdb.mod
+MARKER_FILES += gdb.marker
+CLEANFILES += gdb.marker
+
+gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += gdb.module
+MODULE_FILES += gdb.module$(EXEEXT)
+gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+nodist_gdb_module_SOURCES = ## platform nodist sources
+gdb_module_LDADD =
+gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gdb_module_SOURCES)
+CLEANFILES += $(nodist_gdb_module_SOURCES)
+MOD_FILES += gdb.mod
+MARKER_FILES += gdb.marker
+CLEANFILES += gdb.marker
+
+gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += gdb.module
+MODULE_FILES += gdb.module$(EXEEXT)
+gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+nodist_gdb_module_SOURCES = ## platform nodist sources
+gdb_module_LDADD =
+gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gdb_module_SOURCES)
+CLEANFILES += $(nodist_gdb_module_SOURCES)
+MOD_FILES += gdb.mod
+MARKER_FILES += gdb.marker
+CLEANFILES += gdb.marker
+
+gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += gdb.module
+MODULE_FILES += gdb.module$(EXEEXT)
+gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+nodist_gdb_module_SOURCES = ## platform nodist sources
+gdb_module_LDADD =
+gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gdb_module_SOURCES)
+CLEANFILES += $(nodist_gdb_module_SOURCES)
+MOD_FILES += gdb.mod
+MARKER_FILES += gdb.marker
+CLEANFILES += gdb.marker
+
+gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += gdb.module
+MODULE_FILES += gdb.module$(EXEEXT)
+gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+nodist_gdb_module_SOURCES = ## platform nodist sources
+gdb_module_LDADD =
+gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gdb_module_SOURCES)
+CLEANFILES += $(nodist_gdb_module_SOURCES)
+MOD_FILES += gdb.mod
+MARKER_FILES += gdb.marker
+CLEANFILES += gdb.marker
+
+gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += gdb.module
+MODULE_FILES += gdb.module$(EXEEXT)
+gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+nodist_gdb_module_SOURCES = ## platform nodist sources
+gdb_module_LDADD =
+gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gdb_module_SOURCES)
+CLEANFILES += $(nodist_gdb_module_SOURCES)
+MOD_FILES += gdb.mod
+MARKER_FILES += gdb.marker
+CLEANFILES += gdb.marker
+
+gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += testspeed.module
+MODULE_FILES += testspeed.module$(EXEEXT)
+testspeed_module_SOURCES = commands/testspeed.c ## platform sources
+nodist_testspeed_module_SOURCES = ## platform nodist sources
+testspeed_module_LDADD =
+testspeed_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+testspeed_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+testspeed_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+testspeed_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+testspeed_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_testspeed_module_SOURCES)
+CLEANFILES += $(nodist_testspeed_module_SOURCES)
+MOD_FILES += testspeed.mod
+MARKER_FILES += testspeed.marker
+CLEANFILES += testspeed.marker
+
+testspeed.marker: $(testspeed_module_SOURCES) $(nodist_testspeed_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testspeed_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_efi
+platform_PROGRAMS += tpm.module
+MODULE_FILES += tpm.module$(EXEEXT)
+tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+nodist_tpm_module_SOURCES = ## platform nodist sources
+tpm_module_LDADD =
+tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tpm_module_SOURCES)
+CLEANFILES += $(nodist_tpm_module_SOURCES)
+MOD_FILES += tpm.mod
+MARKER_FILES += tpm.marker
+CLEANFILES += tpm.marker
+
+tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += tpm.module
+MODULE_FILES += tpm.module$(EXEEXT)
+tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+nodist_tpm_module_SOURCES = ## platform nodist sources
+tpm_module_LDADD =
+tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tpm_module_SOURCES)
+CLEANFILES += $(nodist_tpm_module_SOURCES)
+MOD_FILES += tpm.mod
+MARKER_FILES += tpm.marker
+CLEANFILES += tpm.marker
+
+tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += tpm.module
+MODULE_FILES += tpm.module$(EXEEXT)
+tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+nodist_tpm_module_SOURCES = ## platform nodist sources
+tpm_module_LDADD =
+tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tpm_module_SOURCES)
+CLEANFILES += $(nodist_tpm_module_SOURCES)
+MOD_FILES += tpm.mod
+MARKER_FILES += tpm.marker
+CLEANFILES += tpm.marker
+
+tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += tpm.module
+MODULE_FILES += tpm.module$(EXEEXT)
+tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+nodist_tpm_module_SOURCES = ## platform nodist sources
+tpm_module_LDADD =
+tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tpm_module_SOURCES)
+CLEANFILES += $(nodist_tpm_module_SOURCES)
+MOD_FILES += tpm.mod
+MARKER_FILES += tpm.marker
+CLEANFILES += tpm.marker
+
+tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += tpm.module
+MODULE_FILES += tpm.module$(EXEEXT)
+tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+nodist_tpm_module_SOURCES = ## platform nodist sources
+tpm_module_LDADD =
+tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tpm_module_SOURCES)
+CLEANFILES += $(nodist_tpm_module_SOURCES)
+MOD_FILES += tpm.mod
+MARKER_FILES += tpm.marker
+CLEANFILES += tpm.marker
+
+tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += tpm.module
+MODULE_FILES += tpm.module$(EXEEXT)
+tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+nodist_tpm_module_SOURCES = ## platform nodist sources
+tpm_module_LDADD =
+tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tpm_module_SOURCES)
+CLEANFILES += $(nodist_tpm_module_SOURCES)
+MOD_FILES += tpm.mod
+MARKER_FILES += tpm.marker
+CLEANFILES += tpm.marker
+
+tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += tpm.module
+MODULE_FILES += tpm.module$(EXEEXT)
+tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+nodist_tpm_module_SOURCES = ## platform nodist sources
+tpm_module_LDADD =
+tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tpm_module_SOURCES)
+CLEANFILES += $(nodist_tpm_module_SOURCES)
+MOD_FILES += tpm.mod
+MARKER_FILES += tpm.marker
+CLEANFILES += tpm.marker
+
+tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += tr.module
+MODULE_FILES += tr.module$(EXEEXT)
+tr_module_SOURCES = commands/tr.c ## platform sources
+nodist_tr_module_SOURCES = ## platform nodist sources
+tr_module_LDADD =
+tr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_tr_module_SOURCES)
+CLEANFILES += $(nodist_tr_module_SOURCES)
+MOD_FILES += tr.mod
+MARKER_FILES += tr.marker
+CLEANFILES += tr.marker
+
+tr.marker: $(tr_module_SOURCES) $(nodist_tr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += progress.module
+MODULE_FILES += progress.module$(EXEEXT)
+progress_module_SOURCES = lib/progress.c ## platform sources
+nodist_progress_module_SOURCES = ## platform nodist sources
+progress_module_LDADD =
+progress_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+progress_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+progress_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+progress_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+progress_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_progress_module_SOURCES)
+CLEANFILES += $(nodist_progress_module_SOURCES)
+MOD_FILES += progress.mod
+MARKER_FILES += progress.marker
+CLEANFILES += progress.marker
+
+progress.marker: $(progress_module_SOURCES) $(nodist_progress_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(progress_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += file.module
+MODULE_FILES += file.module$(EXEEXT)
+file_module_SOURCES = commands/file.c commands/file32.c commands/file64.c loader/i386/xen_file.c loader/i386/xen_file32.c loader/i386/xen_file64.c ## platform sources
+nodist_file_module_SOURCES = ## platform nodist sources
+file_module_LDADD =
+file_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+file_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+file_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+file_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+file_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += commands/fileXX.c loader/i386/xen_fileXX.c
+BUILT_SOURCES += $(nodist_file_module_SOURCES)
+CLEANFILES += $(nodist_file_module_SOURCES)
+MOD_FILES += file.mod
+MARKER_FILES += file.marker
+CLEANFILES += file.marker
+
+file.marker: $(file_module_SOURCES) $(nodist_file_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_i386_pc
+platform_PROGRAMS += rdmsr.module
+MODULE_FILES += rdmsr.module$(EXEEXT)
+rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+nodist_rdmsr_module_SOURCES = ## platform nodist sources
+rdmsr_module_LDADD =
+rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_rdmsr_module_SOURCES)
+CLEANFILES += $(nodist_rdmsr_module_SOURCES)
+MOD_FILES += rdmsr.mod
+MARKER_FILES += rdmsr.marker
+CLEANFILES += rdmsr.marker
+
+rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += rdmsr.module
+MODULE_FILES += rdmsr.module$(EXEEXT)
+rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+nodist_rdmsr_module_SOURCES = ## platform nodist sources
+rdmsr_module_LDADD =
+rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_rdmsr_module_SOURCES)
+CLEANFILES += $(nodist_rdmsr_module_SOURCES)
+MOD_FILES += rdmsr.mod
+MARKER_FILES += rdmsr.marker
+CLEANFILES += rdmsr.marker
+
+rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += rdmsr.module
+MODULE_FILES += rdmsr.module$(EXEEXT)
+rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+nodist_rdmsr_module_SOURCES = ## platform nodist sources
+rdmsr_module_LDADD =
+rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_rdmsr_module_SOURCES)
+CLEANFILES += $(nodist_rdmsr_module_SOURCES)
+MOD_FILES += rdmsr.mod
+MARKER_FILES += rdmsr.marker
+CLEANFILES += rdmsr.marker
+
+rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += rdmsr.module
+MODULE_FILES += rdmsr.module$(EXEEXT)
+rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+nodist_rdmsr_module_SOURCES = ## platform nodist sources
+rdmsr_module_LDADD =
+rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_rdmsr_module_SOURCES)
+CLEANFILES += $(nodist_rdmsr_module_SOURCES)
+MOD_FILES += rdmsr.mod
+MARKER_FILES += rdmsr.marker
+CLEANFILES += rdmsr.marker
+
+rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += rdmsr.module
+MODULE_FILES += rdmsr.module$(EXEEXT)
+rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+nodist_rdmsr_module_SOURCES = ## platform nodist sources
+rdmsr_module_LDADD =
+rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_rdmsr_module_SOURCES)
+CLEANFILES += $(nodist_rdmsr_module_SOURCES)
+MOD_FILES += rdmsr.mod
+MARKER_FILES += rdmsr.marker
+CLEANFILES += rdmsr.marker
+
+rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += rdmsr.module
+MODULE_FILES += rdmsr.module$(EXEEXT)
+rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+nodist_rdmsr_module_SOURCES = ## platform nodist sources
+rdmsr_module_LDADD =
+rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_rdmsr_module_SOURCES)
+CLEANFILES += $(nodist_rdmsr_module_SOURCES)
+MOD_FILES += rdmsr.mod
+MARKER_FILES += rdmsr.marker
+CLEANFILES += rdmsr.marker
+
+rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += rdmsr.module
+MODULE_FILES += rdmsr.module$(EXEEXT)
+rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+nodist_rdmsr_module_SOURCES = ## platform nodist sources
+rdmsr_module_LDADD =
+rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_rdmsr_module_SOURCES)
+CLEANFILES += $(nodist_rdmsr_module_SOURCES)
+MOD_FILES += rdmsr.mod
+MARKER_FILES += rdmsr.marker
+CLEANFILES += rdmsr.marker
+
+rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += wrmsr.module
+MODULE_FILES += wrmsr.module$(EXEEXT)
+wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+nodist_wrmsr_module_SOURCES = ## platform nodist sources
+wrmsr_module_LDADD =
+wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_wrmsr_module_SOURCES)
+CLEANFILES += $(nodist_wrmsr_module_SOURCES)
+MOD_FILES += wrmsr.mod
+MARKER_FILES += wrmsr.marker
+CLEANFILES += wrmsr.marker
+
+wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += wrmsr.module
+MODULE_FILES += wrmsr.module$(EXEEXT)
+wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+nodist_wrmsr_module_SOURCES = ## platform nodist sources
+wrmsr_module_LDADD =
+wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_wrmsr_module_SOURCES)
+CLEANFILES += $(nodist_wrmsr_module_SOURCES)
+MOD_FILES += wrmsr.mod
+MARKER_FILES += wrmsr.marker
+CLEANFILES += wrmsr.marker
+
+wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += wrmsr.module
+MODULE_FILES += wrmsr.module$(EXEEXT)
+wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+nodist_wrmsr_module_SOURCES = ## platform nodist sources
+wrmsr_module_LDADD =
+wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_wrmsr_module_SOURCES)
+CLEANFILES += $(nodist_wrmsr_module_SOURCES)
+MOD_FILES += wrmsr.mod
+MARKER_FILES += wrmsr.marker
+CLEANFILES += wrmsr.marker
+
+wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += wrmsr.module
+MODULE_FILES += wrmsr.module$(EXEEXT)
+wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+nodist_wrmsr_module_SOURCES = ## platform nodist sources
+wrmsr_module_LDADD =
+wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_wrmsr_module_SOURCES)
+CLEANFILES += $(nodist_wrmsr_module_SOURCES)
+MOD_FILES += wrmsr.mod
+MARKER_FILES += wrmsr.marker
+CLEANFILES += wrmsr.marker
+
+wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += wrmsr.module
+MODULE_FILES += wrmsr.module$(EXEEXT)
+wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+nodist_wrmsr_module_SOURCES = ## platform nodist sources
+wrmsr_module_LDADD =
+wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_wrmsr_module_SOURCES)
+CLEANFILES += $(nodist_wrmsr_module_SOURCES)
+MOD_FILES += wrmsr.mod
+MARKER_FILES += wrmsr.marker
+CLEANFILES += wrmsr.marker
+
+wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += wrmsr.module
+MODULE_FILES += wrmsr.module$(EXEEXT)
+wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+nodist_wrmsr_module_SOURCES = ## platform nodist sources
+wrmsr_module_LDADD =
+wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_wrmsr_module_SOURCES)
+CLEANFILES += $(nodist_wrmsr_module_SOURCES)
+MOD_FILES += wrmsr.mod
+MARKER_FILES += wrmsr.marker
+CLEANFILES += wrmsr.marker
+
+wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += wrmsr.module
+MODULE_FILES += wrmsr.module$(EXEEXT)
+wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+nodist_wrmsr_module_SOURCES = ## platform nodist sources
+wrmsr_module_LDADD =
+wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_wrmsr_module_SOURCES)
+CLEANFILES += $(nodist_wrmsr_module_SOURCES)
+MOD_FILES += wrmsr.mod
+MARKER_FILES += wrmsr.marker
+CLEANFILES += wrmsr.marker
+
+wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+endif
+platform_PROGRAMS += gcry_arcfour.module
+MODULE_FILES += gcry_arcfour.module$(EXEEXT)
+gcry_arcfour_module_SOURCES = lib/libgcrypt-grub/cipher/arcfour.c ## platform sources
+nodist_gcry_arcfour_module_SOURCES = ## platform nodist sources
+gcry_arcfour_module_LDADD =
+gcry_arcfour_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_arcfour_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_arcfour_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_arcfour_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_arcfour_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_arcfour_module_SOURCES)
+CLEANFILES += $(nodist_gcry_arcfour_module_SOURCES)
+MOD_FILES += gcry_arcfour.mod
+MARKER_FILES += gcry_arcfour.marker
+CLEANFILES += gcry_arcfour.marker
+
+gcry_arcfour.marker: $(gcry_arcfour_module_SOURCES) $(nodist_gcry_arcfour_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_arcfour_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_blowfish.module
+MODULE_FILES += gcry_blowfish.module$(EXEEXT)
+gcry_blowfish_module_SOURCES = lib/libgcrypt-grub/cipher/blowfish.c ## platform sources
+nodist_gcry_blowfish_module_SOURCES = ## platform nodist sources
+gcry_blowfish_module_LDADD =
+gcry_blowfish_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_blowfish_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_blowfish_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_blowfish_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_blowfish_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_blowfish_module_SOURCES)
+CLEANFILES += $(nodist_gcry_blowfish_module_SOURCES)
+MOD_FILES += gcry_blowfish.mod
+MARKER_FILES += gcry_blowfish.marker
+CLEANFILES += gcry_blowfish.marker
+
+gcry_blowfish.marker: $(gcry_blowfish_module_SOURCES) $(nodist_gcry_blowfish_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_blowfish_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_camellia.module
+MODULE_FILES += gcry_camellia.module$(EXEEXT)
+gcry_camellia_module_SOURCES = lib/libgcrypt-grub/cipher/camellia-glue.c lib/libgcrypt-grub/cipher/camellia.c ## platform sources
+nodist_gcry_camellia_module_SOURCES = ## platform nodist sources
+gcry_camellia_module_LDADD =
+gcry_camellia_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_camellia_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_camellia_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_camellia_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_camellia_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_camellia_module_SOURCES)
+CLEANFILES += $(nodist_gcry_camellia_module_SOURCES)
+MOD_FILES += gcry_camellia.mod
+MARKER_FILES += gcry_camellia.marker
+CLEANFILES += gcry_camellia.marker
+
+gcry_camellia.marker: $(gcry_camellia_module_SOURCES) $(nodist_gcry_camellia_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_camellia_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_cast5.module
+MODULE_FILES += gcry_cast5.module$(EXEEXT)
+gcry_cast5_module_SOURCES = lib/libgcrypt-grub/cipher/cast5.c ## platform sources
+nodist_gcry_cast5_module_SOURCES = ## platform nodist sources
+gcry_cast5_module_LDADD =
+gcry_cast5_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_cast5_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_cast5_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_cast5_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_cast5_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_cast5_module_SOURCES)
+CLEANFILES += $(nodist_gcry_cast5_module_SOURCES)
+MOD_FILES += gcry_cast5.mod
+MARKER_FILES += gcry_cast5.marker
+CLEANFILES += gcry_cast5.marker
+
+gcry_cast5.marker: $(gcry_cast5_module_SOURCES) $(nodist_gcry_cast5_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_cast5_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_crc.module
+MODULE_FILES += gcry_crc.module$(EXEEXT)
+gcry_crc_module_SOURCES = lib/libgcrypt-grub/cipher/crc.c ## platform sources
+nodist_gcry_crc_module_SOURCES = ## platform nodist sources
+gcry_crc_module_LDADD =
+gcry_crc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_crc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_crc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_crc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_crc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_crc_module_SOURCES)
+CLEANFILES += $(nodist_gcry_crc_module_SOURCES)
+MOD_FILES += gcry_crc.mod
+MARKER_FILES += gcry_crc.marker
+CLEANFILES += gcry_crc.marker
+
+gcry_crc.marker: $(gcry_crc_module_SOURCES) $(nodist_gcry_crc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_crc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_des.module
+MODULE_FILES += gcry_des.module$(EXEEXT)
+gcry_des_module_SOURCES = lib/libgcrypt-grub/cipher/des.c ## platform sources
+nodist_gcry_des_module_SOURCES = ## platform nodist sources
+gcry_des_module_LDADD =
+gcry_des_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_des_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_des_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_des_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_des_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_des_module_SOURCES)
+CLEANFILES += $(nodist_gcry_des_module_SOURCES)
+MOD_FILES += gcry_des.mod
+MARKER_FILES += gcry_des.marker
+CLEANFILES += gcry_des.marker
+
+gcry_des.marker: $(gcry_des_module_SOURCES) $(nodist_gcry_des_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_des_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_dsa.module
+MODULE_FILES += gcry_dsa.module$(EXEEXT)
+gcry_dsa_module_SOURCES = lib/libgcrypt-grub/cipher/dsa.c ## platform sources
+nodist_gcry_dsa_module_SOURCES = ## platform nodist sources
+gcry_dsa_module_LDADD =
+gcry_dsa_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_dsa_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_dsa_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_dsa_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_dsa_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_dsa_module_SOURCES)
+CLEANFILES += $(nodist_gcry_dsa_module_SOURCES)
+MOD_FILES += gcry_dsa.mod
+MARKER_FILES += gcry_dsa.marker
+CLEANFILES += gcry_dsa.marker
+
+gcry_dsa.marker: $(gcry_dsa_module_SOURCES) $(nodist_gcry_dsa_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_dsa_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_idea.module
+MODULE_FILES += gcry_idea.module$(EXEEXT)
+gcry_idea_module_SOURCES = lib/libgcrypt-grub/cipher/idea.c ## platform sources
+nodist_gcry_idea_module_SOURCES = ## platform nodist sources
+gcry_idea_module_LDADD =
+gcry_idea_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_idea_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_idea_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_idea_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_idea_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_idea_module_SOURCES)
+CLEANFILES += $(nodist_gcry_idea_module_SOURCES)
+MOD_FILES += gcry_idea.mod
+MARKER_FILES += gcry_idea.marker
+CLEANFILES += gcry_idea.marker
+
+gcry_idea.marker: $(gcry_idea_module_SOURCES) $(nodist_gcry_idea_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_idea_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_md4.module
+MODULE_FILES += gcry_md4.module$(EXEEXT)
+gcry_md4_module_SOURCES = lib/libgcrypt-grub/cipher/md4.c ## platform sources
+nodist_gcry_md4_module_SOURCES = ## platform nodist sources
+gcry_md4_module_LDADD =
+gcry_md4_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_md4_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_md4_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_md4_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_md4_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_md4_module_SOURCES)
+CLEANFILES += $(nodist_gcry_md4_module_SOURCES)
+MOD_FILES += gcry_md4.mod
+MARKER_FILES += gcry_md4.marker
+CLEANFILES += gcry_md4.marker
+
+gcry_md4.marker: $(gcry_md4_module_SOURCES) $(nodist_gcry_md4_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md4_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_md5.module
+MODULE_FILES += gcry_md5.module$(EXEEXT)
+gcry_md5_module_SOURCES = lib/libgcrypt-grub/cipher/md5.c ## platform sources
+nodist_gcry_md5_module_SOURCES = ## platform nodist sources
+gcry_md5_module_LDADD =
+gcry_md5_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_md5_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_md5_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_md5_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_md5_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_md5_module_SOURCES)
+CLEANFILES += $(nodist_gcry_md5_module_SOURCES)
+MOD_FILES += gcry_md5.mod
+MARKER_FILES += gcry_md5.marker
+CLEANFILES += gcry_md5.marker
+
+gcry_md5.marker: $(gcry_md5_module_SOURCES) $(nodist_gcry_md5_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md5_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_rfc2268.module
+MODULE_FILES += gcry_rfc2268.module$(EXEEXT)
+gcry_rfc2268_module_SOURCES = lib/libgcrypt-grub/cipher/rfc2268.c ## platform sources
+nodist_gcry_rfc2268_module_SOURCES = ## platform nodist sources
+gcry_rfc2268_module_LDADD =
+gcry_rfc2268_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_rfc2268_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_rfc2268_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_rfc2268_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_rfc2268_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_rfc2268_module_SOURCES)
+CLEANFILES += $(nodist_gcry_rfc2268_module_SOURCES)
+MOD_FILES += gcry_rfc2268.mod
+MARKER_FILES += gcry_rfc2268.marker
+CLEANFILES += gcry_rfc2268.marker
+
+gcry_rfc2268.marker: $(gcry_rfc2268_module_SOURCES) $(nodist_gcry_rfc2268_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rfc2268_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_rijndael.module
+MODULE_FILES += gcry_rijndael.module$(EXEEXT)
+gcry_rijndael_module_SOURCES = lib/libgcrypt-grub/cipher/rijndael.c ## platform sources
+nodist_gcry_rijndael_module_SOURCES = ## platform nodist sources
+gcry_rijndael_module_LDADD =
+gcry_rijndael_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_rijndael_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_rijndael_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_rijndael_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_rijndael_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_rijndael_module_SOURCES)
+CLEANFILES += $(nodist_gcry_rijndael_module_SOURCES)
+MOD_FILES += gcry_rijndael.mod
+MARKER_FILES += gcry_rijndael.marker
+CLEANFILES += gcry_rijndael.marker
+
+gcry_rijndael.marker: $(gcry_rijndael_module_SOURCES) $(nodist_gcry_rijndael_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rijndael_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_rmd160.module
+MODULE_FILES += gcry_rmd160.module$(EXEEXT)
+gcry_rmd160_module_SOURCES = lib/libgcrypt-grub/cipher/rmd160.c ## platform sources
+nodist_gcry_rmd160_module_SOURCES = ## platform nodist sources
+gcry_rmd160_module_LDADD =
+gcry_rmd160_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_rmd160_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_rmd160_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_rmd160_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_rmd160_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_rmd160_module_SOURCES)
+CLEANFILES += $(nodist_gcry_rmd160_module_SOURCES)
+MOD_FILES += gcry_rmd160.mod
+MARKER_FILES += gcry_rmd160.marker
+CLEANFILES += gcry_rmd160.marker
+
+gcry_rmd160.marker: $(gcry_rmd160_module_SOURCES) $(nodist_gcry_rmd160_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rmd160_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_rsa.module
+MODULE_FILES += gcry_rsa.module$(EXEEXT)
+gcry_rsa_module_SOURCES = lib/libgcrypt-grub/cipher/rsa.c ## platform sources
+nodist_gcry_rsa_module_SOURCES = ## platform nodist sources
+gcry_rsa_module_LDADD =
+gcry_rsa_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_rsa_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_rsa_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_rsa_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_rsa_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_rsa_module_SOURCES)
+CLEANFILES += $(nodist_gcry_rsa_module_SOURCES)
+MOD_FILES += gcry_rsa.mod
+MARKER_FILES += gcry_rsa.marker
+CLEANFILES += gcry_rsa.marker
+
+gcry_rsa.marker: $(gcry_rsa_module_SOURCES) $(nodist_gcry_rsa_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rsa_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_seed.module
+MODULE_FILES += gcry_seed.module$(EXEEXT)
+gcry_seed_module_SOURCES = lib/libgcrypt-grub/cipher/seed.c ## platform sources
+nodist_gcry_seed_module_SOURCES = ## platform nodist sources
+gcry_seed_module_LDADD =
+gcry_seed_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_seed_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_seed_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_seed_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_seed_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_seed_module_SOURCES)
+CLEANFILES += $(nodist_gcry_seed_module_SOURCES)
+MOD_FILES += gcry_seed.mod
+MARKER_FILES += gcry_seed.marker
+CLEANFILES += gcry_seed.marker
+
+gcry_seed.marker: $(gcry_seed_module_SOURCES) $(nodist_gcry_seed_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_seed_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_serpent.module
+MODULE_FILES += gcry_serpent.module$(EXEEXT)
+gcry_serpent_module_SOURCES = lib/libgcrypt-grub/cipher/serpent.c ## platform sources
+nodist_gcry_serpent_module_SOURCES = ## platform nodist sources
+gcry_serpent_module_LDADD =
+gcry_serpent_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_serpent_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_serpent_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_serpent_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_serpent_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_serpent_module_SOURCES)
+CLEANFILES += $(nodist_gcry_serpent_module_SOURCES)
+MOD_FILES += gcry_serpent.mod
+MARKER_FILES += gcry_serpent.marker
+CLEANFILES += gcry_serpent.marker
+
+gcry_serpent.marker: $(gcry_serpent_module_SOURCES) $(nodist_gcry_serpent_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_serpent_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_sha1.module
+MODULE_FILES += gcry_sha1.module$(EXEEXT)
+gcry_sha1_module_SOURCES = lib/libgcrypt-grub/cipher/sha1.c ## platform sources
+nodist_gcry_sha1_module_SOURCES = ## platform nodist sources
+gcry_sha1_module_LDADD =
+gcry_sha1_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_sha1_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_sha1_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_sha1_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_sha1_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_sha1_module_SOURCES)
+CLEANFILES += $(nodist_gcry_sha1_module_SOURCES)
+MOD_FILES += gcry_sha1.mod
+MARKER_FILES += gcry_sha1.marker
+CLEANFILES += gcry_sha1.marker
+
+gcry_sha1.marker: $(gcry_sha1_module_SOURCES) $(nodist_gcry_sha1_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha1_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_sha256.module
+MODULE_FILES += gcry_sha256.module$(EXEEXT)
+gcry_sha256_module_SOURCES = lib/libgcrypt-grub/cipher/sha256.c ## platform sources
+nodist_gcry_sha256_module_SOURCES = ## platform nodist sources
+gcry_sha256_module_LDADD =
+gcry_sha256_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_sha256_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_sha256_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_sha256_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_sha256_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_sha256_module_SOURCES)
+CLEANFILES += $(nodist_gcry_sha256_module_SOURCES)
+MOD_FILES += gcry_sha256.mod
+MARKER_FILES += gcry_sha256.marker
+CLEANFILES += gcry_sha256.marker
+
+gcry_sha256.marker: $(gcry_sha256_module_SOURCES) $(nodist_gcry_sha256_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha256_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_sha512.module
+MODULE_FILES += gcry_sha512.module$(EXEEXT)
+gcry_sha512_module_SOURCES = lib/libgcrypt-grub/cipher/sha512.c ## platform sources
+nodist_gcry_sha512_module_SOURCES = ## platform nodist sources
+gcry_sha512_module_LDADD =
+gcry_sha512_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_sha512_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_sha512_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_sha512_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_sha512_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_sha512_module_SOURCES)
+CLEANFILES += $(nodist_gcry_sha512_module_SOURCES)
+MOD_FILES += gcry_sha512.mod
+MARKER_FILES += gcry_sha512.marker
+CLEANFILES += gcry_sha512.marker
+
+gcry_sha512.marker: $(gcry_sha512_module_SOURCES) $(nodist_gcry_sha512_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha512_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_tiger.module
+MODULE_FILES += gcry_tiger.module$(EXEEXT)
+gcry_tiger_module_SOURCES = lib/libgcrypt-grub/cipher/tiger.c ## platform sources
+nodist_gcry_tiger_module_SOURCES = ## platform nodist sources
+gcry_tiger_module_LDADD =
+gcry_tiger_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_tiger_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_tiger_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_tiger_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_tiger_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_tiger_module_SOURCES)
+CLEANFILES += $(nodist_gcry_tiger_module_SOURCES)
+MOD_FILES += gcry_tiger.mod
+MARKER_FILES += gcry_tiger.marker
+CLEANFILES += gcry_tiger.marker
+
+gcry_tiger.marker: $(gcry_tiger_module_SOURCES) $(nodist_gcry_tiger_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_tiger_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_twofish.module
+MODULE_FILES += gcry_twofish.module$(EXEEXT)
+gcry_twofish_module_SOURCES = lib/libgcrypt-grub/cipher/twofish.c ## platform sources
+nodist_gcry_twofish_module_SOURCES = ## platform nodist sources
+gcry_twofish_module_LDADD =
+gcry_twofish_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_twofish_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_twofish_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_twofish_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_twofish_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_twofish_module_SOURCES)
+CLEANFILES += $(nodist_gcry_twofish_module_SOURCES)
+MOD_FILES += gcry_twofish.mod
+MARKER_FILES += gcry_twofish.marker
+CLEANFILES += gcry_twofish.marker
+
+gcry_twofish.marker: $(gcry_twofish_module_SOURCES) $(nodist_gcry_twofish_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_twofish_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+platform_PROGRAMS += gcry_whirlpool.module
+MODULE_FILES += gcry_whirlpool.module$(EXEEXT)
+gcry_whirlpool_module_SOURCES = lib/libgcrypt-grub/cipher/whirlpool.c ## platform sources
+nodist_gcry_whirlpool_module_SOURCES = ## platform nodist sources
+gcry_whirlpool_module_LDADD =
+gcry_whirlpool_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_whirlpool_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_whirlpool_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_whirlpool_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_whirlpool_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_gcry_whirlpool_module_SOURCES)
+CLEANFILES += $(nodist_gcry_whirlpool_module_SOURCES)
+MOD_FILES += gcry_whirlpool.mod
+MARKER_FILES += gcry_whirlpool.marker
+CLEANFILES += gcry_whirlpool.marker
+
+gcry_whirlpool.marker: $(gcry_whirlpool_module_SOURCES) $(nodist_gcry_whirlpool_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_whirlpool_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+if COND_emu
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES =
+kernel_exec_SOURCES += disk/host.c kern/emu/cache_s.S kern/emu/hostdisk.c osdep/unix/hostdisk.c osdep/exec.c osdep/devmapper/hostdisk.c osdep/hostdisk.c kern/emu/hostfs.c kern/emu/main.c kern/emu/argp_common.c kern/emu/misc.c kern/emu/mm.c kern/emu/time.c kern/emu/cache.c osdep/emuconsole.c osdep/dl.c osdep/sleep.c osdep/init.c osdep/emunet.c osdep/cputime.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL) $(CFLAGS_GNULIB)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS_GNULIB)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -ed2022 -wd1106 -nu -nd $< $@; elif test ! -z '$(TARGET_OBJ2ELF)'; then $(TARGET_OBJ2ELF) $< $@ || (rm -f $@; exit 1); else cp $< $@; fi
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/i386/pc/startup.S
+kernel_exec_SOURCES += kern/i386/pc/init.c kern/i386/pc/mmap.c term/i386/pc/console.c kern/i386/dl.c kern/i386/tsc.c kern/i386/tsc_pit.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x9000
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_i386_efi
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/i386/efi/startup.S
+kernel_exec_SOURCES += kern/i386/efi/tsc.c kern/i386/tsc_pmtimer.c kern/i386/efi/init.c bus/pci.c kern/i386/dl.c kern/i386/tsc.c kern/i386/tsc_pit.c disk/efi/efidisk.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c term/efi/console.c kern/acpi.c kern/efi/acpi.c kern/efi/sb.c kern/lockdown.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/i386/qemu/startup.S
+kernel_exec_SOURCES += kern/i386/qemu/init.c bus/pci.c kern/vga_init.c kern/i386/qemu/mmap.c term/i386/pc/vga_text.c kern/i386/dl.c kern/i386/tsc.c kern/i386/tsc_pit.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x9000
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_i386_coreboot
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/i386/coreboot/startup.S
+kernel_exec_SOURCES += kern/i386/coreboot/init.c kern/i386/pc/acpi.c kern/acpi.c kern/i386/tsc_pmtimer.c kern/i386/coreboot/cbtable.c video/coreboot/cbfb.c kern/coreboot/mmap.c kern/coreboot/cbtable.c term/gfxterm.c font/font.c font/font_cmd.c io/bufio.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c video/fb/video_fb.c video/video.c term/i386/pc/vga_text.c kern/i386/dl.c kern/i386/tsc.c kern/i386/tsc_pit.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x9000
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_i386_multiboot
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/i386/coreboot/startup.S
+kernel_exec_SOURCES += kern/i386/coreboot/init.c kern/i386/pc/acpi.c kern/acpi.c kern/i386/multiboot_mmap.c term/i386/pc/vga_text.c kern/i386/dl.c kern/i386/tsc.c kern/i386/tsc_pit.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x9000
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_i386_ieee1275
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/i386/ieee1275/startup.S
+kernel_exec_SOURCES += disk/ieee1275/ofdisk.c kern/ieee1275/cmain.c kern/ieee1275/ieee1275.c kern/ieee1275/mmap.c kern/ieee1275/openfw.c term/ieee1275/console.c kern/ieee1275/init.c kern/i386/dl.c kern/i386/tsc.c kern/i386/tsc_pit.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x10000
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_x86_64_efi
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/x86_64/efi/startup.S
+kernel_exec_SOURCES += kern/i386/efi/tsc.c kern/i386/tsc_pmtimer.c kern/x86_64/efi/callwrap.S kern/i386/efi/init.c bus/pci.c kern/x86_64/dl.c kern/i386/tsc.c kern/i386/tsc_pit.c disk/efi/efidisk.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c term/efi/console.c kern/acpi.c kern/efi/acpi.c kern/efi/sb.c kern/lockdown.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_i386_xen
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/i386/xen/startup.S
+kernel_exec_SOURCES += kern/i386/dl.c kern/i386/xen/hypercall.S kern/i386/tsc.c kern/i386/xen/tsc.c kern/xen/init.c term/xen/console.c disk/xen/xendisk.c commands/boot.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_x86_64_xen
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/x86_64/xen/startup.S
+kernel_exec_SOURCES += kern/x86_64/dl.c kern/x86_64/xen/hypercall.S kern/i386/tsc.c kern/i386/xen/tsc.c kern/xen/init.c term/xen/console.c disk/xen/xendisk.c commands/boot.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_i386_xen_pvh
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/i386/xen/startup_pvh.S
+kernel_exec_SOURCES += kern/i386/dl.c commands/boot.c disk/xen/xendisk.c kern/i386/tsc.c kern/i386/xen/tsc.c kern/i386/xen/pvh.c kern/xen/init.c term/xen/console.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x100000
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/mips/startup.S
+kernel_exec_SOURCES += term/ns8250.c bus/bonito.c bus/cs5536.c bus/pci.c kern/mips/loongson/init.c term/at_keyboard.c term/ps2.c commands/boot.c term/serial.c video/sm712.c video/sis315pro.c video/radeon_fuloong2e.c video/radeon_yeeloong3a.c commands/keylayouts.c term/gfxterm.c font/font.c font/font_cmd.c io/bufio.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c video/fb/video_fb.c video/video.c kern/generic/rtc_get_time_ms.c kern/mips/cache.S kern/mips/dl.c kern/mips/init.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-Ttext,0x80200000
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/sparc64/ieee1275/crt0.S
+kernel_exec_SOURCES += kern/sparc64/cache.S kern/sparc64/dl.c kern/sparc64/ieee1275/ieee1275.c disk/ieee1275/obdisk.c disk/ieee1275/ofdisk.c kern/ieee1275/cmain.c kern/ieee1275/ieee1275.c kern/ieee1275/mmap.c kern/ieee1275/openfw.c term/ieee1275/console.c kern/ieee1275/init.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-Ttext,0x4400
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_powerpc_ieee1275
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/powerpc/ieee1275/startup.S
+kernel_exec_SOURCES += kern/powerpc/cache.S kern/powerpc/dl.c kern/powerpc/compiler-rt.S disk/ieee1275/ofdisk.c kern/ieee1275/cmain.c kern/ieee1275/ieee1275.c kern/ieee1275/mmap.c kern/ieee1275/openfw.c term/ieee1275/console.c kern/ieee1275/init.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-Ttext,0x200000
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/mips/startup.S
+kernel_exec_SOURCES += kern/mips/arc/init.c term/arc/console.c disk/arc/arcdisk.c kern/generic/rtc_get_time_ms.c kern/mips/cache.S kern/mips/dl.c kern/mips/init.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-Ttext,$(TARGET_LINK_ADDR)
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) -DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_ia64_efi
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES =
+kernel_exec_SOURCES += kern/ia64/efi/startup.S kern/ia64/efi/init.c kern/ia64/dl.c kern/ia64/dl_helper.c kern/ia64/cache.c lib/division.c disk/efi/efidisk.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c term/efi/console.c kern/acpi.c kern/efi/acpi.c kern/efi/sb.c kern/lockdown.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL) -fno-builtin -fpic -minline-int-divide-max-throughput
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/mips/startup.S
+kernel_exec_SOURCES += kern/mips/qemu_mips/init.c term/ns8250.c term/serial.c term/at_keyboard.c term/ps2.c commands/boot.c commands/keylayouts.c term/i386/pc/vga_text.c kern/vga_init.c kern/generic/rtc_get_time_ms.c kern/mips/cache.S kern/mips/dl.c kern/mips/init.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-Ttext,0x80200000
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_arm_uboot
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/arm/startup.S
+kernel_exec_SOURCES += kern/arm/uboot/init.c kern/arm/uboot/uboot.S disk/uboot/ubootdisk.c kern/uboot/uboot.c kern/uboot/init.c kern/uboot/hw.c term/uboot/console.c kern/arm/dl.c kern/arm/dl_helper.c kern/arm/cache_armv6.S kern/arm/cache_armv7.S kern/arm/cache.c kern/arm/compiler-rt.S lib/division.c term/terminfo.c term/tparm.c commands/extcmd.c lib/arg.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_arm_efi
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/arm/efi/startup.S
+kernel_exec_SOURCES += kern/arm/efi/init.c kern/efi/fdt.c kern/arm/dl.c kern/arm/dl_helper.c kern/arm/cache_armv6.S kern/arm/cache_armv7.S kern/arm/cache.c kern/arm/compiler-rt.S lib/division.c disk/efi/efidisk.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c term/efi/console.c kern/acpi.c kern/efi/acpi.c kern/efi/sb.c kern/lockdown.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_arm64_efi
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/arm64/efi/startup.S
+kernel_exec_SOURCES += kern/arm64/efi/init.c kern/efi/fdt.c kern/arm64/cache.c kern/arm64/cache_flush.S kern/arm64/dl.c kern/arm64/dl_helper.c disk/efi/efidisk.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c term/efi/console.c kern/acpi.c kern/efi/acpi.c kern/efi/sb.c kern/lockdown.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_arm_coreboot
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/arm/startup.S
+kernel_exec_SOURCES += kern/arm/coreboot/init.c kern/arm/coreboot/timer.c kern/arm/coreboot/coreboot.S lib/fdt.c bus/fdt.c term/ps2.c term/arm/pl050.c term/arm/cros.c term/arm/cros_ec.c bus/spi/rk3288_spi.c commands/keylayouts.c kern/arm/coreboot/dma.c kern/arm/coreboot/cbtable.c video/coreboot/cbfb.c kern/coreboot/mmap.c kern/coreboot/cbtable.c term/gfxterm.c font/font.c font/font_cmd.c io/bufio.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c video/fb/video_fb.c video/video.c kern/arm/dl.c kern/arm/dl_helper.c kern/arm/cache_armv6.S kern/arm/cache_armv7.S kern/arm/cache.c kern/arm/compiler-rt.S lib/division.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_riscv32_efi
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/riscv/efi/startup.S
+kernel_exec_SOURCES += kern/riscv/efi/init.c kern/efi/fdt.c kern/riscv/cache.c kern/riscv/cache_flush.S kern/riscv/dl.c lib/division.c disk/efi/efidisk.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c term/efi/console.c kern/acpi.c kern/efi/acpi.c kern/efi/sb.c kern/lockdown.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_riscv64_efi
+platform_PROGRAMS += kernel.exec
+kernel_exec_SOURCES = kern/riscv/efi/startup.S
+kernel_exec_SOURCES += kern/riscv/efi/init.c kern/efi/fdt.c kern/riscv/cache.c kern/riscv/cache_flush.S kern/riscv/dl.c disk/efi/efidisk.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c term/efi/console.c kern/acpi.c kern/efi/acpi.c kern/efi/sb.c kern/lockdown.c kern/compiler-rt.c kern/mm.c kern/time.c kern/generic/millisleep.c kern/buffer.c kern/command.c kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c kern/misc.c kern/parser.c kern/partition.c kern/rescue_parser.c kern/rescue_reader.c kern/term.c kern/verifiers.c
+nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+kernel_exec_LDADD =
+kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame
+kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dist_noinst_DATA += video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+BUILT_SOURCES += $(nodist_kernel_exec_SOURCES)
+CLEANFILES += $(nodist_kernel_exec_SOURCES)
+platform_DATA += kernel.img
+CLEANFILES += kernel.img
+
+kernel.img: kernel.exec$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += boot.image
+boot_image_SOURCES = boot/i386/pc/boot.S
+nodist_boot_image_SOURCES = ## platform nodist sources
+boot_image_LDADD =
+boot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+boot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x7C00
+boot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+boot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+boot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_image_SOURCES)
+CLEANFILES += $(nodist_boot_image_SOURCES)
+platform_DATA += boot.img
+CLEANFILES += boot.img
+
+boot.img: boot.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(boot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_i386_qemu
+platform_PROGRAMS += boot.image
+boot_image_SOURCES = boot/i386/qemu/boot.S
+nodist_boot_image_SOURCES = ## platform nodist sources
+boot_image_LDADD =
+boot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+boot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)
+boot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+boot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
+boot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_image_SOURCES)
+CLEANFILES += $(nodist_boot_image_SOURCES)
+platform_DATA += boot.img
+CLEANFILES += boot.img
+
+boot.img: boot.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(boot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += boot.image
+boot_image_SOURCES = boot/sparc64/ieee1275/boot.S
+nodist_boot_image_SOURCES = ## platform nodist sources
+boot_image_LDADD =
+boot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+boot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext=0x3fe0
+boot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+boot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+boot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_image_SOURCES)
+CLEANFILES += $(nodist_boot_image_SOURCES)
+platform_DATA += boot.img
+CLEANFILES += boot.img
+
+boot.img: boot.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(boot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += boot_hybrid.image
+boot_hybrid_image_SOURCES = boot/i386/pc/boot.S
+nodist_boot_hybrid_image_SOURCES = ## platform nodist sources
+boot_hybrid_image_LDADD =
+boot_hybrid_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+boot_hybrid_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x7C00
+boot_hybrid_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -DHYBRID_BOOT=1
+boot_hybrid_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+boot_hybrid_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_boot_hybrid_image_SOURCES)
+CLEANFILES += $(nodist_boot_hybrid_image_SOURCES)
+platform_DATA += boot_hybrid.img
+CLEANFILES += boot_hybrid.img
+
+boot_hybrid.img: boot_hybrid.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(boot_hybrid_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += cdboot.image
+cdboot_image_SOURCES = boot/i386/pc/cdboot.S
+nodist_cdboot_image_SOURCES = ## platform nodist sources
+cdboot_image_LDADD =
+cdboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+cdboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x7C00
+cdboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+cdboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+cdboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cdboot_image_SOURCES)
+CLEANFILES += $(nodist_cdboot_image_SOURCES)
+platform_DATA += cdboot.img
+CLEANFILES += cdboot.img
+
+cdboot.img: cdboot.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(cdboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += cdboot.image
+cdboot_image_SOURCES = boot/sparc64/ieee1275/boot.S
+nodist_cdboot_image_SOURCES = ## platform nodist sources
+cdboot_image_LDADD =
+cdboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+cdboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext=0x3fe0
+cdboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -DCDBOOT=1
+cdboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+cdboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_cdboot_image_SOURCES)
+CLEANFILES += $(nodist_cdboot_image_SOURCES)
+platform_DATA += cdboot.img
+CLEANFILES += cdboot.img
+
+cdboot.img: cdboot.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(cdboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += pxeboot.image
+pxeboot_image_SOURCES = boot/i386/pc/pxeboot.S
+nodist_pxeboot_image_SOURCES = ## platform nodist sources
+pxeboot_image_LDADD =
+pxeboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+pxeboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x7C00
+pxeboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+pxeboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+pxeboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_pxeboot_image_SOURCES)
+CLEANFILES += $(nodist_pxeboot_image_SOURCES)
+platform_DATA += pxeboot.img
+CLEANFILES += pxeboot.img
+
+pxeboot.img: pxeboot.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(pxeboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += diskboot.image
+diskboot_image_SOURCES = boot/i386/pc/diskboot.S
+nodist_diskboot_image_SOURCES = ## platform nodist sources
+diskboot_image_LDADD =
+diskboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+diskboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x8000
+diskboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+diskboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+diskboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_diskboot_image_SOURCES)
+CLEANFILES += $(nodist_diskboot_image_SOURCES)
+platform_DATA += diskboot.img
+CLEANFILES += diskboot.img
+
+diskboot.img: diskboot.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(diskboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_sparc64_ieee1275
+platform_PROGRAMS += diskboot.image
+diskboot_image_SOURCES = boot/sparc64/ieee1275/diskboot.S
+nodist_diskboot_image_SOURCES = ## platform nodist sources
+diskboot_image_LDADD =
+diskboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+diskboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext=0x4200
+diskboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+diskboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+diskboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_diskboot_image_SOURCES)
+CLEANFILES += $(nodist_diskboot_image_SOURCES)
+platform_DATA += diskboot.img
+CLEANFILES += diskboot.img
+
+diskboot.img: diskboot.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(diskboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += lnxboot.image
+lnxboot_image_SOURCES = boot/i386/pc/lnxboot.S
+nodist_lnxboot_image_SOURCES = ## platform nodist sources
+lnxboot_image_LDADD =
+lnxboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+lnxboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x6000
+lnxboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+lnxboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+lnxboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lnxboot_image_SOURCES)
+CLEANFILES += $(nodist_lnxboot_image_SOURCES)
+platform_DATA += lnxboot.img
+CLEANFILES += lnxboot.img
+
+lnxboot.img: lnxboot.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(lnxboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += xz_decompress.image
+xz_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/minilib.c boot/decompressor/xz.c lib/xzembed/xz_dec_bcj.c lib/xzembed/xz_dec_lzma2.c lib/xzembed/xz_dec_stream.c kern/compiler-rt.c
+nodist_xz_decompress_image_SOURCES = ## platform nodist sources
+xz_decompress_image_LDADD =
+xz_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE) -Wno-unreachable-code
+xz_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+xz_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1
+xz_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+xz_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xz_decompress_image_SOURCES)
+CLEANFILES += $(nodist_xz_decompress_image_SOURCES)
+platform_DATA += xz_decompress.img
+CLEANFILES += xz_decompress.img
+
+xz_decompress.img: xz_decompress.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(xz_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += xz_decompress.image
+xz_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/minilib.c boot/decompressor/xz.c lib/xzembed/xz_dec_bcj.c lib/xzembed/xz_dec_lzma2.c lib/xzembed/xz_dec_stream.c kern/compiler-rt.c
+nodist_xz_decompress_image_SOURCES = ## platform nodist sources
+xz_decompress_image_LDADD =
+xz_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE) -Wno-unreachable-code
+xz_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+xz_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1
+xz_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+xz_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xz_decompress_image_SOURCES)
+CLEANFILES += $(nodist_xz_decompress_image_SOURCES)
+platform_DATA += xz_decompress.img
+CLEANFILES += xz_decompress.img
+
+xz_decompress.img: xz_decompress.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(xz_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += xz_decompress.image
+xz_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/minilib.c boot/decompressor/xz.c lib/xzembed/xz_dec_bcj.c lib/xzembed/xz_dec_lzma2.c lib/xzembed/xz_dec_stream.c kern/compiler-rt.c
+nodist_xz_decompress_image_SOURCES = ## platform nodist sources
+xz_decompress_image_LDADD =
+xz_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE) -Wno-unreachable-code
+xz_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+xz_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1
+xz_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+xz_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_xz_decompress_image_SOURCES)
+CLEANFILES += $(nodist_xz_decompress_image_SOURCES)
+platform_DATA += xz_decompress.img
+CLEANFILES += xz_decompress.img
+
+xz_decompress.img: xz_decompress.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(xz_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += none_decompress.image
+none_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/none.c
+nodist_none_decompress_image_SOURCES = ## platform nodist sources
+none_decompress_image_LDADD =
+none_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+none_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+none_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -DGRUB_EMBED_DECOMPRESSOR=1
+none_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+none_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_none_decompress_image_SOURCES)
+CLEANFILES += $(nodist_none_decompress_image_SOURCES)
+platform_DATA += none_decompress.img
+CLEANFILES += none_decompress.img
+
+none_decompress.img: none_decompress.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(none_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_mips_arc
+platform_PROGRAMS += none_decompress.image
+none_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/none.c
+nodist_none_decompress_image_SOURCES = ## platform nodist sources
+none_decompress_image_LDADD =
+none_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+none_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+none_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -DGRUB_EMBED_DECOMPRESSOR=1
+none_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+none_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_none_decompress_image_SOURCES)
+CLEANFILES += $(nodist_none_decompress_image_SOURCES)
+platform_DATA += none_decompress.img
+CLEANFILES += none_decompress.img
+
+none_decompress.img: none_decompress.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(none_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_mips_qemu_mips
+platform_PROGRAMS += none_decompress.image
+none_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/none.c
+nodist_none_decompress_image_SOURCES = ## platform nodist sources
+none_decompress_image_LDADD =
+none_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+none_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+none_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -DGRUB_EMBED_DECOMPRESSOR=1
+none_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+none_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_none_decompress_image_SOURCES)
+CLEANFILES += $(nodist_none_decompress_image_SOURCES)
+platform_DATA += none_decompress.img
+CLEANFILES += none_decompress.img
+
+none_decompress.img: none_decompress.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(none_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_i386_pc
+platform_PROGRAMS += lzma_decompress.image
+lzma_decompress_image_SOURCES = boot/i386/pc/startup_raw.S
+nodist_lzma_decompress_image_SOURCES = rs_decoder.h ## platform nodist sources
+lzma_decompress_image_LDADD =
+lzma_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+lzma_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x8200
+lzma_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+lzma_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+lzma_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_lzma_decompress_image_SOURCES)
+CLEANFILES += $(nodist_lzma_decompress_image_SOURCES)
+platform_DATA += lzma_decompress.img
+CLEANFILES += lzma_decompress.img
+
+lzma_decompress.img: lzma_decompress.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(lzma_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += fwstart.image
+fwstart_image_SOURCES = boot/mips/loongson/fwstart.S
+nodist_fwstart_image_SOURCES = ## platform nodist sources
+fwstart_image_LDADD =
+fwstart_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+fwstart_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic
+fwstart_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+fwstart_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+fwstart_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fwstart_image_SOURCES)
+CLEANFILES += $(nodist_fwstart_image_SOURCES)
+platform_DATA += fwstart.img
+CLEANFILES += fwstart.img
+
+fwstart.img: fwstart.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(fwstart_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_mips_loongson
+platform_PROGRAMS += fwstart_fuloong2f.image
+fwstart_fuloong2f_image_SOURCES = boot/mips/loongson/fuloong2f.S
+nodist_fwstart_fuloong2f_image_SOURCES = ## platform nodist sources
+fwstart_fuloong2f_image_LDADD =
+fwstart_fuloong2f_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+fwstart_fuloong2f_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic
+fwstart_fuloong2f_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+fwstart_fuloong2f_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+fwstart_fuloong2f_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_fwstart_fuloong2f_image_SOURCES)
+CLEANFILES += $(nodist_fwstart_fuloong2f_image_SOURCES)
+platform_DATA += fwstart_fuloong2f.img
+CLEANFILES += fwstart_fuloong2f.img
+
+fwstart_fuloong2f.img: fwstart_fuloong2f.image$(EXEEXT)
+ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(fwstart_fuloong2f_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+endif
+
+if COND_emu
+bin_PROGRAMS += grub-emu
+if COND_MAN_PAGES
+man_MANS += grub-emu.1
+
+grub-emu.1: grub-emu
+ chmod a+x grub-emu
+ PATH=$(builddir):$$PATH pkgdatadir=$(builddir) $(HELP2MAN) --section=1 -i $(top_srcdir)/docs/man/grub-emu.h2m -o $@ grub-emu
+
+CLEANFILES += grub-emu.1
+endif
+grub_emu_SOURCES = kern/emu/full.c
+nodist_grub_emu_SOURCES = grub_emu_init.c
+grub_emu_LDADD = kernel.exec$(EXEEXT) $(MODULE_FILES) lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)
+grub_emu_CFLAGS = $(AM_CFLAGS) $(CFLAGS_PROGRAM)
+grub_emu_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM)
+grub_emu_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_PROGRAM)
+grub_emu_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_PROGRAM)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_grub_emu_SOURCES)
+CLEANFILES += $(nodist_grub_emu_SOURCES)
+endif
+
+if COND_emu
+bin_PROGRAMS += grub-emu-lite
+grub_emu_lite_SOURCES = kern/emu/lite.c
+nodist_grub_emu_lite_SOURCES = symlist.c
+grub_emu_lite_LDADD = kernel.exec$(EXEEXT) lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)
+grub_emu_lite_CFLAGS = $(AM_CFLAGS) $(CFLAGS_PROGRAM)
+grub_emu_lite_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM)
+grub_emu_lite_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_PROGRAM)
+grub_emu_lite_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_PROGRAM)
+dist_noinst_DATA +=
+BUILT_SOURCES += $(nodist_grub_emu_lite_SOURCES)
+CLEANFILES += $(nodist_grub_emu_lite_SOURCES)
+endif
+noinst_DATA += gensyminfo.sh
+
+gensyminfo.sh: $(top_builddir)/config.status gensyminfo.sh.in
+ (for x in gensyminfo.sh.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x gensyminfo.sh
+
+CLEANFILES += gensyminfo.sh
+EXTRA_DIST +=
+dist_noinst_DATA += gensyminfo.sh.in
+noinst_DATA += genmod.sh
+
+genmod.sh: $(top_builddir)/config.status genmod.sh.in
+ (for x in genmod.sh.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x genmod.sh
+
+CLEANFILES += genmod.sh
+EXTRA_DIST +=
+dist_noinst_DATA += genmod.sh.in
+noinst_DATA += modinfo.sh
+
+modinfo.sh: $(top_builddir)/config.status modinfo.sh.in
+ (for x in modinfo.sh.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x modinfo.sh
+
+CLEANFILES += modinfo.sh
+EXTRA_DIST +=
+dist_noinst_DATA += modinfo.sh.in
+platform_DATA += gmodule.pl
+
+gmodule.pl: $(top_builddir)/config.status gmodule.pl.in
+ (for x in gmodule.pl.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x gmodule.pl
+
+CLEANFILES += gmodule.pl
+EXTRA_DIST +=
+dist_noinst_DATA += gmodule.pl.in
+platform_DATA += gdb_grub
+
+gdb_grub: $(top_builddir)/config.status gdb_grub.in
+ (for x in gdb_grub.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x gdb_grub
+
+CLEANFILES += gdb_grub
+EXTRA_DIST +=
+dist_noinst_DATA += gdb_grub.in
+
+if COND_powerpc_ieee1275
+platform_DATA += grub.chrp
+
+grub.chrp: $(top_builddir)/config.status boot/powerpc/grub.chrp.in
+ (for x in boot/powerpc/grub.chrp.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x grub.chrp
+
+CLEANFILES += grub.chrp
+EXTRA_DIST +=
+dist_noinst_DATA += boot/powerpc/grub.chrp.in
+endif
+
+if COND_powerpc_ieee1275
+platform_DATA += bootinfo.txt
+
+bootinfo.txt: $(top_builddir)/config.status boot/powerpc/bootinfo.txt.in
+ (for x in boot/powerpc/bootinfo.txt.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x bootinfo.txt
+
+CLEANFILES += bootinfo.txt
+EXTRA_DIST +=
+dist_noinst_DATA += boot/powerpc/bootinfo.txt.in
+endif
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
new file mode 100644
index 0000000..8022e1c
--- /dev/null
+++ b/grub-core/Makefile.core.def
@@ -0,0 +1,2529 @@
+AutoGen definitions Makefile.tpl;
+
+transform_data = {
+ installdir = noinst;
+ name = gensyminfo.sh;
+ common = gensyminfo.sh.in;
+};
+
+transform_data = {
+ installdir = noinst;
+ name = genmod.sh;
+ common = genmod.sh.in;
+};
+
+transform_data = {
+ installdir = noinst;
+ name = modinfo.sh;
+ common = modinfo.sh.in;
+};
+
+transform_data = {
+ installdir = platform;
+ name = gmodule.pl;
+ common = gmodule.pl.in;
+};
+
+transform_data = {
+ installdir = platform;
+ name = gdb_grub;
+ common = gdb_grub.in;
+};
+
+transform_data = {
+ installdir = platform;
+ name = grub.chrp;
+ common = boot/powerpc/grub.chrp.in;
+ enable = powerpc_ieee1275;
+};
+
+transform_data = {
+ installdir = platform;
+ name = bootinfo.txt;
+ common = boot/powerpc/bootinfo.txt.in;
+ enable = powerpc_ieee1275;
+};
+
+kernel = {
+ name = kernel;
+
+ nostrip = emu;
+
+ emu_ldflags = '-Wl,-r,-d';
+ i386_efi_ldflags = '-Wl,-r,-d';
+ i386_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+ x86_64_efi_ldflags = '-Wl,-r,-d';
+ x86_64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+
+ ia64_efi_cflags = '-fno-builtin -fpic -minline-int-divide-max-throughput';
+ ia64_efi_ldflags = '-Wl,-r,-d';
+ ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+
+ arm_efi_ldflags = '-Wl,-r,-d';
+ arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+
+ arm64_efi_ldflags = '-Wl,-r,-d';
+ arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
+
+ riscv32_efi_ldflags = '-Wl,-r,-d';
+ riscv32_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
+
+ riscv64_efi_ldflags = '-Wl,-r,-d';
+ riscv64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
+ i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
+ i386_coreboot_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_coreboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
+ i386_multiboot_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_multiboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
+ i386_ieee1275_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_ieee1275_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x10000';
+ i386_xen_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0';
+ x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0';
+ i386_xen_pvh_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_xen_pvh_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x100000';
+
+ mips_loongson_ldflags = '-Wl,-Ttext,0x80200000';
+ powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
+ sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
+ mips_arc_ldflags = '-Wl,-Ttext,$(TARGET_LINK_ADDR)';
+ mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000';
+
+ mips_arc_cppflags = '-DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)';
+ i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
+ emu_cflags = '$(CFLAGS_GNULIB)';
+ emu_cppflags = '$(CPPFLAGS_GNULIB)';
+ arm_uboot_ldflags = '-Wl,-r,-d';
+ arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+ arm_coreboot_ldflags = '-Wl,-r,-d';
+ arm_coreboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+
+ i386_pc_startup = kern/i386/pc/startup.S;
+ i386_efi_startup = kern/i386/efi/startup.S;
+ x86_64_efi_startup = kern/x86_64/efi/startup.S;
+ i386_xen_startup = kern/i386/xen/startup.S;
+ x86_64_xen_startup = kern/x86_64/xen/startup.S;
+ i386_xen_pvh_startup = kern/i386/xen/startup_pvh.S;
+ i386_qemu_startup = kern/i386/qemu/startup.S;
+ i386_ieee1275_startup = kern/i386/ieee1275/startup.S;
+ i386_coreboot_startup = kern/i386/coreboot/startup.S;
+ i386_multiboot_startup = kern/i386/coreboot/startup.S;
+ mips_startup = kern/mips/startup.S;
+ sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S;
+ powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
+ arm_uboot_startup = kern/arm/startup.S;
+ arm_coreboot_startup = kern/arm/startup.S;
+ arm_efi_startup = kern/arm/efi/startup.S;
+ arm64_efi_startup = kern/arm64/efi/startup.S;
+ riscv32_efi_startup = kern/riscv/efi/startup.S;
+ riscv64_efi_startup = kern/riscv/efi/startup.S;
+
+ common = kern/buffer.c;
+ common = kern/command.c;
+ common = kern/corecmd.c;
+ common = kern/device.c;
+ common = kern/disk.c;
+ common = kern/dl.c;
+ common = kern/env.c;
+ common = kern/err.c;
+ common = kern/file.c;
+ common = kern/fs.c;
+ common = kern/list.c;
+ common = kern/main.c;
+ common = kern/misc.c;
+ common = kern/parser.c;
+ common = kern/partition.c;
+ common = kern/rescue_parser.c;
+ common = kern/rescue_reader.c;
+ common = kern/term.c;
+ common = kern/verifiers.c;
+
+ noemu = kern/compiler-rt.c;
+ noemu = kern/mm.c;
+ noemu = kern/time.c;
+ noemu = kern/generic/millisleep.c;
+
+ noemu_nodist = symlist.c;
+
+ mips = kern/generic/rtc_get_time_ms.c;
+
+ ieee1275 = disk/ieee1275/ofdisk.c;
+ ieee1275 = kern/ieee1275/cmain.c;
+ ieee1275 = kern/ieee1275/ieee1275.c;
+ ieee1275 = kern/ieee1275/mmap.c;
+ ieee1275 = kern/ieee1275/openfw.c;
+ ieee1275 = term/ieee1275/console.c;
+ ieee1275 = kern/ieee1275/init.c;
+
+ uboot = disk/uboot/ubootdisk.c;
+ uboot = kern/uboot/uboot.c;
+ uboot = kern/uboot/init.c;
+ uboot = kern/uboot/hw.c;
+ uboot = term/uboot/console.c;
+ arm_uboot = kern/arm/uboot/init.c;
+ arm_uboot = kern/arm/uboot/uboot.S;
+
+ arm_coreboot = kern/arm/coreboot/init.c;
+ arm_coreboot = kern/arm/coreboot/timer.c;
+ arm_coreboot = kern/arm/coreboot/coreboot.S;
+ arm_coreboot = lib/fdt.c;
+ arm_coreboot = bus/fdt.c;
+ arm_coreboot = term/ps2.c;
+ arm_coreboot = term/arm/pl050.c;
+ arm_coreboot = term/arm/cros.c;
+ arm_coreboot = term/arm/cros_ec.c;
+ arm_coreboot = bus/spi/rk3288_spi.c;
+ arm_coreboot = commands/keylayouts.c;
+ arm_coreboot = kern/arm/coreboot/dma.c;
+
+ terminfoinkernel = term/terminfo.c;
+ terminfoinkernel = term/tparm.c;
+ terminfoinkernel = commands/extcmd.c;
+ terminfoinkernel = lib/arg.c;
+
+ softdiv = lib/division.c;
+
+ i386 = kern/i386/dl.c;
+ i386_xen = kern/i386/dl.c;
+ i386_xen_pvh = kern/i386/dl.c;
+
+ i386_coreboot = kern/i386/coreboot/init.c;
+ i386_multiboot = kern/i386/coreboot/init.c;
+ i386_qemu = kern/i386/qemu/init.c;
+ i386_coreboot_multiboot_qemu = term/i386/pc/vga_text.c;
+ coreboot = video/coreboot/cbfb.c;
+
+ efi = disk/efi/efidisk.c;
+ efi = kern/efi/efi.c;
+ efi = kern/efi/init.c;
+ efi = kern/efi/mm.c;
+ efi = term/efi/console.c;
+ efi = kern/acpi.c;
+ efi = kern/efi/acpi.c;
+ efi = kern/efi/sb.c;
+ efi = kern/lockdown.c;
+ i386_coreboot = kern/i386/pc/acpi.c;
+ i386_multiboot = kern/i386/pc/acpi.c;
+ i386_coreboot = kern/acpi.c;
+ i386_multiboot = kern/acpi.c;
+
+ x86 = kern/i386/tsc.c;
+ x86 = kern/i386/tsc_pit.c;
+ i386_efi = kern/i386/efi/tsc.c;
+ x86_64_efi = kern/i386/efi/tsc.c;
+ i386_efi = kern/i386/tsc_pmtimer.c;
+ i386_coreboot = kern/i386/tsc_pmtimer.c;
+ x86_64_efi = kern/i386/tsc_pmtimer.c;
+
+ i386_efi = kern/i386/efi/init.c;
+ i386_efi = bus/pci.c;
+
+ x86_64 = kern/x86_64/dl.c;
+ x86_64_xen = kern/x86_64/dl.c;
+ x86_64_efi = kern/x86_64/efi/callwrap.S;
+ x86_64_efi = kern/i386/efi/init.c;
+ x86_64_efi = bus/pci.c;
+
+ xen = kern/i386/tsc.c;
+ xen = kern/i386/xen/tsc.c;
+ x86_64_xen = kern/x86_64/xen/hypercall.S;
+ i386_xen = kern/i386/xen/hypercall.S;
+ xen = kern/xen/init.c;
+ xen = term/xen/console.c;
+ xen = disk/xen/xendisk.c;
+ xen = commands/boot.c;
+
+ i386_xen_pvh = commands/boot.c;
+ i386_xen_pvh = disk/xen/xendisk.c;
+ i386_xen_pvh = kern/i386/tsc.c;
+ i386_xen_pvh = kern/i386/xen/tsc.c;
+ i386_xen_pvh = kern/i386/xen/pvh.c;
+ i386_xen_pvh = kern/xen/init.c;
+ i386_xen_pvh = term/xen/console.c;
+
+ ia64_efi = kern/ia64/efi/startup.S;
+ ia64_efi = kern/ia64/efi/init.c;
+ ia64_efi = kern/ia64/dl.c;
+ ia64_efi = kern/ia64/dl_helper.c;
+ ia64_efi = kern/ia64/cache.c;
+
+ arm_efi = kern/arm/efi/init.c;
+ arm_efi = kern/efi/fdt.c;
+
+ arm64_efi = kern/arm64/efi/init.c;
+ arm64_efi = kern/efi/fdt.c;
+
+ riscv32_efi = kern/riscv/efi/init.c;
+ riscv32_efi = kern/efi/fdt.c;
+
+ riscv64_efi = kern/riscv/efi/init.c;
+ riscv64_efi = kern/efi/fdt.c;
+
+ i386_pc = kern/i386/pc/init.c;
+ i386_pc = kern/i386/pc/mmap.c;
+ i386_pc = term/i386/pc/console.c;
+
+ i386_qemu = bus/pci.c;
+ i386_qemu = kern/vga_init.c;
+ i386_qemu = kern/i386/qemu/mmap.c;
+
+ coreboot = kern/coreboot/mmap.c;
+ i386_coreboot = kern/i386/coreboot/cbtable.c;
+ coreboot = kern/coreboot/cbtable.c;
+ arm_coreboot = kern/arm/coreboot/cbtable.c;
+
+ i386_multiboot = kern/i386/multiboot_mmap.c;
+
+ mips = kern/mips/cache.S;
+ mips = kern/mips/dl.c;
+ mips = kern/mips/init.c;
+
+ mips_qemu_mips = kern/mips/qemu_mips/init.c;
+ mips_qemu_mips = term/ns8250.c;
+ mips_qemu_mips = term/serial.c;
+ mips_qemu_mips = term/at_keyboard.c;
+ mips_qemu_mips = term/ps2.c;
+ mips_qemu_mips = commands/boot.c;
+ mips_qemu_mips = commands/keylayouts.c;
+ mips_qemu_mips = term/i386/pc/vga_text.c;
+ mips_qemu_mips = kern/vga_init.c;
+
+ mips_arc = kern/mips/arc/init.c;
+ mips_arc = term/arc/console.c;
+ mips_arc = disk/arc/arcdisk.c;
+
+ mips_loongson = term/ns8250.c;
+ mips_loongson = bus/bonito.c;
+ mips_loongson = bus/cs5536.c;
+ mips_loongson = bus/pci.c;
+ mips_loongson = kern/mips/loongson/init.c;
+ mips_loongson = term/at_keyboard.c;
+ mips_loongson = term/ps2.c;
+ mips_loongson = commands/boot.c;
+ mips_loongson = term/serial.c;
+ mips_loongson = video/sm712.c;
+ mips_loongson = video/sis315pro.c;
+ mips_loongson = video/radeon_fuloong2e.c;
+ mips_loongson = video/radeon_yeeloong3a.c;
+ extra_dist = video/sm712_init.c;
+ extra_dist = video/sis315_init.c;
+ mips_loongson = commands/keylayouts.c;
+
+ powerpc_ieee1275 = kern/powerpc/cache.S;
+ powerpc_ieee1275 = kern/powerpc/dl.c;
+ powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
+
+ sparc64_ieee1275 = kern/sparc64/cache.S;
+ sparc64_ieee1275 = kern/sparc64/dl.c;
+ sparc64_ieee1275 = kern/sparc64/ieee1275/ieee1275.c;
+ sparc64_ieee1275 = disk/ieee1275/obdisk.c;
+
+ arm = kern/arm/dl.c;
+ arm = kern/arm/dl_helper.c;
+ arm = kern/arm/cache_armv6.S;
+ arm = kern/arm/cache_armv7.S;
+ extra_dist = kern/arm/cache.S;
+ arm = kern/arm/cache.c;
+ arm = kern/arm/compiler-rt.S;
+
+ arm64 = kern/arm64/cache.c;
+ arm64 = kern/arm64/cache_flush.S;
+ arm64 = kern/arm64/dl.c;
+ arm64 = kern/arm64/dl_helper.c;
+
+ riscv32 = kern/riscv/cache.c;
+ riscv32 = kern/riscv/cache_flush.S;
+ riscv32 = kern/riscv/dl.c;
+
+ riscv64 = kern/riscv/cache.c;
+ riscv64 = kern/riscv/cache_flush.S;
+ riscv64 = kern/riscv/dl.c;
+
+ emu = disk/host.c;
+ emu = kern/emu/cache_s.S;
+ emu = kern/emu/hostdisk.c;
+ emu = osdep/unix/hostdisk.c;
+ emu = osdep/exec.c;
+ extra_dist = osdep/unix/exec.c;
+ emu = osdep/devmapper/hostdisk.c;
+ emu = osdep/hostdisk.c;
+ emu = kern/emu/hostfs.c;
+ emu = kern/emu/main.c;
+ emu = kern/emu/argp_common.c;
+ emu = kern/emu/misc.c;
+ emu = kern/emu/mm.c;
+ emu = kern/emu/time.c;
+ emu = kern/emu/cache.c;
+ emu = osdep/emuconsole.c;
+ extra_dist = osdep/unix/emuconsole.c;
+ extra_dist = osdep/windows/emuconsole.c;
+ emu = osdep/dl.c;
+ extra_dist = osdep/unix/dl.c;
+ extra_dist = osdep/windows/dl.c;
+ emu = osdep/sleep.c;
+ emu = osdep/init.c;
+ emu = osdep/emunet.c;
+ extra_dist = osdep/linux/emunet.c;
+ extra_dist = osdep/basic/emunet.c;
+ emu = osdep/cputime.c;
+ extra_dist = osdep/unix/cputime.c;
+ extra_dist = osdep/windows/cputime.c;
+
+ videoinkernel = term/gfxterm.c;
+ videoinkernel = font/font.c;
+ videoinkernel = font/font_cmd.c;
+ videoinkernel = io/bufio.c;
+ videoinkernel = video/fb/fbblit.c;
+ videoinkernel = video/fb/fbfill.c;
+ videoinkernel = video/fb/fbutil.c;
+ videoinkernel = video/fb/video_fb.c;
+ videoinkernel = video/video.c;
+
+ extra_dist = kern/i386/int.S;
+ extra_dist = kern/i386/realmode.S;
+ extra_dist = boot/i386/pc/lzma_decode.S;
+ extra_dist = kern/mips/cache_flush.S;
+};
+
+program = {
+ name = grub-emu;
+ mansection = 1;
+
+ emu = kern/emu/full.c;
+ emu_nodist = grub_emu_init.c;
+
+ ldadd = 'kernel.exec$(EXEEXT)';
+ ldadd = '$(MODULE_FILES)';
+ ldadd = 'lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
+
+ enable = emu;
+};
+
+program = {
+ name = grub-emu-lite;
+
+ emu = kern/emu/lite.c;
+ emu_nodist = symlist.c;
+
+ ldadd = 'kernel.exec$(EXEEXT)';
+ ldadd = 'lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
+
+ enable = emu;
+};
+
+image = {
+ name = boot;
+ i386_pc = boot/i386/pc/boot.S;
+ i386_qemu = boot/i386/qemu/boot.S;
+ sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+
+ i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)';
+ i386_qemu_ccasflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
+
+ /* The entry point for a.out binaries on sparc64 starts
+ at 0x4000. Since we are writing the 32 bytes long a.out
+ header in the assembly code ourselves, we need to tell
+ the linker to adjust the start of the text segment to
+ 0x4000 - 0x20 = 0x3fe0.
+ */
+ sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0';
+ sparc64_ieee1275_objcopyflags = '-O binary';
+
+ objcopyflags = '-O binary';
+ enable = i386_pc;
+ enable = i386_qemu;
+ enable = sparc64_ieee1275;
+};
+
+image = {
+ name = boot_hybrid;
+ i386_pc = boot/i386/pc/boot.S;
+
+ cppflags = '-DHYBRID_BOOT=1';
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+
+ objcopyflags = '-O binary';
+ enable = i386_pc;
+};
+
+image = {
+ name = cdboot;
+
+ i386_pc = boot/i386/pc/cdboot.S;
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+
+ sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
+
+ /* See comment for sparc64_ieee1275_ldflags above. */
+ sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0';
+ sparc64_ieee1275_objcopyflags = '-O binary';
+ sparc64_ieee1275_cppflags = '-DCDBOOT=1';
+
+ objcopyflags = '-O binary';
+
+ enable = sparc64_ieee1275;
+ enable = i386_pc;
+};
+
+image = {
+ name = pxeboot;
+ i386_pc = boot/i386/pc/pxeboot.S;
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+
+ objcopyflags = '-O binary';
+ enable = i386_pc;
+};
+
+image = {
+ name = diskboot;
+ i386_pc = boot/i386/pc/diskboot.S;
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8000';
+
+ sparc64_ieee1275 = boot/sparc64/ieee1275/diskboot.S;
+ sparc64_ieee1275_ldflags = '-Wl,-Ttext=0x4200';
+
+ objcopyflags = '-O binary';
+
+ enable = i386_pc;
+ enable = sparc64_ieee1275;
+};
+
+image = {
+ name = lnxboot;
+ i386_pc = boot/i386/pc/lnxboot.S;
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x6000';
+
+ objcopyflags = '-O binary';
+ enable = i386_pc;
+};
+
+image = {
+ name = xz_decompress;
+ mips = boot/mips/startup_raw.S;
+ common = boot/decompressor/minilib.c;
+ common = boot/decompressor/xz.c;
+ common = lib/xzembed/xz_dec_bcj.c;
+ common = lib/xzembed/xz_dec_lzma2.c;
+ common = lib/xzembed/xz_dec_stream.c;
+ common = kern/compiler-rt.c;
+
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1';
+
+ objcopyflags = '-O binary';
+ mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
+ cflags = '-Wno-unreachable-code';
+ enable = mips;
+};
+
+image = {
+ name = none_decompress;
+ mips = boot/mips/startup_raw.S;
+ common = boot/decompressor/none.c;
+
+ cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
+
+ objcopyflags = '-O binary';
+ mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
+ enable = mips;
+};
+
+image = {
+ name = lzma_decompress;
+ i386_pc = boot/i386/pc/startup_raw.S;
+ i386_pc_nodist = rs_decoder.h;
+
+ objcopyflags = '-O binary';
+ ldflags = '$(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x8200';
+ enable = i386_pc;
+};
+
+image = {
+ name = fwstart;
+ mips_loongson = boot/mips/loongson/fwstart.S;
+ objcopyflags = '-O binary';
+ ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
+ enable = mips_loongson;
+};
+
+image = {
+ name = fwstart_fuloong2f;
+ mips_loongson = boot/mips/loongson/fuloong2f.S;
+ objcopyflags = '-O binary';
+ ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
+ enable = mips_loongson;
+};
+
+module = {
+ name = disk;
+ common = lib/disk.c;
+ extra_dist = kern/disk_common.c;
+};
+
+module = {
+ name = trig;
+ common_nodist = trigtables.c;
+ extra_dist = gentrigtables.c;
+};
+
+module = {
+ name = cs5536;
+ x86 = bus/cs5536.c;
+ enable = x86;
+};
+
+module = {
+ name = lsspd;
+ mips_loongson = commands/mips/loongson/lsspd.c;
+ enable = mips_loongson;
+};
+
+module = {
+ name = usb;
+ common = bus/usb/usb.c;
+ common = bus/usb/usbtrans.c;
+ common = bus/usb/usbhub.c;
+ enable = usb;
+};
+
+module = {
+ name = usbserial_common;
+ common = bus/usb/serial/common.c;
+ enable = usb;
+};
+
+module = {
+ name = usbserial_pl2303;
+ common = bus/usb/serial/pl2303.c;
+ enable = usb;
+};
+
+module = {
+ name = usbserial_ftdi;
+ common = bus/usb/serial/ftdi.c;
+ enable = usb;
+};
+
+module = {
+ name = usbserial_usbdebug;
+ common = bus/usb/serial/usbdebug_late.c;
+ enable = usb;
+};
+
+module = {
+ name = uhci;
+ common = bus/usb/uhci.c;
+ enable = pci;
+};
+
+module = {
+ name = ohci;
+ common = bus/usb/ohci.c;
+ enable = pci;
+};
+
+module = {
+ name = ehci;
+ common = bus/usb/ehci.c;
+ arm_coreboot = bus/usb/ehci-fdt.c;
+ pci = bus/usb/ehci-pci.c;
+ enable = pci;
+ enable = arm_coreboot;
+};
+
+module = {
+ name = pci;
+ common = bus/pci.c;
+ i386_ieee1275 = bus/i386/ieee1275/pci.c;
+
+ enable = i386_pc;
+ enable = i386_ieee1275;
+ enable = i386_coreboot;
+ enable = i386_multiboot;
+};
+
+module = {
+ name = nativedisk;
+ common = commands/nativedisk.c;
+
+ enable = x86;
+ enable = mips_loongson;
+ enable = mips_qemu_mips;
+};
+
+module = {
+ name = emupci;
+ common = bus/emu/pci.c;
+ common = commands/lspci.c;
+
+ enable = emu;
+ condition = COND_GRUB_EMU_PCI;
+};
+
+module = {
+ name = lsdev;
+ common = commands/arc/lsdev.c;
+
+ enable = mips_arc;
+};
+
+module = {
+ name = lsxen;
+ common = commands/xen/lsxen.c;
+
+ enable = xen;
+};
+
+module = {
+ name = cmostest;
+ common = commands/i386/cmostest.c;
+ enable = cmos;
+};
+
+module = {
+ name = cmosdump;
+ common = commands/i386/cmosdump.c;
+ enable = cmos;
+};
+
+module = {
+ name = iorw;
+ common = commands/iorw.c;
+ enable = x86;
+};
+
+module = {
+ name = cbtable;
+ common = kern/i386/coreboot/cbtable.c;
+ common = kern/coreboot/cbtable.c;
+ enable = i386_pc;
+ enable = i386_efi;
+ enable = i386_qemu;
+ enable = i386_multiboot;
+ enable = i386_ieee1275;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = cbtime;
+ common = commands/i386/coreboot/cb_timestamps.c;
+ enable = x86;
+};
+
+module = {
+ name = cbls;
+ common = commands/i386/coreboot/cbls.c;
+ enable = x86;
+};
+
+module = {
+ name = cbmemc;
+ common = term/i386/coreboot/cbmemc.c;
+ enable = x86;
+};
+
+module = {
+ name = regexp;
+ common = commands/regexp.c;
+ common = commands/wildcard.c;
+ common = lib/gnulib/regex.c;
+ cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
+ cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
+};
+
+module = {
+ name = acpi;
+
+ common = commands/acpi.c;
+ i386_pc = kern/acpi.c;
+ i386_pc = kern/i386/pc/acpi.c;
+
+ enable = efi;
+ enable = i386_pc;
+ enable = i386_coreboot;
+ enable = i386_multiboot;
+};
+
+module = {
+ name = lsacpi;
+
+ common = commands/lsacpi.c;
+
+ enable = efi;
+ enable = i386_pc;
+ enable = i386_coreboot;
+ enable = i386_multiboot;
+};
+
+module = {
+ name = lsefisystab;
+
+ common = commands/efi/lsefisystab.c;
+
+ enable = efi;
+};
+
+module = {
+ name = lssal;
+
+ common = commands/efi/lssal.c;
+
+ enable = efi;
+};
+
+module = {
+ name = lsefimmap;
+
+ common = commands/efi/lsefimmap.c;
+
+ enable = efi;
+};
+
+module = {
+ name = lsefi;
+ common = commands/efi/lsefi.c;
+ enable = efi;
+};
+
+module = {
+ name = efifwsetup;
+ efi = commands/efi/efifwsetup.c;
+ enable = efi;
+};
+
+module = {
+ name = blocklist;
+ common = commands/blocklist.c;
+};
+
+module = {
+ name = boot;
+ common = commands/boot.c;
+ i386_pc = lib/i386/pc/biosnum.c;
+ enable = x86;
+ enable = emu;
+ enable = sparc64_ieee1275;
+ enable = powerpc_ieee1275;
+ enable = mips_arc;
+ enable = ia64_efi;
+ enable = arm_efi;
+ enable = arm64_efi;
+ enable = arm_uboot;
+ enable = arm_coreboot;
+ enable = riscv32_efi;
+ enable = riscv64_efi;
+};
+
+module = {
+ name = cat;
+ common = commands/cat.c;
+};
+
+module = {
+ name = cmp;
+ common = commands/cmp.c;
+};
+
+module = {
+ name = configfile;
+ common = commands/configfile.c;
+};
+
+module = {
+ name = cpuid;
+ common = commands/i386/cpuid.c;
+ enable = x86;
+ enable = i386_xen_pvh;
+ enable = i386_xen;
+ enable = x86_64_xen;
+};
+
+module = {
+ name = date;
+ common = commands/date.c;
+};
+
+module = {
+ name = drivemap;
+
+ i386_pc = commands/i386/pc/drivemap.c;
+ i386_pc = commands/i386/pc/drivemap_int13h.S;
+ enable = i386_pc;
+};
+
+module = {
+ name = echo;
+ common = commands/echo.c;
+};
+
+module = {
+ name = eval;
+ common = commands/eval.c;
+};
+
+module = {
+ name = extcmd;
+ common = commands/extcmd.c;
+ common = lib/arg.c;
+ enable = terminfomodule;
+};
+
+module = {
+ name = fixvideo;
+ common = commands/efi/fixvideo.c;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = gptsync;
+ common = commands/gptsync.c;
+};
+
+module = {
+ name = halt;
+ nopc = commands/halt.c;
+ i386_pc = commands/i386/pc/halt.c;
+ i386_pc = commands/acpihalt.c;
+ i386_coreboot = commands/acpihalt.c;
+ i386_multiboot = commands/acpihalt.c;
+ i386_efi = commands/acpihalt.c;
+ x86_64_efi = commands/acpihalt.c;
+ i386_multiboot = lib/i386/halt.c;
+ i386_coreboot = lib/i386/halt.c;
+ i386_qemu = lib/i386/halt.c;
+ xen = lib/xen/halt.c;
+ i386_xen_pvh = lib/xen/halt.c;
+ efi = lib/efi/halt.c;
+ ieee1275 = lib/ieee1275/halt.c;
+ emu = lib/emu/halt.c;
+ uboot = lib/dummy/halt.c;
+ arm_coreboot = lib/dummy/halt.c;
+};
+
+module = {
+ name = reboot;
+ i386 = lib/i386/reboot.c;
+ i386 = lib/i386/reboot_trampoline.S;
+ powerpc_ieee1275 = lib/ieee1275/reboot.c;
+ sparc64_ieee1275 = lib/ieee1275/reboot.c;
+ mips_arc = lib/mips/arc/reboot.c;
+ mips_loongson = lib/mips/loongson/reboot.c;
+ mips_qemu_mips = lib/mips/qemu_mips/reboot.c;
+ xen = lib/xen/reboot.c;
+ i386_xen_pvh = lib/xen/reboot.c;
+ uboot = lib/uboot/reboot.c;
+ arm_coreboot = lib/dummy/reboot.c;
+ common = commands/reboot.c;
+};
+
+module = {
+ name = hashsum;
+ common = commands/hashsum.c;
+};
+
+module = {
+ name = pgp;
+ common = commands/pgp.c;
+ cflags = '$(CFLAGS_POSIX)';
+ cppflags = '-I$(srcdir)/lib/posix_wrap';
+};
+
+module = {
+ name = hdparm;
+ common = commands/hdparm.c;
+ enable = pci;
+ enable = mips_qemu_mips;
+};
+
+module = {
+ name = help;
+ common = commands/help.c;
+};
+
+module = {
+ name = hexdump;
+ common = commands/hexdump.c;
+ common = lib/hexdump.c;
+};
+
+module = {
+ name = keystatus;
+ common = commands/keystatus.c;
+};
+
+module = {
+ name = loadbios;
+ common = commands/efi/loadbios.c;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = loadenv;
+ common = commands/loadenv.c;
+ common = lib/envblk.c;
+};
+
+module = {
+ name = ls;
+ common = commands/ls.c;
+};
+
+module = {
+ name = lsmmap;
+ common = commands/lsmmap.c;
+};
+
+module = {
+ name = lspci;
+ common = commands/lspci.c;
+
+ enable = pci;
+};
+
+module = {
+ name = memrw;
+ common = commands/memrw.c;
+};
+
+module = {
+ name = minicmd;
+ common = commands/minicmd.c;
+};
+
+module = {
+ name = parttool;
+ common = commands/parttool.c;
+};
+
+module = {
+ name = password;
+ common = commands/password.c;
+};
+
+module = {
+ name = password_pbkdf2;
+ common = commands/password_pbkdf2.c;
+};
+
+module = {
+ name = play;
+ x86 = commands/i386/pc/play.c;
+ enable = x86;
+};
+
+module = {
+ name = spkmodem;
+ x86 = term/spkmodem.c;
+ enable = x86;
+};
+
+module = {
+ name = morse;
+ x86 = term/morse.c;
+ enable = x86;
+};
+
+module = {
+ name = probe;
+ common = commands/probe.c;
+};
+
+module = {
+ name = read;
+ common = commands/read.c;
+};
+
+module = {
+ name = search;
+ common = commands/search_wrap.c;
+ extra_dist = commands/search.c;
+};
+
+module = {
+ name = search_fs_file;
+ common = commands/search_file.c;
+};
+
+module = {
+ name = search_fs_uuid;
+ common = commands/search_uuid.c;
+};
+
+module = {
+ name = search_label;
+ common = commands/search_label.c;
+};
+
+module = {
+ name = setpci;
+ common = commands/setpci.c;
+ enable = pci;
+};
+
+module = {
+ name = pcidump;
+ common = commands/pcidump.c;
+ enable = pci;
+};
+
+module = {
+ name = sleep;
+ common = commands/sleep.c;
+};
+
+module = {
+ name = smbios;
+
+ common = commands/smbios.c;
+ efi = commands/efi/smbios.c;
+ i386_pc = commands/i386/pc/smbios.c;
+ i386_coreboot = commands/i386/pc/smbios.c;
+ i386_multiboot = commands/i386/pc/smbios.c;
+
+ enable = efi;
+ enable = i386_pc;
+ enable = i386_coreboot;
+ enable = i386_multiboot;
+};
+
+module = {
+ name = suspend;
+ ieee1275 = commands/ieee1275/suspend.c;
+ enable = i386_ieee1275;
+ enable = powerpc_ieee1275;
+};
+
+module = {
+ name = escc;
+ ieee1275 = term/ieee1275/escc.c;
+ enable = powerpc_ieee1275;
+};
+
+module = {
+ name = terminal;
+ common = commands/terminal.c;
+};
+
+module = {
+ name = test;
+ common = commands/test.c;
+};
+
+module = {
+ name = true;
+ common = commands/true.c;
+};
+
+module = {
+ name = usbtest;
+ common = commands/usbtest.c;
+ enable = usb;
+};
+
+module = {
+ name = videoinfo;
+ common = commands/videoinfo.c;
+};
+
+module = {
+ name = videotest;
+ common = commands/videotest.c;
+};
+
+module = {
+ name = xnu_uuid;
+ common = commands/xnu_uuid.c;
+};
+
+module = {
+ name = dm_nv;
+ common = disk/dmraid_nvidia.c;
+};
+
+module = {
+ name = loopback;
+ common = disk/loopback.c;
+};
+
+module = {
+ name = cryptodisk;
+ common = disk/cryptodisk.c;
+};
+
+module = {
+ name = json;
+ common = lib/json/json.c;
+};
+
+module = {
+ name = afsplitter;
+ common = disk/AFSplitter.c;
+};
+
+module = {
+ name = luks;
+ common = disk/luks.c;
+};
+
+module = {
+ name = luks2;
+ common = disk/luks2.c;
+ common = lib/gnulib/base64.c;
+ cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
+ cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB) -I$(srcdir)/lib/json';
+};
+
+module = {
+ name = geli;
+ common = disk/geli.c;
+};
+
+module = {
+ name = lvm;
+ common = disk/lvm.c;
+};
+
+module = {
+ name = ldm;
+ common = disk/ldm.c;
+};
+
+module = {
+ name = mdraid09;
+ common = disk/mdraid_linux.c;
+};
+
+module = {
+ name = mdraid09_be;
+ common = disk/mdraid_linux_be.c;
+};
+
+module = {
+ name = mdraid1x;
+ common = disk/mdraid1x_linux.c;
+};
+
+module = {
+ name = diskfilter;
+ common = disk/diskfilter.c;
+};
+
+module = {
+ name = raid5rec;
+ common = disk/raid5_recover.c;
+};
+
+module = {
+ name = raid6rec;
+ common = disk/raid6_recover.c;
+};
+
+module = {
+ name = scsi;
+ common = disk/scsi.c;
+};
+
+module = {
+ name = memdisk;
+ common = disk/memdisk.c;
+};
+
+module = {
+ name = ata;
+ common = disk/ata.c;
+ enable = pci;
+ enable = mips_qemu_mips;
+};
+
+module = {
+ name = ahci;
+ common = disk/ahci.c;
+ enable = pci;
+};
+
+module = {
+ name = pata;
+ common = disk/pata.c;
+ enable = pci;
+ enable = mips_qemu_mips;
+};
+
+module = {
+ name = biosdisk;
+ i386_pc = disk/i386/pc/biosdisk.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = usbms;
+ common = disk/usbms.c;
+ enable = usb;
+};
+
+module = {
+ name = nand;
+ ieee1275 = disk/ieee1275/nand.c;
+ enable = i386_ieee1275;
+};
+
+module = {
+ name = efiemu;
+ common = efiemu/main.c;
+ common = efiemu/i386/loadcore32.c;
+ common = efiemu/i386/loadcore64.c;
+ i386_pc = efiemu/i386/pc/cfgtables.c;
+ i386_coreboot = efiemu/i386/pc/cfgtables.c;
+ i386_multiboot = efiemu/i386/pc/cfgtables.c;
+ i386_ieee1275 = efiemu/i386/nocfgtables.c;
+ i386_qemu = efiemu/i386/nocfgtables.c;
+ common = efiemu/mm.c;
+ common = efiemu/loadcore_common.c;
+ common = efiemu/symbols.c;
+ common = efiemu/loadcore32.c;
+ common = efiemu/loadcore64.c;
+ common = efiemu/prepare32.c;
+ common = efiemu/prepare64.c;
+ common = efiemu/pnvram.c;
+ common = efiemu/i386/coredetect.c;
+
+ extra_dist = efiemu/prepare.c;
+ extra_dist = efiemu/loadcore.c;
+ extra_dist = efiemu/runtime/efiemu.S;
+ extra_dist = efiemu/runtime/efiemu.c;
+
+ enable = i386_pc;
+ enable = i386_coreboot;
+ enable = i386_ieee1275;
+ enable = i386_multiboot;
+ enable = i386_qemu;
+};
+
+module = {
+ name = font;
+ common = font/font.c;
+ common = font/font_cmd.c;
+ enable = videomodules;
+};
+
+module = {
+ name = procfs;
+ common = fs/proc.c;
+};
+
+module = {
+ name = affs;
+ common = fs/affs.c;
+};
+
+module = {
+ name = afs;
+ common = fs/afs.c;
+};
+
+module = {
+ name = bfs;
+ common = fs/bfs.c;
+};
+
+module = {
+ name = zstd;
+ common = lib/zstd/debug.c;
+ common = lib/zstd/entropy_common.c;
+ common = lib/zstd/error_private.c;
+ common = lib/zstd/fse_decompress.c;
+ common = lib/zstd/huf_decompress.c;
+ common = lib/zstd/module.c;
+ common = lib/zstd/xxhash.c;
+ common = lib/zstd/zstd_common.c;
+ common = lib/zstd/zstd_decompress.c;
+ cflags = '$(CFLAGS_POSIX) -Wno-undef';
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/zstd';
+};
+
+module = {
+ name = btrfs;
+ common = fs/btrfs.c;
+ common = lib/crc.c;
+ cflags = '$(CFLAGS_POSIX) -Wno-undef';
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -I$(srcdir)/lib/zstd -DMINILZO_HAVE_CONFIG_H';
+};
+
+module = {
+ name = archelp;
+ common = fs/archelp.c;
+};
+
+module = {
+ name = cbfs;
+ common = fs/cbfs.c;
+};
+
+module = {
+ name = cpio;
+ common = fs/cpio.c;
+};
+
+module = {
+ name = cpio_be;
+ common = fs/cpio_be.c;
+};
+
+module = {
+ name = newc;
+ common = fs/newc.c;
+};
+
+module = {
+ name = odc;
+ common = fs/odc.c;
+};
+
+module = {
+ name = ext2;
+ common = fs/ext2.c;
+};
+
+module = {
+ name = fat;
+ common = fs/fat.c;
+};
+
+module = {
+ name = exfat;
+ common = fs/exfat.c;
+};
+
+module = {
+ name = f2fs;
+ common = fs/f2fs.c;
+};
+
+module = {
+ name = fshelp;
+ common = fs/fshelp.c;
+};
+
+module = {
+ name = hfs;
+ common = fs/hfs.c;
+};
+
+module = {
+ name = hfsplus;
+ common = fs/hfsplus.c;
+};
+
+module = {
+ name = hfspluscomp;
+ common = fs/hfspluscomp.c;
+};
+
+module = {
+ name = iso9660;
+ common = fs/iso9660.c;
+};
+
+module = {
+ name = jfs;
+ common = fs/jfs.c;
+};
+
+module = {
+ name = minix;
+ common = fs/minix.c;
+};
+
+module = {
+ name = minix2;
+ common = fs/minix2.c;
+};
+
+module = {
+ name = minix3;
+ common = fs/minix3.c;
+};
+
+module = {
+ name = minix_be;
+ common = fs/minix_be.c;
+};
+
+module = {
+ name = minix2_be;
+ common = fs/minix2_be.c;
+};
+
+module = {
+ name = minix3_be;
+ common = fs/minix3_be.c;
+};
+
+module = {
+ name = nilfs2;
+ common = fs/nilfs2.c;
+};
+
+module = {
+ name = ntfs;
+ common = fs/ntfs.c;
+};
+
+module = {
+ name = ntfscomp;
+ common = fs/ntfscomp.c;
+};
+
+module = {
+ name = reiserfs;
+ common = fs/reiserfs.c;
+};
+
+module = {
+ name = romfs;
+ common = fs/romfs.c;
+};
+
+module = {
+ name = sfs;
+ common = fs/sfs.c;
+};
+
+module = {
+ name = squash4;
+ common = fs/squash4.c;
+ cflags = '$(CFLAGS_POSIX) -Wno-undef';
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H';
+};
+
+module = {
+ name = tar;
+ common = fs/tar.c;
+};
+
+module = {
+ name = udf;
+ common = fs/udf.c;
+};
+
+module = {
+ name = ufs1;
+ common = fs/ufs.c;
+};
+
+module = {
+ name = ufs1_be;
+ common = fs/ufs_be.c;
+};
+
+module = {
+ name = ufs2;
+ common = fs/ufs2.c;
+};
+
+module = {
+ name = xfs;
+ common = fs/xfs.c;
+};
+
+module = {
+ name = zfs;
+ common = fs/zfs/zfs.c;
+ common = fs/zfs/zfs_lzjb.c;
+ common = fs/zfs/zfs_lz4.c;
+ common = fs/zfs/zfs_sha256.c;
+ common = fs/zfs/zfs_fletcher.c;
+};
+
+module = {
+ name = zfscrypt;
+ common = fs/zfs/zfscrypt.c;
+};
+
+module = {
+ name = zfsinfo;
+ common = fs/zfs/zfsinfo.c;
+};
+
+module = {
+ name = macbless;
+ common = commands/macbless.c;
+};
+
+module = {
+ name = pxe;
+ i386_pc = net/drivers/i386/pc/pxe.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = gettext;
+ common = gettext/gettext.c;
+};
+
+module = {
+ name = gfxmenu;
+ common = gfxmenu/gfxmenu.c;
+ common = gfxmenu/view.c;
+ common = gfxmenu/font.c;
+ common = gfxmenu/icon_manager.c;
+ common = gfxmenu/theme_loader.c;
+ common = gfxmenu/widget-box.c;
+ common = gfxmenu/gui_canvas.c;
+ common = gfxmenu/gui_circular_progress.c;
+ common = gfxmenu/gui_box.c;
+ common = gfxmenu/gui_label.c;
+ common = gfxmenu/gui_list.c;
+ common = gfxmenu/gui_image.c;
+ common = gfxmenu/gui_progress_bar.c;
+ common = gfxmenu/gui_util.c;
+ common = gfxmenu/gui_string_util.c;
+};
+
+module = {
+ name = hello;
+ common = hello/hello.c;
+};
+
+module = {
+ name = gzio;
+ common = io/gzio.c;
+};
+
+module = {
+ name = offsetio;
+ common = io/offset.c;
+};
+
+module = {
+ name = bufio;
+ common = io/bufio.c;
+ enable = videomodules;
+};
+
+module = {
+ name = elf;
+ common = kern/elf.c;
+
+ extra_dist = kern/elfXX.c;
+};
+
+module = {
+ name = crypto;
+ common = lib/crypto.c;
+
+ extra_dist = lib/libgcrypt-grub/cipher/crypto.lst;
+};
+
+module = {
+ name = pbkdf2;
+ common = lib/pbkdf2.c;
+};
+
+module = {
+ name = relocator;
+ common = lib/relocator.c;
+ x86 = lib/i386/relocator16.S;
+ x86 = lib/i386/relocator32.S;
+ x86 = lib/i386/relocator64.S;
+ i386_xen_pvh = lib/i386/relocator16.S;
+ i386_xen_pvh = lib/i386/relocator32.S;
+ i386_xen_pvh = lib/i386/relocator64.S;
+ i386 = lib/i386/relocator_asm.S;
+ i386_xen_pvh = lib/i386/relocator_asm.S;
+ x86_64 = lib/x86_64/relocator_asm.S;
+ i386_xen = lib/i386/relocator_asm.S;
+ x86_64_xen = lib/x86_64/relocator_asm.S;
+ x86 = lib/i386/relocator.c;
+ x86 = lib/i386/relocator_common_c.c;
+ i386_xen_pvh = lib/i386/relocator.c;
+ i386_xen_pvh = lib/i386/relocator_common_c.c;
+ ieee1275 = lib/ieee1275/relocator.c;
+ efi = lib/efi/relocator.c;
+ mips = lib/mips/relocator_asm.S;
+ mips = lib/mips/relocator.c;
+ powerpc = lib/powerpc/relocator_asm.S;
+ powerpc = lib/powerpc/relocator.c;
+ xen = lib/xen/relocator.c;
+ i386_xen = lib/i386/xen/relocator.S;
+ x86_64_xen = lib/x86_64/xen/relocator.S;
+ xen = lib/i386/relocator_common_c.c;
+ x86_64_efi = lib/x86_64/efi/relocator.c;
+
+ extra_dist = lib/i386/relocator_common.S;
+ extra_dist = kern/powerpc/cache_flush.S;
+
+ enable = mips;
+ enable = powerpc;
+ enable = x86;
+ enable = i386_xen_pvh;
+ enable = xen;
+};
+
+module = {
+ name = datetime;
+ common = lib/datetime.c;
+ cmos = lib/cmos_datetime.c;
+ efi = lib/efi/datetime.c;
+ uboot = lib/dummy/datetime.c;
+ arm_coreboot = lib/dummy/datetime.c;
+ sparc64_ieee1275 = lib/ieee1275/datetime.c;
+ powerpc_ieee1275 = lib/ieee1275/datetime.c;
+ sparc64_ieee1275 = lib/ieee1275/cmos.c;
+ powerpc_ieee1275 = lib/ieee1275/cmos.c;
+ xen = lib/xen/datetime.c;
+ i386_xen_pvh = lib/xen/datetime.c;
+
+ mips_arc = lib/arc/datetime.c;
+};
+
+module = {
+ name = setjmp;
+ common = lib/setjmp.S;
+ extra_dist = lib/i386/setjmp.S;
+ extra_dist = lib/mips/setjmp.S;
+ extra_dist = lib/x86_64/setjmp.S;
+ extra_dist = lib/sparc64/setjmp.S;
+ extra_dist = lib/powerpc/setjmp.S;
+ extra_dist = lib/ia64/setjmp.S;
+ extra_dist = lib/ia64/longjmp.S;
+ extra_dist = lib/arm/setjmp.S;
+ extra_dist = lib/arm64/setjmp.S;
+ extra_dist = lib/riscv/setjmp.S;
+};
+
+module = {
+ name = aout;
+ common = loader/aout.c;
+ enable = x86;
+};
+
+module = {
+ name = bsd;
+ x86 = loader/i386/bsd.c;
+ x86 = loader/i386/bsd32.c;
+ x86 = loader/i386/bsd64.c;
+
+ extra_dist = loader/i386/bsdXX.c;
+ extra_dist = loader/i386/bsd_pagetable.c;
+
+ enable = x86;
+};
+
+module = {
+ name = plan9;
+ i386_pc = loader/i386/pc/plan9.c;
+ enable = i386_pc;
+};
+
+
+module = {
+ name = linux16;
+ common = loader/i386/pc/linux.c;
+ enable = x86;
+};
+
+module = {
+ name = ntldr;
+ i386_pc = loader/i386/pc/ntldr.c;
+ enable = i386_pc;
+};
+
+
+module = {
+ name = truecrypt;
+ i386_pc = loader/i386/pc/truecrypt.c;
+ enable = i386_pc;
+};
+
+
+module = {
+ name = freedos;
+ i386_pc = loader/i386/pc/freedos.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = pxechain;
+ i386_pc = loader/i386/pc/pxechainloader.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = multiboot2;
+ cppflags = "-DGRUB_USE_MULTIBOOT2";
+
+ common = loader/multiboot.c;
+ common = loader/multiboot_mbi2.c;
+ enable = x86;
+ enable = i386_xen_pvh;
+ enable = mips;
+};
+
+module = {
+ name = multiboot;
+ common = loader/multiboot.c;
+ x86 = loader/i386/multiboot_mbi.c;
+ i386_xen_pvh = loader/i386/multiboot_mbi.c;
+ extra_dist = loader/multiboot_elfxx.c;
+ enable = x86;
+ enable = i386_xen_pvh;
+};
+
+module = {
+ name = xen_boot;
+ arm64 = loader/arm64/xen_boot.c;
+ enable = arm64;
+};
+
+module = {
+ name = linux;
+ x86 = loader/i386/linux.c;
+ i386_xen_pvh = loader/i386/linux.c;
+ xen = loader/i386/xen.c;
+ i386_pc = lib/i386/pc/vesa_modes_table.c;
+ i386_xen_pvh = lib/i386/pc/vesa_modes_table.c;
+ mips = loader/mips/linux.c;
+ powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
+ sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
+ ia64_efi = loader/ia64/efi/linux.c;
+ arm_coreboot = loader/arm/linux.c;
+ arm_efi = loader/arm64/linux.c;
+ arm_uboot = loader/arm/linux.c;
+ arm64 = loader/arm64/linux.c;
+ riscv32 = loader/riscv/linux.c;
+ riscv64 = loader/riscv/linux.c;
+ common = loader/linux.c;
+ common = lib/cmdline.c;
+ enable = noemu;
+};
+
+module = {
+ name = fdt;
+ efi = loader/efi/fdt.c;
+ common = lib/fdt.c;
+ enable = fdt;
+};
+
+module = {
+ name = xnu;
+ x86 = loader/xnu_resume.c;
+ x86 = loader/i386/xnu.c;
+ x86 = loader/xnu.c;
+
+ /* Code is pretty generic but relies on RNG which
+ is available only on few platforms. It's not a
+ big deal as xnu needs ACPI anyway and we have
+ RNG on all platforms with ACPI.
+ */
+ enable = i386_multiboot;
+ enable = i386_coreboot;
+ enable = i386_pc;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = random;
+ x86 = lib/i386/random.c;
+ common = lib/random.c;
+
+ i386_multiboot = kern/i386/tsc_pmtimer.c;
+ i386_coreboot = kern/i386/tsc_pmtimer.c;
+ i386_pc = kern/i386/tsc_pmtimer.c;
+
+ enable = i386_multiboot;
+ enable = i386_coreboot;
+ enable = i386_pc;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = macho;
+
+ common = loader/macho.c;
+ common = loader/macho32.c;
+ common = loader/macho64.c;
+ common = loader/lzss.c;
+ extra_dist = loader/machoXX.c;
+};
+
+module = {
+ name = appleldr;
+ common = loader/efi/appleloader.c;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = chain;
+ efi = loader/efi/chainloader.c;
+ i386_pc = loader/i386/pc/chainloader.c;
+ i386_coreboot = loader/i386/coreboot/chainloader.c;
+ i386_coreboot = lib/LzmaDec.c;
+ enable = i386_pc;
+ enable = i386_coreboot;
+ enable = efi;
+};
+
+module = {
+ name = mmap;
+ common = mmap/mmap.c;
+ x86 = mmap/i386/uppermem.c;
+ x86 = mmap/i386/mmap.c;
+ i386_xen_pvh = mmap/i386/uppermem.c;
+ i386_xen_pvh = mmap/i386/mmap.c;
+
+ i386_pc = mmap/i386/pc/mmap.c;
+ i386_pc = mmap/i386/pc/mmap_helper.S;
+
+ efi = mmap/efi/mmap.c;
+
+ mips = mmap/mips/uppermem.c;
+
+ enable = x86;
+ enable = i386_xen_pvh;
+ enable = ia64_efi;
+ enable = arm_efi;
+ enable = arm64_efi;
+ enable = riscv32_efi;
+ enable = riscv64_efi;
+ enable = mips;
+};
+
+module = {
+ name = normal;
+ common = normal/main.c;
+ common = normal/cmdline.c;
+ common = normal/dyncmd.c;
+ common = normal/auth.c;
+ common = normal/autofs.c;
+ common = normal/color.c;
+ common = normal/completion.c;
+ common = normal/menu.c;
+ common = normal/menu_entry.c;
+ common = normal/menu_text.c;
+ common = normal/misc.c;
+ common = normal/crypto.c;
+ common = normal/term.c;
+ common = normal/context.c;
+ common = normal/charset.c;
+ common = lib/getline.c;
+
+ common = script/main.c;
+ common = script/script.c;
+ common = script/execute.c;
+ common = script/function.c;
+ common = script/lexer.c;
+ common = script/argv.c;
+
+ common = commands/menuentry.c;
+
+ common = unidata.c;
+ common_nodist = grub_script.tab.c;
+ common_nodist = grub_script.yy.c;
+ common_nodist = grub_script.tab.h;
+ common_nodist = grub_script.yy.h;
+
+ extra_dist = script/yylex.l;
+ extra_dist = script/parser.y;
+
+ cflags = '$(CFLAGS_POSIX) -Wno-redundant-decls';
+ cppflags = '$(CPPFLAGS_POSIX)';
+};
+
+module = {
+ name = part_acorn;
+ common = partmap/acorn.c;
+};
+
+module = {
+ name = part_amiga;
+ common = partmap/amiga.c;
+};
+
+module = {
+ name = part_apple;
+ common = partmap/apple.c;
+};
+
+module = {
+ name = part_gpt;
+ common = partmap/gpt.c;
+};
+
+module = {
+ name = part_msdos;
+ common = partmap/msdos.c;
+};
+
+module = {
+ name = part_sun;
+ common = partmap/sun.c;
+};
+
+module = {
+ name = part_plan;
+ common = partmap/plan.c;
+};
+
+module = {
+ name = part_dvh;
+ common = partmap/dvh.c;
+};
+
+module = {
+ name = part_bsd;
+ common = partmap/bsdlabel.c;
+};
+
+module = {
+ name = part_sunpc;
+ common = partmap/sunpc.c;
+};
+
+module = {
+ name = part_dfly;
+ common = partmap/dfly.c;
+};
+
+module = {
+ name = msdospart;
+ common = parttool/msdospart.c;
+};
+
+module = {
+ name = at_keyboard;
+ common = term/at_keyboard.c;
+ common = term/ps2.c;
+ enable = x86;
+};
+
+module = {
+ name = gfxterm;
+ common = term/gfxterm.c;
+ enable = videomodules;
+};
+
+module = {
+ name = gfxterm_background;
+ common = term/gfxterm_background.c;
+};
+
+module = {
+ name = serial;
+ common = term/serial.c;
+ x86 = term/ns8250.c;
+ ieee1275 = term/ieee1275/serial.c;
+ mips_arc = term/arc/serial.c;
+ efi = term/efi/serial.c;
+
+ enable = terminfomodule;
+ enable = ieee1275;
+ enable = mips_arc;
+};
+
+module = {
+ name = sendkey;
+ i386_pc = commands/i386/pc/sendkey.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = terminfo;
+ common = term/terminfo.c;
+ common = term/tparm.c;
+ enable = terminfomodule;
+};
+
+module = {
+ name = usb_keyboard;
+ common = term/usb_keyboard.c;
+ enable = usb;
+};
+
+module = {
+ name = vga;
+ common = video/i386/pc/vga.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = vga_text;
+ common = term/i386/pc/vga_text.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = mda_text;
+ common = term/i386/pc/mda_text.c;
+ enable = i386_pc;
+ enable = i386_coreboot_multiboot_qemu;
+};
+
+module = {
+ name = video_cirrus;
+ x86 = video/cirrus.c;
+ enable = x86;
+};
+
+module = {
+ name = video_bochs;
+ x86 = video/bochs.c;
+ enable = x86;
+};
+
+module = {
+ name = functional_test;
+ common = tests/lib/functional_test.c;
+ common = tests/lib/test.c;
+ common = tests/checksums.h;
+ common = tests/video_checksum.c;
+ common = tests/fake_input.c;
+ common = video/capture.c;
+};
+
+module = {
+ name = exfctest;
+ common = tests/example_functional_test.c;
+};
+
+module = {
+ name = strtoull_test;
+ common = tests/strtoull_test.c;
+};
+
+module = {
+ name = setjmp_test;
+ common = tests/setjmp_test.c;
+};
+
+module = {
+ name = signature_test;
+ common = tests/signature_test.c;
+ common = tests/signatures.h;
+};
+
+module = {
+ name = sleep_test;
+ common = tests/sleep_test.c;
+};
+
+module = {
+ name = xnu_uuid_test;
+ common = tests/xnu_uuid_test.c;
+};
+
+module = {
+ name = pbkdf2_test;
+ common = tests/pbkdf2_test.c;
+};
+
+module = {
+ name = legacy_password_test;
+ common = tests/legacy_password_test.c;
+ enable = i386_pc;
+ enable = i386_xen_pvh;
+ enable = i386_efi;
+ enable = x86_64_efi;
+ enable = emu;
+ enable = xen;
+};
+
+module = {
+ name = div;
+ common = lib/division.c;
+ enable = no_softdiv;
+};
+
+module = {
+ name = div_test;
+ common = tests/div_test.c;
+};
+
+module = {
+ name = mul_test;
+ common = tests/mul_test.c;
+};
+
+module = {
+ name = shift_test;
+ common = tests/shift_test.c;
+};
+
+module = {
+ name = cmp_test;
+ common = tests/cmp_test.c;
+};
+
+module = {
+ name = ctz_test;
+ common = tests/ctz_test.c;
+};
+
+module = {
+ name = bswap_test;
+ common = tests/bswap_test.c;
+};
+
+module = {
+ name = videotest_checksum;
+ common = tests/videotest_checksum.c;
+};
+
+module = {
+ name = gfxterm_menu;
+ common = tests/gfxterm_menu.c;
+};
+
+module = {
+ name = cmdline_cat_test;
+ common = tests/cmdline_cat_test.c;
+};
+
+module = {
+ name = bitmap;
+ common = video/bitmap.c;
+};
+
+module = {
+ name = bitmap_scale;
+ common = video/bitmap_scale.c;
+};
+
+module = {
+ name = efi_gop;
+ efi = video/efi_gop.c;
+ enable = efi;
+};
+
+module = {
+ name = efi_uga;
+ efi = video/efi_uga.c;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = jpeg;
+ common = video/readers/jpeg.c;
+};
+
+module = {
+ name = png;
+ common = video/readers/png.c;
+};
+
+module = {
+ name = tga;
+ common = video/readers/tga.c;
+};
+
+module = {
+ name = vbe;
+ common = video/i386/pc/vbe.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = video_fb;
+ common = video/fb/video_fb.c;
+ common = video/fb/fbblit.c;
+ common = video/fb/fbfill.c;
+ common = video/fb/fbutil.c;
+ enable = videomodules;
+};
+
+module = {
+ name = video;
+ common = video/video.c;
+ enable = videomodules;
+};
+
+module = {
+ name = video_colors;
+ common = video/colors.c;
+};
+
+module = {
+ name = ieee1275_fb;
+ ieee1275 = video/ieee1275.c;
+ enable = powerpc_ieee1275;
+};
+
+module = {
+ name = sdl;
+ emu = video/emu/sdl.c;
+ enable = emu;
+ condition = COND_GRUB_EMU_SDL;
+};
+
+module = {
+ name = datehook;
+ common = hook/datehook.c;
+};
+
+module = {
+ name = net;
+ common = net/net.c;
+ common = net/dns.c;
+ common = net/bootp.c;
+ common = net/ip.c;
+ common = net/udp.c;
+ common = net/tcp.c;
+ common = net/icmp.c;
+ common = net/icmp6.c;
+ common = net/ethernet.c;
+ common = net/arp.c;
+ common = net/netbuff.c;
+};
+
+module = {
+ name = tftp;
+ common = net/tftp.c;
+};
+
+module = {
+ name = http;
+ common = net/http.c;
+};
+
+module = {
+ name = ofnet;
+ common = net/drivers/ieee1275/ofnet.c;
+ enable = ieee1275;
+};
+
+module = {
+ name = ubootnet;
+ common = net/drivers/uboot/ubootnet.c;
+ enable = uboot;
+};
+
+module = {
+ name = efinet;
+ common = net/drivers/efi/efinet.c;
+ enable = efi;
+};
+
+module = {
+ name = emunet;
+ emu = net/drivers/emu/emunet.c;
+ enable = emu;
+};
+
+module = {
+ name = legacycfg;
+ common = commands/legacycfg.c;
+ common = lib/legacy_parse.c;
+ emu = lib/i386/pc/vesa_modes_table.c;
+ i386_efi = lib/i386/pc/vesa_modes_table.c;
+ x86_64_efi = lib/i386/pc/vesa_modes_table.c;
+ xen = lib/i386/pc/vesa_modes_table.c;
+
+ enable = i386_pc;
+ enable = i386_xen_pvh;
+ enable = i386_efi;
+ enable = x86_64_efi;
+ enable = emu;
+ enable = xen;
+};
+
+module = {
+ name = syslinuxcfg;
+ common = lib/syslinux_parse.c;
+ common = commands/syslinuxcfg.c;
+};
+
+module = {
+ name = test_blockarg;
+ common = tests/test_blockarg.c;
+};
+
+module = {
+ name = xzio;
+ common = io/xzio.c;
+ common = lib/xzembed/xz_dec_bcj.c;
+ common = lib/xzembed/xz_dec_lzma2.c;
+ common = lib/xzembed/xz_dec_stream.c;
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed';
+ cflags='-Wno-unreachable-code';
+};
+
+module = {
+ name = lzopio;
+ common = io/lzopio.c;
+ common = lib/minilzo/minilzo.c;
+ cflags = '$(CFLAGS_POSIX) -Wno-undef -Wno-redundant-decls -Wno-error';
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H';
+};
+
+module = {
+ name = testload;
+ common = commands/testload.c;
+};
+
+module = {
+ name = backtrace;
+ x86 = lib/i386/backtrace.c;
+ i386_xen_pvh = lib/i386/backtrace.c;
+ i386_xen = lib/i386/backtrace.c;
+ x86_64_xen = lib/i386/backtrace.c;
+ common = lib/backtrace.c;
+ enable = x86;
+ enable = i386_xen_pvh;
+ enable = i386_xen;
+ enable = x86_64_xen;
+};
+
+module = {
+ name = lsapm;
+ common = commands/i386/pc/lsapm.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = keylayouts;
+ common = commands/keylayouts.c;
+ enable = x86;
+};
+
+module = {
+ name = priority_queue;
+ common = lib/priority_queue.c;
+};
+
+module = {
+ name = time;
+ common = commands/time.c;
+};
+
+module = {
+ name = cacheinfo;
+ common = commands/cacheinfo.c;
+ condition = COND_ENABLE_CACHE_STATS;
+};
+
+module = {
+ name = boottime;
+ common = commands/boottime.c;
+ condition = COND_ENABLE_BOOT_TIME_STATS;
+};
+
+module = {
+ name = adler32;
+ common = lib/adler32.c;
+};
+
+module = {
+ name = crc64;
+ common = lib/crc64.c;
+};
+
+module = {
+ name = mpi;
+ common = lib/libgcrypt-grub/mpi/mpiutil.c;
+ common = lib/libgcrypt-grub/mpi/mpi-bit.c;
+ common = lib/libgcrypt-grub/mpi/mpi-add.c;
+ common = lib/libgcrypt-grub/mpi/mpi-mul.c;
+ common = lib/libgcrypt-grub/mpi/mpi-mod.c;
+ common = lib/libgcrypt-grub/mpi/mpi-gcd.c;
+ common = lib/libgcrypt-grub/mpi/mpi-div.c;
+ common = lib/libgcrypt-grub/mpi/mpi-cmp.c;
+ common = lib/libgcrypt-grub/mpi/mpi-inv.c;
+ common = lib/libgcrypt-grub/mpi/mpi-pow.c;
+ common = lib/libgcrypt-grub/mpi/mpi-mpow.c;
+ common = lib/libgcrypt-grub/mpi/mpih-lshift.c;
+ common = lib/libgcrypt-grub/mpi/mpih-mul.c;
+ common = lib/libgcrypt-grub/mpi/mpih-mul1.c;
+ common = lib/libgcrypt-grub/mpi/mpih-mul2.c;
+ common = lib/libgcrypt-grub/mpi/mpih-mul3.c;
+ common = lib/libgcrypt-grub/mpi/mpih-add1.c;
+ common = lib/libgcrypt-grub/mpi/mpih-sub1.c;
+ common = lib/libgcrypt-grub/mpi/mpih-div.c;
+ common = lib/libgcrypt-grub/mpi/mpicoder.c;
+ common = lib/libgcrypt-grub/mpi/mpih-rshift.c;
+ common = lib/libgcrypt-grub/mpi/mpi-inline.c;
+ common = lib/libgcrypt_wrap/mem.c;
+
+ cflags = '$(CFLAGS_GCRY) -Wno-redundant-decls -Wno-sign-compare';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = all_video;
+ common = lib/fake_module.c;
+};
+
+module = {
+ name = gdb;
+ common = gdb/cstub.c;
+ common = gdb/gdb.c;
+ i386 = gdb/i386/idt.c;
+ i386 = gdb/i386/machdep.S;
+ i386 = gdb/i386/signal.c;
+ enable = i386;
+};
+
+module = {
+ name = testspeed;
+ common = commands/testspeed.c;
+};
+
+module = {
+ name = tpm;
+ common = commands/tpm.c;
+ efi = commands/efi/tpm.c;
+ enable = efi;
+};
+
+module = {
+ name = tr;
+ common = commands/tr.c;
+};
+
+module = {
+ name = progress;
+ common = lib/progress.c;
+};
+
+module = {
+ name = file;
+ common = commands/file.c;
+ common = commands/file32.c;
+ common = commands/file64.c;
+ extra_dist = commands/fileXX.c;
+ common = loader/i386/xen_file.c;
+ common = loader/i386/xen_file32.c;
+ common = loader/i386/xen_file64.c;
+ extra_dist = loader/i386/xen_fileXX.c;
+};
+module = {
+ name = rdmsr;
+ common = commands/i386/rdmsr.c;
+ enable = x86;
+};
+module = {
+ name = wrmsr;
+ common = commands/i386/wrmsr.c;
+ enable = x86;
+};
diff --git a/grub-core/Makefile.gcry.def b/grub-core/Makefile.gcry.def
new file mode 100644
index 0000000..4853ed2
--- /dev/null
+++ b/grub-core/Makefile.gcry.def
@@ -0,0 +1,157 @@
+AutoGen definitions Makefile.tpl;
+
+module = {
+ name = gcry_arcfour;
+ common = lib/libgcrypt-grub/cipher/arcfour.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_blowfish;
+ common = lib/libgcrypt-grub/cipher/blowfish.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_camellia;
+ common = lib/libgcrypt-grub/cipher/camellia-glue.c;
+ common = lib/libgcrypt-grub/cipher/camellia.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_cast5;
+ common = lib/libgcrypt-grub/cipher/cast5.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_crc;
+ common = lib/libgcrypt-grub/cipher/crc.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_des;
+ common = lib/libgcrypt-grub/cipher/des.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_dsa;
+ common = lib/libgcrypt-grub/cipher/dsa.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_idea;
+ common = lib/libgcrypt-grub/cipher/idea.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_md4;
+ common = lib/libgcrypt-grub/cipher/md4.c;
+ cflags = '$(CFLAGS_GCRY) -Wno-cast-align';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_md5;
+ common = lib/libgcrypt-grub/cipher/md5.c;
+ cflags = '$(CFLAGS_GCRY) -Wno-cast-align';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_rfc2268;
+ common = lib/libgcrypt-grub/cipher/rfc2268.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_rijndael;
+ common = lib/libgcrypt-grub/cipher/rijndael.c;
+ cflags = '$(CFLAGS_GCRY) -Wno-cast-align';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_rmd160;
+ common = lib/libgcrypt-grub/cipher/rmd160.c;
+ cflags = '$(CFLAGS_GCRY) -Wno-cast-align';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_rsa;
+ common = lib/libgcrypt-grub/cipher/rsa.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_seed;
+ common = lib/libgcrypt-grub/cipher/seed.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_serpent;
+ common = lib/libgcrypt-grub/cipher/serpent.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_sha1;
+ common = lib/libgcrypt-grub/cipher/sha1.c;
+ cflags = '$(CFLAGS_GCRY) -Wno-cast-align';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_sha256;
+ common = lib/libgcrypt-grub/cipher/sha256.c;
+ cflags = '$(CFLAGS_GCRY) -Wno-cast-align';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_sha512;
+ common = lib/libgcrypt-grub/cipher/sha512.c;
+ cflags = '$(CFLAGS_GCRY) -Wno-cast-align';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_tiger;
+ common = lib/libgcrypt-grub/cipher/tiger.c;
+ cflags = '$(CFLAGS_GCRY) -Wno-cast-align';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_twofish;
+ common = lib/libgcrypt-grub/cipher/twofish.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = gcry_whirlpool;
+ common = lib/libgcrypt-grub/cipher/whirlpool.c;
+ cflags = '$(CFLAGS_GCRY)';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
diff --git a/grub-core/Makefile.in b/grub-core/Makefile.in
new file mode 100644
index 0000000..37a32dd
--- /dev/null
+++ b/grub-core/Makefile.in
@@ -0,0 +1,47508 @@
+# Makefile.in generated by automake 1.15 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# -*- makefile -*-
+
+
+
+
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+@COND_arm64_TRUE@am__append_1 = -mcmodel=large
+@COND_powerpc_ieee1275_TRUE@am__append_2 = -mcpu=powerpc
+bin_PROGRAMS = $(am__EXEEXT_1)
+sbin_PROGRAMS =
+check_PROGRAMS =
+noinst_PROGRAMS =
+platform_PROGRAMS = disk.module$(EXEEXT) trig.module$(EXEEXT) \
+ $(am__EXEEXT_2) $(am__EXEEXT_3) $(am__EXEEXT_4) \
+ $(am__EXEEXT_5) $(am__EXEEXT_6) $(am__EXEEXT_7) \
+ $(am__EXEEXT_8) $(am__EXEEXT_9) $(am__EXEEXT_10) \
+ $(am__EXEEXT_11) $(am__EXEEXT_12) $(am__EXEEXT_13) \
+ $(am__EXEEXT_14) $(am__EXEEXT_15) $(am__EXEEXT_16) \
+ $(am__EXEEXT_17) $(am__EXEEXT_18) $(am__EXEEXT_19) \
+ $(am__EXEEXT_20) $(am__EXEEXT_21) $(am__EXEEXT_22) \
+ $(am__EXEEXT_23) $(am__EXEEXT_24) $(am__EXEEXT_25) \
+ $(am__EXEEXT_26) $(am__EXEEXT_27) $(am__EXEEXT_28) \
+ $(am__EXEEXT_29) $(am__EXEEXT_30) $(am__EXEEXT_31) \
+ $(am__EXEEXT_32) $(am__EXEEXT_33) $(am__EXEEXT_34) \
+ $(am__EXEEXT_35) $(am__EXEEXT_36) $(am__EXEEXT_37) \
+ $(am__EXEEXT_38) $(am__EXEEXT_39) $(am__EXEEXT_40) \
+ $(am__EXEEXT_41) $(am__EXEEXT_42) $(am__EXEEXT_43) \
+ $(am__EXEEXT_44) $(am__EXEEXT_45) $(am__EXEEXT_46) \
+ $(am__EXEEXT_47) $(am__EXEEXT_48) $(am__EXEEXT_49) \
+ $(am__EXEEXT_50) $(am__EXEEXT_51) $(am__EXEEXT_52) \
+ $(am__EXEEXT_53) $(am__EXEEXT_54) $(am__EXEEXT_55) \
+ $(am__EXEEXT_56) $(am__EXEEXT_57) $(am__EXEEXT_58) \
+ $(am__EXEEXT_59) $(am__EXEEXT_60) $(am__EXEEXT_61) \
+ $(am__EXEEXT_62) $(am__EXEEXT_63) $(am__EXEEXT_64) \
+ $(am__EXEEXT_65) $(am__EXEEXT_66) $(am__EXEEXT_67) \
+ $(am__EXEEXT_68) $(am__EXEEXT_69) $(am__EXEEXT_70) \
+ $(am__EXEEXT_71) $(am__EXEEXT_72) $(am__EXEEXT_73) \
+ $(am__EXEEXT_74) $(am__EXEEXT_75) $(am__EXEEXT_76) \
+ $(am__EXEEXT_77) $(am__EXEEXT_78) $(am__EXEEXT_79) \
+ $(am__EXEEXT_80) $(am__EXEEXT_81) $(am__EXEEXT_82) \
+ $(am__EXEEXT_83) $(am__EXEEXT_84) $(am__EXEEXT_85) \
+ $(am__EXEEXT_86) $(am__EXEEXT_87) $(am__EXEEXT_88) \
+ $(am__EXEEXT_89) $(am__EXEEXT_90) $(am__EXEEXT_91) \
+ $(am__EXEEXT_92) $(am__EXEEXT_93) $(am__EXEEXT_94) \
+ $(am__EXEEXT_95) $(am__EXEEXT_96) $(am__EXEEXT_97) \
+ $(am__EXEEXT_98) $(am__EXEEXT_99) $(am__EXEEXT_100) \
+ $(am__EXEEXT_101) $(am__EXEEXT_102) $(am__EXEEXT_103) \
+ $(am__EXEEXT_104) $(am__EXEEXT_105) $(am__EXEEXT_106) \
+ $(am__EXEEXT_107) $(am__EXEEXT_108) $(am__EXEEXT_109) \
+ $(am__EXEEXT_110) $(am__EXEEXT_111) $(am__EXEEXT_112) \
+ $(am__EXEEXT_113) $(am__EXEEXT_114) $(am__EXEEXT_115) \
+ $(am__EXEEXT_116) $(am__EXEEXT_117) $(am__EXEEXT_118) \
+ $(am__EXEEXT_119) $(am__EXEEXT_120) $(am__EXEEXT_121) \
+ $(am__EXEEXT_122) $(am__EXEEXT_123) $(am__EXEEXT_124) \
+ $(am__EXEEXT_125) $(am__EXEEXT_126) $(am__EXEEXT_127) \
+ $(am__EXEEXT_128) $(am__EXEEXT_129) $(am__EXEEXT_130) \
+ $(am__EXEEXT_131) $(am__EXEEXT_132) $(am__EXEEXT_133) \
+ $(am__EXEEXT_134) $(am__EXEEXT_135) $(am__EXEEXT_136) \
+ $(am__EXEEXT_137) $(am__EXEEXT_138) $(am__EXEEXT_139) \
+ $(am__EXEEXT_140) $(am__EXEEXT_141) $(am__EXEEXT_142) \
+ $(am__EXEEXT_143) $(am__EXEEXT_144) $(am__EXEEXT_145) \
+ $(am__EXEEXT_146) $(am__EXEEXT_147) $(am__EXEEXT_148) \
+ regexp.module$(EXEEXT) $(am__EXEEXT_149) $(am__EXEEXT_150) \
+ $(am__EXEEXT_151) $(am__EXEEXT_152) $(am__EXEEXT_153) \
+ $(am__EXEEXT_154) $(am__EXEEXT_155) $(am__EXEEXT_156) \
+ $(am__EXEEXT_157) $(am__EXEEXT_158) $(am__EXEEXT_159) \
+ $(am__EXEEXT_160) $(am__EXEEXT_161) $(am__EXEEXT_162) \
+ $(am__EXEEXT_163) $(am__EXEEXT_164) $(am__EXEEXT_165) \
+ $(am__EXEEXT_166) $(am__EXEEXT_167) $(am__EXEEXT_168) \
+ $(am__EXEEXT_169) $(am__EXEEXT_170) $(am__EXEEXT_171) \
+ $(am__EXEEXT_172) $(am__EXEEXT_173) $(am__EXEEXT_174) \
+ $(am__EXEEXT_175) $(am__EXEEXT_176) $(am__EXEEXT_177) \
+ $(am__EXEEXT_178) $(am__EXEEXT_179) $(am__EXEEXT_180) \
+ $(am__EXEEXT_181) $(am__EXEEXT_182) $(am__EXEEXT_183) \
+ $(am__EXEEXT_184) $(am__EXEEXT_185) $(am__EXEEXT_186) \
+ $(am__EXEEXT_187) $(am__EXEEXT_188) $(am__EXEEXT_189) \
+ $(am__EXEEXT_190) $(am__EXEEXT_191) $(am__EXEEXT_192) \
+ $(am__EXEEXT_193) $(am__EXEEXT_194) $(am__EXEEXT_195) \
+ $(am__EXEEXT_196) $(am__EXEEXT_197) $(am__EXEEXT_198) \
+ $(am__EXEEXT_199) $(am__EXEEXT_200) $(am__EXEEXT_201) \
+ $(am__EXEEXT_202) $(am__EXEEXT_203) blocklist.module$(EXEEXT) \
+ $(am__EXEEXT_204) $(am__EXEEXT_205) $(am__EXEEXT_206) \
+ $(am__EXEEXT_207) $(am__EXEEXT_208) $(am__EXEEXT_209) \
+ $(am__EXEEXT_210) $(am__EXEEXT_211) $(am__EXEEXT_212) \
+ $(am__EXEEXT_213) $(am__EXEEXT_214) $(am__EXEEXT_215) \
+ $(am__EXEEXT_216) $(am__EXEEXT_217) $(am__EXEEXT_218) \
+ $(am__EXEEXT_219) $(am__EXEEXT_220) $(am__EXEEXT_221) \
+ cat.module$(EXEEXT) cmp.module$(EXEEXT) \
+ configfile.module$(EXEEXT) $(am__EXEEXT_222) $(am__EXEEXT_223) \
+ $(am__EXEEXT_224) $(am__EXEEXT_225) $(am__EXEEXT_226) \
+ $(am__EXEEXT_227) $(am__EXEEXT_228) $(am__EXEEXT_229) \
+ $(am__EXEEXT_230) $(am__EXEEXT_231) date.module$(EXEEXT) \
+ $(am__EXEEXT_232) echo.module$(EXEEXT) eval.module$(EXEEXT) \
+ $(am__EXEEXT_233) $(am__EXEEXT_234) $(am__EXEEXT_235) \
+ $(am__EXEEXT_236) $(am__EXEEXT_237) $(am__EXEEXT_238) \
+ $(am__EXEEXT_239) $(am__EXEEXT_240) $(am__EXEEXT_241) \
+ $(am__EXEEXT_242) $(am__EXEEXT_243) $(am__EXEEXT_244) \
+ $(am__EXEEXT_245) $(am__EXEEXT_246) gptsync.module$(EXEEXT) \
+ $(am__EXEEXT_247) $(am__EXEEXT_248) $(am__EXEEXT_249) \
+ $(am__EXEEXT_250) $(am__EXEEXT_251) $(am__EXEEXT_252) \
+ $(am__EXEEXT_253) $(am__EXEEXT_254) $(am__EXEEXT_255) \
+ $(am__EXEEXT_256) $(am__EXEEXT_257) $(am__EXEEXT_258) \
+ $(am__EXEEXT_259) $(am__EXEEXT_260) $(am__EXEEXT_261) \
+ $(am__EXEEXT_262) $(am__EXEEXT_263) $(am__EXEEXT_264) \
+ $(am__EXEEXT_265) $(am__EXEEXT_266) $(am__EXEEXT_267) \
+ $(am__EXEEXT_268) $(am__EXEEXT_269) $(am__EXEEXT_270) \
+ $(am__EXEEXT_271) $(am__EXEEXT_272) $(am__EXEEXT_273) \
+ $(am__EXEEXT_274) $(am__EXEEXT_275) $(am__EXEEXT_276) \
+ $(am__EXEEXT_277) $(am__EXEEXT_278) $(am__EXEEXT_279) \
+ $(am__EXEEXT_280) $(am__EXEEXT_281) $(am__EXEEXT_282) \
+ $(am__EXEEXT_283) $(am__EXEEXT_284) $(am__EXEEXT_285) \
+ $(am__EXEEXT_286) $(am__EXEEXT_287) $(am__EXEEXT_288) \
+ $(am__EXEEXT_289) $(am__EXEEXT_290) $(am__EXEEXT_291) \
+ $(am__EXEEXT_292) hashsum.module$(EXEEXT) pgp.module$(EXEEXT) \
+ $(am__EXEEXT_293) $(am__EXEEXT_294) $(am__EXEEXT_295) \
+ $(am__EXEEXT_296) $(am__EXEEXT_297) $(am__EXEEXT_298) \
+ $(am__EXEEXT_299) $(am__EXEEXT_300) $(am__EXEEXT_301) \
+ help.module$(EXEEXT) hexdump.module$(EXEEXT) \
+ keystatus.module$(EXEEXT) $(am__EXEEXT_302) $(am__EXEEXT_303) \
+ loadenv.module$(EXEEXT) ls.module$(EXEEXT) \
+ lsmmap.module$(EXEEXT) $(am__EXEEXT_304) $(am__EXEEXT_305) \
+ $(am__EXEEXT_306) $(am__EXEEXT_307) $(am__EXEEXT_308) \
+ $(am__EXEEXT_309) $(am__EXEEXT_310) $(am__EXEEXT_311) \
+ memrw.module$(EXEEXT) minicmd.module$(EXEEXT) \
+ parttool.module$(EXEEXT) password.module$(EXEEXT) \
+ password_pbkdf2.module$(EXEEXT) $(am__EXEEXT_312) \
+ $(am__EXEEXT_313) $(am__EXEEXT_314) $(am__EXEEXT_315) \
+ $(am__EXEEXT_316) $(am__EXEEXT_317) $(am__EXEEXT_318) \
+ $(am__EXEEXT_319) $(am__EXEEXT_320) $(am__EXEEXT_321) \
+ $(am__EXEEXT_322) $(am__EXEEXT_323) $(am__EXEEXT_324) \
+ $(am__EXEEXT_325) $(am__EXEEXT_326) $(am__EXEEXT_327) \
+ $(am__EXEEXT_328) $(am__EXEEXT_329) $(am__EXEEXT_330) \
+ $(am__EXEEXT_331) $(am__EXEEXT_332) probe.module$(EXEEXT) \
+ read.module$(EXEEXT) search.module$(EXEEXT) \
+ search_fs_file.module$(EXEEXT) search_fs_uuid.module$(EXEEXT) \
+ search_label.module$(EXEEXT) $(am__EXEEXT_333) \
+ $(am__EXEEXT_334) $(am__EXEEXT_335) $(am__EXEEXT_336) \
+ $(am__EXEEXT_337) $(am__EXEEXT_338) $(am__EXEEXT_339) \
+ $(am__EXEEXT_340) $(am__EXEEXT_341) $(am__EXEEXT_342) \
+ $(am__EXEEXT_343) $(am__EXEEXT_344) $(am__EXEEXT_345) \
+ $(am__EXEEXT_346) $(am__EXEEXT_347) $(am__EXEEXT_348) \
+ sleep.module$(EXEEXT) $(am__EXEEXT_349) $(am__EXEEXT_350) \
+ $(am__EXEEXT_351) $(am__EXEEXT_352) $(am__EXEEXT_353) \
+ $(am__EXEEXT_354) $(am__EXEEXT_355) $(am__EXEEXT_356) \
+ $(am__EXEEXT_357) $(am__EXEEXT_358) $(am__EXEEXT_359) \
+ $(am__EXEEXT_360) terminal.module$(EXEEXT) \
+ test.module$(EXEEXT) true.module$(EXEEXT) $(am__EXEEXT_361) \
+ $(am__EXEEXT_362) $(am__EXEEXT_363) $(am__EXEEXT_364) \
+ $(am__EXEEXT_365) $(am__EXEEXT_366) $(am__EXEEXT_367) \
+ $(am__EXEEXT_368) $(am__EXEEXT_369) videoinfo.module$(EXEEXT) \
+ videotest.module$(EXEEXT) xnu_uuid.module$(EXEEXT) \
+ dm_nv.module$(EXEEXT) loopback.module$(EXEEXT) \
+ cryptodisk.module$(EXEEXT) json.module$(EXEEXT) \
+ afsplitter.module$(EXEEXT) luks.module$(EXEEXT) \
+ luks2.module$(EXEEXT) geli.module$(EXEEXT) lvm.module$(EXEEXT) \
+ ldm.module$(EXEEXT) mdraid09.module$(EXEEXT) \
+ mdraid09_be.module$(EXEEXT) mdraid1x.module$(EXEEXT) \
+ diskfilter.module$(EXEEXT) raid5rec.module$(EXEEXT) \
+ raid6rec.module$(EXEEXT) scsi.module$(EXEEXT) \
+ memdisk.module$(EXEEXT) $(am__EXEEXT_370) $(am__EXEEXT_371) \
+ $(am__EXEEXT_372) $(am__EXEEXT_373) $(am__EXEEXT_374) \
+ $(am__EXEEXT_375) $(am__EXEEXT_376) $(am__EXEEXT_377) \
+ $(am__EXEEXT_378) $(am__EXEEXT_379) $(am__EXEEXT_380) \
+ $(am__EXEEXT_381) $(am__EXEEXT_382) $(am__EXEEXT_383) \
+ $(am__EXEEXT_384) $(am__EXEEXT_385) $(am__EXEEXT_386) \
+ $(am__EXEEXT_387) $(am__EXEEXT_388) $(am__EXEEXT_389) \
+ $(am__EXEEXT_390) $(am__EXEEXT_391) $(am__EXEEXT_392) \
+ $(am__EXEEXT_393) $(am__EXEEXT_394) $(am__EXEEXT_395) \
+ $(am__EXEEXT_396) $(am__EXEEXT_397) $(am__EXEEXT_398) \
+ $(am__EXEEXT_399) $(am__EXEEXT_400) $(am__EXEEXT_401) \
+ $(am__EXEEXT_402) $(am__EXEEXT_403) $(am__EXEEXT_404) \
+ $(am__EXEEXT_405) $(am__EXEEXT_406) $(am__EXEEXT_407) \
+ $(am__EXEEXT_408) $(am__EXEEXT_409) $(am__EXEEXT_410) \
+ $(am__EXEEXT_411) $(am__EXEEXT_412) $(am__EXEEXT_413) \
+ $(am__EXEEXT_414) $(am__EXEEXT_415) $(am__EXEEXT_416) \
+ $(am__EXEEXT_417) $(am__EXEEXT_418) $(am__EXEEXT_419) \
+ $(am__EXEEXT_420) $(am__EXEEXT_421) $(am__EXEEXT_422) \
+ $(am__EXEEXT_423) $(am__EXEEXT_424) $(am__EXEEXT_425) \
+ $(am__EXEEXT_426) $(am__EXEEXT_427) $(am__EXEEXT_428) \
+ $(am__EXEEXT_429) $(am__EXEEXT_430) procfs.module$(EXEEXT) \
+ affs.module$(EXEEXT) afs.module$(EXEEXT) bfs.module$(EXEEXT) \
+ zstd.module$(EXEEXT) btrfs.module$(EXEEXT) \
+ archelp.module$(EXEEXT) cbfs.module$(EXEEXT) \
+ cpio.module$(EXEEXT) cpio_be.module$(EXEEXT) \
+ newc.module$(EXEEXT) odc.module$(EXEEXT) ext2.module$(EXEEXT) \
+ fat.module$(EXEEXT) exfat.module$(EXEEXT) f2fs.module$(EXEEXT) \
+ fshelp.module$(EXEEXT) hfs.module$(EXEEXT) \
+ hfsplus.module$(EXEEXT) hfspluscomp.module$(EXEEXT) \
+ iso9660.module$(EXEEXT) jfs.module$(EXEEXT) \
+ minix.module$(EXEEXT) minix2.module$(EXEEXT) \
+ minix3.module$(EXEEXT) minix_be.module$(EXEEXT) \
+ minix2_be.module$(EXEEXT) minix3_be.module$(EXEEXT) \
+ nilfs2.module$(EXEEXT) ntfs.module$(EXEEXT) \
+ ntfscomp.module$(EXEEXT) reiserfs.module$(EXEEXT) \
+ romfs.module$(EXEEXT) sfs.module$(EXEEXT) \
+ squash4.module$(EXEEXT) tar.module$(EXEEXT) \
+ udf.module$(EXEEXT) ufs1.module$(EXEEXT) \
+ ufs1_be.module$(EXEEXT) ufs2.module$(EXEEXT) \
+ xfs.module$(EXEEXT) zfs.module$(EXEEXT) \
+ zfscrypt.module$(EXEEXT) zfsinfo.module$(EXEEXT) \
+ macbless.module$(EXEEXT) $(am__EXEEXT_431) \
+ gettext.module$(EXEEXT) gfxmenu.module$(EXEEXT) \
+ hello.module$(EXEEXT) gzio.module$(EXEEXT) \
+ offsetio.module$(EXEEXT) $(am__EXEEXT_432) $(am__EXEEXT_433) \
+ $(am__EXEEXT_434) $(am__EXEEXT_435) $(am__EXEEXT_436) \
+ $(am__EXEEXT_437) $(am__EXEEXT_438) $(am__EXEEXT_439) \
+ $(am__EXEEXT_440) $(am__EXEEXT_441) $(am__EXEEXT_442) \
+ $(am__EXEEXT_443) $(am__EXEEXT_444) $(am__EXEEXT_445) \
+ $(am__EXEEXT_446) $(am__EXEEXT_447) $(am__EXEEXT_448) \
+ $(am__EXEEXT_449) $(am__EXEEXT_450) $(am__EXEEXT_451) \
+ elf.module$(EXEEXT) crypto.module$(EXEEXT) \
+ pbkdf2.module$(EXEEXT) $(am__EXEEXT_452) $(am__EXEEXT_453) \
+ $(am__EXEEXT_454) $(am__EXEEXT_455) $(am__EXEEXT_456) \
+ $(am__EXEEXT_457) $(am__EXEEXT_458) $(am__EXEEXT_459) \
+ $(am__EXEEXT_460) $(am__EXEEXT_461) $(am__EXEEXT_462) \
+ $(am__EXEEXT_463) $(am__EXEEXT_464) $(am__EXEEXT_465) \
+ $(am__EXEEXT_466) $(am__EXEEXT_467) $(am__EXEEXT_468) \
+ $(am__EXEEXT_469) $(am__EXEEXT_470) $(am__EXEEXT_471) \
+ $(am__EXEEXT_472) $(am__EXEEXT_473) $(am__EXEEXT_474) \
+ $(am__EXEEXT_475) $(am__EXEEXT_476) $(am__EXEEXT_477) \
+ $(am__EXEEXT_478) $(am__EXEEXT_479) $(am__EXEEXT_480) \
+ $(am__EXEEXT_481) $(am__EXEEXT_482) $(am__EXEEXT_483) \
+ $(am__EXEEXT_484) $(am__EXEEXT_485) $(am__EXEEXT_486) \
+ $(am__EXEEXT_487) $(am__EXEEXT_488) setjmp.module$(EXEEXT) \
+ $(am__EXEEXT_489) $(am__EXEEXT_490) $(am__EXEEXT_491) \
+ $(am__EXEEXT_492) $(am__EXEEXT_493) $(am__EXEEXT_494) \
+ $(am__EXEEXT_495) $(am__EXEEXT_496) $(am__EXEEXT_497) \
+ $(am__EXEEXT_498) $(am__EXEEXT_499) $(am__EXEEXT_500) \
+ $(am__EXEEXT_501) $(am__EXEEXT_502) $(am__EXEEXT_503) \
+ $(am__EXEEXT_504) $(am__EXEEXT_505) $(am__EXEEXT_506) \
+ $(am__EXEEXT_507) $(am__EXEEXT_508) $(am__EXEEXT_509) \
+ $(am__EXEEXT_510) $(am__EXEEXT_511) $(am__EXEEXT_512) \
+ $(am__EXEEXT_513) $(am__EXEEXT_514) $(am__EXEEXT_515) \
+ $(am__EXEEXT_516) $(am__EXEEXT_517) $(am__EXEEXT_518) \
+ $(am__EXEEXT_519) $(am__EXEEXT_520) $(am__EXEEXT_521) \
+ $(am__EXEEXT_522) $(am__EXEEXT_523) $(am__EXEEXT_524) \
+ $(am__EXEEXT_525) $(am__EXEEXT_526) $(am__EXEEXT_527) \
+ $(am__EXEEXT_528) $(am__EXEEXT_529) $(am__EXEEXT_530) \
+ $(am__EXEEXT_531) $(am__EXEEXT_532) $(am__EXEEXT_533) \
+ $(am__EXEEXT_534) $(am__EXEEXT_535) $(am__EXEEXT_536) \
+ $(am__EXEEXT_537) $(am__EXEEXT_538) $(am__EXEEXT_539) \
+ $(am__EXEEXT_540) $(am__EXEEXT_541) $(am__EXEEXT_542) \
+ $(am__EXEEXT_543) $(am__EXEEXT_544) $(am__EXEEXT_545) \
+ $(am__EXEEXT_546) $(am__EXEEXT_547) $(am__EXEEXT_548) \
+ $(am__EXEEXT_549) $(am__EXEEXT_550) $(am__EXEEXT_551) \
+ $(am__EXEEXT_552) $(am__EXEEXT_553) $(am__EXEEXT_554) \
+ $(am__EXEEXT_555) $(am__EXEEXT_556) $(am__EXEEXT_557) \
+ $(am__EXEEXT_558) $(am__EXEEXT_559) $(am__EXEEXT_560) \
+ $(am__EXEEXT_561) $(am__EXEEXT_562) $(am__EXEEXT_563) \
+ $(am__EXEEXT_564) $(am__EXEEXT_565) $(am__EXEEXT_566) \
+ macho.module$(EXEEXT) $(am__EXEEXT_567) $(am__EXEEXT_568) \
+ $(am__EXEEXT_569) $(am__EXEEXT_570) $(am__EXEEXT_571) \
+ $(am__EXEEXT_572) $(am__EXEEXT_573) $(am__EXEEXT_574) \
+ $(am__EXEEXT_575) $(am__EXEEXT_576) $(am__EXEEXT_577) \
+ $(am__EXEEXT_578) $(am__EXEEXT_579) $(am__EXEEXT_580) \
+ $(am__EXEEXT_581) $(am__EXEEXT_582) $(am__EXEEXT_583) \
+ $(am__EXEEXT_584) $(am__EXEEXT_585) $(am__EXEEXT_586) \
+ $(am__EXEEXT_587) $(am__EXEEXT_588) $(am__EXEEXT_589) \
+ $(am__EXEEXT_590) $(am__EXEEXT_591) $(am__EXEEXT_592) \
+ $(am__EXEEXT_593) normal.module$(EXEEXT) \
+ part_acorn.module$(EXEEXT) part_amiga.module$(EXEEXT) \
+ part_apple.module$(EXEEXT) part_gpt.module$(EXEEXT) \
+ part_msdos.module$(EXEEXT) part_sun.module$(EXEEXT) \
+ part_plan.module$(EXEEXT) part_dvh.module$(EXEEXT) \
+ part_bsd.module$(EXEEXT) part_sunpc.module$(EXEEXT) \
+ part_dfly.module$(EXEEXT) msdospart.module$(EXEEXT) \
+ $(am__EXEEXT_594) $(am__EXEEXT_595) $(am__EXEEXT_596) \
+ $(am__EXEEXT_597) $(am__EXEEXT_598) $(am__EXEEXT_599) \
+ $(am__EXEEXT_600) $(am__EXEEXT_601) $(am__EXEEXT_602) \
+ $(am__EXEEXT_603) $(am__EXEEXT_604) $(am__EXEEXT_605) \
+ $(am__EXEEXT_606) $(am__EXEEXT_607) $(am__EXEEXT_608) \
+ $(am__EXEEXT_609) $(am__EXEEXT_610) $(am__EXEEXT_611) \
+ $(am__EXEEXT_612) $(am__EXEEXT_613) $(am__EXEEXT_614) \
+ $(am__EXEEXT_615) $(am__EXEEXT_616) $(am__EXEEXT_617) \
+ $(am__EXEEXT_618) $(am__EXEEXT_619) $(am__EXEEXT_620) \
+ gfxterm_background.module$(EXEEXT) $(am__EXEEXT_621) \
+ $(am__EXEEXT_622) $(am__EXEEXT_623) $(am__EXEEXT_624) \
+ $(am__EXEEXT_625) $(am__EXEEXT_626) $(am__EXEEXT_627) \
+ $(am__EXEEXT_628) $(am__EXEEXT_629) $(am__EXEEXT_630) \
+ $(am__EXEEXT_631) $(am__EXEEXT_632) $(am__EXEEXT_633) \
+ $(am__EXEEXT_634) $(am__EXEEXT_635) $(am__EXEEXT_636) \
+ $(am__EXEEXT_637) $(am__EXEEXT_638) $(am__EXEEXT_639) \
+ $(am__EXEEXT_640) $(am__EXEEXT_641) $(am__EXEEXT_642) \
+ $(am__EXEEXT_643) $(am__EXEEXT_644) $(am__EXEEXT_645) \
+ $(am__EXEEXT_646) $(am__EXEEXT_647) $(am__EXEEXT_648) \
+ $(am__EXEEXT_649) $(am__EXEEXT_650) $(am__EXEEXT_651) \
+ $(am__EXEEXT_652) $(am__EXEEXT_653) $(am__EXEEXT_654) \
+ $(am__EXEEXT_655) $(am__EXEEXT_656) $(am__EXEEXT_657) \
+ $(am__EXEEXT_658) $(am__EXEEXT_659) $(am__EXEEXT_660) \
+ $(am__EXEEXT_661) $(am__EXEEXT_662) $(am__EXEEXT_663) \
+ $(am__EXEEXT_664) $(am__EXEEXT_665) $(am__EXEEXT_666) \
+ $(am__EXEEXT_667) $(am__EXEEXT_668) $(am__EXEEXT_669) \
+ $(am__EXEEXT_670) $(am__EXEEXT_671) $(am__EXEEXT_672) \
+ $(am__EXEEXT_673) $(am__EXEEXT_674) $(am__EXEEXT_675) \
+ functional_test.module$(EXEEXT) exfctest.module$(EXEEXT) \
+ strtoull_test.module$(EXEEXT) setjmp_test.module$(EXEEXT) \
+ signature_test.module$(EXEEXT) sleep_test.module$(EXEEXT) \
+ xnu_uuid_test.module$(EXEEXT) pbkdf2_test.module$(EXEEXT) \
+ $(am__EXEEXT_676) $(am__EXEEXT_677) $(am__EXEEXT_678) \
+ $(am__EXEEXT_679) $(am__EXEEXT_680) $(am__EXEEXT_681) \
+ $(am__EXEEXT_682) $(am__EXEEXT_683) $(am__EXEEXT_684) \
+ $(am__EXEEXT_685) $(am__EXEEXT_686) $(am__EXEEXT_687) \
+ $(am__EXEEXT_688) $(am__EXEEXT_689) $(am__EXEEXT_690) \
+ $(am__EXEEXT_691) $(am__EXEEXT_692) $(am__EXEEXT_693) \
+ $(am__EXEEXT_694) $(am__EXEEXT_695) $(am__EXEEXT_696) \
+ $(am__EXEEXT_697) $(am__EXEEXT_698) $(am__EXEEXT_699) \
+ $(am__EXEEXT_700) div_test.module$(EXEEXT) \
+ mul_test.module$(EXEEXT) shift_test.module$(EXEEXT) \
+ cmp_test.module$(EXEEXT) ctz_test.module$(EXEEXT) \
+ bswap_test.module$(EXEEXT) videotest_checksum.module$(EXEEXT) \
+ gfxterm_menu.module$(EXEEXT) cmdline_cat_test.module$(EXEEXT) \
+ bitmap.module$(EXEEXT) bitmap_scale.module$(EXEEXT) \
+ $(am__EXEEXT_701) $(am__EXEEXT_702) $(am__EXEEXT_703) \
+ $(am__EXEEXT_704) $(am__EXEEXT_705) $(am__EXEEXT_706) \
+ $(am__EXEEXT_707) $(am__EXEEXT_708) $(am__EXEEXT_709) \
+ jpeg.module$(EXEEXT) png.module$(EXEEXT) tga.module$(EXEEXT) \
+ $(am__EXEEXT_710) $(am__EXEEXT_711) $(am__EXEEXT_712) \
+ $(am__EXEEXT_713) $(am__EXEEXT_714) $(am__EXEEXT_715) \
+ $(am__EXEEXT_716) $(am__EXEEXT_717) $(am__EXEEXT_718) \
+ $(am__EXEEXT_719) $(am__EXEEXT_720) $(am__EXEEXT_721) \
+ $(am__EXEEXT_722) $(am__EXEEXT_723) $(am__EXEEXT_724) \
+ $(am__EXEEXT_725) $(am__EXEEXT_726) $(am__EXEEXT_727) \
+ $(am__EXEEXT_728) $(am__EXEEXT_729) $(am__EXEEXT_730) \
+ $(am__EXEEXT_731) $(am__EXEEXT_732) $(am__EXEEXT_733) \
+ $(am__EXEEXT_734) $(am__EXEEXT_735) $(am__EXEEXT_736) \
+ $(am__EXEEXT_737) $(am__EXEEXT_738) $(am__EXEEXT_739) \
+ $(am__EXEEXT_740) $(am__EXEEXT_741) $(am__EXEEXT_742) \
+ $(am__EXEEXT_743) $(am__EXEEXT_744) $(am__EXEEXT_745) \
+ $(am__EXEEXT_746) $(am__EXEEXT_747) $(am__EXEEXT_748) \
+ $(am__EXEEXT_749) $(am__EXEEXT_750) \
+ video_colors.module$(EXEEXT) $(am__EXEEXT_751) \
+ $(am__EXEEXT_752) datehook.module$(EXEEXT) net.module$(EXEEXT) \
+ tftp.module$(EXEEXT) http.module$(EXEEXT) $(am__EXEEXT_753) \
+ $(am__EXEEXT_754) $(am__EXEEXT_755) $(am__EXEEXT_756) \
+ $(am__EXEEXT_757) $(am__EXEEXT_758) $(am__EXEEXT_759) \
+ $(am__EXEEXT_760) $(am__EXEEXT_761) $(am__EXEEXT_762) \
+ $(am__EXEEXT_763) $(am__EXEEXT_764) $(am__EXEEXT_765) \
+ $(am__EXEEXT_766) $(am__EXEEXT_767) $(am__EXEEXT_768) \
+ $(am__EXEEXT_769) $(am__EXEEXT_770) \
+ syslinuxcfg.module$(EXEEXT) test_blockarg.module$(EXEEXT) \
+ xzio.module$(EXEEXT) lzopio.module$(EXEEXT) \
+ testload.module$(EXEEXT) $(am__EXEEXT_771) $(am__EXEEXT_772) \
+ $(am__EXEEXT_773) $(am__EXEEXT_774) $(am__EXEEXT_775) \
+ $(am__EXEEXT_776) $(am__EXEEXT_777) $(am__EXEEXT_778) \
+ $(am__EXEEXT_779) $(am__EXEEXT_780) $(am__EXEEXT_781) \
+ $(am__EXEEXT_782) $(am__EXEEXT_783) $(am__EXEEXT_784) \
+ $(am__EXEEXT_785) $(am__EXEEXT_786) $(am__EXEEXT_787) \
+ priority_queue.module$(EXEEXT) time.module$(EXEEXT) \
+ $(am__EXEEXT_788) $(am__EXEEXT_789) adler32.module$(EXEEXT) \
+ crc64.module$(EXEEXT) mpi.module$(EXEEXT) \
+ all_video.module$(EXEEXT) $(am__EXEEXT_790) $(am__EXEEXT_791) \
+ $(am__EXEEXT_792) $(am__EXEEXT_793) $(am__EXEEXT_794) \
+ $(am__EXEEXT_795) testspeed.module$(EXEEXT) $(am__EXEEXT_796) \
+ $(am__EXEEXT_797) $(am__EXEEXT_798) $(am__EXEEXT_799) \
+ $(am__EXEEXT_800) $(am__EXEEXT_801) $(am__EXEEXT_802) \
+ tr.module$(EXEEXT) progress.module$(EXEEXT) \
+ file.module$(EXEEXT) $(am__EXEEXT_803) $(am__EXEEXT_804) \
+ $(am__EXEEXT_805) $(am__EXEEXT_806) $(am__EXEEXT_807) \
+ $(am__EXEEXT_808) $(am__EXEEXT_809) $(am__EXEEXT_810) \
+ $(am__EXEEXT_811) $(am__EXEEXT_812) $(am__EXEEXT_813) \
+ $(am__EXEEXT_814) $(am__EXEEXT_815) $(am__EXEEXT_816) \
+ gcry_arcfour.module$(EXEEXT) gcry_blowfish.module$(EXEEXT) \
+ gcry_camellia.module$(EXEEXT) gcry_cast5.module$(EXEEXT) \
+ gcry_crc.module$(EXEEXT) gcry_des.module$(EXEEXT) \
+ gcry_dsa.module$(EXEEXT) gcry_idea.module$(EXEEXT) \
+ gcry_md4.module$(EXEEXT) gcry_md5.module$(EXEEXT) \
+ gcry_rfc2268.module$(EXEEXT) gcry_rijndael.module$(EXEEXT) \
+ gcry_rmd160.module$(EXEEXT) gcry_rsa.module$(EXEEXT) \
+ gcry_seed.module$(EXEEXT) gcry_serpent.module$(EXEEXT) \
+ gcry_sha1.module$(EXEEXT) gcry_sha256.module$(EXEEXT) \
+ gcry_sha512.module$(EXEEXT) gcry_tiger.module$(EXEEXT) \
+ gcry_twofish.module$(EXEEXT) gcry_whirlpool.module$(EXEEXT) \
+ $(am__EXEEXT_817) $(am__EXEEXT_818) $(am__EXEEXT_819) \
+ $(am__EXEEXT_820) $(am__EXEEXT_821) $(am__EXEEXT_822) \
+ $(am__EXEEXT_823) $(am__EXEEXT_824) $(am__EXEEXT_825) \
+ $(am__EXEEXT_826) $(am__EXEEXT_827) $(am__EXEEXT_828) \
+ $(am__EXEEXT_829) $(am__EXEEXT_830) $(am__EXEEXT_831) \
+ $(am__EXEEXT_832) $(am__EXEEXT_833) $(am__EXEEXT_834) \
+ $(am__EXEEXT_835) $(am__EXEEXT_836) $(am__EXEEXT_837) \
+ $(am__EXEEXT_838) $(am__EXEEXT_839) $(am__EXEEXT_840) \
+ $(am__EXEEXT_841) $(am__EXEEXT_842) $(am__EXEEXT_843) \
+ $(am__EXEEXT_844) $(am__EXEEXT_845) $(am__EXEEXT_846) \
+ $(am__EXEEXT_847) $(am__EXEEXT_848) $(am__EXEEXT_849) \
+ $(am__EXEEXT_850) $(am__EXEEXT_851) $(am__EXEEXT_852) \
+ $(am__EXEEXT_853) $(am__EXEEXT_854) $(am__EXEEXT_855)
+TESTS =
+@COND_i386_pc_TRUE@am__append_3 = cs5536.module
+@COND_i386_pc_TRUE@am__append_4 = cs5536.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@cs5536_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_5 =
+@COND_i386_pc_TRUE@am__append_6 = $(nodist_cs5536_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_7 = $(nodist_cs5536_module_SOURCES) \
+@COND_i386_pc_TRUE@ cs5536.marker
+@COND_i386_pc_TRUE@am__append_8 = cs5536.mod
+@COND_i386_pc_TRUE@am__append_9 = cs5536.marker
+@COND_i386_efi_TRUE@am__append_10 = cs5536.module
+@COND_i386_efi_TRUE@am__append_11 = cs5536.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_12 =
+@COND_i386_efi_TRUE@am__append_13 = $(nodist_cs5536_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_14 = $(nodist_cs5536_module_SOURCES) \
+@COND_i386_efi_TRUE@ cs5536.marker
+@COND_i386_efi_TRUE@am__append_15 = cs5536.mod
+@COND_i386_efi_TRUE@am__append_16 = cs5536.marker
+@COND_i386_qemu_TRUE@am__append_17 = cs5536.module
+@COND_i386_qemu_TRUE@am__append_18 = cs5536.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_19 =
+@COND_i386_qemu_TRUE@am__append_20 = $(nodist_cs5536_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_21 = $(nodist_cs5536_module_SOURCES) \
+@COND_i386_qemu_TRUE@ cs5536.marker
+@COND_i386_qemu_TRUE@am__append_22 = cs5536.mod
+@COND_i386_qemu_TRUE@am__append_23 = cs5536.marker
+@COND_i386_coreboot_TRUE@am__append_24 = cs5536.module
+@COND_i386_coreboot_TRUE@am__append_25 = cs5536.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_26 =
+@COND_i386_coreboot_TRUE@am__append_27 = $(nodist_cs5536_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_28 = \
+@COND_i386_coreboot_TRUE@ $(nodist_cs5536_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ cs5536.marker
+@COND_i386_coreboot_TRUE@am__append_29 = cs5536.mod
+@COND_i386_coreboot_TRUE@am__append_30 = cs5536.marker
+@COND_i386_multiboot_TRUE@am__append_31 = cs5536.module
+@COND_i386_multiboot_TRUE@am__append_32 = cs5536.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_33 =
+@COND_i386_multiboot_TRUE@am__append_34 = $(nodist_cs5536_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_35 = \
+@COND_i386_multiboot_TRUE@ $(nodist_cs5536_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ cs5536.marker
+@COND_i386_multiboot_TRUE@am__append_36 = cs5536.mod
+@COND_i386_multiboot_TRUE@am__append_37 = cs5536.marker
+@COND_i386_ieee1275_TRUE@am__append_38 = cs5536.module
+@COND_i386_ieee1275_TRUE@am__append_39 = cs5536.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_40 =
+@COND_i386_ieee1275_TRUE@am__append_41 = $(nodist_cs5536_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_42 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_cs5536_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ cs5536.marker
+@COND_i386_ieee1275_TRUE@am__append_43 = cs5536.mod
+@COND_i386_ieee1275_TRUE@am__append_44 = cs5536.marker
+@COND_x86_64_efi_TRUE@am__append_45 = cs5536.module
+@COND_x86_64_efi_TRUE@am__append_46 = cs5536.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_47 =
+@COND_x86_64_efi_TRUE@am__append_48 = $(nodist_cs5536_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_49 = $(nodist_cs5536_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ cs5536.marker
+@COND_x86_64_efi_TRUE@am__append_50 = cs5536.mod
+@COND_x86_64_efi_TRUE@am__append_51 = cs5536.marker
+@COND_mips_loongson_TRUE@am__append_52 = lsspd.module
+@COND_mips_loongson_TRUE@am__append_53 = lsspd.module$(EXEEXT)
+@COND_mips_loongson_FALSE@lsspd_module_DEPENDENCIES =
+@COND_mips_loongson_TRUE@am__append_54 =
+@COND_mips_loongson_TRUE@am__append_55 = $(nodist_lsspd_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_56 = \
+@COND_mips_loongson_TRUE@ $(nodist_lsspd_module_SOURCES) \
+@COND_mips_loongson_TRUE@ lsspd.marker
+@COND_mips_loongson_TRUE@am__append_57 = lsspd.mod
+@COND_mips_loongson_TRUE@am__append_58 = lsspd.marker
+@COND_i386_pc_TRUE@am__append_59 = usb.module
+@COND_i386_pc_TRUE@am__append_60 = usb.module$(EXEEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@usb_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_61 =
+@COND_i386_pc_TRUE@am__append_62 = $(nodist_usb_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_63 = $(nodist_usb_module_SOURCES) \
+@COND_i386_pc_TRUE@ usb.marker
+@COND_i386_pc_TRUE@am__append_64 = usb.mod
+@COND_i386_pc_TRUE@am__append_65 = usb.marker
+@COND_i386_efi_TRUE@am__append_66 = usb.module
+@COND_i386_efi_TRUE@am__append_67 = usb.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_68 =
+@COND_i386_efi_TRUE@am__append_69 = $(nodist_usb_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_70 = $(nodist_usb_module_SOURCES) \
+@COND_i386_efi_TRUE@ usb.marker
+@COND_i386_efi_TRUE@am__append_71 = usb.mod
+@COND_i386_efi_TRUE@am__append_72 = usb.marker
+@COND_i386_qemu_TRUE@am__append_73 = usb.module
+@COND_i386_qemu_TRUE@am__append_74 = usb.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_75 =
+@COND_i386_qemu_TRUE@am__append_76 = $(nodist_usb_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_77 = $(nodist_usb_module_SOURCES) \
+@COND_i386_qemu_TRUE@ usb.marker
+@COND_i386_qemu_TRUE@am__append_78 = usb.mod
+@COND_i386_qemu_TRUE@am__append_79 = usb.marker
+@COND_i386_coreboot_TRUE@am__append_80 = usb.module
+@COND_i386_coreboot_TRUE@am__append_81 = usb.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_82 =
+@COND_i386_coreboot_TRUE@am__append_83 = $(nodist_usb_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_84 = $(nodist_usb_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ usb.marker
+@COND_i386_coreboot_TRUE@am__append_85 = usb.mod
+@COND_i386_coreboot_TRUE@am__append_86 = usb.marker
+@COND_i386_multiboot_TRUE@am__append_87 = usb.module
+@COND_i386_multiboot_TRUE@am__append_88 = usb.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_89 =
+@COND_i386_multiboot_TRUE@am__append_90 = $(nodist_usb_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_91 = \
+@COND_i386_multiboot_TRUE@ $(nodist_usb_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ usb.marker
+@COND_i386_multiboot_TRUE@am__append_92 = usb.mod
+@COND_i386_multiboot_TRUE@am__append_93 = usb.marker
+@COND_i386_ieee1275_TRUE@am__append_94 = usb.module
+@COND_i386_ieee1275_TRUE@am__append_95 = usb.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_96 =
+@COND_i386_ieee1275_TRUE@am__append_97 = $(nodist_usb_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_98 = $(nodist_usb_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ usb.marker
+@COND_i386_ieee1275_TRUE@am__append_99 = usb.mod
+@COND_i386_ieee1275_TRUE@am__append_100 = usb.marker
+@COND_x86_64_efi_TRUE@am__append_101 = usb.module
+@COND_x86_64_efi_TRUE@am__append_102 = usb.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_103 =
+@COND_x86_64_efi_TRUE@am__append_104 = $(nodist_usb_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_105 = $(nodist_usb_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ usb.marker
+@COND_x86_64_efi_TRUE@am__append_106 = usb.mod
+@COND_x86_64_efi_TRUE@am__append_107 = usb.marker
+@COND_mips_loongson_TRUE@am__append_108 = usb.module
+@COND_mips_loongson_TRUE@am__append_109 = usb.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_110 =
+@COND_mips_loongson_TRUE@am__append_111 = $(nodist_usb_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_112 = \
+@COND_mips_loongson_TRUE@ $(nodist_usb_module_SOURCES) \
+@COND_mips_loongson_TRUE@ usb.marker
+@COND_mips_loongson_TRUE@am__append_113 = usb.mod
+@COND_mips_loongson_TRUE@am__append_114 = usb.marker
+@COND_arm_coreboot_TRUE@am__append_115 = usb.module
+@COND_arm_coreboot_TRUE@am__append_116 = usb.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_117 =
+@COND_arm_coreboot_TRUE@am__append_118 = $(nodist_usb_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_119 = $(nodist_usb_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ usb.marker
+@COND_arm_coreboot_TRUE@am__append_120 = usb.mod
+@COND_arm_coreboot_TRUE@am__append_121 = usb.marker
+@COND_i386_pc_TRUE@am__append_122 = usbserial_common.module
+@COND_i386_pc_TRUE@am__append_123 = usbserial_common.module$(EXEEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@usbserial_common_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_124 =
+@COND_i386_pc_TRUE@am__append_125 = $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_126 = \
+@COND_i386_pc_TRUE@ $(nodist_usbserial_common_module_SOURCES) \
+@COND_i386_pc_TRUE@ usbserial_common.marker
+@COND_i386_pc_TRUE@am__append_127 = usbserial_common.mod
+@COND_i386_pc_TRUE@am__append_128 = usbserial_common.marker
+@COND_i386_efi_TRUE@am__append_129 = usbserial_common.module
+@COND_i386_efi_TRUE@am__append_130 = usbserial_common.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_131 =
+@COND_i386_efi_TRUE@am__append_132 = $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_133 = \
+@COND_i386_efi_TRUE@ $(nodist_usbserial_common_module_SOURCES) \
+@COND_i386_efi_TRUE@ usbserial_common.marker
+@COND_i386_efi_TRUE@am__append_134 = usbserial_common.mod
+@COND_i386_efi_TRUE@am__append_135 = usbserial_common.marker
+@COND_i386_qemu_TRUE@am__append_136 = usbserial_common.module
+@COND_i386_qemu_TRUE@am__append_137 = usbserial_common.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_138 =
+@COND_i386_qemu_TRUE@am__append_139 = $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_140 = $(nodist_usbserial_common_module_SOURCES) \
+@COND_i386_qemu_TRUE@ usbserial_common.marker
+@COND_i386_qemu_TRUE@am__append_141 = usbserial_common.mod
+@COND_i386_qemu_TRUE@am__append_142 = usbserial_common.marker
+@COND_i386_coreboot_TRUE@am__append_143 = usbserial_common.module
+@COND_i386_coreboot_TRUE@am__append_144 = usbserial_common.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_145 =
+@COND_i386_coreboot_TRUE@am__append_146 = $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_147 = $(nodist_usbserial_common_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ usbserial_common.marker
+@COND_i386_coreboot_TRUE@am__append_148 = usbserial_common.mod
+@COND_i386_coreboot_TRUE@am__append_149 = usbserial_common.marker
+@COND_i386_multiboot_TRUE@am__append_150 = usbserial_common.module
+@COND_i386_multiboot_TRUE@am__append_151 = usbserial_common.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_152 =
+@COND_i386_multiboot_TRUE@am__append_153 = $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_154 = $(nodist_usbserial_common_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ usbserial_common.marker
+@COND_i386_multiboot_TRUE@am__append_155 = usbserial_common.mod
+@COND_i386_multiboot_TRUE@am__append_156 = usbserial_common.marker
+@COND_i386_ieee1275_TRUE@am__append_157 = usbserial_common.module
+@COND_i386_ieee1275_TRUE@am__append_158 = usbserial_common.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_159 =
+@COND_i386_ieee1275_TRUE@am__append_160 = $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_161 = $(nodist_usbserial_common_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ usbserial_common.marker
+@COND_i386_ieee1275_TRUE@am__append_162 = usbserial_common.mod
+@COND_i386_ieee1275_TRUE@am__append_163 = usbserial_common.marker
+@COND_x86_64_efi_TRUE@am__append_164 = usbserial_common.module
+@COND_x86_64_efi_TRUE@am__append_165 = usbserial_common.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_166 =
+@COND_x86_64_efi_TRUE@am__append_167 = $(nodist_usbserial_common_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_168 = $(nodist_usbserial_common_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ usbserial_common.marker
+@COND_x86_64_efi_TRUE@am__append_169 = usbserial_common.mod
+@COND_x86_64_efi_TRUE@am__append_170 = usbserial_common.marker
+@COND_mips_loongson_TRUE@am__append_171 = usbserial_common.module
+@COND_mips_loongson_TRUE@am__append_172 = usbserial_common.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_173 =
+@COND_mips_loongson_TRUE@am__append_174 = $(nodist_usbserial_common_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_175 = $(nodist_usbserial_common_module_SOURCES) \
+@COND_mips_loongson_TRUE@ usbserial_common.marker
+@COND_mips_loongson_TRUE@am__append_176 = usbserial_common.mod
+@COND_mips_loongson_TRUE@am__append_177 = usbserial_common.marker
+@COND_arm_coreboot_TRUE@am__append_178 = usbserial_common.module
+@COND_arm_coreboot_TRUE@am__append_179 = usbserial_common.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_180 =
+@COND_arm_coreboot_TRUE@am__append_181 = $(nodist_usbserial_common_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_182 = $(nodist_usbserial_common_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ usbserial_common.marker
+@COND_arm_coreboot_TRUE@am__append_183 = usbserial_common.mod
+@COND_arm_coreboot_TRUE@am__append_184 = usbserial_common.marker
+@COND_i386_pc_TRUE@am__append_185 = usbserial_pl2303.module
+@COND_i386_pc_TRUE@am__append_186 = usbserial_pl2303.module$(EXEEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@usbserial_pl2303_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_187 =
+@COND_i386_pc_TRUE@am__append_188 = $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_189 = \
+@COND_i386_pc_TRUE@ $(nodist_usbserial_pl2303_module_SOURCES) \
+@COND_i386_pc_TRUE@ usbserial_pl2303.marker
+@COND_i386_pc_TRUE@am__append_190 = usbserial_pl2303.mod
+@COND_i386_pc_TRUE@am__append_191 = usbserial_pl2303.marker
+@COND_i386_efi_TRUE@am__append_192 = usbserial_pl2303.module
+@COND_i386_efi_TRUE@am__append_193 = usbserial_pl2303.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_194 =
+@COND_i386_efi_TRUE@am__append_195 = $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_196 = \
+@COND_i386_efi_TRUE@ $(nodist_usbserial_pl2303_module_SOURCES) \
+@COND_i386_efi_TRUE@ usbserial_pl2303.marker
+@COND_i386_efi_TRUE@am__append_197 = usbserial_pl2303.mod
+@COND_i386_efi_TRUE@am__append_198 = usbserial_pl2303.marker
+@COND_i386_qemu_TRUE@am__append_199 = usbserial_pl2303.module
+@COND_i386_qemu_TRUE@am__append_200 = usbserial_pl2303.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_201 =
+@COND_i386_qemu_TRUE@am__append_202 = $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_203 = $(nodist_usbserial_pl2303_module_SOURCES) \
+@COND_i386_qemu_TRUE@ usbserial_pl2303.marker
+@COND_i386_qemu_TRUE@am__append_204 = usbserial_pl2303.mod
+@COND_i386_qemu_TRUE@am__append_205 = usbserial_pl2303.marker
+@COND_i386_coreboot_TRUE@am__append_206 = usbserial_pl2303.module
+@COND_i386_coreboot_TRUE@am__append_207 = usbserial_pl2303.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_208 =
+@COND_i386_coreboot_TRUE@am__append_209 = $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_210 = $(nodist_usbserial_pl2303_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ usbserial_pl2303.marker
+@COND_i386_coreboot_TRUE@am__append_211 = usbserial_pl2303.mod
+@COND_i386_coreboot_TRUE@am__append_212 = usbserial_pl2303.marker
+@COND_i386_multiboot_TRUE@am__append_213 = usbserial_pl2303.module
+@COND_i386_multiboot_TRUE@am__append_214 = usbserial_pl2303.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_215 =
+@COND_i386_multiboot_TRUE@am__append_216 = $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_217 = $(nodist_usbserial_pl2303_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ usbserial_pl2303.marker
+@COND_i386_multiboot_TRUE@am__append_218 = usbserial_pl2303.mod
+@COND_i386_multiboot_TRUE@am__append_219 = usbserial_pl2303.marker
+@COND_i386_ieee1275_TRUE@am__append_220 = usbserial_pl2303.module
+@COND_i386_ieee1275_TRUE@am__append_221 = usbserial_pl2303.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_222 =
+@COND_i386_ieee1275_TRUE@am__append_223 = $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_224 = $(nodist_usbserial_pl2303_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ usbserial_pl2303.marker
+@COND_i386_ieee1275_TRUE@am__append_225 = usbserial_pl2303.mod
+@COND_i386_ieee1275_TRUE@am__append_226 = usbserial_pl2303.marker
+@COND_x86_64_efi_TRUE@am__append_227 = usbserial_pl2303.module
+@COND_x86_64_efi_TRUE@am__append_228 = usbserial_pl2303.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_229 =
+@COND_x86_64_efi_TRUE@am__append_230 = $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_231 = $(nodist_usbserial_pl2303_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ usbserial_pl2303.marker
+@COND_x86_64_efi_TRUE@am__append_232 = usbserial_pl2303.mod
+@COND_x86_64_efi_TRUE@am__append_233 = usbserial_pl2303.marker
+@COND_mips_loongson_TRUE@am__append_234 = usbserial_pl2303.module
+@COND_mips_loongson_TRUE@am__append_235 = usbserial_pl2303.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_236 =
+@COND_mips_loongson_TRUE@am__append_237 = $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_238 = $(nodist_usbserial_pl2303_module_SOURCES) \
+@COND_mips_loongson_TRUE@ usbserial_pl2303.marker
+@COND_mips_loongson_TRUE@am__append_239 = usbserial_pl2303.mod
+@COND_mips_loongson_TRUE@am__append_240 = usbserial_pl2303.marker
+@COND_arm_coreboot_TRUE@am__append_241 = usbserial_pl2303.module
+@COND_arm_coreboot_TRUE@am__append_242 = usbserial_pl2303.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_243 =
+@COND_arm_coreboot_TRUE@am__append_244 = $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_245 = $(nodist_usbserial_pl2303_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ usbserial_pl2303.marker
+@COND_arm_coreboot_TRUE@am__append_246 = usbserial_pl2303.mod
+@COND_arm_coreboot_TRUE@am__append_247 = usbserial_pl2303.marker
+@COND_i386_pc_TRUE@am__append_248 = usbserial_ftdi.module
+@COND_i386_pc_TRUE@am__append_249 = usbserial_ftdi.module$(EXEEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@usbserial_ftdi_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_250 =
+@COND_i386_pc_TRUE@am__append_251 = $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_252 = \
+@COND_i386_pc_TRUE@ $(nodist_usbserial_ftdi_module_SOURCES) \
+@COND_i386_pc_TRUE@ usbserial_ftdi.marker
+@COND_i386_pc_TRUE@am__append_253 = usbserial_ftdi.mod
+@COND_i386_pc_TRUE@am__append_254 = usbserial_ftdi.marker
+@COND_i386_efi_TRUE@am__append_255 = usbserial_ftdi.module
+@COND_i386_efi_TRUE@am__append_256 = usbserial_ftdi.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_257 =
+@COND_i386_efi_TRUE@am__append_258 = $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_259 = \
+@COND_i386_efi_TRUE@ $(nodist_usbserial_ftdi_module_SOURCES) \
+@COND_i386_efi_TRUE@ usbserial_ftdi.marker
+@COND_i386_efi_TRUE@am__append_260 = usbserial_ftdi.mod
+@COND_i386_efi_TRUE@am__append_261 = usbserial_ftdi.marker
+@COND_i386_qemu_TRUE@am__append_262 = usbserial_ftdi.module
+@COND_i386_qemu_TRUE@am__append_263 = usbserial_ftdi.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_264 =
+@COND_i386_qemu_TRUE@am__append_265 = $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_266 = \
+@COND_i386_qemu_TRUE@ $(nodist_usbserial_ftdi_module_SOURCES) \
+@COND_i386_qemu_TRUE@ usbserial_ftdi.marker
+@COND_i386_qemu_TRUE@am__append_267 = usbserial_ftdi.mod
+@COND_i386_qemu_TRUE@am__append_268 = usbserial_ftdi.marker
+@COND_i386_coreboot_TRUE@am__append_269 = usbserial_ftdi.module
+@COND_i386_coreboot_TRUE@am__append_270 = usbserial_ftdi.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_271 =
+@COND_i386_coreboot_TRUE@am__append_272 = $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_273 = $(nodist_usbserial_ftdi_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ usbserial_ftdi.marker
+@COND_i386_coreboot_TRUE@am__append_274 = usbserial_ftdi.mod
+@COND_i386_coreboot_TRUE@am__append_275 = usbserial_ftdi.marker
+@COND_i386_multiboot_TRUE@am__append_276 = usbserial_ftdi.module
+@COND_i386_multiboot_TRUE@am__append_277 = usbserial_ftdi.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_278 =
+@COND_i386_multiboot_TRUE@am__append_279 = $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_280 = $(nodist_usbserial_ftdi_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ usbserial_ftdi.marker
+@COND_i386_multiboot_TRUE@am__append_281 = usbserial_ftdi.mod
+@COND_i386_multiboot_TRUE@am__append_282 = usbserial_ftdi.marker
+@COND_i386_ieee1275_TRUE@am__append_283 = usbserial_ftdi.module
+@COND_i386_ieee1275_TRUE@am__append_284 = usbserial_ftdi.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_285 =
+@COND_i386_ieee1275_TRUE@am__append_286 = $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_287 = $(nodist_usbserial_ftdi_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ usbserial_ftdi.marker
+@COND_i386_ieee1275_TRUE@am__append_288 = usbserial_ftdi.mod
+@COND_i386_ieee1275_TRUE@am__append_289 = usbserial_ftdi.marker
+@COND_x86_64_efi_TRUE@am__append_290 = usbserial_ftdi.module
+@COND_x86_64_efi_TRUE@am__append_291 = usbserial_ftdi.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_292 =
+@COND_x86_64_efi_TRUE@am__append_293 = $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_294 = \
+@COND_x86_64_efi_TRUE@ $(nodist_usbserial_ftdi_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ usbserial_ftdi.marker
+@COND_x86_64_efi_TRUE@am__append_295 = usbserial_ftdi.mod
+@COND_x86_64_efi_TRUE@am__append_296 = usbserial_ftdi.marker
+@COND_mips_loongson_TRUE@am__append_297 = usbserial_ftdi.module
+@COND_mips_loongson_TRUE@am__append_298 = usbserial_ftdi.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_299 =
+@COND_mips_loongson_TRUE@am__append_300 = $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_301 = $(nodist_usbserial_ftdi_module_SOURCES) \
+@COND_mips_loongson_TRUE@ usbserial_ftdi.marker
+@COND_mips_loongson_TRUE@am__append_302 = usbserial_ftdi.mod
+@COND_mips_loongson_TRUE@am__append_303 = usbserial_ftdi.marker
+@COND_arm_coreboot_TRUE@am__append_304 = usbserial_ftdi.module
+@COND_arm_coreboot_TRUE@am__append_305 = usbserial_ftdi.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_306 =
+@COND_arm_coreboot_TRUE@am__append_307 = $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_308 = $(nodist_usbserial_ftdi_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ usbserial_ftdi.marker
+@COND_arm_coreboot_TRUE@am__append_309 = usbserial_ftdi.mod
+@COND_arm_coreboot_TRUE@am__append_310 = usbserial_ftdi.marker
+@COND_i386_pc_TRUE@am__append_311 = usbserial_usbdebug.module
+@COND_i386_pc_TRUE@am__append_312 = usbserial_usbdebug.module$(EXEEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@usbserial_usbdebug_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_313 =
+@COND_i386_pc_TRUE@am__append_314 = $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_315 = $(nodist_usbserial_usbdebug_module_SOURCES) \
+@COND_i386_pc_TRUE@ usbserial_usbdebug.marker
+@COND_i386_pc_TRUE@am__append_316 = usbserial_usbdebug.mod
+@COND_i386_pc_TRUE@am__append_317 = usbserial_usbdebug.marker
+@COND_i386_efi_TRUE@am__append_318 = usbserial_usbdebug.module
+@COND_i386_efi_TRUE@am__append_319 = usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_320 =
+@COND_i386_efi_TRUE@am__append_321 = $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_322 = $(nodist_usbserial_usbdebug_module_SOURCES) \
+@COND_i386_efi_TRUE@ usbserial_usbdebug.marker
+@COND_i386_efi_TRUE@am__append_323 = usbserial_usbdebug.mod
+@COND_i386_efi_TRUE@am__append_324 = usbserial_usbdebug.marker
+@COND_i386_qemu_TRUE@am__append_325 = usbserial_usbdebug.module
+@COND_i386_qemu_TRUE@am__append_326 = usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_327 =
+@COND_i386_qemu_TRUE@am__append_328 = $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_329 = $(nodist_usbserial_usbdebug_module_SOURCES) \
+@COND_i386_qemu_TRUE@ usbserial_usbdebug.marker
+@COND_i386_qemu_TRUE@am__append_330 = usbserial_usbdebug.mod
+@COND_i386_qemu_TRUE@am__append_331 = usbserial_usbdebug.marker
+@COND_i386_coreboot_TRUE@am__append_332 = usbserial_usbdebug.module
+@COND_i386_coreboot_TRUE@am__append_333 = usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_334 =
+@COND_i386_coreboot_TRUE@am__append_335 = $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_336 = $(nodist_usbserial_usbdebug_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ usbserial_usbdebug.marker
+@COND_i386_coreboot_TRUE@am__append_337 = usbserial_usbdebug.mod
+@COND_i386_coreboot_TRUE@am__append_338 = usbserial_usbdebug.marker
+@COND_i386_multiboot_TRUE@am__append_339 = usbserial_usbdebug.module
+@COND_i386_multiboot_TRUE@am__append_340 = usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_341 =
+@COND_i386_multiboot_TRUE@am__append_342 = $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_343 = $(nodist_usbserial_usbdebug_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ usbserial_usbdebug.marker
+@COND_i386_multiboot_TRUE@am__append_344 = usbserial_usbdebug.mod
+@COND_i386_multiboot_TRUE@am__append_345 = usbserial_usbdebug.marker
+@COND_i386_ieee1275_TRUE@am__append_346 = usbserial_usbdebug.module
+@COND_i386_ieee1275_TRUE@am__append_347 = usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_348 =
+@COND_i386_ieee1275_TRUE@am__append_349 = $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_350 = $(nodist_usbserial_usbdebug_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ usbserial_usbdebug.marker
+@COND_i386_ieee1275_TRUE@am__append_351 = usbserial_usbdebug.mod
+@COND_i386_ieee1275_TRUE@am__append_352 = usbserial_usbdebug.marker
+@COND_x86_64_efi_TRUE@am__append_353 = usbserial_usbdebug.module
+@COND_x86_64_efi_TRUE@am__append_354 = usbserial_usbdebug.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_355 =
+@COND_x86_64_efi_TRUE@am__append_356 = $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_357 = $(nodist_usbserial_usbdebug_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ usbserial_usbdebug.marker
+@COND_x86_64_efi_TRUE@am__append_358 = usbserial_usbdebug.mod
+@COND_x86_64_efi_TRUE@am__append_359 = usbserial_usbdebug.marker
+@COND_mips_loongson_TRUE@am__append_360 = usbserial_usbdebug.module
+@COND_mips_loongson_TRUE@am__append_361 = usbserial_usbdebug.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_362 =
+@COND_mips_loongson_TRUE@am__append_363 = $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_364 = $(nodist_usbserial_usbdebug_module_SOURCES) \
+@COND_mips_loongson_TRUE@ usbserial_usbdebug.marker
+@COND_mips_loongson_TRUE@am__append_365 = usbserial_usbdebug.mod
+@COND_mips_loongson_TRUE@am__append_366 = usbserial_usbdebug.marker
+@COND_arm_coreboot_TRUE@am__append_367 = usbserial_usbdebug.module
+@COND_arm_coreboot_TRUE@am__append_368 = usbserial_usbdebug.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_369 =
+@COND_arm_coreboot_TRUE@am__append_370 = $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_371 = $(nodist_usbserial_usbdebug_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ usbserial_usbdebug.marker
+@COND_arm_coreboot_TRUE@am__append_372 = usbserial_usbdebug.mod
+@COND_arm_coreboot_TRUE@am__append_373 = usbserial_usbdebug.marker
+@COND_i386_pc_TRUE@am__append_374 = uhci.module
+@COND_i386_pc_TRUE@am__append_375 = uhci.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@uhci_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_376 =
+@COND_i386_pc_TRUE@am__append_377 = $(nodist_uhci_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_378 = $(nodist_uhci_module_SOURCES) \
+@COND_i386_pc_TRUE@ uhci.marker
+@COND_i386_pc_TRUE@am__append_379 = uhci.mod
+@COND_i386_pc_TRUE@am__append_380 = uhci.marker
+@COND_i386_efi_TRUE@am__append_381 = uhci.module
+@COND_i386_efi_TRUE@am__append_382 = uhci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_383 =
+@COND_i386_efi_TRUE@am__append_384 = $(nodist_uhci_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_385 = $(nodist_uhci_module_SOURCES) \
+@COND_i386_efi_TRUE@ uhci.marker
+@COND_i386_efi_TRUE@am__append_386 = uhci.mod
+@COND_i386_efi_TRUE@am__append_387 = uhci.marker
+@COND_i386_qemu_TRUE@am__append_388 = uhci.module
+@COND_i386_qemu_TRUE@am__append_389 = uhci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_390 =
+@COND_i386_qemu_TRUE@am__append_391 = $(nodist_uhci_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_392 = $(nodist_uhci_module_SOURCES) \
+@COND_i386_qemu_TRUE@ uhci.marker
+@COND_i386_qemu_TRUE@am__append_393 = uhci.mod
+@COND_i386_qemu_TRUE@am__append_394 = uhci.marker
+@COND_i386_coreboot_TRUE@am__append_395 = uhci.module
+@COND_i386_coreboot_TRUE@am__append_396 = uhci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_397 =
+@COND_i386_coreboot_TRUE@am__append_398 = $(nodist_uhci_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_399 = \
+@COND_i386_coreboot_TRUE@ $(nodist_uhci_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ uhci.marker
+@COND_i386_coreboot_TRUE@am__append_400 = uhci.mod
+@COND_i386_coreboot_TRUE@am__append_401 = uhci.marker
+@COND_i386_multiboot_TRUE@am__append_402 = uhci.module
+@COND_i386_multiboot_TRUE@am__append_403 = uhci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_404 =
+@COND_i386_multiboot_TRUE@am__append_405 = $(nodist_uhci_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_406 = \
+@COND_i386_multiboot_TRUE@ $(nodist_uhci_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ uhci.marker
+@COND_i386_multiboot_TRUE@am__append_407 = uhci.mod
+@COND_i386_multiboot_TRUE@am__append_408 = uhci.marker
+@COND_i386_ieee1275_TRUE@am__append_409 = uhci.module
+@COND_i386_ieee1275_TRUE@am__append_410 = uhci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_411 =
+@COND_i386_ieee1275_TRUE@am__append_412 = $(nodist_uhci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_413 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_uhci_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ uhci.marker
+@COND_i386_ieee1275_TRUE@am__append_414 = uhci.mod
+@COND_i386_ieee1275_TRUE@am__append_415 = uhci.marker
+@COND_x86_64_efi_TRUE@am__append_416 = uhci.module
+@COND_x86_64_efi_TRUE@am__append_417 = uhci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_418 =
+@COND_x86_64_efi_TRUE@am__append_419 = $(nodist_uhci_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_420 = $(nodist_uhci_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ uhci.marker
+@COND_x86_64_efi_TRUE@am__append_421 = uhci.mod
+@COND_x86_64_efi_TRUE@am__append_422 = uhci.marker
+@COND_mips_loongson_TRUE@am__append_423 = uhci.module
+@COND_mips_loongson_TRUE@am__append_424 = uhci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_425 =
+@COND_mips_loongson_TRUE@am__append_426 = $(nodist_uhci_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_427 = \
+@COND_mips_loongson_TRUE@ $(nodist_uhci_module_SOURCES) \
+@COND_mips_loongson_TRUE@ uhci.marker
+@COND_mips_loongson_TRUE@am__append_428 = uhci.mod
+@COND_mips_loongson_TRUE@am__append_429 = uhci.marker
+@COND_i386_pc_TRUE@am__append_430 = ohci.module
+@COND_i386_pc_TRUE@am__append_431 = ohci.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@ohci_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_432 =
+@COND_i386_pc_TRUE@am__append_433 = $(nodist_ohci_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_434 = $(nodist_ohci_module_SOURCES) \
+@COND_i386_pc_TRUE@ ohci.marker
+@COND_i386_pc_TRUE@am__append_435 = ohci.mod
+@COND_i386_pc_TRUE@am__append_436 = ohci.marker
+@COND_i386_efi_TRUE@am__append_437 = ohci.module
+@COND_i386_efi_TRUE@am__append_438 = ohci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_439 =
+@COND_i386_efi_TRUE@am__append_440 = $(nodist_ohci_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_441 = $(nodist_ohci_module_SOURCES) \
+@COND_i386_efi_TRUE@ ohci.marker
+@COND_i386_efi_TRUE@am__append_442 = ohci.mod
+@COND_i386_efi_TRUE@am__append_443 = ohci.marker
+@COND_i386_qemu_TRUE@am__append_444 = ohci.module
+@COND_i386_qemu_TRUE@am__append_445 = ohci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_446 =
+@COND_i386_qemu_TRUE@am__append_447 = $(nodist_ohci_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_448 = $(nodist_ohci_module_SOURCES) \
+@COND_i386_qemu_TRUE@ ohci.marker
+@COND_i386_qemu_TRUE@am__append_449 = ohci.mod
+@COND_i386_qemu_TRUE@am__append_450 = ohci.marker
+@COND_i386_coreboot_TRUE@am__append_451 = ohci.module
+@COND_i386_coreboot_TRUE@am__append_452 = ohci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_453 =
+@COND_i386_coreboot_TRUE@am__append_454 = $(nodist_ohci_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_455 = \
+@COND_i386_coreboot_TRUE@ $(nodist_ohci_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ ohci.marker
+@COND_i386_coreboot_TRUE@am__append_456 = ohci.mod
+@COND_i386_coreboot_TRUE@am__append_457 = ohci.marker
+@COND_i386_multiboot_TRUE@am__append_458 = ohci.module
+@COND_i386_multiboot_TRUE@am__append_459 = ohci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_460 =
+@COND_i386_multiboot_TRUE@am__append_461 = $(nodist_ohci_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_462 = \
+@COND_i386_multiboot_TRUE@ $(nodist_ohci_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ ohci.marker
+@COND_i386_multiboot_TRUE@am__append_463 = ohci.mod
+@COND_i386_multiboot_TRUE@am__append_464 = ohci.marker
+@COND_i386_ieee1275_TRUE@am__append_465 = ohci.module
+@COND_i386_ieee1275_TRUE@am__append_466 = ohci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_467 =
+@COND_i386_ieee1275_TRUE@am__append_468 = $(nodist_ohci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_469 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_ohci_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ ohci.marker
+@COND_i386_ieee1275_TRUE@am__append_470 = ohci.mod
+@COND_i386_ieee1275_TRUE@am__append_471 = ohci.marker
+@COND_x86_64_efi_TRUE@am__append_472 = ohci.module
+@COND_x86_64_efi_TRUE@am__append_473 = ohci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_474 =
+@COND_x86_64_efi_TRUE@am__append_475 = $(nodist_ohci_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_476 = $(nodist_ohci_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ ohci.marker
+@COND_x86_64_efi_TRUE@am__append_477 = ohci.mod
+@COND_x86_64_efi_TRUE@am__append_478 = ohci.marker
+@COND_mips_loongson_TRUE@am__append_479 = ohci.module
+@COND_mips_loongson_TRUE@am__append_480 = ohci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_481 =
+@COND_mips_loongson_TRUE@am__append_482 = $(nodist_ohci_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_483 = \
+@COND_mips_loongson_TRUE@ $(nodist_ohci_module_SOURCES) \
+@COND_mips_loongson_TRUE@ ohci.marker
+@COND_mips_loongson_TRUE@am__append_484 = ohci.mod
+@COND_mips_loongson_TRUE@am__append_485 = ohci.marker
+@COND_i386_pc_TRUE@am__append_486 = ehci.module
+@COND_i386_pc_TRUE@am__append_487 = ehci.module$(EXEEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@ehci_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_488 =
+@COND_i386_pc_TRUE@am__append_489 = $(nodist_ehci_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_490 = $(nodist_ehci_module_SOURCES) \
+@COND_i386_pc_TRUE@ ehci.marker
+@COND_i386_pc_TRUE@am__append_491 = ehci.mod
+@COND_i386_pc_TRUE@am__append_492 = ehci.marker
+@COND_i386_efi_TRUE@am__append_493 = ehci.module
+@COND_i386_efi_TRUE@am__append_494 = ehci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_495 =
+@COND_i386_efi_TRUE@am__append_496 = $(nodist_ehci_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_497 = $(nodist_ehci_module_SOURCES) \
+@COND_i386_efi_TRUE@ ehci.marker
+@COND_i386_efi_TRUE@am__append_498 = ehci.mod
+@COND_i386_efi_TRUE@am__append_499 = ehci.marker
+@COND_i386_qemu_TRUE@am__append_500 = ehci.module
+@COND_i386_qemu_TRUE@am__append_501 = ehci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_502 =
+@COND_i386_qemu_TRUE@am__append_503 = $(nodist_ehci_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_504 = $(nodist_ehci_module_SOURCES) \
+@COND_i386_qemu_TRUE@ ehci.marker
+@COND_i386_qemu_TRUE@am__append_505 = ehci.mod
+@COND_i386_qemu_TRUE@am__append_506 = ehci.marker
+@COND_i386_coreboot_TRUE@am__append_507 = ehci.module
+@COND_i386_coreboot_TRUE@am__append_508 = ehci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_509 =
+@COND_i386_coreboot_TRUE@am__append_510 = $(nodist_ehci_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_511 = \
+@COND_i386_coreboot_TRUE@ $(nodist_ehci_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ ehci.marker
+@COND_i386_coreboot_TRUE@am__append_512 = ehci.mod
+@COND_i386_coreboot_TRUE@am__append_513 = ehci.marker
+@COND_i386_multiboot_TRUE@am__append_514 = ehci.module
+@COND_i386_multiboot_TRUE@am__append_515 = ehci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_516 =
+@COND_i386_multiboot_TRUE@am__append_517 = $(nodist_ehci_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_518 = \
+@COND_i386_multiboot_TRUE@ $(nodist_ehci_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ ehci.marker
+@COND_i386_multiboot_TRUE@am__append_519 = ehci.mod
+@COND_i386_multiboot_TRUE@am__append_520 = ehci.marker
+@COND_i386_ieee1275_TRUE@am__append_521 = ehci.module
+@COND_i386_ieee1275_TRUE@am__append_522 = ehci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_523 =
+@COND_i386_ieee1275_TRUE@am__append_524 = $(nodist_ehci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_525 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_ehci_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ ehci.marker
+@COND_i386_ieee1275_TRUE@am__append_526 = ehci.mod
+@COND_i386_ieee1275_TRUE@am__append_527 = ehci.marker
+@COND_x86_64_efi_TRUE@am__append_528 = ehci.module
+@COND_x86_64_efi_TRUE@am__append_529 = ehci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_530 =
+@COND_x86_64_efi_TRUE@am__append_531 = $(nodist_ehci_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_532 = $(nodist_ehci_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ ehci.marker
+@COND_x86_64_efi_TRUE@am__append_533 = ehci.mod
+@COND_x86_64_efi_TRUE@am__append_534 = ehci.marker
+@COND_mips_loongson_TRUE@am__append_535 = ehci.module
+@COND_mips_loongson_TRUE@am__append_536 = ehci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_537 =
+@COND_mips_loongson_TRUE@am__append_538 = $(nodist_ehci_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_539 = \
+@COND_mips_loongson_TRUE@ $(nodist_ehci_module_SOURCES) \
+@COND_mips_loongson_TRUE@ ehci.marker
+@COND_mips_loongson_TRUE@am__append_540 = ehci.mod
+@COND_mips_loongson_TRUE@am__append_541 = ehci.marker
+@COND_arm_coreboot_TRUE@am__append_542 = ehci.module
+@COND_arm_coreboot_TRUE@am__append_543 = ehci.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_544 =
+@COND_arm_coreboot_TRUE@am__append_545 = $(nodist_ehci_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_546 = \
+@COND_arm_coreboot_TRUE@ $(nodist_ehci_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ ehci.marker
+@COND_arm_coreboot_TRUE@am__append_547 = ehci.mod
+@COND_arm_coreboot_TRUE@am__append_548 = ehci.marker
+@COND_i386_pc_TRUE@am__append_549 = pci.module
+@COND_i386_pc_TRUE@am__append_550 = pci.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@pci_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_551 =
+@COND_i386_pc_TRUE@am__append_552 = $(nodist_pci_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_553 = $(nodist_pci_module_SOURCES) \
+@COND_i386_pc_TRUE@ pci.marker
+@COND_i386_pc_TRUE@am__append_554 = pci.mod
+@COND_i386_pc_TRUE@am__append_555 = pci.marker
+@COND_i386_coreboot_TRUE@am__append_556 = pci.module
+@COND_i386_coreboot_TRUE@am__append_557 = pci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_558 =
+@COND_i386_coreboot_TRUE@am__append_559 = $(nodist_pci_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_560 = \
+@COND_i386_coreboot_TRUE@ $(nodist_pci_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ pci.marker
+@COND_i386_coreboot_TRUE@am__append_561 = pci.mod
+@COND_i386_coreboot_TRUE@am__append_562 = pci.marker
+@COND_i386_multiboot_TRUE@am__append_563 = pci.module
+@COND_i386_multiboot_TRUE@am__append_564 = pci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_565 =
+@COND_i386_multiboot_TRUE@am__append_566 = $(nodist_pci_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_567 = \
+@COND_i386_multiboot_TRUE@ $(nodist_pci_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ pci.marker
+@COND_i386_multiboot_TRUE@am__append_568 = pci.mod
+@COND_i386_multiboot_TRUE@am__append_569 = pci.marker
+@COND_i386_ieee1275_TRUE@am__append_570 = pci.module
+@COND_i386_ieee1275_TRUE@am__append_571 = pci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_572 =
+@COND_i386_ieee1275_TRUE@am__append_573 = $(nodist_pci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_574 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_pci_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ pci.marker
+@COND_i386_ieee1275_TRUE@am__append_575 = pci.mod
+@COND_i386_ieee1275_TRUE@am__append_576 = pci.marker
+@COND_i386_pc_TRUE@am__append_577 = nativedisk.module
+@COND_i386_pc_TRUE@am__append_578 = nativedisk.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_FALSE@nativedisk_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_579 =
+@COND_i386_pc_TRUE@am__append_580 = $(nodist_nativedisk_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_581 = \
+@COND_i386_pc_TRUE@ $(nodist_nativedisk_module_SOURCES) \
+@COND_i386_pc_TRUE@ nativedisk.marker
+@COND_i386_pc_TRUE@am__append_582 = nativedisk.mod
+@COND_i386_pc_TRUE@am__append_583 = nativedisk.marker
+@COND_i386_efi_TRUE@am__append_584 = nativedisk.module
+@COND_i386_efi_TRUE@am__append_585 = nativedisk.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_586 =
+@COND_i386_efi_TRUE@am__append_587 = $(nodist_nativedisk_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_588 = \
+@COND_i386_efi_TRUE@ $(nodist_nativedisk_module_SOURCES) \
+@COND_i386_efi_TRUE@ nativedisk.marker
+@COND_i386_efi_TRUE@am__append_589 = nativedisk.mod
+@COND_i386_efi_TRUE@am__append_590 = nativedisk.marker
+@COND_i386_qemu_TRUE@am__append_591 = nativedisk.module
+@COND_i386_qemu_TRUE@am__append_592 = nativedisk.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_593 =
+@COND_i386_qemu_TRUE@am__append_594 = $(nodist_nativedisk_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_595 = \
+@COND_i386_qemu_TRUE@ $(nodist_nativedisk_module_SOURCES) \
+@COND_i386_qemu_TRUE@ nativedisk.marker
+@COND_i386_qemu_TRUE@am__append_596 = nativedisk.mod
+@COND_i386_qemu_TRUE@am__append_597 = nativedisk.marker
+@COND_i386_coreboot_TRUE@am__append_598 = nativedisk.module
+@COND_i386_coreboot_TRUE@am__append_599 = nativedisk.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_600 =
+@COND_i386_coreboot_TRUE@am__append_601 = $(nodist_nativedisk_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_602 = \
+@COND_i386_coreboot_TRUE@ $(nodist_nativedisk_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ nativedisk.marker
+@COND_i386_coreboot_TRUE@am__append_603 = nativedisk.mod
+@COND_i386_coreboot_TRUE@am__append_604 = nativedisk.marker
+@COND_i386_multiboot_TRUE@am__append_605 = nativedisk.module
+@COND_i386_multiboot_TRUE@am__append_606 = nativedisk.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_607 =
+@COND_i386_multiboot_TRUE@am__append_608 = $(nodist_nativedisk_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_609 = \
+@COND_i386_multiboot_TRUE@ $(nodist_nativedisk_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ nativedisk.marker
+@COND_i386_multiboot_TRUE@am__append_610 = nativedisk.mod
+@COND_i386_multiboot_TRUE@am__append_611 = nativedisk.marker
+@COND_i386_ieee1275_TRUE@am__append_612 = nativedisk.module
+@COND_i386_ieee1275_TRUE@am__append_613 = nativedisk.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_614 =
+@COND_i386_ieee1275_TRUE@am__append_615 = $(nodist_nativedisk_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_616 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_nativedisk_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ nativedisk.marker
+@COND_i386_ieee1275_TRUE@am__append_617 = nativedisk.mod
+@COND_i386_ieee1275_TRUE@am__append_618 = nativedisk.marker
+@COND_x86_64_efi_TRUE@am__append_619 = nativedisk.module
+@COND_x86_64_efi_TRUE@am__append_620 = nativedisk.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_621 =
+@COND_x86_64_efi_TRUE@am__append_622 = $(nodist_nativedisk_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_623 = \
+@COND_x86_64_efi_TRUE@ $(nodist_nativedisk_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ nativedisk.marker
+@COND_x86_64_efi_TRUE@am__append_624 = nativedisk.mod
+@COND_x86_64_efi_TRUE@am__append_625 = nativedisk.marker
+@COND_mips_loongson_TRUE@am__append_626 = nativedisk.module
+@COND_mips_loongson_TRUE@am__append_627 = nativedisk.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_628 =
+@COND_mips_loongson_TRUE@am__append_629 = $(nodist_nativedisk_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_630 = \
+@COND_mips_loongson_TRUE@ $(nodist_nativedisk_module_SOURCES) \
+@COND_mips_loongson_TRUE@ nativedisk.marker
+@COND_mips_loongson_TRUE@am__append_631 = nativedisk.mod
+@COND_mips_loongson_TRUE@am__append_632 = nativedisk.marker
+@COND_mips_qemu_mips_TRUE@am__append_633 = nativedisk.module
+@COND_mips_qemu_mips_TRUE@am__append_634 = nativedisk.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_635 =
+@COND_mips_qemu_mips_TRUE@am__append_636 = $(nodist_nativedisk_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_637 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_nativedisk_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ nativedisk.marker
+@COND_mips_qemu_mips_TRUE@am__append_638 = nativedisk.mod
+@COND_mips_qemu_mips_TRUE@am__append_639 = nativedisk.marker
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@am__append_640 = emupci.module
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@am__append_641 = emupci.module$(EXEEXT)
+@COND_GRUB_EMU_PCI_FALSE@emupci_module_DEPENDENCIES =
+@COND_emu_FALSE@emupci_module_DEPENDENCIES =
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@am__append_642 =
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@am__append_643 = $(nodist_emupci_module_SOURCES)
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@am__append_644 = $(nodist_emupci_module_SOURCES) \
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@ emupci.marker
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@am__append_645 = emupci.mod
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@am__append_646 = emupci.marker
+@COND_mips_arc_TRUE@am__append_647 = lsdev.module
+@COND_mips_arc_TRUE@am__append_648 = lsdev.module$(EXEEXT)
+@COND_mips_arc_FALSE@lsdev_module_DEPENDENCIES =
+@COND_mips_arc_TRUE@am__append_649 =
+@COND_mips_arc_TRUE@am__append_650 = $(nodist_lsdev_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_651 = $(nodist_lsdev_module_SOURCES) \
+@COND_mips_arc_TRUE@ lsdev.marker
+@COND_mips_arc_TRUE@am__append_652 = lsdev.mod
+@COND_mips_arc_TRUE@am__append_653 = lsdev.marker
+@COND_i386_xen_TRUE@am__append_654 = lsxen.module
+@COND_i386_xen_TRUE@am__append_655 = lsxen.module$(EXEEXT)
+@COND_i386_xen_FALSE@@COND_x86_64_xen_FALSE@lsxen_module_DEPENDENCIES =
+@COND_i386_xen_TRUE@am__append_656 =
+@COND_i386_xen_TRUE@am__append_657 = $(nodist_lsxen_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_658 = $(nodist_lsxen_module_SOURCES) \
+@COND_i386_xen_TRUE@ lsxen.marker
+@COND_i386_xen_TRUE@am__append_659 = lsxen.mod
+@COND_i386_xen_TRUE@am__append_660 = lsxen.marker
+@COND_x86_64_xen_TRUE@am__append_661 = lsxen.module
+@COND_x86_64_xen_TRUE@am__append_662 = lsxen.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_663 =
+@COND_x86_64_xen_TRUE@am__append_664 = $(nodist_lsxen_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_665 = $(nodist_lsxen_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ lsxen.marker
+@COND_x86_64_xen_TRUE@am__append_666 = lsxen.mod
+@COND_x86_64_xen_TRUE@am__append_667 = lsxen.marker
+@COND_i386_pc_TRUE@am__append_668 = cmostest.module
+@COND_i386_pc_TRUE@am__append_669 = cmostest.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_sparc64_ieee1275_FALSE@cmostest_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_670 =
+@COND_i386_pc_TRUE@am__append_671 = $(nodist_cmostest_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_672 = $(nodist_cmostest_module_SOURCES) \
+@COND_i386_pc_TRUE@ cmostest.marker
+@COND_i386_pc_TRUE@am__append_673 = cmostest.mod
+@COND_i386_pc_TRUE@am__append_674 = cmostest.marker
+@COND_i386_qemu_TRUE@am__append_675 = cmostest.module
+@COND_i386_qemu_TRUE@am__append_676 = cmostest.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_677 =
+@COND_i386_qemu_TRUE@am__append_678 = $(nodist_cmostest_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_679 = \
+@COND_i386_qemu_TRUE@ $(nodist_cmostest_module_SOURCES) \
+@COND_i386_qemu_TRUE@ cmostest.marker
+@COND_i386_qemu_TRUE@am__append_680 = cmostest.mod
+@COND_i386_qemu_TRUE@am__append_681 = cmostest.marker
+@COND_i386_coreboot_TRUE@am__append_682 = cmostest.module
+@COND_i386_coreboot_TRUE@am__append_683 = cmostest.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_684 =
+@COND_i386_coreboot_TRUE@am__append_685 = $(nodist_cmostest_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_686 = \
+@COND_i386_coreboot_TRUE@ $(nodist_cmostest_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ cmostest.marker
+@COND_i386_coreboot_TRUE@am__append_687 = cmostest.mod
+@COND_i386_coreboot_TRUE@am__append_688 = cmostest.marker
+@COND_i386_multiboot_TRUE@am__append_689 = cmostest.module
+@COND_i386_multiboot_TRUE@am__append_690 = cmostest.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_691 =
+@COND_i386_multiboot_TRUE@am__append_692 = $(nodist_cmostest_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_693 = \
+@COND_i386_multiboot_TRUE@ $(nodist_cmostest_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ cmostest.marker
+@COND_i386_multiboot_TRUE@am__append_694 = cmostest.mod
+@COND_i386_multiboot_TRUE@am__append_695 = cmostest.marker
+@COND_i386_ieee1275_TRUE@am__append_696 = cmostest.module
+@COND_i386_ieee1275_TRUE@am__append_697 = cmostest.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_698 =
+@COND_i386_ieee1275_TRUE@am__append_699 = $(nodist_cmostest_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_700 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_cmostest_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ cmostest.marker
+@COND_i386_ieee1275_TRUE@am__append_701 = cmostest.mod
+@COND_i386_ieee1275_TRUE@am__append_702 = cmostest.marker
+@COND_mips_loongson_TRUE@am__append_703 = cmostest.module
+@COND_mips_loongson_TRUE@am__append_704 = cmostest.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_705 =
+@COND_mips_loongson_TRUE@am__append_706 = $(nodist_cmostest_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_707 = \
+@COND_mips_loongson_TRUE@ $(nodist_cmostest_module_SOURCES) \
+@COND_mips_loongson_TRUE@ cmostest.marker
+@COND_mips_loongson_TRUE@am__append_708 = cmostest.mod
+@COND_mips_loongson_TRUE@am__append_709 = cmostest.marker
+@COND_sparc64_ieee1275_TRUE@am__append_710 = cmostest.module
+@COND_sparc64_ieee1275_TRUE@am__append_711 = cmostest.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_712 =
+@COND_sparc64_ieee1275_TRUE@am__append_713 = $(nodist_cmostest_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_714 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_cmostest_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ cmostest.marker
+@COND_sparc64_ieee1275_TRUE@am__append_715 = cmostest.mod
+@COND_sparc64_ieee1275_TRUE@am__append_716 = cmostest.marker
+@COND_powerpc_ieee1275_TRUE@am__append_717 = cmostest.module
+@COND_powerpc_ieee1275_TRUE@am__append_718 = cmostest.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_719 =
+@COND_powerpc_ieee1275_TRUE@am__append_720 = $(nodist_cmostest_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_721 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_cmostest_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ cmostest.marker
+@COND_powerpc_ieee1275_TRUE@am__append_722 = cmostest.mod
+@COND_powerpc_ieee1275_TRUE@am__append_723 = cmostest.marker
+@COND_mips_qemu_mips_TRUE@am__append_724 = cmostest.module
+@COND_mips_qemu_mips_TRUE@am__append_725 = cmostest.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_726 =
+@COND_mips_qemu_mips_TRUE@am__append_727 = $(nodist_cmostest_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_728 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_cmostest_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ cmostest.marker
+@COND_mips_qemu_mips_TRUE@am__append_729 = cmostest.mod
+@COND_mips_qemu_mips_TRUE@am__append_730 = cmostest.marker
+@COND_i386_pc_TRUE@am__append_731 = cmosdump.module
+@COND_i386_pc_TRUE@am__append_732 = cmosdump.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_sparc64_ieee1275_FALSE@cmosdump_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_733 =
+@COND_i386_pc_TRUE@am__append_734 = $(nodist_cmosdump_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_735 = $(nodist_cmosdump_module_SOURCES) \
+@COND_i386_pc_TRUE@ cmosdump.marker
+@COND_i386_pc_TRUE@am__append_736 = cmosdump.mod
+@COND_i386_pc_TRUE@am__append_737 = cmosdump.marker
+@COND_i386_qemu_TRUE@am__append_738 = cmosdump.module
+@COND_i386_qemu_TRUE@am__append_739 = cmosdump.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_740 =
+@COND_i386_qemu_TRUE@am__append_741 = $(nodist_cmosdump_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_742 = \
+@COND_i386_qemu_TRUE@ $(nodist_cmosdump_module_SOURCES) \
+@COND_i386_qemu_TRUE@ cmosdump.marker
+@COND_i386_qemu_TRUE@am__append_743 = cmosdump.mod
+@COND_i386_qemu_TRUE@am__append_744 = cmosdump.marker
+@COND_i386_coreboot_TRUE@am__append_745 = cmosdump.module
+@COND_i386_coreboot_TRUE@am__append_746 = cmosdump.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_747 =
+@COND_i386_coreboot_TRUE@am__append_748 = $(nodist_cmosdump_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_749 = \
+@COND_i386_coreboot_TRUE@ $(nodist_cmosdump_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ cmosdump.marker
+@COND_i386_coreboot_TRUE@am__append_750 = cmosdump.mod
+@COND_i386_coreboot_TRUE@am__append_751 = cmosdump.marker
+@COND_i386_multiboot_TRUE@am__append_752 = cmosdump.module
+@COND_i386_multiboot_TRUE@am__append_753 = cmosdump.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_754 =
+@COND_i386_multiboot_TRUE@am__append_755 = $(nodist_cmosdump_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_756 = \
+@COND_i386_multiboot_TRUE@ $(nodist_cmosdump_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ cmosdump.marker
+@COND_i386_multiboot_TRUE@am__append_757 = cmosdump.mod
+@COND_i386_multiboot_TRUE@am__append_758 = cmosdump.marker
+@COND_i386_ieee1275_TRUE@am__append_759 = cmosdump.module
+@COND_i386_ieee1275_TRUE@am__append_760 = cmosdump.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_761 =
+@COND_i386_ieee1275_TRUE@am__append_762 = $(nodist_cmosdump_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_763 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_cmosdump_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ cmosdump.marker
+@COND_i386_ieee1275_TRUE@am__append_764 = cmosdump.mod
+@COND_i386_ieee1275_TRUE@am__append_765 = cmosdump.marker
+@COND_mips_loongson_TRUE@am__append_766 = cmosdump.module
+@COND_mips_loongson_TRUE@am__append_767 = cmosdump.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_768 =
+@COND_mips_loongson_TRUE@am__append_769 = $(nodist_cmosdump_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_770 = \
+@COND_mips_loongson_TRUE@ $(nodist_cmosdump_module_SOURCES) \
+@COND_mips_loongson_TRUE@ cmosdump.marker
+@COND_mips_loongson_TRUE@am__append_771 = cmosdump.mod
+@COND_mips_loongson_TRUE@am__append_772 = cmosdump.marker
+@COND_sparc64_ieee1275_TRUE@am__append_773 = cmosdump.module
+@COND_sparc64_ieee1275_TRUE@am__append_774 = cmosdump.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_775 =
+@COND_sparc64_ieee1275_TRUE@am__append_776 = $(nodist_cmosdump_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_777 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_cmosdump_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ cmosdump.marker
+@COND_sparc64_ieee1275_TRUE@am__append_778 = cmosdump.mod
+@COND_sparc64_ieee1275_TRUE@am__append_779 = cmosdump.marker
+@COND_powerpc_ieee1275_TRUE@am__append_780 = cmosdump.module
+@COND_powerpc_ieee1275_TRUE@am__append_781 = cmosdump.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_782 =
+@COND_powerpc_ieee1275_TRUE@am__append_783 = $(nodist_cmosdump_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_784 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_cmosdump_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ cmosdump.marker
+@COND_powerpc_ieee1275_TRUE@am__append_785 = cmosdump.mod
+@COND_powerpc_ieee1275_TRUE@am__append_786 = cmosdump.marker
+@COND_mips_qemu_mips_TRUE@am__append_787 = cmosdump.module
+@COND_mips_qemu_mips_TRUE@am__append_788 = cmosdump.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_789 =
+@COND_mips_qemu_mips_TRUE@am__append_790 = $(nodist_cmosdump_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_791 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_cmosdump_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ cmosdump.marker
+@COND_mips_qemu_mips_TRUE@am__append_792 = cmosdump.mod
+@COND_mips_qemu_mips_TRUE@am__append_793 = cmosdump.marker
+@COND_i386_pc_TRUE@am__append_794 = iorw.module
+@COND_i386_pc_TRUE@am__append_795 = iorw.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@iorw_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_796 =
+@COND_i386_pc_TRUE@am__append_797 = $(nodist_iorw_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_798 = $(nodist_iorw_module_SOURCES) \
+@COND_i386_pc_TRUE@ iorw.marker
+@COND_i386_pc_TRUE@am__append_799 = iorw.mod
+@COND_i386_pc_TRUE@am__append_800 = iorw.marker
+@COND_i386_efi_TRUE@am__append_801 = iorw.module
+@COND_i386_efi_TRUE@am__append_802 = iorw.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_803 =
+@COND_i386_efi_TRUE@am__append_804 = $(nodist_iorw_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_805 = $(nodist_iorw_module_SOURCES) \
+@COND_i386_efi_TRUE@ iorw.marker
+@COND_i386_efi_TRUE@am__append_806 = iorw.mod
+@COND_i386_efi_TRUE@am__append_807 = iorw.marker
+@COND_i386_qemu_TRUE@am__append_808 = iorw.module
+@COND_i386_qemu_TRUE@am__append_809 = iorw.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_810 =
+@COND_i386_qemu_TRUE@am__append_811 = $(nodist_iorw_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_812 = $(nodist_iorw_module_SOURCES) \
+@COND_i386_qemu_TRUE@ iorw.marker
+@COND_i386_qemu_TRUE@am__append_813 = iorw.mod
+@COND_i386_qemu_TRUE@am__append_814 = iorw.marker
+@COND_i386_coreboot_TRUE@am__append_815 = iorw.module
+@COND_i386_coreboot_TRUE@am__append_816 = iorw.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_817 =
+@COND_i386_coreboot_TRUE@am__append_818 = $(nodist_iorw_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_819 = \
+@COND_i386_coreboot_TRUE@ $(nodist_iorw_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ iorw.marker
+@COND_i386_coreboot_TRUE@am__append_820 = iorw.mod
+@COND_i386_coreboot_TRUE@am__append_821 = iorw.marker
+@COND_i386_multiboot_TRUE@am__append_822 = iorw.module
+@COND_i386_multiboot_TRUE@am__append_823 = iorw.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_824 =
+@COND_i386_multiboot_TRUE@am__append_825 = $(nodist_iorw_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_826 = \
+@COND_i386_multiboot_TRUE@ $(nodist_iorw_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ iorw.marker
+@COND_i386_multiboot_TRUE@am__append_827 = iorw.mod
+@COND_i386_multiboot_TRUE@am__append_828 = iorw.marker
+@COND_i386_ieee1275_TRUE@am__append_829 = iorw.module
+@COND_i386_ieee1275_TRUE@am__append_830 = iorw.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_831 =
+@COND_i386_ieee1275_TRUE@am__append_832 = $(nodist_iorw_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_833 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_iorw_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ iorw.marker
+@COND_i386_ieee1275_TRUE@am__append_834 = iorw.mod
+@COND_i386_ieee1275_TRUE@am__append_835 = iorw.marker
+@COND_x86_64_efi_TRUE@am__append_836 = iorw.module
+@COND_x86_64_efi_TRUE@am__append_837 = iorw.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_838 =
+@COND_x86_64_efi_TRUE@am__append_839 = $(nodist_iorw_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_840 = $(nodist_iorw_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ iorw.marker
+@COND_x86_64_efi_TRUE@am__append_841 = iorw.mod
+@COND_x86_64_efi_TRUE@am__append_842 = iorw.marker
+@COND_i386_pc_TRUE@am__append_843 = cbtable.module
+@COND_i386_pc_TRUE@am__append_844 = cbtable.module$(EXEEXT)
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@cbtable_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_845 =
+@COND_i386_pc_TRUE@am__append_846 = $(nodist_cbtable_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_847 = $(nodist_cbtable_module_SOURCES) \
+@COND_i386_pc_TRUE@ cbtable.marker
+@COND_i386_pc_TRUE@am__append_848 = cbtable.mod
+@COND_i386_pc_TRUE@am__append_849 = cbtable.marker
+@COND_i386_efi_TRUE@am__append_850 = cbtable.module
+@COND_i386_efi_TRUE@am__append_851 = cbtable.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_852 =
+@COND_i386_efi_TRUE@am__append_853 = $(nodist_cbtable_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_854 = $(nodist_cbtable_module_SOURCES) \
+@COND_i386_efi_TRUE@ cbtable.marker
+@COND_i386_efi_TRUE@am__append_855 = cbtable.mod
+@COND_i386_efi_TRUE@am__append_856 = cbtable.marker
+@COND_i386_qemu_TRUE@am__append_857 = cbtable.module
+@COND_i386_qemu_TRUE@am__append_858 = cbtable.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_859 =
+@COND_i386_qemu_TRUE@am__append_860 = $(nodist_cbtable_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_861 = \
+@COND_i386_qemu_TRUE@ $(nodist_cbtable_module_SOURCES) \
+@COND_i386_qemu_TRUE@ cbtable.marker
+@COND_i386_qemu_TRUE@am__append_862 = cbtable.mod
+@COND_i386_qemu_TRUE@am__append_863 = cbtable.marker
+@COND_i386_multiboot_TRUE@am__append_864 = cbtable.module
+@COND_i386_multiboot_TRUE@am__append_865 = cbtable.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_866 =
+@COND_i386_multiboot_TRUE@am__append_867 = $(nodist_cbtable_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_868 = \
+@COND_i386_multiboot_TRUE@ $(nodist_cbtable_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ cbtable.marker
+@COND_i386_multiboot_TRUE@am__append_869 = cbtable.mod
+@COND_i386_multiboot_TRUE@am__append_870 = cbtable.marker
+@COND_i386_ieee1275_TRUE@am__append_871 = cbtable.module
+@COND_i386_ieee1275_TRUE@am__append_872 = cbtable.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_873 =
+@COND_i386_ieee1275_TRUE@am__append_874 = $(nodist_cbtable_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_875 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_cbtable_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ cbtable.marker
+@COND_i386_ieee1275_TRUE@am__append_876 = cbtable.mod
+@COND_i386_ieee1275_TRUE@am__append_877 = cbtable.marker
+@COND_x86_64_efi_TRUE@am__append_878 = cbtable.module
+@COND_x86_64_efi_TRUE@am__append_879 = cbtable.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_880 =
+@COND_x86_64_efi_TRUE@am__append_881 = $(nodist_cbtable_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_882 = \
+@COND_x86_64_efi_TRUE@ $(nodist_cbtable_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ cbtable.marker
+@COND_x86_64_efi_TRUE@am__append_883 = cbtable.mod
+@COND_x86_64_efi_TRUE@am__append_884 = cbtable.marker
+@COND_i386_pc_TRUE@am__append_885 = cbtime.module
+@COND_i386_pc_TRUE@am__append_886 = cbtime.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@cbtime_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_887 =
+@COND_i386_pc_TRUE@am__append_888 = $(nodist_cbtime_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_889 = $(nodist_cbtime_module_SOURCES) \
+@COND_i386_pc_TRUE@ cbtime.marker
+@COND_i386_pc_TRUE@am__append_890 = cbtime.mod
+@COND_i386_pc_TRUE@am__append_891 = cbtime.marker
+@COND_i386_efi_TRUE@am__append_892 = cbtime.module
+@COND_i386_efi_TRUE@am__append_893 = cbtime.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_894 =
+@COND_i386_efi_TRUE@am__append_895 = $(nodist_cbtime_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_896 = $(nodist_cbtime_module_SOURCES) \
+@COND_i386_efi_TRUE@ cbtime.marker
+@COND_i386_efi_TRUE@am__append_897 = cbtime.mod
+@COND_i386_efi_TRUE@am__append_898 = cbtime.marker
+@COND_i386_qemu_TRUE@am__append_899 = cbtime.module
+@COND_i386_qemu_TRUE@am__append_900 = cbtime.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_901 =
+@COND_i386_qemu_TRUE@am__append_902 = $(nodist_cbtime_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_903 = $(nodist_cbtime_module_SOURCES) \
+@COND_i386_qemu_TRUE@ cbtime.marker
+@COND_i386_qemu_TRUE@am__append_904 = cbtime.mod
+@COND_i386_qemu_TRUE@am__append_905 = cbtime.marker
+@COND_i386_coreboot_TRUE@am__append_906 = cbtime.module
+@COND_i386_coreboot_TRUE@am__append_907 = cbtime.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_908 =
+@COND_i386_coreboot_TRUE@am__append_909 = $(nodist_cbtime_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_910 = \
+@COND_i386_coreboot_TRUE@ $(nodist_cbtime_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ cbtime.marker
+@COND_i386_coreboot_TRUE@am__append_911 = cbtime.mod
+@COND_i386_coreboot_TRUE@am__append_912 = cbtime.marker
+@COND_i386_multiboot_TRUE@am__append_913 = cbtime.module
+@COND_i386_multiboot_TRUE@am__append_914 = cbtime.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_915 =
+@COND_i386_multiboot_TRUE@am__append_916 = $(nodist_cbtime_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_917 = \
+@COND_i386_multiboot_TRUE@ $(nodist_cbtime_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ cbtime.marker
+@COND_i386_multiboot_TRUE@am__append_918 = cbtime.mod
+@COND_i386_multiboot_TRUE@am__append_919 = cbtime.marker
+@COND_i386_ieee1275_TRUE@am__append_920 = cbtime.module
+@COND_i386_ieee1275_TRUE@am__append_921 = cbtime.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_922 =
+@COND_i386_ieee1275_TRUE@am__append_923 = $(nodist_cbtime_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_924 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_cbtime_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ cbtime.marker
+@COND_i386_ieee1275_TRUE@am__append_925 = cbtime.mod
+@COND_i386_ieee1275_TRUE@am__append_926 = cbtime.marker
+@COND_x86_64_efi_TRUE@am__append_927 = cbtime.module
+@COND_x86_64_efi_TRUE@am__append_928 = cbtime.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_929 =
+@COND_x86_64_efi_TRUE@am__append_930 = $(nodist_cbtime_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_931 = \
+@COND_x86_64_efi_TRUE@ $(nodist_cbtime_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ cbtime.marker
+@COND_x86_64_efi_TRUE@am__append_932 = cbtime.mod
+@COND_x86_64_efi_TRUE@am__append_933 = cbtime.marker
+@COND_i386_pc_TRUE@am__append_934 = cbls.module
+@COND_i386_pc_TRUE@am__append_935 = cbls.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@cbls_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_936 =
+@COND_i386_pc_TRUE@am__append_937 = $(nodist_cbls_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_938 = $(nodist_cbls_module_SOURCES) \
+@COND_i386_pc_TRUE@ cbls.marker
+@COND_i386_pc_TRUE@am__append_939 = cbls.mod
+@COND_i386_pc_TRUE@am__append_940 = cbls.marker
+@COND_i386_efi_TRUE@am__append_941 = cbls.module
+@COND_i386_efi_TRUE@am__append_942 = cbls.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_943 =
+@COND_i386_efi_TRUE@am__append_944 = $(nodist_cbls_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_945 = $(nodist_cbls_module_SOURCES) \
+@COND_i386_efi_TRUE@ cbls.marker
+@COND_i386_efi_TRUE@am__append_946 = cbls.mod
+@COND_i386_efi_TRUE@am__append_947 = cbls.marker
+@COND_i386_qemu_TRUE@am__append_948 = cbls.module
+@COND_i386_qemu_TRUE@am__append_949 = cbls.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_950 =
+@COND_i386_qemu_TRUE@am__append_951 = $(nodist_cbls_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_952 = $(nodist_cbls_module_SOURCES) \
+@COND_i386_qemu_TRUE@ cbls.marker
+@COND_i386_qemu_TRUE@am__append_953 = cbls.mod
+@COND_i386_qemu_TRUE@am__append_954 = cbls.marker
+@COND_i386_coreboot_TRUE@am__append_955 = cbls.module
+@COND_i386_coreboot_TRUE@am__append_956 = cbls.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_957 =
+@COND_i386_coreboot_TRUE@am__append_958 = $(nodist_cbls_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_959 = \
+@COND_i386_coreboot_TRUE@ $(nodist_cbls_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ cbls.marker
+@COND_i386_coreboot_TRUE@am__append_960 = cbls.mod
+@COND_i386_coreboot_TRUE@am__append_961 = cbls.marker
+@COND_i386_multiboot_TRUE@am__append_962 = cbls.module
+@COND_i386_multiboot_TRUE@am__append_963 = cbls.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_964 =
+@COND_i386_multiboot_TRUE@am__append_965 = $(nodist_cbls_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_966 = \
+@COND_i386_multiboot_TRUE@ $(nodist_cbls_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ cbls.marker
+@COND_i386_multiboot_TRUE@am__append_967 = cbls.mod
+@COND_i386_multiboot_TRUE@am__append_968 = cbls.marker
+@COND_i386_ieee1275_TRUE@am__append_969 = cbls.module
+@COND_i386_ieee1275_TRUE@am__append_970 = cbls.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_971 =
+@COND_i386_ieee1275_TRUE@am__append_972 = $(nodist_cbls_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_973 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_cbls_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ cbls.marker
+@COND_i386_ieee1275_TRUE@am__append_974 = cbls.mod
+@COND_i386_ieee1275_TRUE@am__append_975 = cbls.marker
+@COND_x86_64_efi_TRUE@am__append_976 = cbls.module
+@COND_x86_64_efi_TRUE@am__append_977 = cbls.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_978 =
+@COND_x86_64_efi_TRUE@am__append_979 = $(nodist_cbls_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_980 = $(nodist_cbls_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ cbls.marker
+@COND_x86_64_efi_TRUE@am__append_981 = cbls.mod
+@COND_x86_64_efi_TRUE@am__append_982 = cbls.marker
+@COND_i386_pc_TRUE@am__append_983 = cbmemc.module
+@COND_i386_pc_TRUE@am__append_984 = cbmemc.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@cbmemc_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_985 =
+@COND_i386_pc_TRUE@am__append_986 = $(nodist_cbmemc_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_987 = $(nodist_cbmemc_module_SOURCES) \
+@COND_i386_pc_TRUE@ cbmemc.marker
+@COND_i386_pc_TRUE@am__append_988 = cbmemc.mod
+@COND_i386_pc_TRUE@am__append_989 = cbmemc.marker
+@COND_i386_efi_TRUE@am__append_990 = cbmemc.module
+@COND_i386_efi_TRUE@am__append_991 = cbmemc.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_992 =
+@COND_i386_efi_TRUE@am__append_993 = $(nodist_cbmemc_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_994 = $(nodist_cbmemc_module_SOURCES) \
+@COND_i386_efi_TRUE@ cbmemc.marker
+@COND_i386_efi_TRUE@am__append_995 = cbmemc.mod
+@COND_i386_efi_TRUE@am__append_996 = cbmemc.marker
+@COND_i386_qemu_TRUE@am__append_997 = cbmemc.module
+@COND_i386_qemu_TRUE@am__append_998 = cbmemc.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_999 =
+@COND_i386_qemu_TRUE@am__append_1000 = $(nodist_cbmemc_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_1001 = \
+@COND_i386_qemu_TRUE@ $(nodist_cbmemc_module_SOURCES) \
+@COND_i386_qemu_TRUE@ cbmemc.marker
+@COND_i386_qemu_TRUE@am__append_1002 = cbmemc.mod
+@COND_i386_qemu_TRUE@am__append_1003 = cbmemc.marker
+@COND_i386_coreboot_TRUE@am__append_1004 = cbmemc.module
+@COND_i386_coreboot_TRUE@am__append_1005 = cbmemc.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_1006 =
+@COND_i386_coreboot_TRUE@am__append_1007 = $(nodist_cbmemc_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_1008 = \
+@COND_i386_coreboot_TRUE@ $(nodist_cbmemc_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ cbmemc.marker
+@COND_i386_coreboot_TRUE@am__append_1009 = cbmemc.mod
+@COND_i386_coreboot_TRUE@am__append_1010 = cbmemc.marker
+@COND_i386_multiboot_TRUE@am__append_1011 = cbmemc.module
+@COND_i386_multiboot_TRUE@am__append_1012 = cbmemc.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_1013 =
+@COND_i386_multiboot_TRUE@am__append_1014 = $(nodist_cbmemc_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_1015 = \
+@COND_i386_multiboot_TRUE@ $(nodist_cbmemc_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ cbmemc.marker
+@COND_i386_multiboot_TRUE@am__append_1016 = cbmemc.mod
+@COND_i386_multiboot_TRUE@am__append_1017 = cbmemc.marker
+@COND_i386_ieee1275_TRUE@am__append_1018 = cbmemc.module
+@COND_i386_ieee1275_TRUE@am__append_1019 = cbmemc.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_1020 =
+@COND_i386_ieee1275_TRUE@am__append_1021 = $(nodist_cbmemc_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_1022 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_cbmemc_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ cbmemc.marker
+@COND_i386_ieee1275_TRUE@am__append_1023 = cbmemc.mod
+@COND_i386_ieee1275_TRUE@am__append_1024 = cbmemc.marker
+@COND_x86_64_efi_TRUE@am__append_1025 = cbmemc.module
+@COND_x86_64_efi_TRUE@am__append_1026 = cbmemc.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1027 =
+@COND_x86_64_efi_TRUE@am__append_1028 = $(nodist_cbmemc_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1029 = \
+@COND_x86_64_efi_TRUE@ $(nodist_cbmemc_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ cbmemc.marker
+@COND_x86_64_efi_TRUE@am__append_1030 = cbmemc.mod
+@COND_x86_64_efi_TRUE@am__append_1031 = cbmemc.marker
+@COND_i386_pc_TRUE@am__append_1032 = acpi.module
+@COND_i386_pc_TRUE@am__append_1033 = acpi.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@acpi_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_1034 =
+@COND_i386_pc_TRUE@am__append_1035 = $(nodist_acpi_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_1036 = $(nodist_acpi_module_SOURCES) \
+@COND_i386_pc_TRUE@ acpi.marker
+@COND_i386_pc_TRUE@am__append_1037 = acpi.mod
+@COND_i386_pc_TRUE@am__append_1038 = acpi.marker
+@COND_i386_efi_TRUE@am__append_1039 = acpi.module
+@COND_i386_efi_TRUE@am__append_1040 = acpi.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_1041 =
+@COND_i386_efi_TRUE@am__append_1042 = $(nodist_acpi_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1043 = $(nodist_acpi_module_SOURCES) \
+@COND_i386_efi_TRUE@ acpi.marker
+@COND_i386_efi_TRUE@am__append_1044 = acpi.mod
+@COND_i386_efi_TRUE@am__append_1045 = acpi.marker
+@COND_i386_coreboot_TRUE@am__append_1046 = acpi.module
+@COND_i386_coreboot_TRUE@am__append_1047 = acpi.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_1048 =
+@COND_i386_coreboot_TRUE@am__append_1049 = $(nodist_acpi_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_1050 = \
+@COND_i386_coreboot_TRUE@ $(nodist_acpi_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ acpi.marker
+@COND_i386_coreboot_TRUE@am__append_1051 = acpi.mod
+@COND_i386_coreboot_TRUE@am__append_1052 = acpi.marker
+@COND_i386_multiboot_TRUE@am__append_1053 = acpi.module
+@COND_i386_multiboot_TRUE@am__append_1054 = acpi.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_1055 =
+@COND_i386_multiboot_TRUE@am__append_1056 = $(nodist_acpi_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_1057 = \
+@COND_i386_multiboot_TRUE@ $(nodist_acpi_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ acpi.marker
+@COND_i386_multiboot_TRUE@am__append_1058 = acpi.mod
+@COND_i386_multiboot_TRUE@am__append_1059 = acpi.marker
+@COND_x86_64_efi_TRUE@am__append_1060 = acpi.module
+@COND_x86_64_efi_TRUE@am__append_1061 = acpi.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1062 =
+@COND_x86_64_efi_TRUE@am__append_1063 = $(nodist_acpi_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1064 = $(nodist_acpi_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ acpi.marker
+@COND_x86_64_efi_TRUE@am__append_1065 = acpi.mod
+@COND_x86_64_efi_TRUE@am__append_1066 = acpi.marker
+@COND_ia64_efi_TRUE@am__append_1067 = acpi.module
+@COND_ia64_efi_TRUE@am__append_1068 = acpi.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1069 =
+@COND_ia64_efi_TRUE@am__append_1070 = $(nodist_acpi_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1071 = $(nodist_acpi_module_SOURCES) \
+@COND_ia64_efi_TRUE@ acpi.marker
+@COND_ia64_efi_TRUE@am__append_1072 = acpi.mod
+@COND_ia64_efi_TRUE@am__append_1073 = acpi.marker
+@COND_arm_efi_TRUE@am__append_1074 = acpi.module
+@COND_arm_efi_TRUE@am__append_1075 = acpi.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_1076 =
+@COND_arm_efi_TRUE@am__append_1077 = $(nodist_acpi_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_1078 = $(nodist_acpi_module_SOURCES) \
+@COND_arm_efi_TRUE@ acpi.marker
+@COND_arm_efi_TRUE@am__append_1079 = acpi.mod
+@COND_arm_efi_TRUE@am__append_1080 = acpi.marker
+@COND_arm64_efi_TRUE@am__append_1081 = acpi.module
+@COND_arm64_efi_TRUE@am__append_1082 = acpi.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_1083 =
+@COND_arm64_efi_TRUE@am__append_1084 = $(nodist_acpi_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_1085 = $(nodist_acpi_module_SOURCES) \
+@COND_arm64_efi_TRUE@ acpi.marker
+@COND_arm64_efi_TRUE@am__append_1086 = acpi.mod
+@COND_arm64_efi_TRUE@am__append_1087 = acpi.marker
+@COND_riscv32_efi_TRUE@am__append_1088 = acpi.module
+@COND_riscv32_efi_TRUE@am__append_1089 = acpi.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_1090 =
+@COND_riscv32_efi_TRUE@am__append_1091 = $(nodist_acpi_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_1092 = \
+@COND_riscv32_efi_TRUE@ $(nodist_acpi_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ acpi.marker
+@COND_riscv32_efi_TRUE@am__append_1093 = acpi.mod
+@COND_riscv32_efi_TRUE@am__append_1094 = acpi.marker
+@COND_riscv64_efi_TRUE@am__append_1095 = acpi.module
+@COND_riscv64_efi_TRUE@am__append_1096 = acpi.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_1097 =
+@COND_riscv64_efi_TRUE@am__append_1098 = $(nodist_acpi_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_1099 = \
+@COND_riscv64_efi_TRUE@ $(nodist_acpi_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ acpi.marker
+@COND_riscv64_efi_TRUE@am__append_1100 = acpi.mod
+@COND_riscv64_efi_TRUE@am__append_1101 = acpi.marker
+@COND_i386_pc_TRUE@am__append_1102 = lsacpi.module
+@COND_i386_pc_TRUE@am__append_1103 = lsacpi.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@lsacpi_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_1104 =
+@COND_i386_pc_TRUE@am__append_1105 = $(nodist_lsacpi_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_1106 = $(nodist_lsacpi_module_SOURCES) \
+@COND_i386_pc_TRUE@ lsacpi.marker
+@COND_i386_pc_TRUE@am__append_1107 = lsacpi.mod
+@COND_i386_pc_TRUE@am__append_1108 = lsacpi.marker
+@COND_i386_efi_TRUE@am__append_1109 = lsacpi.module
+@COND_i386_efi_TRUE@am__append_1110 = lsacpi.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_1111 =
+@COND_i386_efi_TRUE@am__append_1112 = $(nodist_lsacpi_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1113 = $(nodist_lsacpi_module_SOURCES) \
+@COND_i386_efi_TRUE@ lsacpi.marker
+@COND_i386_efi_TRUE@am__append_1114 = lsacpi.mod
+@COND_i386_efi_TRUE@am__append_1115 = lsacpi.marker
+@COND_i386_coreboot_TRUE@am__append_1116 = lsacpi.module
+@COND_i386_coreboot_TRUE@am__append_1117 = lsacpi.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_1118 =
+@COND_i386_coreboot_TRUE@am__append_1119 = $(nodist_lsacpi_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_1120 = \
+@COND_i386_coreboot_TRUE@ $(nodist_lsacpi_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ lsacpi.marker
+@COND_i386_coreboot_TRUE@am__append_1121 = lsacpi.mod
+@COND_i386_coreboot_TRUE@am__append_1122 = lsacpi.marker
+@COND_i386_multiboot_TRUE@am__append_1123 = lsacpi.module
+@COND_i386_multiboot_TRUE@am__append_1124 = lsacpi.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_1125 =
+@COND_i386_multiboot_TRUE@am__append_1126 = $(nodist_lsacpi_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_1127 = \
+@COND_i386_multiboot_TRUE@ $(nodist_lsacpi_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ lsacpi.marker
+@COND_i386_multiboot_TRUE@am__append_1128 = lsacpi.mod
+@COND_i386_multiboot_TRUE@am__append_1129 = lsacpi.marker
+@COND_x86_64_efi_TRUE@am__append_1130 = lsacpi.module
+@COND_x86_64_efi_TRUE@am__append_1131 = lsacpi.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1132 =
+@COND_x86_64_efi_TRUE@am__append_1133 = $(nodist_lsacpi_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1134 = \
+@COND_x86_64_efi_TRUE@ $(nodist_lsacpi_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ lsacpi.marker
+@COND_x86_64_efi_TRUE@am__append_1135 = lsacpi.mod
+@COND_x86_64_efi_TRUE@am__append_1136 = lsacpi.marker
+@COND_ia64_efi_TRUE@am__append_1137 = lsacpi.module
+@COND_ia64_efi_TRUE@am__append_1138 = lsacpi.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1139 =
+@COND_ia64_efi_TRUE@am__append_1140 = $(nodist_lsacpi_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1141 = $(nodist_lsacpi_module_SOURCES) \
+@COND_ia64_efi_TRUE@ lsacpi.marker
+@COND_ia64_efi_TRUE@am__append_1142 = lsacpi.mod
+@COND_ia64_efi_TRUE@am__append_1143 = lsacpi.marker
+@COND_arm_efi_TRUE@am__append_1144 = lsacpi.module
+@COND_arm_efi_TRUE@am__append_1145 = lsacpi.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_1146 =
+@COND_arm_efi_TRUE@am__append_1147 = $(nodist_lsacpi_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_1148 = $(nodist_lsacpi_module_SOURCES) \
+@COND_arm_efi_TRUE@ lsacpi.marker
+@COND_arm_efi_TRUE@am__append_1149 = lsacpi.mod
+@COND_arm_efi_TRUE@am__append_1150 = lsacpi.marker
+@COND_arm64_efi_TRUE@am__append_1151 = lsacpi.module
+@COND_arm64_efi_TRUE@am__append_1152 = lsacpi.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_1153 =
+@COND_arm64_efi_TRUE@am__append_1154 = $(nodist_lsacpi_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_1155 = \
+@COND_arm64_efi_TRUE@ $(nodist_lsacpi_module_SOURCES) \
+@COND_arm64_efi_TRUE@ lsacpi.marker
+@COND_arm64_efi_TRUE@am__append_1156 = lsacpi.mod
+@COND_arm64_efi_TRUE@am__append_1157 = lsacpi.marker
+@COND_riscv32_efi_TRUE@am__append_1158 = lsacpi.module
+@COND_riscv32_efi_TRUE@am__append_1159 = lsacpi.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_1160 =
+@COND_riscv32_efi_TRUE@am__append_1161 = $(nodist_lsacpi_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_1162 = \
+@COND_riscv32_efi_TRUE@ $(nodist_lsacpi_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ lsacpi.marker
+@COND_riscv32_efi_TRUE@am__append_1163 = lsacpi.mod
+@COND_riscv32_efi_TRUE@am__append_1164 = lsacpi.marker
+@COND_riscv64_efi_TRUE@am__append_1165 = lsacpi.module
+@COND_riscv64_efi_TRUE@am__append_1166 = lsacpi.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_1167 =
+@COND_riscv64_efi_TRUE@am__append_1168 = $(nodist_lsacpi_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_1169 = \
+@COND_riscv64_efi_TRUE@ $(nodist_lsacpi_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ lsacpi.marker
+@COND_riscv64_efi_TRUE@am__append_1170 = lsacpi.mod
+@COND_riscv64_efi_TRUE@am__append_1171 = lsacpi.marker
+@COND_i386_efi_TRUE@am__append_1172 = lsefisystab.module
+@COND_i386_efi_TRUE@am__append_1173 = lsefisystab.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@lsefisystab_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_1174 =
+@COND_i386_efi_TRUE@am__append_1175 = $(nodist_lsefisystab_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1176 = \
+@COND_i386_efi_TRUE@ $(nodist_lsefisystab_module_SOURCES) \
+@COND_i386_efi_TRUE@ lsefisystab.marker
+@COND_i386_efi_TRUE@am__append_1177 = lsefisystab.mod
+@COND_i386_efi_TRUE@am__append_1178 = lsefisystab.marker
+@COND_x86_64_efi_TRUE@am__append_1179 = lsefisystab.module
+@COND_x86_64_efi_TRUE@am__append_1180 = lsefisystab.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1181 =
+@COND_x86_64_efi_TRUE@am__append_1182 = $(nodist_lsefisystab_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1183 = \
+@COND_x86_64_efi_TRUE@ $(nodist_lsefisystab_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ lsefisystab.marker
+@COND_x86_64_efi_TRUE@am__append_1184 = lsefisystab.mod
+@COND_x86_64_efi_TRUE@am__append_1185 = lsefisystab.marker
+@COND_ia64_efi_TRUE@am__append_1186 = lsefisystab.module
+@COND_ia64_efi_TRUE@am__append_1187 = lsefisystab.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1188 =
+@COND_ia64_efi_TRUE@am__append_1189 = $(nodist_lsefisystab_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1190 = \
+@COND_ia64_efi_TRUE@ $(nodist_lsefisystab_module_SOURCES) \
+@COND_ia64_efi_TRUE@ lsefisystab.marker
+@COND_ia64_efi_TRUE@am__append_1191 = lsefisystab.mod
+@COND_ia64_efi_TRUE@am__append_1192 = lsefisystab.marker
+@COND_arm_efi_TRUE@am__append_1193 = lsefisystab.module
+@COND_arm_efi_TRUE@am__append_1194 = lsefisystab.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_1195 =
+@COND_arm_efi_TRUE@am__append_1196 = $(nodist_lsefisystab_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_1197 = \
+@COND_arm_efi_TRUE@ $(nodist_lsefisystab_module_SOURCES) \
+@COND_arm_efi_TRUE@ lsefisystab.marker
+@COND_arm_efi_TRUE@am__append_1198 = lsefisystab.mod
+@COND_arm_efi_TRUE@am__append_1199 = lsefisystab.marker
+@COND_arm64_efi_TRUE@am__append_1200 = lsefisystab.module
+@COND_arm64_efi_TRUE@am__append_1201 = lsefisystab.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_1202 =
+@COND_arm64_efi_TRUE@am__append_1203 = $(nodist_lsefisystab_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_1204 = \
+@COND_arm64_efi_TRUE@ $(nodist_lsefisystab_module_SOURCES) \
+@COND_arm64_efi_TRUE@ lsefisystab.marker
+@COND_arm64_efi_TRUE@am__append_1205 = lsefisystab.mod
+@COND_arm64_efi_TRUE@am__append_1206 = lsefisystab.marker
+@COND_riscv32_efi_TRUE@am__append_1207 = lsefisystab.module
+@COND_riscv32_efi_TRUE@am__append_1208 = lsefisystab.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_1209 =
+@COND_riscv32_efi_TRUE@am__append_1210 = $(nodist_lsefisystab_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_1211 = \
+@COND_riscv32_efi_TRUE@ $(nodist_lsefisystab_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ lsefisystab.marker
+@COND_riscv32_efi_TRUE@am__append_1212 = lsefisystab.mod
+@COND_riscv32_efi_TRUE@am__append_1213 = lsefisystab.marker
+@COND_riscv64_efi_TRUE@am__append_1214 = lsefisystab.module
+@COND_riscv64_efi_TRUE@am__append_1215 = lsefisystab.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_1216 =
+@COND_riscv64_efi_TRUE@am__append_1217 = $(nodist_lsefisystab_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_1218 = \
+@COND_riscv64_efi_TRUE@ $(nodist_lsefisystab_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ lsefisystab.marker
+@COND_riscv64_efi_TRUE@am__append_1219 = lsefisystab.mod
+@COND_riscv64_efi_TRUE@am__append_1220 = lsefisystab.marker
+@COND_i386_efi_TRUE@am__append_1221 = lssal.module
+@COND_i386_efi_TRUE@am__append_1222 = lssal.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@lssal_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_1223 =
+@COND_i386_efi_TRUE@am__append_1224 = $(nodist_lssal_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1225 = $(nodist_lssal_module_SOURCES) \
+@COND_i386_efi_TRUE@ lssal.marker
+@COND_i386_efi_TRUE@am__append_1226 = lssal.mod
+@COND_i386_efi_TRUE@am__append_1227 = lssal.marker
+@COND_x86_64_efi_TRUE@am__append_1228 = lssal.module
+@COND_x86_64_efi_TRUE@am__append_1229 = lssal.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1230 =
+@COND_x86_64_efi_TRUE@am__append_1231 = $(nodist_lssal_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1232 = \
+@COND_x86_64_efi_TRUE@ $(nodist_lssal_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ lssal.marker
+@COND_x86_64_efi_TRUE@am__append_1233 = lssal.mod
+@COND_x86_64_efi_TRUE@am__append_1234 = lssal.marker
+@COND_ia64_efi_TRUE@am__append_1235 = lssal.module
+@COND_ia64_efi_TRUE@am__append_1236 = lssal.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1237 =
+@COND_ia64_efi_TRUE@am__append_1238 = $(nodist_lssal_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1239 = $(nodist_lssal_module_SOURCES) \
+@COND_ia64_efi_TRUE@ lssal.marker
+@COND_ia64_efi_TRUE@am__append_1240 = lssal.mod
+@COND_ia64_efi_TRUE@am__append_1241 = lssal.marker
+@COND_arm_efi_TRUE@am__append_1242 = lssal.module
+@COND_arm_efi_TRUE@am__append_1243 = lssal.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_1244 =
+@COND_arm_efi_TRUE@am__append_1245 = $(nodist_lssal_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_1246 = $(nodist_lssal_module_SOURCES) \
+@COND_arm_efi_TRUE@ lssal.marker
+@COND_arm_efi_TRUE@am__append_1247 = lssal.mod
+@COND_arm_efi_TRUE@am__append_1248 = lssal.marker
+@COND_arm64_efi_TRUE@am__append_1249 = lssal.module
+@COND_arm64_efi_TRUE@am__append_1250 = lssal.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_1251 =
+@COND_arm64_efi_TRUE@am__append_1252 = $(nodist_lssal_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_1253 = $(nodist_lssal_module_SOURCES) \
+@COND_arm64_efi_TRUE@ lssal.marker
+@COND_arm64_efi_TRUE@am__append_1254 = lssal.mod
+@COND_arm64_efi_TRUE@am__append_1255 = lssal.marker
+@COND_riscv32_efi_TRUE@am__append_1256 = lssal.module
+@COND_riscv32_efi_TRUE@am__append_1257 = lssal.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_1258 =
+@COND_riscv32_efi_TRUE@am__append_1259 = $(nodist_lssal_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_1260 = \
+@COND_riscv32_efi_TRUE@ $(nodist_lssal_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ lssal.marker
+@COND_riscv32_efi_TRUE@am__append_1261 = lssal.mod
+@COND_riscv32_efi_TRUE@am__append_1262 = lssal.marker
+@COND_riscv64_efi_TRUE@am__append_1263 = lssal.module
+@COND_riscv64_efi_TRUE@am__append_1264 = lssal.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_1265 =
+@COND_riscv64_efi_TRUE@am__append_1266 = $(nodist_lssal_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_1267 = \
+@COND_riscv64_efi_TRUE@ $(nodist_lssal_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ lssal.marker
+@COND_riscv64_efi_TRUE@am__append_1268 = lssal.mod
+@COND_riscv64_efi_TRUE@am__append_1269 = lssal.marker
+@COND_i386_efi_TRUE@am__append_1270 = lsefimmap.module
+@COND_i386_efi_TRUE@am__append_1271 = lsefimmap.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@lsefimmap_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_1272 =
+@COND_i386_efi_TRUE@am__append_1273 = $(nodist_lsefimmap_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1274 = \
+@COND_i386_efi_TRUE@ $(nodist_lsefimmap_module_SOURCES) \
+@COND_i386_efi_TRUE@ lsefimmap.marker
+@COND_i386_efi_TRUE@am__append_1275 = lsefimmap.mod
+@COND_i386_efi_TRUE@am__append_1276 = lsefimmap.marker
+@COND_x86_64_efi_TRUE@am__append_1277 = lsefimmap.module
+@COND_x86_64_efi_TRUE@am__append_1278 = lsefimmap.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1279 =
+@COND_x86_64_efi_TRUE@am__append_1280 = $(nodist_lsefimmap_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1281 = \
+@COND_x86_64_efi_TRUE@ $(nodist_lsefimmap_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ lsefimmap.marker
+@COND_x86_64_efi_TRUE@am__append_1282 = lsefimmap.mod
+@COND_x86_64_efi_TRUE@am__append_1283 = lsefimmap.marker
+@COND_ia64_efi_TRUE@am__append_1284 = lsefimmap.module
+@COND_ia64_efi_TRUE@am__append_1285 = lsefimmap.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1286 =
+@COND_ia64_efi_TRUE@am__append_1287 = $(nodist_lsefimmap_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1288 = \
+@COND_ia64_efi_TRUE@ $(nodist_lsefimmap_module_SOURCES) \
+@COND_ia64_efi_TRUE@ lsefimmap.marker
+@COND_ia64_efi_TRUE@am__append_1289 = lsefimmap.mod
+@COND_ia64_efi_TRUE@am__append_1290 = lsefimmap.marker
+@COND_arm_efi_TRUE@am__append_1291 = lsefimmap.module
+@COND_arm_efi_TRUE@am__append_1292 = lsefimmap.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_1293 =
+@COND_arm_efi_TRUE@am__append_1294 = $(nodist_lsefimmap_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_1295 = \
+@COND_arm_efi_TRUE@ $(nodist_lsefimmap_module_SOURCES) \
+@COND_arm_efi_TRUE@ lsefimmap.marker
+@COND_arm_efi_TRUE@am__append_1296 = lsefimmap.mod
+@COND_arm_efi_TRUE@am__append_1297 = lsefimmap.marker
+@COND_arm64_efi_TRUE@am__append_1298 = lsefimmap.module
+@COND_arm64_efi_TRUE@am__append_1299 = lsefimmap.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_1300 =
+@COND_arm64_efi_TRUE@am__append_1301 = $(nodist_lsefimmap_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_1302 = \
+@COND_arm64_efi_TRUE@ $(nodist_lsefimmap_module_SOURCES) \
+@COND_arm64_efi_TRUE@ lsefimmap.marker
+@COND_arm64_efi_TRUE@am__append_1303 = lsefimmap.mod
+@COND_arm64_efi_TRUE@am__append_1304 = lsefimmap.marker
+@COND_riscv32_efi_TRUE@am__append_1305 = lsefimmap.module
+@COND_riscv32_efi_TRUE@am__append_1306 = lsefimmap.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_1307 =
+@COND_riscv32_efi_TRUE@am__append_1308 = $(nodist_lsefimmap_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_1309 = \
+@COND_riscv32_efi_TRUE@ $(nodist_lsefimmap_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ lsefimmap.marker
+@COND_riscv32_efi_TRUE@am__append_1310 = lsefimmap.mod
+@COND_riscv32_efi_TRUE@am__append_1311 = lsefimmap.marker
+@COND_riscv64_efi_TRUE@am__append_1312 = lsefimmap.module
+@COND_riscv64_efi_TRUE@am__append_1313 = lsefimmap.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_1314 =
+@COND_riscv64_efi_TRUE@am__append_1315 = $(nodist_lsefimmap_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_1316 = \
+@COND_riscv64_efi_TRUE@ $(nodist_lsefimmap_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ lsefimmap.marker
+@COND_riscv64_efi_TRUE@am__append_1317 = lsefimmap.mod
+@COND_riscv64_efi_TRUE@am__append_1318 = lsefimmap.marker
+@COND_i386_efi_TRUE@am__append_1319 = lsefi.module
+@COND_i386_efi_TRUE@am__append_1320 = lsefi.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@lsefi_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_1321 =
+@COND_i386_efi_TRUE@am__append_1322 = $(nodist_lsefi_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1323 = $(nodist_lsefi_module_SOURCES) \
+@COND_i386_efi_TRUE@ lsefi.marker
+@COND_i386_efi_TRUE@am__append_1324 = lsefi.mod
+@COND_i386_efi_TRUE@am__append_1325 = lsefi.marker
+@COND_x86_64_efi_TRUE@am__append_1326 = lsefi.module
+@COND_x86_64_efi_TRUE@am__append_1327 = lsefi.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1328 =
+@COND_x86_64_efi_TRUE@am__append_1329 = $(nodist_lsefi_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1330 = \
+@COND_x86_64_efi_TRUE@ $(nodist_lsefi_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ lsefi.marker
+@COND_x86_64_efi_TRUE@am__append_1331 = lsefi.mod
+@COND_x86_64_efi_TRUE@am__append_1332 = lsefi.marker
+@COND_ia64_efi_TRUE@am__append_1333 = lsefi.module
+@COND_ia64_efi_TRUE@am__append_1334 = lsefi.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1335 =
+@COND_ia64_efi_TRUE@am__append_1336 = $(nodist_lsefi_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1337 = $(nodist_lsefi_module_SOURCES) \
+@COND_ia64_efi_TRUE@ lsefi.marker
+@COND_ia64_efi_TRUE@am__append_1338 = lsefi.mod
+@COND_ia64_efi_TRUE@am__append_1339 = lsefi.marker
+@COND_arm_efi_TRUE@am__append_1340 = lsefi.module
+@COND_arm_efi_TRUE@am__append_1341 = lsefi.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_1342 =
+@COND_arm_efi_TRUE@am__append_1343 = $(nodist_lsefi_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_1344 = $(nodist_lsefi_module_SOURCES) \
+@COND_arm_efi_TRUE@ lsefi.marker
+@COND_arm_efi_TRUE@am__append_1345 = lsefi.mod
+@COND_arm_efi_TRUE@am__append_1346 = lsefi.marker
+@COND_arm64_efi_TRUE@am__append_1347 = lsefi.module
+@COND_arm64_efi_TRUE@am__append_1348 = lsefi.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_1349 =
+@COND_arm64_efi_TRUE@am__append_1350 = $(nodist_lsefi_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_1351 = $(nodist_lsefi_module_SOURCES) \
+@COND_arm64_efi_TRUE@ lsefi.marker
+@COND_arm64_efi_TRUE@am__append_1352 = lsefi.mod
+@COND_arm64_efi_TRUE@am__append_1353 = lsefi.marker
+@COND_riscv32_efi_TRUE@am__append_1354 = lsefi.module
+@COND_riscv32_efi_TRUE@am__append_1355 = lsefi.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_1356 =
+@COND_riscv32_efi_TRUE@am__append_1357 = $(nodist_lsefi_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_1358 = \
+@COND_riscv32_efi_TRUE@ $(nodist_lsefi_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ lsefi.marker
+@COND_riscv32_efi_TRUE@am__append_1359 = lsefi.mod
+@COND_riscv32_efi_TRUE@am__append_1360 = lsefi.marker
+@COND_riscv64_efi_TRUE@am__append_1361 = lsefi.module
+@COND_riscv64_efi_TRUE@am__append_1362 = lsefi.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_1363 =
+@COND_riscv64_efi_TRUE@am__append_1364 = $(nodist_lsefi_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_1365 = \
+@COND_riscv64_efi_TRUE@ $(nodist_lsefi_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ lsefi.marker
+@COND_riscv64_efi_TRUE@am__append_1366 = lsefi.mod
+@COND_riscv64_efi_TRUE@am__append_1367 = lsefi.marker
+@COND_i386_efi_TRUE@am__append_1368 = efifwsetup.module
+@COND_i386_efi_TRUE@am__append_1369 = efifwsetup.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@efifwsetup_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_1370 =
+@COND_i386_efi_TRUE@am__append_1371 = $(nodist_efifwsetup_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1372 = \
+@COND_i386_efi_TRUE@ $(nodist_efifwsetup_module_SOURCES) \
+@COND_i386_efi_TRUE@ efifwsetup.marker
+@COND_i386_efi_TRUE@am__append_1373 = efifwsetup.mod
+@COND_i386_efi_TRUE@am__append_1374 = efifwsetup.marker
+@COND_x86_64_efi_TRUE@am__append_1375 = efifwsetup.module
+@COND_x86_64_efi_TRUE@am__append_1376 = efifwsetup.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1377 =
+@COND_x86_64_efi_TRUE@am__append_1378 = $(nodist_efifwsetup_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1379 = \
+@COND_x86_64_efi_TRUE@ $(nodist_efifwsetup_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ efifwsetup.marker
+@COND_x86_64_efi_TRUE@am__append_1380 = efifwsetup.mod
+@COND_x86_64_efi_TRUE@am__append_1381 = efifwsetup.marker
+@COND_ia64_efi_TRUE@am__append_1382 = efifwsetup.module
+@COND_ia64_efi_TRUE@am__append_1383 = efifwsetup.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1384 =
+@COND_ia64_efi_TRUE@am__append_1385 = $(nodist_efifwsetup_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1386 = \
+@COND_ia64_efi_TRUE@ $(nodist_efifwsetup_module_SOURCES) \
+@COND_ia64_efi_TRUE@ efifwsetup.marker
+@COND_ia64_efi_TRUE@am__append_1387 = efifwsetup.mod
+@COND_ia64_efi_TRUE@am__append_1388 = efifwsetup.marker
+@COND_arm_efi_TRUE@am__append_1389 = efifwsetup.module
+@COND_arm_efi_TRUE@am__append_1390 = efifwsetup.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_1391 =
+@COND_arm_efi_TRUE@am__append_1392 = $(nodist_efifwsetup_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_1393 = \
+@COND_arm_efi_TRUE@ $(nodist_efifwsetup_module_SOURCES) \
+@COND_arm_efi_TRUE@ efifwsetup.marker
+@COND_arm_efi_TRUE@am__append_1394 = efifwsetup.mod
+@COND_arm_efi_TRUE@am__append_1395 = efifwsetup.marker
+@COND_arm64_efi_TRUE@am__append_1396 = efifwsetup.module
+@COND_arm64_efi_TRUE@am__append_1397 = efifwsetup.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_1398 =
+@COND_arm64_efi_TRUE@am__append_1399 = $(nodist_efifwsetup_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_1400 = \
+@COND_arm64_efi_TRUE@ $(nodist_efifwsetup_module_SOURCES) \
+@COND_arm64_efi_TRUE@ efifwsetup.marker
+@COND_arm64_efi_TRUE@am__append_1401 = efifwsetup.mod
+@COND_arm64_efi_TRUE@am__append_1402 = efifwsetup.marker
+@COND_riscv32_efi_TRUE@am__append_1403 = efifwsetup.module
+@COND_riscv32_efi_TRUE@am__append_1404 = efifwsetup.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_1405 =
+@COND_riscv32_efi_TRUE@am__append_1406 = $(nodist_efifwsetup_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_1407 = \
+@COND_riscv32_efi_TRUE@ $(nodist_efifwsetup_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ efifwsetup.marker
+@COND_riscv32_efi_TRUE@am__append_1408 = efifwsetup.mod
+@COND_riscv32_efi_TRUE@am__append_1409 = efifwsetup.marker
+@COND_riscv64_efi_TRUE@am__append_1410 = efifwsetup.module
+@COND_riscv64_efi_TRUE@am__append_1411 = efifwsetup.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_1412 =
+@COND_riscv64_efi_TRUE@am__append_1413 = $(nodist_efifwsetup_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_1414 = \
+@COND_riscv64_efi_TRUE@ $(nodist_efifwsetup_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ efifwsetup.marker
+@COND_riscv64_efi_TRUE@am__append_1415 = efifwsetup.mod
+@COND_riscv64_efi_TRUE@am__append_1416 = efifwsetup.marker
+@COND_emu_TRUE@am__append_1417 = boot.module
+@COND_emu_TRUE@am__append_1418 = boot.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@boot_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_1419 =
+@COND_emu_TRUE@am__append_1420 = $(nodist_boot_module_SOURCES)
+@COND_emu_TRUE@am__append_1421 = $(nodist_boot_module_SOURCES) \
+@COND_emu_TRUE@ boot.marker
+@COND_emu_TRUE@am__append_1422 = boot.mod
+@COND_emu_TRUE@am__append_1423 = boot.marker
+@COND_i386_pc_TRUE@am__append_1424 = boot.module
+@COND_i386_pc_TRUE@am__append_1425 = boot.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_1426 =
+@COND_i386_pc_TRUE@am__append_1427 = $(nodist_boot_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_1428 = $(nodist_boot_module_SOURCES) \
+@COND_i386_pc_TRUE@ boot.marker
+@COND_i386_pc_TRUE@am__append_1429 = boot.mod
+@COND_i386_pc_TRUE@am__append_1430 = boot.marker
+@COND_i386_efi_TRUE@am__append_1431 = boot.module
+@COND_i386_efi_TRUE@am__append_1432 = boot.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_1433 =
+@COND_i386_efi_TRUE@am__append_1434 = $(nodist_boot_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1435 = $(nodist_boot_module_SOURCES) \
+@COND_i386_efi_TRUE@ boot.marker
+@COND_i386_efi_TRUE@am__append_1436 = boot.mod
+@COND_i386_efi_TRUE@am__append_1437 = boot.marker
+@COND_i386_qemu_TRUE@am__append_1438 = boot.module
+@COND_i386_qemu_TRUE@am__append_1439 = boot.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_1440 =
+@COND_i386_qemu_TRUE@am__append_1441 = $(nodist_boot_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_1442 = $(nodist_boot_module_SOURCES) \
+@COND_i386_qemu_TRUE@ boot.marker
+@COND_i386_qemu_TRUE@am__append_1443 = boot.mod
+@COND_i386_qemu_TRUE@am__append_1444 = boot.marker
+@COND_i386_coreboot_TRUE@am__append_1445 = boot.module
+@COND_i386_coreboot_TRUE@am__append_1446 = boot.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_1447 =
+@COND_i386_coreboot_TRUE@am__append_1448 = $(nodist_boot_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_1449 = \
+@COND_i386_coreboot_TRUE@ $(nodist_boot_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ boot.marker
+@COND_i386_coreboot_TRUE@am__append_1450 = boot.mod
+@COND_i386_coreboot_TRUE@am__append_1451 = boot.marker
+@COND_i386_multiboot_TRUE@am__append_1452 = boot.module
+@COND_i386_multiboot_TRUE@am__append_1453 = boot.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_1454 =
+@COND_i386_multiboot_TRUE@am__append_1455 = $(nodist_boot_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_1456 = \
+@COND_i386_multiboot_TRUE@ $(nodist_boot_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ boot.marker
+@COND_i386_multiboot_TRUE@am__append_1457 = boot.mod
+@COND_i386_multiboot_TRUE@am__append_1458 = boot.marker
+@COND_i386_ieee1275_TRUE@am__append_1459 = boot.module
+@COND_i386_ieee1275_TRUE@am__append_1460 = boot.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_1461 =
+@COND_i386_ieee1275_TRUE@am__append_1462 = $(nodist_boot_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_1463 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_boot_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ boot.marker
+@COND_i386_ieee1275_TRUE@am__append_1464 = boot.mod
+@COND_i386_ieee1275_TRUE@am__append_1465 = boot.marker
+@COND_x86_64_efi_TRUE@am__append_1466 = boot.module
+@COND_x86_64_efi_TRUE@am__append_1467 = boot.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1468 =
+@COND_x86_64_efi_TRUE@am__append_1469 = $(nodist_boot_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1470 = $(nodist_boot_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ boot.marker
+@COND_x86_64_efi_TRUE@am__append_1471 = boot.mod
+@COND_x86_64_efi_TRUE@am__append_1472 = boot.marker
+@COND_sparc64_ieee1275_TRUE@am__append_1473 = boot.module
+@COND_sparc64_ieee1275_TRUE@am__append_1474 = boot.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_1475 =
+@COND_sparc64_ieee1275_TRUE@am__append_1476 = $(nodist_boot_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_1477 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_boot_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ boot.marker
+@COND_sparc64_ieee1275_TRUE@am__append_1478 = boot.mod
+@COND_sparc64_ieee1275_TRUE@am__append_1479 = boot.marker
+@COND_powerpc_ieee1275_TRUE@am__append_1480 = boot.module
+@COND_powerpc_ieee1275_TRUE@am__append_1481 = boot.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_1482 =
+@COND_powerpc_ieee1275_TRUE@am__append_1483 = $(nodist_boot_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_1484 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_boot_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ boot.marker
+@COND_powerpc_ieee1275_TRUE@am__append_1485 = boot.mod
+@COND_powerpc_ieee1275_TRUE@am__append_1486 = boot.marker
+@COND_mips_arc_TRUE@am__append_1487 = boot.module
+@COND_mips_arc_TRUE@am__append_1488 = boot.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_1489 =
+@COND_mips_arc_TRUE@am__append_1490 = $(nodist_boot_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_1491 = $(nodist_boot_module_SOURCES) \
+@COND_mips_arc_TRUE@ boot.marker
+@COND_mips_arc_TRUE@am__append_1492 = boot.mod
+@COND_mips_arc_TRUE@am__append_1493 = boot.marker
+@COND_ia64_efi_TRUE@am__append_1494 = boot.module
+@COND_ia64_efi_TRUE@am__append_1495 = boot.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1496 =
+@COND_ia64_efi_TRUE@am__append_1497 = $(nodist_boot_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1498 = $(nodist_boot_module_SOURCES) \
+@COND_ia64_efi_TRUE@ boot.marker
+@COND_ia64_efi_TRUE@am__append_1499 = boot.mod
+@COND_ia64_efi_TRUE@am__append_1500 = boot.marker
+@COND_arm_uboot_TRUE@am__append_1501 = boot.module
+@COND_arm_uboot_TRUE@am__append_1502 = boot.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__append_1503 =
+@COND_arm_uboot_TRUE@am__append_1504 = $(nodist_boot_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_1505 = $(nodist_boot_module_SOURCES) \
+@COND_arm_uboot_TRUE@ boot.marker
+@COND_arm_uboot_TRUE@am__append_1506 = boot.mod
+@COND_arm_uboot_TRUE@am__append_1507 = boot.marker
+@COND_arm_efi_TRUE@am__append_1508 = boot.module
+@COND_arm_efi_TRUE@am__append_1509 = boot.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_1510 =
+@COND_arm_efi_TRUE@am__append_1511 = $(nodist_boot_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_1512 = $(nodist_boot_module_SOURCES) \
+@COND_arm_efi_TRUE@ boot.marker
+@COND_arm_efi_TRUE@am__append_1513 = boot.mod
+@COND_arm_efi_TRUE@am__append_1514 = boot.marker
+@COND_arm64_efi_TRUE@am__append_1515 = boot.module
+@COND_arm64_efi_TRUE@am__append_1516 = boot.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_1517 =
+@COND_arm64_efi_TRUE@am__append_1518 = $(nodist_boot_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_1519 = $(nodist_boot_module_SOURCES) \
+@COND_arm64_efi_TRUE@ boot.marker
+@COND_arm64_efi_TRUE@am__append_1520 = boot.mod
+@COND_arm64_efi_TRUE@am__append_1521 = boot.marker
+@COND_arm_coreboot_TRUE@am__append_1522 = boot.module
+@COND_arm_coreboot_TRUE@am__append_1523 = boot.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_1524 =
+@COND_arm_coreboot_TRUE@am__append_1525 = $(nodist_boot_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_1526 = \
+@COND_arm_coreboot_TRUE@ $(nodist_boot_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ boot.marker
+@COND_arm_coreboot_TRUE@am__append_1527 = boot.mod
+@COND_arm_coreboot_TRUE@am__append_1528 = boot.marker
+@COND_riscv32_efi_TRUE@am__append_1529 = boot.module
+@COND_riscv32_efi_TRUE@am__append_1530 = boot.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_1531 =
+@COND_riscv32_efi_TRUE@am__append_1532 = $(nodist_boot_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_1533 = \
+@COND_riscv32_efi_TRUE@ $(nodist_boot_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ boot.marker
+@COND_riscv32_efi_TRUE@am__append_1534 = boot.mod
+@COND_riscv32_efi_TRUE@am__append_1535 = boot.marker
+@COND_riscv64_efi_TRUE@am__append_1536 = boot.module
+@COND_riscv64_efi_TRUE@am__append_1537 = boot.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_1538 =
+@COND_riscv64_efi_TRUE@am__append_1539 = $(nodist_boot_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_1540 = \
+@COND_riscv64_efi_TRUE@ $(nodist_boot_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ boot.marker
+@COND_riscv64_efi_TRUE@am__append_1541 = boot.mod
+@COND_riscv64_efi_TRUE@am__append_1542 = boot.marker
+@COND_i386_pc_TRUE@am__append_1543 = cpuid.module
+@COND_i386_pc_TRUE@am__append_1544 = cpuid.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@cpuid_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_1545 =
+@COND_i386_pc_TRUE@am__append_1546 = $(nodist_cpuid_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_1547 = $(nodist_cpuid_module_SOURCES) \
+@COND_i386_pc_TRUE@ cpuid.marker
+@COND_i386_pc_TRUE@am__append_1548 = cpuid.mod
+@COND_i386_pc_TRUE@am__append_1549 = cpuid.marker
+@COND_i386_efi_TRUE@am__append_1550 = cpuid.module
+@COND_i386_efi_TRUE@am__append_1551 = cpuid.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_1552 =
+@COND_i386_efi_TRUE@am__append_1553 = $(nodist_cpuid_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1554 = $(nodist_cpuid_module_SOURCES) \
+@COND_i386_efi_TRUE@ cpuid.marker
+@COND_i386_efi_TRUE@am__append_1555 = cpuid.mod
+@COND_i386_efi_TRUE@am__append_1556 = cpuid.marker
+@COND_i386_qemu_TRUE@am__append_1557 = cpuid.module
+@COND_i386_qemu_TRUE@am__append_1558 = cpuid.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_1559 =
+@COND_i386_qemu_TRUE@am__append_1560 = $(nodist_cpuid_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_1561 = $(nodist_cpuid_module_SOURCES) \
+@COND_i386_qemu_TRUE@ cpuid.marker
+@COND_i386_qemu_TRUE@am__append_1562 = cpuid.mod
+@COND_i386_qemu_TRUE@am__append_1563 = cpuid.marker
+@COND_i386_coreboot_TRUE@am__append_1564 = cpuid.module
+@COND_i386_coreboot_TRUE@am__append_1565 = cpuid.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_1566 =
+@COND_i386_coreboot_TRUE@am__append_1567 = $(nodist_cpuid_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_1568 = \
+@COND_i386_coreboot_TRUE@ $(nodist_cpuid_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ cpuid.marker
+@COND_i386_coreboot_TRUE@am__append_1569 = cpuid.mod
+@COND_i386_coreboot_TRUE@am__append_1570 = cpuid.marker
+@COND_i386_multiboot_TRUE@am__append_1571 = cpuid.module
+@COND_i386_multiboot_TRUE@am__append_1572 = cpuid.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_1573 =
+@COND_i386_multiboot_TRUE@am__append_1574 = $(nodist_cpuid_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_1575 = \
+@COND_i386_multiboot_TRUE@ $(nodist_cpuid_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ cpuid.marker
+@COND_i386_multiboot_TRUE@am__append_1576 = cpuid.mod
+@COND_i386_multiboot_TRUE@am__append_1577 = cpuid.marker
+@COND_i386_ieee1275_TRUE@am__append_1578 = cpuid.module
+@COND_i386_ieee1275_TRUE@am__append_1579 = cpuid.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_1580 =
+@COND_i386_ieee1275_TRUE@am__append_1581 = $(nodist_cpuid_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_1582 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_cpuid_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ cpuid.marker
+@COND_i386_ieee1275_TRUE@am__append_1583 = cpuid.mod
+@COND_i386_ieee1275_TRUE@am__append_1584 = cpuid.marker
+@COND_x86_64_efi_TRUE@am__append_1585 = cpuid.module
+@COND_x86_64_efi_TRUE@am__append_1586 = cpuid.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1587 =
+@COND_x86_64_efi_TRUE@am__append_1588 = $(nodist_cpuid_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1589 = \
+@COND_x86_64_efi_TRUE@ $(nodist_cpuid_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ cpuid.marker
+@COND_x86_64_efi_TRUE@am__append_1590 = cpuid.mod
+@COND_x86_64_efi_TRUE@am__append_1591 = cpuid.marker
+@COND_i386_xen_TRUE@am__append_1592 = cpuid.module
+@COND_i386_xen_TRUE@am__append_1593 = cpuid.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_1594 =
+@COND_i386_xen_TRUE@am__append_1595 = $(nodist_cpuid_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_1596 = $(nodist_cpuid_module_SOURCES) \
+@COND_i386_xen_TRUE@ cpuid.marker
+@COND_i386_xen_TRUE@am__append_1597 = cpuid.mod
+@COND_i386_xen_TRUE@am__append_1598 = cpuid.marker
+@COND_x86_64_xen_TRUE@am__append_1599 = cpuid.module
+@COND_x86_64_xen_TRUE@am__append_1600 = cpuid.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_1601 =
+@COND_x86_64_xen_TRUE@am__append_1602 = $(nodist_cpuid_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_1603 = \
+@COND_x86_64_xen_TRUE@ $(nodist_cpuid_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ cpuid.marker
+@COND_x86_64_xen_TRUE@am__append_1604 = cpuid.mod
+@COND_x86_64_xen_TRUE@am__append_1605 = cpuid.marker
+@COND_i386_xen_pvh_TRUE@am__append_1606 = cpuid.module
+@COND_i386_xen_pvh_TRUE@am__append_1607 = cpuid.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_1608 =
+@COND_i386_xen_pvh_TRUE@am__append_1609 = $(nodist_cpuid_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_1610 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_cpuid_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ cpuid.marker
+@COND_i386_xen_pvh_TRUE@am__append_1611 = cpuid.mod
+@COND_i386_xen_pvh_TRUE@am__append_1612 = cpuid.marker
+@COND_i386_pc_TRUE@am__append_1613 = drivemap.module
+@COND_i386_pc_TRUE@am__append_1614 = drivemap.module$(EXEEXT)
+@COND_i386_pc_FALSE@drivemap_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_1615 =
+@COND_i386_pc_TRUE@am__append_1616 = $(nodist_drivemap_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_1617 = \
+@COND_i386_pc_TRUE@ $(nodist_drivemap_module_SOURCES) \
+@COND_i386_pc_TRUE@ drivemap.marker
+@COND_i386_pc_TRUE@am__append_1618 = drivemap.mod
+@COND_i386_pc_TRUE@am__append_1619 = drivemap.marker
+@COND_i386_pc_TRUE@am__append_1620 = extcmd.module
+@COND_i386_pc_TRUE@am__append_1621 = extcmd.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@extcmd_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_1622 =
+@COND_i386_pc_TRUE@am__append_1623 = $(nodist_extcmd_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_1624 = $(nodist_extcmd_module_SOURCES) \
+@COND_i386_pc_TRUE@ extcmd.marker
+@COND_i386_pc_TRUE@am__append_1625 = extcmd.mod
+@COND_i386_pc_TRUE@am__append_1626 = extcmd.marker
+@COND_i386_efi_TRUE@am__append_1627 = extcmd.module
+@COND_i386_efi_TRUE@am__append_1628 = extcmd.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_1629 =
+@COND_i386_efi_TRUE@am__append_1630 = $(nodist_extcmd_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1631 = $(nodist_extcmd_module_SOURCES) \
+@COND_i386_efi_TRUE@ extcmd.marker
+@COND_i386_efi_TRUE@am__append_1632 = extcmd.mod
+@COND_i386_efi_TRUE@am__append_1633 = extcmd.marker
+@COND_i386_qemu_TRUE@am__append_1634 = extcmd.module
+@COND_i386_qemu_TRUE@am__append_1635 = extcmd.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_1636 =
+@COND_i386_qemu_TRUE@am__append_1637 = $(nodist_extcmd_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_1638 = \
+@COND_i386_qemu_TRUE@ $(nodist_extcmd_module_SOURCES) \
+@COND_i386_qemu_TRUE@ extcmd.marker
+@COND_i386_qemu_TRUE@am__append_1639 = extcmd.mod
+@COND_i386_qemu_TRUE@am__append_1640 = extcmd.marker
+@COND_i386_coreboot_TRUE@am__append_1641 = extcmd.module
+@COND_i386_coreboot_TRUE@am__append_1642 = extcmd.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_1643 =
+@COND_i386_coreboot_TRUE@am__append_1644 = $(nodist_extcmd_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_1645 = \
+@COND_i386_coreboot_TRUE@ $(nodist_extcmd_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ extcmd.marker
+@COND_i386_coreboot_TRUE@am__append_1646 = extcmd.mod
+@COND_i386_coreboot_TRUE@am__append_1647 = extcmd.marker
+@COND_i386_multiboot_TRUE@am__append_1648 = extcmd.module
+@COND_i386_multiboot_TRUE@am__append_1649 = extcmd.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_1650 =
+@COND_i386_multiboot_TRUE@am__append_1651 = $(nodist_extcmd_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_1652 = \
+@COND_i386_multiboot_TRUE@ $(nodist_extcmd_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ extcmd.marker
+@COND_i386_multiboot_TRUE@am__append_1653 = extcmd.mod
+@COND_i386_multiboot_TRUE@am__append_1654 = extcmd.marker
+@COND_x86_64_efi_TRUE@am__append_1655 = extcmd.module
+@COND_x86_64_efi_TRUE@am__append_1656 = extcmd.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1657 =
+@COND_x86_64_efi_TRUE@am__append_1658 = $(nodist_extcmd_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1659 = \
+@COND_x86_64_efi_TRUE@ $(nodist_extcmd_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ extcmd.marker
+@COND_x86_64_efi_TRUE@am__append_1660 = extcmd.mod
+@COND_x86_64_efi_TRUE@am__append_1661 = extcmd.marker
+@COND_ia64_efi_TRUE@am__append_1662 = extcmd.module
+@COND_ia64_efi_TRUE@am__append_1663 = extcmd.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1664 =
+@COND_ia64_efi_TRUE@am__append_1665 = $(nodist_extcmd_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1666 = $(nodist_extcmd_module_SOURCES) \
+@COND_ia64_efi_TRUE@ extcmd.marker
+@COND_ia64_efi_TRUE@am__append_1667 = extcmd.mod
+@COND_ia64_efi_TRUE@am__append_1668 = extcmd.marker
+@COND_arm_efi_TRUE@am__append_1669 = extcmd.module
+@COND_arm_efi_TRUE@am__append_1670 = extcmd.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_1671 =
+@COND_arm_efi_TRUE@am__append_1672 = $(nodist_extcmd_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_1673 = $(nodist_extcmd_module_SOURCES) \
+@COND_arm_efi_TRUE@ extcmd.marker
+@COND_arm_efi_TRUE@am__append_1674 = extcmd.mod
+@COND_arm_efi_TRUE@am__append_1675 = extcmd.marker
+@COND_arm64_efi_TRUE@am__append_1676 = extcmd.module
+@COND_arm64_efi_TRUE@am__append_1677 = extcmd.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_1678 =
+@COND_arm64_efi_TRUE@am__append_1679 = $(nodist_extcmd_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_1680 = \
+@COND_arm64_efi_TRUE@ $(nodist_extcmd_module_SOURCES) \
+@COND_arm64_efi_TRUE@ extcmd.marker
+@COND_arm64_efi_TRUE@am__append_1681 = extcmd.mod
+@COND_arm64_efi_TRUE@am__append_1682 = extcmd.marker
+@COND_arm_coreboot_TRUE@am__append_1683 = extcmd.module
+@COND_arm_coreboot_TRUE@am__append_1684 = extcmd.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_1685 =
+@COND_arm_coreboot_TRUE@am__append_1686 = $(nodist_extcmd_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_1687 = \
+@COND_arm_coreboot_TRUE@ $(nodist_extcmd_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ extcmd.marker
+@COND_arm_coreboot_TRUE@am__append_1688 = extcmd.mod
+@COND_arm_coreboot_TRUE@am__append_1689 = extcmd.marker
+@COND_riscv32_efi_TRUE@am__append_1690 = extcmd.module
+@COND_riscv32_efi_TRUE@am__append_1691 = extcmd.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_1692 =
+@COND_riscv32_efi_TRUE@am__append_1693 = $(nodist_extcmd_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_1694 = \
+@COND_riscv32_efi_TRUE@ $(nodist_extcmd_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ extcmd.marker
+@COND_riscv32_efi_TRUE@am__append_1695 = extcmd.mod
+@COND_riscv32_efi_TRUE@am__append_1696 = extcmd.marker
+@COND_riscv64_efi_TRUE@am__append_1697 = extcmd.module
+@COND_riscv64_efi_TRUE@am__append_1698 = extcmd.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_1699 =
+@COND_riscv64_efi_TRUE@am__append_1700 = $(nodist_extcmd_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_1701 = \
+@COND_riscv64_efi_TRUE@ $(nodist_extcmd_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ extcmd.marker
+@COND_riscv64_efi_TRUE@am__append_1702 = extcmd.mod
+@COND_riscv64_efi_TRUE@am__append_1703 = extcmd.marker
+@COND_i386_efi_TRUE@am__append_1704 = fixvideo.module
+@COND_i386_efi_TRUE@am__append_1705 = fixvideo.module$(EXEEXT)
+@COND_i386_efi_FALSE@@COND_x86_64_efi_FALSE@fixvideo_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_1706 =
+@COND_i386_efi_TRUE@am__append_1707 = $(nodist_fixvideo_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1708 = \
+@COND_i386_efi_TRUE@ $(nodist_fixvideo_module_SOURCES) \
+@COND_i386_efi_TRUE@ fixvideo.marker
+@COND_i386_efi_TRUE@am__append_1709 = fixvideo.mod
+@COND_i386_efi_TRUE@am__append_1710 = fixvideo.marker
+@COND_x86_64_efi_TRUE@am__append_1711 = fixvideo.module
+@COND_x86_64_efi_TRUE@am__append_1712 = fixvideo.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1713 =
+@COND_x86_64_efi_TRUE@am__append_1714 = $(nodist_fixvideo_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1715 = \
+@COND_x86_64_efi_TRUE@ $(nodist_fixvideo_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ fixvideo.marker
+@COND_x86_64_efi_TRUE@am__append_1716 = fixvideo.mod
+@COND_x86_64_efi_TRUE@am__append_1717 = fixvideo.marker
+@COND_emu_TRUE@am__append_1718 = halt.module
+@COND_emu_TRUE@am__append_1719 = halt.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@halt_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_1720 =
+@COND_emu_TRUE@am__append_1721 = $(nodist_halt_module_SOURCES)
+@COND_emu_TRUE@am__append_1722 = $(nodist_halt_module_SOURCES) \
+@COND_emu_TRUE@ halt.marker
+@COND_emu_TRUE@am__append_1723 = halt.mod
+@COND_emu_TRUE@am__append_1724 = halt.marker
+@COND_i386_pc_TRUE@am__append_1725 = halt.module
+@COND_i386_pc_TRUE@am__append_1726 = halt.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_1727 =
+@COND_i386_pc_TRUE@am__append_1728 = $(nodist_halt_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_1729 = $(nodist_halt_module_SOURCES) \
+@COND_i386_pc_TRUE@ halt.marker
+@COND_i386_pc_TRUE@am__append_1730 = halt.mod
+@COND_i386_pc_TRUE@am__append_1731 = halt.marker
+@COND_i386_efi_TRUE@am__append_1732 = halt.module
+@COND_i386_efi_TRUE@am__append_1733 = halt.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_1734 =
+@COND_i386_efi_TRUE@am__append_1735 = $(nodist_halt_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1736 = $(nodist_halt_module_SOURCES) \
+@COND_i386_efi_TRUE@ halt.marker
+@COND_i386_efi_TRUE@am__append_1737 = halt.mod
+@COND_i386_efi_TRUE@am__append_1738 = halt.marker
+@COND_i386_qemu_TRUE@am__append_1739 = halt.module
+@COND_i386_qemu_TRUE@am__append_1740 = halt.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_1741 =
+@COND_i386_qemu_TRUE@am__append_1742 = $(nodist_halt_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_1743 = $(nodist_halt_module_SOURCES) \
+@COND_i386_qemu_TRUE@ halt.marker
+@COND_i386_qemu_TRUE@am__append_1744 = halt.mod
+@COND_i386_qemu_TRUE@am__append_1745 = halt.marker
+@COND_i386_coreboot_TRUE@am__append_1746 = halt.module
+@COND_i386_coreboot_TRUE@am__append_1747 = halt.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_1748 =
+@COND_i386_coreboot_TRUE@am__append_1749 = $(nodist_halt_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_1750 = \
+@COND_i386_coreboot_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ halt.marker
+@COND_i386_coreboot_TRUE@am__append_1751 = halt.mod
+@COND_i386_coreboot_TRUE@am__append_1752 = halt.marker
+@COND_i386_multiboot_TRUE@am__append_1753 = halt.module
+@COND_i386_multiboot_TRUE@am__append_1754 = halt.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_1755 =
+@COND_i386_multiboot_TRUE@am__append_1756 = $(nodist_halt_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_1757 = \
+@COND_i386_multiboot_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ halt.marker
+@COND_i386_multiboot_TRUE@am__append_1758 = halt.mod
+@COND_i386_multiboot_TRUE@am__append_1759 = halt.marker
+@COND_i386_ieee1275_TRUE@am__append_1760 = halt.module
+@COND_i386_ieee1275_TRUE@am__append_1761 = halt.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_1762 =
+@COND_i386_ieee1275_TRUE@am__append_1763 = $(nodist_halt_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_1764 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ halt.marker
+@COND_i386_ieee1275_TRUE@am__append_1765 = halt.mod
+@COND_i386_ieee1275_TRUE@am__append_1766 = halt.marker
+@COND_x86_64_efi_TRUE@am__append_1767 = halt.module
+@COND_x86_64_efi_TRUE@am__append_1768 = halt.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1769 =
+@COND_x86_64_efi_TRUE@am__append_1770 = $(nodist_halt_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1771 = $(nodist_halt_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ halt.marker
+@COND_x86_64_efi_TRUE@am__append_1772 = halt.mod
+@COND_x86_64_efi_TRUE@am__append_1773 = halt.marker
+@COND_i386_xen_TRUE@am__append_1774 = halt.module
+@COND_i386_xen_TRUE@am__append_1775 = halt.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_1776 =
+@COND_i386_xen_TRUE@am__append_1777 = $(nodist_halt_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_1778 = $(nodist_halt_module_SOURCES) \
+@COND_i386_xen_TRUE@ halt.marker
+@COND_i386_xen_TRUE@am__append_1779 = halt.mod
+@COND_i386_xen_TRUE@am__append_1780 = halt.marker
+@COND_x86_64_xen_TRUE@am__append_1781 = halt.module
+@COND_x86_64_xen_TRUE@am__append_1782 = halt.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_1783 =
+@COND_x86_64_xen_TRUE@am__append_1784 = $(nodist_halt_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_1785 = $(nodist_halt_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ halt.marker
+@COND_x86_64_xen_TRUE@am__append_1786 = halt.mod
+@COND_x86_64_xen_TRUE@am__append_1787 = halt.marker
+@COND_i386_xen_pvh_TRUE@am__append_1788 = halt.module
+@COND_i386_xen_pvh_TRUE@am__append_1789 = halt.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_1790 =
+@COND_i386_xen_pvh_TRUE@am__append_1791 = $(nodist_halt_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_1792 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ halt.marker
+@COND_i386_xen_pvh_TRUE@am__append_1793 = halt.mod
+@COND_i386_xen_pvh_TRUE@am__append_1794 = halt.marker
+@COND_mips_loongson_TRUE@am__append_1795 = halt.module
+@COND_mips_loongson_TRUE@am__append_1796 = halt.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_1797 =
+@COND_mips_loongson_TRUE@am__append_1798 = $(nodist_halt_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_1799 = \
+@COND_mips_loongson_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_mips_loongson_TRUE@ halt.marker
+@COND_mips_loongson_TRUE@am__append_1800 = halt.mod
+@COND_mips_loongson_TRUE@am__append_1801 = halt.marker
+@COND_sparc64_ieee1275_TRUE@am__append_1802 = halt.module
+@COND_sparc64_ieee1275_TRUE@am__append_1803 = halt.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_1804 =
+@COND_sparc64_ieee1275_TRUE@am__append_1805 = $(nodist_halt_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_1806 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ halt.marker
+@COND_sparc64_ieee1275_TRUE@am__append_1807 = halt.mod
+@COND_sparc64_ieee1275_TRUE@am__append_1808 = halt.marker
+@COND_powerpc_ieee1275_TRUE@am__append_1809 = halt.module
+@COND_powerpc_ieee1275_TRUE@am__append_1810 = halt.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_1811 =
+@COND_powerpc_ieee1275_TRUE@am__append_1812 = $(nodist_halt_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_1813 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ halt.marker
+@COND_powerpc_ieee1275_TRUE@am__append_1814 = halt.mod
+@COND_powerpc_ieee1275_TRUE@am__append_1815 = halt.marker
+@COND_mips_arc_TRUE@am__append_1816 = halt.module
+@COND_mips_arc_TRUE@am__append_1817 = halt.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_1818 =
+@COND_mips_arc_TRUE@am__append_1819 = $(nodist_halt_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_1820 = $(nodist_halt_module_SOURCES) \
+@COND_mips_arc_TRUE@ halt.marker
+@COND_mips_arc_TRUE@am__append_1821 = halt.mod
+@COND_mips_arc_TRUE@am__append_1822 = halt.marker
+@COND_ia64_efi_TRUE@am__append_1823 = halt.module
+@COND_ia64_efi_TRUE@am__append_1824 = halt.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1825 =
+@COND_ia64_efi_TRUE@am__append_1826 = $(nodist_halt_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1827 = $(nodist_halt_module_SOURCES) \
+@COND_ia64_efi_TRUE@ halt.marker
+@COND_ia64_efi_TRUE@am__append_1828 = halt.mod
+@COND_ia64_efi_TRUE@am__append_1829 = halt.marker
+@COND_mips_qemu_mips_TRUE@am__append_1830 = halt.module
+@COND_mips_qemu_mips_TRUE@am__append_1831 = halt.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_1832 =
+@COND_mips_qemu_mips_TRUE@am__append_1833 = $(nodist_halt_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_1834 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ halt.marker
+@COND_mips_qemu_mips_TRUE@am__append_1835 = halt.mod
+@COND_mips_qemu_mips_TRUE@am__append_1836 = halt.marker
+@COND_arm_uboot_TRUE@am__append_1837 = halt.module
+@COND_arm_uboot_TRUE@am__append_1838 = halt.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__append_1839 =
+@COND_arm_uboot_TRUE@am__append_1840 = $(nodist_halt_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_1841 = $(nodist_halt_module_SOURCES) \
+@COND_arm_uboot_TRUE@ halt.marker
+@COND_arm_uboot_TRUE@am__append_1842 = halt.mod
+@COND_arm_uboot_TRUE@am__append_1843 = halt.marker
+@COND_arm_efi_TRUE@am__append_1844 = halt.module
+@COND_arm_efi_TRUE@am__append_1845 = halt.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_1846 =
+@COND_arm_efi_TRUE@am__append_1847 = $(nodist_halt_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_1848 = $(nodist_halt_module_SOURCES) \
+@COND_arm_efi_TRUE@ halt.marker
+@COND_arm_efi_TRUE@am__append_1849 = halt.mod
+@COND_arm_efi_TRUE@am__append_1850 = halt.marker
+@COND_arm64_efi_TRUE@am__append_1851 = halt.module
+@COND_arm64_efi_TRUE@am__append_1852 = halt.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_1853 =
+@COND_arm64_efi_TRUE@am__append_1854 = $(nodist_halt_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_1855 = $(nodist_halt_module_SOURCES) \
+@COND_arm64_efi_TRUE@ halt.marker
+@COND_arm64_efi_TRUE@am__append_1856 = halt.mod
+@COND_arm64_efi_TRUE@am__append_1857 = halt.marker
+@COND_arm_coreboot_TRUE@am__append_1858 = halt.module
+@COND_arm_coreboot_TRUE@am__append_1859 = halt.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_1860 =
+@COND_arm_coreboot_TRUE@am__append_1861 = $(nodist_halt_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_1862 = \
+@COND_arm_coreboot_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ halt.marker
+@COND_arm_coreboot_TRUE@am__append_1863 = halt.mod
+@COND_arm_coreboot_TRUE@am__append_1864 = halt.marker
+@COND_riscv32_efi_TRUE@am__append_1865 = halt.module
+@COND_riscv32_efi_TRUE@am__append_1866 = halt.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_1867 =
+@COND_riscv32_efi_TRUE@am__append_1868 = $(nodist_halt_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_1869 = \
+@COND_riscv32_efi_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ halt.marker
+@COND_riscv32_efi_TRUE@am__append_1870 = halt.mod
+@COND_riscv32_efi_TRUE@am__append_1871 = halt.marker
+@COND_riscv64_efi_TRUE@am__append_1872 = halt.module
+@COND_riscv64_efi_TRUE@am__append_1873 = halt.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_1874 =
+@COND_riscv64_efi_TRUE@am__append_1875 = $(nodist_halt_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_1876 = \
+@COND_riscv64_efi_TRUE@ $(nodist_halt_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ halt.marker
+@COND_riscv64_efi_TRUE@am__append_1877 = halt.mod
+@COND_riscv64_efi_TRUE@am__append_1878 = halt.marker
+@COND_emu_TRUE@am__append_1879 = reboot.module
+@COND_emu_TRUE@am__append_1880 = reboot.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@reboot_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_1881 =
+@COND_emu_TRUE@am__append_1882 = $(nodist_reboot_module_SOURCES)
+@COND_emu_TRUE@am__append_1883 = $(nodist_reboot_module_SOURCES) \
+@COND_emu_TRUE@ reboot.marker
+@COND_emu_TRUE@am__append_1884 = reboot.mod
+@COND_emu_TRUE@am__append_1885 = reboot.marker
+@COND_i386_pc_TRUE@am__append_1886 = reboot.module
+@COND_i386_pc_TRUE@am__append_1887 = reboot.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_1888 =
+@COND_i386_pc_TRUE@am__append_1889 = $(nodist_reboot_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_1890 = $(nodist_reboot_module_SOURCES) \
+@COND_i386_pc_TRUE@ reboot.marker
+@COND_i386_pc_TRUE@am__append_1891 = reboot.mod
+@COND_i386_pc_TRUE@am__append_1892 = reboot.marker
+@COND_i386_efi_TRUE@am__append_1893 = reboot.module
+@COND_i386_efi_TRUE@am__append_1894 = reboot.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_1895 =
+@COND_i386_efi_TRUE@am__append_1896 = $(nodist_reboot_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_1897 = $(nodist_reboot_module_SOURCES) \
+@COND_i386_efi_TRUE@ reboot.marker
+@COND_i386_efi_TRUE@am__append_1898 = reboot.mod
+@COND_i386_efi_TRUE@am__append_1899 = reboot.marker
+@COND_i386_qemu_TRUE@am__append_1900 = reboot.module
+@COND_i386_qemu_TRUE@am__append_1901 = reboot.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_1902 =
+@COND_i386_qemu_TRUE@am__append_1903 = $(nodist_reboot_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_1904 = \
+@COND_i386_qemu_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_i386_qemu_TRUE@ reboot.marker
+@COND_i386_qemu_TRUE@am__append_1905 = reboot.mod
+@COND_i386_qemu_TRUE@am__append_1906 = reboot.marker
+@COND_i386_coreboot_TRUE@am__append_1907 = reboot.module
+@COND_i386_coreboot_TRUE@am__append_1908 = reboot.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_1909 =
+@COND_i386_coreboot_TRUE@am__append_1910 = $(nodist_reboot_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_1911 = \
+@COND_i386_coreboot_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ reboot.marker
+@COND_i386_coreboot_TRUE@am__append_1912 = reboot.mod
+@COND_i386_coreboot_TRUE@am__append_1913 = reboot.marker
+@COND_i386_multiboot_TRUE@am__append_1914 = reboot.module
+@COND_i386_multiboot_TRUE@am__append_1915 = reboot.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_1916 =
+@COND_i386_multiboot_TRUE@am__append_1917 = $(nodist_reboot_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_1918 = \
+@COND_i386_multiboot_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ reboot.marker
+@COND_i386_multiboot_TRUE@am__append_1919 = reboot.mod
+@COND_i386_multiboot_TRUE@am__append_1920 = reboot.marker
+@COND_i386_ieee1275_TRUE@am__append_1921 = reboot.module
+@COND_i386_ieee1275_TRUE@am__append_1922 = reboot.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_1923 =
+@COND_i386_ieee1275_TRUE@am__append_1924 = $(nodist_reboot_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_1925 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ reboot.marker
+@COND_i386_ieee1275_TRUE@am__append_1926 = reboot.mod
+@COND_i386_ieee1275_TRUE@am__append_1927 = reboot.marker
+@COND_x86_64_efi_TRUE@am__append_1928 = reboot.module
+@COND_x86_64_efi_TRUE@am__append_1929 = reboot.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_1930 =
+@COND_x86_64_efi_TRUE@am__append_1931 = $(nodist_reboot_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_1932 = \
+@COND_x86_64_efi_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ reboot.marker
+@COND_x86_64_efi_TRUE@am__append_1933 = reboot.mod
+@COND_x86_64_efi_TRUE@am__append_1934 = reboot.marker
+@COND_i386_xen_TRUE@am__append_1935 = reboot.module
+@COND_i386_xen_TRUE@am__append_1936 = reboot.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_1937 =
+@COND_i386_xen_TRUE@am__append_1938 = $(nodist_reboot_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_1939 = $(nodist_reboot_module_SOURCES) \
+@COND_i386_xen_TRUE@ reboot.marker
+@COND_i386_xen_TRUE@am__append_1940 = reboot.mod
+@COND_i386_xen_TRUE@am__append_1941 = reboot.marker
+@COND_x86_64_xen_TRUE@am__append_1942 = reboot.module
+@COND_x86_64_xen_TRUE@am__append_1943 = reboot.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_1944 =
+@COND_x86_64_xen_TRUE@am__append_1945 = $(nodist_reboot_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_1946 = \
+@COND_x86_64_xen_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ reboot.marker
+@COND_x86_64_xen_TRUE@am__append_1947 = reboot.mod
+@COND_x86_64_xen_TRUE@am__append_1948 = reboot.marker
+@COND_i386_xen_pvh_TRUE@am__append_1949 = reboot.module
+@COND_i386_xen_pvh_TRUE@am__append_1950 = reboot.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_1951 =
+@COND_i386_xen_pvh_TRUE@am__append_1952 = $(nodist_reboot_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_1953 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ reboot.marker
+@COND_i386_xen_pvh_TRUE@am__append_1954 = reboot.mod
+@COND_i386_xen_pvh_TRUE@am__append_1955 = reboot.marker
+@COND_mips_loongson_TRUE@am__append_1956 = reboot.module
+@COND_mips_loongson_TRUE@am__append_1957 = reboot.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_1958 =
+@COND_mips_loongson_TRUE@am__append_1959 = $(nodist_reboot_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_1960 = \
+@COND_mips_loongson_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_mips_loongson_TRUE@ reboot.marker
+@COND_mips_loongson_TRUE@am__append_1961 = reboot.mod
+@COND_mips_loongson_TRUE@am__append_1962 = reboot.marker
+@COND_sparc64_ieee1275_TRUE@am__append_1963 = reboot.module
+@COND_sparc64_ieee1275_TRUE@am__append_1964 = reboot.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_1965 =
+@COND_sparc64_ieee1275_TRUE@am__append_1966 = $(nodist_reboot_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_1967 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ reboot.marker
+@COND_sparc64_ieee1275_TRUE@am__append_1968 = reboot.mod
+@COND_sparc64_ieee1275_TRUE@am__append_1969 = reboot.marker
+@COND_powerpc_ieee1275_TRUE@am__append_1970 = reboot.module
+@COND_powerpc_ieee1275_TRUE@am__append_1971 = reboot.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_1972 =
+@COND_powerpc_ieee1275_TRUE@am__append_1973 = $(nodist_reboot_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_1974 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ reboot.marker
+@COND_powerpc_ieee1275_TRUE@am__append_1975 = reboot.mod
+@COND_powerpc_ieee1275_TRUE@am__append_1976 = reboot.marker
+@COND_mips_arc_TRUE@am__append_1977 = reboot.module
+@COND_mips_arc_TRUE@am__append_1978 = reboot.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_1979 =
+@COND_mips_arc_TRUE@am__append_1980 = $(nodist_reboot_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_1981 = $(nodist_reboot_module_SOURCES) \
+@COND_mips_arc_TRUE@ reboot.marker
+@COND_mips_arc_TRUE@am__append_1982 = reboot.mod
+@COND_mips_arc_TRUE@am__append_1983 = reboot.marker
+@COND_ia64_efi_TRUE@am__append_1984 = reboot.module
+@COND_ia64_efi_TRUE@am__append_1985 = reboot.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_1986 =
+@COND_ia64_efi_TRUE@am__append_1987 = $(nodist_reboot_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_1988 = $(nodist_reboot_module_SOURCES) \
+@COND_ia64_efi_TRUE@ reboot.marker
+@COND_ia64_efi_TRUE@am__append_1989 = reboot.mod
+@COND_ia64_efi_TRUE@am__append_1990 = reboot.marker
+@COND_mips_qemu_mips_TRUE@am__append_1991 = reboot.module
+@COND_mips_qemu_mips_TRUE@am__append_1992 = reboot.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_1993 =
+@COND_mips_qemu_mips_TRUE@am__append_1994 = $(nodist_reboot_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_1995 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ reboot.marker
+@COND_mips_qemu_mips_TRUE@am__append_1996 = reboot.mod
+@COND_mips_qemu_mips_TRUE@am__append_1997 = reboot.marker
+@COND_arm_uboot_TRUE@am__append_1998 = reboot.module
+@COND_arm_uboot_TRUE@am__append_1999 = reboot.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__append_2000 =
+@COND_arm_uboot_TRUE@am__append_2001 = $(nodist_reboot_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_2002 = \
+@COND_arm_uboot_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_arm_uboot_TRUE@ reboot.marker
+@COND_arm_uboot_TRUE@am__append_2003 = reboot.mod
+@COND_arm_uboot_TRUE@am__append_2004 = reboot.marker
+@COND_arm_efi_TRUE@am__append_2005 = reboot.module
+@COND_arm_efi_TRUE@am__append_2006 = reboot.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_2007 =
+@COND_arm_efi_TRUE@am__append_2008 = $(nodist_reboot_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_2009 = $(nodist_reboot_module_SOURCES) \
+@COND_arm_efi_TRUE@ reboot.marker
+@COND_arm_efi_TRUE@am__append_2010 = reboot.mod
+@COND_arm_efi_TRUE@am__append_2011 = reboot.marker
+@COND_arm64_efi_TRUE@am__append_2012 = reboot.module
+@COND_arm64_efi_TRUE@am__append_2013 = reboot.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_2014 =
+@COND_arm64_efi_TRUE@am__append_2015 = $(nodist_reboot_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_2016 = \
+@COND_arm64_efi_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_arm64_efi_TRUE@ reboot.marker
+@COND_arm64_efi_TRUE@am__append_2017 = reboot.mod
+@COND_arm64_efi_TRUE@am__append_2018 = reboot.marker
+@COND_arm_coreboot_TRUE@am__append_2019 = reboot.module
+@COND_arm_coreboot_TRUE@am__append_2020 = reboot.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_2021 =
+@COND_arm_coreboot_TRUE@am__append_2022 = $(nodist_reboot_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_2023 = \
+@COND_arm_coreboot_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ reboot.marker
+@COND_arm_coreboot_TRUE@am__append_2024 = reboot.mod
+@COND_arm_coreboot_TRUE@am__append_2025 = reboot.marker
+@COND_riscv32_efi_TRUE@am__append_2026 = reboot.module
+@COND_riscv32_efi_TRUE@am__append_2027 = reboot.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_2028 =
+@COND_riscv32_efi_TRUE@am__append_2029 = $(nodist_reboot_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_2030 = \
+@COND_riscv32_efi_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ reboot.marker
+@COND_riscv32_efi_TRUE@am__append_2031 = reboot.mod
+@COND_riscv32_efi_TRUE@am__append_2032 = reboot.marker
+@COND_riscv64_efi_TRUE@am__append_2033 = reboot.module
+@COND_riscv64_efi_TRUE@am__append_2034 = reboot.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_2035 =
+@COND_riscv64_efi_TRUE@am__append_2036 = $(nodist_reboot_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_2037 = \
+@COND_riscv64_efi_TRUE@ $(nodist_reboot_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ reboot.marker
+@COND_riscv64_efi_TRUE@am__append_2038 = reboot.mod
+@COND_riscv64_efi_TRUE@am__append_2039 = reboot.marker
+@COND_i386_pc_TRUE@am__append_2040 = hdparm.module
+@COND_i386_pc_TRUE@am__append_2041 = hdparm.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_FALSE@hdparm_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2042 =
+@COND_i386_pc_TRUE@am__append_2043 = $(nodist_hdparm_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2044 = $(nodist_hdparm_module_SOURCES) \
+@COND_i386_pc_TRUE@ hdparm.marker
+@COND_i386_pc_TRUE@am__append_2045 = hdparm.mod
+@COND_i386_pc_TRUE@am__append_2046 = hdparm.marker
+@COND_i386_efi_TRUE@am__append_2047 = hdparm.module
+@COND_i386_efi_TRUE@am__append_2048 = hdparm.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2049 =
+@COND_i386_efi_TRUE@am__append_2050 = $(nodist_hdparm_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2051 = $(nodist_hdparm_module_SOURCES) \
+@COND_i386_efi_TRUE@ hdparm.marker
+@COND_i386_efi_TRUE@am__append_2052 = hdparm.mod
+@COND_i386_efi_TRUE@am__append_2053 = hdparm.marker
+@COND_i386_qemu_TRUE@am__append_2054 = hdparm.module
+@COND_i386_qemu_TRUE@am__append_2055 = hdparm.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2056 =
+@COND_i386_qemu_TRUE@am__append_2057 = $(nodist_hdparm_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2058 = \
+@COND_i386_qemu_TRUE@ $(nodist_hdparm_module_SOURCES) \
+@COND_i386_qemu_TRUE@ hdparm.marker
+@COND_i386_qemu_TRUE@am__append_2059 = hdparm.mod
+@COND_i386_qemu_TRUE@am__append_2060 = hdparm.marker
+@COND_i386_coreboot_TRUE@am__append_2061 = hdparm.module
+@COND_i386_coreboot_TRUE@am__append_2062 = hdparm.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2063 =
+@COND_i386_coreboot_TRUE@am__append_2064 = $(nodist_hdparm_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2065 = \
+@COND_i386_coreboot_TRUE@ $(nodist_hdparm_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ hdparm.marker
+@COND_i386_coreboot_TRUE@am__append_2066 = hdparm.mod
+@COND_i386_coreboot_TRUE@am__append_2067 = hdparm.marker
+@COND_i386_multiboot_TRUE@am__append_2068 = hdparm.module
+@COND_i386_multiboot_TRUE@am__append_2069 = hdparm.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2070 =
+@COND_i386_multiboot_TRUE@am__append_2071 = $(nodist_hdparm_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2072 = \
+@COND_i386_multiboot_TRUE@ $(nodist_hdparm_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ hdparm.marker
+@COND_i386_multiboot_TRUE@am__append_2073 = hdparm.mod
+@COND_i386_multiboot_TRUE@am__append_2074 = hdparm.marker
+@COND_i386_ieee1275_TRUE@am__append_2075 = hdparm.module
+@COND_i386_ieee1275_TRUE@am__append_2076 = hdparm.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2077 =
+@COND_i386_ieee1275_TRUE@am__append_2078 = $(nodist_hdparm_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2079 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_hdparm_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ hdparm.marker
+@COND_i386_ieee1275_TRUE@am__append_2080 = hdparm.mod
+@COND_i386_ieee1275_TRUE@am__append_2081 = hdparm.marker
+@COND_x86_64_efi_TRUE@am__append_2082 = hdparm.module
+@COND_x86_64_efi_TRUE@am__append_2083 = hdparm.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2084 =
+@COND_x86_64_efi_TRUE@am__append_2085 = $(nodist_hdparm_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2086 = \
+@COND_x86_64_efi_TRUE@ $(nodist_hdparm_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ hdparm.marker
+@COND_x86_64_efi_TRUE@am__append_2087 = hdparm.mod
+@COND_x86_64_efi_TRUE@am__append_2088 = hdparm.marker
+@COND_mips_loongson_TRUE@am__append_2089 = hdparm.module
+@COND_mips_loongson_TRUE@am__append_2090 = hdparm.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_2091 =
+@COND_mips_loongson_TRUE@am__append_2092 = $(nodist_hdparm_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_2093 = \
+@COND_mips_loongson_TRUE@ $(nodist_hdparm_module_SOURCES) \
+@COND_mips_loongson_TRUE@ hdparm.marker
+@COND_mips_loongson_TRUE@am__append_2094 = hdparm.mod
+@COND_mips_loongson_TRUE@am__append_2095 = hdparm.marker
+@COND_mips_qemu_mips_TRUE@am__append_2096 = hdparm.module
+@COND_mips_qemu_mips_TRUE@am__append_2097 = hdparm.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_2098 =
+@COND_mips_qemu_mips_TRUE@am__append_2099 = $(nodist_hdparm_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_2100 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_hdparm_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ hdparm.marker
+@COND_mips_qemu_mips_TRUE@am__append_2101 = hdparm.mod
+@COND_mips_qemu_mips_TRUE@am__append_2102 = hdparm.marker
+@COND_i386_efi_TRUE@am__append_2103 = loadbios.module
+@COND_i386_efi_TRUE@am__append_2104 = loadbios.module$(EXEEXT)
+@COND_i386_efi_FALSE@@COND_x86_64_efi_FALSE@loadbios_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_2105 =
+@COND_i386_efi_TRUE@am__append_2106 = $(nodist_loadbios_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2107 = \
+@COND_i386_efi_TRUE@ $(nodist_loadbios_module_SOURCES) \
+@COND_i386_efi_TRUE@ loadbios.marker
+@COND_i386_efi_TRUE@am__append_2108 = loadbios.mod
+@COND_i386_efi_TRUE@am__append_2109 = loadbios.marker
+@COND_x86_64_efi_TRUE@am__append_2110 = loadbios.module
+@COND_x86_64_efi_TRUE@am__append_2111 = loadbios.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2112 =
+@COND_x86_64_efi_TRUE@am__append_2113 = $(nodist_loadbios_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2114 = \
+@COND_x86_64_efi_TRUE@ $(nodist_loadbios_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ loadbios.marker
+@COND_x86_64_efi_TRUE@am__append_2115 = loadbios.mod
+@COND_x86_64_efi_TRUE@am__append_2116 = loadbios.marker
+@COND_i386_pc_TRUE@am__append_2117 = lspci.module
+@COND_i386_pc_TRUE@am__append_2118 = lspci.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@lspci_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2119 =
+@COND_i386_pc_TRUE@am__append_2120 = $(nodist_lspci_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2121 = $(nodist_lspci_module_SOURCES) \
+@COND_i386_pc_TRUE@ lspci.marker
+@COND_i386_pc_TRUE@am__append_2122 = lspci.mod
+@COND_i386_pc_TRUE@am__append_2123 = lspci.marker
+@COND_i386_efi_TRUE@am__append_2124 = lspci.module
+@COND_i386_efi_TRUE@am__append_2125 = lspci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2126 =
+@COND_i386_efi_TRUE@am__append_2127 = $(nodist_lspci_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2128 = $(nodist_lspci_module_SOURCES) \
+@COND_i386_efi_TRUE@ lspci.marker
+@COND_i386_efi_TRUE@am__append_2129 = lspci.mod
+@COND_i386_efi_TRUE@am__append_2130 = lspci.marker
+@COND_i386_qemu_TRUE@am__append_2131 = lspci.module
+@COND_i386_qemu_TRUE@am__append_2132 = lspci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2133 =
+@COND_i386_qemu_TRUE@am__append_2134 = $(nodist_lspci_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2135 = $(nodist_lspci_module_SOURCES) \
+@COND_i386_qemu_TRUE@ lspci.marker
+@COND_i386_qemu_TRUE@am__append_2136 = lspci.mod
+@COND_i386_qemu_TRUE@am__append_2137 = lspci.marker
+@COND_i386_coreboot_TRUE@am__append_2138 = lspci.module
+@COND_i386_coreboot_TRUE@am__append_2139 = lspci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2140 =
+@COND_i386_coreboot_TRUE@am__append_2141 = $(nodist_lspci_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2142 = \
+@COND_i386_coreboot_TRUE@ $(nodist_lspci_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ lspci.marker
+@COND_i386_coreboot_TRUE@am__append_2143 = lspci.mod
+@COND_i386_coreboot_TRUE@am__append_2144 = lspci.marker
+@COND_i386_multiboot_TRUE@am__append_2145 = lspci.module
+@COND_i386_multiboot_TRUE@am__append_2146 = lspci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2147 =
+@COND_i386_multiboot_TRUE@am__append_2148 = $(nodist_lspci_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2149 = \
+@COND_i386_multiboot_TRUE@ $(nodist_lspci_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ lspci.marker
+@COND_i386_multiboot_TRUE@am__append_2150 = lspci.mod
+@COND_i386_multiboot_TRUE@am__append_2151 = lspci.marker
+@COND_i386_ieee1275_TRUE@am__append_2152 = lspci.module
+@COND_i386_ieee1275_TRUE@am__append_2153 = lspci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2154 =
+@COND_i386_ieee1275_TRUE@am__append_2155 = $(nodist_lspci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2156 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_lspci_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ lspci.marker
+@COND_i386_ieee1275_TRUE@am__append_2157 = lspci.mod
+@COND_i386_ieee1275_TRUE@am__append_2158 = lspci.marker
+@COND_x86_64_efi_TRUE@am__append_2159 = lspci.module
+@COND_x86_64_efi_TRUE@am__append_2160 = lspci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2161 =
+@COND_x86_64_efi_TRUE@am__append_2162 = $(nodist_lspci_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2163 = \
+@COND_x86_64_efi_TRUE@ $(nodist_lspci_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ lspci.marker
+@COND_x86_64_efi_TRUE@am__append_2164 = lspci.mod
+@COND_x86_64_efi_TRUE@am__append_2165 = lspci.marker
+@COND_mips_loongson_TRUE@am__append_2166 = lspci.module
+@COND_mips_loongson_TRUE@am__append_2167 = lspci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_2168 =
+@COND_mips_loongson_TRUE@am__append_2169 = $(nodist_lspci_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_2170 = \
+@COND_mips_loongson_TRUE@ $(nodist_lspci_module_SOURCES) \
+@COND_mips_loongson_TRUE@ lspci.marker
+@COND_mips_loongson_TRUE@am__append_2171 = lspci.mod
+@COND_mips_loongson_TRUE@am__append_2172 = lspci.marker
+@COND_i386_pc_TRUE@am__append_2173 = play.module
+@COND_i386_pc_TRUE@am__append_2174 = play.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@play_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2175 =
+@COND_i386_pc_TRUE@am__append_2176 = $(nodist_play_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2177 = $(nodist_play_module_SOURCES) \
+@COND_i386_pc_TRUE@ play.marker
+@COND_i386_pc_TRUE@am__append_2178 = play.mod
+@COND_i386_pc_TRUE@am__append_2179 = play.marker
+@COND_i386_efi_TRUE@am__append_2180 = play.module
+@COND_i386_efi_TRUE@am__append_2181 = play.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2182 =
+@COND_i386_efi_TRUE@am__append_2183 = $(nodist_play_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2184 = $(nodist_play_module_SOURCES) \
+@COND_i386_efi_TRUE@ play.marker
+@COND_i386_efi_TRUE@am__append_2185 = play.mod
+@COND_i386_efi_TRUE@am__append_2186 = play.marker
+@COND_i386_qemu_TRUE@am__append_2187 = play.module
+@COND_i386_qemu_TRUE@am__append_2188 = play.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2189 =
+@COND_i386_qemu_TRUE@am__append_2190 = $(nodist_play_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2191 = $(nodist_play_module_SOURCES) \
+@COND_i386_qemu_TRUE@ play.marker
+@COND_i386_qemu_TRUE@am__append_2192 = play.mod
+@COND_i386_qemu_TRUE@am__append_2193 = play.marker
+@COND_i386_coreboot_TRUE@am__append_2194 = play.module
+@COND_i386_coreboot_TRUE@am__append_2195 = play.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2196 =
+@COND_i386_coreboot_TRUE@am__append_2197 = $(nodist_play_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2198 = \
+@COND_i386_coreboot_TRUE@ $(nodist_play_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ play.marker
+@COND_i386_coreboot_TRUE@am__append_2199 = play.mod
+@COND_i386_coreboot_TRUE@am__append_2200 = play.marker
+@COND_i386_multiboot_TRUE@am__append_2201 = play.module
+@COND_i386_multiboot_TRUE@am__append_2202 = play.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2203 =
+@COND_i386_multiboot_TRUE@am__append_2204 = $(nodist_play_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2205 = \
+@COND_i386_multiboot_TRUE@ $(nodist_play_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ play.marker
+@COND_i386_multiboot_TRUE@am__append_2206 = play.mod
+@COND_i386_multiboot_TRUE@am__append_2207 = play.marker
+@COND_i386_ieee1275_TRUE@am__append_2208 = play.module
+@COND_i386_ieee1275_TRUE@am__append_2209 = play.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2210 =
+@COND_i386_ieee1275_TRUE@am__append_2211 = $(nodist_play_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2212 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_play_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ play.marker
+@COND_i386_ieee1275_TRUE@am__append_2213 = play.mod
+@COND_i386_ieee1275_TRUE@am__append_2214 = play.marker
+@COND_x86_64_efi_TRUE@am__append_2215 = play.module
+@COND_x86_64_efi_TRUE@am__append_2216 = play.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2217 =
+@COND_x86_64_efi_TRUE@am__append_2218 = $(nodist_play_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2219 = $(nodist_play_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ play.marker
+@COND_x86_64_efi_TRUE@am__append_2220 = play.mod
+@COND_x86_64_efi_TRUE@am__append_2221 = play.marker
+@COND_i386_pc_TRUE@am__append_2222 = spkmodem.module
+@COND_i386_pc_TRUE@am__append_2223 = spkmodem.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@spkmodem_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2224 =
+@COND_i386_pc_TRUE@am__append_2225 = $(nodist_spkmodem_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2226 = \
+@COND_i386_pc_TRUE@ $(nodist_spkmodem_module_SOURCES) \
+@COND_i386_pc_TRUE@ spkmodem.marker
+@COND_i386_pc_TRUE@am__append_2227 = spkmodem.mod
+@COND_i386_pc_TRUE@am__append_2228 = spkmodem.marker
+@COND_i386_efi_TRUE@am__append_2229 = spkmodem.module
+@COND_i386_efi_TRUE@am__append_2230 = spkmodem.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2231 =
+@COND_i386_efi_TRUE@am__append_2232 = $(nodist_spkmodem_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2233 = \
+@COND_i386_efi_TRUE@ $(nodist_spkmodem_module_SOURCES) \
+@COND_i386_efi_TRUE@ spkmodem.marker
+@COND_i386_efi_TRUE@am__append_2234 = spkmodem.mod
+@COND_i386_efi_TRUE@am__append_2235 = spkmodem.marker
+@COND_i386_qemu_TRUE@am__append_2236 = spkmodem.module
+@COND_i386_qemu_TRUE@am__append_2237 = spkmodem.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2238 =
+@COND_i386_qemu_TRUE@am__append_2239 = $(nodist_spkmodem_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2240 = \
+@COND_i386_qemu_TRUE@ $(nodist_spkmodem_module_SOURCES) \
+@COND_i386_qemu_TRUE@ spkmodem.marker
+@COND_i386_qemu_TRUE@am__append_2241 = spkmodem.mod
+@COND_i386_qemu_TRUE@am__append_2242 = spkmodem.marker
+@COND_i386_coreboot_TRUE@am__append_2243 = spkmodem.module
+@COND_i386_coreboot_TRUE@am__append_2244 = spkmodem.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2245 =
+@COND_i386_coreboot_TRUE@am__append_2246 = $(nodist_spkmodem_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2247 = \
+@COND_i386_coreboot_TRUE@ $(nodist_spkmodem_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ spkmodem.marker
+@COND_i386_coreboot_TRUE@am__append_2248 = spkmodem.mod
+@COND_i386_coreboot_TRUE@am__append_2249 = spkmodem.marker
+@COND_i386_multiboot_TRUE@am__append_2250 = spkmodem.module
+@COND_i386_multiboot_TRUE@am__append_2251 = spkmodem.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2252 =
+@COND_i386_multiboot_TRUE@am__append_2253 = $(nodist_spkmodem_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2254 = \
+@COND_i386_multiboot_TRUE@ $(nodist_spkmodem_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ spkmodem.marker
+@COND_i386_multiboot_TRUE@am__append_2255 = spkmodem.mod
+@COND_i386_multiboot_TRUE@am__append_2256 = spkmodem.marker
+@COND_i386_ieee1275_TRUE@am__append_2257 = spkmodem.module
+@COND_i386_ieee1275_TRUE@am__append_2258 = spkmodem.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2259 =
+@COND_i386_ieee1275_TRUE@am__append_2260 = $(nodist_spkmodem_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2261 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_spkmodem_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ spkmodem.marker
+@COND_i386_ieee1275_TRUE@am__append_2262 = spkmodem.mod
+@COND_i386_ieee1275_TRUE@am__append_2263 = spkmodem.marker
+@COND_x86_64_efi_TRUE@am__append_2264 = spkmodem.module
+@COND_x86_64_efi_TRUE@am__append_2265 = spkmodem.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2266 =
+@COND_x86_64_efi_TRUE@am__append_2267 = $(nodist_spkmodem_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2268 = \
+@COND_x86_64_efi_TRUE@ $(nodist_spkmodem_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ spkmodem.marker
+@COND_x86_64_efi_TRUE@am__append_2269 = spkmodem.mod
+@COND_x86_64_efi_TRUE@am__append_2270 = spkmodem.marker
+@COND_i386_pc_TRUE@am__append_2271 = morse.module
+@COND_i386_pc_TRUE@am__append_2272 = morse.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@morse_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2273 =
+@COND_i386_pc_TRUE@am__append_2274 = $(nodist_morse_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2275 = $(nodist_morse_module_SOURCES) \
+@COND_i386_pc_TRUE@ morse.marker
+@COND_i386_pc_TRUE@am__append_2276 = morse.mod
+@COND_i386_pc_TRUE@am__append_2277 = morse.marker
+@COND_i386_efi_TRUE@am__append_2278 = morse.module
+@COND_i386_efi_TRUE@am__append_2279 = morse.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2280 =
+@COND_i386_efi_TRUE@am__append_2281 = $(nodist_morse_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2282 = $(nodist_morse_module_SOURCES) \
+@COND_i386_efi_TRUE@ morse.marker
+@COND_i386_efi_TRUE@am__append_2283 = morse.mod
+@COND_i386_efi_TRUE@am__append_2284 = morse.marker
+@COND_i386_qemu_TRUE@am__append_2285 = morse.module
+@COND_i386_qemu_TRUE@am__append_2286 = morse.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2287 =
+@COND_i386_qemu_TRUE@am__append_2288 = $(nodist_morse_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2289 = $(nodist_morse_module_SOURCES) \
+@COND_i386_qemu_TRUE@ morse.marker
+@COND_i386_qemu_TRUE@am__append_2290 = morse.mod
+@COND_i386_qemu_TRUE@am__append_2291 = morse.marker
+@COND_i386_coreboot_TRUE@am__append_2292 = morse.module
+@COND_i386_coreboot_TRUE@am__append_2293 = morse.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2294 =
+@COND_i386_coreboot_TRUE@am__append_2295 = $(nodist_morse_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2296 = \
+@COND_i386_coreboot_TRUE@ $(nodist_morse_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ morse.marker
+@COND_i386_coreboot_TRUE@am__append_2297 = morse.mod
+@COND_i386_coreboot_TRUE@am__append_2298 = morse.marker
+@COND_i386_multiboot_TRUE@am__append_2299 = morse.module
+@COND_i386_multiboot_TRUE@am__append_2300 = morse.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2301 =
+@COND_i386_multiboot_TRUE@am__append_2302 = $(nodist_morse_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2303 = \
+@COND_i386_multiboot_TRUE@ $(nodist_morse_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ morse.marker
+@COND_i386_multiboot_TRUE@am__append_2304 = morse.mod
+@COND_i386_multiboot_TRUE@am__append_2305 = morse.marker
+@COND_i386_ieee1275_TRUE@am__append_2306 = morse.module
+@COND_i386_ieee1275_TRUE@am__append_2307 = morse.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2308 =
+@COND_i386_ieee1275_TRUE@am__append_2309 = $(nodist_morse_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2310 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_morse_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ morse.marker
+@COND_i386_ieee1275_TRUE@am__append_2311 = morse.mod
+@COND_i386_ieee1275_TRUE@am__append_2312 = morse.marker
+@COND_x86_64_efi_TRUE@am__append_2313 = morse.module
+@COND_x86_64_efi_TRUE@am__append_2314 = morse.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2315 =
+@COND_x86_64_efi_TRUE@am__append_2316 = $(nodist_morse_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2317 = \
+@COND_x86_64_efi_TRUE@ $(nodist_morse_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ morse.marker
+@COND_x86_64_efi_TRUE@am__append_2318 = morse.mod
+@COND_x86_64_efi_TRUE@am__append_2319 = morse.marker
+@COND_i386_pc_TRUE@am__append_2320 = setpci.module
+@COND_i386_pc_TRUE@am__append_2321 = setpci.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@setpci_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2322 =
+@COND_i386_pc_TRUE@am__append_2323 = $(nodist_setpci_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2324 = $(nodist_setpci_module_SOURCES) \
+@COND_i386_pc_TRUE@ setpci.marker
+@COND_i386_pc_TRUE@am__append_2325 = setpci.mod
+@COND_i386_pc_TRUE@am__append_2326 = setpci.marker
+@COND_i386_efi_TRUE@am__append_2327 = setpci.module
+@COND_i386_efi_TRUE@am__append_2328 = setpci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2329 =
+@COND_i386_efi_TRUE@am__append_2330 = $(nodist_setpci_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2331 = $(nodist_setpci_module_SOURCES) \
+@COND_i386_efi_TRUE@ setpci.marker
+@COND_i386_efi_TRUE@am__append_2332 = setpci.mod
+@COND_i386_efi_TRUE@am__append_2333 = setpci.marker
+@COND_i386_qemu_TRUE@am__append_2334 = setpci.module
+@COND_i386_qemu_TRUE@am__append_2335 = setpci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2336 =
+@COND_i386_qemu_TRUE@am__append_2337 = $(nodist_setpci_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2338 = \
+@COND_i386_qemu_TRUE@ $(nodist_setpci_module_SOURCES) \
+@COND_i386_qemu_TRUE@ setpci.marker
+@COND_i386_qemu_TRUE@am__append_2339 = setpci.mod
+@COND_i386_qemu_TRUE@am__append_2340 = setpci.marker
+@COND_i386_coreboot_TRUE@am__append_2341 = setpci.module
+@COND_i386_coreboot_TRUE@am__append_2342 = setpci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2343 =
+@COND_i386_coreboot_TRUE@am__append_2344 = $(nodist_setpci_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2345 = \
+@COND_i386_coreboot_TRUE@ $(nodist_setpci_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ setpci.marker
+@COND_i386_coreboot_TRUE@am__append_2346 = setpci.mod
+@COND_i386_coreboot_TRUE@am__append_2347 = setpci.marker
+@COND_i386_multiboot_TRUE@am__append_2348 = setpci.module
+@COND_i386_multiboot_TRUE@am__append_2349 = setpci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2350 =
+@COND_i386_multiboot_TRUE@am__append_2351 = $(nodist_setpci_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2352 = \
+@COND_i386_multiboot_TRUE@ $(nodist_setpci_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ setpci.marker
+@COND_i386_multiboot_TRUE@am__append_2353 = setpci.mod
+@COND_i386_multiboot_TRUE@am__append_2354 = setpci.marker
+@COND_i386_ieee1275_TRUE@am__append_2355 = setpci.module
+@COND_i386_ieee1275_TRUE@am__append_2356 = setpci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2357 =
+@COND_i386_ieee1275_TRUE@am__append_2358 = $(nodist_setpci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2359 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_setpci_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ setpci.marker
+@COND_i386_ieee1275_TRUE@am__append_2360 = setpci.mod
+@COND_i386_ieee1275_TRUE@am__append_2361 = setpci.marker
+@COND_x86_64_efi_TRUE@am__append_2362 = setpci.module
+@COND_x86_64_efi_TRUE@am__append_2363 = setpci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2364 =
+@COND_x86_64_efi_TRUE@am__append_2365 = $(nodist_setpci_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2366 = \
+@COND_x86_64_efi_TRUE@ $(nodist_setpci_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ setpci.marker
+@COND_x86_64_efi_TRUE@am__append_2367 = setpci.mod
+@COND_x86_64_efi_TRUE@am__append_2368 = setpci.marker
+@COND_mips_loongson_TRUE@am__append_2369 = setpci.module
+@COND_mips_loongson_TRUE@am__append_2370 = setpci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_2371 =
+@COND_mips_loongson_TRUE@am__append_2372 = $(nodist_setpci_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_2373 = \
+@COND_mips_loongson_TRUE@ $(nodist_setpci_module_SOURCES) \
+@COND_mips_loongson_TRUE@ setpci.marker
+@COND_mips_loongson_TRUE@am__append_2374 = setpci.mod
+@COND_mips_loongson_TRUE@am__append_2375 = setpci.marker
+@COND_i386_pc_TRUE@am__append_2376 = pcidump.module
+@COND_i386_pc_TRUE@am__append_2377 = pcidump.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@pcidump_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2378 =
+@COND_i386_pc_TRUE@am__append_2379 = $(nodist_pcidump_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2380 = $(nodist_pcidump_module_SOURCES) \
+@COND_i386_pc_TRUE@ pcidump.marker
+@COND_i386_pc_TRUE@am__append_2381 = pcidump.mod
+@COND_i386_pc_TRUE@am__append_2382 = pcidump.marker
+@COND_i386_efi_TRUE@am__append_2383 = pcidump.module
+@COND_i386_efi_TRUE@am__append_2384 = pcidump.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2385 =
+@COND_i386_efi_TRUE@am__append_2386 = $(nodist_pcidump_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2387 = \
+@COND_i386_efi_TRUE@ $(nodist_pcidump_module_SOURCES) \
+@COND_i386_efi_TRUE@ pcidump.marker
+@COND_i386_efi_TRUE@am__append_2388 = pcidump.mod
+@COND_i386_efi_TRUE@am__append_2389 = pcidump.marker
+@COND_i386_qemu_TRUE@am__append_2390 = pcidump.module
+@COND_i386_qemu_TRUE@am__append_2391 = pcidump.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2392 =
+@COND_i386_qemu_TRUE@am__append_2393 = $(nodist_pcidump_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2394 = \
+@COND_i386_qemu_TRUE@ $(nodist_pcidump_module_SOURCES) \
+@COND_i386_qemu_TRUE@ pcidump.marker
+@COND_i386_qemu_TRUE@am__append_2395 = pcidump.mod
+@COND_i386_qemu_TRUE@am__append_2396 = pcidump.marker
+@COND_i386_coreboot_TRUE@am__append_2397 = pcidump.module
+@COND_i386_coreboot_TRUE@am__append_2398 = pcidump.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2399 =
+@COND_i386_coreboot_TRUE@am__append_2400 = $(nodist_pcidump_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2401 = \
+@COND_i386_coreboot_TRUE@ $(nodist_pcidump_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ pcidump.marker
+@COND_i386_coreboot_TRUE@am__append_2402 = pcidump.mod
+@COND_i386_coreboot_TRUE@am__append_2403 = pcidump.marker
+@COND_i386_multiboot_TRUE@am__append_2404 = pcidump.module
+@COND_i386_multiboot_TRUE@am__append_2405 = pcidump.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2406 =
+@COND_i386_multiboot_TRUE@am__append_2407 = $(nodist_pcidump_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2408 = \
+@COND_i386_multiboot_TRUE@ $(nodist_pcidump_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ pcidump.marker
+@COND_i386_multiboot_TRUE@am__append_2409 = pcidump.mod
+@COND_i386_multiboot_TRUE@am__append_2410 = pcidump.marker
+@COND_i386_ieee1275_TRUE@am__append_2411 = pcidump.module
+@COND_i386_ieee1275_TRUE@am__append_2412 = pcidump.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2413 =
+@COND_i386_ieee1275_TRUE@am__append_2414 = $(nodist_pcidump_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2415 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_pcidump_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ pcidump.marker
+@COND_i386_ieee1275_TRUE@am__append_2416 = pcidump.mod
+@COND_i386_ieee1275_TRUE@am__append_2417 = pcidump.marker
+@COND_x86_64_efi_TRUE@am__append_2418 = pcidump.module
+@COND_x86_64_efi_TRUE@am__append_2419 = pcidump.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2420 =
+@COND_x86_64_efi_TRUE@am__append_2421 = $(nodist_pcidump_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2422 = \
+@COND_x86_64_efi_TRUE@ $(nodist_pcidump_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ pcidump.marker
+@COND_x86_64_efi_TRUE@am__append_2423 = pcidump.mod
+@COND_x86_64_efi_TRUE@am__append_2424 = pcidump.marker
+@COND_mips_loongson_TRUE@am__append_2425 = pcidump.module
+@COND_mips_loongson_TRUE@am__append_2426 = pcidump.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_2427 =
+@COND_mips_loongson_TRUE@am__append_2428 = $(nodist_pcidump_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_2429 = \
+@COND_mips_loongson_TRUE@ $(nodist_pcidump_module_SOURCES) \
+@COND_mips_loongson_TRUE@ pcidump.marker
+@COND_mips_loongson_TRUE@am__append_2430 = pcidump.mod
+@COND_mips_loongson_TRUE@am__append_2431 = pcidump.marker
+@COND_i386_pc_TRUE@am__append_2432 = smbios.module
+@COND_i386_pc_TRUE@am__append_2433 = smbios.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@smbios_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2434 =
+@COND_i386_pc_TRUE@am__append_2435 = $(nodist_smbios_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2436 = $(nodist_smbios_module_SOURCES) \
+@COND_i386_pc_TRUE@ smbios.marker
+@COND_i386_pc_TRUE@am__append_2437 = smbios.mod
+@COND_i386_pc_TRUE@am__append_2438 = smbios.marker
+@COND_i386_efi_TRUE@am__append_2439 = smbios.module
+@COND_i386_efi_TRUE@am__append_2440 = smbios.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2441 =
+@COND_i386_efi_TRUE@am__append_2442 = $(nodist_smbios_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2443 = $(nodist_smbios_module_SOURCES) \
+@COND_i386_efi_TRUE@ smbios.marker
+@COND_i386_efi_TRUE@am__append_2444 = smbios.mod
+@COND_i386_efi_TRUE@am__append_2445 = smbios.marker
+@COND_i386_coreboot_TRUE@am__append_2446 = smbios.module
+@COND_i386_coreboot_TRUE@am__append_2447 = smbios.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2448 =
+@COND_i386_coreboot_TRUE@am__append_2449 = $(nodist_smbios_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2450 = \
+@COND_i386_coreboot_TRUE@ $(nodist_smbios_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ smbios.marker
+@COND_i386_coreboot_TRUE@am__append_2451 = smbios.mod
+@COND_i386_coreboot_TRUE@am__append_2452 = smbios.marker
+@COND_i386_multiboot_TRUE@am__append_2453 = smbios.module
+@COND_i386_multiboot_TRUE@am__append_2454 = smbios.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2455 =
+@COND_i386_multiboot_TRUE@am__append_2456 = $(nodist_smbios_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2457 = \
+@COND_i386_multiboot_TRUE@ $(nodist_smbios_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ smbios.marker
+@COND_i386_multiboot_TRUE@am__append_2458 = smbios.mod
+@COND_i386_multiboot_TRUE@am__append_2459 = smbios.marker
+@COND_x86_64_efi_TRUE@am__append_2460 = smbios.module
+@COND_x86_64_efi_TRUE@am__append_2461 = smbios.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2462 =
+@COND_x86_64_efi_TRUE@am__append_2463 = $(nodist_smbios_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2464 = \
+@COND_x86_64_efi_TRUE@ $(nodist_smbios_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ smbios.marker
+@COND_x86_64_efi_TRUE@am__append_2465 = smbios.mod
+@COND_x86_64_efi_TRUE@am__append_2466 = smbios.marker
+@COND_ia64_efi_TRUE@am__append_2467 = smbios.module
+@COND_ia64_efi_TRUE@am__append_2468 = smbios.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_2469 =
+@COND_ia64_efi_TRUE@am__append_2470 = $(nodist_smbios_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_2471 = $(nodist_smbios_module_SOURCES) \
+@COND_ia64_efi_TRUE@ smbios.marker
+@COND_ia64_efi_TRUE@am__append_2472 = smbios.mod
+@COND_ia64_efi_TRUE@am__append_2473 = smbios.marker
+@COND_arm_efi_TRUE@am__append_2474 = smbios.module
+@COND_arm_efi_TRUE@am__append_2475 = smbios.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_2476 =
+@COND_arm_efi_TRUE@am__append_2477 = $(nodist_smbios_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_2478 = $(nodist_smbios_module_SOURCES) \
+@COND_arm_efi_TRUE@ smbios.marker
+@COND_arm_efi_TRUE@am__append_2479 = smbios.mod
+@COND_arm_efi_TRUE@am__append_2480 = smbios.marker
+@COND_arm64_efi_TRUE@am__append_2481 = smbios.module
+@COND_arm64_efi_TRUE@am__append_2482 = smbios.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_2483 =
+@COND_arm64_efi_TRUE@am__append_2484 = $(nodist_smbios_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_2485 = \
+@COND_arm64_efi_TRUE@ $(nodist_smbios_module_SOURCES) \
+@COND_arm64_efi_TRUE@ smbios.marker
+@COND_arm64_efi_TRUE@am__append_2486 = smbios.mod
+@COND_arm64_efi_TRUE@am__append_2487 = smbios.marker
+@COND_riscv32_efi_TRUE@am__append_2488 = smbios.module
+@COND_riscv32_efi_TRUE@am__append_2489 = smbios.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_2490 =
+@COND_riscv32_efi_TRUE@am__append_2491 = $(nodist_smbios_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_2492 = \
+@COND_riscv32_efi_TRUE@ $(nodist_smbios_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ smbios.marker
+@COND_riscv32_efi_TRUE@am__append_2493 = smbios.mod
+@COND_riscv32_efi_TRUE@am__append_2494 = smbios.marker
+@COND_riscv64_efi_TRUE@am__append_2495 = smbios.module
+@COND_riscv64_efi_TRUE@am__append_2496 = smbios.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_2497 =
+@COND_riscv64_efi_TRUE@am__append_2498 = $(nodist_smbios_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_2499 = \
+@COND_riscv64_efi_TRUE@ $(nodist_smbios_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ smbios.marker
+@COND_riscv64_efi_TRUE@am__append_2500 = smbios.mod
+@COND_riscv64_efi_TRUE@am__append_2501 = smbios.marker
+@COND_i386_ieee1275_TRUE@am__append_2502 = suspend.module
+@COND_i386_ieee1275_TRUE@am__append_2503 = suspend.module$(EXEEXT)
+@COND_i386_ieee1275_FALSE@@COND_powerpc_ieee1275_FALSE@suspend_module_DEPENDENCIES =
+@COND_i386_ieee1275_TRUE@am__append_2504 =
+@COND_i386_ieee1275_TRUE@am__append_2505 = $(nodist_suspend_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2506 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_suspend_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ suspend.marker
+@COND_i386_ieee1275_TRUE@am__append_2507 = suspend.mod
+@COND_i386_ieee1275_TRUE@am__append_2508 = suspend.marker
+@COND_powerpc_ieee1275_TRUE@am__append_2509 = suspend.module \
+@COND_powerpc_ieee1275_TRUE@ escc.module
+@COND_powerpc_ieee1275_TRUE@am__append_2510 = suspend.module$(EXEEXT) \
+@COND_powerpc_ieee1275_TRUE@ escc.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_2511 =
+@COND_powerpc_ieee1275_TRUE@am__append_2512 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_suspend_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_escc_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_2513 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_suspend_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ suspend.marker \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_escc_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ escc.marker
+@COND_powerpc_ieee1275_TRUE@am__append_2514 = suspend.mod escc.mod
+@COND_powerpc_ieee1275_TRUE@am__append_2515 = suspend.marker \
+@COND_powerpc_ieee1275_TRUE@ escc.marker
+@COND_powerpc_ieee1275_FALSE@escc_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2516 = usbtest.module
+@COND_i386_pc_TRUE@am__append_2517 = usbtest.module$(EXEEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@usbtest_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2518 =
+@COND_i386_pc_TRUE@am__append_2519 = $(nodist_usbtest_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2520 = $(nodist_usbtest_module_SOURCES) \
+@COND_i386_pc_TRUE@ usbtest.marker
+@COND_i386_pc_TRUE@am__append_2521 = usbtest.mod
+@COND_i386_pc_TRUE@am__append_2522 = usbtest.marker
+@COND_i386_efi_TRUE@am__append_2523 = usbtest.module
+@COND_i386_efi_TRUE@am__append_2524 = usbtest.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2525 =
+@COND_i386_efi_TRUE@am__append_2526 = $(nodist_usbtest_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2527 = \
+@COND_i386_efi_TRUE@ $(nodist_usbtest_module_SOURCES) \
+@COND_i386_efi_TRUE@ usbtest.marker
+@COND_i386_efi_TRUE@am__append_2528 = usbtest.mod
+@COND_i386_efi_TRUE@am__append_2529 = usbtest.marker
+@COND_i386_qemu_TRUE@am__append_2530 = usbtest.module
+@COND_i386_qemu_TRUE@am__append_2531 = usbtest.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2532 =
+@COND_i386_qemu_TRUE@am__append_2533 = $(nodist_usbtest_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2534 = \
+@COND_i386_qemu_TRUE@ $(nodist_usbtest_module_SOURCES) \
+@COND_i386_qemu_TRUE@ usbtest.marker
+@COND_i386_qemu_TRUE@am__append_2535 = usbtest.mod
+@COND_i386_qemu_TRUE@am__append_2536 = usbtest.marker
+@COND_i386_coreboot_TRUE@am__append_2537 = usbtest.module
+@COND_i386_coreboot_TRUE@am__append_2538 = usbtest.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2539 =
+@COND_i386_coreboot_TRUE@am__append_2540 = $(nodist_usbtest_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2541 = \
+@COND_i386_coreboot_TRUE@ $(nodist_usbtest_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ usbtest.marker
+@COND_i386_coreboot_TRUE@am__append_2542 = usbtest.mod
+@COND_i386_coreboot_TRUE@am__append_2543 = usbtest.marker
+@COND_i386_multiboot_TRUE@am__append_2544 = usbtest.module
+@COND_i386_multiboot_TRUE@am__append_2545 = usbtest.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2546 =
+@COND_i386_multiboot_TRUE@am__append_2547 = $(nodist_usbtest_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2548 = \
+@COND_i386_multiboot_TRUE@ $(nodist_usbtest_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ usbtest.marker
+@COND_i386_multiboot_TRUE@am__append_2549 = usbtest.mod
+@COND_i386_multiboot_TRUE@am__append_2550 = usbtest.marker
+@COND_i386_ieee1275_TRUE@am__append_2551 = usbtest.module
+@COND_i386_ieee1275_TRUE@am__append_2552 = usbtest.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2553 =
+@COND_i386_ieee1275_TRUE@am__append_2554 = $(nodist_usbtest_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2555 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_usbtest_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ usbtest.marker
+@COND_i386_ieee1275_TRUE@am__append_2556 = usbtest.mod
+@COND_i386_ieee1275_TRUE@am__append_2557 = usbtest.marker
+@COND_x86_64_efi_TRUE@am__append_2558 = usbtest.module
+@COND_x86_64_efi_TRUE@am__append_2559 = usbtest.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2560 =
+@COND_x86_64_efi_TRUE@am__append_2561 = $(nodist_usbtest_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2562 = \
+@COND_x86_64_efi_TRUE@ $(nodist_usbtest_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ usbtest.marker
+@COND_x86_64_efi_TRUE@am__append_2563 = usbtest.mod
+@COND_x86_64_efi_TRUE@am__append_2564 = usbtest.marker
+@COND_mips_loongson_TRUE@am__append_2565 = usbtest.module
+@COND_mips_loongson_TRUE@am__append_2566 = usbtest.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_2567 =
+@COND_mips_loongson_TRUE@am__append_2568 = $(nodist_usbtest_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_2569 = \
+@COND_mips_loongson_TRUE@ $(nodist_usbtest_module_SOURCES) \
+@COND_mips_loongson_TRUE@ usbtest.marker
+@COND_mips_loongson_TRUE@am__append_2570 = usbtest.mod
+@COND_mips_loongson_TRUE@am__append_2571 = usbtest.marker
+@COND_arm_coreboot_TRUE@am__append_2572 = usbtest.module
+@COND_arm_coreboot_TRUE@am__append_2573 = usbtest.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_2574 =
+@COND_arm_coreboot_TRUE@am__append_2575 = $(nodist_usbtest_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_2576 = \
+@COND_arm_coreboot_TRUE@ $(nodist_usbtest_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ usbtest.marker
+@COND_arm_coreboot_TRUE@am__append_2577 = usbtest.mod
+@COND_arm_coreboot_TRUE@am__append_2578 = usbtest.marker
+@COND_i386_pc_TRUE@am__append_2579 = ata.module
+@COND_i386_pc_TRUE@am__append_2580 = ata.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_FALSE@ata_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2581 =
+@COND_i386_pc_TRUE@am__append_2582 = $(nodist_ata_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2583 = $(nodist_ata_module_SOURCES) \
+@COND_i386_pc_TRUE@ ata.marker
+@COND_i386_pc_TRUE@am__append_2584 = ata.mod
+@COND_i386_pc_TRUE@am__append_2585 = ata.marker
+@COND_i386_efi_TRUE@am__append_2586 = ata.module
+@COND_i386_efi_TRUE@am__append_2587 = ata.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2588 =
+@COND_i386_efi_TRUE@am__append_2589 = $(nodist_ata_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2590 = $(nodist_ata_module_SOURCES) \
+@COND_i386_efi_TRUE@ ata.marker
+@COND_i386_efi_TRUE@am__append_2591 = ata.mod
+@COND_i386_efi_TRUE@am__append_2592 = ata.marker
+@COND_i386_qemu_TRUE@am__append_2593 = ata.module
+@COND_i386_qemu_TRUE@am__append_2594 = ata.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2595 =
+@COND_i386_qemu_TRUE@am__append_2596 = $(nodist_ata_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2597 = $(nodist_ata_module_SOURCES) \
+@COND_i386_qemu_TRUE@ ata.marker
+@COND_i386_qemu_TRUE@am__append_2598 = ata.mod
+@COND_i386_qemu_TRUE@am__append_2599 = ata.marker
+@COND_i386_coreboot_TRUE@am__append_2600 = ata.module
+@COND_i386_coreboot_TRUE@am__append_2601 = ata.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2602 =
+@COND_i386_coreboot_TRUE@am__append_2603 = $(nodist_ata_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2604 = \
+@COND_i386_coreboot_TRUE@ $(nodist_ata_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ ata.marker
+@COND_i386_coreboot_TRUE@am__append_2605 = ata.mod
+@COND_i386_coreboot_TRUE@am__append_2606 = ata.marker
+@COND_i386_multiboot_TRUE@am__append_2607 = ata.module
+@COND_i386_multiboot_TRUE@am__append_2608 = ata.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2609 =
+@COND_i386_multiboot_TRUE@am__append_2610 = $(nodist_ata_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2611 = \
+@COND_i386_multiboot_TRUE@ $(nodist_ata_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ ata.marker
+@COND_i386_multiboot_TRUE@am__append_2612 = ata.mod
+@COND_i386_multiboot_TRUE@am__append_2613 = ata.marker
+@COND_i386_ieee1275_TRUE@am__append_2614 = ata.module
+@COND_i386_ieee1275_TRUE@am__append_2615 = ata.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2616 =
+@COND_i386_ieee1275_TRUE@am__append_2617 = $(nodist_ata_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2618 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_ata_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ ata.marker
+@COND_i386_ieee1275_TRUE@am__append_2619 = ata.mod
+@COND_i386_ieee1275_TRUE@am__append_2620 = ata.marker
+@COND_x86_64_efi_TRUE@am__append_2621 = ata.module
+@COND_x86_64_efi_TRUE@am__append_2622 = ata.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2623 =
+@COND_x86_64_efi_TRUE@am__append_2624 = $(nodist_ata_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2625 = $(nodist_ata_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ ata.marker
+@COND_x86_64_efi_TRUE@am__append_2626 = ata.mod
+@COND_x86_64_efi_TRUE@am__append_2627 = ata.marker
+@COND_mips_loongson_TRUE@am__append_2628 = ata.module
+@COND_mips_loongson_TRUE@am__append_2629 = ata.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_2630 =
+@COND_mips_loongson_TRUE@am__append_2631 = $(nodist_ata_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_2632 = \
+@COND_mips_loongson_TRUE@ $(nodist_ata_module_SOURCES) \
+@COND_mips_loongson_TRUE@ ata.marker
+@COND_mips_loongson_TRUE@am__append_2633 = ata.mod
+@COND_mips_loongson_TRUE@am__append_2634 = ata.marker
+@COND_mips_qemu_mips_TRUE@am__append_2635 = ata.module
+@COND_mips_qemu_mips_TRUE@am__append_2636 = ata.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_2637 =
+@COND_mips_qemu_mips_TRUE@am__append_2638 = $(nodist_ata_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_2639 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_ata_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ ata.marker
+@COND_mips_qemu_mips_TRUE@am__append_2640 = ata.mod
+@COND_mips_qemu_mips_TRUE@am__append_2641 = ata.marker
+@COND_i386_pc_TRUE@am__append_2642 = ahci.module
+@COND_i386_pc_TRUE@am__append_2643 = ahci.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@ahci_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2644 =
+@COND_i386_pc_TRUE@am__append_2645 = $(nodist_ahci_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2646 = $(nodist_ahci_module_SOURCES) \
+@COND_i386_pc_TRUE@ ahci.marker
+@COND_i386_pc_TRUE@am__append_2647 = ahci.mod
+@COND_i386_pc_TRUE@am__append_2648 = ahci.marker
+@COND_i386_efi_TRUE@am__append_2649 = ahci.module
+@COND_i386_efi_TRUE@am__append_2650 = ahci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2651 =
+@COND_i386_efi_TRUE@am__append_2652 = $(nodist_ahci_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2653 = $(nodist_ahci_module_SOURCES) \
+@COND_i386_efi_TRUE@ ahci.marker
+@COND_i386_efi_TRUE@am__append_2654 = ahci.mod
+@COND_i386_efi_TRUE@am__append_2655 = ahci.marker
+@COND_i386_qemu_TRUE@am__append_2656 = ahci.module
+@COND_i386_qemu_TRUE@am__append_2657 = ahci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2658 =
+@COND_i386_qemu_TRUE@am__append_2659 = $(nodist_ahci_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2660 = $(nodist_ahci_module_SOURCES) \
+@COND_i386_qemu_TRUE@ ahci.marker
+@COND_i386_qemu_TRUE@am__append_2661 = ahci.mod
+@COND_i386_qemu_TRUE@am__append_2662 = ahci.marker
+@COND_i386_coreboot_TRUE@am__append_2663 = ahci.module
+@COND_i386_coreboot_TRUE@am__append_2664 = ahci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2665 =
+@COND_i386_coreboot_TRUE@am__append_2666 = $(nodist_ahci_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2667 = \
+@COND_i386_coreboot_TRUE@ $(nodist_ahci_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ ahci.marker
+@COND_i386_coreboot_TRUE@am__append_2668 = ahci.mod
+@COND_i386_coreboot_TRUE@am__append_2669 = ahci.marker
+@COND_i386_multiboot_TRUE@am__append_2670 = ahci.module
+@COND_i386_multiboot_TRUE@am__append_2671 = ahci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2672 =
+@COND_i386_multiboot_TRUE@am__append_2673 = $(nodist_ahci_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2674 = \
+@COND_i386_multiboot_TRUE@ $(nodist_ahci_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ ahci.marker
+@COND_i386_multiboot_TRUE@am__append_2675 = ahci.mod
+@COND_i386_multiboot_TRUE@am__append_2676 = ahci.marker
+@COND_i386_ieee1275_TRUE@am__append_2677 = ahci.module
+@COND_i386_ieee1275_TRUE@am__append_2678 = ahci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2679 =
+@COND_i386_ieee1275_TRUE@am__append_2680 = $(nodist_ahci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2681 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_ahci_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ ahci.marker
+@COND_i386_ieee1275_TRUE@am__append_2682 = ahci.mod
+@COND_i386_ieee1275_TRUE@am__append_2683 = ahci.marker
+@COND_x86_64_efi_TRUE@am__append_2684 = ahci.module
+@COND_x86_64_efi_TRUE@am__append_2685 = ahci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2686 =
+@COND_x86_64_efi_TRUE@am__append_2687 = $(nodist_ahci_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2688 = $(nodist_ahci_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ ahci.marker
+@COND_x86_64_efi_TRUE@am__append_2689 = ahci.mod
+@COND_x86_64_efi_TRUE@am__append_2690 = ahci.marker
+@COND_mips_loongson_TRUE@am__append_2691 = ahci.module
+@COND_mips_loongson_TRUE@am__append_2692 = ahci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_2693 =
+@COND_mips_loongson_TRUE@am__append_2694 = $(nodist_ahci_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_2695 = \
+@COND_mips_loongson_TRUE@ $(nodist_ahci_module_SOURCES) \
+@COND_mips_loongson_TRUE@ ahci.marker
+@COND_mips_loongson_TRUE@am__append_2696 = ahci.mod
+@COND_mips_loongson_TRUE@am__append_2697 = ahci.marker
+@COND_i386_pc_TRUE@am__append_2698 = pata.module
+@COND_i386_pc_TRUE@am__append_2699 = pata.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_FALSE@pata_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2700 =
+@COND_i386_pc_TRUE@am__append_2701 = $(nodist_pata_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2702 = $(nodist_pata_module_SOURCES) \
+@COND_i386_pc_TRUE@ pata.marker
+@COND_i386_pc_TRUE@am__append_2703 = pata.mod
+@COND_i386_pc_TRUE@am__append_2704 = pata.marker
+@COND_i386_efi_TRUE@am__append_2705 = pata.module
+@COND_i386_efi_TRUE@am__append_2706 = pata.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2707 =
+@COND_i386_efi_TRUE@am__append_2708 = $(nodist_pata_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2709 = $(nodist_pata_module_SOURCES) \
+@COND_i386_efi_TRUE@ pata.marker
+@COND_i386_efi_TRUE@am__append_2710 = pata.mod
+@COND_i386_efi_TRUE@am__append_2711 = pata.marker
+@COND_i386_qemu_TRUE@am__append_2712 = pata.module
+@COND_i386_qemu_TRUE@am__append_2713 = pata.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2714 =
+@COND_i386_qemu_TRUE@am__append_2715 = $(nodist_pata_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2716 = $(nodist_pata_module_SOURCES) \
+@COND_i386_qemu_TRUE@ pata.marker
+@COND_i386_qemu_TRUE@am__append_2717 = pata.mod
+@COND_i386_qemu_TRUE@am__append_2718 = pata.marker
+@COND_i386_coreboot_TRUE@am__append_2719 = pata.module
+@COND_i386_coreboot_TRUE@am__append_2720 = pata.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2721 =
+@COND_i386_coreboot_TRUE@am__append_2722 = $(nodist_pata_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2723 = \
+@COND_i386_coreboot_TRUE@ $(nodist_pata_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ pata.marker
+@COND_i386_coreboot_TRUE@am__append_2724 = pata.mod
+@COND_i386_coreboot_TRUE@am__append_2725 = pata.marker
+@COND_i386_multiboot_TRUE@am__append_2726 = pata.module
+@COND_i386_multiboot_TRUE@am__append_2727 = pata.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2728 =
+@COND_i386_multiboot_TRUE@am__append_2729 = $(nodist_pata_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2730 = \
+@COND_i386_multiboot_TRUE@ $(nodist_pata_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ pata.marker
+@COND_i386_multiboot_TRUE@am__append_2731 = pata.mod
+@COND_i386_multiboot_TRUE@am__append_2732 = pata.marker
+@COND_i386_ieee1275_TRUE@am__append_2733 = pata.module
+@COND_i386_ieee1275_TRUE@am__append_2734 = pata.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2735 =
+@COND_i386_ieee1275_TRUE@am__append_2736 = $(nodist_pata_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2737 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_pata_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ pata.marker
+@COND_i386_ieee1275_TRUE@am__append_2738 = pata.mod
+@COND_i386_ieee1275_TRUE@am__append_2739 = pata.marker
+@COND_x86_64_efi_TRUE@am__append_2740 = pata.module
+@COND_x86_64_efi_TRUE@am__append_2741 = pata.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2742 =
+@COND_x86_64_efi_TRUE@am__append_2743 = $(nodist_pata_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2744 = $(nodist_pata_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ pata.marker
+@COND_x86_64_efi_TRUE@am__append_2745 = pata.mod
+@COND_x86_64_efi_TRUE@am__append_2746 = pata.marker
+@COND_mips_loongson_TRUE@am__append_2747 = pata.module
+@COND_mips_loongson_TRUE@am__append_2748 = pata.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_2749 =
+@COND_mips_loongson_TRUE@am__append_2750 = $(nodist_pata_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_2751 = \
+@COND_mips_loongson_TRUE@ $(nodist_pata_module_SOURCES) \
+@COND_mips_loongson_TRUE@ pata.marker
+@COND_mips_loongson_TRUE@am__append_2752 = pata.mod
+@COND_mips_loongson_TRUE@am__append_2753 = pata.marker
+@COND_mips_qemu_mips_TRUE@am__append_2754 = pata.module
+@COND_mips_qemu_mips_TRUE@am__append_2755 = pata.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_2756 =
+@COND_mips_qemu_mips_TRUE@am__append_2757 = $(nodist_pata_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_2758 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_pata_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ pata.marker
+@COND_mips_qemu_mips_TRUE@am__append_2759 = pata.mod
+@COND_mips_qemu_mips_TRUE@am__append_2760 = pata.marker
+@COND_i386_pc_TRUE@am__append_2761 = biosdisk.module usbms.module
+@COND_i386_pc_TRUE@am__append_2762 = biosdisk.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ usbms.module$(EXEEXT)
+@COND_i386_pc_FALSE@biosdisk_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2763 =
+@COND_i386_pc_TRUE@am__append_2764 = \
+@COND_i386_pc_TRUE@ $(nodist_biosdisk_module_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_usbms_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2765 = \
+@COND_i386_pc_TRUE@ $(nodist_biosdisk_module_SOURCES) \
+@COND_i386_pc_TRUE@ biosdisk.marker \
+@COND_i386_pc_TRUE@ $(nodist_usbms_module_SOURCES) usbms.marker
+@COND_i386_pc_TRUE@am__append_2766 = biosdisk.mod usbms.mod
+@COND_i386_pc_TRUE@am__append_2767 = biosdisk.marker usbms.marker
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@usbms_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_2768 = usbms.module
+@COND_i386_efi_TRUE@am__append_2769 = usbms.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2770 =
+@COND_i386_efi_TRUE@am__append_2771 = $(nodist_usbms_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2772 = $(nodist_usbms_module_SOURCES) \
+@COND_i386_efi_TRUE@ usbms.marker
+@COND_i386_efi_TRUE@am__append_2773 = usbms.mod
+@COND_i386_efi_TRUE@am__append_2774 = usbms.marker
+@COND_i386_qemu_TRUE@am__append_2775 = usbms.module
+@COND_i386_qemu_TRUE@am__append_2776 = usbms.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2777 =
+@COND_i386_qemu_TRUE@am__append_2778 = $(nodist_usbms_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2779 = $(nodist_usbms_module_SOURCES) \
+@COND_i386_qemu_TRUE@ usbms.marker
+@COND_i386_qemu_TRUE@am__append_2780 = usbms.mod
+@COND_i386_qemu_TRUE@am__append_2781 = usbms.marker
+@COND_i386_coreboot_TRUE@am__append_2782 = usbms.module
+@COND_i386_coreboot_TRUE@am__append_2783 = usbms.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2784 =
+@COND_i386_coreboot_TRUE@am__append_2785 = $(nodist_usbms_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2786 = \
+@COND_i386_coreboot_TRUE@ $(nodist_usbms_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ usbms.marker
+@COND_i386_coreboot_TRUE@am__append_2787 = usbms.mod
+@COND_i386_coreboot_TRUE@am__append_2788 = usbms.marker
+@COND_i386_multiboot_TRUE@am__append_2789 = usbms.module
+@COND_i386_multiboot_TRUE@am__append_2790 = usbms.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2791 =
+@COND_i386_multiboot_TRUE@am__append_2792 = $(nodist_usbms_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2793 = \
+@COND_i386_multiboot_TRUE@ $(nodist_usbms_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ usbms.marker
+@COND_i386_multiboot_TRUE@am__append_2794 = usbms.mod
+@COND_i386_multiboot_TRUE@am__append_2795 = usbms.marker
+@COND_i386_ieee1275_TRUE@am__append_2796 = usbms.module
+@COND_i386_ieee1275_TRUE@am__append_2797 = usbms.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2798 =
+@COND_i386_ieee1275_TRUE@am__append_2799 = $(nodist_usbms_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2800 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_usbms_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ usbms.marker
+@COND_i386_ieee1275_TRUE@am__append_2801 = usbms.mod
+@COND_i386_ieee1275_TRUE@am__append_2802 = usbms.marker
+@COND_x86_64_efi_TRUE@am__append_2803 = usbms.module
+@COND_x86_64_efi_TRUE@am__append_2804 = usbms.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2805 =
+@COND_x86_64_efi_TRUE@am__append_2806 = $(nodist_usbms_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2807 = \
+@COND_x86_64_efi_TRUE@ $(nodist_usbms_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ usbms.marker
+@COND_x86_64_efi_TRUE@am__append_2808 = usbms.mod
+@COND_x86_64_efi_TRUE@am__append_2809 = usbms.marker
+@COND_mips_loongson_TRUE@am__append_2810 = usbms.module
+@COND_mips_loongson_TRUE@am__append_2811 = usbms.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_2812 =
+@COND_mips_loongson_TRUE@am__append_2813 = $(nodist_usbms_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_2814 = \
+@COND_mips_loongson_TRUE@ $(nodist_usbms_module_SOURCES) \
+@COND_mips_loongson_TRUE@ usbms.marker
+@COND_mips_loongson_TRUE@am__append_2815 = usbms.mod
+@COND_mips_loongson_TRUE@am__append_2816 = usbms.marker
+@COND_arm_coreboot_TRUE@am__append_2817 = usbms.module
+@COND_arm_coreboot_TRUE@am__append_2818 = usbms.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_2819 =
+@COND_arm_coreboot_TRUE@am__append_2820 = $(nodist_usbms_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_2821 = \
+@COND_arm_coreboot_TRUE@ $(nodist_usbms_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ usbms.marker
+@COND_arm_coreboot_TRUE@am__append_2822 = usbms.mod
+@COND_arm_coreboot_TRUE@am__append_2823 = usbms.marker
+@COND_i386_ieee1275_TRUE@am__append_2824 = nand.module
+@COND_i386_ieee1275_TRUE@am__append_2825 = nand.module$(EXEEXT)
+@COND_i386_ieee1275_FALSE@nand_module_DEPENDENCIES =
+@COND_i386_ieee1275_TRUE@am__append_2826 =
+@COND_i386_ieee1275_TRUE@am__append_2827 = $(nodist_nand_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2828 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_nand_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ nand.marker
+@COND_i386_ieee1275_TRUE@am__append_2829 = nand.mod
+@COND_i386_ieee1275_TRUE@am__append_2830 = nand.marker
+@COND_i386_pc_TRUE@am__append_2831 = efiemu.module
+@COND_i386_pc_TRUE@am__append_2832 = efiemu.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@efiemu_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_2833 = efiemu/prepare.c efiemu/loadcore.c efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c
+@COND_i386_pc_TRUE@am__append_2834 = $(nodist_efiemu_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2835 = $(nodist_efiemu_module_SOURCES) \
+@COND_i386_pc_TRUE@ efiemu.marker
+@COND_i386_pc_TRUE@am__append_2836 = efiemu.mod
+@COND_i386_pc_TRUE@am__append_2837 = efiemu.marker
+@COND_i386_qemu_TRUE@am__append_2838 = efiemu.module
+@COND_i386_qemu_TRUE@am__append_2839 = efiemu.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2840 = efiemu/prepare.c efiemu/loadcore.c efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c
+@COND_i386_qemu_TRUE@am__append_2841 = $(nodist_efiemu_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2842 = \
+@COND_i386_qemu_TRUE@ $(nodist_efiemu_module_SOURCES) \
+@COND_i386_qemu_TRUE@ efiemu.marker
+@COND_i386_qemu_TRUE@am__append_2843 = efiemu.mod
+@COND_i386_qemu_TRUE@am__append_2844 = efiemu.marker
+@COND_i386_coreboot_TRUE@am__append_2845 = efiemu.module
+@COND_i386_coreboot_TRUE@am__append_2846 = efiemu.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_2847 = efiemu/prepare.c efiemu/loadcore.c efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c
+@COND_i386_coreboot_TRUE@am__append_2848 = $(nodist_efiemu_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_2849 = \
+@COND_i386_coreboot_TRUE@ $(nodist_efiemu_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ efiemu.marker
+@COND_i386_coreboot_TRUE@am__append_2850 = efiemu.mod
+@COND_i386_coreboot_TRUE@am__append_2851 = efiemu.marker
+@COND_i386_multiboot_TRUE@am__append_2852 = efiemu.module
+@COND_i386_multiboot_TRUE@am__append_2853 = efiemu.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2854 = efiemu/prepare.c efiemu/loadcore.c efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c
+@COND_i386_multiboot_TRUE@am__append_2855 = $(nodist_efiemu_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2856 = \
+@COND_i386_multiboot_TRUE@ $(nodist_efiemu_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ efiemu.marker
+@COND_i386_multiboot_TRUE@am__append_2857 = efiemu.mod
+@COND_i386_multiboot_TRUE@am__append_2858 = efiemu.marker
+@COND_i386_ieee1275_TRUE@am__append_2859 = efiemu.module
+@COND_i386_ieee1275_TRUE@am__append_2860 = efiemu.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2861 = efiemu/prepare.c efiemu/loadcore.c efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c
+@COND_i386_ieee1275_TRUE@am__append_2862 = $(nodist_efiemu_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2863 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_efiemu_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ efiemu.marker
+@COND_i386_ieee1275_TRUE@am__append_2864 = efiemu.mod
+@COND_i386_ieee1275_TRUE@am__append_2865 = efiemu.marker
+@COND_emu_TRUE@am__append_2866 = font.module
+@COND_emu_TRUE@am__append_2867 = font.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@font_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_2868 =
+@COND_emu_TRUE@am__append_2869 = $(nodist_font_module_SOURCES)
+@COND_emu_TRUE@am__append_2870 = $(nodist_font_module_SOURCES) \
+@COND_emu_TRUE@ font.marker
+@COND_emu_TRUE@am__append_2871 = font.mod
+@COND_emu_TRUE@am__append_2872 = font.marker
+@COND_i386_pc_TRUE@am__append_2873 = font.module
+@COND_i386_pc_TRUE@am__append_2874 = font.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_2875 =
+@COND_i386_pc_TRUE@am__append_2876 = $(nodist_font_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_2877 = $(nodist_font_module_SOURCES) \
+@COND_i386_pc_TRUE@ font.marker
+@COND_i386_pc_TRUE@am__append_2878 = font.mod
+@COND_i386_pc_TRUE@am__append_2879 = font.marker
+@COND_i386_efi_TRUE@am__append_2880 = font.module
+@COND_i386_efi_TRUE@am__append_2881 = font.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_2882 =
+@COND_i386_efi_TRUE@am__append_2883 = $(nodist_font_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_2884 = $(nodist_font_module_SOURCES) \
+@COND_i386_efi_TRUE@ font.marker
+@COND_i386_efi_TRUE@am__append_2885 = font.mod
+@COND_i386_efi_TRUE@am__append_2886 = font.marker
+@COND_i386_qemu_TRUE@am__append_2887 = font.module
+@COND_i386_qemu_TRUE@am__append_2888 = font.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_2889 =
+@COND_i386_qemu_TRUE@am__append_2890 = $(nodist_font_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_2891 = $(nodist_font_module_SOURCES) \
+@COND_i386_qemu_TRUE@ font.marker
+@COND_i386_qemu_TRUE@am__append_2892 = font.mod
+@COND_i386_qemu_TRUE@am__append_2893 = font.marker
+@COND_i386_multiboot_TRUE@am__append_2894 = font.module
+@COND_i386_multiboot_TRUE@am__append_2895 = font.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_2896 =
+@COND_i386_multiboot_TRUE@am__append_2897 = $(nodist_font_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_2898 = \
+@COND_i386_multiboot_TRUE@ $(nodist_font_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ font.marker
+@COND_i386_multiboot_TRUE@am__append_2899 = font.mod
+@COND_i386_multiboot_TRUE@am__append_2900 = font.marker
+@COND_i386_ieee1275_TRUE@am__append_2901 = font.module
+@COND_i386_ieee1275_TRUE@am__append_2902 = font.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_2903 =
+@COND_i386_ieee1275_TRUE@am__append_2904 = $(nodist_font_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_2905 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_font_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ font.marker
+@COND_i386_ieee1275_TRUE@am__append_2906 = font.mod
+@COND_i386_ieee1275_TRUE@am__append_2907 = font.marker
+@COND_x86_64_efi_TRUE@am__append_2908 = font.module
+@COND_x86_64_efi_TRUE@am__append_2909 = font.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_2910 =
+@COND_x86_64_efi_TRUE@am__append_2911 = $(nodist_font_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_2912 = $(nodist_font_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ font.marker
+@COND_x86_64_efi_TRUE@am__append_2913 = font.mod
+@COND_x86_64_efi_TRUE@am__append_2914 = font.marker
+@COND_i386_xen_TRUE@am__append_2915 = font.module
+@COND_i386_xen_TRUE@am__append_2916 = font.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_2917 =
+@COND_i386_xen_TRUE@am__append_2918 = $(nodist_font_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_2919 = $(nodist_font_module_SOURCES) \
+@COND_i386_xen_TRUE@ font.marker
+@COND_i386_xen_TRUE@am__append_2920 = font.mod
+@COND_i386_xen_TRUE@am__append_2921 = font.marker
+@COND_x86_64_xen_TRUE@am__append_2922 = font.module
+@COND_x86_64_xen_TRUE@am__append_2923 = font.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_2924 =
+@COND_x86_64_xen_TRUE@am__append_2925 = $(nodist_font_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_2926 = $(nodist_font_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ font.marker
+@COND_x86_64_xen_TRUE@am__append_2927 = font.mod
+@COND_x86_64_xen_TRUE@am__append_2928 = font.marker
+@COND_i386_xen_pvh_TRUE@am__append_2929 = font.module
+@COND_i386_xen_pvh_TRUE@am__append_2930 = font.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_2931 =
+@COND_i386_xen_pvh_TRUE@am__append_2932 = $(nodist_font_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_2933 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_font_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ font.marker
+@COND_i386_xen_pvh_TRUE@am__append_2934 = font.mod
+@COND_i386_xen_pvh_TRUE@am__append_2935 = font.marker
+@COND_sparc64_ieee1275_TRUE@am__append_2936 = font.module
+@COND_sparc64_ieee1275_TRUE@am__append_2937 = font.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_2938 =
+@COND_sparc64_ieee1275_TRUE@am__append_2939 = $(nodist_font_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_2940 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_font_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ font.marker
+@COND_sparc64_ieee1275_TRUE@am__append_2941 = font.mod
+@COND_sparc64_ieee1275_TRUE@am__append_2942 = font.marker
+@COND_powerpc_ieee1275_TRUE@am__append_2943 = font.module
+@COND_powerpc_ieee1275_TRUE@am__append_2944 = font.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_2945 =
+@COND_powerpc_ieee1275_TRUE@am__append_2946 = $(nodist_font_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_2947 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_font_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ font.marker
+@COND_powerpc_ieee1275_TRUE@am__append_2948 = font.mod
+@COND_powerpc_ieee1275_TRUE@am__append_2949 = font.marker
+@COND_mips_arc_TRUE@am__append_2950 = font.module
+@COND_mips_arc_TRUE@am__append_2951 = font.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_2952 =
+@COND_mips_arc_TRUE@am__append_2953 = $(nodist_font_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_2954 = $(nodist_font_module_SOURCES) \
+@COND_mips_arc_TRUE@ font.marker
+@COND_mips_arc_TRUE@am__append_2955 = font.mod
+@COND_mips_arc_TRUE@am__append_2956 = font.marker
+@COND_ia64_efi_TRUE@am__append_2957 = font.module
+@COND_ia64_efi_TRUE@am__append_2958 = font.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_2959 =
+@COND_ia64_efi_TRUE@am__append_2960 = $(nodist_font_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_2961 = $(nodist_font_module_SOURCES) \
+@COND_ia64_efi_TRUE@ font.marker
+@COND_ia64_efi_TRUE@am__append_2962 = font.mod
+@COND_ia64_efi_TRUE@am__append_2963 = font.marker
+@COND_mips_qemu_mips_TRUE@am__append_2964 = font.module
+@COND_mips_qemu_mips_TRUE@am__append_2965 = font.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_2966 =
+@COND_mips_qemu_mips_TRUE@am__append_2967 = $(nodist_font_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_2968 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_font_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ font.marker
+@COND_mips_qemu_mips_TRUE@am__append_2969 = font.mod
+@COND_mips_qemu_mips_TRUE@am__append_2970 = font.marker
+@COND_arm_uboot_TRUE@am__append_2971 = font.module
+@COND_arm_uboot_TRUE@am__append_2972 = font.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__append_2973 =
+@COND_arm_uboot_TRUE@am__append_2974 = $(nodist_font_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_2975 = $(nodist_font_module_SOURCES) \
+@COND_arm_uboot_TRUE@ font.marker
+@COND_arm_uboot_TRUE@am__append_2976 = font.mod
+@COND_arm_uboot_TRUE@am__append_2977 = font.marker
+@COND_arm_efi_TRUE@am__append_2978 = font.module
+@COND_arm_efi_TRUE@am__append_2979 = font.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_2980 =
+@COND_arm_efi_TRUE@am__append_2981 = $(nodist_font_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_2982 = $(nodist_font_module_SOURCES) \
+@COND_arm_efi_TRUE@ font.marker
+@COND_arm_efi_TRUE@am__append_2983 = font.mod
+@COND_arm_efi_TRUE@am__append_2984 = font.marker
+@COND_arm64_efi_TRUE@am__append_2985 = font.module
+@COND_arm64_efi_TRUE@am__append_2986 = font.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_2987 =
+@COND_arm64_efi_TRUE@am__append_2988 = $(nodist_font_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_2989 = $(nodist_font_module_SOURCES) \
+@COND_arm64_efi_TRUE@ font.marker
+@COND_arm64_efi_TRUE@am__append_2990 = font.mod
+@COND_arm64_efi_TRUE@am__append_2991 = font.marker
+@COND_riscv32_efi_TRUE@am__append_2992 = font.module
+@COND_riscv32_efi_TRUE@am__append_2993 = font.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_2994 =
+@COND_riscv32_efi_TRUE@am__append_2995 = $(nodist_font_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_2996 = \
+@COND_riscv32_efi_TRUE@ $(nodist_font_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ font.marker
+@COND_riscv32_efi_TRUE@am__append_2997 = font.mod
+@COND_riscv32_efi_TRUE@am__append_2998 = font.marker
+@COND_riscv64_efi_TRUE@am__append_2999 = font.module
+@COND_riscv64_efi_TRUE@am__append_3000 = font.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_3001 =
+@COND_riscv64_efi_TRUE@am__append_3002 = $(nodist_font_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_3003 = \
+@COND_riscv64_efi_TRUE@ $(nodist_font_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ font.marker
+@COND_riscv64_efi_TRUE@am__append_3004 = font.mod
+@COND_riscv64_efi_TRUE@am__append_3005 = font.marker
+@COND_i386_pc_TRUE@am__append_3006 = pxe.module
+@COND_i386_pc_TRUE@am__append_3007 = pxe.module$(EXEEXT)
+@COND_i386_pc_FALSE@pxe_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3008 =
+@COND_i386_pc_TRUE@am__append_3009 = $(nodist_pxe_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3010 = $(nodist_pxe_module_SOURCES) \
+@COND_i386_pc_TRUE@ pxe.marker
+@COND_i386_pc_TRUE@am__append_3011 = pxe.mod
+@COND_i386_pc_TRUE@am__append_3012 = pxe.marker
+@COND_emu_TRUE@am__append_3013 = bufio.module
+@COND_emu_TRUE@am__append_3014 = bufio.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@bufio_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_3015 =
+@COND_emu_TRUE@am__append_3016 = $(nodist_bufio_module_SOURCES)
+@COND_emu_TRUE@am__append_3017 = $(nodist_bufio_module_SOURCES) \
+@COND_emu_TRUE@ bufio.marker
+@COND_emu_TRUE@am__append_3018 = bufio.mod
+@COND_emu_TRUE@am__append_3019 = bufio.marker
+@COND_i386_pc_TRUE@am__append_3020 = bufio.module
+@COND_i386_pc_TRUE@am__append_3021 = bufio.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_3022 =
+@COND_i386_pc_TRUE@am__append_3023 = $(nodist_bufio_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3024 = $(nodist_bufio_module_SOURCES) \
+@COND_i386_pc_TRUE@ bufio.marker
+@COND_i386_pc_TRUE@am__append_3025 = bufio.mod
+@COND_i386_pc_TRUE@am__append_3026 = bufio.marker
+@COND_i386_efi_TRUE@am__append_3027 = bufio.module
+@COND_i386_efi_TRUE@am__append_3028 = bufio.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3029 =
+@COND_i386_efi_TRUE@am__append_3030 = $(nodist_bufio_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3031 = $(nodist_bufio_module_SOURCES) \
+@COND_i386_efi_TRUE@ bufio.marker
+@COND_i386_efi_TRUE@am__append_3032 = bufio.mod
+@COND_i386_efi_TRUE@am__append_3033 = bufio.marker
+@COND_i386_qemu_TRUE@am__append_3034 = bufio.module
+@COND_i386_qemu_TRUE@am__append_3035 = bufio.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_3036 =
+@COND_i386_qemu_TRUE@am__append_3037 = $(nodist_bufio_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_3038 = $(nodist_bufio_module_SOURCES) \
+@COND_i386_qemu_TRUE@ bufio.marker
+@COND_i386_qemu_TRUE@am__append_3039 = bufio.mod
+@COND_i386_qemu_TRUE@am__append_3040 = bufio.marker
+@COND_i386_multiboot_TRUE@am__append_3041 = bufio.module
+@COND_i386_multiboot_TRUE@am__append_3042 = bufio.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3043 =
+@COND_i386_multiboot_TRUE@am__append_3044 = $(nodist_bufio_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3045 = \
+@COND_i386_multiboot_TRUE@ $(nodist_bufio_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ bufio.marker
+@COND_i386_multiboot_TRUE@am__append_3046 = bufio.mod
+@COND_i386_multiboot_TRUE@am__append_3047 = bufio.marker
+@COND_i386_ieee1275_TRUE@am__append_3048 = bufio.module
+@COND_i386_ieee1275_TRUE@am__append_3049 = bufio.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_3050 =
+@COND_i386_ieee1275_TRUE@am__append_3051 = $(nodist_bufio_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_3052 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_bufio_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ bufio.marker
+@COND_i386_ieee1275_TRUE@am__append_3053 = bufio.mod
+@COND_i386_ieee1275_TRUE@am__append_3054 = bufio.marker
+@COND_x86_64_efi_TRUE@am__append_3055 = bufio.module
+@COND_x86_64_efi_TRUE@am__append_3056 = bufio.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3057 =
+@COND_x86_64_efi_TRUE@am__append_3058 = $(nodist_bufio_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3059 = \
+@COND_x86_64_efi_TRUE@ $(nodist_bufio_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ bufio.marker
+@COND_x86_64_efi_TRUE@am__append_3060 = bufio.mod
+@COND_x86_64_efi_TRUE@am__append_3061 = bufio.marker
+@COND_i386_xen_TRUE@am__append_3062 = bufio.module
+@COND_i386_xen_TRUE@am__append_3063 = bufio.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_3064 =
+@COND_i386_xen_TRUE@am__append_3065 = $(nodist_bufio_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_3066 = $(nodist_bufio_module_SOURCES) \
+@COND_i386_xen_TRUE@ bufio.marker
+@COND_i386_xen_TRUE@am__append_3067 = bufio.mod
+@COND_i386_xen_TRUE@am__append_3068 = bufio.marker
+@COND_x86_64_xen_TRUE@am__append_3069 = bufio.module
+@COND_x86_64_xen_TRUE@am__append_3070 = bufio.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_3071 =
+@COND_x86_64_xen_TRUE@am__append_3072 = $(nodist_bufio_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_3073 = \
+@COND_x86_64_xen_TRUE@ $(nodist_bufio_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ bufio.marker
+@COND_x86_64_xen_TRUE@am__append_3074 = bufio.mod
+@COND_x86_64_xen_TRUE@am__append_3075 = bufio.marker
+@COND_i386_xen_pvh_TRUE@am__append_3076 = bufio.module
+@COND_i386_xen_pvh_TRUE@am__append_3077 = bufio.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_3078 =
+@COND_i386_xen_pvh_TRUE@am__append_3079 = $(nodist_bufio_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_3080 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_bufio_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ bufio.marker
+@COND_i386_xen_pvh_TRUE@am__append_3081 = bufio.mod
+@COND_i386_xen_pvh_TRUE@am__append_3082 = bufio.marker
+@COND_sparc64_ieee1275_TRUE@am__append_3083 = bufio.module
+@COND_sparc64_ieee1275_TRUE@am__append_3084 = bufio.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_3085 =
+@COND_sparc64_ieee1275_TRUE@am__append_3086 = $(nodist_bufio_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_3087 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_bufio_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ bufio.marker
+@COND_sparc64_ieee1275_TRUE@am__append_3088 = bufio.mod
+@COND_sparc64_ieee1275_TRUE@am__append_3089 = bufio.marker
+@COND_powerpc_ieee1275_TRUE@am__append_3090 = bufio.module
+@COND_powerpc_ieee1275_TRUE@am__append_3091 = bufio.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_3092 =
+@COND_powerpc_ieee1275_TRUE@am__append_3093 = $(nodist_bufio_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_3094 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_bufio_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ bufio.marker
+@COND_powerpc_ieee1275_TRUE@am__append_3095 = bufio.mod
+@COND_powerpc_ieee1275_TRUE@am__append_3096 = bufio.marker
+@COND_mips_arc_TRUE@am__append_3097 = bufio.module
+@COND_mips_arc_TRUE@am__append_3098 = bufio.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_3099 =
+@COND_mips_arc_TRUE@am__append_3100 = $(nodist_bufio_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_3101 = $(nodist_bufio_module_SOURCES) \
+@COND_mips_arc_TRUE@ bufio.marker
+@COND_mips_arc_TRUE@am__append_3102 = bufio.mod
+@COND_mips_arc_TRUE@am__append_3103 = bufio.marker
+@COND_ia64_efi_TRUE@am__append_3104 = bufio.module
+@COND_ia64_efi_TRUE@am__append_3105 = bufio.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_3106 =
+@COND_ia64_efi_TRUE@am__append_3107 = $(nodist_bufio_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_3108 = $(nodist_bufio_module_SOURCES) \
+@COND_ia64_efi_TRUE@ bufio.marker
+@COND_ia64_efi_TRUE@am__append_3109 = bufio.mod
+@COND_ia64_efi_TRUE@am__append_3110 = bufio.marker
+@COND_mips_qemu_mips_TRUE@am__append_3111 = bufio.module
+@COND_mips_qemu_mips_TRUE@am__append_3112 = bufio.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_3113 =
+@COND_mips_qemu_mips_TRUE@am__append_3114 = $(nodist_bufio_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_3115 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_bufio_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ bufio.marker
+@COND_mips_qemu_mips_TRUE@am__append_3116 = bufio.mod
+@COND_mips_qemu_mips_TRUE@am__append_3117 = bufio.marker
+@COND_arm_uboot_TRUE@am__append_3118 = bufio.module
+@COND_arm_uboot_TRUE@am__append_3119 = bufio.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__append_3120 =
+@COND_arm_uboot_TRUE@am__append_3121 = $(nodist_bufio_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_3122 = $(nodist_bufio_module_SOURCES) \
+@COND_arm_uboot_TRUE@ bufio.marker
+@COND_arm_uboot_TRUE@am__append_3123 = bufio.mod
+@COND_arm_uboot_TRUE@am__append_3124 = bufio.marker
+@COND_arm_efi_TRUE@am__append_3125 = bufio.module
+@COND_arm_efi_TRUE@am__append_3126 = bufio.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_3127 =
+@COND_arm_efi_TRUE@am__append_3128 = $(nodist_bufio_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_3129 = $(nodist_bufio_module_SOURCES) \
+@COND_arm_efi_TRUE@ bufio.marker
+@COND_arm_efi_TRUE@am__append_3130 = bufio.mod
+@COND_arm_efi_TRUE@am__append_3131 = bufio.marker
+@COND_arm64_efi_TRUE@am__append_3132 = bufio.module
+@COND_arm64_efi_TRUE@am__append_3133 = bufio.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_3134 =
+@COND_arm64_efi_TRUE@am__append_3135 = $(nodist_bufio_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_3136 = $(nodist_bufio_module_SOURCES) \
+@COND_arm64_efi_TRUE@ bufio.marker
+@COND_arm64_efi_TRUE@am__append_3137 = bufio.mod
+@COND_arm64_efi_TRUE@am__append_3138 = bufio.marker
+@COND_riscv32_efi_TRUE@am__append_3139 = bufio.module
+@COND_riscv32_efi_TRUE@am__append_3140 = bufio.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_3141 =
+@COND_riscv32_efi_TRUE@am__append_3142 = $(nodist_bufio_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_3143 = \
+@COND_riscv32_efi_TRUE@ $(nodist_bufio_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ bufio.marker
+@COND_riscv32_efi_TRUE@am__append_3144 = bufio.mod
+@COND_riscv32_efi_TRUE@am__append_3145 = bufio.marker
+@COND_riscv64_efi_TRUE@am__append_3146 = bufio.module
+@COND_riscv64_efi_TRUE@am__append_3147 = bufio.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_3148 =
+@COND_riscv64_efi_TRUE@am__append_3149 = $(nodist_bufio_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_3150 = \
+@COND_riscv64_efi_TRUE@ $(nodist_bufio_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ bufio.marker
+@COND_riscv64_efi_TRUE@am__append_3151 = bufio.mod
+@COND_riscv64_efi_TRUE@am__append_3152 = bufio.marker
+@COND_i386_pc_TRUE@am__append_3153 = relocator.module
+@COND_i386_pc_TRUE@am__append_3154 = relocator.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@relocator_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3155 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_i386_pc_TRUE@am__append_3156 = $(nodist_relocator_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3157 = \
+@COND_i386_pc_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_i386_pc_TRUE@ relocator.marker
+@COND_i386_pc_TRUE@am__append_3158 = relocator.mod
+@COND_i386_pc_TRUE@am__append_3159 = relocator.marker
+@COND_i386_efi_TRUE@am__append_3160 = relocator.module
+@COND_i386_efi_TRUE@am__append_3161 = relocator.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3162 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_i386_efi_TRUE@am__append_3163 = $(nodist_relocator_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3164 = \
+@COND_i386_efi_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_i386_efi_TRUE@ relocator.marker
+@COND_i386_efi_TRUE@am__append_3165 = relocator.mod
+@COND_i386_efi_TRUE@am__append_3166 = relocator.marker
+@COND_i386_qemu_TRUE@am__append_3167 = relocator.module
+@COND_i386_qemu_TRUE@am__append_3168 = relocator.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_3169 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_i386_qemu_TRUE@am__append_3170 = $(nodist_relocator_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_3171 = \
+@COND_i386_qemu_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_i386_qemu_TRUE@ relocator.marker
+@COND_i386_qemu_TRUE@am__append_3172 = relocator.mod
+@COND_i386_qemu_TRUE@am__append_3173 = relocator.marker
+@COND_i386_coreboot_TRUE@am__append_3174 = relocator.module
+@COND_i386_coreboot_TRUE@am__append_3175 = relocator.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3176 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_i386_coreboot_TRUE@am__append_3177 = $(nodist_relocator_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3178 = \
+@COND_i386_coreboot_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ relocator.marker
+@COND_i386_coreboot_TRUE@am__append_3179 = relocator.mod
+@COND_i386_coreboot_TRUE@am__append_3180 = relocator.marker
+@COND_i386_multiboot_TRUE@am__append_3181 = relocator.module
+@COND_i386_multiboot_TRUE@am__append_3182 = relocator.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3183 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_i386_multiboot_TRUE@am__append_3184 = $(nodist_relocator_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3185 = \
+@COND_i386_multiboot_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ relocator.marker
+@COND_i386_multiboot_TRUE@am__append_3186 = relocator.mod
+@COND_i386_multiboot_TRUE@am__append_3187 = relocator.marker
+@COND_i386_ieee1275_TRUE@am__append_3188 = relocator.module
+@COND_i386_ieee1275_TRUE@am__append_3189 = relocator.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_3190 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_i386_ieee1275_TRUE@am__append_3191 = $(nodist_relocator_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_3192 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ relocator.marker
+@COND_i386_ieee1275_TRUE@am__append_3193 = relocator.mod
+@COND_i386_ieee1275_TRUE@am__append_3194 = relocator.marker
+@COND_x86_64_efi_TRUE@am__append_3195 = relocator.module
+@COND_x86_64_efi_TRUE@am__append_3196 = relocator.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3197 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_x86_64_efi_TRUE@am__append_3198 = $(nodist_relocator_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3199 = \
+@COND_x86_64_efi_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ relocator.marker
+@COND_x86_64_efi_TRUE@am__append_3200 = relocator.mod
+@COND_x86_64_efi_TRUE@am__append_3201 = relocator.marker
+@COND_i386_xen_TRUE@am__append_3202 = relocator.module
+@COND_i386_xen_TRUE@am__append_3203 = relocator.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_3204 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_i386_xen_TRUE@am__append_3205 = $(nodist_relocator_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_3206 = \
+@COND_i386_xen_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_i386_xen_TRUE@ relocator.marker
+@COND_i386_xen_TRUE@am__append_3207 = relocator.mod
+@COND_i386_xen_TRUE@am__append_3208 = relocator.marker
+@COND_x86_64_xen_TRUE@am__append_3209 = relocator.module
+@COND_x86_64_xen_TRUE@am__append_3210 = relocator.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_3211 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_x86_64_xen_TRUE@am__append_3212 = $(nodist_relocator_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_3213 = \
+@COND_x86_64_xen_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ relocator.marker
+@COND_x86_64_xen_TRUE@am__append_3214 = relocator.mod
+@COND_x86_64_xen_TRUE@am__append_3215 = relocator.marker
+@COND_i386_xen_pvh_TRUE@am__append_3216 = relocator.module
+@COND_i386_xen_pvh_TRUE@am__append_3217 = relocator.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_3218 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_i386_xen_pvh_TRUE@am__append_3219 = $(nodist_relocator_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_3220 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ relocator.marker
+@COND_i386_xen_pvh_TRUE@am__append_3221 = relocator.mod
+@COND_i386_xen_pvh_TRUE@am__append_3222 = relocator.marker
+@COND_mips_loongson_TRUE@am__append_3223 = relocator.module
+@COND_mips_loongson_TRUE@am__append_3224 = relocator.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_3225 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_mips_loongson_TRUE@am__append_3226 = $(nodist_relocator_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_3227 = \
+@COND_mips_loongson_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_mips_loongson_TRUE@ relocator.marker
+@COND_mips_loongson_TRUE@am__append_3228 = relocator.mod
+@COND_mips_loongson_TRUE@am__append_3229 = relocator.marker
+@COND_powerpc_ieee1275_TRUE@am__append_3230 = relocator.module
+@COND_powerpc_ieee1275_TRUE@am__append_3231 = relocator.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_3232 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_powerpc_ieee1275_TRUE@am__append_3233 = $(nodist_relocator_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_3234 = $(nodist_relocator_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ relocator.marker
+@COND_powerpc_ieee1275_TRUE@am__append_3235 = relocator.mod
+@COND_powerpc_ieee1275_TRUE@am__append_3236 = relocator.marker
+@COND_mips_arc_TRUE@am__append_3237 = relocator.module
+@COND_mips_arc_TRUE@am__append_3238 = relocator.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_3239 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_mips_arc_TRUE@am__append_3240 = $(nodist_relocator_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_3241 = \
+@COND_mips_arc_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_mips_arc_TRUE@ relocator.marker
+@COND_mips_arc_TRUE@am__append_3242 = relocator.mod
+@COND_mips_arc_TRUE@am__append_3243 = relocator.marker
+@COND_mips_qemu_mips_TRUE@am__append_3244 = relocator.module
+@COND_mips_qemu_mips_TRUE@am__append_3245 = relocator.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_3246 = lib/i386/relocator_common.S kern/powerpc/cache_flush.S
+@COND_mips_qemu_mips_TRUE@am__append_3247 = $(nodist_relocator_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_3248 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_relocator_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ relocator.marker
+@COND_mips_qemu_mips_TRUE@am__append_3249 = relocator.mod
+@COND_mips_qemu_mips_TRUE@am__append_3250 = relocator.marker
+@COND_emu_TRUE@am__append_3251 = datetime.module
+@COND_emu_TRUE@am__append_3252 = datetime.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@datetime_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_3253 =
+@COND_emu_TRUE@am__append_3254 = $(nodist_datetime_module_SOURCES)
+@COND_emu_TRUE@am__append_3255 = $(nodist_datetime_module_SOURCES) \
+@COND_emu_TRUE@ datetime.marker
+@COND_emu_TRUE@am__append_3256 = datetime.mod
+@COND_emu_TRUE@am__append_3257 = datetime.marker
+@COND_i386_pc_TRUE@am__append_3258 = datetime.module
+@COND_i386_pc_TRUE@am__append_3259 = datetime.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_3260 =
+@COND_i386_pc_TRUE@am__append_3261 = $(nodist_datetime_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3262 = \
+@COND_i386_pc_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_i386_pc_TRUE@ datetime.marker
+@COND_i386_pc_TRUE@am__append_3263 = datetime.mod
+@COND_i386_pc_TRUE@am__append_3264 = datetime.marker
+@COND_i386_efi_TRUE@am__append_3265 = datetime.module
+@COND_i386_efi_TRUE@am__append_3266 = datetime.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3267 =
+@COND_i386_efi_TRUE@am__append_3268 = $(nodist_datetime_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3269 = \
+@COND_i386_efi_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_i386_efi_TRUE@ datetime.marker
+@COND_i386_efi_TRUE@am__append_3270 = datetime.mod
+@COND_i386_efi_TRUE@am__append_3271 = datetime.marker
+@COND_i386_qemu_TRUE@am__append_3272 = datetime.module
+@COND_i386_qemu_TRUE@am__append_3273 = datetime.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_3274 =
+@COND_i386_qemu_TRUE@am__append_3275 = $(nodist_datetime_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_3276 = \
+@COND_i386_qemu_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_i386_qemu_TRUE@ datetime.marker
+@COND_i386_qemu_TRUE@am__append_3277 = datetime.mod
+@COND_i386_qemu_TRUE@am__append_3278 = datetime.marker
+@COND_i386_coreboot_TRUE@am__append_3279 = datetime.module
+@COND_i386_coreboot_TRUE@am__append_3280 = datetime.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3281 =
+@COND_i386_coreboot_TRUE@am__append_3282 = $(nodist_datetime_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3283 = \
+@COND_i386_coreboot_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ datetime.marker
+@COND_i386_coreboot_TRUE@am__append_3284 = datetime.mod
+@COND_i386_coreboot_TRUE@am__append_3285 = datetime.marker
+@COND_i386_multiboot_TRUE@am__append_3286 = datetime.module
+@COND_i386_multiboot_TRUE@am__append_3287 = datetime.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3288 =
+@COND_i386_multiboot_TRUE@am__append_3289 = $(nodist_datetime_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3290 = \
+@COND_i386_multiboot_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ datetime.marker
+@COND_i386_multiboot_TRUE@am__append_3291 = datetime.mod
+@COND_i386_multiboot_TRUE@am__append_3292 = datetime.marker
+@COND_i386_ieee1275_TRUE@am__append_3293 = datetime.module
+@COND_i386_ieee1275_TRUE@am__append_3294 = datetime.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_3295 =
+@COND_i386_ieee1275_TRUE@am__append_3296 = $(nodist_datetime_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_3297 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ datetime.marker
+@COND_i386_ieee1275_TRUE@am__append_3298 = datetime.mod
+@COND_i386_ieee1275_TRUE@am__append_3299 = datetime.marker
+@COND_x86_64_efi_TRUE@am__append_3300 = datetime.module
+@COND_x86_64_efi_TRUE@am__append_3301 = datetime.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3302 =
+@COND_x86_64_efi_TRUE@am__append_3303 = $(nodist_datetime_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3304 = \
+@COND_x86_64_efi_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ datetime.marker
+@COND_x86_64_efi_TRUE@am__append_3305 = datetime.mod
+@COND_x86_64_efi_TRUE@am__append_3306 = datetime.marker
+@COND_i386_xen_TRUE@am__append_3307 = datetime.module
+@COND_i386_xen_TRUE@am__append_3308 = datetime.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_3309 =
+@COND_i386_xen_TRUE@am__append_3310 = $(nodist_datetime_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_3311 = \
+@COND_i386_xen_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_i386_xen_TRUE@ datetime.marker
+@COND_i386_xen_TRUE@am__append_3312 = datetime.mod
+@COND_i386_xen_TRUE@am__append_3313 = datetime.marker
+@COND_x86_64_xen_TRUE@am__append_3314 = datetime.module
+@COND_x86_64_xen_TRUE@am__append_3315 = datetime.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_3316 =
+@COND_x86_64_xen_TRUE@am__append_3317 = $(nodist_datetime_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_3318 = \
+@COND_x86_64_xen_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ datetime.marker
+@COND_x86_64_xen_TRUE@am__append_3319 = datetime.mod
+@COND_x86_64_xen_TRUE@am__append_3320 = datetime.marker
+@COND_i386_xen_pvh_TRUE@am__append_3321 = datetime.module
+@COND_i386_xen_pvh_TRUE@am__append_3322 = datetime.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_3323 =
+@COND_i386_xen_pvh_TRUE@am__append_3324 = $(nodist_datetime_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_3325 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ datetime.marker
+@COND_i386_xen_pvh_TRUE@am__append_3326 = datetime.mod
+@COND_i386_xen_pvh_TRUE@am__append_3327 = datetime.marker
+@COND_mips_loongson_TRUE@am__append_3328 = datetime.module
+@COND_mips_loongson_TRUE@am__append_3329 = datetime.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_3330 =
+@COND_mips_loongson_TRUE@am__append_3331 = $(nodist_datetime_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_3332 = \
+@COND_mips_loongson_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_mips_loongson_TRUE@ datetime.marker
+@COND_mips_loongson_TRUE@am__append_3333 = datetime.mod
+@COND_mips_loongson_TRUE@am__append_3334 = datetime.marker
+@COND_sparc64_ieee1275_TRUE@am__append_3335 = datetime.module
+@COND_sparc64_ieee1275_TRUE@am__append_3336 = datetime.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_3337 =
+@COND_sparc64_ieee1275_TRUE@am__append_3338 = $(nodist_datetime_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_3339 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ datetime.marker
+@COND_sparc64_ieee1275_TRUE@am__append_3340 = datetime.mod
+@COND_sparc64_ieee1275_TRUE@am__append_3341 = datetime.marker
+@COND_powerpc_ieee1275_TRUE@am__append_3342 = datetime.module
+@COND_powerpc_ieee1275_TRUE@am__append_3343 = datetime.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_3344 =
+@COND_powerpc_ieee1275_TRUE@am__append_3345 = $(nodist_datetime_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_3346 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ datetime.marker
+@COND_powerpc_ieee1275_TRUE@am__append_3347 = datetime.mod
+@COND_powerpc_ieee1275_TRUE@am__append_3348 = datetime.marker
+@COND_mips_arc_TRUE@am__append_3349 = datetime.module
+@COND_mips_arc_TRUE@am__append_3350 = datetime.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_3351 =
+@COND_mips_arc_TRUE@am__append_3352 = $(nodist_datetime_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_3353 = \
+@COND_mips_arc_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_mips_arc_TRUE@ datetime.marker
+@COND_mips_arc_TRUE@am__append_3354 = datetime.mod
+@COND_mips_arc_TRUE@am__append_3355 = datetime.marker
+@COND_ia64_efi_TRUE@am__append_3356 = datetime.module
+@COND_ia64_efi_TRUE@am__append_3357 = datetime.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_3358 =
+@COND_ia64_efi_TRUE@am__append_3359 = $(nodist_datetime_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_3360 = \
+@COND_ia64_efi_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_ia64_efi_TRUE@ datetime.marker
+@COND_ia64_efi_TRUE@am__append_3361 = datetime.mod
+@COND_ia64_efi_TRUE@am__append_3362 = datetime.marker
+@COND_mips_qemu_mips_TRUE@am__append_3363 = datetime.module
+@COND_mips_qemu_mips_TRUE@am__append_3364 = datetime.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_3365 =
+@COND_mips_qemu_mips_TRUE@am__append_3366 = $(nodist_datetime_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_3367 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ datetime.marker
+@COND_mips_qemu_mips_TRUE@am__append_3368 = datetime.mod
+@COND_mips_qemu_mips_TRUE@am__append_3369 = datetime.marker
+@COND_arm_uboot_TRUE@am__append_3370 = datetime.module
+@COND_arm_uboot_TRUE@am__append_3371 = datetime.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__append_3372 =
+@COND_arm_uboot_TRUE@am__append_3373 = $(nodist_datetime_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_3374 = \
+@COND_arm_uboot_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_arm_uboot_TRUE@ datetime.marker
+@COND_arm_uboot_TRUE@am__append_3375 = datetime.mod
+@COND_arm_uboot_TRUE@am__append_3376 = datetime.marker
+@COND_arm_efi_TRUE@am__append_3377 = datetime.module
+@COND_arm_efi_TRUE@am__append_3378 = datetime.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_3379 =
+@COND_arm_efi_TRUE@am__append_3380 = $(nodist_datetime_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_3381 = \
+@COND_arm_efi_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_arm_efi_TRUE@ datetime.marker
+@COND_arm_efi_TRUE@am__append_3382 = datetime.mod
+@COND_arm_efi_TRUE@am__append_3383 = datetime.marker
+@COND_arm64_efi_TRUE@am__append_3384 = datetime.module
+@COND_arm64_efi_TRUE@am__append_3385 = datetime.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_3386 =
+@COND_arm64_efi_TRUE@am__append_3387 = $(nodist_datetime_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_3388 = \
+@COND_arm64_efi_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_arm64_efi_TRUE@ datetime.marker
+@COND_arm64_efi_TRUE@am__append_3389 = datetime.mod
+@COND_arm64_efi_TRUE@am__append_3390 = datetime.marker
+@COND_arm_coreboot_TRUE@am__append_3391 = datetime.module
+@COND_arm_coreboot_TRUE@am__append_3392 = datetime.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_3393 =
+@COND_arm_coreboot_TRUE@am__append_3394 = $(nodist_datetime_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_3395 = \
+@COND_arm_coreboot_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ datetime.marker
+@COND_arm_coreboot_TRUE@am__append_3396 = datetime.mod
+@COND_arm_coreboot_TRUE@am__append_3397 = datetime.marker
+@COND_riscv32_efi_TRUE@am__append_3398 = datetime.module
+@COND_riscv32_efi_TRUE@am__append_3399 = datetime.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_3400 =
+@COND_riscv32_efi_TRUE@am__append_3401 = $(nodist_datetime_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_3402 = \
+@COND_riscv32_efi_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ datetime.marker
+@COND_riscv32_efi_TRUE@am__append_3403 = datetime.mod
+@COND_riscv32_efi_TRUE@am__append_3404 = datetime.marker
+@COND_riscv64_efi_TRUE@am__append_3405 = datetime.module
+@COND_riscv64_efi_TRUE@am__append_3406 = datetime.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_3407 =
+@COND_riscv64_efi_TRUE@am__append_3408 = $(nodist_datetime_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_3409 = \
+@COND_riscv64_efi_TRUE@ $(nodist_datetime_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ datetime.marker
+@COND_riscv64_efi_TRUE@am__append_3410 = datetime.mod
+@COND_riscv64_efi_TRUE@am__append_3411 = datetime.marker
+@COND_i386_pc_TRUE@am__append_3412 = aout.module
+@COND_i386_pc_TRUE@am__append_3413 = aout.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@aout_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3414 =
+@COND_i386_pc_TRUE@am__append_3415 = $(nodist_aout_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3416 = $(nodist_aout_module_SOURCES) \
+@COND_i386_pc_TRUE@ aout.marker
+@COND_i386_pc_TRUE@am__append_3417 = aout.mod
+@COND_i386_pc_TRUE@am__append_3418 = aout.marker
+@COND_i386_efi_TRUE@am__append_3419 = aout.module
+@COND_i386_efi_TRUE@am__append_3420 = aout.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3421 =
+@COND_i386_efi_TRUE@am__append_3422 = $(nodist_aout_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3423 = $(nodist_aout_module_SOURCES) \
+@COND_i386_efi_TRUE@ aout.marker
+@COND_i386_efi_TRUE@am__append_3424 = aout.mod
+@COND_i386_efi_TRUE@am__append_3425 = aout.marker
+@COND_i386_qemu_TRUE@am__append_3426 = aout.module
+@COND_i386_qemu_TRUE@am__append_3427 = aout.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_3428 =
+@COND_i386_qemu_TRUE@am__append_3429 = $(nodist_aout_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_3430 = $(nodist_aout_module_SOURCES) \
+@COND_i386_qemu_TRUE@ aout.marker
+@COND_i386_qemu_TRUE@am__append_3431 = aout.mod
+@COND_i386_qemu_TRUE@am__append_3432 = aout.marker
+@COND_i386_coreboot_TRUE@am__append_3433 = aout.module
+@COND_i386_coreboot_TRUE@am__append_3434 = aout.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3435 =
+@COND_i386_coreboot_TRUE@am__append_3436 = $(nodist_aout_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3437 = \
+@COND_i386_coreboot_TRUE@ $(nodist_aout_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ aout.marker
+@COND_i386_coreboot_TRUE@am__append_3438 = aout.mod
+@COND_i386_coreboot_TRUE@am__append_3439 = aout.marker
+@COND_i386_multiboot_TRUE@am__append_3440 = aout.module
+@COND_i386_multiboot_TRUE@am__append_3441 = aout.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3442 =
+@COND_i386_multiboot_TRUE@am__append_3443 = $(nodist_aout_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3444 = \
+@COND_i386_multiboot_TRUE@ $(nodist_aout_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ aout.marker
+@COND_i386_multiboot_TRUE@am__append_3445 = aout.mod
+@COND_i386_multiboot_TRUE@am__append_3446 = aout.marker
+@COND_i386_ieee1275_TRUE@am__append_3447 = aout.module
+@COND_i386_ieee1275_TRUE@am__append_3448 = aout.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_3449 =
+@COND_i386_ieee1275_TRUE@am__append_3450 = $(nodist_aout_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_3451 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_aout_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ aout.marker
+@COND_i386_ieee1275_TRUE@am__append_3452 = aout.mod
+@COND_i386_ieee1275_TRUE@am__append_3453 = aout.marker
+@COND_x86_64_efi_TRUE@am__append_3454 = aout.module
+@COND_x86_64_efi_TRUE@am__append_3455 = aout.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3456 =
+@COND_x86_64_efi_TRUE@am__append_3457 = $(nodist_aout_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3458 = $(nodist_aout_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ aout.marker
+@COND_x86_64_efi_TRUE@am__append_3459 = aout.mod
+@COND_x86_64_efi_TRUE@am__append_3460 = aout.marker
+@COND_i386_pc_TRUE@am__append_3461 = bsd.module
+@COND_i386_pc_TRUE@am__append_3462 = bsd.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@bsd_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3463 = loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+@COND_i386_pc_TRUE@am__append_3464 = $(nodist_bsd_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3465 = $(nodist_bsd_module_SOURCES) \
+@COND_i386_pc_TRUE@ bsd.marker
+@COND_i386_pc_TRUE@am__append_3466 = bsd.mod
+@COND_i386_pc_TRUE@am__append_3467 = bsd.marker
+@COND_i386_efi_TRUE@am__append_3468 = bsd.module
+@COND_i386_efi_TRUE@am__append_3469 = bsd.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3470 = loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+@COND_i386_efi_TRUE@am__append_3471 = $(nodist_bsd_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3472 = $(nodist_bsd_module_SOURCES) \
+@COND_i386_efi_TRUE@ bsd.marker
+@COND_i386_efi_TRUE@am__append_3473 = bsd.mod
+@COND_i386_efi_TRUE@am__append_3474 = bsd.marker
+@COND_i386_qemu_TRUE@am__append_3475 = bsd.module
+@COND_i386_qemu_TRUE@am__append_3476 = bsd.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_3477 = loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+@COND_i386_qemu_TRUE@am__append_3478 = $(nodist_bsd_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_3479 = $(nodist_bsd_module_SOURCES) \
+@COND_i386_qemu_TRUE@ bsd.marker
+@COND_i386_qemu_TRUE@am__append_3480 = bsd.mod
+@COND_i386_qemu_TRUE@am__append_3481 = bsd.marker
+@COND_i386_coreboot_TRUE@am__append_3482 = bsd.module
+@COND_i386_coreboot_TRUE@am__append_3483 = bsd.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3484 = loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+@COND_i386_coreboot_TRUE@am__append_3485 = $(nodist_bsd_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3486 = \
+@COND_i386_coreboot_TRUE@ $(nodist_bsd_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ bsd.marker
+@COND_i386_coreboot_TRUE@am__append_3487 = bsd.mod
+@COND_i386_coreboot_TRUE@am__append_3488 = bsd.marker
+@COND_i386_multiboot_TRUE@am__append_3489 = bsd.module
+@COND_i386_multiboot_TRUE@am__append_3490 = bsd.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3491 = loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+@COND_i386_multiboot_TRUE@am__append_3492 = $(nodist_bsd_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3493 = \
+@COND_i386_multiboot_TRUE@ $(nodist_bsd_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ bsd.marker
+@COND_i386_multiboot_TRUE@am__append_3494 = bsd.mod
+@COND_i386_multiboot_TRUE@am__append_3495 = bsd.marker
+@COND_i386_ieee1275_TRUE@am__append_3496 = bsd.module
+@COND_i386_ieee1275_TRUE@am__append_3497 = bsd.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_3498 = loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+@COND_i386_ieee1275_TRUE@am__append_3499 = $(nodist_bsd_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_3500 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_bsd_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ bsd.marker
+@COND_i386_ieee1275_TRUE@am__append_3501 = bsd.mod
+@COND_i386_ieee1275_TRUE@am__append_3502 = bsd.marker
+@COND_x86_64_efi_TRUE@am__append_3503 = bsd.module
+@COND_x86_64_efi_TRUE@am__append_3504 = bsd.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3505 = loader/i386/bsdXX.c loader/i386/bsd_pagetable.c
+@COND_x86_64_efi_TRUE@am__append_3506 = $(nodist_bsd_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3507 = $(nodist_bsd_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ bsd.marker
+@COND_x86_64_efi_TRUE@am__append_3508 = bsd.mod
+@COND_x86_64_efi_TRUE@am__append_3509 = bsd.marker
+@COND_i386_pc_TRUE@am__append_3510 = plan9.module linux16.module
+@COND_i386_pc_TRUE@am__append_3511 = plan9.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ linux16.module$(EXEEXT)
+@COND_i386_pc_FALSE@plan9_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3512 =
+@COND_i386_pc_TRUE@am__append_3513 = $(nodist_plan9_module_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_linux16_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3514 = $(nodist_plan9_module_SOURCES) \
+@COND_i386_pc_TRUE@ plan9.marker \
+@COND_i386_pc_TRUE@ $(nodist_linux16_module_SOURCES) \
+@COND_i386_pc_TRUE@ linux16.marker
+@COND_i386_pc_TRUE@am__append_3515 = plan9.mod linux16.mod
+@COND_i386_pc_TRUE@am__append_3516 = plan9.marker linux16.marker
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@linux16_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_3517 = linux16.module
+@COND_i386_efi_TRUE@am__append_3518 = linux16.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3519 =
+@COND_i386_efi_TRUE@am__append_3520 = $(nodist_linux16_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3521 = \
+@COND_i386_efi_TRUE@ $(nodist_linux16_module_SOURCES) \
+@COND_i386_efi_TRUE@ linux16.marker
+@COND_i386_efi_TRUE@am__append_3522 = linux16.mod
+@COND_i386_efi_TRUE@am__append_3523 = linux16.marker
+@COND_i386_qemu_TRUE@am__append_3524 = linux16.module
+@COND_i386_qemu_TRUE@am__append_3525 = linux16.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_3526 =
+@COND_i386_qemu_TRUE@am__append_3527 = $(nodist_linux16_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_3528 = \
+@COND_i386_qemu_TRUE@ $(nodist_linux16_module_SOURCES) \
+@COND_i386_qemu_TRUE@ linux16.marker
+@COND_i386_qemu_TRUE@am__append_3529 = linux16.mod
+@COND_i386_qemu_TRUE@am__append_3530 = linux16.marker
+@COND_i386_coreboot_TRUE@am__append_3531 = linux16.module
+@COND_i386_coreboot_TRUE@am__append_3532 = linux16.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3533 =
+@COND_i386_coreboot_TRUE@am__append_3534 = $(nodist_linux16_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3535 = \
+@COND_i386_coreboot_TRUE@ $(nodist_linux16_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ linux16.marker
+@COND_i386_coreboot_TRUE@am__append_3536 = linux16.mod
+@COND_i386_coreboot_TRUE@am__append_3537 = linux16.marker
+@COND_i386_multiboot_TRUE@am__append_3538 = linux16.module
+@COND_i386_multiboot_TRUE@am__append_3539 = linux16.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3540 =
+@COND_i386_multiboot_TRUE@am__append_3541 = $(nodist_linux16_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3542 = \
+@COND_i386_multiboot_TRUE@ $(nodist_linux16_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ linux16.marker
+@COND_i386_multiboot_TRUE@am__append_3543 = linux16.mod
+@COND_i386_multiboot_TRUE@am__append_3544 = linux16.marker
+@COND_i386_ieee1275_TRUE@am__append_3545 = linux16.module
+@COND_i386_ieee1275_TRUE@am__append_3546 = linux16.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_3547 =
+@COND_i386_ieee1275_TRUE@am__append_3548 = $(nodist_linux16_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_3549 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_linux16_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ linux16.marker
+@COND_i386_ieee1275_TRUE@am__append_3550 = linux16.mod
+@COND_i386_ieee1275_TRUE@am__append_3551 = linux16.marker
+@COND_x86_64_efi_TRUE@am__append_3552 = linux16.module
+@COND_x86_64_efi_TRUE@am__append_3553 = linux16.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3554 =
+@COND_x86_64_efi_TRUE@am__append_3555 = $(nodist_linux16_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3556 = \
+@COND_x86_64_efi_TRUE@ $(nodist_linux16_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ linux16.marker
+@COND_x86_64_efi_TRUE@am__append_3557 = linux16.mod
+@COND_x86_64_efi_TRUE@am__append_3558 = linux16.marker
+@COND_i386_pc_TRUE@am__append_3559 = ntldr.module truecrypt.module \
+@COND_i386_pc_TRUE@ freedos.module pxechain.module \
+@COND_i386_pc_TRUE@ multiboot2.module
+@COND_i386_pc_TRUE@am__append_3560 = ntldr.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ truecrypt.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ freedos.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ pxechain.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ multiboot2.module$(EXEEXT)
+@COND_i386_pc_FALSE@ntldr_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3561 =
+@COND_i386_pc_TRUE@am__append_3562 = $(nodist_ntldr_module_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_truecrypt_module_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_freedos_module_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_pxechain_module_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_multiboot2_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3563 = $(nodist_ntldr_module_SOURCES) \
+@COND_i386_pc_TRUE@ ntldr.marker \
+@COND_i386_pc_TRUE@ $(nodist_truecrypt_module_SOURCES) \
+@COND_i386_pc_TRUE@ truecrypt.marker \
+@COND_i386_pc_TRUE@ $(nodist_freedos_module_SOURCES) \
+@COND_i386_pc_TRUE@ freedos.marker \
+@COND_i386_pc_TRUE@ $(nodist_pxechain_module_SOURCES) \
+@COND_i386_pc_TRUE@ pxechain.marker \
+@COND_i386_pc_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_i386_pc_TRUE@ multiboot2.marker
+@COND_i386_pc_TRUE@am__append_3564 = ntldr.mod truecrypt.mod \
+@COND_i386_pc_TRUE@ freedos.mod pxechain.mod multiboot2.mod
+@COND_i386_pc_TRUE@am__append_3565 = ntldr.marker truecrypt.marker \
+@COND_i386_pc_TRUE@ freedos.marker pxechain.marker \
+@COND_i386_pc_TRUE@ multiboot2.marker
+@COND_i386_pc_FALSE@truecrypt_module_DEPENDENCIES =
+@COND_i386_pc_FALSE@freedos_module_DEPENDENCIES =
+@COND_i386_pc_FALSE@pxechain_module_DEPENDENCIES =
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_FALSE@multiboot2_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_3566 = multiboot2.module
+@COND_i386_efi_TRUE@am__append_3567 = multiboot2.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3568 =
+@COND_i386_efi_TRUE@am__append_3569 = $(nodist_multiboot2_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3570 = \
+@COND_i386_efi_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_i386_efi_TRUE@ multiboot2.marker
+@COND_i386_efi_TRUE@am__append_3571 = multiboot2.mod
+@COND_i386_efi_TRUE@am__append_3572 = multiboot2.marker
+@COND_i386_qemu_TRUE@am__append_3573 = multiboot2.module
+@COND_i386_qemu_TRUE@am__append_3574 = multiboot2.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_3575 =
+@COND_i386_qemu_TRUE@am__append_3576 = $(nodist_multiboot2_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_3577 = \
+@COND_i386_qemu_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_i386_qemu_TRUE@ multiboot2.marker
+@COND_i386_qemu_TRUE@am__append_3578 = multiboot2.mod
+@COND_i386_qemu_TRUE@am__append_3579 = multiboot2.marker
+@COND_i386_coreboot_TRUE@am__append_3580 = multiboot2.module
+@COND_i386_coreboot_TRUE@am__append_3581 = multiboot2.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3582 =
+@COND_i386_coreboot_TRUE@am__append_3583 = $(nodist_multiboot2_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3584 = \
+@COND_i386_coreboot_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ multiboot2.marker
+@COND_i386_coreboot_TRUE@am__append_3585 = multiboot2.mod
+@COND_i386_coreboot_TRUE@am__append_3586 = multiboot2.marker
+@COND_i386_multiboot_TRUE@am__append_3587 = multiboot2.module
+@COND_i386_multiboot_TRUE@am__append_3588 = multiboot2.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3589 =
+@COND_i386_multiboot_TRUE@am__append_3590 = $(nodist_multiboot2_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3591 = \
+@COND_i386_multiboot_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ multiboot2.marker
+@COND_i386_multiboot_TRUE@am__append_3592 = multiboot2.mod
+@COND_i386_multiboot_TRUE@am__append_3593 = multiboot2.marker
+@COND_i386_ieee1275_TRUE@am__append_3594 = multiboot2.module
+@COND_i386_ieee1275_TRUE@am__append_3595 = multiboot2.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_3596 =
+@COND_i386_ieee1275_TRUE@am__append_3597 = $(nodist_multiboot2_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_3598 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ multiboot2.marker
+@COND_i386_ieee1275_TRUE@am__append_3599 = multiboot2.mod
+@COND_i386_ieee1275_TRUE@am__append_3600 = multiboot2.marker
+@COND_x86_64_efi_TRUE@am__append_3601 = multiboot2.module
+@COND_x86_64_efi_TRUE@am__append_3602 = multiboot2.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3603 =
+@COND_x86_64_efi_TRUE@am__append_3604 = $(nodist_multiboot2_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3605 = \
+@COND_x86_64_efi_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ multiboot2.marker
+@COND_x86_64_efi_TRUE@am__append_3606 = multiboot2.mod
+@COND_x86_64_efi_TRUE@am__append_3607 = multiboot2.marker
+@COND_i386_xen_pvh_TRUE@am__append_3608 = multiboot2.module
+@COND_i386_xen_pvh_TRUE@am__append_3609 = multiboot2.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_3610 =
+@COND_i386_xen_pvh_TRUE@am__append_3611 = $(nodist_multiboot2_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_3612 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ multiboot2.marker
+@COND_i386_xen_pvh_TRUE@am__append_3613 = multiboot2.mod
+@COND_i386_xen_pvh_TRUE@am__append_3614 = multiboot2.marker
+@COND_mips_loongson_TRUE@am__append_3615 = multiboot2.module
+@COND_mips_loongson_TRUE@am__append_3616 = multiboot2.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_3617 =
+@COND_mips_loongson_TRUE@am__append_3618 = $(nodist_multiboot2_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_3619 = \
+@COND_mips_loongson_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_mips_loongson_TRUE@ multiboot2.marker
+@COND_mips_loongson_TRUE@am__append_3620 = multiboot2.mod
+@COND_mips_loongson_TRUE@am__append_3621 = multiboot2.marker
+@COND_mips_arc_TRUE@am__append_3622 = multiboot2.module
+@COND_mips_arc_TRUE@am__append_3623 = multiboot2.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_3624 =
+@COND_mips_arc_TRUE@am__append_3625 = $(nodist_multiboot2_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_3626 = \
+@COND_mips_arc_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_mips_arc_TRUE@ multiboot2.marker
+@COND_mips_arc_TRUE@am__append_3627 = multiboot2.mod
+@COND_mips_arc_TRUE@am__append_3628 = multiboot2.marker
+@COND_mips_qemu_mips_TRUE@am__append_3629 = multiboot2.module
+@COND_mips_qemu_mips_TRUE@am__append_3630 = multiboot2.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_3631 =
+@COND_mips_qemu_mips_TRUE@am__append_3632 = $(nodist_multiboot2_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_3633 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_multiboot2_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ multiboot2.marker
+@COND_mips_qemu_mips_TRUE@am__append_3634 = multiboot2.mod
+@COND_mips_qemu_mips_TRUE@am__append_3635 = multiboot2.marker
+@COND_i386_pc_TRUE@am__append_3636 = multiboot.module
+@COND_i386_pc_TRUE@am__append_3637 = multiboot.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@multiboot_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3638 = loader/multiboot_elfxx.c
+@COND_i386_pc_TRUE@am__append_3639 = $(nodist_multiboot_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3640 = \
+@COND_i386_pc_TRUE@ $(nodist_multiboot_module_SOURCES) \
+@COND_i386_pc_TRUE@ multiboot.marker
+@COND_i386_pc_TRUE@am__append_3641 = multiboot.mod
+@COND_i386_pc_TRUE@am__append_3642 = multiboot.marker
+@COND_i386_efi_TRUE@am__append_3643 = multiboot.module
+@COND_i386_efi_TRUE@am__append_3644 = multiboot.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3645 = loader/multiboot_elfxx.c
+@COND_i386_efi_TRUE@am__append_3646 = $(nodist_multiboot_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3647 = \
+@COND_i386_efi_TRUE@ $(nodist_multiboot_module_SOURCES) \
+@COND_i386_efi_TRUE@ multiboot.marker
+@COND_i386_efi_TRUE@am__append_3648 = multiboot.mod
+@COND_i386_efi_TRUE@am__append_3649 = multiboot.marker
+@COND_i386_qemu_TRUE@am__append_3650 = multiboot.module
+@COND_i386_qemu_TRUE@am__append_3651 = multiboot.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_3652 = loader/multiboot_elfxx.c
+@COND_i386_qemu_TRUE@am__append_3653 = $(nodist_multiboot_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_3654 = \
+@COND_i386_qemu_TRUE@ $(nodist_multiboot_module_SOURCES) \
+@COND_i386_qemu_TRUE@ multiboot.marker
+@COND_i386_qemu_TRUE@am__append_3655 = multiboot.mod
+@COND_i386_qemu_TRUE@am__append_3656 = multiboot.marker
+@COND_i386_coreboot_TRUE@am__append_3657 = multiboot.module
+@COND_i386_coreboot_TRUE@am__append_3658 = multiboot.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3659 = loader/multiboot_elfxx.c
+@COND_i386_coreboot_TRUE@am__append_3660 = $(nodist_multiboot_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3661 = \
+@COND_i386_coreboot_TRUE@ $(nodist_multiboot_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ multiboot.marker
+@COND_i386_coreboot_TRUE@am__append_3662 = multiboot.mod
+@COND_i386_coreboot_TRUE@am__append_3663 = multiboot.marker
+@COND_i386_multiboot_TRUE@am__append_3664 = multiboot.module
+@COND_i386_multiboot_TRUE@am__append_3665 = multiboot.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3666 = loader/multiboot_elfxx.c
+@COND_i386_multiboot_TRUE@am__append_3667 = $(nodist_multiboot_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3668 = \
+@COND_i386_multiboot_TRUE@ $(nodist_multiboot_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ multiboot.marker
+@COND_i386_multiboot_TRUE@am__append_3669 = multiboot.mod
+@COND_i386_multiboot_TRUE@am__append_3670 = multiboot.marker
+@COND_i386_ieee1275_TRUE@am__append_3671 = multiboot.module
+@COND_i386_ieee1275_TRUE@am__append_3672 = multiboot.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_3673 = loader/multiboot_elfxx.c
+@COND_i386_ieee1275_TRUE@am__append_3674 = $(nodist_multiboot_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_3675 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_multiboot_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ multiboot.marker
+@COND_i386_ieee1275_TRUE@am__append_3676 = multiboot.mod
+@COND_i386_ieee1275_TRUE@am__append_3677 = multiboot.marker
+@COND_x86_64_efi_TRUE@am__append_3678 = multiboot.module
+@COND_x86_64_efi_TRUE@am__append_3679 = multiboot.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3680 = loader/multiboot_elfxx.c
+@COND_x86_64_efi_TRUE@am__append_3681 = $(nodist_multiboot_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3682 = \
+@COND_x86_64_efi_TRUE@ $(nodist_multiboot_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ multiboot.marker
+@COND_x86_64_efi_TRUE@am__append_3683 = multiboot.mod
+@COND_x86_64_efi_TRUE@am__append_3684 = multiboot.marker
+@COND_i386_xen_pvh_TRUE@am__append_3685 = multiboot.module
+@COND_i386_xen_pvh_TRUE@am__append_3686 = multiboot.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_3687 = loader/multiboot_elfxx.c
+@COND_i386_xen_pvh_TRUE@am__append_3688 = $(nodist_multiboot_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_3689 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_multiboot_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ multiboot.marker
+@COND_i386_xen_pvh_TRUE@am__append_3690 = multiboot.mod
+@COND_i386_xen_pvh_TRUE@am__append_3691 = multiboot.marker
+@COND_arm64_efi_TRUE@am__append_3692 = xen_boot.module
+@COND_arm64_efi_TRUE@am__append_3693 = xen_boot.module$(EXEEXT)
+@COND_arm64_efi_FALSE@xen_boot_module_DEPENDENCIES =
+@COND_arm64_efi_TRUE@am__append_3694 =
+@COND_arm64_efi_TRUE@am__append_3695 = $(nodist_xen_boot_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_3696 = \
+@COND_arm64_efi_TRUE@ $(nodist_xen_boot_module_SOURCES) \
+@COND_arm64_efi_TRUE@ xen_boot.marker
+@COND_arm64_efi_TRUE@am__append_3697 = xen_boot.mod
+@COND_arm64_efi_TRUE@am__append_3698 = xen_boot.marker
+@COND_i386_pc_TRUE@am__append_3699 = linux.module
+@COND_i386_pc_TRUE@am__append_3700 = linux.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@linux_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3701 =
+@COND_i386_pc_TRUE@am__append_3702 = $(nodist_linux_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3703 = $(nodist_linux_module_SOURCES) \
+@COND_i386_pc_TRUE@ linux.marker
+@COND_i386_pc_TRUE@am__append_3704 = linux.mod
+@COND_i386_pc_TRUE@am__append_3705 = linux.marker
+@COND_i386_efi_TRUE@am__append_3706 = linux.module
+@COND_i386_efi_TRUE@am__append_3707 = linux.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3708 =
+@COND_i386_efi_TRUE@am__append_3709 = $(nodist_linux_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3710 = $(nodist_linux_module_SOURCES) \
+@COND_i386_efi_TRUE@ linux.marker
+@COND_i386_efi_TRUE@am__append_3711 = linux.mod
+@COND_i386_efi_TRUE@am__append_3712 = linux.marker
+@COND_i386_qemu_TRUE@am__append_3713 = linux.module
+@COND_i386_qemu_TRUE@am__append_3714 = linux.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_3715 =
+@COND_i386_qemu_TRUE@am__append_3716 = $(nodist_linux_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_3717 = $(nodist_linux_module_SOURCES) \
+@COND_i386_qemu_TRUE@ linux.marker
+@COND_i386_qemu_TRUE@am__append_3718 = linux.mod
+@COND_i386_qemu_TRUE@am__append_3719 = linux.marker
+@COND_i386_coreboot_TRUE@am__append_3720 = linux.module
+@COND_i386_coreboot_TRUE@am__append_3721 = linux.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3722 =
+@COND_i386_coreboot_TRUE@am__append_3723 = $(nodist_linux_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3724 = \
+@COND_i386_coreboot_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ linux.marker
+@COND_i386_coreboot_TRUE@am__append_3725 = linux.mod
+@COND_i386_coreboot_TRUE@am__append_3726 = linux.marker
+@COND_i386_multiboot_TRUE@am__append_3727 = linux.module
+@COND_i386_multiboot_TRUE@am__append_3728 = linux.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3729 =
+@COND_i386_multiboot_TRUE@am__append_3730 = $(nodist_linux_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3731 = \
+@COND_i386_multiboot_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ linux.marker
+@COND_i386_multiboot_TRUE@am__append_3732 = linux.mod
+@COND_i386_multiboot_TRUE@am__append_3733 = linux.marker
+@COND_i386_ieee1275_TRUE@am__append_3734 = linux.module
+@COND_i386_ieee1275_TRUE@am__append_3735 = linux.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_3736 =
+@COND_i386_ieee1275_TRUE@am__append_3737 = $(nodist_linux_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_3738 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ linux.marker
+@COND_i386_ieee1275_TRUE@am__append_3739 = linux.mod
+@COND_i386_ieee1275_TRUE@am__append_3740 = linux.marker
+@COND_x86_64_efi_TRUE@am__append_3741 = linux.module
+@COND_x86_64_efi_TRUE@am__append_3742 = linux.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3743 =
+@COND_x86_64_efi_TRUE@am__append_3744 = $(nodist_linux_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3745 = \
+@COND_x86_64_efi_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ linux.marker
+@COND_x86_64_efi_TRUE@am__append_3746 = linux.mod
+@COND_x86_64_efi_TRUE@am__append_3747 = linux.marker
+@COND_i386_xen_TRUE@am__append_3748 = linux.module
+@COND_i386_xen_TRUE@am__append_3749 = linux.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_3750 =
+@COND_i386_xen_TRUE@am__append_3751 = $(nodist_linux_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_3752 = $(nodist_linux_module_SOURCES) \
+@COND_i386_xen_TRUE@ linux.marker
+@COND_i386_xen_TRUE@am__append_3753 = linux.mod
+@COND_i386_xen_TRUE@am__append_3754 = linux.marker
+@COND_x86_64_xen_TRUE@am__append_3755 = linux.module
+@COND_x86_64_xen_TRUE@am__append_3756 = linux.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_3757 =
+@COND_x86_64_xen_TRUE@am__append_3758 = $(nodist_linux_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_3759 = \
+@COND_x86_64_xen_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ linux.marker
+@COND_x86_64_xen_TRUE@am__append_3760 = linux.mod
+@COND_x86_64_xen_TRUE@am__append_3761 = linux.marker
+@COND_i386_xen_pvh_TRUE@am__append_3762 = linux.module
+@COND_i386_xen_pvh_TRUE@am__append_3763 = linux.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_3764 =
+@COND_i386_xen_pvh_TRUE@am__append_3765 = $(nodist_linux_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_3766 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ linux.marker
+@COND_i386_xen_pvh_TRUE@am__append_3767 = linux.mod
+@COND_i386_xen_pvh_TRUE@am__append_3768 = linux.marker
+@COND_mips_loongson_TRUE@am__append_3769 = linux.module
+@COND_mips_loongson_TRUE@am__append_3770 = linux.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_3771 =
+@COND_mips_loongson_TRUE@am__append_3772 = $(nodist_linux_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_3773 = \
+@COND_mips_loongson_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_mips_loongson_TRUE@ linux.marker
+@COND_mips_loongson_TRUE@am__append_3774 = linux.mod
+@COND_mips_loongson_TRUE@am__append_3775 = linux.marker
+@COND_sparc64_ieee1275_TRUE@am__append_3776 = linux.module
+@COND_sparc64_ieee1275_TRUE@am__append_3777 = linux.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_3778 =
+@COND_sparc64_ieee1275_TRUE@am__append_3779 = $(nodist_linux_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_3780 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ linux.marker
+@COND_sparc64_ieee1275_TRUE@am__append_3781 = linux.mod
+@COND_sparc64_ieee1275_TRUE@am__append_3782 = linux.marker
+@COND_powerpc_ieee1275_TRUE@am__append_3783 = linux.module
+@COND_powerpc_ieee1275_TRUE@am__append_3784 = linux.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_3785 =
+@COND_powerpc_ieee1275_TRUE@am__append_3786 = $(nodist_linux_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_3787 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ linux.marker
+@COND_powerpc_ieee1275_TRUE@am__append_3788 = linux.mod
+@COND_powerpc_ieee1275_TRUE@am__append_3789 = linux.marker
+@COND_mips_arc_TRUE@am__append_3790 = linux.module
+@COND_mips_arc_TRUE@am__append_3791 = linux.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_3792 =
+@COND_mips_arc_TRUE@am__append_3793 = $(nodist_linux_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_3794 = $(nodist_linux_module_SOURCES) \
+@COND_mips_arc_TRUE@ linux.marker
+@COND_mips_arc_TRUE@am__append_3795 = linux.mod
+@COND_mips_arc_TRUE@am__append_3796 = linux.marker
+@COND_ia64_efi_TRUE@am__append_3797 = linux.module
+@COND_ia64_efi_TRUE@am__append_3798 = linux.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_3799 =
+@COND_ia64_efi_TRUE@am__append_3800 = $(nodist_linux_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_3801 = $(nodist_linux_module_SOURCES) \
+@COND_ia64_efi_TRUE@ linux.marker
+@COND_ia64_efi_TRUE@am__append_3802 = linux.mod
+@COND_ia64_efi_TRUE@am__append_3803 = linux.marker
+@COND_mips_qemu_mips_TRUE@am__append_3804 = linux.module
+@COND_mips_qemu_mips_TRUE@am__append_3805 = linux.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_3806 =
+@COND_mips_qemu_mips_TRUE@am__append_3807 = $(nodist_linux_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_3808 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ linux.marker
+@COND_mips_qemu_mips_TRUE@am__append_3809 = linux.mod
+@COND_mips_qemu_mips_TRUE@am__append_3810 = linux.marker
+@COND_arm_uboot_TRUE@am__append_3811 = linux.module
+@COND_arm_uboot_TRUE@am__append_3812 = linux.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__append_3813 =
+@COND_arm_uboot_TRUE@am__append_3814 = $(nodist_linux_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_3815 = $(nodist_linux_module_SOURCES) \
+@COND_arm_uboot_TRUE@ linux.marker
+@COND_arm_uboot_TRUE@am__append_3816 = linux.mod
+@COND_arm_uboot_TRUE@am__append_3817 = linux.marker
+@COND_arm_efi_TRUE@am__append_3818 = linux.module
+@COND_arm_efi_TRUE@am__append_3819 = linux.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_3820 =
+@COND_arm_efi_TRUE@am__append_3821 = $(nodist_linux_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_3822 = $(nodist_linux_module_SOURCES) \
+@COND_arm_efi_TRUE@ linux.marker
+@COND_arm_efi_TRUE@am__append_3823 = linux.mod
+@COND_arm_efi_TRUE@am__append_3824 = linux.marker
+@COND_arm64_efi_TRUE@am__append_3825 = linux.module
+@COND_arm64_efi_TRUE@am__append_3826 = linux.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_3827 =
+@COND_arm64_efi_TRUE@am__append_3828 = $(nodist_linux_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_3829 = $(nodist_linux_module_SOURCES) \
+@COND_arm64_efi_TRUE@ linux.marker
+@COND_arm64_efi_TRUE@am__append_3830 = linux.mod
+@COND_arm64_efi_TRUE@am__append_3831 = linux.marker
+@COND_arm_coreboot_TRUE@am__append_3832 = linux.module
+@COND_arm_coreboot_TRUE@am__append_3833 = linux.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_3834 =
+@COND_arm_coreboot_TRUE@am__append_3835 = $(nodist_linux_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_3836 = \
+@COND_arm_coreboot_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ linux.marker
+@COND_arm_coreboot_TRUE@am__append_3837 = linux.mod
+@COND_arm_coreboot_TRUE@am__append_3838 = linux.marker
+@COND_riscv32_efi_TRUE@am__append_3839 = linux.module
+@COND_riscv32_efi_TRUE@am__append_3840 = linux.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_3841 =
+@COND_riscv32_efi_TRUE@am__append_3842 = $(nodist_linux_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_3843 = \
+@COND_riscv32_efi_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ linux.marker
+@COND_riscv32_efi_TRUE@am__append_3844 = linux.mod
+@COND_riscv32_efi_TRUE@am__append_3845 = linux.marker
+@COND_riscv64_efi_TRUE@am__append_3846 = linux.module
+@COND_riscv64_efi_TRUE@am__append_3847 = linux.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_3848 =
+@COND_riscv64_efi_TRUE@am__append_3849 = $(nodist_linux_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_3850 = \
+@COND_riscv64_efi_TRUE@ $(nodist_linux_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ linux.marker
+@COND_riscv64_efi_TRUE@am__append_3851 = linux.mod
+@COND_riscv64_efi_TRUE@am__append_3852 = linux.marker
+@COND_arm_uboot_TRUE@am__append_3853 = fdt.module
+@COND_arm_uboot_TRUE@am__append_3854 = fdt.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@fdt_module_DEPENDENCIES =
+@COND_arm_uboot_TRUE@am__append_3855 =
+@COND_arm_uboot_TRUE@am__append_3856 = $(nodist_fdt_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_3857 = $(nodist_fdt_module_SOURCES) \
+@COND_arm_uboot_TRUE@ fdt.marker
+@COND_arm_uboot_TRUE@am__append_3858 = fdt.mod
+@COND_arm_uboot_TRUE@am__append_3859 = fdt.marker
+@COND_arm_efi_TRUE@am__append_3860 = fdt.module
+@COND_arm_efi_TRUE@am__append_3861 = fdt.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_3862 =
+@COND_arm_efi_TRUE@am__append_3863 = $(nodist_fdt_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_3864 = $(nodist_fdt_module_SOURCES) \
+@COND_arm_efi_TRUE@ fdt.marker
+@COND_arm_efi_TRUE@am__append_3865 = fdt.mod
+@COND_arm_efi_TRUE@am__append_3866 = fdt.marker
+@COND_arm64_efi_TRUE@am__append_3867 = fdt.module
+@COND_arm64_efi_TRUE@am__append_3868 = fdt.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_3869 =
+@COND_arm64_efi_TRUE@am__append_3870 = $(nodist_fdt_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_3871 = $(nodist_fdt_module_SOURCES) \
+@COND_arm64_efi_TRUE@ fdt.marker
+@COND_arm64_efi_TRUE@am__append_3872 = fdt.mod
+@COND_arm64_efi_TRUE@am__append_3873 = fdt.marker
+@COND_riscv32_efi_TRUE@am__append_3874 = fdt.module
+@COND_riscv32_efi_TRUE@am__append_3875 = fdt.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_3876 =
+@COND_riscv32_efi_TRUE@am__append_3877 = $(nodist_fdt_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_3878 = $(nodist_fdt_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ fdt.marker
+@COND_riscv32_efi_TRUE@am__append_3879 = fdt.mod
+@COND_riscv32_efi_TRUE@am__append_3880 = fdt.marker
+@COND_riscv64_efi_TRUE@am__append_3881 = fdt.module
+@COND_riscv64_efi_TRUE@am__append_3882 = fdt.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_3883 =
+@COND_riscv64_efi_TRUE@am__append_3884 = $(nodist_fdt_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_3885 = $(nodist_fdt_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ fdt.marker
+@COND_riscv64_efi_TRUE@am__append_3886 = fdt.mod
+@COND_riscv64_efi_TRUE@am__append_3887 = fdt.marker
+@COND_i386_pc_TRUE@am__append_3888 = xnu.module
+@COND_i386_pc_TRUE@am__append_3889 = xnu.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_x86_64_efi_FALSE@xnu_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3890 =
+@COND_i386_pc_TRUE@am__append_3891 = $(nodist_xnu_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3892 = $(nodist_xnu_module_SOURCES) \
+@COND_i386_pc_TRUE@ xnu.marker
+@COND_i386_pc_TRUE@am__append_3893 = xnu.mod
+@COND_i386_pc_TRUE@am__append_3894 = xnu.marker
+@COND_i386_efi_TRUE@am__append_3895 = xnu.module
+@COND_i386_efi_TRUE@am__append_3896 = xnu.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3897 =
+@COND_i386_efi_TRUE@am__append_3898 = $(nodist_xnu_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3899 = $(nodist_xnu_module_SOURCES) \
+@COND_i386_efi_TRUE@ xnu.marker
+@COND_i386_efi_TRUE@am__append_3900 = xnu.mod
+@COND_i386_efi_TRUE@am__append_3901 = xnu.marker
+@COND_i386_coreboot_TRUE@am__append_3902 = xnu.module
+@COND_i386_coreboot_TRUE@am__append_3903 = xnu.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3904 =
+@COND_i386_coreboot_TRUE@am__append_3905 = $(nodist_xnu_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3906 = \
+@COND_i386_coreboot_TRUE@ $(nodist_xnu_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ xnu.marker
+@COND_i386_coreboot_TRUE@am__append_3907 = xnu.mod
+@COND_i386_coreboot_TRUE@am__append_3908 = xnu.marker
+@COND_i386_multiboot_TRUE@am__append_3909 = xnu.module
+@COND_i386_multiboot_TRUE@am__append_3910 = xnu.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3911 =
+@COND_i386_multiboot_TRUE@am__append_3912 = $(nodist_xnu_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3913 = \
+@COND_i386_multiboot_TRUE@ $(nodist_xnu_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ xnu.marker
+@COND_i386_multiboot_TRUE@am__append_3914 = xnu.mod
+@COND_i386_multiboot_TRUE@am__append_3915 = xnu.marker
+@COND_x86_64_efi_TRUE@am__append_3916 = xnu.module
+@COND_x86_64_efi_TRUE@am__append_3917 = xnu.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3918 =
+@COND_x86_64_efi_TRUE@am__append_3919 = $(nodist_xnu_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3920 = $(nodist_xnu_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ xnu.marker
+@COND_x86_64_efi_TRUE@am__append_3921 = xnu.mod
+@COND_x86_64_efi_TRUE@am__append_3922 = xnu.marker
+@COND_i386_pc_TRUE@am__append_3923 = random.module
+@COND_i386_pc_TRUE@am__append_3924 = random.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_x86_64_efi_FALSE@random_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3925 =
+@COND_i386_pc_TRUE@am__append_3926 = $(nodist_random_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3927 = $(nodist_random_module_SOURCES) \
+@COND_i386_pc_TRUE@ random.marker
+@COND_i386_pc_TRUE@am__append_3928 = random.mod
+@COND_i386_pc_TRUE@am__append_3929 = random.marker
+@COND_i386_efi_TRUE@am__append_3930 = random.module
+@COND_i386_efi_TRUE@am__append_3931 = random.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3932 =
+@COND_i386_efi_TRUE@am__append_3933 = $(nodist_random_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3934 = $(nodist_random_module_SOURCES) \
+@COND_i386_efi_TRUE@ random.marker
+@COND_i386_efi_TRUE@am__append_3935 = random.mod
+@COND_i386_efi_TRUE@am__append_3936 = random.marker
+@COND_i386_coreboot_TRUE@am__append_3937 = random.module
+@COND_i386_coreboot_TRUE@am__append_3938 = random.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3939 =
+@COND_i386_coreboot_TRUE@am__append_3940 = $(nodist_random_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3941 = \
+@COND_i386_coreboot_TRUE@ $(nodist_random_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ random.marker
+@COND_i386_coreboot_TRUE@am__append_3942 = random.mod
+@COND_i386_coreboot_TRUE@am__append_3943 = random.marker
+@COND_i386_multiboot_TRUE@am__append_3944 = random.module
+@COND_i386_multiboot_TRUE@am__append_3945 = random.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_3946 =
+@COND_i386_multiboot_TRUE@am__append_3947 = $(nodist_random_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_3948 = \
+@COND_i386_multiboot_TRUE@ $(nodist_random_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ random.marker
+@COND_i386_multiboot_TRUE@am__append_3949 = random.mod
+@COND_i386_multiboot_TRUE@am__append_3950 = random.marker
+@COND_x86_64_efi_TRUE@am__append_3951 = random.module
+@COND_x86_64_efi_TRUE@am__append_3952 = random.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3953 =
+@COND_x86_64_efi_TRUE@am__append_3954 = $(nodist_random_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3955 = \
+@COND_x86_64_efi_TRUE@ $(nodist_random_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ random.marker
+@COND_x86_64_efi_TRUE@am__append_3956 = random.mod
+@COND_x86_64_efi_TRUE@am__append_3957 = random.marker
+@COND_i386_efi_TRUE@am__append_3958 = appleldr.module
+@COND_i386_efi_TRUE@am__append_3959 = appleldr.module$(EXEEXT)
+@COND_i386_efi_FALSE@@COND_x86_64_efi_FALSE@appleldr_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_3960 =
+@COND_i386_efi_TRUE@am__append_3961 = $(nodist_appleldr_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3962 = \
+@COND_i386_efi_TRUE@ $(nodist_appleldr_module_SOURCES) \
+@COND_i386_efi_TRUE@ appleldr.marker
+@COND_i386_efi_TRUE@am__append_3963 = appleldr.mod
+@COND_i386_efi_TRUE@am__append_3964 = appleldr.marker
+@COND_x86_64_efi_TRUE@am__append_3965 = appleldr.module
+@COND_x86_64_efi_TRUE@am__append_3966 = appleldr.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3967 =
+@COND_x86_64_efi_TRUE@am__append_3968 = $(nodist_appleldr_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3969 = \
+@COND_x86_64_efi_TRUE@ $(nodist_appleldr_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ appleldr.marker
+@COND_x86_64_efi_TRUE@am__append_3970 = appleldr.mod
+@COND_x86_64_efi_TRUE@am__append_3971 = appleldr.marker
+@COND_i386_pc_TRUE@am__append_3972 = chain.module
+@COND_i386_pc_TRUE@am__append_3973 = chain.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@chain_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_3974 =
+@COND_i386_pc_TRUE@am__append_3975 = $(nodist_chain_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_3976 = $(nodist_chain_module_SOURCES) \
+@COND_i386_pc_TRUE@ chain.marker
+@COND_i386_pc_TRUE@am__append_3977 = chain.mod
+@COND_i386_pc_TRUE@am__append_3978 = chain.marker
+@COND_i386_efi_TRUE@am__append_3979 = chain.module
+@COND_i386_efi_TRUE@am__append_3980 = chain.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_3981 =
+@COND_i386_efi_TRUE@am__append_3982 = $(nodist_chain_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_3983 = $(nodist_chain_module_SOURCES) \
+@COND_i386_efi_TRUE@ chain.marker
+@COND_i386_efi_TRUE@am__append_3984 = chain.mod
+@COND_i386_efi_TRUE@am__append_3985 = chain.marker
+@COND_i386_coreboot_TRUE@am__append_3986 = chain.module
+@COND_i386_coreboot_TRUE@am__append_3987 = chain.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_3988 =
+@COND_i386_coreboot_TRUE@am__append_3989 = $(nodist_chain_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_3990 = \
+@COND_i386_coreboot_TRUE@ $(nodist_chain_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ chain.marker
+@COND_i386_coreboot_TRUE@am__append_3991 = chain.mod
+@COND_i386_coreboot_TRUE@am__append_3992 = chain.marker
+@COND_x86_64_efi_TRUE@am__append_3993 = chain.module
+@COND_x86_64_efi_TRUE@am__append_3994 = chain.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_3995 =
+@COND_x86_64_efi_TRUE@am__append_3996 = $(nodist_chain_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_3997 = \
+@COND_x86_64_efi_TRUE@ $(nodist_chain_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ chain.marker
+@COND_x86_64_efi_TRUE@am__append_3998 = chain.mod
+@COND_x86_64_efi_TRUE@am__append_3999 = chain.marker
+@COND_ia64_efi_TRUE@am__append_4000 = chain.module
+@COND_ia64_efi_TRUE@am__append_4001 = chain.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_4002 =
+@COND_ia64_efi_TRUE@am__append_4003 = $(nodist_chain_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_4004 = $(nodist_chain_module_SOURCES) \
+@COND_ia64_efi_TRUE@ chain.marker
+@COND_ia64_efi_TRUE@am__append_4005 = chain.mod
+@COND_ia64_efi_TRUE@am__append_4006 = chain.marker
+@COND_arm_efi_TRUE@am__append_4007 = chain.module
+@COND_arm_efi_TRUE@am__append_4008 = chain.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_4009 =
+@COND_arm_efi_TRUE@am__append_4010 = $(nodist_chain_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_4011 = $(nodist_chain_module_SOURCES) \
+@COND_arm_efi_TRUE@ chain.marker
+@COND_arm_efi_TRUE@am__append_4012 = chain.mod
+@COND_arm_efi_TRUE@am__append_4013 = chain.marker
+@COND_arm64_efi_TRUE@am__append_4014 = chain.module
+@COND_arm64_efi_TRUE@am__append_4015 = chain.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_4016 =
+@COND_arm64_efi_TRUE@am__append_4017 = $(nodist_chain_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_4018 = $(nodist_chain_module_SOURCES) \
+@COND_arm64_efi_TRUE@ chain.marker
+@COND_arm64_efi_TRUE@am__append_4019 = chain.mod
+@COND_arm64_efi_TRUE@am__append_4020 = chain.marker
+@COND_riscv32_efi_TRUE@am__append_4021 = chain.module
+@COND_riscv32_efi_TRUE@am__append_4022 = chain.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_4023 =
+@COND_riscv32_efi_TRUE@am__append_4024 = $(nodist_chain_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_4025 = \
+@COND_riscv32_efi_TRUE@ $(nodist_chain_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ chain.marker
+@COND_riscv32_efi_TRUE@am__append_4026 = chain.mod
+@COND_riscv32_efi_TRUE@am__append_4027 = chain.marker
+@COND_riscv64_efi_TRUE@am__append_4028 = chain.module
+@COND_riscv64_efi_TRUE@am__append_4029 = chain.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_4030 =
+@COND_riscv64_efi_TRUE@am__append_4031 = $(nodist_chain_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_4032 = \
+@COND_riscv64_efi_TRUE@ $(nodist_chain_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ chain.marker
+@COND_riscv64_efi_TRUE@am__append_4033 = chain.mod
+@COND_riscv64_efi_TRUE@am__append_4034 = chain.marker
+@COND_i386_pc_TRUE@am__append_4035 = mmap.module
+@COND_i386_pc_TRUE@am__append_4036 = mmap.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@mmap_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_4037 =
+@COND_i386_pc_TRUE@am__append_4038 = $(nodist_mmap_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4039 = $(nodist_mmap_module_SOURCES) \
+@COND_i386_pc_TRUE@ mmap.marker
+@COND_i386_pc_TRUE@am__append_4040 = mmap.mod
+@COND_i386_pc_TRUE@am__append_4041 = mmap.marker
+@COND_i386_efi_TRUE@am__append_4042 = mmap.module
+@COND_i386_efi_TRUE@am__append_4043 = mmap.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4044 =
+@COND_i386_efi_TRUE@am__append_4045 = $(nodist_mmap_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4046 = $(nodist_mmap_module_SOURCES) \
+@COND_i386_efi_TRUE@ mmap.marker
+@COND_i386_efi_TRUE@am__append_4047 = mmap.mod
+@COND_i386_efi_TRUE@am__append_4048 = mmap.marker
+@COND_i386_qemu_TRUE@am__append_4049 = mmap.module
+@COND_i386_qemu_TRUE@am__append_4050 = mmap.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4051 =
+@COND_i386_qemu_TRUE@am__append_4052 = $(nodist_mmap_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4053 = $(nodist_mmap_module_SOURCES) \
+@COND_i386_qemu_TRUE@ mmap.marker
+@COND_i386_qemu_TRUE@am__append_4054 = mmap.mod
+@COND_i386_qemu_TRUE@am__append_4055 = mmap.marker
+@COND_i386_coreboot_TRUE@am__append_4056 = mmap.module
+@COND_i386_coreboot_TRUE@am__append_4057 = mmap.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_4058 =
+@COND_i386_coreboot_TRUE@am__append_4059 = $(nodist_mmap_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_4060 = \
+@COND_i386_coreboot_TRUE@ $(nodist_mmap_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ mmap.marker
+@COND_i386_coreboot_TRUE@am__append_4061 = mmap.mod
+@COND_i386_coreboot_TRUE@am__append_4062 = mmap.marker
+@COND_i386_multiboot_TRUE@am__append_4063 = mmap.module
+@COND_i386_multiboot_TRUE@am__append_4064 = mmap.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4065 =
+@COND_i386_multiboot_TRUE@am__append_4066 = $(nodist_mmap_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4067 = \
+@COND_i386_multiboot_TRUE@ $(nodist_mmap_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ mmap.marker
+@COND_i386_multiboot_TRUE@am__append_4068 = mmap.mod
+@COND_i386_multiboot_TRUE@am__append_4069 = mmap.marker
+@COND_i386_ieee1275_TRUE@am__append_4070 = mmap.module
+@COND_i386_ieee1275_TRUE@am__append_4071 = mmap.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_4072 =
+@COND_i386_ieee1275_TRUE@am__append_4073 = $(nodist_mmap_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_4074 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_mmap_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ mmap.marker
+@COND_i386_ieee1275_TRUE@am__append_4075 = mmap.mod
+@COND_i386_ieee1275_TRUE@am__append_4076 = mmap.marker
+@COND_x86_64_efi_TRUE@am__append_4077 = mmap.module
+@COND_x86_64_efi_TRUE@am__append_4078 = mmap.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4079 =
+@COND_x86_64_efi_TRUE@am__append_4080 = $(nodist_mmap_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4081 = $(nodist_mmap_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ mmap.marker
+@COND_x86_64_efi_TRUE@am__append_4082 = mmap.mod
+@COND_x86_64_efi_TRUE@am__append_4083 = mmap.marker
+@COND_i386_xen_pvh_TRUE@am__append_4084 = mmap.module
+@COND_i386_xen_pvh_TRUE@am__append_4085 = mmap.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_4086 =
+@COND_i386_xen_pvh_TRUE@am__append_4087 = $(nodist_mmap_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_4088 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_mmap_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ mmap.marker
+@COND_i386_xen_pvh_TRUE@am__append_4089 = mmap.mod
+@COND_i386_xen_pvh_TRUE@am__append_4090 = mmap.marker
+@COND_mips_loongson_TRUE@am__append_4091 = mmap.module
+@COND_mips_loongson_TRUE@am__append_4092 = mmap.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_4093 =
+@COND_mips_loongson_TRUE@am__append_4094 = $(nodist_mmap_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_4095 = \
+@COND_mips_loongson_TRUE@ $(nodist_mmap_module_SOURCES) \
+@COND_mips_loongson_TRUE@ mmap.marker
+@COND_mips_loongson_TRUE@am__append_4096 = mmap.mod
+@COND_mips_loongson_TRUE@am__append_4097 = mmap.marker
+@COND_mips_arc_TRUE@am__append_4098 = mmap.module
+@COND_mips_arc_TRUE@am__append_4099 = mmap.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_4100 =
+@COND_mips_arc_TRUE@am__append_4101 = $(nodist_mmap_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_4102 = $(nodist_mmap_module_SOURCES) \
+@COND_mips_arc_TRUE@ mmap.marker
+@COND_mips_arc_TRUE@am__append_4103 = mmap.mod
+@COND_mips_arc_TRUE@am__append_4104 = mmap.marker
+@COND_ia64_efi_TRUE@am__append_4105 = mmap.module
+@COND_ia64_efi_TRUE@am__append_4106 = mmap.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_4107 =
+@COND_ia64_efi_TRUE@am__append_4108 = $(nodist_mmap_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_4109 = $(nodist_mmap_module_SOURCES) \
+@COND_ia64_efi_TRUE@ mmap.marker
+@COND_ia64_efi_TRUE@am__append_4110 = mmap.mod
+@COND_ia64_efi_TRUE@am__append_4111 = mmap.marker
+@COND_mips_qemu_mips_TRUE@am__append_4112 = mmap.module
+@COND_mips_qemu_mips_TRUE@am__append_4113 = mmap.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_4114 =
+@COND_mips_qemu_mips_TRUE@am__append_4115 = $(nodist_mmap_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_4116 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_mmap_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ mmap.marker
+@COND_mips_qemu_mips_TRUE@am__append_4117 = mmap.mod
+@COND_mips_qemu_mips_TRUE@am__append_4118 = mmap.marker
+@COND_arm_efi_TRUE@am__append_4119 = mmap.module
+@COND_arm_efi_TRUE@am__append_4120 = mmap.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_4121 =
+@COND_arm_efi_TRUE@am__append_4122 = $(nodist_mmap_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_4123 = $(nodist_mmap_module_SOURCES) \
+@COND_arm_efi_TRUE@ mmap.marker
+@COND_arm_efi_TRUE@am__append_4124 = mmap.mod
+@COND_arm_efi_TRUE@am__append_4125 = mmap.marker
+@COND_arm64_efi_TRUE@am__append_4126 = mmap.module
+@COND_arm64_efi_TRUE@am__append_4127 = mmap.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_4128 =
+@COND_arm64_efi_TRUE@am__append_4129 = $(nodist_mmap_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_4130 = $(nodist_mmap_module_SOURCES) \
+@COND_arm64_efi_TRUE@ mmap.marker
+@COND_arm64_efi_TRUE@am__append_4131 = mmap.mod
+@COND_arm64_efi_TRUE@am__append_4132 = mmap.marker
+@COND_riscv32_efi_TRUE@am__append_4133 = mmap.module
+@COND_riscv32_efi_TRUE@am__append_4134 = mmap.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_4135 =
+@COND_riscv32_efi_TRUE@am__append_4136 = $(nodist_mmap_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_4137 = \
+@COND_riscv32_efi_TRUE@ $(nodist_mmap_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ mmap.marker
+@COND_riscv32_efi_TRUE@am__append_4138 = mmap.mod
+@COND_riscv32_efi_TRUE@am__append_4139 = mmap.marker
+@COND_riscv64_efi_TRUE@am__append_4140 = mmap.module
+@COND_riscv64_efi_TRUE@am__append_4141 = mmap.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_4142 =
+@COND_riscv64_efi_TRUE@am__append_4143 = $(nodist_mmap_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_4144 = \
+@COND_riscv64_efi_TRUE@ $(nodist_mmap_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ mmap.marker
+@COND_riscv64_efi_TRUE@am__append_4145 = mmap.mod
+@COND_riscv64_efi_TRUE@am__append_4146 = mmap.marker
+@COND_i386_pc_TRUE@am__append_4147 = at_keyboard.module
+@COND_i386_pc_TRUE@am__append_4148 = at_keyboard.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@at_keyboard_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_4149 =
+@COND_i386_pc_TRUE@am__append_4150 = $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4151 = \
+@COND_i386_pc_TRUE@ $(nodist_at_keyboard_module_SOURCES) \
+@COND_i386_pc_TRUE@ at_keyboard.marker
+@COND_i386_pc_TRUE@am__append_4152 = at_keyboard.mod
+@COND_i386_pc_TRUE@am__append_4153 = at_keyboard.marker
+@COND_i386_efi_TRUE@am__append_4154 = at_keyboard.module
+@COND_i386_efi_TRUE@am__append_4155 = at_keyboard.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4156 =
+@COND_i386_efi_TRUE@am__append_4157 = $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4158 = \
+@COND_i386_efi_TRUE@ $(nodist_at_keyboard_module_SOURCES) \
+@COND_i386_efi_TRUE@ at_keyboard.marker
+@COND_i386_efi_TRUE@am__append_4159 = at_keyboard.mod
+@COND_i386_efi_TRUE@am__append_4160 = at_keyboard.marker
+@COND_i386_qemu_TRUE@am__append_4161 = at_keyboard.module
+@COND_i386_qemu_TRUE@am__append_4162 = at_keyboard.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4163 =
+@COND_i386_qemu_TRUE@am__append_4164 = $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4165 = \
+@COND_i386_qemu_TRUE@ $(nodist_at_keyboard_module_SOURCES) \
+@COND_i386_qemu_TRUE@ at_keyboard.marker
+@COND_i386_qemu_TRUE@am__append_4166 = at_keyboard.mod
+@COND_i386_qemu_TRUE@am__append_4167 = at_keyboard.marker
+@COND_i386_coreboot_TRUE@am__append_4168 = at_keyboard.module
+@COND_i386_coreboot_TRUE@am__append_4169 = at_keyboard.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_4170 =
+@COND_i386_coreboot_TRUE@am__append_4171 = $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_4172 = \
+@COND_i386_coreboot_TRUE@ $(nodist_at_keyboard_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ at_keyboard.marker
+@COND_i386_coreboot_TRUE@am__append_4173 = at_keyboard.mod
+@COND_i386_coreboot_TRUE@am__append_4174 = at_keyboard.marker
+@COND_i386_multiboot_TRUE@am__append_4175 = at_keyboard.module
+@COND_i386_multiboot_TRUE@am__append_4176 = at_keyboard.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4177 =
+@COND_i386_multiboot_TRUE@am__append_4178 = $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4179 = $(nodist_at_keyboard_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ at_keyboard.marker
+@COND_i386_multiboot_TRUE@am__append_4180 = at_keyboard.mod
+@COND_i386_multiboot_TRUE@am__append_4181 = at_keyboard.marker
+@COND_i386_ieee1275_TRUE@am__append_4182 = at_keyboard.module
+@COND_i386_ieee1275_TRUE@am__append_4183 = at_keyboard.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_4184 =
+@COND_i386_ieee1275_TRUE@am__append_4185 = $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_4186 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_at_keyboard_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ at_keyboard.marker
+@COND_i386_ieee1275_TRUE@am__append_4187 = at_keyboard.mod
+@COND_i386_ieee1275_TRUE@am__append_4188 = at_keyboard.marker
+@COND_x86_64_efi_TRUE@am__append_4189 = at_keyboard.module
+@COND_x86_64_efi_TRUE@am__append_4190 = at_keyboard.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4191 =
+@COND_x86_64_efi_TRUE@am__append_4192 = $(nodist_at_keyboard_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4193 = \
+@COND_x86_64_efi_TRUE@ $(nodist_at_keyboard_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ at_keyboard.marker
+@COND_x86_64_efi_TRUE@am__append_4194 = at_keyboard.mod
+@COND_x86_64_efi_TRUE@am__append_4195 = at_keyboard.marker
+@COND_emu_TRUE@am__append_4196 = gfxterm.module
+@COND_emu_TRUE@am__append_4197 = gfxterm.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@gfxterm_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_4198 =
+@COND_emu_TRUE@am__append_4199 = $(nodist_gfxterm_module_SOURCES)
+@COND_emu_TRUE@am__append_4200 = $(nodist_gfxterm_module_SOURCES) \
+@COND_emu_TRUE@ gfxterm.marker
+@COND_emu_TRUE@am__append_4201 = gfxterm.mod
+@COND_emu_TRUE@am__append_4202 = gfxterm.marker
+@COND_i386_pc_TRUE@am__append_4203 = gfxterm.module
+@COND_i386_pc_TRUE@am__append_4204 = gfxterm.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_4205 =
+@COND_i386_pc_TRUE@am__append_4206 = $(nodist_gfxterm_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4207 = $(nodist_gfxterm_module_SOURCES) \
+@COND_i386_pc_TRUE@ gfxterm.marker
+@COND_i386_pc_TRUE@am__append_4208 = gfxterm.mod
+@COND_i386_pc_TRUE@am__append_4209 = gfxterm.marker
+@COND_i386_efi_TRUE@am__append_4210 = gfxterm.module
+@COND_i386_efi_TRUE@am__append_4211 = gfxterm.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4212 =
+@COND_i386_efi_TRUE@am__append_4213 = $(nodist_gfxterm_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4214 = \
+@COND_i386_efi_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_i386_efi_TRUE@ gfxterm.marker
+@COND_i386_efi_TRUE@am__append_4215 = gfxterm.mod
+@COND_i386_efi_TRUE@am__append_4216 = gfxterm.marker
+@COND_i386_qemu_TRUE@am__append_4217 = gfxterm.module
+@COND_i386_qemu_TRUE@am__append_4218 = gfxterm.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4219 =
+@COND_i386_qemu_TRUE@am__append_4220 = $(nodist_gfxterm_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4221 = \
+@COND_i386_qemu_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_i386_qemu_TRUE@ gfxterm.marker
+@COND_i386_qemu_TRUE@am__append_4222 = gfxterm.mod
+@COND_i386_qemu_TRUE@am__append_4223 = gfxterm.marker
+@COND_i386_multiboot_TRUE@am__append_4224 = gfxterm.module
+@COND_i386_multiboot_TRUE@am__append_4225 = gfxterm.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4226 =
+@COND_i386_multiboot_TRUE@am__append_4227 = $(nodist_gfxterm_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4228 = \
+@COND_i386_multiboot_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ gfxterm.marker
+@COND_i386_multiboot_TRUE@am__append_4229 = gfxterm.mod
+@COND_i386_multiboot_TRUE@am__append_4230 = gfxterm.marker
+@COND_i386_ieee1275_TRUE@am__append_4231 = gfxterm.module
+@COND_i386_ieee1275_TRUE@am__append_4232 = gfxterm.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_4233 =
+@COND_i386_ieee1275_TRUE@am__append_4234 = $(nodist_gfxterm_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_4235 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ gfxterm.marker
+@COND_i386_ieee1275_TRUE@am__append_4236 = gfxterm.mod
+@COND_i386_ieee1275_TRUE@am__append_4237 = gfxterm.marker
+@COND_x86_64_efi_TRUE@am__append_4238 = gfxterm.module
+@COND_x86_64_efi_TRUE@am__append_4239 = gfxterm.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4240 =
+@COND_x86_64_efi_TRUE@am__append_4241 = $(nodist_gfxterm_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4242 = \
+@COND_x86_64_efi_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ gfxterm.marker
+@COND_x86_64_efi_TRUE@am__append_4243 = gfxterm.mod
+@COND_x86_64_efi_TRUE@am__append_4244 = gfxterm.marker
+@COND_i386_xen_TRUE@am__append_4245 = gfxterm.module
+@COND_i386_xen_TRUE@am__append_4246 = gfxterm.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_4247 =
+@COND_i386_xen_TRUE@am__append_4248 = $(nodist_gfxterm_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_4249 = \
+@COND_i386_xen_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_i386_xen_TRUE@ gfxterm.marker
+@COND_i386_xen_TRUE@am__append_4250 = gfxterm.mod
+@COND_i386_xen_TRUE@am__append_4251 = gfxterm.marker
+@COND_x86_64_xen_TRUE@am__append_4252 = gfxterm.module
+@COND_x86_64_xen_TRUE@am__append_4253 = gfxterm.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_4254 =
+@COND_x86_64_xen_TRUE@am__append_4255 = $(nodist_gfxterm_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_4256 = \
+@COND_x86_64_xen_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ gfxterm.marker
+@COND_x86_64_xen_TRUE@am__append_4257 = gfxterm.mod
+@COND_x86_64_xen_TRUE@am__append_4258 = gfxterm.marker
+@COND_i386_xen_pvh_TRUE@am__append_4259 = gfxterm.module
+@COND_i386_xen_pvh_TRUE@am__append_4260 = gfxterm.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_4261 =
+@COND_i386_xen_pvh_TRUE@am__append_4262 = $(nodist_gfxterm_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_4263 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ gfxterm.marker
+@COND_i386_xen_pvh_TRUE@am__append_4264 = gfxterm.mod
+@COND_i386_xen_pvh_TRUE@am__append_4265 = gfxterm.marker
+@COND_sparc64_ieee1275_TRUE@am__append_4266 = gfxterm.module
+@COND_sparc64_ieee1275_TRUE@am__append_4267 = gfxterm.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_4268 =
+@COND_sparc64_ieee1275_TRUE@am__append_4269 = $(nodist_gfxterm_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_4270 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ gfxterm.marker
+@COND_sparc64_ieee1275_TRUE@am__append_4271 = gfxterm.mod
+@COND_sparc64_ieee1275_TRUE@am__append_4272 = gfxterm.marker
+@COND_powerpc_ieee1275_TRUE@am__append_4273 = gfxterm.module
+@COND_powerpc_ieee1275_TRUE@am__append_4274 = gfxterm.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_4275 =
+@COND_powerpc_ieee1275_TRUE@am__append_4276 = $(nodist_gfxterm_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_4277 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ gfxterm.marker
+@COND_powerpc_ieee1275_TRUE@am__append_4278 = gfxterm.mod
+@COND_powerpc_ieee1275_TRUE@am__append_4279 = gfxterm.marker
+@COND_mips_arc_TRUE@am__append_4280 = gfxterm.module
+@COND_mips_arc_TRUE@am__append_4281 = gfxterm.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_4282 =
+@COND_mips_arc_TRUE@am__append_4283 = $(nodist_gfxterm_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_4284 = \
+@COND_mips_arc_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_mips_arc_TRUE@ gfxterm.marker
+@COND_mips_arc_TRUE@am__append_4285 = gfxterm.mod
+@COND_mips_arc_TRUE@am__append_4286 = gfxterm.marker
+@COND_ia64_efi_TRUE@am__append_4287 = gfxterm.module
+@COND_ia64_efi_TRUE@am__append_4288 = gfxterm.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_4289 =
+@COND_ia64_efi_TRUE@am__append_4290 = $(nodist_gfxterm_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_4291 = \
+@COND_ia64_efi_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_ia64_efi_TRUE@ gfxterm.marker
+@COND_ia64_efi_TRUE@am__append_4292 = gfxterm.mod
+@COND_ia64_efi_TRUE@am__append_4293 = gfxterm.marker
+@COND_mips_qemu_mips_TRUE@am__append_4294 = gfxterm.module
+@COND_mips_qemu_mips_TRUE@am__append_4295 = gfxterm.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_4296 =
+@COND_mips_qemu_mips_TRUE@am__append_4297 = $(nodist_gfxterm_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_4298 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ gfxterm.marker
+@COND_mips_qemu_mips_TRUE@am__append_4299 = gfxterm.mod
+@COND_mips_qemu_mips_TRUE@am__append_4300 = gfxterm.marker
+@COND_arm_uboot_TRUE@am__append_4301 = gfxterm.module
+@COND_arm_uboot_TRUE@am__append_4302 = gfxterm.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__append_4303 =
+@COND_arm_uboot_TRUE@am__append_4304 = $(nodist_gfxterm_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_4305 = \
+@COND_arm_uboot_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_arm_uboot_TRUE@ gfxterm.marker
+@COND_arm_uboot_TRUE@am__append_4306 = gfxterm.mod
+@COND_arm_uboot_TRUE@am__append_4307 = gfxterm.marker
+@COND_arm_efi_TRUE@am__append_4308 = gfxterm.module
+@COND_arm_efi_TRUE@am__append_4309 = gfxterm.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_4310 =
+@COND_arm_efi_TRUE@am__append_4311 = $(nodist_gfxterm_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_4312 = $(nodist_gfxterm_module_SOURCES) \
+@COND_arm_efi_TRUE@ gfxterm.marker
+@COND_arm_efi_TRUE@am__append_4313 = gfxterm.mod
+@COND_arm_efi_TRUE@am__append_4314 = gfxterm.marker
+@COND_arm64_efi_TRUE@am__append_4315 = gfxterm.module
+@COND_arm64_efi_TRUE@am__append_4316 = gfxterm.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_4317 =
+@COND_arm64_efi_TRUE@am__append_4318 = $(nodist_gfxterm_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_4319 = \
+@COND_arm64_efi_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_arm64_efi_TRUE@ gfxterm.marker
+@COND_arm64_efi_TRUE@am__append_4320 = gfxterm.mod
+@COND_arm64_efi_TRUE@am__append_4321 = gfxterm.marker
+@COND_riscv32_efi_TRUE@am__append_4322 = gfxterm.module
+@COND_riscv32_efi_TRUE@am__append_4323 = gfxterm.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_4324 =
+@COND_riscv32_efi_TRUE@am__append_4325 = $(nodist_gfxterm_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_4326 = \
+@COND_riscv32_efi_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ gfxterm.marker
+@COND_riscv32_efi_TRUE@am__append_4327 = gfxterm.mod
+@COND_riscv32_efi_TRUE@am__append_4328 = gfxterm.marker
+@COND_riscv64_efi_TRUE@am__append_4329 = gfxterm.module
+@COND_riscv64_efi_TRUE@am__append_4330 = gfxterm.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_4331 =
+@COND_riscv64_efi_TRUE@am__append_4332 = $(nodist_gfxterm_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_4333 = \
+@COND_riscv64_efi_TRUE@ $(nodist_gfxterm_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ gfxterm.marker
+@COND_riscv64_efi_TRUE@am__append_4334 = gfxterm.mod
+@COND_riscv64_efi_TRUE@am__append_4335 = gfxterm.marker
+@COND_i386_pc_TRUE@am__append_4336 = serial.module
+@COND_i386_pc_TRUE@am__append_4337 = serial.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@serial_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_4338 =
+@COND_i386_pc_TRUE@am__append_4339 = $(nodist_serial_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4340 = $(nodist_serial_module_SOURCES) \
+@COND_i386_pc_TRUE@ serial.marker
+@COND_i386_pc_TRUE@am__append_4341 = serial.mod
+@COND_i386_pc_TRUE@am__append_4342 = serial.marker
+@COND_i386_efi_TRUE@am__append_4343 = serial.module
+@COND_i386_efi_TRUE@am__append_4344 = serial.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4345 =
+@COND_i386_efi_TRUE@am__append_4346 = $(nodist_serial_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4347 = $(nodist_serial_module_SOURCES) \
+@COND_i386_efi_TRUE@ serial.marker
+@COND_i386_efi_TRUE@am__append_4348 = serial.mod
+@COND_i386_efi_TRUE@am__append_4349 = serial.marker
+@COND_i386_qemu_TRUE@am__append_4350 = serial.module
+@COND_i386_qemu_TRUE@am__append_4351 = serial.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4352 =
+@COND_i386_qemu_TRUE@am__append_4353 = $(nodist_serial_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4354 = \
+@COND_i386_qemu_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_i386_qemu_TRUE@ serial.marker
+@COND_i386_qemu_TRUE@am__append_4355 = serial.mod
+@COND_i386_qemu_TRUE@am__append_4356 = serial.marker
+@COND_i386_coreboot_TRUE@am__append_4357 = serial.module
+@COND_i386_coreboot_TRUE@am__append_4358 = serial.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_4359 =
+@COND_i386_coreboot_TRUE@am__append_4360 = $(nodist_serial_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_4361 = \
+@COND_i386_coreboot_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ serial.marker
+@COND_i386_coreboot_TRUE@am__append_4362 = serial.mod
+@COND_i386_coreboot_TRUE@am__append_4363 = serial.marker
+@COND_i386_multiboot_TRUE@am__append_4364 = serial.module
+@COND_i386_multiboot_TRUE@am__append_4365 = serial.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4366 =
+@COND_i386_multiboot_TRUE@am__append_4367 = $(nodist_serial_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4368 = \
+@COND_i386_multiboot_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ serial.marker
+@COND_i386_multiboot_TRUE@am__append_4369 = serial.mod
+@COND_i386_multiboot_TRUE@am__append_4370 = serial.marker
+@COND_i386_ieee1275_TRUE@am__append_4371 = serial.module
+@COND_i386_ieee1275_TRUE@am__append_4372 = serial.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_4373 =
+@COND_i386_ieee1275_TRUE@am__append_4374 = $(nodist_serial_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_4375 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ serial.marker
+@COND_i386_ieee1275_TRUE@am__append_4376 = serial.mod
+@COND_i386_ieee1275_TRUE@am__append_4377 = serial.marker
+@COND_x86_64_efi_TRUE@am__append_4378 = serial.module
+@COND_x86_64_efi_TRUE@am__append_4379 = serial.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4380 =
+@COND_x86_64_efi_TRUE@am__append_4381 = $(nodist_serial_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4382 = \
+@COND_x86_64_efi_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ serial.marker
+@COND_x86_64_efi_TRUE@am__append_4383 = serial.mod
+@COND_x86_64_efi_TRUE@am__append_4384 = serial.marker
+@COND_sparc64_ieee1275_TRUE@am__append_4385 = serial.module
+@COND_sparc64_ieee1275_TRUE@am__append_4386 = serial.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_4387 =
+@COND_sparc64_ieee1275_TRUE@am__append_4388 = $(nodist_serial_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_4389 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ serial.marker
+@COND_sparc64_ieee1275_TRUE@am__append_4390 = serial.mod
+@COND_sparc64_ieee1275_TRUE@am__append_4391 = serial.marker
+@COND_powerpc_ieee1275_TRUE@am__append_4392 = serial.module
+@COND_powerpc_ieee1275_TRUE@am__append_4393 = serial.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_4394 =
+@COND_powerpc_ieee1275_TRUE@am__append_4395 = $(nodist_serial_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_4396 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ serial.marker
+@COND_powerpc_ieee1275_TRUE@am__append_4397 = serial.mod
+@COND_powerpc_ieee1275_TRUE@am__append_4398 = serial.marker
+@COND_mips_arc_TRUE@am__append_4399 = serial.module
+@COND_mips_arc_TRUE@am__append_4400 = serial.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_4401 =
+@COND_mips_arc_TRUE@am__append_4402 = $(nodist_serial_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_4403 = $(nodist_serial_module_SOURCES) \
+@COND_mips_arc_TRUE@ serial.marker
+@COND_mips_arc_TRUE@am__append_4404 = serial.mod
+@COND_mips_arc_TRUE@am__append_4405 = serial.marker
+@COND_ia64_efi_TRUE@am__append_4406 = serial.module
+@COND_ia64_efi_TRUE@am__append_4407 = serial.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_4408 =
+@COND_ia64_efi_TRUE@am__append_4409 = $(nodist_serial_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_4410 = $(nodist_serial_module_SOURCES) \
+@COND_ia64_efi_TRUE@ serial.marker
+@COND_ia64_efi_TRUE@am__append_4411 = serial.mod
+@COND_ia64_efi_TRUE@am__append_4412 = serial.marker
+@COND_arm_efi_TRUE@am__append_4413 = serial.module
+@COND_arm_efi_TRUE@am__append_4414 = serial.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_4415 =
+@COND_arm_efi_TRUE@am__append_4416 = $(nodist_serial_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_4417 = $(nodist_serial_module_SOURCES) \
+@COND_arm_efi_TRUE@ serial.marker
+@COND_arm_efi_TRUE@am__append_4418 = serial.mod
+@COND_arm_efi_TRUE@am__append_4419 = serial.marker
+@COND_arm64_efi_TRUE@am__append_4420 = serial.module
+@COND_arm64_efi_TRUE@am__append_4421 = serial.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_4422 =
+@COND_arm64_efi_TRUE@am__append_4423 = $(nodist_serial_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_4424 = \
+@COND_arm64_efi_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_arm64_efi_TRUE@ serial.marker
+@COND_arm64_efi_TRUE@am__append_4425 = serial.mod
+@COND_arm64_efi_TRUE@am__append_4426 = serial.marker
+@COND_arm_coreboot_TRUE@am__append_4427 = serial.module
+@COND_arm_coreboot_TRUE@am__append_4428 = serial.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_4429 =
+@COND_arm_coreboot_TRUE@am__append_4430 = $(nodist_serial_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_4431 = \
+@COND_arm_coreboot_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ serial.marker
+@COND_arm_coreboot_TRUE@am__append_4432 = serial.mod
+@COND_arm_coreboot_TRUE@am__append_4433 = serial.marker
+@COND_riscv32_efi_TRUE@am__append_4434 = serial.module
+@COND_riscv32_efi_TRUE@am__append_4435 = serial.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_4436 =
+@COND_riscv32_efi_TRUE@am__append_4437 = $(nodist_serial_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_4438 = \
+@COND_riscv32_efi_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ serial.marker
+@COND_riscv32_efi_TRUE@am__append_4439 = serial.mod
+@COND_riscv32_efi_TRUE@am__append_4440 = serial.marker
+@COND_riscv64_efi_TRUE@am__append_4441 = serial.module
+@COND_riscv64_efi_TRUE@am__append_4442 = serial.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_4443 =
+@COND_riscv64_efi_TRUE@am__append_4444 = $(nodist_serial_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_4445 = \
+@COND_riscv64_efi_TRUE@ $(nodist_serial_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ serial.marker
+@COND_riscv64_efi_TRUE@am__append_4446 = serial.mod
+@COND_riscv64_efi_TRUE@am__append_4447 = serial.marker
+@COND_i386_pc_TRUE@am__append_4448 = sendkey.module terminfo.module
+@COND_i386_pc_TRUE@am__append_4449 = sendkey.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ terminfo.module$(EXEEXT)
+@COND_i386_pc_FALSE@sendkey_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_4450 =
+@COND_i386_pc_TRUE@am__append_4451 = $(nodist_sendkey_module_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_terminfo_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4452 = $(nodist_sendkey_module_SOURCES) \
+@COND_i386_pc_TRUE@ sendkey.marker \
+@COND_i386_pc_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_i386_pc_TRUE@ terminfo.marker
+@COND_i386_pc_TRUE@am__append_4453 = sendkey.mod terminfo.mod
+@COND_i386_pc_TRUE@am__append_4454 = sendkey.marker terminfo.marker
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@terminfo_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_4455 = terminfo.module
+@COND_i386_efi_TRUE@am__append_4456 = terminfo.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4457 =
+@COND_i386_efi_TRUE@am__append_4458 = $(nodist_terminfo_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4459 = \
+@COND_i386_efi_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_i386_efi_TRUE@ terminfo.marker
+@COND_i386_efi_TRUE@am__append_4460 = terminfo.mod
+@COND_i386_efi_TRUE@am__append_4461 = terminfo.marker
+@COND_i386_qemu_TRUE@am__append_4462 = terminfo.module
+@COND_i386_qemu_TRUE@am__append_4463 = terminfo.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4464 =
+@COND_i386_qemu_TRUE@am__append_4465 = $(nodist_terminfo_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4466 = \
+@COND_i386_qemu_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_i386_qemu_TRUE@ terminfo.marker
+@COND_i386_qemu_TRUE@am__append_4467 = terminfo.mod
+@COND_i386_qemu_TRUE@am__append_4468 = terminfo.marker
+@COND_i386_coreboot_TRUE@am__append_4469 = terminfo.module
+@COND_i386_coreboot_TRUE@am__append_4470 = terminfo.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_4471 =
+@COND_i386_coreboot_TRUE@am__append_4472 = $(nodist_terminfo_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_4473 = \
+@COND_i386_coreboot_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ terminfo.marker
+@COND_i386_coreboot_TRUE@am__append_4474 = terminfo.mod
+@COND_i386_coreboot_TRUE@am__append_4475 = terminfo.marker
+@COND_i386_multiboot_TRUE@am__append_4476 = terminfo.module
+@COND_i386_multiboot_TRUE@am__append_4477 = terminfo.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4478 =
+@COND_i386_multiboot_TRUE@am__append_4479 = $(nodist_terminfo_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4480 = \
+@COND_i386_multiboot_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ terminfo.marker
+@COND_i386_multiboot_TRUE@am__append_4481 = terminfo.mod
+@COND_i386_multiboot_TRUE@am__append_4482 = terminfo.marker
+@COND_x86_64_efi_TRUE@am__append_4483 = terminfo.module
+@COND_x86_64_efi_TRUE@am__append_4484 = terminfo.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4485 =
+@COND_x86_64_efi_TRUE@am__append_4486 = $(nodist_terminfo_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4487 = \
+@COND_x86_64_efi_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ terminfo.marker
+@COND_x86_64_efi_TRUE@am__append_4488 = terminfo.mod
+@COND_x86_64_efi_TRUE@am__append_4489 = terminfo.marker
+@COND_ia64_efi_TRUE@am__append_4490 = terminfo.module
+@COND_ia64_efi_TRUE@am__append_4491 = terminfo.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_4492 =
+@COND_ia64_efi_TRUE@am__append_4493 = $(nodist_terminfo_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_4494 = \
+@COND_ia64_efi_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_ia64_efi_TRUE@ terminfo.marker
+@COND_ia64_efi_TRUE@am__append_4495 = terminfo.mod
+@COND_ia64_efi_TRUE@am__append_4496 = terminfo.marker
+@COND_arm_efi_TRUE@am__append_4497 = terminfo.module
+@COND_arm_efi_TRUE@am__append_4498 = terminfo.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_4499 =
+@COND_arm_efi_TRUE@am__append_4500 = $(nodist_terminfo_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_4501 = \
+@COND_arm_efi_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_arm_efi_TRUE@ terminfo.marker
+@COND_arm_efi_TRUE@am__append_4502 = terminfo.mod
+@COND_arm_efi_TRUE@am__append_4503 = terminfo.marker
+@COND_arm64_efi_TRUE@am__append_4504 = terminfo.module
+@COND_arm64_efi_TRUE@am__append_4505 = terminfo.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_4506 =
+@COND_arm64_efi_TRUE@am__append_4507 = $(nodist_terminfo_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_4508 = \
+@COND_arm64_efi_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_arm64_efi_TRUE@ terminfo.marker
+@COND_arm64_efi_TRUE@am__append_4509 = terminfo.mod
+@COND_arm64_efi_TRUE@am__append_4510 = terminfo.marker
+@COND_arm_coreboot_TRUE@am__append_4511 = terminfo.module
+@COND_arm_coreboot_TRUE@am__append_4512 = terminfo.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_4513 =
+@COND_arm_coreboot_TRUE@am__append_4514 = $(nodist_terminfo_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_4515 = \
+@COND_arm_coreboot_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ terminfo.marker
+@COND_arm_coreboot_TRUE@am__append_4516 = terminfo.mod
+@COND_arm_coreboot_TRUE@am__append_4517 = terminfo.marker
+@COND_riscv32_efi_TRUE@am__append_4518 = terminfo.module
+@COND_riscv32_efi_TRUE@am__append_4519 = terminfo.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_4520 =
+@COND_riscv32_efi_TRUE@am__append_4521 = $(nodist_terminfo_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_4522 = \
+@COND_riscv32_efi_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ terminfo.marker
+@COND_riscv32_efi_TRUE@am__append_4523 = terminfo.mod
+@COND_riscv32_efi_TRUE@am__append_4524 = terminfo.marker
+@COND_riscv64_efi_TRUE@am__append_4525 = terminfo.module
+@COND_riscv64_efi_TRUE@am__append_4526 = terminfo.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_4527 =
+@COND_riscv64_efi_TRUE@am__append_4528 = $(nodist_terminfo_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_4529 = \
+@COND_riscv64_efi_TRUE@ $(nodist_terminfo_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ terminfo.marker
+@COND_riscv64_efi_TRUE@am__append_4530 = terminfo.mod
+@COND_riscv64_efi_TRUE@am__append_4531 = terminfo.marker
+@COND_i386_pc_TRUE@am__append_4532 = usb_keyboard.module
+@COND_i386_pc_TRUE@am__append_4533 = usb_keyboard.module$(EXEEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_FALSE@usb_keyboard_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_4534 =
+@COND_i386_pc_TRUE@am__append_4535 = $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4536 = \
+@COND_i386_pc_TRUE@ $(nodist_usb_keyboard_module_SOURCES) \
+@COND_i386_pc_TRUE@ usb_keyboard.marker
+@COND_i386_pc_TRUE@am__append_4537 = usb_keyboard.mod
+@COND_i386_pc_TRUE@am__append_4538 = usb_keyboard.marker
+@COND_i386_efi_TRUE@am__append_4539 = usb_keyboard.module
+@COND_i386_efi_TRUE@am__append_4540 = usb_keyboard.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4541 =
+@COND_i386_efi_TRUE@am__append_4542 = $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4543 = \
+@COND_i386_efi_TRUE@ $(nodist_usb_keyboard_module_SOURCES) \
+@COND_i386_efi_TRUE@ usb_keyboard.marker
+@COND_i386_efi_TRUE@am__append_4544 = usb_keyboard.mod
+@COND_i386_efi_TRUE@am__append_4545 = usb_keyboard.marker
+@COND_i386_qemu_TRUE@am__append_4546 = usb_keyboard.module
+@COND_i386_qemu_TRUE@am__append_4547 = usb_keyboard.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4548 =
+@COND_i386_qemu_TRUE@am__append_4549 = $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4550 = \
+@COND_i386_qemu_TRUE@ $(nodist_usb_keyboard_module_SOURCES) \
+@COND_i386_qemu_TRUE@ usb_keyboard.marker
+@COND_i386_qemu_TRUE@am__append_4551 = usb_keyboard.mod
+@COND_i386_qemu_TRUE@am__append_4552 = usb_keyboard.marker
+@COND_i386_coreboot_TRUE@am__append_4553 = usb_keyboard.module
+@COND_i386_coreboot_TRUE@am__append_4554 = usb_keyboard.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_4555 =
+@COND_i386_coreboot_TRUE@am__append_4556 = $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_4557 = $(nodist_usb_keyboard_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ usb_keyboard.marker
+@COND_i386_coreboot_TRUE@am__append_4558 = usb_keyboard.mod
+@COND_i386_coreboot_TRUE@am__append_4559 = usb_keyboard.marker
+@COND_i386_multiboot_TRUE@am__append_4560 = usb_keyboard.module
+@COND_i386_multiboot_TRUE@am__append_4561 = usb_keyboard.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4562 =
+@COND_i386_multiboot_TRUE@am__append_4563 = $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4564 = $(nodist_usb_keyboard_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ usb_keyboard.marker
+@COND_i386_multiboot_TRUE@am__append_4565 = usb_keyboard.mod
+@COND_i386_multiboot_TRUE@am__append_4566 = usb_keyboard.marker
+@COND_i386_ieee1275_TRUE@am__append_4567 = usb_keyboard.module
+@COND_i386_ieee1275_TRUE@am__append_4568 = usb_keyboard.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_4569 =
+@COND_i386_ieee1275_TRUE@am__append_4570 = $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_4571 = $(nodist_usb_keyboard_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ usb_keyboard.marker
+@COND_i386_ieee1275_TRUE@am__append_4572 = usb_keyboard.mod
+@COND_i386_ieee1275_TRUE@am__append_4573 = usb_keyboard.marker
+@COND_x86_64_efi_TRUE@am__append_4574 = usb_keyboard.module
+@COND_x86_64_efi_TRUE@am__append_4575 = usb_keyboard.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4576 =
+@COND_x86_64_efi_TRUE@am__append_4577 = $(nodist_usb_keyboard_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4578 = \
+@COND_x86_64_efi_TRUE@ $(nodist_usb_keyboard_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ usb_keyboard.marker
+@COND_x86_64_efi_TRUE@am__append_4579 = usb_keyboard.mod
+@COND_x86_64_efi_TRUE@am__append_4580 = usb_keyboard.marker
+@COND_mips_loongson_TRUE@am__append_4581 = usb_keyboard.module
+@COND_mips_loongson_TRUE@am__append_4582 = usb_keyboard.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_4583 =
+@COND_mips_loongson_TRUE@am__append_4584 = $(nodist_usb_keyboard_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_4585 = $(nodist_usb_keyboard_module_SOURCES) \
+@COND_mips_loongson_TRUE@ usb_keyboard.marker
+@COND_mips_loongson_TRUE@am__append_4586 = usb_keyboard.mod
+@COND_mips_loongson_TRUE@am__append_4587 = usb_keyboard.marker
+@COND_arm_coreboot_TRUE@am__append_4588 = usb_keyboard.module
+@COND_arm_coreboot_TRUE@am__append_4589 = usb_keyboard.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__append_4590 =
+@COND_arm_coreboot_TRUE@am__append_4591 = $(nodist_usb_keyboard_module_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_4592 = \
+@COND_arm_coreboot_TRUE@ $(nodist_usb_keyboard_module_SOURCES) \
+@COND_arm_coreboot_TRUE@ usb_keyboard.marker
+@COND_arm_coreboot_TRUE@am__append_4593 = usb_keyboard.mod
+@COND_arm_coreboot_TRUE@am__append_4594 = usb_keyboard.marker
+@COND_i386_pc_TRUE@am__append_4595 = vga.module vga_text.module \
+@COND_i386_pc_TRUE@ mda_text.module
+@COND_i386_pc_TRUE@am__append_4596 = vga.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ vga_text.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ mda_text.module$(EXEEXT)
+@COND_i386_pc_FALSE@vga_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_4597 =
+@COND_i386_pc_TRUE@am__append_4598 = $(nodist_vga_module_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_vga_text_module_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_mda_text_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4599 = $(nodist_vga_module_SOURCES) \
+@COND_i386_pc_TRUE@ vga.marker \
+@COND_i386_pc_TRUE@ $(nodist_vga_text_module_SOURCES) \
+@COND_i386_pc_TRUE@ vga_text.marker \
+@COND_i386_pc_TRUE@ $(nodist_mda_text_module_SOURCES) \
+@COND_i386_pc_TRUE@ mda_text.marker
+@COND_i386_pc_TRUE@am__append_4600 = vga.mod vga_text.mod mda_text.mod
+@COND_i386_pc_TRUE@am__append_4601 = vga.marker vga_text.marker \
+@COND_i386_pc_TRUE@ mda_text.marker
+@COND_i386_pc_FALSE@vga_text_module_DEPENDENCIES =
+@COND_i386_coreboot_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@mda_text_module_DEPENDENCIES =
+@COND_i386_qemu_TRUE@am__append_4602 = mda_text.module
+@COND_i386_qemu_TRUE@am__append_4603 = mda_text.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4604 =
+@COND_i386_qemu_TRUE@am__append_4605 = $(nodist_mda_text_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4606 = \
+@COND_i386_qemu_TRUE@ $(nodist_mda_text_module_SOURCES) \
+@COND_i386_qemu_TRUE@ mda_text.marker
+@COND_i386_qemu_TRUE@am__append_4607 = mda_text.mod
+@COND_i386_qemu_TRUE@am__append_4608 = mda_text.marker
+@COND_i386_coreboot_TRUE@am__append_4609 = mda_text.module
+@COND_i386_coreboot_TRUE@am__append_4610 = mda_text.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_4611 =
+@COND_i386_coreboot_TRUE@am__append_4612 = $(nodist_mda_text_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_4613 = \
+@COND_i386_coreboot_TRUE@ $(nodist_mda_text_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ mda_text.marker
+@COND_i386_coreboot_TRUE@am__append_4614 = mda_text.mod
+@COND_i386_coreboot_TRUE@am__append_4615 = mda_text.marker
+@COND_i386_multiboot_TRUE@am__append_4616 = mda_text.module
+@COND_i386_multiboot_TRUE@am__append_4617 = mda_text.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4618 =
+@COND_i386_multiboot_TRUE@am__append_4619 = $(nodist_mda_text_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4620 = \
+@COND_i386_multiboot_TRUE@ $(nodist_mda_text_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ mda_text.marker
+@COND_i386_multiboot_TRUE@am__append_4621 = mda_text.mod
+@COND_i386_multiboot_TRUE@am__append_4622 = mda_text.marker
+@COND_i386_pc_TRUE@am__append_4623 = video_cirrus.module
+@COND_i386_pc_TRUE@am__append_4624 = video_cirrus.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@video_cirrus_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_4625 =
+@COND_i386_pc_TRUE@am__append_4626 = $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4627 = \
+@COND_i386_pc_TRUE@ $(nodist_video_cirrus_module_SOURCES) \
+@COND_i386_pc_TRUE@ video_cirrus.marker
+@COND_i386_pc_TRUE@am__append_4628 = video_cirrus.mod
+@COND_i386_pc_TRUE@am__append_4629 = video_cirrus.marker
+@COND_i386_efi_TRUE@am__append_4630 = video_cirrus.module
+@COND_i386_efi_TRUE@am__append_4631 = video_cirrus.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4632 =
+@COND_i386_efi_TRUE@am__append_4633 = $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4634 = \
+@COND_i386_efi_TRUE@ $(nodist_video_cirrus_module_SOURCES) \
+@COND_i386_efi_TRUE@ video_cirrus.marker
+@COND_i386_efi_TRUE@am__append_4635 = video_cirrus.mod
+@COND_i386_efi_TRUE@am__append_4636 = video_cirrus.marker
+@COND_i386_qemu_TRUE@am__append_4637 = video_cirrus.module
+@COND_i386_qemu_TRUE@am__append_4638 = video_cirrus.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4639 =
+@COND_i386_qemu_TRUE@am__append_4640 = $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4641 = \
+@COND_i386_qemu_TRUE@ $(nodist_video_cirrus_module_SOURCES) \
+@COND_i386_qemu_TRUE@ video_cirrus.marker
+@COND_i386_qemu_TRUE@am__append_4642 = video_cirrus.mod
+@COND_i386_qemu_TRUE@am__append_4643 = video_cirrus.marker
+@COND_i386_coreboot_TRUE@am__append_4644 = video_cirrus.module
+@COND_i386_coreboot_TRUE@am__append_4645 = video_cirrus.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_4646 =
+@COND_i386_coreboot_TRUE@am__append_4647 = $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_4648 = $(nodist_video_cirrus_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ video_cirrus.marker
+@COND_i386_coreboot_TRUE@am__append_4649 = video_cirrus.mod
+@COND_i386_coreboot_TRUE@am__append_4650 = video_cirrus.marker
+@COND_i386_multiboot_TRUE@am__append_4651 = video_cirrus.module
+@COND_i386_multiboot_TRUE@am__append_4652 = video_cirrus.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4653 =
+@COND_i386_multiboot_TRUE@am__append_4654 = $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4655 = $(nodist_video_cirrus_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ video_cirrus.marker
+@COND_i386_multiboot_TRUE@am__append_4656 = video_cirrus.mod
+@COND_i386_multiboot_TRUE@am__append_4657 = video_cirrus.marker
+@COND_i386_ieee1275_TRUE@am__append_4658 = video_cirrus.module
+@COND_i386_ieee1275_TRUE@am__append_4659 = video_cirrus.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_4660 =
+@COND_i386_ieee1275_TRUE@am__append_4661 = $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_4662 = $(nodist_video_cirrus_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ video_cirrus.marker
+@COND_i386_ieee1275_TRUE@am__append_4663 = video_cirrus.mod
+@COND_i386_ieee1275_TRUE@am__append_4664 = video_cirrus.marker
+@COND_x86_64_efi_TRUE@am__append_4665 = video_cirrus.module
+@COND_x86_64_efi_TRUE@am__append_4666 = video_cirrus.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4667 =
+@COND_x86_64_efi_TRUE@am__append_4668 = $(nodist_video_cirrus_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4669 = \
+@COND_x86_64_efi_TRUE@ $(nodist_video_cirrus_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ video_cirrus.marker
+@COND_x86_64_efi_TRUE@am__append_4670 = video_cirrus.mod
+@COND_x86_64_efi_TRUE@am__append_4671 = video_cirrus.marker
+@COND_i386_pc_TRUE@am__append_4672 = video_bochs.module
+@COND_i386_pc_TRUE@am__append_4673 = video_bochs.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@video_bochs_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_4674 =
+@COND_i386_pc_TRUE@am__append_4675 = $(nodist_video_bochs_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4676 = \
+@COND_i386_pc_TRUE@ $(nodist_video_bochs_module_SOURCES) \
+@COND_i386_pc_TRUE@ video_bochs.marker
+@COND_i386_pc_TRUE@am__append_4677 = video_bochs.mod
+@COND_i386_pc_TRUE@am__append_4678 = video_bochs.marker
+@COND_i386_efi_TRUE@am__append_4679 = video_bochs.module
+@COND_i386_efi_TRUE@am__append_4680 = video_bochs.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4681 =
+@COND_i386_efi_TRUE@am__append_4682 = $(nodist_video_bochs_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4683 = \
+@COND_i386_efi_TRUE@ $(nodist_video_bochs_module_SOURCES) \
+@COND_i386_efi_TRUE@ video_bochs.marker
+@COND_i386_efi_TRUE@am__append_4684 = video_bochs.mod
+@COND_i386_efi_TRUE@am__append_4685 = video_bochs.marker
+@COND_i386_qemu_TRUE@am__append_4686 = video_bochs.module
+@COND_i386_qemu_TRUE@am__append_4687 = video_bochs.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4688 =
+@COND_i386_qemu_TRUE@am__append_4689 = $(nodist_video_bochs_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4690 = \
+@COND_i386_qemu_TRUE@ $(nodist_video_bochs_module_SOURCES) \
+@COND_i386_qemu_TRUE@ video_bochs.marker
+@COND_i386_qemu_TRUE@am__append_4691 = video_bochs.mod
+@COND_i386_qemu_TRUE@am__append_4692 = video_bochs.marker
+@COND_i386_coreboot_TRUE@am__append_4693 = video_bochs.module
+@COND_i386_coreboot_TRUE@am__append_4694 = video_bochs.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_4695 =
+@COND_i386_coreboot_TRUE@am__append_4696 = $(nodist_video_bochs_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_4697 = \
+@COND_i386_coreboot_TRUE@ $(nodist_video_bochs_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ video_bochs.marker
+@COND_i386_coreboot_TRUE@am__append_4698 = video_bochs.mod
+@COND_i386_coreboot_TRUE@am__append_4699 = video_bochs.marker
+@COND_i386_multiboot_TRUE@am__append_4700 = video_bochs.module
+@COND_i386_multiboot_TRUE@am__append_4701 = video_bochs.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4702 =
+@COND_i386_multiboot_TRUE@am__append_4703 = $(nodist_video_bochs_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4704 = $(nodist_video_bochs_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ video_bochs.marker
+@COND_i386_multiboot_TRUE@am__append_4705 = video_bochs.mod
+@COND_i386_multiboot_TRUE@am__append_4706 = video_bochs.marker
+@COND_i386_ieee1275_TRUE@am__append_4707 = video_bochs.module
+@COND_i386_ieee1275_TRUE@am__append_4708 = video_bochs.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_4709 =
+@COND_i386_ieee1275_TRUE@am__append_4710 = $(nodist_video_bochs_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_4711 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_video_bochs_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ video_bochs.marker
+@COND_i386_ieee1275_TRUE@am__append_4712 = video_bochs.mod
+@COND_i386_ieee1275_TRUE@am__append_4713 = video_bochs.marker
+@COND_x86_64_efi_TRUE@am__append_4714 = video_bochs.module
+@COND_x86_64_efi_TRUE@am__append_4715 = video_bochs.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4716 =
+@COND_x86_64_efi_TRUE@am__append_4717 = $(nodist_video_bochs_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4718 = \
+@COND_x86_64_efi_TRUE@ $(nodist_video_bochs_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ video_bochs.marker
+@COND_x86_64_efi_TRUE@am__append_4719 = video_bochs.mod
+@COND_x86_64_efi_TRUE@am__append_4720 = video_bochs.marker
+@COND_emu_TRUE@am__append_4721 = legacy_password_test.module
+@COND_emu_TRUE@am__append_4722 = legacy_password_test.module$(EXEEXT)
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@legacy_password_test_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_4723 =
+@COND_emu_TRUE@am__append_4724 = $(nodist_legacy_password_test_module_SOURCES)
+@COND_emu_TRUE@am__append_4725 = \
+@COND_emu_TRUE@ $(nodist_legacy_password_test_module_SOURCES) \
+@COND_emu_TRUE@ legacy_password_test.marker
+@COND_emu_TRUE@am__append_4726 = legacy_password_test.mod
+@COND_emu_TRUE@am__append_4727 = legacy_password_test.marker
+@COND_i386_pc_TRUE@am__append_4728 = legacy_password_test.module
+@COND_i386_pc_TRUE@am__append_4729 = legacy_password_test.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_4730 =
+@COND_i386_pc_TRUE@am__append_4731 = $(nodist_legacy_password_test_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4732 = $(nodist_legacy_password_test_module_SOURCES) \
+@COND_i386_pc_TRUE@ legacy_password_test.marker
+@COND_i386_pc_TRUE@am__append_4733 = legacy_password_test.mod
+@COND_i386_pc_TRUE@am__append_4734 = legacy_password_test.marker
+@COND_i386_efi_TRUE@am__append_4735 = legacy_password_test.module
+@COND_i386_efi_TRUE@am__append_4736 = legacy_password_test.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4737 =
+@COND_i386_efi_TRUE@am__append_4738 = $(nodist_legacy_password_test_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4739 = $(nodist_legacy_password_test_module_SOURCES) \
+@COND_i386_efi_TRUE@ legacy_password_test.marker
+@COND_i386_efi_TRUE@am__append_4740 = legacy_password_test.mod
+@COND_i386_efi_TRUE@am__append_4741 = legacy_password_test.marker
+@COND_x86_64_efi_TRUE@am__append_4742 = legacy_password_test.module
+@COND_x86_64_efi_TRUE@am__append_4743 = legacy_password_test.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4744 =
+@COND_x86_64_efi_TRUE@am__append_4745 = $(nodist_legacy_password_test_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4746 = $(nodist_legacy_password_test_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ legacy_password_test.marker
+@COND_x86_64_efi_TRUE@am__append_4747 = legacy_password_test.mod
+@COND_x86_64_efi_TRUE@am__append_4748 = legacy_password_test.marker
+@COND_i386_xen_TRUE@am__append_4749 = legacy_password_test.module
+@COND_i386_xen_TRUE@am__append_4750 = legacy_password_test.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_4751 =
+@COND_i386_xen_TRUE@am__append_4752 = $(nodist_legacy_password_test_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_4753 = $(nodist_legacy_password_test_module_SOURCES) \
+@COND_i386_xen_TRUE@ legacy_password_test.marker
+@COND_i386_xen_TRUE@am__append_4754 = legacy_password_test.mod
+@COND_i386_xen_TRUE@am__append_4755 = legacy_password_test.marker
+@COND_x86_64_xen_TRUE@am__append_4756 = legacy_password_test.module
+@COND_x86_64_xen_TRUE@am__append_4757 = legacy_password_test.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_4758 =
+@COND_x86_64_xen_TRUE@am__append_4759 = $(nodist_legacy_password_test_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_4760 = $(nodist_legacy_password_test_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ legacy_password_test.marker
+@COND_x86_64_xen_TRUE@am__append_4761 = legacy_password_test.mod
+@COND_x86_64_xen_TRUE@am__append_4762 = legacy_password_test.marker
+@COND_i386_xen_pvh_TRUE@am__append_4763 = legacy_password_test.module
+@COND_i386_xen_pvh_TRUE@am__append_4764 = legacy_password_test.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_4765 =
+@COND_i386_xen_pvh_TRUE@am__append_4766 = $(nodist_legacy_password_test_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_4767 = $(nodist_legacy_password_test_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ legacy_password_test.marker
+@COND_i386_xen_pvh_TRUE@am__append_4768 = legacy_password_test.mod
+@COND_i386_xen_pvh_TRUE@am__append_4769 = legacy_password_test.marker
+@COND_emu_TRUE@am__append_4770 = div.module
+@COND_emu_TRUE@am__append_4771 = div.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@div_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_4772 =
+@COND_emu_TRUE@am__append_4773 = $(nodist_div_module_SOURCES)
+@COND_emu_TRUE@am__append_4774 = $(nodist_div_module_SOURCES) \
+@COND_emu_TRUE@ div.marker
+@COND_emu_TRUE@am__append_4775 = div.mod
+@COND_emu_TRUE@am__append_4776 = div.marker
+@COND_i386_pc_TRUE@am__append_4777 = div.module
+@COND_i386_pc_TRUE@am__append_4778 = div.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_4779 =
+@COND_i386_pc_TRUE@am__append_4780 = $(nodist_div_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4781 = $(nodist_div_module_SOURCES) \
+@COND_i386_pc_TRUE@ div.marker
+@COND_i386_pc_TRUE@am__append_4782 = div.mod
+@COND_i386_pc_TRUE@am__append_4783 = div.marker
+@COND_i386_efi_TRUE@am__append_4784 = div.module
+@COND_i386_efi_TRUE@am__append_4785 = div.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4786 =
+@COND_i386_efi_TRUE@am__append_4787 = $(nodist_div_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4788 = $(nodist_div_module_SOURCES) \
+@COND_i386_efi_TRUE@ div.marker
+@COND_i386_efi_TRUE@am__append_4789 = div.mod
+@COND_i386_efi_TRUE@am__append_4790 = div.marker
+@COND_i386_qemu_TRUE@am__append_4791 = div.module
+@COND_i386_qemu_TRUE@am__append_4792 = div.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4793 =
+@COND_i386_qemu_TRUE@am__append_4794 = $(nodist_div_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4795 = $(nodist_div_module_SOURCES) \
+@COND_i386_qemu_TRUE@ div.marker
+@COND_i386_qemu_TRUE@am__append_4796 = div.mod
+@COND_i386_qemu_TRUE@am__append_4797 = div.marker
+@COND_i386_coreboot_TRUE@am__append_4798 = div.module
+@COND_i386_coreboot_TRUE@am__append_4799 = div.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_4800 =
+@COND_i386_coreboot_TRUE@am__append_4801 = $(nodist_div_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_4802 = \
+@COND_i386_coreboot_TRUE@ $(nodist_div_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ div.marker
+@COND_i386_coreboot_TRUE@am__append_4803 = div.mod
+@COND_i386_coreboot_TRUE@am__append_4804 = div.marker
+@COND_i386_multiboot_TRUE@am__append_4805 = div.module
+@COND_i386_multiboot_TRUE@am__append_4806 = div.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4807 =
+@COND_i386_multiboot_TRUE@am__append_4808 = $(nodist_div_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4809 = \
+@COND_i386_multiboot_TRUE@ $(nodist_div_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ div.marker
+@COND_i386_multiboot_TRUE@am__append_4810 = div.mod
+@COND_i386_multiboot_TRUE@am__append_4811 = div.marker
+@COND_i386_ieee1275_TRUE@am__append_4812 = div.module
+@COND_i386_ieee1275_TRUE@am__append_4813 = div.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_4814 =
+@COND_i386_ieee1275_TRUE@am__append_4815 = $(nodist_div_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_4816 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_div_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ div.marker
+@COND_i386_ieee1275_TRUE@am__append_4817 = div.mod
+@COND_i386_ieee1275_TRUE@am__append_4818 = div.marker
+@COND_x86_64_efi_TRUE@am__append_4819 = div.module
+@COND_x86_64_efi_TRUE@am__append_4820 = div.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4821 =
+@COND_x86_64_efi_TRUE@am__append_4822 = $(nodist_div_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4823 = $(nodist_div_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ div.marker
+@COND_x86_64_efi_TRUE@am__append_4824 = div.mod
+@COND_x86_64_efi_TRUE@am__append_4825 = div.marker
+@COND_i386_xen_TRUE@am__append_4826 = div.module
+@COND_i386_xen_TRUE@am__append_4827 = div.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_4828 =
+@COND_i386_xen_TRUE@am__append_4829 = $(nodist_div_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_4830 = $(nodist_div_module_SOURCES) \
+@COND_i386_xen_TRUE@ div.marker
+@COND_i386_xen_TRUE@am__append_4831 = div.mod
+@COND_i386_xen_TRUE@am__append_4832 = div.marker
+@COND_x86_64_xen_TRUE@am__append_4833 = div.module
+@COND_x86_64_xen_TRUE@am__append_4834 = div.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_4835 =
+@COND_x86_64_xen_TRUE@am__append_4836 = $(nodist_div_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_4837 = $(nodist_div_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ div.marker
+@COND_x86_64_xen_TRUE@am__append_4838 = div.mod
+@COND_x86_64_xen_TRUE@am__append_4839 = div.marker
+@COND_i386_xen_pvh_TRUE@am__append_4840 = div.module
+@COND_i386_xen_pvh_TRUE@am__append_4841 = div.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_4842 =
+@COND_i386_xen_pvh_TRUE@am__append_4843 = $(nodist_div_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_4844 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_div_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ div.marker
+@COND_i386_xen_pvh_TRUE@am__append_4845 = div.mod
+@COND_i386_xen_pvh_TRUE@am__append_4846 = div.marker
+@COND_mips_loongson_TRUE@am__append_4847 = div.module
+@COND_mips_loongson_TRUE@am__append_4848 = div.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__append_4849 =
+@COND_mips_loongson_TRUE@am__append_4850 = $(nodist_div_module_SOURCES)
+@COND_mips_loongson_TRUE@am__append_4851 = \
+@COND_mips_loongson_TRUE@ $(nodist_div_module_SOURCES) \
+@COND_mips_loongson_TRUE@ div.marker
+@COND_mips_loongson_TRUE@am__append_4852 = div.mod
+@COND_mips_loongson_TRUE@am__append_4853 = div.marker
+@COND_sparc64_ieee1275_TRUE@am__append_4854 = div.module
+@COND_sparc64_ieee1275_TRUE@am__append_4855 = div.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_4856 =
+@COND_sparc64_ieee1275_TRUE@am__append_4857 = $(nodist_div_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_4858 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_div_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ div.marker
+@COND_sparc64_ieee1275_TRUE@am__append_4859 = div.mod
+@COND_sparc64_ieee1275_TRUE@am__append_4860 = div.marker
+@COND_powerpc_ieee1275_TRUE@am__append_4861 = div.module
+@COND_powerpc_ieee1275_TRUE@am__append_4862 = div.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_4863 =
+@COND_powerpc_ieee1275_TRUE@am__append_4864 = $(nodist_div_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_4865 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_div_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ div.marker
+@COND_powerpc_ieee1275_TRUE@am__append_4866 = div.mod
+@COND_powerpc_ieee1275_TRUE@am__append_4867 = div.marker
+@COND_mips_arc_TRUE@am__append_4868 = div.module
+@COND_mips_arc_TRUE@am__append_4869 = div.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_4870 =
+@COND_mips_arc_TRUE@am__append_4871 = $(nodist_div_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_4872 = $(nodist_div_module_SOURCES) \
+@COND_mips_arc_TRUE@ div.marker
+@COND_mips_arc_TRUE@am__append_4873 = div.mod
+@COND_mips_arc_TRUE@am__append_4874 = div.marker
+@COND_mips_qemu_mips_TRUE@am__append_4875 = div.module
+@COND_mips_qemu_mips_TRUE@am__append_4876 = div.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_4877 =
+@COND_mips_qemu_mips_TRUE@am__append_4878 = $(nodist_div_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_4879 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_div_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ div.marker
+@COND_mips_qemu_mips_TRUE@am__append_4880 = div.mod
+@COND_mips_qemu_mips_TRUE@am__append_4881 = div.marker
+@COND_arm64_efi_TRUE@am__append_4882 = div.module
+@COND_arm64_efi_TRUE@am__append_4883 = div.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_4884 =
+@COND_arm64_efi_TRUE@am__append_4885 = $(nodist_div_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_4886 = $(nodist_div_module_SOURCES) \
+@COND_arm64_efi_TRUE@ div.marker
+@COND_arm64_efi_TRUE@am__append_4887 = div.mod
+@COND_arm64_efi_TRUE@am__append_4888 = div.marker
+@COND_riscv64_efi_TRUE@am__append_4889 = div.module
+@COND_riscv64_efi_TRUE@am__append_4890 = div.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_4891 =
+@COND_riscv64_efi_TRUE@am__append_4892 = $(nodist_div_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_4893 = $(nodist_div_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ div.marker
+@COND_riscv64_efi_TRUE@am__append_4894 = div.mod
+@COND_riscv64_efi_TRUE@am__append_4895 = div.marker
+@COND_i386_efi_TRUE@am__append_4896 = efi_gop.module
+@COND_i386_efi_TRUE@am__append_4897 = efi_gop.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@efi_gop_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_4898 =
+@COND_i386_efi_TRUE@am__append_4899 = $(nodist_efi_gop_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4900 = \
+@COND_i386_efi_TRUE@ $(nodist_efi_gop_module_SOURCES) \
+@COND_i386_efi_TRUE@ efi_gop.marker
+@COND_i386_efi_TRUE@am__append_4901 = efi_gop.mod
+@COND_i386_efi_TRUE@am__append_4902 = efi_gop.marker
+@COND_x86_64_efi_TRUE@am__append_4903 = efi_gop.module
+@COND_x86_64_efi_TRUE@am__append_4904 = efi_gop.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4905 =
+@COND_x86_64_efi_TRUE@am__append_4906 = $(nodist_efi_gop_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4907 = \
+@COND_x86_64_efi_TRUE@ $(nodist_efi_gop_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ efi_gop.marker
+@COND_x86_64_efi_TRUE@am__append_4908 = efi_gop.mod
+@COND_x86_64_efi_TRUE@am__append_4909 = efi_gop.marker
+@COND_ia64_efi_TRUE@am__append_4910 = efi_gop.module
+@COND_ia64_efi_TRUE@am__append_4911 = efi_gop.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_4912 =
+@COND_ia64_efi_TRUE@am__append_4913 = $(nodist_efi_gop_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_4914 = \
+@COND_ia64_efi_TRUE@ $(nodist_efi_gop_module_SOURCES) \
+@COND_ia64_efi_TRUE@ efi_gop.marker
+@COND_ia64_efi_TRUE@am__append_4915 = efi_gop.mod
+@COND_ia64_efi_TRUE@am__append_4916 = efi_gop.marker
+@COND_arm_efi_TRUE@am__append_4917 = efi_gop.module
+@COND_arm_efi_TRUE@am__append_4918 = efi_gop.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_4919 =
+@COND_arm_efi_TRUE@am__append_4920 = $(nodist_efi_gop_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_4921 = $(nodist_efi_gop_module_SOURCES) \
+@COND_arm_efi_TRUE@ efi_gop.marker
+@COND_arm_efi_TRUE@am__append_4922 = efi_gop.mod
+@COND_arm_efi_TRUE@am__append_4923 = efi_gop.marker
+@COND_arm64_efi_TRUE@am__append_4924 = efi_gop.module
+@COND_arm64_efi_TRUE@am__append_4925 = efi_gop.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_4926 =
+@COND_arm64_efi_TRUE@am__append_4927 = $(nodist_efi_gop_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_4928 = \
+@COND_arm64_efi_TRUE@ $(nodist_efi_gop_module_SOURCES) \
+@COND_arm64_efi_TRUE@ efi_gop.marker
+@COND_arm64_efi_TRUE@am__append_4929 = efi_gop.mod
+@COND_arm64_efi_TRUE@am__append_4930 = efi_gop.marker
+@COND_riscv32_efi_TRUE@am__append_4931 = efi_gop.module
+@COND_riscv32_efi_TRUE@am__append_4932 = efi_gop.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_4933 =
+@COND_riscv32_efi_TRUE@am__append_4934 = $(nodist_efi_gop_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_4935 = \
+@COND_riscv32_efi_TRUE@ $(nodist_efi_gop_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ efi_gop.marker
+@COND_riscv32_efi_TRUE@am__append_4936 = efi_gop.mod
+@COND_riscv32_efi_TRUE@am__append_4937 = efi_gop.marker
+@COND_riscv64_efi_TRUE@am__append_4938 = efi_gop.module
+@COND_riscv64_efi_TRUE@am__append_4939 = efi_gop.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_4940 =
+@COND_riscv64_efi_TRUE@am__append_4941 = $(nodist_efi_gop_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_4942 = \
+@COND_riscv64_efi_TRUE@ $(nodist_efi_gop_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ efi_gop.marker
+@COND_riscv64_efi_TRUE@am__append_4943 = efi_gop.mod
+@COND_riscv64_efi_TRUE@am__append_4944 = efi_gop.marker
+@COND_i386_efi_TRUE@am__append_4945 = efi_uga.module
+@COND_i386_efi_TRUE@am__append_4946 = efi_uga.module$(EXEEXT)
+@COND_i386_efi_FALSE@@COND_x86_64_efi_FALSE@efi_uga_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_4947 =
+@COND_i386_efi_TRUE@am__append_4948 = $(nodist_efi_uga_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4949 = \
+@COND_i386_efi_TRUE@ $(nodist_efi_uga_module_SOURCES) \
+@COND_i386_efi_TRUE@ efi_uga.marker
+@COND_i386_efi_TRUE@am__append_4950 = efi_uga.mod
+@COND_i386_efi_TRUE@am__append_4951 = efi_uga.marker
+@COND_x86_64_efi_TRUE@am__append_4952 = efi_uga.module
+@COND_x86_64_efi_TRUE@am__append_4953 = efi_uga.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_4954 =
+@COND_x86_64_efi_TRUE@am__append_4955 = $(nodist_efi_uga_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_4956 = \
+@COND_x86_64_efi_TRUE@ $(nodist_efi_uga_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ efi_uga.marker
+@COND_x86_64_efi_TRUE@am__append_4957 = efi_uga.mod
+@COND_x86_64_efi_TRUE@am__append_4958 = efi_uga.marker
+@COND_i386_pc_TRUE@am__append_4959 = vbe.module
+@COND_i386_pc_TRUE@am__append_4960 = vbe.module$(EXEEXT)
+@COND_i386_pc_FALSE@vbe_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_4961 =
+@COND_i386_pc_TRUE@am__append_4962 = $(nodist_vbe_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4963 = $(nodist_vbe_module_SOURCES) \
+@COND_i386_pc_TRUE@ vbe.marker
+@COND_i386_pc_TRUE@am__append_4964 = vbe.mod
+@COND_i386_pc_TRUE@am__append_4965 = vbe.marker
+@COND_emu_TRUE@am__append_4966 = video_fb.module
+@COND_emu_TRUE@am__append_4967 = video_fb.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@video_fb_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_4968 =
+@COND_emu_TRUE@am__append_4969 = $(nodist_video_fb_module_SOURCES)
+@COND_emu_TRUE@am__append_4970 = $(nodist_video_fb_module_SOURCES) \
+@COND_emu_TRUE@ video_fb.marker
+@COND_emu_TRUE@am__append_4971 = video_fb.mod
+@COND_emu_TRUE@am__append_4972 = video_fb.marker
+@COND_i386_pc_TRUE@am__append_4973 = video_fb.module
+@COND_i386_pc_TRUE@am__append_4974 = video_fb.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_4975 =
+@COND_i386_pc_TRUE@am__append_4976 = $(nodist_video_fb_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_4977 = \
+@COND_i386_pc_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_i386_pc_TRUE@ video_fb.marker
+@COND_i386_pc_TRUE@am__append_4978 = video_fb.mod
+@COND_i386_pc_TRUE@am__append_4979 = video_fb.marker
+@COND_i386_efi_TRUE@am__append_4980 = video_fb.module
+@COND_i386_efi_TRUE@am__append_4981 = video_fb.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_4982 =
+@COND_i386_efi_TRUE@am__append_4983 = $(nodist_video_fb_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_4984 = \
+@COND_i386_efi_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_i386_efi_TRUE@ video_fb.marker
+@COND_i386_efi_TRUE@am__append_4985 = video_fb.mod
+@COND_i386_efi_TRUE@am__append_4986 = video_fb.marker
+@COND_i386_qemu_TRUE@am__append_4987 = video_fb.module
+@COND_i386_qemu_TRUE@am__append_4988 = video_fb.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_4989 =
+@COND_i386_qemu_TRUE@am__append_4990 = $(nodist_video_fb_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_4991 = \
+@COND_i386_qemu_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_i386_qemu_TRUE@ video_fb.marker
+@COND_i386_qemu_TRUE@am__append_4992 = video_fb.mod
+@COND_i386_qemu_TRUE@am__append_4993 = video_fb.marker
+@COND_i386_multiboot_TRUE@am__append_4994 = video_fb.module
+@COND_i386_multiboot_TRUE@am__append_4995 = video_fb.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_4996 =
+@COND_i386_multiboot_TRUE@am__append_4997 = $(nodist_video_fb_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_4998 = \
+@COND_i386_multiboot_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ video_fb.marker
+@COND_i386_multiboot_TRUE@am__append_4999 = video_fb.mod
+@COND_i386_multiboot_TRUE@am__append_5000 = video_fb.marker
+@COND_i386_ieee1275_TRUE@am__append_5001 = video_fb.module
+@COND_i386_ieee1275_TRUE@am__append_5002 = video_fb.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_5003 =
+@COND_i386_ieee1275_TRUE@am__append_5004 = $(nodist_video_fb_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_5005 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ video_fb.marker
+@COND_i386_ieee1275_TRUE@am__append_5006 = video_fb.mod
+@COND_i386_ieee1275_TRUE@am__append_5007 = video_fb.marker
+@COND_x86_64_efi_TRUE@am__append_5008 = video_fb.module
+@COND_x86_64_efi_TRUE@am__append_5009 = video_fb.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_5010 =
+@COND_x86_64_efi_TRUE@am__append_5011 = $(nodist_video_fb_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_5012 = \
+@COND_x86_64_efi_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ video_fb.marker
+@COND_x86_64_efi_TRUE@am__append_5013 = video_fb.mod
+@COND_x86_64_efi_TRUE@am__append_5014 = video_fb.marker
+@COND_i386_xen_TRUE@am__append_5015 = video_fb.module
+@COND_i386_xen_TRUE@am__append_5016 = video_fb.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_5017 =
+@COND_i386_xen_TRUE@am__append_5018 = $(nodist_video_fb_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_5019 = \
+@COND_i386_xen_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_i386_xen_TRUE@ video_fb.marker
+@COND_i386_xen_TRUE@am__append_5020 = video_fb.mod
+@COND_i386_xen_TRUE@am__append_5021 = video_fb.marker
+@COND_x86_64_xen_TRUE@am__append_5022 = video_fb.module
+@COND_x86_64_xen_TRUE@am__append_5023 = video_fb.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_5024 =
+@COND_x86_64_xen_TRUE@am__append_5025 = $(nodist_video_fb_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_5026 = \
+@COND_x86_64_xen_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ video_fb.marker
+@COND_x86_64_xen_TRUE@am__append_5027 = video_fb.mod
+@COND_x86_64_xen_TRUE@am__append_5028 = video_fb.marker
+@COND_i386_xen_pvh_TRUE@am__append_5029 = video_fb.module
+@COND_i386_xen_pvh_TRUE@am__append_5030 = video_fb.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_5031 =
+@COND_i386_xen_pvh_TRUE@am__append_5032 = $(nodist_video_fb_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_5033 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ video_fb.marker
+@COND_i386_xen_pvh_TRUE@am__append_5034 = video_fb.mod
+@COND_i386_xen_pvh_TRUE@am__append_5035 = video_fb.marker
+@COND_sparc64_ieee1275_TRUE@am__append_5036 = video_fb.module
+@COND_sparc64_ieee1275_TRUE@am__append_5037 = video_fb.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_5038 =
+@COND_sparc64_ieee1275_TRUE@am__append_5039 = $(nodist_video_fb_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_5040 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ video_fb.marker
+@COND_sparc64_ieee1275_TRUE@am__append_5041 = video_fb.mod
+@COND_sparc64_ieee1275_TRUE@am__append_5042 = video_fb.marker
+@COND_powerpc_ieee1275_TRUE@am__append_5043 = video_fb.module
+@COND_powerpc_ieee1275_TRUE@am__append_5044 = video_fb.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_5045 =
+@COND_powerpc_ieee1275_TRUE@am__append_5046 = $(nodist_video_fb_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_5047 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ video_fb.marker
+@COND_powerpc_ieee1275_TRUE@am__append_5048 = video_fb.mod
+@COND_powerpc_ieee1275_TRUE@am__append_5049 = video_fb.marker
+@COND_mips_arc_TRUE@am__append_5050 = video_fb.module
+@COND_mips_arc_TRUE@am__append_5051 = video_fb.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_5052 =
+@COND_mips_arc_TRUE@am__append_5053 = $(nodist_video_fb_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_5054 = \
+@COND_mips_arc_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_mips_arc_TRUE@ video_fb.marker
+@COND_mips_arc_TRUE@am__append_5055 = video_fb.mod
+@COND_mips_arc_TRUE@am__append_5056 = video_fb.marker
+@COND_ia64_efi_TRUE@am__append_5057 = video_fb.module
+@COND_ia64_efi_TRUE@am__append_5058 = video_fb.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_5059 =
+@COND_ia64_efi_TRUE@am__append_5060 = $(nodist_video_fb_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_5061 = \
+@COND_ia64_efi_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_ia64_efi_TRUE@ video_fb.marker
+@COND_ia64_efi_TRUE@am__append_5062 = video_fb.mod
+@COND_ia64_efi_TRUE@am__append_5063 = video_fb.marker
+@COND_mips_qemu_mips_TRUE@am__append_5064 = video_fb.module
+@COND_mips_qemu_mips_TRUE@am__append_5065 = video_fb.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_5066 =
+@COND_mips_qemu_mips_TRUE@am__append_5067 = $(nodist_video_fb_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_5068 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ video_fb.marker
+@COND_mips_qemu_mips_TRUE@am__append_5069 = video_fb.mod
+@COND_mips_qemu_mips_TRUE@am__append_5070 = video_fb.marker
+@COND_arm_uboot_TRUE@am__append_5071 = video_fb.module
+@COND_arm_uboot_TRUE@am__append_5072 = video_fb.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__append_5073 =
+@COND_arm_uboot_TRUE@am__append_5074 = $(nodist_video_fb_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_5075 = \
+@COND_arm_uboot_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_arm_uboot_TRUE@ video_fb.marker
+@COND_arm_uboot_TRUE@am__append_5076 = video_fb.mod
+@COND_arm_uboot_TRUE@am__append_5077 = video_fb.marker
+@COND_arm_efi_TRUE@am__append_5078 = video_fb.module
+@COND_arm_efi_TRUE@am__append_5079 = video_fb.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_5080 =
+@COND_arm_efi_TRUE@am__append_5081 = $(nodist_video_fb_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_5082 = \
+@COND_arm_efi_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_arm_efi_TRUE@ video_fb.marker
+@COND_arm_efi_TRUE@am__append_5083 = video_fb.mod
+@COND_arm_efi_TRUE@am__append_5084 = video_fb.marker
+@COND_arm64_efi_TRUE@am__append_5085 = video_fb.module
+@COND_arm64_efi_TRUE@am__append_5086 = video_fb.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_5087 =
+@COND_arm64_efi_TRUE@am__append_5088 = $(nodist_video_fb_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_5089 = \
+@COND_arm64_efi_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_arm64_efi_TRUE@ video_fb.marker
+@COND_arm64_efi_TRUE@am__append_5090 = video_fb.mod
+@COND_arm64_efi_TRUE@am__append_5091 = video_fb.marker
+@COND_riscv32_efi_TRUE@am__append_5092 = video_fb.module
+@COND_riscv32_efi_TRUE@am__append_5093 = video_fb.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_5094 =
+@COND_riscv32_efi_TRUE@am__append_5095 = $(nodist_video_fb_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_5096 = \
+@COND_riscv32_efi_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ video_fb.marker
+@COND_riscv32_efi_TRUE@am__append_5097 = video_fb.mod
+@COND_riscv32_efi_TRUE@am__append_5098 = video_fb.marker
+@COND_riscv64_efi_TRUE@am__append_5099 = video_fb.module
+@COND_riscv64_efi_TRUE@am__append_5100 = video_fb.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_5101 =
+@COND_riscv64_efi_TRUE@am__append_5102 = $(nodist_video_fb_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_5103 = \
+@COND_riscv64_efi_TRUE@ $(nodist_video_fb_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ video_fb.marker
+@COND_riscv64_efi_TRUE@am__append_5104 = video_fb.mod
+@COND_riscv64_efi_TRUE@am__append_5105 = video_fb.marker
+@COND_emu_TRUE@am__append_5106 = video.module
+@COND_emu_TRUE@am__append_5107 = video.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@video_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_5108 =
+@COND_emu_TRUE@am__append_5109 = $(nodist_video_module_SOURCES)
+@COND_emu_TRUE@am__append_5110 = $(nodist_video_module_SOURCES) \
+@COND_emu_TRUE@ video.marker
+@COND_emu_TRUE@am__append_5111 = video.mod
+@COND_emu_TRUE@am__append_5112 = video.marker
+@COND_i386_pc_TRUE@am__append_5113 = video.module
+@COND_i386_pc_TRUE@am__append_5114 = video.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_5115 =
+@COND_i386_pc_TRUE@am__append_5116 = $(nodist_video_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_5117 = $(nodist_video_module_SOURCES) \
+@COND_i386_pc_TRUE@ video.marker
+@COND_i386_pc_TRUE@am__append_5118 = video.mod
+@COND_i386_pc_TRUE@am__append_5119 = video.marker
+@COND_i386_efi_TRUE@am__append_5120 = video.module
+@COND_i386_efi_TRUE@am__append_5121 = video.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_5122 =
+@COND_i386_efi_TRUE@am__append_5123 = $(nodist_video_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_5124 = $(nodist_video_module_SOURCES) \
+@COND_i386_efi_TRUE@ video.marker
+@COND_i386_efi_TRUE@am__append_5125 = video.mod
+@COND_i386_efi_TRUE@am__append_5126 = video.marker
+@COND_i386_qemu_TRUE@am__append_5127 = video.module
+@COND_i386_qemu_TRUE@am__append_5128 = video.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_5129 =
+@COND_i386_qemu_TRUE@am__append_5130 = $(nodist_video_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_5131 = $(nodist_video_module_SOURCES) \
+@COND_i386_qemu_TRUE@ video.marker
+@COND_i386_qemu_TRUE@am__append_5132 = video.mod
+@COND_i386_qemu_TRUE@am__append_5133 = video.marker
+@COND_i386_multiboot_TRUE@am__append_5134 = video.module
+@COND_i386_multiboot_TRUE@am__append_5135 = video.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_5136 =
+@COND_i386_multiboot_TRUE@am__append_5137 = $(nodist_video_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_5138 = \
+@COND_i386_multiboot_TRUE@ $(nodist_video_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ video.marker
+@COND_i386_multiboot_TRUE@am__append_5139 = video.mod
+@COND_i386_multiboot_TRUE@am__append_5140 = video.marker
+@COND_i386_ieee1275_TRUE@am__append_5141 = video.module
+@COND_i386_ieee1275_TRUE@am__append_5142 = video.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_5143 =
+@COND_i386_ieee1275_TRUE@am__append_5144 = $(nodist_video_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_5145 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_video_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ video.marker
+@COND_i386_ieee1275_TRUE@am__append_5146 = video.mod
+@COND_i386_ieee1275_TRUE@am__append_5147 = video.marker
+@COND_x86_64_efi_TRUE@am__append_5148 = video.module
+@COND_x86_64_efi_TRUE@am__append_5149 = video.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_5150 =
+@COND_x86_64_efi_TRUE@am__append_5151 = $(nodist_video_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_5152 = \
+@COND_x86_64_efi_TRUE@ $(nodist_video_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ video.marker
+@COND_x86_64_efi_TRUE@am__append_5153 = video.mod
+@COND_x86_64_efi_TRUE@am__append_5154 = video.marker
+@COND_i386_xen_TRUE@am__append_5155 = video.module
+@COND_i386_xen_TRUE@am__append_5156 = video.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_5157 =
+@COND_i386_xen_TRUE@am__append_5158 = $(nodist_video_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_5159 = $(nodist_video_module_SOURCES) \
+@COND_i386_xen_TRUE@ video.marker
+@COND_i386_xen_TRUE@am__append_5160 = video.mod
+@COND_i386_xen_TRUE@am__append_5161 = video.marker
+@COND_x86_64_xen_TRUE@am__append_5162 = video.module
+@COND_x86_64_xen_TRUE@am__append_5163 = video.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_5164 =
+@COND_x86_64_xen_TRUE@am__append_5165 = $(nodist_video_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_5166 = \
+@COND_x86_64_xen_TRUE@ $(nodist_video_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ video.marker
+@COND_x86_64_xen_TRUE@am__append_5167 = video.mod
+@COND_x86_64_xen_TRUE@am__append_5168 = video.marker
+@COND_i386_xen_pvh_TRUE@am__append_5169 = video.module
+@COND_i386_xen_pvh_TRUE@am__append_5170 = video.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_5171 =
+@COND_i386_xen_pvh_TRUE@am__append_5172 = $(nodist_video_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_5173 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_video_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ video.marker
+@COND_i386_xen_pvh_TRUE@am__append_5174 = video.mod
+@COND_i386_xen_pvh_TRUE@am__append_5175 = video.marker
+@COND_sparc64_ieee1275_TRUE@am__append_5176 = video.module
+@COND_sparc64_ieee1275_TRUE@am__append_5177 = video.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_5178 =
+@COND_sparc64_ieee1275_TRUE@am__append_5179 = $(nodist_video_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_5180 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_video_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ video.marker
+@COND_sparc64_ieee1275_TRUE@am__append_5181 = video.mod
+@COND_sparc64_ieee1275_TRUE@am__append_5182 = video.marker
+@COND_powerpc_ieee1275_TRUE@am__append_5183 = video.module
+@COND_powerpc_ieee1275_TRUE@am__append_5184 = video.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_5185 =
+@COND_powerpc_ieee1275_TRUE@am__append_5186 = $(nodist_video_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_5187 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_video_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ video.marker
+@COND_powerpc_ieee1275_TRUE@am__append_5188 = video.mod
+@COND_powerpc_ieee1275_TRUE@am__append_5189 = video.marker
+@COND_mips_arc_TRUE@am__append_5190 = video.module
+@COND_mips_arc_TRUE@am__append_5191 = video.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__append_5192 =
+@COND_mips_arc_TRUE@am__append_5193 = $(nodist_video_module_SOURCES)
+@COND_mips_arc_TRUE@am__append_5194 = $(nodist_video_module_SOURCES) \
+@COND_mips_arc_TRUE@ video.marker
+@COND_mips_arc_TRUE@am__append_5195 = video.mod
+@COND_mips_arc_TRUE@am__append_5196 = video.marker
+@COND_ia64_efi_TRUE@am__append_5197 = video.module
+@COND_ia64_efi_TRUE@am__append_5198 = video.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_5199 =
+@COND_ia64_efi_TRUE@am__append_5200 = $(nodist_video_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_5201 = $(nodist_video_module_SOURCES) \
+@COND_ia64_efi_TRUE@ video.marker
+@COND_ia64_efi_TRUE@am__append_5202 = video.mod
+@COND_ia64_efi_TRUE@am__append_5203 = video.marker
+@COND_mips_qemu_mips_TRUE@am__append_5204 = video.module
+@COND_mips_qemu_mips_TRUE@am__append_5205 = video.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__append_5206 =
+@COND_mips_qemu_mips_TRUE@am__append_5207 = $(nodist_video_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_5208 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_video_module_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ video.marker
+@COND_mips_qemu_mips_TRUE@am__append_5209 = video.mod
+@COND_mips_qemu_mips_TRUE@am__append_5210 = video.marker
+@COND_arm_uboot_TRUE@am__append_5211 = video.module
+@COND_arm_uboot_TRUE@am__append_5212 = video.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__append_5213 =
+@COND_arm_uboot_TRUE@am__append_5214 = $(nodist_video_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_5215 = $(nodist_video_module_SOURCES) \
+@COND_arm_uboot_TRUE@ video.marker
+@COND_arm_uboot_TRUE@am__append_5216 = video.mod
+@COND_arm_uboot_TRUE@am__append_5217 = video.marker
+@COND_arm_efi_TRUE@am__append_5218 = video.module
+@COND_arm_efi_TRUE@am__append_5219 = video.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_5220 =
+@COND_arm_efi_TRUE@am__append_5221 = $(nodist_video_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_5222 = $(nodist_video_module_SOURCES) \
+@COND_arm_efi_TRUE@ video.marker
+@COND_arm_efi_TRUE@am__append_5223 = video.mod
+@COND_arm_efi_TRUE@am__append_5224 = video.marker
+@COND_arm64_efi_TRUE@am__append_5225 = video.module
+@COND_arm64_efi_TRUE@am__append_5226 = video.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_5227 =
+@COND_arm64_efi_TRUE@am__append_5228 = $(nodist_video_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_5229 = $(nodist_video_module_SOURCES) \
+@COND_arm64_efi_TRUE@ video.marker
+@COND_arm64_efi_TRUE@am__append_5230 = video.mod
+@COND_arm64_efi_TRUE@am__append_5231 = video.marker
+@COND_riscv32_efi_TRUE@am__append_5232 = video.module
+@COND_riscv32_efi_TRUE@am__append_5233 = video.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_5234 =
+@COND_riscv32_efi_TRUE@am__append_5235 = $(nodist_video_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_5236 = \
+@COND_riscv32_efi_TRUE@ $(nodist_video_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ video.marker
+@COND_riscv32_efi_TRUE@am__append_5237 = video.mod
+@COND_riscv32_efi_TRUE@am__append_5238 = video.marker
+@COND_riscv64_efi_TRUE@am__append_5239 = video.module
+@COND_riscv64_efi_TRUE@am__append_5240 = video.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_5241 =
+@COND_riscv64_efi_TRUE@am__append_5242 = $(nodist_video_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_5243 = \
+@COND_riscv64_efi_TRUE@ $(nodist_video_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ video.marker
+@COND_riscv64_efi_TRUE@am__append_5244 = video.mod
+@COND_riscv64_efi_TRUE@am__append_5245 = video.marker
+@COND_powerpc_ieee1275_TRUE@am__append_5246 = ieee1275_fb.module
+@COND_powerpc_ieee1275_TRUE@am__append_5247 = ieee1275_fb.module$(EXEEXT)
+@COND_powerpc_ieee1275_FALSE@ieee1275_fb_module_DEPENDENCIES =
+@COND_powerpc_ieee1275_TRUE@am__append_5248 =
+@COND_powerpc_ieee1275_TRUE@am__append_5249 = $(nodist_ieee1275_fb_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_5250 = $(nodist_ieee1275_fb_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ ieee1275_fb.marker
+@COND_powerpc_ieee1275_TRUE@am__append_5251 = ieee1275_fb.mod
+@COND_powerpc_ieee1275_TRUE@am__append_5252 = ieee1275_fb.marker
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@am__append_5253 = sdl.module
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@am__append_5254 = sdl.module$(EXEEXT)
+@COND_GRUB_EMU_SDL_FALSE@sdl_module_DEPENDENCIES =
+@COND_emu_FALSE@sdl_module_DEPENDENCIES =
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@am__append_5255 =
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@am__append_5256 = $(nodist_sdl_module_SOURCES)
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@am__append_5257 = $(nodist_sdl_module_SOURCES) \
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@ sdl.marker
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@am__append_5258 = sdl.mod
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@am__append_5259 = sdl.marker
+@COND_i386_ieee1275_TRUE@am__append_5260 = ofnet.module
+@COND_i386_ieee1275_TRUE@am__append_5261 = ofnet.module$(EXEEXT)
+@COND_i386_ieee1275_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_sparc64_ieee1275_FALSE@ofnet_module_DEPENDENCIES =
+@COND_i386_ieee1275_TRUE@am__append_5262 =
+@COND_i386_ieee1275_TRUE@am__append_5263 = $(nodist_ofnet_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_5264 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_ofnet_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ ofnet.marker
+@COND_i386_ieee1275_TRUE@am__append_5265 = ofnet.mod
+@COND_i386_ieee1275_TRUE@am__append_5266 = ofnet.marker
+@COND_sparc64_ieee1275_TRUE@am__append_5267 = ofnet.module
+@COND_sparc64_ieee1275_TRUE@am__append_5268 = ofnet.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__append_5269 =
+@COND_sparc64_ieee1275_TRUE@am__append_5270 = $(nodist_ofnet_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_5271 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_ofnet_module_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ ofnet.marker
+@COND_sparc64_ieee1275_TRUE@am__append_5272 = ofnet.mod
+@COND_sparc64_ieee1275_TRUE@am__append_5273 = ofnet.marker
+@COND_powerpc_ieee1275_TRUE@am__append_5274 = ofnet.module
+@COND_powerpc_ieee1275_TRUE@am__append_5275 = ofnet.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__append_5276 =
+@COND_powerpc_ieee1275_TRUE@am__append_5277 = $(nodist_ofnet_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_5278 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_ofnet_module_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ ofnet.marker
+@COND_powerpc_ieee1275_TRUE@am__append_5279 = ofnet.mod
+@COND_powerpc_ieee1275_TRUE@am__append_5280 = ofnet.marker
+@COND_arm_uboot_TRUE@am__append_5281 = ubootnet.module
+@COND_arm_uboot_TRUE@am__append_5282 = ubootnet.module$(EXEEXT)
+@COND_arm_uboot_FALSE@ubootnet_module_DEPENDENCIES =
+@COND_arm_uboot_TRUE@am__append_5283 =
+@COND_arm_uboot_TRUE@am__append_5284 = $(nodist_ubootnet_module_SOURCES)
+@COND_arm_uboot_TRUE@am__append_5285 = \
+@COND_arm_uboot_TRUE@ $(nodist_ubootnet_module_SOURCES) \
+@COND_arm_uboot_TRUE@ ubootnet.marker
+@COND_arm_uboot_TRUE@am__append_5286 = ubootnet.mod
+@COND_arm_uboot_TRUE@am__append_5287 = ubootnet.marker
+@COND_i386_efi_TRUE@am__append_5288 = efinet.module
+@COND_i386_efi_TRUE@am__append_5289 = efinet.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@efinet_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_5290 =
+@COND_i386_efi_TRUE@am__append_5291 = $(nodist_efinet_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_5292 = $(nodist_efinet_module_SOURCES) \
+@COND_i386_efi_TRUE@ efinet.marker
+@COND_i386_efi_TRUE@am__append_5293 = efinet.mod
+@COND_i386_efi_TRUE@am__append_5294 = efinet.marker
+@COND_x86_64_efi_TRUE@am__append_5295 = efinet.module
+@COND_x86_64_efi_TRUE@am__append_5296 = efinet.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_5297 =
+@COND_x86_64_efi_TRUE@am__append_5298 = $(nodist_efinet_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_5299 = \
+@COND_x86_64_efi_TRUE@ $(nodist_efinet_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ efinet.marker
+@COND_x86_64_efi_TRUE@am__append_5300 = efinet.mod
+@COND_x86_64_efi_TRUE@am__append_5301 = efinet.marker
+@COND_ia64_efi_TRUE@am__append_5302 = efinet.module
+@COND_ia64_efi_TRUE@am__append_5303 = efinet.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_5304 =
+@COND_ia64_efi_TRUE@am__append_5305 = $(nodist_efinet_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_5306 = $(nodist_efinet_module_SOURCES) \
+@COND_ia64_efi_TRUE@ efinet.marker
+@COND_ia64_efi_TRUE@am__append_5307 = efinet.mod
+@COND_ia64_efi_TRUE@am__append_5308 = efinet.marker
+@COND_arm_efi_TRUE@am__append_5309 = efinet.module
+@COND_arm_efi_TRUE@am__append_5310 = efinet.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_5311 =
+@COND_arm_efi_TRUE@am__append_5312 = $(nodist_efinet_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_5313 = $(nodist_efinet_module_SOURCES) \
+@COND_arm_efi_TRUE@ efinet.marker
+@COND_arm_efi_TRUE@am__append_5314 = efinet.mod
+@COND_arm_efi_TRUE@am__append_5315 = efinet.marker
+@COND_arm64_efi_TRUE@am__append_5316 = efinet.module
+@COND_arm64_efi_TRUE@am__append_5317 = efinet.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_5318 =
+@COND_arm64_efi_TRUE@am__append_5319 = $(nodist_efinet_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_5320 = \
+@COND_arm64_efi_TRUE@ $(nodist_efinet_module_SOURCES) \
+@COND_arm64_efi_TRUE@ efinet.marker
+@COND_arm64_efi_TRUE@am__append_5321 = efinet.mod
+@COND_arm64_efi_TRUE@am__append_5322 = efinet.marker
+@COND_riscv32_efi_TRUE@am__append_5323 = efinet.module
+@COND_riscv32_efi_TRUE@am__append_5324 = efinet.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_5325 =
+@COND_riscv32_efi_TRUE@am__append_5326 = $(nodist_efinet_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_5327 = \
+@COND_riscv32_efi_TRUE@ $(nodist_efinet_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ efinet.marker
+@COND_riscv32_efi_TRUE@am__append_5328 = efinet.mod
+@COND_riscv32_efi_TRUE@am__append_5329 = efinet.marker
+@COND_riscv64_efi_TRUE@am__append_5330 = efinet.module
+@COND_riscv64_efi_TRUE@am__append_5331 = efinet.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_5332 =
+@COND_riscv64_efi_TRUE@am__append_5333 = $(nodist_efinet_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_5334 = \
+@COND_riscv64_efi_TRUE@ $(nodist_efinet_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ efinet.marker
+@COND_riscv64_efi_TRUE@am__append_5335 = efinet.mod
+@COND_riscv64_efi_TRUE@am__append_5336 = efinet.marker
+@COND_emu_TRUE@am__append_5337 = emunet.module legacycfg.module
+@COND_emu_TRUE@am__append_5338 = emunet.module$(EXEEXT) \
+@COND_emu_TRUE@ legacycfg.module$(EXEEXT)
+@COND_emu_FALSE@emunet_module_DEPENDENCIES =
+@COND_emu_TRUE@am__append_5339 =
+@COND_emu_TRUE@am__append_5340 = $(nodist_emunet_module_SOURCES) \
+@COND_emu_TRUE@ $(nodist_legacycfg_module_SOURCES)
+@COND_emu_TRUE@am__append_5341 = $(nodist_emunet_module_SOURCES) \
+@COND_emu_TRUE@ emunet.marker \
+@COND_emu_TRUE@ $(nodist_legacycfg_module_SOURCES) \
+@COND_emu_TRUE@ legacycfg.marker
+@COND_emu_TRUE@am__append_5342 = emunet.mod legacycfg.mod
+@COND_emu_TRUE@am__append_5343 = emunet.marker legacycfg.marker
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@legacycfg_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_5344 = legacycfg.module
+@COND_i386_pc_TRUE@am__append_5345 = legacycfg.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__append_5346 =
+@COND_i386_pc_TRUE@am__append_5347 = $(nodist_legacycfg_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_5348 = \
+@COND_i386_pc_TRUE@ $(nodist_legacycfg_module_SOURCES) \
+@COND_i386_pc_TRUE@ legacycfg.marker
+@COND_i386_pc_TRUE@am__append_5349 = legacycfg.mod
+@COND_i386_pc_TRUE@am__append_5350 = legacycfg.marker
+@COND_i386_efi_TRUE@am__append_5351 = legacycfg.module
+@COND_i386_efi_TRUE@am__append_5352 = legacycfg.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_5353 =
+@COND_i386_efi_TRUE@am__append_5354 = $(nodist_legacycfg_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_5355 = \
+@COND_i386_efi_TRUE@ $(nodist_legacycfg_module_SOURCES) \
+@COND_i386_efi_TRUE@ legacycfg.marker
+@COND_i386_efi_TRUE@am__append_5356 = legacycfg.mod
+@COND_i386_efi_TRUE@am__append_5357 = legacycfg.marker
+@COND_x86_64_efi_TRUE@am__append_5358 = legacycfg.module
+@COND_x86_64_efi_TRUE@am__append_5359 = legacycfg.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_5360 =
+@COND_x86_64_efi_TRUE@am__append_5361 = $(nodist_legacycfg_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_5362 = \
+@COND_x86_64_efi_TRUE@ $(nodist_legacycfg_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ legacycfg.marker
+@COND_x86_64_efi_TRUE@am__append_5363 = legacycfg.mod
+@COND_x86_64_efi_TRUE@am__append_5364 = legacycfg.marker
+@COND_i386_xen_TRUE@am__append_5365 = legacycfg.module
+@COND_i386_xen_TRUE@am__append_5366 = legacycfg.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_5367 =
+@COND_i386_xen_TRUE@am__append_5368 = $(nodist_legacycfg_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_5369 = \
+@COND_i386_xen_TRUE@ $(nodist_legacycfg_module_SOURCES) \
+@COND_i386_xen_TRUE@ legacycfg.marker
+@COND_i386_xen_TRUE@am__append_5370 = legacycfg.mod
+@COND_i386_xen_TRUE@am__append_5371 = legacycfg.marker
+@COND_x86_64_xen_TRUE@am__append_5372 = legacycfg.module
+@COND_x86_64_xen_TRUE@am__append_5373 = legacycfg.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_5374 =
+@COND_x86_64_xen_TRUE@am__append_5375 = $(nodist_legacycfg_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_5376 = \
+@COND_x86_64_xen_TRUE@ $(nodist_legacycfg_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ legacycfg.marker
+@COND_x86_64_xen_TRUE@am__append_5377 = legacycfg.mod
+@COND_x86_64_xen_TRUE@am__append_5378 = legacycfg.marker
+@COND_i386_xen_pvh_TRUE@am__append_5379 = legacycfg.module
+@COND_i386_xen_pvh_TRUE@am__append_5380 = legacycfg.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_5381 =
+@COND_i386_xen_pvh_TRUE@am__append_5382 = $(nodist_legacycfg_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_5383 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_legacycfg_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ legacycfg.marker
+@COND_i386_xen_pvh_TRUE@am__append_5384 = legacycfg.mod
+@COND_i386_xen_pvh_TRUE@am__append_5385 = legacycfg.marker
+@COND_i386_pc_TRUE@am__append_5386 = backtrace.module
+@COND_i386_pc_TRUE@am__append_5387 = backtrace.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@backtrace_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_5388 =
+@COND_i386_pc_TRUE@am__append_5389 = $(nodist_backtrace_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_5390 = \
+@COND_i386_pc_TRUE@ $(nodist_backtrace_module_SOURCES) \
+@COND_i386_pc_TRUE@ backtrace.marker
+@COND_i386_pc_TRUE@am__append_5391 = backtrace.mod
+@COND_i386_pc_TRUE@am__append_5392 = backtrace.marker
+@COND_i386_efi_TRUE@am__append_5393 = backtrace.module
+@COND_i386_efi_TRUE@am__append_5394 = backtrace.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_5395 =
+@COND_i386_efi_TRUE@am__append_5396 = $(nodist_backtrace_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_5397 = \
+@COND_i386_efi_TRUE@ $(nodist_backtrace_module_SOURCES) \
+@COND_i386_efi_TRUE@ backtrace.marker
+@COND_i386_efi_TRUE@am__append_5398 = backtrace.mod
+@COND_i386_efi_TRUE@am__append_5399 = backtrace.marker
+@COND_i386_qemu_TRUE@am__append_5400 = backtrace.module
+@COND_i386_qemu_TRUE@am__append_5401 = backtrace.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_5402 =
+@COND_i386_qemu_TRUE@am__append_5403 = $(nodist_backtrace_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_5404 = \
+@COND_i386_qemu_TRUE@ $(nodist_backtrace_module_SOURCES) \
+@COND_i386_qemu_TRUE@ backtrace.marker
+@COND_i386_qemu_TRUE@am__append_5405 = backtrace.mod
+@COND_i386_qemu_TRUE@am__append_5406 = backtrace.marker
+@COND_i386_coreboot_TRUE@am__append_5407 = backtrace.module
+@COND_i386_coreboot_TRUE@am__append_5408 = backtrace.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_5409 =
+@COND_i386_coreboot_TRUE@am__append_5410 = $(nodist_backtrace_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_5411 = \
+@COND_i386_coreboot_TRUE@ $(nodist_backtrace_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ backtrace.marker
+@COND_i386_coreboot_TRUE@am__append_5412 = backtrace.mod
+@COND_i386_coreboot_TRUE@am__append_5413 = backtrace.marker
+@COND_i386_multiboot_TRUE@am__append_5414 = backtrace.module
+@COND_i386_multiboot_TRUE@am__append_5415 = backtrace.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_5416 =
+@COND_i386_multiboot_TRUE@am__append_5417 = $(nodist_backtrace_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_5418 = \
+@COND_i386_multiboot_TRUE@ $(nodist_backtrace_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ backtrace.marker
+@COND_i386_multiboot_TRUE@am__append_5419 = backtrace.mod
+@COND_i386_multiboot_TRUE@am__append_5420 = backtrace.marker
+@COND_i386_ieee1275_TRUE@am__append_5421 = backtrace.module
+@COND_i386_ieee1275_TRUE@am__append_5422 = backtrace.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_5423 =
+@COND_i386_ieee1275_TRUE@am__append_5424 = $(nodist_backtrace_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_5425 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_backtrace_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ backtrace.marker
+@COND_i386_ieee1275_TRUE@am__append_5426 = backtrace.mod
+@COND_i386_ieee1275_TRUE@am__append_5427 = backtrace.marker
+@COND_x86_64_efi_TRUE@am__append_5428 = backtrace.module
+@COND_x86_64_efi_TRUE@am__append_5429 = backtrace.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_5430 =
+@COND_x86_64_efi_TRUE@am__append_5431 = $(nodist_backtrace_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_5432 = \
+@COND_x86_64_efi_TRUE@ $(nodist_backtrace_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ backtrace.marker
+@COND_x86_64_efi_TRUE@am__append_5433 = backtrace.mod
+@COND_x86_64_efi_TRUE@am__append_5434 = backtrace.marker
+@COND_i386_xen_TRUE@am__append_5435 = backtrace.module
+@COND_i386_xen_TRUE@am__append_5436 = backtrace.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__append_5437 =
+@COND_i386_xen_TRUE@am__append_5438 = $(nodist_backtrace_module_SOURCES)
+@COND_i386_xen_TRUE@am__append_5439 = \
+@COND_i386_xen_TRUE@ $(nodist_backtrace_module_SOURCES) \
+@COND_i386_xen_TRUE@ backtrace.marker
+@COND_i386_xen_TRUE@am__append_5440 = backtrace.mod
+@COND_i386_xen_TRUE@am__append_5441 = backtrace.marker
+@COND_x86_64_xen_TRUE@am__append_5442 = backtrace.module
+@COND_x86_64_xen_TRUE@am__append_5443 = backtrace.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__append_5444 =
+@COND_x86_64_xen_TRUE@am__append_5445 = $(nodist_backtrace_module_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_5446 = \
+@COND_x86_64_xen_TRUE@ $(nodist_backtrace_module_SOURCES) \
+@COND_x86_64_xen_TRUE@ backtrace.marker
+@COND_x86_64_xen_TRUE@am__append_5447 = backtrace.mod
+@COND_x86_64_xen_TRUE@am__append_5448 = backtrace.marker
+@COND_i386_xen_pvh_TRUE@am__append_5449 = backtrace.module
+@COND_i386_xen_pvh_TRUE@am__append_5450 = backtrace.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__append_5451 =
+@COND_i386_xen_pvh_TRUE@am__append_5452 = $(nodist_backtrace_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_5453 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_backtrace_module_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ backtrace.marker
+@COND_i386_xen_pvh_TRUE@am__append_5454 = backtrace.mod
+@COND_i386_xen_pvh_TRUE@am__append_5455 = backtrace.marker
+@COND_i386_pc_TRUE@am__append_5456 = lsapm.module keylayouts.module
+@COND_i386_pc_TRUE@am__append_5457 = lsapm.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ keylayouts.module$(EXEEXT)
+@COND_i386_pc_FALSE@lsapm_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_5458 =
+@COND_i386_pc_TRUE@am__append_5459 = $(nodist_lsapm_module_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_keylayouts_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_5460 = $(nodist_lsapm_module_SOURCES) \
+@COND_i386_pc_TRUE@ lsapm.marker \
+@COND_i386_pc_TRUE@ $(nodist_keylayouts_module_SOURCES) \
+@COND_i386_pc_TRUE@ keylayouts.marker
+@COND_i386_pc_TRUE@am__append_5461 = lsapm.mod keylayouts.mod
+@COND_i386_pc_TRUE@am__append_5462 = lsapm.marker keylayouts.marker
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@keylayouts_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_5463 = keylayouts.module
+@COND_i386_efi_TRUE@am__append_5464 = keylayouts.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_5465 =
+@COND_i386_efi_TRUE@am__append_5466 = $(nodist_keylayouts_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_5467 = \
+@COND_i386_efi_TRUE@ $(nodist_keylayouts_module_SOURCES) \
+@COND_i386_efi_TRUE@ keylayouts.marker
+@COND_i386_efi_TRUE@am__append_5468 = keylayouts.mod
+@COND_i386_efi_TRUE@am__append_5469 = keylayouts.marker
+@COND_i386_qemu_TRUE@am__append_5470 = keylayouts.module
+@COND_i386_qemu_TRUE@am__append_5471 = keylayouts.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_5472 =
+@COND_i386_qemu_TRUE@am__append_5473 = $(nodist_keylayouts_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_5474 = \
+@COND_i386_qemu_TRUE@ $(nodist_keylayouts_module_SOURCES) \
+@COND_i386_qemu_TRUE@ keylayouts.marker
+@COND_i386_qemu_TRUE@am__append_5475 = keylayouts.mod
+@COND_i386_qemu_TRUE@am__append_5476 = keylayouts.marker
+@COND_i386_coreboot_TRUE@am__append_5477 = keylayouts.module
+@COND_i386_coreboot_TRUE@am__append_5478 = keylayouts.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_5479 =
+@COND_i386_coreboot_TRUE@am__append_5480 = $(nodist_keylayouts_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_5481 = \
+@COND_i386_coreboot_TRUE@ $(nodist_keylayouts_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ keylayouts.marker
+@COND_i386_coreboot_TRUE@am__append_5482 = keylayouts.mod
+@COND_i386_coreboot_TRUE@am__append_5483 = keylayouts.marker
+@COND_i386_multiboot_TRUE@am__append_5484 = keylayouts.module
+@COND_i386_multiboot_TRUE@am__append_5485 = keylayouts.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_5486 =
+@COND_i386_multiboot_TRUE@am__append_5487 = $(nodist_keylayouts_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_5488 = \
+@COND_i386_multiboot_TRUE@ $(nodist_keylayouts_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ keylayouts.marker
+@COND_i386_multiboot_TRUE@am__append_5489 = keylayouts.mod
+@COND_i386_multiboot_TRUE@am__append_5490 = keylayouts.marker
+@COND_i386_ieee1275_TRUE@am__append_5491 = keylayouts.module
+@COND_i386_ieee1275_TRUE@am__append_5492 = keylayouts.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_5493 =
+@COND_i386_ieee1275_TRUE@am__append_5494 = $(nodist_keylayouts_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_5495 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_keylayouts_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ keylayouts.marker
+@COND_i386_ieee1275_TRUE@am__append_5496 = keylayouts.mod
+@COND_i386_ieee1275_TRUE@am__append_5497 = keylayouts.marker
+@COND_x86_64_efi_TRUE@am__append_5498 = keylayouts.module
+@COND_x86_64_efi_TRUE@am__append_5499 = keylayouts.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_5500 =
+@COND_x86_64_efi_TRUE@am__append_5501 = $(nodist_keylayouts_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_5502 = \
+@COND_x86_64_efi_TRUE@ $(nodist_keylayouts_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ keylayouts.marker
+@COND_x86_64_efi_TRUE@am__append_5503 = keylayouts.mod
+@COND_x86_64_efi_TRUE@am__append_5504 = keylayouts.marker
+@COND_ENABLE_CACHE_STATS_TRUE@am__append_5505 = cacheinfo.module
+@COND_ENABLE_CACHE_STATS_TRUE@am__append_5506 = cacheinfo.module$(EXEEXT)
+@COND_ENABLE_CACHE_STATS_FALSE@cacheinfo_module_DEPENDENCIES =
+@COND_ENABLE_CACHE_STATS_TRUE@am__append_5507 =
+@COND_ENABLE_CACHE_STATS_TRUE@am__append_5508 = $(nodist_cacheinfo_module_SOURCES)
+@COND_ENABLE_CACHE_STATS_TRUE@am__append_5509 = $(nodist_cacheinfo_module_SOURCES) \
+@COND_ENABLE_CACHE_STATS_TRUE@ cacheinfo.marker
+@COND_ENABLE_CACHE_STATS_TRUE@am__append_5510 = cacheinfo.mod
+@COND_ENABLE_CACHE_STATS_TRUE@am__append_5511 = cacheinfo.marker
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@am__append_5512 = boottime.module
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@am__append_5513 = boottime.module$(EXEEXT)
+@COND_ENABLE_BOOT_TIME_STATS_FALSE@boottime_module_DEPENDENCIES =
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@am__append_5514 =
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@am__append_5515 = $(nodist_boottime_module_SOURCES)
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@am__append_5516 = $(nodist_boottime_module_SOURCES) \
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@ boottime.marker
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@am__append_5517 = boottime.mod
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@am__append_5518 = boottime.marker
+@COND_i386_pc_TRUE@am__append_5519 = gdb.module
+@COND_i386_pc_TRUE@am__append_5520 = gdb.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@gdb_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_5521 =
+@COND_i386_pc_TRUE@am__append_5522 = $(nodist_gdb_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_5523 = $(nodist_gdb_module_SOURCES) \
+@COND_i386_pc_TRUE@ gdb.marker
+@COND_i386_pc_TRUE@am__append_5524 = gdb.mod
+@COND_i386_pc_TRUE@am__append_5525 = gdb.marker
+@COND_i386_efi_TRUE@am__append_5526 = gdb.module
+@COND_i386_efi_TRUE@am__append_5527 = gdb.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_5528 =
+@COND_i386_efi_TRUE@am__append_5529 = $(nodist_gdb_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_5530 = $(nodist_gdb_module_SOURCES) \
+@COND_i386_efi_TRUE@ gdb.marker
+@COND_i386_efi_TRUE@am__append_5531 = gdb.mod
+@COND_i386_efi_TRUE@am__append_5532 = gdb.marker
+@COND_i386_qemu_TRUE@am__append_5533 = gdb.module
+@COND_i386_qemu_TRUE@am__append_5534 = gdb.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_5535 =
+@COND_i386_qemu_TRUE@am__append_5536 = $(nodist_gdb_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_5537 = $(nodist_gdb_module_SOURCES) \
+@COND_i386_qemu_TRUE@ gdb.marker
+@COND_i386_qemu_TRUE@am__append_5538 = gdb.mod
+@COND_i386_qemu_TRUE@am__append_5539 = gdb.marker
+@COND_i386_coreboot_TRUE@am__append_5540 = gdb.module
+@COND_i386_coreboot_TRUE@am__append_5541 = gdb.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_5542 =
+@COND_i386_coreboot_TRUE@am__append_5543 = $(nodist_gdb_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_5544 = \
+@COND_i386_coreboot_TRUE@ $(nodist_gdb_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ gdb.marker
+@COND_i386_coreboot_TRUE@am__append_5545 = gdb.mod
+@COND_i386_coreboot_TRUE@am__append_5546 = gdb.marker
+@COND_i386_multiboot_TRUE@am__append_5547 = gdb.module
+@COND_i386_multiboot_TRUE@am__append_5548 = gdb.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_5549 =
+@COND_i386_multiboot_TRUE@am__append_5550 = $(nodist_gdb_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_5551 = \
+@COND_i386_multiboot_TRUE@ $(nodist_gdb_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ gdb.marker
+@COND_i386_multiboot_TRUE@am__append_5552 = gdb.mod
+@COND_i386_multiboot_TRUE@am__append_5553 = gdb.marker
+@COND_i386_ieee1275_TRUE@am__append_5554 = gdb.module
+@COND_i386_ieee1275_TRUE@am__append_5555 = gdb.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_5556 =
+@COND_i386_ieee1275_TRUE@am__append_5557 = $(nodist_gdb_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_5558 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_gdb_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ gdb.marker
+@COND_i386_ieee1275_TRUE@am__append_5559 = gdb.mod
+@COND_i386_ieee1275_TRUE@am__append_5560 = gdb.marker
+@COND_i386_efi_TRUE@am__append_5561 = tpm.module
+@COND_i386_efi_TRUE@am__append_5562 = tpm.module$(EXEEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_FALSE@tpm_module_DEPENDENCIES =
+@COND_i386_efi_TRUE@am__append_5563 =
+@COND_i386_efi_TRUE@am__append_5564 = $(nodist_tpm_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_5565 = $(nodist_tpm_module_SOURCES) \
+@COND_i386_efi_TRUE@ tpm.marker
+@COND_i386_efi_TRUE@am__append_5566 = tpm.mod
+@COND_i386_efi_TRUE@am__append_5567 = tpm.marker
+@COND_x86_64_efi_TRUE@am__append_5568 = tpm.module
+@COND_x86_64_efi_TRUE@am__append_5569 = tpm.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_5570 =
+@COND_x86_64_efi_TRUE@am__append_5571 = $(nodist_tpm_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_5572 = $(nodist_tpm_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ tpm.marker
+@COND_x86_64_efi_TRUE@am__append_5573 = tpm.mod
+@COND_x86_64_efi_TRUE@am__append_5574 = tpm.marker
+@COND_ia64_efi_TRUE@am__append_5575 = tpm.module
+@COND_ia64_efi_TRUE@am__append_5576 = tpm.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__append_5577 =
+@COND_ia64_efi_TRUE@am__append_5578 = $(nodist_tpm_module_SOURCES)
+@COND_ia64_efi_TRUE@am__append_5579 = $(nodist_tpm_module_SOURCES) \
+@COND_ia64_efi_TRUE@ tpm.marker
+@COND_ia64_efi_TRUE@am__append_5580 = tpm.mod
+@COND_ia64_efi_TRUE@am__append_5581 = tpm.marker
+@COND_arm_efi_TRUE@am__append_5582 = tpm.module
+@COND_arm_efi_TRUE@am__append_5583 = tpm.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__append_5584 =
+@COND_arm_efi_TRUE@am__append_5585 = $(nodist_tpm_module_SOURCES)
+@COND_arm_efi_TRUE@am__append_5586 = $(nodist_tpm_module_SOURCES) \
+@COND_arm_efi_TRUE@ tpm.marker
+@COND_arm_efi_TRUE@am__append_5587 = tpm.mod
+@COND_arm_efi_TRUE@am__append_5588 = tpm.marker
+@COND_arm64_efi_TRUE@am__append_5589 = tpm.module
+@COND_arm64_efi_TRUE@am__append_5590 = tpm.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__append_5591 =
+@COND_arm64_efi_TRUE@am__append_5592 = $(nodist_tpm_module_SOURCES)
+@COND_arm64_efi_TRUE@am__append_5593 = $(nodist_tpm_module_SOURCES) \
+@COND_arm64_efi_TRUE@ tpm.marker
+@COND_arm64_efi_TRUE@am__append_5594 = tpm.mod
+@COND_arm64_efi_TRUE@am__append_5595 = tpm.marker
+@COND_riscv32_efi_TRUE@am__append_5596 = tpm.module
+@COND_riscv32_efi_TRUE@am__append_5597 = tpm.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__append_5598 =
+@COND_riscv32_efi_TRUE@am__append_5599 = $(nodist_tpm_module_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_5600 = $(nodist_tpm_module_SOURCES) \
+@COND_riscv32_efi_TRUE@ tpm.marker
+@COND_riscv32_efi_TRUE@am__append_5601 = tpm.mod
+@COND_riscv32_efi_TRUE@am__append_5602 = tpm.marker
+@COND_riscv64_efi_TRUE@am__append_5603 = tpm.module
+@COND_riscv64_efi_TRUE@am__append_5604 = tpm.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__append_5605 =
+@COND_riscv64_efi_TRUE@am__append_5606 = $(nodist_tpm_module_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_5607 = $(nodist_tpm_module_SOURCES) \
+@COND_riscv64_efi_TRUE@ tpm.marker
+@COND_riscv64_efi_TRUE@am__append_5608 = tpm.mod
+@COND_riscv64_efi_TRUE@am__append_5609 = tpm.marker
+@COND_i386_pc_TRUE@am__append_5610 = rdmsr.module
+@COND_i386_pc_TRUE@am__append_5611 = rdmsr.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@rdmsr_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_5612 =
+@COND_i386_pc_TRUE@am__append_5613 = $(nodist_rdmsr_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_5614 = $(nodist_rdmsr_module_SOURCES) \
+@COND_i386_pc_TRUE@ rdmsr.marker
+@COND_i386_pc_TRUE@am__append_5615 = rdmsr.mod
+@COND_i386_pc_TRUE@am__append_5616 = rdmsr.marker
+@COND_i386_efi_TRUE@am__append_5617 = rdmsr.module
+@COND_i386_efi_TRUE@am__append_5618 = rdmsr.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_5619 =
+@COND_i386_efi_TRUE@am__append_5620 = $(nodist_rdmsr_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_5621 = $(nodist_rdmsr_module_SOURCES) \
+@COND_i386_efi_TRUE@ rdmsr.marker
+@COND_i386_efi_TRUE@am__append_5622 = rdmsr.mod
+@COND_i386_efi_TRUE@am__append_5623 = rdmsr.marker
+@COND_i386_qemu_TRUE@am__append_5624 = rdmsr.module
+@COND_i386_qemu_TRUE@am__append_5625 = rdmsr.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_5626 =
+@COND_i386_qemu_TRUE@am__append_5627 = $(nodist_rdmsr_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_5628 = $(nodist_rdmsr_module_SOURCES) \
+@COND_i386_qemu_TRUE@ rdmsr.marker
+@COND_i386_qemu_TRUE@am__append_5629 = rdmsr.mod
+@COND_i386_qemu_TRUE@am__append_5630 = rdmsr.marker
+@COND_i386_coreboot_TRUE@am__append_5631 = rdmsr.module
+@COND_i386_coreboot_TRUE@am__append_5632 = rdmsr.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_5633 =
+@COND_i386_coreboot_TRUE@am__append_5634 = $(nodist_rdmsr_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_5635 = \
+@COND_i386_coreboot_TRUE@ $(nodist_rdmsr_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ rdmsr.marker
+@COND_i386_coreboot_TRUE@am__append_5636 = rdmsr.mod
+@COND_i386_coreboot_TRUE@am__append_5637 = rdmsr.marker
+@COND_i386_multiboot_TRUE@am__append_5638 = rdmsr.module
+@COND_i386_multiboot_TRUE@am__append_5639 = rdmsr.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_5640 =
+@COND_i386_multiboot_TRUE@am__append_5641 = $(nodist_rdmsr_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_5642 = \
+@COND_i386_multiboot_TRUE@ $(nodist_rdmsr_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ rdmsr.marker
+@COND_i386_multiboot_TRUE@am__append_5643 = rdmsr.mod
+@COND_i386_multiboot_TRUE@am__append_5644 = rdmsr.marker
+@COND_i386_ieee1275_TRUE@am__append_5645 = rdmsr.module
+@COND_i386_ieee1275_TRUE@am__append_5646 = rdmsr.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_5647 =
+@COND_i386_ieee1275_TRUE@am__append_5648 = $(nodist_rdmsr_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_5649 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_rdmsr_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ rdmsr.marker
+@COND_i386_ieee1275_TRUE@am__append_5650 = rdmsr.mod
+@COND_i386_ieee1275_TRUE@am__append_5651 = rdmsr.marker
+@COND_x86_64_efi_TRUE@am__append_5652 = rdmsr.module
+@COND_x86_64_efi_TRUE@am__append_5653 = rdmsr.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_5654 =
+@COND_x86_64_efi_TRUE@am__append_5655 = $(nodist_rdmsr_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_5656 = \
+@COND_x86_64_efi_TRUE@ $(nodist_rdmsr_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ rdmsr.marker
+@COND_x86_64_efi_TRUE@am__append_5657 = rdmsr.mod
+@COND_x86_64_efi_TRUE@am__append_5658 = rdmsr.marker
+@COND_i386_pc_TRUE@am__append_5659 = wrmsr.module
+@COND_i386_pc_TRUE@am__append_5660 = wrmsr.module$(EXEEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_FALSE@wrmsr_module_DEPENDENCIES =
+@COND_i386_pc_TRUE@am__append_5661 =
+@COND_i386_pc_TRUE@am__append_5662 = $(nodist_wrmsr_module_SOURCES)
+@COND_i386_pc_TRUE@am__append_5663 = $(nodist_wrmsr_module_SOURCES) \
+@COND_i386_pc_TRUE@ wrmsr.marker
+@COND_i386_pc_TRUE@am__append_5664 = wrmsr.mod
+@COND_i386_pc_TRUE@am__append_5665 = wrmsr.marker
+@COND_i386_efi_TRUE@am__append_5666 = wrmsr.module
+@COND_i386_efi_TRUE@am__append_5667 = wrmsr.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__append_5668 =
+@COND_i386_efi_TRUE@am__append_5669 = $(nodist_wrmsr_module_SOURCES)
+@COND_i386_efi_TRUE@am__append_5670 = $(nodist_wrmsr_module_SOURCES) \
+@COND_i386_efi_TRUE@ wrmsr.marker
+@COND_i386_efi_TRUE@am__append_5671 = wrmsr.mod
+@COND_i386_efi_TRUE@am__append_5672 = wrmsr.marker
+@COND_i386_qemu_TRUE@am__append_5673 = wrmsr.module
+@COND_i386_qemu_TRUE@am__append_5674 = wrmsr.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__append_5675 =
+@COND_i386_qemu_TRUE@am__append_5676 = $(nodist_wrmsr_module_SOURCES)
+@COND_i386_qemu_TRUE@am__append_5677 = $(nodist_wrmsr_module_SOURCES) \
+@COND_i386_qemu_TRUE@ wrmsr.marker
+@COND_i386_qemu_TRUE@am__append_5678 = wrmsr.mod
+@COND_i386_qemu_TRUE@am__append_5679 = wrmsr.marker
+@COND_i386_coreboot_TRUE@am__append_5680 = wrmsr.module
+@COND_i386_coreboot_TRUE@am__append_5681 = wrmsr.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__append_5682 =
+@COND_i386_coreboot_TRUE@am__append_5683 = $(nodist_wrmsr_module_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_5684 = \
+@COND_i386_coreboot_TRUE@ $(nodist_wrmsr_module_SOURCES) \
+@COND_i386_coreboot_TRUE@ wrmsr.marker
+@COND_i386_coreboot_TRUE@am__append_5685 = wrmsr.mod
+@COND_i386_coreboot_TRUE@am__append_5686 = wrmsr.marker
+@COND_i386_multiboot_TRUE@am__append_5687 = wrmsr.module
+@COND_i386_multiboot_TRUE@am__append_5688 = wrmsr.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__append_5689 =
+@COND_i386_multiboot_TRUE@am__append_5690 = $(nodist_wrmsr_module_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_5691 = \
+@COND_i386_multiboot_TRUE@ $(nodist_wrmsr_module_SOURCES) \
+@COND_i386_multiboot_TRUE@ wrmsr.marker
+@COND_i386_multiboot_TRUE@am__append_5692 = wrmsr.mod
+@COND_i386_multiboot_TRUE@am__append_5693 = wrmsr.marker
+@COND_i386_ieee1275_TRUE@am__append_5694 = wrmsr.module
+@COND_i386_ieee1275_TRUE@am__append_5695 = wrmsr.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__append_5696 =
+@COND_i386_ieee1275_TRUE@am__append_5697 = $(nodist_wrmsr_module_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_5698 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_wrmsr_module_SOURCES) \
+@COND_i386_ieee1275_TRUE@ wrmsr.marker
+@COND_i386_ieee1275_TRUE@am__append_5699 = wrmsr.mod
+@COND_i386_ieee1275_TRUE@am__append_5700 = wrmsr.marker
+@COND_x86_64_efi_TRUE@am__append_5701 = wrmsr.module
+@COND_x86_64_efi_TRUE@am__append_5702 = wrmsr.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__append_5703 =
+@COND_x86_64_efi_TRUE@am__append_5704 = $(nodist_wrmsr_module_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_5705 = \
+@COND_x86_64_efi_TRUE@ $(nodist_wrmsr_module_SOURCES) \
+@COND_x86_64_efi_TRUE@ wrmsr.marker
+@COND_x86_64_efi_TRUE@am__append_5706 = wrmsr.mod
+@COND_x86_64_efi_TRUE@am__append_5707 = wrmsr.marker
+@COND_emu_TRUE@am__append_5708 = kernel.exec
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_FALSE@kernel_exec_DEPENDENCIES =
+@COND_emu_TRUE@am__append_5709 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_emu_TRUE@am__append_5710 = $(nodist_kernel_exec_SOURCES)
+@COND_emu_TRUE@am__append_5711 = $(nodist_kernel_exec_SOURCES) \
+@COND_emu_TRUE@ kernel.img
+@COND_emu_TRUE@am__append_5712 = kernel.img
+@COND_i386_pc_TRUE@am__append_5713 = kernel.exec
+@COND_i386_pc_TRUE@am__append_5714 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_i386_pc_TRUE@am__append_5715 = $(nodist_kernel_exec_SOURCES)
+@COND_i386_pc_TRUE@am__append_5716 = $(nodist_kernel_exec_SOURCES) \
+@COND_i386_pc_TRUE@ kernel.img
+@COND_i386_pc_TRUE@am__append_5717 = kernel.img
+@COND_i386_efi_TRUE@am__append_5718 = kernel.exec
+@COND_i386_efi_TRUE@am__append_5719 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_i386_efi_TRUE@am__append_5720 = $(nodist_kernel_exec_SOURCES)
+@COND_i386_efi_TRUE@am__append_5721 = $(nodist_kernel_exec_SOURCES) \
+@COND_i386_efi_TRUE@ kernel.img
+@COND_i386_efi_TRUE@am__append_5722 = kernel.img
+@COND_i386_qemu_TRUE@am__append_5723 = kernel.exec
+@COND_i386_qemu_TRUE@am__append_5724 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_i386_qemu_TRUE@am__append_5725 = $(nodist_kernel_exec_SOURCES)
+@COND_i386_qemu_TRUE@am__append_5726 = $(nodist_kernel_exec_SOURCES) \
+@COND_i386_qemu_TRUE@ kernel.img
+@COND_i386_qemu_TRUE@am__append_5727 = kernel.img
+@COND_i386_coreboot_TRUE@am__append_5728 = kernel.exec
+@COND_i386_coreboot_TRUE@am__append_5729 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_i386_coreboot_TRUE@am__append_5730 = $(nodist_kernel_exec_SOURCES)
+@COND_i386_coreboot_TRUE@am__append_5731 = \
+@COND_i386_coreboot_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_i386_coreboot_TRUE@ kernel.img
+@COND_i386_coreboot_TRUE@am__append_5732 = kernel.img
+@COND_i386_multiboot_TRUE@am__append_5733 = kernel.exec
+@COND_i386_multiboot_TRUE@am__append_5734 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_i386_multiboot_TRUE@am__append_5735 = $(nodist_kernel_exec_SOURCES)
+@COND_i386_multiboot_TRUE@am__append_5736 = \
+@COND_i386_multiboot_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_i386_multiboot_TRUE@ kernel.img
+@COND_i386_multiboot_TRUE@am__append_5737 = kernel.img
+@COND_i386_ieee1275_TRUE@am__append_5738 = kernel.exec
+@COND_i386_ieee1275_TRUE@am__append_5739 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_i386_ieee1275_TRUE@am__append_5740 = $(nodist_kernel_exec_SOURCES)
+@COND_i386_ieee1275_TRUE@am__append_5741 = \
+@COND_i386_ieee1275_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_i386_ieee1275_TRUE@ kernel.img
+@COND_i386_ieee1275_TRUE@am__append_5742 = kernel.img
+@COND_x86_64_efi_TRUE@am__append_5743 = kernel.exec
+@COND_x86_64_efi_TRUE@am__append_5744 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_x86_64_efi_TRUE@am__append_5745 = $(nodist_kernel_exec_SOURCES)
+@COND_x86_64_efi_TRUE@am__append_5746 = $(nodist_kernel_exec_SOURCES) \
+@COND_x86_64_efi_TRUE@ kernel.img
+@COND_x86_64_efi_TRUE@am__append_5747 = kernel.img
+@COND_i386_xen_TRUE@am__append_5748 = kernel.exec
+@COND_i386_xen_TRUE@am__append_5749 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_i386_xen_TRUE@am__append_5750 = $(nodist_kernel_exec_SOURCES)
+@COND_i386_xen_TRUE@am__append_5751 = $(nodist_kernel_exec_SOURCES) \
+@COND_i386_xen_TRUE@ kernel.img
+@COND_i386_xen_TRUE@am__append_5752 = kernel.img
+@COND_x86_64_xen_TRUE@am__append_5753 = kernel.exec
+@COND_x86_64_xen_TRUE@am__append_5754 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_x86_64_xen_TRUE@am__append_5755 = $(nodist_kernel_exec_SOURCES)
+@COND_x86_64_xen_TRUE@am__append_5756 = $(nodist_kernel_exec_SOURCES) \
+@COND_x86_64_xen_TRUE@ kernel.img
+@COND_x86_64_xen_TRUE@am__append_5757 = kernel.img
+@COND_i386_xen_pvh_TRUE@am__append_5758 = kernel.exec
+@COND_i386_xen_pvh_TRUE@am__append_5759 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_i386_xen_pvh_TRUE@am__append_5760 = $(nodist_kernel_exec_SOURCES)
+@COND_i386_xen_pvh_TRUE@am__append_5761 = \
+@COND_i386_xen_pvh_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_i386_xen_pvh_TRUE@ kernel.img
+@COND_i386_xen_pvh_TRUE@am__append_5762 = kernel.img
+@COND_mips_loongson_TRUE@am__append_5763 = kernel.exec
+@COND_mips_loongson_TRUE@am__append_5764 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_mips_loongson_TRUE@am__append_5765 = $(nodist_kernel_exec_SOURCES)
+@COND_mips_loongson_TRUE@am__append_5766 = \
+@COND_mips_loongson_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_mips_loongson_TRUE@ kernel.img
+@COND_mips_loongson_TRUE@am__append_5767 = kernel.img
+@COND_sparc64_ieee1275_TRUE@am__append_5768 = kernel.exec
+@COND_sparc64_ieee1275_TRUE@am__append_5769 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_sparc64_ieee1275_TRUE@am__append_5770 = $(nodist_kernel_exec_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_5771 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ kernel.img
+@COND_sparc64_ieee1275_TRUE@am__append_5772 = kernel.img
+@COND_powerpc_ieee1275_TRUE@am__append_5773 = kernel.exec
+@COND_powerpc_ieee1275_TRUE@am__append_5774 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_powerpc_ieee1275_TRUE@am__append_5775 = $(nodist_kernel_exec_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_5776 = \
+@COND_powerpc_ieee1275_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_powerpc_ieee1275_TRUE@ kernel.img
+@COND_powerpc_ieee1275_TRUE@am__append_5777 = kernel.img
+@COND_mips_arc_TRUE@am__append_5778 = kernel.exec
+@COND_mips_arc_TRUE@am__append_5779 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_mips_arc_TRUE@am__append_5780 = $(nodist_kernel_exec_SOURCES)
+@COND_mips_arc_TRUE@am__append_5781 = $(nodist_kernel_exec_SOURCES) \
+@COND_mips_arc_TRUE@ kernel.img
+@COND_mips_arc_TRUE@am__append_5782 = kernel.img
+@COND_ia64_efi_TRUE@am__append_5783 = kernel.exec
+@COND_ia64_efi_TRUE@am__append_5784 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_ia64_efi_TRUE@am__append_5785 = $(nodist_kernel_exec_SOURCES)
+@COND_ia64_efi_TRUE@am__append_5786 = $(nodist_kernel_exec_SOURCES) \
+@COND_ia64_efi_TRUE@ kernel.img
+@COND_ia64_efi_TRUE@am__append_5787 = kernel.img
+@COND_mips_qemu_mips_TRUE@am__append_5788 = kernel.exec
+@COND_mips_qemu_mips_TRUE@am__append_5789 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_mips_qemu_mips_TRUE@am__append_5790 = $(nodist_kernel_exec_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_5791 = \
+@COND_mips_qemu_mips_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ kernel.img
+@COND_mips_qemu_mips_TRUE@am__append_5792 = kernel.img
+@COND_arm_uboot_TRUE@am__append_5793 = kernel.exec
+@COND_arm_uboot_TRUE@am__append_5794 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_arm_uboot_TRUE@am__append_5795 = $(nodist_kernel_exec_SOURCES)
+@COND_arm_uboot_TRUE@am__append_5796 = $(nodist_kernel_exec_SOURCES) \
+@COND_arm_uboot_TRUE@ kernel.img
+@COND_arm_uboot_TRUE@am__append_5797 = kernel.img
+@COND_arm_efi_TRUE@am__append_5798 = kernel.exec
+@COND_arm_efi_TRUE@am__append_5799 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_arm_efi_TRUE@am__append_5800 = $(nodist_kernel_exec_SOURCES)
+@COND_arm_efi_TRUE@am__append_5801 = $(nodist_kernel_exec_SOURCES) \
+@COND_arm_efi_TRUE@ kernel.img
+@COND_arm_efi_TRUE@am__append_5802 = kernel.img
+@COND_arm64_efi_TRUE@am__append_5803 = kernel.exec
+@COND_arm64_efi_TRUE@am__append_5804 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_arm64_efi_TRUE@am__append_5805 = $(nodist_kernel_exec_SOURCES)
+@COND_arm64_efi_TRUE@am__append_5806 = $(nodist_kernel_exec_SOURCES) \
+@COND_arm64_efi_TRUE@ kernel.img
+@COND_arm64_efi_TRUE@am__append_5807 = kernel.img
+@COND_arm_coreboot_TRUE@am__append_5808 = kernel.exec
+@COND_arm_coreboot_TRUE@am__append_5809 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_arm_coreboot_TRUE@am__append_5810 = $(nodist_kernel_exec_SOURCES)
+@COND_arm_coreboot_TRUE@am__append_5811 = \
+@COND_arm_coreboot_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_arm_coreboot_TRUE@ kernel.img
+@COND_arm_coreboot_TRUE@am__append_5812 = kernel.img
+@COND_riscv32_efi_TRUE@am__append_5813 = kernel.exec
+@COND_riscv32_efi_TRUE@am__append_5814 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_riscv32_efi_TRUE@am__append_5815 = $(nodist_kernel_exec_SOURCES)
+@COND_riscv32_efi_TRUE@am__append_5816 = \
+@COND_riscv32_efi_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_riscv32_efi_TRUE@ kernel.img
+@COND_riscv32_efi_TRUE@am__append_5817 = kernel.img
+@COND_riscv64_efi_TRUE@am__append_5818 = kernel.exec
+@COND_riscv64_efi_TRUE@am__append_5819 = video/sm712_init.c video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c osdep/unix/emuconsole.c osdep/windows/emuconsole.c osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c osdep/basic/emunet.c osdep/unix/cputime.c osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S
+@COND_riscv64_efi_TRUE@am__append_5820 = $(nodist_kernel_exec_SOURCES)
+@COND_riscv64_efi_TRUE@am__append_5821 = \
+@COND_riscv64_efi_TRUE@ $(nodist_kernel_exec_SOURCES) \
+@COND_riscv64_efi_TRUE@ kernel.img
+@COND_riscv64_efi_TRUE@am__append_5822 = kernel.img
+@COND_i386_pc_TRUE@am__append_5823 = boot.image
+@COND_i386_pc_TRUE@am__append_5824 =
+@COND_i386_pc_TRUE@am__append_5825 = $(nodist_boot_image_SOURCES)
+@COND_i386_pc_TRUE@am__append_5826 = $(nodist_boot_image_SOURCES) \
+@COND_i386_pc_TRUE@ boot.img
+@COND_i386_pc_TRUE@am__append_5827 = boot.img
+@COND_i386_qemu_TRUE@am__append_5828 = boot.image
+@COND_i386_qemu_TRUE@am__append_5829 =
+@COND_i386_qemu_TRUE@am__append_5830 = $(nodist_boot_image_SOURCES)
+@COND_i386_qemu_TRUE@am__append_5831 = $(nodist_boot_image_SOURCES) \
+@COND_i386_qemu_TRUE@ boot.img
+@COND_i386_qemu_TRUE@am__append_5832 = boot.img
+@COND_sparc64_ieee1275_TRUE@am__append_5833 = boot.image
+@COND_sparc64_ieee1275_TRUE@am__append_5834 =
+@COND_sparc64_ieee1275_TRUE@am__append_5835 = $(nodist_boot_image_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_5836 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_boot_image_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ boot.img
+@COND_sparc64_ieee1275_TRUE@am__append_5837 = boot.img
+@COND_i386_pc_TRUE@am__append_5838 = boot_hybrid.image cdboot.image
+@COND_i386_pc_TRUE@am__append_5839 =
+@COND_i386_pc_TRUE@am__append_5840 = \
+@COND_i386_pc_TRUE@ $(nodist_boot_hybrid_image_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_cdboot_image_SOURCES)
+@COND_i386_pc_TRUE@am__append_5841 = \
+@COND_i386_pc_TRUE@ $(nodist_boot_hybrid_image_SOURCES) \
+@COND_i386_pc_TRUE@ boot_hybrid.img \
+@COND_i386_pc_TRUE@ $(nodist_cdboot_image_SOURCES) cdboot.img
+@COND_i386_pc_TRUE@am__append_5842 = boot_hybrid.img cdboot.img
+@COND_sparc64_ieee1275_TRUE@am__append_5843 = cdboot.image
+@COND_sparc64_ieee1275_TRUE@am__append_5844 =
+@COND_sparc64_ieee1275_TRUE@am__append_5845 = $(nodist_cdboot_image_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_5846 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_cdboot_image_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ cdboot.img
+@COND_sparc64_ieee1275_TRUE@am__append_5847 = cdboot.img
+@COND_i386_pc_TRUE@am__append_5848 = pxeboot.image diskboot.image
+@COND_i386_pc_TRUE@am__append_5849 =
+@COND_i386_pc_TRUE@am__append_5850 = $(nodist_pxeboot_image_SOURCES) \
+@COND_i386_pc_TRUE@ $(nodist_diskboot_image_SOURCES)
+@COND_i386_pc_TRUE@am__append_5851 = $(nodist_pxeboot_image_SOURCES) \
+@COND_i386_pc_TRUE@ pxeboot.img \
+@COND_i386_pc_TRUE@ $(nodist_diskboot_image_SOURCES) \
+@COND_i386_pc_TRUE@ diskboot.img
+@COND_i386_pc_TRUE@am__append_5852 = pxeboot.img diskboot.img
+@COND_sparc64_ieee1275_TRUE@am__append_5853 = diskboot.image
+@COND_sparc64_ieee1275_TRUE@am__append_5854 =
+@COND_sparc64_ieee1275_TRUE@am__append_5855 = $(nodist_diskboot_image_SOURCES)
+@COND_sparc64_ieee1275_TRUE@am__append_5856 = \
+@COND_sparc64_ieee1275_TRUE@ $(nodist_diskboot_image_SOURCES) \
+@COND_sparc64_ieee1275_TRUE@ diskboot.img
+@COND_sparc64_ieee1275_TRUE@am__append_5857 = diskboot.img
+@COND_i386_pc_TRUE@am__append_5858 = lnxboot.image
+@COND_i386_pc_TRUE@am__append_5859 =
+@COND_i386_pc_TRUE@am__append_5860 = $(nodist_lnxboot_image_SOURCES)
+@COND_i386_pc_TRUE@am__append_5861 = $(nodist_lnxboot_image_SOURCES) \
+@COND_i386_pc_TRUE@ lnxboot.img
+@COND_i386_pc_TRUE@am__append_5862 = lnxboot.img
+@COND_mips_loongson_TRUE@am__append_5863 = xz_decompress.image
+@COND_mips_loongson_TRUE@am__append_5864 =
+@COND_mips_loongson_TRUE@am__append_5865 = $(nodist_xz_decompress_image_SOURCES)
+@COND_mips_loongson_TRUE@am__append_5866 = $(nodist_xz_decompress_image_SOURCES) \
+@COND_mips_loongson_TRUE@ xz_decompress.img
+@COND_mips_loongson_TRUE@am__append_5867 = xz_decompress.img
+@COND_mips_arc_TRUE@am__append_5868 = xz_decompress.image
+@COND_mips_arc_TRUE@am__append_5869 =
+@COND_mips_arc_TRUE@am__append_5870 = $(nodist_xz_decompress_image_SOURCES)
+@COND_mips_arc_TRUE@am__append_5871 = \
+@COND_mips_arc_TRUE@ $(nodist_xz_decompress_image_SOURCES) \
+@COND_mips_arc_TRUE@ xz_decompress.img
+@COND_mips_arc_TRUE@am__append_5872 = xz_decompress.img
+@COND_mips_qemu_mips_TRUE@am__append_5873 = xz_decompress.image
+@COND_mips_qemu_mips_TRUE@am__append_5874 =
+@COND_mips_qemu_mips_TRUE@am__append_5875 = $(nodist_xz_decompress_image_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_5876 = $(nodist_xz_decompress_image_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ xz_decompress.img
+@COND_mips_qemu_mips_TRUE@am__append_5877 = xz_decompress.img
+@COND_mips_loongson_TRUE@am__append_5878 = none_decompress.image
+@COND_mips_loongson_TRUE@am__append_5879 =
+@COND_mips_loongson_TRUE@am__append_5880 = $(nodist_none_decompress_image_SOURCES)
+@COND_mips_loongson_TRUE@am__append_5881 = $(nodist_none_decompress_image_SOURCES) \
+@COND_mips_loongson_TRUE@ none_decompress.img
+@COND_mips_loongson_TRUE@am__append_5882 = none_decompress.img
+@COND_mips_arc_TRUE@am__append_5883 = none_decompress.image
+@COND_mips_arc_TRUE@am__append_5884 =
+@COND_mips_arc_TRUE@am__append_5885 = $(nodist_none_decompress_image_SOURCES)
+@COND_mips_arc_TRUE@am__append_5886 = \
+@COND_mips_arc_TRUE@ $(nodist_none_decompress_image_SOURCES) \
+@COND_mips_arc_TRUE@ none_decompress.img
+@COND_mips_arc_TRUE@am__append_5887 = none_decompress.img
+@COND_mips_qemu_mips_TRUE@am__append_5888 = none_decompress.image
+@COND_mips_qemu_mips_TRUE@am__append_5889 =
+@COND_mips_qemu_mips_TRUE@am__append_5890 = $(nodist_none_decompress_image_SOURCES)
+@COND_mips_qemu_mips_TRUE@am__append_5891 = $(nodist_none_decompress_image_SOURCES) \
+@COND_mips_qemu_mips_TRUE@ none_decompress.img
+@COND_mips_qemu_mips_TRUE@am__append_5892 = none_decompress.img
+@COND_i386_pc_TRUE@am__append_5893 = lzma_decompress.image
+@COND_i386_pc_TRUE@am__append_5894 =
+@COND_i386_pc_TRUE@am__append_5895 = $(nodist_lzma_decompress_image_SOURCES)
+@COND_i386_pc_TRUE@am__append_5896 = \
+@COND_i386_pc_TRUE@ $(nodist_lzma_decompress_image_SOURCES) \
+@COND_i386_pc_TRUE@ lzma_decompress.img
+@COND_i386_pc_TRUE@am__append_5897 = lzma_decompress.img
+@COND_mips_loongson_TRUE@am__append_5898 = fwstart.image \
+@COND_mips_loongson_TRUE@ fwstart_fuloong2f.image
+@COND_mips_loongson_TRUE@am__append_5899 =
+@COND_mips_loongson_TRUE@am__append_5900 = \
+@COND_mips_loongson_TRUE@ $(nodist_fwstart_image_SOURCES) \
+@COND_mips_loongson_TRUE@ $(nodist_fwstart_fuloong2f_image_SOURCES)
+@COND_mips_loongson_TRUE@am__append_5901 = \
+@COND_mips_loongson_TRUE@ $(nodist_fwstart_image_SOURCES) \
+@COND_mips_loongson_TRUE@ fwstart.img \
+@COND_mips_loongson_TRUE@ $(nodist_fwstart_fuloong2f_image_SOURCES) \
+@COND_mips_loongson_TRUE@ fwstart_fuloong2f.img
+@COND_mips_loongson_TRUE@am__append_5902 = fwstart.img \
+@COND_mips_loongson_TRUE@ fwstart_fuloong2f.img
+@COND_emu_TRUE@am__append_5903 = grub-emu grub-emu-lite
+@COND_MAN_PAGES_TRUE@@COND_emu_TRUE@am__append_5904 = grub-emu.1
+@COND_MAN_PAGES_TRUE@@COND_emu_TRUE@am__append_5905 = grub-emu.1
+@COND_emu_TRUE@am__append_5906 =
+@COND_emu_TRUE@am__append_5907 = $(nodist_grub_emu_SOURCES) \
+@COND_emu_TRUE@ $(nodist_grub_emu_lite_SOURCES)
+@COND_emu_TRUE@am__append_5908 = $(nodist_grub_emu_SOURCES) \
+@COND_emu_TRUE@ $(nodist_grub_emu_lite_SOURCES)
+@COND_powerpc_ieee1275_TRUE@am__append_5909 = grub.chrp bootinfo.txt
+@COND_powerpc_ieee1275_TRUE@am__append_5910 = grub.chrp bootinfo.txt
+@COND_powerpc_ieee1275_TRUE@am__append_5911 =
+@COND_powerpc_ieee1275_TRUE@am__append_5912 = \
+@COND_powerpc_ieee1275_TRUE@ boot/powerpc/grub.chrp.in \
+@COND_powerpc_ieee1275_TRUE@ boot/powerpc/bootinfo.txt.in
+@COND_emu_TRUE@am__append_5913 = $(top_srcdir)/include/grub/compiler-rt-emu.h
+@COND_emu_FALSE@am__append_5914 = $(top_srcdir)/include/grub/compiler-rt.h
+@COND_i386_pc_TRUE@am__append_5915 = $(top_builddir)/include/grub/machine/kernel.h \
+@COND_i386_pc_TRUE@ $(top_builddir)/include/grub/machine/pxe.h \
+@COND_i386_pc_TRUE@ $(top_builddir)/include/grub/machine/int.h \
+@COND_i386_pc_TRUE@ $(top_srcdir)/include/grub/i386/tsc.h
+@COND_i386_xen_pvh_TRUE@am__append_5916 = $(top_builddir)/include/grub/machine/kernel.h \
+@COND_i386_xen_pvh_TRUE@ $(top_builddir)/include/grub/machine/int.h \
+@COND_i386_xen_pvh_TRUE@ $(top_srcdir)/include/grub/i386/tsc.h \
+@COND_i386_xen_pvh_TRUE@ $(top_srcdir)/include/grub/terminfo.h \
+@COND_i386_xen_pvh_TRUE@ $(top_srcdir)/include/grub/extcmd.h \
+@COND_i386_xen_pvh_TRUE@ $(top_srcdir)/include/grub/loader.h \
+@COND_i386_xen_pvh_TRUE@ $(top_srcdir)/include/grub/lib/arg.h \
+@COND_i386_xen_pvh_TRUE@ $(top_srcdir)/include/grub/xen.h \
+@COND_i386_xen_pvh_TRUE@ $(top_srcdir)/include/grub/i386/xen/hypercall.h
+@COND_i386_efi_TRUE@am__append_5917 = $(top_builddir)/include/grub/machine/kernel.h \
+@COND_i386_efi_TRUE@ $(top_srcdir)/include/grub/efi/efi.h \
+@COND_i386_efi_TRUE@ $(top_srcdir)/include/grub/efi/disk.h \
+@COND_i386_efi_TRUE@ $(top_srcdir)/include/grub/i386/tsc.h \
+@COND_i386_efi_TRUE@ $(top_srcdir)/include/grub/acpi.h \
+@COND_i386_efi_TRUE@ $(top_srcdir)/include/grub/pci.h \
+@COND_i386_efi_TRUE@ $(top_srcdir)/include/grub/i386/pmtimer.h
+@COND_i386_coreboot_TRUE@am__append_5918 = $(top_builddir)/include/grub/machine/kernel.h \
+@COND_i386_coreboot_TRUE@ $(top_srcdir)/include/grub/i386/tsc.h \
+@COND_i386_coreboot_TRUE@ $(top_srcdir)/include/grub/coreboot/lbio.h \
+@COND_i386_coreboot_TRUE@ $(top_srcdir)/include/grub/video.h \
+@COND_i386_coreboot_TRUE@ $(top_srcdir)/include/grub/video_fb.h \
+@COND_i386_coreboot_TRUE@ $(top_srcdir)/include/grub/gfxterm.h \
+@COND_i386_coreboot_TRUE@ $(top_srcdir)/include/grub/font.h \
+@COND_i386_coreboot_TRUE@ $(top_srcdir)/include/grub/bufio.h \
+@COND_i386_coreboot_TRUE@ $(top_srcdir)/include/grub/acpi.h
+@COND_i386_multiboot_TRUE@am__append_5919 = $(top_builddir)/include/grub/machine/kernel.h \
+@COND_i386_multiboot_TRUE@ $(top_srcdir)/include/grub/i386/tsc.h \
+@COND_i386_multiboot_TRUE@ $(top_srcdir)/include/grub/acpi.h
+@COND_i386_qemu_TRUE@am__append_5920 = \
+@COND_i386_qemu_TRUE@ $(top_srcdir)/include/grub/pci.h \
+@COND_i386_qemu_TRUE@ $(top_srcdir)/include/grub/i386/tsc.h
+@COND_i386_ieee1275_TRUE@am__append_5921 = $(top_builddir)/include/grub/machine/kernel.h \
+@COND_i386_ieee1275_TRUE@ $(top_srcdir)/include/grub/ieee1275/ieee1275.h \
+@COND_i386_ieee1275_TRUE@ $(top_srcdir)/include/grub/terminfo.h \
+@COND_i386_ieee1275_TRUE@ $(top_srcdir)/include/grub/extcmd.h \
+@COND_i386_ieee1275_TRUE@ $(top_srcdir)/include/grub/lib/arg.h \
+@COND_i386_ieee1275_TRUE@ $(top_srcdir)/include/grub/i386/tsc.h
+@COND_i386_xen_TRUE@am__append_5922 = $(top_builddir)/include/grub/machine/kernel.h \
+@COND_i386_xen_TRUE@ $(top_srcdir)/include/grub/xen.h \
+@COND_i386_xen_TRUE@ $(top_srcdir)/include/grub/i386/xen/hypercall.h \
+@COND_i386_xen_TRUE@ $(top_srcdir)/include/grub/terminfo.h \
+@COND_i386_xen_TRUE@ $(top_srcdir)/include/grub/extcmd.h \
+@COND_i386_xen_TRUE@ $(top_srcdir)/include/grub/lib/arg.h \
+@COND_i386_xen_TRUE@ $(top_srcdir)/include/grub/loader.h
+@COND_x86_64_xen_TRUE@am__append_5923 = \
+@COND_x86_64_xen_TRUE@ $(top_srcdir)/include/grub/xen.h \
+@COND_x86_64_xen_TRUE@ $(top_srcdir)/include/grub/x86_64/xen/hypercall.h \
+@COND_x86_64_xen_TRUE@ $(top_srcdir)/include/grub/terminfo.h \
+@COND_x86_64_xen_TRUE@ $(top_srcdir)/include/grub/extcmd.h \
+@COND_x86_64_xen_TRUE@ $(top_srcdir)/include/grub/lib/arg.h \
+@COND_x86_64_xen_TRUE@ $(top_srcdir)/include/grub/loader.h
+@COND_x86_64_efi_TRUE@am__append_5924 = $(top_builddir)/include/grub/machine/kernel.h \
+@COND_x86_64_efi_TRUE@ $(top_srcdir)/include/grub/efi/efi.h \
+@COND_x86_64_efi_TRUE@ $(top_srcdir)/include/grub/efi/disk.h \
+@COND_x86_64_efi_TRUE@ $(top_srcdir)/include/grub/i386/tsc.h \
+@COND_x86_64_efi_TRUE@ $(top_srcdir)/include/grub/pci.h \
+@COND_x86_64_efi_TRUE@ $(top_srcdir)/include/grub/acpi.h \
+@COND_x86_64_efi_TRUE@ $(top_srcdir)/include/grub/i386/pmtimer.h
+@COND_ia64_efi_TRUE@am__append_5925 = \
+@COND_ia64_efi_TRUE@ $(top_srcdir)/include/grub/efi/efi.h \
+@COND_ia64_efi_TRUE@ $(top_srcdir)/include/grub/efi/disk.h \
+@COND_ia64_efi_TRUE@ $(top_srcdir)/include/grub/acpi.h
+@COND_mips_TRUE@am__append_5926 = $(top_builddir)/include/grub/cpu/kernel.h
+@COND_mips_arc_TRUE@am__append_5927 = \
+@COND_mips_arc_TRUE@ $(top_srcdir)/include/grub/extcmd.h \
+@COND_mips_arc_TRUE@ $(top_srcdir)/include/grub/arc/arc.h \
+@COND_mips_arc_TRUE@ $(top_srcdir)/include/grub/terminfo.h
+@COND_mips_qemu_mips_TRUE@am__append_5928 = $(top_builddir)/include/grub/keyboard_layouts.h \
+@COND_mips_qemu_mips_TRUE@ $(top_builddir)/include/grub/machine/kernel.h \
+@COND_mips_qemu_mips_TRUE@ $(top_srcdir)/include/grub/serial.h \
+@COND_mips_qemu_mips_TRUE@ $(top_srcdir)/include/grub/loader.h \
+@COND_mips_qemu_mips_TRUE@ $(top_srcdir)/include/grub/terminfo.h \
+@COND_mips_qemu_mips_TRUE@ $(top_srcdir)/include/grub/extcmd.h \
+@COND_mips_qemu_mips_TRUE@ $(top_srcdir)/include/grub/lib/arg.h
+@COND_mips_loongson_TRUE@am__append_5929 = $(top_builddir)/include/grub/keyboard_layouts.h \
+@COND_mips_loongson_TRUE@ $(top_builddir)/include/grub/machine/kernel.h \
+@COND_mips_loongson_TRUE@ $(top_builddir)/include/grub/machine/time.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/video.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/video_fb.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/gfxterm.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/font.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/bufio.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/pci.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/cs5536.h \
+@COND_mips_loongson_TRUE@ $(top_builddir)/include/grub/machine/pci.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/serial.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/loader.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/terminfo.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/extcmd.h \
+@COND_mips_loongson_TRUE@ $(top_srcdir)/include/grub/lib/arg.h
+@COND_mips_qemu_mips_TRUE@am__append_5930 = $(top_builddir)/include/grub/machine/memory.h \
+@COND_mips_qemu_mips_TRUE@ $(top_builddir)/include/grub/machine/kernel.h
+@COND_powerpc_ieee1275_TRUE@am__append_5931 = $(top_srcdir)/include/grub/ieee1275/ieee1275.h \
+@COND_powerpc_ieee1275_TRUE@ $(top_srcdir)/include/grub/terminfo.h \
+@COND_powerpc_ieee1275_TRUE@ $(top_srcdir)/include/grub/extcmd.h \
+@COND_powerpc_ieee1275_TRUE@ $(top_srcdir)/include/grub/lib/arg.h
+@COND_sparc64_ieee1275_TRUE@am__append_5932 = $(top_srcdir)/include/grub/ieee1275/ieee1275.h \
+@COND_sparc64_ieee1275_TRUE@ $(top_srcdir)/include/grub/sparc64/ieee1275/ieee1275.h \
+@COND_sparc64_ieee1275_TRUE@ $(top_srcdir)/include/grub/terminfo.h \
+@COND_sparc64_ieee1275_TRUE@ $(top_srcdir)/include/grub/extcmd.h \
+@COND_sparc64_ieee1275_TRUE@ $(top_srcdir)/include/grub/lib/arg.h
+@COND_arm_uboot_TRUE@am__append_5933 = \
+@COND_arm_uboot_TRUE@ $(top_srcdir)/include/grub/uboot/uboot.h \
+@COND_arm_uboot_TRUE@ $(top_srcdir)/include/grub/uboot/disk.h \
+@COND_arm_uboot_TRUE@ $(top_srcdir)/include/grub/extcmd.h \
+@COND_arm_uboot_TRUE@ $(top_srcdir)/include/grub/lib/arg.h \
+@COND_arm_uboot_TRUE@ $(top_srcdir)/include/grub/arm/system.h
+@COND_arm_coreboot_TRUE@am__append_5934 = $(top_builddir)/include/grub/keyboard_layouts.h \
+@COND_arm_coreboot_TRUE@ $(top_srcdir)/include/grub/arm/system.h \
+@COND_arm_coreboot_TRUE@ $(top_srcdir)/include/grub/video.h \
+@COND_arm_coreboot_TRUE@ $(top_srcdir)/include/grub/video_fb.h \
+@COND_arm_coreboot_TRUE@ $(top_srcdir)/include/grub/gfxterm.h \
+@COND_arm_coreboot_TRUE@ $(top_srcdir)/include/grub/font.h \
+@COND_arm_coreboot_TRUE@ $(top_srcdir)/include/grub/bufio.h \
+@COND_arm_coreboot_TRUE@ $(top_srcdir)/include/grub/fdt.h \
+@COND_arm_coreboot_TRUE@ $(top_srcdir)/include/grub/dma.h \
+@COND_arm_coreboot_TRUE@ $(top_srcdir)/include/grub/arm/coreboot/kernel.h \
+@COND_arm_coreboot_TRUE@ $(top_srcdir)/include/grub/fdtbus.h
+@COND_arm_efi_TRUE@am__append_5935 = \
+@COND_arm_efi_TRUE@ $(top_srcdir)/include/grub/efi/efi.h \
+@COND_arm_efi_TRUE@ $(top_srcdir)/include/grub/efi/disk.h \
+@COND_arm_efi_TRUE@ $(top_srcdir)/include/grub/arm/system.h \
+@COND_arm_efi_TRUE@ $(top_srcdir)/include/grub/acpi.h
+@COND_arm64_efi_TRUE@am__append_5936 = \
+@COND_arm64_efi_TRUE@ $(top_srcdir)/include/grub/efi/efi.h \
+@COND_arm64_efi_TRUE@ $(top_srcdir)/include/grub/efi/disk.h \
+@COND_arm64_efi_TRUE@ $(top_srcdir)/include/grub/acpi.h
+@COND_riscv32_efi_TRUE@am__append_5937 = \
+@COND_riscv32_efi_TRUE@ $(top_srcdir)/include/grub/efi/efi.h \
+@COND_riscv32_efi_TRUE@ $(top_srcdir)/include/grub/efi/disk.h \
+@COND_riscv32_efi_TRUE@ $(top_srcdir)/include/grub/acpi.h
+@COND_riscv64_efi_TRUE@am__append_5938 = \
+@COND_riscv64_efi_TRUE@ $(top_srcdir)/include/grub/efi/efi.h \
+@COND_riscv64_efi_TRUE@ $(top_srcdir)/include/grub/efi/disk.h \
+@COND_riscv64_efi_TRUE@ $(top_srcdir)/include/grub/acpi.h
+@COND_emu_TRUE@am__append_5939 = \
+@COND_emu_TRUE@ $(top_srcdir)/include/grub/datetime.h \
+@COND_emu_TRUE@ $(top_srcdir)/include/grub/emu/misc.h \
+@COND_emu_TRUE@ $(top_srcdir)/include/grub/emu/net.h \
+@COND_emu_TRUE@ $(top_srcdir)/include/grub/emu/hostdisk.h \
+@COND_emu_TRUE@ $(top_srcdir)/include/grub/emu/hostfile.h \
+@COND_emu_TRUE@ $(top_srcdir)/include/grub/extcmd.h
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@am__append_5940 = $(top_srcdir)/include/grub/sdl.h
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@am__append_5941 = $(top_srcdir)/include/grub/libpciaccess.h
+@COND_emu_TRUE@am__append_5942 = grub_emu_init.h grub_emu_init.c
+@COND_ENABLE_EFIEMU_TRUE@am__append_5943 = efiemu32.o efiemu64.o
+@COND_ENABLE_EFIEMU_TRUE@am__append_5944 = efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
+subdir = grub-core
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
+ $(top_srcdir)/m4/__inline.m4 \
+ $(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/alloca.m4 \
+ $(top_srcdir)/m4/argp.m4 $(top_srcdir)/m4/base64.m4 \
+ $(top_srcdir)/m4/btowc.m4 $(top_srcdir)/m4/builtin-expect.m4 \
+ $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/close.m4 \
+ $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/dirent_h.m4 \
+ $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \
+ $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \
+ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/errno_h.m4 \
+ $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/exponentd.m4 \
+ $(top_srcdir)/m4/extensions.m4 \
+ $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fchdir.m4 \
+ $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl.m4 \
+ $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/filenamecat.m4 \
+ $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \
+ $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fnmatch_h.m4 \
+ $(top_srcdir)/m4/fstat.m4 $(top_srcdir)/m4/getcwd.m4 \
+ $(top_srcdir)/m4/getdelim.m4 $(top_srcdir)/m4/getdtablesize.m4 \
+ $(top_srcdir)/m4/getline.m4 $(top_srcdir)/m4/getopt.m4 \
+ $(top_srcdir)/m4/getprogname.m4 $(top_srcdir)/m4/gettext.m4 \
+ $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/gnulib-common.m4 \
+ $(top_srcdir)/m4/gnulib-comp.m4 \
+ $(top_srcdir)/m4/host-cpu-c-abi.m4 $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/include_next.m4 \
+ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax_t.m4 \
+ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/langinfo_h.m4 \
+ $(top_srcdir)/m4/largefile.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libunistring-base.m4 \
+ $(top_srcdir)/m4/limits-h.m4 $(top_srcdir)/m4/localcharset.m4 \
+ $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \
+ $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/locale_h.m4 \
+ $(top_srcdir)/m4/localeconv.m4 $(top_srcdir)/m4/lock.m4 \
+ $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/lstat.m4 \
+ $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \
+ $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \
+ $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \
+ $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/mbtowc.m4 \
+ $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/mempcpy.m4 \
+ $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/mmap-anon.m4 \
+ $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/msvc-inval.m4 \
+ $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \
+ $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \
+ $(top_srcdir)/m4/open-cloexec.m4 $(top_srcdir)/m4/open.m4 \
+ $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf.m4 \
+ $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/m4/pthread_rwlock_rdlock.m4 \
+ $(top_srcdir)/m4/rawmemchr.m4 $(top_srcdir)/m4/realloc.m4 \
+ $(top_srcdir)/m4/regex.m4 $(top_srcdir)/m4/save-cwd.m4 \
+ $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/sleep.m4 \
+ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/stat-time.m4 \
+ $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdalign.m4 \
+ $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \
+ $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \
+ $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \
+ $(top_srcdir)/m4/strcase.m4 $(top_srcdir)/m4/strchrnul.m4 \
+ $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \
+ $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strings_h.m4 \
+ $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \
+ $(top_srcdir)/m4/sys_socket_h.m4 \
+ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_types_h.m4 \
+ $(top_srcdir)/m4/sysexits.m4 $(top_srcdir)/m4/threadlib.m4 \
+ $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/unistd-safer.m4 \
+ $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/vasnprintf.m4 \
+ $(top_srcdir)/m4/vsnprintf.m4 $(top_srcdir)/m4/warn-on-use.m4 \
+ $(top_srcdir)/m4/wchar_h.m4 $(top_srcdir)/m4/wchar_t.m4 \
+ $(top_srcdir)/m4/wcrtomb.m4 $(top_srcdir)/m4/wctype_h.m4 \
+ $(top_srcdir)/m4/wcwidth.m4 $(top_srcdir)/m4/wint_t.m4 \
+ $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(dist_grubconf_DATA) \
+ $(am__dist_noinst_DATA_DIST) $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config-util.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+@COND_emu_TRUE@am__EXEEXT_1 = grub-emu$(EXEEXT) grub-emu-lite$(EXEEXT)
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(platformdir)" \
+ "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(bindir)" \
+ "$(DESTDIR)$(grubconfdir)" "$(DESTDIR)$(platformdir)" \
+ "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man1dir)" \
+ "$(DESTDIR)$(grubconfdir)" "$(DESTDIR)$(pkgdatadir)" \
+ "$(DESTDIR)$(platformdir)"
+@COND_i386_pc_TRUE@am__EXEEXT_2 = cs5536.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_3 = cs5536.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_4 = cs5536.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_5 = cs5536.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_6 = cs5536.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_7 = cs5536.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_8 = cs5536.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_9 = lsspd.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_10 = usb.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_11 = usb.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_12 = usb.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_13 = usb.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_14 = usb.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_15 = usb.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_16 = usb.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_17 = usb.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_18 = usb.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_19 = usbserial_common.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_20 = usbserial_common.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_21 = usbserial_common.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_22 = \
+@COND_i386_coreboot_TRUE@ usbserial_common.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_23 = \
+@COND_i386_multiboot_TRUE@ usbserial_common.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_24 = \
+@COND_i386_ieee1275_TRUE@ usbserial_common.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_25 = \
+@COND_x86_64_efi_TRUE@ usbserial_common.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_26 = \
+@COND_mips_loongson_TRUE@ usbserial_common.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_27 = \
+@COND_arm_coreboot_TRUE@ usbserial_common.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_28 = usbserial_pl2303.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_29 = usbserial_pl2303.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_30 = usbserial_pl2303.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_31 = \
+@COND_i386_coreboot_TRUE@ usbserial_pl2303.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_32 = \
+@COND_i386_multiboot_TRUE@ usbserial_pl2303.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_33 = \
+@COND_i386_ieee1275_TRUE@ usbserial_pl2303.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_34 = \
+@COND_x86_64_efi_TRUE@ usbserial_pl2303.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_35 = \
+@COND_mips_loongson_TRUE@ usbserial_pl2303.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_36 = \
+@COND_arm_coreboot_TRUE@ usbserial_pl2303.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_37 = usbserial_ftdi.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_38 = usbserial_ftdi.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_39 = usbserial_ftdi.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_40 = \
+@COND_i386_coreboot_TRUE@ usbserial_ftdi.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_41 = \
+@COND_i386_multiboot_TRUE@ usbserial_ftdi.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_42 = \
+@COND_i386_ieee1275_TRUE@ usbserial_ftdi.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_43 = usbserial_ftdi.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_44 = \
+@COND_mips_loongson_TRUE@ usbserial_ftdi.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_45 = \
+@COND_arm_coreboot_TRUE@ usbserial_ftdi.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_46 = usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_47 = \
+@COND_i386_efi_TRUE@ usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_48 = \
+@COND_i386_qemu_TRUE@ usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_49 = \
+@COND_i386_coreboot_TRUE@ usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_50 = \
+@COND_i386_multiboot_TRUE@ usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_51 = \
+@COND_i386_ieee1275_TRUE@ usbserial_usbdebug.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_52 = \
+@COND_x86_64_efi_TRUE@ usbserial_usbdebug.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_53 = \
+@COND_mips_loongson_TRUE@ usbserial_usbdebug.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_54 = \
+@COND_arm_coreboot_TRUE@ usbserial_usbdebug.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_55 = uhci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_56 = uhci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_57 = uhci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_58 = uhci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_59 = uhci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_60 = uhci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_61 = uhci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_62 = uhci.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_63 = ohci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_64 = ohci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_65 = ohci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_66 = ohci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_67 = ohci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_68 = ohci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_69 = ohci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_70 = ohci.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_71 = ehci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_72 = ehci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_73 = ehci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_74 = ehci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_75 = ehci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_76 = ehci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_77 = ehci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_78 = ehci.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_79 = ehci.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_80 = pci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_81 = pci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_82 = pci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_83 = pci.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_84 = nativedisk.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_85 = nativedisk.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_86 = nativedisk.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_87 = nativedisk.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_88 = nativedisk.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_89 = nativedisk.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_90 = nativedisk.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_91 = nativedisk.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_92 = nativedisk.module$(EXEEXT)
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@am__EXEEXT_93 = \
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@ emupci.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_94 = lsdev.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_95 = lsxen.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_96 = lsxen.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_97 = cmostest.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_98 = cmostest.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_99 = cmostest.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_100 = cmostest.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_101 = cmostest.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_102 = cmostest.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_103 = cmostest.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_104 = cmostest.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_105 = cmostest.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_106 = cmosdump.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_107 = cmosdump.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_108 = cmosdump.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_109 = cmosdump.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_110 = cmosdump.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_111 = cmosdump.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_112 = cmosdump.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_113 = cmosdump.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_114 = cmosdump.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_115 = iorw.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_116 = iorw.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_117 = iorw.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_118 = iorw.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_119 = iorw.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_120 = iorw.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_121 = iorw.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_122 = cbtable.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_123 = cbtable.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_124 = cbtable.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_125 = cbtable.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_126 = cbtable.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_127 = cbtable.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_128 = cbtime.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_129 = cbtime.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_130 = cbtime.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_131 = cbtime.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_132 = cbtime.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_133 = cbtime.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_134 = cbtime.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_135 = cbls.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_136 = cbls.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_137 = cbls.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_138 = cbls.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_139 = cbls.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_140 = cbls.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_141 = cbls.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_142 = cbmemc.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_143 = cbmemc.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_144 = cbmemc.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_145 = cbmemc.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_146 = cbmemc.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_147 = cbmemc.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_148 = cbmemc.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_149 = acpi.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_150 = acpi.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_151 = acpi.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_152 = acpi.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_153 = acpi.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_154 = acpi.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_155 = acpi.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_156 = acpi.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_157 = acpi.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_158 = acpi.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_159 = lsacpi.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_160 = lsacpi.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_161 = lsacpi.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_162 = lsacpi.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_163 = lsacpi.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_164 = lsacpi.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_165 = lsacpi.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_166 = lsacpi.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_167 = lsacpi.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_168 = lsacpi.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_169 = lsefisystab.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_170 = lsefisystab.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_171 = lsefisystab.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_172 = lsefisystab.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_173 = lsefisystab.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_174 = lsefisystab.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_175 = lsefisystab.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_176 = lssal.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_177 = lssal.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_178 = lssal.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_179 = lssal.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_180 = lssal.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_181 = lssal.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_182 = lssal.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_183 = lsefimmap.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_184 = lsefimmap.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_185 = lsefimmap.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_186 = lsefimmap.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_187 = lsefimmap.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_188 = lsefimmap.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_189 = lsefimmap.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_190 = lsefi.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_191 = lsefi.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_192 = lsefi.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_193 = lsefi.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_194 = lsefi.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_195 = lsefi.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_196 = lsefi.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_197 = efifwsetup.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_198 = efifwsetup.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_199 = efifwsetup.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_200 = efifwsetup.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_201 = efifwsetup.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_202 = efifwsetup.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_203 = efifwsetup.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_204 = boot.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_205 = boot.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_206 = boot.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_207 = boot.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_208 = boot.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_209 = boot.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_210 = boot.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_211 = boot.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_212 = boot.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_213 = boot.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_214 = boot.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_215 = boot.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_216 = boot.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_217 = boot.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_218 = boot.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_219 = boot.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_220 = boot.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_221 = boot.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_222 = cpuid.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_223 = cpuid.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_224 = cpuid.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_225 = cpuid.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_226 = cpuid.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_227 = cpuid.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_228 = cpuid.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_229 = cpuid.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_230 = cpuid.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_231 = cpuid.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_232 = drivemap.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_233 = extcmd.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_234 = extcmd.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_235 = extcmd.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_236 = extcmd.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_237 = extcmd.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_238 = extcmd.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_239 = extcmd.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_240 = extcmd.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_241 = extcmd.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_242 = extcmd.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_243 = extcmd.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_244 = extcmd.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_245 = fixvideo.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_246 = fixvideo.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_247 = halt.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_248 = halt.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_249 = halt.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_250 = halt.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_251 = halt.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_252 = halt.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_253 = halt.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_254 = halt.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_255 = halt.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_256 = halt.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_257 = halt.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_258 = halt.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_259 = halt.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_260 = halt.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_261 = halt.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_262 = halt.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_263 = halt.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_264 = halt.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_265 = halt.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_266 = halt.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_267 = halt.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_268 = halt.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_269 = halt.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_270 = reboot.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_271 = reboot.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_272 = reboot.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_273 = reboot.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_274 = reboot.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_275 = reboot.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_276 = reboot.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_277 = reboot.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_278 = reboot.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_279 = reboot.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_280 = reboot.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_281 = reboot.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_282 = reboot.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_283 = reboot.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_284 = reboot.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_285 = reboot.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_286 = reboot.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_287 = reboot.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_288 = reboot.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_289 = reboot.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_290 = reboot.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_291 = reboot.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_292 = reboot.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_293 = hdparm.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_294 = hdparm.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_295 = hdparm.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_296 = hdparm.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_297 = hdparm.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_298 = hdparm.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_299 = hdparm.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_300 = hdparm.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_301 = hdparm.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_302 = loadbios.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_303 = loadbios.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_304 = lspci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_305 = lspci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_306 = lspci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_307 = lspci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_308 = lspci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_309 = lspci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_310 = lspci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_311 = lspci.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_312 = play.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_313 = play.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_314 = play.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_315 = play.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_316 = play.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_317 = play.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_318 = play.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_319 = spkmodem.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_320 = spkmodem.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_321 = spkmodem.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_322 = spkmodem.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_323 = spkmodem.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_324 = spkmodem.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_325 = spkmodem.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_326 = morse.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_327 = morse.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_328 = morse.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_329 = morse.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_330 = morse.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_331 = morse.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_332 = morse.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_333 = setpci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_334 = setpci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_335 = setpci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_336 = setpci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_337 = setpci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_338 = setpci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_339 = setpci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_340 = setpci.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_341 = pcidump.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_342 = pcidump.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_343 = pcidump.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_344 = pcidump.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_345 = pcidump.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_346 = pcidump.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_347 = pcidump.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_348 = pcidump.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_349 = smbios.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_350 = smbios.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_351 = smbios.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_352 = smbios.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_353 = smbios.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_354 = smbios.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_355 = smbios.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_356 = smbios.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_357 = smbios.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_358 = smbios.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_359 = suspend.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_360 = suspend.module$(EXEEXT) \
+@COND_powerpc_ieee1275_TRUE@ escc.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_361 = usbtest.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_362 = usbtest.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_363 = usbtest.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_364 = usbtest.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_365 = usbtest.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_366 = usbtest.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_367 = usbtest.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_368 = usbtest.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_369 = usbtest.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_370 = ata.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_371 = ata.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_372 = ata.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_373 = ata.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_374 = ata.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_375 = ata.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_376 = ata.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_377 = ata.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_378 = ata.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_379 = ahci.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_380 = ahci.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_381 = ahci.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_382 = ahci.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_383 = ahci.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_384 = ahci.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_385 = ahci.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_386 = ahci.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_387 = pata.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_388 = pata.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_389 = pata.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_390 = pata.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_391 = pata.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_392 = pata.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_393 = pata.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_394 = pata.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_395 = pata.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_396 = biosdisk.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ usbms.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_397 = usbms.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_398 = usbms.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_399 = usbms.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_400 = usbms.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_401 = usbms.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_402 = usbms.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_403 = usbms.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_404 = usbms.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_405 = nand.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_406 = efiemu.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_407 = efiemu.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_408 = efiemu.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_409 = efiemu.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_410 = efiemu.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_411 = font.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_412 = font.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_413 = font.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_414 = font.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_415 = font.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_416 = font.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_417 = font.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_418 = font.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_419 = font.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_420 = font.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_421 = font.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_422 = font.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_423 = font.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_424 = font.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_425 = font.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_426 = font.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_427 = font.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_428 = font.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_429 = font.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_430 = font.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_431 = pxe.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_432 = bufio.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_433 = bufio.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_434 = bufio.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_435 = bufio.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_436 = bufio.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_437 = bufio.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_438 = bufio.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_439 = bufio.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_440 = bufio.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_441 = bufio.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_442 = bufio.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_443 = bufio.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_444 = bufio.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_445 = bufio.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_446 = bufio.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_447 = bufio.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_448 = bufio.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_449 = bufio.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_450 = bufio.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_451 = bufio.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_452 = relocator.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_453 = relocator.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_454 = relocator.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_455 = relocator.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_456 = relocator.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_457 = relocator.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_458 = relocator.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_459 = relocator.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_460 = relocator.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_461 = relocator.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_462 = relocator.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_463 = \
+@COND_powerpc_ieee1275_TRUE@ relocator.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_464 = relocator.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_465 = relocator.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_466 = datetime.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_467 = datetime.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_468 = datetime.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_469 = datetime.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_470 = datetime.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_471 = datetime.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_472 = datetime.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_473 = datetime.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_474 = datetime.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_475 = datetime.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_476 = datetime.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_477 = datetime.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_478 = datetime.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_479 = datetime.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_480 = datetime.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_481 = datetime.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_482 = datetime.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_483 = datetime.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_484 = datetime.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_485 = datetime.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_486 = datetime.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_487 = datetime.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_488 = datetime.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_489 = aout.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_490 = aout.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_491 = aout.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_492 = aout.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_493 = aout.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_494 = aout.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_495 = aout.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_496 = bsd.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_497 = bsd.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_498 = bsd.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_499 = bsd.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_500 = bsd.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_501 = bsd.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_502 = bsd.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_503 = plan9.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ linux16.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_504 = linux16.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_505 = linux16.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_506 = linux16.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_507 = linux16.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_508 = linux16.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_509 = linux16.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_510 = ntldr.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ truecrypt.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ freedos.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ pxechain.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ multiboot2.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_511 = multiboot2.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_512 = multiboot2.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_513 = multiboot2.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_514 = multiboot2.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_515 = multiboot2.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_516 = multiboot2.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_517 = multiboot2.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_518 = multiboot2.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_519 = multiboot2.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_520 = multiboot2.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_521 = multiboot.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_522 = multiboot.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_523 = multiboot.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_524 = multiboot.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_525 = multiboot.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_526 = multiboot.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_527 = multiboot.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_528 = multiboot.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_529 = xen_boot.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_530 = linux.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_531 = linux.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_532 = linux.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_533 = linux.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_534 = linux.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_535 = linux.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_536 = linux.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_537 = linux.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_538 = linux.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_539 = linux.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_540 = linux.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_541 = linux.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_542 = linux.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_543 = linux.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_544 = linux.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_545 = linux.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_546 = linux.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_547 = linux.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_548 = linux.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_549 = linux.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_550 = linux.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_551 = linux.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_552 = fdt.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_553 = fdt.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_554 = fdt.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_555 = fdt.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_556 = fdt.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_557 = xnu.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_558 = xnu.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_559 = xnu.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_560 = xnu.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_561 = xnu.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_562 = random.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_563 = random.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_564 = random.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_565 = random.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_566 = random.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_567 = appleldr.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_568 = appleldr.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_569 = chain.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_570 = chain.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_571 = chain.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_572 = chain.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_573 = chain.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_574 = chain.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_575 = chain.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_576 = chain.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_577 = chain.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_578 = mmap.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_579 = mmap.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_580 = mmap.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_581 = mmap.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_582 = mmap.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_583 = mmap.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_584 = mmap.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_585 = mmap.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_586 = mmap.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_587 = mmap.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_588 = mmap.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_589 = mmap.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_590 = mmap.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_591 = mmap.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_592 = mmap.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_593 = mmap.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_594 = at_keyboard.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_595 = at_keyboard.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_596 = at_keyboard.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_597 = at_keyboard.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_598 = \
+@COND_i386_multiboot_TRUE@ at_keyboard.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_599 = at_keyboard.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_600 = at_keyboard.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_601 = gfxterm.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_602 = gfxterm.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_603 = gfxterm.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_604 = gfxterm.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_605 = gfxterm.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_606 = gfxterm.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_607 = gfxterm.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_608 = gfxterm.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_609 = gfxterm.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_610 = gfxterm.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_611 = gfxterm.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_612 = gfxterm.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_613 = gfxterm.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_614 = gfxterm.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_615 = gfxterm.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_616 = gfxterm.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_617 = gfxterm.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_618 = gfxterm.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_619 = gfxterm.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_620 = gfxterm.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_621 = serial.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_622 = serial.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_623 = serial.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_624 = serial.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_625 = serial.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_626 = serial.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_627 = serial.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_628 = serial.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_629 = serial.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_630 = serial.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_631 = serial.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_632 = serial.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_633 = serial.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_634 = serial.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_635 = serial.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_636 = serial.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_637 = sendkey.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ terminfo.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_638 = terminfo.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_639 = terminfo.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_640 = terminfo.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_641 = terminfo.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_642 = terminfo.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_643 = terminfo.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_644 = terminfo.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_645 = terminfo.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_646 = terminfo.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_647 = terminfo.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_648 = terminfo.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_649 = usb_keyboard.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_650 = usb_keyboard.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_651 = usb_keyboard.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_652 = \
+@COND_i386_coreboot_TRUE@ usb_keyboard.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_653 = \
+@COND_i386_multiboot_TRUE@ usb_keyboard.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_654 = \
+@COND_i386_ieee1275_TRUE@ usb_keyboard.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_655 = usb_keyboard.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_656 = \
+@COND_mips_loongson_TRUE@ usb_keyboard.module$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_657 = usb_keyboard.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_658 = vga.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ vga_text.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ mda_text.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_659 = mda_text.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_660 = mda_text.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_661 = mda_text.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_662 = video_cirrus.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_663 = video_cirrus.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_664 = video_cirrus.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_665 = \
+@COND_i386_coreboot_TRUE@ video_cirrus.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_666 = \
+@COND_i386_multiboot_TRUE@ video_cirrus.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_667 = \
+@COND_i386_ieee1275_TRUE@ video_cirrus.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_668 = video_cirrus.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_669 = video_bochs.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_670 = video_bochs.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_671 = video_bochs.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_672 = video_bochs.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_673 = \
+@COND_i386_multiboot_TRUE@ video_bochs.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_674 = video_bochs.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_675 = video_bochs.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_676 = legacy_password_test.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_677 = \
+@COND_i386_pc_TRUE@ legacy_password_test.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_678 = \
+@COND_i386_efi_TRUE@ legacy_password_test.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_679 = \
+@COND_x86_64_efi_TRUE@ legacy_password_test.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_680 = \
+@COND_i386_xen_TRUE@ legacy_password_test.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_681 = \
+@COND_x86_64_xen_TRUE@ legacy_password_test.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_682 = \
+@COND_i386_xen_pvh_TRUE@ legacy_password_test.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_683 = div.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_684 = div.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_685 = div.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_686 = div.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_687 = div.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_688 = div.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_689 = div.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_690 = div.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_691 = div.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_692 = div.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_693 = div.module$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_694 = div.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_695 = div.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_696 = div.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_697 = div.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_698 = div.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_699 = div.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_700 = div.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_701 = efi_gop.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_702 = efi_gop.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_703 = efi_gop.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_704 = efi_gop.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_705 = efi_gop.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_706 = efi_gop.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_707 = efi_gop.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_708 = efi_uga.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_709 = efi_uga.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_710 = vbe.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_711 = video_fb.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_712 = video_fb.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_713 = video_fb.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_714 = video_fb.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_715 = video_fb.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_716 = video_fb.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_717 = video_fb.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_718 = video_fb.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_719 = video_fb.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_720 = video_fb.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_721 = video_fb.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_722 = video_fb.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_723 = video_fb.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_724 = video_fb.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_725 = video_fb.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_726 = video_fb.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_727 = video_fb.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_728 = video_fb.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_729 = video_fb.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_730 = video_fb.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_731 = video.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_732 = video.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_733 = video.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_734 = video.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_735 = video.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_736 = video.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_737 = video.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_738 = video.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_739 = video.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_740 = video.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_741 = video.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_742 = video.module$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_743 = video.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_744 = video.module$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_745 = video.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_746 = video.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_747 = video.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_748 = video.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_749 = video.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_750 = video.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_751 = \
+@COND_powerpc_ieee1275_TRUE@ ieee1275_fb.module$(EXEEXT)
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@am__EXEEXT_752 = \
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@ sdl.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_753 = ofnet.module$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_754 = ofnet.module$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_755 = ofnet.module$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_756 = ubootnet.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_757 = efinet.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_758 = efinet.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_759 = efinet.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_760 = efinet.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_761 = efinet.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_762 = efinet.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_763 = efinet.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_764 = emunet.module$(EXEEXT) \
+@COND_emu_TRUE@ legacycfg.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_765 = legacycfg.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_766 = legacycfg.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_767 = legacycfg.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_768 = legacycfg.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_769 = legacycfg.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_770 = legacycfg.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_771 = backtrace.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_772 = backtrace.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_773 = backtrace.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_774 = backtrace.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_775 = backtrace.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_776 = backtrace.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_777 = backtrace.module$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_778 = backtrace.module$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_779 = backtrace.module$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_780 = backtrace.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_781 = lsapm.module$(EXEEXT) \
+@COND_i386_pc_TRUE@ keylayouts.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_782 = keylayouts.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_783 = keylayouts.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_784 = keylayouts.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_785 = keylayouts.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_786 = keylayouts.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_787 = keylayouts.module$(EXEEXT)
+@COND_ENABLE_CACHE_STATS_TRUE@am__EXEEXT_788 = \
+@COND_ENABLE_CACHE_STATS_TRUE@ cacheinfo.module$(EXEEXT)
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@am__EXEEXT_789 = \
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@ boottime.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_790 = gdb.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_791 = gdb.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_792 = gdb.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_793 = gdb.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_794 = gdb.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_795 = gdb.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_796 = tpm.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_797 = tpm.module$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_798 = tpm.module$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_799 = tpm.module$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_800 = tpm.module$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_801 = tpm.module$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_802 = tpm.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_803 = rdmsr.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_804 = rdmsr.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_805 = rdmsr.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_806 = rdmsr.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_807 = rdmsr.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_808 = rdmsr.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_809 = rdmsr.module$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_810 = wrmsr.module$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_811 = wrmsr.module$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_812 = wrmsr.module$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_813 = wrmsr.module$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_814 = wrmsr.module$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_815 = wrmsr.module$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_816 = wrmsr.module$(EXEEXT)
+@COND_emu_TRUE@am__EXEEXT_817 = kernel.exec$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_818 = kernel.exec$(EXEEXT)
+@COND_i386_efi_TRUE@am__EXEEXT_819 = kernel.exec$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_820 = kernel.exec$(EXEEXT)
+@COND_i386_coreboot_TRUE@am__EXEEXT_821 = kernel.exec$(EXEEXT)
+@COND_i386_multiboot_TRUE@am__EXEEXT_822 = kernel.exec$(EXEEXT)
+@COND_i386_ieee1275_TRUE@am__EXEEXT_823 = kernel.exec$(EXEEXT)
+@COND_x86_64_efi_TRUE@am__EXEEXT_824 = kernel.exec$(EXEEXT)
+@COND_i386_xen_TRUE@am__EXEEXT_825 = kernel.exec$(EXEEXT)
+@COND_x86_64_xen_TRUE@am__EXEEXT_826 = kernel.exec$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@am__EXEEXT_827 = kernel.exec$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_828 = kernel.exec$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_829 = kernel.exec$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@am__EXEEXT_830 = kernel.exec$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_831 = kernel.exec$(EXEEXT)
+@COND_ia64_efi_TRUE@am__EXEEXT_832 = kernel.exec$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_833 = kernel.exec$(EXEEXT)
+@COND_arm_uboot_TRUE@am__EXEEXT_834 = kernel.exec$(EXEEXT)
+@COND_arm_efi_TRUE@am__EXEEXT_835 = kernel.exec$(EXEEXT)
+@COND_arm64_efi_TRUE@am__EXEEXT_836 = kernel.exec$(EXEEXT)
+@COND_arm_coreboot_TRUE@am__EXEEXT_837 = kernel.exec$(EXEEXT)
+@COND_riscv32_efi_TRUE@am__EXEEXT_838 = kernel.exec$(EXEEXT)
+@COND_riscv64_efi_TRUE@am__EXEEXT_839 = kernel.exec$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_840 = boot.image$(EXEEXT)
+@COND_i386_qemu_TRUE@am__EXEEXT_841 = boot.image$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_842 = boot.image$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_843 = boot_hybrid.image$(EXEEXT) \
+@COND_i386_pc_TRUE@ cdboot.image$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_844 = cdboot.image$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_845 = pxeboot.image$(EXEEXT) \
+@COND_i386_pc_TRUE@ diskboot.image$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@am__EXEEXT_846 = diskboot.image$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_847 = lnxboot.image$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_848 = \
+@COND_mips_loongson_TRUE@ xz_decompress.image$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_849 = xz_decompress.image$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_850 = \
+@COND_mips_qemu_mips_TRUE@ xz_decompress.image$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_851 = \
+@COND_mips_loongson_TRUE@ none_decompress.image$(EXEEXT)
+@COND_mips_arc_TRUE@am__EXEEXT_852 = none_decompress.image$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@am__EXEEXT_853 = \
+@COND_mips_qemu_mips_TRUE@ none_decompress.image$(EXEEXT)
+@COND_i386_pc_TRUE@am__EXEEXT_854 = lzma_decompress.image$(EXEEXT)
+@COND_mips_loongson_TRUE@am__EXEEXT_855 = fwstart.image$(EXEEXT) \
+@COND_mips_loongson_TRUE@ fwstart_fuloong2f.image$(EXEEXT)
+PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) $(platform_PROGRAMS) \
+ $(sbin_PROGRAMS)
+am__acpi_module_SOURCES_DIST = commands/acpi.c kern/acpi.c \
+ kern/i386/pc/acpi.c
+am__dirstamp = $(am__leading_dot)dirstamp
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_acpi_module_OBJECTS = commands/acpi_module-acpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_acpi_module_OBJECTS = commands/acpi_module-acpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_acpi_module_OBJECTS = commands/acpi_module-acpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_TRUE@am_acpi_module_OBJECTS = commands/acpi_module-acpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_acpi_module_OBJECTS = kern/acpi_module-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/i386/pc/acpi_module-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ commands/acpi_module-acpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@am_acpi_module_OBJECTS = commands/acpi_module-acpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_acpi_module_OBJECTS = commands/acpi_module-acpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@am_acpi_module_OBJECTS = commands/acpi_module-acpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_acpi_module_OBJECTS = commands/acpi_module-acpi.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_acpi_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ commands/acpi_module-acpi.$(OBJEXT)
+nodist_acpi_module_OBJECTS =
+acpi_module_OBJECTS = $(am_acpi_module_OBJECTS) \
+ $(nodist_acpi_module_OBJECTS)
+acpi_module_LINK = $(CCLD) $(acpi_module_CFLAGS) $(CFLAGS) \
+ $(acpi_module_LDFLAGS) $(LDFLAGS) -o $@
+am_adler32_module_OBJECTS = lib/adler32_module-adler32.$(OBJEXT)
+nodist_adler32_module_OBJECTS =
+adler32_module_OBJECTS = $(am_adler32_module_OBJECTS) \
+ $(nodist_adler32_module_OBJECTS)
+adler32_module_LINK = $(CCLD) $(adler32_module_CFLAGS) $(CFLAGS) \
+ $(adler32_module_LDFLAGS) $(LDFLAGS) -o $@
+am_affs_module_OBJECTS = fs/affs_module-affs.$(OBJEXT)
+nodist_affs_module_OBJECTS =
+affs_module_OBJECTS = $(am_affs_module_OBJECTS) \
+ $(nodist_affs_module_OBJECTS)
+affs_module_LINK = $(CCLD) $(affs_module_CFLAGS) $(CFLAGS) \
+ $(affs_module_LDFLAGS) $(LDFLAGS) -o $@
+am_afs_module_OBJECTS = fs/afs_module-afs.$(OBJEXT)
+nodist_afs_module_OBJECTS =
+afs_module_OBJECTS = $(am_afs_module_OBJECTS) \
+ $(nodist_afs_module_OBJECTS)
+afs_module_LINK = $(CCLD) $(afs_module_CFLAGS) $(CFLAGS) \
+ $(afs_module_LDFLAGS) $(LDFLAGS) -o $@
+am_afsplitter_module_OBJECTS = \
+ disk/afsplitter_module-AFSplitter.$(OBJEXT)
+nodist_afsplitter_module_OBJECTS =
+afsplitter_module_OBJECTS = $(am_afsplitter_module_OBJECTS) \
+ $(nodist_afsplitter_module_OBJECTS)
+afsplitter_module_LINK = $(CCLD) $(afsplitter_module_CFLAGS) $(CFLAGS) \
+ $(afsplitter_module_LDFLAGS) $(LDFLAGS) -o $@
+am__ahci_module_SOURCES_DIST = disk/ahci.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_ahci_module_OBJECTS = disk/ahci_module-ahci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_ahci_module_OBJECTS = disk/ahci_module-ahci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_ahci_module_OBJECTS = disk/ahci_module-ahci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_ahci_module_OBJECTS = disk/ahci_module-ahci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_ahci_module_OBJECTS = disk/ahci_module-ahci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_ahci_module_OBJECTS = disk/ahci_module-ahci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_ahci_module_OBJECTS = disk/ahci_module-ahci.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_ahci_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ disk/ahci_module-ahci.$(OBJEXT)
+nodist_ahci_module_OBJECTS =
+ahci_module_OBJECTS = $(am_ahci_module_OBJECTS) \
+ $(nodist_ahci_module_OBJECTS)
+ahci_module_LINK = $(CCLD) $(ahci_module_CFLAGS) $(CFLAGS) \
+ $(ahci_module_LDFLAGS) $(LDFLAGS) -o $@
+am_all_video_module_OBJECTS = \
+ lib/all_video_module-fake_module.$(OBJEXT)
+nodist_all_video_module_OBJECTS =
+all_video_module_OBJECTS = $(am_all_video_module_OBJECTS) \
+ $(nodist_all_video_module_OBJECTS)
+all_video_module_LINK = $(CCLD) $(all_video_module_CFLAGS) $(CFLAGS) \
+ $(all_video_module_LDFLAGS) $(LDFLAGS) -o $@
+am__aout_module_SOURCES_DIST = loader/aout.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_aout_module_OBJECTS = loader/aout_module-aout.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_aout_module_OBJECTS = loader/aout_module-aout.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_aout_module_OBJECTS = loader/aout_module-aout.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_aout_module_OBJECTS = loader/aout_module-aout.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_aout_module_OBJECTS = loader/aout_module-aout.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_aout_module_OBJECTS = loader/aout_module-aout.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_aout_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ loader/aout_module-aout.$(OBJEXT)
+nodist_aout_module_OBJECTS =
+aout_module_OBJECTS = $(am_aout_module_OBJECTS) \
+ $(nodist_aout_module_OBJECTS)
+aout_module_LINK = $(CCLD) $(aout_module_CFLAGS) $(CFLAGS) \
+ $(aout_module_LDFLAGS) $(LDFLAGS) -o $@
+am__appleldr_module_SOURCES_DIST = loader/efi/appleloader.c
+@COND_i386_efi_FALSE@@COND_x86_64_efi_TRUE@am_appleldr_module_OBJECTS = loader/efi/appleldr_module-appleloader.$(OBJEXT)
+@COND_i386_efi_TRUE@am_appleldr_module_OBJECTS = loader/efi/appleldr_module-appleloader.$(OBJEXT)
+nodist_appleldr_module_OBJECTS =
+appleldr_module_OBJECTS = $(am_appleldr_module_OBJECTS) \
+ $(nodist_appleldr_module_OBJECTS)
+appleldr_module_LINK = $(CCLD) $(appleldr_module_CFLAGS) $(CFLAGS) \
+ $(appleldr_module_LDFLAGS) $(LDFLAGS) -o $@
+am_archelp_module_OBJECTS = fs/archelp_module-archelp.$(OBJEXT)
+nodist_archelp_module_OBJECTS =
+archelp_module_OBJECTS = $(am_archelp_module_OBJECTS) \
+ $(nodist_archelp_module_OBJECTS)
+archelp_module_LINK = $(CCLD) $(archelp_module_CFLAGS) $(CFLAGS) \
+ $(archelp_module_LDFLAGS) $(LDFLAGS) -o $@
+am__at_keyboard_module_SOURCES_DIST = term/at_keyboard.c term/ps2.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_at_keyboard_module_OBJECTS = term/at_keyboard_module-at_keyboard.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@ term/at_keyboard_module-ps2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_at_keyboard_module_OBJECTS = term/at_keyboard_module-at_keyboard.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ term/at_keyboard_module-ps2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_at_keyboard_module_OBJECTS = term/at_keyboard_module-at_keyboard.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ term/at_keyboard_module-ps2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_at_keyboard_module_OBJECTS = term/at_keyboard_module-at_keyboard.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ term/at_keyboard_module-ps2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_at_keyboard_module_OBJECTS = term/at_keyboard_module-at_keyboard.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ term/at_keyboard_module-ps2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_at_keyboard_module_OBJECTS = term/at_keyboard_module-at_keyboard.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ term/at_keyboard_module-ps2.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_at_keyboard_module_OBJECTS = term/at_keyboard_module-at_keyboard.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ term/at_keyboard_module-ps2.$(OBJEXT)
+nodist_at_keyboard_module_OBJECTS =
+at_keyboard_module_OBJECTS = $(am_at_keyboard_module_OBJECTS) \
+ $(nodist_at_keyboard_module_OBJECTS)
+at_keyboard_module_LINK = $(CCLD) $(at_keyboard_module_CFLAGS) \
+ $(CFLAGS) $(at_keyboard_module_LDFLAGS) $(LDFLAGS) -o $@
+am__ata_module_SOURCES_DIST = disk/ata.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_TRUE@am_ata_module_OBJECTS = disk/ata_module-ata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_ata_module_OBJECTS = disk/ata_module-ata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_ata_module_OBJECTS = disk/ata_module-ata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_ata_module_OBJECTS = disk/ata_module-ata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_ata_module_OBJECTS = disk/ata_module-ata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_ata_module_OBJECTS = disk/ata_module-ata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_ata_module_OBJECTS = disk/ata_module-ata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_ata_module_OBJECTS = disk/ata_module-ata.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_ata_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ disk/ata_module-ata.$(OBJEXT)
+nodist_ata_module_OBJECTS =
+ata_module_OBJECTS = $(am_ata_module_OBJECTS) \
+ $(nodist_ata_module_OBJECTS)
+ata_module_LINK = $(CCLD) $(ata_module_CFLAGS) $(CFLAGS) \
+ $(ata_module_LDFLAGS) $(LDFLAGS) -o $@
+am__backtrace_module_SOURCES_DIST = lib/i386/backtrace.c \
+ lib/backtrace.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_backtrace_module_OBJECTS = lib/i386/backtrace_module-backtrace.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ lib/backtrace_module-backtrace.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_TRUE@am_backtrace_module_OBJECTS = lib/i386/backtrace_module-backtrace.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_TRUE@ lib/backtrace_module-backtrace.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_backtrace_module_OBJECTS = lib/i386/backtrace_module-backtrace.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/backtrace_module-backtrace.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_backtrace_module_OBJECTS = lib/i386/backtrace_module-backtrace.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ lib/backtrace_module-backtrace.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_backtrace_module_OBJECTS = lib/i386/backtrace_module-backtrace.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/backtrace_module-backtrace.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_backtrace_module_OBJECTS = lib/i386/backtrace_module-backtrace.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/backtrace_module-backtrace.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_backtrace_module_OBJECTS = lib/i386/backtrace_module-backtrace.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/backtrace_module-backtrace.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_backtrace_module_OBJECTS = lib/i386/backtrace_module-backtrace.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/backtrace_module-backtrace.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_backtrace_module_OBJECTS = lib/i386/backtrace_module-backtrace.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/backtrace_module-backtrace.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_backtrace_module_OBJECTS = lib/i386/backtrace_module-backtrace.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ lib/backtrace_module-backtrace.$(OBJEXT)
+nodist_backtrace_module_OBJECTS =
+backtrace_module_OBJECTS = $(am_backtrace_module_OBJECTS) \
+ $(nodist_backtrace_module_OBJECTS)
+backtrace_module_LINK = $(CCLD) $(backtrace_module_CFLAGS) $(CFLAGS) \
+ $(backtrace_module_LDFLAGS) $(LDFLAGS) -o $@
+am_bfs_module_OBJECTS = fs/bfs_module-bfs.$(OBJEXT)
+nodist_bfs_module_OBJECTS =
+bfs_module_OBJECTS = $(am_bfs_module_OBJECTS) \
+ $(nodist_bfs_module_OBJECTS)
+bfs_module_LINK = $(CCLD) $(bfs_module_CFLAGS) $(CFLAGS) \
+ $(bfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am__biosdisk_module_SOURCES_DIST = disk/i386/pc/biosdisk.c
+@COND_i386_pc_TRUE@am_biosdisk_module_OBJECTS = disk/i386/pc/biosdisk_module-biosdisk.$(OBJEXT)
+nodist_biosdisk_module_OBJECTS =
+biosdisk_module_OBJECTS = $(am_biosdisk_module_OBJECTS) \
+ $(nodist_biosdisk_module_OBJECTS)
+biosdisk_module_LINK = $(CCLD) $(biosdisk_module_CFLAGS) $(CFLAGS) \
+ $(biosdisk_module_LDFLAGS) $(LDFLAGS) -o $@
+am_bitmap_module_OBJECTS = video/bitmap_module-bitmap.$(OBJEXT)
+nodist_bitmap_module_OBJECTS =
+bitmap_module_OBJECTS = $(am_bitmap_module_OBJECTS) \
+ $(nodist_bitmap_module_OBJECTS)
+bitmap_module_LINK = $(CCLD) $(bitmap_module_CFLAGS) $(CFLAGS) \
+ $(bitmap_module_LDFLAGS) $(LDFLAGS) -o $@
+am_bitmap_scale_module_OBJECTS = \
+ video/bitmap_scale_module-bitmap_scale.$(OBJEXT)
+nodist_bitmap_scale_module_OBJECTS =
+bitmap_scale_module_OBJECTS = $(am_bitmap_scale_module_OBJECTS) \
+ $(nodist_bitmap_scale_module_OBJECTS)
+bitmap_scale_module_LINK = $(CCLD) $(bitmap_scale_module_CFLAGS) \
+ $(CFLAGS) $(bitmap_scale_module_LDFLAGS) $(LDFLAGS) -o $@
+am_blocklist_module_OBJECTS = \
+ commands/blocklist_module-blocklist.$(OBJEXT)
+nodist_blocklist_module_OBJECTS =
+blocklist_module_OBJECTS = $(am_blocklist_module_OBJECTS) \
+ $(nodist_blocklist_module_OBJECTS)
+blocklist_module_LINK = $(CCLD) $(blocklist_module_CFLAGS) $(CFLAGS) \
+ $(blocklist_module_LDFLAGS) $(LDFLAGS) -o $@
+am__boot_image_SOURCES_DIST = boot/i386/pc/boot.S \
+ boot/i386/qemu/boot.S boot/sparc64/ieee1275/boot.S
+@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_sparc64_ieee1275_TRUE@am_boot_image_OBJECTS = boot/sparc64/ieee1275/boot_image-boot.$(OBJEXT)
+@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_boot_image_OBJECTS = boot/i386/qemu/boot_image-boot.$(OBJEXT)
+@COND_i386_pc_TRUE@am_boot_image_OBJECTS = \
+@COND_i386_pc_TRUE@ boot/i386/pc/boot_image-boot.$(OBJEXT)
+nodist_boot_image_OBJECTS =
+boot_image_OBJECTS = $(am_boot_image_OBJECTS) \
+ $(nodist_boot_image_OBJECTS)
+boot_image_DEPENDENCIES =
+boot_image_LINK = $(CCLD) $(boot_image_CFLAGS) $(CFLAGS) \
+ $(boot_image_LDFLAGS) $(LDFLAGS) -o $@
+am__boot_module_SOURCES_DIST = commands/boot.c lib/i386/pc/biosnum.c
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_boot_module_OBJECTS = lib/i386/pc/boot_module-biosnum.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@am_boot_module_OBJECTS = commands/boot_module-boot.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_boot_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ commands/boot_module-boot.$(OBJEXT)
+nodist_boot_module_OBJECTS =
+boot_module_OBJECTS = $(am_boot_module_OBJECTS) \
+ $(nodist_boot_module_OBJECTS)
+boot_module_LINK = $(CCLD) $(boot_module_CFLAGS) $(CFLAGS) \
+ $(boot_module_LDFLAGS) $(LDFLAGS) -o $@
+am__boot_hybrid_image_SOURCES_DIST = boot/i386/pc/boot.S
+@COND_i386_pc_TRUE@am_boot_hybrid_image_OBJECTS = boot/i386/pc/boot_hybrid_image-boot.$(OBJEXT)
+nodist_boot_hybrid_image_OBJECTS =
+boot_hybrid_image_OBJECTS = $(am_boot_hybrid_image_OBJECTS) \
+ $(nodist_boot_hybrid_image_OBJECTS)
+boot_hybrid_image_DEPENDENCIES =
+boot_hybrid_image_LINK = $(CCLD) $(boot_hybrid_image_CFLAGS) $(CFLAGS) \
+ $(boot_hybrid_image_LDFLAGS) $(LDFLAGS) -o $@
+am__boottime_module_SOURCES_DIST = commands/boottime.c
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@am_boottime_module_OBJECTS = commands/boottime_module-boottime.$(OBJEXT)
+nodist_boottime_module_OBJECTS =
+boottime_module_OBJECTS = $(am_boottime_module_OBJECTS) \
+ $(nodist_boottime_module_OBJECTS)
+boottime_module_LINK = $(CCLD) $(boottime_module_CFLAGS) $(CFLAGS) \
+ $(boottime_module_LDFLAGS) $(LDFLAGS) -o $@
+am__bsd_module_SOURCES_DIST = loader/i386/bsd.c loader/i386/bsd32.c \
+ loader/i386/bsd64.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_bsd_module_OBJECTS = loader/i386/bsd_module-bsd.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@ loader/i386/bsd_module-bsd32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@ loader/i386/bsd_module-bsd64.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_bsd_module_OBJECTS = loader/i386/bsd_module-bsd.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ loader/i386/bsd_module-bsd32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ loader/i386/bsd_module-bsd64.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_bsd_module_OBJECTS = loader/i386/bsd_module-bsd.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ loader/i386/bsd_module-bsd32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ loader/i386/bsd_module-bsd64.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_bsd_module_OBJECTS = loader/i386/bsd_module-bsd.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ loader/i386/bsd_module-bsd32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ loader/i386/bsd_module-bsd64.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_bsd_module_OBJECTS = loader/i386/bsd_module-bsd.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ loader/i386/bsd_module-bsd32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ loader/i386/bsd_module-bsd64.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_bsd_module_OBJECTS = loader/i386/bsd_module-bsd.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ loader/i386/bsd_module-bsd32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ loader/i386/bsd_module-bsd64.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_bsd_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ loader/i386/bsd_module-bsd.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ loader/i386/bsd_module-bsd32.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ loader/i386/bsd_module-bsd64.$(OBJEXT)
+nodist_bsd_module_OBJECTS =
+bsd_module_OBJECTS = $(am_bsd_module_OBJECTS) \
+ $(nodist_bsd_module_OBJECTS)
+bsd_module_LINK = $(CCLD) $(bsd_module_CFLAGS) $(CFLAGS) \
+ $(bsd_module_LDFLAGS) $(LDFLAGS) -o $@
+am_bswap_test_module_OBJECTS = \
+ tests/bswap_test_module-bswap_test.$(OBJEXT)
+nodist_bswap_test_module_OBJECTS =
+bswap_test_module_OBJECTS = $(am_bswap_test_module_OBJECTS) \
+ $(nodist_bswap_test_module_OBJECTS)
+bswap_test_module_LINK = $(CCLD) $(bswap_test_module_CFLAGS) $(CFLAGS) \
+ $(bswap_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am_btrfs_module_OBJECTS = fs/btrfs_module-btrfs.$(OBJEXT) \
+ lib/btrfs_module-crc.$(OBJEXT)
+nodist_btrfs_module_OBJECTS =
+btrfs_module_OBJECTS = $(am_btrfs_module_OBJECTS) \
+ $(nodist_btrfs_module_OBJECTS)
+btrfs_module_LINK = $(CCLD) $(btrfs_module_CFLAGS) $(CFLAGS) \
+ $(btrfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am__bufio_module_SOURCES_DIST = io/bufio.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_bufio_module_OBJECTS = io/bufio_module-bufio.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_bufio_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ io/bufio_module-bufio.$(OBJEXT)
+nodist_bufio_module_OBJECTS =
+bufio_module_OBJECTS = $(am_bufio_module_OBJECTS) \
+ $(nodist_bufio_module_OBJECTS)
+bufio_module_LINK = $(CCLD) $(bufio_module_CFLAGS) $(CFLAGS) \
+ $(bufio_module_LDFLAGS) $(LDFLAGS) -o $@
+am__cacheinfo_module_SOURCES_DIST = commands/cacheinfo.c
+@COND_ENABLE_CACHE_STATS_TRUE@am_cacheinfo_module_OBJECTS = commands/cacheinfo_module-cacheinfo.$(OBJEXT)
+nodist_cacheinfo_module_OBJECTS =
+cacheinfo_module_OBJECTS = $(am_cacheinfo_module_OBJECTS) \
+ $(nodist_cacheinfo_module_OBJECTS)
+cacheinfo_module_LINK = $(CCLD) $(cacheinfo_module_CFLAGS) $(CFLAGS) \
+ $(cacheinfo_module_LDFLAGS) $(LDFLAGS) -o $@
+am_cat_module_OBJECTS = commands/cat_module-cat.$(OBJEXT)
+nodist_cat_module_OBJECTS =
+cat_module_OBJECTS = $(am_cat_module_OBJECTS) \
+ $(nodist_cat_module_OBJECTS)
+cat_module_LINK = $(CCLD) $(cat_module_CFLAGS) $(CFLAGS) \
+ $(cat_module_LDFLAGS) $(LDFLAGS) -o $@
+am_cbfs_module_OBJECTS = fs/cbfs_module-cbfs.$(OBJEXT)
+nodist_cbfs_module_OBJECTS =
+cbfs_module_OBJECTS = $(am_cbfs_module_OBJECTS) \
+ $(nodist_cbfs_module_OBJECTS)
+cbfs_module_LINK = $(CCLD) $(cbfs_module_CFLAGS) $(CFLAGS) \
+ $(cbfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am__cbls_module_SOURCES_DIST = commands/i386/coreboot/cbls.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_cbls_module_OBJECTS = commands/i386/coreboot/cbls_module-cbls.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_cbls_module_OBJECTS = commands/i386/coreboot/cbls_module-cbls.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_cbls_module_OBJECTS = commands/i386/coreboot/cbls_module-cbls.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_cbls_module_OBJECTS = commands/i386/coreboot/cbls_module-cbls.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_cbls_module_OBJECTS = commands/i386/coreboot/cbls_module-cbls.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_cbls_module_OBJECTS = commands/i386/coreboot/cbls_module-cbls.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_cbls_module_OBJECTS = commands/i386/coreboot/cbls_module-cbls.$(OBJEXT)
+nodist_cbls_module_OBJECTS =
+cbls_module_OBJECTS = $(am_cbls_module_OBJECTS) \
+ $(nodist_cbls_module_OBJECTS)
+cbls_module_LINK = $(CCLD) $(cbls_module_CFLAGS) $(CFLAGS) \
+ $(cbls_module_LDFLAGS) $(LDFLAGS) -o $@
+am__cbmemc_module_SOURCES_DIST = term/i386/coreboot/cbmemc.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_cbmemc_module_OBJECTS = term/i386/coreboot/cbmemc_module-cbmemc.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_cbmemc_module_OBJECTS = term/i386/coreboot/cbmemc_module-cbmemc.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_cbmemc_module_OBJECTS = term/i386/coreboot/cbmemc_module-cbmemc.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_cbmemc_module_OBJECTS = term/i386/coreboot/cbmemc_module-cbmemc.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_cbmemc_module_OBJECTS = term/i386/coreboot/cbmemc_module-cbmemc.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_cbmemc_module_OBJECTS = term/i386/coreboot/cbmemc_module-cbmemc.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_cbmemc_module_OBJECTS = term/i386/coreboot/cbmemc_module-cbmemc.$(OBJEXT)
+nodist_cbmemc_module_OBJECTS =
+cbmemc_module_OBJECTS = $(am_cbmemc_module_OBJECTS) \
+ $(nodist_cbmemc_module_OBJECTS)
+cbmemc_module_LINK = $(CCLD) $(cbmemc_module_CFLAGS) $(CFLAGS) \
+ $(cbmemc_module_LDFLAGS) $(LDFLAGS) -o $@
+am__cbtable_module_SOURCES_DIST = kern/i386/coreboot/cbtable.c \
+ kern/coreboot/cbtable.c
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_cbtable_module_OBJECTS = kern/i386/coreboot/cbtable_module-cbtable.$(OBJEXT) \
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@ kern/coreboot/cbtable_module-cbtable.$(OBJEXT)
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_cbtable_module_OBJECTS = kern/i386/coreboot/cbtable_module-cbtable.$(OBJEXT) \
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/coreboot/cbtable_module-cbtable.$(OBJEXT)
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_cbtable_module_OBJECTS = kern/i386/coreboot/cbtable_module-cbtable.$(OBJEXT) \
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/coreboot/cbtable_module-cbtable.$(OBJEXT)
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_cbtable_module_OBJECTS = kern/i386/coreboot/cbtable_module-cbtable.$(OBJEXT) \
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/coreboot/cbtable_module-cbtable.$(OBJEXT)
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_cbtable_module_OBJECTS = kern/i386/coreboot/cbtable_module-cbtable.$(OBJEXT) \
+@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/coreboot/cbtable_module-cbtable.$(OBJEXT)
+@COND_i386_efi_TRUE@am_cbtable_module_OBJECTS = kern/i386/coreboot/cbtable_module-cbtable.$(OBJEXT) \
+@COND_i386_efi_TRUE@ kern/coreboot/cbtable_module-cbtable.$(OBJEXT)
+nodist_cbtable_module_OBJECTS =
+cbtable_module_OBJECTS = $(am_cbtable_module_OBJECTS) \
+ $(nodist_cbtable_module_OBJECTS)
+cbtable_module_LINK = $(CCLD) $(cbtable_module_CFLAGS) $(CFLAGS) \
+ $(cbtable_module_LDFLAGS) $(LDFLAGS) -o $@
+am__cbtime_module_SOURCES_DIST = \
+ commands/i386/coreboot/cb_timestamps.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_cbtime_module_OBJECTS = commands/i386/coreboot/cbtime_module-cb_timestamps.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_cbtime_module_OBJECTS = commands/i386/coreboot/cbtime_module-cb_timestamps.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_cbtime_module_OBJECTS = commands/i386/coreboot/cbtime_module-cb_timestamps.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_cbtime_module_OBJECTS = commands/i386/coreboot/cbtime_module-cb_timestamps.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_cbtime_module_OBJECTS = commands/i386/coreboot/cbtime_module-cb_timestamps.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_cbtime_module_OBJECTS = commands/i386/coreboot/cbtime_module-cb_timestamps.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_cbtime_module_OBJECTS = commands/i386/coreboot/cbtime_module-cb_timestamps.$(OBJEXT)
+nodist_cbtime_module_OBJECTS =
+cbtime_module_OBJECTS = $(am_cbtime_module_OBJECTS) \
+ $(nodist_cbtime_module_OBJECTS)
+cbtime_module_LINK = $(CCLD) $(cbtime_module_CFLAGS) $(CFLAGS) \
+ $(cbtime_module_LDFLAGS) $(LDFLAGS) -o $@
+am__cdboot_image_SOURCES_DIST = boot/i386/pc/cdboot.S \
+ boot/sparc64/ieee1275/boot.S
+@COND_i386_pc_FALSE@@COND_sparc64_ieee1275_TRUE@am_cdboot_image_OBJECTS = boot/sparc64/ieee1275/cdboot_image-boot.$(OBJEXT)
+@COND_i386_pc_TRUE@am_cdboot_image_OBJECTS = \
+@COND_i386_pc_TRUE@ boot/i386/pc/cdboot_image-cdboot.$(OBJEXT)
+nodist_cdboot_image_OBJECTS =
+cdboot_image_OBJECTS = $(am_cdboot_image_OBJECTS) \
+ $(nodist_cdboot_image_OBJECTS)
+cdboot_image_DEPENDENCIES =
+cdboot_image_LINK = $(CCLD) $(cdboot_image_CFLAGS) $(CFLAGS) \
+ $(cdboot_image_LDFLAGS) $(LDFLAGS) -o $@
+am__chain_module_SOURCES_DIST = loader/efi/chainloader.c \
+ loader/i386/coreboot/chainloader.c lib/LzmaDec.c \
+ loader/i386/pc/chainloader.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_chain_module_OBJECTS = loader/efi/chain_module-chainloader.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_chain_module_OBJECTS = loader/efi/chain_module-chainloader.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_chain_module_OBJECTS = loader/efi/chain_module-chainloader.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_TRUE@am_chain_module_OBJECTS = loader/efi/chain_module-chainloader.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_TRUE@am_chain_module_OBJECTS = loader/i386/pc/chain_module-chainloader.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_chain_module_OBJECTS = loader/efi/chain_module-chainloader.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@am_chain_module_OBJECTS = loader/i386/coreboot/chain_module-chainloader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@ lib/chain_module-LzmaDec.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_chain_module_OBJECTS = loader/efi/chain_module-chainloader.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_chain_module_OBJECTS = loader/efi/chain_module-chainloader.$(OBJEXT)
+nodist_chain_module_OBJECTS =
+chain_module_OBJECTS = $(am_chain_module_OBJECTS) \
+ $(nodist_chain_module_OBJECTS)
+chain_module_LINK = $(CCLD) $(chain_module_CFLAGS) $(CFLAGS) \
+ $(chain_module_LDFLAGS) $(LDFLAGS) -o $@
+am_cmdline_cat_test_module_OBJECTS = \
+ tests/cmdline_cat_test_module-cmdline_cat_test.$(OBJEXT)
+nodist_cmdline_cat_test_module_OBJECTS =
+cmdline_cat_test_module_OBJECTS = \
+ $(am_cmdline_cat_test_module_OBJECTS) \
+ $(nodist_cmdline_cat_test_module_OBJECTS)
+cmdline_cat_test_module_LINK = $(CCLD) \
+ $(cmdline_cat_test_module_CFLAGS) $(CFLAGS) \
+ $(cmdline_cat_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am__cmosdump_module_SOURCES_DIST = commands/i386/cmosdump.c
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_sparc64_ieee1275_TRUE@am_cmosdump_module_OBJECTS = commands/i386/cmosdump_module-cmosdump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_cmosdump_module_OBJECTS = commands/i386/cmosdump_module-cmosdump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_cmosdump_module_OBJECTS = commands/i386/cmosdump_module-cmosdump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_cmosdump_module_OBJECTS = commands/i386/cmosdump_module-cmosdump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_cmosdump_module_OBJECTS = commands/i386/cmosdump_module-cmosdump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_cmosdump_module_OBJECTS = commands/i386/cmosdump_module-cmosdump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_cmosdump_module_OBJECTS = commands/i386/cmosdump_module-cmosdump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@am_cmosdump_module_OBJECTS = commands/i386/cmosdump_module-cmosdump.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_cmosdump_module_OBJECTS = commands/i386/cmosdump_module-cmosdump.$(OBJEXT)
+nodist_cmosdump_module_OBJECTS =
+cmosdump_module_OBJECTS = $(am_cmosdump_module_OBJECTS) \
+ $(nodist_cmosdump_module_OBJECTS)
+cmosdump_module_LINK = $(CCLD) $(cmosdump_module_CFLAGS) $(CFLAGS) \
+ $(cmosdump_module_LDFLAGS) $(LDFLAGS) -o $@
+am__cmostest_module_SOURCES_DIST = commands/i386/cmostest.c
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_sparc64_ieee1275_TRUE@am_cmostest_module_OBJECTS = commands/i386/cmostest_module-cmostest.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_cmostest_module_OBJECTS = commands/i386/cmostest_module-cmostest.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_cmostest_module_OBJECTS = commands/i386/cmostest_module-cmostest.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_cmostest_module_OBJECTS = commands/i386/cmostest_module-cmostest.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_cmostest_module_OBJECTS = commands/i386/cmostest_module-cmostest.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_cmostest_module_OBJECTS = commands/i386/cmostest_module-cmostest.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_cmostest_module_OBJECTS = commands/i386/cmostest_module-cmostest.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@am_cmostest_module_OBJECTS = commands/i386/cmostest_module-cmostest.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_cmostest_module_OBJECTS = commands/i386/cmostest_module-cmostest.$(OBJEXT)
+nodist_cmostest_module_OBJECTS =
+cmostest_module_OBJECTS = $(am_cmostest_module_OBJECTS) \
+ $(nodist_cmostest_module_OBJECTS)
+cmostest_module_LINK = $(CCLD) $(cmostest_module_CFLAGS) $(CFLAGS) \
+ $(cmostest_module_LDFLAGS) $(LDFLAGS) -o $@
+am_cmp_module_OBJECTS = commands/cmp_module-cmp.$(OBJEXT)
+nodist_cmp_module_OBJECTS =
+cmp_module_OBJECTS = $(am_cmp_module_OBJECTS) \
+ $(nodist_cmp_module_OBJECTS)
+cmp_module_LINK = $(CCLD) $(cmp_module_CFLAGS) $(CFLAGS) \
+ $(cmp_module_LDFLAGS) $(LDFLAGS) -o $@
+am_cmp_test_module_OBJECTS = tests/cmp_test_module-cmp_test.$(OBJEXT)
+nodist_cmp_test_module_OBJECTS =
+cmp_test_module_OBJECTS = $(am_cmp_test_module_OBJECTS) \
+ $(nodist_cmp_test_module_OBJECTS)
+cmp_test_module_LINK = $(CCLD) $(cmp_test_module_CFLAGS) $(CFLAGS) \
+ $(cmp_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am_configfile_module_OBJECTS = \
+ commands/configfile_module-configfile.$(OBJEXT)
+nodist_configfile_module_OBJECTS =
+configfile_module_OBJECTS = $(am_configfile_module_OBJECTS) \
+ $(nodist_configfile_module_OBJECTS)
+configfile_module_LINK = $(CCLD) $(configfile_module_CFLAGS) $(CFLAGS) \
+ $(configfile_module_LDFLAGS) $(LDFLAGS) -o $@
+am_cpio_module_OBJECTS = fs/cpio_module-cpio.$(OBJEXT)
+nodist_cpio_module_OBJECTS =
+cpio_module_OBJECTS = $(am_cpio_module_OBJECTS) \
+ $(nodist_cpio_module_OBJECTS)
+cpio_module_LINK = $(CCLD) $(cpio_module_CFLAGS) $(CFLAGS) \
+ $(cpio_module_LDFLAGS) $(LDFLAGS) -o $@
+am_cpio_be_module_OBJECTS = fs/cpio_be_module-cpio_be.$(OBJEXT)
+nodist_cpio_be_module_OBJECTS =
+cpio_be_module_OBJECTS = $(am_cpio_be_module_OBJECTS) \
+ $(nodist_cpio_be_module_OBJECTS)
+cpio_be_module_LINK = $(CCLD) $(cpio_be_module_CFLAGS) $(CFLAGS) \
+ $(cpio_be_module_LDFLAGS) $(LDFLAGS) -o $@
+am__cpuid_module_SOURCES_DIST = commands/i386/cpuid.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_cpuid_module_OBJECTS = commands/i386/cpuid_module-cpuid.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_TRUE@am_cpuid_module_OBJECTS = commands/i386/cpuid_module-cpuid.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_cpuid_module_OBJECTS = commands/i386/cpuid_module-cpuid.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_cpuid_module_OBJECTS = commands/i386/cpuid_module-cpuid.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_cpuid_module_OBJECTS = commands/i386/cpuid_module-cpuid.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_cpuid_module_OBJECTS = commands/i386/cpuid_module-cpuid.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_cpuid_module_OBJECTS = commands/i386/cpuid_module-cpuid.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_cpuid_module_OBJECTS = commands/i386/cpuid_module-cpuid.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_cpuid_module_OBJECTS = commands/i386/cpuid_module-cpuid.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_cpuid_module_OBJECTS = commands/i386/cpuid_module-cpuid.$(OBJEXT)
+nodist_cpuid_module_OBJECTS =
+cpuid_module_OBJECTS = $(am_cpuid_module_OBJECTS) \
+ $(nodist_cpuid_module_OBJECTS)
+cpuid_module_LINK = $(CCLD) $(cpuid_module_CFLAGS) $(CFLAGS) \
+ $(cpuid_module_LDFLAGS) $(LDFLAGS) -o $@
+am_crc64_module_OBJECTS = lib/crc64_module-crc64.$(OBJEXT)
+nodist_crc64_module_OBJECTS =
+crc64_module_OBJECTS = $(am_crc64_module_OBJECTS) \
+ $(nodist_crc64_module_OBJECTS)
+crc64_module_LINK = $(CCLD) $(crc64_module_CFLAGS) $(CFLAGS) \
+ $(crc64_module_LDFLAGS) $(LDFLAGS) -o $@
+am_crypto_module_OBJECTS = lib/crypto_module-crypto.$(OBJEXT)
+nodist_crypto_module_OBJECTS =
+crypto_module_OBJECTS = $(am_crypto_module_OBJECTS) \
+ $(nodist_crypto_module_OBJECTS)
+crypto_module_LINK = $(CCLD) $(crypto_module_CFLAGS) $(CFLAGS) \
+ $(crypto_module_LDFLAGS) $(LDFLAGS) -o $@
+am_cryptodisk_module_OBJECTS = \
+ disk/cryptodisk_module-cryptodisk.$(OBJEXT)
+nodist_cryptodisk_module_OBJECTS =
+cryptodisk_module_OBJECTS = $(am_cryptodisk_module_OBJECTS) \
+ $(nodist_cryptodisk_module_OBJECTS)
+cryptodisk_module_LINK = $(CCLD) $(cryptodisk_module_CFLAGS) $(CFLAGS) \
+ $(cryptodisk_module_LDFLAGS) $(LDFLAGS) -o $@
+am__cs5536_module_SOURCES_DIST = bus/cs5536.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_cs5536_module_OBJECTS = bus/cs5536_module-cs5536.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_cs5536_module_OBJECTS = bus/cs5536_module-cs5536.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_cs5536_module_OBJECTS = bus/cs5536_module-cs5536.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_cs5536_module_OBJECTS = bus/cs5536_module-cs5536.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_cs5536_module_OBJECTS = bus/cs5536_module-cs5536.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_cs5536_module_OBJECTS = bus/cs5536_module-cs5536.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_cs5536_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ bus/cs5536_module-cs5536.$(OBJEXT)
+nodist_cs5536_module_OBJECTS =
+cs5536_module_OBJECTS = $(am_cs5536_module_OBJECTS) \
+ $(nodist_cs5536_module_OBJECTS)
+cs5536_module_LINK = $(CCLD) $(cs5536_module_CFLAGS) $(CFLAGS) \
+ $(cs5536_module_LDFLAGS) $(LDFLAGS) -o $@
+am_ctz_test_module_OBJECTS = tests/ctz_test_module-ctz_test.$(OBJEXT)
+nodist_ctz_test_module_OBJECTS =
+ctz_test_module_OBJECTS = $(am_ctz_test_module_OBJECTS) \
+ $(nodist_ctz_test_module_OBJECTS)
+ctz_test_module_LINK = $(CCLD) $(ctz_test_module_CFLAGS) $(CFLAGS) \
+ $(ctz_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am_date_module_OBJECTS = commands/date_module-date.$(OBJEXT)
+nodist_date_module_OBJECTS =
+date_module_OBJECTS = $(am_date_module_OBJECTS) \
+ $(nodist_date_module_OBJECTS)
+date_module_LINK = $(CCLD) $(date_module_CFLAGS) $(CFLAGS) \
+ $(date_module_LDFLAGS) $(LDFLAGS) -o $@
+am_datehook_module_OBJECTS = hook/datehook_module-datehook.$(OBJEXT)
+nodist_datehook_module_OBJECTS =
+datehook_module_OBJECTS = $(am_datehook_module_OBJECTS) \
+ $(nodist_datehook_module_OBJECTS)
+datehook_module_LINK = $(CCLD) $(datehook_module_CFLAGS) $(CFLAGS) \
+ $(datehook_module_LDFLAGS) $(LDFLAGS) -o $@
+am__datetime_module_SOURCES_DIST = lib/efi/datetime.c lib/datetime.c \
+ lib/dummy/datetime.c lib/cmos_datetime.c lib/xen/datetime.c \
+ lib/arc/datetime.c lib/ieee1275/datetime.c lib/ieee1275/cmos.c
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_datetime_module_OBJECTS = lib/xen/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_datetime_module_OBJECTS = lib/efi/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_datetime_module_OBJECTS = lib/ieee1275/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ lib/ieee1275/datetime_module-cmos.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ lib/datetime_module-cmos_datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_datetime_module_OBJECTS = lib/efi/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_datetime_module_OBJECTS = lib/efi/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_datetime_module_OBJECTS = lib/ieee1275/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ lib/ieee1275/datetime_module-cmos.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ lib/datetime_module-cmos_datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_datetime_module_OBJECTS = lib/datetime_module-cmos_datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_datetime_module_OBJECTS = lib/datetime_module-cmos_datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_datetime_module_OBJECTS = lib/arc/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_datetime_module_OBJECTS = lib/efi/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_datetime_module_OBJECTS = lib/xen/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_datetime_module_OBJECTS = lib/xen/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_datetime_module_OBJECTS = lib/datetime_module-cmos_datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_datetime_module_OBJECTS = lib/datetime_module-cmos_datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_datetime_module_OBJECTS = lib/datetime_module-cmos_datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_datetime_module_OBJECTS = lib/datetime_module-cmos_datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_datetime_module_OBJECTS = lib/efi/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@am_datetime_module_OBJECTS = lib/datetime_module-cmos_datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@am_datetime_module_OBJECTS = lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_datetime_module_OBJECTS = lib/dummy/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@am_datetime_module_OBJECTS = lib/efi/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@am_datetime_module_OBJECTS = lib/dummy/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_datetime_module_OBJECTS = lib/efi/datetime_module-datetime.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ lib/datetime_module-datetime.$(OBJEXT)
+nodist_datetime_module_OBJECTS =
+datetime_module_OBJECTS = $(am_datetime_module_OBJECTS) \
+ $(nodist_datetime_module_OBJECTS)
+datetime_module_LINK = $(CCLD) $(datetime_module_CFLAGS) $(CFLAGS) \
+ $(datetime_module_LDFLAGS) $(LDFLAGS) -o $@
+am_disk_module_OBJECTS = lib/disk_module-disk.$(OBJEXT)
+nodist_disk_module_OBJECTS =
+disk_module_OBJECTS = $(am_disk_module_OBJECTS) \
+ $(nodist_disk_module_OBJECTS)
+disk_module_LINK = $(CCLD) $(disk_module_CFLAGS) $(CFLAGS) \
+ $(disk_module_LDFLAGS) $(LDFLAGS) -o $@
+am__diskboot_image_SOURCES_DIST = boot/i386/pc/diskboot.S \
+ boot/sparc64/ieee1275/diskboot.S
+@COND_i386_pc_FALSE@@COND_sparc64_ieee1275_TRUE@am_diskboot_image_OBJECTS = boot/sparc64/ieee1275/diskboot_image-diskboot.$(OBJEXT)
+@COND_i386_pc_TRUE@am_diskboot_image_OBJECTS = boot/i386/pc/diskboot_image-diskboot.$(OBJEXT)
+nodist_diskboot_image_OBJECTS =
+diskboot_image_OBJECTS = $(am_diskboot_image_OBJECTS) \
+ $(nodist_diskboot_image_OBJECTS)
+diskboot_image_DEPENDENCIES =
+diskboot_image_LINK = $(CCLD) $(diskboot_image_CFLAGS) $(CFLAGS) \
+ $(diskboot_image_LDFLAGS) $(LDFLAGS) -o $@
+am_diskfilter_module_OBJECTS = \
+ disk/diskfilter_module-diskfilter.$(OBJEXT)
+nodist_diskfilter_module_OBJECTS =
+diskfilter_module_OBJECTS = $(am_diskfilter_module_OBJECTS) \
+ $(nodist_diskfilter_module_OBJECTS)
+diskfilter_module_LINK = $(CCLD) $(diskfilter_module_CFLAGS) $(CFLAGS) \
+ $(diskfilter_module_LDFLAGS) $(LDFLAGS) -o $@
+am__div_module_SOURCES_DIST = lib/division.c
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv64_efi_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_emu_TRUE@am_div_module_OBJECTS = lib/div_module-division.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_div_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ lib/div_module-division.$(OBJEXT)
+nodist_div_module_OBJECTS =
+div_module_OBJECTS = $(am_div_module_OBJECTS) \
+ $(nodist_div_module_OBJECTS)
+div_module_LINK = $(CCLD) $(div_module_CFLAGS) $(CFLAGS) \
+ $(div_module_LDFLAGS) $(LDFLAGS) -o $@
+am_div_test_module_OBJECTS = tests/div_test_module-div_test.$(OBJEXT)
+nodist_div_test_module_OBJECTS =
+div_test_module_OBJECTS = $(am_div_test_module_OBJECTS) \
+ $(nodist_div_test_module_OBJECTS)
+div_test_module_LINK = $(CCLD) $(div_test_module_CFLAGS) $(CFLAGS) \
+ $(div_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am_dm_nv_module_OBJECTS = disk/dm_nv_module-dmraid_nvidia.$(OBJEXT)
+nodist_dm_nv_module_OBJECTS =
+dm_nv_module_OBJECTS = $(am_dm_nv_module_OBJECTS) \
+ $(nodist_dm_nv_module_OBJECTS)
+dm_nv_module_LINK = $(CCLD) $(dm_nv_module_CFLAGS) $(CFLAGS) \
+ $(dm_nv_module_LDFLAGS) $(LDFLAGS) -o $@
+am__drivemap_module_SOURCES_DIST = commands/i386/pc/drivemap.c \
+ commands/i386/pc/drivemap_int13h.S
+@COND_i386_pc_TRUE@am_drivemap_module_OBJECTS = commands/i386/pc/drivemap_module-drivemap.$(OBJEXT) \
+@COND_i386_pc_TRUE@ commands/i386/pc/drivemap_module-drivemap_int13h.$(OBJEXT)
+nodist_drivemap_module_OBJECTS =
+drivemap_module_OBJECTS = $(am_drivemap_module_OBJECTS) \
+ $(nodist_drivemap_module_OBJECTS)
+drivemap_module_LINK = $(CCLD) $(drivemap_module_CFLAGS) $(CFLAGS) \
+ $(drivemap_module_LDFLAGS) $(LDFLAGS) -o $@
+am_echo_module_OBJECTS = commands/echo_module-echo.$(OBJEXT)
+nodist_echo_module_OBJECTS =
+echo_module_OBJECTS = $(am_echo_module_OBJECTS) \
+ $(nodist_echo_module_OBJECTS)
+echo_module_LINK = $(CCLD) $(echo_module_CFLAGS) $(CFLAGS) \
+ $(echo_module_LDFLAGS) $(LDFLAGS) -o $@
+am__efi_gop_module_SOURCES_DIST = video/efi_gop.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_efi_gop_module_OBJECTS = video/efi_gop_module-efi_gop.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_efi_gop_module_OBJECTS = video/efi_gop_module-efi_gop.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_efi_gop_module_OBJECTS = video/efi_gop_module-efi_gop.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_TRUE@am_efi_gop_module_OBJECTS = video/efi_gop_module-efi_gop.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_TRUE@am_efi_gop_module_OBJECTS = video/efi_gop_module-efi_gop.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_efi_gop_module_OBJECTS = video/efi_gop_module-efi_gop.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_efi_gop_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ video/efi_gop_module-efi_gop.$(OBJEXT)
+nodist_efi_gop_module_OBJECTS =
+efi_gop_module_OBJECTS = $(am_efi_gop_module_OBJECTS) \
+ $(nodist_efi_gop_module_OBJECTS)
+efi_gop_module_LINK = $(CCLD) $(efi_gop_module_CFLAGS) $(CFLAGS) \
+ $(efi_gop_module_LDFLAGS) $(LDFLAGS) -o $@
+am__efi_uga_module_SOURCES_DIST = video/efi_uga.c
+@COND_i386_efi_FALSE@@COND_x86_64_efi_TRUE@am_efi_uga_module_OBJECTS = video/efi_uga_module-efi_uga.$(OBJEXT)
+@COND_i386_efi_TRUE@am_efi_uga_module_OBJECTS = \
+@COND_i386_efi_TRUE@ video/efi_uga_module-efi_uga.$(OBJEXT)
+nodist_efi_uga_module_OBJECTS =
+efi_uga_module_OBJECTS = $(am_efi_uga_module_OBJECTS) \
+ $(nodist_efi_uga_module_OBJECTS)
+efi_uga_module_LINK = $(CCLD) $(efi_uga_module_CFLAGS) $(CFLAGS) \
+ $(efi_uga_module_LDFLAGS) $(LDFLAGS) -o $@
+am__efiemu_module_SOURCES_DIST = efiemu/i386/pc/cfgtables.c \
+ efiemu/main.c efiemu/i386/loadcore32.c \
+ efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c \
+ efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c \
+ efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c \
+ efiemu/i386/coredetect.c efiemu/i386/nocfgtables.c
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_efiemu_module_OBJECTS = efiemu/i386/efiemu_module-nocfgtables.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/efiemu_module-main.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/i386/efiemu_module-loadcore32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/i386/efiemu_module-loadcore64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/efiemu_module-mm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/efiemu_module-loadcore_common.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/efiemu_module-symbols.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/efiemu_module-loadcore32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/efiemu_module-loadcore64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/efiemu_module-prepare32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/efiemu_module-prepare64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/efiemu_module-pnvram.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ efiemu/i386/efiemu_module-coredetect.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_efiemu_module_OBJECTS = efiemu/i386/pc/efiemu_module-cfgtables.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/efiemu_module-main.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/i386/efiemu_module-loadcore32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/i386/efiemu_module-loadcore64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/efiemu_module-mm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/efiemu_module-loadcore_common.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/efiemu_module-symbols.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/efiemu_module-loadcore32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/efiemu_module-loadcore64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/efiemu_module-prepare32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/efiemu_module-prepare64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/efiemu_module-pnvram.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ efiemu/i386/efiemu_module-coredetect.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_efiemu_module_OBJECTS = efiemu/i386/pc/efiemu_module-cfgtables.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/efiemu_module-main.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/i386/efiemu_module-loadcore32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/i386/efiemu_module-loadcore64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/efiemu_module-mm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/efiemu_module-loadcore_common.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/efiemu_module-symbols.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/efiemu_module-loadcore32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/efiemu_module-loadcore64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/efiemu_module-prepare32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/efiemu_module-prepare64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/efiemu_module-pnvram.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ efiemu/i386/efiemu_module-coredetect.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@am_efiemu_module_OBJECTS = efiemu/i386/efiemu_module-nocfgtables.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/efiemu_module-main.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/i386/efiemu_module-loadcore32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/i386/efiemu_module-loadcore64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/efiemu_module-mm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/efiemu_module-loadcore_common.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/efiemu_module-symbols.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/efiemu_module-loadcore32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/efiemu_module-loadcore64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/efiemu_module-prepare32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/efiemu_module-prepare64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/efiemu_module-pnvram.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ efiemu/i386/efiemu_module-coredetect.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_efiemu_module_OBJECTS = efiemu/i386/pc/efiemu_module-cfgtables.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/efiemu_module-main.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/i386/efiemu_module-loadcore32.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/i386/efiemu_module-loadcore64.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/efiemu_module-mm.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/efiemu_module-loadcore_common.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/efiemu_module-symbols.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/efiemu_module-loadcore32.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/efiemu_module-loadcore64.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/efiemu_module-prepare32.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/efiemu_module-prepare64.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/efiemu_module-pnvram.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ efiemu/i386/efiemu_module-coredetect.$(OBJEXT)
+nodist_efiemu_module_OBJECTS =
+efiemu_module_OBJECTS = $(am_efiemu_module_OBJECTS) \
+ $(nodist_efiemu_module_OBJECTS)
+efiemu_module_LINK = $(CCLD) $(efiemu_module_CFLAGS) $(CFLAGS) \
+ $(efiemu_module_LDFLAGS) $(LDFLAGS) -o $@
+am__efifwsetup_module_SOURCES_DIST = commands/efi/efifwsetup.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_efifwsetup_module_OBJECTS = commands/efi/efifwsetup_module-efifwsetup.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_efifwsetup_module_OBJECTS = commands/efi/efifwsetup_module-efifwsetup.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_efifwsetup_module_OBJECTS = commands/efi/efifwsetup_module-efifwsetup.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_TRUE@am_efifwsetup_module_OBJECTS = commands/efi/efifwsetup_module-efifwsetup.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_TRUE@am_efifwsetup_module_OBJECTS = commands/efi/efifwsetup_module-efifwsetup.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_efifwsetup_module_OBJECTS = commands/efi/efifwsetup_module-efifwsetup.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_efifwsetup_module_OBJECTS = commands/efi/efifwsetup_module-efifwsetup.$(OBJEXT)
+nodist_efifwsetup_module_OBJECTS =
+efifwsetup_module_OBJECTS = $(am_efifwsetup_module_OBJECTS) \
+ $(nodist_efifwsetup_module_OBJECTS)
+efifwsetup_module_LINK = $(CCLD) $(efifwsetup_module_CFLAGS) $(CFLAGS) \
+ $(efifwsetup_module_LDFLAGS) $(LDFLAGS) -o $@
+am__efinet_module_SOURCES_DIST = net/drivers/efi/efinet.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_efinet_module_OBJECTS = net/drivers/efi/efinet_module-efinet.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_efinet_module_OBJECTS = net/drivers/efi/efinet_module-efinet.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_efinet_module_OBJECTS = net/drivers/efi/efinet_module-efinet.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_TRUE@am_efinet_module_OBJECTS = net/drivers/efi/efinet_module-efinet.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_TRUE@am_efinet_module_OBJECTS = net/drivers/efi/efinet_module-efinet.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_efinet_module_OBJECTS = net/drivers/efi/efinet_module-efinet.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_efinet_module_OBJECTS = net/drivers/efi/efinet_module-efinet.$(OBJEXT)
+nodist_efinet_module_OBJECTS =
+efinet_module_OBJECTS = $(am_efinet_module_OBJECTS) \
+ $(nodist_efinet_module_OBJECTS)
+efinet_module_LINK = $(CCLD) $(efinet_module_CFLAGS) $(CFLAGS) \
+ $(efinet_module_LDFLAGS) $(LDFLAGS) -o $@
+am__ehci_module_SOURCES_DIST = bus/usb/ehci-fdt.c bus/usb/ehci.c \
+ bus/usb/ehci-pci.c
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_ehci_module_OBJECTS = bus/usb/ehci_module-ehci-pci.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@ bus/usb/ehci_module-ehci.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_ehci_module_OBJECTS = bus/usb/ehci_module-ehci-pci.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@ bus/usb/ehci_module-ehci.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_ehci_module_OBJECTS = bus/usb/ehci_module-ehci-pci.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ bus/usb/ehci_module-ehci.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_ehci_module_OBJECTS = bus/usb/ehci_module-ehci-pci.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ bus/usb/ehci_module-ehci.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_ehci_module_OBJECTS = bus/usb/ehci_module-ehci-pci.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ bus/usb/ehci_module-ehci.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_ehci_module_OBJECTS = bus/usb/ehci_module-ehci-pci.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ bus/usb/ehci_module-ehci.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_ehci_module_OBJECTS = bus/usb/ehci_module-ehci-pci.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ bus/usb/ehci_module-ehci.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@am_ehci_module_OBJECTS = bus/usb/ehci_module-ehci-pci.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@ bus/usb/ehci_module-ehci.$(OBJEXT)
+@COND_arm_coreboot_TRUE@am_ehci_module_OBJECTS = bus/usb/ehci_module-ehci-fdt.$(OBJEXT) \
+@COND_arm_coreboot_TRUE@ bus/usb/ehci_module-ehci.$(OBJEXT)
+nodist_ehci_module_OBJECTS =
+ehci_module_OBJECTS = $(am_ehci_module_OBJECTS) \
+ $(nodist_ehci_module_OBJECTS)
+ehci_module_LINK = $(CCLD) $(ehci_module_CFLAGS) $(CFLAGS) \
+ $(ehci_module_LDFLAGS) $(LDFLAGS) -o $@
+am_elf_module_OBJECTS = kern/elf_module-elf.$(OBJEXT)
+nodist_elf_module_OBJECTS =
+elf_module_OBJECTS = $(am_elf_module_OBJECTS) \
+ $(nodist_elf_module_OBJECTS)
+elf_module_LINK = $(CCLD) $(elf_module_CFLAGS) $(CFLAGS) \
+ $(elf_module_LDFLAGS) $(LDFLAGS) -o $@
+am__emunet_module_SOURCES_DIST = net/drivers/emu/emunet.c
+@COND_emu_TRUE@am_emunet_module_OBJECTS = \
+@COND_emu_TRUE@ net/drivers/emu/emunet_module-emunet.$(OBJEXT)
+nodist_emunet_module_OBJECTS =
+emunet_module_OBJECTS = $(am_emunet_module_OBJECTS) \
+ $(nodist_emunet_module_OBJECTS)
+emunet_module_LINK = $(CCLD) $(emunet_module_CFLAGS) $(CFLAGS) \
+ $(emunet_module_LDFLAGS) $(LDFLAGS) -o $@
+am__emupci_module_SOURCES_DIST = bus/emu/pci.c commands/lspci.c
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@am_emupci_module_OBJECTS = bus/emu/emupci_module-pci.$(OBJEXT) \
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@ commands/emupci_module-lspci.$(OBJEXT)
+nodist_emupci_module_OBJECTS =
+emupci_module_OBJECTS = $(am_emupci_module_OBJECTS) \
+ $(nodist_emupci_module_OBJECTS)
+emupci_module_LINK = $(CCLD) $(emupci_module_CFLAGS) $(CFLAGS) \
+ $(emupci_module_LDFLAGS) $(LDFLAGS) -o $@
+am__escc_module_SOURCES_DIST = term/ieee1275/escc.c
+@COND_powerpc_ieee1275_TRUE@am_escc_module_OBJECTS = term/ieee1275/escc_module-escc.$(OBJEXT)
+nodist_escc_module_OBJECTS =
+escc_module_OBJECTS = $(am_escc_module_OBJECTS) \
+ $(nodist_escc_module_OBJECTS)
+escc_module_LINK = $(CCLD) $(escc_module_CFLAGS) $(CFLAGS) \
+ $(escc_module_LDFLAGS) $(LDFLAGS) -o $@
+am_eval_module_OBJECTS = commands/eval_module-eval.$(OBJEXT)
+nodist_eval_module_OBJECTS =
+eval_module_OBJECTS = $(am_eval_module_OBJECTS) \
+ $(nodist_eval_module_OBJECTS)
+eval_module_LINK = $(CCLD) $(eval_module_CFLAGS) $(CFLAGS) \
+ $(eval_module_LDFLAGS) $(LDFLAGS) -o $@
+am_exfat_module_OBJECTS = fs/exfat_module-exfat.$(OBJEXT)
+nodist_exfat_module_OBJECTS =
+exfat_module_OBJECTS = $(am_exfat_module_OBJECTS) \
+ $(nodist_exfat_module_OBJECTS)
+exfat_module_LINK = $(CCLD) $(exfat_module_CFLAGS) $(CFLAGS) \
+ $(exfat_module_LDFLAGS) $(LDFLAGS) -o $@
+am_exfctest_module_OBJECTS = \
+ tests/exfctest_module-example_functional_test.$(OBJEXT)
+nodist_exfctest_module_OBJECTS =
+exfctest_module_OBJECTS = $(am_exfctest_module_OBJECTS) \
+ $(nodist_exfctest_module_OBJECTS)
+exfctest_module_LINK = $(CCLD) $(exfctest_module_CFLAGS) $(CFLAGS) \
+ $(exfctest_module_LDFLAGS) $(LDFLAGS) -o $@
+am_ext2_module_OBJECTS = fs/ext2_module-ext2.$(OBJEXT)
+nodist_ext2_module_OBJECTS =
+ext2_module_OBJECTS = $(am_ext2_module_OBJECTS) \
+ $(nodist_ext2_module_OBJECTS)
+ext2_module_LINK = $(CCLD) $(ext2_module_CFLAGS) $(CFLAGS) \
+ $(ext2_module_LDFLAGS) $(LDFLAGS) -o $@
+am__extcmd_module_SOURCES_DIST = commands/extcmd.c lib/arg.c
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@am_extcmd_module_OBJECTS = commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_extcmd_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ commands/extcmd_module-extcmd.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ lib/extcmd_module-arg.$(OBJEXT)
+nodist_extcmd_module_OBJECTS =
+extcmd_module_OBJECTS = $(am_extcmd_module_OBJECTS) \
+ $(nodist_extcmd_module_OBJECTS)
+extcmd_module_LINK = $(CCLD) $(extcmd_module_CFLAGS) $(CFLAGS) \
+ $(extcmd_module_LDFLAGS) $(LDFLAGS) -o $@
+am_f2fs_module_OBJECTS = fs/f2fs_module-f2fs.$(OBJEXT)
+nodist_f2fs_module_OBJECTS =
+f2fs_module_OBJECTS = $(am_f2fs_module_OBJECTS) \
+ $(nodist_f2fs_module_OBJECTS)
+f2fs_module_LINK = $(CCLD) $(f2fs_module_CFLAGS) $(CFLAGS) \
+ $(f2fs_module_LDFLAGS) $(LDFLAGS) -o $@
+am_fat_module_OBJECTS = fs/fat_module-fat.$(OBJEXT)
+nodist_fat_module_OBJECTS =
+fat_module_OBJECTS = $(am_fat_module_OBJECTS) \
+ $(nodist_fat_module_OBJECTS)
+fat_module_LINK = $(CCLD) $(fat_module_CFLAGS) $(CFLAGS) \
+ $(fat_module_LDFLAGS) $(LDFLAGS) -o $@
+am__fdt_module_SOURCES_DIST = loader/efi/fdt.c lib/fdt.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_fdt_module_OBJECTS = loader/efi/fdt_module-fdt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ lib/fdt_module-fdt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_riscv32_efi_TRUE@am_fdt_module_OBJECTS = loader/efi/fdt_module-fdt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_riscv32_efi_TRUE@ lib/fdt_module-fdt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_fdt_module_OBJECTS = lib/fdt_module-fdt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_fdt_module_OBJECTS = loader/efi/fdt_module-fdt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@ lib/fdt_module-fdt.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_fdt_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ loader/efi/fdt_module-fdt.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ lib/fdt_module-fdt.$(OBJEXT)
+nodist_fdt_module_OBJECTS =
+fdt_module_OBJECTS = $(am_fdt_module_OBJECTS) \
+ $(nodist_fdt_module_OBJECTS)
+fdt_module_LINK = $(CCLD) $(fdt_module_CFLAGS) $(CFLAGS) \
+ $(fdt_module_LDFLAGS) $(LDFLAGS) -o $@
+am_file_module_OBJECTS = commands/file_module-file.$(OBJEXT) \
+ commands/file_module-file32.$(OBJEXT) \
+ commands/file_module-file64.$(OBJEXT) \
+ loader/i386/file_module-xen_file.$(OBJEXT) \
+ loader/i386/file_module-xen_file32.$(OBJEXT) \
+ loader/i386/file_module-xen_file64.$(OBJEXT)
+nodist_file_module_OBJECTS =
+file_module_OBJECTS = $(am_file_module_OBJECTS) \
+ $(nodist_file_module_OBJECTS)
+file_module_LINK = $(CCLD) $(file_module_CFLAGS) $(CFLAGS) \
+ $(file_module_LDFLAGS) $(LDFLAGS) -o $@
+am__fixvideo_module_SOURCES_DIST = commands/efi/fixvideo.c
+@COND_i386_efi_FALSE@@COND_x86_64_efi_TRUE@am_fixvideo_module_OBJECTS = commands/efi/fixvideo_module-fixvideo.$(OBJEXT)
+@COND_i386_efi_TRUE@am_fixvideo_module_OBJECTS = commands/efi/fixvideo_module-fixvideo.$(OBJEXT)
+nodist_fixvideo_module_OBJECTS =
+fixvideo_module_OBJECTS = $(am_fixvideo_module_OBJECTS) \
+ $(nodist_fixvideo_module_OBJECTS)
+fixvideo_module_LINK = $(CCLD) $(fixvideo_module_CFLAGS) $(CFLAGS) \
+ $(fixvideo_module_LDFLAGS) $(LDFLAGS) -o $@
+am__font_module_SOURCES_DIST = font/font.c font/font_cmd.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_font_module_OBJECTS = font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_font_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ font/font_module-font.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ font/font_module-font_cmd.$(OBJEXT)
+nodist_font_module_OBJECTS =
+font_module_OBJECTS = $(am_font_module_OBJECTS) \
+ $(nodist_font_module_OBJECTS)
+font_module_LINK = $(CCLD) $(font_module_CFLAGS) $(CFLAGS) \
+ $(font_module_LDFLAGS) $(LDFLAGS) -o $@
+am__freedos_module_SOURCES_DIST = loader/i386/pc/freedos.c
+@COND_i386_pc_TRUE@am_freedos_module_OBJECTS = loader/i386/pc/freedos_module-freedos.$(OBJEXT)
+nodist_freedos_module_OBJECTS =
+freedos_module_OBJECTS = $(am_freedos_module_OBJECTS) \
+ $(nodist_freedos_module_OBJECTS)
+freedos_module_LINK = $(CCLD) $(freedos_module_CFLAGS) $(CFLAGS) \
+ $(freedos_module_LDFLAGS) $(LDFLAGS) -o $@
+am_fshelp_module_OBJECTS = fs/fshelp_module-fshelp.$(OBJEXT)
+nodist_fshelp_module_OBJECTS =
+fshelp_module_OBJECTS = $(am_fshelp_module_OBJECTS) \
+ $(nodist_fshelp_module_OBJECTS)
+fshelp_module_LINK = $(CCLD) $(fshelp_module_CFLAGS) $(CFLAGS) \
+ $(fshelp_module_LDFLAGS) $(LDFLAGS) -o $@
+am_functional_test_module_OBJECTS = \
+ tests/lib/functional_test_module-functional_test.$(OBJEXT) \
+ tests/lib/functional_test_module-test.$(OBJEXT) \
+ tests/functional_test_module-video_checksum.$(OBJEXT) \
+ tests/functional_test_module-fake_input.$(OBJEXT) \
+ video/functional_test_module-capture.$(OBJEXT)
+nodist_functional_test_module_OBJECTS =
+functional_test_module_OBJECTS = $(am_functional_test_module_OBJECTS) \
+ $(nodist_functional_test_module_OBJECTS)
+functional_test_module_LINK = $(CCLD) $(functional_test_module_CFLAGS) \
+ $(CFLAGS) $(functional_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am__fwstart_image_SOURCES_DIST = boot/mips/loongson/fwstart.S
+@COND_mips_loongson_TRUE@am_fwstart_image_OBJECTS = boot/mips/loongson/fwstart_image-fwstart.$(OBJEXT)
+nodist_fwstart_image_OBJECTS =
+fwstart_image_OBJECTS = $(am_fwstart_image_OBJECTS) \
+ $(nodist_fwstart_image_OBJECTS)
+fwstart_image_DEPENDENCIES =
+fwstart_image_LINK = $(CCLD) $(fwstart_image_CFLAGS) $(CFLAGS) \
+ $(fwstart_image_LDFLAGS) $(LDFLAGS) -o $@
+am__fwstart_fuloong2f_image_SOURCES_DIST = \
+ boot/mips/loongson/fuloong2f.S
+@COND_mips_loongson_TRUE@am_fwstart_fuloong2f_image_OBJECTS = boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.$(OBJEXT)
+nodist_fwstart_fuloong2f_image_OBJECTS =
+fwstart_fuloong2f_image_OBJECTS = \
+ $(am_fwstart_fuloong2f_image_OBJECTS) \
+ $(nodist_fwstart_fuloong2f_image_OBJECTS)
+fwstart_fuloong2f_image_DEPENDENCIES =
+fwstart_fuloong2f_image_LINK = $(CCLD) \
+ $(fwstart_fuloong2f_image_CFLAGS) $(CFLAGS) \
+ $(fwstart_fuloong2f_image_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_arcfour_module_OBJECTS = lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.$(OBJEXT)
+nodist_gcry_arcfour_module_OBJECTS =
+gcry_arcfour_module_OBJECTS = $(am_gcry_arcfour_module_OBJECTS) \
+ $(nodist_gcry_arcfour_module_OBJECTS)
+gcry_arcfour_module_LINK = $(CCLD) $(gcry_arcfour_module_CFLAGS) \
+ $(CFLAGS) $(gcry_arcfour_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_blowfish_module_OBJECTS = lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.$(OBJEXT)
+nodist_gcry_blowfish_module_OBJECTS =
+gcry_blowfish_module_OBJECTS = $(am_gcry_blowfish_module_OBJECTS) \
+ $(nodist_gcry_blowfish_module_OBJECTS)
+gcry_blowfish_module_LINK = $(CCLD) $(gcry_blowfish_module_CFLAGS) \
+ $(CFLAGS) $(gcry_blowfish_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_camellia_module_OBJECTS = lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.$(OBJEXT) \
+ lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.$(OBJEXT)
+nodist_gcry_camellia_module_OBJECTS =
+gcry_camellia_module_OBJECTS = $(am_gcry_camellia_module_OBJECTS) \
+ $(nodist_gcry_camellia_module_OBJECTS)
+gcry_camellia_module_LINK = $(CCLD) $(gcry_camellia_module_CFLAGS) \
+ $(CFLAGS) $(gcry_camellia_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_cast5_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.$(OBJEXT)
+nodist_gcry_cast5_module_OBJECTS =
+gcry_cast5_module_OBJECTS = $(am_gcry_cast5_module_OBJECTS) \
+ $(nodist_gcry_cast5_module_OBJECTS)
+gcry_cast5_module_LINK = $(CCLD) $(gcry_cast5_module_CFLAGS) $(CFLAGS) \
+ $(gcry_cast5_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_crc_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_crc_module-crc.$(OBJEXT)
+nodist_gcry_crc_module_OBJECTS =
+gcry_crc_module_OBJECTS = $(am_gcry_crc_module_OBJECTS) \
+ $(nodist_gcry_crc_module_OBJECTS)
+gcry_crc_module_LINK = $(CCLD) $(gcry_crc_module_CFLAGS) $(CFLAGS) \
+ $(gcry_crc_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_des_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_des_module-des.$(OBJEXT)
+nodist_gcry_des_module_OBJECTS =
+gcry_des_module_OBJECTS = $(am_gcry_des_module_OBJECTS) \
+ $(nodist_gcry_des_module_OBJECTS)
+gcry_des_module_LINK = $(CCLD) $(gcry_des_module_CFLAGS) $(CFLAGS) \
+ $(gcry_des_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_dsa_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.$(OBJEXT)
+nodist_gcry_dsa_module_OBJECTS =
+gcry_dsa_module_OBJECTS = $(am_gcry_dsa_module_OBJECTS) \
+ $(nodist_gcry_dsa_module_OBJECTS)
+gcry_dsa_module_LINK = $(CCLD) $(gcry_dsa_module_CFLAGS) $(CFLAGS) \
+ $(gcry_dsa_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_idea_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_idea_module-idea.$(OBJEXT)
+nodist_gcry_idea_module_OBJECTS =
+gcry_idea_module_OBJECTS = $(am_gcry_idea_module_OBJECTS) \
+ $(nodist_gcry_idea_module_OBJECTS)
+gcry_idea_module_LINK = $(CCLD) $(gcry_idea_module_CFLAGS) $(CFLAGS) \
+ $(gcry_idea_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_md4_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_md4_module-md4.$(OBJEXT)
+nodist_gcry_md4_module_OBJECTS =
+gcry_md4_module_OBJECTS = $(am_gcry_md4_module_OBJECTS) \
+ $(nodist_gcry_md4_module_OBJECTS)
+gcry_md4_module_LINK = $(CCLD) $(gcry_md4_module_CFLAGS) $(CFLAGS) \
+ $(gcry_md4_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_md5_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_md5_module-md5.$(OBJEXT)
+nodist_gcry_md5_module_OBJECTS =
+gcry_md5_module_OBJECTS = $(am_gcry_md5_module_OBJECTS) \
+ $(nodist_gcry_md5_module_OBJECTS)
+gcry_md5_module_LINK = $(CCLD) $(gcry_md5_module_CFLAGS) $(CFLAGS) \
+ $(gcry_md5_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_rfc2268_module_OBJECTS = lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.$(OBJEXT)
+nodist_gcry_rfc2268_module_OBJECTS =
+gcry_rfc2268_module_OBJECTS = $(am_gcry_rfc2268_module_OBJECTS) \
+ $(nodist_gcry_rfc2268_module_OBJECTS)
+gcry_rfc2268_module_LINK = $(CCLD) $(gcry_rfc2268_module_CFLAGS) \
+ $(CFLAGS) $(gcry_rfc2268_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_rijndael_module_OBJECTS = lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.$(OBJEXT)
+nodist_gcry_rijndael_module_OBJECTS =
+gcry_rijndael_module_OBJECTS = $(am_gcry_rijndael_module_OBJECTS) \
+ $(nodist_gcry_rijndael_module_OBJECTS)
+gcry_rijndael_module_LINK = $(CCLD) $(gcry_rijndael_module_CFLAGS) \
+ $(CFLAGS) $(gcry_rijndael_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_rmd160_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.$(OBJEXT)
+nodist_gcry_rmd160_module_OBJECTS =
+gcry_rmd160_module_OBJECTS = $(am_gcry_rmd160_module_OBJECTS) \
+ $(nodist_gcry_rmd160_module_OBJECTS)
+gcry_rmd160_module_LINK = $(CCLD) $(gcry_rmd160_module_CFLAGS) \
+ $(CFLAGS) $(gcry_rmd160_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_rsa_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.$(OBJEXT)
+nodist_gcry_rsa_module_OBJECTS =
+gcry_rsa_module_OBJECTS = $(am_gcry_rsa_module_OBJECTS) \
+ $(nodist_gcry_rsa_module_OBJECTS)
+gcry_rsa_module_LINK = $(CCLD) $(gcry_rsa_module_CFLAGS) $(CFLAGS) \
+ $(gcry_rsa_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_seed_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_seed_module-seed.$(OBJEXT)
+nodist_gcry_seed_module_OBJECTS =
+gcry_seed_module_OBJECTS = $(am_gcry_seed_module_OBJECTS) \
+ $(nodist_gcry_seed_module_OBJECTS)
+gcry_seed_module_LINK = $(CCLD) $(gcry_seed_module_CFLAGS) $(CFLAGS) \
+ $(gcry_seed_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_serpent_module_OBJECTS = lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.$(OBJEXT)
+nodist_gcry_serpent_module_OBJECTS =
+gcry_serpent_module_OBJECTS = $(am_gcry_serpent_module_OBJECTS) \
+ $(nodist_gcry_serpent_module_OBJECTS)
+gcry_serpent_module_LINK = $(CCLD) $(gcry_serpent_module_CFLAGS) \
+ $(CFLAGS) $(gcry_serpent_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_sha1_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.$(OBJEXT)
+nodist_gcry_sha1_module_OBJECTS =
+gcry_sha1_module_OBJECTS = $(am_gcry_sha1_module_OBJECTS) \
+ $(nodist_gcry_sha1_module_OBJECTS)
+gcry_sha1_module_LINK = $(CCLD) $(gcry_sha1_module_CFLAGS) $(CFLAGS) \
+ $(gcry_sha1_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_sha256_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.$(OBJEXT)
+nodist_gcry_sha256_module_OBJECTS =
+gcry_sha256_module_OBJECTS = $(am_gcry_sha256_module_OBJECTS) \
+ $(nodist_gcry_sha256_module_OBJECTS)
+gcry_sha256_module_LINK = $(CCLD) $(gcry_sha256_module_CFLAGS) \
+ $(CFLAGS) $(gcry_sha256_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_sha512_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.$(OBJEXT)
+nodist_gcry_sha512_module_OBJECTS =
+gcry_sha512_module_OBJECTS = $(am_gcry_sha512_module_OBJECTS) \
+ $(nodist_gcry_sha512_module_OBJECTS)
+gcry_sha512_module_LINK = $(CCLD) $(gcry_sha512_module_CFLAGS) \
+ $(CFLAGS) $(gcry_sha512_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_tiger_module_OBJECTS = \
+ lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.$(OBJEXT)
+nodist_gcry_tiger_module_OBJECTS =
+gcry_tiger_module_OBJECTS = $(am_gcry_tiger_module_OBJECTS) \
+ $(nodist_gcry_tiger_module_OBJECTS)
+gcry_tiger_module_LINK = $(CCLD) $(gcry_tiger_module_CFLAGS) $(CFLAGS) \
+ $(gcry_tiger_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_twofish_module_OBJECTS = lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.$(OBJEXT)
+nodist_gcry_twofish_module_OBJECTS =
+gcry_twofish_module_OBJECTS = $(am_gcry_twofish_module_OBJECTS) \
+ $(nodist_gcry_twofish_module_OBJECTS)
+gcry_twofish_module_LINK = $(CCLD) $(gcry_twofish_module_CFLAGS) \
+ $(CFLAGS) $(gcry_twofish_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gcry_whirlpool_module_OBJECTS = lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.$(OBJEXT)
+nodist_gcry_whirlpool_module_OBJECTS =
+gcry_whirlpool_module_OBJECTS = $(am_gcry_whirlpool_module_OBJECTS) \
+ $(nodist_gcry_whirlpool_module_OBJECTS)
+gcry_whirlpool_module_LINK = $(CCLD) $(gcry_whirlpool_module_CFLAGS) \
+ $(CFLAGS) $(gcry_whirlpool_module_LDFLAGS) $(LDFLAGS) -o $@
+am__gdb_module_SOURCES_DIST = gdb/i386/idt.c gdb/i386/machdep.S \
+ gdb/i386/signal.c gdb/cstub.c gdb/gdb.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_gdb_module_OBJECTS = gdb/i386/gdb_module-idt.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ gdb/i386/gdb_module-machdep.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ gdb/i386/gdb_module-signal.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ gdb/gdb_module-cstub.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ gdb/gdb_module-gdb.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_gdb_module_OBJECTS = gdb/i386/gdb_module-idt.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ gdb/i386/gdb_module-machdep.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ gdb/i386/gdb_module-signal.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ gdb/gdb_module-cstub.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ gdb/gdb_module-gdb.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_gdb_module_OBJECTS = gdb/i386/gdb_module-idt.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ gdb/i386/gdb_module-machdep.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ gdb/i386/gdb_module-signal.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ gdb/gdb_module-cstub.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ gdb/gdb_module-gdb.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_gdb_module_OBJECTS = gdb/i386/gdb_module-idt.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ gdb/i386/gdb_module-machdep.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ gdb/i386/gdb_module-signal.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ gdb/gdb_module-cstub.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ gdb/gdb_module-gdb.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_gdb_module_OBJECTS = gdb/i386/gdb_module-idt.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ gdb/i386/gdb_module-machdep.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ gdb/i386/gdb_module-signal.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ gdb/gdb_module-cstub.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ gdb/gdb_module-gdb.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_gdb_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ gdb/i386/gdb_module-idt.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ gdb/i386/gdb_module-machdep.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ gdb/i386/gdb_module-signal.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ gdb/gdb_module-cstub.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ gdb/gdb_module-gdb.$(OBJEXT)
+nodist_gdb_module_OBJECTS =
+gdb_module_OBJECTS = $(am_gdb_module_OBJECTS) \
+ $(nodist_gdb_module_OBJECTS)
+gdb_module_LINK = $(CCLD) $(gdb_module_CFLAGS) $(CFLAGS) \
+ $(gdb_module_LDFLAGS) $(LDFLAGS) -o $@
+am_geli_module_OBJECTS = disk/geli_module-geli.$(OBJEXT)
+nodist_geli_module_OBJECTS =
+geli_module_OBJECTS = $(am_geli_module_OBJECTS) \
+ $(nodist_geli_module_OBJECTS)
+geli_module_LINK = $(CCLD) $(geli_module_CFLAGS) $(CFLAGS) \
+ $(geli_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gettext_module_OBJECTS = gettext/gettext_module-gettext.$(OBJEXT)
+nodist_gettext_module_OBJECTS =
+gettext_module_OBJECTS = $(am_gettext_module_OBJECTS) \
+ $(nodist_gettext_module_OBJECTS)
+gettext_module_LINK = $(CCLD) $(gettext_module_CFLAGS) $(CFLAGS) \
+ $(gettext_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gfxmenu_module_OBJECTS = gfxmenu/gfxmenu_module-gfxmenu.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-view.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-font.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-icon_manager.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-theme_loader.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-widget-box.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-gui_canvas.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-gui_circular_progress.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-gui_box.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-gui_label.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-gui_list.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-gui_image.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-gui_progress_bar.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-gui_util.$(OBJEXT) \
+ gfxmenu/gfxmenu_module-gui_string_util.$(OBJEXT)
+nodist_gfxmenu_module_OBJECTS =
+gfxmenu_module_OBJECTS = $(am_gfxmenu_module_OBJECTS) \
+ $(nodist_gfxmenu_module_OBJECTS)
+gfxmenu_module_LINK = $(CCLD) $(gfxmenu_module_CFLAGS) $(CFLAGS) \
+ $(gfxmenu_module_LDFLAGS) $(LDFLAGS) -o $@
+am__gfxterm_module_SOURCES_DIST = term/gfxterm.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_gfxterm_module_OBJECTS = term/gfxterm_module-gfxterm.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_gfxterm_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ term/gfxterm_module-gfxterm.$(OBJEXT)
+nodist_gfxterm_module_OBJECTS =
+gfxterm_module_OBJECTS = $(am_gfxterm_module_OBJECTS) \
+ $(nodist_gfxterm_module_OBJECTS)
+gfxterm_module_LINK = $(CCLD) $(gfxterm_module_CFLAGS) $(CFLAGS) \
+ $(gfxterm_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gfxterm_background_module_OBJECTS = \
+ term/gfxterm_background_module-gfxterm_background.$(OBJEXT)
+nodist_gfxterm_background_module_OBJECTS =
+gfxterm_background_module_OBJECTS = \
+ $(am_gfxterm_background_module_OBJECTS) \
+ $(nodist_gfxterm_background_module_OBJECTS)
+gfxterm_background_module_LINK = $(CCLD) \
+ $(gfxterm_background_module_CFLAGS) $(CFLAGS) \
+ $(gfxterm_background_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gfxterm_menu_module_OBJECTS = \
+ tests/gfxterm_menu_module-gfxterm_menu.$(OBJEXT)
+nodist_gfxterm_menu_module_OBJECTS =
+gfxterm_menu_module_OBJECTS = $(am_gfxterm_menu_module_OBJECTS) \
+ $(nodist_gfxterm_menu_module_OBJECTS)
+gfxterm_menu_module_LINK = $(CCLD) $(gfxterm_menu_module_CFLAGS) \
+ $(CFLAGS) $(gfxterm_menu_module_LDFLAGS) $(LDFLAGS) -o $@
+am_gptsync_module_OBJECTS = commands/gptsync_module-gptsync.$(OBJEXT)
+nodist_gptsync_module_OBJECTS =
+gptsync_module_OBJECTS = $(am_gptsync_module_OBJECTS) \
+ $(nodist_gptsync_module_OBJECTS)
+gptsync_module_LINK = $(CCLD) $(gptsync_module_CFLAGS) $(CFLAGS) \
+ $(gptsync_module_LDFLAGS) $(LDFLAGS) -o $@
+am__grub_emu_SOURCES_DIST = kern/emu/full.c
+@COND_emu_TRUE@am_grub_emu_OBJECTS = kern/emu/grub_emu-full.$(OBJEXT)
+@COND_emu_TRUE@nodist_grub_emu_OBJECTS = \
+@COND_emu_TRUE@ grub_emu-grub_emu_init.$(OBJEXT)
+grub_emu_OBJECTS = $(am_grub_emu_OBJECTS) $(nodist_grub_emu_OBJECTS)
+am__DEPENDENCIES_1 =
+@COND_emu_TRUE@grub_emu_DEPENDENCIES = kernel.exec$(EXEEXT) \
+@COND_emu_TRUE@ $(MODULE_FILES) lib/gnulib/libgnu.a \
+@COND_emu_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@COND_emu_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@COND_emu_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@COND_emu_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+grub_emu_LINK = $(CCLD) $(grub_emu_CFLAGS) $(CFLAGS) \
+ $(grub_emu_LDFLAGS) $(LDFLAGS) -o $@
+am__grub_emu_lite_SOURCES_DIST = kern/emu/lite.c
+@COND_emu_TRUE@am_grub_emu_lite_OBJECTS = \
+@COND_emu_TRUE@ kern/emu/grub_emu_lite-lite.$(OBJEXT)
+@COND_emu_TRUE@nodist_grub_emu_lite_OBJECTS = \
+@COND_emu_TRUE@ grub_emu_lite-symlist.$(OBJEXT)
+grub_emu_lite_OBJECTS = $(am_grub_emu_lite_OBJECTS) \
+ $(nodist_grub_emu_lite_OBJECTS)
+@COND_emu_TRUE@grub_emu_lite_DEPENDENCIES = kernel.exec$(EXEEXT) \
+@COND_emu_TRUE@ lib/gnulib/libgnu.a $(am__DEPENDENCIES_1) \
+@COND_emu_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@COND_emu_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@COND_emu_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@COND_emu_TRUE@ $(am__DEPENDENCIES_1)
+grub_emu_lite_LINK = $(CCLD) $(grub_emu_lite_CFLAGS) $(CFLAGS) \
+ $(grub_emu_lite_LDFLAGS) $(LDFLAGS) -o $@
+am_gzio_module_OBJECTS = io/gzio_module-gzio.$(OBJEXT)
+nodist_gzio_module_OBJECTS =
+gzio_module_OBJECTS = $(am_gzio_module_OBJECTS) \
+ $(nodist_gzio_module_OBJECTS)
+gzio_module_LINK = $(CCLD) $(gzio_module_CFLAGS) $(CFLAGS) \
+ $(gzio_module_LDFLAGS) $(LDFLAGS) -o $@
+am__halt_module_SOURCES_DIST = lib/efi/halt.c commands/halt.c \
+ lib/dummy/halt.c lib/emu/halt.c commands/acpihalt.c \
+ lib/i386/halt.c lib/ieee1275/halt.c commands/i386/pc/halt.c \
+ lib/xen/halt.c
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_halt_module_OBJECTS = lib/xen/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_halt_module_OBJECTS = commands/halt_module-acpihalt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/efi/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_halt_module_OBJECTS = lib/ieee1275/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_halt_module_OBJECTS = lib/efi/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_halt_module_OBJECTS = lib/efi/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_halt_module_OBJECTS = lib/ieee1275/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_halt_module_OBJECTS = commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_halt_module_OBJECTS = commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_halt_module_OBJECTS = commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_halt_module_OBJECTS = lib/efi/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_halt_module_OBJECTS = lib/xen/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_halt_module_OBJECTS = lib/xen/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_halt_module_OBJECTS = lib/i386/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_halt_module_OBJECTS = commands/i386/pc/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ commands/halt_module-acpihalt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_halt_module_OBJECTS = commands/halt_module-acpihalt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/i386/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_halt_module_OBJECTS = lib/ieee1275/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_halt_module_OBJECTS = commands/halt_module-acpihalt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/efi/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@am_halt_module_OBJECTS = commands/halt_module-acpihalt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ lib/i386/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@am_halt_module_OBJECTS = lib/emu/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_halt_module_OBJECTS = lib/dummy/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@am_halt_module_OBJECTS = lib/efi/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@am_halt_module_OBJECTS = lib/dummy/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ commands/halt_module-halt.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_halt_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ lib/efi/halt_module-halt.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ commands/halt_module-halt.$(OBJEXT)
+nodist_halt_module_OBJECTS =
+halt_module_OBJECTS = $(am_halt_module_OBJECTS) \
+ $(nodist_halt_module_OBJECTS)
+halt_module_LINK = $(CCLD) $(halt_module_CFLAGS) $(CFLAGS) \
+ $(halt_module_LDFLAGS) $(LDFLAGS) -o $@
+am_hashsum_module_OBJECTS = commands/hashsum_module-hashsum.$(OBJEXT)
+nodist_hashsum_module_OBJECTS =
+hashsum_module_OBJECTS = $(am_hashsum_module_OBJECTS) \
+ $(nodist_hashsum_module_OBJECTS)
+hashsum_module_LINK = $(CCLD) $(hashsum_module_CFLAGS) $(CFLAGS) \
+ $(hashsum_module_LDFLAGS) $(LDFLAGS) -o $@
+am__hdparm_module_SOURCES_DIST = commands/hdparm.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_TRUE@am_hdparm_module_OBJECTS = commands/hdparm_module-hdparm.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_hdparm_module_OBJECTS = commands/hdparm_module-hdparm.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_hdparm_module_OBJECTS = commands/hdparm_module-hdparm.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_hdparm_module_OBJECTS = commands/hdparm_module-hdparm.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_hdparm_module_OBJECTS = commands/hdparm_module-hdparm.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_hdparm_module_OBJECTS = commands/hdparm_module-hdparm.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_hdparm_module_OBJECTS = commands/hdparm_module-hdparm.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_hdparm_module_OBJECTS = commands/hdparm_module-hdparm.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_hdparm_module_OBJECTS = commands/hdparm_module-hdparm.$(OBJEXT)
+nodist_hdparm_module_OBJECTS =
+hdparm_module_OBJECTS = $(am_hdparm_module_OBJECTS) \
+ $(nodist_hdparm_module_OBJECTS)
+hdparm_module_LINK = $(CCLD) $(hdparm_module_CFLAGS) $(CFLAGS) \
+ $(hdparm_module_LDFLAGS) $(LDFLAGS) -o $@
+am_hello_module_OBJECTS = hello/hello_module-hello.$(OBJEXT)
+nodist_hello_module_OBJECTS =
+hello_module_OBJECTS = $(am_hello_module_OBJECTS) \
+ $(nodist_hello_module_OBJECTS)
+hello_module_LINK = $(CCLD) $(hello_module_CFLAGS) $(CFLAGS) \
+ $(hello_module_LDFLAGS) $(LDFLAGS) -o $@
+am_help_module_OBJECTS = commands/help_module-help.$(OBJEXT)
+nodist_help_module_OBJECTS =
+help_module_OBJECTS = $(am_help_module_OBJECTS) \
+ $(nodist_help_module_OBJECTS)
+help_module_LINK = $(CCLD) $(help_module_CFLAGS) $(CFLAGS) \
+ $(help_module_LDFLAGS) $(LDFLAGS) -o $@
+am_hexdump_module_OBJECTS = commands/hexdump_module-hexdump.$(OBJEXT) \
+ lib/hexdump_module-hexdump.$(OBJEXT)
+nodist_hexdump_module_OBJECTS =
+hexdump_module_OBJECTS = $(am_hexdump_module_OBJECTS) \
+ $(nodist_hexdump_module_OBJECTS)
+hexdump_module_LINK = $(CCLD) $(hexdump_module_CFLAGS) $(CFLAGS) \
+ $(hexdump_module_LDFLAGS) $(LDFLAGS) -o $@
+am_hfs_module_OBJECTS = fs/hfs_module-hfs.$(OBJEXT)
+nodist_hfs_module_OBJECTS =
+hfs_module_OBJECTS = $(am_hfs_module_OBJECTS) \
+ $(nodist_hfs_module_OBJECTS)
+hfs_module_LINK = $(CCLD) $(hfs_module_CFLAGS) $(CFLAGS) \
+ $(hfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am_hfsplus_module_OBJECTS = fs/hfsplus_module-hfsplus.$(OBJEXT)
+nodist_hfsplus_module_OBJECTS =
+hfsplus_module_OBJECTS = $(am_hfsplus_module_OBJECTS) \
+ $(nodist_hfsplus_module_OBJECTS)
+hfsplus_module_LINK = $(CCLD) $(hfsplus_module_CFLAGS) $(CFLAGS) \
+ $(hfsplus_module_LDFLAGS) $(LDFLAGS) -o $@
+am_hfspluscomp_module_OBJECTS = \
+ fs/hfspluscomp_module-hfspluscomp.$(OBJEXT)
+nodist_hfspluscomp_module_OBJECTS =
+hfspluscomp_module_OBJECTS = $(am_hfspluscomp_module_OBJECTS) \
+ $(nodist_hfspluscomp_module_OBJECTS)
+hfspluscomp_module_LINK = $(CCLD) $(hfspluscomp_module_CFLAGS) \
+ $(CFLAGS) $(hfspluscomp_module_LDFLAGS) $(LDFLAGS) -o $@
+am_http_module_OBJECTS = net/http_module-http.$(OBJEXT)
+nodist_http_module_OBJECTS =
+http_module_OBJECTS = $(am_http_module_OBJECTS) \
+ $(nodist_http_module_OBJECTS)
+http_module_LINK = $(CCLD) $(http_module_CFLAGS) $(CFLAGS) \
+ $(http_module_LDFLAGS) $(LDFLAGS) -o $@
+am__ieee1275_fb_module_SOURCES_DIST = video/ieee1275.c
+@COND_powerpc_ieee1275_TRUE@am_ieee1275_fb_module_OBJECTS = video/ieee1275_fb_module-ieee1275.$(OBJEXT)
+nodist_ieee1275_fb_module_OBJECTS =
+ieee1275_fb_module_OBJECTS = $(am_ieee1275_fb_module_OBJECTS) \
+ $(nodist_ieee1275_fb_module_OBJECTS)
+ieee1275_fb_module_LINK = $(CCLD) $(ieee1275_fb_module_CFLAGS) \
+ $(CFLAGS) $(ieee1275_fb_module_LDFLAGS) $(LDFLAGS) -o $@
+am__iorw_module_SOURCES_DIST = commands/iorw.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_iorw_module_OBJECTS = commands/iorw_module-iorw.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_iorw_module_OBJECTS = commands/iorw_module-iorw.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_iorw_module_OBJECTS = commands/iorw_module-iorw.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_iorw_module_OBJECTS = commands/iorw_module-iorw.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_iorw_module_OBJECTS = commands/iorw_module-iorw.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_iorw_module_OBJECTS = commands/iorw_module-iorw.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_iorw_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ commands/iorw_module-iorw.$(OBJEXT)
+nodist_iorw_module_OBJECTS =
+iorw_module_OBJECTS = $(am_iorw_module_OBJECTS) \
+ $(nodist_iorw_module_OBJECTS)
+iorw_module_LINK = $(CCLD) $(iorw_module_CFLAGS) $(CFLAGS) \
+ $(iorw_module_LDFLAGS) $(LDFLAGS) -o $@
+am_iso9660_module_OBJECTS = fs/iso9660_module-iso9660.$(OBJEXT)
+nodist_iso9660_module_OBJECTS =
+iso9660_module_OBJECTS = $(am_iso9660_module_OBJECTS) \
+ $(nodist_iso9660_module_OBJECTS)
+iso9660_module_LINK = $(CCLD) $(iso9660_module_CFLAGS) $(CFLAGS) \
+ $(iso9660_module_LDFLAGS) $(LDFLAGS) -o $@
+am_jfs_module_OBJECTS = fs/jfs_module-jfs.$(OBJEXT)
+nodist_jfs_module_OBJECTS =
+jfs_module_OBJECTS = $(am_jfs_module_OBJECTS) \
+ $(nodist_jfs_module_OBJECTS)
+jfs_module_LINK = $(CCLD) $(jfs_module_CFLAGS) $(CFLAGS) \
+ $(jfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am_jpeg_module_OBJECTS = video/readers/jpeg_module-jpeg.$(OBJEXT)
+nodist_jpeg_module_OBJECTS =
+jpeg_module_OBJECTS = $(am_jpeg_module_OBJECTS) \
+ $(nodist_jpeg_module_OBJECTS)
+jpeg_module_LINK = $(CCLD) $(jpeg_module_CFLAGS) $(CFLAGS) \
+ $(jpeg_module_LDFLAGS) $(LDFLAGS) -o $@
+am_json_module_OBJECTS = lib/json/json_module-json.$(OBJEXT)
+nodist_json_module_OBJECTS =
+json_module_OBJECTS = $(am_json_module_OBJECTS) \
+ $(nodist_json_module_OBJECTS)
+json_module_LINK = $(CCLD) $(json_module_CFLAGS) $(CFLAGS) \
+ $(json_module_LDFLAGS) $(LDFLAGS) -o $@
+am__kernel_exec_SOURCES_DIST = kern/arm64/efi/startup.S \
+ kern/arm64/efi/init.c kern/efi/fdt.c kern/arm64/cache.c \
+ kern/arm64/cache_flush.S kern/arm64/dl.c \
+ kern/arm64/dl_helper.c disk/efi/efidisk.c kern/efi/efi.c \
+ kern/efi/init.c kern/efi/mm.c term/efi/console.c kern/acpi.c \
+ kern/efi/acpi.c kern/efi/sb.c kern/lockdown.c \
+ kern/compiler-rt.c kern/mm.c kern/time.c \
+ kern/generic/millisleep.c kern/buffer.c kern/command.c \
+ kern/corecmd.c kern/device.c kern/disk.c kern/dl.c kern/env.c \
+ kern/err.c kern/file.c kern/fs.c kern/list.c kern/main.c \
+ kern/misc.c kern/parser.c kern/partition.c \
+ kern/rescue_parser.c kern/rescue_reader.c kern/term.c \
+ kern/verifiers.c kern/arm/startup.S kern/arm/coreboot/init.c \
+ kern/arm/coreboot/timer.c kern/arm/coreboot/coreboot.S \
+ lib/fdt.c bus/fdt.c term/ps2.c term/arm/pl050.c \
+ term/arm/cros.c term/arm/cros_ec.c bus/spi/rk3288_spi.c \
+ commands/keylayouts.c kern/arm/coreboot/dma.c \
+ kern/arm/coreboot/cbtable.c video/coreboot/cbfb.c \
+ kern/coreboot/mmap.c kern/coreboot/cbtable.c term/gfxterm.c \
+ font/font.c font/font_cmd.c io/bufio.c video/fb/fbblit.c \
+ video/fb/fbfill.c video/fb/fbutil.c video/fb/video_fb.c \
+ video/video.c kern/arm/dl.c kern/arm/dl_helper.c \
+ kern/arm/cache_armv6.S kern/arm/cache_armv7.S kern/arm/cache.c \
+ kern/arm/compiler-rt.S lib/division.c kern/arm/efi/startup.S \
+ kern/arm/efi/init.c kern/arm/uboot/init.c \
+ kern/arm/uboot/uboot.S disk/uboot/ubootdisk.c \
+ kern/uboot/uboot.c kern/uboot/init.c kern/uboot/hw.c \
+ term/uboot/console.c term/terminfo.c term/tparm.c \
+ commands/extcmd.c lib/arg.c disk/host.c kern/emu/cache_s.S \
+ kern/emu/hostdisk.c osdep/unix/hostdisk.c osdep/exec.c \
+ osdep/devmapper/hostdisk.c osdep/hostdisk.c kern/emu/hostfs.c \
+ kern/emu/main.c kern/emu/argp_common.c kern/emu/misc.c \
+ kern/emu/mm.c kern/emu/time.c kern/emu/cache.c \
+ osdep/emuconsole.c osdep/dl.c osdep/sleep.c osdep/init.c \
+ osdep/emunet.c osdep/cputime.c kern/i386/coreboot/startup.S \
+ kern/i386/coreboot/init.c kern/i386/pc/acpi.c \
+ kern/i386/tsc_pmtimer.c kern/i386/coreboot/cbtable.c \
+ term/i386/pc/vga_text.c kern/i386/dl.c kern/i386/tsc.c \
+ kern/i386/tsc_pit.c kern/i386/efi/startup.S \
+ kern/i386/efi/tsc.c kern/i386/efi/init.c bus/pci.c \
+ kern/i386/ieee1275/startup.S disk/ieee1275/ofdisk.c \
+ kern/ieee1275/cmain.c kern/ieee1275/ieee1275.c \
+ kern/ieee1275/mmap.c kern/ieee1275/openfw.c \
+ term/ieee1275/console.c kern/ieee1275/init.c \
+ kern/i386/multiboot_mmap.c kern/i386/pc/startup.S \
+ kern/i386/pc/init.c kern/i386/pc/mmap.c term/i386/pc/console.c \
+ kern/i386/qemu/startup.S kern/i386/qemu/init.c kern/vga_init.c \
+ kern/i386/qemu/mmap.c kern/i386/xen/startup.S \
+ kern/i386/xen/hypercall.S kern/i386/xen/tsc.c kern/xen/init.c \
+ term/xen/console.c disk/xen/xendisk.c commands/boot.c \
+ kern/i386/xen/startup_pvh.S kern/i386/xen/pvh.c \
+ kern/ia64/efi/startup.S kern/ia64/efi/init.c kern/ia64/dl.c \
+ kern/ia64/dl_helper.c kern/ia64/cache.c kern/mips/startup.S \
+ kern/mips/arc/init.c term/arc/console.c disk/arc/arcdisk.c \
+ kern/generic/rtc_get_time_ms.c kern/mips/cache.S \
+ kern/mips/dl.c kern/mips/init.c term/ns8250.c bus/bonito.c \
+ bus/cs5536.c kern/mips/loongson/init.c term/at_keyboard.c \
+ term/serial.c video/sm712.c video/sis315pro.c \
+ video/radeon_fuloong2e.c video/radeon_yeeloong3a.c \
+ kern/mips/qemu_mips/init.c kern/powerpc/ieee1275/startup.S \
+ kern/powerpc/cache.S kern/powerpc/dl.c \
+ kern/powerpc/compiler-rt.S kern/riscv/efi/startup.S \
+ kern/riscv/efi/init.c kern/riscv/cache.c \
+ kern/riscv/cache_flush.S kern/riscv/dl.c \
+ kern/sparc64/ieee1275/crt0.S kern/sparc64/cache.S \
+ kern/sparc64/dl.c kern/sparc64/ieee1275/ieee1275.c \
+ disk/ieee1275/obdisk.c kern/x86_64/efi/startup.S \
+ kern/x86_64/efi/callwrap.S kern/x86_64/dl.c \
+ kern/x86_64/xen/startup.S kern/x86_64/xen/hypercall.S
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_kernel_exec_OBJECTS = kern/x86_64/xen/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/x86_64/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/x86_64/xen/kernel_exec-hypercall.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/i386/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/i386/xen/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/xen/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ term/xen/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ disk/xen/kernel_exec-xendisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ commands/kernel_exec-boot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_kernel_exec_OBJECTS = kern/x86_64/efi/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/i386/efi/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/i386/kernel_exec-tsc_pmtimer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/x86_64/efi/kernel_exec-callwrap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/i386/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ bus/kernel_exec-pci.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/x86_64/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/i386/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/i386/kernel_exec-tsc_pit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ disk/efi/kernel_exec-efidisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/efi/kernel_exec-efi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/efi/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ term/efi/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/efi/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/efi/kernel_exec-sb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-lockdown.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_kernel_exec_OBJECTS = kern/sparc64/ieee1275/kernel_exec-crt0.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/sparc64/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/sparc64/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/sparc64/ieee1275/kernel_exec-ieee1275.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ disk/ieee1275/kernel_exec-obdisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ disk/ieee1275/kernel_exec-ofdisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/ieee1275/kernel_exec-cmain.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/ieee1275/kernel_exec-ieee1275.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/ieee1275/kernel_exec-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/ieee1275/kernel_exec-openfw.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ term/ieee1275/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/ieee1275/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_kernel_exec_OBJECTS = kern/riscv/efi/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/riscv/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/efi/kernel_exec-fdt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/riscv/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/riscv/kernel_exec-cache_flush.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/riscv/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ disk/efi/kernel_exec-efidisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/efi/kernel_exec-efi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/efi/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ term/efi/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/efi/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/efi/kernel_exec-sb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-lockdown.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_kernel_exec_OBJECTS = kern/riscv/efi/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/riscv/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/efi/kernel_exec-fdt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/riscv/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/riscv/kernel_exec-cache_flush.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/riscv/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ lib/kernel_exec-division.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ disk/efi/kernel_exec-efidisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/efi/kernel_exec-efi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/efi/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ term/efi/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/efi/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/efi/kernel_exec-sb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-lockdown.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_kernel_exec_OBJECTS = kern/powerpc/ieee1275/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/powerpc/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/powerpc/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/powerpc/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ disk/ieee1275/kernel_exec-ofdisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/ieee1275/kernel_exec-cmain.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/ieee1275/kernel_exec-ieee1275.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/ieee1275/kernel_exec-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/ieee1275/kernel_exec-openfw.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ term/ieee1275/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/ieee1275/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_kernel_exec_OBJECTS = kern/mips/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/mips/qemu_mips/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ term/kernel_exec-ns8250.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ term/kernel_exec-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ term/kernel_exec-at_keyboard.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ term/kernel_exec-ps2.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ commands/kernel_exec-boot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ commands/kernel_exec-keylayouts.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ term/i386/pc/kernel_exec-vga_text.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-vga_init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/generic/kernel_exec-rtc_get_time_ms.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/mips/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/mips/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/mips/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_kernel_exec_OBJECTS = kern/mips/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ term/kernel_exec-ns8250.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ bus/kernel_exec-bonito.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ bus/kernel_exec-cs5536.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ bus/kernel_exec-pci.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/mips/loongson/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ term/kernel_exec-at_keyboard.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ term/kernel_exec-ps2.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ commands/kernel_exec-boot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ term/kernel_exec-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ video/kernel_exec-sm712.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ video/kernel_exec-sis315pro.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ video/kernel_exec-radeon_fuloong2e.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ video/kernel_exec-radeon_yeeloong3a.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ commands/kernel_exec-keylayouts.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ term/kernel_exec-gfxterm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ font/kernel_exec-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ font/kernel_exec-font_cmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ io/kernel_exec-bufio.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ video/fb/kernel_exec-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ video/fb/kernel_exec-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ video/fb/kernel_exec-fbutil.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ video/fb/kernel_exec-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ video/kernel_exec-video.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/generic/kernel_exec-rtc_get_time_ms.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/mips/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/mips/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/mips/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_kernel_exec_OBJECTS = kern/mips/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/mips/arc/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ term/arc/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ disk/arc/kernel_exec-arcdisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/generic/kernel_exec-rtc_get_time_ms.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/mips/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/mips/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/mips/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_kernel_exec_OBJECTS = kern/ia64/efi/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/ia64/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/ia64/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/ia64/kernel_exec-dl_helper.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/ia64/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ lib/kernel_exec-division.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ disk/efi/kernel_exec-efidisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/efi/kernel_exec-efi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/efi/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ term/efi/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/efi/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/efi/kernel_exec-sb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-lockdown.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_kernel_exec_OBJECTS = kern/i386/xen/kernel_exec-startup_pvh.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/i386/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ commands/kernel_exec-boot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ disk/xen/kernel_exec-xendisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/i386/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/i386/xen/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/i386/xen/kernel_exec-pvh.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/xen/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ term/xen/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_kernel_exec_OBJECTS = kern/i386/xen/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/i386/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/i386/xen/kernel_exec-hypercall.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/i386/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/i386/xen/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/xen/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ term/xen/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ disk/xen/kernel_exec-xendisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ commands/kernel_exec-boot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_kernel_exec_OBJECTS = kern/i386/qemu/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/i386/qemu/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ bus/kernel_exec-pci.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-vga_init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/i386/qemu/kernel_exec-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ term/i386/pc/kernel_exec-vga_text.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/i386/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/i386/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/i386/kernel_exec-tsc_pit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_kernel_exec_OBJECTS = kern/i386/pc/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/i386/pc/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/i386/pc/kernel_exec-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ term/i386/pc/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/i386/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/i386/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/i386/kernel_exec-tsc_pit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_kernel_exec_OBJECTS = kern/i386/coreboot/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/i386/coreboot/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/i386/pc/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/i386/kernel_exec-multiboot_mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ term/i386/pc/kernel_exec-vga_text.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/i386/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/i386/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/i386/kernel_exec-tsc_pit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_kernel_exec_OBJECTS = kern/i386/ieee1275/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ disk/ieee1275/kernel_exec-ofdisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/ieee1275/kernel_exec-cmain.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/ieee1275/kernel_exec-ieee1275.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/ieee1275/kernel_exec-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/ieee1275/kernel_exec-openfw.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ term/ieee1275/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/ieee1275/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/i386/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/i386/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/i386/kernel_exec-tsc_pit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_kernel_exec_OBJECTS = kern/i386/efi/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/i386/efi/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/i386/kernel_exec-tsc_pmtimer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/i386/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ bus/kernel_exec-pci.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/i386/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/i386/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/i386/kernel_exec-tsc_pit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ disk/efi/kernel_exec-efidisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/efi/kernel_exec-efi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/efi/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ term/efi/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/efi/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/efi/kernel_exec-sb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-lockdown.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@am_kernel_exec_OBJECTS = kern/i386/coreboot/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/i386/coreboot/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/i386/pc/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/i386/kernel_exec-tsc_pmtimer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/i386/coreboot/kernel_exec-cbtable.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ video/coreboot/kernel_exec-cbfb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/coreboot/kernel_exec-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/coreboot/kernel_exec-cbtable.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ term/kernel_exec-gfxterm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ font/kernel_exec-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ font/kernel_exec-font_cmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ io/kernel_exec-bufio.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ video/fb/kernel_exec-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ video/fb/kernel_exec-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ video/fb/kernel_exec-fbutil.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ video/fb/kernel_exec-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ video/kernel_exec-video.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ term/i386/pc/kernel_exec-vga_text.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/i386/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/i386/kernel_exec-tsc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/i386/kernel_exec-tsc_pit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@am_kernel_exec_OBJECTS = disk/kernel_exec-host.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/emu/kernel_exec-cache_s.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/emu/kernel_exec-hostdisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ osdep/unix/kernel_exec-hostdisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ osdep/kernel_exec-exec.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ osdep/devmapper/kernel_exec-hostdisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ osdep/kernel_exec-hostdisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/emu/kernel_exec-hostfs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/emu/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/emu/kernel_exec-argp_common.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/emu/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/emu/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/emu/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/emu/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ osdep/kernel_exec-emuconsole.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ osdep/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ osdep/kernel_exec-sleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ osdep/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ osdep/kernel_exec-emunet.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ osdep/kernel_exec-cputime.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_kernel_exec_OBJECTS = kern/arm/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/arm/uboot/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/arm/uboot/kernel_exec-uboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ disk/uboot/kernel_exec-ubootdisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/uboot/kernel_exec-uboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/uboot/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/uboot/kernel_exec-hw.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ term/uboot/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/arm/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/arm/kernel_exec-dl_helper.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/arm/kernel_exec-cache_armv6.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/arm/kernel_exec-cache_armv7.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/arm/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/arm/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ lib/kernel_exec-division.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ term/kernel_exec-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ term/kernel_exec-tparm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ commands/kernel_exec-extcmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ lib/kernel_exec-arg.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@am_kernel_exec_OBJECTS = kern/arm/efi/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/arm/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/efi/kernel_exec-fdt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/arm/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/arm/kernel_exec-dl_helper.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/arm/kernel_exec-cache_armv6.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/arm/kernel_exec-cache_armv7.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/arm/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/arm/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ lib/kernel_exec-division.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ disk/efi/kernel_exec-efidisk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/efi/kernel_exec-efi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/efi/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ term/efi/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/efi/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/efi/kernel_exec-sb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-lockdown.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@am_kernel_exec_OBJECTS = kern/arm/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/coreboot/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/coreboot/kernel_exec-timer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/coreboot/kernel_exec-coreboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ lib/kernel_exec-fdt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ bus/kernel_exec-fdt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ term/kernel_exec-ps2.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ term/arm/kernel_exec-pl050.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ term/arm/kernel_exec-cros.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ term/arm/kernel_exec-cros_ec.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ bus/spi/kernel_exec-rk3288_spi.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ commands/kernel_exec-keylayouts.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/coreboot/kernel_exec-dma.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/coreboot/kernel_exec-cbtable.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ video/coreboot/kernel_exec-cbfb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/coreboot/kernel_exec-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/coreboot/kernel_exec-cbtable.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ term/kernel_exec-gfxterm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ font/kernel_exec-font.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ font/kernel_exec-font_cmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ io/kernel_exec-bufio.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ video/fb/kernel_exec-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ video/fb/kernel_exec-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ video/fb/kernel_exec-fbutil.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ video/fb/kernel_exec-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ video/kernel_exec-video.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/kernel_exec-dl_helper.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/kernel_exec-cache_armv6.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/kernel_exec-cache_armv7.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/arm/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ lib/kernel_exec-division.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_kernel_exec_OBJECTS = kern/arm64/efi/kernel_exec-startup.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/arm64/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/efi/kernel_exec-fdt.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/arm64/kernel_exec-cache.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/arm64/kernel_exec-cache_flush.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/arm64/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/arm64/kernel_exec-dl_helper.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ disk/efi/kernel_exec-efidisk.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/efi/kernel_exec-efi.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/efi/kernel_exec-init.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/efi/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ term/efi/kernel_exec-console.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/efi/kernel_exec-acpi.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/efi/kernel_exec-sb.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-lockdown.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-compiler-rt.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-mm.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-time.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/generic/kernel_exec-millisleep.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-buffer.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-command.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-corecmd.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-device.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-disk.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-dl.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-env.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-err.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-file.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-fs.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-list.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-main.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-misc.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-parser.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-partition.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-rescue_parser.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-rescue_reader.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-term.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ kern/kernel_exec-verifiers.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@nodist_kernel_exec_OBJECTS = kernel_exec-symlist.$(OBJEXT)
+@COND_arm64_efi_TRUE@nodist_kernel_exec_OBJECTS = \
+@COND_arm64_efi_TRUE@ kernel_exec-symlist.$(OBJEXT)
+kernel_exec_OBJECTS = $(am_kernel_exec_OBJECTS) \
+ $(nodist_kernel_exec_OBJECTS)
+kernel_exec_LINK = $(CCLD) $(kernel_exec_CFLAGS) $(CFLAGS) \
+ $(kernel_exec_LDFLAGS) $(LDFLAGS) -o $@
+am__keylayouts_module_SOURCES_DIST = commands/keylayouts.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_keylayouts_module_OBJECTS = commands/keylayouts_module-keylayouts.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_keylayouts_module_OBJECTS = commands/keylayouts_module-keylayouts.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_keylayouts_module_OBJECTS = commands/keylayouts_module-keylayouts.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_keylayouts_module_OBJECTS = commands/keylayouts_module-keylayouts.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_keylayouts_module_OBJECTS = commands/keylayouts_module-keylayouts.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_keylayouts_module_OBJECTS = commands/keylayouts_module-keylayouts.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_keylayouts_module_OBJECTS = commands/keylayouts_module-keylayouts.$(OBJEXT)
+nodist_keylayouts_module_OBJECTS =
+keylayouts_module_OBJECTS = $(am_keylayouts_module_OBJECTS) \
+ $(nodist_keylayouts_module_OBJECTS)
+keylayouts_module_LINK = $(CCLD) $(keylayouts_module_CFLAGS) $(CFLAGS) \
+ $(keylayouts_module_LDFLAGS) $(LDFLAGS) -o $@
+am_keystatus_module_OBJECTS = \
+ commands/keystatus_module-keystatus.$(OBJEXT)
+nodist_keystatus_module_OBJECTS =
+keystatus_module_OBJECTS = $(am_keystatus_module_OBJECTS) \
+ $(nodist_keystatus_module_OBJECTS)
+keystatus_module_LINK = $(CCLD) $(keystatus_module_CFLAGS) $(CFLAGS) \
+ $(keystatus_module_LDFLAGS) $(LDFLAGS) -o $@
+am_ldm_module_OBJECTS = disk/ldm_module-ldm.$(OBJEXT)
+nodist_ldm_module_OBJECTS =
+ldm_module_OBJECTS = $(am_ldm_module_OBJECTS) \
+ $(nodist_ldm_module_OBJECTS)
+ldm_module_LINK = $(CCLD) $(ldm_module_CFLAGS) $(CFLAGS) \
+ $(ldm_module_LDFLAGS) $(LDFLAGS) -o $@
+am__legacy_password_test_module_SOURCES_DIST = \
+ tests/legacy_password_test.c
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_legacy_password_test_module_OBJECTS = tests/legacy_password_test_module-legacy_password_test.$(OBJEXT)
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_TRUE@am_legacy_password_test_module_OBJECTS = tests/legacy_password_test_module-legacy_password_test.$(OBJEXT)
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_legacy_password_test_module_OBJECTS = tests/legacy_password_test_module-legacy_password_test.$(OBJEXT)
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_TRUE@am_legacy_password_test_module_OBJECTS = tests/legacy_password_test_module-legacy_password_test.$(OBJEXT)
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_TRUE@am_legacy_password_test_module_OBJECTS = tests/legacy_password_test_module-legacy_password_test.$(OBJEXT)
+@COND_emu_FALSE@@COND_i386_efi_TRUE@am_legacy_password_test_module_OBJECTS = tests/legacy_password_test_module-legacy_password_test.$(OBJEXT)
+@COND_emu_TRUE@am_legacy_password_test_module_OBJECTS = tests/legacy_password_test_module-legacy_password_test.$(OBJEXT)
+nodist_legacy_password_test_module_OBJECTS =
+legacy_password_test_module_OBJECTS = \
+ $(am_legacy_password_test_module_OBJECTS) \
+ $(nodist_legacy_password_test_module_OBJECTS)
+legacy_password_test_module_LINK = $(CCLD) \
+ $(legacy_password_test_module_CFLAGS) $(CFLAGS) \
+ $(legacy_password_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am__legacycfg_module_SOURCES_DIST = lib/i386/pc/vesa_modes_table.c \
+ commands/legacycfg.c lib/legacy_parse.c
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_legacycfg_module_OBJECTS = lib/i386/pc/legacycfg_module-vesa_modes_table.$(OBJEXT) \
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ commands/legacycfg_module-legacycfg.$(OBJEXT) \
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ lib/legacycfg_module-legacy_parse.$(OBJEXT)
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_TRUE@am_legacycfg_module_OBJECTS = lib/i386/pc/legacycfg_module-vesa_modes_table.$(OBJEXT) \
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_TRUE@ commands/legacycfg_module-legacycfg.$(OBJEXT) \
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_TRUE@ lib/legacycfg_module-legacy_parse.$(OBJEXT)
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_legacycfg_module_OBJECTS = commands/legacycfg_module-legacycfg.$(OBJEXT) \
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/legacycfg_module-legacy_parse.$(OBJEXT)
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_TRUE@am_legacycfg_module_OBJECTS = lib/i386/pc/legacycfg_module-vesa_modes_table.$(OBJEXT) \
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_TRUE@ commands/legacycfg_module-legacycfg.$(OBJEXT) \
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_FALSE@@COND_i386_xen_TRUE@ lib/legacycfg_module-legacy_parse.$(OBJEXT)
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_TRUE@am_legacycfg_module_OBJECTS = commands/legacycfg_module-legacycfg.$(OBJEXT) \
+@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_pc_TRUE@ lib/legacycfg_module-legacy_parse.$(OBJEXT)
+@COND_emu_FALSE@@COND_i386_efi_TRUE@am_legacycfg_module_OBJECTS = lib/i386/pc/legacycfg_module-vesa_modes_table.$(OBJEXT) \
+@COND_emu_FALSE@@COND_i386_efi_TRUE@ commands/legacycfg_module-legacycfg.$(OBJEXT) \
+@COND_emu_FALSE@@COND_i386_efi_TRUE@ lib/legacycfg_module-legacy_parse.$(OBJEXT)
+@COND_emu_TRUE@am_legacycfg_module_OBJECTS = lib/i386/pc/legacycfg_module-vesa_modes_table.$(OBJEXT) \
+@COND_emu_TRUE@ commands/legacycfg_module-legacycfg.$(OBJEXT) \
+@COND_emu_TRUE@ lib/legacycfg_module-legacy_parse.$(OBJEXT)
+nodist_legacycfg_module_OBJECTS =
+legacycfg_module_OBJECTS = $(am_legacycfg_module_OBJECTS) \
+ $(nodist_legacycfg_module_OBJECTS)
+legacycfg_module_LINK = $(CCLD) $(legacycfg_module_CFLAGS) $(CFLAGS) \
+ $(legacycfg_module_LDFLAGS) $(LDFLAGS) -o $@
+am__linux_module_SOURCES_DIST = loader/arm64/linux.c loader/linux.c \
+ lib/cmdline.c loader/arm/linux.c loader/i386/linux.c \
+ lib/i386/pc/vesa_modes_table.c loader/i386/xen.c \
+ loader/ia64/efi/linux.c loader/mips/linux.c \
+ loader/powerpc/ieee1275/linux.c loader/riscv/linux.c \
+ loader/sparc64/ieee1275/linux.c
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_linux_module_OBJECTS = loader/i386/linux_module-xen.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_linux_module_OBJECTS = loader/i386/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_linux_module_OBJECTS = loader/sparc64/ieee1275/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_linux_module_OBJECTS = loader/riscv/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_linux_module_OBJECTS = loader/riscv/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_linux_module_OBJECTS = loader/powerpc/ieee1275/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_linux_module_OBJECTS = loader/mips/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_linux_module_OBJECTS = loader/mips/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_linux_module_OBJECTS = loader/mips/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_linux_module_OBJECTS = loader/ia64/efi/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_linux_module_OBJECTS = loader/i386/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/i386/pc/linux_module-vesa_modes_table.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_linux_module_OBJECTS = loader/i386/linux_module-xen.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_linux_module_OBJECTS = loader/i386/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_linux_module_OBJECTS = lib/i386/pc/linux_module-vesa_modes_table.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ loader/i386/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_linux_module_OBJECTS = loader/i386/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_linux_module_OBJECTS = loader/i386/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_linux_module_OBJECTS = loader/i386/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_TRUE@am_linux_module_OBJECTS = loader/i386/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_i386_coreboot_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_linux_module_OBJECTS = loader/arm/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@am_linux_module_OBJECTS = loader/arm64/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@am_linux_module_OBJECTS = loader/arm/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_linux_module_OBJECTS = loader/arm64/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ loader/linux_module-linux.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ lib/linux_module-cmdline.$(OBJEXT)
+nodist_linux_module_OBJECTS =
+linux_module_OBJECTS = $(am_linux_module_OBJECTS) \
+ $(nodist_linux_module_OBJECTS)
+linux_module_LINK = $(CCLD) $(linux_module_CFLAGS) $(CFLAGS) \
+ $(linux_module_LDFLAGS) $(LDFLAGS) -o $@
+am__linux16_module_SOURCES_DIST = loader/i386/pc/linux.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_linux16_module_OBJECTS = loader/i386/pc/linux16_module-linux.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_linux16_module_OBJECTS = loader/i386/pc/linux16_module-linux.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_linux16_module_OBJECTS = loader/i386/pc/linux16_module-linux.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_linux16_module_OBJECTS = loader/i386/pc/linux16_module-linux.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_linux16_module_OBJECTS = loader/i386/pc/linux16_module-linux.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_linux16_module_OBJECTS = loader/i386/pc/linux16_module-linux.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_linux16_module_OBJECTS = loader/i386/pc/linux16_module-linux.$(OBJEXT)
+nodist_linux16_module_OBJECTS =
+linux16_module_OBJECTS = $(am_linux16_module_OBJECTS) \
+ $(nodist_linux16_module_OBJECTS)
+linux16_module_LINK = $(CCLD) $(linux16_module_CFLAGS) $(CFLAGS) \
+ $(linux16_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lnxboot_image_SOURCES_DIST = boot/i386/pc/lnxboot.S
+@COND_i386_pc_TRUE@am_lnxboot_image_OBJECTS = boot/i386/pc/lnxboot_image-lnxboot.$(OBJEXT)
+nodist_lnxboot_image_OBJECTS =
+lnxboot_image_OBJECTS = $(am_lnxboot_image_OBJECTS) \
+ $(nodist_lnxboot_image_OBJECTS)
+lnxboot_image_DEPENDENCIES =
+lnxboot_image_LINK = $(CCLD) $(lnxboot_image_CFLAGS) $(CFLAGS) \
+ $(lnxboot_image_LDFLAGS) $(LDFLAGS) -o $@
+am__loadbios_module_SOURCES_DIST = commands/efi/loadbios.c
+@COND_i386_efi_FALSE@@COND_x86_64_efi_TRUE@am_loadbios_module_OBJECTS = commands/efi/loadbios_module-loadbios.$(OBJEXT)
+@COND_i386_efi_TRUE@am_loadbios_module_OBJECTS = commands/efi/loadbios_module-loadbios.$(OBJEXT)
+nodist_loadbios_module_OBJECTS =
+loadbios_module_OBJECTS = $(am_loadbios_module_OBJECTS) \
+ $(nodist_loadbios_module_OBJECTS)
+loadbios_module_LINK = $(CCLD) $(loadbios_module_CFLAGS) $(CFLAGS) \
+ $(loadbios_module_LDFLAGS) $(LDFLAGS) -o $@
+am_loadenv_module_OBJECTS = commands/loadenv_module-loadenv.$(OBJEXT) \
+ lib/loadenv_module-envblk.$(OBJEXT)
+nodist_loadenv_module_OBJECTS =
+loadenv_module_OBJECTS = $(am_loadenv_module_OBJECTS) \
+ $(nodist_loadenv_module_OBJECTS)
+loadenv_module_LINK = $(CCLD) $(loadenv_module_CFLAGS) $(CFLAGS) \
+ $(loadenv_module_LDFLAGS) $(LDFLAGS) -o $@
+am_loopback_module_OBJECTS = disk/loopback_module-loopback.$(OBJEXT)
+nodist_loopback_module_OBJECTS =
+loopback_module_OBJECTS = $(am_loopback_module_OBJECTS) \
+ $(nodist_loopback_module_OBJECTS)
+loopback_module_LINK = $(CCLD) $(loopback_module_CFLAGS) $(CFLAGS) \
+ $(loopback_module_LDFLAGS) $(LDFLAGS) -o $@
+am_ls_module_OBJECTS = commands/ls_module-ls.$(OBJEXT)
+nodist_ls_module_OBJECTS =
+ls_module_OBJECTS = $(am_ls_module_OBJECTS) \
+ $(nodist_ls_module_OBJECTS)
+ls_module_LINK = $(CCLD) $(ls_module_CFLAGS) $(CFLAGS) \
+ $(ls_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lsacpi_module_SOURCES_DIST = commands/lsacpi.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_lsacpi_module_OBJECTS = commands/lsacpi_module-lsacpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_lsacpi_module_OBJECTS = commands/lsacpi_module-lsacpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_lsacpi_module_OBJECTS = commands/lsacpi_module-lsacpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_TRUE@am_lsacpi_module_OBJECTS = commands/lsacpi_module-lsacpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_lsacpi_module_OBJECTS = commands/lsacpi_module-lsacpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@am_lsacpi_module_OBJECTS = commands/lsacpi_module-lsacpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_lsacpi_module_OBJECTS = commands/lsacpi_module-lsacpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@am_lsacpi_module_OBJECTS = commands/lsacpi_module-lsacpi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_lsacpi_module_OBJECTS = commands/lsacpi_module-lsacpi.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_lsacpi_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ commands/lsacpi_module-lsacpi.$(OBJEXT)
+nodist_lsacpi_module_OBJECTS =
+lsacpi_module_OBJECTS = $(am_lsacpi_module_OBJECTS) \
+ $(nodist_lsacpi_module_OBJECTS)
+lsacpi_module_LINK = $(CCLD) $(lsacpi_module_CFLAGS) $(CFLAGS) \
+ $(lsacpi_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lsapm_module_SOURCES_DIST = commands/i386/pc/lsapm.c
+@COND_i386_pc_TRUE@am_lsapm_module_OBJECTS = commands/i386/pc/lsapm_module-lsapm.$(OBJEXT)
+nodist_lsapm_module_OBJECTS =
+lsapm_module_OBJECTS = $(am_lsapm_module_OBJECTS) \
+ $(nodist_lsapm_module_OBJECTS)
+lsapm_module_LINK = $(CCLD) $(lsapm_module_CFLAGS) $(CFLAGS) \
+ $(lsapm_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lsdev_module_SOURCES_DIST = commands/arc/lsdev.c
+@COND_mips_arc_TRUE@am_lsdev_module_OBJECTS = \
+@COND_mips_arc_TRUE@ commands/arc/lsdev_module-lsdev.$(OBJEXT)
+nodist_lsdev_module_OBJECTS =
+lsdev_module_OBJECTS = $(am_lsdev_module_OBJECTS) \
+ $(nodist_lsdev_module_OBJECTS)
+lsdev_module_LINK = $(CCLD) $(lsdev_module_CFLAGS) $(CFLAGS) \
+ $(lsdev_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lsefi_module_SOURCES_DIST = commands/efi/lsefi.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_lsefi_module_OBJECTS = commands/efi/lsefi_module-lsefi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_lsefi_module_OBJECTS = commands/efi/lsefi_module-lsefi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_lsefi_module_OBJECTS = commands/efi/lsefi_module-lsefi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_TRUE@am_lsefi_module_OBJECTS = commands/efi/lsefi_module-lsefi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_TRUE@am_lsefi_module_OBJECTS = commands/efi/lsefi_module-lsefi.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_lsefi_module_OBJECTS = commands/efi/lsefi_module-lsefi.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_lsefi_module_OBJECTS = commands/efi/lsefi_module-lsefi.$(OBJEXT)
+nodist_lsefi_module_OBJECTS =
+lsefi_module_OBJECTS = $(am_lsefi_module_OBJECTS) \
+ $(nodist_lsefi_module_OBJECTS)
+lsefi_module_LINK = $(CCLD) $(lsefi_module_CFLAGS) $(CFLAGS) \
+ $(lsefi_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lsefimmap_module_SOURCES_DIST = commands/efi/lsefimmap.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_lsefimmap_module_OBJECTS = commands/efi/lsefimmap_module-lsefimmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_lsefimmap_module_OBJECTS = commands/efi/lsefimmap_module-lsefimmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_lsefimmap_module_OBJECTS = commands/efi/lsefimmap_module-lsefimmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_TRUE@am_lsefimmap_module_OBJECTS = commands/efi/lsefimmap_module-lsefimmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_TRUE@am_lsefimmap_module_OBJECTS = commands/efi/lsefimmap_module-lsefimmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_lsefimmap_module_OBJECTS = commands/efi/lsefimmap_module-lsefimmap.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_lsefimmap_module_OBJECTS = commands/efi/lsefimmap_module-lsefimmap.$(OBJEXT)
+nodist_lsefimmap_module_OBJECTS =
+lsefimmap_module_OBJECTS = $(am_lsefimmap_module_OBJECTS) \
+ $(nodist_lsefimmap_module_OBJECTS)
+lsefimmap_module_LINK = $(CCLD) $(lsefimmap_module_CFLAGS) $(CFLAGS) \
+ $(lsefimmap_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lsefisystab_module_SOURCES_DIST = commands/efi/lsefisystab.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_lsefisystab_module_OBJECTS = commands/efi/lsefisystab_module-lsefisystab.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_lsefisystab_module_OBJECTS = commands/efi/lsefisystab_module-lsefisystab.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_lsefisystab_module_OBJECTS = commands/efi/lsefisystab_module-lsefisystab.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_TRUE@am_lsefisystab_module_OBJECTS = commands/efi/lsefisystab_module-lsefisystab.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_TRUE@am_lsefisystab_module_OBJECTS = commands/efi/lsefisystab_module-lsefisystab.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_lsefisystab_module_OBJECTS = commands/efi/lsefisystab_module-lsefisystab.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_lsefisystab_module_OBJECTS = commands/efi/lsefisystab_module-lsefisystab.$(OBJEXT)
+nodist_lsefisystab_module_OBJECTS =
+lsefisystab_module_OBJECTS = $(am_lsefisystab_module_OBJECTS) \
+ $(nodist_lsefisystab_module_OBJECTS)
+lsefisystab_module_LINK = $(CCLD) $(lsefisystab_module_CFLAGS) \
+ $(CFLAGS) $(lsefisystab_module_LDFLAGS) $(LDFLAGS) -o $@
+am_lsmmap_module_OBJECTS = commands/lsmmap_module-lsmmap.$(OBJEXT)
+nodist_lsmmap_module_OBJECTS =
+lsmmap_module_OBJECTS = $(am_lsmmap_module_OBJECTS) \
+ $(nodist_lsmmap_module_OBJECTS)
+lsmmap_module_LINK = $(CCLD) $(lsmmap_module_CFLAGS) $(CFLAGS) \
+ $(lsmmap_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lspci_module_SOURCES_DIST = commands/lspci.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_lspci_module_OBJECTS = commands/lspci_module-lspci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_lspci_module_OBJECTS = commands/lspci_module-lspci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_lspci_module_OBJECTS = commands/lspci_module-lspci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_lspci_module_OBJECTS = commands/lspci_module-lspci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_lspci_module_OBJECTS = commands/lspci_module-lspci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_lspci_module_OBJECTS = commands/lspci_module-lspci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_lspci_module_OBJECTS = commands/lspci_module-lspci.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_lspci_module_OBJECTS = commands/lspci_module-lspci.$(OBJEXT)
+nodist_lspci_module_OBJECTS =
+lspci_module_OBJECTS = $(am_lspci_module_OBJECTS) \
+ $(nodist_lspci_module_OBJECTS)
+lspci_module_LINK = $(CCLD) $(lspci_module_CFLAGS) $(CFLAGS) \
+ $(lspci_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lssal_module_SOURCES_DIST = commands/efi/lssal.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_lssal_module_OBJECTS = commands/efi/lssal_module-lssal.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_lssal_module_OBJECTS = commands/efi/lssal_module-lssal.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_lssal_module_OBJECTS = commands/efi/lssal_module-lssal.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_TRUE@am_lssal_module_OBJECTS = commands/efi/lssal_module-lssal.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_TRUE@am_lssal_module_OBJECTS = commands/efi/lssal_module-lssal.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_lssal_module_OBJECTS = commands/efi/lssal_module-lssal.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_lssal_module_OBJECTS = commands/efi/lssal_module-lssal.$(OBJEXT)
+nodist_lssal_module_OBJECTS =
+lssal_module_OBJECTS = $(am_lssal_module_OBJECTS) \
+ $(nodist_lssal_module_OBJECTS)
+lssal_module_LINK = $(CCLD) $(lssal_module_CFLAGS) $(CFLAGS) \
+ $(lssal_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lsspd_module_SOURCES_DIST = commands/mips/loongson/lsspd.c
+@COND_mips_loongson_TRUE@am_lsspd_module_OBJECTS = commands/mips/loongson/lsspd_module-lsspd.$(OBJEXT)
+nodist_lsspd_module_OBJECTS =
+lsspd_module_OBJECTS = $(am_lsspd_module_OBJECTS) \
+ $(nodist_lsspd_module_OBJECTS)
+lsspd_module_LINK = $(CCLD) $(lsspd_module_CFLAGS) $(CFLAGS) \
+ $(lsspd_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lsxen_module_SOURCES_DIST = commands/xen/lsxen.c
+@COND_i386_xen_FALSE@@COND_x86_64_xen_TRUE@am_lsxen_module_OBJECTS = commands/xen/lsxen_module-lsxen.$(OBJEXT)
+@COND_i386_xen_TRUE@am_lsxen_module_OBJECTS = \
+@COND_i386_xen_TRUE@ commands/xen/lsxen_module-lsxen.$(OBJEXT)
+nodist_lsxen_module_OBJECTS =
+lsxen_module_OBJECTS = $(am_lsxen_module_OBJECTS) \
+ $(nodist_lsxen_module_OBJECTS)
+lsxen_module_LINK = $(CCLD) $(lsxen_module_CFLAGS) $(CFLAGS) \
+ $(lsxen_module_LDFLAGS) $(LDFLAGS) -o $@
+am_luks_module_OBJECTS = disk/luks_module-luks.$(OBJEXT)
+nodist_luks_module_OBJECTS =
+luks_module_OBJECTS = $(am_luks_module_OBJECTS) \
+ $(nodist_luks_module_OBJECTS)
+luks_module_LINK = $(CCLD) $(luks_module_CFLAGS) $(CFLAGS) \
+ $(luks_module_LDFLAGS) $(LDFLAGS) -o $@
+am_luks2_module_OBJECTS = disk/luks2_module-luks2.$(OBJEXT) \
+ lib/gnulib/luks2_module-base64.$(OBJEXT)
+nodist_luks2_module_OBJECTS =
+luks2_module_OBJECTS = $(am_luks2_module_OBJECTS) \
+ $(nodist_luks2_module_OBJECTS)
+luks2_module_LINK = $(CCLD) $(luks2_module_CFLAGS) $(CFLAGS) \
+ $(luks2_module_LDFLAGS) $(LDFLAGS) -o $@
+am_lvm_module_OBJECTS = disk/lvm_module-lvm.$(OBJEXT)
+nodist_lvm_module_OBJECTS =
+lvm_module_OBJECTS = $(am_lvm_module_OBJECTS) \
+ $(nodist_lvm_module_OBJECTS)
+lvm_module_LINK = $(CCLD) $(lvm_module_CFLAGS) $(CFLAGS) \
+ $(lvm_module_LDFLAGS) $(LDFLAGS) -o $@
+am__lzma_decompress_image_SOURCES_DIST = boot/i386/pc/startup_raw.S
+@COND_i386_pc_TRUE@am_lzma_decompress_image_OBJECTS = boot/i386/pc/lzma_decompress_image-startup_raw.$(OBJEXT)
+nodist_lzma_decompress_image_OBJECTS =
+lzma_decompress_image_OBJECTS = $(am_lzma_decompress_image_OBJECTS) \
+ $(nodist_lzma_decompress_image_OBJECTS)
+lzma_decompress_image_DEPENDENCIES =
+lzma_decompress_image_LINK = $(CCLD) $(lzma_decompress_image_CFLAGS) \
+ $(CFLAGS) $(lzma_decompress_image_LDFLAGS) $(LDFLAGS) -o $@
+am_lzopio_module_OBJECTS = io/lzopio_module-lzopio.$(OBJEXT) \
+ lib/minilzo/lzopio_module-minilzo.$(OBJEXT)
+nodist_lzopio_module_OBJECTS =
+lzopio_module_OBJECTS = $(am_lzopio_module_OBJECTS) \
+ $(nodist_lzopio_module_OBJECTS)
+lzopio_module_LINK = $(CCLD) $(lzopio_module_CFLAGS) $(CFLAGS) \
+ $(lzopio_module_LDFLAGS) $(LDFLAGS) -o $@
+am_macbless_module_OBJECTS = \
+ commands/macbless_module-macbless.$(OBJEXT)
+nodist_macbless_module_OBJECTS =
+macbless_module_OBJECTS = $(am_macbless_module_OBJECTS) \
+ $(nodist_macbless_module_OBJECTS)
+macbless_module_LINK = $(CCLD) $(macbless_module_CFLAGS) $(CFLAGS) \
+ $(macbless_module_LDFLAGS) $(LDFLAGS) -o $@
+am_macho_module_OBJECTS = loader/macho_module-macho.$(OBJEXT) \
+ loader/macho_module-macho32.$(OBJEXT) \
+ loader/macho_module-macho64.$(OBJEXT) \
+ loader/macho_module-lzss.$(OBJEXT)
+nodist_macho_module_OBJECTS =
+macho_module_OBJECTS = $(am_macho_module_OBJECTS) \
+ $(nodist_macho_module_OBJECTS)
+macho_module_LINK = $(CCLD) $(macho_module_CFLAGS) $(CFLAGS) \
+ $(macho_module_LDFLAGS) $(LDFLAGS) -o $@
+am__mda_text_module_SOURCES_DIST = term/i386/pc/mda_text.c
+@COND_i386_coreboot_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_mda_text_module_OBJECTS = term/i386/pc/mda_text_module-mda_text.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_mda_text_module_OBJECTS = term/i386/pc/mda_text_module-mda_text.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_multiboot_TRUE@am_mda_text_module_OBJECTS = term/i386/pc/mda_text_module-mda_text.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_mda_text_module_OBJECTS = term/i386/pc/mda_text_module-mda_text.$(OBJEXT)
+nodist_mda_text_module_OBJECTS =
+mda_text_module_OBJECTS = $(am_mda_text_module_OBJECTS) \
+ $(nodist_mda_text_module_OBJECTS)
+mda_text_module_LINK = $(CCLD) $(mda_text_module_CFLAGS) $(CFLAGS) \
+ $(mda_text_module_LDFLAGS) $(LDFLAGS) -o $@
+am_mdraid09_module_OBJECTS = \
+ disk/mdraid09_module-mdraid_linux.$(OBJEXT)
+nodist_mdraid09_module_OBJECTS =
+mdraid09_module_OBJECTS = $(am_mdraid09_module_OBJECTS) \
+ $(nodist_mdraid09_module_OBJECTS)
+mdraid09_module_LINK = $(CCLD) $(mdraid09_module_CFLAGS) $(CFLAGS) \
+ $(mdraid09_module_LDFLAGS) $(LDFLAGS) -o $@
+am_mdraid09_be_module_OBJECTS = \
+ disk/mdraid09_be_module-mdraid_linux_be.$(OBJEXT)
+nodist_mdraid09_be_module_OBJECTS =
+mdraid09_be_module_OBJECTS = $(am_mdraid09_be_module_OBJECTS) \
+ $(nodist_mdraid09_be_module_OBJECTS)
+mdraid09_be_module_LINK = $(CCLD) $(mdraid09_be_module_CFLAGS) \
+ $(CFLAGS) $(mdraid09_be_module_LDFLAGS) $(LDFLAGS) -o $@
+am_mdraid1x_module_OBJECTS = \
+ disk/mdraid1x_module-mdraid1x_linux.$(OBJEXT)
+nodist_mdraid1x_module_OBJECTS =
+mdraid1x_module_OBJECTS = $(am_mdraid1x_module_OBJECTS) \
+ $(nodist_mdraid1x_module_OBJECTS)
+mdraid1x_module_LINK = $(CCLD) $(mdraid1x_module_CFLAGS) $(CFLAGS) \
+ $(mdraid1x_module_LDFLAGS) $(LDFLAGS) -o $@
+am_memdisk_module_OBJECTS = disk/memdisk_module-memdisk.$(OBJEXT)
+nodist_memdisk_module_OBJECTS =
+memdisk_module_OBJECTS = $(am_memdisk_module_OBJECTS) \
+ $(nodist_memdisk_module_OBJECTS)
+memdisk_module_LINK = $(CCLD) $(memdisk_module_CFLAGS) $(CFLAGS) \
+ $(memdisk_module_LDFLAGS) $(LDFLAGS) -o $@
+am_memrw_module_OBJECTS = commands/memrw_module-memrw.$(OBJEXT)
+nodist_memrw_module_OBJECTS =
+memrw_module_OBJECTS = $(am_memrw_module_OBJECTS) \
+ $(nodist_memrw_module_OBJECTS)
+memrw_module_LINK = $(CCLD) $(memrw_module_CFLAGS) $(CFLAGS) \
+ $(memrw_module_LDFLAGS) $(LDFLAGS) -o $@
+am_minicmd_module_OBJECTS = commands/minicmd_module-minicmd.$(OBJEXT)
+nodist_minicmd_module_OBJECTS =
+minicmd_module_OBJECTS = $(am_minicmd_module_OBJECTS) \
+ $(nodist_minicmd_module_OBJECTS)
+minicmd_module_LINK = $(CCLD) $(minicmd_module_CFLAGS) $(CFLAGS) \
+ $(minicmd_module_LDFLAGS) $(LDFLAGS) -o $@
+am_minix_module_OBJECTS = fs/minix_module-minix.$(OBJEXT)
+nodist_minix_module_OBJECTS =
+minix_module_OBJECTS = $(am_minix_module_OBJECTS) \
+ $(nodist_minix_module_OBJECTS)
+minix_module_LINK = $(CCLD) $(minix_module_CFLAGS) $(CFLAGS) \
+ $(minix_module_LDFLAGS) $(LDFLAGS) -o $@
+am_minix2_module_OBJECTS = fs/minix2_module-minix2.$(OBJEXT)
+nodist_minix2_module_OBJECTS =
+minix2_module_OBJECTS = $(am_minix2_module_OBJECTS) \
+ $(nodist_minix2_module_OBJECTS)
+minix2_module_LINK = $(CCLD) $(minix2_module_CFLAGS) $(CFLAGS) \
+ $(minix2_module_LDFLAGS) $(LDFLAGS) -o $@
+am_minix2_be_module_OBJECTS = fs/minix2_be_module-minix2_be.$(OBJEXT)
+nodist_minix2_be_module_OBJECTS =
+minix2_be_module_OBJECTS = $(am_minix2_be_module_OBJECTS) \
+ $(nodist_minix2_be_module_OBJECTS)
+minix2_be_module_LINK = $(CCLD) $(minix2_be_module_CFLAGS) $(CFLAGS) \
+ $(minix2_be_module_LDFLAGS) $(LDFLAGS) -o $@
+am_minix3_module_OBJECTS = fs/minix3_module-minix3.$(OBJEXT)
+nodist_minix3_module_OBJECTS =
+minix3_module_OBJECTS = $(am_minix3_module_OBJECTS) \
+ $(nodist_minix3_module_OBJECTS)
+minix3_module_LINK = $(CCLD) $(minix3_module_CFLAGS) $(CFLAGS) \
+ $(minix3_module_LDFLAGS) $(LDFLAGS) -o $@
+am_minix3_be_module_OBJECTS = fs/minix3_be_module-minix3_be.$(OBJEXT)
+nodist_minix3_be_module_OBJECTS =
+minix3_be_module_OBJECTS = $(am_minix3_be_module_OBJECTS) \
+ $(nodist_minix3_be_module_OBJECTS)
+minix3_be_module_LINK = $(CCLD) $(minix3_be_module_CFLAGS) $(CFLAGS) \
+ $(minix3_be_module_LDFLAGS) $(LDFLAGS) -o $@
+am_minix_be_module_OBJECTS = fs/minix_be_module-minix_be.$(OBJEXT)
+nodist_minix_be_module_OBJECTS =
+minix_be_module_OBJECTS = $(am_minix_be_module_OBJECTS) \
+ $(nodist_minix_be_module_OBJECTS)
+minix_be_module_LINK = $(CCLD) $(minix_be_module_CFLAGS) $(CFLAGS) \
+ $(minix_be_module_LDFLAGS) $(LDFLAGS) -o $@
+am__mmap_module_SOURCES_DIST = mmap/efi/mmap.c mmap/mmap.c \
+ mmap/i386/uppermem.c mmap/i386/mmap.c mmap/i386/pc/mmap.c \
+ mmap/i386/pc/mmap_helper.S mmap/mips/uppermem.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_mmap_module_OBJECTS = mmap/i386/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@ mmap/i386/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@ mmap/efi/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_mmap_module_OBJECTS = mmap/efi/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_riscv32_efi_TRUE@am_mmap_module_OBJECTS = mmap/efi/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_riscv32_efi_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_mmap_module_OBJECTS = mmap/mips/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_mmap_module_OBJECTS = mmap/mips/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_mmap_module_OBJECTS = mmap/mips/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_mmap_module_OBJECTS = mmap/efi/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_TRUE@am_mmap_module_OBJECTS = mmap/i386/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_TRUE@ mmap/i386/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_mmap_module_OBJECTS = mmap/i386/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ mmap/i386/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_mmap_module_OBJECTS = mmap/i386/pc/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ mmap/i386/pc/mmap_module-mmap_helper.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ mmap/i386/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ mmap/i386/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_mmap_module_OBJECTS = mmap/i386/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ mmap/i386/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_mmap_module_OBJECTS = mmap/i386/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ mmap/i386/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_mmap_module_OBJECTS = mmap/i386/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ mmap/i386/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ mmap/efi/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@am_mmap_module_OBJECTS = mmap/i386/mmap_module-uppermem.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@ mmap/i386/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_mmap_module_OBJECTS = mmap/efi/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_mmap_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ mmap/efi/mmap_module-mmap.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ mmap/mmap_module-mmap.$(OBJEXT)
+nodist_mmap_module_OBJECTS =
+mmap_module_OBJECTS = $(am_mmap_module_OBJECTS) \
+ $(nodist_mmap_module_OBJECTS)
+mmap_module_LINK = $(CCLD) $(mmap_module_CFLAGS) $(CFLAGS) \
+ $(mmap_module_LDFLAGS) $(LDFLAGS) -o $@
+am__morse_module_SOURCES_DIST = term/morse.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_morse_module_OBJECTS = term/morse_module-morse.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_morse_module_OBJECTS = term/morse_module-morse.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_morse_module_OBJECTS = term/morse_module-morse.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_morse_module_OBJECTS = term/morse_module-morse.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_morse_module_OBJECTS = term/morse_module-morse.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_morse_module_OBJECTS = term/morse_module-morse.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_morse_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ term/morse_module-morse.$(OBJEXT)
+nodist_morse_module_OBJECTS =
+morse_module_OBJECTS = $(am_morse_module_OBJECTS) \
+ $(nodist_morse_module_OBJECTS)
+morse_module_LINK = $(CCLD) $(morse_module_CFLAGS) $(CFLAGS) \
+ $(morse_module_LDFLAGS) $(LDFLAGS) -o $@
+am_mpi_module_OBJECTS = \
+ lib/libgcrypt-grub/mpi/mpi_module-mpiutil.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-add.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-div.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpih-div.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpicoder.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.$(OBJEXT) \
+ lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.$(OBJEXT) \
+ lib/libgcrypt_wrap/mpi_module-mem.$(OBJEXT)
+nodist_mpi_module_OBJECTS =
+mpi_module_OBJECTS = $(am_mpi_module_OBJECTS) \
+ $(nodist_mpi_module_OBJECTS)
+mpi_module_LINK = $(CCLD) $(mpi_module_CFLAGS) $(CFLAGS) \
+ $(mpi_module_LDFLAGS) $(LDFLAGS) -o $@
+am_msdospart_module_OBJECTS = \
+ parttool/msdospart_module-msdospart.$(OBJEXT)
+nodist_msdospart_module_OBJECTS =
+msdospart_module_OBJECTS = $(am_msdospart_module_OBJECTS) \
+ $(nodist_msdospart_module_OBJECTS)
+msdospart_module_LINK = $(CCLD) $(msdospart_module_CFLAGS) $(CFLAGS) \
+ $(msdospart_module_LDFLAGS) $(LDFLAGS) -o $@
+am_mul_test_module_OBJECTS = tests/mul_test_module-mul_test.$(OBJEXT)
+nodist_mul_test_module_OBJECTS =
+mul_test_module_OBJECTS = $(am_mul_test_module_OBJECTS) \
+ $(nodist_mul_test_module_OBJECTS)
+mul_test_module_LINK = $(CCLD) $(mul_test_module_CFLAGS) $(CFLAGS) \
+ $(mul_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am__multiboot_module_SOURCES_DIST = loader/i386/multiboot_mbi.c \
+ loader/multiboot.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_TRUE@am_multiboot_module_OBJECTS = loader/i386/multiboot_module-multiboot_mbi.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_x86_64_efi_TRUE@ loader/multiboot_module-multiboot.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_TRUE@am_multiboot_module_OBJECTS = loader/i386/multiboot_module-multiboot_mbi.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_TRUE@ loader/multiboot_module-multiboot.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_multiboot_module_OBJECTS = loader/i386/multiboot_module-multiboot_mbi.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ loader/multiboot_module-multiboot.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_multiboot_module_OBJECTS = loader/i386/multiboot_module-multiboot_mbi.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ loader/multiboot_module-multiboot.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_multiboot_module_OBJECTS = loader/i386/multiboot_module-multiboot_mbi.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ loader/multiboot_module-multiboot.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_multiboot_module_OBJECTS = loader/i386/multiboot_module-multiboot_mbi.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ loader/multiboot_module-multiboot.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_multiboot_module_OBJECTS = loader/i386/multiboot_module-multiboot_mbi.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ loader/multiboot_module-multiboot.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_multiboot_module_OBJECTS = loader/i386/multiboot_module-multiboot_mbi.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ loader/multiboot_module-multiboot.$(OBJEXT)
+nodist_multiboot_module_OBJECTS =
+multiboot_module_OBJECTS = $(am_multiboot_module_OBJECTS) \
+ $(nodist_multiboot_module_OBJECTS)
+multiboot_module_LINK = $(CCLD) $(multiboot_module_CFLAGS) $(CFLAGS) \
+ $(multiboot_module_LDFLAGS) $(LDFLAGS) -o $@
+am__multiboot2_module_SOURCES_DIST = loader/multiboot.c \
+ loader/multiboot_mbi2.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_pvh_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_multiboot2_module_OBJECTS = loader/multiboot2_module-multiboot.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ loader/multiboot2_module-multiboot_mbi2.$(OBJEXT)
+nodist_multiboot2_module_OBJECTS =
+multiboot2_module_OBJECTS = $(am_multiboot2_module_OBJECTS) \
+ $(nodist_multiboot2_module_OBJECTS)
+multiboot2_module_LINK = $(CCLD) $(multiboot2_module_CFLAGS) $(CFLAGS) \
+ $(multiboot2_module_LDFLAGS) $(LDFLAGS) -o $@
+am__nand_module_SOURCES_DIST = disk/ieee1275/nand.c
+@COND_i386_ieee1275_TRUE@am_nand_module_OBJECTS = disk/ieee1275/nand_module-nand.$(OBJEXT)
+nodist_nand_module_OBJECTS =
+nand_module_OBJECTS = $(am_nand_module_OBJECTS) \
+ $(nodist_nand_module_OBJECTS)
+nand_module_LINK = $(CCLD) $(nand_module_CFLAGS) $(CFLAGS) \
+ $(nand_module_LDFLAGS) $(LDFLAGS) -o $@
+am__nativedisk_module_SOURCES_DIST = commands/nativedisk.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_TRUE@am_nativedisk_module_OBJECTS = commands/nativedisk_module-nativedisk.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_nativedisk_module_OBJECTS = commands/nativedisk_module-nativedisk.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_nativedisk_module_OBJECTS = commands/nativedisk_module-nativedisk.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_nativedisk_module_OBJECTS = commands/nativedisk_module-nativedisk.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_nativedisk_module_OBJECTS = commands/nativedisk_module-nativedisk.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_nativedisk_module_OBJECTS = commands/nativedisk_module-nativedisk.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_nativedisk_module_OBJECTS = commands/nativedisk_module-nativedisk.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_nativedisk_module_OBJECTS = commands/nativedisk_module-nativedisk.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_nativedisk_module_OBJECTS = commands/nativedisk_module-nativedisk.$(OBJEXT)
+nodist_nativedisk_module_OBJECTS =
+nativedisk_module_OBJECTS = $(am_nativedisk_module_OBJECTS) \
+ $(nodist_nativedisk_module_OBJECTS)
+nativedisk_module_LINK = $(CCLD) $(nativedisk_module_CFLAGS) $(CFLAGS) \
+ $(nativedisk_module_LDFLAGS) $(LDFLAGS) -o $@
+am_net_module_OBJECTS = net/net_module-net.$(OBJEXT) \
+ net/net_module-dns.$(OBJEXT) net/net_module-bootp.$(OBJEXT) \
+ net/net_module-ip.$(OBJEXT) net/net_module-udp.$(OBJEXT) \
+ net/net_module-tcp.$(OBJEXT) net/net_module-icmp.$(OBJEXT) \
+ net/net_module-icmp6.$(OBJEXT) \
+ net/net_module-ethernet.$(OBJEXT) net/net_module-arp.$(OBJEXT) \
+ net/net_module-netbuff.$(OBJEXT)
+nodist_net_module_OBJECTS =
+net_module_OBJECTS = $(am_net_module_OBJECTS) \
+ $(nodist_net_module_OBJECTS)
+net_module_LINK = $(CCLD) $(net_module_CFLAGS) $(CFLAGS) \
+ $(net_module_LDFLAGS) $(LDFLAGS) -o $@
+am_newc_module_OBJECTS = fs/newc_module-newc.$(OBJEXT)
+nodist_newc_module_OBJECTS =
+newc_module_OBJECTS = $(am_newc_module_OBJECTS) \
+ $(nodist_newc_module_OBJECTS)
+newc_module_LINK = $(CCLD) $(newc_module_CFLAGS) $(CFLAGS) \
+ $(newc_module_LDFLAGS) $(LDFLAGS) -o $@
+am_nilfs2_module_OBJECTS = fs/nilfs2_module-nilfs2.$(OBJEXT)
+nodist_nilfs2_module_OBJECTS =
+nilfs2_module_OBJECTS = $(am_nilfs2_module_OBJECTS) \
+ $(nodist_nilfs2_module_OBJECTS)
+nilfs2_module_LINK = $(CCLD) $(nilfs2_module_CFLAGS) $(CFLAGS) \
+ $(nilfs2_module_LDFLAGS) $(LDFLAGS) -o $@
+am__none_decompress_image_SOURCES_DIST = boot/mips/startup_raw.S \
+ boot/decompressor/none.c
+@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_none_decompress_image_OBJECTS = boot/mips/none_decompress_image-startup_raw.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ boot/decompressor/none_decompress_image-none.$(OBJEXT)
+@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_none_decompress_image_OBJECTS = boot/mips/none_decompress_image-startup_raw.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ boot/decompressor/none_decompress_image-none.$(OBJEXT)
+@COND_mips_arc_TRUE@am_none_decompress_image_OBJECTS = boot/mips/none_decompress_image-startup_raw.$(OBJEXT) \
+@COND_mips_arc_TRUE@ boot/decompressor/none_decompress_image-none.$(OBJEXT)
+nodist_none_decompress_image_OBJECTS =
+none_decompress_image_OBJECTS = $(am_none_decompress_image_OBJECTS) \
+ $(nodist_none_decompress_image_OBJECTS)
+none_decompress_image_DEPENDENCIES =
+none_decompress_image_LINK = $(CCLD) $(none_decompress_image_CFLAGS) \
+ $(CFLAGS) $(none_decompress_image_LDFLAGS) $(LDFLAGS) -o $@
+am_normal_module_OBJECTS = normal/normal_module-main.$(OBJEXT) \
+ normal/normal_module-cmdline.$(OBJEXT) \
+ normal/normal_module-dyncmd.$(OBJEXT) \
+ normal/normal_module-auth.$(OBJEXT) \
+ normal/normal_module-autofs.$(OBJEXT) \
+ normal/normal_module-color.$(OBJEXT) \
+ normal/normal_module-completion.$(OBJEXT) \
+ normal/normal_module-menu.$(OBJEXT) \
+ normal/normal_module-menu_entry.$(OBJEXT) \
+ normal/normal_module-menu_text.$(OBJEXT) \
+ normal/normal_module-misc.$(OBJEXT) \
+ normal/normal_module-crypto.$(OBJEXT) \
+ normal/normal_module-term.$(OBJEXT) \
+ normal/normal_module-context.$(OBJEXT) \
+ normal/normal_module-charset.$(OBJEXT) \
+ lib/normal_module-getline.$(OBJEXT) \
+ script/normal_module-main.$(OBJEXT) \
+ script/normal_module-script.$(OBJEXT) \
+ script/normal_module-execute.$(OBJEXT) \
+ script/normal_module-function.$(OBJEXT) \
+ script/normal_module-lexer.$(OBJEXT) \
+ script/normal_module-argv.$(OBJEXT) \
+ commands/normal_module-menuentry.$(OBJEXT) \
+ normal_module-unidata.$(OBJEXT)
+nodist_normal_module_OBJECTS = \
+ normal_module-grub_script.tab.$(OBJEXT) \
+ normal_module-grub_script.yy.$(OBJEXT)
+normal_module_OBJECTS = $(am_normal_module_OBJECTS) \
+ $(nodist_normal_module_OBJECTS)
+normal_module_LINK = $(CCLD) $(normal_module_CFLAGS) $(CFLAGS) \
+ $(normal_module_LDFLAGS) $(LDFLAGS) -o $@
+am_ntfs_module_OBJECTS = fs/ntfs_module-ntfs.$(OBJEXT)
+nodist_ntfs_module_OBJECTS =
+ntfs_module_OBJECTS = $(am_ntfs_module_OBJECTS) \
+ $(nodist_ntfs_module_OBJECTS)
+ntfs_module_LINK = $(CCLD) $(ntfs_module_CFLAGS) $(CFLAGS) \
+ $(ntfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am_ntfscomp_module_OBJECTS = fs/ntfscomp_module-ntfscomp.$(OBJEXT)
+nodist_ntfscomp_module_OBJECTS =
+ntfscomp_module_OBJECTS = $(am_ntfscomp_module_OBJECTS) \
+ $(nodist_ntfscomp_module_OBJECTS)
+ntfscomp_module_LINK = $(CCLD) $(ntfscomp_module_CFLAGS) $(CFLAGS) \
+ $(ntfscomp_module_LDFLAGS) $(LDFLAGS) -o $@
+am__ntldr_module_SOURCES_DIST = loader/i386/pc/ntldr.c
+@COND_i386_pc_TRUE@am_ntldr_module_OBJECTS = loader/i386/pc/ntldr_module-ntldr.$(OBJEXT)
+nodist_ntldr_module_OBJECTS =
+ntldr_module_OBJECTS = $(am_ntldr_module_OBJECTS) \
+ $(nodist_ntldr_module_OBJECTS)
+ntldr_module_LINK = $(CCLD) $(ntldr_module_CFLAGS) $(CFLAGS) \
+ $(ntldr_module_LDFLAGS) $(LDFLAGS) -o $@
+am_odc_module_OBJECTS = fs/odc_module-odc.$(OBJEXT)
+nodist_odc_module_OBJECTS =
+odc_module_OBJECTS = $(am_odc_module_OBJECTS) \
+ $(nodist_odc_module_OBJECTS)
+odc_module_LINK = $(CCLD) $(odc_module_CFLAGS) $(CFLAGS) \
+ $(odc_module_LDFLAGS) $(LDFLAGS) -o $@
+am_offsetio_module_OBJECTS = io/offsetio_module-offset.$(OBJEXT)
+nodist_offsetio_module_OBJECTS =
+offsetio_module_OBJECTS = $(am_offsetio_module_OBJECTS) \
+ $(nodist_offsetio_module_OBJECTS)
+offsetio_module_LINK = $(CCLD) $(offsetio_module_CFLAGS) $(CFLAGS) \
+ $(offsetio_module_LDFLAGS) $(LDFLAGS) -o $@
+am__ofnet_module_SOURCES_DIST = net/drivers/ieee1275/ofnet.c
+@COND_i386_ieee1275_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_sparc64_ieee1275_TRUE@am_ofnet_module_OBJECTS = net/drivers/ieee1275/ofnet_module-ofnet.$(OBJEXT)
+@COND_i386_ieee1275_FALSE@@COND_powerpc_ieee1275_TRUE@am_ofnet_module_OBJECTS = net/drivers/ieee1275/ofnet_module-ofnet.$(OBJEXT)
+@COND_i386_ieee1275_TRUE@am_ofnet_module_OBJECTS = net/drivers/ieee1275/ofnet_module-ofnet.$(OBJEXT)
+nodist_ofnet_module_OBJECTS =
+ofnet_module_OBJECTS = $(am_ofnet_module_OBJECTS) \
+ $(nodist_ofnet_module_OBJECTS)
+ofnet_module_LINK = $(CCLD) $(ofnet_module_CFLAGS) $(CFLAGS) \
+ $(ofnet_module_LDFLAGS) $(LDFLAGS) -o $@
+am__ohci_module_SOURCES_DIST = bus/usb/ohci.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_ohci_module_OBJECTS = bus/usb/ohci_module-ohci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_ohci_module_OBJECTS = bus/usb/ohci_module-ohci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_ohci_module_OBJECTS = bus/usb/ohci_module-ohci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_ohci_module_OBJECTS = bus/usb/ohci_module-ohci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_ohci_module_OBJECTS = bus/usb/ohci_module-ohci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_ohci_module_OBJECTS = bus/usb/ohci_module-ohci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_ohci_module_OBJECTS = bus/usb/ohci_module-ohci.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_ohci_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ bus/usb/ohci_module-ohci.$(OBJEXT)
+nodist_ohci_module_OBJECTS =
+ohci_module_OBJECTS = $(am_ohci_module_OBJECTS) \
+ $(nodist_ohci_module_OBJECTS)
+ohci_module_LINK = $(CCLD) $(ohci_module_CFLAGS) $(CFLAGS) \
+ $(ohci_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_acorn_module_OBJECTS = \
+ partmap/part_acorn_module-acorn.$(OBJEXT)
+nodist_part_acorn_module_OBJECTS =
+part_acorn_module_OBJECTS = $(am_part_acorn_module_OBJECTS) \
+ $(nodist_part_acorn_module_OBJECTS)
+part_acorn_module_LINK = $(CCLD) $(part_acorn_module_CFLAGS) $(CFLAGS) \
+ $(part_acorn_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_amiga_module_OBJECTS = \
+ partmap/part_amiga_module-amiga.$(OBJEXT)
+nodist_part_amiga_module_OBJECTS =
+part_amiga_module_OBJECTS = $(am_part_amiga_module_OBJECTS) \
+ $(nodist_part_amiga_module_OBJECTS)
+part_amiga_module_LINK = $(CCLD) $(part_amiga_module_CFLAGS) $(CFLAGS) \
+ $(part_amiga_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_apple_module_OBJECTS = \
+ partmap/part_apple_module-apple.$(OBJEXT)
+nodist_part_apple_module_OBJECTS =
+part_apple_module_OBJECTS = $(am_part_apple_module_OBJECTS) \
+ $(nodist_part_apple_module_OBJECTS)
+part_apple_module_LINK = $(CCLD) $(part_apple_module_CFLAGS) $(CFLAGS) \
+ $(part_apple_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_bsd_module_OBJECTS = \
+ partmap/part_bsd_module-bsdlabel.$(OBJEXT)
+nodist_part_bsd_module_OBJECTS =
+part_bsd_module_OBJECTS = $(am_part_bsd_module_OBJECTS) \
+ $(nodist_part_bsd_module_OBJECTS)
+part_bsd_module_LINK = $(CCLD) $(part_bsd_module_CFLAGS) $(CFLAGS) \
+ $(part_bsd_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_dfly_module_OBJECTS = partmap/part_dfly_module-dfly.$(OBJEXT)
+nodist_part_dfly_module_OBJECTS =
+part_dfly_module_OBJECTS = $(am_part_dfly_module_OBJECTS) \
+ $(nodist_part_dfly_module_OBJECTS)
+part_dfly_module_LINK = $(CCLD) $(part_dfly_module_CFLAGS) $(CFLAGS) \
+ $(part_dfly_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_dvh_module_OBJECTS = partmap/part_dvh_module-dvh.$(OBJEXT)
+nodist_part_dvh_module_OBJECTS =
+part_dvh_module_OBJECTS = $(am_part_dvh_module_OBJECTS) \
+ $(nodist_part_dvh_module_OBJECTS)
+part_dvh_module_LINK = $(CCLD) $(part_dvh_module_CFLAGS) $(CFLAGS) \
+ $(part_dvh_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_gpt_module_OBJECTS = partmap/part_gpt_module-gpt.$(OBJEXT)
+nodist_part_gpt_module_OBJECTS =
+part_gpt_module_OBJECTS = $(am_part_gpt_module_OBJECTS) \
+ $(nodist_part_gpt_module_OBJECTS)
+part_gpt_module_LINK = $(CCLD) $(part_gpt_module_CFLAGS) $(CFLAGS) \
+ $(part_gpt_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_msdos_module_OBJECTS = \
+ partmap/part_msdos_module-msdos.$(OBJEXT)
+nodist_part_msdos_module_OBJECTS =
+part_msdos_module_OBJECTS = $(am_part_msdos_module_OBJECTS) \
+ $(nodist_part_msdos_module_OBJECTS)
+part_msdos_module_LINK = $(CCLD) $(part_msdos_module_CFLAGS) $(CFLAGS) \
+ $(part_msdos_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_plan_module_OBJECTS = partmap/part_plan_module-plan.$(OBJEXT)
+nodist_part_plan_module_OBJECTS =
+part_plan_module_OBJECTS = $(am_part_plan_module_OBJECTS) \
+ $(nodist_part_plan_module_OBJECTS)
+part_plan_module_LINK = $(CCLD) $(part_plan_module_CFLAGS) $(CFLAGS) \
+ $(part_plan_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_sun_module_OBJECTS = partmap/part_sun_module-sun.$(OBJEXT)
+nodist_part_sun_module_OBJECTS =
+part_sun_module_OBJECTS = $(am_part_sun_module_OBJECTS) \
+ $(nodist_part_sun_module_OBJECTS)
+part_sun_module_LINK = $(CCLD) $(part_sun_module_CFLAGS) $(CFLAGS) \
+ $(part_sun_module_LDFLAGS) $(LDFLAGS) -o $@
+am_part_sunpc_module_OBJECTS = \
+ partmap/part_sunpc_module-sunpc.$(OBJEXT)
+nodist_part_sunpc_module_OBJECTS =
+part_sunpc_module_OBJECTS = $(am_part_sunpc_module_OBJECTS) \
+ $(nodist_part_sunpc_module_OBJECTS)
+part_sunpc_module_LINK = $(CCLD) $(part_sunpc_module_CFLAGS) $(CFLAGS) \
+ $(part_sunpc_module_LDFLAGS) $(LDFLAGS) -o $@
+am_parttool_module_OBJECTS = \
+ commands/parttool_module-parttool.$(OBJEXT)
+nodist_parttool_module_OBJECTS =
+parttool_module_OBJECTS = $(am_parttool_module_OBJECTS) \
+ $(nodist_parttool_module_OBJECTS)
+parttool_module_LINK = $(CCLD) $(parttool_module_CFLAGS) $(CFLAGS) \
+ $(parttool_module_LDFLAGS) $(LDFLAGS) -o $@
+am_password_module_OBJECTS = \
+ commands/password_module-password.$(OBJEXT)
+nodist_password_module_OBJECTS =
+password_module_OBJECTS = $(am_password_module_OBJECTS) \
+ $(nodist_password_module_OBJECTS)
+password_module_LINK = $(CCLD) $(password_module_CFLAGS) $(CFLAGS) \
+ $(password_module_LDFLAGS) $(LDFLAGS) -o $@
+am_password_pbkdf2_module_OBJECTS = \
+ commands/password_pbkdf2_module-password_pbkdf2.$(OBJEXT)
+nodist_password_pbkdf2_module_OBJECTS =
+password_pbkdf2_module_OBJECTS = $(am_password_pbkdf2_module_OBJECTS) \
+ $(nodist_password_pbkdf2_module_OBJECTS)
+password_pbkdf2_module_LINK = $(CCLD) $(password_pbkdf2_module_CFLAGS) \
+ $(CFLAGS) $(password_pbkdf2_module_LDFLAGS) $(LDFLAGS) -o $@
+am__pata_module_SOURCES_DIST = disk/pata.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_x86_64_efi_TRUE@am_pata_module_OBJECTS = disk/pata_module-pata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_pata_module_OBJECTS = disk/pata_module-pata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_pata_module_OBJECTS = disk/pata_module-pata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_pata_module_OBJECTS = disk/pata_module-pata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_pata_module_OBJECTS = disk/pata_module-pata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_pata_module_OBJECTS = disk/pata_module-pata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_pata_module_OBJECTS = disk/pata_module-pata.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_pata_module_OBJECTS = disk/pata_module-pata.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_pata_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ disk/pata_module-pata.$(OBJEXT)
+nodist_pata_module_OBJECTS =
+pata_module_OBJECTS = $(am_pata_module_OBJECTS) \
+ $(nodist_pata_module_OBJECTS)
+pata_module_LINK = $(CCLD) $(pata_module_CFLAGS) $(CFLAGS) \
+ $(pata_module_LDFLAGS) $(LDFLAGS) -o $@
+am_pbkdf2_module_OBJECTS = lib/pbkdf2_module-pbkdf2.$(OBJEXT)
+nodist_pbkdf2_module_OBJECTS =
+pbkdf2_module_OBJECTS = $(am_pbkdf2_module_OBJECTS) \
+ $(nodist_pbkdf2_module_OBJECTS)
+pbkdf2_module_LINK = $(CCLD) $(pbkdf2_module_CFLAGS) $(CFLAGS) \
+ $(pbkdf2_module_LDFLAGS) $(LDFLAGS) -o $@
+am_pbkdf2_test_module_OBJECTS = \
+ tests/pbkdf2_test_module-pbkdf2_test.$(OBJEXT)
+nodist_pbkdf2_test_module_OBJECTS =
+pbkdf2_test_module_OBJECTS = $(am_pbkdf2_test_module_OBJECTS) \
+ $(nodist_pbkdf2_test_module_OBJECTS)
+pbkdf2_test_module_LINK = $(CCLD) $(pbkdf2_test_module_CFLAGS) \
+ $(CFLAGS) $(pbkdf2_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am__pci_module_SOURCES_DIST = bus/pci.c bus/i386/ieee1275/pci.c
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_pci_module_OBJECTS = bus/pci_module-pci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_pci_module_OBJECTS = bus/pci_module-pci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@am_pci_module_OBJECTS = bus/i386/ieee1275/pci_module-pci.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_ieee1275_TRUE@ bus/pci_module-pci.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_pci_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ bus/pci_module-pci.$(OBJEXT)
+nodist_pci_module_OBJECTS =
+pci_module_OBJECTS = $(am_pci_module_OBJECTS) \
+ $(nodist_pci_module_OBJECTS)
+pci_module_LINK = $(CCLD) $(pci_module_CFLAGS) $(CFLAGS) \
+ $(pci_module_LDFLAGS) $(LDFLAGS) -o $@
+am__pcidump_module_SOURCES_DIST = commands/pcidump.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_pcidump_module_OBJECTS = commands/pcidump_module-pcidump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_pcidump_module_OBJECTS = commands/pcidump_module-pcidump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_pcidump_module_OBJECTS = commands/pcidump_module-pcidump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_pcidump_module_OBJECTS = commands/pcidump_module-pcidump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_pcidump_module_OBJECTS = commands/pcidump_module-pcidump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_pcidump_module_OBJECTS = commands/pcidump_module-pcidump.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_pcidump_module_OBJECTS = commands/pcidump_module-pcidump.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_pcidump_module_OBJECTS = commands/pcidump_module-pcidump.$(OBJEXT)
+nodist_pcidump_module_OBJECTS =
+pcidump_module_OBJECTS = $(am_pcidump_module_OBJECTS) \
+ $(nodist_pcidump_module_OBJECTS)
+pcidump_module_LINK = $(CCLD) $(pcidump_module_CFLAGS) $(CFLAGS) \
+ $(pcidump_module_LDFLAGS) $(LDFLAGS) -o $@
+am_pgp_module_OBJECTS = commands/pgp_module-pgp.$(OBJEXT)
+nodist_pgp_module_OBJECTS =
+pgp_module_OBJECTS = $(am_pgp_module_OBJECTS) \
+ $(nodist_pgp_module_OBJECTS)
+pgp_module_LINK = $(CCLD) $(pgp_module_CFLAGS) $(CFLAGS) \
+ $(pgp_module_LDFLAGS) $(LDFLAGS) -o $@
+am__plan9_module_SOURCES_DIST = loader/i386/pc/plan9.c
+@COND_i386_pc_TRUE@am_plan9_module_OBJECTS = loader/i386/pc/plan9_module-plan9.$(OBJEXT)
+nodist_plan9_module_OBJECTS =
+plan9_module_OBJECTS = $(am_plan9_module_OBJECTS) \
+ $(nodist_plan9_module_OBJECTS)
+plan9_module_LINK = $(CCLD) $(plan9_module_CFLAGS) $(CFLAGS) \
+ $(plan9_module_LDFLAGS) $(LDFLAGS) -o $@
+am__play_module_SOURCES_DIST = commands/i386/pc/play.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_play_module_OBJECTS = commands/i386/pc/play_module-play.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_play_module_OBJECTS = commands/i386/pc/play_module-play.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_play_module_OBJECTS = commands/i386/pc/play_module-play.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_play_module_OBJECTS = commands/i386/pc/play_module-play.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_play_module_OBJECTS = commands/i386/pc/play_module-play.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_play_module_OBJECTS = commands/i386/pc/play_module-play.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_play_module_OBJECTS = commands/i386/pc/play_module-play.$(OBJEXT)
+nodist_play_module_OBJECTS =
+play_module_OBJECTS = $(am_play_module_OBJECTS) \
+ $(nodist_play_module_OBJECTS)
+play_module_LINK = $(CCLD) $(play_module_CFLAGS) $(CFLAGS) \
+ $(play_module_LDFLAGS) $(LDFLAGS) -o $@
+am_png_module_OBJECTS = video/readers/png_module-png.$(OBJEXT)
+nodist_png_module_OBJECTS =
+png_module_OBJECTS = $(am_png_module_OBJECTS) \
+ $(nodist_png_module_OBJECTS)
+png_module_LINK = $(CCLD) $(png_module_CFLAGS) $(CFLAGS) \
+ $(png_module_LDFLAGS) $(LDFLAGS) -o $@
+am_priority_queue_module_OBJECTS = \
+ lib/priority_queue_module-priority_queue.$(OBJEXT)
+nodist_priority_queue_module_OBJECTS =
+priority_queue_module_OBJECTS = $(am_priority_queue_module_OBJECTS) \
+ $(nodist_priority_queue_module_OBJECTS)
+priority_queue_module_LINK = $(CCLD) $(priority_queue_module_CFLAGS) \
+ $(CFLAGS) $(priority_queue_module_LDFLAGS) $(LDFLAGS) -o $@
+am_probe_module_OBJECTS = commands/probe_module-probe.$(OBJEXT)
+nodist_probe_module_OBJECTS =
+probe_module_OBJECTS = $(am_probe_module_OBJECTS) \
+ $(nodist_probe_module_OBJECTS)
+probe_module_LINK = $(CCLD) $(probe_module_CFLAGS) $(CFLAGS) \
+ $(probe_module_LDFLAGS) $(LDFLAGS) -o $@
+am_procfs_module_OBJECTS = fs/procfs_module-proc.$(OBJEXT)
+nodist_procfs_module_OBJECTS =
+procfs_module_OBJECTS = $(am_procfs_module_OBJECTS) \
+ $(nodist_procfs_module_OBJECTS)
+procfs_module_LINK = $(CCLD) $(procfs_module_CFLAGS) $(CFLAGS) \
+ $(procfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am_progress_module_OBJECTS = lib/progress_module-progress.$(OBJEXT)
+nodist_progress_module_OBJECTS =
+progress_module_OBJECTS = $(am_progress_module_OBJECTS) \
+ $(nodist_progress_module_OBJECTS)
+progress_module_LINK = $(CCLD) $(progress_module_CFLAGS) $(CFLAGS) \
+ $(progress_module_LDFLAGS) $(LDFLAGS) -o $@
+am__pxe_module_SOURCES_DIST = net/drivers/i386/pc/pxe.c
+@COND_i386_pc_TRUE@am_pxe_module_OBJECTS = net/drivers/i386/pc/pxe_module-pxe.$(OBJEXT)
+nodist_pxe_module_OBJECTS =
+pxe_module_OBJECTS = $(am_pxe_module_OBJECTS) \
+ $(nodist_pxe_module_OBJECTS)
+pxe_module_LINK = $(CCLD) $(pxe_module_CFLAGS) $(CFLAGS) \
+ $(pxe_module_LDFLAGS) $(LDFLAGS) -o $@
+am__pxeboot_image_SOURCES_DIST = boot/i386/pc/pxeboot.S
+@COND_i386_pc_TRUE@am_pxeboot_image_OBJECTS = boot/i386/pc/pxeboot_image-pxeboot.$(OBJEXT)
+nodist_pxeboot_image_OBJECTS =
+pxeboot_image_OBJECTS = $(am_pxeboot_image_OBJECTS) \
+ $(nodist_pxeboot_image_OBJECTS)
+pxeboot_image_DEPENDENCIES =
+pxeboot_image_LINK = $(CCLD) $(pxeboot_image_CFLAGS) $(CFLAGS) \
+ $(pxeboot_image_LDFLAGS) $(LDFLAGS) -o $@
+am__pxechain_module_SOURCES_DIST = loader/i386/pc/pxechainloader.c
+@COND_i386_pc_TRUE@am_pxechain_module_OBJECTS = loader/i386/pc/pxechain_module-pxechainloader.$(OBJEXT)
+nodist_pxechain_module_OBJECTS =
+pxechain_module_OBJECTS = $(am_pxechain_module_OBJECTS) \
+ $(nodist_pxechain_module_OBJECTS)
+pxechain_module_LINK = $(CCLD) $(pxechain_module_CFLAGS) $(CFLAGS) \
+ $(pxechain_module_LDFLAGS) $(LDFLAGS) -o $@
+am_raid5rec_module_OBJECTS = \
+ disk/raid5rec_module-raid5_recover.$(OBJEXT)
+nodist_raid5rec_module_OBJECTS =
+raid5rec_module_OBJECTS = $(am_raid5rec_module_OBJECTS) \
+ $(nodist_raid5rec_module_OBJECTS)
+raid5rec_module_LINK = $(CCLD) $(raid5rec_module_CFLAGS) $(CFLAGS) \
+ $(raid5rec_module_LDFLAGS) $(LDFLAGS) -o $@
+am_raid6rec_module_OBJECTS = \
+ disk/raid6rec_module-raid6_recover.$(OBJEXT)
+nodist_raid6rec_module_OBJECTS =
+raid6rec_module_OBJECTS = $(am_raid6rec_module_OBJECTS) \
+ $(nodist_raid6rec_module_OBJECTS)
+raid6rec_module_LINK = $(CCLD) $(raid6rec_module_CFLAGS) $(CFLAGS) \
+ $(raid6rec_module_LDFLAGS) $(LDFLAGS) -o $@
+am__random_module_SOURCES_DIST = kern/i386/tsc_pmtimer.c \
+ lib/i386/random.c lib/random.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_x86_64_efi_TRUE@am_random_module_OBJECTS = lib/i386/random_module-random.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_x86_64_efi_TRUE@ lib/random_module-random.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_random_module_OBJECTS = kern/i386/random_module-tsc_pmtimer.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/i386/random_module-random.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/random_module-random.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@am_random_module_OBJECTS = kern/i386/random_module-tsc_pmtimer.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@ lib/i386/random_module-random.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@ lib/random_module-random.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_random_module_OBJECTS = lib/i386/random_module-random.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/random_module-random.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_random_module_OBJECTS = kern/i386/random_module-tsc_pmtimer.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ lib/i386/random_module-random.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ lib/random_module-random.$(OBJEXT)
+nodist_random_module_OBJECTS =
+random_module_OBJECTS = $(am_random_module_OBJECTS) \
+ $(nodist_random_module_OBJECTS)
+random_module_LINK = $(CCLD) $(random_module_CFLAGS) $(CFLAGS) \
+ $(random_module_LDFLAGS) $(LDFLAGS) -o $@
+am__rdmsr_module_SOURCES_DIST = commands/i386/rdmsr.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_rdmsr_module_OBJECTS = commands/i386/rdmsr_module-rdmsr.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_rdmsr_module_OBJECTS = commands/i386/rdmsr_module-rdmsr.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_rdmsr_module_OBJECTS = commands/i386/rdmsr_module-rdmsr.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_rdmsr_module_OBJECTS = commands/i386/rdmsr_module-rdmsr.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_rdmsr_module_OBJECTS = commands/i386/rdmsr_module-rdmsr.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_rdmsr_module_OBJECTS = commands/i386/rdmsr_module-rdmsr.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_rdmsr_module_OBJECTS = commands/i386/rdmsr_module-rdmsr.$(OBJEXT)
+nodist_rdmsr_module_OBJECTS =
+rdmsr_module_OBJECTS = $(am_rdmsr_module_OBJECTS) \
+ $(nodist_rdmsr_module_OBJECTS)
+rdmsr_module_LINK = $(CCLD) $(rdmsr_module_CFLAGS) $(CFLAGS) \
+ $(rdmsr_module_LDFLAGS) $(LDFLAGS) -o $@
+am_read_module_OBJECTS = commands/read_module-read.$(OBJEXT)
+nodist_read_module_OBJECTS =
+read_module_OBJECTS = $(am_read_module_OBJECTS) \
+ $(nodist_read_module_OBJECTS)
+read_module_LINK = $(CCLD) $(read_module_CFLAGS) $(CFLAGS) \
+ $(read_module_LDFLAGS) $(LDFLAGS) -o $@
+am__reboot_module_SOURCES_DIST = commands/reboot.c lib/dummy/reboot.c \
+ lib/uboot/reboot.c lib/i386/reboot.c \
+ lib/i386/reboot_trampoline.S lib/xen/reboot.c \
+ lib/mips/arc/reboot.c lib/mips/loongson/reboot.c \
+ lib/mips/qemu_mips/reboot.c lib/ieee1275/reboot.c
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_reboot_module_OBJECTS = lib/xen/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_reboot_module_OBJECTS = commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_reboot_module_OBJECTS = lib/ieee1275/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_reboot_module_OBJECTS = commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_reboot_module_OBJECTS = commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_reboot_module_OBJECTS = lib/ieee1275/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_reboot_module_OBJECTS = lib/mips/qemu_mips/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_reboot_module_OBJECTS = lib/mips/loongson/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_reboot_module_OBJECTS = lib/mips/arc/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_reboot_module_OBJECTS = commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_reboot_module_OBJECTS = lib/xen/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_reboot_module_OBJECTS = lib/xen/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_reboot_module_OBJECTS = lib/i386/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/i386/reboot_module-reboot_trampoline.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_reboot_module_OBJECTS = lib/i386/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/i386/reboot_module-reboot_trampoline.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_reboot_module_OBJECTS = lib/i386/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/i386/reboot_module-reboot_trampoline.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_reboot_module_OBJECTS = lib/i386/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/i386/reboot_module-reboot_trampoline.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_reboot_module_OBJECTS = lib/i386/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/i386/reboot_module-reboot_trampoline.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@am_reboot_module_OBJECTS = lib/i386/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ lib/i386/reboot_module-reboot_trampoline.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_coreboot_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@am_reboot_module_OBJECTS = commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_reboot_module_OBJECTS = lib/uboot/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@am_reboot_module_OBJECTS = commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@am_reboot_module_OBJECTS = lib/dummy/reboot_module-reboot.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_reboot_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ commands/reboot_module-reboot.$(OBJEXT)
+nodist_reboot_module_OBJECTS =
+reboot_module_OBJECTS = $(am_reboot_module_OBJECTS) \
+ $(nodist_reboot_module_OBJECTS)
+reboot_module_LINK = $(CCLD) $(reboot_module_CFLAGS) $(CFLAGS) \
+ $(reboot_module_LDFLAGS) $(LDFLAGS) -o $@
+am_regexp_module_OBJECTS = commands/regexp_module-regexp.$(OBJEXT) \
+ commands/regexp_module-wildcard.$(OBJEXT) \
+ lib/gnulib/regexp_module-regex.$(OBJEXT)
+nodist_regexp_module_OBJECTS =
+regexp_module_OBJECTS = $(am_regexp_module_OBJECTS) \
+ $(nodist_regexp_module_OBJECTS)
+regexp_module_LINK = $(CCLD) $(regexp_module_CFLAGS) $(CFLAGS) \
+ $(regexp_module_LDFLAGS) $(LDFLAGS) -o $@
+am_reiserfs_module_OBJECTS = fs/reiserfs_module-reiserfs.$(OBJEXT)
+nodist_reiserfs_module_OBJECTS =
+reiserfs_module_OBJECTS = $(am_reiserfs_module_OBJECTS) \
+ $(nodist_reiserfs_module_OBJECTS)
+reiserfs_module_LINK = $(CCLD) $(reiserfs_module_CFLAGS) $(CFLAGS) \
+ $(reiserfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am__relocator_module_SOURCES_DIST = lib/i386/relocator_asm.S \
+ lib/i386/relocator16.S lib/i386/relocator32.S \
+ lib/i386/relocator64.S lib/i386/relocator.c \
+ lib/i386/relocator_common_c.c lib/relocator.c \
+ lib/efi/relocator.c lib/ieee1275/relocator.c \
+ lib/i386/xen/relocator.S lib/xen/relocator.c \
+ lib/mips/relocator_asm.S lib/mips/relocator.c \
+ lib/powerpc/relocator_asm.S lib/powerpc/relocator.c \
+ lib/x86_64/efi/relocator.c lib/x86_64/relocator_asm.S \
+ lib/x86_64/xen/relocator.S
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_relocator_module_OBJECTS = lib/x86_64/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ lib/x86_64/xen/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ lib/xen/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ lib/i386/relocator_module-relocator_common_c.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_relocator_module_OBJECTS = lib/x86_64/efi/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/x86_64/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/i386/relocator_module-relocator16.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/i386/relocator_module-relocator32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/i386/relocator_module-relocator64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/i386/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/i386/relocator_module-relocator_common_c.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/efi/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_relocator_module_OBJECTS = lib/powerpc/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ lib/powerpc/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ lib/ieee1275/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_relocator_module_OBJECTS = lib/mips/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ lib/mips/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_relocator_module_OBJECTS = lib/mips/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ lib/mips/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_TRUE@am_relocator_module_OBJECTS = lib/mips/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_TRUE@ lib/mips/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_mips_arc_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_relocator_module_OBJECTS = lib/i386/relocator_module-relocator16.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/i386/relocator_module-relocator32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/i386/relocator_module-relocator64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/i386/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/i386/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/i386/relocator_module-relocator_common_c.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_relocator_module_OBJECTS = lib/i386/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ lib/i386/xen/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ lib/xen/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ lib/i386/relocator_module-relocator_common_c.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_relocator_module_OBJECTS = lib/i386/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/i386/relocator_module-relocator16.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/i386/relocator_module-relocator32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/i386/relocator_module-relocator64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/i386/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/i386/relocator_module-relocator_common_c.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_relocator_module_OBJECTS = lib/i386/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/i386/relocator_module-relocator16.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/i386/relocator_module-relocator32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/i386/relocator_module-relocator64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/i386/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/i386/relocator_module-relocator_common_c.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_relocator_module_OBJECTS = lib/i386/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/i386/relocator_module-relocator16.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/i386/relocator_module-relocator32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/i386/relocator_module-relocator64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/i386/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/i386/relocator_module-relocator_common_c.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_relocator_module_OBJECTS = lib/ieee1275/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/i386/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/i386/relocator_module-relocator16.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/i386/relocator_module-relocator32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/i386/relocator_module-relocator64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/i386/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/i386/relocator_module-relocator_common_c.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_relocator_module_OBJECTS = lib/i386/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/i386/relocator_module-relocator16.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/i386/relocator_module-relocator32.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/i386/relocator_module-relocator64.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/i386/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/i386/relocator_module-relocator_common_c.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/efi/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_relocator_module_OBJECTS = lib/i386/relocator_module-relocator_asm.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ lib/i386/relocator_module-relocator16.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ lib/i386/relocator_module-relocator32.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ lib/i386/relocator_module-relocator64.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ lib/i386/relocator_module-relocator.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ lib/i386/relocator_module-relocator_common_c.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ lib/relocator_module-relocator.$(OBJEXT)
+nodist_relocator_module_OBJECTS =
+relocator_module_OBJECTS = $(am_relocator_module_OBJECTS) \
+ $(nodist_relocator_module_OBJECTS)
+relocator_module_LINK = $(CCLD) $(relocator_module_CFLAGS) $(CFLAGS) \
+ $(relocator_module_LDFLAGS) $(LDFLAGS) -o $@
+am_romfs_module_OBJECTS = fs/romfs_module-romfs.$(OBJEXT)
+nodist_romfs_module_OBJECTS =
+romfs_module_OBJECTS = $(am_romfs_module_OBJECTS) \
+ $(nodist_romfs_module_OBJECTS)
+romfs_module_LINK = $(CCLD) $(romfs_module_CFLAGS) $(CFLAGS) \
+ $(romfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am_scsi_module_OBJECTS = disk/scsi_module-scsi.$(OBJEXT)
+nodist_scsi_module_OBJECTS =
+scsi_module_OBJECTS = $(am_scsi_module_OBJECTS) \
+ $(nodist_scsi_module_OBJECTS)
+scsi_module_LINK = $(CCLD) $(scsi_module_CFLAGS) $(CFLAGS) \
+ $(scsi_module_LDFLAGS) $(LDFLAGS) -o $@
+am__sdl_module_SOURCES_DIST = video/emu/sdl.c
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@am_sdl_module_OBJECTS = video/emu/sdl_module-sdl.$(OBJEXT)
+nodist_sdl_module_OBJECTS =
+sdl_module_OBJECTS = $(am_sdl_module_OBJECTS) \
+ $(nodist_sdl_module_OBJECTS)
+sdl_module_LINK = $(CCLD) $(sdl_module_CFLAGS) $(CFLAGS) \
+ $(sdl_module_LDFLAGS) $(LDFLAGS) -o $@
+am_search_module_OBJECTS = \
+ commands/search_module-search_wrap.$(OBJEXT)
+nodist_search_module_OBJECTS =
+search_module_OBJECTS = $(am_search_module_OBJECTS) \
+ $(nodist_search_module_OBJECTS)
+search_module_LINK = $(CCLD) $(search_module_CFLAGS) $(CFLAGS) \
+ $(search_module_LDFLAGS) $(LDFLAGS) -o $@
+am_search_fs_file_module_OBJECTS = \
+ commands/search_fs_file_module-search_file.$(OBJEXT)
+nodist_search_fs_file_module_OBJECTS =
+search_fs_file_module_OBJECTS = $(am_search_fs_file_module_OBJECTS) \
+ $(nodist_search_fs_file_module_OBJECTS)
+search_fs_file_module_LINK = $(CCLD) $(search_fs_file_module_CFLAGS) \
+ $(CFLAGS) $(search_fs_file_module_LDFLAGS) $(LDFLAGS) -o $@
+am_search_fs_uuid_module_OBJECTS = \
+ commands/search_fs_uuid_module-search_uuid.$(OBJEXT)
+nodist_search_fs_uuid_module_OBJECTS =
+search_fs_uuid_module_OBJECTS = $(am_search_fs_uuid_module_OBJECTS) \
+ $(nodist_search_fs_uuid_module_OBJECTS)
+search_fs_uuid_module_LINK = $(CCLD) $(search_fs_uuid_module_CFLAGS) \
+ $(CFLAGS) $(search_fs_uuid_module_LDFLAGS) $(LDFLAGS) -o $@
+am_search_label_module_OBJECTS = \
+ commands/search_label_module-search_label.$(OBJEXT)
+nodist_search_label_module_OBJECTS =
+search_label_module_OBJECTS = $(am_search_label_module_OBJECTS) \
+ $(nodist_search_label_module_OBJECTS)
+search_label_module_LINK = $(CCLD) $(search_label_module_CFLAGS) \
+ $(CFLAGS) $(search_label_module_LDFLAGS) $(LDFLAGS) -o $@
+am__sendkey_module_SOURCES_DIST = commands/i386/pc/sendkey.c
+@COND_i386_pc_TRUE@am_sendkey_module_OBJECTS = commands/i386/pc/sendkey_module-sendkey.$(OBJEXT)
+nodist_sendkey_module_OBJECTS =
+sendkey_module_OBJECTS = $(am_sendkey_module_OBJECTS) \
+ $(nodist_sendkey_module_OBJECTS)
+sendkey_module_LINK = $(CCLD) $(sendkey_module_CFLAGS) $(CFLAGS) \
+ $(sendkey_module_LDFLAGS) $(LDFLAGS) -o $@
+am__serial_module_SOURCES_DIST = term/efi/serial.c term/serial.c \
+ term/ns8250.c term/ieee1275/serial.c term/arc/serial.c
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_serial_module_OBJECTS = term/serial_module-ns8250.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ term/efi/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_serial_module_OBJECTS = term/ieee1275/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_serial_module_OBJECTS = term/efi/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_serial_module_OBJECTS = term/efi/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_TRUE@am_serial_module_OBJECTS = term/ieee1275/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_powerpc_ieee1275_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_serial_module_OBJECTS = term/arc/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_TRUE@am_serial_module_OBJECTS = term/efi/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_serial_module_OBJECTS = term/serial_module-ns8250.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_serial_module_OBJECTS = term/serial_module-ns8250.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_serial_module_OBJECTS = term/serial_module-ns8250.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_serial_module_OBJECTS = term/ieee1275/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ term/serial_module-ns8250.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_serial_module_OBJECTS = term/serial_module-ns8250.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ term/efi/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@am_serial_module_OBJECTS = term/serial_module-ns8250.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@am_serial_module_OBJECTS = term/efi/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@am_serial_module_OBJECTS = term/serial_module-serial.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_serial_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ term/efi/serial_module-serial.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ term/serial_module-serial.$(OBJEXT)
+nodist_serial_module_OBJECTS =
+serial_module_OBJECTS = $(am_serial_module_OBJECTS) \
+ $(nodist_serial_module_OBJECTS)
+serial_module_LINK = $(CCLD) $(serial_module_CFLAGS) $(CFLAGS) \
+ $(serial_module_LDFLAGS) $(LDFLAGS) -o $@
+am_setjmp_module_OBJECTS = lib/setjmp_module-setjmp.$(OBJEXT)
+nodist_setjmp_module_OBJECTS =
+setjmp_module_OBJECTS = $(am_setjmp_module_OBJECTS) \
+ $(nodist_setjmp_module_OBJECTS)
+setjmp_module_LINK = $(CCLD) $(setjmp_module_CFLAGS) $(CFLAGS) \
+ $(setjmp_module_LDFLAGS) $(LDFLAGS) -o $@
+am_setjmp_test_module_OBJECTS = \
+ tests/setjmp_test_module-setjmp_test.$(OBJEXT)
+nodist_setjmp_test_module_OBJECTS =
+setjmp_test_module_OBJECTS = $(am_setjmp_test_module_OBJECTS) \
+ $(nodist_setjmp_test_module_OBJECTS)
+setjmp_test_module_LINK = $(CCLD) $(setjmp_test_module_CFLAGS) \
+ $(CFLAGS) $(setjmp_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am__setpci_module_SOURCES_DIST = commands/setpci.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_setpci_module_OBJECTS = commands/setpci_module-setpci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_setpci_module_OBJECTS = commands/setpci_module-setpci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_setpci_module_OBJECTS = commands/setpci_module-setpci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_setpci_module_OBJECTS = commands/setpci_module-setpci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_setpci_module_OBJECTS = commands/setpci_module-setpci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_setpci_module_OBJECTS = commands/setpci_module-setpci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_setpci_module_OBJECTS = commands/setpci_module-setpci.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_setpci_module_OBJECTS = commands/setpci_module-setpci.$(OBJEXT)
+nodist_setpci_module_OBJECTS =
+setpci_module_OBJECTS = $(am_setpci_module_OBJECTS) \
+ $(nodist_setpci_module_OBJECTS)
+setpci_module_LINK = $(CCLD) $(setpci_module_CFLAGS) $(CFLAGS) \
+ $(setpci_module_LDFLAGS) $(LDFLAGS) -o $@
+am_sfs_module_OBJECTS = fs/sfs_module-sfs.$(OBJEXT)
+nodist_sfs_module_OBJECTS =
+sfs_module_OBJECTS = $(am_sfs_module_OBJECTS) \
+ $(nodist_sfs_module_OBJECTS)
+sfs_module_LINK = $(CCLD) $(sfs_module_CFLAGS) $(CFLAGS) \
+ $(sfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am_shift_test_module_OBJECTS = \
+ tests/shift_test_module-shift_test.$(OBJEXT)
+nodist_shift_test_module_OBJECTS =
+shift_test_module_OBJECTS = $(am_shift_test_module_OBJECTS) \
+ $(nodist_shift_test_module_OBJECTS)
+shift_test_module_LINK = $(CCLD) $(shift_test_module_CFLAGS) $(CFLAGS) \
+ $(shift_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am_signature_test_module_OBJECTS = \
+ tests/signature_test_module-signature_test.$(OBJEXT)
+nodist_signature_test_module_OBJECTS =
+signature_test_module_OBJECTS = $(am_signature_test_module_OBJECTS) \
+ $(nodist_signature_test_module_OBJECTS)
+signature_test_module_LINK = $(CCLD) $(signature_test_module_CFLAGS) \
+ $(CFLAGS) $(signature_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am_sleep_module_OBJECTS = commands/sleep_module-sleep.$(OBJEXT)
+nodist_sleep_module_OBJECTS =
+sleep_module_OBJECTS = $(am_sleep_module_OBJECTS) \
+ $(nodist_sleep_module_OBJECTS)
+sleep_module_LINK = $(CCLD) $(sleep_module_CFLAGS) $(CFLAGS) \
+ $(sleep_module_LDFLAGS) $(LDFLAGS) -o $@
+am_sleep_test_module_OBJECTS = \
+ tests/sleep_test_module-sleep_test.$(OBJEXT)
+nodist_sleep_test_module_OBJECTS =
+sleep_test_module_OBJECTS = $(am_sleep_test_module_OBJECTS) \
+ $(nodist_sleep_test_module_OBJECTS)
+sleep_test_module_LINK = $(CCLD) $(sleep_test_module_CFLAGS) $(CFLAGS) \
+ $(sleep_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am__smbios_module_SOURCES_DIST = commands/efi/smbios.c \
+ commands/smbios.c commands/i386/pc/smbios.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_smbios_module_OBJECTS = commands/efi/smbios_module-smbios.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@ commands/smbios_module-smbios.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_smbios_module_OBJECTS = commands/efi/smbios_module-smbios.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ commands/smbios_module-smbios.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_smbios_module_OBJECTS = commands/efi/smbios_module-smbios.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@ commands/smbios_module-smbios.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_TRUE@am_smbios_module_OBJECTS = commands/efi/smbios_module-smbios.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_ia64_efi_TRUE@ commands/smbios_module-smbios.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_smbios_module_OBJECTS = commands/i386/pc/smbios_module-smbios.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ commands/smbios_module-smbios.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@am_smbios_module_OBJECTS = commands/i386/pc/smbios_module-smbios.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@ commands/smbios_module-smbios.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_smbios_module_OBJECTS = commands/efi/smbios_module-smbios.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ commands/smbios_module-smbios.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@am_smbios_module_OBJECTS = commands/i386/pc/smbios_module-smbios.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@ commands/smbios_module-smbios.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_smbios_module_OBJECTS = commands/efi/smbios_module-smbios.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@ commands/smbios_module-smbios.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_smbios_module_OBJECTS = commands/efi/smbios_module-smbios.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ commands/smbios_module-smbios.$(OBJEXT)
+nodist_smbios_module_OBJECTS =
+smbios_module_OBJECTS = $(am_smbios_module_OBJECTS) \
+ $(nodist_smbios_module_OBJECTS)
+smbios_module_LINK = $(CCLD) $(smbios_module_CFLAGS) $(CFLAGS) \
+ $(smbios_module_LDFLAGS) $(LDFLAGS) -o $@
+am__spkmodem_module_SOURCES_DIST = term/spkmodem.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_spkmodem_module_OBJECTS = term/spkmodem_module-spkmodem.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_spkmodem_module_OBJECTS = term/spkmodem_module-spkmodem.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_spkmodem_module_OBJECTS = term/spkmodem_module-spkmodem.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_spkmodem_module_OBJECTS = term/spkmodem_module-spkmodem.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_spkmodem_module_OBJECTS = term/spkmodem_module-spkmodem.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_spkmodem_module_OBJECTS = term/spkmodem_module-spkmodem.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_spkmodem_module_OBJECTS = term/spkmodem_module-spkmodem.$(OBJEXT)
+nodist_spkmodem_module_OBJECTS =
+spkmodem_module_OBJECTS = $(am_spkmodem_module_OBJECTS) \
+ $(nodist_spkmodem_module_OBJECTS)
+spkmodem_module_LINK = $(CCLD) $(spkmodem_module_CFLAGS) $(CFLAGS) \
+ $(spkmodem_module_LDFLAGS) $(LDFLAGS) -o $@
+am_squash4_module_OBJECTS = fs/squash4_module-squash4.$(OBJEXT)
+nodist_squash4_module_OBJECTS =
+squash4_module_OBJECTS = $(am_squash4_module_OBJECTS) \
+ $(nodist_squash4_module_OBJECTS)
+squash4_module_LINK = $(CCLD) $(squash4_module_CFLAGS) $(CFLAGS) \
+ $(squash4_module_LDFLAGS) $(LDFLAGS) -o $@
+am_strtoull_test_module_OBJECTS = \
+ tests/strtoull_test_module-strtoull_test.$(OBJEXT)
+nodist_strtoull_test_module_OBJECTS =
+strtoull_test_module_OBJECTS = $(am_strtoull_test_module_OBJECTS) \
+ $(nodist_strtoull_test_module_OBJECTS)
+strtoull_test_module_LINK = $(CCLD) $(strtoull_test_module_CFLAGS) \
+ $(CFLAGS) $(strtoull_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am__suspend_module_SOURCES_DIST = commands/ieee1275/suspend.c
+@COND_i386_ieee1275_FALSE@@COND_powerpc_ieee1275_TRUE@am_suspend_module_OBJECTS = commands/ieee1275/suspend_module-suspend.$(OBJEXT)
+@COND_i386_ieee1275_TRUE@am_suspend_module_OBJECTS = commands/ieee1275/suspend_module-suspend.$(OBJEXT)
+nodist_suspend_module_OBJECTS =
+suspend_module_OBJECTS = $(am_suspend_module_OBJECTS) \
+ $(nodist_suspend_module_OBJECTS)
+suspend_module_LINK = $(CCLD) $(suspend_module_CFLAGS) $(CFLAGS) \
+ $(suspend_module_LDFLAGS) $(LDFLAGS) -o $@
+am_syslinuxcfg_module_OBJECTS = \
+ lib/syslinuxcfg_module-syslinux_parse.$(OBJEXT) \
+ commands/syslinuxcfg_module-syslinuxcfg.$(OBJEXT)
+nodist_syslinuxcfg_module_OBJECTS =
+syslinuxcfg_module_OBJECTS = $(am_syslinuxcfg_module_OBJECTS) \
+ $(nodist_syslinuxcfg_module_OBJECTS)
+syslinuxcfg_module_LINK = $(CCLD) $(syslinuxcfg_module_CFLAGS) \
+ $(CFLAGS) $(syslinuxcfg_module_LDFLAGS) $(LDFLAGS) -o $@
+am_tar_module_OBJECTS = fs/tar_module-tar.$(OBJEXT)
+nodist_tar_module_OBJECTS =
+tar_module_OBJECTS = $(am_tar_module_OBJECTS) \
+ $(nodist_tar_module_OBJECTS)
+tar_module_LINK = $(CCLD) $(tar_module_CFLAGS) $(CFLAGS) \
+ $(tar_module_LDFLAGS) $(LDFLAGS) -o $@
+am_terminal_module_OBJECTS = \
+ commands/terminal_module-terminal.$(OBJEXT)
+nodist_terminal_module_OBJECTS =
+terminal_module_OBJECTS = $(am_terminal_module_OBJECTS) \
+ $(nodist_terminal_module_OBJECTS)
+terminal_module_LINK = $(CCLD) $(terminal_module_CFLAGS) $(CFLAGS) \
+ $(terminal_module_LDFLAGS) $(LDFLAGS) -o $@
+am__terminfo_module_SOURCES_DIST = term/terminfo.c term/tparm.c
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_ia64_efi_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_FALSE@@COND_i386_coreboot_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_FALSE@@COND_arm_efi_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@am_terminfo_module_OBJECTS = term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_coreboot_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_terminfo_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ term/terminfo_module-terminfo.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ term/terminfo_module-tparm.$(OBJEXT)
+nodist_terminfo_module_OBJECTS =
+terminfo_module_OBJECTS = $(am_terminfo_module_OBJECTS) \
+ $(nodist_terminfo_module_OBJECTS)
+terminfo_module_LINK = $(CCLD) $(terminfo_module_CFLAGS) $(CFLAGS) \
+ $(terminfo_module_LDFLAGS) $(LDFLAGS) -o $@
+am_test_module_OBJECTS = commands/test_module-test.$(OBJEXT)
+nodist_test_module_OBJECTS =
+test_module_OBJECTS = $(am_test_module_OBJECTS) \
+ $(nodist_test_module_OBJECTS)
+test_module_LINK = $(CCLD) $(test_module_CFLAGS) $(CFLAGS) \
+ $(test_module_LDFLAGS) $(LDFLAGS) -o $@
+am_test_blockarg_module_OBJECTS = \
+ tests/test_blockarg_module-test_blockarg.$(OBJEXT)
+nodist_test_blockarg_module_OBJECTS =
+test_blockarg_module_OBJECTS = $(am_test_blockarg_module_OBJECTS) \
+ $(nodist_test_blockarg_module_OBJECTS)
+test_blockarg_module_LINK = $(CCLD) $(test_blockarg_module_CFLAGS) \
+ $(CFLAGS) $(test_blockarg_module_LDFLAGS) $(LDFLAGS) -o $@
+am_testload_module_OBJECTS = \
+ commands/testload_module-testload.$(OBJEXT)
+nodist_testload_module_OBJECTS =
+testload_module_OBJECTS = $(am_testload_module_OBJECTS) \
+ $(nodist_testload_module_OBJECTS)
+testload_module_LINK = $(CCLD) $(testload_module_CFLAGS) $(CFLAGS) \
+ $(testload_module_LDFLAGS) $(LDFLAGS) -o $@
+am_testspeed_module_OBJECTS = \
+ commands/testspeed_module-testspeed.$(OBJEXT)
+nodist_testspeed_module_OBJECTS =
+testspeed_module_OBJECTS = $(am_testspeed_module_OBJECTS) \
+ $(nodist_testspeed_module_OBJECTS)
+testspeed_module_LINK = $(CCLD) $(testspeed_module_CFLAGS) $(CFLAGS) \
+ $(testspeed_module_LDFLAGS) $(LDFLAGS) -o $@
+am_tftp_module_OBJECTS = net/tftp_module-tftp.$(OBJEXT)
+nodist_tftp_module_OBJECTS =
+tftp_module_OBJECTS = $(am_tftp_module_OBJECTS) \
+ $(nodist_tftp_module_OBJECTS)
+tftp_module_LINK = $(CCLD) $(tftp_module_CFLAGS) $(CFLAGS) \
+ $(tftp_module_LDFLAGS) $(LDFLAGS) -o $@
+am_tga_module_OBJECTS = video/readers/tga_module-tga.$(OBJEXT)
+nodist_tga_module_OBJECTS =
+tga_module_OBJECTS = $(am_tga_module_OBJECTS) \
+ $(nodist_tga_module_OBJECTS)
+tga_module_LINK = $(CCLD) $(tga_module_CFLAGS) $(CFLAGS) \
+ $(tga_module_LDFLAGS) $(LDFLAGS) -o $@
+am_time_module_OBJECTS = commands/time_module-time.$(OBJEXT)
+nodist_time_module_OBJECTS =
+time_module_OBJECTS = $(am_time_module_OBJECTS) \
+ $(nodist_time_module_OBJECTS)
+time_module_LINK = $(CCLD) $(time_module_CFLAGS) $(CFLAGS) \
+ $(time_module_LDFLAGS) $(LDFLAGS) -o $@
+am__tpm_module_SOURCES_DIST = commands/efi/tpm.c commands/tpm.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@am_tpm_module_OBJECTS = commands/efi/tpm_module-tpm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_x86_64_efi_TRUE@ commands/tpm_module-tpm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_tpm_module_OBJECTS = commands/efi/tpm_module-tpm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ commands/tpm_module-tpm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@am_tpm_module_OBJECTS = commands/efi/tpm_module-tpm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_FALSE@@COND_riscv32_efi_TRUE@ commands/tpm_module-tpm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_TRUE@am_tpm_module_OBJECTS = commands/efi/tpm_module-tpm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_FALSE@@COND_ia64_efi_TRUE@ commands/tpm_module-tpm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_TRUE@am_tpm_module_OBJECTS = commands/efi/tpm_module-tpm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_i386_efi_TRUE@ commands/tpm_module-tpm.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_tpm_module_OBJECTS = commands/efi/tpm_module-tpm.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@ commands/tpm_module-tpm.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_tpm_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ commands/efi/tpm_module-tpm.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ commands/tpm_module-tpm.$(OBJEXT)
+nodist_tpm_module_OBJECTS =
+tpm_module_OBJECTS = $(am_tpm_module_OBJECTS) \
+ $(nodist_tpm_module_OBJECTS)
+tpm_module_LINK = $(CCLD) $(tpm_module_CFLAGS) $(CFLAGS) \
+ $(tpm_module_LDFLAGS) $(LDFLAGS) -o $@
+am_tr_module_OBJECTS = commands/tr_module-tr.$(OBJEXT)
+nodist_tr_module_OBJECTS =
+tr_module_OBJECTS = $(am_tr_module_OBJECTS) \
+ $(nodist_tr_module_OBJECTS)
+tr_module_LINK = $(CCLD) $(tr_module_CFLAGS) $(CFLAGS) \
+ $(tr_module_LDFLAGS) $(LDFLAGS) -o $@
+am_trig_module_OBJECTS =
+nodist_trig_module_OBJECTS = trig_module-trigtables.$(OBJEXT)
+trig_module_OBJECTS = $(am_trig_module_OBJECTS) \
+ $(nodist_trig_module_OBJECTS)
+trig_module_LINK = $(CCLD) $(trig_module_CFLAGS) $(CFLAGS) \
+ $(trig_module_LDFLAGS) $(LDFLAGS) -o $@
+am_true_module_OBJECTS = commands/true_module-true.$(OBJEXT)
+nodist_true_module_OBJECTS =
+true_module_OBJECTS = $(am_true_module_OBJECTS) \
+ $(nodist_true_module_OBJECTS)
+true_module_LINK = $(CCLD) $(true_module_CFLAGS) $(CFLAGS) \
+ $(true_module_LDFLAGS) $(LDFLAGS) -o $@
+am__truecrypt_module_SOURCES_DIST = loader/i386/pc/truecrypt.c
+@COND_i386_pc_TRUE@am_truecrypt_module_OBJECTS = loader/i386/pc/truecrypt_module-truecrypt.$(OBJEXT)
+nodist_truecrypt_module_OBJECTS =
+truecrypt_module_OBJECTS = $(am_truecrypt_module_OBJECTS) \
+ $(nodist_truecrypt_module_OBJECTS)
+truecrypt_module_LINK = $(CCLD) $(truecrypt_module_CFLAGS) $(CFLAGS) \
+ $(truecrypt_module_LDFLAGS) $(LDFLAGS) -o $@
+am__ubootnet_module_SOURCES_DIST = net/drivers/uboot/ubootnet.c
+@COND_arm_uboot_TRUE@am_ubootnet_module_OBJECTS = net/drivers/uboot/ubootnet_module-ubootnet.$(OBJEXT)
+nodist_ubootnet_module_OBJECTS =
+ubootnet_module_OBJECTS = $(am_ubootnet_module_OBJECTS) \
+ $(nodist_ubootnet_module_OBJECTS)
+ubootnet_module_LINK = $(CCLD) $(ubootnet_module_CFLAGS) $(CFLAGS) \
+ $(ubootnet_module_LDFLAGS) $(LDFLAGS) -o $@
+am_udf_module_OBJECTS = fs/udf_module-udf.$(OBJEXT)
+nodist_udf_module_OBJECTS =
+udf_module_OBJECTS = $(am_udf_module_OBJECTS) \
+ $(nodist_udf_module_OBJECTS)
+udf_module_LINK = $(CCLD) $(udf_module_CFLAGS) $(CFLAGS) \
+ $(udf_module_LDFLAGS) $(LDFLAGS) -o $@
+am_ufs1_module_OBJECTS = fs/ufs1_module-ufs.$(OBJEXT)
+nodist_ufs1_module_OBJECTS =
+ufs1_module_OBJECTS = $(am_ufs1_module_OBJECTS) \
+ $(nodist_ufs1_module_OBJECTS)
+ufs1_module_LINK = $(CCLD) $(ufs1_module_CFLAGS) $(CFLAGS) \
+ $(ufs1_module_LDFLAGS) $(LDFLAGS) -o $@
+am_ufs1_be_module_OBJECTS = fs/ufs1_be_module-ufs_be.$(OBJEXT)
+nodist_ufs1_be_module_OBJECTS =
+ufs1_be_module_OBJECTS = $(am_ufs1_be_module_OBJECTS) \
+ $(nodist_ufs1_be_module_OBJECTS)
+ufs1_be_module_LINK = $(CCLD) $(ufs1_be_module_CFLAGS) $(CFLAGS) \
+ $(ufs1_be_module_LDFLAGS) $(LDFLAGS) -o $@
+am_ufs2_module_OBJECTS = fs/ufs2_module-ufs2.$(OBJEXT)
+nodist_ufs2_module_OBJECTS =
+ufs2_module_OBJECTS = $(am_ufs2_module_OBJECTS) \
+ $(nodist_ufs2_module_OBJECTS)
+ufs2_module_LINK = $(CCLD) $(ufs2_module_CFLAGS) $(CFLAGS) \
+ $(ufs2_module_LDFLAGS) $(LDFLAGS) -o $@
+am__uhci_module_SOURCES_DIST = bus/usb/uhci.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_uhci_module_OBJECTS = bus/usb/uhci_module-uhci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_uhci_module_OBJECTS = bus/usb/uhci_module-uhci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_uhci_module_OBJECTS = bus/usb/uhci_module-uhci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_uhci_module_OBJECTS = bus/usb/uhci_module-uhci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_uhci_module_OBJECTS = bus/usb/uhci_module-uhci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_uhci_module_OBJECTS = bus/usb/uhci_module-uhci.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_uhci_module_OBJECTS = bus/usb/uhci_module-uhci.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_uhci_module_OBJECTS = \
+@COND_i386_coreboot_TRUE@ bus/usb/uhci_module-uhci.$(OBJEXT)
+nodist_uhci_module_OBJECTS =
+uhci_module_OBJECTS = $(am_uhci_module_OBJECTS) \
+ $(nodist_uhci_module_OBJECTS)
+uhci_module_LINK = $(CCLD) $(uhci_module_CFLAGS) $(CFLAGS) \
+ $(uhci_module_LDFLAGS) $(LDFLAGS) -o $@
+am__usb_module_SOURCES_DIST = bus/usb/usb.c bus/usb/usbtrans.c \
+ bus/usb/usbhub.c
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_usb_module_OBJECTS = bus/usb/usb_module-usb.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@ bus/usb/usb_module-usbtrans.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@ bus/usb/usb_module-usbhub.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_usb_module_OBJECTS = bus/usb/usb_module-usb.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@ bus/usb/usb_module-usbtrans.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@ bus/usb/usb_module-usbhub.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_usb_module_OBJECTS = bus/usb/usb_module-usb.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ bus/usb/usb_module-usbtrans.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ bus/usb/usb_module-usbhub.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_usb_module_OBJECTS = bus/usb/usb_module-usb.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ bus/usb/usb_module-usbtrans.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ bus/usb/usb_module-usbhub.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_usb_module_OBJECTS = bus/usb/usb_module-usb.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ bus/usb/usb_module-usbtrans.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ bus/usb/usb_module-usbhub.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_usb_module_OBJECTS = bus/usb/usb_module-usb.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ bus/usb/usb_module-usbtrans.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ bus/usb/usb_module-usbhub.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_usb_module_OBJECTS = bus/usb/usb_module-usb.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ bus/usb/usb_module-usbtrans.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ bus/usb/usb_module-usbhub.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@am_usb_module_OBJECTS = bus/usb/usb_module-usb.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@ bus/usb/usb_module-usbtrans.$(OBJEXT) \
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@ bus/usb/usb_module-usbhub.$(OBJEXT)
+@COND_arm_coreboot_TRUE@am_usb_module_OBJECTS = \
+@COND_arm_coreboot_TRUE@ bus/usb/usb_module-usb.$(OBJEXT) \
+@COND_arm_coreboot_TRUE@ bus/usb/usb_module-usbtrans.$(OBJEXT) \
+@COND_arm_coreboot_TRUE@ bus/usb/usb_module-usbhub.$(OBJEXT)
+nodist_usb_module_OBJECTS =
+usb_module_OBJECTS = $(am_usb_module_OBJECTS) \
+ $(nodist_usb_module_OBJECTS)
+usb_module_LINK = $(CCLD) $(usb_module_CFLAGS) $(CFLAGS) \
+ $(usb_module_LDFLAGS) $(LDFLAGS) -o $@
+am__usb_keyboard_module_SOURCES_DIST = term/usb_keyboard.c
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_usb_keyboard_module_OBJECTS = term/usb_keyboard_module-usb_keyboard.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_usb_keyboard_module_OBJECTS = term/usb_keyboard_module-usb_keyboard.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_usb_keyboard_module_OBJECTS = term/usb_keyboard_module-usb_keyboard.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_usb_keyboard_module_OBJECTS = term/usb_keyboard_module-usb_keyboard.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_usb_keyboard_module_OBJECTS = term/usb_keyboard_module-usb_keyboard.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_usb_keyboard_module_OBJECTS = term/usb_keyboard_module-usb_keyboard.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_usb_keyboard_module_OBJECTS = term/usb_keyboard_module-usb_keyboard.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@am_usb_keyboard_module_OBJECTS = term/usb_keyboard_module-usb_keyboard.$(OBJEXT)
+@COND_arm_coreboot_TRUE@am_usb_keyboard_module_OBJECTS = term/usb_keyboard_module-usb_keyboard.$(OBJEXT)
+nodist_usb_keyboard_module_OBJECTS =
+usb_keyboard_module_OBJECTS = $(am_usb_keyboard_module_OBJECTS) \
+ $(nodist_usb_keyboard_module_OBJECTS)
+usb_keyboard_module_LINK = $(CCLD) $(usb_keyboard_module_CFLAGS) \
+ $(CFLAGS) $(usb_keyboard_module_LDFLAGS) $(LDFLAGS) -o $@
+am__usbms_module_SOURCES_DIST = disk/usbms.c
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_usbms_module_OBJECTS = disk/usbms_module-usbms.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_usbms_module_OBJECTS = disk/usbms_module-usbms.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_usbms_module_OBJECTS = disk/usbms_module-usbms.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_usbms_module_OBJECTS = disk/usbms_module-usbms.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_usbms_module_OBJECTS = disk/usbms_module-usbms.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_usbms_module_OBJECTS = disk/usbms_module-usbms.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_usbms_module_OBJECTS = disk/usbms_module-usbms.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@am_usbms_module_OBJECTS = disk/usbms_module-usbms.$(OBJEXT)
+@COND_arm_coreboot_TRUE@am_usbms_module_OBJECTS = \
+@COND_arm_coreboot_TRUE@ disk/usbms_module-usbms.$(OBJEXT)
+nodist_usbms_module_OBJECTS =
+usbms_module_OBJECTS = $(am_usbms_module_OBJECTS) \
+ $(nodist_usbms_module_OBJECTS)
+usbms_module_LINK = $(CCLD) $(usbms_module_CFLAGS) $(CFLAGS) \
+ $(usbms_module_LDFLAGS) $(LDFLAGS) -o $@
+am__usbserial_common_module_SOURCES_DIST = bus/usb/serial/common.c
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_usbserial_common_module_OBJECTS = bus/usb/serial/usbserial_common_module-common.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_usbserial_common_module_OBJECTS = bus/usb/serial/usbserial_common_module-common.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_usbserial_common_module_OBJECTS = bus/usb/serial/usbserial_common_module-common.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_usbserial_common_module_OBJECTS = bus/usb/serial/usbserial_common_module-common.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_usbserial_common_module_OBJECTS = bus/usb/serial/usbserial_common_module-common.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_usbserial_common_module_OBJECTS = bus/usb/serial/usbserial_common_module-common.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_usbserial_common_module_OBJECTS = bus/usb/serial/usbserial_common_module-common.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@am_usbserial_common_module_OBJECTS = bus/usb/serial/usbserial_common_module-common.$(OBJEXT)
+@COND_arm_coreboot_TRUE@am_usbserial_common_module_OBJECTS = bus/usb/serial/usbserial_common_module-common.$(OBJEXT)
+nodist_usbserial_common_module_OBJECTS =
+usbserial_common_module_OBJECTS = \
+ $(am_usbserial_common_module_OBJECTS) \
+ $(nodist_usbserial_common_module_OBJECTS)
+usbserial_common_module_LINK = $(CCLD) \
+ $(usbserial_common_module_CFLAGS) $(CFLAGS) \
+ $(usbserial_common_module_LDFLAGS) $(LDFLAGS) -o $@
+am__usbserial_ftdi_module_SOURCES_DIST = bus/usb/serial/ftdi.c
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_usbserial_ftdi_module_OBJECTS = bus/usb/serial/usbserial_ftdi_module-ftdi.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_usbserial_ftdi_module_OBJECTS = bus/usb/serial/usbserial_ftdi_module-ftdi.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_usbserial_ftdi_module_OBJECTS = bus/usb/serial/usbserial_ftdi_module-ftdi.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_usbserial_ftdi_module_OBJECTS = bus/usb/serial/usbserial_ftdi_module-ftdi.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_usbserial_ftdi_module_OBJECTS = bus/usb/serial/usbserial_ftdi_module-ftdi.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_usbserial_ftdi_module_OBJECTS = bus/usb/serial/usbserial_ftdi_module-ftdi.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_usbserial_ftdi_module_OBJECTS = bus/usb/serial/usbserial_ftdi_module-ftdi.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@am_usbserial_ftdi_module_OBJECTS = bus/usb/serial/usbserial_ftdi_module-ftdi.$(OBJEXT)
+@COND_arm_coreboot_TRUE@am_usbserial_ftdi_module_OBJECTS = bus/usb/serial/usbserial_ftdi_module-ftdi.$(OBJEXT)
+nodist_usbserial_ftdi_module_OBJECTS =
+usbserial_ftdi_module_OBJECTS = $(am_usbserial_ftdi_module_OBJECTS) \
+ $(nodist_usbserial_ftdi_module_OBJECTS)
+usbserial_ftdi_module_LINK = $(CCLD) $(usbserial_ftdi_module_CFLAGS) \
+ $(CFLAGS) $(usbserial_ftdi_module_LDFLAGS) $(LDFLAGS) -o $@
+am__usbserial_pl2303_module_SOURCES_DIST = bus/usb/serial/pl2303.c
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_usbserial_pl2303_module_OBJECTS = bus/usb/serial/usbserial_pl2303_module-pl2303.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_usbserial_pl2303_module_OBJECTS = bus/usb/serial/usbserial_pl2303_module-pl2303.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_usbserial_pl2303_module_OBJECTS = bus/usb/serial/usbserial_pl2303_module-pl2303.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_usbserial_pl2303_module_OBJECTS = bus/usb/serial/usbserial_pl2303_module-pl2303.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_usbserial_pl2303_module_OBJECTS = bus/usb/serial/usbserial_pl2303_module-pl2303.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_usbserial_pl2303_module_OBJECTS = bus/usb/serial/usbserial_pl2303_module-pl2303.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_usbserial_pl2303_module_OBJECTS = bus/usb/serial/usbserial_pl2303_module-pl2303.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@am_usbserial_pl2303_module_OBJECTS = bus/usb/serial/usbserial_pl2303_module-pl2303.$(OBJEXT)
+@COND_arm_coreboot_TRUE@am_usbserial_pl2303_module_OBJECTS = bus/usb/serial/usbserial_pl2303_module-pl2303.$(OBJEXT)
+nodist_usbserial_pl2303_module_OBJECTS =
+usbserial_pl2303_module_OBJECTS = \
+ $(am_usbserial_pl2303_module_OBJECTS) \
+ $(nodist_usbserial_pl2303_module_OBJECTS)
+usbserial_pl2303_module_LINK = $(CCLD) \
+ $(usbserial_pl2303_module_CFLAGS) $(CFLAGS) \
+ $(usbserial_pl2303_module_LDFLAGS) $(LDFLAGS) -o $@
+am__usbserial_usbdebug_module_SOURCES_DIST = \
+ bus/usb/serial/usbdebug_late.c
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_usbserial_usbdebug_module_OBJECTS = bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_usbserial_usbdebug_module_OBJECTS = bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_usbserial_usbdebug_module_OBJECTS = bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_usbserial_usbdebug_module_OBJECTS = bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_usbserial_usbdebug_module_OBJECTS = bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_usbserial_usbdebug_module_OBJECTS = bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_usbserial_usbdebug_module_OBJECTS = bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@am_usbserial_usbdebug_module_OBJECTS = bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.$(OBJEXT)
+@COND_arm_coreboot_TRUE@am_usbserial_usbdebug_module_OBJECTS = bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.$(OBJEXT)
+nodist_usbserial_usbdebug_module_OBJECTS =
+usbserial_usbdebug_module_OBJECTS = \
+ $(am_usbserial_usbdebug_module_OBJECTS) \
+ $(nodist_usbserial_usbdebug_module_OBJECTS)
+usbserial_usbdebug_module_LINK = $(CCLD) \
+ $(usbserial_usbdebug_module_CFLAGS) $(CFLAGS) \
+ $(usbserial_usbdebug_module_LDFLAGS) $(LDFLAGS) -o $@
+am__usbtest_module_SOURCES_DIST = commands/usbtest.c
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_FALSE@@COND_x86_64_efi_TRUE@am_usbtest_module_OBJECTS = commands/usbtest_module-usbtest.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_mips_loongson_TRUE@am_usbtest_module_OBJECTS = commands/usbtest_module-usbtest.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_usbtest_module_OBJECTS = commands/usbtest_module-usbtest.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_usbtest_module_OBJECTS = commands/usbtest_module-usbtest.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_usbtest_module_OBJECTS = commands/usbtest_module-usbtest.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_usbtest_module_OBJECTS = commands/usbtest_module-usbtest.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_usbtest_module_OBJECTS = commands/usbtest_module-usbtest.$(OBJEXT)
+@COND_arm_coreboot_FALSE@@COND_i386_coreboot_TRUE@am_usbtest_module_OBJECTS = commands/usbtest_module-usbtest.$(OBJEXT)
+@COND_arm_coreboot_TRUE@am_usbtest_module_OBJECTS = commands/usbtest_module-usbtest.$(OBJEXT)
+nodist_usbtest_module_OBJECTS =
+usbtest_module_OBJECTS = $(am_usbtest_module_OBJECTS) \
+ $(nodist_usbtest_module_OBJECTS)
+usbtest_module_LINK = $(CCLD) $(usbtest_module_CFLAGS) $(CFLAGS) \
+ $(usbtest_module_LDFLAGS) $(LDFLAGS) -o $@
+am__vbe_module_SOURCES_DIST = video/i386/pc/vbe.c
+@COND_i386_pc_TRUE@am_vbe_module_OBJECTS = \
+@COND_i386_pc_TRUE@ video/i386/pc/vbe_module-vbe.$(OBJEXT)
+nodist_vbe_module_OBJECTS =
+vbe_module_OBJECTS = $(am_vbe_module_OBJECTS) \
+ $(nodist_vbe_module_OBJECTS)
+vbe_module_LINK = $(CCLD) $(vbe_module_CFLAGS) $(CFLAGS) \
+ $(vbe_module_LDFLAGS) $(LDFLAGS) -o $@
+am__vga_module_SOURCES_DIST = video/i386/pc/vga.c
+@COND_i386_pc_TRUE@am_vga_module_OBJECTS = \
+@COND_i386_pc_TRUE@ video/i386/pc/vga_module-vga.$(OBJEXT)
+nodist_vga_module_OBJECTS =
+vga_module_OBJECTS = $(am_vga_module_OBJECTS) \
+ $(nodist_vga_module_OBJECTS)
+vga_module_LINK = $(CCLD) $(vga_module_CFLAGS) $(CFLAGS) \
+ $(vga_module_LDFLAGS) $(LDFLAGS) -o $@
+am__vga_text_module_SOURCES_DIST = term/i386/pc/vga_text.c
+@COND_i386_pc_TRUE@am_vga_text_module_OBJECTS = term/i386/pc/vga_text_module-vga_text.$(OBJEXT)
+nodist_vga_text_module_OBJECTS =
+vga_text_module_OBJECTS = $(am_vga_text_module_OBJECTS) \
+ $(nodist_vga_text_module_OBJECTS)
+vga_text_module_LINK = $(CCLD) $(vga_text_module_CFLAGS) $(CFLAGS) \
+ $(vga_text_module_LDFLAGS) $(LDFLAGS) -o $@
+am__video_module_SOURCES_DIST = video/video.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_video_module_OBJECTS = video/video_module-video.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_video_module_OBJECTS = \
+@COND_arm64_efi_TRUE@ video/video_module-video.$(OBJEXT)
+nodist_video_module_OBJECTS =
+video_module_OBJECTS = $(am_video_module_OBJECTS) \
+ $(nodist_video_module_OBJECTS)
+video_module_LINK = $(CCLD) $(video_module_CFLAGS) $(CFLAGS) \
+ $(video_module_LDFLAGS) $(LDFLAGS) -o $@
+am__video_bochs_module_SOURCES_DIST = video/bochs.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_video_bochs_module_OBJECTS = video/video_bochs_module-bochs.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_video_bochs_module_OBJECTS = video/video_bochs_module-bochs.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_video_bochs_module_OBJECTS = video/video_bochs_module-bochs.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_video_bochs_module_OBJECTS = video/video_bochs_module-bochs.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_video_bochs_module_OBJECTS = video/video_bochs_module-bochs.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_video_bochs_module_OBJECTS = video/video_bochs_module-bochs.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_video_bochs_module_OBJECTS = video/video_bochs_module-bochs.$(OBJEXT)
+nodist_video_bochs_module_OBJECTS =
+video_bochs_module_OBJECTS = $(am_video_bochs_module_OBJECTS) \
+ $(nodist_video_bochs_module_OBJECTS)
+video_bochs_module_LINK = $(CCLD) $(video_bochs_module_CFLAGS) \
+ $(CFLAGS) $(video_bochs_module_LDFLAGS) $(LDFLAGS) -o $@
+am__video_cirrus_module_SOURCES_DIST = video/cirrus.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_video_cirrus_module_OBJECTS = video/video_cirrus_module-cirrus.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_video_cirrus_module_OBJECTS = video/video_cirrus_module-cirrus.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_video_cirrus_module_OBJECTS = video/video_cirrus_module-cirrus.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_video_cirrus_module_OBJECTS = video/video_cirrus_module-cirrus.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_video_cirrus_module_OBJECTS = video/video_cirrus_module-cirrus.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_video_cirrus_module_OBJECTS = video/video_cirrus_module-cirrus.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_video_cirrus_module_OBJECTS = video/video_cirrus_module-cirrus.$(OBJEXT)
+nodist_video_cirrus_module_OBJECTS =
+video_cirrus_module_OBJECTS = $(am_video_cirrus_module_OBJECTS) \
+ $(nodist_video_cirrus_module_OBJECTS)
+video_cirrus_module_LINK = $(CCLD) $(video_cirrus_module_CFLAGS) \
+ $(CFLAGS) $(video_cirrus_module_LDFLAGS) $(LDFLAGS) -o $@
+am_video_colors_module_OBJECTS = \
+ video/video_colors_module-colors.$(OBJEXT)
+nodist_video_colors_module_OBJECTS =
+video_colors_module_OBJECTS = $(am_video_colors_module_OBJECTS) \
+ $(nodist_video_colors_module_OBJECTS)
+video_colors_module_LINK = $(CCLD) $(video_colors_module_CFLAGS) \
+ $(CFLAGS) $(video_colors_module_LDFLAGS) $(LDFLAGS) -o $@
+am__video_fb_module_SOURCES_DIST = video/fb/video_fb.c \
+ video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_FALSE@@COND_x86_64_xen_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_FALSE@@COND_x86_64_efi_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_FALSE@@COND_sparc64_ieee1275_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_FALSE@@COND_riscv64_efi_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_FALSE@@COND_riscv32_efi_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_FALSE@@COND_powerpc_ieee1275_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_FALSE@@COND_mips_qemu_mips_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_FALSE@@COND_mips_arc_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_FALSE@@COND_ia64_efi_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_FALSE@@COND_i386_xen_pvh_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_i386_xen_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_FALSE@@COND_i386_efi_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_FALSE@@COND_emu_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_FALSE@@COND_arm_uboot_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_FALSE@@COND_arm_efi_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+@COND_arm64_efi_TRUE@am_video_fb_module_OBJECTS = video/fb/video_fb_module-video_fb.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ video/fb/video_fb_module-fbblit.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ video/fb/video_fb_module-fbfill.$(OBJEXT) \
+@COND_arm64_efi_TRUE@ video/fb/video_fb_module-fbutil.$(OBJEXT)
+nodist_video_fb_module_OBJECTS =
+video_fb_module_OBJECTS = $(am_video_fb_module_OBJECTS) \
+ $(nodist_video_fb_module_OBJECTS)
+video_fb_module_LINK = $(CCLD) $(video_fb_module_CFLAGS) $(CFLAGS) \
+ $(video_fb_module_LDFLAGS) $(LDFLAGS) -o $@
+am_videoinfo_module_OBJECTS = \
+ commands/videoinfo_module-videoinfo.$(OBJEXT)
+nodist_videoinfo_module_OBJECTS =
+videoinfo_module_OBJECTS = $(am_videoinfo_module_OBJECTS) \
+ $(nodist_videoinfo_module_OBJECTS)
+videoinfo_module_LINK = $(CCLD) $(videoinfo_module_CFLAGS) $(CFLAGS) \
+ $(videoinfo_module_LDFLAGS) $(LDFLAGS) -o $@
+am_videotest_module_OBJECTS = \
+ commands/videotest_module-videotest.$(OBJEXT)
+nodist_videotest_module_OBJECTS =
+videotest_module_OBJECTS = $(am_videotest_module_OBJECTS) \
+ $(nodist_videotest_module_OBJECTS)
+videotest_module_LINK = $(CCLD) $(videotest_module_CFLAGS) $(CFLAGS) \
+ $(videotest_module_LDFLAGS) $(LDFLAGS) -o $@
+am_videotest_checksum_module_OBJECTS = \
+ tests/videotest_checksum_module-videotest_checksum.$(OBJEXT)
+nodist_videotest_checksum_module_OBJECTS =
+videotest_checksum_module_OBJECTS = \
+ $(am_videotest_checksum_module_OBJECTS) \
+ $(nodist_videotest_checksum_module_OBJECTS)
+videotest_checksum_module_LINK = $(CCLD) \
+ $(videotest_checksum_module_CFLAGS) $(CFLAGS) \
+ $(videotest_checksum_module_LDFLAGS) $(LDFLAGS) -o $@
+am__wrmsr_module_SOURCES_DIST = commands/i386/wrmsr.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_FALSE@@COND_x86_64_efi_TRUE@am_wrmsr_module_OBJECTS = commands/i386/wrmsr_module-wrmsr.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_i386_qemu_TRUE@am_wrmsr_module_OBJECTS = commands/i386/wrmsr_module-wrmsr.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_wrmsr_module_OBJECTS = commands/i386/wrmsr_module-wrmsr.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_FALSE@@COND_i386_multiboot_TRUE@am_wrmsr_module_OBJECTS = commands/i386/wrmsr_module-wrmsr.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_ieee1275_TRUE@am_wrmsr_module_OBJECTS = commands/i386/wrmsr_module-wrmsr.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_wrmsr_module_OBJECTS = commands/i386/wrmsr_module-wrmsr.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_wrmsr_module_OBJECTS = commands/i386/wrmsr_module-wrmsr.$(OBJEXT)
+nodist_wrmsr_module_OBJECTS =
+wrmsr_module_OBJECTS = $(am_wrmsr_module_OBJECTS) \
+ $(nodist_wrmsr_module_OBJECTS)
+wrmsr_module_LINK = $(CCLD) $(wrmsr_module_CFLAGS) $(CFLAGS) \
+ $(wrmsr_module_LDFLAGS) $(LDFLAGS) -o $@
+am__xen_boot_module_SOURCES_DIST = loader/arm64/xen_boot.c
+@COND_arm64_efi_TRUE@am_xen_boot_module_OBJECTS = loader/arm64/xen_boot_module-xen_boot.$(OBJEXT)
+nodist_xen_boot_module_OBJECTS =
+xen_boot_module_OBJECTS = $(am_xen_boot_module_OBJECTS) \
+ $(nodist_xen_boot_module_OBJECTS)
+xen_boot_module_LINK = $(CCLD) $(xen_boot_module_CFLAGS) $(CFLAGS) \
+ $(xen_boot_module_LDFLAGS) $(LDFLAGS) -o $@
+am_xfs_module_OBJECTS = fs/xfs_module-xfs.$(OBJEXT)
+nodist_xfs_module_OBJECTS =
+xfs_module_OBJECTS = $(am_xfs_module_OBJECTS) \
+ $(nodist_xfs_module_OBJECTS)
+xfs_module_LINK = $(CCLD) $(xfs_module_CFLAGS) $(CFLAGS) \
+ $(xfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am__xnu_module_SOURCES_DIST = loader/xnu_resume.c loader/i386/xnu.c \
+ loader/xnu.c
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_x86_64_efi_TRUE@am_xnu_module_OBJECTS = loader/xnu_module-xnu_resume.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_x86_64_efi_TRUE@ loader/i386/xnu_module-xnu.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_FALSE@@COND_x86_64_efi_TRUE@ loader/xnu_module-xnu.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@am_xnu_module_OBJECTS = loader/xnu_module-xnu_resume.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ loader/i386/xnu_module-xnu.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_FALSE@@COND_i386_pc_TRUE@ loader/xnu_module-xnu.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@am_xnu_module_OBJECTS = loader/xnu_module-xnu_resume.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@ loader/i386/xnu_module-xnu.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_FALSE@@COND_i386_multiboot_TRUE@ loader/xnu_module-xnu.$(OBJEXT)
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@am_xnu_module_OBJECTS = loader/xnu_module-xnu_resume.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ loader/i386/xnu_module-xnu.$(OBJEXT) \
+@COND_i386_coreboot_FALSE@@COND_i386_efi_TRUE@ loader/xnu_module-xnu.$(OBJEXT)
+@COND_i386_coreboot_TRUE@am_xnu_module_OBJECTS = loader/xnu_module-xnu_resume.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ loader/i386/xnu_module-xnu.$(OBJEXT) \
+@COND_i386_coreboot_TRUE@ loader/xnu_module-xnu.$(OBJEXT)
+nodist_xnu_module_OBJECTS =
+xnu_module_OBJECTS = $(am_xnu_module_OBJECTS) \
+ $(nodist_xnu_module_OBJECTS)
+xnu_module_LINK = $(CCLD) $(xnu_module_CFLAGS) $(CFLAGS) \
+ $(xnu_module_LDFLAGS) $(LDFLAGS) -o $@
+am_xnu_uuid_module_OBJECTS = \
+ commands/xnu_uuid_module-xnu_uuid.$(OBJEXT)
+nodist_xnu_uuid_module_OBJECTS =
+xnu_uuid_module_OBJECTS = $(am_xnu_uuid_module_OBJECTS) \
+ $(nodist_xnu_uuid_module_OBJECTS)
+xnu_uuid_module_LINK = $(CCLD) $(xnu_uuid_module_CFLAGS) $(CFLAGS) \
+ $(xnu_uuid_module_LDFLAGS) $(LDFLAGS) -o $@
+am_xnu_uuid_test_module_OBJECTS = \
+ tests/xnu_uuid_test_module-xnu_uuid_test.$(OBJEXT)
+nodist_xnu_uuid_test_module_OBJECTS =
+xnu_uuid_test_module_OBJECTS = $(am_xnu_uuid_test_module_OBJECTS) \
+ $(nodist_xnu_uuid_test_module_OBJECTS)
+xnu_uuid_test_module_LINK = $(CCLD) $(xnu_uuid_test_module_CFLAGS) \
+ $(CFLAGS) $(xnu_uuid_test_module_LDFLAGS) $(LDFLAGS) -o $@
+am__xz_decompress_image_SOURCES_DIST = boot/mips/startup_raw.S \
+ boot/decompressor/minilib.c boot/decompressor/xz.c \
+ lib/xzembed/xz_dec_bcj.c lib/xzembed/xz_dec_lzma2.c \
+ lib/xzembed/xz_dec_stream.c kern/compiler-rt.c
+@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@am_xz_decompress_image_OBJECTS = boot/mips/xz_decompress_image-startup_raw.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ boot/decompressor/xz_decompress_image-minilib.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ boot/decompressor/xz_decompress_image-xz.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ lib/xzembed/xz_decompress_image-xz_dec_bcj.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ lib/xzembed/xz_decompress_image-xz_dec_lzma2.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ lib/xzembed/xz_decompress_image-xz_dec_stream.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_FALSE@@COND_mips_qemu_mips_TRUE@ kern/xz_decompress_image-compiler-rt.$(OBJEXT)
+@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@am_xz_decompress_image_OBJECTS = boot/mips/xz_decompress_image-startup_raw.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ boot/decompressor/xz_decompress_image-minilib.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ boot/decompressor/xz_decompress_image-xz.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ lib/xzembed/xz_decompress_image-xz_dec_bcj.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ lib/xzembed/xz_decompress_image-xz_dec_lzma2.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ lib/xzembed/xz_decompress_image-xz_dec_stream.$(OBJEXT) \
+@COND_mips_arc_FALSE@@COND_mips_loongson_TRUE@ kern/xz_decompress_image-compiler-rt.$(OBJEXT)
+@COND_mips_arc_TRUE@am_xz_decompress_image_OBJECTS = boot/mips/xz_decompress_image-startup_raw.$(OBJEXT) \
+@COND_mips_arc_TRUE@ boot/decompressor/xz_decompress_image-minilib.$(OBJEXT) \
+@COND_mips_arc_TRUE@ boot/decompressor/xz_decompress_image-xz.$(OBJEXT) \
+@COND_mips_arc_TRUE@ lib/xzembed/xz_decompress_image-xz_dec_bcj.$(OBJEXT) \
+@COND_mips_arc_TRUE@ lib/xzembed/xz_decompress_image-xz_dec_lzma2.$(OBJEXT) \
+@COND_mips_arc_TRUE@ lib/xzembed/xz_decompress_image-xz_dec_stream.$(OBJEXT) \
+@COND_mips_arc_TRUE@ kern/xz_decompress_image-compiler-rt.$(OBJEXT)
+nodist_xz_decompress_image_OBJECTS =
+xz_decompress_image_OBJECTS = $(am_xz_decompress_image_OBJECTS) \
+ $(nodist_xz_decompress_image_OBJECTS)
+xz_decompress_image_DEPENDENCIES =
+xz_decompress_image_LINK = $(CCLD) $(xz_decompress_image_CFLAGS) \
+ $(CFLAGS) $(xz_decompress_image_LDFLAGS) $(LDFLAGS) -o $@
+am_xzio_module_OBJECTS = io/xzio_module-xzio.$(OBJEXT) \
+ lib/xzembed/xzio_module-xz_dec_bcj.$(OBJEXT) \
+ lib/xzembed/xzio_module-xz_dec_lzma2.$(OBJEXT) \
+ lib/xzembed/xzio_module-xz_dec_stream.$(OBJEXT)
+nodist_xzio_module_OBJECTS =
+xzio_module_OBJECTS = $(am_xzio_module_OBJECTS) \
+ $(nodist_xzio_module_OBJECTS)
+xzio_module_LINK = $(CCLD) $(xzio_module_CFLAGS) $(CFLAGS) \
+ $(xzio_module_LDFLAGS) $(LDFLAGS) -o $@
+am_zfs_module_OBJECTS = fs/zfs/zfs_module-zfs.$(OBJEXT) \
+ fs/zfs/zfs_module-zfs_lzjb.$(OBJEXT) \
+ fs/zfs/zfs_module-zfs_lz4.$(OBJEXT) \
+ fs/zfs/zfs_module-zfs_sha256.$(OBJEXT) \
+ fs/zfs/zfs_module-zfs_fletcher.$(OBJEXT)
+nodist_zfs_module_OBJECTS =
+zfs_module_OBJECTS = $(am_zfs_module_OBJECTS) \
+ $(nodist_zfs_module_OBJECTS)
+zfs_module_LINK = $(CCLD) $(zfs_module_CFLAGS) $(CFLAGS) \
+ $(zfs_module_LDFLAGS) $(LDFLAGS) -o $@
+am_zfscrypt_module_OBJECTS = \
+ fs/zfs/zfscrypt_module-zfscrypt.$(OBJEXT)
+nodist_zfscrypt_module_OBJECTS =
+zfscrypt_module_OBJECTS = $(am_zfscrypt_module_OBJECTS) \
+ $(nodist_zfscrypt_module_OBJECTS)
+zfscrypt_module_LINK = $(CCLD) $(zfscrypt_module_CFLAGS) $(CFLAGS) \
+ $(zfscrypt_module_LDFLAGS) $(LDFLAGS) -o $@
+am_zfsinfo_module_OBJECTS = fs/zfs/zfsinfo_module-zfsinfo.$(OBJEXT)
+nodist_zfsinfo_module_OBJECTS =
+zfsinfo_module_OBJECTS = $(am_zfsinfo_module_OBJECTS) \
+ $(nodist_zfsinfo_module_OBJECTS)
+zfsinfo_module_LINK = $(CCLD) $(zfsinfo_module_CFLAGS) $(CFLAGS) \
+ $(zfsinfo_module_LDFLAGS) $(LDFLAGS) -o $@
+am_zstd_module_OBJECTS = lib/zstd/zstd_module-debug.$(OBJEXT) \
+ lib/zstd/zstd_module-entropy_common.$(OBJEXT) \
+ lib/zstd/zstd_module-error_private.$(OBJEXT) \
+ lib/zstd/zstd_module-fse_decompress.$(OBJEXT) \
+ lib/zstd/zstd_module-huf_decompress.$(OBJEXT) \
+ lib/zstd/zstd_module-module.$(OBJEXT) \
+ lib/zstd/zstd_module-xxhash.$(OBJEXT) \
+ lib/zstd/zstd_module-zstd_common.$(OBJEXT) \
+ lib/zstd/zstd_module-zstd_decompress.$(OBJEXT)
+nodist_zstd_module_OBJECTS =
+zstd_module_OBJECTS = $(am_zstd_module_OBJECTS) \
+ $(nodist_zstd_module_OBJECTS)
+zstd_module_LINK = $(CCLD) $(zstd_module_CFLAGS) $(CFLAGS) \
+ $(zstd_module_LDFLAGS) $(LDFLAGS) -o $@
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+SCRIPTS = $(bin_SCRIPTS) $(grubconf_SCRIPTS) $(noinst_SCRIPTS) \
+ $(platform_SCRIPTS) $(sbin_SCRIPTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)
+AM_V_CPPAS = $(am__v_CPPAS_@AM_V@)
+am__v_CPPAS_ = $(am__v_CPPAS_@AM_DEFAULT_V@)
+am__v_CPPAS_0 = @echo " CPPAS " $@;
+am__v_CPPAS_1 =
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES) \
+ $(adler32_module_SOURCES) $(nodist_adler32_module_SOURCES) \
+ $(affs_module_SOURCES) $(nodist_affs_module_SOURCES) \
+ $(afs_module_SOURCES) $(nodist_afs_module_SOURCES) \
+ $(afsplitter_module_SOURCES) \
+ $(nodist_afsplitter_module_SOURCES) $(ahci_module_SOURCES) \
+ $(nodist_ahci_module_SOURCES) $(all_video_module_SOURCES) \
+ $(nodist_all_video_module_SOURCES) $(aout_module_SOURCES) \
+ $(nodist_aout_module_SOURCES) $(appleldr_module_SOURCES) \
+ $(nodist_appleldr_module_SOURCES) $(archelp_module_SOURCES) \
+ $(nodist_archelp_module_SOURCES) $(at_keyboard_module_SOURCES) \
+ $(nodist_at_keyboard_module_SOURCES) $(ata_module_SOURCES) \
+ $(nodist_ata_module_SOURCES) $(backtrace_module_SOURCES) \
+ $(nodist_backtrace_module_SOURCES) $(bfs_module_SOURCES) \
+ $(nodist_bfs_module_SOURCES) $(biosdisk_module_SOURCES) \
+ $(nodist_biosdisk_module_SOURCES) $(bitmap_module_SOURCES) \
+ $(nodist_bitmap_module_SOURCES) $(bitmap_scale_module_SOURCES) \
+ $(nodist_bitmap_scale_module_SOURCES) \
+ $(blocklist_module_SOURCES) $(nodist_blocklist_module_SOURCES) \
+ $(boot_image_SOURCES) $(nodist_boot_image_SOURCES) \
+ $(boot_module_SOURCES) $(nodist_boot_module_SOURCES) \
+ $(boot_hybrid_image_SOURCES) \
+ $(nodist_boot_hybrid_image_SOURCES) $(boottime_module_SOURCES) \
+ $(nodist_boottime_module_SOURCES) $(bsd_module_SOURCES) \
+ $(nodist_bsd_module_SOURCES) $(bswap_test_module_SOURCES) \
+ $(nodist_bswap_test_module_SOURCES) $(btrfs_module_SOURCES) \
+ $(nodist_btrfs_module_SOURCES) $(bufio_module_SOURCES) \
+ $(nodist_bufio_module_SOURCES) $(cacheinfo_module_SOURCES) \
+ $(nodist_cacheinfo_module_SOURCES) $(cat_module_SOURCES) \
+ $(nodist_cat_module_SOURCES) $(cbfs_module_SOURCES) \
+ $(nodist_cbfs_module_SOURCES) $(cbls_module_SOURCES) \
+ $(nodist_cbls_module_SOURCES) $(cbmemc_module_SOURCES) \
+ $(nodist_cbmemc_module_SOURCES) $(cbtable_module_SOURCES) \
+ $(nodist_cbtable_module_SOURCES) $(cbtime_module_SOURCES) \
+ $(nodist_cbtime_module_SOURCES) $(cdboot_image_SOURCES) \
+ $(nodist_cdboot_image_SOURCES) $(chain_module_SOURCES) \
+ $(nodist_chain_module_SOURCES) \
+ $(cmdline_cat_test_module_SOURCES) \
+ $(nodist_cmdline_cat_test_module_SOURCES) \
+ $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES) \
+ $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES) \
+ $(cmp_module_SOURCES) $(nodist_cmp_module_SOURCES) \
+ $(cmp_test_module_SOURCES) $(nodist_cmp_test_module_SOURCES) \
+ $(configfile_module_SOURCES) \
+ $(nodist_configfile_module_SOURCES) $(cpio_module_SOURCES) \
+ $(nodist_cpio_module_SOURCES) $(cpio_be_module_SOURCES) \
+ $(nodist_cpio_be_module_SOURCES) $(cpuid_module_SOURCES) \
+ $(nodist_cpuid_module_SOURCES) $(crc64_module_SOURCES) \
+ $(nodist_crc64_module_SOURCES) $(crypto_module_SOURCES) \
+ $(nodist_crypto_module_SOURCES) $(cryptodisk_module_SOURCES) \
+ $(nodist_cryptodisk_module_SOURCES) $(cs5536_module_SOURCES) \
+ $(nodist_cs5536_module_SOURCES) $(ctz_test_module_SOURCES) \
+ $(nodist_ctz_test_module_SOURCES) $(date_module_SOURCES) \
+ $(nodist_date_module_SOURCES) $(datehook_module_SOURCES) \
+ $(nodist_datehook_module_SOURCES) $(datetime_module_SOURCES) \
+ $(nodist_datetime_module_SOURCES) $(disk_module_SOURCES) \
+ $(nodist_disk_module_SOURCES) $(diskboot_image_SOURCES) \
+ $(nodist_diskboot_image_SOURCES) $(diskfilter_module_SOURCES) \
+ $(nodist_diskfilter_module_SOURCES) $(div_module_SOURCES) \
+ $(nodist_div_module_SOURCES) $(div_test_module_SOURCES) \
+ $(nodist_div_test_module_SOURCES) $(dm_nv_module_SOURCES) \
+ $(nodist_dm_nv_module_SOURCES) $(drivemap_module_SOURCES) \
+ $(nodist_drivemap_module_SOURCES) $(echo_module_SOURCES) \
+ $(nodist_echo_module_SOURCES) $(efi_gop_module_SOURCES) \
+ $(nodist_efi_gop_module_SOURCES) $(efi_uga_module_SOURCES) \
+ $(nodist_efi_uga_module_SOURCES) $(efiemu_module_SOURCES) \
+ $(nodist_efiemu_module_SOURCES) $(efifwsetup_module_SOURCES) \
+ $(nodist_efifwsetup_module_SOURCES) $(efinet_module_SOURCES) \
+ $(nodist_efinet_module_SOURCES) $(ehci_module_SOURCES) \
+ $(nodist_ehci_module_SOURCES) $(elf_module_SOURCES) \
+ $(nodist_elf_module_SOURCES) $(emunet_module_SOURCES) \
+ $(nodist_emunet_module_SOURCES) $(emupci_module_SOURCES) \
+ $(nodist_emupci_module_SOURCES) $(escc_module_SOURCES) \
+ $(nodist_escc_module_SOURCES) $(eval_module_SOURCES) \
+ $(nodist_eval_module_SOURCES) $(exfat_module_SOURCES) \
+ $(nodist_exfat_module_SOURCES) $(exfctest_module_SOURCES) \
+ $(nodist_exfctest_module_SOURCES) $(ext2_module_SOURCES) \
+ $(nodist_ext2_module_SOURCES) $(extcmd_module_SOURCES) \
+ $(nodist_extcmd_module_SOURCES) $(f2fs_module_SOURCES) \
+ $(nodist_f2fs_module_SOURCES) $(fat_module_SOURCES) \
+ $(nodist_fat_module_SOURCES) $(fdt_module_SOURCES) \
+ $(nodist_fdt_module_SOURCES) $(file_module_SOURCES) \
+ $(nodist_file_module_SOURCES) $(fixvideo_module_SOURCES) \
+ $(nodist_fixvideo_module_SOURCES) $(font_module_SOURCES) \
+ $(nodist_font_module_SOURCES) $(freedos_module_SOURCES) \
+ $(nodist_freedos_module_SOURCES) $(fshelp_module_SOURCES) \
+ $(nodist_fshelp_module_SOURCES) \
+ $(functional_test_module_SOURCES) \
+ $(nodist_functional_test_module_SOURCES) \
+ $(fwstart_image_SOURCES) $(nodist_fwstart_image_SOURCES) \
+ $(fwstart_fuloong2f_image_SOURCES) \
+ $(nodist_fwstart_fuloong2f_image_SOURCES) \
+ $(gcry_arcfour_module_SOURCES) \
+ $(nodist_gcry_arcfour_module_SOURCES) \
+ $(gcry_blowfish_module_SOURCES) \
+ $(nodist_gcry_blowfish_module_SOURCES) \
+ $(gcry_camellia_module_SOURCES) \
+ $(nodist_gcry_camellia_module_SOURCES) \
+ $(gcry_cast5_module_SOURCES) \
+ $(nodist_gcry_cast5_module_SOURCES) $(gcry_crc_module_SOURCES) \
+ $(nodist_gcry_crc_module_SOURCES) $(gcry_des_module_SOURCES) \
+ $(nodist_gcry_des_module_SOURCES) $(gcry_dsa_module_SOURCES) \
+ $(nodist_gcry_dsa_module_SOURCES) $(gcry_idea_module_SOURCES) \
+ $(nodist_gcry_idea_module_SOURCES) $(gcry_md4_module_SOURCES) \
+ $(nodist_gcry_md4_module_SOURCES) $(gcry_md5_module_SOURCES) \
+ $(nodist_gcry_md5_module_SOURCES) \
+ $(gcry_rfc2268_module_SOURCES) \
+ $(nodist_gcry_rfc2268_module_SOURCES) \
+ $(gcry_rijndael_module_SOURCES) \
+ $(nodist_gcry_rijndael_module_SOURCES) \
+ $(gcry_rmd160_module_SOURCES) \
+ $(nodist_gcry_rmd160_module_SOURCES) \
+ $(gcry_rsa_module_SOURCES) $(nodist_gcry_rsa_module_SOURCES) \
+ $(gcry_seed_module_SOURCES) $(nodist_gcry_seed_module_SOURCES) \
+ $(gcry_serpent_module_SOURCES) \
+ $(nodist_gcry_serpent_module_SOURCES) \
+ $(gcry_sha1_module_SOURCES) $(nodist_gcry_sha1_module_SOURCES) \
+ $(gcry_sha256_module_SOURCES) \
+ $(nodist_gcry_sha256_module_SOURCES) \
+ $(gcry_sha512_module_SOURCES) \
+ $(nodist_gcry_sha512_module_SOURCES) \
+ $(gcry_tiger_module_SOURCES) \
+ $(nodist_gcry_tiger_module_SOURCES) \
+ $(gcry_twofish_module_SOURCES) \
+ $(nodist_gcry_twofish_module_SOURCES) \
+ $(gcry_whirlpool_module_SOURCES) \
+ $(nodist_gcry_whirlpool_module_SOURCES) $(gdb_module_SOURCES) \
+ $(nodist_gdb_module_SOURCES) $(geli_module_SOURCES) \
+ $(nodist_geli_module_SOURCES) $(gettext_module_SOURCES) \
+ $(nodist_gettext_module_SOURCES) $(gfxmenu_module_SOURCES) \
+ $(nodist_gfxmenu_module_SOURCES) $(gfxterm_module_SOURCES) \
+ $(nodist_gfxterm_module_SOURCES) \
+ $(gfxterm_background_module_SOURCES) \
+ $(nodist_gfxterm_background_module_SOURCES) \
+ $(gfxterm_menu_module_SOURCES) \
+ $(nodist_gfxterm_menu_module_SOURCES) \
+ $(gptsync_module_SOURCES) $(nodist_gptsync_module_SOURCES) \
+ $(grub_emu_SOURCES) $(nodist_grub_emu_SOURCES) \
+ $(grub_emu_lite_SOURCES) $(nodist_grub_emu_lite_SOURCES) \
+ $(gzio_module_SOURCES) $(nodist_gzio_module_SOURCES) \
+ $(halt_module_SOURCES) $(nodist_halt_module_SOURCES) \
+ $(hashsum_module_SOURCES) $(nodist_hashsum_module_SOURCES) \
+ $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES) \
+ $(hello_module_SOURCES) $(nodist_hello_module_SOURCES) \
+ $(help_module_SOURCES) $(nodist_help_module_SOURCES) \
+ $(hexdump_module_SOURCES) $(nodist_hexdump_module_SOURCES) \
+ $(hfs_module_SOURCES) $(nodist_hfs_module_SOURCES) \
+ $(hfsplus_module_SOURCES) $(nodist_hfsplus_module_SOURCES) \
+ $(hfspluscomp_module_SOURCES) \
+ $(nodist_hfspluscomp_module_SOURCES) $(http_module_SOURCES) \
+ $(nodist_http_module_SOURCES) $(ieee1275_fb_module_SOURCES) \
+ $(nodist_ieee1275_fb_module_SOURCES) $(iorw_module_SOURCES) \
+ $(nodist_iorw_module_SOURCES) $(iso9660_module_SOURCES) \
+ $(nodist_iso9660_module_SOURCES) $(jfs_module_SOURCES) \
+ $(nodist_jfs_module_SOURCES) $(jpeg_module_SOURCES) \
+ $(nodist_jpeg_module_SOURCES) $(json_module_SOURCES) \
+ $(nodist_json_module_SOURCES) $(kernel_exec_SOURCES) \
+ $(nodist_kernel_exec_SOURCES) $(keylayouts_module_SOURCES) \
+ $(nodist_keylayouts_module_SOURCES) \
+ $(keystatus_module_SOURCES) $(nodist_keystatus_module_SOURCES) \
+ $(ldm_module_SOURCES) $(nodist_ldm_module_SOURCES) \
+ $(legacy_password_test_module_SOURCES) \
+ $(nodist_legacy_password_test_module_SOURCES) \
+ $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES) \
+ $(linux_module_SOURCES) $(nodist_linux_module_SOURCES) \
+ $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES) \
+ $(lnxboot_image_SOURCES) $(nodist_lnxboot_image_SOURCES) \
+ $(loadbios_module_SOURCES) $(nodist_loadbios_module_SOURCES) \
+ $(loadenv_module_SOURCES) $(nodist_loadenv_module_SOURCES) \
+ $(loopback_module_SOURCES) $(nodist_loopback_module_SOURCES) \
+ $(ls_module_SOURCES) $(nodist_ls_module_SOURCES) \
+ $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES) \
+ $(lsapm_module_SOURCES) $(nodist_lsapm_module_SOURCES) \
+ $(lsdev_module_SOURCES) $(nodist_lsdev_module_SOURCES) \
+ $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES) \
+ $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES) \
+ $(lsefisystab_module_SOURCES) \
+ $(nodist_lsefisystab_module_SOURCES) $(lsmmap_module_SOURCES) \
+ $(nodist_lsmmap_module_SOURCES) $(lspci_module_SOURCES) \
+ $(nodist_lspci_module_SOURCES) $(lssal_module_SOURCES) \
+ $(nodist_lssal_module_SOURCES) $(lsspd_module_SOURCES) \
+ $(nodist_lsspd_module_SOURCES) $(lsxen_module_SOURCES) \
+ $(nodist_lsxen_module_SOURCES) $(luks_module_SOURCES) \
+ $(nodist_luks_module_SOURCES) $(luks2_module_SOURCES) \
+ $(nodist_luks2_module_SOURCES) $(lvm_module_SOURCES) \
+ $(nodist_lvm_module_SOURCES) $(lzma_decompress_image_SOURCES) \
+ $(nodist_lzma_decompress_image_SOURCES) \
+ $(lzopio_module_SOURCES) $(nodist_lzopio_module_SOURCES) \
+ $(macbless_module_SOURCES) $(nodist_macbless_module_SOURCES) \
+ $(macho_module_SOURCES) $(nodist_macho_module_SOURCES) \
+ $(mda_text_module_SOURCES) $(nodist_mda_text_module_SOURCES) \
+ $(mdraid09_module_SOURCES) $(nodist_mdraid09_module_SOURCES) \
+ $(mdraid09_be_module_SOURCES) \
+ $(nodist_mdraid09_be_module_SOURCES) \
+ $(mdraid1x_module_SOURCES) $(nodist_mdraid1x_module_SOURCES) \
+ $(memdisk_module_SOURCES) $(nodist_memdisk_module_SOURCES) \
+ $(memrw_module_SOURCES) $(nodist_memrw_module_SOURCES) \
+ $(minicmd_module_SOURCES) $(nodist_minicmd_module_SOURCES) \
+ $(minix_module_SOURCES) $(nodist_minix_module_SOURCES) \
+ $(minix2_module_SOURCES) $(nodist_minix2_module_SOURCES) \
+ $(minix2_be_module_SOURCES) $(nodist_minix2_be_module_SOURCES) \
+ $(minix3_module_SOURCES) $(nodist_minix3_module_SOURCES) \
+ $(minix3_be_module_SOURCES) $(nodist_minix3_be_module_SOURCES) \
+ $(minix_be_module_SOURCES) $(nodist_minix_be_module_SOURCES) \
+ $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES) \
+ $(morse_module_SOURCES) $(nodist_morse_module_SOURCES) \
+ $(mpi_module_SOURCES) $(nodist_mpi_module_SOURCES) \
+ $(msdospart_module_SOURCES) $(nodist_msdospart_module_SOURCES) \
+ $(mul_test_module_SOURCES) $(nodist_mul_test_module_SOURCES) \
+ $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES) \
+ $(multiboot2_module_SOURCES) \
+ $(nodist_multiboot2_module_SOURCES) $(nand_module_SOURCES) \
+ $(nodist_nand_module_SOURCES) $(nativedisk_module_SOURCES) \
+ $(nodist_nativedisk_module_SOURCES) $(net_module_SOURCES) \
+ $(nodist_net_module_SOURCES) $(newc_module_SOURCES) \
+ $(nodist_newc_module_SOURCES) $(nilfs2_module_SOURCES) \
+ $(nodist_nilfs2_module_SOURCES) \
+ $(none_decompress_image_SOURCES) \
+ $(nodist_none_decompress_image_SOURCES) \
+ $(normal_module_SOURCES) $(nodist_normal_module_SOURCES) \
+ $(ntfs_module_SOURCES) $(nodist_ntfs_module_SOURCES) \
+ $(ntfscomp_module_SOURCES) $(nodist_ntfscomp_module_SOURCES) \
+ $(ntldr_module_SOURCES) $(nodist_ntldr_module_SOURCES) \
+ $(odc_module_SOURCES) $(nodist_odc_module_SOURCES) \
+ $(offsetio_module_SOURCES) $(nodist_offsetio_module_SOURCES) \
+ $(ofnet_module_SOURCES) $(nodist_ofnet_module_SOURCES) \
+ $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES) \
+ $(part_acorn_module_SOURCES) \
+ $(nodist_part_acorn_module_SOURCES) \
+ $(part_amiga_module_SOURCES) \
+ $(nodist_part_amiga_module_SOURCES) \
+ $(part_apple_module_SOURCES) \
+ $(nodist_part_apple_module_SOURCES) $(part_bsd_module_SOURCES) \
+ $(nodist_part_bsd_module_SOURCES) $(part_dfly_module_SOURCES) \
+ $(nodist_part_dfly_module_SOURCES) $(part_dvh_module_SOURCES) \
+ $(nodist_part_dvh_module_SOURCES) $(part_gpt_module_SOURCES) \
+ $(nodist_part_gpt_module_SOURCES) $(part_msdos_module_SOURCES) \
+ $(nodist_part_msdos_module_SOURCES) \
+ $(part_plan_module_SOURCES) $(nodist_part_plan_module_SOURCES) \
+ $(part_sun_module_SOURCES) $(nodist_part_sun_module_SOURCES) \
+ $(part_sunpc_module_SOURCES) \
+ $(nodist_part_sunpc_module_SOURCES) $(parttool_module_SOURCES) \
+ $(nodist_parttool_module_SOURCES) $(password_module_SOURCES) \
+ $(nodist_password_module_SOURCES) \
+ $(password_pbkdf2_module_SOURCES) \
+ $(nodist_password_pbkdf2_module_SOURCES) \
+ $(pata_module_SOURCES) $(nodist_pata_module_SOURCES) \
+ $(pbkdf2_module_SOURCES) $(nodist_pbkdf2_module_SOURCES) \
+ $(pbkdf2_test_module_SOURCES) \
+ $(nodist_pbkdf2_test_module_SOURCES) $(pci_module_SOURCES) \
+ $(nodist_pci_module_SOURCES) $(pcidump_module_SOURCES) \
+ $(nodist_pcidump_module_SOURCES) $(pgp_module_SOURCES) \
+ $(nodist_pgp_module_SOURCES) $(plan9_module_SOURCES) \
+ $(nodist_plan9_module_SOURCES) $(play_module_SOURCES) \
+ $(nodist_play_module_SOURCES) $(png_module_SOURCES) \
+ $(nodist_png_module_SOURCES) $(priority_queue_module_SOURCES) \
+ $(nodist_priority_queue_module_SOURCES) \
+ $(probe_module_SOURCES) $(nodist_probe_module_SOURCES) \
+ $(procfs_module_SOURCES) $(nodist_procfs_module_SOURCES) \
+ $(progress_module_SOURCES) $(nodist_progress_module_SOURCES) \
+ $(pxe_module_SOURCES) $(nodist_pxe_module_SOURCES) \
+ $(pxeboot_image_SOURCES) $(nodist_pxeboot_image_SOURCES) \
+ $(pxechain_module_SOURCES) $(nodist_pxechain_module_SOURCES) \
+ $(raid5rec_module_SOURCES) $(nodist_raid5rec_module_SOURCES) \
+ $(raid6rec_module_SOURCES) $(nodist_raid6rec_module_SOURCES) \
+ $(random_module_SOURCES) $(nodist_random_module_SOURCES) \
+ $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES) \
+ $(read_module_SOURCES) $(nodist_read_module_SOURCES) \
+ $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES) \
+ $(regexp_module_SOURCES) $(nodist_regexp_module_SOURCES) \
+ $(reiserfs_module_SOURCES) $(nodist_reiserfs_module_SOURCES) \
+ $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES) \
+ $(romfs_module_SOURCES) $(nodist_romfs_module_SOURCES) \
+ $(scsi_module_SOURCES) $(nodist_scsi_module_SOURCES) \
+ $(sdl_module_SOURCES) $(nodist_sdl_module_SOURCES) \
+ $(search_module_SOURCES) $(nodist_search_module_SOURCES) \
+ $(search_fs_file_module_SOURCES) \
+ $(nodist_search_fs_file_module_SOURCES) \
+ $(search_fs_uuid_module_SOURCES) \
+ $(nodist_search_fs_uuid_module_SOURCES) \
+ $(search_label_module_SOURCES) \
+ $(nodist_search_label_module_SOURCES) \
+ $(sendkey_module_SOURCES) $(nodist_sendkey_module_SOURCES) \
+ $(serial_module_SOURCES) $(nodist_serial_module_SOURCES) \
+ $(setjmp_module_SOURCES) $(nodist_setjmp_module_SOURCES) \
+ $(setjmp_test_module_SOURCES) \
+ $(nodist_setjmp_test_module_SOURCES) $(setpci_module_SOURCES) \
+ $(nodist_setpci_module_SOURCES) $(sfs_module_SOURCES) \
+ $(nodist_sfs_module_SOURCES) $(shift_test_module_SOURCES) \
+ $(nodist_shift_test_module_SOURCES) \
+ $(signature_test_module_SOURCES) \
+ $(nodist_signature_test_module_SOURCES) \
+ $(sleep_module_SOURCES) $(nodist_sleep_module_SOURCES) \
+ $(sleep_test_module_SOURCES) \
+ $(nodist_sleep_test_module_SOURCES) $(smbios_module_SOURCES) \
+ $(nodist_smbios_module_SOURCES) $(spkmodem_module_SOURCES) \
+ $(nodist_spkmodem_module_SOURCES) $(squash4_module_SOURCES) \
+ $(nodist_squash4_module_SOURCES) \
+ $(strtoull_test_module_SOURCES) \
+ $(nodist_strtoull_test_module_SOURCES) \
+ $(suspend_module_SOURCES) $(nodist_suspend_module_SOURCES) \
+ $(syslinuxcfg_module_SOURCES) \
+ $(nodist_syslinuxcfg_module_SOURCES) $(tar_module_SOURCES) \
+ $(nodist_tar_module_SOURCES) $(terminal_module_SOURCES) \
+ $(nodist_terminal_module_SOURCES) $(terminfo_module_SOURCES) \
+ $(nodist_terminfo_module_SOURCES) $(test_module_SOURCES) \
+ $(nodist_test_module_SOURCES) $(test_blockarg_module_SOURCES) \
+ $(nodist_test_blockarg_module_SOURCES) \
+ $(testload_module_SOURCES) $(nodist_testload_module_SOURCES) \
+ $(testspeed_module_SOURCES) $(nodist_testspeed_module_SOURCES) \
+ $(tftp_module_SOURCES) $(nodist_tftp_module_SOURCES) \
+ $(tga_module_SOURCES) $(nodist_tga_module_SOURCES) \
+ $(time_module_SOURCES) $(nodist_time_module_SOURCES) \
+ $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES) \
+ $(tr_module_SOURCES) $(nodist_tr_module_SOURCES) \
+ $(trig_module_SOURCES) $(nodist_trig_module_SOURCES) \
+ $(true_module_SOURCES) $(nodist_true_module_SOURCES) \
+ $(truecrypt_module_SOURCES) $(nodist_truecrypt_module_SOURCES) \
+ $(ubootnet_module_SOURCES) $(nodist_ubootnet_module_SOURCES) \
+ $(udf_module_SOURCES) $(nodist_udf_module_SOURCES) \
+ $(ufs1_module_SOURCES) $(nodist_ufs1_module_SOURCES) \
+ $(ufs1_be_module_SOURCES) $(nodist_ufs1_be_module_SOURCES) \
+ $(ufs2_module_SOURCES) $(nodist_ufs2_module_SOURCES) \
+ $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES) \
+ $(usb_module_SOURCES) $(nodist_usb_module_SOURCES) \
+ $(usb_keyboard_module_SOURCES) \
+ $(nodist_usb_keyboard_module_SOURCES) $(usbms_module_SOURCES) \
+ $(nodist_usbms_module_SOURCES) \
+ $(usbserial_common_module_SOURCES) \
+ $(nodist_usbserial_common_module_SOURCES) \
+ $(usbserial_ftdi_module_SOURCES) \
+ $(nodist_usbserial_ftdi_module_SOURCES) \
+ $(usbserial_pl2303_module_SOURCES) \
+ $(nodist_usbserial_pl2303_module_SOURCES) \
+ $(usbserial_usbdebug_module_SOURCES) \
+ $(nodist_usbserial_usbdebug_module_SOURCES) \
+ $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES) \
+ $(vbe_module_SOURCES) $(nodist_vbe_module_SOURCES) \
+ $(vga_module_SOURCES) $(nodist_vga_module_SOURCES) \
+ $(vga_text_module_SOURCES) $(nodist_vga_text_module_SOURCES) \
+ $(video_module_SOURCES) $(nodist_video_module_SOURCES) \
+ $(video_bochs_module_SOURCES) \
+ $(nodist_video_bochs_module_SOURCES) \
+ $(video_cirrus_module_SOURCES) \
+ $(nodist_video_cirrus_module_SOURCES) \
+ $(video_colors_module_SOURCES) \
+ $(nodist_video_colors_module_SOURCES) \
+ $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES) \
+ $(videoinfo_module_SOURCES) $(nodist_videoinfo_module_SOURCES) \
+ $(videotest_module_SOURCES) $(nodist_videotest_module_SOURCES) \
+ $(videotest_checksum_module_SOURCES) \
+ $(nodist_videotest_checksum_module_SOURCES) \
+ $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES) \
+ $(xen_boot_module_SOURCES) $(nodist_xen_boot_module_SOURCES) \
+ $(xfs_module_SOURCES) $(nodist_xfs_module_SOURCES) \
+ $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES) \
+ $(xnu_uuid_module_SOURCES) $(nodist_xnu_uuid_module_SOURCES) \
+ $(xnu_uuid_test_module_SOURCES) \
+ $(nodist_xnu_uuid_test_module_SOURCES) \
+ $(xz_decompress_image_SOURCES) \
+ $(nodist_xz_decompress_image_SOURCES) $(xzio_module_SOURCES) \
+ $(nodist_xzio_module_SOURCES) $(zfs_module_SOURCES) \
+ $(nodist_zfs_module_SOURCES) $(zfscrypt_module_SOURCES) \
+ $(nodist_zfscrypt_module_SOURCES) $(zfsinfo_module_SOURCES) \
+ $(nodist_zfsinfo_module_SOURCES) $(zstd_module_SOURCES) \
+ $(nodist_zstd_module_SOURCES)
+DIST_SOURCES = $(am__acpi_module_SOURCES_DIST) \
+ $(adler32_module_SOURCES) $(affs_module_SOURCES) \
+ $(afs_module_SOURCES) $(afsplitter_module_SOURCES) \
+ $(am__ahci_module_SOURCES_DIST) $(all_video_module_SOURCES) \
+ $(am__aout_module_SOURCES_DIST) \
+ $(am__appleldr_module_SOURCES_DIST) $(archelp_module_SOURCES) \
+ $(am__at_keyboard_module_SOURCES_DIST) \
+ $(am__ata_module_SOURCES_DIST) \
+ $(am__backtrace_module_SOURCES_DIST) $(bfs_module_SOURCES) \
+ $(am__biosdisk_module_SOURCES_DIST) $(bitmap_module_SOURCES) \
+ $(bitmap_scale_module_SOURCES) $(blocklist_module_SOURCES) \
+ $(am__boot_image_SOURCES_DIST) $(am__boot_module_SOURCES_DIST) \
+ $(am__boot_hybrid_image_SOURCES_DIST) \
+ $(am__boottime_module_SOURCES_DIST) \
+ $(am__bsd_module_SOURCES_DIST) $(bswap_test_module_SOURCES) \
+ $(btrfs_module_SOURCES) $(am__bufio_module_SOURCES_DIST) \
+ $(am__cacheinfo_module_SOURCES_DIST) $(cat_module_SOURCES) \
+ $(cbfs_module_SOURCES) $(am__cbls_module_SOURCES_DIST) \
+ $(am__cbmemc_module_SOURCES_DIST) \
+ $(am__cbtable_module_SOURCES_DIST) \
+ $(am__cbtime_module_SOURCES_DIST) \
+ $(am__cdboot_image_SOURCES_DIST) \
+ $(am__chain_module_SOURCES_DIST) \
+ $(cmdline_cat_test_module_SOURCES) \
+ $(am__cmosdump_module_SOURCES_DIST) \
+ $(am__cmostest_module_SOURCES_DIST) $(cmp_module_SOURCES) \
+ $(cmp_test_module_SOURCES) $(configfile_module_SOURCES) \
+ $(cpio_module_SOURCES) $(cpio_be_module_SOURCES) \
+ $(am__cpuid_module_SOURCES_DIST) $(crc64_module_SOURCES) \
+ $(crypto_module_SOURCES) $(cryptodisk_module_SOURCES) \
+ $(am__cs5536_module_SOURCES_DIST) $(ctz_test_module_SOURCES) \
+ $(date_module_SOURCES) $(datehook_module_SOURCES) \
+ $(am__datetime_module_SOURCES_DIST) $(disk_module_SOURCES) \
+ $(am__diskboot_image_SOURCES_DIST) \
+ $(diskfilter_module_SOURCES) $(am__div_module_SOURCES_DIST) \
+ $(div_test_module_SOURCES) $(dm_nv_module_SOURCES) \
+ $(am__drivemap_module_SOURCES_DIST) $(echo_module_SOURCES) \
+ $(am__efi_gop_module_SOURCES_DIST) \
+ $(am__efi_uga_module_SOURCES_DIST) \
+ $(am__efiemu_module_SOURCES_DIST) \
+ $(am__efifwsetup_module_SOURCES_DIST) \
+ $(am__efinet_module_SOURCES_DIST) \
+ $(am__ehci_module_SOURCES_DIST) $(elf_module_SOURCES) \
+ $(am__emunet_module_SOURCES_DIST) \
+ $(am__emupci_module_SOURCES_DIST) \
+ $(am__escc_module_SOURCES_DIST) $(eval_module_SOURCES) \
+ $(exfat_module_SOURCES) $(exfctest_module_SOURCES) \
+ $(ext2_module_SOURCES) $(am__extcmd_module_SOURCES_DIST) \
+ $(f2fs_module_SOURCES) $(fat_module_SOURCES) \
+ $(am__fdt_module_SOURCES_DIST) $(file_module_SOURCES) \
+ $(am__fixvideo_module_SOURCES_DIST) \
+ $(am__font_module_SOURCES_DIST) \
+ $(am__freedos_module_SOURCES_DIST) $(fshelp_module_SOURCES) \
+ $(functional_test_module_SOURCES) \
+ $(am__fwstart_image_SOURCES_DIST) \
+ $(am__fwstart_fuloong2f_image_SOURCES_DIST) \
+ $(gcry_arcfour_module_SOURCES) $(gcry_blowfish_module_SOURCES) \
+ $(gcry_camellia_module_SOURCES) $(gcry_cast5_module_SOURCES) \
+ $(gcry_crc_module_SOURCES) $(gcry_des_module_SOURCES) \
+ $(gcry_dsa_module_SOURCES) $(gcry_idea_module_SOURCES) \
+ $(gcry_md4_module_SOURCES) $(gcry_md5_module_SOURCES) \
+ $(gcry_rfc2268_module_SOURCES) $(gcry_rijndael_module_SOURCES) \
+ $(gcry_rmd160_module_SOURCES) $(gcry_rsa_module_SOURCES) \
+ $(gcry_seed_module_SOURCES) $(gcry_serpent_module_SOURCES) \
+ $(gcry_sha1_module_SOURCES) $(gcry_sha256_module_SOURCES) \
+ $(gcry_sha512_module_SOURCES) $(gcry_tiger_module_SOURCES) \
+ $(gcry_twofish_module_SOURCES) \
+ $(gcry_whirlpool_module_SOURCES) \
+ $(am__gdb_module_SOURCES_DIST) $(geli_module_SOURCES) \
+ $(gettext_module_SOURCES) $(gfxmenu_module_SOURCES) \
+ $(am__gfxterm_module_SOURCES_DIST) \
+ $(gfxterm_background_module_SOURCES) \
+ $(gfxterm_menu_module_SOURCES) $(gptsync_module_SOURCES) \
+ $(am__grub_emu_SOURCES_DIST) $(am__grub_emu_lite_SOURCES_DIST) \
+ $(gzio_module_SOURCES) $(am__halt_module_SOURCES_DIST) \
+ $(hashsum_module_SOURCES) $(am__hdparm_module_SOURCES_DIST) \
+ $(hello_module_SOURCES) $(help_module_SOURCES) \
+ $(hexdump_module_SOURCES) $(hfs_module_SOURCES) \
+ $(hfsplus_module_SOURCES) $(hfspluscomp_module_SOURCES) \
+ $(http_module_SOURCES) $(am__ieee1275_fb_module_SOURCES_DIST) \
+ $(am__iorw_module_SOURCES_DIST) $(iso9660_module_SOURCES) \
+ $(jfs_module_SOURCES) $(jpeg_module_SOURCES) \
+ $(json_module_SOURCES) $(am__kernel_exec_SOURCES_DIST) \
+ $(am__keylayouts_module_SOURCES_DIST) \
+ $(keystatus_module_SOURCES) $(ldm_module_SOURCES) \
+ $(am__legacy_password_test_module_SOURCES_DIST) \
+ $(am__legacycfg_module_SOURCES_DIST) \
+ $(am__linux_module_SOURCES_DIST) \
+ $(am__linux16_module_SOURCES_DIST) \
+ $(am__lnxboot_image_SOURCES_DIST) \
+ $(am__loadbios_module_SOURCES_DIST) $(loadenv_module_SOURCES) \
+ $(loopback_module_SOURCES) $(ls_module_SOURCES) \
+ $(am__lsacpi_module_SOURCES_DIST) \
+ $(am__lsapm_module_SOURCES_DIST) \
+ $(am__lsdev_module_SOURCES_DIST) \
+ $(am__lsefi_module_SOURCES_DIST) \
+ $(am__lsefimmap_module_SOURCES_DIST) \
+ $(am__lsefisystab_module_SOURCES_DIST) \
+ $(lsmmap_module_SOURCES) $(am__lspci_module_SOURCES_DIST) \
+ $(am__lssal_module_SOURCES_DIST) \
+ $(am__lsspd_module_SOURCES_DIST) \
+ $(am__lsxen_module_SOURCES_DIST) $(luks_module_SOURCES) \
+ $(luks2_module_SOURCES) $(lvm_module_SOURCES) \
+ $(am__lzma_decompress_image_SOURCES_DIST) \
+ $(lzopio_module_SOURCES) $(macbless_module_SOURCES) \
+ $(macho_module_SOURCES) $(am__mda_text_module_SOURCES_DIST) \
+ $(mdraid09_module_SOURCES) $(mdraid09_be_module_SOURCES) \
+ $(mdraid1x_module_SOURCES) $(memdisk_module_SOURCES) \
+ $(memrw_module_SOURCES) $(minicmd_module_SOURCES) \
+ $(minix_module_SOURCES) $(minix2_module_SOURCES) \
+ $(minix2_be_module_SOURCES) $(minix3_module_SOURCES) \
+ $(minix3_be_module_SOURCES) $(minix_be_module_SOURCES) \
+ $(am__mmap_module_SOURCES_DIST) \
+ $(am__morse_module_SOURCES_DIST) $(mpi_module_SOURCES) \
+ $(msdospart_module_SOURCES) $(mul_test_module_SOURCES) \
+ $(am__multiboot_module_SOURCES_DIST) \
+ $(am__multiboot2_module_SOURCES_DIST) \
+ $(am__nand_module_SOURCES_DIST) \
+ $(am__nativedisk_module_SOURCES_DIST) $(net_module_SOURCES) \
+ $(newc_module_SOURCES) $(nilfs2_module_SOURCES) \
+ $(am__none_decompress_image_SOURCES_DIST) \
+ $(normal_module_SOURCES) $(ntfs_module_SOURCES) \
+ $(ntfscomp_module_SOURCES) $(am__ntldr_module_SOURCES_DIST) \
+ $(odc_module_SOURCES) $(offsetio_module_SOURCES) \
+ $(am__ofnet_module_SOURCES_DIST) \
+ $(am__ohci_module_SOURCES_DIST) $(part_acorn_module_SOURCES) \
+ $(part_amiga_module_SOURCES) $(part_apple_module_SOURCES) \
+ $(part_bsd_module_SOURCES) $(part_dfly_module_SOURCES) \
+ $(part_dvh_module_SOURCES) $(part_gpt_module_SOURCES) \
+ $(part_msdos_module_SOURCES) $(part_plan_module_SOURCES) \
+ $(part_sun_module_SOURCES) $(part_sunpc_module_SOURCES) \
+ $(parttool_module_SOURCES) $(password_module_SOURCES) \
+ $(password_pbkdf2_module_SOURCES) \
+ $(am__pata_module_SOURCES_DIST) $(pbkdf2_module_SOURCES) \
+ $(pbkdf2_test_module_SOURCES) $(am__pci_module_SOURCES_DIST) \
+ $(am__pcidump_module_SOURCES_DIST) $(pgp_module_SOURCES) \
+ $(am__plan9_module_SOURCES_DIST) \
+ $(am__play_module_SOURCES_DIST) $(png_module_SOURCES) \
+ $(priority_queue_module_SOURCES) $(probe_module_SOURCES) \
+ $(procfs_module_SOURCES) $(progress_module_SOURCES) \
+ $(am__pxe_module_SOURCES_DIST) \
+ $(am__pxeboot_image_SOURCES_DIST) \
+ $(am__pxechain_module_SOURCES_DIST) $(raid5rec_module_SOURCES) \
+ $(raid6rec_module_SOURCES) $(am__random_module_SOURCES_DIST) \
+ $(am__rdmsr_module_SOURCES_DIST) $(read_module_SOURCES) \
+ $(am__reboot_module_SOURCES_DIST) $(regexp_module_SOURCES) \
+ $(reiserfs_module_SOURCES) \
+ $(am__relocator_module_SOURCES_DIST) $(romfs_module_SOURCES) \
+ $(scsi_module_SOURCES) $(am__sdl_module_SOURCES_DIST) \
+ $(search_module_SOURCES) $(search_fs_file_module_SOURCES) \
+ $(search_fs_uuid_module_SOURCES) \
+ $(search_label_module_SOURCES) \
+ $(am__sendkey_module_SOURCES_DIST) \
+ $(am__serial_module_SOURCES_DIST) $(setjmp_module_SOURCES) \
+ $(setjmp_test_module_SOURCES) \
+ $(am__setpci_module_SOURCES_DIST) $(sfs_module_SOURCES) \
+ $(shift_test_module_SOURCES) $(signature_test_module_SOURCES) \
+ $(sleep_module_SOURCES) $(sleep_test_module_SOURCES) \
+ $(am__smbios_module_SOURCES_DIST) \
+ $(am__spkmodem_module_SOURCES_DIST) $(squash4_module_SOURCES) \
+ $(strtoull_test_module_SOURCES) \
+ $(am__suspend_module_SOURCES_DIST) \
+ $(syslinuxcfg_module_SOURCES) $(tar_module_SOURCES) \
+ $(terminal_module_SOURCES) $(am__terminfo_module_SOURCES_DIST) \
+ $(test_module_SOURCES) $(test_blockarg_module_SOURCES) \
+ $(testload_module_SOURCES) $(testspeed_module_SOURCES) \
+ $(tftp_module_SOURCES) $(tga_module_SOURCES) \
+ $(time_module_SOURCES) $(am__tpm_module_SOURCES_DIST) \
+ $(tr_module_SOURCES) $(trig_module_SOURCES) \
+ $(true_module_SOURCES) $(am__truecrypt_module_SOURCES_DIST) \
+ $(am__ubootnet_module_SOURCES_DIST) $(udf_module_SOURCES) \
+ $(ufs1_module_SOURCES) $(ufs1_be_module_SOURCES) \
+ $(ufs2_module_SOURCES) $(am__uhci_module_SOURCES_DIST) \
+ $(am__usb_module_SOURCES_DIST) \
+ $(am__usb_keyboard_module_SOURCES_DIST) \
+ $(am__usbms_module_SOURCES_DIST) \
+ $(am__usbserial_common_module_SOURCES_DIST) \
+ $(am__usbserial_ftdi_module_SOURCES_DIST) \
+ $(am__usbserial_pl2303_module_SOURCES_DIST) \
+ $(am__usbserial_usbdebug_module_SOURCES_DIST) \
+ $(am__usbtest_module_SOURCES_DIST) \
+ $(am__vbe_module_SOURCES_DIST) $(am__vga_module_SOURCES_DIST) \
+ $(am__vga_text_module_SOURCES_DIST) \
+ $(am__video_module_SOURCES_DIST) \
+ $(am__video_bochs_module_SOURCES_DIST) \
+ $(am__video_cirrus_module_SOURCES_DIST) \
+ $(video_colors_module_SOURCES) \
+ $(am__video_fb_module_SOURCES_DIST) \
+ $(videoinfo_module_SOURCES) $(videotest_module_SOURCES) \
+ $(videotest_checksum_module_SOURCES) \
+ $(am__wrmsr_module_SOURCES_DIST) \
+ $(am__xen_boot_module_SOURCES_DIST) $(xfs_module_SOURCES) \
+ $(am__xnu_module_SOURCES_DIST) $(xnu_uuid_module_SOURCES) \
+ $(xnu_uuid_test_module_SOURCES) \
+ $(am__xz_decompress_image_SOURCES_DIST) $(xzio_module_SOURCES) \
+ $(zfs_module_SOURCES) $(zfscrypt_module_SOURCES) \
+ $(zfsinfo_module_SOURCES) $(zstd_module_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+man1dir = $(mandir)/man1
+NROFF = nroff
+MANS = $(man_MANS)
+am__dist_noinst_DATA_DIST = kern/disk_common.c gentrigtables.c \
+ commands/search.c efiemu/prepare.c efiemu/loadcore.c \
+ efiemu/runtime/efiemu.S efiemu/runtime/efiemu.c kern/elfXX.c \
+ lib/libgcrypt-grub/cipher/crypto.lst \
+ lib/i386/relocator_common.S kern/powerpc/cache_flush.S \
+ lib/i386/setjmp.S lib/mips/setjmp.S lib/x86_64/setjmp.S \
+ lib/sparc64/setjmp.S lib/powerpc/setjmp.S lib/ia64/setjmp.S \
+ lib/ia64/longjmp.S lib/arm/setjmp.S lib/arm64/setjmp.S \
+ lib/riscv/setjmp.S loader/i386/bsdXX.c \
+ loader/i386/bsd_pagetable.c loader/multiboot_elfxx.c \
+ loader/machoXX.c script/yylex.l script/parser.y \
+ commands/fileXX.c loader/i386/xen_fileXX.c video/sm712_init.c \
+ video/sis315_init.c kern/arm/cache.S osdep/unix/exec.c \
+ osdep/unix/emuconsole.c osdep/windows/emuconsole.c \
+ osdep/unix/dl.c osdep/windows/dl.c osdep/linux/emunet.c \
+ osdep/basic/emunet.c osdep/unix/cputime.c \
+ osdep/windows/cputime.c kern/i386/int.S kern/i386/realmode.S \
+ boot/i386/pc/lzma_decode.S kern/mips/cache_flush.S \
+ gensyminfo.sh.in genmod.sh.in modinfo.sh.in gmodule.pl.in \
+ gdb_grub.in boot/powerpc/grub.chrp.in \
+ boot/powerpc/bootinfo.txt.in
+DATA = $(dist_grubconf_DATA) $(dist_noinst_DATA) $(noinst_DATA) \
+ $(pkgdata_DATA) $(platform_DATA)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors_dummy = \
+ mgn= red= grn= lgn= blu= brg= std=; \
+ am__color_tests=no
+am__tty_colors = { \
+ $(am__tty_colors_dummy); \
+ if test "X$(AM_COLOR_TESTS)" = Xno; then \
+ am__color_tests=no; \
+ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
+ am__color_tests=yes; \
+ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
+ am__color_tests=yes; \
+ fi; \
+ if test $$am__color_tests = yes; then \
+ red=''; \
+ grn=''; \
+ lgn=''; \
+ blu=''; \
+ mgn=''; \
+ brg=''; \
+ std=''; \
+ fi; \
+}
+am__recheck_rx = ^[ ]*:recheck:[ ]*
+am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
+am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
+# A command that, given a newline-separated list of test names on the
+# standard input, print the name of the tests that are to be re-run
+# upon "make recheck".
+am__list_recheck_tests = $(AWK) '{ \
+ recheck = 1; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ { \
+ if ((getline line2 < ($$0 ".log")) < 0) \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
+ { \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
+ { \
+ break; \
+ } \
+ }; \
+ if (recheck) \
+ print $$0; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# A command that, given a newline-separated list of test names on the
+# standard input, create the global log from their .trs and .log files.
+am__create_global_log = $(AWK) ' \
+function fatal(msg) \
+{ \
+ print "fatal: making $@: " msg | "cat >&2"; \
+ exit 1; \
+} \
+function rst_section(header) \
+{ \
+ print header; \
+ len = length(header); \
+ for (i = 1; i <= len; i = i + 1) \
+ printf "="; \
+ printf "\n\n"; \
+} \
+{ \
+ copy_in_global_log = 1; \
+ global_test_result = "RUN"; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".trs"); \
+ if (line ~ /$(am__global_test_result_rx)/) \
+ { \
+ sub("$(am__global_test_result_rx)", "", line); \
+ sub("[ ]*$$", "", line); \
+ global_test_result = line; \
+ } \
+ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
+ copy_in_global_log = 0; \
+ }; \
+ if (copy_in_global_log) \
+ { \
+ rst_section(global_test_result ": " $$0); \
+ while ((rc = (getline line < ($$0 ".log"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".log"); \
+ print line; \
+ }; \
+ printf "\n"; \
+ }; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# Restructured Text title.
+am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
+# by disabling -e (using the XSI extension "set +e") if it's set.
+am__sh_e_setup = case $$- in *e*) set +e;; esac
+# Default flags passed to test drivers.
+am__common_driver_flags = \
+ --color-tests "$$am__color_tests" \
+ --enable-hard-errors "$$am__enable_hard_errors" \
+ --expect-failure "$$am__expect_failure"
+# To be inserted before the command running the test. Creates the
+# directory for the log if needed. Stores in $dir the directory
+# containing $f, in $tst the test, in $log the log. Executes the
+# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
+# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
+# will run the test scripts (or their associated LOG_COMPILER, if
+# thy have one).
+am__check_pre = \
+$(am__sh_e_setup); \
+$(am__vpath_adj_setup) $(am__vpath_adj) \
+$(am__tty_colors); \
+srcdir=$(srcdir); export srcdir; \
+case "$@" in \
+ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
+ *) am__odir=.;; \
+esac; \
+test "x$$am__odir" = x"." || test -d "$$am__odir" \
+ || $(MKDIR_P) "$$am__odir" || exit $$?; \
+if test -f "./$$f"; then dir=./; \
+elif test -f "$$f"; then dir=; \
+else dir="$(srcdir)/"; fi; \
+tst=$$dir$$f; log='$@'; \
+if test -n '$(DISABLE_HARD_ERRORS)'; then \
+ am__enable_hard_errors=no; \
+else \
+ am__enable_hard_errors=yes; \
+fi; \
+case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
+ am__expect_failure=yes;; \
+ *) \
+ am__expect_failure=no;; \
+esac; \
+$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
+# A shell command to get the names of the tests scripts with any registered
+# extension removed (i.e., equivalently, the names of the test logs, with
+# the '.log' extension removed). The result is saved in the shell variable
+# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
+# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
+# since that might cause problem with VPATH rewrites for suffix-less tests.
+# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
+am__set_TESTS_bases = \
+ bases='$(TEST_LOGS)'; \
+ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
+ bases=`echo $$bases`
+RECHECK_LOGS = $(TEST_LOGS)
+AM_RECURSIVE_TARGETS = check recheck
+TEST_SUITE_LOG = test-suite.log
+TEST_EXTENSIONS = @EXEEXT@ .test
+am__test_logs1 = $(TESTS:=.log)
+am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
+TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+ $(TEST_LOG_FLAGS)
+am__set_b = \
+ case '$@' in \
+ */*) \
+ case '$*' in \
+ */*) b='$*';; \
+ *) b=`echo '$@' | sed 's/\.log$$//'`; \
+ esac;; \
+ *) \
+ b='$*';; \
+ esac
+am__DIST_COMMON = $(srcdir)/Makefile.core.am $(srcdir)/Makefile.in \
+ $(top_srcdir)/build-aux/depcomp \
+ $(top_srcdir)/build-aux/test-driver \
+ $(top_srcdir)/conf/Makefile.common
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARFLAGS = @ARFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+BOOT_TIME_STATS = @BOOT_TIME_STATS@
+BSS_START_SYMBOL = @BSS_START_SYMBOL@
+BUILD_CC = @BUILD_CC@
+BUILD_CFLAGS = @BUILD_CFLAGS@
+BUILD_CPPFLAGS = @BUILD_CPPFLAGS@ $(CPPFLAGS_DEFAULT)
+BUILD_EXEEXT = @BUILD_EXEEXT@
+BUILD_FREETYPE_CFLAGS = @BUILD_FREETYPE_CFLAGS@
+BUILD_FREETYPE_LIBS = @BUILD_FREETYPE_LIBS@
+BUILD_LDFLAGS = @BUILD_LDFLAGS@
+BUILD_LIBM = @BUILD_LIBM@
+BUILD_SHEBANG = @BUILD_SHEBANG@
+BUILD_SIZEOF_LONG = @BUILD_SIZEOF_LONG@
+BUILD_SIZEOF_VOID_P = @BUILD_SIZEOF_VOID_P@
+BUILD_WORDS_BIGENDIAN = @BUILD_WORDS_BIGENDIAN@
+CC = $(TARGET_CC)
+CCAS = $(TARGET_CC)
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMP = @CMP@
+CPP = $(TARGET_CC)
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = .deps-core
+DISK_CACHE_STATS = @DISK_CACHE_STATS@
+DJVU_FONT_SOURCE = @DJVU_FONT_SOURCE@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EFIEMU64_LINK_FORMAT = @EFIEMU64_LINK_FORMAT@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+END_SYMBOL = @END_SYMBOL@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+FONT_SOURCE = @FONT_SOURCE@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GETOPT_CDEFS_H = @GETOPT_CDEFS_H@
+GETOPT_H = @GETOPT_H@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GLIBC21 = @GLIBC21@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GNULIB_ALPHASORT = @GNULIB_ALPHASORT@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHDIR = @GNULIB_CHDIR@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_CLOSEDIR = @GNULIB_CLOSEDIR@
+GNULIB_CTIME = @GNULIB_CTIME@
+GNULIB_DIRFD = @GNULIB_DIRFD@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP = @GNULIB_DUP@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_EXPLICIT_BZERO = @GNULIB_EXPLICIT_BZERO@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FDATASYNC = @GNULIB_FDATASYNC@
+GNULIB_FDOPEN = @GNULIB_FDOPEN@
+GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FFS = @GNULIB_FFS@
+GNULIB_FFSL = @GNULIB_FFSL@
+GNULIB_FFSLL = @GNULIB_FFSLL@
+GNULIB_FGETC = @GNULIB_FGETC@
+GNULIB_FGETS = @GNULIB_FGETS@
+GNULIB_FNMATCH = @GNULIB_FNMATCH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREAD = @GNULIB_FREAD@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSCANF = @GNULIB_FSCANF@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTAT = @GNULIB_FSTAT@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETC = @GNULIB_GETC@
+GNULIB_GETCHAR = @GNULIB_GETCHAR@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETPASS = @GNULIB_GETPASS@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETTIMEOFDAY = @GNULIB_GETTIMEOFDAY@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GL_UNISTD_H_GETOPT = @GNULIB_GL_UNISTD_H_GETOPT@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_GROUP_MEMBER = @GNULIB_GROUP_MEMBER@
+GNULIB_ISATTY = @GNULIB_ISATTY@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LOCALECONV = @GNULIB_LOCALECONV@
+GNULIB_LOCALENAME = @GNULIB_LOCALENAME@
+GNULIB_LOCALTIME = @GNULIB_LOCALTIME@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_NONBLOCKING = @GNULIB_NONBLOCKING@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_OPENDIR = @GNULIB_OPENDIR@
+GNULIB_OVERRIDES_STRUCT_STAT = @GNULIB_OVERRIDES_STRUCT_STAT@
+GNULIB_OVERRIDES_WINT_T = @GNULIB_OVERRIDES_WINT_T@
+GNULIB_PCLOSE = @GNULIB_PCLOSE@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PTSNAME_R = @GNULIB_PTSNAME_R@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_QSORT_R = @GNULIB_QSORT_R@
+GNULIB_RANDOM = @GNULIB_RANDOM@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READ = @GNULIB_READ@
+GNULIB_READDIR = @GNULIB_READDIR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOCARRAY = @GNULIB_REALLOCARRAY@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_REWINDDIR = @GNULIB_REWINDDIR@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SCANDIR = @GNULIB_SCANDIR@
+GNULIB_SCANF = @GNULIB_SCANF@
+GNULIB_SECURE_GETENV = @GNULIB_SECURE_GETENV@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETHOSTNAME = @GNULIB_SETHOSTNAME@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_NONBLOCKING = @GNULIB_STDIO_H_NONBLOCKING@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRFTIME = @GNULIB_STRFTIME@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TIME_RZ = @GNULIB_TIME_RZ@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TRUNCATE = @GNULIB_TRUNCATE@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_TZSET = @GNULIB_TZSET@
+GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VFSCANF = @GNULIB_VFSCANF@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSCANF = @GNULIB_VSCANF@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSFTIME = @GNULIB_WCSFTIME@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+GRUB_BOOT_MACHINE_LINK_ADDR = @GRUB_BOOT_MACHINE_LINK_ADDR@
+GRUB_PLATFORM = @GRUB_PLATFORM@
+GRUB_TARGET_CPU = @GRUB_TARGET_CPU@
+HAVE_ALPHASORT = @HAVE_ALPHASORT@
+HAVE_ASM_USCORE = @HAVE_ASM_USCORE@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_C99_STDINT_H = @HAVE_C99_STDINT_H@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_CLOSEDIR = @HAVE_CLOSEDIR@
+HAVE_CRTDEFS_H = @HAVE_CRTDEFS_H@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DECL_DIRFD = @HAVE_DECL_DIRFD@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FDATASYNC = @HAVE_DECL_FDATASYNC@
+HAVE_DECL_FDOPENDIR = @HAVE_DECL_FDOPENDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN = @HAVE_DECL_GETLOGIN@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_INITSTATE = @HAVE_DECL_INITSTATE@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@
+HAVE_DECL_SETSTATE = @HAVE_DECL_SETSTATE@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNCASECMP = @HAVE_DECL_STRNCASECMP@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TRUNCATE = @HAVE_DECL_TRUNCATE@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DIRENT_H = @HAVE_DIRENT_H@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_EXPLICIT_BZERO = @HAVE_EXPLICIT_BZERO@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FDATASYNC = @HAVE_FDATASYNC@
+HAVE_FDOPENDIR = @HAVE_FDOPENDIR@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FFS = @HAVE_FFS@
+HAVE_FFSL = @HAVE_FFSL@
+HAVE_FFSLL = @HAVE_FFSLL@
+HAVE_FNMATCH = @HAVE_FNMATCH@
+HAVE_FNMATCH_H = @HAVE_FNMATCH_H@
+HAVE_FONT_SOURCE = @HAVE_FONT_SOURCE@
+HAVE_FREELOCALE = @HAVE_FREELOCALE@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETPASS = @HAVE_GETPASS@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_GROUP_MEMBER = @HAVE_GROUP_MEMBER@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_ALTMON = @HAVE_LANGINFO_ALTMON@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_MSVC_INVALID_PARAMETER_HANDLER = @HAVE_MSVC_INVALID_PARAMETER_HANDLER@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NEWLOCALE = @HAVE_NEWLOCALE@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OPENDIR = @HAVE_OPENDIR@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PCLOSE = @HAVE_PCLOSE@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_POPEN = @HAVE_POPEN@
+HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PTSNAME_R = @HAVE_PTSNAME_R@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_QSORT_R = @HAVE_QSORT_R@
+HAVE_RANDOM = @HAVE_RANDOM@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READDIR = @HAVE_READDIR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALLOCARRAY = @HAVE_REALLOCARRAY@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_REWINDDIR = @HAVE_REWINDDIR@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SCANDIR = @HAVE_SCANDIR@
+HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASECMP = @HAVE_STRCASECMP@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRINGS_H = @HAVE_STRINGS_H@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYSEXITS_H = @HAVE_SYSEXITS_H@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_CDEFS_H = @HAVE_SYS_CDEFS_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@
+HAVE_TZSET = @HAVE_TZSET@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSFTIME = @HAVE_WCSFTIME@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+HELP2MAN = @HELP2MAN@
+HOST_CC = @HOST_CC@
+HOST_CCASFLAGS = @HOST_CCASFLAGS@
+HOST_CFLAGS = @HOST_CFLAGS@
+HOST_CPPFLAGS = @HOST_CPPFLAGS@
+HOST_LDFLAGS = @HOST_LDFLAGS@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDEVMAPPER = @LIBDEVMAPPER@
+LIBGEOM = @LIBGEOM@
+LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
+LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBLZMA = @LIBLZMA@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBNVPAIR = @LIBNVPAIR@
+LIBOBJS = @LIBOBJS@
+LIBPCIACCESS = @LIBPCIACCESS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBSDL = @LIBSDL@
+LIBTHREAD = @LIBTHREAD@
+LIBUNISTRING_UNITYPES_H = @LIBUNISTRING_UNITYPES_H@
+LIBUNISTRING_UNIWIDTH_H = @LIBUNISTRING_UNIWIDTH_H@
+LIBUTIL = @LIBUTIL@
+LIBZFS = @LIBZFS@
+LIMITS_H = @LIMITS_H@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_FNMATCH_H = @NEXT_AS_FIRST_DIRECTIVE_FNMATCH_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRINGS_H = @NEXT_AS_FIRST_DIRECTIVE_STRINGS_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYSEXITS_H = @NEXT_AS_FIRST_DIRECTIVE_SYSEXITS_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_DIRENT_H = @NEXT_DIRENT_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_FNMATCH_H = @NEXT_FNMATCH_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LIMITS_H = @NEXT_LIMITS_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRINGS_H = @NEXT_STRINGS_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYSEXITS_H = @NEXT_SYSEXITS_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POSUB = @POSUB@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = $(TARGET_RANLIB)
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
+REPLACE_CTIME = @REPLACE_CTIME@
+REPLACE_DIRFD = @REPLACE_DIRFD@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FACCESSAT = @REPLACE_FACCESSAT@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FDOPEN = @REPLACE_FDOPEN@
+REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FNMATCH = @REPLACE_FNMATCH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREELOCALE = @REPLACE_FREELOCALE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FTRUNCATE = @REPLACE_FTRUNCATE@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETDTABLESIZE = @REPLACE_GETDTABLESIZE@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_GETPASS = @REPLACE_GETPASS@
+REPLACE_GMTIME = @REPLACE_GMTIME@
+REPLACE_ISATTY = @REPLACE_ISATTY@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_ITOLD = @REPLACE_ITOLD@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALECONV = @REPLACE_LOCALECONV@
+REPLACE_LOCALTIME = @REPLACE_LOCALTIME@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NEWLOCALE = @REPLACE_NEWLOCALE@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_OPENDIR = @REPLACE_OPENDIR@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PTSNAME = @REPLACE_PTSNAME@
+REPLACE_PTSNAME_R = @REPLACE_PTSNAME_R@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_QSORT_R = @REPLACE_QSORT_R@
+REPLACE_RANDOM_R = @REPLACE_RANDOM_R@
+REPLACE_READ = @REPLACE_READ@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_READLINKAT = @REPLACE_READLINKAT@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_READ_FUNCS = @REPLACE_STDIO_READ_FUNCS@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRFTIME = @REPLACE_STRFTIME@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_STRUCT_LCONV = @REPLACE_STRUCT_LCONV@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TOWLOWER = @REPLACE_TOWLOWER@
+REPLACE_TRUNCATE = @REPLACE_TRUNCATE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_TZSET = @REPLACE_TZSET@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSFTIME = @REPLACE_WCSFTIME@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDALIGN_H = @STDALIGN_H@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = $(TARGET_STRIP)
+SYSEXITS_H = @SYSEXITS_H@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TARGET_APPLE_LINKER = @TARGET_APPLE_LINKER@
+TARGET_CC = @TARGET_CC@
+TARGET_CCAS = @TARGET_CCAS@
+TARGET_CCASFLAGS = @TARGET_CCASFLAGS@
+TARGET_CC_VERSION = @TARGET_CC_VERSION@
+TARGET_CFLAGS = @TARGET_CFLAGS@
+TARGET_CPP = @TARGET_CPP@
+TARGET_CPPFLAGS = @TARGET_CPPFLAGS@
+TARGET_DECOMPRESSOR_LINK_ADDR = @TARGET_DECOMPRESSOR_LINK_ADDR@
+TARGET_IMG_BASE_LDOPT = @TARGET_IMG_BASE_LDOPT@
+TARGET_IMG_CFLAGS = @TARGET_IMG_CFLAGS@
+TARGET_IMG_LDFLAGS = @TARGET_IMG_LDFLAGS@
+TARGET_LDFLAGS = @TARGET_LDFLAGS@
+TARGET_LDFLAGS_OLDMAGIC = @TARGET_LDFLAGS_OLDMAGIC@
+TARGET_LINK_ADDR = @TARGET_LINK_ADDR@
+TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
+TARGET_NM = @TARGET_NM@
+TARGET_NMFLAGS_DEFINED_ONLY = @TARGET_NMFLAGS_DEFINED_ONLY@
+TARGET_NMFLAGS_MINUS_P = @TARGET_NMFLAGS_MINUS_P@
+TARGET_OBJ2ELF = @TARGET_OBJ2ELF@
+TARGET_OBJCONV = @TARGET_OBJCONV@
+TARGET_OBJCOPY = @TARGET_OBJCOPY@
+TARGET_RANLIB = @TARGET_RANLIB@
+TARGET_STRIP = @TARGET_STRIP@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@
+WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@
+WINDOWS_STAT_INODES = @WINDOWS_STAT_INODES@
+WINDOWS_STAT_TIMESPEC = @WINDOWS_STAT_TIMESPEC@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_TARGET_CC = @ac_ct_TARGET_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bootdirname = @bootdirname@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+enable_efiemu = @enable_efiemu@
+enable_grub_emu_pci = @enable_grub_emu_pci@
+enable_grub_emu_sdl = @enable_grub_emu_sdl@
+enable_grub_mkfont = @enable_grub_mkfont@
+enable_grub_mount = @enable_grub_mount@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+grub_bios_setup = @grub_bios_setup@
+grub_editenv = @grub_editenv@
+grub_file = @grub_file@
+grub_glue_efi = @grub_glue_efi@
+grub_install = @grub_install@
+grub_mkconfig = @grub_mkconfig@
+grub_mkfont = @grub_mkfont@
+grub_mkimage = @grub_mkimage@
+grub_mklayout = @grub_mklayout@
+grub_mkpasswd_pbkdf2 = @grub_mkpasswd_pbkdf2@
+grub_mkrelpath = @grub_mkrelpath@
+grub_mkrescue = @grub_mkrescue@
+grub_probe = @grub_probe@
+grub_reboot = @grub_reboot@
+grub_render_label = @grub_render_label@
+grub_script_check = @grub_script_check@
+grub_set_default = @grub_set_default@
+grub_sparc64_setup = @grub_sparc64_setup@
+grubdirname = @grubdirname@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_kernel = @host_kernel@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+platform = @platform@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = subdir-objects -Wno-portability
+CFLAGS_PLATFORM = $(am__append_1) $(am__append_2)
+@COND_arm_TRUE@@COND_emu_FALSE@LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache
+
+# Platform specific options
+@COND_sparc64_ieee1275_TRUE@LDFLAGS_PLATFORM = -Wl,-melf64_sparc
+
+# Other options
+CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\" \
+ -I$(builddir) -I$(srcdir) -I$(top_builddir) -I$(top_srcdir) \
+ -I$(top_srcdir)/include -I$(top_builddir)/include \
+ -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/
+CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1
+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 -R .MIPS.abiflags -R .ARM.exidx
+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_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)
+CFLAGS_PROGRAM = $(CFLAGS_PLATFORM)
+LDFLAGS_PROGRAM = $(LDFLAGS_PLATFORM)
+CPPFLAGS_PROGRAM = $(CPPFLAGS_PLATFORM)
+CCASFLAGS_PROGRAM = $(CCASFLAGS_PLATFORM)
+CFLAGS_LIBRARY = $(CFLAGS_PLATFORM) -fno-builtin
+CPPFLAGS_LIBRARY = $(CPPFLAGS_PLATFORM)
+CCASFLAGS_LIBRARY = $(CCASFLAGS_PLATFORM)
+
+# Other variables
+grubconfdir = $(sysconfdir)/grub.d
+platformdir = $(pkglibdir)/$(target_cpu)-$(platform)
+starfielddir = $(pkgdatadir)/themes/starfield
+CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion
+CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib
+CFLAGS_POSIX = -fno-builtin
+CPPFLAGS_POSIX = -I$(top_srcdir)/grub-core/lib/posix_wrap
+CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers -Wno-redundant-decls -Wno-undef $(CFLAGS_POSIX)
+CPPFLAGS_GCRY = -I$(top_srcdir)/grub-core/lib/libgcrypt_wrap $(CPPFLAGS_POSIX) -D_GCRYPT_IN_LIBGCRYPT=1 -I$(top_srcdir)/include/grub/gcrypt
+CPPFLAGS_EFIEMU = -I$(top_srcdir)/grub-core/efiemu/runtime
+
+# List file macros for recognizing /interesting/ modules
+CPPFLAGS_FS_LIST = -Dgrub_fs_register=FS_LIST_MARKER
+CPPFLAGS_VIDEO_LIST = -Dgrub_video_register=VIDEO_LIST_MARKER
+CPPFLAGS_PARTMAP_LIST = -Dgrub_partition_map_register=PARTMAP_LIST_MARKER
+CPPFLAGS_PARTTOOL_LIST = -Dgrub_parttool_register=PARTTOOL_LIST_MARKER
+CPPFLAGS_TERMINAL_LIST = '-Dgrub_term_register_input(...)=INPUT_TERMINAL_LIST_MARKER(__VA_ARGS__)' \
+ '-Dgrub_term_register_output(...)=OUTPUT_TERMINAL_LIST_MARKER(__VA_ARGS__)'
+CPPFLAGS_COMMAND_LIST = '-Dgrub_register_command(...)=COMMAND_LIST_MARKER(__VA_ARGS__)' \
+ '-Dgrub_register_command_lockdown(...)=COMMAND_LOCKDOWN_LIST_MARKER(__VA_ARGS__)' \
+ '-Dgrub_register_extcmd(...)=EXTCOMMAND_LIST_MARKER(__VA_ARGS__)' \
+ '-Dgrub_register_extcmd_lockdown(...)=EXTCOMMAND_LOCKDOWN_LIST_MARKER(__VA_ARGS__)' \
+ '-Dgrub_register_command_p1(...)=P1COMMAND_LIST_MARKER(__VA_ARGS__)'
+CPPFLAGS_FDT_LIST := '-Dgrub_fdtbus_register(...)=FDT_DRIVER_LIST_MARKER(__VA_ARGS__)'
+CPPFLAGS_MARKER = $(CPPFLAGS_FS_LIST) $(CPPFLAGS_VIDEO_LIST) \
+ $(CPPFLAGS_PARTTOOL_LIST) $(CPPFLAGS_PARTMAP_LIST) \
+ $(CPPFLAGS_TERMINAL_LIST) $(CPPFLAGS_COMMAND_LIST) \
+ $(CPPFLAGS_FDT_LIST)
+
+
+# Define these variables to calm down automake
+IMG_FILES =
+MOD_FILES = disk.mod trig.mod $(am__append_8) $(am__append_15) \
+ $(am__append_22) $(am__append_29) $(am__append_36) \
+ $(am__append_43) $(am__append_50) $(am__append_57) \
+ $(am__append_64) $(am__append_71) $(am__append_78) \
+ $(am__append_85) $(am__append_92) $(am__append_99) \
+ $(am__append_106) $(am__append_113) $(am__append_120) \
+ $(am__append_127) $(am__append_134) $(am__append_141) \
+ $(am__append_148) $(am__append_155) $(am__append_162) \
+ $(am__append_169) $(am__append_176) $(am__append_183) \
+ $(am__append_190) $(am__append_197) $(am__append_204) \
+ $(am__append_211) $(am__append_218) $(am__append_225) \
+ $(am__append_232) $(am__append_239) $(am__append_246) \
+ $(am__append_253) $(am__append_260) $(am__append_267) \
+ $(am__append_274) $(am__append_281) $(am__append_288) \
+ $(am__append_295) $(am__append_302) $(am__append_309) \
+ $(am__append_316) $(am__append_323) $(am__append_330) \
+ $(am__append_337) $(am__append_344) $(am__append_351) \
+ $(am__append_358) $(am__append_365) $(am__append_372) \
+ $(am__append_379) $(am__append_386) $(am__append_393) \
+ $(am__append_400) $(am__append_407) $(am__append_414) \
+ $(am__append_421) $(am__append_428) $(am__append_435) \
+ $(am__append_442) $(am__append_449) $(am__append_456) \
+ $(am__append_463) $(am__append_470) $(am__append_477) \
+ $(am__append_484) $(am__append_491) $(am__append_498) \
+ $(am__append_505) $(am__append_512) $(am__append_519) \
+ $(am__append_526) $(am__append_533) $(am__append_540) \
+ $(am__append_547) $(am__append_554) $(am__append_561) \
+ $(am__append_568) $(am__append_575) $(am__append_582) \
+ $(am__append_589) $(am__append_596) $(am__append_603) \
+ $(am__append_610) $(am__append_617) $(am__append_624) \
+ $(am__append_631) $(am__append_638) $(am__append_645) \
+ $(am__append_652) $(am__append_659) $(am__append_666) \
+ $(am__append_673) $(am__append_680) $(am__append_687) \
+ $(am__append_694) $(am__append_701) $(am__append_708) \
+ $(am__append_715) $(am__append_722) $(am__append_729) \
+ $(am__append_736) $(am__append_743) $(am__append_750) \
+ $(am__append_757) $(am__append_764) $(am__append_771) \
+ $(am__append_778) $(am__append_785) $(am__append_792) \
+ $(am__append_799) $(am__append_806) $(am__append_813) \
+ $(am__append_820) $(am__append_827) $(am__append_834) \
+ $(am__append_841) $(am__append_848) $(am__append_855) \
+ $(am__append_862) $(am__append_869) $(am__append_876) \
+ $(am__append_883) $(am__append_890) $(am__append_897) \
+ $(am__append_904) $(am__append_911) $(am__append_918) \
+ $(am__append_925) $(am__append_932) $(am__append_939) \
+ $(am__append_946) $(am__append_953) $(am__append_960) \
+ $(am__append_967) $(am__append_974) $(am__append_981) \
+ $(am__append_988) $(am__append_995) $(am__append_1002) \
+ $(am__append_1009) $(am__append_1016) $(am__append_1023) \
+ $(am__append_1030) regexp.mod $(am__append_1037) \
+ $(am__append_1044) $(am__append_1051) $(am__append_1058) \
+ $(am__append_1065) $(am__append_1072) $(am__append_1079) \
+ $(am__append_1086) $(am__append_1093) $(am__append_1100) \
+ $(am__append_1107) $(am__append_1114) $(am__append_1121) \
+ $(am__append_1128) $(am__append_1135) $(am__append_1142) \
+ $(am__append_1149) $(am__append_1156) $(am__append_1163) \
+ $(am__append_1170) $(am__append_1177) $(am__append_1184) \
+ $(am__append_1191) $(am__append_1198) $(am__append_1205) \
+ $(am__append_1212) $(am__append_1219) $(am__append_1226) \
+ $(am__append_1233) $(am__append_1240) $(am__append_1247) \
+ $(am__append_1254) $(am__append_1261) $(am__append_1268) \
+ $(am__append_1275) $(am__append_1282) $(am__append_1289) \
+ $(am__append_1296) $(am__append_1303) $(am__append_1310) \
+ $(am__append_1317) $(am__append_1324) $(am__append_1331) \
+ $(am__append_1338) $(am__append_1345) $(am__append_1352) \
+ $(am__append_1359) $(am__append_1366) $(am__append_1373) \
+ $(am__append_1380) $(am__append_1387) $(am__append_1394) \
+ $(am__append_1401) $(am__append_1408) $(am__append_1415) \
+ blocklist.mod $(am__append_1422) $(am__append_1429) \
+ $(am__append_1436) $(am__append_1443) $(am__append_1450) \
+ $(am__append_1457) $(am__append_1464) $(am__append_1471) \
+ $(am__append_1478) $(am__append_1485) $(am__append_1492) \
+ $(am__append_1499) $(am__append_1506) $(am__append_1513) \
+ $(am__append_1520) $(am__append_1527) $(am__append_1534) \
+ $(am__append_1541) cat.mod cmp.mod configfile.mod \
+ $(am__append_1548) $(am__append_1555) $(am__append_1562) \
+ $(am__append_1569) $(am__append_1576) $(am__append_1583) \
+ $(am__append_1590) $(am__append_1597) $(am__append_1604) \
+ $(am__append_1611) date.mod $(am__append_1618) echo.mod \
+ eval.mod $(am__append_1625) $(am__append_1632) \
+ $(am__append_1639) $(am__append_1646) $(am__append_1653) \
+ $(am__append_1660) $(am__append_1667) $(am__append_1674) \
+ $(am__append_1681) $(am__append_1688) $(am__append_1695) \
+ $(am__append_1702) $(am__append_1709) $(am__append_1716) \
+ gptsync.mod $(am__append_1723) $(am__append_1730) \
+ $(am__append_1737) $(am__append_1744) $(am__append_1751) \
+ $(am__append_1758) $(am__append_1765) $(am__append_1772) \
+ $(am__append_1779) $(am__append_1786) $(am__append_1793) \
+ $(am__append_1800) $(am__append_1807) $(am__append_1814) \
+ $(am__append_1821) $(am__append_1828) $(am__append_1835) \
+ $(am__append_1842) $(am__append_1849) $(am__append_1856) \
+ $(am__append_1863) $(am__append_1870) $(am__append_1877) \
+ $(am__append_1884) $(am__append_1891) $(am__append_1898) \
+ $(am__append_1905) $(am__append_1912) $(am__append_1919) \
+ $(am__append_1926) $(am__append_1933) $(am__append_1940) \
+ $(am__append_1947) $(am__append_1954) $(am__append_1961) \
+ $(am__append_1968) $(am__append_1975) $(am__append_1982) \
+ $(am__append_1989) $(am__append_1996) $(am__append_2003) \
+ $(am__append_2010) $(am__append_2017) $(am__append_2024) \
+ $(am__append_2031) $(am__append_2038) hashsum.mod pgp.mod \
+ $(am__append_2045) $(am__append_2052) $(am__append_2059) \
+ $(am__append_2066) $(am__append_2073) $(am__append_2080) \
+ $(am__append_2087) $(am__append_2094) $(am__append_2101) \
+ help.mod hexdump.mod keystatus.mod $(am__append_2108) \
+ $(am__append_2115) loadenv.mod ls.mod lsmmap.mod \
+ $(am__append_2122) $(am__append_2129) $(am__append_2136) \
+ $(am__append_2143) $(am__append_2150) $(am__append_2157) \
+ $(am__append_2164) $(am__append_2171) memrw.mod minicmd.mod \
+ parttool.mod password.mod password_pbkdf2.mod \
+ $(am__append_2178) $(am__append_2185) $(am__append_2192) \
+ $(am__append_2199) $(am__append_2206) $(am__append_2213) \
+ $(am__append_2220) $(am__append_2227) $(am__append_2234) \
+ $(am__append_2241) $(am__append_2248) $(am__append_2255) \
+ $(am__append_2262) $(am__append_2269) $(am__append_2276) \
+ $(am__append_2283) $(am__append_2290) $(am__append_2297) \
+ $(am__append_2304) $(am__append_2311) $(am__append_2318) \
+ probe.mod read.mod search.mod search_fs_file.mod \
+ search_fs_uuid.mod search_label.mod $(am__append_2325) \
+ $(am__append_2332) $(am__append_2339) $(am__append_2346) \
+ $(am__append_2353) $(am__append_2360) $(am__append_2367) \
+ $(am__append_2374) $(am__append_2381) $(am__append_2388) \
+ $(am__append_2395) $(am__append_2402) $(am__append_2409) \
+ $(am__append_2416) $(am__append_2423) $(am__append_2430) \
+ sleep.mod $(am__append_2437) $(am__append_2444) \
+ $(am__append_2451) $(am__append_2458) $(am__append_2465) \
+ $(am__append_2472) $(am__append_2479) $(am__append_2486) \
+ $(am__append_2493) $(am__append_2500) $(am__append_2507) \
+ $(am__append_2514) terminal.mod test.mod true.mod \
+ $(am__append_2521) $(am__append_2528) $(am__append_2535) \
+ $(am__append_2542) $(am__append_2549) $(am__append_2556) \
+ $(am__append_2563) $(am__append_2570) $(am__append_2577) \
+ videoinfo.mod videotest.mod xnu_uuid.mod dm_nv.mod \
+ loopback.mod cryptodisk.mod json.mod afsplitter.mod luks.mod \
+ luks2.mod geli.mod lvm.mod ldm.mod mdraid09.mod \
+ mdraid09_be.mod mdraid1x.mod diskfilter.mod raid5rec.mod \
+ raid6rec.mod scsi.mod memdisk.mod $(am__append_2584) \
+ $(am__append_2591) $(am__append_2598) $(am__append_2605) \
+ $(am__append_2612) $(am__append_2619) $(am__append_2626) \
+ $(am__append_2633) $(am__append_2640) $(am__append_2647) \
+ $(am__append_2654) $(am__append_2661) $(am__append_2668) \
+ $(am__append_2675) $(am__append_2682) $(am__append_2689) \
+ $(am__append_2696) $(am__append_2703) $(am__append_2710) \
+ $(am__append_2717) $(am__append_2724) $(am__append_2731) \
+ $(am__append_2738) $(am__append_2745) $(am__append_2752) \
+ $(am__append_2759) $(am__append_2766) $(am__append_2773) \
+ $(am__append_2780) $(am__append_2787) $(am__append_2794) \
+ $(am__append_2801) $(am__append_2808) $(am__append_2815) \
+ $(am__append_2822) $(am__append_2829) $(am__append_2836) \
+ $(am__append_2843) $(am__append_2850) $(am__append_2857) \
+ $(am__append_2864) $(am__append_2871) $(am__append_2878) \
+ $(am__append_2885) $(am__append_2892) $(am__append_2899) \
+ $(am__append_2906) $(am__append_2913) $(am__append_2920) \
+ $(am__append_2927) $(am__append_2934) $(am__append_2941) \
+ $(am__append_2948) $(am__append_2955) $(am__append_2962) \
+ $(am__append_2969) $(am__append_2976) $(am__append_2983) \
+ $(am__append_2990) $(am__append_2997) $(am__append_3004) \
+ procfs.mod affs.mod afs.mod bfs.mod zstd.mod btrfs.mod \
+ archelp.mod cbfs.mod cpio.mod cpio_be.mod newc.mod odc.mod \
+ ext2.mod fat.mod exfat.mod f2fs.mod fshelp.mod hfs.mod \
+ hfsplus.mod hfspluscomp.mod iso9660.mod jfs.mod minix.mod \
+ minix2.mod minix3.mod minix_be.mod minix2_be.mod minix3_be.mod \
+ nilfs2.mod ntfs.mod ntfscomp.mod reiserfs.mod romfs.mod \
+ sfs.mod squash4.mod tar.mod udf.mod ufs1.mod ufs1_be.mod \
+ ufs2.mod xfs.mod zfs.mod zfscrypt.mod zfsinfo.mod macbless.mod \
+ $(am__append_3011) gettext.mod gfxmenu.mod hello.mod gzio.mod \
+ offsetio.mod $(am__append_3018) $(am__append_3025) \
+ $(am__append_3032) $(am__append_3039) $(am__append_3046) \
+ $(am__append_3053) $(am__append_3060) $(am__append_3067) \
+ $(am__append_3074) $(am__append_3081) $(am__append_3088) \
+ $(am__append_3095) $(am__append_3102) $(am__append_3109) \
+ $(am__append_3116) $(am__append_3123) $(am__append_3130) \
+ $(am__append_3137) $(am__append_3144) $(am__append_3151) \
+ elf.mod crypto.mod pbkdf2.mod $(am__append_3158) \
+ $(am__append_3165) $(am__append_3172) $(am__append_3179) \
+ $(am__append_3186) $(am__append_3193) $(am__append_3200) \
+ $(am__append_3207) $(am__append_3214) $(am__append_3221) \
+ $(am__append_3228) $(am__append_3235) $(am__append_3242) \
+ $(am__append_3249) $(am__append_3256) $(am__append_3263) \
+ $(am__append_3270) $(am__append_3277) $(am__append_3284) \
+ $(am__append_3291) $(am__append_3298) $(am__append_3305) \
+ $(am__append_3312) $(am__append_3319) $(am__append_3326) \
+ $(am__append_3333) $(am__append_3340) $(am__append_3347) \
+ $(am__append_3354) $(am__append_3361) $(am__append_3368) \
+ $(am__append_3375) $(am__append_3382) $(am__append_3389) \
+ $(am__append_3396) $(am__append_3403) $(am__append_3410) \
+ setjmp.mod $(am__append_3417) $(am__append_3424) \
+ $(am__append_3431) $(am__append_3438) $(am__append_3445) \
+ $(am__append_3452) $(am__append_3459) $(am__append_3466) \
+ $(am__append_3473) $(am__append_3480) $(am__append_3487) \
+ $(am__append_3494) $(am__append_3501) $(am__append_3508) \
+ $(am__append_3515) $(am__append_3522) $(am__append_3529) \
+ $(am__append_3536) $(am__append_3543) $(am__append_3550) \
+ $(am__append_3557) $(am__append_3564) $(am__append_3571) \
+ $(am__append_3578) $(am__append_3585) $(am__append_3592) \
+ $(am__append_3599) $(am__append_3606) $(am__append_3613) \
+ $(am__append_3620) $(am__append_3627) $(am__append_3634) \
+ $(am__append_3641) $(am__append_3648) $(am__append_3655) \
+ $(am__append_3662) $(am__append_3669) $(am__append_3676) \
+ $(am__append_3683) $(am__append_3690) $(am__append_3697) \
+ $(am__append_3704) $(am__append_3711) $(am__append_3718) \
+ $(am__append_3725) $(am__append_3732) $(am__append_3739) \
+ $(am__append_3746) $(am__append_3753) $(am__append_3760) \
+ $(am__append_3767) $(am__append_3774) $(am__append_3781) \
+ $(am__append_3788) $(am__append_3795) $(am__append_3802) \
+ $(am__append_3809) $(am__append_3816) $(am__append_3823) \
+ $(am__append_3830) $(am__append_3837) $(am__append_3844) \
+ $(am__append_3851) $(am__append_3858) $(am__append_3865) \
+ $(am__append_3872) $(am__append_3879) $(am__append_3886) \
+ $(am__append_3893) $(am__append_3900) $(am__append_3907) \
+ $(am__append_3914) $(am__append_3921) $(am__append_3928) \
+ $(am__append_3935) $(am__append_3942) $(am__append_3949) \
+ $(am__append_3956) macho.mod $(am__append_3963) \
+ $(am__append_3970) $(am__append_3977) $(am__append_3984) \
+ $(am__append_3991) $(am__append_3998) $(am__append_4005) \
+ $(am__append_4012) $(am__append_4019) $(am__append_4026) \
+ $(am__append_4033) $(am__append_4040) $(am__append_4047) \
+ $(am__append_4054) $(am__append_4061) $(am__append_4068) \
+ $(am__append_4075) $(am__append_4082) $(am__append_4089) \
+ $(am__append_4096) $(am__append_4103) $(am__append_4110) \
+ $(am__append_4117) $(am__append_4124) $(am__append_4131) \
+ $(am__append_4138) $(am__append_4145) normal.mod \
+ part_acorn.mod part_amiga.mod part_apple.mod part_gpt.mod \
+ part_msdos.mod part_sun.mod part_plan.mod part_dvh.mod \
+ part_bsd.mod part_sunpc.mod part_dfly.mod msdospart.mod \
+ $(am__append_4152) $(am__append_4159) $(am__append_4166) \
+ $(am__append_4173) $(am__append_4180) $(am__append_4187) \
+ $(am__append_4194) $(am__append_4201) $(am__append_4208) \
+ $(am__append_4215) $(am__append_4222) $(am__append_4229) \
+ $(am__append_4236) $(am__append_4243) $(am__append_4250) \
+ $(am__append_4257) $(am__append_4264) $(am__append_4271) \
+ $(am__append_4278) $(am__append_4285) $(am__append_4292) \
+ $(am__append_4299) $(am__append_4306) $(am__append_4313) \
+ $(am__append_4320) $(am__append_4327) $(am__append_4334) \
+ gfxterm_background.mod $(am__append_4341) $(am__append_4348) \
+ $(am__append_4355) $(am__append_4362) $(am__append_4369) \
+ $(am__append_4376) $(am__append_4383) $(am__append_4390) \
+ $(am__append_4397) $(am__append_4404) $(am__append_4411) \
+ $(am__append_4418) $(am__append_4425) $(am__append_4432) \
+ $(am__append_4439) $(am__append_4446) $(am__append_4453) \
+ $(am__append_4460) $(am__append_4467) $(am__append_4474) \
+ $(am__append_4481) $(am__append_4488) $(am__append_4495) \
+ $(am__append_4502) $(am__append_4509) $(am__append_4516) \
+ $(am__append_4523) $(am__append_4530) $(am__append_4537) \
+ $(am__append_4544) $(am__append_4551) $(am__append_4558) \
+ $(am__append_4565) $(am__append_4572) $(am__append_4579) \
+ $(am__append_4586) $(am__append_4593) $(am__append_4600) \
+ $(am__append_4607) $(am__append_4614) $(am__append_4621) \
+ $(am__append_4628) $(am__append_4635) $(am__append_4642) \
+ $(am__append_4649) $(am__append_4656) $(am__append_4663) \
+ $(am__append_4670) $(am__append_4677) $(am__append_4684) \
+ $(am__append_4691) $(am__append_4698) $(am__append_4705) \
+ $(am__append_4712) $(am__append_4719) functional_test.mod \
+ exfctest.mod strtoull_test.mod setjmp_test.mod \
+ signature_test.mod sleep_test.mod xnu_uuid_test.mod \
+ pbkdf2_test.mod $(am__append_4726) $(am__append_4733) \
+ $(am__append_4740) $(am__append_4747) $(am__append_4754) \
+ $(am__append_4761) $(am__append_4768) $(am__append_4775) \
+ $(am__append_4782) $(am__append_4789) $(am__append_4796) \
+ $(am__append_4803) $(am__append_4810) $(am__append_4817) \
+ $(am__append_4824) $(am__append_4831) $(am__append_4838) \
+ $(am__append_4845) $(am__append_4852) $(am__append_4859) \
+ $(am__append_4866) $(am__append_4873) $(am__append_4880) \
+ $(am__append_4887) $(am__append_4894) div_test.mod \
+ mul_test.mod shift_test.mod cmp_test.mod ctz_test.mod \
+ bswap_test.mod videotest_checksum.mod gfxterm_menu.mod \
+ cmdline_cat_test.mod bitmap.mod bitmap_scale.mod \
+ $(am__append_4901) $(am__append_4908) $(am__append_4915) \
+ $(am__append_4922) $(am__append_4929) $(am__append_4936) \
+ $(am__append_4943) $(am__append_4950) $(am__append_4957) \
+ jpeg.mod png.mod tga.mod $(am__append_4964) $(am__append_4971) \
+ $(am__append_4978) $(am__append_4985) $(am__append_4992) \
+ $(am__append_4999) $(am__append_5006) $(am__append_5013) \
+ $(am__append_5020) $(am__append_5027) $(am__append_5034) \
+ $(am__append_5041) $(am__append_5048) $(am__append_5055) \
+ $(am__append_5062) $(am__append_5069) $(am__append_5076) \
+ $(am__append_5083) $(am__append_5090) $(am__append_5097) \
+ $(am__append_5104) $(am__append_5111) $(am__append_5118) \
+ $(am__append_5125) $(am__append_5132) $(am__append_5139) \
+ $(am__append_5146) $(am__append_5153) $(am__append_5160) \
+ $(am__append_5167) $(am__append_5174) $(am__append_5181) \
+ $(am__append_5188) $(am__append_5195) $(am__append_5202) \
+ $(am__append_5209) $(am__append_5216) $(am__append_5223) \
+ $(am__append_5230) $(am__append_5237) $(am__append_5244) \
+ video_colors.mod $(am__append_5251) $(am__append_5258) \
+ datehook.mod net.mod tftp.mod http.mod $(am__append_5265) \
+ $(am__append_5272) $(am__append_5279) $(am__append_5286) \
+ $(am__append_5293) $(am__append_5300) $(am__append_5307) \
+ $(am__append_5314) $(am__append_5321) $(am__append_5328) \
+ $(am__append_5335) $(am__append_5342) $(am__append_5349) \
+ $(am__append_5356) $(am__append_5363) $(am__append_5370) \
+ $(am__append_5377) $(am__append_5384) syslinuxcfg.mod \
+ test_blockarg.mod xzio.mod lzopio.mod testload.mod \
+ $(am__append_5391) $(am__append_5398) $(am__append_5405) \
+ $(am__append_5412) $(am__append_5419) $(am__append_5426) \
+ $(am__append_5433) $(am__append_5440) $(am__append_5447) \
+ $(am__append_5454) $(am__append_5461) $(am__append_5468) \
+ $(am__append_5475) $(am__append_5482) $(am__append_5489) \
+ $(am__append_5496) $(am__append_5503) priority_queue.mod \
+ time.mod $(am__append_5510) $(am__append_5517) adler32.mod \
+ crc64.mod mpi.mod all_video.mod $(am__append_5524) \
+ $(am__append_5531) $(am__append_5538) $(am__append_5545) \
+ $(am__append_5552) $(am__append_5559) testspeed.mod \
+ $(am__append_5566) $(am__append_5573) $(am__append_5580) \
+ $(am__append_5587) $(am__append_5594) $(am__append_5601) \
+ $(am__append_5608) tr.mod progress.mod file.mod \
+ $(am__append_5615) $(am__append_5622) $(am__append_5629) \
+ $(am__append_5636) $(am__append_5643) $(am__append_5650) \
+ $(am__append_5657) $(am__append_5664) $(am__append_5671) \
+ $(am__append_5678) $(am__append_5685) $(am__append_5692) \
+ $(am__append_5699) $(am__append_5706) gcry_arcfour.mod \
+ gcry_blowfish.mod gcry_camellia.mod gcry_cast5.mod \
+ gcry_crc.mod gcry_des.mod gcry_dsa.mod gcry_idea.mod \
+ gcry_md4.mod gcry_md5.mod gcry_rfc2268.mod gcry_rijndael.mod \
+ gcry_rmd160.mod gcry_rsa.mod gcry_seed.mod gcry_serpent.mod \
+ gcry_sha1.mod gcry_sha256.mod gcry_sha512.mod gcry_tiger.mod \
+ gcry_twofish.mod gcry_whirlpool.mod
+MODULE_FILES = disk.module$(EXEEXT) trig.module$(EXEEXT) \
+ $(am__append_4) $(am__append_11) $(am__append_18) \
+ $(am__append_25) $(am__append_32) $(am__append_39) \
+ $(am__append_46) $(am__append_53) $(am__append_60) \
+ $(am__append_67) $(am__append_74) $(am__append_81) \
+ $(am__append_88) $(am__append_95) $(am__append_102) \
+ $(am__append_109) $(am__append_116) $(am__append_123) \
+ $(am__append_130) $(am__append_137) $(am__append_144) \
+ $(am__append_151) $(am__append_158) $(am__append_165) \
+ $(am__append_172) $(am__append_179) $(am__append_186) \
+ $(am__append_193) $(am__append_200) $(am__append_207) \
+ $(am__append_214) $(am__append_221) $(am__append_228) \
+ $(am__append_235) $(am__append_242) $(am__append_249) \
+ $(am__append_256) $(am__append_263) $(am__append_270) \
+ $(am__append_277) $(am__append_284) $(am__append_291) \
+ $(am__append_298) $(am__append_305) $(am__append_312) \
+ $(am__append_319) $(am__append_326) $(am__append_333) \
+ $(am__append_340) $(am__append_347) $(am__append_354) \
+ $(am__append_361) $(am__append_368) $(am__append_375) \
+ $(am__append_382) $(am__append_389) $(am__append_396) \
+ $(am__append_403) $(am__append_410) $(am__append_417) \
+ $(am__append_424) $(am__append_431) $(am__append_438) \
+ $(am__append_445) $(am__append_452) $(am__append_459) \
+ $(am__append_466) $(am__append_473) $(am__append_480) \
+ $(am__append_487) $(am__append_494) $(am__append_501) \
+ $(am__append_508) $(am__append_515) $(am__append_522) \
+ $(am__append_529) $(am__append_536) $(am__append_543) \
+ $(am__append_550) $(am__append_557) $(am__append_564) \
+ $(am__append_571) $(am__append_578) $(am__append_585) \
+ $(am__append_592) $(am__append_599) $(am__append_606) \
+ $(am__append_613) $(am__append_620) $(am__append_627) \
+ $(am__append_634) $(am__append_641) $(am__append_648) \
+ $(am__append_655) $(am__append_662) $(am__append_669) \
+ $(am__append_676) $(am__append_683) $(am__append_690) \
+ $(am__append_697) $(am__append_704) $(am__append_711) \
+ $(am__append_718) $(am__append_725) $(am__append_732) \
+ $(am__append_739) $(am__append_746) $(am__append_753) \
+ $(am__append_760) $(am__append_767) $(am__append_774) \
+ $(am__append_781) $(am__append_788) $(am__append_795) \
+ $(am__append_802) $(am__append_809) $(am__append_816) \
+ $(am__append_823) $(am__append_830) $(am__append_837) \
+ $(am__append_844) $(am__append_851) $(am__append_858) \
+ $(am__append_865) $(am__append_872) $(am__append_879) \
+ $(am__append_886) $(am__append_893) $(am__append_900) \
+ $(am__append_907) $(am__append_914) $(am__append_921) \
+ $(am__append_928) $(am__append_935) $(am__append_942) \
+ $(am__append_949) $(am__append_956) $(am__append_963) \
+ $(am__append_970) $(am__append_977) $(am__append_984) \
+ $(am__append_991) $(am__append_998) $(am__append_1005) \
+ $(am__append_1012) $(am__append_1019) $(am__append_1026) \
+ regexp.module$(EXEEXT) $(am__append_1033) $(am__append_1040) \
+ $(am__append_1047) $(am__append_1054) $(am__append_1061) \
+ $(am__append_1068) $(am__append_1075) $(am__append_1082) \
+ $(am__append_1089) $(am__append_1096) $(am__append_1103) \
+ $(am__append_1110) $(am__append_1117) $(am__append_1124) \
+ $(am__append_1131) $(am__append_1138) $(am__append_1145) \
+ $(am__append_1152) $(am__append_1159) $(am__append_1166) \
+ $(am__append_1173) $(am__append_1180) $(am__append_1187) \
+ $(am__append_1194) $(am__append_1201) $(am__append_1208) \
+ $(am__append_1215) $(am__append_1222) $(am__append_1229) \
+ $(am__append_1236) $(am__append_1243) $(am__append_1250) \
+ $(am__append_1257) $(am__append_1264) $(am__append_1271) \
+ $(am__append_1278) $(am__append_1285) $(am__append_1292) \
+ $(am__append_1299) $(am__append_1306) $(am__append_1313) \
+ $(am__append_1320) $(am__append_1327) $(am__append_1334) \
+ $(am__append_1341) $(am__append_1348) $(am__append_1355) \
+ $(am__append_1362) $(am__append_1369) $(am__append_1376) \
+ $(am__append_1383) $(am__append_1390) $(am__append_1397) \
+ $(am__append_1404) $(am__append_1411) \
+ blocklist.module$(EXEEXT) $(am__append_1418) \
+ $(am__append_1425) $(am__append_1432) $(am__append_1439) \
+ $(am__append_1446) $(am__append_1453) $(am__append_1460) \
+ $(am__append_1467) $(am__append_1474) $(am__append_1481) \
+ $(am__append_1488) $(am__append_1495) $(am__append_1502) \
+ $(am__append_1509) $(am__append_1516) $(am__append_1523) \
+ $(am__append_1530) $(am__append_1537) cat.module$(EXEEXT) \
+ cmp.module$(EXEEXT) configfile.module$(EXEEXT) \
+ $(am__append_1544) $(am__append_1551) $(am__append_1558) \
+ $(am__append_1565) $(am__append_1572) $(am__append_1579) \
+ $(am__append_1586) $(am__append_1593) $(am__append_1600) \
+ $(am__append_1607) date.module$(EXEEXT) $(am__append_1614) \
+ echo.module$(EXEEXT) eval.module$(EXEEXT) $(am__append_1621) \
+ $(am__append_1628) $(am__append_1635) $(am__append_1642) \
+ $(am__append_1649) $(am__append_1656) $(am__append_1663) \
+ $(am__append_1670) $(am__append_1677) $(am__append_1684) \
+ $(am__append_1691) $(am__append_1698) $(am__append_1705) \
+ $(am__append_1712) gptsync.module$(EXEEXT) $(am__append_1719) \
+ $(am__append_1726) $(am__append_1733) $(am__append_1740) \
+ $(am__append_1747) $(am__append_1754) $(am__append_1761) \
+ $(am__append_1768) $(am__append_1775) $(am__append_1782) \
+ $(am__append_1789) $(am__append_1796) $(am__append_1803) \
+ $(am__append_1810) $(am__append_1817) $(am__append_1824) \
+ $(am__append_1831) $(am__append_1838) $(am__append_1845) \
+ $(am__append_1852) $(am__append_1859) $(am__append_1866) \
+ $(am__append_1873) $(am__append_1880) $(am__append_1887) \
+ $(am__append_1894) $(am__append_1901) $(am__append_1908) \
+ $(am__append_1915) $(am__append_1922) $(am__append_1929) \
+ $(am__append_1936) $(am__append_1943) $(am__append_1950) \
+ $(am__append_1957) $(am__append_1964) $(am__append_1971) \
+ $(am__append_1978) $(am__append_1985) $(am__append_1992) \
+ $(am__append_1999) $(am__append_2006) $(am__append_2013) \
+ $(am__append_2020) $(am__append_2027) $(am__append_2034) \
+ hashsum.module$(EXEEXT) pgp.module$(EXEEXT) $(am__append_2041) \
+ $(am__append_2048) $(am__append_2055) $(am__append_2062) \
+ $(am__append_2069) $(am__append_2076) $(am__append_2083) \
+ $(am__append_2090) $(am__append_2097) help.module$(EXEEXT) \
+ hexdump.module$(EXEEXT) keystatus.module$(EXEEXT) \
+ $(am__append_2104) $(am__append_2111) loadenv.module$(EXEEXT) \
+ ls.module$(EXEEXT) lsmmap.module$(EXEEXT) $(am__append_2118) \
+ $(am__append_2125) $(am__append_2132) $(am__append_2139) \
+ $(am__append_2146) $(am__append_2153) $(am__append_2160) \
+ $(am__append_2167) memrw.module$(EXEEXT) \
+ minicmd.module$(EXEEXT) parttool.module$(EXEEXT) \
+ password.module$(EXEEXT) password_pbkdf2.module$(EXEEXT) \
+ $(am__append_2174) $(am__append_2181) $(am__append_2188) \
+ $(am__append_2195) $(am__append_2202) $(am__append_2209) \
+ $(am__append_2216) $(am__append_2223) $(am__append_2230) \
+ $(am__append_2237) $(am__append_2244) $(am__append_2251) \
+ $(am__append_2258) $(am__append_2265) $(am__append_2272) \
+ $(am__append_2279) $(am__append_2286) $(am__append_2293) \
+ $(am__append_2300) $(am__append_2307) $(am__append_2314) \
+ probe.module$(EXEEXT) read.module$(EXEEXT) \
+ search.module$(EXEEXT) search_fs_file.module$(EXEEXT) \
+ search_fs_uuid.module$(EXEEXT) search_label.module$(EXEEXT) \
+ $(am__append_2321) $(am__append_2328) $(am__append_2335) \
+ $(am__append_2342) $(am__append_2349) $(am__append_2356) \
+ $(am__append_2363) $(am__append_2370) $(am__append_2377) \
+ $(am__append_2384) $(am__append_2391) $(am__append_2398) \
+ $(am__append_2405) $(am__append_2412) $(am__append_2419) \
+ $(am__append_2426) sleep.module$(EXEEXT) $(am__append_2433) \
+ $(am__append_2440) $(am__append_2447) $(am__append_2454) \
+ $(am__append_2461) $(am__append_2468) $(am__append_2475) \
+ $(am__append_2482) $(am__append_2489) $(am__append_2496) \
+ $(am__append_2503) $(am__append_2510) terminal.module$(EXEEXT) \
+ test.module$(EXEEXT) true.module$(EXEEXT) $(am__append_2517) \
+ $(am__append_2524) $(am__append_2531) $(am__append_2538) \
+ $(am__append_2545) $(am__append_2552) $(am__append_2559) \
+ $(am__append_2566) $(am__append_2573) \
+ videoinfo.module$(EXEEXT) videotest.module$(EXEEXT) \
+ xnu_uuid.module$(EXEEXT) dm_nv.module$(EXEEXT) \
+ loopback.module$(EXEEXT) cryptodisk.module$(EXEEXT) \
+ json.module$(EXEEXT) afsplitter.module$(EXEEXT) \
+ luks.module$(EXEEXT) luks2.module$(EXEEXT) \
+ geli.module$(EXEEXT) lvm.module$(EXEEXT) ldm.module$(EXEEXT) \
+ mdraid09.module$(EXEEXT) mdraid09_be.module$(EXEEXT) \
+ mdraid1x.module$(EXEEXT) diskfilter.module$(EXEEXT) \
+ raid5rec.module$(EXEEXT) raid6rec.module$(EXEEXT) \
+ scsi.module$(EXEEXT) memdisk.module$(EXEEXT) \
+ $(am__append_2580) $(am__append_2587) $(am__append_2594) \
+ $(am__append_2601) $(am__append_2608) $(am__append_2615) \
+ $(am__append_2622) $(am__append_2629) $(am__append_2636) \
+ $(am__append_2643) $(am__append_2650) $(am__append_2657) \
+ $(am__append_2664) $(am__append_2671) $(am__append_2678) \
+ $(am__append_2685) $(am__append_2692) $(am__append_2699) \
+ $(am__append_2706) $(am__append_2713) $(am__append_2720) \
+ $(am__append_2727) $(am__append_2734) $(am__append_2741) \
+ $(am__append_2748) $(am__append_2755) $(am__append_2762) \
+ $(am__append_2769) $(am__append_2776) $(am__append_2783) \
+ $(am__append_2790) $(am__append_2797) $(am__append_2804) \
+ $(am__append_2811) $(am__append_2818) $(am__append_2825) \
+ $(am__append_2832) $(am__append_2839) $(am__append_2846) \
+ $(am__append_2853) $(am__append_2860) $(am__append_2867) \
+ $(am__append_2874) $(am__append_2881) $(am__append_2888) \
+ $(am__append_2895) $(am__append_2902) $(am__append_2909) \
+ $(am__append_2916) $(am__append_2923) $(am__append_2930) \
+ $(am__append_2937) $(am__append_2944) $(am__append_2951) \
+ $(am__append_2958) $(am__append_2965) $(am__append_2972) \
+ $(am__append_2979) $(am__append_2986) $(am__append_2993) \
+ $(am__append_3000) procfs.module$(EXEEXT) affs.module$(EXEEXT) \
+ afs.module$(EXEEXT) bfs.module$(EXEEXT) zstd.module$(EXEEXT) \
+ btrfs.module$(EXEEXT) archelp.module$(EXEEXT) \
+ cbfs.module$(EXEEXT) cpio.module$(EXEEXT) \
+ cpio_be.module$(EXEEXT) newc.module$(EXEEXT) \
+ odc.module$(EXEEXT) ext2.module$(EXEEXT) fat.module$(EXEEXT) \
+ exfat.module$(EXEEXT) f2fs.module$(EXEEXT) \
+ fshelp.module$(EXEEXT) hfs.module$(EXEEXT) \
+ hfsplus.module$(EXEEXT) hfspluscomp.module$(EXEEXT) \
+ iso9660.module$(EXEEXT) jfs.module$(EXEEXT) \
+ minix.module$(EXEEXT) minix2.module$(EXEEXT) \
+ minix3.module$(EXEEXT) minix_be.module$(EXEEXT) \
+ minix2_be.module$(EXEEXT) minix3_be.module$(EXEEXT) \
+ nilfs2.module$(EXEEXT) ntfs.module$(EXEEXT) \
+ ntfscomp.module$(EXEEXT) reiserfs.module$(EXEEXT) \
+ romfs.module$(EXEEXT) sfs.module$(EXEEXT) \
+ squash4.module$(EXEEXT) tar.module$(EXEEXT) \
+ udf.module$(EXEEXT) ufs1.module$(EXEEXT) \
+ ufs1_be.module$(EXEEXT) ufs2.module$(EXEEXT) \
+ xfs.module$(EXEEXT) zfs.module$(EXEEXT) \
+ zfscrypt.module$(EXEEXT) zfsinfo.module$(EXEEXT) \
+ macbless.module$(EXEEXT) $(am__append_3007) \
+ gettext.module$(EXEEXT) gfxmenu.module$(EXEEXT) \
+ hello.module$(EXEEXT) gzio.module$(EXEEXT) \
+ offsetio.module$(EXEEXT) $(am__append_3014) $(am__append_3021) \
+ $(am__append_3028) $(am__append_3035) $(am__append_3042) \
+ $(am__append_3049) $(am__append_3056) $(am__append_3063) \
+ $(am__append_3070) $(am__append_3077) $(am__append_3084) \
+ $(am__append_3091) $(am__append_3098) $(am__append_3105) \
+ $(am__append_3112) $(am__append_3119) $(am__append_3126) \
+ $(am__append_3133) $(am__append_3140) $(am__append_3147) \
+ elf.module$(EXEEXT) crypto.module$(EXEEXT) \
+ pbkdf2.module$(EXEEXT) $(am__append_3154) $(am__append_3161) \
+ $(am__append_3168) $(am__append_3175) $(am__append_3182) \
+ $(am__append_3189) $(am__append_3196) $(am__append_3203) \
+ $(am__append_3210) $(am__append_3217) $(am__append_3224) \
+ $(am__append_3231) $(am__append_3238) $(am__append_3245) \
+ $(am__append_3252) $(am__append_3259) $(am__append_3266) \
+ $(am__append_3273) $(am__append_3280) $(am__append_3287) \
+ $(am__append_3294) $(am__append_3301) $(am__append_3308) \
+ $(am__append_3315) $(am__append_3322) $(am__append_3329) \
+ $(am__append_3336) $(am__append_3343) $(am__append_3350) \
+ $(am__append_3357) $(am__append_3364) $(am__append_3371) \
+ $(am__append_3378) $(am__append_3385) $(am__append_3392) \
+ $(am__append_3399) $(am__append_3406) setjmp.module$(EXEEXT) \
+ $(am__append_3413) $(am__append_3420) $(am__append_3427) \
+ $(am__append_3434) $(am__append_3441) $(am__append_3448) \
+ $(am__append_3455) $(am__append_3462) $(am__append_3469) \
+ $(am__append_3476) $(am__append_3483) $(am__append_3490) \
+ $(am__append_3497) $(am__append_3504) $(am__append_3511) \
+ $(am__append_3518) $(am__append_3525) $(am__append_3532) \
+ $(am__append_3539) $(am__append_3546) $(am__append_3553) \
+ $(am__append_3560) $(am__append_3567) $(am__append_3574) \
+ $(am__append_3581) $(am__append_3588) $(am__append_3595) \
+ $(am__append_3602) $(am__append_3609) $(am__append_3616) \
+ $(am__append_3623) $(am__append_3630) $(am__append_3637) \
+ $(am__append_3644) $(am__append_3651) $(am__append_3658) \
+ $(am__append_3665) $(am__append_3672) $(am__append_3679) \
+ $(am__append_3686) $(am__append_3693) $(am__append_3700) \
+ $(am__append_3707) $(am__append_3714) $(am__append_3721) \
+ $(am__append_3728) $(am__append_3735) $(am__append_3742) \
+ $(am__append_3749) $(am__append_3756) $(am__append_3763) \
+ $(am__append_3770) $(am__append_3777) $(am__append_3784) \
+ $(am__append_3791) $(am__append_3798) $(am__append_3805) \
+ $(am__append_3812) $(am__append_3819) $(am__append_3826) \
+ $(am__append_3833) $(am__append_3840) $(am__append_3847) \
+ $(am__append_3854) $(am__append_3861) $(am__append_3868) \
+ $(am__append_3875) $(am__append_3882) $(am__append_3889) \
+ $(am__append_3896) $(am__append_3903) $(am__append_3910) \
+ $(am__append_3917) $(am__append_3924) $(am__append_3931) \
+ $(am__append_3938) $(am__append_3945) $(am__append_3952) \
+ macho.module$(EXEEXT) $(am__append_3959) $(am__append_3966) \
+ $(am__append_3973) $(am__append_3980) $(am__append_3987) \
+ $(am__append_3994) $(am__append_4001) $(am__append_4008) \
+ $(am__append_4015) $(am__append_4022) $(am__append_4029) \
+ $(am__append_4036) $(am__append_4043) $(am__append_4050) \
+ $(am__append_4057) $(am__append_4064) $(am__append_4071) \
+ $(am__append_4078) $(am__append_4085) $(am__append_4092) \
+ $(am__append_4099) $(am__append_4106) $(am__append_4113) \
+ $(am__append_4120) $(am__append_4127) $(am__append_4134) \
+ $(am__append_4141) normal.module$(EXEEXT) \
+ part_acorn.module$(EXEEXT) part_amiga.module$(EXEEXT) \
+ part_apple.module$(EXEEXT) part_gpt.module$(EXEEXT) \
+ part_msdos.module$(EXEEXT) part_sun.module$(EXEEXT) \
+ part_plan.module$(EXEEXT) part_dvh.module$(EXEEXT) \
+ part_bsd.module$(EXEEXT) part_sunpc.module$(EXEEXT) \
+ part_dfly.module$(EXEEXT) msdospart.module$(EXEEXT) \
+ $(am__append_4148) $(am__append_4155) $(am__append_4162) \
+ $(am__append_4169) $(am__append_4176) $(am__append_4183) \
+ $(am__append_4190) $(am__append_4197) $(am__append_4204) \
+ $(am__append_4211) $(am__append_4218) $(am__append_4225) \
+ $(am__append_4232) $(am__append_4239) $(am__append_4246) \
+ $(am__append_4253) $(am__append_4260) $(am__append_4267) \
+ $(am__append_4274) $(am__append_4281) $(am__append_4288) \
+ $(am__append_4295) $(am__append_4302) $(am__append_4309) \
+ $(am__append_4316) $(am__append_4323) $(am__append_4330) \
+ gfxterm_background.module$(EXEEXT) $(am__append_4337) \
+ $(am__append_4344) $(am__append_4351) $(am__append_4358) \
+ $(am__append_4365) $(am__append_4372) $(am__append_4379) \
+ $(am__append_4386) $(am__append_4393) $(am__append_4400) \
+ $(am__append_4407) $(am__append_4414) $(am__append_4421) \
+ $(am__append_4428) $(am__append_4435) $(am__append_4442) \
+ $(am__append_4449) $(am__append_4456) $(am__append_4463) \
+ $(am__append_4470) $(am__append_4477) $(am__append_4484) \
+ $(am__append_4491) $(am__append_4498) $(am__append_4505) \
+ $(am__append_4512) $(am__append_4519) $(am__append_4526) \
+ $(am__append_4533) $(am__append_4540) $(am__append_4547) \
+ $(am__append_4554) $(am__append_4561) $(am__append_4568) \
+ $(am__append_4575) $(am__append_4582) $(am__append_4589) \
+ $(am__append_4596) $(am__append_4603) $(am__append_4610) \
+ $(am__append_4617) $(am__append_4624) $(am__append_4631) \
+ $(am__append_4638) $(am__append_4645) $(am__append_4652) \
+ $(am__append_4659) $(am__append_4666) $(am__append_4673) \
+ $(am__append_4680) $(am__append_4687) $(am__append_4694) \
+ $(am__append_4701) $(am__append_4708) $(am__append_4715) \
+ functional_test.module$(EXEEXT) exfctest.module$(EXEEXT) \
+ strtoull_test.module$(EXEEXT) setjmp_test.module$(EXEEXT) \
+ signature_test.module$(EXEEXT) sleep_test.module$(EXEEXT) \
+ xnu_uuid_test.module$(EXEEXT) pbkdf2_test.module$(EXEEXT) \
+ $(am__append_4722) $(am__append_4729) $(am__append_4736) \
+ $(am__append_4743) $(am__append_4750) $(am__append_4757) \
+ $(am__append_4764) $(am__append_4771) $(am__append_4778) \
+ $(am__append_4785) $(am__append_4792) $(am__append_4799) \
+ $(am__append_4806) $(am__append_4813) $(am__append_4820) \
+ $(am__append_4827) $(am__append_4834) $(am__append_4841) \
+ $(am__append_4848) $(am__append_4855) $(am__append_4862) \
+ $(am__append_4869) $(am__append_4876) $(am__append_4883) \
+ $(am__append_4890) div_test.module$(EXEEXT) \
+ mul_test.module$(EXEEXT) shift_test.module$(EXEEXT) \
+ cmp_test.module$(EXEEXT) ctz_test.module$(EXEEXT) \
+ bswap_test.module$(EXEEXT) videotest_checksum.module$(EXEEXT) \
+ gfxterm_menu.module$(EXEEXT) cmdline_cat_test.module$(EXEEXT) \
+ bitmap.module$(EXEEXT) bitmap_scale.module$(EXEEXT) \
+ $(am__append_4897) $(am__append_4904) $(am__append_4911) \
+ $(am__append_4918) $(am__append_4925) $(am__append_4932) \
+ $(am__append_4939) $(am__append_4946) $(am__append_4953) \
+ jpeg.module$(EXEEXT) png.module$(EXEEXT) tga.module$(EXEEXT) \
+ $(am__append_4960) $(am__append_4967) $(am__append_4974) \
+ $(am__append_4981) $(am__append_4988) $(am__append_4995) \
+ $(am__append_5002) $(am__append_5009) $(am__append_5016) \
+ $(am__append_5023) $(am__append_5030) $(am__append_5037) \
+ $(am__append_5044) $(am__append_5051) $(am__append_5058) \
+ $(am__append_5065) $(am__append_5072) $(am__append_5079) \
+ $(am__append_5086) $(am__append_5093) $(am__append_5100) \
+ $(am__append_5107) $(am__append_5114) $(am__append_5121) \
+ $(am__append_5128) $(am__append_5135) $(am__append_5142) \
+ $(am__append_5149) $(am__append_5156) $(am__append_5163) \
+ $(am__append_5170) $(am__append_5177) $(am__append_5184) \
+ $(am__append_5191) $(am__append_5198) $(am__append_5205) \
+ $(am__append_5212) $(am__append_5219) $(am__append_5226) \
+ $(am__append_5233) $(am__append_5240) \
+ video_colors.module$(EXEEXT) $(am__append_5247) \
+ $(am__append_5254) datehook.module$(EXEEXT) \
+ net.module$(EXEEXT) tftp.module$(EXEEXT) http.module$(EXEEXT) \
+ $(am__append_5261) $(am__append_5268) $(am__append_5275) \
+ $(am__append_5282) $(am__append_5289) $(am__append_5296) \
+ $(am__append_5303) $(am__append_5310) $(am__append_5317) \
+ $(am__append_5324) $(am__append_5331) $(am__append_5338) \
+ $(am__append_5345) $(am__append_5352) $(am__append_5359) \
+ $(am__append_5366) $(am__append_5373) $(am__append_5380) \
+ syslinuxcfg.module$(EXEEXT) test_blockarg.module$(EXEEXT) \
+ xzio.module$(EXEEXT) lzopio.module$(EXEEXT) \
+ testload.module$(EXEEXT) $(am__append_5387) $(am__append_5394) \
+ $(am__append_5401) $(am__append_5408) $(am__append_5415) \
+ $(am__append_5422) $(am__append_5429) $(am__append_5436) \
+ $(am__append_5443) $(am__append_5450) $(am__append_5457) \
+ $(am__append_5464) $(am__append_5471) $(am__append_5478) \
+ $(am__append_5485) $(am__append_5492) $(am__append_5499) \
+ priority_queue.module$(EXEEXT) time.module$(EXEEXT) \
+ $(am__append_5506) $(am__append_5513) adler32.module$(EXEEXT) \
+ crc64.module$(EXEEXT) mpi.module$(EXEEXT) \
+ all_video.module$(EXEEXT) $(am__append_5520) \
+ $(am__append_5527) $(am__append_5534) $(am__append_5541) \
+ $(am__append_5548) $(am__append_5555) \
+ testspeed.module$(EXEEXT) $(am__append_5562) \
+ $(am__append_5569) $(am__append_5576) $(am__append_5583) \
+ $(am__append_5590) $(am__append_5597) $(am__append_5604) \
+ tr.module$(EXEEXT) progress.module$(EXEEXT) \
+ file.module$(EXEEXT) $(am__append_5611) $(am__append_5618) \
+ $(am__append_5625) $(am__append_5632) $(am__append_5639) \
+ $(am__append_5646) $(am__append_5653) $(am__append_5660) \
+ $(am__append_5667) $(am__append_5674) $(am__append_5681) \
+ $(am__append_5688) $(am__append_5695) $(am__append_5702) \
+ gcry_arcfour.module$(EXEEXT) gcry_blowfish.module$(EXEEXT) \
+ gcry_camellia.module$(EXEEXT) gcry_cast5.module$(EXEEXT) \
+ gcry_crc.module$(EXEEXT) gcry_des.module$(EXEEXT) \
+ gcry_dsa.module$(EXEEXT) gcry_idea.module$(EXEEXT) \
+ gcry_md4.module$(EXEEXT) gcry_md5.module$(EXEEXT) \
+ gcry_rfc2268.module$(EXEEXT) gcry_rijndael.module$(EXEEXT) \
+ gcry_rmd160.module$(EXEEXT) gcry_rsa.module$(EXEEXT) \
+ gcry_seed.module$(EXEEXT) gcry_serpent.module$(EXEEXT) \
+ gcry_sha1.module$(EXEEXT) gcry_sha256.module$(EXEEXT) \
+ gcry_sha512.module$(EXEEXT) gcry_tiger.module$(EXEEXT) \
+ gcry_twofish.module$(EXEEXT) gcry_whirlpool.module$(EXEEXT)
+MARKER_FILES = disk.marker trig.marker $(am__append_9) \
+ $(am__append_16) $(am__append_23) $(am__append_30) \
+ $(am__append_37) $(am__append_44) $(am__append_51) \
+ $(am__append_58) $(am__append_65) $(am__append_72) \
+ $(am__append_79) $(am__append_86) $(am__append_93) \
+ $(am__append_100) $(am__append_107) $(am__append_114) \
+ $(am__append_121) $(am__append_128) $(am__append_135) \
+ $(am__append_142) $(am__append_149) $(am__append_156) \
+ $(am__append_163) $(am__append_170) $(am__append_177) \
+ $(am__append_184) $(am__append_191) $(am__append_198) \
+ $(am__append_205) $(am__append_212) $(am__append_219) \
+ $(am__append_226) $(am__append_233) $(am__append_240) \
+ $(am__append_247) $(am__append_254) $(am__append_261) \
+ $(am__append_268) $(am__append_275) $(am__append_282) \
+ $(am__append_289) $(am__append_296) $(am__append_303) \
+ $(am__append_310) $(am__append_317) $(am__append_324) \
+ $(am__append_331) $(am__append_338) $(am__append_345) \
+ $(am__append_352) $(am__append_359) $(am__append_366) \
+ $(am__append_373) $(am__append_380) $(am__append_387) \
+ $(am__append_394) $(am__append_401) $(am__append_408) \
+ $(am__append_415) $(am__append_422) $(am__append_429) \
+ $(am__append_436) $(am__append_443) $(am__append_450) \
+ $(am__append_457) $(am__append_464) $(am__append_471) \
+ $(am__append_478) $(am__append_485) $(am__append_492) \
+ $(am__append_499) $(am__append_506) $(am__append_513) \
+ $(am__append_520) $(am__append_527) $(am__append_534) \
+ $(am__append_541) $(am__append_548) $(am__append_555) \
+ $(am__append_562) $(am__append_569) $(am__append_576) \
+ $(am__append_583) $(am__append_590) $(am__append_597) \
+ $(am__append_604) $(am__append_611) $(am__append_618) \
+ $(am__append_625) $(am__append_632) $(am__append_639) \
+ $(am__append_646) $(am__append_653) $(am__append_660) \
+ $(am__append_667) $(am__append_674) $(am__append_681) \
+ $(am__append_688) $(am__append_695) $(am__append_702) \
+ $(am__append_709) $(am__append_716) $(am__append_723) \
+ $(am__append_730) $(am__append_737) $(am__append_744) \
+ $(am__append_751) $(am__append_758) $(am__append_765) \
+ $(am__append_772) $(am__append_779) $(am__append_786) \
+ $(am__append_793) $(am__append_800) $(am__append_807) \
+ $(am__append_814) $(am__append_821) $(am__append_828) \
+ $(am__append_835) $(am__append_842) $(am__append_849) \
+ $(am__append_856) $(am__append_863) $(am__append_870) \
+ $(am__append_877) $(am__append_884) $(am__append_891) \
+ $(am__append_898) $(am__append_905) $(am__append_912) \
+ $(am__append_919) $(am__append_926) $(am__append_933) \
+ $(am__append_940) $(am__append_947) $(am__append_954) \
+ $(am__append_961) $(am__append_968) $(am__append_975) \
+ $(am__append_982) $(am__append_989) $(am__append_996) \
+ $(am__append_1003) $(am__append_1010) $(am__append_1017) \
+ $(am__append_1024) $(am__append_1031) regexp.marker \
+ $(am__append_1038) $(am__append_1045) $(am__append_1052) \
+ $(am__append_1059) $(am__append_1066) $(am__append_1073) \
+ $(am__append_1080) $(am__append_1087) $(am__append_1094) \
+ $(am__append_1101) $(am__append_1108) $(am__append_1115) \
+ $(am__append_1122) $(am__append_1129) $(am__append_1136) \
+ $(am__append_1143) $(am__append_1150) $(am__append_1157) \
+ $(am__append_1164) $(am__append_1171) $(am__append_1178) \
+ $(am__append_1185) $(am__append_1192) $(am__append_1199) \
+ $(am__append_1206) $(am__append_1213) $(am__append_1220) \
+ $(am__append_1227) $(am__append_1234) $(am__append_1241) \
+ $(am__append_1248) $(am__append_1255) $(am__append_1262) \
+ $(am__append_1269) $(am__append_1276) $(am__append_1283) \
+ $(am__append_1290) $(am__append_1297) $(am__append_1304) \
+ $(am__append_1311) $(am__append_1318) $(am__append_1325) \
+ $(am__append_1332) $(am__append_1339) $(am__append_1346) \
+ $(am__append_1353) $(am__append_1360) $(am__append_1367) \
+ $(am__append_1374) $(am__append_1381) $(am__append_1388) \
+ $(am__append_1395) $(am__append_1402) $(am__append_1409) \
+ $(am__append_1416) blocklist.marker $(am__append_1423) \
+ $(am__append_1430) $(am__append_1437) $(am__append_1444) \
+ $(am__append_1451) $(am__append_1458) $(am__append_1465) \
+ $(am__append_1472) $(am__append_1479) $(am__append_1486) \
+ $(am__append_1493) $(am__append_1500) $(am__append_1507) \
+ $(am__append_1514) $(am__append_1521) $(am__append_1528) \
+ $(am__append_1535) $(am__append_1542) cat.marker cmp.marker \
+ configfile.marker $(am__append_1549) $(am__append_1556) \
+ $(am__append_1563) $(am__append_1570) $(am__append_1577) \
+ $(am__append_1584) $(am__append_1591) $(am__append_1598) \
+ $(am__append_1605) $(am__append_1612) date.marker \
+ $(am__append_1619) echo.marker eval.marker $(am__append_1626) \
+ $(am__append_1633) $(am__append_1640) $(am__append_1647) \
+ $(am__append_1654) $(am__append_1661) $(am__append_1668) \
+ $(am__append_1675) $(am__append_1682) $(am__append_1689) \
+ $(am__append_1696) $(am__append_1703) $(am__append_1710) \
+ $(am__append_1717) gptsync.marker $(am__append_1724) \
+ $(am__append_1731) $(am__append_1738) $(am__append_1745) \
+ $(am__append_1752) $(am__append_1759) $(am__append_1766) \
+ $(am__append_1773) $(am__append_1780) $(am__append_1787) \
+ $(am__append_1794) $(am__append_1801) $(am__append_1808) \
+ $(am__append_1815) $(am__append_1822) $(am__append_1829) \
+ $(am__append_1836) $(am__append_1843) $(am__append_1850) \
+ $(am__append_1857) $(am__append_1864) $(am__append_1871) \
+ $(am__append_1878) $(am__append_1885) $(am__append_1892) \
+ $(am__append_1899) $(am__append_1906) $(am__append_1913) \
+ $(am__append_1920) $(am__append_1927) $(am__append_1934) \
+ $(am__append_1941) $(am__append_1948) $(am__append_1955) \
+ $(am__append_1962) $(am__append_1969) $(am__append_1976) \
+ $(am__append_1983) $(am__append_1990) $(am__append_1997) \
+ $(am__append_2004) $(am__append_2011) $(am__append_2018) \
+ $(am__append_2025) $(am__append_2032) $(am__append_2039) \
+ hashsum.marker pgp.marker $(am__append_2046) \
+ $(am__append_2053) $(am__append_2060) $(am__append_2067) \
+ $(am__append_2074) $(am__append_2081) $(am__append_2088) \
+ $(am__append_2095) $(am__append_2102) help.marker \
+ hexdump.marker keystatus.marker $(am__append_2109) \
+ $(am__append_2116) loadenv.marker ls.marker lsmmap.marker \
+ $(am__append_2123) $(am__append_2130) $(am__append_2137) \
+ $(am__append_2144) $(am__append_2151) $(am__append_2158) \
+ $(am__append_2165) $(am__append_2172) memrw.marker \
+ minicmd.marker parttool.marker password.marker \
+ password_pbkdf2.marker $(am__append_2179) $(am__append_2186) \
+ $(am__append_2193) $(am__append_2200) $(am__append_2207) \
+ $(am__append_2214) $(am__append_2221) $(am__append_2228) \
+ $(am__append_2235) $(am__append_2242) $(am__append_2249) \
+ $(am__append_2256) $(am__append_2263) $(am__append_2270) \
+ $(am__append_2277) $(am__append_2284) $(am__append_2291) \
+ $(am__append_2298) $(am__append_2305) $(am__append_2312) \
+ $(am__append_2319) probe.marker read.marker search.marker \
+ search_fs_file.marker search_fs_uuid.marker \
+ search_label.marker $(am__append_2326) $(am__append_2333) \
+ $(am__append_2340) $(am__append_2347) $(am__append_2354) \
+ $(am__append_2361) $(am__append_2368) $(am__append_2375) \
+ $(am__append_2382) $(am__append_2389) $(am__append_2396) \
+ $(am__append_2403) $(am__append_2410) $(am__append_2417) \
+ $(am__append_2424) $(am__append_2431) sleep.marker \
+ $(am__append_2438) $(am__append_2445) $(am__append_2452) \
+ $(am__append_2459) $(am__append_2466) $(am__append_2473) \
+ $(am__append_2480) $(am__append_2487) $(am__append_2494) \
+ $(am__append_2501) $(am__append_2508) $(am__append_2515) \
+ terminal.marker test.marker true.marker $(am__append_2522) \
+ $(am__append_2529) $(am__append_2536) $(am__append_2543) \
+ $(am__append_2550) $(am__append_2557) $(am__append_2564) \
+ $(am__append_2571) $(am__append_2578) videoinfo.marker \
+ videotest.marker xnu_uuid.marker dm_nv.marker loopback.marker \
+ cryptodisk.marker json.marker afsplitter.marker luks.marker \
+ luks2.marker geli.marker lvm.marker ldm.marker mdraid09.marker \
+ mdraid09_be.marker mdraid1x.marker diskfilter.marker \
+ raid5rec.marker raid6rec.marker scsi.marker memdisk.marker \
+ $(am__append_2585) $(am__append_2592) $(am__append_2599) \
+ $(am__append_2606) $(am__append_2613) $(am__append_2620) \
+ $(am__append_2627) $(am__append_2634) $(am__append_2641) \
+ $(am__append_2648) $(am__append_2655) $(am__append_2662) \
+ $(am__append_2669) $(am__append_2676) $(am__append_2683) \
+ $(am__append_2690) $(am__append_2697) $(am__append_2704) \
+ $(am__append_2711) $(am__append_2718) $(am__append_2725) \
+ $(am__append_2732) $(am__append_2739) $(am__append_2746) \
+ $(am__append_2753) $(am__append_2760) $(am__append_2767) \
+ $(am__append_2774) $(am__append_2781) $(am__append_2788) \
+ $(am__append_2795) $(am__append_2802) $(am__append_2809) \
+ $(am__append_2816) $(am__append_2823) $(am__append_2830) \
+ $(am__append_2837) $(am__append_2844) $(am__append_2851) \
+ $(am__append_2858) $(am__append_2865) $(am__append_2872) \
+ $(am__append_2879) $(am__append_2886) $(am__append_2893) \
+ $(am__append_2900) $(am__append_2907) $(am__append_2914) \
+ $(am__append_2921) $(am__append_2928) $(am__append_2935) \
+ $(am__append_2942) $(am__append_2949) $(am__append_2956) \
+ $(am__append_2963) $(am__append_2970) $(am__append_2977) \
+ $(am__append_2984) $(am__append_2991) $(am__append_2998) \
+ $(am__append_3005) procfs.marker affs.marker afs.marker \
+ bfs.marker zstd.marker btrfs.marker archelp.marker cbfs.marker \
+ cpio.marker cpio_be.marker newc.marker odc.marker ext2.marker \
+ fat.marker exfat.marker f2fs.marker fshelp.marker hfs.marker \
+ hfsplus.marker hfspluscomp.marker iso9660.marker jfs.marker \
+ minix.marker minix2.marker minix3.marker minix_be.marker \
+ minix2_be.marker minix3_be.marker nilfs2.marker ntfs.marker \
+ ntfscomp.marker reiserfs.marker romfs.marker sfs.marker \
+ squash4.marker tar.marker udf.marker ufs1.marker \
+ ufs1_be.marker ufs2.marker xfs.marker zfs.marker \
+ zfscrypt.marker zfsinfo.marker macbless.marker \
+ $(am__append_3012) gettext.marker gfxmenu.marker hello.marker \
+ gzio.marker offsetio.marker $(am__append_3019) \
+ $(am__append_3026) $(am__append_3033) $(am__append_3040) \
+ $(am__append_3047) $(am__append_3054) $(am__append_3061) \
+ $(am__append_3068) $(am__append_3075) $(am__append_3082) \
+ $(am__append_3089) $(am__append_3096) $(am__append_3103) \
+ $(am__append_3110) $(am__append_3117) $(am__append_3124) \
+ $(am__append_3131) $(am__append_3138) $(am__append_3145) \
+ $(am__append_3152) elf.marker crypto.marker pbkdf2.marker \
+ $(am__append_3159) $(am__append_3166) $(am__append_3173) \
+ $(am__append_3180) $(am__append_3187) $(am__append_3194) \
+ $(am__append_3201) $(am__append_3208) $(am__append_3215) \
+ $(am__append_3222) $(am__append_3229) $(am__append_3236) \
+ $(am__append_3243) $(am__append_3250) $(am__append_3257) \
+ $(am__append_3264) $(am__append_3271) $(am__append_3278) \
+ $(am__append_3285) $(am__append_3292) $(am__append_3299) \
+ $(am__append_3306) $(am__append_3313) $(am__append_3320) \
+ $(am__append_3327) $(am__append_3334) $(am__append_3341) \
+ $(am__append_3348) $(am__append_3355) $(am__append_3362) \
+ $(am__append_3369) $(am__append_3376) $(am__append_3383) \
+ $(am__append_3390) $(am__append_3397) $(am__append_3404) \
+ $(am__append_3411) setjmp.marker $(am__append_3418) \
+ $(am__append_3425) $(am__append_3432) $(am__append_3439) \
+ $(am__append_3446) $(am__append_3453) $(am__append_3460) \
+ $(am__append_3467) $(am__append_3474) $(am__append_3481) \
+ $(am__append_3488) $(am__append_3495) $(am__append_3502) \
+ $(am__append_3509) $(am__append_3516) $(am__append_3523) \
+ $(am__append_3530) $(am__append_3537) $(am__append_3544) \
+ $(am__append_3551) $(am__append_3558) $(am__append_3565) \
+ $(am__append_3572) $(am__append_3579) $(am__append_3586) \
+ $(am__append_3593) $(am__append_3600) $(am__append_3607) \
+ $(am__append_3614) $(am__append_3621) $(am__append_3628) \
+ $(am__append_3635) $(am__append_3642) $(am__append_3649) \
+ $(am__append_3656) $(am__append_3663) $(am__append_3670) \
+ $(am__append_3677) $(am__append_3684) $(am__append_3691) \
+ $(am__append_3698) $(am__append_3705) $(am__append_3712) \
+ $(am__append_3719) $(am__append_3726) $(am__append_3733) \
+ $(am__append_3740) $(am__append_3747) $(am__append_3754) \
+ $(am__append_3761) $(am__append_3768) $(am__append_3775) \
+ $(am__append_3782) $(am__append_3789) $(am__append_3796) \
+ $(am__append_3803) $(am__append_3810) $(am__append_3817) \
+ $(am__append_3824) $(am__append_3831) $(am__append_3838) \
+ $(am__append_3845) $(am__append_3852) $(am__append_3859) \
+ $(am__append_3866) $(am__append_3873) $(am__append_3880) \
+ $(am__append_3887) $(am__append_3894) $(am__append_3901) \
+ $(am__append_3908) $(am__append_3915) $(am__append_3922) \
+ $(am__append_3929) $(am__append_3936) $(am__append_3943) \
+ $(am__append_3950) $(am__append_3957) macho.marker \
+ $(am__append_3964) $(am__append_3971) $(am__append_3978) \
+ $(am__append_3985) $(am__append_3992) $(am__append_3999) \
+ $(am__append_4006) $(am__append_4013) $(am__append_4020) \
+ $(am__append_4027) $(am__append_4034) $(am__append_4041) \
+ $(am__append_4048) $(am__append_4055) $(am__append_4062) \
+ $(am__append_4069) $(am__append_4076) $(am__append_4083) \
+ $(am__append_4090) $(am__append_4097) $(am__append_4104) \
+ $(am__append_4111) $(am__append_4118) $(am__append_4125) \
+ $(am__append_4132) $(am__append_4139) $(am__append_4146) \
+ normal.marker part_acorn.marker part_amiga.marker \
+ part_apple.marker part_gpt.marker part_msdos.marker \
+ part_sun.marker part_plan.marker part_dvh.marker \
+ part_bsd.marker part_sunpc.marker part_dfly.marker \
+ msdospart.marker $(am__append_4153) $(am__append_4160) \
+ $(am__append_4167) $(am__append_4174) $(am__append_4181) \
+ $(am__append_4188) $(am__append_4195) $(am__append_4202) \
+ $(am__append_4209) $(am__append_4216) $(am__append_4223) \
+ $(am__append_4230) $(am__append_4237) $(am__append_4244) \
+ $(am__append_4251) $(am__append_4258) $(am__append_4265) \
+ $(am__append_4272) $(am__append_4279) $(am__append_4286) \
+ $(am__append_4293) $(am__append_4300) $(am__append_4307) \
+ $(am__append_4314) $(am__append_4321) $(am__append_4328) \
+ $(am__append_4335) gfxterm_background.marker \
+ $(am__append_4342) $(am__append_4349) $(am__append_4356) \
+ $(am__append_4363) $(am__append_4370) $(am__append_4377) \
+ $(am__append_4384) $(am__append_4391) $(am__append_4398) \
+ $(am__append_4405) $(am__append_4412) $(am__append_4419) \
+ $(am__append_4426) $(am__append_4433) $(am__append_4440) \
+ $(am__append_4447) $(am__append_4454) $(am__append_4461) \
+ $(am__append_4468) $(am__append_4475) $(am__append_4482) \
+ $(am__append_4489) $(am__append_4496) $(am__append_4503) \
+ $(am__append_4510) $(am__append_4517) $(am__append_4524) \
+ $(am__append_4531) $(am__append_4538) $(am__append_4545) \
+ $(am__append_4552) $(am__append_4559) $(am__append_4566) \
+ $(am__append_4573) $(am__append_4580) $(am__append_4587) \
+ $(am__append_4594) $(am__append_4601) $(am__append_4608) \
+ $(am__append_4615) $(am__append_4622) $(am__append_4629) \
+ $(am__append_4636) $(am__append_4643) $(am__append_4650) \
+ $(am__append_4657) $(am__append_4664) $(am__append_4671) \
+ $(am__append_4678) $(am__append_4685) $(am__append_4692) \
+ $(am__append_4699) $(am__append_4706) $(am__append_4713) \
+ $(am__append_4720) functional_test.marker exfctest.marker \
+ strtoull_test.marker setjmp_test.marker signature_test.marker \
+ sleep_test.marker xnu_uuid_test.marker pbkdf2_test.marker \
+ $(am__append_4727) $(am__append_4734) $(am__append_4741) \
+ $(am__append_4748) $(am__append_4755) $(am__append_4762) \
+ $(am__append_4769) $(am__append_4776) $(am__append_4783) \
+ $(am__append_4790) $(am__append_4797) $(am__append_4804) \
+ $(am__append_4811) $(am__append_4818) $(am__append_4825) \
+ $(am__append_4832) $(am__append_4839) $(am__append_4846) \
+ $(am__append_4853) $(am__append_4860) $(am__append_4867) \
+ $(am__append_4874) $(am__append_4881) $(am__append_4888) \
+ $(am__append_4895) div_test.marker mul_test.marker \
+ shift_test.marker cmp_test.marker ctz_test.marker \
+ bswap_test.marker videotest_checksum.marker \
+ gfxterm_menu.marker cmdline_cat_test.marker bitmap.marker \
+ bitmap_scale.marker $(am__append_4902) $(am__append_4909) \
+ $(am__append_4916) $(am__append_4923) $(am__append_4930) \
+ $(am__append_4937) $(am__append_4944) $(am__append_4951) \
+ $(am__append_4958) jpeg.marker png.marker tga.marker \
+ $(am__append_4965) $(am__append_4972) $(am__append_4979) \
+ $(am__append_4986) $(am__append_4993) $(am__append_5000) \
+ $(am__append_5007) $(am__append_5014) $(am__append_5021) \
+ $(am__append_5028) $(am__append_5035) $(am__append_5042) \
+ $(am__append_5049) $(am__append_5056) $(am__append_5063) \
+ $(am__append_5070) $(am__append_5077) $(am__append_5084) \
+ $(am__append_5091) $(am__append_5098) $(am__append_5105) \
+ $(am__append_5112) $(am__append_5119) $(am__append_5126) \
+ $(am__append_5133) $(am__append_5140) $(am__append_5147) \
+ $(am__append_5154) $(am__append_5161) $(am__append_5168) \
+ $(am__append_5175) $(am__append_5182) $(am__append_5189) \
+ $(am__append_5196) $(am__append_5203) $(am__append_5210) \
+ $(am__append_5217) $(am__append_5224) $(am__append_5231) \
+ $(am__append_5238) $(am__append_5245) video_colors.marker \
+ $(am__append_5252) $(am__append_5259) datehook.marker \
+ net.marker tftp.marker http.marker $(am__append_5266) \
+ $(am__append_5273) $(am__append_5280) $(am__append_5287) \
+ $(am__append_5294) $(am__append_5301) $(am__append_5308) \
+ $(am__append_5315) $(am__append_5322) $(am__append_5329) \
+ $(am__append_5336) $(am__append_5343) $(am__append_5350) \
+ $(am__append_5357) $(am__append_5364) $(am__append_5371) \
+ $(am__append_5378) $(am__append_5385) syslinuxcfg.marker \
+ test_blockarg.marker xzio.marker lzopio.marker testload.marker \
+ $(am__append_5392) $(am__append_5399) $(am__append_5406) \
+ $(am__append_5413) $(am__append_5420) $(am__append_5427) \
+ $(am__append_5434) $(am__append_5441) $(am__append_5448) \
+ $(am__append_5455) $(am__append_5462) $(am__append_5469) \
+ $(am__append_5476) $(am__append_5483) $(am__append_5490) \
+ $(am__append_5497) $(am__append_5504) priority_queue.marker \
+ time.marker $(am__append_5511) $(am__append_5518) \
+ adler32.marker crc64.marker mpi.marker all_video.marker \
+ $(am__append_5525) $(am__append_5532) $(am__append_5539) \
+ $(am__append_5546) $(am__append_5553) $(am__append_5560) \
+ testspeed.marker $(am__append_5567) $(am__append_5574) \
+ $(am__append_5581) $(am__append_5588) $(am__append_5595) \
+ $(am__append_5602) $(am__append_5609) tr.marker \
+ progress.marker file.marker $(am__append_5616) \
+ $(am__append_5623) $(am__append_5630) $(am__append_5637) \
+ $(am__append_5644) $(am__append_5651) $(am__append_5658) \
+ $(am__append_5665) $(am__append_5672) $(am__append_5679) \
+ $(am__append_5686) $(am__append_5693) $(am__append_5700) \
+ $(am__append_5707) gcry_arcfour.marker gcry_blowfish.marker \
+ gcry_camellia.marker gcry_cast5.marker gcry_crc.marker \
+ gcry_des.marker gcry_dsa.marker gcry_idea.marker \
+ gcry_md4.marker gcry_md5.marker gcry_rfc2268.marker \
+ gcry_rijndael.marker gcry_rmd160.marker gcry_rsa.marker \
+ gcry_seed.marker gcry_serpent.marker gcry_sha1.marker \
+ gcry_sha256.marker gcry_sha512.marker gcry_tiger.marker \
+ gcry_twofish.marker gcry_whirlpool.marker
+KERNEL_HEADER_FILES = $(top_srcdir)/include/grub/cache.h \
+ $(top_srcdir)/include/grub/command.h \
+ $(top_srcdir)/include/grub/device.h \
+ $(top_srcdir)/include/grub/disk.h \
+ $(top_srcdir)/include/grub/dl.h \
+ $(top_srcdir)/include/grub/efi/sb.h \
+ $(top_srcdir)/include/grub/env.h \
+ $(top_srcdir)/include/grub/env_private.h \
+ $(top_srcdir)/include/grub/err.h \
+ $(top_srcdir)/include/grub/file.h \
+ $(top_srcdir)/include/grub/fs.h \
+ $(top_srcdir)/include/grub/i18n.h \
+ $(top_srcdir)/include/grub/kernel.h \
+ $(top_srcdir)/include/grub/list.h \
+ $(top_srcdir)/include/grub/lockdown.h \
+ $(top_srcdir)/include/grub/misc.h $(am__append_5913) \
+ $(am__append_5914) $(top_srcdir)/include/grub/mm.h \
+ $(top_srcdir)/include/grub/parser.h \
+ $(top_srcdir)/include/grub/partition.h \
+ $(top_srcdir)/include/grub/stack_protector.h \
+ $(top_srcdir)/include/grub/term.h \
+ $(top_srcdir)/include/grub/time.h \
+ $(top_srcdir)/include/grub/verify.h \
+ $(top_srcdir)/include/grub/mm_private.h \
+ $(top_srcdir)/include/grub/net.h \
+ $(top_srcdir)/include/grub/memory.h $(am__append_5915) \
+ $(am__append_5916) $(am__append_5917) $(am__append_5918) \
+ $(am__append_5919) $(am__append_5920) $(am__append_5921) \
+ $(am__append_5922) $(am__append_5923) $(am__append_5924) \
+ $(am__append_5925) $(am__append_5926) $(am__append_5927) \
+ $(am__append_5928) $(am__append_5929) $(am__append_5930) \
+ $(am__append_5931) $(am__append_5932) $(am__append_5933) \
+ $(am__append_5934) $(am__append_5935) $(am__append_5936) \
+ $(am__append_5937) $(am__append_5938) $(am__append_5939) \
+ $(am__append_5940) $(am__append_5941)
+man_MANS = $(am__append_5904)
+noinst_DATA = gensyminfo.sh genmod.sh modinfo.sh kernel_syms.lst
+pkgdata_DATA =
+bin_SCRIPTS =
+sbin_SCRIPTS =
+platform_DATA = $(am__append_5712) $(am__append_5717) \
+ $(am__append_5722) $(am__append_5727) $(am__append_5732) \
+ $(am__append_5737) $(am__append_5742) $(am__append_5747) \
+ $(am__append_5752) $(am__append_5757) $(am__append_5762) \
+ $(am__append_5767) $(am__append_5772) $(am__append_5777) \
+ $(am__append_5782) $(am__append_5787) $(am__append_5792) \
+ $(am__append_5797) $(am__append_5802) $(am__append_5807) \
+ $(am__append_5812) $(am__append_5817) $(am__append_5822) \
+ $(am__append_5827) $(am__append_5832) $(am__append_5837) \
+ $(am__append_5842) $(am__append_5847) $(am__append_5852) \
+ $(am__append_5857) $(am__append_5862) $(am__append_5867) \
+ $(am__append_5872) $(am__append_5877) $(am__append_5882) \
+ $(am__append_5887) $(am__append_5892) $(am__append_5897) \
+ $(am__append_5902) gmodule.pl gdb_grub $(am__append_5909) \
+ fs.lst command.lst partmap.lst terminal.lst fdt.lst \
+ parttool.lst video.lst crypto.lst moddep.lst $(MOD_FILES) \
+ modinfo.sh $(am__append_5943)
+check_SCRIPTS =
+dist_grubconf_DATA =
+noinst_SCRIPTS =
+grubconf_SCRIPTS =
+noinst_LIBRARIES =
+dist_noinst_DATA = kern/disk_common.c gentrigtables.c $(am__append_5) \
+ $(am__append_12) $(am__append_19) $(am__append_26) \
+ $(am__append_33) $(am__append_40) $(am__append_47) \
+ $(am__append_54) $(am__append_61) $(am__append_68) \
+ $(am__append_75) $(am__append_82) $(am__append_89) \
+ $(am__append_96) $(am__append_103) $(am__append_110) \
+ $(am__append_117) $(am__append_124) $(am__append_131) \
+ $(am__append_138) $(am__append_145) $(am__append_152) \
+ $(am__append_159) $(am__append_166) $(am__append_173) \
+ $(am__append_180) $(am__append_187) $(am__append_194) \
+ $(am__append_201) $(am__append_208) $(am__append_215) \
+ $(am__append_222) $(am__append_229) $(am__append_236) \
+ $(am__append_243) $(am__append_250) $(am__append_257) \
+ $(am__append_264) $(am__append_271) $(am__append_278) \
+ $(am__append_285) $(am__append_292) $(am__append_299) \
+ $(am__append_306) $(am__append_313) $(am__append_320) \
+ $(am__append_327) $(am__append_334) $(am__append_341) \
+ $(am__append_348) $(am__append_355) $(am__append_362) \
+ $(am__append_369) $(am__append_376) $(am__append_383) \
+ $(am__append_390) $(am__append_397) $(am__append_404) \
+ $(am__append_411) $(am__append_418) $(am__append_425) \
+ $(am__append_432) $(am__append_439) $(am__append_446) \
+ $(am__append_453) $(am__append_460) $(am__append_467) \
+ $(am__append_474) $(am__append_481) $(am__append_488) \
+ $(am__append_495) $(am__append_502) $(am__append_509) \
+ $(am__append_516) $(am__append_523) $(am__append_530) \
+ $(am__append_537) $(am__append_544) $(am__append_551) \
+ $(am__append_558) $(am__append_565) $(am__append_572) \
+ $(am__append_579) $(am__append_586) $(am__append_593) \
+ $(am__append_600) $(am__append_607) $(am__append_614) \
+ $(am__append_621) $(am__append_628) $(am__append_635) \
+ $(am__append_642) $(am__append_649) $(am__append_656) \
+ $(am__append_663) $(am__append_670) $(am__append_677) \
+ $(am__append_684) $(am__append_691) $(am__append_698) \
+ $(am__append_705) $(am__append_712) $(am__append_719) \
+ $(am__append_726) $(am__append_733) $(am__append_740) \
+ $(am__append_747) $(am__append_754) $(am__append_761) \
+ $(am__append_768) $(am__append_775) $(am__append_782) \
+ $(am__append_789) $(am__append_796) $(am__append_803) \
+ $(am__append_810) $(am__append_817) $(am__append_824) \
+ $(am__append_831) $(am__append_838) $(am__append_845) \
+ $(am__append_852) $(am__append_859) $(am__append_866) \
+ $(am__append_873) $(am__append_880) $(am__append_887) \
+ $(am__append_894) $(am__append_901) $(am__append_908) \
+ $(am__append_915) $(am__append_922) $(am__append_929) \
+ $(am__append_936) $(am__append_943) $(am__append_950) \
+ $(am__append_957) $(am__append_964) $(am__append_971) \
+ $(am__append_978) $(am__append_985) $(am__append_992) \
+ $(am__append_999) $(am__append_1006) $(am__append_1013) \
+ $(am__append_1020) $(am__append_1027) $(am__append_1034) \
+ $(am__append_1041) $(am__append_1048) $(am__append_1055) \
+ $(am__append_1062) $(am__append_1069) $(am__append_1076) \
+ $(am__append_1083) $(am__append_1090) $(am__append_1097) \
+ $(am__append_1104) $(am__append_1111) $(am__append_1118) \
+ $(am__append_1125) $(am__append_1132) $(am__append_1139) \
+ $(am__append_1146) $(am__append_1153) $(am__append_1160) \
+ $(am__append_1167) $(am__append_1174) $(am__append_1181) \
+ $(am__append_1188) $(am__append_1195) $(am__append_1202) \
+ $(am__append_1209) $(am__append_1216) $(am__append_1223) \
+ $(am__append_1230) $(am__append_1237) $(am__append_1244) \
+ $(am__append_1251) $(am__append_1258) $(am__append_1265) \
+ $(am__append_1272) $(am__append_1279) $(am__append_1286) \
+ $(am__append_1293) $(am__append_1300) $(am__append_1307) \
+ $(am__append_1314) $(am__append_1321) $(am__append_1328) \
+ $(am__append_1335) $(am__append_1342) $(am__append_1349) \
+ $(am__append_1356) $(am__append_1363) $(am__append_1370) \
+ $(am__append_1377) $(am__append_1384) $(am__append_1391) \
+ $(am__append_1398) $(am__append_1405) $(am__append_1412) \
+ $(am__append_1419) $(am__append_1426) $(am__append_1433) \
+ $(am__append_1440) $(am__append_1447) $(am__append_1454) \
+ $(am__append_1461) $(am__append_1468) $(am__append_1475) \
+ $(am__append_1482) $(am__append_1489) $(am__append_1496) \
+ $(am__append_1503) $(am__append_1510) $(am__append_1517) \
+ $(am__append_1524) $(am__append_1531) $(am__append_1538) \
+ $(am__append_1545) $(am__append_1552) $(am__append_1559) \
+ $(am__append_1566) $(am__append_1573) $(am__append_1580) \
+ $(am__append_1587) $(am__append_1594) $(am__append_1601) \
+ $(am__append_1608) $(am__append_1615) $(am__append_1622) \
+ $(am__append_1629) $(am__append_1636) $(am__append_1643) \
+ $(am__append_1650) $(am__append_1657) $(am__append_1664) \
+ $(am__append_1671) $(am__append_1678) $(am__append_1685) \
+ $(am__append_1692) $(am__append_1699) $(am__append_1706) \
+ $(am__append_1713) $(am__append_1720) $(am__append_1727) \
+ $(am__append_1734) $(am__append_1741) $(am__append_1748) \
+ $(am__append_1755) $(am__append_1762) $(am__append_1769) \
+ $(am__append_1776) $(am__append_1783) $(am__append_1790) \
+ $(am__append_1797) $(am__append_1804) $(am__append_1811) \
+ $(am__append_1818) $(am__append_1825) $(am__append_1832) \
+ $(am__append_1839) $(am__append_1846) $(am__append_1853) \
+ $(am__append_1860) $(am__append_1867) $(am__append_1874) \
+ $(am__append_1881) $(am__append_1888) $(am__append_1895) \
+ $(am__append_1902) $(am__append_1909) $(am__append_1916) \
+ $(am__append_1923) $(am__append_1930) $(am__append_1937) \
+ $(am__append_1944) $(am__append_1951) $(am__append_1958) \
+ $(am__append_1965) $(am__append_1972) $(am__append_1979) \
+ $(am__append_1986) $(am__append_1993) $(am__append_2000) \
+ $(am__append_2007) $(am__append_2014) $(am__append_2021) \
+ $(am__append_2028) $(am__append_2035) $(am__append_2042) \
+ $(am__append_2049) $(am__append_2056) $(am__append_2063) \
+ $(am__append_2070) $(am__append_2077) $(am__append_2084) \
+ $(am__append_2091) $(am__append_2098) $(am__append_2105) \
+ $(am__append_2112) $(am__append_2119) $(am__append_2126) \
+ $(am__append_2133) $(am__append_2140) $(am__append_2147) \
+ $(am__append_2154) $(am__append_2161) $(am__append_2168) \
+ $(am__append_2175) $(am__append_2182) $(am__append_2189) \
+ $(am__append_2196) $(am__append_2203) $(am__append_2210) \
+ $(am__append_2217) $(am__append_2224) $(am__append_2231) \
+ $(am__append_2238) $(am__append_2245) $(am__append_2252) \
+ $(am__append_2259) $(am__append_2266) $(am__append_2273) \
+ $(am__append_2280) $(am__append_2287) $(am__append_2294) \
+ $(am__append_2301) $(am__append_2308) $(am__append_2315) \
+ commands/search.c $(am__append_2322) $(am__append_2329) \
+ $(am__append_2336) $(am__append_2343) $(am__append_2350) \
+ $(am__append_2357) $(am__append_2364) $(am__append_2371) \
+ $(am__append_2378) $(am__append_2385) $(am__append_2392) \
+ $(am__append_2399) $(am__append_2406) $(am__append_2413) \
+ $(am__append_2420) $(am__append_2427) $(am__append_2434) \
+ $(am__append_2441) $(am__append_2448) $(am__append_2455) \
+ $(am__append_2462) $(am__append_2469) $(am__append_2476) \
+ $(am__append_2483) $(am__append_2490) $(am__append_2497) \
+ $(am__append_2504) $(am__append_2511) $(am__append_2518) \
+ $(am__append_2525) $(am__append_2532) $(am__append_2539) \
+ $(am__append_2546) $(am__append_2553) $(am__append_2560) \
+ $(am__append_2567) $(am__append_2574) $(am__append_2581) \
+ $(am__append_2588) $(am__append_2595) $(am__append_2602) \
+ $(am__append_2609) $(am__append_2616) $(am__append_2623) \
+ $(am__append_2630) $(am__append_2637) $(am__append_2644) \
+ $(am__append_2651) $(am__append_2658) $(am__append_2665) \
+ $(am__append_2672) $(am__append_2679) $(am__append_2686) \
+ $(am__append_2693) $(am__append_2700) $(am__append_2707) \
+ $(am__append_2714) $(am__append_2721) $(am__append_2728) \
+ $(am__append_2735) $(am__append_2742) $(am__append_2749) \
+ $(am__append_2756) $(am__append_2763) $(am__append_2770) \
+ $(am__append_2777) $(am__append_2784) $(am__append_2791) \
+ $(am__append_2798) $(am__append_2805) $(am__append_2812) \
+ $(am__append_2819) $(am__append_2826) $(am__append_2833) \
+ $(am__append_2840) $(am__append_2847) $(am__append_2854) \
+ $(am__append_2861) $(am__append_2868) $(am__append_2875) \
+ $(am__append_2882) $(am__append_2889) $(am__append_2896) \
+ $(am__append_2903) $(am__append_2910) $(am__append_2917) \
+ $(am__append_2924) $(am__append_2931) $(am__append_2938) \
+ $(am__append_2945) $(am__append_2952) $(am__append_2959) \
+ $(am__append_2966) $(am__append_2973) $(am__append_2980) \
+ $(am__append_2987) $(am__append_2994) $(am__append_3001) \
+ $(am__append_3008) $(am__append_3015) $(am__append_3022) \
+ $(am__append_3029) $(am__append_3036) $(am__append_3043) \
+ $(am__append_3050) $(am__append_3057) $(am__append_3064) \
+ $(am__append_3071) $(am__append_3078) $(am__append_3085) \
+ $(am__append_3092) $(am__append_3099) $(am__append_3106) \
+ $(am__append_3113) $(am__append_3120) $(am__append_3127) \
+ $(am__append_3134) $(am__append_3141) $(am__append_3148) \
+ kern/elfXX.c lib/libgcrypt-grub/cipher/crypto.lst \
+ $(am__append_3155) $(am__append_3162) $(am__append_3169) \
+ $(am__append_3176) $(am__append_3183) $(am__append_3190) \
+ $(am__append_3197) $(am__append_3204) $(am__append_3211) \
+ $(am__append_3218) $(am__append_3225) $(am__append_3232) \
+ $(am__append_3239) $(am__append_3246) $(am__append_3253) \
+ $(am__append_3260) $(am__append_3267) $(am__append_3274) \
+ $(am__append_3281) $(am__append_3288) $(am__append_3295) \
+ $(am__append_3302) $(am__append_3309) $(am__append_3316) \
+ $(am__append_3323) $(am__append_3330) $(am__append_3337) \
+ $(am__append_3344) $(am__append_3351) $(am__append_3358) \
+ $(am__append_3365) $(am__append_3372) $(am__append_3379) \
+ $(am__append_3386) $(am__append_3393) $(am__append_3400) \
+ $(am__append_3407) lib/i386/setjmp.S lib/mips/setjmp.S \
+ lib/x86_64/setjmp.S lib/sparc64/setjmp.S lib/powerpc/setjmp.S \
+ lib/ia64/setjmp.S lib/ia64/longjmp.S lib/arm/setjmp.S \
+ lib/arm64/setjmp.S lib/riscv/setjmp.S $(am__append_3414) \
+ $(am__append_3421) $(am__append_3428) $(am__append_3435) \
+ $(am__append_3442) $(am__append_3449) $(am__append_3456) \
+ $(am__append_3463) $(am__append_3470) $(am__append_3477) \
+ $(am__append_3484) $(am__append_3491) $(am__append_3498) \
+ $(am__append_3505) $(am__append_3512) $(am__append_3519) \
+ $(am__append_3526) $(am__append_3533) $(am__append_3540) \
+ $(am__append_3547) $(am__append_3554) $(am__append_3561) \
+ $(am__append_3568) $(am__append_3575) $(am__append_3582) \
+ $(am__append_3589) $(am__append_3596) $(am__append_3603) \
+ $(am__append_3610) $(am__append_3617) $(am__append_3624) \
+ $(am__append_3631) $(am__append_3638) $(am__append_3645) \
+ $(am__append_3652) $(am__append_3659) $(am__append_3666) \
+ $(am__append_3673) $(am__append_3680) $(am__append_3687) \
+ $(am__append_3694) $(am__append_3701) $(am__append_3708) \
+ $(am__append_3715) $(am__append_3722) $(am__append_3729) \
+ $(am__append_3736) $(am__append_3743) $(am__append_3750) \
+ $(am__append_3757) $(am__append_3764) $(am__append_3771) \
+ $(am__append_3778) $(am__append_3785) $(am__append_3792) \
+ $(am__append_3799) $(am__append_3806) $(am__append_3813) \
+ $(am__append_3820) $(am__append_3827) $(am__append_3834) \
+ $(am__append_3841) $(am__append_3848) $(am__append_3855) \
+ $(am__append_3862) $(am__append_3869) $(am__append_3876) \
+ $(am__append_3883) $(am__append_3890) $(am__append_3897) \
+ $(am__append_3904) $(am__append_3911) $(am__append_3918) \
+ $(am__append_3925) $(am__append_3932) $(am__append_3939) \
+ $(am__append_3946) $(am__append_3953) loader/machoXX.c \
+ $(am__append_3960) $(am__append_3967) $(am__append_3974) \
+ $(am__append_3981) $(am__append_3988) $(am__append_3995) \
+ $(am__append_4002) $(am__append_4009) $(am__append_4016) \
+ $(am__append_4023) $(am__append_4030) $(am__append_4037) \
+ $(am__append_4044) $(am__append_4051) $(am__append_4058) \
+ $(am__append_4065) $(am__append_4072) $(am__append_4079) \
+ $(am__append_4086) $(am__append_4093) $(am__append_4100) \
+ $(am__append_4107) $(am__append_4114) $(am__append_4121) \
+ $(am__append_4128) $(am__append_4135) $(am__append_4142) \
+ script/yylex.l script/parser.y $(am__append_4149) \
+ $(am__append_4156) $(am__append_4163) $(am__append_4170) \
+ $(am__append_4177) $(am__append_4184) $(am__append_4191) \
+ $(am__append_4198) $(am__append_4205) $(am__append_4212) \
+ $(am__append_4219) $(am__append_4226) $(am__append_4233) \
+ $(am__append_4240) $(am__append_4247) $(am__append_4254) \
+ $(am__append_4261) $(am__append_4268) $(am__append_4275) \
+ $(am__append_4282) $(am__append_4289) $(am__append_4296) \
+ $(am__append_4303) $(am__append_4310) $(am__append_4317) \
+ $(am__append_4324) $(am__append_4331) $(am__append_4338) \
+ $(am__append_4345) $(am__append_4352) $(am__append_4359) \
+ $(am__append_4366) $(am__append_4373) $(am__append_4380) \
+ $(am__append_4387) $(am__append_4394) $(am__append_4401) \
+ $(am__append_4408) $(am__append_4415) $(am__append_4422) \
+ $(am__append_4429) $(am__append_4436) $(am__append_4443) \
+ $(am__append_4450) $(am__append_4457) $(am__append_4464) \
+ $(am__append_4471) $(am__append_4478) $(am__append_4485) \
+ $(am__append_4492) $(am__append_4499) $(am__append_4506) \
+ $(am__append_4513) $(am__append_4520) $(am__append_4527) \
+ $(am__append_4534) $(am__append_4541) $(am__append_4548) \
+ $(am__append_4555) $(am__append_4562) $(am__append_4569) \
+ $(am__append_4576) $(am__append_4583) $(am__append_4590) \
+ $(am__append_4597) $(am__append_4604) $(am__append_4611) \
+ $(am__append_4618) $(am__append_4625) $(am__append_4632) \
+ $(am__append_4639) $(am__append_4646) $(am__append_4653) \
+ $(am__append_4660) $(am__append_4667) $(am__append_4674) \
+ $(am__append_4681) $(am__append_4688) $(am__append_4695) \
+ $(am__append_4702) $(am__append_4709) $(am__append_4716) \
+ $(am__append_4723) $(am__append_4730) $(am__append_4737) \
+ $(am__append_4744) $(am__append_4751) $(am__append_4758) \
+ $(am__append_4765) $(am__append_4772) $(am__append_4779) \
+ $(am__append_4786) $(am__append_4793) $(am__append_4800) \
+ $(am__append_4807) $(am__append_4814) $(am__append_4821) \
+ $(am__append_4828) $(am__append_4835) $(am__append_4842) \
+ $(am__append_4849) $(am__append_4856) $(am__append_4863) \
+ $(am__append_4870) $(am__append_4877) $(am__append_4884) \
+ $(am__append_4891) $(am__append_4898) $(am__append_4905) \
+ $(am__append_4912) $(am__append_4919) $(am__append_4926) \
+ $(am__append_4933) $(am__append_4940) $(am__append_4947) \
+ $(am__append_4954) $(am__append_4961) $(am__append_4968) \
+ $(am__append_4975) $(am__append_4982) $(am__append_4989) \
+ $(am__append_4996) $(am__append_5003) $(am__append_5010) \
+ $(am__append_5017) $(am__append_5024) $(am__append_5031) \
+ $(am__append_5038) $(am__append_5045) $(am__append_5052) \
+ $(am__append_5059) $(am__append_5066) $(am__append_5073) \
+ $(am__append_5080) $(am__append_5087) $(am__append_5094) \
+ $(am__append_5101) $(am__append_5108) $(am__append_5115) \
+ $(am__append_5122) $(am__append_5129) $(am__append_5136) \
+ $(am__append_5143) $(am__append_5150) $(am__append_5157) \
+ $(am__append_5164) $(am__append_5171) $(am__append_5178) \
+ $(am__append_5185) $(am__append_5192) $(am__append_5199) \
+ $(am__append_5206) $(am__append_5213) $(am__append_5220) \
+ $(am__append_5227) $(am__append_5234) $(am__append_5241) \
+ $(am__append_5248) $(am__append_5255) $(am__append_5262) \
+ $(am__append_5269) $(am__append_5276) $(am__append_5283) \
+ $(am__append_5290) $(am__append_5297) $(am__append_5304) \
+ $(am__append_5311) $(am__append_5318) $(am__append_5325) \
+ $(am__append_5332) $(am__append_5339) $(am__append_5346) \
+ $(am__append_5353) $(am__append_5360) $(am__append_5367) \
+ $(am__append_5374) $(am__append_5381) $(am__append_5388) \
+ $(am__append_5395) $(am__append_5402) $(am__append_5409) \
+ $(am__append_5416) $(am__append_5423) $(am__append_5430) \
+ $(am__append_5437) $(am__append_5444) $(am__append_5451) \
+ $(am__append_5458) $(am__append_5465) $(am__append_5472) \
+ $(am__append_5479) $(am__append_5486) $(am__append_5493) \
+ $(am__append_5500) $(am__append_5507) $(am__append_5514) \
+ $(am__append_5521) $(am__append_5528) $(am__append_5535) \
+ $(am__append_5542) $(am__append_5549) $(am__append_5556) \
+ $(am__append_5563) $(am__append_5570) $(am__append_5577) \
+ $(am__append_5584) $(am__append_5591) $(am__append_5598) \
+ $(am__append_5605) commands/fileXX.c loader/i386/xen_fileXX.c \
+ $(am__append_5612) $(am__append_5619) $(am__append_5626) \
+ $(am__append_5633) $(am__append_5640) $(am__append_5647) \
+ $(am__append_5654) $(am__append_5661) $(am__append_5668) \
+ $(am__append_5675) $(am__append_5682) $(am__append_5689) \
+ $(am__append_5696) $(am__append_5703) $(am__append_5709) \
+ $(am__append_5714) $(am__append_5719) $(am__append_5724) \
+ $(am__append_5729) $(am__append_5734) $(am__append_5739) \
+ $(am__append_5744) $(am__append_5749) $(am__append_5754) \
+ $(am__append_5759) $(am__append_5764) $(am__append_5769) \
+ $(am__append_5774) $(am__append_5779) $(am__append_5784) \
+ $(am__append_5789) $(am__append_5794) $(am__append_5799) \
+ $(am__append_5804) $(am__append_5809) $(am__append_5814) \
+ $(am__append_5819) $(am__append_5824) $(am__append_5829) \
+ $(am__append_5834) $(am__append_5839) $(am__append_5844) \
+ $(am__append_5849) $(am__append_5854) $(am__append_5859) \
+ $(am__append_5864) $(am__append_5869) $(am__append_5874) \
+ $(am__append_5879) $(am__append_5884) $(am__append_5889) \
+ $(am__append_5894) $(am__append_5899) $(am__append_5906) \
+ gensyminfo.sh.in genmod.sh.in modinfo.sh.in gmodule.pl.in \
+ gdb_grub.in $(am__append_5912)
+platform_SCRIPTS =
+EXTRA_DIST = $(am__append_5911)
+CLEANFILES = build-grub-pep2elf$(BUILD_EXEEXT) \
+ build-grub-pe2elf$(BUILD_EXEEXT) gentrigtables$(BUILD_EXEEXT) \
+ build-grub-module-verifier$(BUILD_EXEEXT) trigtables.c \
+ grub_script.tab.c grub_script.tab.h grub_script.yy.c \
+ grub_script.yy.h $(nodist_disk_module_SOURCES) disk.marker \
+ $(nodist_trig_module_SOURCES) trig.marker $(am__append_7) \
+ $(am__append_14) $(am__append_21) $(am__append_28) \
+ $(am__append_35) $(am__append_42) $(am__append_49) \
+ $(am__append_56) $(am__append_63) $(am__append_70) \
+ $(am__append_77) $(am__append_84) $(am__append_91) \
+ $(am__append_98) $(am__append_105) $(am__append_112) \
+ $(am__append_119) $(am__append_126) $(am__append_133) \
+ $(am__append_140) $(am__append_147) $(am__append_154) \
+ $(am__append_161) $(am__append_168) $(am__append_175) \
+ $(am__append_182) $(am__append_189) $(am__append_196) \
+ $(am__append_203) $(am__append_210) $(am__append_217) \
+ $(am__append_224) $(am__append_231) $(am__append_238) \
+ $(am__append_245) $(am__append_252) $(am__append_259) \
+ $(am__append_266) $(am__append_273) $(am__append_280) \
+ $(am__append_287) $(am__append_294) $(am__append_301) \
+ $(am__append_308) $(am__append_315) $(am__append_322) \
+ $(am__append_329) $(am__append_336) $(am__append_343) \
+ $(am__append_350) $(am__append_357) $(am__append_364) \
+ $(am__append_371) $(am__append_378) $(am__append_385) \
+ $(am__append_392) $(am__append_399) $(am__append_406) \
+ $(am__append_413) $(am__append_420) $(am__append_427) \
+ $(am__append_434) $(am__append_441) $(am__append_448) \
+ $(am__append_455) $(am__append_462) $(am__append_469) \
+ $(am__append_476) $(am__append_483) $(am__append_490) \
+ $(am__append_497) $(am__append_504) $(am__append_511) \
+ $(am__append_518) $(am__append_525) $(am__append_532) \
+ $(am__append_539) $(am__append_546) $(am__append_553) \
+ $(am__append_560) $(am__append_567) $(am__append_574) \
+ $(am__append_581) $(am__append_588) $(am__append_595) \
+ $(am__append_602) $(am__append_609) $(am__append_616) \
+ $(am__append_623) $(am__append_630) $(am__append_637) \
+ $(am__append_644) $(am__append_651) $(am__append_658) \
+ $(am__append_665) $(am__append_672) $(am__append_679) \
+ $(am__append_686) $(am__append_693) $(am__append_700) \
+ $(am__append_707) $(am__append_714) $(am__append_721) \
+ $(am__append_728) $(am__append_735) $(am__append_742) \
+ $(am__append_749) $(am__append_756) $(am__append_763) \
+ $(am__append_770) $(am__append_777) $(am__append_784) \
+ $(am__append_791) $(am__append_798) $(am__append_805) \
+ $(am__append_812) $(am__append_819) $(am__append_826) \
+ $(am__append_833) $(am__append_840) $(am__append_847) \
+ $(am__append_854) $(am__append_861) $(am__append_868) \
+ $(am__append_875) $(am__append_882) $(am__append_889) \
+ $(am__append_896) $(am__append_903) $(am__append_910) \
+ $(am__append_917) $(am__append_924) $(am__append_931) \
+ $(am__append_938) $(am__append_945) $(am__append_952) \
+ $(am__append_959) $(am__append_966) $(am__append_973) \
+ $(am__append_980) $(am__append_987) $(am__append_994) \
+ $(am__append_1001) $(am__append_1008) $(am__append_1015) \
+ $(am__append_1022) $(am__append_1029) \
+ $(nodist_regexp_module_SOURCES) regexp.marker \
+ $(am__append_1036) $(am__append_1043) $(am__append_1050) \
+ $(am__append_1057) $(am__append_1064) $(am__append_1071) \
+ $(am__append_1078) $(am__append_1085) $(am__append_1092) \
+ $(am__append_1099) $(am__append_1106) $(am__append_1113) \
+ $(am__append_1120) $(am__append_1127) $(am__append_1134) \
+ $(am__append_1141) $(am__append_1148) $(am__append_1155) \
+ $(am__append_1162) $(am__append_1169) $(am__append_1176) \
+ $(am__append_1183) $(am__append_1190) $(am__append_1197) \
+ $(am__append_1204) $(am__append_1211) $(am__append_1218) \
+ $(am__append_1225) $(am__append_1232) $(am__append_1239) \
+ $(am__append_1246) $(am__append_1253) $(am__append_1260) \
+ $(am__append_1267) $(am__append_1274) $(am__append_1281) \
+ $(am__append_1288) $(am__append_1295) $(am__append_1302) \
+ $(am__append_1309) $(am__append_1316) $(am__append_1323) \
+ $(am__append_1330) $(am__append_1337) $(am__append_1344) \
+ $(am__append_1351) $(am__append_1358) $(am__append_1365) \
+ $(am__append_1372) $(am__append_1379) $(am__append_1386) \
+ $(am__append_1393) $(am__append_1400) $(am__append_1407) \
+ $(am__append_1414) $(nodist_blocklist_module_SOURCES) \
+ blocklist.marker $(am__append_1421) $(am__append_1428) \
+ $(am__append_1435) $(am__append_1442) $(am__append_1449) \
+ $(am__append_1456) $(am__append_1463) $(am__append_1470) \
+ $(am__append_1477) $(am__append_1484) $(am__append_1491) \
+ $(am__append_1498) $(am__append_1505) $(am__append_1512) \
+ $(am__append_1519) $(am__append_1526) $(am__append_1533) \
+ $(am__append_1540) $(nodist_cat_module_SOURCES) cat.marker \
+ $(nodist_cmp_module_SOURCES) cmp.marker \
+ $(nodist_configfile_module_SOURCES) configfile.marker \
+ $(am__append_1547) $(am__append_1554) $(am__append_1561) \
+ $(am__append_1568) $(am__append_1575) $(am__append_1582) \
+ $(am__append_1589) $(am__append_1596) $(am__append_1603) \
+ $(am__append_1610) $(nodist_date_module_SOURCES) date.marker \
+ $(am__append_1617) $(nodist_echo_module_SOURCES) echo.marker \
+ $(nodist_eval_module_SOURCES) eval.marker $(am__append_1624) \
+ $(am__append_1631) $(am__append_1638) $(am__append_1645) \
+ $(am__append_1652) $(am__append_1659) $(am__append_1666) \
+ $(am__append_1673) $(am__append_1680) $(am__append_1687) \
+ $(am__append_1694) $(am__append_1701) $(am__append_1708) \
+ $(am__append_1715) $(nodist_gptsync_module_SOURCES) \
+ gptsync.marker $(am__append_1722) $(am__append_1729) \
+ $(am__append_1736) $(am__append_1743) $(am__append_1750) \
+ $(am__append_1757) $(am__append_1764) $(am__append_1771) \
+ $(am__append_1778) $(am__append_1785) $(am__append_1792) \
+ $(am__append_1799) $(am__append_1806) $(am__append_1813) \
+ $(am__append_1820) $(am__append_1827) $(am__append_1834) \
+ $(am__append_1841) $(am__append_1848) $(am__append_1855) \
+ $(am__append_1862) $(am__append_1869) $(am__append_1876) \
+ $(am__append_1883) $(am__append_1890) $(am__append_1897) \
+ $(am__append_1904) $(am__append_1911) $(am__append_1918) \
+ $(am__append_1925) $(am__append_1932) $(am__append_1939) \
+ $(am__append_1946) $(am__append_1953) $(am__append_1960) \
+ $(am__append_1967) $(am__append_1974) $(am__append_1981) \
+ $(am__append_1988) $(am__append_1995) $(am__append_2002) \
+ $(am__append_2009) $(am__append_2016) $(am__append_2023) \
+ $(am__append_2030) $(am__append_2037) \
+ $(nodist_hashsum_module_SOURCES) hashsum.marker \
+ $(nodist_pgp_module_SOURCES) pgp.marker $(am__append_2044) \
+ $(am__append_2051) $(am__append_2058) $(am__append_2065) \
+ $(am__append_2072) $(am__append_2079) $(am__append_2086) \
+ $(am__append_2093) $(am__append_2100) \
+ $(nodist_help_module_SOURCES) help.marker \
+ $(nodist_hexdump_module_SOURCES) hexdump.marker \
+ $(nodist_keystatus_module_SOURCES) keystatus.marker \
+ $(am__append_2107) $(am__append_2114) \
+ $(nodist_loadenv_module_SOURCES) loadenv.marker \
+ $(nodist_ls_module_SOURCES) ls.marker \
+ $(nodist_lsmmap_module_SOURCES) lsmmap.marker \
+ $(am__append_2121) $(am__append_2128) $(am__append_2135) \
+ $(am__append_2142) $(am__append_2149) $(am__append_2156) \
+ $(am__append_2163) $(am__append_2170) \
+ $(nodist_memrw_module_SOURCES) memrw.marker \
+ $(nodist_minicmd_module_SOURCES) minicmd.marker \
+ $(nodist_parttool_module_SOURCES) parttool.marker \
+ $(nodist_password_module_SOURCES) password.marker \
+ $(nodist_password_pbkdf2_module_SOURCES) \
+ password_pbkdf2.marker $(am__append_2177) $(am__append_2184) \
+ $(am__append_2191) $(am__append_2198) $(am__append_2205) \
+ $(am__append_2212) $(am__append_2219) $(am__append_2226) \
+ $(am__append_2233) $(am__append_2240) $(am__append_2247) \
+ $(am__append_2254) $(am__append_2261) $(am__append_2268) \
+ $(am__append_2275) $(am__append_2282) $(am__append_2289) \
+ $(am__append_2296) $(am__append_2303) $(am__append_2310) \
+ $(am__append_2317) $(nodist_probe_module_SOURCES) probe.marker \
+ $(nodist_read_module_SOURCES) read.marker \
+ $(nodist_search_module_SOURCES) search.marker \
+ $(nodist_search_fs_file_module_SOURCES) search_fs_file.marker \
+ $(nodist_search_fs_uuid_module_SOURCES) search_fs_uuid.marker \
+ $(nodist_search_label_module_SOURCES) search_label.marker \
+ $(am__append_2324) $(am__append_2331) $(am__append_2338) \
+ $(am__append_2345) $(am__append_2352) $(am__append_2359) \
+ $(am__append_2366) $(am__append_2373) $(am__append_2380) \
+ $(am__append_2387) $(am__append_2394) $(am__append_2401) \
+ $(am__append_2408) $(am__append_2415) $(am__append_2422) \
+ $(am__append_2429) $(nodist_sleep_module_SOURCES) sleep.marker \
+ $(am__append_2436) $(am__append_2443) $(am__append_2450) \
+ $(am__append_2457) $(am__append_2464) $(am__append_2471) \
+ $(am__append_2478) $(am__append_2485) $(am__append_2492) \
+ $(am__append_2499) $(am__append_2506) $(am__append_2513) \
+ $(nodist_terminal_module_SOURCES) terminal.marker \
+ $(nodist_test_module_SOURCES) test.marker \
+ $(nodist_true_module_SOURCES) true.marker $(am__append_2520) \
+ $(am__append_2527) $(am__append_2534) $(am__append_2541) \
+ $(am__append_2548) $(am__append_2555) $(am__append_2562) \
+ $(am__append_2569) $(am__append_2576) \
+ $(nodist_videoinfo_module_SOURCES) videoinfo.marker \
+ $(nodist_videotest_module_SOURCES) videotest.marker \
+ $(nodist_xnu_uuid_module_SOURCES) xnu_uuid.marker \
+ $(nodist_dm_nv_module_SOURCES) dm_nv.marker \
+ $(nodist_loopback_module_SOURCES) loopback.marker \
+ $(nodist_cryptodisk_module_SOURCES) cryptodisk.marker \
+ $(nodist_json_module_SOURCES) json.marker \
+ $(nodist_afsplitter_module_SOURCES) afsplitter.marker \
+ $(nodist_luks_module_SOURCES) luks.marker \
+ $(nodist_luks2_module_SOURCES) luks2.marker \
+ $(nodist_geli_module_SOURCES) geli.marker \
+ $(nodist_lvm_module_SOURCES) lvm.marker \
+ $(nodist_ldm_module_SOURCES) ldm.marker \
+ $(nodist_mdraid09_module_SOURCES) mdraid09.marker \
+ $(nodist_mdraid09_be_module_SOURCES) mdraid09_be.marker \
+ $(nodist_mdraid1x_module_SOURCES) mdraid1x.marker \
+ $(nodist_diskfilter_module_SOURCES) diskfilter.marker \
+ $(nodist_raid5rec_module_SOURCES) raid5rec.marker \
+ $(nodist_raid6rec_module_SOURCES) raid6rec.marker \
+ $(nodist_scsi_module_SOURCES) scsi.marker \
+ $(nodist_memdisk_module_SOURCES) memdisk.marker \
+ $(am__append_2583) $(am__append_2590) $(am__append_2597) \
+ $(am__append_2604) $(am__append_2611) $(am__append_2618) \
+ $(am__append_2625) $(am__append_2632) $(am__append_2639) \
+ $(am__append_2646) $(am__append_2653) $(am__append_2660) \
+ $(am__append_2667) $(am__append_2674) $(am__append_2681) \
+ $(am__append_2688) $(am__append_2695) $(am__append_2702) \
+ $(am__append_2709) $(am__append_2716) $(am__append_2723) \
+ $(am__append_2730) $(am__append_2737) $(am__append_2744) \
+ $(am__append_2751) $(am__append_2758) $(am__append_2765) \
+ $(am__append_2772) $(am__append_2779) $(am__append_2786) \
+ $(am__append_2793) $(am__append_2800) $(am__append_2807) \
+ $(am__append_2814) $(am__append_2821) $(am__append_2828) \
+ $(am__append_2835) $(am__append_2842) $(am__append_2849) \
+ $(am__append_2856) $(am__append_2863) $(am__append_2870) \
+ $(am__append_2877) $(am__append_2884) $(am__append_2891) \
+ $(am__append_2898) $(am__append_2905) $(am__append_2912) \
+ $(am__append_2919) $(am__append_2926) $(am__append_2933) \
+ $(am__append_2940) $(am__append_2947) $(am__append_2954) \
+ $(am__append_2961) $(am__append_2968) $(am__append_2975) \
+ $(am__append_2982) $(am__append_2989) $(am__append_2996) \
+ $(am__append_3003) $(nodist_procfs_module_SOURCES) \
+ procfs.marker $(nodist_affs_module_SOURCES) affs.marker \
+ $(nodist_afs_module_SOURCES) afs.marker \
+ $(nodist_bfs_module_SOURCES) bfs.marker \
+ $(nodist_zstd_module_SOURCES) zstd.marker \
+ $(nodist_btrfs_module_SOURCES) btrfs.marker \
+ $(nodist_archelp_module_SOURCES) archelp.marker \
+ $(nodist_cbfs_module_SOURCES) cbfs.marker \
+ $(nodist_cpio_module_SOURCES) cpio.marker \
+ $(nodist_cpio_be_module_SOURCES) cpio_be.marker \
+ $(nodist_newc_module_SOURCES) newc.marker \
+ $(nodist_odc_module_SOURCES) odc.marker \
+ $(nodist_ext2_module_SOURCES) ext2.marker \
+ $(nodist_fat_module_SOURCES) fat.marker \
+ $(nodist_exfat_module_SOURCES) exfat.marker \
+ $(nodist_f2fs_module_SOURCES) f2fs.marker \
+ $(nodist_fshelp_module_SOURCES) fshelp.marker \
+ $(nodist_hfs_module_SOURCES) hfs.marker \
+ $(nodist_hfsplus_module_SOURCES) hfsplus.marker \
+ $(nodist_hfspluscomp_module_SOURCES) hfspluscomp.marker \
+ $(nodist_iso9660_module_SOURCES) iso9660.marker \
+ $(nodist_jfs_module_SOURCES) jfs.marker \
+ $(nodist_minix_module_SOURCES) minix.marker \
+ $(nodist_minix2_module_SOURCES) minix2.marker \
+ $(nodist_minix3_module_SOURCES) minix3.marker \
+ $(nodist_minix_be_module_SOURCES) minix_be.marker \
+ $(nodist_minix2_be_module_SOURCES) minix2_be.marker \
+ $(nodist_minix3_be_module_SOURCES) minix3_be.marker \
+ $(nodist_nilfs2_module_SOURCES) nilfs2.marker \
+ $(nodist_ntfs_module_SOURCES) ntfs.marker \
+ $(nodist_ntfscomp_module_SOURCES) ntfscomp.marker \
+ $(nodist_reiserfs_module_SOURCES) reiserfs.marker \
+ $(nodist_romfs_module_SOURCES) romfs.marker \
+ $(nodist_sfs_module_SOURCES) sfs.marker \
+ $(nodist_squash4_module_SOURCES) squash4.marker \
+ $(nodist_tar_module_SOURCES) tar.marker \
+ $(nodist_udf_module_SOURCES) udf.marker \
+ $(nodist_ufs1_module_SOURCES) ufs1.marker \
+ $(nodist_ufs1_be_module_SOURCES) ufs1_be.marker \
+ $(nodist_ufs2_module_SOURCES) ufs2.marker \
+ $(nodist_xfs_module_SOURCES) xfs.marker \
+ $(nodist_zfs_module_SOURCES) zfs.marker \
+ $(nodist_zfscrypt_module_SOURCES) zfscrypt.marker \
+ $(nodist_zfsinfo_module_SOURCES) zfsinfo.marker \
+ $(nodist_macbless_module_SOURCES) macbless.marker \
+ $(am__append_3010) $(nodist_gettext_module_SOURCES) \
+ gettext.marker $(nodist_gfxmenu_module_SOURCES) gfxmenu.marker \
+ $(nodist_hello_module_SOURCES) hello.marker \
+ $(nodist_gzio_module_SOURCES) gzio.marker \
+ $(nodist_offsetio_module_SOURCES) offsetio.marker \
+ $(am__append_3017) $(am__append_3024) $(am__append_3031) \
+ $(am__append_3038) $(am__append_3045) $(am__append_3052) \
+ $(am__append_3059) $(am__append_3066) $(am__append_3073) \
+ $(am__append_3080) $(am__append_3087) $(am__append_3094) \
+ $(am__append_3101) $(am__append_3108) $(am__append_3115) \
+ $(am__append_3122) $(am__append_3129) $(am__append_3136) \
+ $(am__append_3143) $(am__append_3150) \
+ $(nodist_elf_module_SOURCES) elf.marker \
+ $(nodist_crypto_module_SOURCES) crypto.marker \
+ $(nodist_pbkdf2_module_SOURCES) pbkdf2.marker \
+ $(am__append_3157) $(am__append_3164) $(am__append_3171) \
+ $(am__append_3178) $(am__append_3185) $(am__append_3192) \
+ $(am__append_3199) $(am__append_3206) $(am__append_3213) \
+ $(am__append_3220) $(am__append_3227) $(am__append_3234) \
+ $(am__append_3241) $(am__append_3248) $(am__append_3255) \
+ $(am__append_3262) $(am__append_3269) $(am__append_3276) \
+ $(am__append_3283) $(am__append_3290) $(am__append_3297) \
+ $(am__append_3304) $(am__append_3311) $(am__append_3318) \
+ $(am__append_3325) $(am__append_3332) $(am__append_3339) \
+ $(am__append_3346) $(am__append_3353) $(am__append_3360) \
+ $(am__append_3367) $(am__append_3374) $(am__append_3381) \
+ $(am__append_3388) $(am__append_3395) $(am__append_3402) \
+ $(am__append_3409) $(nodist_setjmp_module_SOURCES) \
+ setjmp.marker $(am__append_3416) $(am__append_3423) \
+ $(am__append_3430) $(am__append_3437) $(am__append_3444) \
+ $(am__append_3451) $(am__append_3458) $(am__append_3465) \
+ $(am__append_3472) $(am__append_3479) $(am__append_3486) \
+ $(am__append_3493) $(am__append_3500) $(am__append_3507) \
+ $(am__append_3514) $(am__append_3521) $(am__append_3528) \
+ $(am__append_3535) $(am__append_3542) $(am__append_3549) \
+ $(am__append_3556) $(am__append_3563) $(am__append_3570) \
+ $(am__append_3577) $(am__append_3584) $(am__append_3591) \
+ $(am__append_3598) $(am__append_3605) $(am__append_3612) \
+ $(am__append_3619) $(am__append_3626) $(am__append_3633) \
+ $(am__append_3640) $(am__append_3647) $(am__append_3654) \
+ $(am__append_3661) $(am__append_3668) $(am__append_3675) \
+ $(am__append_3682) $(am__append_3689) $(am__append_3696) \
+ $(am__append_3703) $(am__append_3710) $(am__append_3717) \
+ $(am__append_3724) $(am__append_3731) $(am__append_3738) \
+ $(am__append_3745) $(am__append_3752) $(am__append_3759) \
+ $(am__append_3766) $(am__append_3773) $(am__append_3780) \
+ $(am__append_3787) $(am__append_3794) $(am__append_3801) \
+ $(am__append_3808) $(am__append_3815) $(am__append_3822) \
+ $(am__append_3829) $(am__append_3836) $(am__append_3843) \
+ $(am__append_3850) $(am__append_3857) $(am__append_3864) \
+ $(am__append_3871) $(am__append_3878) $(am__append_3885) \
+ $(am__append_3892) $(am__append_3899) $(am__append_3906) \
+ $(am__append_3913) $(am__append_3920) $(am__append_3927) \
+ $(am__append_3934) $(am__append_3941) $(am__append_3948) \
+ $(am__append_3955) $(nodist_macho_module_SOURCES) macho.marker \
+ $(am__append_3962) $(am__append_3969) $(am__append_3976) \
+ $(am__append_3983) $(am__append_3990) $(am__append_3997) \
+ $(am__append_4004) $(am__append_4011) $(am__append_4018) \
+ $(am__append_4025) $(am__append_4032) $(am__append_4039) \
+ $(am__append_4046) $(am__append_4053) $(am__append_4060) \
+ $(am__append_4067) $(am__append_4074) $(am__append_4081) \
+ $(am__append_4088) $(am__append_4095) $(am__append_4102) \
+ $(am__append_4109) $(am__append_4116) $(am__append_4123) \
+ $(am__append_4130) $(am__append_4137) $(am__append_4144) \
+ $(nodist_normal_module_SOURCES) normal.marker \
+ $(nodist_part_acorn_module_SOURCES) part_acorn.marker \
+ $(nodist_part_amiga_module_SOURCES) part_amiga.marker \
+ $(nodist_part_apple_module_SOURCES) part_apple.marker \
+ $(nodist_part_gpt_module_SOURCES) part_gpt.marker \
+ $(nodist_part_msdos_module_SOURCES) part_msdos.marker \
+ $(nodist_part_sun_module_SOURCES) part_sun.marker \
+ $(nodist_part_plan_module_SOURCES) part_plan.marker \
+ $(nodist_part_dvh_module_SOURCES) part_dvh.marker \
+ $(nodist_part_bsd_module_SOURCES) part_bsd.marker \
+ $(nodist_part_sunpc_module_SOURCES) part_sunpc.marker \
+ $(nodist_part_dfly_module_SOURCES) part_dfly.marker \
+ $(nodist_msdospart_module_SOURCES) msdospart.marker \
+ $(am__append_4151) $(am__append_4158) $(am__append_4165) \
+ $(am__append_4172) $(am__append_4179) $(am__append_4186) \
+ $(am__append_4193) $(am__append_4200) $(am__append_4207) \
+ $(am__append_4214) $(am__append_4221) $(am__append_4228) \
+ $(am__append_4235) $(am__append_4242) $(am__append_4249) \
+ $(am__append_4256) $(am__append_4263) $(am__append_4270) \
+ $(am__append_4277) $(am__append_4284) $(am__append_4291) \
+ $(am__append_4298) $(am__append_4305) $(am__append_4312) \
+ $(am__append_4319) $(am__append_4326) $(am__append_4333) \
+ $(nodist_gfxterm_background_module_SOURCES) \
+ gfxterm_background.marker $(am__append_4340) \
+ $(am__append_4347) $(am__append_4354) $(am__append_4361) \
+ $(am__append_4368) $(am__append_4375) $(am__append_4382) \
+ $(am__append_4389) $(am__append_4396) $(am__append_4403) \
+ $(am__append_4410) $(am__append_4417) $(am__append_4424) \
+ $(am__append_4431) $(am__append_4438) $(am__append_4445) \
+ $(am__append_4452) $(am__append_4459) $(am__append_4466) \
+ $(am__append_4473) $(am__append_4480) $(am__append_4487) \
+ $(am__append_4494) $(am__append_4501) $(am__append_4508) \
+ $(am__append_4515) $(am__append_4522) $(am__append_4529) \
+ $(am__append_4536) $(am__append_4543) $(am__append_4550) \
+ $(am__append_4557) $(am__append_4564) $(am__append_4571) \
+ $(am__append_4578) $(am__append_4585) $(am__append_4592) \
+ $(am__append_4599) $(am__append_4606) $(am__append_4613) \
+ $(am__append_4620) $(am__append_4627) $(am__append_4634) \
+ $(am__append_4641) $(am__append_4648) $(am__append_4655) \
+ $(am__append_4662) $(am__append_4669) $(am__append_4676) \
+ $(am__append_4683) $(am__append_4690) $(am__append_4697) \
+ $(am__append_4704) $(am__append_4711) $(am__append_4718) \
+ $(nodist_functional_test_module_SOURCES) \
+ functional_test.marker $(nodist_exfctest_module_SOURCES) \
+ exfctest.marker $(nodist_strtoull_test_module_SOURCES) \
+ strtoull_test.marker $(nodist_setjmp_test_module_SOURCES) \
+ setjmp_test.marker $(nodist_signature_test_module_SOURCES) \
+ signature_test.marker $(nodist_sleep_test_module_SOURCES) \
+ sleep_test.marker $(nodist_xnu_uuid_test_module_SOURCES) \
+ xnu_uuid_test.marker $(nodist_pbkdf2_test_module_SOURCES) \
+ pbkdf2_test.marker $(am__append_4725) $(am__append_4732) \
+ $(am__append_4739) $(am__append_4746) $(am__append_4753) \
+ $(am__append_4760) $(am__append_4767) $(am__append_4774) \
+ $(am__append_4781) $(am__append_4788) $(am__append_4795) \
+ $(am__append_4802) $(am__append_4809) $(am__append_4816) \
+ $(am__append_4823) $(am__append_4830) $(am__append_4837) \
+ $(am__append_4844) $(am__append_4851) $(am__append_4858) \
+ $(am__append_4865) $(am__append_4872) $(am__append_4879) \
+ $(am__append_4886) $(am__append_4893) \
+ $(nodist_div_test_module_SOURCES) div_test.marker \
+ $(nodist_mul_test_module_SOURCES) mul_test.marker \
+ $(nodist_shift_test_module_SOURCES) shift_test.marker \
+ $(nodist_cmp_test_module_SOURCES) cmp_test.marker \
+ $(nodist_ctz_test_module_SOURCES) ctz_test.marker \
+ $(nodist_bswap_test_module_SOURCES) bswap_test.marker \
+ $(nodist_videotest_checksum_module_SOURCES) \
+ videotest_checksum.marker \
+ $(nodist_gfxterm_menu_module_SOURCES) gfxterm_menu.marker \
+ $(nodist_cmdline_cat_test_module_SOURCES) \
+ cmdline_cat_test.marker $(nodist_bitmap_module_SOURCES) \
+ bitmap.marker $(nodist_bitmap_scale_module_SOURCES) \
+ bitmap_scale.marker $(am__append_4900) $(am__append_4907) \
+ $(am__append_4914) $(am__append_4921) $(am__append_4928) \
+ $(am__append_4935) $(am__append_4942) $(am__append_4949) \
+ $(am__append_4956) $(nodist_jpeg_module_SOURCES) jpeg.marker \
+ $(nodist_png_module_SOURCES) png.marker \
+ $(nodist_tga_module_SOURCES) tga.marker $(am__append_4963) \
+ $(am__append_4970) $(am__append_4977) $(am__append_4984) \
+ $(am__append_4991) $(am__append_4998) $(am__append_5005) \
+ $(am__append_5012) $(am__append_5019) $(am__append_5026) \
+ $(am__append_5033) $(am__append_5040) $(am__append_5047) \
+ $(am__append_5054) $(am__append_5061) $(am__append_5068) \
+ $(am__append_5075) $(am__append_5082) $(am__append_5089) \
+ $(am__append_5096) $(am__append_5103) $(am__append_5110) \
+ $(am__append_5117) $(am__append_5124) $(am__append_5131) \
+ $(am__append_5138) $(am__append_5145) $(am__append_5152) \
+ $(am__append_5159) $(am__append_5166) $(am__append_5173) \
+ $(am__append_5180) $(am__append_5187) $(am__append_5194) \
+ $(am__append_5201) $(am__append_5208) $(am__append_5215) \
+ $(am__append_5222) $(am__append_5229) $(am__append_5236) \
+ $(am__append_5243) $(nodist_video_colors_module_SOURCES) \
+ video_colors.marker $(am__append_5250) $(am__append_5257) \
+ $(nodist_datehook_module_SOURCES) datehook.marker \
+ $(nodist_net_module_SOURCES) net.marker \
+ $(nodist_tftp_module_SOURCES) tftp.marker \
+ $(nodist_http_module_SOURCES) http.marker $(am__append_5264) \
+ $(am__append_5271) $(am__append_5278) $(am__append_5285) \
+ $(am__append_5292) $(am__append_5299) $(am__append_5306) \
+ $(am__append_5313) $(am__append_5320) $(am__append_5327) \
+ $(am__append_5334) $(am__append_5341) $(am__append_5348) \
+ $(am__append_5355) $(am__append_5362) $(am__append_5369) \
+ $(am__append_5376) $(am__append_5383) \
+ $(nodist_syslinuxcfg_module_SOURCES) syslinuxcfg.marker \
+ $(nodist_test_blockarg_module_SOURCES) test_blockarg.marker \
+ $(nodist_xzio_module_SOURCES) xzio.marker \
+ $(nodist_lzopio_module_SOURCES) lzopio.marker \
+ $(nodist_testload_module_SOURCES) testload.marker \
+ $(am__append_5390) $(am__append_5397) $(am__append_5404) \
+ $(am__append_5411) $(am__append_5418) $(am__append_5425) \
+ $(am__append_5432) $(am__append_5439) $(am__append_5446) \
+ $(am__append_5453) $(am__append_5460) $(am__append_5467) \
+ $(am__append_5474) $(am__append_5481) $(am__append_5488) \
+ $(am__append_5495) $(am__append_5502) \
+ $(nodist_priority_queue_module_SOURCES) priority_queue.marker \
+ $(nodist_time_module_SOURCES) time.marker $(am__append_5509) \
+ $(am__append_5516) $(nodist_adler32_module_SOURCES) \
+ adler32.marker $(nodist_crc64_module_SOURCES) crc64.marker \
+ $(nodist_mpi_module_SOURCES) mpi.marker \
+ $(nodist_all_video_module_SOURCES) all_video.marker \
+ $(am__append_5523) $(am__append_5530) $(am__append_5537) \
+ $(am__append_5544) $(am__append_5551) $(am__append_5558) \
+ $(nodist_testspeed_module_SOURCES) testspeed.marker \
+ $(am__append_5565) $(am__append_5572) $(am__append_5579) \
+ $(am__append_5586) $(am__append_5593) $(am__append_5600) \
+ $(am__append_5607) $(nodist_tr_module_SOURCES) tr.marker \
+ $(nodist_progress_module_SOURCES) progress.marker \
+ $(nodist_file_module_SOURCES) file.marker $(am__append_5614) \
+ $(am__append_5621) $(am__append_5628) $(am__append_5635) \
+ $(am__append_5642) $(am__append_5649) $(am__append_5656) \
+ $(am__append_5663) $(am__append_5670) $(am__append_5677) \
+ $(am__append_5684) $(am__append_5691) $(am__append_5698) \
+ $(am__append_5705) $(nodist_gcry_arcfour_module_SOURCES) \
+ gcry_arcfour.marker $(nodist_gcry_blowfish_module_SOURCES) \
+ gcry_blowfish.marker $(nodist_gcry_camellia_module_SOURCES) \
+ gcry_camellia.marker $(nodist_gcry_cast5_module_SOURCES) \
+ gcry_cast5.marker $(nodist_gcry_crc_module_SOURCES) \
+ gcry_crc.marker $(nodist_gcry_des_module_SOURCES) \
+ gcry_des.marker $(nodist_gcry_dsa_module_SOURCES) \
+ gcry_dsa.marker $(nodist_gcry_idea_module_SOURCES) \
+ gcry_idea.marker $(nodist_gcry_md4_module_SOURCES) \
+ gcry_md4.marker $(nodist_gcry_md5_module_SOURCES) \
+ gcry_md5.marker $(nodist_gcry_rfc2268_module_SOURCES) \
+ gcry_rfc2268.marker $(nodist_gcry_rijndael_module_SOURCES) \
+ gcry_rijndael.marker $(nodist_gcry_rmd160_module_SOURCES) \
+ gcry_rmd160.marker $(nodist_gcry_rsa_module_SOURCES) \
+ gcry_rsa.marker $(nodist_gcry_seed_module_SOURCES) \
+ gcry_seed.marker $(nodist_gcry_serpent_module_SOURCES) \
+ gcry_serpent.marker $(nodist_gcry_sha1_module_SOURCES) \
+ gcry_sha1.marker $(nodist_gcry_sha256_module_SOURCES) \
+ gcry_sha256.marker $(nodist_gcry_sha512_module_SOURCES) \
+ gcry_sha512.marker $(nodist_gcry_tiger_module_SOURCES) \
+ gcry_tiger.marker $(nodist_gcry_twofish_module_SOURCES) \
+ gcry_twofish.marker $(nodist_gcry_whirlpool_module_SOURCES) \
+ gcry_whirlpool.marker $(am__append_5711) $(am__append_5716) \
+ $(am__append_5721) $(am__append_5726) $(am__append_5731) \
+ $(am__append_5736) $(am__append_5741) $(am__append_5746) \
+ $(am__append_5751) $(am__append_5756) $(am__append_5761) \
+ $(am__append_5766) $(am__append_5771) $(am__append_5776) \
+ $(am__append_5781) $(am__append_5786) $(am__append_5791) \
+ $(am__append_5796) $(am__append_5801) $(am__append_5806) \
+ $(am__append_5811) $(am__append_5816) $(am__append_5821) \
+ $(am__append_5826) $(am__append_5831) $(am__append_5836) \
+ $(am__append_5841) $(am__append_5846) $(am__append_5851) \
+ $(am__append_5856) $(am__append_5861) $(am__append_5866) \
+ $(am__append_5871) $(am__append_5876) $(am__append_5881) \
+ $(am__append_5886) $(am__append_5891) $(am__append_5896) \
+ $(am__append_5901) $(am__append_5905) $(am__append_5908) \
+ gensyminfo.sh genmod.sh modinfo.sh gmodule.pl gdb_grub \
+ $(am__append_5910) symlist.h symlist.c kernel_syms.lst \
+ $(am__append_5942) fs.lst command.lst partmap.lst terminal.lst \
+ fdt.lst parttool.lst video.lst crypto.lst config.log \
+ syminfo.lst moddep.lst $(MOD_FILES) $(am__append_5944)
+BUILT_SOURCES = $(nodist_disk_module_SOURCES) \
+ $(nodist_trig_module_SOURCES) $(am__append_6) $(am__append_13) \
+ $(am__append_20) $(am__append_27) $(am__append_34) \
+ $(am__append_41) $(am__append_48) $(am__append_55) \
+ $(am__append_62) $(am__append_69) $(am__append_76) \
+ $(am__append_83) $(am__append_90) $(am__append_97) \
+ $(am__append_104) $(am__append_111) $(am__append_118) \
+ $(am__append_125) $(am__append_132) $(am__append_139) \
+ $(am__append_146) $(am__append_153) $(am__append_160) \
+ $(am__append_167) $(am__append_174) $(am__append_181) \
+ $(am__append_188) $(am__append_195) $(am__append_202) \
+ $(am__append_209) $(am__append_216) $(am__append_223) \
+ $(am__append_230) $(am__append_237) $(am__append_244) \
+ $(am__append_251) $(am__append_258) $(am__append_265) \
+ $(am__append_272) $(am__append_279) $(am__append_286) \
+ $(am__append_293) $(am__append_300) $(am__append_307) \
+ $(am__append_314) $(am__append_321) $(am__append_328) \
+ $(am__append_335) $(am__append_342) $(am__append_349) \
+ $(am__append_356) $(am__append_363) $(am__append_370) \
+ $(am__append_377) $(am__append_384) $(am__append_391) \
+ $(am__append_398) $(am__append_405) $(am__append_412) \
+ $(am__append_419) $(am__append_426) $(am__append_433) \
+ $(am__append_440) $(am__append_447) $(am__append_454) \
+ $(am__append_461) $(am__append_468) $(am__append_475) \
+ $(am__append_482) $(am__append_489) $(am__append_496) \
+ $(am__append_503) $(am__append_510) $(am__append_517) \
+ $(am__append_524) $(am__append_531) $(am__append_538) \
+ $(am__append_545) $(am__append_552) $(am__append_559) \
+ $(am__append_566) $(am__append_573) $(am__append_580) \
+ $(am__append_587) $(am__append_594) $(am__append_601) \
+ $(am__append_608) $(am__append_615) $(am__append_622) \
+ $(am__append_629) $(am__append_636) $(am__append_643) \
+ $(am__append_650) $(am__append_657) $(am__append_664) \
+ $(am__append_671) $(am__append_678) $(am__append_685) \
+ $(am__append_692) $(am__append_699) $(am__append_706) \
+ $(am__append_713) $(am__append_720) $(am__append_727) \
+ $(am__append_734) $(am__append_741) $(am__append_748) \
+ $(am__append_755) $(am__append_762) $(am__append_769) \
+ $(am__append_776) $(am__append_783) $(am__append_790) \
+ $(am__append_797) $(am__append_804) $(am__append_811) \
+ $(am__append_818) $(am__append_825) $(am__append_832) \
+ $(am__append_839) $(am__append_846) $(am__append_853) \
+ $(am__append_860) $(am__append_867) $(am__append_874) \
+ $(am__append_881) $(am__append_888) $(am__append_895) \
+ $(am__append_902) $(am__append_909) $(am__append_916) \
+ $(am__append_923) $(am__append_930) $(am__append_937) \
+ $(am__append_944) $(am__append_951) $(am__append_958) \
+ $(am__append_965) $(am__append_972) $(am__append_979) \
+ $(am__append_986) $(am__append_993) $(am__append_1000) \
+ $(am__append_1007) $(am__append_1014) $(am__append_1021) \
+ $(am__append_1028) $(nodist_regexp_module_SOURCES) \
+ $(am__append_1035) $(am__append_1042) $(am__append_1049) \
+ $(am__append_1056) $(am__append_1063) $(am__append_1070) \
+ $(am__append_1077) $(am__append_1084) $(am__append_1091) \
+ $(am__append_1098) $(am__append_1105) $(am__append_1112) \
+ $(am__append_1119) $(am__append_1126) $(am__append_1133) \
+ $(am__append_1140) $(am__append_1147) $(am__append_1154) \
+ $(am__append_1161) $(am__append_1168) $(am__append_1175) \
+ $(am__append_1182) $(am__append_1189) $(am__append_1196) \
+ $(am__append_1203) $(am__append_1210) $(am__append_1217) \
+ $(am__append_1224) $(am__append_1231) $(am__append_1238) \
+ $(am__append_1245) $(am__append_1252) $(am__append_1259) \
+ $(am__append_1266) $(am__append_1273) $(am__append_1280) \
+ $(am__append_1287) $(am__append_1294) $(am__append_1301) \
+ $(am__append_1308) $(am__append_1315) $(am__append_1322) \
+ $(am__append_1329) $(am__append_1336) $(am__append_1343) \
+ $(am__append_1350) $(am__append_1357) $(am__append_1364) \
+ $(am__append_1371) $(am__append_1378) $(am__append_1385) \
+ $(am__append_1392) $(am__append_1399) $(am__append_1406) \
+ $(am__append_1413) $(nodist_blocklist_module_SOURCES) \
+ $(am__append_1420) $(am__append_1427) $(am__append_1434) \
+ $(am__append_1441) $(am__append_1448) $(am__append_1455) \
+ $(am__append_1462) $(am__append_1469) $(am__append_1476) \
+ $(am__append_1483) $(am__append_1490) $(am__append_1497) \
+ $(am__append_1504) $(am__append_1511) $(am__append_1518) \
+ $(am__append_1525) $(am__append_1532) $(am__append_1539) \
+ $(nodist_cat_module_SOURCES) $(nodist_cmp_module_SOURCES) \
+ $(nodist_configfile_module_SOURCES) $(am__append_1546) \
+ $(am__append_1553) $(am__append_1560) $(am__append_1567) \
+ $(am__append_1574) $(am__append_1581) $(am__append_1588) \
+ $(am__append_1595) $(am__append_1602) $(am__append_1609) \
+ $(nodist_date_module_SOURCES) $(am__append_1616) \
+ $(nodist_echo_module_SOURCES) $(nodist_eval_module_SOURCES) \
+ $(am__append_1623) $(am__append_1630) $(am__append_1637) \
+ $(am__append_1644) $(am__append_1651) $(am__append_1658) \
+ $(am__append_1665) $(am__append_1672) $(am__append_1679) \
+ $(am__append_1686) $(am__append_1693) $(am__append_1700) \
+ $(am__append_1707) $(am__append_1714) \
+ $(nodist_gptsync_module_SOURCES) $(am__append_1721) \
+ $(am__append_1728) $(am__append_1735) $(am__append_1742) \
+ $(am__append_1749) $(am__append_1756) $(am__append_1763) \
+ $(am__append_1770) $(am__append_1777) $(am__append_1784) \
+ $(am__append_1791) $(am__append_1798) $(am__append_1805) \
+ $(am__append_1812) $(am__append_1819) $(am__append_1826) \
+ $(am__append_1833) $(am__append_1840) $(am__append_1847) \
+ $(am__append_1854) $(am__append_1861) $(am__append_1868) \
+ $(am__append_1875) $(am__append_1882) $(am__append_1889) \
+ $(am__append_1896) $(am__append_1903) $(am__append_1910) \
+ $(am__append_1917) $(am__append_1924) $(am__append_1931) \
+ $(am__append_1938) $(am__append_1945) $(am__append_1952) \
+ $(am__append_1959) $(am__append_1966) $(am__append_1973) \
+ $(am__append_1980) $(am__append_1987) $(am__append_1994) \
+ $(am__append_2001) $(am__append_2008) $(am__append_2015) \
+ $(am__append_2022) $(am__append_2029) $(am__append_2036) \
+ $(nodist_hashsum_module_SOURCES) $(nodist_pgp_module_SOURCES) \
+ $(am__append_2043) $(am__append_2050) $(am__append_2057) \
+ $(am__append_2064) $(am__append_2071) $(am__append_2078) \
+ $(am__append_2085) $(am__append_2092) $(am__append_2099) \
+ $(nodist_help_module_SOURCES) $(nodist_hexdump_module_SOURCES) \
+ $(nodist_keystatus_module_SOURCES) $(am__append_2106) \
+ $(am__append_2113) $(nodist_loadenv_module_SOURCES) \
+ $(nodist_ls_module_SOURCES) $(nodist_lsmmap_module_SOURCES) \
+ $(am__append_2120) $(am__append_2127) $(am__append_2134) \
+ $(am__append_2141) $(am__append_2148) $(am__append_2155) \
+ $(am__append_2162) $(am__append_2169) \
+ $(nodist_memrw_module_SOURCES) \
+ $(nodist_minicmd_module_SOURCES) \
+ $(nodist_parttool_module_SOURCES) \
+ $(nodist_password_module_SOURCES) \
+ $(nodist_password_pbkdf2_module_SOURCES) $(am__append_2176) \
+ $(am__append_2183) $(am__append_2190) $(am__append_2197) \
+ $(am__append_2204) $(am__append_2211) $(am__append_2218) \
+ $(am__append_2225) $(am__append_2232) $(am__append_2239) \
+ $(am__append_2246) $(am__append_2253) $(am__append_2260) \
+ $(am__append_2267) $(am__append_2274) $(am__append_2281) \
+ $(am__append_2288) $(am__append_2295) $(am__append_2302) \
+ $(am__append_2309) $(am__append_2316) \
+ $(nodist_probe_module_SOURCES) $(nodist_read_module_SOURCES) \
+ $(nodist_search_module_SOURCES) \
+ $(nodist_search_fs_file_module_SOURCES) \
+ $(nodist_search_fs_uuid_module_SOURCES) \
+ $(nodist_search_label_module_SOURCES) $(am__append_2323) \
+ $(am__append_2330) $(am__append_2337) $(am__append_2344) \
+ $(am__append_2351) $(am__append_2358) $(am__append_2365) \
+ $(am__append_2372) $(am__append_2379) $(am__append_2386) \
+ $(am__append_2393) $(am__append_2400) $(am__append_2407) \
+ $(am__append_2414) $(am__append_2421) $(am__append_2428) \
+ $(nodist_sleep_module_SOURCES) $(am__append_2435) \
+ $(am__append_2442) $(am__append_2449) $(am__append_2456) \
+ $(am__append_2463) $(am__append_2470) $(am__append_2477) \
+ $(am__append_2484) $(am__append_2491) $(am__append_2498) \
+ $(am__append_2505) $(am__append_2512) \
+ $(nodist_terminal_module_SOURCES) \
+ $(nodist_test_module_SOURCES) $(nodist_true_module_SOURCES) \
+ $(am__append_2519) $(am__append_2526) $(am__append_2533) \
+ $(am__append_2540) $(am__append_2547) $(am__append_2554) \
+ $(am__append_2561) $(am__append_2568) $(am__append_2575) \
+ $(nodist_videoinfo_module_SOURCES) \
+ $(nodist_videotest_module_SOURCES) \
+ $(nodist_xnu_uuid_module_SOURCES) \
+ $(nodist_dm_nv_module_SOURCES) \
+ $(nodist_loopback_module_SOURCES) \
+ $(nodist_cryptodisk_module_SOURCES) \
+ $(nodist_json_module_SOURCES) \
+ $(nodist_afsplitter_module_SOURCES) \
+ $(nodist_luks_module_SOURCES) $(nodist_luks2_module_SOURCES) \
+ $(nodist_geli_module_SOURCES) $(nodist_lvm_module_SOURCES) \
+ $(nodist_ldm_module_SOURCES) $(nodist_mdraid09_module_SOURCES) \
+ $(nodist_mdraid09_be_module_SOURCES) \
+ $(nodist_mdraid1x_module_SOURCES) \
+ $(nodist_diskfilter_module_SOURCES) \
+ $(nodist_raid5rec_module_SOURCES) \
+ $(nodist_raid6rec_module_SOURCES) \
+ $(nodist_scsi_module_SOURCES) $(nodist_memdisk_module_SOURCES) \
+ $(am__append_2582) $(am__append_2589) $(am__append_2596) \
+ $(am__append_2603) $(am__append_2610) $(am__append_2617) \
+ $(am__append_2624) $(am__append_2631) $(am__append_2638) \
+ $(am__append_2645) $(am__append_2652) $(am__append_2659) \
+ $(am__append_2666) $(am__append_2673) $(am__append_2680) \
+ $(am__append_2687) $(am__append_2694) $(am__append_2701) \
+ $(am__append_2708) $(am__append_2715) $(am__append_2722) \
+ $(am__append_2729) $(am__append_2736) $(am__append_2743) \
+ $(am__append_2750) $(am__append_2757) $(am__append_2764) \
+ $(am__append_2771) $(am__append_2778) $(am__append_2785) \
+ $(am__append_2792) $(am__append_2799) $(am__append_2806) \
+ $(am__append_2813) $(am__append_2820) $(am__append_2827) \
+ $(am__append_2834) $(am__append_2841) $(am__append_2848) \
+ $(am__append_2855) $(am__append_2862) $(am__append_2869) \
+ $(am__append_2876) $(am__append_2883) $(am__append_2890) \
+ $(am__append_2897) $(am__append_2904) $(am__append_2911) \
+ $(am__append_2918) $(am__append_2925) $(am__append_2932) \
+ $(am__append_2939) $(am__append_2946) $(am__append_2953) \
+ $(am__append_2960) $(am__append_2967) $(am__append_2974) \
+ $(am__append_2981) $(am__append_2988) $(am__append_2995) \
+ $(am__append_3002) $(nodist_procfs_module_SOURCES) \
+ $(nodist_affs_module_SOURCES) $(nodist_afs_module_SOURCES) \
+ $(nodist_bfs_module_SOURCES) $(nodist_zstd_module_SOURCES) \
+ $(nodist_btrfs_module_SOURCES) \
+ $(nodist_archelp_module_SOURCES) $(nodist_cbfs_module_SOURCES) \
+ $(nodist_cpio_module_SOURCES) $(nodist_cpio_be_module_SOURCES) \
+ $(nodist_newc_module_SOURCES) $(nodist_odc_module_SOURCES) \
+ $(nodist_ext2_module_SOURCES) $(nodist_fat_module_SOURCES) \
+ $(nodist_exfat_module_SOURCES) $(nodist_f2fs_module_SOURCES) \
+ $(nodist_fshelp_module_SOURCES) $(nodist_hfs_module_SOURCES) \
+ $(nodist_hfsplus_module_SOURCES) \
+ $(nodist_hfspluscomp_module_SOURCES) \
+ $(nodist_iso9660_module_SOURCES) $(nodist_jfs_module_SOURCES) \
+ $(nodist_minix_module_SOURCES) $(nodist_minix2_module_SOURCES) \
+ $(nodist_minix3_module_SOURCES) \
+ $(nodist_minix_be_module_SOURCES) \
+ $(nodist_minix2_be_module_SOURCES) \
+ $(nodist_minix3_be_module_SOURCES) \
+ $(nodist_nilfs2_module_SOURCES) $(nodist_ntfs_module_SOURCES) \
+ $(nodist_ntfscomp_module_SOURCES) \
+ $(nodist_reiserfs_module_SOURCES) \
+ $(nodist_romfs_module_SOURCES) $(nodist_sfs_module_SOURCES) \
+ $(nodist_squash4_module_SOURCES) $(nodist_tar_module_SOURCES) \
+ $(nodist_udf_module_SOURCES) $(nodist_ufs1_module_SOURCES) \
+ $(nodist_ufs1_be_module_SOURCES) $(nodist_ufs2_module_SOURCES) \
+ $(nodist_xfs_module_SOURCES) $(nodist_zfs_module_SOURCES) \
+ $(nodist_zfscrypt_module_SOURCES) \
+ $(nodist_zfsinfo_module_SOURCES) \
+ $(nodist_macbless_module_SOURCES) $(am__append_3009) \
+ $(nodist_gettext_module_SOURCES) \
+ $(nodist_gfxmenu_module_SOURCES) \
+ $(nodist_hello_module_SOURCES) $(nodist_gzio_module_SOURCES) \
+ $(nodist_offsetio_module_SOURCES) $(am__append_3016) \
+ $(am__append_3023) $(am__append_3030) $(am__append_3037) \
+ $(am__append_3044) $(am__append_3051) $(am__append_3058) \
+ $(am__append_3065) $(am__append_3072) $(am__append_3079) \
+ $(am__append_3086) $(am__append_3093) $(am__append_3100) \
+ $(am__append_3107) $(am__append_3114) $(am__append_3121) \
+ $(am__append_3128) $(am__append_3135) $(am__append_3142) \
+ $(am__append_3149) $(nodist_elf_module_SOURCES) \
+ $(nodist_crypto_module_SOURCES) \
+ $(nodist_pbkdf2_module_SOURCES) $(am__append_3156) \
+ $(am__append_3163) $(am__append_3170) $(am__append_3177) \
+ $(am__append_3184) $(am__append_3191) $(am__append_3198) \
+ $(am__append_3205) $(am__append_3212) $(am__append_3219) \
+ $(am__append_3226) $(am__append_3233) $(am__append_3240) \
+ $(am__append_3247) $(am__append_3254) $(am__append_3261) \
+ $(am__append_3268) $(am__append_3275) $(am__append_3282) \
+ $(am__append_3289) $(am__append_3296) $(am__append_3303) \
+ $(am__append_3310) $(am__append_3317) $(am__append_3324) \
+ $(am__append_3331) $(am__append_3338) $(am__append_3345) \
+ $(am__append_3352) $(am__append_3359) $(am__append_3366) \
+ $(am__append_3373) $(am__append_3380) $(am__append_3387) \
+ $(am__append_3394) $(am__append_3401) $(am__append_3408) \
+ $(nodist_setjmp_module_SOURCES) $(am__append_3415) \
+ $(am__append_3422) $(am__append_3429) $(am__append_3436) \
+ $(am__append_3443) $(am__append_3450) $(am__append_3457) \
+ $(am__append_3464) $(am__append_3471) $(am__append_3478) \
+ $(am__append_3485) $(am__append_3492) $(am__append_3499) \
+ $(am__append_3506) $(am__append_3513) $(am__append_3520) \
+ $(am__append_3527) $(am__append_3534) $(am__append_3541) \
+ $(am__append_3548) $(am__append_3555) $(am__append_3562) \
+ $(am__append_3569) $(am__append_3576) $(am__append_3583) \
+ $(am__append_3590) $(am__append_3597) $(am__append_3604) \
+ $(am__append_3611) $(am__append_3618) $(am__append_3625) \
+ $(am__append_3632) $(am__append_3639) $(am__append_3646) \
+ $(am__append_3653) $(am__append_3660) $(am__append_3667) \
+ $(am__append_3674) $(am__append_3681) $(am__append_3688) \
+ $(am__append_3695) $(am__append_3702) $(am__append_3709) \
+ $(am__append_3716) $(am__append_3723) $(am__append_3730) \
+ $(am__append_3737) $(am__append_3744) $(am__append_3751) \
+ $(am__append_3758) $(am__append_3765) $(am__append_3772) \
+ $(am__append_3779) $(am__append_3786) $(am__append_3793) \
+ $(am__append_3800) $(am__append_3807) $(am__append_3814) \
+ $(am__append_3821) $(am__append_3828) $(am__append_3835) \
+ $(am__append_3842) $(am__append_3849) $(am__append_3856) \
+ $(am__append_3863) $(am__append_3870) $(am__append_3877) \
+ $(am__append_3884) $(am__append_3891) $(am__append_3898) \
+ $(am__append_3905) $(am__append_3912) $(am__append_3919) \
+ $(am__append_3926) $(am__append_3933) $(am__append_3940) \
+ $(am__append_3947) $(am__append_3954) \
+ $(nodist_macho_module_SOURCES) $(am__append_3961) \
+ $(am__append_3968) $(am__append_3975) $(am__append_3982) \
+ $(am__append_3989) $(am__append_3996) $(am__append_4003) \
+ $(am__append_4010) $(am__append_4017) $(am__append_4024) \
+ $(am__append_4031) $(am__append_4038) $(am__append_4045) \
+ $(am__append_4052) $(am__append_4059) $(am__append_4066) \
+ $(am__append_4073) $(am__append_4080) $(am__append_4087) \
+ $(am__append_4094) $(am__append_4101) $(am__append_4108) \
+ $(am__append_4115) $(am__append_4122) $(am__append_4129) \
+ $(am__append_4136) $(am__append_4143) \
+ $(nodist_normal_module_SOURCES) \
+ $(nodist_part_acorn_module_SOURCES) \
+ $(nodist_part_amiga_module_SOURCES) \
+ $(nodist_part_apple_module_SOURCES) \
+ $(nodist_part_gpt_module_SOURCES) \
+ $(nodist_part_msdos_module_SOURCES) \
+ $(nodist_part_sun_module_SOURCES) \
+ $(nodist_part_plan_module_SOURCES) \
+ $(nodist_part_dvh_module_SOURCES) \
+ $(nodist_part_bsd_module_SOURCES) \
+ $(nodist_part_sunpc_module_SOURCES) \
+ $(nodist_part_dfly_module_SOURCES) \
+ $(nodist_msdospart_module_SOURCES) $(am__append_4150) \
+ $(am__append_4157) $(am__append_4164) $(am__append_4171) \
+ $(am__append_4178) $(am__append_4185) $(am__append_4192) \
+ $(am__append_4199) $(am__append_4206) $(am__append_4213) \
+ $(am__append_4220) $(am__append_4227) $(am__append_4234) \
+ $(am__append_4241) $(am__append_4248) $(am__append_4255) \
+ $(am__append_4262) $(am__append_4269) $(am__append_4276) \
+ $(am__append_4283) $(am__append_4290) $(am__append_4297) \
+ $(am__append_4304) $(am__append_4311) $(am__append_4318) \
+ $(am__append_4325) $(am__append_4332) \
+ $(nodist_gfxterm_background_module_SOURCES) $(am__append_4339) \
+ $(am__append_4346) $(am__append_4353) $(am__append_4360) \
+ $(am__append_4367) $(am__append_4374) $(am__append_4381) \
+ $(am__append_4388) $(am__append_4395) $(am__append_4402) \
+ $(am__append_4409) $(am__append_4416) $(am__append_4423) \
+ $(am__append_4430) $(am__append_4437) $(am__append_4444) \
+ $(am__append_4451) $(am__append_4458) $(am__append_4465) \
+ $(am__append_4472) $(am__append_4479) $(am__append_4486) \
+ $(am__append_4493) $(am__append_4500) $(am__append_4507) \
+ $(am__append_4514) $(am__append_4521) $(am__append_4528) \
+ $(am__append_4535) $(am__append_4542) $(am__append_4549) \
+ $(am__append_4556) $(am__append_4563) $(am__append_4570) \
+ $(am__append_4577) $(am__append_4584) $(am__append_4591) \
+ $(am__append_4598) $(am__append_4605) $(am__append_4612) \
+ $(am__append_4619) $(am__append_4626) $(am__append_4633) \
+ $(am__append_4640) $(am__append_4647) $(am__append_4654) \
+ $(am__append_4661) $(am__append_4668) $(am__append_4675) \
+ $(am__append_4682) $(am__append_4689) $(am__append_4696) \
+ $(am__append_4703) $(am__append_4710) $(am__append_4717) \
+ $(nodist_functional_test_module_SOURCES) \
+ $(nodist_exfctest_module_SOURCES) \
+ $(nodist_strtoull_test_module_SOURCES) \
+ $(nodist_setjmp_test_module_SOURCES) \
+ $(nodist_signature_test_module_SOURCES) \
+ $(nodist_sleep_test_module_SOURCES) \
+ $(nodist_xnu_uuid_test_module_SOURCES) \
+ $(nodist_pbkdf2_test_module_SOURCES) $(am__append_4724) \
+ $(am__append_4731) $(am__append_4738) $(am__append_4745) \
+ $(am__append_4752) $(am__append_4759) $(am__append_4766) \
+ $(am__append_4773) $(am__append_4780) $(am__append_4787) \
+ $(am__append_4794) $(am__append_4801) $(am__append_4808) \
+ $(am__append_4815) $(am__append_4822) $(am__append_4829) \
+ $(am__append_4836) $(am__append_4843) $(am__append_4850) \
+ $(am__append_4857) $(am__append_4864) $(am__append_4871) \
+ $(am__append_4878) $(am__append_4885) $(am__append_4892) \
+ $(nodist_div_test_module_SOURCES) \
+ $(nodist_mul_test_module_SOURCES) \
+ $(nodist_shift_test_module_SOURCES) \
+ $(nodist_cmp_test_module_SOURCES) \
+ $(nodist_ctz_test_module_SOURCES) \
+ $(nodist_bswap_test_module_SOURCES) \
+ $(nodist_videotest_checksum_module_SOURCES) \
+ $(nodist_gfxterm_menu_module_SOURCES) \
+ $(nodist_cmdline_cat_test_module_SOURCES) \
+ $(nodist_bitmap_module_SOURCES) \
+ $(nodist_bitmap_scale_module_SOURCES) $(am__append_4899) \
+ $(am__append_4906) $(am__append_4913) $(am__append_4920) \
+ $(am__append_4927) $(am__append_4934) $(am__append_4941) \
+ $(am__append_4948) $(am__append_4955) \
+ $(nodist_jpeg_module_SOURCES) $(nodist_png_module_SOURCES) \
+ $(nodist_tga_module_SOURCES) $(am__append_4962) \
+ $(am__append_4969) $(am__append_4976) $(am__append_4983) \
+ $(am__append_4990) $(am__append_4997) $(am__append_5004) \
+ $(am__append_5011) $(am__append_5018) $(am__append_5025) \
+ $(am__append_5032) $(am__append_5039) $(am__append_5046) \
+ $(am__append_5053) $(am__append_5060) $(am__append_5067) \
+ $(am__append_5074) $(am__append_5081) $(am__append_5088) \
+ $(am__append_5095) $(am__append_5102) $(am__append_5109) \
+ $(am__append_5116) $(am__append_5123) $(am__append_5130) \
+ $(am__append_5137) $(am__append_5144) $(am__append_5151) \
+ $(am__append_5158) $(am__append_5165) $(am__append_5172) \
+ $(am__append_5179) $(am__append_5186) $(am__append_5193) \
+ $(am__append_5200) $(am__append_5207) $(am__append_5214) \
+ $(am__append_5221) $(am__append_5228) $(am__append_5235) \
+ $(am__append_5242) $(nodist_video_colors_module_SOURCES) \
+ $(am__append_5249) $(am__append_5256) \
+ $(nodist_datehook_module_SOURCES) $(nodist_net_module_SOURCES) \
+ $(nodist_tftp_module_SOURCES) $(nodist_http_module_SOURCES) \
+ $(am__append_5263) $(am__append_5270) $(am__append_5277) \
+ $(am__append_5284) $(am__append_5291) $(am__append_5298) \
+ $(am__append_5305) $(am__append_5312) $(am__append_5319) \
+ $(am__append_5326) $(am__append_5333) $(am__append_5340) \
+ $(am__append_5347) $(am__append_5354) $(am__append_5361) \
+ $(am__append_5368) $(am__append_5375) $(am__append_5382) \
+ $(nodist_syslinuxcfg_module_SOURCES) \
+ $(nodist_test_blockarg_module_SOURCES) \
+ $(nodist_xzio_module_SOURCES) $(nodist_lzopio_module_SOURCES) \
+ $(nodist_testload_module_SOURCES) $(am__append_5389) \
+ $(am__append_5396) $(am__append_5403) $(am__append_5410) \
+ $(am__append_5417) $(am__append_5424) $(am__append_5431) \
+ $(am__append_5438) $(am__append_5445) $(am__append_5452) \
+ $(am__append_5459) $(am__append_5466) $(am__append_5473) \
+ $(am__append_5480) $(am__append_5487) $(am__append_5494) \
+ $(am__append_5501) $(nodist_priority_queue_module_SOURCES) \
+ $(nodist_time_module_SOURCES) $(am__append_5508) \
+ $(am__append_5515) $(nodist_adler32_module_SOURCES) \
+ $(nodist_crc64_module_SOURCES) $(nodist_mpi_module_SOURCES) \
+ $(nodist_all_video_module_SOURCES) $(am__append_5522) \
+ $(am__append_5529) $(am__append_5536) $(am__append_5543) \
+ $(am__append_5550) $(am__append_5557) \
+ $(nodist_testspeed_module_SOURCES) $(am__append_5564) \
+ $(am__append_5571) $(am__append_5578) $(am__append_5585) \
+ $(am__append_5592) $(am__append_5599) $(am__append_5606) \
+ $(nodist_tr_module_SOURCES) $(nodist_progress_module_SOURCES) \
+ $(nodist_file_module_SOURCES) $(am__append_5613) \
+ $(am__append_5620) $(am__append_5627) $(am__append_5634) \
+ $(am__append_5641) $(am__append_5648) $(am__append_5655) \
+ $(am__append_5662) $(am__append_5669) $(am__append_5676) \
+ $(am__append_5683) $(am__append_5690) $(am__append_5697) \
+ $(am__append_5704) $(nodist_gcry_arcfour_module_SOURCES) \
+ $(nodist_gcry_blowfish_module_SOURCES) \
+ $(nodist_gcry_camellia_module_SOURCES) \
+ $(nodist_gcry_cast5_module_SOURCES) \
+ $(nodist_gcry_crc_module_SOURCES) \
+ $(nodist_gcry_des_module_SOURCES) \
+ $(nodist_gcry_dsa_module_SOURCES) \
+ $(nodist_gcry_idea_module_SOURCES) \
+ $(nodist_gcry_md4_module_SOURCES) \
+ $(nodist_gcry_md5_module_SOURCES) \
+ $(nodist_gcry_rfc2268_module_SOURCES) \
+ $(nodist_gcry_rijndael_module_SOURCES) \
+ $(nodist_gcry_rmd160_module_SOURCES) \
+ $(nodist_gcry_rsa_module_SOURCES) \
+ $(nodist_gcry_seed_module_SOURCES) \
+ $(nodist_gcry_serpent_module_SOURCES) \
+ $(nodist_gcry_sha1_module_SOURCES) \
+ $(nodist_gcry_sha256_module_SOURCES) \
+ $(nodist_gcry_sha512_module_SOURCES) \
+ $(nodist_gcry_tiger_module_SOURCES) \
+ $(nodist_gcry_twofish_module_SOURCES) \
+ $(nodist_gcry_whirlpool_module_SOURCES) $(am__append_5710) \
+ $(am__append_5715) $(am__append_5720) $(am__append_5725) \
+ $(am__append_5730) $(am__append_5735) $(am__append_5740) \
+ $(am__append_5745) $(am__append_5750) $(am__append_5755) \
+ $(am__append_5760) $(am__append_5765) $(am__append_5770) \
+ $(am__append_5775) $(am__append_5780) $(am__append_5785) \
+ $(am__append_5790) $(am__append_5795) $(am__append_5800) \
+ $(am__append_5805) $(am__append_5810) $(am__append_5815) \
+ $(am__append_5820) $(am__append_5825) $(am__append_5830) \
+ $(am__append_5835) $(am__append_5840) $(am__append_5845) \
+ $(am__append_5850) $(am__append_5855) $(am__append_5860) \
+ $(am__append_5865) $(am__append_5870) $(am__append_5875) \
+ $(am__append_5880) $(am__append_5885) $(am__append_5890) \
+ $(am__append_5895) $(am__append_5900) $(am__append_5907) \
+ symlist.h symlist.c
+MACHO2IMG = $(top_builddir)/grub-macho2img
+AM_CFLAGS = $(TARGET_CFLAGS)
+AM_LDFLAGS = $(TARGET_LDFLAGS)
+AM_CPPFLAGS = $(TARGET_CPPFLAGS) $(CPPFLAGS_DEFAULT)
+AM_CCASFLAGS = $(TARGET_CCASFLAGS) $(CCASFLAGS_DEFAULT)
+disk_module_SOURCES = lib/disk.c ## platform sources
+nodist_disk_module_SOURCES = ## platform nodist sources
+disk_module_LDADD =
+disk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+disk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+disk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+disk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+disk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+trig_module_SOURCES = ## platform sources
+nodist_trig_module_SOURCES = trigtables.c ## platform nodist sources
+trig_module_LDADD =
+trig_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+trig_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+trig_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+trig_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+trig_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+@COND_i386_efi_TRUE@cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+@COND_i386_ieee1275_TRUE@cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+@COND_i386_multiboot_TRUE@cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+@COND_i386_pc_TRUE@cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+@COND_i386_qemu_TRUE@cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+@COND_x86_64_efi_TRUE@cs5536_module_SOURCES = bus/cs5536.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_cs5536_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_cs5536_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_cs5536_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_cs5536_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_cs5536_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_cs5536_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_cs5536_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@cs5536_module_LDADD =
+@COND_i386_efi_TRUE@cs5536_module_LDADD =
+@COND_i386_ieee1275_TRUE@cs5536_module_LDADD =
+@COND_i386_multiboot_TRUE@cs5536_module_LDADD =
+@COND_i386_pc_TRUE@cs5536_module_LDADD =
+@COND_i386_qemu_TRUE@cs5536_module_LDADD =
+@COND_x86_64_efi_TRUE@cs5536_module_LDADD =
+@COND_i386_coreboot_TRUE@cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cs5536_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cs5536_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cs5536_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cs5536_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@cs5536_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@lsspd_module_SOURCES = commands/mips/loongson/lsspd.c ## platform sources
+@COND_mips_loongson_TRUE@nodist_lsspd_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@lsspd_module_LDADD =
+@COND_mips_loongson_TRUE@lsspd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@lsspd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@lsspd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@lsspd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@lsspd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+@COND_i386_coreboot_TRUE@usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+@COND_i386_efi_TRUE@usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+@COND_i386_ieee1275_TRUE@usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+@COND_i386_multiboot_TRUE@usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+@COND_i386_pc_TRUE@usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+@COND_i386_qemu_TRUE@usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+@COND_mips_loongson_TRUE@usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+@COND_x86_64_efi_TRUE@usb_module_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c ## platform sources
+@COND_arm_coreboot_TRUE@nodist_usb_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_usb_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_usb_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_usb_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_usb_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_usb_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_usb_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_usb_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_usb_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@usb_module_LDADD =
+@COND_i386_coreboot_TRUE@usb_module_LDADD =
+@COND_i386_efi_TRUE@usb_module_LDADD =
+@COND_i386_ieee1275_TRUE@usb_module_LDADD =
+@COND_i386_multiboot_TRUE@usb_module_LDADD =
+@COND_i386_pc_TRUE@usb_module_LDADD =
+@COND_i386_qemu_TRUE@usb_module_LDADD =
+@COND_mips_loongson_TRUE@usb_module_LDADD =
+@COND_x86_64_efi_TRUE@usb_module_LDADD =
+@COND_arm_coreboot_TRUE@usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@usb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+@COND_i386_coreboot_TRUE@usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+@COND_i386_efi_TRUE@usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+@COND_i386_ieee1275_TRUE@usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+@COND_i386_multiboot_TRUE@usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+@COND_i386_pc_TRUE@usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+@COND_i386_qemu_TRUE@usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+@COND_mips_loongson_TRUE@usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+@COND_x86_64_efi_TRUE@usbserial_common_module_SOURCES = bus/usb/serial/common.c ## platform sources
+@COND_arm_coreboot_TRUE@nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_usbserial_common_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@usbserial_common_module_LDADD =
+@COND_i386_coreboot_TRUE@usbserial_common_module_LDADD =
+@COND_i386_efi_TRUE@usbserial_common_module_LDADD =
+@COND_i386_ieee1275_TRUE@usbserial_common_module_LDADD =
+@COND_i386_multiboot_TRUE@usbserial_common_module_LDADD =
+@COND_i386_pc_TRUE@usbserial_common_module_LDADD =
+@COND_i386_qemu_TRUE@usbserial_common_module_LDADD =
+@COND_mips_loongson_TRUE@usbserial_common_module_LDADD =
+@COND_x86_64_efi_TRUE@usbserial_common_module_LDADD =
+@COND_arm_coreboot_TRUE@usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_common_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_common_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_common_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_common_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@usbserial_common_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+@COND_i386_coreboot_TRUE@usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+@COND_i386_efi_TRUE@usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+@COND_i386_ieee1275_TRUE@usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+@COND_i386_multiboot_TRUE@usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+@COND_i386_pc_TRUE@usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+@COND_i386_qemu_TRUE@usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+@COND_mips_loongson_TRUE@usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+@COND_x86_64_efi_TRUE@usbserial_pl2303_module_SOURCES = bus/usb/serial/pl2303.c ## platform sources
+@COND_arm_coreboot_TRUE@nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_usbserial_pl2303_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@usbserial_pl2303_module_LDADD =
+@COND_i386_coreboot_TRUE@usbserial_pl2303_module_LDADD =
+@COND_i386_efi_TRUE@usbserial_pl2303_module_LDADD =
+@COND_i386_ieee1275_TRUE@usbserial_pl2303_module_LDADD =
+@COND_i386_multiboot_TRUE@usbserial_pl2303_module_LDADD =
+@COND_i386_pc_TRUE@usbserial_pl2303_module_LDADD =
+@COND_i386_qemu_TRUE@usbserial_pl2303_module_LDADD =
+@COND_mips_loongson_TRUE@usbserial_pl2303_module_LDADD =
+@COND_x86_64_efi_TRUE@usbserial_pl2303_module_LDADD =
+@COND_arm_coreboot_TRUE@usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_pl2303_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_pl2303_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_pl2303_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_pl2303_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@usbserial_pl2303_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+@COND_i386_coreboot_TRUE@usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+@COND_i386_efi_TRUE@usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+@COND_i386_ieee1275_TRUE@usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+@COND_i386_multiboot_TRUE@usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+@COND_i386_pc_TRUE@usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+@COND_i386_qemu_TRUE@usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+@COND_mips_loongson_TRUE@usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+@COND_x86_64_efi_TRUE@usbserial_ftdi_module_SOURCES = bus/usb/serial/ftdi.c ## platform sources
+@COND_arm_coreboot_TRUE@nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_usbserial_ftdi_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@usbserial_ftdi_module_LDADD =
+@COND_i386_coreboot_TRUE@usbserial_ftdi_module_LDADD =
+@COND_i386_efi_TRUE@usbserial_ftdi_module_LDADD =
+@COND_i386_ieee1275_TRUE@usbserial_ftdi_module_LDADD =
+@COND_i386_multiboot_TRUE@usbserial_ftdi_module_LDADD =
+@COND_i386_pc_TRUE@usbserial_ftdi_module_LDADD =
+@COND_i386_qemu_TRUE@usbserial_ftdi_module_LDADD =
+@COND_mips_loongson_TRUE@usbserial_ftdi_module_LDADD =
+@COND_x86_64_efi_TRUE@usbserial_ftdi_module_LDADD =
+@COND_arm_coreboot_TRUE@usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_ftdi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_ftdi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_ftdi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_ftdi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@usbserial_ftdi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+@COND_i386_coreboot_TRUE@usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+@COND_i386_efi_TRUE@usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+@COND_i386_ieee1275_TRUE@usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+@COND_i386_multiboot_TRUE@usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+@COND_i386_pc_TRUE@usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+@COND_i386_qemu_TRUE@usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+@COND_mips_loongson_TRUE@usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+@COND_x86_64_efi_TRUE@usbserial_usbdebug_module_SOURCES = bus/usb/serial/usbdebug_late.c ## platform sources
+@COND_arm_coreboot_TRUE@nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_usbserial_usbdebug_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@usbserial_usbdebug_module_LDADD =
+@COND_i386_coreboot_TRUE@usbserial_usbdebug_module_LDADD =
+@COND_i386_efi_TRUE@usbserial_usbdebug_module_LDADD =
+@COND_i386_ieee1275_TRUE@usbserial_usbdebug_module_LDADD =
+@COND_i386_multiboot_TRUE@usbserial_usbdebug_module_LDADD =
+@COND_i386_pc_TRUE@usbserial_usbdebug_module_LDADD =
+@COND_i386_qemu_TRUE@usbserial_usbdebug_module_LDADD =
+@COND_mips_loongson_TRUE@usbserial_usbdebug_module_LDADD =
+@COND_x86_64_efi_TRUE@usbserial_usbdebug_module_LDADD =
+@COND_arm_coreboot_TRUE@usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_usbdebug_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_usbdebug_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_usbdebug_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbserial_usbdebug_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@usbserial_usbdebug_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+@COND_i386_efi_TRUE@uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+@COND_i386_ieee1275_TRUE@uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+@COND_i386_multiboot_TRUE@uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+@COND_i386_pc_TRUE@uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+@COND_i386_qemu_TRUE@uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+@COND_mips_loongson_TRUE@uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+@COND_x86_64_efi_TRUE@uhci_module_SOURCES = bus/usb/uhci.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_uhci_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_uhci_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_uhci_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_uhci_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_uhci_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_uhci_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_uhci_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_uhci_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@uhci_module_LDADD =
+@COND_i386_efi_TRUE@uhci_module_LDADD =
+@COND_i386_ieee1275_TRUE@uhci_module_LDADD =
+@COND_i386_multiboot_TRUE@uhci_module_LDADD =
+@COND_i386_pc_TRUE@uhci_module_LDADD =
+@COND_i386_qemu_TRUE@uhci_module_LDADD =
+@COND_mips_loongson_TRUE@uhci_module_LDADD =
+@COND_x86_64_efi_TRUE@uhci_module_LDADD =
+@COND_i386_coreboot_TRUE@uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@uhci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@uhci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@uhci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@uhci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@uhci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+@COND_i386_efi_TRUE@ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+@COND_i386_ieee1275_TRUE@ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+@COND_i386_multiboot_TRUE@ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+@COND_i386_pc_TRUE@ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+@COND_i386_qemu_TRUE@ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+@COND_mips_loongson_TRUE@ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+@COND_x86_64_efi_TRUE@ohci_module_SOURCES = bus/usb/ohci.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_ohci_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_ohci_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_ohci_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_ohci_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_ohci_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_ohci_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_ohci_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_ohci_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@ohci_module_LDADD =
+@COND_i386_efi_TRUE@ohci_module_LDADD =
+@COND_i386_ieee1275_TRUE@ohci_module_LDADD =
+@COND_i386_multiboot_TRUE@ohci_module_LDADD =
+@COND_i386_pc_TRUE@ohci_module_LDADD =
+@COND_i386_qemu_TRUE@ohci_module_LDADD =
+@COND_mips_loongson_TRUE@ohci_module_LDADD =
+@COND_x86_64_efi_TRUE@ohci_module_LDADD =
+@COND_i386_coreboot_TRUE@ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ohci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ohci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ohci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ohci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@ohci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@ehci_module_SOURCES = bus/usb/ehci-fdt.c bus/usb/ehci.c ## platform sources
+@COND_i386_coreboot_TRUE@ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+@COND_i386_efi_TRUE@ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+@COND_i386_ieee1275_TRUE@ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+@COND_i386_multiboot_TRUE@ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+@COND_i386_pc_TRUE@ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+@COND_i386_qemu_TRUE@ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+@COND_mips_loongson_TRUE@ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+@COND_x86_64_efi_TRUE@ehci_module_SOURCES = bus/usb/ehci-pci.c bus/usb/ehci.c ## platform sources
+@COND_arm_coreboot_TRUE@nodist_ehci_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_ehci_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_ehci_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_ehci_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_ehci_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_ehci_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_ehci_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_ehci_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_ehci_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@ehci_module_LDADD =
+@COND_i386_coreboot_TRUE@ehci_module_LDADD =
+@COND_i386_efi_TRUE@ehci_module_LDADD =
+@COND_i386_ieee1275_TRUE@ehci_module_LDADD =
+@COND_i386_multiboot_TRUE@ehci_module_LDADD =
+@COND_i386_pc_TRUE@ehci_module_LDADD =
+@COND_i386_qemu_TRUE@ehci_module_LDADD =
+@COND_mips_loongson_TRUE@ehci_module_LDADD =
+@COND_x86_64_efi_TRUE@ehci_module_LDADD =
+@COND_arm_coreboot_TRUE@ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ehci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ehci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ehci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ehci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@ehci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@pci_module_SOURCES = bus/pci.c ## platform sources
+@COND_i386_ieee1275_TRUE@pci_module_SOURCES = bus/i386/ieee1275/pci.c bus/pci.c ## platform sources
+@COND_i386_multiboot_TRUE@pci_module_SOURCES = bus/pci.c ## platform sources
+@COND_i386_pc_TRUE@pci_module_SOURCES = bus/pci.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_pci_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_pci_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_pci_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_pci_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@pci_module_LDADD =
+@COND_i386_ieee1275_TRUE@pci_module_LDADD =
+@COND_i386_multiboot_TRUE@pci_module_LDADD =
+@COND_i386_pc_TRUE@pci_module_LDADD =
+@COND_i386_coreboot_TRUE@pci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@pci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@pci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@pci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@pci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@pci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@pci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@pci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+@COND_i386_efi_TRUE@nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+@COND_i386_ieee1275_TRUE@nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+@COND_i386_multiboot_TRUE@nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+@COND_i386_pc_TRUE@nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+@COND_i386_qemu_TRUE@nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+@COND_mips_loongson_TRUE@nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+@COND_mips_qemu_mips_TRUE@nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+@COND_x86_64_efi_TRUE@nativedisk_module_SOURCES = commands/nativedisk.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_nativedisk_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_nativedisk_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_nativedisk_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_nativedisk_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_nativedisk_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_nativedisk_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_nativedisk_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_nativedisk_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_nativedisk_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nativedisk_module_LDADD =
+@COND_i386_efi_TRUE@nativedisk_module_LDADD =
+@COND_i386_ieee1275_TRUE@nativedisk_module_LDADD =
+@COND_i386_multiboot_TRUE@nativedisk_module_LDADD =
+@COND_i386_pc_TRUE@nativedisk_module_LDADD =
+@COND_i386_qemu_TRUE@nativedisk_module_LDADD =
+@COND_mips_loongson_TRUE@nativedisk_module_LDADD =
+@COND_mips_qemu_mips_TRUE@nativedisk_module_LDADD =
+@COND_x86_64_efi_TRUE@nativedisk_module_LDADD =
+@COND_i386_coreboot_TRUE@nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@nativedisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@nativedisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@nativedisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@nativedisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@nativedisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@emupci_module_SOURCES = bus/emu/pci.c commands/lspci.c ## platform sources
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@nodist_emupci_module_SOURCES = ## platform nodist sources
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@emupci_module_LDADD =
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@emupci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@emupci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@emupci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@emupci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@emupci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@lsdev_module_SOURCES = commands/arc/lsdev.c ## platform sources
+@COND_mips_arc_TRUE@nodist_lsdev_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@lsdev_module_LDADD =
+@COND_mips_arc_TRUE@lsdev_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@lsdev_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@lsdev_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@lsdev_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@lsdev_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@lsxen_module_SOURCES = commands/xen/lsxen.c ## platform sources
+@COND_x86_64_xen_TRUE@lsxen_module_SOURCES = commands/xen/lsxen.c ## platform sources
+@COND_i386_xen_TRUE@nodist_lsxen_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_lsxen_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@lsxen_module_LDADD =
+@COND_x86_64_xen_TRUE@lsxen_module_LDADD =
+@COND_i386_xen_TRUE@lsxen_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@lsxen_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@lsxen_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@lsxen_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@lsxen_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@lsxen_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@lsxen_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@lsxen_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@lsxen_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@lsxen_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+@COND_i386_ieee1275_TRUE@cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+@COND_i386_multiboot_TRUE@cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+@COND_i386_pc_TRUE@cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+@COND_i386_qemu_TRUE@cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+@COND_mips_loongson_TRUE@cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+@COND_mips_qemu_mips_TRUE@cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@cmostest_module_SOURCES = commands/i386/cmostest.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_cmostest_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_cmostest_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_cmostest_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_cmostest_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_cmostest_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_cmostest_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_cmostest_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_cmostest_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_cmostest_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@cmostest_module_LDADD =
+@COND_i386_ieee1275_TRUE@cmostest_module_LDADD =
+@COND_i386_multiboot_TRUE@cmostest_module_LDADD =
+@COND_i386_pc_TRUE@cmostest_module_LDADD =
+@COND_i386_qemu_TRUE@cmostest_module_LDADD =
+@COND_mips_loongson_TRUE@cmostest_module_LDADD =
+@COND_mips_qemu_mips_TRUE@cmostest_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@cmostest_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@cmostest_module_LDADD =
+@COND_i386_coreboot_TRUE@cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@cmostest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@cmostest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@cmostest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@cmostest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@cmostest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+@COND_i386_ieee1275_TRUE@cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+@COND_i386_multiboot_TRUE@cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+@COND_i386_pc_TRUE@cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+@COND_i386_qemu_TRUE@cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+@COND_mips_loongson_TRUE@cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+@COND_mips_qemu_mips_TRUE@cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@cmosdump_module_SOURCES = commands/i386/cmosdump.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_cmosdump_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_cmosdump_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_cmosdump_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_cmosdump_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_cmosdump_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_cmosdump_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_cmosdump_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_cmosdump_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_cmosdump_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@cmosdump_module_LDADD =
+@COND_i386_ieee1275_TRUE@cmosdump_module_LDADD =
+@COND_i386_multiboot_TRUE@cmosdump_module_LDADD =
+@COND_i386_pc_TRUE@cmosdump_module_LDADD =
+@COND_i386_qemu_TRUE@cmosdump_module_LDADD =
+@COND_mips_loongson_TRUE@cmosdump_module_LDADD =
+@COND_mips_qemu_mips_TRUE@cmosdump_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@cmosdump_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@cmosdump_module_LDADD =
+@COND_i386_coreboot_TRUE@cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@cmosdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@cmosdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@cmosdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@cmosdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@cmosdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@iorw_module_SOURCES = commands/iorw.c ## platform sources
+@COND_i386_efi_TRUE@iorw_module_SOURCES = commands/iorw.c ## platform sources
+@COND_i386_ieee1275_TRUE@iorw_module_SOURCES = commands/iorw.c ## platform sources
+@COND_i386_multiboot_TRUE@iorw_module_SOURCES = commands/iorw.c ## platform sources
+@COND_i386_pc_TRUE@iorw_module_SOURCES = commands/iorw.c ## platform sources
+@COND_i386_qemu_TRUE@iorw_module_SOURCES = commands/iorw.c ## platform sources
+@COND_x86_64_efi_TRUE@iorw_module_SOURCES = commands/iorw.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_iorw_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_iorw_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_iorw_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_iorw_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_iorw_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_iorw_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_iorw_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@iorw_module_LDADD =
+@COND_i386_efi_TRUE@iorw_module_LDADD =
+@COND_i386_ieee1275_TRUE@iorw_module_LDADD =
+@COND_i386_multiboot_TRUE@iorw_module_LDADD =
+@COND_i386_pc_TRUE@iorw_module_LDADD =
+@COND_i386_qemu_TRUE@iorw_module_LDADD =
+@COND_x86_64_efi_TRUE@iorw_module_LDADD =
+@COND_i386_coreboot_TRUE@iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@iorw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@iorw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@iorw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@iorw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@iorw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+@COND_i386_ieee1275_TRUE@cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+@COND_i386_multiboot_TRUE@cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+@COND_i386_pc_TRUE@cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+@COND_i386_qemu_TRUE@cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+@COND_x86_64_efi_TRUE@cbtable_module_SOURCES = kern/i386/coreboot/cbtable.c kern/coreboot/cbtable.c ## platform sources
+@COND_i386_efi_TRUE@nodist_cbtable_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_cbtable_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_cbtable_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_cbtable_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_cbtable_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_cbtable_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@cbtable_module_LDADD =
+@COND_i386_ieee1275_TRUE@cbtable_module_LDADD =
+@COND_i386_multiboot_TRUE@cbtable_module_LDADD =
+@COND_i386_pc_TRUE@cbtable_module_LDADD =
+@COND_i386_qemu_TRUE@cbtable_module_LDADD =
+@COND_x86_64_efi_TRUE@cbtable_module_LDADD =
+@COND_i386_efi_TRUE@cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbtable_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbtable_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbtable_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbtable_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@cbtable_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+@COND_i386_efi_TRUE@cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+@COND_i386_ieee1275_TRUE@cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+@COND_i386_multiboot_TRUE@cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+@COND_i386_pc_TRUE@cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+@COND_i386_qemu_TRUE@cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+@COND_x86_64_efi_TRUE@cbtime_module_SOURCES = commands/i386/coreboot/cb_timestamps.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_cbtime_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_cbtime_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_cbtime_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_cbtime_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_cbtime_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_cbtime_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_cbtime_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@cbtime_module_LDADD =
+@COND_i386_efi_TRUE@cbtime_module_LDADD =
+@COND_i386_ieee1275_TRUE@cbtime_module_LDADD =
+@COND_i386_multiboot_TRUE@cbtime_module_LDADD =
+@COND_i386_pc_TRUE@cbtime_module_LDADD =
+@COND_i386_qemu_TRUE@cbtime_module_LDADD =
+@COND_x86_64_efi_TRUE@cbtime_module_LDADD =
+@COND_i386_coreboot_TRUE@cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbtime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbtime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbtime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbtime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@cbtime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+@COND_i386_efi_TRUE@cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+@COND_i386_ieee1275_TRUE@cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+@COND_i386_multiboot_TRUE@cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+@COND_i386_pc_TRUE@cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+@COND_i386_qemu_TRUE@cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+@COND_x86_64_efi_TRUE@cbls_module_SOURCES = commands/i386/coreboot/cbls.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_cbls_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_cbls_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_cbls_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_cbls_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_cbls_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_cbls_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_cbls_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@cbls_module_LDADD =
+@COND_i386_efi_TRUE@cbls_module_LDADD =
+@COND_i386_ieee1275_TRUE@cbls_module_LDADD =
+@COND_i386_multiboot_TRUE@cbls_module_LDADD =
+@COND_i386_pc_TRUE@cbls_module_LDADD =
+@COND_i386_qemu_TRUE@cbls_module_LDADD =
+@COND_x86_64_efi_TRUE@cbls_module_LDADD =
+@COND_i386_coreboot_TRUE@cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@cbls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+@COND_i386_efi_TRUE@cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+@COND_i386_ieee1275_TRUE@cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+@COND_i386_multiboot_TRUE@cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+@COND_i386_pc_TRUE@cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+@COND_i386_qemu_TRUE@cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+@COND_x86_64_efi_TRUE@cbmemc_module_SOURCES = term/i386/coreboot/cbmemc.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_cbmemc_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_cbmemc_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_cbmemc_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_cbmemc_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_cbmemc_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_cbmemc_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_cbmemc_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@cbmemc_module_LDADD =
+@COND_i386_efi_TRUE@cbmemc_module_LDADD =
+@COND_i386_ieee1275_TRUE@cbmemc_module_LDADD =
+@COND_i386_multiboot_TRUE@cbmemc_module_LDADD =
+@COND_i386_pc_TRUE@cbmemc_module_LDADD =
+@COND_i386_qemu_TRUE@cbmemc_module_LDADD =
+@COND_x86_64_efi_TRUE@cbmemc_module_LDADD =
+@COND_i386_coreboot_TRUE@cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbmemc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbmemc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbmemc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cbmemc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@cbmemc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+regexp_module_SOURCES = commands/regexp.c commands/wildcard.c lib/gnulib/regex.c ## platform sources
+nodist_regexp_module_SOURCES = ## platform nodist sources
+regexp_module_LDADD =
+regexp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) $(CFLAGS_GNULIB)
+regexp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+regexp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)
+regexp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+regexp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@acpi_module_SOURCES = commands/acpi.c ## platform sources
+@COND_arm_efi_TRUE@acpi_module_SOURCES = commands/acpi.c ## platform sources
+@COND_i386_coreboot_TRUE@acpi_module_SOURCES = commands/acpi.c ## platform sources
+@COND_i386_efi_TRUE@acpi_module_SOURCES = commands/acpi.c ## platform sources
+@COND_i386_multiboot_TRUE@acpi_module_SOURCES = commands/acpi.c ## platform sources
+@COND_i386_pc_TRUE@acpi_module_SOURCES = kern/acpi.c kern/i386/pc/acpi.c commands/acpi.c ## platform sources
+@COND_ia64_efi_TRUE@acpi_module_SOURCES = commands/acpi.c ## platform sources
+@COND_riscv32_efi_TRUE@acpi_module_SOURCES = commands/acpi.c ## platform sources
+@COND_riscv64_efi_TRUE@acpi_module_SOURCES = commands/acpi.c ## platform sources
+@COND_x86_64_efi_TRUE@acpi_module_SOURCES = commands/acpi.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_acpi_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_acpi_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_acpi_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_acpi_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_acpi_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_acpi_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_acpi_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_acpi_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_acpi_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_acpi_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@acpi_module_LDADD =
+@COND_arm_efi_TRUE@acpi_module_LDADD =
+@COND_i386_coreboot_TRUE@acpi_module_LDADD =
+@COND_i386_efi_TRUE@acpi_module_LDADD =
+@COND_i386_multiboot_TRUE@acpi_module_LDADD =
+@COND_i386_pc_TRUE@acpi_module_LDADD =
+@COND_ia64_efi_TRUE@acpi_module_LDADD =
+@COND_riscv32_efi_TRUE@acpi_module_LDADD =
+@COND_riscv64_efi_TRUE@acpi_module_LDADD =
+@COND_x86_64_efi_TRUE@acpi_module_LDADD =
+@COND_arm64_efi_TRUE@acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@acpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@acpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@acpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@acpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@acpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+@COND_arm_efi_TRUE@lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+@COND_i386_coreboot_TRUE@lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+@COND_i386_efi_TRUE@lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+@COND_i386_multiboot_TRUE@lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+@COND_i386_pc_TRUE@lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+@COND_ia64_efi_TRUE@lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+@COND_riscv32_efi_TRUE@lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+@COND_riscv64_efi_TRUE@lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+@COND_x86_64_efi_TRUE@lsacpi_module_SOURCES = commands/lsacpi.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_lsacpi_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_lsacpi_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_lsacpi_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_lsacpi_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_lsacpi_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_lsacpi_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_lsacpi_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_lsacpi_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_lsacpi_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_lsacpi_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@lsacpi_module_LDADD =
+@COND_arm_efi_TRUE@lsacpi_module_LDADD =
+@COND_i386_coreboot_TRUE@lsacpi_module_LDADD =
+@COND_i386_efi_TRUE@lsacpi_module_LDADD =
+@COND_i386_multiboot_TRUE@lsacpi_module_LDADD =
+@COND_i386_pc_TRUE@lsacpi_module_LDADD =
+@COND_ia64_efi_TRUE@lsacpi_module_LDADD =
+@COND_riscv32_efi_TRUE@lsacpi_module_LDADD =
+@COND_riscv64_efi_TRUE@lsacpi_module_LDADD =
+@COND_x86_64_efi_TRUE@lsacpi_module_LDADD =
+@COND_arm64_efi_TRUE@lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsacpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsacpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsacpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsacpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@lsacpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+@COND_arm_efi_TRUE@lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+@COND_i386_efi_TRUE@lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+@COND_ia64_efi_TRUE@lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+@COND_riscv32_efi_TRUE@lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+@COND_riscv64_efi_TRUE@lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+@COND_x86_64_efi_TRUE@lsefisystab_module_SOURCES = commands/efi/lsefisystab.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_lsefisystab_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@lsefisystab_module_LDADD =
+@COND_arm_efi_TRUE@lsefisystab_module_LDADD =
+@COND_i386_efi_TRUE@lsefisystab_module_LDADD =
+@COND_ia64_efi_TRUE@lsefisystab_module_LDADD =
+@COND_riscv32_efi_TRUE@lsefisystab_module_LDADD =
+@COND_riscv64_efi_TRUE@lsefisystab_module_LDADD =
+@COND_x86_64_efi_TRUE@lsefisystab_module_LDADD =
+@COND_arm64_efi_TRUE@lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefisystab_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefisystab_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefisystab_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefisystab_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@lsefisystab_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+@COND_arm_efi_TRUE@lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+@COND_i386_efi_TRUE@lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+@COND_ia64_efi_TRUE@lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+@COND_riscv32_efi_TRUE@lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+@COND_riscv64_efi_TRUE@lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+@COND_x86_64_efi_TRUE@lssal_module_SOURCES = commands/efi/lssal.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_lssal_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_lssal_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_lssal_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_lssal_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_lssal_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_lssal_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_lssal_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@lssal_module_LDADD =
+@COND_arm_efi_TRUE@lssal_module_LDADD =
+@COND_i386_efi_TRUE@lssal_module_LDADD =
+@COND_ia64_efi_TRUE@lssal_module_LDADD =
+@COND_riscv32_efi_TRUE@lssal_module_LDADD =
+@COND_riscv64_efi_TRUE@lssal_module_LDADD =
+@COND_x86_64_efi_TRUE@lssal_module_LDADD =
+@COND_arm64_efi_TRUE@lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lssal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lssal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lssal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lssal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@lssal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+@COND_arm_efi_TRUE@lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+@COND_i386_efi_TRUE@lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+@COND_ia64_efi_TRUE@lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+@COND_riscv32_efi_TRUE@lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+@COND_riscv64_efi_TRUE@lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+@COND_x86_64_efi_TRUE@lsefimmap_module_SOURCES = commands/efi/lsefimmap.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_lsefimmap_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@lsefimmap_module_LDADD =
+@COND_arm_efi_TRUE@lsefimmap_module_LDADD =
+@COND_i386_efi_TRUE@lsefimmap_module_LDADD =
+@COND_ia64_efi_TRUE@lsefimmap_module_LDADD =
+@COND_riscv32_efi_TRUE@lsefimmap_module_LDADD =
+@COND_riscv64_efi_TRUE@lsefimmap_module_LDADD =
+@COND_x86_64_efi_TRUE@lsefimmap_module_LDADD =
+@COND_arm64_efi_TRUE@lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefimmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefimmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefimmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefimmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@lsefimmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+@COND_arm_efi_TRUE@lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+@COND_i386_efi_TRUE@lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+@COND_ia64_efi_TRUE@lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+@COND_riscv32_efi_TRUE@lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+@COND_riscv64_efi_TRUE@lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+@COND_x86_64_efi_TRUE@lsefi_module_SOURCES = commands/efi/lsefi.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_lsefi_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_lsefi_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_lsefi_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_lsefi_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_lsefi_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_lsefi_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_lsefi_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@lsefi_module_LDADD =
+@COND_arm_efi_TRUE@lsefi_module_LDADD =
+@COND_i386_efi_TRUE@lsefi_module_LDADD =
+@COND_ia64_efi_TRUE@lsefi_module_LDADD =
+@COND_riscv32_efi_TRUE@lsefi_module_LDADD =
+@COND_riscv64_efi_TRUE@lsefi_module_LDADD =
+@COND_x86_64_efi_TRUE@lsefi_module_LDADD =
+@COND_arm64_efi_TRUE@lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lsefi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@lsefi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+@COND_arm_efi_TRUE@efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+@COND_i386_efi_TRUE@efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+@COND_ia64_efi_TRUE@efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+@COND_riscv32_efi_TRUE@efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+@COND_riscv64_efi_TRUE@efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+@COND_x86_64_efi_TRUE@efifwsetup_module_SOURCES = commands/efi/efifwsetup.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_efifwsetup_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@efifwsetup_module_LDADD =
+@COND_arm_efi_TRUE@efifwsetup_module_LDADD =
+@COND_i386_efi_TRUE@efifwsetup_module_LDADD =
+@COND_ia64_efi_TRUE@efifwsetup_module_LDADD =
+@COND_riscv32_efi_TRUE@efifwsetup_module_LDADD =
+@COND_riscv64_efi_TRUE@efifwsetup_module_LDADD =
+@COND_x86_64_efi_TRUE@efifwsetup_module_LDADD =
+@COND_arm64_efi_TRUE@efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efifwsetup_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efifwsetup_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efifwsetup_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efifwsetup_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@efifwsetup_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+blocklist_module_SOURCES = commands/blocklist.c ## platform sources
+nodist_blocklist_module_SOURCES = ## platform nodist sources
+blocklist_module_LDADD =
+blocklist_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+blocklist_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+blocklist_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+blocklist_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+blocklist_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_arm_coreboot_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_arm_efi_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_arm_uboot_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_emu_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_i386_coreboot_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_i386_efi_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_i386_ieee1275_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_i386_multiboot_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_i386_pc_TRUE@boot_module_SOURCES = lib/i386/pc/biosnum.c commands/boot.c ## platform sources
+@COND_i386_qemu_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_ia64_efi_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_mips_arc_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_riscv32_efi_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_riscv64_efi_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_x86_64_efi_TRUE@boot_module_SOURCES = commands/boot.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_boot_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@boot_module_LDADD =
+@COND_arm_coreboot_TRUE@boot_module_LDADD =
+@COND_arm_efi_TRUE@boot_module_LDADD =
+@COND_arm_uboot_TRUE@boot_module_LDADD =
+@COND_emu_TRUE@boot_module_LDADD =
+@COND_i386_coreboot_TRUE@boot_module_LDADD =
+@COND_i386_efi_TRUE@boot_module_LDADD =
+@COND_i386_ieee1275_TRUE@boot_module_LDADD =
+@COND_i386_multiboot_TRUE@boot_module_LDADD =
+@COND_i386_pc_TRUE@boot_module_LDADD =
+@COND_i386_qemu_TRUE@boot_module_LDADD =
+@COND_ia64_efi_TRUE@boot_module_LDADD =
+@COND_mips_arc_TRUE@boot_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@boot_module_LDADD =
+@COND_riscv32_efi_TRUE@boot_module_LDADD =
+@COND_riscv64_efi_TRUE@boot_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@boot_module_LDADD =
+@COND_x86_64_efi_TRUE@boot_module_LDADD =
+@COND_arm64_efi_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+cat_module_SOURCES = commands/cat.c ## platform sources
+nodist_cat_module_SOURCES = ## platform nodist sources
+cat_module_LDADD =
+cat_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cat_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cat_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cat_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cat_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+cmp_module_SOURCES = commands/cmp.c ## platform sources
+nodist_cmp_module_SOURCES = ## platform nodist sources
+cmp_module_LDADD =
+cmp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+configfile_module_SOURCES = commands/configfile.c ## platform sources
+nodist_configfile_module_SOURCES = ## platform nodist sources
+configfile_module_LDADD =
+configfile_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+configfile_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+configfile_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+configfile_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+configfile_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+@COND_i386_efi_TRUE@cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+@COND_i386_ieee1275_TRUE@cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+@COND_i386_multiboot_TRUE@cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+@COND_i386_pc_TRUE@cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+@COND_i386_qemu_TRUE@cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+@COND_i386_xen_TRUE@cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+@COND_i386_xen_pvh_TRUE@cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+@COND_x86_64_efi_TRUE@cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+@COND_x86_64_xen_TRUE@cpuid_module_SOURCES = commands/i386/cpuid.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_cpuid_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_cpuid_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_cpuid_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_cpuid_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_cpuid_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_cpuid_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_cpuid_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_cpuid_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_cpuid_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_cpuid_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@cpuid_module_LDADD =
+@COND_i386_efi_TRUE@cpuid_module_LDADD =
+@COND_i386_ieee1275_TRUE@cpuid_module_LDADD =
+@COND_i386_multiboot_TRUE@cpuid_module_LDADD =
+@COND_i386_pc_TRUE@cpuid_module_LDADD =
+@COND_i386_qemu_TRUE@cpuid_module_LDADD =
+@COND_i386_xen_TRUE@cpuid_module_LDADD =
+@COND_i386_xen_pvh_TRUE@cpuid_module_LDADD =
+@COND_x86_64_efi_TRUE@cpuid_module_LDADD =
+@COND_x86_64_xen_TRUE@cpuid_module_LDADD =
+@COND_i386_coreboot_TRUE@cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@cpuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@cpuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@cpuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@cpuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@cpuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+date_module_SOURCES = commands/date.c ## platform sources
+nodist_date_module_SOURCES = ## platform nodist sources
+date_module_LDADD =
+date_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+date_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+date_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+date_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+date_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@drivemap_module_SOURCES = commands/i386/pc/drivemap.c commands/i386/pc/drivemap_int13h.S ## platform sources
+@COND_i386_pc_TRUE@nodist_drivemap_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@drivemap_module_LDADD =
+@COND_i386_pc_TRUE@drivemap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@drivemap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@drivemap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@drivemap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@drivemap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+echo_module_SOURCES = commands/echo.c ## platform sources
+nodist_echo_module_SOURCES = ## platform nodist sources
+echo_module_LDADD =
+echo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+echo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+echo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+echo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+echo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+eval_module_SOURCES = commands/eval.c ## platform sources
+nodist_eval_module_SOURCES = ## platform nodist sources
+eval_module_LDADD =
+eval_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+eval_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+eval_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+eval_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+eval_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_arm_coreboot_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_arm_efi_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_i386_coreboot_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_i386_efi_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_i386_multiboot_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_i386_pc_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_i386_qemu_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_ia64_efi_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_riscv32_efi_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_riscv64_efi_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_x86_64_efi_TRUE@extcmd_module_SOURCES = commands/extcmd.c lib/arg.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_extcmd_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@extcmd_module_LDADD =
+@COND_arm_coreboot_TRUE@extcmd_module_LDADD =
+@COND_arm_efi_TRUE@extcmd_module_LDADD =
+@COND_i386_coreboot_TRUE@extcmd_module_LDADD =
+@COND_i386_efi_TRUE@extcmd_module_LDADD =
+@COND_i386_multiboot_TRUE@extcmd_module_LDADD =
+@COND_i386_pc_TRUE@extcmd_module_LDADD =
+@COND_i386_qemu_TRUE@extcmd_module_LDADD =
+@COND_ia64_efi_TRUE@extcmd_module_LDADD =
+@COND_riscv32_efi_TRUE@extcmd_module_LDADD =
+@COND_riscv64_efi_TRUE@extcmd_module_LDADD =
+@COND_x86_64_efi_TRUE@extcmd_module_LDADD =
+@COND_arm64_efi_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@extcmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@extcmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@extcmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@extcmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@extcmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@fixvideo_module_SOURCES = commands/efi/fixvideo.c ## platform sources
+@COND_x86_64_efi_TRUE@fixvideo_module_SOURCES = commands/efi/fixvideo.c ## platform sources
+@COND_i386_efi_TRUE@nodist_fixvideo_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_fixvideo_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@fixvideo_module_LDADD =
+@COND_x86_64_efi_TRUE@fixvideo_module_LDADD =
+@COND_i386_efi_TRUE@fixvideo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@fixvideo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@fixvideo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@fixvideo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@fixvideo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@fixvideo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@fixvideo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@fixvideo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@fixvideo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@fixvideo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gptsync_module_SOURCES = commands/gptsync.c ## platform sources
+nodist_gptsync_module_SOURCES = ## platform nodist sources
+gptsync_module_LDADD =
+gptsync_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gptsync_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gptsync_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gptsync_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gptsync_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@halt_module_SOURCES = lib/efi/halt.c commands/halt.c ## platform sources
+@COND_arm_coreboot_TRUE@halt_module_SOURCES = lib/dummy/halt.c commands/halt.c ## platform sources
+@COND_arm_efi_TRUE@halt_module_SOURCES = lib/efi/halt.c commands/halt.c ## platform sources
+@COND_arm_uboot_TRUE@halt_module_SOURCES = lib/dummy/halt.c commands/halt.c ## platform sources
+@COND_emu_TRUE@halt_module_SOURCES = lib/emu/halt.c commands/halt.c ## platform sources
+@COND_i386_coreboot_TRUE@halt_module_SOURCES = commands/acpihalt.c lib/i386/halt.c commands/halt.c ## platform sources
+@COND_i386_efi_TRUE@halt_module_SOURCES = commands/acpihalt.c lib/efi/halt.c commands/halt.c ## platform sources
+@COND_i386_ieee1275_TRUE@halt_module_SOURCES = lib/ieee1275/halt.c commands/halt.c ## platform sources
+@COND_i386_multiboot_TRUE@halt_module_SOURCES = commands/acpihalt.c lib/i386/halt.c commands/halt.c ## platform sources
+@COND_i386_pc_TRUE@halt_module_SOURCES = commands/i386/pc/halt.c commands/acpihalt.c ## platform sources
+@COND_i386_qemu_TRUE@halt_module_SOURCES = lib/i386/halt.c commands/halt.c ## platform sources
+@COND_i386_xen_TRUE@halt_module_SOURCES = lib/xen/halt.c commands/halt.c ## platform sources
+@COND_i386_xen_pvh_TRUE@halt_module_SOURCES = lib/xen/halt.c commands/halt.c ## platform sources
+@COND_ia64_efi_TRUE@halt_module_SOURCES = lib/efi/halt.c commands/halt.c ## platform sources
+@COND_mips_arc_TRUE@halt_module_SOURCES = commands/halt.c ## platform sources
+@COND_mips_loongson_TRUE@halt_module_SOURCES = commands/halt.c ## platform sources
+@COND_mips_qemu_mips_TRUE@halt_module_SOURCES = commands/halt.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@halt_module_SOURCES = lib/ieee1275/halt.c commands/halt.c ## platform sources
+@COND_riscv32_efi_TRUE@halt_module_SOURCES = lib/efi/halt.c commands/halt.c ## platform sources
+@COND_riscv64_efi_TRUE@halt_module_SOURCES = lib/efi/halt.c commands/halt.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@halt_module_SOURCES = lib/ieee1275/halt.c commands/halt.c ## platform sources
+@COND_x86_64_efi_TRUE@halt_module_SOURCES = commands/acpihalt.c lib/efi/halt.c commands/halt.c ## platform sources
+@COND_x86_64_xen_TRUE@halt_module_SOURCES = lib/xen/halt.c commands/halt.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_halt_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@halt_module_LDADD =
+@COND_arm_coreboot_TRUE@halt_module_LDADD =
+@COND_arm_efi_TRUE@halt_module_LDADD =
+@COND_arm_uboot_TRUE@halt_module_LDADD =
+@COND_emu_TRUE@halt_module_LDADD =
+@COND_i386_coreboot_TRUE@halt_module_LDADD =
+@COND_i386_efi_TRUE@halt_module_LDADD =
+@COND_i386_ieee1275_TRUE@halt_module_LDADD =
+@COND_i386_multiboot_TRUE@halt_module_LDADD =
+@COND_i386_pc_TRUE@halt_module_LDADD =
+@COND_i386_qemu_TRUE@halt_module_LDADD =
+@COND_i386_xen_TRUE@halt_module_LDADD =
+@COND_i386_xen_pvh_TRUE@halt_module_LDADD =
+@COND_ia64_efi_TRUE@halt_module_LDADD =
+@COND_mips_arc_TRUE@halt_module_LDADD =
+@COND_mips_loongson_TRUE@halt_module_LDADD =
+@COND_mips_qemu_mips_TRUE@halt_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@halt_module_LDADD =
+@COND_riscv32_efi_TRUE@halt_module_LDADD =
+@COND_riscv64_efi_TRUE@halt_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@halt_module_LDADD =
+@COND_x86_64_efi_TRUE@halt_module_LDADD =
+@COND_x86_64_xen_TRUE@halt_module_LDADD =
+@COND_arm64_efi_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@halt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@halt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@halt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@halt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@halt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@reboot_module_SOURCES = commands/reboot.c ## platform sources
+@COND_arm_coreboot_TRUE@reboot_module_SOURCES = lib/dummy/reboot.c commands/reboot.c ## platform sources
+@COND_arm_efi_TRUE@reboot_module_SOURCES = commands/reboot.c ## platform sources
+@COND_arm_uboot_TRUE@reboot_module_SOURCES = lib/uboot/reboot.c commands/reboot.c ## platform sources
+@COND_emu_TRUE@reboot_module_SOURCES = commands/reboot.c ## platform sources
+@COND_i386_coreboot_TRUE@reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+@COND_i386_efi_TRUE@reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+@COND_i386_ieee1275_TRUE@reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+@COND_i386_multiboot_TRUE@reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+@COND_i386_pc_TRUE@reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+@COND_i386_qemu_TRUE@reboot_module_SOURCES = lib/i386/reboot.c lib/i386/reboot_trampoline.S commands/reboot.c ## platform sources
+@COND_i386_xen_TRUE@reboot_module_SOURCES = lib/xen/reboot.c commands/reboot.c ## platform sources
+@COND_i386_xen_pvh_TRUE@reboot_module_SOURCES = lib/xen/reboot.c commands/reboot.c ## platform sources
+@COND_ia64_efi_TRUE@reboot_module_SOURCES = commands/reboot.c ## platform sources
+@COND_mips_arc_TRUE@reboot_module_SOURCES = lib/mips/arc/reboot.c commands/reboot.c ## platform sources
+@COND_mips_loongson_TRUE@reboot_module_SOURCES = lib/mips/loongson/reboot.c commands/reboot.c ## platform sources
+@COND_mips_qemu_mips_TRUE@reboot_module_SOURCES = lib/mips/qemu_mips/reboot.c commands/reboot.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@reboot_module_SOURCES = lib/ieee1275/reboot.c commands/reboot.c ## platform sources
+@COND_riscv32_efi_TRUE@reboot_module_SOURCES = commands/reboot.c ## platform sources
+@COND_riscv64_efi_TRUE@reboot_module_SOURCES = commands/reboot.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@reboot_module_SOURCES = lib/ieee1275/reboot.c commands/reboot.c ## platform sources
+@COND_x86_64_efi_TRUE@reboot_module_SOURCES = commands/reboot.c ## platform sources
+@COND_x86_64_xen_TRUE@reboot_module_SOURCES = lib/xen/reboot.c commands/reboot.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_reboot_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@reboot_module_LDADD =
+@COND_arm_coreboot_TRUE@reboot_module_LDADD =
+@COND_arm_efi_TRUE@reboot_module_LDADD =
+@COND_arm_uboot_TRUE@reboot_module_LDADD =
+@COND_emu_TRUE@reboot_module_LDADD =
+@COND_i386_coreboot_TRUE@reboot_module_LDADD =
+@COND_i386_efi_TRUE@reboot_module_LDADD =
+@COND_i386_ieee1275_TRUE@reboot_module_LDADD =
+@COND_i386_multiboot_TRUE@reboot_module_LDADD =
+@COND_i386_pc_TRUE@reboot_module_LDADD =
+@COND_i386_qemu_TRUE@reboot_module_LDADD =
+@COND_i386_xen_TRUE@reboot_module_LDADD =
+@COND_i386_xen_pvh_TRUE@reboot_module_LDADD =
+@COND_ia64_efi_TRUE@reboot_module_LDADD =
+@COND_mips_arc_TRUE@reboot_module_LDADD =
+@COND_mips_loongson_TRUE@reboot_module_LDADD =
+@COND_mips_qemu_mips_TRUE@reboot_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@reboot_module_LDADD =
+@COND_riscv32_efi_TRUE@reboot_module_LDADD =
+@COND_riscv64_efi_TRUE@reboot_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@reboot_module_LDADD =
+@COND_x86_64_efi_TRUE@reboot_module_LDADD =
+@COND_x86_64_xen_TRUE@reboot_module_LDADD =
+@COND_arm64_efi_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@reboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@reboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@reboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@reboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@reboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+hashsum_module_SOURCES = commands/hashsum.c ## platform sources
+nodist_hashsum_module_SOURCES = ## platform nodist sources
+hashsum_module_LDADD =
+hashsum_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hashsum_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hashsum_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hashsum_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hashsum_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+pgp_module_SOURCES = commands/pgp.c ## platform sources
+nodist_pgp_module_SOURCES = ## platform nodist sources
+pgp_module_LDADD =
+pgp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX)
+pgp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pgp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap
+pgp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pgp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+@COND_i386_efi_TRUE@hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+@COND_i386_ieee1275_TRUE@hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+@COND_i386_multiboot_TRUE@hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+@COND_i386_pc_TRUE@hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+@COND_i386_qemu_TRUE@hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+@COND_mips_loongson_TRUE@hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+@COND_mips_qemu_mips_TRUE@hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+@COND_x86_64_efi_TRUE@hdparm_module_SOURCES = commands/hdparm.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_hdparm_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_hdparm_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_hdparm_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_hdparm_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_hdparm_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_hdparm_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_hdparm_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_hdparm_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_hdparm_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@hdparm_module_LDADD =
+@COND_i386_efi_TRUE@hdparm_module_LDADD =
+@COND_i386_ieee1275_TRUE@hdparm_module_LDADD =
+@COND_i386_multiboot_TRUE@hdparm_module_LDADD =
+@COND_i386_pc_TRUE@hdparm_module_LDADD =
+@COND_i386_qemu_TRUE@hdparm_module_LDADD =
+@COND_mips_loongson_TRUE@hdparm_module_LDADD =
+@COND_mips_qemu_mips_TRUE@hdparm_module_LDADD =
+@COND_x86_64_efi_TRUE@hdparm_module_LDADD =
+@COND_i386_coreboot_TRUE@hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@hdparm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@hdparm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@hdparm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@hdparm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@hdparm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+help_module_SOURCES = commands/help.c ## platform sources
+nodist_help_module_SOURCES = ## platform nodist sources
+help_module_LDADD =
+help_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+help_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+help_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+help_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+help_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+hexdump_module_SOURCES = commands/hexdump.c lib/hexdump.c ## platform sources
+nodist_hexdump_module_SOURCES = ## platform nodist sources
+hexdump_module_LDADD =
+hexdump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hexdump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hexdump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hexdump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hexdump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+keystatus_module_SOURCES = commands/keystatus.c ## platform sources
+nodist_keystatus_module_SOURCES = ## platform nodist sources
+keystatus_module_LDADD =
+keystatus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+keystatus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+keystatus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+keystatus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+keystatus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@loadbios_module_SOURCES = commands/efi/loadbios.c ## platform sources
+@COND_x86_64_efi_TRUE@loadbios_module_SOURCES = commands/efi/loadbios.c ## platform sources
+@COND_i386_efi_TRUE@nodist_loadbios_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_loadbios_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@loadbios_module_LDADD =
+@COND_x86_64_efi_TRUE@loadbios_module_LDADD =
+@COND_i386_efi_TRUE@loadbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@loadbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@loadbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@loadbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@loadbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@loadbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@loadbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@loadbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@loadbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@loadbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+loadenv_module_SOURCES = commands/loadenv.c lib/envblk.c ## platform sources
+nodist_loadenv_module_SOURCES = ## platform nodist sources
+loadenv_module_LDADD =
+loadenv_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+loadenv_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+loadenv_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+loadenv_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+loadenv_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+ls_module_SOURCES = commands/ls.c ## platform sources
+nodist_ls_module_SOURCES = ## platform nodist sources
+ls_module_LDADD =
+ls_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ls_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ls_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ls_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ls_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+lsmmap_module_SOURCES = commands/lsmmap.c ## platform sources
+nodist_lsmmap_module_SOURCES = ## platform nodist sources
+lsmmap_module_LDADD =
+lsmmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lsmmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lsmmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lsmmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lsmmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@lspci_module_SOURCES = commands/lspci.c ## platform sources
+@COND_i386_efi_TRUE@lspci_module_SOURCES = commands/lspci.c ## platform sources
+@COND_i386_ieee1275_TRUE@lspci_module_SOURCES = commands/lspci.c ## platform sources
+@COND_i386_multiboot_TRUE@lspci_module_SOURCES = commands/lspci.c ## platform sources
+@COND_i386_pc_TRUE@lspci_module_SOURCES = commands/lspci.c ## platform sources
+@COND_i386_qemu_TRUE@lspci_module_SOURCES = commands/lspci.c ## platform sources
+@COND_mips_loongson_TRUE@lspci_module_SOURCES = commands/lspci.c ## platform sources
+@COND_x86_64_efi_TRUE@lspci_module_SOURCES = commands/lspci.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_lspci_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_lspci_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_lspci_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_lspci_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_lspci_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_lspci_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_lspci_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_lspci_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@lspci_module_LDADD =
+@COND_i386_efi_TRUE@lspci_module_LDADD =
+@COND_i386_ieee1275_TRUE@lspci_module_LDADD =
+@COND_i386_multiboot_TRUE@lspci_module_LDADD =
+@COND_i386_pc_TRUE@lspci_module_LDADD =
+@COND_i386_qemu_TRUE@lspci_module_LDADD =
+@COND_mips_loongson_TRUE@lspci_module_LDADD =
+@COND_x86_64_efi_TRUE@lspci_module_LDADD =
+@COND_i386_coreboot_TRUE@lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lspci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lspci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lspci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@lspci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@lspci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+memrw_module_SOURCES = commands/memrw.c ## platform sources
+nodist_memrw_module_SOURCES = ## platform nodist sources
+memrw_module_LDADD =
+memrw_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+memrw_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+memrw_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+memrw_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+memrw_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+minicmd_module_SOURCES = commands/minicmd.c ## platform sources
+nodist_minicmd_module_SOURCES = ## platform nodist sources
+minicmd_module_LDADD =
+minicmd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minicmd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minicmd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minicmd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minicmd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+parttool_module_SOURCES = commands/parttool.c ## platform sources
+nodist_parttool_module_SOURCES = ## platform nodist sources
+parttool_module_LDADD =
+parttool_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+parttool_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+parttool_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+parttool_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+parttool_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+password_module_SOURCES = commands/password.c ## platform sources
+nodist_password_module_SOURCES = ## platform nodist sources
+password_module_LDADD =
+password_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+password_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+password_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+password_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+password_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+password_pbkdf2_module_SOURCES = commands/password_pbkdf2.c ## platform sources
+nodist_password_pbkdf2_module_SOURCES = ## platform nodist sources
+password_pbkdf2_module_LDADD =
+password_pbkdf2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+password_pbkdf2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+password_pbkdf2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+password_pbkdf2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+password_pbkdf2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+@COND_i386_efi_TRUE@play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+@COND_i386_ieee1275_TRUE@play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+@COND_i386_multiboot_TRUE@play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+@COND_i386_pc_TRUE@play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+@COND_i386_qemu_TRUE@play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+@COND_x86_64_efi_TRUE@play_module_SOURCES = commands/i386/pc/play.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_play_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_play_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_play_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_play_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_play_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_play_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_play_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@play_module_LDADD =
+@COND_i386_efi_TRUE@play_module_LDADD =
+@COND_i386_ieee1275_TRUE@play_module_LDADD =
+@COND_i386_multiboot_TRUE@play_module_LDADD =
+@COND_i386_pc_TRUE@play_module_LDADD =
+@COND_i386_qemu_TRUE@play_module_LDADD =
+@COND_x86_64_efi_TRUE@play_module_LDADD =
+@COND_i386_coreboot_TRUE@play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@play_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@play_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@play_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@play_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@play_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+@COND_i386_efi_TRUE@spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+@COND_i386_ieee1275_TRUE@spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+@COND_i386_multiboot_TRUE@spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+@COND_i386_pc_TRUE@spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+@COND_i386_qemu_TRUE@spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+@COND_x86_64_efi_TRUE@spkmodem_module_SOURCES = term/spkmodem.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_spkmodem_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_spkmodem_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_spkmodem_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_spkmodem_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_spkmodem_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_spkmodem_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_spkmodem_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@spkmodem_module_LDADD =
+@COND_i386_efi_TRUE@spkmodem_module_LDADD =
+@COND_i386_ieee1275_TRUE@spkmodem_module_LDADD =
+@COND_i386_multiboot_TRUE@spkmodem_module_LDADD =
+@COND_i386_pc_TRUE@spkmodem_module_LDADD =
+@COND_i386_qemu_TRUE@spkmodem_module_LDADD =
+@COND_x86_64_efi_TRUE@spkmodem_module_LDADD =
+@COND_i386_coreboot_TRUE@spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@spkmodem_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@spkmodem_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@spkmodem_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@spkmodem_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@spkmodem_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@morse_module_SOURCES = term/morse.c ## platform sources
+@COND_i386_efi_TRUE@morse_module_SOURCES = term/morse.c ## platform sources
+@COND_i386_ieee1275_TRUE@morse_module_SOURCES = term/morse.c ## platform sources
+@COND_i386_multiboot_TRUE@morse_module_SOURCES = term/morse.c ## platform sources
+@COND_i386_pc_TRUE@morse_module_SOURCES = term/morse.c ## platform sources
+@COND_i386_qemu_TRUE@morse_module_SOURCES = term/morse.c ## platform sources
+@COND_x86_64_efi_TRUE@morse_module_SOURCES = term/morse.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_morse_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_morse_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_morse_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_morse_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_morse_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_morse_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_morse_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@morse_module_LDADD =
+@COND_i386_efi_TRUE@morse_module_LDADD =
+@COND_i386_ieee1275_TRUE@morse_module_LDADD =
+@COND_i386_multiboot_TRUE@morse_module_LDADD =
+@COND_i386_pc_TRUE@morse_module_LDADD =
+@COND_i386_qemu_TRUE@morse_module_LDADD =
+@COND_x86_64_efi_TRUE@morse_module_LDADD =
+@COND_i386_coreboot_TRUE@morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@morse_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@morse_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@morse_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@morse_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@morse_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+probe_module_SOURCES = commands/probe.c ## platform sources
+nodist_probe_module_SOURCES = ## platform nodist sources
+probe_module_LDADD =
+probe_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+probe_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+probe_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+probe_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+probe_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+read_module_SOURCES = commands/read.c ## platform sources
+nodist_read_module_SOURCES = ## platform nodist sources
+read_module_LDADD =
+read_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+read_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+read_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+read_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+read_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+search_module_SOURCES = commands/search_wrap.c ## platform sources
+nodist_search_module_SOURCES = ## platform nodist sources
+search_module_LDADD =
+search_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+search_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+search_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+search_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+search_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+search_fs_file_module_SOURCES = commands/search_file.c ## platform sources
+nodist_search_fs_file_module_SOURCES = ## platform nodist sources
+search_fs_file_module_LDADD =
+search_fs_file_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+search_fs_file_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+search_fs_file_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+search_fs_file_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+search_fs_file_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+search_fs_uuid_module_SOURCES = commands/search_uuid.c ## platform sources
+nodist_search_fs_uuid_module_SOURCES = ## platform nodist sources
+search_fs_uuid_module_LDADD =
+search_fs_uuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+search_fs_uuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+search_fs_uuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+search_fs_uuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+search_fs_uuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+search_label_module_SOURCES = commands/search_label.c ## platform sources
+nodist_search_label_module_SOURCES = ## platform nodist sources
+search_label_module_LDADD =
+search_label_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+search_label_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+search_label_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+search_label_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+search_label_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@setpci_module_SOURCES = commands/setpci.c ## platform sources
+@COND_i386_efi_TRUE@setpci_module_SOURCES = commands/setpci.c ## platform sources
+@COND_i386_ieee1275_TRUE@setpci_module_SOURCES = commands/setpci.c ## platform sources
+@COND_i386_multiboot_TRUE@setpci_module_SOURCES = commands/setpci.c ## platform sources
+@COND_i386_pc_TRUE@setpci_module_SOURCES = commands/setpci.c ## platform sources
+@COND_i386_qemu_TRUE@setpci_module_SOURCES = commands/setpci.c ## platform sources
+@COND_mips_loongson_TRUE@setpci_module_SOURCES = commands/setpci.c ## platform sources
+@COND_x86_64_efi_TRUE@setpci_module_SOURCES = commands/setpci.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_setpci_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_setpci_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_setpci_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_setpci_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_setpci_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_setpci_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_setpci_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_setpci_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@setpci_module_LDADD =
+@COND_i386_efi_TRUE@setpci_module_LDADD =
+@COND_i386_ieee1275_TRUE@setpci_module_LDADD =
+@COND_i386_multiboot_TRUE@setpci_module_LDADD =
+@COND_i386_pc_TRUE@setpci_module_LDADD =
+@COND_i386_qemu_TRUE@setpci_module_LDADD =
+@COND_mips_loongson_TRUE@setpci_module_LDADD =
+@COND_x86_64_efi_TRUE@setpci_module_LDADD =
+@COND_i386_coreboot_TRUE@setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@setpci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@setpci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@setpci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@setpci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@setpci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+@COND_i386_efi_TRUE@pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+@COND_i386_ieee1275_TRUE@pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+@COND_i386_multiboot_TRUE@pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+@COND_i386_pc_TRUE@pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+@COND_i386_qemu_TRUE@pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+@COND_mips_loongson_TRUE@pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+@COND_x86_64_efi_TRUE@pcidump_module_SOURCES = commands/pcidump.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_pcidump_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_pcidump_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_pcidump_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_pcidump_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_pcidump_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_pcidump_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_pcidump_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_pcidump_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@pcidump_module_LDADD =
+@COND_i386_efi_TRUE@pcidump_module_LDADD =
+@COND_i386_ieee1275_TRUE@pcidump_module_LDADD =
+@COND_i386_multiboot_TRUE@pcidump_module_LDADD =
+@COND_i386_pc_TRUE@pcidump_module_LDADD =
+@COND_i386_qemu_TRUE@pcidump_module_LDADD =
+@COND_mips_loongson_TRUE@pcidump_module_LDADD =
+@COND_x86_64_efi_TRUE@pcidump_module_LDADD =
+@COND_i386_coreboot_TRUE@pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@pcidump_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@pcidump_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@pcidump_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@pcidump_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@pcidump_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+sleep_module_SOURCES = commands/sleep.c ## platform sources
+nodist_sleep_module_SOURCES = ## platform nodist sources
+sleep_module_LDADD =
+sleep_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+sleep_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+sleep_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+sleep_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+sleep_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+@COND_arm_efi_TRUE@smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+@COND_i386_coreboot_TRUE@smbios_module_SOURCES = commands/i386/pc/smbios.c commands/smbios.c ## platform sources
+@COND_i386_efi_TRUE@smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+@COND_i386_multiboot_TRUE@smbios_module_SOURCES = commands/i386/pc/smbios.c commands/smbios.c ## platform sources
+@COND_i386_pc_TRUE@smbios_module_SOURCES = commands/i386/pc/smbios.c commands/smbios.c ## platform sources
+@COND_ia64_efi_TRUE@smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+@COND_riscv32_efi_TRUE@smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+@COND_riscv64_efi_TRUE@smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+@COND_x86_64_efi_TRUE@smbios_module_SOURCES = commands/efi/smbios.c commands/smbios.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_smbios_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_smbios_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_smbios_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_smbios_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_smbios_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_smbios_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_smbios_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_smbios_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_smbios_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_smbios_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@smbios_module_LDADD =
+@COND_arm_efi_TRUE@smbios_module_LDADD =
+@COND_i386_coreboot_TRUE@smbios_module_LDADD =
+@COND_i386_efi_TRUE@smbios_module_LDADD =
+@COND_i386_multiboot_TRUE@smbios_module_LDADD =
+@COND_i386_pc_TRUE@smbios_module_LDADD =
+@COND_ia64_efi_TRUE@smbios_module_LDADD =
+@COND_riscv32_efi_TRUE@smbios_module_LDADD =
+@COND_riscv64_efi_TRUE@smbios_module_LDADD =
+@COND_x86_64_efi_TRUE@smbios_module_LDADD =
+@COND_arm64_efi_TRUE@smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@smbios_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@smbios_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@smbios_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@smbios_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@smbios_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@suspend_module_SOURCES = commands/ieee1275/suspend.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@suspend_module_SOURCES = commands/ieee1275/suspend.c ## platform sources
+@COND_i386_ieee1275_TRUE@nodist_suspend_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_suspend_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@suspend_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@suspend_module_LDADD =
+@COND_i386_ieee1275_TRUE@suspend_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@suspend_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@suspend_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@suspend_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@suspend_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@suspend_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@suspend_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@suspend_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@suspend_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@suspend_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@escc_module_SOURCES = term/ieee1275/escc.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@nodist_escc_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@escc_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@escc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@escc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@escc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@escc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@escc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+terminal_module_SOURCES = commands/terminal.c ## platform sources
+nodist_terminal_module_SOURCES = ## platform nodist sources
+terminal_module_LDADD =
+terminal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+terminal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+terminal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+terminal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+terminal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+test_module_SOURCES = commands/test.c ## platform sources
+nodist_test_module_SOURCES = ## platform nodist sources
+test_module_LDADD =
+test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+true_module_SOURCES = commands/true.c ## platform sources
+nodist_true_module_SOURCES = ## platform nodist sources
+true_module_LDADD =
+true_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+true_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+true_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+true_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+true_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+@COND_i386_coreboot_TRUE@usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+@COND_i386_efi_TRUE@usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+@COND_i386_ieee1275_TRUE@usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+@COND_i386_multiboot_TRUE@usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+@COND_i386_pc_TRUE@usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+@COND_i386_qemu_TRUE@usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+@COND_mips_loongson_TRUE@usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+@COND_x86_64_efi_TRUE@usbtest_module_SOURCES = commands/usbtest.c ## platform sources
+@COND_arm_coreboot_TRUE@nodist_usbtest_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_usbtest_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_usbtest_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_usbtest_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_usbtest_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_usbtest_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_usbtest_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_usbtest_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_usbtest_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@usbtest_module_LDADD =
+@COND_i386_coreboot_TRUE@usbtest_module_LDADD =
+@COND_i386_efi_TRUE@usbtest_module_LDADD =
+@COND_i386_ieee1275_TRUE@usbtest_module_LDADD =
+@COND_i386_multiboot_TRUE@usbtest_module_LDADD =
+@COND_i386_pc_TRUE@usbtest_module_LDADD =
+@COND_i386_qemu_TRUE@usbtest_module_LDADD =
+@COND_mips_loongson_TRUE@usbtest_module_LDADD =
+@COND_x86_64_efi_TRUE@usbtest_module_LDADD =
+@COND_arm_coreboot_TRUE@usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbtest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbtest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbtest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbtest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@usbtest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+videoinfo_module_SOURCES = commands/videoinfo.c ## platform sources
+nodist_videoinfo_module_SOURCES = ## platform nodist sources
+videoinfo_module_LDADD =
+videoinfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+videoinfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+videoinfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+videoinfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+videoinfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+videotest_module_SOURCES = commands/videotest.c ## platform sources
+nodist_videotest_module_SOURCES = ## platform nodist sources
+videotest_module_LDADD =
+videotest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+videotest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+videotest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+videotest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+videotest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+xnu_uuid_module_SOURCES = commands/xnu_uuid.c ## platform sources
+nodist_xnu_uuid_module_SOURCES = ## platform nodist sources
+xnu_uuid_module_LDADD =
+xnu_uuid_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xnu_uuid_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xnu_uuid_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xnu_uuid_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xnu_uuid_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+dm_nv_module_SOURCES = disk/dmraid_nvidia.c ## platform sources
+nodist_dm_nv_module_SOURCES = ## platform nodist sources
+dm_nv_module_LDADD =
+dm_nv_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+dm_nv_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+dm_nv_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+dm_nv_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+dm_nv_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+loopback_module_SOURCES = disk/loopback.c ## platform sources
+nodist_loopback_module_SOURCES = ## platform nodist sources
+loopback_module_LDADD =
+loopback_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+loopback_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+loopback_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+loopback_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+loopback_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+cryptodisk_module_SOURCES = disk/cryptodisk.c ## platform sources
+nodist_cryptodisk_module_SOURCES = ## platform nodist sources
+cryptodisk_module_LDADD =
+cryptodisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cryptodisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cryptodisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cryptodisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cryptodisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+json_module_SOURCES = lib/json/json.c ## platform sources
+nodist_json_module_SOURCES = ## platform nodist sources
+json_module_LDADD =
+json_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+json_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+json_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+json_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+json_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+afsplitter_module_SOURCES = disk/AFSplitter.c ## platform sources
+nodist_afsplitter_module_SOURCES = ## platform nodist sources
+afsplitter_module_LDADD =
+afsplitter_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+afsplitter_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+afsplitter_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+afsplitter_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+afsplitter_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+luks_module_SOURCES = disk/luks.c ## platform sources
+nodist_luks_module_SOURCES = ## platform nodist sources
+luks_module_LDADD =
+luks_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+luks_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+luks_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+luks_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+luks_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+luks2_module_SOURCES = disk/luks2.c lib/gnulib/base64.c ## platform sources
+nodist_luks2_module_SOURCES = ## platform nodist sources
+luks2_module_LDADD =
+luks2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) $(CFLAGS_GNULIB)
+luks2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+luks2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB) -I$(srcdir)/lib/json
+luks2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+luks2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+geli_module_SOURCES = disk/geli.c ## platform sources
+nodist_geli_module_SOURCES = ## platform nodist sources
+geli_module_LDADD =
+geli_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+geli_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+geli_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+geli_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+geli_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+lvm_module_SOURCES = disk/lvm.c ## platform sources
+nodist_lvm_module_SOURCES = ## platform nodist sources
+lvm_module_LDADD =
+lvm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+lvm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lvm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+lvm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lvm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+ldm_module_SOURCES = disk/ldm.c ## platform sources
+nodist_ldm_module_SOURCES = ## platform nodist sources
+ldm_module_LDADD =
+ldm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ldm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ldm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ldm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ldm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+mdraid09_module_SOURCES = disk/mdraid_linux.c ## platform sources
+nodist_mdraid09_module_SOURCES = ## platform nodist sources
+mdraid09_module_LDADD =
+mdraid09_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mdraid09_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mdraid09_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mdraid09_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mdraid09_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+mdraid09_be_module_SOURCES = disk/mdraid_linux_be.c ## platform sources
+nodist_mdraid09_be_module_SOURCES = ## platform nodist sources
+mdraid09_be_module_LDADD =
+mdraid09_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mdraid09_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mdraid09_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mdraid09_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mdraid09_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+mdraid1x_module_SOURCES = disk/mdraid1x_linux.c ## platform sources
+nodist_mdraid1x_module_SOURCES = ## platform nodist sources
+mdraid1x_module_LDADD =
+mdraid1x_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mdraid1x_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mdraid1x_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mdraid1x_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mdraid1x_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+diskfilter_module_SOURCES = disk/diskfilter.c ## platform sources
+nodist_diskfilter_module_SOURCES = ## platform nodist sources
+diskfilter_module_LDADD =
+diskfilter_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+diskfilter_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+diskfilter_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+diskfilter_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+diskfilter_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+raid5rec_module_SOURCES = disk/raid5_recover.c ## platform sources
+nodist_raid5rec_module_SOURCES = ## platform nodist sources
+raid5rec_module_LDADD =
+raid5rec_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+raid5rec_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+raid5rec_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+raid5rec_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+raid5rec_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+raid6rec_module_SOURCES = disk/raid6_recover.c ## platform sources
+nodist_raid6rec_module_SOURCES = ## platform nodist sources
+raid6rec_module_LDADD =
+raid6rec_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+raid6rec_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+raid6rec_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+raid6rec_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+raid6rec_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+scsi_module_SOURCES = disk/scsi.c ## platform sources
+nodist_scsi_module_SOURCES = ## platform nodist sources
+scsi_module_LDADD =
+scsi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+scsi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+scsi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+scsi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+scsi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+memdisk_module_SOURCES = disk/memdisk.c ## platform sources
+nodist_memdisk_module_SOURCES = ## platform nodist sources
+memdisk_module_LDADD =
+memdisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+memdisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+memdisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+memdisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+memdisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@ata_module_SOURCES = disk/ata.c ## platform sources
+@COND_i386_efi_TRUE@ata_module_SOURCES = disk/ata.c ## platform sources
+@COND_i386_ieee1275_TRUE@ata_module_SOURCES = disk/ata.c ## platform sources
+@COND_i386_multiboot_TRUE@ata_module_SOURCES = disk/ata.c ## platform sources
+@COND_i386_pc_TRUE@ata_module_SOURCES = disk/ata.c ## platform sources
+@COND_i386_qemu_TRUE@ata_module_SOURCES = disk/ata.c ## platform sources
+@COND_mips_loongson_TRUE@ata_module_SOURCES = disk/ata.c ## platform sources
+@COND_mips_qemu_mips_TRUE@ata_module_SOURCES = disk/ata.c ## platform sources
+@COND_x86_64_efi_TRUE@ata_module_SOURCES = disk/ata.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_ata_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_ata_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_ata_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_ata_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_ata_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_ata_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_ata_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_ata_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_ata_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@ata_module_LDADD =
+@COND_i386_efi_TRUE@ata_module_LDADD =
+@COND_i386_ieee1275_TRUE@ata_module_LDADD =
+@COND_i386_multiboot_TRUE@ata_module_LDADD =
+@COND_i386_pc_TRUE@ata_module_LDADD =
+@COND_i386_qemu_TRUE@ata_module_LDADD =
+@COND_mips_loongson_TRUE@ata_module_LDADD =
+@COND_mips_qemu_mips_TRUE@ata_module_LDADD =
+@COND_x86_64_efi_TRUE@ata_module_LDADD =
+@COND_i386_coreboot_TRUE@ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@ata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@ahci_module_SOURCES = disk/ahci.c ## platform sources
+@COND_i386_efi_TRUE@ahci_module_SOURCES = disk/ahci.c ## platform sources
+@COND_i386_ieee1275_TRUE@ahci_module_SOURCES = disk/ahci.c ## platform sources
+@COND_i386_multiboot_TRUE@ahci_module_SOURCES = disk/ahci.c ## platform sources
+@COND_i386_pc_TRUE@ahci_module_SOURCES = disk/ahci.c ## platform sources
+@COND_i386_qemu_TRUE@ahci_module_SOURCES = disk/ahci.c ## platform sources
+@COND_mips_loongson_TRUE@ahci_module_SOURCES = disk/ahci.c ## platform sources
+@COND_x86_64_efi_TRUE@ahci_module_SOURCES = disk/ahci.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_ahci_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_ahci_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_ahci_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_ahci_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_ahci_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_ahci_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_ahci_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_ahci_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@ahci_module_LDADD =
+@COND_i386_efi_TRUE@ahci_module_LDADD =
+@COND_i386_ieee1275_TRUE@ahci_module_LDADD =
+@COND_i386_multiboot_TRUE@ahci_module_LDADD =
+@COND_i386_pc_TRUE@ahci_module_LDADD =
+@COND_i386_qemu_TRUE@ahci_module_LDADD =
+@COND_mips_loongson_TRUE@ahci_module_LDADD =
+@COND_x86_64_efi_TRUE@ahci_module_LDADD =
+@COND_i386_coreboot_TRUE@ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ahci_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ahci_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ahci_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@ahci_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@ahci_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@pata_module_SOURCES = disk/pata.c ## platform sources
+@COND_i386_efi_TRUE@pata_module_SOURCES = disk/pata.c ## platform sources
+@COND_i386_ieee1275_TRUE@pata_module_SOURCES = disk/pata.c ## platform sources
+@COND_i386_multiboot_TRUE@pata_module_SOURCES = disk/pata.c ## platform sources
+@COND_i386_pc_TRUE@pata_module_SOURCES = disk/pata.c ## platform sources
+@COND_i386_qemu_TRUE@pata_module_SOURCES = disk/pata.c ## platform sources
+@COND_mips_loongson_TRUE@pata_module_SOURCES = disk/pata.c ## platform sources
+@COND_mips_qemu_mips_TRUE@pata_module_SOURCES = disk/pata.c ## platform sources
+@COND_x86_64_efi_TRUE@pata_module_SOURCES = disk/pata.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_pata_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_pata_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_pata_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_pata_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_pata_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_pata_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_pata_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_pata_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_pata_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@pata_module_LDADD =
+@COND_i386_efi_TRUE@pata_module_LDADD =
+@COND_i386_ieee1275_TRUE@pata_module_LDADD =
+@COND_i386_multiboot_TRUE@pata_module_LDADD =
+@COND_i386_pc_TRUE@pata_module_LDADD =
+@COND_i386_qemu_TRUE@pata_module_LDADD =
+@COND_mips_loongson_TRUE@pata_module_LDADD =
+@COND_mips_qemu_mips_TRUE@pata_module_LDADD =
+@COND_x86_64_efi_TRUE@pata_module_LDADD =
+@COND_i386_coreboot_TRUE@pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@pata_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@pata_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@pata_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@pata_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@pata_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@biosdisk_module_SOURCES = disk/i386/pc/biosdisk.c ## platform sources
+@COND_i386_pc_TRUE@nodist_biosdisk_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@biosdisk_module_LDADD =
+@COND_i386_pc_TRUE@biosdisk_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@biosdisk_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@biosdisk_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@biosdisk_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@biosdisk_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@usbms_module_SOURCES = disk/usbms.c ## platform sources
+@COND_i386_coreboot_TRUE@usbms_module_SOURCES = disk/usbms.c ## platform sources
+@COND_i386_efi_TRUE@usbms_module_SOURCES = disk/usbms.c ## platform sources
+@COND_i386_ieee1275_TRUE@usbms_module_SOURCES = disk/usbms.c ## platform sources
+@COND_i386_multiboot_TRUE@usbms_module_SOURCES = disk/usbms.c ## platform sources
+@COND_i386_pc_TRUE@usbms_module_SOURCES = disk/usbms.c ## platform sources
+@COND_i386_qemu_TRUE@usbms_module_SOURCES = disk/usbms.c ## platform sources
+@COND_mips_loongson_TRUE@usbms_module_SOURCES = disk/usbms.c ## platform sources
+@COND_x86_64_efi_TRUE@usbms_module_SOURCES = disk/usbms.c ## platform sources
+@COND_arm_coreboot_TRUE@nodist_usbms_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_usbms_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_usbms_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_usbms_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_usbms_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_usbms_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_usbms_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_usbms_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_usbms_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@usbms_module_LDADD =
+@COND_i386_coreboot_TRUE@usbms_module_LDADD =
+@COND_i386_efi_TRUE@usbms_module_LDADD =
+@COND_i386_ieee1275_TRUE@usbms_module_LDADD =
+@COND_i386_multiboot_TRUE@usbms_module_LDADD =
+@COND_i386_pc_TRUE@usbms_module_LDADD =
+@COND_i386_qemu_TRUE@usbms_module_LDADD =
+@COND_mips_loongson_TRUE@usbms_module_LDADD =
+@COND_x86_64_efi_TRUE@usbms_module_LDADD =
+@COND_arm_coreboot_TRUE@usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbms_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbms_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbms_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usbms_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@usbms_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@nand_module_SOURCES = disk/ieee1275/nand.c ## platform sources
+@COND_i386_ieee1275_TRUE@nodist_nand_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nand_module_LDADD =
+@COND_i386_ieee1275_TRUE@nand_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@nand_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@nand_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@nand_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@nand_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@efiemu_module_SOURCES = efiemu/i386/pc/cfgtables.c efiemu/main.c efiemu/i386/loadcore32.c efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c efiemu/i386/coredetect.c ## platform sources
+@COND_i386_ieee1275_TRUE@efiemu_module_SOURCES = efiemu/i386/nocfgtables.c efiemu/main.c efiemu/i386/loadcore32.c efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c efiemu/i386/coredetect.c ## platform sources
+@COND_i386_multiboot_TRUE@efiemu_module_SOURCES = efiemu/i386/pc/cfgtables.c efiemu/main.c efiemu/i386/loadcore32.c efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c efiemu/i386/coredetect.c ## platform sources
+@COND_i386_pc_TRUE@efiemu_module_SOURCES = efiemu/i386/pc/cfgtables.c efiemu/main.c efiemu/i386/loadcore32.c efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c efiemu/i386/coredetect.c ## platform sources
+@COND_i386_qemu_TRUE@efiemu_module_SOURCES = efiemu/i386/nocfgtables.c efiemu/main.c efiemu/i386/loadcore32.c efiemu/i386/loadcore64.c efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c efiemu/loadcore32.c efiemu/loadcore64.c efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c efiemu/i386/coredetect.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_efiemu_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_efiemu_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_efiemu_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_efiemu_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_efiemu_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@efiemu_module_LDADD =
+@COND_i386_ieee1275_TRUE@efiemu_module_LDADD =
+@COND_i386_multiboot_TRUE@efiemu_module_LDADD =
+@COND_i386_pc_TRUE@efiemu_module_LDADD =
+@COND_i386_qemu_TRUE@efiemu_module_LDADD =
+@COND_i386_coreboot_TRUE@efiemu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@efiemu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@efiemu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@efiemu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@efiemu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@efiemu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@efiemu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@efiemu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@efiemu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@efiemu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@efiemu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@efiemu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@efiemu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@efiemu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@efiemu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@efiemu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@efiemu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@efiemu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@efiemu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@efiemu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@efiemu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@efiemu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@efiemu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@efiemu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@efiemu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_arm_efi_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_arm_uboot_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_emu_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_i386_efi_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_i386_ieee1275_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_i386_multiboot_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_i386_pc_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_i386_qemu_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_i386_xen_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_i386_xen_pvh_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_ia64_efi_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_mips_arc_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_mips_qemu_mips_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_riscv32_efi_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_riscv64_efi_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_x86_64_efi_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_x86_64_xen_TRUE@font_module_SOURCES = font/font.c font/font_cmd.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_font_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@font_module_LDADD =
+@COND_arm_efi_TRUE@font_module_LDADD =
+@COND_arm_uboot_TRUE@font_module_LDADD =
+@COND_emu_TRUE@font_module_LDADD =
+@COND_i386_efi_TRUE@font_module_LDADD =
+@COND_i386_ieee1275_TRUE@font_module_LDADD =
+@COND_i386_multiboot_TRUE@font_module_LDADD =
+@COND_i386_pc_TRUE@font_module_LDADD =
+@COND_i386_qemu_TRUE@font_module_LDADD =
+@COND_i386_xen_TRUE@font_module_LDADD =
+@COND_i386_xen_pvh_TRUE@font_module_LDADD =
+@COND_ia64_efi_TRUE@font_module_LDADD =
+@COND_mips_arc_TRUE@font_module_LDADD =
+@COND_mips_qemu_mips_TRUE@font_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@font_module_LDADD =
+@COND_riscv32_efi_TRUE@font_module_LDADD =
+@COND_riscv64_efi_TRUE@font_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@font_module_LDADD =
+@COND_x86_64_efi_TRUE@font_module_LDADD =
+@COND_x86_64_xen_TRUE@font_module_LDADD =
+@COND_arm64_efi_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@font_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@font_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@font_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@font_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@font_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+procfs_module_SOURCES = fs/proc.c ## platform sources
+nodist_procfs_module_SOURCES = ## platform nodist sources
+procfs_module_LDADD =
+procfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+procfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+procfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+procfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+procfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+affs_module_SOURCES = fs/affs.c ## platform sources
+nodist_affs_module_SOURCES = ## platform nodist sources
+affs_module_LDADD =
+affs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+affs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+affs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+affs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+affs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+afs_module_SOURCES = fs/afs.c ## platform sources
+nodist_afs_module_SOURCES = ## platform nodist sources
+afs_module_LDADD =
+afs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+afs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+afs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+afs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+afs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+bfs_module_SOURCES = fs/bfs.c ## platform sources
+nodist_bfs_module_SOURCES = ## platform nodist sources
+bfs_module_LDADD =
+bfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+zstd_module_SOURCES = lib/zstd/debug.c lib/zstd/entropy_common.c lib/zstd/error_private.c lib/zstd/fse_decompress.c lib/zstd/huf_decompress.c lib/zstd/module.c lib/zstd/xxhash.c lib/zstd/zstd_common.c lib/zstd/zstd_decompress.c ## platform sources
+nodist_zstd_module_SOURCES = ## platform nodist sources
+zstd_module_LDADD =
+zstd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) -Wno-undef
+zstd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+zstd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/zstd
+zstd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+zstd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+btrfs_module_SOURCES = fs/btrfs.c lib/crc.c ## platform sources
+nodist_btrfs_module_SOURCES = ## platform nodist sources
+btrfs_module_LDADD =
+btrfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) -Wno-undef
+btrfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+btrfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -I$(srcdir)/lib/zstd -DMINILZO_HAVE_CONFIG_H
+btrfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+btrfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+archelp_module_SOURCES = fs/archelp.c ## platform sources
+nodist_archelp_module_SOURCES = ## platform nodist sources
+archelp_module_LDADD =
+archelp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+archelp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+archelp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+archelp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+archelp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+cbfs_module_SOURCES = fs/cbfs.c ## platform sources
+nodist_cbfs_module_SOURCES = ## platform nodist sources
+cbfs_module_LDADD =
+cbfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cbfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cbfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cbfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cbfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+cpio_module_SOURCES = fs/cpio.c ## platform sources
+nodist_cpio_module_SOURCES = ## platform nodist sources
+cpio_module_LDADD =
+cpio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+cpio_be_module_SOURCES = fs/cpio_be.c ## platform sources
+nodist_cpio_be_module_SOURCES = ## platform nodist sources
+cpio_be_module_LDADD =
+cpio_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cpio_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cpio_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cpio_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cpio_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+newc_module_SOURCES = fs/newc.c ## platform sources
+nodist_newc_module_SOURCES = ## platform nodist sources
+newc_module_LDADD =
+newc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+newc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+newc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+newc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+newc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+odc_module_SOURCES = fs/odc.c ## platform sources
+nodist_odc_module_SOURCES = ## platform nodist sources
+odc_module_LDADD =
+odc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+odc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+odc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+odc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+odc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+ext2_module_SOURCES = fs/ext2.c ## platform sources
+nodist_ext2_module_SOURCES = ## platform nodist sources
+ext2_module_LDADD =
+ext2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ext2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ext2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ext2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ext2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+fat_module_SOURCES = fs/fat.c ## platform sources
+nodist_fat_module_SOURCES = ## platform nodist sources
+fat_module_LDADD =
+fat_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fat_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fat_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fat_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fat_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+exfat_module_SOURCES = fs/exfat.c ## platform sources
+nodist_exfat_module_SOURCES = ## platform nodist sources
+exfat_module_LDADD =
+exfat_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+exfat_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+exfat_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+exfat_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+exfat_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+f2fs_module_SOURCES = fs/f2fs.c ## platform sources
+nodist_f2fs_module_SOURCES = ## platform nodist sources
+f2fs_module_LDADD =
+f2fs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+f2fs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+f2fs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+f2fs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+f2fs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+fshelp_module_SOURCES = fs/fshelp.c ## platform sources
+nodist_fshelp_module_SOURCES = ## platform nodist sources
+fshelp_module_LDADD =
+fshelp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+fshelp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+fshelp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+fshelp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+fshelp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+hfs_module_SOURCES = fs/hfs.c ## platform sources
+nodist_hfs_module_SOURCES = ## platform nodist sources
+hfs_module_LDADD =
+hfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+hfsplus_module_SOURCES = fs/hfsplus.c ## platform sources
+nodist_hfsplus_module_SOURCES = ## platform nodist sources
+hfsplus_module_LDADD =
+hfsplus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hfsplus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hfsplus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hfsplus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hfsplus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+hfspluscomp_module_SOURCES = fs/hfspluscomp.c ## platform sources
+nodist_hfspluscomp_module_SOURCES = ## platform nodist sources
+hfspluscomp_module_LDADD =
+hfspluscomp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hfspluscomp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hfspluscomp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hfspluscomp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hfspluscomp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+iso9660_module_SOURCES = fs/iso9660.c ## platform sources
+nodist_iso9660_module_SOURCES = ## platform nodist sources
+iso9660_module_LDADD =
+iso9660_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+iso9660_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+iso9660_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+iso9660_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+iso9660_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+jfs_module_SOURCES = fs/jfs.c ## platform sources
+nodist_jfs_module_SOURCES = ## platform nodist sources
+jfs_module_LDADD =
+jfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+jfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+jfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+jfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+jfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+minix_module_SOURCES = fs/minix.c ## platform sources
+nodist_minix_module_SOURCES = ## platform nodist sources
+minix_module_LDADD =
+minix_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+minix2_module_SOURCES = fs/minix2.c ## platform sources
+nodist_minix2_module_SOURCES = ## platform nodist sources
+minix2_module_LDADD =
+minix2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+minix3_module_SOURCES = fs/minix3.c ## platform sources
+nodist_minix3_module_SOURCES = ## platform nodist sources
+minix3_module_LDADD =
+minix3_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix3_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix3_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix3_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix3_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+minix_be_module_SOURCES = fs/minix_be.c ## platform sources
+nodist_minix_be_module_SOURCES = ## platform nodist sources
+minix_be_module_LDADD =
+minix_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+minix2_be_module_SOURCES = fs/minix2_be.c ## platform sources
+nodist_minix2_be_module_SOURCES = ## platform nodist sources
+minix2_be_module_LDADD =
+minix2_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix2_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix2_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix2_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix2_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+minix3_be_module_SOURCES = fs/minix3_be.c ## platform sources
+nodist_minix3_be_module_SOURCES = ## platform nodist sources
+minix3_be_module_LDADD =
+minix3_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+minix3_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+minix3_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+minix3_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+minix3_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+nilfs2_module_SOURCES = fs/nilfs2.c ## platform sources
+nodist_nilfs2_module_SOURCES = ## platform nodist sources
+nilfs2_module_LDADD =
+nilfs2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+nilfs2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+nilfs2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+nilfs2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+nilfs2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+ntfs_module_SOURCES = fs/ntfs.c ## platform sources
+nodist_ntfs_module_SOURCES = ## platform nodist sources
+ntfs_module_LDADD =
+ntfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ntfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ntfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ntfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ntfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+ntfscomp_module_SOURCES = fs/ntfscomp.c ## platform sources
+nodist_ntfscomp_module_SOURCES = ## platform nodist sources
+ntfscomp_module_LDADD =
+ntfscomp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ntfscomp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ntfscomp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ntfscomp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ntfscomp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+reiserfs_module_SOURCES = fs/reiserfs.c ## platform sources
+nodist_reiserfs_module_SOURCES = ## platform nodist sources
+reiserfs_module_LDADD =
+reiserfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+reiserfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+reiserfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+reiserfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+reiserfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+romfs_module_SOURCES = fs/romfs.c ## platform sources
+nodist_romfs_module_SOURCES = ## platform nodist sources
+romfs_module_LDADD =
+romfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+romfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+romfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+romfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+romfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+sfs_module_SOURCES = fs/sfs.c ## platform sources
+nodist_sfs_module_SOURCES = ## platform nodist sources
+sfs_module_LDADD =
+sfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+sfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+sfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+sfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+sfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+squash4_module_SOURCES = fs/squash4.c ## platform sources
+nodist_squash4_module_SOURCES = ## platform nodist sources
+squash4_module_LDADD =
+squash4_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) -Wno-undef
+squash4_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+squash4_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H
+squash4_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+squash4_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+tar_module_SOURCES = fs/tar.c ## platform sources
+nodist_tar_module_SOURCES = ## platform nodist sources
+tar_module_LDADD =
+tar_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tar_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tar_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tar_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tar_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+udf_module_SOURCES = fs/udf.c ## platform sources
+nodist_udf_module_SOURCES = ## platform nodist sources
+udf_module_LDADD =
+udf_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+udf_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+udf_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+udf_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+udf_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+ufs1_module_SOURCES = fs/ufs.c ## platform sources
+nodist_ufs1_module_SOURCES = ## platform nodist sources
+ufs1_module_LDADD =
+ufs1_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ufs1_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ufs1_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ufs1_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ufs1_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+ufs1_be_module_SOURCES = fs/ufs_be.c ## platform sources
+nodist_ufs1_be_module_SOURCES = ## platform nodist sources
+ufs1_be_module_LDADD =
+ufs1_be_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ufs1_be_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ufs1_be_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ufs1_be_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ufs1_be_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+ufs2_module_SOURCES = fs/ufs2.c ## platform sources
+nodist_ufs2_module_SOURCES = ## platform nodist sources
+ufs2_module_LDADD =
+ufs2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ufs2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ufs2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ufs2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ufs2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+xfs_module_SOURCES = fs/xfs.c ## platform sources
+nodist_xfs_module_SOURCES = ## platform nodist sources
+xfs_module_LDADD =
+xfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+zfs_module_SOURCES = fs/zfs/zfs.c fs/zfs/zfs_lzjb.c fs/zfs/zfs_lz4.c fs/zfs/zfs_sha256.c fs/zfs/zfs_fletcher.c ## platform sources
+nodist_zfs_module_SOURCES = ## platform nodist sources
+zfs_module_LDADD =
+zfs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+zfs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+zfs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+zfs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+zfs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+zfscrypt_module_SOURCES = fs/zfs/zfscrypt.c ## platform sources
+nodist_zfscrypt_module_SOURCES = ## platform nodist sources
+zfscrypt_module_LDADD =
+zfscrypt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+zfscrypt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+zfscrypt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+zfscrypt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+zfscrypt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+zfsinfo_module_SOURCES = fs/zfs/zfsinfo.c ## platform sources
+nodist_zfsinfo_module_SOURCES = ## platform nodist sources
+zfsinfo_module_LDADD =
+zfsinfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+zfsinfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+zfsinfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+zfsinfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+zfsinfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+macbless_module_SOURCES = commands/macbless.c ## platform sources
+nodist_macbless_module_SOURCES = ## platform nodist sources
+macbless_module_LDADD =
+macbless_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+macbless_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+macbless_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+macbless_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+macbless_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@pxe_module_SOURCES = net/drivers/i386/pc/pxe.c ## platform sources
+@COND_i386_pc_TRUE@nodist_pxe_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@pxe_module_LDADD =
+@COND_i386_pc_TRUE@pxe_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@pxe_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@pxe_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@pxe_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@pxe_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gettext_module_SOURCES = gettext/gettext.c ## platform sources
+nodist_gettext_module_SOURCES = ## platform nodist sources
+gettext_module_LDADD =
+gettext_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gettext_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gettext_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gettext_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gettext_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gfxmenu_module_SOURCES = gfxmenu/gfxmenu.c gfxmenu/view.c gfxmenu/font.c gfxmenu/icon_manager.c gfxmenu/theme_loader.c gfxmenu/widget-box.c gfxmenu/gui_canvas.c gfxmenu/gui_circular_progress.c gfxmenu/gui_box.c gfxmenu/gui_label.c gfxmenu/gui_list.c gfxmenu/gui_image.c gfxmenu/gui_progress_bar.c gfxmenu/gui_util.c gfxmenu/gui_string_util.c ## platform sources
+nodist_gfxmenu_module_SOURCES = ## platform nodist sources
+gfxmenu_module_LDADD =
+gfxmenu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxmenu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxmenu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxmenu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxmenu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+hello_module_SOURCES = hello/hello.c ## platform sources
+nodist_hello_module_SOURCES = ## platform nodist sources
+hello_module_LDADD =
+hello_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+hello_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+hello_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+hello_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+hello_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gzio_module_SOURCES = io/gzio.c ## platform sources
+nodist_gzio_module_SOURCES = ## platform nodist sources
+gzio_module_LDADD =
+gzio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gzio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gzio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gzio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gzio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+offsetio_module_SOURCES = io/offset.c ## platform sources
+nodist_offsetio_module_SOURCES = ## platform nodist sources
+offsetio_module_LDADD =
+offsetio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+offsetio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+offsetio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+offsetio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+offsetio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_arm_efi_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_arm_uboot_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_emu_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_i386_efi_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_i386_ieee1275_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_i386_multiboot_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_i386_pc_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_i386_qemu_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_i386_xen_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_i386_xen_pvh_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_ia64_efi_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_mips_arc_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_mips_qemu_mips_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_riscv32_efi_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_riscv64_efi_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_x86_64_efi_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_x86_64_xen_TRUE@bufio_module_SOURCES = io/bufio.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_bufio_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@bufio_module_LDADD =
+@COND_arm_efi_TRUE@bufio_module_LDADD =
+@COND_arm_uboot_TRUE@bufio_module_LDADD =
+@COND_emu_TRUE@bufio_module_LDADD =
+@COND_i386_efi_TRUE@bufio_module_LDADD =
+@COND_i386_ieee1275_TRUE@bufio_module_LDADD =
+@COND_i386_multiboot_TRUE@bufio_module_LDADD =
+@COND_i386_pc_TRUE@bufio_module_LDADD =
+@COND_i386_qemu_TRUE@bufio_module_LDADD =
+@COND_i386_xen_TRUE@bufio_module_LDADD =
+@COND_i386_xen_pvh_TRUE@bufio_module_LDADD =
+@COND_ia64_efi_TRUE@bufio_module_LDADD =
+@COND_mips_arc_TRUE@bufio_module_LDADD =
+@COND_mips_qemu_mips_TRUE@bufio_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@bufio_module_LDADD =
+@COND_riscv32_efi_TRUE@bufio_module_LDADD =
+@COND_riscv64_efi_TRUE@bufio_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@bufio_module_LDADD =
+@COND_x86_64_efi_TRUE@bufio_module_LDADD =
+@COND_x86_64_xen_TRUE@bufio_module_LDADD =
+@COND_arm64_efi_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@bufio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@bufio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@bufio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@bufio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@bufio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+elf_module_SOURCES = kern/elf.c ## platform sources
+nodist_elf_module_SOURCES = ## platform nodist sources
+elf_module_LDADD =
+elf_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+elf_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+elf_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+elf_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+elf_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+crypto_module_SOURCES = lib/crypto.c ## platform sources
+nodist_crypto_module_SOURCES = ## platform nodist sources
+crypto_module_LDADD =
+crypto_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+crypto_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+crypto_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+crypto_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+crypto_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+pbkdf2_module_SOURCES = lib/pbkdf2.c ## platform sources
+nodist_pbkdf2_module_SOURCES = ## platform nodist sources
+pbkdf2_module_LDADD =
+pbkdf2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pbkdf2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pbkdf2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pbkdf2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pbkdf2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+@COND_i386_efi_TRUE@relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/efi/relocator.c lib/relocator.c ## platform sources
+@COND_i386_ieee1275_TRUE@relocator_module_SOURCES = lib/ieee1275/relocator.c lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+@COND_i386_multiboot_TRUE@relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+@COND_i386_pc_TRUE@relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+@COND_i386_qemu_TRUE@relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+@COND_i386_xen_TRUE@relocator_module_SOURCES = lib/i386/relocator_asm.S lib/i386/xen/relocator.S lib/xen/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+@COND_i386_xen_pvh_TRUE@relocator_module_SOURCES = lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator_asm.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+@COND_mips_arc_TRUE@relocator_module_SOURCES = lib/mips/relocator_asm.S lib/mips/relocator.c lib/relocator.c ## platform sources
+@COND_mips_loongson_TRUE@relocator_module_SOURCES = lib/mips/relocator_asm.S lib/mips/relocator.c lib/relocator.c ## platform sources
+@COND_mips_qemu_mips_TRUE@relocator_module_SOURCES = lib/mips/relocator_asm.S lib/mips/relocator.c lib/relocator.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@relocator_module_SOURCES = lib/powerpc/relocator_asm.S lib/powerpc/relocator.c lib/ieee1275/relocator.c lib/relocator.c ## platform sources
+@COND_x86_64_efi_TRUE@relocator_module_SOURCES = lib/x86_64/efi/relocator.c lib/x86_64/relocator_asm.S lib/i386/relocator16.S lib/i386/relocator32.S lib/i386/relocator64.S lib/i386/relocator.c lib/i386/relocator_common_c.c lib/efi/relocator.c lib/relocator.c ## platform sources
+@COND_x86_64_xen_TRUE@relocator_module_SOURCES = lib/x86_64/relocator_asm.S lib/x86_64/xen/relocator.S lib/xen/relocator.c lib/i386/relocator_common_c.c lib/relocator.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_relocator_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@relocator_module_LDADD =
+@COND_i386_efi_TRUE@relocator_module_LDADD =
+@COND_i386_ieee1275_TRUE@relocator_module_LDADD =
+@COND_i386_multiboot_TRUE@relocator_module_LDADD =
+@COND_i386_pc_TRUE@relocator_module_LDADD =
+@COND_i386_qemu_TRUE@relocator_module_LDADD =
+@COND_i386_xen_TRUE@relocator_module_LDADD =
+@COND_i386_xen_pvh_TRUE@relocator_module_LDADD =
+@COND_mips_arc_TRUE@relocator_module_LDADD =
+@COND_mips_loongson_TRUE@relocator_module_LDADD =
+@COND_mips_qemu_mips_TRUE@relocator_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@relocator_module_LDADD =
+@COND_x86_64_efi_TRUE@relocator_module_LDADD =
+@COND_x86_64_xen_TRUE@relocator_module_LDADD =
+@COND_i386_coreboot_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@relocator_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@relocator_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@relocator_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@relocator_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@relocator_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+@COND_arm_coreboot_TRUE@datetime_module_SOURCES = lib/dummy/datetime.c lib/datetime.c ## platform sources
+@COND_arm_efi_TRUE@datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+@COND_arm_uboot_TRUE@datetime_module_SOURCES = lib/dummy/datetime.c lib/datetime.c ## platform sources
+@COND_emu_TRUE@datetime_module_SOURCES = lib/datetime.c ## platform sources
+@COND_i386_coreboot_TRUE@datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+@COND_i386_efi_TRUE@datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+@COND_i386_ieee1275_TRUE@datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+@COND_i386_multiboot_TRUE@datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+@COND_i386_pc_TRUE@datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+@COND_i386_qemu_TRUE@datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+@COND_i386_xen_TRUE@datetime_module_SOURCES = lib/xen/datetime.c lib/datetime.c ## platform sources
+@COND_i386_xen_pvh_TRUE@datetime_module_SOURCES = lib/xen/datetime.c lib/datetime.c ## platform sources
+@COND_ia64_efi_TRUE@datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+@COND_mips_arc_TRUE@datetime_module_SOURCES = lib/arc/datetime.c lib/datetime.c ## platform sources
+@COND_mips_loongson_TRUE@datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+@COND_mips_qemu_mips_TRUE@datetime_module_SOURCES = lib/cmos_datetime.c lib/datetime.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@datetime_module_SOURCES = lib/ieee1275/datetime.c lib/ieee1275/cmos.c lib/cmos_datetime.c lib/datetime.c ## platform sources
+@COND_riscv32_efi_TRUE@datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+@COND_riscv64_efi_TRUE@datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@datetime_module_SOURCES = lib/ieee1275/datetime.c lib/ieee1275/cmos.c lib/cmos_datetime.c lib/datetime.c ## platform sources
+@COND_x86_64_efi_TRUE@datetime_module_SOURCES = lib/efi/datetime.c lib/datetime.c ## platform sources
+@COND_x86_64_xen_TRUE@datetime_module_SOURCES = lib/xen/datetime.c lib/datetime.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_datetime_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@datetime_module_LDADD =
+@COND_arm_coreboot_TRUE@datetime_module_LDADD =
+@COND_arm_efi_TRUE@datetime_module_LDADD =
+@COND_arm_uboot_TRUE@datetime_module_LDADD =
+@COND_emu_TRUE@datetime_module_LDADD =
+@COND_i386_coreboot_TRUE@datetime_module_LDADD =
+@COND_i386_efi_TRUE@datetime_module_LDADD =
+@COND_i386_ieee1275_TRUE@datetime_module_LDADD =
+@COND_i386_multiboot_TRUE@datetime_module_LDADD =
+@COND_i386_pc_TRUE@datetime_module_LDADD =
+@COND_i386_qemu_TRUE@datetime_module_LDADD =
+@COND_i386_xen_TRUE@datetime_module_LDADD =
+@COND_i386_xen_pvh_TRUE@datetime_module_LDADD =
+@COND_ia64_efi_TRUE@datetime_module_LDADD =
+@COND_mips_arc_TRUE@datetime_module_LDADD =
+@COND_mips_loongson_TRUE@datetime_module_LDADD =
+@COND_mips_qemu_mips_TRUE@datetime_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@datetime_module_LDADD =
+@COND_riscv32_efi_TRUE@datetime_module_LDADD =
+@COND_riscv64_efi_TRUE@datetime_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@datetime_module_LDADD =
+@COND_x86_64_efi_TRUE@datetime_module_LDADD =
+@COND_x86_64_xen_TRUE@datetime_module_LDADD =
+@COND_arm64_efi_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@datetime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@datetime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@datetime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@datetime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@datetime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+setjmp_module_SOURCES = lib/setjmp.S ## platform sources
+nodist_setjmp_module_SOURCES = ## platform nodist sources
+setjmp_module_LDADD =
+setjmp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setjmp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setjmp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setjmp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setjmp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@aout_module_SOURCES = loader/aout.c ## platform sources
+@COND_i386_efi_TRUE@aout_module_SOURCES = loader/aout.c ## platform sources
+@COND_i386_ieee1275_TRUE@aout_module_SOURCES = loader/aout.c ## platform sources
+@COND_i386_multiboot_TRUE@aout_module_SOURCES = loader/aout.c ## platform sources
+@COND_i386_pc_TRUE@aout_module_SOURCES = loader/aout.c ## platform sources
+@COND_i386_qemu_TRUE@aout_module_SOURCES = loader/aout.c ## platform sources
+@COND_x86_64_efi_TRUE@aout_module_SOURCES = loader/aout.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_aout_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_aout_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_aout_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_aout_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_aout_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_aout_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_aout_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@aout_module_LDADD =
+@COND_i386_efi_TRUE@aout_module_LDADD =
+@COND_i386_ieee1275_TRUE@aout_module_LDADD =
+@COND_i386_multiboot_TRUE@aout_module_LDADD =
+@COND_i386_pc_TRUE@aout_module_LDADD =
+@COND_i386_qemu_TRUE@aout_module_LDADD =
+@COND_x86_64_efi_TRUE@aout_module_LDADD =
+@COND_i386_coreboot_TRUE@aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@aout_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@aout_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@aout_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@aout_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@aout_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+@COND_i386_efi_TRUE@bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+@COND_i386_ieee1275_TRUE@bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+@COND_i386_multiboot_TRUE@bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+@COND_i386_pc_TRUE@bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+@COND_i386_qemu_TRUE@bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+@COND_x86_64_efi_TRUE@bsd_module_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_bsd_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_bsd_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_bsd_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_bsd_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_bsd_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_bsd_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_bsd_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@bsd_module_LDADD =
+@COND_i386_efi_TRUE@bsd_module_LDADD =
+@COND_i386_ieee1275_TRUE@bsd_module_LDADD =
+@COND_i386_multiboot_TRUE@bsd_module_LDADD =
+@COND_i386_pc_TRUE@bsd_module_LDADD =
+@COND_i386_qemu_TRUE@bsd_module_LDADD =
+@COND_x86_64_efi_TRUE@bsd_module_LDADD =
+@COND_i386_coreboot_TRUE@bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@plan9_module_SOURCES = loader/i386/pc/plan9.c ## platform sources
+@COND_i386_pc_TRUE@nodist_plan9_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@plan9_module_LDADD =
+@COND_i386_pc_TRUE@plan9_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@plan9_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@plan9_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@plan9_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@plan9_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+@COND_i386_efi_TRUE@linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+@COND_i386_ieee1275_TRUE@linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+@COND_i386_multiboot_TRUE@linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+@COND_i386_pc_TRUE@linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+@COND_i386_qemu_TRUE@linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+@COND_x86_64_efi_TRUE@linux16_module_SOURCES = loader/i386/pc/linux.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_linux16_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_linux16_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_linux16_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_linux16_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_linux16_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_linux16_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_linux16_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@linux16_module_LDADD =
+@COND_i386_efi_TRUE@linux16_module_LDADD =
+@COND_i386_ieee1275_TRUE@linux16_module_LDADD =
+@COND_i386_multiboot_TRUE@linux16_module_LDADD =
+@COND_i386_pc_TRUE@linux16_module_LDADD =
+@COND_i386_qemu_TRUE@linux16_module_LDADD =
+@COND_x86_64_efi_TRUE@linux16_module_LDADD =
+@COND_i386_coreboot_TRUE@linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@linux16_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@linux16_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@linux16_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@linux16_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@linux16_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@ntldr_module_SOURCES = loader/i386/pc/ntldr.c ## platform sources
+@COND_i386_pc_TRUE@nodist_ntldr_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@ntldr_module_LDADD =
+@COND_i386_pc_TRUE@ntldr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@ntldr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@ntldr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@ntldr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@ntldr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@truecrypt_module_SOURCES = loader/i386/pc/truecrypt.c ## platform sources
+@COND_i386_pc_TRUE@nodist_truecrypt_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@truecrypt_module_LDADD =
+@COND_i386_pc_TRUE@truecrypt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@truecrypt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@truecrypt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@truecrypt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@truecrypt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@freedos_module_SOURCES = loader/i386/pc/freedos.c ## platform sources
+@COND_i386_pc_TRUE@nodist_freedos_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@freedos_module_LDADD =
+@COND_i386_pc_TRUE@freedos_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@freedos_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@freedos_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@freedos_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@freedos_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@pxechain_module_SOURCES = loader/i386/pc/pxechainloader.c ## platform sources
+@COND_i386_pc_TRUE@nodist_pxechain_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@pxechain_module_LDADD =
+@COND_i386_pc_TRUE@pxechain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@pxechain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@pxechain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@pxechain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@pxechain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_i386_efi_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_i386_ieee1275_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_i386_multiboot_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_i386_pc_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_i386_qemu_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_i386_xen_pvh_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_mips_arc_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_mips_loongson_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_mips_qemu_mips_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_x86_64_efi_TRUE@multiboot2_module_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_multiboot2_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@multiboot2_module_LDADD =
+@COND_i386_efi_TRUE@multiboot2_module_LDADD =
+@COND_i386_ieee1275_TRUE@multiboot2_module_LDADD =
+@COND_i386_multiboot_TRUE@multiboot2_module_LDADD =
+@COND_i386_pc_TRUE@multiboot2_module_LDADD =
+@COND_i386_qemu_TRUE@multiboot2_module_LDADD =
+@COND_i386_xen_pvh_TRUE@multiboot2_module_LDADD =
+@COND_mips_arc_TRUE@multiboot2_module_LDADD =
+@COND_mips_loongson_TRUE@multiboot2_module_LDADD =
+@COND_mips_qemu_mips_TRUE@multiboot2_module_LDADD =
+@COND_x86_64_efi_TRUE@multiboot2_module_LDADD =
+@COND_i386_coreboot_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@multiboot2_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@multiboot2_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_i386_efi_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_i386_ieee1275_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_i386_multiboot_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_i386_pc_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_i386_qemu_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_i386_xen_pvh_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_mips_arc_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_mips_loongson_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_mips_qemu_mips_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_x86_64_efi_TRUE@multiboot2_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -DGRUB_USE_MULTIBOOT2
+@COND_i386_coreboot_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@multiboot2_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@multiboot2_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+@COND_i386_efi_TRUE@multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+@COND_i386_ieee1275_TRUE@multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+@COND_i386_multiboot_TRUE@multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+@COND_i386_pc_TRUE@multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+@COND_i386_qemu_TRUE@multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+@COND_i386_xen_pvh_TRUE@multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+@COND_x86_64_efi_TRUE@multiboot_module_SOURCES = loader/i386/multiboot_mbi.c loader/multiboot.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_multiboot_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_multiboot_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_multiboot_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_multiboot_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_multiboot_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_multiboot_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_multiboot_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_multiboot_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@multiboot_module_LDADD =
+@COND_i386_efi_TRUE@multiboot_module_LDADD =
+@COND_i386_ieee1275_TRUE@multiboot_module_LDADD =
+@COND_i386_multiboot_TRUE@multiboot_module_LDADD =
+@COND_i386_pc_TRUE@multiboot_module_LDADD =
+@COND_i386_qemu_TRUE@multiboot_module_LDADD =
+@COND_i386_xen_pvh_TRUE@multiboot_module_LDADD =
+@COND_x86_64_efi_TRUE@multiboot_module_LDADD =
+@COND_i386_coreboot_TRUE@multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@multiboot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@multiboot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@multiboot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@multiboot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@multiboot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@xen_boot_module_SOURCES = loader/arm64/xen_boot.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_xen_boot_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@xen_boot_module_LDADD =
+@COND_arm64_efi_TRUE@xen_boot_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@xen_boot_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@xen_boot_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@xen_boot_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@xen_boot_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@linux_module_SOURCES = loader/arm64/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_arm_coreboot_TRUE@linux_module_SOURCES = loader/arm/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_arm_efi_TRUE@linux_module_SOURCES = loader/arm64/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_arm_uboot_TRUE@linux_module_SOURCES = loader/arm/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_i386_coreboot_TRUE@linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_i386_efi_TRUE@linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_i386_ieee1275_TRUE@linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_i386_multiboot_TRUE@linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_i386_pc_TRUE@linux_module_SOURCES = lib/i386/pc/vesa_modes_table.c loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_i386_qemu_TRUE@linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_i386_xen_TRUE@linux_module_SOURCES = loader/i386/xen.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_i386_xen_pvh_TRUE@linux_module_SOURCES = loader/i386/linux.c lib/i386/pc/vesa_modes_table.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_ia64_efi_TRUE@linux_module_SOURCES = loader/ia64/efi/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_mips_arc_TRUE@linux_module_SOURCES = loader/mips/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_mips_loongson_TRUE@linux_module_SOURCES = loader/mips/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_mips_qemu_mips_TRUE@linux_module_SOURCES = loader/mips/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@linux_module_SOURCES = loader/powerpc/ieee1275/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_riscv32_efi_TRUE@linux_module_SOURCES = loader/riscv/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_riscv64_efi_TRUE@linux_module_SOURCES = loader/riscv/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@linux_module_SOURCES = loader/sparc64/ieee1275/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_x86_64_efi_TRUE@linux_module_SOURCES = loader/i386/linux.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_x86_64_xen_TRUE@linux_module_SOURCES = loader/i386/xen.c loader/linux.c lib/cmdline.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_linux_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@linux_module_LDADD =
+@COND_arm_coreboot_TRUE@linux_module_LDADD =
+@COND_arm_efi_TRUE@linux_module_LDADD =
+@COND_arm_uboot_TRUE@linux_module_LDADD =
+@COND_i386_coreboot_TRUE@linux_module_LDADD =
+@COND_i386_efi_TRUE@linux_module_LDADD =
+@COND_i386_ieee1275_TRUE@linux_module_LDADD =
+@COND_i386_multiboot_TRUE@linux_module_LDADD =
+@COND_i386_pc_TRUE@linux_module_LDADD =
+@COND_i386_qemu_TRUE@linux_module_LDADD =
+@COND_i386_xen_TRUE@linux_module_LDADD =
+@COND_i386_xen_pvh_TRUE@linux_module_LDADD =
+@COND_ia64_efi_TRUE@linux_module_LDADD =
+@COND_mips_arc_TRUE@linux_module_LDADD =
+@COND_mips_loongson_TRUE@linux_module_LDADD =
+@COND_mips_qemu_mips_TRUE@linux_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@linux_module_LDADD =
+@COND_riscv32_efi_TRUE@linux_module_LDADD =
+@COND_riscv64_efi_TRUE@linux_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@linux_module_LDADD =
+@COND_x86_64_efi_TRUE@linux_module_LDADD =
+@COND_x86_64_xen_TRUE@linux_module_LDADD =
+@COND_arm64_efi_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@linux_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@linux_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@linux_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@linux_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@linux_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@fdt_module_SOURCES = loader/efi/fdt.c lib/fdt.c ## platform sources
+@COND_arm_efi_TRUE@fdt_module_SOURCES = loader/efi/fdt.c lib/fdt.c ## platform sources
+@COND_arm_uboot_TRUE@fdt_module_SOURCES = lib/fdt.c ## platform sources
+@COND_riscv32_efi_TRUE@fdt_module_SOURCES = loader/efi/fdt.c lib/fdt.c ## platform sources
+@COND_riscv64_efi_TRUE@fdt_module_SOURCES = loader/efi/fdt.c lib/fdt.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_fdt_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_fdt_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_fdt_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_fdt_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_fdt_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@fdt_module_LDADD =
+@COND_arm_efi_TRUE@fdt_module_LDADD =
+@COND_arm_uboot_TRUE@fdt_module_LDADD =
+@COND_riscv32_efi_TRUE@fdt_module_LDADD =
+@COND_riscv64_efi_TRUE@fdt_module_LDADD =
+@COND_arm64_efi_TRUE@fdt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@fdt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@fdt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@fdt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@fdt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@fdt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@fdt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@fdt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@fdt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@fdt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@fdt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@fdt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@fdt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@fdt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@fdt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@fdt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@fdt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@fdt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@fdt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@fdt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@fdt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@fdt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@fdt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@fdt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@fdt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@xnu_module_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/xnu.c ## platform sources
+@COND_i386_efi_TRUE@xnu_module_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/xnu.c ## platform sources
+@COND_i386_multiboot_TRUE@xnu_module_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/xnu.c ## platform sources
+@COND_i386_pc_TRUE@xnu_module_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/xnu.c ## platform sources
+@COND_x86_64_efi_TRUE@xnu_module_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/xnu.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_xnu_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_xnu_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_xnu_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_xnu_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_xnu_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@xnu_module_LDADD =
+@COND_i386_efi_TRUE@xnu_module_LDADD =
+@COND_i386_multiboot_TRUE@xnu_module_LDADD =
+@COND_i386_pc_TRUE@xnu_module_LDADD =
+@COND_x86_64_efi_TRUE@xnu_module_LDADD =
+@COND_i386_coreboot_TRUE@xnu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@xnu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@xnu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@xnu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@xnu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@xnu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@xnu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@xnu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@xnu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@xnu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@xnu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@xnu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@xnu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@xnu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@xnu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@xnu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@xnu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@xnu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@xnu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@xnu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@xnu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@xnu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@xnu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@xnu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@xnu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@random_module_SOURCES = kern/i386/tsc_pmtimer.c lib/i386/random.c lib/random.c ## platform sources
+@COND_i386_efi_TRUE@random_module_SOURCES = lib/i386/random.c lib/random.c ## platform sources
+@COND_i386_multiboot_TRUE@random_module_SOURCES = kern/i386/tsc_pmtimer.c lib/i386/random.c lib/random.c ## platform sources
+@COND_i386_pc_TRUE@random_module_SOURCES = kern/i386/tsc_pmtimer.c lib/i386/random.c lib/random.c ## platform sources
+@COND_x86_64_efi_TRUE@random_module_SOURCES = lib/i386/random.c lib/random.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_random_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_random_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_random_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_random_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_random_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@random_module_LDADD =
+@COND_i386_efi_TRUE@random_module_LDADD =
+@COND_i386_multiboot_TRUE@random_module_LDADD =
+@COND_i386_pc_TRUE@random_module_LDADD =
+@COND_x86_64_efi_TRUE@random_module_LDADD =
+@COND_i386_coreboot_TRUE@random_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@random_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@random_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@random_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@random_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@random_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@random_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@random_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@random_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@random_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@random_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@random_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@random_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@random_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@random_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@random_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@random_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@random_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@random_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@random_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@random_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@random_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@random_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@random_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@random_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+macho_module_SOURCES = loader/macho.c loader/macho32.c loader/macho64.c loader/lzss.c ## platform sources
+nodist_macho_module_SOURCES = ## platform nodist sources
+macho_module_LDADD =
+macho_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+macho_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+macho_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+macho_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+macho_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@appleldr_module_SOURCES = loader/efi/appleloader.c ## platform sources
+@COND_x86_64_efi_TRUE@appleldr_module_SOURCES = loader/efi/appleloader.c ## platform sources
+@COND_i386_efi_TRUE@nodist_appleldr_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_appleldr_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@appleldr_module_LDADD =
+@COND_x86_64_efi_TRUE@appleldr_module_LDADD =
+@COND_i386_efi_TRUE@appleldr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@appleldr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@appleldr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@appleldr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@appleldr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@appleldr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@appleldr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@appleldr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@appleldr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@appleldr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+@COND_arm_efi_TRUE@chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+@COND_i386_coreboot_TRUE@chain_module_SOURCES = loader/i386/coreboot/chainloader.c lib/LzmaDec.c ## platform sources
+@COND_i386_efi_TRUE@chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+@COND_i386_pc_TRUE@chain_module_SOURCES = loader/i386/pc/chainloader.c ## platform sources
+@COND_ia64_efi_TRUE@chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+@COND_riscv32_efi_TRUE@chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+@COND_riscv64_efi_TRUE@chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+@COND_x86_64_efi_TRUE@chain_module_SOURCES = loader/efi/chainloader.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_chain_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_chain_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_chain_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_chain_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_chain_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_chain_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_chain_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_chain_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_chain_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@chain_module_LDADD =
+@COND_arm_efi_TRUE@chain_module_LDADD =
+@COND_i386_coreboot_TRUE@chain_module_LDADD =
+@COND_i386_efi_TRUE@chain_module_LDADD =
+@COND_i386_pc_TRUE@chain_module_LDADD =
+@COND_ia64_efi_TRUE@chain_module_LDADD =
+@COND_riscv32_efi_TRUE@chain_module_LDADD =
+@COND_riscv64_efi_TRUE@chain_module_LDADD =
+@COND_x86_64_efi_TRUE@chain_module_LDADD =
+@COND_arm64_efi_TRUE@chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@chain_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@chain_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@chain_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@chain_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@chain_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@mmap_module_SOURCES = mmap/efi/mmap.c mmap/mmap.c ## platform sources
+@COND_arm_efi_TRUE@mmap_module_SOURCES = mmap/efi/mmap.c mmap/mmap.c ## platform sources
+@COND_i386_coreboot_TRUE@mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+@COND_i386_efi_TRUE@mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/efi/mmap.c mmap/mmap.c ## platform sources
+@COND_i386_ieee1275_TRUE@mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+@COND_i386_multiboot_TRUE@mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+@COND_i386_pc_TRUE@mmap_module_SOURCES = mmap/i386/pc/mmap.c mmap/i386/pc/mmap_helper.S mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+@COND_i386_qemu_TRUE@mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+@COND_i386_xen_pvh_TRUE@mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/mmap.c ## platform sources
+@COND_ia64_efi_TRUE@mmap_module_SOURCES = mmap/efi/mmap.c mmap/mmap.c ## platform sources
+@COND_mips_arc_TRUE@mmap_module_SOURCES = mmap/mips/uppermem.c mmap/mmap.c ## platform sources
+@COND_mips_loongson_TRUE@mmap_module_SOURCES = mmap/mips/uppermem.c mmap/mmap.c ## platform sources
+@COND_mips_qemu_mips_TRUE@mmap_module_SOURCES = mmap/mips/uppermem.c mmap/mmap.c ## platform sources
+@COND_riscv32_efi_TRUE@mmap_module_SOURCES = mmap/efi/mmap.c mmap/mmap.c ## platform sources
+@COND_riscv64_efi_TRUE@mmap_module_SOURCES = mmap/efi/mmap.c mmap/mmap.c ## platform sources
+@COND_x86_64_efi_TRUE@mmap_module_SOURCES = mmap/i386/uppermem.c mmap/i386/mmap.c mmap/efi/mmap.c mmap/mmap.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_mmap_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@mmap_module_LDADD =
+@COND_arm_efi_TRUE@mmap_module_LDADD =
+@COND_i386_coreboot_TRUE@mmap_module_LDADD =
+@COND_i386_efi_TRUE@mmap_module_LDADD =
+@COND_i386_ieee1275_TRUE@mmap_module_LDADD =
+@COND_i386_multiboot_TRUE@mmap_module_LDADD =
+@COND_i386_pc_TRUE@mmap_module_LDADD =
+@COND_i386_qemu_TRUE@mmap_module_LDADD =
+@COND_i386_xen_pvh_TRUE@mmap_module_LDADD =
+@COND_ia64_efi_TRUE@mmap_module_LDADD =
+@COND_mips_arc_TRUE@mmap_module_LDADD =
+@COND_mips_loongson_TRUE@mmap_module_LDADD =
+@COND_mips_qemu_mips_TRUE@mmap_module_LDADD =
+@COND_riscv32_efi_TRUE@mmap_module_LDADD =
+@COND_riscv64_efi_TRUE@mmap_module_LDADD =
+@COND_x86_64_efi_TRUE@mmap_module_LDADD =
+@COND_arm64_efi_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@mmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@mmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@mmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@mmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@mmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+normal_module_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c normal/auth.c normal/autofs.c normal/color.c normal/completion.c normal/menu.c normal/menu_entry.c normal/menu_text.c normal/misc.c normal/crypto.c normal/term.c normal/context.c normal/charset.c lib/getline.c script/main.c script/script.c script/execute.c script/function.c script/lexer.c script/argv.c commands/menuentry.c unidata.c ## platform sources
+nodist_normal_module_SOURCES = grub_script.tab.c grub_script.yy.c grub_script.tab.h grub_script.yy.h ## platform nodist sources
+normal_module_LDADD =
+normal_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) -Wno-redundant-decls
+normal_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+normal_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_POSIX)
+normal_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+normal_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_acorn_module_SOURCES = partmap/acorn.c ## platform sources
+nodist_part_acorn_module_SOURCES = ## platform nodist sources
+part_acorn_module_LDADD =
+part_acorn_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_acorn_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_acorn_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_acorn_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_acorn_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_amiga_module_SOURCES = partmap/amiga.c ## platform sources
+nodist_part_amiga_module_SOURCES = ## platform nodist sources
+part_amiga_module_LDADD =
+part_amiga_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_amiga_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_amiga_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_amiga_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_amiga_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_apple_module_SOURCES = partmap/apple.c ## platform sources
+nodist_part_apple_module_SOURCES = ## platform nodist sources
+part_apple_module_LDADD =
+part_apple_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_apple_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_apple_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_apple_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_apple_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_gpt_module_SOURCES = partmap/gpt.c ## platform sources
+nodist_part_gpt_module_SOURCES = ## platform nodist sources
+part_gpt_module_LDADD =
+part_gpt_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_gpt_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_gpt_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_gpt_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_gpt_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_msdos_module_SOURCES = partmap/msdos.c ## platform sources
+nodist_part_msdos_module_SOURCES = ## platform nodist sources
+part_msdos_module_LDADD =
+part_msdos_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_msdos_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_msdos_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_msdos_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_msdos_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_sun_module_SOURCES = partmap/sun.c ## platform sources
+nodist_part_sun_module_SOURCES = ## platform nodist sources
+part_sun_module_LDADD =
+part_sun_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_sun_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_sun_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_sun_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_sun_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_plan_module_SOURCES = partmap/plan.c ## platform sources
+nodist_part_plan_module_SOURCES = ## platform nodist sources
+part_plan_module_LDADD =
+part_plan_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_plan_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_plan_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_plan_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_plan_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_dvh_module_SOURCES = partmap/dvh.c ## platform sources
+nodist_part_dvh_module_SOURCES = ## platform nodist sources
+part_dvh_module_LDADD =
+part_dvh_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_dvh_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_dvh_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_dvh_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_dvh_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_bsd_module_SOURCES = partmap/bsdlabel.c ## platform sources
+nodist_part_bsd_module_SOURCES = ## platform nodist sources
+part_bsd_module_LDADD =
+part_bsd_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_bsd_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_bsd_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_bsd_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_bsd_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_sunpc_module_SOURCES = partmap/sunpc.c ## platform sources
+nodist_part_sunpc_module_SOURCES = ## platform nodist sources
+part_sunpc_module_LDADD =
+part_sunpc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_sunpc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_sunpc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_sunpc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_sunpc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+part_dfly_module_SOURCES = partmap/dfly.c ## platform sources
+nodist_part_dfly_module_SOURCES = ## platform nodist sources
+part_dfly_module_LDADD =
+part_dfly_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+part_dfly_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+part_dfly_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+part_dfly_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+part_dfly_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+msdospart_module_SOURCES = parttool/msdospart.c ## platform sources
+nodist_msdospart_module_SOURCES = ## platform nodist sources
+msdospart_module_LDADD =
+msdospart_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+msdospart_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+msdospart_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+msdospart_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+msdospart_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+@COND_i386_efi_TRUE@at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+@COND_i386_ieee1275_TRUE@at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+@COND_i386_multiboot_TRUE@at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+@COND_i386_pc_TRUE@at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+@COND_i386_qemu_TRUE@at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+@COND_x86_64_efi_TRUE@at_keyboard_module_SOURCES = term/at_keyboard.c term/ps2.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_at_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@at_keyboard_module_LDADD =
+@COND_i386_efi_TRUE@at_keyboard_module_LDADD =
+@COND_i386_ieee1275_TRUE@at_keyboard_module_LDADD =
+@COND_i386_multiboot_TRUE@at_keyboard_module_LDADD =
+@COND_i386_pc_TRUE@at_keyboard_module_LDADD =
+@COND_i386_qemu_TRUE@at_keyboard_module_LDADD =
+@COND_x86_64_efi_TRUE@at_keyboard_module_LDADD =
+@COND_i386_coreboot_TRUE@at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@at_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@at_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@at_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@at_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@at_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_arm_efi_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_arm_uboot_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_emu_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_i386_efi_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_i386_ieee1275_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_i386_multiboot_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_i386_pc_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_i386_qemu_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_i386_xen_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_i386_xen_pvh_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_ia64_efi_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_mips_arc_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_mips_qemu_mips_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_riscv32_efi_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_riscv64_efi_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_x86_64_efi_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_x86_64_xen_TRUE@gfxterm_module_SOURCES = term/gfxterm.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_gfxterm_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@gfxterm_module_LDADD =
+@COND_arm_efi_TRUE@gfxterm_module_LDADD =
+@COND_arm_uboot_TRUE@gfxterm_module_LDADD =
+@COND_emu_TRUE@gfxterm_module_LDADD =
+@COND_i386_efi_TRUE@gfxterm_module_LDADD =
+@COND_i386_ieee1275_TRUE@gfxterm_module_LDADD =
+@COND_i386_multiboot_TRUE@gfxterm_module_LDADD =
+@COND_i386_pc_TRUE@gfxterm_module_LDADD =
+@COND_i386_qemu_TRUE@gfxterm_module_LDADD =
+@COND_i386_xen_TRUE@gfxterm_module_LDADD =
+@COND_i386_xen_pvh_TRUE@gfxterm_module_LDADD =
+@COND_ia64_efi_TRUE@gfxterm_module_LDADD =
+@COND_mips_arc_TRUE@gfxterm_module_LDADD =
+@COND_mips_qemu_mips_TRUE@gfxterm_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@gfxterm_module_LDADD =
+@COND_riscv32_efi_TRUE@gfxterm_module_LDADD =
+@COND_riscv64_efi_TRUE@gfxterm_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@gfxterm_module_LDADD =
+@COND_x86_64_efi_TRUE@gfxterm_module_LDADD =
+@COND_x86_64_xen_TRUE@gfxterm_module_LDADD =
+@COND_arm64_efi_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@gfxterm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@gfxterm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@gfxterm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@gfxterm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@gfxterm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gfxterm_background_module_SOURCES = term/gfxterm_background.c ## platform sources
+nodist_gfxterm_background_module_SOURCES = ## platform nodist sources
+gfxterm_background_module_LDADD =
+gfxterm_background_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_background_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_background_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_background_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_background_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@serial_module_SOURCES = term/efi/serial.c term/serial.c ## platform sources
+@COND_arm_coreboot_TRUE@serial_module_SOURCES = term/serial.c ## platform sources
+@COND_arm_efi_TRUE@serial_module_SOURCES = term/efi/serial.c term/serial.c ## platform sources
+@COND_i386_coreboot_TRUE@serial_module_SOURCES = term/ns8250.c term/serial.c ## platform sources
+@COND_i386_efi_TRUE@serial_module_SOURCES = term/ns8250.c term/efi/serial.c term/serial.c ## platform sources
+@COND_i386_ieee1275_TRUE@serial_module_SOURCES = term/ieee1275/serial.c term/ns8250.c term/serial.c ## platform sources
+@COND_i386_multiboot_TRUE@serial_module_SOURCES = term/ns8250.c term/serial.c ## platform sources
+@COND_i386_pc_TRUE@serial_module_SOURCES = term/ns8250.c term/serial.c ## platform sources
+@COND_i386_qemu_TRUE@serial_module_SOURCES = term/ns8250.c term/serial.c ## platform sources
+@COND_ia64_efi_TRUE@serial_module_SOURCES = term/efi/serial.c term/serial.c ## platform sources
+@COND_mips_arc_TRUE@serial_module_SOURCES = term/arc/serial.c term/serial.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@serial_module_SOURCES = term/ieee1275/serial.c term/serial.c ## platform sources
+@COND_riscv32_efi_TRUE@serial_module_SOURCES = term/efi/serial.c term/serial.c ## platform sources
+@COND_riscv64_efi_TRUE@serial_module_SOURCES = term/efi/serial.c term/serial.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@serial_module_SOURCES = term/ieee1275/serial.c term/serial.c ## platform sources
+@COND_x86_64_efi_TRUE@serial_module_SOURCES = term/ns8250.c term/efi/serial.c term/serial.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_serial_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@serial_module_LDADD =
+@COND_arm_coreboot_TRUE@serial_module_LDADD =
+@COND_arm_efi_TRUE@serial_module_LDADD =
+@COND_i386_coreboot_TRUE@serial_module_LDADD =
+@COND_i386_efi_TRUE@serial_module_LDADD =
+@COND_i386_ieee1275_TRUE@serial_module_LDADD =
+@COND_i386_multiboot_TRUE@serial_module_LDADD =
+@COND_i386_pc_TRUE@serial_module_LDADD =
+@COND_i386_qemu_TRUE@serial_module_LDADD =
+@COND_ia64_efi_TRUE@serial_module_LDADD =
+@COND_mips_arc_TRUE@serial_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@serial_module_LDADD =
+@COND_riscv32_efi_TRUE@serial_module_LDADD =
+@COND_riscv64_efi_TRUE@serial_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@serial_module_LDADD =
+@COND_x86_64_efi_TRUE@serial_module_LDADD =
+@COND_arm64_efi_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@serial_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@serial_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@serial_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@serial_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@serial_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@sendkey_module_SOURCES = commands/i386/pc/sendkey.c ## platform sources
+@COND_i386_pc_TRUE@nodist_sendkey_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@sendkey_module_LDADD =
+@COND_i386_pc_TRUE@sendkey_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@sendkey_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@sendkey_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@sendkey_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@sendkey_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_arm_coreboot_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_arm_efi_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_i386_coreboot_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_i386_efi_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_i386_multiboot_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_i386_pc_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_i386_qemu_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_ia64_efi_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_riscv32_efi_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_riscv64_efi_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_x86_64_efi_TRUE@terminfo_module_SOURCES = term/terminfo.c term/tparm.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_terminfo_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@terminfo_module_LDADD =
+@COND_arm_coreboot_TRUE@terminfo_module_LDADD =
+@COND_arm_efi_TRUE@terminfo_module_LDADD =
+@COND_i386_coreboot_TRUE@terminfo_module_LDADD =
+@COND_i386_efi_TRUE@terminfo_module_LDADD =
+@COND_i386_multiboot_TRUE@terminfo_module_LDADD =
+@COND_i386_pc_TRUE@terminfo_module_LDADD =
+@COND_i386_qemu_TRUE@terminfo_module_LDADD =
+@COND_ia64_efi_TRUE@terminfo_module_LDADD =
+@COND_riscv32_efi_TRUE@terminfo_module_LDADD =
+@COND_riscv64_efi_TRUE@terminfo_module_LDADD =
+@COND_x86_64_efi_TRUE@terminfo_module_LDADD =
+@COND_arm64_efi_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@terminfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@terminfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@terminfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@terminfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@terminfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+@COND_i386_coreboot_TRUE@usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+@COND_i386_efi_TRUE@usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+@COND_i386_ieee1275_TRUE@usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+@COND_i386_multiboot_TRUE@usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+@COND_i386_pc_TRUE@usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+@COND_i386_qemu_TRUE@usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+@COND_mips_loongson_TRUE@usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+@COND_x86_64_efi_TRUE@usb_keyboard_module_SOURCES = term/usb_keyboard.c ## platform sources
+@COND_arm_coreboot_TRUE@nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_usb_keyboard_module_SOURCES = ## platform nodist sources
+@COND_arm_coreboot_TRUE@usb_keyboard_module_LDADD =
+@COND_i386_coreboot_TRUE@usb_keyboard_module_LDADD =
+@COND_i386_efi_TRUE@usb_keyboard_module_LDADD =
+@COND_i386_ieee1275_TRUE@usb_keyboard_module_LDADD =
+@COND_i386_multiboot_TRUE@usb_keyboard_module_LDADD =
+@COND_i386_pc_TRUE@usb_keyboard_module_LDADD =
+@COND_i386_qemu_TRUE@usb_keyboard_module_LDADD =
+@COND_mips_loongson_TRUE@usb_keyboard_module_LDADD =
+@COND_x86_64_efi_TRUE@usb_keyboard_module_LDADD =
+@COND_arm_coreboot_TRUE@usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usb_keyboard_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usb_keyboard_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usb_keyboard_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@usb_keyboard_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_coreboot_TRUE@usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@usb_keyboard_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@vga_module_SOURCES = video/i386/pc/vga.c ## platform sources
+@COND_i386_pc_TRUE@nodist_vga_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@vga_module_LDADD =
+@COND_i386_pc_TRUE@vga_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@vga_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@vga_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@vga_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@vga_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@vga_text_module_SOURCES = term/i386/pc/vga_text.c ## platform sources
+@COND_i386_pc_TRUE@nodist_vga_text_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@vga_text_module_LDADD =
+@COND_i386_pc_TRUE@vga_text_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@vga_text_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@vga_text_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@vga_text_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@vga_text_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@mda_text_module_SOURCES = term/i386/pc/mda_text.c ## platform sources
+@COND_i386_multiboot_TRUE@mda_text_module_SOURCES = term/i386/pc/mda_text.c ## platform sources
+@COND_i386_pc_TRUE@mda_text_module_SOURCES = term/i386/pc/mda_text.c ## platform sources
+@COND_i386_qemu_TRUE@mda_text_module_SOURCES = term/i386/pc/mda_text.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_mda_text_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_mda_text_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_mda_text_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_mda_text_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@mda_text_module_LDADD =
+@COND_i386_multiboot_TRUE@mda_text_module_LDADD =
+@COND_i386_pc_TRUE@mda_text_module_LDADD =
+@COND_i386_qemu_TRUE@mda_text_module_LDADD =
+@COND_i386_coreboot_TRUE@mda_text_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@mda_text_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@mda_text_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@mda_text_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@mda_text_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@mda_text_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@mda_text_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@mda_text_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@mda_text_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@mda_text_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@mda_text_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@mda_text_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@mda_text_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@mda_text_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@mda_text_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@mda_text_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@mda_text_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@mda_text_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@mda_text_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@mda_text_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+@COND_i386_efi_TRUE@video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+@COND_i386_ieee1275_TRUE@video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+@COND_i386_multiboot_TRUE@video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+@COND_i386_pc_TRUE@video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+@COND_i386_qemu_TRUE@video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+@COND_x86_64_efi_TRUE@video_cirrus_module_SOURCES = video/cirrus.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_video_cirrus_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@video_cirrus_module_LDADD =
+@COND_i386_efi_TRUE@video_cirrus_module_LDADD =
+@COND_i386_ieee1275_TRUE@video_cirrus_module_LDADD =
+@COND_i386_multiboot_TRUE@video_cirrus_module_LDADD =
+@COND_i386_pc_TRUE@video_cirrus_module_LDADD =
+@COND_i386_qemu_TRUE@video_cirrus_module_LDADD =
+@COND_x86_64_efi_TRUE@video_cirrus_module_LDADD =
+@COND_i386_coreboot_TRUE@video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_cirrus_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_cirrus_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_cirrus_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_cirrus_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@video_cirrus_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@video_bochs_module_SOURCES = video/bochs.c ## platform sources
+@COND_i386_efi_TRUE@video_bochs_module_SOURCES = video/bochs.c ## platform sources
+@COND_i386_ieee1275_TRUE@video_bochs_module_SOURCES = video/bochs.c ## platform sources
+@COND_i386_multiboot_TRUE@video_bochs_module_SOURCES = video/bochs.c ## platform sources
+@COND_i386_pc_TRUE@video_bochs_module_SOURCES = video/bochs.c ## platform sources
+@COND_i386_qemu_TRUE@video_bochs_module_SOURCES = video/bochs.c ## platform sources
+@COND_x86_64_efi_TRUE@video_bochs_module_SOURCES = video/bochs.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_video_bochs_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_video_bochs_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_video_bochs_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_video_bochs_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_video_bochs_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_video_bochs_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_video_bochs_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@video_bochs_module_LDADD =
+@COND_i386_efi_TRUE@video_bochs_module_LDADD =
+@COND_i386_ieee1275_TRUE@video_bochs_module_LDADD =
+@COND_i386_multiboot_TRUE@video_bochs_module_LDADD =
+@COND_i386_pc_TRUE@video_bochs_module_LDADD =
+@COND_i386_qemu_TRUE@video_bochs_module_LDADD =
+@COND_x86_64_efi_TRUE@video_bochs_module_LDADD =
+@COND_i386_coreboot_TRUE@video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_bochs_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_bochs_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_bochs_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_bochs_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@video_bochs_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+functional_test_module_SOURCES = tests/lib/functional_test.c tests/lib/test.c tests/checksums.h tests/video_checksum.c tests/fake_input.c video/capture.c ## platform sources
+nodist_functional_test_module_SOURCES = ## platform nodist sources
+functional_test_module_LDADD =
+functional_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+functional_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+functional_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+functional_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+functional_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+exfctest_module_SOURCES = tests/example_functional_test.c ## platform sources
+nodist_exfctest_module_SOURCES = ## platform nodist sources
+exfctest_module_LDADD =
+exfctest_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+exfctest_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+exfctest_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+exfctest_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+exfctest_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+strtoull_test_module_SOURCES = tests/strtoull_test.c ## platform sources
+nodist_strtoull_test_module_SOURCES = ## platform nodist sources
+strtoull_test_module_LDADD =
+strtoull_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+strtoull_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+strtoull_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+strtoull_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+strtoull_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+setjmp_test_module_SOURCES = tests/setjmp_test.c ## platform sources
+nodist_setjmp_test_module_SOURCES = ## platform nodist sources
+setjmp_test_module_LDADD =
+setjmp_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+setjmp_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+setjmp_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+setjmp_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+setjmp_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+signature_test_module_SOURCES = tests/signature_test.c tests/signatures.h ## platform sources
+nodist_signature_test_module_SOURCES = ## platform nodist sources
+signature_test_module_LDADD =
+signature_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+signature_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+signature_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+signature_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+signature_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+sleep_test_module_SOURCES = tests/sleep_test.c ## platform sources
+nodist_sleep_test_module_SOURCES = ## platform nodist sources
+sleep_test_module_LDADD =
+sleep_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+sleep_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+sleep_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+sleep_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+sleep_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+xnu_uuid_test_module_SOURCES = tests/xnu_uuid_test.c ## platform sources
+nodist_xnu_uuid_test_module_SOURCES = ## platform nodist sources
+xnu_uuid_test_module_LDADD =
+xnu_uuid_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+xnu_uuid_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xnu_uuid_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+xnu_uuid_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xnu_uuid_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+pbkdf2_test_module_SOURCES = tests/pbkdf2_test.c ## platform sources
+nodist_pbkdf2_test_module_SOURCES = ## platform nodist sources
+pbkdf2_test_module_LDADD =
+pbkdf2_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+pbkdf2_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+pbkdf2_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+pbkdf2_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+pbkdf2_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+@COND_i386_efi_TRUE@legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+@COND_i386_pc_TRUE@legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+@COND_i386_xen_TRUE@legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+@COND_i386_xen_pvh_TRUE@legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+@COND_x86_64_efi_TRUE@legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+@COND_x86_64_xen_TRUE@legacy_password_test_module_SOURCES = tests/legacy_password_test.c ## platform sources
+@COND_emu_TRUE@nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_legacy_password_test_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@legacy_password_test_module_LDADD =
+@COND_i386_efi_TRUE@legacy_password_test_module_LDADD =
+@COND_i386_pc_TRUE@legacy_password_test_module_LDADD =
+@COND_i386_xen_TRUE@legacy_password_test_module_LDADD =
+@COND_i386_xen_pvh_TRUE@legacy_password_test_module_LDADD =
+@COND_x86_64_efi_TRUE@legacy_password_test_module_LDADD =
+@COND_x86_64_xen_TRUE@legacy_password_test_module_LDADD =
+@COND_emu_TRUE@legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@legacy_password_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@legacy_password_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@legacy_password_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@legacy_password_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@legacy_password_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_emu_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_i386_coreboot_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_i386_efi_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_i386_ieee1275_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_i386_multiboot_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_i386_pc_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_i386_qemu_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_i386_xen_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_i386_xen_pvh_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_mips_arc_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_mips_loongson_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_mips_qemu_mips_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_riscv64_efi_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_x86_64_efi_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_x86_64_xen_TRUE@div_module_SOURCES = lib/division.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_div_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@div_module_LDADD =
+@COND_emu_TRUE@div_module_LDADD =
+@COND_i386_coreboot_TRUE@div_module_LDADD =
+@COND_i386_efi_TRUE@div_module_LDADD =
+@COND_i386_ieee1275_TRUE@div_module_LDADD =
+@COND_i386_multiboot_TRUE@div_module_LDADD =
+@COND_i386_pc_TRUE@div_module_LDADD =
+@COND_i386_qemu_TRUE@div_module_LDADD =
+@COND_i386_xen_TRUE@div_module_LDADD =
+@COND_i386_xen_pvh_TRUE@div_module_LDADD =
+@COND_mips_arc_TRUE@div_module_LDADD =
+@COND_mips_loongson_TRUE@div_module_LDADD =
+@COND_mips_qemu_mips_TRUE@div_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@div_module_LDADD =
+@COND_riscv64_efi_TRUE@div_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@div_module_LDADD =
+@COND_x86_64_efi_TRUE@div_module_LDADD =
+@COND_x86_64_xen_TRUE@div_module_LDADD =
+@COND_arm64_efi_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_loongson_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@div_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_loongson_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@div_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_loongson_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@div_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_loongson_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@div_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@div_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+div_test_module_SOURCES = tests/div_test.c ## platform sources
+nodist_div_test_module_SOURCES = ## platform nodist sources
+div_test_module_LDADD =
+div_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+div_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+div_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+div_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+div_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+mul_test_module_SOURCES = tests/mul_test.c ## platform sources
+nodist_mul_test_module_SOURCES = ## platform nodist sources
+mul_test_module_LDADD =
+mul_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+mul_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mul_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+mul_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mul_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+shift_test_module_SOURCES = tests/shift_test.c ## platform sources
+nodist_shift_test_module_SOURCES = ## platform nodist sources
+shift_test_module_LDADD =
+shift_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+shift_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+shift_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+shift_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+shift_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+cmp_test_module_SOURCES = tests/cmp_test.c ## platform sources
+nodist_cmp_test_module_SOURCES = ## platform nodist sources
+cmp_test_module_LDADD =
+cmp_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmp_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmp_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmp_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmp_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+ctz_test_module_SOURCES = tests/ctz_test.c ## platform sources
+nodist_ctz_test_module_SOURCES = ## platform nodist sources
+ctz_test_module_LDADD =
+ctz_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+ctz_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+ctz_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+ctz_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+ctz_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+bswap_test_module_SOURCES = tests/bswap_test.c ## platform sources
+nodist_bswap_test_module_SOURCES = ## platform nodist sources
+bswap_test_module_LDADD =
+bswap_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bswap_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bswap_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bswap_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bswap_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+videotest_checksum_module_SOURCES = tests/videotest_checksum.c ## platform sources
+nodist_videotest_checksum_module_SOURCES = ## platform nodist sources
+videotest_checksum_module_LDADD =
+videotest_checksum_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+videotest_checksum_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+videotest_checksum_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+videotest_checksum_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+videotest_checksum_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gfxterm_menu_module_SOURCES = tests/gfxterm_menu.c ## platform sources
+nodist_gfxterm_menu_module_SOURCES = ## platform nodist sources
+gfxterm_menu_module_LDADD =
+gfxterm_menu_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+gfxterm_menu_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gfxterm_menu_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+gfxterm_menu_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gfxterm_menu_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+cmdline_cat_test_module_SOURCES = tests/cmdline_cat_test.c ## platform sources
+nodist_cmdline_cat_test_module_SOURCES = ## platform nodist sources
+cmdline_cat_test_module_LDADD =
+cmdline_cat_test_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+cmdline_cat_test_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+cmdline_cat_test_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+cmdline_cat_test_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+cmdline_cat_test_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+bitmap_module_SOURCES = video/bitmap.c ## platform sources
+nodist_bitmap_module_SOURCES = ## platform nodist sources
+bitmap_module_LDADD =
+bitmap_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bitmap_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bitmap_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bitmap_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bitmap_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+bitmap_scale_module_SOURCES = video/bitmap_scale.c ## platform sources
+nodist_bitmap_scale_module_SOURCES = ## platform nodist sources
+bitmap_scale_module_LDADD =
+bitmap_scale_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+bitmap_scale_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+bitmap_scale_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+bitmap_scale_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+bitmap_scale_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+@COND_arm_efi_TRUE@efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+@COND_i386_efi_TRUE@efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+@COND_ia64_efi_TRUE@efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+@COND_riscv32_efi_TRUE@efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+@COND_riscv64_efi_TRUE@efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+@COND_x86_64_efi_TRUE@efi_gop_module_SOURCES = video/efi_gop.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_efi_gop_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_efi_gop_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_efi_gop_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_efi_gop_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_efi_gop_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_efi_gop_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_efi_gop_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@efi_gop_module_LDADD =
+@COND_arm_efi_TRUE@efi_gop_module_LDADD =
+@COND_i386_efi_TRUE@efi_gop_module_LDADD =
+@COND_ia64_efi_TRUE@efi_gop_module_LDADD =
+@COND_riscv32_efi_TRUE@efi_gop_module_LDADD =
+@COND_riscv64_efi_TRUE@efi_gop_module_LDADD =
+@COND_x86_64_efi_TRUE@efi_gop_module_LDADD =
+@COND_arm64_efi_TRUE@efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efi_gop_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efi_gop_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efi_gop_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efi_gop_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@efi_gop_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@efi_uga_module_SOURCES = video/efi_uga.c ## platform sources
+@COND_x86_64_efi_TRUE@efi_uga_module_SOURCES = video/efi_uga.c ## platform sources
+@COND_i386_efi_TRUE@nodist_efi_uga_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_efi_uga_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@efi_uga_module_LDADD =
+@COND_x86_64_efi_TRUE@efi_uga_module_LDADD =
+@COND_i386_efi_TRUE@efi_uga_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efi_uga_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@efi_uga_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efi_uga_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@efi_uga_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efi_uga_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@efi_uga_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efi_uga_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@efi_uga_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@efi_uga_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+jpeg_module_SOURCES = video/readers/jpeg.c ## platform sources
+nodist_jpeg_module_SOURCES = ## platform nodist sources
+jpeg_module_LDADD =
+jpeg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+jpeg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+jpeg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+jpeg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+jpeg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+png_module_SOURCES = video/readers/png.c ## platform sources
+nodist_png_module_SOURCES = ## platform nodist sources
+png_module_LDADD =
+png_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+png_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+png_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+png_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+png_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+tga_module_SOURCES = video/readers/tga.c ## platform sources
+nodist_tga_module_SOURCES = ## platform nodist sources
+tga_module_LDADD =
+tga_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tga_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tga_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tga_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tga_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@vbe_module_SOURCES = video/i386/pc/vbe.c ## platform sources
+@COND_i386_pc_TRUE@nodist_vbe_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@vbe_module_LDADD =
+@COND_i386_pc_TRUE@vbe_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@vbe_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@vbe_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@vbe_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@vbe_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_arm_efi_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_arm_uboot_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_emu_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_i386_efi_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_i386_ieee1275_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_i386_multiboot_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_i386_pc_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_i386_qemu_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_i386_xen_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_i386_xen_pvh_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_ia64_efi_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_mips_arc_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_mips_qemu_mips_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_riscv32_efi_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_riscv64_efi_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_x86_64_efi_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_x86_64_xen_TRUE@video_fb_module_SOURCES = video/fb/video_fb.c video/fb/fbblit.c video/fb/fbfill.c video/fb/fbutil.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_video_fb_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@video_fb_module_LDADD =
+@COND_arm_efi_TRUE@video_fb_module_LDADD =
+@COND_arm_uboot_TRUE@video_fb_module_LDADD =
+@COND_emu_TRUE@video_fb_module_LDADD =
+@COND_i386_efi_TRUE@video_fb_module_LDADD =
+@COND_i386_ieee1275_TRUE@video_fb_module_LDADD =
+@COND_i386_multiboot_TRUE@video_fb_module_LDADD =
+@COND_i386_pc_TRUE@video_fb_module_LDADD =
+@COND_i386_qemu_TRUE@video_fb_module_LDADD =
+@COND_i386_xen_TRUE@video_fb_module_LDADD =
+@COND_i386_xen_pvh_TRUE@video_fb_module_LDADD =
+@COND_ia64_efi_TRUE@video_fb_module_LDADD =
+@COND_mips_arc_TRUE@video_fb_module_LDADD =
+@COND_mips_qemu_mips_TRUE@video_fb_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@video_fb_module_LDADD =
+@COND_riscv32_efi_TRUE@video_fb_module_LDADD =
+@COND_riscv64_efi_TRUE@video_fb_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@video_fb_module_LDADD =
+@COND_x86_64_efi_TRUE@video_fb_module_LDADD =
+@COND_x86_64_xen_TRUE@video_fb_module_LDADD =
+@COND_arm64_efi_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@video_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@video_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@video_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@video_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@video_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_arm_efi_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_arm_uboot_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_emu_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_i386_efi_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_i386_ieee1275_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_i386_multiboot_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_i386_pc_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_i386_qemu_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_i386_xen_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_i386_xen_pvh_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_ia64_efi_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_mips_arc_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_mips_qemu_mips_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_riscv32_efi_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_riscv64_efi_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_x86_64_efi_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_x86_64_xen_TRUE@video_module_SOURCES = video/video.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_video_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@video_module_LDADD =
+@COND_arm_efi_TRUE@video_module_LDADD =
+@COND_arm_uboot_TRUE@video_module_LDADD =
+@COND_emu_TRUE@video_module_LDADD =
+@COND_i386_efi_TRUE@video_module_LDADD =
+@COND_i386_ieee1275_TRUE@video_module_LDADD =
+@COND_i386_multiboot_TRUE@video_module_LDADD =
+@COND_i386_pc_TRUE@video_module_LDADD =
+@COND_i386_qemu_TRUE@video_module_LDADD =
+@COND_i386_xen_TRUE@video_module_LDADD =
+@COND_i386_xen_pvh_TRUE@video_module_LDADD =
+@COND_ia64_efi_TRUE@video_module_LDADD =
+@COND_mips_arc_TRUE@video_module_LDADD =
+@COND_mips_qemu_mips_TRUE@video_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@video_module_LDADD =
+@COND_riscv32_efi_TRUE@video_module_LDADD =
+@COND_riscv64_efi_TRUE@video_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@video_module_LDADD =
+@COND_x86_64_efi_TRUE@video_module_LDADD =
+@COND_x86_64_xen_TRUE@video_module_LDADD =
+@COND_arm64_efi_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_arc_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_arc_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_arc_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_arc_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_mips_qemu_mips_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+video_colors_module_SOURCES = video/colors.c ## platform sources
+nodist_video_colors_module_SOURCES = ## platform nodist sources
+video_colors_module_LDADD =
+video_colors_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+video_colors_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+video_colors_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+video_colors_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+video_colors_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@ieee1275_fb_module_SOURCES = video/ieee1275.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@nodist_ieee1275_fb_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@ieee1275_fb_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@ieee1275_fb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@ieee1275_fb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@ieee1275_fb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@ieee1275_fb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@ieee1275_fb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@sdl_module_SOURCES = video/emu/sdl.c ## platform sources
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@nodist_sdl_module_SOURCES = ## platform nodist sources
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@sdl_module_LDADD =
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@sdl_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@sdl_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@sdl_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@sdl_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@sdl_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+datehook_module_SOURCES = hook/datehook.c ## platform sources
+nodist_datehook_module_SOURCES = ## platform nodist sources
+datehook_module_LDADD =
+datehook_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+datehook_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+datehook_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+datehook_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+datehook_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+net_module_SOURCES = net/net.c net/dns.c net/bootp.c net/ip.c net/udp.c net/tcp.c net/icmp.c net/icmp6.c net/ethernet.c net/arp.c net/netbuff.c ## platform sources
+nodist_net_module_SOURCES = ## platform nodist sources
+net_module_LDADD =
+net_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+net_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+net_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+net_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+net_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+tftp_module_SOURCES = net/tftp.c ## platform sources
+nodist_tftp_module_SOURCES = ## platform nodist sources
+tftp_module_LDADD =
+tftp_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tftp_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tftp_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tftp_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tftp_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+http_module_SOURCES = net/http.c ## platform sources
+nodist_http_module_SOURCES = ## platform nodist sources
+http_module_LDADD =
+http_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+http_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+http_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+http_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+http_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@ofnet_module_SOURCES = net/drivers/ieee1275/ofnet.c ## platform sources
+@COND_powerpc_ieee1275_TRUE@ofnet_module_SOURCES = net/drivers/ieee1275/ofnet.c ## platform sources
+@COND_sparc64_ieee1275_TRUE@ofnet_module_SOURCES = net/drivers/ieee1275/ofnet.c ## platform sources
+@COND_i386_ieee1275_TRUE@nodist_ofnet_module_SOURCES = ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_ofnet_module_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_ofnet_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@ofnet_module_LDADD =
+@COND_powerpc_ieee1275_TRUE@ofnet_module_LDADD =
+@COND_sparc64_ieee1275_TRUE@ofnet_module_LDADD =
+@COND_i386_ieee1275_TRUE@ofnet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@ofnet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@ofnet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ofnet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@ofnet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@ofnet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ofnet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@ofnet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@ofnet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ofnet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_powerpc_ieee1275_TRUE@ofnet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_sparc64_ieee1275_TRUE@ofnet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@ofnet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@ofnet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@ofnet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@ubootnet_module_SOURCES = net/drivers/uboot/ubootnet.c ## platform sources
+@COND_arm_uboot_TRUE@nodist_ubootnet_module_SOURCES = ## platform nodist sources
+@COND_arm_uboot_TRUE@ubootnet_module_LDADD =
+@COND_arm_uboot_TRUE@ubootnet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_uboot_TRUE@ubootnet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_uboot_TRUE@ubootnet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_uboot_TRUE@ubootnet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_uboot_TRUE@ubootnet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+@COND_arm_efi_TRUE@efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+@COND_i386_efi_TRUE@efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+@COND_ia64_efi_TRUE@efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+@COND_riscv32_efi_TRUE@efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+@COND_riscv64_efi_TRUE@efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+@COND_x86_64_efi_TRUE@efinet_module_SOURCES = net/drivers/efi/efinet.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_efinet_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_efinet_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_efinet_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_efinet_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_efinet_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_efinet_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_efinet_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@efinet_module_LDADD =
+@COND_arm_efi_TRUE@efinet_module_LDADD =
+@COND_i386_efi_TRUE@efinet_module_LDADD =
+@COND_ia64_efi_TRUE@efinet_module_LDADD =
+@COND_riscv32_efi_TRUE@efinet_module_LDADD =
+@COND_riscv64_efi_TRUE@efinet_module_LDADD =
+@COND_x86_64_efi_TRUE@efinet_module_LDADD =
+@COND_arm64_efi_TRUE@efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efinet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efinet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efinet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@efinet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@efinet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@emunet_module_SOURCES = net/drivers/emu/emunet.c ## platform sources
+@COND_emu_TRUE@nodist_emunet_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@emunet_module_LDADD =
+@COND_emu_TRUE@emunet_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@emunet_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@emunet_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@emunet_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@emunet_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@legacycfg_module_SOURCES = lib/i386/pc/vesa_modes_table.c commands/legacycfg.c lib/legacy_parse.c ## platform sources
+@COND_i386_efi_TRUE@legacycfg_module_SOURCES = lib/i386/pc/vesa_modes_table.c commands/legacycfg.c lib/legacy_parse.c ## platform sources
+@COND_i386_pc_TRUE@legacycfg_module_SOURCES = commands/legacycfg.c lib/legacy_parse.c ## platform sources
+@COND_i386_xen_TRUE@legacycfg_module_SOURCES = lib/i386/pc/vesa_modes_table.c commands/legacycfg.c lib/legacy_parse.c ## platform sources
+@COND_i386_xen_pvh_TRUE@legacycfg_module_SOURCES = commands/legacycfg.c lib/legacy_parse.c ## platform sources
+@COND_x86_64_efi_TRUE@legacycfg_module_SOURCES = lib/i386/pc/vesa_modes_table.c commands/legacycfg.c lib/legacy_parse.c ## platform sources
+@COND_x86_64_xen_TRUE@legacycfg_module_SOURCES = lib/i386/pc/vesa_modes_table.c commands/legacycfg.c lib/legacy_parse.c ## platform sources
+@COND_emu_TRUE@nodist_legacycfg_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_legacycfg_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_legacycfg_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_legacycfg_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_legacycfg_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_legacycfg_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_legacycfg_module_SOURCES = ## platform nodist sources
+@COND_emu_TRUE@legacycfg_module_LDADD =
+@COND_i386_efi_TRUE@legacycfg_module_LDADD =
+@COND_i386_pc_TRUE@legacycfg_module_LDADD =
+@COND_i386_xen_TRUE@legacycfg_module_LDADD =
+@COND_i386_xen_pvh_TRUE@legacycfg_module_LDADD =
+@COND_x86_64_efi_TRUE@legacycfg_module_LDADD =
+@COND_x86_64_xen_TRUE@legacycfg_module_LDADD =
+@COND_emu_TRUE@legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@legacycfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_emu_TRUE@legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@legacycfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_emu_TRUE@legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@legacycfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_emu_TRUE@legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@legacycfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_emu_TRUE@legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@legacycfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+syslinuxcfg_module_SOURCES = lib/syslinux_parse.c commands/syslinuxcfg.c ## platform sources
+nodist_syslinuxcfg_module_SOURCES = ## platform nodist sources
+syslinuxcfg_module_LDADD =
+syslinuxcfg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+syslinuxcfg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+syslinuxcfg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+syslinuxcfg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+syslinuxcfg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+test_blockarg_module_SOURCES = tests/test_blockarg.c ## platform sources
+nodist_test_blockarg_module_SOURCES = ## platform nodist sources
+test_blockarg_module_LDADD =
+test_blockarg_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+test_blockarg_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+test_blockarg_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+test_blockarg_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+test_blockarg_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+xzio_module_SOURCES = io/xzio.c lib/xzembed/xz_dec_bcj.c lib/xzembed/xz_dec_lzma2.c lib/xzembed/xz_dec_stream.c ## platform sources
+nodist_xzio_module_SOURCES = ## platform nodist sources
+xzio_module_LDADD =
+xzio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) -Wno-unreachable-code
+xzio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+xzio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed
+xzio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+xzio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+lzopio_module_SOURCES = io/lzopio.c lib/minilzo/minilzo.c ## platform sources
+nodist_lzopio_module_SOURCES = ## platform nodist sources
+lzopio_module_LDADD =
+lzopio_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_POSIX) -Wno-undef -Wno-redundant-decls -Wno-error
+lzopio_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+lzopio_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H
+lzopio_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+lzopio_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+testload_module_SOURCES = commands/testload.c ## platform sources
+nodist_testload_module_SOURCES = ## platform nodist sources
+testload_module_LDADD =
+testload_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+testload_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+testload_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+testload_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+testload_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+@COND_i386_efi_TRUE@backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+@COND_i386_ieee1275_TRUE@backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+@COND_i386_multiboot_TRUE@backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+@COND_i386_pc_TRUE@backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+@COND_i386_qemu_TRUE@backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+@COND_i386_xen_TRUE@backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+@COND_i386_xen_pvh_TRUE@backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+@COND_x86_64_efi_TRUE@backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+@COND_x86_64_xen_TRUE@backtrace_module_SOURCES = lib/i386/backtrace.c lib/backtrace.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_backtrace_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_backtrace_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_backtrace_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_backtrace_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_backtrace_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_backtrace_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_backtrace_module_SOURCES = ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_backtrace_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_backtrace_module_SOURCES = ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_backtrace_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@backtrace_module_LDADD =
+@COND_i386_efi_TRUE@backtrace_module_LDADD =
+@COND_i386_ieee1275_TRUE@backtrace_module_LDADD =
+@COND_i386_multiboot_TRUE@backtrace_module_LDADD =
+@COND_i386_pc_TRUE@backtrace_module_LDADD =
+@COND_i386_qemu_TRUE@backtrace_module_LDADD =
+@COND_i386_xen_TRUE@backtrace_module_LDADD =
+@COND_i386_xen_pvh_TRUE@backtrace_module_LDADD =
+@COND_x86_64_efi_TRUE@backtrace_module_LDADD =
+@COND_x86_64_xen_TRUE@backtrace_module_LDADD =
+@COND_i386_coreboot_TRUE@backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_TRUE@backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@backtrace_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_TRUE@backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@backtrace_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_TRUE@backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@backtrace_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_TRUE@backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_xen_pvh_TRUE@backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_xen_TRUE@backtrace_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@backtrace_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@lsapm_module_SOURCES = commands/i386/pc/lsapm.c ## platform sources
+@COND_i386_pc_TRUE@nodist_lsapm_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@lsapm_module_LDADD =
+@COND_i386_pc_TRUE@lsapm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@lsapm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@lsapm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@lsapm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@lsapm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+@COND_i386_efi_TRUE@keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+@COND_i386_ieee1275_TRUE@keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+@COND_i386_multiboot_TRUE@keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+@COND_i386_pc_TRUE@keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+@COND_i386_qemu_TRUE@keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+@COND_x86_64_efi_TRUE@keylayouts_module_SOURCES = commands/keylayouts.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_keylayouts_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_keylayouts_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_keylayouts_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_keylayouts_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_keylayouts_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_keylayouts_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_keylayouts_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@keylayouts_module_LDADD =
+@COND_i386_efi_TRUE@keylayouts_module_LDADD =
+@COND_i386_ieee1275_TRUE@keylayouts_module_LDADD =
+@COND_i386_multiboot_TRUE@keylayouts_module_LDADD =
+@COND_i386_pc_TRUE@keylayouts_module_LDADD =
+@COND_i386_qemu_TRUE@keylayouts_module_LDADD =
+@COND_x86_64_efi_TRUE@keylayouts_module_LDADD =
+@COND_i386_coreboot_TRUE@keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@keylayouts_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@keylayouts_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@keylayouts_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@keylayouts_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@keylayouts_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+priority_queue_module_SOURCES = lib/priority_queue.c ## platform sources
+nodist_priority_queue_module_SOURCES = ## platform nodist sources
+priority_queue_module_LDADD =
+priority_queue_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+priority_queue_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+priority_queue_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+priority_queue_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+priority_queue_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+time_module_SOURCES = commands/time.c ## platform sources
+nodist_time_module_SOURCES = ## platform nodist sources
+time_module_LDADD =
+time_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+time_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+time_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+time_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+time_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ENABLE_CACHE_STATS_TRUE@cacheinfo_module_SOURCES = commands/cacheinfo.c ## platform sources
+@COND_ENABLE_CACHE_STATS_TRUE@nodist_cacheinfo_module_SOURCES = ## platform nodist sources
+@COND_ENABLE_CACHE_STATS_TRUE@cacheinfo_module_LDADD =
+@COND_ENABLE_CACHE_STATS_TRUE@cacheinfo_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ENABLE_CACHE_STATS_TRUE@cacheinfo_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ENABLE_CACHE_STATS_TRUE@cacheinfo_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ENABLE_CACHE_STATS_TRUE@cacheinfo_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ENABLE_CACHE_STATS_TRUE@cacheinfo_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@boottime_module_SOURCES = commands/boottime.c ## platform sources
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@nodist_boottime_module_SOURCES = ## platform nodist sources
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@boottime_module_LDADD =
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@boottime_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@boottime_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@boottime_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@boottime_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@boottime_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+adler32_module_SOURCES = lib/adler32.c ## platform sources
+nodist_adler32_module_SOURCES = ## platform nodist sources
+adler32_module_LDADD =
+adler32_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+adler32_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+adler32_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+adler32_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+adler32_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+crc64_module_SOURCES = lib/crc64.c ## platform sources
+nodist_crc64_module_SOURCES = ## platform nodist sources
+crc64_module_LDADD =
+crc64_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+crc64_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+crc64_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+crc64_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+crc64_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+mpi_module_SOURCES = lib/libgcrypt-grub/mpi/mpiutil.c lib/libgcrypt-grub/mpi/mpi-bit.c lib/libgcrypt-grub/mpi/mpi-add.c lib/libgcrypt-grub/mpi/mpi-mul.c lib/libgcrypt-grub/mpi/mpi-mod.c lib/libgcrypt-grub/mpi/mpi-gcd.c lib/libgcrypt-grub/mpi/mpi-div.c lib/libgcrypt-grub/mpi/mpi-cmp.c lib/libgcrypt-grub/mpi/mpi-inv.c lib/libgcrypt-grub/mpi/mpi-pow.c lib/libgcrypt-grub/mpi/mpi-mpow.c lib/libgcrypt-grub/mpi/mpih-lshift.c lib/libgcrypt-grub/mpi/mpih-mul.c lib/libgcrypt-grub/mpi/mpih-mul1.c lib/libgcrypt-grub/mpi/mpih-mul2.c lib/libgcrypt-grub/mpi/mpih-mul3.c lib/libgcrypt-grub/mpi/mpih-add1.c lib/libgcrypt-grub/mpi/mpih-sub1.c lib/libgcrypt-grub/mpi/mpih-div.c lib/libgcrypt-grub/mpi/mpicoder.c lib/libgcrypt-grub/mpi/mpih-rshift.c lib/libgcrypt-grub/mpi/mpi-inline.c lib/libgcrypt_wrap/mem.c ## platform sources
+nodist_mpi_module_SOURCES = ## platform nodist sources
+mpi_module_LDADD =
+mpi_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-redundant-decls -Wno-sign-compare
+mpi_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+mpi_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+mpi_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+mpi_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+all_video_module_SOURCES = lib/fake_module.c ## platform sources
+nodist_all_video_module_SOURCES = ## platform nodist sources
+all_video_module_LDADD =
+all_video_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+all_video_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+all_video_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+all_video_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+all_video_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+@COND_i386_efi_TRUE@gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+@COND_i386_ieee1275_TRUE@gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+@COND_i386_multiboot_TRUE@gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+@COND_i386_pc_TRUE@gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+@COND_i386_qemu_TRUE@gdb_module_SOURCES = gdb/i386/idt.c gdb/i386/machdep.S gdb/i386/signal.c gdb/cstub.c gdb/gdb.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_gdb_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_gdb_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_gdb_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_gdb_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_gdb_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_gdb_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@gdb_module_LDADD =
+@COND_i386_efi_TRUE@gdb_module_LDADD =
+@COND_i386_ieee1275_TRUE@gdb_module_LDADD =
+@COND_i386_multiboot_TRUE@gdb_module_LDADD =
+@COND_i386_pc_TRUE@gdb_module_LDADD =
+@COND_i386_qemu_TRUE@gdb_module_LDADD =
+@COND_i386_coreboot_TRUE@gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@gdb_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@gdb_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@gdb_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@gdb_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@gdb_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+testspeed_module_SOURCES = commands/testspeed.c ## platform sources
+nodist_testspeed_module_SOURCES = ## platform nodist sources
+testspeed_module_LDADD =
+testspeed_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+testspeed_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+testspeed_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+testspeed_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+testspeed_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+@COND_arm_efi_TRUE@tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+@COND_i386_efi_TRUE@tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+@COND_ia64_efi_TRUE@tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+@COND_riscv32_efi_TRUE@tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+@COND_riscv64_efi_TRUE@tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+@COND_x86_64_efi_TRUE@tpm_module_SOURCES = commands/efi/tpm.c commands/tpm.c ## platform sources
+@COND_arm64_efi_TRUE@nodist_tpm_module_SOURCES = ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_tpm_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_tpm_module_SOURCES = ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_tpm_module_SOURCES = ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_tpm_module_SOURCES = ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_tpm_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_tpm_module_SOURCES = ## platform nodist sources
+@COND_arm64_efi_TRUE@tpm_module_LDADD =
+@COND_arm_efi_TRUE@tpm_module_LDADD =
+@COND_i386_efi_TRUE@tpm_module_LDADD =
+@COND_ia64_efi_TRUE@tpm_module_LDADD =
+@COND_riscv32_efi_TRUE@tpm_module_LDADD =
+@COND_riscv64_efi_TRUE@tpm_module_LDADD =
+@COND_x86_64_efi_TRUE@tpm_module_LDADD =
+@COND_arm64_efi_TRUE@tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm_efi_TRUE@tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_ia64_efi_TRUE@tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@tpm_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_arm64_efi_TRUE@tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm_efi_TRUE@tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_ia64_efi_TRUE@tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@tpm_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_arm64_efi_TRUE@tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm_efi_TRUE@tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_ia64_efi_TRUE@tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@tpm_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_arm64_efi_TRUE@tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm_efi_TRUE@tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_ia64_efi_TRUE@tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv32_efi_TRUE@tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_riscv64_efi_TRUE@tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@tpm_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_arm64_efi_TRUE@tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@tpm_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+tr_module_SOURCES = commands/tr.c ## platform sources
+nodist_tr_module_SOURCES = ## platform nodist sources
+tr_module_LDADD =
+tr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+tr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+tr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+tr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+tr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+progress_module_SOURCES = lib/progress.c ## platform sources
+nodist_progress_module_SOURCES = ## platform nodist sources
+progress_module_LDADD =
+progress_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+progress_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+progress_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+progress_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+progress_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+file_module_SOURCES = commands/file.c commands/file32.c commands/file64.c loader/i386/xen_file.c loader/i386/xen_file32.c loader/i386/xen_file64.c ## platform sources
+nodist_file_module_SOURCES = ## platform nodist sources
+file_module_LDADD =
+file_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+file_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+file_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+file_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+file_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+@COND_i386_efi_TRUE@rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+@COND_i386_ieee1275_TRUE@rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+@COND_i386_multiboot_TRUE@rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+@COND_i386_pc_TRUE@rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+@COND_i386_qemu_TRUE@rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+@COND_x86_64_efi_TRUE@rdmsr_module_SOURCES = commands/i386/rdmsr.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_rdmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_rdmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_rdmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_rdmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_rdmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_rdmsr_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_rdmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@rdmsr_module_LDADD =
+@COND_i386_efi_TRUE@rdmsr_module_LDADD =
+@COND_i386_ieee1275_TRUE@rdmsr_module_LDADD =
+@COND_i386_multiboot_TRUE@rdmsr_module_LDADD =
+@COND_i386_pc_TRUE@rdmsr_module_LDADD =
+@COND_i386_qemu_TRUE@rdmsr_module_LDADD =
+@COND_x86_64_efi_TRUE@rdmsr_module_LDADD =
+@COND_i386_coreboot_TRUE@rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@rdmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@rdmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@rdmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@rdmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@rdmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+@COND_i386_efi_TRUE@wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+@COND_i386_ieee1275_TRUE@wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+@COND_i386_multiboot_TRUE@wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+@COND_i386_pc_TRUE@wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+@COND_i386_qemu_TRUE@wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+@COND_x86_64_efi_TRUE@wrmsr_module_SOURCES = commands/i386/wrmsr.c ## platform sources
+@COND_i386_coreboot_TRUE@nodist_wrmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_wrmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_wrmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_wrmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_wrmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_wrmsr_module_SOURCES = ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_wrmsr_module_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@wrmsr_module_LDADD =
+@COND_i386_efi_TRUE@wrmsr_module_LDADD =
+@COND_i386_ieee1275_TRUE@wrmsr_module_LDADD =
+@COND_i386_multiboot_TRUE@wrmsr_module_LDADD =
+@COND_i386_pc_TRUE@wrmsr_module_LDADD =
+@COND_i386_qemu_TRUE@wrmsr_module_LDADD =
+@COND_x86_64_efi_TRUE@wrmsr_module_LDADD =
+@COND_i386_coreboot_TRUE@wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_efi_TRUE@wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_pc_TRUE@wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_qemu_TRUE@wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@wrmsr_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_efi_TRUE@wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_pc_TRUE@wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_qemu_TRUE@wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@wrmsr_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_efi_TRUE@wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_pc_TRUE@wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_qemu_TRUE@wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@wrmsr_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_efi_TRUE@wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_ieee1275_TRUE@wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_multiboot_TRUE@wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_pc_TRUE@wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_qemu_TRUE@wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_x86_64_efi_TRUE@wrmsr_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+@COND_i386_coreboot_TRUE@wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@wrmsr_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_arcfour_module_SOURCES = lib/libgcrypt-grub/cipher/arcfour.c ## platform sources
+nodist_gcry_arcfour_module_SOURCES = ## platform nodist sources
+gcry_arcfour_module_LDADD =
+gcry_arcfour_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_arcfour_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_arcfour_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_arcfour_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_arcfour_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_blowfish_module_SOURCES = lib/libgcrypt-grub/cipher/blowfish.c ## platform sources
+nodist_gcry_blowfish_module_SOURCES = ## platform nodist sources
+gcry_blowfish_module_LDADD =
+gcry_blowfish_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_blowfish_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_blowfish_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_blowfish_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_blowfish_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_camellia_module_SOURCES = lib/libgcrypt-grub/cipher/camellia-glue.c lib/libgcrypt-grub/cipher/camellia.c ## platform sources
+nodist_gcry_camellia_module_SOURCES = ## platform nodist sources
+gcry_camellia_module_LDADD =
+gcry_camellia_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_camellia_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_camellia_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_camellia_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_camellia_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_cast5_module_SOURCES = lib/libgcrypt-grub/cipher/cast5.c ## platform sources
+nodist_gcry_cast5_module_SOURCES = ## platform nodist sources
+gcry_cast5_module_LDADD =
+gcry_cast5_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_cast5_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_cast5_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_cast5_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_cast5_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_crc_module_SOURCES = lib/libgcrypt-grub/cipher/crc.c ## platform sources
+nodist_gcry_crc_module_SOURCES = ## platform nodist sources
+gcry_crc_module_LDADD =
+gcry_crc_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_crc_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_crc_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_crc_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_crc_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_des_module_SOURCES = lib/libgcrypt-grub/cipher/des.c ## platform sources
+nodist_gcry_des_module_SOURCES = ## platform nodist sources
+gcry_des_module_LDADD =
+gcry_des_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_des_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_des_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_des_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_des_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_dsa_module_SOURCES = lib/libgcrypt-grub/cipher/dsa.c ## platform sources
+nodist_gcry_dsa_module_SOURCES = ## platform nodist sources
+gcry_dsa_module_LDADD =
+gcry_dsa_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_dsa_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_dsa_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_dsa_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_dsa_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_idea_module_SOURCES = lib/libgcrypt-grub/cipher/idea.c ## platform sources
+nodist_gcry_idea_module_SOURCES = ## platform nodist sources
+gcry_idea_module_LDADD =
+gcry_idea_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_idea_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_idea_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_idea_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_idea_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_md4_module_SOURCES = lib/libgcrypt-grub/cipher/md4.c ## platform sources
+nodist_gcry_md4_module_SOURCES = ## platform nodist sources
+gcry_md4_module_LDADD =
+gcry_md4_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_md4_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_md4_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_md4_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_md4_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_md5_module_SOURCES = lib/libgcrypt-grub/cipher/md5.c ## platform sources
+nodist_gcry_md5_module_SOURCES = ## platform nodist sources
+gcry_md5_module_LDADD =
+gcry_md5_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_md5_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_md5_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_md5_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_md5_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_rfc2268_module_SOURCES = lib/libgcrypt-grub/cipher/rfc2268.c ## platform sources
+nodist_gcry_rfc2268_module_SOURCES = ## platform nodist sources
+gcry_rfc2268_module_LDADD =
+gcry_rfc2268_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_rfc2268_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_rfc2268_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_rfc2268_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_rfc2268_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_rijndael_module_SOURCES = lib/libgcrypt-grub/cipher/rijndael.c ## platform sources
+nodist_gcry_rijndael_module_SOURCES = ## platform nodist sources
+gcry_rijndael_module_LDADD =
+gcry_rijndael_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_rijndael_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_rijndael_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_rijndael_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_rijndael_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_rmd160_module_SOURCES = lib/libgcrypt-grub/cipher/rmd160.c ## platform sources
+nodist_gcry_rmd160_module_SOURCES = ## platform nodist sources
+gcry_rmd160_module_LDADD =
+gcry_rmd160_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_rmd160_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_rmd160_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_rmd160_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_rmd160_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_rsa_module_SOURCES = lib/libgcrypt-grub/cipher/rsa.c ## platform sources
+nodist_gcry_rsa_module_SOURCES = ## platform nodist sources
+gcry_rsa_module_LDADD =
+gcry_rsa_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_rsa_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_rsa_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_rsa_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_rsa_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_seed_module_SOURCES = lib/libgcrypt-grub/cipher/seed.c ## platform sources
+nodist_gcry_seed_module_SOURCES = ## platform nodist sources
+gcry_seed_module_LDADD =
+gcry_seed_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_seed_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_seed_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_seed_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_seed_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_serpent_module_SOURCES = lib/libgcrypt-grub/cipher/serpent.c ## platform sources
+nodist_gcry_serpent_module_SOURCES = ## platform nodist sources
+gcry_serpent_module_LDADD =
+gcry_serpent_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_serpent_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_serpent_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_serpent_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_serpent_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_sha1_module_SOURCES = lib/libgcrypt-grub/cipher/sha1.c ## platform sources
+nodist_gcry_sha1_module_SOURCES = ## platform nodist sources
+gcry_sha1_module_LDADD =
+gcry_sha1_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_sha1_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_sha1_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_sha1_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_sha1_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_sha256_module_SOURCES = lib/libgcrypt-grub/cipher/sha256.c ## platform sources
+nodist_gcry_sha256_module_SOURCES = ## platform nodist sources
+gcry_sha256_module_LDADD =
+gcry_sha256_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_sha256_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_sha256_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_sha256_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_sha256_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_sha512_module_SOURCES = lib/libgcrypt-grub/cipher/sha512.c ## platform sources
+nodist_gcry_sha512_module_SOURCES = ## platform nodist sources
+gcry_sha512_module_LDADD =
+gcry_sha512_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_sha512_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_sha512_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_sha512_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_sha512_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_tiger_module_SOURCES = lib/libgcrypt-grub/cipher/tiger.c ## platform sources
+nodist_gcry_tiger_module_SOURCES = ## platform nodist sources
+gcry_tiger_module_LDADD =
+gcry_tiger_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY) -Wno-cast-align
+gcry_tiger_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_tiger_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_tiger_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_tiger_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_twofish_module_SOURCES = lib/libgcrypt-grub/cipher/twofish.c ## platform sources
+nodist_gcry_twofish_module_SOURCES = ## platform nodist sources
+gcry_twofish_module_LDADD =
+gcry_twofish_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_twofish_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_twofish_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_twofish_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_twofish_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+gcry_whirlpool_module_SOURCES = lib/libgcrypt-grub/cipher/whirlpool.c ## platform sources
+nodist_gcry_whirlpool_module_SOURCES = ## platform nodist sources
+gcry_whirlpool_module_LDADD =
+gcry_whirlpool_module_CFLAGS = $(AM_CFLAGS) $(CFLAGS_MODULE) $(CFLAGS_GCRY)
+gcry_whirlpool_module_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MODULE)
+gcry_whirlpool_module_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_MODULE) $(CPPFLAGS_GCRY)
+gcry_whirlpool_module_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_MODULE)
+gcry_whirlpool_module_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm64_efi_TRUE@kernel_exec_SOURCES = kern/arm64/efi/startup.S \
+@COND_arm64_efi_TRUE@ kern/arm64/efi/init.c kern/efi/fdt.c \
+@COND_arm64_efi_TRUE@ kern/arm64/cache.c \
+@COND_arm64_efi_TRUE@ kern/arm64/cache_flush.S kern/arm64/dl.c \
+@COND_arm64_efi_TRUE@ kern/arm64/dl_helper.c disk/efi/efidisk.c \
+@COND_arm64_efi_TRUE@ kern/efi/efi.c kern/efi/init.c \
+@COND_arm64_efi_TRUE@ kern/efi/mm.c term/efi/console.c \
+@COND_arm64_efi_TRUE@ kern/acpi.c kern/efi/acpi.c kern/efi/sb.c \
+@COND_arm64_efi_TRUE@ kern/lockdown.c kern/compiler-rt.c \
+@COND_arm64_efi_TRUE@ kern/mm.c kern/time.c \
+@COND_arm64_efi_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_arm64_efi_TRUE@ kern/command.c kern/corecmd.c \
+@COND_arm64_efi_TRUE@ kern/device.c kern/disk.c kern/dl.c \
+@COND_arm64_efi_TRUE@ kern/env.c kern/err.c kern/file.c \
+@COND_arm64_efi_TRUE@ kern/fs.c kern/list.c kern/main.c \
+@COND_arm64_efi_TRUE@ kern/misc.c kern/parser.c \
+@COND_arm64_efi_TRUE@ kern/partition.c kern/rescue_parser.c \
+@COND_arm64_efi_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_arm64_efi_TRUE@ kern/verifiers.c
+@COND_arm_coreboot_TRUE@kernel_exec_SOURCES = kern/arm/startup.S \
+@COND_arm_coreboot_TRUE@ kern/arm/coreboot/init.c \
+@COND_arm_coreboot_TRUE@ kern/arm/coreboot/timer.c \
+@COND_arm_coreboot_TRUE@ kern/arm/coreboot/coreboot.S lib/fdt.c \
+@COND_arm_coreboot_TRUE@ bus/fdt.c term/ps2.c term/arm/pl050.c \
+@COND_arm_coreboot_TRUE@ term/arm/cros.c term/arm/cros_ec.c \
+@COND_arm_coreboot_TRUE@ bus/spi/rk3288_spi.c \
+@COND_arm_coreboot_TRUE@ commands/keylayouts.c \
+@COND_arm_coreboot_TRUE@ kern/arm/coreboot/dma.c \
+@COND_arm_coreboot_TRUE@ kern/arm/coreboot/cbtable.c \
+@COND_arm_coreboot_TRUE@ video/coreboot/cbfb.c \
+@COND_arm_coreboot_TRUE@ kern/coreboot/mmap.c \
+@COND_arm_coreboot_TRUE@ kern/coreboot/cbtable.c term/gfxterm.c \
+@COND_arm_coreboot_TRUE@ font/font.c font/font_cmd.c io/bufio.c \
+@COND_arm_coreboot_TRUE@ video/fb/fbblit.c video/fb/fbfill.c \
+@COND_arm_coreboot_TRUE@ video/fb/fbutil.c video/fb/video_fb.c \
+@COND_arm_coreboot_TRUE@ video/video.c kern/arm/dl.c \
+@COND_arm_coreboot_TRUE@ kern/arm/dl_helper.c \
+@COND_arm_coreboot_TRUE@ kern/arm/cache_armv6.S \
+@COND_arm_coreboot_TRUE@ kern/arm/cache_armv7.S \
+@COND_arm_coreboot_TRUE@ kern/arm/cache.c \
+@COND_arm_coreboot_TRUE@ kern/arm/compiler-rt.S lib/division.c \
+@COND_arm_coreboot_TRUE@ kern/compiler-rt.c kern/mm.c \
+@COND_arm_coreboot_TRUE@ kern/time.c kern/generic/millisleep.c \
+@COND_arm_coreboot_TRUE@ kern/buffer.c kern/command.c \
+@COND_arm_coreboot_TRUE@ kern/corecmd.c kern/device.c \
+@COND_arm_coreboot_TRUE@ kern/disk.c kern/dl.c kern/env.c \
+@COND_arm_coreboot_TRUE@ kern/err.c kern/file.c kern/fs.c \
+@COND_arm_coreboot_TRUE@ kern/list.c kern/main.c kern/misc.c \
+@COND_arm_coreboot_TRUE@ kern/parser.c kern/partition.c \
+@COND_arm_coreboot_TRUE@ kern/rescue_parser.c \
+@COND_arm_coreboot_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_arm_coreboot_TRUE@ kern/verifiers.c
+@COND_arm_efi_TRUE@kernel_exec_SOURCES = kern/arm/efi/startup.S \
+@COND_arm_efi_TRUE@ kern/arm/efi/init.c kern/efi/fdt.c \
+@COND_arm_efi_TRUE@ kern/arm/dl.c kern/arm/dl_helper.c \
+@COND_arm_efi_TRUE@ kern/arm/cache_armv6.S \
+@COND_arm_efi_TRUE@ kern/arm/cache_armv7.S kern/arm/cache.c \
+@COND_arm_efi_TRUE@ kern/arm/compiler-rt.S lib/division.c \
+@COND_arm_efi_TRUE@ disk/efi/efidisk.c kern/efi/efi.c \
+@COND_arm_efi_TRUE@ kern/efi/init.c kern/efi/mm.c \
+@COND_arm_efi_TRUE@ term/efi/console.c kern/acpi.c \
+@COND_arm_efi_TRUE@ kern/efi/acpi.c kern/efi/sb.c \
+@COND_arm_efi_TRUE@ kern/lockdown.c kern/compiler-rt.c \
+@COND_arm_efi_TRUE@ kern/mm.c kern/time.c \
+@COND_arm_efi_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_arm_efi_TRUE@ kern/command.c kern/corecmd.c kern/device.c \
+@COND_arm_efi_TRUE@ kern/disk.c kern/dl.c kern/env.c kern/err.c \
+@COND_arm_efi_TRUE@ kern/file.c kern/fs.c kern/list.c \
+@COND_arm_efi_TRUE@ kern/main.c kern/misc.c kern/parser.c \
+@COND_arm_efi_TRUE@ kern/partition.c kern/rescue_parser.c \
+@COND_arm_efi_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_arm_efi_TRUE@ kern/verifiers.c
+@COND_arm_uboot_TRUE@kernel_exec_SOURCES = kern/arm/startup.S \
+@COND_arm_uboot_TRUE@ kern/arm/uboot/init.c \
+@COND_arm_uboot_TRUE@ kern/arm/uboot/uboot.S \
+@COND_arm_uboot_TRUE@ disk/uboot/ubootdisk.c kern/uboot/uboot.c \
+@COND_arm_uboot_TRUE@ kern/uboot/init.c kern/uboot/hw.c \
+@COND_arm_uboot_TRUE@ term/uboot/console.c kern/arm/dl.c \
+@COND_arm_uboot_TRUE@ kern/arm/dl_helper.c \
+@COND_arm_uboot_TRUE@ kern/arm/cache_armv6.S \
+@COND_arm_uboot_TRUE@ kern/arm/cache_armv7.S kern/arm/cache.c \
+@COND_arm_uboot_TRUE@ kern/arm/compiler-rt.S lib/division.c \
+@COND_arm_uboot_TRUE@ term/terminfo.c term/tparm.c \
+@COND_arm_uboot_TRUE@ commands/extcmd.c lib/arg.c \
+@COND_arm_uboot_TRUE@ kern/compiler-rt.c kern/mm.c kern/time.c \
+@COND_arm_uboot_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_arm_uboot_TRUE@ kern/command.c kern/corecmd.c \
+@COND_arm_uboot_TRUE@ kern/device.c kern/disk.c kern/dl.c \
+@COND_arm_uboot_TRUE@ kern/env.c kern/err.c kern/file.c \
+@COND_arm_uboot_TRUE@ kern/fs.c kern/list.c kern/main.c \
+@COND_arm_uboot_TRUE@ kern/misc.c kern/parser.c \
+@COND_arm_uboot_TRUE@ kern/partition.c kern/rescue_parser.c \
+@COND_arm_uboot_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_arm_uboot_TRUE@ kern/verifiers.c
+@COND_emu_TRUE@kernel_exec_SOURCES = disk/host.c kern/emu/cache_s.S \
+@COND_emu_TRUE@ kern/emu/hostdisk.c osdep/unix/hostdisk.c \
+@COND_emu_TRUE@ osdep/exec.c osdep/devmapper/hostdisk.c \
+@COND_emu_TRUE@ osdep/hostdisk.c kern/emu/hostfs.c \
+@COND_emu_TRUE@ kern/emu/main.c kern/emu/argp_common.c \
+@COND_emu_TRUE@ kern/emu/misc.c kern/emu/mm.c kern/emu/time.c \
+@COND_emu_TRUE@ kern/emu/cache.c osdep/emuconsole.c osdep/dl.c \
+@COND_emu_TRUE@ osdep/sleep.c osdep/init.c osdep/emunet.c \
+@COND_emu_TRUE@ osdep/cputime.c term/terminfo.c term/tparm.c \
+@COND_emu_TRUE@ commands/extcmd.c lib/arg.c kern/buffer.c \
+@COND_emu_TRUE@ kern/command.c kern/corecmd.c kern/device.c \
+@COND_emu_TRUE@ kern/disk.c kern/dl.c kern/env.c kern/err.c \
+@COND_emu_TRUE@ kern/file.c kern/fs.c kern/list.c kern/main.c \
+@COND_emu_TRUE@ kern/misc.c kern/parser.c kern/partition.c \
+@COND_emu_TRUE@ kern/rescue_parser.c kern/rescue_reader.c \
+@COND_emu_TRUE@ kern/term.c kern/verifiers.c
+@COND_i386_coreboot_TRUE@kernel_exec_SOURCES = \
+@COND_i386_coreboot_TRUE@ kern/i386/coreboot/startup.S \
+@COND_i386_coreboot_TRUE@ kern/i386/coreboot/init.c \
+@COND_i386_coreboot_TRUE@ kern/i386/pc/acpi.c kern/acpi.c \
+@COND_i386_coreboot_TRUE@ kern/i386/tsc_pmtimer.c \
+@COND_i386_coreboot_TRUE@ kern/i386/coreboot/cbtable.c \
+@COND_i386_coreboot_TRUE@ video/coreboot/cbfb.c \
+@COND_i386_coreboot_TRUE@ kern/coreboot/mmap.c \
+@COND_i386_coreboot_TRUE@ kern/coreboot/cbtable.c \
+@COND_i386_coreboot_TRUE@ term/gfxterm.c font/font.c \
+@COND_i386_coreboot_TRUE@ font/font_cmd.c io/bufio.c \
+@COND_i386_coreboot_TRUE@ video/fb/fbblit.c video/fb/fbfill.c \
+@COND_i386_coreboot_TRUE@ video/fb/fbutil.c video/fb/video_fb.c \
+@COND_i386_coreboot_TRUE@ video/video.c term/i386/pc/vga_text.c \
+@COND_i386_coreboot_TRUE@ kern/i386/dl.c kern/i386/tsc.c \
+@COND_i386_coreboot_TRUE@ kern/i386/tsc_pit.c \
+@COND_i386_coreboot_TRUE@ kern/compiler-rt.c kern/mm.c \
+@COND_i386_coreboot_TRUE@ kern/time.c kern/generic/millisleep.c \
+@COND_i386_coreboot_TRUE@ kern/buffer.c kern/command.c \
+@COND_i386_coreboot_TRUE@ kern/corecmd.c kern/device.c \
+@COND_i386_coreboot_TRUE@ kern/disk.c kern/dl.c kern/env.c \
+@COND_i386_coreboot_TRUE@ kern/err.c kern/file.c kern/fs.c \
+@COND_i386_coreboot_TRUE@ kern/list.c kern/main.c kern/misc.c \
+@COND_i386_coreboot_TRUE@ kern/parser.c kern/partition.c \
+@COND_i386_coreboot_TRUE@ kern/rescue_parser.c \
+@COND_i386_coreboot_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_i386_coreboot_TRUE@ kern/verifiers.c
+@COND_i386_efi_TRUE@kernel_exec_SOURCES = kern/i386/efi/startup.S \
+@COND_i386_efi_TRUE@ kern/i386/efi/tsc.c \
+@COND_i386_efi_TRUE@ kern/i386/tsc_pmtimer.c \
+@COND_i386_efi_TRUE@ kern/i386/efi/init.c bus/pci.c \
+@COND_i386_efi_TRUE@ kern/i386/dl.c kern/i386/tsc.c \
+@COND_i386_efi_TRUE@ kern/i386/tsc_pit.c disk/efi/efidisk.c \
+@COND_i386_efi_TRUE@ kern/efi/efi.c kern/efi/init.c \
+@COND_i386_efi_TRUE@ kern/efi/mm.c term/efi/console.c \
+@COND_i386_efi_TRUE@ kern/acpi.c kern/efi/acpi.c kern/efi/sb.c \
+@COND_i386_efi_TRUE@ kern/lockdown.c kern/compiler-rt.c \
+@COND_i386_efi_TRUE@ kern/mm.c kern/time.c \
+@COND_i386_efi_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_i386_efi_TRUE@ kern/command.c kern/corecmd.c \
+@COND_i386_efi_TRUE@ kern/device.c kern/disk.c kern/dl.c \
+@COND_i386_efi_TRUE@ kern/env.c kern/err.c kern/file.c \
+@COND_i386_efi_TRUE@ kern/fs.c kern/list.c kern/main.c \
+@COND_i386_efi_TRUE@ kern/misc.c kern/parser.c kern/partition.c \
+@COND_i386_efi_TRUE@ kern/rescue_parser.c kern/rescue_reader.c \
+@COND_i386_efi_TRUE@ kern/term.c kern/verifiers.c
+@COND_i386_ieee1275_TRUE@kernel_exec_SOURCES = \
+@COND_i386_ieee1275_TRUE@ kern/i386/ieee1275/startup.S \
+@COND_i386_ieee1275_TRUE@ disk/ieee1275/ofdisk.c \
+@COND_i386_ieee1275_TRUE@ kern/ieee1275/cmain.c \
+@COND_i386_ieee1275_TRUE@ kern/ieee1275/ieee1275.c \
+@COND_i386_ieee1275_TRUE@ kern/ieee1275/mmap.c \
+@COND_i386_ieee1275_TRUE@ kern/ieee1275/openfw.c \
+@COND_i386_ieee1275_TRUE@ term/ieee1275/console.c \
+@COND_i386_ieee1275_TRUE@ kern/ieee1275/init.c kern/i386/dl.c \
+@COND_i386_ieee1275_TRUE@ kern/i386/tsc.c kern/i386/tsc_pit.c \
+@COND_i386_ieee1275_TRUE@ term/terminfo.c term/tparm.c \
+@COND_i386_ieee1275_TRUE@ commands/extcmd.c lib/arg.c \
+@COND_i386_ieee1275_TRUE@ kern/compiler-rt.c kern/mm.c \
+@COND_i386_ieee1275_TRUE@ kern/time.c kern/generic/millisleep.c \
+@COND_i386_ieee1275_TRUE@ kern/buffer.c kern/command.c \
+@COND_i386_ieee1275_TRUE@ kern/corecmd.c kern/device.c \
+@COND_i386_ieee1275_TRUE@ kern/disk.c kern/dl.c kern/env.c \
+@COND_i386_ieee1275_TRUE@ kern/err.c kern/file.c kern/fs.c \
+@COND_i386_ieee1275_TRUE@ kern/list.c kern/main.c kern/misc.c \
+@COND_i386_ieee1275_TRUE@ kern/parser.c kern/partition.c \
+@COND_i386_ieee1275_TRUE@ kern/rescue_parser.c \
+@COND_i386_ieee1275_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_i386_ieee1275_TRUE@ kern/verifiers.c
+@COND_i386_multiboot_TRUE@kernel_exec_SOURCES = \
+@COND_i386_multiboot_TRUE@ kern/i386/coreboot/startup.S \
+@COND_i386_multiboot_TRUE@ kern/i386/coreboot/init.c \
+@COND_i386_multiboot_TRUE@ kern/i386/pc/acpi.c kern/acpi.c \
+@COND_i386_multiboot_TRUE@ kern/i386/multiboot_mmap.c \
+@COND_i386_multiboot_TRUE@ term/i386/pc/vga_text.c \
+@COND_i386_multiboot_TRUE@ kern/i386/dl.c kern/i386/tsc.c \
+@COND_i386_multiboot_TRUE@ kern/i386/tsc_pit.c \
+@COND_i386_multiboot_TRUE@ kern/compiler-rt.c kern/mm.c \
+@COND_i386_multiboot_TRUE@ kern/time.c \
+@COND_i386_multiboot_TRUE@ kern/generic/millisleep.c \
+@COND_i386_multiboot_TRUE@ kern/buffer.c kern/command.c \
+@COND_i386_multiboot_TRUE@ kern/corecmd.c kern/device.c \
+@COND_i386_multiboot_TRUE@ kern/disk.c kern/dl.c kern/env.c \
+@COND_i386_multiboot_TRUE@ kern/err.c kern/file.c kern/fs.c \
+@COND_i386_multiboot_TRUE@ kern/list.c kern/main.c kern/misc.c \
+@COND_i386_multiboot_TRUE@ kern/parser.c kern/partition.c \
+@COND_i386_multiboot_TRUE@ kern/rescue_parser.c \
+@COND_i386_multiboot_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_i386_multiboot_TRUE@ kern/verifiers.c
+@COND_i386_pc_TRUE@kernel_exec_SOURCES = kern/i386/pc/startup.S \
+@COND_i386_pc_TRUE@ kern/i386/pc/init.c kern/i386/pc/mmap.c \
+@COND_i386_pc_TRUE@ term/i386/pc/console.c kern/i386/dl.c \
+@COND_i386_pc_TRUE@ kern/i386/tsc.c kern/i386/tsc_pit.c \
+@COND_i386_pc_TRUE@ kern/compiler-rt.c kern/mm.c kern/time.c \
+@COND_i386_pc_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_i386_pc_TRUE@ kern/command.c kern/corecmd.c kern/device.c \
+@COND_i386_pc_TRUE@ kern/disk.c kern/dl.c kern/env.c kern/err.c \
+@COND_i386_pc_TRUE@ kern/file.c kern/fs.c kern/list.c \
+@COND_i386_pc_TRUE@ kern/main.c kern/misc.c kern/parser.c \
+@COND_i386_pc_TRUE@ kern/partition.c kern/rescue_parser.c \
+@COND_i386_pc_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_i386_pc_TRUE@ kern/verifiers.c
+@COND_i386_qemu_TRUE@kernel_exec_SOURCES = kern/i386/qemu/startup.S \
+@COND_i386_qemu_TRUE@ kern/i386/qemu/init.c bus/pci.c \
+@COND_i386_qemu_TRUE@ kern/vga_init.c kern/i386/qemu/mmap.c \
+@COND_i386_qemu_TRUE@ term/i386/pc/vga_text.c kern/i386/dl.c \
+@COND_i386_qemu_TRUE@ kern/i386/tsc.c kern/i386/tsc_pit.c \
+@COND_i386_qemu_TRUE@ kern/compiler-rt.c kern/mm.c kern/time.c \
+@COND_i386_qemu_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_i386_qemu_TRUE@ kern/command.c kern/corecmd.c \
+@COND_i386_qemu_TRUE@ kern/device.c kern/disk.c kern/dl.c \
+@COND_i386_qemu_TRUE@ kern/env.c kern/err.c kern/file.c \
+@COND_i386_qemu_TRUE@ kern/fs.c kern/list.c kern/main.c \
+@COND_i386_qemu_TRUE@ kern/misc.c kern/parser.c \
+@COND_i386_qemu_TRUE@ kern/partition.c kern/rescue_parser.c \
+@COND_i386_qemu_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_i386_qemu_TRUE@ kern/verifiers.c
+@COND_i386_xen_TRUE@kernel_exec_SOURCES = kern/i386/xen/startup.S \
+@COND_i386_xen_TRUE@ kern/i386/dl.c kern/i386/xen/hypercall.S \
+@COND_i386_xen_TRUE@ kern/i386/tsc.c kern/i386/xen/tsc.c \
+@COND_i386_xen_TRUE@ kern/xen/init.c term/xen/console.c \
+@COND_i386_xen_TRUE@ disk/xen/xendisk.c commands/boot.c \
+@COND_i386_xen_TRUE@ term/terminfo.c term/tparm.c \
+@COND_i386_xen_TRUE@ commands/extcmd.c lib/arg.c \
+@COND_i386_xen_TRUE@ kern/compiler-rt.c kern/mm.c kern/time.c \
+@COND_i386_xen_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_i386_xen_TRUE@ kern/command.c kern/corecmd.c \
+@COND_i386_xen_TRUE@ kern/device.c kern/disk.c kern/dl.c \
+@COND_i386_xen_TRUE@ kern/env.c kern/err.c kern/file.c \
+@COND_i386_xen_TRUE@ kern/fs.c kern/list.c kern/main.c \
+@COND_i386_xen_TRUE@ kern/misc.c kern/parser.c kern/partition.c \
+@COND_i386_xen_TRUE@ kern/rescue_parser.c kern/rescue_reader.c \
+@COND_i386_xen_TRUE@ kern/term.c kern/verifiers.c
+@COND_i386_xen_pvh_TRUE@kernel_exec_SOURCES = \
+@COND_i386_xen_pvh_TRUE@ kern/i386/xen/startup_pvh.S \
+@COND_i386_xen_pvh_TRUE@ kern/i386/dl.c commands/boot.c \
+@COND_i386_xen_pvh_TRUE@ disk/xen/xendisk.c kern/i386/tsc.c \
+@COND_i386_xen_pvh_TRUE@ kern/i386/xen/tsc.c \
+@COND_i386_xen_pvh_TRUE@ kern/i386/xen/pvh.c kern/xen/init.c \
+@COND_i386_xen_pvh_TRUE@ term/xen/console.c term/terminfo.c \
+@COND_i386_xen_pvh_TRUE@ term/tparm.c commands/extcmd.c \
+@COND_i386_xen_pvh_TRUE@ lib/arg.c kern/compiler-rt.c kern/mm.c \
+@COND_i386_xen_pvh_TRUE@ kern/time.c kern/generic/millisleep.c \
+@COND_i386_xen_pvh_TRUE@ kern/buffer.c kern/command.c \
+@COND_i386_xen_pvh_TRUE@ kern/corecmd.c kern/device.c \
+@COND_i386_xen_pvh_TRUE@ kern/disk.c kern/dl.c kern/env.c \
+@COND_i386_xen_pvh_TRUE@ kern/err.c kern/file.c kern/fs.c \
+@COND_i386_xen_pvh_TRUE@ kern/list.c kern/main.c kern/misc.c \
+@COND_i386_xen_pvh_TRUE@ kern/parser.c kern/partition.c \
+@COND_i386_xen_pvh_TRUE@ kern/rescue_parser.c \
+@COND_i386_xen_pvh_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_i386_xen_pvh_TRUE@ kern/verifiers.c
+@COND_ia64_efi_TRUE@kernel_exec_SOURCES = kern/ia64/efi/startup.S \
+@COND_ia64_efi_TRUE@ kern/ia64/efi/init.c kern/ia64/dl.c \
+@COND_ia64_efi_TRUE@ kern/ia64/dl_helper.c kern/ia64/cache.c \
+@COND_ia64_efi_TRUE@ lib/division.c disk/efi/efidisk.c \
+@COND_ia64_efi_TRUE@ kern/efi/efi.c kern/efi/init.c \
+@COND_ia64_efi_TRUE@ kern/efi/mm.c term/efi/console.c \
+@COND_ia64_efi_TRUE@ kern/acpi.c kern/efi/acpi.c kern/efi/sb.c \
+@COND_ia64_efi_TRUE@ kern/lockdown.c kern/compiler-rt.c \
+@COND_ia64_efi_TRUE@ kern/mm.c kern/time.c \
+@COND_ia64_efi_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_ia64_efi_TRUE@ kern/command.c kern/corecmd.c \
+@COND_ia64_efi_TRUE@ kern/device.c kern/disk.c kern/dl.c \
+@COND_ia64_efi_TRUE@ kern/env.c kern/err.c kern/file.c \
+@COND_ia64_efi_TRUE@ kern/fs.c kern/list.c kern/main.c \
+@COND_ia64_efi_TRUE@ kern/misc.c kern/parser.c kern/partition.c \
+@COND_ia64_efi_TRUE@ kern/rescue_parser.c kern/rescue_reader.c \
+@COND_ia64_efi_TRUE@ kern/term.c kern/verifiers.c
+@COND_mips_arc_TRUE@kernel_exec_SOURCES = kern/mips/startup.S \
+@COND_mips_arc_TRUE@ kern/mips/arc/init.c term/arc/console.c \
+@COND_mips_arc_TRUE@ disk/arc/arcdisk.c \
+@COND_mips_arc_TRUE@ kern/generic/rtc_get_time_ms.c \
+@COND_mips_arc_TRUE@ kern/mips/cache.S kern/mips/dl.c \
+@COND_mips_arc_TRUE@ kern/mips/init.c term/terminfo.c \
+@COND_mips_arc_TRUE@ term/tparm.c commands/extcmd.c lib/arg.c \
+@COND_mips_arc_TRUE@ kern/compiler-rt.c kern/mm.c kern/time.c \
+@COND_mips_arc_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_mips_arc_TRUE@ kern/command.c kern/corecmd.c \
+@COND_mips_arc_TRUE@ kern/device.c kern/disk.c kern/dl.c \
+@COND_mips_arc_TRUE@ kern/env.c kern/err.c kern/file.c \
+@COND_mips_arc_TRUE@ kern/fs.c kern/list.c kern/main.c \
+@COND_mips_arc_TRUE@ kern/misc.c kern/parser.c kern/partition.c \
+@COND_mips_arc_TRUE@ kern/rescue_parser.c kern/rescue_reader.c \
+@COND_mips_arc_TRUE@ kern/term.c kern/verifiers.c
+@COND_mips_loongson_TRUE@kernel_exec_SOURCES = kern/mips/startup.S \
+@COND_mips_loongson_TRUE@ term/ns8250.c bus/bonito.c \
+@COND_mips_loongson_TRUE@ bus/cs5536.c bus/pci.c \
+@COND_mips_loongson_TRUE@ kern/mips/loongson/init.c \
+@COND_mips_loongson_TRUE@ term/at_keyboard.c term/ps2.c \
+@COND_mips_loongson_TRUE@ commands/boot.c term/serial.c \
+@COND_mips_loongson_TRUE@ video/sm712.c video/sis315pro.c \
+@COND_mips_loongson_TRUE@ video/radeon_fuloong2e.c \
+@COND_mips_loongson_TRUE@ video/radeon_yeeloong3a.c \
+@COND_mips_loongson_TRUE@ commands/keylayouts.c term/gfxterm.c \
+@COND_mips_loongson_TRUE@ font/font.c font/font_cmd.c \
+@COND_mips_loongson_TRUE@ io/bufio.c video/fb/fbblit.c \
+@COND_mips_loongson_TRUE@ video/fb/fbfill.c video/fb/fbutil.c \
+@COND_mips_loongson_TRUE@ video/fb/video_fb.c video/video.c \
+@COND_mips_loongson_TRUE@ kern/generic/rtc_get_time_ms.c \
+@COND_mips_loongson_TRUE@ kern/mips/cache.S kern/mips/dl.c \
+@COND_mips_loongson_TRUE@ kern/mips/init.c term/terminfo.c \
+@COND_mips_loongson_TRUE@ term/tparm.c commands/extcmd.c \
+@COND_mips_loongson_TRUE@ lib/arg.c kern/compiler-rt.c \
+@COND_mips_loongson_TRUE@ kern/mm.c kern/time.c \
+@COND_mips_loongson_TRUE@ kern/generic/millisleep.c \
+@COND_mips_loongson_TRUE@ kern/buffer.c kern/command.c \
+@COND_mips_loongson_TRUE@ kern/corecmd.c kern/device.c \
+@COND_mips_loongson_TRUE@ kern/disk.c kern/dl.c kern/env.c \
+@COND_mips_loongson_TRUE@ kern/err.c kern/file.c kern/fs.c \
+@COND_mips_loongson_TRUE@ kern/list.c kern/main.c kern/misc.c \
+@COND_mips_loongson_TRUE@ kern/parser.c kern/partition.c \
+@COND_mips_loongson_TRUE@ kern/rescue_parser.c \
+@COND_mips_loongson_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_mips_loongson_TRUE@ kern/verifiers.c
+@COND_mips_qemu_mips_TRUE@kernel_exec_SOURCES = kern/mips/startup.S \
+@COND_mips_qemu_mips_TRUE@ kern/mips/qemu_mips/init.c \
+@COND_mips_qemu_mips_TRUE@ term/ns8250.c term/serial.c \
+@COND_mips_qemu_mips_TRUE@ term/at_keyboard.c term/ps2.c \
+@COND_mips_qemu_mips_TRUE@ commands/boot.c \
+@COND_mips_qemu_mips_TRUE@ commands/keylayouts.c \
+@COND_mips_qemu_mips_TRUE@ term/i386/pc/vga_text.c \
+@COND_mips_qemu_mips_TRUE@ kern/vga_init.c \
+@COND_mips_qemu_mips_TRUE@ kern/generic/rtc_get_time_ms.c \
+@COND_mips_qemu_mips_TRUE@ kern/mips/cache.S kern/mips/dl.c \
+@COND_mips_qemu_mips_TRUE@ kern/mips/init.c term/terminfo.c \
+@COND_mips_qemu_mips_TRUE@ term/tparm.c commands/extcmd.c \
+@COND_mips_qemu_mips_TRUE@ lib/arg.c kern/compiler-rt.c \
+@COND_mips_qemu_mips_TRUE@ kern/mm.c kern/time.c \
+@COND_mips_qemu_mips_TRUE@ kern/generic/millisleep.c \
+@COND_mips_qemu_mips_TRUE@ kern/buffer.c kern/command.c \
+@COND_mips_qemu_mips_TRUE@ kern/corecmd.c kern/device.c \
+@COND_mips_qemu_mips_TRUE@ kern/disk.c kern/dl.c kern/env.c \
+@COND_mips_qemu_mips_TRUE@ kern/err.c kern/file.c kern/fs.c \
+@COND_mips_qemu_mips_TRUE@ kern/list.c kern/main.c kern/misc.c \
+@COND_mips_qemu_mips_TRUE@ kern/parser.c kern/partition.c \
+@COND_mips_qemu_mips_TRUE@ kern/rescue_parser.c \
+@COND_mips_qemu_mips_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_mips_qemu_mips_TRUE@ kern/verifiers.c
+@COND_powerpc_ieee1275_TRUE@kernel_exec_SOURCES = \
+@COND_powerpc_ieee1275_TRUE@ kern/powerpc/ieee1275/startup.S \
+@COND_powerpc_ieee1275_TRUE@ kern/powerpc/cache.S \
+@COND_powerpc_ieee1275_TRUE@ kern/powerpc/dl.c \
+@COND_powerpc_ieee1275_TRUE@ kern/powerpc/compiler-rt.S \
+@COND_powerpc_ieee1275_TRUE@ disk/ieee1275/ofdisk.c \
+@COND_powerpc_ieee1275_TRUE@ kern/ieee1275/cmain.c \
+@COND_powerpc_ieee1275_TRUE@ kern/ieee1275/ieee1275.c \
+@COND_powerpc_ieee1275_TRUE@ kern/ieee1275/mmap.c \
+@COND_powerpc_ieee1275_TRUE@ kern/ieee1275/openfw.c \
+@COND_powerpc_ieee1275_TRUE@ term/ieee1275/console.c \
+@COND_powerpc_ieee1275_TRUE@ kern/ieee1275/init.c \
+@COND_powerpc_ieee1275_TRUE@ term/terminfo.c term/tparm.c \
+@COND_powerpc_ieee1275_TRUE@ commands/extcmd.c lib/arg.c \
+@COND_powerpc_ieee1275_TRUE@ kern/compiler-rt.c kern/mm.c \
+@COND_powerpc_ieee1275_TRUE@ kern/time.c \
+@COND_powerpc_ieee1275_TRUE@ kern/generic/millisleep.c \
+@COND_powerpc_ieee1275_TRUE@ kern/buffer.c kern/command.c \
+@COND_powerpc_ieee1275_TRUE@ kern/corecmd.c kern/device.c \
+@COND_powerpc_ieee1275_TRUE@ kern/disk.c kern/dl.c kern/env.c \
+@COND_powerpc_ieee1275_TRUE@ kern/err.c kern/file.c kern/fs.c \
+@COND_powerpc_ieee1275_TRUE@ kern/list.c kern/main.c \
+@COND_powerpc_ieee1275_TRUE@ kern/misc.c kern/parser.c \
+@COND_powerpc_ieee1275_TRUE@ kern/partition.c \
+@COND_powerpc_ieee1275_TRUE@ kern/rescue_parser.c \
+@COND_powerpc_ieee1275_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_powerpc_ieee1275_TRUE@ kern/verifiers.c
+@COND_riscv32_efi_TRUE@kernel_exec_SOURCES = kern/riscv/efi/startup.S \
+@COND_riscv32_efi_TRUE@ kern/riscv/efi/init.c kern/efi/fdt.c \
+@COND_riscv32_efi_TRUE@ kern/riscv/cache.c \
+@COND_riscv32_efi_TRUE@ kern/riscv/cache_flush.S \
+@COND_riscv32_efi_TRUE@ kern/riscv/dl.c lib/division.c \
+@COND_riscv32_efi_TRUE@ disk/efi/efidisk.c kern/efi/efi.c \
+@COND_riscv32_efi_TRUE@ kern/efi/init.c kern/efi/mm.c \
+@COND_riscv32_efi_TRUE@ term/efi/console.c kern/acpi.c \
+@COND_riscv32_efi_TRUE@ kern/efi/acpi.c kern/efi/sb.c \
+@COND_riscv32_efi_TRUE@ kern/lockdown.c kern/compiler-rt.c \
+@COND_riscv32_efi_TRUE@ kern/mm.c kern/time.c \
+@COND_riscv32_efi_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_riscv32_efi_TRUE@ kern/command.c kern/corecmd.c \
+@COND_riscv32_efi_TRUE@ kern/device.c kern/disk.c kern/dl.c \
+@COND_riscv32_efi_TRUE@ kern/env.c kern/err.c kern/file.c \
+@COND_riscv32_efi_TRUE@ kern/fs.c kern/list.c kern/main.c \
+@COND_riscv32_efi_TRUE@ kern/misc.c kern/parser.c \
+@COND_riscv32_efi_TRUE@ kern/partition.c kern/rescue_parser.c \
+@COND_riscv32_efi_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_riscv32_efi_TRUE@ kern/verifiers.c
+@COND_riscv64_efi_TRUE@kernel_exec_SOURCES = kern/riscv/efi/startup.S \
+@COND_riscv64_efi_TRUE@ kern/riscv/efi/init.c kern/efi/fdt.c \
+@COND_riscv64_efi_TRUE@ kern/riscv/cache.c \
+@COND_riscv64_efi_TRUE@ kern/riscv/cache_flush.S \
+@COND_riscv64_efi_TRUE@ kern/riscv/dl.c disk/efi/efidisk.c \
+@COND_riscv64_efi_TRUE@ kern/efi/efi.c kern/efi/init.c \
+@COND_riscv64_efi_TRUE@ kern/efi/mm.c term/efi/console.c \
+@COND_riscv64_efi_TRUE@ kern/acpi.c kern/efi/acpi.c \
+@COND_riscv64_efi_TRUE@ kern/efi/sb.c kern/lockdown.c \
+@COND_riscv64_efi_TRUE@ kern/compiler-rt.c kern/mm.c \
+@COND_riscv64_efi_TRUE@ kern/time.c kern/generic/millisleep.c \
+@COND_riscv64_efi_TRUE@ kern/buffer.c kern/command.c \
+@COND_riscv64_efi_TRUE@ kern/corecmd.c kern/device.c \
+@COND_riscv64_efi_TRUE@ kern/disk.c kern/dl.c kern/env.c \
+@COND_riscv64_efi_TRUE@ kern/err.c kern/file.c kern/fs.c \
+@COND_riscv64_efi_TRUE@ kern/list.c kern/main.c kern/misc.c \
+@COND_riscv64_efi_TRUE@ kern/parser.c kern/partition.c \
+@COND_riscv64_efi_TRUE@ kern/rescue_parser.c \
+@COND_riscv64_efi_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_riscv64_efi_TRUE@ kern/verifiers.c
+@COND_sparc64_ieee1275_TRUE@kernel_exec_SOURCES = \
+@COND_sparc64_ieee1275_TRUE@ kern/sparc64/ieee1275/crt0.S \
+@COND_sparc64_ieee1275_TRUE@ kern/sparc64/cache.S \
+@COND_sparc64_ieee1275_TRUE@ kern/sparc64/dl.c \
+@COND_sparc64_ieee1275_TRUE@ kern/sparc64/ieee1275/ieee1275.c \
+@COND_sparc64_ieee1275_TRUE@ disk/ieee1275/obdisk.c \
+@COND_sparc64_ieee1275_TRUE@ disk/ieee1275/ofdisk.c \
+@COND_sparc64_ieee1275_TRUE@ kern/ieee1275/cmain.c \
+@COND_sparc64_ieee1275_TRUE@ kern/ieee1275/ieee1275.c \
+@COND_sparc64_ieee1275_TRUE@ kern/ieee1275/mmap.c \
+@COND_sparc64_ieee1275_TRUE@ kern/ieee1275/openfw.c \
+@COND_sparc64_ieee1275_TRUE@ term/ieee1275/console.c \
+@COND_sparc64_ieee1275_TRUE@ kern/ieee1275/init.c \
+@COND_sparc64_ieee1275_TRUE@ term/terminfo.c term/tparm.c \
+@COND_sparc64_ieee1275_TRUE@ commands/extcmd.c lib/arg.c \
+@COND_sparc64_ieee1275_TRUE@ kern/compiler-rt.c kern/mm.c \
+@COND_sparc64_ieee1275_TRUE@ kern/time.c \
+@COND_sparc64_ieee1275_TRUE@ kern/generic/millisleep.c \
+@COND_sparc64_ieee1275_TRUE@ kern/buffer.c kern/command.c \
+@COND_sparc64_ieee1275_TRUE@ kern/corecmd.c kern/device.c \
+@COND_sparc64_ieee1275_TRUE@ kern/disk.c kern/dl.c kern/env.c \
+@COND_sparc64_ieee1275_TRUE@ kern/err.c kern/file.c kern/fs.c \
+@COND_sparc64_ieee1275_TRUE@ kern/list.c kern/main.c \
+@COND_sparc64_ieee1275_TRUE@ kern/misc.c kern/parser.c \
+@COND_sparc64_ieee1275_TRUE@ kern/partition.c \
+@COND_sparc64_ieee1275_TRUE@ kern/rescue_parser.c \
+@COND_sparc64_ieee1275_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_sparc64_ieee1275_TRUE@ kern/verifiers.c
+@COND_x86_64_efi_TRUE@kernel_exec_SOURCES = kern/x86_64/efi/startup.S \
+@COND_x86_64_efi_TRUE@ kern/i386/efi/tsc.c \
+@COND_x86_64_efi_TRUE@ kern/i386/tsc_pmtimer.c \
+@COND_x86_64_efi_TRUE@ kern/x86_64/efi/callwrap.S \
+@COND_x86_64_efi_TRUE@ kern/i386/efi/init.c bus/pci.c \
+@COND_x86_64_efi_TRUE@ kern/x86_64/dl.c kern/i386/tsc.c \
+@COND_x86_64_efi_TRUE@ kern/i386/tsc_pit.c disk/efi/efidisk.c \
+@COND_x86_64_efi_TRUE@ kern/efi/efi.c kern/efi/init.c \
+@COND_x86_64_efi_TRUE@ kern/efi/mm.c term/efi/console.c \
+@COND_x86_64_efi_TRUE@ kern/acpi.c kern/efi/acpi.c \
+@COND_x86_64_efi_TRUE@ kern/efi/sb.c kern/lockdown.c \
+@COND_x86_64_efi_TRUE@ kern/compiler-rt.c kern/mm.c kern/time.c \
+@COND_x86_64_efi_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_x86_64_efi_TRUE@ kern/command.c kern/corecmd.c \
+@COND_x86_64_efi_TRUE@ kern/device.c kern/disk.c kern/dl.c \
+@COND_x86_64_efi_TRUE@ kern/env.c kern/err.c kern/file.c \
+@COND_x86_64_efi_TRUE@ kern/fs.c kern/list.c kern/main.c \
+@COND_x86_64_efi_TRUE@ kern/misc.c kern/parser.c \
+@COND_x86_64_efi_TRUE@ kern/partition.c kern/rescue_parser.c \
+@COND_x86_64_efi_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_x86_64_efi_TRUE@ kern/verifiers.c
+@COND_x86_64_xen_TRUE@kernel_exec_SOURCES = kern/x86_64/xen/startup.S \
+@COND_x86_64_xen_TRUE@ kern/x86_64/dl.c \
+@COND_x86_64_xen_TRUE@ kern/x86_64/xen/hypercall.S \
+@COND_x86_64_xen_TRUE@ kern/i386/tsc.c kern/i386/xen/tsc.c \
+@COND_x86_64_xen_TRUE@ kern/xen/init.c term/xen/console.c \
+@COND_x86_64_xen_TRUE@ disk/xen/xendisk.c commands/boot.c \
+@COND_x86_64_xen_TRUE@ term/terminfo.c term/tparm.c \
+@COND_x86_64_xen_TRUE@ commands/extcmd.c lib/arg.c \
+@COND_x86_64_xen_TRUE@ kern/compiler-rt.c kern/mm.c kern/time.c \
+@COND_x86_64_xen_TRUE@ kern/generic/millisleep.c kern/buffer.c \
+@COND_x86_64_xen_TRUE@ kern/command.c kern/corecmd.c \
+@COND_x86_64_xen_TRUE@ kern/device.c kern/disk.c kern/dl.c \
+@COND_x86_64_xen_TRUE@ kern/env.c kern/err.c kern/file.c \
+@COND_x86_64_xen_TRUE@ kern/fs.c kern/list.c kern/main.c \
+@COND_x86_64_xen_TRUE@ kern/misc.c kern/parser.c \
+@COND_x86_64_xen_TRUE@ kern/partition.c kern/rescue_parser.c \
+@COND_x86_64_xen_TRUE@ kern/rescue_reader.c kern/term.c \
+@COND_x86_64_xen_TRUE@ kern/verifiers.c
+@COND_arm64_efi_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_arm_coreboot_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_arm_efi_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_arm_uboot_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_emu_TRUE@nodist_kernel_exec_SOURCES = ## platform nodist sources
+@COND_i386_coreboot_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_i386_efi_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_i386_ieee1275_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_i386_multiboot_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_i386_pc_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_i386_xen_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_i386_xen_pvh_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_ia64_efi_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_mips_arc_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_powerpc_ieee1275_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_riscv32_efi_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_riscv64_efi_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_x86_64_efi_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_x86_64_xen_TRUE@nodist_kernel_exec_SOURCES = symlist.c ## platform nodist sources
+@COND_arm64_efi_TRUE@kernel_exec_LDADD =
+@COND_arm_coreboot_TRUE@kernel_exec_LDADD =
+@COND_arm_efi_TRUE@kernel_exec_LDADD =
+@COND_arm_uboot_TRUE@kernel_exec_LDADD =
+@COND_emu_TRUE@kernel_exec_LDADD =
+@COND_i386_coreboot_TRUE@kernel_exec_LDADD =
+@COND_i386_efi_TRUE@kernel_exec_LDADD =
+@COND_i386_ieee1275_TRUE@kernel_exec_LDADD =
+@COND_i386_multiboot_TRUE@kernel_exec_LDADD =
+@COND_i386_pc_TRUE@kernel_exec_LDADD =
+@COND_i386_qemu_TRUE@kernel_exec_LDADD =
+@COND_i386_xen_TRUE@kernel_exec_LDADD =
+@COND_i386_xen_pvh_TRUE@kernel_exec_LDADD =
+@COND_ia64_efi_TRUE@kernel_exec_LDADD =
+@COND_mips_arc_TRUE@kernel_exec_LDADD =
+@COND_mips_loongson_TRUE@kernel_exec_LDADD =
+@COND_mips_qemu_mips_TRUE@kernel_exec_LDADD =
+@COND_powerpc_ieee1275_TRUE@kernel_exec_LDADD =
+@COND_riscv32_efi_TRUE@kernel_exec_LDADD =
+@COND_riscv64_efi_TRUE@kernel_exec_LDADD =
+@COND_sparc64_ieee1275_TRUE@kernel_exec_LDADD =
+@COND_x86_64_efi_TRUE@kernel_exec_LDADD =
+@COND_x86_64_xen_TRUE@kernel_exec_LDADD =
+@COND_arm64_efi_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_arm_coreboot_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_arm_efi_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_arm_uboot_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_emu_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL) $(CFLAGS_GNULIB)
+@COND_i386_coreboot_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_i386_efi_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_i386_ieee1275_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_i386_multiboot_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_i386_pc_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_i386_qemu_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_i386_xen_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_i386_xen_pvh_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_ia64_efi_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL) -fno-builtin -fpic -minline-int-divide-max-throughput
+@COND_mips_arc_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_mips_loongson_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_mips_qemu_mips_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_powerpc_ieee1275_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_riscv32_efi_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_riscv64_efi_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_sparc64_ieee1275_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_x86_64_efi_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_x86_64_xen_TRUE@kernel_exec_CFLAGS = $(AM_CFLAGS) $(CFLAGS_KERNEL)
+@COND_arm64_efi_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+@COND_arm_coreboot_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+@COND_arm_efi_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+@COND_arm_uboot_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+@COND_emu_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+@COND_i386_coreboot_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x9000
+@COND_i386_efi_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+@COND_i386_ieee1275_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x10000
+@COND_i386_multiboot_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x9000
+@COND_i386_pc_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x9000
+@COND_i386_qemu_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x9000
+@COND_i386_xen_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0
+@COND_i386_xen_pvh_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x100000
+@COND_ia64_efi_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+@COND_mips_arc_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-Ttext,$(TARGET_LINK_ADDR)
+@COND_mips_loongson_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-Ttext,0x80200000
+@COND_mips_qemu_mips_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-Ttext,0x80200000
+@COND_powerpc_ieee1275_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-Ttext,0x200000
+@COND_riscv32_efi_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+@COND_riscv64_efi_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+@COND_sparc64_ieee1275_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-Ttext,0x4400
+@COND_x86_64_efi_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) -Wl,-r,-d
+@COND_x86_64_xen_TRUE@kernel_exec_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_KERNEL) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0
+@COND_arm64_efi_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_arm_coreboot_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_arm_efi_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_arm_uboot_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_emu_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS_GNULIB)
+@COND_i386_coreboot_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_i386_efi_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_i386_ieee1275_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_i386_multiboot_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_i386_pc_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_i386_qemu_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
+@COND_i386_xen_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_i386_xen_pvh_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_ia64_efi_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_mips_arc_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) -DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)
+@COND_mips_loongson_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_mips_qemu_mips_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_powerpc_ieee1275_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_riscv32_efi_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_riscv64_efi_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_sparc64_ieee1275_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_x86_64_efi_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_x86_64_xen_TRUE@kernel_exec_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL)
+@COND_arm64_efi_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_arm_coreboot_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_arm_efi_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_arm_uboot_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_emu_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_i386_coreboot_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_i386_efi_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_i386_ieee1275_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_i386_multiboot_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_i386_pc_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_i386_qemu_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_i386_xen_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_i386_xen_pvh_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_ia64_efi_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_mips_arc_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_mips_loongson_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_mips_qemu_mips_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_powerpc_ieee1275_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_riscv32_efi_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_riscv64_efi_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_sparc64_ieee1275_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_x86_64_efi_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_x86_64_xen_TRUE@kernel_exec_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_KERNEL)
+@COND_arm64_efi_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame
+@COND_arm_coreboot_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+@COND_arm_efi_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+@COND_arm_uboot_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+@COND_emu_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_i386_coreboot_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_i386_efi_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+@COND_i386_ieee1275_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_i386_multiboot_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_i386_pc_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_i386_qemu_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_i386_xen_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_i386_xen_pvh_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_ia64_efi_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+@COND_mips_arc_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_mips_loongson_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_mips_qemu_mips_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_powerpc_ieee1275_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_riscv32_efi_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame
+@COND_riscv64_efi_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame
+@COND_sparc64_ieee1275_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_x86_64_efi_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL) --strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version
+@COND_x86_64_xen_TRUE@kernel_exec_STRIPFLAGS = $(AM_STRIPFLAGS) $(STRIPFLAGS_KERNEL)
+@COND_arm64_efi_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_coreboot_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_efi_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_arm_uboot_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_emu_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_coreboot_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_efi_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_ieee1275_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_multiboot_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_qemu_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_xen_pvh_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_ia64_efi_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_arc_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_loongson_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_mips_qemu_mips_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_powerpc_ieee1275_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv32_efi_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_riscv64_efi_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_sparc64_ieee1275_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_efi_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_x86_64_xen_TRUE@kernel_exec_DEPENDENCIES = $(TARGET_OBJ2ELF)
+@COND_i386_pc_TRUE@boot_image_SOURCES = boot/i386/pc/boot.S
+@COND_i386_qemu_TRUE@boot_image_SOURCES = boot/i386/qemu/boot.S
+@COND_sparc64_ieee1275_TRUE@boot_image_SOURCES = boot/sparc64/ieee1275/boot.S
+@COND_i386_pc_TRUE@nodist_boot_image_SOURCES = ## platform nodist sources
+@COND_i386_qemu_TRUE@nodist_boot_image_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_boot_image_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@boot_image_LDADD =
+@COND_i386_qemu_TRUE@boot_image_LDADD =
+@COND_sparc64_ieee1275_TRUE@boot_image_LDADD =
+@COND_i386_pc_TRUE@boot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_i386_qemu_TRUE@boot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_sparc64_ieee1275_TRUE@boot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_i386_pc_TRUE@boot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x7C00
+@COND_i386_qemu_TRUE@boot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)
+@COND_sparc64_ieee1275_TRUE@boot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext=0x3fe0
+@COND_i386_pc_TRUE@boot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_i386_qemu_TRUE@boot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_sparc64_ieee1275_TRUE@boot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_i386_pc_TRUE@boot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_i386_qemu_TRUE@boot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
+@COND_sparc64_ieee1275_TRUE@boot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_i386_pc_TRUE@boot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_i386_qemu_TRUE@boot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_sparc64_ieee1275_TRUE@boot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_i386_pc_TRUE@boot_hybrid_image_SOURCES = boot/i386/pc/boot.S
+@COND_i386_pc_TRUE@nodist_boot_hybrid_image_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@boot_hybrid_image_LDADD =
+@COND_i386_pc_TRUE@boot_hybrid_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_i386_pc_TRUE@boot_hybrid_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x7C00
+@COND_i386_pc_TRUE@boot_hybrid_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -DHYBRID_BOOT=1
+@COND_i386_pc_TRUE@boot_hybrid_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_i386_pc_TRUE@boot_hybrid_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_i386_pc_TRUE@cdboot_image_SOURCES = boot/i386/pc/cdboot.S
+@COND_sparc64_ieee1275_TRUE@cdboot_image_SOURCES = boot/sparc64/ieee1275/boot.S
+@COND_i386_pc_TRUE@nodist_cdboot_image_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_cdboot_image_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@cdboot_image_LDADD =
+@COND_sparc64_ieee1275_TRUE@cdboot_image_LDADD =
+@COND_i386_pc_TRUE@cdboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_sparc64_ieee1275_TRUE@cdboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_i386_pc_TRUE@cdboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x7C00
+@COND_sparc64_ieee1275_TRUE@cdboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext=0x3fe0
+@COND_i386_pc_TRUE@cdboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_sparc64_ieee1275_TRUE@cdboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -DCDBOOT=1
+@COND_i386_pc_TRUE@cdboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_sparc64_ieee1275_TRUE@cdboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_i386_pc_TRUE@cdboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_sparc64_ieee1275_TRUE@cdboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_i386_pc_TRUE@pxeboot_image_SOURCES = boot/i386/pc/pxeboot.S
+@COND_i386_pc_TRUE@nodist_pxeboot_image_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@pxeboot_image_LDADD =
+@COND_i386_pc_TRUE@pxeboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_i386_pc_TRUE@pxeboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x7C00
+@COND_i386_pc_TRUE@pxeboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_i386_pc_TRUE@pxeboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_i386_pc_TRUE@pxeboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_i386_pc_TRUE@diskboot_image_SOURCES = boot/i386/pc/diskboot.S
+@COND_sparc64_ieee1275_TRUE@diskboot_image_SOURCES = boot/sparc64/ieee1275/diskboot.S
+@COND_i386_pc_TRUE@nodist_diskboot_image_SOURCES = ## platform nodist sources
+@COND_sparc64_ieee1275_TRUE@nodist_diskboot_image_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@diskboot_image_LDADD =
+@COND_sparc64_ieee1275_TRUE@diskboot_image_LDADD =
+@COND_i386_pc_TRUE@diskboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_sparc64_ieee1275_TRUE@diskboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_i386_pc_TRUE@diskboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x8000
+@COND_sparc64_ieee1275_TRUE@diskboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext=0x4200
+@COND_i386_pc_TRUE@diskboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_sparc64_ieee1275_TRUE@diskboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_i386_pc_TRUE@diskboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_sparc64_ieee1275_TRUE@diskboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_i386_pc_TRUE@diskboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_sparc64_ieee1275_TRUE@diskboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_i386_pc_TRUE@lnxboot_image_SOURCES = boot/i386/pc/lnxboot.S
+@COND_i386_pc_TRUE@nodist_lnxboot_image_SOURCES = ## platform nodist sources
+@COND_i386_pc_TRUE@lnxboot_image_LDADD =
+@COND_i386_pc_TRUE@lnxboot_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_i386_pc_TRUE@lnxboot_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x6000
+@COND_i386_pc_TRUE@lnxboot_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_i386_pc_TRUE@lnxboot_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_i386_pc_TRUE@lnxboot_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_mips_arc_TRUE@xz_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/minilib.c boot/decompressor/xz.c lib/xzembed/xz_dec_bcj.c lib/xzembed/xz_dec_lzma2.c lib/xzembed/xz_dec_stream.c kern/compiler-rt.c
+@COND_mips_loongson_TRUE@xz_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/minilib.c boot/decompressor/xz.c lib/xzembed/xz_dec_bcj.c lib/xzembed/xz_dec_lzma2.c lib/xzembed/xz_dec_stream.c kern/compiler-rt.c
+@COND_mips_qemu_mips_TRUE@xz_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/minilib.c boot/decompressor/xz.c lib/xzembed/xz_dec_bcj.c lib/xzembed/xz_dec_lzma2.c lib/xzembed/xz_dec_stream.c kern/compiler-rt.c
+@COND_mips_arc_TRUE@nodist_xz_decompress_image_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_xz_decompress_image_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_xz_decompress_image_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@xz_decompress_image_LDADD =
+@COND_mips_loongson_TRUE@xz_decompress_image_LDADD =
+@COND_mips_qemu_mips_TRUE@xz_decompress_image_LDADD =
+@COND_mips_arc_TRUE@xz_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE) -Wno-unreachable-code
+@COND_mips_loongson_TRUE@xz_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE) -Wno-unreachable-code
+@COND_mips_qemu_mips_TRUE@xz_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE) -Wno-unreachable-code
+@COND_mips_arc_TRUE@xz_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+@COND_mips_loongson_TRUE@xz_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+@COND_mips_qemu_mips_TRUE@xz_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+@COND_mips_arc_TRUE@xz_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1
+@COND_mips_loongson_TRUE@xz_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1
+@COND_mips_qemu_mips_TRUE@xz_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1
+@COND_mips_arc_TRUE@xz_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_mips_loongson_TRUE@xz_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_mips_qemu_mips_TRUE@xz_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_mips_arc_TRUE@xz_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_mips_loongson_TRUE@xz_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_mips_qemu_mips_TRUE@xz_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_mips_arc_TRUE@none_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/none.c
+@COND_mips_loongson_TRUE@none_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/none.c
+@COND_mips_qemu_mips_TRUE@none_decompress_image_SOURCES = boot/mips/startup_raw.S boot/decompressor/none.c
+@COND_mips_arc_TRUE@nodist_none_decompress_image_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@nodist_none_decompress_image_SOURCES = ## platform nodist sources
+@COND_mips_qemu_mips_TRUE@nodist_none_decompress_image_SOURCES = ## platform nodist sources
+@COND_mips_arc_TRUE@none_decompress_image_LDADD =
+@COND_mips_loongson_TRUE@none_decompress_image_LDADD =
+@COND_mips_qemu_mips_TRUE@none_decompress_image_LDADD =
+@COND_mips_arc_TRUE@none_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_mips_loongson_TRUE@none_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_mips_qemu_mips_TRUE@none_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_mips_arc_TRUE@none_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+@COND_mips_loongson_TRUE@none_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+@COND_mips_qemu_mips_TRUE@none_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)
+@COND_mips_arc_TRUE@none_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -DGRUB_EMBED_DECOMPRESSOR=1
+@COND_mips_loongson_TRUE@none_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -DGRUB_EMBED_DECOMPRESSOR=1
+@COND_mips_qemu_mips_TRUE@none_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) -DGRUB_EMBED_DECOMPRESSOR=1
+@COND_mips_arc_TRUE@none_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_mips_loongson_TRUE@none_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_mips_qemu_mips_TRUE@none_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_mips_arc_TRUE@none_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_mips_loongson_TRUE@none_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_mips_qemu_mips_TRUE@none_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_i386_pc_TRUE@lzma_decompress_image_SOURCES = boot/i386/pc/startup_raw.S
+@COND_i386_pc_TRUE@nodist_lzma_decompress_image_SOURCES = rs_decoder.h ## platform nodist sources
+@COND_i386_pc_TRUE@lzma_decompress_image_LDADD =
+@COND_i386_pc_TRUE@lzma_decompress_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_i386_pc_TRUE@lzma_decompress_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) $(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x8200
+@COND_i386_pc_TRUE@lzma_decompress_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_i386_pc_TRUE@lzma_decompress_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_i386_pc_TRUE@lzma_decompress_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_mips_loongson_TRUE@fwstart_image_SOURCES = boot/mips/loongson/fwstart.S
+@COND_mips_loongson_TRUE@nodist_fwstart_image_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@fwstart_image_LDADD =
+@COND_mips_loongson_TRUE@fwstart_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_mips_loongson_TRUE@fwstart_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic
+@COND_mips_loongson_TRUE@fwstart_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_mips_loongson_TRUE@fwstart_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_mips_loongson_TRUE@fwstart_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_mips_loongson_TRUE@fwstart_fuloong2f_image_SOURCES = boot/mips/loongson/fuloong2f.S
+@COND_mips_loongson_TRUE@nodist_fwstart_fuloong2f_image_SOURCES = ## platform nodist sources
+@COND_mips_loongson_TRUE@fwstart_fuloong2f_image_LDADD =
+@COND_mips_loongson_TRUE@fwstart_fuloong2f_image_CFLAGS = $(AM_CFLAGS) $(CFLAGS_IMAGE)
+@COND_mips_loongson_TRUE@fwstart_fuloong2f_image_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_IMAGE) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic
+@COND_mips_loongson_TRUE@fwstart_fuloong2f_image_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_IMAGE)
+@COND_mips_loongson_TRUE@fwstart_fuloong2f_image_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_IMAGE)
+@COND_mips_loongson_TRUE@fwstart_fuloong2f_image_OBJCOPYFLAGS = $(OBJCOPYFLAGS_IMAGE) -O binary
+@COND_emu_TRUE@grub_emu_SOURCES = kern/emu/full.c
+@COND_emu_TRUE@nodist_grub_emu_SOURCES = grub_emu_init.c
+@COND_emu_TRUE@grub_emu_LDADD = kernel.exec$(EXEEXT) $(MODULE_FILES) lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)
+@COND_emu_TRUE@grub_emu_CFLAGS = $(AM_CFLAGS) $(CFLAGS_PROGRAM)
+@COND_emu_TRUE@grub_emu_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM)
+@COND_emu_TRUE@grub_emu_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_PROGRAM)
+@COND_emu_TRUE@grub_emu_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_PROGRAM)
+@COND_emu_TRUE@grub_emu_lite_SOURCES = kern/emu/lite.c
+@COND_emu_TRUE@nodist_grub_emu_lite_SOURCES = symlist.c
+@COND_emu_TRUE@grub_emu_lite_LDADD = kernel.exec$(EXEEXT) lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)
+@COND_emu_TRUE@grub_emu_lite_CFLAGS = $(AM_CFLAGS) $(CFLAGS_PROGRAM)
+@COND_emu_TRUE@grub_emu_lite_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM)
+@COND_emu_TRUE@grub_emu_lite_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_PROGRAM)
+@COND_emu_TRUE@grub_emu_lite_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_PROGRAM)
+@COND_HAVE_ASM_USCORE_FALSE@ASM_PREFIX =
+@COND_HAVE_ASM_USCORE_TRUE@ASM_PREFIX = _
+windowsdir = $(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .S .c .log .o .obj .test .test$(EXEEXT) .trs
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/conf/Makefile.common $(srcdir)/Makefile.core.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu grub-core/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu grub-core/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+$(top_srcdir)/conf/Makefile.common $(srcdir)/Makefile.core.am $(am__empty):
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+ fi; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p \
+ ; then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' \
+ -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' \
+ `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+clean-checkPROGRAMS:
+ -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
+
+clean-noinstPROGRAMS:
+ -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+install-platformPROGRAMS: $(platform_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ @list='$(platform_PROGRAMS)'; test -n "$(platformdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(platformdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(platformdir)" || exit 1; \
+ fi; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p \
+ ; then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' \
+ -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(platformdir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(platformdir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-platformPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(platform_PROGRAMS)'; test -n "$(platformdir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' \
+ `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(platformdir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(platformdir)" && rm -f $$files
+
+clean-platformPROGRAMS:
+ -test -z "$(platform_PROGRAMS)" || rm -f $(platform_PROGRAMS)
+install-sbinPROGRAMS: $(sbin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \
+ fi; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p \
+ ; then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' \
+ -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-sbinPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' \
+ `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(sbindir)" && rm -f $$files
+
+clean-sbinPROGRAMS:
+ -test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+commands/$(am__dirstamp):
+ @$(MKDIR_P) commands
+ @: > commands/$(am__dirstamp)
+commands/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) commands/$(DEPDIR)
+ @: > commands/$(DEPDIR)/$(am__dirstamp)
+commands/acpi_module-acpi.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+kern/$(am__dirstamp):
+ @$(MKDIR_P) kern
+ @: > kern/$(am__dirstamp)
+kern/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/$(DEPDIR)
+ @: > kern/$(DEPDIR)/$(am__dirstamp)
+kern/acpi_module-acpi.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/pc
+ @: > kern/i386/pc/$(am__dirstamp)
+kern/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/pc/$(DEPDIR)
+ @: > kern/i386/pc/$(DEPDIR)/$(am__dirstamp)
+kern/i386/pc/acpi_module-acpi.$(OBJEXT): kern/i386/pc/$(am__dirstamp) \
+ kern/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+acpi.module$(EXEEXT): $(acpi_module_OBJECTS) $(acpi_module_DEPENDENCIES) $(EXTRA_acpi_module_DEPENDENCIES)
+ @rm -f acpi.module$(EXEEXT)
+ $(AM_V_CCLD)$(acpi_module_LINK) $(acpi_module_OBJECTS) $(acpi_module_LDADD) $(LIBS)
+lib/$(am__dirstamp):
+ @$(MKDIR_P) lib
+ @: > lib/$(am__dirstamp)
+lib/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/$(DEPDIR)
+ @: > lib/$(DEPDIR)/$(am__dirstamp)
+lib/adler32_module-adler32.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+adler32.module$(EXEEXT): $(adler32_module_OBJECTS) $(adler32_module_DEPENDENCIES) $(EXTRA_adler32_module_DEPENDENCIES)
+ @rm -f adler32.module$(EXEEXT)
+ $(AM_V_CCLD)$(adler32_module_LINK) $(adler32_module_OBJECTS) $(adler32_module_LDADD) $(LIBS)
+fs/$(am__dirstamp):
+ @$(MKDIR_P) fs
+ @: > fs/$(am__dirstamp)
+fs/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) fs/$(DEPDIR)
+ @: > fs/$(DEPDIR)/$(am__dirstamp)
+fs/affs_module-affs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+affs.module$(EXEEXT): $(affs_module_OBJECTS) $(affs_module_DEPENDENCIES) $(EXTRA_affs_module_DEPENDENCIES)
+ @rm -f affs.module$(EXEEXT)
+ $(AM_V_CCLD)$(affs_module_LINK) $(affs_module_OBJECTS) $(affs_module_LDADD) $(LIBS)
+fs/afs_module-afs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+afs.module$(EXEEXT): $(afs_module_OBJECTS) $(afs_module_DEPENDENCIES) $(EXTRA_afs_module_DEPENDENCIES)
+ @rm -f afs.module$(EXEEXT)
+ $(AM_V_CCLD)$(afs_module_LINK) $(afs_module_OBJECTS) $(afs_module_LDADD) $(LIBS)
+disk/$(am__dirstamp):
+ @$(MKDIR_P) disk
+ @: > disk/$(am__dirstamp)
+disk/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) disk/$(DEPDIR)
+ @: > disk/$(DEPDIR)/$(am__dirstamp)
+disk/afsplitter_module-AFSplitter.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+afsplitter.module$(EXEEXT): $(afsplitter_module_OBJECTS) $(afsplitter_module_DEPENDENCIES) $(EXTRA_afsplitter_module_DEPENDENCIES)
+ @rm -f afsplitter.module$(EXEEXT)
+ $(AM_V_CCLD)$(afsplitter_module_LINK) $(afsplitter_module_OBJECTS) $(afsplitter_module_LDADD) $(LIBS)
+disk/ahci_module-ahci.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+ahci.module$(EXEEXT): $(ahci_module_OBJECTS) $(ahci_module_DEPENDENCIES) $(EXTRA_ahci_module_DEPENDENCIES)
+ @rm -f ahci.module$(EXEEXT)
+ $(AM_V_CCLD)$(ahci_module_LINK) $(ahci_module_OBJECTS) $(ahci_module_LDADD) $(LIBS)
+lib/all_video_module-fake_module.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+all_video.module$(EXEEXT): $(all_video_module_OBJECTS) $(all_video_module_DEPENDENCIES) $(EXTRA_all_video_module_DEPENDENCIES)
+ @rm -f all_video.module$(EXEEXT)
+ $(AM_V_CCLD)$(all_video_module_LINK) $(all_video_module_OBJECTS) $(all_video_module_LDADD) $(LIBS)
+loader/$(am__dirstamp):
+ @$(MKDIR_P) loader
+ @: > loader/$(am__dirstamp)
+loader/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/$(DEPDIR)
+ @: > loader/$(DEPDIR)/$(am__dirstamp)
+loader/aout_module-aout.$(OBJEXT): loader/$(am__dirstamp) \
+ loader/$(DEPDIR)/$(am__dirstamp)
+
+aout.module$(EXEEXT): $(aout_module_OBJECTS) $(aout_module_DEPENDENCIES) $(EXTRA_aout_module_DEPENDENCIES)
+ @rm -f aout.module$(EXEEXT)
+ $(AM_V_CCLD)$(aout_module_LINK) $(aout_module_OBJECTS) $(aout_module_LDADD) $(LIBS)
+loader/efi/$(am__dirstamp):
+ @$(MKDIR_P) loader/efi
+ @: > loader/efi/$(am__dirstamp)
+loader/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/efi/$(DEPDIR)
+ @: > loader/efi/$(DEPDIR)/$(am__dirstamp)
+loader/efi/appleldr_module-appleloader.$(OBJEXT): \
+ loader/efi/$(am__dirstamp) \
+ loader/efi/$(DEPDIR)/$(am__dirstamp)
+
+appleldr.module$(EXEEXT): $(appleldr_module_OBJECTS) $(appleldr_module_DEPENDENCIES) $(EXTRA_appleldr_module_DEPENDENCIES)
+ @rm -f appleldr.module$(EXEEXT)
+ $(AM_V_CCLD)$(appleldr_module_LINK) $(appleldr_module_OBJECTS) $(appleldr_module_LDADD) $(LIBS)
+fs/archelp_module-archelp.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+archelp.module$(EXEEXT): $(archelp_module_OBJECTS) $(archelp_module_DEPENDENCIES) $(EXTRA_archelp_module_DEPENDENCIES)
+ @rm -f archelp.module$(EXEEXT)
+ $(AM_V_CCLD)$(archelp_module_LINK) $(archelp_module_OBJECTS) $(archelp_module_LDADD) $(LIBS)
+term/$(am__dirstamp):
+ @$(MKDIR_P) term
+ @: > term/$(am__dirstamp)
+term/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) term/$(DEPDIR)
+ @: > term/$(DEPDIR)/$(am__dirstamp)
+term/at_keyboard_module-at_keyboard.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+term/at_keyboard_module-ps2.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+
+at_keyboard.module$(EXEEXT): $(at_keyboard_module_OBJECTS) $(at_keyboard_module_DEPENDENCIES) $(EXTRA_at_keyboard_module_DEPENDENCIES)
+ @rm -f at_keyboard.module$(EXEEXT)
+ $(AM_V_CCLD)$(at_keyboard_module_LINK) $(at_keyboard_module_OBJECTS) $(at_keyboard_module_LDADD) $(LIBS)
+disk/ata_module-ata.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+ata.module$(EXEEXT): $(ata_module_OBJECTS) $(ata_module_DEPENDENCIES) $(EXTRA_ata_module_DEPENDENCIES)
+ @rm -f ata.module$(EXEEXT)
+ $(AM_V_CCLD)$(ata_module_LINK) $(ata_module_OBJECTS) $(ata_module_LDADD) $(LIBS)
+lib/i386/$(am__dirstamp):
+ @$(MKDIR_P) lib/i386
+ @: > lib/i386/$(am__dirstamp)
+lib/i386/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/i386/$(DEPDIR)
+ @: > lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/i386/backtrace_module-backtrace.$(OBJEXT): \
+ lib/i386/$(am__dirstamp) lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/backtrace_module-backtrace.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+backtrace.module$(EXEEXT): $(backtrace_module_OBJECTS) $(backtrace_module_DEPENDENCIES) $(EXTRA_backtrace_module_DEPENDENCIES)
+ @rm -f backtrace.module$(EXEEXT)
+ $(AM_V_CCLD)$(backtrace_module_LINK) $(backtrace_module_OBJECTS) $(backtrace_module_LDADD) $(LIBS)
+fs/bfs_module-bfs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+bfs.module$(EXEEXT): $(bfs_module_OBJECTS) $(bfs_module_DEPENDENCIES) $(EXTRA_bfs_module_DEPENDENCIES)
+ @rm -f bfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(bfs_module_LINK) $(bfs_module_OBJECTS) $(bfs_module_LDADD) $(LIBS)
+disk/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) disk/i386/pc
+ @: > disk/i386/pc/$(am__dirstamp)
+disk/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) disk/i386/pc/$(DEPDIR)
+ @: > disk/i386/pc/$(DEPDIR)/$(am__dirstamp)
+disk/i386/pc/biosdisk_module-biosdisk.$(OBJEXT): \
+ disk/i386/pc/$(am__dirstamp) \
+ disk/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+biosdisk.module$(EXEEXT): $(biosdisk_module_OBJECTS) $(biosdisk_module_DEPENDENCIES) $(EXTRA_biosdisk_module_DEPENDENCIES)
+ @rm -f biosdisk.module$(EXEEXT)
+ $(AM_V_CCLD)$(biosdisk_module_LINK) $(biosdisk_module_OBJECTS) $(biosdisk_module_LDADD) $(LIBS)
+video/$(am__dirstamp):
+ @$(MKDIR_P) video
+ @: > video/$(am__dirstamp)
+video/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) video/$(DEPDIR)
+ @: > video/$(DEPDIR)/$(am__dirstamp)
+video/bitmap_module-bitmap.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+
+bitmap.module$(EXEEXT): $(bitmap_module_OBJECTS) $(bitmap_module_DEPENDENCIES) $(EXTRA_bitmap_module_DEPENDENCIES)
+ @rm -f bitmap.module$(EXEEXT)
+ $(AM_V_CCLD)$(bitmap_module_LINK) $(bitmap_module_OBJECTS) $(bitmap_module_LDADD) $(LIBS)
+video/bitmap_scale_module-bitmap_scale.$(OBJEXT): \
+ video/$(am__dirstamp) video/$(DEPDIR)/$(am__dirstamp)
+
+bitmap_scale.module$(EXEEXT): $(bitmap_scale_module_OBJECTS) $(bitmap_scale_module_DEPENDENCIES) $(EXTRA_bitmap_scale_module_DEPENDENCIES)
+ @rm -f bitmap_scale.module$(EXEEXT)
+ $(AM_V_CCLD)$(bitmap_scale_module_LINK) $(bitmap_scale_module_OBJECTS) $(bitmap_scale_module_LDADD) $(LIBS)
+commands/blocklist_module-blocklist.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+blocklist.module$(EXEEXT): $(blocklist_module_OBJECTS) $(blocklist_module_DEPENDENCIES) $(EXTRA_blocklist_module_DEPENDENCIES)
+ @rm -f blocklist.module$(EXEEXT)
+ $(AM_V_CCLD)$(blocklist_module_LINK) $(blocklist_module_OBJECTS) $(blocklist_module_LDADD) $(LIBS)
+boot/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) boot/i386/pc
+ @: > boot/i386/pc/$(am__dirstamp)
+boot/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) boot/i386/pc/$(DEPDIR)
+ @: > boot/i386/pc/$(DEPDIR)/$(am__dirstamp)
+boot/i386/pc/boot_image-boot.$(OBJEXT): boot/i386/pc/$(am__dirstamp) \
+ boot/i386/pc/$(DEPDIR)/$(am__dirstamp)
+boot/i386/qemu/$(am__dirstamp):
+ @$(MKDIR_P) boot/i386/qemu
+ @: > boot/i386/qemu/$(am__dirstamp)
+boot/i386/qemu/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) boot/i386/qemu/$(DEPDIR)
+ @: > boot/i386/qemu/$(DEPDIR)/$(am__dirstamp)
+boot/i386/qemu/boot_image-boot.$(OBJEXT): \
+ boot/i386/qemu/$(am__dirstamp) \
+ boot/i386/qemu/$(DEPDIR)/$(am__dirstamp)
+boot/sparc64/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) boot/sparc64/ieee1275
+ @: > boot/sparc64/ieee1275/$(am__dirstamp)
+boot/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) boot/sparc64/ieee1275/$(DEPDIR)
+ @: > boot/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+boot/sparc64/ieee1275/boot_image-boot.$(OBJEXT): \
+ boot/sparc64/ieee1275/$(am__dirstamp) \
+ boot/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+boot.image$(EXEEXT): $(boot_image_OBJECTS) $(boot_image_DEPENDENCIES) $(EXTRA_boot_image_DEPENDENCIES)
+ @rm -f boot.image$(EXEEXT)
+ $(AM_V_CCLD)$(boot_image_LINK) $(boot_image_OBJECTS) $(boot_image_LDADD) $(LIBS)
+commands/boot_module-boot.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+lib/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) lib/i386/pc
+ @: > lib/i386/pc/$(am__dirstamp)
+lib/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/i386/pc/$(DEPDIR)
+ @: > lib/i386/pc/$(DEPDIR)/$(am__dirstamp)
+lib/i386/pc/boot_module-biosnum.$(OBJEXT): \
+ lib/i386/pc/$(am__dirstamp) \
+ lib/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+boot.module$(EXEEXT): $(boot_module_OBJECTS) $(boot_module_DEPENDENCIES) $(EXTRA_boot_module_DEPENDENCIES)
+ @rm -f boot.module$(EXEEXT)
+ $(AM_V_CCLD)$(boot_module_LINK) $(boot_module_OBJECTS) $(boot_module_LDADD) $(LIBS)
+boot/i386/pc/boot_hybrid_image-boot.$(OBJEXT): \
+ boot/i386/pc/$(am__dirstamp) \
+ boot/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+boot_hybrid.image$(EXEEXT): $(boot_hybrid_image_OBJECTS) $(boot_hybrid_image_DEPENDENCIES) $(EXTRA_boot_hybrid_image_DEPENDENCIES)
+ @rm -f boot_hybrid.image$(EXEEXT)
+ $(AM_V_CCLD)$(boot_hybrid_image_LINK) $(boot_hybrid_image_OBJECTS) $(boot_hybrid_image_LDADD) $(LIBS)
+commands/boottime_module-boottime.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+boottime.module$(EXEEXT): $(boottime_module_OBJECTS) $(boottime_module_DEPENDENCIES) $(EXTRA_boottime_module_DEPENDENCIES)
+ @rm -f boottime.module$(EXEEXT)
+ $(AM_V_CCLD)$(boottime_module_LINK) $(boottime_module_OBJECTS) $(boottime_module_LDADD) $(LIBS)
+loader/i386/$(am__dirstamp):
+ @$(MKDIR_P) loader/i386
+ @: > loader/i386/$(am__dirstamp)
+loader/i386/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/i386/$(DEPDIR)
+ @: > loader/i386/$(DEPDIR)/$(am__dirstamp)
+loader/i386/bsd_module-bsd.$(OBJEXT): loader/i386/$(am__dirstamp) \
+ loader/i386/$(DEPDIR)/$(am__dirstamp)
+loader/i386/bsd_module-bsd32.$(OBJEXT): loader/i386/$(am__dirstamp) \
+ loader/i386/$(DEPDIR)/$(am__dirstamp)
+loader/i386/bsd_module-bsd64.$(OBJEXT): loader/i386/$(am__dirstamp) \
+ loader/i386/$(DEPDIR)/$(am__dirstamp)
+
+bsd.module$(EXEEXT): $(bsd_module_OBJECTS) $(bsd_module_DEPENDENCIES) $(EXTRA_bsd_module_DEPENDENCIES)
+ @rm -f bsd.module$(EXEEXT)
+ $(AM_V_CCLD)$(bsd_module_LINK) $(bsd_module_OBJECTS) $(bsd_module_LDADD) $(LIBS)
+tests/$(am__dirstamp):
+ @$(MKDIR_P) tests
+ @: > tests/$(am__dirstamp)
+tests/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) tests/$(DEPDIR)
+ @: > tests/$(DEPDIR)/$(am__dirstamp)
+tests/bswap_test_module-bswap_test.$(OBJEXT): tests/$(am__dirstamp) \
+ tests/$(DEPDIR)/$(am__dirstamp)
+
+bswap_test.module$(EXEEXT): $(bswap_test_module_OBJECTS) $(bswap_test_module_DEPENDENCIES) $(EXTRA_bswap_test_module_DEPENDENCIES)
+ @rm -f bswap_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(bswap_test_module_LINK) $(bswap_test_module_OBJECTS) $(bswap_test_module_LDADD) $(LIBS)
+fs/btrfs_module-btrfs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+lib/btrfs_module-crc.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+btrfs.module$(EXEEXT): $(btrfs_module_OBJECTS) $(btrfs_module_DEPENDENCIES) $(EXTRA_btrfs_module_DEPENDENCIES)
+ @rm -f btrfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(btrfs_module_LINK) $(btrfs_module_OBJECTS) $(btrfs_module_LDADD) $(LIBS)
+io/$(am__dirstamp):
+ @$(MKDIR_P) io
+ @: > io/$(am__dirstamp)
+io/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) io/$(DEPDIR)
+ @: > io/$(DEPDIR)/$(am__dirstamp)
+io/bufio_module-bufio.$(OBJEXT): io/$(am__dirstamp) \
+ io/$(DEPDIR)/$(am__dirstamp)
+
+bufio.module$(EXEEXT): $(bufio_module_OBJECTS) $(bufio_module_DEPENDENCIES) $(EXTRA_bufio_module_DEPENDENCIES)
+ @rm -f bufio.module$(EXEEXT)
+ $(AM_V_CCLD)$(bufio_module_LINK) $(bufio_module_OBJECTS) $(bufio_module_LDADD) $(LIBS)
+commands/cacheinfo_module-cacheinfo.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+cacheinfo.module$(EXEEXT): $(cacheinfo_module_OBJECTS) $(cacheinfo_module_DEPENDENCIES) $(EXTRA_cacheinfo_module_DEPENDENCIES)
+ @rm -f cacheinfo.module$(EXEEXT)
+ $(AM_V_CCLD)$(cacheinfo_module_LINK) $(cacheinfo_module_OBJECTS) $(cacheinfo_module_LDADD) $(LIBS)
+commands/cat_module-cat.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+cat.module$(EXEEXT): $(cat_module_OBJECTS) $(cat_module_DEPENDENCIES) $(EXTRA_cat_module_DEPENDENCIES)
+ @rm -f cat.module$(EXEEXT)
+ $(AM_V_CCLD)$(cat_module_LINK) $(cat_module_OBJECTS) $(cat_module_LDADD) $(LIBS)
+fs/cbfs_module-cbfs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+cbfs.module$(EXEEXT): $(cbfs_module_OBJECTS) $(cbfs_module_DEPENDENCIES) $(EXTRA_cbfs_module_DEPENDENCIES)
+ @rm -f cbfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(cbfs_module_LINK) $(cbfs_module_OBJECTS) $(cbfs_module_LDADD) $(LIBS)
+commands/i386/coreboot/$(am__dirstamp):
+ @$(MKDIR_P) commands/i386/coreboot
+ @: > commands/i386/coreboot/$(am__dirstamp)
+commands/i386/coreboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) commands/i386/coreboot/$(DEPDIR)
+ @: > commands/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+commands/i386/coreboot/cbls_module-cbls.$(OBJEXT): \
+ commands/i386/coreboot/$(am__dirstamp) \
+ commands/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+
+cbls.module$(EXEEXT): $(cbls_module_OBJECTS) $(cbls_module_DEPENDENCIES) $(EXTRA_cbls_module_DEPENDENCIES)
+ @rm -f cbls.module$(EXEEXT)
+ $(AM_V_CCLD)$(cbls_module_LINK) $(cbls_module_OBJECTS) $(cbls_module_LDADD) $(LIBS)
+term/i386/coreboot/$(am__dirstamp):
+ @$(MKDIR_P) term/i386/coreboot
+ @: > term/i386/coreboot/$(am__dirstamp)
+term/i386/coreboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) term/i386/coreboot/$(DEPDIR)
+ @: > term/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+term/i386/coreboot/cbmemc_module-cbmemc.$(OBJEXT): \
+ term/i386/coreboot/$(am__dirstamp) \
+ term/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+
+cbmemc.module$(EXEEXT): $(cbmemc_module_OBJECTS) $(cbmemc_module_DEPENDENCIES) $(EXTRA_cbmemc_module_DEPENDENCIES)
+ @rm -f cbmemc.module$(EXEEXT)
+ $(AM_V_CCLD)$(cbmemc_module_LINK) $(cbmemc_module_OBJECTS) $(cbmemc_module_LDADD) $(LIBS)
+kern/i386/coreboot/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/coreboot
+ @: > kern/i386/coreboot/$(am__dirstamp)
+kern/i386/coreboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/coreboot/$(DEPDIR)
+ @: > kern/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/i386/coreboot/cbtable_module-cbtable.$(OBJEXT): \
+ kern/i386/coreboot/$(am__dirstamp) \
+ kern/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/coreboot/$(am__dirstamp):
+ @$(MKDIR_P) kern/coreboot
+ @: > kern/coreboot/$(am__dirstamp)
+kern/coreboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/coreboot/$(DEPDIR)
+ @: > kern/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/coreboot/cbtable_module-cbtable.$(OBJEXT): \
+ kern/coreboot/$(am__dirstamp) \
+ kern/coreboot/$(DEPDIR)/$(am__dirstamp)
+
+cbtable.module$(EXEEXT): $(cbtable_module_OBJECTS) $(cbtable_module_DEPENDENCIES) $(EXTRA_cbtable_module_DEPENDENCIES)
+ @rm -f cbtable.module$(EXEEXT)
+ $(AM_V_CCLD)$(cbtable_module_LINK) $(cbtable_module_OBJECTS) $(cbtable_module_LDADD) $(LIBS)
+commands/i386/coreboot/cbtime_module-cb_timestamps.$(OBJEXT): \
+ commands/i386/coreboot/$(am__dirstamp) \
+ commands/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+
+cbtime.module$(EXEEXT): $(cbtime_module_OBJECTS) $(cbtime_module_DEPENDENCIES) $(EXTRA_cbtime_module_DEPENDENCIES)
+ @rm -f cbtime.module$(EXEEXT)
+ $(AM_V_CCLD)$(cbtime_module_LINK) $(cbtime_module_OBJECTS) $(cbtime_module_LDADD) $(LIBS)
+boot/i386/pc/cdboot_image-cdboot.$(OBJEXT): \
+ boot/i386/pc/$(am__dirstamp) \
+ boot/i386/pc/$(DEPDIR)/$(am__dirstamp)
+boot/sparc64/ieee1275/cdboot_image-boot.$(OBJEXT): \
+ boot/sparc64/ieee1275/$(am__dirstamp) \
+ boot/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+cdboot.image$(EXEEXT): $(cdboot_image_OBJECTS) $(cdboot_image_DEPENDENCIES) $(EXTRA_cdboot_image_DEPENDENCIES)
+ @rm -f cdboot.image$(EXEEXT)
+ $(AM_V_CCLD)$(cdboot_image_LINK) $(cdboot_image_OBJECTS) $(cdboot_image_LDADD) $(LIBS)
+loader/efi/chain_module-chainloader.$(OBJEXT): \
+ loader/efi/$(am__dirstamp) \
+ loader/efi/$(DEPDIR)/$(am__dirstamp)
+loader/i386/coreboot/$(am__dirstamp):
+ @$(MKDIR_P) loader/i386/coreboot
+ @: > loader/i386/coreboot/$(am__dirstamp)
+loader/i386/coreboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/i386/coreboot/$(DEPDIR)
+ @: > loader/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+loader/i386/coreboot/chain_module-chainloader.$(OBJEXT): \
+ loader/i386/coreboot/$(am__dirstamp) \
+ loader/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+lib/chain_module-LzmaDec.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+loader/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) loader/i386/pc
+ @: > loader/i386/pc/$(am__dirstamp)
+loader/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/i386/pc/$(DEPDIR)
+ @: > loader/i386/pc/$(DEPDIR)/$(am__dirstamp)
+loader/i386/pc/chain_module-chainloader.$(OBJEXT): \
+ loader/i386/pc/$(am__dirstamp) \
+ loader/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+chain.module$(EXEEXT): $(chain_module_OBJECTS) $(chain_module_DEPENDENCIES) $(EXTRA_chain_module_DEPENDENCIES)
+ @rm -f chain.module$(EXEEXT)
+ $(AM_V_CCLD)$(chain_module_LINK) $(chain_module_OBJECTS) $(chain_module_LDADD) $(LIBS)
+tests/cmdline_cat_test_module-cmdline_cat_test.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+
+cmdline_cat_test.module$(EXEEXT): $(cmdline_cat_test_module_OBJECTS) $(cmdline_cat_test_module_DEPENDENCIES) $(EXTRA_cmdline_cat_test_module_DEPENDENCIES)
+ @rm -f cmdline_cat_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(cmdline_cat_test_module_LINK) $(cmdline_cat_test_module_OBJECTS) $(cmdline_cat_test_module_LDADD) $(LIBS)
+commands/i386/$(am__dirstamp):
+ @$(MKDIR_P) commands/i386
+ @: > commands/i386/$(am__dirstamp)
+commands/i386/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) commands/i386/$(DEPDIR)
+ @: > commands/i386/$(DEPDIR)/$(am__dirstamp)
+commands/i386/cmosdump_module-cmosdump.$(OBJEXT): \
+ commands/i386/$(am__dirstamp) \
+ commands/i386/$(DEPDIR)/$(am__dirstamp)
+
+cmosdump.module$(EXEEXT): $(cmosdump_module_OBJECTS) $(cmosdump_module_DEPENDENCIES) $(EXTRA_cmosdump_module_DEPENDENCIES)
+ @rm -f cmosdump.module$(EXEEXT)
+ $(AM_V_CCLD)$(cmosdump_module_LINK) $(cmosdump_module_OBJECTS) $(cmosdump_module_LDADD) $(LIBS)
+commands/i386/cmostest_module-cmostest.$(OBJEXT): \
+ commands/i386/$(am__dirstamp) \
+ commands/i386/$(DEPDIR)/$(am__dirstamp)
+
+cmostest.module$(EXEEXT): $(cmostest_module_OBJECTS) $(cmostest_module_DEPENDENCIES) $(EXTRA_cmostest_module_DEPENDENCIES)
+ @rm -f cmostest.module$(EXEEXT)
+ $(AM_V_CCLD)$(cmostest_module_LINK) $(cmostest_module_OBJECTS) $(cmostest_module_LDADD) $(LIBS)
+commands/cmp_module-cmp.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+cmp.module$(EXEEXT): $(cmp_module_OBJECTS) $(cmp_module_DEPENDENCIES) $(EXTRA_cmp_module_DEPENDENCIES)
+ @rm -f cmp.module$(EXEEXT)
+ $(AM_V_CCLD)$(cmp_module_LINK) $(cmp_module_OBJECTS) $(cmp_module_LDADD) $(LIBS)
+tests/cmp_test_module-cmp_test.$(OBJEXT): tests/$(am__dirstamp) \
+ tests/$(DEPDIR)/$(am__dirstamp)
+
+cmp_test.module$(EXEEXT): $(cmp_test_module_OBJECTS) $(cmp_test_module_DEPENDENCIES) $(EXTRA_cmp_test_module_DEPENDENCIES)
+ @rm -f cmp_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(cmp_test_module_LINK) $(cmp_test_module_OBJECTS) $(cmp_test_module_LDADD) $(LIBS)
+commands/configfile_module-configfile.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+configfile.module$(EXEEXT): $(configfile_module_OBJECTS) $(configfile_module_DEPENDENCIES) $(EXTRA_configfile_module_DEPENDENCIES)
+ @rm -f configfile.module$(EXEEXT)
+ $(AM_V_CCLD)$(configfile_module_LINK) $(configfile_module_OBJECTS) $(configfile_module_LDADD) $(LIBS)
+fs/cpio_module-cpio.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+cpio.module$(EXEEXT): $(cpio_module_OBJECTS) $(cpio_module_DEPENDENCIES) $(EXTRA_cpio_module_DEPENDENCIES)
+ @rm -f cpio.module$(EXEEXT)
+ $(AM_V_CCLD)$(cpio_module_LINK) $(cpio_module_OBJECTS) $(cpio_module_LDADD) $(LIBS)
+fs/cpio_be_module-cpio_be.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+cpio_be.module$(EXEEXT): $(cpio_be_module_OBJECTS) $(cpio_be_module_DEPENDENCIES) $(EXTRA_cpio_be_module_DEPENDENCIES)
+ @rm -f cpio_be.module$(EXEEXT)
+ $(AM_V_CCLD)$(cpio_be_module_LINK) $(cpio_be_module_OBJECTS) $(cpio_be_module_LDADD) $(LIBS)
+commands/i386/cpuid_module-cpuid.$(OBJEXT): \
+ commands/i386/$(am__dirstamp) \
+ commands/i386/$(DEPDIR)/$(am__dirstamp)
+
+cpuid.module$(EXEEXT): $(cpuid_module_OBJECTS) $(cpuid_module_DEPENDENCIES) $(EXTRA_cpuid_module_DEPENDENCIES)
+ @rm -f cpuid.module$(EXEEXT)
+ $(AM_V_CCLD)$(cpuid_module_LINK) $(cpuid_module_OBJECTS) $(cpuid_module_LDADD) $(LIBS)
+lib/crc64_module-crc64.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+crc64.module$(EXEEXT): $(crc64_module_OBJECTS) $(crc64_module_DEPENDENCIES) $(EXTRA_crc64_module_DEPENDENCIES)
+ @rm -f crc64.module$(EXEEXT)
+ $(AM_V_CCLD)$(crc64_module_LINK) $(crc64_module_OBJECTS) $(crc64_module_LDADD) $(LIBS)
+lib/crypto_module-crypto.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+crypto.module$(EXEEXT): $(crypto_module_OBJECTS) $(crypto_module_DEPENDENCIES) $(EXTRA_crypto_module_DEPENDENCIES)
+ @rm -f crypto.module$(EXEEXT)
+ $(AM_V_CCLD)$(crypto_module_LINK) $(crypto_module_OBJECTS) $(crypto_module_LDADD) $(LIBS)
+disk/cryptodisk_module-cryptodisk.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+cryptodisk.module$(EXEEXT): $(cryptodisk_module_OBJECTS) $(cryptodisk_module_DEPENDENCIES) $(EXTRA_cryptodisk_module_DEPENDENCIES)
+ @rm -f cryptodisk.module$(EXEEXT)
+ $(AM_V_CCLD)$(cryptodisk_module_LINK) $(cryptodisk_module_OBJECTS) $(cryptodisk_module_LDADD) $(LIBS)
+bus/$(am__dirstamp):
+ @$(MKDIR_P) bus
+ @: > bus/$(am__dirstamp)
+bus/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) bus/$(DEPDIR)
+ @: > bus/$(DEPDIR)/$(am__dirstamp)
+bus/cs5536_module-cs5536.$(OBJEXT): bus/$(am__dirstamp) \
+ bus/$(DEPDIR)/$(am__dirstamp)
+
+cs5536.module$(EXEEXT): $(cs5536_module_OBJECTS) $(cs5536_module_DEPENDENCIES) $(EXTRA_cs5536_module_DEPENDENCIES)
+ @rm -f cs5536.module$(EXEEXT)
+ $(AM_V_CCLD)$(cs5536_module_LINK) $(cs5536_module_OBJECTS) $(cs5536_module_LDADD) $(LIBS)
+tests/ctz_test_module-ctz_test.$(OBJEXT): tests/$(am__dirstamp) \
+ tests/$(DEPDIR)/$(am__dirstamp)
+
+ctz_test.module$(EXEEXT): $(ctz_test_module_OBJECTS) $(ctz_test_module_DEPENDENCIES) $(EXTRA_ctz_test_module_DEPENDENCIES)
+ @rm -f ctz_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(ctz_test_module_LINK) $(ctz_test_module_OBJECTS) $(ctz_test_module_LDADD) $(LIBS)
+commands/date_module-date.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+date.module$(EXEEXT): $(date_module_OBJECTS) $(date_module_DEPENDENCIES) $(EXTRA_date_module_DEPENDENCIES)
+ @rm -f date.module$(EXEEXT)
+ $(AM_V_CCLD)$(date_module_LINK) $(date_module_OBJECTS) $(date_module_LDADD) $(LIBS)
+hook/$(am__dirstamp):
+ @$(MKDIR_P) hook
+ @: > hook/$(am__dirstamp)
+hook/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) hook/$(DEPDIR)
+ @: > hook/$(DEPDIR)/$(am__dirstamp)
+hook/datehook_module-datehook.$(OBJEXT): hook/$(am__dirstamp) \
+ hook/$(DEPDIR)/$(am__dirstamp)
+
+datehook.module$(EXEEXT): $(datehook_module_OBJECTS) $(datehook_module_DEPENDENCIES) $(EXTRA_datehook_module_DEPENDENCIES)
+ @rm -f datehook.module$(EXEEXT)
+ $(AM_V_CCLD)$(datehook_module_LINK) $(datehook_module_OBJECTS) $(datehook_module_LDADD) $(LIBS)
+lib/efi/$(am__dirstamp):
+ @$(MKDIR_P) lib/efi
+ @: > lib/efi/$(am__dirstamp)
+lib/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/efi/$(DEPDIR)
+ @: > lib/efi/$(DEPDIR)/$(am__dirstamp)
+lib/efi/datetime_module-datetime.$(OBJEXT): lib/efi/$(am__dirstamp) \
+ lib/efi/$(DEPDIR)/$(am__dirstamp)
+lib/datetime_module-datetime.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+lib/dummy/$(am__dirstamp):
+ @$(MKDIR_P) lib/dummy
+ @: > lib/dummy/$(am__dirstamp)
+lib/dummy/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/dummy/$(DEPDIR)
+ @: > lib/dummy/$(DEPDIR)/$(am__dirstamp)
+lib/dummy/datetime_module-datetime.$(OBJEXT): \
+ lib/dummy/$(am__dirstamp) lib/dummy/$(DEPDIR)/$(am__dirstamp)
+lib/datetime_module-cmos_datetime.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+lib/xen/$(am__dirstamp):
+ @$(MKDIR_P) lib/xen
+ @: > lib/xen/$(am__dirstamp)
+lib/xen/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/xen/$(DEPDIR)
+ @: > lib/xen/$(DEPDIR)/$(am__dirstamp)
+lib/xen/datetime_module-datetime.$(OBJEXT): lib/xen/$(am__dirstamp) \
+ lib/xen/$(DEPDIR)/$(am__dirstamp)
+lib/arc/$(am__dirstamp):
+ @$(MKDIR_P) lib/arc
+ @: > lib/arc/$(am__dirstamp)
+lib/arc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/arc/$(DEPDIR)
+ @: > lib/arc/$(DEPDIR)/$(am__dirstamp)
+lib/arc/datetime_module-datetime.$(OBJEXT): lib/arc/$(am__dirstamp) \
+ lib/arc/$(DEPDIR)/$(am__dirstamp)
+lib/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) lib/ieee1275
+ @: > lib/ieee1275/$(am__dirstamp)
+lib/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/ieee1275/$(DEPDIR)
+ @: > lib/ieee1275/$(DEPDIR)/$(am__dirstamp)
+lib/ieee1275/datetime_module-datetime.$(OBJEXT): \
+ lib/ieee1275/$(am__dirstamp) \
+ lib/ieee1275/$(DEPDIR)/$(am__dirstamp)
+lib/ieee1275/datetime_module-cmos.$(OBJEXT): \
+ lib/ieee1275/$(am__dirstamp) \
+ lib/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+datetime.module$(EXEEXT): $(datetime_module_OBJECTS) $(datetime_module_DEPENDENCIES) $(EXTRA_datetime_module_DEPENDENCIES)
+ @rm -f datetime.module$(EXEEXT)
+ $(AM_V_CCLD)$(datetime_module_LINK) $(datetime_module_OBJECTS) $(datetime_module_LDADD) $(LIBS)
+lib/disk_module-disk.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+disk.module$(EXEEXT): $(disk_module_OBJECTS) $(disk_module_DEPENDENCIES) $(EXTRA_disk_module_DEPENDENCIES)
+ @rm -f disk.module$(EXEEXT)
+ $(AM_V_CCLD)$(disk_module_LINK) $(disk_module_OBJECTS) $(disk_module_LDADD) $(LIBS)
+boot/i386/pc/diskboot_image-diskboot.$(OBJEXT): \
+ boot/i386/pc/$(am__dirstamp) \
+ boot/i386/pc/$(DEPDIR)/$(am__dirstamp)
+boot/sparc64/ieee1275/diskboot_image-diskboot.$(OBJEXT): \
+ boot/sparc64/ieee1275/$(am__dirstamp) \
+ boot/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+diskboot.image$(EXEEXT): $(diskboot_image_OBJECTS) $(diskboot_image_DEPENDENCIES) $(EXTRA_diskboot_image_DEPENDENCIES)
+ @rm -f diskboot.image$(EXEEXT)
+ $(AM_V_CCLD)$(diskboot_image_LINK) $(diskboot_image_OBJECTS) $(diskboot_image_LDADD) $(LIBS)
+disk/diskfilter_module-diskfilter.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+diskfilter.module$(EXEEXT): $(diskfilter_module_OBJECTS) $(diskfilter_module_DEPENDENCIES) $(EXTRA_diskfilter_module_DEPENDENCIES)
+ @rm -f diskfilter.module$(EXEEXT)
+ $(AM_V_CCLD)$(diskfilter_module_LINK) $(diskfilter_module_OBJECTS) $(diskfilter_module_LDADD) $(LIBS)
+lib/div_module-division.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+div.module$(EXEEXT): $(div_module_OBJECTS) $(div_module_DEPENDENCIES) $(EXTRA_div_module_DEPENDENCIES)
+ @rm -f div.module$(EXEEXT)
+ $(AM_V_CCLD)$(div_module_LINK) $(div_module_OBJECTS) $(div_module_LDADD) $(LIBS)
+tests/div_test_module-div_test.$(OBJEXT): tests/$(am__dirstamp) \
+ tests/$(DEPDIR)/$(am__dirstamp)
+
+div_test.module$(EXEEXT): $(div_test_module_OBJECTS) $(div_test_module_DEPENDENCIES) $(EXTRA_div_test_module_DEPENDENCIES)
+ @rm -f div_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(div_test_module_LINK) $(div_test_module_OBJECTS) $(div_test_module_LDADD) $(LIBS)
+disk/dm_nv_module-dmraid_nvidia.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+dm_nv.module$(EXEEXT): $(dm_nv_module_OBJECTS) $(dm_nv_module_DEPENDENCIES) $(EXTRA_dm_nv_module_DEPENDENCIES)
+ @rm -f dm_nv.module$(EXEEXT)
+ $(AM_V_CCLD)$(dm_nv_module_LINK) $(dm_nv_module_OBJECTS) $(dm_nv_module_LDADD) $(LIBS)
+commands/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) commands/i386/pc
+ @: > commands/i386/pc/$(am__dirstamp)
+commands/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) commands/i386/pc/$(DEPDIR)
+ @: > commands/i386/pc/$(DEPDIR)/$(am__dirstamp)
+commands/i386/pc/drivemap_module-drivemap.$(OBJEXT): \
+ commands/i386/pc/$(am__dirstamp) \
+ commands/i386/pc/$(DEPDIR)/$(am__dirstamp)
+commands/i386/pc/drivemap_module-drivemap_int13h.$(OBJEXT): \
+ commands/i386/pc/$(am__dirstamp) \
+ commands/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+drivemap.module$(EXEEXT): $(drivemap_module_OBJECTS) $(drivemap_module_DEPENDENCIES) $(EXTRA_drivemap_module_DEPENDENCIES)
+ @rm -f drivemap.module$(EXEEXT)
+ $(AM_V_CCLD)$(drivemap_module_LINK) $(drivemap_module_OBJECTS) $(drivemap_module_LDADD) $(LIBS)
+commands/echo_module-echo.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+echo.module$(EXEEXT): $(echo_module_OBJECTS) $(echo_module_DEPENDENCIES) $(EXTRA_echo_module_DEPENDENCIES)
+ @rm -f echo.module$(EXEEXT)
+ $(AM_V_CCLD)$(echo_module_LINK) $(echo_module_OBJECTS) $(echo_module_LDADD) $(LIBS)
+video/efi_gop_module-efi_gop.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+
+efi_gop.module$(EXEEXT): $(efi_gop_module_OBJECTS) $(efi_gop_module_DEPENDENCIES) $(EXTRA_efi_gop_module_DEPENDENCIES)
+ @rm -f efi_gop.module$(EXEEXT)
+ $(AM_V_CCLD)$(efi_gop_module_LINK) $(efi_gop_module_OBJECTS) $(efi_gop_module_LDADD) $(LIBS)
+video/efi_uga_module-efi_uga.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+
+efi_uga.module$(EXEEXT): $(efi_uga_module_OBJECTS) $(efi_uga_module_DEPENDENCIES) $(EXTRA_efi_uga_module_DEPENDENCIES)
+ @rm -f efi_uga.module$(EXEEXT)
+ $(AM_V_CCLD)$(efi_uga_module_LINK) $(efi_uga_module_OBJECTS) $(efi_uga_module_LDADD) $(LIBS)
+efiemu/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) efiemu/i386/pc
+ @: > efiemu/i386/pc/$(am__dirstamp)
+efiemu/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) efiemu/i386/pc/$(DEPDIR)
+ @: > efiemu/i386/pc/$(DEPDIR)/$(am__dirstamp)
+efiemu/i386/pc/efiemu_module-cfgtables.$(OBJEXT): \
+ efiemu/i386/pc/$(am__dirstamp) \
+ efiemu/i386/pc/$(DEPDIR)/$(am__dirstamp)
+efiemu/$(am__dirstamp):
+ @$(MKDIR_P) efiemu
+ @: > efiemu/$(am__dirstamp)
+efiemu/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) efiemu/$(DEPDIR)
+ @: > efiemu/$(DEPDIR)/$(am__dirstamp)
+efiemu/efiemu_module-main.$(OBJEXT): efiemu/$(am__dirstamp) \
+ efiemu/$(DEPDIR)/$(am__dirstamp)
+efiemu/i386/$(am__dirstamp):
+ @$(MKDIR_P) efiemu/i386
+ @: > efiemu/i386/$(am__dirstamp)
+efiemu/i386/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) efiemu/i386/$(DEPDIR)
+ @: > efiemu/i386/$(DEPDIR)/$(am__dirstamp)
+efiemu/i386/efiemu_module-loadcore32.$(OBJEXT): \
+ efiemu/i386/$(am__dirstamp) \
+ efiemu/i386/$(DEPDIR)/$(am__dirstamp)
+efiemu/i386/efiemu_module-loadcore64.$(OBJEXT): \
+ efiemu/i386/$(am__dirstamp) \
+ efiemu/i386/$(DEPDIR)/$(am__dirstamp)
+efiemu/efiemu_module-mm.$(OBJEXT): efiemu/$(am__dirstamp) \
+ efiemu/$(DEPDIR)/$(am__dirstamp)
+efiemu/efiemu_module-loadcore_common.$(OBJEXT): \
+ efiemu/$(am__dirstamp) efiemu/$(DEPDIR)/$(am__dirstamp)
+efiemu/efiemu_module-symbols.$(OBJEXT): efiemu/$(am__dirstamp) \
+ efiemu/$(DEPDIR)/$(am__dirstamp)
+efiemu/efiemu_module-loadcore32.$(OBJEXT): efiemu/$(am__dirstamp) \
+ efiemu/$(DEPDIR)/$(am__dirstamp)
+efiemu/efiemu_module-loadcore64.$(OBJEXT): efiemu/$(am__dirstamp) \
+ efiemu/$(DEPDIR)/$(am__dirstamp)
+efiemu/efiemu_module-prepare32.$(OBJEXT): efiemu/$(am__dirstamp) \
+ efiemu/$(DEPDIR)/$(am__dirstamp)
+efiemu/efiemu_module-prepare64.$(OBJEXT): efiemu/$(am__dirstamp) \
+ efiemu/$(DEPDIR)/$(am__dirstamp)
+efiemu/efiemu_module-pnvram.$(OBJEXT): efiemu/$(am__dirstamp) \
+ efiemu/$(DEPDIR)/$(am__dirstamp)
+efiemu/i386/efiemu_module-coredetect.$(OBJEXT): \
+ efiemu/i386/$(am__dirstamp) \
+ efiemu/i386/$(DEPDIR)/$(am__dirstamp)
+efiemu/i386/efiemu_module-nocfgtables.$(OBJEXT): \
+ efiemu/i386/$(am__dirstamp) \
+ efiemu/i386/$(DEPDIR)/$(am__dirstamp)
+
+efiemu.module$(EXEEXT): $(efiemu_module_OBJECTS) $(efiemu_module_DEPENDENCIES) $(EXTRA_efiemu_module_DEPENDENCIES)
+ @rm -f efiemu.module$(EXEEXT)
+ $(AM_V_CCLD)$(efiemu_module_LINK) $(efiemu_module_OBJECTS) $(efiemu_module_LDADD) $(LIBS)
+commands/efi/$(am__dirstamp):
+ @$(MKDIR_P) commands/efi
+ @: > commands/efi/$(am__dirstamp)
+commands/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) commands/efi/$(DEPDIR)
+ @: > commands/efi/$(DEPDIR)/$(am__dirstamp)
+commands/efi/efifwsetup_module-efifwsetup.$(OBJEXT): \
+ commands/efi/$(am__dirstamp) \
+ commands/efi/$(DEPDIR)/$(am__dirstamp)
+
+efifwsetup.module$(EXEEXT): $(efifwsetup_module_OBJECTS) $(efifwsetup_module_DEPENDENCIES) $(EXTRA_efifwsetup_module_DEPENDENCIES)
+ @rm -f efifwsetup.module$(EXEEXT)
+ $(AM_V_CCLD)$(efifwsetup_module_LINK) $(efifwsetup_module_OBJECTS) $(efifwsetup_module_LDADD) $(LIBS)
+net/drivers/efi/$(am__dirstamp):
+ @$(MKDIR_P) net/drivers/efi
+ @: > net/drivers/efi/$(am__dirstamp)
+net/drivers/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) net/drivers/efi/$(DEPDIR)
+ @: > net/drivers/efi/$(DEPDIR)/$(am__dirstamp)
+net/drivers/efi/efinet_module-efinet.$(OBJEXT): \
+ net/drivers/efi/$(am__dirstamp) \
+ net/drivers/efi/$(DEPDIR)/$(am__dirstamp)
+
+efinet.module$(EXEEXT): $(efinet_module_OBJECTS) $(efinet_module_DEPENDENCIES) $(EXTRA_efinet_module_DEPENDENCIES)
+ @rm -f efinet.module$(EXEEXT)
+ $(AM_V_CCLD)$(efinet_module_LINK) $(efinet_module_OBJECTS) $(efinet_module_LDADD) $(LIBS)
+bus/usb/$(am__dirstamp):
+ @$(MKDIR_P) bus/usb
+ @: > bus/usb/$(am__dirstamp)
+bus/usb/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) bus/usb/$(DEPDIR)
+ @: > bus/usb/$(DEPDIR)/$(am__dirstamp)
+bus/usb/ehci_module-ehci-fdt.$(OBJEXT): bus/usb/$(am__dirstamp) \
+ bus/usb/$(DEPDIR)/$(am__dirstamp)
+bus/usb/ehci_module-ehci.$(OBJEXT): bus/usb/$(am__dirstamp) \
+ bus/usb/$(DEPDIR)/$(am__dirstamp)
+bus/usb/ehci_module-ehci-pci.$(OBJEXT): bus/usb/$(am__dirstamp) \
+ bus/usb/$(DEPDIR)/$(am__dirstamp)
+
+ehci.module$(EXEEXT): $(ehci_module_OBJECTS) $(ehci_module_DEPENDENCIES) $(EXTRA_ehci_module_DEPENDENCIES)
+ @rm -f ehci.module$(EXEEXT)
+ $(AM_V_CCLD)$(ehci_module_LINK) $(ehci_module_OBJECTS) $(ehci_module_LDADD) $(LIBS)
+kern/elf_module-elf.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+
+elf.module$(EXEEXT): $(elf_module_OBJECTS) $(elf_module_DEPENDENCIES) $(EXTRA_elf_module_DEPENDENCIES)
+ @rm -f elf.module$(EXEEXT)
+ $(AM_V_CCLD)$(elf_module_LINK) $(elf_module_OBJECTS) $(elf_module_LDADD) $(LIBS)
+net/drivers/emu/$(am__dirstamp):
+ @$(MKDIR_P) net/drivers/emu
+ @: > net/drivers/emu/$(am__dirstamp)
+net/drivers/emu/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) net/drivers/emu/$(DEPDIR)
+ @: > net/drivers/emu/$(DEPDIR)/$(am__dirstamp)
+net/drivers/emu/emunet_module-emunet.$(OBJEXT): \
+ net/drivers/emu/$(am__dirstamp) \
+ net/drivers/emu/$(DEPDIR)/$(am__dirstamp)
+
+emunet.module$(EXEEXT): $(emunet_module_OBJECTS) $(emunet_module_DEPENDENCIES) $(EXTRA_emunet_module_DEPENDENCIES)
+ @rm -f emunet.module$(EXEEXT)
+ $(AM_V_CCLD)$(emunet_module_LINK) $(emunet_module_OBJECTS) $(emunet_module_LDADD) $(LIBS)
+bus/emu/$(am__dirstamp):
+ @$(MKDIR_P) bus/emu
+ @: > bus/emu/$(am__dirstamp)
+bus/emu/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) bus/emu/$(DEPDIR)
+ @: > bus/emu/$(DEPDIR)/$(am__dirstamp)
+bus/emu/emupci_module-pci.$(OBJEXT): bus/emu/$(am__dirstamp) \
+ bus/emu/$(DEPDIR)/$(am__dirstamp)
+commands/emupci_module-lspci.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+emupci.module$(EXEEXT): $(emupci_module_OBJECTS) $(emupci_module_DEPENDENCIES) $(EXTRA_emupci_module_DEPENDENCIES)
+ @rm -f emupci.module$(EXEEXT)
+ $(AM_V_CCLD)$(emupci_module_LINK) $(emupci_module_OBJECTS) $(emupci_module_LDADD) $(LIBS)
+term/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) term/ieee1275
+ @: > term/ieee1275/$(am__dirstamp)
+term/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) term/ieee1275/$(DEPDIR)
+ @: > term/ieee1275/$(DEPDIR)/$(am__dirstamp)
+term/ieee1275/escc_module-escc.$(OBJEXT): \
+ term/ieee1275/$(am__dirstamp) \
+ term/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+escc.module$(EXEEXT): $(escc_module_OBJECTS) $(escc_module_DEPENDENCIES) $(EXTRA_escc_module_DEPENDENCIES)
+ @rm -f escc.module$(EXEEXT)
+ $(AM_V_CCLD)$(escc_module_LINK) $(escc_module_OBJECTS) $(escc_module_LDADD) $(LIBS)
+commands/eval_module-eval.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+eval.module$(EXEEXT): $(eval_module_OBJECTS) $(eval_module_DEPENDENCIES) $(EXTRA_eval_module_DEPENDENCIES)
+ @rm -f eval.module$(EXEEXT)
+ $(AM_V_CCLD)$(eval_module_LINK) $(eval_module_OBJECTS) $(eval_module_LDADD) $(LIBS)
+fs/exfat_module-exfat.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+exfat.module$(EXEEXT): $(exfat_module_OBJECTS) $(exfat_module_DEPENDENCIES) $(EXTRA_exfat_module_DEPENDENCIES)
+ @rm -f exfat.module$(EXEEXT)
+ $(AM_V_CCLD)$(exfat_module_LINK) $(exfat_module_OBJECTS) $(exfat_module_LDADD) $(LIBS)
+tests/exfctest_module-example_functional_test.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+
+exfctest.module$(EXEEXT): $(exfctest_module_OBJECTS) $(exfctest_module_DEPENDENCIES) $(EXTRA_exfctest_module_DEPENDENCIES)
+ @rm -f exfctest.module$(EXEEXT)
+ $(AM_V_CCLD)$(exfctest_module_LINK) $(exfctest_module_OBJECTS) $(exfctest_module_LDADD) $(LIBS)
+fs/ext2_module-ext2.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+ext2.module$(EXEEXT): $(ext2_module_OBJECTS) $(ext2_module_DEPENDENCIES) $(EXTRA_ext2_module_DEPENDENCIES)
+ @rm -f ext2.module$(EXEEXT)
+ $(AM_V_CCLD)$(ext2_module_LINK) $(ext2_module_OBJECTS) $(ext2_module_LDADD) $(LIBS)
+commands/extcmd_module-extcmd.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+lib/extcmd_module-arg.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+extcmd.module$(EXEEXT): $(extcmd_module_OBJECTS) $(extcmd_module_DEPENDENCIES) $(EXTRA_extcmd_module_DEPENDENCIES)
+ @rm -f extcmd.module$(EXEEXT)
+ $(AM_V_CCLD)$(extcmd_module_LINK) $(extcmd_module_OBJECTS) $(extcmd_module_LDADD) $(LIBS)
+fs/f2fs_module-f2fs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+f2fs.module$(EXEEXT): $(f2fs_module_OBJECTS) $(f2fs_module_DEPENDENCIES) $(EXTRA_f2fs_module_DEPENDENCIES)
+ @rm -f f2fs.module$(EXEEXT)
+ $(AM_V_CCLD)$(f2fs_module_LINK) $(f2fs_module_OBJECTS) $(f2fs_module_LDADD) $(LIBS)
+fs/fat_module-fat.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+fat.module$(EXEEXT): $(fat_module_OBJECTS) $(fat_module_DEPENDENCIES) $(EXTRA_fat_module_DEPENDENCIES)
+ @rm -f fat.module$(EXEEXT)
+ $(AM_V_CCLD)$(fat_module_LINK) $(fat_module_OBJECTS) $(fat_module_LDADD) $(LIBS)
+loader/efi/fdt_module-fdt.$(OBJEXT): loader/efi/$(am__dirstamp) \
+ loader/efi/$(DEPDIR)/$(am__dirstamp)
+lib/fdt_module-fdt.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+fdt.module$(EXEEXT): $(fdt_module_OBJECTS) $(fdt_module_DEPENDENCIES) $(EXTRA_fdt_module_DEPENDENCIES)
+ @rm -f fdt.module$(EXEEXT)
+ $(AM_V_CCLD)$(fdt_module_LINK) $(fdt_module_OBJECTS) $(fdt_module_LDADD) $(LIBS)
+commands/file_module-file.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+commands/file_module-file32.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+commands/file_module-file64.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+loader/i386/file_module-xen_file.$(OBJEXT): \
+ loader/i386/$(am__dirstamp) \
+ loader/i386/$(DEPDIR)/$(am__dirstamp)
+loader/i386/file_module-xen_file32.$(OBJEXT): \
+ loader/i386/$(am__dirstamp) \
+ loader/i386/$(DEPDIR)/$(am__dirstamp)
+loader/i386/file_module-xen_file64.$(OBJEXT): \
+ loader/i386/$(am__dirstamp) \
+ loader/i386/$(DEPDIR)/$(am__dirstamp)
+
+file.module$(EXEEXT): $(file_module_OBJECTS) $(file_module_DEPENDENCIES) $(EXTRA_file_module_DEPENDENCIES)
+ @rm -f file.module$(EXEEXT)
+ $(AM_V_CCLD)$(file_module_LINK) $(file_module_OBJECTS) $(file_module_LDADD) $(LIBS)
+commands/efi/fixvideo_module-fixvideo.$(OBJEXT): \
+ commands/efi/$(am__dirstamp) \
+ commands/efi/$(DEPDIR)/$(am__dirstamp)
+
+fixvideo.module$(EXEEXT): $(fixvideo_module_OBJECTS) $(fixvideo_module_DEPENDENCIES) $(EXTRA_fixvideo_module_DEPENDENCIES)
+ @rm -f fixvideo.module$(EXEEXT)
+ $(AM_V_CCLD)$(fixvideo_module_LINK) $(fixvideo_module_OBJECTS) $(fixvideo_module_LDADD) $(LIBS)
+font/$(am__dirstamp):
+ @$(MKDIR_P) font
+ @: > font/$(am__dirstamp)
+font/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) font/$(DEPDIR)
+ @: > font/$(DEPDIR)/$(am__dirstamp)
+font/font_module-font.$(OBJEXT): font/$(am__dirstamp) \
+ font/$(DEPDIR)/$(am__dirstamp)
+font/font_module-font_cmd.$(OBJEXT): font/$(am__dirstamp) \
+ font/$(DEPDIR)/$(am__dirstamp)
+
+font.module$(EXEEXT): $(font_module_OBJECTS) $(font_module_DEPENDENCIES) $(EXTRA_font_module_DEPENDENCIES)
+ @rm -f font.module$(EXEEXT)
+ $(AM_V_CCLD)$(font_module_LINK) $(font_module_OBJECTS) $(font_module_LDADD) $(LIBS)
+loader/i386/pc/freedos_module-freedos.$(OBJEXT): \
+ loader/i386/pc/$(am__dirstamp) \
+ loader/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+freedos.module$(EXEEXT): $(freedos_module_OBJECTS) $(freedos_module_DEPENDENCIES) $(EXTRA_freedos_module_DEPENDENCIES)
+ @rm -f freedos.module$(EXEEXT)
+ $(AM_V_CCLD)$(freedos_module_LINK) $(freedos_module_OBJECTS) $(freedos_module_LDADD) $(LIBS)
+fs/fshelp_module-fshelp.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+fshelp.module$(EXEEXT): $(fshelp_module_OBJECTS) $(fshelp_module_DEPENDENCIES) $(EXTRA_fshelp_module_DEPENDENCIES)
+ @rm -f fshelp.module$(EXEEXT)
+ $(AM_V_CCLD)$(fshelp_module_LINK) $(fshelp_module_OBJECTS) $(fshelp_module_LDADD) $(LIBS)
+tests/lib/$(am__dirstamp):
+ @$(MKDIR_P) tests/lib
+ @: > tests/lib/$(am__dirstamp)
+tests/lib/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) tests/lib/$(DEPDIR)
+ @: > tests/lib/$(DEPDIR)/$(am__dirstamp)
+tests/lib/functional_test_module-functional_test.$(OBJEXT): \
+ tests/lib/$(am__dirstamp) tests/lib/$(DEPDIR)/$(am__dirstamp)
+tests/lib/functional_test_module-test.$(OBJEXT): \
+ tests/lib/$(am__dirstamp) tests/lib/$(DEPDIR)/$(am__dirstamp)
+tests/functional_test_module-video_checksum.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+tests/functional_test_module-fake_input.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+video/functional_test_module-capture.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+
+functional_test.module$(EXEEXT): $(functional_test_module_OBJECTS) $(functional_test_module_DEPENDENCIES) $(EXTRA_functional_test_module_DEPENDENCIES)
+ @rm -f functional_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(functional_test_module_LINK) $(functional_test_module_OBJECTS) $(functional_test_module_LDADD) $(LIBS)
+boot/mips/loongson/$(am__dirstamp):
+ @$(MKDIR_P) boot/mips/loongson
+ @: > boot/mips/loongson/$(am__dirstamp)
+boot/mips/loongson/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) boot/mips/loongson/$(DEPDIR)
+ @: > boot/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+boot/mips/loongson/fwstart_image-fwstart.$(OBJEXT): \
+ boot/mips/loongson/$(am__dirstamp) \
+ boot/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+
+fwstart.image$(EXEEXT): $(fwstart_image_OBJECTS) $(fwstart_image_DEPENDENCIES) $(EXTRA_fwstart_image_DEPENDENCIES)
+ @rm -f fwstart.image$(EXEEXT)
+ $(AM_V_CCLD)$(fwstart_image_LINK) $(fwstart_image_OBJECTS) $(fwstart_image_LDADD) $(LIBS)
+boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.$(OBJEXT): \
+ boot/mips/loongson/$(am__dirstamp) \
+ boot/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+
+fwstart_fuloong2f.image$(EXEEXT): $(fwstart_fuloong2f_image_OBJECTS) $(fwstart_fuloong2f_image_DEPENDENCIES) $(EXTRA_fwstart_fuloong2f_image_DEPENDENCIES)
+ @rm -f fwstart_fuloong2f.image$(EXEEXT)
+ $(AM_V_CCLD)$(fwstart_fuloong2f_image_LINK) $(fwstart_fuloong2f_image_OBJECTS) $(fwstart_fuloong2f_image_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/$(am__dirstamp):
+ @$(MKDIR_P) lib/libgcrypt-grub/cipher
+ @: > lib/libgcrypt-grub/cipher/$(am__dirstamp)
+lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/libgcrypt-grub/cipher/$(DEPDIR)
+ @: > lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_arcfour.module$(EXEEXT): $(gcry_arcfour_module_OBJECTS) $(gcry_arcfour_module_DEPENDENCIES) $(EXTRA_gcry_arcfour_module_DEPENDENCIES)
+ @rm -f gcry_arcfour.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_arcfour_module_LINK) $(gcry_arcfour_module_OBJECTS) $(gcry_arcfour_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_blowfish.module$(EXEEXT): $(gcry_blowfish_module_OBJECTS) $(gcry_blowfish_module_DEPENDENCIES) $(EXTRA_gcry_blowfish_module_DEPENDENCIES)
+ @rm -f gcry_blowfish.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_blowfish_module_LINK) $(gcry_blowfish_module_OBJECTS) $(gcry_blowfish_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_camellia.module$(EXEEXT): $(gcry_camellia_module_OBJECTS) $(gcry_camellia_module_DEPENDENCIES) $(EXTRA_gcry_camellia_module_DEPENDENCIES)
+ @rm -f gcry_camellia.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_camellia_module_LINK) $(gcry_camellia_module_OBJECTS) $(gcry_camellia_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_cast5.module$(EXEEXT): $(gcry_cast5_module_OBJECTS) $(gcry_cast5_module_DEPENDENCIES) $(EXTRA_gcry_cast5_module_DEPENDENCIES)
+ @rm -f gcry_cast5.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_cast5_module_LINK) $(gcry_cast5_module_OBJECTS) $(gcry_cast5_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_crc_module-crc.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_crc.module$(EXEEXT): $(gcry_crc_module_OBJECTS) $(gcry_crc_module_DEPENDENCIES) $(EXTRA_gcry_crc_module_DEPENDENCIES)
+ @rm -f gcry_crc.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_crc_module_LINK) $(gcry_crc_module_OBJECTS) $(gcry_crc_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_des_module-des.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_des.module$(EXEEXT): $(gcry_des_module_OBJECTS) $(gcry_des_module_DEPENDENCIES) $(EXTRA_gcry_des_module_DEPENDENCIES)
+ @rm -f gcry_des.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_des_module_LINK) $(gcry_des_module_OBJECTS) $(gcry_des_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_dsa.module$(EXEEXT): $(gcry_dsa_module_OBJECTS) $(gcry_dsa_module_DEPENDENCIES) $(EXTRA_gcry_dsa_module_DEPENDENCIES)
+ @rm -f gcry_dsa.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_dsa_module_LINK) $(gcry_dsa_module_OBJECTS) $(gcry_dsa_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_idea_module-idea.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_idea.module$(EXEEXT): $(gcry_idea_module_OBJECTS) $(gcry_idea_module_DEPENDENCIES) $(EXTRA_gcry_idea_module_DEPENDENCIES)
+ @rm -f gcry_idea.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_idea_module_LINK) $(gcry_idea_module_OBJECTS) $(gcry_idea_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_md4_module-md4.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_md4.module$(EXEEXT): $(gcry_md4_module_OBJECTS) $(gcry_md4_module_DEPENDENCIES) $(EXTRA_gcry_md4_module_DEPENDENCIES)
+ @rm -f gcry_md4.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_md4_module_LINK) $(gcry_md4_module_OBJECTS) $(gcry_md4_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_md5_module-md5.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_md5.module$(EXEEXT): $(gcry_md5_module_OBJECTS) $(gcry_md5_module_DEPENDENCIES) $(EXTRA_gcry_md5_module_DEPENDENCIES)
+ @rm -f gcry_md5.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_md5_module_LINK) $(gcry_md5_module_OBJECTS) $(gcry_md5_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_rfc2268.module$(EXEEXT): $(gcry_rfc2268_module_OBJECTS) $(gcry_rfc2268_module_DEPENDENCIES) $(EXTRA_gcry_rfc2268_module_DEPENDENCIES)
+ @rm -f gcry_rfc2268.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_rfc2268_module_LINK) $(gcry_rfc2268_module_OBJECTS) $(gcry_rfc2268_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_rijndael.module$(EXEEXT): $(gcry_rijndael_module_OBJECTS) $(gcry_rijndael_module_DEPENDENCIES) $(EXTRA_gcry_rijndael_module_DEPENDENCIES)
+ @rm -f gcry_rijndael.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_rijndael_module_LINK) $(gcry_rijndael_module_OBJECTS) $(gcry_rijndael_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_rmd160.module$(EXEEXT): $(gcry_rmd160_module_OBJECTS) $(gcry_rmd160_module_DEPENDENCIES) $(EXTRA_gcry_rmd160_module_DEPENDENCIES)
+ @rm -f gcry_rmd160.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_rmd160_module_LINK) $(gcry_rmd160_module_OBJECTS) $(gcry_rmd160_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_rsa.module$(EXEEXT): $(gcry_rsa_module_OBJECTS) $(gcry_rsa_module_DEPENDENCIES) $(EXTRA_gcry_rsa_module_DEPENDENCIES)
+ @rm -f gcry_rsa.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_rsa_module_LINK) $(gcry_rsa_module_OBJECTS) $(gcry_rsa_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_seed_module-seed.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_seed.module$(EXEEXT): $(gcry_seed_module_OBJECTS) $(gcry_seed_module_DEPENDENCIES) $(EXTRA_gcry_seed_module_DEPENDENCIES)
+ @rm -f gcry_seed.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_seed_module_LINK) $(gcry_seed_module_OBJECTS) $(gcry_seed_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_serpent.module$(EXEEXT): $(gcry_serpent_module_OBJECTS) $(gcry_serpent_module_DEPENDENCIES) $(EXTRA_gcry_serpent_module_DEPENDENCIES)
+ @rm -f gcry_serpent.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_serpent_module_LINK) $(gcry_serpent_module_OBJECTS) $(gcry_serpent_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_sha1.module$(EXEEXT): $(gcry_sha1_module_OBJECTS) $(gcry_sha1_module_DEPENDENCIES) $(EXTRA_gcry_sha1_module_DEPENDENCIES)
+ @rm -f gcry_sha1.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_sha1_module_LINK) $(gcry_sha1_module_OBJECTS) $(gcry_sha1_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_sha256.module$(EXEEXT): $(gcry_sha256_module_OBJECTS) $(gcry_sha256_module_DEPENDENCIES) $(EXTRA_gcry_sha256_module_DEPENDENCIES)
+ @rm -f gcry_sha256.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_sha256_module_LINK) $(gcry_sha256_module_OBJECTS) $(gcry_sha256_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_sha512.module$(EXEEXT): $(gcry_sha512_module_OBJECTS) $(gcry_sha512_module_DEPENDENCIES) $(EXTRA_gcry_sha512_module_DEPENDENCIES)
+ @rm -f gcry_sha512.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_sha512_module_LINK) $(gcry_sha512_module_OBJECTS) $(gcry_sha512_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_tiger.module$(EXEEXT): $(gcry_tiger_module_OBJECTS) $(gcry_tiger_module_DEPENDENCIES) $(EXTRA_gcry_tiger_module_DEPENDENCIES)
+ @rm -f gcry_tiger.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_tiger_module_LINK) $(gcry_tiger_module_OBJECTS) $(gcry_tiger_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_twofish.module$(EXEEXT): $(gcry_twofish_module_OBJECTS) $(gcry_twofish_module_DEPENDENCIES) $(EXTRA_gcry_twofish_module_DEPENDENCIES)
+ @rm -f gcry_twofish.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_twofish_module_LINK) $(gcry_twofish_module_OBJECTS) $(gcry_twofish_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.$(OBJEXT): \
+ lib/libgcrypt-grub/cipher/$(am__dirstamp) \
+ lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+
+gcry_whirlpool.module$(EXEEXT): $(gcry_whirlpool_module_OBJECTS) $(gcry_whirlpool_module_DEPENDENCIES) $(EXTRA_gcry_whirlpool_module_DEPENDENCIES)
+ @rm -f gcry_whirlpool.module$(EXEEXT)
+ $(AM_V_CCLD)$(gcry_whirlpool_module_LINK) $(gcry_whirlpool_module_OBJECTS) $(gcry_whirlpool_module_LDADD) $(LIBS)
+gdb/i386/$(am__dirstamp):
+ @$(MKDIR_P) gdb/i386
+ @: > gdb/i386/$(am__dirstamp)
+gdb/i386/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) gdb/i386/$(DEPDIR)
+ @: > gdb/i386/$(DEPDIR)/$(am__dirstamp)
+gdb/i386/gdb_module-idt.$(OBJEXT): gdb/i386/$(am__dirstamp) \
+ gdb/i386/$(DEPDIR)/$(am__dirstamp)
+gdb/i386/gdb_module-machdep.$(OBJEXT): gdb/i386/$(am__dirstamp) \
+ gdb/i386/$(DEPDIR)/$(am__dirstamp)
+gdb/i386/gdb_module-signal.$(OBJEXT): gdb/i386/$(am__dirstamp) \
+ gdb/i386/$(DEPDIR)/$(am__dirstamp)
+gdb/$(am__dirstamp):
+ @$(MKDIR_P) gdb
+ @: > gdb/$(am__dirstamp)
+gdb/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) gdb/$(DEPDIR)
+ @: > gdb/$(DEPDIR)/$(am__dirstamp)
+gdb/gdb_module-cstub.$(OBJEXT): gdb/$(am__dirstamp) \
+ gdb/$(DEPDIR)/$(am__dirstamp)
+gdb/gdb_module-gdb.$(OBJEXT): gdb/$(am__dirstamp) \
+ gdb/$(DEPDIR)/$(am__dirstamp)
+
+gdb.module$(EXEEXT): $(gdb_module_OBJECTS) $(gdb_module_DEPENDENCIES) $(EXTRA_gdb_module_DEPENDENCIES)
+ @rm -f gdb.module$(EXEEXT)
+ $(AM_V_CCLD)$(gdb_module_LINK) $(gdb_module_OBJECTS) $(gdb_module_LDADD) $(LIBS)
+disk/geli_module-geli.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+geli.module$(EXEEXT): $(geli_module_OBJECTS) $(geli_module_DEPENDENCIES) $(EXTRA_geli_module_DEPENDENCIES)
+ @rm -f geli.module$(EXEEXT)
+ $(AM_V_CCLD)$(geli_module_LINK) $(geli_module_OBJECTS) $(geli_module_LDADD) $(LIBS)
+gettext/$(am__dirstamp):
+ @$(MKDIR_P) gettext
+ @: > gettext/$(am__dirstamp)
+gettext/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) gettext/$(DEPDIR)
+ @: > gettext/$(DEPDIR)/$(am__dirstamp)
+gettext/gettext_module-gettext.$(OBJEXT): gettext/$(am__dirstamp) \
+ gettext/$(DEPDIR)/$(am__dirstamp)
+
+gettext.module$(EXEEXT): $(gettext_module_OBJECTS) $(gettext_module_DEPENDENCIES) $(EXTRA_gettext_module_DEPENDENCIES)
+ @rm -f gettext.module$(EXEEXT)
+ $(AM_V_CCLD)$(gettext_module_LINK) $(gettext_module_OBJECTS) $(gettext_module_LDADD) $(LIBS)
+gfxmenu/$(am__dirstamp):
+ @$(MKDIR_P) gfxmenu
+ @: > gfxmenu/$(am__dirstamp)
+gfxmenu/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) gfxmenu/$(DEPDIR)
+ @: > gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-gfxmenu.$(OBJEXT): gfxmenu/$(am__dirstamp) \
+ gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-view.$(OBJEXT): gfxmenu/$(am__dirstamp) \
+ gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-font.$(OBJEXT): gfxmenu/$(am__dirstamp) \
+ gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-icon_manager.$(OBJEXT): \
+ gfxmenu/$(am__dirstamp) gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-theme_loader.$(OBJEXT): \
+ gfxmenu/$(am__dirstamp) gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-widget-box.$(OBJEXT): gfxmenu/$(am__dirstamp) \
+ gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-gui_canvas.$(OBJEXT): gfxmenu/$(am__dirstamp) \
+ gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-gui_circular_progress.$(OBJEXT): \
+ gfxmenu/$(am__dirstamp) gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-gui_box.$(OBJEXT): gfxmenu/$(am__dirstamp) \
+ gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-gui_label.$(OBJEXT): gfxmenu/$(am__dirstamp) \
+ gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-gui_list.$(OBJEXT): gfxmenu/$(am__dirstamp) \
+ gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-gui_image.$(OBJEXT): gfxmenu/$(am__dirstamp) \
+ gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-gui_progress_bar.$(OBJEXT): \
+ gfxmenu/$(am__dirstamp) gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-gui_util.$(OBJEXT): gfxmenu/$(am__dirstamp) \
+ gfxmenu/$(DEPDIR)/$(am__dirstamp)
+gfxmenu/gfxmenu_module-gui_string_util.$(OBJEXT): \
+ gfxmenu/$(am__dirstamp) gfxmenu/$(DEPDIR)/$(am__dirstamp)
+
+gfxmenu.module$(EXEEXT): $(gfxmenu_module_OBJECTS) $(gfxmenu_module_DEPENDENCIES) $(EXTRA_gfxmenu_module_DEPENDENCIES)
+ @rm -f gfxmenu.module$(EXEEXT)
+ $(AM_V_CCLD)$(gfxmenu_module_LINK) $(gfxmenu_module_OBJECTS) $(gfxmenu_module_LDADD) $(LIBS)
+term/gfxterm_module-gfxterm.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+
+gfxterm.module$(EXEEXT): $(gfxterm_module_OBJECTS) $(gfxterm_module_DEPENDENCIES) $(EXTRA_gfxterm_module_DEPENDENCIES)
+ @rm -f gfxterm.module$(EXEEXT)
+ $(AM_V_CCLD)$(gfxterm_module_LINK) $(gfxterm_module_OBJECTS) $(gfxterm_module_LDADD) $(LIBS)
+term/gfxterm_background_module-gfxterm_background.$(OBJEXT): \
+ term/$(am__dirstamp) term/$(DEPDIR)/$(am__dirstamp)
+
+gfxterm_background.module$(EXEEXT): $(gfxterm_background_module_OBJECTS) $(gfxterm_background_module_DEPENDENCIES) $(EXTRA_gfxterm_background_module_DEPENDENCIES)
+ @rm -f gfxterm_background.module$(EXEEXT)
+ $(AM_V_CCLD)$(gfxterm_background_module_LINK) $(gfxterm_background_module_OBJECTS) $(gfxterm_background_module_LDADD) $(LIBS)
+tests/gfxterm_menu_module-gfxterm_menu.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+
+gfxterm_menu.module$(EXEEXT): $(gfxterm_menu_module_OBJECTS) $(gfxterm_menu_module_DEPENDENCIES) $(EXTRA_gfxterm_menu_module_DEPENDENCIES)
+ @rm -f gfxterm_menu.module$(EXEEXT)
+ $(AM_V_CCLD)$(gfxterm_menu_module_LINK) $(gfxterm_menu_module_OBJECTS) $(gfxterm_menu_module_LDADD) $(LIBS)
+commands/gptsync_module-gptsync.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+gptsync.module$(EXEEXT): $(gptsync_module_OBJECTS) $(gptsync_module_DEPENDENCIES) $(EXTRA_gptsync_module_DEPENDENCIES)
+ @rm -f gptsync.module$(EXEEXT)
+ $(AM_V_CCLD)$(gptsync_module_LINK) $(gptsync_module_OBJECTS) $(gptsync_module_LDADD) $(LIBS)
+kern/emu/$(am__dirstamp):
+ @$(MKDIR_P) kern/emu
+ @: > kern/emu/$(am__dirstamp)
+kern/emu/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/emu/$(DEPDIR)
+ @: > kern/emu/$(DEPDIR)/$(am__dirstamp)
+kern/emu/grub_emu-full.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+
+grub-emu$(EXEEXT): $(grub_emu_OBJECTS) $(grub_emu_DEPENDENCIES) $(EXTRA_grub_emu_DEPENDENCIES)
+ @rm -f grub-emu$(EXEEXT)
+ $(AM_V_CCLD)$(grub_emu_LINK) $(grub_emu_OBJECTS) $(grub_emu_LDADD) $(LIBS)
+kern/emu/grub_emu_lite-lite.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+
+grub-emu-lite$(EXEEXT): $(grub_emu_lite_OBJECTS) $(grub_emu_lite_DEPENDENCIES) $(EXTRA_grub_emu_lite_DEPENDENCIES)
+ @rm -f grub-emu-lite$(EXEEXT)
+ $(AM_V_CCLD)$(grub_emu_lite_LINK) $(grub_emu_lite_OBJECTS) $(grub_emu_lite_LDADD) $(LIBS)
+io/gzio_module-gzio.$(OBJEXT): io/$(am__dirstamp) \
+ io/$(DEPDIR)/$(am__dirstamp)
+
+gzio.module$(EXEEXT): $(gzio_module_OBJECTS) $(gzio_module_DEPENDENCIES) $(EXTRA_gzio_module_DEPENDENCIES)
+ @rm -f gzio.module$(EXEEXT)
+ $(AM_V_CCLD)$(gzio_module_LINK) $(gzio_module_OBJECTS) $(gzio_module_LDADD) $(LIBS)
+lib/efi/halt_module-halt.$(OBJEXT): lib/efi/$(am__dirstamp) \
+ lib/efi/$(DEPDIR)/$(am__dirstamp)
+commands/halt_module-halt.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+lib/dummy/halt_module-halt.$(OBJEXT): lib/dummy/$(am__dirstamp) \
+ lib/dummy/$(DEPDIR)/$(am__dirstamp)
+lib/emu/$(am__dirstamp):
+ @$(MKDIR_P) lib/emu
+ @: > lib/emu/$(am__dirstamp)
+lib/emu/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/emu/$(DEPDIR)
+ @: > lib/emu/$(DEPDIR)/$(am__dirstamp)
+lib/emu/halt_module-halt.$(OBJEXT): lib/emu/$(am__dirstamp) \
+ lib/emu/$(DEPDIR)/$(am__dirstamp)
+commands/halt_module-acpihalt.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+lib/i386/halt_module-halt.$(OBJEXT): lib/i386/$(am__dirstamp) \
+ lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/ieee1275/halt_module-halt.$(OBJEXT): lib/ieee1275/$(am__dirstamp) \
+ lib/ieee1275/$(DEPDIR)/$(am__dirstamp)
+commands/i386/pc/halt_module-halt.$(OBJEXT): \
+ commands/i386/pc/$(am__dirstamp) \
+ commands/i386/pc/$(DEPDIR)/$(am__dirstamp)
+lib/xen/halt_module-halt.$(OBJEXT): lib/xen/$(am__dirstamp) \
+ lib/xen/$(DEPDIR)/$(am__dirstamp)
+
+halt.module$(EXEEXT): $(halt_module_OBJECTS) $(halt_module_DEPENDENCIES) $(EXTRA_halt_module_DEPENDENCIES)
+ @rm -f halt.module$(EXEEXT)
+ $(AM_V_CCLD)$(halt_module_LINK) $(halt_module_OBJECTS) $(halt_module_LDADD) $(LIBS)
+commands/hashsum_module-hashsum.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+hashsum.module$(EXEEXT): $(hashsum_module_OBJECTS) $(hashsum_module_DEPENDENCIES) $(EXTRA_hashsum_module_DEPENDENCIES)
+ @rm -f hashsum.module$(EXEEXT)
+ $(AM_V_CCLD)$(hashsum_module_LINK) $(hashsum_module_OBJECTS) $(hashsum_module_LDADD) $(LIBS)
+commands/hdparm_module-hdparm.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+hdparm.module$(EXEEXT): $(hdparm_module_OBJECTS) $(hdparm_module_DEPENDENCIES) $(EXTRA_hdparm_module_DEPENDENCIES)
+ @rm -f hdparm.module$(EXEEXT)
+ $(AM_V_CCLD)$(hdparm_module_LINK) $(hdparm_module_OBJECTS) $(hdparm_module_LDADD) $(LIBS)
+hello/$(am__dirstamp):
+ @$(MKDIR_P) hello
+ @: > hello/$(am__dirstamp)
+hello/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) hello/$(DEPDIR)
+ @: > hello/$(DEPDIR)/$(am__dirstamp)
+hello/hello_module-hello.$(OBJEXT): hello/$(am__dirstamp) \
+ hello/$(DEPDIR)/$(am__dirstamp)
+
+hello.module$(EXEEXT): $(hello_module_OBJECTS) $(hello_module_DEPENDENCIES) $(EXTRA_hello_module_DEPENDENCIES)
+ @rm -f hello.module$(EXEEXT)
+ $(AM_V_CCLD)$(hello_module_LINK) $(hello_module_OBJECTS) $(hello_module_LDADD) $(LIBS)
+commands/help_module-help.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+help.module$(EXEEXT): $(help_module_OBJECTS) $(help_module_DEPENDENCIES) $(EXTRA_help_module_DEPENDENCIES)
+ @rm -f help.module$(EXEEXT)
+ $(AM_V_CCLD)$(help_module_LINK) $(help_module_OBJECTS) $(help_module_LDADD) $(LIBS)
+commands/hexdump_module-hexdump.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+lib/hexdump_module-hexdump.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+hexdump.module$(EXEEXT): $(hexdump_module_OBJECTS) $(hexdump_module_DEPENDENCIES) $(EXTRA_hexdump_module_DEPENDENCIES)
+ @rm -f hexdump.module$(EXEEXT)
+ $(AM_V_CCLD)$(hexdump_module_LINK) $(hexdump_module_OBJECTS) $(hexdump_module_LDADD) $(LIBS)
+fs/hfs_module-hfs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+hfs.module$(EXEEXT): $(hfs_module_OBJECTS) $(hfs_module_DEPENDENCIES) $(EXTRA_hfs_module_DEPENDENCIES)
+ @rm -f hfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(hfs_module_LINK) $(hfs_module_OBJECTS) $(hfs_module_LDADD) $(LIBS)
+fs/hfsplus_module-hfsplus.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+hfsplus.module$(EXEEXT): $(hfsplus_module_OBJECTS) $(hfsplus_module_DEPENDENCIES) $(EXTRA_hfsplus_module_DEPENDENCIES)
+ @rm -f hfsplus.module$(EXEEXT)
+ $(AM_V_CCLD)$(hfsplus_module_LINK) $(hfsplus_module_OBJECTS) $(hfsplus_module_LDADD) $(LIBS)
+fs/hfspluscomp_module-hfspluscomp.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+hfspluscomp.module$(EXEEXT): $(hfspluscomp_module_OBJECTS) $(hfspluscomp_module_DEPENDENCIES) $(EXTRA_hfspluscomp_module_DEPENDENCIES)
+ @rm -f hfspluscomp.module$(EXEEXT)
+ $(AM_V_CCLD)$(hfspluscomp_module_LINK) $(hfspluscomp_module_OBJECTS) $(hfspluscomp_module_LDADD) $(LIBS)
+net/$(am__dirstamp):
+ @$(MKDIR_P) net
+ @: > net/$(am__dirstamp)
+net/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) net/$(DEPDIR)
+ @: > net/$(DEPDIR)/$(am__dirstamp)
+net/http_module-http.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+
+http.module$(EXEEXT): $(http_module_OBJECTS) $(http_module_DEPENDENCIES) $(EXTRA_http_module_DEPENDENCIES)
+ @rm -f http.module$(EXEEXT)
+ $(AM_V_CCLD)$(http_module_LINK) $(http_module_OBJECTS) $(http_module_LDADD) $(LIBS)
+video/ieee1275_fb_module-ieee1275.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+
+ieee1275_fb.module$(EXEEXT): $(ieee1275_fb_module_OBJECTS) $(ieee1275_fb_module_DEPENDENCIES) $(EXTRA_ieee1275_fb_module_DEPENDENCIES)
+ @rm -f ieee1275_fb.module$(EXEEXT)
+ $(AM_V_CCLD)$(ieee1275_fb_module_LINK) $(ieee1275_fb_module_OBJECTS) $(ieee1275_fb_module_LDADD) $(LIBS)
+commands/iorw_module-iorw.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+iorw.module$(EXEEXT): $(iorw_module_OBJECTS) $(iorw_module_DEPENDENCIES) $(EXTRA_iorw_module_DEPENDENCIES)
+ @rm -f iorw.module$(EXEEXT)
+ $(AM_V_CCLD)$(iorw_module_LINK) $(iorw_module_OBJECTS) $(iorw_module_LDADD) $(LIBS)
+fs/iso9660_module-iso9660.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+iso9660.module$(EXEEXT): $(iso9660_module_OBJECTS) $(iso9660_module_DEPENDENCIES) $(EXTRA_iso9660_module_DEPENDENCIES)
+ @rm -f iso9660.module$(EXEEXT)
+ $(AM_V_CCLD)$(iso9660_module_LINK) $(iso9660_module_OBJECTS) $(iso9660_module_LDADD) $(LIBS)
+fs/jfs_module-jfs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+jfs.module$(EXEEXT): $(jfs_module_OBJECTS) $(jfs_module_DEPENDENCIES) $(EXTRA_jfs_module_DEPENDENCIES)
+ @rm -f jfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(jfs_module_LINK) $(jfs_module_OBJECTS) $(jfs_module_LDADD) $(LIBS)
+video/readers/$(am__dirstamp):
+ @$(MKDIR_P) video/readers
+ @: > video/readers/$(am__dirstamp)
+video/readers/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) video/readers/$(DEPDIR)
+ @: > video/readers/$(DEPDIR)/$(am__dirstamp)
+video/readers/jpeg_module-jpeg.$(OBJEXT): \
+ video/readers/$(am__dirstamp) \
+ video/readers/$(DEPDIR)/$(am__dirstamp)
+
+jpeg.module$(EXEEXT): $(jpeg_module_OBJECTS) $(jpeg_module_DEPENDENCIES) $(EXTRA_jpeg_module_DEPENDENCIES)
+ @rm -f jpeg.module$(EXEEXT)
+ $(AM_V_CCLD)$(jpeg_module_LINK) $(jpeg_module_OBJECTS) $(jpeg_module_LDADD) $(LIBS)
+lib/json/$(am__dirstamp):
+ @$(MKDIR_P) lib/json
+ @: > lib/json/$(am__dirstamp)
+lib/json/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/json/$(DEPDIR)
+ @: > lib/json/$(DEPDIR)/$(am__dirstamp)
+lib/json/json_module-json.$(OBJEXT): lib/json/$(am__dirstamp) \
+ lib/json/$(DEPDIR)/$(am__dirstamp)
+
+json.module$(EXEEXT): $(json_module_OBJECTS) $(json_module_DEPENDENCIES) $(EXTRA_json_module_DEPENDENCIES)
+ @rm -f json.module$(EXEEXT)
+ $(AM_V_CCLD)$(json_module_LINK) $(json_module_OBJECTS) $(json_module_LDADD) $(LIBS)
+kern/arm64/efi/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm64/efi
+ @: > kern/arm64/efi/$(am__dirstamp)
+kern/arm64/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm64/efi/$(DEPDIR)
+ @: > kern/arm64/efi/$(DEPDIR)/$(am__dirstamp)
+kern/arm64/efi/kernel_exec-startup.$(OBJEXT): \
+ kern/arm64/efi/$(am__dirstamp) \
+ kern/arm64/efi/$(DEPDIR)/$(am__dirstamp)
+kern/arm64/efi/kernel_exec-init.$(OBJEXT): \
+ kern/arm64/efi/$(am__dirstamp) \
+ kern/arm64/efi/$(DEPDIR)/$(am__dirstamp)
+kern/efi/$(am__dirstamp):
+ @$(MKDIR_P) kern/efi
+ @: > kern/efi/$(am__dirstamp)
+kern/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/efi/$(DEPDIR)
+ @: > kern/efi/$(DEPDIR)/$(am__dirstamp)
+kern/efi/kernel_exec-fdt.$(OBJEXT): kern/efi/$(am__dirstamp) \
+ kern/efi/$(DEPDIR)/$(am__dirstamp)
+kern/arm64/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm64
+ @: > kern/arm64/$(am__dirstamp)
+kern/arm64/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm64/$(DEPDIR)
+ @: > kern/arm64/$(DEPDIR)/$(am__dirstamp)
+kern/arm64/kernel_exec-cache.$(OBJEXT): kern/arm64/$(am__dirstamp) \
+ kern/arm64/$(DEPDIR)/$(am__dirstamp)
+kern/arm64/kernel_exec-cache_flush.$(OBJEXT): \
+ kern/arm64/$(am__dirstamp) \
+ kern/arm64/$(DEPDIR)/$(am__dirstamp)
+kern/arm64/kernel_exec-dl.$(OBJEXT): kern/arm64/$(am__dirstamp) \
+ kern/arm64/$(DEPDIR)/$(am__dirstamp)
+kern/arm64/kernel_exec-dl_helper.$(OBJEXT): \
+ kern/arm64/$(am__dirstamp) \
+ kern/arm64/$(DEPDIR)/$(am__dirstamp)
+disk/efi/$(am__dirstamp):
+ @$(MKDIR_P) disk/efi
+ @: > disk/efi/$(am__dirstamp)
+disk/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) disk/efi/$(DEPDIR)
+ @: > disk/efi/$(DEPDIR)/$(am__dirstamp)
+disk/efi/kernel_exec-efidisk.$(OBJEXT): disk/efi/$(am__dirstamp) \
+ disk/efi/$(DEPDIR)/$(am__dirstamp)
+kern/efi/kernel_exec-efi.$(OBJEXT): kern/efi/$(am__dirstamp) \
+ kern/efi/$(DEPDIR)/$(am__dirstamp)
+kern/efi/kernel_exec-init.$(OBJEXT): kern/efi/$(am__dirstamp) \
+ kern/efi/$(DEPDIR)/$(am__dirstamp)
+kern/efi/kernel_exec-mm.$(OBJEXT): kern/efi/$(am__dirstamp) \
+ kern/efi/$(DEPDIR)/$(am__dirstamp)
+term/efi/$(am__dirstamp):
+ @$(MKDIR_P) term/efi
+ @: > term/efi/$(am__dirstamp)
+term/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) term/efi/$(DEPDIR)
+ @: > term/efi/$(DEPDIR)/$(am__dirstamp)
+term/efi/kernel_exec-console.$(OBJEXT): term/efi/$(am__dirstamp) \
+ term/efi/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-acpi.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/efi/kernel_exec-acpi.$(OBJEXT): kern/efi/$(am__dirstamp) \
+ kern/efi/$(DEPDIR)/$(am__dirstamp)
+kern/efi/kernel_exec-sb.$(OBJEXT): kern/efi/$(am__dirstamp) \
+ kern/efi/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-lockdown.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-compiler-rt.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-mm.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-time.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/generic/$(am__dirstamp):
+ @$(MKDIR_P) kern/generic
+ @: > kern/generic/$(am__dirstamp)
+kern/generic/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/generic/$(DEPDIR)
+ @: > kern/generic/$(DEPDIR)/$(am__dirstamp)
+kern/generic/kernel_exec-millisleep.$(OBJEXT): \
+ kern/generic/$(am__dirstamp) \
+ kern/generic/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-buffer.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-command.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-corecmd.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-device.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-disk.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-dl.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-env.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-err.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-file.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-fs.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-list.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-main.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-misc.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-parser.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-partition.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-rescue_parser.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-rescue_reader.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-term.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-verifiers.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/arm/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm
+ @: > kern/arm/$(am__dirstamp)
+kern/arm/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm/$(DEPDIR)
+ @: > kern/arm/$(DEPDIR)/$(am__dirstamp)
+kern/arm/kernel_exec-startup.$(OBJEXT): kern/arm/$(am__dirstamp) \
+ kern/arm/$(DEPDIR)/$(am__dirstamp)
+kern/arm/coreboot/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm/coreboot
+ @: > kern/arm/coreboot/$(am__dirstamp)
+kern/arm/coreboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm/coreboot/$(DEPDIR)
+ @: > kern/arm/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/arm/coreboot/kernel_exec-init.$(OBJEXT): \
+ kern/arm/coreboot/$(am__dirstamp) \
+ kern/arm/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/arm/coreboot/kernel_exec-timer.$(OBJEXT): \
+ kern/arm/coreboot/$(am__dirstamp) \
+ kern/arm/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/arm/coreboot/kernel_exec-coreboot.$(OBJEXT): \
+ kern/arm/coreboot/$(am__dirstamp) \
+ kern/arm/coreboot/$(DEPDIR)/$(am__dirstamp)
+lib/kernel_exec-fdt.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+bus/kernel_exec-fdt.$(OBJEXT): bus/$(am__dirstamp) \
+ bus/$(DEPDIR)/$(am__dirstamp)
+term/kernel_exec-ps2.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+term/arm/$(am__dirstamp):
+ @$(MKDIR_P) term/arm
+ @: > term/arm/$(am__dirstamp)
+term/arm/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) term/arm/$(DEPDIR)
+ @: > term/arm/$(DEPDIR)/$(am__dirstamp)
+term/arm/kernel_exec-pl050.$(OBJEXT): term/arm/$(am__dirstamp) \
+ term/arm/$(DEPDIR)/$(am__dirstamp)
+term/arm/kernel_exec-cros.$(OBJEXT): term/arm/$(am__dirstamp) \
+ term/arm/$(DEPDIR)/$(am__dirstamp)
+term/arm/kernel_exec-cros_ec.$(OBJEXT): term/arm/$(am__dirstamp) \
+ term/arm/$(DEPDIR)/$(am__dirstamp)
+bus/spi/$(am__dirstamp):
+ @$(MKDIR_P) bus/spi
+ @: > bus/spi/$(am__dirstamp)
+bus/spi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) bus/spi/$(DEPDIR)
+ @: > bus/spi/$(DEPDIR)/$(am__dirstamp)
+bus/spi/kernel_exec-rk3288_spi.$(OBJEXT): bus/spi/$(am__dirstamp) \
+ bus/spi/$(DEPDIR)/$(am__dirstamp)
+commands/kernel_exec-keylayouts.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+kern/arm/coreboot/kernel_exec-dma.$(OBJEXT): \
+ kern/arm/coreboot/$(am__dirstamp) \
+ kern/arm/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/arm/coreboot/kernel_exec-cbtable.$(OBJEXT): \
+ kern/arm/coreboot/$(am__dirstamp) \
+ kern/arm/coreboot/$(DEPDIR)/$(am__dirstamp)
+video/coreboot/$(am__dirstamp):
+ @$(MKDIR_P) video/coreboot
+ @: > video/coreboot/$(am__dirstamp)
+video/coreboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) video/coreboot/$(DEPDIR)
+ @: > video/coreboot/$(DEPDIR)/$(am__dirstamp)
+video/coreboot/kernel_exec-cbfb.$(OBJEXT): \
+ video/coreboot/$(am__dirstamp) \
+ video/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/coreboot/kernel_exec-mmap.$(OBJEXT): \
+ kern/coreboot/$(am__dirstamp) \
+ kern/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/coreboot/kernel_exec-cbtable.$(OBJEXT): \
+ kern/coreboot/$(am__dirstamp) \
+ kern/coreboot/$(DEPDIR)/$(am__dirstamp)
+term/kernel_exec-gfxterm.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+font/kernel_exec-font.$(OBJEXT): font/$(am__dirstamp) \
+ font/$(DEPDIR)/$(am__dirstamp)
+font/kernel_exec-font_cmd.$(OBJEXT): font/$(am__dirstamp) \
+ font/$(DEPDIR)/$(am__dirstamp)
+io/kernel_exec-bufio.$(OBJEXT): io/$(am__dirstamp) \
+ io/$(DEPDIR)/$(am__dirstamp)
+video/fb/$(am__dirstamp):
+ @$(MKDIR_P) video/fb
+ @: > video/fb/$(am__dirstamp)
+video/fb/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) video/fb/$(DEPDIR)
+ @: > video/fb/$(DEPDIR)/$(am__dirstamp)
+video/fb/kernel_exec-fbblit.$(OBJEXT): video/fb/$(am__dirstamp) \
+ video/fb/$(DEPDIR)/$(am__dirstamp)
+video/fb/kernel_exec-fbfill.$(OBJEXT): video/fb/$(am__dirstamp) \
+ video/fb/$(DEPDIR)/$(am__dirstamp)
+video/fb/kernel_exec-fbutil.$(OBJEXT): video/fb/$(am__dirstamp) \
+ video/fb/$(DEPDIR)/$(am__dirstamp)
+video/fb/kernel_exec-video_fb.$(OBJEXT): video/fb/$(am__dirstamp) \
+ video/fb/$(DEPDIR)/$(am__dirstamp)
+video/kernel_exec-video.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+kern/arm/kernel_exec-dl.$(OBJEXT): kern/arm/$(am__dirstamp) \
+ kern/arm/$(DEPDIR)/$(am__dirstamp)
+kern/arm/kernel_exec-dl_helper.$(OBJEXT): kern/arm/$(am__dirstamp) \
+ kern/arm/$(DEPDIR)/$(am__dirstamp)
+kern/arm/kernel_exec-cache_armv6.$(OBJEXT): kern/arm/$(am__dirstamp) \
+ kern/arm/$(DEPDIR)/$(am__dirstamp)
+kern/arm/kernel_exec-cache_armv7.$(OBJEXT): kern/arm/$(am__dirstamp) \
+ kern/arm/$(DEPDIR)/$(am__dirstamp)
+kern/arm/kernel_exec-cache.$(OBJEXT): kern/arm/$(am__dirstamp) \
+ kern/arm/$(DEPDIR)/$(am__dirstamp)
+kern/arm/kernel_exec-compiler-rt.$(OBJEXT): kern/arm/$(am__dirstamp) \
+ kern/arm/$(DEPDIR)/$(am__dirstamp)
+lib/kernel_exec-division.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+kern/arm/efi/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm/efi
+ @: > kern/arm/efi/$(am__dirstamp)
+kern/arm/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm/efi/$(DEPDIR)
+ @: > kern/arm/efi/$(DEPDIR)/$(am__dirstamp)
+kern/arm/efi/kernel_exec-startup.$(OBJEXT): \
+ kern/arm/efi/$(am__dirstamp) \
+ kern/arm/efi/$(DEPDIR)/$(am__dirstamp)
+kern/arm/efi/kernel_exec-init.$(OBJEXT): kern/arm/efi/$(am__dirstamp) \
+ kern/arm/efi/$(DEPDIR)/$(am__dirstamp)
+kern/arm/uboot/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm/uboot
+ @: > kern/arm/uboot/$(am__dirstamp)
+kern/arm/uboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/arm/uboot/$(DEPDIR)
+ @: > kern/arm/uboot/$(DEPDIR)/$(am__dirstamp)
+kern/arm/uboot/kernel_exec-init.$(OBJEXT): \
+ kern/arm/uboot/$(am__dirstamp) \
+ kern/arm/uboot/$(DEPDIR)/$(am__dirstamp)
+kern/arm/uboot/kernel_exec-uboot.$(OBJEXT): \
+ kern/arm/uboot/$(am__dirstamp) \
+ kern/arm/uboot/$(DEPDIR)/$(am__dirstamp)
+disk/uboot/$(am__dirstamp):
+ @$(MKDIR_P) disk/uboot
+ @: > disk/uboot/$(am__dirstamp)
+disk/uboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) disk/uboot/$(DEPDIR)
+ @: > disk/uboot/$(DEPDIR)/$(am__dirstamp)
+disk/uboot/kernel_exec-ubootdisk.$(OBJEXT): \
+ disk/uboot/$(am__dirstamp) \
+ disk/uboot/$(DEPDIR)/$(am__dirstamp)
+kern/uboot/$(am__dirstamp):
+ @$(MKDIR_P) kern/uboot
+ @: > kern/uboot/$(am__dirstamp)
+kern/uboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/uboot/$(DEPDIR)
+ @: > kern/uboot/$(DEPDIR)/$(am__dirstamp)
+kern/uboot/kernel_exec-uboot.$(OBJEXT): kern/uboot/$(am__dirstamp) \
+ kern/uboot/$(DEPDIR)/$(am__dirstamp)
+kern/uboot/kernel_exec-init.$(OBJEXT): kern/uboot/$(am__dirstamp) \
+ kern/uboot/$(DEPDIR)/$(am__dirstamp)
+kern/uboot/kernel_exec-hw.$(OBJEXT): kern/uboot/$(am__dirstamp) \
+ kern/uboot/$(DEPDIR)/$(am__dirstamp)
+term/uboot/$(am__dirstamp):
+ @$(MKDIR_P) term/uboot
+ @: > term/uboot/$(am__dirstamp)
+term/uboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) term/uboot/$(DEPDIR)
+ @: > term/uboot/$(DEPDIR)/$(am__dirstamp)
+term/uboot/kernel_exec-console.$(OBJEXT): term/uboot/$(am__dirstamp) \
+ term/uboot/$(DEPDIR)/$(am__dirstamp)
+term/kernel_exec-terminfo.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+term/kernel_exec-tparm.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+commands/kernel_exec-extcmd.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+lib/kernel_exec-arg.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+disk/kernel_exec-host.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+kern/emu/kernel_exec-cache_s.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+kern/emu/kernel_exec-hostdisk.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+osdep/unix/$(am__dirstamp):
+ @$(MKDIR_P) osdep/unix
+ @: > osdep/unix/$(am__dirstamp)
+osdep/unix/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) osdep/unix/$(DEPDIR)
+ @: > osdep/unix/$(DEPDIR)/$(am__dirstamp)
+osdep/unix/kernel_exec-hostdisk.$(OBJEXT): osdep/unix/$(am__dirstamp) \
+ osdep/unix/$(DEPDIR)/$(am__dirstamp)
+osdep/$(am__dirstamp):
+ @$(MKDIR_P) osdep
+ @: > osdep/$(am__dirstamp)
+osdep/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) osdep/$(DEPDIR)
+ @: > osdep/$(DEPDIR)/$(am__dirstamp)
+osdep/kernel_exec-exec.$(OBJEXT): osdep/$(am__dirstamp) \
+ osdep/$(DEPDIR)/$(am__dirstamp)
+osdep/devmapper/$(am__dirstamp):
+ @$(MKDIR_P) osdep/devmapper
+ @: > osdep/devmapper/$(am__dirstamp)
+osdep/devmapper/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) osdep/devmapper/$(DEPDIR)
+ @: > osdep/devmapper/$(DEPDIR)/$(am__dirstamp)
+osdep/devmapper/kernel_exec-hostdisk.$(OBJEXT): \
+ osdep/devmapper/$(am__dirstamp) \
+ osdep/devmapper/$(DEPDIR)/$(am__dirstamp)
+osdep/kernel_exec-hostdisk.$(OBJEXT): osdep/$(am__dirstamp) \
+ osdep/$(DEPDIR)/$(am__dirstamp)
+kern/emu/kernel_exec-hostfs.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+kern/emu/kernel_exec-main.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+kern/emu/kernel_exec-argp_common.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+kern/emu/kernel_exec-misc.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+kern/emu/kernel_exec-mm.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+kern/emu/kernel_exec-time.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+kern/emu/kernel_exec-cache.$(OBJEXT): kern/emu/$(am__dirstamp) \
+ kern/emu/$(DEPDIR)/$(am__dirstamp)
+osdep/kernel_exec-emuconsole.$(OBJEXT): osdep/$(am__dirstamp) \
+ osdep/$(DEPDIR)/$(am__dirstamp)
+osdep/kernel_exec-dl.$(OBJEXT): osdep/$(am__dirstamp) \
+ osdep/$(DEPDIR)/$(am__dirstamp)
+osdep/kernel_exec-sleep.$(OBJEXT): osdep/$(am__dirstamp) \
+ osdep/$(DEPDIR)/$(am__dirstamp)
+osdep/kernel_exec-init.$(OBJEXT): osdep/$(am__dirstamp) \
+ osdep/$(DEPDIR)/$(am__dirstamp)
+osdep/kernel_exec-emunet.$(OBJEXT): osdep/$(am__dirstamp) \
+ osdep/$(DEPDIR)/$(am__dirstamp)
+osdep/kernel_exec-cputime.$(OBJEXT): osdep/$(am__dirstamp) \
+ osdep/$(DEPDIR)/$(am__dirstamp)
+kern/i386/coreboot/kernel_exec-startup.$(OBJEXT): \
+ kern/i386/coreboot/$(am__dirstamp) \
+ kern/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/i386/coreboot/kernel_exec-init.$(OBJEXT): \
+ kern/i386/coreboot/$(am__dirstamp) \
+ kern/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+kern/i386/pc/kernel_exec-acpi.$(OBJEXT): kern/i386/pc/$(am__dirstamp) \
+ kern/i386/pc/$(DEPDIR)/$(am__dirstamp)
+kern/i386/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386
+ @: > kern/i386/$(am__dirstamp)
+kern/i386/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/$(DEPDIR)
+ @: > kern/i386/$(DEPDIR)/$(am__dirstamp)
+kern/i386/kernel_exec-tsc_pmtimer.$(OBJEXT): \
+ kern/i386/$(am__dirstamp) kern/i386/$(DEPDIR)/$(am__dirstamp)
+kern/i386/coreboot/kernel_exec-cbtable.$(OBJEXT): \
+ kern/i386/coreboot/$(am__dirstamp) \
+ kern/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+term/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) term/i386/pc
+ @: > term/i386/pc/$(am__dirstamp)
+term/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) term/i386/pc/$(DEPDIR)
+ @: > term/i386/pc/$(DEPDIR)/$(am__dirstamp)
+term/i386/pc/kernel_exec-vga_text.$(OBJEXT): \
+ term/i386/pc/$(am__dirstamp) \
+ term/i386/pc/$(DEPDIR)/$(am__dirstamp)
+kern/i386/kernel_exec-dl.$(OBJEXT): kern/i386/$(am__dirstamp) \
+ kern/i386/$(DEPDIR)/$(am__dirstamp)
+kern/i386/kernel_exec-tsc.$(OBJEXT): kern/i386/$(am__dirstamp) \
+ kern/i386/$(DEPDIR)/$(am__dirstamp)
+kern/i386/kernel_exec-tsc_pit.$(OBJEXT): kern/i386/$(am__dirstamp) \
+ kern/i386/$(DEPDIR)/$(am__dirstamp)
+kern/i386/efi/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/efi
+ @: > kern/i386/efi/$(am__dirstamp)
+kern/i386/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/efi/$(DEPDIR)
+ @: > kern/i386/efi/$(DEPDIR)/$(am__dirstamp)
+kern/i386/efi/kernel_exec-startup.$(OBJEXT): \
+ kern/i386/efi/$(am__dirstamp) \
+ kern/i386/efi/$(DEPDIR)/$(am__dirstamp)
+kern/i386/efi/kernel_exec-tsc.$(OBJEXT): \
+ kern/i386/efi/$(am__dirstamp) \
+ kern/i386/efi/$(DEPDIR)/$(am__dirstamp)
+kern/i386/efi/kernel_exec-init.$(OBJEXT): \
+ kern/i386/efi/$(am__dirstamp) \
+ kern/i386/efi/$(DEPDIR)/$(am__dirstamp)
+bus/kernel_exec-pci.$(OBJEXT): bus/$(am__dirstamp) \
+ bus/$(DEPDIR)/$(am__dirstamp)
+kern/i386/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/ieee1275
+ @: > kern/i386/ieee1275/$(am__dirstamp)
+kern/i386/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/ieee1275/$(DEPDIR)
+ @: > kern/i386/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/i386/ieee1275/kernel_exec-startup.$(OBJEXT): \
+ kern/i386/ieee1275/$(am__dirstamp) \
+ kern/i386/ieee1275/$(DEPDIR)/$(am__dirstamp)
+disk/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) disk/ieee1275
+ @: > disk/ieee1275/$(am__dirstamp)
+disk/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) disk/ieee1275/$(DEPDIR)
+ @: > disk/ieee1275/$(DEPDIR)/$(am__dirstamp)
+disk/ieee1275/kernel_exec-ofdisk.$(OBJEXT): \
+ disk/ieee1275/$(am__dirstamp) \
+ disk/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) kern/ieee1275
+ @: > kern/ieee1275/$(am__dirstamp)
+kern/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/ieee1275/$(DEPDIR)
+ @: > kern/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/ieee1275/kernel_exec-cmain.$(OBJEXT): \
+ kern/ieee1275/$(am__dirstamp) \
+ kern/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/ieee1275/kernel_exec-ieee1275.$(OBJEXT): \
+ kern/ieee1275/$(am__dirstamp) \
+ kern/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/ieee1275/kernel_exec-mmap.$(OBJEXT): \
+ kern/ieee1275/$(am__dirstamp) \
+ kern/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/ieee1275/kernel_exec-openfw.$(OBJEXT): \
+ kern/ieee1275/$(am__dirstamp) \
+ kern/ieee1275/$(DEPDIR)/$(am__dirstamp)
+term/ieee1275/kernel_exec-console.$(OBJEXT): \
+ term/ieee1275/$(am__dirstamp) \
+ term/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/ieee1275/kernel_exec-init.$(OBJEXT): \
+ kern/ieee1275/$(am__dirstamp) \
+ kern/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/i386/kernel_exec-multiboot_mmap.$(OBJEXT): \
+ kern/i386/$(am__dirstamp) kern/i386/$(DEPDIR)/$(am__dirstamp)
+kern/i386/pc/kernel_exec-startup.$(OBJEXT): \
+ kern/i386/pc/$(am__dirstamp) \
+ kern/i386/pc/$(DEPDIR)/$(am__dirstamp)
+kern/i386/pc/kernel_exec-init.$(OBJEXT): kern/i386/pc/$(am__dirstamp) \
+ kern/i386/pc/$(DEPDIR)/$(am__dirstamp)
+kern/i386/pc/kernel_exec-mmap.$(OBJEXT): kern/i386/pc/$(am__dirstamp) \
+ kern/i386/pc/$(DEPDIR)/$(am__dirstamp)
+term/i386/pc/kernel_exec-console.$(OBJEXT): \
+ term/i386/pc/$(am__dirstamp) \
+ term/i386/pc/$(DEPDIR)/$(am__dirstamp)
+kern/i386/qemu/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/qemu
+ @: > kern/i386/qemu/$(am__dirstamp)
+kern/i386/qemu/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/qemu/$(DEPDIR)
+ @: > kern/i386/qemu/$(DEPDIR)/$(am__dirstamp)
+kern/i386/qemu/kernel_exec-startup.$(OBJEXT): \
+ kern/i386/qemu/$(am__dirstamp) \
+ kern/i386/qemu/$(DEPDIR)/$(am__dirstamp)
+kern/i386/qemu/kernel_exec-init.$(OBJEXT): \
+ kern/i386/qemu/$(am__dirstamp) \
+ kern/i386/qemu/$(DEPDIR)/$(am__dirstamp)
+kern/kernel_exec-vga_init.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+kern/i386/qemu/kernel_exec-mmap.$(OBJEXT): \
+ kern/i386/qemu/$(am__dirstamp) \
+ kern/i386/qemu/$(DEPDIR)/$(am__dirstamp)
+kern/i386/xen/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/xen
+ @: > kern/i386/xen/$(am__dirstamp)
+kern/i386/xen/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/i386/xen/$(DEPDIR)
+ @: > kern/i386/xen/$(DEPDIR)/$(am__dirstamp)
+kern/i386/xen/kernel_exec-startup.$(OBJEXT): \
+ kern/i386/xen/$(am__dirstamp) \
+ kern/i386/xen/$(DEPDIR)/$(am__dirstamp)
+kern/i386/xen/kernel_exec-hypercall.$(OBJEXT): \
+ kern/i386/xen/$(am__dirstamp) \
+ kern/i386/xen/$(DEPDIR)/$(am__dirstamp)
+kern/i386/xen/kernel_exec-tsc.$(OBJEXT): \
+ kern/i386/xen/$(am__dirstamp) \
+ kern/i386/xen/$(DEPDIR)/$(am__dirstamp)
+kern/xen/$(am__dirstamp):
+ @$(MKDIR_P) kern/xen
+ @: > kern/xen/$(am__dirstamp)
+kern/xen/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/xen/$(DEPDIR)
+ @: > kern/xen/$(DEPDIR)/$(am__dirstamp)
+kern/xen/kernel_exec-init.$(OBJEXT): kern/xen/$(am__dirstamp) \
+ kern/xen/$(DEPDIR)/$(am__dirstamp)
+term/xen/$(am__dirstamp):
+ @$(MKDIR_P) term/xen
+ @: > term/xen/$(am__dirstamp)
+term/xen/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) term/xen/$(DEPDIR)
+ @: > term/xen/$(DEPDIR)/$(am__dirstamp)
+term/xen/kernel_exec-console.$(OBJEXT): term/xen/$(am__dirstamp) \
+ term/xen/$(DEPDIR)/$(am__dirstamp)
+disk/xen/$(am__dirstamp):
+ @$(MKDIR_P) disk/xen
+ @: > disk/xen/$(am__dirstamp)
+disk/xen/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) disk/xen/$(DEPDIR)
+ @: > disk/xen/$(DEPDIR)/$(am__dirstamp)
+disk/xen/kernel_exec-xendisk.$(OBJEXT): disk/xen/$(am__dirstamp) \
+ disk/xen/$(DEPDIR)/$(am__dirstamp)
+commands/kernel_exec-boot.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+kern/i386/xen/kernel_exec-startup_pvh.$(OBJEXT): \
+ kern/i386/xen/$(am__dirstamp) \
+ kern/i386/xen/$(DEPDIR)/$(am__dirstamp)
+kern/i386/xen/kernel_exec-pvh.$(OBJEXT): \
+ kern/i386/xen/$(am__dirstamp) \
+ kern/i386/xen/$(DEPDIR)/$(am__dirstamp)
+kern/ia64/efi/$(am__dirstamp):
+ @$(MKDIR_P) kern/ia64/efi
+ @: > kern/ia64/efi/$(am__dirstamp)
+kern/ia64/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/ia64/efi/$(DEPDIR)
+ @: > kern/ia64/efi/$(DEPDIR)/$(am__dirstamp)
+kern/ia64/efi/kernel_exec-startup.$(OBJEXT): \
+ kern/ia64/efi/$(am__dirstamp) \
+ kern/ia64/efi/$(DEPDIR)/$(am__dirstamp)
+kern/ia64/efi/kernel_exec-init.$(OBJEXT): \
+ kern/ia64/efi/$(am__dirstamp) \
+ kern/ia64/efi/$(DEPDIR)/$(am__dirstamp)
+kern/ia64/$(am__dirstamp):
+ @$(MKDIR_P) kern/ia64
+ @: > kern/ia64/$(am__dirstamp)
+kern/ia64/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/ia64/$(DEPDIR)
+ @: > kern/ia64/$(DEPDIR)/$(am__dirstamp)
+kern/ia64/kernel_exec-dl.$(OBJEXT): kern/ia64/$(am__dirstamp) \
+ kern/ia64/$(DEPDIR)/$(am__dirstamp)
+kern/ia64/kernel_exec-dl_helper.$(OBJEXT): kern/ia64/$(am__dirstamp) \
+ kern/ia64/$(DEPDIR)/$(am__dirstamp)
+kern/ia64/kernel_exec-cache.$(OBJEXT): kern/ia64/$(am__dirstamp) \
+ kern/ia64/$(DEPDIR)/$(am__dirstamp)
+kern/mips/$(am__dirstamp):
+ @$(MKDIR_P) kern/mips
+ @: > kern/mips/$(am__dirstamp)
+kern/mips/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/mips/$(DEPDIR)
+ @: > kern/mips/$(DEPDIR)/$(am__dirstamp)
+kern/mips/kernel_exec-startup.$(OBJEXT): kern/mips/$(am__dirstamp) \
+ kern/mips/$(DEPDIR)/$(am__dirstamp)
+kern/mips/arc/$(am__dirstamp):
+ @$(MKDIR_P) kern/mips/arc
+ @: > kern/mips/arc/$(am__dirstamp)
+kern/mips/arc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/mips/arc/$(DEPDIR)
+ @: > kern/mips/arc/$(DEPDIR)/$(am__dirstamp)
+kern/mips/arc/kernel_exec-init.$(OBJEXT): \
+ kern/mips/arc/$(am__dirstamp) \
+ kern/mips/arc/$(DEPDIR)/$(am__dirstamp)
+term/arc/$(am__dirstamp):
+ @$(MKDIR_P) term/arc
+ @: > term/arc/$(am__dirstamp)
+term/arc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) term/arc/$(DEPDIR)
+ @: > term/arc/$(DEPDIR)/$(am__dirstamp)
+term/arc/kernel_exec-console.$(OBJEXT): term/arc/$(am__dirstamp) \
+ term/arc/$(DEPDIR)/$(am__dirstamp)
+disk/arc/$(am__dirstamp):
+ @$(MKDIR_P) disk/arc
+ @: > disk/arc/$(am__dirstamp)
+disk/arc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) disk/arc/$(DEPDIR)
+ @: > disk/arc/$(DEPDIR)/$(am__dirstamp)
+disk/arc/kernel_exec-arcdisk.$(OBJEXT): disk/arc/$(am__dirstamp) \
+ disk/arc/$(DEPDIR)/$(am__dirstamp)
+kern/generic/kernel_exec-rtc_get_time_ms.$(OBJEXT): \
+ kern/generic/$(am__dirstamp) \
+ kern/generic/$(DEPDIR)/$(am__dirstamp)
+kern/mips/kernel_exec-cache.$(OBJEXT): kern/mips/$(am__dirstamp) \
+ kern/mips/$(DEPDIR)/$(am__dirstamp)
+kern/mips/kernel_exec-dl.$(OBJEXT): kern/mips/$(am__dirstamp) \
+ kern/mips/$(DEPDIR)/$(am__dirstamp)
+kern/mips/kernel_exec-init.$(OBJEXT): kern/mips/$(am__dirstamp) \
+ kern/mips/$(DEPDIR)/$(am__dirstamp)
+term/kernel_exec-ns8250.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+bus/kernel_exec-bonito.$(OBJEXT): bus/$(am__dirstamp) \
+ bus/$(DEPDIR)/$(am__dirstamp)
+bus/kernel_exec-cs5536.$(OBJEXT): bus/$(am__dirstamp) \
+ bus/$(DEPDIR)/$(am__dirstamp)
+kern/mips/loongson/$(am__dirstamp):
+ @$(MKDIR_P) kern/mips/loongson
+ @: > kern/mips/loongson/$(am__dirstamp)
+kern/mips/loongson/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/mips/loongson/$(DEPDIR)
+ @: > kern/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+kern/mips/loongson/kernel_exec-init.$(OBJEXT): \
+ kern/mips/loongson/$(am__dirstamp) \
+ kern/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+term/kernel_exec-at_keyboard.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+term/kernel_exec-serial.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+video/kernel_exec-sm712.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+video/kernel_exec-sis315pro.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+video/kernel_exec-radeon_fuloong2e.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+video/kernel_exec-radeon_yeeloong3a.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+kern/mips/qemu_mips/$(am__dirstamp):
+ @$(MKDIR_P) kern/mips/qemu_mips
+ @: > kern/mips/qemu_mips/$(am__dirstamp)
+kern/mips/qemu_mips/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/mips/qemu_mips/$(DEPDIR)
+ @: > kern/mips/qemu_mips/$(DEPDIR)/$(am__dirstamp)
+kern/mips/qemu_mips/kernel_exec-init.$(OBJEXT): \
+ kern/mips/qemu_mips/$(am__dirstamp) \
+ kern/mips/qemu_mips/$(DEPDIR)/$(am__dirstamp)
+kern/powerpc/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) kern/powerpc/ieee1275
+ @: > kern/powerpc/ieee1275/$(am__dirstamp)
+kern/powerpc/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/powerpc/ieee1275/$(DEPDIR)
+ @: > kern/powerpc/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/powerpc/ieee1275/kernel_exec-startup.$(OBJEXT): \
+ kern/powerpc/ieee1275/$(am__dirstamp) \
+ kern/powerpc/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/powerpc/$(am__dirstamp):
+ @$(MKDIR_P) kern/powerpc
+ @: > kern/powerpc/$(am__dirstamp)
+kern/powerpc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/powerpc/$(DEPDIR)
+ @: > kern/powerpc/$(DEPDIR)/$(am__dirstamp)
+kern/powerpc/kernel_exec-cache.$(OBJEXT): \
+ kern/powerpc/$(am__dirstamp) \
+ kern/powerpc/$(DEPDIR)/$(am__dirstamp)
+kern/powerpc/kernel_exec-dl.$(OBJEXT): kern/powerpc/$(am__dirstamp) \
+ kern/powerpc/$(DEPDIR)/$(am__dirstamp)
+kern/powerpc/kernel_exec-compiler-rt.$(OBJEXT): \
+ kern/powerpc/$(am__dirstamp) \
+ kern/powerpc/$(DEPDIR)/$(am__dirstamp)
+kern/riscv/efi/$(am__dirstamp):
+ @$(MKDIR_P) kern/riscv/efi
+ @: > kern/riscv/efi/$(am__dirstamp)
+kern/riscv/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/riscv/efi/$(DEPDIR)
+ @: > kern/riscv/efi/$(DEPDIR)/$(am__dirstamp)
+kern/riscv/efi/kernel_exec-startup.$(OBJEXT): \
+ kern/riscv/efi/$(am__dirstamp) \
+ kern/riscv/efi/$(DEPDIR)/$(am__dirstamp)
+kern/riscv/efi/kernel_exec-init.$(OBJEXT): \
+ kern/riscv/efi/$(am__dirstamp) \
+ kern/riscv/efi/$(DEPDIR)/$(am__dirstamp)
+kern/riscv/$(am__dirstamp):
+ @$(MKDIR_P) kern/riscv
+ @: > kern/riscv/$(am__dirstamp)
+kern/riscv/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/riscv/$(DEPDIR)
+ @: > kern/riscv/$(DEPDIR)/$(am__dirstamp)
+kern/riscv/kernel_exec-cache.$(OBJEXT): kern/riscv/$(am__dirstamp) \
+ kern/riscv/$(DEPDIR)/$(am__dirstamp)
+kern/riscv/kernel_exec-cache_flush.$(OBJEXT): \
+ kern/riscv/$(am__dirstamp) \
+ kern/riscv/$(DEPDIR)/$(am__dirstamp)
+kern/riscv/kernel_exec-dl.$(OBJEXT): kern/riscv/$(am__dirstamp) \
+ kern/riscv/$(DEPDIR)/$(am__dirstamp)
+kern/sparc64/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) kern/sparc64/ieee1275
+ @: > kern/sparc64/ieee1275/$(am__dirstamp)
+kern/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/sparc64/ieee1275/$(DEPDIR)
+ @: > kern/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/sparc64/ieee1275/kernel_exec-crt0.$(OBJEXT): \
+ kern/sparc64/ieee1275/$(am__dirstamp) \
+ kern/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/sparc64/$(am__dirstamp):
+ @$(MKDIR_P) kern/sparc64
+ @: > kern/sparc64/$(am__dirstamp)
+kern/sparc64/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/sparc64/$(DEPDIR)
+ @: > kern/sparc64/$(DEPDIR)/$(am__dirstamp)
+kern/sparc64/kernel_exec-cache.$(OBJEXT): \
+ kern/sparc64/$(am__dirstamp) \
+ kern/sparc64/$(DEPDIR)/$(am__dirstamp)
+kern/sparc64/kernel_exec-dl.$(OBJEXT): kern/sparc64/$(am__dirstamp) \
+ kern/sparc64/$(DEPDIR)/$(am__dirstamp)
+kern/sparc64/ieee1275/kernel_exec-ieee1275.$(OBJEXT): \
+ kern/sparc64/ieee1275/$(am__dirstamp) \
+ kern/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+disk/ieee1275/kernel_exec-obdisk.$(OBJEXT): \
+ disk/ieee1275/$(am__dirstamp) \
+ disk/ieee1275/$(DEPDIR)/$(am__dirstamp)
+kern/x86_64/efi/$(am__dirstamp):
+ @$(MKDIR_P) kern/x86_64/efi
+ @: > kern/x86_64/efi/$(am__dirstamp)
+kern/x86_64/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/x86_64/efi/$(DEPDIR)
+ @: > kern/x86_64/efi/$(DEPDIR)/$(am__dirstamp)
+kern/x86_64/efi/kernel_exec-startup.$(OBJEXT): \
+ kern/x86_64/efi/$(am__dirstamp) \
+ kern/x86_64/efi/$(DEPDIR)/$(am__dirstamp)
+kern/x86_64/efi/kernel_exec-callwrap.$(OBJEXT): \
+ kern/x86_64/efi/$(am__dirstamp) \
+ kern/x86_64/efi/$(DEPDIR)/$(am__dirstamp)
+kern/x86_64/$(am__dirstamp):
+ @$(MKDIR_P) kern/x86_64
+ @: > kern/x86_64/$(am__dirstamp)
+kern/x86_64/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/x86_64/$(DEPDIR)
+ @: > kern/x86_64/$(DEPDIR)/$(am__dirstamp)
+kern/x86_64/kernel_exec-dl.$(OBJEXT): kern/x86_64/$(am__dirstamp) \
+ kern/x86_64/$(DEPDIR)/$(am__dirstamp)
+kern/x86_64/xen/$(am__dirstamp):
+ @$(MKDIR_P) kern/x86_64/xen
+ @: > kern/x86_64/xen/$(am__dirstamp)
+kern/x86_64/xen/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) kern/x86_64/xen/$(DEPDIR)
+ @: > kern/x86_64/xen/$(DEPDIR)/$(am__dirstamp)
+kern/x86_64/xen/kernel_exec-startup.$(OBJEXT): \
+ kern/x86_64/xen/$(am__dirstamp) \
+ kern/x86_64/xen/$(DEPDIR)/$(am__dirstamp)
+kern/x86_64/xen/kernel_exec-hypercall.$(OBJEXT): \
+ kern/x86_64/xen/$(am__dirstamp) \
+ kern/x86_64/xen/$(DEPDIR)/$(am__dirstamp)
+
+kernel.exec$(EXEEXT): $(kernel_exec_OBJECTS) $(kernel_exec_DEPENDENCIES) $(EXTRA_kernel_exec_DEPENDENCIES)
+ @rm -f kernel.exec$(EXEEXT)
+ $(AM_V_CCLD)$(kernel_exec_LINK) $(kernel_exec_OBJECTS) $(kernel_exec_LDADD) $(LIBS)
+commands/keylayouts_module-keylayouts.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+keylayouts.module$(EXEEXT): $(keylayouts_module_OBJECTS) $(keylayouts_module_DEPENDENCIES) $(EXTRA_keylayouts_module_DEPENDENCIES)
+ @rm -f keylayouts.module$(EXEEXT)
+ $(AM_V_CCLD)$(keylayouts_module_LINK) $(keylayouts_module_OBJECTS) $(keylayouts_module_LDADD) $(LIBS)
+commands/keystatus_module-keystatus.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+keystatus.module$(EXEEXT): $(keystatus_module_OBJECTS) $(keystatus_module_DEPENDENCIES) $(EXTRA_keystatus_module_DEPENDENCIES)
+ @rm -f keystatus.module$(EXEEXT)
+ $(AM_V_CCLD)$(keystatus_module_LINK) $(keystatus_module_OBJECTS) $(keystatus_module_LDADD) $(LIBS)
+disk/ldm_module-ldm.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+ldm.module$(EXEEXT): $(ldm_module_OBJECTS) $(ldm_module_DEPENDENCIES) $(EXTRA_ldm_module_DEPENDENCIES)
+ @rm -f ldm.module$(EXEEXT)
+ $(AM_V_CCLD)$(ldm_module_LINK) $(ldm_module_OBJECTS) $(ldm_module_LDADD) $(LIBS)
+tests/legacy_password_test_module-legacy_password_test.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+
+legacy_password_test.module$(EXEEXT): $(legacy_password_test_module_OBJECTS) $(legacy_password_test_module_DEPENDENCIES) $(EXTRA_legacy_password_test_module_DEPENDENCIES)
+ @rm -f legacy_password_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(legacy_password_test_module_LINK) $(legacy_password_test_module_OBJECTS) $(legacy_password_test_module_LDADD) $(LIBS)
+lib/i386/pc/legacycfg_module-vesa_modes_table.$(OBJEXT): \
+ lib/i386/pc/$(am__dirstamp) \
+ lib/i386/pc/$(DEPDIR)/$(am__dirstamp)
+commands/legacycfg_module-legacycfg.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+lib/legacycfg_module-legacy_parse.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+legacycfg.module$(EXEEXT): $(legacycfg_module_OBJECTS) $(legacycfg_module_DEPENDENCIES) $(EXTRA_legacycfg_module_DEPENDENCIES)
+ @rm -f legacycfg.module$(EXEEXT)
+ $(AM_V_CCLD)$(legacycfg_module_LINK) $(legacycfg_module_OBJECTS) $(legacycfg_module_LDADD) $(LIBS)
+loader/arm64/$(am__dirstamp):
+ @$(MKDIR_P) loader/arm64
+ @: > loader/arm64/$(am__dirstamp)
+loader/arm64/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/arm64/$(DEPDIR)
+ @: > loader/arm64/$(DEPDIR)/$(am__dirstamp)
+loader/arm64/linux_module-linux.$(OBJEXT): \
+ loader/arm64/$(am__dirstamp) \
+ loader/arm64/$(DEPDIR)/$(am__dirstamp)
+loader/linux_module-linux.$(OBJEXT): loader/$(am__dirstamp) \
+ loader/$(DEPDIR)/$(am__dirstamp)
+lib/linux_module-cmdline.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+loader/arm/$(am__dirstamp):
+ @$(MKDIR_P) loader/arm
+ @: > loader/arm/$(am__dirstamp)
+loader/arm/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/arm/$(DEPDIR)
+ @: > loader/arm/$(DEPDIR)/$(am__dirstamp)
+loader/arm/linux_module-linux.$(OBJEXT): loader/arm/$(am__dirstamp) \
+ loader/arm/$(DEPDIR)/$(am__dirstamp)
+loader/i386/linux_module-linux.$(OBJEXT): loader/i386/$(am__dirstamp) \
+ loader/i386/$(DEPDIR)/$(am__dirstamp)
+lib/i386/pc/linux_module-vesa_modes_table.$(OBJEXT): \
+ lib/i386/pc/$(am__dirstamp) \
+ lib/i386/pc/$(DEPDIR)/$(am__dirstamp)
+loader/i386/linux_module-xen.$(OBJEXT): loader/i386/$(am__dirstamp) \
+ loader/i386/$(DEPDIR)/$(am__dirstamp)
+loader/ia64/efi/$(am__dirstamp):
+ @$(MKDIR_P) loader/ia64/efi
+ @: > loader/ia64/efi/$(am__dirstamp)
+loader/ia64/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/ia64/efi/$(DEPDIR)
+ @: > loader/ia64/efi/$(DEPDIR)/$(am__dirstamp)
+loader/ia64/efi/linux_module-linux.$(OBJEXT): \
+ loader/ia64/efi/$(am__dirstamp) \
+ loader/ia64/efi/$(DEPDIR)/$(am__dirstamp)
+loader/mips/$(am__dirstamp):
+ @$(MKDIR_P) loader/mips
+ @: > loader/mips/$(am__dirstamp)
+loader/mips/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/mips/$(DEPDIR)
+ @: > loader/mips/$(DEPDIR)/$(am__dirstamp)
+loader/mips/linux_module-linux.$(OBJEXT): loader/mips/$(am__dirstamp) \
+ loader/mips/$(DEPDIR)/$(am__dirstamp)
+loader/powerpc/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) loader/powerpc/ieee1275
+ @: > loader/powerpc/ieee1275/$(am__dirstamp)
+loader/powerpc/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/powerpc/ieee1275/$(DEPDIR)
+ @: > loader/powerpc/ieee1275/$(DEPDIR)/$(am__dirstamp)
+loader/powerpc/ieee1275/linux_module-linux.$(OBJEXT): \
+ loader/powerpc/ieee1275/$(am__dirstamp) \
+ loader/powerpc/ieee1275/$(DEPDIR)/$(am__dirstamp)
+loader/riscv/$(am__dirstamp):
+ @$(MKDIR_P) loader/riscv
+ @: > loader/riscv/$(am__dirstamp)
+loader/riscv/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/riscv/$(DEPDIR)
+ @: > loader/riscv/$(DEPDIR)/$(am__dirstamp)
+loader/riscv/linux_module-linux.$(OBJEXT): \
+ loader/riscv/$(am__dirstamp) \
+ loader/riscv/$(DEPDIR)/$(am__dirstamp)
+loader/sparc64/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) loader/sparc64/ieee1275
+ @: > loader/sparc64/ieee1275/$(am__dirstamp)
+loader/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) loader/sparc64/ieee1275/$(DEPDIR)
+ @: > loader/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+loader/sparc64/ieee1275/linux_module-linux.$(OBJEXT): \
+ loader/sparc64/ieee1275/$(am__dirstamp) \
+ loader/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+linux.module$(EXEEXT): $(linux_module_OBJECTS) $(linux_module_DEPENDENCIES) $(EXTRA_linux_module_DEPENDENCIES)
+ @rm -f linux.module$(EXEEXT)
+ $(AM_V_CCLD)$(linux_module_LINK) $(linux_module_OBJECTS) $(linux_module_LDADD) $(LIBS)
+loader/i386/pc/linux16_module-linux.$(OBJEXT): \
+ loader/i386/pc/$(am__dirstamp) \
+ loader/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+linux16.module$(EXEEXT): $(linux16_module_OBJECTS) $(linux16_module_DEPENDENCIES) $(EXTRA_linux16_module_DEPENDENCIES)
+ @rm -f linux16.module$(EXEEXT)
+ $(AM_V_CCLD)$(linux16_module_LINK) $(linux16_module_OBJECTS) $(linux16_module_LDADD) $(LIBS)
+boot/i386/pc/lnxboot_image-lnxboot.$(OBJEXT): \
+ boot/i386/pc/$(am__dirstamp) \
+ boot/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+lnxboot.image$(EXEEXT): $(lnxboot_image_OBJECTS) $(lnxboot_image_DEPENDENCIES) $(EXTRA_lnxboot_image_DEPENDENCIES)
+ @rm -f lnxboot.image$(EXEEXT)
+ $(AM_V_CCLD)$(lnxboot_image_LINK) $(lnxboot_image_OBJECTS) $(lnxboot_image_LDADD) $(LIBS)
+commands/efi/loadbios_module-loadbios.$(OBJEXT): \
+ commands/efi/$(am__dirstamp) \
+ commands/efi/$(DEPDIR)/$(am__dirstamp)
+
+loadbios.module$(EXEEXT): $(loadbios_module_OBJECTS) $(loadbios_module_DEPENDENCIES) $(EXTRA_loadbios_module_DEPENDENCIES)
+ @rm -f loadbios.module$(EXEEXT)
+ $(AM_V_CCLD)$(loadbios_module_LINK) $(loadbios_module_OBJECTS) $(loadbios_module_LDADD) $(LIBS)
+commands/loadenv_module-loadenv.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+lib/loadenv_module-envblk.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+loadenv.module$(EXEEXT): $(loadenv_module_OBJECTS) $(loadenv_module_DEPENDENCIES) $(EXTRA_loadenv_module_DEPENDENCIES)
+ @rm -f loadenv.module$(EXEEXT)
+ $(AM_V_CCLD)$(loadenv_module_LINK) $(loadenv_module_OBJECTS) $(loadenv_module_LDADD) $(LIBS)
+disk/loopback_module-loopback.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+loopback.module$(EXEEXT): $(loopback_module_OBJECTS) $(loopback_module_DEPENDENCIES) $(EXTRA_loopback_module_DEPENDENCIES)
+ @rm -f loopback.module$(EXEEXT)
+ $(AM_V_CCLD)$(loopback_module_LINK) $(loopback_module_OBJECTS) $(loopback_module_LDADD) $(LIBS)
+commands/ls_module-ls.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+ls.module$(EXEEXT): $(ls_module_OBJECTS) $(ls_module_DEPENDENCIES) $(EXTRA_ls_module_DEPENDENCIES)
+ @rm -f ls.module$(EXEEXT)
+ $(AM_V_CCLD)$(ls_module_LINK) $(ls_module_OBJECTS) $(ls_module_LDADD) $(LIBS)
+commands/lsacpi_module-lsacpi.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+lsacpi.module$(EXEEXT): $(lsacpi_module_OBJECTS) $(lsacpi_module_DEPENDENCIES) $(EXTRA_lsacpi_module_DEPENDENCIES)
+ @rm -f lsacpi.module$(EXEEXT)
+ $(AM_V_CCLD)$(lsacpi_module_LINK) $(lsacpi_module_OBJECTS) $(lsacpi_module_LDADD) $(LIBS)
+commands/i386/pc/lsapm_module-lsapm.$(OBJEXT): \
+ commands/i386/pc/$(am__dirstamp) \
+ commands/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+lsapm.module$(EXEEXT): $(lsapm_module_OBJECTS) $(lsapm_module_DEPENDENCIES) $(EXTRA_lsapm_module_DEPENDENCIES)
+ @rm -f lsapm.module$(EXEEXT)
+ $(AM_V_CCLD)$(lsapm_module_LINK) $(lsapm_module_OBJECTS) $(lsapm_module_LDADD) $(LIBS)
+commands/arc/$(am__dirstamp):
+ @$(MKDIR_P) commands/arc
+ @: > commands/arc/$(am__dirstamp)
+commands/arc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) commands/arc/$(DEPDIR)
+ @: > commands/arc/$(DEPDIR)/$(am__dirstamp)
+commands/arc/lsdev_module-lsdev.$(OBJEXT): \
+ commands/arc/$(am__dirstamp) \
+ commands/arc/$(DEPDIR)/$(am__dirstamp)
+
+lsdev.module$(EXEEXT): $(lsdev_module_OBJECTS) $(lsdev_module_DEPENDENCIES) $(EXTRA_lsdev_module_DEPENDENCIES)
+ @rm -f lsdev.module$(EXEEXT)
+ $(AM_V_CCLD)$(lsdev_module_LINK) $(lsdev_module_OBJECTS) $(lsdev_module_LDADD) $(LIBS)
+commands/efi/lsefi_module-lsefi.$(OBJEXT): \
+ commands/efi/$(am__dirstamp) \
+ commands/efi/$(DEPDIR)/$(am__dirstamp)
+
+lsefi.module$(EXEEXT): $(lsefi_module_OBJECTS) $(lsefi_module_DEPENDENCIES) $(EXTRA_lsefi_module_DEPENDENCIES)
+ @rm -f lsefi.module$(EXEEXT)
+ $(AM_V_CCLD)$(lsefi_module_LINK) $(lsefi_module_OBJECTS) $(lsefi_module_LDADD) $(LIBS)
+commands/efi/lsefimmap_module-lsefimmap.$(OBJEXT): \
+ commands/efi/$(am__dirstamp) \
+ commands/efi/$(DEPDIR)/$(am__dirstamp)
+
+lsefimmap.module$(EXEEXT): $(lsefimmap_module_OBJECTS) $(lsefimmap_module_DEPENDENCIES) $(EXTRA_lsefimmap_module_DEPENDENCIES)
+ @rm -f lsefimmap.module$(EXEEXT)
+ $(AM_V_CCLD)$(lsefimmap_module_LINK) $(lsefimmap_module_OBJECTS) $(lsefimmap_module_LDADD) $(LIBS)
+commands/efi/lsefisystab_module-lsefisystab.$(OBJEXT): \
+ commands/efi/$(am__dirstamp) \
+ commands/efi/$(DEPDIR)/$(am__dirstamp)
+
+lsefisystab.module$(EXEEXT): $(lsefisystab_module_OBJECTS) $(lsefisystab_module_DEPENDENCIES) $(EXTRA_lsefisystab_module_DEPENDENCIES)
+ @rm -f lsefisystab.module$(EXEEXT)
+ $(AM_V_CCLD)$(lsefisystab_module_LINK) $(lsefisystab_module_OBJECTS) $(lsefisystab_module_LDADD) $(LIBS)
+commands/lsmmap_module-lsmmap.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+lsmmap.module$(EXEEXT): $(lsmmap_module_OBJECTS) $(lsmmap_module_DEPENDENCIES) $(EXTRA_lsmmap_module_DEPENDENCIES)
+ @rm -f lsmmap.module$(EXEEXT)
+ $(AM_V_CCLD)$(lsmmap_module_LINK) $(lsmmap_module_OBJECTS) $(lsmmap_module_LDADD) $(LIBS)
+commands/lspci_module-lspci.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+lspci.module$(EXEEXT): $(lspci_module_OBJECTS) $(lspci_module_DEPENDENCIES) $(EXTRA_lspci_module_DEPENDENCIES)
+ @rm -f lspci.module$(EXEEXT)
+ $(AM_V_CCLD)$(lspci_module_LINK) $(lspci_module_OBJECTS) $(lspci_module_LDADD) $(LIBS)
+commands/efi/lssal_module-lssal.$(OBJEXT): \
+ commands/efi/$(am__dirstamp) \
+ commands/efi/$(DEPDIR)/$(am__dirstamp)
+
+lssal.module$(EXEEXT): $(lssal_module_OBJECTS) $(lssal_module_DEPENDENCIES) $(EXTRA_lssal_module_DEPENDENCIES)
+ @rm -f lssal.module$(EXEEXT)
+ $(AM_V_CCLD)$(lssal_module_LINK) $(lssal_module_OBJECTS) $(lssal_module_LDADD) $(LIBS)
+commands/mips/loongson/$(am__dirstamp):
+ @$(MKDIR_P) commands/mips/loongson
+ @: > commands/mips/loongson/$(am__dirstamp)
+commands/mips/loongson/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) commands/mips/loongson/$(DEPDIR)
+ @: > commands/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+commands/mips/loongson/lsspd_module-lsspd.$(OBJEXT): \
+ commands/mips/loongson/$(am__dirstamp) \
+ commands/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+
+lsspd.module$(EXEEXT): $(lsspd_module_OBJECTS) $(lsspd_module_DEPENDENCIES) $(EXTRA_lsspd_module_DEPENDENCIES)
+ @rm -f lsspd.module$(EXEEXT)
+ $(AM_V_CCLD)$(lsspd_module_LINK) $(lsspd_module_OBJECTS) $(lsspd_module_LDADD) $(LIBS)
+commands/xen/$(am__dirstamp):
+ @$(MKDIR_P) commands/xen
+ @: > commands/xen/$(am__dirstamp)
+commands/xen/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) commands/xen/$(DEPDIR)
+ @: > commands/xen/$(DEPDIR)/$(am__dirstamp)
+commands/xen/lsxen_module-lsxen.$(OBJEXT): \
+ commands/xen/$(am__dirstamp) \
+ commands/xen/$(DEPDIR)/$(am__dirstamp)
+
+lsxen.module$(EXEEXT): $(lsxen_module_OBJECTS) $(lsxen_module_DEPENDENCIES) $(EXTRA_lsxen_module_DEPENDENCIES)
+ @rm -f lsxen.module$(EXEEXT)
+ $(AM_V_CCLD)$(lsxen_module_LINK) $(lsxen_module_OBJECTS) $(lsxen_module_LDADD) $(LIBS)
+disk/luks_module-luks.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+luks.module$(EXEEXT): $(luks_module_OBJECTS) $(luks_module_DEPENDENCIES) $(EXTRA_luks_module_DEPENDENCIES)
+ @rm -f luks.module$(EXEEXT)
+ $(AM_V_CCLD)$(luks_module_LINK) $(luks_module_OBJECTS) $(luks_module_LDADD) $(LIBS)
+disk/luks2_module-luks2.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+lib/gnulib/$(am__dirstamp):
+ @$(MKDIR_P) lib/gnulib
+ @: > lib/gnulib/$(am__dirstamp)
+lib/gnulib/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/gnulib/$(DEPDIR)
+ @: > lib/gnulib/$(DEPDIR)/$(am__dirstamp)
+lib/gnulib/luks2_module-base64.$(OBJEXT): lib/gnulib/$(am__dirstamp) \
+ lib/gnulib/$(DEPDIR)/$(am__dirstamp)
+
+luks2.module$(EXEEXT): $(luks2_module_OBJECTS) $(luks2_module_DEPENDENCIES) $(EXTRA_luks2_module_DEPENDENCIES)
+ @rm -f luks2.module$(EXEEXT)
+ $(AM_V_CCLD)$(luks2_module_LINK) $(luks2_module_OBJECTS) $(luks2_module_LDADD) $(LIBS)
+disk/lvm_module-lvm.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+lvm.module$(EXEEXT): $(lvm_module_OBJECTS) $(lvm_module_DEPENDENCIES) $(EXTRA_lvm_module_DEPENDENCIES)
+ @rm -f lvm.module$(EXEEXT)
+ $(AM_V_CCLD)$(lvm_module_LINK) $(lvm_module_OBJECTS) $(lvm_module_LDADD) $(LIBS)
+boot/i386/pc/lzma_decompress_image-startup_raw.$(OBJEXT): \
+ boot/i386/pc/$(am__dirstamp) \
+ boot/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+lzma_decompress.image$(EXEEXT): $(lzma_decompress_image_OBJECTS) $(lzma_decompress_image_DEPENDENCIES) $(EXTRA_lzma_decompress_image_DEPENDENCIES)
+ @rm -f lzma_decompress.image$(EXEEXT)
+ $(AM_V_CCLD)$(lzma_decompress_image_LINK) $(lzma_decompress_image_OBJECTS) $(lzma_decompress_image_LDADD) $(LIBS)
+io/lzopio_module-lzopio.$(OBJEXT): io/$(am__dirstamp) \
+ io/$(DEPDIR)/$(am__dirstamp)
+lib/minilzo/$(am__dirstamp):
+ @$(MKDIR_P) lib/minilzo
+ @: > lib/minilzo/$(am__dirstamp)
+lib/minilzo/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/minilzo/$(DEPDIR)
+ @: > lib/minilzo/$(DEPDIR)/$(am__dirstamp)
+lib/minilzo/lzopio_module-minilzo.$(OBJEXT): \
+ lib/minilzo/$(am__dirstamp) \
+ lib/minilzo/$(DEPDIR)/$(am__dirstamp)
+
+lzopio.module$(EXEEXT): $(lzopio_module_OBJECTS) $(lzopio_module_DEPENDENCIES) $(EXTRA_lzopio_module_DEPENDENCIES)
+ @rm -f lzopio.module$(EXEEXT)
+ $(AM_V_CCLD)$(lzopio_module_LINK) $(lzopio_module_OBJECTS) $(lzopio_module_LDADD) $(LIBS)
+commands/macbless_module-macbless.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+macbless.module$(EXEEXT): $(macbless_module_OBJECTS) $(macbless_module_DEPENDENCIES) $(EXTRA_macbless_module_DEPENDENCIES)
+ @rm -f macbless.module$(EXEEXT)
+ $(AM_V_CCLD)$(macbless_module_LINK) $(macbless_module_OBJECTS) $(macbless_module_LDADD) $(LIBS)
+loader/macho_module-macho.$(OBJEXT): loader/$(am__dirstamp) \
+ loader/$(DEPDIR)/$(am__dirstamp)
+loader/macho_module-macho32.$(OBJEXT): loader/$(am__dirstamp) \
+ loader/$(DEPDIR)/$(am__dirstamp)
+loader/macho_module-macho64.$(OBJEXT): loader/$(am__dirstamp) \
+ loader/$(DEPDIR)/$(am__dirstamp)
+loader/macho_module-lzss.$(OBJEXT): loader/$(am__dirstamp) \
+ loader/$(DEPDIR)/$(am__dirstamp)
+
+macho.module$(EXEEXT): $(macho_module_OBJECTS) $(macho_module_DEPENDENCIES) $(EXTRA_macho_module_DEPENDENCIES)
+ @rm -f macho.module$(EXEEXT)
+ $(AM_V_CCLD)$(macho_module_LINK) $(macho_module_OBJECTS) $(macho_module_LDADD) $(LIBS)
+term/i386/pc/mda_text_module-mda_text.$(OBJEXT): \
+ term/i386/pc/$(am__dirstamp) \
+ term/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+mda_text.module$(EXEEXT): $(mda_text_module_OBJECTS) $(mda_text_module_DEPENDENCIES) $(EXTRA_mda_text_module_DEPENDENCIES)
+ @rm -f mda_text.module$(EXEEXT)
+ $(AM_V_CCLD)$(mda_text_module_LINK) $(mda_text_module_OBJECTS) $(mda_text_module_LDADD) $(LIBS)
+disk/mdraid09_module-mdraid_linux.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+mdraid09.module$(EXEEXT): $(mdraid09_module_OBJECTS) $(mdraid09_module_DEPENDENCIES) $(EXTRA_mdraid09_module_DEPENDENCIES)
+ @rm -f mdraid09.module$(EXEEXT)
+ $(AM_V_CCLD)$(mdraid09_module_LINK) $(mdraid09_module_OBJECTS) $(mdraid09_module_LDADD) $(LIBS)
+disk/mdraid09_be_module-mdraid_linux_be.$(OBJEXT): \
+ disk/$(am__dirstamp) disk/$(DEPDIR)/$(am__dirstamp)
+
+mdraid09_be.module$(EXEEXT): $(mdraid09_be_module_OBJECTS) $(mdraid09_be_module_DEPENDENCIES) $(EXTRA_mdraid09_be_module_DEPENDENCIES)
+ @rm -f mdraid09_be.module$(EXEEXT)
+ $(AM_V_CCLD)$(mdraid09_be_module_LINK) $(mdraid09_be_module_OBJECTS) $(mdraid09_be_module_LDADD) $(LIBS)
+disk/mdraid1x_module-mdraid1x_linux.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+mdraid1x.module$(EXEEXT): $(mdraid1x_module_OBJECTS) $(mdraid1x_module_DEPENDENCIES) $(EXTRA_mdraid1x_module_DEPENDENCIES)
+ @rm -f mdraid1x.module$(EXEEXT)
+ $(AM_V_CCLD)$(mdraid1x_module_LINK) $(mdraid1x_module_OBJECTS) $(mdraid1x_module_LDADD) $(LIBS)
+disk/memdisk_module-memdisk.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+memdisk.module$(EXEEXT): $(memdisk_module_OBJECTS) $(memdisk_module_DEPENDENCIES) $(EXTRA_memdisk_module_DEPENDENCIES)
+ @rm -f memdisk.module$(EXEEXT)
+ $(AM_V_CCLD)$(memdisk_module_LINK) $(memdisk_module_OBJECTS) $(memdisk_module_LDADD) $(LIBS)
+commands/memrw_module-memrw.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+memrw.module$(EXEEXT): $(memrw_module_OBJECTS) $(memrw_module_DEPENDENCIES) $(EXTRA_memrw_module_DEPENDENCIES)
+ @rm -f memrw.module$(EXEEXT)
+ $(AM_V_CCLD)$(memrw_module_LINK) $(memrw_module_OBJECTS) $(memrw_module_LDADD) $(LIBS)
+commands/minicmd_module-minicmd.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+minicmd.module$(EXEEXT): $(minicmd_module_OBJECTS) $(minicmd_module_DEPENDENCIES) $(EXTRA_minicmd_module_DEPENDENCIES)
+ @rm -f minicmd.module$(EXEEXT)
+ $(AM_V_CCLD)$(minicmd_module_LINK) $(minicmd_module_OBJECTS) $(minicmd_module_LDADD) $(LIBS)
+fs/minix_module-minix.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+minix.module$(EXEEXT): $(minix_module_OBJECTS) $(minix_module_DEPENDENCIES) $(EXTRA_minix_module_DEPENDENCIES)
+ @rm -f minix.module$(EXEEXT)
+ $(AM_V_CCLD)$(minix_module_LINK) $(minix_module_OBJECTS) $(minix_module_LDADD) $(LIBS)
+fs/minix2_module-minix2.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+minix2.module$(EXEEXT): $(minix2_module_OBJECTS) $(minix2_module_DEPENDENCIES) $(EXTRA_minix2_module_DEPENDENCIES)
+ @rm -f minix2.module$(EXEEXT)
+ $(AM_V_CCLD)$(minix2_module_LINK) $(minix2_module_OBJECTS) $(minix2_module_LDADD) $(LIBS)
+fs/minix2_be_module-minix2_be.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+minix2_be.module$(EXEEXT): $(minix2_be_module_OBJECTS) $(minix2_be_module_DEPENDENCIES) $(EXTRA_minix2_be_module_DEPENDENCIES)
+ @rm -f minix2_be.module$(EXEEXT)
+ $(AM_V_CCLD)$(minix2_be_module_LINK) $(minix2_be_module_OBJECTS) $(minix2_be_module_LDADD) $(LIBS)
+fs/minix3_module-minix3.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+minix3.module$(EXEEXT): $(minix3_module_OBJECTS) $(minix3_module_DEPENDENCIES) $(EXTRA_minix3_module_DEPENDENCIES)
+ @rm -f minix3.module$(EXEEXT)
+ $(AM_V_CCLD)$(minix3_module_LINK) $(minix3_module_OBJECTS) $(minix3_module_LDADD) $(LIBS)
+fs/minix3_be_module-minix3_be.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+minix3_be.module$(EXEEXT): $(minix3_be_module_OBJECTS) $(minix3_be_module_DEPENDENCIES) $(EXTRA_minix3_be_module_DEPENDENCIES)
+ @rm -f minix3_be.module$(EXEEXT)
+ $(AM_V_CCLD)$(minix3_be_module_LINK) $(minix3_be_module_OBJECTS) $(minix3_be_module_LDADD) $(LIBS)
+fs/minix_be_module-minix_be.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+minix_be.module$(EXEEXT): $(minix_be_module_OBJECTS) $(minix_be_module_DEPENDENCIES) $(EXTRA_minix_be_module_DEPENDENCIES)
+ @rm -f minix_be.module$(EXEEXT)
+ $(AM_V_CCLD)$(minix_be_module_LINK) $(minix_be_module_OBJECTS) $(minix_be_module_LDADD) $(LIBS)
+mmap/efi/$(am__dirstamp):
+ @$(MKDIR_P) mmap/efi
+ @: > mmap/efi/$(am__dirstamp)
+mmap/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) mmap/efi/$(DEPDIR)
+ @: > mmap/efi/$(DEPDIR)/$(am__dirstamp)
+mmap/efi/mmap_module-mmap.$(OBJEXT): mmap/efi/$(am__dirstamp) \
+ mmap/efi/$(DEPDIR)/$(am__dirstamp)
+mmap/$(am__dirstamp):
+ @$(MKDIR_P) mmap
+ @: > mmap/$(am__dirstamp)
+mmap/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) mmap/$(DEPDIR)
+ @: > mmap/$(DEPDIR)/$(am__dirstamp)
+mmap/mmap_module-mmap.$(OBJEXT): mmap/$(am__dirstamp) \
+ mmap/$(DEPDIR)/$(am__dirstamp)
+mmap/i386/$(am__dirstamp):
+ @$(MKDIR_P) mmap/i386
+ @: > mmap/i386/$(am__dirstamp)
+mmap/i386/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) mmap/i386/$(DEPDIR)
+ @: > mmap/i386/$(DEPDIR)/$(am__dirstamp)
+mmap/i386/mmap_module-uppermem.$(OBJEXT): mmap/i386/$(am__dirstamp) \
+ mmap/i386/$(DEPDIR)/$(am__dirstamp)
+mmap/i386/mmap_module-mmap.$(OBJEXT): mmap/i386/$(am__dirstamp) \
+ mmap/i386/$(DEPDIR)/$(am__dirstamp)
+mmap/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) mmap/i386/pc
+ @: > mmap/i386/pc/$(am__dirstamp)
+mmap/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) mmap/i386/pc/$(DEPDIR)
+ @: > mmap/i386/pc/$(DEPDIR)/$(am__dirstamp)
+mmap/i386/pc/mmap_module-mmap.$(OBJEXT): mmap/i386/pc/$(am__dirstamp) \
+ mmap/i386/pc/$(DEPDIR)/$(am__dirstamp)
+mmap/i386/pc/mmap_module-mmap_helper.$(OBJEXT): \
+ mmap/i386/pc/$(am__dirstamp) \
+ mmap/i386/pc/$(DEPDIR)/$(am__dirstamp)
+mmap/mips/$(am__dirstamp):
+ @$(MKDIR_P) mmap/mips
+ @: > mmap/mips/$(am__dirstamp)
+mmap/mips/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) mmap/mips/$(DEPDIR)
+ @: > mmap/mips/$(DEPDIR)/$(am__dirstamp)
+mmap/mips/mmap_module-uppermem.$(OBJEXT): mmap/mips/$(am__dirstamp) \
+ mmap/mips/$(DEPDIR)/$(am__dirstamp)
+
+mmap.module$(EXEEXT): $(mmap_module_OBJECTS) $(mmap_module_DEPENDENCIES) $(EXTRA_mmap_module_DEPENDENCIES)
+ @rm -f mmap.module$(EXEEXT)
+ $(AM_V_CCLD)$(mmap_module_LINK) $(mmap_module_OBJECTS) $(mmap_module_LDADD) $(LIBS)
+term/morse_module-morse.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+
+morse.module$(EXEEXT): $(morse_module_OBJECTS) $(morse_module_DEPENDENCIES) $(EXTRA_morse_module_DEPENDENCIES)
+ @rm -f morse.module$(EXEEXT)
+ $(AM_V_CCLD)$(morse_module_LINK) $(morse_module_OBJECTS) $(morse_module_LDADD) $(LIBS)
+lib/libgcrypt-grub/mpi/$(am__dirstamp):
+ @$(MKDIR_P) lib/libgcrypt-grub/mpi
+ @: > lib/libgcrypt-grub/mpi/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/libgcrypt-grub/mpi/$(DEPDIR)
+ @: > lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpiutil.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-add.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-div.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpih-div.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpicoder.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.$(OBJEXT): \
+ lib/libgcrypt-grub/mpi/$(am__dirstamp) \
+ lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt_wrap/$(am__dirstamp):
+ @$(MKDIR_P) lib/libgcrypt_wrap
+ @: > lib/libgcrypt_wrap/$(am__dirstamp)
+lib/libgcrypt_wrap/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/libgcrypt_wrap/$(DEPDIR)
+ @: > lib/libgcrypt_wrap/$(DEPDIR)/$(am__dirstamp)
+lib/libgcrypt_wrap/mpi_module-mem.$(OBJEXT): \
+ lib/libgcrypt_wrap/$(am__dirstamp) \
+ lib/libgcrypt_wrap/$(DEPDIR)/$(am__dirstamp)
+
+mpi.module$(EXEEXT): $(mpi_module_OBJECTS) $(mpi_module_DEPENDENCIES) $(EXTRA_mpi_module_DEPENDENCIES)
+ @rm -f mpi.module$(EXEEXT)
+ $(AM_V_CCLD)$(mpi_module_LINK) $(mpi_module_OBJECTS) $(mpi_module_LDADD) $(LIBS)
+parttool/$(am__dirstamp):
+ @$(MKDIR_P) parttool
+ @: > parttool/$(am__dirstamp)
+parttool/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) parttool/$(DEPDIR)
+ @: > parttool/$(DEPDIR)/$(am__dirstamp)
+parttool/msdospart_module-msdospart.$(OBJEXT): \
+ parttool/$(am__dirstamp) parttool/$(DEPDIR)/$(am__dirstamp)
+
+msdospart.module$(EXEEXT): $(msdospart_module_OBJECTS) $(msdospart_module_DEPENDENCIES) $(EXTRA_msdospart_module_DEPENDENCIES)
+ @rm -f msdospart.module$(EXEEXT)
+ $(AM_V_CCLD)$(msdospart_module_LINK) $(msdospart_module_OBJECTS) $(msdospart_module_LDADD) $(LIBS)
+tests/mul_test_module-mul_test.$(OBJEXT): tests/$(am__dirstamp) \
+ tests/$(DEPDIR)/$(am__dirstamp)
+
+mul_test.module$(EXEEXT): $(mul_test_module_OBJECTS) $(mul_test_module_DEPENDENCIES) $(EXTRA_mul_test_module_DEPENDENCIES)
+ @rm -f mul_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(mul_test_module_LINK) $(mul_test_module_OBJECTS) $(mul_test_module_LDADD) $(LIBS)
+loader/i386/multiboot_module-multiboot_mbi.$(OBJEXT): \
+ loader/i386/$(am__dirstamp) \
+ loader/i386/$(DEPDIR)/$(am__dirstamp)
+loader/multiboot_module-multiboot.$(OBJEXT): loader/$(am__dirstamp) \
+ loader/$(DEPDIR)/$(am__dirstamp)
+
+multiboot.module$(EXEEXT): $(multiboot_module_OBJECTS) $(multiboot_module_DEPENDENCIES) $(EXTRA_multiboot_module_DEPENDENCIES)
+ @rm -f multiboot.module$(EXEEXT)
+ $(AM_V_CCLD)$(multiboot_module_LINK) $(multiboot_module_OBJECTS) $(multiboot_module_LDADD) $(LIBS)
+loader/multiboot2_module-multiboot.$(OBJEXT): loader/$(am__dirstamp) \
+ loader/$(DEPDIR)/$(am__dirstamp)
+loader/multiboot2_module-multiboot_mbi2.$(OBJEXT): \
+ loader/$(am__dirstamp) loader/$(DEPDIR)/$(am__dirstamp)
+
+multiboot2.module$(EXEEXT): $(multiboot2_module_OBJECTS) $(multiboot2_module_DEPENDENCIES) $(EXTRA_multiboot2_module_DEPENDENCIES)
+ @rm -f multiboot2.module$(EXEEXT)
+ $(AM_V_CCLD)$(multiboot2_module_LINK) $(multiboot2_module_OBJECTS) $(multiboot2_module_LDADD) $(LIBS)
+disk/ieee1275/nand_module-nand.$(OBJEXT): \
+ disk/ieee1275/$(am__dirstamp) \
+ disk/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+nand.module$(EXEEXT): $(nand_module_OBJECTS) $(nand_module_DEPENDENCIES) $(EXTRA_nand_module_DEPENDENCIES)
+ @rm -f nand.module$(EXEEXT)
+ $(AM_V_CCLD)$(nand_module_LINK) $(nand_module_OBJECTS) $(nand_module_LDADD) $(LIBS)
+commands/nativedisk_module-nativedisk.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+nativedisk.module$(EXEEXT): $(nativedisk_module_OBJECTS) $(nativedisk_module_DEPENDENCIES) $(EXTRA_nativedisk_module_DEPENDENCIES)
+ @rm -f nativedisk.module$(EXEEXT)
+ $(AM_V_CCLD)$(nativedisk_module_LINK) $(nativedisk_module_OBJECTS) $(nativedisk_module_LDADD) $(LIBS)
+net/net_module-net.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+net/net_module-dns.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+net/net_module-bootp.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+net/net_module-ip.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+net/net_module-udp.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+net/net_module-tcp.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+net/net_module-icmp.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+net/net_module-icmp6.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+net/net_module-ethernet.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+net/net_module-arp.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+net/net_module-netbuff.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+
+net.module$(EXEEXT): $(net_module_OBJECTS) $(net_module_DEPENDENCIES) $(EXTRA_net_module_DEPENDENCIES)
+ @rm -f net.module$(EXEEXT)
+ $(AM_V_CCLD)$(net_module_LINK) $(net_module_OBJECTS) $(net_module_LDADD) $(LIBS)
+fs/newc_module-newc.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+newc.module$(EXEEXT): $(newc_module_OBJECTS) $(newc_module_DEPENDENCIES) $(EXTRA_newc_module_DEPENDENCIES)
+ @rm -f newc.module$(EXEEXT)
+ $(AM_V_CCLD)$(newc_module_LINK) $(newc_module_OBJECTS) $(newc_module_LDADD) $(LIBS)
+fs/nilfs2_module-nilfs2.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+nilfs2.module$(EXEEXT): $(nilfs2_module_OBJECTS) $(nilfs2_module_DEPENDENCIES) $(EXTRA_nilfs2_module_DEPENDENCIES)
+ @rm -f nilfs2.module$(EXEEXT)
+ $(AM_V_CCLD)$(nilfs2_module_LINK) $(nilfs2_module_OBJECTS) $(nilfs2_module_LDADD) $(LIBS)
+boot/mips/$(am__dirstamp):
+ @$(MKDIR_P) boot/mips
+ @: > boot/mips/$(am__dirstamp)
+boot/mips/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) boot/mips/$(DEPDIR)
+ @: > boot/mips/$(DEPDIR)/$(am__dirstamp)
+boot/mips/none_decompress_image-startup_raw.$(OBJEXT): \
+ boot/mips/$(am__dirstamp) boot/mips/$(DEPDIR)/$(am__dirstamp)
+boot/decompressor/$(am__dirstamp):
+ @$(MKDIR_P) boot/decompressor
+ @: > boot/decompressor/$(am__dirstamp)
+boot/decompressor/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) boot/decompressor/$(DEPDIR)
+ @: > boot/decompressor/$(DEPDIR)/$(am__dirstamp)
+boot/decompressor/none_decompress_image-none.$(OBJEXT): \
+ boot/decompressor/$(am__dirstamp) \
+ boot/decompressor/$(DEPDIR)/$(am__dirstamp)
+
+none_decompress.image$(EXEEXT): $(none_decompress_image_OBJECTS) $(none_decompress_image_DEPENDENCIES) $(EXTRA_none_decompress_image_DEPENDENCIES)
+ @rm -f none_decompress.image$(EXEEXT)
+ $(AM_V_CCLD)$(none_decompress_image_LINK) $(none_decompress_image_OBJECTS) $(none_decompress_image_LDADD) $(LIBS)
+normal/$(am__dirstamp):
+ @$(MKDIR_P) normal
+ @: > normal/$(am__dirstamp)
+normal/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) normal/$(DEPDIR)
+ @: > normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-main.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-cmdline.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-dyncmd.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-auth.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-autofs.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-color.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-completion.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-menu.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-menu_entry.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-menu_text.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-misc.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-crypto.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-term.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-context.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+normal/normal_module-charset.$(OBJEXT): normal/$(am__dirstamp) \
+ normal/$(DEPDIR)/$(am__dirstamp)
+lib/normal_module-getline.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+script/$(am__dirstamp):
+ @$(MKDIR_P) script
+ @: > script/$(am__dirstamp)
+script/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) script/$(DEPDIR)
+ @: > script/$(DEPDIR)/$(am__dirstamp)
+script/normal_module-main.$(OBJEXT): script/$(am__dirstamp) \
+ script/$(DEPDIR)/$(am__dirstamp)
+script/normal_module-script.$(OBJEXT): script/$(am__dirstamp) \
+ script/$(DEPDIR)/$(am__dirstamp)
+script/normal_module-execute.$(OBJEXT): script/$(am__dirstamp) \
+ script/$(DEPDIR)/$(am__dirstamp)
+script/normal_module-function.$(OBJEXT): script/$(am__dirstamp) \
+ script/$(DEPDIR)/$(am__dirstamp)
+script/normal_module-lexer.$(OBJEXT): script/$(am__dirstamp) \
+ script/$(DEPDIR)/$(am__dirstamp)
+script/normal_module-argv.$(OBJEXT): script/$(am__dirstamp) \
+ script/$(DEPDIR)/$(am__dirstamp)
+commands/normal_module-menuentry.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+normal.module$(EXEEXT): $(normal_module_OBJECTS) $(normal_module_DEPENDENCIES) $(EXTRA_normal_module_DEPENDENCIES)
+ @rm -f normal.module$(EXEEXT)
+ $(AM_V_CCLD)$(normal_module_LINK) $(normal_module_OBJECTS) $(normal_module_LDADD) $(LIBS)
+fs/ntfs_module-ntfs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+ntfs.module$(EXEEXT): $(ntfs_module_OBJECTS) $(ntfs_module_DEPENDENCIES) $(EXTRA_ntfs_module_DEPENDENCIES)
+ @rm -f ntfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(ntfs_module_LINK) $(ntfs_module_OBJECTS) $(ntfs_module_LDADD) $(LIBS)
+fs/ntfscomp_module-ntfscomp.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+ntfscomp.module$(EXEEXT): $(ntfscomp_module_OBJECTS) $(ntfscomp_module_DEPENDENCIES) $(EXTRA_ntfscomp_module_DEPENDENCIES)
+ @rm -f ntfscomp.module$(EXEEXT)
+ $(AM_V_CCLD)$(ntfscomp_module_LINK) $(ntfscomp_module_OBJECTS) $(ntfscomp_module_LDADD) $(LIBS)
+loader/i386/pc/ntldr_module-ntldr.$(OBJEXT): \
+ loader/i386/pc/$(am__dirstamp) \
+ loader/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+ntldr.module$(EXEEXT): $(ntldr_module_OBJECTS) $(ntldr_module_DEPENDENCIES) $(EXTRA_ntldr_module_DEPENDENCIES)
+ @rm -f ntldr.module$(EXEEXT)
+ $(AM_V_CCLD)$(ntldr_module_LINK) $(ntldr_module_OBJECTS) $(ntldr_module_LDADD) $(LIBS)
+fs/odc_module-odc.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+odc.module$(EXEEXT): $(odc_module_OBJECTS) $(odc_module_DEPENDENCIES) $(EXTRA_odc_module_DEPENDENCIES)
+ @rm -f odc.module$(EXEEXT)
+ $(AM_V_CCLD)$(odc_module_LINK) $(odc_module_OBJECTS) $(odc_module_LDADD) $(LIBS)
+io/offsetio_module-offset.$(OBJEXT): io/$(am__dirstamp) \
+ io/$(DEPDIR)/$(am__dirstamp)
+
+offsetio.module$(EXEEXT): $(offsetio_module_OBJECTS) $(offsetio_module_DEPENDENCIES) $(EXTRA_offsetio_module_DEPENDENCIES)
+ @rm -f offsetio.module$(EXEEXT)
+ $(AM_V_CCLD)$(offsetio_module_LINK) $(offsetio_module_OBJECTS) $(offsetio_module_LDADD) $(LIBS)
+net/drivers/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) net/drivers/ieee1275
+ @: > net/drivers/ieee1275/$(am__dirstamp)
+net/drivers/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) net/drivers/ieee1275/$(DEPDIR)
+ @: > net/drivers/ieee1275/$(DEPDIR)/$(am__dirstamp)
+net/drivers/ieee1275/ofnet_module-ofnet.$(OBJEXT): \
+ net/drivers/ieee1275/$(am__dirstamp) \
+ net/drivers/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+ofnet.module$(EXEEXT): $(ofnet_module_OBJECTS) $(ofnet_module_DEPENDENCIES) $(EXTRA_ofnet_module_DEPENDENCIES)
+ @rm -f ofnet.module$(EXEEXT)
+ $(AM_V_CCLD)$(ofnet_module_LINK) $(ofnet_module_OBJECTS) $(ofnet_module_LDADD) $(LIBS)
+bus/usb/ohci_module-ohci.$(OBJEXT): bus/usb/$(am__dirstamp) \
+ bus/usb/$(DEPDIR)/$(am__dirstamp)
+
+ohci.module$(EXEEXT): $(ohci_module_OBJECTS) $(ohci_module_DEPENDENCIES) $(EXTRA_ohci_module_DEPENDENCIES)
+ @rm -f ohci.module$(EXEEXT)
+ $(AM_V_CCLD)$(ohci_module_LINK) $(ohci_module_OBJECTS) $(ohci_module_LDADD) $(LIBS)
+partmap/$(am__dirstamp):
+ @$(MKDIR_P) partmap
+ @: > partmap/$(am__dirstamp)
+partmap/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) partmap/$(DEPDIR)
+ @: > partmap/$(DEPDIR)/$(am__dirstamp)
+partmap/part_acorn_module-acorn.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_acorn.module$(EXEEXT): $(part_acorn_module_OBJECTS) $(part_acorn_module_DEPENDENCIES) $(EXTRA_part_acorn_module_DEPENDENCIES)
+ @rm -f part_acorn.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_acorn_module_LINK) $(part_acorn_module_OBJECTS) $(part_acorn_module_LDADD) $(LIBS)
+partmap/part_amiga_module-amiga.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_amiga.module$(EXEEXT): $(part_amiga_module_OBJECTS) $(part_amiga_module_DEPENDENCIES) $(EXTRA_part_amiga_module_DEPENDENCIES)
+ @rm -f part_amiga.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_amiga_module_LINK) $(part_amiga_module_OBJECTS) $(part_amiga_module_LDADD) $(LIBS)
+partmap/part_apple_module-apple.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_apple.module$(EXEEXT): $(part_apple_module_OBJECTS) $(part_apple_module_DEPENDENCIES) $(EXTRA_part_apple_module_DEPENDENCIES)
+ @rm -f part_apple.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_apple_module_LINK) $(part_apple_module_OBJECTS) $(part_apple_module_LDADD) $(LIBS)
+partmap/part_bsd_module-bsdlabel.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_bsd.module$(EXEEXT): $(part_bsd_module_OBJECTS) $(part_bsd_module_DEPENDENCIES) $(EXTRA_part_bsd_module_DEPENDENCIES)
+ @rm -f part_bsd.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_bsd_module_LINK) $(part_bsd_module_OBJECTS) $(part_bsd_module_LDADD) $(LIBS)
+partmap/part_dfly_module-dfly.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_dfly.module$(EXEEXT): $(part_dfly_module_OBJECTS) $(part_dfly_module_DEPENDENCIES) $(EXTRA_part_dfly_module_DEPENDENCIES)
+ @rm -f part_dfly.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_dfly_module_LINK) $(part_dfly_module_OBJECTS) $(part_dfly_module_LDADD) $(LIBS)
+partmap/part_dvh_module-dvh.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_dvh.module$(EXEEXT): $(part_dvh_module_OBJECTS) $(part_dvh_module_DEPENDENCIES) $(EXTRA_part_dvh_module_DEPENDENCIES)
+ @rm -f part_dvh.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_dvh_module_LINK) $(part_dvh_module_OBJECTS) $(part_dvh_module_LDADD) $(LIBS)
+partmap/part_gpt_module-gpt.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_gpt.module$(EXEEXT): $(part_gpt_module_OBJECTS) $(part_gpt_module_DEPENDENCIES) $(EXTRA_part_gpt_module_DEPENDENCIES)
+ @rm -f part_gpt.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_gpt_module_LINK) $(part_gpt_module_OBJECTS) $(part_gpt_module_LDADD) $(LIBS)
+partmap/part_msdos_module-msdos.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_msdos.module$(EXEEXT): $(part_msdos_module_OBJECTS) $(part_msdos_module_DEPENDENCIES) $(EXTRA_part_msdos_module_DEPENDENCIES)
+ @rm -f part_msdos.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_msdos_module_LINK) $(part_msdos_module_OBJECTS) $(part_msdos_module_LDADD) $(LIBS)
+partmap/part_plan_module-plan.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_plan.module$(EXEEXT): $(part_plan_module_OBJECTS) $(part_plan_module_DEPENDENCIES) $(EXTRA_part_plan_module_DEPENDENCIES)
+ @rm -f part_plan.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_plan_module_LINK) $(part_plan_module_OBJECTS) $(part_plan_module_LDADD) $(LIBS)
+partmap/part_sun_module-sun.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_sun.module$(EXEEXT): $(part_sun_module_OBJECTS) $(part_sun_module_DEPENDENCIES) $(EXTRA_part_sun_module_DEPENDENCIES)
+ @rm -f part_sun.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_sun_module_LINK) $(part_sun_module_OBJECTS) $(part_sun_module_LDADD) $(LIBS)
+partmap/part_sunpc_module-sunpc.$(OBJEXT): partmap/$(am__dirstamp) \
+ partmap/$(DEPDIR)/$(am__dirstamp)
+
+part_sunpc.module$(EXEEXT): $(part_sunpc_module_OBJECTS) $(part_sunpc_module_DEPENDENCIES) $(EXTRA_part_sunpc_module_DEPENDENCIES)
+ @rm -f part_sunpc.module$(EXEEXT)
+ $(AM_V_CCLD)$(part_sunpc_module_LINK) $(part_sunpc_module_OBJECTS) $(part_sunpc_module_LDADD) $(LIBS)
+commands/parttool_module-parttool.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+parttool.module$(EXEEXT): $(parttool_module_OBJECTS) $(parttool_module_DEPENDENCIES) $(EXTRA_parttool_module_DEPENDENCIES)
+ @rm -f parttool.module$(EXEEXT)
+ $(AM_V_CCLD)$(parttool_module_LINK) $(parttool_module_OBJECTS) $(parttool_module_LDADD) $(LIBS)
+commands/password_module-password.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+password.module$(EXEEXT): $(password_module_OBJECTS) $(password_module_DEPENDENCIES) $(EXTRA_password_module_DEPENDENCIES)
+ @rm -f password.module$(EXEEXT)
+ $(AM_V_CCLD)$(password_module_LINK) $(password_module_OBJECTS) $(password_module_LDADD) $(LIBS)
+commands/password_pbkdf2_module-password_pbkdf2.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+password_pbkdf2.module$(EXEEXT): $(password_pbkdf2_module_OBJECTS) $(password_pbkdf2_module_DEPENDENCIES) $(EXTRA_password_pbkdf2_module_DEPENDENCIES)
+ @rm -f password_pbkdf2.module$(EXEEXT)
+ $(AM_V_CCLD)$(password_pbkdf2_module_LINK) $(password_pbkdf2_module_OBJECTS) $(password_pbkdf2_module_LDADD) $(LIBS)
+disk/pata_module-pata.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+pata.module$(EXEEXT): $(pata_module_OBJECTS) $(pata_module_DEPENDENCIES) $(EXTRA_pata_module_DEPENDENCIES)
+ @rm -f pata.module$(EXEEXT)
+ $(AM_V_CCLD)$(pata_module_LINK) $(pata_module_OBJECTS) $(pata_module_LDADD) $(LIBS)
+lib/pbkdf2_module-pbkdf2.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+pbkdf2.module$(EXEEXT): $(pbkdf2_module_OBJECTS) $(pbkdf2_module_DEPENDENCIES) $(EXTRA_pbkdf2_module_DEPENDENCIES)
+ @rm -f pbkdf2.module$(EXEEXT)
+ $(AM_V_CCLD)$(pbkdf2_module_LINK) $(pbkdf2_module_OBJECTS) $(pbkdf2_module_LDADD) $(LIBS)
+tests/pbkdf2_test_module-pbkdf2_test.$(OBJEXT): tests/$(am__dirstamp) \
+ tests/$(DEPDIR)/$(am__dirstamp)
+
+pbkdf2_test.module$(EXEEXT): $(pbkdf2_test_module_OBJECTS) $(pbkdf2_test_module_DEPENDENCIES) $(EXTRA_pbkdf2_test_module_DEPENDENCIES)
+ @rm -f pbkdf2_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(pbkdf2_test_module_LINK) $(pbkdf2_test_module_OBJECTS) $(pbkdf2_test_module_LDADD) $(LIBS)
+bus/pci_module-pci.$(OBJEXT): bus/$(am__dirstamp) \
+ bus/$(DEPDIR)/$(am__dirstamp)
+bus/i386/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) bus/i386/ieee1275
+ @: > bus/i386/ieee1275/$(am__dirstamp)
+bus/i386/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) bus/i386/ieee1275/$(DEPDIR)
+ @: > bus/i386/ieee1275/$(DEPDIR)/$(am__dirstamp)
+bus/i386/ieee1275/pci_module-pci.$(OBJEXT): \
+ bus/i386/ieee1275/$(am__dirstamp) \
+ bus/i386/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+pci.module$(EXEEXT): $(pci_module_OBJECTS) $(pci_module_DEPENDENCIES) $(EXTRA_pci_module_DEPENDENCIES)
+ @rm -f pci.module$(EXEEXT)
+ $(AM_V_CCLD)$(pci_module_LINK) $(pci_module_OBJECTS) $(pci_module_LDADD) $(LIBS)
+commands/pcidump_module-pcidump.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+pcidump.module$(EXEEXT): $(pcidump_module_OBJECTS) $(pcidump_module_DEPENDENCIES) $(EXTRA_pcidump_module_DEPENDENCIES)
+ @rm -f pcidump.module$(EXEEXT)
+ $(AM_V_CCLD)$(pcidump_module_LINK) $(pcidump_module_OBJECTS) $(pcidump_module_LDADD) $(LIBS)
+commands/pgp_module-pgp.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+pgp.module$(EXEEXT): $(pgp_module_OBJECTS) $(pgp_module_DEPENDENCIES) $(EXTRA_pgp_module_DEPENDENCIES)
+ @rm -f pgp.module$(EXEEXT)
+ $(AM_V_CCLD)$(pgp_module_LINK) $(pgp_module_OBJECTS) $(pgp_module_LDADD) $(LIBS)
+loader/i386/pc/plan9_module-plan9.$(OBJEXT): \
+ loader/i386/pc/$(am__dirstamp) \
+ loader/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+plan9.module$(EXEEXT): $(plan9_module_OBJECTS) $(plan9_module_DEPENDENCIES) $(EXTRA_plan9_module_DEPENDENCIES)
+ @rm -f plan9.module$(EXEEXT)
+ $(AM_V_CCLD)$(plan9_module_LINK) $(plan9_module_OBJECTS) $(plan9_module_LDADD) $(LIBS)
+commands/i386/pc/play_module-play.$(OBJEXT): \
+ commands/i386/pc/$(am__dirstamp) \
+ commands/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+play.module$(EXEEXT): $(play_module_OBJECTS) $(play_module_DEPENDENCIES) $(EXTRA_play_module_DEPENDENCIES)
+ @rm -f play.module$(EXEEXT)
+ $(AM_V_CCLD)$(play_module_LINK) $(play_module_OBJECTS) $(play_module_LDADD) $(LIBS)
+video/readers/png_module-png.$(OBJEXT): video/readers/$(am__dirstamp) \
+ video/readers/$(DEPDIR)/$(am__dirstamp)
+
+png.module$(EXEEXT): $(png_module_OBJECTS) $(png_module_DEPENDENCIES) $(EXTRA_png_module_DEPENDENCIES)
+ @rm -f png.module$(EXEEXT)
+ $(AM_V_CCLD)$(png_module_LINK) $(png_module_OBJECTS) $(png_module_LDADD) $(LIBS)
+lib/priority_queue_module-priority_queue.$(OBJEXT): \
+ lib/$(am__dirstamp) lib/$(DEPDIR)/$(am__dirstamp)
+
+priority_queue.module$(EXEEXT): $(priority_queue_module_OBJECTS) $(priority_queue_module_DEPENDENCIES) $(EXTRA_priority_queue_module_DEPENDENCIES)
+ @rm -f priority_queue.module$(EXEEXT)
+ $(AM_V_CCLD)$(priority_queue_module_LINK) $(priority_queue_module_OBJECTS) $(priority_queue_module_LDADD) $(LIBS)
+commands/probe_module-probe.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+probe.module$(EXEEXT): $(probe_module_OBJECTS) $(probe_module_DEPENDENCIES) $(EXTRA_probe_module_DEPENDENCIES)
+ @rm -f probe.module$(EXEEXT)
+ $(AM_V_CCLD)$(probe_module_LINK) $(probe_module_OBJECTS) $(probe_module_LDADD) $(LIBS)
+fs/procfs_module-proc.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+procfs.module$(EXEEXT): $(procfs_module_OBJECTS) $(procfs_module_DEPENDENCIES) $(EXTRA_procfs_module_DEPENDENCIES)
+ @rm -f procfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(procfs_module_LINK) $(procfs_module_OBJECTS) $(procfs_module_LDADD) $(LIBS)
+lib/progress_module-progress.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+progress.module$(EXEEXT): $(progress_module_OBJECTS) $(progress_module_DEPENDENCIES) $(EXTRA_progress_module_DEPENDENCIES)
+ @rm -f progress.module$(EXEEXT)
+ $(AM_V_CCLD)$(progress_module_LINK) $(progress_module_OBJECTS) $(progress_module_LDADD) $(LIBS)
+net/drivers/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) net/drivers/i386/pc
+ @: > net/drivers/i386/pc/$(am__dirstamp)
+net/drivers/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) net/drivers/i386/pc/$(DEPDIR)
+ @: > net/drivers/i386/pc/$(DEPDIR)/$(am__dirstamp)
+net/drivers/i386/pc/pxe_module-pxe.$(OBJEXT): \
+ net/drivers/i386/pc/$(am__dirstamp) \
+ net/drivers/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+pxe.module$(EXEEXT): $(pxe_module_OBJECTS) $(pxe_module_DEPENDENCIES) $(EXTRA_pxe_module_DEPENDENCIES)
+ @rm -f pxe.module$(EXEEXT)
+ $(AM_V_CCLD)$(pxe_module_LINK) $(pxe_module_OBJECTS) $(pxe_module_LDADD) $(LIBS)
+boot/i386/pc/pxeboot_image-pxeboot.$(OBJEXT): \
+ boot/i386/pc/$(am__dirstamp) \
+ boot/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+pxeboot.image$(EXEEXT): $(pxeboot_image_OBJECTS) $(pxeboot_image_DEPENDENCIES) $(EXTRA_pxeboot_image_DEPENDENCIES)
+ @rm -f pxeboot.image$(EXEEXT)
+ $(AM_V_CCLD)$(pxeboot_image_LINK) $(pxeboot_image_OBJECTS) $(pxeboot_image_LDADD) $(LIBS)
+loader/i386/pc/pxechain_module-pxechainloader.$(OBJEXT): \
+ loader/i386/pc/$(am__dirstamp) \
+ loader/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+pxechain.module$(EXEEXT): $(pxechain_module_OBJECTS) $(pxechain_module_DEPENDENCIES) $(EXTRA_pxechain_module_DEPENDENCIES)
+ @rm -f pxechain.module$(EXEEXT)
+ $(AM_V_CCLD)$(pxechain_module_LINK) $(pxechain_module_OBJECTS) $(pxechain_module_LDADD) $(LIBS)
+disk/raid5rec_module-raid5_recover.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+raid5rec.module$(EXEEXT): $(raid5rec_module_OBJECTS) $(raid5rec_module_DEPENDENCIES) $(EXTRA_raid5rec_module_DEPENDENCIES)
+ @rm -f raid5rec.module$(EXEEXT)
+ $(AM_V_CCLD)$(raid5rec_module_LINK) $(raid5rec_module_OBJECTS) $(raid5rec_module_LDADD) $(LIBS)
+disk/raid6rec_module-raid6_recover.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+raid6rec.module$(EXEEXT): $(raid6rec_module_OBJECTS) $(raid6rec_module_DEPENDENCIES) $(EXTRA_raid6rec_module_DEPENDENCIES)
+ @rm -f raid6rec.module$(EXEEXT)
+ $(AM_V_CCLD)$(raid6rec_module_LINK) $(raid6rec_module_OBJECTS) $(raid6rec_module_LDADD) $(LIBS)
+kern/i386/random_module-tsc_pmtimer.$(OBJEXT): \
+ kern/i386/$(am__dirstamp) kern/i386/$(DEPDIR)/$(am__dirstamp)
+lib/i386/random_module-random.$(OBJEXT): lib/i386/$(am__dirstamp) \
+ lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/random_module-random.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+random.module$(EXEEXT): $(random_module_OBJECTS) $(random_module_DEPENDENCIES) $(EXTRA_random_module_DEPENDENCIES)
+ @rm -f random.module$(EXEEXT)
+ $(AM_V_CCLD)$(random_module_LINK) $(random_module_OBJECTS) $(random_module_LDADD) $(LIBS)
+commands/i386/rdmsr_module-rdmsr.$(OBJEXT): \
+ commands/i386/$(am__dirstamp) \
+ commands/i386/$(DEPDIR)/$(am__dirstamp)
+
+rdmsr.module$(EXEEXT): $(rdmsr_module_OBJECTS) $(rdmsr_module_DEPENDENCIES) $(EXTRA_rdmsr_module_DEPENDENCIES)
+ @rm -f rdmsr.module$(EXEEXT)
+ $(AM_V_CCLD)$(rdmsr_module_LINK) $(rdmsr_module_OBJECTS) $(rdmsr_module_LDADD) $(LIBS)
+commands/read_module-read.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+read.module$(EXEEXT): $(read_module_OBJECTS) $(read_module_DEPENDENCIES) $(EXTRA_read_module_DEPENDENCIES)
+ @rm -f read.module$(EXEEXT)
+ $(AM_V_CCLD)$(read_module_LINK) $(read_module_OBJECTS) $(read_module_LDADD) $(LIBS)
+commands/reboot_module-reboot.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+lib/dummy/reboot_module-reboot.$(OBJEXT): lib/dummy/$(am__dirstamp) \
+ lib/dummy/$(DEPDIR)/$(am__dirstamp)
+lib/uboot/$(am__dirstamp):
+ @$(MKDIR_P) lib/uboot
+ @: > lib/uboot/$(am__dirstamp)
+lib/uboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/uboot/$(DEPDIR)
+ @: > lib/uboot/$(DEPDIR)/$(am__dirstamp)
+lib/uboot/reboot_module-reboot.$(OBJEXT): lib/uboot/$(am__dirstamp) \
+ lib/uboot/$(DEPDIR)/$(am__dirstamp)
+lib/i386/reboot_module-reboot.$(OBJEXT): lib/i386/$(am__dirstamp) \
+ lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/i386/reboot_module-reboot_trampoline.$(OBJEXT): \
+ lib/i386/$(am__dirstamp) lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/xen/reboot_module-reboot.$(OBJEXT): lib/xen/$(am__dirstamp) \
+ lib/xen/$(DEPDIR)/$(am__dirstamp)
+lib/mips/arc/$(am__dirstamp):
+ @$(MKDIR_P) lib/mips/arc
+ @: > lib/mips/arc/$(am__dirstamp)
+lib/mips/arc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/mips/arc/$(DEPDIR)
+ @: > lib/mips/arc/$(DEPDIR)/$(am__dirstamp)
+lib/mips/arc/reboot_module-reboot.$(OBJEXT): \
+ lib/mips/arc/$(am__dirstamp) \
+ lib/mips/arc/$(DEPDIR)/$(am__dirstamp)
+lib/mips/loongson/$(am__dirstamp):
+ @$(MKDIR_P) lib/mips/loongson
+ @: > lib/mips/loongson/$(am__dirstamp)
+lib/mips/loongson/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/mips/loongson/$(DEPDIR)
+ @: > lib/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+lib/mips/loongson/reboot_module-reboot.$(OBJEXT): \
+ lib/mips/loongson/$(am__dirstamp) \
+ lib/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+lib/mips/qemu_mips/$(am__dirstamp):
+ @$(MKDIR_P) lib/mips/qemu_mips
+ @: > lib/mips/qemu_mips/$(am__dirstamp)
+lib/mips/qemu_mips/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/mips/qemu_mips/$(DEPDIR)
+ @: > lib/mips/qemu_mips/$(DEPDIR)/$(am__dirstamp)
+lib/mips/qemu_mips/reboot_module-reboot.$(OBJEXT): \
+ lib/mips/qemu_mips/$(am__dirstamp) \
+ lib/mips/qemu_mips/$(DEPDIR)/$(am__dirstamp)
+lib/ieee1275/reboot_module-reboot.$(OBJEXT): \
+ lib/ieee1275/$(am__dirstamp) \
+ lib/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+reboot.module$(EXEEXT): $(reboot_module_OBJECTS) $(reboot_module_DEPENDENCIES) $(EXTRA_reboot_module_DEPENDENCIES)
+ @rm -f reboot.module$(EXEEXT)
+ $(AM_V_CCLD)$(reboot_module_LINK) $(reboot_module_OBJECTS) $(reboot_module_LDADD) $(LIBS)
+commands/regexp_module-regexp.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+commands/regexp_module-wildcard.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+lib/gnulib/regexp_module-regex.$(OBJEXT): lib/gnulib/$(am__dirstamp) \
+ lib/gnulib/$(DEPDIR)/$(am__dirstamp)
+
+regexp.module$(EXEEXT): $(regexp_module_OBJECTS) $(regexp_module_DEPENDENCIES) $(EXTRA_regexp_module_DEPENDENCIES)
+ @rm -f regexp.module$(EXEEXT)
+ $(AM_V_CCLD)$(regexp_module_LINK) $(regexp_module_OBJECTS) $(regexp_module_LDADD) $(LIBS)
+fs/reiserfs_module-reiserfs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+reiserfs.module$(EXEEXT): $(reiserfs_module_OBJECTS) $(reiserfs_module_DEPENDENCIES) $(EXTRA_reiserfs_module_DEPENDENCIES)
+ @rm -f reiserfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(reiserfs_module_LINK) $(reiserfs_module_OBJECTS) $(reiserfs_module_LDADD) $(LIBS)
+lib/i386/relocator_module-relocator_asm.$(OBJEXT): \
+ lib/i386/$(am__dirstamp) lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/i386/relocator_module-relocator16.$(OBJEXT): \
+ lib/i386/$(am__dirstamp) lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/i386/relocator_module-relocator32.$(OBJEXT): \
+ lib/i386/$(am__dirstamp) lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/i386/relocator_module-relocator64.$(OBJEXT): \
+ lib/i386/$(am__dirstamp) lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/i386/relocator_module-relocator.$(OBJEXT): \
+ lib/i386/$(am__dirstamp) lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/i386/relocator_module-relocator_common_c.$(OBJEXT): \
+ lib/i386/$(am__dirstamp) lib/i386/$(DEPDIR)/$(am__dirstamp)
+lib/relocator_module-relocator.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+lib/efi/relocator_module-relocator.$(OBJEXT): lib/efi/$(am__dirstamp) \
+ lib/efi/$(DEPDIR)/$(am__dirstamp)
+lib/ieee1275/relocator_module-relocator.$(OBJEXT): \
+ lib/ieee1275/$(am__dirstamp) \
+ lib/ieee1275/$(DEPDIR)/$(am__dirstamp)
+lib/i386/xen/$(am__dirstamp):
+ @$(MKDIR_P) lib/i386/xen
+ @: > lib/i386/xen/$(am__dirstamp)
+lib/i386/xen/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/i386/xen/$(DEPDIR)
+ @: > lib/i386/xen/$(DEPDIR)/$(am__dirstamp)
+lib/i386/xen/relocator_module-relocator.$(OBJEXT): \
+ lib/i386/xen/$(am__dirstamp) \
+ lib/i386/xen/$(DEPDIR)/$(am__dirstamp)
+lib/xen/relocator_module-relocator.$(OBJEXT): lib/xen/$(am__dirstamp) \
+ lib/xen/$(DEPDIR)/$(am__dirstamp)
+lib/mips/$(am__dirstamp):
+ @$(MKDIR_P) lib/mips
+ @: > lib/mips/$(am__dirstamp)
+lib/mips/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/mips/$(DEPDIR)
+ @: > lib/mips/$(DEPDIR)/$(am__dirstamp)
+lib/mips/relocator_module-relocator_asm.$(OBJEXT): \
+ lib/mips/$(am__dirstamp) lib/mips/$(DEPDIR)/$(am__dirstamp)
+lib/mips/relocator_module-relocator.$(OBJEXT): \
+ lib/mips/$(am__dirstamp) lib/mips/$(DEPDIR)/$(am__dirstamp)
+lib/powerpc/$(am__dirstamp):
+ @$(MKDIR_P) lib/powerpc
+ @: > lib/powerpc/$(am__dirstamp)
+lib/powerpc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/powerpc/$(DEPDIR)
+ @: > lib/powerpc/$(DEPDIR)/$(am__dirstamp)
+lib/powerpc/relocator_module-relocator_asm.$(OBJEXT): \
+ lib/powerpc/$(am__dirstamp) \
+ lib/powerpc/$(DEPDIR)/$(am__dirstamp)
+lib/powerpc/relocator_module-relocator.$(OBJEXT): \
+ lib/powerpc/$(am__dirstamp) \
+ lib/powerpc/$(DEPDIR)/$(am__dirstamp)
+lib/x86_64/efi/$(am__dirstamp):
+ @$(MKDIR_P) lib/x86_64/efi
+ @: > lib/x86_64/efi/$(am__dirstamp)
+lib/x86_64/efi/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/x86_64/efi/$(DEPDIR)
+ @: > lib/x86_64/efi/$(DEPDIR)/$(am__dirstamp)
+lib/x86_64/efi/relocator_module-relocator.$(OBJEXT): \
+ lib/x86_64/efi/$(am__dirstamp) \
+ lib/x86_64/efi/$(DEPDIR)/$(am__dirstamp)
+lib/x86_64/$(am__dirstamp):
+ @$(MKDIR_P) lib/x86_64
+ @: > lib/x86_64/$(am__dirstamp)
+lib/x86_64/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/x86_64/$(DEPDIR)
+ @: > lib/x86_64/$(DEPDIR)/$(am__dirstamp)
+lib/x86_64/relocator_module-relocator_asm.$(OBJEXT): \
+ lib/x86_64/$(am__dirstamp) \
+ lib/x86_64/$(DEPDIR)/$(am__dirstamp)
+lib/x86_64/xen/$(am__dirstamp):
+ @$(MKDIR_P) lib/x86_64/xen
+ @: > lib/x86_64/xen/$(am__dirstamp)
+lib/x86_64/xen/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/x86_64/xen/$(DEPDIR)
+ @: > lib/x86_64/xen/$(DEPDIR)/$(am__dirstamp)
+lib/x86_64/xen/relocator_module-relocator.$(OBJEXT): \
+ lib/x86_64/xen/$(am__dirstamp) \
+ lib/x86_64/xen/$(DEPDIR)/$(am__dirstamp)
+
+relocator.module$(EXEEXT): $(relocator_module_OBJECTS) $(relocator_module_DEPENDENCIES) $(EXTRA_relocator_module_DEPENDENCIES)
+ @rm -f relocator.module$(EXEEXT)
+ $(AM_V_CCLD)$(relocator_module_LINK) $(relocator_module_OBJECTS) $(relocator_module_LDADD) $(LIBS)
+fs/romfs_module-romfs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+romfs.module$(EXEEXT): $(romfs_module_OBJECTS) $(romfs_module_DEPENDENCIES) $(EXTRA_romfs_module_DEPENDENCIES)
+ @rm -f romfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(romfs_module_LINK) $(romfs_module_OBJECTS) $(romfs_module_LDADD) $(LIBS)
+disk/scsi_module-scsi.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+scsi.module$(EXEEXT): $(scsi_module_OBJECTS) $(scsi_module_DEPENDENCIES) $(EXTRA_scsi_module_DEPENDENCIES)
+ @rm -f scsi.module$(EXEEXT)
+ $(AM_V_CCLD)$(scsi_module_LINK) $(scsi_module_OBJECTS) $(scsi_module_LDADD) $(LIBS)
+video/emu/$(am__dirstamp):
+ @$(MKDIR_P) video/emu
+ @: > video/emu/$(am__dirstamp)
+video/emu/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) video/emu/$(DEPDIR)
+ @: > video/emu/$(DEPDIR)/$(am__dirstamp)
+video/emu/sdl_module-sdl.$(OBJEXT): video/emu/$(am__dirstamp) \
+ video/emu/$(DEPDIR)/$(am__dirstamp)
+
+sdl.module$(EXEEXT): $(sdl_module_OBJECTS) $(sdl_module_DEPENDENCIES) $(EXTRA_sdl_module_DEPENDENCIES)
+ @rm -f sdl.module$(EXEEXT)
+ $(AM_V_CCLD)$(sdl_module_LINK) $(sdl_module_OBJECTS) $(sdl_module_LDADD) $(LIBS)
+commands/search_module-search_wrap.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+search.module$(EXEEXT): $(search_module_OBJECTS) $(search_module_DEPENDENCIES) $(EXTRA_search_module_DEPENDENCIES)
+ @rm -f search.module$(EXEEXT)
+ $(AM_V_CCLD)$(search_module_LINK) $(search_module_OBJECTS) $(search_module_LDADD) $(LIBS)
+commands/search_fs_file_module-search_file.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+search_fs_file.module$(EXEEXT): $(search_fs_file_module_OBJECTS) $(search_fs_file_module_DEPENDENCIES) $(EXTRA_search_fs_file_module_DEPENDENCIES)
+ @rm -f search_fs_file.module$(EXEEXT)
+ $(AM_V_CCLD)$(search_fs_file_module_LINK) $(search_fs_file_module_OBJECTS) $(search_fs_file_module_LDADD) $(LIBS)
+commands/search_fs_uuid_module-search_uuid.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+search_fs_uuid.module$(EXEEXT): $(search_fs_uuid_module_OBJECTS) $(search_fs_uuid_module_DEPENDENCIES) $(EXTRA_search_fs_uuid_module_DEPENDENCIES)
+ @rm -f search_fs_uuid.module$(EXEEXT)
+ $(AM_V_CCLD)$(search_fs_uuid_module_LINK) $(search_fs_uuid_module_OBJECTS) $(search_fs_uuid_module_LDADD) $(LIBS)
+commands/search_label_module-search_label.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+search_label.module$(EXEEXT): $(search_label_module_OBJECTS) $(search_label_module_DEPENDENCIES) $(EXTRA_search_label_module_DEPENDENCIES)
+ @rm -f search_label.module$(EXEEXT)
+ $(AM_V_CCLD)$(search_label_module_LINK) $(search_label_module_OBJECTS) $(search_label_module_LDADD) $(LIBS)
+commands/i386/pc/sendkey_module-sendkey.$(OBJEXT): \
+ commands/i386/pc/$(am__dirstamp) \
+ commands/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+sendkey.module$(EXEEXT): $(sendkey_module_OBJECTS) $(sendkey_module_DEPENDENCIES) $(EXTRA_sendkey_module_DEPENDENCIES)
+ @rm -f sendkey.module$(EXEEXT)
+ $(AM_V_CCLD)$(sendkey_module_LINK) $(sendkey_module_OBJECTS) $(sendkey_module_LDADD) $(LIBS)
+term/efi/serial_module-serial.$(OBJEXT): term/efi/$(am__dirstamp) \
+ term/efi/$(DEPDIR)/$(am__dirstamp)
+term/serial_module-serial.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+term/serial_module-ns8250.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+term/ieee1275/serial_module-serial.$(OBJEXT): \
+ term/ieee1275/$(am__dirstamp) \
+ term/ieee1275/$(DEPDIR)/$(am__dirstamp)
+term/arc/serial_module-serial.$(OBJEXT): term/arc/$(am__dirstamp) \
+ term/arc/$(DEPDIR)/$(am__dirstamp)
+
+serial.module$(EXEEXT): $(serial_module_OBJECTS) $(serial_module_DEPENDENCIES) $(EXTRA_serial_module_DEPENDENCIES)
+ @rm -f serial.module$(EXEEXT)
+ $(AM_V_CCLD)$(serial_module_LINK) $(serial_module_OBJECTS) $(serial_module_LDADD) $(LIBS)
+lib/setjmp_module-setjmp.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+
+setjmp.module$(EXEEXT): $(setjmp_module_OBJECTS) $(setjmp_module_DEPENDENCIES) $(EXTRA_setjmp_module_DEPENDENCIES)
+ @rm -f setjmp.module$(EXEEXT)
+ $(AM_V_CCLD)$(setjmp_module_LINK) $(setjmp_module_OBJECTS) $(setjmp_module_LDADD) $(LIBS)
+tests/setjmp_test_module-setjmp_test.$(OBJEXT): tests/$(am__dirstamp) \
+ tests/$(DEPDIR)/$(am__dirstamp)
+
+setjmp_test.module$(EXEEXT): $(setjmp_test_module_OBJECTS) $(setjmp_test_module_DEPENDENCIES) $(EXTRA_setjmp_test_module_DEPENDENCIES)
+ @rm -f setjmp_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(setjmp_test_module_LINK) $(setjmp_test_module_OBJECTS) $(setjmp_test_module_LDADD) $(LIBS)
+commands/setpci_module-setpci.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+setpci.module$(EXEEXT): $(setpci_module_OBJECTS) $(setpci_module_DEPENDENCIES) $(EXTRA_setpci_module_DEPENDENCIES)
+ @rm -f setpci.module$(EXEEXT)
+ $(AM_V_CCLD)$(setpci_module_LINK) $(setpci_module_OBJECTS) $(setpci_module_LDADD) $(LIBS)
+fs/sfs_module-sfs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+sfs.module$(EXEEXT): $(sfs_module_OBJECTS) $(sfs_module_DEPENDENCIES) $(EXTRA_sfs_module_DEPENDENCIES)
+ @rm -f sfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(sfs_module_LINK) $(sfs_module_OBJECTS) $(sfs_module_LDADD) $(LIBS)
+tests/shift_test_module-shift_test.$(OBJEXT): tests/$(am__dirstamp) \
+ tests/$(DEPDIR)/$(am__dirstamp)
+
+shift_test.module$(EXEEXT): $(shift_test_module_OBJECTS) $(shift_test_module_DEPENDENCIES) $(EXTRA_shift_test_module_DEPENDENCIES)
+ @rm -f shift_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(shift_test_module_LINK) $(shift_test_module_OBJECTS) $(shift_test_module_LDADD) $(LIBS)
+tests/signature_test_module-signature_test.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+
+signature_test.module$(EXEEXT): $(signature_test_module_OBJECTS) $(signature_test_module_DEPENDENCIES) $(EXTRA_signature_test_module_DEPENDENCIES)
+ @rm -f signature_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(signature_test_module_LINK) $(signature_test_module_OBJECTS) $(signature_test_module_LDADD) $(LIBS)
+commands/sleep_module-sleep.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+sleep.module$(EXEEXT): $(sleep_module_OBJECTS) $(sleep_module_DEPENDENCIES) $(EXTRA_sleep_module_DEPENDENCIES)
+ @rm -f sleep.module$(EXEEXT)
+ $(AM_V_CCLD)$(sleep_module_LINK) $(sleep_module_OBJECTS) $(sleep_module_LDADD) $(LIBS)
+tests/sleep_test_module-sleep_test.$(OBJEXT): tests/$(am__dirstamp) \
+ tests/$(DEPDIR)/$(am__dirstamp)
+
+sleep_test.module$(EXEEXT): $(sleep_test_module_OBJECTS) $(sleep_test_module_DEPENDENCIES) $(EXTRA_sleep_test_module_DEPENDENCIES)
+ @rm -f sleep_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(sleep_test_module_LINK) $(sleep_test_module_OBJECTS) $(sleep_test_module_LDADD) $(LIBS)
+commands/efi/smbios_module-smbios.$(OBJEXT): \
+ commands/efi/$(am__dirstamp) \
+ commands/efi/$(DEPDIR)/$(am__dirstamp)
+commands/smbios_module-smbios.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+commands/i386/pc/smbios_module-smbios.$(OBJEXT): \
+ commands/i386/pc/$(am__dirstamp) \
+ commands/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+smbios.module$(EXEEXT): $(smbios_module_OBJECTS) $(smbios_module_DEPENDENCIES) $(EXTRA_smbios_module_DEPENDENCIES)
+ @rm -f smbios.module$(EXEEXT)
+ $(AM_V_CCLD)$(smbios_module_LINK) $(smbios_module_OBJECTS) $(smbios_module_LDADD) $(LIBS)
+term/spkmodem_module-spkmodem.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+
+spkmodem.module$(EXEEXT): $(spkmodem_module_OBJECTS) $(spkmodem_module_DEPENDENCIES) $(EXTRA_spkmodem_module_DEPENDENCIES)
+ @rm -f spkmodem.module$(EXEEXT)
+ $(AM_V_CCLD)$(spkmodem_module_LINK) $(spkmodem_module_OBJECTS) $(spkmodem_module_LDADD) $(LIBS)
+fs/squash4_module-squash4.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+squash4.module$(EXEEXT): $(squash4_module_OBJECTS) $(squash4_module_DEPENDENCIES) $(EXTRA_squash4_module_DEPENDENCIES)
+ @rm -f squash4.module$(EXEEXT)
+ $(AM_V_CCLD)$(squash4_module_LINK) $(squash4_module_OBJECTS) $(squash4_module_LDADD) $(LIBS)
+tests/strtoull_test_module-strtoull_test.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+
+strtoull_test.module$(EXEEXT): $(strtoull_test_module_OBJECTS) $(strtoull_test_module_DEPENDENCIES) $(EXTRA_strtoull_test_module_DEPENDENCIES)
+ @rm -f strtoull_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(strtoull_test_module_LINK) $(strtoull_test_module_OBJECTS) $(strtoull_test_module_LDADD) $(LIBS)
+commands/ieee1275/$(am__dirstamp):
+ @$(MKDIR_P) commands/ieee1275
+ @: > commands/ieee1275/$(am__dirstamp)
+commands/ieee1275/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) commands/ieee1275/$(DEPDIR)
+ @: > commands/ieee1275/$(DEPDIR)/$(am__dirstamp)
+commands/ieee1275/suspend_module-suspend.$(OBJEXT): \
+ commands/ieee1275/$(am__dirstamp) \
+ commands/ieee1275/$(DEPDIR)/$(am__dirstamp)
+
+suspend.module$(EXEEXT): $(suspend_module_OBJECTS) $(suspend_module_DEPENDENCIES) $(EXTRA_suspend_module_DEPENDENCIES)
+ @rm -f suspend.module$(EXEEXT)
+ $(AM_V_CCLD)$(suspend_module_LINK) $(suspend_module_OBJECTS) $(suspend_module_LDADD) $(LIBS)
+lib/syslinuxcfg_module-syslinux_parse.$(OBJEXT): lib/$(am__dirstamp) \
+ lib/$(DEPDIR)/$(am__dirstamp)
+commands/syslinuxcfg_module-syslinuxcfg.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+syslinuxcfg.module$(EXEEXT): $(syslinuxcfg_module_OBJECTS) $(syslinuxcfg_module_DEPENDENCIES) $(EXTRA_syslinuxcfg_module_DEPENDENCIES)
+ @rm -f syslinuxcfg.module$(EXEEXT)
+ $(AM_V_CCLD)$(syslinuxcfg_module_LINK) $(syslinuxcfg_module_OBJECTS) $(syslinuxcfg_module_LDADD) $(LIBS)
+fs/tar_module-tar.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+tar.module$(EXEEXT): $(tar_module_OBJECTS) $(tar_module_DEPENDENCIES) $(EXTRA_tar_module_DEPENDENCIES)
+ @rm -f tar.module$(EXEEXT)
+ $(AM_V_CCLD)$(tar_module_LINK) $(tar_module_OBJECTS) $(tar_module_LDADD) $(LIBS)
+commands/terminal_module-terminal.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+terminal.module$(EXEEXT): $(terminal_module_OBJECTS) $(terminal_module_DEPENDENCIES) $(EXTRA_terminal_module_DEPENDENCIES)
+ @rm -f terminal.module$(EXEEXT)
+ $(AM_V_CCLD)$(terminal_module_LINK) $(terminal_module_OBJECTS) $(terminal_module_LDADD) $(LIBS)
+term/terminfo_module-terminfo.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+term/terminfo_module-tparm.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+
+terminfo.module$(EXEEXT): $(terminfo_module_OBJECTS) $(terminfo_module_DEPENDENCIES) $(EXTRA_terminfo_module_DEPENDENCIES)
+ @rm -f terminfo.module$(EXEEXT)
+ $(AM_V_CCLD)$(terminfo_module_LINK) $(terminfo_module_OBJECTS) $(terminfo_module_LDADD) $(LIBS)
+commands/test_module-test.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+test.module$(EXEEXT): $(test_module_OBJECTS) $(test_module_DEPENDENCIES) $(EXTRA_test_module_DEPENDENCIES)
+ @rm -f test.module$(EXEEXT)
+ $(AM_V_CCLD)$(test_module_LINK) $(test_module_OBJECTS) $(test_module_LDADD) $(LIBS)
+tests/test_blockarg_module-test_blockarg.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+
+test_blockarg.module$(EXEEXT): $(test_blockarg_module_OBJECTS) $(test_blockarg_module_DEPENDENCIES) $(EXTRA_test_blockarg_module_DEPENDENCIES)
+ @rm -f test_blockarg.module$(EXEEXT)
+ $(AM_V_CCLD)$(test_blockarg_module_LINK) $(test_blockarg_module_OBJECTS) $(test_blockarg_module_LDADD) $(LIBS)
+commands/testload_module-testload.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+testload.module$(EXEEXT): $(testload_module_OBJECTS) $(testload_module_DEPENDENCIES) $(EXTRA_testload_module_DEPENDENCIES)
+ @rm -f testload.module$(EXEEXT)
+ $(AM_V_CCLD)$(testload_module_LINK) $(testload_module_OBJECTS) $(testload_module_LDADD) $(LIBS)
+commands/testspeed_module-testspeed.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+testspeed.module$(EXEEXT): $(testspeed_module_OBJECTS) $(testspeed_module_DEPENDENCIES) $(EXTRA_testspeed_module_DEPENDENCIES)
+ @rm -f testspeed.module$(EXEEXT)
+ $(AM_V_CCLD)$(testspeed_module_LINK) $(testspeed_module_OBJECTS) $(testspeed_module_LDADD) $(LIBS)
+net/tftp_module-tftp.$(OBJEXT): net/$(am__dirstamp) \
+ net/$(DEPDIR)/$(am__dirstamp)
+
+tftp.module$(EXEEXT): $(tftp_module_OBJECTS) $(tftp_module_DEPENDENCIES) $(EXTRA_tftp_module_DEPENDENCIES)
+ @rm -f tftp.module$(EXEEXT)
+ $(AM_V_CCLD)$(tftp_module_LINK) $(tftp_module_OBJECTS) $(tftp_module_LDADD) $(LIBS)
+video/readers/tga_module-tga.$(OBJEXT): video/readers/$(am__dirstamp) \
+ video/readers/$(DEPDIR)/$(am__dirstamp)
+
+tga.module$(EXEEXT): $(tga_module_OBJECTS) $(tga_module_DEPENDENCIES) $(EXTRA_tga_module_DEPENDENCIES)
+ @rm -f tga.module$(EXEEXT)
+ $(AM_V_CCLD)$(tga_module_LINK) $(tga_module_OBJECTS) $(tga_module_LDADD) $(LIBS)
+commands/time_module-time.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+time.module$(EXEEXT): $(time_module_OBJECTS) $(time_module_DEPENDENCIES) $(EXTRA_time_module_DEPENDENCIES)
+ @rm -f time.module$(EXEEXT)
+ $(AM_V_CCLD)$(time_module_LINK) $(time_module_OBJECTS) $(time_module_LDADD) $(LIBS)
+commands/efi/tpm_module-tpm.$(OBJEXT): commands/efi/$(am__dirstamp) \
+ commands/efi/$(DEPDIR)/$(am__dirstamp)
+commands/tpm_module-tpm.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+tpm.module$(EXEEXT): $(tpm_module_OBJECTS) $(tpm_module_DEPENDENCIES) $(EXTRA_tpm_module_DEPENDENCIES)
+ @rm -f tpm.module$(EXEEXT)
+ $(AM_V_CCLD)$(tpm_module_LINK) $(tpm_module_OBJECTS) $(tpm_module_LDADD) $(LIBS)
+commands/tr_module-tr.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+tr.module$(EXEEXT): $(tr_module_OBJECTS) $(tr_module_DEPENDENCIES) $(EXTRA_tr_module_DEPENDENCIES)
+ @rm -f tr.module$(EXEEXT)
+ $(AM_V_CCLD)$(tr_module_LINK) $(tr_module_OBJECTS) $(tr_module_LDADD) $(LIBS)
+
+trig.module$(EXEEXT): $(trig_module_OBJECTS) $(trig_module_DEPENDENCIES) $(EXTRA_trig_module_DEPENDENCIES)
+ @rm -f trig.module$(EXEEXT)
+ $(AM_V_CCLD)$(trig_module_LINK) $(trig_module_OBJECTS) $(trig_module_LDADD) $(LIBS)
+commands/true_module-true.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+true.module$(EXEEXT): $(true_module_OBJECTS) $(true_module_DEPENDENCIES) $(EXTRA_true_module_DEPENDENCIES)
+ @rm -f true.module$(EXEEXT)
+ $(AM_V_CCLD)$(true_module_LINK) $(true_module_OBJECTS) $(true_module_LDADD) $(LIBS)
+loader/i386/pc/truecrypt_module-truecrypt.$(OBJEXT): \
+ loader/i386/pc/$(am__dirstamp) \
+ loader/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+truecrypt.module$(EXEEXT): $(truecrypt_module_OBJECTS) $(truecrypt_module_DEPENDENCIES) $(EXTRA_truecrypt_module_DEPENDENCIES)
+ @rm -f truecrypt.module$(EXEEXT)
+ $(AM_V_CCLD)$(truecrypt_module_LINK) $(truecrypt_module_OBJECTS) $(truecrypt_module_LDADD) $(LIBS)
+net/drivers/uboot/$(am__dirstamp):
+ @$(MKDIR_P) net/drivers/uboot
+ @: > net/drivers/uboot/$(am__dirstamp)
+net/drivers/uboot/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) net/drivers/uboot/$(DEPDIR)
+ @: > net/drivers/uboot/$(DEPDIR)/$(am__dirstamp)
+net/drivers/uboot/ubootnet_module-ubootnet.$(OBJEXT): \
+ net/drivers/uboot/$(am__dirstamp) \
+ net/drivers/uboot/$(DEPDIR)/$(am__dirstamp)
+
+ubootnet.module$(EXEEXT): $(ubootnet_module_OBJECTS) $(ubootnet_module_DEPENDENCIES) $(EXTRA_ubootnet_module_DEPENDENCIES)
+ @rm -f ubootnet.module$(EXEEXT)
+ $(AM_V_CCLD)$(ubootnet_module_LINK) $(ubootnet_module_OBJECTS) $(ubootnet_module_LDADD) $(LIBS)
+fs/udf_module-udf.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+udf.module$(EXEEXT): $(udf_module_OBJECTS) $(udf_module_DEPENDENCIES) $(EXTRA_udf_module_DEPENDENCIES)
+ @rm -f udf.module$(EXEEXT)
+ $(AM_V_CCLD)$(udf_module_LINK) $(udf_module_OBJECTS) $(udf_module_LDADD) $(LIBS)
+fs/ufs1_module-ufs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+ufs1.module$(EXEEXT): $(ufs1_module_OBJECTS) $(ufs1_module_DEPENDENCIES) $(EXTRA_ufs1_module_DEPENDENCIES)
+ @rm -f ufs1.module$(EXEEXT)
+ $(AM_V_CCLD)$(ufs1_module_LINK) $(ufs1_module_OBJECTS) $(ufs1_module_LDADD) $(LIBS)
+fs/ufs1_be_module-ufs_be.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+ufs1_be.module$(EXEEXT): $(ufs1_be_module_OBJECTS) $(ufs1_be_module_DEPENDENCIES) $(EXTRA_ufs1_be_module_DEPENDENCIES)
+ @rm -f ufs1_be.module$(EXEEXT)
+ $(AM_V_CCLD)$(ufs1_be_module_LINK) $(ufs1_be_module_OBJECTS) $(ufs1_be_module_LDADD) $(LIBS)
+fs/ufs2_module-ufs2.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+ufs2.module$(EXEEXT): $(ufs2_module_OBJECTS) $(ufs2_module_DEPENDENCIES) $(EXTRA_ufs2_module_DEPENDENCIES)
+ @rm -f ufs2.module$(EXEEXT)
+ $(AM_V_CCLD)$(ufs2_module_LINK) $(ufs2_module_OBJECTS) $(ufs2_module_LDADD) $(LIBS)
+bus/usb/uhci_module-uhci.$(OBJEXT): bus/usb/$(am__dirstamp) \
+ bus/usb/$(DEPDIR)/$(am__dirstamp)
+
+uhci.module$(EXEEXT): $(uhci_module_OBJECTS) $(uhci_module_DEPENDENCIES) $(EXTRA_uhci_module_DEPENDENCIES)
+ @rm -f uhci.module$(EXEEXT)
+ $(AM_V_CCLD)$(uhci_module_LINK) $(uhci_module_OBJECTS) $(uhci_module_LDADD) $(LIBS)
+bus/usb/usb_module-usb.$(OBJEXT): bus/usb/$(am__dirstamp) \
+ bus/usb/$(DEPDIR)/$(am__dirstamp)
+bus/usb/usb_module-usbtrans.$(OBJEXT): bus/usb/$(am__dirstamp) \
+ bus/usb/$(DEPDIR)/$(am__dirstamp)
+bus/usb/usb_module-usbhub.$(OBJEXT): bus/usb/$(am__dirstamp) \
+ bus/usb/$(DEPDIR)/$(am__dirstamp)
+
+usb.module$(EXEEXT): $(usb_module_OBJECTS) $(usb_module_DEPENDENCIES) $(EXTRA_usb_module_DEPENDENCIES)
+ @rm -f usb.module$(EXEEXT)
+ $(AM_V_CCLD)$(usb_module_LINK) $(usb_module_OBJECTS) $(usb_module_LDADD) $(LIBS)
+term/usb_keyboard_module-usb_keyboard.$(OBJEXT): term/$(am__dirstamp) \
+ term/$(DEPDIR)/$(am__dirstamp)
+
+usb_keyboard.module$(EXEEXT): $(usb_keyboard_module_OBJECTS) $(usb_keyboard_module_DEPENDENCIES) $(EXTRA_usb_keyboard_module_DEPENDENCIES)
+ @rm -f usb_keyboard.module$(EXEEXT)
+ $(AM_V_CCLD)$(usb_keyboard_module_LINK) $(usb_keyboard_module_OBJECTS) $(usb_keyboard_module_LDADD) $(LIBS)
+disk/usbms_module-usbms.$(OBJEXT): disk/$(am__dirstamp) \
+ disk/$(DEPDIR)/$(am__dirstamp)
+
+usbms.module$(EXEEXT): $(usbms_module_OBJECTS) $(usbms_module_DEPENDENCIES) $(EXTRA_usbms_module_DEPENDENCIES)
+ @rm -f usbms.module$(EXEEXT)
+ $(AM_V_CCLD)$(usbms_module_LINK) $(usbms_module_OBJECTS) $(usbms_module_LDADD) $(LIBS)
+bus/usb/serial/$(am__dirstamp):
+ @$(MKDIR_P) bus/usb/serial
+ @: > bus/usb/serial/$(am__dirstamp)
+bus/usb/serial/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) bus/usb/serial/$(DEPDIR)
+ @: > bus/usb/serial/$(DEPDIR)/$(am__dirstamp)
+bus/usb/serial/usbserial_common_module-common.$(OBJEXT): \
+ bus/usb/serial/$(am__dirstamp) \
+ bus/usb/serial/$(DEPDIR)/$(am__dirstamp)
+
+usbserial_common.module$(EXEEXT): $(usbserial_common_module_OBJECTS) $(usbserial_common_module_DEPENDENCIES) $(EXTRA_usbserial_common_module_DEPENDENCIES)
+ @rm -f usbserial_common.module$(EXEEXT)
+ $(AM_V_CCLD)$(usbserial_common_module_LINK) $(usbserial_common_module_OBJECTS) $(usbserial_common_module_LDADD) $(LIBS)
+bus/usb/serial/usbserial_ftdi_module-ftdi.$(OBJEXT): \
+ bus/usb/serial/$(am__dirstamp) \
+ bus/usb/serial/$(DEPDIR)/$(am__dirstamp)
+
+usbserial_ftdi.module$(EXEEXT): $(usbserial_ftdi_module_OBJECTS) $(usbserial_ftdi_module_DEPENDENCIES) $(EXTRA_usbserial_ftdi_module_DEPENDENCIES)
+ @rm -f usbserial_ftdi.module$(EXEEXT)
+ $(AM_V_CCLD)$(usbserial_ftdi_module_LINK) $(usbserial_ftdi_module_OBJECTS) $(usbserial_ftdi_module_LDADD) $(LIBS)
+bus/usb/serial/usbserial_pl2303_module-pl2303.$(OBJEXT): \
+ bus/usb/serial/$(am__dirstamp) \
+ bus/usb/serial/$(DEPDIR)/$(am__dirstamp)
+
+usbserial_pl2303.module$(EXEEXT): $(usbserial_pl2303_module_OBJECTS) $(usbserial_pl2303_module_DEPENDENCIES) $(EXTRA_usbserial_pl2303_module_DEPENDENCIES)
+ @rm -f usbserial_pl2303.module$(EXEEXT)
+ $(AM_V_CCLD)$(usbserial_pl2303_module_LINK) $(usbserial_pl2303_module_OBJECTS) $(usbserial_pl2303_module_LDADD) $(LIBS)
+bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.$(OBJEXT): \
+ bus/usb/serial/$(am__dirstamp) \
+ bus/usb/serial/$(DEPDIR)/$(am__dirstamp)
+
+usbserial_usbdebug.module$(EXEEXT): $(usbserial_usbdebug_module_OBJECTS) $(usbserial_usbdebug_module_DEPENDENCIES) $(EXTRA_usbserial_usbdebug_module_DEPENDENCIES)
+ @rm -f usbserial_usbdebug.module$(EXEEXT)
+ $(AM_V_CCLD)$(usbserial_usbdebug_module_LINK) $(usbserial_usbdebug_module_OBJECTS) $(usbserial_usbdebug_module_LDADD) $(LIBS)
+commands/usbtest_module-usbtest.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+usbtest.module$(EXEEXT): $(usbtest_module_OBJECTS) $(usbtest_module_DEPENDENCIES) $(EXTRA_usbtest_module_DEPENDENCIES)
+ @rm -f usbtest.module$(EXEEXT)
+ $(AM_V_CCLD)$(usbtest_module_LINK) $(usbtest_module_OBJECTS) $(usbtest_module_LDADD) $(LIBS)
+video/i386/pc/$(am__dirstamp):
+ @$(MKDIR_P) video/i386/pc
+ @: > video/i386/pc/$(am__dirstamp)
+video/i386/pc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) video/i386/pc/$(DEPDIR)
+ @: > video/i386/pc/$(DEPDIR)/$(am__dirstamp)
+video/i386/pc/vbe_module-vbe.$(OBJEXT): video/i386/pc/$(am__dirstamp) \
+ video/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+vbe.module$(EXEEXT): $(vbe_module_OBJECTS) $(vbe_module_DEPENDENCIES) $(EXTRA_vbe_module_DEPENDENCIES)
+ @rm -f vbe.module$(EXEEXT)
+ $(AM_V_CCLD)$(vbe_module_LINK) $(vbe_module_OBJECTS) $(vbe_module_LDADD) $(LIBS)
+video/i386/pc/vga_module-vga.$(OBJEXT): video/i386/pc/$(am__dirstamp) \
+ video/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+vga.module$(EXEEXT): $(vga_module_OBJECTS) $(vga_module_DEPENDENCIES) $(EXTRA_vga_module_DEPENDENCIES)
+ @rm -f vga.module$(EXEEXT)
+ $(AM_V_CCLD)$(vga_module_LINK) $(vga_module_OBJECTS) $(vga_module_LDADD) $(LIBS)
+term/i386/pc/vga_text_module-vga_text.$(OBJEXT): \
+ term/i386/pc/$(am__dirstamp) \
+ term/i386/pc/$(DEPDIR)/$(am__dirstamp)
+
+vga_text.module$(EXEEXT): $(vga_text_module_OBJECTS) $(vga_text_module_DEPENDENCIES) $(EXTRA_vga_text_module_DEPENDENCIES)
+ @rm -f vga_text.module$(EXEEXT)
+ $(AM_V_CCLD)$(vga_text_module_LINK) $(vga_text_module_OBJECTS) $(vga_text_module_LDADD) $(LIBS)
+video/video_module-video.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+
+video.module$(EXEEXT): $(video_module_OBJECTS) $(video_module_DEPENDENCIES) $(EXTRA_video_module_DEPENDENCIES)
+ @rm -f video.module$(EXEEXT)
+ $(AM_V_CCLD)$(video_module_LINK) $(video_module_OBJECTS) $(video_module_LDADD) $(LIBS)
+video/video_bochs_module-bochs.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+
+video_bochs.module$(EXEEXT): $(video_bochs_module_OBJECTS) $(video_bochs_module_DEPENDENCIES) $(EXTRA_video_bochs_module_DEPENDENCIES)
+ @rm -f video_bochs.module$(EXEEXT)
+ $(AM_V_CCLD)$(video_bochs_module_LINK) $(video_bochs_module_OBJECTS) $(video_bochs_module_LDADD) $(LIBS)
+video/video_cirrus_module-cirrus.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+
+video_cirrus.module$(EXEEXT): $(video_cirrus_module_OBJECTS) $(video_cirrus_module_DEPENDENCIES) $(EXTRA_video_cirrus_module_DEPENDENCIES)
+ @rm -f video_cirrus.module$(EXEEXT)
+ $(AM_V_CCLD)$(video_cirrus_module_LINK) $(video_cirrus_module_OBJECTS) $(video_cirrus_module_LDADD) $(LIBS)
+video/video_colors_module-colors.$(OBJEXT): video/$(am__dirstamp) \
+ video/$(DEPDIR)/$(am__dirstamp)
+
+video_colors.module$(EXEEXT): $(video_colors_module_OBJECTS) $(video_colors_module_DEPENDENCIES) $(EXTRA_video_colors_module_DEPENDENCIES)
+ @rm -f video_colors.module$(EXEEXT)
+ $(AM_V_CCLD)$(video_colors_module_LINK) $(video_colors_module_OBJECTS) $(video_colors_module_LDADD) $(LIBS)
+video/fb/video_fb_module-video_fb.$(OBJEXT): video/fb/$(am__dirstamp) \
+ video/fb/$(DEPDIR)/$(am__dirstamp)
+video/fb/video_fb_module-fbblit.$(OBJEXT): video/fb/$(am__dirstamp) \
+ video/fb/$(DEPDIR)/$(am__dirstamp)
+video/fb/video_fb_module-fbfill.$(OBJEXT): video/fb/$(am__dirstamp) \
+ video/fb/$(DEPDIR)/$(am__dirstamp)
+video/fb/video_fb_module-fbutil.$(OBJEXT): video/fb/$(am__dirstamp) \
+ video/fb/$(DEPDIR)/$(am__dirstamp)
+
+video_fb.module$(EXEEXT): $(video_fb_module_OBJECTS) $(video_fb_module_DEPENDENCIES) $(EXTRA_video_fb_module_DEPENDENCIES)
+ @rm -f video_fb.module$(EXEEXT)
+ $(AM_V_CCLD)$(video_fb_module_LINK) $(video_fb_module_OBJECTS) $(video_fb_module_LDADD) $(LIBS)
+commands/videoinfo_module-videoinfo.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+videoinfo.module$(EXEEXT): $(videoinfo_module_OBJECTS) $(videoinfo_module_DEPENDENCIES) $(EXTRA_videoinfo_module_DEPENDENCIES)
+ @rm -f videoinfo.module$(EXEEXT)
+ $(AM_V_CCLD)$(videoinfo_module_LINK) $(videoinfo_module_OBJECTS) $(videoinfo_module_LDADD) $(LIBS)
+commands/videotest_module-videotest.$(OBJEXT): \
+ commands/$(am__dirstamp) commands/$(DEPDIR)/$(am__dirstamp)
+
+videotest.module$(EXEEXT): $(videotest_module_OBJECTS) $(videotest_module_DEPENDENCIES) $(EXTRA_videotest_module_DEPENDENCIES)
+ @rm -f videotest.module$(EXEEXT)
+ $(AM_V_CCLD)$(videotest_module_LINK) $(videotest_module_OBJECTS) $(videotest_module_LDADD) $(LIBS)
+tests/videotest_checksum_module-videotest_checksum.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+
+videotest_checksum.module$(EXEEXT): $(videotest_checksum_module_OBJECTS) $(videotest_checksum_module_DEPENDENCIES) $(EXTRA_videotest_checksum_module_DEPENDENCIES)
+ @rm -f videotest_checksum.module$(EXEEXT)
+ $(AM_V_CCLD)$(videotest_checksum_module_LINK) $(videotest_checksum_module_OBJECTS) $(videotest_checksum_module_LDADD) $(LIBS)
+commands/i386/wrmsr_module-wrmsr.$(OBJEXT): \
+ commands/i386/$(am__dirstamp) \
+ commands/i386/$(DEPDIR)/$(am__dirstamp)
+
+wrmsr.module$(EXEEXT): $(wrmsr_module_OBJECTS) $(wrmsr_module_DEPENDENCIES) $(EXTRA_wrmsr_module_DEPENDENCIES)
+ @rm -f wrmsr.module$(EXEEXT)
+ $(AM_V_CCLD)$(wrmsr_module_LINK) $(wrmsr_module_OBJECTS) $(wrmsr_module_LDADD) $(LIBS)
+loader/arm64/xen_boot_module-xen_boot.$(OBJEXT): \
+ loader/arm64/$(am__dirstamp) \
+ loader/arm64/$(DEPDIR)/$(am__dirstamp)
+
+xen_boot.module$(EXEEXT): $(xen_boot_module_OBJECTS) $(xen_boot_module_DEPENDENCIES) $(EXTRA_xen_boot_module_DEPENDENCIES)
+ @rm -f xen_boot.module$(EXEEXT)
+ $(AM_V_CCLD)$(xen_boot_module_LINK) $(xen_boot_module_OBJECTS) $(xen_boot_module_LDADD) $(LIBS)
+fs/xfs_module-xfs.$(OBJEXT): fs/$(am__dirstamp) \
+ fs/$(DEPDIR)/$(am__dirstamp)
+
+xfs.module$(EXEEXT): $(xfs_module_OBJECTS) $(xfs_module_DEPENDENCIES) $(EXTRA_xfs_module_DEPENDENCIES)
+ @rm -f xfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(xfs_module_LINK) $(xfs_module_OBJECTS) $(xfs_module_LDADD) $(LIBS)
+loader/xnu_module-xnu_resume.$(OBJEXT): loader/$(am__dirstamp) \
+ loader/$(DEPDIR)/$(am__dirstamp)
+loader/i386/xnu_module-xnu.$(OBJEXT): loader/i386/$(am__dirstamp) \
+ loader/i386/$(DEPDIR)/$(am__dirstamp)
+loader/xnu_module-xnu.$(OBJEXT): loader/$(am__dirstamp) \
+ loader/$(DEPDIR)/$(am__dirstamp)
+
+xnu.module$(EXEEXT): $(xnu_module_OBJECTS) $(xnu_module_DEPENDENCIES) $(EXTRA_xnu_module_DEPENDENCIES)
+ @rm -f xnu.module$(EXEEXT)
+ $(AM_V_CCLD)$(xnu_module_LINK) $(xnu_module_OBJECTS) $(xnu_module_LDADD) $(LIBS)
+commands/xnu_uuid_module-xnu_uuid.$(OBJEXT): commands/$(am__dirstamp) \
+ commands/$(DEPDIR)/$(am__dirstamp)
+
+xnu_uuid.module$(EXEEXT): $(xnu_uuid_module_OBJECTS) $(xnu_uuid_module_DEPENDENCIES) $(EXTRA_xnu_uuid_module_DEPENDENCIES)
+ @rm -f xnu_uuid.module$(EXEEXT)
+ $(AM_V_CCLD)$(xnu_uuid_module_LINK) $(xnu_uuid_module_OBJECTS) $(xnu_uuid_module_LDADD) $(LIBS)
+tests/xnu_uuid_test_module-xnu_uuid_test.$(OBJEXT): \
+ tests/$(am__dirstamp) tests/$(DEPDIR)/$(am__dirstamp)
+
+xnu_uuid_test.module$(EXEEXT): $(xnu_uuid_test_module_OBJECTS) $(xnu_uuid_test_module_DEPENDENCIES) $(EXTRA_xnu_uuid_test_module_DEPENDENCIES)
+ @rm -f xnu_uuid_test.module$(EXEEXT)
+ $(AM_V_CCLD)$(xnu_uuid_test_module_LINK) $(xnu_uuid_test_module_OBJECTS) $(xnu_uuid_test_module_LDADD) $(LIBS)
+boot/mips/xz_decompress_image-startup_raw.$(OBJEXT): \
+ boot/mips/$(am__dirstamp) boot/mips/$(DEPDIR)/$(am__dirstamp)
+boot/decompressor/xz_decompress_image-minilib.$(OBJEXT): \
+ boot/decompressor/$(am__dirstamp) \
+ boot/decompressor/$(DEPDIR)/$(am__dirstamp)
+boot/decompressor/xz_decompress_image-xz.$(OBJEXT): \
+ boot/decompressor/$(am__dirstamp) \
+ boot/decompressor/$(DEPDIR)/$(am__dirstamp)
+lib/xzembed/$(am__dirstamp):
+ @$(MKDIR_P) lib/xzembed
+ @: > lib/xzembed/$(am__dirstamp)
+lib/xzembed/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/xzembed/$(DEPDIR)
+ @: > lib/xzembed/$(DEPDIR)/$(am__dirstamp)
+lib/xzembed/xz_decompress_image-xz_dec_bcj.$(OBJEXT): \
+ lib/xzembed/$(am__dirstamp) \
+ lib/xzembed/$(DEPDIR)/$(am__dirstamp)
+lib/xzembed/xz_decompress_image-xz_dec_lzma2.$(OBJEXT): \
+ lib/xzembed/$(am__dirstamp) \
+ lib/xzembed/$(DEPDIR)/$(am__dirstamp)
+lib/xzembed/xz_decompress_image-xz_dec_stream.$(OBJEXT): \
+ lib/xzembed/$(am__dirstamp) \
+ lib/xzembed/$(DEPDIR)/$(am__dirstamp)
+kern/xz_decompress_image-compiler-rt.$(OBJEXT): kern/$(am__dirstamp) \
+ kern/$(DEPDIR)/$(am__dirstamp)
+
+xz_decompress.image$(EXEEXT): $(xz_decompress_image_OBJECTS) $(xz_decompress_image_DEPENDENCIES) $(EXTRA_xz_decompress_image_DEPENDENCIES)
+ @rm -f xz_decompress.image$(EXEEXT)
+ $(AM_V_CCLD)$(xz_decompress_image_LINK) $(xz_decompress_image_OBJECTS) $(xz_decompress_image_LDADD) $(LIBS)
+io/xzio_module-xzio.$(OBJEXT): io/$(am__dirstamp) \
+ io/$(DEPDIR)/$(am__dirstamp)
+lib/xzembed/xzio_module-xz_dec_bcj.$(OBJEXT): \
+ lib/xzembed/$(am__dirstamp) \
+ lib/xzembed/$(DEPDIR)/$(am__dirstamp)
+lib/xzembed/xzio_module-xz_dec_lzma2.$(OBJEXT): \
+ lib/xzembed/$(am__dirstamp) \
+ lib/xzembed/$(DEPDIR)/$(am__dirstamp)
+lib/xzembed/xzio_module-xz_dec_stream.$(OBJEXT): \
+ lib/xzembed/$(am__dirstamp) \
+ lib/xzembed/$(DEPDIR)/$(am__dirstamp)
+
+xzio.module$(EXEEXT): $(xzio_module_OBJECTS) $(xzio_module_DEPENDENCIES) $(EXTRA_xzio_module_DEPENDENCIES)
+ @rm -f xzio.module$(EXEEXT)
+ $(AM_V_CCLD)$(xzio_module_LINK) $(xzio_module_OBJECTS) $(xzio_module_LDADD) $(LIBS)
+fs/zfs/$(am__dirstamp):
+ @$(MKDIR_P) fs/zfs
+ @: > fs/zfs/$(am__dirstamp)
+fs/zfs/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) fs/zfs/$(DEPDIR)
+ @: > fs/zfs/$(DEPDIR)/$(am__dirstamp)
+fs/zfs/zfs_module-zfs.$(OBJEXT): fs/zfs/$(am__dirstamp) \
+ fs/zfs/$(DEPDIR)/$(am__dirstamp)
+fs/zfs/zfs_module-zfs_lzjb.$(OBJEXT): fs/zfs/$(am__dirstamp) \
+ fs/zfs/$(DEPDIR)/$(am__dirstamp)
+fs/zfs/zfs_module-zfs_lz4.$(OBJEXT): fs/zfs/$(am__dirstamp) \
+ fs/zfs/$(DEPDIR)/$(am__dirstamp)
+fs/zfs/zfs_module-zfs_sha256.$(OBJEXT): fs/zfs/$(am__dirstamp) \
+ fs/zfs/$(DEPDIR)/$(am__dirstamp)
+fs/zfs/zfs_module-zfs_fletcher.$(OBJEXT): fs/zfs/$(am__dirstamp) \
+ fs/zfs/$(DEPDIR)/$(am__dirstamp)
+
+zfs.module$(EXEEXT): $(zfs_module_OBJECTS) $(zfs_module_DEPENDENCIES) $(EXTRA_zfs_module_DEPENDENCIES)
+ @rm -f zfs.module$(EXEEXT)
+ $(AM_V_CCLD)$(zfs_module_LINK) $(zfs_module_OBJECTS) $(zfs_module_LDADD) $(LIBS)
+fs/zfs/zfscrypt_module-zfscrypt.$(OBJEXT): fs/zfs/$(am__dirstamp) \
+ fs/zfs/$(DEPDIR)/$(am__dirstamp)
+
+zfscrypt.module$(EXEEXT): $(zfscrypt_module_OBJECTS) $(zfscrypt_module_DEPENDENCIES) $(EXTRA_zfscrypt_module_DEPENDENCIES)
+ @rm -f zfscrypt.module$(EXEEXT)
+ $(AM_V_CCLD)$(zfscrypt_module_LINK) $(zfscrypt_module_OBJECTS) $(zfscrypt_module_LDADD) $(LIBS)
+fs/zfs/zfsinfo_module-zfsinfo.$(OBJEXT): fs/zfs/$(am__dirstamp) \
+ fs/zfs/$(DEPDIR)/$(am__dirstamp)
+
+zfsinfo.module$(EXEEXT): $(zfsinfo_module_OBJECTS) $(zfsinfo_module_DEPENDENCIES) $(EXTRA_zfsinfo_module_DEPENDENCIES)
+ @rm -f zfsinfo.module$(EXEEXT)
+ $(AM_V_CCLD)$(zfsinfo_module_LINK) $(zfsinfo_module_OBJECTS) $(zfsinfo_module_LDADD) $(LIBS)
+lib/zstd/$(am__dirstamp):
+ @$(MKDIR_P) lib/zstd
+ @: > lib/zstd/$(am__dirstamp)
+lib/zstd/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) lib/zstd/$(DEPDIR)
+ @: > lib/zstd/$(DEPDIR)/$(am__dirstamp)
+lib/zstd/zstd_module-debug.$(OBJEXT): lib/zstd/$(am__dirstamp) \
+ lib/zstd/$(DEPDIR)/$(am__dirstamp)
+lib/zstd/zstd_module-entropy_common.$(OBJEXT): \
+ lib/zstd/$(am__dirstamp) lib/zstd/$(DEPDIR)/$(am__dirstamp)
+lib/zstd/zstd_module-error_private.$(OBJEXT): \
+ lib/zstd/$(am__dirstamp) lib/zstd/$(DEPDIR)/$(am__dirstamp)
+lib/zstd/zstd_module-fse_decompress.$(OBJEXT): \
+ lib/zstd/$(am__dirstamp) lib/zstd/$(DEPDIR)/$(am__dirstamp)
+lib/zstd/zstd_module-huf_decompress.$(OBJEXT): \
+ lib/zstd/$(am__dirstamp) lib/zstd/$(DEPDIR)/$(am__dirstamp)
+lib/zstd/zstd_module-module.$(OBJEXT): lib/zstd/$(am__dirstamp) \
+ lib/zstd/$(DEPDIR)/$(am__dirstamp)
+lib/zstd/zstd_module-xxhash.$(OBJEXT): lib/zstd/$(am__dirstamp) \
+ lib/zstd/$(DEPDIR)/$(am__dirstamp)
+lib/zstd/zstd_module-zstd_common.$(OBJEXT): lib/zstd/$(am__dirstamp) \
+ lib/zstd/$(DEPDIR)/$(am__dirstamp)
+lib/zstd/zstd_module-zstd_decompress.$(OBJEXT): \
+ lib/zstd/$(am__dirstamp) lib/zstd/$(DEPDIR)/$(am__dirstamp)
+
+zstd.module$(EXEEXT): $(zstd_module_OBJECTS) $(zstd_module_DEPENDENCIES) $(EXTRA_zstd_module_DEPENDENCIES)
+ @rm -f zstd.module$(EXEEXT)
+ $(AM_V_CCLD)$(zstd_module_LINK) $(zstd_module_OBJECTS) $(zstd_module_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir)
+install-grubconfSCRIPTS: $(grubconf_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ @list='$(grubconf_SCRIPTS)'; test -n "$(grubconfdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(grubconfdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(grubconfdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(grubconfdir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(grubconfdir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-grubconfSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(grubconf_SCRIPTS)'; test -n "$(grubconfdir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ dir='$(DESTDIR)$(grubconfdir)'; $(am__uninstall_files_from_dir)
+install-platformSCRIPTS: $(platform_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ @list='$(platform_SCRIPTS)'; test -n "$(platformdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(platformdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(platformdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(platformdir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(platformdir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-platformSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(platform_SCRIPTS)'; test -n "$(platformdir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ dir='$(DESTDIR)$(platformdir)'; $(am__uninstall_files_from_dir)
+install-sbinSCRIPTS: $(sbin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ @list='$(sbin_SCRIPTS)'; test -n "$(sbindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(sbindir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-sbinSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(sbin_SCRIPTS)'; test -n "$(sbindir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ dir='$(DESTDIR)$(sbindir)'; $(am__uninstall_files_from_dir)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+ -rm -f boot/decompressor/*.$(OBJEXT)
+ -rm -f boot/i386/pc/*.$(OBJEXT)
+ -rm -f boot/i386/qemu/*.$(OBJEXT)
+ -rm -f boot/mips/*.$(OBJEXT)
+ -rm -f boot/mips/loongson/*.$(OBJEXT)
+ -rm -f boot/sparc64/ieee1275/*.$(OBJEXT)
+ -rm -f bus/*.$(OBJEXT)
+ -rm -f bus/emu/*.$(OBJEXT)
+ -rm -f bus/i386/ieee1275/*.$(OBJEXT)
+ -rm -f bus/spi/*.$(OBJEXT)
+ -rm -f bus/usb/*.$(OBJEXT)
+ -rm -f bus/usb/serial/*.$(OBJEXT)
+ -rm -f commands/*.$(OBJEXT)
+ -rm -f commands/arc/*.$(OBJEXT)
+ -rm -f commands/efi/*.$(OBJEXT)
+ -rm -f commands/i386/*.$(OBJEXT)
+ -rm -f commands/i386/coreboot/*.$(OBJEXT)
+ -rm -f commands/i386/pc/*.$(OBJEXT)
+ -rm -f commands/ieee1275/*.$(OBJEXT)
+ -rm -f commands/mips/loongson/*.$(OBJEXT)
+ -rm -f commands/xen/*.$(OBJEXT)
+ -rm -f disk/*.$(OBJEXT)
+ -rm -f disk/arc/*.$(OBJEXT)
+ -rm -f disk/efi/*.$(OBJEXT)
+ -rm -f disk/i386/pc/*.$(OBJEXT)
+ -rm -f disk/ieee1275/*.$(OBJEXT)
+ -rm -f disk/uboot/*.$(OBJEXT)
+ -rm -f disk/xen/*.$(OBJEXT)
+ -rm -f efiemu/*.$(OBJEXT)
+ -rm -f efiemu/i386/*.$(OBJEXT)
+ -rm -f efiemu/i386/pc/*.$(OBJEXT)
+ -rm -f font/*.$(OBJEXT)
+ -rm -f fs/*.$(OBJEXT)
+ -rm -f fs/zfs/*.$(OBJEXT)
+ -rm -f gdb/*.$(OBJEXT)
+ -rm -f gdb/i386/*.$(OBJEXT)
+ -rm -f gettext/*.$(OBJEXT)
+ -rm -f gfxmenu/*.$(OBJEXT)
+ -rm -f hello/*.$(OBJEXT)
+ -rm -f hook/*.$(OBJEXT)
+ -rm -f io/*.$(OBJEXT)
+ -rm -f kern/*.$(OBJEXT)
+ -rm -f kern/arm/*.$(OBJEXT)
+ -rm -f kern/arm/coreboot/*.$(OBJEXT)
+ -rm -f kern/arm/efi/*.$(OBJEXT)
+ -rm -f kern/arm/uboot/*.$(OBJEXT)
+ -rm -f kern/arm64/*.$(OBJEXT)
+ -rm -f kern/arm64/efi/*.$(OBJEXT)
+ -rm -f kern/coreboot/*.$(OBJEXT)
+ -rm -f kern/efi/*.$(OBJEXT)
+ -rm -f kern/emu/*.$(OBJEXT)
+ -rm -f kern/generic/*.$(OBJEXT)
+ -rm -f kern/i386/*.$(OBJEXT)
+ -rm -f kern/i386/coreboot/*.$(OBJEXT)
+ -rm -f kern/i386/efi/*.$(OBJEXT)
+ -rm -f kern/i386/ieee1275/*.$(OBJEXT)
+ -rm -f kern/i386/pc/*.$(OBJEXT)
+ -rm -f kern/i386/qemu/*.$(OBJEXT)
+ -rm -f kern/i386/xen/*.$(OBJEXT)
+ -rm -f kern/ia64/*.$(OBJEXT)
+ -rm -f kern/ia64/efi/*.$(OBJEXT)
+ -rm -f kern/ieee1275/*.$(OBJEXT)
+ -rm -f kern/mips/*.$(OBJEXT)
+ -rm -f kern/mips/arc/*.$(OBJEXT)
+ -rm -f kern/mips/loongson/*.$(OBJEXT)
+ -rm -f kern/mips/qemu_mips/*.$(OBJEXT)
+ -rm -f kern/powerpc/*.$(OBJEXT)
+ -rm -f kern/powerpc/ieee1275/*.$(OBJEXT)
+ -rm -f kern/riscv/*.$(OBJEXT)
+ -rm -f kern/riscv/efi/*.$(OBJEXT)
+ -rm -f kern/sparc64/*.$(OBJEXT)
+ -rm -f kern/sparc64/ieee1275/*.$(OBJEXT)
+ -rm -f kern/uboot/*.$(OBJEXT)
+ -rm -f kern/x86_64/*.$(OBJEXT)
+ -rm -f kern/x86_64/efi/*.$(OBJEXT)
+ -rm -f kern/x86_64/xen/*.$(OBJEXT)
+ -rm -f kern/xen/*.$(OBJEXT)
+ -rm -f lib/*.$(OBJEXT)
+ -rm -f lib/arc/*.$(OBJEXT)
+ -rm -f lib/dummy/*.$(OBJEXT)
+ -rm -f lib/efi/*.$(OBJEXT)
+ -rm -f lib/emu/*.$(OBJEXT)
+ -rm -f lib/gnulib/*.$(OBJEXT)
+ -rm -f lib/i386/*.$(OBJEXT)
+ -rm -f lib/i386/pc/*.$(OBJEXT)
+ -rm -f lib/i386/xen/*.$(OBJEXT)
+ -rm -f lib/ieee1275/*.$(OBJEXT)
+ -rm -f lib/json/*.$(OBJEXT)
+ -rm -f lib/libgcrypt-grub/cipher/*.$(OBJEXT)
+ -rm -f lib/libgcrypt-grub/mpi/*.$(OBJEXT)
+ -rm -f lib/libgcrypt_wrap/*.$(OBJEXT)
+ -rm -f lib/minilzo/*.$(OBJEXT)
+ -rm -f lib/mips/*.$(OBJEXT)
+ -rm -f lib/mips/arc/*.$(OBJEXT)
+ -rm -f lib/mips/loongson/*.$(OBJEXT)
+ -rm -f lib/mips/qemu_mips/*.$(OBJEXT)
+ -rm -f lib/powerpc/*.$(OBJEXT)
+ -rm -f lib/uboot/*.$(OBJEXT)
+ -rm -f lib/x86_64/*.$(OBJEXT)
+ -rm -f lib/x86_64/efi/*.$(OBJEXT)
+ -rm -f lib/x86_64/xen/*.$(OBJEXT)
+ -rm -f lib/xen/*.$(OBJEXT)
+ -rm -f lib/xzembed/*.$(OBJEXT)
+ -rm -f lib/zstd/*.$(OBJEXT)
+ -rm -f loader/*.$(OBJEXT)
+ -rm -f loader/arm/*.$(OBJEXT)
+ -rm -f loader/arm64/*.$(OBJEXT)
+ -rm -f loader/efi/*.$(OBJEXT)
+ -rm -f loader/i386/*.$(OBJEXT)
+ -rm -f loader/i386/coreboot/*.$(OBJEXT)
+ -rm -f loader/i386/pc/*.$(OBJEXT)
+ -rm -f loader/ia64/efi/*.$(OBJEXT)
+ -rm -f loader/mips/*.$(OBJEXT)
+ -rm -f loader/powerpc/ieee1275/*.$(OBJEXT)
+ -rm -f loader/riscv/*.$(OBJEXT)
+ -rm -f loader/sparc64/ieee1275/*.$(OBJEXT)
+ -rm -f mmap/*.$(OBJEXT)
+ -rm -f mmap/efi/*.$(OBJEXT)
+ -rm -f mmap/i386/*.$(OBJEXT)
+ -rm -f mmap/i386/pc/*.$(OBJEXT)
+ -rm -f mmap/mips/*.$(OBJEXT)
+ -rm -f net/*.$(OBJEXT)
+ -rm -f net/drivers/efi/*.$(OBJEXT)
+ -rm -f net/drivers/emu/*.$(OBJEXT)
+ -rm -f net/drivers/i386/pc/*.$(OBJEXT)
+ -rm -f net/drivers/ieee1275/*.$(OBJEXT)
+ -rm -f net/drivers/uboot/*.$(OBJEXT)
+ -rm -f normal/*.$(OBJEXT)
+ -rm -f osdep/*.$(OBJEXT)
+ -rm -f osdep/devmapper/*.$(OBJEXT)
+ -rm -f osdep/unix/*.$(OBJEXT)
+ -rm -f partmap/*.$(OBJEXT)
+ -rm -f parttool/*.$(OBJEXT)
+ -rm -f script/*.$(OBJEXT)
+ -rm -f term/*.$(OBJEXT)
+ -rm -f term/arc/*.$(OBJEXT)
+ -rm -f term/arm/*.$(OBJEXT)
+ -rm -f term/efi/*.$(OBJEXT)
+ -rm -f term/i386/coreboot/*.$(OBJEXT)
+ -rm -f term/i386/pc/*.$(OBJEXT)
+ -rm -f term/ieee1275/*.$(OBJEXT)
+ -rm -f term/uboot/*.$(OBJEXT)
+ -rm -f term/xen/*.$(OBJEXT)
+ -rm -f tests/*.$(OBJEXT)
+ -rm -f tests/lib/*.$(OBJEXT)
+ -rm -f video/*.$(OBJEXT)
+ -rm -f video/coreboot/*.$(OBJEXT)
+ -rm -f video/emu/*.$(OBJEXT)
+ -rm -f video/fb/*.$(OBJEXT)
+ -rm -f video/i386/pc/*.$(OBJEXT)
+ -rm -f video/readers/*.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grub_emu-grub_emu_init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grub_emu_lite-symlist.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kernel_exec-symlist.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/normal_module-grub_script.tab.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/normal_module-grub_script.yy.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/normal_module-unidata.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trig_module-trigtables.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/decompressor/$(DEPDIR)/none_decompress_image-none.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/decompressor/$(DEPDIR)/xz_decompress_image-minilib.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/decompressor/$(DEPDIR)/xz_decompress_image-xz.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/i386/pc/$(DEPDIR)/boot_hybrid_image-boot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/i386/pc/$(DEPDIR)/boot_image-boot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/i386/pc/$(DEPDIR)/cdboot_image-cdboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/i386/pc/$(DEPDIR)/diskboot_image-diskboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/i386/pc/$(DEPDIR)/lnxboot_image-lnxboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/i386/pc/$(DEPDIR)/lzma_decompress_image-startup_raw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/i386/pc/$(DEPDIR)/pxeboot_image-pxeboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/i386/qemu/$(DEPDIR)/boot_image-boot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/mips/$(DEPDIR)/none_decompress_image-startup_raw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/mips/$(DEPDIR)/xz_decompress_image-startup_raw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/mips/loongson/$(DEPDIR)/fwstart_fuloong2f_image-fuloong2f.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/mips/loongson/$(DEPDIR)/fwstart_image-fwstart.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/sparc64/ieee1275/$(DEPDIR)/boot_image-boot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/sparc64/ieee1275/$(DEPDIR)/cdboot_image-boot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@boot/sparc64/ieee1275/$(DEPDIR)/diskboot_image-diskboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/$(DEPDIR)/cs5536_module-cs5536.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/$(DEPDIR)/kernel_exec-bonito.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/$(DEPDIR)/kernel_exec-cs5536.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/$(DEPDIR)/kernel_exec-fdt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/$(DEPDIR)/kernel_exec-pci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/$(DEPDIR)/pci_module-pci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/emu/$(DEPDIR)/emupci_module-pci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/i386/ieee1275/$(DEPDIR)/pci_module-pci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/spi/$(DEPDIR)/kernel_exec-rk3288_spi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/$(DEPDIR)/ehci_module-ehci-fdt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/$(DEPDIR)/ehci_module-ehci-pci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/$(DEPDIR)/ehci_module-ehci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/$(DEPDIR)/ohci_module-ohci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/$(DEPDIR)/uhci_module-uhci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/$(DEPDIR)/usb_module-usb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/$(DEPDIR)/usb_module-usbhub.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/$(DEPDIR)/usb_module-usbtrans.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/serial/$(DEPDIR)/usbserial_common_module-common.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/serial/$(DEPDIR)/usbserial_ftdi_module-ftdi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/serial/$(DEPDIR)/usbserial_pl2303_module-pl2303.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@bus/usb/serial/$(DEPDIR)/usbserial_usbdebug_module-usbdebug_late.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/acpi_module-acpi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/blocklist_module-blocklist.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/boot_module-boot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/boottime_module-boottime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/cacheinfo_module-cacheinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/cat_module-cat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/cmp_module-cmp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/configfile_module-configfile.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/date_module-date.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/echo_module-echo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/emupci_module-lspci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/eval_module-eval.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/extcmd_module-extcmd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/file_module-file.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/file_module-file32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/file_module-file64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/gptsync_module-gptsync.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/halt_module-acpihalt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/halt_module-halt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/hashsum_module-hashsum.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/hdparm_module-hdparm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/help_module-help.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/hexdump_module-hexdump.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/iorw_module-iorw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/kernel_exec-boot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/kernel_exec-extcmd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/kernel_exec-keylayouts.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/keylayouts_module-keylayouts.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/keystatus_module-keystatus.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/legacycfg_module-legacycfg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/loadenv_module-loadenv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/ls_module-ls.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/lsacpi_module-lsacpi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/lsmmap_module-lsmmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/lspci_module-lspci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/macbless_module-macbless.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/memrw_module-memrw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/minicmd_module-minicmd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/nativedisk_module-nativedisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/normal_module-menuentry.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/parttool_module-parttool.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/password_module-password.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/password_pbkdf2_module-password_pbkdf2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/pcidump_module-pcidump.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/pgp_module-pgp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/probe_module-probe.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/read_module-read.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/reboot_module-reboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/regexp_module-regexp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/regexp_module-wildcard.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/search_fs_file_module-search_file.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/search_fs_uuid_module-search_uuid.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/search_label_module-search_label.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/search_module-search_wrap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/setpci_module-setpci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/sleep_module-sleep.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/smbios_module-smbios.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/syslinuxcfg_module-syslinuxcfg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/terminal_module-terminal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/test_module-test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/testload_module-testload.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/testspeed_module-testspeed.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/time_module-time.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/tpm_module-tpm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/tr_module-tr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/true_module-true.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/usbtest_module-usbtest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/videoinfo_module-videoinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/videotest_module-videotest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/$(DEPDIR)/xnu_uuid_module-xnu_uuid.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/arc/$(DEPDIR)/lsdev_module-lsdev.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/efi/$(DEPDIR)/efifwsetup_module-efifwsetup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/efi/$(DEPDIR)/fixvideo_module-fixvideo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/efi/$(DEPDIR)/loadbios_module-loadbios.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/efi/$(DEPDIR)/lsefi_module-lsefi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/efi/$(DEPDIR)/lsefimmap_module-lsefimmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/efi/$(DEPDIR)/lsefisystab_module-lsefisystab.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/efi/$(DEPDIR)/lssal_module-lssal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/efi/$(DEPDIR)/smbios_module-smbios.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/efi/$(DEPDIR)/tpm_module-tpm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/$(DEPDIR)/cmosdump_module-cmosdump.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/$(DEPDIR)/cmostest_module-cmostest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/$(DEPDIR)/cpuid_module-cpuid.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/$(DEPDIR)/rdmsr_module-rdmsr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/$(DEPDIR)/wrmsr_module-wrmsr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/coreboot/$(DEPDIR)/cbls_module-cbls.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/coreboot/$(DEPDIR)/cbtime_module-cb_timestamps.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap_int13h.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/pc/$(DEPDIR)/halt_module-halt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/pc/$(DEPDIR)/lsapm_module-lsapm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/pc/$(DEPDIR)/play_module-play.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/pc/$(DEPDIR)/sendkey_module-sendkey.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/i386/pc/$(DEPDIR)/smbios_module-smbios.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/ieee1275/$(DEPDIR)/suspend_module-suspend.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/mips/loongson/$(DEPDIR)/lsspd_module-lsspd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@commands/xen/$(DEPDIR)/lsxen_module-lsxen.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/afsplitter_module-AFSplitter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/ahci_module-ahci.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/ata_module-ata.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/cryptodisk_module-cryptodisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/diskfilter_module-diskfilter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/dm_nv_module-dmraid_nvidia.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/geli_module-geli.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/kernel_exec-host.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/ldm_module-ldm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/loopback_module-loopback.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/luks2_module-luks2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/luks_module-luks.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/lvm_module-lvm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/mdraid09_be_module-mdraid_linux_be.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/mdraid09_module-mdraid_linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/mdraid1x_module-mdraid1x_linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/memdisk_module-memdisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/pata_module-pata.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/raid5rec_module-raid5_recover.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/raid6rec_module-raid6_recover.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/scsi_module-scsi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/$(DEPDIR)/usbms_module-usbms.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/arc/$(DEPDIR)/kernel_exec-arcdisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/efi/$(DEPDIR)/kernel_exec-efidisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/i386/pc/$(DEPDIR)/biosdisk_module-biosdisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/ieee1275/$(DEPDIR)/kernel_exec-obdisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/ieee1275/$(DEPDIR)/kernel_exec-ofdisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/ieee1275/$(DEPDIR)/nand_module-nand.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/uboot/$(DEPDIR)/kernel_exec-ubootdisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@disk/xen/$(DEPDIR)/kernel_exec-xendisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/$(DEPDIR)/efiemu_module-loadcore32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/$(DEPDIR)/efiemu_module-loadcore64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/$(DEPDIR)/efiemu_module-loadcore_common.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/$(DEPDIR)/efiemu_module-main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/$(DEPDIR)/efiemu_module-mm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/$(DEPDIR)/efiemu_module-pnvram.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/$(DEPDIR)/efiemu_module-prepare32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/$(DEPDIR)/efiemu_module-prepare64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/$(DEPDIR)/efiemu_module-symbols.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/i386/$(DEPDIR)/efiemu_module-coredetect.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/i386/$(DEPDIR)/efiemu_module-loadcore32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/i386/$(DEPDIR)/efiemu_module-loadcore64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/i386/$(DEPDIR)/efiemu_module-nocfgtables.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@efiemu/i386/pc/$(DEPDIR)/efiemu_module-cfgtables.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@font/$(DEPDIR)/font_module-font.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@font/$(DEPDIR)/font_module-font_cmd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@font/$(DEPDIR)/kernel_exec-font.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@font/$(DEPDIR)/kernel_exec-font_cmd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/affs_module-affs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/afs_module-afs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/archelp_module-archelp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/bfs_module-bfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/btrfs_module-btrfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/cbfs_module-cbfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/cpio_be_module-cpio_be.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/cpio_module-cpio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/exfat_module-exfat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/ext2_module-ext2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/f2fs_module-f2fs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/fat_module-fat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/fshelp_module-fshelp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/hfs_module-hfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/hfsplus_module-hfsplus.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/hfspluscomp_module-hfspluscomp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/iso9660_module-iso9660.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/jfs_module-jfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/minix2_be_module-minix2_be.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/minix2_module-minix2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/minix3_be_module-minix3_be.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/minix3_module-minix3.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/minix_be_module-minix_be.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/minix_module-minix.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/newc_module-newc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/nilfs2_module-nilfs2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/ntfs_module-ntfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/ntfscomp_module-ntfscomp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/odc_module-odc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/procfs_module-proc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/reiserfs_module-reiserfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/romfs_module-romfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/sfs_module-sfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/squash4_module-squash4.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/tar_module-tar.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/udf_module-udf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/ufs1_be_module-ufs_be.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/ufs1_module-ufs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/ufs2_module-ufs2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/$(DEPDIR)/xfs_module-xfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/zfs/$(DEPDIR)/zfs_module-zfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/zfs/$(DEPDIR)/zfs_module-zfs_fletcher.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/zfs/$(DEPDIR)/zfs_module-zfs_lz4.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/zfs/$(DEPDIR)/zfs_module-zfs_lzjb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/zfs/$(DEPDIR)/zfs_module-zfs_sha256.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/zfs/$(DEPDIR)/zfscrypt_module-zfscrypt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@fs/zfs/$(DEPDIR)/zfsinfo_module-zfsinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gdb/$(DEPDIR)/gdb_module-cstub.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gdb/$(DEPDIR)/gdb_module-gdb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gdb/i386/$(DEPDIR)/gdb_module-idt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gdb/i386/$(DEPDIR)/gdb_module-machdep.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gdb/i386/$(DEPDIR)/gdb_module-signal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gettext/$(DEPDIR)/gettext_module-gettext.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-font.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-gfxmenu.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-gui_box.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-gui_canvas.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-gui_circular_progress.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-gui_image.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-gui_label.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-gui_list.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-gui_progress_bar.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-gui_string_util.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-gui_util.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-icon_manager.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-theme_loader.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-view.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@gfxmenu/$(DEPDIR)/gfxmenu_module-widget-box.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@hello/$(DEPDIR)/hello_module-hello.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@hook/$(DEPDIR)/datehook_module-datehook.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@io/$(DEPDIR)/bufio_module-bufio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@io/$(DEPDIR)/gzio_module-gzio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@io/$(DEPDIR)/kernel_exec-bufio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@io/$(DEPDIR)/lzopio_module-lzopio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@io/$(DEPDIR)/offsetio_module-offset.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@io/$(DEPDIR)/xzio_module-xzio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/acpi_module-acpi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/elf_module-elf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-acpi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-buffer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-command.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-compiler-rt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-corecmd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-device.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-disk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-env.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-err.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-file.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-fs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-list.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-lockdown.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-misc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-mm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-parser.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-partition.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-rescue_parser.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-rescue_reader.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-term.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-time.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-verifiers.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/kernel_exec-vga_init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/$(DEPDIR)/xz_decompress_image-compiler-rt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/$(DEPDIR)/kernel_exec-cache.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/$(DEPDIR)/kernel_exec-cache_armv6.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/$(DEPDIR)/kernel_exec-cache_armv7.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/$(DEPDIR)/kernel_exec-compiler-rt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/$(DEPDIR)/kernel_exec-dl_helper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/coreboot/$(DEPDIR)/kernel_exec-cbtable.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/coreboot/$(DEPDIR)/kernel_exec-coreboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/coreboot/$(DEPDIR)/kernel_exec-dma.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/coreboot/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/coreboot/$(DEPDIR)/kernel_exec-timer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/efi/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/efi/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/uboot/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm/uboot/$(DEPDIR)/kernel_exec-uboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm64/$(DEPDIR)/kernel_exec-cache.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm64/$(DEPDIR)/kernel_exec-cache_flush.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm64/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm64/$(DEPDIR)/kernel_exec-dl_helper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm64/efi/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/arm64/efi/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/coreboot/$(DEPDIR)/cbtable_module-cbtable.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/coreboot/$(DEPDIR)/kernel_exec-cbtable.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/coreboot/$(DEPDIR)/kernel_exec-mmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/efi/$(DEPDIR)/kernel_exec-acpi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/efi/$(DEPDIR)/kernel_exec-efi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/efi/$(DEPDIR)/kernel_exec-fdt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/efi/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/efi/$(DEPDIR)/kernel_exec-mm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/efi/$(DEPDIR)/kernel_exec-sb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/grub_emu-full.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/grub_emu_lite-lite.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/kernel_exec-argp_common.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/kernel_exec-cache.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/kernel_exec-cache_s.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/kernel_exec-hostdisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/kernel_exec-hostfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/kernel_exec-main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/kernel_exec-misc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/kernel_exec-mm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/emu/$(DEPDIR)/kernel_exec-time.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/generic/$(DEPDIR)/kernel_exec-millisleep.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/generic/$(DEPDIR)/kernel_exec-rtc_get_time_ms.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/$(DEPDIR)/kernel_exec-multiboot_mmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/$(DEPDIR)/kernel_exec-tsc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/$(DEPDIR)/kernel_exec-tsc_pit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/$(DEPDIR)/kernel_exec-tsc_pmtimer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/$(DEPDIR)/random_module-tsc_pmtimer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/coreboot/$(DEPDIR)/cbtable_module-cbtable.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/coreboot/$(DEPDIR)/kernel_exec-cbtable.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/coreboot/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/coreboot/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/efi/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/efi/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/efi/$(DEPDIR)/kernel_exec-tsc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/ieee1275/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/pc/$(DEPDIR)/acpi_module-acpi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/pc/$(DEPDIR)/kernel_exec-acpi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/pc/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/pc/$(DEPDIR)/kernel_exec-mmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/pc/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/qemu/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/qemu/$(DEPDIR)/kernel_exec-mmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/qemu/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/xen/$(DEPDIR)/kernel_exec-hypercall.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/xen/$(DEPDIR)/kernel_exec-pvh.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/xen/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/xen/$(DEPDIR)/kernel_exec-startup_pvh.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/i386/xen/$(DEPDIR)/kernel_exec-tsc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/ia64/$(DEPDIR)/kernel_exec-cache.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/ia64/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/ia64/$(DEPDIR)/kernel_exec-dl_helper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/ia64/efi/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/ia64/efi/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/ieee1275/$(DEPDIR)/kernel_exec-cmain.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/ieee1275/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/ieee1275/$(DEPDIR)/kernel_exec-mmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/ieee1275/$(DEPDIR)/kernel_exec-openfw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/mips/$(DEPDIR)/kernel_exec-cache.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/mips/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/mips/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/mips/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/mips/arc/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/mips/loongson/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/mips/qemu_mips/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/powerpc/$(DEPDIR)/kernel_exec-cache.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/powerpc/$(DEPDIR)/kernel_exec-compiler-rt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/powerpc/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/powerpc/ieee1275/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/riscv/$(DEPDIR)/kernel_exec-cache.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/riscv/$(DEPDIR)/kernel_exec-cache_flush.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/riscv/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/riscv/efi/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/riscv/efi/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/sparc64/$(DEPDIR)/kernel_exec-cache.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/sparc64/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-crt0.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/uboot/$(DEPDIR)/kernel_exec-hw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/uboot/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/uboot/$(DEPDIR)/kernel_exec-uboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/x86_64/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/x86_64/efi/$(DEPDIR)/kernel_exec-callwrap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/x86_64/efi/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/x86_64/xen/$(DEPDIR)/kernel_exec-hypercall.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/x86_64/xen/$(DEPDIR)/kernel_exec-startup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@kern/xen/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/adler32_module-adler32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/all_video_module-fake_module.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/backtrace_module-backtrace.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/btrfs_module-crc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/chain_module-LzmaDec.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/crc64_module-crc64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/crypto_module-crypto.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/datetime_module-cmos_datetime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/datetime_module-datetime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/disk_module-disk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/div_module-division.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/extcmd_module-arg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/fdt_module-fdt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/hexdump_module-hexdump.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/kernel_exec-arg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/kernel_exec-division.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/kernel_exec-fdt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/legacycfg_module-legacy_parse.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/linux_module-cmdline.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/loadenv_module-envblk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/normal_module-getline.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/pbkdf2_module-pbkdf2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/priority_queue_module-priority_queue.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/progress_module-progress.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/random_module-random.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/relocator_module-relocator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/setjmp_module-setjmp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/syslinuxcfg_module-syslinux_parse.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/arc/$(DEPDIR)/datetime_module-datetime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/dummy/$(DEPDIR)/datetime_module-datetime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/dummy/$(DEPDIR)/halt_module-halt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/dummy/$(DEPDIR)/reboot_module-reboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/efi/$(DEPDIR)/datetime_module-datetime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/efi/$(DEPDIR)/halt_module-halt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/efi/$(DEPDIR)/relocator_module-relocator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/emu/$(DEPDIR)/halt_module-halt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/gnulib/$(DEPDIR)/luks2_module-base64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/gnulib/$(DEPDIR)/regexp_module-regex.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/backtrace_module-backtrace.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/halt_module-halt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/random_module-random.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/reboot_module-reboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/reboot_module-reboot_trampoline.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/relocator_module-relocator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/relocator_module-relocator16.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/relocator_module-relocator32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/relocator_module-relocator64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/relocator_module-relocator_asm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/$(DEPDIR)/relocator_module-relocator_common_c.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/pc/$(DEPDIR)/boot_module-biosnum.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/pc/$(DEPDIR)/legacycfg_module-vesa_modes_table.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/pc/$(DEPDIR)/linux_module-vesa_modes_table.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/i386/xen/$(DEPDIR)/relocator_module-relocator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/ieee1275/$(DEPDIR)/datetime_module-cmos.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/ieee1275/$(DEPDIR)/datetime_module-datetime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/ieee1275/$(DEPDIR)/halt_module-halt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/ieee1275/$(DEPDIR)/reboot_module-reboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/ieee1275/$(DEPDIR)/relocator_module-relocator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/json/$(DEPDIR)/json_module-json.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_arcfour_module-arcfour.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_blowfish_module-blowfish.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia-glue.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_cast5_module-cast5.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_crc_module-crc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_des_module-des.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_dsa_module-dsa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_idea_module-idea.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md4_module-md4.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md5_module-md5.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rfc2268_module-rfc2268.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rijndael_module-rijndael.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rmd160_module-rmd160.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rsa_module-rsa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_seed_module-seed.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_serpent_module-serpent.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha1_module-sha1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha256_module-sha256.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha512_module-sha512.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_tiger_module-tiger.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_twofish_module-twofish.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_whirlpool_module-whirlpool.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-add.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-bit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-cmp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-div.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-gcd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inline.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mod.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mpow.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mul.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-pow.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpicoder.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-add1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-div.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-lshift.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul3.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-rshift.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-sub1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpiutil.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/libgcrypt_wrap/$(DEPDIR)/mpi_module-mem.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/minilzo/$(DEPDIR)/lzopio_module-minilzo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/mips/$(DEPDIR)/relocator_module-relocator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/mips/$(DEPDIR)/relocator_module-relocator_asm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/mips/arc/$(DEPDIR)/reboot_module-reboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/mips/loongson/$(DEPDIR)/reboot_module-reboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/mips/qemu_mips/$(DEPDIR)/reboot_module-reboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/powerpc/$(DEPDIR)/relocator_module-relocator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/powerpc/$(DEPDIR)/relocator_module-relocator_asm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/uboot/$(DEPDIR)/reboot_module-reboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/x86_64/$(DEPDIR)/relocator_module-relocator_asm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/x86_64/efi/$(DEPDIR)/relocator_module-relocator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/x86_64/xen/$(DEPDIR)/relocator_module-relocator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/xen/$(DEPDIR)/datetime_module-datetime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/xen/$(DEPDIR)/halt_module-halt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/xen/$(DEPDIR)/reboot_module-reboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/xen/$(DEPDIR)/relocator_module-relocator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_bcj.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_lzma2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_stream.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_bcj.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_lzma2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_stream.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/zstd/$(DEPDIR)/zstd_module-debug.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/zstd/$(DEPDIR)/zstd_module-entropy_common.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/zstd/$(DEPDIR)/zstd_module-error_private.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/zstd/$(DEPDIR)/zstd_module-fse_decompress.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/zstd/$(DEPDIR)/zstd_module-huf_decompress.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/zstd/$(DEPDIR)/zstd_module-module.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/zstd/$(DEPDIR)/zstd_module-xxhash.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/zstd/$(DEPDIR)/zstd_module-zstd_common.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@lib/zstd/$(DEPDIR)/zstd_module-zstd_decompress.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/aout_module-aout.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/linux_module-linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/macho_module-lzss.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/macho_module-macho.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/macho_module-macho32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/macho_module-macho64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/multiboot2_module-multiboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/multiboot2_module-multiboot_mbi2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/multiboot_module-multiboot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/xnu_module-xnu.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/$(DEPDIR)/xnu_module-xnu_resume.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/arm/$(DEPDIR)/linux_module-linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/arm64/$(DEPDIR)/linux_module-linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/arm64/$(DEPDIR)/xen_boot_module-xen_boot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/efi/$(DEPDIR)/appleldr_module-appleloader.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/efi/$(DEPDIR)/chain_module-chainloader.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/efi/$(DEPDIR)/fdt_module-fdt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/$(DEPDIR)/bsd_module-bsd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/$(DEPDIR)/bsd_module-bsd32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/$(DEPDIR)/bsd_module-bsd64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/$(DEPDIR)/file_module-xen_file.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/$(DEPDIR)/file_module-xen_file32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/$(DEPDIR)/file_module-xen_file64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/$(DEPDIR)/linux_module-linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/$(DEPDIR)/linux_module-xen.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/$(DEPDIR)/multiboot_module-multiboot_mbi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/$(DEPDIR)/xnu_module-xnu.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/coreboot/$(DEPDIR)/chain_module-chainloader.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/pc/$(DEPDIR)/chain_module-chainloader.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/pc/$(DEPDIR)/freedos_module-freedos.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/pc/$(DEPDIR)/linux16_module-linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/pc/$(DEPDIR)/ntldr_module-ntldr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/pc/$(DEPDIR)/plan9_module-plan9.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/pc/$(DEPDIR)/pxechain_module-pxechainloader.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/i386/pc/$(DEPDIR)/truecrypt_module-truecrypt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/ia64/efi/$(DEPDIR)/linux_module-linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/mips/$(DEPDIR)/linux_module-linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/powerpc/ieee1275/$(DEPDIR)/linux_module-linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/riscv/$(DEPDIR)/linux_module-linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@loader/sparc64/ieee1275/$(DEPDIR)/linux_module-linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@mmap/$(DEPDIR)/mmap_module-mmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@mmap/efi/$(DEPDIR)/mmap_module-mmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@mmap/i386/$(DEPDIR)/mmap_module-mmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@mmap/i386/$(DEPDIR)/mmap_module-uppermem.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@mmap/i386/pc/$(DEPDIR)/mmap_module-mmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@mmap/i386/pc/$(DEPDIR)/mmap_module-mmap_helper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@mmap/mips/$(DEPDIR)/mmap_module-uppermem.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/http_module-http.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-arp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-bootp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-dns.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-ethernet.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-icmp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-icmp6.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-ip.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-net.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-netbuff.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-tcp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/net_module-udp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/$(DEPDIR)/tftp_module-tftp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/drivers/efi/$(DEPDIR)/efinet_module-efinet.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/drivers/emu/$(DEPDIR)/emunet_module-emunet.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/drivers/i386/pc/$(DEPDIR)/pxe_module-pxe.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/drivers/ieee1275/$(DEPDIR)/ofnet_module-ofnet.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@net/drivers/uboot/$(DEPDIR)/ubootnet_module-ubootnet.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-auth.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-autofs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-charset.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-cmdline.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-color.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-completion.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-context.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-crypto.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-dyncmd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-menu.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-menu_entry.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-menu_text.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-misc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@normal/$(DEPDIR)/normal_module-term.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@osdep/$(DEPDIR)/kernel_exec-cputime.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@osdep/$(DEPDIR)/kernel_exec-dl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@osdep/$(DEPDIR)/kernel_exec-emuconsole.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@osdep/$(DEPDIR)/kernel_exec-emunet.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@osdep/$(DEPDIR)/kernel_exec-exec.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@osdep/$(DEPDIR)/kernel_exec-hostdisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@osdep/$(DEPDIR)/kernel_exec-init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@osdep/$(DEPDIR)/kernel_exec-sleep.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@osdep/devmapper/$(DEPDIR)/kernel_exec-hostdisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@osdep/unix/$(DEPDIR)/kernel_exec-hostdisk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_acorn_module-acorn.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_amiga_module-amiga.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_apple_module-apple.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_bsd_module-bsdlabel.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_dfly_module-dfly.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_dvh_module-dvh.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_gpt_module-gpt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_msdos_module-msdos.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_plan_module-plan.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_sun_module-sun.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@partmap/$(DEPDIR)/part_sunpc_module-sunpc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@parttool/$(DEPDIR)/msdospart_module-msdospart.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@script/$(DEPDIR)/normal_module-argv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@script/$(DEPDIR)/normal_module-execute.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@script/$(DEPDIR)/normal_module-function.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@script/$(DEPDIR)/normal_module-lexer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@script/$(DEPDIR)/normal_module-main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@script/$(DEPDIR)/normal_module-script.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/at_keyboard_module-at_keyboard.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/at_keyboard_module-ps2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/gfxterm_background_module-gfxterm_background.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/gfxterm_module-gfxterm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/kernel_exec-at_keyboard.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/kernel_exec-gfxterm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/kernel_exec-ns8250.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/kernel_exec-ps2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/kernel_exec-serial.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/kernel_exec-terminfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/kernel_exec-tparm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/morse_module-morse.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/serial_module-ns8250.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/serial_module-serial.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/spkmodem_module-spkmodem.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/terminfo_module-terminfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/terminfo_module-tparm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/$(DEPDIR)/usb_keyboard_module-usb_keyboard.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/arc/$(DEPDIR)/kernel_exec-console.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/arc/$(DEPDIR)/serial_module-serial.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/arm/$(DEPDIR)/kernel_exec-cros.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/arm/$(DEPDIR)/kernel_exec-cros_ec.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/arm/$(DEPDIR)/kernel_exec-pl050.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/efi/$(DEPDIR)/kernel_exec-console.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/efi/$(DEPDIR)/serial_module-serial.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/i386/coreboot/$(DEPDIR)/cbmemc_module-cbmemc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/i386/pc/$(DEPDIR)/kernel_exec-console.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/i386/pc/$(DEPDIR)/kernel_exec-vga_text.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/i386/pc/$(DEPDIR)/mda_text_module-mda_text.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/i386/pc/$(DEPDIR)/vga_text_module-vga_text.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/ieee1275/$(DEPDIR)/escc_module-escc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/ieee1275/$(DEPDIR)/kernel_exec-console.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/ieee1275/$(DEPDIR)/serial_module-serial.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/uboot/$(DEPDIR)/kernel_exec-console.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@term/xen/$(DEPDIR)/kernel_exec-console.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/bswap_test_module-bswap_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/cmdline_cat_test_module-cmdline_cat_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/cmp_test_module-cmp_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/ctz_test_module-ctz_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/div_test_module-div_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/exfctest_module-example_functional_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/functional_test_module-fake_input.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/functional_test_module-video_checksum.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/gfxterm_menu_module-gfxterm_menu.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/legacy_password_test_module-legacy_password_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/mul_test_module-mul_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/pbkdf2_test_module-pbkdf2_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/setjmp_test_module-setjmp_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/shift_test_module-shift_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/signature_test_module-signature_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/sleep_test_module-sleep_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/strtoull_test_module-strtoull_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/test_blockarg_module-test_blockarg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/videotest_checksum_module-videotest_checksum.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/xnu_uuid_test_module-xnu_uuid_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/lib/$(DEPDIR)/functional_test_module-functional_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/lib/$(DEPDIR)/functional_test_module-test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/bitmap_module-bitmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/bitmap_scale_module-bitmap_scale.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/efi_gop_module-efi_gop.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/efi_uga_module-efi_uga.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/functional_test_module-capture.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/ieee1275_fb_module-ieee1275.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/kernel_exec-radeon_fuloong2e.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/kernel_exec-radeon_yeeloong3a.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/kernel_exec-sis315pro.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/kernel_exec-sm712.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/kernel_exec-video.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/video_bochs_module-bochs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/video_cirrus_module-cirrus.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/video_colors_module-colors.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/$(DEPDIR)/video_module-video.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/coreboot/$(DEPDIR)/kernel_exec-cbfb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/emu/$(DEPDIR)/sdl_module-sdl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/fb/$(DEPDIR)/kernel_exec-fbblit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/fb/$(DEPDIR)/kernel_exec-fbfill.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/fb/$(DEPDIR)/kernel_exec-fbutil.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/fb/$(DEPDIR)/kernel_exec-video_fb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/fb/$(DEPDIR)/video_fb_module-fbblit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/fb/$(DEPDIR)/video_fb_module-fbfill.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/fb/$(DEPDIR)/video_fb_module-fbutil.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/fb/$(DEPDIR)/video_fb_module-video_fb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/i386/pc/$(DEPDIR)/vbe_module-vbe.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/i386/pc/$(DEPDIR)/vga_module-vga.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/readers/$(DEPDIR)/jpeg_module-jpeg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/readers/$(DEPDIR)/png_module-png.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@video/readers/$(DEPDIR)/tga_module-tga.Po@am__quote@
+
+.S.o:
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ $<
+
+.S.obj:
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+boot/i386/pc/boot_image-boot.o: boot/i386/pc/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/boot_image-boot.o -MD -MP -MF boot/i386/pc/$(DEPDIR)/boot_image-boot.Tpo -c -o boot/i386/pc/boot_image-boot.o `test -f 'boot/i386/pc/boot.S' || echo '$(srcdir)/'`boot/i386/pc/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/boot_image-boot.Tpo boot/i386/pc/$(DEPDIR)/boot_image-boot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/boot.S' object='boot/i386/pc/boot_image-boot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/boot_image-boot.o `test -f 'boot/i386/pc/boot.S' || echo '$(srcdir)/'`boot/i386/pc/boot.S
+
+boot/i386/pc/boot_image-boot.obj: boot/i386/pc/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/boot_image-boot.obj -MD -MP -MF boot/i386/pc/$(DEPDIR)/boot_image-boot.Tpo -c -o boot/i386/pc/boot_image-boot.obj `if test -f 'boot/i386/pc/boot.S'; then $(CYGPATH_W) 'boot/i386/pc/boot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/boot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/boot_image-boot.Tpo boot/i386/pc/$(DEPDIR)/boot_image-boot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/boot.S' object='boot/i386/pc/boot_image-boot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/boot_image-boot.obj `if test -f 'boot/i386/pc/boot.S'; then $(CYGPATH_W) 'boot/i386/pc/boot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/boot.S'; fi`
+
+boot/i386/qemu/boot_image-boot.o: boot/i386/qemu/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/qemu/boot_image-boot.o -MD -MP -MF boot/i386/qemu/$(DEPDIR)/boot_image-boot.Tpo -c -o boot/i386/qemu/boot_image-boot.o `test -f 'boot/i386/qemu/boot.S' || echo '$(srcdir)/'`boot/i386/qemu/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/qemu/$(DEPDIR)/boot_image-boot.Tpo boot/i386/qemu/$(DEPDIR)/boot_image-boot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/qemu/boot.S' object='boot/i386/qemu/boot_image-boot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/qemu/boot_image-boot.o `test -f 'boot/i386/qemu/boot.S' || echo '$(srcdir)/'`boot/i386/qemu/boot.S
+
+boot/i386/qemu/boot_image-boot.obj: boot/i386/qemu/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/qemu/boot_image-boot.obj -MD -MP -MF boot/i386/qemu/$(DEPDIR)/boot_image-boot.Tpo -c -o boot/i386/qemu/boot_image-boot.obj `if test -f 'boot/i386/qemu/boot.S'; then $(CYGPATH_W) 'boot/i386/qemu/boot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/qemu/boot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/qemu/$(DEPDIR)/boot_image-boot.Tpo boot/i386/qemu/$(DEPDIR)/boot_image-boot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/qemu/boot.S' object='boot/i386/qemu/boot_image-boot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/qemu/boot_image-boot.obj `if test -f 'boot/i386/qemu/boot.S'; then $(CYGPATH_W) 'boot/i386/qemu/boot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/qemu/boot.S'; fi`
+
+boot/sparc64/ieee1275/boot_image-boot.o: boot/sparc64/ieee1275/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/sparc64/ieee1275/boot_image-boot.o -MD -MP -MF boot/sparc64/ieee1275/$(DEPDIR)/boot_image-boot.Tpo -c -o boot/sparc64/ieee1275/boot_image-boot.o `test -f 'boot/sparc64/ieee1275/boot.S' || echo '$(srcdir)/'`boot/sparc64/ieee1275/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/sparc64/ieee1275/$(DEPDIR)/boot_image-boot.Tpo boot/sparc64/ieee1275/$(DEPDIR)/boot_image-boot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/sparc64/ieee1275/boot.S' object='boot/sparc64/ieee1275/boot_image-boot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/sparc64/ieee1275/boot_image-boot.o `test -f 'boot/sparc64/ieee1275/boot.S' || echo '$(srcdir)/'`boot/sparc64/ieee1275/boot.S
+
+boot/sparc64/ieee1275/boot_image-boot.obj: boot/sparc64/ieee1275/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/sparc64/ieee1275/boot_image-boot.obj -MD -MP -MF boot/sparc64/ieee1275/$(DEPDIR)/boot_image-boot.Tpo -c -o boot/sparc64/ieee1275/boot_image-boot.obj `if test -f 'boot/sparc64/ieee1275/boot.S'; then $(CYGPATH_W) 'boot/sparc64/ieee1275/boot.S'; else $(CYGPATH_W) '$(srcdir)/boot/sparc64/ieee1275/boot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/sparc64/ieee1275/$(DEPDIR)/boot_image-boot.Tpo boot/sparc64/ieee1275/$(DEPDIR)/boot_image-boot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/sparc64/ieee1275/boot.S' object='boot/sparc64/ieee1275/boot_image-boot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_image_CPPFLAGS) $(CPPFLAGS) $(boot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/sparc64/ieee1275/boot_image-boot.obj `if test -f 'boot/sparc64/ieee1275/boot.S'; then $(CYGPATH_W) 'boot/sparc64/ieee1275/boot.S'; else $(CYGPATH_W) '$(srcdir)/boot/sparc64/ieee1275/boot.S'; fi`
+
+boot/i386/pc/boot_hybrid_image-boot.o: boot/i386/pc/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_hybrid_image_CPPFLAGS) $(CPPFLAGS) $(boot_hybrid_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/boot_hybrid_image-boot.o -MD -MP -MF boot/i386/pc/$(DEPDIR)/boot_hybrid_image-boot.Tpo -c -o boot/i386/pc/boot_hybrid_image-boot.o `test -f 'boot/i386/pc/boot.S' || echo '$(srcdir)/'`boot/i386/pc/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/boot_hybrid_image-boot.Tpo boot/i386/pc/$(DEPDIR)/boot_hybrid_image-boot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/boot.S' object='boot/i386/pc/boot_hybrid_image-boot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_hybrid_image_CPPFLAGS) $(CPPFLAGS) $(boot_hybrid_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/boot_hybrid_image-boot.o `test -f 'boot/i386/pc/boot.S' || echo '$(srcdir)/'`boot/i386/pc/boot.S
+
+boot/i386/pc/boot_hybrid_image-boot.obj: boot/i386/pc/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_hybrid_image_CPPFLAGS) $(CPPFLAGS) $(boot_hybrid_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/boot_hybrid_image-boot.obj -MD -MP -MF boot/i386/pc/$(DEPDIR)/boot_hybrid_image-boot.Tpo -c -o boot/i386/pc/boot_hybrid_image-boot.obj `if test -f 'boot/i386/pc/boot.S'; then $(CYGPATH_W) 'boot/i386/pc/boot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/boot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/boot_hybrid_image-boot.Tpo boot/i386/pc/$(DEPDIR)/boot_hybrid_image-boot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/boot.S' object='boot/i386/pc/boot_hybrid_image-boot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_hybrid_image_CPPFLAGS) $(CPPFLAGS) $(boot_hybrid_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/boot_hybrid_image-boot.obj `if test -f 'boot/i386/pc/boot.S'; then $(CYGPATH_W) 'boot/i386/pc/boot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/boot.S'; fi`
+
+boot/i386/pc/cdboot_image-cdboot.o: boot/i386/pc/cdboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdboot_image_CPPFLAGS) $(CPPFLAGS) $(cdboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/cdboot_image-cdboot.o -MD -MP -MF boot/i386/pc/$(DEPDIR)/cdboot_image-cdboot.Tpo -c -o boot/i386/pc/cdboot_image-cdboot.o `test -f 'boot/i386/pc/cdboot.S' || echo '$(srcdir)/'`boot/i386/pc/cdboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/cdboot_image-cdboot.Tpo boot/i386/pc/$(DEPDIR)/cdboot_image-cdboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/cdboot.S' object='boot/i386/pc/cdboot_image-cdboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdboot_image_CPPFLAGS) $(CPPFLAGS) $(cdboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/cdboot_image-cdboot.o `test -f 'boot/i386/pc/cdboot.S' || echo '$(srcdir)/'`boot/i386/pc/cdboot.S
+
+boot/i386/pc/cdboot_image-cdboot.obj: boot/i386/pc/cdboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdboot_image_CPPFLAGS) $(CPPFLAGS) $(cdboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/cdboot_image-cdboot.obj -MD -MP -MF boot/i386/pc/$(DEPDIR)/cdboot_image-cdboot.Tpo -c -o boot/i386/pc/cdboot_image-cdboot.obj `if test -f 'boot/i386/pc/cdboot.S'; then $(CYGPATH_W) 'boot/i386/pc/cdboot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/cdboot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/cdboot_image-cdboot.Tpo boot/i386/pc/$(DEPDIR)/cdboot_image-cdboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/cdboot.S' object='boot/i386/pc/cdboot_image-cdboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdboot_image_CPPFLAGS) $(CPPFLAGS) $(cdboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/cdboot_image-cdboot.obj `if test -f 'boot/i386/pc/cdboot.S'; then $(CYGPATH_W) 'boot/i386/pc/cdboot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/cdboot.S'; fi`
+
+boot/sparc64/ieee1275/cdboot_image-boot.o: boot/sparc64/ieee1275/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdboot_image_CPPFLAGS) $(CPPFLAGS) $(cdboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/sparc64/ieee1275/cdboot_image-boot.o -MD -MP -MF boot/sparc64/ieee1275/$(DEPDIR)/cdboot_image-boot.Tpo -c -o boot/sparc64/ieee1275/cdboot_image-boot.o `test -f 'boot/sparc64/ieee1275/boot.S' || echo '$(srcdir)/'`boot/sparc64/ieee1275/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/sparc64/ieee1275/$(DEPDIR)/cdboot_image-boot.Tpo boot/sparc64/ieee1275/$(DEPDIR)/cdboot_image-boot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/sparc64/ieee1275/boot.S' object='boot/sparc64/ieee1275/cdboot_image-boot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdboot_image_CPPFLAGS) $(CPPFLAGS) $(cdboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/sparc64/ieee1275/cdboot_image-boot.o `test -f 'boot/sparc64/ieee1275/boot.S' || echo '$(srcdir)/'`boot/sparc64/ieee1275/boot.S
+
+boot/sparc64/ieee1275/cdboot_image-boot.obj: boot/sparc64/ieee1275/boot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdboot_image_CPPFLAGS) $(CPPFLAGS) $(cdboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/sparc64/ieee1275/cdboot_image-boot.obj -MD -MP -MF boot/sparc64/ieee1275/$(DEPDIR)/cdboot_image-boot.Tpo -c -o boot/sparc64/ieee1275/cdboot_image-boot.obj `if test -f 'boot/sparc64/ieee1275/boot.S'; then $(CYGPATH_W) 'boot/sparc64/ieee1275/boot.S'; else $(CYGPATH_W) '$(srcdir)/boot/sparc64/ieee1275/boot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/sparc64/ieee1275/$(DEPDIR)/cdboot_image-boot.Tpo boot/sparc64/ieee1275/$(DEPDIR)/cdboot_image-boot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/sparc64/ieee1275/boot.S' object='boot/sparc64/ieee1275/cdboot_image-boot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdboot_image_CPPFLAGS) $(CPPFLAGS) $(cdboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/sparc64/ieee1275/cdboot_image-boot.obj `if test -f 'boot/sparc64/ieee1275/boot.S'; then $(CYGPATH_W) 'boot/sparc64/ieee1275/boot.S'; else $(CYGPATH_W) '$(srcdir)/boot/sparc64/ieee1275/boot.S'; fi`
+
+boot/i386/pc/diskboot_image-diskboot.o: boot/i386/pc/diskboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskboot_image_CPPFLAGS) $(CPPFLAGS) $(diskboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/diskboot_image-diskboot.o -MD -MP -MF boot/i386/pc/$(DEPDIR)/diskboot_image-diskboot.Tpo -c -o boot/i386/pc/diskboot_image-diskboot.o `test -f 'boot/i386/pc/diskboot.S' || echo '$(srcdir)/'`boot/i386/pc/diskboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/diskboot_image-diskboot.Tpo boot/i386/pc/$(DEPDIR)/diskboot_image-diskboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/diskboot.S' object='boot/i386/pc/diskboot_image-diskboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskboot_image_CPPFLAGS) $(CPPFLAGS) $(diskboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/diskboot_image-diskboot.o `test -f 'boot/i386/pc/diskboot.S' || echo '$(srcdir)/'`boot/i386/pc/diskboot.S
+
+boot/i386/pc/diskboot_image-diskboot.obj: boot/i386/pc/diskboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskboot_image_CPPFLAGS) $(CPPFLAGS) $(diskboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/diskboot_image-diskboot.obj -MD -MP -MF boot/i386/pc/$(DEPDIR)/diskboot_image-diskboot.Tpo -c -o boot/i386/pc/diskboot_image-diskboot.obj `if test -f 'boot/i386/pc/diskboot.S'; then $(CYGPATH_W) 'boot/i386/pc/diskboot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/diskboot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/diskboot_image-diskboot.Tpo boot/i386/pc/$(DEPDIR)/diskboot_image-diskboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/diskboot.S' object='boot/i386/pc/diskboot_image-diskboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskboot_image_CPPFLAGS) $(CPPFLAGS) $(diskboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/diskboot_image-diskboot.obj `if test -f 'boot/i386/pc/diskboot.S'; then $(CYGPATH_W) 'boot/i386/pc/diskboot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/diskboot.S'; fi`
+
+boot/sparc64/ieee1275/diskboot_image-diskboot.o: boot/sparc64/ieee1275/diskboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskboot_image_CPPFLAGS) $(CPPFLAGS) $(diskboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/sparc64/ieee1275/diskboot_image-diskboot.o -MD -MP -MF boot/sparc64/ieee1275/$(DEPDIR)/diskboot_image-diskboot.Tpo -c -o boot/sparc64/ieee1275/diskboot_image-diskboot.o `test -f 'boot/sparc64/ieee1275/diskboot.S' || echo '$(srcdir)/'`boot/sparc64/ieee1275/diskboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/sparc64/ieee1275/$(DEPDIR)/diskboot_image-diskboot.Tpo boot/sparc64/ieee1275/$(DEPDIR)/diskboot_image-diskboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/sparc64/ieee1275/diskboot.S' object='boot/sparc64/ieee1275/diskboot_image-diskboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskboot_image_CPPFLAGS) $(CPPFLAGS) $(diskboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/sparc64/ieee1275/diskboot_image-diskboot.o `test -f 'boot/sparc64/ieee1275/diskboot.S' || echo '$(srcdir)/'`boot/sparc64/ieee1275/diskboot.S
+
+boot/sparc64/ieee1275/diskboot_image-diskboot.obj: boot/sparc64/ieee1275/diskboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskboot_image_CPPFLAGS) $(CPPFLAGS) $(diskboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/sparc64/ieee1275/diskboot_image-diskboot.obj -MD -MP -MF boot/sparc64/ieee1275/$(DEPDIR)/diskboot_image-diskboot.Tpo -c -o boot/sparc64/ieee1275/diskboot_image-diskboot.obj `if test -f 'boot/sparc64/ieee1275/diskboot.S'; then $(CYGPATH_W) 'boot/sparc64/ieee1275/diskboot.S'; else $(CYGPATH_W) '$(srcdir)/boot/sparc64/ieee1275/diskboot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/sparc64/ieee1275/$(DEPDIR)/diskboot_image-diskboot.Tpo boot/sparc64/ieee1275/$(DEPDIR)/diskboot_image-diskboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/sparc64/ieee1275/diskboot.S' object='boot/sparc64/ieee1275/diskboot_image-diskboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskboot_image_CPPFLAGS) $(CPPFLAGS) $(diskboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/sparc64/ieee1275/diskboot_image-diskboot.obj `if test -f 'boot/sparc64/ieee1275/diskboot.S'; then $(CYGPATH_W) 'boot/sparc64/ieee1275/diskboot.S'; else $(CYGPATH_W) '$(srcdir)/boot/sparc64/ieee1275/diskboot.S'; fi`
+
+commands/i386/pc/drivemap_module-drivemap_int13h.o: commands/i386/pc/drivemap_int13h.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(drivemap_module_CPPFLAGS) $(CPPFLAGS) $(drivemap_module_CCASFLAGS) $(CCASFLAGS) -MT commands/i386/pc/drivemap_module-drivemap_int13h.o -MD -MP -MF commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap_int13h.Tpo -c -o commands/i386/pc/drivemap_module-drivemap_int13h.o `test -f 'commands/i386/pc/drivemap_int13h.S' || echo '$(srcdir)/'`commands/i386/pc/drivemap_int13h.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap_int13h.Tpo commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap_int13h.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='commands/i386/pc/drivemap_int13h.S' object='commands/i386/pc/drivemap_module-drivemap_int13h.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(drivemap_module_CPPFLAGS) $(CPPFLAGS) $(drivemap_module_CCASFLAGS) $(CCASFLAGS) -c -o commands/i386/pc/drivemap_module-drivemap_int13h.o `test -f 'commands/i386/pc/drivemap_int13h.S' || echo '$(srcdir)/'`commands/i386/pc/drivemap_int13h.S
+
+commands/i386/pc/drivemap_module-drivemap_int13h.obj: commands/i386/pc/drivemap_int13h.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(drivemap_module_CPPFLAGS) $(CPPFLAGS) $(drivemap_module_CCASFLAGS) $(CCASFLAGS) -MT commands/i386/pc/drivemap_module-drivemap_int13h.obj -MD -MP -MF commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap_int13h.Tpo -c -o commands/i386/pc/drivemap_module-drivemap_int13h.obj `if test -f 'commands/i386/pc/drivemap_int13h.S'; then $(CYGPATH_W) 'commands/i386/pc/drivemap_int13h.S'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/drivemap_int13h.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap_int13h.Tpo commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap_int13h.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='commands/i386/pc/drivemap_int13h.S' object='commands/i386/pc/drivemap_module-drivemap_int13h.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(drivemap_module_CPPFLAGS) $(CPPFLAGS) $(drivemap_module_CCASFLAGS) $(CCASFLAGS) -c -o commands/i386/pc/drivemap_module-drivemap_int13h.obj `if test -f 'commands/i386/pc/drivemap_int13h.S'; then $(CYGPATH_W) 'commands/i386/pc/drivemap_int13h.S'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/drivemap_int13h.S'; fi`
+
+boot/mips/loongson/fwstart_image-fwstart.o: boot/mips/loongson/fwstart.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fwstart_image_CPPFLAGS) $(CPPFLAGS) $(fwstart_image_CCASFLAGS) $(CCASFLAGS) -MT boot/mips/loongson/fwstart_image-fwstart.o -MD -MP -MF boot/mips/loongson/$(DEPDIR)/fwstart_image-fwstart.Tpo -c -o boot/mips/loongson/fwstart_image-fwstart.o `test -f 'boot/mips/loongson/fwstart.S' || echo '$(srcdir)/'`boot/mips/loongson/fwstart.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/mips/loongson/$(DEPDIR)/fwstart_image-fwstart.Tpo boot/mips/loongson/$(DEPDIR)/fwstart_image-fwstart.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/mips/loongson/fwstart.S' object='boot/mips/loongson/fwstart_image-fwstart.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fwstart_image_CPPFLAGS) $(CPPFLAGS) $(fwstart_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/mips/loongson/fwstart_image-fwstart.o `test -f 'boot/mips/loongson/fwstart.S' || echo '$(srcdir)/'`boot/mips/loongson/fwstart.S
+
+boot/mips/loongson/fwstart_image-fwstart.obj: boot/mips/loongson/fwstart.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fwstart_image_CPPFLAGS) $(CPPFLAGS) $(fwstart_image_CCASFLAGS) $(CCASFLAGS) -MT boot/mips/loongson/fwstart_image-fwstart.obj -MD -MP -MF boot/mips/loongson/$(DEPDIR)/fwstart_image-fwstart.Tpo -c -o boot/mips/loongson/fwstart_image-fwstart.obj `if test -f 'boot/mips/loongson/fwstart.S'; then $(CYGPATH_W) 'boot/mips/loongson/fwstart.S'; else $(CYGPATH_W) '$(srcdir)/boot/mips/loongson/fwstart.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/mips/loongson/$(DEPDIR)/fwstart_image-fwstart.Tpo boot/mips/loongson/$(DEPDIR)/fwstart_image-fwstart.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/mips/loongson/fwstart.S' object='boot/mips/loongson/fwstart_image-fwstart.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fwstart_image_CPPFLAGS) $(CPPFLAGS) $(fwstart_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/mips/loongson/fwstart_image-fwstart.obj `if test -f 'boot/mips/loongson/fwstart.S'; then $(CYGPATH_W) 'boot/mips/loongson/fwstart.S'; else $(CYGPATH_W) '$(srcdir)/boot/mips/loongson/fwstart.S'; fi`
+
+boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.o: boot/mips/loongson/fuloong2f.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fwstart_fuloong2f_image_CPPFLAGS) $(CPPFLAGS) $(fwstart_fuloong2f_image_CCASFLAGS) $(CCASFLAGS) -MT boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.o -MD -MP -MF boot/mips/loongson/$(DEPDIR)/fwstart_fuloong2f_image-fuloong2f.Tpo -c -o boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.o `test -f 'boot/mips/loongson/fuloong2f.S' || echo '$(srcdir)/'`boot/mips/loongson/fuloong2f.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/mips/loongson/$(DEPDIR)/fwstart_fuloong2f_image-fuloong2f.Tpo boot/mips/loongson/$(DEPDIR)/fwstart_fuloong2f_image-fuloong2f.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/mips/loongson/fuloong2f.S' object='boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fwstart_fuloong2f_image_CPPFLAGS) $(CPPFLAGS) $(fwstart_fuloong2f_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.o `test -f 'boot/mips/loongson/fuloong2f.S' || echo '$(srcdir)/'`boot/mips/loongson/fuloong2f.S
+
+boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.obj: boot/mips/loongson/fuloong2f.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fwstart_fuloong2f_image_CPPFLAGS) $(CPPFLAGS) $(fwstart_fuloong2f_image_CCASFLAGS) $(CCASFLAGS) -MT boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.obj -MD -MP -MF boot/mips/loongson/$(DEPDIR)/fwstart_fuloong2f_image-fuloong2f.Tpo -c -o boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.obj `if test -f 'boot/mips/loongson/fuloong2f.S'; then $(CYGPATH_W) 'boot/mips/loongson/fuloong2f.S'; else $(CYGPATH_W) '$(srcdir)/boot/mips/loongson/fuloong2f.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/mips/loongson/$(DEPDIR)/fwstart_fuloong2f_image-fuloong2f.Tpo boot/mips/loongson/$(DEPDIR)/fwstart_fuloong2f_image-fuloong2f.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/mips/loongson/fuloong2f.S' object='boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fwstart_fuloong2f_image_CPPFLAGS) $(CPPFLAGS) $(fwstart_fuloong2f_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/mips/loongson/fwstart_fuloong2f_image-fuloong2f.obj `if test -f 'boot/mips/loongson/fuloong2f.S'; then $(CYGPATH_W) 'boot/mips/loongson/fuloong2f.S'; else $(CYGPATH_W) '$(srcdir)/boot/mips/loongson/fuloong2f.S'; fi`
+
+gdb/i386/gdb_module-machdep.o: gdb/i386/machdep.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CCASFLAGS) $(CCASFLAGS) -MT gdb/i386/gdb_module-machdep.o -MD -MP -MF gdb/i386/$(DEPDIR)/gdb_module-machdep.Tpo -c -o gdb/i386/gdb_module-machdep.o `test -f 'gdb/i386/machdep.S' || echo '$(srcdir)/'`gdb/i386/machdep.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) gdb/i386/$(DEPDIR)/gdb_module-machdep.Tpo gdb/i386/$(DEPDIR)/gdb_module-machdep.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='gdb/i386/machdep.S' object='gdb/i386/gdb_module-machdep.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CCASFLAGS) $(CCASFLAGS) -c -o gdb/i386/gdb_module-machdep.o `test -f 'gdb/i386/machdep.S' || echo '$(srcdir)/'`gdb/i386/machdep.S
+
+gdb/i386/gdb_module-machdep.obj: gdb/i386/machdep.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CCASFLAGS) $(CCASFLAGS) -MT gdb/i386/gdb_module-machdep.obj -MD -MP -MF gdb/i386/$(DEPDIR)/gdb_module-machdep.Tpo -c -o gdb/i386/gdb_module-machdep.obj `if test -f 'gdb/i386/machdep.S'; then $(CYGPATH_W) 'gdb/i386/machdep.S'; else $(CYGPATH_W) '$(srcdir)/gdb/i386/machdep.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) gdb/i386/$(DEPDIR)/gdb_module-machdep.Tpo gdb/i386/$(DEPDIR)/gdb_module-machdep.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='gdb/i386/machdep.S' object='gdb/i386/gdb_module-machdep.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CCASFLAGS) $(CCASFLAGS) -c -o gdb/i386/gdb_module-machdep.obj `if test -f 'gdb/i386/machdep.S'; then $(CYGPATH_W) 'gdb/i386/machdep.S'; else $(CYGPATH_W) '$(srcdir)/gdb/i386/machdep.S'; fi`
+
+kern/arm64/efi/kernel_exec-startup.o: kern/arm64/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm64/efi/kernel_exec-startup.o -MD -MP -MF kern/arm64/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/arm64/efi/kernel_exec-startup.o `test -f 'kern/arm64/efi/startup.S' || echo '$(srcdir)/'`kern/arm64/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/arm64/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm64/efi/startup.S' object='kern/arm64/efi/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm64/efi/kernel_exec-startup.o `test -f 'kern/arm64/efi/startup.S' || echo '$(srcdir)/'`kern/arm64/efi/startup.S
+
+kern/arm64/efi/kernel_exec-startup.obj: kern/arm64/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm64/efi/kernel_exec-startup.obj -MD -MP -MF kern/arm64/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/arm64/efi/kernel_exec-startup.obj `if test -f 'kern/arm64/efi/startup.S'; then $(CYGPATH_W) 'kern/arm64/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/efi/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/arm64/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm64/efi/startup.S' object='kern/arm64/efi/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm64/efi/kernel_exec-startup.obj `if test -f 'kern/arm64/efi/startup.S'; then $(CYGPATH_W) 'kern/arm64/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/efi/startup.S'; fi`
+
+kern/arm64/kernel_exec-cache_flush.o: kern/arm64/cache_flush.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm64/kernel_exec-cache_flush.o -MD -MP -MF kern/arm64/$(DEPDIR)/kernel_exec-cache_flush.Tpo -c -o kern/arm64/kernel_exec-cache_flush.o `test -f 'kern/arm64/cache_flush.S' || echo '$(srcdir)/'`kern/arm64/cache_flush.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/$(DEPDIR)/kernel_exec-cache_flush.Tpo kern/arm64/$(DEPDIR)/kernel_exec-cache_flush.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm64/cache_flush.S' object='kern/arm64/kernel_exec-cache_flush.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm64/kernel_exec-cache_flush.o `test -f 'kern/arm64/cache_flush.S' || echo '$(srcdir)/'`kern/arm64/cache_flush.S
+
+kern/arm64/kernel_exec-cache_flush.obj: kern/arm64/cache_flush.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm64/kernel_exec-cache_flush.obj -MD -MP -MF kern/arm64/$(DEPDIR)/kernel_exec-cache_flush.Tpo -c -o kern/arm64/kernel_exec-cache_flush.obj `if test -f 'kern/arm64/cache_flush.S'; then $(CYGPATH_W) 'kern/arm64/cache_flush.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/cache_flush.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/$(DEPDIR)/kernel_exec-cache_flush.Tpo kern/arm64/$(DEPDIR)/kernel_exec-cache_flush.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm64/cache_flush.S' object='kern/arm64/kernel_exec-cache_flush.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm64/kernel_exec-cache_flush.obj `if test -f 'kern/arm64/cache_flush.S'; then $(CYGPATH_W) 'kern/arm64/cache_flush.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/cache_flush.S'; fi`
+
+kern/arm/kernel_exec-startup.o: kern/arm/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/kernel_exec-startup.o -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/arm/kernel_exec-startup.o `test -f 'kern/arm/startup.S' || echo '$(srcdir)/'`kern/arm/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-startup.Tpo kern/arm/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/startup.S' object='kern/arm/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/kernel_exec-startup.o `test -f 'kern/arm/startup.S' || echo '$(srcdir)/'`kern/arm/startup.S
+
+kern/arm/kernel_exec-startup.obj: kern/arm/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/kernel_exec-startup.obj -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/arm/kernel_exec-startup.obj `if test -f 'kern/arm/startup.S'; then $(CYGPATH_W) 'kern/arm/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-startup.Tpo kern/arm/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/startup.S' object='kern/arm/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/kernel_exec-startup.obj `if test -f 'kern/arm/startup.S'; then $(CYGPATH_W) 'kern/arm/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/startup.S'; fi`
+
+kern/arm/coreboot/kernel_exec-coreboot.o: kern/arm/coreboot/coreboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/coreboot/kernel_exec-coreboot.o -MD -MP -MF kern/arm/coreboot/$(DEPDIR)/kernel_exec-coreboot.Tpo -c -o kern/arm/coreboot/kernel_exec-coreboot.o `test -f 'kern/arm/coreboot/coreboot.S' || echo '$(srcdir)/'`kern/arm/coreboot/coreboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/coreboot/$(DEPDIR)/kernel_exec-coreboot.Tpo kern/arm/coreboot/$(DEPDIR)/kernel_exec-coreboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/coreboot/coreboot.S' object='kern/arm/coreboot/kernel_exec-coreboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/coreboot/kernel_exec-coreboot.o `test -f 'kern/arm/coreboot/coreboot.S' || echo '$(srcdir)/'`kern/arm/coreboot/coreboot.S
+
+kern/arm/coreboot/kernel_exec-coreboot.obj: kern/arm/coreboot/coreboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/coreboot/kernel_exec-coreboot.obj -MD -MP -MF kern/arm/coreboot/$(DEPDIR)/kernel_exec-coreboot.Tpo -c -o kern/arm/coreboot/kernel_exec-coreboot.obj `if test -f 'kern/arm/coreboot/coreboot.S'; then $(CYGPATH_W) 'kern/arm/coreboot/coreboot.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/coreboot/coreboot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/coreboot/$(DEPDIR)/kernel_exec-coreboot.Tpo kern/arm/coreboot/$(DEPDIR)/kernel_exec-coreboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/coreboot/coreboot.S' object='kern/arm/coreboot/kernel_exec-coreboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/coreboot/kernel_exec-coreboot.obj `if test -f 'kern/arm/coreboot/coreboot.S'; then $(CYGPATH_W) 'kern/arm/coreboot/coreboot.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/coreboot/coreboot.S'; fi`
+
+kern/arm/kernel_exec-cache_armv6.o: kern/arm/cache_armv6.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/kernel_exec-cache_armv6.o -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-cache_armv6.Tpo -c -o kern/arm/kernel_exec-cache_armv6.o `test -f 'kern/arm/cache_armv6.S' || echo '$(srcdir)/'`kern/arm/cache_armv6.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-cache_armv6.Tpo kern/arm/$(DEPDIR)/kernel_exec-cache_armv6.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/cache_armv6.S' object='kern/arm/kernel_exec-cache_armv6.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/kernel_exec-cache_armv6.o `test -f 'kern/arm/cache_armv6.S' || echo '$(srcdir)/'`kern/arm/cache_armv6.S
+
+kern/arm/kernel_exec-cache_armv6.obj: kern/arm/cache_armv6.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/kernel_exec-cache_armv6.obj -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-cache_armv6.Tpo -c -o kern/arm/kernel_exec-cache_armv6.obj `if test -f 'kern/arm/cache_armv6.S'; then $(CYGPATH_W) 'kern/arm/cache_armv6.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/cache_armv6.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-cache_armv6.Tpo kern/arm/$(DEPDIR)/kernel_exec-cache_armv6.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/cache_armv6.S' object='kern/arm/kernel_exec-cache_armv6.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/kernel_exec-cache_armv6.obj `if test -f 'kern/arm/cache_armv6.S'; then $(CYGPATH_W) 'kern/arm/cache_armv6.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/cache_armv6.S'; fi`
+
+kern/arm/kernel_exec-cache_armv7.o: kern/arm/cache_armv7.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/kernel_exec-cache_armv7.o -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-cache_armv7.Tpo -c -o kern/arm/kernel_exec-cache_armv7.o `test -f 'kern/arm/cache_armv7.S' || echo '$(srcdir)/'`kern/arm/cache_armv7.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-cache_armv7.Tpo kern/arm/$(DEPDIR)/kernel_exec-cache_armv7.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/cache_armv7.S' object='kern/arm/kernel_exec-cache_armv7.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/kernel_exec-cache_armv7.o `test -f 'kern/arm/cache_armv7.S' || echo '$(srcdir)/'`kern/arm/cache_armv7.S
+
+kern/arm/kernel_exec-cache_armv7.obj: kern/arm/cache_armv7.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/kernel_exec-cache_armv7.obj -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-cache_armv7.Tpo -c -o kern/arm/kernel_exec-cache_armv7.obj `if test -f 'kern/arm/cache_armv7.S'; then $(CYGPATH_W) 'kern/arm/cache_armv7.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/cache_armv7.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-cache_armv7.Tpo kern/arm/$(DEPDIR)/kernel_exec-cache_armv7.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/cache_armv7.S' object='kern/arm/kernel_exec-cache_armv7.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/kernel_exec-cache_armv7.obj `if test -f 'kern/arm/cache_armv7.S'; then $(CYGPATH_W) 'kern/arm/cache_armv7.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/cache_armv7.S'; fi`
+
+kern/arm/kernel_exec-compiler-rt.o: kern/arm/compiler-rt.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/kernel_exec-compiler-rt.o -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-compiler-rt.Tpo -c -o kern/arm/kernel_exec-compiler-rt.o `test -f 'kern/arm/compiler-rt.S' || echo '$(srcdir)/'`kern/arm/compiler-rt.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-compiler-rt.Tpo kern/arm/$(DEPDIR)/kernel_exec-compiler-rt.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/compiler-rt.S' object='kern/arm/kernel_exec-compiler-rt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/kernel_exec-compiler-rt.o `test -f 'kern/arm/compiler-rt.S' || echo '$(srcdir)/'`kern/arm/compiler-rt.S
+
+kern/arm/kernel_exec-compiler-rt.obj: kern/arm/compiler-rt.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/kernel_exec-compiler-rt.obj -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-compiler-rt.Tpo -c -o kern/arm/kernel_exec-compiler-rt.obj `if test -f 'kern/arm/compiler-rt.S'; then $(CYGPATH_W) 'kern/arm/compiler-rt.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/compiler-rt.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-compiler-rt.Tpo kern/arm/$(DEPDIR)/kernel_exec-compiler-rt.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/compiler-rt.S' object='kern/arm/kernel_exec-compiler-rt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/kernel_exec-compiler-rt.obj `if test -f 'kern/arm/compiler-rt.S'; then $(CYGPATH_W) 'kern/arm/compiler-rt.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/compiler-rt.S'; fi`
+
+kern/arm/efi/kernel_exec-startup.o: kern/arm/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/efi/kernel_exec-startup.o -MD -MP -MF kern/arm/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/arm/efi/kernel_exec-startup.o `test -f 'kern/arm/efi/startup.S' || echo '$(srcdir)/'`kern/arm/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/arm/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/efi/startup.S' object='kern/arm/efi/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/efi/kernel_exec-startup.o `test -f 'kern/arm/efi/startup.S' || echo '$(srcdir)/'`kern/arm/efi/startup.S
+
+kern/arm/efi/kernel_exec-startup.obj: kern/arm/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/efi/kernel_exec-startup.obj -MD -MP -MF kern/arm/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/arm/efi/kernel_exec-startup.obj `if test -f 'kern/arm/efi/startup.S'; then $(CYGPATH_W) 'kern/arm/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/efi/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/arm/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/efi/startup.S' object='kern/arm/efi/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/efi/kernel_exec-startup.obj `if test -f 'kern/arm/efi/startup.S'; then $(CYGPATH_W) 'kern/arm/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/efi/startup.S'; fi`
+
+kern/arm/uboot/kernel_exec-uboot.o: kern/arm/uboot/uboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/uboot/kernel_exec-uboot.o -MD -MP -MF kern/arm/uboot/$(DEPDIR)/kernel_exec-uboot.Tpo -c -o kern/arm/uboot/kernel_exec-uboot.o `test -f 'kern/arm/uboot/uboot.S' || echo '$(srcdir)/'`kern/arm/uboot/uboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/uboot/$(DEPDIR)/kernel_exec-uboot.Tpo kern/arm/uboot/$(DEPDIR)/kernel_exec-uboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/uboot/uboot.S' object='kern/arm/uboot/kernel_exec-uboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/uboot/kernel_exec-uboot.o `test -f 'kern/arm/uboot/uboot.S' || echo '$(srcdir)/'`kern/arm/uboot/uboot.S
+
+kern/arm/uboot/kernel_exec-uboot.obj: kern/arm/uboot/uboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/arm/uboot/kernel_exec-uboot.obj -MD -MP -MF kern/arm/uboot/$(DEPDIR)/kernel_exec-uboot.Tpo -c -o kern/arm/uboot/kernel_exec-uboot.obj `if test -f 'kern/arm/uboot/uboot.S'; then $(CYGPATH_W) 'kern/arm/uboot/uboot.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/uboot/uboot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/arm/uboot/$(DEPDIR)/kernel_exec-uboot.Tpo kern/arm/uboot/$(DEPDIR)/kernel_exec-uboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/arm/uboot/uboot.S' object='kern/arm/uboot/kernel_exec-uboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/arm/uboot/kernel_exec-uboot.obj `if test -f 'kern/arm/uboot/uboot.S'; then $(CYGPATH_W) 'kern/arm/uboot/uboot.S'; else $(CYGPATH_W) '$(srcdir)/kern/arm/uboot/uboot.S'; fi`
+
+kern/emu/kernel_exec-cache_s.o: kern/emu/cache_s.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/emu/kernel_exec-cache_s.o -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-cache_s.Tpo -c -o kern/emu/kernel_exec-cache_s.o `test -f 'kern/emu/cache_s.S' || echo '$(srcdir)/'`kern/emu/cache_s.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-cache_s.Tpo kern/emu/$(DEPDIR)/kernel_exec-cache_s.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/emu/cache_s.S' object='kern/emu/kernel_exec-cache_s.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/emu/kernel_exec-cache_s.o `test -f 'kern/emu/cache_s.S' || echo '$(srcdir)/'`kern/emu/cache_s.S
+
+kern/emu/kernel_exec-cache_s.obj: kern/emu/cache_s.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/emu/kernel_exec-cache_s.obj -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-cache_s.Tpo -c -o kern/emu/kernel_exec-cache_s.obj `if test -f 'kern/emu/cache_s.S'; then $(CYGPATH_W) 'kern/emu/cache_s.S'; else $(CYGPATH_W) '$(srcdir)/kern/emu/cache_s.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-cache_s.Tpo kern/emu/$(DEPDIR)/kernel_exec-cache_s.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/emu/cache_s.S' object='kern/emu/kernel_exec-cache_s.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/emu/kernel_exec-cache_s.obj `if test -f 'kern/emu/cache_s.S'; then $(CYGPATH_W) 'kern/emu/cache_s.S'; else $(CYGPATH_W) '$(srcdir)/kern/emu/cache_s.S'; fi`
+
+kern/i386/coreboot/kernel_exec-startup.o: kern/i386/coreboot/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/coreboot/kernel_exec-startup.o -MD -MP -MF kern/i386/coreboot/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/coreboot/kernel_exec-startup.o `test -f 'kern/i386/coreboot/startup.S' || echo '$(srcdir)/'`kern/i386/coreboot/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/coreboot/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/coreboot/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/coreboot/startup.S' object='kern/i386/coreboot/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/coreboot/kernel_exec-startup.o `test -f 'kern/i386/coreboot/startup.S' || echo '$(srcdir)/'`kern/i386/coreboot/startup.S
+
+kern/i386/coreboot/kernel_exec-startup.obj: kern/i386/coreboot/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/coreboot/kernel_exec-startup.obj -MD -MP -MF kern/i386/coreboot/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/coreboot/kernel_exec-startup.obj `if test -f 'kern/i386/coreboot/startup.S'; then $(CYGPATH_W) 'kern/i386/coreboot/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/coreboot/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/coreboot/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/coreboot/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/coreboot/startup.S' object='kern/i386/coreboot/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/coreboot/kernel_exec-startup.obj `if test -f 'kern/i386/coreboot/startup.S'; then $(CYGPATH_W) 'kern/i386/coreboot/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/coreboot/startup.S'; fi`
+
+kern/i386/efi/kernel_exec-startup.o: kern/i386/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/efi/kernel_exec-startup.o -MD -MP -MF kern/i386/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/efi/kernel_exec-startup.o `test -f 'kern/i386/efi/startup.S' || echo '$(srcdir)/'`kern/i386/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/efi/startup.S' object='kern/i386/efi/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/efi/kernel_exec-startup.o `test -f 'kern/i386/efi/startup.S' || echo '$(srcdir)/'`kern/i386/efi/startup.S
+
+kern/i386/efi/kernel_exec-startup.obj: kern/i386/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/efi/kernel_exec-startup.obj -MD -MP -MF kern/i386/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/efi/kernel_exec-startup.obj `if test -f 'kern/i386/efi/startup.S'; then $(CYGPATH_W) 'kern/i386/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/efi/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/efi/startup.S' object='kern/i386/efi/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/efi/kernel_exec-startup.obj `if test -f 'kern/i386/efi/startup.S'; then $(CYGPATH_W) 'kern/i386/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/efi/startup.S'; fi`
+
+kern/i386/ieee1275/kernel_exec-startup.o: kern/i386/ieee1275/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/ieee1275/kernel_exec-startup.o -MD -MP -MF kern/i386/ieee1275/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/ieee1275/kernel_exec-startup.o `test -f 'kern/i386/ieee1275/startup.S' || echo '$(srcdir)/'`kern/i386/ieee1275/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/ieee1275/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/ieee1275/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/ieee1275/startup.S' object='kern/i386/ieee1275/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/ieee1275/kernel_exec-startup.o `test -f 'kern/i386/ieee1275/startup.S' || echo '$(srcdir)/'`kern/i386/ieee1275/startup.S
+
+kern/i386/ieee1275/kernel_exec-startup.obj: kern/i386/ieee1275/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/ieee1275/kernel_exec-startup.obj -MD -MP -MF kern/i386/ieee1275/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/ieee1275/kernel_exec-startup.obj `if test -f 'kern/i386/ieee1275/startup.S'; then $(CYGPATH_W) 'kern/i386/ieee1275/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/ieee1275/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/ieee1275/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/ieee1275/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/ieee1275/startup.S' object='kern/i386/ieee1275/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/ieee1275/kernel_exec-startup.obj `if test -f 'kern/i386/ieee1275/startup.S'; then $(CYGPATH_W) 'kern/i386/ieee1275/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/ieee1275/startup.S'; fi`
+
+kern/i386/pc/kernel_exec-startup.o: kern/i386/pc/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/pc/kernel_exec-startup.o -MD -MP -MF kern/i386/pc/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/pc/kernel_exec-startup.o `test -f 'kern/i386/pc/startup.S' || echo '$(srcdir)/'`kern/i386/pc/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/pc/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/pc/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/pc/startup.S' object='kern/i386/pc/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/pc/kernel_exec-startup.o `test -f 'kern/i386/pc/startup.S' || echo '$(srcdir)/'`kern/i386/pc/startup.S
+
+kern/i386/pc/kernel_exec-startup.obj: kern/i386/pc/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/pc/kernel_exec-startup.obj -MD -MP -MF kern/i386/pc/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/pc/kernel_exec-startup.obj `if test -f 'kern/i386/pc/startup.S'; then $(CYGPATH_W) 'kern/i386/pc/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/pc/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/pc/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/pc/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/pc/startup.S' object='kern/i386/pc/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/pc/kernel_exec-startup.obj `if test -f 'kern/i386/pc/startup.S'; then $(CYGPATH_W) 'kern/i386/pc/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/pc/startup.S'; fi`
+
+kern/i386/qemu/kernel_exec-startup.o: kern/i386/qemu/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/qemu/kernel_exec-startup.o -MD -MP -MF kern/i386/qemu/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/qemu/kernel_exec-startup.o `test -f 'kern/i386/qemu/startup.S' || echo '$(srcdir)/'`kern/i386/qemu/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/qemu/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/qemu/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/qemu/startup.S' object='kern/i386/qemu/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/qemu/kernel_exec-startup.o `test -f 'kern/i386/qemu/startup.S' || echo '$(srcdir)/'`kern/i386/qemu/startup.S
+
+kern/i386/qemu/kernel_exec-startup.obj: kern/i386/qemu/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/qemu/kernel_exec-startup.obj -MD -MP -MF kern/i386/qemu/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/qemu/kernel_exec-startup.obj `if test -f 'kern/i386/qemu/startup.S'; then $(CYGPATH_W) 'kern/i386/qemu/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/qemu/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/qemu/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/qemu/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/qemu/startup.S' object='kern/i386/qemu/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/qemu/kernel_exec-startup.obj `if test -f 'kern/i386/qemu/startup.S'; then $(CYGPATH_W) 'kern/i386/qemu/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/qemu/startup.S'; fi`
+
+kern/i386/xen/kernel_exec-startup.o: kern/i386/xen/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/xen/kernel_exec-startup.o -MD -MP -MF kern/i386/xen/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/xen/kernel_exec-startup.o `test -f 'kern/i386/xen/startup.S' || echo '$(srcdir)/'`kern/i386/xen/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/xen/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/xen/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/xen/startup.S' object='kern/i386/xen/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/xen/kernel_exec-startup.o `test -f 'kern/i386/xen/startup.S' || echo '$(srcdir)/'`kern/i386/xen/startup.S
+
+kern/i386/xen/kernel_exec-startup.obj: kern/i386/xen/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/xen/kernel_exec-startup.obj -MD -MP -MF kern/i386/xen/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/i386/xen/kernel_exec-startup.obj `if test -f 'kern/i386/xen/startup.S'; then $(CYGPATH_W) 'kern/i386/xen/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/xen/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/xen/$(DEPDIR)/kernel_exec-startup.Tpo kern/i386/xen/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/xen/startup.S' object='kern/i386/xen/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/xen/kernel_exec-startup.obj `if test -f 'kern/i386/xen/startup.S'; then $(CYGPATH_W) 'kern/i386/xen/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/xen/startup.S'; fi`
+
+kern/i386/xen/kernel_exec-hypercall.o: kern/i386/xen/hypercall.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/xen/kernel_exec-hypercall.o -MD -MP -MF kern/i386/xen/$(DEPDIR)/kernel_exec-hypercall.Tpo -c -o kern/i386/xen/kernel_exec-hypercall.o `test -f 'kern/i386/xen/hypercall.S' || echo '$(srcdir)/'`kern/i386/xen/hypercall.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/xen/$(DEPDIR)/kernel_exec-hypercall.Tpo kern/i386/xen/$(DEPDIR)/kernel_exec-hypercall.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/xen/hypercall.S' object='kern/i386/xen/kernel_exec-hypercall.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/xen/kernel_exec-hypercall.o `test -f 'kern/i386/xen/hypercall.S' || echo '$(srcdir)/'`kern/i386/xen/hypercall.S
+
+kern/i386/xen/kernel_exec-hypercall.obj: kern/i386/xen/hypercall.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/xen/kernel_exec-hypercall.obj -MD -MP -MF kern/i386/xen/$(DEPDIR)/kernel_exec-hypercall.Tpo -c -o kern/i386/xen/kernel_exec-hypercall.obj `if test -f 'kern/i386/xen/hypercall.S'; then $(CYGPATH_W) 'kern/i386/xen/hypercall.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/xen/hypercall.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/xen/$(DEPDIR)/kernel_exec-hypercall.Tpo kern/i386/xen/$(DEPDIR)/kernel_exec-hypercall.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/xen/hypercall.S' object='kern/i386/xen/kernel_exec-hypercall.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/xen/kernel_exec-hypercall.obj `if test -f 'kern/i386/xen/hypercall.S'; then $(CYGPATH_W) 'kern/i386/xen/hypercall.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/xen/hypercall.S'; fi`
+
+kern/i386/xen/kernel_exec-startup_pvh.o: kern/i386/xen/startup_pvh.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/xen/kernel_exec-startup_pvh.o -MD -MP -MF kern/i386/xen/$(DEPDIR)/kernel_exec-startup_pvh.Tpo -c -o kern/i386/xen/kernel_exec-startup_pvh.o `test -f 'kern/i386/xen/startup_pvh.S' || echo '$(srcdir)/'`kern/i386/xen/startup_pvh.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/xen/$(DEPDIR)/kernel_exec-startup_pvh.Tpo kern/i386/xen/$(DEPDIR)/kernel_exec-startup_pvh.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/xen/startup_pvh.S' object='kern/i386/xen/kernel_exec-startup_pvh.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/xen/kernel_exec-startup_pvh.o `test -f 'kern/i386/xen/startup_pvh.S' || echo '$(srcdir)/'`kern/i386/xen/startup_pvh.S
+
+kern/i386/xen/kernel_exec-startup_pvh.obj: kern/i386/xen/startup_pvh.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/i386/xen/kernel_exec-startup_pvh.obj -MD -MP -MF kern/i386/xen/$(DEPDIR)/kernel_exec-startup_pvh.Tpo -c -o kern/i386/xen/kernel_exec-startup_pvh.obj `if test -f 'kern/i386/xen/startup_pvh.S'; then $(CYGPATH_W) 'kern/i386/xen/startup_pvh.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/xen/startup_pvh.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/i386/xen/$(DEPDIR)/kernel_exec-startup_pvh.Tpo kern/i386/xen/$(DEPDIR)/kernel_exec-startup_pvh.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/i386/xen/startup_pvh.S' object='kern/i386/xen/kernel_exec-startup_pvh.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/i386/xen/kernel_exec-startup_pvh.obj `if test -f 'kern/i386/xen/startup_pvh.S'; then $(CYGPATH_W) 'kern/i386/xen/startup_pvh.S'; else $(CYGPATH_W) '$(srcdir)/kern/i386/xen/startup_pvh.S'; fi`
+
+kern/ia64/efi/kernel_exec-startup.o: kern/ia64/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/ia64/efi/kernel_exec-startup.o -MD -MP -MF kern/ia64/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/ia64/efi/kernel_exec-startup.o `test -f 'kern/ia64/efi/startup.S' || echo '$(srcdir)/'`kern/ia64/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/ia64/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/ia64/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/ia64/efi/startup.S' object='kern/ia64/efi/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/ia64/efi/kernel_exec-startup.o `test -f 'kern/ia64/efi/startup.S' || echo '$(srcdir)/'`kern/ia64/efi/startup.S
+
+kern/ia64/efi/kernel_exec-startup.obj: kern/ia64/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/ia64/efi/kernel_exec-startup.obj -MD -MP -MF kern/ia64/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/ia64/efi/kernel_exec-startup.obj `if test -f 'kern/ia64/efi/startup.S'; then $(CYGPATH_W) 'kern/ia64/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/ia64/efi/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/ia64/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/ia64/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/ia64/efi/startup.S' object='kern/ia64/efi/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/ia64/efi/kernel_exec-startup.obj `if test -f 'kern/ia64/efi/startup.S'; then $(CYGPATH_W) 'kern/ia64/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/ia64/efi/startup.S'; fi`
+
+kern/mips/kernel_exec-startup.o: kern/mips/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/mips/kernel_exec-startup.o -MD -MP -MF kern/mips/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/mips/kernel_exec-startup.o `test -f 'kern/mips/startup.S' || echo '$(srcdir)/'`kern/mips/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/mips/$(DEPDIR)/kernel_exec-startup.Tpo kern/mips/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/mips/startup.S' object='kern/mips/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/mips/kernel_exec-startup.o `test -f 'kern/mips/startup.S' || echo '$(srcdir)/'`kern/mips/startup.S
+
+kern/mips/kernel_exec-startup.obj: kern/mips/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/mips/kernel_exec-startup.obj -MD -MP -MF kern/mips/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/mips/kernel_exec-startup.obj `if test -f 'kern/mips/startup.S'; then $(CYGPATH_W) 'kern/mips/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/mips/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/mips/$(DEPDIR)/kernel_exec-startup.Tpo kern/mips/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/mips/startup.S' object='kern/mips/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/mips/kernel_exec-startup.obj `if test -f 'kern/mips/startup.S'; then $(CYGPATH_W) 'kern/mips/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/mips/startup.S'; fi`
+
+kern/mips/kernel_exec-cache.o: kern/mips/cache.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/mips/kernel_exec-cache.o -MD -MP -MF kern/mips/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/mips/kernel_exec-cache.o `test -f 'kern/mips/cache.S' || echo '$(srcdir)/'`kern/mips/cache.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/mips/$(DEPDIR)/kernel_exec-cache.Tpo kern/mips/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/mips/cache.S' object='kern/mips/kernel_exec-cache.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/mips/kernel_exec-cache.o `test -f 'kern/mips/cache.S' || echo '$(srcdir)/'`kern/mips/cache.S
+
+kern/mips/kernel_exec-cache.obj: kern/mips/cache.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/mips/kernel_exec-cache.obj -MD -MP -MF kern/mips/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/mips/kernel_exec-cache.obj `if test -f 'kern/mips/cache.S'; then $(CYGPATH_W) 'kern/mips/cache.S'; else $(CYGPATH_W) '$(srcdir)/kern/mips/cache.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/mips/$(DEPDIR)/kernel_exec-cache.Tpo kern/mips/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/mips/cache.S' object='kern/mips/kernel_exec-cache.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/mips/kernel_exec-cache.obj `if test -f 'kern/mips/cache.S'; then $(CYGPATH_W) 'kern/mips/cache.S'; else $(CYGPATH_W) '$(srcdir)/kern/mips/cache.S'; fi`
+
+kern/powerpc/ieee1275/kernel_exec-startup.o: kern/powerpc/ieee1275/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/powerpc/ieee1275/kernel_exec-startup.o -MD -MP -MF kern/powerpc/ieee1275/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/powerpc/ieee1275/kernel_exec-startup.o `test -f 'kern/powerpc/ieee1275/startup.S' || echo '$(srcdir)/'`kern/powerpc/ieee1275/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/powerpc/ieee1275/$(DEPDIR)/kernel_exec-startup.Tpo kern/powerpc/ieee1275/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/powerpc/ieee1275/startup.S' object='kern/powerpc/ieee1275/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/powerpc/ieee1275/kernel_exec-startup.o `test -f 'kern/powerpc/ieee1275/startup.S' || echo '$(srcdir)/'`kern/powerpc/ieee1275/startup.S
+
+kern/powerpc/ieee1275/kernel_exec-startup.obj: kern/powerpc/ieee1275/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/powerpc/ieee1275/kernel_exec-startup.obj -MD -MP -MF kern/powerpc/ieee1275/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/powerpc/ieee1275/kernel_exec-startup.obj `if test -f 'kern/powerpc/ieee1275/startup.S'; then $(CYGPATH_W) 'kern/powerpc/ieee1275/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/powerpc/ieee1275/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/powerpc/ieee1275/$(DEPDIR)/kernel_exec-startup.Tpo kern/powerpc/ieee1275/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/powerpc/ieee1275/startup.S' object='kern/powerpc/ieee1275/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/powerpc/ieee1275/kernel_exec-startup.obj `if test -f 'kern/powerpc/ieee1275/startup.S'; then $(CYGPATH_W) 'kern/powerpc/ieee1275/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/powerpc/ieee1275/startup.S'; fi`
+
+kern/powerpc/kernel_exec-cache.o: kern/powerpc/cache.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/powerpc/kernel_exec-cache.o -MD -MP -MF kern/powerpc/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/powerpc/kernel_exec-cache.o `test -f 'kern/powerpc/cache.S' || echo '$(srcdir)/'`kern/powerpc/cache.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/powerpc/$(DEPDIR)/kernel_exec-cache.Tpo kern/powerpc/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/powerpc/cache.S' object='kern/powerpc/kernel_exec-cache.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/powerpc/kernel_exec-cache.o `test -f 'kern/powerpc/cache.S' || echo '$(srcdir)/'`kern/powerpc/cache.S
+
+kern/powerpc/kernel_exec-cache.obj: kern/powerpc/cache.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/powerpc/kernel_exec-cache.obj -MD -MP -MF kern/powerpc/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/powerpc/kernel_exec-cache.obj `if test -f 'kern/powerpc/cache.S'; then $(CYGPATH_W) 'kern/powerpc/cache.S'; else $(CYGPATH_W) '$(srcdir)/kern/powerpc/cache.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/powerpc/$(DEPDIR)/kernel_exec-cache.Tpo kern/powerpc/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/powerpc/cache.S' object='kern/powerpc/kernel_exec-cache.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/powerpc/kernel_exec-cache.obj `if test -f 'kern/powerpc/cache.S'; then $(CYGPATH_W) 'kern/powerpc/cache.S'; else $(CYGPATH_W) '$(srcdir)/kern/powerpc/cache.S'; fi`
+
+kern/powerpc/kernel_exec-compiler-rt.o: kern/powerpc/compiler-rt.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/powerpc/kernel_exec-compiler-rt.o -MD -MP -MF kern/powerpc/$(DEPDIR)/kernel_exec-compiler-rt.Tpo -c -o kern/powerpc/kernel_exec-compiler-rt.o `test -f 'kern/powerpc/compiler-rt.S' || echo '$(srcdir)/'`kern/powerpc/compiler-rt.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/powerpc/$(DEPDIR)/kernel_exec-compiler-rt.Tpo kern/powerpc/$(DEPDIR)/kernel_exec-compiler-rt.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/powerpc/compiler-rt.S' object='kern/powerpc/kernel_exec-compiler-rt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/powerpc/kernel_exec-compiler-rt.o `test -f 'kern/powerpc/compiler-rt.S' || echo '$(srcdir)/'`kern/powerpc/compiler-rt.S
+
+kern/powerpc/kernel_exec-compiler-rt.obj: kern/powerpc/compiler-rt.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/powerpc/kernel_exec-compiler-rt.obj -MD -MP -MF kern/powerpc/$(DEPDIR)/kernel_exec-compiler-rt.Tpo -c -o kern/powerpc/kernel_exec-compiler-rt.obj `if test -f 'kern/powerpc/compiler-rt.S'; then $(CYGPATH_W) 'kern/powerpc/compiler-rt.S'; else $(CYGPATH_W) '$(srcdir)/kern/powerpc/compiler-rt.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/powerpc/$(DEPDIR)/kernel_exec-compiler-rt.Tpo kern/powerpc/$(DEPDIR)/kernel_exec-compiler-rt.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/powerpc/compiler-rt.S' object='kern/powerpc/kernel_exec-compiler-rt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/powerpc/kernel_exec-compiler-rt.obj `if test -f 'kern/powerpc/compiler-rt.S'; then $(CYGPATH_W) 'kern/powerpc/compiler-rt.S'; else $(CYGPATH_W) '$(srcdir)/kern/powerpc/compiler-rt.S'; fi`
+
+kern/riscv/efi/kernel_exec-startup.o: kern/riscv/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/riscv/efi/kernel_exec-startup.o -MD -MP -MF kern/riscv/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/riscv/efi/kernel_exec-startup.o `test -f 'kern/riscv/efi/startup.S' || echo '$(srcdir)/'`kern/riscv/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/riscv/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/riscv/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/riscv/efi/startup.S' object='kern/riscv/efi/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/riscv/efi/kernel_exec-startup.o `test -f 'kern/riscv/efi/startup.S' || echo '$(srcdir)/'`kern/riscv/efi/startup.S
+
+kern/riscv/efi/kernel_exec-startup.obj: kern/riscv/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/riscv/efi/kernel_exec-startup.obj -MD -MP -MF kern/riscv/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/riscv/efi/kernel_exec-startup.obj `if test -f 'kern/riscv/efi/startup.S'; then $(CYGPATH_W) 'kern/riscv/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/riscv/efi/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/riscv/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/riscv/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/riscv/efi/startup.S' object='kern/riscv/efi/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/riscv/efi/kernel_exec-startup.obj `if test -f 'kern/riscv/efi/startup.S'; then $(CYGPATH_W) 'kern/riscv/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/riscv/efi/startup.S'; fi`
+
+kern/riscv/kernel_exec-cache_flush.o: kern/riscv/cache_flush.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/riscv/kernel_exec-cache_flush.o -MD -MP -MF kern/riscv/$(DEPDIR)/kernel_exec-cache_flush.Tpo -c -o kern/riscv/kernel_exec-cache_flush.o `test -f 'kern/riscv/cache_flush.S' || echo '$(srcdir)/'`kern/riscv/cache_flush.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/riscv/$(DEPDIR)/kernel_exec-cache_flush.Tpo kern/riscv/$(DEPDIR)/kernel_exec-cache_flush.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/riscv/cache_flush.S' object='kern/riscv/kernel_exec-cache_flush.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/riscv/kernel_exec-cache_flush.o `test -f 'kern/riscv/cache_flush.S' || echo '$(srcdir)/'`kern/riscv/cache_flush.S
+
+kern/riscv/kernel_exec-cache_flush.obj: kern/riscv/cache_flush.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/riscv/kernel_exec-cache_flush.obj -MD -MP -MF kern/riscv/$(DEPDIR)/kernel_exec-cache_flush.Tpo -c -o kern/riscv/kernel_exec-cache_flush.obj `if test -f 'kern/riscv/cache_flush.S'; then $(CYGPATH_W) 'kern/riscv/cache_flush.S'; else $(CYGPATH_W) '$(srcdir)/kern/riscv/cache_flush.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/riscv/$(DEPDIR)/kernel_exec-cache_flush.Tpo kern/riscv/$(DEPDIR)/kernel_exec-cache_flush.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/riscv/cache_flush.S' object='kern/riscv/kernel_exec-cache_flush.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/riscv/kernel_exec-cache_flush.obj `if test -f 'kern/riscv/cache_flush.S'; then $(CYGPATH_W) 'kern/riscv/cache_flush.S'; else $(CYGPATH_W) '$(srcdir)/kern/riscv/cache_flush.S'; fi`
+
+kern/sparc64/ieee1275/kernel_exec-crt0.o: kern/sparc64/ieee1275/crt0.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/sparc64/ieee1275/kernel_exec-crt0.o -MD -MP -MF kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-crt0.Tpo -c -o kern/sparc64/ieee1275/kernel_exec-crt0.o `test -f 'kern/sparc64/ieee1275/crt0.S' || echo '$(srcdir)/'`kern/sparc64/ieee1275/crt0.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-crt0.Tpo kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-crt0.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/sparc64/ieee1275/crt0.S' object='kern/sparc64/ieee1275/kernel_exec-crt0.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/sparc64/ieee1275/kernel_exec-crt0.o `test -f 'kern/sparc64/ieee1275/crt0.S' || echo '$(srcdir)/'`kern/sparc64/ieee1275/crt0.S
+
+kern/sparc64/ieee1275/kernel_exec-crt0.obj: kern/sparc64/ieee1275/crt0.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/sparc64/ieee1275/kernel_exec-crt0.obj -MD -MP -MF kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-crt0.Tpo -c -o kern/sparc64/ieee1275/kernel_exec-crt0.obj `if test -f 'kern/sparc64/ieee1275/crt0.S'; then $(CYGPATH_W) 'kern/sparc64/ieee1275/crt0.S'; else $(CYGPATH_W) '$(srcdir)/kern/sparc64/ieee1275/crt0.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-crt0.Tpo kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-crt0.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/sparc64/ieee1275/crt0.S' object='kern/sparc64/ieee1275/kernel_exec-crt0.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/sparc64/ieee1275/kernel_exec-crt0.obj `if test -f 'kern/sparc64/ieee1275/crt0.S'; then $(CYGPATH_W) 'kern/sparc64/ieee1275/crt0.S'; else $(CYGPATH_W) '$(srcdir)/kern/sparc64/ieee1275/crt0.S'; fi`
+
+kern/sparc64/kernel_exec-cache.o: kern/sparc64/cache.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/sparc64/kernel_exec-cache.o -MD -MP -MF kern/sparc64/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/sparc64/kernel_exec-cache.o `test -f 'kern/sparc64/cache.S' || echo '$(srcdir)/'`kern/sparc64/cache.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/sparc64/$(DEPDIR)/kernel_exec-cache.Tpo kern/sparc64/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/sparc64/cache.S' object='kern/sparc64/kernel_exec-cache.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/sparc64/kernel_exec-cache.o `test -f 'kern/sparc64/cache.S' || echo '$(srcdir)/'`kern/sparc64/cache.S
+
+kern/sparc64/kernel_exec-cache.obj: kern/sparc64/cache.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/sparc64/kernel_exec-cache.obj -MD -MP -MF kern/sparc64/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/sparc64/kernel_exec-cache.obj `if test -f 'kern/sparc64/cache.S'; then $(CYGPATH_W) 'kern/sparc64/cache.S'; else $(CYGPATH_W) '$(srcdir)/kern/sparc64/cache.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/sparc64/$(DEPDIR)/kernel_exec-cache.Tpo kern/sparc64/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/sparc64/cache.S' object='kern/sparc64/kernel_exec-cache.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/sparc64/kernel_exec-cache.obj `if test -f 'kern/sparc64/cache.S'; then $(CYGPATH_W) 'kern/sparc64/cache.S'; else $(CYGPATH_W) '$(srcdir)/kern/sparc64/cache.S'; fi`
+
+kern/x86_64/efi/kernel_exec-startup.o: kern/x86_64/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/x86_64/efi/kernel_exec-startup.o -MD -MP -MF kern/x86_64/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/x86_64/efi/kernel_exec-startup.o `test -f 'kern/x86_64/efi/startup.S' || echo '$(srcdir)/'`kern/x86_64/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/x86_64/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/x86_64/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/x86_64/efi/startup.S' object='kern/x86_64/efi/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/x86_64/efi/kernel_exec-startup.o `test -f 'kern/x86_64/efi/startup.S' || echo '$(srcdir)/'`kern/x86_64/efi/startup.S
+
+kern/x86_64/efi/kernel_exec-startup.obj: kern/x86_64/efi/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/x86_64/efi/kernel_exec-startup.obj -MD -MP -MF kern/x86_64/efi/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/x86_64/efi/kernel_exec-startup.obj `if test -f 'kern/x86_64/efi/startup.S'; then $(CYGPATH_W) 'kern/x86_64/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/x86_64/efi/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/x86_64/efi/$(DEPDIR)/kernel_exec-startup.Tpo kern/x86_64/efi/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/x86_64/efi/startup.S' object='kern/x86_64/efi/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/x86_64/efi/kernel_exec-startup.obj `if test -f 'kern/x86_64/efi/startup.S'; then $(CYGPATH_W) 'kern/x86_64/efi/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/x86_64/efi/startup.S'; fi`
+
+kern/x86_64/efi/kernel_exec-callwrap.o: kern/x86_64/efi/callwrap.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/x86_64/efi/kernel_exec-callwrap.o -MD -MP -MF kern/x86_64/efi/$(DEPDIR)/kernel_exec-callwrap.Tpo -c -o kern/x86_64/efi/kernel_exec-callwrap.o `test -f 'kern/x86_64/efi/callwrap.S' || echo '$(srcdir)/'`kern/x86_64/efi/callwrap.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/x86_64/efi/$(DEPDIR)/kernel_exec-callwrap.Tpo kern/x86_64/efi/$(DEPDIR)/kernel_exec-callwrap.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/x86_64/efi/callwrap.S' object='kern/x86_64/efi/kernel_exec-callwrap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/x86_64/efi/kernel_exec-callwrap.o `test -f 'kern/x86_64/efi/callwrap.S' || echo '$(srcdir)/'`kern/x86_64/efi/callwrap.S
+
+kern/x86_64/efi/kernel_exec-callwrap.obj: kern/x86_64/efi/callwrap.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/x86_64/efi/kernel_exec-callwrap.obj -MD -MP -MF kern/x86_64/efi/$(DEPDIR)/kernel_exec-callwrap.Tpo -c -o kern/x86_64/efi/kernel_exec-callwrap.obj `if test -f 'kern/x86_64/efi/callwrap.S'; then $(CYGPATH_W) 'kern/x86_64/efi/callwrap.S'; else $(CYGPATH_W) '$(srcdir)/kern/x86_64/efi/callwrap.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/x86_64/efi/$(DEPDIR)/kernel_exec-callwrap.Tpo kern/x86_64/efi/$(DEPDIR)/kernel_exec-callwrap.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/x86_64/efi/callwrap.S' object='kern/x86_64/efi/kernel_exec-callwrap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/x86_64/efi/kernel_exec-callwrap.obj `if test -f 'kern/x86_64/efi/callwrap.S'; then $(CYGPATH_W) 'kern/x86_64/efi/callwrap.S'; else $(CYGPATH_W) '$(srcdir)/kern/x86_64/efi/callwrap.S'; fi`
+
+kern/x86_64/xen/kernel_exec-startup.o: kern/x86_64/xen/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/x86_64/xen/kernel_exec-startup.o -MD -MP -MF kern/x86_64/xen/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/x86_64/xen/kernel_exec-startup.o `test -f 'kern/x86_64/xen/startup.S' || echo '$(srcdir)/'`kern/x86_64/xen/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/x86_64/xen/$(DEPDIR)/kernel_exec-startup.Tpo kern/x86_64/xen/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/x86_64/xen/startup.S' object='kern/x86_64/xen/kernel_exec-startup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/x86_64/xen/kernel_exec-startup.o `test -f 'kern/x86_64/xen/startup.S' || echo '$(srcdir)/'`kern/x86_64/xen/startup.S
+
+kern/x86_64/xen/kernel_exec-startup.obj: kern/x86_64/xen/startup.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/x86_64/xen/kernel_exec-startup.obj -MD -MP -MF kern/x86_64/xen/$(DEPDIR)/kernel_exec-startup.Tpo -c -o kern/x86_64/xen/kernel_exec-startup.obj `if test -f 'kern/x86_64/xen/startup.S'; then $(CYGPATH_W) 'kern/x86_64/xen/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/x86_64/xen/startup.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/x86_64/xen/$(DEPDIR)/kernel_exec-startup.Tpo kern/x86_64/xen/$(DEPDIR)/kernel_exec-startup.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/x86_64/xen/startup.S' object='kern/x86_64/xen/kernel_exec-startup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/x86_64/xen/kernel_exec-startup.obj `if test -f 'kern/x86_64/xen/startup.S'; then $(CYGPATH_W) 'kern/x86_64/xen/startup.S'; else $(CYGPATH_W) '$(srcdir)/kern/x86_64/xen/startup.S'; fi`
+
+kern/x86_64/xen/kernel_exec-hypercall.o: kern/x86_64/xen/hypercall.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/x86_64/xen/kernel_exec-hypercall.o -MD -MP -MF kern/x86_64/xen/$(DEPDIR)/kernel_exec-hypercall.Tpo -c -o kern/x86_64/xen/kernel_exec-hypercall.o `test -f 'kern/x86_64/xen/hypercall.S' || echo '$(srcdir)/'`kern/x86_64/xen/hypercall.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/x86_64/xen/$(DEPDIR)/kernel_exec-hypercall.Tpo kern/x86_64/xen/$(DEPDIR)/kernel_exec-hypercall.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/x86_64/xen/hypercall.S' object='kern/x86_64/xen/kernel_exec-hypercall.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/x86_64/xen/kernel_exec-hypercall.o `test -f 'kern/x86_64/xen/hypercall.S' || echo '$(srcdir)/'`kern/x86_64/xen/hypercall.S
+
+kern/x86_64/xen/kernel_exec-hypercall.obj: kern/x86_64/xen/hypercall.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -MT kern/x86_64/xen/kernel_exec-hypercall.obj -MD -MP -MF kern/x86_64/xen/$(DEPDIR)/kernel_exec-hypercall.Tpo -c -o kern/x86_64/xen/kernel_exec-hypercall.obj `if test -f 'kern/x86_64/xen/hypercall.S'; then $(CYGPATH_W) 'kern/x86_64/xen/hypercall.S'; else $(CYGPATH_W) '$(srcdir)/kern/x86_64/xen/hypercall.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) kern/x86_64/xen/$(DEPDIR)/kernel_exec-hypercall.Tpo kern/x86_64/xen/$(DEPDIR)/kernel_exec-hypercall.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='kern/x86_64/xen/hypercall.S' object='kern/x86_64/xen/kernel_exec-hypercall.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CCASFLAGS) $(CCASFLAGS) -c -o kern/x86_64/xen/kernel_exec-hypercall.obj `if test -f 'kern/x86_64/xen/hypercall.S'; then $(CYGPATH_W) 'kern/x86_64/xen/hypercall.S'; else $(CYGPATH_W) '$(srcdir)/kern/x86_64/xen/hypercall.S'; fi`
+
+boot/i386/pc/lnxboot_image-lnxboot.o: boot/i386/pc/lnxboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lnxboot_image_CPPFLAGS) $(CPPFLAGS) $(lnxboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/lnxboot_image-lnxboot.o -MD -MP -MF boot/i386/pc/$(DEPDIR)/lnxboot_image-lnxboot.Tpo -c -o boot/i386/pc/lnxboot_image-lnxboot.o `test -f 'boot/i386/pc/lnxboot.S' || echo '$(srcdir)/'`boot/i386/pc/lnxboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/lnxboot_image-lnxboot.Tpo boot/i386/pc/$(DEPDIR)/lnxboot_image-lnxboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/lnxboot.S' object='boot/i386/pc/lnxboot_image-lnxboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lnxboot_image_CPPFLAGS) $(CPPFLAGS) $(lnxboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/lnxboot_image-lnxboot.o `test -f 'boot/i386/pc/lnxboot.S' || echo '$(srcdir)/'`boot/i386/pc/lnxboot.S
+
+boot/i386/pc/lnxboot_image-lnxboot.obj: boot/i386/pc/lnxboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lnxboot_image_CPPFLAGS) $(CPPFLAGS) $(lnxboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/lnxboot_image-lnxboot.obj -MD -MP -MF boot/i386/pc/$(DEPDIR)/lnxboot_image-lnxboot.Tpo -c -o boot/i386/pc/lnxboot_image-lnxboot.obj `if test -f 'boot/i386/pc/lnxboot.S'; then $(CYGPATH_W) 'boot/i386/pc/lnxboot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/lnxboot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/lnxboot_image-lnxboot.Tpo boot/i386/pc/$(DEPDIR)/lnxboot_image-lnxboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/lnxboot.S' object='boot/i386/pc/lnxboot_image-lnxboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lnxboot_image_CPPFLAGS) $(CPPFLAGS) $(lnxboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/lnxboot_image-lnxboot.obj `if test -f 'boot/i386/pc/lnxboot.S'; then $(CYGPATH_W) 'boot/i386/pc/lnxboot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/lnxboot.S'; fi`
+
+boot/i386/pc/lzma_decompress_image-startup_raw.o: boot/i386/pc/startup_raw.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzma_decompress_image_CPPFLAGS) $(CPPFLAGS) $(lzma_decompress_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/lzma_decompress_image-startup_raw.o -MD -MP -MF boot/i386/pc/$(DEPDIR)/lzma_decompress_image-startup_raw.Tpo -c -o boot/i386/pc/lzma_decompress_image-startup_raw.o `test -f 'boot/i386/pc/startup_raw.S' || echo '$(srcdir)/'`boot/i386/pc/startup_raw.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/lzma_decompress_image-startup_raw.Tpo boot/i386/pc/$(DEPDIR)/lzma_decompress_image-startup_raw.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/startup_raw.S' object='boot/i386/pc/lzma_decompress_image-startup_raw.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzma_decompress_image_CPPFLAGS) $(CPPFLAGS) $(lzma_decompress_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/lzma_decompress_image-startup_raw.o `test -f 'boot/i386/pc/startup_raw.S' || echo '$(srcdir)/'`boot/i386/pc/startup_raw.S
+
+boot/i386/pc/lzma_decompress_image-startup_raw.obj: boot/i386/pc/startup_raw.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzma_decompress_image_CPPFLAGS) $(CPPFLAGS) $(lzma_decompress_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/lzma_decompress_image-startup_raw.obj -MD -MP -MF boot/i386/pc/$(DEPDIR)/lzma_decompress_image-startup_raw.Tpo -c -o boot/i386/pc/lzma_decompress_image-startup_raw.obj `if test -f 'boot/i386/pc/startup_raw.S'; then $(CYGPATH_W) 'boot/i386/pc/startup_raw.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/startup_raw.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/lzma_decompress_image-startup_raw.Tpo boot/i386/pc/$(DEPDIR)/lzma_decompress_image-startup_raw.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/startup_raw.S' object='boot/i386/pc/lzma_decompress_image-startup_raw.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzma_decompress_image_CPPFLAGS) $(CPPFLAGS) $(lzma_decompress_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/lzma_decompress_image-startup_raw.obj `if test -f 'boot/i386/pc/startup_raw.S'; then $(CYGPATH_W) 'boot/i386/pc/startup_raw.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/startup_raw.S'; fi`
+
+mmap/i386/pc/mmap_module-mmap_helper.o: mmap/i386/pc/mmap_helper.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CCASFLAGS) $(CCASFLAGS) -MT mmap/i386/pc/mmap_module-mmap_helper.o -MD -MP -MF mmap/i386/pc/$(DEPDIR)/mmap_module-mmap_helper.Tpo -c -o mmap/i386/pc/mmap_module-mmap_helper.o `test -f 'mmap/i386/pc/mmap_helper.S' || echo '$(srcdir)/'`mmap/i386/pc/mmap_helper.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) mmap/i386/pc/$(DEPDIR)/mmap_module-mmap_helper.Tpo mmap/i386/pc/$(DEPDIR)/mmap_module-mmap_helper.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='mmap/i386/pc/mmap_helper.S' object='mmap/i386/pc/mmap_module-mmap_helper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CCASFLAGS) $(CCASFLAGS) -c -o mmap/i386/pc/mmap_module-mmap_helper.o `test -f 'mmap/i386/pc/mmap_helper.S' || echo '$(srcdir)/'`mmap/i386/pc/mmap_helper.S
+
+mmap/i386/pc/mmap_module-mmap_helper.obj: mmap/i386/pc/mmap_helper.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CCASFLAGS) $(CCASFLAGS) -MT mmap/i386/pc/mmap_module-mmap_helper.obj -MD -MP -MF mmap/i386/pc/$(DEPDIR)/mmap_module-mmap_helper.Tpo -c -o mmap/i386/pc/mmap_module-mmap_helper.obj `if test -f 'mmap/i386/pc/mmap_helper.S'; then $(CYGPATH_W) 'mmap/i386/pc/mmap_helper.S'; else $(CYGPATH_W) '$(srcdir)/mmap/i386/pc/mmap_helper.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) mmap/i386/pc/$(DEPDIR)/mmap_module-mmap_helper.Tpo mmap/i386/pc/$(DEPDIR)/mmap_module-mmap_helper.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='mmap/i386/pc/mmap_helper.S' object='mmap/i386/pc/mmap_module-mmap_helper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CCASFLAGS) $(CCASFLAGS) -c -o mmap/i386/pc/mmap_module-mmap_helper.obj `if test -f 'mmap/i386/pc/mmap_helper.S'; then $(CYGPATH_W) 'mmap/i386/pc/mmap_helper.S'; else $(CYGPATH_W) '$(srcdir)/mmap/i386/pc/mmap_helper.S'; fi`
+
+boot/mips/none_decompress_image-startup_raw.o: boot/mips/startup_raw.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(none_decompress_image_CPPFLAGS) $(CPPFLAGS) $(none_decompress_image_CCASFLAGS) $(CCASFLAGS) -MT boot/mips/none_decompress_image-startup_raw.o -MD -MP -MF boot/mips/$(DEPDIR)/none_decompress_image-startup_raw.Tpo -c -o boot/mips/none_decompress_image-startup_raw.o `test -f 'boot/mips/startup_raw.S' || echo '$(srcdir)/'`boot/mips/startup_raw.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/mips/$(DEPDIR)/none_decompress_image-startup_raw.Tpo boot/mips/$(DEPDIR)/none_decompress_image-startup_raw.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/mips/startup_raw.S' object='boot/mips/none_decompress_image-startup_raw.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(none_decompress_image_CPPFLAGS) $(CPPFLAGS) $(none_decompress_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/mips/none_decompress_image-startup_raw.o `test -f 'boot/mips/startup_raw.S' || echo '$(srcdir)/'`boot/mips/startup_raw.S
+
+boot/mips/none_decompress_image-startup_raw.obj: boot/mips/startup_raw.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(none_decompress_image_CPPFLAGS) $(CPPFLAGS) $(none_decompress_image_CCASFLAGS) $(CCASFLAGS) -MT boot/mips/none_decompress_image-startup_raw.obj -MD -MP -MF boot/mips/$(DEPDIR)/none_decompress_image-startup_raw.Tpo -c -o boot/mips/none_decompress_image-startup_raw.obj `if test -f 'boot/mips/startup_raw.S'; then $(CYGPATH_W) 'boot/mips/startup_raw.S'; else $(CYGPATH_W) '$(srcdir)/boot/mips/startup_raw.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/mips/$(DEPDIR)/none_decompress_image-startup_raw.Tpo boot/mips/$(DEPDIR)/none_decompress_image-startup_raw.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/mips/startup_raw.S' object='boot/mips/none_decompress_image-startup_raw.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(none_decompress_image_CPPFLAGS) $(CPPFLAGS) $(none_decompress_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/mips/none_decompress_image-startup_raw.obj `if test -f 'boot/mips/startup_raw.S'; then $(CYGPATH_W) 'boot/mips/startup_raw.S'; else $(CYGPATH_W) '$(srcdir)/boot/mips/startup_raw.S'; fi`
+
+boot/i386/pc/pxeboot_image-pxeboot.o: boot/i386/pc/pxeboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxeboot_image_CPPFLAGS) $(CPPFLAGS) $(pxeboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/pxeboot_image-pxeboot.o -MD -MP -MF boot/i386/pc/$(DEPDIR)/pxeboot_image-pxeboot.Tpo -c -o boot/i386/pc/pxeboot_image-pxeboot.o `test -f 'boot/i386/pc/pxeboot.S' || echo '$(srcdir)/'`boot/i386/pc/pxeboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/pxeboot_image-pxeboot.Tpo boot/i386/pc/$(DEPDIR)/pxeboot_image-pxeboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/pxeboot.S' object='boot/i386/pc/pxeboot_image-pxeboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxeboot_image_CPPFLAGS) $(CPPFLAGS) $(pxeboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/pxeboot_image-pxeboot.o `test -f 'boot/i386/pc/pxeboot.S' || echo '$(srcdir)/'`boot/i386/pc/pxeboot.S
+
+boot/i386/pc/pxeboot_image-pxeboot.obj: boot/i386/pc/pxeboot.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxeboot_image_CPPFLAGS) $(CPPFLAGS) $(pxeboot_image_CCASFLAGS) $(CCASFLAGS) -MT boot/i386/pc/pxeboot_image-pxeboot.obj -MD -MP -MF boot/i386/pc/$(DEPDIR)/pxeboot_image-pxeboot.Tpo -c -o boot/i386/pc/pxeboot_image-pxeboot.obj `if test -f 'boot/i386/pc/pxeboot.S'; then $(CYGPATH_W) 'boot/i386/pc/pxeboot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/pxeboot.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/i386/pc/$(DEPDIR)/pxeboot_image-pxeboot.Tpo boot/i386/pc/$(DEPDIR)/pxeboot_image-pxeboot.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/i386/pc/pxeboot.S' object='boot/i386/pc/pxeboot_image-pxeboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxeboot_image_CPPFLAGS) $(CPPFLAGS) $(pxeboot_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/i386/pc/pxeboot_image-pxeboot.obj `if test -f 'boot/i386/pc/pxeboot.S'; then $(CYGPATH_W) 'boot/i386/pc/pxeboot.S'; else $(CYGPATH_W) '$(srcdir)/boot/i386/pc/pxeboot.S'; fi`
+
+lib/i386/reboot_module-reboot_trampoline.o: lib/i386/reboot_trampoline.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/reboot_module-reboot_trampoline.o -MD -MP -MF lib/i386/$(DEPDIR)/reboot_module-reboot_trampoline.Tpo -c -o lib/i386/reboot_module-reboot_trampoline.o `test -f 'lib/i386/reboot_trampoline.S' || echo '$(srcdir)/'`lib/i386/reboot_trampoline.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/reboot_module-reboot_trampoline.Tpo lib/i386/$(DEPDIR)/reboot_module-reboot_trampoline.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/reboot_trampoline.S' object='lib/i386/reboot_module-reboot_trampoline.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/reboot_module-reboot_trampoline.o `test -f 'lib/i386/reboot_trampoline.S' || echo '$(srcdir)/'`lib/i386/reboot_trampoline.S
+
+lib/i386/reboot_module-reboot_trampoline.obj: lib/i386/reboot_trampoline.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/reboot_module-reboot_trampoline.obj -MD -MP -MF lib/i386/$(DEPDIR)/reboot_module-reboot_trampoline.Tpo -c -o lib/i386/reboot_module-reboot_trampoline.obj `if test -f 'lib/i386/reboot_trampoline.S'; then $(CYGPATH_W) 'lib/i386/reboot_trampoline.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/reboot_trampoline.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/reboot_module-reboot_trampoline.Tpo lib/i386/$(DEPDIR)/reboot_module-reboot_trampoline.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/reboot_trampoline.S' object='lib/i386/reboot_module-reboot_trampoline.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/reboot_module-reboot_trampoline.obj `if test -f 'lib/i386/reboot_trampoline.S'; then $(CYGPATH_W) 'lib/i386/reboot_trampoline.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/reboot_trampoline.S'; fi`
+
+lib/i386/relocator_module-relocator_asm.o: lib/i386/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/relocator_module-relocator_asm.o -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator_asm.Tpo -c -o lib/i386/relocator_module-relocator_asm.o `test -f 'lib/i386/relocator_asm.S' || echo '$(srcdir)/'`lib/i386/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator_asm.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator_asm.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/relocator_asm.S' object='lib/i386/relocator_module-relocator_asm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/relocator_module-relocator_asm.o `test -f 'lib/i386/relocator_asm.S' || echo '$(srcdir)/'`lib/i386/relocator_asm.S
+
+lib/i386/relocator_module-relocator_asm.obj: lib/i386/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/relocator_module-relocator_asm.obj -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator_asm.Tpo -c -o lib/i386/relocator_module-relocator_asm.obj `if test -f 'lib/i386/relocator_asm.S'; then $(CYGPATH_W) 'lib/i386/relocator_asm.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator_asm.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator_asm.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator_asm.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/relocator_asm.S' object='lib/i386/relocator_module-relocator_asm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/relocator_module-relocator_asm.obj `if test -f 'lib/i386/relocator_asm.S'; then $(CYGPATH_W) 'lib/i386/relocator_asm.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator_asm.S'; fi`
+
+lib/i386/relocator_module-relocator16.o: lib/i386/relocator16.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/relocator_module-relocator16.o -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator16.Tpo -c -o lib/i386/relocator_module-relocator16.o `test -f 'lib/i386/relocator16.S' || echo '$(srcdir)/'`lib/i386/relocator16.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator16.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator16.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/relocator16.S' object='lib/i386/relocator_module-relocator16.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/relocator_module-relocator16.o `test -f 'lib/i386/relocator16.S' || echo '$(srcdir)/'`lib/i386/relocator16.S
+
+lib/i386/relocator_module-relocator16.obj: lib/i386/relocator16.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/relocator_module-relocator16.obj -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator16.Tpo -c -o lib/i386/relocator_module-relocator16.obj `if test -f 'lib/i386/relocator16.S'; then $(CYGPATH_W) 'lib/i386/relocator16.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator16.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator16.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator16.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/relocator16.S' object='lib/i386/relocator_module-relocator16.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/relocator_module-relocator16.obj `if test -f 'lib/i386/relocator16.S'; then $(CYGPATH_W) 'lib/i386/relocator16.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator16.S'; fi`
+
+lib/i386/relocator_module-relocator32.o: lib/i386/relocator32.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/relocator_module-relocator32.o -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator32.Tpo -c -o lib/i386/relocator_module-relocator32.o `test -f 'lib/i386/relocator32.S' || echo '$(srcdir)/'`lib/i386/relocator32.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator32.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator32.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/relocator32.S' object='lib/i386/relocator_module-relocator32.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/relocator_module-relocator32.o `test -f 'lib/i386/relocator32.S' || echo '$(srcdir)/'`lib/i386/relocator32.S
+
+lib/i386/relocator_module-relocator32.obj: lib/i386/relocator32.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/relocator_module-relocator32.obj -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator32.Tpo -c -o lib/i386/relocator_module-relocator32.obj `if test -f 'lib/i386/relocator32.S'; then $(CYGPATH_W) 'lib/i386/relocator32.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator32.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator32.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator32.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/relocator32.S' object='lib/i386/relocator_module-relocator32.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/relocator_module-relocator32.obj `if test -f 'lib/i386/relocator32.S'; then $(CYGPATH_W) 'lib/i386/relocator32.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator32.S'; fi`
+
+lib/i386/relocator_module-relocator64.o: lib/i386/relocator64.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/relocator_module-relocator64.o -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator64.Tpo -c -o lib/i386/relocator_module-relocator64.o `test -f 'lib/i386/relocator64.S' || echo '$(srcdir)/'`lib/i386/relocator64.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator64.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator64.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/relocator64.S' object='lib/i386/relocator_module-relocator64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/relocator_module-relocator64.o `test -f 'lib/i386/relocator64.S' || echo '$(srcdir)/'`lib/i386/relocator64.S
+
+lib/i386/relocator_module-relocator64.obj: lib/i386/relocator64.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/relocator_module-relocator64.obj -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator64.Tpo -c -o lib/i386/relocator_module-relocator64.obj `if test -f 'lib/i386/relocator64.S'; then $(CYGPATH_W) 'lib/i386/relocator64.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator64.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator64.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator64.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/relocator64.S' object='lib/i386/relocator_module-relocator64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/relocator_module-relocator64.obj `if test -f 'lib/i386/relocator64.S'; then $(CYGPATH_W) 'lib/i386/relocator64.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator64.S'; fi`
+
+lib/i386/xen/relocator_module-relocator.o: lib/i386/xen/relocator.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/xen/relocator_module-relocator.o -MD -MP -MF lib/i386/xen/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/i386/xen/relocator_module-relocator.o `test -f 'lib/i386/xen/relocator.S' || echo '$(srcdir)/'`lib/i386/xen/relocator.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/xen/$(DEPDIR)/relocator_module-relocator.Tpo lib/i386/xen/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/xen/relocator.S' object='lib/i386/xen/relocator_module-relocator.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/xen/relocator_module-relocator.o `test -f 'lib/i386/xen/relocator.S' || echo '$(srcdir)/'`lib/i386/xen/relocator.S
+
+lib/i386/xen/relocator_module-relocator.obj: lib/i386/xen/relocator.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/i386/xen/relocator_module-relocator.obj -MD -MP -MF lib/i386/xen/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/i386/xen/relocator_module-relocator.obj `if test -f 'lib/i386/xen/relocator.S'; then $(CYGPATH_W) 'lib/i386/xen/relocator.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/xen/relocator.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/i386/xen/$(DEPDIR)/relocator_module-relocator.Tpo lib/i386/xen/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/i386/xen/relocator.S' object='lib/i386/xen/relocator_module-relocator.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/i386/xen/relocator_module-relocator.obj `if test -f 'lib/i386/xen/relocator.S'; then $(CYGPATH_W) 'lib/i386/xen/relocator.S'; else $(CYGPATH_W) '$(srcdir)/lib/i386/xen/relocator.S'; fi`
+
+lib/mips/relocator_module-relocator_asm.o: lib/mips/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/mips/relocator_module-relocator_asm.o -MD -MP -MF lib/mips/$(DEPDIR)/relocator_module-relocator_asm.Tpo -c -o lib/mips/relocator_module-relocator_asm.o `test -f 'lib/mips/relocator_asm.S' || echo '$(srcdir)/'`lib/mips/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/mips/$(DEPDIR)/relocator_module-relocator_asm.Tpo lib/mips/$(DEPDIR)/relocator_module-relocator_asm.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/mips/relocator_asm.S' object='lib/mips/relocator_module-relocator_asm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/mips/relocator_module-relocator_asm.o `test -f 'lib/mips/relocator_asm.S' || echo '$(srcdir)/'`lib/mips/relocator_asm.S
+
+lib/mips/relocator_module-relocator_asm.obj: lib/mips/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/mips/relocator_module-relocator_asm.obj -MD -MP -MF lib/mips/$(DEPDIR)/relocator_module-relocator_asm.Tpo -c -o lib/mips/relocator_module-relocator_asm.obj `if test -f 'lib/mips/relocator_asm.S'; then $(CYGPATH_W) 'lib/mips/relocator_asm.S'; else $(CYGPATH_W) '$(srcdir)/lib/mips/relocator_asm.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/mips/$(DEPDIR)/relocator_module-relocator_asm.Tpo lib/mips/$(DEPDIR)/relocator_module-relocator_asm.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/mips/relocator_asm.S' object='lib/mips/relocator_module-relocator_asm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/mips/relocator_module-relocator_asm.obj `if test -f 'lib/mips/relocator_asm.S'; then $(CYGPATH_W) 'lib/mips/relocator_asm.S'; else $(CYGPATH_W) '$(srcdir)/lib/mips/relocator_asm.S'; fi`
+
+lib/powerpc/relocator_module-relocator_asm.o: lib/powerpc/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/powerpc/relocator_module-relocator_asm.o -MD -MP -MF lib/powerpc/$(DEPDIR)/relocator_module-relocator_asm.Tpo -c -o lib/powerpc/relocator_module-relocator_asm.o `test -f 'lib/powerpc/relocator_asm.S' || echo '$(srcdir)/'`lib/powerpc/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/powerpc/$(DEPDIR)/relocator_module-relocator_asm.Tpo lib/powerpc/$(DEPDIR)/relocator_module-relocator_asm.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/powerpc/relocator_asm.S' object='lib/powerpc/relocator_module-relocator_asm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/powerpc/relocator_module-relocator_asm.o `test -f 'lib/powerpc/relocator_asm.S' || echo '$(srcdir)/'`lib/powerpc/relocator_asm.S
+
+lib/powerpc/relocator_module-relocator_asm.obj: lib/powerpc/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/powerpc/relocator_module-relocator_asm.obj -MD -MP -MF lib/powerpc/$(DEPDIR)/relocator_module-relocator_asm.Tpo -c -o lib/powerpc/relocator_module-relocator_asm.obj `if test -f 'lib/powerpc/relocator_asm.S'; then $(CYGPATH_W) 'lib/powerpc/relocator_asm.S'; else $(CYGPATH_W) '$(srcdir)/lib/powerpc/relocator_asm.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/powerpc/$(DEPDIR)/relocator_module-relocator_asm.Tpo lib/powerpc/$(DEPDIR)/relocator_module-relocator_asm.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/powerpc/relocator_asm.S' object='lib/powerpc/relocator_module-relocator_asm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/powerpc/relocator_module-relocator_asm.obj `if test -f 'lib/powerpc/relocator_asm.S'; then $(CYGPATH_W) 'lib/powerpc/relocator_asm.S'; else $(CYGPATH_W) '$(srcdir)/lib/powerpc/relocator_asm.S'; fi`
+
+lib/x86_64/relocator_module-relocator_asm.o: lib/x86_64/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/x86_64/relocator_module-relocator_asm.o -MD -MP -MF lib/x86_64/$(DEPDIR)/relocator_module-relocator_asm.Tpo -c -o lib/x86_64/relocator_module-relocator_asm.o `test -f 'lib/x86_64/relocator_asm.S' || echo '$(srcdir)/'`lib/x86_64/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/x86_64/$(DEPDIR)/relocator_module-relocator_asm.Tpo lib/x86_64/$(DEPDIR)/relocator_module-relocator_asm.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/x86_64/relocator_asm.S' object='lib/x86_64/relocator_module-relocator_asm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/x86_64/relocator_module-relocator_asm.o `test -f 'lib/x86_64/relocator_asm.S' || echo '$(srcdir)/'`lib/x86_64/relocator_asm.S
+
+lib/x86_64/relocator_module-relocator_asm.obj: lib/x86_64/relocator_asm.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/x86_64/relocator_module-relocator_asm.obj -MD -MP -MF lib/x86_64/$(DEPDIR)/relocator_module-relocator_asm.Tpo -c -o lib/x86_64/relocator_module-relocator_asm.obj `if test -f 'lib/x86_64/relocator_asm.S'; then $(CYGPATH_W) 'lib/x86_64/relocator_asm.S'; else $(CYGPATH_W) '$(srcdir)/lib/x86_64/relocator_asm.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/x86_64/$(DEPDIR)/relocator_module-relocator_asm.Tpo lib/x86_64/$(DEPDIR)/relocator_module-relocator_asm.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/x86_64/relocator_asm.S' object='lib/x86_64/relocator_module-relocator_asm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/x86_64/relocator_module-relocator_asm.obj `if test -f 'lib/x86_64/relocator_asm.S'; then $(CYGPATH_W) 'lib/x86_64/relocator_asm.S'; else $(CYGPATH_W) '$(srcdir)/lib/x86_64/relocator_asm.S'; fi`
+
+lib/x86_64/xen/relocator_module-relocator.o: lib/x86_64/xen/relocator.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/x86_64/xen/relocator_module-relocator.o -MD -MP -MF lib/x86_64/xen/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/x86_64/xen/relocator_module-relocator.o `test -f 'lib/x86_64/xen/relocator.S' || echo '$(srcdir)/'`lib/x86_64/xen/relocator.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/x86_64/xen/$(DEPDIR)/relocator_module-relocator.Tpo lib/x86_64/xen/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/x86_64/xen/relocator.S' object='lib/x86_64/xen/relocator_module-relocator.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/x86_64/xen/relocator_module-relocator.o `test -f 'lib/x86_64/xen/relocator.S' || echo '$(srcdir)/'`lib/x86_64/xen/relocator.S
+
+lib/x86_64/xen/relocator_module-relocator.obj: lib/x86_64/xen/relocator.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -MT lib/x86_64/xen/relocator_module-relocator.obj -MD -MP -MF lib/x86_64/xen/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/x86_64/xen/relocator_module-relocator.obj `if test -f 'lib/x86_64/xen/relocator.S'; then $(CYGPATH_W) 'lib/x86_64/xen/relocator.S'; else $(CYGPATH_W) '$(srcdir)/lib/x86_64/xen/relocator.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/x86_64/xen/$(DEPDIR)/relocator_module-relocator.Tpo lib/x86_64/xen/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/x86_64/xen/relocator.S' object='lib/x86_64/xen/relocator_module-relocator.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/x86_64/xen/relocator_module-relocator.obj `if test -f 'lib/x86_64/xen/relocator.S'; then $(CYGPATH_W) 'lib/x86_64/xen/relocator.S'; else $(CYGPATH_W) '$(srcdir)/lib/x86_64/xen/relocator.S'; fi`
+
+lib/setjmp_module-setjmp.o: lib/setjmp.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_module_CPPFLAGS) $(CPPFLAGS) $(setjmp_module_CCASFLAGS) $(CCASFLAGS) -MT lib/setjmp_module-setjmp.o -MD -MP -MF lib/$(DEPDIR)/setjmp_module-setjmp.Tpo -c -o lib/setjmp_module-setjmp.o `test -f 'lib/setjmp.S' || echo '$(srcdir)/'`lib/setjmp.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/setjmp_module-setjmp.Tpo lib/$(DEPDIR)/setjmp_module-setjmp.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/setjmp.S' object='lib/setjmp_module-setjmp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_module_CPPFLAGS) $(CPPFLAGS) $(setjmp_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/setjmp_module-setjmp.o `test -f 'lib/setjmp.S' || echo '$(srcdir)/'`lib/setjmp.S
+
+lib/setjmp_module-setjmp.obj: lib/setjmp.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_module_CPPFLAGS) $(CPPFLAGS) $(setjmp_module_CCASFLAGS) $(CCASFLAGS) -MT lib/setjmp_module-setjmp.obj -MD -MP -MF lib/$(DEPDIR)/setjmp_module-setjmp.Tpo -c -o lib/setjmp_module-setjmp.obj `if test -f 'lib/setjmp.S'; then $(CYGPATH_W) 'lib/setjmp.S'; else $(CYGPATH_W) '$(srcdir)/lib/setjmp.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/setjmp_module-setjmp.Tpo lib/$(DEPDIR)/setjmp_module-setjmp.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='lib/setjmp.S' object='lib/setjmp_module-setjmp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_module_CPPFLAGS) $(CPPFLAGS) $(setjmp_module_CCASFLAGS) $(CCASFLAGS) -c -o lib/setjmp_module-setjmp.obj `if test -f 'lib/setjmp.S'; then $(CYGPATH_W) 'lib/setjmp.S'; else $(CYGPATH_W) '$(srcdir)/lib/setjmp.S'; fi`
+
+boot/mips/xz_decompress_image-startup_raw.o: boot/mips/startup_raw.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CCASFLAGS) $(CCASFLAGS) -MT boot/mips/xz_decompress_image-startup_raw.o -MD -MP -MF boot/mips/$(DEPDIR)/xz_decompress_image-startup_raw.Tpo -c -o boot/mips/xz_decompress_image-startup_raw.o `test -f 'boot/mips/startup_raw.S' || echo '$(srcdir)/'`boot/mips/startup_raw.S
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/mips/$(DEPDIR)/xz_decompress_image-startup_raw.Tpo boot/mips/$(DEPDIR)/xz_decompress_image-startup_raw.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/mips/startup_raw.S' object='boot/mips/xz_decompress_image-startup_raw.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/mips/xz_decompress_image-startup_raw.o `test -f 'boot/mips/startup_raw.S' || echo '$(srcdir)/'`boot/mips/startup_raw.S
+
+boot/mips/xz_decompress_image-startup_raw.obj: boot/mips/startup_raw.S
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CCASFLAGS) $(CCASFLAGS) -MT boot/mips/xz_decompress_image-startup_raw.obj -MD -MP -MF boot/mips/$(DEPDIR)/xz_decompress_image-startup_raw.Tpo -c -o boot/mips/xz_decompress_image-startup_raw.obj `if test -f 'boot/mips/startup_raw.S'; then $(CYGPATH_W) 'boot/mips/startup_raw.S'; else $(CYGPATH_W) '$(srcdir)/boot/mips/startup_raw.S'; fi`
+@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) boot/mips/$(DEPDIR)/xz_decompress_image-startup_raw.Tpo boot/mips/$(DEPDIR)/xz_decompress_image-startup_raw.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='boot/mips/startup_raw.S' object='boot/mips/xz_decompress_image-startup_raw.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CCASFLAGS) $(CCASFLAGS) -c -o boot/mips/xz_decompress_image-startup_raw.obj `if test -f 'boot/mips/startup_raw.S'; then $(CYGPATH_W) 'boot/mips/startup_raw.S'; else $(CYGPATH_W) '$(srcdir)/boot/mips/startup_raw.S'; fi`
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+commands/acpi_module-acpi.o: commands/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -MT commands/acpi_module-acpi.o -MD -MP -MF commands/$(DEPDIR)/acpi_module-acpi.Tpo -c -o commands/acpi_module-acpi.o `test -f 'commands/acpi.c' || echo '$(srcdir)/'`commands/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/acpi_module-acpi.Tpo commands/$(DEPDIR)/acpi_module-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/acpi.c' object='commands/acpi_module-acpi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -c -o commands/acpi_module-acpi.o `test -f 'commands/acpi.c' || echo '$(srcdir)/'`commands/acpi.c
+
+commands/acpi_module-acpi.obj: commands/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -MT commands/acpi_module-acpi.obj -MD -MP -MF commands/$(DEPDIR)/acpi_module-acpi.Tpo -c -o commands/acpi_module-acpi.obj `if test -f 'commands/acpi.c'; then $(CYGPATH_W) 'commands/acpi.c'; else $(CYGPATH_W) '$(srcdir)/commands/acpi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/acpi_module-acpi.Tpo commands/$(DEPDIR)/acpi_module-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/acpi.c' object='commands/acpi_module-acpi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -c -o commands/acpi_module-acpi.obj `if test -f 'commands/acpi.c'; then $(CYGPATH_W) 'commands/acpi.c'; else $(CYGPATH_W) '$(srcdir)/commands/acpi.c'; fi`
+
+kern/acpi_module-acpi.o: kern/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -MT kern/acpi_module-acpi.o -MD -MP -MF kern/$(DEPDIR)/acpi_module-acpi.Tpo -c -o kern/acpi_module-acpi.o `test -f 'kern/acpi.c' || echo '$(srcdir)/'`kern/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/acpi_module-acpi.Tpo kern/$(DEPDIR)/acpi_module-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/acpi.c' object='kern/acpi_module-acpi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -c -o kern/acpi_module-acpi.o `test -f 'kern/acpi.c' || echo '$(srcdir)/'`kern/acpi.c
+
+kern/acpi_module-acpi.obj: kern/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -MT kern/acpi_module-acpi.obj -MD -MP -MF kern/$(DEPDIR)/acpi_module-acpi.Tpo -c -o kern/acpi_module-acpi.obj `if test -f 'kern/acpi.c'; then $(CYGPATH_W) 'kern/acpi.c'; else $(CYGPATH_W) '$(srcdir)/kern/acpi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/acpi_module-acpi.Tpo kern/$(DEPDIR)/acpi_module-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/acpi.c' object='kern/acpi_module-acpi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -c -o kern/acpi_module-acpi.obj `if test -f 'kern/acpi.c'; then $(CYGPATH_W) 'kern/acpi.c'; else $(CYGPATH_W) '$(srcdir)/kern/acpi.c'; fi`
+
+kern/i386/pc/acpi_module-acpi.o: kern/i386/pc/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -MT kern/i386/pc/acpi_module-acpi.o -MD -MP -MF kern/i386/pc/$(DEPDIR)/acpi_module-acpi.Tpo -c -o kern/i386/pc/acpi_module-acpi.o `test -f 'kern/i386/pc/acpi.c' || echo '$(srcdir)/'`kern/i386/pc/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/pc/$(DEPDIR)/acpi_module-acpi.Tpo kern/i386/pc/$(DEPDIR)/acpi_module-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/pc/acpi.c' object='kern/i386/pc/acpi_module-acpi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -c -o kern/i386/pc/acpi_module-acpi.o `test -f 'kern/i386/pc/acpi.c' || echo '$(srcdir)/'`kern/i386/pc/acpi.c
+
+kern/i386/pc/acpi_module-acpi.obj: kern/i386/pc/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -MT kern/i386/pc/acpi_module-acpi.obj -MD -MP -MF kern/i386/pc/$(DEPDIR)/acpi_module-acpi.Tpo -c -o kern/i386/pc/acpi_module-acpi.obj `if test -f 'kern/i386/pc/acpi.c'; then $(CYGPATH_W) 'kern/i386/pc/acpi.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/pc/acpi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/pc/$(DEPDIR)/acpi_module-acpi.Tpo kern/i386/pc/$(DEPDIR)/acpi_module-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/pc/acpi.c' object='kern/i386/pc/acpi_module-acpi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $(acpi_module_CFLAGS) $(CFLAGS) -c -o kern/i386/pc/acpi_module-acpi.obj `if test -f 'kern/i386/pc/acpi.c'; then $(CYGPATH_W) 'kern/i386/pc/acpi.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/pc/acpi.c'; fi`
+
+lib/adler32_module-adler32.o: lib/adler32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adler32_module_CPPFLAGS) $(CPPFLAGS) $(adler32_module_CFLAGS) $(CFLAGS) -MT lib/adler32_module-adler32.o -MD -MP -MF lib/$(DEPDIR)/adler32_module-adler32.Tpo -c -o lib/adler32_module-adler32.o `test -f 'lib/adler32.c' || echo '$(srcdir)/'`lib/adler32.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/adler32_module-adler32.Tpo lib/$(DEPDIR)/adler32_module-adler32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/adler32.c' object='lib/adler32_module-adler32.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adler32_module_CPPFLAGS) $(CPPFLAGS) $(adler32_module_CFLAGS) $(CFLAGS) -c -o lib/adler32_module-adler32.o `test -f 'lib/adler32.c' || echo '$(srcdir)/'`lib/adler32.c
+
+lib/adler32_module-adler32.obj: lib/adler32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adler32_module_CPPFLAGS) $(CPPFLAGS) $(adler32_module_CFLAGS) $(CFLAGS) -MT lib/adler32_module-adler32.obj -MD -MP -MF lib/$(DEPDIR)/adler32_module-adler32.Tpo -c -o lib/adler32_module-adler32.obj `if test -f 'lib/adler32.c'; then $(CYGPATH_W) 'lib/adler32.c'; else $(CYGPATH_W) '$(srcdir)/lib/adler32.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/adler32_module-adler32.Tpo lib/$(DEPDIR)/adler32_module-adler32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/adler32.c' object='lib/adler32_module-adler32.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adler32_module_CPPFLAGS) $(CPPFLAGS) $(adler32_module_CFLAGS) $(CFLAGS) -c -o lib/adler32_module-adler32.obj `if test -f 'lib/adler32.c'; then $(CYGPATH_W) 'lib/adler32.c'; else $(CYGPATH_W) '$(srcdir)/lib/adler32.c'; fi`
+
+fs/affs_module-affs.o: fs/affs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(affs_module_CPPFLAGS) $(CPPFLAGS) $(affs_module_CFLAGS) $(CFLAGS) -MT fs/affs_module-affs.o -MD -MP -MF fs/$(DEPDIR)/affs_module-affs.Tpo -c -o fs/affs_module-affs.o `test -f 'fs/affs.c' || echo '$(srcdir)/'`fs/affs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/affs_module-affs.Tpo fs/$(DEPDIR)/affs_module-affs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/affs.c' object='fs/affs_module-affs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(affs_module_CPPFLAGS) $(CPPFLAGS) $(affs_module_CFLAGS) $(CFLAGS) -c -o fs/affs_module-affs.o `test -f 'fs/affs.c' || echo '$(srcdir)/'`fs/affs.c
+
+fs/affs_module-affs.obj: fs/affs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(affs_module_CPPFLAGS) $(CPPFLAGS) $(affs_module_CFLAGS) $(CFLAGS) -MT fs/affs_module-affs.obj -MD -MP -MF fs/$(DEPDIR)/affs_module-affs.Tpo -c -o fs/affs_module-affs.obj `if test -f 'fs/affs.c'; then $(CYGPATH_W) 'fs/affs.c'; else $(CYGPATH_W) '$(srcdir)/fs/affs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/affs_module-affs.Tpo fs/$(DEPDIR)/affs_module-affs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/affs.c' object='fs/affs_module-affs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(affs_module_CPPFLAGS) $(CPPFLAGS) $(affs_module_CFLAGS) $(CFLAGS) -c -o fs/affs_module-affs.obj `if test -f 'fs/affs.c'; then $(CYGPATH_W) 'fs/affs.c'; else $(CYGPATH_W) '$(srcdir)/fs/affs.c'; fi`
+
+fs/afs_module-afs.o: fs/afs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afs_module_CPPFLAGS) $(CPPFLAGS) $(afs_module_CFLAGS) $(CFLAGS) -MT fs/afs_module-afs.o -MD -MP -MF fs/$(DEPDIR)/afs_module-afs.Tpo -c -o fs/afs_module-afs.o `test -f 'fs/afs.c' || echo '$(srcdir)/'`fs/afs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/afs_module-afs.Tpo fs/$(DEPDIR)/afs_module-afs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/afs.c' object='fs/afs_module-afs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afs_module_CPPFLAGS) $(CPPFLAGS) $(afs_module_CFLAGS) $(CFLAGS) -c -o fs/afs_module-afs.o `test -f 'fs/afs.c' || echo '$(srcdir)/'`fs/afs.c
+
+fs/afs_module-afs.obj: fs/afs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afs_module_CPPFLAGS) $(CPPFLAGS) $(afs_module_CFLAGS) $(CFLAGS) -MT fs/afs_module-afs.obj -MD -MP -MF fs/$(DEPDIR)/afs_module-afs.Tpo -c -o fs/afs_module-afs.obj `if test -f 'fs/afs.c'; then $(CYGPATH_W) 'fs/afs.c'; else $(CYGPATH_W) '$(srcdir)/fs/afs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/afs_module-afs.Tpo fs/$(DEPDIR)/afs_module-afs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/afs.c' object='fs/afs_module-afs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afs_module_CPPFLAGS) $(CPPFLAGS) $(afs_module_CFLAGS) $(CFLAGS) -c -o fs/afs_module-afs.obj `if test -f 'fs/afs.c'; then $(CYGPATH_W) 'fs/afs.c'; else $(CYGPATH_W) '$(srcdir)/fs/afs.c'; fi`
+
+disk/afsplitter_module-AFSplitter.o: disk/AFSplitter.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afsplitter_module_CPPFLAGS) $(CPPFLAGS) $(afsplitter_module_CFLAGS) $(CFLAGS) -MT disk/afsplitter_module-AFSplitter.o -MD -MP -MF disk/$(DEPDIR)/afsplitter_module-AFSplitter.Tpo -c -o disk/afsplitter_module-AFSplitter.o `test -f 'disk/AFSplitter.c' || echo '$(srcdir)/'`disk/AFSplitter.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/afsplitter_module-AFSplitter.Tpo disk/$(DEPDIR)/afsplitter_module-AFSplitter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/AFSplitter.c' object='disk/afsplitter_module-AFSplitter.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afsplitter_module_CPPFLAGS) $(CPPFLAGS) $(afsplitter_module_CFLAGS) $(CFLAGS) -c -o disk/afsplitter_module-AFSplitter.o `test -f 'disk/AFSplitter.c' || echo '$(srcdir)/'`disk/AFSplitter.c
+
+disk/afsplitter_module-AFSplitter.obj: disk/AFSplitter.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afsplitter_module_CPPFLAGS) $(CPPFLAGS) $(afsplitter_module_CFLAGS) $(CFLAGS) -MT disk/afsplitter_module-AFSplitter.obj -MD -MP -MF disk/$(DEPDIR)/afsplitter_module-AFSplitter.Tpo -c -o disk/afsplitter_module-AFSplitter.obj `if test -f 'disk/AFSplitter.c'; then $(CYGPATH_W) 'disk/AFSplitter.c'; else $(CYGPATH_W) '$(srcdir)/disk/AFSplitter.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/afsplitter_module-AFSplitter.Tpo disk/$(DEPDIR)/afsplitter_module-AFSplitter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/AFSplitter.c' object='disk/afsplitter_module-AFSplitter.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afsplitter_module_CPPFLAGS) $(CPPFLAGS) $(afsplitter_module_CFLAGS) $(CFLAGS) -c -o disk/afsplitter_module-AFSplitter.obj `if test -f 'disk/AFSplitter.c'; then $(CYGPATH_W) 'disk/AFSplitter.c'; else $(CYGPATH_W) '$(srcdir)/disk/AFSplitter.c'; fi`
+
+disk/ahci_module-ahci.o: disk/ahci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $(ahci_module_CFLAGS) $(CFLAGS) -MT disk/ahci_module-ahci.o -MD -MP -MF disk/$(DEPDIR)/ahci_module-ahci.Tpo -c -o disk/ahci_module-ahci.o `test -f 'disk/ahci.c' || echo '$(srcdir)/'`disk/ahci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/ahci_module-ahci.Tpo disk/$(DEPDIR)/ahci_module-ahci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ahci.c' object='disk/ahci_module-ahci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $(ahci_module_CFLAGS) $(CFLAGS) -c -o disk/ahci_module-ahci.o `test -f 'disk/ahci.c' || echo '$(srcdir)/'`disk/ahci.c
+
+disk/ahci_module-ahci.obj: disk/ahci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $(ahci_module_CFLAGS) $(CFLAGS) -MT disk/ahci_module-ahci.obj -MD -MP -MF disk/$(DEPDIR)/ahci_module-ahci.Tpo -c -o disk/ahci_module-ahci.obj `if test -f 'disk/ahci.c'; then $(CYGPATH_W) 'disk/ahci.c'; else $(CYGPATH_W) '$(srcdir)/disk/ahci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/ahci_module-ahci.Tpo disk/$(DEPDIR)/ahci_module-ahci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ahci.c' object='disk/ahci_module-ahci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $(ahci_module_CFLAGS) $(CFLAGS) -c -o disk/ahci_module-ahci.obj `if test -f 'disk/ahci.c'; then $(CYGPATH_W) 'disk/ahci.c'; else $(CYGPATH_W) '$(srcdir)/disk/ahci.c'; fi`
+
+lib/all_video_module-fake_module.o: lib/fake_module.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(all_video_module_CPPFLAGS) $(CPPFLAGS) $(all_video_module_CFLAGS) $(CFLAGS) -MT lib/all_video_module-fake_module.o -MD -MP -MF lib/$(DEPDIR)/all_video_module-fake_module.Tpo -c -o lib/all_video_module-fake_module.o `test -f 'lib/fake_module.c' || echo '$(srcdir)/'`lib/fake_module.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/all_video_module-fake_module.Tpo lib/$(DEPDIR)/all_video_module-fake_module.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/fake_module.c' object='lib/all_video_module-fake_module.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(all_video_module_CPPFLAGS) $(CPPFLAGS) $(all_video_module_CFLAGS) $(CFLAGS) -c -o lib/all_video_module-fake_module.o `test -f 'lib/fake_module.c' || echo '$(srcdir)/'`lib/fake_module.c
+
+lib/all_video_module-fake_module.obj: lib/fake_module.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(all_video_module_CPPFLAGS) $(CPPFLAGS) $(all_video_module_CFLAGS) $(CFLAGS) -MT lib/all_video_module-fake_module.obj -MD -MP -MF lib/$(DEPDIR)/all_video_module-fake_module.Tpo -c -o lib/all_video_module-fake_module.obj `if test -f 'lib/fake_module.c'; then $(CYGPATH_W) 'lib/fake_module.c'; else $(CYGPATH_W) '$(srcdir)/lib/fake_module.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/all_video_module-fake_module.Tpo lib/$(DEPDIR)/all_video_module-fake_module.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/fake_module.c' object='lib/all_video_module-fake_module.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(all_video_module_CPPFLAGS) $(CPPFLAGS) $(all_video_module_CFLAGS) $(CFLAGS) -c -o lib/all_video_module-fake_module.obj `if test -f 'lib/fake_module.c'; then $(CYGPATH_W) 'lib/fake_module.c'; else $(CYGPATH_W) '$(srcdir)/lib/fake_module.c'; fi`
+
+loader/aout_module-aout.o: loader/aout.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $(aout_module_CFLAGS) $(CFLAGS) -MT loader/aout_module-aout.o -MD -MP -MF loader/$(DEPDIR)/aout_module-aout.Tpo -c -o loader/aout_module-aout.o `test -f 'loader/aout.c' || echo '$(srcdir)/'`loader/aout.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/aout_module-aout.Tpo loader/$(DEPDIR)/aout_module-aout.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/aout.c' object='loader/aout_module-aout.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $(aout_module_CFLAGS) $(CFLAGS) -c -o loader/aout_module-aout.o `test -f 'loader/aout.c' || echo '$(srcdir)/'`loader/aout.c
+
+loader/aout_module-aout.obj: loader/aout.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $(aout_module_CFLAGS) $(CFLAGS) -MT loader/aout_module-aout.obj -MD -MP -MF loader/$(DEPDIR)/aout_module-aout.Tpo -c -o loader/aout_module-aout.obj `if test -f 'loader/aout.c'; then $(CYGPATH_W) 'loader/aout.c'; else $(CYGPATH_W) '$(srcdir)/loader/aout.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/aout_module-aout.Tpo loader/$(DEPDIR)/aout_module-aout.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/aout.c' object='loader/aout_module-aout.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $(aout_module_CFLAGS) $(CFLAGS) -c -o loader/aout_module-aout.obj `if test -f 'loader/aout.c'; then $(CYGPATH_W) 'loader/aout.c'; else $(CYGPATH_W) '$(srcdir)/loader/aout.c'; fi`
+
+loader/efi/appleldr_module-appleloader.o: loader/efi/appleloader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(appleldr_module_CPPFLAGS) $(CPPFLAGS) $(appleldr_module_CFLAGS) $(CFLAGS) -MT loader/efi/appleldr_module-appleloader.o -MD -MP -MF loader/efi/$(DEPDIR)/appleldr_module-appleloader.Tpo -c -o loader/efi/appleldr_module-appleloader.o `test -f 'loader/efi/appleloader.c' || echo '$(srcdir)/'`loader/efi/appleloader.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/efi/$(DEPDIR)/appleldr_module-appleloader.Tpo loader/efi/$(DEPDIR)/appleldr_module-appleloader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/efi/appleloader.c' object='loader/efi/appleldr_module-appleloader.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(appleldr_module_CPPFLAGS) $(CPPFLAGS) $(appleldr_module_CFLAGS) $(CFLAGS) -c -o loader/efi/appleldr_module-appleloader.o `test -f 'loader/efi/appleloader.c' || echo '$(srcdir)/'`loader/efi/appleloader.c
+
+loader/efi/appleldr_module-appleloader.obj: loader/efi/appleloader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(appleldr_module_CPPFLAGS) $(CPPFLAGS) $(appleldr_module_CFLAGS) $(CFLAGS) -MT loader/efi/appleldr_module-appleloader.obj -MD -MP -MF loader/efi/$(DEPDIR)/appleldr_module-appleloader.Tpo -c -o loader/efi/appleldr_module-appleloader.obj `if test -f 'loader/efi/appleloader.c'; then $(CYGPATH_W) 'loader/efi/appleloader.c'; else $(CYGPATH_W) '$(srcdir)/loader/efi/appleloader.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/efi/$(DEPDIR)/appleldr_module-appleloader.Tpo loader/efi/$(DEPDIR)/appleldr_module-appleloader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/efi/appleloader.c' object='loader/efi/appleldr_module-appleloader.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(appleldr_module_CPPFLAGS) $(CPPFLAGS) $(appleldr_module_CFLAGS) $(CFLAGS) -c -o loader/efi/appleldr_module-appleloader.obj `if test -f 'loader/efi/appleloader.c'; then $(CYGPATH_W) 'loader/efi/appleloader.c'; else $(CYGPATH_W) '$(srcdir)/loader/efi/appleloader.c'; fi`
+
+fs/archelp_module-archelp.o: fs/archelp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(archelp_module_CPPFLAGS) $(CPPFLAGS) $(archelp_module_CFLAGS) $(CFLAGS) -MT fs/archelp_module-archelp.o -MD -MP -MF fs/$(DEPDIR)/archelp_module-archelp.Tpo -c -o fs/archelp_module-archelp.o `test -f 'fs/archelp.c' || echo '$(srcdir)/'`fs/archelp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/archelp_module-archelp.Tpo fs/$(DEPDIR)/archelp_module-archelp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/archelp.c' object='fs/archelp_module-archelp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(archelp_module_CPPFLAGS) $(CPPFLAGS) $(archelp_module_CFLAGS) $(CFLAGS) -c -o fs/archelp_module-archelp.o `test -f 'fs/archelp.c' || echo '$(srcdir)/'`fs/archelp.c
+
+fs/archelp_module-archelp.obj: fs/archelp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(archelp_module_CPPFLAGS) $(CPPFLAGS) $(archelp_module_CFLAGS) $(CFLAGS) -MT fs/archelp_module-archelp.obj -MD -MP -MF fs/$(DEPDIR)/archelp_module-archelp.Tpo -c -o fs/archelp_module-archelp.obj `if test -f 'fs/archelp.c'; then $(CYGPATH_W) 'fs/archelp.c'; else $(CYGPATH_W) '$(srcdir)/fs/archelp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/archelp_module-archelp.Tpo fs/$(DEPDIR)/archelp_module-archelp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/archelp.c' object='fs/archelp_module-archelp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(archelp_module_CPPFLAGS) $(CPPFLAGS) $(archelp_module_CFLAGS) $(CFLAGS) -c -o fs/archelp_module-archelp.obj `if test -f 'fs/archelp.c'; then $(CYGPATH_W) 'fs/archelp.c'; else $(CYGPATH_W) '$(srcdir)/fs/archelp.c'; fi`
+
+term/at_keyboard_module-at_keyboard.o: term/at_keyboard.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(at_keyboard_module_CFLAGS) $(CFLAGS) -MT term/at_keyboard_module-at_keyboard.o -MD -MP -MF term/$(DEPDIR)/at_keyboard_module-at_keyboard.Tpo -c -o term/at_keyboard_module-at_keyboard.o `test -f 'term/at_keyboard.c' || echo '$(srcdir)/'`term/at_keyboard.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/at_keyboard_module-at_keyboard.Tpo term/$(DEPDIR)/at_keyboard_module-at_keyboard.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/at_keyboard.c' object='term/at_keyboard_module-at_keyboard.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(at_keyboard_module_CFLAGS) $(CFLAGS) -c -o term/at_keyboard_module-at_keyboard.o `test -f 'term/at_keyboard.c' || echo '$(srcdir)/'`term/at_keyboard.c
+
+term/at_keyboard_module-at_keyboard.obj: term/at_keyboard.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(at_keyboard_module_CFLAGS) $(CFLAGS) -MT term/at_keyboard_module-at_keyboard.obj -MD -MP -MF term/$(DEPDIR)/at_keyboard_module-at_keyboard.Tpo -c -o term/at_keyboard_module-at_keyboard.obj `if test -f 'term/at_keyboard.c'; then $(CYGPATH_W) 'term/at_keyboard.c'; else $(CYGPATH_W) '$(srcdir)/term/at_keyboard.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/at_keyboard_module-at_keyboard.Tpo term/$(DEPDIR)/at_keyboard_module-at_keyboard.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/at_keyboard.c' object='term/at_keyboard_module-at_keyboard.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(at_keyboard_module_CFLAGS) $(CFLAGS) -c -o term/at_keyboard_module-at_keyboard.obj `if test -f 'term/at_keyboard.c'; then $(CYGPATH_W) 'term/at_keyboard.c'; else $(CYGPATH_W) '$(srcdir)/term/at_keyboard.c'; fi`
+
+term/at_keyboard_module-ps2.o: term/ps2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(at_keyboard_module_CFLAGS) $(CFLAGS) -MT term/at_keyboard_module-ps2.o -MD -MP -MF term/$(DEPDIR)/at_keyboard_module-ps2.Tpo -c -o term/at_keyboard_module-ps2.o `test -f 'term/ps2.c' || echo '$(srcdir)/'`term/ps2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/at_keyboard_module-ps2.Tpo term/$(DEPDIR)/at_keyboard_module-ps2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ps2.c' object='term/at_keyboard_module-ps2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(at_keyboard_module_CFLAGS) $(CFLAGS) -c -o term/at_keyboard_module-ps2.o `test -f 'term/ps2.c' || echo '$(srcdir)/'`term/ps2.c
+
+term/at_keyboard_module-ps2.obj: term/ps2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(at_keyboard_module_CFLAGS) $(CFLAGS) -MT term/at_keyboard_module-ps2.obj -MD -MP -MF term/$(DEPDIR)/at_keyboard_module-ps2.Tpo -c -o term/at_keyboard_module-ps2.obj `if test -f 'term/ps2.c'; then $(CYGPATH_W) 'term/ps2.c'; else $(CYGPATH_W) '$(srcdir)/term/ps2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/at_keyboard_module-ps2.Tpo term/$(DEPDIR)/at_keyboard_module-ps2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ps2.c' object='term/at_keyboard_module-ps2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(at_keyboard_module_CFLAGS) $(CFLAGS) -c -o term/at_keyboard_module-ps2.obj `if test -f 'term/ps2.c'; then $(CYGPATH_W) 'term/ps2.c'; else $(CYGPATH_W) '$(srcdir)/term/ps2.c'; fi`
+
+disk/ata_module-ata.o: disk/ata.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $(ata_module_CFLAGS) $(CFLAGS) -MT disk/ata_module-ata.o -MD -MP -MF disk/$(DEPDIR)/ata_module-ata.Tpo -c -o disk/ata_module-ata.o `test -f 'disk/ata.c' || echo '$(srcdir)/'`disk/ata.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/ata_module-ata.Tpo disk/$(DEPDIR)/ata_module-ata.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ata.c' object='disk/ata_module-ata.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $(ata_module_CFLAGS) $(CFLAGS) -c -o disk/ata_module-ata.o `test -f 'disk/ata.c' || echo '$(srcdir)/'`disk/ata.c
+
+disk/ata_module-ata.obj: disk/ata.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $(ata_module_CFLAGS) $(CFLAGS) -MT disk/ata_module-ata.obj -MD -MP -MF disk/$(DEPDIR)/ata_module-ata.Tpo -c -o disk/ata_module-ata.obj `if test -f 'disk/ata.c'; then $(CYGPATH_W) 'disk/ata.c'; else $(CYGPATH_W) '$(srcdir)/disk/ata.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/ata_module-ata.Tpo disk/$(DEPDIR)/ata_module-ata.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ata.c' object='disk/ata_module-ata.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $(ata_module_CFLAGS) $(CFLAGS) -c -o disk/ata_module-ata.obj `if test -f 'disk/ata.c'; then $(CYGPATH_W) 'disk/ata.c'; else $(CYGPATH_W) '$(srcdir)/disk/ata.c'; fi`
+
+lib/i386/backtrace_module-backtrace.o: lib/i386/backtrace.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $(backtrace_module_CFLAGS) $(CFLAGS) -MT lib/i386/backtrace_module-backtrace.o -MD -MP -MF lib/i386/$(DEPDIR)/backtrace_module-backtrace.Tpo -c -o lib/i386/backtrace_module-backtrace.o `test -f 'lib/i386/backtrace.c' || echo '$(srcdir)/'`lib/i386/backtrace.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/backtrace_module-backtrace.Tpo lib/i386/$(DEPDIR)/backtrace_module-backtrace.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/backtrace.c' object='lib/i386/backtrace_module-backtrace.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $(backtrace_module_CFLAGS) $(CFLAGS) -c -o lib/i386/backtrace_module-backtrace.o `test -f 'lib/i386/backtrace.c' || echo '$(srcdir)/'`lib/i386/backtrace.c
+
+lib/i386/backtrace_module-backtrace.obj: lib/i386/backtrace.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $(backtrace_module_CFLAGS) $(CFLAGS) -MT lib/i386/backtrace_module-backtrace.obj -MD -MP -MF lib/i386/$(DEPDIR)/backtrace_module-backtrace.Tpo -c -o lib/i386/backtrace_module-backtrace.obj `if test -f 'lib/i386/backtrace.c'; then $(CYGPATH_W) 'lib/i386/backtrace.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/backtrace.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/backtrace_module-backtrace.Tpo lib/i386/$(DEPDIR)/backtrace_module-backtrace.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/backtrace.c' object='lib/i386/backtrace_module-backtrace.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $(backtrace_module_CFLAGS) $(CFLAGS) -c -o lib/i386/backtrace_module-backtrace.obj `if test -f 'lib/i386/backtrace.c'; then $(CYGPATH_W) 'lib/i386/backtrace.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/backtrace.c'; fi`
+
+lib/backtrace_module-backtrace.o: lib/backtrace.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $(backtrace_module_CFLAGS) $(CFLAGS) -MT lib/backtrace_module-backtrace.o -MD -MP -MF lib/$(DEPDIR)/backtrace_module-backtrace.Tpo -c -o lib/backtrace_module-backtrace.o `test -f 'lib/backtrace.c' || echo '$(srcdir)/'`lib/backtrace.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/backtrace_module-backtrace.Tpo lib/$(DEPDIR)/backtrace_module-backtrace.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/backtrace.c' object='lib/backtrace_module-backtrace.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $(backtrace_module_CFLAGS) $(CFLAGS) -c -o lib/backtrace_module-backtrace.o `test -f 'lib/backtrace.c' || echo '$(srcdir)/'`lib/backtrace.c
+
+lib/backtrace_module-backtrace.obj: lib/backtrace.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $(backtrace_module_CFLAGS) $(CFLAGS) -MT lib/backtrace_module-backtrace.obj -MD -MP -MF lib/$(DEPDIR)/backtrace_module-backtrace.Tpo -c -o lib/backtrace_module-backtrace.obj `if test -f 'lib/backtrace.c'; then $(CYGPATH_W) 'lib/backtrace.c'; else $(CYGPATH_W) '$(srcdir)/lib/backtrace.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/backtrace_module-backtrace.Tpo lib/$(DEPDIR)/backtrace_module-backtrace.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/backtrace.c' object='lib/backtrace_module-backtrace.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $(backtrace_module_CFLAGS) $(CFLAGS) -c -o lib/backtrace_module-backtrace.obj `if test -f 'lib/backtrace.c'; then $(CYGPATH_W) 'lib/backtrace.c'; else $(CYGPATH_W) '$(srcdir)/lib/backtrace.c'; fi`
+
+fs/bfs_module-bfs.o: fs/bfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bfs_module_CPPFLAGS) $(CPPFLAGS) $(bfs_module_CFLAGS) $(CFLAGS) -MT fs/bfs_module-bfs.o -MD -MP -MF fs/$(DEPDIR)/bfs_module-bfs.Tpo -c -o fs/bfs_module-bfs.o `test -f 'fs/bfs.c' || echo '$(srcdir)/'`fs/bfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/bfs_module-bfs.Tpo fs/$(DEPDIR)/bfs_module-bfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/bfs.c' object='fs/bfs_module-bfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bfs_module_CPPFLAGS) $(CPPFLAGS) $(bfs_module_CFLAGS) $(CFLAGS) -c -o fs/bfs_module-bfs.o `test -f 'fs/bfs.c' || echo '$(srcdir)/'`fs/bfs.c
+
+fs/bfs_module-bfs.obj: fs/bfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bfs_module_CPPFLAGS) $(CPPFLAGS) $(bfs_module_CFLAGS) $(CFLAGS) -MT fs/bfs_module-bfs.obj -MD -MP -MF fs/$(DEPDIR)/bfs_module-bfs.Tpo -c -o fs/bfs_module-bfs.obj `if test -f 'fs/bfs.c'; then $(CYGPATH_W) 'fs/bfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/bfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/bfs_module-bfs.Tpo fs/$(DEPDIR)/bfs_module-bfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/bfs.c' object='fs/bfs_module-bfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bfs_module_CPPFLAGS) $(CPPFLAGS) $(bfs_module_CFLAGS) $(CFLAGS) -c -o fs/bfs_module-bfs.obj `if test -f 'fs/bfs.c'; then $(CYGPATH_W) 'fs/bfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/bfs.c'; fi`
+
+disk/i386/pc/biosdisk_module-biosdisk.o: disk/i386/pc/biosdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(biosdisk_module_CPPFLAGS) $(CPPFLAGS) $(biosdisk_module_CFLAGS) $(CFLAGS) -MT disk/i386/pc/biosdisk_module-biosdisk.o -MD -MP -MF disk/i386/pc/$(DEPDIR)/biosdisk_module-biosdisk.Tpo -c -o disk/i386/pc/biosdisk_module-biosdisk.o `test -f 'disk/i386/pc/biosdisk.c' || echo '$(srcdir)/'`disk/i386/pc/biosdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/i386/pc/$(DEPDIR)/biosdisk_module-biosdisk.Tpo disk/i386/pc/$(DEPDIR)/biosdisk_module-biosdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/i386/pc/biosdisk.c' object='disk/i386/pc/biosdisk_module-biosdisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(biosdisk_module_CPPFLAGS) $(CPPFLAGS) $(biosdisk_module_CFLAGS) $(CFLAGS) -c -o disk/i386/pc/biosdisk_module-biosdisk.o `test -f 'disk/i386/pc/biosdisk.c' || echo '$(srcdir)/'`disk/i386/pc/biosdisk.c
+
+disk/i386/pc/biosdisk_module-biosdisk.obj: disk/i386/pc/biosdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(biosdisk_module_CPPFLAGS) $(CPPFLAGS) $(biosdisk_module_CFLAGS) $(CFLAGS) -MT disk/i386/pc/biosdisk_module-biosdisk.obj -MD -MP -MF disk/i386/pc/$(DEPDIR)/biosdisk_module-biosdisk.Tpo -c -o disk/i386/pc/biosdisk_module-biosdisk.obj `if test -f 'disk/i386/pc/biosdisk.c'; then $(CYGPATH_W) 'disk/i386/pc/biosdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/i386/pc/biosdisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/i386/pc/$(DEPDIR)/biosdisk_module-biosdisk.Tpo disk/i386/pc/$(DEPDIR)/biosdisk_module-biosdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/i386/pc/biosdisk.c' object='disk/i386/pc/biosdisk_module-biosdisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(biosdisk_module_CPPFLAGS) $(CPPFLAGS) $(biosdisk_module_CFLAGS) $(CFLAGS) -c -o disk/i386/pc/biosdisk_module-biosdisk.obj `if test -f 'disk/i386/pc/biosdisk.c'; then $(CYGPATH_W) 'disk/i386/pc/biosdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/i386/pc/biosdisk.c'; fi`
+
+video/bitmap_module-bitmap.o: video/bitmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_module_CPPFLAGS) $(CPPFLAGS) $(bitmap_module_CFLAGS) $(CFLAGS) -MT video/bitmap_module-bitmap.o -MD -MP -MF video/$(DEPDIR)/bitmap_module-bitmap.Tpo -c -o video/bitmap_module-bitmap.o `test -f 'video/bitmap.c' || echo '$(srcdir)/'`video/bitmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/bitmap_module-bitmap.Tpo video/$(DEPDIR)/bitmap_module-bitmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/bitmap.c' object='video/bitmap_module-bitmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_module_CPPFLAGS) $(CPPFLAGS) $(bitmap_module_CFLAGS) $(CFLAGS) -c -o video/bitmap_module-bitmap.o `test -f 'video/bitmap.c' || echo '$(srcdir)/'`video/bitmap.c
+
+video/bitmap_module-bitmap.obj: video/bitmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_module_CPPFLAGS) $(CPPFLAGS) $(bitmap_module_CFLAGS) $(CFLAGS) -MT video/bitmap_module-bitmap.obj -MD -MP -MF video/$(DEPDIR)/bitmap_module-bitmap.Tpo -c -o video/bitmap_module-bitmap.obj `if test -f 'video/bitmap.c'; then $(CYGPATH_W) 'video/bitmap.c'; else $(CYGPATH_W) '$(srcdir)/video/bitmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/bitmap_module-bitmap.Tpo video/$(DEPDIR)/bitmap_module-bitmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/bitmap.c' object='video/bitmap_module-bitmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_module_CPPFLAGS) $(CPPFLAGS) $(bitmap_module_CFLAGS) $(CFLAGS) -c -o video/bitmap_module-bitmap.obj `if test -f 'video/bitmap.c'; then $(CYGPATH_W) 'video/bitmap.c'; else $(CYGPATH_W) '$(srcdir)/video/bitmap.c'; fi`
+
+video/bitmap_scale_module-bitmap_scale.o: video/bitmap_scale.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_scale_module_CPPFLAGS) $(CPPFLAGS) $(bitmap_scale_module_CFLAGS) $(CFLAGS) -MT video/bitmap_scale_module-bitmap_scale.o -MD -MP -MF video/$(DEPDIR)/bitmap_scale_module-bitmap_scale.Tpo -c -o video/bitmap_scale_module-bitmap_scale.o `test -f 'video/bitmap_scale.c' || echo '$(srcdir)/'`video/bitmap_scale.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/bitmap_scale_module-bitmap_scale.Tpo video/$(DEPDIR)/bitmap_scale_module-bitmap_scale.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/bitmap_scale.c' object='video/bitmap_scale_module-bitmap_scale.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_scale_module_CPPFLAGS) $(CPPFLAGS) $(bitmap_scale_module_CFLAGS) $(CFLAGS) -c -o video/bitmap_scale_module-bitmap_scale.o `test -f 'video/bitmap_scale.c' || echo '$(srcdir)/'`video/bitmap_scale.c
+
+video/bitmap_scale_module-bitmap_scale.obj: video/bitmap_scale.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_scale_module_CPPFLAGS) $(CPPFLAGS) $(bitmap_scale_module_CFLAGS) $(CFLAGS) -MT video/bitmap_scale_module-bitmap_scale.obj -MD -MP -MF video/$(DEPDIR)/bitmap_scale_module-bitmap_scale.Tpo -c -o video/bitmap_scale_module-bitmap_scale.obj `if test -f 'video/bitmap_scale.c'; then $(CYGPATH_W) 'video/bitmap_scale.c'; else $(CYGPATH_W) '$(srcdir)/video/bitmap_scale.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/bitmap_scale_module-bitmap_scale.Tpo video/$(DEPDIR)/bitmap_scale_module-bitmap_scale.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/bitmap_scale.c' object='video/bitmap_scale_module-bitmap_scale.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_scale_module_CPPFLAGS) $(CPPFLAGS) $(bitmap_scale_module_CFLAGS) $(CFLAGS) -c -o video/bitmap_scale_module-bitmap_scale.obj `if test -f 'video/bitmap_scale.c'; then $(CYGPATH_W) 'video/bitmap_scale.c'; else $(CYGPATH_W) '$(srcdir)/video/bitmap_scale.c'; fi`
+
+commands/blocklist_module-blocklist.o: commands/blocklist.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(blocklist_module_CPPFLAGS) $(CPPFLAGS) $(blocklist_module_CFLAGS) $(CFLAGS) -MT commands/blocklist_module-blocklist.o -MD -MP -MF commands/$(DEPDIR)/blocklist_module-blocklist.Tpo -c -o commands/blocklist_module-blocklist.o `test -f 'commands/blocklist.c' || echo '$(srcdir)/'`commands/blocklist.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/blocklist_module-blocklist.Tpo commands/$(DEPDIR)/blocklist_module-blocklist.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/blocklist.c' object='commands/blocklist_module-blocklist.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(blocklist_module_CPPFLAGS) $(CPPFLAGS) $(blocklist_module_CFLAGS) $(CFLAGS) -c -o commands/blocklist_module-blocklist.o `test -f 'commands/blocklist.c' || echo '$(srcdir)/'`commands/blocklist.c
+
+commands/blocklist_module-blocklist.obj: commands/blocklist.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(blocklist_module_CPPFLAGS) $(CPPFLAGS) $(blocklist_module_CFLAGS) $(CFLAGS) -MT commands/blocklist_module-blocklist.obj -MD -MP -MF commands/$(DEPDIR)/blocklist_module-blocklist.Tpo -c -o commands/blocklist_module-blocklist.obj `if test -f 'commands/blocklist.c'; then $(CYGPATH_W) 'commands/blocklist.c'; else $(CYGPATH_W) '$(srcdir)/commands/blocklist.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/blocklist_module-blocklist.Tpo commands/$(DEPDIR)/blocklist_module-blocklist.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/blocklist.c' object='commands/blocklist_module-blocklist.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(blocklist_module_CPPFLAGS) $(CPPFLAGS) $(blocklist_module_CFLAGS) $(CFLAGS) -c -o commands/blocklist_module-blocklist.obj `if test -f 'commands/blocklist.c'; then $(CYGPATH_W) 'commands/blocklist.c'; else $(CYGPATH_W) '$(srcdir)/commands/blocklist.c'; fi`
+
+commands/boot_module-boot.o: commands/boot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $(boot_module_CFLAGS) $(CFLAGS) -MT commands/boot_module-boot.o -MD -MP -MF commands/$(DEPDIR)/boot_module-boot.Tpo -c -o commands/boot_module-boot.o `test -f 'commands/boot.c' || echo '$(srcdir)/'`commands/boot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/boot_module-boot.Tpo commands/$(DEPDIR)/boot_module-boot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/boot.c' object='commands/boot_module-boot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $(boot_module_CFLAGS) $(CFLAGS) -c -o commands/boot_module-boot.o `test -f 'commands/boot.c' || echo '$(srcdir)/'`commands/boot.c
+
+commands/boot_module-boot.obj: commands/boot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $(boot_module_CFLAGS) $(CFLAGS) -MT commands/boot_module-boot.obj -MD -MP -MF commands/$(DEPDIR)/boot_module-boot.Tpo -c -o commands/boot_module-boot.obj `if test -f 'commands/boot.c'; then $(CYGPATH_W) 'commands/boot.c'; else $(CYGPATH_W) '$(srcdir)/commands/boot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/boot_module-boot.Tpo commands/$(DEPDIR)/boot_module-boot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/boot.c' object='commands/boot_module-boot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $(boot_module_CFLAGS) $(CFLAGS) -c -o commands/boot_module-boot.obj `if test -f 'commands/boot.c'; then $(CYGPATH_W) 'commands/boot.c'; else $(CYGPATH_W) '$(srcdir)/commands/boot.c'; fi`
+
+lib/i386/pc/boot_module-biosnum.o: lib/i386/pc/biosnum.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $(boot_module_CFLAGS) $(CFLAGS) -MT lib/i386/pc/boot_module-biosnum.o -MD -MP -MF lib/i386/pc/$(DEPDIR)/boot_module-biosnum.Tpo -c -o lib/i386/pc/boot_module-biosnum.o `test -f 'lib/i386/pc/biosnum.c' || echo '$(srcdir)/'`lib/i386/pc/biosnum.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/pc/$(DEPDIR)/boot_module-biosnum.Tpo lib/i386/pc/$(DEPDIR)/boot_module-biosnum.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/pc/biosnum.c' object='lib/i386/pc/boot_module-biosnum.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $(boot_module_CFLAGS) $(CFLAGS) -c -o lib/i386/pc/boot_module-biosnum.o `test -f 'lib/i386/pc/biosnum.c' || echo '$(srcdir)/'`lib/i386/pc/biosnum.c
+
+lib/i386/pc/boot_module-biosnum.obj: lib/i386/pc/biosnum.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $(boot_module_CFLAGS) $(CFLAGS) -MT lib/i386/pc/boot_module-biosnum.obj -MD -MP -MF lib/i386/pc/$(DEPDIR)/boot_module-biosnum.Tpo -c -o lib/i386/pc/boot_module-biosnum.obj `if test -f 'lib/i386/pc/biosnum.c'; then $(CYGPATH_W) 'lib/i386/pc/biosnum.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/pc/biosnum.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/pc/$(DEPDIR)/boot_module-biosnum.Tpo lib/i386/pc/$(DEPDIR)/boot_module-biosnum.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/pc/biosnum.c' object='lib/i386/pc/boot_module-biosnum.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $(boot_module_CFLAGS) $(CFLAGS) -c -o lib/i386/pc/boot_module-biosnum.obj `if test -f 'lib/i386/pc/biosnum.c'; then $(CYGPATH_W) 'lib/i386/pc/biosnum.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/pc/biosnum.c'; fi`
+
+commands/boottime_module-boottime.o: commands/boottime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boottime_module_CPPFLAGS) $(CPPFLAGS) $(boottime_module_CFLAGS) $(CFLAGS) -MT commands/boottime_module-boottime.o -MD -MP -MF commands/$(DEPDIR)/boottime_module-boottime.Tpo -c -o commands/boottime_module-boottime.o `test -f 'commands/boottime.c' || echo '$(srcdir)/'`commands/boottime.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/boottime_module-boottime.Tpo commands/$(DEPDIR)/boottime_module-boottime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/boottime.c' object='commands/boottime_module-boottime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boottime_module_CPPFLAGS) $(CPPFLAGS) $(boottime_module_CFLAGS) $(CFLAGS) -c -o commands/boottime_module-boottime.o `test -f 'commands/boottime.c' || echo '$(srcdir)/'`commands/boottime.c
+
+commands/boottime_module-boottime.obj: commands/boottime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boottime_module_CPPFLAGS) $(CPPFLAGS) $(boottime_module_CFLAGS) $(CFLAGS) -MT commands/boottime_module-boottime.obj -MD -MP -MF commands/$(DEPDIR)/boottime_module-boottime.Tpo -c -o commands/boottime_module-boottime.obj `if test -f 'commands/boottime.c'; then $(CYGPATH_W) 'commands/boottime.c'; else $(CYGPATH_W) '$(srcdir)/commands/boottime.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/boottime_module-boottime.Tpo commands/$(DEPDIR)/boottime_module-boottime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/boottime.c' object='commands/boottime_module-boottime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boottime_module_CPPFLAGS) $(CPPFLAGS) $(boottime_module_CFLAGS) $(CFLAGS) -c -o commands/boottime_module-boottime.obj `if test -f 'commands/boottime.c'; then $(CYGPATH_W) 'commands/boottime.c'; else $(CYGPATH_W) '$(srcdir)/commands/boottime.c'; fi`
+
+loader/i386/bsd_module-bsd.o: loader/i386/bsd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -MT loader/i386/bsd_module-bsd.o -MD -MP -MF loader/i386/$(DEPDIR)/bsd_module-bsd.Tpo -c -o loader/i386/bsd_module-bsd.o `test -f 'loader/i386/bsd.c' || echo '$(srcdir)/'`loader/i386/bsd.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/bsd_module-bsd.Tpo loader/i386/$(DEPDIR)/bsd_module-bsd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/bsd.c' object='loader/i386/bsd_module-bsd.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -c -o loader/i386/bsd_module-bsd.o `test -f 'loader/i386/bsd.c' || echo '$(srcdir)/'`loader/i386/bsd.c
+
+loader/i386/bsd_module-bsd.obj: loader/i386/bsd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -MT loader/i386/bsd_module-bsd.obj -MD -MP -MF loader/i386/$(DEPDIR)/bsd_module-bsd.Tpo -c -o loader/i386/bsd_module-bsd.obj `if test -f 'loader/i386/bsd.c'; then $(CYGPATH_W) 'loader/i386/bsd.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/bsd.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/bsd_module-bsd.Tpo loader/i386/$(DEPDIR)/bsd_module-bsd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/bsd.c' object='loader/i386/bsd_module-bsd.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -c -o loader/i386/bsd_module-bsd.obj `if test -f 'loader/i386/bsd.c'; then $(CYGPATH_W) 'loader/i386/bsd.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/bsd.c'; fi`
+
+loader/i386/bsd_module-bsd32.o: loader/i386/bsd32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -MT loader/i386/bsd_module-bsd32.o -MD -MP -MF loader/i386/$(DEPDIR)/bsd_module-bsd32.Tpo -c -o loader/i386/bsd_module-bsd32.o `test -f 'loader/i386/bsd32.c' || echo '$(srcdir)/'`loader/i386/bsd32.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/bsd_module-bsd32.Tpo loader/i386/$(DEPDIR)/bsd_module-bsd32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/bsd32.c' object='loader/i386/bsd_module-bsd32.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -c -o loader/i386/bsd_module-bsd32.o `test -f 'loader/i386/bsd32.c' || echo '$(srcdir)/'`loader/i386/bsd32.c
+
+loader/i386/bsd_module-bsd32.obj: loader/i386/bsd32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -MT loader/i386/bsd_module-bsd32.obj -MD -MP -MF loader/i386/$(DEPDIR)/bsd_module-bsd32.Tpo -c -o loader/i386/bsd_module-bsd32.obj `if test -f 'loader/i386/bsd32.c'; then $(CYGPATH_W) 'loader/i386/bsd32.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/bsd32.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/bsd_module-bsd32.Tpo loader/i386/$(DEPDIR)/bsd_module-bsd32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/bsd32.c' object='loader/i386/bsd_module-bsd32.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -c -o loader/i386/bsd_module-bsd32.obj `if test -f 'loader/i386/bsd32.c'; then $(CYGPATH_W) 'loader/i386/bsd32.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/bsd32.c'; fi`
+
+loader/i386/bsd_module-bsd64.o: loader/i386/bsd64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -MT loader/i386/bsd_module-bsd64.o -MD -MP -MF loader/i386/$(DEPDIR)/bsd_module-bsd64.Tpo -c -o loader/i386/bsd_module-bsd64.o `test -f 'loader/i386/bsd64.c' || echo '$(srcdir)/'`loader/i386/bsd64.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/bsd_module-bsd64.Tpo loader/i386/$(DEPDIR)/bsd_module-bsd64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/bsd64.c' object='loader/i386/bsd_module-bsd64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -c -o loader/i386/bsd_module-bsd64.o `test -f 'loader/i386/bsd64.c' || echo '$(srcdir)/'`loader/i386/bsd64.c
+
+loader/i386/bsd_module-bsd64.obj: loader/i386/bsd64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -MT loader/i386/bsd_module-bsd64.obj -MD -MP -MF loader/i386/$(DEPDIR)/bsd_module-bsd64.Tpo -c -o loader/i386/bsd_module-bsd64.obj `if test -f 'loader/i386/bsd64.c'; then $(CYGPATH_W) 'loader/i386/bsd64.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/bsd64.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/bsd_module-bsd64.Tpo loader/i386/$(DEPDIR)/bsd_module-bsd64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/bsd64.c' object='loader/i386/bsd_module-bsd64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $(bsd_module_CFLAGS) $(CFLAGS) -c -o loader/i386/bsd_module-bsd64.obj `if test -f 'loader/i386/bsd64.c'; then $(CYGPATH_W) 'loader/i386/bsd64.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/bsd64.c'; fi`
+
+tests/bswap_test_module-bswap_test.o: tests/bswap_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bswap_test_module_CPPFLAGS) $(CPPFLAGS) $(bswap_test_module_CFLAGS) $(CFLAGS) -MT tests/bswap_test_module-bswap_test.o -MD -MP -MF tests/$(DEPDIR)/bswap_test_module-bswap_test.Tpo -c -o tests/bswap_test_module-bswap_test.o `test -f 'tests/bswap_test.c' || echo '$(srcdir)/'`tests/bswap_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/bswap_test_module-bswap_test.Tpo tests/$(DEPDIR)/bswap_test_module-bswap_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/bswap_test.c' object='tests/bswap_test_module-bswap_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bswap_test_module_CPPFLAGS) $(CPPFLAGS) $(bswap_test_module_CFLAGS) $(CFLAGS) -c -o tests/bswap_test_module-bswap_test.o `test -f 'tests/bswap_test.c' || echo '$(srcdir)/'`tests/bswap_test.c
+
+tests/bswap_test_module-bswap_test.obj: tests/bswap_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bswap_test_module_CPPFLAGS) $(CPPFLAGS) $(bswap_test_module_CFLAGS) $(CFLAGS) -MT tests/bswap_test_module-bswap_test.obj -MD -MP -MF tests/$(DEPDIR)/bswap_test_module-bswap_test.Tpo -c -o tests/bswap_test_module-bswap_test.obj `if test -f 'tests/bswap_test.c'; then $(CYGPATH_W) 'tests/bswap_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/bswap_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/bswap_test_module-bswap_test.Tpo tests/$(DEPDIR)/bswap_test_module-bswap_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/bswap_test.c' object='tests/bswap_test_module-bswap_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bswap_test_module_CPPFLAGS) $(CPPFLAGS) $(bswap_test_module_CFLAGS) $(CFLAGS) -c -o tests/bswap_test_module-bswap_test.obj `if test -f 'tests/bswap_test.c'; then $(CYGPATH_W) 'tests/bswap_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/bswap_test.c'; fi`
+
+fs/btrfs_module-btrfs.o: fs/btrfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(btrfs_module_CPPFLAGS) $(CPPFLAGS) $(btrfs_module_CFLAGS) $(CFLAGS) -MT fs/btrfs_module-btrfs.o -MD -MP -MF fs/$(DEPDIR)/btrfs_module-btrfs.Tpo -c -o fs/btrfs_module-btrfs.o `test -f 'fs/btrfs.c' || echo '$(srcdir)/'`fs/btrfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/btrfs_module-btrfs.Tpo fs/$(DEPDIR)/btrfs_module-btrfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/btrfs.c' object='fs/btrfs_module-btrfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(btrfs_module_CPPFLAGS) $(CPPFLAGS) $(btrfs_module_CFLAGS) $(CFLAGS) -c -o fs/btrfs_module-btrfs.o `test -f 'fs/btrfs.c' || echo '$(srcdir)/'`fs/btrfs.c
+
+fs/btrfs_module-btrfs.obj: fs/btrfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(btrfs_module_CPPFLAGS) $(CPPFLAGS) $(btrfs_module_CFLAGS) $(CFLAGS) -MT fs/btrfs_module-btrfs.obj -MD -MP -MF fs/$(DEPDIR)/btrfs_module-btrfs.Tpo -c -o fs/btrfs_module-btrfs.obj `if test -f 'fs/btrfs.c'; then $(CYGPATH_W) 'fs/btrfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/btrfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/btrfs_module-btrfs.Tpo fs/$(DEPDIR)/btrfs_module-btrfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/btrfs.c' object='fs/btrfs_module-btrfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(btrfs_module_CPPFLAGS) $(CPPFLAGS) $(btrfs_module_CFLAGS) $(CFLAGS) -c -o fs/btrfs_module-btrfs.obj `if test -f 'fs/btrfs.c'; then $(CYGPATH_W) 'fs/btrfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/btrfs.c'; fi`
+
+lib/btrfs_module-crc.o: lib/crc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(btrfs_module_CPPFLAGS) $(CPPFLAGS) $(btrfs_module_CFLAGS) $(CFLAGS) -MT lib/btrfs_module-crc.o -MD -MP -MF lib/$(DEPDIR)/btrfs_module-crc.Tpo -c -o lib/btrfs_module-crc.o `test -f 'lib/crc.c' || echo '$(srcdir)/'`lib/crc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/btrfs_module-crc.Tpo lib/$(DEPDIR)/btrfs_module-crc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/crc.c' object='lib/btrfs_module-crc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(btrfs_module_CPPFLAGS) $(CPPFLAGS) $(btrfs_module_CFLAGS) $(CFLAGS) -c -o lib/btrfs_module-crc.o `test -f 'lib/crc.c' || echo '$(srcdir)/'`lib/crc.c
+
+lib/btrfs_module-crc.obj: lib/crc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(btrfs_module_CPPFLAGS) $(CPPFLAGS) $(btrfs_module_CFLAGS) $(CFLAGS) -MT lib/btrfs_module-crc.obj -MD -MP -MF lib/$(DEPDIR)/btrfs_module-crc.Tpo -c -o lib/btrfs_module-crc.obj `if test -f 'lib/crc.c'; then $(CYGPATH_W) 'lib/crc.c'; else $(CYGPATH_W) '$(srcdir)/lib/crc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/btrfs_module-crc.Tpo lib/$(DEPDIR)/btrfs_module-crc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/crc.c' object='lib/btrfs_module-crc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(btrfs_module_CPPFLAGS) $(CPPFLAGS) $(btrfs_module_CFLAGS) $(CFLAGS) -c -o lib/btrfs_module-crc.obj `if test -f 'lib/crc.c'; then $(CYGPATH_W) 'lib/crc.c'; else $(CYGPATH_W) '$(srcdir)/lib/crc.c'; fi`
+
+io/bufio_module-bufio.o: io/bufio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $(bufio_module_CFLAGS) $(CFLAGS) -MT io/bufio_module-bufio.o -MD -MP -MF io/$(DEPDIR)/bufio_module-bufio.Tpo -c -o io/bufio_module-bufio.o `test -f 'io/bufio.c' || echo '$(srcdir)/'`io/bufio.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/bufio_module-bufio.Tpo io/$(DEPDIR)/bufio_module-bufio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/bufio.c' object='io/bufio_module-bufio.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $(bufio_module_CFLAGS) $(CFLAGS) -c -o io/bufio_module-bufio.o `test -f 'io/bufio.c' || echo '$(srcdir)/'`io/bufio.c
+
+io/bufio_module-bufio.obj: io/bufio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $(bufio_module_CFLAGS) $(CFLAGS) -MT io/bufio_module-bufio.obj -MD -MP -MF io/$(DEPDIR)/bufio_module-bufio.Tpo -c -o io/bufio_module-bufio.obj `if test -f 'io/bufio.c'; then $(CYGPATH_W) 'io/bufio.c'; else $(CYGPATH_W) '$(srcdir)/io/bufio.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/bufio_module-bufio.Tpo io/$(DEPDIR)/bufio_module-bufio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/bufio.c' object='io/bufio_module-bufio.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $(bufio_module_CFLAGS) $(CFLAGS) -c -o io/bufio_module-bufio.obj `if test -f 'io/bufio.c'; then $(CYGPATH_W) 'io/bufio.c'; else $(CYGPATH_W) '$(srcdir)/io/bufio.c'; fi`
+
+commands/cacheinfo_module-cacheinfo.o: commands/cacheinfo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cacheinfo_module_CPPFLAGS) $(CPPFLAGS) $(cacheinfo_module_CFLAGS) $(CFLAGS) -MT commands/cacheinfo_module-cacheinfo.o -MD -MP -MF commands/$(DEPDIR)/cacheinfo_module-cacheinfo.Tpo -c -o commands/cacheinfo_module-cacheinfo.o `test -f 'commands/cacheinfo.c' || echo '$(srcdir)/'`commands/cacheinfo.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/cacheinfo_module-cacheinfo.Tpo commands/$(DEPDIR)/cacheinfo_module-cacheinfo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/cacheinfo.c' object='commands/cacheinfo_module-cacheinfo.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cacheinfo_module_CPPFLAGS) $(CPPFLAGS) $(cacheinfo_module_CFLAGS) $(CFLAGS) -c -o commands/cacheinfo_module-cacheinfo.o `test -f 'commands/cacheinfo.c' || echo '$(srcdir)/'`commands/cacheinfo.c
+
+commands/cacheinfo_module-cacheinfo.obj: commands/cacheinfo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cacheinfo_module_CPPFLAGS) $(CPPFLAGS) $(cacheinfo_module_CFLAGS) $(CFLAGS) -MT commands/cacheinfo_module-cacheinfo.obj -MD -MP -MF commands/$(DEPDIR)/cacheinfo_module-cacheinfo.Tpo -c -o commands/cacheinfo_module-cacheinfo.obj `if test -f 'commands/cacheinfo.c'; then $(CYGPATH_W) 'commands/cacheinfo.c'; else $(CYGPATH_W) '$(srcdir)/commands/cacheinfo.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/cacheinfo_module-cacheinfo.Tpo commands/$(DEPDIR)/cacheinfo_module-cacheinfo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/cacheinfo.c' object='commands/cacheinfo_module-cacheinfo.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cacheinfo_module_CPPFLAGS) $(CPPFLAGS) $(cacheinfo_module_CFLAGS) $(CFLAGS) -c -o commands/cacheinfo_module-cacheinfo.obj `if test -f 'commands/cacheinfo.c'; then $(CYGPATH_W) 'commands/cacheinfo.c'; else $(CYGPATH_W) '$(srcdir)/commands/cacheinfo.c'; fi`
+
+commands/cat_module-cat.o: commands/cat.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cat_module_CPPFLAGS) $(CPPFLAGS) $(cat_module_CFLAGS) $(CFLAGS) -MT commands/cat_module-cat.o -MD -MP -MF commands/$(DEPDIR)/cat_module-cat.Tpo -c -o commands/cat_module-cat.o `test -f 'commands/cat.c' || echo '$(srcdir)/'`commands/cat.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/cat_module-cat.Tpo commands/$(DEPDIR)/cat_module-cat.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/cat.c' object='commands/cat_module-cat.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cat_module_CPPFLAGS) $(CPPFLAGS) $(cat_module_CFLAGS) $(CFLAGS) -c -o commands/cat_module-cat.o `test -f 'commands/cat.c' || echo '$(srcdir)/'`commands/cat.c
+
+commands/cat_module-cat.obj: commands/cat.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cat_module_CPPFLAGS) $(CPPFLAGS) $(cat_module_CFLAGS) $(CFLAGS) -MT commands/cat_module-cat.obj -MD -MP -MF commands/$(DEPDIR)/cat_module-cat.Tpo -c -o commands/cat_module-cat.obj `if test -f 'commands/cat.c'; then $(CYGPATH_W) 'commands/cat.c'; else $(CYGPATH_W) '$(srcdir)/commands/cat.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/cat_module-cat.Tpo commands/$(DEPDIR)/cat_module-cat.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/cat.c' object='commands/cat_module-cat.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cat_module_CPPFLAGS) $(CPPFLAGS) $(cat_module_CFLAGS) $(CFLAGS) -c -o commands/cat_module-cat.obj `if test -f 'commands/cat.c'; then $(CYGPATH_W) 'commands/cat.c'; else $(CYGPATH_W) '$(srcdir)/commands/cat.c'; fi`
+
+fs/cbfs_module-cbfs.o: fs/cbfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbfs_module_CPPFLAGS) $(CPPFLAGS) $(cbfs_module_CFLAGS) $(CFLAGS) -MT fs/cbfs_module-cbfs.o -MD -MP -MF fs/$(DEPDIR)/cbfs_module-cbfs.Tpo -c -o fs/cbfs_module-cbfs.o `test -f 'fs/cbfs.c' || echo '$(srcdir)/'`fs/cbfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/cbfs_module-cbfs.Tpo fs/$(DEPDIR)/cbfs_module-cbfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/cbfs.c' object='fs/cbfs_module-cbfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbfs_module_CPPFLAGS) $(CPPFLAGS) $(cbfs_module_CFLAGS) $(CFLAGS) -c -o fs/cbfs_module-cbfs.o `test -f 'fs/cbfs.c' || echo '$(srcdir)/'`fs/cbfs.c
+
+fs/cbfs_module-cbfs.obj: fs/cbfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbfs_module_CPPFLAGS) $(CPPFLAGS) $(cbfs_module_CFLAGS) $(CFLAGS) -MT fs/cbfs_module-cbfs.obj -MD -MP -MF fs/$(DEPDIR)/cbfs_module-cbfs.Tpo -c -o fs/cbfs_module-cbfs.obj `if test -f 'fs/cbfs.c'; then $(CYGPATH_W) 'fs/cbfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/cbfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/cbfs_module-cbfs.Tpo fs/$(DEPDIR)/cbfs_module-cbfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/cbfs.c' object='fs/cbfs_module-cbfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbfs_module_CPPFLAGS) $(CPPFLAGS) $(cbfs_module_CFLAGS) $(CFLAGS) -c -o fs/cbfs_module-cbfs.obj `if test -f 'fs/cbfs.c'; then $(CYGPATH_W) 'fs/cbfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/cbfs.c'; fi`
+
+commands/i386/coreboot/cbls_module-cbls.o: commands/i386/coreboot/cbls.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $(cbls_module_CFLAGS) $(CFLAGS) -MT commands/i386/coreboot/cbls_module-cbls.o -MD -MP -MF commands/i386/coreboot/$(DEPDIR)/cbls_module-cbls.Tpo -c -o commands/i386/coreboot/cbls_module-cbls.o `test -f 'commands/i386/coreboot/cbls.c' || echo '$(srcdir)/'`commands/i386/coreboot/cbls.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/coreboot/$(DEPDIR)/cbls_module-cbls.Tpo commands/i386/coreboot/$(DEPDIR)/cbls_module-cbls.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/coreboot/cbls.c' object='commands/i386/coreboot/cbls_module-cbls.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $(cbls_module_CFLAGS) $(CFLAGS) -c -o commands/i386/coreboot/cbls_module-cbls.o `test -f 'commands/i386/coreboot/cbls.c' || echo '$(srcdir)/'`commands/i386/coreboot/cbls.c
+
+commands/i386/coreboot/cbls_module-cbls.obj: commands/i386/coreboot/cbls.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $(cbls_module_CFLAGS) $(CFLAGS) -MT commands/i386/coreboot/cbls_module-cbls.obj -MD -MP -MF commands/i386/coreboot/$(DEPDIR)/cbls_module-cbls.Tpo -c -o commands/i386/coreboot/cbls_module-cbls.obj `if test -f 'commands/i386/coreboot/cbls.c'; then $(CYGPATH_W) 'commands/i386/coreboot/cbls.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/coreboot/cbls.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/coreboot/$(DEPDIR)/cbls_module-cbls.Tpo commands/i386/coreboot/$(DEPDIR)/cbls_module-cbls.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/coreboot/cbls.c' object='commands/i386/coreboot/cbls_module-cbls.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $(cbls_module_CFLAGS) $(CFLAGS) -c -o commands/i386/coreboot/cbls_module-cbls.obj `if test -f 'commands/i386/coreboot/cbls.c'; then $(CYGPATH_W) 'commands/i386/coreboot/cbls.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/coreboot/cbls.c'; fi`
+
+term/i386/coreboot/cbmemc_module-cbmemc.o: term/i386/coreboot/cbmemc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $(cbmemc_module_CFLAGS) $(CFLAGS) -MT term/i386/coreboot/cbmemc_module-cbmemc.o -MD -MP -MF term/i386/coreboot/$(DEPDIR)/cbmemc_module-cbmemc.Tpo -c -o term/i386/coreboot/cbmemc_module-cbmemc.o `test -f 'term/i386/coreboot/cbmemc.c' || echo '$(srcdir)/'`term/i386/coreboot/cbmemc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/i386/coreboot/$(DEPDIR)/cbmemc_module-cbmemc.Tpo term/i386/coreboot/$(DEPDIR)/cbmemc_module-cbmemc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/i386/coreboot/cbmemc.c' object='term/i386/coreboot/cbmemc_module-cbmemc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $(cbmemc_module_CFLAGS) $(CFLAGS) -c -o term/i386/coreboot/cbmemc_module-cbmemc.o `test -f 'term/i386/coreboot/cbmemc.c' || echo '$(srcdir)/'`term/i386/coreboot/cbmemc.c
+
+term/i386/coreboot/cbmemc_module-cbmemc.obj: term/i386/coreboot/cbmemc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $(cbmemc_module_CFLAGS) $(CFLAGS) -MT term/i386/coreboot/cbmemc_module-cbmemc.obj -MD -MP -MF term/i386/coreboot/$(DEPDIR)/cbmemc_module-cbmemc.Tpo -c -o term/i386/coreboot/cbmemc_module-cbmemc.obj `if test -f 'term/i386/coreboot/cbmemc.c'; then $(CYGPATH_W) 'term/i386/coreboot/cbmemc.c'; else $(CYGPATH_W) '$(srcdir)/term/i386/coreboot/cbmemc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/i386/coreboot/$(DEPDIR)/cbmemc_module-cbmemc.Tpo term/i386/coreboot/$(DEPDIR)/cbmemc_module-cbmemc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/i386/coreboot/cbmemc.c' object='term/i386/coreboot/cbmemc_module-cbmemc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $(cbmemc_module_CFLAGS) $(CFLAGS) -c -o term/i386/coreboot/cbmemc_module-cbmemc.obj `if test -f 'term/i386/coreboot/cbmemc.c'; then $(CYGPATH_W) 'term/i386/coreboot/cbmemc.c'; else $(CYGPATH_W) '$(srcdir)/term/i386/coreboot/cbmemc.c'; fi`
+
+kern/i386/coreboot/cbtable_module-cbtable.o: kern/i386/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $(cbtable_module_CFLAGS) $(CFLAGS) -MT kern/i386/coreboot/cbtable_module-cbtable.o -MD -MP -MF kern/i386/coreboot/$(DEPDIR)/cbtable_module-cbtable.Tpo -c -o kern/i386/coreboot/cbtable_module-cbtable.o `test -f 'kern/i386/coreboot/cbtable.c' || echo '$(srcdir)/'`kern/i386/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/coreboot/$(DEPDIR)/cbtable_module-cbtable.Tpo kern/i386/coreboot/$(DEPDIR)/cbtable_module-cbtable.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/coreboot/cbtable.c' object='kern/i386/coreboot/cbtable_module-cbtable.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $(cbtable_module_CFLAGS) $(CFLAGS) -c -o kern/i386/coreboot/cbtable_module-cbtable.o `test -f 'kern/i386/coreboot/cbtable.c' || echo '$(srcdir)/'`kern/i386/coreboot/cbtable.c
+
+kern/i386/coreboot/cbtable_module-cbtable.obj: kern/i386/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $(cbtable_module_CFLAGS) $(CFLAGS) -MT kern/i386/coreboot/cbtable_module-cbtable.obj -MD -MP -MF kern/i386/coreboot/$(DEPDIR)/cbtable_module-cbtable.Tpo -c -o kern/i386/coreboot/cbtable_module-cbtable.obj `if test -f 'kern/i386/coreboot/cbtable.c'; then $(CYGPATH_W) 'kern/i386/coreboot/cbtable.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/coreboot/cbtable.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/coreboot/$(DEPDIR)/cbtable_module-cbtable.Tpo kern/i386/coreboot/$(DEPDIR)/cbtable_module-cbtable.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/coreboot/cbtable.c' object='kern/i386/coreboot/cbtable_module-cbtable.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $(cbtable_module_CFLAGS) $(CFLAGS) -c -o kern/i386/coreboot/cbtable_module-cbtable.obj `if test -f 'kern/i386/coreboot/cbtable.c'; then $(CYGPATH_W) 'kern/i386/coreboot/cbtable.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/coreboot/cbtable.c'; fi`
+
+kern/coreboot/cbtable_module-cbtable.o: kern/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $(cbtable_module_CFLAGS) $(CFLAGS) -MT kern/coreboot/cbtable_module-cbtable.o -MD -MP -MF kern/coreboot/$(DEPDIR)/cbtable_module-cbtable.Tpo -c -o kern/coreboot/cbtable_module-cbtable.o `test -f 'kern/coreboot/cbtable.c' || echo '$(srcdir)/'`kern/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/coreboot/$(DEPDIR)/cbtable_module-cbtable.Tpo kern/coreboot/$(DEPDIR)/cbtable_module-cbtable.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/coreboot/cbtable.c' object='kern/coreboot/cbtable_module-cbtable.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $(cbtable_module_CFLAGS) $(CFLAGS) -c -o kern/coreboot/cbtable_module-cbtable.o `test -f 'kern/coreboot/cbtable.c' || echo '$(srcdir)/'`kern/coreboot/cbtable.c
+
+kern/coreboot/cbtable_module-cbtable.obj: kern/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $(cbtable_module_CFLAGS) $(CFLAGS) -MT kern/coreboot/cbtable_module-cbtable.obj -MD -MP -MF kern/coreboot/$(DEPDIR)/cbtable_module-cbtable.Tpo -c -o kern/coreboot/cbtable_module-cbtable.obj `if test -f 'kern/coreboot/cbtable.c'; then $(CYGPATH_W) 'kern/coreboot/cbtable.c'; else $(CYGPATH_W) '$(srcdir)/kern/coreboot/cbtable.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/coreboot/$(DEPDIR)/cbtable_module-cbtable.Tpo kern/coreboot/$(DEPDIR)/cbtable_module-cbtable.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/coreboot/cbtable.c' object='kern/coreboot/cbtable_module-cbtable.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $(cbtable_module_CFLAGS) $(CFLAGS) -c -o kern/coreboot/cbtable_module-cbtable.obj `if test -f 'kern/coreboot/cbtable.c'; then $(CYGPATH_W) 'kern/coreboot/cbtable.c'; else $(CYGPATH_W) '$(srcdir)/kern/coreboot/cbtable.c'; fi`
+
+commands/i386/coreboot/cbtime_module-cb_timestamps.o: commands/i386/coreboot/cb_timestamps.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $(cbtime_module_CFLAGS) $(CFLAGS) -MT commands/i386/coreboot/cbtime_module-cb_timestamps.o -MD -MP -MF commands/i386/coreboot/$(DEPDIR)/cbtime_module-cb_timestamps.Tpo -c -o commands/i386/coreboot/cbtime_module-cb_timestamps.o `test -f 'commands/i386/coreboot/cb_timestamps.c' || echo '$(srcdir)/'`commands/i386/coreboot/cb_timestamps.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/coreboot/$(DEPDIR)/cbtime_module-cb_timestamps.Tpo commands/i386/coreboot/$(DEPDIR)/cbtime_module-cb_timestamps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/coreboot/cb_timestamps.c' object='commands/i386/coreboot/cbtime_module-cb_timestamps.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $(cbtime_module_CFLAGS) $(CFLAGS) -c -o commands/i386/coreboot/cbtime_module-cb_timestamps.o `test -f 'commands/i386/coreboot/cb_timestamps.c' || echo '$(srcdir)/'`commands/i386/coreboot/cb_timestamps.c
+
+commands/i386/coreboot/cbtime_module-cb_timestamps.obj: commands/i386/coreboot/cb_timestamps.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $(cbtime_module_CFLAGS) $(CFLAGS) -MT commands/i386/coreboot/cbtime_module-cb_timestamps.obj -MD -MP -MF commands/i386/coreboot/$(DEPDIR)/cbtime_module-cb_timestamps.Tpo -c -o commands/i386/coreboot/cbtime_module-cb_timestamps.obj `if test -f 'commands/i386/coreboot/cb_timestamps.c'; then $(CYGPATH_W) 'commands/i386/coreboot/cb_timestamps.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/coreboot/cb_timestamps.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/coreboot/$(DEPDIR)/cbtime_module-cb_timestamps.Tpo commands/i386/coreboot/$(DEPDIR)/cbtime_module-cb_timestamps.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/coreboot/cb_timestamps.c' object='commands/i386/coreboot/cbtime_module-cb_timestamps.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $(cbtime_module_CFLAGS) $(CFLAGS) -c -o commands/i386/coreboot/cbtime_module-cb_timestamps.obj `if test -f 'commands/i386/coreboot/cb_timestamps.c'; then $(CYGPATH_W) 'commands/i386/coreboot/cb_timestamps.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/coreboot/cb_timestamps.c'; fi`
+
+loader/efi/chain_module-chainloader.o: loader/efi/chainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -MT loader/efi/chain_module-chainloader.o -MD -MP -MF loader/efi/$(DEPDIR)/chain_module-chainloader.Tpo -c -o loader/efi/chain_module-chainloader.o `test -f 'loader/efi/chainloader.c' || echo '$(srcdir)/'`loader/efi/chainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/efi/$(DEPDIR)/chain_module-chainloader.Tpo loader/efi/$(DEPDIR)/chain_module-chainloader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/efi/chainloader.c' object='loader/efi/chain_module-chainloader.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -c -o loader/efi/chain_module-chainloader.o `test -f 'loader/efi/chainloader.c' || echo '$(srcdir)/'`loader/efi/chainloader.c
+
+loader/efi/chain_module-chainloader.obj: loader/efi/chainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -MT loader/efi/chain_module-chainloader.obj -MD -MP -MF loader/efi/$(DEPDIR)/chain_module-chainloader.Tpo -c -o loader/efi/chain_module-chainloader.obj `if test -f 'loader/efi/chainloader.c'; then $(CYGPATH_W) 'loader/efi/chainloader.c'; else $(CYGPATH_W) '$(srcdir)/loader/efi/chainloader.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/efi/$(DEPDIR)/chain_module-chainloader.Tpo loader/efi/$(DEPDIR)/chain_module-chainloader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/efi/chainloader.c' object='loader/efi/chain_module-chainloader.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -c -o loader/efi/chain_module-chainloader.obj `if test -f 'loader/efi/chainloader.c'; then $(CYGPATH_W) 'loader/efi/chainloader.c'; else $(CYGPATH_W) '$(srcdir)/loader/efi/chainloader.c'; fi`
+
+loader/i386/coreboot/chain_module-chainloader.o: loader/i386/coreboot/chainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -MT loader/i386/coreboot/chain_module-chainloader.o -MD -MP -MF loader/i386/coreboot/$(DEPDIR)/chain_module-chainloader.Tpo -c -o loader/i386/coreboot/chain_module-chainloader.o `test -f 'loader/i386/coreboot/chainloader.c' || echo '$(srcdir)/'`loader/i386/coreboot/chainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/coreboot/$(DEPDIR)/chain_module-chainloader.Tpo loader/i386/coreboot/$(DEPDIR)/chain_module-chainloader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/coreboot/chainloader.c' object='loader/i386/coreboot/chain_module-chainloader.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -c -o loader/i386/coreboot/chain_module-chainloader.o `test -f 'loader/i386/coreboot/chainloader.c' || echo '$(srcdir)/'`loader/i386/coreboot/chainloader.c
+
+loader/i386/coreboot/chain_module-chainloader.obj: loader/i386/coreboot/chainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -MT loader/i386/coreboot/chain_module-chainloader.obj -MD -MP -MF loader/i386/coreboot/$(DEPDIR)/chain_module-chainloader.Tpo -c -o loader/i386/coreboot/chain_module-chainloader.obj `if test -f 'loader/i386/coreboot/chainloader.c'; then $(CYGPATH_W) 'loader/i386/coreboot/chainloader.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/coreboot/chainloader.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/coreboot/$(DEPDIR)/chain_module-chainloader.Tpo loader/i386/coreboot/$(DEPDIR)/chain_module-chainloader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/coreboot/chainloader.c' object='loader/i386/coreboot/chain_module-chainloader.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -c -o loader/i386/coreboot/chain_module-chainloader.obj `if test -f 'loader/i386/coreboot/chainloader.c'; then $(CYGPATH_W) 'loader/i386/coreboot/chainloader.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/coreboot/chainloader.c'; fi`
+
+lib/chain_module-LzmaDec.o: lib/LzmaDec.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -MT lib/chain_module-LzmaDec.o -MD -MP -MF lib/$(DEPDIR)/chain_module-LzmaDec.Tpo -c -o lib/chain_module-LzmaDec.o `test -f 'lib/LzmaDec.c' || echo '$(srcdir)/'`lib/LzmaDec.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/chain_module-LzmaDec.Tpo lib/$(DEPDIR)/chain_module-LzmaDec.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/LzmaDec.c' object='lib/chain_module-LzmaDec.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -c -o lib/chain_module-LzmaDec.o `test -f 'lib/LzmaDec.c' || echo '$(srcdir)/'`lib/LzmaDec.c
+
+lib/chain_module-LzmaDec.obj: lib/LzmaDec.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -MT lib/chain_module-LzmaDec.obj -MD -MP -MF lib/$(DEPDIR)/chain_module-LzmaDec.Tpo -c -o lib/chain_module-LzmaDec.obj `if test -f 'lib/LzmaDec.c'; then $(CYGPATH_W) 'lib/LzmaDec.c'; else $(CYGPATH_W) '$(srcdir)/lib/LzmaDec.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/chain_module-LzmaDec.Tpo lib/$(DEPDIR)/chain_module-LzmaDec.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/LzmaDec.c' object='lib/chain_module-LzmaDec.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -c -o lib/chain_module-LzmaDec.obj `if test -f 'lib/LzmaDec.c'; then $(CYGPATH_W) 'lib/LzmaDec.c'; else $(CYGPATH_W) '$(srcdir)/lib/LzmaDec.c'; fi`
+
+loader/i386/pc/chain_module-chainloader.o: loader/i386/pc/chainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/chain_module-chainloader.o -MD -MP -MF loader/i386/pc/$(DEPDIR)/chain_module-chainloader.Tpo -c -o loader/i386/pc/chain_module-chainloader.o `test -f 'loader/i386/pc/chainloader.c' || echo '$(srcdir)/'`loader/i386/pc/chainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/chain_module-chainloader.Tpo loader/i386/pc/$(DEPDIR)/chain_module-chainloader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/chainloader.c' object='loader/i386/pc/chain_module-chainloader.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/chain_module-chainloader.o `test -f 'loader/i386/pc/chainloader.c' || echo '$(srcdir)/'`loader/i386/pc/chainloader.c
+
+loader/i386/pc/chain_module-chainloader.obj: loader/i386/pc/chainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/chain_module-chainloader.obj -MD -MP -MF loader/i386/pc/$(DEPDIR)/chain_module-chainloader.Tpo -c -o loader/i386/pc/chain_module-chainloader.obj `if test -f 'loader/i386/pc/chainloader.c'; then $(CYGPATH_W) 'loader/i386/pc/chainloader.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/chainloader.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/chain_module-chainloader.Tpo loader/i386/pc/$(DEPDIR)/chain_module-chainloader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/chainloader.c' object='loader/i386/pc/chain_module-chainloader.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $(chain_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/chain_module-chainloader.obj `if test -f 'loader/i386/pc/chainloader.c'; then $(CYGPATH_W) 'loader/i386/pc/chainloader.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/chainloader.c'; fi`
+
+tests/cmdline_cat_test_module-cmdline_cat_test.o: tests/cmdline_cat_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmdline_cat_test_module_CPPFLAGS) $(CPPFLAGS) $(cmdline_cat_test_module_CFLAGS) $(CFLAGS) -MT tests/cmdline_cat_test_module-cmdline_cat_test.o -MD -MP -MF tests/$(DEPDIR)/cmdline_cat_test_module-cmdline_cat_test.Tpo -c -o tests/cmdline_cat_test_module-cmdline_cat_test.o `test -f 'tests/cmdline_cat_test.c' || echo '$(srcdir)/'`tests/cmdline_cat_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/cmdline_cat_test_module-cmdline_cat_test.Tpo tests/$(DEPDIR)/cmdline_cat_test_module-cmdline_cat_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/cmdline_cat_test.c' object='tests/cmdline_cat_test_module-cmdline_cat_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmdline_cat_test_module_CPPFLAGS) $(CPPFLAGS) $(cmdline_cat_test_module_CFLAGS) $(CFLAGS) -c -o tests/cmdline_cat_test_module-cmdline_cat_test.o `test -f 'tests/cmdline_cat_test.c' || echo '$(srcdir)/'`tests/cmdline_cat_test.c
+
+tests/cmdline_cat_test_module-cmdline_cat_test.obj: tests/cmdline_cat_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmdline_cat_test_module_CPPFLAGS) $(CPPFLAGS) $(cmdline_cat_test_module_CFLAGS) $(CFLAGS) -MT tests/cmdline_cat_test_module-cmdline_cat_test.obj -MD -MP -MF tests/$(DEPDIR)/cmdline_cat_test_module-cmdline_cat_test.Tpo -c -o tests/cmdline_cat_test_module-cmdline_cat_test.obj `if test -f 'tests/cmdline_cat_test.c'; then $(CYGPATH_W) 'tests/cmdline_cat_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/cmdline_cat_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/cmdline_cat_test_module-cmdline_cat_test.Tpo tests/$(DEPDIR)/cmdline_cat_test_module-cmdline_cat_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/cmdline_cat_test.c' object='tests/cmdline_cat_test_module-cmdline_cat_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmdline_cat_test_module_CPPFLAGS) $(CPPFLAGS) $(cmdline_cat_test_module_CFLAGS) $(CFLAGS) -c -o tests/cmdline_cat_test_module-cmdline_cat_test.obj `if test -f 'tests/cmdline_cat_test.c'; then $(CYGPATH_W) 'tests/cmdline_cat_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/cmdline_cat_test.c'; fi`
+
+commands/i386/cmosdump_module-cmosdump.o: commands/i386/cmosdump.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $(cmosdump_module_CFLAGS) $(CFLAGS) -MT commands/i386/cmosdump_module-cmosdump.o -MD -MP -MF commands/i386/$(DEPDIR)/cmosdump_module-cmosdump.Tpo -c -o commands/i386/cmosdump_module-cmosdump.o `test -f 'commands/i386/cmosdump.c' || echo '$(srcdir)/'`commands/i386/cmosdump.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/$(DEPDIR)/cmosdump_module-cmosdump.Tpo commands/i386/$(DEPDIR)/cmosdump_module-cmosdump.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/cmosdump.c' object='commands/i386/cmosdump_module-cmosdump.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $(cmosdump_module_CFLAGS) $(CFLAGS) -c -o commands/i386/cmosdump_module-cmosdump.o `test -f 'commands/i386/cmosdump.c' || echo '$(srcdir)/'`commands/i386/cmosdump.c
+
+commands/i386/cmosdump_module-cmosdump.obj: commands/i386/cmosdump.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $(cmosdump_module_CFLAGS) $(CFLAGS) -MT commands/i386/cmosdump_module-cmosdump.obj -MD -MP -MF commands/i386/$(DEPDIR)/cmosdump_module-cmosdump.Tpo -c -o commands/i386/cmosdump_module-cmosdump.obj `if test -f 'commands/i386/cmosdump.c'; then $(CYGPATH_W) 'commands/i386/cmosdump.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/cmosdump.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/$(DEPDIR)/cmosdump_module-cmosdump.Tpo commands/i386/$(DEPDIR)/cmosdump_module-cmosdump.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/cmosdump.c' object='commands/i386/cmosdump_module-cmosdump.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $(cmosdump_module_CFLAGS) $(CFLAGS) -c -o commands/i386/cmosdump_module-cmosdump.obj `if test -f 'commands/i386/cmosdump.c'; then $(CYGPATH_W) 'commands/i386/cmosdump.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/cmosdump.c'; fi`
+
+commands/i386/cmostest_module-cmostest.o: commands/i386/cmostest.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $(cmostest_module_CFLAGS) $(CFLAGS) -MT commands/i386/cmostest_module-cmostest.o -MD -MP -MF commands/i386/$(DEPDIR)/cmostest_module-cmostest.Tpo -c -o commands/i386/cmostest_module-cmostest.o `test -f 'commands/i386/cmostest.c' || echo '$(srcdir)/'`commands/i386/cmostest.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/$(DEPDIR)/cmostest_module-cmostest.Tpo commands/i386/$(DEPDIR)/cmostest_module-cmostest.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/cmostest.c' object='commands/i386/cmostest_module-cmostest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $(cmostest_module_CFLAGS) $(CFLAGS) -c -o commands/i386/cmostest_module-cmostest.o `test -f 'commands/i386/cmostest.c' || echo '$(srcdir)/'`commands/i386/cmostest.c
+
+commands/i386/cmostest_module-cmostest.obj: commands/i386/cmostest.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $(cmostest_module_CFLAGS) $(CFLAGS) -MT commands/i386/cmostest_module-cmostest.obj -MD -MP -MF commands/i386/$(DEPDIR)/cmostest_module-cmostest.Tpo -c -o commands/i386/cmostest_module-cmostest.obj `if test -f 'commands/i386/cmostest.c'; then $(CYGPATH_W) 'commands/i386/cmostest.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/cmostest.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/$(DEPDIR)/cmostest_module-cmostest.Tpo commands/i386/$(DEPDIR)/cmostest_module-cmostest.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/cmostest.c' object='commands/i386/cmostest_module-cmostest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $(cmostest_module_CFLAGS) $(CFLAGS) -c -o commands/i386/cmostest_module-cmostest.obj `if test -f 'commands/i386/cmostest.c'; then $(CYGPATH_W) 'commands/i386/cmostest.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/cmostest.c'; fi`
+
+commands/cmp_module-cmp.o: commands/cmp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_module_CPPFLAGS) $(CPPFLAGS) $(cmp_module_CFLAGS) $(CFLAGS) -MT commands/cmp_module-cmp.o -MD -MP -MF commands/$(DEPDIR)/cmp_module-cmp.Tpo -c -o commands/cmp_module-cmp.o `test -f 'commands/cmp.c' || echo '$(srcdir)/'`commands/cmp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/cmp_module-cmp.Tpo commands/$(DEPDIR)/cmp_module-cmp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/cmp.c' object='commands/cmp_module-cmp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_module_CPPFLAGS) $(CPPFLAGS) $(cmp_module_CFLAGS) $(CFLAGS) -c -o commands/cmp_module-cmp.o `test -f 'commands/cmp.c' || echo '$(srcdir)/'`commands/cmp.c
+
+commands/cmp_module-cmp.obj: commands/cmp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_module_CPPFLAGS) $(CPPFLAGS) $(cmp_module_CFLAGS) $(CFLAGS) -MT commands/cmp_module-cmp.obj -MD -MP -MF commands/$(DEPDIR)/cmp_module-cmp.Tpo -c -o commands/cmp_module-cmp.obj `if test -f 'commands/cmp.c'; then $(CYGPATH_W) 'commands/cmp.c'; else $(CYGPATH_W) '$(srcdir)/commands/cmp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/cmp_module-cmp.Tpo commands/$(DEPDIR)/cmp_module-cmp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/cmp.c' object='commands/cmp_module-cmp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_module_CPPFLAGS) $(CPPFLAGS) $(cmp_module_CFLAGS) $(CFLAGS) -c -o commands/cmp_module-cmp.obj `if test -f 'commands/cmp.c'; then $(CYGPATH_W) 'commands/cmp.c'; else $(CYGPATH_W) '$(srcdir)/commands/cmp.c'; fi`
+
+tests/cmp_test_module-cmp_test.o: tests/cmp_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_test_module_CPPFLAGS) $(CPPFLAGS) $(cmp_test_module_CFLAGS) $(CFLAGS) -MT tests/cmp_test_module-cmp_test.o -MD -MP -MF tests/$(DEPDIR)/cmp_test_module-cmp_test.Tpo -c -o tests/cmp_test_module-cmp_test.o `test -f 'tests/cmp_test.c' || echo '$(srcdir)/'`tests/cmp_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/cmp_test_module-cmp_test.Tpo tests/$(DEPDIR)/cmp_test_module-cmp_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/cmp_test.c' object='tests/cmp_test_module-cmp_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_test_module_CPPFLAGS) $(CPPFLAGS) $(cmp_test_module_CFLAGS) $(CFLAGS) -c -o tests/cmp_test_module-cmp_test.o `test -f 'tests/cmp_test.c' || echo '$(srcdir)/'`tests/cmp_test.c
+
+tests/cmp_test_module-cmp_test.obj: tests/cmp_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_test_module_CPPFLAGS) $(CPPFLAGS) $(cmp_test_module_CFLAGS) $(CFLAGS) -MT tests/cmp_test_module-cmp_test.obj -MD -MP -MF tests/$(DEPDIR)/cmp_test_module-cmp_test.Tpo -c -o tests/cmp_test_module-cmp_test.obj `if test -f 'tests/cmp_test.c'; then $(CYGPATH_W) 'tests/cmp_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/cmp_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/cmp_test_module-cmp_test.Tpo tests/$(DEPDIR)/cmp_test_module-cmp_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/cmp_test.c' object='tests/cmp_test_module-cmp_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_test_module_CPPFLAGS) $(CPPFLAGS) $(cmp_test_module_CFLAGS) $(CFLAGS) -c -o tests/cmp_test_module-cmp_test.obj `if test -f 'tests/cmp_test.c'; then $(CYGPATH_W) 'tests/cmp_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/cmp_test.c'; fi`
+
+commands/configfile_module-configfile.o: commands/configfile.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(configfile_module_CPPFLAGS) $(CPPFLAGS) $(configfile_module_CFLAGS) $(CFLAGS) -MT commands/configfile_module-configfile.o -MD -MP -MF commands/$(DEPDIR)/configfile_module-configfile.Tpo -c -o commands/configfile_module-configfile.o `test -f 'commands/configfile.c' || echo '$(srcdir)/'`commands/configfile.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/configfile_module-configfile.Tpo commands/$(DEPDIR)/configfile_module-configfile.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/configfile.c' object='commands/configfile_module-configfile.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(configfile_module_CPPFLAGS) $(CPPFLAGS) $(configfile_module_CFLAGS) $(CFLAGS) -c -o commands/configfile_module-configfile.o `test -f 'commands/configfile.c' || echo '$(srcdir)/'`commands/configfile.c
+
+commands/configfile_module-configfile.obj: commands/configfile.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(configfile_module_CPPFLAGS) $(CPPFLAGS) $(configfile_module_CFLAGS) $(CFLAGS) -MT commands/configfile_module-configfile.obj -MD -MP -MF commands/$(DEPDIR)/configfile_module-configfile.Tpo -c -o commands/configfile_module-configfile.obj `if test -f 'commands/configfile.c'; then $(CYGPATH_W) 'commands/configfile.c'; else $(CYGPATH_W) '$(srcdir)/commands/configfile.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/configfile_module-configfile.Tpo commands/$(DEPDIR)/configfile_module-configfile.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/configfile.c' object='commands/configfile_module-configfile.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(configfile_module_CPPFLAGS) $(CPPFLAGS) $(configfile_module_CFLAGS) $(CFLAGS) -c -o commands/configfile_module-configfile.obj `if test -f 'commands/configfile.c'; then $(CYGPATH_W) 'commands/configfile.c'; else $(CYGPATH_W) '$(srcdir)/commands/configfile.c'; fi`
+
+fs/cpio_module-cpio.o: fs/cpio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_module_CPPFLAGS) $(CPPFLAGS) $(cpio_module_CFLAGS) $(CFLAGS) -MT fs/cpio_module-cpio.o -MD -MP -MF fs/$(DEPDIR)/cpio_module-cpio.Tpo -c -o fs/cpio_module-cpio.o `test -f 'fs/cpio.c' || echo '$(srcdir)/'`fs/cpio.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/cpio_module-cpio.Tpo fs/$(DEPDIR)/cpio_module-cpio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/cpio.c' object='fs/cpio_module-cpio.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_module_CPPFLAGS) $(CPPFLAGS) $(cpio_module_CFLAGS) $(CFLAGS) -c -o fs/cpio_module-cpio.o `test -f 'fs/cpio.c' || echo '$(srcdir)/'`fs/cpio.c
+
+fs/cpio_module-cpio.obj: fs/cpio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_module_CPPFLAGS) $(CPPFLAGS) $(cpio_module_CFLAGS) $(CFLAGS) -MT fs/cpio_module-cpio.obj -MD -MP -MF fs/$(DEPDIR)/cpio_module-cpio.Tpo -c -o fs/cpio_module-cpio.obj `if test -f 'fs/cpio.c'; then $(CYGPATH_W) 'fs/cpio.c'; else $(CYGPATH_W) '$(srcdir)/fs/cpio.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/cpio_module-cpio.Tpo fs/$(DEPDIR)/cpio_module-cpio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/cpio.c' object='fs/cpio_module-cpio.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_module_CPPFLAGS) $(CPPFLAGS) $(cpio_module_CFLAGS) $(CFLAGS) -c -o fs/cpio_module-cpio.obj `if test -f 'fs/cpio.c'; then $(CYGPATH_W) 'fs/cpio.c'; else $(CYGPATH_W) '$(srcdir)/fs/cpio.c'; fi`
+
+fs/cpio_be_module-cpio_be.o: fs/cpio_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_be_module_CPPFLAGS) $(CPPFLAGS) $(cpio_be_module_CFLAGS) $(CFLAGS) -MT fs/cpio_be_module-cpio_be.o -MD -MP -MF fs/$(DEPDIR)/cpio_be_module-cpio_be.Tpo -c -o fs/cpio_be_module-cpio_be.o `test -f 'fs/cpio_be.c' || echo '$(srcdir)/'`fs/cpio_be.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/cpio_be_module-cpio_be.Tpo fs/$(DEPDIR)/cpio_be_module-cpio_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/cpio_be.c' object='fs/cpio_be_module-cpio_be.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_be_module_CPPFLAGS) $(CPPFLAGS) $(cpio_be_module_CFLAGS) $(CFLAGS) -c -o fs/cpio_be_module-cpio_be.o `test -f 'fs/cpio_be.c' || echo '$(srcdir)/'`fs/cpio_be.c
+
+fs/cpio_be_module-cpio_be.obj: fs/cpio_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_be_module_CPPFLAGS) $(CPPFLAGS) $(cpio_be_module_CFLAGS) $(CFLAGS) -MT fs/cpio_be_module-cpio_be.obj -MD -MP -MF fs/$(DEPDIR)/cpio_be_module-cpio_be.Tpo -c -o fs/cpio_be_module-cpio_be.obj `if test -f 'fs/cpio_be.c'; then $(CYGPATH_W) 'fs/cpio_be.c'; else $(CYGPATH_W) '$(srcdir)/fs/cpio_be.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/cpio_be_module-cpio_be.Tpo fs/$(DEPDIR)/cpio_be_module-cpio_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/cpio_be.c' object='fs/cpio_be_module-cpio_be.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_be_module_CPPFLAGS) $(CPPFLAGS) $(cpio_be_module_CFLAGS) $(CFLAGS) -c -o fs/cpio_be_module-cpio_be.obj `if test -f 'fs/cpio_be.c'; then $(CYGPATH_W) 'fs/cpio_be.c'; else $(CYGPATH_W) '$(srcdir)/fs/cpio_be.c'; fi`
+
+commands/i386/cpuid_module-cpuid.o: commands/i386/cpuid.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $(cpuid_module_CFLAGS) $(CFLAGS) -MT commands/i386/cpuid_module-cpuid.o -MD -MP -MF commands/i386/$(DEPDIR)/cpuid_module-cpuid.Tpo -c -o commands/i386/cpuid_module-cpuid.o `test -f 'commands/i386/cpuid.c' || echo '$(srcdir)/'`commands/i386/cpuid.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/$(DEPDIR)/cpuid_module-cpuid.Tpo commands/i386/$(DEPDIR)/cpuid_module-cpuid.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/cpuid.c' object='commands/i386/cpuid_module-cpuid.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $(cpuid_module_CFLAGS) $(CFLAGS) -c -o commands/i386/cpuid_module-cpuid.o `test -f 'commands/i386/cpuid.c' || echo '$(srcdir)/'`commands/i386/cpuid.c
+
+commands/i386/cpuid_module-cpuid.obj: commands/i386/cpuid.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $(cpuid_module_CFLAGS) $(CFLAGS) -MT commands/i386/cpuid_module-cpuid.obj -MD -MP -MF commands/i386/$(DEPDIR)/cpuid_module-cpuid.Tpo -c -o commands/i386/cpuid_module-cpuid.obj `if test -f 'commands/i386/cpuid.c'; then $(CYGPATH_W) 'commands/i386/cpuid.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/cpuid.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/$(DEPDIR)/cpuid_module-cpuid.Tpo commands/i386/$(DEPDIR)/cpuid_module-cpuid.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/cpuid.c' object='commands/i386/cpuid_module-cpuid.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $(cpuid_module_CFLAGS) $(CFLAGS) -c -o commands/i386/cpuid_module-cpuid.obj `if test -f 'commands/i386/cpuid.c'; then $(CYGPATH_W) 'commands/i386/cpuid.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/cpuid.c'; fi`
+
+lib/crc64_module-crc64.o: lib/crc64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crc64_module_CPPFLAGS) $(CPPFLAGS) $(crc64_module_CFLAGS) $(CFLAGS) -MT lib/crc64_module-crc64.o -MD -MP -MF lib/$(DEPDIR)/crc64_module-crc64.Tpo -c -o lib/crc64_module-crc64.o `test -f 'lib/crc64.c' || echo '$(srcdir)/'`lib/crc64.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/crc64_module-crc64.Tpo lib/$(DEPDIR)/crc64_module-crc64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/crc64.c' object='lib/crc64_module-crc64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crc64_module_CPPFLAGS) $(CPPFLAGS) $(crc64_module_CFLAGS) $(CFLAGS) -c -o lib/crc64_module-crc64.o `test -f 'lib/crc64.c' || echo '$(srcdir)/'`lib/crc64.c
+
+lib/crc64_module-crc64.obj: lib/crc64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crc64_module_CPPFLAGS) $(CPPFLAGS) $(crc64_module_CFLAGS) $(CFLAGS) -MT lib/crc64_module-crc64.obj -MD -MP -MF lib/$(DEPDIR)/crc64_module-crc64.Tpo -c -o lib/crc64_module-crc64.obj `if test -f 'lib/crc64.c'; then $(CYGPATH_W) 'lib/crc64.c'; else $(CYGPATH_W) '$(srcdir)/lib/crc64.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/crc64_module-crc64.Tpo lib/$(DEPDIR)/crc64_module-crc64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/crc64.c' object='lib/crc64_module-crc64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crc64_module_CPPFLAGS) $(CPPFLAGS) $(crc64_module_CFLAGS) $(CFLAGS) -c -o lib/crc64_module-crc64.obj `if test -f 'lib/crc64.c'; then $(CYGPATH_W) 'lib/crc64.c'; else $(CYGPATH_W) '$(srcdir)/lib/crc64.c'; fi`
+
+lib/crypto_module-crypto.o: lib/crypto.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crypto_module_CPPFLAGS) $(CPPFLAGS) $(crypto_module_CFLAGS) $(CFLAGS) -MT lib/crypto_module-crypto.o -MD -MP -MF lib/$(DEPDIR)/crypto_module-crypto.Tpo -c -o lib/crypto_module-crypto.o `test -f 'lib/crypto.c' || echo '$(srcdir)/'`lib/crypto.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/crypto_module-crypto.Tpo lib/$(DEPDIR)/crypto_module-crypto.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/crypto.c' object='lib/crypto_module-crypto.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crypto_module_CPPFLAGS) $(CPPFLAGS) $(crypto_module_CFLAGS) $(CFLAGS) -c -o lib/crypto_module-crypto.o `test -f 'lib/crypto.c' || echo '$(srcdir)/'`lib/crypto.c
+
+lib/crypto_module-crypto.obj: lib/crypto.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crypto_module_CPPFLAGS) $(CPPFLAGS) $(crypto_module_CFLAGS) $(CFLAGS) -MT lib/crypto_module-crypto.obj -MD -MP -MF lib/$(DEPDIR)/crypto_module-crypto.Tpo -c -o lib/crypto_module-crypto.obj `if test -f 'lib/crypto.c'; then $(CYGPATH_W) 'lib/crypto.c'; else $(CYGPATH_W) '$(srcdir)/lib/crypto.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/crypto_module-crypto.Tpo lib/$(DEPDIR)/crypto_module-crypto.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/crypto.c' object='lib/crypto_module-crypto.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crypto_module_CPPFLAGS) $(CPPFLAGS) $(crypto_module_CFLAGS) $(CFLAGS) -c -o lib/crypto_module-crypto.obj `if test -f 'lib/crypto.c'; then $(CYGPATH_W) 'lib/crypto.c'; else $(CYGPATH_W) '$(srcdir)/lib/crypto.c'; fi`
+
+disk/cryptodisk_module-cryptodisk.o: disk/cryptodisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cryptodisk_module_CPPFLAGS) $(CPPFLAGS) $(cryptodisk_module_CFLAGS) $(CFLAGS) -MT disk/cryptodisk_module-cryptodisk.o -MD -MP -MF disk/$(DEPDIR)/cryptodisk_module-cryptodisk.Tpo -c -o disk/cryptodisk_module-cryptodisk.o `test -f 'disk/cryptodisk.c' || echo '$(srcdir)/'`disk/cryptodisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/cryptodisk_module-cryptodisk.Tpo disk/$(DEPDIR)/cryptodisk_module-cryptodisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/cryptodisk.c' object='disk/cryptodisk_module-cryptodisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cryptodisk_module_CPPFLAGS) $(CPPFLAGS) $(cryptodisk_module_CFLAGS) $(CFLAGS) -c -o disk/cryptodisk_module-cryptodisk.o `test -f 'disk/cryptodisk.c' || echo '$(srcdir)/'`disk/cryptodisk.c
+
+disk/cryptodisk_module-cryptodisk.obj: disk/cryptodisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cryptodisk_module_CPPFLAGS) $(CPPFLAGS) $(cryptodisk_module_CFLAGS) $(CFLAGS) -MT disk/cryptodisk_module-cryptodisk.obj -MD -MP -MF disk/$(DEPDIR)/cryptodisk_module-cryptodisk.Tpo -c -o disk/cryptodisk_module-cryptodisk.obj `if test -f 'disk/cryptodisk.c'; then $(CYGPATH_W) 'disk/cryptodisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/cryptodisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/cryptodisk_module-cryptodisk.Tpo disk/$(DEPDIR)/cryptodisk_module-cryptodisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/cryptodisk.c' object='disk/cryptodisk_module-cryptodisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cryptodisk_module_CPPFLAGS) $(CPPFLAGS) $(cryptodisk_module_CFLAGS) $(CFLAGS) -c -o disk/cryptodisk_module-cryptodisk.obj `if test -f 'disk/cryptodisk.c'; then $(CYGPATH_W) 'disk/cryptodisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/cryptodisk.c'; fi`
+
+bus/cs5536_module-cs5536.o: bus/cs5536.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $(cs5536_module_CFLAGS) $(CFLAGS) -MT bus/cs5536_module-cs5536.o -MD -MP -MF bus/$(DEPDIR)/cs5536_module-cs5536.Tpo -c -o bus/cs5536_module-cs5536.o `test -f 'bus/cs5536.c' || echo '$(srcdir)/'`bus/cs5536.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/cs5536_module-cs5536.Tpo bus/$(DEPDIR)/cs5536_module-cs5536.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/cs5536.c' object='bus/cs5536_module-cs5536.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $(cs5536_module_CFLAGS) $(CFLAGS) -c -o bus/cs5536_module-cs5536.o `test -f 'bus/cs5536.c' || echo '$(srcdir)/'`bus/cs5536.c
+
+bus/cs5536_module-cs5536.obj: bus/cs5536.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $(cs5536_module_CFLAGS) $(CFLAGS) -MT bus/cs5536_module-cs5536.obj -MD -MP -MF bus/$(DEPDIR)/cs5536_module-cs5536.Tpo -c -o bus/cs5536_module-cs5536.obj `if test -f 'bus/cs5536.c'; then $(CYGPATH_W) 'bus/cs5536.c'; else $(CYGPATH_W) '$(srcdir)/bus/cs5536.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/cs5536_module-cs5536.Tpo bus/$(DEPDIR)/cs5536_module-cs5536.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/cs5536.c' object='bus/cs5536_module-cs5536.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $(cs5536_module_CFLAGS) $(CFLAGS) -c -o bus/cs5536_module-cs5536.obj `if test -f 'bus/cs5536.c'; then $(CYGPATH_W) 'bus/cs5536.c'; else $(CYGPATH_W) '$(srcdir)/bus/cs5536.c'; fi`
+
+tests/ctz_test_module-ctz_test.o: tests/ctz_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ctz_test_module_CPPFLAGS) $(CPPFLAGS) $(ctz_test_module_CFLAGS) $(CFLAGS) -MT tests/ctz_test_module-ctz_test.o -MD -MP -MF tests/$(DEPDIR)/ctz_test_module-ctz_test.Tpo -c -o tests/ctz_test_module-ctz_test.o `test -f 'tests/ctz_test.c' || echo '$(srcdir)/'`tests/ctz_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/ctz_test_module-ctz_test.Tpo tests/$(DEPDIR)/ctz_test_module-ctz_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/ctz_test.c' object='tests/ctz_test_module-ctz_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ctz_test_module_CPPFLAGS) $(CPPFLAGS) $(ctz_test_module_CFLAGS) $(CFLAGS) -c -o tests/ctz_test_module-ctz_test.o `test -f 'tests/ctz_test.c' || echo '$(srcdir)/'`tests/ctz_test.c
+
+tests/ctz_test_module-ctz_test.obj: tests/ctz_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ctz_test_module_CPPFLAGS) $(CPPFLAGS) $(ctz_test_module_CFLAGS) $(CFLAGS) -MT tests/ctz_test_module-ctz_test.obj -MD -MP -MF tests/$(DEPDIR)/ctz_test_module-ctz_test.Tpo -c -o tests/ctz_test_module-ctz_test.obj `if test -f 'tests/ctz_test.c'; then $(CYGPATH_W) 'tests/ctz_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/ctz_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/ctz_test_module-ctz_test.Tpo tests/$(DEPDIR)/ctz_test_module-ctz_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/ctz_test.c' object='tests/ctz_test_module-ctz_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ctz_test_module_CPPFLAGS) $(CPPFLAGS) $(ctz_test_module_CFLAGS) $(CFLAGS) -c -o tests/ctz_test_module-ctz_test.obj `if test -f 'tests/ctz_test.c'; then $(CYGPATH_W) 'tests/ctz_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/ctz_test.c'; fi`
+
+commands/date_module-date.o: commands/date.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(date_module_CPPFLAGS) $(CPPFLAGS) $(date_module_CFLAGS) $(CFLAGS) -MT commands/date_module-date.o -MD -MP -MF commands/$(DEPDIR)/date_module-date.Tpo -c -o commands/date_module-date.o `test -f 'commands/date.c' || echo '$(srcdir)/'`commands/date.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/date_module-date.Tpo commands/$(DEPDIR)/date_module-date.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/date.c' object='commands/date_module-date.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(date_module_CPPFLAGS) $(CPPFLAGS) $(date_module_CFLAGS) $(CFLAGS) -c -o commands/date_module-date.o `test -f 'commands/date.c' || echo '$(srcdir)/'`commands/date.c
+
+commands/date_module-date.obj: commands/date.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(date_module_CPPFLAGS) $(CPPFLAGS) $(date_module_CFLAGS) $(CFLAGS) -MT commands/date_module-date.obj -MD -MP -MF commands/$(DEPDIR)/date_module-date.Tpo -c -o commands/date_module-date.obj `if test -f 'commands/date.c'; then $(CYGPATH_W) 'commands/date.c'; else $(CYGPATH_W) '$(srcdir)/commands/date.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/date_module-date.Tpo commands/$(DEPDIR)/date_module-date.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/date.c' object='commands/date_module-date.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(date_module_CPPFLAGS) $(CPPFLAGS) $(date_module_CFLAGS) $(CFLAGS) -c -o commands/date_module-date.obj `if test -f 'commands/date.c'; then $(CYGPATH_W) 'commands/date.c'; else $(CYGPATH_W) '$(srcdir)/commands/date.c'; fi`
+
+hook/datehook_module-datehook.o: hook/datehook.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datehook_module_CPPFLAGS) $(CPPFLAGS) $(datehook_module_CFLAGS) $(CFLAGS) -MT hook/datehook_module-datehook.o -MD -MP -MF hook/$(DEPDIR)/datehook_module-datehook.Tpo -c -o hook/datehook_module-datehook.o `test -f 'hook/datehook.c' || echo '$(srcdir)/'`hook/datehook.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) hook/$(DEPDIR)/datehook_module-datehook.Tpo hook/$(DEPDIR)/datehook_module-datehook.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hook/datehook.c' object='hook/datehook_module-datehook.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datehook_module_CPPFLAGS) $(CPPFLAGS) $(datehook_module_CFLAGS) $(CFLAGS) -c -o hook/datehook_module-datehook.o `test -f 'hook/datehook.c' || echo '$(srcdir)/'`hook/datehook.c
+
+hook/datehook_module-datehook.obj: hook/datehook.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datehook_module_CPPFLAGS) $(CPPFLAGS) $(datehook_module_CFLAGS) $(CFLAGS) -MT hook/datehook_module-datehook.obj -MD -MP -MF hook/$(DEPDIR)/datehook_module-datehook.Tpo -c -o hook/datehook_module-datehook.obj `if test -f 'hook/datehook.c'; then $(CYGPATH_W) 'hook/datehook.c'; else $(CYGPATH_W) '$(srcdir)/hook/datehook.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) hook/$(DEPDIR)/datehook_module-datehook.Tpo hook/$(DEPDIR)/datehook_module-datehook.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hook/datehook.c' object='hook/datehook_module-datehook.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datehook_module_CPPFLAGS) $(CPPFLAGS) $(datehook_module_CFLAGS) $(CFLAGS) -c -o hook/datehook_module-datehook.obj `if test -f 'hook/datehook.c'; then $(CYGPATH_W) 'hook/datehook.c'; else $(CYGPATH_W) '$(srcdir)/hook/datehook.c'; fi`
+
+lib/efi/datetime_module-datetime.o: lib/efi/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/efi/datetime_module-datetime.o -MD -MP -MF lib/efi/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/efi/datetime_module-datetime.o `test -f 'lib/efi/datetime.c' || echo '$(srcdir)/'`lib/efi/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/efi/$(DEPDIR)/datetime_module-datetime.Tpo lib/efi/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/efi/datetime.c' object='lib/efi/datetime_module-datetime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/efi/datetime_module-datetime.o `test -f 'lib/efi/datetime.c' || echo '$(srcdir)/'`lib/efi/datetime.c
+
+lib/efi/datetime_module-datetime.obj: lib/efi/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/efi/datetime_module-datetime.obj -MD -MP -MF lib/efi/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/efi/datetime_module-datetime.obj `if test -f 'lib/efi/datetime.c'; then $(CYGPATH_W) 'lib/efi/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/efi/datetime.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/efi/$(DEPDIR)/datetime_module-datetime.Tpo lib/efi/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/efi/datetime.c' object='lib/efi/datetime_module-datetime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/efi/datetime_module-datetime.obj `if test -f 'lib/efi/datetime.c'; then $(CYGPATH_W) 'lib/efi/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/efi/datetime.c'; fi`
+
+lib/datetime_module-datetime.o: lib/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/datetime_module-datetime.o -MD -MP -MF lib/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/datetime_module-datetime.o `test -f 'lib/datetime.c' || echo '$(srcdir)/'`lib/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/datetime_module-datetime.Tpo lib/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/datetime.c' object='lib/datetime_module-datetime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/datetime_module-datetime.o `test -f 'lib/datetime.c' || echo '$(srcdir)/'`lib/datetime.c
+
+lib/datetime_module-datetime.obj: lib/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/datetime_module-datetime.obj -MD -MP -MF lib/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/datetime_module-datetime.obj `if test -f 'lib/datetime.c'; then $(CYGPATH_W) 'lib/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/datetime.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/datetime_module-datetime.Tpo lib/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/datetime.c' object='lib/datetime_module-datetime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/datetime_module-datetime.obj `if test -f 'lib/datetime.c'; then $(CYGPATH_W) 'lib/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/datetime.c'; fi`
+
+lib/dummy/datetime_module-datetime.o: lib/dummy/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/dummy/datetime_module-datetime.o -MD -MP -MF lib/dummy/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/dummy/datetime_module-datetime.o `test -f 'lib/dummy/datetime.c' || echo '$(srcdir)/'`lib/dummy/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/dummy/$(DEPDIR)/datetime_module-datetime.Tpo lib/dummy/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/dummy/datetime.c' object='lib/dummy/datetime_module-datetime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/dummy/datetime_module-datetime.o `test -f 'lib/dummy/datetime.c' || echo '$(srcdir)/'`lib/dummy/datetime.c
+
+lib/dummy/datetime_module-datetime.obj: lib/dummy/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/dummy/datetime_module-datetime.obj -MD -MP -MF lib/dummy/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/dummy/datetime_module-datetime.obj `if test -f 'lib/dummy/datetime.c'; then $(CYGPATH_W) 'lib/dummy/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/dummy/datetime.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/dummy/$(DEPDIR)/datetime_module-datetime.Tpo lib/dummy/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/dummy/datetime.c' object='lib/dummy/datetime_module-datetime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/dummy/datetime_module-datetime.obj `if test -f 'lib/dummy/datetime.c'; then $(CYGPATH_W) 'lib/dummy/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/dummy/datetime.c'; fi`
+
+lib/datetime_module-cmos_datetime.o: lib/cmos_datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/datetime_module-cmos_datetime.o -MD -MP -MF lib/$(DEPDIR)/datetime_module-cmos_datetime.Tpo -c -o lib/datetime_module-cmos_datetime.o `test -f 'lib/cmos_datetime.c' || echo '$(srcdir)/'`lib/cmos_datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/datetime_module-cmos_datetime.Tpo lib/$(DEPDIR)/datetime_module-cmos_datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/cmos_datetime.c' object='lib/datetime_module-cmos_datetime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/datetime_module-cmos_datetime.o `test -f 'lib/cmos_datetime.c' || echo '$(srcdir)/'`lib/cmos_datetime.c
+
+lib/datetime_module-cmos_datetime.obj: lib/cmos_datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/datetime_module-cmos_datetime.obj -MD -MP -MF lib/$(DEPDIR)/datetime_module-cmos_datetime.Tpo -c -o lib/datetime_module-cmos_datetime.obj `if test -f 'lib/cmos_datetime.c'; then $(CYGPATH_W) 'lib/cmos_datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/cmos_datetime.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/datetime_module-cmos_datetime.Tpo lib/$(DEPDIR)/datetime_module-cmos_datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/cmos_datetime.c' object='lib/datetime_module-cmos_datetime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/datetime_module-cmos_datetime.obj `if test -f 'lib/cmos_datetime.c'; then $(CYGPATH_W) 'lib/cmos_datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/cmos_datetime.c'; fi`
+
+lib/xen/datetime_module-datetime.o: lib/xen/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/xen/datetime_module-datetime.o -MD -MP -MF lib/xen/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/xen/datetime_module-datetime.o `test -f 'lib/xen/datetime.c' || echo '$(srcdir)/'`lib/xen/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xen/$(DEPDIR)/datetime_module-datetime.Tpo lib/xen/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xen/datetime.c' object='lib/xen/datetime_module-datetime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/xen/datetime_module-datetime.o `test -f 'lib/xen/datetime.c' || echo '$(srcdir)/'`lib/xen/datetime.c
+
+lib/xen/datetime_module-datetime.obj: lib/xen/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/xen/datetime_module-datetime.obj -MD -MP -MF lib/xen/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/xen/datetime_module-datetime.obj `if test -f 'lib/xen/datetime.c'; then $(CYGPATH_W) 'lib/xen/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/xen/datetime.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xen/$(DEPDIR)/datetime_module-datetime.Tpo lib/xen/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xen/datetime.c' object='lib/xen/datetime_module-datetime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/xen/datetime_module-datetime.obj `if test -f 'lib/xen/datetime.c'; then $(CYGPATH_W) 'lib/xen/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/xen/datetime.c'; fi`
+
+lib/arc/datetime_module-datetime.o: lib/arc/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/arc/datetime_module-datetime.o -MD -MP -MF lib/arc/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/arc/datetime_module-datetime.o `test -f 'lib/arc/datetime.c' || echo '$(srcdir)/'`lib/arc/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/arc/$(DEPDIR)/datetime_module-datetime.Tpo lib/arc/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/arc/datetime.c' object='lib/arc/datetime_module-datetime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/arc/datetime_module-datetime.o `test -f 'lib/arc/datetime.c' || echo '$(srcdir)/'`lib/arc/datetime.c
+
+lib/arc/datetime_module-datetime.obj: lib/arc/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/arc/datetime_module-datetime.obj -MD -MP -MF lib/arc/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/arc/datetime_module-datetime.obj `if test -f 'lib/arc/datetime.c'; then $(CYGPATH_W) 'lib/arc/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/arc/datetime.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/arc/$(DEPDIR)/datetime_module-datetime.Tpo lib/arc/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/arc/datetime.c' object='lib/arc/datetime_module-datetime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/arc/datetime_module-datetime.obj `if test -f 'lib/arc/datetime.c'; then $(CYGPATH_W) 'lib/arc/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/arc/datetime.c'; fi`
+
+lib/ieee1275/datetime_module-datetime.o: lib/ieee1275/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/ieee1275/datetime_module-datetime.o -MD -MP -MF lib/ieee1275/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/ieee1275/datetime_module-datetime.o `test -f 'lib/ieee1275/datetime.c' || echo '$(srcdir)/'`lib/ieee1275/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/ieee1275/$(DEPDIR)/datetime_module-datetime.Tpo lib/ieee1275/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/ieee1275/datetime.c' object='lib/ieee1275/datetime_module-datetime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/ieee1275/datetime_module-datetime.o `test -f 'lib/ieee1275/datetime.c' || echo '$(srcdir)/'`lib/ieee1275/datetime.c
+
+lib/ieee1275/datetime_module-datetime.obj: lib/ieee1275/datetime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/ieee1275/datetime_module-datetime.obj -MD -MP -MF lib/ieee1275/$(DEPDIR)/datetime_module-datetime.Tpo -c -o lib/ieee1275/datetime_module-datetime.obj `if test -f 'lib/ieee1275/datetime.c'; then $(CYGPATH_W) 'lib/ieee1275/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/ieee1275/datetime.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/ieee1275/$(DEPDIR)/datetime_module-datetime.Tpo lib/ieee1275/$(DEPDIR)/datetime_module-datetime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/ieee1275/datetime.c' object='lib/ieee1275/datetime_module-datetime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/ieee1275/datetime_module-datetime.obj `if test -f 'lib/ieee1275/datetime.c'; then $(CYGPATH_W) 'lib/ieee1275/datetime.c'; else $(CYGPATH_W) '$(srcdir)/lib/ieee1275/datetime.c'; fi`
+
+lib/ieee1275/datetime_module-cmos.o: lib/ieee1275/cmos.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/ieee1275/datetime_module-cmos.o -MD -MP -MF lib/ieee1275/$(DEPDIR)/datetime_module-cmos.Tpo -c -o lib/ieee1275/datetime_module-cmos.o `test -f 'lib/ieee1275/cmos.c' || echo '$(srcdir)/'`lib/ieee1275/cmos.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/ieee1275/$(DEPDIR)/datetime_module-cmos.Tpo lib/ieee1275/$(DEPDIR)/datetime_module-cmos.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/ieee1275/cmos.c' object='lib/ieee1275/datetime_module-cmos.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/ieee1275/datetime_module-cmos.o `test -f 'lib/ieee1275/cmos.c' || echo '$(srcdir)/'`lib/ieee1275/cmos.c
+
+lib/ieee1275/datetime_module-cmos.obj: lib/ieee1275/cmos.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -MT lib/ieee1275/datetime_module-cmos.obj -MD -MP -MF lib/ieee1275/$(DEPDIR)/datetime_module-cmos.Tpo -c -o lib/ieee1275/datetime_module-cmos.obj `if test -f 'lib/ieee1275/cmos.c'; then $(CYGPATH_W) 'lib/ieee1275/cmos.c'; else $(CYGPATH_W) '$(srcdir)/lib/ieee1275/cmos.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/ieee1275/$(DEPDIR)/datetime_module-cmos.Tpo lib/ieee1275/$(DEPDIR)/datetime_module-cmos.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/ieee1275/cmos.c' object='lib/ieee1275/datetime_module-cmos.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $(datetime_module_CFLAGS) $(CFLAGS) -c -o lib/ieee1275/datetime_module-cmos.obj `if test -f 'lib/ieee1275/cmos.c'; then $(CYGPATH_W) 'lib/ieee1275/cmos.c'; else $(CYGPATH_W) '$(srcdir)/lib/ieee1275/cmos.c'; fi`
+
+lib/disk_module-disk.o: lib/disk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(disk_module_CPPFLAGS) $(CPPFLAGS) $(disk_module_CFLAGS) $(CFLAGS) -MT lib/disk_module-disk.o -MD -MP -MF lib/$(DEPDIR)/disk_module-disk.Tpo -c -o lib/disk_module-disk.o `test -f 'lib/disk.c' || echo '$(srcdir)/'`lib/disk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/disk_module-disk.Tpo lib/$(DEPDIR)/disk_module-disk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/disk.c' object='lib/disk_module-disk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(disk_module_CPPFLAGS) $(CPPFLAGS) $(disk_module_CFLAGS) $(CFLAGS) -c -o lib/disk_module-disk.o `test -f 'lib/disk.c' || echo '$(srcdir)/'`lib/disk.c
+
+lib/disk_module-disk.obj: lib/disk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(disk_module_CPPFLAGS) $(CPPFLAGS) $(disk_module_CFLAGS) $(CFLAGS) -MT lib/disk_module-disk.obj -MD -MP -MF lib/$(DEPDIR)/disk_module-disk.Tpo -c -o lib/disk_module-disk.obj `if test -f 'lib/disk.c'; then $(CYGPATH_W) 'lib/disk.c'; else $(CYGPATH_W) '$(srcdir)/lib/disk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/disk_module-disk.Tpo lib/$(DEPDIR)/disk_module-disk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/disk.c' object='lib/disk_module-disk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(disk_module_CPPFLAGS) $(CPPFLAGS) $(disk_module_CFLAGS) $(CFLAGS) -c -o lib/disk_module-disk.obj `if test -f 'lib/disk.c'; then $(CYGPATH_W) 'lib/disk.c'; else $(CYGPATH_W) '$(srcdir)/lib/disk.c'; fi`
+
+disk/diskfilter_module-diskfilter.o: disk/diskfilter.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskfilter_module_CPPFLAGS) $(CPPFLAGS) $(diskfilter_module_CFLAGS) $(CFLAGS) -MT disk/diskfilter_module-diskfilter.o -MD -MP -MF disk/$(DEPDIR)/diskfilter_module-diskfilter.Tpo -c -o disk/diskfilter_module-diskfilter.o `test -f 'disk/diskfilter.c' || echo '$(srcdir)/'`disk/diskfilter.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/diskfilter_module-diskfilter.Tpo disk/$(DEPDIR)/diskfilter_module-diskfilter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/diskfilter.c' object='disk/diskfilter_module-diskfilter.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskfilter_module_CPPFLAGS) $(CPPFLAGS) $(diskfilter_module_CFLAGS) $(CFLAGS) -c -o disk/diskfilter_module-diskfilter.o `test -f 'disk/diskfilter.c' || echo '$(srcdir)/'`disk/diskfilter.c
+
+disk/diskfilter_module-diskfilter.obj: disk/diskfilter.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskfilter_module_CPPFLAGS) $(CPPFLAGS) $(diskfilter_module_CFLAGS) $(CFLAGS) -MT disk/diskfilter_module-diskfilter.obj -MD -MP -MF disk/$(DEPDIR)/diskfilter_module-diskfilter.Tpo -c -o disk/diskfilter_module-diskfilter.obj `if test -f 'disk/diskfilter.c'; then $(CYGPATH_W) 'disk/diskfilter.c'; else $(CYGPATH_W) '$(srcdir)/disk/diskfilter.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/diskfilter_module-diskfilter.Tpo disk/$(DEPDIR)/diskfilter_module-diskfilter.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/diskfilter.c' object='disk/diskfilter_module-diskfilter.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskfilter_module_CPPFLAGS) $(CPPFLAGS) $(diskfilter_module_CFLAGS) $(CFLAGS) -c -o disk/diskfilter_module-diskfilter.obj `if test -f 'disk/diskfilter.c'; then $(CYGPATH_W) 'disk/diskfilter.c'; else $(CYGPATH_W) '$(srcdir)/disk/diskfilter.c'; fi`
+
+lib/div_module-division.o: lib/division.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $(div_module_CFLAGS) $(CFLAGS) -MT lib/div_module-division.o -MD -MP -MF lib/$(DEPDIR)/div_module-division.Tpo -c -o lib/div_module-division.o `test -f 'lib/division.c' || echo '$(srcdir)/'`lib/division.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/div_module-division.Tpo lib/$(DEPDIR)/div_module-division.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/division.c' object='lib/div_module-division.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $(div_module_CFLAGS) $(CFLAGS) -c -o lib/div_module-division.o `test -f 'lib/division.c' || echo '$(srcdir)/'`lib/division.c
+
+lib/div_module-division.obj: lib/division.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $(div_module_CFLAGS) $(CFLAGS) -MT lib/div_module-division.obj -MD -MP -MF lib/$(DEPDIR)/div_module-division.Tpo -c -o lib/div_module-division.obj `if test -f 'lib/division.c'; then $(CYGPATH_W) 'lib/division.c'; else $(CYGPATH_W) '$(srcdir)/lib/division.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/div_module-division.Tpo lib/$(DEPDIR)/div_module-division.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/division.c' object='lib/div_module-division.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $(div_module_CFLAGS) $(CFLAGS) -c -o lib/div_module-division.obj `if test -f 'lib/division.c'; then $(CYGPATH_W) 'lib/division.c'; else $(CYGPATH_W) '$(srcdir)/lib/division.c'; fi`
+
+tests/div_test_module-div_test.o: tests/div_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_test_module_CPPFLAGS) $(CPPFLAGS) $(div_test_module_CFLAGS) $(CFLAGS) -MT tests/div_test_module-div_test.o -MD -MP -MF tests/$(DEPDIR)/div_test_module-div_test.Tpo -c -o tests/div_test_module-div_test.o `test -f 'tests/div_test.c' || echo '$(srcdir)/'`tests/div_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/div_test_module-div_test.Tpo tests/$(DEPDIR)/div_test_module-div_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/div_test.c' object='tests/div_test_module-div_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_test_module_CPPFLAGS) $(CPPFLAGS) $(div_test_module_CFLAGS) $(CFLAGS) -c -o tests/div_test_module-div_test.o `test -f 'tests/div_test.c' || echo '$(srcdir)/'`tests/div_test.c
+
+tests/div_test_module-div_test.obj: tests/div_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_test_module_CPPFLAGS) $(CPPFLAGS) $(div_test_module_CFLAGS) $(CFLAGS) -MT tests/div_test_module-div_test.obj -MD -MP -MF tests/$(DEPDIR)/div_test_module-div_test.Tpo -c -o tests/div_test_module-div_test.obj `if test -f 'tests/div_test.c'; then $(CYGPATH_W) 'tests/div_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/div_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/div_test_module-div_test.Tpo tests/$(DEPDIR)/div_test_module-div_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/div_test.c' object='tests/div_test_module-div_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_test_module_CPPFLAGS) $(CPPFLAGS) $(div_test_module_CFLAGS) $(CFLAGS) -c -o tests/div_test_module-div_test.obj `if test -f 'tests/div_test.c'; then $(CYGPATH_W) 'tests/div_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/div_test.c'; fi`
+
+disk/dm_nv_module-dmraid_nvidia.o: disk/dmraid_nvidia.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dm_nv_module_CPPFLAGS) $(CPPFLAGS) $(dm_nv_module_CFLAGS) $(CFLAGS) -MT disk/dm_nv_module-dmraid_nvidia.o -MD -MP -MF disk/$(DEPDIR)/dm_nv_module-dmraid_nvidia.Tpo -c -o disk/dm_nv_module-dmraid_nvidia.o `test -f 'disk/dmraid_nvidia.c' || echo '$(srcdir)/'`disk/dmraid_nvidia.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/dm_nv_module-dmraid_nvidia.Tpo disk/$(DEPDIR)/dm_nv_module-dmraid_nvidia.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/dmraid_nvidia.c' object='disk/dm_nv_module-dmraid_nvidia.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dm_nv_module_CPPFLAGS) $(CPPFLAGS) $(dm_nv_module_CFLAGS) $(CFLAGS) -c -o disk/dm_nv_module-dmraid_nvidia.o `test -f 'disk/dmraid_nvidia.c' || echo '$(srcdir)/'`disk/dmraid_nvidia.c
+
+disk/dm_nv_module-dmraid_nvidia.obj: disk/dmraid_nvidia.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dm_nv_module_CPPFLAGS) $(CPPFLAGS) $(dm_nv_module_CFLAGS) $(CFLAGS) -MT disk/dm_nv_module-dmraid_nvidia.obj -MD -MP -MF disk/$(DEPDIR)/dm_nv_module-dmraid_nvidia.Tpo -c -o disk/dm_nv_module-dmraid_nvidia.obj `if test -f 'disk/dmraid_nvidia.c'; then $(CYGPATH_W) 'disk/dmraid_nvidia.c'; else $(CYGPATH_W) '$(srcdir)/disk/dmraid_nvidia.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/dm_nv_module-dmraid_nvidia.Tpo disk/$(DEPDIR)/dm_nv_module-dmraid_nvidia.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/dmraid_nvidia.c' object='disk/dm_nv_module-dmraid_nvidia.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dm_nv_module_CPPFLAGS) $(CPPFLAGS) $(dm_nv_module_CFLAGS) $(CFLAGS) -c -o disk/dm_nv_module-dmraid_nvidia.obj `if test -f 'disk/dmraid_nvidia.c'; then $(CYGPATH_W) 'disk/dmraid_nvidia.c'; else $(CYGPATH_W) '$(srcdir)/disk/dmraid_nvidia.c'; fi`
+
+commands/i386/pc/drivemap_module-drivemap.o: commands/i386/pc/drivemap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(drivemap_module_CPPFLAGS) $(CPPFLAGS) $(drivemap_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/drivemap_module-drivemap.o -MD -MP -MF commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap.Tpo -c -o commands/i386/pc/drivemap_module-drivemap.o `test -f 'commands/i386/pc/drivemap.c' || echo '$(srcdir)/'`commands/i386/pc/drivemap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap.Tpo commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/drivemap.c' object='commands/i386/pc/drivemap_module-drivemap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(drivemap_module_CPPFLAGS) $(CPPFLAGS) $(drivemap_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/drivemap_module-drivemap.o `test -f 'commands/i386/pc/drivemap.c' || echo '$(srcdir)/'`commands/i386/pc/drivemap.c
+
+commands/i386/pc/drivemap_module-drivemap.obj: commands/i386/pc/drivemap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(drivemap_module_CPPFLAGS) $(CPPFLAGS) $(drivemap_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/drivemap_module-drivemap.obj -MD -MP -MF commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap.Tpo -c -o commands/i386/pc/drivemap_module-drivemap.obj `if test -f 'commands/i386/pc/drivemap.c'; then $(CYGPATH_W) 'commands/i386/pc/drivemap.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/drivemap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap.Tpo commands/i386/pc/$(DEPDIR)/drivemap_module-drivemap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/drivemap.c' object='commands/i386/pc/drivemap_module-drivemap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(drivemap_module_CPPFLAGS) $(CPPFLAGS) $(drivemap_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/drivemap_module-drivemap.obj `if test -f 'commands/i386/pc/drivemap.c'; then $(CYGPATH_W) 'commands/i386/pc/drivemap.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/drivemap.c'; fi`
+
+commands/echo_module-echo.o: commands/echo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(echo_module_CPPFLAGS) $(CPPFLAGS) $(echo_module_CFLAGS) $(CFLAGS) -MT commands/echo_module-echo.o -MD -MP -MF commands/$(DEPDIR)/echo_module-echo.Tpo -c -o commands/echo_module-echo.o `test -f 'commands/echo.c' || echo '$(srcdir)/'`commands/echo.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/echo_module-echo.Tpo commands/$(DEPDIR)/echo_module-echo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/echo.c' object='commands/echo_module-echo.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(echo_module_CPPFLAGS) $(CPPFLAGS) $(echo_module_CFLAGS) $(CFLAGS) -c -o commands/echo_module-echo.o `test -f 'commands/echo.c' || echo '$(srcdir)/'`commands/echo.c
+
+commands/echo_module-echo.obj: commands/echo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(echo_module_CPPFLAGS) $(CPPFLAGS) $(echo_module_CFLAGS) $(CFLAGS) -MT commands/echo_module-echo.obj -MD -MP -MF commands/$(DEPDIR)/echo_module-echo.Tpo -c -o commands/echo_module-echo.obj `if test -f 'commands/echo.c'; then $(CYGPATH_W) 'commands/echo.c'; else $(CYGPATH_W) '$(srcdir)/commands/echo.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/echo_module-echo.Tpo commands/$(DEPDIR)/echo_module-echo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/echo.c' object='commands/echo_module-echo.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(echo_module_CPPFLAGS) $(CPPFLAGS) $(echo_module_CFLAGS) $(CFLAGS) -c -o commands/echo_module-echo.obj `if test -f 'commands/echo.c'; then $(CYGPATH_W) 'commands/echo.c'; else $(CYGPATH_W) '$(srcdir)/commands/echo.c'; fi`
+
+video/efi_gop_module-efi_gop.o: video/efi_gop.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $(efi_gop_module_CFLAGS) $(CFLAGS) -MT video/efi_gop_module-efi_gop.o -MD -MP -MF video/$(DEPDIR)/efi_gop_module-efi_gop.Tpo -c -o video/efi_gop_module-efi_gop.o `test -f 'video/efi_gop.c' || echo '$(srcdir)/'`video/efi_gop.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/efi_gop_module-efi_gop.Tpo video/$(DEPDIR)/efi_gop_module-efi_gop.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/efi_gop.c' object='video/efi_gop_module-efi_gop.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $(efi_gop_module_CFLAGS) $(CFLAGS) -c -o video/efi_gop_module-efi_gop.o `test -f 'video/efi_gop.c' || echo '$(srcdir)/'`video/efi_gop.c
+
+video/efi_gop_module-efi_gop.obj: video/efi_gop.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $(efi_gop_module_CFLAGS) $(CFLAGS) -MT video/efi_gop_module-efi_gop.obj -MD -MP -MF video/$(DEPDIR)/efi_gop_module-efi_gop.Tpo -c -o video/efi_gop_module-efi_gop.obj `if test -f 'video/efi_gop.c'; then $(CYGPATH_W) 'video/efi_gop.c'; else $(CYGPATH_W) '$(srcdir)/video/efi_gop.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/efi_gop_module-efi_gop.Tpo video/$(DEPDIR)/efi_gop_module-efi_gop.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/efi_gop.c' object='video/efi_gop_module-efi_gop.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $(efi_gop_module_CFLAGS) $(CFLAGS) -c -o video/efi_gop_module-efi_gop.obj `if test -f 'video/efi_gop.c'; then $(CYGPATH_W) 'video/efi_gop.c'; else $(CYGPATH_W) '$(srcdir)/video/efi_gop.c'; fi`
+
+video/efi_uga_module-efi_uga.o: video/efi_uga.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_uga_module_CPPFLAGS) $(CPPFLAGS) $(efi_uga_module_CFLAGS) $(CFLAGS) -MT video/efi_uga_module-efi_uga.o -MD -MP -MF video/$(DEPDIR)/efi_uga_module-efi_uga.Tpo -c -o video/efi_uga_module-efi_uga.o `test -f 'video/efi_uga.c' || echo '$(srcdir)/'`video/efi_uga.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/efi_uga_module-efi_uga.Tpo video/$(DEPDIR)/efi_uga_module-efi_uga.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/efi_uga.c' object='video/efi_uga_module-efi_uga.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_uga_module_CPPFLAGS) $(CPPFLAGS) $(efi_uga_module_CFLAGS) $(CFLAGS) -c -o video/efi_uga_module-efi_uga.o `test -f 'video/efi_uga.c' || echo '$(srcdir)/'`video/efi_uga.c
+
+video/efi_uga_module-efi_uga.obj: video/efi_uga.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_uga_module_CPPFLAGS) $(CPPFLAGS) $(efi_uga_module_CFLAGS) $(CFLAGS) -MT video/efi_uga_module-efi_uga.obj -MD -MP -MF video/$(DEPDIR)/efi_uga_module-efi_uga.Tpo -c -o video/efi_uga_module-efi_uga.obj `if test -f 'video/efi_uga.c'; then $(CYGPATH_W) 'video/efi_uga.c'; else $(CYGPATH_W) '$(srcdir)/video/efi_uga.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/efi_uga_module-efi_uga.Tpo video/$(DEPDIR)/efi_uga_module-efi_uga.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/efi_uga.c' object='video/efi_uga_module-efi_uga.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_uga_module_CPPFLAGS) $(CPPFLAGS) $(efi_uga_module_CFLAGS) $(CFLAGS) -c -o video/efi_uga_module-efi_uga.obj `if test -f 'video/efi_uga.c'; then $(CYGPATH_W) 'video/efi_uga.c'; else $(CYGPATH_W) '$(srcdir)/video/efi_uga.c'; fi`
+
+efiemu/i386/pc/efiemu_module-cfgtables.o: efiemu/i386/pc/cfgtables.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/i386/pc/efiemu_module-cfgtables.o -MD -MP -MF efiemu/i386/pc/$(DEPDIR)/efiemu_module-cfgtables.Tpo -c -o efiemu/i386/pc/efiemu_module-cfgtables.o `test -f 'efiemu/i386/pc/cfgtables.c' || echo '$(srcdir)/'`efiemu/i386/pc/cfgtables.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/i386/pc/$(DEPDIR)/efiemu_module-cfgtables.Tpo efiemu/i386/pc/$(DEPDIR)/efiemu_module-cfgtables.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/i386/pc/cfgtables.c' object='efiemu/i386/pc/efiemu_module-cfgtables.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/i386/pc/efiemu_module-cfgtables.o `test -f 'efiemu/i386/pc/cfgtables.c' || echo '$(srcdir)/'`efiemu/i386/pc/cfgtables.c
+
+efiemu/i386/pc/efiemu_module-cfgtables.obj: efiemu/i386/pc/cfgtables.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/i386/pc/efiemu_module-cfgtables.obj -MD -MP -MF efiemu/i386/pc/$(DEPDIR)/efiemu_module-cfgtables.Tpo -c -o efiemu/i386/pc/efiemu_module-cfgtables.obj `if test -f 'efiemu/i386/pc/cfgtables.c'; then $(CYGPATH_W) 'efiemu/i386/pc/cfgtables.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/i386/pc/cfgtables.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/i386/pc/$(DEPDIR)/efiemu_module-cfgtables.Tpo efiemu/i386/pc/$(DEPDIR)/efiemu_module-cfgtables.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/i386/pc/cfgtables.c' object='efiemu/i386/pc/efiemu_module-cfgtables.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/i386/pc/efiemu_module-cfgtables.obj `if test -f 'efiemu/i386/pc/cfgtables.c'; then $(CYGPATH_W) 'efiemu/i386/pc/cfgtables.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/i386/pc/cfgtables.c'; fi`
+
+efiemu/efiemu_module-main.o: efiemu/main.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-main.o -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-main.Tpo -c -o efiemu/efiemu_module-main.o `test -f 'efiemu/main.c' || echo '$(srcdir)/'`efiemu/main.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-main.Tpo efiemu/$(DEPDIR)/efiemu_module-main.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/main.c' object='efiemu/efiemu_module-main.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-main.o `test -f 'efiemu/main.c' || echo '$(srcdir)/'`efiemu/main.c
+
+efiemu/efiemu_module-main.obj: efiemu/main.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-main.obj -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-main.Tpo -c -o efiemu/efiemu_module-main.obj `if test -f 'efiemu/main.c'; then $(CYGPATH_W) 'efiemu/main.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/main.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-main.Tpo efiemu/$(DEPDIR)/efiemu_module-main.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/main.c' object='efiemu/efiemu_module-main.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-main.obj `if test -f 'efiemu/main.c'; then $(CYGPATH_W) 'efiemu/main.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/main.c'; fi`
+
+efiemu/i386/efiemu_module-loadcore32.o: efiemu/i386/loadcore32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/i386/efiemu_module-loadcore32.o -MD -MP -MF efiemu/i386/$(DEPDIR)/efiemu_module-loadcore32.Tpo -c -o efiemu/i386/efiemu_module-loadcore32.o `test -f 'efiemu/i386/loadcore32.c' || echo '$(srcdir)/'`efiemu/i386/loadcore32.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/i386/$(DEPDIR)/efiemu_module-loadcore32.Tpo efiemu/i386/$(DEPDIR)/efiemu_module-loadcore32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/i386/loadcore32.c' object='efiemu/i386/efiemu_module-loadcore32.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/i386/efiemu_module-loadcore32.o `test -f 'efiemu/i386/loadcore32.c' || echo '$(srcdir)/'`efiemu/i386/loadcore32.c
+
+efiemu/i386/efiemu_module-loadcore32.obj: efiemu/i386/loadcore32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/i386/efiemu_module-loadcore32.obj -MD -MP -MF efiemu/i386/$(DEPDIR)/efiemu_module-loadcore32.Tpo -c -o efiemu/i386/efiemu_module-loadcore32.obj `if test -f 'efiemu/i386/loadcore32.c'; then $(CYGPATH_W) 'efiemu/i386/loadcore32.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/i386/loadcore32.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/i386/$(DEPDIR)/efiemu_module-loadcore32.Tpo efiemu/i386/$(DEPDIR)/efiemu_module-loadcore32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/i386/loadcore32.c' object='efiemu/i386/efiemu_module-loadcore32.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/i386/efiemu_module-loadcore32.obj `if test -f 'efiemu/i386/loadcore32.c'; then $(CYGPATH_W) 'efiemu/i386/loadcore32.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/i386/loadcore32.c'; fi`
+
+efiemu/i386/efiemu_module-loadcore64.o: efiemu/i386/loadcore64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/i386/efiemu_module-loadcore64.o -MD -MP -MF efiemu/i386/$(DEPDIR)/efiemu_module-loadcore64.Tpo -c -o efiemu/i386/efiemu_module-loadcore64.o `test -f 'efiemu/i386/loadcore64.c' || echo '$(srcdir)/'`efiemu/i386/loadcore64.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/i386/$(DEPDIR)/efiemu_module-loadcore64.Tpo efiemu/i386/$(DEPDIR)/efiemu_module-loadcore64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/i386/loadcore64.c' object='efiemu/i386/efiemu_module-loadcore64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/i386/efiemu_module-loadcore64.o `test -f 'efiemu/i386/loadcore64.c' || echo '$(srcdir)/'`efiemu/i386/loadcore64.c
+
+efiemu/i386/efiemu_module-loadcore64.obj: efiemu/i386/loadcore64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/i386/efiemu_module-loadcore64.obj -MD -MP -MF efiemu/i386/$(DEPDIR)/efiemu_module-loadcore64.Tpo -c -o efiemu/i386/efiemu_module-loadcore64.obj `if test -f 'efiemu/i386/loadcore64.c'; then $(CYGPATH_W) 'efiemu/i386/loadcore64.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/i386/loadcore64.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/i386/$(DEPDIR)/efiemu_module-loadcore64.Tpo efiemu/i386/$(DEPDIR)/efiemu_module-loadcore64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/i386/loadcore64.c' object='efiemu/i386/efiemu_module-loadcore64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/i386/efiemu_module-loadcore64.obj `if test -f 'efiemu/i386/loadcore64.c'; then $(CYGPATH_W) 'efiemu/i386/loadcore64.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/i386/loadcore64.c'; fi`
+
+efiemu/efiemu_module-mm.o: efiemu/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-mm.o -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-mm.Tpo -c -o efiemu/efiemu_module-mm.o `test -f 'efiemu/mm.c' || echo '$(srcdir)/'`efiemu/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-mm.Tpo efiemu/$(DEPDIR)/efiemu_module-mm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/mm.c' object='efiemu/efiemu_module-mm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-mm.o `test -f 'efiemu/mm.c' || echo '$(srcdir)/'`efiemu/mm.c
+
+efiemu/efiemu_module-mm.obj: efiemu/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-mm.obj -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-mm.Tpo -c -o efiemu/efiemu_module-mm.obj `if test -f 'efiemu/mm.c'; then $(CYGPATH_W) 'efiemu/mm.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/mm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-mm.Tpo efiemu/$(DEPDIR)/efiemu_module-mm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/mm.c' object='efiemu/efiemu_module-mm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-mm.obj `if test -f 'efiemu/mm.c'; then $(CYGPATH_W) 'efiemu/mm.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/mm.c'; fi`
+
+efiemu/efiemu_module-loadcore_common.o: efiemu/loadcore_common.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-loadcore_common.o -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-loadcore_common.Tpo -c -o efiemu/efiemu_module-loadcore_common.o `test -f 'efiemu/loadcore_common.c' || echo '$(srcdir)/'`efiemu/loadcore_common.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-loadcore_common.Tpo efiemu/$(DEPDIR)/efiemu_module-loadcore_common.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/loadcore_common.c' object='efiemu/efiemu_module-loadcore_common.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-loadcore_common.o `test -f 'efiemu/loadcore_common.c' || echo '$(srcdir)/'`efiemu/loadcore_common.c
+
+efiemu/efiemu_module-loadcore_common.obj: efiemu/loadcore_common.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-loadcore_common.obj -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-loadcore_common.Tpo -c -o efiemu/efiemu_module-loadcore_common.obj `if test -f 'efiemu/loadcore_common.c'; then $(CYGPATH_W) 'efiemu/loadcore_common.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/loadcore_common.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-loadcore_common.Tpo efiemu/$(DEPDIR)/efiemu_module-loadcore_common.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/loadcore_common.c' object='efiemu/efiemu_module-loadcore_common.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-loadcore_common.obj `if test -f 'efiemu/loadcore_common.c'; then $(CYGPATH_W) 'efiemu/loadcore_common.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/loadcore_common.c'; fi`
+
+efiemu/efiemu_module-symbols.o: efiemu/symbols.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-symbols.o -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-symbols.Tpo -c -o efiemu/efiemu_module-symbols.o `test -f 'efiemu/symbols.c' || echo '$(srcdir)/'`efiemu/symbols.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-symbols.Tpo efiemu/$(DEPDIR)/efiemu_module-symbols.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/symbols.c' object='efiemu/efiemu_module-symbols.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-symbols.o `test -f 'efiemu/symbols.c' || echo '$(srcdir)/'`efiemu/symbols.c
+
+efiemu/efiemu_module-symbols.obj: efiemu/symbols.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-symbols.obj -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-symbols.Tpo -c -o efiemu/efiemu_module-symbols.obj `if test -f 'efiemu/symbols.c'; then $(CYGPATH_W) 'efiemu/symbols.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/symbols.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-symbols.Tpo efiemu/$(DEPDIR)/efiemu_module-symbols.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/symbols.c' object='efiemu/efiemu_module-symbols.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-symbols.obj `if test -f 'efiemu/symbols.c'; then $(CYGPATH_W) 'efiemu/symbols.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/symbols.c'; fi`
+
+efiemu/efiemu_module-loadcore32.o: efiemu/loadcore32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-loadcore32.o -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-loadcore32.Tpo -c -o efiemu/efiemu_module-loadcore32.o `test -f 'efiemu/loadcore32.c' || echo '$(srcdir)/'`efiemu/loadcore32.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-loadcore32.Tpo efiemu/$(DEPDIR)/efiemu_module-loadcore32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/loadcore32.c' object='efiemu/efiemu_module-loadcore32.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-loadcore32.o `test -f 'efiemu/loadcore32.c' || echo '$(srcdir)/'`efiemu/loadcore32.c
+
+efiemu/efiemu_module-loadcore32.obj: efiemu/loadcore32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-loadcore32.obj -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-loadcore32.Tpo -c -o efiemu/efiemu_module-loadcore32.obj `if test -f 'efiemu/loadcore32.c'; then $(CYGPATH_W) 'efiemu/loadcore32.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/loadcore32.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-loadcore32.Tpo efiemu/$(DEPDIR)/efiemu_module-loadcore32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/loadcore32.c' object='efiemu/efiemu_module-loadcore32.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-loadcore32.obj `if test -f 'efiemu/loadcore32.c'; then $(CYGPATH_W) 'efiemu/loadcore32.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/loadcore32.c'; fi`
+
+efiemu/efiemu_module-loadcore64.o: efiemu/loadcore64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-loadcore64.o -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-loadcore64.Tpo -c -o efiemu/efiemu_module-loadcore64.o `test -f 'efiemu/loadcore64.c' || echo '$(srcdir)/'`efiemu/loadcore64.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-loadcore64.Tpo efiemu/$(DEPDIR)/efiemu_module-loadcore64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/loadcore64.c' object='efiemu/efiemu_module-loadcore64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-loadcore64.o `test -f 'efiemu/loadcore64.c' || echo '$(srcdir)/'`efiemu/loadcore64.c
+
+efiemu/efiemu_module-loadcore64.obj: efiemu/loadcore64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-loadcore64.obj -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-loadcore64.Tpo -c -o efiemu/efiemu_module-loadcore64.obj `if test -f 'efiemu/loadcore64.c'; then $(CYGPATH_W) 'efiemu/loadcore64.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/loadcore64.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-loadcore64.Tpo efiemu/$(DEPDIR)/efiemu_module-loadcore64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/loadcore64.c' object='efiemu/efiemu_module-loadcore64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-loadcore64.obj `if test -f 'efiemu/loadcore64.c'; then $(CYGPATH_W) 'efiemu/loadcore64.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/loadcore64.c'; fi`
+
+efiemu/efiemu_module-prepare32.o: efiemu/prepare32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-prepare32.o -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-prepare32.Tpo -c -o efiemu/efiemu_module-prepare32.o `test -f 'efiemu/prepare32.c' || echo '$(srcdir)/'`efiemu/prepare32.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-prepare32.Tpo efiemu/$(DEPDIR)/efiemu_module-prepare32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/prepare32.c' object='efiemu/efiemu_module-prepare32.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-prepare32.o `test -f 'efiemu/prepare32.c' || echo '$(srcdir)/'`efiemu/prepare32.c
+
+efiemu/efiemu_module-prepare32.obj: efiemu/prepare32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-prepare32.obj -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-prepare32.Tpo -c -o efiemu/efiemu_module-prepare32.obj `if test -f 'efiemu/prepare32.c'; then $(CYGPATH_W) 'efiemu/prepare32.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/prepare32.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-prepare32.Tpo efiemu/$(DEPDIR)/efiemu_module-prepare32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/prepare32.c' object='efiemu/efiemu_module-prepare32.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-prepare32.obj `if test -f 'efiemu/prepare32.c'; then $(CYGPATH_W) 'efiemu/prepare32.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/prepare32.c'; fi`
+
+efiemu/efiemu_module-prepare64.o: efiemu/prepare64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-prepare64.o -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-prepare64.Tpo -c -o efiemu/efiemu_module-prepare64.o `test -f 'efiemu/prepare64.c' || echo '$(srcdir)/'`efiemu/prepare64.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-prepare64.Tpo efiemu/$(DEPDIR)/efiemu_module-prepare64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/prepare64.c' object='efiemu/efiemu_module-prepare64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-prepare64.o `test -f 'efiemu/prepare64.c' || echo '$(srcdir)/'`efiemu/prepare64.c
+
+efiemu/efiemu_module-prepare64.obj: efiemu/prepare64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-prepare64.obj -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-prepare64.Tpo -c -o efiemu/efiemu_module-prepare64.obj `if test -f 'efiemu/prepare64.c'; then $(CYGPATH_W) 'efiemu/prepare64.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/prepare64.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-prepare64.Tpo efiemu/$(DEPDIR)/efiemu_module-prepare64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/prepare64.c' object='efiemu/efiemu_module-prepare64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-prepare64.obj `if test -f 'efiemu/prepare64.c'; then $(CYGPATH_W) 'efiemu/prepare64.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/prepare64.c'; fi`
+
+efiemu/efiemu_module-pnvram.o: efiemu/pnvram.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-pnvram.o -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-pnvram.Tpo -c -o efiemu/efiemu_module-pnvram.o `test -f 'efiemu/pnvram.c' || echo '$(srcdir)/'`efiemu/pnvram.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-pnvram.Tpo efiemu/$(DEPDIR)/efiemu_module-pnvram.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/pnvram.c' object='efiemu/efiemu_module-pnvram.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-pnvram.o `test -f 'efiemu/pnvram.c' || echo '$(srcdir)/'`efiemu/pnvram.c
+
+efiemu/efiemu_module-pnvram.obj: efiemu/pnvram.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/efiemu_module-pnvram.obj -MD -MP -MF efiemu/$(DEPDIR)/efiemu_module-pnvram.Tpo -c -o efiemu/efiemu_module-pnvram.obj `if test -f 'efiemu/pnvram.c'; then $(CYGPATH_W) 'efiemu/pnvram.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/pnvram.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/$(DEPDIR)/efiemu_module-pnvram.Tpo efiemu/$(DEPDIR)/efiemu_module-pnvram.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/pnvram.c' object='efiemu/efiemu_module-pnvram.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/efiemu_module-pnvram.obj `if test -f 'efiemu/pnvram.c'; then $(CYGPATH_W) 'efiemu/pnvram.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/pnvram.c'; fi`
+
+efiemu/i386/efiemu_module-coredetect.o: efiemu/i386/coredetect.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/i386/efiemu_module-coredetect.o -MD -MP -MF efiemu/i386/$(DEPDIR)/efiemu_module-coredetect.Tpo -c -o efiemu/i386/efiemu_module-coredetect.o `test -f 'efiemu/i386/coredetect.c' || echo '$(srcdir)/'`efiemu/i386/coredetect.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/i386/$(DEPDIR)/efiemu_module-coredetect.Tpo efiemu/i386/$(DEPDIR)/efiemu_module-coredetect.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/i386/coredetect.c' object='efiemu/i386/efiemu_module-coredetect.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/i386/efiemu_module-coredetect.o `test -f 'efiemu/i386/coredetect.c' || echo '$(srcdir)/'`efiemu/i386/coredetect.c
+
+efiemu/i386/efiemu_module-coredetect.obj: efiemu/i386/coredetect.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/i386/efiemu_module-coredetect.obj -MD -MP -MF efiemu/i386/$(DEPDIR)/efiemu_module-coredetect.Tpo -c -o efiemu/i386/efiemu_module-coredetect.obj `if test -f 'efiemu/i386/coredetect.c'; then $(CYGPATH_W) 'efiemu/i386/coredetect.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/i386/coredetect.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/i386/$(DEPDIR)/efiemu_module-coredetect.Tpo efiemu/i386/$(DEPDIR)/efiemu_module-coredetect.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/i386/coredetect.c' object='efiemu/i386/efiemu_module-coredetect.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/i386/efiemu_module-coredetect.obj `if test -f 'efiemu/i386/coredetect.c'; then $(CYGPATH_W) 'efiemu/i386/coredetect.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/i386/coredetect.c'; fi`
+
+efiemu/i386/efiemu_module-nocfgtables.o: efiemu/i386/nocfgtables.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/i386/efiemu_module-nocfgtables.o -MD -MP -MF efiemu/i386/$(DEPDIR)/efiemu_module-nocfgtables.Tpo -c -o efiemu/i386/efiemu_module-nocfgtables.o `test -f 'efiemu/i386/nocfgtables.c' || echo '$(srcdir)/'`efiemu/i386/nocfgtables.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/i386/$(DEPDIR)/efiemu_module-nocfgtables.Tpo efiemu/i386/$(DEPDIR)/efiemu_module-nocfgtables.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/i386/nocfgtables.c' object='efiemu/i386/efiemu_module-nocfgtables.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/i386/efiemu_module-nocfgtables.o `test -f 'efiemu/i386/nocfgtables.c' || echo '$(srcdir)/'`efiemu/i386/nocfgtables.c
+
+efiemu/i386/efiemu_module-nocfgtables.obj: efiemu/i386/nocfgtables.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -MT efiemu/i386/efiemu_module-nocfgtables.obj -MD -MP -MF efiemu/i386/$(DEPDIR)/efiemu_module-nocfgtables.Tpo -c -o efiemu/i386/efiemu_module-nocfgtables.obj `if test -f 'efiemu/i386/nocfgtables.c'; then $(CYGPATH_W) 'efiemu/i386/nocfgtables.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/i386/nocfgtables.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) efiemu/i386/$(DEPDIR)/efiemu_module-nocfgtables.Tpo efiemu/i386/$(DEPDIR)/efiemu_module-nocfgtables.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='efiemu/i386/nocfgtables.c' object='efiemu/i386/efiemu_module-nocfgtables.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $(efiemu_module_CFLAGS) $(CFLAGS) -c -o efiemu/i386/efiemu_module-nocfgtables.obj `if test -f 'efiemu/i386/nocfgtables.c'; then $(CYGPATH_W) 'efiemu/i386/nocfgtables.c'; else $(CYGPATH_W) '$(srcdir)/efiemu/i386/nocfgtables.c'; fi`
+
+commands/efi/efifwsetup_module-efifwsetup.o: commands/efi/efifwsetup.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $(efifwsetup_module_CFLAGS) $(CFLAGS) -MT commands/efi/efifwsetup_module-efifwsetup.o -MD -MP -MF commands/efi/$(DEPDIR)/efifwsetup_module-efifwsetup.Tpo -c -o commands/efi/efifwsetup_module-efifwsetup.o `test -f 'commands/efi/efifwsetup.c' || echo '$(srcdir)/'`commands/efi/efifwsetup.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/efifwsetup_module-efifwsetup.Tpo commands/efi/$(DEPDIR)/efifwsetup_module-efifwsetup.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/efifwsetup.c' object='commands/efi/efifwsetup_module-efifwsetup.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $(efifwsetup_module_CFLAGS) $(CFLAGS) -c -o commands/efi/efifwsetup_module-efifwsetup.o `test -f 'commands/efi/efifwsetup.c' || echo '$(srcdir)/'`commands/efi/efifwsetup.c
+
+commands/efi/efifwsetup_module-efifwsetup.obj: commands/efi/efifwsetup.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $(efifwsetup_module_CFLAGS) $(CFLAGS) -MT commands/efi/efifwsetup_module-efifwsetup.obj -MD -MP -MF commands/efi/$(DEPDIR)/efifwsetup_module-efifwsetup.Tpo -c -o commands/efi/efifwsetup_module-efifwsetup.obj `if test -f 'commands/efi/efifwsetup.c'; then $(CYGPATH_W) 'commands/efi/efifwsetup.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/efifwsetup.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/efifwsetup_module-efifwsetup.Tpo commands/efi/$(DEPDIR)/efifwsetup_module-efifwsetup.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/efifwsetup.c' object='commands/efi/efifwsetup_module-efifwsetup.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $(efifwsetup_module_CFLAGS) $(CFLAGS) -c -o commands/efi/efifwsetup_module-efifwsetup.obj `if test -f 'commands/efi/efifwsetup.c'; then $(CYGPATH_W) 'commands/efi/efifwsetup.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/efifwsetup.c'; fi`
+
+net/drivers/efi/efinet_module-efinet.o: net/drivers/efi/efinet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $(efinet_module_CFLAGS) $(CFLAGS) -MT net/drivers/efi/efinet_module-efinet.o -MD -MP -MF net/drivers/efi/$(DEPDIR)/efinet_module-efinet.Tpo -c -o net/drivers/efi/efinet_module-efinet.o `test -f 'net/drivers/efi/efinet.c' || echo '$(srcdir)/'`net/drivers/efi/efinet.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/drivers/efi/$(DEPDIR)/efinet_module-efinet.Tpo net/drivers/efi/$(DEPDIR)/efinet_module-efinet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/drivers/efi/efinet.c' object='net/drivers/efi/efinet_module-efinet.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $(efinet_module_CFLAGS) $(CFLAGS) -c -o net/drivers/efi/efinet_module-efinet.o `test -f 'net/drivers/efi/efinet.c' || echo '$(srcdir)/'`net/drivers/efi/efinet.c
+
+net/drivers/efi/efinet_module-efinet.obj: net/drivers/efi/efinet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $(efinet_module_CFLAGS) $(CFLAGS) -MT net/drivers/efi/efinet_module-efinet.obj -MD -MP -MF net/drivers/efi/$(DEPDIR)/efinet_module-efinet.Tpo -c -o net/drivers/efi/efinet_module-efinet.obj `if test -f 'net/drivers/efi/efinet.c'; then $(CYGPATH_W) 'net/drivers/efi/efinet.c'; else $(CYGPATH_W) '$(srcdir)/net/drivers/efi/efinet.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/drivers/efi/$(DEPDIR)/efinet_module-efinet.Tpo net/drivers/efi/$(DEPDIR)/efinet_module-efinet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/drivers/efi/efinet.c' object='net/drivers/efi/efinet_module-efinet.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $(efinet_module_CFLAGS) $(CFLAGS) -c -o net/drivers/efi/efinet_module-efinet.obj `if test -f 'net/drivers/efi/efinet.c'; then $(CYGPATH_W) 'net/drivers/efi/efinet.c'; else $(CYGPATH_W) '$(srcdir)/net/drivers/efi/efinet.c'; fi`
+
+bus/usb/ehci_module-ehci-fdt.o: bus/usb/ehci-fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -MT bus/usb/ehci_module-ehci-fdt.o -MD -MP -MF bus/usb/$(DEPDIR)/ehci_module-ehci-fdt.Tpo -c -o bus/usb/ehci_module-ehci-fdt.o `test -f 'bus/usb/ehci-fdt.c' || echo '$(srcdir)/'`bus/usb/ehci-fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/ehci_module-ehci-fdt.Tpo bus/usb/$(DEPDIR)/ehci_module-ehci-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/ehci-fdt.c' object='bus/usb/ehci_module-ehci-fdt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -c -o bus/usb/ehci_module-ehci-fdt.o `test -f 'bus/usb/ehci-fdt.c' || echo '$(srcdir)/'`bus/usb/ehci-fdt.c
+
+bus/usb/ehci_module-ehci-fdt.obj: bus/usb/ehci-fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -MT bus/usb/ehci_module-ehci-fdt.obj -MD -MP -MF bus/usb/$(DEPDIR)/ehci_module-ehci-fdt.Tpo -c -o bus/usb/ehci_module-ehci-fdt.obj `if test -f 'bus/usb/ehci-fdt.c'; then $(CYGPATH_W) 'bus/usb/ehci-fdt.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/ehci-fdt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/ehci_module-ehci-fdt.Tpo bus/usb/$(DEPDIR)/ehci_module-ehci-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/ehci-fdt.c' object='bus/usb/ehci_module-ehci-fdt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -c -o bus/usb/ehci_module-ehci-fdt.obj `if test -f 'bus/usb/ehci-fdt.c'; then $(CYGPATH_W) 'bus/usb/ehci-fdt.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/ehci-fdt.c'; fi`
+
+bus/usb/ehci_module-ehci.o: bus/usb/ehci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -MT bus/usb/ehci_module-ehci.o -MD -MP -MF bus/usb/$(DEPDIR)/ehci_module-ehci.Tpo -c -o bus/usb/ehci_module-ehci.o `test -f 'bus/usb/ehci.c' || echo '$(srcdir)/'`bus/usb/ehci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/ehci_module-ehci.Tpo bus/usb/$(DEPDIR)/ehci_module-ehci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/ehci.c' object='bus/usb/ehci_module-ehci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -c -o bus/usb/ehci_module-ehci.o `test -f 'bus/usb/ehci.c' || echo '$(srcdir)/'`bus/usb/ehci.c
+
+bus/usb/ehci_module-ehci.obj: bus/usb/ehci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -MT bus/usb/ehci_module-ehci.obj -MD -MP -MF bus/usb/$(DEPDIR)/ehci_module-ehci.Tpo -c -o bus/usb/ehci_module-ehci.obj `if test -f 'bus/usb/ehci.c'; then $(CYGPATH_W) 'bus/usb/ehci.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/ehci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/ehci_module-ehci.Tpo bus/usb/$(DEPDIR)/ehci_module-ehci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/ehci.c' object='bus/usb/ehci_module-ehci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -c -o bus/usb/ehci_module-ehci.obj `if test -f 'bus/usb/ehci.c'; then $(CYGPATH_W) 'bus/usb/ehci.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/ehci.c'; fi`
+
+bus/usb/ehci_module-ehci-pci.o: bus/usb/ehci-pci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -MT bus/usb/ehci_module-ehci-pci.o -MD -MP -MF bus/usb/$(DEPDIR)/ehci_module-ehci-pci.Tpo -c -o bus/usb/ehci_module-ehci-pci.o `test -f 'bus/usb/ehci-pci.c' || echo '$(srcdir)/'`bus/usb/ehci-pci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/ehci_module-ehci-pci.Tpo bus/usb/$(DEPDIR)/ehci_module-ehci-pci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/ehci-pci.c' object='bus/usb/ehci_module-ehci-pci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -c -o bus/usb/ehci_module-ehci-pci.o `test -f 'bus/usb/ehci-pci.c' || echo '$(srcdir)/'`bus/usb/ehci-pci.c
+
+bus/usb/ehci_module-ehci-pci.obj: bus/usb/ehci-pci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -MT bus/usb/ehci_module-ehci-pci.obj -MD -MP -MF bus/usb/$(DEPDIR)/ehci_module-ehci-pci.Tpo -c -o bus/usb/ehci_module-ehci-pci.obj `if test -f 'bus/usb/ehci-pci.c'; then $(CYGPATH_W) 'bus/usb/ehci-pci.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/ehci-pci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/ehci_module-ehci-pci.Tpo bus/usb/$(DEPDIR)/ehci_module-ehci-pci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/ehci-pci.c' object='bus/usb/ehci_module-ehci-pci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $(ehci_module_CFLAGS) $(CFLAGS) -c -o bus/usb/ehci_module-ehci-pci.obj `if test -f 'bus/usb/ehci-pci.c'; then $(CYGPATH_W) 'bus/usb/ehci-pci.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/ehci-pci.c'; fi`
+
+kern/elf_module-elf.o: kern/elf.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elf_module_CPPFLAGS) $(CPPFLAGS) $(elf_module_CFLAGS) $(CFLAGS) -MT kern/elf_module-elf.o -MD -MP -MF kern/$(DEPDIR)/elf_module-elf.Tpo -c -o kern/elf_module-elf.o `test -f 'kern/elf.c' || echo '$(srcdir)/'`kern/elf.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/elf_module-elf.Tpo kern/$(DEPDIR)/elf_module-elf.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/elf.c' object='kern/elf_module-elf.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elf_module_CPPFLAGS) $(CPPFLAGS) $(elf_module_CFLAGS) $(CFLAGS) -c -o kern/elf_module-elf.o `test -f 'kern/elf.c' || echo '$(srcdir)/'`kern/elf.c
+
+kern/elf_module-elf.obj: kern/elf.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elf_module_CPPFLAGS) $(CPPFLAGS) $(elf_module_CFLAGS) $(CFLAGS) -MT kern/elf_module-elf.obj -MD -MP -MF kern/$(DEPDIR)/elf_module-elf.Tpo -c -o kern/elf_module-elf.obj `if test -f 'kern/elf.c'; then $(CYGPATH_W) 'kern/elf.c'; else $(CYGPATH_W) '$(srcdir)/kern/elf.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/elf_module-elf.Tpo kern/$(DEPDIR)/elf_module-elf.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/elf.c' object='kern/elf_module-elf.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elf_module_CPPFLAGS) $(CPPFLAGS) $(elf_module_CFLAGS) $(CFLAGS) -c -o kern/elf_module-elf.obj `if test -f 'kern/elf.c'; then $(CYGPATH_W) 'kern/elf.c'; else $(CYGPATH_W) '$(srcdir)/kern/elf.c'; fi`
+
+net/drivers/emu/emunet_module-emunet.o: net/drivers/emu/emunet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emunet_module_CPPFLAGS) $(CPPFLAGS) $(emunet_module_CFLAGS) $(CFLAGS) -MT net/drivers/emu/emunet_module-emunet.o -MD -MP -MF net/drivers/emu/$(DEPDIR)/emunet_module-emunet.Tpo -c -o net/drivers/emu/emunet_module-emunet.o `test -f 'net/drivers/emu/emunet.c' || echo '$(srcdir)/'`net/drivers/emu/emunet.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/drivers/emu/$(DEPDIR)/emunet_module-emunet.Tpo net/drivers/emu/$(DEPDIR)/emunet_module-emunet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/drivers/emu/emunet.c' object='net/drivers/emu/emunet_module-emunet.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emunet_module_CPPFLAGS) $(CPPFLAGS) $(emunet_module_CFLAGS) $(CFLAGS) -c -o net/drivers/emu/emunet_module-emunet.o `test -f 'net/drivers/emu/emunet.c' || echo '$(srcdir)/'`net/drivers/emu/emunet.c
+
+net/drivers/emu/emunet_module-emunet.obj: net/drivers/emu/emunet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emunet_module_CPPFLAGS) $(CPPFLAGS) $(emunet_module_CFLAGS) $(CFLAGS) -MT net/drivers/emu/emunet_module-emunet.obj -MD -MP -MF net/drivers/emu/$(DEPDIR)/emunet_module-emunet.Tpo -c -o net/drivers/emu/emunet_module-emunet.obj `if test -f 'net/drivers/emu/emunet.c'; then $(CYGPATH_W) 'net/drivers/emu/emunet.c'; else $(CYGPATH_W) '$(srcdir)/net/drivers/emu/emunet.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/drivers/emu/$(DEPDIR)/emunet_module-emunet.Tpo net/drivers/emu/$(DEPDIR)/emunet_module-emunet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/drivers/emu/emunet.c' object='net/drivers/emu/emunet_module-emunet.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emunet_module_CPPFLAGS) $(CPPFLAGS) $(emunet_module_CFLAGS) $(CFLAGS) -c -o net/drivers/emu/emunet_module-emunet.obj `if test -f 'net/drivers/emu/emunet.c'; then $(CYGPATH_W) 'net/drivers/emu/emunet.c'; else $(CYGPATH_W) '$(srcdir)/net/drivers/emu/emunet.c'; fi`
+
+bus/emu/emupci_module-pci.o: bus/emu/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emupci_module_CPPFLAGS) $(CPPFLAGS) $(emupci_module_CFLAGS) $(CFLAGS) -MT bus/emu/emupci_module-pci.o -MD -MP -MF bus/emu/$(DEPDIR)/emupci_module-pci.Tpo -c -o bus/emu/emupci_module-pci.o `test -f 'bus/emu/pci.c' || echo '$(srcdir)/'`bus/emu/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/emu/$(DEPDIR)/emupci_module-pci.Tpo bus/emu/$(DEPDIR)/emupci_module-pci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/emu/pci.c' object='bus/emu/emupci_module-pci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emupci_module_CPPFLAGS) $(CPPFLAGS) $(emupci_module_CFLAGS) $(CFLAGS) -c -o bus/emu/emupci_module-pci.o `test -f 'bus/emu/pci.c' || echo '$(srcdir)/'`bus/emu/pci.c
+
+bus/emu/emupci_module-pci.obj: bus/emu/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emupci_module_CPPFLAGS) $(CPPFLAGS) $(emupci_module_CFLAGS) $(CFLAGS) -MT bus/emu/emupci_module-pci.obj -MD -MP -MF bus/emu/$(DEPDIR)/emupci_module-pci.Tpo -c -o bus/emu/emupci_module-pci.obj `if test -f 'bus/emu/pci.c'; then $(CYGPATH_W) 'bus/emu/pci.c'; else $(CYGPATH_W) '$(srcdir)/bus/emu/pci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/emu/$(DEPDIR)/emupci_module-pci.Tpo bus/emu/$(DEPDIR)/emupci_module-pci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/emu/pci.c' object='bus/emu/emupci_module-pci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emupci_module_CPPFLAGS) $(CPPFLAGS) $(emupci_module_CFLAGS) $(CFLAGS) -c -o bus/emu/emupci_module-pci.obj `if test -f 'bus/emu/pci.c'; then $(CYGPATH_W) 'bus/emu/pci.c'; else $(CYGPATH_W) '$(srcdir)/bus/emu/pci.c'; fi`
+
+commands/emupci_module-lspci.o: commands/lspci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emupci_module_CPPFLAGS) $(CPPFLAGS) $(emupci_module_CFLAGS) $(CFLAGS) -MT commands/emupci_module-lspci.o -MD -MP -MF commands/$(DEPDIR)/emupci_module-lspci.Tpo -c -o commands/emupci_module-lspci.o `test -f 'commands/lspci.c' || echo '$(srcdir)/'`commands/lspci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/emupci_module-lspci.Tpo commands/$(DEPDIR)/emupci_module-lspci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/lspci.c' object='commands/emupci_module-lspci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emupci_module_CPPFLAGS) $(CPPFLAGS) $(emupci_module_CFLAGS) $(CFLAGS) -c -o commands/emupci_module-lspci.o `test -f 'commands/lspci.c' || echo '$(srcdir)/'`commands/lspci.c
+
+commands/emupci_module-lspci.obj: commands/lspci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emupci_module_CPPFLAGS) $(CPPFLAGS) $(emupci_module_CFLAGS) $(CFLAGS) -MT commands/emupci_module-lspci.obj -MD -MP -MF commands/$(DEPDIR)/emupci_module-lspci.Tpo -c -o commands/emupci_module-lspci.obj `if test -f 'commands/lspci.c'; then $(CYGPATH_W) 'commands/lspci.c'; else $(CYGPATH_W) '$(srcdir)/commands/lspci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/emupci_module-lspci.Tpo commands/$(DEPDIR)/emupci_module-lspci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/lspci.c' object='commands/emupci_module-lspci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emupci_module_CPPFLAGS) $(CPPFLAGS) $(emupci_module_CFLAGS) $(CFLAGS) -c -o commands/emupci_module-lspci.obj `if test -f 'commands/lspci.c'; then $(CYGPATH_W) 'commands/lspci.c'; else $(CYGPATH_W) '$(srcdir)/commands/lspci.c'; fi`
+
+term/ieee1275/escc_module-escc.o: term/ieee1275/escc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(escc_module_CPPFLAGS) $(CPPFLAGS) $(escc_module_CFLAGS) $(CFLAGS) -MT term/ieee1275/escc_module-escc.o -MD -MP -MF term/ieee1275/$(DEPDIR)/escc_module-escc.Tpo -c -o term/ieee1275/escc_module-escc.o `test -f 'term/ieee1275/escc.c' || echo '$(srcdir)/'`term/ieee1275/escc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/ieee1275/$(DEPDIR)/escc_module-escc.Tpo term/ieee1275/$(DEPDIR)/escc_module-escc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ieee1275/escc.c' object='term/ieee1275/escc_module-escc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(escc_module_CPPFLAGS) $(CPPFLAGS) $(escc_module_CFLAGS) $(CFLAGS) -c -o term/ieee1275/escc_module-escc.o `test -f 'term/ieee1275/escc.c' || echo '$(srcdir)/'`term/ieee1275/escc.c
+
+term/ieee1275/escc_module-escc.obj: term/ieee1275/escc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(escc_module_CPPFLAGS) $(CPPFLAGS) $(escc_module_CFLAGS) $(CFLAGS) -MT term/ieee1275/escc_module-escc.obj -MD -MP -MF term/ieee1275/$(DEPDIR)/escc_module-escc.Tpo -c -o term/ieee1275/escc_module-escc.obj `if test -f 'term/ieee1275/escc.c'; then $(CYGPATH_W) 'term/ieee1275/escc.c'; else $(CYGPATH_W) '$(srcdir)/term/ieee1275/escc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/ieee1275/$(DEPDIR)/escc_module-escc.Tpo term/ieee1275/$(DEPDIR)/escc_module-escc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ieee1275/escc.c' object='term/ieee1275/escc_module-escc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(escc_module_CPPFLAGS) $(CPPFLAGS) $(escc_module_CFLAGS) $(CFLAGS) -c -o term/ieee1275/escc_module-escc.obj `if test -f 'term/ieee1275/escc.c'; then $(CYGPATH_W) 'term/ieee1275/escc.c'; else $(CYGPATH_W) '$(srcdir)/term/ieee1275/escc.c'; fi`
+
+commands/eval_module-eval.o: commands/eval.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(eval_module_CPPFLAGS) $(CPPFLAGS) $(eval_module_CFLAGS) $(CFLAGS) -MT commands/eval_module-eval.o -MD -MP -MF commands/$(DEPDIR)/eval_module-eval.Tpo -c -o commands/eval_module-eval.o `test -f 'commands/eval.c' || echo '$(srcdir)/'`commands/eval.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/eval_module-eval.Tpo commands/$(DEPDIR)/eval_module-eval.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/eval.c' object='commands/eval_module-eval.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(eval_module_CPPFLAGS) $(CPPFLAGS) $(eval_module_CFLAGS) $(CFLAGS) -c -o commands/eval_module-eval.o `test -f 'commands/eval.c' || echo '$(srcdir)/'`commands/eval.c
+
+commands/eval_module-eval.obj: commands/eval.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(eval_module_CPPFLAGS) $(CPPFLAGS) $(eval_module_CFLAGS) $(CFLAGS) -MT commands/eval_module-eval.obj -MD -MP -MF commands/$(DEPDIR)/eval_module-eval.Tpo -c -o commands/eval_module-eval.obj `if test -f 'commands/eval.c'; then $(CYGPATH_W) 'commands/eval.c'; else $(CYGPATH_W) '$(srcdir)/commands/eval.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/eval_module-eval.Tpo commands/$(DEPDIR)/eval_module-eval.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/eval.c' object='commands/eval_module-eval.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(eval_module_CPPFLAGS) $(CPPFLAGS) $(eval_module_CFLAGS) $(CFLAGS) -c -o commands/eval_module-eval.obj `if test -f 'commands/eval.c'; then $(CYGPATH_W) 'commands/eval.c'; else $(CYGPATH_W) '$(srcdir)/commands/eval.c'; fi`
+
+fs/exfat_module-exfat.o: fs/exfat.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfat_module_CPPFLAGS) $(CPPFLAGS) $(exfat_module_CFLAGS) $(CFLAGS) -MT fs/exfat_module-exfat.o -MD -MP -MF fs/$(DEPDIR)/exfat_module-exfat.Tpo -c -o fs/exfat_module-exfat.o `test -f 'fs/exfat.c' || echo '$(srcdir)/'`fs/exfat.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/exfat_module-exfat.Tpo fs/$(DEPDIR)/exfat_module-exfat.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/exfat.c' object='fs/exfat_module-exfat.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfat_module_CPPFLAGS) $(CPPFLAGS) $(exfat_module_CFLAGS) $(CFLAGS) -c -o fs/exfat_module-exfat.o `test -f 'fs/exfat.c' || echo '$(srcdir)/'`fs/exfat.c
+
+fs/exfat_module-exfat.obj: fs/exfat.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfat_module_CPPFLAGS) $(CPPFLAGS) $(exfat_module_CFLAGS) $(CFLAGS) -MT fs/exfat_module-exfat.obj -MD -MP -MF fs/$(DEPDIR)/exfat_module-exfat.Tpo -c -o fs/exfat_module-exfat.obj `if test -f 'fs/exfat.c'; then $(CYGPATH_W) 'fs/exfat.c'; else $(CYGPATH_W) '$(srcdir)/fs/exfat.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/exfat_module-exfat.Tpo fs/$(DEPDIR)/exfat_module-exfat.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/exfat.c' object='fs/exfat_module-exfat.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfat_module_CPPFLAGS) $(CPPFLAGS) $(exfat_module_CFLAGS) $(CFLAGS) -c -o fs/exfat_module-exfat.obj `if test -f 'fs/exfat.c'; then $(CYGPATH_W) 'fs/exfat.c'; else $(CYGPATH_W) '$(srcdir)/fs/exfat.c'; fi`
+
+tests/exfctest_module-example_functional_test.o: tests/example_functional_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfctest_module_CPPFLAGS) $(CPPFLAGS) $(exfctest_module_CFLAGS) $(CFLAGS) -MT tests/exfctest_module-example_functional_test.o -MD -MP -MF tests/$(DEPDIR)/exfctest_module-example_functional_test.Tpo -c -o tests/exfctest_module-example_functional_test.o `test -f 'tests/example_functional_test.c' || echo '$(srcdir)/'`tests/example_functional_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/exfctest_module-example_functional_test.Tpo tests/$(DEPDIR)/exfctest_module-example_functional_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/example_functional_test.c' object='tests/exfctest_module-example_functional_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfctest_module_CPPFLAGS) $(CPPFLAGS) $(exfctest_module_CFLAGS) $(CFLAGS) -c -o tests/exfctest_module-example_functional_test.o `test -f 'tests/example_functional_test.c' || echo '$(srcdir)/'`tests/example_functional_test.c
+
+tests/exfctest_module-example_functional_test.obj: tests/example_functional_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfctest_module_CPPFLAGS) $(CPPFLAGS) $(exfctest_module_CFLAGS) $(CFLAGS) -MT tests/exfctest_module-example_functional_test.obj -MD -MP -MF tests/$(DEPDIR)/exfctest_module-example_functional_test.Tpo -c -o tests/exfctest_module-example_functional_test.obj `if test -f 'tests/example_functional_test.c'; then $(CYGPATH_W) 'tests/example_functional_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/example_functional_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/exfctest_module-example_functional_test.Tpo tests/$(DEPDIR)/exfctest_module-example_functional_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/example_functional_test.c' object='tests/exfctest_module-example_functional_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfctest_module_CPPFLAGS) $(CPPFLAGS) $(exfctest_module_CFLAGS) $(CFLAGS) -c -o tests/exfctest_module-example_functional_test.obj `if test -f 'tests/example_functional_test.c'; then $(CYGPATH_W) 'tests/example_functional_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/example_functional_test.c'; fi`
+
+fs/ext2_module-ext2.o: fs/ext2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ext2_module_CPPFLAGS) $(CPPFLAGS) $(ext2_module_CFLAGS) $(CFLAGS) -MT fs/ext2_module-ext2.o -MD -MP -MF fs/$(DEPDIR)/ext2_module-ext2.Tpo -c -o fs/ext2_module-ext2.o `test -f 'fs/ext2.c' || echo '$(srcdir)/'`fs/ext2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ext2_module-ext2.Tpo fs/$(DEPDIR)/ext2_module-ext2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ext2.c' object='fs/ext2_module-ext2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ext2_module_CPPFLAGS) $(CPPFLAGS) $(ext2_module_CFLAGS) $(CFLAGS) -c -o fs/ext2_module-ext2.o `test -f 'fs/ext2.c' || echo '$(srcdir)/'`fs/ext2.c
+
+fs/ext2_module-ext2.obj: fs/ext2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ext2_module_CPPFLAGS) $(CPPFLAGS) $(ext2_module_CFLAGS) $(CFLAGS) -MT fs/ext2_module-ext2.obj -MD -MP -MF fs/$(DEPDIR)/ext2_module-ext2.Tpo -c -o fs/ext2_module-ext2.obj `if test -f 'fs/ext2.c'; then $(CYGPATH_W) 'fs/ext2.c'; else $(CYGPATH_W) '$(srcdir)/fs/ext2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ext2_module-ext2.Tpo fs/$(DEPDIR)/ext2_module-ext2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ext2.c' object='fs/ext2_module-ext2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ext2_module_CPPFLAGS) $(CPPFLAGS) $(ext2_module_CFLAGS) $(CFLAGS) -c -o fs/ext2_module-ext2.obj `if test -f 'fs/ext2.c'; then $(CYGPATH_W) 'fs/ext2.c'; else $(CYGPATH_W) '$(srcdir)/fs/ext2.c'; fi`
+
+commands/extcmd_module-extcmd.o: commands/extcmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $(extcmd_module_CFLAGS) $(CFLAGS) -MT commands/extcmd_module-extcmd.o -MD -MP -MF commands/$(DEPDIR)/extcmd_module-extcmd.Tpo -c -o commands/extcmd_module-extcmd.o `test -f 'commands/extcmd.c' || echo '$(srcdir)/'`commands/extcmd.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/extcmd_module-extcmd.Tpo commands/$(DEPDIR)/extcmd_module-extcmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/extcmd.c' object='commands/extcmd_module-extcmd.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $(extcmd_module_CFLAGS) $(CFLAGS) -c -o commands/extcmd_module-extcmd.o `test -f 'commands/extcmd.c' || echo '$(srcdir)/'`commands/extcmd.c
+
+commands/extcmd_module-extcmd.obj: commands/extcmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $(extcmd_module_CFLAGS) $(CFLAGS) -MT commands/extcmd_module-extcmd.obj -MD -MP -MF commands/$(DEPDIR)/extcmd_module-extcmd.Tpo -c -o commands/extcmd_module-extcmd.obj `if test -f 'commands/extcmd.c'; then $(CYGPATH_W) 'commands/extcmd.c'; else $(CYGPATH_W) '$(srcdir)/commands/extcmd.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/extcmd_module-extcmd.Tpo commands/$(DEPDIR)/extcmd_module-extcmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/extcmd.c' object='commands/extcmd_module-extcmd.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $(extcmd_module_CFLAGS) $(CFLAGS) -c -o commands/extcmd_module-extcmd.obj `if test -f 'commands/extcmd.c'; then $(CYGPATH_W) 'commands/extcmd.c'; else $(CYGPATH_W) '$(srcdir)/commands/extcmd.c'; fi`
+
+lib/extcmd_module-arg.o: lib/arg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $(extcmd_module_CFLAGS) $(CFLAGS) -MT lib/extcmd_module-arg.o -MD -MP -MF lib/$(DEPDIR)/extcmd_module-arg.Tpo -c -o lib/extcmd_module-arg.o `test -f 'lib/arg.c' || echo '$(srcdir)/'`lib/arg.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/extcmd_module-arg.Tpo lib/$(DEPDIR)/extcmd_module-arg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/arg.c' object='lib/extcmd_module-arg.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $(extcmd_module_CFLAGS) $(CFLAGS) -c -o lib/extcmd_module-arg.o `test -f 'lib/arg.c' || echo '$(srcdir)/'`lib/arg.c
+
+lib/extcmd_module-arg.obj: lib/arg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $(extcmd_module_CFLAGS) $(CFLAGS) -MT lib/extcmd_module-arg.obj -MD -MP -MF lib/$(DEPDIR)/extcmd_module-arg.Tpo -c -o lib/extcmd_module-arg.obj `if test -f 'lib/arg.c'; then $(CYGPATH_W) 'lib/arg.c'; else $(CYGPATH_W) '$(srcdir)/lib/arg.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/extcmd_module-arg.Tpo lib/$(DEPDIR)/extcmd_module-arg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/arg.c' object='lib/extcmd_module-arg.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $(extcmd_module_CFLAGS) $(CFLAGS) -c -o lib/extcmd_module-arg.obj `if test -f 'lib/arg.c'; then $(CYGPATH_W) 'lib/arg.c'; else $(CYGPATH_W) '$(srcdir)/lib/arg.c'; fi`
+
+fs/f2fs_module-f2fs.o: fs/f2fs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(f2fs_module_CPPFLAGS) $(CPPFLAGS) $(f2fs_module_CFLAGS) $(CFLAGS) -MT fs/f2fs_module-f2fs.o -MD -MP -MF fs/$(DEPDIR)/f2fs_module-f2fs.Tpo -c -o fs/f2fs_module-f2fs.o `test -f 'fs/f2fs.c' || echo '$(srcdir)/'`fs/f2fs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/f2fs_module-f2fs.Tpo fs/$(DEPDIR)/f2fs_module-f2fs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/f2fs.c' object='fs/f2fs_module-f2fs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(f2fs_module_CPPFLAGS) $(CPPFLAGS) $(f2fs_module_CFLAGS) $(CFLAGS) -c -o fs/f2fs_module-f2fs.o `test -f 'fs/f2fs.c' || echo '$(srcdir)/'`fs/f2fs.c
+
+fs/f2fs_module-f2fs.obj: fs/f2fs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(f2fs_module_CPPFLAGS) $(CPPFLAGS) $(f2fs_module_CFLAGS) $(CFLAGS) -MT fs/f2fs_module-f2fs.obj -MD -MP -MF fs/$(DEPDIR)/f2fs_module-f2fs.Tpo -c -o fs/f2fs_module-f2fs.obj `if test -f 'fs/f2fs.c'; then $(CYGPATH_W) 'fs/f2fs.c'; else $(CYGPATH_W) '$(srcdir)/fs/f2fs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/f2fs_module-f2fs.Tpo fs/$(DEPDIR)/f2fs_module-f2fs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/f2fs.c' object='fs/f2fs_module-f2fs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(f2fs_module_CPPFLAGS) $(CPPFLAGS) $(f2fs_module_CFLAGS) $(CFLAGS) -c -o fs/f2fs_module-f2fs.obj `if test -f 'fs/f2fs.c'; then $(CYGPATH_W) 'fs/f2fs.c'; else $(CYGPATH_W) '$(srcdir)/fs/f2fs.c'; fi`
+
+fs/fat_module-fat.o: fs/fat.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fat_module_CPPFLAGS) $(CPPFLAGS) $(fat_module_CFLAGS) $(CFLAGS) -MT fs/fat_module-fat.o -MD -MP -MF fs/$(DEPDIR)/fat_module-fat.Tpo -c -o fs/fat_module-fat.o `test -f 'fs/fat.c' || echo '$(srcdir)/'`fs/fat.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/fat_module-fat.Tpo fs/$(DEPDIR)/fat_module-fat.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/fat.c' object='fs/fat_module-fat.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fat_module_CPPFLAGS) $(CPPFLAGS) $(fat_module_CFLAGS) $(CFLAGS) -c -o fs/fat_module-fat.o `test -f 'fs/fat.c' || echo '$(srcdir)/'`fs/fat.c
+
+fs/fat_module-fat.obj: fs/fat.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fat_module_CPPFLAGS) $(CPPFLAGS) $(fat_module_CFLAGS) $(CFLAGS) -MT fs/fat_module-fat.obj -MD -MP -MF fs/$(DEPDIR)/fat_module-fat.Tpo -c -o fs/fat_module-fat.obj `if test -f 'fs/fat.c'; then $(CYGPATH_W) 'fs/fat.c'; else $(CYGPATH_W) '$(srcdir)/fs/fat.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/fat_module-fat.Tpo fs/$(DEPDIR)/fat_module-fat.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/fat.c' object='fs/fat_module-fat.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fat_module_CPPFLAGS) $(CPPFLAGS) $(fat_module_CFLAGS) $(CFLAGS) -c -o fs/fat_module-fat.obj `if test -f 'fs/fat.c'; then $(CYGPATH_W) 'fs/fat.c'; else $(CYGPATH_W) '$(srcdir)/fs/fat.c'; fi`
+
+loader/efi/fdt_module-fdt.o: loader/efi/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $(fdt_module_CFLAGS) $(CFLAGS) -MT loader/efi/fdt_module-fdt.o -MD -MP -MF loader/efi/$(DEPDIR)/fdt_module-fdt.Tpo -c -o loader/efi/fdt_module-fdt.o `test -f 'loader/efi/fdt.c' || echo '$(srcdir)/'`loader/efi/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/efi/$(DEPDIR)/fdt_module-fdt.Tpo loader/efi/$(DEPDIR)/fdt_module-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/efi/fdt.c' object='loader/efi/fdt_module-fdt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $(fdt_module_CFLAGS) $(CFLAGS) -c -o loader/efi/fdt_module-fdt.o `test -f 'loader/efi/fdt.c' || echo '$(srcdir)/'`loader/efi/fdt.c
+
+loader/efi/fdt_module-fdt.obj: loader/efi/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $(fdt_module_CFLAGS) $(CFLAGS) -MT loader/efi/fdt_module-fdt.obj -MD -MP -MF loader/efi/$(DEPDIR)/fdt_module-fdt.Tpo -c -o loader/efi/fdt_module-fdt.obj `if test -f 'loader/efi/fdt.c'; then $(CYGPATH_W) 'loader/efi/fdt.c'; else $(CYGPATH_W) '$(srcdir)/loader/efi/fdt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/efi/$(DEPDIR)/fdt_module-fdt.Tpo loader/efi/$(DEPDIR)/fdt_module-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/efi/fdt.c' object='loader/efi/fdt_module-fdt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $(fdt_module_CFLAGS) $(CFLAGS) -c -o loader/efi/fdt_module-fdt.obj `if test -f 'loader/efi/fdt.c'; then $(CYGPATH_W) 'loader/efi/fdt.c'; else $(CYGPATH_W) '$(srcdir)/loader/efi/fdt.c'; fi`
+
+lib/fdt_module-fdt.o: lib/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $(fdt_module_CFLAGS) $(CFLAGS) -MT lib/fdt_module-fdt.o -MD -MP -MF lib/$(DEPDIR)/fdt_module-fdt.Tpo -c -o lib/fdt_module-fdt.o `test -f 'lib/fdt.c' || echo '$(srcdir)/'`lib/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/fdt_module-fdt.Tpo lib/$(DEPDIR)/fdt_module-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/fdt.c' object='lib/fdt_module-fdt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $(fdt_module_CFLAGS) $(CFLAGS) -c -o lib/fdt_module-fdt.o `test -f 'lib/fdt.c' || echo '$(srcdir)/'`lib/fdt.c
+
+lib/fdt_module-fdt.obj: lib/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $(fdt_module_CFLAGS) $(CFLAGS) -MT lib/fdt_module-fdt.obj -MD -MP -MF lib/$(DEPDIR)/fdt_module-fdt.Tpo -c -o lib/fdt_module-fdt.obj `if test -f 'lib/fdt.c'; then $(CYGPATH_W) 'lib/fdt.c'; else $(CYGPATH_W) '$(srcdir)/lib/fdt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/fdt_module-fdt.Tpo lib/$(DEPDIR)/fdt_module-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/fdt.c' object='lib/fdt_module-fdt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $(fdt_module_CFLAGS) $(CFLAGS) -c -o lib/fdt_module-fdt.obj `if test -f 'lib/fdt.c'; then $(CYGPATH_W) 'lib/fdt.c'; else $(CYGPATH_W) '$(srcdir)/lib/fdt.c'; fi`
+
+commands/file_module-file.o: commands/file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT commands/file_module-file.o -MD -MP -MF commands/$(DEPDIR)/file_module-file.Tpo -c -o commands/file_module-file.o `test -f 'commands/file.c' || echo '$(srcdir)/'`commands/file.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/file_module-file.Tpo commands/$(DEPDIR)/file_module-file.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/file.c' object='commands/file_module-file.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o commands/file_module-file.o `test -f 'commands/file.c' || echo '$(srcdir)/'`commands/file.c
+
+commands/file_module-file.obj: commands/file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT commands/file_module-file.obj -MD -MP -MF commands/$(DEPDIR)/file_module-file.Tpo -c -o commands/file_module-file.obj `if test -f 'commands/file.c'; then $(CYGPATH_W) 'commands/file.c'; else $(CYGPATH_W) '$(srcdir)/commands/file.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/file_module-file.Tpo commands/$(DEPDIR)/file_module-file.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/file.c' object='commands/file_module-file.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o commands/file_module-file.obj `if test -f 'commands/file.c'; then $(CYGPATH_W) 'commands/file.c'; else $(CYGPATH_W) '$(srcdir)/commands/file.c'; fi`
+
+commands/file_module-file32.o: commands/file32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT commands/file_module-file32.o -MD -MP -MF commands/$(DEPDIR)/file_module-file32.Tpo -c -o commands/file_module-file32.o `test -f 'commands/file32.c' || echo '$(srcdir)/'`commands/file32.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/file_module-file32.Tpo commands/$(DEPDIR)/file_module-file32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/file32.c' object='commands/file_module-file32.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o commands/file_module-file32.o `test -f 'commands/file32.c' || echo '$(srcdir)/'`commands/file32.c
+
+commands/file_module-file32.obj: commands/file32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT commands/file_module-file32.obj -MD -MP -MF commands/$(DEPDIR)/file_module-file32.Tpo -c -o commands/file_module-file32.obj `if test -f 'commands/file32.c'; then $(CYGPATH_W) 'commands/file32.c'; else $(CYGPATH_W) '$(srcdir)/commands/file32.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/file_module-file32.Tpo commands/$(DEPDIR)/file_module-file32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/file32.c' object='commands/file_module-file32.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o commands/file_module-file32.obj `if test -f 'commands/file32.c'; then $(CYGPATH_W) 'commands/file32.c'; else $(CYGPATH_W) '$(srcdir)/commands/file32.c'; fi`
+
+commands/file_module-file64.o: commands/file64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT commands/file_module-file64.o -MD -MP -MF commands/$(DEPDIR)/file_module-file64.Tpo -c -o commands/file_module-file64.o `test -f 'commands/file64.c' || echo '$(srcdir)/'`commands/file64.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/file_module-file64.Tpo commands/$(DEPDIR)/file_module-file64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/file64.c' object='commands/file_module-file64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o commands/file_module-file64.o `test -f 'commands/file64.c' || echo '$(srcdir)/'`commands/file64.c
+
+commands/file_module-file64.obj: commands/file64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT commands/file_module-file64.obj -MD -MP -MF commands/$(DEPDIR)/file_module-file64.Tpo -c -o commands/file_module-file64.obj `if test -f 'commands/file64.c'; then $(CYGPATH_W) 'commands/file64.c'; else $(CYGPATH_W) '$(srcdir)/commands/file64.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/file_module-file64.Tpo commands/$(DEPDIR)/file_module-file64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/file64.c' object='commands/file_module-file64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o commands/file_module-file64.obj `if test -f 'commands/file64.c'; then $(CYGPATH_W) 'commands/file64.c'; else $(CYGPATH_W) '$(srcdir)/commands/file64.c'; fi`
+
+loader/i386/file_module-xen_file.o: loader/i386/xen_file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT loader/i386/file_module-xen_file.o -MD -MP -MF loader/i386/$(DEPDIR)/file_module-xen_file.Tpo -c -o loader/i386/file_module-xen_file.o `test -f 'loader/i386/xen_file.c' || echo '$(srcdir)/'`loader/i386/xen_file.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/file_module-xen_file.Tpo loader/i386/$(DEPDIR)/file_module-xen_file.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/xen_file.c' object='loader/i386/file_module-xen_file.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o loader/i386/file_module-xen_file.o `test -f 'loader/i386/xen_file.c' || echo '$(srcdir)/'`loader/i386/xen_file.c
+
+loader/i386/file_module-xen_file.obj: loader/i386/xen_file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT loader/i386/file_module-xen_file.obj -MD -MP -MF loader/i386/$(DEPDIR)/file_module-xen_file.Tpo -c -o loader/i386/file_module-xen_file.obj `if test -f 'loader/i386/xen_file.c'; then $(CYGPATH_W) 'loader/i386/xen_file.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/xen_file.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/file_module-xen_file.Tpo loader/i386/$(DEPDIR)/file_module-xen_file.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/xen_file.c' object='loader/i386/file_module-xen_file.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o loader/i386/file_module-xen_file.obj `if test -f 'loader/i386/xen_file.c'; then $(CYGPATH_W) 'loader/i386/xen_file.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/xen_file.c'; fi`
+
+loader/i386/file_module-xen_file32.o: loader/i386/xen_file32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT loader/i386/file_module-xen_file32.o -MD -MP -MF loader/i386/$(DEPDIR)/file_module-xen_file32.Tpo -c -o loader/i386/file_module-xen_file32.o `test -f 'loader/i386/xen_file32.c' || echo '$(srcdir)/'`loader/i386/xen_file32.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/file_module-xen_file32.Tpo loader/i386/$(DEPDIR)/file_module-xen_file32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/xen_file32.c' object='loader/i386/file_module-xen_file32.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o loader/i386/file_module-xen_file32.o `test -f 'loader/i386/xen_file32.c' || echo '$(srcdir)/'`loader/i386/xen_file32.c
+
+loader/i386/file_module-xen_file32.obj: loader/i386/xen_file32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT loader/i386/file_module-xen_file32.obj -MD -MP -MF loader/i386/$(DEPDIR)/file_module-xen_file32.Tpo -c -o loader/i386/file_module-xen_file32.obj `if test -f 'loader/i386/xen_file32.c'; then $(CYGPATH_W) 'loader/i386/xen_file32.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/xen_file32.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/file_module-xen_file32.Tpo loader/i386/$(DEPDIR)/file_module-xen_file32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/xen_file32.c' object='loader/i386/file_module-xen_file32.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o loader/i386/file_module-xen_file32.obj `if test -f 'loader/i386/xen_file32.c'; then $(CYGPATH_W) 'loader/i386/xen_file32.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/xen_file32.c'; fi`
+
+loader/i386/file_module-xen_file64.o: loader/i386/xen_file64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT loader/i386/file_module-xen_file64.o -MD -MP -MF loader/i386/$(DEPDIR)/file_module-xen_file64.Tpo -c -o loader/i386/file_module-xen_file64.o `test -f 'loader/i386/xen_file64.c' || echo '$(srcdir)/'`loader/i386/xen_file64.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/file_module-xen_file64.Tpo loader/i386/$(DEPDIR)/file_module-xen_file64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/xen_file64.c' object='loader/i386/file_module-xen_file64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o loader/i386/file_module-xen_file64.o `test -f 'loader/i386/xen_file64.c' || echo '$(srcdir)/'`loader/i386/xen_file64.c
+
+loader/i386/file_module-xen_file64.obj: loader/i386/xen_file64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -MT loader/i386/file_module-xen_file64.obj -MD -MP -MF loader/i386/$(DEPDIR)/file_module-xen_file64.Tpo -c -o loader/i386/file_module-xen_file64.obj `if test -f 'loader/i386/xen_file64.c'; then $(CYGPATH_W) 'loader/i386/xen_file64.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/xen_file64.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/file_module-xen_file64.Tpo loader/i386/$(DEPDIR)/file_module-xen_file64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/xen_file64.c' object='loader/i386/file_module-xen_file64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $(file_module_CFLAGS) $(CFLAGS) -c -o loader/i386/file_module-xen_file64.obj `if test -f 'loader/i386/xen_file64.c'; then $(CYGPATH_W) 'loader/i386/xen_file64.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/xen_file64.c'; fi`
+
+commands/efi/fixvideo_module-fixvideo.o: commands/efi/fixvideo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fixvideo_module_CPPFLAGS) $(CPPFLAGS) $(fixvideo_module_CFLAGS) $(CFLAGS) -MT commands/efi/fixvideo_module-fixvideo.o -MD -MP -MF commands/efi/$(DEPDIR)/fixvideo_module-fixvideo.Tpo -c -o commands/efi/fixvideo_module-fixvideo.o `test -f 'commands/efi/fixvideo.c' || echo '$(srcdir)/'`commands/efi/fixvideo.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/fixvideo_module-fixvideo.Tpo commands/efi/$(DEPDIR)/fixvideo_module-fixvideo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/fixvideo.c' object='commands/efi/fixvideo_module-fixvideo.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fixvideo_module_CPPFLAGS) $(CPPFLAGS) $(fixvideo_module_CFLAGS) $(CFLAGS) -c -o commands/efi/fixvideo_module-fixvideo.o `test -f 'commands/efi/fixvideo.c' || echo '$(srcdir)/'`commands/efi/fixvideo.c
+
+commands/efi/fixvideo_module-fixvideo.obj: commands/efi/fixvideo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fixvideo_module_CPPFLAGS) $(CPPFLAGS) $(fixvideo_module_CFLAGS) $(CFLAGS) -MT commands/efi/fixvideo_module-fixvideo.obj -MD -MP -MF commands/efi/$(DEPDIR)/fixvideo_module-fixvideo.Tpo -c -o commands/efi/fixvideo_module-fixvideo.obj `if test -f 'commands/efi/fixvideo.c'; then $(CYGPATH_W) 'commands/efi/fixvideo.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/fixvideo.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/fixvideo_module-fixvideo.Tpo commands/efi/$(DEPDIR)/fixvideo_module-fixvideo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/fixvideo.c' object='commands/efi/fixvideo_module-fixvideo.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fixvideo_module_CPPFLAGS) $(CPPFLAGS) $(fixvideo_module_CFLAGS) $(CFLAGS) -c -o commands/efi/fixvideo_module-fixvideo.obj `if test -f 'commands/efi/fixvideo.c'; then $(CYGPATH_W) 'commands/efi/fixvideo.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/fixvideo.c'; fi`
+
+font/font_module-font.o: font/font.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $(font_module_CFLAGS) $(CFLAGS) -MT font/font_module-font.o -MD -MP -MF font/$(DEPDIR)/font_module-font.Tpo -c -o font/font_module-font.o `test -f 'font/font.c' || echo '$(srcdir)/'`font/font.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) font/$(DEPDIR)/font_module-font.Tpo font/$(DEPDIR)/font_module-font.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='font/font.c' object='font/font_module-font.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $(font_module_CFLAGS) $(CFLAGS) -c -o font/font_module-font.o `test -f 'font/font.c' || echo '$(srcdir)/'`font/font.c
+
+font/font_module-font.obj: font/font.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $(font_module_CFLAGS) $(CFLAGS) -MT font/font_module-font.obj -MD -MP -MF font/$(DEPDIR)/font_module-font.Tpo -c -o font/font_module-font.obj `if test -f 'font/font.c'; then $(CYGPATH_W) 'font/font.c'; else $(CYGPATH_W) '$(srcdir)/font/font.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) font/$(DEPDIR)/font_module-font.Tpo font/$(DEPDIR)/font_module-font.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='font/font.c' object='font/font_module-font.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $(font_module_CFLAGS) $(CFLAGS) -c -o font/font_module-font.obj `if test -f 'font/font.c'; then $(CYGPATH_W) 'font/font.c'; else $(CYGPATH_W) '$(srcdir)/font/font.c'; fi`
+
+font/font_module-font_cmd.o: font/font_cmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $(font_module_CFLAGS) $(CFLAGS) -MT font/font_module-font_cmd.o -MD -MP -MF font/$(DEPDIR)/font_module-font_cmd.Tpo -c -o font/font_module-font_cmd.o `test -f 'font/font_cmd.c' || echo '$(srcdir)/'`font/font_cmd.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) font/$(DEPDIR)/font_module-font_cmd.Tpo font/$(DEPDIR)/font_module-font_cmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='font/font_cmd.c' object='font/font_module-font_cmd.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $(font_module_CFLAGS) $(CFLAGS) -c -o font/font_module-font_cmd.o `test -f 'font/font_cmd.c' || echo '$(srcdir)/'`font/font_cmd.c
+
+font/font_module-font_cmd.obj: font/font_cmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $(font_module_CFLAGS) $(CFLAGS) -MT font/font_module-font_cmd.obj -MD -MP -MF font/$(DEPDIR)/font_module-font_cmd.Tpo -c -o font/font_module-font_cmd.obj `if test -f 'font/font_cmd.c'; then $(CYGPATH_W) 'font/font_cmd.c'; else $(CYGPATH_W) '$(srcdir)/font/font_cmd.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) font/$(DEPDIR)/font_module-font_cmd.Tpo font/$(DEPDIR)/font_module-font_cmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='font/font_cmd.c' object='font/font_module-font_cmd.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $(font_module_CFLAGS) $(CFLAGS) -c -o font/font_module-font_cmd.obj `if test -f 'font/font_cmd.c'; then $(CYGPATH_W) 'font/font_cmd.c'; else $(CYGPATH_W) '$(srcdir)/font/font_cmd.c'; fi`
+
+loader/i386/pc/freedos_module-freedos.o: loader/i386/pc/freedos.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(freedos_module_CPPFLAGS) $(CPPFLAGS) $(freedos_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/freedos_module-freedos.o -MD -MP -MF loader/i386/pc/$(DEPDIR)/freedos_module-freedos.Tpo -c -o loader/i386/pc/freedos_module-freedos.o `test -f 'loader/i386/pc/freedos.c' || echo '$(srcdir)/'`loader/i386/pc/freedos.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/freedos_module-freedos.Tpo loader/i386/pc/$(DEPDIR)/freedos_module-freedos.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/freedos.c' object='loader/i386/pc/freedos_module-freedos.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(freedos_module_CPPFLAGS) $(CPPFLAGS) $(freedos_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/freedos_module-freedos.o `test -f 'loader/i386/pc/freedos.c' || echo '$(srcdir)/'`loader/i386/pc/freedos.c
+
+loader/i386/pc/freedos_module-freedos.obj: loader/i386/pc/freedos.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(freedos_module_CPPFLAGS) $(CPPFLAGS) $(freedos_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/freedos_module-freedos.obj -MD -MP -MF loader/i386/pc/$(DEPDIR)/freedos_module-freedos.Tpo -c -o loader/i386/pc/freedos_module-freedos.obj `if test -f 'loader/i386/pc/freedos.c'; then $(CYGPATH_W) 'loader/i386/pc/freedos.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/freedos.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/freedos_module-freedos.Tpo loader/i386/pc/$(DEPDIR)/freedos_module-freedos.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/freedos.c' object='loader/i386/pc/freedos_module-freedos.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(freedos_module_CPPFLAGS) $(CPPFLAGS) $(freedos_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/freedos_module-freedos.obj `if test -f 'loader/i386/pc/freedos.c'; then $(CYGPATH_W) 'loader/i386/pc/freedos.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/freedos.c'; fi`
+
+fs/fshelp_module-fshelp.o: fs/fshelp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fshelp_module_CPPFLAGS) $(CPPFLAGS) $(fshelp_module_CFLAGS) $(CFLAGS) -MT fs/fshelp_module-fshelp.o -MD -MP -MF fs/$(DEPDIR)/fshelp_module-fshelp.Tpo -c -o fs/fshelp_module-fshelp.o `test -f 'fs/fshelp.c' || echo '$(srcdir)/'`fs/fshelp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/fshelp_module-fshelp.Tpo fs/$(DEPDIR)/fshelp_module-fshelp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/fshelp.c' object='fs/fshelp_module-fshelp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fshelp_module_CPPFLAGS) $(CPPFLAGS) $(fshelp_module_CFLAGS) $(CFLAGS) -c -o fs/fshelp_module-fshelp.o `test -f 'fs/fshelp.c' || echo '$(srcdir)/'`fs/fshelp.c
+
+fs/fshelp_module-fshelp.obj: fs/fshelp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fshelp_module_CPPFLAGS) $(CPPFLAGS) $(fshelp_module_CFLAGS) $(CFLAGS) -MT fs/fshelp_module-fshelp.obj -MD -MP -MF fs/$(DEPDIR)/fshelp_module-fshelp.Tpo -c -o fs/fshelp_module-fshelp.obj `if test -f 'fs/fshelp.c'; then $(CYGPATH_W) 'fs/fshelp.c'; else $(CYGPATH_W) '$(srcdir)/fs/fshelp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/fshelp_module-fshelp.Tpo fs/$(DEPDIR)/fshelp_module-fshelp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/fshelp.c' object='fs/fshelp_module-fshelp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fshelp_module_CPPFLAGS) $(CPPFLAGS) $(fshelp_module_CFLAGS) $(CFLAGS) -c -o fs/fshelp_module-fshelp.obj `if test -f 'fs/fshelp.c'; then $(CYGPATH_W) 'fs/fshelp.c'; else $(CYGPATH_W) '$(srcdir)/fs/fshelp.c'; fi`
+
+tests/lib/functional_test_module-functional_test.o: tests/lib/functional_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -MT tests/lib/functional_test_module-functional_test.o -MD -MP -MF tests/lib/$(DEPDIR)/functional_test_module-functional_test.Tpo -c -o tests/lib/functional_test_module-functional_test.o `test -f 'tests/lib/functional_test.c' || echo '$(srcdir)/'`tests/lib/functional_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/lib/$(DEPDIR)/functional_test_module-functional_test.Tpo tests/lib/$(DEPDIR)/functional_test_module-functional_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/lib/functional_test.c' object='tests/lib/functional_test_module-functional_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -c -o tests/lib/functional_test_module-functional_test.o `test -f 'tests/lib/functional_test.c' || echo '$(srcdir)/'`tests/lib/functional_test.c
+
+tests/lib/functional_test_module-functional_test.obj: tests/lib/functional_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -MT tests/lib/functional_test_module-functional_test.obj -MD -MP -MF tests/lib/$(DEPDIR)/functional_test_module-functional_test.Tpo -c -o tests/lib/functional_test_module-functional_test.obj `if test -f 'tests/lib/functional_test.c'; then $(CYGPATH_W) 'tests/lib/functional_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/lib/functional_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/lib/$(DEPDIR)/functional_test_module-functional_test.Tpo tests/lib/$(DEPDIR)/functional_test_module-functional_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/lib/functional_test.c' object='tests/lib/functional_test_module-functional_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -c -o tests/lib/functional_test_module-functional_test.obj `if test -f 'tests/lib/functional_test.c'; then $(CYGPATH_W) 'tests/lib/functional_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/lib/functional_test.c'; fi`
+
+tests/lib/functional_test_module-test.o: tests/lib/test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -MT tests/lib/functional_test_module-test.o -MD -MP -MF tests/lib/$(DEPDIR)/functional_test_module-test.Tpo -c -o tests/lib/functional_test_module-test.o `test -f 'tests/lib/test.c' || echo '$(srcdir)/'`tests/lib/test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/lib/$(DEPDIR)/functional_test_module-test.Tpo tests/lib/$(DEPDIR)/functional_test_module-test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/lib/test.c' object='tests/lib/functional_test_module-test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -c -o tests/lib/functional_test_module-test.o `test -f 'tests/lib/test.c' || echo '$(srcdir)/'`tests/lib/test.c
+
+tests/lib/functional_test_module-test.obj: tests/lib/test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -MT tests/lib/functional_test_module-test.obj -MD -MP -MF tests/lib/$(DEPDIR)/functional_test_module-test.Tpo -c -o tests/lib/functional_test_module-test.obj `if test -f 'tests/lib/test.c'; then $(CYGPATH_W) 'tests/lib/test.c'; else $(CYGPATH_W) '$(srcdir)/tests/lib/test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/lib/$(DEPDIR)/functional_test_module-test.Tpo tests/lib/$(DEPDIR)/functional_test_module-test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/lib/test.c' object='tests/lib/functional_test_module-test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -c -o tests/lib/functional_test_module-test.obj `if test -f 'tests/lib/test.c'; then $(CYGPATH_W) 'tests/lib/test.c'; else $(CYGPATH_W) '$(srcdir)/tests/lib/test.c'; fi`
+
+tests/functional_test_module-video_checksum.o: tests/video_checksum.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -MT tests/functional_test_module-video_checksum.o -MD -MP -MF tests/$(DEPDIR)/functional_test_module-video_checksum.Tpo -c -o tests/functional_test_module-video_checksum.o `test -f 'tests/video_checksum.c' || echo '$(srcdir)/'`tests/video_checksum.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/functional_test_module-video_checksum.Tpo tests/$(DEPDIR)/functional_test_module-video_checksum.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/video_checksum.c' object='tests/functional_test_module-video_checksum.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -c -o tests/functional_test_module-video_checksum.o `test -f 'tests/video_checksum.c' || echo '$(srcdir)/'`tests/video_checksum.c
+
+tests/functional_test_module-video_checksum.obj: tests/video_checksum.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -MT tests/functional_test_module-video_checksum.obj -MD -MP -MF tests/$(DEPDIR)/functional_test_module-video_checksum.Tpo -c -o tests/functional_test_module-video_checksum.obj `if test -f 'tests/video_checksum.c'; then $(CYGPATH_W) 'tests/video_checksum.c'; else $(CYGPATH_W) '$(srcdir)/tests/video_checksum.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/functional_test_module-video_checksum.Tpo tests/$(DEPDIR)/functional_test_module-video_checksum.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/video_checksum.c' object='tests/functional_test_module-video_checksum.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -c -o tests/functional_test_module-video_checksum.obj `if test -f 'tests/video_checksum.c'; then $(CYGPATH_W) 'tests/video_checksum.c'; else $(CYGPATH_W) '$(srcdir)/tests/video_checksum.c'; fi`
+
+tests/functional_test_module-fake_input.o: tests/fake_input.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -MT tests/functional_test_module-fake_input.o -MD -MP -MF tests/$(DEPDIR)/functional_test_module-fake_input.Tpo -c -o tests/functional_test_module-fake_input.o `test -f 'tests/fake_input.c' || echo '$(srcdir)/'`tests/fake_input.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/functional_test_module-fake_input.Tpo tests/$(DEPDIR)/functional_test_module-fake_input.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/fake_input.c' object='tests/functional_test_module-fake_input.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -c -o tests/functional_test_module-fake_input.o `test -f 'tests/fake_input.c' || echo '$(srcdir)/'`tests/fake_input.c
+
+tests/functional_test_module-fake_input.obj: tests/fake_input.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -MT tests/functional_test_module-fake_input.obj -MD -MP -MF tests/$(DEPDIR)/functional_test_module-fake_input.Tpo -c -o tests/functional_test_module-fake_input.obj `if test -f 'tests/fake_input.c'; then $(CYGPATH_W) 'tests/fake_input.c'; else $(CYGPATH_W) '$(srcdir)/tests/fake_input.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/functional_test_module-fake_input.Tpo tests/$(DEPDIR)/functional_test_module-fake_input.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/fake_input.c' object='tests/functional_test_module-fake_input.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -c -o tests/functional_test_module-fake_input.obj `if test -f 'tests/fake_input.c'; then $(CYGPATH_W) 'tests/fake_input.c'; else $(CYGPATH_W) '$(srcdir)/tests/fake_input.c'; fi`
+
+video/functional_test_module-capture.o: video/capture.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -MT video/functional_test_module-capture.o -MD -MP -MF video/$(DEPDIR)/functional_test_module-capture.Tpo -c -o video/functional_test_module-capture.o `test -f 'video/capture.c' || echo '$(srcdir)/'`video/capture.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/functional_test_module-capture.Tpo video/$(DEPDIR)/functional_test_module-capture.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/capture.c' object='video/functional_test_module-capture.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -c -o video/functional_test_module-capture.o `test -f 'video/capture.c' || echo '$(srcdir)/'`video/capture.c
+
+video/functional_test_module-capture.obj: video/capture.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -MT video/functional_test_module-capture.obj -MD -MP -MF video/$(DEPDIR)/functional_test_module-capture.Tpo -c -o video/functional_test_module-capture.obj `if test -f 'video/capture.c'; then $(CYGPATH_W) 'video/capture.c'; else $(CYGPATH_W) '$(srcdir)/video/capture.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/functional_test_module-capture.Tpo video/$(DEPDIR)/functional_test_module-capture.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/capture.c' object='video/functional_test_module-capture.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $(functional_test_module_CFLAGS) $(CFLAGS) -c -o video/functional_test_module-capture.obj `if test -f 'video/capture.c'; then $(CYGPATH_W) 'video/capture.c'; else $(CYGPATH_W) '$(srcdir)/video/capture.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.o: lib/libgcrypt-grub/cipher/arcfour.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_arcfour_module_CPPFLAGS) $(CPPFLAGS) $(gcry_arcfour_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_arcfour_module-arcfour.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.o `test -f 'lib/libgcrypt-grub/cipher/arcfour.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/arcfour.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_arcfour_module-arcfour.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_arcfour_module-arcfour.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/arcfour.c' object='lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_arcfour_module_CPPFLAGS) $(CPPFLAGS) $(gcry_arcfour_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.o `test -f 'lib/libgcrypt-grub/cipher/arcfour.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/arcfour.c
+
+lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.obj: lib/libgcrypt-grub/cipher/arcfour.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_arcfour_module_CPPFLAGS) $(CPPFLAGS) $(gcry_arcfour_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_arcfour_module-arcfour.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.obj `if test -f 'lib/libgcrypt-grub/cipher/arcfour.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/arcfour.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/arcfour.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_arcfour_module-arcfour.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_arcfour_module-arcfour.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/arcfour.c' object='lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_arcfour_module_CPPFLAGS) $(CPPFLAGS) $(gcry_arcfour_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_arcfour_module-arcfour.obj `if test -f 'lib/libgcrypt-grub/cipher/arcfour.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/arcfour.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/arcfour.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.o: lib/libgcrypt-grub/cipher/blowfish.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_blowfish_module_CPPFLAGS) $(CPPFLAGS) $(gcry_blowfish_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_blowfish_module-blowfish.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.o `test -f 'lib/libgcrypt-grub/cipher/blowfish.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/blowfish.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_blowfish_module-blowfish.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_blowfish_module-blowfish.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/blowfish.c' object='lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_blowfish_module_CPPFLAGS) $(CPPFLAGS) $(gcry_blowfish_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.o `test -f 'lib/libgcrypt-grub/cipher/blowfish.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/blowfish.c
+
+lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.obj: lib/libgcrypt-grub/cipher/blowfish.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_blowfish_module_CPPFLAGS) $(CPPFLAGS) $(gcry_blowfish_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_blowfish_module-blowfish.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.obj `if test -f 'lib/libgcrypt-grub/cipher/blowfish.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/blowfish.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/blowfish.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_blowfish_module-blowfish.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_blowfish_module-blowfish.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/blowfish.c' object='lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_blowfish_module_CPPFLAGS) $(CPPFLAGS) $(gcry_blowfish_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_blowfish_module-blowfish.obj `if test -f 'lib/libgcrypt-grub/cipher/blowfish.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/blowfish.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/blowfish.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.o: lib/libgcrypt-grub/cipher/camellia-glue.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_camellia_module_CPPFLAGS) $(CPPFLAGS) $(gcry_camellia_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia-glue.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.o `test -f 'lib/libgcrypt-grub/cipher/camellia-glue.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/camellia-glue.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia-glue.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia-glue.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/camellia-glue.c' object='lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_camellia_module_CPPFLAGS) $(CPPFLAGS) $(gcry_camellia_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.o `test -f 'lib/libgcrypt-grub/cipher/camellia-glue.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/camellia-glue.c
+
+lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.obj: lib/libgcrypt-grub/cipher/camellia-glue.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_camellia_module_CPPFLAGS) $(CPPFLAGS) $(gcry_camellia_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia-glue.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.obj `if test -f 'lib/libgcrypt-grub/cipher/camellia-glue.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/camellia-glue.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/camellia-glue.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia-glue.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia-glue.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/camellia-glue.c' object='lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_camellia_module_CPPFLAGS) $(CPPFLAGS) $(gcry_camellia_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia-glue.obj `if test -f 'lib/libgcrypt-grub/cipher/camellia-glue.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/camellia-glue.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/camellia-glue.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.o: lib/libgcrypt-grub/cipher/camellia.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_camellia_module_CPPFLAGS) $(CPPFLAGS) $(gcry_camellia_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.o `test -f 'lib/libgcrypt-grub/cipher/camellia.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/camellia.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/camellia.c' object='lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_camellia_module_CPPFLAGS) $(CPPFLAGS) $(gcry_camellia_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.o `test -f 'lib/libgcrypt-grub/cipher/camellia.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/camellia.c
+
+lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.obj: lib/libgcrypt-grub/cipher/camellia.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_camellia_module_CPPFLAGS) $(CPPFLAGS) $(gcry_camellia_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.obj `if test -f 'lib/libgcrypt-grub/cipher/camellia.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/camellia.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/camellia.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_camellia_module-camellia.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/camellia.c' object='lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_camellia_module_CPPFLAGS) $(CPPFLAGS) $(gcry_camellia_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_camellia_module-camellia.obj `if test -f 'lib/libgcrypt-grub/cipher/camellia.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/camellia.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/camellia.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.o: lib/libgcrypt-grub/cipher/cast5.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_cast5_module_CPPFLAGS) $(CPPFLAGS) $(gcry_cast5_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_cast5_module-cast5.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.o `test -f 'lib/libgcrypt-grub/cipher/cast5.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/cast5.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_cast5_module-cast5.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_cast5_module-cast5.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/cast5.c' object='lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_cast5_module_CPPFLAGS) $(CPPFLAGS) $(gcry_cast5_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.o `test -f 'lib/libgcrypt-grub/cipher/cast5.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/cast5.c
+
+lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.obj: lib/libgcrypt-grub/cipher/cast5.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_cast5_module_CPPFLAGS) $(CPPFLAGS) $(gcry_cast5_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_cast5_module-cast5.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.obj `if test -f 'lib/libgcrypt-grub/cipher/cast5.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/cast5.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/cast5.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_cast5_module-cast5.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_cast5_module-cast5.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/cast5.c' object='lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_cast5_module_CPPFLAGS) $(CPPFLAGS) $(gcry_cast5_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_cast5_module-cast5.obj `if test -f 'lib/libgcrypt-grub/cipher/cast5.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/cast5.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/cast5.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_crc_module-crc.o: lib/libgcrypt-grub/cipher/crc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_crc_module_CPPFLAGS) $(CPPFLAGS) $(gcry_crc_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_crc_module-crc.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_crc_module-crc.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_crc_module-crc.o `test -f 'lib/libgcrypt-grub/cipher/crc.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/crc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_crc_module-crc.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_crc_module-crc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/crc.c' object='lib/libgcrypt-grub/cipher/gcry_crc_module-crc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_crc_module_CPPFLAGS) $(CPPFLAGS) $(gcry_crc_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_crc_module-crc.o `test -f 'lib/libgcrypt-grub/cipher/crc.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/crc.c
+
+lib/libgcrypt-grub/cipher/gcry_crc_module-crc.obj: lib/libgcrypt-grub/cipher/crc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_crc_module_CPPFLAGS) $(CPPFLAGS) $(gcry_crc_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_crc_module-crc.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_crc_module-crc.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_crc_module-crc.obj `if test -f 'lib/libgcrypt-grub/cipher/crc.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/crc.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/crc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_crc_module-crc.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_crc_module-crc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/crc.c' object='lib/libgcrypt-grub/cipher/gcry_crc_module-crc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_crc_module_CPPFLAGS) $(CPPFLAGS) $(gcry_crc_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_crc_module-crc.obj `if test -f 'lib/libgcrypt-grub/cipher/crc.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/crc.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/crc.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_des_module-des.o: lib/libgcrypt-grub/cipher/des.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_des_module_CPPFLAGS) $(CPPFLAGS) $(gcry_des_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_des_module-des.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_des_module-des.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_des_module-des.o `test -f 'lib/libgcrypt-grub/cipher/des.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/des.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_des_module-des.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_des_module-des.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/des.c' object='lib/libgcrypt-grub/cipher/gcry_des_module-des.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_des_module_CPPFLAGS) $(CPPFLAGS) $(gcry_des_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_des_module-des.o `test -f 'lib/libgcrypt-grub/cipher/des.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/des.c
+
+lib/libgcrypt-grub/cipher/gcry_des_module-des.obj: lib/libgcrypt-grub/cipher/des.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_des_module_CPPFLAGS) $(CPPFLAGS) $(gcry_des_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_des_module-des.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_des_module-des.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_des_module-des.obj `if test -f 'lib/libgcrypt-grub/cipher/des.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/des.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/des.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_des_module-des.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_des_module-des.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/des.c' object='lib/libgcrypt-grub/cipher/gcry_des_module-des.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_des_module_CPPFLAGS) $(CPPFLAGS) $(gcry_des_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_des_module-des.obj `if test -f 'lib/libgcrypt-grub/cipher/des.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/des.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/des.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.o: lib/libgcrypt-grub/cipher/dsa.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_dsa_module_CPPFLAGS) $(CPPFLAGS) $(gcry_dsa_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_dsa_module-dsa.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.o `test -f 'lib/libgcrypt-grub/cipher/dsa.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/dsa.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_dsa_module-dsa.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_dsa_module-dsa.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/dsa.c' object='lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_dsa_module_CPPFLAGS) $(CPPFLAGS) $(gcry_dsa_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.o `test -f 'lib/libgcrypt-grub/cipher/dsa.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/dsa.c
+
+lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.obj: lib/libgcrypt-grub/cipher/dsa.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_dsa_module_CPPFLAGS) $(CPPFLAGS) $(gcry_dsa_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_dsa_module-dsa.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.obj `if test -f 'lib/libgcrypt-grub/cipher/dsa.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/dsa.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/dsa.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_dsa_module-dsa.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_dsa_module-dsa.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/dsa.c' object='lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_dsa_module_CPPFLAGS) $(CPPFLAGS) $(gcry_dsa_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_dsa_module-dsa.obj `if test -f 'lib/libgcrypt-grub/cipher/dsa.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/dsa.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/dsa.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_idea_module-idea.o: lib/libgcrypt-grub/cipher/idea.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_idea_module_CPPFLAGS) $(CPPFLAGS) $(gcry_idea_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_idea_module-idea.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_idea_module-idea.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_idea_module-idea.o `test -f 'lib/libgcrypt-grub/cipher/idea.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/idea.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_idea_module-idea.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_idea_module-idea.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/idea.c' object='lib/libgcrypt-grub/cipher/gcry_idea_module-idea.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_idea_module_CPPFLAGS) $(CPPFLAGS) $(gcry_idea_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_idea_module-idea.o `test -f 'lib/libgcrypt-grub/cipher/idea.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/idea.c
+
+lib/libgcrypt-grub/cipher/gcry_idea_module-idea.obj: lib/libgcrypt-grub/cipher/idea.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_idea_module_CPPFLAGS) $(CPPFLAGS) $(gcry_idea_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_idea_module-idea.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_idea_module-idea.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_idea_module-idea.obj `if test -f 'lib/libgcrypt-grub/cipher/idea.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/idea.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/idea.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_idea_module-idea.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_idea_module-idea.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/idea.c' object='lib/libgcrypt-grub/cipher/gcry_idea_module-idea.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_idea_module_CPPFLAGS) $(CPPFLAGS) $(gcry_idea_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_idea_module-idea.obj `if test -f 'lib/libgcrypt-grub/cipher/idea.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/idea.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/idea.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_md4_module-md4.o: lib/libgcrypt-grub/cipher/md4.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md4_module_CPPFLAGS) $(CPPFLAGS) $(gcry_md4_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_md4_module-md4.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md4_module-md4.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_md4_module-md4.o `test -f 'lib/libgcrypt-grub/cipher/md4.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/md4.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md4_module-md4.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md4_module-md4.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/md4.c' object='lib/libgcrypt-grub/cipher/gcry_md4_module-md4.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md4_module_CPPFLAGS) $(CPPFLAGS) $(gcry_md4_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_md4_module-md4.o `test -f 'lib/libgcrypt-grub/cipher/md4.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/md4.c
+
+lib/libgcrypt-grub/cipher/gcry_md4_module-md4.obj: lib/libgcrypt-grub/cipher/md4.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md4_module_CPPFLAGS) $(CPPFLAGS) $(gcry_md4_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_md4_module-md4.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md4_module-md4.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_md4_module-md4.obj `if test -f 'lib/libgcrypt-grub/cipher/md4.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/md4.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/md4.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md4_module-md4.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md4_module-md4.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/md4.c' object='lib/libgcrypt-grub/cipher/gcry_md4_module-md4.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md4_module_CPPFLAGS) $(CPPFLAGS) $(gcry_md4_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_md4_module-md4.obj `if test -f 'lib/libgcrypt-grub/cipher/md4.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/md4.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/md4.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_md5_module-md5.o: lib/libgcrypt-grub/cipher/md5.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md5_module_CPPFLAGS) $(CPPFLAGS) $(gcry_md5_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_md5_module-md5.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md5_module-md5.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_md5_module-md5.o `test -f 'lib/libgcrypt-grub/cipher/md5.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/md5.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md5_module-md5.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md5_module-md5.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/md5.c' object='lib/libgcrypt-grub/cipher/gcry_md5_module-md5.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md5_module_CPPFLAGS) $(CPPFLAGS) $(gcry_md5_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_md5_module-md5.o `test -f 'lib/libgcrypt-grub/cipher/md5.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/md5.c
+
+lib/libgcrypt-grub/cipher/gcry_md5_module-md5.obj: lib/libgcrypt-grub/cipher/md5.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md5_module_CPPFLAGS) $(CPPFLAGS) $(gcry_md5_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_md5_module-md5.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md5_module-md5.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_md5_module-md5.obj `if test -f 'lib/libgcrypt-grub/cipher/md5.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/md5.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/md5.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md5_module-md5.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_md5_module-md5.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/md5.c' object='lib/libgcrypt-grub/cipher/gcry_md5_module-md5.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md5_module_CPPFLAGS) $(CPPFLAGS) $(gcry_md5_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_md5_module-md5.obj `if test -f 'lib/libgcrypt-grub/cipher/md5.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/md5.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/md5.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.o: lib/libgcrypt-grub/cipher/rfc2268.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rfc2268_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rfc2268_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rfc2268_module-rfc2268.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.o `test -f 'lib/libgcrypt-grub/cipher/rfc2268.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/rfc2268.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rfc2268_module-rfc2268.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rfc2268_module-rfc2268.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/rfc2268.c' object='lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rfc2268_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rfc2268_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.o `test -f 'lib/libgcrypt-grub/cipher/rfc2268.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/rfc2268.c
+
+lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.obj: lib/libgcrypt-grub/cipher/rfc2268.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rfc2268_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rfc2268_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rfc2268_module-rfc2268.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.obj `if test -f 'lib/libgcrypt-grub/cipher/rfc2268.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/rfc2268.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/rfc2268.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rfc2268_module-rfc2268.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rfc2268_module-rfc2268.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/rfc2268.c' object='lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rfc2268_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rfc2268_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_rfc2268_module-rfc2268.obj `if test -f 'lib/libgcrypt-grub/cipher/rfc2268.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/rfc2268.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/rfc2268.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.o: lib/libgcrypt-grub/cipher/rijndael.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rijndael_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rijndael_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rijndael_module-rijndael.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.o `test -f 'lib/libgcrypt-grub/cipher/rijndael.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/rijndael.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rijndael_module-rijndael.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rijndael_module-rijndael.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/rijndael.c' object='lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rijndael_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rijndael_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.o `test -f 'lib/libgcrypt-grub/cipher/rijndael.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/rijndael.c
+
+lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.obj: lib/libgcrypt-grub/cipher/rijndael.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rijndael_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rijndael_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rijndael_module-rijndael.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.obj `if test -f 'lib/libgcrypt-grub/cipher/rijndael.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/rijndael.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/rijndael.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rijndael_module-rijndael.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rijndael_module-rijndael.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/rijndael.c' object='lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rijndael_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rijndael_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_rijndael_module-rijndael.obj `if test -f 'lib/libgcrypt-grub/cipher/rijndael.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/rijndael.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/rijndael.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.o: lib/libgcrypt-grub/cipher/rmd160.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rmd160_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rmd160_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rmd160_module-rmd160.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.o `test -f 'lib/libgcrypt-grub/cipher/rmd160.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/rmd160.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rmd160_module-rmd160.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rmd160_module-rmd160.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/rmd160.c' object='lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rmd160_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rmd160_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.o `test -f 'lib/libgcrypt-grub/cipher/rmd160.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/rmd160.c
+
+lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.obj: lib/libgcrypt-grub/cipher/rmd160.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rmd160_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rmd160_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rmd160_module-rmd160.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.obj `if test -f 'lib/libgcrypt-grub/cipher/rmd160.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/rmd160.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/rmd160.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rmd160_module-rmd160.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rmd160_module-rmd160.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/rmd160.c' object='lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rmd160_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rmd160_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_rmd160_module-rmd160.obj `if test -f 'lib/libgcrypt-grub/cipher/rmd160.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/rmd160.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/rmd160.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.o: lib/libgcrypt-grub/cipher/rsa.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rsa_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rsa_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rsa_module-rsa.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.o `test -f 'lib/libgcrypt-grub/cipher/rsa.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/rsa.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rsa_module-rsa.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rsa_module-rsa.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/rsa.c' object='lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rsa_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rsa_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.o `test -f 'lib/libgcrypt-grub/cipher/rsa.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/rsa.c
+
+lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.obj: lib/libgcrypt-grub/cipher/rsa.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rsa_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rsa_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rsa_module-rsa.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.obj `if test -f 'lib/libgcrypt-grub/cipher/rsa.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/rsa.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/rsa.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rsa_module-rsa.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_rsa_module-rsa.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/rsa.c' object='lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rsa_module_CPPFLAGS) $(CPPFLAGS) $(gcry_rsa_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_rsa_module-rsa.obj `if test -f 'lib/libgcrypt-grub/cipher/rsa.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/rsa.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/rsa.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_seed_module-seed.o: lib/libgcrypt-grub/cipher/seed.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_seed_module_CPPFLAGS) $(CPPFLAGS) $(gcry_seed_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_seed_module-seed.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_seed_module-seed.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_seed_module-seed.o `test -f 'lib/libgcrypt-grub/cipher/seed.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/seed.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_seed_module-seed.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_seed_module-seed.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/seed.c' object='lib/libgcrypt-grub/cipher/gcry_seed_module-seed.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_seed_module_CPPFLAGS) $(CPPFLAGS) $(gcry_seed_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_seed_module-seed.o `test -f 'lib/libgcrypt-grub/cipher/seed.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/seed.c
+
+lib/libgcrypt-grub/cipher/gcry_seed_module-seed.obj: lib/libgcrypt-grub/cipher/seed.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_seed_module_CPPFLAGS) $(CPPFLAGS) $(gcry_seed_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_seed_module-seed.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_seed_module-seed.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_seed_module-seed.obj `if test -f 'lib/libgcrypt-grub/cipher/seed.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/seed.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/seed.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_seed_module-seed.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_seed_module-seed.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/seed.c' object='lib/libgcrypt-grub/cipher/gcry_seed_module-seed.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_seed_module_CPPFLAGS) $(CPPFLAGS) $(gcry_seed_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_seed_module-seed.obj `if test -f 'lib/libgcrypt-grub/cipher/seed.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/seed.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/seed.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.o: lib/libgcrypt-grub/cipher/serpent.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_serpent_module_CPPFLAGS) $(CPPFLAGS) $(gcry_serpent_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_serpent_module-serpent.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.o `test -f 'lib/libgcrypt-grub/cipher/serpent.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/serpent.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_serpent_module-serpent.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_serpent_module-serpent.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/serpent.c' object='lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_serpent_module_CPPFLAGS) $(CPPFLAGS) $(gcry_serpent_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.o `test -f 'lib/libgcrypt-grub/cipher/serpent.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/serpent.c
+
+lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.obj: lib/libgcrypt-grub/cipher/serpent.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_serpent_module_CPPFLAGS) $(CPPFLAGS) $(gcry_serpent_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_serpent_module-serpent.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.obj `if test -f 'lib/libgcrypt-grub/cipher/serpent.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/serpent.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/serpent.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_serpent_module-serpent.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_serpent_module-serpent.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/serpent.c' object='lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_serpent_module_CPPFLAGS) $(CPPFLAGS) $(gcry_serpent_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_serpent_module-serpent.obj `if test -f 'lib/libgcrypt-grub/cipher/serpent.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/serpent.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/serpent.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.o: lib/libgcrypt-grub/cipher/sha1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha1_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha1_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha1_module-sha1.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.o `test -f 'lib/libgcrypt-grub/cipher/sha1.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/sha1.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha1_module-sha1.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha1_module-sha1.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/sha1.c' object='lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha1_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha1_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.o `test -f 'lib/libgcrypt-grub/cipher/sha1.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/sha1.c
+
+lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.obj: lib/libgcrypt-grub/cipher/sha1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha1_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha1_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha1_module-sha1.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.obj `if test -f 'lib/libgcrypt-grub/cipher/sha1.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/sha1.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/sha1.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha1_module-sha1.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha1_module-sha1.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/sha1.c' object='lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha1_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha1_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_sha1_module-sha1.obj `if test -f 'lib/libgcrypt-grub/cipher/sha1.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/sha1.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/sha1.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.o: lib/libgcrypt-grub/cipher/sha256.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha256_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha256_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha256_module-sha256.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.o `test -f 'lib/libgcrypt-grub/cipher/sha256.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/sha256.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha256_module-sha256.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha256_module-sha256.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/sha256.c' object='lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha256_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha256_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.o `test -f 'lib/libgcrypt-grub/cipher/sha256.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/sha256.c
+
+lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.obj: lib/libgcrypt-grub/cipher/sha256.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha256_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha256_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha256_module-sha256.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.obj `if test -f 'lib/libgcrypt-grub/cipher/sha256.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/sha256.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/sha256.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha256_module-sha256.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha256_module-sha256.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/sha256.c' object='lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha256_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha256_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_sha256_module-sha256.obj `if test -f 'lib/libgcrypt-grub/cipher/sha256.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/sha256.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/sha256.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.o: lib/libgcrypt-grub/cipher/sha512.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha512_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha512_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha512_module-sha512.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.o `test -f 'lib/libgcrypt-grub/cipher/sha512.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/sha512.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha512_module-sha512.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha512_module-sha512.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/sha512.c' object='lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha512_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha512_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.o `test -f 'lib/libgcrypt-grub/cipher/sha512.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/sha512.c
+
+lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.obj: lib/libgcrypt-grub/cipher/sha512.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha512_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha512_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha512_module-sha512.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.obj `if test -f 'lib/libgcrypt-grub/cipher/sha512.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/sha512.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/sha512.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha512_module-sha512.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_sha512_module-sha512.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/sha512.c' object='lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha512_module_CPPFLAGS) $(CPPFLAGS) $(gcry_sha512_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_sha512_module-sha512.obj `if test -f 'lib/libgcrypt-grub/cipher/sha512.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/sha512.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/sha512.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.o: lib/libgcrypt-grub/cipher/tiger.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_tiger_module_CPPFLAGS) $(CPPFLAGS) $(gcry_tiger_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_tiger_module-tiger.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.o `test -f 'lib/libgcrypt-grub/cipher/tiger.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/tiger.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_tiger_module-tiger.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_tiger_module-tiger.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/tiger.c' object='lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_tiger_module_CPPFLAGS) $(CPPFLAGS) $(gcry_tiger_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.o `test -f 'lib/libgcrypt-grub/cipher/tiger.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/tiger.c
+
+lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.obj: lib/libgcrypt-grub/cipher/tiger.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_tiger_module_CPPFLAGS) $(CPPFLAGS) $(gcry_tiger_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_tiger_module-tiger.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.obj `if test -f 'lib/libgcrypt-grub/cipher/tiger.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/tiger.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/tiger.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_tiger_module-tiger.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_tiger_module-tiger.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/tiger.c' object='lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_tiger_module_CPPFLAGS) $(CPPFLAGS) $(gcry_tiger_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_tiger_module-tiger.obj `if test -f 'lib/libgcrypt-grub/cipher/tiger.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/tiger.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/tiger.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.o: lib/libgcrypt-grub/cipher/twofish.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_twofish_module_CPPFLAGS) $(CPPFLAGS) $(gcry_twofish_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_twofish_module-twofish.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.o `test -f 'lib/libgcrypt-grub/cipher/twofish.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/twofish.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_twofish_module-twofish.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_twofish_module-twofish.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/twofish.c' object='lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_twofish_module_CPPFLAGS) $(CPPFLAGS) $(gcry_twofish_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.o `test -f 'lib/libgcrypt-grub/cipher/twofish.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/twofish.c
+
+lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.obj: lib/libgcrypt-grub/cipher/twofish.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_twofish_module_CPPFLAGS) $(CPPFLAGS) $(gcry_twofish_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_twofish_module-twofish.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.obj `if test -f 'lib/libgcrypt-grub/cipher/twofish.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/twofish.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/twofish.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_twofish_module-twofish.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_twofish_module-twofish.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/twofish.c' object='lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_twofish_module_CPPFLAGS) $(CPPFLAGS) $(gcry_twofish_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_twofish_module-twofish.obj `if test -f 'lib/libgcrypt-grub/cipher/twofish.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/twofish.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/twofish.c'; fi`
+
+lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.o: lib/libgcrypt-grub/cipher/whirlpool.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_whirlpool_module_CPPFLAGS) $(CPPFLAGS) $(gcry_whirlpool_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.o -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_whirlpool_module-whirlpool.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.o `test -f 'lib/libgcrypt-grub/cipher/whirlpool.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/whirlpool.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_whirlpool_module-whirlpool.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_whirlpool_module-whirlpool.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/whirlpool.c' object='lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_whirlpool_module_CPPFLAGS) $(CPPFLAGS) $(gcry_whirlpool_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.o `test -f 'lib/libgcrypt-grub/cipher/whirlpool.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/cipher/whirlpool.c
+
+lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.obj: lib/libgcrypt-grub/cipher/whirlpool.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_whirlpool_module_CPPFLAGS) $(CPPFLAGS) $(gcry_whirlpool_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.obj -MD -MP -MF lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_whirlpool_module-whirlpool.Tpo -c -o lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.obj `if test -f 'lib/libgcrypt-grub/cipher/whirlpool.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/whirlpool.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/whirlpool.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_whirlpool_module-whirlpool.Tpo lib/libgcrypt-grub/cipher/$(DEPDIR)/gcry_whirlpool_module-whirlpool.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/cipher/whirlpool.c' object='lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_whirlpool_module_CPPFLAGS) $(CPPFLAGS) $(gcry_whirlpool_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/cipher/gcry_whirlpool_module-whirlpool.obj `if test -f 'lib/libgcrypt-grub/cipher/whirlpool.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/cipher/whirlpool.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/cipher/whirlpool.c'; fi`
+
+gdb/i386/gdb_module-idt.o: gdb/i386/idt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -MT gdb/i386/gdb_module-idt.o -MD -MP -MF gdb/i386/$(DEPDIR)/gdb_module-idt.Tpo -c -o gdb/i386/gdb_module-idt.o `test -f 'gdb/i386/idt.c' || echo '$(srcdir)/'`gdb/i386/idt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdb/i386/$(DEPDIR)/gdb_module-idt.Tpo gdb/i386/$(DEPDIR)/gdb_module-idt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdb/i386/idt.c' object='gdb/i386/gdb_module-idt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -c -o gdb/i386/gdb_module-idt.o `test -f 'gdb/i386/idt.c' || echo '$(srcdir)/'`gdb/i386/idt.c
+
+gdb/i386/gdb_module-idt.obj: gdb/i386/idt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -MT gdb/i386/gdb_module-idt.obj -MD -MP -MF gdb/i386/$(DEPDIR)/gdb_module-idt.Tpo -c -o gdb/i386/gdb_module-idt.obj `if test -f 'gdb/i386/idt.c'; then $(CYGPATH_W) 'gdb/i386/idt.c'; else $(CYGPATH_W) '$(srcdir)/gdb/i386/idt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdb/i386/$(DEPDIR)/gdb_module-idt.Tpo gdb/i386/$(DEPDIR)/gdb_module-idt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdb/i386/idt.c' object='gdb/i386/gdb_module-idt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -c -o gdb/i386/gdb_module-idt.obj `if test -f 'gdb/i386/idt.c'; then $(CYGPATH_W) 'gdb/i386/idt.c'; else $(CYGPATH_W) '$(srcdir)/gdb/i386/idt.c'; fi`
+
+gdb/i386/gdb_module-signal.o: gdb/i386/signal.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -MT gdb/i386/gdb_module-signal.o -MD -MP -MF gdb/i386/$(DEPDIR)/gdb_module-signal.Tpo -c -o gdb/i386/gdb_module-signal.o `test -f 'gdb/i386/signal.c' || echo '$(srcdir)/'`gdb/i386/signal.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdb/i386/$(DEPDIR)/gdb_module-signal.Tpo gdb/i386/$(DEPDIR)/gdb_module-signal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdb/i386/signal.c' object='gdb/i386/gdb_module-signal.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -c -o gdb/i386/gdb_module-signal.o `test -f 'gdb/i386/signal.c' || echo '$(srcdir)/'`gdb/i386/signal.c
+
+gdb/i386/gdb_module-signal.obj: gdb/i386/signal.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -MT gdb/i386/gdb_module-signal.obj -MD -MP -MF gdb/i386/$(DEPDIR)/gdb_module-signal.Tpo -c -o gdb/i386/gdb_module-signal.obj `if test -f 'gdb/i386/signal.c'; then $(CYGPATH_W) 'gdb/i386/signal.c'; else $(CYGPATH_W) '$(srcdir)/gdb/i386/signal.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdb/i386/$(DEPDIR)/gdb_module-signal.Tpo gdb/i386/$(DEPDIR)/gdb_module-signal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdb/i386/signal.c' object='gdb/i386/gdb_module-signal.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -c -o gdb/i386/gdb_module-signal.obj `if test -f 'gdb/i386/signal.c'; then $(CYGPATH_W) 'gdb/i386/signal.c'; else $(CYGPATH_W) '$(srcdir)/gdb/i386/signal.c'; fi`
+
+gdb/gdb_module-cstub.o: gdb/cstub.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -MT gdb/gdb_module-cstub.o -MD -MP -MF gdb/$(DEPDIR)/gdb_module-cstub.Tpo -c -o gdb/gdb_module-cstub.o `test -f 'gdb/cstub.c' || echo '$(srcdir)/'`gdb/cstub.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdb/$(DEPDIR)/gdb_module-cstub.Tpo gdb/$(DEPDIR)/gdb_module-cstub.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdb/cstub.c' object='gdb/gdb_module-cstub.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -c -o gdb/gdb_module-cstub.o `test -f 'gdb/cstub.c' || echo '$(srcdir)/'`gdb/cstub.c
+
+gdb/gdb_module-cstub.obj: gdb/cstub.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -MT gdb/gdb_module-cstub.obj -MD -MP -MF gdb/$(DEPDIR)/gdb_module-cstub.Tpo -c -o gdb/gdb_module-cstub.obj `if test -f 'gdb/cstub.c'; then $(CYGPATH_W) 'gdb/cstub.c'; else $(CYGPATH_W) '$(srcdir)/gdb/cstub.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdb/$(DEPDIR)/gdb_module-cstub.Tpo gdb/$(DEPDIR)/gdb_module-cstub.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdb/cstub.c' object='gdb/gdb_module-cstub.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -c -o gdb/gdb_module-cstub.obj `if test -f 'gdb/cstub.c'; then $(CYGPATH_W) 'gdb/cstub.c'; else $(CYGPATH_W) '$(srcdir)/gdb/cstub.c'; fi`
+
+gdb/gdb_module-gdb.o: gdb/gdb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -MT gdb/gdb_module-gdb.o -MD -MP -MF gdb/$(DEPDIR)/gdb_module-gdb.Tpo -c -o gdb/gdb_module-gdb.o `test -f 'gdb/gdb.c' || echo '$(srcdir)/'`gdb/gdb.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdb/$(DEPDIR)/gdb_module-gdb.Tpo gdb/$(DEPDIR)/gdb_module-gdb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdb/gdb.c' object='gdb/gdb_module-gdb.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -c -o gdb/gdb_module-gdb.o `test -f 'gdb/gdb.c' || echo '$(srcdir)/'`gdb/gdb.c
+
+gdb/gdb_module-gdb.obj: gdb/gdb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -MT gdb/gdb_module-gdb.obj -MD -MP -MF gdb/$(DEPDIR)/gdb_module-gdb.Tpo -c -o gdb/gdb_module-gdb.obj `if test -f 'gdb/gdb.c'; then $(CYGPATH_W) 'gdb/gdb.c'; else $(CYGPATH_W) '$(srcdir)/gdb/gdb.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdb/$(DEPDIR)/gdb_module-gdb.Tpo gdb/$(DEPDIR)/gdb_module-gdb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdb/gdb.c' object='gdb/gdb_module-gdb.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $(gdb_module_CFLAGS) $(CFLAGS) -c -o gdb/gdb_module-gdb.obj `if test -f 'gdb/gdb.c'; then $(CYGPATH_W) 'gdb/gdb.c'; else $(CYGPATH_W) '$(srcdir)/gdb/gdb.c'; fi`
+
+disk/geli_module-geli.o: disk/geli.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(geli_module_CPPFLAGS) $(CPPFLAGS) $(geli_module_CFLAGS) $(CFLAGS) -MT disk/geli_module-geli.o -MD -MP -MF disk/$(DEPDIR)/geli_module-geli.Tpo -c -o disk/geli_module-geli.o `test -f 'disk/geli.c' || echo '$(srcdir)/'`disk/geli.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/geli_module-geli.Tpo disk/$(DEPDIR)/geli_module-geli.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/geli.c' object='disk/geli_module-geli.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(geli_module_CPPFLAGS) $(CPPFLAGS) $(geli_module_CFLAGS) $(CFLAGS) -c -o disk/geli_module-geli.o `test -f 'disk/geli.c' || echo '$(srcdir)/'`disk/geli.c
+
+disk/geli_module-geli.obj: disk/geli.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(geli_module_CPPFLAGS) $(CPPFLAGS) $(geli_module_CFLAGS) $(CFLAGS) -MT disk/geli_module-geli.obj -MD -MP -MF disk/$(DEPDIR)/geli_module-geli.Tpo -c -o disk/geli_module-geli.obj `if test -f 'disk/geli.c'; then $(CYGPATH_W) 'disk/geli.c'; else $(CYGPATH_W) '$(srcdir)/disk/geli.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/geli_module-geli.Tpo disk/$(DEPDIR)/geli_module-geli.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/geli.c' object='disk/geli_module-geli.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(geli_module_CPPFLAGS) $(CPPFLAGS) $(geli_module_CFLAGS) $(CFLAGS) -c -o disk/geli_module-geli.obj `if test -f 'disk/geli.c'; then $(CYGPATH_W) 'disk/geli.c'; else $(CYGPATH_W) '$(srcdir)/disk/geli.c'; fi`
+
+gettext/gettext_module-gettext.o: gettext/gettext.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gettext_module_CPPFLAGS) $(CPPFLAGS) $(gettext_module_CFLAGS) $(CFLAGS) -MT gettext/gettext_module-gettext.o -MD -MP -MF gettext/$(DEPDIR)/gettext_module-gettext.Tpo -c -o gettext/gettext_module-gettext.o `test -f 'gettext/gettext.c' || echo '$(srcdir)/'`gettext/gettext.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gettext/$(DEPDIR)/gettext_module-gettext.Tpo gettext/$(DEPDIR)/gettext_module-gettext.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gettext/gettext.c' object='gettext/gettext_module-gettext.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gettext_module_CPPFLAGS) $(CPPFLAGS) $(gettext_module_CFLAGS) $(CFLAGS) -c -o gettext/gettext_module-gettext.o `test -f 'gettext/gettext.c' || echo '$(srcdir)/'`gettext/gettext.c
+
+gettext/gettext_module-gettext.obj: gettext/gettext.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gettext_module_CPPFLAGS) $(CPPFLAGS) $(gettext_module_CFLAGS) $(CFLAGS) -MT gettext/gettext_module-gettext.obj -MD -MP -MF gettext/$(DEPDIR)/gettext_module-gettext.Tpo -c -o gettext/gettext_module-gettext.obj `if test -f 'gettext/gettext.c'; then $(CYGPATH_W) 'gettext/gettext.c'; else $(CYGPATH_W) '$(srcdir)/gettext/gettext.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gettext/$(DEPDIR)/gettext_module-gettext.Tpo gettext/$(DEPDIR)/gettext_module-gettext.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gettext/gettext.c' object='gettext/gettext_module-gettext.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gettext_module_CPPFLAGS) $(CPPFLAGS) $(gettext_module_CFLAGS) $(CFLAGS) -c -o gettext/gettext_module-gettext.obj `if test -f 'gettext/gettext.c'; then $(CYGPATH_W) 'gettext/gettext.c'; else $(CYGPATH_W) '$(srcdir)/gettext/gettext.c'; fi`
+
+gfxmenu/gfxmenu_module-gfxmenu.o: gfxmenu/gfxmenu.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gfxmenu.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gfxmenu.Tpo -c -o gfxmenu/gfxmenu_module-gfxmenu.o `test -f 'gfxmenu/gfxmenu.c' || echo '$(srcdir)/'`gfxmenu/gfxmenu.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gfxmenu.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gfxmenu.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gfxmenu.c' object='gfxmenu/gfxmenu_module-gfxmenu.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gfxmenu.o `test -f 'gfxmenu/gfxmenu.c' || echo '$(srcdir)/'`gfxmenu/gfxmenu.c
+
+gfxmenu/gfxmenu_module-gfxmenu.obj: gfxmenu/gfxmenu.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gfxmenu.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gfxmenu.Tpo -c -o gfxmenu/gfxmenu_module-gfxmenu.obj `if test -f 'gfxmenu/gfxmenu.c'; then $(CYGPATH_W) 'gfxmenu/gfxmenu.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gfxmenu.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gfxmenu.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gfxmenu.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gfxmenu.c' object='gfxmenu/gfxmenu_module-gfxmenu.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gfxmenu.obj `if test -f 'gfxmenu/gfxmenu.c'; then $(CYGPATH_W) 'gfxmenu/gfxmenu.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gfxmenu.c'; fi`
+
+gfxmenu/gfxmenu_module-view.o: gfxmenu/view.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-view.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-view.Tpo -c -o gfxmenu/gfxmenu_module-view.o `test -f 'gfxmenu/view.c' || echo '$(srcdir)/'`gfxmenu/view.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-view.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-view.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/view.c' object='gfxmenu/gfxmenu_module-view.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-view.o `test -f 'gfxmenu/view.c' || echo '$(srcdir)/'`gfxmenu/view.c
+
+gfxmenu/gfxmenu_module-view.obj: gfxmenu/view.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-view.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-view.Tpo -c -o gfxmenu/gfxmenu_module-view.obj `if test -f 'gfxmenu/view.c'; then $(CYGPATH_W) 'gfxmenu/view.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/view.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-view.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-view.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/view.c' object='gfxmenu/gfxmenu_module-view.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-view.obj `if test -f 'gfxmenu/view.c'; then $(CYGPATH_W) 'gfxmenu/view.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/view.c'; fi`
+
+gfxmenu/gfxmenu_module-font.o: gfxmenu/font.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-font.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-font.Tpo -c -o gfxmenu/gfxmenu_module-font.o `test -f 'gfxmenu/font.c' || echo '$(srcdir)/'`gfxmenu/font.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-font.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-font.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/font.c' object='gfxmenu/gfxmenu_module-font.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-font.o `test -f 'gfxmenu/font.c' || echo '$(srcdir)/'`gfxmenu/font.c
+
+gfxmenu/gfxmenu_module-font.obj: gfxmenu/font.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-font.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-font.Tpo -c -o gfxmenu/gfxmenu_module-font.obj `if test -f 'gfxmenu/font.c'; then $(CYGPATH_W) 'gfxmenu/font.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/font.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-font.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-font.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/font.c' object='gfxmenu/gfxmenu_module-font.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-font.obj `if test -f 'gfxmenu/font.c'; then $(CYGPATH_W) 'gfxmenu/font.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/font.c'; fi`
+
+gfxmenu/gfxmenu_module-icon_manager.o: gfxmenu/icon_manager.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-icon_manager.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-icon_manager.Tpo -c -o gfxmenu/gfxmenu_module-icon_manager.o `test -f 'gfxmenu/icon_manager.c' || echo '$(srcdir)/'`gfxmenu/icon_manager.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-icon_manager.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-icon_manager.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/icon_manager.c' object='gfxmenu/gfxmenu_module-icon_manager.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-icon_manager.o `test -f 'gfxmenu/icon_manager.c' || echo '$(srcdir)/'`gfxmenu/icon_manager.c
+
+gfxmenu/gfxmenu_module-icon_manager.obj: gfxmenu/icon_manager.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-icon_manager.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-icon_manager.Tpo -c -o gfxmenu/gfxmenu_module-icon_manager.obj `if test -f 'gfxmenu/icon_manager.c'; then $(CYGPATH_W) 'gfxmenu/icon_manager.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/icon_manager.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-icon_manager.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-icon_manager.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/icon_manager.c' object='gfxmenu/gfxmenu_module-icon_manager.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-icon_manager.obj `if test -f 'gfxmenu/icon_manager.c'; then $(CYGPATH_W) 'gfxmenu/icon_manager.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/icon_manager.c'; fi`
+
+gfxmenu/gfxmenu_module-theme_loader.o: gfxmenu/theme_loader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-theme_loader.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-theme_loader.Tpo -c -o gfxmenu/gfxmenu_module-theme_loader.o `test -f 'gfxmenu/theme_loader.c' || echo '$(srcdir)/'`gfxmenu/theme_loader.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-theme_loader.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-theme_loader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/theme_loader.c' object='gfxmenu/gfxmenu_module-theme_loader.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-theme_loader.o `test -f 'gfxmenu/theme_loader.c' || echo '$(srcdir)/'`gfxmenu/theme_loader.c
+
+gfxmenu/gfxmenu_module-theme_loader.obj: gfxmenu/theme_loader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-theme_loader.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-theme_loader.Tpo -c -o gfxmenu/gfxmenu_module-theme_loader.obj `if test -f 'gfxmenu/theme_loader.c'; then $(CYGPATH_W) 'gfxmenu/theme_loader.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/theme_loader.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-theme_loader.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-theme_loader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/theme_loader.c' object='gfxmenu/gfxmenu_module-theme_loader.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-theme_loader.obj `if test -f 'gfxmenu/theme_loader.c'; then $(CYGPATH_W) 'gfxmenu/theme_loader.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/theme_loader.c'; fi`
+
+gfxmenu/gfxmenu_module-widget-box.o: gfxmenu/widget-box.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-widget-box.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-widget-box.Tpo -c -o gfxmenu/gfxmenu_module-widget-box.o `test -f 'gfxmenu/widget-box.c' || echo '$(srcdir)/'`gfxmenu/widget-box.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-widget-box.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-widget-box.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/widget-box.c' object='gfxmenu/gfxmenu_module-widget-box.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-widget-box.o `test -f 'gfxmenu/widget-box.c' || echo '$(srcdir)/'`gfxmenu/widget-box.c
+
+gfxmenu/gfxmenu_module-widget-box.obj: gfxmenu/widget-box.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-widget-box.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-widget-box.Tpo -c -o gfxmenu/gfxmenu_module-widget-box.obj `if test -f 'gfxmenu/widget-box.c'; then $(CYGPATH_W) 'gfxmenu/widget-box.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/widget-box.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-widget-box.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-widget-box.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/widget-box.c' object='gfxmenu/gfxmenu_module-widget-box.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-widget-box.obj `if test -f 'gfxmenu/widget-box.c'; then $(CYGPATH_W) 'gfxmenu/widget-box.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/widget-box.c'; fi`
+
+gfxmenu/gfxmenu_module-gui_canvas.o: gfxmenu/gui_canvas.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_canvas.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_canvas.Tpo -c -o gfxmenu/gfxmenu_module-gui_canvas.o `test -f 'gfxmenu/gui_canvas.c' || echo '$(srcdir)/'`gfxmenu/gui_canvas.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_canvas.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_canvas.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_canvas.c' object='gfxmenu/gfxmenu_module-gui_canvas.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_canvas.o `test -f 'gfxmenu/gui_canvas.c' || echo '$(srcdir)/'`gfxmenu/gui_canvas.c
+
+gfxmenu/gfxmenu_module-gui_canvas.obj: gfxmenu/gui_canvas.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_canvas.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_canvas.Tpo -c -o gfxmenu/gfxmenu_module-gui_canvas.obj `if test -f 'gfxmenu/gui_canvas.c'; then $(CYGPATH_W) 'gfxmenu/gui_canvas.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_canvas.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_canvas.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_canvas.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_canvas.c' object='gfxmenu/gfxmenu_module-gui_canvas.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_canvas.obj `if test -f 'gfxmenu/gui_canvas.c'; then $(CYGPATH_W) 'gfxmenu/gui_canvas.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_canvas.c'; fi`
+
+gfxmenu/gfxmenu_module-gui_circular_progress.o: gfxmenu/gui_circular_progress.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_circular_progress.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_circular_progress.Tpo -c -o gfxmenu/gfxmenu_module-gui_circular_progress.o `test -f 'gfxmenu/gui_circular_progress.c' || echo '$(srcdir)/'`gfxmenu/gui_circular_progress.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_circular_progress.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_circular_progress.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_circular_progress.c' object='gfxmenu/gfxmenu_module-gui_circular_progress.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_circular_progress.o `test -f 'gfxmenu/gui_circular_progress.c' || echo '$(srcdir)/'`gfxmenu/gui_circular_progress.c
+
+gfxmenu/gfxmenu_module-gui_circular_progress.obj: gfxmenu/gui_circular_progress.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_circular_progress.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_circular_progress.Tpo -c -o gfxmenu/gfxmenu_module-gui_circular_progress.obj `if test -f 'gfxmenu/gui_circular_progress.c'; then $(CYGPATH_W) 'gfxmenu/gui_circular_progress.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_circular_progress.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_circular_progress.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_circular_progress.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_circular_progress.c' object='gfxmenu/gfxmenu_module-gui_circular_progress.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_circular_progress.obj `if test -f 'gfxmenu/gui_circular_progress.c'; then $(CYGPATH_W) 'gfxmenu/gui_circular_progress.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_circular_progress.c'; fi`
+
+gfxmenu/gfxmenu_module-gui_box.o: gfxmenu/gui_box.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_box.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_box.Tpo -c -o gfxmenu/gfxmenu_module-gui_box.o `test -f 'gfxmenu/gui_box.c' || echo '$(srcdir)/'`gfxmenu/gui_box.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_box.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_box.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_box.c' object='gfxmenu/gfxmenu_module-gui_box.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_box.o `test -f 'gfxmenu/gui_box.c' || echo '$(srcdir)/'`gfxmenu/gui_box.c
+
+gfxmenu/gfxmenu_module-gui_box.obj: gfxmenu/gui_box.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_box.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_box.Tpo -c -o gfxmenu/gfxmenu_module-gui_box.obj `if test -f 'gfxmenu/gui_box.c'; then $(CYGPATH_W) 'gfxmenu/gui_box.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_box.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_box.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_box.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_box.c' object='gfxmenu/gfxmenu_module-gui_box.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_box.obj `if test -f 'gfxmenu/gui_box.c'; then $(CYGPATH_W) 'gfxmenu/gui_box.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_box.c'; fi`
+
+gfxmenu/gfxmenu_module-gui_label.o: gfxmenu/gui_label.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_label.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_label.Tpo -c -o gfxmenu/gfxmenu_module-gui_label.o `test -f 'gfxmenu/gui_label.c' || echo '$(srcdir)/'`gfxmenu/gui_label.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_label.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_label.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_label.c' object='gfxmenu/gfxmenu_module-gui_label.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_label.o `test -f 'gfxmenu/gui_label.c' || echo '$(srcdir)/'`gfxmenu/gui_label.c
+
+gfxmenu/gfxmenu_module-gui_label.obj: gfxmenu/gui_label.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_label.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_label.Tpo -c -o gfxmenu/gfxmenu_module-gui_label.obj `if test -f 'gfxmenu/gui_label.c'; then $(CYGPATH_W) 'gfxmenu/gui_label.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_label.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_label.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_label.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_label.c' object='gfxmenu/gfxmenu_module-gui_label.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_label.obj `if test -f 'gfxmenu/gui_label.c'; then $(CYGPATH_W) 'gfxmenu/gui_label.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_label.c'; fi`
+
+gfxmenu/gfxmenu_module-gui_list.o: gfxmenu/gui_list.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_list.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_list.Tpo -c -o gfxmenu/gfxmenu_module-gui_list.o `test -f 'gfxmenu/gui_list.c' || echo '$(srcdir)/'`gfxmenu/gui_list.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_list.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_list.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_list.c' object='gfxmenu/gfxmenu_module-gui_list.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_list.o `test -f 'gfxmenu/gui_list.c' || echo '$(srcdir)/'`gfxmenu/gui_list.c
+
+gfxmenu/gfxmenu_module-gui_list.obj: gfxmenu/gui_list.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_list.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_list.Tpo -c -o gfxmenu/gfxmenu_module-gui_list.obj `if test -f 'gfxmenu/gui_list.c'; then $(CYGPATH_W) 'gfxmenu/gui_list.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_list.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_list.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_list.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_list.c' object='gfxmenu/gfxmenu_module-gui_list.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_list.obj `if test -f 'gfxmenu/gui_list.c'; then $(CYGPATH_W) 'gfxmenu/gui_list.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_list.c'; fi`
+
+gfxmenu/gfxmenu_module-gui_image.o: gfxmenu/gui_image.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_image.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_image.Tpo -c -o gfxmenu/gfxmenu_module-gui_image.o `test -f 'gfxmenu/gui_image.c' || echo '$(srcdir)/'`gfxmenu/gui_image.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_image.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_image.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_image.c' object='gfxmenu/gfxmenu_module-gui_image.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_image.o `test -f 'gfxmenu/gui_image.c' || echo '$(srcdir)/'`gfxmenu/gui_image.c
+
+gfxmenu/gfxmenu_module-gui_image.obj: gfxmenu/gui_image.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_image.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_image.Tpo -c -o gfxmenu/gfxmenu_module-gui_image.obj `if test -f 'gfxmenu/gui_image.c'; then $(CYGPATH_W) 'gfxmenu/gui_image.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_image.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_image.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_image.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_image.c' object='gfxmenu/gfxmenu_module-gui_image.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_image.obj `if test -f 'gfxmenu/gui_image.c'; then $(CYGPATH_W) 'gfxmenu/gui_image.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_image.c'; fi`
+
+gfxmenu/gfxmenu_module-gui_progress_bar.o: gfxmenu/gui_progress_bar.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_progress_bar.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_progress_bar.Tpo -c -o gfxmenu/gfxmenu_module-gui_progress_bar.o `test -f 'gfxmenu/gui_progress_bar.c' || echo '$(srcdir)/'`gfxmenu/gui_progress_bar.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_progress_bar.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_progress_bar.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_progress_bar.c' object='gfxmenu/gfxmenu_module-gui_progress_bar.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_progress_bar.o `test -f 'gfxmenu/gui_progress_bar.c' || echo '$(srcdir)/'`gfxmenu/gui_progress_bar.c
+
+gfxmenu/gfxmenu_module-gui_progress_bar.obj: gfxmenu/gui_progress_bar.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_progress_bar.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_progress_bar.Tpo -c -o gfxmenu/gfxmenu_module-gui_progress_bar.obj `if test -f 'gfxmenu/gui_progress_bar.c'; then $(CYGPATH_W) 'gfxmenu/gui_progress_bar.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_progress_bar.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_progress_bar.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_progress_bar.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_progress_bar.c' object='gfxmenu/gfxmenu_module-gui_progress_bar.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_progress_bar.obj `if test -f 'gfxmenu/gui_progress_bar.c'; then $(CYGPATH_W) 'gfxmenu/gui_progress_bar.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_progress_bar.c'; fi`
+
+gfxmenu/gfxmenu_module-gui_util.o: gfxmenu/gui_util.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_util.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_util.Tpo -c -o gfxmenu/gfxmenu_module-gui_util.o `test -f 'gfxmenu/gui_util.c' || echo '$(srcdir)/'`gfxmenu/gui_util.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_util.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_util.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_util.c' object='gfxmenu/gfxmenu_module-gui_util.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_util.o `test -f 'gfxmenu/gui_util.c' || echo '$(srcdir)/'`gfxmenu/gui_util.c
+
+gfxmenu/gfxmenu_module-gui_util.obj: gfxmenu/gui_util.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_util.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_util.Tpo -c -o gfxmenu/gfxmenu_module-gui_util.obj `if test -f 'gfxmenu/gui_util.c'; then $(CYGPATH_W) 'gfxmenu/gui_util.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_util.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_util.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_util.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_util.c' object='gfxmenu/gfxmenu_module-gui_util.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_util.obj `if test -f 'gfxmenu/gui_util.c'; then $(CYGPATH_W) 'gfxmenu/gui_util.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_util.c'; fi`
+
+gfxmenu/gfxmenu_module-gui_string_util.o: gfxmenu/gui_string_util.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_string_util.o -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_string_util.Tpo -c -o gfxmenu/gfxmenu_module-gui_string_util.o `test -f 'gfxmenu/gui_string_util.c' || echo '$(srcdir)/'`gfxmenu/gui_string_util.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_string_util.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_string_util.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_string_util.c' object='gfxmenu/gfxmenu_module-gui_string_util.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_string_util.o `test -f 'gfxmenu/gui_string_util.c' || echo '$(srcdir)/'`gfxmenu/gui_string_util.c
+
+gfxmenu/gfxmenu_module-gui_string_util.obj: gfxmenu/gui_string_util.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -MT gfxmenu/gfxmenu_module-gui_string_util.obj -MD -MP -MF gfxmenu/$(DEPDIR)/gfxmenu_module-gui_string_util.Tpo -c -o gfxmenu/gfxmenu_module-gui_string_util.obj `if test -f 'gfxmenu/gui_string_util.c'; then $(CYGPATH_W) 'gfxmenu/gui_string_util.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_string_util.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gfxmenu/$(DEPDIR)/gfxmenu_module-gui_string_util.Tpo gfxmenu/$(DEPDIR)/gfxmenu_module-gui_string_util.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gfxmenu/gui_string_util.c' object='gfxmenu/gfxmenu_module-gui_string_util.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $(gfxmenu_module_CFLAGS) $(CFLAGS) -c -o gfxmenu/gfxmenu_module-gui_string_util.obj `if test -f 'gfxmenu/gui_string_util.c'; then $(CYGPATH_W) 'gfxmenu/gui_string_util.c'; else $(CYGPATH_W) '$(srcdir)/gfxmenu/gui_string_util.c'; fi`
+
+term/gfxterm_module-gfxterm.o: term/gfxterm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_module_CFLAGS) $(CFLAGS) -MT term/gfxterm_module-gfxterm.o -MD -MP -MF term/$(DEPDIR)/gfxterm_module-gfxterm.Tpo -c -o term/gfxterm_module-gfxterm.o `test -f 'term/gfxterm.c' || echo '$(srcdir)/'`term/gfxterm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/gfxterm_module-gfxterm.Tpo term/$(DEPDIR)/gfxterm_module-gfxterm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/gfxterm.c' object='term/gfxterm_module-gfxterm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_module_CFLAGS) $(CFLAGS) -c -o term/gfxterm_module-gfxterm.o `test -f 'term/gfxterm.c' || echo '$(srcdir)/'`term/gfxterm.c
+
+term/gfxterm_module-gfxterm.obj: term/gfxterm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_module_CFLAGS) $(CFLAGS) -MT term/gfxterm_module-gfxterm.obj -MD -MP -MF term/$(DEPDIR)/gfxterm_module-gfxterm.Tpo -c -o term/gfxterm_module-gfxterm.obj `if test -f 'term/gfxterm.c'; then $(CYGPATH_W) 'term/gfxterm.c'; else $(CYGPATH_W) '$(srcdir)/term/gfxterm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/gfxterm_module-gfxterm.Tpo term/$(DEPDIR)/gfxterm_module-gfxterm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/gfxterm.c' object='term/gfxterm_module-gfxterm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_module_CFLAGS) $(CFLAGS) -c -o term/gfxterm_module-gfxterm.obj `if test -f 'term/gfxterm.c'; then $(CYGPATH_W) 'term/gfxterm.c'; else $(CYGPATH_W) '$(srcdir)/term/gfxterm.c'; fi`
+
+term/gfxterm_background_module-gfxterm_background.o: term/gfxterm_background.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_background_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_background_module_CFLAGS) $(CFLAGS) -MT term/gfxterm_background_module-gfxterm_background.o -MD -MP -MF term/$(DEPDIR)/gfxterm_background_module-gfxterm_background.Tpo -c -o term/gfxterm_background_module-gfxterm_background.o `test -f 'term/gfxterm_background.c' || echo '$(srcdir)/'`term/gfxterm_background.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/gfxterm_background_module-gfxterm_background.Tpo term/$(DEPDIR)/gfxterm_background_module-gfxterm_background.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/gfxterm_background.c' object='term/gfxterm_background_module-gfxterm_background.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_background_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_background_module_CFLAGS) $(CFLAGS) -c -o term/gfxterm_background_module-gfxterm_background.o `test -f 'term/gfxterm_background.c' || echo '$(srcdir)/'`term/gfxterm_background.c
+
+term/gfxterm_background_module-gfxterm_background.obj: term/gfxterm_background.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_background_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_background_module_CFLAGS) $(CFLAGS) -MT term/gfxterm_background_module-gfxterm_background.obj -MD -MP -MF term/$(DEPDIR)/gfxterm_background_module-gfxterm_background.Tpo -c -o term/gfxterm_background_module-gfxterm_background.obj `if test -f 'term/gfxterm_background.c'; then $(CYGPATH_W) 'term/gfxterm_background.c'; else $(CYGPATH_W) '$(srcdir)/term/gfxterm_background.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/gfxterm_background_module-gfxterm_background.Tpo term/$(DEPDIR)/gfxterm_background_module-gfxterm_background.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/gfxterm_background.c' object='term/gfxterm_background_module-gfxterm_background.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_background_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_background_module_CFLAGS) $(CFLAGS) -c -o term/gfxterm_background_module-gfxterm_background.obj `if test -f 'term/gfxterm_background.c'; then $(CYGPATH_W) 'term/gfxterm_background.c'; else $(CYGPATH_W) '$(srcdir)/term/gfxterm_background.c'; fi`
+
+tests/gfxterm_menu_module-gfxterm_menu.o: tests/gfxterm_menu.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_menu_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_menu_module_CFLAGS) $(CFLAGS) -MT tests/gfxterm_menu_module-gfxterm_menu.o -MD -MP -MF tests/$(DEPDIR)/gfxterm_menu_module-gfxterm_menu.Tpo -c -o tests/gfxterm_menu_module-gfxterm_menu.o `test -f 'tests/gfxterm_menu.c' || echo '$(srcdir)/'`tests/gfxterm_menu.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/gfxterm_menu_module-gfxterm_menu.Tpo tests/$(DEPDIR)/gfxterm_menu_module-gfxterm_menu.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/gfxterm_menu.c' object='tests/gfxterm_menu_module-gfxterm_menu.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_menu_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_menu_module_CFLAGS) $(CFLAGS) -c -o tests/gfxterm_menu_module-gfxterm_menu.o `test -f 'tests/gfxterm_menu.c' || echo '$(srcdir)/'`tests/gfxterm_menu.c
+
+tests/gfxterm_menu_module-gfxterm_menu.obj: tests/gfxterm_menu.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_menu_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_menu_module_CFLAGS) $(CFLAGS) -MT tests/gfxterm_menu_module-gfxterm_menu.obj -MD -MP -MF tests/$(DEPDIR)/gfxterm_menu_module-gfxterm_menu.Tpo -c -o tests/gfxterm_menu_module-gfxterm_menu.obj `if test -f 'tests/gfxterm_menu.c'; then $(CYGPATH_W) 'tests/gfxterm_menu.c'; else $(CYGPATH_W) '$(srcdir)/tests/gfxterm_menu.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/gfxterm_menu_module-gfxterm_menu.Tpo tests/$(DEPDIR)/gfxterm_menu_module-gfxterm_menu.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/gfxterm_menu.c' object='tests/gfxterm_menu_module-gfxterm_menu.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_menu_module_CPPFLAGS) $(CPPFLAGS) $(gfxterm_menu_module_CFLAGS) $(CFLAGS) -c -o tests/gfxterm_menu_module-gfxterm_menu.obj `if test -f 'tests/gfxterm_menu.c'; then $(CYGPATH_W) 'tests/gfxterm_menu.c'; else $(CYGPATH_W) '$(srcdir)/tests/gfxterm_menu.c'; fi`
+
+commands/gptsync_module-gptsync.o: commands/gptsync.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gptsync_module_CPPFLAGS) $(CPPFLAGS) $(gptsync_module_CFLAGS) $(CFLAGS) -MT commands/gptsync_module-gptsync.o -MD -MP -MF commands/$(DEPDIR)/gptsync_module-gptsync.Tpo -c -o commands/gptsync_module-gptsync.o `test -f 'commands/gptsync.c' || echo '$(srcdir)/'`commands/gptsync.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/gptsync_module-gptsync.Tpo commands/$(DEPDIR)/gptsync_module-gptsync.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/gptsync.c' object='commands/gptsync_module-gptsync.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gptsync_module_CPPFLAGS) $(CPPFLAGS) $(gptsync_module_CFLAGS) $(CFLAGS) -c -o commands/gptsync_module-gptsync.o `test -f 'commands/gptsync.c' || echo '$(srcdir)/'`commands/gptsync.c
+
+commands/gptsync_module-gptsync.obj: commands/gptsync.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gptsync_module_CPPFLAGS) $(CPPFLAGS) $(gptsync_module_CFLAGS) $(CFLAGS) -MT commands/gptsync_module-gptsync.obj -MD -MP -MF commands/$(DEPDIR)/gptsync_module-gptsync.Tpo -c -o commands/gptsync_module-gptsync.obj `if test -f 'commands/gptsync.c'; then $(CYGPATH_W) 'commands/gptsync.c'; else $(CYGPATH_W) '$(srcdir)/commands/gptsync.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/gptsync_module-gptsync.Tpo commands/$(DEPDIR)/gptsync_module-gptsync.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/gptsync.c' object='commands/gptsync_module-gptsync.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gptsync_module_CPPFLAGS) $(CPPFLAGS) $(gptsync_module_CFLAGS) $(CFLAGS) -c -o commands/gptsync_module-gptsync.obj `if test -f 'commands/gptsync.c'; then $(CYGPATH_W) 'commands/gptsync.c'; else $(CYGPATH_W) '$(srcdir)/commands/gptsync.c'; fi`
+
+kern/emu/grub_emu-full.o: kern/emu/full.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_CPPFLAGS) $(CPPFLAGS) $(grub_emu_CFLAGS) $(CFLAGS) -MT kern/emu/grub_emu-full.o -MD -MP -MF kern/emu/$(DEPDIR)/grub_emu-full.Tpo -c -o kern/emu/grub_emu-full.o `test -f 'kern/emu/full.c' || echo '$(srcdir)/'`kern/emu/full.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/grub_emu-full.Tpo kern/emu/$(DEPDIR)/grub_emu-full.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/full.c' object='kern/emu/grub_emu-full.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_CPPFLAGS) $(CPPFLAGS) $(grub_emu_CFLAGS) $(CFLAGS) -c -o kern/emu/grub_emu-full.o `test -f 'kern/emu/full.c' || echo '$(srcdir)/'`kern/emu/full.c
+
+kern/emu/grub_emu-full.obj: kern/emu/full.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_CPPFLAGS) $(CPPFLAGS) $(grub_emu_CFLAGS) $(CFLAGS) -MT kern/emu/grub_emu-full.obj -MD -MP -MF kern/emu/$(DEPDIR)/grub_emu-full.Tpo -c -o kern/emu/grub_emu-full.obj `if test -f 'kern/emu/full.c'; then $(CYGPATH_W) 'kern/emu/full.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/full.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/grub_emu-full.Tpo kern/emu/$(DEPDIR)/grub_emu-full.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/full.c' object='kern/emu/grub_emu-full.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_CPPFLAGS) $(CPPFLAGS) $(grub_emu_CFLAGS) $(CFLAGS) -c -o kern/emu/grub_emu-full.obj `if test -f 'kern/emu/full.c'; then $(CYGPATH_W) 'kern/emu/full.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/full.c'; fi`
+
+grub_emu-grub_emu_init.o: grub_emu_init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_CPPFLAGS) $(CPPFLAGS) $(grub_emu_CFLAGS) $(CFLAGS) -MT grub_emu-grub_emu_init.o -MD -MP -MF $(DEPDIR)/grub_emu-grub_emu_init.Tpo -c -o grub_emu-grub_emu_init.o `test -f 'grub_emu_init.c' || echo '$(srcdir)/'`grub_emu_init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/grub_emu-grub_emu_init.Tpo $(DEPDIR)/grub_emu-grub_emu_init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='grub_emu_init.c' object='grub_emu-grub_emu_init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_CPPFLAGS) $(CPPFLAGS) $(grub_emu_CFLAGS) $(CFLAGS) -c -o grub_emu-grub_emu_init.o `test -f 'grub_emu_init.c' || echo '$(srcdir)/'`grub_emu_init.c
+
+grub_emu-grub_emu_init.obj: grub_emu_init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_CPPFLAGS) $(CPPFLAGS) $(grub_emu_CFLAGS) $(CFLAGS) -MT grub_emu-grub_emu_init.obj -MD -MP -MF $(DEPDIR)/grub_emu-grub_emu_init.Tpo -c -o grub_emu-grub_emu_init.obj `if test -f 'grub_emu_init.c'; then $(CYGPATH_W) 'grub_emu_init.c'; else $(CYGPATH_W) '$(srcdir)/grub_emu_init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/grub_emu-grub_emu_init.Tpo $(DEPDIR)/grub_emu-grub_emu_init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='grub_emu_init.c' object='grub_emu-grub_emu_init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_CPPFLAGS) $(CPPFLAGS) $(grub_emu_CFLAGS) $(CFLAGS) -c -o grub_emu-grub_emu_init.obj `if test -f 'grub_emu_init.c'; then $(CYGPATH_W) 'grub_emu_init.c'; else $(CYGPATH_W) '$(srcdir)/grub_emu_init.c'; fi`
+
+kern/emu/grub_emu_lite-lite.o: kern/emu/lite.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_lite_CPPFLAGS) $(CPPFLAGS) $(grub_emu_lite_CFLAGS) $(CFLAGS) -MT kern/emu/grub_emu_lite-lite.o -MD -MP -MF kern/emu/$(DEPDIR)/grub_emu_lite-lite.Tpo -c -o kern/emu/grub_emu_lite-lite.o `test -f 'kern/emu/lite.c' || echo '$(srcdir)/'`kern/emu/lite.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/grub_emu_lite-lite.Tpo kern/emu/$(DEPDIR)/grub_emu_lite-lite.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/lite.c' object='kern/emu/grub_emu_lite-lite.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_lite_CPPFLAGS) $(CPPFLAGS) $(grub_emu_lite_CFLAGS) $(CFLAGS) -c -o kern/emu/grub_emu_lite-lite.o `test -f 'kern/emu/lite.c' || echo '$(srcdir)/'`kern/emu/lite.c
+
+kern/emu/grub_emu_lite-lite.obj: kern/emu/lite.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_lite_CPPFLAGS) $(CPPFLAGS) $(grub_emu_lite_CFLAGS) $(CFLAGS) -MT kern/emu/grub_emu_lite-lite.obj -MD -MP -MF kern/emu/$(DEPDIR)/grub_emu_lite-lite.Tpo -c -o kern/emu/grub_emu_lite-lite.obj `if test -f 'kern/emu/lite.c'; then $(CYGPATH_W) 'kern/emu/lite.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/lite.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/grub_emu_lite-lite.Tpo kern/emu/$(DEPDIR)/grub_emu_lite-lite.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/lite.c' object='kern/emu/grub_emu_lite-lite.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_lite_CPPFLAGS) $(CPPFLAGS) $(grub_emu_lite_CFLAGS) $(CFLAGS) -c -o kern/emu/grub_emu_lite-lite.obj `if test -f 'kern/emu/lite.c'; then $(CYGPATH_W) 'kern/emu/lite.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/lite.c'; fi`
+
+grub_emu_lite-symlist.o: symlist.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_lite_CPPFLAGS) $(CPPFLAGS) $(grub_emu_lite_CFLAGS) $(CFLAGS) -MT grub_emu_lite-symlist.o -MD -MP -MF $(DEPDIR)/grub_emu_lite-symlist.Tpo -c -o grub_emu_lite-symlist.o `test -f 'symlist.c' || echo '$(srcdir)/'`symlist.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/grub_emu_lite-symlist.Tpo $(DEPDIR)/grub_emu_lite-symlist.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='symlist.c' object='grub_emu_lite-symlist.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_lite_CPPFLAGS) $(CPPFLAGS) $(grub_emu_lite_CFLAGS) $(CFLAGS) -c -o grub_emu_lite-symlist.o `test -f 'symlist.c' || echo '$(srcdir)/'`symlist.c
+
+grub_emu_lite-symlist.obj: symlist.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_lite_CPPFLAGS) $(CPPFLAGS) $(grub_emu_lite_CFLAGS) $(CFLAGS) -MT grub_emu_lite-symlist.obj -MD -MP -MF $(DEPDIR)/grub_emu_lite-symlist.Tpo -c -o grub_emu_lite-symlist.obj `if test -f 'symlist.c'; then $(CYGPATH_W) 'symlist.c'; else $(CYGPATH_W) '$(srcdir)/symlist.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/grub_emu_lite-symlist.Tpo $(DEPDIR)/grub_emu_lite-symlist.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='symlist.c' object='grub_emu_lite-symlist.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(grub_emu_lite_CPPFLAGS) $(CPPFLAGS) $(grub_emu_lite_CFLAGS) $(CFLAGS) -c -o grub_emu_lite-symlist.obj `if test -f 'symlist.c'; then $(CYGPATH_W) 'symlist.c'; else $(CYGPATH_W) '$(srcdir)/symlist.c'; fi`
+
+io/gzio_module-gzio.o: io/gzio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gzio_module_CPPFLAGS) $(CPPFLAGS) $(gzio_module_CFLAGS) $(CFLAGS) -MT io/gzio_module-gzio.o -MD -MP -MF io/$(DEPDIR)/gzio_module-gzio.Tpo -c -o io/gzio_module-gzio.o `test -f 'io/gzio.c' || echo '$(srcdir)/'`io/gzio.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/gzio_module-gzio.Tpo io/$(DEPDIR)/gzio_module-gzio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/gzio.c' object='io/gzio_module-gzio.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gzio_module_CPPFLAGS) $(CPPFLAGS) $(gzio_module_CFLAGS) $(CFLAGS) -c -o io/gzio_module-gzio.o `test -f 'io/gzio.c' || echo '$(srcdir)/'`io/gzio.c
+
+io/gzio_module-gzio.obj: io/gzio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gzio_module_CPPFLAGS) $(CPPFLAGS) $(gzio_module_CFLAGS) $(CFLAGS) -MT io/gzio_module-gzio.obj -MD -MP -MF io/$(DEPDIR)/gzio_module-gzio.Tpo -c -o io/gzio_module-gzio.obj `if test -f 'io/gzio.c'; then $(CYGPATH_W) 'io/gzio.c'; else $(CYGPATH_W) '$(srcdir)/io/gzio.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/gzio_module-gzio.Tpo io/$(DEPDIR)/gzio_module-gzio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/gzio.c' object='io/gzio_module-gzio.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gzio_module_CPPFLAGS) $(CPPFLAGS) $(gzio_module_CFLAGS) $(CFLAGS) -c -o io/gzio_module-gzio.obj `if test -f 'io/gzio.c'; then $(CYGPATH_W) 'io/gzio.c'; else $(CYGPATH_W) '$(srcdir)/io/gzio.c'; fi`
+
+lib/efi/halt_module-halt.o: lib/efi/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/efi/halt_module-halt.o -MD -MP -MF lib/efi/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/efi/halt_module-halt.o `test -f 'lib/efi/halt.c' || echo '$(srcdir)/'`lib/efi/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/efi/$(DEPDIR)/halt_module-halt.Tpo lib/efi/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/efi/halt.c' object='lib/efi/halt_module-halt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/efi/halt_module-halt.o `test -f 'lib/efi/halt.c' || echo '$(srcdir)/'`lib/efi/halt.c
+
+lib/efi/halt_module-halt.obj: lib/efi/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/efi/halt_module-halt.obj -MD -MP -MF lib/efi/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/efi/halt_module-halt.obj `if test -f 'lib/efi/halt.c'; then $(CYGPATH_W) 'lib/efi/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/efi/halt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/efi/$(DEPDIR)/halt_module-halt.Tpo lib/efi/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/efi/halt.c' object='lib/efi/halt_module-halt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/efi/halt_module-halt.obj `if test -f 'lib/efi/halt.c'; then $(CYGPATH_W) 'lib/efi/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/efi/halt.c'; fi`
+
+commands/halt_module-halt.o: commands/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT commands/halt_module-halt.o -MD -MP -MF commands/$(DEPDIR)/halt_module-halt.Tpo -c -o commands/halt_module-halt.o `test -f 'commands/halt.c' || echo '$(srcdir)/'`commands/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/halt_module-halt.Tpo commands/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/halt.c' object='commands/halt_module-halt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o commands/halt_module-halt.o `test -f 'commands/halt.c' || echo '$(srcdir)/'`commands/halt.c
+
+commands/halt_module-halt.obj: commands/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT commands/halt_module-halt.obj -MD -MP -MF commands/$(DEPDIR)/halt_module-halt.Tpo -c -o commands/halt_module-halt.obj `if test -f 'commands/halt.c'; then $(CYGPATH_W) 'commands/halt.c'; else $(CYGPATH_W) '$(srcdir)/commands/halt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/halt_module-halt.Tpo commands/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/halt.c' object='commands/halt_module-halt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o commands/halt_module-halt.obj `if test -f 'commands/halt.c'; then $(CYGPATH_W) 'commands/halt.c'; else $(CYGPATH_W) '$(srcdir)/commands/halt.c'; fi`
+
+lib/dummy/halt_module-halt.o: lib/dummy/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/dummy/halt_module-halt.o -MD -MP -MF lib/dummy/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/dummy/halt_module-halt.o `test -f 'lib/dummy/halt.c' || echo '$(srcdir)/'`lib/dummy/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/dummy/$(DEPDIR)/halt_module-halt.Tpo lib/dummy/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/dummy/halt.c' object='lib/dummy/halt_module-halt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/dummy/halt_module-halt.o `test -f 'lib/dummy/halt.c' || echo '$(srcdir)/'`lib/dummy/halt.c
+
+lib/dummy/halt_module-halt.obj: lib/dummy/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/dummy/halt_module-halt.obj -MD -MP -MF lib/dummy/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/dummy/halt_module-halt.obj `if test -f 'lib/dummy/halt.c'; then $(CYGPATH_W) 'lib/dummy/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/dummy/halt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/dummy/$(DEPDIR)/halt_module-halt.Tpo lib/dummy/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/dummy/halt.c' object='lib/dummy/halt_module-halt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/dummy/halt_module-halt.obj `if test -f 'lib/dummy/halt.c'; then $(CYGPATH_W) 'lib/dummy/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/dummy/halt.c'; fi`
+
+lib/emu/halt_module-halt.o: lib/emu/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/emu/halt_module-halt.o -MD -MP -MF lib/emu/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/emu/halt_module-halt.o `test -f 'lib/emu/halt.c' || echo '$(srcdir)/'`lib/emu/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/emu/$(DEPDIR)/halt_module-halt.Tpo lib/emu/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/emu/halt.c' object='lib/emu/halt_module-halt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/emu/halt_module-halt.o `test -f 'lib/emu/halt.c' || echo '$(srcdir)/'`lib/emu/halt.c
+
+lib/emu/halt_module-halt.obj: lib/emu/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/emu/halt_module-halt.obj -MD -MP -MF lib/emu/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/emu/halt_module-halt.obj `if test -f 'lib/emu/halt.c'; then $(CYGPATH_W) 'lib/emu/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/emu/halt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/emu/$(DEPDIR)/halt_module-halt.Tpo lib/emu/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/emu/halt.c' object='lib/emu/halt_module-halt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/emu/halt_module-halt.obj `if test -f 'lib/emu/halt.c'; then $(CYGPATH_W) 'lib/emu/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/emu/halt.c'; fi`
+
+commands/halt_module-acpihalt.o: commands/acpihalt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT commands/halt_module-acpihalt.o -MD -MP -MF commands/$(DEPDIR)/halt_module-acpihalt.Tpo -c -o commands/halt_module-acpihalt.o `test -f 'commands/acpihalt.c' || echo '$(srcdir)/'`commands/acpihalt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/halt_module-acpihalt.Tpo commands/$(DEPDIR)/halt_module-acpihalt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/acpihalt.c' object='commands/halt_module-acpihalt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o commands/halt_module-acpihalt.o `test -f 'commands/acpihalt.c' || echo '$(srcdir)/'`commands/acpihalt.c
+
+commands/halt_module-acpihalt.obj: commands/acpihalt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT commands/halt_module-acpihalt.obj -MD -MP -MF commands/$(DEPDIR)/halt_module-acpihalt.Tpo -c -o commands/halt_module-acpihalt.obj `if test -f 'commands/acpihalt.c'; then $(CYGPATH_W) 'commands/acpihalt.c'; else $(CYGPATH_W) '$(srcdir)/commands/acpihalt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/halt_module-acpihalt.Tpo commands/$(DEPDIR)/halt_module-acpihalt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/acpihalt.c' object='commands/halt_module-acpihalt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o commands/halt_module-acpihalt.obj `if test -f 'commands/acpihalt.c'; then $(CYGPATH_W) 'commands/acpihalt.c'; else $(CYGPATH_W) '$(srcdir)/commands/acpihalt.c'; fi`
+
+lib/i386/halt_module-halt.o: lib/i386/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/i386/halt_module-halt.o -MD -MP -MF lib/i386/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/i386/halt_module-halt.o `test -f 'lib/i386/halt.c' || echo '$(srcdir)/'`lib/i386/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/halt_module-halt.Tpo lib/i386/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/halt.c' object='lib/i386/halt_module-halt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/i386/halt_module-halt.o `test -f 'lib/i386/halt.c' || echo '$(srcdir)/'`lib/i386/halt.c
+
+lib/i386/halt_module-halt.obj: lib/i386/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/i386/halt_module-halt.obj -MD -MP -MF lib/i386/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/i386/halt_module-halt.obj `if test -f 'lib/i386/halt.c'; then $(CYGPATH_W) 'lib/i386/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/halt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/halt_module-halt.Tpo lib/i386/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/halt.c' object='lib/i386/halt_module-halt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/i386/halt_module-halt.obj `if test -f 'lib/i386/halt.c'; then $(CYGPATH_W) 'lib/i386/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/halt.c'; fi`
+
+lib/ieee1275/halt_module-halt.o: lib/ieee1275/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/ieee1275/halt_module-halt.o -MD -MP -MF lib/ieee1275/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/ieee1275/halt_module-halt.o `test -f 'lib/ieee1275/halt.c' || echo '$(srcdir)/'`lib/ieee1275/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/ieee1275/$(DEPDIR)/halt_module-halt.Tpo lib/ieee1275/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/ieee1275/halt.c' object='lib/ieee1275/halt_module-halt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/ieee1275/halt_module-halt.o `test -f 'lib/ieee1275/halt.c' || echo '$(srcdir)/'`lib/ieee1275/halt.c
+
+lib/ieee1275/halt_module-halt.obj: lib/ieee1275/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/ieee1275/halt_module-halt.obj -MD -MP -MF lib/ieee1275/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/ieee1275/halt_module-halt.obj `if test -f 'lib/ieee1275/halt.c'; then $(CYGPATH_W) 'lib/ieee1275/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/ieee1275/halt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/ieee1275/$(DEPDIR)/halt_module-halt.Tpo lib/ieee1275/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/ieee1275/halt.c' object='lib/ieee1275/halt_module-halt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/ieee1275/halt_module-halt.obj `if test -f 'lib/ieee1275/halt.c'; then $(CYGPATH_W) 'lib/ieee1275/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/ieee1275/halt.c'; fi`
+
+commands/i386/pc/halt_module-halt.o: commands/i386/pc/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/halt_module-halt.o -MD -MP -MF commands/i386/pc/$(DEPDIR)/halt_module-halt.Tpo -c -o commands/i386/pc/halt_module-halt.o `test -f 'commands/i386/pc/halt.c' || echo '$(srcdir)/'`commands/i386/pc/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/halt_module-halt.Tpo commands/i386/pc/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/halt.c' object='commands/i386/pc/halt_module-halt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/halt_module-halt.o `test -f 'commands/i386/pc/halt.c' || echo '$(srcdir)/'`commands/i386/pc/halt.c
+
+commands/i386/pc/halt_module-halt.obj: commands/i386/pc/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/halt_module-halt.obj -MD -MP -MF commands/i386/pc/$(DEPDIR)/halt_module-halt.Tpo -c -o commands/i386/pc/halt_module-halt.obj `if test -f 'commands/i386/pc/halt.c'; then $(CYGPATH_W) 'commands/i386/pc/halt.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/halt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/halt_module-halt.Tpo commands/i386/pc/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/halt.c' object='commands/i386/pc/halt_module-halt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/halt_module-halt.obj `if test -f 'commands/i386/pc/halt.c'; then $(CYGPATH_W) 'commands/i386/pc/halt.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/halt.c'; fi`
+
+lib/xen/halt_module-halt.o: lib/xen/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/xen/halt_module-halt.o -MD -MP -MF lib/xen/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/xen/halt_module-halt.o `test -f 'lib/xen/halt.c' || echo '$(srcdir)/'`lib/xen/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xen/$(DEPDIR)/halt_module-halt.Tpo lib/xen/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xen/halt.c' object='lib/xen/halt_module-halt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/xen/halt_module-halt.o `test -f 'lib/xen/halt.c' || echo '$(srcdir)/'`lib/xen/halt.c
+
+lib/xen/halt_module-halt.obj: lib/xen/halt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -MT lib/xen/halt_module-halt.obj -MD -MP -MF lib/xen/$(DEPDIR)/halt_module-halt.Tpo -c -o lib/xen/halt_module-halt.obj `if test -f 'lib/xen/halt.c'; then $(CYGPATH_W) 'lib/xen/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/xen/halt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xen/$(DEPDIR)/halt_module-halt.Tpo lib/xen/$(DEPDIR)/halt_module-halt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xen/halt.c' object='lib/xen/halt_module-halt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $(halt_module_CFLAGS) $(CFLAGS) -c -o lib/xen/halt_module-halt.obj `if test -f 'lib/xen/halt.c'; then $(CYGPATH_W) 'lib/xen/halt.c'; else $(CYGPATH_W) '$(srcdir)/lib/xen/halt.c'; fi`
+
+commands/hashsum_module-hashsum.o: commands/hashsum.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hashsum_module_CPPFLAGS) $(CPPFLAGS) $(hashsum_module_CFLAGS) $(CFLAGS) -MT commands/hashsum_module-hashsum.o -MD -MP -MF commands/$(DEPDIR)/hashsum_module-hashsum.Tpo -c -o commands/hashsum_module-hashsum.o `test -f 'commands/hashsum.c' || echo '$(srcdir)/'`commands/hashsum.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/hashsum_module-hashsum.Tpo commands/$(DEPDIR)/hashsum_module-hashsum.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/hashsum.c' object='commands/hashsum_module-hashsum.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hashsum_module_CPPFLAGS) $(CPPFLAGS) $(hashsum_module_CFLAGS) $(CFLAGS) -c -o commands/hashsum_module-hashsum.o `test -f 'commands/hashsum.c' || echo '$(srcdir)/'`commands/hashsum.c
+
+commands/hashsum_module-hashsum.obj: commands/hashsum.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hashsum_module_CPPFLAGS) $(CPPFLAGS) $(hashsum_module_CFLAGS) $(CFLAGS) -MT commands/hashsum_module-hashsum.obj -MD -MP -MF commands/$(DEPDIR)/hashsum_module-hashsum.Tpo -c -o commands/hashsum_module-hashsum.obj `if test -f 'commands/hashsum.c'; then $(CYGPATH_W) 'commands/hashsum.c'; else $(CYGPATH_W) '$(srcdir)/commands/hashsum.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/hashsum_module-hashsum.Tpo commands/$(DEPDIR)/hashsum_module-hashsum.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/hashsum.c' object='commands/hashsum_module-hashsum.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hashsum_module_CPPFLAGS) $(CPPFLAGS) $(hashsum_module_CFLAGS) $(CFLAGS) -c -o commands/hashsum_module-hashsum.obj `if test -f 'commands/hashsum.c'; then $(CYGPATH_W) 'commands/hashsum.c'; else $(CYGPATH_W) '$(srcdir)/commands/hashsum.c'; fi`
+
+commands/hdparm_module-hdparm.o: commands/hdparm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $(hdparm_module_CFLAGS) $(CFLAGS) -MT commands/hdparm_module-hdparm.o -MD -MP -MF commands/$(DEPDIR)/hdparm_module-hdparm.Tpo -c -o commands/hdparm_module-hdparm.o `test -f 'commands/hdparm.c' || echo '$(srcdir)/'`commands/hdparm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/hdparm_module-hdparm.Tpo commands/$(DEPDIR)/hdparm_module-hdparm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/hdparm.c' object='commands/hdparm_module-hdparm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $(hdparm_module_CFLAGS) $(CFLAGS) -c -o commands/hdparm_module-hdparm.o `test -f 'commands/hdparm.c' || echo '$(srcdir)/'`commands/hdparm.c
+
+commands/hdparm_module-hdparm.obj: commands/hdparm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $(hdparm_module_CFLAGS) $(CFLAGS) -MT commands/hdparm_module-hdparm.obj -MD -MP -MF commands/$(DEPDIR)/hdparm_module-hdparm.Tpo -c -o commands/hdparm_module-hdparm.obj `if test -f 'commands/hdparm.c'; then $(CYGPATH_W) 'commands/hdparm.c'; else $(CYGPATH_W) '$(srcdir)/commands/hdparm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/hdparm_module-hdparm.Tpo commands/$(DEPDIR)/hdparm_module-hdparm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/hdparm.c' object='commands/hdparm_module-hdparm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $(hdparm_module_CFLAGS) $(CFLAGS) -c -o commands/hdparm_module-hdparm.obj `if test -f 'commands/hdparm.c'; then $(CYGPATH_W) 'commands/hdparm.c'; else $(CYGPATH_W) '$(srcdir)/commands/hdparm.c'; fi`
+
+hello/hello_module-hello.o: hello/hello.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hello_module_CPPFLAGS) $(CPPFLAGS) $(hello_module_CFLAGS) $(CFLAGS) -MT hello/hello_module-hello.o -MD -MP -MF hello/$(DEPDIR)/hello_module-hello.Tpo -c -o hello/hello_module-hello.o `test -f 'hello/hello.c' || echo '$(srcdir)/'`hello/hello.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) hello/$(DEPDIR)/hello_module-hello.Tpo hello/$(DEPDIR)/hello_module-hello.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hello/hello.c' object='hello/hello_module-hello.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hello_module_CPPFLAGS) $(CPPFLAGS) $(hello_module_CFLAGS) $(CFLAGS) -c -o hello/hello_module-hello.o `test -f 'hello/hello.c' || echo '$(srcdir)/'`hello/hello.c
+
+hello/hello_module-hello.obj: hello/hello.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hello_module_CPPFLAGS) $(CPPFLAGS) $(hello_module_CFLAGS) $(CFLAGS) -MT hello/hello_module-hello.obj -MD -MP -MF hello/$(DEPDIR)/hello_module-hello.Tpo -c -o hello/hello_module-hello.obj `if test -f 'hello/hello.c'; then $(CYGPATH_W) 'hello/hello.c'; else $(CYGPATH_W) '$(srcdir)/hello/hello.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) hello/$(DEPDIR)/hello_module-hello.Tpo hello/$(DEPDIR)/hello_module-hello.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hello/hello.c' object='hello/hello_module-hello.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hello_module_CPPFLAGS) $(CPPFLAGS) $(hello_module_CFLAGS) $(CFLAGS) -c -o hello/hello_module-hello.obj `if test -f 'hello/hello.c'; then $(CYGPATH_W) 'hello/hello.c'; else $(CYGPATH_W) '$(srcdir)/hello/hello.c'; fi`
+
+commands/help_module-help.o: commands/help.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(help_module_CPPFLAGS) $(CPPFLAGS) $(help_module_CFLAGS) $(CFLAGS) -MT commands/help_module-help.o -MD -MP -MF commands/$(DEPDIR)/help_module-help.Tpo -c -o commands/help_module-help.o `test -f 'commands/help.c' || echo '$(srcdir)/'`commands/help.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/help_module-help.Tpo commands/$(DEPDIR)/help_module-help.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/help.c' object='commands/help_module-help.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(help_module_CPPFLAGS) $(CPPFLAGS) $(help_module_CFLAGS) $(CFLAGS) -c -o commands/help_module-help.o `test -f 'commands/help.c' || echo '$(srcdir)/'`commands/help.c
+
+commands/help_module-help.obj: commands/help.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(help_module_CPPFLAGS) $(CPPFLAGS) $(help_module_CFLAGS) $(CFLAGS) -MT commands/help_module-help.obj -MD -MP -MF commands/$(DEPDIR)/help_module-help.Tpo -c -o commands/help_module-help.obj `if test -f 'commands/help.c'; then $(CYGPATH_W) 'commands/help.c'; else $(CYGPATH_W) '$(srcdir)/commands/help.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/help_module-help.Tpo commands/$(DEPDIR)/help_module-help.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/help.c' object='commands/help_module-help.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(help_module_CPPFLAGS) $(CPPFLAGS) $(help_module_CFLAGS) $(CFLAGS) -c -o commands/help_module-help.obj `if test -f 'commands/help.c'; then $(CYGPATH_W) 'commands/help.c'; else $(CYGPATH_W) '$(srcdir)/commands/help.c'; fi`
+
+commands/hexdump_module-hexdump.o: commands/hexdump.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hexdump_module_CPPFLAGS) $(CPPFLAGS) $(hexdump_module_CFLAGS) $(CFLAGS) -MT commands/hexdump_module-hexdump.o -MD -MP -MF commands/$(DEPDIR)/hexdump_module-hexdump.Tpo -c -o commands/hexdump_module-hexdump.o `test -f 'commands/hexdump.c' || echo '$(srcdir)/'`commands/hexdump.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/hexdump_module-hexdump.Tpo commands/$(DEPDIR)/hexdump_module-hexdump.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/hexdump.c' object='commands/hexdump_module-hexdump.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hexdump_module_CPPFLAGS) $(CPPFLAGS) $(hexdump_module_CFLAGS) $(CFLAGS) -c -o commands/hexdump_module-hexdump.o `test -f 'commands/hexdump.c' || echo '$(srcdir)/'`commands/hexdump.c
+
+commands/hexdump_module-hexdump.obj: commands/hexdump.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hexdump_module_CPPFLAGS) $(CPPFLAGS) $(hexdump_module_CFLAGS) $(CFLAGS) -MT commands/hexdump_module-hexdump.obj -MD -MP -MF commands/$(DEPDIR)/hexdump_module-hexdump.Tpo -c -o commands/hexdump_module-hexdump.obj `if test -f 'commands/hexdump.c'; then $(CYGPATH_W) 'commands/hexdump.c'; else $(CYGPATH_W) '$(srcdir)/commands/hexdump.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/hexdump_module-hexdump.Tpo commands/$(DEPDIR)/hexdump_module-hexdump.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/hexdump.c' object='commands/hexdump_module-hexdump.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hexdump_module_CPPFLAGS) $(CPPFLAGS) $(hexdump_module_CFLAGS) $(CFLAGS) -c -o commands/hexdump_module-hexdump.obj `if test -f 'commands/hexdump.c'; then $(CYGPATH_W) 'commands/hexdump.c'; else $(CYGPATH_W) '$(srcdir)/commands/hexdump.c'; fi`
+
+lib/hexdump_module-hexdump.o: lib/hexdump.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hexdump_module_CPPFLAGS) $(CPPFLAGS) $(hexdump_module_CFLAGS) $(CFLAGS) -MT lib/hexdump_module-hexdump.o -MD -MP -MF lib/$(DEPDIR)/hexdump_module-hexdump.Tpo -c -o lib/hexdump_module-hexdump.o `test -f 'lib/hexdump.c' || echo '$(srcdir)/'`lib/hexdump.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/hexdump_module-hexdump.Tpo lib/$(DEPDIR)/hexdump_module-hexdump.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/hexdump.c' object='lib/hexdump_module-hexdump.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hexdump_module_CPPFLAGS) $(CPPFLAGS) $(hexdump_module_CFLAGS) $(CFLAGS) -c -o lib/hexdump_module-hexdump.o `test -f 'lib/hexdump.c' || echo '$(srcdir)/'`lib/hexdump.c
+
+lib/hexdump_module-hexdump.obj: lib/hexdump.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hexdump_module_CPPFLAGS) $(CPPFLAGS) $(hexdump_module_CFLAGS) $(CFLAGS) -MT lib/hexdump_module-hexdump.obj -MD -MP -MF lib/$(DEPDIR)/hexdump_module-hexdump.Tpo -c -o lib/hexdump_module-hexdump.obj `if test -f 'lib/hexdump.c'; then $(CYGPATH_W) 'lib/hexdump.c'; else $(CYGPATH_W) '$(srcdir)/lib/hexdump.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/hexdump_module-hexdump.Tpo lib/$(DEPDIR)/hexdump_module-hexdump.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/hexdump.c' object='lib/hexdump_module-hexdump.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hexdump_module_CPPFLAGS) $(CPPFLAGS) $(hexdump_module_CFLAGS) $(CFLAGS) -c -o lib/hexdump_module-hexdump.obj `if test -f 'lib/hexdump.c'; then $(CYGPATH_W) 'lib/hexdump.c'; else $(CYGPATH_W) '$(srcdir)/lib/hexdump.c'; fi`
+
+fs/hfs_module-hfs.o: fs/hfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfs_module_CPPFLAGS) $(CPPFLAGS) $(hfs_module_CFLAGS) $(CFLAGS) -MT fs/hfs_module-hfs.o -MD -MP -MF fs/$(DEPDIR)/hfs_module-hfs.Tpo -c -o fs/hfs_module-hfs.o `test -f 'fs/hfs.c' || echo '$(srcdir)/'`fs/hfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/hfs_module-hfs.Tpo fs/$(DEPDIR)/hfs_module-hfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/hfs.c' object='fs/hfs_module-hfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfs_module_CPPFLAGS) $(CPPFLAGS) $(hfs_module_CFLAGS) $(CFLAGS) -c -o fs/hfs_module-hfs.o `test -f 'fs/hfs.c' || echo '$(srcdir)/'`fs/hfs.c
+
+fs/hfs_module-hfs.obj: fs/hfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfs_module_CPPFLAGS) $(CPPFLAGS) $(hfs_module_CFLAGS) $(CFLAGS) -MT fs/hfs_module-hfs.obj -MD -MP -MF fs/$(DEPDIR)/hfs_module-hfs.Tpo -c -o fs/hfs_module-hfs.obj `if test -f 'fs/hfs.c'; then $(CYGPATH_W) 'fs/hfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/hfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/hfs_module-hfs.Tpo fs/$(DEPDIR)/hfs_module-hfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/hfs.c' object='fs/hfs_module-hfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfs_module_CPPFLAGS) $(CPPFLAGS) $(hfs_module_CFLAGS) $(CFLAGS) -c -o fs/hfs_module-hfs.obj `if test -f 'fs/hfs.c'; then $(CYGPATH_W) 'fs/hfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/hfs.c'; fi`
+
+fs/hfsplus_module-hfsplus.o: fs/hfsplus.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfsplus_module_CPPFLAGS) $(CPPFLAGS) $(hfsplus_module_CFLAGS) $(CFLAGS) -MT fs/hfsplus_module-hfsplus.o -MD -MP -MF fs/$(DEPDIR)/hfsplus_module-hfsplus.Tpo -c -o fs/hfsplus_module-hfsplus.o `test -f 'fs/hfsplus.c' || echo '$(srcdir)/'`fs/hfsplus.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/hfsplus_module-hfsplus.Tpo fs/$(DEPDIR)/hfsplus_module-hfsplus.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/hfsplus.c' object='fs/hfsplus_module-hfsplus.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfsplus_module_CPPFLAGS) $(CPPFLAGS) $(hfsplus_module_CFLAGS) $(CFLAGS) -c -o fs/hfsplus_module-hfsplus.o `test -f 'fs/hfsplus.c' || echo '$(srcdir)/'`fs/hfsplus.c
+
+fs/hfsplus_module-hfsplus.obj: fs/hfsplus.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfsplus_module_CPPFLAGS) $(CPPFLAGS) $(hfsplus_module_CFLAGS) $(CFLAGS) -MT fs/hfsplus_module-hfsplus.obj -MD -MP -MF fs/$(DEPDIR)/hfsplus_module-hfsplus.Tpo -c -o fs/hfsplus_module-hfsplus.obj `if test -f 'fs/hfsplus.c'; then $(CYGPATH_W) 'fs/hfsplus.c'; else $(CYGPATH_W) '$(srcdir)/fs/hfsplus.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/hfsplus_module-hfsplus.Tpo fs/$(DEPDIR)/hfsplus_module-hfsplus.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/hfsplus.c' object='fs/hfsplus_module-hfsplus.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfsplus_module_CPPFLAGS) $(CPPFLAGS) $(hfsplus_module_CFLAGS) $(CFLAGS) -c -o fs/hfsplus_module-hfsplus.obj `if test -f 'fs/hfsplus.c'; then $(CYGPATH_W) 'fs/hfsplus.c'; else $(CYGPATH_W) '$(srcdir)/fs/hfsplus.c'; fi`
+
+fs/hfspluscomp_module-hfspluscomp.o: fs/hfspluscomp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfspluscomp_module_CPPFLAGS) $(CPPFLAGS) $(hfspluscomp_module_CFLAGS) $(CFLAGS) -MT fs/hfspluscomp_module-hfspluscomp.o -MD -MP -MF fs/$(DEPDIR)/hfspluscomp_module-hfspluscomp.Tpo -c -o fs/hfspluscomp_module-hfspluscomp.o `test -f 'fs/hfspluscomp.c' || echo '$(srcdir)/'`fs/hfspluscomp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/hfspluscomp_module-hfspluscomp.Tpo fs/$(DEPDIR)/hfspluscomp_module-hfspluscomp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/hfspluscomp.c' object='fs/hfspluscomp_module-hfspluscomp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfspluscomp_module_CPPFLAGS) $(CPPFLAGS) $(hfspluscomp_module_CFLAGS) $(CFLAGS) -c -o fs/hfspluscomp_module-hfspluscomp.o `test -f 'fs/hfspluscomp.c' || echo '$(srcdir)/'`fs/hfspluscomp.c
+
+fs/hfspluscomp_module-hfspluscomp.obj: fs/hfspluscomp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfspluscomp_module_CPPFLAGS) $(CPPFLAGS) $(hfspluscomp_module_CFLAGS) $(CFLAGS) -MT fs/hfspluscomp_module-hfspluscomp.obj -MD -MP -MF fs/$(DEPDIR)/hfspluscomp_module-hfspluscomp.Tpo -c -o fs/hfspluscomp_module-hfspluscomp.obj `if test -f 'fs/hfspluscomp.c'; then $(CYGPATH_W) 'fs/hfspluscomp.c'; else $(CYGPATH_W) '$(srcdir)/fs/hfspluscomp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/hfspluscomp_module-hfspluscomp.Tpo fs/$(DEPDIR)/hfspluscomp_module-hfspluscomp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/hfspluscomp.c' object='fs/hfspluscomp_module-hfspluscomp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfspluscomp_module_CPPFLAGS) $(CPPFLAGS) $(hfspluscomp_module_CFLAGS) $(CFLAGS) -c -o fs/hfspluscomp_module-hfspluscomp.obj `if test -f 'fs/hfspluscomp.c'; then $(CYGPATH_W) 'fs/hfspluscomp.c'; else $(CYGPATH_W) '$(srcdir)/fs/hfspluscomp.c'; fi`
+
+net/http_module-http.o: net/http.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(http_module_CPPFLAGS) $(CPPFLAGS) $(http_module_CFLAGS) $(CFLAGS) -MT net/http_module-http.o -MD -MP -MF net/$(DEPDIR)/http_module-http.Tpo -c -o net/http_module-http.o `test -f 'net/http.c' || echo '$(srcdir)/'`net/http.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/http_module-http.Tpo net/$(DEPDIR)/http_module-http.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/http.c' object='net/http_module-http.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(http_module_CPPFLAGS) $(CPPFLAGS) $(http_module_CFLAGS) $(CFLAGS) -c -o net/http_module-http.o `test -f 'net/http.c' || echo '$(srcdir)/'`net/http.c
+
+net/http_module-http.obj: net/http.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(http_module_CPPFLAGS) $(CPPFLAGS) $(http_module_CFLAGS) $(CFLAGS) -MT net/http_module-http.obj -MD -MP -MF net/$(DEPDIR)/http_module-http.Tpo -c -o net/http_module-http.obj `if test -f 'net/http.c'; then $(CYGPATH_W) 'net/http.c'; else $(CYGPATH_W) '$(srcdir)/net/http.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/http_module-http.Tpo net/$(DEPDIR)/http_module-http.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/http.c' object='net/http_module-http.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(http_module_CPPFLAGS) $(CPPFLAGS) $(http_module_CFLAGS) $(CFLAGS) -c -o net/http_module-http.obj `if test -f 'net/http.c'; then $(CYGPATH_W) 'net/http.c'; else $(CYGPATH_W) '$(srcdir)/net/http.c'; fi`
+
+video/ieee1275_fb_module-ieee1275.o: video/ieee1275.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ieee1275_fb_module_CPPFLAGS) $(CPPFLAGS) $(ieee1275_fb_module_CFLAGS) $(CFLAGS) -MT video/ieee1275_fb_module-ieee1275.o -MD -MP -MF video/$(DEPDIR)/ieee1275_fb_module-ieee1275.Tpo -c -o video/ieee1275_fb_module-ieee1275.o `test -f 'video/ieee1275.c' || echo '$(srcdir)/'`video/ieee1275.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/ieee1275_fb_module-ieee1275.Tpo video/$(DEPDIR)/ieee1275_fb_module-ieee1275.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/ieee1275.c' object='video/ieee1275_fb_module-ieee1275.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ieee1275_fb_module_CPPFLAGS) $(CPPFLAGS) $(ieee1275_fb_module_CFLAGS) $(CFLAGS) -c -o video/ieee1275_fb_module-ieee1275.o `test -f 'video/ieee1275.c' || echo '$(srcdir)/'`video/ieee1275.c
+
+video/ieee1275_fb_module-ieee1275.obj: video/ieee1275.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ieee1275_fb_module_CPPFLAGS) $(CPPFLAGS) $(ieee1275_fb_module_CFLAGS) $(CFLAGS) -MT video/ieee1275_fb_module-ieee1275.obj -MD -MP -MF video/$(DEPDIR)/ieee1275_fb_module-ieee1275.Tpo -c -o video/ieee1275_fb_module-ieee1275.obj `if test -f 'video/ieee1275.c'; then $(CYGPATH_W) 'video/ieee1275.c'; else $(CYGPATH_W) '$(srcdir)/video/ieee1275.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/ieee1275_fb_module-ieee1275.Tpo video/$(DEPDIR)/ieee1275_fb_module-ieee1275.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/ieee1275.c' object='video/ieee1275_fb_module-ieee1275.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ieee1275_fb_module_CPPFLAGS) $(CPPFLAGS) $(ieee1275_fb_module_CFLAGS) $(CFLAGS) -c -o video/ieee1275_fb_module-ieee1275.obj `if test -f 'video/ieee1275.c'; then $(CYGPATH_W) 'video/ieee1275.c'; else $(CYGPATH_W) '$(srcdir)/video/ieee1275.c'; fi`
+
+commands/iorw_module-iorw.o: commands/iorw.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $(iorw_module_CFLAGS) $(CFLAGS) -MT commands/iorw_module-iorw.o -MD -MP -MF commands/$(DEPDIR)/iorw_module-iorw.Tpo -c -o commands/iorw_module-iorw.o `test -f 'commands/iorw.c' || echo '$(srcdir)/'`commands/iorw.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/iorw_module-iorw.Tpo commands/$(DEPDIR)/iorw_module-iorw.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/iorw.c' object='commands/iorw_module-iorw.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $(iorw_module_CFLAGS) $(CFLAGS) -c -o commands/iorw_module-iorw.o `test -f 'commands/iorw.c' || echo '$(srcdir)/'`commands/iorw.c
+
+commands/iorw_module-iorw.obj: commands/iorw.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $(iorw_module_CFLAGS) $(CFLAGS) -MT commands/iorw_module-iorw.obj -MD -MP -MF commands/$(DEPDIR)/iorw_module-iorw.Tpo -c -o commands/iorw_module-iorw.obj `if test -f 'commands/iorw.c'; then $(CYGPATH_W) 'commands/iorw.c'; else $(CYGPATH_W) '$(srcdir)/commands/iorw.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/iorw_module-iorw.Tpo commands/$(DEPDIR)/iorw_module-iorw.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/iorw.c' object='commands/iorw_module-iorw.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $(iorw_module_CFLAGS) $(CFLAGS) -c -o commands/iorw_module-iorw.obj `if test -f 'commands/iorw.c'; then $(CYGPATH_W) 'commands/iorw.c'; else $(CYGPATH_W) '$(srcdir)/commands/iorw.c'; fi`
+
+fs/iso9660_module-iso9660.o: fs/iso9660.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iso9660_module_CPPFLAGS) $(CPPFLAGS) $(iso9660_module_CFLAGS) $(CFLAGS) -MT fs/iso9660_module-iso9660.o -MD -MP -MF fs/$(DEPDIR)/iso9660_module-iso9660.Tpo -c -o fs/iso9660_module-iso9660.o `test -f 'fs/iso9660.c' || echo '$(srcdir)/'`fs/iso9660.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/iso9660_module-iso9660.Tpo fs/$(DEPDIR)/iso9660_module-iso9660.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/iso9660.c' object='fs/iso9660_module-iso9660.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iso9660_module_CPPFLAGS) $(CPPFLAGS) $(iso9660_module_CFLAGS) $(CFLAGS) -c -o fs/iso9660_module-iso9660.o `test -f 'fs/iso9660.c' || echo '$(srcdir)/'`fs/iso9660.c
+
+fs/iso9660_module-iso9660.obj: fs/iso9660.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iso9660_module_CPPFLAGS) $(CPPFLAGS) $(iso9660_module_CFLAGS) $(CFLAGS) -MT fs/iso9660_module-iso9660.obj -MD -MP -MF fs/$(DEPDIR)/iso9660_module-iso9660.Tpo -c -o fs/iso9660_module-iso9660.obj `if test -f 'fs/iso9660.c'; then $(CYGPATH_W) 'fs/iso9660.c'; else $(CYGPATH_W) '$(srcdir)/fs/iso9660.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/iso9660_module-iso9660.Tpo fs/$(DEPDIR)/iso9660_module-iso9660.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/iso9660.c' object='fs/iso9660_module-iso9660.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iso9660_module_CPPFLAGS) $(CPPFLAGS) $(iso9660_module_CFLAGS) $(CFLAGS) -c -o fs/iso9660_module-iso9660.obj `if test -f 'fs/iso9660.c'; then $(CYGPATH_W) 'fs/iso9660.c'; else $(CYGPATH_W) '$(srcdir)/fs/iso9660.c'; fi`
+
+fs/jfs_module-jfs.o: fs/jfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jfs_module_CPPFLAGS) $(CPPFLAGS) $(jfs_module_CFLAGS) $(CFLAGS) -MT fs/jfs_module-jfs.o -MD -MP -MF fs/$(DEPDIR)/jfs_module-jfs.Tpo -c -o fs/jfs_module-jfs.o `test -f 'fs/jfs.c' || echo '$(srcdir)/'`fs/jfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/jfs_module-jfs.Tpo fs/$(DEPDIR)/jfs_module-jfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/jfs.c' object='fs/jfs_module-jfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jfs_module_CPPFLAGS) $(CPPFLAGS) $(jfs_module_CFLAGS) $(CFLAGS) -c -o fs/jfs_module-jfs.o `test -f 'fs/jfs.c' || echo '$(srcdir)/'`fs/jfs.c
+
+fs/jfs_module-jfs.obj: fs/jfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jfs_module_CPPFLAGS) $(CPPFLAGS) $(jfs_module_CFLAGS) $(CFLAGS) -MT fs/jfs_module-jfs.obj -MD -MP -MF fs/$(DEPDIR)/jfs_module-jfs.Tpo -c -o fs/jfs_module-jfs.obj `if test -f 'fs/jfs.c'; then $(CYGPATH_W) 'fs/jfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/jfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/jfs_module-jfs.Tpo fs/$(DEPDIR)/jfs_module-jfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/jfs.c' object='fs/jfs_module-jfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jfs_module_CPPFLAGS) $(CPPFLAGS) $(jfs_module_CFLAGS) $(CFLAGS) -c -o fs/jfs_module-jfs.obj `if test -f 'fs/jfs.c'; then $(CYGPATH_W) 'fs/jfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/jfs.c'; fi`
+
+video/readers/jpeg_module-jpeg.o: video/readers/jpeg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jpeg_module_CPPFLAGS) $(CPPFLAGS) $(jpeg_module_CFLAGS) $(CFLAGS) -MT video/readers/jpeg_module-jpeg.o -MD -MP -MF video/readers/$(DEPDIR)/jpeg_module-jpeg.Tpo -c -o video/readers/jpeg_module-jpeg.o `test -f 'video/readers/jpeg.c' || echo '$(srcdir)/'`video/readers/jpeg.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/readers/$(DEPDIR)/jpeg_module-jpeg.Tpo video/readers/$(DEPDIR)/jpeg_module-jpeg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/readers/jpeg.c' object='video/readers/jpeg_module-jpeg.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jpeg_module_CPPFLAGS) $(CPPFLAGS) $(jpeg_module_CFLAGS) $(CFLAGS) -c -o video/readers/jpeg_module-jpeg.o `test -f 'video/readers/jpeg.c' || echo '$(srcdir)/'`video/readers/jpeg.c
+
+video/readers/jpeg_module-jpeg.obj: video/readers/jpeg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jpeg_module_CPPFLAGS) $(CPPFLAGS) $(jpeg_module_CFLAGS) $(CFLAGS) -MT video/readers/jpeg_module-jpeg.obj -MD -MP -MF video/readers/$(DEPDIR)/jpeg_module-jpeg.Tpo -c -o video/readers/jpeg_module-jpeg.obj `if test -f 'video/readers/jpeg.c'; then $(CYGPATH_W) 'video/readers/jpeg.c'; else $(CYGPATH_W) '$(srcdir)/video/readers/jpeg.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/readers/$(DEPDIR)/jpeg_module-jpeg.Tpo video/readers/$(DEPDIR)/jpeg_module-jpeg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/readers/jpeg.c' object='video/readers/jpeg_module-jpeg.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jpeg_module_CPPFLAGS) $(CPPFLAGS) $(jpeg_module_CFLAGS) $(CFLAGS) -c -o video/readers/jpeg_module-jpeg.obj `if test -f 'video/readers/jpeg.c'; then $(CYGPATH_W) 'video/readers/jpeg.c'; else $(CYGPATH_W) '$(srcdir)/video/readers/jpeg.c'; fi`
+
+lib/json/json_module-json.o: lib/json/json.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(json_module_CPPFLAGS) $(CPPFLAGS) $(json_module_CFLAGS) $(CFLAGS) -MT lib/json/json_module-json.o -MD -MP -MF lib/json/$(DEPDIR)/json_module-json.Tpo -c -o lib/json/json_module-json.o `test -f 'lib/json/json.c' || echo '$(srcdir)/'`lib/json/json.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/json/$(DEPDIR)/json_module-json.Tpo lib/json/$(DEPDIR)/json_module-json.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/json/json.c' object='lib/json/json_module-json.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(json_module_CPPFLAGS) $(CPPFLAGS) $(json_module_CFLAGS) $(CFLAGS) -c -o lib/json/json_module-json.o `test -f 'lib/json/json.c' || echo '$(srcdir)/'`lib/json/json.c
+
+lib/json/json_module-json.obj: lib/json/json.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(json_module_CPPFLAGS) $(CPPFLAGS) $(json_module_CFLAGS) $(CFLAGS) -MT lib/json/json_module-json.obj -MD -MP -MF lib/json/$(DEPDIR)/json_module-json.Tpo -c -o lib/json/json_module-json.obj `if test -f 'lib/json/json.c'; then $(CYGPATH_W) 'lib/json/json.c'; else $(CYGPATH_W) '$(srcdir)/lib/json/json.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/json/$(DEPDIR)/json_module-json.Tpo lib/json/$(DEPDIR)/json_module-json.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/json/json.c' object='lib/json/json_module-json.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(json_module_CPPFLAGS) $(CPPFLAGS) $(json_module_CFLAGS) $(CFLAGS) -c -o lib/json/json_module-json.obj `if test -f 'lib/json/json.c'; then $(CYGPATH_W) 'lib/json/json.c'; else $(CYGPATH_W) '$(srcdir)/lib/json/json.c'; fi`
+
+kern/arm64/efi/kernel_exec-init.o: kern/arm64/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm64/efi/kernel_exec-init.o -MD -MP -MF kern/arm64/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/arm64/efi/kernel_exec-init.o `test -f 'kern/arm64/efi/init.c' || echo '$(srcdir)/'`kern/arm64/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/arm64/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm64/efi/init.c' object='kern/arm64/efi/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm64/efi/kernel_exec-init.o `test -f 'kern/arm64/efi/init.c' || echo '$(srcdir)/'`kern/arm64/efi/init.c
+
+kern/arm64/efi/kernel_exec-init.obj: kern/arm64/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm64/efi/kernel_exec-init.obj -MD -MP -MF kern/arm64/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/arm64/efi/kernel_exec-init.obj `if test -f 'kern/arm64/efi/init.c'; then $(CYGPATH_W) 'kern/arm64/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/efi/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/arm64/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm64/efi/init.c' object='kern/arm64/efi/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm64/efi/kernel_exec-init.obj `if test -f 'kern/arm64/efi/init.c'; then $(CYGPATH_W) 'kern/arm64/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/efi/init.c'; fi`
+
+kern/efi/kernel_exec-fdt.o: kern/efi/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-fdt.o -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-fdt.Tpo -c -o kern/efi/kernel_exec-fdt.o `test -f 'kern/efi/fdt.c' || echo '$(srcdir)/'`kern/efi/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-fdt.Tpo kern/efi/$(DEPDIR)/kernel_exec-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/fdt.c' object='kern/efi/kernel_exec-fdt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-fdt.o `test -f 'kern/efi/fdt.c' || echo '$(srcdir)/'`kern/efi/fdt.c
+
+kern/efi/kernel_exec-fdt.obj: kern/efi/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-fdt.obj -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-fdt.Tpo -c -o kern/efi/kernel_exec-fdt.obj `if test -f 'kern/efi/fdt.c'; then $(CYGPATH_W) 'kern/efi/fdt.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/fdt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-fdt.Tpo kern/efi/$(DEPDIR)/kernel_exec-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/fdt.c' object='kern/efi/kernel_exec-fdt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-fdt.obj `if test -f 'kern/efi/fdt.c'; then $(CYGPATH_W) 'kern/efi/fdt.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/fdt.c'; fi`
+
+kern/arm64/kernel_exec-cache.o: kern/arm64/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm64/kernel_exec-cache.o -MD -MP -MF kern/arm64/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/arm64/kernel_exec-cache.o `test -f 'kern/arm64/cache.c' || echo '$(srcdir)/'`kern/arm64/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/$(DEPDIR)/kernel_exec-cache.Tpo kern/arm64/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm64/cache.c' object='kern/arm64/kernel_exec-cache.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm64/kernel_exec-cache.o `test -f 'kern/arm64/cache.c' || echo '$(srcdir)/'`kern/arm64/cache.c
+
+kern/arm64/kernel_exec-cache.obj: kern/arm64/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm64/kernel_exec-cache.obj -MD -MP -MF kern/arm64/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/arm64/kernel_exec-cache.obj `if test -f 'kern/arm64/cache.c'; then $(CYGPATH_W) 'kern/arm64/cache.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/cache.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/$(DEPDIR)/kernel_exec-cache.Tpo kern/arm64/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm64/cache.c' object='kern/arm64/kernel_exec-cache.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm64/kernel_exec-cache.obj `if test -f 'kern/arm64/cache.c'; then $(CYGPATH_W) 'kern/arm64/cache.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/cache.c'; fi`
+
+kern/arm64/kernel_exec-dl.o: kern/arm64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm64/kernel_exec-dl.o -MD -MP -MF kern/arm64/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/arm64/kernel_exec-dl.o `test -f 'kern/arm64/dl.c' || echo '$(srcdir)/'`kern/arm64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/$(DEPDIR)/kernel_exec-dl.Tpo kern/arm64/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm64/dl.c' object='kern/arm64/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm64/kernel_exec-dl.o `test -f 'kern/arm64/dl.c' || echo '$(srcdir)/'`kern/arm64/dl.c
+
+kern/arm64/kernel_exec-dl.obj: kern/arm64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm64/kernel_exec-dl.obj -MD -MP -MF kern/arm64/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/arm64/kernel_exec-dl.obj `if test -f 'kern/arm64/dl.c'; then $(CYGPATH_W) 'kern/arm64/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/$(DEPDIR)/kernel_exec-dl.Tpo kern/arm64/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm64/dl.c' object='kern/arm64/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm64/kernel_exec-dl.obj `if test -f 'kern/arm64/dl.c'; then $(CYGPATH_W) 'kern/arm64/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/dl.c'; fi`
+
+kern/arm64/kernel_exec-dl_helper.o: kern/arm64/dl_helper.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm64/kernel_exec-dl_helper.o -MD -MP -MF kern/arm64/$(DEPDIR)/kernel_exec-dl_helper.Tpo -c -o kern/arm64/kernel_exec-dl_helper.o `test -f 'kern/arm64/dl_helper.c' || echo '$(srcdir)/'`kern/arm64/dl_helper.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/$(DEPDIR)/kernel_exec-dl_helper.Tpo kern/arm64/$(DEPDIR)/kernel_exec-dl_helper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm64/dl_helper.c' object='kern/arm64/kernel_exec-dl_helper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm64/kernel_exec-dl_helper.o `test -f 'kern/arm64/dl_helper.c' || echo '$(srcdir)/'`kern/arm64/dl_helper.c
+
+kern/arm64/kernel_exec-dl_helper.obj: kern/arm64/dl_helper.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm64/kernel_exec-dl_helper.obj -MD -MP -MF kern/arm64/$(DEPDIR)/kernel_exec-dl_helper.Tpo -c -o kern/arm64/kernel_exec-dl_helper.obj `if test -f 'kern/arm64/dl_helper.c'; then $(CYGPATH_W) 'kern/arm64/dl_helper.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/dl_helper.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm64/$(DEPDIR)/kernel_exec-dl_helper.Tpo kern/arm64/$(DEPDIR)/kernel_exec-dl_helper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm64/dl_helper.c' object='kern/arm64/kernel_exec-dl_helper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm64/kernel_exec-dl_helper.obj `if test -f 'kern/arm64/dl_helper.c'; then $(CYGPATH_W) 'kern/arm64/dl_helper.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm64/dl_helper.c'; fi`
+
+disk/efi/kernel_exec-efidisk.o: disk/efi/efidisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/efi/kernel_exec-efidisk.o -MD -MP -MF disk/efi/$(DEPDIR)/kernel_exec-efidisk.Tpo -c -o disk/efi/kernel_exec-efidisk.o `test -f 'disk/efi/efidisk.c' || echo '$(srcdir)/'`disk/efi/efidisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/efi/$(DEPDIR)/kernel_exec-efidisk.Tpo disk/efi/$(DEPDIR)/kernel_exec-efidisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/efi/efidisk.c' object='disk/efi/kernel_exec-efidisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/efi/kernel_exec-efidisk.o `test -f 'disk/efi/efidisk.c' || echo '$(srcdir)/'`disk/efi/efidisk.c
+
+disk/efi/kernel_exec-efidisk.obj: disk/efi/efidisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/efi/kernel_exec-efidisk.obj -MD -MP -MF disk/efi/$(DEPDIR)/kernel_exec-efidisk.Tpo -c -o disk/efi/kernel_exec-efidisk.obj `if test -f 'disk/efi/efidisk.c'; then $(CYGPATH_W) 'disk/efi/efidisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/efi/efidisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/efi/$(DEPDIR)/kernel_exec-efidisk.Tpo disk/efi/$(DEPDIR)/kernel_exec-efidisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/efi/efidisk.c' object='disk/efi/kernel_exec-efidisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/efi/kernel_exec-efidisk.obj `if test -f 'disk/efi/efidisk.c'; then $(CYGPATH_W) 'disk/efi/efidisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/efi/efidisk.c'; fi`
+
+kern/efi/kernel_exec-efi.o: kern/efi/efi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-efi.o -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-efi.Tpo -c -o kern/efi/kernel_exec-efi.o `test -f 'kern/efi/efi.c' || echo '$(srcdir)/'`kern/efi/efi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-efi.Tpo kern/efi/$(DEPDIR)/kernel_exec-efi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/efi.c' object='kern/efi/kernel_exec-efi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-efi.o `test -f 'kern/efi/efi.c' || echo '$(srcdir)/'`kern/efi/efi.c
+
+kern/efi/kernel_exec-efi.obj: kern/efi/efi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-efi.obj -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-efi.Tpo -c -o kern/efi/kernel_exec-efi.obj `if test -f 'kern/efi/efi.c'; then $(CYGPATH_W) 'kern/efi/efi.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/efi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-efi.Tpo kern/efi/$(DEPDIR)/kernel_exec-efi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/efi.c' object='kern/efi/kernel_exec-efi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-efi.obj `if test -f 'kern/efi/efi.c'; then $(CYGPATH_W) 'kern/efi/efi.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/efi.c'; fi`
+
+kern/efi/kernel_exec-init.o: kern/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-init.o -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/efi/kernel_exec-init.o `test -f 'kern/efi/init.c' || echo '$(srcdir)/'`kern/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/init.c' object='kern/efi/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-init.o `test -f 'kern/efi/init.c' || echo '$(srcdir)/'`kern/efi/init.c
+
+kern/efi/kernel_exec-init.obj: kern/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-init.obj -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/efi/kernel_exec-init.obj `if test -f 'kern/efi/init.c'; then $(CYGPATH_W) 'kern/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/init.c' object='kern/efi/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-init.obj `if test -f 'kern/efi/init.c'; then $(CYGPATH_W) 'kern/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/init.c'; fi`
+
+kern/efi/kernel_exec-mm.o: kern/efi/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-mm.o -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-mm.Tpo -c -o kern/efi/kernel_exec-mm.o `test -f 'kern/efi/mm.c' || echo '$(srcdir)/'`kern/efi/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-mm.Tpo kern/efi/$(DEPDIR)/kernel_exec-mm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/mm.c' object='kern/efi/kernel_exec-mm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-mm.o `test -f 'kern/efi/mm.c' || echo '$(srcdir)/'`kern/efi/mm.c
+
+kern/efi/kernel_exec-mm.obj: kern/efi/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-mm.obj -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-mm.Tpo -c -o kern/efi/kernel_exec-mm.obj `if test -f 'kern/efi/mm.c'; then $(CYGPATH_W) 'kern/efi/mm.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/mm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-mm.Tpo kern/efi/$(DEPDIR)/kernel_exec-mm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/mm.c' object='kern/efi/kernel_exec-mm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-mm.obj `if test -f 'kern/efi/mm.c'; then $(CYGPATH_W) 'kern/efi/mm.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/mm.c'; fi`
+
+term/efi/kernel_exec-console.o: term/efi/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/efi/kernel_exec-console.o -MD -MP -MF term/efi/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/efi/kernel_exec-console.o `test -f 'term/efi/console.c' || echo '$(srcdir)/'`term/efi/console.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/efi/$(DEPDIR)/kernel_exec-console.Tpo term/efi/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/efi/console.c' object='term/efi/kernel_exec-console.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/efi/kernel_exec-console.o `test -f 'term/efi/console.c' || echo '$(srcdir)/'`term/efi/console.c
+
+term/efi/kernel_exec-console.obj: term/efi/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/efi/kernel_exec-console.obj -MD -MP -MF term/efi/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/efi/kernel_exec-console.obj `if test -f 'term/efi/console.c'; then $(CYGPATH_W) 'term/efi/console.c'; else $(CYGPATH_W) '$(srcdir)/term/efi/console.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/efi/$(DEPDIR)/kernel_exec-console.Tpo term/efi/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/efi/console.c' object='term/efi/kernel_exec-console.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/efi/kernel_exec-console.obj `if test -f 'term/efi/console.c'; then $(CYGPATH_W) 'term/efi/console.c'; else $(CYGPATH_W) '$(srcdir)/term/efi/console.c'; fi`
+
+kern/kernel_exec-acpi.o: kern/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-acpi.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-acpi.Tpo -c -o kern/kernel_exec-acpi.o `test -f 'kern/acpi.c' || echo '$(srcdir)/'`kern/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-acpi.Tpo kern/$(DEPDIR)/kernel_exec-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/acpi.c' object='kern/kernel_exec-acpi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-acpi.o `test -f 'kern/acpi.c' || echo '$(srcdir)/'`kern/acpi.c
+
+kern/kernel_exec-acpi.obj: kern/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-acpi.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-acpi.Tpo -c -o kern/kernel_exec-acpi.obj `if test -f 'kern/acpi.c'; then $(CYGPATH_W) 'kern/acpi.c'; else $(CYGPATH_W) '$(srcdir)/kern/acpi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-acpi.Tpo kern/$(DEPDIR)/kernel_exec-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/acpi.c' object='kern/kernel_exec-acpi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-acpi.obj `if test -f 'kern/acpi.c'; then $(CYGPATH_W) 'kern/acpi.c'; else $(CYGPATH_W) '$(srcdir)/kern/acpi.c'; fi`
+
+kern/efi/kernel_exec-acpi.o: kern/efi/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-acpi.o -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-acpi.Tpo -c -o kern/efi/kernel_exec-acpi.o `test -f 'kern/efi/acpi.c' || echo '$(srcdir)/'`kern/efi/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-acpi.Tpo kern/efi/$(DEPDIR)/kernel_exec-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/acpi.c' object='kern/efi/kernel_exec-acpi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-acpi.o `test -f 'kern/efi/acpi.c' || echo '$(srcdir)/'`kern/efi/acpi.c
+
+kern/efi/kernel_exec-acpi.obj: kern/efi/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-acpi.obj -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-acpi.Tpo -c -o kern/efi/kernel_exec-acpi.obj `if test -f 'kern/efi/acpi.c'; then $(CYGPATH_W) 'kern/efi/acpi.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/acpi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-acpi.Tpo kern/efi/$(DEPDIR)/kernel_exec-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/acpi.c' object='kern/efi/kernel_exec-acpi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-acpi.obj `if test -f 'kern/efi/acpi.c'; then $(CYGPATH_W) 'kern/efi/acpi.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/acpi.c'; fi`
+
+kern/efi/kernel_exec-sb.o: kern/efi/sb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-sb.o -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-sb.Tpo -c -o kern/efi/kernel_exec-sb.o `test -f 'kern/efi/sb.c' || echo '$(srcdir)/'`kern/efi/sb.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-sb.Tpo kern/efi/$(DEPDIR)/kernel_exec-sb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/sb.c' object='kern/efi/kernel_exec-sb.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-sb.o `test -f 'kern/efi/sb.c' || echo '$(srcdir)/'`kern/efi/sb.c
+
+kern/efi/kernel_exec-sb.obj: kern/efi/sb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/efi/kernel_exec-sb.obj -MD -MP -MF kern/efi/$(DEPDIR)/kernel_exec-sb.Tpo -c -o kern/efi/kernel_exec-sb.obj `if test -f 'kern/efi/sb.c'; then $(CYGPATH_W) 'kern/efi/sb.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/sb.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/efi/$(DEPDIR)/kernel_exec-sb.Tpo kern/efi/$(DEPDIR)/kernel_exec-sb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/efi/sb.c' object='kern/efi/kernel_exec-sb.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/efi/kernel_exec-sb.obj `if test -f 'kern/efi/sb.c'; then $(CYGPATH_W) 'kern/efi/sb.c'; else $(CYGPATH_W) '$(srcdir)/kern/efi/sb.c'; fi`
+
+kern/kernel_exec-lockdown.o: kern/lockdown.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-lockdown.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-lockdown.Tpo -c -o kern/kernel_exec-lockdown.o `test -f 'kern/lockdown.c' || echo '$(srcdir)/'`kern/lockdown.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-lockdown.Tpo kern/$(DEPDIR)/kernel_exec-lockdown.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/lockdown.c' object='kern/kernel_exec-lockdown.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-lockdown.o `test -f 'kern/lockdown.c' || echo '$(srcdir)/'`kern/lockdown.c
+
+kern/kernel_exec-lockdown.obj: kern/lockdown.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-lockdown.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-lockdown.Tpo -c -o kern/kernel_exec-lockdown.obj `if test -f 'kern/lockdown.c'; then $(CYGPATH_W) 'kern/lockdown.c'; else $(CYGPATH_W) '$(srcdir)/kern/lockdown.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-lockdown.Tpo kern/$(DEPDIR)/kernel_exec-lockdown.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/lockdown.c' object='kern/kernel_exec-lockdown.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-lockdown.obj `if test -f 'kern/lockdown.c'; then $(CYGPATH_W) 'kern/lockdown.c'; else $(CYGPATH_W) '$(srcdir)/kern/lockdown.c'; fi`
+
+kern/kernel_exec-compiler-rt.o: kern/compiler-rt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-compiler-rt.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-compiler-rt.Tpo -c -o kern/kernel_exec-compiler-rt.o `test -f 'kern/compiler-rt.c' || echo '$(srcdir)/'`kern/compiler-rt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-compiler-rt.Tpo kern/$(DEPDIR)/kernel_exec-compiler-rt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/compiler-rt.c' object='kern/kernel_exec-compiler-rt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-compiler-rt.o `test -f 'kern/compiler-rt.c' || echo '$(srcdir)/'`kern/compiler-rt.c
+
+kern/kernel_exec-compiler-rt.obj: kern/compiler-rt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-compiler-rt.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-compiler-rt.Tpo -c -o kern/kernel_exec-compiler-rt.obj `if test -f 'kern/compiler-rt.c'; then $(CYGPATH_W) 'kern/compiler-rt.c'; else $(CYGPATH_W) '$(srcdir)/kern/compiler-rt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-compiler-rt.Tpo kern/$(DEPDIR)/kernel_exec-compiler-rt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/compiler-rt.c' object='kern/kernel_exec-compiler-rt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-compiler-rt.obj `if test -f 'kern/compiler-rt.c'; then $(CYGPATH_W) 'kern/compiler-rt.c'; else $(CYGPATH_W) '$(srcdir)/kern/compiler-rt.c'; fi`
+
+kern/kernel_exec-mm.o: kern/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-mm.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-mm.Tpo -c -o kern/kernel_exec-mm.o `test -f 'kern/mm.c' || echo '$(srcdir)/'`kern/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-mm.Tpo kern/$(DEPDIR)/kernel_exec-mm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mm.c' object='kern/kernel_exec-mm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-mm.o `test -f 'kern/mm.c' || echo '$(srcdir)/'`kern/mm.c
+
+kern/kernel_exec-mm.obj: kern/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-mm.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-mm.Tpo -c -o kern/kernel_exec-mm.obj `if test -f 'kern/mm.c'; then $(CYGPATH_W) 'kern/mm.c'; else $(CYGPATH_W) '$(srcdir)/kern/mm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-mm.Tpo kern/$(DEPDIR)/kernel_exec-mm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mm.c' object='kern/kernel_exec-mm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-mm.obj `if test -f 'kern/mm.c'; then $(CYGPATH_W) 'kern/mm.c'; else $(CYGPATH_W) '$(srcdir)/kern/mm.c'; fi`
+
+kern/kernel_exec-time.o: kern/time.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-time.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-time.Tpo -c -o kern/kernel_exec-time.o `test -f 'kern/time.c' || echo '$(srcdir)/'`kern/time.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-time.Tpo kern/$(DEPDIR)/kernel_exec-time.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/time.c' object='kern/kernel_exec-time.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-time.o `test -f 'kern/time.c' || echo '$(srcdir)/'`kern/time.c
+
+kern/kernel_exec-time.obj: kern/time.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-time.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-time.Tpo -c -o kern/kernel_exec-time.obj `if test -f 'kern/time.c'; then $(CYGPATH_W) 'kern/time.c'; else $(CYGPATH_W) '$(srcdir)/kern/time.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-time.Tpo kern/$(DEPDIR)/kernel_exec-time.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/time.c' object='kern/kernel_exec-time.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-time.obj `if test -f 'kern/time.c'; then $(CYGPATH_W) 'kern/time.c'; else $(CYGPATH_W) '$(srcdir)/kern/time.c'; fi`
+
+kern/generic/kernel_exec-millisleep.o: kern/generic/millisleep.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/generic/kernel_exec-millisleep.o -MD -MP -MF kern/generic/$(DEPDIR)/kernel_exec-millisleep.Tpo -c -o kern/generic/kernel_exec-millisleep.o `test -f 'kern/generic/millisleep.c' || echo '$(srcdir)/'`kern/generic/millisleep.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/generic/$(DEPDIR)/kernel_exec-millisleep.Tpo kern/generic/$(DEPDIR)/kernel_exec-millisleep.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/generic/millisleep.c' object='kern/generic/kernel_exec-millisleep.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/generic/kernel_exec-millisleep.o `test -f 'kern/generic/millisleep.c' || echo '$(srcdir)/'`kern/generic/millisleep.c
+
+kern/generic/kernel_exec-millisleep.obj: kern/generic/millisleep.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/generic/kernel_exec-millisleep.obj -MD -MP -MF kern/generic/$(DEPDIR)/kernel_exec-millisleep.Tpo -c -o kern/generic/kernel_exec-millisleep.obj `if test -f 'kern/generic/millisleep.c'; then $(CYGPATH_W) 'kern/generic/millisleep.c'; else $(CYGPATH_W) '$(srcdir)/kern/generic/millisleep.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/generic/$(DEPDIR)/kernel_exec-millisleep.Tpo kern/generic/$(DEPDIR)/kernel_exec-millisleep.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/generic/millisleep.c' object='kern/generic/kernel_exec-millisleep.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/generic/kernel_exec-millisleep.obj `if test -f 'kern/generic/millisleep.c'; then $(CYGPATH_W) 'kern/generic/millisleep.c'; else $(CYGPATH_W) '$(srcdir)/kern/generic/millisleep.c'; fi`
+
+kern/kernel_exec-buffer.o: kern/buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-buffer.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-buffer.Tpo -c -o kern/kernel_exec-buffer.o `test -f 'kern/buffer.c' || echo '$(srcdir)/'`kern/buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-buffer.Tpo kern/$(DEPDIR)/kernel_exec-buffer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/buffer.c' object='kern/kernel_exec-buffer.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-buffer.o `test -f 'kern/buffer.c' || echo '$(srcdir)/'`kern/buffer.c
+
+kern/kernel_exec-buffer.obj: kern/buffer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-buffer.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-buffer.Tpo -c -o kern/kernel_exec-buffer.obj `if test -f 'kern/buffer.c'; then $(CYGPATH_W) 'kern/buffer.c'; else $(CYGPATH_W) '$(srcdir)/kern/buffer.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-buffer.Tpo kern/$(DEPDIR)/kernel_exec-buffer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/buffer.c' object='kern/kernel_exec-buffer.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-buffer.obj `if test -f 'kern/buffer.c'; then $(CYGPATH_W) 'kern/buffer.c'; else $(CYGPATH_W) '$(srcdir)/kern/buffer.c'; fi`
+
+kern/kernel_exec-command.o: kern/command.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-command.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-command.Tpo -c -o kern/kernel_exec-command.o `test -f 'kern/command.c' || echo '$(srcdir)/'`kern/command.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-command.Tpo kern/$(DEPDIR)/kernel_exec-command.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/command.c' object='kern/kernel_exec-command.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-command.o `test -f 'kern/command.c' || echo '$(srcdir)/'`kern/command.c
+
+kern/kernel_exec-command.obj: kern/command.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-command.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-command.Tpo -c -o kern/kernel_exec-command.obj `if test -f 'kern/command.c'; then $(CYGPATH_W) 'kern/command.c'; else $(CYGPATH_W) '$(srcdir)/kern/command.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-command.Tpo kern/$(DEPDIR)/kernel_exec-command.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/command.c' object='kern/kernel_exec-command.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-command.obj `if test -f 'kern/command.c'; then $(CYGPATH_W) 'kern/command.c'; else $(CYGPATH_W) '$(srcdir)/kern/command.c'; fi`
+
+kern/kernel_exec-corecmd.o: kern/corecmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-corecmd.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-corecmd.Tpo -c -o kern/kernel_exec-corecmd.o `test -f 'kern/corecmd.c' || echo '$(srcdir)/'`kern/corecmd.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-corecmd.Tpo kern/$(DEPDIR)/kernel_exec-corecmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/corecmd.c' object='kern/kernel_exec-corecmd.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-corecmd.o `test -f 'kern/corecmd.c' || echo '$(srcdir)/'`kern/corecmd.c
+
+kern/kernel_exec-corecmd.obj: kern/corecmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-corecmd.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-corecmd.Tpo -c -o kern/kernel_exec-corecmd.obj `if test -f 'kern/corecmd.c'; then $(CYGPATH_W) 'kern/corecmd.c'; else $(CYGPATH_W) '$(srcdir)/kern/corecmd.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-corecmd.Tpo kern/$(DEPDIR)/kernel_exec-corecmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/corecmd.c' object='kern/kernel_exec-corecmd.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-corecmd.obj `if test -f 'kern/corecmd.c'; then $(CYGPATH_W) 'kern/corecmd.c'; else $(CYGPATH_W) '$(srcdir)/kern/corecmd.c'; fi`
+
+kern/kernel_exec-device.o: kern/device.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-device.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-device.Tpo -c -o kern/kernel_exec-device.o `test -f 'kern/device.c' || echo '$(srcdir)/'`kern/device.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-device.Tpo kern/$(DEPDIR)/kernel_exec-device.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/device.c' object='kern/kernel_exec-device.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-device.o `test -f 'kern/device.c' || echo '$(srcdir)/'`kern/device.c
+
+kern/kernel_exec-device.obj: kern/device.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-device.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-device.Tpo -c -o kern/kernel_exec-device.obj `if test -f 'kern/device.c'; then $(CYGPATH_W) 'kern/device.c'; else $(CYGPATH_W) '$(srcdir)/kern/device.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-device.Tpo kern/$(DEPDIR)/kernel_exec-device.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/device.c' object='kern/kernel_exec-device.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-device.obj `if test -f 'kern/device.c'; then $(CYGPATH_W) 'kern/device.c'; else $(CYGPATH_W) '$(srcdir)/kern/device.c'; fi`
+
+kern/kernel_exec-disk.o: kern/disk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-disk.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-disk.Tpo -c -o kern/kernel_exec-disk.o `test -f 'kern/disk.c' || echo '$(srcdir)/'`kern/disk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-disk.Tpo kern/$(DEPDIR)/kernel_exec-disk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/disk.c' object='kern/kernel_exec-disk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-disk.o `test -f 'kern/disk.c' || echo '$(srcdir)/'`kern/disk.c
+
+kern/kernel_exec-disk.obj: kern/disk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-disk.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-disk.Tpo -c -o kern/kernel_exec-disk.obj `if test -f 'kern/disk.c'; then $(CYGPATH_W) 'kern/disk.c'; else $(CYGPATH_W) '$(srcdir)/kern/disk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-disk.Tpo kern/$(DEPDIR)/kernel_exec-disk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/disk.c' object='kern/kernel_exec-disk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-disk.obj `if test -f 'kern/disk.c'; then $(CYGPATH_W) 'kern/disk.c'; else $(CYGPATH_W) '$(srcdir)/kern/disk.c'; fi`
+
+kern/kernel_exec-dl.o: kern/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-dl.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/kernel_exec-dl.o `test -f 'kern/dl.c' || echo '$(srcdir)/'`kern/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-dl.Tpo kern/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/dl.c' object='kern/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-dl.o `test -f 'kern/dl.c' || echo '$(srcdir)/'`kern/dl.c
+
+kern/kernel_exec-dl.obj: kern/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-dl.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/kernel_exec-dl.obj `if test -f 'kern/dl.c'; then $(CYGPATH_W) 'kern/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-dl.Tpo kern/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/dl.c' object='kern/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-dl.obj `if test -f 'kern/dl.c'; then $(CYGPATH_W) 'kern/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/dl.c'; fi`
+
+kern/kernel_exec-env.o: kern/env.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-env.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-env.Tpo -c -o kern/kernel_exec-env.o `test -f 'kern/env.c' || echo '$(srcdir)/'`kern/env.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-env.Tpo kern/$(DEPDIR)/kernel_exec-env.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/env.c' object='kern/kernel_exec-env.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-env.o `test -f 'kern/env.c' || echo '$(srcdir)/'`kern/env.c
+
+kern/kernel_exec-env.obj: kern/env.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-env.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-env.Tpo -c -o kern/kernel_exec-env.obj `if test -f 'kern/env.c'; then $(CYGPATH_W) 'kern/env.c'; else $(CYGPATH_W) '$(srcdir)/kern/env.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-env.Tpo kern/$(DEPDIR)/kernel_exec-env.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/env.c' object='kern/kernel_exec-env.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-env.obj `if test -f 'kern/env.c'; then $(CYGPATH_W) 'kern/env.c'; else $(CYGPATH_W) '$(srcdir)/kern/env.c'; fi`
+
+kern/kernel_exec-err.o: kern/err.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-err.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-err.Tpo -c -o kern/kernel_exec-err.o `test -f 'kern/err.c' || echo '$(srcdir)/'`kern/err.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-err.Tpo kern/$(DEPDIR)/kernel_exec-err.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/err.c' object='kern/kernel_exec-err.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-err.o `test -f 'kern/err.c' || echo '$(srcdir)/'`kern/err.c
+
+kern/kernel_exec-err.obj: kern/err.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-err.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-err.Tpo -c -o kern/kernel_exec-err.obj `if test -f 'kern/err.c'; then $(CYGPATH_W) 'kern/err.c'; else $(CYGPATH_W) '$(srcdir)/kern/err.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-err.Tpo kern/$(DEPDIR)/kernel_exec-err.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/err.c' object='kern/kernel_exec-err.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-err.obj `if test -f 'kern/err.c'; then $(CYGPATH_W) 'kern/err.c'; else $(CYGPATH_W) '$(srcdir)/kern/err.c'; fi`
+
+kern/kernel_exec-file.o: kern/file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-file.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-file.Tpo -c -o kern/kernel_exec-file.o `test -f 'kern/file.c' || echo '$(srcdir)/'`kern/file.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-file.Tpo kern/$(DEPDIR)/kernel_exec-file.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/file.c' object='kern/kernel_exec-file.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-file.o `test -f 'kern/file.c' || echo '$(srcdir)/'`kern/file.c
+
+kern/kernel_exec-file.obj: kern/file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-file.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-file.Tpo -c -o kern/kernel_exec-file.obj `if test -f 'kern/file.c'; then $(CYGPATH_W) 'kern/file.c'; else $(CYGPATH_W) '$(srcdir)/kern/file.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-file.Tpo kern/$(DEPDIR)/kernel_exec-file.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/file.c' object='kern/kernel_exec-file.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-file.obj `if test -f 'kern/file.c'; then $(CYGPATH_W) 'kern/file.c'; else $(CYGPATH_W) '$(srcdir)/kern/file.c'; fi`
+
+kern/kernel_exec-fs.o: kern/fs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-fs.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-fs.Tpo -c -o kern/kernel_exec-fs.o `test -f 'kern/fs.c' || echo '$(srcdir)/'`kern/fs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-fs.Tpo kern/$(DEPDIR)/kernel_exec-fs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/fs.c' object='kern/kernel_exec-fs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-fs.o `test -f 'kern/fs.c' || echo '$(srcdir)/'`kern/fs.c
+
+kern/kernel_exec-fs.obj: kern/fs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-fs.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-fs.Tpo -c -o kern/kernel_exec-fs.obj `if test -f 'kern/fs.c'; then $(CYGPATH_W) 'kern/fs.c'; else $(CYGPATH_W) '$(srcdir)/kern/fs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-fs.Tpo kern/$(DEPDIR)/kernel_exec-fs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/fs.c' object='kern/kernel_exec-fs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-fs.obj `if test -f 'kern/fs.c'; then $(CYGPATH_W) 'kern/fs.c'; else $(CYGPATH_W) '$(srcdir)/kern/fs.c'; fi`
+
+kern/kernel_exec-list.o: kern/list.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-list.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-list.Tpo -c -o kern/kernel_exec-list.o `test -f 'kern/list.c' || echo '$(srcdir)/'`kern/list.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-list.Tpo kern/$(DEPDIR)/kernel_exec-list.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/list.c' object='kern/kernel_exec-list.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-list.o `test -f 'kern/list.c' || echo '$(srcdir)/'`kern/list.c
+
+kern/kernel_exec-list.obj: kern/list.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-list.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-list.Tpo -c -o kern/kernel_exec-list.obj `if test -f 'kern/list.c'; then $(CYGPATH_W) 'kern/list.c'; else $(CYGPATH_W) '$(srcdir)/kern/list.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-list.Tpo kern/$(DEPDIR)/kernel_exec-list.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/list.c' object='kern/kernel_exec-list.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-list.obj `if test -f 'kern/list.c'; then $(CYGPATH_W) 'kern/list.c'; else $(CYGPATH_W) '$(srcdir)/kern/list.c'; fi`
+
+kern/kernel_exec-main.o: kern/main.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-main.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-main.Tpo -c -o kern/kernel_exec-main.o `test -f 'kern/main.c' || echo '$(srcdir)/'`kern/main.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-main.Tpo kern/$(DEPDIR)/kernel_exec-main.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/main.c' object='kern/kernel_exec-main.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-main.o `test -f 'kern/main.c' || echo '$(srcdir)/'`kern/main.c
+
+kern/kernel_exec-main.obj: kern/main.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-main.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-main.Tpo -c -o kern/kernel_exec-main.obj `if test -f 'kern/main.c'; then $(CYGPATH_W) 'kern/main.c'; else $(CYGPATH_W) '$(srcdir)/kern/main.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-main.Tpo kern/$(DEPDIR)/kernel_exec-main.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/main.c' object='kern/kernel_exec-main.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-main.obj `if test -f 'kern/main.c'; then $(CYGPATH_W) 'kern/main.c'; else $(CYGPATH_W) '$(srcdir)/kern/main.c'; fi`
+
+kern/kernel_exec-misc.o: kern/misc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-misc.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-misc.Tpo -c -o kern/kernel_exec-misc.o `test -f 'kern/misc.c' || echo '$(srcdir)/'`kern/misc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-misc.Tpo kern/$(DEPDIR)/kernel_exec-misc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/misc.c' object='kern/kernel_exec-misc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-misc.o `test -f 'kern/misc.c' || echo '$(srcdir)/'`kern/misc.c
+
+kern/kernel_exec-misc.obj: kern/misc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-misc.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-misc.Tpo -c -o kern/kernel_exec-misc.obj `if test -f 'kern/misc.c'; then $(CYGPATH_W) 'kern/misc.c'; else $(CYGPATH_W) '$(srcdir)/kern/misc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-misc.Tpo kern/$(DEPDIR)/kernel_exec-misc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/misc.c' object='kern/kernel_exec-misc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-misc.obj `if test -f 'kern/misc.c'; then $(CYGPATH_W) 'kern/misc.c'; else $(CYGPATH_W) '$(srcdir)/kern/misc.c'; fi`
+
+kern/kernel_exec-parser.o: kern/parser.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-parser.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-parser.Tpo -c -o kern/kernel_exec-parser.o `test -f 'kern/parser.c' || echo '$(srcdir)/'`kern/parser.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-parser.Tpo kern/$(DEPDIR)/kernel_exec-parser.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/parser.c' object='kern/kernel_exec-parser.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-parser.o `test -f 'kern/parser.c' || echo '$(srcdir)/'`kern/parser.c
+
+kern/kernel_exec-parser.obj: kern/parser.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-parser.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-parser.Tpo -c -o kern/kernel_exec-parser.obj `if test -f 'kern/parser.c'; then $(CYGPATH_W) 'kern/parser.c'; else $(CYGPATH_W) '$(srcdir)/kern/parser.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-parser.Tpo kern/$(DEPDIR)/kernel_exec-parser.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/parser.c' object='kern/kernel_exec-parser.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-parser.obj `if test -f 'kern/parser.c'; then $(CYGPATH_W) 'kern/parser.c'; else $(CYGPATH_W) '$(srcdir)/kern/parser.c'; fi`
+
+kern/kernel_exec-partition.o: kern/partition.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-partition.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-partition.Tpo -c -o kern/kernel_exec-partition.o `test -f 'kern/partition.c' || echo '$(srcdir)/'`kern/partition.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-partition.Tpo kern/$(DEPDIR)/kernel_exec-partition.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/partition.c' object='kern/kernel_exec-partition.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-partition.o `test -f 'kern/partition.c' || echo '$(srcdir)/'`kern/partition.c
+
+kern/kernel_exec-partition.obj: kern/partition.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-partition.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-partition.Tpo -c -o kern/kernel_exec-partition.obj `if test -f 'kern/partition.c'; then $(CYGPATH_W) 'kern/partition.c'; else $(CYGPATH_W) '$(srcdir)/kern/partition.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-partition.Tpo kern/$(DEPDIR)/kernel_exec-partition.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/partition.c' object='kern/kernel_exec-partition.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-partition.obj `if test -f 'kern/partition.c'; then $(CYGPATH_W) 'kern/partition.c'; else $(CYGPATH_W) '$(srcdir)/kern/partition.c'; fi`
+
+kern/kernel_exec-rescue_parser.o: kern/rescue_parser.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-rescue_parser.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-rescue_parser.Tpo -c -o kern/kernel_exec-rescue_parser.o `test -f 'kern/rescue_parser.c' || echo '$(srcdir)/'`kern/rescue_parser.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-rescue_parser.Tpo kern/$(DEPDIR)/kernel_exec-rescue_parser.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/rescue_parser.c' object='kern/kernel_exec-rescue_parser.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-rescue_parser.o `test -f 'kern/rescue_parser.c' || echo '$(srcdir)/'`kern/rescue_parser.c
+
+kern/kernel_exec-rescue_parser.obj: kern/rescue_parser.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-rescue_parser.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-rescue_parser.Tpo -c -o kern/kernel_exec-rescue_parser.obj `if test -f 'kern/rescue_parser.c'; then $(CYGPATH_W) 'kern/rescue_parser.c'; else $(CYGPATH_W) '$(srcdir)/kern/rescue_parser.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-rescue_parser.Tpo kern/$(DEPDIR)/kernel_exec-rescue_parser.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/rescue_parser.c' object='kern/kernel_exec-rescue_parser.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-rescue_parser.obj `if test -f 'kern/rescue_parser.c'; then $(CYGPATH_W) 'kern/rescue_parser.c'; else $(CYGPATH_W) '$(srcdir)/kern/rescue_parser.c'; fi`
+
+kern/kernel_exec-rescue_reader.o: kern/rescue_reader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-rescue_reader.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-rescue_reader.Tpo -c -o kern/kernel_exec-rescue_reader.o `test -f 'kern/rescue_reader.c' || echo '$(srcdir)/'`kern/rescue_reader.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-rescue_reader.Tpo kern/$(DEPDIR)/kernel_exec-rescue_reader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/rescue_reader.c' object='kern/kernel_exec-rescue_reader.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-rescue_reader.o `test -f 'kern/rescue_reader.c' || echo '$(srcdir)/'`kern/rescue_reader.c
+
+kern/kernel_exec-rescue_reader.obj: kern/rescue_reader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-rescue_reader.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-rescue_reader.Tpo -c -o kern/kernel_exec-rescue_reader.obj `if test -f 'kern/rescue_reader.c'; then $(CYGPATH_W) 'kern/rescue_reader.c'; else $(CYGPATH_W) '$(srcdir)/kern/rescue_reader.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-rescue_reader.Tpo kern/$(DEPDIR)/kernel_exec-rescue_reader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/rescue_reader.c' object='kern/kernel_exec-rescue_reader.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-rescue_reader.obj `if test -f 'kern/rescue_reader.c'; then $(CYGPATH_W) 'kern/rescue_reader.c'; else $(CYGPATH_W) '$(srcdir)/kern/rescue_reader.c'; fi`
+
+kern/kernel_exec-term.o: kern/term.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-term.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-term.Tpo -c -o kern/kernel_exec-term.o `test -f 'kern/term.c' || echo '$(srcdir)/'`kern/term.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-term.Tpo kern/$(DEPDIR)/kernel_exec-term.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/term.c' object='kern/kernel_exec-term.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-term.o `test -f 'kern/term.c' || echo '$(srcdir)/'`kern/term.c
+
+kern/kernel_exec-term.obj: kern/term.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-term.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-term.Tpo -c -o kern/kernel_exec-term.obj `if test -f 'kern/term.c'; then $(CYGPATH_W) 'kern/term.c'; else $(CYGPATH_W) '$(srcdir)/kern/term.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-term.Tpo kern/$(DEPDIR)/kernel_exec-term.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/term.c' object='kern/kernel_exec-term.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-term.obj `if test -f 'kern/term.c'; then $(CYGPATH_W) 'kern/term.c'; else $(CYGPATH_W) '$(srcdir)/kern/term.c'; fi`
+
+kern/kernel_exec-verifiers.o: kern/verifiers.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-verifiers.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-verifiers.Tpo -c -o kern/kernel_exec-verifiers.o `test -f 'kern/verifiers.c' || echo '$(srcdir)/'`kern/verifiers.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-verifiers.Tpo kern/$(DEPDIR)/kernel_exec-verifiers.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/verifiers.c' object='kern/kernel_exec-verifiers.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-verifiers.o `test -f 'kern/verifiers.c' || echo '$(srcdir)/'`kern/verifiers.c
+
+kern/kernel_exec-verifiers.obj: kern/verifiers.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-verifiers.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-verifiers.Tpo -c -o kern/kernel_exec-verifiers.obj `if test -f 'kern/verifiers.c'; then $(CYGPATH_W) 'kern/verifiers.c'; else $(CYGPATH_W) '$(srcdir)/kern/verifiers.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-verifiers.Tpo kern/$(DEPDIR)/kernel_exec-verifiers.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/verifiers.c' object='kern/kernel_exec-verifiers.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-verifiers.obj `if test -f 'kern/verifiers.c'; then $(CYGPATH_W) 'kern/verifiers.c'; else $(CYGPATH_W) '$(srcdir)/kern/verifiers.c'; fi`
+
+kern/arm/coreboot/kernel_exec-init.o: kern/arm/coreboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/coreboot/kernel_exec-init.o -MD -MP -MF kern/arm/coreboot/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/arm/coreboot/kernel_exec-init.o `test -f 'kern/arm/coreboot/init.c' || echo '$(srcdir)/'`kern/arm/coreboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/coreboot/$(DEPDIR)/kernel_exec-init.Tpo kern/arm/coreboot/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/coreboot/init.c' object='kern/arm/coreboot/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/coreboot/kernel_exec-init.o `test -f 'kern/arm/coreboot/init.c' || echo '$(srcdir)/'`kern/arm/coreboot/init.c
+
+kern/arm/coreboot/kernel_exec-init.obj: kern/arm/coreboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/coreboot/kernel_exec-init.obj -MD -MP -MF kern/arm/coreboot/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/arm/coreboot/kernel_exec-init.obj `if test -f 'kern/arm/coreboot/init.c'; then $(CYGPATH_W) 'kern/arm/coreboot/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/coreboot/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/coreboot/$(DEPDIR)/kernel_exec-init.Tpo kern/arm/coreboot/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/coreboot/init.c' object='kern/arm/coreboot/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/coreboot/kernel_exec-init.obj `if test -f 'kern/arm/coreboot/init.c'; then $(CYGPATH_W) 'kern/arm/coreboot/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/coreboot/init.c'; fi`
+
+kern/arm/coreboot/kernel_exec-timer.o: kern/arm/coreboot/timer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/coreboot/kernel_exec-timer.o -MD -MP -MF kern/arm/coreboot/$(DEPDIR)/kernel_exec-timer.Tpo -c -o kern/arm/coreboot/kernel_exec-timer.o `test -f 'kern/arm/coreboot/timer.c' || echo '$(srcdir)/'`kern/arm/coreboot/timer.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/coreboot/$(DEPDIR)/kernel_exec-timer.Tpo kern/arm/coreboot/$(DEPDIR)/kernel_exec-timer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/coreboot/timer.c' object='kern/arm/coreboot/kernel_exec-timer.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/coreboot/kernel_exec-timer.o `test -f 'kern/arm/coreboot/timer.c' || echo '$(srcdir)/'`kern/arm/coreboot/timer.c
+
+kern/arm/coreboot/kernel_exec-timer.obj: kern/arm/coreboot/timer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/coreboot/kernel_exec-timer.obj -MD -MP -MF kern/arm/coreboot/$(DEPDIR)/kernel_exec-timer.Tpo -c -o kern/arm/coreboot/kernel_exec-timer.obj `if test -f 'kern/arm/coreboot/timer.c'; then $(CYGPATH_W) 'kern/arm/coreboot/timer.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/coreboot/timer.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/coreboot/$(DEPDIR)/kernel_exec-timer.Tpo kern/arm/coreboot/$(DEPDIR)/kernel_exec-timer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/coreboot/timer.c' object='kern/arm/coreboot/kernel_exec-timer.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/coreboot/kernel_exec-timer.obj `if test -f 'kern/arm/coreboot/timer.c'; then $(CYGPATH_W) 'kern/arm/coreboot/timer.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/coreboot/timer.c'; fi`
+
+lib/kernel_exec-fdt.o: lib/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT lib/kernel_exec-fdt.o -MD -MP -MF lib/$(DEPDIR)/kernel_exec-fdt.Tpo -c -o lib/kernel_exec-fdt.o `test -f 'lib/fdt.c' || echo '$(srcdir)/'`lib/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/kernel_exec-fdt.Tpo lib/$(DEPDIR)/kernel_exec-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/fdt.c' object='lib/kernel_exec-fdt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o lib/kernel_exec-fdt.o `test -f 'lib/fdt.c' || echo '$(srcdir)/'`lib/fdt.c
+
+lib/kernel_exec-fdt.obj: lib/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT lib/kernel_exec-fdt.obj -MD -MP -MF lib/$(DEPDIR)/kernel_exec-fdt.Tpo -c -o lib/kernel_exec-fdt.obj `if test -f 'lib/fdt.c'; then $(CYGPATH_W) 'lib/fdt.c'; else $(CYGPATH_W) '$(srcdir)/lib/fdt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/kernel_exec-fdt.Tpo lib/$(DEPDIR)/kernel_exec-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/fdt.c' object='lib/kernel_exec-fdt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o lib/kernel_exec-fdt.obj `if test -f 'lib/fdt.c'; then $(CYGPATH_W) 'lib/fdt.c'; else $(CYGPATH_W) '$(srcdir)/lib/fdt.c'; fi`
+
+bus/kernel_exec-fdt.o: bus/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT bus/kernel_exec-fdt.o -MD -MP -MF bus/$(DEPDIR)/kernel_exec-fdt.Tpo -c -o bus/kernel_exec-fdt.o `test -f 'bus/fdt.c' || echo '$(srcdir)/'`bus/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/kernel_exec-fdt.Tpo bus/$(DEPDIR)/kernel_exec-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/fdt.c' object='bus/kernel_exec-fdt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o bus/kernel_exec-fdt.o `test -f 'bus/fdt.c' || echo '$(srcdir)/'`bus/fdt.c
+
+bus/kernel_exec-fdt.obj: bus/fdt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT bus/kernel_exec-fdt.obj -MD -MP -MF bus/$(DEPDIR)/kernel_exec-fdt.Tpo -c -o bus/kernel_exec-fdt.obj `if test -f 'bus/fdt.c'; then $(CYGPATH_W) 'bus/fdt.c'; else $(CYGPATH_W) '$(srcdir)/bus/fdt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/kernel_exec-fdt.Tpo bus/$(DEPDIR)/kernel_exec-fdt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/fdt.c' object='bus/kernel_exec-fdt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o bus/kernel_exec-fdt.obj `if test -f 'bus/fdt.c'; then $(CYGPATH_W) 'bus/fdt.c'; else $(CYGPATH_W) '$(srcdir)/bus/fdt.c'; fi`
+
+term/kernel_exec-ps2.o: term/ps2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-ps2.o -MD -MP -MF term/$(DEPDIR)/kernel_exec-ps2.Tpo -c -o term/kernel_exec-ps2.o `test -f 'term/ps2.c' || echo '$(srcdir)/'`term/ps2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-ps2.Tpo term/$(DEPDIR)/kernel_exec-ps2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ps2.c' object='term/kernel_exec-ps2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-ps2.o `test -f 'term/ps2.c' || echo '$(srcdir)/'`term/ps2.c
+
+term/kernel_exec-ps2.obj: term/ps2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-ps2.obj -MD -MP -MF term/$(DEPDIR)/kernel_exec-ps2.Tpo -c -o term/kernel_exec-ps2.obj `if test -f 'term/ps2.c'; then $(CYGPATH_W) 'term/ps2.c'; else $(CYGPATH_W) '$(srcdir)/term/ps2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-ps2.Tpo term/$(DEPDIR)/kernel_exec-ps2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ps2.c' object='term/kernel_exec-ps2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-ps2.obj `if test -f 'term/ps2.c'; then $(CYGPATH_W) 'term/ps2.c'; else $(CYGPATH_W) '$(srcdir)/term/ps2.c'; fi`
+
+term/arm/kernel_exec-pl050.o: term/arm/pl050.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/arm/kernel_exec-pl050.o -MD -MP -MF term/arm/$(DEPDIR)/kernel_exec-pl050.Tpo -c -o term/arm/kernel_exec-pl050.o `test -f 'term/arm/pl050.c' || echo '$(srcdir)/'`term/arm/pl050.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/arm/$(DEPDIR)/kernel_exec-pl050.Tpo term/arm/$(DEPDIR)/kernel_exec-pl050.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/arm/pl050.c' object='term/arm/kernel_exec-pl050.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/arm/kernel_exec-pl050.o `test -f 'term/arm/pl050.c' || echo '$(srcdir)/'`term/arm/pl050.c
+
+term/arm/kernel_exec-pl050.obj: term/arm/pl050.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/arm/kernel_exec-pl050.obj -MD -MP -MF term/arm/$(DEPDIR)/kernel_exec-pl050.Tpo -c -o term/arm/kernel_exec-pl050.obj `if test -f 'term/arm/pl050.c'; then $(CYGPATH_W) 'term/arm/pl050.c'; else $(CYGPATH_W) '$(srcdir)/term/arm/pl050.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/arm/$(DEPDIR)/kernel_exec-pl050.Tpo term/arm/$(DEPDIR)/kernel_exec-pl050.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/arm/pl050.c' object='term/arm/kernel_exec-pl050.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/arm/kernel_exec-pl050.obj `if test -f 'term/arm/pl050.c'; then $(CYGPATH_W) 'term/arm/pl050.c'; else $(CYGPATH_W) '$(srcdir)/term/arm/pl050.c'; fi`
+
+term/arm/kernel_exec-cros.o: term/arm/cros.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/arm/kernel_exec-cros.o -MD -MP -MF term/arm/$(DEPDIR)/kernel_exec-cros.Tpo -c -o term/arm/kernel_exec-cros.o `test -f 'term/arm/cros.c' || echo '$(srcdir)/'`term/arm/cros.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/arm/$(DEPDIR)/kernel_exec-cros.Tpo term/arm/$(DEPDIR)/kernel_exec-cros.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/arm/cros.c' object='term/arm/kernel_exec-cros.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/arm/kernel_exec-cros.o `test -f 'term/arm/cros.c' || echo '$(srcdir)/'`term/arm/cros.c
+
+term/arm/kernel_exec-cros.obj: term/arm/cros.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/arm/kernel_exec-cros.obj -MD -MP -MF term/arm/$(DEPDIR)/kernel_exec-cros.Tpo -c -o term/arm/kernel_exec-cros.obj `if test -f 'term/arm/cros.c'; then $(CYGPATH_W) 'term/arm/cros.c'; else $(CYGPATH_W) '$(srcdir)/term/arm/cros.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/arm/$(DEPDIR)/kernel_exec-cros.Tpo term/arm/$(DEPDIR)/kernel_exec-cros.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/arm/cros.c' object='term/arm/kernel_exec-cros.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/arm/kernel_exec-cros.obj `if test -f 'term/arm/cros.c'; then $(CYGPATH_W) 'term/arm/cros.c'; else $(CYGPATH_W) '$(srcdir)/term/arm/cros.c'; fi`
+
+term/arm/kernel_exec-cros_ec.o: term/arm/cros_ec.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/arm/kernel_exec-cros_ec.o -MD -MP -MF term/arm/$(DEPDIR)/kernel_exec-cros_ec.Tpo -c -o term/arm/kernel_exec-cros_ec.o `test -f 'term/arm/cros_ec.c' || echo '$(srcdir)/'`term/arm/cros_ec.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/arm/$(DEPDIR)/kernel_exec-cros_ec.Tpo term/arm/$(DEPDIR)/kernel_exec-cros_ec.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/arm/cros_ec.c' object='term/arm/kernel_exec-cros_ec.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/arm/kernel_exec-cros_ec.o `test -f 'term/arm/cros_ec.c' || echo '$(srcdir)/'`term/arm/cros_ec.c
+
+term/arm/kernel_exec-cros_ec.obj: term/arm/cros_ec.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/arm/kernel_exec-cros_ec.obj -MD -MP -MF term/arm/$(DEPDIR)/kernel_exec-cros_ec.Tpo -c -o term/arm/kernel_exec-cros_ec.obj `if test -f 'term/arm/cros_ec.c'; then $(CYGPATH_W) 'term/arm/cros_ec.c'; else $(CYGPATH_W) '$(srcdir)/term/arm/cros_ec.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/arm/$(DEPDIR)/kernel_exec-cros_ec.Tpo term/arm/$(DEPDIR)/kernel_exec-cros_ec.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/arm/cros_ec.c' object='term/arm/kernel_exec-cros_ec.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/arm/kernel_exec-cros_ec.obj `if test -f 'term/arm/cros_ec.c'; then $(CYGPATH_W) 'term/arm/cros_ec.c'; else $(CYGPATH_W) '$(srcdir)/term/arm/cros_ec.c'; fi`
+
+bus/spi/kernel_exec-rk3288_spi.o: bus/spi/rk3288_spi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT bus/spi/kernel_exec-rk3288_spi.o -MD -MP -MF bus/spi/$(DEPDIR)/kernel_exec-rk3288_spi.Tpo -c -o bus/spi/kernel_exec-rk3288_spi.o `test -f 'bus/spi/rk3288_spi.c' || echo '$(srcdir)/'`bus/spi/rk3288_spi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/spi/$(DEPDIR)/kernel_exec-rk3288_spi.Tpo bus/spi/$(DEPDIR)/kernel_exec-rk3288_spi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/spi/rk3288_spi.c' object='bus/spi/kernel_exec-rk3288_spi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o bus/spi/kernel_exec-rk3288_spi.o `test -f 'bus/spi/rk3288_spi.c' || echo '$(srcdir)/'`bus/spi/rk3288_spi.c
+
+bus/spi/kernel_exec-rk3288_spi.obj: bus/spi/rk3288_spi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT bus/spi/kernel_exec-rk3288_spi.obj -MD -MP -MF bus/spi/$(DEPDIR)/kernel_exec-rk3288_spi.Tpo -c -o bus/spi/kernel_exec-rk3288_spi.obj `if test -f 'bus/spi/rk3288_spi.c'; then $(CYGPATH_W) 'bus/spi/rk3288_spi.c'; else $(CYGPATH_W) '$(srcdir)/bus/spi/rk3288_spi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/spi/$(DEPDIR)/kernel_exec-rk3288_spi.Tpo bus/spi/$(DEPDIR)/kernel_exec-rk3288_spi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/spi/rk3288_spi.c' object='bus/spi/kernel_exec-rk3288_spi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o bus/spi/kernel_exec-rk3288_spi.obj `if test -f 'bus/spi/rk3288_spi.c'; then $(CYGPATH_W) 'bus/spi/rk3288_spi.c'; else $(CYGPATH_W) '$(srcdir)/bus/spi/rk3288_spi.c'; fi`
+
+commands/kernel_exec-keylayouts.o: commands/keylayouts.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT commands/kernel_exec-keylayouts.o -MD -MP -MF commands/$(DEPDIR)/kernel_exec-keylayouts.Tpo -c -o commands/kernel_exec-keylayouts.o `test -f 'commands/keylayouts.c' || echo '$(srcdir)/'`commands/keylayouts.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/kernel_exec-keylayouts.Tpo commands/$(DEPDIR)/kernel_exec-keylayouts.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/keylayouts.c' object='commands/kernel_exec-keylayouts.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o commands/kernel_exec-keylayouts.o `test -f 'commands/keylayouts.c' || echo '$(srcdir)/'`commands/keylayouts.c
+
+commands/kernel_exec-keylayouts.obj: commands/keylayouts.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT commands/kernel_exec-keylayouts.obj -MD -MP -MF commands/$(DEPDIR)/kernel_exec-keylayouts.Tpo -c -o commands/kernel_exec-keylayouts.obj `if test -f 'commands/keylayouts.c'; then $(CYGPATH_W) 'commands/keylayouts.c'; else $(CYGPATH_W) '$(srcdir)/commands/keylayouts.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/kernel_exec-keylayouts.Tpo commands/$(DEPDIR)/kernel_exec-keylayouts.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/keylayouts.c' object='commands/kernel_exec-keylayouts.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o commands/kernel_exec-keylayouts.obj `if test -f 'commands/keylayouts.c'; then $(CYGPATH_W) 'commands/keylayouts.c'; else $(CYGPATH_W) '$(srcdir)/commands/keylayouts.c'; fi`
+
+kern/arm/coreboot/kernel_exec-dma.o: kern/arm/coreboot/dma.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/coreboot/kernel_exec-dma.o -MD -MP -MF kern/arm/coreboot/$(DEPDIR)/kernel_exec-dma.Tpo -c -o kern/arm/coreboot/kernel_exec-dma.o `test -f 'kern/arm/coreboot/dma.c' || echo '$(srcdir)/'`kern/arm/coreboot/dma.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/coreboot/$(DEPDIR)/kernel_exec-dma.Tpo kern/arm/coreboot/$(DEPDIR)/kernel_exec-dma.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/coreboot/dma.c' object='kern/arm/coreboot/kernel_exec-dma.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/coreboot/kernel_exec-dma.o `test -f 'kern/arm/coreboot/dma.c' || echo '$(srcdir)/'`kern/arm/coreboot/dma.c
+
+kern/arm/coreboot/kernel_exec-dma.obj: kern/arm/coreboot/dma.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/coreboot/kernel_exec-dma.obj -MD -MP -MF kern/arm/coreboot/$(DEPDIR)/kernel_exec-dma.Tpo -c -o kern/arm/coreboot/kernel_exec-dma.obj `if test -f 'kern/arm/coreboot/dma.c'; then $(CYGPATH_W) 'kern/arm/coreboot/dma.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/coreboot/dma.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/coreboot/$(DEPDIR)/kernel_exec-dma.Tpo kern/arm/coreboot/$(DEPDIR)/kernel_exec-dma.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/coreboot/dma.c' object='kern/arm/coreboot/kernel_exec-dma.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/coreboot/kernel_exec-dma.obj `if test -f 'kern/arm/coreboot/dma.c'; then $(CYGPATH_W) 'kern/arm/coreboot/dma.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/coreboot/dma.c'; fi`
+
+kern/arm/coreboot/kernel_exec-cbtable.o: kern/arm/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/coreboot/kernel_exec-cbtable.o -MD -MP -MF kern/arm/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo -c -o kern/arm/coreboot/kernel_exec-cbtable.o `test -f 'kern/arm/coreboot/cbtable.c' || echo '$(srcdir)/'`kern/arm/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo kern/arm/coreboot/$(DEPDIR)/kernel_exec-cbtable.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/coreboot/cbtable.c' object='kern/arm/coreboot/kernel_exec-cbtable.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/coreboot/kernel_exec-cbtable.o `test -f 'kern/arm/coreboot/cbtable.c' || echo '$(srcdir)/'`kern/arm/coreboot/cbtable.c
+
+kern/arm/coreboot/kernel_exec-cbtable.obj: kern/arm/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/coreboot/kernel_exec-cbtable.obj -MD -MP -MF kern/arm/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo -c -o kern/arm/coreboot/kernel_exec-cbtable.obj `if test -f 'kern/arm/coreboot/cbtable.c'; then $(CYGPATH_W) 'kern/arm/coreboot/cbtable.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/coreboot/cbtable.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo kern/arm/coreboot/$(DEPDIR)/kernel_exec-cbtable.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/coreboot/cbtable.c' object='kern/arm/coreboot/kernel_exec-cbtable.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/coreboot/kernel_exec-cbtable.obj `if test -f 'kern/arm/coreboot/cbtable.c'; then $(CYGPATH_W) 'kern/arm/coreboot/cbtable.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/coreboot/cbtable.c'; fi`
+
+video/coreboot/kernel_exec-cbfb.o: video/coreboot/cbfb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/coreboot/kernel_exec-cbfb.o -MD -MP -MF video/coreboot/$(DEPDIR)/kernel_exec-cbfb.Tpo -c -o video/coreboot/kernel_exec-cbfb.o `test -f 'video/coreboot/cbfb.c' || echo '$(srcdir)/'`video/coreboot/cbfb.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/coreboot/$(DEPDIR)/kernel_exec-cbfb.Tpo video/coreboot/$(DEPDIR)/kernel_exec-cbfb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/coreboot/cbfb.c' object='video/coreboot/kernel_exec-cbfb.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/coreboot/kernel_exec-cbfb.o `test -f 'video/coreboot/cbfb.c' || echo '$(srcdir)/'`video/coreboot/cbfb.c
+
+video/coreboot/kernel_exec-cbfb.obj: video/coreboot/cbfb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/coreboot/kernel_exec-cbfb.obj -MD -MP -MF video/coreboot/$(DEPDIR)/kernel_exec-cbfb.Tpo -c -o video/coreboot/kernel_exec-cbfb.obj `if test -f 'video/coreboot/cbfb.c'; then $(CYGPATH_W) 'video/coreboot/cbfb.c'; else $(CYGPATH_W) '$(srcdir)/video/coreboot/cbfb.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/coreboot/$(DEPDIR)/kernel_exec-cbfb.Tpo video/coreboot/$(DEPDIR)/kernel_exec-cbfb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/coreboot/cbfb.c' object='video/coreboot/kernel_exec-cbfb.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/coreboot/kernel_exec-cbfb.obj `if test -f 'video/coreboot/cbfb.c'; then $(CYGPATH_W) 'video/coreboot/cbfb.c'; else $(CYGPATH_W) '$(srcdir)/video/coreboot/cbfb.c'; fi`
+
+kern/coreboot/kernel_exec-mmap.o: kern/coreboot/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/coreboot/kernel_exec-mmap.o -MD -MP -MF kern/coreboot/$(DEPDIR)/kernel_exec-mmap.Tpo -c -o kern/coreboot/kernel_exec-mmap.o `test -f 'kern/coreboot/mmap.c' || echo '$(srcdir)/'`kern/coreboot/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/coreboot/$(DEPDIR)/kernel_exec-mmap.Tpo kern/coreboot/$(DEPDIR)/kernel_exec-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/coreboot/mmap.c' object='kern/coreboot/kernel_exec-mmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/coreboot/kernel_exec-mmap.o `test -f 'kern/coreboot/mmap.c' || echo '$(srcdir)/'`kern/coreboot/mmap.c
+
+kern/coreboot/kernel_exec-mmap.obj: kern/coreboot/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/coreboot/kernel_exec-mmap.obj -MD -MP -MF kern/coreboot/$(DEPDIR)/kernel_exec-mmap.Tpo -c -o kern/coreboot/kernel_exec-mmap.obj `if test -f 'kern/coreboot/mmap.c'; then $(CYGPATH_W) 'kern/coreboot/mmap.c'; else $(CYGPATH_W) '$(srcdir)/kern/coreboot/mmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/coreboot/$(DEPDIR)/kernel_exec-mmap.Tpo kern/coreboot/$(DEPDIR)/kernel_exec-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/coreboot/mmap.c' object='kern/coreboot/kernel_exec-mmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/coreboot/kernel_exec-mmap.obj `if test -f 'kern/coreboot/mmap.c'; then $(CYGPATH_W) 'kern/coreboot/mmap.c'; else $(CYGPATH_W) '$(srcdir)/kern/coreboot/mmap.c'; fi`
+
+kern/coreboot/kernel_exec-cbtable.o: kern/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/coreboot/kernel_exec-cbtable.o -MD -MP -MF kern/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo -c -o kern/coreboot/kernel_exec-cbtable.o `test -f 'kern/coreboot/cbtable.c' || echo '$(srcdir)/'`kern/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo kern/coreboot/$(DEPDIR)/kernel_exec-cbtable.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/coreboot/cbtable.c' object='kern/coreboot/kernel_exec-cbtable.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/coreboot/kernel_exec-cbtable.o `test -f 'kern/coreboot/cbtable.c' || echo '$(srcdir)/'`kern/coreboot/cbtable.c
+
+kern/coreboot/kernel_exec-cbtable.obj: kern/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/coreboot/kernel_exec-cbtable.obj -MD -MP -MF kern/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo -c -o kern/coreboot/kernel_exec-cbtable.obj `if test -f 'kern/coreboot/cbtable.c'; then $(CYGPATH_W) 'kern/coreboot/cbtable.c'; else $(CYGPATH_W) '$(srcdir)/kern/coreboot/cbtable.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo kern/coreboot/$(DEPDIR)/kernel_exec-cbtable.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/coreboot/cbtable.c' object='kern/coreboot/kernel_exec-cbtable.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/coreboot/kernel_exec-cbtable.obj `if test -f 'kern/coreboot/cbtable.c'; then $(CYGPATH_W) 'kern/coreboot/cbtable.c'; else $(CYGPATH_W) '$(srcdir)/kern/coreboot/cbtable.c'; fi`
+
+term/kernel_exec-gfxterm.o: term/gfxterm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-gfxterm.o -MD -MP -MF term/$(DEPDIR)/kernel_exec-gfxterm.Tpo -c -o term/kernel_exec-gfxterm.o `test -f 'term/gfxterm.c' || echo '$(srcdir)/'`term/gfxterm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-gfxterm.Tpo term/$(DEPDIR)/kernel_exec-gfxterm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/gfxterm.c' object='term/kernel_exec-gfxterm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-gfxterm.o `test -f 'term/gfxterm.c' || echo '$(srcdir)/'`term/gfxterm.c
+
+term/kernel_exec-gfxterm.obj: term/gfxterm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-gfxterm.obj -MD -MP -MF term/$(DEPDIR)/kernel_exec-gfxterm.Tpo -c -o term/kernel_exec-gfxterm.obj `if test -f 'term/gfxterm.c'; then $(CYGPATH_W) 'term/gfxterm.c'; else $(CYGPATH_W) '$(srcdir)/term/gfxterm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-gfxterm.Tpo term/$(DEPDIR)/kernel_exec-gfxterm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/gfxterm.c' object='term/kernel_exec-gfxterm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-gfxterm.obj `if test -f 'term/gfxterm.c'; then $(CYGPATH_W) 'term/gfxterm.c'; else $(CYGPATH_W) '$(srcdir)/term/gfxterm.c'; fi`
+
+font/kernel_exec-font.o: font/font.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT font/kernel_exec-font.o -MD -MP -MF font/$(DEPDIR)/kernel_exec-font.Tpo -c -o font/kernel_exec-font.o `test -f 'font/font.c' || echo '$(srcdir)/'`font/font.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) font/$(DEPDIR)/kernel_exec-font.Tpo font/$(DEPDIR)/kernel_exec-font.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='font/font.c' object='font/kernel_exec-font.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o font/kernel_exec-font.o `test -f 'font/font.c' || echo '$(srcdir)/'`font/font.c
+
+font/kernel_exec-font.obj: font/font.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT font/kernel_exec-font.obj -MD -MP -MF font/$(DEPDIR)/kernel_exec-font.Tpo -c -o font/kernel_exec-font.obj `if test -f 'font/font.c'; then $(CYGPATH_W) 'font/font.c'; else $(CYGPATH_W) '$(srcdir)/font/font.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) font/$(DEPDIR)/kernel_exec-font.Tpo font/$(DEPDIR)/kernel_exec-font.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='font/font.c' object='font/kernel_exec-font.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o font/kernel_exec-font.obj `if test -f 'font/font.c'; then $(CYGPATH_W) 'font/font.c'; else $(CYGPATH_W) '$(srcdir)/font/font.c'; fi`
+
+font/kernel_exec-font_cmd.o: font/font_cmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT font/kernel_exec-font_cmd.o -MD -MP -MF font/$(DEPDIR)/kernel_exec-font_cmd.Tpo -c -o font/kernel_exec-font_cmd.o `test -f 'font/font_cmd.c' || echo '$(srcdir)/'`font/font_cmd.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) font/$(DEPDIR)/kernel_exec-font_cmd.Tpo font/$(DEPDIR)/kernel_exec-font_cmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='font/font_cmd.c' object='font/kernel_exec-font_cmd.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o font/kernel_exec-font_cmd.o `test -f 'font/font_cmd.c' || echo '$(srcdir)/'`font/font_cmd.c
+
+font/kernel_exec-font_cmd.obj: font/font_cmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT font/kernel_exec-font_cmd.obj -MD -MP -MF font/$(DEPDIR)/kernel_exec-font_cmd.Tpo -c -o font/kernel_exec-font_cmd.obj `if test -f 'font/font_cmd.c'; then $(CYGPATH_W) 'font/font_cmd.c'; else $(CYGPATH_W) '$(srcdir)/font/font_cmd.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) font/$(DEPDIR)/kernel_exec-font_cmd.Tpo font/$(DEPDIR)/kernel_exec-font_cmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='font/font_cmd.c' object='font/kernel_exec-font_cmd.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o font/kernel_exec-font_cmd.obj `if test -f 'font/font_cmd.c'; then $(CYGPATH_W) 'font/font_cmd.c'; else $(CYGPATH_W) '$(srcdir)/font/font_cmd.c'; fi`
+
+io/kernel_exec-bufio.o: io/bufio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT io/kernel_exec-bufio.o -MD -MP -MF io/$(DEPDIR)/kernel_exec-bufio.Tpo -c -o io/kernel_exec-bufio.o `test -f 'io/bufio.c' || echo '$(srcdir)/'`io/bufio.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/kernel_exec-bufio.Tpo io/$(DEPDIR)/kernel_exec-bufio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/bufio.c' object='io/kernel_exec-bufio.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o io/kernel_exec-bufio.o `test -f 'io/bufio.c' || echo '$(srcdir)/'`io/bufio.c
+
+io/kernel_exec-bufio.obj: io/bufio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT io/kernel_exec-bufio.obj -MD -MP -MF io/$(DEPDIR)/kernel_exec-bufio.Tpo -c -o io/kernel_exec-bufio.obj `if test -f 'io/bufio.c'; then $(CYGPATH_W) 'io/bufio.c'; else $(CYGPATH_W) '$(srcdir)/io/bufio.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/kernel_exec-bufio.Tpo io/$(DEPDIR)/kernel_exec-bufio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/bufio.c' object='io/kernel_exec-bufio.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o io/kernel_exec-bufio.obj `if test -f 'io/bufio.c'; then $(CYGPATH_W) 'io/bufio.c'; else $(CYGPATH_W) '$(srcdir)/io/bufio.c'; fi`
+
+video/fb/kernel_exec-fbblit.o: video/fb/fbblit.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/fb/kernel_exec-fbblit.o -MD -MP -MF video/fb/$(DEPDIR)/kernel_exec-fbblit.Tpo -c -o video/fb/kernel_exec-fbblit.o `test -f 'video/fb/fbblit.c' || echo '$(srcdir)/'`video/fb/fbblit.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/kernel_exec-fbblit.Tpo video/fb/$(DEPDIR)/kernel_exec-fbblit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbblit.c' object='video/fb/kernel_exec-fbblit.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/fb/kernel_exec-fbblit.o `test -f 'video/fb/fbblit.c' || echo '$(srcdir)/'`video/fb/fbblit.c
+
+video/fb/kernel_exec-fbblit.obj: video/fb/fbblit.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/fb/kernel_exec-fbblit.obj -MD -MP -MF video/fb/$(DEPDIR)/kernel_exec-fbblit.Tpo -c -o video/fb/kernel_exec-fbblit.obj `if test -f 'video/fb/fbblit.c'; then $(CYGPATH_W) 'video/fb/fbblit.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbblit.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/kernel_exec-fbblit.Tpo video/fb/$(DEPDIR)/kernel_exec-fbblit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbblit.c' object='video/fb/kernel_exec-fbblit.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/fb/kernel_exec-fbblit.obj `if test -f 'video/fb/fbblit.c'; then $(CYGPATH_W) 'video/fb/fbblit.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbblit.c'; fi`
+
+video/fb/kernel_exec-fbfill.o: video/fb/fbfill.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/fb/kernel_exec-fbfill.o -MD -MP -MF video/fb/$(DEPDIR)/kernel_exec-fbfill.Tpo -c -o video/fb/kernel_exec-fbfill.o `test -f 'video/fb/fbfill.c' || echo '$(srcdir)/'`video/fb/fbfill.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/kernel_exec-fbfill.Tpo video/fb/$(DEPDIR)/kernel_exec-fbfill.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbfill.c' object='video/fb/kernel_exec-fbfill.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/fb/kernel_exec-fbfill.o `test -f 'video/fb/fbfill.c' || echo '$(srcdir)/'`video/fb/fbfill.c
+
+video/fb/kernel_exec-fbfill.obj: video/fb/fbfill.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/fb/kernel_exec-fbfill.obj -MD -MP -MF video/fb/$(DEPDIR)/kernel_exec-fbfill.Tpo -c -o video/fb/kernel_exec-fbfill.obj `if test -f 'video/fb/fbfill.c'; then $(CYGPATH_W) 'video/fb/fbfill.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbfill.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/kernel_exec-fbfill.Tpo video/fb/$(DEPDIR)/kernel_exec-fbfill.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbfill.c' object='video/fb/kernel_exec-fbfill.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/fb/kernel_exec-fbfill.obj `if test -f 'video/fb/fbfill.c'; then $(CYGPATH_W) 'video/fb/fbfill.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbfill.c'; fi`
+
+video/fb/kernel_exec-fbutil.o: video/fb/fbutil.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/fb/kernel_exec-fbutil.o -MD -MP -MF video/fb/$(DEPDIR)/kernel_exec-fbutil.Tpo -c -o video/fb/kernel_exec-fbutil.o `test -f 'video/fb/fbutil.c' || echo '$(srcdir)/'`video/fb/fbutil.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/kernel_exec-fbutil.Tpo video/fb/$(DEPDIR)/kernel_exec-fbutil.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbutil.c' object='video/fb/kernel_exec-fbutil.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/fb/kernel_exec-fbutil.o `test -f 'video/fb/fbutil.c' || echo '$(srcdir)/'`video/fb/fbutil.c
+
+video/fb/kernel_exec-fbutil.obj: video/fb/fbutil.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/fb/kernel_exec-fbutil.obj -MD -MP -MF video/fb/$(DEPDIR)/kernel_exec-fbutil.Tpo -c -o video/fb/kernel_exec-fbutil.obj `if test -f 'video/fb/fbutil.c'; then $(CYGPATH_W) 'video/fb/fbutil.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbutil.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/kernel_exec-fbutil.Tpo video/fb/$(DEPDIR)/kernel_exec-fbutil.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbutil.c' object='video/fb/kernel_exec-fbutil.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/fb/kernel_exec-fbutil.obj `if test -f 'video/fb/fbutil.c'; then $(CYGPATH_W) 'video/fb/fbutil.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbutil.c'; fi`
+
+video/fb/kernel_exec-video_fb.o: video/fb/video_fb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/fb/kernel_exec-video_fb.o -MD -MP -MF video/fb/$(DEPDIR)/kernel_exec-video_fb.Tpo -c -o video/fb/kernel_exec-video_fb.o `test -f 'video/fb/video_fb.c' || echo '$(srcdir)/'`video/fb/video_fb.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/kernel_exec-video_fb.Tpo video/fb/$(DEPDIR)/kernel_exec-video_fb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/video_fb.c' object='video/fb/kernel_exec-video_fb.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/fb/kernel_exec-video_fb.o `test -f 'video/fb/video_fb.c' || echo '$(srcdir)/'`video/fb/video_fb.c
+
+video/fb/kernel_exec-video_fb.obj: video/fb/video_fb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/fb/kernel_exec-video_fb.obj -MD -MP -MF video/fb/$(DEPDIR)/kernel_exec-video_fb.Tpo -c -o video/fb/kernel_exec-video_fb.obj `if test -f 'video/fb/video_fb.c'; then $(CYGPATH_W) 'video/fb/video_fb.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/video_fb.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/kernel_exec-video_fb.Tpo video/fb/$(DEPDIR)/kernel_exec-video_fb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/video_fb.c' object='video/fb/kernel_exec-video_fb.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/fb/kernel_exec-video_fb.obj `if test -f 'video/fb/video_fb.c'; then $(CYGPATH_W) 'video/fb/video_fb.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/video_fb.c'; fi`
+
+video/kernel_exec-video.o: video/video.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/kernel_exec-video.o -MD -MP -MF video/$(DEPDIR)/kernel_exec-video.Tpo -c -o video/kernel_exec-video.o `test -f 'video/video.c' || echo '$(srcdir)/'`video/video.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/kernel_exec-video.Tpo video/$(DEPDIR)/kernel_exec-video.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/video.c' object='video/kernel_exec-video.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/kernel_exec-video.o `test -f 'video/video.c' || echo '$(srcdir)/'`video/video.c
+
+video/kernel_exec-video.obj: video/video.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/kernel_exec-video.obj -MD -MP -MF video/$(DEPDIR)/kernel_exec-video.Tpo -c -o video/kernel_exec-video.obj `if test -f 'video/video.c'; then $(CYGPATH_W) 'video/video.c'; else $(CYGPATH_W) '$(srcdir)/video/video.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/kernel_exec-video.Tpo video/$(DEPDIR)/kernel_exec-video.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/video.c' object='video/kernel_exec-video.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/kernel_exec-video.obj `if test -f 'video/video.c'; then $(CYGPATH_W) 'video/video.c'; else $(CYGPATH_W) '$(srcdir)/video/video.c'; fi`
+
+kern/arm/kernel_exec-dl.o: kern/arm/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/kernel_exec-dl.o -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/arm/kernel_exec-dl.o `test -f 'kern/arm/dl.c' || echo '$(srcdir)/'`kern/arm/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-dl.Tpo kern/arm/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/dl.c' object='kern/arm/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/kernel_exec-dl.o `test -f 'kern/arm/dl.c' || echo '$(srcdir)/'`kern/arm/dl.c
+
+kern/arm/kernel_exec-dl.obj: kern/arm/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/kernel_exec-dl.obj -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/arm/kernel_exec-dl.obj `if test -f 'kern/arm/dl.c'; then $(CYGPATH_W) 'kern/arm/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-dl.Tpo kern/arm/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/dl.c' object='kern/arm/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/kernel_exec-dl.obj `if test -f 'kern/arm/dl.c'; then $(CYGPATH_W) 'kern/arm/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/dl.c'; fi`
+
+kern/arm/kernel_exec-dl_helper.o: kern/arm/dl_helper.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/kernel_exec-dl_helper.o -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-dl_helper.Tpo -c -o kern/arm/kernel_exec-dl_helper.o `test -f 'kern/arm/dl_helper.c' || echo '$(srcdir)/'`kern/arm/dl_helper.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-dl_helper.Tpo kern/arm/$(DEPDIR)/kernel_exec-dl_helper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/dl_helper.c' object='kern/arm/kernel_exec-dl_helper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/kernel_exec-dl_helper.o `test -f 'kern/arm/dl_helper.c' || echo '$(srcdir)/'`kern/arm/dl_helper.c
+
+kern/arm/kernel_exec-dl_helper.obj: kern/arm/dl_helper.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/kernel_exec-dl_helper.obj -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-dl_helper.Tpo -c -o kern/arm/kernel_exec-dl_helper.obj `if test -f 'kern/arm/dl_helper.c'; then $(CYGPATH_W) 'kern/arm/dl_helper.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/dl_helper.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-dl_helper.Tpo kern/arm/$(DEPDIR)/kernel_exec-dl_helper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/dl_helper.c' object='kern/arm/kernel_exec-dl_helper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/kernel_exec-dl_helper.obj `if test -f 'kern/arm/dl_helper.c'; then $(CYGPATH_W) 'kern/arm/dl_helper.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/dl_helper.c'; fi`
+
+kern/arm/kernel_exec-cache.o: kern/arm/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/kernel_exec-cache.o -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/arm/kernel_exec-cache.o `test -f 'kern/arm/cache.c' || echo '$(srcdir)/'`kern/arm/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-cache.Tpo kern/arm/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/cache.c' object='kern/arm/kernel_exec-cache.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/kernel_exec-cache.o `test -f 'kern/arm/cache.c' || echo '$(srcdir)/'`kern/arm/cache.c
+
+kern/arm/kernel_exec-cache.obj: kern/arm/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/kernel_exec-cache.obj -MD -MP -MF kern/arm/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/arm/kernel_exec-cache.obj `if test -f 'kern/arm/cache.c'; then $(CYGPATH_W) 'kern/arm/cache.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/cache.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/$(DEPDIR)/kernel_exec-cache.Tpo kern/arm/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/cache.c' object='kern/arm/kernel_exec-cache.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/kernel_exec-cache.obj `if test -f 'kern/arm/cache.c'; then $(CYGPATH_W) 'kern/arm/cache.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/cache.c'; fi`
+
+lib/kernel_exec-division.o: lib/division.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT lib/kernel_exec-division.o -MD -MP -MF lib/$(DEPDIR)/kernel_exec-division.Tpo -c -o lib/kernel_exec-division.o `test -f 'lib/division.c' || echo '$(srcdir)/'`lib/division.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/kernel_exec-division.Tpo lib/$(DEPDIR)/kernel_exec-division.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/division.c' object='lib/kernel_exec-division.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o lib/kernel_exec-division.o `test -f 'lib/division.c' || echo '$(srcdir)/'`lib/division.c
+
+lib/kernel_exec-division.obj: lib/division.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT lib/kernel_exec-division.obj -MD -MP -MF lib/$(DEPDIR)/kernel_exec-division.Tpo -c -o lib/kernel_exec-division.obj `if test -f 'lib/division.c'; then $(CYGPATH_W) 'lib/division.c'; else $(CYGPATH_W) '$(srcdir)/lib/division.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/kernel_exec-division.Tpo lib/$(DEPDIR)/kernel_exec-division.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/division.c' object='lib/kernel_exec-division.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o lib/kernel_exec-division.obj `if test -f 'lib/division.c'; then $(CYGPATH_W) 'lib/division.c'; else $(CYGPATH_W) '$(srcdir)/lib/division.c'; fi`
+
+kern/arm/efi/kernel_exec-init.o: kern/arm/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/efi/kernel_exec-init.o -MD -MP -MF kern/arm/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/arm/efi/kernel_exec-init.o `test -f 'kern/arm/efi/init.c' || echo '$(srcdir)/'`kern/arm/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/arm/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/efi/init.c' object='kern/arm/efi/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/efi/kernel_exec-init.o `test -f 'kern/arm/efi/init.c' || echo '$(srcdir)/'`kern/arm/efi/init.c
+
+kern/arm/efi/kernel_exec-init.obj: kern/arm/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/efi/kernel_exec-init.obj -MD -MP -MF kern/arm/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/arm/efi/kernel_exec-init.obj `if test -f 'kern/arm/efi/init.c'; then $(CYGPATH_W) 'kern/arm/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/efi/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/arm/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/efi/init.c' object='kern/arm/efi/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/efi/kernel_exec-init.obj `if test -f 'kern/arm/efi/init.c'; then $(CYGPATH_W) 'kern/arm/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/efi/init.c'; fi`
+
+kern/arm/uboot/kernel_exec-init.o: kern/arm/uboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/uboot/kernel_exec-init.o -MD -MP -MF kern/arm/uboot/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/arm/uboot/kernel_exec-init.o `test -f 'kern/arm/uboot/init.c' || echo '$(srcdir)/'`kern/arm/uboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/uboot/$(DEPDIR)/kernel_exec-init.Tpo kern/arm/uboot/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/uboot/init.c' object='kern/arm/uboot/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/uboot/kernel_exec-init.o `test -f 'kern/arm/uboot/init.c' || echo '$(srcdir)/'`kern/arm/uboot/init.c
+
+kern/arm/uboot/kernel_exec-init.obj: kern/arm/uboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/arm/uboot/kernel_exec-init.obj -MD -MP -MF kern/arm/uboot/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/arm/uboot/kernel_exec-init.obj `if test -f 'kern/arm/uboot/init.c'; then $(CYGPATH_W) 'kern/arm/uboot/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/uboot/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/arm/uboot/$(DEPDIR)/kernel_exec-init.Tpo kern/arm/uboot/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/arm/uboot/init.c' object='kern/arm/uboot/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/arm/uboot/kernel_exec-init.obj `if test -f 'kern/arm/uboot/init.c'; then $(CYGPATH_W) 'kern/arm/uboot/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/arm/uboot/init.c'; fi`
+
+disk/uboot/kernel_exec-ubootdisk.o: disk/uboot/ubootdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/uboot/kernel_exec-ubootdisk.o -MD -MP -MF disk/uboot/$(DEPDIR)/kernel_exec-ubootdisk.Tpo -c -o disk/uboot/kernel_exec-ubootdisk.o `test -f 'disk/uboot/ubootdisk.c' || echo '$(srcdir)/'`disk/uboot/ubootdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/uboot/$(DEPDIR)/kernel_exec-ubootdisk.Tpo disk/uboot/$(DEPDIR)/kernel_exec-ubootdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/uboot/ubootdisk.c' object='disk/uboot/kernel_exec-ubootdisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/uboot/kernel_exec-ubootdisk.o `test -f 'disk/uboot/ubootdisk.c' || echo '$(srcdir)/'`disk/uboot/ubootdisk.c
+
+disk/uboot/kernel_exec-ubootdisk.obj: disk/uboot/ubootdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/uboot/kernel_exec-ubootdisk.obj -MD -MP -MF disk/uboot/$(DEPDIR)/kernel_exec-ubootdisk.Tpo -c -o disk/uboot/kernel_exec-ubootdisk.obj `if test -f 'disk/uboot/ubootdisk.c'; then $(CYGPATH_W) 'disk/uboot/ubootdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/uboot/ubootdisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/uboot/$(DEPDIR)/kernel_exec-ubootdisk.Tpo disk/uboot/$(DEPDIR)/kernel_exec-ubootdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/uboot/ubootdisk.c' object='disk/uboot/kernel_exec-ubootdisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/uboot/kernel_exec-ubootdisk.obj `if test -f 'disk/uboot/ubootdisk.c'; then $(CYGPATH_W) 'disk/uboot/ubootdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/uboot/ubootdisk.c'; fi`
+
+kern/uboot/kernel_exec-uboot.o: kern/uboot/uboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/uboot/kernel_exec-uboot.o -MD -MP -MF kern/uboot/$(DEPDIR)/kernel_exec-uboot.Tpo -c -o kern/uboot/kernel_exec-uboot.o `test -f 'kern/uboot/uboot.c' || echo '$(srcdir)/'`kern/uboot/uboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/uboot/$(DEPDIR)/kernel_exec-uboot.Tpo kern/uboot/$(DEPDIR)/kernel_exec-uboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/uboot/uboot.c' object='kern/uboot/kernel_exec-uboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/uboot/kernel_exec-uboot.o `test -f 'kern/uboot/uboot.c' || echo '$(srcdir)/'`kern/uboot/uboot.c
+
+kern/uboot/kernel_exec-uboot.obj: kern/uboot/uboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/uboot/kernel_exec-uboot.obj -MD -MP -MF kern/uboot/$(DEPDIR)/kernel_exec-uboot.Tpo -c -o kern/uboot/kernel_exec-uboot.obj `if test -f 'kern/uboot/uboot.c'; then $(CYGPATH_W) 'kern/uboot/uboot.c'; else $(CYGPATH_W) '$(srcdir)/kern/uboot/uboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/uboot/$(DEPDIR)/kernel_exec-uboot.Tpo kern/uboot/$(DEPDIR)/kernel_exec-uboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/uboot/uboot.c' object='kern/uboot/kernel_exec-uboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/uboot/kernel_exec-uboot.obj `if test -f 'kern/uboot/uboot.c'; then $(CYGPATH_W) 'kern/uboot/uboot.c'; else $(CYGPATH_W) '$(srcdir)/kern/uboot/uboot.c'; fi`
+
+kern/uboot/kernel_exec-init.o: kern/uboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/uboot/kernel_exec-init.o -MD -MP -MF kern/uboot/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/uboot/kernel_exec-init.o `test -f 'kern/uboot/init.c' || echo '$(srcdir)/'`kern/uboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/uboot/$(DEPDIR)/kernel_exec-init.Tpo kern/uboot/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/uboot/init.c' object='kern/uboot/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/uboot/kernel_exec-init.o `test -f 'kern/uboot/init.c' || echo '$(srcdir)/'`kern/uboot/init.c
+
+kern/uboot/kernel_exec-init.obj: kern/uboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/uboot/kernel_exec-init.obj -MD -MP -MF kern/uboot/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/uboot/kernel_exec-init.obj `if test -f 'kern/uboot/init.c'; then $(CYGPATH_W) 'kern/uboot/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/uboot/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/uboot/$(DEPDIR)/kernel_exec-init.Tpo kern/uboot/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/uboot/init.c' object='kern/uboot/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/uboot/kernel_exec-init.obj `if test -f 'kern/uboot/init.c'; then $(CYGPATH_W) 'kern/uboot/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/uboot/init.c'; fi`
+
+kern/uboot/kernel_exec-hw.o: kern/uboot/hw.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/uboot/kernel_exec-hw.o -MD -MP -MF kern/uboot/$(DEPDIR)/kernel_exec-hw.Tpo -c -o kern/uboot/kernel_exec-hw.o `test -f 'kern/uboot/hw.c' || echo '$(srcdir)/'`kern/uboot/hw.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/uboot/$(DEPDIR)/kernel_exec-hw.Tpo kern/uboot/$(DEPDIR)/kernel_exec-hw.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/uboot/hw.c' object='kern/uboot/kernel_exec-hw.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/uboot/kernel_exec-hw.o `test -f 'kern/uboot/hw.c' || echo '$(srcdir)/'`kern/uboot/hw.c
+
+kern/uboot/kernel_exec-hw.obj: kern/uboot/hw.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/uboot/kernel_exec-hw.obj -MD -MP -MF kern/uboot/$(DEPDIR)/kernel_exec-hw.Tpo -c -o kern/uboot/kernel_exec-hw.obj `if test -f 'kern/uboot/hw.c'; then $(CYGPATH_W) 'kern/uboot/hw.c'; else $(CYGPATH_W) '$(srcdir)/kern/uboot/hw.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/uboot/$(DEPDIR)/kernel_exec-hw.Tpo kern/uboot/$(DEPDIR)/kernel_exec-hw.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/uboot/hw.c' object='kern/uboot/kernel_exec-hw.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/uboot/kernel_exec-hw.obj `if test -f 'kern/uboot/hw.c'; then $(CYGPATH_W) 'kern/uboot/hw.c'; else $(CYGPATH_W) '$(srcdir)/kern/uboot/hw.c'; fi`
+
+term/uboot/kernel_exec-console.o: term/uboot/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/uboot/kernel_exec-console.o -MD -MP -MF term/uboot/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/uboot/kernel_exec-console.o `test -f 'term/uboot/console.c' || echo '$(srcdir)/'`term/uboot/console.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/uboot/$(DEPDIR)/kernel_exec-console.Tpo term/uboot/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/uboot/console.c' object='term/uboot/kernel_exec-console.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/uboot/kernel_exec-console.o `test -f 'term/uboot/console.c' || echo '$(srcdir)/'`term/uboot/console.c
+
+term/uboot/kernel_exec-console.obj: term/uboot/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/uboot/kernel_exec-console.obj -MD -MP -MF term/uboot/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/uboot/kernel_exec-console.obj `if test -f 'term/uboot/console.c'; then $(CYGPATH_W) 'term/uboot/console.c'; else $(CYGPATH_W) '$(srcdir)/term/uboot/console.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/uboot/$(DEPDIR)/kernel_exec-console.Tpo term/uboot/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/uboot/console.c' object='term/uboot/kernel_exec-console.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/uboot/kernel_exec-console.obj `if test -f 'term/uboot/console.c'; then $(CYGPATH_W) 'term/uboot/console.c'; else $(CYGPATH_W) '$(srcdir)/term/uboot/console.c'; fi`
+
+term/kernel_exec-terminfo.o: term/terminfo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-terminfo.o -MD -MP -MF term/$(DEPDIR)/kernel_exec-terminfo.Tpo -c -o term/kernel_exec-terminfo.o `test -f 'term/terminfo.c' || echo '$(srcdir)/'`term/terminfo.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-terminfo.Tpo term/$(DEPDIR)/kernel_exec-terminfo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/terminfo.c' object='term/kernel_exec-terminfo.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-terminfo.o `test -f 'term/terminfo.c' || echo '$(srcdir)/'`term/terminfo.c
+
+term/kernel_exec-terminfo.obj: term/terminfo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-terminfo.obj -MD -MP -MF term/$(DEPDIR)/kernel_exec-terminfo.Tpo -c -o term/kernel_exec-terminfo.obj `if test -f 'term/terminfo.c'; then $(CYGPATH_W) 'term/terminfo.c'; else $(CYGPATH_W) '$(srcdir)/term/terminfo.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-terminfo.Tpo term/$(DEPDIR)/kernel_exec-terminfo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/terminfo.c' object='term/kernel_exec-terminfo.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-terminfo.obj `if test -f 'term/terminfo.c'; then $(CYGPATH_W) 'term/terminfo.c'; else $(CYGPATH_W) '$(srcdir)/term/terminfo.c'; fi`
+
+term/kernel_exec-tparm.o: term/tparm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-tparm.o -MD -MP -MF term/$(DEPDIR)/kernel_exec-tparm.Tpo -c -o term/kernel_exec-tparm.o `test -f 'term/tparm.c' || echo '$(srcdir)/'`term/tparm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-tparm.Tpo term/$(DEPDIR)/kernel_exec-tparm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/tparm.c' object='term/kernel_exec-tparm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-tparm.o `test -f 'term/tparm.c' || echo '$(srcdir)/'`term/tparm.c
+
+term/kernel_exec-tparm.obj: term/tparm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-tparm.obj -MD -MP -MF term/$(DEPDIR)/kernel_exec-tparm.Tpo -c -o term/kernel_exec-tparm.obj `if test -f 'term/tparm.c'; then $(CYGPATH_W) 'term/tparm.c'; else $(CYGPATH_W) '$(srcdir)/term/tparm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-tparm.Tpo term/$(DEPDIR)/kernel_exec-tparm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/tparm.c' object='term/kernel_exec-tparm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-tparm.obj `if test -f 'term/tparm.c'; then $(CYGPATH_W) 'term/tparm.c'; else $(CYGPATH_W) '$(srcdir)/term/tparm.c'; fi`
+
+commands/kernel_exec-extcmd.o: commands/extcmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT commands/kernel_exec-extcmd.o -MD -MP -MF commands/$(DEPDIR)/kernel_exec-extcmd.Tpo -c -o commands/kernel_exec-extcmd.o `test -f 'commands/extcmd.c' || echo '$(srcdir)/'`commands/extcmd.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/kernel_exec-extcmd.Tpo commands/$(DEPDIR)/kernel_exec-extcmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/extcmd.c' object='commands/kernel_exec-extcmd.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o commands/kernel_exec-extcmd.o `test -f 'commands/extcmd.c' || echo '$(srcdir)/'`commands/extcmd.c
+
+commands/kernel_exec-extcmd.obj: commands/extcmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT commands/kernel_exec-extcmd.obj -MD -MP -MF commands/$(DEPDIR)/kernel_exec-extcmd.Tpo -c -o commands/kernel_exec-extcmd.obj `if test -f 'commands/extcmd.c'; then $(CYGPATH_W) 'commands/extcmd.c'; else $(CYGPATH_W) '$(srcdir)/commands/extcmd.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/kernel_exec-extcmd.Tpo commands/$(DEPDIR)/kernel_exec-extcmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/extcmd.c' object='commands/kernel_exec-extcmd.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o commands/kernel_exec-extcmd.obj `if test -f 'commands/extcmd.c'; then $(CYGPATH_W) 'commands/extcmd.c'; else $(CYGPATH_W) '$(srcdir)/commands/extcmd.c'; fi`
+
+lib/kernel_exec-arg.o: lib/arg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT lib/kernel_exec-arg.o -MD -MP -MF lib/$(DEPDIR)/kernel_exec-arg.Tpo -c -o lib/kernel_exec-arg.o `test -f 'lib/arg.c' || echo '$(srcdir)/'`lib/arg.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/kernel_exec-arg.Tpo lib/$(DEPDIR)/kernel_exec-arg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/arg.c' object='lib/kernel_exec-arg.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o lib/kernel_exec-arg.o `test -f 'lib/arg.c' || echo '$(srcdir)/'`lib/arg.c
+
+lib/kernel_exec-arg.obj: lib/arg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT lib/kernel_exec-arg.obj -MD -MP -MF lib/$(DEPDIR)/kernel_exec-arg.Tpo -c -o lib/kernel_exec-arg.obj `if test -f 'lib/arg.c'; then $(CYGPATH_W) 'lib/arg.c'; else $(CYGPATH_W) '$(srcdir)/lib/arg.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/kernel_exec-arg.Tpo lib/$(DEPDIR)/kernel_exec-arg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/arg.c' object='lib/kernel_exec-arg.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o lib/kernel_exec-arg.obj `if test -f 'lib/arg.c'; then $(CYGPATH_W) 'lib/arg.c'; else $(CYGPATH_W) '$(srcdir)/lib/arg.c'; fi`
+
+disk/kernel_exec-host.o: disk/host.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/kernel_exec-host.o -MD -MP -MF disk/$(DEPDIR)/kernel_exec-host.Tpo -c -o disk/kernel_exec-host.o `test -f 'disk/host.c' || echo '$(srcdir)/'`disk/host.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/kernel_exec-host.Tpo disk/$(DEPDIR)/kernel_exec-host.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/host.c' object='disk/kernel_exec-host.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/kernel_exec-host.o `test -f 'disk/host.c' || echo '$(srcdir)/'`disk/host.c
+
+disk/kernel_exec-host.obj: disk/host.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/kernel_exec-host.obj -MD -MP -MF disk/$(DEPDIR)/kernel_exec-host.Tpo -c -o disk/kernel_exec-host.obj `if test -f 'disk/host.c'; then $(CYGPATH_W) 'disk/host.c'; else $(CYGPATH_W) '$(srcdir)/disk/host.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/kernel_exec-host.Tpo disk/$(DEPDIR)/kernel_exec-host.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/host.c' object='disk/kernel_exec-host.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/kernel_exec-host.obj `if test -f 'disk/host.c'; then $(CYGPATH_W) 'disk/host.c'; else $(CYGPATH_W) '$(srcdir)/disk/host.c'; fi`
+
+kern/emu/kernel_exec-hostdisk.o: kern/emu/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-hostdisk.o -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-hostdisk.Tpo -c -o kern/emu/kernel_exec-hostdisk.o `test -f 'kern/emu/hostdisk.c' || echo '$(srcdir)/'`kern/emu/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-hostdisk.Tpo kern/emu/$(DEPDIR)/kernel_exec-hostdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/hostdisk.c' object='kern/emu/kernel_exec-hostdisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-hostdisk.o `test -f 'kern/emu/hostdisk.c' || echo '$(srcdir)/'`kern/emu/hostdisk.c
+
+kern/emu/kernel_exec-hostdisk.obj: kern/emu/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-hostdisk.obj -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-hostdisk.Tpo -c -o kern/emu/kernel_exec-hostdisk.obj `if test -f 'kern/emu/hostdisk.c'; then $(CYGPATH_W) 'kern/emu/hostdisk.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/hostdisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-hostdisk.Tpo kern/emu/$(DEPDIR)/kernel_exec-hostdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/hostdisk.c' object='kern/emu/kernel_exec-hostdisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-hostdisk.obj `if test -f 'kern/emu/hostdisk.c'; then $(CYGPATH_W) 'kern/emu/hostdisk.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/hostdisk.c'; fi`
+
+osdep/unix/kernel_exec-hostdisk.o: osdep/unix/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/unix/kernel_exec-hostdisk.o -MD -MP -MF osdep/unix/$(DEPDIR)/kernel_exec-hostdisk.Tpo -c -o osdep/unix/kernel_exec-hostdisk.o `test -f 'osdep/unix/hostdisk.c' || echo '$(srcdir)/'`osdep/unix/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/unix/$(DEPDIR)/kernel_exec-hostdisk.Tpo osdep/unix/$(DEPDIR)/kernel_exec-hostdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/unix/hostdisk.c' object='osdep/unix/kernel_exec-hostdisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/unix/kernel_exec-hostdisk.o `test -f 'osdep/unix/hostdisk.c' || echo '$(srcdir)/'`osdep/unix/hostdisk.c
+
+osdep/unix/kernel_exec-hostdisk.obj: osdep/unix/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/unix/kernel_exec-hostdisk.obj -MD -MP -MF osdep/unix/$(DEPDIR)/kernel_exec-hostdisk.Tpo -c -o osdep/unix/kernel_exec-hostdisk.obj `if test -f 'osdep/unix/hostdisk.c'; then $(CYGPATH_W) 'osdep/unix/hostdisk.c'; else $(CYGPATH_W) '$(srcdir)/osdep/unix/hostdisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/unix/$(DEPDIR)/kernel_exec-hostdisk.Tpo osdep/unix/$(DEPDIR)/kernel_exec-hostdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/unix/hostdisk.c' object='osdep/unix/kernel_exec-hostdisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/unix/kernel_exec-hostdisk.obj `if test -f 'osdep/unix/hostdisk.c'; then $(CYGPATH_W) 'osdep/unix/hostdisk.c'; else $(CYGPATH_W) '$(srcdir)/osdep/unix/hostdisk.c'; fi`
+
+osdep/kernel_exec-exec.o: osdep/exec.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-exec.o -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-exec.Tpo -c -o osdep/kernel_exec-exec.o `test -f 'osdep/exec.c' || echo '$(srcdir)/'`osdep/exec.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-exec.Tpo osdep/$(DEPDIR)/kernel_exec-exec.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/exec.c' object='osdep/kernel_exec-exec.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-exec.o `test -f 'osdep/exec.c' || echo '$(srcdir)/'`osdep/exec.c
+
+osdep/kernel_exec-exec.obj: osdep/exec.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-exec.obj -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-exec.Tpo -c -o osdep/kernel_exec-exec.obj `if test -f 'osdep/exec.c'; then $(CYGPATH_W) 'osdep/exec.c'; else $(CYGPATH_W) '$(srcdir)/osdep/exec.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-exec.Tpo osdep/$(DEPDIR)/kernel_exec-exec.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/exec.c' object='osdep/kernel_exec-exec.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-exec.obj `if test -f 'osdep/exec.c'; then $(CYGPATH_W) 'osdep/exec.c'; else $(CYGPATH_W) '$(srcdir)/osdep/exec.c'; fi`
+
+osdep/devmapper/kernel_exec-hostdisk.o: osdep/devmapper/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/devmapper/kernel_exec-hostdisk.o -MD -MP -MF osdep/devmapper/$(DEPDIR)/kernel_exec-hostdisk.Tpo -c -o osdep/devmapper/kernel_exec-hostdisk.o `test -f 'osdep/devmapper/hostdisk.c' || echo '$(srcdir)/'`osdep/devmapper/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/devmapper/$(DEPDIR)/kernel_exec-hostdisk.Tpo osdep/devmapper/$(DEPDIR)/kernel_exec-hostdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/devmapper/hostdisk.c' object='osdep/devmapper/kernel_exec-hostdisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/devmapper/kernel_exec-hostdisk.o `test -f 'osdep/devmapper/hostdisk.c' || echo '$(srcdir)/'`osdep/devmapper/hostdisk.c
+
+osdep/devmapper/kernel_exec-hostdisk.obj: osdep/devmapper/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/devmapper/kernel_exec-hostdisk.obj -MD -MP -MF osdep/devmapper/$(DEPDIR)/kernel_exec-hostdisk.Tpo -c -o osdep/devmapper/kernel_exec-hostdisk.obj `if test -f 'osdep/devmapper/hostdisk.c'; then $(CYGPATH_W) 'osdep/devmapper/hostdisk.c'; else $(CYGPATH_W) '$(srcdir)/osdep/devmapper/hostdisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/devmapper/$(DEPDIR)/kernel_exec-hostdisk.Tpo osdep/devmapper/$(DEPDIR)/kernel_exec-hostdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/devmapper/hostdisk.c' object='osdep/devmapper/kernel_exec-hostdisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/devmapper/kernel_exec-hostdisk.obj `if test -f 'osdep/devmapper/hostdisk.c'; then $(CYGPATH_W) 'osdep/devmapper/hostdisk.c'; else $(CYGPATH_W) '$(srcdir)/osdep/devmapper/hostdisk.c'; fi`
+
+osdep/kernel_exec-hostdisk.o: osdep/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-hostdisk.o -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-hostdisk.Tpo -c -o osdep/kernel_exec-hostdisk.o `test -f 'osdep/hostdisk.c' || echo '$(srcdir)/'`osdep/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-hostdisk.Tpo osdep/$(DEPDIR)/kernel_exec-hostdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/hostdisk.c' object='osdep/kernel_exec-hostdisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-hostdisk.o `test -f 'osdep/hostdisk.c' || echo '$(srcdir)/'`osdep/hostdisk.c
+
+osdep/kernel_exec-hostdisk.obj: osdep/hostdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-hostdisk.obj -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-hostdisk.Tpo -c -o osdep/kernel_exec-hostdisk.obj `if test -f 'osdep/hostdisk.c'; then $(CYGPATH_W) 'osdep/hostdisk.c'; else $(CYGPATH_W) '$(srcdir)/osdep/hostdisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-hostdisk.Tpo osdep/$(DEPDIR)/kernel_exec-hostdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/hostdisk.c' object='osdep/kernel_exec-hostdisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-hostdisk.obj `if test -f 'osdep/hostdisk.c'; then $(CYGPATH_W) 'osdep/hostdisk.c'; else $(CYGPATH_W) '$(srcdir)/osdep/hostdisk.c'; fi`
+
+kern/emu/kernel_exec-hostfs.o: kern/emu/hostfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-hostfs.o -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-hostfs.Tpo -c -o kern/emu/kernel_exec-hostfs.o `test -f 'kern/emu/hostfs.c' || echo '$(srcdir)/'`kern/emu/hostfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-hostfs.Tpo kern/emu/$(DEPDIR)/kernel_exec-hostfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/hostfs.c' object='kern/emu/kernel_exec-hostfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-hostfs.o `test -f 'kern/emu/hostfs.c' || echo '$(srcdir)/'`kern/emu/hostfs.c
+
+kern/emu/kernel_exec-hostfs.obj: kern/emu/hostfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-hostfs.obj -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-hostfs.Tpo -c -o kern/emu/kernel_exec-hostfs.obj `if test -f 'kern/emu/hostfs.c'; then $(CYGPATH_W) 'kern/emu/hostfs.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/hostfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-hostfs.Tpo kern/emu/$(DEPDIR)/kernel_exec-hostfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/hostfs.c' object='kern/emu/kernel_exec-hostfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-hostfs.obj `if test -f 'kern/emu/hostfs.c'; then $(CYGPATH_W) 'kern/emu/hostfs.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/hostfs.c'; fi`
+
+kern/emu/kernel_exec-main.o: kern/emu/main.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-main.o -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-main.Tpo -c -o kern/emu/kernel_exec-main.o `test -f 'kern/emu/main.c' || echo '$(srcdir)/'`kern/emu/main.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-main.Tpo kern/emu/$(DEPDIR)/kernel_exec-main.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/main.c' object='kern/emu/kernel_exec-main.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-main.o `test -f 'kern/emu/main.c' || echo '$(srcdir)/'`kern/emu/main.c
+
+kern/emu/kernel_exec-main.obj: kern/emu/main.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-main.obj -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-main.Tpo -c -o kern/emu/kernel_exec-main.obj `if test -f 'kern/emu/main.c'; then $(CYGPATH_W) 'kern/emu/main.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/main.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-main.Tpo kern/emu/$(DEPDIR)/kernel_exec-main.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/main.c' object='kern/emu/kernel_exec-main.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-main.obj `if test -f 'kern/emu/main.c'; then $(CYGPATH_W) 'kern/emu/main.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/main.c'; fi`
+
+kern/emu/kernel_exec-argp_common.o: kern/emu/argp_common.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-argp_common.o -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-argp_common.Tpo -c -o kern/emu/kernel_exec-argp_common.o `test -f 'kern/emu/argp_common.c' || echo '$(srcdir)/'`kern/emu/argp_common.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-argp_common.Tpo kern/emu/$(DEPDIR)/kernel_exec-argp_common.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/argp_common.c' object='kern/emu/kernel_exec-argp_common.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-argp_common.o `test -f 'kern/emu/argp_common.c' || echo '$(srcdir)/'`kern/emu/argp_common.c
+
+kern/emu/kernel_exec-argp_common.obj: kern/emu/argp_common.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-argp_common.obj -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-argp_common.Tpo -c -o kern/emu/kernel_exec-argp_common.obj `if test -f 'kern/emu/argp_common.c'; then $(CYGPATH_W) 'kern/emu/argp_common.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/argp_common.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-argp_common.Tpo kern/emu/$(DEPDIR)/kernel_exec-argp_common.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/argp_common.c' object='kern/emu/kernel_exec-argp_common.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-argp_common.obj `if test -f 'kern/emu/argp_common.c'; then $(CYGPATH_W) 'kern/emu/argp_common.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/argp_common.c'; fi`
+
+kern/emu/kernel_exec-misc.o: kern/emu/misc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-misc.o -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-misc.Tpo -c -o kern/emu/kernel_exec-misc.o `test -f 'kern/emu/misc.c' || echo '$(srcdir)/'`kern/emu/misc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-misc.Tpo kern/emu/$(DEPDIR)/kernel_exec-misc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/misc.c' object='kern/emu/kernel_exec-misc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-misc.o `test -f 'kern/emu/misc.c' || echo '$(srcdir)/'`kern/emu/misc.c
+
+kern/emu/kernel_exec-misc.obj: kern/emu/misc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-misc.obj -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-misc.Tpo -c -o kern/emu/kernel_exec-misc.obj `if test -f 'kern/emu/misc.c'; then $(CYGPATH_W) 'kern/emu/misc.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/misc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-misc.Tpo kern/emu/$(DEPDIR)/kernel_exec-misc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/misc.c' object='kern/emu/kernel_exec-misc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-misc.obj `if test -f 'kern/emu/misc.c'; then $(CYGPATH_W) 'kern/emu/misc.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/misc.c'; fi`
+
+kern/emu/kernel_exec-mm.o: kern/emu/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-mm.o -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-mm.Tpo -c -o kern/emu/kernel_exec-mm.o `test -f 'kern/emu/mm.c' || echo '$(srcdir)/'`kern/emu/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-mm.Tpo kern/emu/$(DEPDIR)/kernel_exec-mm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/mm.c' object='kern/emu/kernel_exec-mm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-mm.o `test -f 'kern/emu/mm.c' || echo '$(srcdir)/'`kern/emu/mm.c
+
+kern/emu/kernel_exec-mm.obj: kern/emu/mm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-mm.obj -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-mm.Tpo -c -o kern/emu/kernel_exec-mm.obj `if test -f 'kern/emu/mm.c'; then $(CYGPATH_W) 'kern/emu/mm.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/mm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-mm.Tpo kern/emu/$(DEPDIR)/kernel_exec-mm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/mm.c' object='kern/emu/kernel_exec-mm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-mm.obj `if test -f 'kern/emu/mm.c'; then $(CYGPATH_W) 'kern/emu/mm.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/mm.c'; fi`
+
+kern/emu/kernel_exec-time.o: kern/emu/time.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-time.o -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-time.Tpo -c -o kern/emu/kernel_exec-time.o `test -f 'kern/emu/time.c' || echo '$(srcdir)/'`kern/emu/time.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-time.Tpo kern/emu/$(DEPDIR)/kernel_exec-time.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/time.c' object='kern/emu/kernel_exec-time.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-time.o `test -f 'kern/emu/time.c' || echo '$(srcdir)/'`kern/emu/time.c
+
+kern/emu/kernel_exec-time.obj: kern/emu/time.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-time.obj -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-time.Tpo -c -o kern/emu/kernel_exec-time.obj `if test -f 'kern/emu/time.c'; then $(CYGPATH_W) 'kern/emu/time.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/time.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-time.Tpo kern/emu/$(DEPDIR)/kernel_exec-time.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/time.c' object='kern/emu/kernel_exec-time.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-time.obj `if test -f 'kern/emu/time.c'; then $(CYGPATH_W) 'kern/emu/time.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/time.c'; fi`
+
+kern/emu/kernel_exec-cache.o: kern/emu/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-cache.o -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/emu/kernel_exec-cache.o `test -f 'kern/emu/cache.c' || echo '$(srcdir)/'`kern/emu/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-cache.Tpo kern/emu/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/cache.c' object='kern/emu/kernel_exec-cache.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-cache.o `test -f 'kern/emu/cache.c' || echo '$(srcdir)/'`kern/emu/cache.c
+
+kern/emu/kernel_exec-cache.obj: kern/emu/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/emu/kernel_exec-cache.obj -MD -MP -MF kern/emu/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/emu/kernel_exec-cache.obj `if test -f 'kern/emu/cache.c'; then $(CYGPATH_W) 'kern/emu/cache.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/cache.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/emu/$(DEPDIR)/kernel_exec-cache.Tpo kern/emu/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/emu/cache.c' object='kern/emu/kernel_exec-cache.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/emu/kernel_exec-cache.obj `if test -f 'kern/emu/cache.c'; then $(CYGPATH_W) 'kern/emu/cache.c'; else $(CYGPATH_W) '$(srcdir)/kern/emu/cache.c'; fi`
+
+osdep/kernel_exec-emuconsole.o: osdep/emuconsole.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-emuconsole.o -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-emuconsole.Tpo -c -o osdep/kernel_exec-emuconsole.o `test -f 'osdep/emuconsole.c' || echo '$(srcdir)/'`osdep/emuconsole.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-emuconsole.Tpo osdep/$(DEPDIR)/kernel_exec-emuconsole.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/emuconsole.c' object='osdep/kernel_exec-emuconsole.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-emuconsole.o `test -f 'osdep/emuconsole.c' || echo '$(srcdir)/'`osdep/emuconsole.c
+
+osdep/kernel_exec-emuconsole.obj: osdep/emuconsole.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-emuconsole.obj -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-emuconsole.Tpo -c -o osdep/kernel_exec-emuconsole.obj `if test -f 'osdep/emuconsole.c'; then $(CYGPATH_W) 'osdep/emuconsole.c'; else $(CYGPATH_W) '$(srcdir)/osdep/emuconsole.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-emuconsole.Tpo osdep/$(DEPDIR)/kernel_exec-emuconsole.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/emuconsole.c' object='osdep/kernel_exec-emuconsole.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-emuconsole.obj `if test -f 'osdep/emuconsole.c'; then $(CYGPATH_W) 'osdep/emuconsole.c'; else $(CYGPATH_W) '$(srcdir)/osdep/emuconsole.c'; fi`
+
+osdep/kernel_exec-dl.o: osdep/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-dl.o -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-dl.Tpo -c -o osdep/kernel_exec-dl.o `test -f 'osdep/dl.c' || echo '$(srcdir)/'`osdep/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-dl.Tpo osdep/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/dl.c' object='osdep/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-dl.o `test -f 'osdep/dl.c' || echo '$(srcdir)/'`osdep/dl.c
+
+osdep/kernel_exec-dl.obj: osdep/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-dl.obj -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-dl.Tpo -c -o osdep/kernel_exec-dl.obj `if test -f 'osdep/dl.c'; then $(CYGPATH_W) 'osdep/dl.c'; else $(CYGPATH_W) '$(srcdir)/osdep/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-dl.Tpo osdep/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/dl.c' object='osdep/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-dl.obj `if test -f 'osdep/dl.c'; then $(CYGPATH_W) 'osdep/dl.c'; else $(CYGPATH_W) '$(srcdir)/osdep/dl.c'; fi`
+
+osdep/kernel_exec-sleep.o: osdep/sleep.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-sleep.o -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-sleep.Tpo -c -o osdep/kernel_exec-sleep.o `test -f 'osdep/sleep.c' || echo '$(srcdir)/'`osdep/sleep.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-sleep.Tpo osdep/$(DEPDIR)/kernel_exec-sleep.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/sleep.c' object='osdep/kernel_exec-sleep.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-sleep.o `test -f 'osdep/sleep.c' || echo '$(srcdir)/'`osdep/sleep.c
+
+osdep/kernel_exec-sleep.obj: osdep/sleep.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-sleep.obj -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-sleep.Tpo -c -o osdep/kernel_exec-sleep.obj `if test -f 'osdep/sleep.c'; then $(CYGPATH_W) 'osdep/sleep.c'; else $(CYGPATH_W) '$(srcdir)/osdep/sleep.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-sleep.Tpo osdep/$(DEPDIR)/kernel_exec-sleep.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/sleep.c' object='osdep/kernel_exec-sleep.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-sleep.obj `if test -f 'osdep/sleep.c'; then $(CYGPATH_W) 'osdep/sleep.c'; else $(CYGPATH_W) '$(srcdir)/osdep/sleep.c'; fi`
+
+osdep/kernel_exec-init.o: osdep/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-init.o -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-init.Tpo -c -o osdep/kernel_exec-init.o `test -f 'osdep/init.c' || echo '$(srcdir)/'`osdep/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-init.Tpo osdep/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/init.c' object='osdep/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-init.o `test -f 'osdep/init.c' || echo '$(srcdir)/'`osdep/init.c
+
+osdep/kernel_exec-init.obj: osdep/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-init.obj -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-init.Tpo -c -o osdep/kernel_exec-init.obj `if test -f 'osdep/init.c'; then $(CYGPATH_W) 'osdep/init.c'; else $(CYGPATH_W) '$(srcdir)/osdep/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-init.Tpo osdep/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/init.c' object='osdep/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-init.obj `if test -f 'osdep/init.c'; then $(CYGPATH_W) 'osdep/init.c'; else $(CYGPATH_W) '$(srcdir)/osdep/init.c'; fi`
+
+osdep/kernel_exec-emunet.o: osdep/emunet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-emunet.o -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-emunet.Tpo -c -o osdep/kernel_exec-emunet.o `test -f 'osdep/emunet.c' || echo '$(srcdir)/'`osdep/emunet.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-emunet.Tpo osdep/$(DEPDIR)/kernel_exec-emunet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/emunet.c' object='osdep/kernel_exec-emunet.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-emunet.o `test -f 'osdep/emunet.c' || echo '$(srcdir)/'`osdep/emunet.c
+
+osdep/kernel_exec-emunet.obj: osdep/emunet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-emunet.obj -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-emunet.Tpo -c -o osdep/kernel_exec-emunet.obj `if test -f 'osdep/emunet.c'; then $(CYGPATH_W) 'osdep/emunet.c'; else $(CYGPATH_W) '$(srcdir)/osdep/emunet.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-emunet.Tpo osdep/$(DEPDIR)/kernel_exec-emunet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/emunet.c' object='osdep/kernel_exec-emunet.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-emunet.obj `if test -f 'osdep/emunet.c'; then $(CYGPATH_W) 'osdep/emunet.c'; else $(CYGPATH_W) '$(srcdir)/osdep/emunet.c'; fi`
+
+osdep/kernel_exec-cputime.o: osdep/cputime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-cputime.o -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-cputime.Tpo -c -o osdep/kernel_exec-cputime.o `test -f 'osdep/cputime.c' || echo '$(srcdir)/'`osdep/cputime.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-cputime.Tpo osdep/$(DEPDIR)/kernel_exec-cputime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/cputime.c' object='osdep/kernel_exec-cputime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-cputime.o `test -f 'osdep/cputime.c' || echo '$(srcdir)/'`osdep/cputime.c
+
+osdep/kernel_exec-cputime.obj: osdep/cputime.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT osdep/kernel_exec-cputime.obj -MD -MP -MF osdep/$(DEPDIR)/kernel_exec-cputime.Tpo -c -o osdep/kernel_exec-cputime.obj `if test -f 'osdep/cputime.c'; then $(CYGPATH_W) 'osdep/cputime.c'; else $(CYGPATH_W) '$(srcdir)/osdep/cputime.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) osdep/$(DEPDIR)/kernel_exec-cputime.Tpo osdep/$(DEPDIR)/kernel_exec-cputime.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='osdep/cputime.c' object='osdep/kernel_exec-cputime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o osdep/kernel_exec-cputime.obj `if test -f 'osdep/cputime.c'; then $(CYGPATH_W) 'osdep/cputime.c'; else $(CYGPATH_W) '$(srcdir)/osdep/cputime.c'; fi`
+
+kern/i386/coreboot/kernel_exec-init.o: kern/i386/coreboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/coreboot/kernel_exec-init.o -MD -MP -MF kern/i386/coreboot/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/i386/coreboot/kernel_exec-init.o `test -f 'kern/i386/coreboot/init.c' || echo '$(srcdir)/'`kern/i386/coreboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/coreboot/$(DEPDIR)/kernel_exec-init.Tpo kern/i386/coreboot/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/coreboot/init.c' object='kern/i386/coreboot/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/coreboot/kernel_exec-init.o `test -f 'kern/i386/coreboot/init.c' || echo '$(srcdir)/'`kern/i386/coreboot/init.c
+
+kern/i386/coreboot/kernel_exec-init.obj: kern/i386/coreboot/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/coreboot/kernel_exec-init.obj -MD -MP -MF kern/i386/coreboot/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/i386/coreboot/kernel_exec-init.obj `if test -f 'kern/i386/coreboot/init.c'; then $(CYGPATH_W) 'kern/i386/coreboot/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/coreboot/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/coreboot/$(DEPDIR)/kernel_exec-init.Tpo kern/i386/coreboot/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/coreboot/init.c' object='kern/i386/coreboot/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/coreboot/kernel_exec-init.obj `if test -f 'kern/i386/coreboot/init.c'; then $(CYGPATH_W) 'kern/i386/coreboot/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/coreboot/init.c'; fi`
+
+kern/i386/pc/kernel_exec-acpi.o: kern/i386/pc/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/pc/kernel_exec-acpi.o -MD -MP -MF kern/i386/pc/$(DEPDIR)/kernel_exec-acpi.Tpo -c -o kern/i386/pc/kernel_exec-acpi.o `test -f 'kern/i386/pc/acpi.c' || echo '$(srcdir)/'`kern/i386/pc/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/pc/$(DEPDIR)/kernel_exec-acpi.Tpo kern/i386/pc/$(DEPDIR)/kernel_exec-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/pc/acpi.c' object='kern/i386/pc/kernel_exec-acpi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/pc/kernel_exec-acpi.o `test -f 'kern/i386/pc/acpi.c' || echo '$(srcdir)/'`kern/i386/pc/acpi.c
+
+kern/i386/pc/kernel_exec-acpi.obj: kern/i386/pc/acpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/pc/kernel_exec-acpi.obj -MD -MP -MF kern/i386/pc/$(DEPDIR)/kernel_exec-acpi.Tpo -c -o kern/i386/pc/kernel_exec-acpi.obj `if test -f 'kern/i386/pc/acpi.c'; then $(CYGPATH_W) 'kern/i386/pc/acpi.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/pc/acpi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/pc/$(DEPDIR)/kernel_exec-acpi.Tpo kern/i386/pc/$(DEPDIR)/kernel_exec-acpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/pc/acpi.c' object='kern/i386/pc/kernel_exec-acpi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/pc/kernel_exec-acpi.obj `if test -f 'kern/i386/pc/acpi.c'; then $(CYGPATH_W) 'kern/i386/pc/acpi.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/pc/acpi.c'; fi`
+
+kern/i386/kernel_exec-tsc_pmtimer.o: kern/i386/tsc_pmtimer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/kernel_exec-tsc_pmtimer.o -MD -MP -MF kern/i386/$(DEPDIR)/kernel_exec-tsc_pmtimer.Tpo -c -o kern/i386/kernel_exec-tsc_pmtimer.o `test -f 'kern/i386/tsc_pmtimer.c' || echo '$(srcdir)/'`kern/i386/tsc_pmtimer.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/kernel_exec-tsc_pmtimer.Tpo kern/i386/$(DEPDIR)/kernel_exec-tsc_pmtimer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/tsc_pmtimer.c' object='kern/i386/kernel_exec-tsc_pmtimer.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/kernel_exec-tsc_pmtimer.o `test -f 'kern/i386/tsc_pmtimer.c' || echo '$(srcdir)/'`kern/i386/tsc_pmtimer.c
+
+kern/i386/kernel_exec-tsc_pmtimer.obj: kern/i386/tsc_pmtimer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/kernel_exec-tsc_pmtimer.obj -MD -MP -MF kern/i386/$(DEPDIR)/kernel_exec-tsc_pmtimer.Tpo -c -o kern/i386/kernel_exec-tsc_pmtimer.obj `if test -f 'kern/i386/tsc_pmtimer.c'; then $(CYGPATH_W) 'kern/i386/tsc_pmtimer.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/tsc_pmtimer.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/kernel_exec-tsc_pmtimer.Tpo kern/i386/$(DEPDIR)/kernel_exec-tsc_pmtimer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/tsc_pmtimer.c' object='kern/i386/kernel_exec-tsc_pmtimer.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/kernel_exec-tsc_pmtimer.obj `if test -f 'kern/i386/tsc_pmtimer.c'; then $(CYGPATH_W) 'kern/i386/tsc_pmtimer.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/tsc_pmtimer.c'; fi`
+
+kern/i386/coreboot/kernel_exec-cbtable.o: kern/i386/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/coreboot/kernel_exec-cbtable.o -MD -MP -MF kern/i386/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo -c -o kern/i386/coreboot/kernel_exec-cbtable.o `test -f 'kern/i386/coreboot/cbtable.c' || echo '$(srcdir)/'`kern/i386/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo kern/i386/coreboot/$(DEPDIR)/kernel_exec-cbtable.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/coreboot/cbtable.c' object='kern/i386/coreboot/kernel_exec-cbtable.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/coreboot/kernel_exec-cbtable.o `test -f 'kern/i386/coreboot/cbtable.c' || echo '$(srcdir)/'`kern/i386/coreboot/cbtable.c
+
+kern/i386/coreboot/kernel_exec-cbtable.obj: kern/i386/coreboot/cbtable.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/coreboot/kernel_exec-cbtable.obj -MD -MP -MF kern/i386/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo -c -o kern/i386/coreboot/kernel_exec-cbtable.obj `if test -f 'kern/i386/coreboot/cbtable.c'; then $(CYGPATH_W) 'kern/i386/coreboot/cbtable.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/coreboot/cbtable.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/coreboot/$(DEPDIR)/kernel_exec-cbtable.Tpo kern/i386/coreboot/$(DEPDIR)/kernel_exec-cbtable.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/coreboot/cbtable.c' object='kern/i386/coreboot/kernel_exec-cbtable.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/coreboot/kernel_exec-cbtable.obj `if test -f 'kern/i386/coreboot/cbtable.c'; then $(CYGPATH_W) 'kern/i386/coreboot/cbtable.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/coreboot/cbtable.c'; fi`
+
+term/i386/pc/kernel_exec-vga_text.o: term/i386/pc/vga_text.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/i386/pc/kernel_exec-vga_text.o -MD -MP -MF term/i386/pc/$(DEPDIR)/kernel_exec-vga_text.Tpo -c -o term/i386/pc/kernel_exec-vga_text.o `test -f 'term/i386/pc/vga_text.c' || echo '$(srcdir)/'`term/i386/pc/vga_text.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/i386/pc/$(DEPDIR)/kernel_exec-vga_text.Tpo term/i386/pc/$(DEPDIR)/kernel_exec-vga_text.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/i386/pc/vga_text.c' object='term/i386/pc/kernel_exec-vga_text.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/i386/pc/kernel_exec-vga_text.o `test -f 'term/i386/pc/vga_text.c' || echo '$(srcdir)/'`term/i386/pc/vga_text.c
+
+term/i386/pc/kernel_exec-vga_text.obj: term/i386/pc/vga_text.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/i386/pc/kernel_exec-vga_text.obj -MD -MP -MF term/i386/pc/$(DEPDIR)/kernel_exec-vga_text.Tpo -c -o term/i386/pc/kernel_exec-vga_text.obj `if test -f 'term/i386/pc/vga_text.c'; then $(CYGPATH_W) 'term/i386/pc/vga_text.c'; else $(CYGPATH_W) '$(srcdir)/term/i386/pc/vga_text.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/i386/pc/$(DEPDIR)/kernel_exec-vga_text.Tpo term/i386/pc/$(DEPDIR)/kernel_exec-vga_text.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/i386/pc/vga_text.c' object='term/i386/pc/kernel_exec-vga_text.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/i386/pc/kernel_exec-vga_text.obj `if test -f 'term/i386/pc/vga_text.c'; then $(CYGPATH_W) 'term/i386/pc/vga_text.c'; else $(CYGPATH_W) '$(srcdir)/term/i386/pc/vga_text.c'; fi`
+
+kern/i386/kernel_exec-dl.o: kern/i386/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/kernel_exec-dl.o -MD -MP -MF kern/i386/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/i386/kernel_exec-dl.o `test -f 'kern/i386/dl.c' || echo '$(srcdir)/'`kern/i386/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/kernel_exec-dl.Tpo kern/i386/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/dl.c' object='kern/i386/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/kernel_exec-dl.o `test -f 'kern/i386/dl.c' || echo '$(srcdir)/'`kern/i386/dl.c
+
+kern/i386/kernel_exec-dl.obj: kern/i386/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/kernel_exec-dl.obj -MD -MP -MF kern/i386/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/i386/kernel_exec-dl.obj `if test -f 'kern/i386/dl.c'; then $(CYGPATH_W) 'kern/i386/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/kernel_exec-dl.Tpo kern/i386/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/dl.c' object='kern/i386/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/kernel_exec-dl.obj `if test -f 'kern/i386/dl.c'; then $(CYGPATH_W) 'kern/i386/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/dl.c'; fi`
+
+kern/i386/kernel_exec-tsc.o: kern/i386/tsc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/kernel_exec-tsc.o -MD -MP -MF kern/i386/$(DEPDIR)/kernel_exec-tsc.Tpo -c -o kern/i386/kernel_exec-tsc.o `test -f 'kern/i386/tsc.c' || echo '$(srcdir)/'`kern/i386/tsc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/kernel_exec-tsc.Tpo kern/i386/$(DEPDIR)/kernel_exec-tsc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/tsc.c' object='kern/i386/kernel_exec-tsc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/kernel_exec-tsc.o `test -f 'kern/i386/tsc.c' || echo '$(srcdir)/'`kern/i386/tsc.c
+
+kern/i386/kernel_exec-tsc.obj: kern/i386/tsc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/kernel_exec-tsc.obj -MD -MP -MF kern/i386/$(DEPDIR)/kernel_exec-tsc.Tpo -c -o kern/i386/kernel_exec-tsc.obj `if test -f 'kern/i386/tsc.c'; then $(CYGPATH_W) 'kern/i386/tsc.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/tsc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/kernel_exec-tsc.Tpo kern/i386/$(DEPDIR)/kernel_exec-tsc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/tsc.c' object='kern/i386/kernel_exec-tsc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/kernel_exec-tsc.obj `if test -f 'kern/i386/tsc.c'; then $(CYGPATH_W) 'kern/i386/tsc.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/tsc.c'; fi`
+
+kern/i386/kernel_exec-tsc_pit.o: kern/i386/tsc_pit.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/kernel_exec-tsc_pit.o -MD -MP -MF kern/i386/$(DEPDIR)/kernel_exec-tsc_pit.Tpo -c -o kern/i386/kernel_exec-tsc_pit.o `test -f 'kern/i386/tsc_pit.c' || echo '$(srcdir)/'`kern/i386/tsc_pit.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/kernel_exec-tsc_pit.Tpo kern/i386/$(DEPDIR)/kernel_exec-tsc_pit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/tsc_pit.c' object='kern/i386/kernel_exec-tsc_pit.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/kernel_exec-tsc_pit.o `test -f 'kern/i386/tsc_pit.c' || echo '$(srcdir)/'`kern/i386/tsc_pit.c
+
+kern/i386/kernel_exec-tsc_pit.obj: kern/i386/tsc_pit.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/kernel_exec-tsc_pit.obj -MD -MP -MF kern/i386/$(DEPDIR)/kernel_exec-tsc_pit.Tpo -c -o kern/i386/kernel_exec-tsc_pit.obj `if test -f 'kern/i386/tsc_pit.c'; then $(CYGPATH_W) 'kern/i386/tsc_pit.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/tsc_pit.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/kernel_exec-tsc_pit.Tpo kern/i386/$(DEPDIR)/kernel_exec-tsc_pit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/tsc_pit.c' object='kern/i386/kernel_exec-tsc_pit.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/kernel_exec-tsc_pit.obj `if test -f 'kern/i386/tsc_pit.c'; then $(CYGPATH_W) 'kern/i386/tsc_pit.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/tsc_pit.c'; fi`
+
+kern/i386/efi/kernel_exec-tsc.o: kern/i386/efi/tsc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/efi/kernel_exec-tsc.o -MD -MP -MF kern/i386/efi/$(DEPDIR)/kernel_exec-tsc.Tpo -c -o kern/i386/efi/kernel_exec-tsc.o `test -f 'kern/i386/efi/tsc.c' || echo '$(srcdir)/'`kern/i386/efi/tsc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/efi/$(DEPDIR)/kernel_exec-tsc.Tpo kern/i386/efi/$(DEPDIR)/kernel_exec-tsc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/efi/tsc.c' object='kern/i386/efi/kernel_exec-tsc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/efi/kernel_exec-tsc.o `test -f 'kern/i386/efi/tsc.c' || echo '$(srcdir)/'`kern/i386/efi/tsc.c
+
+kern/i386/efi/kernel_exec-tsc.obj: kern/i386/efi/tsc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/efi/kernel_exec-tsc.obj -MD -MP -MF kern/i386/efi/$(DEPDIR)/kernel_exec-tsc.Tpo -c -o kern/i386/efi/kernel_exec-tsc.obj `if test -f 'kern/i386/efi/tsc.c'; then $(CYGPATH_W) 'kern/i386/efi/tsc.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/efi/tsc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/efi/$(DEPDIR)/kernel_exec-tsc.Tpo kern/i386/efi/$(DEPDIR)/kernel_exec-tsc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/efi/tsc.c' object='kern/i386/efi/kernel_exec-tsc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/efi/kernel_exec-tsc.obj `if test -f 'kern/i386/efi/tsc.c'; then $(CYGPATH_W) 'kern/i386/efi/tsc.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/efi/tsc.c'; fi`
+
+kern/i386/efi/kernel_exec-init.o: kern/i386/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/efi/kernel_exec-init.o -MD -MP -MF kern/i386/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/i386/efi/kernel_exec-init.o `test -f 'kern/i386/efi/init.c' || echo '$(srcdir)/'`kern/i386/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/i386/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/efi/init.c' object='kern/i386/efi/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/efi/kernel_exec-init.o `test -f 'kern/i386/efi/init.c' || echo '$(srcdir)/'`kern/i386/efi/init.c
+
+kern/i386/efi/kernel_exec-init.obj: kern/i386/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/efi/kernel_exec-init.obj -MD -MP -MF kern/i386/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/i386/efi/kernel_exec-init.obj `if test -f 'kern/i386/efi/init.c'; then $(CYGPATH_W) 'kern/i386/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/efi/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/i386/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/efi/init.c' object='kern/i386/efi/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/efi/kernel_exec-init.obj `if test -f 'kern/i386/efi/init.c'; then $(CYGPATH_W) 'kern/i386/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/efi/init.c'; fi`
+
+bus/kernel_exec-pci.o: bus/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT bus/kernel_exec-pci.o -MD -MP -MF bus/$(DEPDIR)/kernel_exec-pci.Tpo -c -o bus/kernel_exec-pci.o `test -f 'bus/pci.c' || echo '$(srcdir)/'`bus/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/kernel_exec-pci.Tpo bus/$(DEPDIR)/kernel_exec-pci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/pci.c' object='bus/kernel_exec-pci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o bus/kernel_exec-pci.o `test -f 'bus/pci.c' || echo '$(srcdir)/'`bus/pci.c
+
+bus/kernel_exec-pci.obj: bus/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT bus/kernel_exec-pci.obj -MD -MP -MF bus/$(DEPDIR)/kernel_exec-pci.Tpo -c -o bus/kernel_exec-pci.obj `if test -f 'bus/pci.c'; then $(CYGPATH_W) 'bus/pci.c'; else $(CYGPATH_W) '$(srcdir)/bus/pci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/kernel_exec-pci.Tpo bus/$(DEPDIR)/kernel_exec-pci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/pci.c' object='bus/kernel_exec-pci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o bus/kernel_exec-pci.obj `if test -f 'bus/pci.c'; then $(CYGPATH_W) 'bus/pci.c'; else $(CYGPATH_W) '$(srcdir)/bus/pci.c'; fi`
+
+disk/ieee1275/kernel_exec-ofdisk.o: disk/ieee1275/ofdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/ieee1275/kernel_exec-ofdisk.o -MD -MP -MF disk/ieee1275/$(DEPDIR)/kernel_exec-ofdisk.Tpo -c -o disk/ieee1275/kernel_exec-ofdisk.o `test -f 'disk/ieee1275/ofdisk.c' || echo '$(srcdir)/'`disk/ieee1275/ofdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/ieee1275/$(DEPDIR)/kernel_exec-ofdisk.Tpo disk/ieee1275/$(DEPDIR)/kernel_exec-ofdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ieee1275/ofdisk.c' object='disk/ieee1275/kernel_exec-ofdisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/ieee1275/kernel_exec-ofdisk.o `test -f 'disk/ieee1275/ofdisk.c' || echo '$(srcdir)/'`disk/ieee1275/ofdisk.c
+
+disk/ieee1275/kernel_exec-ofdisk.obj: disk/ieee1275/ofdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/ieee1275/kernel_exec-ofdisk.obj -MD -MP -MF disk/ieee1275/$(DEPDIR)/kernel_exec-ofdisk.Tpo -c -o disk/ieee1275/kernel_exec-ofdisk.obj `if test -f 'disk/ieee1275/ofdisk.c'; then $(CYGPATH_W) 'disk/ieee1275/ofdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/ieee1275/ofdisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/ieee1275/$(DEPDIR)/kernel_exec-ofdisk.Tpo disk/ieee1275/$(DEPDIR)/kernel_exec-ofdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ieee1275/ofdisk.c' object='disk/ieee1275/kernel_exec-ofdisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/ieee1275/kernel_exec-ofdisk.obj `if test -f 'disk/ieee1275/ofdisk.c'; then $(CYGPATH_W) 'disk/ieee1275/ofdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/ieee1275/ofdisk.c'; fi`
+
+kern/ieee1275/kernel_exec-cmain.o: kern/ieee1275/cmain.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ieee1275/kernel_exec-cmain.o -MD -MP -MF kern/ieee1275/$(DEPDIR)/kernel_exec-cmain.Tpo -c -o kern/ieee1275/kernel_exec-cmain.o `test -f 'kern/ieee1275/cmain.c' || echo '$(srcdir)/'`kern/ieee1275/cmain.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ieee1275/$(DEPDIR)/kernel_exec-cmain.Tpo kern/ieee1275/$(DEPDIR)/kernel_exec-cmain.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ieee1275/cmain.c' object='kern/ieee1275/kernel_exec-cmain.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ieee1275/kernel_exec-cmain.o `test -f 'kern/ieee1275/cmain.c' || echo '$(srcdir)/'`kern/ieee1275/cmain.c
+
+kern/ieee1275/kernel_exec-cmain.obj: kern/ieee1275/cmain.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ieee1275/kernel_exec-cmain.obj -MD -MP -MF kern/ieee1275/$(DEPDIR)/kernel_exec-cmain.Tpo -c -o kern/ieee1275/kernel_exec-cmain.obj `if test -f 'kern/ieee1275/cmain.c'; then $(CYGPATH_W) 'kern/ieee1275/cmain.c'; else $(CYGPATH_W) '$(srcdir)/kern/ieee1275/cmain.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ieee1275/$(DEPDIR)/kernel_exec-cmain.Tpo kern/ieee1275/$(DEPDIR)/kernel_exec-cmain.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ieee1275/cmain.c' object='kern/ieee1275/kernel_exec-cmain.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ieee1275/kernel_exec-cmain.obj `if test -f 'kern/ieee1275/cmain.c'; then $(CYGPATH_W) 'kern/ieee1275/cmain.c'; else $(CYGPATH_W) '$(srcdir)/kern/ieee1275/cmain.c'; fi`
+
+kern/ieee1275/kernel_exec-ieee1275.o: kern/ieee1275/ieee1275.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ieee1275/kernel_exec-ieee1275.o -MD -MP -MF kern/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Tpo -c -o kern/ieee1275/kernel_exec-ieee1275.o `test -f 'kern/ieee1275/ieee1275.c' || echo '$(srcdir)/'`kern/ieee1275/ieee1275.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Tpo kern/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ieee1275/ieee1275.c' object='kern/ieee1275/kernel_exec-ieee1275.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ieee1275/kernel_exec-ieee1275.o `test -f 'kern/ieee1275/ieee1275.c' || echo '$(srcdir)/'`kern/ieee1275/ieee1275.c
+
+kern/ieee1275/kernel_exec-ieee1275.obj: kern/ieee1275/ieee1275.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ieee1275/kernel_exec-ieee1275.obj -MD -MP -MF kern/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Tpo -c -o kern/ieee1275/kernel_exec-ieee1275.obj `if test -f 'kern/ieee1275/ieee1275.c'; then $(CYGPATH_W) 'kern/ieee1275/ieee1275.c'; else $(CYGPATH_W) '$(srcdir)/kern/ieee1275/ieee1275.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Tpo kern/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ieee1275/ieee1275.c' object='kern/ieee1275/kernel_exec-ieee1275.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ieee1275/kernel_exec-ieee1275.obj `if test -f 'kern/ieee1275/ieee1275.c'; then $(CYGPATH_W) 'kern/ieee1275/ieee1275.c'; else $(CYGPATH_W) '$(srcdir)/kern/ieee1275/ieee1275.c'; fi`
+
+kern/ieee1275/kernel_exec-mmap.o: kern/ieee1275/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ieee1275/kernel_exec-mmap.o -MD -MP -MF kern/ieee1275/$(DEPDIR)/kernel_exec-mmap.Tpo -c -o kern/ieee1275/kernel_exec-mmap.o `test -f 'kern/ieee1275/mmap.c' || echo '$(srcdir)/'`kern/ieee1275/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ieee1275/$(DEPDIR)/kernel_exec-mmap.Tpo kern/ieee1275/$(DEPDIR)/kernel_exec-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ieee1275/mmap.c' object='kern/ieee1275/kernel_exec-mmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ieee1275/kernel_exec-mmap.o `test -f 'kern/ieee1275/mmap.c' || echo '$(srcdir)/'`kern/ieee1275/mmap.c
+
+kern/ieee1275/kernel_exec-mmap.obj: kern/ieee1275/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ieee1275/kernel_exec-mmap.obj -MD -MP -MF kern/ieee1275/$(DEPDIR)/kernel_exec-mmap.Tpo -c -o kern/ieee1275/kernel_exec-mmap.obj `if test -f 'kern/ieee1275/mmap.c'; then $(CYGPATH_W) 'kern/ieee1275/mmap.c'; else $(CYGPATH_W) '$(srcdir)/kern/ieee1275/mmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ieee1275/$(DEPDIR)/kernel_exec-mmap.Tpo kern/ieee1275/$(DEPDIR)/kernel_exec-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ieee1275/mmap.c' object='kern/ieee1275/kernel_exec-mmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ieee1275/kernel_exec-mmap.obj `if test -f 'kern/ieee1275/mmap.c'; then $(CYGPATH_W) 'kern/ieee1275/mmap.c'; else $(CYGPATH_W) '$(srcdir)/kern/ieee1275/mmap.c'; fi`
+
+kern/ieee1275/kernel_exec-openfw.o: kern/ieee1275/openfw.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ieee1275/kernel_exec-openfw.o -MD -MP -MF kern/ieee1275/$(DEPDIR)/kernel_exec-openfw.Tpo -c -o kern/ieee1275/kernel_exec-openfw.o `test -f 'kern/ieee1275/openfw.c' || echo '$(srcdir)/'`kern/ieee1275/openfw.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ieee1275/$(DEPDIR)/kernel_exec-openfw.Tpo kern/ieee1275/$(DEPDIR)/kernel_exec-openfw.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ieee1275/openfw.c' object='kern/ieee1275/kernel_exec-openfw.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ieee1275/kernel_exec-openfw.o `test -f 'kern/ieee1275/openfw.c' || echo '$(srcdir)/'`kern/ieee1275/openfw.c
+
+kern/ieee1275/kernel_exec-openfw.obj: kern/ieee1275/openfw.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ieee1275/kernel_exec-openfw.obj -MD -MP -MF kern/ieee1275/$(DEPDIR)/kernel_exec-openfw.Tpo -c -o kern/ieee1275/kernel_exec-openfw.obj `if test -f 'kern/ieee1275/openfw.c'; then $(CYGPATH_W) 'kern/ieee1275/openfw.c'; else $(CYGPATH_W) '$(srcdir)/kern/ieee1275/openfw.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ieee1275/$(DEPDIR)/kernel_exec-openfw.Tpo kern/ieee1275/$(DEPDIR)/kernel_exec-openfw.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ieee1275/openfw.c' object='kern/ieee1275/kernel_exec-openfw.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ieee1275/kernel_exec-openfw.obj `if test -f 'kern/ieee1275/openfw.c'; then $(CYGPATH_W) 'kern/ieee1275/openfw.c'; else $(CYGPATH_W) '$(srcdir)/kern/ieee1275/openfw.c'; fi`
+
+term/ieee1275/kernel_exec-console.o: term/ieee1275/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/ieee1275/kernel_exec-console.o -MD -MP -MF term/ieee1275/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/ieee1275/kernel_exec-console.o `test -f 'term/ieee1275/console.c' || echo '$(srcdir)/'`term/ieee1275/console.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/ieee1275/$(DEPDIR)/kernel_exec-console.Tpo term/ieee1275/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ieee1275/console.c' object='term/ieee1275/kernel_exec-console.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/ieee1275/kernel_exec-console.o `test -f 'term/ieee1275/console.c' || echo '$(srcdir)/'`term/ieee1275/console.c
+
+term/ieee1275/kernel_exec-console.obj: term/ieee1275/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/ieee1275/kernel_exec-console.obj -MD -MP -MF term/ieee1275/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/ieee1275/kernel_exec-console.obj `if test -f 'term/ieee1275/console.c'; then $(CYGPATH_W) 'term/ieee1275/console.c'; else $(CYGPATH_W) '$(srcdir)/term/ieee1275/console.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/ieee1275/$(DEPDIR)/kernel_exec-console.Tpo term/ieee1275/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ieee1275/console.c' object='term/ieee1275/kernel_exec-console.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/ieee1275/kernel_exec-console.obj `if test -f 'term/ieee1275/console.c'; then $(CYGPATH_W) 'term/ieee1275/console.c'; else $(CYGPATH_W) '$(srcdir)/term/ieee1275/console.c'; fi`
+
+kern/ieee1275/kernel_exec-init.o: kern/ieee1275/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ieee1275/kernel_exec-init.o -MD -MP -MF kern/ieee1275/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/ieee1275/kernel_exec-init.o `test -f 'kern/ieee1275/init.c' || echo '$(srcdir)/'`kern/ieee1275/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ieee1275/$(DEPDIR)/kernel_exec-init.Tpo kern/ieee1275/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ieee1275/init.c' object='kern/ieee1275/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ieee1275/kernel_exec-init.o `test -f 'kern/ieee1275/init.c' || echo '$(srcdir)/'`kern/ieee1275/init.c
+
+kern/ieee1275/kernel_exec-init.obj: kern/ieee1275/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ieee1275/kernel_exec-init.obj -MD -MP -MF kern/ieee1275/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/ieee1275/kernel_exec-init.obj `if test -f 'kern/ieee1275/init.c'; then $(CYGPATH_W) 'kern/ieee1275/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/ieee1275/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ieee1275/$(DEPDIR)/kernel_exec-init.Tpo kern/ieee1275/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ieee1275/init.c' object='kern/ieee1275/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ieee1275/kernel_exec-init.obj `if test -f 'kern/ieee1275/init.c'; then $(CYGPATH_W) 'kern/ieee1275/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/ieee1275/init.c'; fi`
+
+kern/i386/kernel_exec-multiboot_mmap.o: kern/i386/multiboot_mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/kernel_exec-multiboot_mmap.o -MD -MP -MF kern/i386/$(DEPDIR)/kernel_exec-multiboot_mmap.Tpo -c -o kern/i386/kernel_exec-multiboot_mmap.o `test -f 'kern/i386/multiboot_mmap.c' || echo '$(srcdir)/'`kern/i386/multiboot_mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/kernel_exec-multiboot_mmap.Tpo kern/i386/$(DEPDIR)/kernel_exec-multiboot_mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/multiboot_mmap.c' object='kern/i386/kernel_exec-multiboot_mmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/kernel_exec-multiboot_mmap.o `test -f 'kern/i386/multiboot_mmap.c' || echo '$(srcdir)/'`kern/i386/multiboot_mmap.c
+
+kern/i386/kernel_exec-multiboot_mmap.obj: kern/i386/multiboot_mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/kernel_exec-multiboot_mmap.obj -MD -MP -MF kern/i386/$(DEPDIR)/kernel_exec-multiboot_mmap.Tpo -c -o kern/i386/kernel_exec-multiboot_mmap.obj `if test -f 'kern/i386/multiboot_mmap.c'; then $(CYGPATH_W) 'kern/i386/multiboot_mmap.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/multiboot_mmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/kernel_exec-multiboot_mmap.Tpo kern/i386/$(DEPDIR)/kernel_exec-multiboot_mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/multiboot_mmap.c' object='kern/i386/kernel_exec-multiboot_mmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/kernel_exec-multiboot_mmap.obj `if test -f 'kern/i386/multiboot_mmap.c'; then $(CYGPATH_W) 'kern/i386/multiboot_mmap.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/multiboot_mmap.c'; fi`
+
+kern/i386/pc/kernel_exec-init.o: kern/i386/pc/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/pc/kernel_exec-init.o -MD -MP -MF kern/i386/pc/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/i386/pc/kernel_exec-init.o `test -f 'kern/i386/pc/init.c' || echo '$(srcdir)/'`kern/i386/pc/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/pc/$(DEPDIR)/kernel_exec-init.Tpo kern/i386/pc/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/pc/init.c' object='kern/i386/pc/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/pc/kernel_exec-init.o `test -f 'kern/i386/pc/init.c' || echo '$(srcdir)/'`kern/i386/pc/init.c
+
+kern/i386/pc/kernel_exec-init.obj: kern/i386/pc/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/pc/kernel_exec-init.obj -MD -MP -MF kern/i386/pc/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/i386/pc/kernel_exec-init.obj `if test -f 'kern/i386/pc/init.c'; then $(CYGPATH_W) 'kern/i386/pc/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/pc/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/pc/$(DEPDIR)/kernel_exec-init.Tpo kern/i386/pc/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/pc/init.c' object='kern/i386/pc/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/pc/kernel_exec-init.obj `if test -f 'kern/i386/pc/init.c'; then $(CYGPATH_W) 'kern/i386/pc/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/pc/init.c'; fi`
+
+kern/i386/pc/kernel_exec-mmap.o: kern/i386/pc/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/pc/kernel_exec-mmap.o -MD -MP -MF kern/i386/pc/$(DEPDIR)/kernel_exec-mmap.Tpo -c -o kern/i386/pc/kernel_exec-mmap.o `test -f 'kern/i386/pc/mmap.c' || echo '$(srcdir)/'`kern/i386/pc/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/pc/$(DEPDIR)/kernel_exec-mmap.Tpo kern/i386/pc/$(DEPDIR)/kernel_exec-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/pc/mmap.c' object='kern/i386/pc/kernel_exec-mmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/pc/kernel_exec-mmap.o `test -f 'kern/i386/pc/mmap.c' || echo '$(srcdir)/'`kern/i386/pc/mmap.c
+
+kern/i386/pc/kernel_exec-mmap.obj: kern/i386/pc/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/pc/kernel_exec-mmap.obj -MD -MP -MF kern/i386/pc/$(DEPDIR)/kernel_exec-mmap.Tpo -c -o kern/i386/pc/kernel_exec-mmap.obj `if test -f 'kern/i386/pc/mmap.c'; then $(CYGPATH_W) 'kern/i386/pc/mmap.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/pc/mmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/pc/$(DEPDIR)/kernel_exec-mmap.Tpo kern/i386/pc/$(DEPDIR)/kernel_exec-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/pc/mmap.c' object='kern/i386/pc/kernel_exec-mmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/pc/kernel_exec-mmap.obj `if test -f 'kern/i386/pc/mmap.c'; then $(CYGPATH_W) 'kern/i386/pc/mmap.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/pc/mmap.c'; fi`
+
+term/i386/pc/kernel_exec-console.o: term/i386/pc/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/i386/pc/kernel_exec-console.o -MD -MP -MF term/i386/pc/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/i386/pc/kernel_exec-console.o `test -f 'term/i386/pc/console.c' || echo '$(srcdir)/'`term/i386/pc/console.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/i386/pc/$(DEPDIR)/kernel_exec-console.Tpo term/i386/pc/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/i386/pc/console.c' object='term/i386/pc/kernel_exec-console.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/i386/pc/kernel_exec-console.o `test -f 'term/i386/pc/console.c' || echo '$(srcdir)/'`term/i386/pc/console.c
+
+term/i386/pc/kernel_exec-console.obj: term/i386/pc/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/i386/pc/kernel_exec-console.obj -MD -MP -MF term/i386/pc/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/i386/pc/kernel_exec-console.obj `if test -f 'term/i386/pc/console.c'; then $(CYGPATH_W) 'term/i386/pc/console.c'; else $(CYGPATH_W) '$(srcdir)/term/i386/pc/console.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/i386/pc/$(DEPDIR)/kernel_exec-console.Tpo term/i386/pc/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/i386/pc/console.c' object='term/i386/pc/kernel_exec-console.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/i386/pc/kernel_exec-console.obj `if test -f 'term/i386/pc/console.c'; then $(CYGPATH_W) 'term/i386/pc/console.c'; else $(CYGPATH_W) '$(srcdir)/term/i386/pc/console.c'; fi`
+
+kern/i386/qemu/kernel_exec-init.o: kern/i386/qemu/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/qemu/kernel_exec-init.o -MD -MP -MF kern/i386/qemu/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/i386/qemu/kernel_exec-init.o `test -f 'kern/i386/qemu/init.c' || echo '$(srcdir)/'`kern/i386/qemu/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/qemu/$(DEPDIR)/kernel_exec-init.Tpo kern/i386/qemu/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/qemu/init.c' object='kern/i386/qemu/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/qemu/kernel_exec-init.o `test -f 'kern/i386/qemu/init.c' || echo '$(srcdir)/'`kern/i386/qemu/init.c
+
+kern/i386/qemu/kernel_exec-init.obj: kern/i386/qemu/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/qemu/kernel_exec-init.obj -MD -MP -MF kern/i386/qemu/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/i386/qemu/kernel_exec-init.obj `if test -f 'kern/i386/qemu/init.c'; then $(CYGPATH_W) 'kern/i386/qemu/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/qemu/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/qemu/$(DEPDIR)/kernel_exec-init.Tpo kern/i386/qemu/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/qemu/init.c' object='kern/i386/qemu/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/qemu/kernel_exec-init.obj `if test -f 'kern/i386/qemu/init.c'; then $(CYGPATH_W) 'kern/i386/qemu/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/qemu/init.c'; fi`
+
+kern/kernel_exec-vga_init.o: kern/vga_init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-vga_init.o -MD -MP -MF kern/$(DEPDIR)/kernel_exec-vga_init.Tpo -c -o kern/kernel_exec-vga_init.o `test -f 'kern/vga_init.c' || echo '$(srcdir)/'`kern/vga_init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-vga_init.Tpo kern/$(DEPDIR)/kernel_exec-vga_init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/vga_init.c' object='kern/kernel_exec-vga_init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-vga_init.o `test -f 'kern/vga_init.c' || echo '$(srcdir)/'`kern/vga_init.c
+
+kern/kernel_exec-vga_init.obj: kern/vga_init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/kernel_exec-vga_init.obj -MD -MP -MF kern/$(DEPDIR)/kernel_exec-vga_init.Tpo -c -o kern/kernel_exec-vga_init.obj `if test -f 'kern/vga_init.c'; then $(CYGPATH_W) 'kern/vga_init.c'; else $(CYGPATH_W) '$(srcdir)/kern/vga_init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/kernel_exec-vga_init.Tpo kern/$(DEPDIR)/kernel_exec-vga_init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/vga_init.c' object='kern/kernel_exec-vga_init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/kernel_exec-vga_init.obj `if test -f 'kern/vga_init.c'; then $(CYGPATH_W) 'kern/vga_init.c'; else $(CYGPATH_W) '$(srcdir)/kern/vga_init.c'; fi`
+
+kern/i386/qemu/kernel_exec-mmap.o: kern/i386/qemu/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/qemu/kernel_exec-mmap.o -MD -MP -MF kern/i386/qemu/$(DEPDIR)/kernel_exec-mmap.Tpo -c -o kern/i386/qemu/kernel_exec-mmap.o `test -f 'kern/i386/qemu/mmap.c' || echo '$(srcdir)/'`kern/i386/qemu/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/qemu/$(DEPDIR)/kernel_exec-mmap.Tpo kern/i386/qemu/$(DEPDIR)/kernel_exec-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/qemu/mmap.c' object='kern/i386/qemu/kernel_exec-mmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/qemu/kernel_exec-mmap.o `test -f 'kern/i386/qemu/mmap.c' || echo '$(srcdir)/'`kern/i386/qemu/mmap.c
+
+kern/i386/qemu/kernel_exec-mmap.obj: kern/i386/qemu/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/qemu/kernel_exec-mmap.obj -MD -MP -MF kern/i386/qemu/$(DEPDIR)/kernel_exec-mmap.Tpo -c -o kern/i386/qemu/kernel_exec-mmap.obj `if test -f 'kern/i386/qemu/mmap.c'; then $(CYGPATH_W) 'kern/i386/qemu/mmap.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/qemu/mmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/qemu/$(DEPDIR)/kernel_exec-mmap.Tpo kern/i386/qemu/$(DEPDIR)/kernel_exec-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/qemu/mmap.c' object='kern/i386/qemu/kernel_exec-mmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/qemu/kernel_exec-mmap.obj `if test -f 'kern/i386/qemu/mmap.c'; then $(CYGPATH_W) 'kern/i386/qemu/mmap.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/qemu/mmap.c'; fi`
+
+kern/i386/xen/kernel_exec-tsc.o: kern/i386/xen/tsc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/xen/kernel_exec-tsc.o -MD -MP -MF kern/i386/xen/$(DEPDIR)/kernel_exec-tsc.Tpo -c -o kern/i386/xen/kernel_exec-tsc.o `test -f 'kern/i386/xen/tsc.c' || echo '$(srcdir)/'`kern/i386/xen/tsc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/xen/$(DEPDIR)/kernel_exec-tsc.Tpo kern/i386/xen/$(DEPDIR)/kernel_exec-tsc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/xen/tsc.c' object='kern/i386/xen/kernel_exec-tsc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/xen/kernel_exec-tsc.o `test -f 'kern/i386/xen/tsc.c' || echo '$(srcdir)/'`kern/i386/xen/tsc.c
+
+kern/i386/xen/kernel_exec-tsc.obj: kern/i386/xen/tsc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/xen/kernel_exec-tsc.obj -MD -MP -MF kern/i386/xen/$(DEPDIR)/kernel_exec-tsc.Tpo -c -o kern/i386/xen/kernel_exec-tsc.obj `if test -f 'kern/i386/xen/tsc.c'; then $(CYGPATH_W) 'kern/i386/xen/tsc.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/xen/tsc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/xen/$(DEPDIR)/kernel_exec-tsc.Tpo kern/i386/xen/$(DEPDIR)/kernel_exec-tsc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/xen/tsc.c' object='kern/i386/xen/kernel_exec-tsc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/xen/kernel_exec-tsc.obj `if test -f 'kern/i386/xen/tsc.c'; then $(CYGPATH_W) 'kern/i386/xen/tsc.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/xen/tsc.c'; fi`
+
+kern/xen/kernel_exec-init.o: kern/xen/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/xen/kernel_exec-init.o -MD -MP -MF kern/xen/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/xen/kernel_exec-init.o `test -f 'kern/xen/init.c' || echo '$(srcdir)/'`kern/xen/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/xen/$(DEPDIR)/kernel_exec-init.Tpo kern/xen/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/xen/init.c' object='kern/xen/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/xen/kernel_exec-init.o `test -f 'kern/xen/init.c' || echo '$(srcdir)/'`kern/xen/init.c
+
+kern/xen/kernel_exec-init.obj: kern/xen/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/xen/kernel_exec-init.obj -MD -MP -MF kern/xen/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/xen/kernel_exec-init.obj `if test -f 'kern/xen/init.c'; then $(CYGPATH_W) 'kern/xen/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/xen/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/xen/$(DEPDIR)/kernel_exec-init.Tpo kern/xen/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/xen/init.c' object='kern/xen/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/xen/kernel_exec-init.obj `if test -f 'kern/xen/init.c'; then $(CYGPATH_W) 'kern/xen/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/xen/init.c'; fi`
+
+term/xen/kernel_exec-console.o: term/xen/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/xen/kernel_exec-console.o -MD -MP -MF term/xen/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/xen/kernel_exec-console.o `test -f 'term/xen/console.c' || echo '$(srcdir)/'`term/xen/console.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/xen/$(DEPDIR)/kernel_exec-console.Tpo term/xen/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/xen/console.c' object='term/xen/kernel_exec-console.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/xen/kernel_exec-console.o `test -f 'term/xen/console.c' || echo '$(srcdir)/'`term/xen/console.c
+
+term/xen/kernel_exec-console.obj: term/xen/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/xen/kernel_exec-console.obj -MD -MP -MF term/xen/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/xen/kernel_exec-console.obj `if test -f 'term/xen/console.c'; then $(CYGPATH_W) 'term/xen/console.c'; else $(CYGPATH_W) '$(srcdir)/term/xen/console.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/xen/$(DEPDIR)/kernel_exec-console.Tpo term/xen/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/xen/console.c' object='term/xen/kernel_exec-console.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/xen/kernel_exec-console.obj `if test -f 'term/xen/console.c'; then $(CYGPATH_W) 'term/xen/console.c'; else $(CYGPATH_W) '$(srcdir)/term/xen/console.c'; fi`
+
+disk/xen/kernel_exec-xendisk.o: disk/xen/xendisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/xen/kernel_exec-xendisk.o -MD -MP -MF disk/xen/$(DEPDIR)/kernel_exec-xendisk.Tpo -c -o disk/xen/kernel_exec-xendisk.o `test -f 'disk/xen/xendisk.c' || echo '$(srcdir)/'`disk/xen/xendisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/xen/$(DEPDIR)/kernel_exec-xendisk.Tpo disk/xen/$(DEPDIR)/kernel_exec-xendisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/xen/xendisk.c' object='disk/xen/kernel_exec-xendisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/xen/kernel_exec-xendisk.o `test -f 'disk/xen/xendisk.c' || echo '$(srcdir)/'`disk/xen/xendisk.c
+
+disk/xen/kernel_exec-xendisk.obj: disk/xen/xendisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/xen/kernel_exec-xendisk.obj -MD -MP -MF disk/xen/$(DEPDIR)/kernel_exec-xendisk.Tpo -c -o disk/xen/kernel_exec-xendisk.obj `if test -f 'disk/xen/xendisk.c'; then $(CYGPATH_W) 'disk/xen/xendisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/xen/xendisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/xen/$(DEPDIR)/kernel_exec-xendisk.Tpo disk/xen/$(DEPDIR)/kernel_exec-xendisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/xen/xendisk.c' object='disk/xen/kernel_exec-xendisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/xen/kernel_exec-xendisk.obj `if test -f 'disk/xen/xendisk.c'; then $(CYGPATH_W) 'disk/xen/xendisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/xen/xendisk.c'; fi`
+
+commands/kernel_exec-boot.o: commands/boot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT commands/kernel_exec-boot.o -MD -MP -MF commands/$(DEPDIR)/kernel_exec-boot.Tpo -c -o commands/kernel_exec-boot.o `test -f 'commands/boot.c' || echo '$(srcdir)/'`commands/boot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/kernel_exec-boot.Tpo commands/$(DEPDIR)/kernel_exec-boot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/boot.c' object='commands/kernel_exec-boot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o commands/kernel_exec-boot.o `test -f 'commands/boot.c' || echo '$(srcdir)/'`commands/boot.c
+
+commands/kernel_exec-boot.obj: commands/boot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT commands/kernel_exec-boot.obj -MD -MP -MF commands/$(DEPDIR)/kernel_exec-boot.Tpo -c -o commands/kernel_exec-boot.obj `if test -f 'commands/boot.c'; then $(CYGPATH_W) 'commands/boot.c'; else $(CYGPATH_W) '$(srcdir)/commands/boot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/kernel_exec-boot.Tpo commands/$(DEPDIR)/kernel_exec-boot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/boot.c' object='commands/kernel_exec-boot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o commands/kernel_exec-boot.obj `if test -f 'commands/boot.c'; then $(CYGPATH_W) 'commands/boot.c'; else $(CYGPATH_W) '$(srcdir)/commands/boot.c'; fi`
+
+kern/i386/xen/kernel_exec-pvh.o: kern/i386/xen/pvh.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/xen/kernel_exec-pvh.o -MD -MP -MF kern/i386/xen/$(DEPDIR)/kernel_exec-pvh.Tpo -c -o kern/i386/xen/kernel_exec-pvh.o `test -f 'kern/i386/xen/pvh.c' || echo '$(srcdir)/'`kern/i386/xen/pvh.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/xen/$(DEPDIR)/kernel_exec-pvh.Tpo kern/i386/xen/$(DEPDIR)/kernel_exec-pvh.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/xen/pvh.c' object='kern/i386/xen/kernel_exec-pvh.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/xen/kernel_exec-pvh.o `test -f 'kern/i386/xen/pvh.c' || echo '$(srcdir)/'`kern/i386/xen/pvh.c
+
+kern/i386/xen/kernel_exec-pvh.obj: kern/i386/xen/pvh.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/i386/xen/kernel_exec-pvh.obj -MD -MP -MF kern/i386/xen/$(DEPDIR)/kernel_exec-pvh.Tpo -c -o kern/i386/xen/kernel_exec-pvh.obj `if test -f 'kern/i386/xen/pvh.c'; then $(CYGPATH_W) 'kern/i386/xen/pvh.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/xen/pvh.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/xen/$(DEPDIR)/kernel_exec-pvh.Tpo kern/i386/xen/$(DEPDIR)/kernel_exec-pvh.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/xen/pvh.c' object='kern/i386/xen/kernel_exec-pvh.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/i386/xen/kernel_exec-pvh.obj `if test -f 'kern/i386/xen/pvh.c'; then $(CYGPATH_W) 'kern/i386/xen/pvh.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/xen/pvh.c'; fi`
+
+kern/ia64/efi/kernel_exec-init.o: kern/ia64/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ia64/efi/kernel_exec-init.o -MD -MP -MF kern/ia64/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/ia64/efi/kernel_exec-init.o `test -f 'kern/ia64/efi/init.c' || echo '$(srcdir)/'`kern/ia64/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ia64/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/ia64/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ia64/efi/init.c' object='kern/ia64/efi/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ia64/efi/kernel_exec-init.o `test -f 'kern/ia64/efi/init.c' || echo '$(srcdir)/'`kern/ia64/efi/init.c
+
+kern/ia64/efi/kernel_exec-init.obj: kern/ia64/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ia64/efi/kernel_exec-init.obj -MD -MP -MF kern/ia64/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/ia64/efi/kernel_exec-init.obj `if test -f 'kern/ia64/efi/init.c'; then $(CYGPATH_W) 'kern/ia64/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/ia64/efi/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ia64/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/ia64/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ia64/efi/init.c' object='kern/ia64/efi/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ia64/efi/kernel_exec-init.obj `if test -f 'kern/ia64/efi/init.c'; then $(CYGPATH_W) 'kern/ia64/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/ia64/efi/init.c'; fi`
+
+kern/ia64/kernel_exec-dl.o: kern/ia64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ia64/kernel_exec-dl.o -MD -MP -MF kern/ia64/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/ia64/kernel_exec-dl.o `test -f 'kern/ia64/dl.c' || echo '$(srcdir)/'`kern/ia64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ia64/$(DEPDIR)/kernel_exec-dl.Tpo kern/ia64/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ia64/dl.c' object='kern/ia64/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ia64/kernel_exec-dl.o `test -f 'kern/ia64/dl.c' || echo '$(srcdir)/'`kern/ia64/dl.c
+
+kern/ia64/kernel_exec-dl.obj: kern/ia64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ia64/kernel_exec-dl.obj -MD -MP -MF kern/ia64/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/ia64/kernel_exec-dl.obj `if test -f 'kern/ia64/dl.c'; then $(CYGPATH_W) 'kern/ia64/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/ia64/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ia64/$(DEPDIR)/kernel_exec-dl.Tpo kern/ia64/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ia64/dl.c' object='kern/ia64/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ia64/kernel_exec-dl.obj `if test -f 'kern/ia64/dl.c'; then $(CYGPATH_W) 'kern/ia64/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/ia64/dl.c'; fi`
+
+kern/ia64/kernel_exec-dl_helper.o: kern/ia64/dl_helper.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ia64/kernel_exec-dl_helper.o -MD -MP -MF kern/ia64/$(DEPDIR)/kernel_exec-dl_helper.Tpo -c -o kern/ia64/kernel_exec-dl_helper.o `test -f 'kern/ia64/dl_helper.c' || echo '$(srcdir)/'`kern/ia64/dl_helper.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ia64/$(DEPDIR)/kernel_exec-dl_helper.Tpo kern/ia64/$(DEPDIR)/kernel_exec-dl_helper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ia64/dl_helper.c' object='kern/ia64/kernel_exec-dl_helper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ia64/kernel_exec-dl_helper.o `test -f 'kern/ia64/dl_helper.c' || echo '$(srcdir)/'`kern/ia64/dl_helper.c
+
+kern/ia64/kernel_exec-dl_helper.obj: kern/ia64/dl_helper.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ia64/kernel_exec-dl_helper.obj -MD -MP -MF kern/ia64/$(DEPDIR)/kernel_exec-dl_helper.Tpo -c -o kern/ia64/kernel_exec-dl_helper.obj `if test -f 'kern/ia64/dl_helper.c'; then $(CYGPATH_W) 'kern/ia64/dl_helper.c'; else $(CYGPATH_W) '$(srcdir)/kern/ia64/dl_helper.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ia64/$(DEPDIR)/kernel_exec-dl_helper.Tpo kern/ia64/$(DEPDIR)/kernel_exec-dl_helper.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ia64/dl_helper.c' object='kern/ia64/kernel_exec-dl_helper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ia64/kernel_exec-dl_helper.obj `if test -f 'kern/ia64/dl_helper.c'; then $(CYGPATH_W) 'kern/ia64/dl_helper.c'; else $(CYGPATH_W) '$(srcdir)/kern/ia64/dl_helper.c'; fi`
+
+kern/ia64/kernel_exec-cache.o: kern/ia64/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ia64/kernel_exec-cache.o -MD -MP -MF kern/ia64/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/ia64/kernel_exec-cache.o `test -f 'kern/ia64/cache.c' || echo '$(srcdir)/'`kern/ia64/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ia64/$(DEPDIR)/kernel_exec-cache.Tpo kern/ia64/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ia64/cache.c' object='kern/ia64/kernel_exec-cache.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ia64/kernel_exec-cache.o `test -f 'kern/ia64/cache.c' || echo '$(srcdir)/'`kern/ia64/cache.c
+
+kern/ia64/kernel_exec-cache.obj: kern/ia64/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/ia64/kernel_exec-cache.obj -MD -MP -MF kern/ia64/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/ia64/kernel_exec-cache.obj `if test -f 'kern/ia64/cache.c'; then $(CYGPATH_W) 'kern/ia64/cache.c'; else $(CYGPATH_W) '$(srcdir)/kern/ia64/cache.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/ia64/$(DEPDIR)/kernel_exec-cache.Tpo kern/ia64/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/ia64/cache.c' object='kern/ia64/kernel_exec-cache.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/ia64/kernel_exec-cache.obj `if test -f 'kern/ia64/cache.c'; then $(CYGPATH_W) 'kern/ia64/cache.c'; else $(CYGPATH_W) '$(srcdir)/kern/ia64/cache.c'; fi`
+
+kern/mips/arc/kernel_exec-init.o: kern/mips/arc/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/mips/arc/kernel_exec-init.o -MD -MP -MF kern/mips/arc/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/mips/arc/kernel_exec-init.o `test -f 'kern/mips/arc/init.c' || echo '$(srcdir)/'`kern/mips/arc/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/mips/arc/$(DEPDIR)/kernel_exec-init.Tpo kern/mips/arc/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mips/arc/init.c' object='kern/mips/arc/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/mips/arc/kernel_exec-init.o `test -f 'kern/mips/arc/init.c' || echo '$(srcdir)/'`kern/mips/arc/init.c
+
+kern/mips/arc/kernel_exec-init.obj: kern/mips/arc/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/mips/arc/kernel_exec-init.obj -MD -MP -MF kern/mips/arc/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/mips/arc/kernel_exec-init.obj `if test -f 'kern/mips/arc/init.c'; then $(CYGPATH_W) 'kern/mips/arc/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/mips/arc/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/mips/arc/$(DEPDIR)/kernel_exec-init.Tpo kern/mips/arc/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mips/arc/init.c' object='kern/mips/arc/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/mips/arc/kernel_exec-init.obj `if test -f 'kern/mips/arc/init.c'; then $(CYGPATH_W) 'kern/mips/arc/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/mips/arc/init.c'; fi`
+
+term/arc/kernel_exec-console.o: term/arc/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/arc/kernel_exec-console.o -MD -MP -MF term/arc/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/arc/kernel_exec-console.o `test -f 'term/arc/console.c' || echo '$(srcdir)/'`term/arc/console.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/arc/$(DEPDIR)/kernel_exec-console.Tpo term/arc/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/arc/console.c' object='term/arc/kernel_exec-console.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/arc/kernel_exec-console.o `test -f 'term/arc/console.c' || echo '$(srcdir)/'`term/arc/console.c
+
+term/arc/kernel_exec-console.obj: term/arc/console.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/arc/kernel_exec-console.obj -MD -MP -MF term/arc/$(DEPDIR)/kernel_exec-console.Tpo -c -o term/arc/kernel_exec-console.obj `if test -f 'term/arc/console.c'; then $(CYGPATH_W) 'term/arc/console.c'; else $(CYGPATH_W) '$(srcdir)/term/arc/console.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/arc/$(DEPDIR)/kernel_exec-console.Tpo term/arc/$(DEPDIR)/kernel_exec-console.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/arc/console.c' object='term/arc/kernel_exec-console.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/arc/kernel_exec-console.obj `if test -f 'term/arc/console.c'; then $(CYGPATH_W) 'term/arc/console.c'; else $(CYGPATH_W) '$(srcdir)/term/arc/console.c'; fi`
+
+disk/arc/kernel_exec-arcdisk.o: disk/arc/arcdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/arc/kernel_exec-arcdisk.o -MD -MP -MF disk/arc/$(DEPDIR)/kernel_exec-arcdisk.Tpo -c -o disk/arc/kernel_exec-arcdisk.o `test -f 'disk/arc/arcdisk.c' || echo '$(srcdir)/'`disk/arc/arcdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/arc/$(DEPDIR)/kernel_exec-arcdisk.Tpo disk/arc/$(DEPDIR)/kernel_exec-arcdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/arc/arcdisk.c' object='disk/arc/kernel_exec-arcdisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/arc/kernel_exec-arcdisk.o `test -f 'disk/arc/arcdisk.c' || echo '$(srcdir)/'`disk/arc/arcdisk.c
+
+disk/arc/kernel_exec-arcdisk.obj: disk/arc/arcdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/arc/kernel_exec-arcdisk.obj -MD -MP -MF disk/arc/$(DEPDIR)/kernel_exec-arcdisk.Tpo -c -o disk/arc/kernel_exec-arcdisk.obj `if test -f 'disk/arc/arcdisk.c'; then $(CYGPATH_W) 'disk/arc/arcdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/arc/arcdisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/arc/$(DEPDIR)/kernel_exec-arcdisk.Tpo disk/arc/$(DEPDIR)/kernel_exec-arcdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/arc/arcdisk.c' object='disk/arc/kernel_exec-arcdisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/arc/kernel_exec-arcdisk.obj `if test -f 'disk/arc/arcdisk.c'; then $(CYGPATH_W) 'disk/arc/arcdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/arc/arcdisk.c'; fi`
+
+kern/generic/kernel_exec-rtc_get_time_ms.o: kern/generic/rtc_get_time_ms.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/generic/kernel_exec-rtc_get_time_ms.o -MD -MP -MF kern/generic/$(DEPDIR)/kernel_exec-rtc_get_time_ms.Tpo -c -o kern/generic/kernel_exec-rtc_get_time_ms.o `test -f 'kern/generic/rtc_get_time_ms.c' || echo '$(srcdir)/'`kern/generic/rtc_get_time_ms.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/generic/$(DEPDIR)/kernel_exec-rtc_get_time_ms.Tpo kern/generic/$(DEPDIR)/kernel_exec-rtc_get_time_ms.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/generic/rtc_get_time_ms.c' object='kern/generic/kernel_exec-rtc_get_time_ms.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/generic/kernel_exec-rtc_get_time_ms.o `test -f 'kern/generic/rtc_get_time_ms.c' || echo '$(srcdir)/'`kern/generic/rtc_get_time_ms.c
+
+kern/generic/kernel_exec-rtc_get_time_ms.obj: kern/generic/rtc_get_time_ms.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/generic/kernel_exec-rtc_get_time_ms.obj -MD -MP -MF kern/generic/$(DEPDIR)/kernel_exec-rtc_get_time_ms.Tpo -c -o kern/generic/kernel_exec-rtc_get_time_ms.obj `if test -f 'kern/generic/rtc_get_time_ms.c'; then $(CYGPATH_W) 'kern/generic/rtc_get_time_ms.c'; else $(CYGPATH_W) '$(srcdir)/kern/generic/rtc_get_time_ms.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/generic/$(DEPDIR)/kernel_exec-rtc_get_time_ms.Tpo kern/generic/$(DEPDIR)/kernel_exec-rtc_get_time_ms.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/generic/rtc_get_time_ms.c' object='kern/generic/kernel_exec-rtc_get_time_ms.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/generic/kernel_exec-rtc_get_time_ms.obj `if test -f 'kern/generic/rtc_get_time_ms.c'; then $(CYGPATH_W) 'kern/generic/rtc_get_time_ms.c'; else $(CYGPATH_W) '$(srcdir)/kern/generic/rtc_get_time_ms.c'; fi`
+
+kern/mips/kernel_exec-dl.o: kern/mips/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/mips/kernel_exec-dl.o -MD -MP -MF kern/mips/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/mips/kernel_exec-dl.o `test -f 'kern/mips/dl.c' || echo '$(srcdir)/'`kern/mips/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/mips/$(DEPDIR)/kernel_exec-dl.Tpo kern/mips/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mips/dl.c' object='kern/mips/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/mips/kernel_exec-dl.o `test -f 'kern/mips/dl.c' || echo '$(srcdir)/'`kern/mips/dl.c
+
+kern/mips/kernel_exec-dl.obj: kern/mips/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/mips/kernel_exec-dl.obj -MD -MP -MF kern/mips/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/mips/kernel_exec-dl.obj `if test -f 'kern/mips/dl.c'; then $(CYGPATH_W) 'kern/mips/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/mips/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/mips/$(DEPDIR)/kernel_exec-dl.Tpo kern/mips/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mips/dl.c' object='kern/mips/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/mips/kernel_exec-dl.obj `if test -f 'kern/mips/dl.c'; then $(CYGPATH_W) 'kern/mips/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/mips/dl.c'; fi`
+
+kern/mips/kernel_exec-init.o: kern/mips/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/mips/kernel_exec-init.o -MD -MP -MF kern/mips/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/mips/kernel_exec-init.o `test -f 'kern/mips/init.c' || echo '$(srcdir)/'`kern/mips/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/mips/$(DEPDIR)/kernel_exec-init.Tpo kern/mips/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mips/init.c' object='kern/mips/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/mips/kernel_exec-init.o `test -f 'kern/mips/init.c' || echo '$(srcdir)/'`kern/mips/init.c
+
+kern/mips/kernel_exec-init.obj: kern/mips/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/mips/kernel_exec-init.obj -MD -MP -MF kern/mips/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/mips/kernel_exec-init.obj `if test -f 'kern/mips/init.c'; then $(CYGPATH_W) 'kern/mips/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/mips/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/mips/$(DEPDIR)/kernel_exec-init.Tpo kern/mips/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mips/init.c' object='kern/mips/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/mips/kernel_exec-init.obj `if test -f 'kern/mips/init.c'; then $(CYGPATH_W) 'kern/mips/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/mips/init.c'; fi`
+
+term/kernel_exec-ns8250.o: term/ns8250.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-ns8250.o -MD -MP -MF term/$(DEPDIR)/kernel_exec-ns8250.Tpo -c -o term/kernel_exec-ns8250.o `test -f 'term/ns8250.c' || echo '$(srcdir)/'`term/ns8250.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-ns8250.Tpo term/$(DEPDIR)/kernel_exec-ns8250.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ns8250.c' object='term/kernel_exec-ns8250.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-ns8250.o `test -f 'term/ns8250.c' || echo '$(srcdir)/'`term/ns8250.c
+
+term/kernel_exec-ns8250.obj: term/ns8250.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-ns8250.obj -MD -MP -MF term/$(DEPDIR)/kernel_exec-ns8250.Tpo -c -o term/kernel_exec-ns8250.obj `if test -f 'term/ns8250.c'; then $(CYGPATH_W) 'term/ns8250.c'; else $(CYGPATH_W) '$(srcdir)/term/ns8250.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-ns8250.Tpo term/$(DEPDIR)/kernel_exec-ns8250.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ns8250.c' object='term/kernel_exec-ns8250.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-ns8250.obj `if test -f 'term/ns8250.c'; then $(CYGPATH_W) 'term/ns8250.c'; else $(CYGPATH_W) '$(srcdir)/term/ns8250.c'; fi`
+
+bus/kernel_exec-bonito.o: bus/bonito.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT bus/kernel_exec-bonito.o -MD -MP -MF bus/$(DEPDIR)/kernel_exec-bonito.Tpo -c -o bus/kernel_exec-bonito.o `test -f 'bus/bonito.c' || echo '$(srcdir)/'`bus/bonito.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/kernel_exec-bonito.Tpo bus/$(DEPDIR)/kernel_exec-bonito.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/bonito.c' object='bus/kernel_exec-bonito.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o bus/kernel_exec-bonito.o `test -f 'bus/bonito.c' || echo '$(srcdir)/'`bus/bonito.c
+
+bus/kernel_exec-bonito.obj: bus/bonito.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT bus/kernel_exec-bonito.obj -MD -MP -MF bus/$(DEPDIR)/kernel_exec-bonito.Tpo -c -o bus/kernel_exec-bonito.obj `if test -f 'bus/bonito.c'; then $(CYGPATH_W) 'bus/bonito.c'; else $(CYGPATH_W) '$(srcdir)/bus/bonito.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/kernel_exec-bonito.Tpo bus/$(DEPDIR)/kernel_exec-bonito.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/bonito.c' object='bus/kernel_exec-bonito.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o bus/kernel_exec-bonito.obj `if test -f 'bus/bonito.c'; then $(CYGPATH_W) 'bus/bonito.c'; else $(CYGPATH_W) '$(srcdir)/bus/bonito.c'; fi`
+
+bus/kernel_exec-cs5536.o: bus/cs5536.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT bus/kernel_exec-cs5536.o -MD -MP -MF bus/$(DEPDIR)/kernel_exec-cs5536.Tpo -c -o bus/kernel_exec-cs5536.o `test -f 'bus/cs5536.c' || echo '$(srcdir)/'`bus/cs5536.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/kernel_exec-cs5536.Tpo bus/$(DEPDIR)/kernel_exec-cs5536.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/cs5536.c' object='bus/kernel_exec-cs5536.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o bus/kernel_exec-cs5536.o `test -f 'bus/cs5536.c' || echo '$(srcdir)/'`bus/cs5536.c
+
+bus/kernel_exec-cs5536.obj: bus/cs5536.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT bus/kernel_exec-cs5536.obj -MD -MP -MF bus/$(DEPDIR)/kernel_exec-cs5536.Tpo -c -o bus/kernel_exec-cs5536.obj `if test -f 'bus/cs5536.c'; then $(CYGPATH_W) 'bus/cs5536.c'; else $(CYGPATH_W) '$(srcdir)/bus/cs5536.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/kernel_exec-cs5536.Tpo bus/$(DEPDIR)/kernel_exec-cs5536.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/cs5536.c' object='bus/kernel_exec-cs5536.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o bus/kernel_exec-cs5536.obj `if test -f 'bus/cs5536.c'; then $(CYGPATH_W) 'bus/cs5536.c'; else $(CYGPATH_W) '$(srcdir)/bus/cs5536.c'; fi`
+
+kern/mips/loongson/kernel_exec-init.o: kern/mips/loongson/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/mips/loongson/kernel_exec-init.o -MD -MP -MF kern/mips/loongson/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/mips/loongson/kernel_exec-init.o `test -f 'kern/mips/loongson/init.c' || echo '$(srcdir)/'`kern/mips/loongson/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/mips/loongson/$(DEPDIR)/kernel_exec-init.Tpo kern/mips/loongson/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mips/loongson/init.c' object='kern/mips/loongson/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/mips/loongson/kernel_exec-init.o `test -f 'kern/mips/loongson/init.c' || echo '$(srcdir)/'`kern/mips/loongson/init.c
+
+kern/mips/loongson/kernel_exec-init.obj: kern/mips/loongson/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/mips/loongson/kernel_exec-init.obj -MD -MP -MF kern/mips/loongson/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/mips/loongson/kernel_exec-init.obj `if test -f 'kern/mips/loongson/init.c'; then $(CYGPATH_W) 'kern/mips/loongson/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/mips/loongson/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/mips/loongson/$(DEPDIR)/kernel_exec-init.Tpo kern/mips/loongson/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mips/loongson/init.c' object='kern/mips/loongson/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/mips/loongson/kernel_exec-init.obj `if test -f 'kern/mips/loongson/init.c'; then $(CYGPATH_W) 'kern/mips/loongson/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/mips/loongson/init.c'; fi`
+
+term/kernel_exec-at_keyboard.o: term/at_keyboard.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-at_keyboard.o -MD -MP -MF term/$(DEPDIR)/kernel_exec-at_keyboard.Tpo -c -o term/kernel_exec-at_keyboard.o `test -f 'term/at_keyboard.c' || echo '$(srcdir)/'`term/at_keyboard.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-at_keyboard.Tpo term/$(DEPDIR)/kernel_exec-at_keyboard.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/at_keyboard.c' object='term/kernel_exec-at_keyboard.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-at_keyboard.o `test -f 'term/at_keyboard.c' || echo '$(srcdir)/'`term/at_keyboard.c
+
+term/kernel_exec-at_keyboard.obj: term/at_keyboard.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-at_keyboard.obj -MD -MP -MF term/$(DEPDIR)/kernel_exec-at_keyboard.Tpo -c -o term/kernel_exec-at_keyboard.obj `if test -f 'term/at_keyboard.c'; then $(CYGPATH_W) 'term/at_keyboard.c'; else $(CYGPATH_W) '$(srcdir)/term/at_keyboard.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-at_keyboard.Tpo term/$(DEPDIR)/kernel_exec-at_keyboard.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/at_keyboard.c' object='term/kernel_exec-at_keyboard.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-at_keyboard.obj `if test -f 'term/at_keyboard.c'; then $(CYGPATH_W) 'term/at_keyboard.c'; else $(CYGPATH_W) '$(srcdir)/term/at_keyboard.c'; fi`
+
+term/kernel_exec-serial.o: term/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-serial.o -MD -MP -MF term/$(DEPDIR)/kernel_exec-serial.Tpo -c -o term/kernel_exec-serial.o `test -f 'term/serial.c' || echo '$(srcdir)/'`term/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-serial.Tpo term/$(DEPDIR)/kernel_exec-serial.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/serial.c' object='term/kernel_exec-serial.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-serial.o `test -f 'term/serial.c' || echo '$(srcdir)/'`term/serial.c
+
+term/kernel_exec-serial.obj: term/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT term/kernel_exec-serial.obj -MD -MP -MF term/$(DEPDIR)/kernel_exec-serial.Tpo -c -o term/kernel_exec-serial.obj `if test -f 'term/serial.c'; then $(CYGPATH_W) 'term/serial.c'; else $(CYGPATH_W) '$(srcdir)/term/serial.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/kernel_exec-serial.Tpo term/$(DEPDIR)/kernel_exec-serial.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/serial.c' object='term/kernel_exec-serial.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o term/kernel_exec-serial.obj `if test -f 'term/serial.c'; then $(CYGPATH_W) 'term/serial.c'; else $(CYGPATH_W) '$(srcdir)/term/serial.c'; fi`
+
+video/kernel_exec-sm712.o: video/sm712.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/kernel_exec-sm712.o -MD -MP -MF video/$(DEPDIR)/kernel_exec-sm712.Tpo -c -o video/kernel_exec-sm712.o `test -f 'video/sm712.c' || echo '$(srcdir)/'`video/sm712.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/kernel_exec-sm712.Tpo video/$(DEPDIR)/kernel_exec-sm712.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/sm712.c' object='video/kernel_exec-sm712.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/kernel_exec-sm712.o `test -f 'video/sm712.c' || echo '$(srcdir)/'`video/sm712.c
+
+video/kernel_exec-sm712.obj: video/sm712.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/kernel_exec-sm712.obj -MD -MP -MF video/$(DEPDIR)/kernel_exec-sm712.Tpo -c -o video/kernel_exec-sm712.obj `if test -f 'video/sm712.c'; then $(CYGPATH_W) 'video/sm712.c'; else $(CYGPATH_W) '$(srcdir)/video/sm712.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/kernel_exec-sm712.Tpo video/$(DEPDIR)/kernel_exec-sm712.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/sm712.c' object='video/kernel_exec-sm712.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/kernel_exec-sm712.obj `if test -f 'video/sm712.c'; then $(CYGPATH_W) 'video/sm712.c'; else $(CYGPATH_W) '$(srcdir)/video/sm712.c'; fi`
+
+video/kernel_exec-sis315pro.o: video/sis315pro.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/kernel_exec-sis315pro.o -MD -MP -MF video/$(DEPDIR)/kernel_exec-sis315pro.Tpo -c -o video/kernel_exec-sis315pro.o `test -f 'video/sis315pro.c' || echo '$(srcdir)/'`video/sis315pro.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/kernel_exec-sis315pro.Tpo video/$(DEPDIR)/kernel_exec-sis315pro.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/sis315pro.c' object='video/kernel_exec-sis315pro.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/kernel_exec-sis315pro.o `test -f 'video/sis315pro.c' || echo '$(srcdir)/'`video/sis315pro.c
+
+video/kernel_exec-sis315pro.obj: video/sis315pro.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/kernel_exec-sis315pro.obj -MD -MP -MF video/$(DEPDIR)/kernel_exec-sis315pro.Tpo -c -o video/kernel_exec-sis315pro.obj `if test -f 'video/sis315pro.c'; then $(CYGPATH_W) 'video/sis315pro.c'; else $(CYGPATH_W) '$(srcdir)/video/sis315pro.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/kernel_exec-sis315pro.Tpo video/$(DEPDIR)/kernel_exec-sis315pro.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/sis315pro.c' object='video/kernel_exec-sis315pro.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/kernel_exec-sis315pro.obj `if test -f 'video/sis315pro.c'; then $(CYGPATH_W) 'video/sis315pro.c'; else $(CYGPATH_W) '$(srcdir)/video/sis315pro.c'; fi`
+
+video/kernel_exec-radeon_fuloong2e.o: video/radeon_fuloong2e.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/kernel_exec-radeon_fuloong2e.o -MD -MP -MF video/$(DEPDIR)/kernel_exec-radeon_fuloong2e.Tpo -c -o video/kernel_exec-radeon_fuloong2e.o `test -f 'video/radeon_fuloong2e.c' || echo '$(srcdir)/'`video/radeon_fuloong2e.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/kernel_exec-radeon_fuloong2e.Tpo video/$(DEPDIR)/kernel_exec-radeon_fuloong2e.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/radeon_fuloong2e.c' object='video/kernel_exec-radeon_fuloong2e.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/kernel_exec-radeon_fuloong2e.o `test -f 'video/radeon_fuloong2e.c' || echo '$(srcdir)/'`video/radeon_fuloong2e.c
+
+video/kernel_exec-radeon_fuloong2e.obj: video/radeon_fuloong2e.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/kernel_exec-radeon_fuloong2e.obj -MD -MP -MF video/$(DEPDIR)/kernel_exec-radeon_fuloong2e.Tpo -c -o video/kernel_exec-radeon_fuloong2e.obj `if test -f 'video/radeon_fuloong2e.c'; then $(CYGPATH_W) 'video/radeon_fuloong2e.c'; else $(CYGPATH_W) '$(srcdir)/video/radeon_fuloong2e.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/kernel_exec-radeon_fuloong2e.Tpo video/$(DEPDIR)/kernel_exec-radeon_fuloong2e.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/radeon_fuloong2e.c' object='video/kernel_exec-radeon_fuloong2e.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/kernel_exec-radeon_fuloong2e.obj `if test -f 'video/radeon_fuloong2e.c'; then $(CYGPATH_W) 'video/radeon_fuloong2e.c'; else $(CYGPATH_W) '$(srcdir)/video/radeon_fuloong2e.c'; fi`
+
+video/kernel_exec-radeon_yeeloong3a.o: video/radeon_yeeloong3a.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/kernel_exec-radeon_yeeloong3a.o -MD -MP -MF video/$(DEPDIR)/kernel_exec-radeon_yeeloong3a.Tpo -c -o video/kernel_exec-radeon_yeeloong3a.o `test -f 'video/radeon_yeeloong3a.c' || echo '$(srcdir)/'`video/radeon_yeeloong3a.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/kernel_exec-radeon_yeeloong3a.Tpo video/$(DEPDIR)/kernel_exec-radeon_yeeloong3a.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/radeon_yeeloong3a.c' object='video/kernel_exec-radeon_yeeloong3a.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/kernel_exec-radeon_yeeloong3a.o `test -f 'video/radeon_yeeloong3a.c' || echo '$(srcdir)/'`video/radeon_yeeloong3a.c
+
+video/kernel_exec-radeon_yeeloong3a.obj: video/radeon_yeeloong3a.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT video/kernel_exec-radeon_yeeloong3a.obj -MD -MP -MF video/$(DEPDIR)/kernel_exec-radeon_yeeloong3a.Tpo -c -o video/kernel_exec-radeon_yeeloong3a.obj `if test -f 'video/radeon_yeeloong3a.c'; then $(CYGPATH_W) 'video/radeon_yeeloong3a.c'; else $(CYGPATH_W) '$(srcdir)/video/radeon_yeeloong3a.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/kernel_exec-radeon_yeeloong3a.Tpo video/$(DEPDIR)/kernel_exec-radeon_yeeloong3a.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/radeon_yeeloong3a.c' object='video/kernel_exec-radeon_yeeloong3a.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o video/kernel_exec-radeon_yeeloong3a.obj `if test -f 'video/radeon_yeeloong3a.c'; then $(CYGPATH_W) 'video/radeon_yeeloong3a.c'; else $(CYGPATH_W) '$(srcdir)/video/radeon_yeeloong3a.c'; fi`
+
+kern/mips/qemu_mips/kernel_exec-init.o: kern/mips/qemu_mips/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/mips/qemu_mips/kernel_exec-init.o -MD -MP -MF kern/mips/qemu_mips/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/mips/qemu_mips/kernel_exec-init.o `test -f 'kern/mips/qemu_mips/init.c' || echo '$(srcdir)/'`kern/mips/qemu_mips/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/mips/qemu_mips/$(DEPDIR)/kernel_exec-init.Tpo kern/mips/qemu_mips/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mips/qemu_mips/init.c' object='kern/mips/qemu_mips/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/mips/qemu_mips/kernel_exec-init.o `test -f 'kern/mips/qemu_mips/init.c' || echo '$(srcdir)/'`kern/mips/qemu_mips/init.c
+
+kern/mips/qemu_mips/kernel_exec-init.obj: kern/mips/qemu_mips/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/mips/qemu_mips/kernel_exec-init.obj -MD -MP -MF kern/mips/qemu_mips/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/mips/qemu_mips/kernel_exec-init.obj `if test -f 'kern/mips/qemu_mips/init.c'; then $(CYGPATH_W) 'kern/mips/qemu_mips/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/mips/qemu_mips/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/mips/qemu_mips/$(DEPDIR)/kernel_exec-init.Tpo kern/mips/qemu_mips/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/mips/qemu_mips/init.c' object='kern/mips/qemu_mips/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/mips/qemu_mips/kernel_exec-init.obj `if test -f 'kern/mips/qemu_mips/init.c'; then $(CYGPATH_W) 'kern/mips/qemu_mips/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/mips/qemu_mips/init.c'; fi`
+
+kern/powerpc/kernel_exec-dl.o: kern/powerpc/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/powerpc/kernel_exec-dl.o -MD -MP -MF kern/powerpc/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/powerpc/kernel_exec-dl.o `test -f 'kern/powerpc/dl.c' || echo '$(srcdir)/'`kern/powerpc/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/powerpc/$(DEPDIR)/kernel_exec-dl.Tpo kern/powerpc/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/powerpc/dl.c' object='kern/powerpc/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/powerpc/kernel_exec-dl.o `test -f 'kern/powerpc/dl.c' || echo '$(srcdir)/'`kern/powerpc/dl.c
+
+kern/powerpc/kernel_exec-dl.obj: kern/powerpc/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/powerpc/kernel_exec-dl.obj -MD -MP -MF kern/powerpc/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/powerpc/kernel_exec-dl.obj `if test -f 'kern/powerpc/dl.c'; then $(CYGPATH_W) 'kern/powerpc/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/powerpc/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/powerpc/$(DEPDIR)/kernel_exec-dl.Tpo kern/powerpc/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/powerpc/dl.c' object='kern/powerpc/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/powerpc/kernel_exec-dl.obj `if test -f 'kern/powerpc/dl.c'; then $(CYGPATH_W) 'kern/powerpc/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/powerpc/dl.c'; fi`
+
+kern/riscv/efi/kernel_exec-init.o: kern/riscv/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/riscv/efi/kernel_exec-init.o -MD -MP -MF kern/riscv/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/riscv/efi/kernel_exec-init.o `test -f 'kern/riscv/efi/init.c' || echo '$(srcdir)/'`kern/riscv/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/riscv/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/riscv/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/riscv/efi/init.c' object='kern/riscv/efi/kernel_exec-init.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/riscv/efi/kernel_exec-init.o `test -f 'kern/riscv/efi/init.c' || echo '$(srcdir)/'`kern/riscv/efi/init.c
+
+kern/riscv/efi/kernel_exec-init.obj: kern/riscv/efi/init.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/riscv/efi/kernel_exec-init.obj -MD -MP -MF kern/riscv/efi/$(DEPDIR)/kernel_exec-init.Tpo -c -o kern/riscv/efi/kernel_exec-init.obj `if test -f 'kern/riscv/efi/init.c'; then $(CYGPATH_W) 'kern/riscv/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/riscv/efi/init.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/riscv/efi/$(DEPDIR)/kernel_exec-init.Tpo kern/riscv/efi/$(DEPDIR)/kernel_exec-init.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/riscv/efi/init.c' object='kern/riscv/efi/kernel_exec-init.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/riscv/efi/kernel_exec-init.obj `if test -f 'kern/riscv/efi/init.c'; then $(CYGPATH_W) 'kern/riscv/efi/init.c'; else $(CYGPATH_W) '$(srcdir)/kern/riscv/efi/init.c'; fi`
+
+kern/riscv/kernel_exec-cache.o: kern/riscv/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/riscv/kernel_exec-cache.o -MD -MP -MF kern/riscv/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/riscv/kernel_exec-cache.o `test -f 'kern/riscv/cache.c' || echo '$(srcdir)/'`kern/riscv/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/riscv/$(DEPDIR)/kernel_exec-cache.Tpo kern/riscv/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/riscv/cache.c' object='kern/riscv/kernel_exec-cache.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/riscv/kernel_exec-cache.o `test -f 'kern/riscv/cache.c' || echo '$(srcdir)/'`kern/riscv/cache.c
+
+kern/riscv/kernel_exec-cache.obj: kern/riscv/cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/riscv/kernel_exec-cache.obj -MD -MP -MF kern/riscv/$(DEPDIR)/kernel_exec-cache.Tpo -c -o kern/riscv/kernel_exec-cache.obj `if test -f 'kern/riscv/cache.c'; then $(CYGPATH_W) 'kern/riscv/cache.c'; else $(CYGPATH_W) '$(srcdir)/kern/riscv/cache.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/riscv/$(DEPDIR)/kernel_exec-cache.Tpo kern/riscv/$(DEPDIR)/kernel_exec-cache.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/riscv/cache.c' object='kern/riscv/kernel_exec-cache.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/riscv/kernel_exec-cache.obj `if test -f 'kern/riscv/cache.c'; then $(CYGPATH_W) 'kern/riscv/cache.c'; else $(CYGPATH_W) '$(srcdir)/kern/riscv/cache.c'; fi`
+
+kern/riscv/kernel_exec-dl.o: kern/riscv/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/riscv/kernel_exec-dl.o -MD -MP -MF kern/riscv/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/riscv/kernel_exec-dl.o `test -f 'kern/riscv/dl.c' || echo '$(srcdir)/'`kern/riscv/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/riscv/$(DEPDIR)/kernel_exec-dl.Tpo kern/riscv/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/riscv/dl.c' object='kern/riscv/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/riscv/kernel_exec-dl.o `test -f 'kern/riscv/dl.c' || echo '$(srcdir)/'`kern/riscv/dl.c
+
+kern/riscv/kernel_exec-dl.obj: kern/riscv/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/riscv/kernel_exec-dl.obj -MD -MP -MF kern/riscv/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/riscv/kernel_exec-dl.obj `if test -f 'kern/riscv/dl.c'; then $(CYGPATH_W) 'kern/riscv/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/riscv/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/riscv/$(DEPDIR)/kernel_exec-dl.Tpo kern/riscv/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/riscv/dl.c' object='kern/riscv/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/riscv/kernel_exec-dl.obj `if test -f 'kern/riscv/dl.c'; then $(CYGPATH_W) 'kern/riscv/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/riscv/dl.c'; fi`
+
+kern/sparc64/kernel_exec-dl.o: kern/sparc64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/sparc64/kernel_exec-dl.o -MD -MP -MF kern/sparc64/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/sparc64/kernel_exec-dl.o `test -f 'kern/sparc64/dl.c' || echo '$(srcdir)/'`kern/sparc64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/sparc64/$(DEPDIR)/kernel_exec-dl.Tpo kern/sparc64/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/sparc64/dl.c' object='kern/sparc64/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/sparc64/kernel_exec-dl.o `test -f 'kern/sparc64/dl.c' || echo '$(srcdir)/'`kern/sparc64/dl.c
+
+kern/sparc64/kernel_exec-dl.obj: kern/sparc64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/sparc64/kernel_exec-dl.obj -MD -MP -MF kern/sparc64/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/sparc64/kernel_exec-dl.obj `if test -f 'kern/sparc64/dl.c'; then $(CYGPATH_W) 'kern/sparc64/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/sparc64/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/sparc64/$(DEPDIR)/kernel_exec-dl.Tpo kern/sparc64/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/sparc64/dl.c' object='kern/sparc64/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/sparc64/kernel_exec-dl.obj `if test -f 'kern/sparc64/dl.c'; then $(CYGPATH_W) 'kern/sparc64/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/sparc64/dl.c'; fi`
+
+kern/sparc64/ieee1275/kernel_exec-ieee1275.o: kern/sparc64/ieee1275/ieee1275.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/sparc64/ieee1275/kernel_exec-ieee1275.o -MD -MP -MF kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Tpo -c -o kern/sparc64/ieee1275/kernel_exec-ieee1275.o `test -f 'kern/sparc64/ieee1275/ieee1275.c' || echo '$(srcdir)/'`kern/sparc64/ieee1275/ieee1275.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Tpo kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/sparc64/ieee1275/ieee1275.c' object='kern/sparc64/ieee1275/kernel_exec-ieee1275.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/sparc64/ieee1275/kernel_exec-ieee1275.o `test -f 'kern/sparc64/ieee1275/ieee1275.c' || echo '$(srcdir)/'`kern/sparc64/ieee1275/ieee1275.c
+
+kern/sparc64/ieee1275/kernel_exec-ieee1275.obj: kern/sparc64/ieee1275/ieee1275.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/sparc64/ieee1275/kernel_exec-ieee1275.obj -MD -MP -MF kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Tpo -c -o kern/sparc64/ieee1275/kernel_exec-ieee1275.obj `if test -f 'kern/sparc64/ieee1275/ieee1275.c'; then $(CYGPATH_W) 'kern/sparc64/ieee1275/ieee1275.c'; else $(CYGPATH_W) '$(srcdir)/kern/sparc64/ieee1275/ieee1275.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Tpo kern/sparc64/ieee1275/$(DEPDIR)/kernel_exec-ieee1275.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/sparc64/ieee1275/ieee1275.c' object='kern/sparc64/ieee1275/kernel_exec-ieee1275.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/sparc64/ieee1275/kernel_exec-ieee1275.obj `if test -f 'kern/sparc64/ieee1275/ieee1275.c'; then $(CYGPATH_W) 'kern/sparc64/ieee1275/ieee1275.c'; else $(CYGPATH_W) '$(srcdir)/kern/sparc64/ieee1275/ieee1275.c'; fi`
+
+disk/ieee1275/kernel_exec-obdisk.o: disk/ieee1275/obdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/ieee1275/kernel_exec-obdisk.o -MD -MP -MF disk/ieee1275/$(DEPDIR)/kernel_exec-obdisk.Tpo -c -o disk/ieee1275/kernel_exec-obdisk.o `test -f 'disk/ieee1275/obdisk.c' || echo '$(srcdir)/'`disk/ieee1275/obdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/ieee1275/$(DEPDIR)/kernel_exec-obdisk.Tpo disk/ieee1275/$(DEPDIR)/kernel_exec-obdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ieee1275/obdisk.c' object='disk/ieee1275/kernel_exec-obdisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/ieee1275/kernel_exec-obdisk.o `test -f 'disk/ieee1275/obdisk.c' || echo '$(srcdir)/'`disk/ieee1275/obdisk.c
+
+disk/ieee1275/kernel_exec-obdisk.obj: disk/ieee1275/obdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT disk/ieee1275/kernel_exec-obdisk.obj -MD -MP -MF disk/ieee1275/$(DEPDIR)/kernel_exec-obdisk.Tpo -c -o disk/ieee1275/kernel_exec-obdisk.obj `if test -f 'disk/ieee1275/obdisk.c'; then $(CYGPATH_W) 'disk/ieee1275/obdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/ieee1275/obdisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/ieee1275/$(DEPDIR)/kernel_exec-obdisk.Tpo disk/ieee1275/$(DEPDIR)/kernel_exec-obdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ieee1275/obdisk.c' object='disk/ieee1275/kernel_exec-obdisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o disk/ieee1275/kernel_exec-obdisk.obj `if test -f 'disk/ieee1275/obdisk.c'; then $(CYGPATH_W) 'disk/ieee1275/obdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/ieee1275/obdisk.c'; fi`
+
+kern/x86_64/kernel_exec-dl.o: kern/x86_64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/x86_64/kernel_exec-dl.o -MD -MP -MF kern/x86_64/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/x86_64/kernel_exec-dl.o `test -f 'kern/x86_64/dl.c' || echo '$(srcdir)/'`kern/x86_64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/x86_64/$(DEPDIR)/kernel_exec-dl.Tpo kern/x86_64/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/x86_64/dl.c' object='kern/x86_64/kernel_exec-dl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/x86_64/kernel_exec-dl.o `test -f 'kern/x86_64/dl.c' || echo '$(srcdir)/'`kern/x86_64/dl.c
+
+kern/x86_64/kernel_exec-dl.obj: kern/x86_64/dl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kern/x86_64/kernel_exec-dl.obj -MD -MP -MF kern/x86_64/$(DEPDIR)/kernel_exec-dl.Tpo -c -o kern/x86_64/kernel_exec-dl.obj `if test -f 'kern/x86_64/dl.c'; then $(CYGPATH_W) 'kern/x86_64/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/x86_64/dl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/x86_64/$(DEPDIR)/kernel_exec-dl.Tpo kern/x86_64/$(DEPDIR)/kernel_exec-dl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/x86_64/dl.c' object='kern/x86_64/kernel_exec-dl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kern/x86_64/kernel_exec-dl.obj `if test -f 'kern/x86_64/dl.c'; then $(CYGPATH_W) 'kern/x86_64/dl.c'; else $(CYGPATH_W) '$(srcdir)/kern/x86_64/dl.c'; fi`
+
+kernel_exec-symlist.o: symlist.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kernel_exec-symlist.o -MD -MP -MF $(DEPDIR)/kernel_exec-symlist.Tpo -c -o kernel_exec-symlist.o `test -f 'symlist.c' || echo '$(srcdir)/'`symlist.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kernel_exec-symlist.Tpo $(DEPDIR)/kernel_exec-symlist.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='symlist.c' object='kernel_exec-symlist.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kernel_exec-symlist.o `test -f 'symlist.c' || echo '$(srcdir)/'`symlist.c
+
+kernel_exec-symlist.obj: symlist.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -MT kernel_exec-symlist.obj -MD -MP -MF $(DEPDIR)/kernel_exec-symlist.Tpo -c -o kernel_exec-symlist.obj `if test -f 'symlist.c'; then $(CYGPATH_W) 'symlist.c'; else $(CYGPATH_W) '$(srcdir)/symlist.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kernel_exec-symlist.Tpo $(DEPDIR)/kernel_exec-symlist.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='symlist.c' object='kernel_exec-symlist.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kernel_exec_CPPFLAGS) $(CPPFLAGS) $(kernel_exec_CFLAGS) $(CFLAGS) -c -o kernel_exec-symlist.obj `if test -f 'symlist.c'; then $(CYGPATH_W) 'symlist.c'; else $(CYGPATH_W) '$(srcdir)/symlist.c'; fi`
+
+commands/keylayouts_module-keylayouts.o: commands/keylayouts.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $(keylayouts_module_CFLAGS) $(CFLAGS) -MT commands/keylayouts_module-keylayouts.o -MD -MP -MF commands/$(DEPDIR)/keylayouts_module-keylayouts.Tpo -c -o commands/keylayouts_module-keylayouts.o `test -f 'commands/keylayouts.c' || echo '$(srcdir)/'`commands/keylayouts.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/keylayouts_module-keylayouts.Tpo commands/$(DEPDIR)/keylayouts_module-keylayouts.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/keylayouts.c' object='commands/keylayouts_module-keylayouts.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $(keylayouts_module_CFLAGS) $(CFLAGS) -c -o commands/keylayouts_module-keylayouts.o `test -f 'commands/keylayouts.c' || echo '$(srcdir)/'`commands/keylayouts.c
+
+commands/keylayouts_module-keylayouts.obj: commands/keylayouts.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $(keylayouts_module_CFLAGS) $(CFLAGS) -MT commands/keylayouts_module-keylayouts.obj -MD -MP -MF commands/$(DEPDIR)/keylayouts_module-keylayouts.Tpo -c -o commands/keylayouts_module-keylayouts.obj `if test -f 'commands/keylayouts.c'; then $(CYGPATH_W) 'commands/keylayouts.c'; else $(CYGPATH_W) '$(srcdir)/commands/keylayouts.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/keylayouts_module-keylayouts.Tpo commands/$(DEPDIR)/keylayouts_module-keylayouts.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/keylayouts.c' object='commands/keylayouts_module-keylayouts.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $(keylayouts_module_CFLAGS) $(CFLAGS) -c -o commands/keylayouts_module-keylayouts.obj `if test -f 'commands/keylayouts.c'; then $(CYGPATH_W) 'commands/keylayouts.c'; else $(CYGPATH_W) '$(srcdir)/commands/keylayouts.c'; fi`
+
+commands/keystatus_module-keystatus.o: commands/keystatus.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keystatus_module_CPPFLAGS) $(CPPFLAGS) $(keystatus_module_CFLAGS) $(CFLAGS) -MT commands/keystatus_module-keystatus.o -MD -MP -MF commands/$(DEPDIR)/keystatus_module-keystatus.Tpo -c -o commands/keystatus_module-keystatus.o `test -f 'commands/keystatus.c' || echo '$(srcdir)/'`commands/keystatus.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/keystatus_module-keystatus.Tpo commands/$(DEPDIR)/keystatus_module-keystatus.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/keystatus.c' object='commands/keystatus_module-keystatus.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keystatus_module_CPPFLAGS) $(CPPFLAGS) $(keystatus_module_CFLAGS) $(CFLAGS) -c -o commands/keystatus_module-keystatus.o `test -f 'commands/keystatus.c' || echo '$(srcdir)/'`commands/keystatus.c
+
+commands/keystatus_module-keystatus.obj: commands/keystatus.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keystatus_module_CPPFLAGS) $(CPPFLAGS) $(keystatus_module_CFLAGS) $(CFLAGS) -MT commands/keystatus_module-keystatus.obj -MD -MP -MF commands/$(DEPDIR)/keystatus_module-keystatus.Tpo -c -o commands/keystatus_module-keystatus.obj `if test -f 'commands/keystatus.c'; then $(CYGPATH_W) 'commands/keystatus.c'; else $(CYGPATH_W) '$(srcdir)/commands/keystatus.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/keystatus_module-keystatus.Tpo commands/$(DEPDIR)/keystatus_module-keystatus.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/keystatus.c' object='commands/keystatus_module-keystatus.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keystatus_module_CPPFLAGS) $(CPPFLAGS) $(keystatus_module_CFLAGS) $(CFLAGS) -c -o commands/keystatus_module-keystatus.obj `if test -f 'commands/keystatus.c'; then $(CYGPATH_W) 'commands/keystatus.c'; else $(CYGPATH_W) '$(srcdir)/commands/keystatus.c'; fi`
+
+disk/ldm_module-ldm.o: disk/ldm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ldm_module_CPPFLAGS) $(CPPFLAGS) $(ldm_module_CFLAGS) $(CFLAGS) -MT disk/ldm_module-ldm.o -MD -MP -MF disk/$(DEPDIR)/ldm_module-ldm.Tpo -c -o disk/ldm_module-ldm.o `test -f 'disk/ldm.c' || echo '$(srcdir)/'`disk/ldm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/ldm_module-ldm.Tpo disk/$(DEPDIR)/ldm_module-ldm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ldm.c' object='disk/ldm_module-ldm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ldm_module_CPPFLAGS) $(CPPFLAGS) $(ldm_module_CFLAGS) $(CFLAGS) -c -o disk/ldm_module-ldm.o `test -f 'disk/ldm.c' || echo '$(srcdir)/'`disk/ldm.c
+
+disk/ldm_module-ldm.obj: disk/ldm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ldm_module_CPPFLAGS) $(CPPFLAGS) $(ldm_module_CFLAGS) $(CFLAGS) -MT disk/ldm_module-ldm.obj -MD -MP -MF disk/$(DEPDIR)/ldm_module-ldm.Tpo -c -o disk/ldm_module-ldm.obj `if test -f 'disk/ldm.c'; then $(CYGPATH_W) 'disk/ldm.c'; else $(CYGPATH_W) '$(srcdir)/disk/ldm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/ldm_module-ldm.Tpo disk/$(DEPDIR)/ldm_module-ldm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ldm.c' object='disk/ldm_module-ldm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ldm_module_CPPFLAGS) $(CPPFLAGS) $(ldm_module_CFLAGS) $(CFLAGS) -c -o disk/ldm_module-ldm.obj `if test -f 'disk/ldm.c'; then $(CYGPATH_W) 'disk/ldm.c'; else $(CYGPATH_W) '$(srcdir)/disk/ldm.c'; fi`
+
+tests/legacy_password_test_module-legacy_password_test.o: tests/legacy_password_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $(legacy_password_test_module_CFLAGS) $(CFLAGS) -MT tests/legacy_password_test_module-legacy_password_test.o -MD -MP -MF tests/$(DEPDIR)/legacy_password_test_module-legacy_password_test.Tpo -c -o tests/legacy_password_test_module-legacy_password_test.o `test -f 'tests/legacy_password_test.c' || echo '$(srcdir)/'`tests/legacy_password_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/legacy_password_test_module-legacy_password_test.Tpo tests/$(DEPDIR)/legacy_password_test_module-legacy_password_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/legacy_password_test.c' object='tests/legacy_password_test_module-legacy_password_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $(legacy_password_test_module_CFLAGS) $(CFLAGS) -c -o tests/legacy_password_test_module-legacy_password_test.o `test -f 'tests/legacy_password_test.c' || echo '$(srcdir)/'`tests/legacy_password_test.c
+
+tests/legacy_password_test_module-legacy_password_test.obj: tests/legacy_password_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $(legacy_password_test_module_CFLAGS) $(CFLAGS) -MT tests/legacy_password_test_module-legacy_password_test.obj -MD -MP -MF tests/$(DEPDIR)/legacy_password_test_module-legacy_password_test.Tpo -c -o tests/legacy_password_test_module-legacy_password_test.obj `if test -f 'tests/legacy_password_test.c'; then $(CYGPATH_W) 'tests/legacy_password_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/legacy_password_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/legacy_password_test_module-legacy_password_test.Tpo tests/$(DEPDIR)/legacy_password_test_module-legacy_password_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/legacy_password_test.c' object='tests/legacy_password_test_module-legacy_password_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $(legacy_password_test_module_CFLAGS) $(CFLAGS) -c -o tests/legacy_password_test_module-legacy_password_test.obj `if test -f 'tests/legacy_password_test.c'; then $(CYGPATH_W) 'tests/legacy_password_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/legacy_password_test.c'; fi`
+
+lib/i386/pc/legacycfg_module-vesa_modes_table.o: lib/i386/pc/vesa_modes_table.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -MT lib/i386/pc/legacycfg_module-vesa_modes_table.o -MD -MP -MF lib/i386/pc/$(DEPDIR)/legacycfg_module-vesa_modes_table.Tpo -c -o lib/i386/pc/legacycfg_module-vesa_modes_table.o `test -f 'lib/i386/pc/vesa_modes_table.c' || echo '$(srcdir)/'`lib/i386/pc/vesa_modes_table.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/pc/$(DEPDIR)/legacycfg_module-vesa_modes_table.Tpo lib/i386/pc/$(DEPDIR)/legacycfg_module-vesa_modes_table.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/pc/vesa_modes_table.c' object='lib/i386/pc/legacycfg_module-vesa_modes_table.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -c -o lib/i386/pc/legacycfg_module-vesa_modes_table.o `test -f 'lib/i386/pc/vesa_modes_table.c' || echo '$(srcdir)/'`lib/i386/pc/vesa_modes_table.c
+
+lib/i386/pc/legacycfg_module-vesa_modes_table.obj: lib/i386/pc/vesa_modes_table.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -MT lib/i386/pc/legacycfg_module-vesa_modes_table.obj -MD -MP -MF lib/i386/pc/$(DEPDIR)/legacycfg_module-vesa_modes_table.Tpo -c -o lib/i386/pc/legacycfg_module-vesa_modes_table.obj `if test -f 'lib/i386/pc/vesa_modes_table.c'; then $(CYGPATH_W) 'lib/i386/pc/vesa_modes_table.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/pc/vesa_modes_table.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/pc/$(DEPDIR)/legacycfg_module-vesa_modes_table.Tpo lib/i386/pc/$(DEPDIR)/legacycfg_module-vesa_modes_table.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/pc/vesa_modes_table.c' object='lib/i386/pc/legacycfg_module-vesa_modes_table.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -c -o lib/i386/pc/legacycfg_module-vesa_modes_table.obj `if test -f 'lib/i386/pc/vesa_modes_table.c'; then $(CYGPATH_W) 'lib/i386/pc/vesa_modes_table.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/pc/vesa_modes_table.c'; fi`
+
+commands/legacycfg_module-legacycfg.o: commands/legacycfg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -MT commands/legacycfg_module-legacycfg.o -MD -MP -MF commands/$(DEPDIR)/legacycfg_module-legacycfg.Tpo -c -o commands/legacycfg_module-legacycfg.o `test -f 'commands/legacycfg.c' || echo '$(srcdir)/'`commands/legacycfg.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/legacycfg_module-legacycfg.Tpo commands/$(DEPDIR)/legacycfg_module-legacycfg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/legacycfg.c' object='commands/legacycfg_module-legacycfg.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -c -o commands/legacycfg_module-legacycfg.o `test -f 'commands/legacycfg.c' || echo '$(srcdir)/'`commands/legacycfg.c
+
+commands/legacycfg_module-legacycfg.obj: commands/legacycfg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -MT commands/legacycfg_module-legacycfg.obj -MD -MP -MF commands/$(DEPDIR)/legacycfg_module-legacycfg.Tpo -c -o commands/legacycfg_module-legacycfg.obj `if test -f 'commands/legacycfg.c'; then $(CYGPATH_W) 'commands/legacycfg.c'; else $(CYGPATH_W) '$(srcdir)/commands/legacycfg.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/legacycfg_module-legacycfg.Tpo commands/$(DEPDIR)/legacycfg_module-legacycfg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/legacycfg.c' object='commands/legacycfg_module-legacycfg.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -c -o commands/legacycfg_module-legacycfg.obj `if test -f 'commands/legacycfg.c'; then $(CYGPATH_W) 'commands/legacycfg.c'; else $(CYGPATH_W) '$(srcdir)/commands/legacycfg.c'; fi`
+
+lib/legacycfg_module-legacy_parse.o: lib/legacy_parse.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -MT lib/legacycfg_module-legacy_parse.o -MD -MP -MF lib/$(DEPDIR)/legacycfg_module-legacy_parse.Tpo -c -o lib/legacycfg_module-legacy_parse.o `test -f 'lib/legacy_parse.c' || echo '$(srcdir)/'`lib/legacy_parse.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/legacycfg_module-legacy_parse.Tpo lib/$(DEPDIR)/legacycfg_module-legacy_parse.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/legacy_parse.c' object='lib/legacycfg_module-legacy_parse.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -c -o lib/legacycfg_module-legacy_parse.o `test -f 'lib/legacy_parse.c' || echo '$(srcdir)/'`lib/legacy_parse.c
+
+lib/legacycfg_module-legacy_parse.obj: lib/legacy_parse.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -MT lib/legacycfg_module-legacy_parse.obj -MD -MP -MF lib/$(DEPDIR)/legacycfg_module-legacy_parse.Tpo -c -o lib/legacycfg_module-legacy_parse.obj `if test -f 'lib/legacy_parse.c'; then $(CYGPATH_W) 'lib/legacy_parse.c'; else $(CYGPATH_W) '$(srcdir)/lib/legacy_parse.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/legacycfg_module-legacy_parse.Tpo lib/$(DEPDIR)/legacycfg_module-legacy_parse.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/legacy_parse.c' object='lib/legacycfg_module-legacy_parse.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $(legacycfg_module_CFLAGS) $(CFLAGS) -c -o lib/legacycfg_module-legacy_parse.obj `if test -f 'lib/legacy_parse.c'; then $(CYGPATH_W) 'lib/legacy_parse.c'; else $(CYGPATH_W) '$(srcdir)/lib/legacy_parse.c'; fi`
+
+loader/arm64/linux_module-linux.o: loader/arm64/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/arm64/linux_module-linux.o -MD -MP -MF loader/arm64/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/arm64/linux_module-linux.o `test -f 'loader/arm64/linux.c' || echo '$(srcdir)/'`loader/arm64/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/arm64/$(DEPDIR)/linux_module-linux.Tpo loader/arm64/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/arm64/linux.c' object='loader/arm64/linux_module-linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/arm64/linux_module-linux.o `test -f 'loader/arm64/linux.c' || echo '$(srcdir)/'`loader/arm64/linux.c
+
+loader/arm64/linux_module-linux.obj: loader/arm64/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/arm64/linux_module-linux.obj -MD -MP -MF loader/arm64/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/arm64/linux_module-linux.obj `if test -f 'loader/arm64/linux.c'; then $(CYGPATH_W) 'loader/arm64/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/arm64/linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/arm64/$(DEPDIR)/linux_module-linux.Tpo loader/arm64/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/arm64/linux.c' object='loader/arm64/linux_module-linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/arm64/linux_module-linux.obj `if test -f 'loader/arm64/linux.c'; then $(CYGPATH_W) 'loader/arm64/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/arm64/linux.c'; fi`
+
+loader/linux_module-linux.o: loader/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/linux_module-linux.o -MD -MP -MF loader/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/linux_module-linux.o `test -f 'loader/linux.c' || echo '$(srcdir)/'`loader/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/linux_module-linux.Tpo loader/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/linux.c' object='loader/linux_module-linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/linux_module-linux.o `test -f 'loader/linux.c' || echo '$(srcdir)/'`loader/linux.c
+
+loader/linux_module-linux.obj: loader/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/linux_module-linux.obj -MD -MP -MF loader/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/linux_module-linux.obj `if test -f 'loader/linux.c'; then $(CYGPATH_W) 'loader/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/linux_module-linux.Tpo loader/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/linux.c' object='loader/linux_module-linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/linux_module-linux.obj `if test -f 'loader/linux.c'; then $(CYGPATH_W) 'loader/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/linux.c'; fi`
+
+lib/linux_module-cmdline.o: lib/cmdline.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT lib/linux_module-cmdline.o -MD -MP -MF lib/$(DEPDIR)/linux_module-cmdline.Tpo -c -o lib/linux_module-cmdline.o `test -f 'lib/cmdline.c' || echo '$(srcdir)/'`lib/cmdline.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/linux_module-cmdline.Tpo lib/$(DEPDIR)/linux_module-cmdline.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/cmdline.c' object='lib/linux_module-cmdline.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o lib/linux_module-cmdline.o `test -f 'lib/cmdline.c' || echo '$(srcdir)/'`lib/cmdline.c
+
+lib/linux_module-cmdline.obj: lib/cmdline.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT lib/linux_module-cmdline.obj -MD -MP -MF lib/$(DEPDIR)/linux_module-cmdline.Tpo -c -o lib/linux_module-cmdline.obj `if test -f 'lib/cmdline.c'; then $(CYGPATH_W) 'lib/cmdline.c'; else $(CYGPATH_W) '$(srcdir)/lib/cmdline.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/linux_module-cmdline.Tpo lib/$(DEPDIR)/linux_module-cmdline.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/cmdline.c' object='lib/linux_module-cmdline.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o lib/linux_module-cmdline.obj `if test -f 'lib/cmdline.c'; then $(CYGPATH_W) 'lib/cmdline.c'; else $(CYGPATH_W) '$(srcdir)/lib/cmdline.c'; fi`
+
+loader/arm/linux_module-linux.o: loader/arm/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/arm/linux_module-linux.o -MD -MP -MF loader/arm/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/arm/linux_module-linux.o `test -f 'loader/arm/linux.c' || echo '$(srcdir)/'`loader/arm/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/arm/$(DEPDIR)/linux_module-linux.Tpo loader/arm/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/arm/linux.c' object='loader/arm/linux_module-linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/arm/linux_module-linux.o `test -f 'loader/arm/linux.c' || echo '$(srcdir)/'`loader/arm/linux.c
+
+loader/arm/linux_module-linux.obj: loader/arm/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/arm/linux_module-linux.obj -MD -MP -MF loader/arm/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/arm/linux_module-linux.obj `if test -f 'loader/arm/linux.c'; then $(CYGPATH_W) 'loader/arm/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/arm/linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/arm/$(DEPDIR)/linux_module-linux.Tpo loader/arm/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/arm/linux.c' object='loader/arm/linux_module-linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/arm/linux_module-linux.obj `if test -f 'loader/arm/linux.c'; then $(CYGPATH_W) 'loader/arm/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/arm/linux.c'; fi`
+
+loader/i386/linux_module-linux.o: loader/i386/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/i386/linux_module-linux.o -MD -MP -MF loader/i386/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/i386/linux_module-linux.o `test -f 'loader/i386/linux.c' || echo '$(srcdir)/'`loader/i386/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/linux_module-linux.Tpo loader/i386/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/linux.c' object='loader/i386/linux_module-linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/i386/linux_module-linux.o `test -f 'loader/i386/linux.c' || echo '$(srcdir)/'`loader/i386/linux.c
+
+loader/i386/linux_module-linux.obj: loader/i386/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/i386/linux_module-linux.obj -MD -MP -MF loader/i386/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/i386/linux_module-linux.obj `if test -f 'loader/i386/linux.c'; then $(CYGPATH_W) 'loader/i386/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/linux_module-linux.Tpo loader/i386/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/linux.c' object='loader/i386/linux_module-linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/i386/linux_module-linux.obj `if test -f 'loader/i386/linux.c'; then $(CYGPATH_W) 'loader/i386/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/linux.c'; fi`
+
+lib/i386/pc/linux_module-vesa_modes_table.o: lib/i386/pc/vesa_modes_table.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT lib/i386/pc/linux_module-vesa_modes_table.o -MD -MP -MF lib/i386/pc/$(DEPDIR)/linux_module-vesa_modes_table.Tpo -c -o lib/i386/pc/linux_module-vesa_modes_table.o `test -f 'lib/i386/pc/vesa_modes_table.c' || echo '$(srcdir)/'`lib/i386/pc/vesa_modes_table.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/pc/$(DEPDIR)/linux_module-vesa_modes_table.Tpo lib/i386/pc/$(DEPDIR)/linux_module-vesa_modes_table.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/pc/vesa_modes_table.c' object='lib/i386/pc/linux_module-vesa_modes_table.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o lib/i386/pc/linux_module-vesa_modes_table.o `test -f 'lib/i386/pc/vesa_modes_table.c' || echo '$(srcdir)/'`lib/i386/pc/vesa_modes_table.c
+
+lib/i386/pc/linux_module-vesa_modes_table.obj: lib/i386/pc/vesa_modes_table.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT lib/i386/pc/linux_module-vesa_modes_table.obj -MD -MP -MF lib/i386/pc/$(DEPDIR)/linux_module-vesa_modes_table.Tpo -c -o lib/i386/pc/linux_module-vesa_modes_table.obj `if test -f 'lib/i386/pc/vesa_modes_table.c'; then $(CYGPATH_W) 'lib/i386/pc/vesa_modes_table.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/pc/vesa_modes_table.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/pc/$(DEPDIR)/linux_module-vesa_modes_table.Tpo lib/i386/pc/$(DEPDIR)/linux_module-vesa_modes_table.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/pc/vesa_modes_table.c' object='lib/i386/pc/linux_module-vesa_modes_table.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o lib/i386/pc/linux_module-vesa_modes_table.obj `if test -f 'lib/i386/pc/vesa_modes_table.c'; then $(CYGPATH_W) 'lib/i386/pc/vesa_modes_table.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/pc/vesa_modes_table.c'; fi`
+
+loader/i386/linux_module-xen.o: loader/i386/xen.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/i386/linux_module-xen.o -MD -MP -MF loader/i386/$(DEPDIR)/linux_module-xen.Tpo -c -o loader/i386/linux_module-xen.o `test -f 'loader/i386/xen.c' || echo '$(srcdir)/'`loader/i386/xen.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/linux_module-xen.Tpo loader/i386/$(DEPDIR)/linux_module-xen.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/xen.c' object='loader/i386/linux_module-xen.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/i386/linux_module-xen.o `test -f 'loader/i386/xen.c' || echo '$(srcdir)/'`loader/i386/xen.c
+
+loader/i386/linux_module-xen.obj: loader/i386/xen.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/i386/linux_module-xen.obj -MD -MP -MF loader/i386/$(DEPDIR)/linux_module-xen.Tpo -c -o loader/i386/linux_module-xen.obj `if test -f 'loader/i386/xen.c'; then $(CYGPATH_W) 'loader/i386/xen.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/xen.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/linux_module-xen.Tpo loader/i386/$(DEPDIR)/linux_module-xen.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/xen.c' object='loader/i386/linux_module-xen.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/i386/linux_module-xen.obj `if test -f 'loader/i386/xen.c'; then $(CYGPATH_W) 'loader/i386/xen.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/xen.c'; fi`
+
+loader/ia64/efi/linux_module-linux.o: loader/ia64/efi/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/ia64/efi/linux_module-linux.o -MD -MP -MF loader/ia64/efi/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/ia64/efi/linux_module-linux.o `test -f 'loader/ia64/efi/linux.c' || echo '$(srcdir)/'`loader/ia64/efi/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/ia64/efi/$(DEPDIR)/linux_module-linux.Tpo loader/ia64/efi/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/ia64/efi/linux.c' object='loader/ia64/efi/linux_module-linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/ia64/efi/linux_module-linux.o `test -f 'loader/ia64/efi/linux.c' || echo '$(srcdir)/'`loader/ia64/efi/linux.c
+
+loader/ia64/efi/linux_module-linux.obj: loader/ia64/efi/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/ia64/efi/linux_module-linux.obj -MD -MP -MF loader/ia64/efi/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/ia64/efi/linux_module-linux.obj `if test -f 'loader/ia64/efi/linux.c'; then $(CYGPATH_W) 'loader/ia64/efi/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/ia64/efi/linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/ia64/efi/$(DEPDIR)/linux_module-linux.Tpo loader/ia64/efi/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/ia64/efi/linux.c' object='loader/ia64/efi/linux_module-linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/ia64/efi/linux_module-linux.obj `if test -f 'loader/ia64/efi/linux.c'; then $(CYGPATH_W) 'loader/ia64/efi/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/ia64/efi/linux.c'; fi`
+
+loader/mips/linux_module-linux.o: loader/mips/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/mips/linux_module-linux.o -MD -MP -MF loader/mips/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/mips/linux_module-linux.o `test -f 'loader/mips/linux.c' || echo '$(srcdir)/'`loader/mips/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/mips/$(DEPDIR)/linux_module-linux.Tpo loader/mips/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/mips/linux.c' object='loader/mips/linux_module-linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/mips/linux_module-linux.o `test -f 'loader/mips/linux.c' || echo '$(srcdir)/'`loader/mips/linux.c
+
+loader/mips/linux_module-linux.obj: loader/mips/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/mips/linux_module-linux.obj -MD -MP -MF loader/mips/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/mips/linux_module-linux.obj `if test -f 'loader/mips/linux.c'; then $(CYGPATH_W) 'loader/mips/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/mips/linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/mips/$(DEPDIR)/linux_module-linux.Tpo loader/mips/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/mips/linux.c' object='loader/mips/linux_module-linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/mips/linux_module-linux.obj `if test -f 'loader/mips/linux.c'; then $(CYGPATH_W) 'loader/mips/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/mips/linux.c'; fi`
+
+loader/powerpc/ieee1275/linux_module-linux.o: loader/powerpc/ieee1275/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/powerpc/ieee1275/linux_module-linux.o -MD -MP -MF loader/powerpc/ieee1275/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/powerpc/ieee1275/linux_module-linux.o `test -f 'loader/powerpc/ieee1275/linux.c' || echo '$(srcdir)/'`loader/powerpc/ieee1275/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/powerpc/ieee1275/$(DEPDIR)/linux_module-linux.Tpo loader/powerpc/ieee1275/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/powerpc/ieee1275/linux.c' object='loader/powerpc/ieee1275/linux_module-linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/powerpc/ieee1275/linux_module-linux.o `test -f 'loader/powerpc/ieee1275/linux.c' || echo '$(srcdir)/'`loader/powerpc/ieee1275/linux.c
+
+loader/powerpc/ieee1275/linux_module-linux.obj: loader/powerpc/ieee1275/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/powerpc/ieee1275/linux_module-linux.obj -MD -MP -MF loader/powerpc/ieee1275/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/powerpc/ieee1275/linux_module-linux.obj `if test -f 'loader/powerpc/ieee1275/linux.c'; then $(CYGPATH_W) 'loader/powerpc/ieee1275/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/powerpc/ieee1275/linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/powerpc/ieee1275/$(DEPDIR)/linux_module-linux.Tpo loader/powerpc/ieee1275/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/powerpc/ieee1275/linux.c' object='loader/powerpc/ieee1275/linux_module-linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/powerpc/ieee1275/linux_module-linux.obj `if test -f 'loader/powerpc/ieee1275/linux.c'; then $(CYGPATH_W) 'loader/powerpc/ieee1275/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/powerpc/ieee1275/linux.c'; fi`
+
+loader/riscv/linux_module-linux.o: loader/riscv/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/riscv/linux_module-linux.o -MD -MP -MF loader/riscv/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/riscv/linux_module-linux.o `test -f 'loader/riscv/linux.c' || echo '$(srcdir)/'`loader/riscv/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/riscv/$(DEPDIR)/linux_module-linux.Tpo loader/riscv/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/riscv/linux.c' object='loader/riscv/linux_module-linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/riscv/linux_module-linux.o `test -f 'loader/riscv/linux.c' || echo '$(srcdir)/'`loader/riscv/linux.c
+
+loader/riscv/linux_module-linux.obj: loader/riscv/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/riscv/linux_module-linux.obj -MD -MP -MF loader/riscv/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/riscv/linux_module-linux.obj `if test -f 'loader/riscv/linux.c'; then $(CYGPATH_W) 'loader/riscv/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/riscv/linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/riscv/$(DEPDIR)/linux_module-linux.Tpo loader/riscv/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/riscv/linux.c' object='loader/riscv/linux_module-linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/riscv/linux_module-linux.obj `if test -f 'loader/riscv/linux.c'; then $(CYGPATH_W) 'loader/riscv/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/riscv/linux.c'; fi`
+
+loader/sparc64/ieee1275/linux_module-linux.o: loader/sparc64/ieee1275/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/sparc64/ieee1275/linux_module-linux.o -MD -MP -MF loader/sparc64/ieee1275/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/sparc64/ieee1275/linux_module-linux.o `test -f 'loader/sparc64/ieee1275/linux.c' || echo '$(srcdir)/'`loader/sparc64/ieee1275/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/sparc64/ieee1275/$(DEPDIR)/linux_module-linux.Tpo loader/sparc64/ieee1275/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/sparc64/ieee1275/linux.c' object='loader/sparc64/ieee1275/linux_module-linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/sparc64/ieee1275/linux_module-linux.o `test -f 'loader/sparc64/ieee1275/linux.c' || echo '$(srcdir)/'`loader/sparc64/ieee1275/linux.c
+
+loader/sparc64/ieee1275/linux_module-linux.obj: loader/sparc64/ieee1275/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -MT loader/sparc64/ieee1275/linux_module-linux.obj -MD -MP -MF loader/sparc64/ieee1275/$(DEPDIR)/linux_module-linux.Tpo -c -o loader/sparc64/ieee1275/linux_module-linux.obj `if test -f 'loader/sparc64/ieee1275/linux.c'; then $(CYGPATH_W) 'loader/sparc64/ieee1275/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/sparc64/ieee1275/linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/sparc64/ieee1275/$(DEPDIR)/linux_module-linux.Tpo loader/sparc64/ieee1275/$(DEPDIR)/linux_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/sparc64/ieee1275/linux.c' object='loader/sparc64/ieee1275/linux_module-linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $(linux_module_CFLAGS) $(CFLAGS) -c -o loader/sparc64/ieee1275/linux_module-linux.obj `if test -f 'loader/sparc64/ieee1275/linux.c'; then $(CYGPATH_W) 'loader/sparc64/ieee1275/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/sparc64/ieee1275/linux.c'; fi`
+
+loader/i386/pc/linux16_module-linux.o: loader/i386/pc/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $(linux16_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/linux16_module-linux.o -MD -MP -MF loader/i386/pc/$(DEPDIR)/linux16_module-linux.Tpo -c -o loader/i386/pc/linux16_module-linux.o `test -f 'loader/i386/pc/linux.c' || echo '$(srcdir)/'`loader/i386/pc/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/linux16_module-linux.Tpo loader/i386/pc/$(DEPDIR)/linux16_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/linux.c' object='loader/i386/pc/linux16_module-linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $(linux16_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/linux16_module-linux.o `test -f 'loader/i386/pc/linux.c' || echo '$(srcdir)/'`loader/i386/pc/linux.c
+
+loader/i386/pc/linux16_module-linux.obj: loader/i386/pc/linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $(linux16_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/linux16_module-linux.obj -MD -MP -MF loader/i386/pc/$(DEPDIR)/linux16_module-linux.Tpo -c -o loader/i386/pc/linux16_module-linux.obj `if test -f 'loader/i386/pc/linux.c'; then $(CYGPATH_W) 'loader/i386/pc/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/linux16_module-linux.Tpo loader/i386/pc/$(DEPDIR)/linux16_module-linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/linux.c' object='loader/i386/pc/linux16_module-linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $(linux16_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/linux16_module-linux.obj `if test -f 'loader/i386/pc/linux.c'; then $(CYGPATH_W) 'loader/i386/pc/linux.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/linux.c'; fi`
+
+commands/efi/loadbios_module-loadbios.o: commands/efi/loadbios.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadbios_module_CPPFLAGS) $(CPPFLAGS) $(loadbios_module_CFLAGS) $(CFLAGS) -MT commands/efi/loadbios_module-loadbios.o -MD -MP -MF commands/efi/$(DEPDIR)/loadbios_module-loadbios.Tpo -c -o commands/efi/loadbios_module-loadbios.o `test -f 'commands/efi/loadbios.c' || echo '$(srcdir)/'`commands/efi/loadbios.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/loadbios_module-loadbios.Tpo commands/efi/$(DEPDIR)/loadbios_module-loadbios.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/loadbios.c' object='commands/efi/loadbios_module-loadbios.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadbios_module_CPPFLAGS) $(CPPFLAGS) $(loadbios_module_CFLAGS) $(CFLAGS) -c -o commands/efi/loadbios_module-loadbios.o `test -f 'commands/efi/loadbios.c' || echo '$(srcdir)/'`commands/efi/loadbios.c
+
+commands/efi/loadbios_module-loadbios.obj: commands/efi/loadbios.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadbios_module_CPPFLAGS) $(CPPFLAGS) $(loadbios_module_CFLAGS) $(CFLAGS) -MT commands/efi/loadbios_module-loadbios.obj -MD -MP -MF commands/efi/$(DEPDIR)/loadbios_module-loadbios.Tpo -c -o commands/efi/loadbios_module-loadbios.obj `if test -f 'commands/efi/loadbios.c'; then $(CYGPATH_W) 'commands/efi/loadbios.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/loadbios.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/loadbios_module-loadbios.Tpo commands/efi/$(DEPDIR)/loadbios_module-loadbios.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/loadbios.c' object='commands/efi/loadbios_module-loadbios.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadbios_module_CPPFLAGS) $(CPPFLAGS) $(loadbios_module_CFLAGS) $(CFLAGS) -c -o commands/efi/loadbios_module-loadbios.obj `if test -f 'commands/efi/loadbios.c'; then $(CYGPATH_W) 'commands/efi/loadbios.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/loadbios.c'; fi`
+
+commands/loadenv_module-loadenv.o: commands/loadenv.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadenv_module_CPPFLAGS) $(CPPFLAGS) $(loadenv_module_CFLAGS) $(CFLAGS) -MT commands/loadenv_module-loadenv.o -MD -MP -MF commands/$(DEPDIR)/loadenv_module-loadenv.Tpo -c -o commands/loadenv_module-loadenv.o `test -f 'commands/loadenv.c' || echo '$(srcdir)/'`commands/loadenv.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/loadenv_module-loadenv.Tpo commands/$(DEPDIR)/loadenv_module-loadenv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/loadenv.c' object='commands/loadenv_module-loadenv.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadenv_module_CPPFLAGS) $(CPPFLAGS) $(loadenv_module_CFLAGS) $(CFLAGS) -c -o commands/loadenv_module-loadenv.o `test -f 'commands/loadenv.c' || echo '$(srcdir)/'`commands/loadenv.c
+
+commands/loadenv_module-loadenv.obj: commands/loadenv.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadenv_module_CPPFLAGS) $(CPPFLAGS) $(loadenv_module_CFLAGS) $(CFLAGS) -MT commands/loadenv_module-loadenv.obj -MD -MP -MF commands/$(DEPDIR)/loadenv_module-loadenv.Tpo -c -o commands/loadenv_module-loadenv.obj `if test -f 'commands/loadenv.c'; then $(CYGPATH_W) 'commands/loadenv.c'; else $(CYGPATH_W) '$(srcdir)/commands/loadenv.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/loadenv_module-loadenv.Tpo commands/$(DEPDIR)/loadenv_module-loadenv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/loadenv.c' object='commands/loadenv_module-loadenv.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadenv_module_CPPFLAGS) $(CPPFLAGS) $(loadenv_module_CFLAGS) $(CFLAGS) -c -o commands/loadenv_module-loadenv.obj `if test -f 'commands/loadenv.c'; then $(CYGPATH_W) 'commands/loadenv.c'; else $(CYGPATH_W) '$(srcdir)/commands/loadenv.c'; fi`
+
+lib/loadenv_module-envblk.o: lib/envblk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadenv_module_CPPFLAGS) $(CPPFLAGS) $(loadenv_module_CFLAGS) $(CFLAGS) -MT lib/loadenv_module-envblk.o -MD -MP -MF lib/$(DEPDIR)/loadenv_module-envblk.Tpo -c -o lib/loadenv_module-envblk.o `test -f 'lib/envblk.c' || echo '$(srcdir)/'`lib/envblk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/loadenv_module-envblk.Tpo lib/$(DEPDIR)/loadenv_module-envblk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/envblk.c' object='lib/loadenv_module-envblk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadenv_module_CPPFLAGS) $(CPPFLAGS) $(loadenv_module_CFLAGS) $(CFLAGS) -c -o lib/loadenv_module-envblk.o `test -f 'lib/envblk.c' || echo '$(srcdir)/'`lib/envblk.c
+
+lib/loadenv_module-envblk.obj: lib/envblk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadenv_module_CPPFLAGS) $(CPPFLAGS) $(loadenv_module_CFLAGS) $(CFLAGS) -MT lib/loadenv_module-envblk.obj -MD -MP -MF lib/$(DEPDIR)/loadenv_module-envblk.Tpo -c -o lib/loadenv_module-envblk.obj `if test -f 'lib/envblk.c'; then $(CYGPATH_W) 'lib/envblk.c'; else $(CYGPATH_W) '$(srcdir)/lib/envblk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/loadenv_module-envblk.Tpo lib/$(DEPDIR)/loadenv_module-envblk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/envblk.c' object='lib/loadenv_module-envblk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadenv_module_CPPFLAGS) $(CPPFLAGS) $(loadenv_module_CFLAGS) $(CFLAGS) -c -o lib/loadenv_module-envblk.obj `if test -f 'lib/envblk.c'; then $(CYGPATH_W) 'lib/envblk.c'; else $(CYGPATH_W) '$(srcdir)/lib/envblk.c'; fi`
+
+disk/loopback_module-loopback.o: disk/loopback.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loopback_module_CPPFLAGS) $(CPPFLAGS) $(loopback_module_CFLAGS) $(CFLAGS) -MT disk/loopback_module-loopback.o -MD -MP -MF disk/$(DEPDIR)/loopback_module-loopback.Tpo -c -o disk/loopback_module-loopback.o `test -f 'disk/loopback.c' || echo '$(srcdir)/'`disk/loopback.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/loopback_module-loopback.Tpo disk/$(DEPDIR)/loopback_module-loopback.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/loopback.c' object='disk/loopback_module-loopback.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loopback_module_CPPFLAGS) $(CPPFLAGS) $(loopback_module_CFLAGS) $(CFLAGS) -c -o disk/loopback_module-loopback.o `test -f 'disk/loopback.c' || echo '$(srcdir)/'`disk/loopback.c
+
+disk/loopback_module-loopback.obj: disk/loopback.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loopback_module_CPPFLAGS) $(CPPFLAGS) $(loopback_module_CFLAGS) $(CFLAGS) -MT disk/loopback_module-loopback.obj -MD -MP -MF disk/$(DEPDIR)/loopback_module-loopback.Tpo -c -o disk/loopback_module-loopback.obj `if test -f 'disk/loopback.c'; then $(CYGPATH_W) 'disk/loopback.c'; else $(CYGPATH_W) '$(srcdir)/disk/loopback.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/loopback_module-loopback.Tpo disk/$(DEPDIR)/loopback_module-loopback.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/loopback.c' object='disk/loopback_module-loopback.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loopback_module_CPPFLAGS) $(CPPFLAGS) $(loopback_module_CFLAGS) $(CFLAGS) -c -o disk/loopback_module-loopback.obj `if test -f 'disk/loopback.c'; then $(CYGPATH_W) 'disk/loopback.c'; else $(CYGPATH_W) '$(srcdir)/disk/loopback.c'; fi`
+
+commands/ls_module-ls.o: commands/ls.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ls_module_CPPFLAGS) $(CPPFLAGS) $(ls_module_CFLAGS) $(CFLAGS) -MT commands/ls_module-ls.o -MD -MP -MF commands/$(DEPDIR)/ls_module-ls.Tpo -c -o commands/ls_module-ls.o `test -f 'commands/ls.c' || echo '$(srcdir)/'`commands/ls.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/ls_module-ls.Tpo commands/$(DEPDIR)/ls_module-ls.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/ls.c' object='commands/ls_module-ls.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ls_module_CPPFLAGS) $(CPPFLAGS) $(ls_module_CFLAGS) $(CFLAGS) -c -o commands/ls_module-ls.o `test -f 'commands/ls.c' || echo '$(srcdir)/'`commands/ls.c
+
+commands/ls_module-ls.obj: commands/ls.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ls_module_CPPFLAGS) $(CPPFLAGS) $(ls_module_CFLAGS) $(CFLAGS) -MT commands/ls_module-ls.obj -MD -MP -MF commands/$(DEPDIR)/ls_module-ls.Tpo -c -o commands/ls_module-ls.obj `if test -f 'commands/ls.c'; then $(CYGPATH_W) 'commands/ls.c'; else $(CYGPATH_W) '$(srcdir)/commands/ls.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/ls_module-ls.Tpo commands/$(DEPDIR)/ls_module-ls.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/ls.c' object='commands/ls_module-ls.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ls_module_CPPFLAGS) $(CPPFLAGS) $(ls_module_CFLAGS) $(CFLAGS) -c -o commands/ls_module-ls.obj `if test -f 'commands/ls.c'; then $(CYGPATH_W) 'commands/ls.c'; else $(CYGPATH_W) '$(srcdir)/commands/ls.c'; fi`
+
+commands/lsacpi_module-lsacpi.o: commands/lsacpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $(lsacpi_module_CFLAGS) $(CFLAGS) -MT commands/lsacpi_module-lsacpi.o -MD -MP -MF commands/$(DEPDIR)/lsacpi_module-lsacpi.Tpo -c -o commands/lsacpi_module-lsacpi.o `test -f 'commands/lsacpi.c' || echo '$(srcdir)/'`commands/lsacpi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/lsacpi_module-lsacpi.Tpo commands/$(DEPDIR)/lsacpi_module-lsacpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/lsacpi.c' object='commands/lsacpi_module-lsacpi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $(lsacpi_module_CFLAGS) $(CFLAGS) -c -o commands/lsacpi_module-lsacpi.o `test -f 'commands/lsacpi.c' || echo '$(srcdir)/'`commands/lsacpi.c
+
+commands/lsacpi_module-lsacpi.obj: commands/lsacpi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $(lsacpi_module_CFLAGS) $(CFLAGS) -MT commands/lsacpi_module-lsacpi.obj -MD -MP -MF commands/$(DEPDIR)/lsacpi_module-lsacpi.Tpo -c -o commands/lsacpi_module-lsacpi.obj `if test -f 'commands/lsacpi.c'; then $(CYGPATH_W) 'commands/lsacpi.c'; else $(CYGPATH_W) '$(srcdir)/commands/lsacpi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/lsacpi_module-lsacpi.Tpo commands/$(DEPDIR)/lsacpi_module-lsacpi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/lsacpi.c' object='commands/lsacpi_module-lsacpi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $(lsacpi_module_CFLAGS) $(CFLAGS) -c -o commands/lsacpi_module-lsacpi.obj `if test -f 'commands/lsacpi.c'; then $(CYGPATH_W) 'commands/lsacpi.c'; else $(CYGPATH_W) '$(srcdir)/commands/lsacpi.c'; fi`
+
+commands/i386/pc/lsapm_module-lsapm.o: commands/i386/pc/lsapm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsapm_module_CPPFLAGS) $(CPPFLAGS) $(lsapm_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/lsapm_module-lsapm.o -MD -MP -MF commands/i386/pc/$(DEPDIR)/lsapm_module-lsapm.Tpo -c -o commands/i386/pc/lsapm_module-lsapm.o `test -f 'commands/i386/pc/lsapm.c' || echo '$(srcdir)/'`commands/i386/pc/lsapm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/lsapm_module-lsapm.Tpo commands/i386/pc/$(DEPDIR)/lsapm_module-lsapm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/lsapm.c' object='commands/i386/pc/lsapm_module-lsapm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsapm_module_CPPFLAGS) $(CPPFLAGS) $(lsapm_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/lsapm_module-lsapm.o `test -f 'commands/i386/pc/lsapm.c' || echo '$(srcdir)/'`commands/i386/pc/lsapm.c
+
+commands/i386/pc/lsapm_module-lsapm.obj: commands/i386/pc/lsapm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsapm_module_CPPFLAGS) $(CPPFLAGS) $(lsapm_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/lsapm_module-lsapm.obj -MD -MP -MF commands/i386/pc/$(DEPDIR)/lsapm_module-lsapm.Tpo -c -o commands/i386/pc/lsapm_module-lsapm.obj `if test -f 'commands/i386/pc/lsapm.c'; then $(CYGPATH_W) 'commands/i386/pc/lsapm.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/lsapm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/lsapm_module-lsapm.Tpo commands/i386/pc/$(DEPDIR)/lsapm_module-lsapm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/lsapm.c' object='commands/i386/pc/lsapm_module-lsapm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsapm_module_CPPFLAGS) $(CPPFLAGS) $(lsapm_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/lsapm_module-lsapm.obj `if test -f 'commands/i386/pc/lsapm.c'; then $(CYGPATH_W) 'commands/i386/pc/lsapm.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/lsapm.c'; fi`
+
+commands/arc/lsdev_module-lsdev.o: commands/arc/lsdev.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsdev_module_CPPFLAGS) $(CPPFLAGS) $(lsdev_module_CFLAGS) $(CFLAGS) -MT commands/arc/lsdev_module-lsdev.o -MD -MP -MF commands/arc/$(DEPDIR)/lsdev_module-lsdev.Tpo -c -o commands/arc/lsdev_module-lsdev.o `test -f 'commands/arc/lsdev.c' || echo '$(srcdir)/'`commands/arc/lsdev.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/arc/$(DEPDIR)/lsdev_module-lsdev.Tpo commands/arc/$(DEPDIR)/lsdev_module-lsdev.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/arc/lsdev.c' object='commands/arc/lsdev_module-lsdev.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsdev_module_CPPFLAGS) $(CPPFLAGS) $(lsdev_module_CFLAGS) $(CFLAGS) -c -o commands/arc/lsdev_module-lsdev.o `test -f 'commands/arc/lsdev.c' || echo '$(srcdir)/'`commands/arc/lsdev.c
+
+commands/arc/lsdev_module-lsdev.obj: commands/arc/lsdev.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsdev_module_CPPFLAGS) $(CPPFLAGS) $(lsdev_module_CFLAGS) $(CFLAGS) -MT commands/arc/lsdev_module-lsdev.obj -MD -MP -MF commands/arc/$(DEPDIR)/lsdev_module-lsdev.Tpo -c -o commands/arc/lsdev_module-lsdev.obj `if test -f 'commands/arc/lsdev.c'; then $(CYGPATH_W) 'commands/arc/lsdev.c'; else $(CYGPATH_W) '$(srcdir)/commands/arc/lsdev.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/arc/$(DEPDIR)/lsdev_module-lsdev.Tpo commands/arc/$(DEPDIR)/lsdev_module-lsdev.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/arc/lsdev.c' object='commands/arc/lsdev_module-lsdev.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsdev_module_CPPFLAGS) $(CPPFLAGS) $(lsdev_module_CFLAGS) $(CFLAGS) -c -o commands/arc/lsdev_module-lsdev.obj `if test -f 'commands/arc/lsdev.c'; then $(CYGPATH_W) 'commands/arc/lsdev.c'; else $(CYGPATH_W) '$(srcdir)/commands/arc/lsdev.c'; fi`
+
+commands/efi/lsefi_module-lsefi.o: commands/efi/lsefi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $(lsefi_module_CFLAGS) $(CFLAGS) -MT commands/efi/lsefi_module-lsefi.o -MD -MP -MF commands/efi/$(DEPDIR)/lsefi_module-lsefi.Tpo -c -o commands/efi/lsefi_module-lsefi.o `test -f 'commands/efi/lsefi.c' || echo '$(srcdir)/'`commands/efi/lsefi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/lsefi_module-lsefi.Tpo commands/efi/$(DEPDIR)/lsefi_module-lsefi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/lsefi.c' object='commands/efi/lsefi_module-lsefi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $(lsefi_module_CFLAGS) $(CFLAGS) -c -o commands/efi/lsefi_module-lsefi.o `test -f 'commands/efi/lsefi.c' || echo '$(srcdir)/'`commands/efi/lsefi.c
+
+commands/efi/lsefi_module-lsefi.obj: commands/efi/lsefi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $(lsefi_module_CFLAGS) $(CFLAGS) -MT commands/efi/lsefi_module-lsefi.obj -MD -MP -MF commands/efi/$(DEPDIR)/lsefi_module-lsefi.Tpo -c -o commands/efi/lsefi_module-lsefi.obj `if test -f 'commands/efi/lsefi.c'; then $(CYGPATH_W) 'commands/efi/lsefi.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/lsefi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/lsefi_module-lsefi.Tpo commands/efi/$(DEPDIR)/lsefi_module-lsefi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/lsefi.c' object='commands/efi/lsefi_module-lsefi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $(lsefi_module_CFLAGS) $(CFLAGS) -c -o commands/efi/lsefi_module-lsefi.obj `if test -f 'commands/efi/lsefi.c'; then $(CYGPATH_W) 'commands/efi/lsefi.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/lsefi.c'; fi`
+
+commands/efi/lsefimmap_module-lsefimmap.o: commands/efi/lsefimmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $(lsefimmap_module_CFLAGS) $(CFLAGS) -MT commands/efi/lsefimmap_module-lsefimmap.o -MD -MP -MF commands/efi/$(DEPDIR)/lsefimmap_module-lsefimmap.Tpo -c -o commands/efi/lsefimmap_module-lsefimmap.o `test -f 'commands/efi/lsefimmap.c' || echo '$(srcdir)/'`commands/efi/lsefimmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/lsefimmap_module-lsefimmap.Tpo commands/efi/$(DEPDIR)/lsefimmap_module-lsefimmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/lsefimmap.c' object='commands/efi/lsefimmap_module-lsefimmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $(lsefimmap_module_CFLAGS) $(CFLAGS) -c -o commands/efi/lsefimmap_module-lsefimmap.o `test -f 'commands/efi/lsefimmap.c' || echo '$(srcdir)/'`commands/efi/lsefimmap.c
+
+commands/efi/lsefimmap_module-lsefimmap.obj: commands/efi/lsefimmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $(lsefimmap_module_CFLAGS) $(CFLAGS) -MT commands/efi/lsefimmap_module-lsefimmap.obj -MD -MP -MF commands/efi/$(DEPDIR)/lsefimmap_module-lsefimmap.Tpo -c -o commands/efi/lsefimmap_module-lsefimmap.obj `if test -f 'commands/efi/lsefimmap.c'; then $(CYGPATH_W) 'commands/efi/lsefimmap.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/lsefimmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/lsefimmap_module-lsefimmap.Tpo commands/efi/$(DEPDIR)/lsefimmap_module-lsefimmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/lsefimmap.c' object='commands/efi/lsefimmap_module-lsefimmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $(lsefimmap_module_CFLAGS) $(CFLAGS) -c -o commands/efi/lsefimmap_module-lsefimmap.obj `if test -f 'commands/efi/lsefimmap.c'; then $(CYGPATH_W) 'commands/efi/lsefimmap.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/lsefimmap.c'; fi`
+
+commands/efi/lsefisystab_module-lsefisystab.o: commands/efi/lsefisystab.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $(lsefisystab_module_CFLAGS) $(CFLAGS) -MT commands/efi/lsefisystab_module-lsefisystab.o -MD -MP -MF commands/efi/$(DEPDIR)/lsefisystab_module-lsefisystab.Tpo -c -o commands/efi/lsefisystab_module-lsefisystab.o `test -f 'commands/efi/lsefisystab.c' || echo '$(srcdir)/'`commands/efi/lsefisystab.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/lsefisystab_module-lsefisystab.Tpo commands/efi/$(DEPDIR)/lsefisystab_module-lsefisystab.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/lsefisystab.c' object='commands/efi/lsefisystab_module-lsefisystab.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $(lsefisystab_module_CFLAGS) $(CFLAGS) -c -o commands/efi/lsefisystab_module-lsefisystab.o `test -f 'commands/efi/lsefisystab.c' || echo '$(srcdir)/'`commands/efi/lsefisystab.c
+
+commands/efi/lsefisystab_module-lsefisystab.obj: commands/efi/lsefisystab.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $(lsefisystab_module_CFLAGS) $(CFLAGS) -MT commands/efi/lsefisystab_module-lsefisystab.obj -MD -MP -MF commands/efi/$(DEPDIR)/lsefisystab_module-lsefisystab.Tpo -c -o commands/efi/lsefisystab_module-lsefisystab.obj `if test -f 'commands/efi/lsefisystab.c'; then $(CYGPATH_W) 'commands/efi/lsefisystab.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/lsefisystab.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/lsefisystab_module-lsefisystab.Tpo commands/efi/$(DEPDIR)/lsefisystab_module-lsefisystab.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/lsefisystab.c' object='commands/efi/lsefisystab_module-lsefisystab.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $(lsefisystab_module_CFLAGS) $(CFLAGS) -c -o commands/efi/lsefisystab_module-lsefisystab.obj `if test -f 'commands/efi/lsefisystab.c'; then $(CYGPATH_W) 'commands/efi/lsefisystab.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/lsefisystab.c'; fi`
+
+commands/lsmmap_module-lsmmap.o: commands/lsmmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsmmap_module_CPPFLAGS) $(CPPFLAGS) $(lsmmap_module_CFLAGS) $(CFLAGS) -MT commands/lsmmap_module-lsmmap.o -MD -MP -MF commands/$(DEPDIR)/lsmmap_module-lsmmap.Tpo -c -o commands/lsmmap_module-lsmmap.o `test -f 'commands/lsmmap.c' || echo '$(srcdir)/'`commands/lsmmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/lsmmap_module-lsmmap.Tpo commands/$(DEPDIR)/lsmmap_module-lsmmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/lsmmap.c' object='commands/lsmmap_module-lsmmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsmmap_module_CPPFLAGS) $(CPPFLAGS) $(lsmmap_module_CFLAGS) $(CFLAGS) -c -o commands/lsmmap_module-lsmmap.o `test -f 'commands/lsmmap.c' || echo '$(srcdir)/'`commands/lsmmap.c
+
+commands/lsmmap_module-lsmmap.obj: commands/lsmmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsmmap_module_CPPFLAGS) $(CPPFLAGS) $(lsmmap_module_CFLAGS) $(CFLAGS) -MT commands/lsmmap_module-lsmmap.obj -MD -MP -MF commands/$(DEPDIR)/lsmmap_module-lsmmap.Tpo -c -o commands/lsmmap_module-lsmmap.obj `if test -f 'commands/lsmmap.c'; then $(CYGPATH_W) 'commands/lsmmap.c'; else $(CYGPATH_W) '$(srcdir)/commands/lsmmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/lsmmap_module-lsmmap.Tpo commands/$(DEPDIR)/lsmmap_module-lsmmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/lsmmap.c' object='commands/lsmmap_module-lsmmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsmmap_module_CPPFLAGS) $(CPPFLAGS) $(lsmmap_module_CFLAGS) $(CFLAGS) -c -o commands/lsmmap_module-lsmmap.obj `if test -f 'commands/lsmmap.c'; then $(CYGPATH_W) 'commands/lsmmap.c'; else $(CYGPATH_W) '$(srcdir)/commands/lsmmap.c'; fi`
+
+commands/lspci_module-lspci.o: commands/lspci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $(lspci_module_CFLAGS) $(CFLAGS) -MT commands/lspci_module-lspci.o -MD -MP -MF commands/$(DEPDIR)/lspci_module-lspci.Tpo -c -o commands/lspci_module-lspci.o `test -f 'commands/lspci.c' || echo '$(srcdir)/'`commands/lspci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/lspci_module-lspci.Tpo commands/$(DEPDIR)/lspci_module-lspci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/lspci.c' object='commands/lspci_module-lspci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $(lspci_module_CFLAGS) $(CFLAGS) -c -o commands/lspci_module-lspci.o `test -f 'commands/lspci.c' || echo '$(srcdir)/'`commands/lspci.c
+
+commands/lspci_module-lspci.obj: commands/lspci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $(lspci_module_CFLAGS) $(CFLAGS) -MT commands/lspci_module-lspci.obj -MD -MP -MF commands/$(DEPDIR)/lspci_module-lspci.Tpo -c -o commands/lspci_module-lspci.obj `if test -f 'commands/lspci.c'; then $(CYGPATH_W) 'commands/lspci.c'; else $(CYGPATH_W) '$(srcdir)/commands/lspci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/lspci_module-lspci.Tpo commands/$(DEPDIR)/lspci_module-lspci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/lspci.c' object='commands/lspci_module-lspci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $(lspci_module_CFLAGS) $(CFLAGS) -c -o commands/lspci_module-lspci.obj `if test -f 'commands/lspci.c'; then $(CYGPATH_W) 'commands/lspci.c'; else $(CYGPATH_W) '$(srcdir)/commands/lspci.c'; fi`
+
+commands/efi/lssal_module-lssal.o: commands/efi/lssal.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $(lssal_module_CFLAGS) $(CFLAGS) -MT commands/efi/lssal_module-lssal.o -MD -MP -MF commands/efi/$(DEPDIR)/lssal_module-lssal.Tpo -c -o commands/efi/lssal_module-lssal.o `test -f 'commands/efi/lssal.c' || echo '$(srcdir)/'`commands/efi/lssal.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/lssal_module-lssal.Tpo commands/efi/$(DEPDIR)/lssal_module-lssal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/lssal.c' object='commands/efi/lssal_module-lssal.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $(lssal_module_CFLAGS) $(CFLAGS) -c -o commands/efi/lssal_module-lssal.o `test -f 'commands/efi/lssal.c' || echo '$(srcdir)/'`commands/efi/lssal.c
+
+commands/efi/lssal_module-lssal.obj: commands/efi/lssal.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $(lssal_module_CFLAGS) $(CFLAGS) -MT commands/efi/lssal_module-lssal.obj -MD -MP -MF commands/efi/$(DEPDIR)/lssal_module-lssal.Tpo -c -o commands/efi/lssal_module-lssal.obj `if test -f 'commands/efi/lssal.c'; then $(CYGPATH_W) 'commands/efi/lssal.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/lssal.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/lssal_module-lssal.Tpo commands/efi/$(DEPDIR)/lssal_module-lssal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/lssal.c' object='commands/efi/lssal_module-lssal.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $(lssal_module_CFLAGS) $(CFLAGS) -c -o commands/efi/lssal_module-lssal.obj `if test -f 'commands/efi/lssal.c'; then $(CYGPATH_W) 'commands/efi/lssal.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/lssal.c'; fi`
+
+commands/mips/loongson/lsspd_module-lsspd.o: commands/mips/loongson/lsspd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsspd_module_CPPFLAGS) $(CPPFLAGS) $(lsspd_module_CFLAGS) $(CFLAGS) -MT commands/mips/loongson/lsspd_module-lsspd.o -MD -MP -MF commands/mips/loongson/$(DEPDIR)/lsspd_module-lsspd.Tpo -c -o commands/mips/loongson/lsspd_module-lsspd.o `test -f 'commands/mips/loongson/lsspd.c' || echo '$(srcdir)/'`commands/mips/loongson/lsspd.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/mips/loongson/$(DEPDIR)/lsspd_module-lsspd.Tpo commands/mips/loongson/$(DEPDIR)/lsspd_module-lsspd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/mips/loongson/lsspd.c' object='commands/mips/loongson/lsspd_module-lsspd.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsspd_module_CPPFLAGS) $(CPPFLAGS) $(lsspd_module_CFLAGS) $(CFLAGS) -c -o commands/mips/loongson/lsspd_module-lsspd.o `test -f 'commands/mips/loongson/lsspd.c' || echo '$(srcdir)/'`commands/mips/loongson/lsspd.c
+
+commands/mips/loongson/lsspd_module-lsspd.obj: commands/mips/loongson/lsspd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsspd_module_CPPFLAGS) $(CPPFLAGS) $(lsspd_module_CFLAGS) $(CFLAGS) -MT commands/mips/loongson/lsspd_module-lsspd.obj -MD -MP -MF commands/mips/loongson/$(DEPDIR)/lsspd_module-lsspd.Tpo -c -o commands/mips/loongson/lsspd_module-lsspd.obj `if test -f 'commands/mips/loongson/lsspd.c'; then $(CYGPATH_W) 'commands/mips/loongson/lsspd.c'; else $(CYGPATH_W) '$(srcdir)/commands/mips/loongson/lsspd.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/mips/loongson/$(DEPDIR)/lsspd_module-lsspd.Tpo commands/mips/loongson/$(DEPDIR)/lsspd_module-lsspd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/mips/loongson/lsspd.c' object='commands/mips/loongson/lsspd_module-lsspd.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsspd_module_CPPFLAGS) $(CPPFLAGS) $(lsspd_module_CFLAGS) $(CFLAGS) -c -o commands/mips/loongson/lsspd_module-lsspd.obj `if test -f 'commands/mips/loongson/lsspd.c'; then $(CYGPATH_W) 'commands/mips/loongson/lsspd.c'; else $(CYGPATH_W) '$(srcdir)/commands/mips/loongson/lsspd.c'; fi`
+
+commands/xen/lsxen_module-lsxen.o: commands/xen/lsxen.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsxen_module_CPPFLAGS) $(CPPFLAGS) $(lsxen_module_CFLAGS) $(CFLAGS) -MT commands/xen/lsxen_module-lsxen.o -MD -MP -MF commands/xen/$(DEPDIR)/lsxen_module-lsxen.Tpo -c -o commands/xen/lsxen_module-lsxen.o `test -f 'commands/xen/lsxen.c' || echo '$(srcdir)/'`commands/xen/lsxen.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/xen/$(DEPDIR)/lsxen_module-lsxen.Tpo commands/xen/$(DEPDIR)/lsxen_module-lsxen.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/xen/lsxen.c' object='commands/xen/lsxen_module-lsxen.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsxen_module_CPPFLAGS) $(CPPFLAGS) $(lsxen_module_CFLAGS) $(CFLAGS) -c -o commands/xen/lsxen_module-lsxen.o `test -f 'commands/xen/lsxen.c' || echo '$(srcdir)/'`commands/xen/lsxen.c
+
+commands/xen/lsxen_module-lsxen.obj: commands/xen/lsxen.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsxen_module_CPPFLAGS) $(CPPFLAGS) $(lsxen_module_CFLAGS) $(CFLAGS) -MT commands/xen/lsxen_module-lsxen.obj -MD -MP -MF commands/xen/$(DEPDIR)/lsxen_module-lsxen.Tpo -c -o commands/xen/lsxen_module-lsxen.obj `if test -f 'commands/xen/lsxen.c'; then $(CYGPATH_W) 'commands/xen/lsxen.c'; else $(CYGPATH_W) '$(srcdir)/commands/xen/lsxen.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/xen/$(DEPDIR)/lsxen_module-lsxen.Tpo commands/xen/$(DEPDIR)/lsxen_module-lsxen.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/xen/lsxen.c' object='commands/xen/lsxen_module-lsxen.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsxen_module_CPPFLAGS) $(CPPFLAGS) $(lsxen_module_CFLAGS) $(CFLAGS) -c -o commands/xen/lsxen_module-lsxen.obj `if test -f 'commands/xen/lsxen.c'; then $(CYGPATH_W) 'commands/xen/lsxen.c'; else $(CYGPATH_W) '$(srcdir)/commands/xen/lsxen.c'; fi`
+
+disk/luks_module-luks.o: disk/luks.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks_module_CPPFLAGS) $(CPPFLAGS) $(luks_module_CFLAGS) $(CFLAGS) -MT disk/luks_module-luks.o -MD -MP -MF disk/$(DEPDIR)/luks_module-luks.Tpo -c -o disk/luks_module-luks.o `test -f 'disk/luks.c' || echo '$(srcdir)/'`disk/luks.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/luks_module-luks.Tpo disk/$(DEPDIR)/luks_module-luks.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/luks.c' object='disk/luks_module-luks.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks_module_CPPFLAGS) $(CPPFLAGS) $(luks_module_CFLAGS) $(CFLAGS) -c -o disk/luks_module-luks.o `test -f 'disk/luks.c' || echo '$(srcdir)/'`disk/luks.c
+
+disk/luks_module-luks.obj: disk/luks.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks_module_CPPFLAGS) $(CPPFLAGS) $(luks_module_CFLAGS) $(CFLAGS) -MT disk/luks_module-luks.obj -MD -MP -MF disk/$(DEPDIR)/luks_module-luks.Tpo -c -o disk/luks_module-luks.obj `if test -f 'disk/luks.c'; then $(CYGPATH_W) 'disk/luks.c'; else $(CYGPATH_W) '$(srcdir)/disk/luks.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/luks_module-luks.Tpo disk/$(DEPDIR)/luks_module-luks.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/luks.c' object='disk/luks_module-luks.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks_module_CPPFLAGS) $(CPPFLAGS) $(luks_module_CFLAGS) $(CFLAGS) -c -o disk/luks_module-luks.obj `if test -f 'disk/luks.c'; then $(CYGPATH_W) 'disk/luks.c'; else $(CYGPATH_W) '$(srcdir)/disk/luks.c'; fi`
+
+disk/luks2_module-luks2.o: disk/luks2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks2_module_CPPFLAGS) $(CPPFLAGS) $(luks2_module_CFLAGS) $(CFLAGS) -MT disk/luks2_module-luks2.o -MD -MP -MF disk/$(DEPDIR)/luks2_module-luks2.Tpo -c -o disk/luks2_module-luks2.o `test -f 'disk/luks2.c' || echo '$(srcdir)/'`disk/luks2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/luks2_module-luks2.Tpo disk/$(DEPDIR)/luks2_module-luks2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/luks2.c' object='disk/luks2_module-luks2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks2_module_CPPFLAGS) $(CPPFLAGS) $(luks2_module_CFLAGS) $(CFLAGS) -c -o disk/luks2_module-luks2.o `test -f 'disk/luks2.c' || echo '$(srcdir)/'`disk/luks2.c
+
+disk/luks2_module-luks2.obj: disk/luks2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks2_module_CPPFLAGS) $(CPPFLAGS) $(luks2_module_CFLAGS) $(CFLAGS) -MT disk/luks2_module-luks2.obj -MD -MP -MF disk/$(DEPDIR)/luks2_module-luks2.Tpo -c -o disk/luks2_module-luks2.obj `if test -f 'disk/luks2.c'; then $(CYGPATH_W) 'disk/luks2.c'; else $(CYGPATH_W) '$(srcdir)/disk/luks2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/luks2_module-luks2.Tpo disk/$(DEPDIR)/luks2_module-luks2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/luks2.c' object='disk/luks2_module-luks2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks2_module_CPPFLAGS) $(CPPFLAGS) $(luks2_module_CFLAGS) $(CFLAGS) -c -o disk/luks2_module-luks2.obj `if test -f 'disk/luks2.c'; then $(CYGPATH_W) 'disk/luks2.c'; else $(CYGPATH_W) '$(srcdir)/disk/luks2.c'; fi`
+
+lib/gnulib/luks2_module-base64.o: lib/gnulib/base64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks2_module_CPPFLAGS) $(CPPFLAGS) $(luks2_module_CFLAGS) $(CFLAGS) -MT lib/gnulib/luks2_module-base64.o -MD -MP -MF lib/gnulib/$(DEPDIR)/luks2_module-base64.Tpo -c -o lib/gnulib/luks2_module-base64.o `test -f 'lib/gnulib/base64.c' || echo '$(srcdir)/'`lib/gnulib/base64.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/gnulib/$(DEPDIR)/luks2_module-base64.Tpo lib/gnulib/$(DEPDIR)/luks2_module-base64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/gnulib/base64.c' object='lib/gnulib/luks2_module-base64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks2_module_CPPFLAGS) $(CPPFLAGS) $(luks2_module_CFLAGS) $(CFLAGS) -c -o lib/gnulib/luks2_module-base64.o `test -f 'lib/gnulib/base64.c' || echo '$(srcdir)/'`lib/gnulib/base64.c
+
+lib/gnulib/luks2_module-base64.obj: lib/gnulib/base64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks2_module_CPPFLAGS) $(CPPFLAGS) $(luks2_module_CFLAGS) $(CFLAGS) -MT lib/gnulib/luks2_module-base64.obj -MD -MP -MF lib/gnulib/$(DEPDIR)/luks2_module-base64.Tpo -c -o lib/gnulib/luks2_module-base64.obj `if test -f 'lib/gnulib/base64.c'; then $(CYGPATH_W) 'lib/gnulib/base64.c'; else $(CYGPATH_W) '$(srcdir)/lib/gnulib/base64.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/gnulib/$(DEPDIR)/luks2_module-base64.Tpo lib/gnulib/$(DEPDIR)/luks2_module-base64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/gnulib/base64.c' object='lib/gnulib/luks2_module-base64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks2_module_CPPFLAGS) $(CPPFLAGS) $(luks2_module_CFLAGS) $(CFLAGS) -c -o lib/gnulib/luks2_module-base64.obj `if test -f 'lib/gnulib/base64.c'; then $(CYGPATH_W) 'lib/gnulib/base64.c'; else $(CYGPATH_W) '$(srcdir)/lib/gnulib/base64.c'; fi`
+
+disk/lvm_module-lvm.o: disk/lvm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lvm_module_CPPFLAGS) $(CPPFLAGS) $(lvm_module_CFLAGS) $(CFLAGS) -MT disk/lvm_module-lvm.o -MD -MP -MF disk/$(DEPDIR)/lvm_module-lvm.Tpo -c -o disk/lvm_module-lvm.o `test -f 'disk/lvm.c' || echo '$(srcdir)/'`disk/lvm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/lvm_module-lvm.Tpo disk/$(DEPDIR)/lvm_module-lvm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/lvm.c' object='disk/lvm_module-lvm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lvm_module_CPPFLAGS) $(CPPFLAGS) $(lvm_module_CFLAGS) $(CFLAGS) -c -o disk/lvm_module-lvm.o `test -f 'disk/lvm.c' || echo '$(srcdir)/'`disk/lvm.c
+
+disk/lvm_module-lvm.obj: disk/lvm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lvm_module_CPPFLAGS) $(CPPFLAGS) $(lvm_module_CFLAGS) $(CFLAGS) -MT disk/lvm_module-lvm.obj -MD -MP -MF disk/$(DEPDIR)/lvm_module-lvm.Tpo -c -o disk/lvm_module-lvm.obj `if test -f 'disk/lvm.c'; then $(CYGPATH_W) 'disk/lvm.c'; else $(CYGPATH_W) '$(srcdir)/disk/lvm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/lvm_module-lvm.Tpo disk/$(DEPDIR)/lvm_module-lvm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/lvm.c' object='disk/lvm_module-lvm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lvm_module_CPPFLAGS) $(CPPFLAGS) $(lvm_module_CFLAGS) $(CFLAGS) -c -o disk/lvm_module-lvm.obj `if test -f 'disk/lvm.c'; then $(CYGPATH_W) 'disk/lvm.c'; else $(CYGPATH_W) '$(srcdir)/disk/lvm.c'; fi`
+
+io/lzopio_module-lzopio.o: io/lzopio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzopio_module_CPPFLAGS) $(CPPFLAGS) $(lzopio_module_CFLAGS) $(CFLAGS) -MT io/lzopio_module-lzopio.o -MD -MP -MF io/$(DEPDIR)/lzopio_module-lzopio.Tpo -c -o io/lzopio_module-lzopio.o `test -f 'io/lzopio.c' || echo '$(srcdir)/'`io/lzopio.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/lzopio_module-lzopio.Tpo io/$(DEPDIR)/lzopio_module-lzopio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/lzopio.c' object='io/lzopio_module-lzopio.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzopio_module_CPPFLAGS) $(CPPFLAGS) $(lzopio_module_CFLAGS) $(CFLAGS) -c -o io/lzopio_module-lzopio.o `test -f 'io/lzopio.c' || echo '$(srcdir)/'`io/lzopio.c
+
+io/lzopio_module-lzopio.obj: io/lzopio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzopio_module_CPPFLAGS) $(CPPFLAGS) $(lzopio_module_CFLAGS) $(CFLAGS) -MT io/lzopio_module-lzopio.obj -MD -MP -MF io/$(DEPDIR)/lzopio_module-lzopio.Tpo -c -o io/lzopio_module-lzopio.obj `if test -f 'io/lzopio.c'; then $(CYGPATH_W) 'io/lzopio.c'; else $(CYGPATH_W) '$(srcdir)/io/lzopio.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/lzopio_module-lzopio.Tpo io/$(DEPDIR)/lzopio_module-lzopio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/lzopio.c' object='io/lzopio_module-lzopio.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzopio_module_CPPFLAGS) $(CPPFLAGS) $(lzopio_module_CFLAGS) $(CFLAGS) -c -o io/lzopio_module-lzopio.obj `if test -f 'io/lzopio.c'; then $(CYGPATH_W) 'io/lzopio.c'; else $(CYGPATH_W) '$(srcdir)/io/lzopio.c'; fi`
+
+lib/minilzo/lzopio_module-minilzo.o: lib/minilzo/minilzo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzopio_module_CPPFLAGS) $(CPPFLAGS) $(lzopio_module_CFLAGS) $(CFLAGS) -MT lib/minilzo/lzopio_module-minilzo.o -MD -MP -MF lib/minilzo/$(DEPDIR)/lzopio_module-minilzo.Tpo -c -o lib/minilzo/lzopio_module-minilzo.o `test -f 'lib/minilzo/minilzo.c' || echo '$(srcdir)/'`lib/minilzo/minilzo.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/minilzo/$(DEPDIR)/lzopio_module-minilzo.Tpo lib/minilzo/$(DEPDIR)/lzopio_module-minilzo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/minilzo/minilzo.c' object='lib/minilzo/lzopio_module-minilzo.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzopio_module_CPPFLAGS) $(CPPFLAGS) $(lzopio_module_CFLAGS) $(CFLAGS) -c -o lib/minilzo/lzopio_module-minilzo.o `test -f 'lib/minilzo/minilzo.c' || echo '$(srcdir)/'`lib/minilzo/minilzo.c
+
+lib/minilzo/lzopio_module-minilzo.obj: lib/minilzo/minilzo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzopio_module_CPPFLAGS) $(CPPFLAGS) $(lzopio_module_CFLAGS) $(CFLAGS) -MT lib/minilzo/lzopio_module-minilzo.obj -MD -MP -MF lib/minilzo/$(DEPDIR)/lzopio_module-minilzo.Tpo -c -o lib/minilzo/lzopio_module-minilzo.obj `if test -f 'lib/minilzo/minilzo.c'; then $(CYGPATH_W) 'lib/minilzo/minilzo.c'; else $(CYGPATH_W) '$(srcdir)/lib/minilzo/minilzo.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/minilzo/$(DEPDIR)/lzopio_module-minilzo.Tpo lib/minilzo/$(DEPDIR)/lzopio_module-minilzo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/minilzo/minilzo.c' object='lib/minilzo/lzopio_module-minilzo.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzopio_module_CPPFLAGS) $(CPPFLAGS) $(lzopio_module_CFLAGS) $(CFLAGS) -c -o lib/minilzo/lzopio_module-minilzo.obj `if test -f 'lib/minilzo/minilzo.c'; then $(CYGPATH_W) 'lib/minilzo/minilzo.c'; else $(CYGPATH_W) '$(srcdir)/lib/minilzo/minilzo.c'; fi`
+
+commands/macbless_module-macbless.o: commands/macbless.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macbless_module_CPPFLAGS) $(CPPFLAGS) $(macbless_module_CFLAGS) $(CFLAGS) -MT commands/macbless_module-macbless.o -MD -MP -MF commands/$(DEPDIR)/macbless_module-macbless.Tpo -c -o commands/macbless_module-macbless.o `test -f 'commands/macbless.c' || echo '$(srcdir)/'`commands/macbless.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/macbless_module-macbless.Tpo commands/$(DEPDIR)/macbless_module-macbless.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/macbless.c' object='commands/macbless_module-macbless.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macbless_module_CPPFLAGS) $(CPPFLAGS) $(macbless_module_CFLAGS) $(CFLAGS) -c -o commands/macbless_module-macbless.o `test -f 'commands/macbless.c' || echo '$(srcdir)/'`commands/macbless.c
+
+commands/macbless_module-macbless.obj: commands/macbless.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macbless_module_CPPFLAGS) $(CPPFLAGS) $(macbless_module_CFLAGS) $(CFLAGS) -MT commands/macbless_module-macbless.obj -MD -MP -MF commands/$(DEPDIR)/macbless_module-macbless.Tpo -c -o commands/macbless_module-macbless.obj `if test -f 'commands/macbless.c'; then $(CYGPATH_W) 'commands/macbless.c'; else $(CYGPATH_W) '$(srcdir)/commands/macbless.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/macbless_module-macbless.Tpo commands/$(DEPDIR)/macbless_module-macbless.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/macbless.c' object='commands/macbless_module-macbless.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macbless_module_CPPFLAGS) $(CPPFLAGS) $(macbless_module_CFLAGS) $(CFLAGS) -c -o commands/macbless_module-macbless.obj `if test -f 'commands/macbless.c'; then $(CYGPATH_W) 'commands/macbless.c'; else $(CYGPATH_W) '$(srcdir)/commands/macbless.c'; fi`
+
+loader/macho_module-macho.o: loader/macho.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -MT loader/macho_module-macho.o -MD -MP -MF loader/$(DEPDIR)/macho_module-macho.Tpo -c -o loader/macho_module-macho.o `test -f 'loader/macho.c' || echo '$(srcdir)/'`loader/macho.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/macho_module-macho.Tpo loader/$(DEPDIR)/macho_module-macho.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/macho.c' object='loader/macho_module-macho.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -c -o loader/macho_module-macho.o `test -f 'loader/macho.c' || echo '$(srcdir)/'`loader/macho.c
+
+loader/macho_module-macho.obj: loader/macho.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -MT loader/macho_module-macho.obj -MD -MP -MF loader/$(DEPDIR)/macho_module-macho.Tpo -c -o loader/macho_module-macho.obj `if test -f 'loader/macho.c'; then $(CYGPATH_W) 'loader/macho.c'; else $(CYGPATH_W) '$(srcdir)/loader/macho.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/macho_module-macho.Tpo loader/$(DEPDIR)/macho_module-macho.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/macho.c' object='loader/macho_module-macho.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -c -o loader/macho_module-macho.obj `if test -f 'loader/macho.c'; then $(CYGPATH_W) 'loader/macho.c'; else $(CYGPATH_W) '$(srcdir)/loader/macho.c'; fi`
+
+loader/macho_module-macho32.o: loader/macho32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -MT loader/macho_module-macho32.o -MD -MP -MF loader/$(DEPDIR)/macho_module-macho32.Tpo -c -o loader/macho_module-macho32.o `test -f 'loader/macho32.c' || echo '$(srcdir)/'`loader/macho32.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/macho_module-macho32.Tpo loader/$(DEPDIR)/macho_module-macho32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/macho32.c' object='loader/macho_module-macho32.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -c -o loader/macho_module-macho32.o `test -f 'loader/macho32.c' || echo '$(srcdir)/'`loader/macho32.c
+
+loader/macho_module-macho32.obj: loader/macho32.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -MT loader/macho_module-macho32.obj -MD -MP -MF loader/$(DEPDIR)/macho_module-macho32.Tpo -c -o loader/macho_module-macho32.obj `if test -f 'loader/macho32.c'; then $(CYGPATH_W) 'loader/macho32.c'; else $(CYGPATH_W) '$(srcdir)/loader/macho32.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/macho_module-macho32.Tpo loader/$(DEPDIR)/macho_module-macho32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/macho32.c' object='loader/macho_module-macho32.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -c -o loader/macho_module-macho32.obj `if test -f 'loader/macho32.c'; then $(CYGPATH_W) 'loader/macho32.c'; else $(CYGPATH_W) '$(srcdir)/loader/macho32.c'; fi`
+
+loader/macho_module-macho64.o: loader/macho64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -MT loader/macho_module-macho64.o -MD -MP -MF loader/$(DEPDIR)/macho_module-macho64.Tpo -c -o loader/macho_module-macho64.o `test -f 'loader/macho64.c' || echo '$(srcdir)/'`loader/macho64.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/macho_module-macho64.Tpo loader/$(DEPDIR)/macho_module-macho64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/macho64.c' object='loader/macho_module-macho64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -c -o loader/macho_module-macho64.o `test -f 'loader/macho64.c' || echo '$(srcdir)/'`loader/macho64.c
+
+loader/macho_module-macho64.obj: loader/macho64.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -MT loader/macho_module-macho64.obj -MD -MP -MF loader/$(DEPDIR)/macho_module-macho64.Tpo -c -o loader/macho_module-macho64.obj `if test -f 'loader/macho64.c'; then $(CYGPATH_W) 'loader/macho64.c'; else $(CYGPATH_W) '$(srcdir)/loader/macho64.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/macho_module-macho64.Tpo loader/$(DEPDIR)/macho_module-macho64.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/macho64.c' object='loader/macho_module-macho64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -c -o loader/macho_module-macho64.obj `if test -f 'loader/macho64.c'; then $(CYGPATH_W) 'loader/macho64.c'; else $(CYGPATH_W) '$(srcdir)/loader/macho64.c'; fi`
+
+loader/macho_module-lzss.o: loader/lzss.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -MT loader/macho_module-lzss.o -MD -MP -MF loader/$(DEPDIR)/macho_module-lzss.Tpo -c -o loader/macho_module-lzss.o `test -f 'loader/lzss.c' || echo '$(srcdir)/'`loader/lzss.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/macho_module-lzss.Tpo loader/$(DEPDIR)/macho_module-lzss.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/lzss.c' object='loader/macho_module-lzss.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -c -o loader/macho_module-lzss.o `test -f 'loader/lzss.c' || echo '$(srcdir)/'`loader/lzss.c
+
+loader/macho_module-lzss.obj: loader/lzss.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -MT loader/macho_module-lzss.obj -MD -MP -MF loader/$(DEPDIR)/macho_module-lzss.Tpo -c -o loader/macho_module-lzss.obj `if test -f 'loader/lzss.c'; then $(CYGPATH_W) 'loader/lzss.c'; else $(CYGPATH_W) '$(srcdir)/loader/lzss.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/macho_module-lzss.Tpo loader/$(DEPDIR)/macho_module-lzss.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/lzss.c' object='loader/macho_module-lzss.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $(macho_module_CFLAGS) $(CFLAGS) -c -o loader/macho_module-lzss.obj `if test -f 'loader/lzss.c'; then $(CYGPATH_W) 'loader/lzss.c'; else $(CYGPATH_W) '$(srcdir)/loader/lzss.c'; fi`
+
+term/i386/pc/mda_text_module-mda_text.o: term/i386/pc/mda_text.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $(mda_text_module_CFLAGS) $(CFLAGS) -MT term/i386/pc/mda_text_module-mda_text.o -MD -MP -MF term/i386/pc/$(DEPDIR)/mda_text_module-mda_text.Tpo -c -o term/i386/pc/mda_text_module-mda_text.o `test -f 'term/i386/pc/mda_text.c' || echo '$(srcdir)/'`term/i386/pc/mda_text.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/i386/pc/$(DEPDIR)/mda_text_module-mda_text.Tpo term/i386/pc/$(DEPDIR)/mda_text_module-mda_text.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/i386/pc/mda_text.c' object='term/i386/pc/mda_text_module-mda_text.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $(mda_text_module_CFLAGS) $(CFLAGS) -c -o term/i386/pc/mda_text_module-mda_text.o `test -f 'term/i386/pc/mda_text.c' || echo '$(srcdir)/'`term/i386/pc/mda_text.c
+
+term/i386/pc/mda_text_module-mda_text.obj: term/i386/pc/mda_text.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $(mda_text_module_CFLAGS) $(CFLAGS) -MT term/i386/pc/mda_text_module-mda_text.obj -MD -MP -MF term/i386/pc/$(DEPDIR)/mda_text_module-mda_text.Tpo -c -o term/i386/pc/mda_text_module-mda_text.obj `if test -f 'term/i386/pc/mda_text.c'; then $(CYGPATH_W) 'term/i386/pc/mda_text.c'; else $(CYGPATH_W) '$(srcdir)/term/i386/pc/mda_text.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/i386/pc/$(DEPDIR)/mda_text_module-mda_text.Tpo term/i386/pc/$(DEPDIR)/mda_text_module-mda_text.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/i386/pc/mda_text.c' object='term/i386/pc/mda_text_module-mda_text.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $(mda_text_module_CFLAGS) $(CFLAGS) -c -o term/i386/pc/mda_text_module-mda_text.obj `if test -f 'term/i386/pc/mda_text.c'; then $(CYGPATH_W) 'term/i386/pc/mda_text.c'; else $(CYGPATH_W) '$(srcdir)/term/i386/pc/mda_text.c'; fi`
+
+disk/mdraid09_module-mdraid_linux.o: disk/mdraid_linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_module_CPPFLAGS) $(CPPFLAGS) $(mdraid09_module_CFLAGS) $(CFLAGS) -MT disk/mdraid09_module-mdraid_linux.o -MD -MP -MF disk/$(DEPDIR)/mdraid09_module-mdraid_linux.Tpo -c -o disk/mdraid09_module-mdraid_linux.o `test -f 'disk/mdraid_linux.c' || echo '$(srcdir)/'`disk/mdraid_linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/mdraid09_module-mdraid_linux.Tpo disk/$(DEPDIR)/mdraid09_module-mdraid_linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/mdraid_linux.c' object='disk/mdraid09_module-mdraid_linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_module_CPPFLAGS) $(CPPFLAGS) $(mdraid09_module_CFLAGS) $(CFLAGS) -c -o disk/mdraid09_module-mdraid_linux.o `test -f 'disk/mdraid_linux.c' || echo '$(srcdir)/'`disk/mdraid_linux.c
+
+disk/mdraid09_module-mdraid_linux.obj: disk/mdraid_linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_module_CPPFLAGS) $(CPPFLAGS) $(mdraid09_module_CFLAGS) $(CFLAGS) -MT disk/mdraid09_module-mdraid_linux.obj -MD -MP -MF disk/$(DEPDIR)/mdraid09_module-mdraid_linux.Tpo -c -o disk/mdraid09_module-mdraid_linux.obj `if test -f 'disk/mdraid_linux.c'; then $(CYGPATH_W) 'disk/mdraid_linux.c'; else $(CYGPATH_W) '$(srcdir)/disk/mdraid_linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/mdraid09_module-mdraid_linux.Tpo disk/$(DEPDIR)/mdraid09_module-mdraid_linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/mdraid_linux.c' object='disk/mdraid09_module-mdraid_linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_module_CPPFLAGS) $(CPPFLAGS) $(mdraid09_module_CFLAGS) $(CFLAGS) -c -o disk/mdraid09_module-mdraid_linux.obj `if test -f 'disk/mdraid_linux.c'; then $(CYGPATH_W) 'disk/mdraid_linux.c'; else $(CYGPATH_W) '$(srcdir)/disk/mdraid_linux.c'; fi`
+
+disk/mdraid09_be_module-mdraid_linux_be.o: disk/mdraid_linux_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_be_module_CPPFLAGS) $(CPPFLAGS) $(mdraid09_be_module_CFLAGS) $(CFLAGS) -MT disk/mdraid09_be_module-mdraid_linux_be.o -MD -MP -MF disk/$(DEPDIR)/mdraid09_be_module-mdraid_linux_be.Tpo -c -o disk/mdraid09_be_module-mdraid_linux_be.o `test -f 'disk/mdraid_linux_be.c' || echo '$(srcdir)/'`disk/mdraid_linux_be.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/mdraid09_be_module-mdraid_linux_be.Tpo disk/$(DEPDIR)/mdraid09_be_module-mdraid_linux_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/mdraid_linux_be.c' object='disk/mdraid09_be_module-mdraid_linux_be.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_be_module_CPPFLAGS) $(CPPFLAGS) $(mdraid09_be_module_CFLAGS) $(CFLAGS) -c -o disk/mdraid09_be_module-mdraid_linux_be.o `test -f 'disk/mdraid_linux_be.c' || echo '$(srcdir)/'`disk/mdraid_linux_be.c
+
+disk/mdraid09_be_module-mdraid_linux_be.obj: disk/mdraid_linux_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_be_module_CPPFLAGS) $(CPPFLAGS) $(mdraid09_be_module_CFLAGS) $(CFLAGS) -MT disk/mdraid09_be_module-mdraid_linux_be.obj -MD -MP -MF disk/$(DEPDIR)/mdraid09_be_module-mdraid_linux_be.Tpo -c -o disk/mdraid09_be_module-mdraid_linux_be.obj `if test -f 'disk/mdraid_linux_be.c'; then $(CYGPATH_W) 'disk/mdraid_linux_be.c'; else $(CYGPATH_W) '$(srcdir)/disk/mdraid_linux_be.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/mdraid09_be_module-mdraid_linux_be.Tpo disk/$(DEPDIR)/mdraid09_be_module-mdraid_linux_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/mdraid_linux_be.c' object='disk/mdraid09_be_module-mdraid_linux_be.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_be_module_CPPFLAGS) $(CPPFLAGS) $(mdraid09_be_module_CFLAGS) $(CFLAGS) -c -o disk/mdraid09_be_module-mdraid_linux_be.obj `if test -f 'disk/mdraid_linux_be.c'; then $(CYGPATH_W) 'disk/mdraid_linux_be.c'; else $(CYGPATH_W) '$(srcdir)/disk/mdraid_linux_be.c'; fi`
+
+disk/mdraid1x_module-mdraid1x_linux.o: disk/mdraid1x_linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid1x_module_CPPFLAGS) $(CPPFLAGS) $(mdraid1x_module_CFLAGS) $(CFLAGS) -MT disk/mdraid1x_module-mdraid1x_linux.o -MD -MP -MF disk/$(DEPDIR)/mdraid1x_module-mdraid1x_linux.Tpo -c -o disk/mdraid1x_module-mdraid1x_linux.o `test -f 'disk/mdraid1x_linux.c' || echo '$(srcdir)/'`disk/mdraid1x_linux.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/mdraid1x_module-mdraid1x_linux.Tpo disk/$(DEPDIR)/mdraid1x_module-mdraid1x_linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/mdraid1x_linux.c' object='disk/mdraid1x_module-mdraid1x_linux.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid1x_module_CPPFLAGS) $(CPPFLAGS) $(mdraid1x_module_CFLAGS) $(CFLAGS) -c -o disk/mdraid1x_module-mdraid1x_linux.o `test -f 'disk/mdraid1x_linux.c' || echo '$(srcdir)/'`disk/mdraid1x_linux.c
+
+disk/mdraid1x_module-mdraid1x_linux.obj: disk/mdraid1x_linux.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid1x_module_CPPFLAGS) $(CPPFLAGS) $(mdraid1x_module_CFLAGS) $(CFLAGS) -MT disk/mdraid1x_module-mdraid1x_linux.obj -MD -MP -MF disk/$(DEPDIR)/mdraid1x_module-mdraid1x_linux.Tpo -c -o disk/mdraid1x_module-mdraid1x_linux.obj `if test -f 'disk/mdraid1x_linux.c'; then $(CYGPATH_W) 'disk/mdraid1x_linux.c'; else $(CYGPATH_W) '$(srcdir)/disk/mdraid1x_linux.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/mdraid1x_module-mdraid1x_linux.Tpo disk/$(DEPDIR)/mdraid1x_module-mdraid1x_linux.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/mdraid1x_linux.c' object='disk/mdraid1x_module-mdraid1x_linux.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid1x_module_CPPFLAGS) $(CPPFLAGS) $(mdraid1x_module_CFLAGS) $(CFLAGS) -c -o disk/mdraid1x_module-mdraid1x_linux.obj `if test -f 'disk/mdraid1x_linux.c'; then $(CYGPATH_W) 'disk/mdraid1x_linux.c'; else $(CYGPATH_W) '$(srcdir)/disk/mdraid1x_linux.c'; fi`
+
+disk/memdisk_module-memdisk.o: disk/memdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memdisk_module_CPPFLAGS) $(CPPFLAGS) $(memdisk_module_CFLAGS) $(CFLAGS) -MT disk/memdisk_module-memdisk.o -MD -MP -MF disk/$(DEPDIR)/memdisk_module-memdisk.Tpo -c -o disk/memdisk_module-memdisk.o `test -f 'disk/memdisk.c' || echo '$(srcdir)/'`disk/memdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/memdisk_module-memdisk.Tpo disk/$(DEPDIR)/memdisk_module-memdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/memdisk.c' object='disk/memdisk_module-memdisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memdisk_module_CPPFLAGS) $(CPPFLAGS) $(memdisk_module_CFLAGS) $(CFLAGS) -c -o disk/memdisk_module-memdisk.o `test -f 'disk/memdisk.c' || echo '$(srcdir)/'`disk/memdisk.c
+
+disk/memdisk_module-memdisk.obj: disk/memdisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memdisk_module_CPPFLAGS) $(CPPFLAGS) $(memdisk_module_CFLAGS) $(CFLAGS) -MT disk/memdisk_module-memdisk.obj -MD -MP -MF disk/$(DEPDIR)/memdisk_module-memdisk.Tpo -c -o disk/memdisk_module-memdisk.obj `if test -f 'disk/memdisk.c'; then $(CYGPATH_W) 'disk/memdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/memdisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/memdisk_module-memdisk.Tpo disk/$(DEPDIR)/memdisk_module-memdisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/memdisk.c' object='disk/memdisk_module-memdisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memdisk_module_CPPFLAGS) $(CPPFLAGS) $(memdisk_module_CFLAGS) $(CFLAGS) -c -o disk/memdisk_module-memdisk.obj `if test -f 'disk/memdisk.c'; then $(CYGPATH_W) 'disk/memdisk.c'; else $(CYGPATH_W) '$(srcdir)/disk/memdisk.c'; fi`
+
+commands/memrw_module-memrw.o: commands/memrw.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memrw_module_CPPFLAGS) $(CPPFLAGS) $(memrw_module_CFLAGS) $(CFLAGS) -MT commands/memrw_module-memrw.o -MD -MP -MF commands/$(DEPDIR)/memrw_module-memrw.Tpo -c -o commands/memrw_module-memrw.o `test -f 'commands/memrw.c' || echo '$(srcdir)/'`commands/memrw.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/memrw_module-memrw.Tpo commands/$(DEPDIR)/memrw_module-memrw.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/memrw.c' object='commands/memrw_module-memrw.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memrw_module_CPPFLAGS) $(CPPFLAGS) $(memrw_module_CFLAGS) $(CFLAGS) -c -o commands/memrw_module-memrw.o `test -f 'commands/memrw.c' || echo '$(srcdir)/'`commands/memrw.c
+
+commands/memrw_module-memrw.obj: commands/memrw.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memrw_module_CPPFLAGS) $(CPPFLAGS) $(memrw_module_CFLAGS) $(CFLAGS) -MT commands/memrw_module-memrw.obj -MD -MP -MF commands/$(DEPDIR)/memrw_module-memrw.Tpo -c -o commands/memrw_module-memrw.obj `if test -f 'commands/memrw.c'; then $(CYGPATH_W) 'commands/memrw.c'; else $(CYGPATH_W) '$(srcdir)/commands/memrw.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/memrw_module-memrw.Tpo commands/$(DEPDIR)/memrw_module-memrw.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/memrw.c' object='commands/memrw_module-memrw.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memrw_module_CPPFLAGS) $(CPPFLAGS) $(memrw_module_CFLAGS) $(CFLAGS) -c -o commands/memrw_module-memrw.obj `if test -f 'commands/memrw.c'; then $(CYGPATH_W) 'commands/memrw.c'; else $(CYGPATH_W) '$(srcdir)/commands/memrw.c'; fi`
+
+commands/minicmd_module-minicmd.o: commands/minicmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minicmd_module_CPPFLAGS) $(CPPFLAGS) $(minicmd_module_CFLAGS) $(CFLAGS) -MT commands/minicmd_module-minicmd.o -MD -MP -MF commands/$(DEPDIR)/minicmd_module-minicmd.Tpo -c -o commands/minicmd_module-minicmd.o `test -f 'commands/minicmd.c' || echo '$(srcdir)/'`commands/minicmd.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/minicmd_module-minicmd.Tpo commands/$(DEPDIR)/minicmd_module-minicmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/minicmd.c' object='commands/minicmd_module-minicmd.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minicmd_module_CPPFLAGS) $(CPPFLAGS) $(minicmd_module_CFLAGS) $(CFLAGS) -c -o commands/minicmd_module-minicmd.o `test -f 'commands/minicmd.c' || echo '$(srcdir)/'`commands/minicmd.c
+
+commands/minicmd_module-minicmd.obj: commands/minicmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minicmd_module_CPPFLAGS) $(CPPFLAGS) $(minicmd_module_CFLAGS) $(CFLAGS) -MT commands/minicmd_module-minicmd.obj -MD -MP -MF commands/$(DEPDIR)/minicmd_module-minicmd.Tpo -c -o commands/minicmd_module-minicmd.obj `if test -f 'commands/minicmd.c'; then $(CYGPATH_W) 'commands/minicmd.c'; else $(CYGPATH_W) '$(srcdir)/commands/minicmd.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/minicmd_module-minicmd.Tpo commands/$(DEPDIR)/minicmd_module-minicmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/minicmd.c' object='commands/minicmd_module-minicmd.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minicmd_module_CPPFLAGS) $(CPPFLAGS) $(minicmd_module_CFLAGS) $(CFLAGS) -c -o commands/minicmd_module-minicmd.obj `if test -f 'commands/minicmd.c'; then $(CYGPATH_W) 'commands/minicmd.c'; else $(CYGPATH_W) '$(srcdir)/commands/minicmd.c'; fi`
+
+fs/minix_module-minix.o: fs/minix.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_module_CPPFLAGS) $(CPPFLAGS) $(minix_module_CFLAGS) $(CFLAGS) -MT fs/minix_module-minix.o -MD -MP -MF fs/$(DEPDIR)/minix_module-minix.Tpo -c -o fs/minix_module-minix.o `test -f 'fs/minix.c' || echo '$(srcdir)/'`fs/minix.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix_module-minix.Tpo fs/$(DEPDIR)/minix_module-minix.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix.c' object='fs/minix_module-minix.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_module_CPPFLAGS) $(CPPFLAGS) $(minix_module_CFLAGS) $(CFLAGS) -c -o fs/minix_module-minix.o `test -f 'fs/minix.c' || echo '$(srcdir)/'`fs/minix.c
+
+fs/minix_module-minix.obj: fs/minix.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_module_CPPFLAGS) $(CPPFLAGS) $(minix_module_CFLAGS) $(CFLAGS) -MT fs/minix_module-minix.obj -MD -MP -MF fs/$(DEPDIR)/minix_module-minix.Tpo -c -o fs/minix_module-minix.obj `if test -f 'fs/minix.c'; then $(CYGPATH_W) 'fs/minix.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix_module-minix.Tpo fs/$(DEPDIR)/minix_module-minix.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix.c' object='fs/minix_module-minix.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_module_CPPFLAGS) $(CPPFLAGS) $(minix_module_CFLAGS) $(CFLAGS) -c -o fs/minix_module-minix.obj `if test -f 'fs/minix.c'; then $(CYGPATH_W) 'fs/minix.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix.c'; fi`
+
+fs/minix2_module-minix2.o: fs/minix2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_module_CPPFLAGS) $(CPPFLAGS) $(minix2_module_CFLAGS) $(CFLAGS) -MT fs/minix2_module-minix2.o -MD -MP -MF fs/$(DEPDIR)/minix2_module-minix2.Tpo -c -o fs/minix2_module-minix2.o `test -f 'fs/minix2.c' || echo '$(srcdir)/'`fs/minix2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix2_module-minix2.Tpo fs/$(DEPDIR)/minix2_module-minix2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix2.c' object='fs/minix2_module-minix2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_module_CPPFLAGS) $(CPPFLAGS) $(minix2_module_CFLAGS) $(CFLAGS) -c -o fs/minix2_module-minix2.o `test -f 'fs/minix2.c' || echo '$(srcdir)/'`fs/minix2.c
+
+fs/minix2_module-minix2.obj: fs/minix2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_module_CPPFLAGS) $(CPPFLAGS) $(minix2_module_CFLAGS) $(CFLAGS) -MT fs/minix2_module-minix2.obj -MD -MP -MF fs/$(DEPDIR)/minix2_module-minix2.Tpo -c -o fs/minix2_module-minix2.obj `if test -f 'fs/minix2.c'; then $(CYGPATH_W) 'fs/minix2.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix2_module-minix2.Tpo fs/$(DEPDIR)/minix2_module-minix2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix2.c' object='fs/minix2_module-minix2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_module_CPPFLAGS) $(CPPFLAGS) $(minix2_module_CFLAGS) $(CFLAGS) -c -o fs/minix2_module-minix2.obj `if test -f 'fs/minix2.c'; then $(CYGPATH_W) 'fs/minix2.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix2.c'; fi`
+
+fs/minix2_be_module-minix2_be.o: fs/minix2_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_be_module_CPPFLAGS) $(CPPFLAGS) $(minix2_be_module_CFLAGS) $(CFLAGS) -MT fs/minix2_be_module-minix2_be.o -MD -MP -MF fs/$(DEPDIR)/minix2_be_module-minix2_be.Tpo -c -o fs/minix2_be_module-minix2_be.o `test -f 'fs/minix2_be.c' || echo '$(srcdir)/'`fs/minix2_be.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix2_be_module-minix2_be.Tpo fs/$(DEPDIR)/minix2_be_module-minix2_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix2_be.c' object='fs/minix2_be_module-minix2_be.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_be_module_CPPFLAGS) $(CPPFLAGS) $(minix2_be_module_CFLAGS) $(CFLAGS) -c -o fs/minix2_be_module-minix2_be.o `test -f 'fs/minix2_be.c' || echo '$(srcdir)/'`fs/minix2_be.c
+
+fs/minix2_be_module-minix2_be.obj: fs/minix2_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_be_module_CPPFLAGS) $(CPPFLAGS) $(minix2_be_module_CFLAGS) $(CFLAGS) -MT fs/minix2_be_module-minix2_be.obj -MD -MP -MF fs/$(DEPDIR)/minix2_be_module-minix2_be.Tpo -c -o fs/minix2_be_module-minix2_be.obj `if test -f 'fs/minix2_be.c'; then $(CYGPATH_W) 'fs/minix2_be.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix2_be.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix2_be_module-minix2_be.Tpo fs/$(DEPDIR)/minix2_be_module-minix2_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix2_be.c' object='fs/minix2_be_module-minix2_be.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_be_module_CPPFLAGS) $(CPPFLAGS) $(minix2_be_module_CFLAGS) $(CFLAGS) -c -o fs/minix2_be_module-minix2_be.obj `if test -f 'fs/minix2_be.c'; then $(CYGPATH_W) 'fs/minix2_be.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix2_be.c'; fi`
+
+fs/minix3_module-minix3.o: fs/minix3.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_module_CPPFLAGS) $(CPPFLAGS) $(minix3_module_CFLAGS) $(CFLAGS) -MT fs/minix3_module-minix3.o -MD -MP -MF fs/$(DEPDIR)/minix3_module-minix3.Tpo -c -o fs/minix3_module-minix3.o `test -f 'fs/minix3.c' || echo '$(srcdir)/'`fs/minix3.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix3_module-minix3.Tpo fs/$(DEPDIR)/minix3_module-minix3.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix3.c' object='fs/minix3_module-minix3.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_module_CPPFLAGS) $(CPPFLAGS) $(minix3_module_CFLAGS) $(CFLAGS) -c -o fs/minix3_module-minix3.o `test -f 'fs/minix3.c' || echo '$(srcdir)/'`fs/minix3.c
+
+fs/minix3_module-minix3.obj: fs/minix3.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_module_CPPFLAGS) $(CPPFLAGS) $(minix3_module_CFLAGS) $(CFLAGS) -MT fs/minix3_module-minix3.obj -MD -MP -MF fs/$(DEPDIR)/minix3_module-minix3.Tpo -c -o fs/minix3_module-minix3.obj `if test -f 'fs/minix3.c'; then $(CYGPATH_W) 'fs/minix3.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix3.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix3_module-minix3.Tpo fs/$(DEPDIR)/minix3_module-minix3.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix3.c' object='fs/minix3_module-minix3.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_module_CPPFLAGS) $(CPPFLAGS) $(minix3_module_CFLAGS) $(CFLAGS) -c -o fs/minix3_module-minix3.obj `if test -f 'fs/minix3.c'; then $(CYGPATH_W) 'fs/minix3.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix3.c'; fi`
+
+fs/minix3_be_module-minix3_be.o: fs/minix3_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_be_module_CPPFLAGS) $(CPPFLAGS) $(minix3_be_module_CFLAGS) $(CFLAGS) -MT fs/minix3_be_module-minix3_be.o -MD -MP -MF fs/$(DEPDIR)/minix3_be_module-minix3_be.Tpo -c -o fs/minix3_be_module-minix3_be.o `test -f 'fs/minix3_be.c' || echo '$(srcdir)/'`fs/minix3_be.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix3_be_module-minix3_be.Tpo fs/$(DEPDIR)/minix3_be_module-minix3_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix3_be.c' object='fs/minix3_be_module-minix3_be.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_be_module_CPPFLAGS) $(CPPFLAGS) $(minix3_be_module_CFLAGS) $(CFLAGS) -c -o fs/minix3_be_module-minix3_be.o `test -f 'fs/minix3_be.c' || echo '$(srcdir)/'`fs/minix3_be.c
+
+fs/minix3_be_module-minix3_be.obj: fs/minix3_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_be_module_CPPFLAGS) $(CPPFLAGS) $(minix3_be_module_CFLAGS) $(CFLAGS) -MT fs/minix3_be_module-minix3_be.obj -MD -MP -MF fs/$(DEPDIR)/minix3_be_module-minix3_be.Tpo -c -o fs/minix3_be_module-minix3_be.obj `if test -f 'fs/minix3_be.c'; then $(CYGPATH_W) 'fs/minix3_be.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix3_be.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix3_be_module-minix3_be.Tpo fs/$(DEPDIR)/minix3_be_module-minix3_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix3_be.c' object='fs/minix3_be_module-minix3_be.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_be_module_CPPFLAGS) $(CPPFLAGS) $(minix3_be_module_CFLAGS) $(CFLAGS) -c -o fs/minix3_be_module-minix3_be.obj `if test -f 'fs/minix3_be.c'; then $(CYGPATH_W) 'fs/minix3_be.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix3_be.c'; fi`
+
+fs/minix_be_module-minix_be.o: fs/minix_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_be_module_CPPFLAGS) $(CPPFLAGS) $(minix_be_module_CFLAGS) $(CFLAGS) -MT fs/minix_be_module-minix_be.o -MD -MP -MF fs/$(DEPDIR)/minix_be_module-minix_be.Tpo -c -o fs/minix_be_module-minix_be.o `test -f 'fs/minix_be.c' || echo '$(srcdir)/'`fs/minix_be.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix_be_module-minix_be.Tpo fs/$(DEPDIR)/minix_be_module-minix_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix_be.c' object='fs/minix_be_module-minix_be.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_be_module_CPPFLAGS) $(CPPFLAGS) $(minix_be_module_CFLAGS) $(CFLAGS) -c -o fs/minix_be_module-minix_be.o `test -f 'fs/minix_be.c' || echo '$(srcdir)/'`fs/minix_be.c
+
+fs/minix_be_module-minix_be.obj: fs/minix_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_be_module_CPPFLAGS) $(CPPFLAGS) $(minix_be_module_CFLAGS) $(CFLAGS) -MT fs/minix_be_module-minix_be.obj -MD -MP -MF fs/$(DEPDIR)/minix_be_module-minix_be.Tpo -c -o fs/minix_be_module-minix_be.obj `if test -f 'fs/minix_be.c'; then $(CYGPATH_W) 'fs/minix_be.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix_be.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/minix_be_module-minix_be.Tpo fs/$(DEPDIR)/minix_be_module-minix_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/minix_be.c' object='fs/minix_be_module-minix_be.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_be_module_CPPFLAGS) $(CPPFLAGS) $(minix_be_module_CFLAGS) $(CFLAGS) -c -o fs/minix_be_module-minix_be.obj `if test -f 'fs/minix_be.c'; then $(CYGPATH_W) 'fs/minix_be.c'; else $(CYGPATH_W) '$(srcdir)/fs/minix_be.c'; fi`
+
+mmap/efi/mmap_module-mmap.o: mmap/efi/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/efi/mmap_module-mmap.o -MD -MP -MF mmap/efi/$(DEPDIR)/mmap_module-mmap.Tpo -c -o mmap/efi/mmap_module-mmap.o `test -f 'mmap/efi/mmap.c' || echo '$(srcdir)/'`mmap/efi/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/efi/$(DEPDIR)/mmap_module-mmap.Tpo mmap/efi/$(DEPDIR)/mmap_module-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/efi/mmap.c' object='mmap/efi/mmap_module-mmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/efi/mmap_module-mmap.o `test -f 'mmap/efi/mmap.c' || echo '$(srcdir)/'`mmap/efi/mmap.c
+
+mmap/efi/mmap_module-mmap.obj: mmap/efi/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/efi/mmap_module-mmap.obj -MD -MP -MF mmap/efi/$(DEPDIR)/mmap_module-mmap.Tpo -c -o mmap/efi/mmap_module-mmap.obj `if test -f 'mmap/efi/mmap.c'; then $(CYGPATH_W) 'mmap/efi/mmap.c'; else $(CYGPATH_W) '$(srcdir)/mmap/efi/mmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/efi/$(DEPDIR)/mmap_module-mmap.Tpo mmap/efi/$(DEPDIR)/mmap_module-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/efi/mmap.c' object='mmap/efi/mmap_module-mmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/efi/mmap_module-mmap.obj `if test -f 'mmap/efi/mmap.c'; then $(CYGPATH_W) 'mmap/efi/mmap.c'; else $(CYGPATH_W) '$(srcdir)/mmap/efi/mmap.c'; fi`
+
+mmap/mmap_module-mmap.o: mmap/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/mmap_module-mmap.o -MD -MP -MF mmap/$(DEPDIR)/mmap_module-mmap.Tpo -c -o mmap/mmap_module-mmap.o `test -f 'mmap/mmap.c' || echo '$(srcdir)/'`mmap/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/$(DEPDIR)/mmap_module-mmap.Tpo mmap/$(DEPDIR)/mmap_module-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/mmap.c' object='mmap/mmap_module-mmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/mmap_module-mmap.o `test -f 'mmap/mmap.c' || echo '$(srcdir)/'`mmap/mmap.c
+
+mmap/mmap_module-mmap.obj: mmap/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/mmap_module-mmap.obj -MD -MP -MF mmap/$(DEPDIR)/mmap_module-mmap.Tpo -c -o mmap/mmap_module-mmap.obj `if test -f 'mmap/mmap.c'; then $(CYGPATH_W) 'mmap/mmap.c'; else $(CYGPATH_W) '$(srcdir)/mmap/mmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/$(DEPDIR)/mmap_module-mmap.Tpo mmap/$(DEPDIR)/mmap_module-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/mmap.c' object='mmap/mmap_module-mmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/mmap_module-mmap.obj `if test -f 'mmap/mmap.c'; then $(CYGPATH_W) 'mmap/mmap.c'; else $(CYGPATH_W) '$(srcdir)/mmap/mmap.c'; fi`
+
+mmap/i386/mmap_module-uppermem.o: mmap/i386/uppermem.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/i386/mmap_module-uppermem.o -MD -MP -MF mmap/i386/$(DEPDIR)/mmap_module-uppermem.Tpo -c -o mmap/i386/mmap_module-uppermem.o `test -f 'mmap/i386/uppermem.c' || echo '$(srcdir)/'`mmap/i386/uppermem.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/i386/$(DEPDIR)/mmap_module-uppermem.Tpo mmap/i386/$(DEPDIR)/mmap_module-uppermem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/i386/uppermem.c' object='mmap/i386/mmap_module-uppermem.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/i386/mmap_module-uppermem.o `test -f 'mmap/i386/uppermem.c' || echo '$(srcdir)/'`mmap/i386/uppermem.c
+
+mmap/i386/mmap_module-uppermem.obj: mmap/i386/uppermem.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/i386/mmap_module-uppermem.obj -MD -MP -MF mmap/i386/$(DEPDIR)/mmap_module-uppermem.Tpo -c -o mmap/i386/mmap_module-uppermem.obj `if test -f 'mmap/i386/uppermem.c'; then $(CYGPATH_W) 'mmap/i386/uppermem.c'; else $(CYGPATH_W) '$(srcdir)/mmap/i386/uppermem.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/i386/$(DEPDIR)/mmap_module-uppermem.Tpo mmap/i386/$(DEPDIR)/mmap_module-uppermem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/i386/uppermem.c' object='mmap/i386/mmap_module-uppermem.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/i386/mmap_module-uppermem.obj `if test -f 'mmap/i386/uppermem.c'; then $(CYGPATH_W) 'mmap/i386/uppermem.c'; else $(CYGPATH_W) '$(srcdir)/mmap/i386/uppermem.c'; fi`
+
+mmap/i386/mmap_module-mmap.o: mmap/i386/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/i386/mmap_module-mmap.o -MD -MP -MF mmap/i386/$(DEPDIR)/mmap_module-mmap.Tpo -c -o mmap/i386/mmap_module-mmap.o `test -f 'mmap/i386/mmap.c' || echo '$(srcdir)/'`mmap/i386/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/i386/$(DEPDIR)/mmap_module-mmap.Tpo mmap/i386/$(DEPDIR)/mmap_module-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/i386/mmap.c' object='mmap/i386/mmap_module-mmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/i386/mmap_module-mmap.o `test -f 'mmap/i386/mmap.c' || echo '$(srcdir)/'`mmap/i386/mmap.c
+
+mmap/i386/mmap_module-mmap.obj: mmap/i386/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/i386/mmap_module-mmap.obj -MD -MP -MF mmap/i386/$(DEPDIR)/mmap_module-mmap.Tpo -c -o mmap/i386/mmap_module-mmap.obj `if test -f 'mmap/i386/mmap.c'; then $(CYGPATH_W) 'mmap/i386/mmap.c'; else $(CYGPATH_W) '$(srcdir)/mmap/i386/mmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/i386/$(DEPDIR)/mmap_module-mmap.Tpo mmap/i386/$(DEPDIR)/mmap_module-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/i386/mmap.c' object='mmap/i386/mmap_module-mmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/i386/mmap_module-mmap.obj `if test -f 'mmap/i386/mmap.c'; then $(CYGPATH_W) 'mmap/i386/mmap.c'; else $(CYGPATH_W) '$(srcdir)/mmap/i386/mmap.c'; fi`
+
+mmap/i386/pc/mmap_module-mmap.o: mmap/i386/pc/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/i386/pc/mmap_module-mmap.o -MD -MP -MF mmap/i386/pc/$(DEPDIR)/mmap_module-mmap.Tpo -c -o mmap/i386/pc/mmap_module-mmap.o `test -f 'mmap/i386/pc/mmap.c' || echo '$(srcdir)/'`mmap/i386/pc/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/i386/pc/$(DEPDIR)/mmap_module-mmap.Tpo mmap/i386/pc/$(DEPDIR)/mmap_module-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/i386/pc/mmap.c' object='mmap/i386/pc/mmap_module-mmap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/i386/pc/mmap_module-mmap.o `test -f 'mmap/i386/pc/mmap.c' || echo '$(srcdir)/'`mmap/i386/pc/mmap.c
+
+mmap/i386/pc/mmap_module-mmap.obj: mmap/i386/pc/mmap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/i386/pc/mmap_module-mmap.obj -MD -MP -MF mmap/i386/pc/$(DEPDIR)/mmap_module-mmap.Tpo -c -o mmap/i386/pc/mmap_module-mmap.obj `if test -f 'mmap/i386/pc/mmap.c'; then $(CYGPATH_W) 'mmap/i386/pc/mmap.c'; else $(CYGPATH_W) '$(srcdir)/mmap/i386/pc/mmap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/i386/pc/$(DEPDIR)/mmap_module-mmap.Tpo mmap/i386/pc/$(DEPDIR)/mmap_module-mmap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/i386/pc/mmap.c' object='mmap/i386/pc/mmap_module-mmap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/i386/pc/mmap_module-mmap.obj `if test -f 'mmap/i386/pc/mmap.c'; then $(CYGPATH_W) 'mmap/i386/pc/mmap.c'; else $(CYGPATH_W) '$(srcdir)/mmap/i386/pc/mmap.c'; fi`
+
+mmap/mips/mmap_module-uppermem.o: mmap/mips/uppermem.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/mips/mmap_module-uppermem.o -MD -MP -MF mmap/mips/$(DEPDIR)/mmap_module-uppermem.Tpo -c -o mmap/mips/mmap_module-uppermem.o `test -f 'mmap/mips/uppermem.c' || echo '$(srcdir)/'`mmap/mips/uppermem.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/mips/$(DEPDIR)/mmap_module-uppermem.Tpo mmap/mips/$(DEPDIR)/mmap_module-uppermem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/mips/uppermem.c' object='mmap/mips/mmap_module-uppermem.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/mips/mmap_module-uppermem.o `test -f 'mmap/mips/uppermem.c' || echo '$(srcdir)/'`mmap/mips/uppermem.c
+
+mmap/mips/mmap_module-uppermem.obj: mmap/mips/uppermem.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -MT mmap/mips/mmap_module-uppermem.obj -MD -MP -MF mmap/mips/$(DEPDIR)/mmap_module-uppermem.Tpo -c -o mmap/mips/mmap_module-uppermem.obj `if test -f 'mmap/mips/uppermem.c'; then $(CYGPATH_W) 'mmap/mips/uppermem.c'; else $(CYGPATH_W) '$(srcdir)/mmap/mips/uppermem.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mmap/mips/$(DEPDIR)/mmap_module-uppermem.Tpo mmap/mips/$(DEPDIR)/mmap_module-uppermem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mmap/mips/uppermem.c' object='mmap/mips/mmap_module-uppermem.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $(mmap_module_CFLAGS) $(CFLAGS) -c -o mmap/mips/mmap_module-uppermem.obj `if test -f 'mmap/mips/uppermem.c'; then $(CYGPATH_W) 'mmap/mips/uppermem.c'; else $(CYGPATH_W) '$(srcdir)/mmap/mips/uppermem.c'; fi`
+
+term/morse_module-morse.o: term/morse.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $(morse_module_CFLAGS) $(CFLAGS) -MT term/morse_module-morse.o -MD -MP -MF term/$(DEPDIR)/morse_module-morse.Tpo -c -o term/morse_module-morse.o `test -f 'term/morse.c' || echo '$(srcdir)/'`term/morse.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/morse_module-morse.Tpo term/$(DEPDIR)/morse_module-morse.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/morse.c' object='term/morse_module-morse.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $(morse_module_CFLAGS) $(CFLAGS) -c -o term/morse_module-morse.o `test -f 'term/morse.c' || echo '$(srcdir)/'`term/morse.c
+
+term/morse_module-morse.obj: term/morse.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $(morse_module_CFLAGS) $(CFLAGS) -MT term/morse_module-morse.obj -MD -MP -MF term/$(DEPDIR)/morse_module-morse.Tpo -c -o term/morse_module-morse.obj `if test -f 'term/morse.c'; then $(CYGPATH_W) 'term/morse.c'; else $(CYGPATH_W) '$(srcdir)/term/morse.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/morse_module-morse.Tpo term/$(DEPDIR)/morse_module-morse.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/morse.c' object='term/morse_module-morse.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $(morse_module_CFLAGS) $(CFLAGS) -c -o term/morse_module-morse.obj `if test -f 'term/morse.c'; then $(CYGPATH_W) 'term/morse.c'; else $(CYGPATH_W) '$(srcdir)/term/morse.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpiutil.o: lib/libgcrypt-grub/mpi/mpiutil.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpiutil.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpiutil.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpiutil.o `test -f 'lib/libgcrypt-grub/mpi/mpiutil.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpiutil.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpiutil.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpiutil.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpiutil.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpiutil.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpiutil.o `test -f 'lib/libgcrypt-grub/mpi/mpiutil.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpiutil.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpiutil.obj: lib/libgcrypt-grub/mpi/mpiutil.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpiutil.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpiutil.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpiutil.obj `if test -f 'lib/libgcrypt-grub/mpi/mpiutil.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpiutil.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpiutil.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpiutil.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpiutil.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpiutil.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpiutil.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpiutil.obj `if test -f 'lib/libgcrypt-grub/mpi/mpiutil.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpiutil.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpiutil.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.o: lib/libgcrypt-grub/mpi/mpi-bit.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-bit.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.o `test -f 'lib/libgcrypt-grub/mpi/mpi-bit.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-bit.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-bit.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-bit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-bit.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.o `test -f 'lib/libgcrypt-grub/mpi/mpi-bit.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-bit.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.obj: lib/libgcrypt-grub/mpi/mpi-bit.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-bit.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-bit.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-bit.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-bit.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-bit.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-bit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-bit.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-bit.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-bit.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-bit.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-bit.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-add.o: lib/libgcrypt-grub/mpi/mpi-add.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-add.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-add.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-add.o `test -f 'lib/libgcrypt-grub/mpi/mpi-add.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-add.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-add.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-add.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-add.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-add.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-add.o `test -f 'lib/libgcrypt-grub/mpi/mpi-add.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-add.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-add.obj: lib/libgcrypt-grub/mpi/mpi-add.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-add.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-add.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-add.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-add.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-add.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-add.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-add.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-add.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-add.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-add.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-add.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-add.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-add.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-add.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.o: lib/libgcrypt-grub/mpi/mpi-mul.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mul.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.o `test -f 'lib/libgcrypt-grub/mpi/mpi-mul.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-mul.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mul.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mul.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-mul.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.o `test -f 'lib/libgcrypt-grub/mpi/mpi-mul.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-mul.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.obj: lib/libgcrypt-grub/mpi/mpi-mul.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mul.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-mul.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-mul.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-mul.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mul.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mul.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-mul.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mul.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-mul.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-mul.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-mul.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.o: lib/libgcrypt-grub/mpi/mpi-mod.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mod.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.o `test -f 'lib/libgcrypt-grub/mpi/mpi-mod.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-mod.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mod.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mod.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-mod.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.o `test -f 'lib/libgcrypt-grub/mpi/mpi-mod.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-mod.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.obj: lib/libgcrypt-grub/mpi/mpi-mod.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mod.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-mod.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-mod.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-mod.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mod.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mod.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-mod.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mod.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-mod.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-mod.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-mod.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.o: lib/libgcrypt-grub/mpi/mpi-gcd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-gcd.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.o `test -f 'lib/libgcrypt-grub/mpi/mpi-gcd.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-gcd.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-gcd.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-gcd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-gcd.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.o `test -f 'lib/libgcrypt-grub/mpi/mpi-gcd.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-gcd.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.obj: lib/libgcrypt-grub/mpi/mpi-gcd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-gcd.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-gcd.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-gcd.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-gcd.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-gcd.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-gcd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-gcd.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-gcd.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-gcd.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-gcd.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-gcd.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-div.o: lib/libgcrypt-grub/mpi/mpi-div.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-div.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-div.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-div.o `test -f 'lib/libgcrypt-grub/mpi/mpi-div.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-div.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-div.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-div.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-div.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-div.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-div.o `test -f 'lib/libgcrypt-grub/mpi/mpi-div.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-div.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-div.obj: lib/libgcrypt-grub/mpi/mpi-div.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-div.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-div.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-div.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-div.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-div.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-div.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-div.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-div.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-div.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-div.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-div.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-div.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-div.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-div.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.o: lib/libgcrypt-grub/mpi/mpi-cmp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-cmp.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.o `test -f 'lib/libgcrypt-grub/mpi/mpi-cmp.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-cmp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-cmp.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-cmp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-cmp.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.o `test -f 'lib/libgcrypt-grub/mpi/mpi-cmp.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-cmp.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.obj: lib/libgcrypt-grub/mpi/mpi-cmp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-cmp.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-cmp.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-cmp.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-cmp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-cmp.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-cmp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-cmp.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-cmp.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-cmp.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-cmp.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-cmp.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.o: lib/libgcrypt-grub/mpi/mpi-inv.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inv.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.o `test -f 'lib/libgcrypt-grub/mpi/mpi-inv.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-inv.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inv.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-inv.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.o `test -f 'lib/libgcrypt-grub/mpi/mpi-inv.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-inv.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.obj: lib/libgcrypt-grub/mpi/mpi-inv.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inv.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-inv.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-inv.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-inv.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inv.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-inv.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-inv.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-inv.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-inv.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-inv.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.o: lib/libgcrypt-grub/mpi/mpi-pow.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-pow.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.o `test -f 'lib/libgcrypt-grub/mpi/mpi-pow.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-pow.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-pow.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-pow.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-pow.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.o `test -f 'lib/libgcrypt-grub/mpi/mpi-pow.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-pow.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.obj: lib/libgcrypt-grub/mpi/mpi-pow.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-pow.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-pow.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-pow.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-pow.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-pow.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-pow.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-pow.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-pow.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-pow.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-pow.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-pow.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.o: lib/libgcrypt-grub/mpi/mpi-mpow.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mpow.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.o `test -f 'lib/libgcrypt-grub/mpi/mpi-mpow.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-mpow.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mpow.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mpow.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-mpow.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.o `test -f 'lib/libgcrypt-grub/mpi/mpi-mpow.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-mpow.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.obj: lib/libgcrypt-grub/mpi/mpi-mpow.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mpow.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-mpow.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-mpow.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-mpow.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mpow.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-mpow.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-mpow.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-mpow.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-mpow.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-mpow.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-mpow.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.o: lib/libgcrypt-grub/mpi/mpih-lshift.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-lshift.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.o `test -f 'lib/libgcrypt-grub/mpi/mpih-lshift.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-lshift.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-lshift.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-lshift.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-lshift.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.o `test -f 'lib/libgcrypt-grub/mpi/mpih-lshift.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-lshift.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.obj: lib/libgcrypt-grub/mpi/mpih-lshift.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-lshift.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-lshift.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-lshift.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-lshift.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-lshift.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-lshift.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-lshift.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-lshift.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-lshift.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-lshift.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-lshift.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.o: lib/libgcrypt-grub/mpi/mpih-mul.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.o `test -f 'lib/libgcrypt-grub/mpi/mpih-mul.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-mul.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-mul.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.o `test -f 'lib/libgcrypt-grub/mpi/mpih-mul.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-mul.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.obj: lib/libgcrypt-grub/mpi/mpih-mul.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-mul.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-mul.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-mul.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-mul.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-mul.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-mul.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-mul.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.o: lib/libgcrypt-grub/mpi/mpih-mul1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul1.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.o `test -f 'lib/libgcrypt-grub/mpi/mpih-mul1.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-mul1.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul1.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul1.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-mul1.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.o `test -f 'lib/libgcrypt-grub/mpi/mpih-mul1.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-mul1.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.obj: lib/libgcrypt-grub/mpi/mpih-mul1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul1.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-mul1.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-mul1.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-mul1.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul1.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul1.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-mul1.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul1.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-mul1.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-mul1.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-mul1.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.o: lib/libgcrypt-grub/mpi/mpih-mul2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul2.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.o `test -f 'lib/libgcrypt-grub/mpi/mpih-mul2.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-mul2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul2.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-mul2.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.o `test -f 'lib/libgcrypt-grub/mpi/mpih-mul2.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-mul2.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.obj: lib/libgcrypt-grub/mpi/mpih-mul2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul2.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-mul2.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-mul2.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-mul2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul2.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-mul2.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul2.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-mul2.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-mul2.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-mul2.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.o: lib/libgcrypt-grub/mpi/mpih-mul3.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul3.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.o `test -f 'lib/libgcrypt-grub/mpi/mpih-mul3.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-mul3.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul3.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul3.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-mul3.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.o `test -f 'lib/libgcrypt-grub/mpi/mpih-mul3.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-mul3.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.obj: lib/libgcrypt-grub/mpi/mpih-mul3.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul3.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-mul3.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-mul3.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-mul3.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul3.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-mul3.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-mul3.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-mul3.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-mul3.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-mul3.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-mul3.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.o: lib/libgcrypt-grub/mpi/mpih-add1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-add1.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.o `test -f 'lib/libgcrypt-grub/mpi/mpih-add1.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-add1.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-add1.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-add1.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-add1.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.o `test -f 'lib/libgcrypt-grub/mpi/mpih-add1.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-add1.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.obj: lib/libgcrypt-grub/mpi/mpih-add1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-add1.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-add1.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-add1.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-add1.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-add1.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-add1.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-add1.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-add1.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-add1.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-add1.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-add1.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.o: lib/libgcrypt-grub/mpi/mpih-sub1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-sub1.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.o `test -f 'lib/libgcrypt-grub/mpi/mpih-sub1.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-sub1.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-sub1.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-sub1.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-sub1.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.o `test -f 'lib/libgcrypt-grub/mpi/mpih-sub1.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-sub1.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.obj: lib/libgcrypt-grub/mpi/mpih-sub1.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-sub1.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-sub1.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-sub1.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-sub1.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-sub1.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-sub1.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-sub1.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-sub1.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-sub1.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-sub1.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-sub1.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-div.o: lib/libgcrypt-grub/mpi/mpih-div.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-div.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-div.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-div.o `test -f 'lib/libgcrypt-grub/mpi/mpih-div.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-div.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-div.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-div.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-div.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-div.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-div.o `test -f 'lib/libgcrypt-grub/mpi/mpih-div.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-div.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-div.obj: lib/libgcrypt-grub/mpi/mpih-div.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-div.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-div.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-div.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-div.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-div.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-div.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-div.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-div.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-div.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-div.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-div.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-div.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-div.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-div.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpicoder.o: lib/libgcrypt-grub/mpi/mpicoder.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpicoder.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpicoder.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpicoder.o `test -f 'lib/libgcrypt-grub/mpi/mpicoder.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpicoder.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpicoder.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpicoder.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpicoder.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpicoder.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpicoder.o `test -f 'lib/libgcrypt-grub/mpi/mpicoder.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpicoder.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpicoder.obj: lib/libgcrypt-grub/mpi/mpicoder.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpicoder.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpicoder.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpicoder.obj `if test -f 'lib/libgcrypt-grub/mpi/mpicoder.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpicoder.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpicoder.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpicoder.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpicoder.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpicoder.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpicoder.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpicoder.obj `if test -f 'lib/libgcrypt-grub/mpi/mpicoder.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpicoder.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpicoder.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.o: lib/libgcrypt-grub/mpi/mpih-rshift.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-rshift.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.o `test -f 'lib/libgcrypt-grub/mpi/mpih-rshift.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-rshift.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-rshift.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-rshift.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-rshift.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.o `test -f 'lib/libgcrypt-grub/mpi/mpih-rshift.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpih-rshift.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.obj: lib/libgcrypt-grub/mpi/mpih-rshift.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-rshift.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-rshift.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-rshift.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-rshift.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-rshift.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpih-rshift.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpih-rshift.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpih-rshift.obj `if test -f 'lib/libgcrypt-grub/mpi/mpih-rshift.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpih-rshift.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpih-rshift.c'; fi`
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.o: lib/libgcrypt-grub/mpi/mpi-inline.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.o -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inline.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.o `test -f 'lib/libgcrypt-grub/mpi/mpi-inline.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-inline.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inline.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inline.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-inline.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.o `test -f 'lib/libgcrypt-grub/mpi/mpi-inline.c' || echo '$(srcdir)/'`lib/libgcrypt-grub/mpi/mpi-inline.c
+
+lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.obj: lib/libgcrypt-grub/mpi/mpi-inline.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.obj -MD -MP -MF lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inline.Tpo -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-inline.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-inline.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-inline.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inline.Tpo lib/libgcrypt-grub/mpi/$(DEPDIR)/mpi_module-mpi-inline.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt-grub/mpi/mpi-inline.c' object='lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt-grub/mpi/mpi_module-mpi-inline.obj `if test -f 'lib/libgcrypt-grub/mpi/mpi-inline.c'; then $(CYGPATH_W) 'lib/libgcrypt-grub/mpi/mpi-inline.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt-grub/mpi/mpi-inline.c'; fi`
+
+lib/libgcrypt_wrap/mpi_module-mem.o: lib/libgcrypt_wrap/mem.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt_wrap/mpi_module-mem.o -MD -MP -MF lib/libgcrypt_wrap/$(DEPDIR)/mpi_module-mem.Tpo -c -o lib/libgcrypt_wrap/mpi_module-mem.o `test -f 'lib/libgcrypt_wrap/mem.c' || echo '$(srcdir)/'`lib/libgcrypt_wrap/mem.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt_wrap/$(DEPDIR)/mpi_module-mem.Tpo lib/libgcrypt_wrap/$(DEPDIR)/mpi_module-mem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt_wrap/mem.c' object='lib/libgcrypt_wrap/mpi_module-mem.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt_wrap/mpi_module-mem.o `test -f 'lib/libgcrypt_wrap/mem.c' || echo '$(srcdir)/'`lib/libgcrypt_wrap/mem.c
+
+lib/libgcrypt_wrap/mpi_module-mem.obj: lib/libgcrypt_wrap/mem.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -MT lib/libgcrypt_wrap/mpi_module-mem.obj -MD -MP -MF lib/libgcrypt_wrap/$(DEPDIR)/mpi_module-mem.Tpo -c -o lib/libgcrypt_wrap/mpi_module-mem.obj `if test -f 'lib/libgcrypt_wrap/mem.c'; then $(CYGPATH_W) 'lib/libgcrypt_wrap/mem.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt_wrap/mem.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/libgcrypt_wrap/$(DEPDIR)/mpi_module-mem.Tpo lib/libgcrypt_wrap/$(DEPDIR)/mpi_module-mem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/libgcrypt_wrap/mem.c' object='lib/libgcrypt_wrap/mpi_module-mem.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $(mpi_module_CFLAGS) $(CFLAGS) -c -o lib/libgcrypt_wrap/mpi_module-mem.obj `if test -f 'lib/libgcrypt_wrap/mem.c'; then $(CYGPATH_W) 'lib/libgcrypt_wrap/mem.c'; else $(CYGPATH_W) '$(srcdir)/lib/libgcrypt_wrap/mem.c'; fi`
+
+parttool/msdospart_module-msdospart.o: parttool/msdospart.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(msdospart_module_CPPFLAGS) $(CPPFLAGS) $(msdospart_module_CFLAGS) $(CFLAGS) -MT parttool/msdospart_module-msdospart.o -MD -MP -MF parttool/$(DEPDIR)/msdospart_module-msdospart.Tpo -c -o parttool/msdospart_module-msdospart.o `test -f 'parttool/msdospart.c' || echo '$(srcdir)/'`parttool/msdospart.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) parttool/$(DEPDIR)/msdospart_module-msdospart.Tpo parttool/$(DEPDIR)/msdospart_module-msdospart.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='parttool/msdospart.c' object='parttool/msdospart_module-msdospart.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(msdospart_module_CPPFLAGS) $(CPPFLAGS) $(msdospart_module_CFLAGS) $(CFLAGS) -c -o parttool/msdospart_module-msdospart.o `test -f 'parttool/msdospart.c' || echo '$(srcdir)/'`parttool/msdospart.c
+
+parttool/msdospart_module-msdospart.obj: parttool/msdospart.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(msdospart_module_CPPFLAGS) $(CPPFLAGS) $(msdospart_module_CFLAGS) $(CFLAGS) -MT parttool/msdospart_module-msdospart.obj -MD -MP -MF parttool/$(DEPDIR)/msdospart_module-msdospart.Tpo -c -o parttool/msdospart_module-msdospart.obj `if test -f 'parttool/msdospart.c'; then $(CYGPATH_W) 'parttool/msdospart.c'; else $(CYGPATH_W) '$(srcdir)/parttool/msdospart.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) parttool/$(DEPDIR)/msdospart_module-msdospart.Tpo parttool/$(DEPDIR)/msdospart_module-msdospart.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='parttool/msdospart.c' object='parttool/msdospart_module-msdospart.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(msdospart_module_CPPFLAGS) $(CPPFLAGS) $(msdospart_module_CFLAGS) $(CFLAGS) -c -o parttool/msdospart_module-msdospart.obj `if test -f 'parttool/msdospart.c'; then $(CYGPATH_W) 'parttool/msdospart.c'; else $(CYGPATH_W) '$(srcdir)/parttool/msdospart.c'; fi`
+
+tests/mul_test_module-mul_test.o: tests/mul_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mul_test_module_CPPFLAGS) $(CPPFLAGS) $(mul_test_module_CFLAGS) $(CFLAGS) -MT tests/mul_test_module-mul_test.o -MD -MP -MF tests/$(DEPDIR)/mul_test_module-mul_test.Tpo -c -o tests/mul_test_module-mul_test.o `test -f 'tests/mul_test.c' || echo '$(srcdir)/'`tests/mul_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/mul_test_module-mul_test.Tpo tests/$(DEPDIR)/mul_test_module-mul_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/mul_test.c' object='tests/mul_test_module-mul_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mul_test_module_CPPFLAGS) $(CPPFLAGS) $(mul_test_module_CFLAGS) $(CFLAGS) -c -o tests/mul_test_module-mul_test.o `test -f 'tests/mul_test.c' || echo '$(srcdir)/'`tests/mul_test.c
+
+tests/mul_test_module-mul_test.obj: tests/mul_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mul_test_module_CPPFLAGS) $(CPPFLAGS) $(mul_test_module_CFLAGS) $(CFLAGS) -MT tests/mul_test_module-mul_test.obj -MD -MP -MF tests/$(DEPDIR)/mul_test_module-mul_test.Tpo -c -o tests/mul_test_module-mul_test.obj `if test -f 'tests/mul_test.c'; then $(CYGPATH_W) 'tests/mul_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/mul_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/mul_test_module-mul_test.Tpo tests/$(DEPDIR)/mul_test_module-mul_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/mul_test.c' object='tests/mul_test_module-mul_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mul_test_module_CPPFLAGS) $(CPPFLAGS) $(mul_test_module_CFLAGS) $(CFLAGS) -c -o tests/mul_test_module-mul_test.obj `if test -f 'tests/mul_test.c'; then $(CYGPATH_W) 'tests/mul_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/mul_test.c'; fi`
+
+loader/i386/multiboot_module-multiboot_mbi.o: loader/i386/multiboot_mbi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $(multiboot_module_CFLAGS) $(CFLAGS) -MT loader/i386/multiboot_module-multiboot_mbi.o -MD -MP -MF loader/i386/$(DEPDIR)/multiboot_module-multiboot_mbi.Tpo -c -o loader/i386/multiboot_module-multiboot_mbi.o `test -f 'loader/i386/multiboot_mbi.c' || echo '$(srcdir)/'`loader/i386/multiboot_mbi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/multiboot_module-multiboot_mbi.Tpo loader/i386/$(DEPDIR)/multiboot_module-multiboot_mbi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/multiboot_mbi.c' object='loader/i386/multiboot_module-multiboot_mbi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $(multiboot_module_CFLAGS) $(CFLAGS) -c -o loader/i386/multiboot_module-multiboot_mbi.o `test -f 'loader/i386/multiboot_mbi.c' || echo '$(srcdir)/'`loader/i386/multiboot_mbi.c
+
+loader/i386/multiboot_module-multiboot_mbi.obj: loader/i386/multiboot_mbi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $(multiboot_module_CFLAGS) $(CFLAGS) -MT loader/i386/multiboot_module-multiboot_mbi.obj -MD -MP -MF loader/i386/$(DEPDIR)/multiboot_module-multiboot_mbi.Tpo -c -o loader/i386/multiboot_module-multiboot_mbi.obj `if test -f 'loader/i386/multiboot_mbi.c'; then $(CYGPATH_W) 'loader/i386/multiboot_mbi.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/multiboot_mbi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/multiboot_module-multiboot_mbi.Tpo loader/i386/$(DEPDIR)/multiboot_module-multiboot_mbi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/multiboot_mbi.c' object='loader/i386/multiboot_module-multiboot_mbi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $(multiboot_module_CFLAGS) $(CFLAGS) -c -o loader/i386/multiboot_module-multiboot_mbi.obj `if test -f 'loader/i386/multiboot_mbi.c'; then $(CYGPATH_W) 'loader/i386/multiboot_mbi.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/multiboot_mbi.c'; fi`
+
+loader/multiboot_module-multiboot.o: loader/multiboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $(multiboot_module_CFLAGS) $(CFLAGS) -MT loader/multiboot_module-multiboot.o -MD -MP -MF loader/$(DEPDIR)/multiboot_module-multiboot.Tpo -c -o loader/multiboot_module-multiboot.o `test -f 'loader/multiboot.c' || echo '$(srcdir)/'`loader/multiboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/multiboot_module-multiboot.Tpo loader/$(DEPDIR)/multiboot_module-multiboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/multiboot.c' object='loader/multiboot_module-multiboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $(multiboot_module_CFLAGS) $(CFLAGS) -c -o loader/multiboot_module-multiboot.o `test -f 'loader/multiboot.c' || echo '$(srcdir)/'`loader/multiboot.c
+
+loader/multiboot_module-multiboot.obj: loader/multiboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $(multiboot_module_CFLAGS) $(CFLAGS) -MT loader/multiboot_module-multiboot.obj -MD -MP -MF loader/$(DEPDIR)/multiboot_module-multiboot.Tpo -c -o loader/multiboot_module-multiboot.obj `if test -f 'loader/multiboot.c'; then $(CYGPATH_W) 'loader/multiboot.c'; else $(CYGPATH_W) '$(srcdir)/loader/multiboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/multiboot_module-multiboot.Tpo loader/$(DEPDIR)/multiboot_module-multiboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/multiboot.c' object='loader/multiboot_module-multiboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $(multiboot_module_CFLAGS) $(CFLAGS) -c -o loader/multiboot_module-multiboot.obj `if test -f 'loader/multiboot.c'; then $(CYGPATH_W) 'loader/multiboot.c'; else $(CYGPATH_W) '$(srcdir)/loader/multiboot.c'; fi`
+
+loader/multiboot2_module-multiboot.o: loader/multiboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $(multiboot2_module_CFLAGS) $(CFLAGS) -MT loader/multiboot2_module-multiboot.o -MD -MP -MF loader/$(DEPDIR)/multiboot2_module-multiboot.Tpo -c -o loader/multiboot2_module-multiboot.o `test -f 'loader/multiboot.c' || echo '$(srcdir)/'`loader/multiboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/multiboot2_module-multiboot.Tpo loader/$(DEPDIR)/multiboot2_module-multiboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/multiboot.c' object='loader/multiboot2_module-multiboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $(multiboot2_module_CFLAGS) $(CFLAGS) -c -o loader/multiboot2_module-multiboot.o `test -f 'loader/multiboot.c' || echo '$(srcdir)/'`loader/multiboot.c
+
+loader/multiboot2_module-multiboot.obj: loader/multiboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $(multiboot2_module_CFLAGS) $(CFLAGS) -MT loader/multiboot2_module-multiboot.obj -MD -MP -MF loader/$(DEPDIR)/multiboot2_module-multiboot.Tpo -c -o loader/multiboot2_module-multiboot.obj `if test -f 'loader/multiboot.c'; then $(CYGPATH_W) 'loader/multiboot.c'; else $(CYGPATH_W) '$(srcdir)/loader/multiboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/multiboot2_module-multiboot.Tpo loader/$(DEPDIR)/multiboot2_module-multiboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/multiboot.c' object='loader/multiboot2_module-multiboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $(multiboot2_module_CFLAGS) $(CFLAGS) -c -o loader/multiboot2_module-multiboot.obj `if test -f 'loader/multiboot.c'; then $(CYGPATH_W) 'loader/multiboot.c'; else $(CYGPATH_W) '$(srcdir)/loader/multiboot.c'; fi`
+
+loader/multiboot2_module-multiboot_mbi2.o: loader/multiboot_mbi2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $(multiboot2_module_CFLAGS) $(CFLAGS) -MT loader/multiboot2_module-multiboot_mbi2.o -MD -MP -MF loader/$(DEPDIR)/multiboot2_module-multiboot_mbi2.Tpo -c -o loader/multiboot2_module-multiboot_mbi2.o `test -f 'loader/multiboot_mbi2.c' || echo '$(srcdir)/'`loader/multiboot_mbi2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/multiboot2_module-multiboot_mbi2.Tpo loader/$(DEPDIR)/multiboot2_module-multiboot_mbi2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/multiboot_mbi2.c' object='loader/multiboot2_module-multiboot_mbi2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $(multiboot2_module_CFLAGS) $(CFLAGS) -c -o loader/multiboot2_module-multiboot_mbi2.o `test -f 'loader/multiboot_mbi2.c' || echo '$(srcdir)/'`loader/multiboot_mbi2.c
+
+loader/multiboot2_module-multiboot_mbi2.obj: loader/multiboot_mbi2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $(multiboot2_module_CFLAGS) $(CFLAGS) -MT loader/multiboot2_module-multiboot_mbi2.obj -MD -MP -MF loader/$(DEPDIR)/multiboot2_module-multiboot_mbi2.Tpo -c -o loader/multiboot2_module-multiboot_mbi2.obj `if test -f 'loader/multiboot_mbi2.c'; then $(CYGPATH_W) 'loader/multiboot_mbi2.c'; else $(CYGPATH_W) '$(srcdir)/loader/multiboot_mbi2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/multiboot2_module-multiboot_mbi2.Tpo loader/$(DEPDIR)/multiboot2_module-multiboot_mbi2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/multiboot_mbi2.c' object='loader/multiboot2_module-multiboot_mbi2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $(multiboot2_module_CFLAGS) $(CFLAGS) -c -o loader/multiboot2_module-multiboot_mbi2.obj `if test -f 'loader/multiboot_mbi2.c'; then $(CYGPATH_W) 'loader/multiboot_mbi2.c'; else $(CYGPATH_W) '$(srcdir)/loader/multiboot_mbi2.c'; fi`
+
+disk/ieee1275/nand_module-nand.o: disk/ieee1275/nand.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nand_module_CPPFLAGS) $(CPPFLAGS) $(nand_module_CFLAGS) $(CFLAGS) -MT disk/ieee1275/nand_module-nand.o -MD -MP -MF disk/ieee1275/$(DEPDIR)/nand_module-nand.Tpo -c -o disk/ieee1275/nand_module-nand.o `test -f 'disk/ieee1275/nand.c' || echo '$(srcdir)/'`disk/ieee1275/nand.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/ieee1275/$(DEPDIR)/nand_module-nand.Tpo disk/ieee1275/$(DEPDIR)/nand_module-nand.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ieee1275/nand.c' object='disk/ieee1275/nand_module-nand.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nand_module_CPPFLAGS) $(CPPFLAGS) $(nand_module_CFLAGS) $(CFLAGS) -c -o disk/ieee1275/nand_module-nand.o `test -f 'disk/ieee1275/nand.c' || echo '$(srcdir)/'`disk/ieee1275/nand.c
+
+disk/ieee1275/nand_module-nand.obj: disk/ieee1275/nand.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nand_module_CPPFLAGS) $(CPPFLAGS) $(nand_module_CFLAGS) $(CFLAGS) -MT disk/ieee1275/nand_module-nand.obj -MD -MP -MF disk/ieee1275/$(DEPDIR)/nand_module-nand.Tpo -c -o disk/ieee1275/nand_module-nand.obj `if test -f 'disk/ieee1275/nand.c'; then $(CYGPATH_W) 'disk/ieee1275/nand.c'; else $(CYGPATH_W) '$(srcdir)/disk/ieee1275/nand.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/ieee1275/$(DEPDIR)/nand_module-nand.Tpo disk/ieee1275/$(DEPDIR)/nand_module-nand.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/ieee1275/nand.c' object='disk/ieee1275/nand_module-nand.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nand_module_CPPFLAGS) $(CPPFLAGS) $(nand_module_CFLAGS) $(CFLAGS) -c -o disk/ieee1275/nand_module-nand.obj `if test -f 'disk/ieee1275/nand.c'; then $(CYGPATH_W) 'disk/ieee1275/nand.c'; else $(CYGPATH_W) '$(srcdir)/disk/ieee1275/nand.c'; fi`
+
+commands/nativedisk_module-nativedisk.o: commands/nativedisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $(nativedisk_module_CFLAGS) $(CFLAGS) -MT commands/nativedisk_module-nativedisk.o -MD -MP -MF commands/$(DEPDIR)/nativedisk_module-nativedisk.Tpo -c -o commands/nativedisk_module-nativedisk.o `test -f 'commands/nativedisk.c' || echo '$(srcdir)/'`commands/nativedisk.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/nativedisk_module-nativedisk.Tpo commands/$(DEPDIR)/nativedisk_module-nativedisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/nativedisk.c' object='commands/nativedisk_module-nativedisk.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $(nativedisk_module_CFLAGS) $(CFLAGS) -c -o commands/nativedisk_module-nativedisk.o `test -f 'commands/nativedisk.c' || echo '$(srcdir)/'`commands/nativedisk.c
+
+commands/nativedisk_module-nativedisk.obj: commands/nativedisk.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $(nativedisk_module_CFLAGS) $(CFLAGS) -MT commands/nativedisk_module-nativedisk.obj -MD -MP -MF commands/$(DEPDIR)/nativedisk_module-nativedisk.Tpo -c -o commands/nativedisk_module-nativedisk.obj `if test -f 'commands/nativedisk.c'; then $(CYGPATH_W) 'commands/nativedisk.c'; else $(CYGPATH_W) '$(srcdir)/commands/nativedisk.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/nativedisk_module-nativedisk.Tpo commands/$(DEPDIR)/nativedisk_module-nativedisk.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/nativedisk.c' object='commands/nativedisk_module-nativedisk.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $(nativedisk_module_CFLAGS) $(CFLAGS) -c -o commands/nativedisk_module-nativedisk.obj `if test -f 'commands/nativedisk.c'; then $(CYGPATH_W) 'commands/nativedisk.c'; else $(CYGPATH_W) '$(srcdir)/commands/nativedisk.c'; fi`
+
+net/net_module-net.o: net/net.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-net.o -MD -MP -MF net/$(DEPDIR)/net_module-net.Tpo -c -o net/net_module-net.o `test -f 'net/net.c' || echo '$(srcdir)/'`net/net.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-net.Tpo net/$(DEPDIR)/net_module-net.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/net.c' object='net/net_module-net.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-net.o `test -f 'net/net.c' || echo '$(srcdir)/'`net/net.c
+
+net/net_module-net.obj: net/net.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-net.obj -MD -MP -MF net/$(DEPDIR)/net_module-net.Tpo -c -o net/net_module-net.obj `if test -f 'net/net.c'; then $(CYGPATH_W) 'net/net.c'; else $(CYGPATH_W) '$(srcdir)/net/net.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-net.Tpo net/$(DEPDIR)/net_module-net.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/net.c' object='net/net_module-net.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-net.obj `if test -f 'net/net.c'; then $(CYGPATH_W) 'net/net.c'; else $(CYGPATH_W) '$(srcdir)/net/net.c'; fi`
+
+net/net_module-dns.o: net/dns.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-dns.o -MD -MP -MF net/$(DEPDIR)/net_module-dns.Tpo -c -o net/net_module-dns.o `test -f 'net/dns.c' || echo '$(srcdir)/'`net/dns.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-dns.Tpo net/$(DEPDIR)/net_module-dns.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/dns.c' object='net/net_module-dns.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-dns.o `test -f 'net/dns.c' || echo '$(srcdir)/'`net/dns.c
+
+net/net_module-dns.obj: net/dns.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-dns.obj -MD -MP -MF net/$(DEPDIR)/net_module-dns.Tpo -c -o net/net_module-dns.obj `if test -f 'net/dns.c'; then $(CYGPATH_W) 'net/dns.c'; else $(CYGPATH_W) '$(srcdir)/net/dns.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-dns.Tpo net/$(DEPDIR)/net_module-dns.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/dns.c' object='net/net_module-dns.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-dns.obj `if test -f 'net/dns.c'; then $(CYGPATH_W) 'net/dns.c'; else $(CYGPATH_W) '$(srcdir)/net/dns.c'; fi`
+
+net/net_module-bootp.o: net/bootp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-bootp.o -MD -MP -MF net/$(DEPDIR)/net_module-bootp.Tpo -c -o net/net_module-bootp.o `test -f 'net/bootp.c' || echo '$(srcdir)/'`net/bootp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-bootp.Tpo net/$(DEPDIR)/net_module-bootp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/bootp.c' object='net/net_module-bootp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-bootp.o `test -f 'net/bootp.c' || echo '$(srcdir)/'`net/bootp.c
+
+net/net_module-bootp.obj: net/bootp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-bootp.obj -MD -MP -MF net/$(DEPDIR)/net_module-bootp.Tpo -c -o net/net_module-bootp.obj `if test -f 'net/bootp.c'; then $(CYGPATH_W) 'net/bootp.c'; else $(CYGPATH_W) '$(srcdir)/net/bootp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-bootp.Tpo net/$(DEPDIR)/net_module-bootp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/bootp.c' object='net/net_module-bootp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-bootp.obj `if test -f 'net/bootp.c'; then $(CYGPATH_W) 'net/bootp.c'; else $(CYGPATH_W) '$(srcdir)/net/bootp.c'; fi`
+
+net/net_module-ip.o: net/ip.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-ip.o -MD -MP -MF net/$(DEPDIR)/net_module-ip.Tpo -c -o net/net_module-ip.o `test -f 'net/ip.c' || echo '$(srcdir)/'`net/ip.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-ip.Tpo net/$(DEPDIR)/net_module-ip.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/ip.c' object='net/net_module-ip.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-ip.o `test -f 'net/ip.c' || echo '$(srcdir)/'`net/ip.c
+
+net/net_module-ip.obj: net/ip.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-ip.obj -MD -MP -MF net/$(DEPDIR)/net_module-ip.Tpo -c -o net/net_module-ip.obj `if test -f 'net/ip.c'; then $(CYGPATH_W) 'net/ip.c'; else $(CYGPATH_W) '$(srcdir)/net/ip.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-ip.Tpo net/$(DEPDIR)/net_module-ip.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/ip.c' object='net/net_module-ip.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-ip.obj `if test -f 'net/ip.c'; then $(CYGPATH_W) 'net/ip.c'; else $(CYGPATH_W) '$(srcdir)/net/ip.c'; fi`
+
+net/net_module-udp.o: net/udp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-udp.o -MD -MP -MF net/$(DEPDIR)/net_module-udp.Tpo -c -o net/net_module-udp.o `test -f 'net/udp.c' || echo '$(srcdir)/'`net/udp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-udp.Tpo net/$(DEPDIR)/net_module-udp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/udp.c' object='net/net_module-udp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-udp.o `test -f 'net/udp.c' || echo '$(srcdir)/'`net/udp.c
+
+net/net_module-udp.obj: net/udp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-udp.obj -MD -MP -MF net/$(DEPDIR)/net_module-udp.Tpo -c -o net/net_module-udp.obj `if test -f 'net/udp.c'; then $(CYGPATH_W) 'net/udp.c'; else $(CYGPATH_W) '$(srcdir)/net/udp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-udp.Tpo net/$(DEPDIR)/net_module-udp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/udp.c' object='net/net_module-udp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-udp.obj `if test -f 'net/udp.c'; then $(CYGPATH_W) 'net/udp.c'; else $(CYGPATH_W) '$(srcdir)/net/udp.c'; fi`
+
+net/net_module-tcp.o: net/tcp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-tcp.o -MD -MP -MF net/$(DEPDIR)/net_module-tcp.Tpo -c -o net/net_module-tcp.o `test -f 'net/tcp.c' || echo '$(srcdir)/'`net/tcp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-tcp.Tpo net/$(DEPDIR)/net_module-tcp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/tcp.c' object='net/net_module-tcp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-tcp.o `test -f 'net/tcp.c' || echo '$(srcdir)/'`net/tcp.c
+
+net/net_module-tcp.obj: net/tcp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-tcp.obj -MD -MP -MF net/$(DEPDIR)/net_module-tcp.Tpo -c -o net/net_module-tcp.obj `if test -f 'net/tcp.c'; then $(CYGPATH_W) 'net/tcp.c'; else $(CYGPATH_W) '$(srcdir)/net/tcp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-tcp.Tpo net/$(DEPDIR)/net_module-tcp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/tcp.c' object='net/net_module-tcp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-tcp.obj `if test -f 'net/tcp.c'; then $(CYGPATH_W) 'net/tcp.c'; else $(CYGPATH_W) '$(srcdir)/net/tcp.c'; fi`
+
+net/net_module-icmp.o: net/icmp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-icmp.o -MD -MP -MF net/$(DEPDIR)/net_module-icmp.Tpo -c -o net/net_module-icmp.o `test -f 'net/icmp.c' || echo '$(srcdir)/'`net/icmp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-icmp.Tpo net/$(DEPDIR)/net_module-icmp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/icmp.c' object='net/net_module-icmp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-icmp.o `test -f 'net/icmp.c' || echo '$(srcdir)/'`net/icmp.c
+
+net/net_module-icmp.obj: net/icmp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-icmp.obj -MD -MP -MF net/$(DEPDIR)/net_module-icmp.Tpo -c -o net/net_module-icmp.obj `if test -f 'net/icmp.c'; then $(CYGPATH_W) 'net/icmp.c'; else $(CYGPATH_W) '$(srcdir)/net/icmp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-icmp.Tpo net/$(DEPDIR)/net_module-icmp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/icmp.c' object='net/net_module-icmp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-icmp.obj `if test -f 'net/icmp.c'; then $(CYGPATH_W) 'net/icmp.c'; else $(CYGPATH_W) '$(srcdir)/net/icmp.c'; fi`
+
+net/net_module-icmp6.o: net/icmp6.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-icmp6.o -MD -MP -MF net/$(DEPDIR)/net_module-icmp6.Tpo -c -o net/net_module-icmp6.o `test -f 'net/icmp6.c' || echo '$(srcdir)/'`net/icmp6.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-icmp6.Tpo net/$(DEPDIR)/net_module-icmp6.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/icmp6.c' object='net/net_module-icmp6.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-icmp6.o `test -f 'net/icmp6.c' || echo '$(srcdir)/'`net/icmp6.c
+
+net/net_module-icmp6.obj: net/icmp6.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-icmp6.obj -MD -MP -MF net/$(DEPDIR)/net_module-icmp6.Tpo -c -o net/net_module-icmp6.obj `if test -f 'net/icmp6.c'; then $(CYGPATH_W) 'net/icmp6.c'; else $(CYGPATH_W) '$(srcdir)/net/icmp6.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-icmp6.Tpo net/$(DEPDIR)/net_module-icmp6.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/icmp6.c' object='net/net_module-icmp6.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-icmp6.obj `if test -f 'net/icmp6.c'; then $(CYGPATH_W) 'net/icmp6.c'; else $(CYGPATH_W) '$(srcdir)/net/icmp6.c'; fi`
+
+net/net_module-ethernet.o: net/ethernet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-ethernet.o -MD -MP -MF net/$(DEPDIR)/net_module-ethernet.Tpo -c -o net/net_module-ethernet.o `test -f 'net/ethernet.c' || echo '$(srcdir)/'`net/ethernet.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-ethernet.Tpo net/$(DEPDIR)/net_module-ethernet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/ethernet.c' object='net/net_module-ethernet.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-ethernet.o `test -f 'net/ethernet.c' || echo '$(srcdir)/'`net/ethernet.c
+
+net/net_module-ethernet.obj: net/ethernet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-ethernet.obj -MD -MP -MF net/$(DEPDIR)/net_module-ethernet.Tpo -c -o net/net_module-ethernet.obj `if test -f 'net/ethernet.c'; then $(CYGPATH_W) 'net/ethernet.c'; else $(CYGPATH_W) '$(srcdir)/net/ethernet.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-ethernet.Tpo net/$(DEPDIR)/net_module-ethernet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/ethernet.c' object='net/net_module-ethernet.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-ethernet.obj `if test -f 'net/ethernet.c'; then $(CYGPATH_W) 'net/ethernet.c'; else $(CYGPATH_W) '$(srcdir)/net/ethernet.c'; fi`
+
+net/net_module-arp.o: net/arp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-arp.o -MD -MP -MF net/$(DEPDIR)/net_module-arp.Tpo -c -o net/net_module-arp.o `test -f 'net/arp.c' || echo '$(srcdir)/'`net/arp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-arp.Tpo net/$(DEPDIR)/net_module-arp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/arp.c' object='net/net_module-arp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-arp.o `test -f 'net/arp.c' || echo '$(srcdir)/'`net/arp.c
+
+net/net_module-arp.obj: net/arp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-arp.obj -MD -MP -MF net/$(DEPDIR)/net_module-arp.Tpo -c -o net/net_module-arp.obj `if test -f 'net/arp.c'; then $(CYGPATH_W) 'net/arp.c'; else $(CYGPATH_W) '$(srcdir)/net/arp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-arp.Tpo net/$(DEPDIR)/net_module-arp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/arp.c' object='net/net_module-arp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-arp.obj `if test -f 'net/arp.c'; then $(CYGPATH_W) 'net/arp.c'; else $(CYGPATH_W) '$(srcdir)/net/arp.c'; fi`
+
+net/net_module-netbuff.o: net/netbuff.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-netbuff.o -MD -MP -MF net/$(DEPDIR)/net_module-netbuff.Tpo -c -o net/net_module-netbuff.o `test -f 'net/netbuff.c' || echo '$(srcdir)/'`net/netbuff.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-netbuff.Tpo net/$(DEPDIR)/net_module-netbuff.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/netbuff.c' object='net/net_module-netbuff.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-netbuff.o `test -f 'net/netbuff.c' || echo '$(srcdir)/'`net/netbuff.c
+
+net/net_module-netbuff.obj: net/netbuff.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -MT net/net_module-netbuff.obj -MD -MP -MF net/$(DEPDIR)/net_module-netbuff.Tpo -c -o net/net_module-netbuff.obj `if test -f 'net/netbuff.c'; then $(CYGPATH_W) 'net/netbuff.c'; else $(CYGPATH_W) '$(srcdir)/net/netbuff.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/net_module-netbuff.Tpo net/$(DEPDIR)/net_module-netbuff.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/netbuff.c' object='net/net_module-netbuff.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $(net_module_CFLAGS) $(CFLAGS) -c -o net/net_module-netbuff.obj `if test -f 'net/netbuff.c'; then $(CYGPATH_W) 'net/netbuff.c'; else $(CYGPATH_W) '$(srcdir)/net/netbuff.c'; fi`
+
+fs/newc_module-newc.o: fs/newc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(newc_module_CPPFLAGS) $(CPPFLAGS) $(newc_module_CFLAGS) $(CFLAGS) -MT fs/newc_module-newc.o -MD -MP -MF fs/$(DEPDIR)/newc_module-newc.Tpo -c -o fs/newc_module-newc.o `test -f 'fs/newc.c' || echo '$(srcdir)/'`fs/newc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/newc_module-newc.Tpo fs/$(DEPDIR)/newc_module-newc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/newc.c' object='fs/newc_module-newc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(newc_module_CPPFLAGS) $(CPPFLAGS) $(newc_module_CFLAGS) $(CFLAGS) -c -o fs/newc_module-newc.o `test -f 'fs/newc.c' || echo '$(srcdir)/'`fs/newc.c
+
+fs/newc_module-newc.obj: fs/newc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(newc_module_CPPFLAGS) $(CPPFLAGS) $(newc_module_CFLAGS) $(CFLAGS) -MT fs/newc_module-newc.obj -MD -MP -MF fs/$(DEPDIR)/newc_module-newc.Tpo -c -o fs/newc_module-newc.obj `if test -f 'fs/newc.c'; then $(CYGPATH_W) 'fs/newc.c'; else $(CYGPATH_W) '$(srcdir)/fs/newc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/newc_module-newc.Tpo fs/$(DEPDIR)/newc_module-newc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/newc.c' object='fs/newc_module-newc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(newc_module_CPPFLAGS) $(CPPFLAGS) $(newc_module_CFLAGS) $(CFLAGS) -c -o fs/newc_module-newc.obj `if test -f 'fs/newc.c'; then $(CYGPATH_W) 'fs/newc.c'; else $(CYGPATH_W) '$(srcdir)/fs/newc.c'; fi`
+
+fs/nilfs2_module-nilfs2.o: fs/nilfs2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nilfs2_module_CPPFLAGS) $(CPPFLAGS) $(nilfs2_module_CFLAGS) $(CFLAGS) -MT fs/nilfs2_module-nilfs2.o -MD -MP -MF fs/$(DEPDIR)/nilfs2_module-nilfs2.Tpo -c -o fs/nilfs2_module-nilfs2.o `test -f 'fs/nilfs2.c' || echo '$(srcdir)/'`fs/nilfs2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/nilfs2_module-nilfs2.Tpo fs/$(DEPDIR)/nilfs2_module-nilfs2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/nilfs2.c' object='fs/nilfs2_module-nilfs2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nilfs2_module_CPPFLAGS) $(CPPFLAGS) $(nilfs2_module_CFLAGS) $(CFLAGS) -c -o fs/nilfs2_module-nilfs2.o `test -f 'fs/nilfs2.c' || echo '$(srcdir)/'`fs/nilfs2.c
+
+fs/nilfs2_module-nilfs2.obj: fs/nilfs2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nilfs2_module_CPPFLAGS) $(CPPFLAGS) $(nilfs2_module_CFLAGS) $(CFLAGS) -MT fs/nilfs2_module-nilfs2.obj -MD -MP -MF fs/$(DEPDIR)/nilfs2_module-nilfs2.Tpo -c -o fs/nilfs2_module-nilfs2.obj `if test -f 'fs/nilfs2.c'; then $(CYGPATH_W) 'fs/nilfs2.c'; else $(CYGPATH_W) '$(srcdir)/fs/nilfs2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/nilfs2_module-nilfs2.Tpo fs/$(DEPDIR)/nilfs2_module-nilfs2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/nilfs2.c' object='fs/nilfs2_module-nilfs2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nilfs2_module_CPPFLAGS) $(CPPFLAGS) $(nilfs2_module_CFLAGS) $(CFLAGS) -c -o fs/nilfs2_module-nilfs2.obj `if test -f 'fs/nilfs2.c'; then $(CYGPATH_W) 'fs/nilfs2.c'; else $(CYGPATH_W) '$(srcdir)/fs/nilfs2.c'; fi`
+
+boot/decompressor/none_decompress_image-none.o: boot/decompressor/none.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(none_decompress_image_CPPFLAGS) $(CPPFLAGS) $(none_decompress_image_CFLAGS) $(CFLAGS) -MT boot/decompressor/none_decompress_image-none.o -MD -MP -MF boot/decompressor/$(DEPDIR)/none_decompress_image-none.Tpo -c -o boot/decompressor/none_decompress_image-none.o `test -f 'boot/decompressor/none.c' || echo '$(srcdir)/'`boot/decompressor/none.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) boot/decompressor/$(DEPDIR)/none_decompress_image-none.Tpo boot/decompressor/$(DEPDIR)/none_decompress_image-none.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='boot/decompressor/none.c' object='boot/decompressor/none_decompress_image-none.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(none_decompress_image_CPPFLAGS) $(CPPFLAGS) $(none_decompress_image_CFLAGS) $(CFLAGS) -c -o boot/decompressor/none_decompress_image-none.o `test -f 'boot/decompressor/none.c' || echo '$(srcdir)/'`boot/decompressor/none.c
+
+boot/decompressor/none_decompress_image-none.obj: boot/decompressor/none.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(none_decompress_image_CPPFLAGS) $(CPPFLAGS) $(none_decompress_image_CFLAGS) $(CFLAGS) -MT boot/decompressor/none_decompress_image-none.obj -MD -MP -MF boot/decompressor/$(DEPDIR)/none_decompress_image-none.Tpo -c -o boot/decompressor/none_decompress_image-none.obj `if test -f 'boot/decompressor/none.c'; then $(CYGPATH_W) 'boot/decompressor/none.c'; else $(CYGPATH_W) '$(srcdir)/boot/decompressor/none.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) boot/decompressor/$(DEPDIR)/none_decompress_image-none.Tpo boot/decompressor/$(DEPDIR)/none_decompress_image-none.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='boot/decompressor/none.c' object='boot/decompressor/none_decompress_image-none.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(none_decompress_image_CPPFLAGS) $(CPPFLAGS) $(none_decompress_image_CFLAGS) $(CFLAGS) -c -o boot/decompressor/none_decompress_image-none.obj `if test -f 'boot/decompressor/none.c'; then $(CYGPATH_W) 'boot/decompressor/none.c'; else $(CYGPATH_W) '$(srcdir)/boot/decompressor/none.c'; fi`
+
+normal/normal_module-main.o: normal/main.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-main.o -MD -MP -MF normal/$(DEPDIR)/normal_module-main.Tpo -c -o normal/normal_module-main.o `test -f 'normal/main.c' || echo '$(srcdir)/'`normal/main.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-main.Tpo normal/$(DEPDIR)/normal_module-main.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/main.c' object='normal/normal_module-main.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-main.o `test -f 'normal/main.c' || echo '$(srcdir)/'`normal/main.c
+
+normal/normal_module-main.obj: normal/main.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-main.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-main.Tpo -c -o normal/normal_module-main.obj `if test -f 'normal/main.c'; then $(CYGPATH_W) 'normal/main.c'; else $(CYGPATH_W) '$(srcdir)/normal/main.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-main.Tpo normal/$(DEPDIR)/normal_module-main.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/main.c' object='normal/normal_module-main.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-main.obj `if test -f 'normal/main.c'; then $(CYGPATH_W) 'normal/main.c'; else $(CYGPATH_W) '$(srcdir)/normal/main.c'; fi`
+
+normal/normal_module-cmdline.o: normal/cmdline.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-cmdline.o -MD -MP -MF normal/$(DEPDIR)/normal_module-cmdline.Tpo -c -o normal/normal_module-cmdline.o `test -f 'normal/cmdline.c' || echo '$(srcdir)/'`normal/cmdline.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-cmdline.Tpo normal/$(DEPDIR)/normal_module-cmdline.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/cmdline.c' object='normal/normal_module-cmdline.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-cmdline.o `test -f 'normal/cmdline.c' || echo '$(srcdir)/'`normal/cmdline.c
+
+normal/normal_module-cmdline.obj: normal/cmdline.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-cmdline.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-cmdline.Tpo -c -o normal/normal_module-cmdline.obj `if test -f 'normal/cmdline.c'; then $(CYGPATH_W) 'normal/cmdline.c'; else $(CYGPATH_W) '$(srcdir)/normal/cmdline.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-cmdline.Tpo normal/$(DEPDIR)/normal_module-cmdline.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/cmdline.c' object='normal/normal_module-cmdline.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-cmdline.obj `if test -f 'normal/cmdline.c'; then $(CYGPATH_W) 'normal/cmdline.c'; else $(CYGPATH_W) '$(srcdir)/normal/cmdline.c'; fi`
+
+normal/normal_module-dyncmd.o: normal/dyncmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-dyncmd.o -MD -MP -MF normal/$(DEPDIR)/normal_module-dyncmd.Tpo -c -o normal/normal_module-dyncmd.o `test -f 'normal/dyncmd.c' || echo '$(srcdir)/'`normal/dyncmd.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-dyncmd.Tpo normal/$(DEPDIR)/normal_module-dyncmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/dyncmd.c' object='normal/normal_module-dyncmd.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-dyncmd.o `test -f 'normal/dyncmd.c' || echo '$(srcdir)/'`normal/dyncmd.c
+
+normal/normal_module-dyncmd.obj: normal/dyncmd.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-dyncmd.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-dyncmd.Tpo -c -o normal/normal_module-dyncmd.obj `if test -f 'normal/dyncmd.c'; then $(CYGPATH_W) 'normal/dyncmd.c'; else $(CYGPATH_W) '$(srcdir)/normal/dyncmd.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-dyncmd.Tpo normal/$(DEPDIR)/normal_module-dyncmd.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/dyncmd.c' object='normal/normal_module-dyncmd.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-dyncmd.obj `if test -f 'normal/dyncmd.c'; then $(CYGPATH_W) 'normal/dyncmd.c'; else $(CYGPATH_W) '$(srcdir)/normal/dyncmd.c'; fi`
+
+normal/normal_module-auth.o: normal/auth.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-auth.o -MD -MP -MF normal/$(DEPDIR)/normal_module-auth.Tpo -c -o normal/normal_module-auth.o `test -f 'normal/auth.c' || echo '$(srcdir)/'`normal/auth.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-auth.Tpo normal/$(DEPDIR)/normal_module-auth.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/auth.c' object='normal/normal_module-auth.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-auth.o `test -f 'normal/auth.c' || echo '$(srcdir)/'`normal/auth.c
+
+normal/normal_module-auth.obj: normal/auth.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-auth.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-auth.Tpo -c -o normal/normal_module-auth.obj `if test -f 'normal/auth.c'; then $(CYGPATH_W) 'normal/auth.c'; else $(CYGPATH_W) '$(srcdir)/normal/auth.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-auth.Tpo normal/$(DEPDIR)/normal_module-auth.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/auth.c' object='normal/normal_module-auth.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-auth.obj `if test -f 'normal/auth.c'; then $(CYGPATH_W) 'normal/auth.c'; else $(CYGPATH_W) '$(srcdir)/normal/auth.c'; fi`
+
+normal/normal_module-autofs.o: normal/autofs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-autofs.o -MD -MP -MF normal/$(DEPDIR)/normal_module-autofs.Tpo -c -o normal/normal_module-autofs.o `test -f 'normal/autofs.c' || echo '$(srcdir)/'`normal/autofs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-autofs.Tpo normal/$(DEPDIR)/normal_module-autofs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/autofs.c' object='normal/normal_module-autofs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-autofs.o `test -f 'normal/autofs.c' || echo '$(srcdir)/'`normal/autofs.c
+
+normal/normal_module-autofs.obj: normal/autofs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-autofs.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-autofs.Tpo -c -o normal/normal_module-autofs.obj `if test -f 'normal/autofs.c'; then $(CYGPATH_W) 'normal/autofs.c'; else $(CYGPATH_W) '$(srcdir)/normal/autofs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-autofs.Tpo normal/$(DEPDIR)/normal_module-autofs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/autofs.c' object='normal/normal_module-autofs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-autofs.obj `if test -f 'normal/autofs.c'; then $(CYGPATH_W) 'normal/autofs.c'; else $(CYGPATH_W) '$(srcdir)/normal/autofs.c'; fi`
+
+normal/normal_module-color.o: normal/color.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-color.o -MD -MP -MF normal/$(DEPDIR)/normal_module-color.Tpo -c -o normal/normal_module-color.o `test -f 'normal/color.c' || echo '$(srcdir)/'`normal/color.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-color.Tpo normal/$(DEPDIR)/normal_module-color.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/color.c' object='normal/normal_module-color.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-color.o `test -f 'normal/color.c' || echo '$(srcdir)/'`normal/color.c
+
+normal/normal_module-color.obj: normal/color.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-color.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-color.Tpo -c -o normal/normal_module-color.obj `if test -f 'normal/color.c'; then $(CYGPATH_W) 'normal/color.c'; else $(CYGPATH_W) '$(srcdir)/normal/color.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-color.Tpo normal/$(DEPDIR)/normal_module-color.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/color.c' object='normal/normal_module-color.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-color.obj `if test -f 'normal/color.c'; then $(CYGPATH_W) 'normal/color.c'; else $(CYGPATH_W) '$(srcdir)/normal/color.c'; fi`
+
+normal/normal_module-completion.o: normal/completion.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-completion.o -MD -MP -MF normal/$(DEPDIR)/normal_module-completion.Tpo -c -o normal/normal_module-completion.o `test -f 'normal/completion.c' || echo '$(srcdir)/'`normal/completion.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-completion.Tpo normal/$(DEPDIR)/normal_module-completion.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/completion.c' object='normal/normal_module-completion.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-completion.o `test -f 'normal/completion.c' || echo '$(srcdir)/'`normal/completion.c
+
+normal/normal_module-completion.obj: normal/completion.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-completion.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-completion.Tpo -c -o normal/normal_module-completion.obj `if test -f 'normal/completion.c'; then $(CYGPATH_W) 'normal/completion.c'; else $(CYGPATH_W) '$(srcdir)/normal/completion.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-completion.Tpo normal/$(DEPDIR)/normal_module-completion.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/completion.c' object='normal/normal_module-completion.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-completion.obj `if test -f 'normal/completion.c'; then $(CYGPATH_W) 'normal/completion.c'; else $(CYGPATH_W) '$(srcdir)/normal/completion.c'; fi`
+
+normal/normal_module-menu.o: normal/menu.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-menu.o -MD -MP -MF normal/$(DEPDIR)/normal_module-menu.Tpo -c -o normal/normal_module-menu.o `test -f 'normal/menu.c' || echo '$(srcdir)/'`normal/menu.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-menu.Tpo normal/$(DEPDIR)/normal_module-menu.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/menu.c' object='normal/normal_module-menu.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-menu.o `test -f 'normal/menu.c' || echo '$(srcdir)/'`normal/menu.c
+
+normal/normal_module-menu.obj: normal/menu.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-menu.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-menu.Tpo -c -o normal/normal_module-menu.obj `if test -f 'normal/menu.c'; then $(CYGPATH_W) 'normal/menu.c'; else $(CYGPATH_W) '$(srcdir)/normal/menu.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-menu.Tpo normal/$(DEPDIR)/normal_module-menu.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/menu.c' object='normal/normal_module-menu.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-menu.obj `if test -f 'normal/menu.c'; then $(CYGPATH_W) 'normal/menu.c'; else $(CYGPATH_W) '$(srcdir)/normal/menu.c'; fi`
+
+normal/normal_module-menu_entry.o: normal/menu_entry.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-menu_entry.o -MD -MP -MF normal/$(DEPDIR)/normal_module-menu_entry.Tpo -c -o normal/normal_module-menu_entry.o `test -f 'normal/menu_entry.c' || echo '$(srcdir)/'`normal/menu_entry.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-menu_entry.Tpo normal/$(DEPDIR)/normal_module-menu_entry.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/menu_entry.c' object='normal/normal_module-menu_entry.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-menu_entry.o `test -f 'normal/menu_entry.c' || echo '$(srcdir)/'`normal/menu_entry.c
+
+normal/normal_module-menu_entry.obj: normal/menu_entry.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-menu_entry.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-menu_entry.Tpo -c -o normal/normal_module-menu_entry.obj `if test -f 'normal/menu_entry.c'; then $(CYGPATH_W) 'normal/menu_entry.c'; else $(CYGPATH_W) '$(srcdir)/normal/menu_entry.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-menu_entry.Tpo normal/$(DEPDIR)/normal_module-menu_entry.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/menu_entry.c' object='normal/normal_module-menu_entry.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-menu_entry.obj `if test -f 'normal/menu_entry.c'; then $(CYGPATH_W) 'normal/menu_entry.c'; else $(CYGPATH_W) '$(srcdir)/normal/menu_entry.c'; fi`
+
+normal/normal_module-menu_text.o: normal/menu_text.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-menu_text.o -MD -MP -MF normal/$(DEPDIR)/normal_module-menu_text.Tpo -c -o normal/normal_module-menu_text.o `test -f 'normal/menu_text.c' || echo '$(srcdir)/'`normal/menu_text.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-menu_text.Tpo normal/$(DEPDIR)/normal_module-menu_text.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/menu_text.c' object='normal/normal_module-menu_text.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-menu_text.o `test -f 'normal/menu_text.c' || echo '$(srcdir)/'`normal/menu_text.c
+
+normal/normal_module-menu_text.obj: normal/menu_text.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-menu_text.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-menu_text.Tpo -c -o normal/normal_module-menu_text.obj `if test -f 'normal/menu_text.c'; then $(CYGPATH_W) 'normal/menu_text.c'; else $(CYGPATH_W) '$(srcdir)/normal/menu_text.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-menu_text.Tpo normal/$(DEPDIR)/normal_module-menu_text.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/menu_text.c' object='normal/normal_module-menu_text.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-menu_text.obj `if test -f 'normal/menu_text.c'; then $(CYGPATH_W) 'normal/menu_text.c'; else $(CYGPATH_W) '$(srcdir)/normal/menu_text.c'; fi`
+
+normal/normal_module-misc.o: normal/misc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-misc.o -MD -MP -MF normal/$(DEPDIR)/normal_module-misc.Tpo -c -o normal/normal_module-misc.o `test -f 'normal/misc.c' || echo '$(srcdir)/'`normal/misc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-misc.Tpo normal/$(DEPDIR)/normal_module-misc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/misc.c' object='normal/normal_module-misc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-misc.o `test -f 'normal/misc.c' || echo '$(srcdir)/'`normal/misc.c
+
+normal/normal_module-misc.obj: normal/misc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-misc.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-misc.Tpo -c -o normal/normal_module-misc.obj `if test -f 'normal/misc.c'; then $(CYGPATH_W) 'normal/misc.c'; else $(CYGPATH_W) '$(srcdir)/normal/misc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-misc.Tpo normal/$(DEPDIR)/normal_module-misc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/misc.c' object='normal/normal_module-misc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-misc.obj `if test -f 'normal/misc.c'; then $(CYGPATH_W) 'normal/misc.c'; else $(CYGPATH_W) '$(srcdir)/normal/misc.c'; fi`
+
+normal/normal_module-crypto.o: normal/crypto.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-crypto.o -MD -MP -MF normal/$(DEPDIR)/normal_module-crypto.Tpo -c -o normal/normal_module-crypto.o `test -f 'normal/crypto.c' || echo '$(srcdir)/'`normal/crypto.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-crypto.Tpo normal/$(DEPDIR)/normal_module-crypto.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/crypto.c' object='normal/normal_module-crypto.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-crypto.o `test -f 'normal/crypto.c' || echo '$(srcdir)/'`normal/crypto.c
+
+normal/normal_module-crypto.obj: normal/crypto.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-crypto.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-crypto.Tpo -c -o normal/normal_module-crypto.obj `if test -f 'normal/crypto.c'; then $(CYGPATH_W) 'normal/crypto.c'; else $(CYGPATH_W) '$(srcdir)/normal/crypto.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-crypto.Tpo normal/$(DEPDIR)/normal_module-crypto.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/crypto.c' object='normal/normal_module-crypto.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-crypto.obj `if test -f 'normal/crypto.c'; then $(CYGPATH_W) 'normal/crypto.c'; else $(CYGPATH_W) '$(srcdir)/normal/crypto.c'; fi`
+
+normal/normal_module-term.o: normal/term.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-term.o -MD -MP -MF normal/$(DEPDIR)/normal_module-term.Tpo -c -o normal/normal_module-term.o `test -f 'normal/term.c' || echo '$(srcdir)/'`normal/term.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-term.Tpo normal/$(DEPDIR)/normal_module-term.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/term.c' object='normal/normal_module-term.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-term.o `test -f 'normal/term.c' || echo '$(srcdir)/'`normal/term.c
+
+normal/normal_module-term.obj: normal/term.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-term.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-term.Tpo -c -o normal/normal_module-term.obj `if test -f 'normal/term.c'; then $(CYGPATH_W) 'normal/term.c'; else $(CYGPATH_W) '$(srcdir)/normal/term.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-term.Tpo normal/$(DEPDIR)/normal_module-term.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/term.c' object='normal/normal_module-term.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-term.obj `if test -f 'normal/term.c'; then $(CYGPATH_W) 'normal/term.c'; else $(CYGPATH_W) '$(srcdir)/normal/term.c'; fi`
+
+normal/normal_module-context.o: normal/context.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-context.o -MD -MP -MF normal/$(DEPDIR)/normal_module-context.Tpo -c -o normal/normal_module-context.o `test -f 'normal/context.c' || echo '$(srcdir)/'`normal/context.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-context.Tpo normal/$(DEPDIR)/normal_module-context.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/context.c' object='normal/normal_module-context.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-context.o `test -f 'normal/context.c' || echo '$(srcdir)/'`normal/context.c
+
+normal/normal_module-context.obj: normal/context.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-context.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-context.Tpo -c -o normal/normal_module-context.obj `if test -f 'normal/context.c'; then $(CYGPATH_W) 'normal/context.c'; else $(CYGPATH_W) '$(srcdir)/normal/context.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-context.Tpo normal/$(DEPDIR)/normal_module-context.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/context.c' object='normal/normal_module-context.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-context.obj `if test -f 'normal/context.c'; then $(CYGPATH_W) 'normal/context.c'; else $(CYGPATH_W) '$(srcdir)/normal/context.c'; fi`
+
+normal/normal_module-charset.o: normal/charset.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-charset.o -MD -MP -MF normal/$(DEPDIR)/normal_module-charset.Tpo -c -o normal/normal_module-charset.o `test -f 'normal/charset.c' || echo '$(srcdir)/'`normal/charset.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-charset.Tpo normal/$(DEPDIR)/normal_module-charset.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/charset.c' object='normal/normal_module-charset.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-charset.o `test -f 'normal/charset.c' || echo '$(srcdir)/'`normal/charset.c
+
+normal/normal_module-charset.obj: normal/charset.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal/normal_module-charset.obj -MD -MP -MF normal/$(DEPDIR)/normal_module-charset.Tpo -c -o normal/normal_module-charset.obj `if test -f 'normal/charset.c'; then $(CYGPATH_W) 'normal/charset.c'; else $(CYGPATH_W) '$(srcdir)/normal/charset.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) normal/$(DEPDIR)/normal_module-charset.Tpo normal/$(DEPDIR)/normal_module-charset.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='normal/charset.c' object='normal/normal_module-charset.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal/normal_module-charset.obj `if test -f 'normal/charset.c'; then $(CYGPATH_W) 'normal/charset.c'; else $(CYGPATH_W) '$(srcdir)/normal/charset.c'; fi`
+
+lib/normal_module-getline.o: lib/getline.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT lib/normal_module-getline.o -MD -MP -MF lib/$(DEPDIR)/normal_module-getline.Tpo -c -o lib/normal_module-getline.o `test -f 'lib/getline.c' || echo '$(srcdir)/'`lib/getline.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/normal_module-getline.Tpo lib/$(DEPDIR)/normal_module-getline.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/getline.c' object='lib/normal_module-getline.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o lib/normal_module-getline.o `test -f 'lib/getline.c' || echo '$(srcdir)/'`lib/getline.c
+
+lib/normal_module-getline.obj: lib/getline.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT lib/normal_module-getline.obj -MD -MP -MF lib/$(DEPDIR)/normal_module-getline.Tpo -c -o lib/normal_module-getline.obj `if test -f 'lib/getline.c'; then $(CYGPATH_W) 'lib/getline.c'; else $(CYGPATH_W) '$(srcdir)/lib/getline.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/normal_module-getline.Tpo lib/$(DEPDIR)/normal_module-getline.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/getline.c' object='lib/normal_module-getline.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o lib/normal_module-getline.obj `if test -f 'lib/getline.c'; then $(CYGPATH_W) 'lib/getline.c'; else $(CYGPATH_W) '$(srcdir)/lib/getline.c'; fi`
+
+script/normal_module-main.o: script/main.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-main.o -MD -MP -MF script/$(DEPDIR)/normal_module-main.Tpo -c -o script/normal_module-main.o `test -f 'script/main.c' || echo '$(srcdir)/'`script/main.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-main.Tpo script/$(DEPDIR)/normal_module-main.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/main.c' object='script/normal_module-main.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-main.o `test -f 'script/main.c' || echo '$(srcdir)/'`script/main.c
+
+script/normal_module-main.obj: script/main.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-main.obj -MD -MP -MF script/$(DEPDIR)/normal_module-main.Tpo -c -o script/normal_module-main.obj `if test -f 'script/main.c'; then $(CYGPATH_W) 'script/main.c'; else $(CYGPATH_W) '$(srcdir)/script/main.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-main.Tpo script/$(DEPDIR)/normal_module-main.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/main.c' object='script/normal_module-main.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-main.obj `if test -f 'script/main.c'; then $(CYGPATH_W) 'script/main.c'; else $(CYGPATH_W) '$(srcdir)/script/main.c'; fi`
+
+script/normal_module-script.o: script/script.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-script.o -MD -MP -MF script/$(DEPDIR)/normal_module-script.Tpo -c -o script/normal_module-script.o `test -f 'script/script.c' || echo '$(srcdir)/'`script/script.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-script.Tpo script/$(DEPDIR)/normal_module-script.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/script.c' object='script/normal_module-script.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-script.o `test -f 'script/script.c' || echo '$(srcdir)/'`script/script.c
+
+script/normal_module-script.obj: script/script.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-script.obj -MD -MP -MF script/$(DEPDIR)/normal_module-script.Tpo -c -o script/normal_module-script.obj `if test -f 'script/script.c'; then $(CYGPATH_W) 'script/script.c'; else $(CYGPATH_W) '$(srcdir)/script/script.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-script.Tpo script/$(DEPDIR)/normal_module-script.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/script.c' object='script/normal_module-script.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-script.obj `if test -f 'script/script.c'; then $(CYGPATH_W) 'script/script.c'; else $(CYGPATH_W) '$(srcdir)/script/script.c'; fi`
+
+script/normal_module-execute.o: script/execute.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-execute.o -MD -MP -MF script/$(DEPDIR)/normal_module-execute.Tpo -c -o script/normal_module-execute.o `test -f 'script/execute.c' || echo '$(srcdir)/'`script/execute.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-execute.Tpo script/$(DEPDIR)/normal_module-execute.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/execute.c' object='script/normal_module-execute.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-execute.o `test -f 'script/execute.c' || echo '$(srcdir)/'`script/execute.c
+
+script/normal_module-execute.obj: script/execute.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-execute.obj -MD -MP -MF script/$(DEPDIR)/normal_module-execute.Tpo -c -o script/normal_module-execute.obj `if test -f 'script/execute.c'; then $(CYGPATH_W) 'script/execute.c'; else $(CYGPATH_W) '$(srcdir)/script/execute.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-execute.Tpo script/$(DEPDIR)/normal_module-execute.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/execute.c' object='script/normal_module-execute.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-execute.obj `if test -f 'script/execute.c'; then $(CYGPATH_W) 'script/execute.c'; else $(CYGPATH_W) '$(srcdir)/script/execute.c'; fi`
+
+script/normal_module-function.o: script/function.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-function.o -MD -MP -MF script/$(DEPDIR)/normal_module-function.Tpo -c -o script/normal_module-function.o `test -f 'script/function.c' || echo '$(srcdir)/'`script/function.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-function.Tpo script/$(DEPDIR)/normal_module-function.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/function.c' object='script/normal_module-function.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-function.o `test -f 'script/function.c' || echo '$(srcdir)/'`script/function.c
+
+script/normal_module-function.obj: script/function.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-function.obj -MD -MP -MF script/$(DEPDIR)/normal_module-function.Tpo -c -o script/normal_module-function.obj `if test -f 'script/function.c'; then $(CYGPATH_W) 'script/function.c'; else $(CYGPATH_W) '$(srcdir)/script/function.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-function.Tpo script/$(DEPDIR)/normal_module-function.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/function.c' object='script/normal_module-function.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-function.obj `if test -f 'script/function.c'; then $(CYGPATH_W) 'script/function.c'; else $(CYGPATH_W) '$(srcdir)/script/function.c'; fi`
+
+script/normal_module-lexer.o: script/lexer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-lexer.o -MD -MP -MF script/$(DEPDIR)/normal_module-lexer.Tpo -c -o script/normal_module-lexer.o `test -f 'script/lexer.c' || echo '$(srcdir)/'`script/lexer.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-lexer.Tpo script/$(DEPDIR)/normal_module-lexer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/lexer.c' object='script/normal_module-lexer.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-lexer.o `test -f 'script/lexer.c' || echo '$(srcdir)/'`script/lexer.c
+
+script/normal_module-lexer.obj: script/lexer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-lexer.obj -MD -MP -MF script/$(DEPDIR)/normal_module-lexer.Tpo -c -o script/normal_module-lexer.obj `if test -f 'script/lexer.c'; then $(CYGPATH_W) 'script/lexer.c'; else $(CYGPATH_W) '$(srcdir)/script/lexer.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-lexer.Tpo script/$(DEPDIR)/normal_module-lexer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/lexer.c' object='script/normal_module-lexer.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-lexer.obj `if test -f 'script/lexer.c'; then $(CYGPATH_W) 'script/lexer.c'; else $(CYGPATH_W) '$(srcdir)/script/lexer.c'; fi`
+
+script/normal_module-argv.o: script/argv.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-argv.o -MD -MP -MF script/$(DEPDIR)/normal_module-argv.Tpo -c -o script/normal_module-argv.o `test -f 'script/argv.c' || echo '$(srcdir)/'`script/argv.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-argv.Tpo script/$(DEPDIR)/normal_module-argv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/argv.c' object='script/normal_module-argv.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-argv.o `test -f 'script/argv.c' || echo '$(srcdir)/'`script/argv.c
+
+script/normal_module-argv.obj: script/argv.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT script/normal_module-argv.obj -MD -MP -MF script/$(DEPDIR)/normal_module-argv.Tpo -c -o script/normal_module-argv.obj `if test -f 'script/argv.c'; then $(CYGPATH_W) 'script/argv.c'; else $(CYGPATH_W) '$(srcdir)/script/argv.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) script/$(DEPDIR)/normal_module-argv.Tpo script/$(DEPDIR)/normal_module-argv.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='script/argv.c' object='script/normal_module-argv.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o script/normal_module-argv.obj `if test -f 'script/argv.c'; then $(CYGPATH_W) 'script/argv.c'; else $(CYGPATH_W) '$(srcdir)/script/argv.c'; fi`
+
+commands/normal_module-menuentry.o: commands/menuentry.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT commands/normal_module-menuentry.o -MD -MP -MF commands/$(DEPDIR)/normal_module-menuentry.Tpo -c -o commands/normal_module-menuentry.o `test -f 'commands/menuentry.c' || echo '$(srcdir)/'`commands/menuentry.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/normal_module-menuentry.Tpo commands/$(DEPDIR)/normal_module-menuentry.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/menuentry.c' object='commands/normal_module-menuentry.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o commands/normal_module-menuentry.o `test -f 'commands/menuentry.c' || echo '$(srcdir)/'`commands/menuentry.c
+
+commands/normal_module-menuentry.obj: commands/menuentry.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT commands/normal_module-menuentry.obj -MD -MP -MF commands/$(DEPDIR)/normal_module-menuentry.Tpo -c -o commands/normal_module-menuentry.obj `if test -f 'commands/menuentry.c'; then $(CYGPATH_W) 'commands/menuentry.c'; else $(CYGPATH_W) '$(srcdir)/commands/menuentry.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/normal_module-menuentry.Tpo commands/$(DEPDIR)/normal_module-menuentry.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/menuentry.c' object='commands/normal_module-menuentry.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o commands/normal_module-menuentry.obj `if test -f 'commands/menuentry.c'; then $(CYGPATH_W) 'commands/menuentry.c'; else $(CYGPATH_W) '$(srcdir)/commands/menuentry.c'; fi`
+
+normal_module-unidata.o: unidata.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal_module-unidata.o -MD -MP -MF $(DEPDIR)/normal_module-unidata.Tpo -c -o normal_module-unidata.o `test -f 'unidata.c' || echo '$(srcdir)/'`unidata.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/normal_module-unidata.Tpo $(DEPDIR)/normal_module-unidata.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='unidata.c' object='normal_module-unidata.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal_module-unidata.o `test -f 'unidata.c' || echo '$(srcdir)/'`unidata.c
+
+normal_module-unidata.obj: unidata.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal_module-unidata.obj -MD -MP -MF $(DEPDIR)/normal_module-unidata.Tpo -c -o normal_module-unidata.obj `if test -f 'unidata.c'; then $(CYGPATH_W) 'unidata.c'; else $(CYGPATH_W) '$(srcdir)/unidata.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/normal_module-unidata.Tpo $(DEPDIR)/normal_module-unidata.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='unidata.c' object='normal_module-unidata.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal_module-unidata.obj `if test -f 'unidata.c'; then $(CYGPATH_W) 'unidata.c'; else $(CYGPATH_W) '$(srcdir)/unidata.c'; fi`
+
+normal_module-grub_script.tab.o: grub_script.tab.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal_module-grub_script.tab.o -MD -MP -MF $(DEPDIR)/normal_module-grub_script.tab.Tpo -c -o normal_module-grub_script.tab.o `test -f 'grub_script.tab.c' || echo '$(srcdir)/'`grub_script.tab.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/normal_module-grub_script.tab.Tpo $(DEPDIR)/normal_module-grub_script.tab.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='grub_script.tab.c' object='normal_module-grub_script.tab.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal_module-grub_script.tab.o `test -f 'grub_script.tab.c' || echo '$(srcdir)/'`grub_script.tab.c
+
+normal_module-grub_script.tab.obj: grub_script.tab.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal_module-grub_script.tab.obj -MD -MP -MF $(DEPDIR)/normal_module-grub_script.tab.Tpo -c -o normal_module-grub_script.tab.obj `if test -f 'grub_script.tab.c'; then $(CYGPATH_W) 'grub_script.tab.c'; else $(CYGPATH_W) '$(srcdir)/grub_script.tab.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/normal_module-grub_script.tab.Tpo $(DEPDIR)/normal_module-grub_script.tab.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='grub_script.tab.c' object='normal_module-grub_script.tab.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal_module-grub_script.tab.obj `if test -f 'grub_script.tab.c'; then $(CYGPATH_W) 'grub_script.tab.c'; else $(CYGPATH_W) '$(srcdir)/grub_script.tab.c'; fi`
+
+normal_module-grub_script.yy.o: grub_script.yy.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal_module-grub_script.yy.o -MD -MP -MF $(DEPDIR)/normal_module-grub_script.yy.Tpo -c -o normal_module-grub_script.yy.o `test -f 'grub_script.yy.c' || echo '$(srcdir)/'`grub_script.yy.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/normal_module-grub_script.yy.Tpo $(DEPDIR)/normal_module-grub_script.yy.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='grub_script.yy.c' object='normal_module-grub_script.yy.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal_module-grub_script.yy.o `test -f 'grub_script.yy.c' || echo '$(srcdir)/'`grub_script.yy.c
+
+normal_module-grub_script.yy.obj: grub_script.yy.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -MT normal_module-grub_script.yy.obj -MD -MP -MF $(DEPDIR)/normal_module-grub_script.yy.Tpo -c -o normal_module-grub_script.yy.obj `if test -f 'grub_script.yy.c'; then $(CYGPATH_W) 'grub_script.yy.c'; else $(CYGPATH_W) '$(srcdir)/grub_script.yy.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/normal_module-grub_script.yy.Tpo $(DEPDIR)/normal_module-grub_script.yy.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='grub_script.yy.c' object='normal_module-grub_script.yy.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $(normal_module_CFLAGS) $(CFLAGS) -c -o normal_module-grub_script.yy.obj `if test -f 'grub_script.yy.c'; then $(CYGPATH_W) 'grub_script.yy.c'; else $(CYGPATH_W) '$(srcdir)/grub_script.yy.c'; fi`
+
+fs/ntfs_module-ntfs.o: fs/ntfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfs_module_CPPFLAGS) $(CPPFLAGS) $(ntfs_module_CFLAGS) $(CFLAGS) -MT fs/ntfs_module-ntfs.o -MD -MP -MF fs/$(DEPDIR)/ntfs_module-ntfs.Tpo -c -o fs/ntfs_module-ntfs.o `test -f 'fs/ntfs.c' || echo '$(srcdir)/'`fs/ntfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ntfs_module-ntfs.Tpo fs/$(DEPDIR)/ntfs_module-ntfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ntfs.c' object='fs/ntfs_module-ntfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfs_module_CPPFLAGS) $(CPPFLAGS) $(ntfs_module_CFLAGS) $(CFLAGS) -c -o fs/ntfs_module-ntfs.o `test -f 'fs/ntfs.c' || echo '$(srcdir)/'`fs/ntfs.c
+
+fs/ntfs_module-ntfs.obj: fs/ntfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfs_module_CPPFLAGS) $(CPPFLAGS) $(ntfs_module_CFLAGS) $(CFLAGS) -MT fs/ntfs_module-ntfs.obj -MD -MP -MF fs/$(DEPDIR)/ntfs_module-ntfs.Tpo -c -o fs/ntfs_module-ntfs.obj `if test -f 'fs/ntfs.c'; then $(CYGPATH_W) 'fs/ntfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/ntfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ntfs_module-ntfs.Tpo fs/$(DEPDIR)/ntfs_module-ntfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ntfs.c' object='fs/ntfs_module-ntfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfs_module_CPPFLAGS) $(CPPFLAGS) $(ntfs_module_CFLAGS) $(CFLAGS) -c -o fs/ntfs_module-ntfs.obj `if test -f 'fs/ntfs.c'; then $(CYGPATH_W) 'fs/ntfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/ntfs.c'; fi`
+
+fs/ntfscomp_module-ntfscomp.o: fs/ntfscomp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfscomp_module_CPPFLAGS) $(CPPFLAGS) $(ntfscomp_module_CFLAGS) $(CFLAGS) -MT fs/ntfscomp_module-ntfscomp.o -MD -MP -MF fs/$(DEPDIR)/ntfscomp_module-ntfscomp.Tpo -c -o fs/ntfscomp_module-ntfscomp.o `test -f 'fs/ntfscomp.c' || echo '$(srcdir)/'`fs/ntfscomp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ntfscomp_module-ntfscomp.Tpo fs/$(DEPDIR)/ntfscomp_module-ntfscomp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ntfscomp.c' object='fs/ntfscomp_module-ntfscomp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfscomp_module_CPPFLAGS) $(CPPFLAGS) $(ntfscomp_module_CFLAGS) $(CFLAGS) -c -o fs/ntfscomp_module-ntfscomp.o `test -f 'fs/ntfscomp.c' || echo '$(srcdir)/'`fs/ntfscomp.c
+
+fs/ntfscomp_module-ntfscomp.obj: fs/ntfscomp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfscomp_module_CPPFLAGS) $(CPPFLAGS) $(ntfscomp_module_CFLAGS) $(CFLAGS) -MT fs/ntfscomp_module-ntfscomp.obj -MD -MP -MF fs/$(DEPDIR)/ntfscomp_module-ntfscomp.Tpo -c -o fs/ntfscomp_module-ntfscomp.obj `if test -f 'fs/ntfscomp.c'; then $(CYGPATH_W) 'fs/ntfscomp.c'; else $(CYGPATH_W) '$(srcdir)/fs/ntfscomp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ntfscomp_module-ntfscomp.Tpo fs/$(DEPDIR)/ntfscomp_module-ntfscomp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ntfscomp.c' object='fs/ntfscomp_module-ntfscomp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfscomp_module_CPPFLAGS) $(CPPFLAGS) $(ntfscomp_module_CFLAGS) $(CFLAGS) -c -o fs/ntfscomp_module-ntfscomp.obj `if test -f 'fs/ntfscomp.c'; then $(CYGPATH_W) 'fs/ntfscomp.c'; else $(CYGPATH_W) '$(srcdir)/fs/ntfscomp.c'; fi`
+
+loader/i386/pc/ntldr_module-ntldr.o: loader/i386/pc/ntldr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntldr_module_CPPFLAGS) $(CPPFLAGS) $(ntldr_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/ntldr_module-ntldr.o -MD -MP -MF loader/i386/pc/$(DEPDIR)/ntldr_module-ntldr.Tpo -c -o loader/i386/pc/ntldr_module-ntldr.o `test -f 'loader/i386/pc/ntldr.c' || echo '$(srcdir)/'`loader/i386/pc/ntldr.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/ntldr_module-ntldr.Tpo loader/i386/pc/$(DEPDIR)/ntldr_module-ntldr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/ntldr.c' object='loader/i386/pc/ntldr_module-ntldr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntldr_module_CPPFLAGS) $(CPPFLAGS) $(ntldr_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/ntldr_module-ntldr.o `test -f 'loader/i386/pc/ntldr.c' || echo '$(srcdir)/'`loader/i386/pc/ntldr.c
+
+loader/i386/pc/ntldr_module-ntldr.obj: loader/i386/pc/ntldr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntldr_module_CPPFLAGS) $(CPPFLAGS) $(ntldr_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/ntldr_module-ntldr.obj -MD -MP -MF loader/i386/pc/$(DEPDIR)/ntldr_module-ntldr.Tpo -c -o loader/i386/pc/ntldr_module-ntldr.obj `if test -f 'loader/i386/pc/ntldr.c'; then $(CYGPATH_W) 'loader/i386/pc/ntldr.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/ntldr.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/ntldr_module-ntldr.Tpo loader/i386/pc/$(DEPDIR)/ntldr_module-ntldr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/ntldr.c' object='loader/i386/pc/ntldr_module-ntldr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntldr_module_CPPFLAGS) $(CPPFLAGS) $(ntldr_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/ntldr_module-ntldr.obj `if test -f 'loader/i386/pc/ntldr.c'; then $(CYGPATH_W) 'loader/i386/pc/ntldr.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/ntldr.c'; fi`
+
+fs/odc_module-odc.o: fs/odc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(odc_module_CPPFLAGS) $(CPPFLAGS) $(odc_module_CFLAGS) $(CFLAGS) -MT fs/odc_module-odc.o -MD -MP -MF fs/$(DEPDIR)/odc_module-odc.Tpo -c -o fs/odc_module-odc.o `test -f 'fs/odc.c' || echo '$(srcdir)/'`fs/odc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/odc_module-odc.Tpo fs/$(DEPDIR)/odc_module-odc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/odc.c' object='fs/odc_module-odc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(odc_module_CPPFLAGS) $(CPPFLAGS) $(odc_module_CFLAGS) $(CFLAGS) -c -o fs/odc_module-odc.o `test -f 'fs/odc.c' || echo '$(srcdir)/'`fs/odc.c
+
+fs/odc_module-odc.obj: fs/odc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(odc_module_CPPFLAGS) $(CPPFLAGS) $(odc_module_CFLAGS) $(CFLAGS) -MT fs/odc_module-odc.obj -MD -MP -MF fs/$(DEPDIR)/odc_module-odc.Tpo -c -o fs/odc_module-odc.obj `if test -f 'fs/odc.c'; then $(CYGPATH_W) 'fs/odc.c'; else $(CYGPATH_W) '$(srcdir)/fs/odc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/odc_module-odc.Tpo fs/$(DEPDIR)/odc_module-odc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/odc.c' object='fs/odc_module-odc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(odc_module_CPPFLAGS) $(CPPFLAGS) $(odc_module_CFLAGS) $(CFLAGS) -c -o fs/odc_module-odc.obj `if test -f 'fs/odc.c'; then $(CYGPATH_W) 'fs/odc.c'; else $(CYGPATH_W) '$(srcdir)/fs/odc.c'; fi`
+
+io/offsetio_module-offset.o: io/offset.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offsetio_module_CPPFLAGS) $(CPPFLAGS) $(offsetio_module_CFLAGS) $(CFLAGS) -MT io/offsetio_module-offset.o -MD -MP -MF io/$(DEPDIR)/offsetio_module-offset.Tpo -c -o io/offsetio_module-offset.o `test -f 'io/offset.c' || echo '$(srcdir)/'`io/offset.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/offsetio_module-offset.Tpo io/$(DEPDIR)/offsetio_module-offset.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/offset.c' object='io/offsetio_module-offset.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offsetio_module_CPPFLAGS) $(CPPFLAGS) $(offsetio_module_CFLAGS) $(CFLAGS) -c -o io/offsetio_module-offset.o `test -f 'io/offset.c' || echo '$(srcdir)/'`io/offset.c
+
+io/offsetio_module-offset.obj: io/offset.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offsetio_module_CPPFLAGS) $(CPPFLAGS) $(offsetio_module_CFLAGS) $(CFLAGS) -MT io/offsetio_module-offset.obj -MD -MP -MF io/$(DEPDIR)/offsetio_module-offset.Tpo -c -o io/offsetio_module-offset.obj `if test -f 'io/offset.c'; then $(CYGPATH_W) 'io/offset.c'; else $(CYGPATH_W) '$(srcdir)/io/offset.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/offsetio_module-offset.Tpo io/$(DEPDIR)/offsetio_module-offset.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/offset.c' object='io/offsetio_module-offset.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offsetio_module_CPPFLAGS) $(CPPFLAGS) $(offsetio_module_CFLAGS) $(CFLAGS) -c -o io/offsetio_module-offset.obj `if test -f 'io/offset.c'; then $(CYGPATH_W) 'io/offset.c'; else $(CYGPATH_W) '$(srcdir)/io/offset.c'; fi`
+
+net/drivers/ieee1275/ofnet_module-ofnet.o: net/drivers/ieee1275/ofnet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ofnet_module_CPPFLAGS) $(CPPFLAGS) $(ofnet_module_CFLAGS) $(CFLAGS) -MT net/drivers/ieee1275/ofnet_module-ofnet.o -MD -MP -MF net/drivers/ieee1275/$(DEPDIR)/ofnet_module-ofnet.Tpo -c -o net/drivers/ieee1275/ofnet_module-ofnet.o `test -f 'net/drivers/ieee1275/ofnet.c' || echo '$(srcdir)/'`net/drivers/ieee1275/ofnet.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/drivers/ieee1275/$(DEPDIR)/ofnet_module-ofnet.Tpo net/drivers/ieee1275/$(DEPDIR)/ofnet_module-ofnet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/drivers/ieee1275/ofnet.c' object='net/drivers/ieee1275/ofnet_module-ofnet.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ofnet_module_CPPFLAGS) $(CPPFLAGS) $(ofnet_module_CFLAGS) $(CFLAGS) -c -o net/drivers/ieee1275/ofnet_module-ofnet.o `test -f 'net/drivers/ieee1275/ofnet.c' || echo '$(srcdir)/'`net/drivers/ieee1275/ofnet.c
+
+net/drivers/ieee1275/ofnet_module-ofnet.obj: net/drivers/ieee1275/ofnet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ofnet_module_CPPFLAGS) $(CPPFLAGS) $(ofnet_module_CFLAGS) $(CFLAGS) -MT net/drivers/ieee1275/ofnet_module-ofnet.obj -MD -MP -MF net/drivers/ieee1275/$(DEPDIR)/ofnet_module-ofnet.Tpo -c -o net/drivers/ieee1275/ofnet_module-ofnet.obj `if test -f 'net/drivers/ieee1275/ofnet.c'; then $(CYGPATH_W) 'net/drivers/ieee1275/ofnet.c'; else $(CYGPATH_W) '$(srcdir)/net/drivers/ieee1275/ofnet.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/drivers/ieee1275/$(DEPDIR)/ofnet_module-ofnet.Tpo net/drivers/ieee1275/$(DEPDIR)/ofnet_module-ofnet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/drivers/ieee1275/ofnet.c' object='net/drivers/ieee1275/ofnet_module-ofnet.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ofnet_module_CPPFLAGS) $(CPPFLAGS) $(ofnet_module_CFLAGS) $(CFLAGS) -c -o net/drivers/ieee1275/ofnet_module-ofnet.obj `if test -f 'net/drivers/ieee1275/ofnet.c'; then $(CYGPATH_W) 'net/drivers/ieee1275/ofnet.c'; else $(CYGPATH_W) '$(srcdir)/net/drivers/ieee1275/ofnet.c'; fi`
+
+bus/usb/ohci_module-ohci.o: bus/usb/ohci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $(ohci_module_CFLAGS) $(CFLAGS) -MT bus/usb/ohci_module-ohci.o -MD -MP -MF bus/usb/$(DEPDIR)/ohci_module-ohci.Tpo -c -o bus/usb/ohci_module-ohci.o `test -f 'bus/usb/ohci.c' || echo '$(srcdir)/'`bus/usb/ohci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/ohci_module-ohci.Tpo bus/usb/$(DEPDIR)/ohci_module-ohci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/ohci.c' object='bus/usb/ohci_module-ohci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $(ohci_module_CFLAGS) $(CFLAGS) -c -o bus/usb/ohci_module-ohci.o `test -f 'bus/usb/ohci.c' || echo '$(srcdir)/'`bus/usb/ohci.c
+
+bus/usb/ohci_module-ohci.obj: bus/usb/ohci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $(ohci_module_CFLAGS) $(CFLAGS) -MT bus/usb/ohci_module-ohci.obj -MD -MP -MF bus/usb/$(DEPDIR)/ohci_module-ohci.Tpo -c -o bus/usb/ohci_module-ohci.obj `if test -f 'bus/usb/ohci.c'; then $(CYGPATH_W) 'bus/usb/ohci.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/ohci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/ohci_module-ohci.Tpo bus/usb/$(DEPDIR)/ohci_module-ohci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/ohci.c' object='bus/usb/ohci_module-ohci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $(ohci_module_CFLAGS) $(CFLAGS) -c -o bus/usb/ohci_module-ohci.obj `if test -f 'bus/usb/ohci.c'; then $(CYGPATH_W) 'bus/usb/ohci.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/ohci.c'; fi`
+
+partmap/part_acorn_module-acorn.o: partmap/acorn.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_acorn_module_CPPFLAGS) $(CPPFLAGS) $(part_acorn_module_CFLAGS) $(CFLAGS) -MT partmap/part_acorn_module-acorn.o -MD -MP -MF partmap/$(DEPDIR)/part_acorn_module-acorn.Tpo -c -o partmap/part_acorn_module-acorn.o `test -f 'partmap/acorn.c' || echo '$(srcdir)/'`partmap/acorn.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_acorn_module-acorn.Tpo partmap/$(DEPDIR)/part_acorn_module-acorn.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/acorn.c' object='partmap/part_acorn_module-acorn.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_acorn_module_CPPFLAGS) $(CPPFLAGS) $(part_acorn_module_CFLAGS) $(CFLAGS) -c -o partmap/part_acorn_module-acorn.o `test -f 'partmap/acorn.c' || echo '$(srcdir)/'`partmap/acorn.c
+
+partmap/part_acorn_module-acorn.obj: partmap/acorn.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_acorn_module_CPPFLAGS) $(CPPFLAGS) $(part_acorn_module_CFLAGS) $(CFLAGS) -MT partmap/part_acorn_module-acorn.obj -MD -MP -MF partmap/$(DEPDIR)/part_acorn_module-acorn.Tpo -c -o partmap/part_acorn_module-acorn.obj `if test -f 'partmap/acorn.c'; then $(CYGPATH_W) 'partmap/acorn.c'; else $(CYGPATH_W) '$(srcdir)/partmap/acorn.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_acorn_module-acorn.Tpo partmap/$(DEPDIR)/part_acorn_module-acorn.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/acorn.c' object='partmap/part_acorn_module-acorn.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_acorn_module_CPPFLAGS) $(CPPFLAGS) $(part_acorn_module_CFLAGS) $(CFLAGS) -c -o partmap/part_acorn_module-acorn.obj `if test -f 'partmap/acorn.c'; then $(CYGPATH_W) 'partmap/acorn.c'; else $(CYGPATH_W) '$(srcdir)/partmap/acorn.c'; fi`
+
+partmap/part_amiga_module-amiga.o: partmap/amiga.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_amiga_module_CPPFLAGS) $(CPPFLAGS) $(part_amiga_module_CFLAGS) $(CFLAGS) -MT partmap/part_amiga_module-amiga.o -MD -MP -MF partmap/$(DEPDIR)/part_amiga_module-amiga.Tpo -c -o partmap/part_amiga_module-amiga.o `test -f 'partmap/amiga.c' || echo '$(srcdir)/'`partmap/amiga.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_amiga_module-amiga.Tpo partmap/$(DEPDIR)/part_amiga_module-amiga.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/amiga.c' object='partmap/part_amiga_module-amiga.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_amiga_module_CPPFLAGS) $(CPPFLAGS) $(part_amiga_module_CFLAGS) $(CFLAGS) -c -o partmap/part_amiga_module-amiga.o `test -f 'partmap/amiga.c' || echo '$(srcdir)/'`partmap/amiga.c
+
+partmap/part_amiga_module-amiga.obj: partmap/amiga.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_amiga_module_CPPFLAGS) $(CPPFLAGS) $(part_amiga_module_CFLAGS) $(CFLAGS) -MT partmap/part_amiga_module-amiga.obj -MD -MP -MF partmap/$(DEPDIR)/part_amiga_module-amiga.Tpo -c -o partmap/part_amiga_module-amiga.obj `if test -f 'partmap/amiga.c'; then $(CYGPATH_W) 'partmap/amiga.c'; else $(CYGPATH_W) '$(srcdir)/partmap/amiga.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_amiga_module-amiga.Tpo partmap/$(DEPDIR)/part_amiga_module-amiga.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/amiga.c' object='partmap/part_amiga_module-amiga.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_amiga_module_CPPFLAGS) $(CPPFLAGS) $(part_amiga_module_CFLAGS) $(CFLAGS) -c -o partmap/part_amiga_module-amiga.obj `if test -f 'partmap/amiga.c'; then $(CYGPATH_W) 'partmap/amiga.c'; else $(CYGPATH_W) '$(srcdir)/partmap/amiga.c'; fi`
+
+partmap/part_apple_module-apple.o: partmap/apple.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_apple_module_CPPFLAGS) $(CPPFLAGS) $(part_apple_module_CFLAGS) $(CFLAGS) -MT partmap/part_apple_module-apple.o -MD -MP -MF partmap/$(DEPDIR)/part_apple_module-apple.Tpo -c -o partmap/part_apple_module-apple.o `test -f 'partmap/apple.c' || echo '$(srcdir)/'`partmap/apple.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_apple_module-apple.Tpo partmap/$(DEPDIR)/part_apple_module-apple.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/apple.c' object='partmap/part_apple_module-apple.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_apple_module_CPPFLAGS) $(CPPFLAGS) $(part_apple_module_CFLAGS) $(CFLAGS) -c -o partmap/part_apple_module-apple.o `test -f 'partmap/apple.c' || echo '$(srcdir)/'`partmap/apple.c
+
+partmap/part_apple_module-apple.obj: partmap/apple.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_apple_module_CPPFLAGS) $(CPPFLAGS) $(part_apple_module_CFLAGS) $(CFLAGS) -MT partmap/part_apple_module-apple.obj -MD -MP -MF partmap/$(DEPDIR)/part_apple_module-apple.Tpo -c -o partmap/part_apple_module-apple.obj `if test -f 'partmap/apple.c'; then $(CYGPATH_W) 'partmap/apple.c'; else $(CYGPATH_W) '$(srcdir)/partmap/apple.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_apple_module-apple.Tpo partmap/$(DEPDIR)/part_apple_module-apple.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/apple.c' object='partmap/part_apple_module-apple.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_apple_module_CPPFLAGS) $(CPPFLAGS) $(part_apple_module_CFLAGS) $(CFLAGS) -c -o partmap/part_apple_module-apple.obj `if test -f 'partmap/apple.c'; then $(CYGPATH_W) 'partmap/apple.c'; else $(CYGPATH_W) '$(srcdir)/partmap/apple.c'; fi`
+
+partmap/part_bsd_module-bsdlabel.o: partmap/bsdlabel.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_bsd_module_CPPFLAGS) $(CPPFLAGS) $(part_bsd_module_CFLAGS) $(CFLAGS) -MT partmap/part_bsd_module-bsdlabel.o -MD -MP -MF partmap/$(DEPDIR)/part_bsd_module-bsdlabel.Tpo -c -o partmap/part_bsd_module-bsdlabel.o `test -f 'partmap/bsdlabel.c' || echo '$(srcdir)/'`partmap/bsdlabel.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_bsd_module-bsdlabel.Tpo partmap/$(DEPDIR)/part_bsd_module-bsdlabel.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/bsdlabel.c' object='partmap/part_bsd_module-bsdlabel.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_bsd_module_CPPFLAGS) $(CPPFLAGS) $(part_bsd_module_CFLAGS) $(CFLAGS) -c -o partmap/part_bsd_module-bsdlabel.o `test -f 'partmap/bsdlabel.c' || echo '$(srcdir)/'`partmap/bsdlabel.c
+
+partmap/part_bsd_module-bsdlabel.obj: partmap/bsdlabel.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_bsd_module_CPPFLAGS) $(CPPFLAGS) $(part_bsd_module_CFLAGS) $(CFLAGS) -MT partmap/part_bsd_module-bsdlabel.obj -MD -MP -MF partmap/$(DEPDIR)/part_bsd_module-bsdlabel.Tpo -c -o partmap/part_bsd_module-bsdlabel.obj `if test -f 'partmap/bsdlabel.c'; then $(CYGPATH_W) 'partmap/bsdlabel.c'; else $(CYGPATH_W) '$(srcdir)/partmap/bsdlabel.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_bsd_module-bsdlabel.Tpo partmap/$(DEPDIR)/part_bsd_module-bsdlabel.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/bsdlabel.c' object='partmap/part_bsd_module-bsdlabel.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_bsd_module_CPPFLAGS) $(CPPFLAGS) $(part_bsd_module_CFLAGS) $(CFLAGS) -c -o partmap/part_bsd_module-bsdlabel.obj `if test -f 'partmap/bsdlabel.c'; then $(CYGPATH_W) 'partmap/bsdlabel.c'; else $(CYGPATH_W) '$(srcdir)/partmap/bsdlabel.c'; fi`
+
+partmap/part_dfly_module-dfly.o: partmap/dfly.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dfly_module_CPPFLAGS) $(CPPFLAGS) $(part_dfly_module_CFLAGS) $(CFLAGS) -MT partmap/part_dfly_module-dfly.o -MD -MP -MF partmap/$(DEPDIR)/part_dfly_module-dfly.Tpo -c -o partmap/part_dfly_module-dfly.o `test -f 'partmap/dfly.c' || echo '$(srcdir)/'`partmap/dfly.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_dfly_module-dfly.Tpo partmap/$(DEPDIR)/part_dfly_module-dfly.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/dfly.c' object='partmap/part_dfly_module-dfly.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dfly_module_CPPFLAGS) $(CPPFLAGS) $(part_dfly_module_CFLAGS) $(CFLAGS) -c -o partmap/part_dfly_module-dfly.o `test -f 'partmap/dfly.c' || echo '$(srcdir)/'`partmap/dfly.c
+
+partmap/part_dfly_module-dfly.obj: partmap/dfly.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dfly_module_CPPFLAGS) $(CPPFLAGS) $(part_dfly_module_CFLAGS) $(CFLAGS) -MT partmap/part_dfly_module-dfly.obj -MD -MP -MF partmap/$(DEPDIR)/part_dfly_module-dfly.Tpo -c -o partmap/part_dfly_module-dfly.obj `if test -f 'partmap/dfly.c'; then $(CYGPATH_W) 'partmap/dfly.c'; else $(CYGPATH_W) '$(srcdir)/partmap/dfly.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_dfly_module-dfly.Tpo partmap/$(DEPDIR)/part_dfly_module-dfly.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/dfly.c' object='partmap/part_dfly_module-dfly.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dfly_module_CPPFLAGS) $(CPPFLAGS) $(part_dfly_module_CFLAGS) $(CFLAGS) -c -o partmap/part_dfly_module-dfly.obj `if test -f 'partmap/dfly.c'; then $(CYGPATH_W) 'partmap/dfly.c'; else $(CYGPATH_W) '$(srcdir)/partmap/dfly.c'; fi`
+
+partmap/part_dvh_module-dvh.o: partmap/dvh.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dvh_module_CPPFLAGS) $(CPPFLAGS) $(part_dvh_module_CFLAGS) $(CFLAGS) -MT partmap/part_dvh_module-dvh.o -MD -MP -MF partmap/$(DEPDIR)/part_dvh_module-dvh.Tpo -c -o partmap/part_dvh_module-dvh.o `test -f 'partmap/dvh.c' || echo '$(srcdir)/'`partmap/dvh.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_dvh_module-dvh.Tpo partmap/$(DEPDIR)/part_dvh_module-dvh.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/dvh.c' object='partmap/part_dvh_module-dvh.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dvh_module_CPPFLAGS) $(CPPFLAGS) $(part_dvh_module_CFLAGS) $(CFLAGS) -c -o partmap/part_dvh_module-dvh.o `test -f 'partmap/dvh.c' || echo '$(srcdir)/'`partmap/dvh.c
+
+partmap/part_dvh_module-dvh.obj: partmap/dvh.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dvh_module_CPPFLAGS) $(CPPFLAGS) $(part_dvh_module_CFLAGS) $(CFLAGS) -MT partmap/part_dvh_module-dvh.obj -MD -MP -MF partmap/$(DEPDIR)/part_dvh_module-dvh.Tpo -c -o partmap/part_dvh_module-dvh.obj `if test -f 'partmap/dvh.c'; then $(CYGPATH_W) 'partmap/dvh.c'; else $(CYGPATH_W) '$(srcdir)/partmap/dvh.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_dvh_module-dvh.Tpo partmap/$(DEPDIR)/part_dvh_module-dvh.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/dvh.c' object='partmap/part_dvh_module-dvh.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dvh_module_CPPFLAGS) $(CPPFLAGS) $(part_dvh_module_CFLAGS) $(CFLAGS) -c -o partmap/part_dvh_module-dvh.obj `if test -f 'partmap/dvh.c'; then $(CYGPATH_W) 'partmap/dvh.c'; else $(CYGPATH_W) '$(srcdir)/partmap/dvh.c'; fi`
+
+partmap/part_gpt_module-gpt.o: partmap/gpt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_gpt_module_CPPFLAGS) $(CPPFLAGS) $(part_gpt_module_CFLAGS) $(CFLAGS) -MT partmap/part_gpt_module-gpt.o -MD -MP -MF partmap/$(DEPDIR)/part_gpt_module-gpt.Tpo -c -o partmap/part_gpt_module-gpt.o `test -f 'partmap/gpt.c' || echo '$(srcdir)/'`partmap/gpt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_gpt_module-gpt.Tpo partmap/$(DEPDIR)/part_gpt_module-gpt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/gpt.c' object='partmap/part_gpt_module-gpt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_gpt_module_CPPFLAGS) $(CPPFLAGS) $(part_gpt_module_CFLAGS) $(CFLAGS) -c -o partmap/part_gpt_module-gpt.o `test -f 'partmap/gpt.c' || echo '$(srcdir)/'`partmap/gpt.c
+
+partmap/part_gpt_module-gpt.obj: partmap/gpt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_gpt_module_CPPFLAGS) $(CPPFLAGS) $(part_gpt_module_CFLAGS) $(CFLAGS) -MT partmap/part_gpt_module-gpt.obj -MD -MP -MF partmap/$(DEPDIR)/part_gpt_module-gpt.Tpo -c -o partmap/part_gpt_module-gpt.obj `if test -f 'partmap/gpt.c'; then $(CYGPATH_W) 'partmap/gpt.c'; else $(CYGPATH_W) '$(srcdir)/partmap/gpt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_gpt_module-gpt.Tpo partmap/$(DEPDIR)/part_gpt_module-gpt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/gpt.c' object='partmap/part_gpt_module-gpt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_gpt_module_CPPFLAGS) $(CPPFLAGS) $(part_gpt_module_CFLAGS) $(CFLAGS) -c -o partmap/part_gpt_module-gpt.obj `if test -f 'partmap/gpt.c'; then $(CYGPATH_W) 'partmap/gpt.c'; else $(CYGPATH_W) '$(srcdir)/partmap/gpt.c'; fi`
+
+partmap/part_msdos_module-msdos.o: partmap/msdos.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_msdos_module_CPPFLAGS) $(CPPFLAGS) $(part_msdos_module_CFLAGS) $(CFLAGS) -MT partmap/part_msdos_module-msdos.o -MD -MP -MF partmap/$(DEPDIR)/part_msdos_module-msdos.Tpo -c -o partmap/part_msdos_module-msdos.o `test -f 'partmap/msdos.c' || echo '$(srcdir)/'`partmap/msdos.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_msdos_module-msdos.Tpo partmap/$(DEPDIR)/part_msdos_module-msdos.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/msdos.c' object='partmap/part_msdos_module-msdos.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_msdos_module_CPPFLAGS) $(CPPFLAGS) $(part_msdos_module_CFLAGS) $(CFLAGS) -c -o partmap/part_msdos_module-msdos.o `test -f 'partmap/msdos.c' || echo '$(srcdir)/'`partmap/msdos.c
+
+partmap/part_msdos_module-msdos.obj: partmap/msdos.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_msdos_module_CPPFLAGS) $(CPPFLAGS) $(part_msdos_module_CFLAGS) $(CFLAGS) -MT partmap/part_msdos_module-msdos.obj -MD -MP -MF partmap/$(DEPDIR)/part_msdos_module-msdos.Tpo -c -o partmap/part_msdos_module-msdos.obj `if test -f 'partmap/msdos.c'; then $(CYGPATH_W) 'partmap/msdos.c'; else $(CYGPATH_W) '$(srcdir)/partmap/msdos.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_msdos_module-msdos.Tpo partmap/$(DEPDIR)/part_msdos_module-msdos.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/msdos.c' object='partmap/part_msdos_module-msdos.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_msdos_module_CPPFLAGS) $(CPPFLAGS) $(part_msdos_module_CFLAGS) $(CFLAGS) -c -o partmap/part_msdos_module-msdos.obj `if test -f 'partmap/msdos.c'; then $(CYGPATH_W) 'partmap/msdos.c'; else $(CYGPATH_W) '$(srcdir)/partmap/msdos.c'; fi`
+
+partmap/part_plan_module-plan.o: partmap/plan.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_plan_module_CPPFLAGS) $(CPPFLAGS) $(part_plan_module_CFLAGS) $(CFLAGS) -MT partmap/part_plan_module-plan.o -MD -MP -MF partmap/$(DEPDIR)/part_plan_module-plan.Tpo -c -o partmap/part_plan_module-plan.o `test -f 'partmap/plan.c' || echo '$(srcdir)/'`partmap/plan.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_plan_module-plan.Tpo partmap/$(DEPDIR)/part_plan_module-plan.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/plan.c' object='partmap/part_plan_module-plan.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_plan_module_CPPFLAGS) $(CPPFLAGS) $(part_plan_module_CFLAGS) $(CFLAGS) -c -o partmap/part_plan_module-plan.o `test -f 'partmap/plan.c' || echo '$(srcdir)/'`partmap/plan.c
+
+partmap/part_plan_module-plan.obj: partmap/plan.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_plan_module_CPPFLAGS) $(CPPFLAGS) $(part_plan_module_CFLAGS) $(CFLAGS) -MT partmap/part_plan_module-plan.obj -MD -MP -MF partmap/$(DEPDIR)/part_plan_module-plan.Tpo -c -o partmap/part_plan_module-plan.obj `if test -f 'partmap/plan.c'; then $(CYGPATH_W) 'partmap/plan.c'; else $(CYGPATH_W) '$(srcdir)/partmap/plan.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_plan_module-plan.Tpo partmap/$(DEPDIR)/part_plan_module-plan.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/plan.c' object='partmap/part_plan_module-plan.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_plan_module_CPPFLAGS) $(CPPFLAGS) $(part_plan_module_CFLAGS) $(CFLAGS) -c -o partmap/part_plan_module-plan.obj `if test -f 'partmap/plan.c'; then $(CYGPATH_W) 'partmap/plan.c'; else $(CYGPATH_W) '$(srcdir)/partmap/plan.c'; fi`
+
+partmap/part_sun_module-sun.o: partmap/sun.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sun_module_CPPFLAGS) $(CPPFLAGS) $(part_sun_module_CFLAGS) $(CFLAGS) -MT partmap/part_sun_module-sun.o -MD -MP -MF partmap/$(DEPDIR)/part_sun_module-sun.Tpo -c -o partmap/part_sun_module-sun.o `test -f 'partmap/sun.c' || echo '$(srcdir)/'`partmap/sun.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_sun_module-sun.Tpo partmap/$(DEPDIR)/part_sun_module-sun.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/sun.c' object='partmap/part_sun_module-sun.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sun_module_CPPFLAGS) $(CPPFLAGS) $(part_sun_module_CFLAGS) $(CFLAGS) -c -o partmap/part_sun_module-sun.o `test -f 'partmap/sun.c' || echo '$(srcdir)/'`partmap/sun.c
+
+partmap/part_sun_module-sun.obj: partmap/sun.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sun_module_CPPFLAGS) $(CPPFLAGS) $(part_sun_module_CFLAGS) $(CFLAGS) -MT partmap/part_sun_module-sun.obj -MD -MP -MF partmap/$(DEPDIR)/part_sun_module-sun.Tpo -c -o partmap/part_sun_module-sun.obj `if test -f 'partmap/sun.c'; then $(CYGPATH_W) 'partmap/sun.c'; else $(CYGPATH_W) '$(srcdir)/partmap/sun.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_sun_module-sun.Tpo partmap/$(DEPDIR)/part_sun_module-sun.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/sun.c' object='partmap/part_sun_module-sun.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sun_module_CPPFLAGS) $(CPPFLAGS) $(part_sun_module_CFLAGS) $(CFLAGS) -c -o partmap/part_sun_module-sun.obj `if test -f 'partmap/sun.c'; then $(CYGPATH_W) 'partmap/sun.c'; else $(CYGPATH_W) '$(srcdir)/partmap/sun.c'; fi`
+
+partmap/part_sunpc_module-sunpc.o: partmap/sunpc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sunpc_module_CPPFLAGS) $(CPPFLAGS) $(part_sunpc_module_CFLAGS) $(CFLAGS) -MT partmap/part_sunpc_module-sunpc.o -MD -MP -MF partmap/$(DEPDIR)/part_sunpc_module-sunpc.Tpo -c -o partmap/part_sunpc_module-sunpc.o `test -f 'partmap/sunpc.c' || echo '$(srcdir)/'`partmap/sunpc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_sunpc_module-sunpc.Tpo partmap/$(DEPDIR)/part_sunpc_module-sunpc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/sunpc.c' object='partmap/part_sunpc_module-sunpc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sunpc_module_CPPFLAGS) $(CPPFLAGS) $(part_sunpc_module_CFLAGS) $(CFLAGS) -c -o partmap/part_sunpc_module-sunpc.o `test -f 'partmap/sunpc.c' || echo '$(srcdir)/'`partmap/sunpc.c
+
+partmap/part_sunpc_module-sunpc.obj: partmap/sunpc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sunpc_module_CPPFLAGS) $(CPPFLAGS) $(part_sunpc_module_CFLAGS) $(CFLAGS) -MT partmap/part_sunpc_module-sunpc.obj -MD -MP -MF partmap/$(DEPDIR)/part_sunpc_module-sunpc.Tpo -c -o partmap/part_sunpc_module-sunpc.obj `if test -f 'partmap/sunpc.c'; then $(CYGPATH_W) 'partmap/sunpc.c'; else $(CYGPATH_W) '$(srcdir)/partmap/sunpc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) partmap/$(DEPDIR)/part_sunpc_module-sunpc.Tpo partmap/$(DEPDIR)/part_sunpc_module-sunpc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='partmap/sunpc.c' object='partmap/part_sunpc_module-sunpc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sunpc_module_CPPFLAGS) $(CPPFLAGS) $(part_sunpc_module_CFLAGS) $(CFLAGS) -c -o partmap/part_sunpc_module-sunpc.obj `if test -f 'partmap/sunpc.c'; then $(CYGPATH_W) 'partmap/sunpc.c'; else $(CYGPATH_W) '$(srcdir)/partmap/sunpc.c'; fi`
+
+commands/parttool_module-parttool.o: commands/parttool.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(parttool_module_CPPFLAGS) $(CPPFLAGS) $(parttool_module_CFLAGS) $(CFLAGS) -MT commands/parttool_module-parttool.o -MD -MP -MF commands/$(DEPDIR)/parttool_module-parttool.Tpo -c -o commands/parttool_module-parttool.o `test -f 'commands/parttool.c' || echo '$(srcdir)/'`commands/parttool.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/parttool_module-parttool.Tpo commands/$(DEPDIR)/parttool_module-parttool.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/parttool.c' object='commands/parttool_module-parttool.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(parttool_module_CPPFLAGS) $(CPPFLAGS) $(parttool_module_CFLAGS) $(CFLAGS) -c -o commands/parttool_module-parttool.o `test -f 'commands/parttool.c' || echo '$(srcdir)/'`commands/parttool.c
+
+commands/parttool_module-parttool.obj: commands/parttool.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(parttool_module_CPPFLAGS) $(CPPFLAGS) $(parttool_module_CFLAGS) $(CFLAGS) -MT commands/parttool_module-parttool.obj -MD -MP -MF commands/$(DEPDIR)/parttool_module-parttool.Tpo -c -o commands/parttool_module-parttool.obj `if test -f 'commands/parttool.c'; then $(CYGPATH_W) 'commands/parttool.c'; else $(CYGPATH_W) '$(srcdir)/commands/parttool.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/parttool_module-parttool.Tpo commands/$(DEPDIR)/parttool_module-parttool.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/parttool.c' object='commands/parttool_module-parttool.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(parttool_module_CPPFLAGS) $(CPPFLAGS) $(parttool_module_CFLAGS) $(CFLAGS) -c -o commands/parttool_module-parttool.obj `if test -f 'commands/parttool.c'; then $(CYGPATH_W) 'commands/parttool.c'; else $(CYGPATH_W) '$(srcdir)/commands/parttool.c'; fi`
+
+commands/password_module-password.o: commands/password.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_module_CPPFLAGS) $(CPPFLAGS) $(password_module_CFLAGS) $(CFLAGS) -MT commands/password_module-password.o -MD -MP -MF commands/$(DEPDIR)/password_module-password.Tpo -c -o commands/password_module-password.o `test -f 'commands/password.c' || echo '$(srcdir)/'`commands/password.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/password_module-password.Tpo commands/$(DEPDIR)/password_module-password.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/password.c' object='commands/password_module-password.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_module_CPPFLAGS) $(CPPFLAGS) $(password_module_CFLAGS) $(CFLAGS) -c -o commands/password_module-password.o `test -f 'commands/password.c' || echo '$(srcdir)/'`commands/password.c
+
+commands/password_module-password.obj: commands/password.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_module_CPPFLAGS) $(CPPFLAGS) $(password_module_CFLAGS) $(CFLAGS) -MT commands/password_module-password.obj -MD -MP -MF commands/$(DEPDIR)/password_module-password.Tpo -c -o commands/password_module-password.obj `if test -f 'commands/password.c'; then $(CYGPATH_W) 'commands/password.c'; else $(CYGPATH_W) '$(srcdir)/commands/password.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/password_module-password.Tpo commands/$(DEPDIR)/password_module-password.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/password.c' object='commands/password_module-password.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_module_CPPFLAGS) $(CPPFLAGS) $(password_module_CFLAGS) $(CFLAGS) -c -o commands/password_module-password.obj `if test -f 'commands/password.c'; then $(CYGPATH_W) 'commands/password.c'; else $(CYGPATH_W) '$(srcdir)/commands/password.c'; fi`
+
+commands/password_pbkdf2_module-password_pbkdf2.o: commands/password_pbkdf2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $(password_pbkdf2_module_CFLAGS) $(CFLAGS) -MT commands/password_pbkdf2_module-password_pbkdf2.o -MD -MP -MF commands/$(DEPDIR)/password_pbkdf2_module-password_pbkdf2.Tpo -c -o commands/password_pbkdf2_module-password_pbkdf2.o `test -f 'commands/password_pbkdf2.c' || echo '$(srcdir)/'`commands/password_pbkdf2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/password_pbkdf2_module-password_pbkdf2.Tpo commands/$(DEPDIR)/password_pbkdf2_module-password_pbkdf2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/password_pbkdf2.c' object='commands/password_pbkdf2_module-password_pbkdf2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $(password_pbkdf2_module_CFLAGS) $(CFLAGS) -c -o commands/password_pbkdf2_module-password_pbkdf2.o `test -f 'commands/password_pbkdf2.c' || echo '$(srcdir)/'`commands/password_pbkdf2.c
+
+commands/password_pbkdf2_module-password_pbkdf2.obj: commands/password_pbkdf2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $(password_pbkdf2_module_CFLAGS) $(CFLAGS) -MT commands/password_pbkdf2_module-password_pbkdf2.obj -MD -MP -MF commands/$(DEPDIR)/password_pbkdf2_module-password_pbkdf2.Tpo -c -o commands/password_pbkdf2_module-password_pbkdf2.obj `if test -f 'commands/password_pbkdf2.c'; then $(CYGPATH_W) 'commands/password_pbkdf2.c'; else $(CYGPATH_W) '$(srcdir)/commands/password_pbkdf2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/password_pbkdf2_module-password_pbkdf2.Tpo commands/$(DEPDIR)/password_pbkdf2_module-password_pbkdf2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/password_pbkdf2.c' object='commands/password_pbkdf2_module-password_pbkdf2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $(password_pbkdf2_module_CFLAGS) $(CFLAGS) -c -o commands/password_pbkdf2_module-password_pbkdf2.obj `if test -f 'commands/password_pbkdf2.c'; then $(CYGPATH_W) 'commands/password_pbkdf2.c'; else $(CYGPATH_W) '$(srcdir)/commands/password_pbkdf2.c'; fi`
+
+disk/pata_module-pata.o: disk/pata.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $(pata_module_CFLAGS) $(CFLAGS) -MT disk/pata_module-pata.o -MD -MP -MF disk/$(DEPDIR)/pata_module-pata.Tpo -c -o disk/pata_module-pata.o `test -f 'disk/pata.c' || echo '$(srcdir)/'`disk/pata.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/pata_module-pata.Tpo disk/$(DEPDIR)/pata_module-pata.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/pata.c' object='disk/pata_module-pata.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $(pata_module_CFLAGS) $(CFLAGS) -c -o disk/pata_module-pata.o `test -f 'disk/pata.c' || echo '$(srcdir)/'`disk/pata.c
+
+disk/pata_module-pata.obj: disk/pata.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $(pata_module_CFLAGS) $(CFLAGS) -MT disk/pata_module-pata.obj -MD -MP -MF disk/$(DEPDIR)/pata_module-pata.Tpo -c -o disk/pata_module-pata.obj `if test -f 'disk/pata.c'; then $(CYGPATH_W) 'disk/pata.c'; else $(CYGPATH_W) '$(srcdir)/disk/pata.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/pata_module-pata.Tpo disk/$(DEPDIR)/pata_module-pata.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/pata.c' object='disk/pata_module-pata.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $(pata_module_CFLAGS) $(CFLAGS) -c -o disk/pata_module-pata.obj `if test -f 'disk/pata.c'; then $(CYGPATH_W) 'disk/pata.c'; else $(CYGPATH_W) '$(srcdir)/disk/pata.c'; fi`
+
+lib/pbkdf2_module-pbkdf2.o: lib/pbkdf2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $(pbkdf2_module_CFLAGS) $(CFLAGS) -MT lib/pbkdf2_module-pbkdf2.o -MD -MP -MF lib/$(DEPDIR)/pbkdf2_module-pbkdf2.Tpo -c -o lib/pbkdf2_module-pbkdf2.o `test -f 'lib/pbkdf2.c' || echo '$(srcdir)/'`lib/pbkdf2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/pbkdf2_module-pbkdf2.Tpo lib/$(DEPDIR)/pbkdf2_module-pbkdf2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/pbkdf2.c' object='lib/pbkdf2_module-pbkdf2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $(pbkdf2_module_CFLAGS) $(CFLAGS) -c -o lib/pbkdf2_module-pbkdf2.o `test -f 'lib/pbkdf2.c' || echo '$(srcdir)/'`lib/pbkdf2.c
+
+lib/pbkdf2_module-pbkdf2.obj: lib/pbkdf2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $(pbkdf2_module_CFLAGS) $(CFLAGS) -MT lib/pbkdf2_module-pbkdf2.obj -MD -MP -MF lib/$(DEPDIR)/pbkdf2_module-pbkdf2.Tpo -c -o lib/pbkdf2_module-pbkdf2.obj `if test -f 'lib/pbkdf2.c'; then $(CYGPATH_W) 'lib/pbkdf2.c'; else $(CYGPATH_W) '$(srcdir)/lib/pbkdf2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/pbkdf2_module-pbkdf2.Tpo lib/$(DEPDIR)/pbkdf2_module-pbkdf2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/pbkdf2.c' object='lib/pbkdf2_module-pbkdf2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $(pbkdf2_module_CFLAGS) $(CFLAGS) -c -o lib/pbkdf2_module-pbkdf2.obj `if test -f 'lib/pbkdf2.c'; then $(CYGPATH_W) 'lib/pbkdf2.c'; else $(CYGPATH_W) '$(srcdir)/lib/pbkdf2.c'; fi`
+
+tests/pbkdf2_test_module-pbkdf2_test.o: tests/pbkdf2_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_test_module_CPPFLAGS) $(CPPFLAGS) $(pbkdf2_test_module_CFLAGS) $(CFLAGS) -MT tests/pbkdf2_test_module-pbkdf2_test.o -MD -MP -MF tests/$(DEPDIR)/pbkdf2_test_module-pbkdf2_test.Tpo -c -o tests/pbkdf2_test_module-pbkdf2_test.o `test -f 'tests/pbkdf2_test.c' || echo '$(srcdir)/'`tests/pbkdf2_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/pbkdf2_test_module-pbkdf2_test.Tpo tests/$(DEPDIR)/pbkdf2_test_module-pbkdf2_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/pbkdf2_test.c' object='tests/pbkdf2_test_module-pbkdf2_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_test_module_CPPFLAGS) $(CPPFLAGS) $(pbkdf2_test_module_CFLAGS) $(CFLAGS) -c -o tests/pbkdf2_test_module-pbkdf2_test.o `test -f 'tests/pbkdf2_test.c' || echo '$(srcdir)/'`tests/pbkdf2_test.c
+
+tests/pbkdf2_test_module-pbkdf2_test.obj: tests/pbkdf2_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_test_module_CPPFLAGS) $(CPPFLAGS) $(pbkdf2_test_module_CFLAGS) $(CFLAGS) -MT tests/pbkdf2_test_module-pbkdf2_test.obj -MD -MP -MF tests/$(DEPDIR)/pbkdf2_test_module-pbkdf2_test.Tpo -c -o tests/pbkdf2_test_module-pbkdf2_test.obj `if test -f 'tests/pbkdf2_test.c'; then $(CYGPATH_W) 'tests/pbkdf2_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/pbkdf2_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/pbkdf2_test_module-pbkdf2_test.Tpo tests/$(DEPDIR)/pbkdf2_test_module-pbkdf2_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/pbkdf2_test.c' object='tests/pbkdf2_test_module-pbkdf2_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_test_module_CPPFLAGS) $(CPPFLAGS) $(pbkdf2_test_module_CFLAGS) $(CFLAGS) -c -o tests/pbkdf2_test_module-pbkdf2_test.obj `if test -f 'tests/pbkdf2_test.c'; then $(CYGPATH_W) 'tests/pbkdf2_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/pbkdf2_test.c'; fi`
+
+bus/pci_module-pci.o: bus/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $(pci_module_CFLAGS) $(CFLAGS) -MT bus/pci_module-pci.o -MD -MP -MF bus/$(DEPDIR)/pci_module-pci.Tpo -c -o bus/pci_module-pci.o `test -f 'bus/pci.c' || echo '$(srcdir)/'`bus/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/pci_module-pci.Tpo bus/$(DEPDIR)/pci_module-pci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/pci.c' object='bus/pci_module-pci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $(pci_module_CFLAGS) $(CFLAGS) -c -o bus/pci_module-pci.o `test -f 'bus/pci.c' || echo '$(srcdir)/'`bus/pci.c
+
+bus/pci_module-pci.obj: bus/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $(pci_module_CFLAGS) $(CFLAGS) -MT bus/pci_module-pci.obj -MD -MP -MF bus/$(DEPDIR)/pci_module-pci.Tpo -c -o bus/pci_module-pci.obj `if test -f 'bus/pci.c'; then $(CYGPATH_W) 'bus/pci.c'; else $(CYGPATH_W) '$(srcdir)/bus/pci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/$(DEPDIR)/pci_module-pci.Tpo bus/$(DEPDIR)/pci_module-pci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/pci.c' object='bus/pci_module-pci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $(pci_module_CFLAGS) $(CFLAGS) -c -o bus/pci_module-pci.obj `if test -f 'bus/pci.c'; then $(CYGPATH_W) 'bus/pci.c'; else $(CYGPATH_W) '$(srcdir)/bus/pci.c'; fi`
+
+bus/i386/ieee1275/pci_module-pci.o: bus/i386/ieee1275/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $(pci_module_CFLAGS) $(CFLAGS) -MT bus/i386/ieee1275/pci_module-pci.o -MD -MP -MF bus/i386/ieee1275/$(DEPDIR)/pci_module-pci.Tpo -c -o bus/i386/ieee1275/pci_module-pci.o `test -f 'bus/i386/ieee1275/pci.c' || echo '$(srcdir)/'`bus/i386/ieee1275/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/i386/ieee1275/$(DEPDIR)/pci_module-pci.Tpo bus/i386/ieee1275/$(DEPDIR)/pci_module-pci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/i386/ieee1275/pci.c' object='bus/i386/ieee1275/pci_module-pci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $(pci_module_CFLAGS) $(CFLAGS) -c -o bus/i386/ieee1275/pci_module-pci.o `test -f 'bus/i386/ieee1275/pci.c' || echo '$(srcdir)/'`bus/i386/ieee1275/pci.c
+
+bus/i386/ieee1275/pci_module-pci.obj: bus/i386/ieee1275/pci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $(pci_module_CFLAGS) $(CFLAGS) -MT bus/i386/ieee1275/pci_module-pci.obj -MD -MP -MF bus/i386/ieee1275/$(DEPDIR)/pci_module-pci.Tpo -c -o bus/i386/ieee1275/pci_module-pci.obj `if test -f 'bus/i386/ieee1275/pci.c'; then $(CYGPATH_W) 'bus/i386/ieee1275/pci.c'; else $(CYGPATH_W) '$(srcdir)/bus/i386/ieee1275/pci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/i386/ieee1275/$(DEPDIR)/pci_module-pci.Tpo bus/i386/ieee1275/$(DEPDIR)/pci_module-pci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/i386/ieee1275/pci.c' object='bus/i386/ieee1275/pci_module-pci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $(pci_module_CFLAGS) $(CFLAGS) -c -o bus/i386/ieee1275/pci_module-pci.obj `if test -f 'bus/i386/ieee1275/pci.c'; then $(CYGPATH_W) 'bus/i386/ieee1275/pci.c'; else $(CYGPATH_W) '$(srcdir)/bus/i386/ieee1275/pci.c'; fi`
+
+commands/pcidump_module-pcidump.o: commands/pcidump.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $(pcidump_module_CFLAGS) $(CFLAGS) -MT commands/pcidump_module-pcidump.o -MD -MP -MF commands/$(DEPDIR)/pcidump_module-pcidump.Tpo -c -o commands/pcidump_module-pcidump.o `test -f 'commands/pcidump.c' || echo '$(srcdir)/'`commands/pcidump.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/pcidump_module-pcidump.Tpo commands/$(DEPDIR)/pcidump_module-pcidump.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/pcidump.c' object='commands/pcidump_module-pcidump.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $(pcidump_module_CFLAGS) $(CFLAGS) -c -o commands/pcidump_module-pcidump.o `test -f 'commands/pcidump.c' || echo '$(srcdir)/'`commands/pcidump.c
+
+commands/pcidump_module-pcidump.obj: commands/pcidump.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $(pcidump_module_CFLAGS) $(CFLAGS) -MT commands/pcidump_module-pcidump.obj -MD -MP -MF commands/$(DEPDIR)/pcidump_module-pcidump.Tpo -c -o commands/pcidump_module-pcidump.obj `if test -f 'commands/pcidump.c'; then $(CYGPATH_W) 'commands/pcidump.c'; else $(CYGPATH_W) '$(srcdir)/commands/pcidump.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/pcidump_module-pcidump.Tpo commands/$(DEPDIR)/pcidump_module-pcidump.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/pcidump.c' object='commands/pcidump_module-pcidump.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $(pcidump_module_CFLAGS) $(CFLAGS) -c -o commands/pcidump_module-pcidump.obj `if test -f 'commands/pcidump.c'; then $(CYGPATH_W) 'commands/pcidump.c'; else $(CYGPATH_W) '$(srcdir)/commands/pcidump.c'; fi`
+
+commands/pgp_module-pgp.o: commands/pgp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pgp_module_CPPFLAGS) $(CPPFLAGS) $(pgp_module_CFLAGS) $(CFLAGS) -MT commands/pgp_module-pgp.o -MD -MP -MF commands/$(DEPDIR)/pgp_module-pgp.Tpo -c -o commands/pgp_module-pgp.o `test -f 'commands/pgp.c' || echo '$(srcdir)/'`commands/pgp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/pgp_module-pgp.Tpo commands/$(DEPDIR)/pgp_module-pgp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/pgp.c' object='commands/pgp_module-pgp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pgp_module_CPPFLAGS) $(CPPFLAGS) $(pgp_module_CFLAGS) $(CFLAGS) -c -o commands/pgp_module-pgp.o `test -f 'commands/pgp.c' || echo '$(srcdir)/'`commands/pgp.c
+
+commands/pgp_module-pgp.obj: commands/pgp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pgp_module_CPPFLAGS) $(CPPFLAGS) $(pgp_module_CFLAGS) $(CFLAGS) -MT commands/pgp_module-pgp.obj -MD -MP -MF commands/$(DEPDIR)/pgp_module-pgp.Tpo -c -o commands/pgp_module-pgp.obj `if test -f 'commands/pgp.c'; then $(CYGPATH_W) 'commands/pgp.c'; else $(CYGPATH_W) '$(srcdir)/commands/pgp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/pgp_module-pgp.Tpo commands/$(DEPDIR)/pgp_module-pgp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/pgp.c' object='commands/pgp_module-pgp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pgp_module_CPPFLAGS) $(CPPFLAGS) $(pgp_module_CFLAGS) $(CFLAGS) -c -o commands/pgp_module-pgp.obj `if test -f 'commands/pgp.c'; then $(CYGPATH_W) 'commands/pgp.c'; else $(CYGPATH_W) '$(srcdir)/commands/pgp.c'; fi`
+
+loader/i386/pc/plan9_module-plan9.o: loader/i386/pc/plan9.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(plan9_module_CPPFLAGS) $(CPPFLAGS) $(plan9_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/plan9_module-plan9.o -MD -MP -MF loader/i386/pc/$(DEPDIR)/plan9_module-plan9.Tpo -c -o loader/i386/pc/plan9_module-plan9.o `test -f 'loader/i386/pc/plan9.c' || echo '$(srcdir)/'`loader/i386/pc/plan9.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/plan9_module-plan9.Tpo loader/i386/pc/$(DEPDIR)/plan9_module-plan9.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/plan9.c' object='loader/i386/pc/plan9_module-plan9.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(plan9_module_CPPFLAGS) $(CPPFLAGS) $(plan9_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/plan9_module-plan9.o `test -f 'loader/i386/pc/plan9.c' || echo '$(srcdir)/'`loader/i386/pc/plan9.c
+
+loader/i386/pc/plan9_module-plan9.obj: loader/i386/pc/plan9.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(plan9_module_CPPFLAGS) $(CPPFLAGS) $(plan9_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/plan9_module-plan9.obj -MD -MP -MF loader/i386/pc/$(DEPDIR)/plan9_module-plan9.Tpo -c -o loader/i386/pc/plan9_module-plan9.obj `if test -f 'loader/i386/pc/plan9.c'; then $(CYGPATH_W) 'loader/i386/pc/plan9.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/plan9.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/plan9_module-plan9.Tpo loader/i386/pc/$(DEPDIR)/plan9_module-plan9.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/plan9.c' object='loader/i386/pc/plan9_module-plan9.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(plan9_module_CPPFLAGS) $(CPPFLAGS) $(plan9_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/plan9_module-plan9.obj `if test -f 'loader/i386/pc/plan9.c'; then $(CYGPATH_W) 'loader/i386/pc/plan9.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/plan9.c'; fi`
+
+commands/i386/pc/play_module-play.o: commands/i386/pc/play.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $(play_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/play_module-play.o -MD -MP -MF commands/i386/pc/$(DEPDIR)/play_module-play.Tpo -c -o commands/i386/pc/play_module-play.o `test -f 'commands/i386/pc/play.c' || echo '$(srcdir)/'`commands/i386/pc/play.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/play_module-play.Tpo commands/i386/pc/$(DEPDIR)/play_module-play.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/play.c' object='commands/i386/pc/play_module-play.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $(play_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/play_module-play.o `test -f 'commands/i386/pc/play.c' || echo '$(srcdir)/'`commands/i386/pc/play.c
+
+commands/i386/pc/play_module-play.obj: commands/i386/pc/play.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $(play_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/play_module-play.obj -MD -MP -MF commands/i386/pc/$(DEPDIR)/play_module-play.Tpo -c -o commands/i386/pc/play_module-play.obj `if test -f 'commands/i386/pc/play.c'; then $(CYGPATH_W) 'commands/i386/pc/play.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/play.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/play_module-play.Tpo commands/i386/pc/$(DEPDIR)/play_module-play.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/play.c' object='commands/i386/pc/play_module-play.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $(play_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/play_module-play.obj `if test -f 'commands/i386/pc/play.c'; then $(CYGPATH_W) 'commands/i386/pc/play.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/play.c'; fi`
+
+video/readers/png_module-png.o: video/readers/png.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(png_module_CPPFLAGS) $(CPPFLAGS) $(png_module_CFLAGS) $(CFLAGS) -MT video/readers/png_module-png.o -MD -MP -MF video/readers/$(DEPDIR)/png_module-png.Tpo -c -o video/readers/png_module-png.o `test -f 'video/readers/png.c' || echo '$(srcdir)/'`video/readers/png.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/readers/$(DEPDIR)/png_module-png.Tpo video/readers/$(DEPDIR)/png_module-png.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/readers/png.c' object='video/readers/png_module-png.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(png_module_CPPFLAGS) $(CPPFLAGS) $(png_module_CFLAGS) $(CFLAGS) -c -o video/readers/png_module-png.o `test -f 'video/readers/png.c' || echo '$(srcdir)/'`video/readers/png.c
+
+video/readers/png_module-png.obj: video/readers/png.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(png_module_CPPFLAGS) $(CPPFLAGS) $(png_module_CFLAGS) $(CFLAGS) -MT video/readers/png_module-png.obj -MD -MP -MF video/readers/$(DEPDIR)/png_module-png.Tpo -c -o video/readers/png_module-png.obj `if test -f 'video/readers/png.c'; then $(CYGPATH_W) 'video/readers/png.c'; else $(CYGPATH_W) '$(srcdir)/video/readers/png.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/readers/$(DEPDIR)/png_module-png.Tpo video/readers/$(DEPDIR)/png_module-png.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/readers/png.c' object='video/readers/png_module-png.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(png_module_CPPFLAGS) $(CPPFLAGS) $(png_module_CFLAGS) $(CFLAGS) -c -o video/readers/png_module-png.obj `if test -f 'video/readers/png.c'; then $(CYGPATH_W) 'video/readers/png.c'; else $(CYGPATH_W) '$(srcdir)/video/readers/png.c'; fi`
+
+lib/priority_queue_module-priority_queue.o: lib/priority_queue.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(priority_queue_module_CPPFLAGS) $(CPPFLAGS) $(priority_queue_module_CFLAGS) $(CFLAGS) -MT lib/priority_queue_module-priority_queue.o -MD -MP -MF lib/$(DEPDIR)/priority_queue_module-priority_queue.Tpo -c -o lib/priority_queue_module-priority_queue.o `test -f 'lib/priority_queue.c' || echo '$(srcdir)/'`lib/priority_queue.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/priority_queue_module-priority_queue.Tpo lib/$(DEPDIR)/priority_queue_module-priority_queue.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/priority_queue.c' object='lib/priority_queue_module-priority_queue.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(priority_queue_module_CPPFLAGS) $(CPPFLAGS) $(priority_queue_module_CFLAGS) $(CFLAGS) -c -o lib/priority_queue_module-priority_queue.o `test -f 'lib/priority_queue.c' || echo '$(srcdir)/'`lib/priority_queue.c
+
+lib/priority_queue_module-priority_queue.obj: lib/priority_queue.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(priority_queue_module_CPPFLAGS) $(CPPFLAGS) $(priority_queue_module_CFLAGS) $(CFLAGS) -MT lib/priority_queue_module-priority_queue.obj -MD -MP -MF lib/$(DEPDIR)/priority_queue_module-priority_queue.Tpo -c -o lib/priority_queue_module-priority_queue.obj `if test -f 'lib/priority_queue.c'; then $(CYGPATH_W) 'lib/priority_queue.c'; else $(CYGPATH_W) '$(srcdir)/lib/priority_queue.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/priority_queue_module-priority_queue.Tpo lib/$(DEPDIR)/priority_queue_module-priority_queue.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/priority_queue.c' object='lib/priority_queue_module-priority_queue.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(priority_queue_module_CPPFLAGS) $(CPPFLAGS) $(priority_queue_module_CFLAGS) $(CFLAGS) -c -o lib/priority_queue_module-priority_queue.obj `if test -f 'lib/priority_queue.c'; then $(CYGPATH_W) 'lib/priority_queue.c'; else $(CYGPATH_W) '$(srcdir)/lib/priority_queue.c'; fi`
+
+commands/probe_module-probe.o: commands/probe.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(probe_module_CPPFLAGS) $(CPPFLAGS) $(probe_module_CFLAGS) $(CFLAGS) -MT commands/probe_module-probe.o -MD -MP -MF commands/$(DEPDIR)/probe_module-probe.Tpo -c -o commands/probe_module-probe.o `test -f 'commands/probe.c' || echo '$(srcdir)/'`commands/probe.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/probe_module-probe.Tpo commands/$(DEPDIR)/probe_module-probe.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/probe.c' object='commands/probe_module-probe.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(probe_module_CPPFLAGS) $(CPPFLAGS) $(probe_module_CFLAGS) $(CFLAGS) -c -o commands/probe_module-probe.o `test -f 'commands/probe.c' || echo '$(srcdir)/'`commands/probe.c
+
+commands/probe_module-probe.obj: commands/probe.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(probe_module_CPPFLAGS) $(CPPFLAGS) $(probe_module_CFLAGS) $(CFLAGS) -MT commands/probe_module-probe.obj -MD -MP -MF commands/$(DEPDIR)/probe_module-probe.Tpo -c -o commands/probe_module-probe.obj `if test -f 'commands/probe.c'; then $(CYGPATH_W) 'commands/probe.c'; else $(CYGPATH_W) '$(srcdir)/commands/probe.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/probe_module-probe.Tpo commands/$(DEPDIR)/probe_module-probe.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/probe.c' object='commands/probe_module-probe.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(probe_module_CPPFLAGS) $(CPPFLAGS) $(probe_module_CFLAGS) $(CFLAGS) -c -o commands/probe_module-probe.obj `if test -f 'commands/probe.c'; then $(CYGPATH_W) 'commands/probe.c'; else $(CYGPATH_W) '$(srcdir)/commands/probe.c'; fi`
+
+fs/procfs_module-proc.o: fs/proc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(procfs_module_CPPFLAGS) $(CPPFLAGS) $(procfs_module_CFLAGS) $(CFLAGS) -MT fs/procfs_module-proc.o -MD -MP -MF fs/$(DEPDIR)/procfs_module-proc.Tpo -c -o fs/procfs_module-proc.o `test -f 'fs/proc.c' || echo '$(srcdir)/'`fs/proc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/procfs_module-proc.Tpo fs/$(DEPDIR)/procfs_module-proc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/proc.c' object='fs/procfs_module-proc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(procfs_module_CPPFLAGS) $(CPPFLAGS) $(procfs_module_CFLAGS) $(CFLAGS) -c -o fs/procfs_module-proc.o `test -f 'fs/proc.c' || echo '$(srcdir)/'`fs/proc.c
+
+fs/procfs_module-proc.obj: fs/proc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(procfs_module_CPPFLAGS) $(CPPFLAGS) $(procfs_module_CFLAGS) $(CFLAGS) -MT fs/procfs_module-proc.obj -MD -MP -MF fs/$(DEPDIR)/procfs_module-proc.Tpo -c -o fs/procfs_module-proc.obj `if test -f 'fs/proc.c'; then $(CYGPATH_W) 'fs/proc.c'; else $(CYGPATH_W) '$(srcdir)/fs/proc.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/procfs_module-proc.Tpo fs/$(DEPDIR)/procfs_module-proc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/proc.c' object='fs/procfs_module-proc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(procfs_module_CPPFLAGS) $(CPPFLAGS) $(procfs_module_CFLAGS) $(CFLAGS) -c -o fs/procfs_module-proc.obj `if test -f 'fs/proc.c'; then $(CYGPATH_W) 'fs/proc.c'; else $(CYGPATH_W) '$(srcdir)/fs/proc.c'; fi`
+
+lib/progress_module-progress.o: lib/progress.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(progress_module_CPPFLAGS) $(CPPFLAGS) $(progress_module_CFLAGS) $(CFLAGS) -MT lib/progress_module-progress.o -MD -MP -MF lib/$(DEPDIR)/progress_module-progress.Tpo -c -o lib/progress_module-progress.o `test -f 'lib/progress.c' || echo '$(srcdir)/'`lib/progress.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/progress_module-progress.Tpo lib/$(DEPDIR)/progress_module-progress.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/progress.c' object='lib/progress_module-progress.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(progress_module_CPPFLAGS) $(CPPFLAGS) $(progress_module_CFLAGS) $(CFLAGS) -c -o lib/progress_module-progress.o `test -f 'lib/progress.c' || echo '$(srcdir)/'`lib/progress.c
+
+lib/progress_module-progress.obj: lib/progress.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(progress_module_CPPFLAGS) $(CPPFLAGS) $(progress_module_CFLAGS) $(CFLAGS) -MT lib/progress_module-progress.obj -MD -MP -MF lib/$(DEPDIR)/progress_module-progress.Tpo -c -o lib/progress_module-progress.obj `if test -f 'lib/progress.c'; then $(CYGPATH_W) 'lib/progress.c'; else $(CYGPATH_W) '$(srcdir)/lib/progress.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/progress_module-progress.Tpo lib/$(DEPDIR)/progress_module-progress.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/progress.c' object='lib/progress_module-progress.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(progress_module_CPPFLAGS) $(CPPFLAGS) $(progress_module_CFLAGS) $(CFLAGS) -c -o lib/progress_module-progress.obj `if test -f 'lib/progress.c'; then $(CYGPATH_W) 'lib/progress.c'; else $(CYGPATH_W) '$(srcdir)/lib/progress.c'; fi`
+
+net/drivers/i386/pc/pxe_module-pxe.o: net/drivers/i386/pc/pxe.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxe_module_CPPFLAGS) $(CPPFLAGS) $(pxe_module_CFLAGS) $(CFLAGS) -MT net/drivers/i386/pc/pxe_module-pxe.o -MD -MP -MF net/drivers/i386/pc/$(DEPDIR)/pxe_module-pxe.Tpo -c -o net/drivers/i386/pc/pxe_module-pxe.o `test -f 'net/drivers/i386/pc/pxe.c' || echo '$(srcdir)/'`net/drivers/i386/pc/pxe.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/drivers/i386/pc/$(DEPDIR)/pxe_module-pxe.Tpo net/drivers/i386/pc/$(DEPDIR)/pxe_module-pxe.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/drivers/i386/pc/pxe.c' object='net/drivers/i386/pc/pxe_module-pxe.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxe_module_CPPFLAGS) $(CPPFLAGS) $(pxe_module_CFLAGS) $(CFLAGS) -c -o net/drivers/i386/pc/pxe_module-pxe.o `test -f 'net/drivers/i386/pc/pxe.c' || echo '$(srcdir)/'`net/drivers/i386/pc/pxe.c
+
+net/drivers/i386/pc/pxe_module-pxe.obj: net/drivers/i386/pc/pxe.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxe_module_CPPFLAGS) $(CPPFLAGS) $(pxe_module_CFLAGS) $(CFLAGS) -MT net/drivers/i386/pc/pxe_module-pxe.obj -MD -MP -MF net/drivers/i386/pc/$(DEPDIR)/pxe_module-pxe.Tpo -c -o net/drivers/i386/pc/pxe_module-pxe.obj `if test -f 'net/drivers/i386/pc/pxe.c'; then $(CYGPATH_W) 'net/drivers/i386/pc/pxe.c'; else $(CYGPATH_W) '$(srcdir)/net/drivers/i386/pc/pxe.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/drivers/i386/pc/$(DEPDIR)/pxe_module-pxe.Tpo net/drivers/i386/pc/$(DEPDIR)/pxe_module-pxe.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/drivers/i386/pc/pxe.c' object='net/drivers/i386/pc/pxe_module-pxe.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxe_module_CPPFLAGS) $(CPPFLAGS) $(pxe_module_CFLAGS) $(CFLAGS) -c -o net/drivers/i386/pc/pxe_module-pxe.obj `if test -f 'net/drivers/i386/pc/pxe.c'; then $(CYGPATH_W) 'net/drivers/i386/pc/pxe.c'; else $(CYGPATH_W) '$(srcdir)/net/drivers/i386/pc/pxe.c'; fi`
+
+loader/i386/pc/pxechain_module-pxechainloader.o: loader/i386/pc/pxechainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxechain_module_CPPFLAGS) $(CPPFLAGS) $(pxechain_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/pxechain_module-pxechainloader.o -MD -MP -MF loader/i386/pc/$(DEPDIR)/pxechain_module-pxechainloader.Tpo -c -o loader/i386/pc/pxechain_module-pxechainloader.o `test -f 'loader/i386/pc/pxechainloader.c' || echo '$(srcdir)/'`loader/i386/pc/pxechainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/pxechain_module-pxechainloader.Tpo loader/i386/pc/$(DEPDIR)/pxechain_module-pxechainloader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/pxechainloader.c' object='loader/i386/pc/pxechain_module-pxechainloader.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxechain_module_CPPFLAGS) $(CPPFLAGS) $(pxechain_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/pxechain_module-pxechainloader.o `test -f 'loader/i386/pc/pxechainloader.c' || echo '$(srcdir)/'`loader/i386/pc/pxechainloader.c
+
+loader/i386/pc/pxechain_module-pxechainloader.obj: loader/i386/pc/pxechainloader.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxechain_module_CPPFLAGS) $(CPPFLAGS) $(pxechain_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/pxechain_module-pxechainloader.obj -MD -MP -MF loader/i386/pc/$(DEPDIR)/pxechain_module-pxechainloader.Tpo -c -o loader/i386/pc/pxechain_module-pxechainloader.obj `if test -f 'loader/i386/pc/pxechainloader.c'; then $(CYGPATH_W) 'loader/i386/pc/pxechainloader.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/pxechainloader.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/pxechain_module-pxechainloader.Tpo loader/i386/pc/$(DEPDIR)/pxechain_module-pxechainloader.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/pxechainloader.c' object='loader/i386/pc/pxechain_module-pxechainloader.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxechain_module_CPPFLAGS) $(CPPFLAGS) $(pxechain_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/pxechain_module-pxechainloader.obj `if test -f 'loader/i386/pc/pxechainloader.c'; then $(CYGPATH_W) 'loader/i386/pc/pxechainloader.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/pxechainloader.c'; fi`
+
+disk/raid5rec_module-raid5_recover.o: disk/raid5_recover.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid5rec_module_CPPFLAGS) $(CPPFLAGS) $(raid5rec_module_CFLAGS) $(CFLAGS) -MT disk/raid5rec_module-raid5_recover.o -MD -MP -MF disk/$(DEPDIR)/raid5rec_module-raid5_recover.Tpo -c -o disk/raid5rec_module-raid5_recover.o `test -f 'disk/raid5_recover.c' || echo '$(srcdir)/'`disk/raid5_recover.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/raid5rec_module-raid5_recover.Tpo disk/$(DEPDIR)/raid5rec_module-raid5_recover.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/raid5_recover.c' object='disk/raid5rec_module-raid5_recover.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid5rec_module_CPPFLAGS) $(CPPFLAGS) $(raid5rec_module_CFLAGS) $(CFLAGS) -c -o disk/raid5rec_module-raid5_recover.o `test -f 'disk/raid5_recover.c' || echo '$(srcdir)/'`disk/raid5_recover.c
+
+disk/raid5rec_module-raid5_recover.obj: disk/raid5_recover.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid5rec_module_CPPFLAGS) $(CPPFLAGS) $(raid5rec_module_CFLAGS) $(CFLAGS) -MT disk/raid5rec_module-raid5_recover.obj -MD -MP -MF disk/$(DEPDIR)/raid5rec_module-raid5_recover.Tpo -c -o disk/raid5rec_module-raid5_recover.obj `if test -f 'disk/raid5_recover.c'; then $(CYGPATH_W) 'disk/raid5_recover.c'; else $(CYGPATH_W) '$(srcdir)/disk/raid5_recover.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/raid5rec_module-raid5_recover.Tpo disk/$(DEPDIR)/raid5rec_module-raid5_recover.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/raid5_recover.c' object='disk/raid5rec_module-raid5_recover.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid5rec_module_CPPFLAGS) $(CPPFLAGS) $(raid5rec_module_CFLAGS) $(CFLAGS) -c -o disk/raid5rec_module-raid5_recover.obj `if test -f 'disk/raid5_recover.c'; then $(CYGPATH_W) 'disk/raid5_recover.c'; else $(CYGPATH_W) '$(srcdir)/disk/raid5_recover.c'; fi`
+
+disk/raid6rec_module-raid6_recover.o: disk/raid6_recover.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid6rec_module_CPPFLAGS) $(CPPFLAGS) $(raid6rec_module_CFLAGS) $(CFLAGS) -MT disk/raid6rec_module-raid6_recover.o -MD -MP -MF disk/$(DEPDIR)/raid6rec_module-raid6_recover.Tpo -c -o disk/raid6rec_module-raid6_recover.o `test -f 'disk/raid6_recover.c' || echo '$(srcdir)/'`disk/raid6_recover.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/raid6rec_module-raid6_recover.Tpo disk/$(DEPDIR)/raid6rec_module-raid6_recover.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/raid6_recover.c' object='disk/raid6rec_module-raid6_recover.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid6rec_module_CPPFLAGS) $(CPPFLAGS) $(raid6rec_module_CFLAGS) $(CFLAGS) -c -o disk/raid6rec_module-raid6_recover.o `test -f 'disk/raid6_recover.c' || echo '$(srcdir)/'`disk/raid6_recover.c
+
+disk/raid6rec_module-raid6_recover.obj: disk/raid6_recover.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid6rec_module_CPPFLAGS) $(CPPFLAGS) $(raid6rec_module_CFLAGS) $(CFLAGS) -MT disk/raid6rec_module-raid6_recover.obj -MD -MP -MF disk/$(DEPDIR)/raid6rec_module-raid6_recover.Tpo -c -o disk/raid6rec_module-raid6_recover.obj `if test -f 'disk/raid6_recover.c'; then $(CYGPATH_W) 'disk/raid6_recover.c'; else $(CYGPATH_W) '$(srcdir)/disk/raid6_recover.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/raid6rec_module-raid6_recover.Tpo disk/$(DEPDIR)/raid6rec_module-raid6_recover.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/raid6_recover.c' object='disk/raid6rec_module-raid6_recover.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid6rec_module_CPPFLAGS) $(CPPFLAGS) $(raid6rec_module_CFLAGS) $(CFLAGS) -c -o disk/raid6rec_module-raid6_recover.obj `if test -f 'disk/raid6_recover.c'; then $(CYGPATH_W) 'disk/raid6_recover.c'; else $(CYGPATH_W) '$(srcdir)/disk/raid6_recover.c'; fi`
+
+kern/i386/random_module-tsc_pmtimer.o: kern/i386/tsc_pmtimer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -MT kern/i386/random_module-tsc_pmtimer.o -MD -MP -MF kern/i386/$(DEPDIR)/random_module-tsc_pmtimer.Tpo -c -o kern/i386/random_module-tsc_pmtimer.o `test -f 'kern/i386/tsc_pmtimer.c' || echo '$(srcdir)/'`kern/i386/tsc_pmtimer.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/random_module-tsc_pmtimer.Tpo kern/i386/$(DEPDIR)/random_module-tsc_pmtimer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/tsc_pmtimer.c' object='kern/i386/random_module-tsc_pmtimer.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -c -o kern/i386/random_module-tsc_pmtimer.o `test -f 'kern/i386/tsc_pmtimer.c' || echo '$(srcdir)/'`kern/i386/tsc_pmtimer.c
+
+kern/i386/random_module-tsc_pmtimer.obj: kern/i386/tsc_pmtimer.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -MT kern/i386/random_module-tsc_pmtimer.obj -MD -MP -MF kern/i386/$(DEPDIR)/random_module-tsc_pmtimer.Tpo -c -o kern/i386/random_module-tsc_pmtimer.obj `if test -f 'kern/i386/tsc_pmtimer.c'; then $(CYGPATH_W) 'kern/i386/tsc_pmtimer.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/tsc_pmtimer.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/i386/$(DEPDIR)/random_module-tsc_pmtimer.Tpo kern/i386/$(DEPDIR)/random_module-tsc_pmtimer.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/i386/tsc_pmtimer.c' object='kern/i386/random_module-tsc_pmtimer.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -c -o kern/i386/random_module-tsc_pmtimer.obj `if test -f 'kern/i386/tsc_pmtimer.c'; then $(CYGPATH_W) 'kern/i386/tsc_pmtimer.c'; else $(CYGPATH_W) '$(srcdir)/kern/i386/tsc_pmtimer.c'; fi`
+
+lib/i386/random_module-random.o: lib/i386/random.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -MT lib/i386/random_module-random.o -MD -MP -MF lib/i386/$(DEPDIR)/random_module-random.Tpo -c -o lib/i386/random_module-random.o `test -f 'lib/i386/random.c' || echo '$(srcdir)/'`lib/i386/random.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/random_module-random.Tpo lib/i386/$(DEPDIR)/random_module-random.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/random.c' object='lib/i386/random_module-random.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -c -o lib/i386/random_module-random.o `test -f 'lib/i386/random.c' || echo '$(srcdir)/'`lib/i386/random.c
+
+lib/i386/random_module-random.obj: lib/i386/random.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -MT lib/i386/random_module-random.obj -MD -MP -MF lib/i386/$(DEPDIR)/random_module-random.Tpo -c -o lib/i386/random_module-random.obj `if test -f 'lib/i386/random.c'; then $(CYGPATH_W) 'lib/i386/random.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/random.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/random_module-random.Tpo lib/i386/$(DEPDIR)/random_module-random.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/random.c' object='lib/i386/random_module-random.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -c -o lib/i386/random_module-random.obj `if test -f 'lib/i386/random.c'; then $(CYGPATH_W) 'lib/i386/random.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/random.c'; fi`
+
+lib/random_module-random.o: lib/random.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -MT lib/random_module-random.o -MD -MP -MF lib/$(DEPDIR)/random_module-random.Tpo -c -o lib/random_module-random.o `test -f 'lib/random.c' || echo '$(srcdir)/'`lib/random.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/random_module-random.Tpo lib/$(DEPDIR)/random_module-random.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/random.c' object='lib/random_module-random.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -c -o lib/random_module-random.o `test -f 'lib/random.c' || echo '$(srcdir)/'`lib/random.c
+
+lib/random_module-random.obj: lib/random.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -MT lib/random_module-random.obj -MD -MP -MF lib/$(DEPDIR)/random_module-random.Tpo -c -o lib/random_module-random.obj `if test -f 'lib/random.c'; then $(CYGPATH_W) 'lib/random.c'; else $(CYGPATH_W) '$(srcdir)/lib/random.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/random_module-random.Tpo lib/$(DEPDIR)/random_module-random.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/random.c' object='lib/random_module-random.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $(random_module_CFLAGS) $(CFLAGS) -c -o lib/random_module-random.obj `if test -f 'lib/random.c'; then $(CYGPATH_W) 'lib/random.c'; else $(CYGPATH_W) '$(srcdir)/lib/random.c'; fi`
+
+commands/i386/rdmsr_module-rdmsr.o: commands/i386/rdmsr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $(rdmsr_module_CFLAGS) $(CFLAGS) -MT commands/i386/rdmsr_module-rdmsr.o -MD -MP -MF commands/i386/$(DEPDIR)/rdmsr_module-rdmsr.Tpo -c -o commands/i386/rdmsr_module-rdmsr.o `test -f 'commands/i386/rdmsr.c' || echo '$(srcdir)/'`commands/i386/rdmsr.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/$(DEPDIR)/rdmsr_module-rdmsr.Tpo commands/i386/$(DEPDIR)/rdmsr_module-rdmsr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/rdmsr.c' object='commands/i386/rdmsr_module-rdmsr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $(rdmsr_module_CFLAGS) $(CFLAGS) -c -o commands/i386/rdmsr_module-rdmsr.o `test -f 'commands/i386/rdmsr.c' || echo '$(srcdir)/'`commands/i386/rdmsr.c
+
+commands/i386/rdmsr_module-rdmsr.obj: commands/i386/rdmsr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $(rdmsr_module_CFLAGS) $(CFLAGS) -MT commands/i386/rdmsr_module-rdmsr.obj -MD -MP -MF commands/i386/$(DEPDIR)/rdmsr_module-rdmsr.Tpo -c -o commands/i386/rdmsr_module-rdmsr.obj `if test -f 'commands/i386/rdmsr.c'; then $(CYGPATH_W) 'commands/i386/rdmsr.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/rdmsr.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/$(DEPDIR)/rdmsr_module-rdmsr.Tpo commands/i386/$(DEPDIR)/rdmsr_module-rdmsr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/rdmsr.c' object='commands/i386/rdmsr_module-rdmsr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $(rdmsr_module_CFLAGS) $(CFLAGS) -c -o commands/i386/rdmsr_module-rdmsr.obj `if test -f 'commands/i386/rdmsr.c'; then $(CYGPATH_W) 'commands/i386/rdmsr.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/rdmsr.c'; fi`
+
+commands/read_module-read.o: commands/read.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(read_module_CPPFLAGS) $(CPPFLAGS) $(read_module_CFLAGS) $(CFLAGS) -MT commands/read_module-read.o -MD -MP -MF commands/$(DEPDIR)/read_module-read.Tpo -c -o commands/read_module-read.o `test -f 'commands/read.c' || echo '$(srcdir)/'`commands/read.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/read_module-read.Tpo commands/$(DEPDIR)/read_module-read.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/read.c' object='commands/read_module-read.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(read_module_CPPFLAGS) $(CPPFLAGS) $(read_module_CFLAGS) $(CFLAGS) -c -o commands/read_module-read.o `test -f 'commands/read.c' || echo '$(srcdir)/'`commands/read.c
+
+commands/read_module-read.obj: commands/read.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(read_module_CPPFLAGS) $(CPPFLAGS) $(read_module_CFLAGS) $(CFLAGS) -MT commands/read_module-read.obj -MD -MP -MF commands/$(DEPDIR)/read_module-read.Tpo -c -o commands/read_module-read.obj `if test -f 'commands/read.c'; then $(CYGPATH_W) 'commands/read.c'; else $(CYGPATH_W) '$(srcdir)/commands/read.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/read_module-read.Tpo commands/$(DEPDIR)/read_module-read.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/read.c' object='commands/read_module-read.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(read_module_CPPFLAGS) $(CPPFLAGS) $(read_module_CFLAGS) $(CFLAGS) -c -o commands/read_module-read.obj `if test -f 'commands/read.c'; then $(CYGPATH_W) 'commands/read.c'; else $(CYGPATH_W) '$(srcdir)/commands/read.c'; fi`
+
+commands/reboot_module-reboot.o: commands/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT commands/reboot_module-reboot.o -MD -MP -MF commands/$(DEPDIR)/reboot_module-reboot.Tpo -c -o commands/reboot_module-reboot.o `test -f 'commands/reboot.c' || echo '$(srcdir)/'`commands/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/reboot_module-reboot.Tpo commands/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/reboot.c' object='commands/reboot_module-reboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o commands/reboot_module-reboot.o `test -f 'commands/reboot.c' || echo '$(srcdir)/'`commands/reboot.c
+
+commands/reboot_module-reboot.obj: commands/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT commands/reboot_module-reboot.obj -MD -MP -MF commands/$(DEPDIR)/reboot_module-reboot.Tpo -c -o commands/reboot_module-reboot.obj `if test -f 'commands/reboot.c'; then $(CYGPATH_W) 'commands/reboot.c'; else $(CYGPATH_W) '$(srcdir)/commands/reboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/reboot_module-reboot.Tpo commands/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/reboot.c' object='commands/reboot_module-reboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o commands/reboot_module-reboot.obj `if test -f 'commands/reboot.c'; then $(CYGPATH_W) 'commands/reboot.c'; else $(CYGPATH_W) '$(srcdir)/commands/reboot.c'; fi`
+
+lib/dummy/reboot_module-reboot.o: lib/dummy/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/dummy/reboot_module-reboot.o -MD -MP -MF lib/dummy/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/dummy/reboot_module-reboot.o `test -f 'lib/dummy/reboot.c' || echo '$(srcdir)/'`lib/dummy/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/dummy/$(DEPDIR)/reboot_module-reboot.Tpo lib/dummy/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/dummy/reboot.c' object='lib/dummy/reboot_module-reboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/dummy/reboot_module-reboot.o `test -f 'lib/dummy/reboot.c' || echo '$(srcdir)/'`lib/dummy/reboot.c
+
+lib/dummy/reboot_module-reboot.obj: lib/dummy/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/dummy/reboot_module-reboot.obj -MD -MP -MF lib/dummy/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/dummy/reboot_module-reboot.obj `if test -f 'lib/dummy/reboot.c'; then $(CYGPATH_W) 'lib/dummy/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/dummy/reboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/dummy/$(DEPDIR)/reboot_module-reboot.Tpo lib/dummy/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/dummy/reboot.c' object='lib/dummy/reboot_module-reboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/dummy/reboot_module-reboot.obj `if test -f 'lib/dummy/reboot.c'; then $(CYGPATH_W) 'lib/dummy/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/dummy/reboot.c'; fi`
+
+lib/uboot/reboot_module-reboot.o: lib/uboot/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/uboot/reboot_module-reboot.o -MD -MP -MF lib/uboot/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/uboot/reboot_module-reboot.o `test -f 'lib/uboot/reboot.c' || echo '$(srcdir)/'`lib/uboot/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/uboot/$(DEPDIR)/reboot_module-reboot.Tpo lib/uboot/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/uboot/reboot.c' object='lib/uboot/reboot_module-reboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/uboot/reboot_module-reboot.o `test -f 'lib/uboot/reboot.c' || echo '$(srcdir)/'`lib/uboot/reboot.c
+
+lib/uboot/reboot_module-reboot.obj: lib/uboot/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/uboot/reboot_module-reboot.obj -MD -MP -MF lib/uboot/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/uboot/reboot_module-reboot.obj `if test -f 'lib/uboot/reboot.c'; then $(CYGPATH_W) 'lib/uboot/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/uboot/reboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/uboot/$(DEPDIR)/reboot_module-reboot.Tpo lib/uboot/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/uboot/reboot.c' object='lib/uboot/reboot_module-reboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/uboot/reboot_module-reboot.obj `if test -f 'lib/uboot/reboot.c'; then $(CYGPATH_W) 'lib/uboot/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/uboot/reboot.c'; fi`
+
+lib/i386/reboot_module-reboot.o: lib/i386/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/i386/reboot_module-reboot.o -MD -MP -MF lib/i386/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/i386/reboot_module-reboot.o `test -f 'lib/i386/reboot.c' || echo '$(srcdir)/'`lib/i386/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/reboot_module-reboot.Tpo lib/i386/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/reboot.c' object='lib/i386/reboot_module-reboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/i386/reboot_module-reboot.o `test -f 'lib/i386/reboot.c' || echo '$(srcdir)/'`lib/i386/reboot.c
+
+lib/i386/reboot_module-reboot.obj: lib/i386/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/i386/reboot_module-reboot.obj -MD -MP -MF lib/i386/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/i386/reboot_module-reboot.obj `if test -f 'lib/i386/reboot.c'; then $(CYGPATH_W) 'lib/i386/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/reboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/reboot_module-reboot.Tpo lib/i386/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/reboot.c' object='lib/i386/reboot_module-reboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/i386/reboot_module-reboot.obj `if test -f 'lib/i386/reboot.c'; then $(CYGPATH_W) 'lib/i386/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/reboot.c'; fi`
+
+lib/xen/reboot_module-reboot.o: lib/xen/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/xen/reboot_module-reboot.o -MD -MP -MF lib/xen/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/xen/reboot_module-reboot.o `test -f 'lib/xen/reboot.c' || echo '$(srcdir)/'`lib/xen/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xen/$(DEPDIR)/reboot_module-reboot.Tpo lib/xen/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xen/reboot.c' object='lib/xen/reboot_module-reboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/xen/reboot_module-reboot.o `test -f 'lib/xen/reboot.c' || echo '$(srcdir)/'`lib/xen/reboot.c
+
+lib/xen/reboot_module-reboot.obj: lib/xen/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/xen/reboot_module-reboot.obj -MD -MP -MF lib/xen/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/xen/reboot_module-reboot.obj `if test -f 'lib/xen/reboot.c'; then $(CYGPATH_W) 'lib/xen/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/xen/reboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xen/$(DEPDIR)/reboot_module-reboot.Tpo lib/xen/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xen/reboot.c' object='lib/xen/reboot_module-reboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/xen/reboot_module-reboot.obj `if test -f 'lib/xen/reboot.c'; then $(CYGPATH_W) 'lib/xen/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/xen/reboot.c'; fi`
+
+lib/mips/arc/reboot_module-reboot.o: lib/mips/arc/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/mips/arc/reboot_module-reboot.o -MD -MP -MF lib/mips/arc/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/mips/arc/reboot_module-reboot.o `test -f 'lib/mips/arc/reboot.c' || echo '$(srcdir)/'`lib/mips/arc/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/mips/arc/$(DEPDIR)/reboot_module-reboot.Tpo lib/mips/arc/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/mips/arc/reboot.c' object='lib/mips/arc/reboot_module-reboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/mips/arc/reboot_module-reboot.o `test -f 'lib/mips/arc/reboot.c' || echo '$(srcdir)/'`lib/mips/arc/reboot.c
+
+lib/mips/arc/reboot_module-reboot.obj: lib/mips/arc/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/mips/arc/reboot_module-reboot.obj -MD -MP -MF lib/mips/arc/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/mips/arc/reboot_module-reboot.obj `if test -f 'lib/mips/arc/reboot.c'; then $(CYGPATH_W) 'lib/mips/arc/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/mips/arc/reboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/mips/arc/$(DEPDIR)/reboot_module-reboot.Tpo lib/mips/arc/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/mips/arc/reboot.c' object='lib/mips/arc/reboot_module-reboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/mips/arc/reboot_module-reboot.obj `if test -f 'lib/mips/arc/reboot.c'; then $(CYGPATH_W) 'lib/mips/arc/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/mips/arc/reboot.c'; fi`
+
+lib/mips/loongson/reboot_module-reboot.o: lib/mips/loongson/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/mips/loongson/reboot_module-reboot.o -MD -MP -MF lib/mips/loongson/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/mips/loongson/reboot_module-reboot.o `test -f 'lib/mips/loongson/reboot.c' || echo '$(srcdir)/'`lib/mips/loongson/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/mips/loongson/$(DEPDIR)/reboot_module-reboot.Tpo lib/mips/loongson/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/mips/loongson/reboot.c' object='lib/mips/loongson/reboot_module-reboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/mips/loongson/reboot_module-reboot.o `test -f 'lib/mips/loongson/reboot.c' || echo '$(srcdir)/'`lib/mips/loongson/reboot.c
+
+lib/mips/loongson/reboot_module-reboot.obj: lib/mips/loongson/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/mips/loongson/reboot_module-reboot.obj -MD -MP -MF lib/mips/loongson/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/mips/loongson/reboot_module-reboot.obj `if test -f 'lib/mips/loongson/reboot.c'; then $(CYGPATH_W) 'lib/mips/loongson/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/mips/loongson/reboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/mips/loongson/$(DEPDIR)/reboot_module-reboot.Tpo lib/mips/loongson/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/mips/loongson/reboot.c' object='lib/mips/loongson/reboot_module-reboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/mips/loongson/reboot_module-reboot.obj `if test -f 'lib/mips/loongson/reboot.c'; then $(CYGPATH_W) 'lib/mips/loongson/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/mips/loongson/reboot.c'; fi`
+
+lib/mips/qemu_mips/reboot_module-reboot.o: lib/mips/qemu_mips/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/mips/qemu_mips/reboot_module-reboot.o -MD -MP -MF lib/mips/qemu_mips/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/mips/qemu_mips/reboot_module-reboot.o `test -f 'lib/mips/qemu_mips/reboot.c' || echo '$(srcdir)/'`lib/mips/qemu_mips/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/mips/qemu_mips/$(DEPDIR)/reboot_module-reboot.Tpo lib/mips/qemu_mips/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/mips/qemu_mips/reboot.c' object='lib/mips/qemu_mips/reboot_module-reboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/mips/qemu_mips/reboot_module-reboot.o `test -f 'lib/mips/qemu_mips/reboot.c' || echo '$(srcdir)/'`lib/mips/qemu_mips/reboot.c
+
+lib/mips/qemu_mips/reboot_module-reboot.obj: lib/mips/qemu_mips/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/mips/qemu_mips/reboot_module-reboot.obj -MD -MP -MF lib/mips/qemu_mips/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/mips/qemu_mips/reboot_module-reboot.obj `if test -f 'lib/mips/qemu_mips/reboot.c'; then $(CYGPATH_W) 'lib/mips/qemu_mips/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/mips/qemu_mips/reboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/mips/qemu_mips/$(DEPDIR)/reboot_module-reboot.Tpo lib/mips/qemu_mips/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/mips/qemu_mips/reboot.c' object='lib/mips/qemu_mips/reboot_module-reboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/mips/qemu_mips/reboot_module-reboot.obj `if test -f 'lib/mips/qemu_mips/reboot.c'; then $(CYGPATH_W) 'lib/mips/qemu_mips/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/mips/qemu_mips/reboot.c'; fi`
+
+lib/ieee1275/reboot_module-reboot.o: lib/ieee1275/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/ieee1275/reboot_module-reboot.o -MD -MP -MF lib/ieee1275/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/ieee1275/reboot_module-reboot.o `test -f 'lib/ieee1275/reboot.c' || echo '$(srcdir)/'`lib/ieee1275/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/ieee1275/$(DEPDIR)/reboot_module-reboot.Tpo lib/ieee1275/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/ieee1275/reboot.c' object='lib/ieee1275/reboot_module-reboot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/ieee1275/reboot_module-reboot.o `test -f 'lib/ieee1275/reboot.c' || echo '$(srcdir)/'`lib/ieee1275/reboot.c
+
+lib/ieee1275/reboot_module-reboot.obj: lib/ieee1275/reboot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -MT lib/ieee1275/reboot_module-reboot.obj -MD -MP -MF lib/ieee1275/$(DEPDIR)/reboot_module-reboot.Tpo -c -o lib/ieee1275/reboot_module-reboot.obj `if test -f 'lib/ieee1275/reboot.c'; then $(CYGPATH_W) 'lib/ieee1275/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/ieee1275/reboot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/ieee1275/$(DEPDIR)/reboot_module-reboot.Tpo lib/ieee1275/$(DEPDIR)/reboot_module-reboot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/ieee1275/reboot.c' object='lib/ieee1275/reboot_module-reboot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $(reboot_module_CFLAGS) $(CFLAGS) -c -o lib/ieee1275/reboot_module-reboot.obj `if test -f 'lib/ieee1275/reboot.c'; then $(CYGPATH_W) 'lib/ieee1275/reboot.c'; else $(CYGPATH_W) '$(srcdir)/lib/ieee1275/reboot.c'; fi`
+
+commands/regexp_module-regexp.o: commands/regexp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -MT commands/regexp_module-regexp.o -MD -MP -MF commands/$(DEPDIR)/regexp_module-regexp.Tpo -c -o commands/regexp_module-regexp.o `test -f 'commands/regexp.c' || echo '$(srcdir)/'`commands/regexp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/regexp_module-regexp.Tpo commands/$(DEPDIR)/regexp_module-regexp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/regexp.c' object='commands/regexp_module-regexp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -c -o commands/regexp_module-regexp.o `test -f 'commands/regexp.c' || echo '$(srcdir)/'`commands/regexp.c
+
+commands/regexp_module-regexp.obj: commands/regexp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -MT commands/regexp_module-regexp.obj -MD -MP -MF commands/$(DEPDIR)/regexp_module-regexp.Tpo -c -o commands/regexp_module-regexp.obj `if test -f 'commands/regexp.c'; then $(CYGPATH_W) 'commands/regexp.c'; else $(CYGPATH_W) '$(srcdir)/commands/regexp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/regexp_module-regexp.Tpo commands/$(DEPDIR)/regexp_module-regexp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/regexp.c' object='commands/regexp_module-regexp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -c -o commands/regexp_module-regexp.obj `if test -f 'commands/regexp.c'; then $(CYGPATH_W) 'commands/regexp.c'; else $(CYGPATH_W) '$(srcdir)/commands/regexp.c'; fi`
+
+commands/regexp_module-wildcard.o: commands/wildcard.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -MT commands/regexp_module-wildcard.o -MD -MP -MF commands/$(DEPDIR)/regexp_module-wildcard.Tpo -c -o commands/regexp_module-wildcard.o `test -f 'commands/wildcard.c' || echo '$(srcdir)/'`commands/wildcard.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/regexp_module-wildcard.Tpo commands/$(DEPDIR)/regexp_module-wildcard.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/wildcard.c' object='commands/regexp_module-wildcard.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -c -o commands/regexp_module-wildcard.o `test -f 'commands/wildcard.c' || echo '$(srcdir)/'`commands/wildcard.c
+
+commands/regexp_module-wildcard.obj: commands/wildcard.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -MT commands/regexp_module-wildcard.obj -MD -MP -MF commands/$(DEPDIR)/regexp_module-wildcard.Tpo -c -o commands/regexp_module-wildcard.obj `if test -f 'commands/wildcard.c'; then $(CYGPATH_W) 'commands/wildcard.c'; else $(CYGPATH_W) '$(srcdir)/commands/wildcard.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/regexp_module-wildcard.Tpo commands/$(DEPDIR)/regexp_module-wildcard.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/wildcard.c' object='commands/regexp_module-wildcard.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -c -o commands/regexp_module-wildcard.obj `if test -f 'commands/wildcard.c'; then $(CYGPATH_W) 'commands/wildcard.c'; else $(CYGPATH_W) '$(srcdir)/commands/wildcard.c'; fi`
+
+lib/gnulib/regexp_module-regex.o: lib/gnulib/regex.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -MT lib/gnulib/regexp_module-regex.o -MD -MP -MF lib/gnulib/$(DEPDIR)/regexp_module-regex.Tpo -c -o lib/gnulib/regexp_module-regex.o `test -f 'lib/gnulib/regex.c' || echo '$(srcdir)/'`lib/gnulib/regex.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/gnulib/$(DEPDIR)/regexp_module-regex.Tpo lib/gnulib/$(DEPDIR)/regexp_module-regex.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/gnulib/regex.c' object='lib/gnulib/regexp_module-regex.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -c -o lib/gnulib/regexp_module-regex.o `test -f 'lib/gnulib/regex.c' || echo '$(srcdir)/'`lib/gnulib/regex.c
+
+lib/gnulib/regexp_module-regex.obj: lib/gnulib/regex.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -MT lib/gnulib/regexp_module-regex.obj -MD -MP -MF lib/gnulib/$(DEPDIR)/regexp_module-regex.Tpo -c -o lib/gnulib/regexp_module-regex.obj `if test -f 'lib/gnulib/regex.c'; then $(CYGPATH_W) 'lib/gnulib/regex.c'; else $(CYGPATH_W) '$(srcdir)/lib/gnulib/regex.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/gnulib/$(DEPDIR)/regexp_module-regex.Tpo lib/gnulib/$(DEPDIR)/regexp_module-regex.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/gnulib/regex.c' object='lib/gnulib/regexp_module-regex.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $(regexp_module_CFLAGS) $(CFLAGS) -c -o lib/gnulib/regexp_module-regex.obj `if test -f 'lib/gnulib/regex.c'; then $(CYGPATH_W) 'lib/gnulib/regex.c'; else $(CYGPATH_W) '$(srcdir)/lib/gnulib/regex.c'; fi`
+
+fs/reiserfs_module-reiserfs.o: fs/reiserfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reiserfs_module_CPPFLAGS) $(CPPFLAGS) $(reiserfs_module_CFLAGS) $(CFLAGS) -MT fs/reiserfs_module-reiserfs.o -MD -MP -MF fs/$(DEPDIR)/reiserfs_module-reiserfs.Tpo -c -o fs/reiserfs_module-reiserfs.o `test -f 'fs/reiserfs.c' || echo '$(srcdir)/'`fs/reiserfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/reiserfs_module-reiserfs.Tpo fs/$(DEPDIR)/reiserfs_module-reiserfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/reiserfs.c' object='fs/reiserfs_module-reiserfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reiserfs_module_CPPFLAGS) $(CPPFLAGS) $(reiserfs_module_CFLAGS) $(CFLAGS) -c -o fs/reiserfs_module-reiserfs.o `test -f 'fs/reiserfs.c' || echo '$(srcdir)/'`fs/reiserfs.c
+
+fs/reiserfs_module-reiserfs.obj: fs/reiserfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reiserfs_module_CPPFLAGS) $(CPPFLAGS) $(reiserfs_module_CFLAGS) $(CFLAGS) -MT fs/reiserfs_module-reiserfs.obj -MD -MP -MF fs/$(DEPDIR)/reiserfs_module-reiserfs.Tpo -c -o fs/reiserfs_module-reiserfs.obj `if test -f 'fs/reiserfs.c'; then $(CYGPATH_W) 'fs/reiserfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/reiserfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/reiserfs_module-reiserfs.Tpo fs/$(DEPDIR)/reiserfs_module-reiserfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/reiserfs.c' object='fs/reiserfs_module-reiserfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reiserfs_module_CPPFLAGS) $(CPPFLAGS) $(reiserfs_module_CFLAGS) $(CFLAGS) -c -o fs/reiserfs_module-reiserfs.obj `if test -f 'fs/reiserfs.c'; then $(CYGPATH_W) 'fs/reiserfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/reiserfs.c'; fi`
+
+lib/i386/relocator_module-relocator.o: lib/i386/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/i386/relocator_module-relocator.o -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/i386/relocator_module-relocator.o `test -f 'lib/i386/relocator.c' || echo '$(srcdir)/'`lib/i386/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/relocator.c' object='lib/i386/relocator_module-relocator.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/i386/relocator_module-relocator.o `test -f 'lib/i386/relocator.c' || echo '$(srcdir)/'`lib/i386/relocator.c
+
+lib/i386/relocator_module-relocator.obj: lib/i386/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/i386/relocator_module-relocator.obj -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/i386/relocator_module-relocator.obj `if test -f 'lib/i386/relocator.c'; then $(CYGPATH_W) 'lib/i386/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/relocator.c' object='lib/i386/relocator_module-relocator.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/i386/relocator_module-relocator.obj `if test -f 'lib/i386/relocator.c'; then $(CYGPATH_W) 'lib/i386/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator.c'; fi`
+
+lib/i386/relocator_module-relocator_common_c.o: lib/i386/relocator_common_c.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/i386/relocator_module-relocator_common_c.o -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator_common_c.Tpo -c -o lib/i386/relocator_module-relocator_common_c.o `test -f 'lib/i386/relocator_common_c.c' || echo '$(srcdir)/'`lib/i386/relocator_common_c.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator_common_c.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator_common_c.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/relocator_common_c.c' object='lib/i386/relocator_module-relocator_common_c.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/i386/relocator_module-relocator_common_c.o `test -f 'lib/i386/relocator_common_c.c' || echo '$(srcdir)/'`lib/i386/relocator_common_c.c
+
+lib/i386/relocator_module-relocator_common_c.obj: lib/i386/relocator_common_c.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/i386/relocator_module-relocator_common_c.obj -MD -MP -MF lib/i386/$(DEPDIR)/relocator_module-relocator_common_c.Tpo -c -o lib/i386/relocator_module-relocator_common_c.obj `if test -f 'lib/i386/relocator_common_c.c'; then $(CYGPATH_W) 'lib/i386/relocator_common_c.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator_common_c.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/i386/$(DEPDIR)/relocator_module-relocator_common_c.Tpo lib/i386/$(DEPDIR)/relocator_module-relocator_common_c.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/i386/relocator_common_c.c' object='lib/i386/relocator_module-relocator_common_c.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/i386/relocator_module-relocator_common_c.obj `if test -f 'lib/i386/relocator_common_c.c'; then $(CYGPATH_W) 'lib/i386/relocator_common_c.c'; else $(CYGPATH_W) '$(srcdir)/lib/i386/relocator_common_c.c'; fi`
+
+lib/relocator_module-relocator.o: lib/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/relocator_module-relocator.o -MD -MP -MF lib/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/relocator_module-relocator.o `test -f 'lib/relocator.c' || echo '$(srcdir)/'`lib/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/relocator_module-relocator.Tpo lib/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/relocator.c' object='lib/relocator_module-relocator.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/relocator_module-relocator.o `test -f 'lib/relocator.c' || echo '$(srcdir)/'`lib/relocator.c
+
+lib/relocator_module-relocator.obj: lib/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/relocator_module-relocator.obj -MD -MP -MF lib/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/relocator_module-relocator.obj `if test -f 'lib/relocator.c'; then $(CYGPATH_W) 'lib/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/relocator.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/relocator_module-relocator.Tpo lib/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/relocator.c' object='lib/relocator_module-relocator.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/relocator_module-relocator.obj `if test -f 'lib/relocator.c'; then $(CYGPATH_W) 'lib/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/relocator.c'; fi`
+
+lib/efi/relocator_module-relocator.o: lib/efi/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/efi/relocator_module-relocator.o -MD -MP -MF lib/efi/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/efi/relocator_module-relocator.o `test -f 'lib/efi/relocator.c' || echo '$(srcdir)/'`lib/efi/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/efi/$(DEPDIR)/relocator_module-relocator.Tpo lib/efi/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/efi/relocator.c' object='lib/efi/relocator_module-relocator.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/efi/relocator_module-relocator.o `test -f 'lib/efi/relocator.c' || echo '$(srcdir)/'`lib/efi/relocator.c
+
+lib/efi/relocator_module-relocator.obj: lib/efi/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/efi/relocator_module-relocator.obj -MD -MP -MF lib/efi/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/efi/relocator_module-relocator.obj `if test -f 'lib/efi/relocator.c'; then $(CYGPATH_W) 'lib/efi/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/efi/relocator.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/efi/$(DEPDIR)/relocator_module-relocator.Tpo lib/efi/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/efi/relocator.c' object='lib/efi/relocator_module-relocator.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/efi/relocator_module-relocator.obj `if test -f 'lib/efi/relocator.c'; then $(CYGPATH_W) 'lib/efi/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/efi/relocator.c'; fi`
+
+lib/ieee1275/relocator_module-relocator.o: lib/ieee1275/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/ieee1275/relocator_module-relocator.o -MD -MP -MF lib/ieee1275/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/ieee1275/relocator_module-relocator.o `test -f 'lib/ieee1275/relocator.c' || echo '$(srcdir)/'`lib/ieee1275/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/ieee1275/$(DEPDIR)/relocator_module-relocator.Tpo lib/ieee1275/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/ieee1275/relocator.c' object='lib/ieee1275/relocator_module-relocator.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/ieee1275/relocator_module-relocator.o `test -f 'lib/ieee1275/relocator.c' || echo '$(srcdir)/'`lib/ieee1275/relocator.c
+
+lib/ieee1275/relocator_module-relocator.obj: lib/ieee1275/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/ieee1275/relocator_module-relocator.obj -MD -MP -MF lib/ieee1275/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/ieee1275/relocator_module-relocator.obj `if test -f 'lib/ieee1275/relocator.c'; then $(CYGPATH_W) 'lib/ieee1275/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/ieee1275/relocator.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/ieee1275/$(DEPDIR)/relocator_module-relocator.Tpo lib/ieee1275/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/ieee1275/relocator.c' object='lib/ieee1275/relocator_module-relocator.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/ieee1275/relocator_module-relocator.obj `if test -f 'lib/ieee1275/relocator.c'; then $(CYGPATH_W) 'lib/ieee1275/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/ieee1275/relocator.c'; fi`
+
+lib/xen/relocator_module-relocator.o: lib/xen/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/xen/relocator_module-relocator.o -MD -MP -MF lib/xen/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/xen/relocator_module-relocator.o `test -f 'lib/xen/relocator.c' || echo '$(srcdir)/'`lib/xen/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xen/$(DEPDIR)/relocator_module-relocator.Tpo lib/xen/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xen/relocator.c' object='lib/xen/relocator_module-relocator.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/xen/relocator_module-relocator.o `test -f 'lib/xen/relocator.c' || echo '$(srcdir)/'`lib/xen/relocator.c
+
+lib/xen/relocator_module-relocator.obj: lib/xen/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/xen/relocator_module-relocator.obj -MD -MP -MF lib/xen/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/xen/relocator_module-relocator.obj `if test -f 'lib/xen/relocator.c'; then $(CYGPATH_W) 'lib/xen/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/xen/relocator.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xen/$(DEPDIR)/relocator_module-relocator.Tpo lib/xen/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xen/relocator.c' object='lib/xen/relocator_module-relocator.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/xen/relocator_module-relocator.obj `if test -f 'lib/xen/relocator.c'; then $(CYGPATH_W) 'lib/xen/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/xen/relocator.c'; fi`
+
+lib/mips/relocator_module-relocator.o: lib/mips/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/mips/relocator_module-relocator.o -MD -MP -MF lib/mips/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/mips/relocator_module-relocator.o `test -f 'lib/mips/relocator.c' || echo '$(srcdir)/'`lib/mips/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/mips/$(DEPDIR)/relocator_module-relocator.Tpo lib/mips/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/mips/relocator.c' object='lib/mips/relocator_module-relocator.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/mips/relocator_module-relocator.o `test -f 'lib/mips/relocator.c' || echo '$(srcdir)/'`lib/mips/relocator.c
+
+lib/mips/relocator_module-relocator.obj: lib/mips/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/mips/relocator_module-relocator.obj -MD -MP -MF lib/mips/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/mips/relocator_module-relocator.obj `if test -f 'lib/mips/relocator.c'; then $(CYGPATH_W) 'lib/mips/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/mips/relocator.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/mips/$(DEPDIR)/relocator_module-relocator.Tpo lib/mips/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/mips/relocator.c' object='lib/mips/relocator_module-relocator.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/mips/relocator_module-relocator.obj `if test -f 'lib/mips/relocator.c'; then $(CYGPATH_W) 'lib/mips/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/mips/relocator.c'; fi`
+
+lib/powerpc/relocator_module-relocator.o: lib/powerpc/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/powerpc/relocator_module-relocator.o -MD -MP -MF lib/powerpc/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/powerpc/relocator_module-relocator.o `test -f 'lib/powerpc/relocator.c' || echo '$(srcdir)/'`lib/powerpc/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/powerpc/$(DEPDIR)/relocator_module-relocator.Tpo lib/powerpc/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/powerpc/relocator.c' object='lib/powerpc/relocator_module-relocator.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/powerpc/relocator_module-relocator.o `test -f 'lib/powerpc/relocator.c' || echo '$(srcdir)/'`lib/powerpc/relocator.c
+
+lib/powerpc/relocator_module-relocator.obj: lib/powerpc/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/powerpc/relocator_module-relocator.obj -MD -MP -MF lib/powerpc/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/powerpc/relocator_module-relocator.obj `if test -f 'lib/powerpc/relocator.c'; then $(CYGPATH_W) 'lib/powerpc/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/powerpc/relocator.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/powerpc/$(DEPDIR)/relocator_module-relocator.Tpo lib/powerpc/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/powerpc/relocator.c' object='lib/powerpc/relocator_module-relocator.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/powerpc/relocator_module-relocator.obj `if test -f 'lib/powerpc/relocator.c'; then $(CYGPATH_W) 'lib/powerpc/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/powerpc/relocator.c'; fi`
+
+lib/x86_64/efi/relocator_module-relocator.o: lib/x86_64/efi/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/x86_64/efi/relocator_module-relocator.o -MD -MP -MF lib/x86_64/efi/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/x86_64/efi/relocator_module-relocator.o `test -f 'lib/x86_64/efi/relocator.c' || echo '$(srcdir)/'`lib/x86_64/efi/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/x86_64/efi/$(DEPDIR)/relocator_module-relocator.Tpo lib/x86_64/efi/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/x86_64/efi/relocator.c' object='lib/x86_64/efi/relocator_module-relocator.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/x86_64/efi/relocator_module-relocator.o `test -f 'lib/x86_64/efi/relocator.c' || echo '$(srcdir)/'`lib/x86_64/efi/relocator.c
+
+lib/x86_64/efi/relocator_module-relocator.obj: lib/x86_64/efi/relocator.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -MT lib/x86_64/efi/relocator_module-relocator.obj -MD -MP -MF lib/x86_64/efi/$(DEPDIR)/relocator_module-relocator.Tpo -c -o lib/x86_64/efi/relocator_module-relocator.obj `if test -f 'lib/x86_64/efi/relocator.c'; then $(CYGPATH_W) 'lib/x86_64/efi/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/x86_64/efi/relocator.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/x86_64/efi/$(DEPDIR)/relocator_module-relocator.Tpo lib/x86_64/efi/$(DEPDIR)/relocator_module-relocator.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/x86_64/efi/relocator.c' object='lib/x86_64/efi/relocator_module-relocator.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $(relocator_module_CFLAGS) $(CFLAGS) -c -o lib/x86_64/efi/relocator_module-relocator.obj `if test -f 'lib/x86_64/efi/relocator.c'; then $(CYGPATH_W) 'lib/x86_64/efi/relocator.c'; else $(CYGPATH_W) '$(srcdir)/lib/x86_64/efi/relocator.c'; fi`
+
+fs/romfs_module-romfs.o: fs/romfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(romfs_module_CPPFLAGS) $(CPPFLAGS) $(romfs_module_CFLAGS) $(CFLAGS) -MT fs/romfs_module-romfs.o -MD -MP -MF fs/$(DEPDIR)/romfs_module-romfs.Tpo -c -o fs/romfs_module-romfs.o `test -f 'fs/romfs.c' || echo '$(srcdir)/'`fs/romfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/romfs_module-romfs.Tpo fs/$(DEPDIR)/romfs_module-romfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/romfs.c' object='fs/romfs_module-romfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(romfs_module_CPPFLAGS) $(CPPFLAGS) $(romfs_module_CFLAGS) $(CFLAGS) -c -o fs/romfs_module-romfs.o `test -f 'fs/romfs.c' || echo '$(srcdir)/'`fs/romfs.c
+
+fs/romfs_module-romfs.obj: fs/romfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(romfs_module_CPPFLAGS) $(CPPFLAGS) $(romfs_module_CFLAGS) $(CFLAGS) -MT fs/romfs_module-romfs.obj -MD -MP -MF fs/$(DEPDIR)/romfs_module-romfs.Tpo -c -o fs/romfs_module-romfs.obj `if test -f 'fs/romfs.c'; then $(CYGPATH_W) 'fs/romfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/romfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/romfs_module-romfs.Tpo fs/$(DEPDIR)/romfs_module-romfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/romfs.c' object='fs/romfs_module-romfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(romfs_module_CPPFLAGS) $(CPPFLAGS) $(romfs_module_CFLAGS) $(CFLAGS) -c -o fs/romfs_module-romfs.obj `if test -f 'fs/romfs.c'; then $(CYGPATH_W) 'fs/romfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/romfs.c'; fi`
+
+disk/scsi_module-scsi.o: disk/scsi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(scsi_module_CPPFLAGS) $(CPPFLAGS) $(scsi_module_CFLAGS) $(CFLAGS) -MT disk/scsi_module-scsi.o -MD -MP -MF disk/$(DEPDIR)/scsi_module-scsi.Tpo -c -o disk/scsi_module-scsi.o `test -f 'disk/scsi.c' || echo '$(srcdir)/'`disk/scsi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/scsi_module-scsi.Tpo disk/$(DEPDIR)/scsi_module-scsi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/scsi.c' object='disk/scsi_module-scsi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(scsi_module_CPPFLAGS) $(CPPFLAGS) $(scsi_module_CFLAGS) $(CFLAGS) -c -o disk/scsi_module-scsi.o `test -f 'disk/scsi.c' || echo '$(srcdir)/'`disk/scsi.c
+
+disk/scsi_module-scsi.obj: disk/scsi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(scsi_module_CPPFLAGS) $(CPPFLAGS) $(scsi_module_CFLAGS) $(CFLAGS) -MT disk/scsi_module-scsi.obj -MD -MP -MF disk/$(DEPDIR)/scsi_module-scsi.Tpo -c -o disk/scsi_module-scsi.obj `if test -f 'disk/scsi.c'; then $(CYGPATH_W) 'disk/scsi.c'; else $(CYGPATH_W) '$(srcdir)/disk/scsi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/scsi_module-scsi.Tpo disk/$(DEPDIR)/scsi_module-scsi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/scsi.c' object='disk/scsi_module-scsi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(scsi_module_CPPFLAGS) $(CPPFLAGS) $(scsi_module_CFLAGS) $(CFLAGS) -c -o disk/scsi_module-scsi.obj `if test -f 'disk/scsi.c'; then $(CYGPATH_W) 'disk/scsi.c'; else $(CYGPATH_W) '$(srcdir)/disk/scsi.c'; fi`
+
+video/emu/sdl_module-sdl.o: video/emu/sdl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sdl_module_CPPFLAGS) $(CPPFLAGS) $(sdl_module_CFLAGS) $(CFLAGS) -MT video/emu/sdl_module-sdl.o -MD -MP -MF video/emu/$(DEPDIR)/sdl_module-sdl.Tpo -c -o video/emu/sdl_module-sdl.o `test -f 'video/emu/sdl.c' || echo '$(srcdir)/'`video/emu/sdl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/emu/$(DEPDIR)/sdl_module-sdl.Tpo video/emu/$(DEPDIR)/sdl_module-sdl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/emu/sdl.c' object='video/emu/sdl_module-sdl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sdl_module_CPPFLAGS) $(CPPFLAGS) $(sdl_module_CFLAGS) $(CFLAGS) -c -o video/emu/sdl_module-sdl.o `test -f 'video/emu/sdl.c' || echo '$(srcdir)/'`video/emu/sdl.c
+
+video/emu/sdl_module-sdl.obj: video/emu/sdl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sdl_module_CPPFLAGS) $(CPPFLAGS) $(sdl_module_CFLAGS) $(CFLAGS) -MT video/emu/sdl_module-sdl.obj -MD -MP -MF video/emu/$(DEPDIR)/sdl_module-sdl.Tpo -c -o video/emu/sdl_module-sdl.obj `if test -f 'video/emu/sdl.c'; then $(CYGPATH_W) 'video/emu/sdl.c'; else $(CYGPATH_W) '$(srcdir)/video/emu/sdl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/emu/$(DEPDIR)/sdl_module-sdl.Tpo video/emu/$(DEPDIR)/sdl_module-sdl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/emu/sdl.c' object='video/emu/sdl_module-sdl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sdl_module_CPPFLAGS) $(CPPFLAGS) $(sdl_module_CFLAGS) $(CFLAGS) -c -o video/emu/sdl_module-sdl.obj `if test -f 'video/emu/sdl.c'; then $(CYGPATH_W) 'video/emu/sdl.c'; else $(CYGPATH_W) '$(srcdir)/video/emu/sdl.c'; fi`
+
+commands/search_module-search_wrap.o: commands/search_wrap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_module_CPPFLAGS) $(CPPFLAGS) $(search_module_CFLAGS) $(CFLAGS) -MT commands/search_module-search_wrap.o -MD -MP -MF commands/$(DEPDIR)/search_module-search_wrap.Tpo -c -o commands/search_module-search_wrap.o `test -f 'commands/search_wrap.c' || echo '$(srcdir)/'`commands/search_wrap.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/search_module-search_wrap.Tpo commands/$(DEPDIR)/search_module-search_wrap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/search_wrap.c' object='commands/search_module-search_wrap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_module_CPPFLAGS) $(CPPFLAGS) $(search_module_CFLAGS) $(CFLAGS) -c -o commands/search_module-search_wrap.o `test -f 'commands/search_wrap.c' || echo '$(srcdir)/'`commands/search_wrap.c
+
+commands/search_module-search_wrap.obj: commands/search_wrap.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_module_CPPFLAGS) $(CPPFLAGS) $(search_module_CFLAGS) $(CFLAGS) -MT commands/search_module-search_wrap.obj -MD -MP -MF commands/$(DEPDIR)/search_module-search_wrap.Tpo -c -o commands/search_module-search_wrap.obj `if test -f 'commands/search_wrap.c'; then $(CYGPATH_W) 'commands/search_wrap.c'; else $(CYGPATH_W) '$(srcdir)/commands/search_wrap.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/search_module-search_wrap.Tpo commands/$(DEPDIR)/search_module-search_wrap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/search_wrap.c' object='commands/search_module-search_wrap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_module_CPPFLAGS) $(CPPFLAGS) $(search_module_CFLAGS) $(CFLAGS) -c -o commands/search_module-search_wrap.obj `if test -f 'commands/search_wrap.c'; then $(CYGPATH_W) 'commands/search_wrap.c'; else $(CYGPATH_W) '$(srcdir)/commands/search_wrap.c'; fi`
+
+commands/search_fs_file_module-search_file.o: commands/search_file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_file_module_CPPFLAGS) $(CPPFLAGS) $(search_fs_file_module_CFLAGS) $(CFLAGS) -MT commands/search_fs_file_module-search_file.o -MD -MP -MF commands/$(DEPDIR)/search_fs_file_module-search_file.Tpo -c -o commands/search_fs_file_module-search_file.o `test -f 'commands/search_file.c' || echo '$(srcdir)/'`commands/search_file.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/search_fs_file_module-search_file.Tpo commands/$(DEPDIR)/search_fs_file_module-search_file.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/search_file.c' object='commands/search_fs_file_module-search_file.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_file_module_CPPFLAGS) $(CPPFLAGS) $(search_fs_file_module_CFLAGS) $(CFLAGS) -c -o commands/search_fs_file_module-search_file.o `test -f 'commands/search_file.c' || echo '$(srcdir)/'`commands/search_file.c
+
+commands/search_fs_file_module-search_file.obj: commands/search_file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_file_module_CPPFLAGS) $(CPPFLAGS) $(search_fs_file_module_CFLAGS) $(CFLAGS) -MT commands/search_fs_file_module-search_file.obj -MD -MP -MF commands/$(DEPDIR)/search_fs_file_module-search_file.Tpo -c -o commands/search_fs_file_module-search_file.obj `if test -f 'commands/search_file.c'; then $(CYGPATH_W) 'commands/search_file.c'; else $(CYGPATH_W) '$(srcdir)/commands/search_file.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/search_fs_file_module-search_file.Tpo commands/$(DEPDIR)/search_fs_file_module-search_file.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/search_file.c' object='commands/search_fs_file_module-search_file.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_file_module_CPPFLAGS) $(CPPFLAGS) $(search_fs_file_module_CFLAGS) $(CFLAGS) -c -o commands/search_fs_file_module-search_file.obj `if test -f 'commands/search_file.c'; then $(CYGPATH_W) 'commands/search_file.c'; else $(CYGPATH_W) '$(srcdir)/commands/search_file.c'; fi`
+
+commands/search_fs_uuid_module-search_uuid.o: commands/search_uuid.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_uuid_module_CPPFLAGS) $(CPPFLAGS) $(search_fs_uuid_module_CFLAGS) $(CFLAGS) -MT commands/search_fs_uuid_module-search_uuid.o -MD -MP -MF commands/$(DEPDIR)/search_fs_uuid_module-search_uuid.Tpo -c -o commands/search_fs_uuid_module-search_uuid.o `test -f 'commands/search_uuid.c' || echo '$(srcdir)/'`commands/search_uuid.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/search_fs_uuid_module-search_uuid.Tpo commands/$(DEPDIR)/search_fs_uuid_module-search_uuid.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/search_uuid.c' object='commands/search_fs_uuid_module-search_uuid.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_uuid_module_CPPFLAGS) $(CPPFLAGS) $(search_fs_uuid_module_CFLAGS) $(CFLAGS) -c -o commands/search_fs_uuid_module-search_uuid.o `test -f 'commands/search_uuid.c' || echo '$(srcdir)/'`commands/search_uuid.c
+
+commands/search_fs_uuid_module-search_uuid.obj: commands/search_uuid.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_uuid_module_CPPFLAGS) $(CPPFLAGS) $(search_fs_uuid_module_CFLAGS) $(CFLAGS) -MT commands/search_fs_uuid_module-search_uuid.obj -MD -MP -MF commands/$(DEPDIR)/search_fs_uuid_module-search_uuid.Tpo -c -o commands/search_fs_uuid_module-search_uuid.obj `if test -f 'commands/search_uuid.c'; then $(CYGPATH_W) 'commands/search_uuid.c'; else $(CYGPATH_W) '$(srcdir)/commands/search_uuid.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/search_fs_uuid_module-search_uuid.Tpo commands/$(DEPDIR)/search_fs_uuid_module-search_uuid.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/search_uuid.c' object='commands/search_fs_uuid_module-search_uuid.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_uuid_module_CPPFLAGS) $(CPPFLAGS) $(search_fs_uuid_module_CFLAGS) $(CFLAGS) -c -o commands/search_fs_uuid_module-search_uuid.obj `if test -f 'commands/search_uuid.c'; then $(CYGPATH_W) 'commands/search_uuid.c'; else $(CYGPATH_W) '$(srcdir)/commands/search_uuid.c'; fi`
+
+commands/search_label_module-search_label.o: commands/search_label.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_label_module_CPPFLAGS) $(CPPFLAGS) $(search_label_module_CFLAGS) $(CFLAGS) -MT commands/search_label_module-search_label.o -MD -MP -MF commands/$(DEPDIR)/search_label_module-search_label.Tpo -c -o commands/search_label_module-search_label.o `test -f 'commands/search_label.c' || echo '$(srcdir)/'`commands/search_label.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/search_label_module-search_label.Tpo commands/$(DEPDIR)/search_label_module-search_label.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/search_label.c' object='commands/search_label_module-search_label.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_label_module_CPPFLAGS) $(CPPFLAGS) $(search_label_module_CFLAGS) $(CFLAGS) -c -o commands/search_label_module-search_label.o `test -f 'commands/search_label.c' || echo '$(srcdir)/'`commands/search_label.c
+
+commands/search_label_module-search_label.obj: commands/search_label.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_label_module_CPPFLAGS) $(CPPFLAGS) $(search_label_module_CFLAGS) $(CFLAGS) -MT commands/search_label_module-search_label.obj -MD -MP -MF commands/$(DEPDIR)/search_label_module-search_label.Tpo -c -o commands/search_label_module-search_label.obj `if test -f 'commands/search_label.c'; then $(CYGPATH_W) 'commands/search_label.c'; else $(CYGPATH_W) '$(srcdir)/commands/search_label.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/search_label_module-search_label.Tpo commands/$(DEPDIR)/search_label_module-search_label.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/search_label.c' object='commands/search_label_module-search_label.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_label_module_CPPFLAGS) $(CPPFLAGS) $(search_label_module_CFLAGS) $(CFLAGS) -c -o commands/search_label_module-search_label.obj `if test -f 'commands/search_label.c'; then $(CYGPATH_W) 'commands/search_label.c'; else $(CYGPATH_W) '$(srcdir)/commands/search_label.c'; fi`
+
+commands/i386/pc/sendkey_module-sendkey.o: commands/i386/pc/sendkey.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sendkey_module_CPPFLAGS) $(CPPFLAGS) $(sendkey_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/sendkey_module-sendkey.o -MD -MP -MF commands/i386/pc/$(DEPDIR)/sendkey_module-sendkey.Tpo -c -o commands/i386/pc/sendkey_module-sendkey.o `test -f 'commands/i386/pc/sendkey.c' || echo '$(srcdir)/'`commands/i386/pc/sendkey.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/sendkey_module-sendkey.Tpo commands/i386/pc/$(DEPDIR)/sendkey_module-sendkey.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/sendkey.c' object='commands/i386/pc/sendkey_module-sendkey.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sendkey_module_CPPFLAGS) $(CPPFLAGS) $(sendkey_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/sendkey_module-sendkey.o `test -f 'commands/i386/pc/sendkey.c' || echo '$(srcdir)/'`commands/i386/pc/sendkey.c
+
+commands/i386/pc/sendkey_module-sendkey.obj: commands/i386/pc/sendkey.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sendkey_module_CPPFLAGS) $(CPPFLAGS) $(sendkey_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/sendkey_module-sendkey.obj -MD -MP -MF commands/i386/pc/$(DEPDIR)/sendkey_module-sendkey.Tpo -c -o commands/i386/pc/sendkey_module-sendkey.obj `if test -f 'commands/i386/pc/sendkey.c'; then $(CYGPATH_W) 'commands/i386/pc/sendkey.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/sendkey.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/sendkey_module-sendkey.Tpo commands/i386/pc/$(DEPDIR)/sendkey_module-sendkey.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/sendkey.c' object='commands/i386/pc/sendkey_module-sendkey.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sendkey_module_CPPFLAGS) $(CPPFLAGS) $(sendkey_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/sendkey_module-sendkey.obj `if test -f 'commands/i386/pc/sendkey.c'; then $(CYGPATH_W) 'commands/i386/pc/sendkey.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/sendkey.c'; fi`
+
+term/efi/serial_module-serial.o: term/efi/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -MT term/efi/serial_module-serial.o -MD -MP -MF term/efi/$(DEPDIR)/serial_module-serial.Tpo -c -o term/efi/serial_module-serial.o `test -f 'term/efi/serial.c' || echo '$(srcdir)/'`term/efi/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/efi/$(DEPDIR)/serial_module-serial.Tpo term/efi/$(DEPDIR)/serial_module-serial.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/efi/serial.c' object='term/efi/serial_module-serial.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -c -o term/efi/serial_module-serial.o `test -f 'term/efi/serial.c' || echo '$(srcdir)/'`term/efi/serial.c
+
+term/efi/serial_module-serial.obj: term/efi/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -MT term/efi/serial_module-serial.obj -MD -MP -MF term/efi/$(DEPDIR)/serial_module-serial.Tpo -c -o term/efi/serial_module-serial.obj `if test -f 'term/efi/serial.c'; then $(CYGPATH_W) 'term/efi/serial.c'; else $(CYGPATH_W) '$(srcdir)/term/efi/serial.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/efi/$(DEPDIR)/serial_module-serial.Tpo term/efi/$(DEPDIR)/serial_module-serial.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/efi/serial.c' object='term/efi/serial_module-serial.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -c -o term/efi/serial_module-serial.obj `if test -f 'term/efi/serial.c'; then $(CYGPATH_W) 'term/efi/serial.c'; else $(CYGPATH_W) '$(srcdir)/term/efi/serial.c'; fi`
+
+term/serial_module-serial.o: term/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -MT term/serial_module-serial.o -MD -MP -MF term/$(DEPDIR)/serial_module-serial.Tpo -c -o term/serial_module-serial.o `test -f 'term/serial.c' || echo '$(srcdir)/'`term/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/serial_module-serial.Tpo term/$(DEPDIR)/serial_module-serial.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/serial.c' object='term/serial_module-serial.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -c -o term/serial_module-serial.o `test -f 'term/serial.c' || echo '$(srcdir)/'`term/serial.c
+
+term/serial_module-serial.obj: term/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -MT term/serial_module-serial.obj -MD -MP -MF term/$(DEPDIR)/serial_module-serial.Tpo -c -o term/serial_module-serial.obj `if test -f 'term/serial.c'; then $(CYGPATH_W) 'term/serial.c'; else $(CYGPATH_W) '$(srcdir)/term/serial.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/serial_module-serial.Tpo term/$(DEPDIR)/serial_module-serial.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/serial.c' object='term/serial_module-serial.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -c -o term/serial_module-serial.obj `if test -f 'term/serial.c'; then $(CYGPATH_W) 'term/serial.c'; else $(CYGPATH_W) '$(srcdir)/term/serial.c'; fi`
+
+term/serial_module-ns8250.o: term/ns8250.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -MT term/serial_module-ns8250.o -MD -MP -MF term/$(DEPDIR)/serial_module-ns8250.Tpo -c -o term/serial_module-ns8250.o `test -f 'term/ns8250.c' || echo '$(srcdir)/'`term/ns8250.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/serial_module-ns8250.Tpo term/$(DEPDIR)/serial_module-ns8250.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ns8250.c' object='term/serial_module-ns8250.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -c -o term/serial_module-ns8250.o `test -f 'term/ns8250.c' || echo '$(srcdir)/'`term/ns8250.c
+
+term/serial_module-ns8250.obj: term/ns8250.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -MT term/serial_module-ns8250.obj -MD -MP -MF term/$(DEPDIR)/serial_module-ns8250.Tpo -c -o term/serial_module-ns8250.obj `if test -f 'term/ns8250.c'; then $(CYGPATH_W) 'term/ns8250.c'; else $(CYGPATH_W) '$(srcdir)/term/ns8250.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/serial_module-ns8250.Tpo term/$(DEPDIR)/serial_module-ns8250.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ns8250.c' object='term/serial_module-ns8250.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -c -o term/serial_module-ns8250.obj `if test -f 'term/ns8250.c'; then $(CYGPATH_W) 'term/ns8250.c'; else $(CYGPATH_W) '$(srcdir)/term/ns8250.c'; fi`
+
+term/ieee1275/serial_module-serial.o: term/ieee1275/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -MT term/ieee1275/serial_module-serial.o -MD -MP -MF term/ieee1275/$(DEPDIR)/serial_module-serial.Tpo -c -o term/ieee1275/serial_module-serial.o `test -f 'term/ieee1275/serial.c' || echo '$(srcdir)/'`term/ieee1275/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/ieee1275/$(DEPDIR)/serial_module-serial.Tpo term/ieee1275/$(DEPDIR)/serial_module-serial.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ieee1275/serial.c' object='term/ieee1275/serial_module-serial.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -c -o term/ieee1275/serial_module-serial.o `test -f 'term/ieee1275/serial.c' || echo '$(srcdir)/'`term/ieee1275/serial.c
+
+term/ieee1275/serial_module-serial.obj: term/ieee1275/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -MT term/ieee1275/serial_module-serial.obj -MD -MP -MF term/ieee1275/$(DEPDIR)/serial_module-serial.Tpo -c -o term/ieee1275/serial_module-serial.obj `if test -f 'term/ieee1275/serial.c'; then $(CYGPATH_W) 'term/ieee1275/serial.c'; else $(CYGPATH_W) '$(srcdir)/term/ieee1275/serial.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/ieee1275/$(DEPDIR)/serial_module-serial.Tpo term/ieee1275/$(DEPDIR)/serial_module-serial.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/ieee1275/serial.c' object='term/ieee1275/serial_module-serial.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -c -o term/ieee1275/serial_module-serial.obj `if test -f 'term/ieee1275/serial.c'; then $(CYGPATH_W) 'term/ieee1275/serial.c'; else $(CYGPATH_W) '$(srcdir)/term/ieee1275/serial.c'; fi`
+
+term/arc/serial_module-serial.o: term/arc/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -MT term/arc/serial_module-serial.o -MD -MP -MF term/arc/$(DEPDIR)/serial_module-serial.Tpo -c -o term/arc/serial_module-serial.o `test -f 'term/arc/serial.c' || echo '$(srcdir)/'`term/arc/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/arc/$(DEPDIR)/serial_module-serial.Tpo term/arc/$(DEPDIR)/serial_module-serial.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/arc/serial.c' object='term/arc/serial_module-serial.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -c -o term/arc/serial_module-serial.o `test -f 'term/arc/serial.c' || echo '$(srcdir)/'`term/arc/serial.c
+
+term/arc/serial_module-serial.obj: term/arc/serial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -MT term/arc/serial_module-serial.obj -MD -MP -MF term/arc/$(DEPDIR)/serial_module-serial.Tpo -c -o term/arc/serial_module-serial.obj `if test -f 'term/arc/serial.c'; then $(CYGPATH_W) 'term/arc/serial.c'; else $(CYGPATH_W) '$(srcdir)/term/arc/serial.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/arc/$(DEPDIR)/serial_module-serial.Tpo term/arc/$(DEPDIR)/serial_module-serial.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/arc/serial.c' object='term/arc/serial_module-serial.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $(serial_module_CFLAGS) $(CFLAGS) -c -o term/arc/serial_module-serial.obj `if test -f 'term/arc/serial.c'; then $(CYGPATH_W) 'term/arc/serial.c'; else $(CYGPATH_W) '$(srcdir)/term/arc/serial.c'; fi`
+
+tests/setjmp_test_module-setjmp_test.o: tests/setjmp_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_test_module_CPPFLAGS) $(CPPFLAGS) $(setjmp_test_module_CFLAGS) $(CFLAGS) -MT tests/setjmp_test_module-setjmp_test.o -MD -MP -MF tests/$(DEPDIR)/setjmp_test_module-setjmp_test.Tpo -c -o tests/setjmp_test_module-setjmp_test.o `test -f 'tests/setjmp_test.c' || echo '$(srcdir)/'`tests/setjmp_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/setjmp_test_module-setjmp_test.Tpo tests/$(DEPDIR)/setjmp_test_module-setjmp_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/setjmp_test.c' object='tests/setjmp_test_module-setjmp_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_test_module_CPPFLAGS) $(CPPFLAGS) $(setjmp_test_module_CFLAGS) $(CFLAGS) -c -o tests/setjmp_test_module-setjmp_test.o `test -f 'tests/setjmp_test.c' || echo '$(srcdir)/'`tests/setjmp_test.c
+
+tests/setjmp_test_module-setjmp_test.obj: tests/setjmp_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_test_module_CPPFLAGS) $(CPPFLAGS) $(setjmp_test_module_CFLAGS) $(CFLAGS) -MT tests/setjmp_test_module-setjmp_test.obj -MD -MP -MF tests/$(DEPDIR)/setjmp_test_module-setjmp_test.Tpo -c -o tests/setjmp_test_module-setjmp_test.obj `if test -f 'tests/setjmp_test.c'; then $(CYGPATH_W) 'tests/setjmp_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/setjmp_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/setjmp_test_module-setjmp_test.Tpo tests/$(DEPDIR)/setjmp_test_module-setjmp_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/setjmp_test.c' object='tests/setjmp_test_module-setjmp_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_test_module_CPPFLAGS) $(CPPFLAGS) $(setjmp_test_module_CFLAGS) $(CFLAGS) -c -o tests/setjmp_test_module-setjmp_test.obj `if test -f 'tests/setjmp_test.c'; then $(CYGPATH_W) 'tests/setjmp_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/setjmp_test.c'; fi`
+
+commands/setpci_module-setpci.o: commands/setpci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $(setpci_module_CFLAGS) $(CFLAGS) -MT commands/setpci_module-setpci.o -MD -MP -MF commands/$(DEPDIR)/setpci_module-setpci.Tpo -c -o commands/setpci_module-setpci.o `test -f 'commands/setpci.c' || echo '$(srcdir)/'`commands/setpci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/setpci_module-setpci.Tpo commands/$(DEPDIR)/setpci_module-setpci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/setpci.c' object='commands/setpci_module-setpci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $(setpci_module_CFLAGS) $(CFLAGS) -c -o commands/setpci_module-setpci.o `test -f 'commands/setpci.c' || echo '$(srcdir)/'`commands/setpci.c
+
+commands/setpci_module-setpci.obj: commands/setpci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $(setpci_module_CFLAGS) $(CFLAGS) -MT commands/setpci_module-setpci.obj -MD -MP -MF commands/$(DEPDIR)/setpci_module-setpci.Tpo -c -o commands/setpci_module-setpci.obj `if test -f 'commands/setpci.c'; then $(CYGPATH_W) 'commands/setpci.c'; else $(CYGPATH_W) '$(srcdir)/commands/setpci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/setpci_module-setpci.Tpo commands/$(DEPDIR)/setpci_module-setpci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/setpci.c' object='commands/setpci_module-setpci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $(setpci_module_CFLAGS) $(CFLAGS) -c -o commands/setpci_module-setpci.obj `if test -f 'commands/setpci.c'; then $(CYGPATH_W) 'commands/setpci.c'; else $(CYGPATH_W) '$(srcdir)/commands/setpci.c'; fi`
+
+fs/sfs_module-sfs.o: fs/sfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sfs_module_CPPFLAGS) $(CPPFLAGS) $(sfs_module_CFLAGS) $(CFLAGS) -MT fs/sfs_module-sfs.o -MD -MP -MF fs/$(DEPDIR)/sfs_module-sfs.Tpo -c -o fs/sfs_module-sfs.o `test -f 'fs/sfs.c' || echo '$(srcdir)/'`fs/sfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/sfs_module-sfs.Tpo fs/$(DEPDIR)/sfs_module-sfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/sfs.c' object='fs/sfs_module-sfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sfs_module_CPPFLAGS) $(CPPFLAGS) $(sfs_module_CFLAGS) $(CFLAGS) -c -o fs/sfs_module-sfs.o `test -f 'fs/sfs.c' || echo '$(srcdir)/'`fs/sfs.c
+
+fs/sfs_module-sfs.obj: fs/sfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sfs_module_CPPFLAGS) $(CPPFLAGS) $(sfs_module_CFLAGS) $(CFLAGS) -MT fs/sfs_module-sfs.obj -MD -MP -MF fs/$(DEPDIR)/sfs_module-sfs.Tpo -c -o fs/sfs_module-sfs.obj `if test -f 'fs/sfs.c'; then $(CYGPATH_W) 'fs/sfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/sfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/sfs_module-sfs.Tpo fs/$(DEPDIR)/sfs_module-sfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/sfs.c' object='fs/sfs_module-sfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sfs_module_CPPFLAGS) $(CPPFLAGS) $(sfs_module_CFLAGS) $(CFLAGS) -c -o fs/sfs_module-sfs.obj `if test -f 'fs/sfs.c'; then $(CYGPATH_W) 'fs/sfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/sfs.c'; fi`
+
+tests/shift_test_module-shift_test.o: tests/shift_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(shift_test_module_CPPFLAGS) $(CPPFLAGS) $(shift_test_module_CFLAGS) $(CFLAGS) -MT tests/shift_test_module-shift_test.o -MD -MP -MF tests/$(DEPDIR)/shift_test_module-shift_test.Tpo -c -o tests/shift_test_module-shift_test.o `test -f 'tests/shift_test.c' || echo '$(srcdir)/'`tests/shift_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/shift_test_module-shift_test.Tpo tests/$(DEPDIR)/shift_test_module-shift_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/shift_test.c' object='tests/shift_test_module-shift_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(shift_test_module_CPPFLAGS) $(CPPFLAGS) $(shift_test_module_CFLAGS) $(CFLAGS) -c -o tests/shift_test_module-shift_test.o `test -f 'tests/shift_test.c' || echo '$(srcdir)/'`tests/shift_test.c
+
+tests/shift_test_module-shift_test.obj: tests/shift_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(shift_test_module_CPPFLAGS) $(CPPFLAGS) $(shift_test_module_CFLAGS) $(CFLAGS) -MT tests/shift_test_module-shift_test.obj -MD -MP -MF tests/$(DEPDIR)/shift_test_module-shift_test.Tpo -c -o tests/shift_test_module-shift_test.obj `if test -f 'tests/shift_test.c'; then $(CYGPATH_W) 'tests/shift_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/shift_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/shift_test_module-shift_test.Tpo tests/$(DEPDIR)/shift_test_module-shift_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/shift_test.c' object='tests/shift_test_module-shift_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(shift_test_module_CPPFLAGS) $(CPPFLAGS) $(shift_test_module_CFLAGS) $(CFLAGS) -c -o tests/shift_test_module-shift_test.obj `if test -f 'tests/shift_test.c'; then $(CYGPATH_W) 'tests/shift_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/shift_test.c'; fi`
+
+tests/signature_test_module-signature_test.o: tests/signature_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(signature_test_module_CPPFLAGS) $(CPPFLAGS) $(signature_test_module_CFLAGS) $(CFLAGS) -MT tests/signature_test_module-signature_test.o -MD -MP -MF tests/$(DEPDIR)/signature_test_module-signature_test.Tpo -c -o tests/signature_test_module-signature_test.o `test -f 'tests/signature_test.c' || echo '$(srcdir)/'`tests/signature_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/signature_test_module-signature_test.Tpo tests/$(DEPDIR)/signature_test_module-signature_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/signature_test.c' object='tests/signature_test_module-signature_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(signature_test_module_CPPFLAGS) $(CPPFLAGS) $(signature_test_module_CFLAGS) $(CFLAGS) -c -o tests/signature_test_module-signature_test.o `test -f 'tests/signature_test.c' || echo '$(srcdir)/'`tests/signature_test.c
+
+tests/signature_test_module-signature_test.obj: tests/signature_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(signature_test_module_CPPFLAGS) $(CPPFLAGS) $(signature_test_module_CFLAGS) $(CFLAGS) -MT tests/signature_test_module-signature_test.obj -MD -MP -MF tests/$(DEPDIR)/signature_test_module-signature_test.Tpo -c -o tests/signature_test_module-signature_test.obj `if test -f 'tests/signature_test.c'; then $(CYGPATH_W) 'tests/signature_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/signature_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/signature_test_module-signature_test.Tpo tests/$(DEPDIR)/signature_test_module-signature_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/signature_test.c' object='tests/signature_test_module-signature_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(signature_test_module_CPPFLAGS) $(CPPFLAGS) $(signature_test_module_CFLAGS) $(CFLAGS) -c -o tests/signature_test_module-signature_test.obj `if test -f 'tests/signature_test.c'; then $(CYGPATH_W) 'tests/signature_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/signature_test.c'; fi`
+
+commands/sleep_module-sleep.o: commands/sleep.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_module_CPPFLAGS) $(CPPFLAGS) $(sleep_module_CFLAGS) $(CFLAGS) -MT commands/sleep_module-sleep.o -MD -MP -MF commands/$(DEPDIR)/sleep_module-sleep.Tpo -c -o commands/sleep_module-sleep.o `test -f 'commands/sleep.c' || echo '$(srcdir)/'`commands/sleep.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/sleep_module-sleep.Tpo commands/$(DEPDIR)/sleep_module-sleep.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/sleep.c' object='commands/sleep_module-sleep.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_module_CPPFLAGS) $(CPPFLAGS) $(sleep_module_CFLAGS) $(CFLAGS) -c -o commands/sleep_module-sleep.o `test -f 'commands/sleep.c' || echo '$(srcdir)/'`commands/sleep.c
+
+commands/sleep_module-sleep.obj: commands/sleep.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_module_CPPFLAGS) $(CPPFLAGS) $(sleep_module_CFLAGS) $(CFLAGS) -MT commands/sleep_module-sleep.obj -MD -MP -MF commands/$(DEPDIR)/sleep_module-sleep.Tpo -c -o commands/sleep_module-sleep.obj `if test -f 'commands/sleep.c'; then $(CYGPATH_W) 'commands/sleep.c'; else $(CYGPATH_W) '$(srcdir)/commands/sleep.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/sleep_module-sleep.Tpo commands/$(DEPDIR)/sleep_module-sleep.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/sleep.c' object='commands/sleep_module-sleep.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_module_CPPFLAGS) $(CPPFLAGS) $(sleep_module_CFLAGS) $(CFLAGS) -c -o commands/sleep_module-sleep.obj `if test -f 'commands/sleep.c'; then $(CYGPATH_W) 'commands/sleep.c'; else $(CYGPATH_W) '$(srcdir)/commands/sleep.c'; fi`
+
+tests/sleep_test_module-sleep_test.o: tests/sleep_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_test_module_CPPFLAGS) $(CPPFLAGS) $(sleep_test_module_CFLAGS) $(CFLAGS) -MT tests/sleep_test_module-sleep_test.o -MD -MP -MF tests/$(DEPDIR)/sleep_test_module-sleep_test.Tpo -c -o tests/sleep_test_module-sleep_test.o `test -f 'tests/sleep_test.c' || echo '$(srcdir)/'`tests/sleep_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/sleep_test_module-sleep_test.Tpo tests/$(DEPDIR)/sleep_test_module-sleep_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/sleep_test.c' object='tests/sleep_test_module-sleep_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_test_module_CPPFLAGS) $(CPPFLAGS) $(sleep_test_module_CFLAGS) $(CFLAGS) -c -o tests/sleep_test_module-sleep_test.o `test -f 'tests/sleep_test.c' || echo '$(srcdir)/'`tests/sleep_test.c
+
+tests/sleep_test_module-sleep_test.obj: tests/sleep_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_test_module_CPPFLAGS) $(CPPFLAGS) $(sleep_test_module_CFLAGS) $(CFLAGS) -MT tests/sleep_test_module-sleep_test.obj -MD -MP -MF tests/$(DEPDIR)/sleep_test_module-sleep_test.Tpo -c -o tests/sleep_test_module-sleep_test.obj `if test -f 'tests/sleep_test.c'; then $(CYGPATH_W) 'tests/sleep_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/sleep_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/sleep_test_module-sleep_test.Tpo tests/$(DEPDIR)/sleep_test_module-sleep_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/sleep_test.c' object='tests/sleep_test_module-sleep_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_test_module_CPPFLAGS) $(CPPFLAGS) $(sleep_test_module_CFLAGS) $(CFLAGS) -c -o tests/sleep_test_module-sleep_test.obj `if test -f 'tests/sleep_test.c'; then $(CYGPATH_W) 'tests/sleep_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/sleep_test.c'; fi`
+
+commands/efi/smbios_module-smbios.o: commands/efi/smbios.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -MT commands/efi/smbios_module-smbios.o -MD -MP -MF commands/efi/$(DEPDIR)/smbios_module-smbios.Tpo -c -o commands/efi/smbios_module-smbios.o `test -f 'commands/efi/smbios.c' || echo '$(srcdir)/'`commands/efi/smbios.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/smbios_module-smbios.Tpo commands/efi/$(DEPDIR)/smbios_module-smbios.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/smbios.c' object='commands/efi/smbios_module-smbios.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -c -o commands/efi/smbios_module-smbios.o `test -f 'commands/efi/smbios.c' || echo '$(srcdir)/'`commands/efi/smbios.c
+
+commands/efi/smbios_module-smbios.obj: commands/efi/smbios.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -MT commands/efi/smbios_module-smbios.obj -MD -MP -MF commands/efi/$(DEPDIR)/smbios_module-smbios.Tpo -c -o commands/efi/smbios_module-smbios.obj `if test -f 'commands/efi/smbios.c'; then $(CYGPATH_W) 'commands/efi/smbios.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/smbios.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/smbios_module-smbios.Tpo commands/efi/$(DEPDIR)/smbios_module-smbios.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/smbios.c' object='commands/efi/smbios_module-smbios.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -c -o commands/efi/smbios_module-smbios.obj `if test -f 'commands/efi/smbios.c'; then $(CYGPATH_W) 'commands/efi/smbios.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/smbios.c'; fi`
+
+commands/smbios_module-smbios.o: commands/smbios.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -MT commands/smbios_module-smbios.o -MD -MP -MF commands/$(DEPDIR)/smbios_module-smbios.Tpo -c -o commands/smbios_module-smbios.o `test -f 'commands/smbios.c' || echo '$(srcdir)/'`commands/smbios.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/smbios_module-smbios.Tpo commands/$(DEPDIR)/smbios_module-smbios.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/smbios.c' object='commands/smbios_module-smbios.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -c -o commands/smbios_module-smbios.o `test -f 'commands/smbios.c' || echo '$(srcdir)/'`commands/smbios.c
+
+commands/smbios_module-smbios.obj: commands/smbios.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -MT commands/smbios_module-smbios.obj -MD -MP -MF commands/$(DEPDIR)/smbios_module-smbios.Tpo -c -o commands/smbios_module-smbios.obj `if test -f 'commands/smbios.c'; then $(CYGPATH_W) 'commands/smbios.c'; else $(CYGPATH_W) '$(srcdir)/commands/smbios.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/smbios_module-smbios.Tpo commands/$(DEPDIR)/smbios_module-smbios.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/smbios.c' object='commands/smbios_module-smbios.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -c -o commands/smbios_module-smbios.obj `if test -f 'commands/smbios.c'; then $(CYGPATH_W) 'commands/smbios.c'; else $(CYGPATH_W) '$(srcdir)/commands/smbios.c'; fi`
+
+commands/i386/pc/smbios_module-smbios.o: commands/i386/pc/smbios.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/smbios_module-smbios.o -MD -MP -MF commands/i386/pc/$(DEPDIR)/smbios_module-smbios.Tpo -c -o commands/i386/pc/smbios_module-smbios.o `test -f 'commands/i386/pc/smbios.c' || echo '$(srcdir)/'`commands/i386/pc/smbios.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/smbios_module-smbios.Tpo commands/i386/pc/$(DEPDIR)/smbios_module-smbios.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/smbios.c' object='commands/i386/pc/smbios_module-smbios.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/smbios_module-smbios.o `test -f 'commands/i386/pc/smbios.c' || echo '$(srcdir)/'`commands/i386/pc/smbios.c
+
+commands/i386/pc/smbios_module-smbios.obj: commands/i386/pc/smbios.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -MT commands/i386/pc/smbios_module-smbios.obj -MD -MP -MF commands/i386/pc/$(DEPDIR)/smbios_module-smbios.Tpo -c -o commands/i386/pc/smbios_module-smbios.obj `if test -f 'commands/i386/pc/smbios.c'; then $(CYGPATH_W) 'commands/i386/pc/smbios.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/smbios.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/pc/$(DEPDIR)/smbios_module-smbios.Tpo commands/i386/pc/$(DEPDIR)/smbios_module-smbios.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/pc/smbios.c' object='commands/i386/pc/smbios_module-smbios.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $(smbios_module_CFLAGS) $(CFLAGS) -c -o commands/i386/pc/smbios_module-smbios.obj `if test -f 'commands/i386/pc/smbios.c'; then $(CYGPATH_W) 'commands/i386/pc/smbios.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/pc/smbios.c'; fi`
+
+term/spkmodem_module-spkmodem.o: term/spkmodem.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $(spkmodem_module_CFLAGS) $(CFLAGS) -MT term/spkmodem_module-spkmodem.o -MD -MP -MF term/$(DEPDIR)/spkmodem_module-spkmodem.Tpo -c -o term/spkmodem_module-spkmodem.o `test -f 'term/spkmodem.c' || echo '$(srcdir)/'`term/spkmodem.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/spkmodem_module-spkmodem.Tpo term/$(DEPDIR)/spkmodem_module-spkmodem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/spkmodem.c' object='term/spkmodem_module-spkmodem.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $(spkmodem_module_CFLAGS) $(CFLAGS) -c -o term/spkmodem_module-spkmodem.o `test -f 'term/spkmodem.c' || echo '$(srcdir)/'`term/spkmodem.c
+
+term/spkmodem_module-spkmodem.obj: term/spkmodem.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $(spkmodem_module_CFLAGS) $(CFLAGS) -MT term/spkmodem_module-spkmodem.obj -MD -MP -MF term/$(DEPDIR)/spkmodem_module-spkmodem.Tpo -c -o term/spkmodem_module-spkmodem.obj `if test -f 'term/spkmodem.c'; then $(CYGPATH_W) 'term/spkmodem.c'; else $(CYGPATH_W) '$(srcdir)/term/spkmodem.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/spkmodem_module-spkmodem.Tpo term/$(DEPDIR)/spkmodem_module-spkmodem.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/spkmodem.c' object='term/spkmodem_module-spkmodem.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $(spkmodem_module_CFLAGS) $(CFLAGS) -c -o term/spkmodem_module-spkmodem.obj `if test -f 'term/spkmodem.c'; then $(CYGPATH_W) 'term/spkmodem.c'; else $(CYGPATH_W) '$(srcdir)/term/spkmodem.c'; fi`
+
+fs/squash4_module-squash4.o: fs/squash4.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(squash4_module_CPPFLAGS) $(CPPFLAGS) $(squash4_module_CFLAGS) $(CFLAGS) -MT fs/squash4_module-squash4.o -MD -MP -MF fs/$(DEPDIR)/squash4_module-squash4.Tpo -c -o fs/squash4_module-squash4.o `test -f 'fs/squash4.c' || echo '$(srcdir)/'`fs/squash4.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/squash4_module-squash4.Tpo fs/$(DEPDIR)/squash4_module-squash4.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/squash4.c' object='fs/squash4_module-squash4.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(squash4_module_CPPFLAGS) $(CPPFLAGS) $(squash4_module_CFLAGS) $(CFLAGS) -c -o fs/squash4_module-squash4.o `test -f 'fs/squash4.c' || echo '$(srcdir)/'`fs/squash4.c
+
+fs/squash4_module-squash4.obj: fs/squash4.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(squash4_module_CPPFLAGS) $(CPPFLAGS) $(squash4_module_CFLAGS) $(CFLAGS) -MT fs/squash4_module-squash4.obj -MD -MP -MF fs/$(DEPDIR)/squash4_module-squash4.Tpo -c -o fs/squash4_module-squash4.obj `if test -f 'fs/squash4.c'; then $(CYGPATH_W) 'fs/squash4.c'; else $(CYGPATH_W) '$(srcdir)/fs/squash4.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/squash4_module-squash4.Tpo fs/$(DEPDIR)/squash4_module-squash4.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/squash4.c' object='fs/squash4_module-squash4.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(squash4_module_CPPFLAGS) $(CPPFLAGS) $(squash4_module_CFLAGS) $(CFLAGS) -c -o fs/squash4_module-squash4.obj `if test -f 'fs/squash4.c'; then $(CYGPATH_W) 'fs/squash4.c'; else $(CYGPATH_W) '$(srcdir)/fs/squash4.c'; fi`
+
+tests/strtoull_test_module-strtoull_test.o: tests/strtoull_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(strtoull_test_module_CPPFLAGS) $(CPPFLAGS) $(strtoull_test_module_CFLAGS) $(CFLAGS) -MT tests/strtoull_test_module-strtoull_test.o -MD -MP -MF tests/$(DEPDIR)/strtoull_test_module-strtoull_test.Tpo -c -o tests/strtoull_test_module-strtoull_test.o `test -f 'tests/strtoull_test.c' || echo '$(srcdir)/'`tests/strtoull_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/strtoull_test_module-strtoull_test.Tpo tests/$(DEPDIR)/strtoull_test_module-strtoull_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/strtoull_test.c' object='tests/strtoull_test_module-strtoull_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(strtoull_test_module_CPPFLAGS) $(CPPFLAGS) $(strtoull_test_module_CFLAGS) $(CFLAGS) -c -o tests/strtoull_test_module-strtoull_test.o `test -f 'tests/strtoull_test.c' || echo '$(srcdir)/'`tests/strtoull_test.c
+
+tests/strtoull_test_module-strtoull_test.obj: tests/strtoull_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(strtoull_test_module_CPPFLAGS) $(CPPFLAGS) $(strtoull_test_module_CFLAGS) $(CFLAGS) -MT tests/strtoull_test_module-strtoull_test.obj -MD -MP -MF tests/$(DEPDIR)/strtoull_test_module-strtoull_test.Tpo -c -o tests/strtoull_test_module-strtoull_test.obj `if test -f 'tests/strtoull_test.c'; then $(CYGPATH_W) 'tests/strtoull_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/strtoull_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/strtoull_test_module-strtoull_test.Tpo tests/$(DEPDIR)/strtoull_test_module-strtoull_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/strtoull_test.c' object='tests/strtoull_test_module-strtoull_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(strtoull_test_module_CPPFLAGS) $(CPPFLAGS) $(strtoull_test_module_CFLAGS) $(CFLAGS) -c -o tests/strtoull_test_module-strtoull_test.obj `if test -f 'tests/strtoull_test.c'; then $(CYGPATH_W) 'tests/strtoull_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/strtoull_test.c'; fi`
+
+commands/ieee1275/suspend_module-suspend.o: commands/ieee1275/suspend.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_module_CPPFLAGS) $(CPPFLAGS) $(suspend_module_CFLAGS) $(CFLAGS) -MT commands/ieee1275/suspend_module-suspend.o -MD -MP -MF commands/ieee1275/$(DEPDIR)/suspend_module-suspend.Tpo -c -o commands/ieee1275/suspend_module-suspend.o `test -f 'commands/ieee1275/suspend.c' || echo '$(srcdir)/'`commands/ieee1275/suspend.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/ieee1275/$(DEPDIR)/suspend_module-suspend.Tpo commands/ieee1275/$(DEPDIR)/suspend_module-suspend.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/ieee1275/suspend.c' object='commands/ieee1275/suspend_module-suspend.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_module_CPPFLAGS) $(CPPFLAGS) $(suspend_module_CFLAGS) $(CFLAGS) -c -o commands/ieee1275/suspend_module-suspend.o `test -f 'commands/ieee1275/suspend.c' || echo '$(srcdir)/'`commands/ieee1275/suspend.c
+
+commands/ieee1275/suspend_module-suspend.obj: commands/ieee1275/suspend.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_module_CPPFLAGS) $(CPPFLAGS) $(suspend_module_CFLAGS) $(CFLAGS) -MT commands/ieee1275/suspend_module-suspend.obj -MD -MP -MF commands/ieee1275/$(DEPDIR)/suspend_module-suspend.Tpo -c -o commands/ieee1275/suspend_module-suspend.obj `if test -f 'commands/ieee1275/suspend.c'; then $(CYGPATH_W) 'commands/ieee1275/suspend.c'; else $(CYGPATH_W) '$(srcdir)/commands/ieee1275/suspend.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/ieee1275/$(DEPDIR)/suspend_module-suspend.Tpo commands/ieee1275/$(DEPDIR)/suspend_module-suspend.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/ieee1275/suspend.c' object='commands/ieee1275/suspend_module-suspend.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_module_CPPFLAGS) $(CPPFLAGS) $(suspend_module_CFLAGS) $(CFLAGS) -c -o commands/ieee1275/suspend_module-suspend.obj `if test -f 'commands/ieee1275/suspend.c'; then $(CYGPATH_W) 'commands/ieee1275/suspend.c'; else $(CYGPATH_W) '$(srcdir)/commands/ieee1275/suspend.c'; fi`
+
+lib/syslinuxcfg_module-syslinux_parse.o: lib/syslinux_parse.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(syslinuxcfg_module_CPPFLAGS) $(CPPFLAGS) $(syslinuxcfg_module_CFLAGS) $(CFLAGS) -MT lib/syslinuxcfg_module-syslinux_parse.o -MD -MP -MF lib/$(DEPDIR)/syslinuxcfg_module-syslinux_parse.Tpo -c -o lib/syslinuxcfg_module-syslinux_parse.o `test -f 'lib/syslinux_parse.c' || echo '$(srcdir)/'`lib/syslinux_parse.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/syslinuxcfg_module-syslinux_parse.Tpo lib/$(DEPDIR)/syslinuxcfg_module-syslinux_parse.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/syslinux_parse.c' object='lib/syslinuxcfg_module-syslinux_parse.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(syslinuxcfg_module_CPPFLAGS) $(CPPFLAGS) $(syslinuxcfg_module_CFLAGS) $(CFLAGS) -c -o lib/syslinuxcfg_module-syslinux_parse.o `test -f 'lib/syslinux_parse.c' || echo '$(srcdir)/'`lib/syslinux_parse.c
+
+lib/syslinuxcfg_module-syslinux_parse.obj: lib/syslinux_parse.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(syslinuxcfg_module_CPPFLAGS) $(CPPFLAGS) $(syslinuxcfg_module_CFLAGS) $(CFLAGS) -MT lib/syslinuxcfg_module-syslinux_parse.obj -MD -MP -MF lib/$(DEPDIR)/syslinuxcfg_module-syslinux_parse.Tpo -c -o lib/syslinuxcfg_module-syslinux_parse.obj `if test -f 'lib/syslinux_parse.c'; then $(CYGPATH_W) 'lib/syslinux_parse.c'; else $(CYGPATH_W) '$(srcdir)/lib/syslinux_parse.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/$(DEPDIR)/syslinuxcfg_module-syslinux_parse.Tpo lib/$(DEPDIR)/syslinuxcfg_module-syslinux_parse.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/syslinux_parse.c' object='lib/syslinuxcfg_module-syslinux_parse.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(syslinuxcfg_module_CPPFLAGS) $(CPPFLAGS) $(syslinuxcfg_module_CFLAGS) $(CFLAGS) -c -o lib/syslinuxcfg_module-syslinux_parse.obj `if test -f 'lib/syslinux_parse.c'; then $(CYGPATH_W) 'lib/syslinux_parse.c'; else $(CYGPATH_W) '$(srcdir)/lib/syslinux_parse.c'; fi`
+
+commands/syslinuxcfg_module-syslinuxcfg.o: commands/syslinuxcfg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(syslinuxcfg_module_CPPFLAGS) $(CPPFLAGS) $(syslinuxcfg_module_CFLAGS) $(CFLAGS) -MT commands/syslinuxcfg_module-syslinuxcfg.o -MD -MP -MF commands/$(DEPDIR)/syslinuxcfg_module-syslinuxcfg.Tpo -c -o commands/syslinuxcfg_module-syslinuxcfg.o `test -f 'commands/syslinuxcfg.c' || echo '$(srcdir)/'`commands/syslinuxcfg.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/syslinuxcfg_module-syslinuxcfg.Tpo commands/$(DEPDIR)/syslinuxcfg_module-syslinuxcfg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/syslinuxcfg.c' object='commands/syslinuxcfg_module-syslinuxcfg.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(syslinuxcfg_module_CPPFLAGS) $(CPPFLAGS) $(syslinuxcfg_module_CFLAGS) $(CFLAGS) -c -o commands/syslinuxcfg_module-syslinuxcfg.o `test -f 'commands/syslinuxcfg.c' || echo '$(srcdir)/'`commands/syslinuxcfg.c
+
+commands/syslinuxcfg_module-syslinuxcfg.obj: commands/syslinuxcfg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(syslinuxcfg_module_CPPFLAGS) $(CPPFLAGS) $(syslinuxcfg_module_CFLAGS) $(CFLAGS) -MT commands/syslinuxcfg_module-syslinuxcfg.obj -MD -MP -MF commands/$(DEPDIR)/syslinuxcfg_module-syslinuxcfg.Tpo -c -o commands/syslinuxcfg_module-syslinuxcfg.obj `if test -f 'commands/syslinuxcfg.c'; then $(CYGPATH_W) 'commands/syslinuxcfg.c'; else $(CYGPATH_W) '$(srcdir)/commands/syslinuxcfg.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/syslinuxcfg_module-syslinuxcfg.Tpo commands/$(DEPDIR)/syslinuxcfg_module-syslinuxcfg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/syslinuxcfg.c' object='commands/syslinuxcfg_module-syslinuxcfg.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(syslinuxcfg_module_CPPFLAGS) $(CPPFLAGS) $(syslinuxcfg_module_CFLAGS) $(CFLAGS) -c -o commands/syslinuxcfg_module-syslinuxcfg.obj `if test -f 'commands/syslinuxcfg.c'; then $(CYGPATH_W) 'commands/syslinuxcfg.c'; else $(CYGPATH_W) '$(srcdir)/commands/syslinuxcfg.c'; fi`
+
+fs/tar_module-tar.o: fs/tar.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tar_module_CPPFLAGS) $(CPPFLAGS) $(tar_module_CFLAGS) $(CFLAGS) -MT fs/tar_module-tar.o -MD -MP -MF fs/$(DEPDIR)/tar_module-tar.Tpo -c -o fs/tar_module-tar.o `test -f 'fs/tar.c' || echo '$(srcdir)/'`fs/tar.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/tar_module-tar.Tpo fs/$(DEPDIR)/tar_module-tar.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/tar.c' object='fs/tar_module-tar.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tar_module_CPPFLAGS) $(CPPFLAGS) $(tar_module_CFLAGS) $(CFLAGS) -c -o fs/tar_module-tar.o `test -f 'fs/tar.c' || echo '$(srcdir)/'`fs/tar.c
+
+fs/tar_module-tar.obj: fs/tar.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tar_module_CPPFLAGS) $(CPPFLAGS) $(tar_module_CFLAGS) $(CFLAGS) -MT fs/tar_module-tar.obj -MD -MP -MF fs/$(DEPDIR)/tar_module-tar.Tpo -c -o fs/tar_module-tar.obj `if test -f 'fs/tar.c'; then $(CYGPATH_W) 'fs/tar.c'; else $(CYGPATH_W) '$(srcdir)/fs/tar.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/tar_module-tar.Tpo fs/$(DEPDIR)/tar_module-tar.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/tar.c' object='fs/tar_module-tar.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tar_module_CPPFLAGS) $(CPPFLAGS) $(tar_module_CFLAGS) $(CFLAGS) -c -o fs/tar_module-tar.obj `if test -f 'fs/tar.c'; then $(CYGPATH_W) 'fs/tar.c'; else $(CYGPATH_W) '$(srcdir)/fs/tar.c'; fi`
+
+commands/terminal_module-terminal.o: commands/terminal.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminal_module_CPPFLAGS) $(CPPFLAGS) $(terminal_module_CFLAGS) $(CFLAGS) -MT commands/terminal_module-terminal.o -MD -MP -MF commands/$(DEPDIR)/terminal_module-terminal.Tpo -c -o commands/terminal_module-terminal.o `test -f 'commands/terminal.c' || echo '$(srcdir)/'`commands/terminal.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/terminal_module-terminal.Tpo commands/$(DEPDIR)/terminal_module-terminal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/terminal.c' object='commands/terminal_module-terminal.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminal_module_CPPFLAGS) $(CPPFLAGS) $(terminal_module_CFLAGS) $(CFLAGS) -c -o commands/terminal_module-terminal.o `test -f 'commands/terminal.c' || echo '$(srcdir)/'`commands/terminal.c
+
+commands/terminal_module-terminal.obj: commands/terminal.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminal_module_CPPFLAGS) $(CPPFLAGS) $(terminal_module_CFLAGS) $(CFLAGS) -MT commands/terminal_module-terminal.obj -MD -MP -MF commands/$(DEPDIR)/terminal_module-terminal.Tpo -c -o commands/terminal_module-terminal.obj `if test -f 'commands/terminal.c'; then $(CYGPATH_W) 'commands/terminal.c'; else $(CYGPATH_W) '$(srcdir)/commands/terminal.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/terminal_module-terminal.Tpo commands/$(DEPDIR)/terminal_module-terminal.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/terminal.c' object='commands/terminal_module-terminal.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminal_module_CPPFLAGS) $(CPPFLAGS) $(terminal_module_CFLAGS) $(CFLAGS) -c -o commands/terminal_module-terminal.obj `if test -f 'commands/terminal.c'; then $(CYGPATH_W) 'commands/terminal.c'; else $(CYGPATH_W) '$(srcdir)/commands/terminal.c'; fi`
+
+term/terminfo_module-terminfo.o: term/terminfo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $(terminfo_module_CFLAGS) $(CFLAGS) -MT term/terminfo_module-terminfo.o -MD -MP -MF term/$(DEPDIR)/terminfo_module-terminfo.Tpo -c -o term/terminfo_module-terminfo.o `test -f 'term/terminfo.c' || echo '$(srcdir)/'`term/terminfo.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/terminfo_module-terminfo.Tpo term/$(DEPDIR)/terminfo_module-terminfo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/terminfo.c' object='term/terminfo_module-terminfo.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $(terminfo_module_CFLAGS) $(CFLAGS) -c -o term/terminfo_module-terminfo.o `test -f 'term/terminfo.c' || echo '$(srcdir)/'`term/terminfo.c
+
+term/terminfo_module-terminfo.obj: term/terminfo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $(terminfo_module_CFLAGS) $(CFLAGS) -MT term/terminfo_module-terminfo.obj -MD -MP -MF term/$(DEPDIR)/terminfo_module-terminfo.Tpo -c -o term/terminfo_module-terminfo.obj `if test -f 'term/terminfo.c'; then $(CYGPATH_W) 'term/terminfo.c'; else $(CYGPATH_W) '$(srcdir)/term/terminfo.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/terminfo_module-terminfo.Tpo term/$(DEPDIR)/terminfo_module-terminfo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/terminfo.c' object='term/terminfo_module-terminfo.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $(terminfo_module_CFLAGS) $(CFLAGS) -c -o term/terminfo_module-terminfo.obj `if test -f 'term/terminfo.c'; then $(CYGPATH_W) 'term/terminfo.c'; else $(CYGPATH_W) '$(srcdir)/term/terminfo.c'; fi`
+
+term/terminfo_module-tparm.o: term/tparm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $(terminfo_module_CFLAGS) $(CFLAGS) -MT term/terminfo_module-tparm.o -MD -MP -MF term/$(DEPDIR)/terminfo_module-tparm.Tpo -c -o term/terminfo_module-tparm.o `test -f 'term/tparm.c' || echo '$(srcdir)/'`term/tparm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/terminfo_module-tparm.Tpo term/$(DEPDIR)/terminfo_module-tparm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/tparm.c' object='term/terminfo_module-tparm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $(terminfo_module_CFLAGS) $(CFLAGS) -c -o term/terminfo_module-tparm.o `test -f 'term/tparm.c' || echo '$(srcdir)/'`term/tparm.c
+
+term/terminfo_module-tparm.obj: term/tparm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $(terminfo_module_CFLAGS) $(CFLAGS) -MT term/terminfo_module-tparm.obj -MD -MP -MF term/$(DEPDIR)/terminfo_module-tparm.Tpo -c -o term/terminfo_module-tparm.obj `if test -f 'term/tparm.c'; then $(CYGPATH_W) 'term/tparm.c'; else $(CYGPATH_W) '$(srcdir)/term/tparm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/terminfo_module-tparm.Tpo term/$(DEPDIR)/terminfo_module-tparm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/tparm.c' object='term/terminfo_module-tparm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $(terminfo_module_CFLAGS) $(CFLAGS) -c -o term/terminfo_module-tparm.obj `if test -f 'term/tparm.c'; then $(CYGPATH_W) 'term/tparm.c'; else $(CYGPATH_W) '$(srcdir)/term/tparm.c'; fi`
+
+commands/test_module-test.o: commands/test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_module_CPPFLAGS) $(CPPFLAGS) $(test_module_CFLAGS) $(CFLAGS) -MT commands/test_module-test.o -MD -MP -MF commands/$(DEPDIR)/test_module-test.Tpo -c -o commands/test_module-test.o `test -f 'commands/test.c' || echo '$(srcdir)/'`commands/test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/test_module-test.Tpo commands/$(DEPDIR)/test_module-test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/test.c' object='commands/test_module-test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_module_CPPFLAGS) $(CPPFLAGS) $(test_module_CFLAGS) $(CFLAGS) -c -o commands/test_module-test.o `test -f 'commands/test.c' || echo '$(srcdir)/'`commands/test.c
+
+commands/test_module-test.obj: commands/test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_module_CPPFLAGS) $(CPPFLAGS) $(test_module_CFLAGS) $(CFLAGS) -MT commands/test_module-test.obj -MD -MP -MF commands/$(DEPDIR)/test_module-test.Tpo -c -o commands/test_module-test.obj `if test -f 'commands/test.c'; then $(CYGPATH_W) 'commands/test.c'; else $(CYGPATH_W) '$(srcdir)/commands/test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/test_module-test.Tpo commands/$(DEPDIR)/test_module-test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/test.c' object='commands/test_module-test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_module_CPPFLAGS) $(CPPFLAGS) $(test_module_CFLAGS) $(CFLAGS) -c -o commands/test_module-test.obj `if test -f 'commands/test.c'; then $(CYGPATH_W) 'commands/test.c'; else $(CYGPATH_W) '$(srcdir)/commands/test.c'; fi`
+
+tests/test_blockarg_module-test_blockarg.o: tests/test_blockarg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_blockarg_module_CPPFLAGS) $(CPPFLAGS) $(test_blockarg_module_CFLAGS) $(CFLAGS) -MT tests/test_blockarg_module-test_blockarg.o -MD -MP -MF tests/$(DEPDIR)/test_blockarg_module-test_blockarg.Tpo -c -o tests/test_blockarg_module-test_blockarg.o `test -f 'tests/test_blockarg.c' || echo '$(srcdir)/'`tests/test_blockarg.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/test_blockarg_module-test_blockarg.Tpo tests/$(DEPDIR)/test_blockarg_module-test_blockarg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/test_blockarg.c' object='tests/test_blockarg_module-test_blockarg.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_blockarg_module_CPPFLAGS) $(CPPFLAGS) $(test_blockarg_module_CFLAGS) $(CFLAGS) -c -o tests/test_blockarg_module-test_blockarg.o `test -f 'tests/test_blockarg.c' || echo '$(srcdir)/'`tests/test_blockarg.c
+
+tests/test_blockarg_module-test_blockarg.obj: tests/test_blockarg.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_blockarg_module_CPPFLAGS) $(CPPFLAGS) $(test_blockarg_module_CFLAGS) $(CFLAGS) -MT tests/test_blockarg_module-test_blockarg.obj -MD -MP -MF tests/$(DEPDIR)/test_blockarg_module-test_blockarg.Tpo -c -o tests/test_blockarg_module-test_blockarg.obj `if test -f 'tests/test_blockarg.c'; then $(CYGPATH_W) 'tests/test_blockarg.c'; else $(CYGPATH_W) '$(srcdir)/tests/test_blockarg.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/test_blockarg_module-test_blockarg.Tpo tests/$(DEPDIR)/test_blockarg_module-test_blockarg.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/test_blockarg.c' object='tests/test_blockarg_module-test_blockarg.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_blockarg_module_CPPFLAGS) $(CPPFLAGS) $(test_blockarg_module_CFLAGS) $(CFLAGS) -c -o tests/test_blockarg_module-test_blockarg.obj `if test -f 'tests/test_blockarg.c'; then $(CYGPATH_W) 'tests/test_blockarg.c'; else $(CYGPATH_W) '$(srcdir)/tests/test_blockarg.c'; fi`
+
+commands/testload_module-testload.o: commands/testload.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testload_module_CPPFLAGS) $(CPPFLAGS) $(testload_module_CFLAGS) $(CFLAGS) -MT commands/testload_module-testload.o -MD -MP -MF commands/$(DEPDIR)/testload_module-testload.Tpo -c -o commands/testload_module-testload.o `test -f 'commands/testload.c' || echo '$(srcdir)/'`commands/testload.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/testload_module-testload.Tpo commands/$(DEPDIR)/testload_module-testload.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/testload.c' object='commands/testload_module-testload.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testload_module_CPPFLAGS) $(CPPFLAGS) $(testload_module_CFLAGS) $(CFLAGS) -c -o commands/testload_module-testload.o `test -f 'commands/testload.c' || echo '$(srcdir)/'`commands/testload.c
+
+commands/testload_module-testload.obj: commands/testload.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testload_module_CPPFLAGS) $(CPPFLAGS) $(testload_module_CFLAGS) $(CFLAGS) -MT commands/testload_module-testload.obj -MD -MP -MF commands/$(DEPDIR)/testload_module-testload.Tpo -c -o commands/testload_module-testload.obj `if test -f 'commands/testload.c'; then $(CYGPATH_W) 'commands/testload.c'; else $(CYGPATH_W) '$(srcdir)/commands/testload.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/testload_module-testload.Tpo commands/$(DEPDIR)/testload_module-testload.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/testload.c' object='commands/testload_module-testload.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testload_module_CPPFLAGS) $(CPPFLAGS) $(testload_module_CFLAGS) $(CFLAGS) -c -o commands/testload_module-testload.obj `if test -f 'commands/testload.c'; then $(CYGPATH_W) 'commands/testload.c'; else $(CYGPATH_W) '$(srcdir)/commands/testload.c'; fi`
+
+commands/testspeed_module-testspeed.o: commands/testspeed.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testspeed_module_CPPFLAGS) $(CPPFLAGS) $(testspeed_module_CFLAGS) $(CFLAGS) -MT commands/testspeed_module-testspeed.o -MD -MP -MF commands/$(DEPDIR)/testspeed_module-testspeed.Tpo -c -o commands/testspeed_module-testspeed.o `test -f 'commands/testspeed.c' || echo '$(srcdir)/'`commands/testspeed.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/testspeed_module-testspeed.Tpo commands/$(DEPDIR)/testspeed_module-testspeed.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/testspeed.c' object='commands/testspeed_module-testspeed.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testspeed_module_CPPFLAGS) $(CPPFLAGS) $(testspeed_module_CFLAGS) $(CFLAGS) -c -o commands/testspeed_module-testspeed.o `test -f 'commands/testspeed.c' || echo '$(srcdir)/'`commands/testspeed.c
+
+commands/testspeed_module-testspeed.obj: commands/testspeed.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testspeed_module_CPPFLAGS) $(CPPFLAGS) $(testspeed_module_CFLAGS) $(CFLAGS) -MT commands/testspeed_module-testspeed.obj -MD -MP -MF commands/$(DEPDIR)/testspeed_module-testspeed.Tpo -c -o commands/testspeed_module-testspeed.obj `if test -f 'commands/testspeed.c'; then $(CYGPATH_W) 'commands/testspeed.c'; else $(CYGPATH_W) '$(srcdir)/commands/testspeed.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/testspeed_module-testspeed.Tpo commands/$(DEPDIR)/testspeed_module-testspeed.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/testspeed.c' object='commands/testspeed_module-testspeed.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testspeed_module_CPPFLAGS) $(CPPFLAGS) $(testspeed_module_CFLAGS) $(CFLAGS) -c -o commands/testspeed_module-testspeed.obj `if test -f 'commands/testspeed.c'; then $(CYGPATH_W) 'commands/testspeed.c'; else $(CYGPATH_W) '$(srcdir)/commands/testspeed.c'; fi`
+
+net/tftp_module-tftp.o: net/tftp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tftp_module_CPPFLAGS) $(CPPFLAGS) $(tftp_module_CFLAGS) $(CFLAGS) -MT net/tftp_module-tftp.o -MD -MP -MF net/$(DEPDIR)/tftp_module-tftp.Tpo -c -o net/tftp_module-tftp.o `test -f 'net/tftp.c' || echo '$(srcdir)/'`net/tftp.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/tftp_module-tftp.Tpo net/$(DEPDIR)/tftp_module-tftp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/tftp.c' object='net/tftp_module-tftp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tftp_module_CPPFLAGS) $(CPPFLAGS) $(tftp_module_CFLAGS) $(CFLAGS) -c -o net/tftp_module-tftp.o `test -f 'net/tftp.c' || echo '$(srcdir)/'`net/tftp.c
+
+net/tftp_module-tftp.obj: net/tftp.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tftp_module_CPPFLAGS) $(CPPFLAGS) $(tftp_module_CFLAGS) $(CFLAGS) -MT net/tftp_module-tftp.obj -MD -MP -MF net/$(DEPDIR)/tftp_module-tftp.Tpo -c -o net/tftp_module-tftp.obj `if test -f 'net/tftp.c'; then $(CYGPATH_W) 'net/tftp.c'; else $(CYGPATH_W) '$(srcdir)/net/tftp.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/$(DEPDIR)/tftp_module-tftp.Tpo net/$(DEPDIR)/tftp_module-tftp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/tftp.c' object='net/tftp_module-tftp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tftp_module_CPPFLAGS) $(CPPFLAGS) $(tftp_module_CFLAGS) $(CFLAGS) -c -o net/tftp_module-tftp.obj `if test -f 'net/tftp.c'; then $(CYGPATH_W) 'net/tftp.c'; else $(CYGPATH_W) '$(srcdir)/net/tftp.c'; fi`
+
+video/readers/tga_module-tga.o: video/readers/tga.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tga_module_CPPFLAGS) $(CPPFLAGS) $(tga_module_CFLAGS) $(CFLAGS) -MT video/readers/tga_module-tga.o -MD -MP -MF video/readers/$(DEPDIR)/tga_module-tga.Tpo -c -o video/readers/tga_module-tga.o `test -f 'video/readers/tga.c' || echo '$(srcdir)/'`video/readers/tga.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/readers/$(DEPDIR)/tga_module-tga.Tpo video/readers/$(DEPDIR)/tga_module-tga.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/readers/tga.c' object='video/readers/tga_module-tga.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tga_module_CPPFLAGS) $(CPPFLAGS) $(tga_module_CFLAGS) $(CFLAGS) -c -o video/readers/tga_module-tga.o `test -f 'video/readers/tga.c' || echo '$(srcdir)/'`video/readers/tga.c
+
+video/readers/tga_module-tga.obj: video/readers/tga.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tga_module_CPPFLAGS) $(CPPFLAGS) $(tga_module_CFLAGS) $(CFLAGS) -MT video/readers/tga_module-tga.obj -MD -MP -MF video/readers/$(DEPDIR)/tga_module-tga.Tpo -c -o video/readers/tga_module-tga.obj `if test -f 'video/readers/tga.c'; then $(CYGPATH_W) 'video/readers/tga.c'; else $(CYGPATH_W) '$(srcdir)/video/readers/tga.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/readers/$(DEPDIR)/tga_module-tga.Tpo video/readers/$(DEPDIR)/tga_module-tga.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/readers/tga.c' object='video/readers/tga_module-tga.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tga_module_CPPFLAGS) $(CPPFLAGS) $(tga_module_CFLAGS) $(CFLAGS) -c -o video/readers/tga_module-tga.obj `if test -f 'video/readers/tga.c'; then $(CYGPATH_W) 'video/readers/tga.c'; else $(CYGPATH_W) '$(srcdir)/video/readers/tga.c'; fi`
+
+commands/time_module-time.o: commands/time.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(time_module_CPPFLAGS) $(CPPFLAGS) $(time_module_CFLAGS) $(CFLAGS) -MT commands/time_module-time.o -MD -MP -MF commands/$(DEPDIR)/time_module-time.Tpo -c -o commands/time_module-time.o `test -f 'commands/time.c' || echo '$(srcdir)/'`commands/time.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/time_module-time.Tpo commands/$(DEPDIR)/time_module-time.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/time.c' object='commands/time_module-time.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(time_module_CPPFLAGS) $(CPPFLAGS) $(time_module_CFLAGS) $(CFLAGS) -c -o commands/time_module-time.o `test -f 'commands/time.c' || echo '$(srcdir)/'`commands/time.c
+
+commands/time_module-time.obj: commands/time.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(time_module_CPPFLAGS) $(CPPFLAGS) $(time_module_CFLAGS) $(CFLAGS) -MT commands/time_module-time.obj -MD -MP -MF commands/$(DEPDIR)/time_module-time.Tpo -c -o commands/time_module-time.obj `if test -f 'commands/time.c'; then $(CYGPATH_W) 'commands/time.c'; else $(CYGPATH_W) '$(srcdir)/commands/time.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/time_module-time.Tpo commands/$(DEPDIR)/time_module-time.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/time.c' object='commands/time_module-time.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(time_module_CPPFLAGS) $(CPPFLAGS) $(time_module_CFLAGS) $(CFLAGS) -c -o commands/time_module-time.obj `if test -f 'commands/time.c'; then $(CYGPATH_W) 'commands/time.c'; else $(CYGPATH_W) '$(srcdir)/commands/time.c'; fi`
+
+commands/efi/tpm_module-tpm.o: commands/efi/tpm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $(tpm_module_CFLAGS) $(CFLAGS) -MT commands/efi/tpm_module-tpm.o -MD -MP -MF commands/efi/$(DEPDIR)/tpm_module-tpm.Tpo -c -o commands/efi/tpm_module-tpm.o `test -f 'commands/efi/tpm.c' || echo '$(srcdir)/'`commands/efi/tpm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/tpm_module-tpm.Tpo commands/efi/$(DEPDIR)/tpm_module-tpm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/tpm.c' object='commands/efi/tpm_module-tpm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $(tpm_module_CFLAGS) $(CFLAGS) -c -o commands/efi/tpm_module-tpm.o `test -f 'commands/efi/tpm.c' || echo '$(srcdir)/'`commands/efi/tpm.c
+
+commands/efi/tpm_module-tpm.obj: commands/efi/tpm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $(tpm_module_CFLAGS) $(CFLAGS) -MT commands/efi/tpm_module-tpm.obj -MD -MP -MF commands/efi/$(DEPDIR)/tpm_module-tpm.Tpo -c -o commands/efi/tpm_module-tpm.obj `if test -f 'commands/efi/tpm.c'; then $(CYGPATH_W) 'commands/efi/tpm.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/tpm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/efi/$(DEPDIR)/tpm_module-tpm.Tpo commands/efi/$(DEPDIR)/tpm_module-tpm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/efi/tpm.c' object='commands/efi/tpm_module-tpm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $(tpm_module_CFLAGS) $(CFLAGS) -c -o commands/efi/tpm_module-tpm.obj `if test -f 'commands/efi/tpm.c'; then $(CYGPATH_W) 'commands/efi/tpm.c'; else $(CYGPATH_W) '$(srcdir)/commands/efi/tpm.c'; fi`
+
+commands/tpm_module-tpm.o: commands/tpm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $(tpm_module_CFLAGS) $(CFLAGS) -MT commands/tpm_module-tpm.o -MD -MP -MF commands/$(DEPDIR)/tpm_module-tpm.Tpo -c -o commands/tpm_module-tpm.o `test -f 'commands/tpm.c' || echo '$(srcdir)/'`commands/tpm.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/tpm_module-tpm.Tpo commands/$(DEPDIR)/tpm_module-tpm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/tpm.c' object='commands/tpm_module-tpm.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $(tpm_module_CFLAGS) $(CFLAGS) -c -o commands/tpm_module-tpm.o `test -f 'commands/tpm.c' || echo '$(srcdir)/'`commands/tpm.c
+
+commands/tpm_module-tpm.obj: commands/tpm.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $(tpm_module_CFLAGS) $(CFLAGS) -MT commands/tpm_module-tpm.obj -MD -MP -MF commands/$(DEPDIR)/tpm_module-tpm.Tpo -c -o commands/tpm_module-tpm.obj `if test -f 'commands/tpm.c'; then $(CYGPATH_W) 'commands/tpm.c'; else $(CYGPATH_W) '$(srcdir)/commands/tpm.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/tpm_module-tpm.Tpo commands/$(DEPDIR)/tpm_module-tpm.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/tpm.c' object='commands/tpm_module-tpm.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $(tpm_module_CFLAGS) $(CFLAGS) -c -o commands/tpm_module-tpm.obj `if test -f 'commands/tpm.c'; then $(CYGPATH_W) 'commands/tpm.c'; else $(CYGPATH_W) '$(srcdir)/commands/tpm.c'; fi`
+
+commands/tr_module-tr.o: commands/tr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tr_module_CPPFLAGS) $(CPPFLAGS) $(tr_module_CFLAGS) $(CFLAGS) -MT commands/tr_module-tr.o -MD -MP -MF commands/$(DEPDIR)/tr_module-tr.Tpo -c -o commands/tr_module-tr.o `test -f 'commands/tr.c' || echo '$(srcdir)/'`commands/tr.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/tr_module-tr.Tpo commands/$(DEPDIR)/tr_module-tr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/tr.c' object='commands/tr_module-tr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tr_module_CPPFLAGS) $(CPPFLAGS) $(tr_module_CFLAGS) $(CFLAGS) -c -o commands/tr_module-tr.o `test -f 'commands/tr.c' || echo '$(srcdir)/'`commands/tr.c
+
+commands/tr_module-tr.obj: commands/tr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tr_module_CPPFLAGS) $(CPPFLAGS) $(tr_module_CFLAGS) $(CFLAGS) -MT commands/tr_module-tr.obj -MD -MP -MF commands/$(DEPDIR)/tr_module-tr.Tpo -c -o commands/tr_module-tr.obj `if test -f 'commands/tr.c'; then $(CYGPATH_W) 'commands/tr.c'; else $(CYGPATH_W) '$(srcdir)/commands/tr.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/tr_module-tr.Tpo commands/$(DEPDIR)/tr_module-tr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/tr.c' object='commands/tr_module-tr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tr_module_CPPFLAGS) $(CPPFLAGS) $(tr_module_CFLAGS) $(CFLAGS) -c -o commands/tr_module-tr.obj `if test -f 'commands/tr.c'; then $(CYGPATH_W) 'commands/tr.c'; else $(CYGPATH_W) '$(srcdir)/commands/tr.c'; fi`
+
+trig_module-trigtables.o: trigtables.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(trig_module_CPPFLAGS) $(CPPFLAGS) $(trig_module_CFLAGS) $(CFLAGS) -MT trig_module-trigtables.o -MD -MP -MF $(DEPDIR)/trig_module-trigtables.Tpo -c -o trig_module-trigtables.o `test -f 'trigtables.c' || echo '$(srcdir)/'`trigtables.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/trig_module-trigtables.Tpo $(DEPDIR)/trig_module-trigtables.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='trigtables.c' object='trig_module-trigtables.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(trig_module_CPPFLAGS) $(CPPFLAGS) $(trig_module_CFLAGS) $(CFLAGS) -c -o trig_module-trigtables.o `test -f 'trigtables.c' || echo '$(srcdir)/'`trigtables.c
+
+trig_module-trigtables.obj: trigtables.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(trig_module_CPPFLAGS) $(CPPFLAGS) $(trig_module_CFLAGS) $(CFLAGS) -MT trig_module-trigtables.obj -MD -MP -MF $(DEPDIR)/trig_module-trigtables.Tpo -c -o trig_module-trigtables.obj `if test -f 'trigtables.c'; then $(CYGPATH_W) 'trigtables.c'; else $(CYGPATH_W) '$(srcdir)/trigtables.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/trig_module-trigtables.Tpo $(DEPDIR)/trig_module-trigtables.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='trigtables.c' object='trig_module-trigtables.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(trig_module_CPPFLAGS) $(CPPFLAGS) $(trig_module_CFLAGS) $(CFLAGS) -c -o trig_module-trigtables.obj `if test -f 'trigtables.c'; then $(CYGPATH_W) 'trigtables.c'; else $(CYGPATH_W) '$(srcdir)/trigtables.c'; fi`
+
+commands/true_module-true.o: commands/true.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(true_module_CPPFLAGS) $(CPPFLAGS) $(true_module_CFLAGS) $(CFLAGS) -MT commands/true_module-true.o -MD -MP -MF commands/$(DEPDIR)/true_module-true.Tpo -c -o commands/true_module-true.o `test -f 'commands/true.c' || echo '$(srcdir)/'`commands/true.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/true_module-true.Tpo commands/$(DEPDIR)/true_module-true.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/true.c' object='commands/true_module-true.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(true_module_CPPFLAGS) $(CPPFLAGS) $(true_module_CFLAGS) $(CFLAGS) -c -o commands/true_module-true.o `test -f 'commands/true.c' || echo '$(srcdir)/'`commands/true.c
+
+commands/true_module-true.obj: commands/true.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(true_module_CPPFLAGS) $(CPPFLAGS) $(true_module_CFLAGS) $(CFLAGS) -MT commands/true_module-true.obj -MD -MP -MF commands/$(DEPDIR)/true_module-true.Tpo -c -o commands/true_module-true.obj `if test -f 'commands/true.c'; then $(CYGPATH_W) 'commands/true.c'; else $(CYGPATH_W) '$(srcdir)/commands/true.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/true_module-true.Tpo commands/$(DEPDIR)/true_module-true.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/true.c' object='commands/true_module-true.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(true_module_CPPFLAGS) $(CPPFLAGS) $(true_module_CFLAGS) $(CFLAGS) -c -o commands/true_module-true.obj `if test -f 'commands/true.c'; then $(CYGPATH_W) 'commands/true.c'; else $(CYGPATH_W) '$(srcdir)/commands/true.c'; fi`
+
+loader/i386/pc/truecrypt_module-truecrypt.o: loader/i386/pc/truecrypt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(truecrypt_module_CPPFLAGS) $(CPPFLAGS) $(truecrypt_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/truecrypt_module-truecrypt.o -MD -MP -MF loader/i386/pc/$(DEPDIR)/truecrypt_module-truecrypt.Tpo -c -o loader/i386/pc/truecrypt_module-truecrypt.o `test -f 'loader/i386/pc/truecrypt.c' || echo '$(srcdir)/'`loader/i386/pc/truecrypt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/truecrypt_module-truecrypt.Tpo loader/i386/pc/$(DEPDIR)/truecrypt_module-truecrypt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/truecrypt.c' object='loader/i386/pc/truecrypt_module-truecrypt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(truecrypt_module_CPPFLAGS) $(CPPFLAGS) $(truecrypt_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/truecrypt_module-truecrypt.o `test -f 'loader/i386/pc/truecrypt.c' || echo '$(srcdir)/'`loader/i386/pc/truecrypt.c
+
+loader/i386/pc/truecrypt_module-truecrypt.obj: loader/i386/pc/truecrypt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(truecrypt_module_CPPFLAGS) $(CPPFLAGS) $(truecrypt_module_CFLAGS) $(CFLAGS) -MT loader/i386/pc/truecrypt_module-truecrypt.obj -MD -MP -MF loader/i386/pc/$(DEPDIR)/truecrypt_module-truecrypt.Tpo -c -o loader/i386/pc/truecrypt_module-truecrypt.obj `if test -f 'loader/i386/pc/truecrypt.c'; then $(CYGPATH_W) 'loader/i386/pc/truecrypt.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/truecrypt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/pc/$(DEPDIR)/truecrypt_module-truecrypt.Tpo loader/i386/pc/$(DEPDIR)/truecrypt_module-truecrypt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/pc/truecrypt.c' object='loader/i386/pc/truecrypt_module-truecrypt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(truecrypt_module_CPPFLAGS) $(CPPFLAGS) $(truecrypt_module_CFLAGS) $(CFLAGS) -c -o loader/i386/pc/truecrypt_module-truecrypt.obj `if test -f 'loader/i386/pc/truecrypt.c'; then $(CYGPATH_W) 'loader/i386/pc/truecrypt.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/pc/truecrypt.c'; fi`
+
+net/drivers/uboot/ubootnet_module-ubootnet.o: net/drivers/uboot/ubootnet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ubootnet_module_CPPFLAGS) $(CPPFLAGS) $(ubootnet_module_CFLAGS) $(CFLAGS) -MT net/drivers/uboot/ubootnet_module-ubootnet.o -MD -MP -MF net/drivers/uboot/$(DEPDIR)/ubootnet_module-ubootnet.Tpo -c -o net/drivers/uboot/ubootnet_module-ubootnet.o `test -f 'net/drivers/uboot/ubootnet.c' || echo '$(srcdir)/'`net/drivers/uboot/ubootnet.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/drivers/uboot/$(DEPDIR)/ubootnet_module-ubootnet.Tpo net/drivers/uboot/$(DEPDIR)/ubootnet_module-ubootnet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/drivers/uboot/ubootnet.c' object='net/drivers/uboot/ubootnet_module-ubootnet.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ubootnet_module_CPPFLAGS) $(CPPFLAGS) $(ubootnet_module_CFLAGS) $(CFLAGS) -c -o net/drivers/uboot/ubootnet_module-ubootnet.o `test -f 'net/drivers/uboot/ubootnet.c' || echo '$(srcdir)/'`net/drivers/uboot/ubootnet.c
+
+net/drivers/uboot/ubootnet_module-ubootnet.obj: net/drivers/uboot/ubootnet.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ubootnet_module_CPPFLAGS) $(CPPFLAGS) $(ubootnet_module_CFLAGS) $(CFLAGS) -MT net/drivers/uboot/ubootnet_module-ubootnet.obj -MD -MP -MF net/drivers/uboot/$(DEPDIR)/ubootnet_module-ubootnet.Tpo -c -o net/drivers/uboot/ubootnet_module-ubootnet.obj `if test -f 'net/drivers/uboot/ubootnet.c'; then $(CYGPATH_W) 'net/drivers/uboot/ubootnet.c'; else $(CYGPATH_W) '$(srcdir)/net/drivers/uboot/ubootnet.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) net/drivers/uboot/$(DEPDIR)/ubootnet_module-ubootnet.Tpo net/drivers/uboot/$(DEPDIR)/ubootnet_module-ubootnet.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net/drivers/uboot/ubootnet.c' object='net/drivers/uboot/ubootnet_module-ubootnet.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ubootnet_module_CPPFLAGS) $(CPPFLAGS) $(ubootnet_module_CFLAGS) $(CFLAGS) -c -o net/drivers/uboot/ubootnet_module-ubootnet.obj `if test -f 'net/drivers/uboot/ubootnet.c'; then $(CYGPATH_W) 'net/drivers/uboot/ubootnet.c'; else $(CYGPATH_W) '$(srcdir)/net/drivers/uboot/ubootnet.c'; fi`
+
+fs/udf_module-udf.o: fs/udf.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(udf_module_CPPFLAGS) $(CPPFLAGS) $(udf_module_CFLAGS) $(CFLAGS) -MT fs/udf_module-udf.o -MD -MP -MF fs/$(DEPDIR)/udf_module-udf.Tpo -c -o fs/udf_module-udf.o `test -f 'fs/udf.c' || echo '$(srcdir)/'`fs/udf.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/udf_module-udf.Tpo fs/$(DEPDIR)/udf_module-udf.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/udf.c' object='fs/udf_module-udf.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(udf_module_CPPFLAGS) $(CPPFLAGS) $(udf_module_CFLAGS) $(CFLAGS) -c -o fs/udf_module-udf.o `test -f 'fs/udf.c' || echo '$(srcdir)/'`fs/udf.c
+
+fs/udf_module-udf.obj: fs/udf.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(udf_module_CPPFLAGS) $(CPPFLAGS) $(udf_module_CFLAGS) $(CFLAGS) -MT fs/udf_module-udf.obj -MD -MP -MF fs/$(DEPDIR)/udf_module-udf.Tpo -c -o fs/udf_module-udf.obj `if test -f 'fs/udf.c'; then $(CYGPATH_W) 'fs/udf.c'; else $(CYGPATH_W) '$(srcdir)/fs/udf.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/udf_module-udf.Tpo fs/$(DEPDIR)/udf_module-udf.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/udf.c' object='fs/udf_module-udf.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(udf_module_CPPFLAGS) $(CPPFLAGS) $(udf_module_CFLAGS) $(CFLAGS) -c -o fs/udf_module-udf.obj `if test -f 'fs/udf.c'; then $(CYGPATH_W) 'fs/udf.c'; else $(CYGPATH_W) '$(srcdir)/fs/udf.c'; fi`
+
+fs/ufs1_module-ufs.o: fs/ufs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_module_CPPFLAGS) $(CPPFLAGS) $(ufs1_module_CFLAGS) $(CFLAGS) -MT fs/ufs1_module-ufs.o -MD -MP -MF fs/$(DEPDIR)/ufs1_module-ufs.Tpo -c -o fs/ufs1_module-ufs.o `test -f 'fs/ufs.c' || echo '$(srcdir)/'`fs/ufs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ufs1_module-ufs.Tpo fs/$(DEPDIR)/ufs1_module-ufs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ufs.c' object='fs/ufs1_module-ufs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_module_CPPFLAGS) $(CPPFLAGS) $(ufs1_module_CFLAGS) $(CFLAGS) -c -o fs/ufs1_module-ufs.o `test -f 'fs/ufs.c' || echo '$(srcdir)/'`fs/ufs.c
+
+fs/ufs1_module-ufs.obj: fs/ufs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_module_CPPFLAGS) $(CPPFLAGS) $(ufs1_module_CFLAGS) $(CFLAGS) -MT fs/ufs1_module-ufs.obj -MD -MP -MF fs/$(DEPDIR)/ufs1_module-ufs.Tpo -c -o fs/ufs1_module-ufs.obj `if test -f 'fs/ufs.c'; then $(CYGPATH_W) 'fs/ufs.c'; else $(CYGPATH_W) '$(srcdir)/fs/ufs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ufs1_module-ufs.Tpo fs/$(DEPDIR)/ufs1_module-ufs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ufs.c' object='fs/ufs1_module-ufs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_module_CPPFLAGS) $(CPPFLAGS) $(ufs1_module_CFLAGS) $(CFLAGS) -c -o fs/ufs1_module-ufs.obj `if test -f 'fs/ufs.c'; then $(CYGPATH_W) 'fs/ufs.c'; else $(CYGPATH_W) '$(srcdir)/fs/ufs.c'; fi`
+
+fs/ufs1_be_module-ufs_be.o: fs/ufs_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_be_module_CPPFLAGS) $(CPPFLAGS) $(ufs1_be_module_CFLAGS) $(CFLAGS) -MT fs/ufs1_be_module-ufs_be.o -MD -MP -MF fs/$(DEPDIR)/ufs1_be_module-ufs_be.Tpo -c -o fs/ufs1_be_module-ufs_be.o `test -f 'fs/ufs_be.c' || echo '$(srcdir)/'`fs/ufs_be.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ufs1_be_module-ufs_be.Tpo fs/$(DEPDIR)/ufs1_be_module-ufs_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ufs_be.c' object='fs/ufs1_be_module-ufs_be.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_be_module_CPPFLAGS) $(CPPFLAGS) $(ufs1_be_module_CFLAGS) $(CFLAGS) -c -o fs/ufs1_be_module-ufs_be.o `test -f 'fs/ufs_be.c' || echo '$(srcdir)/'`fs/ufs_be.c
+
+fs/ufs1_be_module-ufs_be.obj: fs/ufs_be.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_be_module_CPPFLAGS) $(CPPFLAGS) $(ufs1_be_module_CFLAGS) $(CFLAGS) -MT fs/ufs1_be_module-ufs_be.obj -MD -MP -MF fs/$(DEPDIR)/ufs1_be_module-ufs_be.Tpo -c -o fs/ufs1_be_module-ufs_be.obj `if test -f 'fs/ufs_be.c'; then $(CYGPATH_W) 'fs/ufs_be.c'; else $(CYGPATH_W) '$(srcdir)/fs/ufs_be.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ufs1_be_module-ufs_be.Tpo fs/$(DEPDIR)/ufs1_be_module-ufs_be.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ufs_be.c' object='fs/ufs1_be_module-ufs_be.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_be_module_CPPFLAGS) $(CPPFLAGS) $(ufs1_be_module_CFLAGS) $(CFLAGS) -c -o fs/ufs1_be_module-ufs_be.obj `if test -f 'fs/ufs_be.c'; then $(CYGPATH_W) 'fs/ufs_be.c'; else $(CYGPATH_W) '$(srcdir)/fs/ufs_be.c'; fi`
+
+fs/ufs2_module-ufs2.o: fs/ufs2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs2_module_CPPFLAGS) $(CPPFLAGS) $(ufs2_module_CFLAGS) $(CFLAGS) -MT fs/ufs2_module-ufs2.o -MD -MP -MF fs/$(DEPDIR)/ufs2_module-ufs2.Tpo -c -o fs/ufs2_module-ufs2.o `test -f 'fs/ufs2.c' || echo '$(srcdir)/'`fs/ufs2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ufs2_module-ufs2.Tpo fs/$(DEPDIR)/ufs2_module-ufs2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ufs2.c' object='fs/ufs2_module-ufs2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs2_module_CPPFLAGS) $(CPPFLAGS) $(ufs2_module_CFLAGS) $(CFLAGS) -c -o fs/ufs2_module-ufs2.o `test -f 'fs/ufs2.c' || echo '$(srcdir)/'`fs/ufs2.c
+
+fs/ufs2_module-ufs2.obj: fs/ufs2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs2_module_CPPFLAGS) $(CPPFLAGS) $(ufs2_module_CFLAGS) $(CFLAGS) -MT fs/ufs2_module-ufs2.obj -MD -MP -MF fs/$(DEPDIR)/ufs2_module-ufs2.Tpo -c -o fs/ufs2_module-ufs2.obj `if test -f 'fs/ufs2.c'; then $(CYGPATH_W) 'fs/ufs2.c'; else $(CYGPATH_W) '$(srcdir)/fs/ufs2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/ufs2_module-ufs2.Tpo fs/$(DEPDIR)/ufs2_module-ufs2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/ufs2.c' object='fs/ufs2_module-ufs2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs2_module_CPPFLAGS) $(CPPFLAGS) $(ufs2_module_CFLAGS) $(CFLAGS) -c -o fs/ufs2_module-ufs2.obj `if test -f 'fs/ufs2.c'; then $(CYGPATH_W) 'fs/ufs2.c'; else $(CYGPATH_W) '$(srcdir)/fs/ufs2.c'; fi`
+
+bus/usb/uhci_module-uhci.o: bus/usb/uhci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $(uhci_module_CFLAGS) $(CFLAGS) -MT bus/usb/uhci_module-uhci.o -MD -MP -MF bus/usb/$(DEPDIR)/uhci_module-uhci.Tpo -c -o bus/usb/uhci_module-uhci.o `test -f 'bus/usb/uhci.c' || echo '$(srcdir)/'`bus/usb/uhci.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/uhci_module-uhci.Tpo bus/usb/$(DEPDIR)/uhci_module-uhci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/uhci.c' object='bus/usb/uhci_module-uhci.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $(uhci_module_CFLAGS) $(CFLAGS) -c -o bus/usb/uhci_module-uhci.o `test -f 'bus/usb/uhci.c' || echo '$(srcdir)/'`bus/usb/uhci.c
+
+bus/usb/uhci_module-uhci.obj: bus/usb/uhci.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $(uhci_module_CFLAGS) $(CFLAGS) -MT bus/usb/uhci_module-uhci.obj -MD -MP -MF bus/usb/$(DEPDIR)/uhci_module-uhci.Tpo -c -o bus/usb/uhci_module-uhci.obj `if test -f 'bus/usb/uhci.c'; then $(CYGPATH_W) 'bus/usb/uhci.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/uhci.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/uhci_module-uhci.Tpo bus/usb/$(DEPDIR)/uhci_module-uhci.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/uhci.c' object='bus/usb/uhci_module-uhci.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $(uhci_module_CFLAGS) $(CFLAGS) -c -o bus/usb/uhci_module-uhci.obj `if test -f 'bus/usb/uhci.c'; then $(CYGPATH_W) 'bus/usb/uhci.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/uhci.c'; fi`
+
+bus/usb/usb_module-usb.o: bus/usb/usb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -MT bus/usb/usb_module-usb.o -MD -MP -MF bus/usb/$(DEPDIR)/usb_module-usb.Tpo -c -o bus/usb/usb_module-usb.o `test -f 'bus/usb/usb.c' || echo '$(srcdir)/'`bus/usb/usb.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/usb_module-usb.Tpo bus/usb/$(DEPDIR)/usb_module-usb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/usb.c' object='bus/usb/usb_module-usb.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -c -o bus/usb/usb_module-usb.o `test -f 'bus/usb/usb.c' || echo '$(srcdir)/'`bus/usb/usb.c
+
+bus/usb/usb_module-usb.obj: bus/usb/usb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -MT bus/usb/usb_module-usb.obj -MD -MP -MF bus/usb/$(DEPDIR)/usb_module-usb.Tpo -c -o bus/usb/usb_module-usb.obj `if test -f 'bus/usb/usb.c'; then $(CYGPATH_W) 'bus/usb/usb.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/usb.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/usb_module-usb.Tpo bus/usb/$(DEPDIR)/usb_module-usb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/usb.c' object='bus/usb/usb_module-usb.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -c -o bus/usb/usb_module-usb.obj `if test -f 'bus/usb/usb.c'; then $(CYGPATH_W) 'bus/usb/usb.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/usb.c'; fi`
+
+bus/usb/usb_module-usbtrans.o: bus/usb/usbtrans.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -MT bus/usb/usb_module-usbtrans.o -MD -MP -MF bus/usb/$(DEPDIR)/usb_module-usbtrans.Tpo -c -o bus/usb/usb_module-usbtrans.o `test -f 'bus/usb/usbtrans.c' || echo '$(srcdir)/'`bus/usb/usbtrans.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/usb_module-usbtrans.Tpo bus/usb/$(DEPDIR)/usb_module-usbtrans.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/usbtrans.c' object='bus/usb/usb_module-usbtrans.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -c -o bus/usb/usb_module-usbtrans.o `test -f 'bus/usb/usbtrans.c' || echo '$(srcdir)/'`bus/usb/usbtrans.c
+
+bus/usb/usb_module-usbtrans.obj: bus/usb/usbtrans.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -MT bus/usb/usb_module-usbtrans.obj -MD -MP -MF bus/usb/$(DEPDIR)/usb_module-usbtrans.Tpo -c -o bus/usb/usb_module-usbtrans.obj `if test -f 'bus/usb/usbtrans.c'; then $(CYGPATH_W) 'bus/usb/usbtrans.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/usbtrans.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/usb_module-usbtrans.Tpo bus/usb/$(DEPDIR)/usb_module-usbtrans.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/usbtrans.c' object='bus/usb/usb_module-usbtrans.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -c -o bus/usb/usb_module-usbtrans.obj `if test -f 'bus/usb/usbtrans.c'; then $(CYGPATH_W) 'bus/usb/usbtrans.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/usbtrans.c'; fi`
+
+bus/usb/usb_module-usbhub.o: bus/usb/usbhub.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -MT bus/usb/usb_module-usbhub.o -MD -MP -MF bus/usb/$(DEPDIR)/usb_module-usbhub.Tpo -c -o bus/usb/usb_module-usbhub.o `test -f 'bus/usb/usbhub.c' || echo '$(srcdir)/'`bus/usb/usbhub.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/usb_module-usbhub.Tpo bus/usb/$(DEPDIR)/usb_module-usbhub.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/usbhub.c' object='bus/usb/usb_module-usbhub.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -c -o bus/usb/usb_module-usbhub.o `test -f 'bus/usb/usbhub.c' || echo '$(srcdir)/'`bus/usb/usbhub.c
+
+bus/usb/usb_module-usbhub.obj: bus/usb/usbhub.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -MT bus/usb/usb_module-usbhub.obj -MD -MP -MF bus/usb/$(DEPDIR)/usb_module-usbhub.Tpo -c -o bus/usb/usb_module-usbhub.obj `if test -f 'bus/usb/usbhub.c'; then $(CYGPATH_W) 'bus/usb/usbhub.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/usbhub.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/$(DEPDIR)/usb_module-usbhub.Tpo bus/usb/$(DEPDIR)/usb_module-usbhub.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/usbhub.c' object='bus/usb/usb_module-usbhub.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $(usb_module_CFLAGS) $(CFLAGS) -c -o bus/usb/usb_module-usbhub.obj `if test -f 'bus/usb/usbhub.c'; then $(CYGPATH_W) 'bus/usb/usbhub.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/usbhub.c'; fi`
+
+term/usb_keyboard_module-usb_keyboard.o: term/usb_keyboard.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(usb_keyboard_module_CFLAGS) $(CFLAGS) -MT term/usb_keyboard_module-usb_keyboard.o -MD -MP -MF term/$(DEPDIR)/usb_keyboard_module-usb_keyboard.Tpo -c -o term/usb_keyboard_module-usb_keyboard.o `test -f 'term/usb_keyboard.c' || echo '$(srcdir)/'`term/usb_keyboard.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/usb_keyboard_module-usb_keyboard.Tpo term/$(DEPDIR)/usb_keyboard_module-usb_keyboard.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/usb_keyboard.c' object='term/usb_keyboard_module-usb_keyboard.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(usb_keyboard_module_CFLAGS) $(CFLAGS) -c -o term/usb_keyboard_module-usb_keyboard.o `test -f 'term/usb_keyboard.c' || echo '$(srcdir)/'`term/usb_keyboard.c
+
+term/usb_keyboard_module-usb_keyboard.obj: term/usb_keyboard.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(usb_keyboard_module_CFLAGS) $(CFLAGS) -MT term/usb_keyboard_module-usb_keyboard.obj -MD -MP -MF term/$(DEPDIR)/usb_keyboard_module-usb_keyboard.Tpo -c -o term/usb_keyboard_module-usb_keyboard.obj `if test -f 'term/usb_keyboard.c'; then $(CYGPATH_W) 'term/usb_keyboard.c'; else $(CYGPATH_W) '$(srcdir)/term/usb_keyboard.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/$(DEPDIR)/usb_keyboard_module-usb_keyboard.Tpo term/$(DEPDIR)/usb_keyboard_module-usb_keyboard.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/usb_keyboard.c' object='term/usb_keyboard_module-usb_keyboard.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $(usb_keyboard_module_CFLAGS) $(CFLAGS) -c -o term/usb_keyboard_module-usb_keyboard.obj `if test -f 'term/usb_keyboard.c'; then $(CYGPATH_W) 'term/usb_keyboard.c'; else $(CYGPATH_W) '$(srcdir)/term/usb_keyboard.c'; fi`
+
+disk/usbms_module-usbms.o: disk/usbms.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $(usbms_module_CFLAGS) $(CFLAGS) -MT disk/usbms_module-usbms.o -MD -MP -MF disk/$(DEPDIR)/usbms_module-usbms.Tpo -c -o disk/usbms_module-usbms.o `test -f 'disk/usbms.c' || echo '$(srcdir)/'`disk/usbms.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/usbms_module-usbms.Tpo disk/$(DEPDIR)/usbms_module-usbms.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/usbms.c' object='disk/usbms_module-usbms.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $(usbms_module_CFLAGS) $(CFLAGS) -c -o disk/usbms_module-usbms.o `test -f 'disk/usbms.c' || echo '$(srcdir)/'`disk/usbms.c
+
+disk/usbms_module-usbms.obj: disk/usbms.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $(usbms_module_CFLAGS) $(CFLAGS) -MT disk/usbms_module-usbms.obj -MD -MP -MF disk/$(DEPDIR)/usbms_module-usbms.Tpo -c -o disk/usbms_module-usbms.obj `if test -f 'disk/usbms.c'; then $(CYGPATH_W) 'disk/usbms.c'; else $(CYGPATH_W) '$(srcdir)/disk/usbms.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) disk/$(DEPDIR)/usbms_module-usbms.Tpo disk/$(DEPDIR)/usbms_module-usbms.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='disk/usbms.c' object='disk/usbms_module-usbms.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $(usbms_module_CFLAGS) $(CFLAGS) -c -o disk/usbms_module-usbms.obj `if test -f 'disk/usbms.c'; then $(CYGPATH_W) 'disk/usbms.c'; else $(CYGPATH_W) '$(srcdir)/disk/usbms.c'; fi`
+
+bus/usb/serial/usbserial_common_module-common.o: bus/usb/serial/common.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_common_module_CFLAGS) $(CFLAGS) -MT bus/usb/serial/usbserial_common_module-common.o -MD -MP -MF bus/usb/serial/$(DEPDIR)/usbserial_common_module-common.Tpo -c -o bus/usb/serial/usbserial_common_module-common.o `test -f 'bus/usb/serial/common.c' || echo '$(srcdir)/'`bus/usb/serial/common.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/serial/$(DEPDIR)/usbserial_common_module-common.Tpo bus/usb/serial/$(DEPDIR)/usbserial_common_module-common.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/serial/common.c' object='bus/usb/serial/usbserial_common_module-common.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_common_module_CFLAGS) $(CFLAGS) -c -o bus/usb/serial/usbserial_common_module-common.o `test -f 'bus/usb/serial/common.c' || echo '$(srcdir)/'`bus/usb/serial/common.c
+
+bus/usb/serial/usbserial_common_module-common.obj: bus/usb/serial/common.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_common_module_CFLAGS) $(CFLAGS) -MT bus/usb/serial/usbserial_common_module-common.obj -MD -MP -MF bus/usb/serial/$(DEPDIR)/usbserial_common_module-common.Tpo -c -o bus/usb/serial/usbserial_common_module-common.obj `if test -f 'bus/usb/serial/common.c'; then $(CYGPATH_W) 'bus/usb/serial/common.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/serial/common.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/serial/$(DEPDIR)/usbserial_common_module-common.Tpo bus/usb/serial/$(DEPDIR)/usbserial_common_module-common.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/serial/common.c' object='bus/usb/serial/usbserial_common_module-common.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_common_module_CFLAGS) $(CFLAGS) -c -o bus/usb/serial/usbserial_common_module-common.obj `if test -f 'bus/usb/serial/common.c'; then $(CYGPATH_W) 'bus/usb/serial/common.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/serial/common.c'; fi`
+
+bus/usb/serial/usbserial_ftdi_module-ftdi.o: bus/usb/serial/ftdi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_ftdi_module_CFLAGS) $(CFLAGS) -MT bus/usb/serial/usbserial_ftdi_module-ftdi.o -MD -MP -MF bus/usb/serial/$(DEPDIR)/usbserial_ftdi_module-ftdi.Tpo -c -o bus/usb/serial/usbserial_ftdi_module-ftdi.o `test -f 'bus/usb/serial/ftdi.c' || echo '$(srcdir)/'`bus/usb/serial/ftdi.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/serial/$(DEPDIR)/usbserial_ftdi_module-ftdi.Tpo bus/usb/serial/$(DEPDIR)/usbserial_ftdi_module-ftdi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/serial/ftdi.c' object='bus/usb/serial/usbserial_ftdi_module-ftdi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_ftdi_module_CFLAGS) $(CFLAGS) -c -o bus/usb/serial/usbserial_ftdi_module-ftdi.o `test -f 'bus/usb/serial/ftdi.c' || echo '$(srcdir)/'`bus/usb/serial/ftdi.c
+
+bus/usb/serial/usbserial_ftdi_module-ftdi.obj: bus/usb/serial/ftdi.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_ftdi_module_CFLAGS) $(CFLAGS) -MT bus/usb/serial/usbserial_ftdi_module-ftdi.obj -MD -MP -MF bus/usb/serial/$(DEPDIR)/usbserial_ftdi_module-ftdi.Tpo -c -o bus/usb/serial/usbserial_ftdi_module-ftdi.obj `if test -f 'bus/usb/serial/ftdi.c'; then $(CYGPATH_W) 'bus/usb/serial/ftdi.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/serial/ftdi.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/serial/$(DEPDIR)/usbserial_ftdi_module-ftdi.Tpo bus/usb/serial/$(DEPDIR)/usbserial_ftdi_module-ftdi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/serial/ftdi.c' object='bus/usb/serial/usbserial_ftdi_module-ftdi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_ftdi_module_CFLAGS) $(CFLAGS) -c -o bus/usb/serial/usbserial_ftdi_module-ftdi.obj `if test -f 'bus/usb/serial/ftdi.c'; then $(CYGPATH_W) 'bus/usb/serial/ftdi.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/serial/ftdi.c'; fi`
+
+bus/usb/serial/usbserial_pl2303_module-pl2303.o: bus/usb/serial/pl2303.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_pl2303_module_CFLAGS) $(CFLAGS) -MT bus/usb/serial/usbserial_pl2303_module-pl2303.o -MD -MP -MF bus/usb/serial/$(DEPDIR)/usbserial_pl2303_module-pl2303.Tpo -c -o bus/usb/serial/usbserial_pl2303_module-pl2303.o `test -f 'bus/usb/serial/pl2303.c' || echo '$(srcdir)/'`bus/usb/serial/pl2303.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/serial/$(DEPDIR)/usbserial_pl2303_module-pl2303.Tpo bus/usb/serial/$(DEPDIR)/usbserial_pl2303_module-pl2303.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/serial/pl2303.c' object='bus/usb/serial/usbserial_pl2303_module-pl2303.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_pl2303_module_CFLAGS) $(CFLAGS) -c -o bus/usb/serial/usbserial_pl2303_module-pl2303.o `test -f 'bus/usb/serial/pl2303.c' || echo '$(srcdir)/'`bus/usb/serial/pl2303.c
+
+bus/usb/serial/usbserial_pl2303_module-pl2303.obj: bus/usb/serial/pl2303.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_pl2303_module_CFLAGS) $(CFLAGS) -MT bus/usb/serial/usbserial_pl2303_module-pl2303.obj -MD -MP -MF bus/usb/serial/$(DEPDIR)/usbserial_pl2303_module-pl2303.Tpo -c -o bus/usb/serial/usbserial_pl2303_module-pl2303.obj `if test -f 'bus/usb/serial/pl2303.c'; then $(CYGPATH_W) 'bus/usb/serial/pl2303.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/serial/pl2303.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/serial/$(DEPDIR)/usbserial_pl2303_module-pl2303.Tpo bus/usb/serial/$(DEPDIR)/usbserial_pl2303_module-pl2303.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/serial/pl2303.c' object='bus/usb/serial/usbserial_pl2303_module-pl2303.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_pl2303_module_CFLAGS) $(CFLAGS) -c -o bus/usb/serial/usbserial_pl2303_module-pl2303.obj `if test -f 'bus/usb/serial/pl2303.c'; then $(CYGPATH_W) 'bus/usb/serial/pl2303.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/serial/pl2303.c'; fi`
+
+bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.o: bus/usb/serial/usbdebug_late.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_usbdebug_module_CFLAGS) $(CFLAGS) -MT bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.o -MD -MP -MF bus/usb/serial/$(DEPDIR)/usbserial_usbdebug_module-usbdebug_late.Tpo -c -o bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.o `test -f 'bus/usb/serial/usbdebug_late.c' || echo '$(srcdir)/'`bus/usb/serial/usbdebug_late.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/serial/$(DEPDIR)/usbserial_usbdebug_module-usbdebug_late.Tpo bus/usb/serial/$(DEPDIR)/usbserial_usbdebug_module-usbdebug_late.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/serial/usbdebug_late.c' object='bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_usbdebug_module_CFLAGS) $(CFLAGS) -c -o bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.o `test -f 'bus/usb/serial/usbdebug_late.c' || echo '$(srcdir)/'`bus/usb/serial/usbdebug_late.c
+
+bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.obj: bus/usb/serial/usbdebug_late.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_usbdebug_module_CFLAGS) $(CFLAGS) -MT bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.obj -MD -MP -MF bus/usb/serial/$(DEPDIR)/usbserial_usbdebug_module-usbdebug_late.Tpo -c -o bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.obj `if test -f 'bus/usb/serial/usbdebug_late.c'; then $(CYGPATH_W) 'bus/usb/serial/usbdebug_late.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/serial/usbdebug_late.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bus/usb/serial/$(DEPDIR)/usbserial_usbdebug_module-usbdebug_late.Tpo bus/usb/serial/$(DEPDIR)/usbserial_usbdebug_module-usbdebug_late.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bus/usb/serial/usbdebug_late.c' object='bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $(usbserial_usbdebug_module_CFLAGS) $(CFLAGS) -c -o bus/usb/serial/usbserial_usbdebug_module-usbdebug_late.obj `if test -f 'bus/usb/serial/usbdebug_late.c'; then $(CYGPATH_W) 'bus/usb/serial/usbdebug_late.c'; else $(CYGPATH_W) '$(srcdir)/bus/usb/serial/usbdebug_late.c'; fi`
+
+commands/usbtest_module-usbtest.o: commands/usbtest.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $(usbtest_module_CFLAGS) $(CFLAGS) -MT commands/usbtest_module-usbtest.o -MD -MP -MF commands/$(DEPDIR)/usbtest_module-usbtest.Tpo -c -o commands/usbtest_module-usbtest.o `test -f 'commands/usbtest.c' || echo '$(srcdir)/'`commands/usbtest.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/usbtest_module-usbtest.Tpo commands/$(DEPDIR)/usbtest_module-usbtest.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/usbtest.c' object='commands/usbtest_module-usbtest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $(usbtest_module_CFLAGS) $(CFLAGS) -c -o commands/usbtest_module-usbtest.o `test -f 'commands/usbtest.c' || echo '$(srcdir)/'`commands/usbtest.c
+
+commands/usbtest_module-usbtest.obj: commands/usbtest.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $(usbtest_module_CFLAGS) $(CFLAGS) -MT commands/usbtest_module-usbtest.obj -MD -MP -MF commands/$(DEPDIR)/usbtest_module-usbtest.Tpo -c -o commands/usbtest_module-usbtest.obj `if test -f 'commands/usbtest.c'; then $(CYGPATH_W) 'commands/usbtest.c'; else $(CYGPATH_W) '$(srcdir)/commands/usbtest.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/usbtest_module-usbtest.Tpo commands/$(DEPDIR)/usbtest_module-usbtest.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/usbtest.c' object='commands/usbtest_module-usbtest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $(usbtest_module_CFLAGS) $(CFLAGS) -c -o commands/usbtest_module-usbtest.obj `if test -f 'commands/usbtest.c'; then $(CYGPATH_W) 'commands/usbtest.c'; else $(CYGPATH_W) '$(srcdir)/commands/usbtest.c'; fi`
+
+video/i386/pc/vbe_module-vbe.o: video/i386/pc/vbe.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vbe_module_CPPFLAGS) $(CPPFLAGS) $(vbe_module_CFLAGS) $(CFLAGS) -MT video/i386/pc/vbe_module-vbe.o -MD -MP -MF video/i386/pc/$(DEPDIR)/vbe_module-vbe.Tpo -c -o video/i386/pc/vbe_module-vbe.o `test -f 'video/i386/pc/vbe.c' || echo '$(srcdir)/'`video/i386/pc/vbe.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/i386/pc/$(DEPDIR)/vbe_module-vbe.Tpo video/i386/pc/$(DEPDIR)/vbe_module-vbe.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/i386/pc/vbe.c' object='video/i386/pc/vbe_module-vbe.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vbe_module_CPPFLAGS) $(CPPFLAGS) $(vbe_module_CFLAGS) $(CFLAGS) -c -o video/i386/pc/vbe_module-vbe.o `test -f 'video/i386/pc/vbe.c' || echo '$(srcdir)/'`video/i386/pc/vbe.c
+
+video/i386/pc/vbe_module-vbe.obj: video/i386/pc/vbe.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vbe_module_CPPFLAGS) $(CPPFLAGS) $(vbe_module_CFLAGS) $(CFLAGS) -MT video/i386/pc/vbe_module-vbe.obj -MD -MP -MF video/i386/pc/$(DEPDIR)/vbe_module-vbe.Tpo -c -o video/i386/pc/vbe_module-vbe.obj `if test -f 'video/i386/pc/vbe.c'; then $(CYGPATH_W) 'video/i386/pc/vbe.c'; else $(CYGPATH_W) '$(srcdir)/video/i386/pc/vbe.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/i386/pc/$(DEPDIR)/vbe_module-vbe.Tpo video/i386/pc/$(DEPDIR)/vbe_module-vbe.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/i386/pc/vbe.c' object='video/i386/pc/vbe_module-vbe.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vbe_module_CPPFLAGS) $(CPPFLAGS) $(vbe_module_CFLAGS) $(CFLAGS) -c -o video/i386/pc/vbe_module-vbe.obj `if test -f 'video/i386/pc/vbe.c'; then $(CYGPATH_W) 'video/i386/pc/vbe.c'; else $(CYGPATH_W) '$(srcdir)/video/i386/pc/vbe.c'; fi`
+
+video/i386/pc/vga_module-vga.o: video/i386/pc/vga.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_module_CPPFLAGS) $(CPPFLAGS) $(vga_module_CFLAGS) $(CFLAGS) -MT video/i386/pc/vga_module-vga.o -MD -MP -MF video/i386/pc/$(DEPDIR)/vga_module-vga.Tpo -c -o video/i386/pc/vga_module-vga.o `test -f 'video/i386/pc/vga.c' || echo '$(srcdir)/'`video/i386/pc/vga.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/i386/pc/$(DEPDIR)/vga_module-vga.Tpo video/i386/pc/$(DEPDIR)/vga_module-vga.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/i386/pc/vga.c' object='video/i386/pc/vga_module-vga.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_module_CPPFLAGS) $(CPPFLAGS) $(vga_module_CFLAGS) $(CFLAGS) -c -o video/i386/pc/vga_module-vga.o `test -f 'video/i386/pc/vga.c' || echo '$(srcdir)/'`video/i386/pc/vga.c
+
+video/i386/pc/vga_module-vga.obj: video/i386/pc/vga.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_module_CPPFLAGS) $(CPPFLAGS) $(vga_module_CFLAGS) $(CFLAGS) -MT video/i386/pc/vga_module-vga.obj -MD -MP -MF video/i386/pc/$(DEPDIR)/vga_module-vga.Tpo -c -o video/i386/pc/vga_module-vga.obj `if test -f 'video/i386/pc/vga.c'; then $(CYGPATH_W) 'video/i386/pc/vga.c'; else $(CYGPATH_W) '$(srcdir)/video/i386/pc/vga.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/i386/pc/$(DEPDIR)/vga_module-vga.Tpo video/i386/pc/$(DEPDIR)/vga_module-vga.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/i386/pc/vga.c' object='video/i386/pc/vga_module-vga.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_module_CPPFLAGS) $(CPPFLAGS) $(vga_module_CFLAGS) $(CFLAGS) -c -o video/i386/pc/vga_module-vga.obj `if test -f 'video/i386/pc/vga.c'; then $(CYGPATH_W) 'video/i386/pc/vga.c'; else $(CYGPATH_W) '$(srcdir)/video/i386/pc/vga.c'; fi`
+
+term/i386/pc/vga_text_module-vga_text.o: term/i386/pc/vga_text.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_text_module_CPPFLAGS) $(CPPFLAGS) $(vga_text_module_CFLAGS) $(CFLAGS) -MT term/i386/pc/vga_text_module-vga_text.o -MD -MP -MF term/i386/pc/$(DEPDIR)/vga_text_module-vga_text.Tpo -c -o term/i386/pc/vga_text_module-vga_text.o `test -f 'term/i386/pc/vga_text.c' || echo '$(srcdir)/'`term/i386/pc/vga_text.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/i386/pc/$(DEPDIR)/vga_text_module-vga_text.Tpo term/i386/pc/$(DEPDIR)/vga_text_module-vga_text.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/i386/pc/vga_text.c' object='term/i386/pc/vga_text_module-vga_text.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_text_module_CPPFLAGS) $(CPPFLAGS) $(vga_text_module_CFLAGS) $(CFLAGS) -c -o term/i386/pc/vga_text_module-vga_text.o `test -f 'term/i386/pc/vga_text.c' || echo '$(srcdir)/'`term/i386/pc/vga_text.c
+
+term/i386/pc/vga_text_module-vga_text.obj: term/i386/pc/vga_text.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_text_module_CPPFLAGS) $(CPPFLAGS) $(vga_text_module_CFLAGS) $(CFLAGS) -MT term/i386/pc/vga_text_module-vga_text.obj -MD -MP -MF term/i386/pc/$(DEPDIR)/vga_text_module-vga_text.Tpo -c -o term/i386/pc/vga_text_module-vga_text.obj `if test -f 'term/i386/pc/vga_text.c'; then $(CYGPATH_W) 'term/i386/pc/vga_text.c'; else $(CYGPATH_W) '$(srcdir)/term/i386/pc/vga_text.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) term/i386/pc/$(DEPDIR)/vga_text_module-vga_text.Tpo term/i386/pc/$(DEPDIR)/vga_text_module-vga_text.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='term/i386/pc/vga_text.c' object='term/i386/pc/vga_text_module-vga_text.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_text_module_CPPFLAGS) $(CPPFLAGS) $(vga_text_module_CFLAGS) $(CFLAGS) -c -o term/i386/pc/vga_text_module-vga_text.obj `if test -f 'term/i386/pc/vga_text.c'; then $(CYGPATH_W) 'term/i386/pc/vga_text.c'; else $(CYGPATH_W) '$(srcdir)/term/i386/pc/vga_text.c'; fi`
+
+video/video_module-video.o: video/video.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $(video_module_CFLAGS) $(CFLAGS) -MT video/video_module-video.o -MD -MP -MF video/$(DEPDIR)/video_module-video.Tpo -c -o video/video_module-video.o `test -f 'video/video.c' || echo '$(srcdir)/'`video/video.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/video_module-video.Tpo video/$(DEPDIR)/video_module-video.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/video.c' object='video/video_module-video.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $(video_module_CFLAGS) $(CFLAGS) -c -o video/video_module-video.o `test -f 'video/video.c' || echo '$(srcdir)/'`video/video.c
+
+video/video_module-video.obj: video/video.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $(video_module_CFLAGS) $(CFLAGS) -MT video/video_module-video.obj -MD -MP -MF video/$(DEPDIR)/video_module-video.Tpo -c -o video/video_module-video.obj `if test -f 'video/video.c'; then $(CYGPATH_W) 'video/video.c'; else $(CYGPATH_W) '$(srcdir)/video/video.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/video_module-video.Tpo video/$(DEPDIR)/video_module-video.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/video.c' object='video/video_module-video.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $(video_module_CFLAGS) $(CFLAGS) -c -o video/video_module-video.obj `if test -f 'video/video.c'; then $(CYGPATH_W) 'video/video.c'; else $(CYGPATH_W) '$(srcdir)/video/video.c'; fi`
+
+video/video_bochs_module-bochs.o: video/bochs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $(video_bochs_module_CFLAGS) $(CFLAGS) -MT video/video_bochs_module-bochs.o -MD -MP -MF video/$(DEPDIR)/video_bochs_module-bochs.Tpo -c -o video/video_bochs_module-bochs.o `test -f 'video/bochs.c' || echo '$(srcdir)/'`video/bochs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/video_bochs_module-bochs.Tpo video/$(DEPDIR)/video_bochs_module-bochs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/bochs.c' object='video/video_bochs_module-bochs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $(video_bochs_module_CFLAGS) $(CFLAGS) -c -o video/video_bochs_module-bochs.o `test -f 'video/bochs.c' || echo '$(srcdir)/'`video/bochs.c
+
+video/video_bochs_module-bochs.obj: video/bochs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $(video_bochs_module_CFLAGS) $(CFLAGS) -MT video/video_bochs_module-bochs.obj -MD -MP -MF video/$(DEPDIR)/video_bochs_module-bochs.Tpo -c -o video/video_bochs_module-bochs.obj `if test -f 'video/bochs.c'; then $(CYGPATH_W) 'video/bochs.c'; else $(CYGPATH_W) '$(srcdir)/video/bochs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/video_bochs_module-bochs.Tpo video/$(DEPDIR)/video_bochs_module-bochs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/bochs.c' object='video/video_bochs_module-bochs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $(video_bochs_module_CFLAGS) $(CFLAGS) -c -o video/video_bochs_module-bochs.obj `if test -f 'video/bochs.c'; then $(CYGPATH_W) 'video/bochs.c'; else $(CYGPATH_W) '$(srcdir)/video/bochs.c'; fi`
+
+video/video_cirrus_module-cirrus.o: video/cirrus.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $(video_cirrus_module_CFLAGS) $(CFLAGS) -MT video/video_cirrus_module-cirrus.o -MD -MP -MF video/$(DEPDIR)/video_cirrus_module-cirrus.Tpo -c -o video/video_cirrus_module-cirrus.o `test -f 'video/cirrus.c' || echo '$(srcdir)/'`video/cirrus.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/video_cirrus_module-cirrus.Tpo video/$(DEPDIR)/video_cirrus_module-cirrus.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/cirrus.c' object='video/video_cirrus_module-cirrus.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $(video_cirrus_module_CFLAGS) $(CFLAGS) -c -o video/video_cirrus_module-cirrus.o `test -f 'video/cirrus.c' || echo '$(srcdir)/'`video/cirrus.c
+
+video/video_cirrus_module-cirrus.obj: video/cirrus.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $(video_cirrus_module_CFLAGS) $(CFLAGS) -MT video/video_cirrus_module-cirrus.obj -MD -MP -MF video/$(DEPDIR)/video_cirrus_module-cirrus.Tpo -c -o video/video_cirrus_module-cirrus.obj `if test -f 'video/cirrus.c'; then $(CYGPATH_W) 'video/cirrus.c'; else $(CYGPATH_W) '$(srcdir)/video/cirrus.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/video_cirrus_module-cirrus.Tpo video/$(DEPDIR)/video_cirrus_module-cirrus.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/cirrus.c' object='video/video_cirrus_module-cirrus.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $(video_cirrus_module_CFLAGS) $(CFLAGS) -c -o video/video_cirrus_module-cirrus.obj `if test -f 'video/cirrus.c'; then $(CYGPATH_W) 'video/cirrus.c'; else $(CYGPATH_W) '$(srcdir)/video/cirrus.c'; fi`
+
+video/video_colors_module-colors.o: video/colors.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_colors_module_CPPFLAGS) $(CPPFLAGS) $(video_colors_module_CFLAGS) $(CFLAGS) -MT video/video_colors_module-colors.o -MD -MP -MF video/$(DEPDIR)/video_colors_module-colors.Tpo -c -o video/video_colors_module-colors.o `test -f 'video/colors.c' || echo '$(srcdir)/'`video/colors.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/video_colors_module-colors.Tpo video/$(DEPDIR)/video_colors_module-colors.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/colors.c' object='video/video_colors_module-colors.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_colors_module_CPPFLAGS) $(CPPFLAGS) $(video_colors_module_CFLAGS) $(CFLAGS) -c -o video/video_colors_module-colors.o `test -f 'video/colors.c' || echo '$(srcdir)/'`video/colors.c
+
+video/video_colors_module-colors.obj: video/colors.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_colors_module_CPPFLAGS) $(CPPFLAGS) $(video_colors_module_CFLAGS) $(CFLAGS) -MT video/video_colors_module-colors.obj -MD -MP -MF video/$(DEPDIR)/video_colors_module-colors.Tpo -c -o video/video_colors_module-colors.obj `if test -f 'video/colors.c'; then $(CYGPATH_W) 'video/colors.c'; else $(CYGPATH_W) '$(srcdir)/video/colors.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/$(DEPDIR)/video_colors_module-colors.Tpo video/$(DEPDIR)/video_colors_module-colors.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/colors.c' object='video/video_colors_module-colors.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_colors_module_CPPFLAGS) $(CPPFLAGS) $(video_colors_module_CFLAGS) $(CFLAGS) -c -o video/video_colors_module-colors.obj `if test -f 'video/colors.c'; then $(CYGPATH_W) 'video/colors.c'; else $(CYGPATH_W) '$(srcdir)/video/colors.c'; fi`
+
+video/fb/video_fb_module-video_fb.o: video/fb/video_fb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -MT video/fb/video_fb_module-video_fb.o -MD -MP -MF video/fb/$(DEPDIR)/video_fb_module-video_fb.Tpo -c -o video/fb/video_fb_module-video_fb.o `test -f 'video/fb/video_fb.c' || echo '$(srcdir)/'`video/fb/video_fb.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/video_fb_module-video_fb.Tpo video/fb/$(DEPDIR)/video_fb_module-video_fb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/video_fb.c' object='video/fb/video_fb_module-video_fb.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -c -o video/fb/video_fb_module-video_fb.o `test -f 'video/fb/video_fb.c' || echo '$(srcdir)/'`video/fb/video_fb.c
+
+video/fb/video_fb_module-video_fb.obj: video/fb/video_fb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -MT video/fb/video_fb_module-video_fb.obj -MD -MP -MF video/fb/$(DEPDIR)/video_fb_module-video_fb.Tpo -c -o video/fb/video_fb_module-video_fb.obj `if test -f 'video/fb/video_fb.c'; then $(CYGPATH_W) 'video/fb/video_fb.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/video_fb.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/video_fb_module-video_fb.Tpo video/fb/$(DEPDIR)/video_fb_module-video_fb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/video_fb.c' object='video/fb/video_fb_module-video_fb.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -c -o video/fb/video_fb_module-video_fb.obj `if test -f 'video/fb/video_fb.c'; then $(CYGPATH_W) 'video/fb/video_fb.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/video_fb.c'; fi`
+
+video/fb/video_fb_module-fbblit.o: video/fb/fbblit.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -MT video/fb/video_fb_module-fbblit.o -MD -MP -MF video/fb/$(DEPDIR)/video_fb_module-fbblit.Tpo -c -o video/fb/video_fb_module-fbblit.o `test -f 'video/fb/fbblit.c' || echo '$(srcdir)/'`video/fb/fbblit.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/video_fb_module-fbblit.Tpo video/fb/$(DEPDIR)/video_fb_module-fbblit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbblit.c' object='video/fb/video_fb_module-fbblit.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -c -o video/fb/video_fb_module-fbblit.o `test -f 'video/fb/fbblit.c' || echo '$(srcdir)/'`video/fb/fbblit.c
+
+video/fb/video_fb_module-fbblit.obj: video/fb/fbblit.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -MT video/fb/video_fb_module-fbblit.obj -MD -MP -MF video/fb/$(DEPDIR)/video_fb_module-fbblit.Tpo -c -o video/fb/video_fb_module-fbblit.obj `if test -f 'video/fb/fbblit.c'; then $(CYGPATH_W) 'video/fb/fbblit.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbblit.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/video_fb_module-fbblit.Tpo video/fb/$(DEPDIR)/video_fb_module-fbblit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbblit.c' object='video/fb/video_fb_module-fbblit.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -c -o video/fb/video_fb_module-fbblit.obj `if test -f 'video/fb/fbblit.c'; then $(CYGPATH_W) 'video/fb/fbblit.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbblit.c'; fi`
+
+video/fb/video_fb_module-fbfill.o: video/fb/fbfill.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -MT video/fb/video_fb_module-fbfill.o -MD -MP -MF video/fb/$(DEPDIR)/video_fb_module-fbfill.Tpo -c -o video/fb/video_fb_module-fbfill.o `test -f 'video/fb/fbfill.c' || echo '$(srcdir)/'`video/fb/fbfill.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/video_fb_module-fbfill.Tpo video/fb/$(DEPDIR)/video_fb_module-fbfill.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbfill.c' object='video/fb/video_fb_module-fbfill.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -c -o video/fb/video_fb_module-fbfill.o `test -f 'video/fb/fbfill.c' || echo '$(srcdir)/'`video/fb/fbfill.c
+
+video/fb/video_fb_module-fbfill.obj: video/fb/fbfill.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -MT video/fb/video_fb_module-fbfill.obj -MD -MP -MF video/fb/$(DEPDIR)/video_fb_module-fbfill.Tpo -c -o video/fb/video_fb_module-fbfill.obj `if test -f 'video/fb/fbfill.c'; then $(CYGPATH_W) 'video/fb/fbfill.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbfill.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/video_fb_module-fbfill.Tpo video/fb/$(DEPDIR)/video_fb_module-fbfill.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbfill.c' object='video/fb/video_fb_module-fbfill.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -c -o video/fb/video_fb_module-fbfill.obj `if test -f 'video/fb/fbfill.c'; then $(CYGPATH_W) 'video/fb/fbfill.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbfill.c'; fi`
+
+video/fb/video_fb_module-fbutil.o: video/fb/fbutil.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -MT video/fb/video_fb_module-fbutil.o -MD -MP -MF video/fb/$(DEPDIR)/video_fb_module-fbutil.Tpo -c -o video/fb/video_fb_module-fbutil.o `test -f 'video/fb/fbutil.c' || echo '$(srcdir)/'`video/fb/fbutil.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/video_fb_module-fbutil.Tpo video/fb/$(DEPDIR)/video_fb_module-fbutil.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbutil.c' object='video/fb/video_fb_module-fbutil.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -c -o video/fb/video_fb_module-fbutil.o `test -f 'video/fb/fbutil.c' || echo '$(srcdir)/'`video/fb/fbutil.c
+
+video/fb/video_fb_module-fbutil.obj: video/fb/fbutil.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -MT video/fb/video_fb_module-fbutil.obj -MD -MP -MF video/fb/$(DEPDIR)/video_fb_module-fbutil.Tpo -c -o video/fb/video_fb_module-fbutil.obj `if test -f 'video/fb/fbutil.c'; then $(CYGPATH_W) 'video/fb/fbutil.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbutil.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) video/fb/$(DEPDIR)/video_fb_module-fbutil.Tpo video/fb/$(DEPDIR)/video_fb_module-fbutil.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='video/fb/fbutil.c' object='video/fb/video_fb_module-fbutil.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $(video_fb_module_CFLAGS) $(CFLAGS) -c -o video/fb/video_fb_module-fbutil.obj `if test -f 'video/fb/fbutil.c'; then $(CYGPATH_W) 'video/fb/fbutil.c'; else $(CYGPATH_W) '$(srcdir)/video/fb/fbutil.c'; fi`
+
+commands/videoinfo_module-videoinfo.o: commands/videoinfo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videoinfo_module_CPPFLAGS) $(CPPFLAGS) $(videoinfo_module_CFLAGS) $(CFLAGS) -MT commands/videoinfo_module-videoinfo.o -MD -MP -MF commands/$(DEPDIR)/videoinfo_module-videoinfo.Tpo -c -o commands/videoinfo_module-videoinfo.o `test -f 'commands/videoinfo.c' || echo '$(srcdir)/'`commands/videoinfo.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/videoinfo_module-videoinfo.Tpo commands/$(DEPDIR)/videoinfo_module-videoinfo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/videoinfo.c' object='commands/videoinfo_module-videoinfo.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videoinfo_module_CPPFLAGS) $(CPPFLAGS) $(videoinfo_module_CFLAGS) $(CFLAGS) -c -o commands/videoinfo_module-videoinfo.o `test -f 'commands/videoinfo.c' || echo '$(srcdir)/'`commands/videoinfo.c
+
+commands/videoinfo_module-videoinfo.obj: commands/videoinfo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videoinfo_module_CPPFLAGS) $(CPPFLAGS) $(videoinfo_module_CFLAGS) $(CFLAGS) -MT commands/videoinfo_module-videoinfo.obj -MD -MP -MF commands/$(DEPDIR)/videoinfo_module-videoinfo.Tpo -c -o commands/videoinfo_module-videoinfo.obj `if test -f 'commands/videoinfo.c'; then $(CYGPATH_W) 'commands/videoinfo.c'; else $(CYGPATH_W) '$(srcdir)/commands/videoinfo.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/videoinfo_module-videoinfo.Tpo commands/$(DEPDIR)/videoinfo_module-videoinfo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/videoinfo.c' object='commands/videoinfo_module-videoinfo.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videoinfo_module_CPPFLAGS) $(CPPFLAGS) $(videoinfo_module_CFLAGS) $(CFLAGS) -c -o commands/videoinfo_module-videoinfo.obj `if test -f 'commands/videoinfo.c'; then $(CYGPATH_W) 'commands/videoinfo.c'; else $(CYGPATH_W) '$(srcdir)/commands/videoinfo.c'; fi`
+
+commands/videotest_module-videotest.o: commands/videotest.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_module_CPPFLAGS) $(CPPFLAGS) $(videotest_module_CFLAGS) $(CFLAGS) -MT commands/videotest_module-videotest.o -MD -MP -MF commands/$(DEPDIR)/videotest_module-videotest.Tpo -c -o commands/videotest_module-videotest.o `test -f 'commands/videotest.c' || echo '$(srcdir)/'`commands/videotest.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/videotest_module-videotest.Tpo commands/$(DEPDIR)/videotest_module-videotest.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/videotest.c' object='commands/videotest_module-videotest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_module_CPPFLAGS) $(CPPFLAGS) $(videotest_module_CFLAGS) $(CFLAGS) -c -o commands/videotest_module-videotest.o `test -f 'commands/videotest.c' || echo '$(srcdir)/'`commands/videotest.c
+
+commands/videotest_module-videotest.obj: commands/videotest.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_module_CPPFLAGS) $(CPPFLAGS) $(videotest_module_CFLAGS) $(CFLAGS) -MT commands/videotest_module-videotest.obj -MD -MP -MF commands/$(DEPDIR)/videotest_module-videotest.Tpo -c -o commands/videotest_module-videotest.obj `if test -f 'commands/videotest.c'; then $(CYGPATH_W) 'commands/videotest.c'; else $(CYGPATH_W) '$(srcdir)/commands/videotest.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/videotest_module-videotest.Tpo commands/$(DEPDIR)/videotest_module-videotest.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/videotest.c' object='commands/videotest_module-videotest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_module_CPPFLAGS) $(CPPFLAGS) $(videotest_module_CFLAGS) $(CFLAGS) -c -o commands/videotest_module-videotest.obj `if test -f 'commands/videotest.c'; then $(CYGPATH_W) 'commands/videotest.c'; else $(CYGPATH_W) '$(srcdir)/commands/videotest.c'; fi`
+
+tests/videotest_checksum_module-videotest_checksum.o: tests/videotest_checksum.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_checksum_module_CPPFLAGS) $(CPPFLAGS) $(videotest_checksum_module_CFLAGS) $(CFLAGS) -MT tests/videotest_checksum_module-videotest_checksum.o -MD -MP -MF tests/$(DEPDIR)/videotest_checksum_module-videotest_checksum.Tpo -c -o tests/videotest_checksum_module-videotest_checksum.o `test -f 'tests/videotest_checksum.c' || echo '$(srcdir)/'`tests/videotest_checksum.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/videotest_checksum_module-videotest_checksum.Tpo tests/$(DEPDIR)/videotest_checksum_module-videotest_checksum.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/videotest_checksum.c' object='tests/videotest_checksum_module-videotest_checksum.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_checksum_module_CPPFLAGS) $(CPPFLAGS) $(videotest_checksum_module_CFLAGS) $(CFLAGS) -c -o tests/videotest_checksum_module-videotest_checksum.o `test -f 'tests/videotest_checksum.c' || echo '$(srcdir)/'`tests/videotest_checksum.c
+
+tests/videotest_checksum_module-videotest_checksum.obj: tests/videotest_checksum.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_checksum_module_CPPFLAGS) $(CPPFLAGS) $(videotest_checksum_module_CFLAGS) $(CFLAGS) -MT tests/videotest_checksum_module-videotest_checksum.obj -MD -MP -MF tests/$(DEPDIR)/videotest_checksum_module-videotest_checksum.Tpo -c -o tests/videotest_checksum_module-videotest_checksum.obj `if test -f 'tests/videotest_checksum.c'; then $(CYGPATH_W) 'tests/videotest_checksum.c'; else $(CYGPATH_W) '$(srcdir)/tests/videotest_checksum.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/videotest_checksum_module-videotest_checksum.Tpo tests/$(DEPDIR)/videotest_checksum_module-videotest_checksum.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/videotest_checksum.c' object='tests/videotest_checksum_module-videotest_checksum.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_checksum_module_CPPFLAGS) $(CPPFLAGS) $(videotest_checksum_module_CFLAGS) $(CFLAGS) -c -o tests/videotest_checksum_module-videotest_checksum.obj `if test -f 'tests/videotest_checksum.c'; then $(CYGPATH_W) 'tests/videotest_checksum.c'; else $(CYGPATH_W) '$(srcdir)/tests/videotest_checksum.c'; fi`
+
+commands/i386/wrmsr_module-wrmsr.o: commands/i386/wrmsr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $(wrmsr_module_CFLAGS) $(CFLAGS) -MT commands/i386/wrmsr_module-wrmsr.o -MD -MP -MF commands/i386/$(DEPDIR)/wrmsr_module-wrmsr.Tpo -c -o commands/i386/wrmsr_module-wrmsr.o `test -f 'commands/i386/wrmsr.c' || echo '$(srcdir)/'`commands/i386/wrmsr.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/$(DEPDIR)/wrmsr_module-wrmsr.Tpo commands/i386/$(DEPDIR)/wrmsr_module-wrmsr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/wrmsr.c' object='commands/i386/wrmsr_module-wrmsr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $(wrmsr_module_CFLAGS) $(CFLAGS) -c -o commands/i386/wrmsr_module-wrmsr.o `test -f 'commands/i386/wrmsr.c' || echo '$(srcdir)/'`commands/i386/wrmsr.c
+
+commands/i386/wrmsr_module-wrmsr.obj: commands/i386/wrmsr.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $(wrmsr_module_CFLAGS) $(CFLAGS) -MT commands/i386/wrmsr_module-wrmsr.obj -MD -MP -MF commands/i386/$(DEPDIR)/wrmsr_module-wrmsr.Tpo -c -o commands/i386/wrmsr_module-wrmsr.obj `if test -f 'commands/i386/wrmsr.c'; then $(CYGPATH_W) 'commands/i386/wrmsr.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/wrmsr.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/i386/$(DEPDIR)/wrmsr_module-wrmsr.Tpo commands/i386/$(DEPDIR)/wrmsr_module-wrmsr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/i386/wrmsr.c' object='commands/i386/wrmsr_module-wrmsr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $(wrmsr_module_CFLAGS) $(CFLAGS) -c -o commands/i386/wrmsr_module-wrmsr.obj `if test -f 'commands/i386/wrmsr.c'; then $(CYGPATH_W) 'commands/i386/wrmsr.c'; else $(CYGPATH_W) '$(srcdir)/commands/i386/wrmsr.c'; fi`
+
+loader/arm64/xen_boot_module-xen_boot.o: loader/arm64/xen_boot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xen_boot_module_CPPFLAGS) $(CPPFLAGS) $(xen_boot_module_CFLAGS) $(CFLAGS) -MT loader/arm64/xen_boot_module-xen_boot.o -MD -MP -MF loader/arm64/$(DEPDIR)/xen_boot_module-xen_boot.Tpo -c -o loader/arm64/xen_boot_module-xen_boot.o `test -f 'loader/arm64/xen_boot.c' || echo '$(srcdir)/'`loader/arm64/xen_boot.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/arm64/$(DEPDIR)/xen_boot_module-xen_boot.Tpo loader/arm64/$(DEPDIR)/xen_boot_module-xen_boot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/arm64/xen_boot.c' object='loader/arm64/xen_boot_module-xen_boot.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xen_boot_module_CPPFLAGS) $(CPPFLAGS) $(xen_boot_module_CFLAGS) $(CFLAGS) -c -o loader/arm64/xen_boot_module-xen_boot.o `test -f 'loader/arm64/xen_boot.c' || echo '$(srcdir)/'`loader/arm64/xen_boot.c
+
+loader/arm64/xen_boot_module-xen_boot.obj: loader/arm64/xen_boot.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xen_boot_module_CPPFLAGS) $(CPPFLAGS) $(xen_boot_module_CFLAGS) $(CFLAGS) -MT loader/arm64/xen_boot_module-xen_boot.obj -MD -MP -MF loader/arm64/$(DEPDIR)/xen_boot_module-xen_boot.Tpo -c -o loader/arm64/xen_boot_module-xen_boot.obj `if test -f 'loader/arm64/xen_boot.c'; then $(CYGPATH_W) 'loader/arm64/xen_boot.c'; else $(CYGPATH_W) '$(srcdir)/loader/arm64/xen_boot.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/arm64/$(DEPDIR)/xen_boot_module-xen_boot.Tpo loader/arm64/$(DEPDIR)/xen_boot_module-xen_boot.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/arm64/xen_boot.c' object='loader/arm64/xen_boot_module-xen_boot.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xen_boot_module_CPPFLAGS) $(CPPFLAGS) $(xen_boot_module_CFLAGS) $(CFLAGS) -c -o loader/arm64/xen_boot_module-xen_boot.obj `if test -f 'loader/arm64/xen_boot.c'; then $(CYGPATH_W) 'loader/arm64/xen_boot.c'; else $(CYGPATH_W) '$(srcdir)/loader/arm64/xen_boot.c'; fi`
+
+fs/xfs_module-xfs.o: fs/xfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xfs_module_CPPFLAGS) $(CPPFLAGS) $(xfs_module_CFLAGS) $(CFLAGS) -MT fs/xfs_module-xfs.o -MD -MP -MF fs/$(DEPDIR)/xfs_module-xfs.Tpo -c -o fs/xfs_module-xfs.o `test -f 'fs/xfs.c' || echo '$(srcdir)/'`fs/xfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/xfs_module-xfs.Tpo fs/$(DEPDIR)/xfs_module-xfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/xfs.c' object='fs/xfs_module-xfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xfs_module_CPPFLAGS) $(CPPFLAGS) $(xfs_module_CFLAGS) $(CFLAGS) -c -o fs/xfs_module-xfs.o `test -f 'fs/xfs.c' || echo '$(srcdir)/'`fs/xfs.c
+
+fs/xfs_module-xfs.obj: fs/xfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xfs_module_CPPFLAGS) $(CPPFLAGS) $(xfs_module_CFLAGS) $(CFLAGS) -MT fs/xfs_module-xfs.obj -MD -MP -MF fs/$(DEPDIR)/xfs_module-xfs.Tpo -c -o fs/xfs_module-xfs.obj `if test -f 'fs/xfs.c'; then $(CYGPATH_W) 'fs/xfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/xfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/$(DEPDIR)/xfs_module-xfs.Tpo fs/$(DEPDIR)/xfs_module-xfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/xfs.c' object='fs/xfs_module-xfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xfs_module_CPPFLAGS) $(CPPFLAGS) $(xfs_module_CFLAGS) $(CFLAGS) -c -o fs/xfs_module-xfs.obj `if test -f 'fs/xfs.c'; then $(CYGPATH_W) 'fs/xfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/xfs.c'; fi`
+
+loader/xnu_module-xnu_resume.o: loader/xnu_resume.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -MT loader/xnu_module-xnu_resume.o -MD -MP -MF loader/$(DEPDIR)/xnu_module-xnu_resume.Tpo -c -o loader/xnu_module-xnu_resume.o `test -f 'loader/xnu_resume.c' || echo '$(srcdir)/'`loader/xnu_resume.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/xnu_module-xnu_resume.Tpo loader/$(DEPDIR)/xnu_module-xnu_resume.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/xnu_resume.c' object='loader/xnu_module-xnu_resume.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -c -o loader/xnu_module-xnu_resume.o `test -f 'loader/xnu_resume.c' || echo '$(srcdir)/'`loader/xnu_resume.c
+
+loader/xnu_module-xnu_resume.obj: loader/xnu_resume.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -MT loader/xnu_module-xnu_resume.obj -MD -MP -MF loader/$(DEPDIR)/xnu_module-xnu_resume.Tpo -c -o loader/xnu_module-xnu_resume.obj `if test -f 'loader/xnu_resume.c'; then $(CYGPATH_W) 'loader/xnu_resume.c'; else $(CYGPATH_W) '$(srcdir)/loader/xnu_resume.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/xnu_module-xnu_resume.Tpo loader/$(DEPDIR)/xnu_module-xnu_resume.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/xnu_resume.c' object='loader/xnu_module-xnu_resume.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -c -o loader/xnu_module-xnu_resume.obj `if test -f 'loader/xnu_resume.c'; then $(CYGPATH_W) 'loader/xnu_resume.c'; else $(CYGPATH_W) '$(srcdir)/loader/xnu_resume.c'; fi`
+
+loader/i386/xnu_module-xnu.o: loader/i386/xnu.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -MT loader/i386/xnu_module-xnu.o -MD -MP -MF loader/i386/$(DEPDIR)/xnu_module-xnu.Tpo -c -o loader/i386/xnu_module-xnu.o `test -f 'loader/i386/xnu.c' || echo '$(srcdir)/'`loader/i386/xnu.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/xnu_module-xnu.Tpo loader/i386/$(DEPDIR)/xnu_module-xnu.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/xnu.c' object='loader/i386/xnu_module-xnu.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -c -o loader/i386/xnu_module-xnu.o `test -f 'loader/i386/xnu.c' || echo '$(srcdir)/'`loader/i386/xnu.c
+
+loader/i386/xnu_module-xnu.obj: loader/i386/xnu.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -MT loader/i386/xnu_module-xnu.obj -MD -MP -MF loader/i386/$(DEPDIR)/xnu_module-xnu.Tpo -c -o loader/i386/xnu_module-xnu.obj `if test -f 'loader/i386/xnu.c'; then $(CYGPATH_W) 'loader/i386/xnu.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/xnu.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/i386/$(DEPDIR)/xnu_module-xnu.Tpo loader/i386/$(DEPDIR)/xnu_module-xnu.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/i386/xnu.c' object='loader/i386/xnu_module-xnu.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -c -o loader/i386/xnu_module-xnu.obj `if test -f 'loader/i386/xnu.c'; then $(CYGPATH_W) 'loader/i386/xnu.c'; else $(CYGPATH_W) '$(srcdir)/loader/i386/xnu.c'; fi`
+
+loader/xnu_module-xnu.o: loader/xnu.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -MT loader/xnu_module-xnu.o -MD -MP -MF loader/$(DEPDIR)/xnu_module-xnu.Tpo -c -o loader/xnu_module-xnu.o `test -f 'loader/xnu.c' || echo '$(srcdir)/'`loader/xnu.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/xnu_module-xnu.Tpo loader/$(DEPDIR)/xnu_module-xnu.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/xnu.c' object='loader/xnu_module-xnu.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -c -o loader/xnu_module-xnu.o `test -f 'loader/xnu.c' || echo '$(srcdir)/'`loader/xnu.c
+
+loader/xnu_module-xnu.obj: loader/xnu.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -MT loader/xnu_module-xnu.obj -MD -MP -MF loader/$(DEPDIR)/xnu_module-xnu.Tpo -c -o loader/xnu_module-xnu.obj `if test -f 'loader/xnu.c'; then $(CYGPATH_W) 'loader/xnu.c'; else $(CYGPATH_W) '$(srcdir)/loader/xnu.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) loader/$(DEPDIR)/xnu_module-xnu.Tpo loader/$(DEPDIR)/xnu_module-xnu.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loader/xnu.c' object='loader/xnu_module-xnu.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $(xnu_module_CFLAGS) $(CFLAGS) -c -o loader/xnu_module-xnu.obj `if test -f 'loader/xnu.c'; then $(CYGPATH_W) 'loader/xnu.c'; else $(CYGPATH_W) '$(srcdir)/loader/xnu.c'; fi`
+
+commands/xnu_uuid_module-xnu_uuid.o: commands/xnu_uuid.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_module_CPPFLAGS) $(CPPFLAGS) $(xnu_uuid_module_CFLAGS) $(CFLAGS) -MT commands/xnu_uuid_module-xnu_uuid.o -MD -MP -MF commands/$(DEPDIR)/xnu_uuid_module-xnu_uuid.Tpo -c -o commands/xnu_uuid_module-xnu_uuid.o `test -f 'commands/xnu_uuid.c' || echo '$(srcdir)/'`commands/xnu_uuid.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/xnu_uuid_module-xnu_uuid.Tpo commands/$(DEPDIR)/xnu_uuid_module-xnu_uuid.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/xnu_uuid.c' object='commands/xnu_uuid_module-xnu_uuid.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_module_CPPFLAGS) $(CPPFLAGS) $(xnu_uuid_module_CFLAGS) $(CFLAGS) -c -o commands/xnu_uuid_module-xnu_uuid.o `test -f 'commands/xnu_uuid.c' || echo '$(srcdir)/'`commands/xnu_uuid.c
+
+commands/xnu_uuid_module-xnu_uuid.obj: commands/xnu_uuid.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_module_CPPFLAGS) $(CPPFLAGS) $(xnu_uuid_module_CFLAGS) $(CFLAGS) -MT commands/xnu_uuid_module-xnu_uuid.obj -MD -MP -MF commands/$(DEPDIR)/xnu_uuid_module-xnu_uuid.Tpo -c -o commands/xnu_uuid_module-xnu_uuid.obj `if test -f 'commands/xnu_uuid.c'; then $(CYGPATH_W) 'commands/xnu_uuid.c'; else $(CYGPATH_W) '$(srcdir)/commands/xnu_uuid.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/xnu_uuid_module-xnu_uuid.Tpo commands/$(DEPDIR)/xnu_uuid_module-xnu_uuid.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='commands/xnu_uuid.c' object='commands/xnu_uuid_module-xnu_uuid.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_module_CPPFLAGS) $(CPPFLAGS) $(xnu_uuid_module_CFLAGS) $(CFLAGS) -c -o commands/xnu_uuid_module-xnu_uuid.obj `if test -f 'commands/xnu_uuid.c'; then $(CYGPATH_W) 'commands/xnu_uuid.c'; else $(CYGPATH_W) '$(srcdir)/commands/xnu_uuid.c'; fi`
+
+tests/xnu_uuid_test_module-xnu_uuid_test.o: tests/xnu_uuid_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_test_module_CPPFLAGS) $(CPPFLAGS) $(xnu_uuid_test_module_CFLAGS) $(CFLAGS) -MT tests/xnu_uuid_test_module-xnu_uuid_test.o -MD -MP -MF tests/$(DEPDIR)/xnu_uuid_test_module-xnu_uuid_test.Tpo -c -o tests/xnu_uuid_test_module-xnu_uuid_test.o `test -f 'tests/xnu_uuid_test.c' || echo '$(srcdir)/'`tests/xnu_uuid_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/xnu_uuid_test_module-xnu_uuid_test.Tpo tests/$(DEPDIR)/xnu_uuid_test_module-xnu_uuid_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/xnu_uuid_test.c' object='tests/xnu_uuid_test_module-xnu_uuid_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_test_module_CPPFLAGS) $(CPPFLAGS) $(xnu_uuid_test_module_CFLAGS) $(CFLAGS) -c -o tests/xnu_uuid_test_module-xnu_uuid_test.o `test -f 'tests/xnu_uuid_test.c' || echo '$(srcdir)/'`tests/xnu_uuid_test.c
+
+tests/xnu_uuid_test_module-xnu_uuid_test.obj: tests/xnu_uuid_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_test_module_CPPFLAGS) $(CPPFLAGS) $(xnu_uuid_test_module_CFLAGS) $(CFLAGS) -MT tests/xnu_uuid_test_module-xnu_uuid_test.obj -MD -MP -MF tests/$(DEPDIR)/xnu_uuid_test_module-xnu_uuid_test.Tpo -c -o tests/xnu_uuid_test_module-xnu_uuid_test.obj `if test -f 'tests/xnu_uuid_test.c'; then $(CYGPATH_W) 'tests/xnu_uuid_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/xnu_uuid_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tests/$(DEPDIR)/xnu_uuid_test_module-xnu_uuid_test.Tpo tests/$(DEPDIR)/xnu_uuid_test_module-xnu_uuid_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests/xnu_uuid_test.c' object='tests/xnu_uuid_test_module-xnu_uuid_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_test_module_CPPFLAGS) $(CPPFLAGS) $(xnu_uuid_test_module_CFLAGS) $(CFLAGS) -c -o tests/xnu_uuid_test_module-xnu_uuid_test.obj `if test -f 'tests/xnu_uuid_test.c'; then $(CYGPATH_W) 'tests/xnu_uuid_test.c'; else $(CYGPATH_W) '$(srcdir)/tests/xnu_uuid_test.c'; fi`
+
+boot/decompressor/xz_decompress_image-minilib.o: boot/decompressor/minilib.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT boot/decompressor/xz_decompress_image-minilib.o -MD -MP -MF boot/decompressor/$(DEPDIR)/xz_decompress_image-minilib.Tpo -c -o boot/decompressor/xz_decompress_image-minilib.o `test -f 'boot/decompressor/minilib.c' || echo '$(srcdir)/'`boot/decompressor/minilib.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) boot/decompressor/$(DEPDIR)/xz_decompress_image-minilib.Tpo boot/decompressor/$(DEPDIR)/xz_decompress_image-minilib.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='boot/decompressor/minilib.c' object='boot/decompressor/xz_decompress_image-minilib.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o boot/decompressor/xz_decompress_image-minilib.o `test -f 'boot/decompressor/minilib.c' || echo '$(srcdir)/'`boot/decompressor/minilib.c
+
+boot/decompressor/xz_decompress_image-minilib.obj: boot/decompressor/minilib.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT boot/decompressor/xz_decompress_image-minilib.obj -MD -MP -MF boot/decompressor/$(DEPDIR)/xz_decompress_image-minilib.Tpo -c -o boot/decompressor/xz_decompress_image-minilib.obj `if test -f 'boot/decompressor/minilib.c'; then $(CYGPATH_W) 'boot/decompressor/minilib.c'; else $(CYGPATH_W) '$(srcdir)/boot/decompressor/minilib.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) boot/decompressor/$(DEPDIR)/xz_decompress_image-minilib.Tpo boot/decompressor/$(DEPDIR)/xz_decompress_image-minilib.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='boot/decompressor/minilib.c' object='boot/decompressor/xz_decompress_image-minilib.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o boot/decompressor/xz_decompress_image-minilib.obj `if test -f 'boot/decompressor/minilib.c'; then $(CYGPATH_W) 'boot/decompressor/minilib.c'; else $(CYGPATH_W) '$(srcdir)/boot/decompressor/minilib.c'; fi`
+
+boot/decompressor/xz_decompress_image-xz.o: boot/decompressor/xz.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT boot/decompressor/xz_decompress_image-xz.o -MD -MP -MF boot/decompressor/$(DEPDIR)/xz_decompress_image-xz.Tpo -c -o boot/decompressor/xz_decompress_image-xz.o `test -f 'boot/decompressor/xz.c' || echo '$(srcdir)/'`boot/decompressor/xz.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) boot/decompressor/$(DEPDIR)/xz_decompress_image-xz.Tpo boot/decompressor/$(DEPDIR)/xz_decompress_image-xz.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='boot/decompressor/xz.c' object='boot/decompressor/xz_decompress_image-xz.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o boot/decompressor/xz_decompress_image-xz.o `test -f 'boot/decompressor/xz.c' || echo '$(srcdir)/'`boot/decompressor/xz.c
+
+boot/decompressor/xz_decompress_image-xz.obj: boot/decompressor/xz.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT boot/decompressor/xz_decompress_image-xz.obj -MD -MP -MF boot/decompressor/$(DEPDIR)/xz_decompress_image-xz.Tpo -c -o boot/decompressor/xz_decompress_image-xz.obj `if test -f 'boot/decompressor/xz.c'; then $(CYGPATH_W) 'boot/decompressor/xz.c'; else $(CYGPATH_W) '$(srcdir)/boot/decompressor/xz.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) boot/decompressor/$(DEPDIR)/xz_decompress_image-xz.Tpo boot/decompressor/$(DEPDIR)/xz_decompress_image-xz.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='boot/decompressor/xz.c' object='boot/decompressor/xz_decompress_image-xz.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o boot/decompressor/xz_decompress_image-xz.obj `if test -f 'boot/decompressor/xz.c'; then $(CYGPATH_W) 'boot/decompressor/xz.c'; else $(CYGPATH_W) '$(srcdir)/boot/decompressor/xz.c'; fi`
+
+lib/xzembed/xz_decompress_image-xz_dec_bcj.o: lib/xzembed/xz_dec_bcj.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT lib/xzembed/xz_decompress_image-xz_dec_bcj.o -MD -MP -MF lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_bcj.Tpo -c -o lib/xzembed/xz_decompress_image-xz_dec_bcj.o `test -f 'lib/xzembed/xz_dec_bcj.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_bcj.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_bcj.Tpo lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_bcj.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_bcj.c' object='lib/xzembed/xz_decompress_image-xz_dec_bcj.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xz_decompress_image-xz_dec_bcj.o `test -f 'lib/xzembed/xz_dec_bcj.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_bcj.c
+
+lib/xzembed/xz_decompress_image-xz_dec_bcj.obj: lib/xzembed/xz_dec_bcj.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT lib/xzembed/xz_decompress_image-xz_dec_bcj.obj -MD -MP -MF lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_bcj.Tpo -c -o lib/xzembed/xz_decompress_image-xz_dec_bcj.obj `if test -f 'lib/xzembed/xz_dec_bcj.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_bcj.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_bcj.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_bcj.Tpo lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_bcj.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_bcj.c' object='lib/xzembed/xz_decompress_image-xz_dec_bcj.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xz_decompress_image-xz_dec_bcj.obj `if test -f 'lib/xzembed/xz_dec_bcj.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_bcj.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_bcj.c'; fi`
+
+lib/xzembed/xz_decompress_image-xz_dec_lzma2.o: lib/xzembed/xz_dec_lzma2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT lib/xzembed/xz_decompress_image-xz_dec_lzma2.o -MD -MP -MF lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_lzma2.Tpo -c -o lib/xzembed/xz_decompress_image-xz_dec_lzma2.o `test -f 'lib/xzembed/xz_dec_lzma2.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_lzma2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_lzma2.Tpo lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_lzma2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_lzma2.c' object='lib/xzembed/xz_decompress_image-xz_dec_lzma2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xz_decompress_image-xz_dec_lzma2.o `test -f 'lib/xzembed/xz_dec_lzma2.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_lzma2.c
+
+lib/xzembed/xz_decompress_image-xz_dec_lzma2.obj: lib/xzembed/xz_dec_lzma2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT lib/xzembed/xz_decompress_image-xz_dec_lzma2.obj -MD -MP -MF lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_lzma2.Tpo -c -o lib/xzembed/xz_decompress_image-xz_dec_lzma2.obj `if test -f 'lib/xzembed/xz_dec_lzma2.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_lzma2.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_lzma2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_lzma2.Tpo lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_lzma2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_lzma2.c' object='lib/xzembed/xz_decompress_image-xz_dec_lzma2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xz_decompress_image-xz_dec_lzma2.obj `if test -f 'lib/xzembed/xz_dec_lzma2.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_lzma2.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_lzma2.c'; fi`
+
+lib/xzembed/xz_decompress_image-xz_dec_stream.o: lib/xzembed/xz_dec_stream.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT lib/xzembed/xz_decompress_image-xz_dec_stream.o -MD -MP -MF lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_stream.Tpo -c -o lib/xzembed/xz_decompress_image-xz_dec_stream.o `test -f 'lib/xzembed/xz_dec_stream.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_stream.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_stream.Tpo lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_stream.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_stream.c' object='lib/xzembed/xz_decompress_image-xz_dec_stream.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xz_decompress_image-xz_dec_stream.o `test -f 'lib/xzembed/xz_dec_stream.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_stream.c
+
+lib/xzembed/xz_decompress_image-xz_dec_stream.obj: lib/xzembed/xz_dec_stream.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT lib/xzembed/xz_decompress_image-xz_dec_stream.obj -MD -MP -MF lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_stream.Tpo -c -o lib/xzembed/xz_decompress_image-xz_dec_stream.obj `if test -f 'lib/xzembed/xz_dec_stream.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_stream.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_stream.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_stream.Tpo lib/xzembed/$(DEPDIR)/xz_decompress_image-xz_dec_stream.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_stream.c' object='lib/xzembed/xz_decompress_image-xz_dec_stream.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xz_decompress_image-xz_dec_stream.obj `if test -f 'lib/xzembed/xz_dec_stream.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_stream.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_stream.c'; fi`
+
+kern/xz_decompress_image-compiler-rt.o: kern/compiler-rt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT kern/xz_decompress_image-compiler-rt.o -MD -MP -MF kern/$(DEPDIR)/xz_decompress_image-compiler-rt.Tpo -c -o kern/xz_decompress_image-compiler-rt.o `test -f 'kern/compiler-rt.c' || echo '$(srcdir)/'`kern/compiler-rt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/xz_decompress_image-compiler-rt.Tpo kern/$(DEPDIR)/xz_decompress_image-compiler-rt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/compiler-rt.c' object='kern/xz_decompress_image-compiler-rt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o kern/xz_decompress_image-compiler-rt.o `test -f 'kern/compiler-rt.c' || echo '$(srcdir)/'`kern/compiler-rt.c
+
+kern/xz_decompress_image-compiler-rt.obj: kern/compiler-rt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -MT kern/xz_decompress_image-compiler-rt.obj -MD -MP -MF kern/$(DEPDIR)/xz_decompress_image-compiler-rt.Tpo -c -o kern/xz_decompress_image-compiler-rt.obj `if test -f 'kern/compiler-rt.c'; then $(CYGPATH_W) 'kern/compiler-rt.c'; else $(CYGPATH_W) '$(srcdir)/kern/compiler-rt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) kern/$(DEPDIR)/xz_decompress_image-compiler-rt.Tpo kern/$(DEPDIR)/xz_decompress_image-compiler-rt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kern/compiler-rt.c' object='kern/xz_decompress_image-compiler-rt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xz_decompress_image_CPPFLAGS) $(CPPFLAGS) $(xz_decompress_image_CFLAGS) $(CFLAGS) -c -o kern/xz_decompress_image-compiler-rt.obj `if test -f 'kern/compiler-rt.c'; then $(CYGPATH_W) 'kern/compiler-rt.c'; else $(CYGPATH_W) '$(srcdir)/kern/compiler-rt.c'; fi`
+
+io/xzio_module-xzio.o: io/xzio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -MT io/xzio_module-xzio.o -MD -MP -MF io/$(DEPDIR)/xzio_module-xzio.Tpo -c -o io/xzio_module-xzio.o `test -f 'io/xzio.c' || echo '$(srcdir)/'`io/xzio.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/xzio_module-xzio.Tpo io/$(DEPDIR)/xzio_module-xzio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/xzio.c' object='io/xzio_module-xzio.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -c -o io/xzio_module-xzio.o `test -f 'io/xzio.c' || echo '$(srcdir)/'`io/xzio.c
+
+io/xzio_module-xzio.obj: io/xzio.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -MT io/xzio_module-xzio.obj -MD -MP -MF io/$(DEPDIR)/xzio_module-xzio.Tpo -c -o io/xzio_module-xzio.obj `if test -f 'io/xzio.c'; then $(CYGPATH_W) 'io/xzio.c'; else $(CYGPATH_W) '$(srcdir)/io/xzio.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) io/$(DEPDIR)/xzio_module-xzio.Tpo io/$(DEPDIR)/xzio_module-xzio.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='io/xzio.c' object='io/xzio_module-xzio.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -c -o io/xzio_module-xzio.obj `if test -f 'io/xzio.c'; then $(CYGPATH_W) 'io/xzio.c'; else $(CYGPATH_W) '$(srcdir)/io/xzio.c'; fi`
+
+lib/xzembed/xzio_module-xz_dec_bcj.o: lib/xzembed/xz_dec_bcj.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -MT lib/xzembed/xzio_module-xz_dec_bcj.o -MD -MP -MF lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_bcj.Tpo -c -o lib/xzembed/xzio_module-xz_dec_bcj.o `test -f 'lib/xzembed/xz_dec_bcj.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_bcj.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_bcj.Tpo lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_bcj.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_bcj.c' object='lib/xzembed/xzio_module-xz_dec_bcj.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xzio_module-xz_dec_bcj.o `test -f 'lib/xzembed/xz_dec_bcj.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_bcj.c
+
+lib/xzembed/xzio_module-xz_dec_bcj.obj: lib/xzembed/xz_dec_bcj.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -MT lib/xzembed/xzio_module-xz_dec_bcj.obj -MD -MP -MF lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_bcj.Tpo -c -o lib/xzembed/xzio_module-xz_dec_bcj.obj `if test -f 'lib/xzembed/xz_dec_bcj.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_bcj.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_bcj.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_bcj.Tpo lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_bcj.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_bcj.c' object='lib/xzembed/xzio_module-xz_dec_bcj.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xzio_module-xz_dec_bcj.obj `if test -f 'lib/xzembed/xz_dec_bcj.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_bcj.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_bcj.c'; fi`
+
+lib/xzembed/xzio_module-xz_dec_lzma2.o: lib/xzembed/xz_dec_lzma2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -MT lib/xzembed/xzio_module-xz_dec_lzma2.o -MD -MP -MF lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_lzma2.Tpo -c -o lib/xzembed/xzio_module-xz_dec_lzma2.o `test -f 'lib/xzembed/xz_dec_lzma2.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_lzma2.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_lzma2.Tpo lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_lzma2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_lzma2.c' object='lib/xzembed/xzio_module-xz_dec_lzma2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xzio_module-xz_dec_lzma2.o `test -f 'lib/xzembed/xz_dec_lzma2.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_lzma2.c
+
+lib/xzembed/xzio_module-xz_dec_lzma2.obj: lib/xzembed/xz_dec_lzma2.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -MT lib/xzembed/xzio_module-xz_dec_lzma2.obj -MD -MP -MF lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_lzma2.Tpo -c -o lib/xzembed/xzio_module-xz_dec_lzma2.obj `if test -f 'lib/xzembed/xz_dec_lzma2.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_lzma2.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_lzma2.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_lzma2.Tpo lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_lzma2.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_lzma2.c' object='lib/xzembed/xzio_module-xz_dec_lzma2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xzio_module-xz_dec_lzma2.obj `if test -f 'lib/xzembed/xz_dec_lzma2.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_lzma2.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_lzma2.c'; fi`
+
+lib/xzembed/xzio_module-xz_dec_stream.o: lib/xzembed/xz_dec_stream.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -MT lib/xzembed/xzio_module-xz_dec_stream.o -MD -MP -MF lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_stream.Tpo -c -o lib/xzembed/xzio_module-xz_dec_stream.o `test -f 'lib/xzembed/xz_dec_stream.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_stream.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_stream.Tpo lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_stream.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_stream.c' object='lib/xzembed/xzio_module-xz_dec_stream.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xzio_module-xz_dec_stream.o `test -f 'lib/xzembed/xz_dec_stream.c' || echo '$(srcdir)/'`lib/xzembed/xz_dec_stream.c
+
+lib/xzembed/xzio_module-xz_dec_stream.obj: lib/xzembed/xz_dec_stream.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -MT lib/xzembed/xzio_module-xz_dec_stream.obj -MD -MP -MF lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_stream.Tpo -c -o lib/xzembed/xzio_module-xz_dec_stream.obj `if test -f 'lib/xzembed/xz_dec_stream.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_stream.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_stream.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_stream.Tpo lib/xzembed/$(DEPDIR)/xzio_module-xz_dec_stream.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/xzembed/xz_dec_stream.c' object='lib/xzembed/xzio_module-xz_dec_stream.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $(xzio_module_CFLAGS) $(CFLAGS) -c -o lib/xzembed/xzio_module-xz_dec_stream.obj `if test -f 'lib/xzembed/xz_dec_stream.c'; then $(CYGPATH_W) 'lib/xzembed/xz_dec_stream.c'; else $(CYGPATH_W) '$(srcdir)/lib/xzembed/xz_dec_stream.c'; fi`
+
+fs/zfs/zfs_module-zfs.o: fs/zfs/zfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfs_module-zfs.o -MD -MP -MF fs/zfs/$(DEPDIR)/zfs_module-zfs.Tpo -c -o fs/zfs/zfs_module-zfs.o `test -f 'fs/zfs/zfs.c' || echo '$(srcdir)/'`fs/zfs/zfs.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfs_module-zfs.Tpo fs/zfs/$(DEPDIR)/zfs_module-zfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfs.c' object='fs/zfs/zfs_module-zfs.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfs_module-zfs.o `test -f 'fs/zfs/zfs.c' || echo '$(srcdir)/'`fs/zfs/zfs.c
+
+fs/zfs/zfs_module-zfs.obj: fs/zfs/zfs.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfs_module-zfs.obj -MD -MP -MF fs/zfs/$(DEPDIR)/zfs_module-zfs.Tpo -c -o fs/zfs/zfs_module-zfs.obj `if test -f 'fs/zfs/zfs.c'; then $(CYGPATH_W) 'fs/zfs/zfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfs.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfs_module-zfs.Tpo fs/zfs/$(DEPDIR)/zfs_module-zfs.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfs.c' object='fs/zfs/zfs_module-zfs.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfs_module-zfs.obj `if test -f 'fs/zfs/zfs.c'; then $(CYGPATH_W) 'fs/zfs/zfs.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfs.c'; fi`
+
+fs/zfs/zfs_module-zfs_lzjb.o: fs/zfs/zfs_lzjb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfs_module-zfs_lzjb.o -MD -MP -MF fs/zfs/$(DEPDIR)/zfs_module-zfs_lzjb.Tpo -c -o fs/zfs/zfs_module-zfs_lzjb.o `test -f 'fs/zfs/zfs_lzjb.c' || echo '$(srcdir)/'`fs/zfs/zfs_lzjb.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfs_module-zfs_lzjb.Tpo fs/zfs/$(DEPDIR)/zfs_module-zfs_lzjb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfs_lzjb.c' object='fs/zfs/zfs_module-zfs_lzjb.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfs_module-zfs_lzjb.o `test -f 'fs/zfs/zfs_lzjb.c' || echo '$(srcdir)/'`fs/zfs/zfs_lzjb.c
+
+fs/zfs/zfs_module-zfs_lzjb.obj: fs/zfs/zfs_lzjb.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfs_module-zfs_lzjb.obj -MD -MP -MF fs/zfs/$(DEPDIR)/zfs_module-zfs_lzjb.Tpo -c -o fs/zfs/zfs_module-zfs_lzjb.obj `if test -f 'fs/zfs/zfs_lzjb.c'; then $(CYGPATH_W) 'fs/zfs/zfs_lzjb.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfs_lzjb.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfs_module-zfs_lzjb.Tpo fs/zfs/$(DEPDIR)/zfs_module-zfs_lzjb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfs_lzjb.c' object='fs/zfs/zfs_module-zfs_lzjb.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfs_module-zfs_lzjb.obj `if test -f 'fs/zfs/zfs_lzjb.c'; then $(CYGPATH_W) 'fs/zfs/zfs_lzjb.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfs_lzjb.c'; fi`
+
+fs/zfs/zfs_module-zfs_lz4.o: fs/zfs/zfs_lz4.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfs_module-zfs_lz4.o -MD -MP -MF fs/zfs/$(DEPDIR)/zfs_module-zfs_lz4.Tpo -c -o fs/zfs/zfs_module-zfs_lz4.o `test -f 'fs/zfs/zfs_lz4.c' || echo '$(srcdir)/'`fs/zfs/zfs_lz4.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfs_module-zfs_lz4.Tpo fs/zfs/$(DEPDIR)/zfs_module-zfs_lz4.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfs_lz4.c' object='fs/zfs/zfs_module-zfs_lz4.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfs_module-zfs_lz4.o `test -f 'fs/zfs/zfs_lz4.c' || echo '$(srcdir)/'`fs/zfs/zfs_lz4.c
+
+fs/zfs/zfs_module-zfs_lz4.obj: fs/zfs/zfs_lz4.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfs_module-zfs_lz4.obj -MD -MP -MF fs/zfs/$(DEPDIR)/zfs_module-zfs_lz4.Tpo -c -o fs/zfs/zfs_module-zfs_lz4.obj `if test -f 'fs/zfs/zfs_lz4.c'; then $(CYGPATH_W) 'fs/zfs/zfs_lz4.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfs_lz4.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfs_module-zfs_lz4.Tpo fs/zfs/$(DEPDIR)/zfs_module-zfs_lz4.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfs_lz4.c' object='fs/zfs/zfs_module-zfs_lz4.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfs_module-zfs_lz4.obj `if test -f 'fs/zfs/zfs_lz4.c'; then $(CYGPATH_W) 'fs/zfs/zfs_lz4.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfs_lz4.c'; fi`
+
+fs/zfs/zfs_module-zfs_sha256.o: fs/zfs/zfs_sha256.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfs_module-zfs_sha256.o -MD -MP -MF fs/zfs/$(DEPDIR)/zfs_module-zfs_sha256.Tpo -c -o fs/zfs/zfs_module-zfs_sha256.o `test -f 'fs/zfs/zfs_sha256.c' || echo '$(srcdir)/'`fs/zfs/zfs_sha256.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfs_module-zfs_sha256.Tpo fs/zfs/$(DEPDIR)/zfs_module-zfs_sha256.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfs_sha256.c' object='fs/zfs/zfs_module-zfs_sha256.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfs_module-zfs_sha256.o `test -f 'fs/zfs/zfs_sha256.c' || echo '$(srcdir)/'`fs/zfs/zfs_sha256.c
+
+fs/zfs/zfs_module-zfs_sha256.obj: fs/zfs/zfs_sha256.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfs_module-zfs_sha256.obj -MD -MP -MF fs/zfs/$(DEPDIR)/zfs_module-zfs_sha256.Tpo -c -o fs/zfs/zfs_module-zfs_sha256.obj `if test -f 'fs/zfs/zfs_sha256.c'; then $(CYGPATH_W) 'fs/zfs/zfs_sha256.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfs_sha256.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfs_module-zfs_sha256.Tpo fs/zfs/$(DEPDIR)/zfs_module-zfs_sha256.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfs_sha256.c' object='fs/zfs/zfs_module-zfs_sha256.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfs_module-zfs_sha256.obj `if test -f 'fs/zfs/zfs_sha256.c'; then $(CYGPATH_W) 'fs/zfs/zfs_sha256.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfs_sha256.c'; fi`
+
+fs/zfs/zfs_module-zfs_fletcher.o: fs/zfs/zfs_fletcher.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfs_module-zfs_fletcher.o -MD -MP -MF fs/zfs/$(DEPDIR)/zfs_module-zfs_fletcher.Tpo -c -o fs/zfs/zfs_module-zfs_fletcher.o `test -f 'fs/zfs/zfs_fletcher.c' || echo '$(srcdir)/'`fs/zfs/zfs_fletcher.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfs_module-zfs_fletcher.Tpo fs/zfs/$(DEPDIR)/zfs_module-zfs_fletcher.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfs_fletcher.c' object='fs/zfs/zfs_module-zfs_fletcher.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfs_module-zfs_fletcher.o `test -f 'fs/zfs/zfs_fletcher.c' || echo '$(srcdir)/'`fs/zfs/zfs_fletcher.c
+
+fs/zfs/zfs_module-zfs_fletcher.obj: fs/zfs/zfs_fletcher.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfs_module-zfs_fletcher.obj -MD -MP -MF fs/zfs/$(DEPDIR)/zfs_module-zfs_fletcher.Tpo -c -o fs/zfs/zfs_module-zfs_fletcher.obj `if test -f 'fs/zfs/zfs_fletcher.c'; then $(CYGPATH_W) 'fs/zfs/zfs_fletcher.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfs_fletcher.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfs_module-zfs_fletcher.Tpo fs/zfs/$(DEPDIR)/zfs_module-zfs_fletcher.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfs_fletcher.c' object='fs/zfs/zfs_module-zfs_fletcher.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $(zfs_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfs_module-zfs_fletcher.obj `if test -f 'fs/zfs/zfs_fletcher.c'; then $(CYGPATH_W) 'fs/zfs/zfs_fletcher.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfs_fletcher.c'; fi`
+
+fs/zfs/zfscrypt_module-zfscrypt.o: fs/zfs/zfscrypt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfscrypt_module_CPPFLAGS) $(CPPFLAGS) $(zfscrypt_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfscrypt_module-zfscrypt.o -MD -MP -MF fs/zfs/$(DEPDIR)/zfscrypt_module-zfscrypt.Tpo -c -o fs/zfs/zfscrypt_module-zfscrypt.o `test -f 'fs/zfs/zfscrypt.c' || echo '$(srcdir)/'`fs/zfs/zfscrypt.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfscrypt_module-zfscrypt.Tpo fs/zfs/$(DEPDIR)/zfscrypt_module-zfscrypt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfscrypt.c' object='fs/zfs/zfscrypt_module-zfscrypt.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfscrypt_module_CPPFLAGS) $(CPPFLAGS) $(zfscrypt_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfscrypt_module-zfscrypt.o `test -f 'fs/zfs/zfscrypt.c' || echo '$(srcdir)/'`fs/zfs/zfscrypt.c
+
+fs/zfs/zfscrypt_module-zfscrypt.obj: fs/zfs/zfscrypt.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfscrypt_module_CPPFLAGS) $(CPPFLAGS) $(zfscrypt_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfscrypt_module-zfscrypt.obj -MD -MP -MF fs/zfs/$(DEPDIR)/zfscrypt_module-zfscrypt.Tpo -c -o fs/zfs/zfscrypt_module-zfscrypt.obj `if test -f 'fs/zfs/zfscrypt.c'; then $(CYGPATH_W) 'fs/zfs/zfscrypt.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfscrypt.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfscrypt_module-zfscrypt.Tpo fs/zfs/$(DEPDIR)/zfscrypt_module-zfscrypt.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfscrypt.c' object='fs/zfs/zfscrypt_module-zfscrypt.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfscrypt_module_CPPFLAGS) $(CPPFLAGS) $(zfscrypt_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfscrypt_module-zfscrypt.obj `if test -f 'fs/zfs/zfscrypt.c'; then $(CYGPATH_W) 'fs/zfs/zfscrypt.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfscrypt.c'; fi`
+
+fs/zfs/zfsinfo_module-zfsinfo.o: fs/zfs/zfsinfo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfsinfo_module_CPPFLAGS) $(CPPFLAGS) $(zfsinfo_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfsinfo_module-zfsinfo.o -MD -MP -MF fs/zfs/$(DEPDIR)/zfsinfo_module-zfsinfo.Tpo -c -o fs/zfs/zfsinfo_module-zfsinfo.o `test -f 'fs/zfs/zfsinfo.c' || echo '$(srcdir)/'`fs/zfs/zfsinfo.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfsinfo_module-zfsinfo.Tpo fs/zfs/$(DEPDIR)/zfsinfo_module-zfsinfo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfsinfo.c' object='fs/zfs/zfsinfo_module-zfsinfo.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfsinfo_module_CPPFLAGS) $(CPPFLAGS) $(zfsinfo_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfsinfo_module-zfsinfo.o `test -f 'fs/zfs/zfsinfo.c' || echo '$(srcdir)/'`fs/zfs/zfsinfo.c
+
+fs/zfs/zfsinfo_module-zfsinfo.obj: fs/zfs/zfsinfo.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfsinfo_module_CPPFLAGS) $(CPPFLAGS) $(zfsinfo_module_CFLAGS) $(CFLAGS) -MT fs/zfs/zfsinfo_module-zfsinfo.obj -MD -MP -MF fs/zfs/$(DEPDIR)/zfsinfo_module-zfsinfo.Tpo -c -o fs/zfs/zfsinfo_module-zfsinfo.obj `if test -f 'fs/zfs/zfsinfo.c'; then $(CYGPATH_W) 'fs/zfs/zfsinfo.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfsinfo.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) fs/zfs/$(DEPDIR)/zfsinfo_module-zfsinfo.Tpo fs/zfs/$(DEPDIR)/zfsinfo_module-zfsinfo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fs/zfs/zfsinfo.c' object='fs/zfs/zfsinfo_module-zfsinfo.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfsinfo_module_CPPFLAGS) $(CPPFLAGS) $(zfsinfo_module_CFLAGS) $(CFLAGS) -c -o fs/zfs/zfsinfo_module-zfsinfo.obj `if test -f 'fs/zfs/zfsinfo.c'; then $(CYGPATH_W) 'fs/zfs/zfsinfo.c'; else $(CYGPATH_W) '$(srcdir)/fs/zfs/zfsinfo.c'; fi`
+
+lib/zstd/zstd_module-debug.o: lib/zstd/debug.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-debug.o -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-debug.Tpo -c -o lib/zstd/zstd_module-debug.o `test -f 'lib/zstd/debug.c' || echo '$(srcdir)/'`lib/zstd/debug.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-debug.Tpo lib/zstd/$(DEPDIR)/zstd_module-debug.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/debug.c' object='lib/zstd/zstd_module-debug.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-debug.o `test -f 'lib/zstd/debug.c' || echo '$(srcdir)/'`lib/zstd/debug.c
+
+lib/zstd/zstd_module-debug.obj: lib/zstd/debug.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-debug.obj -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-debug.Tpo -c -o lib/zstd/zstd_module-debug.obj `if test -f 'lib/zstd/debug.c'; then $(CYGPATH_W) 'lib/zstd/debug.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/debug.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-debug.Tpo lib/zstd/$(DEPDIR)/zstd_module-debug.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/debug.c' object='lib/zstd/zstd_module-debug.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-debug.obj `if test -f 'lib/zstd/debug.c'; then $(CYGPATH_W) 'lib/zstd/debug.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/debug.c'; fi`
+
+lib/zstd/zstd_module-entropy_common.o: lib/zstd/entropy_common.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-entropy_common.o -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-entropy_common.Tpo -c -o lib/zstd/zstd_module-entropy_common.o `test -f 'lib/zstd/entropy_common.c' || echo '$(srcdir)/'`lib/zstd/entropy_common.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-entropy_common.Tpo lib/zstd/$(DEPDIR)/zstd_module-entropy_common.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/entropy_common.c' object='lib/zstd/zstd_module-entropy_common.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-entropy_common.o `test -f 'lib/zstd/entropy_common.c' || echo '$(srcdir)/'`lib/zstd/entropy_common.c
+
+lib/zstd/zstd_module-entropy_common.obj: lib/zstd/entropy_common.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-entropy_common.obj -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-entropy_common.Tpo -c -o lib/zstd/zstd_module-entropy_common.obj `if test -f 'lib/zstd/entropy_common.c'; then $(CYGPATH_W) 'lib/zstd/entropy_common.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/entropy_common.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-entropy_common.Tpo lib/zstd/$(DEPDIR)/zstd_module-entropy_common.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/entropy_common.c' object='lib/zstd/zstd_module-entropy_common.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-entropy_common.obj `if test -f 'lib/zstd/entropy_common.c'; then $(CYGPATH_W) 'lib/zstd/entropy_common.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/entropy_common.c'; fi`
+
+lib/zstd/zstd_module-error_private.o: lib/zstd/error_private.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-error_private.o -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-error_private.Tpo -c -o lib/zstd/zstd_module-error_private.o `test -f 'lib/zstd/error_private.c' || echo '$(srcdir)/'`lib/zstd/error_private.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-error_private.Tpo lib/zstd/$(DEPDIR)/zstd_module-error_private.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/error_private.c' object='lib/zstd/zstd_module-error_private.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-error_private.o `test -f 'lib/zstd/error_private.c' || echo '$(srcdir)/'`lib/zstd/error_private.c
+
+lib/zstd/zstd_module-error_private.obj: lib/zstd/error_private.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-error_private.obj -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-error_private.Tpo -c -o lib/zstd/zstd_module-error_private.obj `if test -f 'lib/zstd/error_private.c'; then $(CYGPATH_W) 'lib/zstd/error_private.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/error_private.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-error_private.Tpo lib/zstd/$(DEPDIR)/zstd_module-error_private.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/error_private.c' object='lib/zstd/zstd_module-error_private.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-error_private.obj `if test -f 'lib/zstd/error_private.c'; then $(CYGPATH_W) 'lib/zstd/error_private.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/error_private.c'; fi`
+
+lib/zstd/zstd_module-fse_decompress.o: lib/zstd/fse_decompress.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-fse_decompress.o -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-fse_decompress.Tpo -c -o lib/zstd/zstd_module-fse_decompress.o `test -f 'lib/zstd/fse_decompress.c' || echo '$(srcdir)/'`lib/zstd/fse_decompress.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-fse_decompress.Tpo lib/zstd/$(DEPDIR)/zstd_module-fse_decompress.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/fse_decompress.c' object='lib/zstd/zstd_module-fse_decompress.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-fse_decompress.o `test -f 'lib/zstd/fse_decompress.c' || echo '$(srcdir)/'`lib/zstd/fse_decompress.c
+
+lib/zstd/zstd_module-fse_decompress.obj: lib/zstd/fse_decompress.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-fse_decompress.obj -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-fse_decompress.Tpo -c -o lib/zstd/zstd_module-fse_decompress.obj `if test -f 'lib/zstd/fse_decompress.c'; then $(CYGPATH_W) 'lib/zstd/fse_decompress.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/fse_decompress.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-fse_decompress.Tpo lib/zstd/$(DEPDIR)/zstd_module-fse_decompress.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/fse_decompress.c' object='lib/zstd/zstd_module-fse_decompress.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-fse_decompress.obj `if test -f 'lib/zstd/fse_decompress.c'; then $(CYGPATH_W) 'lib/zstd/fse_decompress.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/fse_decompress.c'; fi`
+
+lib/zstd/zstd_module-huf_decompress.o: lib/zstd/huf_decompress.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-huf_decompress.o -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-huf_decompress.Tpo -c -o lib/zstd/zstd_module-huf_decompress.o `test -f 'lib/zstd/huf_decompress.c' || echo '$(srcdir)/'`lib/zstd/huf_decompress.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-huf_decompress.Tpo lib/zstd/$(DEPDIR)/zstd_module-huf_decompress.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/huf_decompress.c' object='lib/zstd/zstd_module-huf_decompress.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-huf_decompress.o `test -f 'lib/zstd/huf_decompress.c' || echo '$(srcdir)/'`lib/zstd/huf_decompress.c
+
+lib/zstd/zstd_module-huf_decompress.obj: lib/zstd/huf_decompress.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-huf_decompress.obj -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-huf_decompress.Tpo -c -o lib/zstd/zstd_module-huf_decompress.obj `if test -f 'lib/zstd/huf_decompress.c'; then $(CYGPATH_W) 'lib/zstd/huf_decompress.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/huf_decompress.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-huf_decompress.Tpo lib/zstd/$(DEPDIR)/zstd_module-huf_decompress.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/huf_decompress.c' object='lib/zstd/zstd_module-huf_decompress.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-huf_decompress.obj `if test -f 'lib/zstd/huf_decompress.c'; then $(CYGPATH_W) 'lib/zstd/huf_decompress.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/huf_decompress.c'; fi`
+
+lib/zstd/zstd_module-module.o: lib/zstd/module.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-module.o -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-module.Tpo -c -o lib/zstd/zstd_module-module.o `test -f 'lib/zstd/module.c' || echo '$(srcdir)/'`lib/zstd/module.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-module.Tpo lib/zstd/$(DEPDIR)/zstd_module-module.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/module.c' object='lib/zstd/zstd_module-module.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-module.o `test -f 'lib/zstd/module.c' || echo '$(srcdir)/'`lib/zstd/module.c
+
+lib/zstd/zstd_module-module.obj: lib/zstd/module.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-module.obj -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-module.Tpo -c -o lib/zstd/zstd_module-module.obj `if test -f 'lib/zstd/module.c'; then $(CYGPATH_W) 'lib/zstd/module.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/module.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-module.Tpo lib/zstd/$(DEPDIR)/zstd_module-module.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/module.c' object='lib/zstd/zstd_module-module.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-module.obj `if test -f 'lib/zstd/module.c'; then $(CYGPATH_W) 'lib/zstd/module.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/module.c'; fi`
+
+lib/zstd/zstd_module-xxhash.o: lib/zstd/xxhash.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-xxhash.o -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-xxhash.Tpo -c -o lib/zstd/zstd_module-xxhash.o `test -f 'lib/zstd/xxhash.c' || echo '$(srcdir)/'`lib/zstd/xxhash.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-xxhash.Tpo lib/zstd/$(DEPDIR)/zstd_module-xxhash.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/xxhash.c' object='lib/zstd/zstd_module-xxhash.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-xxhash.o `test -f 'lib/zstd/xxhash.c' || echo '$(srcdir)/'`lib/zstd/xxhash.c
+
+lib/zstd/zstd_module-xxhash.obj: lib/zstd/xxhash.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-xxhash.obj -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-xxhash.Tpo -c -o lib/zstd/zstd_module-xxhash.obj `if test -f 'lib/zstd/xxhash.c'; then $(CYGPATH_W) 'lib/zstd/xxhash.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/xxhash.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-xxhash.Tpo lib/zstd/$(DEPDIR)/zstd_module-xxhash.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/xxhash.c' object='lib/zstd/zstd_module-xxhash.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-xxhash.obj `if test -f 'lib/zstd/xxhash.c'; then $(CYGPATH_W) 'lib/zstd/xxhash.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/xxhash.c'; fi`
+
+lib/zstd/zstd_module-zstd_common.o: lib/zstd/zstd_common.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-zstd_common.o -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-zstd_common.Tpo -c -o lib/zstd/zstd_module-zstd_common.o `test -f 'lib/zstd/zstd_common.c' || echo '$(srcdir)/'`lib/zstd/zstd_common.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-zstd_common.Tpo lib/zstd/$(DEPDIR)/zstd_module-zstd_common.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/zstd_common.c' object='lib/zstd/zstd_module-zstd_common.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-zstd_common.o `test -f 'lib/zstd/zstd_common.c' || echo '$(srcdir)/'`lib/zstd/zstd_common.c
+
+lib/zstd/zstd_module-zstd_common.obj: lib/zstd/zstd_common.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-zstd_common.obj -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-zstd_common.Tpo -c -o lib/zstd/zstd_module-zstd_common.obj `if test -f 'lib/zstd/zstd_common.c'; then $(CYGPATH_W) 'lib/zstd/zstd_common.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/zstd_common.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-zstd_common.Tpo lib/zstd/$(DEPDIR)/zstd_module-zstd_common.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/zstd_common.c' object='lib/zstd/zstd_module-zstd_common.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-zstd_common.obj `if test -f 'lib/zstd/zstd_common.c'; then $(CYGPATH_W) 'lib/zstd/zstd_common.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/zstd_common.c'; fi`
+
+lib/zstd/zstd_module-zstd_decompress.o: lib/zstd/zstd_decompress.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-zstd_decompress.o -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-zstd_decompress.Tpo -c -o lib/zstd/zstd_module-zstd_decompress.o `test -f 'lib/zstd/zstd_decompress.c' || echo '$(srcdir)/'`lib/zstd/zstd_decompress.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-zstd_decompress.Tpo lib/zstd/$(DEPDIR)/zstd_module-zstd_decompress.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/zstd_decompress.c' object='lib/zstd/zstd_module-zstd_decompress.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-zstd_decompress.o `test -f 'lib/zstd/zstd_decompress.c' || echo '$(srcdir)/'`lib/zstd/zstd_decompress.c
+
+lib/zstd/zstd_module-zstd_decompress.obj: lib/zstd/zstd_decompress.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -MT lib/zstd/zstd_module-zstd_decompress.obj -MD -MP -MF lib/zstd/$(DEPDIR)/zstd_module-zstd_decompress.Tpo -c -o lib/zstd/zstd_module-zstd_decompress.obj `if test -f 'lib/zstd/zstd_decompress.c'; then $(CYGPATH_W) 'lib/zstd/zstd_decompress.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/zstd_decompress.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lib/zstd/$(DEPDIR)/zstd_module-zstd_decompress.Tpo lib/zstd/$(DEPDIR)/zstd_module-zstd_decompress.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lib/zstd/zstd_decompress.c' object='lib/zstd/zstd_module-zstd_decompress.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $(zstd_module_CFLAGS) $(CFLAGS) -c -o lib/zstd/zstd_module-zstd_decompress.obj `if test -f 'lib/zstd/zstd_decompress.c'; then $(CYGPATH_W) 'lib/zstd/zstd_decompress.c'; else $(CYGPATH_W) '$(srcdir)/lib/zstd/zstd_decompress.c'; fi`
+install-man1: $(man_MANS)
+ @$(NORMAL_INSTALL)
+ @list1=''; \
+ list2='$(man_MANS)'; \
+ test -n "$(man1dir)" \
+ && test -n "`echo $$list1$$list2`" \
+ || exit 0; \
+ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \
+ { for i in $$list1; do echo "$$i"; done; \
+ if test -n "$$list2"; then \
+ for i in $$list2; do echo "$$i"; done \
+ | sed -n '/\.1[a-z]*$$/p'; \
+ fi; \
+ } | while read p; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; echo "$$p"; \
+ done | \
+ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+ sed 'N;N;s,\n, ,g' | { \
+ list=; while read file base inst; do \
+ if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+ fi; \
+ done; \
+ for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+ while read files; do \
+ test -z "$$files" || { \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+ done; }
+
+uninstall-man1:
+ @$(NORMAL_UNINSTALL)
+ @list=''; test -n "$(man1dir)" || exit 0; \
+ files=`{ for i in $$list; do echo "$$i"; done; \
+ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.1[a-z]*$$/p'; \
+ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir)
+install-dist_grubconfDATA: $(dist_grubconf_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(dist_grubconf_DATA)'; test -n "$(grubconfdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(grubconfdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(grubconfdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(grubconfdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(grubconfdir)" || exit $$?; \
+ done
+
+uninstall-dist_grubconfDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(dist_grubconf_DATA)'; test -n "$(grubconfdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(grubconfdir)'; $(am__uninstall_files_from_dir)
+install-pkgdataDATA: $(pkgdata_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pkgdatadir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgdatadir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgdatadir)" || exit $$?; \
+ done
+
+uninstall-pkgdataDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(pkgdatadir)'; $(am__uninstall_files_from_dir)
+install-platformDATA: $(platform_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(platform_DATA)'; test -n "$(platformdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(platformdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(platformdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(platformdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(platformdir)" || exit $$?; \
+ done
+
+uninstall-platformDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(platform_DATA)'; test -n "$(platformdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(platformdir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+# Recover from deleted '.trs' file; this should ensure that
+# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
+# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
+# to avoid problems with "make -n".
+.log.trs:
+ rm -f $< $@
+ $(MAKE) $(AM_MAKEFLAGS) $<
+
+# Leading 'am--fnord' is there to ensure the list of targets does not
+# expand to empty, as could happen e.g. with make check TESTS=''.
+am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
+am--force-recheck:
+ @:
+
+$(TEST_SUITE_LOG): $(TEST_LOGS)
+ @$(am__set_TESTS_bases); \
+ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
+ redo_bases=`for i in $$bases; do \
+ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
+ done`; \
+ if test -n "$$redo_bases"; then \
+ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
+ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
+ if $(am__make_dryrun); then :; else \
+ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
+ fi; \
+ fi; \
+ if test -n "$$am__remaking_logs"; then \
+ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+ "recursion detected" >&2; \
+ elif test -n "$$redo_logs"; then \
+ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+ fi; \
+ if $(am__make_dryrun); then :; else \
+ st=0; \
+ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
+ for i in $$redo_bases; do \
+ test -f $$i.trs && test -r $$i.trs \
+ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
+ test -f $$i.log && test -r $$i.log \
+ || { echo "$$errmsg $$i.log" >&2; st=1; }; \
+ done; \
+ test $$st -eq 0 || exit 1; \
+ fi
+ @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
+ ws='[ ]'; \
+ results=`for b in $$bases; do echo $$b.trs; done`; \
+ test -n "$$results" || results=/dev/null; \
+ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
+ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
+ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
+ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
+ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
+ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
+ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
+ if test `expr $$fail + $$xpass + $$error` -eq 0; then \
+ success=true; \
+ else \
+ success=false; \
+ fi; \
+ br='==================='; br=$$br$$br$$br$$br; \
+ result_count () \
+ { \
+ if test x"$$1" = x"--maybe-color"; then \
+ maybe_colorize=yes; \
+ elif test x"$$1" = x"--no-color"; then \
+ maybe_colorize=no; \
+ else \
+ echo "$@: invalid 'result_count' usage" >&2; exit 4; \
+ fi; \
+ shift; \
+ desc=$$1 count=$$2; \
+ if test $$maybe_colorize = yes && test $$count -gt 0; then \
+ color_start=$$3 color_end=$$std; \
+ else \
+ color_start= color_end=; \
+ fi; \
+ echo "$${color_start}# $$desc $$count$${color_end}"; \
+ }; \
+ create_testsuite_report () \
+ { \
+ result_count $$1 "TOTAL:" $$all "$$brg"; \
+ result_count $$1 "PASS: " $$pass "$$grn"; \
+ result_count $$1 "SKIP: " $$skip "$$blu"; \
+ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
+ result_count $$1 "FAIL: " $$fail "$$red"; \
+ result_count $$1 "XPASS:" $$xpass "$$red"; \
+ result_count $$1 "ERROR:" $$error "$$mgn"; \
+ }; \
+ { \
+ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
+ $(am__rst_title); \
+ create_testsuite_report --no-color; \
+ echo; \
+ echo ".. contents:: :depth: 2"; \
+ echo; \
+ for b in $$bases; do echo $$b; done \
+ | $(am__create_global_log); \
+ } >$(TEST_SUITE_LOG).tmp || exit 1; \
+ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
+ if $$success; then \
+ col="$$grn"; \
+ else \
+ col="$$red"; \
+ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
+ fi; \
+ echo "$${col}$$br$${std}"; \
+ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
+ echo "$${col}$$br$${std}"; \
+ create_testsuite_report --maybe-color; \
+ echo "$$col$$br$$std"; \
+ if $$success; then :; else \
+ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
+ if test -n "$(PACKAGE_BUGREPORT)"; then \
+ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
+ fi; \
+ echo "$$col$$br$$std"; \
+ fi; \
+ $$success || exit 1
+
+check-TESTS:
+ @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+ @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ trs_list=`for i in $$bases; do echo $$i.trs; done`; \
+ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
+ exit $$?;
+recheck: all $(check_PROGRAMS) $(check_SCRIPTS)
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ bases=`for i in $$bases; do echo $$i; done \
+ | $(am__list_recheck_tests)` || exit 1; \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ log_list=`echo $$log_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
+ am__force_recheck=am--force-recheck \
+ TEST_LOGS="$$log_list"; \
+ exit $$?
+.test.log:
+ @p='$<'; \
+ $(am__set_b); \
+ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+@am__EXEEXT_TRUE@.test$(EXEEXT).log:
+@am__EXEEXT_TRUE@ @p='$<'; \
+@am__EXEEXT_TRUE@ $(am__set_b); \
+@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
+@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(check_SCRIPTS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(SCRIPTS) $(MANS) $(DATA)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(platformdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(grubconfdir)" "$(DESTDIR)$(platformdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(grubconfdir)" "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(platformdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+ -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
+ -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
+ -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -rm -f boot/decompressor/$(DEPDIR)/$(am__dirstamp)
+ -rm -f boot/decompressor/$(am__dirstamp)
+ -rm -f boot/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f boot/i386/pc/$(am__dirstamp)
+ -rm -f boot/i386/qemu/$(DEPDIR)/$(am__dirstamp)
+ -rm -f boot/i386/qemu/$(am__dirstamp)
+ -rm -f boot/mips/$(DEPDIR)/$(am__dirstamp)
+ -rm -f boot/mips/$(am__dirstamp)
+ -rm -f boot/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+ -rm -f boot/mips/loongson/$(am__dirstamp)
+ -rm -f boot/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f boot/sparc64/ieee1275/$(am__dirstamp)
+ -rm -f bus/$(DEPDIR)/$(am__dirstamp)
+ -rm -f bus/$(am__dirstamp)
+ -rm -f bus/emu/$(DEPDIR)/$(am__dirstamp)
+ -rm -f bus/emu/$(am__dirstamp)
+ -rm -f bus/i386/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f bus/i386/ieee1275/$(am__dirstamp)
+ -rm -f bus/spi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f bus/spi/$(am__dirstamp)
+ -rm -f bus/usb/$(DEPDIR)/$(am__dirstamp)
+ -rm -f bus/usb/$(am__dirstamp)
+ -rm -f bus/usb/serial/$(DEPDIR)/$(am__dirstamp)
+ -rm -f bus/usb/serial/$(am__dirstamp)
+ -rm -f commands/$(DEPDIR)/$(am__dirstamp)
+ -rm -f commands/$(am__dirstamp)
+ -rm -f commands/arc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f commands/arc/$(am__dirstamp)
+ -rm -f commands/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f commands/efi/$(am__dirstamp)
+ -rm -f commands/i386/$(DEPDIR)/$(am__dirstamp)
+ -rm -f commands/i386/$(am__dirstamp)
+ -rm -f commands/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f commands/i386/coreboot/$(am__dirstamp)
+ -rm -f commands/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f commands/i386/pc/$(am__dirstamp)
+ -rm -f commands/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f commands/ieee1275/$(am__dirstamp)
+ -rm -f commands/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+ -rm -f commands/mips/loongson/$(am__dirstamp)
+ -rm -f commands/xen/$(DEPDIR)/$(am__dirstamp)
+ -rm -f commands/xen/$(am__dirstamp)
+ -rm -f disk/$(DEPDIR)/$(am__dirstamp)
+ -rm -f disk/$(am__dirstamp)
+ -rm -f disk/arc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f disk/arc/$(am__dirstamp)
+ -rm -f disk/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f disk/efi/$(am__dirstamp)
+ -rm -f disk/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f disk/i386/pc/$(am__dirstamp)
+ -rm -f disk/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f disk/ieee1275/$(am__dirstamp)
+ -rm -f disk/uboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f disk/uboot/$(am__dirstamp)
+ -rm -f disk/xen/$(DEPDIR)/$(am__dirstamp)
+ -rm -f disk/xen/$(am__dirstamp)
+ -rm -f efiemu/$(DEPDIR)/$(am__dirstamp)
+ -rm -f efiemu/$(am__dirstamp)
+ -rm -f efiemu/i386/$(DEPDIR)/$(am__dirstamp)
+ -rm -f efiemu/i386/$(am__dirstamp)
+ -rm -f efiemu/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f efiemu/i386/pc/$(am__dirstamp)
+ -rm -f font/$(DEPDIR)/$(am__dirstamp)
+ -rm -f font/$(am__dirstamp)
+ -rm -f fs/$(DEPDIR)/$(am__dirstamp)
+ -rm -f fs/$(am__dirstamp)
+ -rm -f fs/zfs/$(DEPDIR)/$(am__dirstamp)
+ -rm -f fs/zfs/$(am__dirstamp)
+ -rm -f gdb/$(DEPDIR)/$(am__dirstamp)
+ -rm -f gdb/$(am__dirstamp)
+ -rm -f gdb/i386/$(DEPDIR)/$(am__dirstamp)
+ -rm -f gdb/i386/$(am__dirstamp)
+ -rm -f gettext/$(DEPDIR)/$(am__dirstamp)
+ -rm -f gettext/$(am__dirstamp)
+ -rm -f gfxmenu/$(DEPDIR)/$(am__dirstamp)
+ -rm -f gfxmenu/$(am__dirstamp)
+ -rm -f hello/$(DEPDIR)/$(am__dirstamp)
+ -rm -f hello/$(am__dirstamp)
+ -rm -f hook/$(DEPDIR)/$(am__dirstamp)
+ -rm -f hook/$(am__dirstamp)
+ -rm -f io/$(DEPDIR)/$(am__dirstamp)
+ -rm -f io/$(am__dirstamp)
+ -rm -f kern/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/$(am__dirstamp)
+ -rm -f kern/arm/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/arm/$(am__dirstamp)
+ -rm -f kern/arm/coreboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/arm/coreboot/$(am__dirstamp)
+ -rm -f kern/arm/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/arm/efi/$(am__dirstamp)
+ -rm -f kern/arm/uboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/arm/uboot/$(am__dirstamp)
+ -rm -f kern/arm64/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/arm64/$(am__dirstamp)
+ -rm -f kern/arm64/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/arm64/efi/$(am__dirstamp)
+ -rm -f kern/coreboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/coreboot/$(am__dirstamp)
+ -rm -f kern/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/efi/$(am__dirstamp)
+ -rm -f kern/emu/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/emu/$(am__dirstamp)
+ -rm -f kern/generic/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/generic/$(am__dirstamp)
+ -rm -f kern/i386/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/i386/$(am__dirstamp)
+ -rm -f kern/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/i386/coreboot/$(am__dirstamp)
+ -rm -f kern/i386/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/i386/efi/$(am__dirstamp)
+ -rm -f kern/i386/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/i386/ieee1275/$(am__dirstamp)
+ -rm -f kern/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/i386/pc/$(am__dirstamp)
+ -rm -f kern/i386/qemu/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/i386/qemu/$(am__dirstamp)
+ -rm -f kern/i386/xen/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/i386/xen/$(am__dirstamp)
+ -rm -f kern/ia64/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/ia64/$(am__dirstamp)
+ -rm -f kern/ia64/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/ia64/efi/$(am__dirstamp)
+ -rm -f kern/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/ieee1275/$(am__dirstamp)
+ -rm -f kern/mips/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/mips/$(am__dirstamp)
+ -rm -f kern/mips/arc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/mips/arc/$(am__dirstamp)
+ -rm -f kern/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/mips/loongson/$(am__dirstamp)
+ -rm -f kern/mips/qemu_mips/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/mips/qemu_mips/$(am__dirstamp)
+ -rm -f kern/powerpc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/powerpc/$(am__dirstamp)
+ -rm -f kern/powerpc/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/powerpc/ieee1275/$(am__dirstamp)
+ -rm -f kern/riscv/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/riscv/$(am__dirstamp)
+ -rm -f kern/riscv/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/riscv/efi/$(am__dirstamp)
+ -rm -f kern/sparc64/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/sparc64/$(am__dirstamp)
+ -rm -f kern/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/sparc64/ieee1275/$(am__dirstamp)
+ -rm -f kern/uboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/uboot/$(am__dirstamp)
+ -rm -f kern/x86_64/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/x86_64/$(am__dirstamp)
+ -rm -f kern/x86_64/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/x86_64/efi/$(am__dirstamp)
+ -rm -f kern/x86_64/xen/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/x86_64/xen/$(am__dirstamp)
+ -rm -f kern/xen/$(DEPDIR)/$(am__dirstamp)
+ -rm -f kern/xen/$(am__dirstamp)
+ -rm -f lib/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/$(am__dirstamp)
+ -rm -f lib/arc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/arc/$(am__dirstamp)
+ -rm -f lib/dummy/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/dummy/$(am__dirstamp)
+ -rm -f lib/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/efi/$(am__dirstamp)
+ -rm -f lib/emu/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/emu/$(am__dirstamp)
+ -rm -f lib/gnulib/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/gnulib/$(am__dirstamp)
+ -rm -f lib/i386/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/i386/$(am__dirstamp)
+ -rm -f lib/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/i386/pc/$(am__dirstamp)
+ -rm -f lib/i386/xen/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/i386/xen/$(am__dirstamp)
+ -rm -f lib/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/ieee1275/$(am__dirstamp)
+ -rm -f lib/json/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/json/$(am__dirstamp)
+ -rm -f lib/libgcrypt-grub/cipher/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/libgcrypt-grub/cipher/$(am__dirstamp)
+ -rm -f lib/libgcrypt-grub/mpi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/libgcrypt-grub/mpi/$(am__dirstamp)
+ -rm -f lib/libgcrypt_wrap/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/libgcrypt_wrap/$(am__dirstamp)
+ -rm -f lib/minilzo/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/minilzo/$(am__dirstamp)
+ -rm -f lib/mips/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/mips/$(am__dirstamp)
+ -rm -f lib/mips/arc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/mips/arc/$(am__dirstamp)
+ -rm -f lib/mips/loongson/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/mips/loongson/$(am__dirstamp)
+ -rm -f lib/mips/qemu_mips/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/mips/qemu_mips/$(am__dirstamp)
+ -rm -f lib/powerpc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/powerpc/$(am__dirstamp)
+ -rm -f lib/uboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/uboot/$(am__dirstamp)
+ -rm -f lib/x86_64/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/x86_64/$(am__dirstamp)
+ -rm -f lib/x86_64/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/x86_64/efi/$(am__dirstamp)
+ -rm -f lib/x86_64/xen/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/x86_64/xen/$(am__dirstamp)
+ -rm -f lib/xen/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/xen/$(am__dirstamp)
+ -rm -f lib/xzembed/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/xzembed/$(am__dirstamp)
+ -rm -f lib/zstd/$(DEPDIR)/$(am__dirstamp)
+ -rm -f lib/zstd/$(am__dirstamp)
+ -rm -f loader/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/$(am__dirstamp)
+ -rm -f loader/arm/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/arm/$(am__dirstamp)
+ -rm -f loader/arm64/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/arm64/$(am__dirstamp)
+ -rm -f loader/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/efi/$(am__dirstamp)
+ -rm -f loader/i386/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/i386/$(am__dirstamp)
+ -rm -f loader/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/i386/coreboot/$(am__dirstamp)
+ -rm -f loader/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/i386/pc/$(am__dirstamp)
+ -rm -f loader/ia64/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/ia64/efi/$(am__dirstamp)
+ -rm -f loader/mips/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/mips/$(am__dirstamp)
+ -rm -f loader/powerpc/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/powerpc/ieee1275/$(am__dirstamp)
+ -rm -f loader/riscv/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/riscv/$(am__dirstamp)
+ -rm -f loader/sparc64/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f loader/sparc64/ieee1275/$(am__dirstamp)
+ -rm -f mmap/$(DEPDIR)/$(am__dirstamp)
+ -rm -f mmap/$(am__dirstamp)
+ -rm -f mmap/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f mmap/efi/$(am__dirstamp)
+ -rm -f mmap/i386/$(DEPDIR)/$(am__dirstamp)
+ -rm -f mmap/i386/$(am__dirstamp)
+ -rm -f mmap/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f mmap/i386/pc/$(am__dirstamp)
+ -rm -f mmap/mips/$(DEPDIR)/$(am__dirstamp)
+ -rm -f mmap/mips/$(am__dirstamp)
+ -rm -f net/$(DEPDIR)/$(am__dirstamp)
+ -rm -f net/$(am__dirstamp)
+ -rm -f net/drivers/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f net/drivers/efi/$(am__dirstamp)
+ -rm -f net/drivers/emu/$(DEPDIR)/$(am__dirstamp)
+ -rm -f net/drivers/emu/$(am__dirstamp)
+ -rm -f net/drivers/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f net/drivers/i386/pc/$(am__dirstamp)
+ -rm -f net/drivers/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f net/drivers/ieee1275/$(am__dirstamp)
+ -rm -f net/drivers/uboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f net/drivers/uboot/$(am__dirstamp)
+ -rm -f normal/$(DEPDIR)/$(am__dirstamp)
+ -rm -f normal/$(am__dirstamp)
+ -rm -f osdep/$(DEPDIR)/$(am__dirstamp)
+ -rm -f osdep/$(am__dirstamp)
+ -rm -f osdep/devmapper/$(DEPDIR)/$(am__dirstamp)
+ -rm -f osdep/devmapper/$(am__dirstamp)
+ -rm -f osdep/unix/$(DEPDIR)/$(am__dirstamp)
+ -rm -f osdep/unix/$(am__dirstamp)
+ -rm -f partmap/$(DEPDIR)/$(am__dirstamp)
+ -rm -f partmap/$(am__dirstamp)
+ -rm -f parttool/$(DEPDIR)/$(am__dirstamp)
+ -rm -f parttool/$(am__dirstamp)
+ -rm -f script/$(DEPDIR)/$(am__dirstamp)
+ -rm -f script/$(am__dirstamp)
+ -rm -f term/$(DEPDIR)/$(am__dirstamp)
+ -rm -f term/$(am__dirstamp)
+ -rm -f term/arc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f term/arc/$(am__dirstamp)
+ -rm -f term/arm/$(DEPDIR)/$(am__dirstamp)
+ -rm -f term/arm/$(am__dirstamp)
+ -rm -f term/efi/$(DEPDIR)/$(am__dirstamp)
+ -rm -f term/efi/$(am__dirstamp)
+ -rm -f term/i386/coreboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f term/i386/coreboot/$(am__dirstamp)
+ -rm -f term/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f term/i386/pc/$(am__dirstamp)
+ -rm -f term/ieee1275/$(DEPDIR)/$(am__dirstamp)
+ -rm -f term/ieee1275/$(am__dirstamp)
+ -rm -f term/uboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f term/uboot/$(am__dirstamp)
+ -rm -f term/xen/$(DEPDIR)/$(am__dirstamp)
+ -rm -f term/xen/$(am__dirstamp)
+ -rm -f tests/$(DEPDIR)/$(am__dirstamp)
+ -rm -f tests/$(am__dirstamp)
+ -rm -f tests/lib/$(DEPDIR)/$(am__dirstamp)
+ -rm -f tests/lib/$(am__dirstamp)
+ -rm -f video/$(DEPDIR)/$(am__dirstamp)
+ -rm -f video/$(am__dirstamp)
+ -rm -f video/coreboot/$(DEPDIR)/$(am__dirstamp)
+ -rm -f video/coreboot/$(am__dirstamp)
+ -rm -f video/emu/$(DEPDIR)/$(am__dirstamp)
+ -rm -f video/emu/$(am__dirstamp)
+ -rm -f video/fb/$(DEPDIR)/$(am__dirstamp)
+ -rm -f video/fb/$(am__dirstamp)
+ -rm -f video/i386/pc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f video/i386/pc/$(am__dirstamp)
+ -rm -f video/readers/$(DEPDIR)/$(am__dirstamp)
+ -rm -f video/readers/$(am__dirstamp)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
+ clean-noinstLIBRARIES clean-noinstPROGRAMS \
+ clean-platformPROGRAMS clean-sbinPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR) boot/decompressor/$(DEPDIR) boot/i386/pc/$(DEPDIR) boot/i386/qemu/$(DEPDIR) boot/mips/$(DEPDIR) boot/mips/loongson/$(DEPDIR) boot/sparc64/ieee1275/$(DEPDIR) bus/$(DEPDIR) bus/emu/$(DEPDIR) bus/i386/ieee1275/$(DEPDIR) bus/spi/$(DEPDIR) bus/usb/$(DEPDIR) bus/usb/serial/$(DEPDIR) commands/$(DEPDIR) commands/arc/$(DEPDIR) commands/efi/$(DEPDIR) commands/i386/$(DEPDIR) commands/i386/coreboot/$(DEPDIR) commands/i386/pc/$(DEPDIR) commands/ieee1275/$(DEPDIR) commands/mips/loongson/$(DEPDIR) commands/xen/$(DEPDIR) disk/$(DEPDIR) disk/arc/$(DEPDIR) disk/efi/$(DEPDIR) disk/i386/pc/$(DEPDIR) disk/ieee1275/$(DEPDIR) disk/uboot/$(DEPDIR) disk/xen/$(DEPDIR) efiemu/$(DEPDIR) efiemu/i386/$(DEPDIR) efiemu/i386/pc/$(DEPDIR) font/$(DEPDIR) fs/$(DEPDIR) fs/zfs/$(DEPDIR) gdb/$(DEPDIR) gdb/i386/$(DEPDIR) gettext/$(DEPDIR) gfxmenu/$(DEPDIR) hello/$(DEPDIR) hook/$(DEPDIR) io/$(DEPDIR) kern/$(DEPDIR) kern/arm/$(DEPDIR) kern/arm/coreboot/$(DEPDIR) kern/arm/efi/$(DEPDIR) kern/arm/uboot/$(DEPDIR) kern/arm64/$(DEPDIR) kern/arm64/efi/$(DEPDIR) kern/coreboot/$(DEPDIR) kern/efi/$(DEPDIR) kern/emu/$(DEPDIR) kern/generic/$(DEPDIR) kern/i386/$(DEPDIR) kern/i386/coreboot/$(DEPDIR) kern/i386/efi/$(DEPDIR) kern/i386/ieee1275/$(DEPDIR) kern/i386/pc/$(DEPDIR) kern/i386/qemu/$(DEPDIR) kern/i386/xen/$(DEPDIR) kern/ia64/$(DEPDIR) kern/ia64/efi/$(DEPDIR) kern/ieee1275/$(DEPDIR) kern/mips/$(DEPDIR) kern/mips/arc/$(DEPDIR) kern/mips/loongson/$(DEPDIR) kern/mips/qemu_mips/$(DEPDIR) kern/powerpc/$(DEPDIR) kern/powerpc/ieee1275/$(DEPDIR) kern/riscv/$(DEPDIR) kern/riscv/efi/$(DEPDIR) kern/sparc64/$(DEPDIR) kern/sparc64/ieee1275/$(DEPDIR) kern/uboot/$(DEPDIR) kern/x86_64/$(DEPDIR) kern/x86_64/efi/$(DEPDIR) kern/x86_64/xen/$(DEPDIR) kern/xen/$(DEPDIR) lib/$(DEPDIR) lib/arc/$(DEPDIR) lib/dummy/$(DEPDIR) lib/efi/$(DEPDIR) lib/emu/$(DEPDIR) lib/gnulib/$(DEPDIR) lib/i386/$(DEPDIR) lib/i386/pc/$(DEPDIR) lib/i386/xen/$(DEPDIR) lib/ieee1275/$(DEPDIR) lib/json/$(DEPDIR) lib/libgcrypt-grub/cipher/$(DEPDIR) lib/libgcrypt-grub/mpi/$(DEPDIR) lib/libgcrypt_wrap/$(DEPDIR) lib/minilzo/$(DEPDIR) lib/mips/$(DEPDIR) lib/mips/arc/$(DEPDIR) lib/mips/loongson/$(DEPDIR) lib/mips/qemu_mips/$(DEPDIR) lib/powerpc/$(DEPDIR) lib/uboot/$(DEPDIR) lib/x86_64/$(DEPDIR) lib/x86_64/efi/$(DEPDIR) lib/x86_64/xen/$(DEPDIR) lib/xen/$(DEPDIR) lib/xzembed/$(DEPDIR) lib/zstd/$(DEPDIR) loader/$(DEPDIR) loader/arm/$(DEPDIR) loader/arm64/$(DEPDIR) loader/efi/$(DEPDIR) loader/i386/$(DEPDIR) loader/i386/coreboot/$(DEPDIR) loader/i386/pc/$(DEPDIR) loader/ia64/efi/$(DEPDIR) loader/mips/$(DEPDIR) loader/powerpc/ieee1275/$(DEPDIR) loader/riscv/$(DEPDIR) loader/sparc64/ieee1275/$(DEPDIR) mmap/$(DEPDIR) mmap/efi/$(DEPDIR) mmap/i386/$(DEPDIR) mmap/i386/pc/$(DEPDIR) mmap/mips/$(DEPDIR) net/$(DEPDIR) net/drivers/efi/$(DEPDIR) net/drivers/emu/$(DEPDIR) net/drivers/i386/pc/$(DEPDIR) net/drivers/ieee1275/$(DEPDIR) net/drivers/uboot/$(DEPDIR) normal/$(DEPDIR) osdep/$(DEPDIR) osdep/devmapper/$(DEPDIR) osdep/unix/$(DEPDIR) partmap/$(DEPDIR) parttool/$(DEPDIR) script/$(DEPDIR) term/$(DEPDIR) term/arc/$(DEPDIR) term/arm/$(DEPDIR) term/efi/$(DEPDIR) term/i386/coreboot/$(DEPDIR) term/i386/pc/$(DEPDIR) term/ieee1275/$(DEPDIR) term/uboot/$(DEPDIR) term/xen/$(DEPDIR) tests/$(DEPDIR) tests/lib/$(DEPDIR) video/$(DEPDIR) video/coreboot/$(DEPDIR) video/emu/$(DEPDIR) video/fb/$(DEPDIR) video/i386/pc/$(DEPDIR) video/readers/$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-dist_grubconfDATA install-grubconfSCRIPTS \
+ install-man install-pkgdataDATA install-platformDATA \
+ install-platformPROGRAMS install-platformSCRIPTS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS install-binSCRIPTS \
+ install-sbinPROGRAMS install-sbinSCRIPTS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man1
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR) boot/decompressor/$(DEPDIR) boot/i386/pc/$(DEPDIR) boot/i386/qemu/$(DEPDIR) boot/mips/$(DEPDIR) boot/mips/loongson/$(DEPDIR) boot/sparc64/ieee1275/$(DEPDIR) bus/$(DEPDIR) bus/emu/$(DEPDIR) bus/i386/ieee1275/$(DEPDIR) bus/spi/$(DEPDIR) bus/usb/$(DEPDIR) bus/usb/serial/$(DEPDIR) commands/$(DEPDIR) commands/arc/$(DEPDIR) commands/efi/$(DEPDIR) commands/i386/$(DEPDIR) commands/i386/coreboot/$(DEPDIR) commands/i386/pc/$(DEPDIR) commands/ieee1275/$(DEPDIR) commands/mips/loongson/$(DEPDIR) commands/xen/$(DEPDIR) disk/$(DEPDIR) disk/arc/$(DEPDIR) disk/efi/$(DEPDIR) disk/i386/pc/$(DEPDIR) disk/ieee1275/$(DEPDIR) disk/uboot/$(DEPDIR) disk/xen/$(DEPDIR) efiemu/$(DEPDIR) efiemu/i386/$(DEPDIR) efiemu/i386/pc/$(DEPDIR) font/$(DEPDIR) fs/$(DEPDIR) fs/zfs/$(DEPDIR) gdb/$(DEPDIR) gdb/i386/$(DEPDIR) gettext/$(DEPDIR) gfxmenu/$(DEPDIR) hello/$(DEPDIR) hook/$(DEPDIR) io/$(DEPDIR) kern/$(DEPDIR) kern/arm/$(DEPDIR) kern/arm/coreboot/$(DEPDIR) kern/arm/efi/$(DEPDIR) kern/arm/uboot/$(DEPDIR) kern/arm64/$(DEPDIR) kern/arm64/efi/$(DEPDIR) kern/coreboot/$(DEPDIR) kern/efi/$(DEPDIR) kern/emu/$(DEPDIR) kern/generic/$(DEPDIR) kern/i386/$(DEPDIR) kern/i386/coreboot/$(DEPDIR) kern/i386/efi/$(DEPDIR) kern/i386/ieee1275/$(DEPDIR) kern/i386/pc/$(DEPDIR) kern/i386/qemu/$(DEPDIR) kern/i386/xen/$(DEPDIR) kern/ia64/$(DEPDIR) kern/ia64/efi/$(DEPDIR) kern/ieee1275/$(DEPDIR) kern/mips/$(DEPDIR) kern/mips/arc/$(DEPDIR) kern/mips/loongson/$(DEPDIR) kern/mips/qemu_mips/$(DEPDIR) kern/powerpc/$(DEPDIR) kern/powerpc/ieee1275/$(DEPDIR) kern/riscv/$(DEPDIR) kern/riscv/efi/$(DEPDIR) kern/sparc64/$(DEPDIR) kern/sparc64/ieee1275/$(DEPDIR) kern/uboot/$(DEPDIR) kern/x86_64/$(DEPDIR) kern/x86_64/efi/$(DEPDIR) kern/x86_64/xen/$(DEPDIR) kern/xen/$(DEPDIR) lib/$(DEPDIR) lib/arc/$(DEPDIR) lib/dummy/$(DEPDIR) lib/efi/$(DEPDIR) lib/emu/$(DEPDIR) lib/gnulib/$(DEPDIR) lib/i386/$(DEPDIR) lib/i386/pc/$(DEPDIR) lib/i386/xen/$(DEPDIR) lib/ieee1275/$(DEPDIR) lib/json/$(DEPDIR) lib/libgcrypt-grub/cipher/$(DEPDIR) lib/libgcrypt-grub/mpi/$(DEPDIR) lib/libgcrypt_wrap/$(DEPDIR) lib/minilzo/$(DEPDIR) lib/mips/$(DEPDIR) lib/mips/arc/$(DEPDIR) lib/mips/loongson/$(DEPDIR) lib/mips/qemu_mips/$(DEPDIR) lib/powerpc/$(DEPDIR) lib/uboot/$(DEPDIR) lib/x86_64/$(DEPDIR) lib/x86_64/efi/$(DEPDIR) lib/x86_64/xen/$(DEPDIR) lib/xen/$(DEPDIR) lib/xzembed/$(DEPDIR) lib/zstd/$(DEPDIR) loader/$(DEPDIR) loader/arm/$(DEPDIR) loader/arm64/$(DEPDIR) loader/efi/$(DEPDIR) loader/i386/$(DEPDIR) loader/i386/coreboot/$(DEPDIR) loader/i386/pc/$(DEPDIR) loader/ia64/efi/$(DEPDIR) loader/mips/$(DEPDIR) loader/powerpc/ieee1275/$(DEPDIR) loader/riscv/$(DEPDIR) loader/sparc64/ieee1275/$(DEPDIR) mmap/$(DEPDIR) mmap/efi/$(DEPDIR) mmap/i386/$(DEPDIR) mmap/i386/pc/$(DEPDIR) mmap/mips/$(DEPDIR) net/$(DEPDIR) net/drivers/efi/$(DEPDIR) net/drivers/emu/$(DEPDIR) net/drivers/i386/pc/$(DEPDIR) net/drivers/ieee1275/$(DEPDIR) net/drivers/uboot/$(DEPDIR) normal/$(DEPDIR) osdep/$(DEPDIR) osdep/devmapper/$(DEPDIR) osdep/unix/$(DEPDIR) partmap/$(DEPDIR) parttool/$(DEPDIR) script/$(DEPDIR) term/$(DEPDIR) term/arc/$(DEPDIR) term/arm/$(DEPDIR) term/efi/$(DEPDIR) term/i386/coreboot/$(DEPDIR) term/i386/pc/$(DEPDIR) term/ieee1275/$(DEPDIR) term/uboot/$(DEPDIR) term/xen/$(DEPDIR) tests/$(DEPDIR) tests/lib/$(DEPDIR) video/$(DEPDIR) video/coreboot/$(DEPDIR) video/emu/$(DEPDIR) video/fb/$(DEPDIR) video/i386/pc/$(DEPDIR) video/readers/$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+ uninstall-dist_grubconfDATA uninstall-grubconfSCRIPTS \
+ uninstall-man uninstall-pkgdataDATA uninstall-platformDATA \
+ uninstall-platformPROGRAMS uninstall-platformSCRIPTS \
+ uninstall-sbinPROGRAMS uninstall-sbinSCRIPTS
+
+uninstall-man: uninstall-man1
+
+.MAKE: all check check-am install install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \
+ clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
+ clean-noinstLIBRARIES clean-noinstPROGRAMS \
+ clean-platformPROGRAMS clean-sbinPROGRAMS cscopelist-am ctags \
+ ctags-am distclean distclean-compile distclean-generic \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-binPROGRAMS install-binSCRIPTS \
+ install-data install-data-am install-dist_grubconfDATA \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-grubconfSCRIPTS install-html install-html-am \
+ install-info install-info-am install-man install-man1 \
+ install-pdf install-pdf-am install-pkgdataDATA \
+ install-platformDATA install-platformPROGRAMS \
+ install-platformSCRIPTS install-ps install-ps-am \
+ install-sbinPROGRAMS install-sbinSCRIPTS install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic pdf pdf-am ps ps-am recheck tags tags-am \
+ uninstall uninstall-am uninstall-binPROGRAMS \
+ uninstall-binSCRIPTS uninstall-dist_grubconfDATA \
+ uninstall-grubconfSCRIPTS uninstall-man uninstall-man1 \
+ uninstall-pkgdataDATA uninstall-platformDATA \
+ uninstall-platformPROGRAMS uninstall-platformSCRIPTS \
+ uninstall-sbinPROGRAMS uninstall-sbinSCRIPTS
+
+.PRECIOUS: Makefile
+
+
+export LC_COLLATE := C
+unexport LC_ALL
+
+# Rules for Automake input
+
+.PRECIOUS: $(top_srcdir)/Makefile.util.am
+$(top_srcdir)/Makefile.util.am: $(top_srcdir)/gentpl.py $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def
+ $(PYTHON) $^ > $@.new || (rm -f $@.new; exit 1)
+ mv $@.new $@
+
+.PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am
+$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/gentpl.py $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def
+ if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./bootstrap manually." >&2; exit 1; fi
+ $(PYTHON) $^ > $@.new || (rm -f $@.new; exit 1)
+ mv $@.new $@
+
+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\" $^
+
+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\" $^
+
+# gentrigtables
+gentrigtables$(BUILD_EXEEXT): gentrigtables.c
+ $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM)
+
+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\" $^
+
+# trigtables.c
+trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac
+ ./gentrigtables$(BUILD_EXEEXT) > $@
+
+# XXX Use Automake's LEX & YACC support
+grub_script.tab.h: script/parser.y
+ $(YACC) -d -p grub_script_yy -b grub_script $<
+grub_script.tab.c: grub_script.tab.h
+
+# For the lexer.
+grub_script.yy.h: script/yylex.l
+ $(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h $<
+grub_script.yy.c: grub_script.yy.h
+
+rs_decoder.h: $(srcdir)/lib/reed_solomon.c
+ $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Os -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3 -ffreestanding
+
+disk.marker: $(disk_module_SOURCES) $(nodist_disk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(disk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+trig.marker: $(trig_module_SOURCES) $(nodist_trig_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(trig_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@cs5536.marker: $(cs5536_module_SOURCES) $(nodist_cs5536_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cs5536_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@lsspd.marker: $(lsspd_module_SOURCES) $(nodist_lsspd_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsspd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@usb.marker: $(usb_module_SOURCES) $(nodist_usb_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@usbserial_common.marker: $(usbserial_common_module_SOURCES) $(nodist_usbserial_common_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_common_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@usbserial_pl2303.marker: $(usbserial_pl2303_module_SOURCES) $(nodist_usbserial_pl2303_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_pl2303_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@usbserial_ftdi.marker: $(usbserial_ftdi_module_SOURCES) $(nodist_usbserial_ftdi_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_ftdi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@usbserial_usbdebug.marker: $(usbserial_usbdebug_module_SOURCES) $(nodist_usbserial_usbdebug_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbserial_usbdebug_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@uhci.marker: $(uhci_module_SOURCES) $(nodist_uhci_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uhci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@ohci.marker: $(ohci_module_SOURCES) $(nodist_ohci_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ohci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@ehci.marker: $(ehci_module_SOURCES) $(nodist_ehci_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ehci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@pci.marker: $(pci_module_SOURCES) $(nodist_pci_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@pci.marker: $(pci_module_SOURCES) $(nodist_pci_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@pci.marker: $(pci_module_SOURCES) $(nodist_pci_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@pci.marker: $(pci_module_SOURCES) $(nodist_pci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@nativedisk.marker: $(nativedisk_module_SOURCES) $(nodist_nativedisk_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nativedisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@emupci.marker: $(emupci_module_SOURCES) $(nodist_emupci_module_SOURCES)
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emupci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_GRUB_EMU_PCI_TRUE@@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@lsdev.marker: $(lsdev_module_SOURCES) $(nodist_lsdev_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsdev_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@lsxen.marker: $(lsxen_module_SOURCES) $(nodist_lsxen_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsxen_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@lsxen.marker: $(lsxen_module_SOURCES) $(nodist_lsxen_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsxen_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@cmostest.marker: $(cmostest_module_SOURCES) $(nodist_cmostest_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmostest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@cmosdump.marker: $(cmosdump_module_SOURCES) $(nodist_cmosdump_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmosdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@iorw.marker: $(iorw_module_SOURCES) $(nodist_iorw_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iorw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@cbtable.marker: $(cbtable_module_SOURCES) $(nodist_cbtable_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtable_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@cbtime.marker: $(cbtime_module_SOURCES) $(nodist_cbtime_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbtime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@cbls.marker: $(cbls_module_SOURCES) $(nodist_cbls_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@cbmemc.marker: $(cbmemc_module_SOURCES) $(nodist_cbmemc_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbmemc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+regexp.marker: $(regexp_module_SOURCES) $(nodist_regexp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(regexp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@acpi.marker: $(acpi_module_SOURCES) $(nodist_acpi_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(acpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@lsacpi.marker: $(lsacpi_module_SOURCES) $(nodist_lsacpi_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsacpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@lsefisystab.marker: $(lsefisystab_module_SOURCES) $(nodist_lsefisystab_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefisystab_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@lssal.marker: $(lssal_module_SOURCES) $(nodist_lssal_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lssal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@lsefimmap.marker: $(lsefimmap_module_SOURCES) $(nodist_lsefimmap_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefimmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@lsefi.marker: $(lsefi_module_SOURCES) $(nodist_lsefi_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsefi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@efifwsetup.marker: $(efifwsetup_module_SOURCES) $(nodist_efifwsetup_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efifwsetup_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+blocklist.marker: $(blocklist_module_SOURCES) $(nodist_blocklist_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(blocklist_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@boot.marker: $(boot_module_SOURCES) $(nodist_boot_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+cat.marker: $(cat_module_SOURCES) $(nodist_cat_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cat_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+cmp.marker: $(cmp_module_SOURCES) $(nodist_cmp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+configfile.marker: $(configfile_module_SOURCES) $(nodist_configfile_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(configfile_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@cpuid.marker: $(cpuid_module_SOURCES) $(nodist_cpuid_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+date.marker: $(date_module_SOURCES) $(nodist_date_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(date_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@drivemap.marker: $(drivemap_module_SOURCES) $(nodist_drivemap_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(drivemap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+echo.marker: $(echo_module_SOURCES) $(nodist_echo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(echo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+eval.marker: $(eval_module_SOURCES) $(nodist_eval_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(eval_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@extcmd.marker: $(extcmd_module_SOURCES) $(nodist_extcmd_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(extcmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@fixvideo.marker: $(fixvideo_module_SOURCES) $(nodist_fixvideo_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fixvideo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@fixvideo.marker: $(fixvideo_module_SOURCES) $(nodist_fixvideo_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fixvideo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gptsync.marker: $(gptsync_module_SOURCES) $(nodist_gptsync_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gptsync_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@halt.marker: $(halt_module_SOURCES) $(nodist_halt_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(halt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@reboot.marker: $(reboot_module_SOURCES) $(nodist_reboot_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+hashsum.marker: $(hashsum_module_SOURCES) $(nodist_hashsum_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hashsum_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+pgp.marker: $(pgp_module_SOURCES) $(nodist_pgp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pgp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@hdparm.marker: $(hdparm_module_SOURCES) $(nodist_hdparm_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hdparm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+help.marker: $(help_module_SOURCES) $(nodist_help_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(help_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+hexdump.marker: $(hexdump_module_SOURCES) $(nodist_hexdump_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hexdump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+keystatus.marker: $(keystatus_module_SOURCES) $(nodist_keystatus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keystatus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@loadbios.marker: $(loadbios_module_SOURCES) $(nodist_loadbios_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@loadbios.marker: $(loadbios_module_SOURCES) $(nodist_loadbios_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+loadenv.marker: $(loadenv_module_SOURCES) $(nodist_loadenv_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loadenv_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+ls.marker: $(ls_module_SOURCES) $(nodist_ls_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ls_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+lsmmap.marker: $(lsmmap_module_SOURCES) $(nodist_lsmmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsmmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@lspci.marker: $(lspci_module_SOURCES) $(nodist_lspci_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lspci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+memrw.marker: $(memrw_module_SOURCES) $(nodist_memrw_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memrw_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+minicmd.marker: $(minicmd_module_SOURCES) $(nodist_minicmd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minicmd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+parttool.marker: $(parttool_module_SOURCES) $(nodist_parttool_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(parttool_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+password.marker: $(password_module_SOURCES) $(nodist_password_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+password_pbkdf2.marker: $(password_pbkdf2_module_SOURCES) $(nodist_password_pbkdf2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(password_pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@play.marker: $(play_module_SOURCES) $(nodist_play_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(play_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@spkmodem.marker: $(spkmodem_module_SOURCES) $(nodist_spkmodem_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spkmodem_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@morse.marker: $(morse_module_SOURCES) $(nodist_morse_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(morse_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+probe.marker: $(probe_module_SOURCES) $(nodist_probe_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(probe_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+read.marker: $(read_module_SOURCES) $(nodist_read_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(read_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+search.marker: $(search_module_SOURCES) $(nodist_search_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+search_fs_file.marker: $(search_fs_file_module_SOURCES) $(nodist_search_fs_file_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_file_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+search_fs_uuid.marker: $(search_fs_uuid_module_SOURCES) $(nodist_search_fs_uuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_fs_uuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+search_label.marker: $(search_label_module_SOURCES) $(nodist_search_label_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(search_label_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@setpci.marker: $(setpci_module_SOURCES) $(nodist_setpci_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setpci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@pcidump.marker: $(pcidump_module_SOURCES) $(nodist_pcidump_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pcidump_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+sleep.marker: $(sleep_module_SOURCES) $(nodist_sleep_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@smbios.marker: $(smbios_module_SOURCES) $(nodist_smbios_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(smbios_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@suspend.marker: $(suspend_module_SOURCES) $(nodist_suspend_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@suspend.marker: $(suspend_module_SOURCES) $(nodist_suspend_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@escc.marker: $(escc_module_SOURCES) $(nodist_escc_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(escc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+terminal.marker: $(terminal_module_SOURCES) $(nodist_terminal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+test.marker: $(test_module_SOURCES) $(nodist_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+true.marker: $(true_module_SOURCES) $(nodist_true_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(true_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@usbtest.marker: $(usbtest_module_SOURCES) $(nodist_usbtest_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbtest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+videoinfo.marker: $(videoinfo_module_SOURCES) $(nodist_videoinfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videoinfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+videotest.marker: $(videotest_module_SOURCES) $(nodist_videotest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+xnu_uuid.marker: $(xnu_uuid_module_SOURCES) $(nodist_xnu_uuid_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+dm_nv.marker: $(dm_nv_module_SOURCES) $(nodist_dm_nv_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dm_nv_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+loopback.marker: $(loopback_module_SOURCES) $(nodist_loopback_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(loopback_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+cryptodisk.marker: $(cryptodisk_module_SOURCES) $(nodist_cryptodisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cryptodisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+json.marker: $(json_module_SOURCES) $(nodist_json_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(json_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+afsplitter.marker: $(afsplitter_module_SOURCES) $(nodist_afsplitter_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afsplitter_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+luks.marker: $(luks_module_SOURCES) $(nodist_luks_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+luks2.marker: $(luks2_module_SOURCES) $(nodist_luks2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(luks2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+geli.marker: $(geli_module_SOURCES) $(nodist_geli_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(geli_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+lvm.marker: $(lvm_module_SOURCES) $(nodist_lvm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lvm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+ldm.marker: $(ldm_module_SOURCES) $(nodist_ldm_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ldm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+mdraid09.marker: $(mdraid09_module_SOURCES) $(nodist_mdraid09_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+mdraid09_be.marker: $(mdraid09_be_module_SOURCES) $(nodist_mdraid09_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid09_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+mdraid1x.marker: $(mdraid1x_module_SOURCES) $(nodist_mdraid1x_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mdraid1x_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+diskfilter.marker: $(diskfilter_module_SOURCES) $(nodist_diskfilter_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(diskfilter_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+raid5rec.marker: $(raid5rec_module_SOURCES) $(nodist_raid5rec_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid5rec_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+raid6rec.marker: $(raid6rec_module_SOURCES) $(nodist_raid6rec_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(raid6rec_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+scsi.marker: $(scsi_module_SOURCES) $(nodist_scsi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(scsi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+memdisk.marker: $(memdisk_module_SOURCES) $(nodist_memdisk_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(memdisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@ata.marker: $(ata_module_SOURCES) $(nodist_ata_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@ahci.marker: $(ahci_module_SOURCES) $(nodist_ahci_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ahci_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@pata.marker: $(pata_module_SOURCES) $(nodist_pata_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pata_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@biosdisk.marker: $(biosdisk_module_SOURCES) $(nodist_biosdisk_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(biosdisk_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@usbms.marker: $(usbms_module_SOURCES) $(nodist_usbms_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usbms_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@nand.marker: $(nand_module_SOURCES) $(nodist_nand_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nand_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@efiemu.marker: $(efiemu_module_SOURCES) $(nodist_efiemu_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@efiemu.marker: $(efiemu_module_SOURCES) $(nodist_efiemu_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@efiemu.marker: $(efiemu_module_SOURCES) $(nodist_efiemu_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@efiemu.marker: $(efiemu_module_SOURCES) $(nodist_efiemu_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@efiemu.marker: $(efiemu_module_SOURCES) $(nodist_efiemu_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efiemu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@font.marker: $(font_module_SOURCES) $(nodist_font_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(font_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+procfs.marker: $(procfs_module_SOURCES) $(nodist_procfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(procfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+affs.marker: $(affs_module_SOURCES) $(nodist_affs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(affs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+afs.marker: $(afs_module_SOURCES) $(nodist_afs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(afs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+bfs.marker: $(bfs_module_SOURCES) $(nodist_bfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+zstd.marker: $(zstd_module_SOURCES) $(nodist_zstd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zstd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+btrfs.marker: $(btrfs_module_SOURCES) $(nodist_btrfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(btrfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+archelp.marker: $(archelp_module_SOURCES) $(nodist_archelp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(archelp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+cbfs.marker: $(cbfs_module_SOURCES) $(nodist_cbfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cbfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+cpio.marker: $(cpio_module_SOURCES) $(nodist_cpio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+cpio_be.marker: $(cpio_be_module_SOURCES) $(nodist_cpio_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cpio_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+newc.marker: $(newc_module_SOURCES) $(nodist_newc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(newc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+odc.marker: $(odc_module_SOURCES) $(nodist_odc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(odc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+ext2.marker: $(ext2_module_SOURCES) $(nodist_ext2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ext2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+fat.marker: $(fat_module_SOURCES) $(nodist_fat_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fat_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+exfat.marker: $(exfat_module_SOURCES) $(nodist_exfat_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfat_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+f2fs.marker: $(f2fs_module_SOURCES) $(nodist_f2fs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(f2fs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+fshelp.marker: $(fshelp_module_SOURCES) $(nodist_fshelp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fshelp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+hfs.marker: $(hfs_module_SOURCES) $(nodist_hfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+hfsplus.marker: $(hfsplus_module_SOURCES) $(nodist_hfsplus_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfsplus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+hfspluscomp.marker: $(hfspluscomp_module_SOURCES) $(nodist_hfspluscomp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hfspluscomp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+iso9660.marker: $(iso9660_module_SOURCES) $(nodist_iso9660_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(iso9660_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+jfs.marker: $(jfs_module_SOURCES) $(nodist_jfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+minix.marker: $(minix_module_SOURCES) $(nodist_minix_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+minix2.marker: $(minix2_module_SOURCES) $(nodist_minix2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+minix3.marker: $(minix3_module_SOURCES) $(nodist_minix3_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+minix_be.marker: $(minix_be_module_SOURCES) $(nodist_minix_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+minix2_be.marker: $(minix2_be_module_SOURCES) $(nodist_minix2_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix2_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+minix3_be.marker: $(minix3_be_module_SOURCES) $(nodist_minix3_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(minix3_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+nilfs2.marker: $(nilfs2_module_SOURCES) $(nodist_nilfs2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(nilfs2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+ntfs.marker: $(ntfs_module_SOURCES) $(nodist_ntfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+ntfscomp.marker: $(ntfscomp_module_SOURCES) $(nodist_ntfscomp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntfscomp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+reiserfs.marker: $(reiserfs_module_SOURCES) $(nodist_reiserfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(reiserfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+romfs.marker: $(romfs_module_SOURCES) $(nodist_romfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(romfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+sfs.marker: $(sfs_module_SOURCES) $(nodist_sfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+squash4.marker: $(squash4_module_SOURCES) $(nodist_squash4_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(squash4_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+tar.marker: $(tar_module_SOURCES) $(nodist_tar_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tar_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+udf.marker: $(udf_module_SOURCES) $(nodist_udf_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(udf_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+ufs1.marker: $(ufs1_module_SOURCES) $(nodist_ufs1_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+ufs1_be.marker: $(ufs1_be_module_SOURCES) $(nodist_ufs1_be_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs1_be_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+ufs2.marker: $(ufs2_module_SOURCES) $(nodist_ufs2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ufs2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+xfs.marker: $(xfs_module_SOURCES) $(nodist_xfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+zfs.marker: $(zfs_module_SOURCES) $(nodist_zfs_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+zfscrypt.marker: $(zfscrypt_module_SOURCES) $(nodist_zfscrypt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfscrypt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+zfsinfo.marker: $(zfsinfo_module_SOURCES) $(nodist_zfsinfo_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zfsinfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+macbless.marker: $(macbless_module_SOURCES) $(nodist_macbless_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macbless_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@pxe.marker: $(pxe_module_SOURCES) $(nodist_pxe_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxe_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gettext.marker: $(gettext_module_SOURCES) $(nodist_gettext_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gettext_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gfxmenu.marker: $(gfxmenu_module_SOURCES) $(nodist_gfxmenu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxmenu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+hello.marker: $(hello_module_SOURCES) $(nodist_hello_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hello_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gzio.marker: $(gzio_module_SOURCES) $(nodist_gzio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gzio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+offsetio.marker: $(offsetio_module_SOURCES) $(nodist_offsetio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(offsetio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@bufio.marker: $(bufio_module_SOURCES) $(nodist_bufio_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bufio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+elf.marker: $(elf_module_SOURCES) $(nodist_elf_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elf_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+crypto.marker: $(crypto_module_SOURCES) $(nodist_crypto_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crypto_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+pbkdf2.marker: $(pbkdf2_module_SOURCES) $(nodist_pbkdf2_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@relocator.marker: $(relocator_module_SOURCES) $(nodist_relocator_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(relocator_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@datetime.marker: $(datetime_module_SOURCES) $(nodist_datetime_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datetime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+setjmp.marker: $(setjmp_module_SOURCES) $(nodist_setjmp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@aout.marker: $(aout_module_SOURCES) $(nodist_aout_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aout_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@bsd.marker: $(bsd_module_SOURCES) $(nodist_bsd_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@plan9.marker: $(plan9_module_SOURCES) $(nodist_plan9_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(plan9_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@linux16.marker: $(linux16_module_SOURCES) $(nodist_linux16_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux16_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@ntldr.marker: $(ntldr_module_SOURCES) $(nodist_ntldr_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ntldr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@truecrypt.marker: $(truecrypt_module_SOURCES) $(nodist_truecrypt_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(truecrypt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@freedos.marker: $(freedos_module_SOURCES) $(nodist_freedos_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(freedos_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@pxechain.marker: $(pxechain_module_SOURCES) $(nodist_pxechain_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pxechain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@multiboot2.marker: $(multiboot2_module_SOURCES) $(nodist_multiboot2_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot2_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@multiboot.marker: $(multiboot_module_SOURCES) $(nodist_multiboot_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(multiboot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@xen_boot.marker: $(xen_boot_module_SOURCES) $(nodist_xen_boot_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xen_boot_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@linux.marker: $(linux_module_SOURCES) $(nodist_linux_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(linux_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@fdt.marker: $(fdt_module_SOURCES) $(nodist_fdt_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@fdt.marker: $(fdt_module_SOURCES) $(nodist_fdt_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@fdt.marker: $(fdt_module_SOURCES) $(nodist_fdt_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@fdt.marker: $(fdt_module_SOURCES) $(nodist_fdt_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@fdt.marker: $(fdt_module_SOURCES) $(nodist_fdt_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fdt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@xnu.marker: $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@xnu.marker: $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@xnu.marker: $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@xnu.marker: $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@xnu.marker: $(xnu_module_SOURCES) $(nodist_xnu_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@random.marker: $(random_module_SOURCES) $(nodist_random_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@random.marker: $(random_module_SOURCES) $(nodist_random_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@random.marker: $(random_module_SOURCES) $(nodist_random_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@random.marker: $(random_module_SOURCES) $(nodist_random_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@random.marker: $(random_module_SOURCES) $(nodist_random_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(random_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+macho.marker: $(macho_module_SOURCES) $(nodist_macho_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(macho_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@appleldr.marker: $(appleldr_module_SOURCES) $(nodist_appleldr_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(appleldr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@appleldr.marker: $(appleldr_module_SOURCES) $(nodist_appleldr_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(appleldr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@chain.marker: $(chain_module_SOURCES) $(nodist_chain_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(chain_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@mmap.marker: $(mmap_module_SOURCES) $(nodist_mmap_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+normal.marker: $(normal_module_SOURCES) $(nodist_normal_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(normal_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_acorn.marker: $(part_acorn_module_SOURCES) $(nodist_part_acorn_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_acorn_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_amiga.marker: $(part_amiga_module_SOURCES) $(nodist_part_amiga_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_amiga_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_apple.marker: $(part_apple_module_SOURCES) $(nodist_part_apple_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_apple_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_gpt.marker: $(part_gpt_module_SOURCES) $(nodist_part_gpt_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_gpt_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_msdos.marker: $(part_msdos_module_SOURCES) $(nodist_part_msdos_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_msdos_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_sun.marker: $(part_sun_module_SOURCES) $(nodist_part_sun_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sun_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_plan.marker: $(part_plan_module_SOURCES) $(nodist_part_plan_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_plan_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_dvh.marker: $(part_dvh_module_SOURCES) $(nodist_part_dvh_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dvh_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_bsd.marker: $(part_bsd_module_SOURCES) $(nodist_part_bsd_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_bsd_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_sunpc.marker: $(part_sunpc_module_SOURCES) $(nodist_part_sunpc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_sunpc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+part_dfly.marker: $(part_dfly_module_SOURCES) $(nodist_part_dfly_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(part_dfly_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+msdospart.marker: $(msdospart_module_SOURCES) $(nodist_msdospart_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(msdospart_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@at_keyboard.marker: $(at_keyboard_module_SOURCES) $(nodist_at_keyboard_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(at_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@gfxterm.marker: $(gfxterm_module_SOURCES) $(nodist_gfxterm_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gfxterm_background.marker: $(gfxterm_background_module_SOURCES) $(nodist_gfxterm_background_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_background_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@serial.marker: $(serial_module_SOURCES) $(nodist_serial_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(serial_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@sendkey.marker: $(sendkey_module_SOURCES) $(nodist_sendkey_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sendkey_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@terminfo.marker: $(terminfo_module_SOURCES) $(nodist_terminfo_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(terminfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_coreboot_TRUE@usb_keyboard.marker: $(usb_keyboard_module_SOURCES) $(nodist_usb_keyboard_module_SOURCES)
+@COND_arm_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(usb_keyboard_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@vga.marker: $(vga_module_SOURCES) $(nodist_vga_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@vga_text.marker: $(vga_text_module_SOURCES) $(nodist_vga_text_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vga_text_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@mda_text.marker: $(mda_text_module_SOURCES) $(nodist_mda_text_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@mda_text.marker: $(mda_text_module_SOURCES) $(nodist_mda_text_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@mda_text.marker: $(mda_text_module_SOURCES) $(nodist_mda_text_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@mda_text.marker: $(mda_text_module_SOURCES) $(nodist_mda_text_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mda_text_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@video_cirrus.marker: $(video_cirrus_module_SOURCES) $(nodist_video_cirrus_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_cirrus_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@video_bochs.marker: $(video_bochs_module_SOURCES) $(nodist_video_bochs_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_bochs_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+functional_test.marker: $(functional_test_module_SOURCES) $(nodist_functional_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(functional_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+exfctest.marker: $(exfctest_module_SOURCES) $(nodist_exfctest_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exfctest_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+strtoull_test.marker: $(strtoull_test_module_SOURCES) $(nodist_strtoull_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(strtoull_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+setjmp_test.marker: $(setjmp_test_module_SOURCES) $(nodist_setjmp_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(setjmp_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+signature_test.marker: $(signature_test_module_SOURCES) $(nodist_signature_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(signature_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+sleep_test.marker: $(sleep_test_module_SOURCES) $(nodist_sleep_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sleep_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+xnu_uuid_test.marker: $(xnu_uuid_test_module_SOURCES) $(nodist_xnu_uuid_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xnu_uuid_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+pbkdf2_test.marker: $(pbkdf2_test_module_SOURCES) $(nodist_pbkdf2_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pbkdf2_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@legacy_password_test.marker: $(legacy_password_test_module_SOURCES) $(nodist_legacy_password_test_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacy_password_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_loongson_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_mips_loongson_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_loongson_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@div.marker: $(div_module_SOURCES) $(nodist_div_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+div_test.marker: $(div_test_module_SOURCES) $(nodist_div_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(div_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+mul_test.marker: $(mul_test_module_SOURCES) $(nodist_mul_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mul_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+shift_test.marker: $(shift_test_module_SOURCES) $(nodist_shift_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(shift_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+cmp_test.marker: $(cmp_test_module_SOURCES) $(nodist_cmp_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmp_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+ctz_test.marker: $(ctz_test_module_SOURCES) $(nodist_ctz_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ctz_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+bswap_test.marker: $(bswap_test_module_SOURCES) $(nodist_bswap_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bswap_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+videotest_checksum.marker: $(videotest_checksum_module_SOURCES) $(nodist_videotest_checksum_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(videotest_checksum_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gfxterm_menu.marker: $(gfxterm_menu_module_SOURCES) $(nodist_gfxterm_menu_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gfxterm_menu_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+cmdline_cat_test.marker: $(cmdline_cat_test_module_SOURCES) $(nodist_cmdline_cat_test_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cmdline_cat_test_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+bitmap.marker: $(bitmap_module_SOURCES) $(nodist_bitmap_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+bitmap_scale.marker: $(bitmap_scale_module_SOURCES) $(nodist_bitmap_scale_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bitmap_scale_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@efi_gop.marker: $(efi_gop_module_SOURCES) $(nodist_efi_gop_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_gop_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@efi_uga.marker: $(efi_uga_module_SOURCES) $(nodist_efi_uga_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_uga_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@efi_uga.marker: $(efi_uga_module_SOURCES) $(nodist_efi_uga_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efi_uga_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+jpeg.marker: $(jpeg_module_SOURCES) $(nodist_jpeg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(jpeg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+png.marker: $(png_module_SOURCES) $(nodist_png_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(png_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+tga.marker: $(tga_module_SOURCES) $(nodist_tga_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tga_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@vbe.marker: $(vbe_module_SOURCES) $(nodist_vbe_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(vbe_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@video_fb.marker: $(video_fb_module_SOURCES) $(nodist_video_fb_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_arc_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_mips_arc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_arc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_mips_qemu_mips_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_mips_qemu_mips_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_mips_qemu_mips_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@video.marker: $(video_module_SOURCES) $(nodist_video_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+video_colors.marker: $(video_colors_module_SOURCES) $(nodist_video_colors_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(video_colors_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@ieee1275_fb.marker: $(ieee1275_fb_module_SOURCES) $(nodist_ieee1275_fb_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ieee1275_fb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@sdl.marker: $(sdl_module_SOURCES) $(nodist_sdl_module_SOURCES)
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sdl_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_GRUB_EMU_SDL_TRUE@@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+datehook.marker: $(datehook_module_SOURCES) $(nodist_datehook_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(datehook_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+net.marker: $(net_module_SOURCES) $(nodist_net_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(net_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+tftp.marker: $(tftp_module_SOURCES) $(nodist_tftp_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tftp_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+http.marker: $(http_module_SOURCES) $(nodist_http_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(http_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@ofnet.marker: $(ofnet_module_SOURCES) $(nodist_ofnet_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ofnet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_sparc64_ieee1275_TRUE@ofnet.marker: $(ofnet_module_SOURCES) $(nodist_ofnet_module_SOURCES)
+@COND_sparc64_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ofnet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_sparc64_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_powerpc_ieee1275_TRUE@ofnet.marker: $(ofnet_module_SOURCES) $(nodist_ofnet_module_SOURCES)
+@COND_powerpc_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ofnet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_powerpc_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_uboot_TRUE@ubootnet.marker: $(ubootnet_module_SOURCES) $(nodist_ubootnet_module_SOURCES)
+@COND_arm_uboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ubootnet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_uboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@efinet.marker: $(efinet_module_SOURCES) $(nodist_efinet_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(efinet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@emunet.marker: $(emunet_module_SOURCES) $(nodist_emunet_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(emunet_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+@COND_emu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_emu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@legacycfg.marker: $(legacycfg_module_SOURCES) $(nodist_legacycfg_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(legacycfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+syslinuxcfg.marker: $(syslinuxcfg_module_SOURCES) $(nodist_syslinuxcfg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(syslinuxcfg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+test_blockarg.marker: $(test_blockarg_module_SOURCES) $(nodist_test_blockarg_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_blockarg_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+xzio.marker: $(xzio_module_SOURCES) $(nodist_xzio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xzio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+lzopio.marker: $(lzopio_module_SOURCES) $(nodist_lzopio_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lzopio_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+testload.marker: $(testload_module_SOURCES) $(nodist_testload_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testload_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_TRUE@backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+@COND_i386_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_xen_TRUE@backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+@COND_x86_64_xen_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_xen_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_xen_pvh_TRUE@backtrace.marker: $(backtrace_module_SOURCES) $(nodist_backtrace_module_SOURCES)
+@COND_i386_xen_pvh_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(backtrace_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_xen_pvh_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@lsapm.marker: $(lsapm_module_SOURCES) $(nodist_lsapm_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lsapm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@keylayouts.marker: $(keylayouts_module_SOURCES) $(nodist_keylayouts_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keylayouts_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+priority_queue.marker: $(priority_queue_module_SOURCES) $(nodist_priority_queue_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(priority_queue_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+time.marker: $(time_module_SOURCES) $(nodist_time_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(time_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ENABLE_CACHE_STATS_TRUE@cacheinfo.marker: $(cacheinfo_module_SOURCES) $(nodist_cacheinfo_module_SOURCES)
+@COND_ENABLE_CACHE_STATS_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cacheinfo_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ENABLE_CACHE_STATS_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@boottime.marker: $(boottime_module_SOURCES) $(nodist_boottime_module_SOURCES)
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boottime_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ENABLE_BOOT_TIME_STATS_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+adler32.marker: $(adler32_module_SOURCES) $(nodist_adler32_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(adler32_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+crc64.marker: $(crc64_module_SOURCES) $(nodist_crc64_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(crc64_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+mpi.marker: $(mpi_module_SOURCES) $(nodist_mpi_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mpi_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+all_video.marker: $(all_video_module_SOURCES) $(nodist_all_video_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(all_video_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@gdb.marker: $(gdb_module_SOURCES) $(nodist_gdb_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gdb_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+testspeed.marker: $(testspeed_module_SOURCES) $(nodist_testspeed_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testspeed_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_ia64_efi_TRUE@tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+@COND_ia64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_ia64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm_efi_TRUE@tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+@COND_arm_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_arm64_efi_TRUE@tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+@COND_arm64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_arm64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv32_efi_TRUE@tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+@COND_riscv32_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv32_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_riscv64_efi_TRUE@tpm.marker: $(tpm_module_SOURCES) $(nodist_tpm_module_SOURCES)
+@COND_riscv64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tpm_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_riscv64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+tr.marker: $(tr_module_SOURCES) $(nodist_tr_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+progress.marker: $(progress_module_SOURCES) $(nodist_progress_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(progress_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+file.marker: $(file_module_SOURCES) $(nodist_file_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(file_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@rdmsr.marker: $(rdmsr_module_SOURCES) $(nodist_rdmsr_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rdmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_pc_TRUE@wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+@COND_i386_pc_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_pc_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_efi_TRUE@wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+@COND_i386_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_qemu_TRUE@wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+@COND_i386_qemu_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_qemu_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_coreboot_TRUE@wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+@COND_i386_coreboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_coreboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_multiboot_TRUE@wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+@COND_i386_multiboot_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_multiboot_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_i386_ieee1275_TRUE@wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+@COND_i386_ieee1275_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_i386_ieee1275_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_x86_64_efi_TRUE@wrmsr.marker: $(wrmsr_module_SOURCES) $(nodist_wrmsr_module_SOURCES)
+@COND_x86_64_efi_TRUE@ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(wrmsr_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+@COND_x86_64_efi_TRUE@ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_arcfour.marker: $(gcry_arcfour_module_SOURCES) $(nodist_gcry_arcfour_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_arcfour_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_blowfish.marker: $(gcry_blowfish_module_SOURCES) $(nodist_gcry_blowfish_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_blowfish_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_camellia.marker: $(gcry_camellia_module_SOURCES) $(nodist_gcry_camellia_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_camellia_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_cast5.marker: $(gcry_cast5_module_SOURCES) $(nodist_gcry_cast5_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_cast5_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_crc.marker: $(gcry_crc_module_SOURCES) $(nodist_gcry_crc_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_crc_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_des.marker: $(gcry_des_module_SOURCES) $(nodist_gcry_des_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_des_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_dsa.marker: $(gcry_dsa_module_SOURCES) $(nodist_gcry_dsa_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_dsa_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_idea.marker: $(gcry_idea_module_SOURCES) $(nodist_gcry_idea_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_idea_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_md4.marker: $(gcry_md4_module_SOURCES) $(nodist_gcry_md4_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md4_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_md5.marker: $(gcry_md5_module_SOURCES) $(nodist_gcry_md5_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_md5_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_rfc2268.marker: $(gcry_rfc2268_module_SOURCES) $(nodist_gcry_rfc2268_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rfc2268_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_rijndael.marker: $(gcry_rijndael_module_SOURCES) $(nodist_gcry_rijndael_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rijndael_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_rmd160.marker: $(gcry_rmd160_module_SOURCES) $(nodist_gcry_rmd160_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rmd160_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_rsa.marker: $(gcry_rsa_module_SOURCES) $(nodist_gcry_rsa_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_rsa_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_seed.marker: $(gcry_seed_module_SOURCES) $(nodist_gcry_seed_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_seed_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_serpent.marker: $(gcry_serpent_module_SOURCES) $(nodist_gcry_serpent_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_serpent_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_sha1.marker: $(gcry_sha1_module_SOURCES) $(nodist_gcry_sha1_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha1_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_sha256.marker: $(gcry_sha256_module_SOURCES) $(nodist_gcry_sha256_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha256_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_sha512.marker: $(gcry_sha512_module_SOURCES) $(nodist_gcry_sha512_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_sha512_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_tiger.marker: $(gcry_tiger_module_SOURCES) $(nodist_gcry_tiger_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_tiger_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_twofish.marker: $(gcry_twofish_module_SOURCES) $(nodist_gcry_twofish_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_twofish_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+gcry_whirlpool.marker: $(gcry_whirlpool_module_SOURCES) $(nodist_gcry_whirlpool_module_SOURCES)
+ $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gcry_whirlpool_module_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1)
+ grep 'MARKER' $@.new > $@; rm -f $@.new
+
+@COND_emu_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_emu_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -ed2022 -wd1106 -nu -nd $< $@; elif test ! -z '$(TARGET_OBJ2ELF)'; then $(TARGET_OBJ2ELF) $< $@ || (rm -f $@; exit 1); else cp $< $@; fi
+
+@COND_i386_pc_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_i386_pc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_i386_efi_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_i386_efi_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_i386_qemu_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_i386_qemu_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_i386_coreboot_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_i386_coreboot_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_i386_multiboot_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_i386_multiboot_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_i386_ieee1275_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_i386_ieee1275_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_x86_64_efi_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_x86_64_efi_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_i386_xen_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_i386_xen_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_x86_64_xen_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_x86_64_xen_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_i386_xen_pvh_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_i386_xen_pvh_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_mips_loongson_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_mips_loongson_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_sparc64_ieee1275_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_powerpc_ieee1275_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_powerpc_ieee1275_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_mips_arc_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_mips_arc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_ia64_efi_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_ia64_efi_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_mips_qemu_mips_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_arm_uboot_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_arm_uboot_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_arm_efi_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_arm_efi_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_arm64_efi_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_arm64_efi_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_arm_coreboot_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_arm_coreboot_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_riscv32_efi_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_riscv32_efi_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_riscv64_efi_TRUE@kernel.img: kernel.exec$(EXEEXT)
+@COND_riscv64_efi_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(TARGET_STRIP) -S -x $(kernel_exec) -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) $(kernel_exec_STRIPFLAGS) -o $@.bin $< && $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); rm -f $@.bin; else $(TARGET_STRIP) $(kernel_exec_STRIPFLAGS) -o $@ $<; fi
+
+@COND_i386_pc_TRUE@boot.img: boot.image$(EXEEXT)
+@COND_i386_pc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(boot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_i386_qemu_TRUE@boot.img: boot.image$(EXEEXT)
+@COND_i386_qemu_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(boot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_sparc64_ieee1275_TRUE@boot.img: boot.image$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(boot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_i386_pc_TRUE@boot_hybrid.img: boot_hybrid.image$(EXEEXT)
+@COND_i386_pc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(boot_hybrid_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_i386_pc_TRUE@cdboot.img: cdboot.image$(EXEEXT)
+@COND_i386_pc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(cdboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_sparc64_ieee1275_TRUE@cdboot.img: cdboot.image$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(cdboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_i386_pc_TRUE@pxeboot.img: pxeboot.image$(EXEEXT)
+@COND_i386_pc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(pxeboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_i386_pc_TRUE@diskboot.img: diskboot.image$(EXEEXT)
+@COND_i386_pc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(diskboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_sparc64_ieee1275_TRUE@diskboot.img: diskboot.image$(EXEEXT)
+@COND_sparc64_ieee1275_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(diskboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_i386_pc_TRUE@lnxboot.img: lnxboot.image$(EXEEXT)
+@COND_i386_pc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(lnxboot_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_mips_loongson_TRUE@xz_decompress.img: xz_decompress.image$(EXEEXT)
+@COND_mips_loongson_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(xz_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_mips_arc_TRUE@xz_decompress.img: xz_decompress.image$(EXEEXT)
+@COND_mips_arc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(xz_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_mips_qemu_mips_TRUE@xz_decompress.img: xz_decompress.image$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(xz_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_mips_loongson_TRUE@none_decompress.img: none_decompress.image$(EXEEXT)
+@COND_mips_loongson_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(none_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_mips_arc_TRUE@none_decompress.img: none_decompress.image$(EXEEXT)
+@COND_mips_arc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(none_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_mips_qemu_mips_TRUE@none_decompress.img: none_decompress.image$(EXEEXT)
+@COND_mips_qemu_mips_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(none_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_i386_pc_TRUE@lzma_decompress.img: lzma_decompress.image$(EXEEXT)
+@COND_i386_pc_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(lzma_decompress_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_mips_loongson_TRUE@fwstart.img: fwstart.image$(EXEEXT)
+@COND_mips_loongson_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(fwstart_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_mips_loongson_TRUE@fwstart_fuloong2f.img: fwstart_fuloong2f.image$(EXEEXT)
+@COND_mips_loongson_TRUE@ if test x$(TARGET_APPLE_LINKER) = x1; then $(MACHO2IMG) $< $@; else $(TARGET_OBJCOPY) $(fwstart_fuloong2f_image_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 .note.gnu.property -R .ARM.exidx $< $@; fi
+
+@COND_MAN_PAGES_TRUE@@COND_emu_TRUE@grub-emu.1: grub-emu
+@COND_MAN_PAGES_TRUE@@COND_emu_TRUE@ chmod a+x grub-emu
+@COND_MAN_PAGES_TRUE@@COND_emu_TRUE@ PATH=$(builddir):$$PATH pkgdatadir=$(builddir) $(HELP2MAN) --section=1 -i $(top_srcdir)/docs/man/grub-emu.h2m -o $@ grub-emu
+
+gensyminfo.sh: $(top_builddir)/config.status gensyminfo.sh.in
+ (for x in gensyminfo.sh.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x gensyminfo.sh
+
+genmod.sh: $(top_builddir)/config.status genmod.sh.in
+ (for x in genmod.sh.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x genmod.sh
+
+modinfo.sh: $(top_builddir)/config.status modinfo.sh.in
+ (for x in modinfo.sh.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x modinfo.sh
+
+gmodule.pl: $(top_builddir)/config.status gmodule.pl.in
+ (for x in gmodule.pl.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x gmodule.pl
+
+gdb_grub: $(top_builddir)/config.status gdb_grub.in
+ (for x in gdb_grub.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+ chmod a+x gdb_grub
+
+@COND_powerpc_ieee1275_TRUE@grub.chrp: $(top_builddir)/config.status boot/powerpc/grub.chrp.in
+@COND_powerpc_ieee1275_TRUE@ (for x in boot/powerpc/grub.chrp.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+@COND_powerpc_ieee1275_TRUE@ chmod a+x grub.chrp
+
+@COND_powerpc_ieee1275_TRUE@bootinfo.txt: $(top_builddir)/config.status boot/powerpc/bootinfo.txt.in
+@COND_powerpc_ieee1275_TRUE@ (for x in boot/powerpc/bootinfo.txt.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+@COND_powerpc_ieee1275_TRUE@ chmod a+x bootinfo.txt
+
+symlist.h: $(top_builddir)/config.h $(KERNEL_HEADER_FILES)
+ @list='$^'; \
+ for p in $$list; do \
+ echo "#include <$$p>" >> $@ || (rm -f $@; exit 1); \
+ done
+
+symlist.c: symlist.h gensymlist.sh
+ $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) -DGRUB_SYMBOL_GENERATOR=1 symlist.h > symlist.p || (rm -f symlist.p; exit 1)
+ cat symlist.p | $(SHELL) $(srcdir)/gensymlist.sh $(top_builddir)/config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1)
+ rm -f symlist.p
+
+kernel_syms.lst: $(KERNEL_HEADER_FILES) $(top_builddir)/config.h
+ $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) $(CFLAGS) -DGRUB_SYMBOL_GENERATOR=1 $^ >kernel_syms.input
+ cat kernel_syms.input | grep -v '^#' | sed -n \
+ -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \
+ -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \
+ | sort -u >$@
+ rm -f kernel_syms.input
+
+@COND_emu_TRUE@kern/emu/grub_emu-main.$(OBJEXT):grub_emu_init.h
+@COND_emu_TRUE@grub_emu-grub_emu_init.$(OBJEXT):grub_emu_init.h
+@COND_emu_TRUE@kern/emu/grub_emu_dyn-main.$(OBJEXT):grub_emu_init.h
+@COND_emu_TRUE@grub_emu_dyn-grub_emu_init.$(OBJEXT):grub_emu_init.h
+
+@COND_emu_TRUE@grub_emu_init.h: genemuinitheader.sh $(MODULE_FILES)
+@COND_emu_TRUE@ rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinitheader.sh $(TARGET_NM) > $@
+
+@COND_emu_TRUE@grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MODULE_FILES)
+@COND_emu_TRUE@ rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinit.sh $(TARGET_NM) > $@
+
+# List files
+
+fs.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ if grep 'FS_LIST_MARKER' $$pp >/dev/null 2>&1; then \
+ echo $$b; \
+ fi; \
+ done) | sort -u > $@
+
+command.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ sed -n \
+ -e "/EXTCOMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
+ -e "/EXTCOMMAND_LOCKDOWN_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
+ -e "/P1COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
+ -e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" \
+ -e "/COMMAND_LOCKDOWN_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
+ done) | sort -u > $@
+
+partmap.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ if grep 'PARTMAP_LIST_MARKER' $$pp >/dev/null 2>&1; then \
+ echo $$b; \
+ fi; \
+ done) | sort -u > $@
+
+terminal.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ sed -n \
+ -e "/INPUT_TERMINAL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $$b/;p;}" \
+ -e "/OUTPUT_TERMINAL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $$b/;p;}" $$pp; \
+ done) | sort -u > $@
+
+fdt.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ sed -n \
+ -e "/FDT_DRIVER_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $$b/;p;}" \
+ -e "/FDT_DRIVER_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $$b/;p;}" $$pp; \
+ done) | sort -u > $@
+
+parttool.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ sed -n \
+ -e "/PARTTOOL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
+ done) | sort -u > $@
+
+video.lst: $(MARKER_FILES)
+ (for pp in $^; do \
+ b=`basename $$pp .marker`; \
+ if grep 'VIDEO_LIST_MARKER' $$pp >/dev/null 2>&1; then \
+ echo $$b; \
+ fi; \
+ done) | sort -u > $@
+
+# but, crypto.lst is simply copied
+crypto.lst: $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst
+ cp $^ $@
+
+syminfo.lst: gensyminfo.sh kernel_syms.lst $(MODULE_FILES)
+ cat kernel_syms.lst > $@.new
+ for m in $(MODULE_FILES); do \
+ sh $< $$m >> $@.new || exit 1; \
+ done
+ mv $@.new $@
+
+# generate global module dependencies list
+moddep.lst: syminfo.lst genmoddep.awk video.lst
+ cat $< | sort | $(AWK) -f $(srcdir)/genmoddep.awk > $@ || (rm -f $@; exit 1)
+
+$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier$(BUILD_EXEEXT)
+ TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@
+
+@COND_ENABLE_EFIEMU_TRUE@efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
+@COND_ENABLE_EFIEMU_TRUE@ -rm -f $@
+@COND_ENABLE_EFIEMU_TRUE@ -rm -f $@.bin
+@COND_ENABLE_EFIEMU_TRUE@ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -static -O2 -c -o $@.bin $<
+@COND_ENABLE_EFIEMU_TRUE@ if test "x$(TARGET_APPLE_LINKER)" = x1; then \
+@COND_ENABLE_EFIEMU_TRUE@ $(TARGET_OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
+@COND_ENABLE_EFIEMU_TRUE@ rm -f $@.bin ; \
+@COND_ENABLE_EFIEMU_TRUE@ elif test ! -z "$(TARGET_OBJ2ELF)"; then \
+@COND_ENABLE_EFIEMU_TRUE@ $(TARGET_OBJ2ELF) $@.bin || (rm -f $@.bin; exit 1); \
+@COND_ENABLE_EFIEMU_TRUE@ mv $@.bin $@ ; \
+@COND_ENABLE_EFIEMU_TRUE@ else \
+@COND_ENABLE_EFIEMU_TRUE@ mv $@.bin $@ ; \
+@COND_ENABLE_EFIEMU_TRUE@ fi
+
+# Link format -arch,x86_64 means Apple linker
+@COND_ENABLE_EFIEMU_TRUE@efiemu64_c.o: efiemu/runtime/efiemu.c
+@COND_ENABLE_EFIEMU_TRUE@ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
+
+@COND_ENABLE_EFIEMU_TRUE@efiemu64_s.o: efiemu/runtime/efiemu.S
+@COND_ENABLE_EFIEMU_TRUE@ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
+
+@COND_ENABLE_EFIEMU_TRUE@efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
+@COND_ENABLE_EFIEMU_TRUE@ -rm -f $@
+@COND_ENABLE_EFIEMU_TRUE@ -rm -f $@.bin
+@COND_ENABLE_EFIEMU_TRUE@ $(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -static -Wl,-r -o $@.bin $^
+@COND_ENABLE_EFIEMU_TRUE@ if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \
+@COND_ENABLE_EFIEMU_TRUE@ $(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
+@COND_ENABLE_EFIEMU_TRUE@ rm -f $@.bin; \
+@COND_ENABLE_EFIEMU_TRUE@ else \
+@COND_ENABLE_EFIEMU_TRUE@ mv $@.bin $@ ; \
+@COND_ENABLE_EFIEMU_TRUE@ fi
+windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
+ test -d $(windowsdir)/$(target_cpu)-$(platform) || mkdir $(windowsdir)/$(target_cpu)-$(platform)
+ for x in $(platform_DATA); do \
+ cp -fp $$x $(windowsdir)/$(target_cpu)-$(platform)/$$x; \
+ done
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/grub-core/boot/decompressor/minilib.c b/grub-core/boot/decompressor/minilib.c
new file mode 100644
index 0000000..fc46ee0
--- /dev/null
+++ b/grub-core/boot/decompressor/minilib.c
@@ -0,0 +1,93 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/decompressor.h>
+
+void *
+grub_memset (void *s, int c, grub_size_t len)
+{
+ grub_uint8_t *ptr;
+ for (ptr = s; len; ptr++, len--)
+ *ptr = c;
+ return s;
+}
+
+void *
+grub_memmove (void *dest, const void *src, grub_size_t n)
+{
+ char *d = (char *) dest;
+ const char *s = (const char *) src;
+
+ if (d < s)
+ while (n--)
+ *d++ = *s++;
+ else
+ {
+ d += n;
+ s += n;
+
+ while (n--)
+ *--d = *--s;
+ }
+
+ return dest;
+}
+
+int
+grub_memcmp (const void *s1, const void *s2, grub_size_t n)
+{
+ const unsigned char *t1 = s1;
+ const unsigned char *t2 = s2;
+
+ while (n--)
+ {
+ if (*t1 != *t2)
+ return (int) *t1 - (int) *t2;
+
+ t1++;
+ t2++;
+ }
+
+ return 0;
+}
+
+void *grub_decompressor_scratch;
+
+void
+find_scratch (void *src, void *dst, unsigned long srcsize,
+ unsigned long dstsize)
+{
+#ifdef _mips
+ /* Decoding from ROM. */
+ if (((grub_addr_t) src & 0x10000000))
+ {
+ grub_decompressor_scratch = (void *) ALIGN_UP((grub_addr_t) dst + dstsize,
+ 256);
+ return;
+ }
+#endif
+ if ((char *) src + srcsize > (char *) dst + dstsize)
+ grub_decompressor_scratch = (void *) ALIGN_UP ((grub_addr_t) src + srcsize,
+ 256);
+ else
+ grub_decompressor_scratch = (void *) ALIGN_UP ((grub_addr_t) dst + dstsize,
+ 256);
+ return;
+}
diff --git a/grub-core/boot/decompressor/none.c b/grub-core/boot/decompressor/none.c
new file mode 100644
index 0000000..911e861
--- /dev/null
+++ b/grub-core/boot/decompressor/none.c
@@ -0,0 +1,42 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/decompressor.h>
+
+void
+grub_decompress_core (void *src, void *dest, unsigned long n,
+ unsigned long dstsize __attribute__ ((unused)))
+{
+ char *d = (char *) dest;
+ const char *s = (const char *) src;
+
+ if (d == s)
+ return;
+
+ if (d < s)
+ while (n--)
+ *d++ = *s++;
+ else
+ {
+ d += n;
+ s += n;
+
+ while (n--)
+ *--d = *--s;
+ }
+}
diff --git a/grub-core/boot/decompressor/xz.c b/grub-core/boot/decompressor/xz.c
new file mode 100644
index 0000000..2279118
--- /dev/null
+++ b/grub-core/boot/decompressor/xz.c
@@ -0,0 +1,60 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/decompressor.h>
+
+#include "xz.h"
+#include "xz_stream.h"
+
+void
+grub_decompress_core (void *src, void *dst, unsigned long srcsize,
+ unsigned long dstsize)
+{
+ struct xz_dec *dec;
+ struct xz_buf buf;
+
+ find_scratch (src, dst, srcsize, dstsize);
+
+ dec = xz_dec_init (GRUB_DECOMPRESSOR_DICT_SIZE);
+
+ buf.in = src;
+ buf.in_pos = 0;
+ buf.in_size = srcsize;
+ buf.out = dst;
+ buf.out_pos = 0;
+ buf.out_size = dstsize;
+
+ while (buf.in_pos != buf.in_size)
+ {
+ enum xz_ret xzret;
+ xzret = xz_dec_run (dec, &buf);
+ switch (xzret)
+ {
+ case XZ_MEMLIMIT_ERROR:
+ case XZ_FORMAT_ERROR:
+ case XZ_OPTIONS_ERROR:
+ case XZ_DATA_ERROR:
+ case XZ_BUF_ERROR:
+ return;
+ default:
+ break;
+ }
+ }
+}
diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S
new file mode 100644
index 0000000..2bd0b2d
--- /dev/null
+++ b/grub-core/boot/i386/pc/boot.S
@@ -0,0 +1,542 @@
+/* -*-Asm-*- */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/machine/boot.h>
+
+/*
+ * defines for the code go here
+ */
+
+ /* Print message string */
+#define MSG(x) movw $x, %si; call LOCAL(message)
+#define ERR(x) movw $x, %si; jmp LOCAL(error_message)
+
+ .macro floppy
+part_start:
+
+LOCAL(probe_values):
+ .byte 36, 18, 15, 9, 0
+
+LOCAL(floppy_probe):
+ pushw %dx
+/*
+ * Perform floppy probe.
+ */
+#ifdef __APPLE__
+ LOCAL(probe_values_minus_one) = LOCAL(probe_values) - 1
+ movw MACRO_DOLLAR(LOCAL(probe_values_minus_one)), %si
+#else
+ movw MACRO_DOLLAR(LOCAL(probe_values)) - 1, %si
+#endif
+
+LOCAL(probe_loop):
+ /* reset floppy controller INT 13h AH=0 */
+ xorw %ax, %ax
+ int MACRO_DOLLAR(0x13)
+
+ incw %si
+ movb (%si), %cl
+
+ /* if number of sectors is 0, display error and die */
+ testb %cl, %cl
+ jnz 1f
+
+/*
+ * Floppy disk probe failure.
+ */
+ MSG(fd_probe_error_string)
+ jmp LOCAL(general_error)
+
+/* "Floppy" */
+fd_probe_error_string: .asciz "Floppy"
+
+1:
+ /* perform read */
+ movw MACRO_DOLLAR(GRUB_BOOT_MACHINE_BUFFER_SEG), %bx
+ movw %bx, %es
+ xorw %bx, %bx
+ movw MACRO_DOLLAR(0x201), %ax
+ movb MACRO_DOLLAR(0), %ch
+ movb MACRO_DOLLAR(0), %dh
+ int MACRO_DOLLAR(0x13)
+
+ /* if error, jump to "LOCAL(probe_loop)" */
+ jc LOCAL(probe_loop)
+
+ /* %cl is already the correct value! */
+ movb MACRO_DOLLAR(1), %dh
+ movb MACRO_DOLLAR(79), %ch
+
+ jmp LOCAL(final_init)
+ .endm
+
+ .macro scratch
+
+ /* scratch space */
+mode:
+ .byte 0
+disk_address_packet:
+sectors:
+ .long 0
+heads:
+ .long 0
+cylinders:
+ .word 0
+sector_start:
+ .byte 0
+head_start:
+ .byte 0
+cylinder_start:
+ .word 0
+ /* more space... */
+ .endm
+
+ .file "boot.S"
+
+ .text
+
+ /* Tell GAS to generate 16-bit instructions so that this code works
+ in real mode. */
+ .code16
+
+.globl _start, start;
+_start:
+start:
+ /*
+ * _start is loaded at 0x7c00 and is jumped to with CS:IP 0:0x7c00
+ */
+
+ /*
+ * Beginning of the sector is compatible with the FAT/HPFS BIOS
+ * parameter block.
+ */
+
+ jmp LOCAL(after_BPB)
+ nop /* do I care about this ??? */
+
+#ifdef HYBRID_BOOT
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+
+ nop
+ nop
+ jmp LOCAL(after_BPB)
+#else
+ /*
+ * This space is for the BIOS parameter block!!!! Don't change
+ * the first jump, nor start the code anywhere but right after
+ * this area.
+ */
+
+ .org GRUB_BOOT_MACHINE_BPB_START
+ .org 4
+#endif
+#ifdef HYBRID_BOOT
+ floppy
+#else
+ scratch
+#endif
+
+ .org GRUB_BOOT_MACHINE_BPB_END
+ /*
+ * End of BIOS parameter block.
+ */
+
+LOCAL(kernel_address):
+ .word GRUB_BOOT_MACHINE_KERNEL_ADDR
+
+#ifndef HYBRID_BOOT
+ .org GRUB_BOOT_MACHINE_KERNEL_SECTOR
+LOCAL(kernel_sector):
+ .long 1
+LOCAL(kernel_sector_high):
+ .long 0
+#endif
+
+ .org GRUB_BOOT_MACHINE_BOOT_DRIVE
+boot_drive:
+ .byte 0xff /* the disk to load kernel from */
+ /* 0xff means use the boot drive */
+
+LOCAL(after_BPB):
+
+/* general setup */
+ cli /* we're not safe here! */
+
+ /*
+ * This is a workaround for buggy BIOSes which don't pass boot
+ * drive correctly. If GRUB is installed into a HDD, check if
+ * DL is masked correctly. If not, assume that the BIOS passed
+ * a bogus value and set DL to 0x80, since this is the only
+ * possible boot drive. If GRUB is installed into a floppy,
+ * this does nothing (only jump).
+ */
+ .org GRUB_BOOT_MACHINE_DRIVE_CHECK
+boot_drive_check:
+ jmp 3f /* grub-setup may overwrite this jump */
+ testb $0x80, %dl
+ jz 2f
+3:
+ /* Ignore %dl different from 0-0x0f and 0x80-0x8f. */
+ testb $0x70, %dl
+ jz 1f
+2:
+ movb $0x80, %dl
+1:
+ /*
+ * ljmp to the next instruction because some bogus BIOSes
+ * jump to 07C0:0000 instead of 0000:7C00.
+ */
+ ljmp $0, $real_start
+
+real_start:
+
+ /* set up %ds and %ss as offset from 0 */
+ xorw %ax, %ax
+ movw %ax, %ds
+ movw %ax, %ss
+
+ /* set up the REAL stack */
+ movw $GRUB_BOOT_MACHINE_STACK_SEG, %sp
+
+ sti /* we're safe again */
+
+ /*
+ * Check if we have a forced disk reference here
+ */
+ movb boot_drive, %al
+ cmpb $0xff, %al
+ je 1f
+ movb %al, %dl
+1:
+ /* save drive reference first thing! */
+ pushw %dx
+
+ /* print a notification message on the screen */
+ MSG(notification_string)
+
+ /* set %si to the disk address packet */
+ movw $disk_address_packet, %si
+
+ /* check if LBA is supported */
+ movb $0x41, %ah
+ movw $0x55aa, %bx
+ int $0x13
+
+ /*
+ * %dl may have been clobbered by INT 13, AH=41H.
+ * This happens, for example, with AST BIOS 1.04.
+ */
+ popw %dx
+ pushw %dx
+
+ /* use CHS if fails */
+ jc LOCAL(chs_mode)
+ cmpw $0xaa55, %bx
+ jne LOCAL(chs_mode)
+
+ andw $1, %cx
+ jz LOCAL(chs_mode)
+
+LOCAL(lba_mode):
+ xorw %ax, %ax
+ movw %ax, 4(%si)
+
+ incw %ax
+ /* set the mode to non-zero */
+ movb %al, -1(%si)
+
+ /* the blocks */
+ movw %ax, 2(%si)
+
+ /* the size and the reserved byte */
+ movw $0x0010, (%si)
+
+ /* the absolute address */
+ movl LOCAL(kernel_sector), %ebx
+ movl %ebx, 8(%si)
+ movl LOCAL(kernel_sector_high), %ebx
+ movl %ebx, 12(%si)
+
+ /* the segment of buffer address */
+ movw $GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si)
+
+/*
+ * BIOS call "INT 0x13 Function 0x42" to read sectors from disk into memory
+ * Call with %ah = 0x42
+ * %dl = drive number
+ * %ds:%si = segment:offset of disk address packet
+ * Return:
+ * %al = 0x0 on success; err code on failure
+ */
+
+ movb $0x42, %ah
+ int $0x13
+
+ /* LBA read is not supported, so fallback to CHS. */
+ jc LOCAL(chs_mode)
+
+ movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
+ jmp LOCAL(copy_buffer)
+
+LOCAL(chs_mode):
+ /*
+ * Determine the hard disk geometry from the BIOS!
+ * We do this first, so that LS-120 IDE floppies work correctly.
+ */
+ movb $8, %ah
+ int $0x13
+ jnc LOCAL(final_init)
+
+ popw %dx
+ /*
+ * The call failed, so maybe use the floppy probe instead.
+ */
+ testb %dl, %dl
+ jnb LOCAL(floppy_probe)
+
+ /* Nope, we definitely have a hard disk, and we're screwed. */
+ ERR(hd_probe_error_string)
+
+LOCAL(final_init):
+ /* set the mode to zero */
+ movzbl %dh, %eax
+ movb %ah, -1(%si)
+
+ /* save number of heads */
+ incw %ax
+ movl %eax, 4(%si)
+
+ movzbw %cl, %dx
+ shlw $2, %dx
+ movb %ch, %al
+ movb %dh, %ah
+
+ /* save number of cylinders */
+ incw %ax
+ movw %ax, 8(%si)
+
+ movzbw %dl, %ax
+ shrb $2, %al
+
+ /* save number of sectors */
+ movl %eax, (%si)
+
+setup_sectors:
+ /* load logical sector start (top half) */
+ movl LOCAL(kernel_sector_high), %eax
+
+ orl %eax, %eax
+ jnz LOCAL(geometry_error)
+
+ /* load logical sector start (bottom half) */
+ movl LOCAL(kernel_sector), %eax
+
+ /* zero %edx */
+ xorl %edx, %edx
+
+ /* divide by number of sectors */
+ divl (%si)
+
+ /* save sector start */
+ movb %dl, %cl
+
+ xorw %dx, %dx /* zero %edx */
+ divl 4(%si) /* divide by number of heads */
+
+ /* do we need too many cylinders? */
+ cmpw 8(%si), %ax
+ jge LOCAL(geometry_error)
+
+ /* normalize sector start (1-based) */
+ incb %cl
+
+ /* low bits of cylinder start */
+ movb %al, %ch
+
+ /* high bits of cylinder start */
+ xorb %al, %al
+ shrw $2, %ax
+ orb %al, %cl
+
+ /* save head start */
+ movb %dl, %al
+
+ /* restore %dl */
+ popw %dx
+
+ /* head start */
+ movb %al, %dh
+
+/*
+ * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory
+ * Call with %ah = 0x2
+ * %al = number of sectors
+ * %ch = cylinder
+ * %cl = sector (bits 6-7 are high bits of "cylinder")
+ * %dh = head
+ * %dl = drive (0x80 for hard disk, 0x0 for floppy disk)
+ * %es:%bx = segment:offset of buffer
+ * Return:
+ * %al = 0x0 on success; err code on failure
+ */
+
+ movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
+ movw %bx, %es /* load %es segment with disk buffer */
+
+ xorw %bx, %bx /* %bx = 0, put it at 0 in the segment */
+ movw $0x0201, %ax /* function 2 */
+ int $0x13
+
+ jc LOCAL(read_error)
+
+ movw %es, %bx
+
+LOCAL(copy_buffer):
+ /*
+ * We need to save %cx and %si because the startup code in
+ * kernel uses them without initializing them.
+ */
+ pusha
+ pushw %ds
+
+ movw $0x100, %cx
+ movw %bx, %ds
+ xorw %si, %si
+ movw $GRUB_BOOT_MACHINE_KERNEL_ADDR, %di
+ movw %si, %es
+
+ cld
+
+ rep
+ movsw
+
+ popw %ds
+ popa
+
+ /* boot kernel */
+ jmp *(LOCAL(kernel_address))
+
+/* END OF MAIN LOOP */
+
+/*
+ * BIOS Geometry translation error (past the end of the disk geometry!).
+ */
+LOCAL(geometry_error):
+ ERR(geometry_error_string)
+
+/*
+ * Read error on the disk.
+ */
+LOCAL(read_error):
+ movw $read_error_string, %si
+LOCAL(error_message):
+ call LOCAL(message)
+LOCAL(general_error):
+ MSG(general_error_string)
+
+/* go here when you need to stop the machine hard after an error condition */
+ /* tell the BIOS a boot failure, which may result in no effect */
+ int $0x18
+LOCAL(stop):
+ jmp LOCAL(stop)
+
+notification_string: .asciz "GRUB "
+geometry_error_string: .asciz "Geom"
+hd_probe_error_string: .asciz "Hard Disk"
+read_error_string: .asciz "Read"
+general_error_string: .asciz " Error\r\n"
+
+/*
+ * message: write the string pointed to by %si
+ *
+ * WARNING: trashes %si, %ax, and %bx
+ */
+
+ /*
+ * Use BIOS "int 10H Function 0Eh" to write character in teletype mode
+ * %ah = 0xe %al = character
+ * %bh = page %bl = foreground color (graphics modes)
+ */
+1:
+ movw $0x0001, %bx
+ movb $0xe, %ah
+ int $0x10 /* display a byte */
+LOCAL(message):
+ lodsb
+ cmpb $0, %al
+ jne 1b /* if not end of string, jmp to display */
+ ret
+
+ /*
+ * Windows NT breaks compatibility by embedding a magic
+ * number here.
+ */
+
+#ifdef HYBRID_BOOT
+ .org 0x1b0
+LOCAL(kernel_sector):
+ .long 1
+LOCAL(kernel_sector_high):
+ .long 0
+#endif
+ .org GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
+nt_magic:
+ .long 0
+ .word 0
+
+ /*
+ * This is where an MBR would go if on a hard disk. The code
+ * here isn't even referenced unless we're on a floppy. Kinda
+ * sneaky, huh?
+ */
+
+ .org GRUB_BOOT_MACHINE_PART_START
+
+#ifndef HYBRID_BOOT
+ floppy
+#else
+ scratch
+#endif
+
+ .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
new file mode 100644
index 0000000..de4f809
--- /dev/null
+++ b/grub-core/boot/i386/pc/cdboot.S
@@ -0,0 +1,173 @@
+/* -*-Asm-*- */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/machine/boot.h>
+#include <grub/machine/kernel.h>
+#include <multiboot.h>
+
+ .file "cdboot.S"
+
+#define CODE_ADDR 0x6000
+#define DATA_ADDR ((GRUB_BOOT_MACHINE_KERNEL_ADDR) + 0x200)
+
+#define CDSEC_SHIFT 11
+#define CDBLK_LENG 16
+
+ .text
+
+ .code16
+
+ .globl start, _start
+
+start:
+_start:
+ call LOCAL(next)
+
+LOCAL(next):
+ jmp 1f
+
+ .org 8
+
+bi_pvd:
+ .long 0 /* LBA of primary volume descriptor. */
+bi_file:
+ .long 0 /* LBA of boot file. */
+bi_length:
+ .long 0 /* Length of boot file. */
+bi_csum:
+ .long 0 /* Checksum of boot file */
+bi_reserved:
+ .space (10*4) /* Reserved */
+
+1:
+ popw %bx
+
+ /* Boot from CDROM. */
+
+ xorw %ax, %ax
+ movw %ax, %ss
+ movw $(CODE_ADDR), %sp
+ movw %ax, %ds
+ movw %ax, %es
+
+ movw $(0x7C00 + err_noboot_msg - start), %si
+ movl %cs: bi_length - LOCAL(next)(%bx), %ecx
+ orl %ecx, %ecx
+ jz LOCAL(fail)
+
+ addl $((1 << CDSEC_SHIFT) - 1), %ecx
+ shrl $CDSEC_SHIFT, %ecx
+
+ movl %cs: bi_file - LOCAL(next)(%bx), %esi
+
+ call LOCAL(read_cdrom)
+
+ ljmp $(DATA_ADDR >> 4), $0
+
+/*
+ * Parameters:
+ * esi: start sector
+ * ecx: number of sectors
+ */
+LOCAL(read_cdrom):
+ xorl %eax, %eax
+
+ /* Number of blocks to read. */
+ pushw $CDBLK_LENG
+
+ /* Block number. */
+ incl %esi
+ pushl %eax
+ pushl %esi
+
+ /* Buffer address. */
+ pushw $((DATA_ADDR - 0x200)>> 4)
+ pushl %eax
+ pushw $0x10
+
+ xorl %edi, %edi
+ movw %sp, %si
+
+1:
+ movw 0x10(%si), %di
+ cmpl %ecx, %edi
+ jbe 2f
+ movl %ecx, %edi
+
+2:
+ mov %di, 2(%si)
+
+ pushl %ecx
+
+ movb $0x42, %ah
+ int $0x13
+
+ jnc 3f
+
+ movb $0x42, %ah /* Try again. */
+ int $0x13
+
+ jnc 3f
+
+2:
+ shrw $1, %di /* Reduce transfer size. */
+ jz LOCAL(cdrom_fail)
+ movw %di, 0x10(%si)
+ movw %di, 2(%si)
+ movb $0x42, %ah
+ int $0x13
+ jc 2b
+
+3:
+
+ movw %di, %ax
+ shlw $(CDSEC_SHIFT - 4), %ax
+ addw %ax, 6(%si)
+ addl %edi, 8(%si)
+
+ popl %ecx
+ subl %edi, %ecx
+ jnz 1b
+
+ addw $0x12, %sp
+ ret
+
+LOCAL(cdrom_fail):
+ movw $(0x7C00 + err_cdfail_msg - start), %si
+
+LOCAL(fail):
+ movb $0x0e, %ah
+ xorw %bx, %bx
+1:
+ lodsb (%si), %al
+ int $0x10
+ cmpb $0, %al
+ jne 1b
+1: jmp 1b
+
+err_noboot_msg:
+ .ascii "no boot info\0"
+
+err_cdfail_msg:
+ .ascii "cdrom read fails\0"
+
+ .org 0x7FF
+
+ .byte 0
diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S
new file mode 100644
index 0000000..c1addc0
--- /dev/null
+++ b/grub-core/boot/i386/pc/diskboot.S
@@ -0,0 +1,378 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2006,2007,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/machine/boot.h>
+
+/*
+ * defines for the code go here
+ */
+
+#define MSG(x) movw $x, %si; call LOCAL(message)
+
+ .file "diskboot.S"
+
+ .text
+
+ /* Tell GAS to generate 16-bit instructions so that this code works
+ in real mode. */
+ .code16
+
+ .globl start, _start
+start:
+_start:
+ /*
+ * _start is loaded at 0x8000 and is jumped to with
+ * CS:IP 0:0x8000 in kernel.
+ */
+
+ /*
+ * we continue to use the stack for boot.img and assume that
+ * some registers are set to correct values. See boot.S
+ * for more information.
+ */
+
+ /* save drive reference first thing! */
+ pushw %dx
+
+ /* print a notification message on the screen */
+ pushw %si
+ MSG(notification_string)
+ popw %si
+
+ /* this sets up for the first run through "bootloop" */
+ movw $LOCAL(firstlist), %di
+
+ /* save the sector number of the second sector in %ebp */
+ movl (%di), %ebp
+
+ /* this is the loop for reading the rest of the kernel in */
+LOCAL(bootloop):
+
+ /* check the number of sectors to read */
+ cmpw $0, 8(%di)
+
+ /* if zero, go to the start function */
+ je LOCAL(bootit)
+
+LOCAL(setup_sectors):
+ /* check if we use LBA or CHS */
+ cmpb $0, -1(%si)
+
+ /* use CHS if zero, LBA otherwise */
+ je LOCAL(chs_mode)
+
+ /* load logical sector start */
+ movl (%di), %ebx
+ movl 4(%di), %ecx
+
+ /* the maximum is limited to 0x7f because of Phoenix EDD */
+ xorl %eax, %eax
+ movb $0x7f, %al
+
+ /* how many do we really want to read? */
+ cmpw %ax, 8(%di) /* compare against total number of sectors */
+
+ /* which is greater? */
+ jg 1f
+
+ /* if less than, set to total */
+ movw 8(%di), %ax
+
+1:
+ /* subtract from total */
+ subw %ax, 8(%di)
+
+ /* add into logical sector start */
+ addl %eax, (%di)
+ adcl $0, 4(%di)
+
+ /* set up disk address packet */
+
+ /* the size and the reserved byte */
+ movw $0x0010, (%si)
+
+ /* the number of sectors */
+ movw %ax, 2(%si)
+
+ /* the absolute address */
+ movl %ebx, 8(%si)
+ movl %ecx, 12(%si)
+
+ /* the segment of buffer address */
+ movw $GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si)
+
+ /* save %ax from destruction! */
+ pushw %ax
+
+ /* the offset of buffer address */
+ movw $0, 4(%si)
+
+/*
+ * BIOS call "INT 0x13 Function 0x42" to read sectors from disk into memory
+ * Call with %ah = 0x42
+ * %dl = drive number
+ * %ds:%si = segment:offset of disk address packet
+ * Return:
+ * %al = 0x0 on success; err code on failure
+ */
+
+ movb $0x42, %ah
+ int $0x13
+
+ jc LOCAL(read_error)
+
+ movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
+ jmp LOCAL(copy_buffer)
+
+LOCAL(chs_mode):
+ /* load logical sector start (top half) */
+ movl 4(%di), %eax
+ orl %eax, %eax
+ jnz LOCAL(geometry_error)
+
+ /* load logical sector start (bottom half) */
+ movl (%di), %eax
+
+ /* zero %edx */
+ xorl %edx, %edx
+
+ /* divide by number of sectors */
+ divl (%si)
+
+ /* save sector start */
+ movb %dl, 10(%si)
+
+ xorl %edx, %edx /* zero %edx */
+ divl 4(%si) /* divide by number of heads */
+
+ /* save head start */
+ movb %dl, 11(%si)
+
+ /* save cylinder start */
+ movw %ax, 12(%si)
+
+ /* do we need too many cylinders? */
+ cmpw 8(%si), %ax
+ jge LOCAL(geometry_error)
+
+ /* determine the maximum sector length of this read */
+ movw (%si), %ax /* get number of sectors per track/head */
+
+ /* subtract sector start */
+ subb 10(%si), %al
+
+ /* how many do we really want to read? */
+ cmpw %ax, 8(%di) /* compare against total number of sectors */
+
+
+ /* which is greater? */
+ jg 2f
+
+ /* if less than, set to total */
+ movw 8(%di), %ax
+
+2:
+ /* subtract from total */
+ subw %ax, 8(%di)
+
+ /* add into logical sector start */
+ addl %eax, (%di)
+ adcl $0, 4(%di)
+
+/*
+ * This is the loop for taking care of BIOS geometry translation (ugh!)
+ */
+
+ /* get high bits of cylinder */
+ movb 13(%si), %dl
+
+ shlb $6, %dl /* shift left by 6 bits */
+ movb 10(%si), %cl /* get sector */
+
+ incb %cl /* normalize sector (sectors go
+ from 1-N, not 0-(N-1) ) */
+ orb %dl, %cl /* composite together */
+ movb 12(%si), %ch /* sector+hcyl in cl, cylinder in ch */
+
+ /* restore %dx */
+ popw %dx
+ pushw %dx
+
+ /* head number */
+ movb 11(%si), %dh
+
+ pushw %ax /* save %ax from destruction! */
+
+/*
+ * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory
+ * Call with %ah = 0x2
+ * %al = number of sectors
+ * %ch = cylinder
+ * %cl = sector (bits 6-7 are high bits of "cylinder")
+ * %dh = head
+ * %dl = drive (0x80 for hard disk, 0x0 for floppy disk)
+ * %es:%bx = segment:offset of buffer
+ * Return:
+ * %al = 0x0 on success; err code on failure
+ */
+
+ movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
+ movw %bx, %es /* load %es segment with disk buffer */
+
+ xorw %bx, %bx /* %bx = 0, put it at 0 in the segment */
+ movb $0x2, %ah /* function 2 */
+ int $0x13
+
+ jc LOCAL(read_error)
+
+ /* save source segment */
+ movw %es, %bx
+
+LOCAL(copy_buffer):
+
+ /* load addresses for copy from disk buffer to destination */
+ movw 10(%di), %es /* load destination segment */
+
+ /* restore %ax */
+ popw %ax
+
+ /* determine the next possible destination address (presuming
+ 512 byte sectors!) */
+ shlw $5, %ax /* shift %ax five bits to the left */
+ addw %ax, 10(%di) /* add the corrected value to the destination
+ address for next time */
+
+ /* save addressing regs */
+ pusha
+ pushw %ds
+
+ /* get the copy length */
+ shlw $3, %ax
+ movw %ax, %cx
+
+ xorw %di, %di /* zero offset of destination addresses */
+ xorw %si, %si /* zero offset of source addresses */
+ movw %bx, %ds /* restore the source segment */
+
+ cld /* sets the copy direction to forward */
+
+ /* perform copy */
+ rep /* sets a repeat */
+ movsw /* this runs the actual copy */
+
+ /* restore addressing regs and print a dot with correct DS
+ (MSG modifies SI, which is saved, and unused AX and BX) */
+ popw %ds
+ MSG(notification_step)
+ popa
+
+ /* check if finished with this dataset */
+ cmpw $0, 8(%di)
+ jne LOCAL(setup_sectors)
+
+ /* update position to load from */
+ subw $GRUB_BOOT_MACHINE_LIST_SIZE, %di
+
+ /* jump to bootloop */
+ jmp LOCAL(bootloop)
+
+/* END OF MAIN LOOP */
+
+LOCAL(bootit):
+ /* print a newline */
+ MSG(notification_done)
+ popw %dx /* this makes sure %dl is our "boot" drive */
+ ljmp $0, $(GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
+
+
+/*
+ * BIOS Geometry translation error (past the end of the disk geometry!).
+ */
+LOCAL(geometry_error):
+ MSG(geometry_error_string)
+ jmp LOCAL(general_error)
+
+/*
+ * Read error on the disk.
+ */
+LOCAL(read_error):
+ MSG(read_error_string)
+
+LOCAL(general_error):
+ MSG(general_error_string)
+
+/* go here when you need to stop the machine hard after an error condition */
+LOCAL(stop): jmp LOCAL(stop)
+
+notification_string: .asciz "loading"
+
+notification_step: .asciz "."
+notification_done: .asciz "\r\n"
+
+geometry_error_string: .asciz "Geom"
+read_error_string: .asciz "Read"
+general_error_string: .asciz " Error"
+
+/*
+ * message: write the string pointed to by %si
+ *
+ * WARNING: trashes %si, %ax, and %bx
+ */
+
+ /*
+ * Use BIOS "int 10H Function 0Eh" to write character in teletype mode
+ * %ah = 0xe %al = character
+ * %bh = page %bl = foreground color (graphics modes)
+ */
+1:
+ movw $0x0001, %bx
+ movb $0xe, %ah
+ int $0x10 /* display a byte */
+
+ incw %si
+LOCAL(message):
+ movb (%si), %al
+ cmpb $0, %al
+ jne 1b /* if not end of string, jmp to display */
+ ret
+
+/*
+ * This area is an empty space between the main body of code below which
+ * grows up (fixed after compilation, but between releases it may change
+ * in size easily), and the lists of sectors to read, which grows down
+ * from a fixed top location.
+ */
+
+ .word 0
+ .word 0
+
+ .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:
+ /* this is the sector start parameter, in logical sectors from
+ the start of the disk, sector 0 */
+ .long 2, 0
+blocklist_default_len:
+ /* this is the number of sectors to read. grub-mkimage
+ will fill this up */
+ .word 0
+blocklist_default_seg:
+ /* this is the segment of the starting address to load the data into */
+ .word (GRUB_BOOT_MACHINE_KERNEL_SEG + 0x20)
diff --git a/grub-core/boot/i386/pc/lnxboot.S b/grub-core/boot/i386/pc/lnxboot.S
new file mode 100644
index 0000000..2dda0e0
--- /dev/null
+++ b/grub-core/boot/i386/pc/lnxboot.S
@@ -0,0 +1,295 @@
+/* -*-Asm-*- */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/symbol.h>
+#include <grub/machine/boot.h>
+#include <grub/machine/kernel.h>
+#include <multiboot.h>
+
+ .file "lnxboot.S"
+
+#define CODE_ADDR 0x6000
+#define CODE_SECTORS 1
+#define DATA_ADDR ((GRUB_BOOT_MACHINE_KERNEL_ADDR) + 0x200)
+
+#define BLCK_LENG 0x4000
+
+ .text
+
+ .code16
+
+ .globl start, _start
+
+data_start:
+ xorl %ebp, %ebp
+ jmp LOCAL(linux_next)
+
+ .org 0x1F1
+
+setup_sects:
+ .byte CODE_SECTORS
+root_flags:
+ .word 0
+syssize:
+ .word 0
+swap_dev:
+ .word 0
+ram_size:
+ .word 0
+vid_mode:
+ .word 0
+root_dev:
+ .word 0
+boot_flag:
+ .word 0xAA55
+
+start:
+_start:
+
+ jmp LOCAL(linux_init)
+
+ .ascii "HdrS" /* Header signature. */
+ .word 0x0203 /* Header version number. */
+
+realmode_swtch:
+ .word 0, 0 /* default_switch, SETUPSEG. */
+start_sys_seg:
+ .word 0x1000 /* Obsolete. */
+version_ptr:
+ .word 0 /* Version string ptr. */
+type_of_loader:
+ .byte 0 /* Filled in by boot loader. */
+loadflags:
+ .byte 1 /* Please load high. */
+setup_move_size:
+ .word 0 /* Unused. */
+code32_start:
+ .long 0x100000 /* 32-bit start address. */
+ramdisk_image:
+ .long 0 /* Loaded ramdisk image address. */
+ramdisk_size:
+ .long 0 /* Size of loaded ramdisk. */
+bootsect_kludge:
+ .word 0, 0
+heap_end_ptr:
+ .word 0
+pad1:
+ .word 0
+cmd_line_ptr:
+ .long 0 /* Command line. */
+ramdisk_max:
+ .long 0xffffffff /* Highest allowed ramdisk address. */
+
+gdt:
+ .long 0, 0, 0, 0 /* Must be zero. */
+ .word 0xffff /* 64 K segment size. */
+gdt_src1:
+ .byte 0, 0 ,0 /* Low 24 bits of source address. */
+ .byte 0x93 /* Access rights. */
+ .byte 0 /* Extended access rights. */
+gdt_src2:
+ .byte 0 /* High 8 bits of source address. */
+ .word 0xffff /* 64 K segment size. */
+gdt_dst1:
+ .byte 0, 0, 0 /* Low 24 bits of target address. */
+ .byte 0x93 /* Access rights. */
+ .byte 0 /* Extended access rights. */
+gdt_dst2:
+ .byte 0 /* High 8 bits of source address. */
+ .long 0, 0, 0, 0 /* More space for the BIOS. */
+
+reg_edx:
+ .byte 0x80, 0, 0xFF, 0xFF
+
+data_leng:
+ .long 0
+
+LOCAL(linux_init):
+ movw %cs:(reg_edx - start), %dx
+ movl %cs:(code32_start - start), %ebp
+
+LOCAL(linux_next):
+
+ call LOCAL(normalize)
+
+LOCAL(normalize):
+ popw %bx
+ subw $(LOCAL(normalize) - start), %bx
+ shrw $4, %bx
+ movw %cs, %ax
+ addw %bx, %ax
+ pushw %ax
+ pushw $(real_code - start)
+ lret /* Jump to real_code. */
+
+real_code:
+ subw $0x20, %ax
+ movw %ax, %ds
+ movw (setup_sects - data_start), %cx
+ shlw $7, %cx
+
+ /* Setup stack. */
+
+ xorw %si, %si
+ movw %si, %ss
+ movw $(CODE_ADDR), %sp
+
+ /* Move itself to 0:CODE_ADDR. */
+
+ cld
+ movw %cs, %ax
+ movw %ax, %ds
+ movw $(CODE_ADDR >> 4), %ax
+ movw %ax, %es
+ movw %si, %di
+
+ rep
+ movsl
+ ljmp $(CODE_ADDR >> 4), $(real_code_2 - start)
+
+real_code_2:
+
+ xchgl %ebp, %esi
+ orl %esi, %esi
+ jnz 1f
+ movw %ds, %si
+ shll $4, %esi
+ addl %ebp, %esi
+1:
+
+ pushw %es
+ popw %ds
+
+ movl $0x1000, %ecx
+ addl $0x200, %esi
+ movl $DATA_ADDR, %edi
+
+ call LOCAL(move_memory)
+
+ /* Check for multiboot signature. */
+ movl $DATA_ADDR, %edi
+3:
+ movl %ss:(%edi), %eax
+ cmpl $MULTIBOOT_HEADER_MAGIC, %eax
+ jz 1f
+ addl $4, %edi
+ cmpl $(DATA_ADDR + 0x1000), %edi
+ jne 3b
+
+ movl (ramdisk_image - start), %esi
+ movl (ramdisk_size - start), %ecx
+ movl $(DATA_ADDR - 0x200), %edi
+ jmp 2f
+
+1:
+
+ movl $(DATA_ADDR + 0x1000), %edi
+ movl %ss:(DATA_ADDR + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE), %ecx
+ addl $GRUB_DECOMPRESSOR_I386_PC_MAX_DECOMPRESSOR_SIZE, %ecx
+
+2:
+ call LOCAL(move_memory)
+
+ movb %dh, %ss:(DATA_ADDR + GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE + 2)
+ movb (reg_edx + 2 - start), %dh
+ movb %dh, %ss:(DATA_ADDR + GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE + 1)
+
+ movb $0xFF, %dh
+
+ ljmp $(DATA_ADDR >> 4), $0
+
+/*
+ * Parameters:
+ * esi: source address
+ * edi: target address
+ * ecx: number of bytes
+ */
+
+LOCAL(move_memory):
+ incl %ecx
+ andb $0xFE, %cl
+ pushw %dx
+1:
+ pushl %esi
+ pushl %edi
+ pushl %ecx
+ cmpl $BLCK_LENG, %ecx
+ jbe 2f
+ movl $BLCK_LENG, %ecx
+2:
+ pushl %ecx
+
+ movl %esi, %eax
+ movw %si, (gdt_src1 - start)
+ shrl $16, %eax
+ movb %al, (gdt_src1 + 2 - start)
+ movb %ah, (gdt_src2 - start)
+
+ movl %edi, %eax
+ movw %di, (gdt_dst1 - start)
+ shrl $16, %eax
+ movb %al, (gdt_dst1 + 2 - start)
+ movb %ah, (gdt_dst2 - start)
+
+ movw $(gdt - start), %si
+ movb $0x87, %ah
+ shrw $1, %cx
+
+ int $0x15
+
+ popl %eax
+ popl %ecx
+ popl %edi
+ popl %esi
+
+ jnc 2f
+ movw $(err_int15_msg - start), %si
+ jmp LOCAL(fail)
+
+2:
+
+ addl %eax, %esi
+ addl %eax, %edi
+ subl %eax, %ecx
+ jnz 1b
+
+
+ popw %dx
+ ret
+
+/*
+ * Parameters:
+ * si: message
+ */
+
+LOCAL(fail):
+ movb $0x0e, %ah
+ xorw %bx, %bx
+1:
+ lodsb (%si), %al
+ int $0x10
+ cmpb $0, %al
+ jne 1b
+1: jmp 1b
+
+err_int15_msg:
+ .ascii "move memory fails\0"
+
+ .org (CODE_SECTORS * 512 + 512)
diff --git a/grub-core/boot/i386/pc/lzma_decode.S b/grub-core/boot/i386/pc/lzma_decode.S
new file mode 100644
index 0000000..88c668d
--- /dev/null
+++ b/grub-core/boot/i386/pc/lzma_decode.S
@@ -0,0 +1,614 @@
+/*
+ * 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/>.
+ */
+
+#define FIXED_PROPS
+
+#define LZMA_BASE_SIZE 1846
+#define LZMA_LIT_SIZE 768
+
+#define LZMA_PROPERTIES_SIZE 5
+
+#define kNumTopBits 24
+#define kTopValue (1 << kNumTopBits)
+
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
+
+
+#define kNumPosBitsMax 4
+#define kNumPosStatesMax (1 << kNumPosBitsMax)
+
+#define kLenNumLowBits 3
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
+#define kLenNumMidBits 3
+#define kLenNumMidSymbols (1 << kLenNumMidBits)
+#define kLenNumHighBits 8
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
+
+#define LenChoice 0
+#define LenChoice2 (LenChoice + 1)
+#define LenLow (LenChoice2 + 1)
+#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
+#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
+#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
+
+
+#define kNumStates 12
+#define kNumLitStates 7
+
+#define kStartPosModelIndex 4
+#define kEndPosModelIndex 14
+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
+
+#define kNumPosSlotBits 6
+#define kNumLenToPosStates 4
+
+#define kNumAlignBits 4
+#define kAlignTableSize (1 << kNumAlignBits)
+
+#define kMatchMinLen 2
+
+#define IsMatch 0
+#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
+#define IsRepG0 (IsRep + kNumStates)
+#define IsRepG1 (IsRepG0 + kNumStates)
+#define IsRepG2 (IsRepG1 + kNumStates)
+#define IsRep0Long (IsRepG2 + kNumStates)
+#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
+#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
+#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
+#define LenCoder (Align + kAlignTableSize)
+#define RepLenCoder (LenCoder + kNumLenProbs)
+#define Literal (RepLenCoder + kNumLenProbs)
+
+#define out_size 8(%ebp)
+
+#define now_pos -4(%ebp)
+#define prev_byte -8(%ebp)
+#define range -12(%ebp)
+#define code -16(%ebp)
+#define state -20(%ebp)
+#define rep0 -24(%ebp)
+#define rep1 -28(%ebp)
+#define rep2 -32(%ebp)
+#define rep3 -36(%ebp)
+
+#ifdef FIXED_PROPS
+
+#define FIXED_LC 3
+#define FIXED_LP 0
+#define FIXED_PB 2
+
+#define POS_STATE_MASK ((1 << (FIXED_PB)) - 1)
+#define LIT_POS_MASK ((1 << (FIXED_LP)) - 1)
+
+#define LOCAL_SIZE 36
+
+#else
+
+#define lc (%ebx)
+#define lp 4(%ebx)
+#define pb 8(%ebx)
+#define probs 12(%ebx)
+
+#define pos_state_mask -40(%ebp)
+#define lit_pos_mask -44(%ebp)
+
+#define LOCAL_SIZE 44
+
+#endif
+
+RangeDecoderBitDecode:
+#ifdef FIXED_PROPS
+ leal (%ebx, %eax, 4), %eax
+#else
+ shll $2, %eax
+ addl probs, %eax
+#endif
+
+ movl %eax, %ecx
+ movl (%ecx), %eax
+
+ movl range, %edx
+ shrl $kNumBitModelTotalBits, %edx
+ mull %edx
+
+ cmpl code, %eax
+ jbe 1f
+
+ movl %eax, range
+ movl $kBitModelTotal, %edx
+ subl (%ecx), %edx
+ shrl $kNumMoveBits, %edx
+ addl %edx, (%ecx)
+ clc
+3:
+ pushf
+ cmpl $kTopValue, range
+ jnc 2f
+ shll $8, code
+ lodsb
+ movb %al, code
+ shll $8, range
+2:
+ popf
+ ret
+1:
+ subl %eax, range
+ subl %eax, code
+ movl (%ecx), %edx
+ shrl $kNumMoveBits, %edx
+ subl %edx, (%ecx)
+ stc
+ jmp 3b
+
+RangeDecoderBitTreeDecode:
+RangeDecoderReverseBitTreeDecode:
+ movzbl %cl, %ecx
+ xorl %edx, %edx
+ pushl %edx
+ incl %edx
+ pushl %edx
+
+1:
+ pushl %eax
+ pushl %ecx
+ pushl %edx
+
+ addl %edx, %eax
+ call RangeDecoderBitDecode
+
+ popl %edx
+ popl %ecx
+
+ jnc 2f
+ movl 4(%esp), %eax
+ orl %eax, 8(%esp)
+ stc
+
+2:
+ adcl %edx, %edx
+ popl %eax
+
+ shll $1, (%esp)
+ loop 1b
+
+ popl %ecx
+ subl %ecx, %edx /* RangeDecoderBitTreeDecode */
+ popl %ecx /* RangeDecoderReverseBitTreeDecode */
+ ret
+
+LzmaLenDecode:
+ pushl %eax
+ addl $LenChoice, %eax
+ call RangeDecoderBitDecode
+ popl %eax
+ jc 1f
+ pushl $0
+ movb $kLenNumLowBits, %cl
+ addl $LenLow, %eax
+2:
+ movl 12(%esp), %edx
+ shll %cl, %edx
+ addl %edx, %eax
+3:
+
+ call RangeDecoderBitTreeDecode
+ popl %eax
+ addl %eax, %edx
+ ret
+
+1:
+ pushl %eax
+ addl $LenChoice2, %eax
+ call RangeDecoderBitDecode
+ popl %eax
+ jc 1f
+ pushl $kLenNumLowSymbols
+ movb $kLenNumMidBits, %cl
+ addl $LenMid, %eax
+ jmp 2b
+
+1:
+ pushl $(kLenNumLowSymbols + kLenNumMidSymbols)
+ addl $LenHigh, %eax
+ movb $kLenNumHighBits, %cl
+ jmp 3b
+
+WriteByte:
+ movb %al, prev_byte
+ stosb
+ incl now_pos
+ ret
+
+/*
+ * int LzmaDecode(CLzmaDecoderState *vs,
+ * const unsigned char *inStream,
+ * unsigned char *outStream,
+ * SizeT outSize);
+ */
+
+_LzmaDecodeA:
+
+ pushl %ebp
+ movl %esp, %ebp
+ subl $LOCAL_SIZE, %esp
+
+#ifndef ASM_FILE
+ pushl %esi
+ pushl %edi
+ pushl %ebx
+
+ movl %eax, %ebx
+ movl %edx, %esi
+ pushl %ecx
+#else
+ pushl %edi
+#endif
+
+ cld
+
+#ifdef FIXED_PROPS
+ movl %ebx, %edi
+ movl $(Literal + (LZMA_LIT_SIZE << (FIXED_LC + FIXED_LP))), %ecx
+#else
+ movl $LZMA_LIT_SIZE, %eax
+ movb lc, %cl
+ addb lp, %cl
+ shll %cl, %eax
+ addl $Literal, %eax
+ movl %eax, %ecx
+ movl probs, %edi
+#endif
+
+ movl $(kBitModelTotal >> 1), %eax
+
+ rep
+ stosl
+
+ popl %edi
+
+ xorl %eax, %eax
+ movl %eax, now_pos
+ movl %eax, prev_byte
+ movl %eax, state
+
+ incl %eax
+ movl %eax, rep0
+ movl %eax, rep1
+ movl %eax, rep2
+ movl %eax, rep3
+
+#ifndef FIXED_PROPS
+ movl %eax, %edx
+ movb pb, %cl
+ shll %cl, %edx
+ decl %edx
+ movl %edx, pos_state_mask
+
+ movl %eax, %edx
+ movb lp, %cl
+ shll %cl, %edx
+ decl %edx
+ movl %edx, lit_pos_mask;
+#endif
+
+ /* RangeDecoderInit */
+ negl %eax
+ movl %eax, range
+
+ incl %eax
+ movb $5, %cl
+
+1:
+ shll $8, %eax
+ lodsb
+ loop 1b
+
+ movl %eax, code
+
+lzma_decode_loop:
+ movl now_pos, %eax
+ cmpl out_size, %eax
+
+ jb 1f
+
+#ifndef ASM_FILE
+ xorl %eax, %eax
+
+ popl %ebx
+ popl %edi
+ popl %esi
+#endif
+
+ movl %ebp, %esp
+ popl %ebp
+ ret
+
+1:
+#ifdef FIXED_PROPS
+ andl $POS_STATE_MASK, %eax
+#else
+ andl pos_state_mask, %eax
+#endif
+ pushl %eax /* posState */
+ movl state, %edx
+ shll $kNumPosBitsMax, %edx
+ addl %edx, %eax
+ pushl %eax /* (state << kNumPosBitsMax) + posState */
+
+ call RangeDecoderBitDecode
+ jc 1f
+
+ movl now_pos, %eax
+
+#ifdef FIXED_PROPS
+ andl $LIT_POS_MASK, %eax
+ shll $FIXED_LC, %eax
+ movl prev_byte, %edx
+ shrl $(8 - FIXED_LC), %edx
+#else
+ andl lit_pos_mask, %eax
+ movb lc, %cl
+ shll %cl, %eax
+ negb %cl
+ addb $8, %cl
+ movl prev_byte, %edx
+ shrl %cl, %edx
+#endif
+
+ addl %edx, %eax
+ movl $LZMA_LIT_SIZE, %edx
+ mull %edx
+ addl $Literal, %eax
+ pushl %eax
+
+ incl %edx /* edx = 1 */
+
+ movl rep0, %eax
+ negl %eax
+ pushl (%edi, %eax) /* matchByte */
+
+ cmpb $kNumLitStates, state
+ jb 5f
+
+ /* LzmaLiteralDecodeMatch */
+
+3:
+ cmpl $0x100, %edx
+ jae 4f
+
+ xorl %eax, %eax
+ shlb $1, (%esp)
+ adcl %eax, %eax
+
+ pushl %eax
+ pushl %edx
+
+ shll $8, %eax
+ leal 0x100(%edx, %eax), %eax
+ addl 12(%esp), %eax
+ call RangeDecoderBitDecode
+
+ setc %al
+ popl %edx
+ adcl %edx, %edx
+
+ popl %ecx
+ cmpb %cl, %al
+ jz 3b
+
+5:
+
+ /* LzmaLiteralDecode */
+
+ cmpl $0x100, %edx
+ jae 4f
+
+ pushl %edx
+ movl %edx, %eax
+ addl 8(%esp), %eax
+ call RangeDecoderBitDecode
+ popl %edx
+ adcl %edx, %edx
+ jmp 5b
+
+4:
+ addl $16, %esp
+
+ movb %dl, %al
+ call WriteByte
+
+ movb state, %al
+ cmpb $4, %al
+ jae 2f
+ xorb %al, %al
+ jmp 3f
+2:
+ subb $3, %al
+ cmpb $7, %al
+ jb 3f
+ subb $3, %al
+3:
+ movb %al, state
+ jmp lzma_decode_loop
+
+1:
+ movl state, %eax
+ addl $IsRep, %eax
+ call RangeDecoderBitDecode
+ jnc 1f
+
+ movl state, %eax
+ addl $IsRepG0, %eax
+ call RangeDecoderBitDecode
+ jc 10f
+
+ movl (%esp), %eax
+ addl $IsRep0Long, %eax
+ call RangeDecoderBitDecode
+ jc 20f
+
+ cmpb $7, state
+ movb $9, state
+ jb 100f
+ addb $2, state
+100:
+
+ movl $1, %ecx
+
+3:
+ movl rep0, %edx
+ negl %edx
+
+4:
+ movb (%edi, %edx), %al
+ call WriteByte
+ loop 4b
+
+ popl %eax
+ popl %eax
+ jmp lzma_decode_loop
+
+10:
+ movl state, %eax
+ addl $IsRepG1, %eax
+ call RangeDecoderBitDecode
+ movl rep1, %edx
+ jnc 100f
+
+ movl state, %eax
+ addl $IsRepG2, %eax
+ call RangeDecoderBitDecode
+ movl rep2, %edx
+ jnc 1000f
+ movl rep2, %edx
+ xchgl rep3, %edx
+1000:
+ pushl rep1
+ popl rep2
+100:
+ xchg rep0, %edx
+ movl %edx, rep1
+20:
+
+ movl $RepLenCoder, %eax
+ call LzmaLenDecode
+
+ cmpb $7, state
+ movb $8, state
+ jb 100f
+ addb $3, state
+100:
+ jmp 2f
+
+1:
+ movl rep0, %eax
+ xchgl rep1, %eax
+ xchgl rep2, %eax
+ movl %eax, rep3
+
+ cmpb $7, state
+ movb $7, state
+ jb 10f
+ addb $3, state
+10:
+
+ movl $LenCoder, %eax
+ call LzmaLenDecode
+ pushl %edx
+
+ movl $(kNumLenToPosStates - 1), %eax
+ cmpl %eax, %edx
+ jbe 100f
+ movl %eax, %edx
+100:
+ movb $kNumPosSlotBits, %cl
+ shll %cl, %edx
+ leal PosSlot(%edx), %eax
+ call RangeDecoderBitTreeDecode
+
+ movl %edx, rep0
+ cmpl $kStartPosModelIndex, %edx
+ jb 100f
+
+ movl %edx, %ecx
+ shrl $1, %ecx
+ decl %ecx
+
+ movzbl %dl, %eax
+ andb $1, %al
+ orb $2, %al
+ shll %cl, %eax
+ movl %eax, rep0
+
+ cmpl $kEndPosModelIndex, %edx
+ jae 200f
+ movl rep0, %eax
+ addl $(SpecPos - 1), %eax
+ subl %edx, %eax
+ jmp 300f
+200:
+
+ subb $kNumAlignBits, %cl
+
+ /* RangeDecoderDecodeDirectBits */
+ xorl %edx, %edx
+
+1000:
+ shrl $1, range
+ shll $1, %edx
+
+ movl range, %eax
+ cmpl %eax, code
+ jb 2000f
+ subl %eax, code
+ orb $1, %dl
+2000:
+
+ cmpl $kTopValue, %eax
+ jae 3000f
+ shll $8, range
+ shll $8, code
+ lodsb
+ movb %al, code
+
+3000:
+ loop 1000b
+
+ movb $kNumAlignBits, %cl
+ shll %cl, %edx
+ addl %edx, rep0
+
+ movl $Align, %eax
+
+300:
+ call RangeDecoderReverseBitTreeDecode
+ addl %ecx, rep0
+
+100:
+ incl rep0
+ popl %edx
+
+2:
+
+ addl $kMatchMinLen, %edx
+ movl %edx, %ecx
+
+ jmp 3b
diff --git a/grub-core/boot/i386/pc/pxeboot.S b/grub-core/boot/i386/pc/pxeboot.S
new file mode 100644
index 0000000..b695b24
--- /dev/null
+++ b/grub-core/boot/i386/pc/pxeboot.S
@@ -0,0 +1,42 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/boot.h>
+
+ .file "pxeboot.S"
+ .text
+
+ /* Start with the prehistoric environment... */
+ .code16
+
+ /* Let's go */
+.globl start, _start;
+_start:
+start:
+
+ /* Use drive number 0x7F for PXE */
+ movb $GRUB_BOOT_MACHINE_PXE_DL, %dl
+
+ /* Jump to the real world */
+ ljmp $0, $0x8200
+
+ /* 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. */
+ .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
new file mode 100644
index 0000000..2897482
--- /dev/null
+++ b/grub-core/boot/i386/pc/startup_raw.S
@@ -0,0 +1,369 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008,2009,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/symbol.h>
+#include <grub/offsets.h>
+#include <grub/machine/boot.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/kernel.h>
+
+#define ABS(x) ((x) - LOCAL (base) + GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
+
+ .file "startup_raw.S"
+
+ .text
+
+ /* Tell GAS to generate 16-bit instructions so that this code works
+ in real mode. */
+ .code16
+
+ .globl start, _start
+start:
+_start:
+LOCAL (base):
+ /*
+ * Guarantee that "main" is loaded at 0x0:0x8200.
+ */
+#ifdef __APPLE__
+ ljmp $0, $(ABS(LOCAL (codestart)) - 0x10000)
+#else
+ ljmp $0, $ABS(LOCAL (codestart))
+#endif
+
+ /*
+ * This is a special data area.
+ */
+
+ .org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
+LOCAL(compressed_size):
+ .long 0
+ .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
+LOCAL(uncompressed_size):
+ .long 0
+
+ .org GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY
+reed_solomon_redundancy:
+ .long 0
+ .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.
+ */
+ .org GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE
+LOCAL(boot_dev):
+ .byte 0xFF, 0xFF, 0xFF
+LOCAL(boot_drive):
+ .byte 0x00
+
+/* the real mode code continues... */
+LOCAL (codestart):
+ cli /* we're not safe here! */
+
+ /* set up %ds, %ss, and %es */
+ xorw %ax, %ax
+ movw %ax, %ds
+ movw %ax, %ss
+ movw %ax, %es
+
+ /* set up the real mode/BIOS stack */
+ movl $GRUB_MEMORY_MACHINE_REAL_STACK, %ebp
+ movl %ebp, %esp
+
+ sti /* we're safe again */
+
+ /* save the boot drive */
+ movb %dl, LOCAL(boot_drive)
+
+ /* reset disk system (%ah = 0) */
+ int $0x13
+
+ /* transition to protected mode */
+ calll real_to_prot
+
+ /* The ".code32" directive takes GAS out of 16-bit mode. */
+ .code32
+
+ cld
+ call grub_gate_a20
+
+ movl LOCAL(compressed_size), %edx
+#ifdef __APPLE__
+ addl $decompressor_end, %edx
+ subl $(LOCAL(reed_solomon_part)), %edx
+#else
+ addl $(LOCAL(decompressor_end) - LOCAL(reed_solomon_part)), %edx
+#endif
+ movl reed_solomon_redundancy, %ecx
+ leal LOCAL(reed_solomon_part), %eax
+ cld
+ call EXT_C (grub_reed_solomon_recover)
+ jmp post_reed_solomon
+
+#include "../../../kern/i386/realmode.S"
+
+/*
+ *
+ * This is a workaround for clang adding a section containing only .addrsig
+ * Since clang itself is unable to assemble this pseudo-opcode, just replace
+ * it with .text
+ *
+ */
+#define addrsig text
+#include <rs_decoder.h>
+#undef addrsig
+
+ .text
+
+/*
+ * grub_gate_a20(void)
+ *
+ * Gate address-line 20 for high memory.
+ *
+ * This routine is probably overconservative in what it does, but so what?
+ *
+ * It also eats any keystrokes in the keyboard buffer. :-(
+ */
+
+grub_gate_a20:
+gate_a20_test_current_state:
+ /* first of all, test if already in a good state */
+ call gate_a20_check_state
+ testb %al, %al
+ jnz gate_a20_try_bios
+ ret
+
+gate_a20_try_bios:
+ /* second, try a BIOS call */
+ pushl %ebp
+ call prot_to_real
+
+ .code16
+ movw $0x2401, %ax
+ int $0x15
+
+ calll real_to_prot
+ .code32
+
+ popl %ebp
+ call gate_a20_check_state
+ testb %al, %al
+ jnz gate_a20_try_system_control_port_a
+ ret
+
+gate_a20_try_system_control_port_a:
+ /*
+ * In macbook, the keyboard test would hang the machine, so we move
+ * this forward.
+ */
+ /* fourth, try the system control port A */
+ inb $0x92
+ andb $(~0x03), %al
+ orb $0x02, %al
+ outb $0x92
+
+ call gate_a20_check_state
+ testb %al, %al
+ jnz gate_a20_try_keyboard_controller
+ ret
+
+gate_a20_flush_keyboard_buffer:
+ inb $0x64
+ andb $0x02, %al
+ jnz gate_a20_flush_keyboard_buffer
+2:
+ inb $0x64
+ andb $0x01, %al
+ jz 3f
+ inb $0x60
+ jmp 2b
+3:
+ ret
+
+gate_a20_try_keyboard_controller:
+ /* third, try the keyboard controller */
+ call gate_a20_flush_keyboard_buffer
+
+ movb $0xd1, %al
+ outb $0x64
+4:
+ inb $0x64
+ andb $0x02, %al
+ jnz 4b
+
+ movb $0xdf, %al
+ outb $0x60
+ call gate_a20_flush_keyboard_buffer
+
+ /* output a dummy command (USB keyboard hack) */
+ movb $0xff, %al
+ outb $0x64
+ call gate_a20_flush_keyboard_buffer
+
+ call gate_a20_check_state
+ testb %al, %al
+ /* everything failed, so restart from the beginning */
+ jnz gate_a20_try_bios
+ ret
+
+gate_a20_check_state:
+ /* iterate the checking for a while */
+ movl $100, %ecx
+1:
+ call 3f
+ testb %al, %al
+ jz 2f
+ loop 1b
+2:
+ ret
+3:
+ pushl %ebx
+ pushl %ecx
+ xorl %eax, %eax
+ /* compare the byte at 0x8000 with that at 0x108000 */
+ movl $GRUB_BOOT_MACHINE_KERNEL_ADDR, %ebx
+ pushl %ebx
+ /* save the original byte in CL */
+ movb (%ebx), %cl
+ /* store the value at 0x108000 in AL */
+ addl $0x100000, %ebx
+ movb (%ebx), %al
+ /* try to set one less value at 0x8000 */
+ popl %ebx
+ movb %al, %ch
+ decb %ch
+ movb %ch, (%ebx)
+ /* serialize */
+ outb %al, $0x80
+ outb %al, $0x80
+ /* obtain the value at 0x108000 in CH */
+ pushl %ebx
+ addl $0x100000, %ebx
+ movb (%ebx), %ch
+ /* this result is 0 if A20 is on or 1 if it is off */
+ subb %ch, %al
+ /* restore the original */
+ popl %ebx
+ movb %cl, (%ebx)
+ popl %ecx
+ popl %ebx
+ ret
+
+LOCAL(reed_solomon_part):
+
+/*
+ * Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
+ * This uses the a.out kludge to load raw binary to the area starting at 1MB,
+ * and relocates itself after loaded.
+ */
+ .p2align 2 /* force 4-byte alignment */
+multiboot_header:
+ /* magic */
+ .long 0x1BADB002
+ /* flags */
+ .long (1 << 16)
+ /* checksum */
+ .long -0x1BADB002 - (1 << 16)
+ /* header addr */
+ .long multiboot_header - _start + 0x100000 + 0x200
+ /* load addr */
+ .long 0x100000
+ /* load end addr */
+ .long 0
+ /* bss end addr */
+ .long 0
+ /* entry addr */
+ .long multiboot_entry - _start + 0x100000 + 0x200
+
+multiboot_entry:
+ .code32
+ /* obtain the boot device */
+ movl 12(%ebx), %edx
+
+ movl $GRUB_MEMORY_MACHINE_PROT_STACK, %ebp
+ movl %ebp, %esp
+
+ /* relocate the code */
+#ifdef __APPLE__
+ LOCAL(compressed_size_offset) = LOCAL(compressed_size) - LOCAL(base)
+ movl $0x200, %ecx
+ addl $decompressor_end, %ecx
+ subl $LOCAL(base), %ecx
+ addl LOCAL(compressed_size_offset) + 0x100000 + 0x200, %ecx
+#else
+ movl $(LOCAL(decompressor_end) - _start + 0x200), %ecx
+ addl LOCAL(compressed_size) - _start + 0x100000 + 0x200, %ecx
+#endif
+ movl $0x100000, %esi
+ movl $GRUB_BOOT_MACHINE_KERNEL_ADDR, %edi
+ cld
+ rep
+ movsb
+ /* jump to the real address */
+ movl $multiboot_trampoline, %eax
+ jmp *%eax
+
+multiboot_trampoline:
+ /* fill the boot information */
+ movl %edx, LOCAL(boot_dev)
+ shrl $24, %edx
+ /* enter the usual booting */
+ call prot_to_real
+ .code16
+ jmp LOCAL (codestart)
+ .code32
+
+post_reed_solomon:
+
+#ifdef ENABLE_LZMA
+ movl $GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR, %edi
+#ifdef __APPLE__
+ movl $decompressor_end, %esi
+#else
+ movl $LOCAL(decompressor_end), %esi
+#endif
+ pushl %edi
+ movl LOCAL (uncompressed_size), %ecx
+ leal (%edi, %ecx), %ebx
+ /* Don't remove this push: it's an argument. */
+ push %ecx
+ call _LzmaDecodeA
+ pop %ecx
+ /* _LzmaDecodeA clears DF, so no need to run cld */
+ popl %esi
+#endif
+
+ movl LOCAL(boot_dev), %edx
+ movl $prot_to_real, %edi
+ movl $real_to_prot, %ecx
+ movl $LOCAL(realidt), %eax
+ jmp *%esi
+
+#ifdef ENABLE_LZMA
+#include "lzma_decode.S"
+#endif
+
+ .p2align 4
+
+#ifdef __APPLE__
+ .zerofill __DATA, __aa_before_bss, decompressor_end, 10, 0
+#else
+ .bss
+LOCAL(decompressor_end):
+#endif
diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S
new file mode 100644
index 0000000..8c3a1db
--- /dev/null
+++ b/grub-core/boot/i386/qemu/boot.S
@@ -0,0 +1,74 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/symbol.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/boot.h>
+#include <grub/machine/kernel.h>
+
+ .text
+ .code16
+ .globl _start
+_start:
+ /* Disable interrupts. */
+ cli
+
+ jmp 1f
+
+ .org GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR
+VARIABLE(grub_core_entry_addr)
+ .long 0
+1:
+
+ /* Set up %ds, %ss, and %es. */
+ xorw %ax, %ax
+ movw %ax, %ds
+ movw %ax, %ss
+ movw %ax, %es
+
+ /* Set up the real mode stack. */
+ movl $GRUB_MEMORY_MACHINE_REAL_STACK, %esp
+
+ /* Transition to protected mode. We use pushl to force generation
+ of a flat return address. */
+ pushl $1f
+ 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. */
+ inb $0x92
+ andb $(~0x03), %al
+ orb $0x02, %al
+ outb $0x92
+ movl EXT_C(grub_core_entry_addr), %edx
+ jmp *%edx
+
+#include "../../../kern/i386/realmode.S"
+
+ /* Intel, in its infinite wisdom, decided to put the i8086 entry point
+ *right here* and this is why we need this kludge. */
+
+ .org GRUB_BOOT_MACHINE_SIZE - 16
+
+ .code16
+
+ jmp _start
+ .org GRUB_BOOT_MACHINE_SIZE
diff --git a/grub-core/boot/mips/loongson/fuloong2f.S b/grub-core/boot/mips/loongson/fuloong2f.S
new file mode 100644
index 0000000..a88c81e
--- /dev/null
+++ b/grub-core/boot/mips/loongson/fuloong2f.S
@@ -0,0 +1,2 @@
+#define FULOONG2F 1
+#include "fwstart.S"
diff --git a/grub-core/boot/mips/loongson/fwstart.S b/grub-core/boot/mips/loongson/fwstart.S
new file mode 100644
index 0000000..28c6346
--- /dev/null
+++ b/grub-core/boot/mips/loongson/fwstart.S
@@ -0,0 +1,756 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mips/loongson/serial.h>
+#include <grub/mips/loongson/pci.h>
+#include <grub/mips/loongson.h>
+#include <grub/pci.h>
+#include <grub/machine/serial.h>
+#include <grub/machine/kernel.h>
+#include <grub/ns8250.h>
+#include <grub/cs5536.h>
+#include <grub/smbus.h>
+
+#ifndef FULOONG2F
+#include <grub/vgaregs.h>
+#define GRUB_SM712_REG_BASE 0x700000
+#define GRUB_SM712_PCIID 0x0712126f
+#endif
+
+#ifdef FULOONG2F
+#define GRUB_MACHINE_SERIAL_PORT GRUB_MACHINE_SERIAL_PORT2
+#define GRUB_MACHINE_SERIAL_DIVISOR_115200 GRUB_MACHINE_SERIAL_PORT2_DIVISOR_115200
+#else
+#define GRUB_MACHINE_SERIAL_PORT GRUB_MACHINE_SERIAL_PORT0
+#define GRUB_MACHINE_SERIAL_DIVISOR_115200 GRUB_MACHINE_SERIAL_PORT0_DIVISOR_115200
+#endif
+
+ .set noreorder
+ .set noat
+ .set nomacro
+ .set mips3
+
+ .global start,_start,__start
+start:
+_start:
+__start:
+ /* Put serial init as soon as possible. But on Fuloong2f serial is past
+ Geode, so on Fuloong2f we need Geode first.
+ */
+#ifndef FULOONG2F
+ bal serial_hw_init
+ nop
+#endif
+
+ /* Find CS5536 controller. */
+ /* $t4 chooses device in priority encoding. */
+ /* Resulting value is kept in GRUB_MACHINE_PCI_CONF_CTRL_REG.
+ This way we don't need to sacrifice a register for it. */
+retry_cs5536:
+ /* We have only one bus (0). Function is 0. */
+ lui $t0, %hi(GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR_2F)
+ lui $t1, %hi(GRUB_MACHINE_PCI_CONFSPACE_2F)
+ lui $t3, %hi(GRUB_CS5536_PCIID)
+ addiu $t3, $t3, %lo(GRUB_CS5536_PCIID)
+ ori $t4, $zero, 1
+1:
+ andi $t4, $t4, ((1 << GRUB_PCI_NUM_DEVICES_2F) - 1)
+ /* In case of failure try again. CS5536 may be slow to come up. */
+ beql $t4, $zero, retry_cs5536
+ nop
+ sw $t4, %lo(GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR_2F) ($t0)
+ lw $t2, (%lo(GRUB_MACHINE_PCI_CONFSPACE_2F) + GRUB_PCI_REG_PCI_ID) ($t1)
+ bnel $t2, $t3, 1b
+ sll $t4, $t4, 1
+
+#ifndef FULOONG2F
+ lui $a0, %hi(cs5536_found)
+ bal message
+ addiu $a0, $a0, %lo(cs5536_found)
+ bal printhex
+ move $a0, $t4
+#endif
+
+ lui $t0, %hi(GRUB_MACHINE_PCI_CONFSPACE_2F)
+ li $t1, GRUB_CS5536_MSR_MAILBOX_CONFIG_ENABLED
+ sw $t1, (%lo(GRUB_MACHINE_PCI_CONFSPACE_2F) + GRUB_CS5536_MSR_MAILBOX_CONFIG) ($t0)
+
+ /* Set GPIO LBAR. */
+ lui $a0, %hi(GRUB_CS5536_MSR_GPIO_BAR)
+ addiu $a0, $a0, %lo(GRUB_CS5536_MSR_GPIO_BAR)
+ ori $a1, $zero, GRUB_CS5536_LBAR_GPIO
+ /* Set mask to 0xf and enabled bit to 1. */
+ bal wrmsr
+ ori $a2, $zero, ((GRUB_CS5536_LBAR_MASK_MASK \
+ | GRUB_CS5536_LBAR_ENABLE) >> 32)
+
+ bal gpio_init
+ nop
+
+#ifdef FULOONG2F
+ bal serial_hw_init
+ nop
+#endif
+
+ /* Initialise SMBus controller. */
+ /* Set SMBUS LBAR. */
+ lui $a0, %hi(GRUB_CS5536_MSR_SMB_BAR)
+ addiu $a0, $a0, %lo(GRUB_CS5536_MSR_SMB_BAR)
+ ori $a1, $zero, GRUB_CS5536_LBAR_SMBUS
+ /* Set mask to 0xf and enabled bit to 1. */
+ bal wrmsr
+ ori $a2, $zero, ((GRUB_CS5536_LBAR_MASK_MASK \
+ | GRUB_CS5536_LBAR_ENABLE) >> 32)
+
+ lui $a0, %hi(smbus_enabled)
+ bal message
+ addiu $a0, $a0, %lo(smbus_enabled)
+
+ lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS)
+
+ /* Disable SMB. */
+ sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL2) ($t0)
+
+ /* Disable interrupts. */
+ sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1) ($t0)
+
+ /* Set as master. */
+ sb $zero, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_ADDR) ($t0)
+
+ /* Launch SMBus controller at slowest speed possible. */
+ ori $t1, $zero, 0xff
+ sb $t1, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL3) ($t0)
+ sb $t1, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL2) ($t0)
+
+ /* Yeeloong and Fuloong2f have only one memory slot. */
+ /* Output first byte on serial for debugging. */
+ ori $a1, $zero, GRUB_SMB_RAM_START_ADDR
+ bal read_spd
+ move $a0, $zero
+ bal printhex
+ move $a0, $v0
+
+ bal read_spd
+ ori $a0, $zero, GRUB_SMBUS_SPD_MEMORY_TYPE_ADDR
+ ori $t0, $zero, GRUB_SMBUS_SPD_MEMORY_TYPE_DDR2
+ lui $a0, %hi(unimplemented_memory_type)
+ bne $t0, $v0, fatal
+ addiu $a0, $a0, %lo(unimplemented_memory_type)
+
+ /* And here is our goal: DDR2 controller initialisation. */
+ lui $t0, %hi(GRUB_CPU_LOONGSON_CORECFG)
+ ld $t1, %lo(GRUB_CPU_LOONGSON_CORECFG) ($t0)
+ /* Use addiu for sign-extension. */
+ addiu $t2, $zero, ~(GRUB_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE|GRUB_CPU_LOONGSON_CORECFG_BUFFER_CPU)
+ and $t1, $t1, $t2
+ sd $t1, %lo (GRUB_CPU_LOONGSON_CORECFG) ($t0)
+
+ b continue
+
+ .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
+ move $s3, $ra
+ lui $a0, %hi(epc)
+ bal message
+ addiu $a0, $a0, %lo(epc)
+
+ bal printhex
+ move $a0, $s1
+
+ lui $a0, %hi(badvaddr)
+ bal message
+ addiu $a0, $a0, %lo(badvaddr)
+
+ bal printhex
+ move $a0, $s2
+
+ lui $a0, %hi(return_msg)
+ bal message
+ addiu $a0, $a0, %lo(return_msg)
+
+ bal printhex
+ move $a0, $s3
+
+ lui $a0, %hi(newline)
+ bal message
+ addiu $a0, $a0, %lo(newline)
+
+ lui $a0, %hi(unhandled_tlb_refill)
+ b fatal
+ addiu $a0, $a0, %lo(unhandled_tlb_refill)
+
+ .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)
+
+ .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
+ mfc0 $s2, GRUB_CPU_LOONGSON_COP0_BADVADDR
+ lui $a0, %hi(cause)
+ bal message
+ addiu $a0, $a0, %lo(cause)
+
+ bal printhex
+ move $a0, $s0
+
+ lui $a0, %hi(epc)
+ bal message
+ addiu $a0, $a0, %lo(epc)
+
+ bal printhex
+ move $a0, $s1
+
+ lui $a0, %hi(badvaddr)
+ bal message
+ addiu $a0, $a0, %lo(badvaddr)
+
+ bal printhex
+ move $a0, $s2
+
+ lui $a0, %hi(newline)
+ bal message
+ addiu $a0, $a0, %lo(newline)
+
+ lui $a0, %hi(unhandled_exception)
+ b fatal
+ addiu $a0, $a0, %lo(unhandled_exception)
+
+gpio_init:
+ lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_GPIO)
+ addiu $t0, $t0, %lo(GRUB_MACHINE_PCI_IO_BASE_2F + GRUB_CS5536_LBAR_GPIO)
+ lui $t1, %hi (gpio_dump)
+ addiu $t1, $t1, %lo (gpio_dump)
+
+1:
+ lw $t2, 0($t1)
+ sw $t2, 0($t0)
+ addiu $t0, $t0, 4
+ addiu $t1, $t1, 4
+ lui $t2, %hi (gpio_dump_end)
+ addiu $t2, $t2, %lo (gpio_dump_end)
+ bne $t1, $t2, 1b
+ nop
+ jr $ra
+ nop
+
+ /* Same as similarly named C function but in asm since
+ we need it early. */
+ /* In: none. Out: none. Clobbered: $t0, $t1, $t2, $a0, $a1, $a2. */
+serial_hw_init:
+ move $t2, $ra
+#ifdef FULOONG2F
+ lui $a0, %hi(GRUB_CS5536_MSR_DIVIL_LEG_IO)
+ addiu $a0, $a0, %lo(GRUB_CS5536_MSR_DIVIL_LEG_IO)
+ lui $a1, %hi (GRUB_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3 \
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP \
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86 \
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1)
+ ori $a1, $a1, (GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0 \
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1)
+ bal wrmsr
+ move $a2, $zero
+
+ lui $a0, %hi(GRUB_CS5536_MSR_DIVIL_UART1_CONF)
+ addiu $a0, $a0, %lo(GRUB_CS5536_MSR_DIVIL_UART1_CONF)
+ li $a1, 2
+ bal wrmsr
+ move $a2, $zero
+
+ lui $a0, %hi(GRUB_CS5536_MSR_DIVIL_UART2_CONF)
+ addiu $a0, $a0, %lo(GRUB_CS5536_MSR_DIVIL_UART2_CONF)
+ li $a1, 2
+ bal wrmsr
+ move $a2, $zero
+#endif
+
+ lui $t0, %hi (GRUB_MACHINE_SERIAL_PORT)
+
+ /* Turn off the interrupt. */
+ sb $zero, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_IER)($t0)
+
+ /* Set DLAB. */
+ ori $t1, $zero, UART_DLAB
+ sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_LCR)($t0)
+
+ /* Set the baud rate 115200. */
+ ori $t1, $zero, GRUB_MACHINE_SERIAL_DIVISOR_115200
+ sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_DLL)($t0)
+ sb $zero, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_DLH)($t0)
+
+ /* Set the line status. */
+ ori $t1, $zero, (UART_NO_PARITY | UART_8BITS_WORD | UART_1_STOP_BIT)
+ sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_LCR)($t0)
+
+ /* Enable the FIFO. */
+ ori $t1, $zero, UART_ENABLE_FIFO_TRIGGER1
+ sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_FCR)($t0)
+
+ /* Turn on DTR and RTS. */
+ ori $t1, $zero, UART_ENABLE_DTRRTS
+ sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_MCR)($t0)
+
+ /* Let message return to original caller. */
+ lui $a0, %hi(notification_string)
+ addiu $a0, $a0, %lo(notification_string)
+ move $ra, $t2
+
+ /* Print message on serial console. */
+ /* In: $a0 = asciiz message. Out: none. Clobbered: $t0, $t1, $a0. */
+message:
+ lui $t0, %hi (GRUB_MACHINE_SERIAL_PORT)
+1:
+ lb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_LSR)($t0)
+ andi $t1, $t1, UART_EMPTY_TRANSMITTER
+ beq $t1, $zero, 1b
+ nop
+ lb $t1, 0($a0)
+ sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_TX)($t0)
+ bne $t1, $zero, 1b
+ addiu $a0, $a0, 1
+ jr $ra
+ nop
+
+ /* Print 32-bit hexadecimal on serial.
+ In: $a0. Out: None. Clobbered: $a0, $t0, $t1, $t2
+ */
+printhex:
+ lui $t0, %hi (GRUB_MACHINE_SERIAL_PORT)
+ ori $t2, $zero, 8
+1:
+ lb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_LSR)($t0)
+ andi $t1, $t1, UART_EMPTY_TRANSMITTER
+ beq $t1, $zero, 1b
+ nop
+ srl $t1, $a0, 28
+ addiu $t1, $t1, -10
+ bltz $t1, 2f
+ sll $a0, $a0, 4
+ addiu $t1, $t1, 'A'-10-'0'
+2: addiu $t1, $t1, '0'+10
+ sb $t1, (%lo (GRUB_MACHINE_SERIAL_PORT) + UART_TX)($t0)
+ addiu $t2, $t2, -1
+ bne $t2, $zero, 1b
+ nop
+ jr $ra
+ nop
+
+fatal:
+ bal message
+ nop
+self:
+ b self
+ nop
+
+ /* Write CS5536 MSR.
+ In: $a0 address, $a1 lower word, $a2 upper word.
+ Out: None
+ Clobbered: $t0
+ */
+wrmsr:
+ lui $t0, %hi(GRUB_MACHINE_PCI_CONFSPACE_2F)
+ sw $a0, (%lo(GRUB_MACHINE_PCI_CONFSPACE_2F) + GRUB_CS5536_MSR_MAILBOX_ADDR) ($t0)
+ sw $a1, (%lo(GRUB_MACHINE_PCI_CONFSPACE_2F) + GRUB_CS5536_MSR_MAILBOX_DATA0) ($t0)
+ jr $ra
+ sw $a2, (%lo(GRUB_MACHINE_PCI_CONFSPACE_2F) + GRUB_CS5536_MSR_MAILBOX_DATA1) ($t0)
+
+ /* Wait for SMBus data or empty transmitter. */
+ /* In: $a0 = exception handler. Out: none. Clobbered: $t0, $t1 */
+smbus_wait:
+1:
+ lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_STATUS + GRUB_MACHINE_PCI_IO_BASE_2F)
+ lb $t0, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_STATUS + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+ andi $t1, $t0, GRUB_CS5536_SMB_REG_STATUS_SDAST
+ bne $t1, $zero, return
+ nop
+ andi $t1, $t0, (GRUB_CS5536_SMB_REG_STATUS_BER | GRUB_CS5536_SMB_REG_STATUS_NACK)
+ beq $t1, $zero, 1b
+ nop
+ jr $a0
+ nop
+return:
+ jr $ra
+ nop
+
+ /* Read SPD byte. In: $a0 byte, $a1 device. Out: $v0 read byte (0x100 on failure).
+ Clobbered: $t0, $t1, $t2, $t3, $a0. */
+read_spd:
+ move $t2, $a0
+ move $t3, $ra
+ lui $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)
+ lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+ ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_START
+ bal smbus_wait
+ sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+
+ /* Send device address. */
+ lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F)
+ sll $t1, $a1, 1
+ bal smbus_wait
+ sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+
+ /* Send ACK. */
+ lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
+ lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+ ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_ACK
+ sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+
+ /* Send byte address. */
+ lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F)
+ bal smbus_wait
+ sb $t2, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+
+ /* Send START. */
+ lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
+ lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+ ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_START
+ bal smbus_wait
+ sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+
+ /* Send device address. */
+ lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F)
+ sll $t1, $a1, 1
+ ori $t1, $t1, 1
+ bal smbus_wait
+ sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+
+ /* Send STOP. */
+ lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
+ lb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+ ori $t1, $t1, GRUB_CS5536_SMB_REG_CTRL1_STOP
+ bal smbus_wait
+ sb $t1, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+
+ lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F)
+ lb $v0, %lo(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_DATA + GRUB_MACHINE_PCI_IO_BASE_2F) ($t0)
+ jr $t3
+ andi $v0, $v0, 0xff
+read_spd_fail:
+ jr $t3
+ ori $v0, $v0, 0x100
+
+notification_string: .asciz "GRUB "
+cs5536_found: .asciz "CS5536 at "
+sm_failed: .asciz "SM transaction failed.\n\r"
+unhandled_tlb_refill: .asciz "Unhandled TLB refill.\n\r"
+unhandled_cache_error: .asciz "Unhandled cache error.\n\r"
+unhandled_exception: .asciz "Unhandled exception.\n\r"
+smbus_enabled: .asciz "SMBus controller enabled.\n\r"
+unimplemented_memory_type: .asciz "non-DDR2 memory isn't supported.\n\r"
+no_cas_latency: .asciz "Couldn't determine CAS latency.\n\r"
+cause: .asciz "Cause: "
+epc: .asciz "\n\rEPC: "
+badvaddr: .asciz "\n\rBadVaddr: "
+newline: .asciz "\n\r"
+return_msg: .asciz "\n\rReturn address: "
+caches_enabled: .asciz "Caches enabled\n\r"
+
+ .p2align 3
+
+regdump:
+ .quad 0x0100010000000101 /* 0 */
+ .quad 0x0100010100000000 /* 2 */
+ .quad 0x0101000001000000 /* 3 */
+ .quad 0x0100020200010101 /* 4 */
+ .quad 0x0a04030603050203 /* 6 */
+ .quad 0x0f0e040000010a0b /* 7 */
+#ifdef FULOONG2F
+ .quad 0x0000000100000001 /* 8 */
+#else
+ .quad 0x0000010200000102 /* 8 */
+#endif
+ .quad 0x0000060c00000000 /* 9 */
+ .quad 0x2323233f3f1f0200 /* a */
+ .quad 0x5f7f232323232323 /* b */
+ .quad 0x002a3c0615000000 /* c */
+ .quad 0x002a002a002a002a /* d */
+ .quad 0x002a002a002a002a /* e */
+#ifdef FULOONG2F
+ .quad 0x00b40020005b0004 /* f */
+#else
+ .quad 0x00b40020006d0004 /* f */
+#endif
+ .quad 0x070007ff00000087 /* 10 */
+ .quad 0x000000000016101f /* 11 */
+ .quad 0x001c000000000000 /* 12 */
+ .quad 0x28e1000200c8006b /* 13 */
+ .quad 0x0000204200c8002f /* 14 */
+ .quad 0x0000000000030d40 /* 15 */
+ .quad 0 /* 16 */
+ .quad 0 /* 17 */
+ .quad 0 /* 18 */
+ .quad 0 /* 19 */
+ .quad 0 /* 1a */
+ .quad 0 /* 1b */
+ .quad 0 /* 1c */
+
+/* Dump of GPIO connections. FIXME: Remove useless and macroify. */
+gpio_dump:
+#ifdef FULOONG2F
+ .long 0xffff0000, 0x2eefd110, 0xffff0000, 0xffff0000
+ .long 0x2eefd110, 0xffff0000, 0x1000efff, 0xefff1000
+ .long 0x3df3c20c, 0xffff0000, 0xffff0000, 0xffff0000
+ .long 0x7df3820c, 0x3df3c20c, 0xffff0000, 0x00000000
+ .long 0xffff0000, 0xffff0000, 0x3de3c21c, 0x3d83c27c
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ .long 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000
+ .long 0xffff0000, 0xffff0000, 0x0000ffff, 0xffff0000
+ .long 0xefff1000, 0xffff0000, 0xffff0000, 0xffff0000
+ .long 0xefff1000, 0xefff1000, 0xffff0000, 0x00000000
+ .long 0xffff0000, 0xffff0000, 0xefff1000, 0xefff1000
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+#else
+ .long 0xffff0000, 0x2ffdd002, 0xffff0000, 0xffff0000
+ .long 0x2fffd000, 0xffff0000, 0x1000efff, 0xefff1000
+ .long 0x3ffbc004, 0xffff0000, 0xffff0000, 0xffff0000
+ .long 0x3ffbc004, 0x3ffbc004, 0xffff0000, 0x00000000
+ .long 0xffff0000, 0xffff0000, 0x3ffbc004, 0x3f9bc064
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ .long 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000
+ .long 0xffff0000, 0xffff0000, 0x0000ffff, 0xffff0000
+ .long 0xefff1000, 0xffff0000, 0xffff0000, 0xffff0000
+ .long 0xefff1000, 0xefff1000, 0xffff0000, 0x00000000
+ .long 0xffff0000, 0xffff0000, 0xefff1000, 0xffff0000
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ .long 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ .long 0x00000000, 0x50000000, 0x00000000, 0x00000000
+#endif
+gpio_dump_end:
+
+ .p2align 3
+
+write_dumpreg:
+ ld $t2, 0($t6)
+ sd $t2, 0($t4)
+ addiu $t4, $t4, GRUB_CPU_LOONGSON_DDR2_REG_STEP
+ jr $ra
+ addiu $t6, $t6, GRUB_CPU_LOONGSON_DDR2_REG_SIZE
+
+continue:
+ lui $t4, %hi(GRUB_CPU_LOONGSON_DDR2_BASE)
+ addiu $t4, $t4, %lo(GRUB_CPU_LOONGSON_DDR2_BASE)
+ lui $t6, %hi(regdump)
+
+ /* 0 */
+ bal write_dumpreg
+ addiu $t6, $t6, %lo(regdump)
+
+ /* 1 */
+ ori $a1, $a1, GRUB_SMB_RAM_START_ADDR
+ move $t8, $zero
+ lui $t5, 0x0001
+ bal read_spd
+ ori $a0, $zero, GRUB_SMBUS_SPD_MEMORY_NUM_BANKS_ADDR
+ ori $t7, $zero, 8
+ bne $v0, $t7, 1f
+ ori $t5, $t5, 0x0001
+ ori $t8, $t8, GRUB_CPU_LOONGSON_DDR2_REG1_HI_8BANKS
+1:
+ dsll $t8, $t8, 32
+ or $t5, $t5, $t8
+ sd $t5, 0 ($t4)
+ addiu $t4, $t4, GRUB_CPU_LOONGSON_DDR2_REG_STEP
+
+ /* 2 */
+ bal write_dumpreg
+ nop
+
+ /* 3 */
+ bal write_dumpreg
+ nop
+
+ /* 4 */
+ bal write_dumpreg
+ nop
+
+ /* 5 */
+ /* FIXME: figure termination resistance. */
+ ori $t5, $zero, 0x2
+ bal read_spd
+ ori $a0, $zero, GRUB_SMBUS_SPD_MEMORY_NUM_ROWS_ADDR
+ /* $v0 = 15 - $v0. */
+ xori $v0, $v0, 0xf
+ andi $v0, $v0, 0x7
+ sll $v0, $v0, 8
+ or $t5, $t5, $v0
+
+ /* Find the fastest supported CAS latency. */
+ bal read_spd
+ ori $a0, $zero, GRUB_SMBUS_SPD_MEMORY_CAS_LATENCY_ADDR
+ ori $t0, $zero, GRUB_SMBUS_SPD_MEMORY_CAS_LATENCY_MIN_VALUE
+ ori $t1, $zero, (1 << GRUB_SMBUS_SPD_MEMORY_CAS_LATENCY_MIN_VALUE)
+2:
+ and $t2, $t1, $v0
+ bne $t2, $zero, 1f
+ ori $t3, $zero, 8
+ lui $a0, %hi(no_cas_latency)
+ beq $t0, $t3, fatal
+ addiu $a0, $a0, %lo(no_cas_latency)
+ addiu $t0, $t0, 1
+ b 2b
+ sll $t1, $t1, 1
+1:
+ sll $t0, $t0, 16
+ or $t5, $t5, $t0
+
+ bal read_spd
+ ori $a0, $zero, GRUB_SMBUS_SPD_MEMORY_NUM_COLUMNS_ADDR
+ /* $v0 = 15 - ($v0 + 1) = 14 - $v0. */
+ addiu $v0, $v0, 1
+ xori $v0, $v0, 0xf
+ andi $v0, $v0, 0x7
+ sll $v0, 24
+ or $t5, $t5, $v0
+ sd $t5, 0 ($t4)
+
+ addiu $t4, $t4, GRUB_CPU_LOONGSON_DDR2_REG_STEP
+
+ ori $t7, $zero, 0x16
+
+1:
+ ld $t2, 0($t6)
+ sd $t2, 0($t4)
+ addiu $t4, $t4, GRUB_CPU_LOONGSON_DDR2_REG_STEP
+ addiu $t7, $t7, -1
+ bne $t7, $zero, 1b
+ addiu $t6, $t6, GRUB_CPU_LOONGSON_DDR2_REG_SIZE
+
+ lui $t4, %hi(GRUB_CPU_LOONGSON_DDR2_BASE)
+ ld $t5, (%lo(GRUB_CPU_LOONGSON_DDR2_BASE) + 0x30) ($t4)
+ ori $t0, $zero, 1
+ dsll $t0, $t0, 40
+ or $t5, $t5, $t0
+ sd $t5, (%lo(GRUB_CPU_LOONGSON_DDR2_BASE) + 0x30) ($t4)
+
+ /* Desactivate DDR2 registers. */
+ lui $t0, %hi (GRUB_CPU_LOONGSON_CORECFG)
+ ld $t1, %lo (GRUB_CPU_LOONGSON_CORECFG) ($t0)
+ ori $t1, $t1, GRUB_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE
+ sd $t1, %lo (GRUB_CPU_LOONGSON_CORECFG) ($t0)
+
+ /* Enable cache. */
+ mfc0 $t0, GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG
+ addiu $t1, $zero, ~GRUB_CPU_LOONGSON_CACHE_TYPE_MASK
+ and $t0, $t1, $t1
+ /* Set line size to 32 bytes and disabled cache. */
+ ori $t0, $t0, (GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG_ILINESIZE \
+ | GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG_DLINESIZE \
+ | GRUB_CPU_LOONGSON_CACHE_ACCELERATED)
+ mtc0 $t0, GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG
+
+ /* Invalidate all I-cache entries. */
+ srl $t1, $t0, GRUB_CPU_LOONGSON_COP0_CACHE_ISIZE_SHIFT
+ andi $t1, $t1, GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_MASK
+ ori $t2, $zero, (1 << (GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET \
+ - GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
+ - GRUB_CPU_LOONGSON_I_CACHE_LOG_WAYS))
+ sll $t1, $t2, $t1
+ lui $t2, 0x8000
+
+1:
+ cache GRUB_CPU_LOONGSON_COP0_I_INDEX_INVALIDATE, 0($t2)
+ addiu $t1, $t1, -1
+ bne $t1, $zero, 1b
+ addiu $t2, $t2, (1 << GRUB_CPU_LOONGSON_COP0_I_INDEX_BIT_OFFSET)
+
+ /* Invalidate all D-cache entries. */
+ srl $t1, $t0, GRUB_CPU_LOONGSON_COP0_CACHE_DSIZE_SHIFT
+ andi $t1, $t1, GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_MASK
+ ori $t2, $zero, (1 << (GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET \
+ - GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
+ - GRUB_CPU_LOONGSON_D_CACHE_LOG_WAYS))
+ sll $t1, $t2, $t1
+ lui $t2, 0x8000
+ mtc0 $zero, GRUB_CPU_LOONGSON_COP0_CACHE_TAGLO
+ mtc0 $zero, GRUB_CPU_LOONGSON_COP0_CACHE_TAGHI
+1:
+ /* All four ways. */
+ cache GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 0($t2)
+ cache GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 1($t2)
+ cache GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 2($t2)
+ cache GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE, 3($t2)
+ addiu $t1, $t1, -1
+ bne $t1, $zero, 1b
+ addiu $t2, $t2, (1 << GRUB_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET)
+
+ /* Invalidate all S-cache entries. */
+ ori $t1, $zero, (1 << (GRUB_CPU_LOONGSON_SECONDARY_CACHE_LOG_SIZE \
+ - GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG \
+ - GRUB_CPU_LOONGSON_S_CACHE_LOG_WAYS))
+ lui $t2, 0x8000
+ mtc0 $zero, GRUB_CPU_LOONGSON_COP0_CACHE_TAGLO
+ mtc0 $zero, GRUB_CPU_LOONGSON_COP0_CACHE_TAGHI
+1:
+ /* All four ways. */
+ cache GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 0($t2)
+ cache GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 1($t2)
+ cache GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 2($t2)
+ cache GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE, 3($t2)
+ addiu $t1, $t1, -1
+ bne $t1, $zero, 1b
+ addiu $t2, $t2, (1 << GRUB_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET)
+
+ /* Finally enable cache. */
+ mfc0 $t0, GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG
+ addiu $t1, $zero, ~GRUB_CPU_LOONGSON_CACHE_TYPE_MASK
+ and $t0, $t1, $t1
+ ori $t0, $t0, GRUB_CPU_LOONGSON_CACHE_CACHED
+ mtc0 $t0, GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG
+
+ lui $a0, %hi(caches_enabled)
+ bal message
+ addiu $a0, $a0, %lo(caches_enabled)
+
+ /* Set ROM delay cycles to 1. */
+ lui $t0, %hi(GRUB_CPU_LOONGSON_LIOCFG)
+ lw $t1, %lo(GRUB_CPU_LOONGSON_LIOCFG) ($t0)
+ addiu $t2, $zero, ~(GRUB_CPU_LOONGSON_ROM_DELAY_MASK \
+ << GRUB_CPU_LOONGSON_ROM_DELAY_OFFSET)
+ and $t1, $t1, $t2
+ ori $t1, $t1, (1 << GRUB_CPU_LOONGSON_ROM_DELAY_OFFSET)
+ sw $t1, %lo(GRUB_CPU_LOONGSON_LIOCFG) ($t0)
+
+ addiu $a0, $zero, -1
+ addiu $a1, $zero, -1
+
+ /* Take advantage of cache. */
+ lui $t0, %hi(cached_continue - 0x20000000)
+ addiu $t0, $t0, %lo(cached_continue - 0x20000000)
+ jr $t0
+#ifdef FULOONG2F
+ addiu $a2, $zero, -(1 + GRUB_ARCH_MACHINE_FULOONG2F)
+#else
+ addiu $a2, $zero, -(1 + GRUB_ARCH_MACHINE_YEELOONG)
+#endif
+
+cached_continue:
diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S
new file mode 100644
index 0000000..6a81b37
--- /dev/null
+++ b/grub-core/boot/mips/startup_raw.S
@@ -0,0 +1,300 @@
+/* startup.S - Startup code for the MIPS. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/offsets.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/kernel.h>
+#include <grub/offsets.h>
+#include <grub/mips/asm.h>
+
+#define BASE_ADDR 8
+
+.extern __bss_start
+.extern _end
+.extern _edata
+
+ .globl __start, _start, start
+ .set noreorder
+ .set nomacro
+__start:
+_start:
+start:
+
+ bal codestart
+ nop
+base:
+ .org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
+compressed_size:
+ .long 0
+ .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
+uncompressed_size:
+ .long 0
+ .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR
+uncompressed_addr:
+ .long 0
+codestart:
+ /* Save our base. */
+ move $s0, $ra
+
+ /* Parse arguments. Has to be done before relocation.
+ So need to do it in asm. */
+#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
+ lui $t0, %hi (((16 << 20) - 264 + 4) | 0x80000000)
+ lw $t1, %lo (((16 << 20) - 264 + 4) | 0x80000000) ($t0)
+
+ lui $t2, 0x1234
+ ori $t2, 0x5678
+
+ bne $t1, $t2, 1f
+ nop
+
+ lui $t0, %hi (((16 << 20) - 264) | 0x80000000)
+ b 2f
+ lw $s4, %lo (((16 << 20) - 264) | 0x80000000) ($t0)
+
+1:
+ li $s4, 0
+2:
+#endif
+
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ move $s2, $zero
+ move $s3, $zero
+ move $s4, $zero
+ move $s5, $zero
+ move $s7, $zero
+
+ /* $a2 has the environment. */
+ addiu $t0, $zero, -0x10
+ and $t1, $a2, $t0
+ beq $t0, $t1, argfw
+ nop
+ move $t0, $a2
+argcont:
+ lw $t1, 0($t0)
+ beq $t1, $zero, argdone
+ nop
+#define DO_PARSE(str, reg) \
+ addiu $t2, $s0, (str-base);\
+ bal parsestr;\
+ nop ;\
+ beq $v0, $zero, 1f;\
+ nop ;\
+ b 2f;\
+ move reg, $v0; \
+1:
+#define DO_CHECKT1(str, val) \
+ move $t6, $t1 ;\
+ addiu $t7, $s0, (str - base);\
+ bal do_check ;\
+ li $t2, val
+
+ DO_PARSE (busclockstr, $s2)
+ DO_PARSE (cpuclockstr, $s3)
+ DO_PARSE (memsizestr, $s4)
+ DO_PARSE (highmemsizestr, $s5)
+ DO_CHECKT1 (pmon_yeeloong_verstr, GRUB_ARCH_MACHINE_YEELOONG)
+ DO_CHECKT1 (pmon_fuloong2f_verstr, GRUB_ARCH_MACHINE_FULOONG2F)
+2:
+ b argcont
+ addiu $t0, $t0, 4
+parsestr:
+ move $v0, $zero
+ move $t3, $t1
+3:
+ lb GRUB_ASM_T4, 0($t2)
+ lb GRUB_ASM_T5, 0($t3)
+ addiu $t2, $t2, 1
+ addiu $t3, $t3, 1
+ beq GRUB_ASM_T5, $zero, 1f
+ nop
+ beq GRUB_ASM_T5, GRUB_ASM_T4, 3b
+ nop
+ bne GRUB_ASM_T4, $zero, 1f
+ nop
+
+ addiu $t3, $t3, 0xffff
+digcont:
+ lb GRUB_ASM_T5, 0($t3)
+ /* Substract '0' from digit. */
+ addiu GRUB_ASM_T5, GRUB_ASM_T5, 0xffd0
+ bltz GRUB_ASM_T5, 1f
+ nop
+ 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 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: .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:
+ beq $a0, $zero, cmdlinedone
+ nop
+#define DO_CHECKA1(str, val) \
+ lw $t6, 0($a1) ;\
+ addiu $t7, $s0, (str - base);\
+ bal do_check ;\
+ li $t2, val
+ DO_CHECKA1 (machtype_yeeloong_str1, GRUB_ARCH_MACHINE_YEELOONG)
+ DO_CHECKA1 (machtype_yeeloong_str2, GRUB_ARCH_MACHINE_YEELOONG)
+ DO_CHECKA1 (pmon_yeeloong_str, GRUB_ARCH_MACHINE_YEELOONG)
+ DO_CHECKA1 (machtype_fuloong2f_str, GRUB_ARCH_MACHINE_FULOONG2F)
+ DO_CHECKA1 (machtype_fuloong2e_str, GRUB_ARCH_MACHINE_FULOONG2E)
+ DO_CHECKA1 (pmon_fuloong2f_str, GRUB_ARCH_MACHINE_FULOONG2F)
+ addiu $a0, $a0, -1
+ b argdone
+ addiu $a1, $a1, 4
+do_check:
+ lb GRUB_ASM_T4, 0($t7)
+ beq GRUB_ASM_T4, $zero, 1f
+ lb $t3, 0($t6)
+ bne $t3, GRUB_ASM_T4, 2f
+ addiu $t6, $t6, 1
+ b do_check
+ addiu $t7, $t7, 1
+1:
+ move $s7, $t2
+2:
+ jr $ra
+ nop
+argfw:
+ not $s7, $a2
+cmdlinedone:
+#endif
+#ifdef GRUB_MACHINE_ARC
+ lui $t0, %hi(_start - 256)
+ addiu $t0, $t0, %lo(_start - 256)
+ addiu $t3, $t0, 255
+ lw $t1, 0($a1)
+1:
+ bne $t0, $t3, 2f
+ lb $t2, 0($t1)
+ move $t2, $zero
+2:
+ sb $t2, 0($t0)
+ addiu $t0, $t0, 1
+ bnez $t2, 1b
+ addiu $t1, $t1, 1
+#endif
+ /* Copy the decompressor. */
+ lui $t1, %hi(base)
+ addiu $t1, $t1, %lo(base)
+ lui $t3, %hi(__bss_start)
+ addiu $t3, $t3, %lo(__bss_start)
+ move $t2, $s0
+
+1:
+ beq $t1, $t3, 2f
+ lb GRUB_ASM_T4, 0($t2)
+ sb GRUB_ASM_T4, 0($t1)
+ addiu $t1, $t1, 1
+ b 1b
+ addiu $t2, $t2, 1
+2:
+ /* Clean out its BSS. */
+ lui $t1, %hi(__bss_start)
+ addiu $t1, $t1, %lo(__bss_start)
+ lui $t2, %hi(_end)
+ addiu $t2, $t2, %lo(_end)
+1:
+ beq $t1, $t2, 2f
+ nop
+ sb $zero, 0($t1)
+ b 1b
+ addiu $t1, $t1, 1
+2:
+ lui $a0, %hi(base)
+ addiu $a0, $a0, %lo(base)
+ lui $a1, %hi(_end)
+ addiu $a1, %lo(_end)
+ subu $a1,$a1,$a0
+
+#include "../../kern/mips/cache_flush.S"
+
+ /* Decompress the payload. */
+ lui $a0, %hi(_edata)
+ addiu $a0, $a0, %lo(_edata)
+
+ lui $t0, %hi(base)
+ addiu $t0, $t0, %lo(base)
+ subu $a0, $a0, $t0
+ addu $a0, $a0, $s0
+
+ lw $a1, (GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR - BASE_ADDR)($s0)
+ lw $a2, (GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE - BASE_ADDR)($s0)
+ lw $a3, (GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE - BASE_ADDR)($s0)
+ move $s1, $a1
+
+ /* $a0 contains source compressed address, $a1 is destination,
+ $a2 is compressed size, $a3 is uncompressed size.
+ */
+ move $s6, $a3
+
+ lui $t9, %hi(EXT_C(grub_decompress_core))
+ addiu $t9, $t9, %lo(EXT_C(grub_decompress_core))
+
+#ifdef GRUB_MACHINE_ARC
+ lui $sp, %hi(_start - 512)
+ jalr $t9
+ addiu $sp, $sp, %lo(_start - 512)
+#else
+ lui $sp, %hi(_start - 256)
+ jalr $t9
+ addiu $sp, $sp, %lo(_start - 256)
+#endif
+ move $a0, $s1
+ move $a1, $s6
+
+#include "../../kern/mips/cache_flush.S"
+
+ lui $t1, %hi(GRUB_MACHINE_LINK_ADDR)
+ addiu $t1, %lo(GRUB_MACHINE_LINK_ADDR)
+
+ jr $t1
+ nop
+ /* Ensure that .data section is created. In code we suppose that _edata
+ is first location not in decompressor image. Strictly speaking it's
+ _edata only when .data is present and _etext otherwise. But checking
+ for .data presence would cost more in code than it is to ensure that
+ .data is created.
+ */
+ .data
+ .long 0
diff --git a/grub-core/boot/powerpc/bootinfo.txt.in b/grub-core/boot/powerpc/bootinfo.txt.in
new file mode 100644
index 0000000..bc831da
--- /dev/null
+++ b/grub-core/boot/powerpc/bootinfo.txt.in
@@ -0,0 +1,73 @@
+<chrp-boot>
+<description>@PACKAGE@ @VERSION@</description>
+<os-name>@PACKAGE@ @VERSION@</os-name>
+<boot-script>boot &device;:\boot\grub\powerpc.elf</boot-script>
+<icon size=64,64 color-space=3,3,2>
+<bitmap>
+FF FF FF FF FF FF FF FF FF FF 92 6D 6D 6D 6D 6D 6D 6D 6D 6D DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 92 6D 92 92 92 DB FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF DB 6D 92 DB FF FF FF FF FF DB B6 FF FF 92 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 92 DB FF FF FF FF FF B6 6D 92 DB FF FF FF FF FF FF FF
+FF FF FF FF FF FF 49 92 FF FF B6 B6 24 00 24 00 00 00 00 49 6D DB 6D 92 DB B6 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 6D DB 92 6D 24 49 92 6D 6D FF FF FF 92 6D FF FF FF FF FF FF
+FF FF FF FF B6 49 DB FF FF 24 00 00 00 92 92 B6 FF DB DB FF DB B6 FF DB 92 49 DB FF FF FF FF FF FF FF FF FF FF FF FF FF DB 49 6D B6 FF 6D B6 6D 6D 92 24 24 00 00 24 6D FF FF 49 DB FF FF FF FF
+FF FF FF B6 49 FF DB 49 24 00 49 6D B6 FF B6 92 6D 6D 6D 92 DB DB DB B6 6D 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D DB FF FF FF FF DB B6 B6 B6 FF DB 24 00 00 92 B6 FF 49 FF FF FF FF
+FF FF DB 49 FF FF 49 00 00 24 FF FF 6D 49 92 DB FF FF FF DB 92 92 92 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 92 92 6D 6D B6 DB DB B6 6D 6D FF FF 24 00 00 DB FF 49 FF FF FF
+FF FF 49 FF FF 49 00 00 6D DB DB 49 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 B6 B6 24 00 24 DB DB 6D FF FF
+FF B6 92 FF B6 00 00 24 FF DB 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 B6 FF 00 00 49 FF 92 B6 FF
+FF 6D FF FF 92 00 00 49 FF 6D FF FF FF FF FF FF FF FF FF FF FF FF FF B6 92 92 6D 6D 6D 6D DB FF FF FF FF FF FF B6 92 92 92 92 92 FF FF FF FF FF FF FF FF FF FF FF FF 6D FF 24 00 24 FF FF 6D FF
+DB 92 FF DB 00 00 49 FF 92 DB FF FF FF FF FF FF FF FF FF FF FF DB 6D B6 FF FF FF FF FF FF 92 6D FF FF FF FF 6D B6 FF FF FF FF FF B6 B6 FF FF FF FF FF FF FF FF FF FF FF 92 DB 00 00 92 FF 92 DB
+92 FF FF B6 00 00 6D FF 6D FF FF FF FF FF FF FF FF FF FF FF DB 6D FF FF FF 92 49 49 49 92 FF FF 49 DB DB 24 DB FF B6 49 49 92 FF FF DB 92 FF FF FF FF FF FF FF FF FF FF 92 FF 00 00 6D FF DB 92
+6D FF FF FF 00 00 49 92 DB FF FF FF FF FF FF FF FF FF FF DB 6D FF FF 6D 00 00 00 00 00 00 00 B6 FF 49 00 24 24 49 24 00 00 00 00 6D FF DB 92 FF FF FF FF FF FF FF FF FF DB B6 00 00 92 FF FF 6D
+6D FF FF 24 00 00 DB 6D FF FF FF FF FF FF FF FF FF FF DB 6D FF DB 00 00 00 00 00 00 00 00 00 00 B6 FF DB B6 49 92 24 24 00 00 00 00 24 FF DB 92 FF FF FF FF FF FF FF FF FF 92 6D 00 00 DB FF 6D
+6D FF FF 24 00 00 FF 6D FF FF FF FF FF FF FF FF FF FF 49 FF B6 00 00 00 00 00 00 00 00 00 00 00 00 92 FF FF 92 DB DB 24 24 00 00 00 00 24 FF 92 DB FF FF FF FF FF FF FF FF 92 92 00 00 FF FF 6D
+6D FF FF B6 00 00 92 6D FF FF FF FF FF FF FF FF FF 49 FF DB 00 00 00 00 00 00 00 00 00 00 00 00 00 92 FF FF B6 B6 FF 92 24 00 00 00 00 00 49 FF 6D FF FF FF FF FF FF FF FF 92 24 00 49 FF FF 6D
+6D FF FF 00 00 00 DB 6D FF FF FF FF FF FF FF FF 6D DB DB 00 00 00 00 00 00 00 00 00 00 00 00 00 00 92 FF FF DB B6 FF B6 49 00 00 00 00 00 00 6D FF 6D FF FF FF FF FF FF FF 92 92 00 00 DB FF 6D
+6D FF FF DB 00 00 B6 6D FF FF FF FF FF FF FF 6D B6 FF 24 00 00 00 00 00 00 00 00 00 00 00 24 B6 DB 6D FF FF FF FF FF 6D 49 24 00 00 00 00 00 00 B6 DB B6 FF FF FF FF FF B6 DB 24 00 92 FF FF 6D
+6D FF FF 6D 00 00 24 DB 92 FF FF FF FF FF 92 92 FF 49 00 00 00 00 00 49 B6 FF FF DB B6 DB FF FF FF B6 92 FF FF DB 92 FF FF FF 49 6D 92 24 00 00 00 DB B6 DB FF FF FF FF 6D FF 00 00 00 DB FF 6D
+6D FF FF 92 24 00 49 FF 6D B6 FF FF FF 6D 92 FF 49 00 00 49 DB FF FF FF FF FF FF B6 FF FF FF FF FF FF B6 6D 92 92 FF FF FF FF 6D FF FF FF DB 24 00 24 FF 92 B6 FF FF 92 B6 FF 00 00 B6 FF FF 6D
+92 FF FF FF 00 00 24 92 FF 92 6D 92 49 B6 DB 24 00 24 DB FF FF FF FF FF DB 92 24 00 FF FF FF FF 6D 6D FF FF FF 6D 6D FF FF B6 DB 6D FF FF FF FF 00 00 24 DB B6 6D 6D B6 DB 00 00 00 6D FF FF 6D
+DB 92 FF DB 49 00 00 00 B6 FF FF DB FF 6D 00 00 6D FF FF FF FF FF FF FF 24 92 00 49 FF FF FF FF FF 6D B6 FF FF 6D 6D FF 6D 00 DB DB 92 FF FF FF DB 00 00 00 6D FF FF DB 6D 00 00 24 FF FF 92 DB
+FF 49 FF FF 6D 00 00 00 24 49 B6 FF 24 00 00 6D FF FF FF FF FF FF FF 49 92 B6 00 DB FF FF DB DB FF FF B6 FF FF FF FF FF 00 49 DB FF 92 FF FF FF FF 92 00 00 00 24 6D 00 00 00 00 24 DB FF 49 FF
+FF 92 B6 FF 92 49 00 00 00 00 00 24 00 00 00 FF FF FF FF FF FF FF 92 6D FF B6 DB FF DB B6 DB B6 B6 FF FF B6 FF FF FF DB 00 B6 DB FF 92 FF FF FF FF FF 24 00 00 00 00 00 00 00 00 B6 FF 92 B6 FF
+FF FF 49 FF FF 49 24 00 00 00 00 00 00 00 B6 FF FF FF FF FF FF FF B6 FF FF FF FF FF FF FF FF FF 6D FF FF 6D FF FF FF DB 24 FF FF FF 92 FF FF FF FF FF 6D 00 00 00 00 00 00 00 DB FF FF 6D FF FF
+FF FF DB 6D FF FF 6D 49 00 00 00 00 00 24 FF FF FF FF FF FF FF FF FF FF FF FF FF DB 6D 49 24 24 24 FF FF DB FF FF FF FF 24 24 00 00 92 FF FF FF FF FF DB 00 00 00 00 00 00 FF DB FF 6D FF FF FF
+FF FF FF 92 B6 FF FF DB 49 24 00 00 00 92 FF FF FF FF FF FF FF FF FF DB FF FF FF 49 49 24 00 24 FF FF FF FF FF FF FF FF 49 6D 00 24 49 FF FF FF FF FF FF 49 00 24 6D 6D B6 FF FF 6D B6 FF FF FF
+FF FF FF FF 6D B6 FF FF DB 92 B6 49 00 FF FF FF FF FF FF FF FF FF FF B6 FF FF FF 92 DB 92 00 24 FF FF FF FF FF FF FF FF FF 00 00 6D FF FF FF FF FF FF FF DB 00 6D DB FF FF FF 6D B6 FF FF FF FF
+FF FF FF FF FF 92 6D FF FF FF FF B6 49 FF FF FF FF FF FF FF FF FF FF 6D FF FF FF FF B6 92 92 B6 B6 DB FF FF FF FF FF FF FF B6 6D 49 6D FF FF FF FF FF FF FF 92 24 FF FF B6 6D DB FF FF FF FF FF
+FF FF FF FF FF FF DB 49 6D B6 FF 6D 92 FF FF FF FF FF FF FF FF FF DB 6D FF FF FF FF FF FF FF FF FF 92 FF FF FF FF FF FF FF FF 6D DB 92 FF FF FF FF FF FF FF FF 6D 49 6D DB FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF DB 92 49 00 FF FF FF FF FF FF FF FF FF FF 6D 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 92 6D FF FF FF FF FF FF FF DB 92 FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF 49 FF FF FF FF FF FF FF FF FF DB 00 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 B6 92 6D B6 FF FF FF FF FF FF 49 DB FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF 24 FF FF FF FF FF FF FF FF FF 49 DB 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 6D FF 92 49 92 FF FF FF FF DB 49 DB FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF B6 49 FF FF FF FF FF FF FF FF 6D 92 FF 92 FF FF FF FF FF FF FF FF FF FF B6 6D 49 6D DB FF FF FF FF FF 6D 49 FF FF FF DB 6D 6D 92 92 6D 49 FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF 24 FF FF FF FF FF FF FF FF 6D 92 FF FF FF DB FF FF FF FF FF FF FF FF 6D 6D FF FF FF 92 6D FF FF FF FF FF 49 92 B6 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF DB 6D FF FF FF FF FF FF DB 24 92 FF FF FF FF FF FF FF FF FF FF FF FF FF 49 49 6D DB FF FF DB 6D B6 FF FF FF FF B6 B6 DB 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF 24 B6 FF FF FF FF B6 49 49 24 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF 00 49 FF DB DB FF FF FF B6 92 FF FF FF FF FF FF 92 DB FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF 24 B6 FF FF B6 24 00 6D DB FF 6D 92 FF FF FF FF FF FF FF FF FF FF FF FF FF 6D DB DB 00 00 24 FF FF FF FF B6 FF FF FF FF FF B6 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF B6 B6 DB B6 6D 49 49 92 FF FF FF B6 6D FF FF FF FF FF FF FF 92 92 FF FF FF FF FF FF FF 49 92 DB 49 FF FF FF FF FF FF FF FF FF 92 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF 92 24 49 49 6D FF 6D 92 FF FF FF B6 6D FF FF FF FF FF FF FF FF FF FF DB FF FF FF FF FF FF FF FF B6 FF FF FF FF FF FF FF FF FF 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 92 FF FF FF B6 6D FF FF FF FF FF FF FF FF FF FF B6 DB DB FF FF FF FF FF FF FF DB FF FF FF FF FF FF FF 6D 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 92 FF FF FF FF 24 92 FF FF FF FF FF FF FF FF FF FF 6D B6 FF FF FF FF FF FF FF FF FF FF FF FF FF DB 49 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF 6D B6 FF FF FF FF B6 6D FF FF FF FF FF FF FF FF FF FF B6 92 FF FF FF FF FF FF FF FF FF FF FF DB 6D 00 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 92 FF FF FF FF DB 49 FF FF FF FF FF FF FF FF FF FF FF 49 FF FF FF FF FF FF FF FF FF FF FF FF FF DB 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF 92 6D FF FF FF FF FF 00 24 DB FF FF FF FF FF FF FF FF FF DB 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF B6 49 FF FF FF FF FF FF 92 6D FF FF FF FF FF FF FF FF FF FF 6D B6 FF FF FF FF FF FF FF FF FF FF FF FF B6 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 FF FF FF FF FF FF FF 49 00 DB FF FF FF FF FF FF FF FF FF 6D 6D B6 DB DB DB 92 49 00 00 00 00 00 49 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF 49 DB FF FF FF FF FF FF FF 24 FF FF FF FF FF FF FF FF FF FF FF DB 6D 49 49 6D B6 DB FF FF FF B6 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 92 FF FF FF FF FF FF B6 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 24 FF FF FF FF FF FF DB 00 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DB 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 B6 FF FF FF FF FF FF DB 6D 00 49 FF FF FF FF FF FF FF FF FF FF FF FF DB B6 92 6D 6D 6D 49 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 49 FF FF FF FF FF FF FF FF 49 00 92 FF FF FF FF FF FF FF FF 49 00 00 00 00 00 49 B6 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DB 6D FF FF FF FF FF FF FF FF 6D 6D FF B6 B6 FF FF FF FF FF FF 92 92 FF FF 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 B6 FF FF FF FF FF FF DB 00 DB 6D 00 B6 FF FF FF FF FF FF FF FF FF FF 24 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 DB FF FF FF FF FF 92 00 FF 24 00 00 49 FF FF FF FF FF FF FF FF FF B6 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 FF FF FF FF FF FF 49 24 24 00 00 6D FF FF FF FF FF FF FF DB FF DB 6D FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 FF FF FF FF FF FF 6D 00 24 24 24 FF FF FF FF FF FF DB B6 DB 49 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 00 B6 00 49 DB FF FF FF DB 24 6D 24 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 B6 6D 00 00 DB FF 6D 00 00 00 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DB 00 6D FF FF 00 00 DB 49 00 00 00 00 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 92 DB FF FF 6D 00 00 92 24 00 00 00 00 00 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 FF FF 00 6D 00 00 24 00 00 00 00 00 00 24 92 DB FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D DB 00 00 00 00 00 00 00 00 00 00 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DB 00 24 00 00 6D 00 00 00 B6 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DB 49 92 6D 6D DB B6 92 92 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
+</bitmap>
+</icon>
+</chrp-boot>
diff --git a/grub-core/boot/powerpc/grub.chrp.in b/grub-core/boot/powerpc/grub.chrp.in
new file mode 100644
index 0000000..9b22183
--- /dev/null
+++ b/grub-core/boot/powerpc/grub.chrp.in
@@ -0,0 +1,172 @@
+<CHRP-BOOT>
+<COMPATIBLE>
+MacRISC MacRISC3 MacRISC4
+</COMPATIBLE>
+<DESCRIPTION>
+@PACKAGE@ @VERSION@
+</DESCRIPTION>
+<OS-BADGE-ICONS>
+3434
+00000000000000F781FB8181818181FBFAF500000000000000000000000000000000000000F6FAFAFAFA81F9F600000000000000
+0000000000F8FBF9F500F95656FCFB5656FBF800000000000000000000000000000000F5FAF9F5F7F600F6F6F9FAF70000000000
+000000F5FBFA0056FDFEFEFDFDFAAC81FB56568181560000000000000000000000F9F9F9F7FCFDFEFEFEFFFC81F656FA00000000
+0000F5AC2BF7FBFEFEFD2BF6568181F9F7F6F6F8FBF50000000000000000000000FAF700F600F5F7F7F6F7FEFFACF82BFB000000
+0000FC2BF5FEFFFFF5F7FC81F70000F7F9FAFAF8000000000000000000000000000056F9F9FAF9F7F7FA812BF7FFFF56F7FA0000
+005656F5FEFFAC2BF9FA000000000000000000000000000000000000000000000000000000000000000000FA56FAFEFEF8F9F700
+00FB00F7FFFF56F9F800000000000000000000F656FAFA56F50000000000F5F8F9F8F5000000000000000000F9F7FCFFFB00FB00
+F8F800ACFFACF6FA000000000000000000F6FA562BF5F5F781FA000000F9FA2B00F556F9F5000000000000000081F8FFFEF6562B
+810000FFFFF9FAF500000000000000002B8100F5F9FCACFBF82BFBF6FCFAF6FAFC81F600FA2B000000000000002BF8FEFFF8F5FA
+FA00F5FEFFFA8100000000000000002B8100F9FEFFFFFFFFFFFBF6FDFEACFDFEFFFFFFFBF581F600000000000000F9FEFFF700FA
+FA00FBFFFEF6F900000000000000F6FB00FCFFFFFFFFFFFFFFFFFCF600FCF7ACFEFFFFFFFDF6810000000000000056F9FFAC00FA
+FA00F6FFFFF856000000000000F5FBF5ACFFFFFFFFFFFFFFFFFFFF2B002BF8F5ACFFFFFFFFFDF6FA000000000000F9FCFF560081
+FA0081FFFFF8F9000000000000FBF6FBFFFFFFFFFFFFFFFFFFFFFFF800F55600FCFFFFFFFFFF81F8F80000000000F981FFAC0081
+FA0000FEFEF8FB0000000000812BFAFFFFFFFFFFFFFEFFFFFDF92BFA0000F6F981ACFEFFFFFFFF56F9F600000000F9FDFF2B0081
+FA00FAFFFF81812B000000FAF8F9FFFFFEACFBF80000F500000000F9F900562B0000FCF7F9ACFFFF2BF9F50000F9F6FEFFFB0081
+810000FCFFFBF6FB56F7FBF8F9FFFE5600000000F5FAAC000000F82BF6FAFBF800F556F80000F9FFFE2BFAFAFAF8FAFFFEF60081
+FAF6F5ACFFFFAC00F856F7ACFFFCF500000000FAFCFFFC00000056AC00F581F92BFEF9FAF6000081FFFFFBF6F62BFFFFACF6F6FA
+F6FA00FAFFFFFFACFA56FFFFAC0000000000F6FD2BFEF6F5565600F5F800F60081FEF7F656000000FDFFFFFDFDFFFFFFAC0081F5
+0081F52BFDFFFFFFFFFFFFFFF60000000000FBF6F6F5F656F52BF900FA000000FCFAF5F656000000F7FFFFFFFFFFFFFDF7F68100
+00F6FB00F8FDFFFFFFFFFF810000000000F6F5000000F52B56F9FC00F7F70000FCF881FCF500000000FEFFFFFFFFAC5600FBF500
+000056F900F8ACFDFFFFFFF5000000000000002B0000FDFEFFFE560000F60000F9ACFFFE810000000081FFFEFDFAF800FAF70000
+000000FAF9002B56FAFDFC0000000000000000F80000FBF5FEFEF5000000000000ACFFFA2B0000000000FEFB2BF5008156000000
+00000000F9FBF600F6FBF800000000000000F7F8000000F9F9F9F82B0000000000F6ACACF70000000000F7FD2BFA812B00000000
+0000000000F681FCFBFD0000000000000000FBF6000000000000F52B000000000000F92B810000000000008181F6000000000000
+0000000000000000F6FC00000000000000F6FF0000000000000000000000000000000081FBFB2B00000000F7F900000000000000
+000000000000000000FC00000000000000FCFAF600000000000000000000000000000056ACF581FBF700000081FB000000000000
+0000000000000000FAF90000000000008156F5F8000000000000002BFBFCFBF800000000FD2B000056FB8181FBF8000000000000
+0000000000000000AC0000000000F5FBF90000F6000000000000F5AC56F6005681F50000F6ACFCFBF70000000000000000000000
+00000000000000F881000000F5FAFDFD00000000000000000000F7FEFA2B0000F581F70000000000810000000000000000000000
+000000000000F9FCF500FAFDACFAF5FD00000000000000000000F5ACF5FDFEFA0000F82B00000000810000000000000000000000
+000000000000FCF8F9AC81FD000000FD000000000000FAF7000000F50081F9FAF800000000000000FB0000000000000000000000
+000000000000FC81F956F5FD000000FD0000000000000000F800F5000000000056000000000000F7FB0000000000000000000000
+00000000000000000000F5AC000000ACF800000000000000F5FAF80000000000F50000000000F8ACF50000000000000000000000
+00000000000000000000F5AC000000F5AC000000000000000056F9000000000000000000F7ACFCF5000000000000000000000000
+00000000000000000000F5FD00000000AC000000000000000000FB0000000000000000F5F6F5FCF6000000000000000000000000
+0000000000000000000000FD00000000FBFDF600000000000000F8F900000000000000000000F5FB000000000000000000000000
+0000000000000000000000FDF500000000F9ACF800000000000000815600000000F656818181AC56000000000000000000000000
+000000000000000000000081F80000000000F9FC0000000000000000F9ACACACFCFBFAFA81FD2B00000000000000000000000000
+0000000000000000000000F7FB0000000000FBF70000000000000000000000000000000000FB0000000000000000000000000000
+000000000000000000000000ACF500000000F9FD56F5000000000000000000000000000000FB0000000000000000000000000000
+000000000000000000000000F8FA0000000000F6FEFEF5000000000000F55681FCACFDACFC560000000000000000000000000000
+00000000000000000000000000FBF600000000002BFCFA00F700000000F9FDFDFAFEF90000000000000000000000000000000000
+00000000000000000000000000F5FB0000000000F5FEF7ACAC0000000000000000FCF50000000000000000000000000000000000
+0000000000000000000000000000F6FA000000002BFF2BFFFFAC00000000000000F7FA0000000000000000000000000000000000
+000000000000000000000000000000F65600000000FAFEFFFFAC0000000000F800F6810000000000000000000000000000000000
+00000000000000000000000000000000F52B00000000F8FEFBFF5600000000FCFAACF60000000000000000000000000000000000
+0000000000000000000000000000000000000000000000F9FCFCFFFB00F8FEFFFDF5000000000000000000000000000000000000
+00000000000000000000000000000000000000000000F9FDF7F5FFFD56FFFFFFFD00000000000000000000000000000000000000
+00000000000000000000000000000000000000000000810000FBFFFFFBFFFFFFFFACF9F5F5000000000000000000000000000000
+0000000000000000000000000000000000000000000000F600FC81FFFEFFFFFFFFFFFE8100000000000000000000000000000000
+00000000000000000000000000000000000000000000000000F7F6FDFFFFFFFEFFFFACF500000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000F5FC81FC81FAFBF9F500000000000000000000000000000000
+
+00000000000000F781FB8181818181FBFAF500000000000000000000000000000000000000F6FAFAFAFA81F9F600000000000000
+0000000000F8FBF9F500F95656FCFB5656FBF800000000000000000000000000000000F5FAF9F5F7F600F6F6F9FAF70000000000
+000000F5FBFA0056FDFEFEFDFDFAAC81FB56568181560000000000000000000000F9F9F9F7FCFDFEFEFEFFFC81F656FA00000000
+0000F5AC2BF7FBFEFEFD2BF6568181F9F7F6F6F8FBF50000000000000000000000FAF700F600F5F7F7F6F7FEFFACF82BFB000000
+0000FC2BF5FEFFFFF5F7FC81F70000F7F9FAFAF8000000000000000000000000000056F9F9FAF9F7F7FA812BF7FFFF56F7FA0000
+005656F5FEFFAC2BF9FA000000000000000000000000000000000000000000000000000000000000000000FA56FAFEFEF8F9F700
+00FB00F7FFFF56F9F800000000000000000000F656FAFA56F50000000000F5F8F9F8F5000000000000000000F9F7FCFFFB00FB00
+F8F800ACFFACF6FA000000000000000000F6FA562BF5F5F781FA000000F9FA2B00F556F9F5000000000000000081F8FFFEF6562B
+810000FFFFF9FAF500000000000000002B8100F5F9FCACFBF82BFBF6FCFAF6FAFC81F600FA2B000000000000002BF8FEFFF8F5FA
+FA00F5FEFFFA8100000000000000002B8100F9FEFFFFFFFFFFFBF6FDFEACFDFEFFFFFFFBF581F600000000000000F9FEFFF700FA
+FA00FBFFFEF6F900000000000000F6FB00FCFFFFFFFFFFFFFFFFFCF600FCF7ACFEFFFFFFFDF6810000000000000056F9FFAC00FA
+FA00F6FFFFF856000000000000F5FBF5ACFFFFFFFFFFFFFFFFFFFF2B002BF8F5ACFFFFFFFFFDF6FA000000000000F9FCFF560081
+FA0081FFFFF8F9000000000000FBF6FBFFFFFFFFFFFFFFFFFFFFFFF800F55600FCFFFFFFFFFF81F8F80000000000F981FFAC0081
+FA0000FEFEF8FB0000000000812BFAFFFFFFFFFFFFFEFFFFFDF92BFA0000F6F981ACFEFFFFFFFF56F9F600000000F9FDFF2B0081
+FA00FAFFFF81812B000000FAF8F9FFFFFEACFBF80000F500000000F9F900562B0000FCF7F9ACFFFF2BF9F50000F9F6FEFFFB0081
+810000FCFFFBF6FB56F7FBF8F9FFFE5600000000F5FAAC000000F82BF6FAFBF800F556F80000F9FFFE2BFAFAFAF8FAFFFEF60081
+FAF6F5ACFFFFAC00F856F7ACFFFCF500000000FAFCFFFC00000056AC00F581F92BFEF9FAF6000081FFFFFBF6F62BFFFFACF6F6FA
+F6FA00FAFFFFFFACFA56FFFFAC0000000000F6FD2BFEF6F5565600F5F800F60081FEF7F656000000FDFFFFFDFDFFFFFFAC0081F5
+0081F52BFDFFFFFFFFFFFFFFF60000000000FBF6F6F5F656F52BF900FA000000FCFAF5F656000000F7FFFFFFFFFFFFFDF7F68100
+00F6FB00F8FDFFFFFFFFFF810000000000F6F5000000F52B56F9FC00F7F70000FCF881FCF500000000FEFFFFFFFFAC5600FBF500
+000056F900F8ACFDFFFFFFF5000000000000002B0000FDFEFFFE560000F60000F9ACFFFE810000000081FFFEFDFAF800FAF70000
+000000FAF9002B56FAFDFC0000000000000000F80000FBF5FEFEF5000000000000ACFFFA2B0000000000FEFB2BF5008156000000
+00000000F9FBF600F6FBF800000000000000F7F8000000F9F9F9F82B0000000000F6ACACF70000000000F7FD2BFA812B00000000
+0000000000F681FCFBFD0000000000000000FBF6000000000000F52B000000000000F92B810000000000008181F6000000000000
+0000000000000000F6FC00000000000000F6FF0000000000000000000000000000000081FBFB2B00000000F7F900000000000000
+000000000000000000FC00000000000000FCFAF600000000000000000000000000000056ACF581FBF700000081FB000000000000
+0000000000000000FAF90000000000008156F5F8000000000000002BFBFCFBF800000000FD2B000056FB8181FBF8000000000000
+0000000000000000AC0000000000F5FBF90000F6000000000000F5AC56F6005681F50000F6ACFCFBF70000000000000000000000
+00000000000000F881000000F5FAFDFD00000000000000000000F7FEFA2B0000F581F70000000000810000000000000000000000
+000000000000F9FCF500FAFDACFAF5FD00000000000000000000F5ACF5FDFEFA0000F82B00000000810000000000000000000000
+000000000000FCF8F9AC81FD000000FD000000000000FAF7000000F50081F9FAF800000000000000FB0000000000000000000000
+000000000000FC81F956F5FD000000FD0000000000000000F800F5000000000056000000000000F7FB0000000000000000000000
+00000000000000000000F5AC000000ACF800000000000000F5FAF80000000000F50000000000F8ACF50000000000000000000000
+00000000000000000000F5AC000000F5AC000000000000000056F9000000000000000000F7ACFCF5000000000000000000000000
+00000000000000000000F5FD00000000AC000000000000000000FB0000000000000000F5F6F5FCF6000000000000000000000000
+0000000000000000000000FD00000000FBFDF600000000000000F8F900000000000000000000F5FB000000000000000000000000
+0000000000000000000000FDF500000000F9ACF800000000000000815600000000F656818181AC56000000000000000000000000
+000000000000000000000081F80000000000F9FC0000000000000000F9ACACACFCFBFAFA81FD2B00000000000000000000000000
+0000000000000000000000F7FB0000000000FBF70000000000000000000000000000000000FB0000000000000000000000000000
+000000000000000000000000ACF500000000F9FD56F5000000000000000000000000000000FB0000000000000000000000000000
+000000000000000000000000F8FA0000000000F6FEFEF5000000000000F55681FCACFDACFC560000000000000000000000000000
+00000000000000000000000000FBF600000000002BFCFA00F700000000F9FDFDFAFEF90000000000000000000000000000000000
+00000000000000000000000000F5FB0000000000F5FEF7ACAC0000000000000000FCF50000000000000000000000000000000000
+0000000000000000000000000000F6FA000000002BFF2BFFFFAC00000000000000F7FA0000000000000000000000000000000000
+000000000000000000000000000000F65600000000FAFEFFFFAC0000000000F800F6810000000000000000000000000000000000
+00000000000000000000000000000000F52B00000000F8FEFBFF5600000000FCFAACF60000000000000000000000000000000000
+0000000000000000000000000000000000000000000000F9FCFCFFFB00F8FEFFFDF5000000000000000000000000000000000000
+00000000000000000000000000000000000000000000F9FDF7F5FFFD56FFFFFFFD00000000000000000000000000000000000000
+00000000000000000000000000000000000000000000810000FBFFFFFBFFFFFFFFACF9F5F5000000000000000000000000000000
+0000000000000000000000000000000000000000000000F600FC81FFFEFFFFFFFFFFFE8100000000000000000000000000000000
+00000000000000000000000000000000000000000000000000F7F6FDFFFFFFFEFFFFACF500000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000F5FC81FC81FAFBF9F500000000000000000000000000000000
+
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+</OS-BADGE-ICONS>
+<BOOT-SCRIPT>
+boot &device;:&partition;,\System\Library\CoreServices\grub.elf
+</BOOT-SCRIPT>
+</CHRP-BOOT>
diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S
new file mode 100644
index 0000000..ff8a79d
--- /dev/null
+++ b/grub-core/boot/sparc64/ieee1275/boot.S
@@ -0,0 +1,262 @@
+/* -*-Asm-*- */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/boot.h>
+
+ .text
+ .align 4
+ /*
+ * We're writing the a.out header ourselves as newer
+ * upstream versions of binutils no longer support
+ * the a.out format on sparc64.
+ *
+ * The boot loader fits into 512 bytes with 32 bytes
+ * used for the a.out header, hence the text segment
+ * size is 512 - 32. There is no data segment and no
+ * code relocation, thus those fields remain zero.
+ */
+ .word 0x1030107 /* Magic number. */
+ .word 512 - GRUB_BOOT_AOUT_HEADER_SIZE /* Size of text segment. */
+ .word 0 /* Size of initialized data. */
+ .word 0 /* Size of uninitialized data. */
+ .word 0 /* Size of symbol table || checksum. */
+ .word _start /* Entry point. */
+ .word 0 /* Size of text relocation. */
+ .word 0 /* Size of data relocation. */
+ .globl _start
+_start:
+ /* OF CIF entry point arrives in %o4 */
+pic_base:
+ call boot_continue
+ mov %o4, CIF_REG
+
+#ifndef CDBOOT
+ /* The offsets to these locations are defined by the
+ * GRUB_BOOT_MACHINE_foo macros in include/grub/sparc64/ieee1275/boot.h,
+ * and grub-setup uses this to patch these next three values as needed.
+ *
+ * The boot_path will be the OF device path of the partition where the
+ * rest of the GRUB kernel image resides. kernel_sector will be set to
+ * the location of the first block of the GRUB kernel, and
+ * kernel_address is the location where we should load that first block.
+ *
+ * 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).
+ *
+ * Since this assembly code includes the 32 bytes long a.out header,
+ * we need to move the actual code entry point forward by the size
+ * of the a.out header, i.e. += GRUB_BOOT_AOUT_HEADER_SIZE.
+ */
+ .org GRUB_BOOT_MACHINE_BOOT_DEVPATH + GRUB_BOOT_AOUT_HEADER_SIZE
+boot_path:
+ .org GRUB_BOOT_MACHINE_KERNEL_BYTE + GRUB_BOOT_AOUT_HEADER_SIZE
+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>
+
+ .org 8 + GRUB_BOOT_AOUT_HEADER_SIZE
+kernel_byte: .xword (2 << 9)
+kernel_size: .word 512
+kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS
+#endif
+
+prom_finddev_name: .asciz "finddevice"
+prom_chosen_path: .asciz "/chosen"
+prom_getprop_name: .asciz "getprop"
+prom_stdout_name: .asciz "stdout"
+prom_write_name: .asciz "write"
+prom_bootpath_name: .asciz "bootpath"
+prom_open_name: .asciz "open"
+prom_seek_name: .asciz "seek"
+prom_read_name: .asciz "read"
+prom_exit_name: .asciz "exit"
+grub_name: .asciz "GRUB "
+#ifdef CDBOOT
+prom_close_name: .asciz "close"
+#endif
+
+#define GRUB_NAME_LEN 5
+
+ .align 4
+
+prom_open_error:
+ GET_ABS(prom_open_name, %o2)
+ call console_write
+ mov 4, %o3
+ /* fallthru */
+
+prom_error:
+ GET_ABS(prom_exit_name, %o0)
+ /* fallthru */
+
+ /* %o0: OF call name
+ * %o1: input arg 1
+ */
+prom_call_1_1_o2:
+ clr %o2
+ ba prom_call_x_1
+ mov 1, %g1
+
+prom_call_getprop:
+ mov 4, %g1
+ stx %g1, [%l1 + 256]
+ mov CHOSEN_NODE_REG, %o1
+ ba prom_call_x_1
+ GET_ABS(prom_getprop_name, %o0)
+
+prom_call_3_1_o1:
+ ba prom_call_3_1
+ mov BOOTDEV_REG, %o1
+
+
+ /* %o2: message string
+ * %o3: message length
+ */
+console_write:
+ GET_ABS(prom_write_name, %o0)
+ mov STDOUT_NODE_REG, %o1
+ /* fallthru */
+
+ /* %o0: OF call name
+ * %o1: input arg 1
+ * %o2: input arg 2
+ * %o3: input arg 3
+ */
+prom_call_3_1:
+ mov 3, %g1
+prom_call_x_1:
+ mov 1, %o5
+ /* fallthru */
+
+ /* %o0: OF call name
+ * %g1: num inputs
+ * %o5: num outputs
+ * %o1-%o4: inputs
+ */
+prom_call:
+ stx %o0, [%l1 + 0x00]
+ stx %g1, [%l1 + 0x08]
+ stx %o5, [%l1 + 0x10]
+ stx %o1, [%l1 + 0x18]
+ stx %o2, [%l1 + 0x20]
+ stx %o3, [%l1 + 0x28]
+ stx %o4, [%l1 + 0x30]
+ jmpl CIF_REG, %g0
+ mov %l1, %o0
+
+boot_continue:
+ mov %o7, PIC_REG /* PIC base */
+#ifndef CDBOOT
+ sethi %hi(SCRATCH_PAD_BOOT), %l1 /* OF argument slots */
+#else
+ GET_ABS(_start + 512, %l1) /* OF argument slots */
+#endif
+
+ /* Find the /chosen node so we can fetch the stdout handle,
+ * and thus perform console output.
+ *
+ * chosen_node = prom_finddevice("/chosen")
+ */
+ GET_ABS(prom_finddev_name, %o0)
+ call prom_call_1_1_o2
+ GET_ABS(prom_chosen_path, %o1)
+
+ ldx [%l1 + 0x20], CHOSEN_NODE_REG
+ brz CHOSEN_NODE_REG, prom_error
+
+ /* getprop(chosen_node, "stdout", &buffer, buffer_size) */
+ GET_ABS(prom_stdout_name, %o2)
+ add %l1, 256, %o3
+ call prom_call_getprop
+ mov 1024, %o4
+
+ lduw [%l1 + 256], STDOUT_NODE_REG
+ brz,pn STDOUT_NODE_REG, prom_error
+
+ /* write(stdout_node, "GRUB ", strlen("GRUB ")) */
+ GET_ABS(grub_name, %o2)
+ call console_write
+ mov GRUB_NAME_LEN, %o3
+
+ GET_ABS(boot_path, %o3)
+#ifndef CDBOOT
+ ldub [%o3], %o1
+ brnz,pn %o1, bootpath_known
+#endif
+
+ /* getprop(chosen_node, "bootpath", &buffer, buffer_size) */
+ GET_ABS(prom_bootpath_name, %o2)
+ call prom_call_getprop
+ mov (boot_path_end - boot_path), %o4
+
+bootpath_known:
+
+ /* Open up the boot_path, and use that handle to read the
+ * first block of the GRUB kernel image.
+ *
+ * bootdev_handle = open(boot_path)
+ */
+ GET_ABS(prom_open_name, %o0)
+ call prom_call_1_1_o2
+ GET_ABS(boot_path, %o1)
+
+ ldx [%l1 + 0x20], BOOTDEV_REG
+ brz,pn BOOTDEV_REG, prom_open_error
+
+ /* Since we have 64-bit cells, the high cell of the seek offset
+ * is zero and the low cell is the entire value.
+ *
+ * seek(bootdev, 0, *kernel_byte)
+ */
+ GET_ABS(prom_seek_name, %o0)
+ clr %o2
+ call prom_call_3_1_o1
+ LDX_ABS(kernel_byte, 0x00, %o3)
+
+ /* read(bootdev, *kernel_address, 512) */
+ GET_ABS(prom_read_name, %o0)
+ LDUW_ABS(kernel_address, 0x00, %o2)
+ call prom_call_3_1_o1
+#ifdef CDBOOT
+ LDUW_ABS(kernel_size, 0x00, %o3)
+
+ GET_ABS(prom_close_name, %o0)
+ mov 1, %g1
+ mov 0, %o5
+ call prom_call
+ mov BOOTDEV_REG, %o1
+#else
+ mov 512, %o3
+#endif
+
+ LDUW_ABS(kernel_address, 0x00, %o2)
+ jmpl %o2, %o7
+#ifdef CDBOOT
+ mov CIF_REG, %o4
+#else
+ nop
+#endif
+ .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
new file mode 100644
index 0000000..35e02c1
--- /dev/null
+++ b/grub-core/boot/sparc64/ieee1275/diskboot.S
@@ -0,0 +1,145 @@
+/* -*-Asm-*- */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/boot.h>
+#include <grub/offsets.h>
+
+ .text
+ .align 4
+ .globl _start
+_start:
+ /* First stage boot block jumps to us here. */
+pic_base:
+ call after_info_block
+ mov %o7, PIC_REG
+
+prom_write_name: .asciz "write"
+prom_seek_name: .asciz "seek"
+prom_read_name: .asciz "read"
+prom_close_name: .asciz "close"
+
+notification_string: .asciz "Loading kernel"
+#define NOTIFICATION_STRING_LEN 14
+
+notification_step: .asciz "."
+#define NOTIFICATION_STEP_LEN 1
+
+notification_done: .asciz "\r\n"
+#define NOTIFICATION_DONE_LEN 2
+
+ .align 4
+
+ /* %o2: message string
+ * %o3: message length
+ */
+console_write:
+ GET_ABS(prom_write_name, %o0)
+ mov STDOUT_NODE_REG, %o1
+ /* fallthru */
+
+ /* %o0: OF call name
+ * %o1: input arg 1
+ * %o2: input arg 2
+ * %o3: input arg 3
+ */
+prom_call_3_1:
+ mov 3, %g1
+ mov 1, %o5
+ /* fallthru */
+
+ /* %o0: OF call name
+ * %g1: num inputs
+ * %o5: num outputs
+ * %o1-%o4: inputs
+ */
+prom_call:
+ stx %o0, [%l1 + 0x00]
+ stx %g1, [%l1 + 0x08]
+ stx %o5, [%l1 + 0x10]
+ stx %o1, [%l1 + 0x18]
+ stx %o2, [%l1 + 0x20]
+ stx %o3, [%l1 + 0x28]
+ stx %o4, [%l1 + 0x30]
+ jmpl CIF_REG, %g0
+ mov %l1, %o0
+
+
+after_info_block:
+ sethi %hi(SCRATCH_PAD_DISKBOOT), %l1 /* OF argument slots */
+
+ GET_ABS(notification_string, %o2)
+ call console_write
+ mov NOTIFICATION_STRING_LEN, %o3
+
+ GET_ABS(firstlist - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2)
+ set GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS, %l3
+bootloop:
+ lduw [%l2 + 0x08], %o0
+ brz %o0, bootit
+ lduw [%l2 + 0x00], %o3
+ sllx %o3, 32, %o3
+ lduw [%l2 + 0x04], %o4
+ or %o3, %o4, %o3
+ GET_ABS(prom_seek_name, %o0)
+ mov BOOTDEV_REG, %o1
+ clr %o2
+ call prom_call_3_1
+ sllx %o3, 9, %o3
+
+ GET_ABS(prom_read_name, %o0)
+ mov BOOTDEV_REG, %o1
+ lduw [%l2 + 0x08], %o3
+ sllx %o3, 9, %o3
+ mov %l3, %o2
+ call prom_call_3_1
+ add %l3, %o3, %l3
+
+ GET_ABS(notification_step, %o2)
+ call console_write
+ mov NOTIFICATION_STEP_LEN, %o3
+
+ ba bootloop
+ sub %l2, GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2
+
+bootit:
+ GET_ABS(prom_close_name, %o0)
+ mov 1, %g1
+ mov 0, %o5
+ call prom_call
+ mov BOOTDEV_REG, %o1
+
+ GET_ABS(notification_done, %o2)
+ call console_write
+ mov NOTIFICATION_DONE_LEN, %o3
+ sethi %hi(GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o2
+ jmpl %o2 + %lo(GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o7
+ mov CIF_REG, %o4
+1: ba,a 1b
+
+lastlist:
+ .word 0
+ .word 0
+
+ .org (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE)
+blocklist_default_start:
+ .word 0
+ .word 2
+blocklist_default_len:
+ .word 0
+firstlist:
diff --git a/grub-core/bus/bonito.c b/grub-core/bus/bonito.c
new file mode 100644
index 0000000..9a63f07
--- /dev/null
+++ b/grub-core/bus/bonito.c
@@ -0,0 +1,176 @@
+/* bonito.c - PCI bonito interface. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/pci.h>
+#include <grub/misc.h>
+
+static grub_uint32_t base_win[GRUB_MACHINE_PCI_NUM_WIN];
+static const grub_size_t sizes_win[GRUB_MACHINE_PCI_NUM_WIN] =
+ {GRUB_MACHINE_PCI_WIN1_SIZE, GRUB_MACHINE_PCI_WIN_SIZE,
+ GRUB_MACHINE_PCI_WIN_SIZE};
+/* Usage counters. */
+static int usage_win[GRUB_MACHINE_PCI_NUM_WIN];
+static grub_addr_t addr_win[GRUB_MACHINE_PCI_NUM_WIN] =
+ {GRUB_MACHINE_PCI_WIN1_ADDR, GRUB_MACHINE_PCI_WIN2_ADDR,
+ GRUB_MACHINE_PCI_WIN3_ADDR};
+
+grub_bonito_type_t grub_bonito_type;
+
+static volatile void *
+config_addr (grub_pci_address_t addr)
+{
+ if (grub_bonito_type == GRUB_BONITO_2F)
+ {
+ GRUB_MACHINE_PCI_CONF_CTRL_REG_2F = 1 << ((addr >> 11) & 0xf);
+ return (volatile void *) (GRUB_MACHINE_PCI_CONFSPACE_2F
+ | (addr & 0x07ff));
+ }
+ else
+ {
+
+ if (addr >> 16)
+ return (volatile void *) (GRUB_MACHINE_PCI_CONFSPACE_3A_EXT | addr);
+ else
+ return (volatile void *) (GRUB_MACHINE_PCI_CONFSPACE_3A | addr);
+ }
+}
+
+grub_uint32_t
+grub_pci_read (grub_pci_address_t addr)
+{
+ return *(volatile grub_uint32_t *) config_addr (addr);
+}
+
+grub_uint16_t
+grub_pci_read_word (grub_pci_address_t addr)
+{
+ return *(volatile grub_uint16_t *) config_addr (addr);
+}
+
+grub_uint8_t
+grub_pci_read_byte (grub_pci_address_t addr)
+{
+ return *(volatile grub_uint8_t *) config_addr (addr);
+}
+
+void
+grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
+{
+ *(volatile grub_uint32_t *) config_addr (addr) = data;
+}
+
+void
+grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
+{
+ *(volatile grub_uint16_t *) config_addr (addr) = data;
+}
+
+void
+grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
+{
+ *(volatile grub_uint8_t *) config_addr (addr) = data;
+}
+
+
+static inline void
+write_bases_2f (void)
+{
+ int i;
+ grub_uint32_t reg = 0;
+ for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
+ reg |= (((base_win[i] >> GRUB_MACHINE_PCI_WIN_SHIFT)
+ & GRUB_MACHINE_PCI_WIN_MASK)
+ << (i * GRUB_MACHINE_PCI_WIN_MASK_SIZE));
+ GRUB_MACHINE_PCI_IO_CTRL_REG_2F = reg;
+}
+
+volatile void *
+grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
+ grub_addr_t base, grub_size_t size)
+{
+ if (grub_bonito_type == GRUB_BONITO_2F)
+ {
+ int i;
+ grub_addr_t newbase;
+
+ /* First try already used registers. */
+ for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
+ if (usage_win[i] && base_win[i] <= base
+ && base_win[i] + sizes_win[i] > base + size)
+ {
+ usage_win[i]++;
+ return (void *)
+ (addr_win[i] | (base & GRUB_MACHINE_PCI_WIN_OFFSET_MASK));
+ }
+ /* Map new register. */
+ newbase = base & ~GRUB_MACHINE_PCI_WIN_OFFSET_MASK;
+ for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
+ if (!usage_win[i] && newbase <= base
+ && newbase + sizes_win[i] > base + size)
+ {
+ usage_win[i]++;
+ base_win[i] = newbase;
+ write_bases_2f ();
+ return (void *)
+ (addr_win[i] | (base & GRUB_MACHINE_PCI_WIN_OFFSET_MASK));
+ }
+ grub_fatal ("Out of PCI windows.");
+ }
+ else
+ {
+ int region = 0;
+ if (base >= 0x10000000
+ && base + size <= 0x18000000)
+ region = 1;
+ if (base >= 0x1c000000
+ && base + size <= 0x1f000000)
+ region = 2;
+ if (region == 0)
+ grub_fatal ("Attempt to map out of regions");
+ return (void *) (0xa0000000 | base);
+ }
+}
+
+void *
+grub_pci_device_map_range_cached (grub_pci_device_t dev,
+ grub_addr_t base, grub_size_t size)
+{
+ return (void *) (((grub_addr_t) grub_pci_device_map_range (dev, base, size))
+ & ~0x20000000);
+}
+
+void
+grub_pci_device_unmap_range (grub_pci_device_t dev __attribute__ ((unused)),
+ volatile void *mem,
+ grub_size_t size __attribute__ ((unused)))
+{
+ if (grub_bonito_type == GRUB_BONITO_2F)
+ {
+ int i;
+ for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
+ if (usage_win[i] && addr_win[i]
+ == (((grub_addr_t) mem | 0x20000000)
+ & ~GRUB_MACHINE_PCI_WIN_OFFSET_MASK))
+ {
+ usage_win[i]--;
+ return;
+ }
+ grub_fatal ("Tried to unmap not mapped region");
+ }
+}
diff --git a/grub-core/bus/cs5536.c b/grub-core/bus/cs5536.c
new file mode 100644
index 0000000..bb9aa27
--- /dev/null
+++ b/grub-core/bus/cs5536.c
@@ -0,0 +1,381 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/cs5536.h>
+#include <grub/pci.h>
+#include <grub/time.h>
+#include <grub/ata.h>
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+#include <grub/machine/kernel.h>
+#endif
+
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Context for grub_cs5536_find. */
+struct grub_cs5536_find_ctx
+{
+ grub_pci_device_t *devp;
+ int found;
+};
+
+/* Helper for grub_cs5536_find. */
+static int
+grub_cs5536_find_iter (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
+{
+ struct grub_cs5536_find_ctx *ctx = data;
+
+ if (pciid == GRUB_CS5536_PCIID)
+ {
+ *ctx->devp = dev;
+ ctx->found = 1;
+ return 1;
+ }
+ return 0;
+}
+
+int
+grub_cs5536_find (grub_pci_device_t *devp)
+{
+ struct grub_cs5536_find_ctx ctx = {
+ .devp = devp,
+ .found = 0
+ };
+
+ grub_pci_iterate (grub_cs5536_find_iter, &ctx);
+
+ return ctx.found;
+}
+
+grub_uint64_t
+grub_cs5536_read_msr (grub_pci_device_t dev, grub_uint32_t addr)
+{
+ grub_uint64_t ret = 0;
+ grub_pci_write (grub_pci_make_address (dev, GRUB_CS5536_MSR_MAILBOX_ADDR),
+ addr);
+ ret = (grub_uint64_t)
+ grub_pci_read (grub_pci_make_address (dev, GRUB_CS5536_MSR_MAILBOX_DATA0));
+ ret |= (((grub_uint64_t)
+ grub_pci_read (grub_pci_make_address (dev,
+ GRUB_CS5536_MSR_MAILBOX_DATA1)))
+ << 32);
+ return ret;
+}
+
+void
+grub_cs5536_write_msr (grub_pci_device_t dev, grub_uint32_t addr,
+ grub_uint64_t val)
+{
+ grub_pci_write (grub_pci_make_address (dev, GRUB_CS5536_MSR_MAILBOX_ADDR),
+ addr);
+ grub_pci_write (grub_pci_make_address (dev, GRUB_CS5536_MSR_MAILBOX_DATA0),
+ val & 0xffffffff);
+ grub_pci_write (grub_pci_make_address (dev, GRUB_CS5536_MSR_MAILBOX_DATA1),
+ val >> 32);
+}
+
+grub_err_t
+grub_cs5536_smbus_wait (grub_port_t smbbase)
+{
+ grub_uint64_t start = grub_get_time_ms ();
+ while (1)
+ {
+ grub_uint8_t status;
+ status = grub_inb (smbbase + GRUB_CS5536_SMB_REG_STATUS);
+ if (status & GRUB_CS5536_SMB_REG_STATUS_SDAST)
+ return GRUB_ERR_NONE;
+ if (status & GRUB_CS5536_SMB_REG_STATUS_BER)
+ return grub_error (GRUB_ERR_IO, "SM bus error");
+ if (status & GRUB_CS5536_SMB_REG_STATUS_NACK)
+ return grub_error (GRUB_ERR_IO, "NACK received");
+ if (grub_get_time_ms () > start + 40)
+ return grub_error (GRUB_ERR_IO, "SM stalled");
+ }
+}
+
+grub_err_t
+grub_cs5536_read_spd_byte (grub_port_t smbbase, grub_uint8_t dev,
+ grub_uint8_t addr, grub_uint8_t *res)
+{
+ grub_err_t err;
+
+ /* Send START. */
+ grub_outb (grub_inb (smbbase + GRUB_CS5536_SMB_REG_CTRL1)
+ | GRUB_CS5536_SMB_REG_CTRL1_START,
+ smbbase + GRUB_CS5536_SMB_REG_CTRL1);
+
+ /* Send device address. */
+ err = grub_cs5536_smbus_wait (smbbase);
+ if (err)
+ return err;
+ grub_outb (dev << 1, smbbase + GRUB_CS5536_SMB_REG_DATA);
+
+ /* Send ACK. */
+ err = grub_cs5536_smbus_wait (smbbase);
+ if (err)
+ return err;
+ grub_outb (grub_inb (smbbase + GRUB_CS5536_SMB_REG_CTRL1)
+ | GRUB_CS5536_SMB_REG_CTRL1_ACK,
+ smbbase + GRUB_CS5536_SMB_REG_CTRL1);
+
+ /* Send byte address. */
+ grub_outb (addr, smbbase + GRUB_CS5536_SMB_REG_DATA);
+
+ /* Send START. */
+ err = grub_cs5536_smbus_wait (smbbase);
+ if (err)
+ return err;
+ grub_outb (grub_inb (smbbase + GRUB_CS5536_SMB_REG_CTRL1)
+ | GRUB_CS5536_SMB_REG_CTRL1_START,
+ smbbase + GRUB_CS5536_SMB_REG_CTRL1);
+
+ /* Send device address. */
+ err = grub_cs5536_smbus_wait (smbbase);
+ if (err)
+ return err;
+ grub_outb ((dev << 1) | 1, smbbase + GRUB_CS5536_SMB_REG_DATA);
+
+ /* Send STOP. */
+ err = grub_cs5536_smbus_wait (smbbase);
+ if (err)
+ return err;
+ grub_outb (grub_inb (smbbase + GRUB_CS5536_SMB_REG_CTRL1)
+ | GRUB_CS5536_SMB_REG_CTRL1_STOP,
+ smbbase + GRUB_CS5536_SMB_REG_CTRL1);
+
+ err = grub_cs5536_smbus_wait (smbbase);
+ if (err)
+ return err;
+ *res = grub_inb (smbbase + GRUB_CS5536_SMB_REG_DATA);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_cs5536_init_smbus (grub_pci_device_t dev, grub_uint16_t divisor,
+ grub_port_t *smbbase)
+{
+ grub_uint64_t smbbar;
+
+ smbbar = grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_SMB_BAR);
+
+ /* FIXME */
+ if (!(smbbar & GRUB_CS5536_LBAR_ENABLE))
+ return grub_error(GRUB_ERR_IO, "SMB controller not enabled\n");
+ *smbbase = (smbbar & GRUB_CS5536_LBAR_ADDR_MASK) + GRUB_MACHINE_PCI_IO_BASE;
+
+ if (divisor < 8)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid divisor");
+
+ /* Disable SMB. */
+ grub_outb (0, *smbbase + GRUB_CS5536_SMB_REG_CTRL2);
+
+ /* Disable interrupts. */
+ grub_outb (0, *smbbase + GRUB_CS5536_SMB_REG_CTRL1);
+
+ /* Set as master. */
+ grub_outb (GRUB_CS5536_SMB_REG_ADDR_MASTER,
+ *smbbase + GRUB_CS5536_SMB_REG_ADDR);
+
+ /* Launch. */
+ grub_outb (((divisor >> 7) & 0xff), *smbbase + GRUB_CS5536_SMB_REG_CTRL3);
+ grub_outb (((divisor << 1) & 0xfe) | GRUB_CS5536_SMB_REG_CTRL2_ENABLE,
+ *smbbase + GRUB_CS5536_SMB_REG_CTRL2);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_cs5536_read_spd (grub_port_t smbbase, grub_uint8_t dev,
+ struct grub_smbus_spd *res)
+{
+ grub_err_t err;
+ grub_size_t size;
+ grub_uint8_t b;
+ grub_size_t ptr;
+
+ err = grub_cs5536_read_spd_byte (smbbase, dev, 0, &b);
+ if (err)
+ return err;
+ if (b == 0)
+ return grub_error (GRUB_ERR_IO, "no SPD found");
+ size = b;
+
+ ((grub_uint8_t *) res)[0] = b;
+ for (ptr = 1; ptr < size; ptr++)
+ {
+ err = grub_cs5536_read_spd_byte (smbbase, dev, ptr,
+ &((grub_uint8_t *) res)[ptr]);
+ if (err)
+ return err;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static inline void
+set_io_space (grub_pci_device_t dev, int num, grub_uint16_t start,
+ grub_uint16_t len)
+{
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_GL_REGIONS_START + num,
+ ((((grub_uint64_t) start + len - 4)
+ << GRUB_CS5536_MSR_GL_REGION_IO_TOP_SHIFT)
+ & GRUB_CS5536_MSR_GL_REGION_TOP_MASK)
+ | (((grub_uint64_t) start
+ << GRUB_CS5536_MSR_GL_REGION_IO_BASE_SHIFT)
+ & GRUB_CS5536_MSR_GL_REGION_BASE_MASK)
+ | GRUB_CS5536_MSR_GL_REGION_IO
+ | GRUB_CS5536_MSR_GL_REGION_ENABLE);
+}
+
+static inline void
+set_iod (grub_pci_device_t dev, int num, int dest, int start, int mask)
+{
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_GL_IOD_START + num,
+ ((grub_uint64_t) dest << GRUB_CS5536_IOD_DEST_SHIFT)
+ | (((grub_uint64_t) start & GRUB_CS5536_IOD_ADDR_MASK)
+ << GRUB_CS5536_IOD_BASE_SHIFT)
+ | ((mask & GRUB_CS5536_IOD_ADDR_MASK)
+ << GRUB_CS5536_IOD_MASK_SHIFT));
+}
+
+static inline void
+set_p2d (grub_pci_device_t dev, int num, int dest, grub_uint32_t start)
+{
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_GL_P2D_START + num,
+ (((grub_uint64_t) dest) << GRUB_CS5536_P2D_DEST_SHIFT)
+ | ((grub_uint64_t) (start >> GRUB_CS5536_P2D_LOG_ALIGN)
+ << GRUB_CS5536_P2D_BASE_SHIFT)
+ | (((1 << (32 - GRUB_CS5536_P2D_LOG_ALIGN)) - 1)
+ << GRUB_CS5536_P2D_MASK_SHIFT));
+}
+
+void
+grub_cs5536_init_geode (grub_pci_device_t dev)
+{
+ /* Enable more BARs. */
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IRQ_MAP_BAR,
+ GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_IRQ_MAP);
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_MFGPT_BAR,
+ GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_MFGPT);
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_ACPI_BAR,
+ GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_ACPI);
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_PM_BAR,
+ GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_PM);
+
+ /* Setup DIVIL. */
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ switch (grub_arch_machine)
+ {
+ case GRUB_ARCH_MACHINE_YEELOONG:
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_LEG_IO,
+ GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1);
+ break;
+ case GRUB_ARCH_MACHINE_FULOONG2F:
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_LEG_IO,
+ GRUB_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0
+ | GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1);
+ break;
+ }
+#endif
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_PRIMARY_MASK,
+ (~GRUB_CS5536_DIVIL_LPC_INTERRUPTS) & 0xffff);
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_LPC_MASK,
+ GRUB_CS5536_DIVIL_LPC_INTERRUPTS);
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL,
+ GRUB_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL_ENABLE);
+
+ /* Initialise USB controller. */
+ /* FIXME: assign adresses dynamically. */
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_OHCI_BASE,
+ GRUB_CS5536_MSR_USB_BASE_BUS_MASTER
+ | GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE
+ | 0x05024000);
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE,
+ GRUB_CS5536_MSR_USB_BASE_BUS_MASTER
+ | GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE
+ | (0x20ULL << GRUB_CS5536_MSR_USB_EHCI_BASE_FLDJ_SHIFT)
+ | 0x05023000);
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_CONTROLLER_BASE,
+ GRUB_CS5536_MSR_USB_BASE_BUS_MASTER
+ | GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE | 0x05020000);
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_OPTION_CONTROLLER_BASE,
+ GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE | 0x05022000);
+ set_p2d (dev, 0, GRUB_CS5536_DESTINATION_USB, 0x05020000);
+ set_p2d (dev, 1, GRUB_CS5536_DESTINATION_USB, 0x05022000);
+ set_p2d (dev, 5, GRUB_CS5536_DESTINATION_USB, 0x05024000);
+ set_p2d (dev, 6, GRUB_CS5536_DESTINATION_USB, 0x05023000);
+
+ {
+ volatile grub_uint32_t *oc;
+ oc = grub_pci_device_map_range (dev, 0x05022000,
+ GRUB_CS5536_USB_OPTION_REGS_SIZE);
+
+ oc[GRUB_CS5536_USB_OPTION_REG_UOCMUX] =
+ (oc[GRUB_CS5536_USB_OPTION_REG_UOCMUX]
+ & ~GRUB_CS5536_USB_OPTION_REG_UOCMUX_PMUX_MASK)
+ | GRUB_CS5536_USB_OPTION_REG_UOCMUX_PMUX_HC;
+ grub_pci_device_unmap_range (dev, oc, GRUB_CS5536_USB_OPTION_REGS_SIZE);
+ }
+
+ /* Setup IDE controller. */
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IDE_IO_BAR,
+ GRUB_CS5536_LBAR_IDE
+ | GRUB_CS5536_MSR_IDE_IO_BAR_UNITS);
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IDE_CFG,
+ GRUB_CS5536_MSR_IDE_CFG_CHANNEL_ENABLE);
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IDE_TIMING,
+ (GRUB_CS5536_MSR_IDE_TIMING_PIO0
+ << GRUB_CS5536_MSR_IDE_TIMING_DRIVE0_SHIFT)
+ | (GRUB_CS5536_MSR_IDE_TIMING_PIO0
+ << GRUB_CS5536_MSR_IDE_TIMING_DRIVE1_SHIFT));
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IDE_CAS_TIMING,
+ (GRUB_CS5536_MSR_IDE_CAS_TIMING_CMD_PIO0
+ << GRUB_CS5536_MSR_IDE_CAS_TIMING_CMD_SHIFT)
+ | (GRUB_CS5536_MSR_IDE_CAS_TIMING_PIO0
+ << GRUB_CS5536_MSR_IDE_CAS_TIMING_DRIVE0_SHIFT)
+ | (GRUB_CS5536_MSR_IDE_CAS_TIMING_PIO0
+ << GRUB_CS5536_MSR_IDE_CAS_TIMING_DRIVE1_SHIFT));
+
+ /* Setup Geodelink PCI. */
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_GL_PCI_CTRL,
+ (4ULL << GRUB_CS5536_MSR_GL_PCI_CTRL_OUT_THR_SHIFT)
+ | (4ULL << GRUB_CS5536_MSR_GL_PCI_CTRL_IN_THR_SHIFT)
+ | (8ULL << GRUB_CS5536_MSR_GL_PCI_CTRL_LATENCY_SHIFT)
+ | GRUB_CS5536_MSR_GL_PCI_CTRL_IO_ENABLE
+ | GRUB_CS5536_MSR_GL_PCI_CTRL_MEMORY_ENABLE);
+
+ /* Setup windows. */
+ set_io_space (dev, 0, GRUB_CS5536_LBAR_SMBUS, GRUB_CS5536_SMBUS_REGS_SIZE);
+ set_io_space (dev, 1, GRUB_CS5536_LBAR_GPIO, GRUB_CS5536_GPIO_REGS_SIZE);
+ set_io_space (dev, 2, GRUB_CS5536_LBAR_MFGPT, GRUB_CS5536_MFGPT_REGS_SIZE);
+ set_io_space (dev, 3, GRUB_CS5536_LBAR_IRQ_MAP, GRUB_CS5536_IRQ_MAP_REGS_SIZE);
+ set_io_space (dev, 4, GRUB_CS5536_LBAR_PM, GRUB_CS5536_PM_REGS_SIZE);
+ set_io_space (dev, 5, GRUB_CS5536_LBAR_ACPI, GRUB_CS5536_ACPI_REGS_SIZE);
+ set_iod (dev, 0, GRUB_CS5536_DESTINATION_IDE, GRUB_ATA_CH0_PORT1, 0xffff8);
+ set_iod (dev, 1, GRUB_CS5536_DESTINATION_ACC, GRUB_CS5536_LBAR_ACC, 0xfff80);
+ set_iod (dev, 2, GRUB_CS5536_DESTINATION_IDE, GRUB_CS5536_LBAR_IDE, 0xffff0);
+}
diff --git a/grub-core/bus/emu/pci.c b/grub-core/bus/emu/pci.c
new file mode 100644
index 0000000..267f262
--- /dev/null
+++ b/grub-core/bus/emu/pci.c
@@ -0,0 +1,78 @@
+/* pci.c - Generic PCI interfaces. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/pci.h>
+#include <grub/dl.h>
+#include <grub/emu/misc.h>
+#include <grub/util/misc.h>
+
+grub_pci_address_t
+grub_pci_make_address (grub_pci_device_t dev, int reg)
+{
+ grub_pci_address_t ret;
+ ret.dev = dev;
+ ret.pos = reg;
+ return ret;
+}
+
+void
+grub_pci_iterate (grub_pci_iteratefunc_t hook, void *hook_data)
+{
+ struct pci_device_iterator *iter;
+ struct pci_slot_match slot;
+ struct pci_device *dev;
+ slot.domain = PCI_MATCH_ANY;
+ slot.bus = PCI_MATCH_ANY;
+ slot.dev = PCI_MATCH_ANY;
+ slot.func = PCI_MATCH_ANY;
+ iter = pci_slot_match_iterator_create (&slot);
+ while ((dev = pci_device_next (iter)))
+ hook (dev, dev->vendor_id | (dev->device_id << 16), hook_data);
+ pci_iterator_destroy (iter);
+}
+
+void *
+grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base,
+ grub_size_t size)
+{
+ void *addr;
+ int err;
+ err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr);
+ if (err)
+ grub_util_error ("mapping 0x%llx failed (error %d)",
+ (unsigned long long) base, err);
+ return addr;
+}
+
+void
+grub_pci_device_unmap_range (grub_pci_device_t dev, void *mem,
+ grub_size_t size)
+{
+ pci_device_unmap_range (dev, mem, size);
+}
+
+GRUB_MOD_INIT (emupci)
+{
+ pci_system_init ();
+}
+
+GRUB_MOD_FINI (emupci)
+{
+ pci_system_cleanup ();
+}
diff --git a/grub-core/bus/fdt.c b/grub-core/bus/fdt.c
new file mode 100644
index 0000000..135da49
--- /dev/null
+++ b/grub-core/bus/fdt.c
@@ -0,0 +1,256 @@
+/*
+ * 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/fdtbus.h>
+#include <grub/fdt.h>
+#include <grub/term.h>
+
+static const void *dtb;
+static grub_size_t root_address_cells, root_size_cells;
+/* Pointer to this symbol signals invalid mapping. */
+char grub_fdtbus_invalid_mapping[1];
+
+struct grub_fdtbus_dev *devs;
+struct grub_fdtbus_driver *drivers;
+
+int
+grub_fdtbus_is_compatible (const char *compat_string,
+ const struct grub_fdtbus_dev *dev)
+{
+ grub_size_t compatible_size;
+ const char *compatible = grub_fdt_get_prop (dtb, dev->node, "compatible",
+ &compatible_size);
+ if (!compatible)
+ return 0;
+ const char *compatible_end = compatible + compatible_size;
+ while (compatible < compatible_end)
+ {
+ if (grub_strcmp (compat_string, compatible) == 0)
+ return 1;
+ compatible += grub_strlen (compatible) + 1;
+ }
+ return 0;
+}
+
+static void
+fdtbus_scan (struct grub_fdtbus_dev *parent)
+{
+ int node;
+ for (node = grub_fdt_first_node (dtb, parent ? parent->node : 0); node >= 0;
+ node = grub_fdt_next_node (dtb, node))
+ {
+ struct grub_fdtbus_dev *dev;
+ struct grub_fdtbus_driver *driver;
+ dev = grub_zalloc (sizeof (*dev));
+ if (!dev)
+ {
+ grub_print_error ();
+ return;
+ }
+ dev->node = node;
+ dev->next = devs;
+ dev->parent = parent;
+ devs = dev;
+ FOR_LIST_ELEMENTS(driver, drivers)
+ if (!dev->driver && grub_fdtbus_is_compatible (driver->compatible, dev))
+ {
+ grub_dprintf ("fdtbus", "Attaching %s\n", driver->compatible);
+ if (driver->attach (dev) == GRUB_ERR_NONE)
+ {
+ grub_dprintf ("fdtbus", "Attached %s\n", driver->compatible);
+ dev->driver = driver;
+ break;
+ }
+ grub_print_error ();
+ }
+ fdtbus_scan (dev);
+ }
+}
+
+void
+grub_fdtbus_register (struct grub_fdtbus_driver *driver)
+{
+ struct grub_fdtbus_dev *dev;
+ grub_dprintf ("fdtbus", "Registering %s\n", driver->compatible);
+ grub_list_push (GRUB_AS_LIST_P (&drivers),
+ GRUB_AS_LIST (driver));
+ for (dev = devs; dev; dev = dev->next)
+ if (!dev->driver && grub_fdtbus_is_compatible (driver->compatible, dev))
+ {
+ grub_dprintf ("fdtbus", "Attaching %s (%p)\n", driver->compatible, dev);
+ if (driver->attach (dev) == GRUB_ERR_NONE)
+ {
+ grub_dprintf ("fdtbus", "Attached %s\n", driver->compatible);
+ dev->driver = driver;
+ }
+ grub_print_error ();
+ }
+}
+
+void
+grub_fdtbus_unregister (struct grub_fdtbus_driver *driver)
+{
+ grub_list_remove (GRUB_AS_LIST (driver));
+ struct grub_fdtbus_dev *dev;
+ for (dev = devs; dev; dev = dev->next)
+ if (dev->driver == driver)
+ {
+ if (driver->detach)
+ driver->detach(dev);
+ dev->driver = 0;
+ }
+}
+
+void
+grub_fdtbus_init (const void *dtb_in, grub_size_t size)
+{
+ if (!dtb_in || grub_fdt_check_header (dtb_in, size) < 0)
+ grub_fatal ("invalid FDT");
+ dtb = dtb_in;
+ const grub_uint32_t *prop = grub_fdt_get_prop (dtb, 0, "#address-cells", 0);
+ if (prop)
+ root_address_cells = grub_be_to_cpu32 (*prop);
+ else
+ root_address_cells = 1;
+
+ prop = grub_fdt_get_prop (dtb, 0, "#size-cells", 0);
+ if (prop)
+ root_size_cells = grub_be_to_cpu32 (*prop);
+ else
+ root_size_cells = 1;
+
+ fdtbus_scan (0);
+}
+
+static int
+get_address_cells (const struct grub_fdtbus_dev *dev)
+{
+ const grub_uint32_t *prop;
+ if (!dev)
+ return root_address_cells;
+ prop = grub_fdt_get_prop (dtb, dev->node, "#address-cells", 0);
+ if (prop)
+ return grub_be_to_cpu32 (*prop);
+ return 1;
+}
+
+static int
+get_size_cells (const struct grub_fdtbus_dev *dev)
+{
+ const grub_uint32_t *prop;
+ if (!dev)
+ return root_size_cells;
+ prop = grub_fdt_get_prop (dtb, dev->node, "#size-cells", 0);
+ if (prop)
+ return grub_be_to_cpu32 (*prop);
+ return 1;
+}
+
+static grub_uint64_t
+get64 (const grub_uint32_t *reg, grub_size_t cells)
+{
+ grub_uint64_t val = 0;
+ if (cells >= 1)
+ val = grub_be_to_cpu32 (reg[cells - 1]);
+ if (cells >= 2)
+ val |= ((grub_uint64_t) grub_be_to_cpu32 (reg[cells - 2])) << 32;
+ return val;
+}
+
+static volatile void *
+translate (const struct grub_fdtbus_dev *dev, const grub_uint32_t *reg)
+{
+ volatile void *ret;
+ const grub_uint32_t *ranges;
+ grub_size_t ranges_size, cells_per_mapping;
+ grub_size_t parent_address_cells, child_address_cells, child_size_cells;
+ grub_size_t nmappings, i;
+ if (dev == 0)
+ {
+ grub_uint64_t val;
+ val = get64 (reg, root_address_cells);
+ if (sizeof (void *) == 4 && (val >> 32))
+ return grub_fdtbus_invalid_mapping;
+ return (void *) (grub_addr_t) val;
+ }
+ ranges = grub_fdt_get_prop (dtb, dev->node, "ranges", &ranges_size);
+ if (!ranges)
+ return grub_fdtbus_invalid_mapping;
+ if (ranges_size == 0)
+ return translate (dev->parent, reg);
+ parent_address_cells = get_address_cells (dev->parent);
+ child_address_cells = get_address_cells (dev);
+ child_size_cells = get_size_cells (dev);
+ cells_per_mapping = parent_address_cells + child_address_cells + child_size_cells;
+ nmappings = ranges_size / 4 / cells_per_mapping;
+ for (i = 0; i < nmappings; i++)
+ {
+ const grub_uint32_t *child_addr = &ranges[i * cells_per_mapping];
+ const grub_uint32_t *parent_addr = child_addr + child_address_cells;
+ grub_uint64_t child_size = get64 (parent_addr + parent_address_cells, child_size_cells);
+
+ if (child_address_cells > 2 && grub_memcmp (reg, child_addr, (child_address_cells - 2) * 4) != 0)
+ continue;
+ if (get64 (reg, child_address_cells) < get64 (child_addr, child_address_cells))
+ continue;
+
+ grub_uint64_t offset = get64 (reg, child_address_cells) - get64 (child_addr, child_address_cells);
+ if (offset >= child_size)
+ continue;
+
+ ret = translate (dev->parent, parent_addr);
+ if (grub_fdtbus_is_mapping_valid (ret))
+ ret = (volatile char *) ret + offset;
+ return ret;
+ }
+ return grub_fdtbus_invalid_mapping;
+}
+
+volatile void *
+grub_fdtbus_map_reg (const struct grub_fdtbus_dev *dev, int regno, grub_size_t *size)
+{
+ grub_size_t address_cells, size_cells;
+ address_cells = get_address_cells (dev->parent);
+ size_cells = get_size_cells (dev->parent);
+ const grub_uint32_t *reg = grub_fdt_get_prop (dtb, dev->node, "reg", 0);
+ if (size && size_cells)
+ *size = reg[(address_cells + size_cells) * regno + address_cells];
+ if (size && !size_cells)
+ *size = 0;
+ return translate (dev->parent, reg + (address_cells + size_cells) * regno);
+}
+
+const char *
+grub_fdtbus_get_name (const struct grub_fdtbus_dev *dev)
+{
+ return grub_fdt_get_nodename (dtb, dev->node);
+}
+
+const void *
+grub_fdtbus_get_prop (const struct grub_fdtbus_dev *dev,
+ const char *name,
+ grub_uint32_t *len)
+{
+ return grub_fdt_get_prop (dtb, dev->node, name, len);
+}
+
+const void *
+grub_fdtbus_get_fdt (void)
+{
+ return dtb;
+}
diff --git a/grub-core/bus/i386/ieee1275/pci.c b/grub-core/bus/i386/ieee1275/pci.c
new file mode 100644
index 0000000..1fd3b56
--- /dev/null
+++ b/grub-core/bus/i386/ieee1275/pci.c
@@ -0,0 +1,42 @@
+/*
+ * 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/dl.h>
+#include <grub/pci.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/ieee1275/ieee1275.h>
+
+volatile void *
+grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
+ grub_addr_t base,
+ grub_size_t size)
+{
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE))
+ return (volatile void *) base;
+ if (grub_ieee1275_map (base, base, size, 7))
+ grub_fatal ("couldn't map 0x%lx", base);
+ return (volatile void *) base;
+}
+
+void
+grub_pci_device_unmap_range (grub_pci_device_t dev __attribute__ ((unused)),
+ volatile void *mem __attribute__ ((unused)),
+ grub_size_t size __attribute__ ((unused)))
+{
+}
diff --git a/grub-core/bus/pci.c b/grub-core/bus/pci.c
new file mode 100644
index 0000000..b388ce5
--- /dev/null
+++ b/grub-core/bus/pci.c
@@ -0,0 +1,173 @@
+/* pci.c - Generic PCI interfaces. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/pci.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/mm_private.h>
+#include <grub/cache.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* FIXME: correctly support 64-bit architectures. */
+/* #if GRUB_TARGET_SIZEOF_VOID_P == 4 */
+struct grub_pci_dma_chunk *
+grub_memalign_dma32 (grub_size_t align, grub_size_t size)
+{
+ void *ret;
+ if (align < 64)
+ align = 64;
+ size = ALIGN_UP (size, align);
+ ret = grub_memalign (align, size);
+#if GRUB_CPU_SIZEOF_VOID_P == 8
+ if ((grub_addr_t) ret >> 32)
+ {
+ /* Shouldn't happend since the only platform in this case is
+ x86_64-efi and it skips any regions > 4GiB because
+ of EFI bugs anyway. */
+ grub_error (GRUB_ERR_BUG, "allocation outside 32-bit range");
+ return 0;
+ }
+#endif
+ if (!ret)
+ return 0;
+ grub_arch_sync_dma_caches (ret, size);
+ return ret;
+}
+
+/* FIXME: evil. */
+void
+grub_dma_free (struct grub_pci_dma_chunk *ch)
+{
+ grub_size_t size = (((struct grub_mm_header *) ch) - 1)->size * GRUB_MM_ALIGN;
+ grub_arch_sync_dma_caches (ch, size);
+ grub_free (ch);
+}
+/* #endif */
+
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+volatile void *
+grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
+{
+ return (void *) ((((grub_uint32_t) ch) & 0x1fffffff) | 0xa0000000);
+}
+
+grub_uint32_t
+grub_dma_get_phys (struct grub_pci_dma_chunk *ch)
+{
+ return (((grub_uint32_t) ch) & 0x1fffffff) | 0x80000000;
+}
+#else
+
+volatile void *
+grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
+{
+ return (void *) ch;
+}
+
+grub_uint32_t
+grub_dma_get_phys (struct grub_pci_dma_chunk *ch)
+{
+ return (grub_uint32_t) (grub_addr_t) ch;
+}
+
+#endif
+
+grub_pci_address_t
+grub_pci_make_address (grub_pci_device_t dev, int reg)
+{
+ return (1 << 31) | (dev.bus << 16) | (dev.device << 11)
+ | (dev.function << 8) | reg;
+}
+
+void
+grub_pci_iterate (grub_pci_iteratefunc_t hook, void *hook_data)
+{
+ grub_pci_device_t dev;
+ grub_pci_address_t addr;
+ grub_pci_id_t id;
+ grub_uint32_t hdr;
+
+ for (dev.bus = 0; dev.bus < GRUB_PCI_NUM_BUS; dev.bus++)
+ {
+ for (dev.device = 0; dev.device < GRUB_PCI_NUM_DEVICES; dev.device++)
+ {
+ for (dev.function = 0; dev.function < 8; dev.function++)
+ {
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_PCI_ID);
+ id = grub_pci_read (addr);
+
+ /* Check if there is a device present. */
+ if (id >> 16 == 0xFFFF)
+ {
+ if (dev.function == 0)
+ /* Devices are required to implement function 0, so if
+ it's missing then there is no device here. */
+ break;
+ else
+ continue;
+ }
+
+ if (hook (dev, id, hook_data))
+ return;
+
+ /* Probe only func = 0 if the device if not multifunction */
+ if (dev.function == 0)
+ {
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CACHELINE);
+ hdr = grub_pci_read (addr);
+ if (!(hdr & 0x800000))
+ break;
+ }
+ }
+ }
+ }
+}
+
+grub_uint8_t
+grub_pci_find_capability (grub_pci_device_t dev, grub_uint8_t cap)
+{
+ grub_uint8_t pos = 0x34;
+ int ttl = 48;
+
+ while (ttl--)
+ {
+ grub_uint8_t id;
+ grub_pci_address_t addr;
+
+ addr = grub_pci_make_address (dev, pos);
+ pos = grub_pci_read_byte (addr);
+ if (pos < 0x40)
+ break;
+
+ pos &= ~3;
+
+ addr = grub_pci_make_address (dev, pos);
+ id = grub_pci_read_byte (addr);
+
+ if (id == 0xff)
+ break;
+
+ if (id == cap)
+ return pos;
+ pos++;
+ }
+ return 0;
+}
diff --git a/grub-core/bus/spi/rk3288_spi.c b/grub-core/bus/spi/rk3288_spi.c
new file mode 100644
index 0000000..aacb79f
--- /dev/null
+++ b/grub-core/bus/spi/rk3288_spi.c
@@ -0,0 +1,103 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ *
+ * Copyright (C) 2012 Google Inc.
+ * Copyright (C) 2016 Free Software Foundation, Inc.
+ *
+ * This is based on depthcharge code.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/mm.h>
+#include <grub/time.h>
+#include <grub/misc.h>
+#include <grub/fdtbus.h>
+#include <grub/machine/kernel.h>
+
+static grub_err_t
+spi_send (const struct grub_fdtbus_dev *dev, const void *data, grub_size_t sz)
+{
+ const grub_uint8_t *ptr = data, *end = ptr + sz;
+ volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0);
+ spi[2] = 0;
+ spi[1] = sz - 1;
+ spi[0] = ((1 << 18) | spi[0]) & ~(1 << 19);
+ spi[2] = 1;
+ while (ptr < end)
+ {
+ while (spi[9] & 2);
+ spi[256] = *ptr++;
+ }
+ while (spi[9] & 1);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+spi_receive (const struct grub_fdtbus_dev *dev, void *data, grub_size_t sz)
+{
+ grub_uint8_t *ptr = data, *end = ptr + sz;
+ volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0);
+ spi[2] = 0;
+ spi[1] = sz - 1;
+ spi[0] = ((1 << 19) | spi[0]) & ~(1 << 18);
+ spi[2] = 1;
+ while (ptr < end)
+ {
+ while (spi[9] & 8);
+ *ptr++ = spi[512];
+ }
+ while (spi[9] & 1);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+spi_start (const struct grub_fdtbus_dev *dev)
+{
+ volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0);
+ spi[3] = 1;
+ return GRUB_ERR_NONE;
+}
+
+static void
+spi_stop (const struct grub_fdtbus_dev *dev)
+{
+ volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0);
+ spi[3] = 0;
+}
+
+static grub_err_t
+spi_attach(const struct grub_fdtbus_dev *dev)
+{
+ if (!grub_fdtbus_is_mapping_valid (grub_fdtbus_map_reg (dev, 0, 0)))
+ return GRUB_ERR_IO;
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_fdtbus_driver spi =
+{
+ .compatible = "rockchip,rk3288-spi",
+ .attach = spi_attach,
+ .send = spi_send,
+ .receive = spi_receive,
+ .start = spi_start,
+ .stop = spi_stop,
+};
+
+void
+grub_rk3288_spi_init (void)
+{
+ grub_fdtbus_register (&spi);
+}
diff --git a/grub-core/bus/usb/ehci-fdt.c b/grub-core/bus/usb/ehci-fdt.c
new file mode 100644
index 0000000..29b50bd
--- /dev/null
+++ b/grub-core/bus/usb/ehci-fdt.c
@@ -0,0 +1,45 @@
+/* ehci.c - EHCI Support. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/mm.h>
+#include <grub/time.h>
+#include <grub/usb.h>
+#include <grub/fdtbus.h>
+
+static grub_err_t
+ehci_attach(const struct grub_fdtbus_dev *dev)
+{
+ grub_dprintf ("ehci", "Found generic-ehci\n");
+
+ grub_ehci_init_device (grub_fdtbus_map_reg (dev, 0, 0));
+ return 0;
+}
+
+struct grub_fdtbus_driver ehci =
+{
+ .compatible = "generic-ehci",
+ .attach = ehci_attach
+};
+
+void
+grub_ehci_pci_scan (void)
+{
+ grub_fdtbus_register (&ehci);
+}
diff --git a/grub-core/bus/usb/ehci-pci.c b/grub-core/bus/usb/ehci-pci.c
new file mode 100644
index 0000000..65e6cb5
--- /dev/null
+++ b/grub-core/bus/usb/ehci-pci.c
@@ -0,0 +1,208 @@
+/* ehci.c - EHCI Support. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/pci.h>
+#include <grub/cpu/pci.h>
+#include <grub/cs5536.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/usb.h>
+
+#define GRUB_EHCI_PCI_SBRN_REG 0x60
+#define GRUB_EHCI_ADDR_MEM_MASK (~0xff)
+
+/* USBLEGSUP bits and related OS OWNED byte offset */
+enum
+{
+ GRUB_EHCI_BIOS_OWNED = (1 << 16),
+ GRUB_EHCI_OS_OWNED = (1 << 24)
+};
+
+/* PCI iteration function... */
+static int
+grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ volatile grub_uint32_t *regs;
+ grub_uint32_t base, base_h;
+ grub_uint32_t eecp_offset;
+ grub_uint32_t usblegsup = 0;
+ grub_uint64_t maxtime;
+ grub_uint32_t interf;
+ grub_uint32_t subclass;
+ grub_uint32_t class;
+ grub_uint8_t release;
+ grub_uint32_t class_code;
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: begin\n");
+
+ if (pciid == GRUB_CS5536_PCIID)
+ {
+ grub_uint64_t basereg;
+
+ basereg = grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE);
+ if (!(basereg & GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE))
+ {
+ /* Shouldn't happen. */
+ grub_dprintf ("ehci", "No EHCI address is assigned\n");
+ return 0;
+ }
+ base = (basereg & GRUB_CS5536_MSR_USB_BASE_ADDR_MASK);
+ basereg |= GRUB_CS5536_MSR_USB_BASE_BUS_MASTER;
+ basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_ENABLED;
+ basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_STATUS;
+ basereg &= ~GRUB_CS5536_MSR_USB_BASE_SMI_ENABLE;
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE, basereg);
+ }
+ else
+ {
+ grub_pci_address_t addr;
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class_code = grub_pci_read (addr) >> 8;
+ interf = class_code & 0xFF;
+ subclass = (class_code >> 8) & 0xFF;
+ class = class_code >> 16;
+
+ /* If this is not an EHCI controller, just return. */
+ if (class != 0x0c || subclass != 0x03 || interf != 0x20)
+ return 0;
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: class OK\n");
+
+ /* Check Serial Bus Release Number */
+ addr = grub_pci_make_address (dev, GRUB_EHCI_PCI_SBRN_REG);
+ release = grub_pci_read_byte (addr);
+ if (release != 0x20)
+ {
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: Wrong SBRN: %0x\n",
+ release);
+ return 0;
+ }
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: bus rev. num. OK\n");
+
+ /* Determine EHCI EHCC registers base address. */
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
+ base = grub_pci_read (addr);
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1);
+ base_h = grub_pci_read (addr);
+ /* Stop if registers are mapped above 4G - GRUB does not currently
+ * work with registers mapped above 4G */
+ if (((base & GRUB_PCI_ADDR_MEM_TYPE_MASK) != GRUB_PCI_ADDR_MEM_TYPE_32)
+ && (base_h != 0))
+ {
+ grub_dprintf ("ehci",
+ "EHCI grub_ehci_pci_iter: registers above 4G are not supported\n");
+ return 0;
+ }
+ base &= GRUB_PCI_ADDR_MEM_MASK;
+ if (!base)
+ {
+ grub_dprintf ("ehci",
+ "EHCI: EHCI is not mapped\n");
+ return 0;
+ }
+
+ /* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write_word(addr,
+ GRUB_PCI_COMMAND_MEM_ENABLED
+ | GRUB_PCI_COMMAND_BUS_MASTER
+ | grub_pci_read_word(addr));
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: 32-bit EHCI OK\n");
+ }
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: iobase of EHCC: %08x\n",
+ (base & GRUB_EHCI_ADDR_MEM_MASK));
+
+ regs = grub_pci_device_map_range (dev,
+ (base & GRUB_EHCI_ADDR_MEM_MASK),
+ 0x100);
+
+ /* Is there EECP ? */
+ eecp_offset = (grub_le_to_cpu32 (regs[2]) >> 8) & 0xff;
+
+ /* Determine and change ownership. */
+ /* EECP offset valid in HCCPARAMS */
+ /* Ownership can be changed via EECP only */
+ if (pciid != GRUB_CS5536_PCIID && eecp_offset >= 0x40)
+ {
+ grub_pci_address_t pciaddr_eecp;
+ pciaddr_eecp = grub_pci_make_address (dev, eecp_offset);
+
+ usblegsup = grub_pci_read (pciaddr_eecp);
+ if (usblegsup & GRUB_EHCI_BIOS_OWNED)
+ {
+ grub_boot_time ("Taking ownership of EHCI controller");
+ grub_dprintf ("ehci",
+ "EHCI grub_ehci_pci_iter: EHCI owned by: BIOS\n");
+ /* Ownership change - set OS_OWNED bit */
+ grub_pci_write (pciaddr_eecp, usblegsup | GRUB_EHCI_OS_OWNED);
+ /* Ensure PCI register is written */
+ grub_pci_read (pciaddr_eecp);
+
+ /* Wait for finish of ownership change, EHCI specification
+ * doesn't say how long it can take... */
+ maxtime = grub_get_time_ms () + 1000;
+ while ((grub_pci_read (pciaddr_eecp) & GRUB_EHCI_BIOS_OWNED)
+ && (grub_get_time_ms () < maxtime));
+ if (grub_pci_read (pciaddr_eecp) & GRUB_EHCI_BIOS_OWNED)
+ {
+ grub_dprintf ("ehci",
+ "EHCI grub_ehci_pci_iter: EHCI change ownership timeout");
+ /* Change ownership in "hard way" - reset BIOS ownership */
+ grub_pci_write (pciaddr_eecp, GRUB_EHCI_OS_OWNED);
+ /* Ensure PCI register is written */
+ grub_pci_read (pciaddr_eecp);
+ }
+ }
+ else if (usblegsup & GRUB_EHCI_OS_OWNED)
+ /* XXX: What to do in this case - nothing ? Can it happen ? */
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: EHCI owned by: OS\n");
+ else
+ {
+ grub_dprintf ("ehci",
+ "EHCI grub_ehci_pci_iter: EHCI owned by: NONE\n");
+ /* XXX: What to do in this case ? Can it happen ?
+ * Is code below correct ? */
+ /* Ownership change - set OS_OWNED bit */
+ grub_pci_write (pciaddr_eecp, GRUB_EHCI_OS_OWNED);
+ /* Ensure PCI register is written */
+ grub_pci_read (pciaddr_eecp);
+ }
+
+ /* Disable SMI, just to be sure. */
+ pciaddr_eecp = grub_pci_make_address (dev, eecp_offset + 4);
+ grub_pci_write (pciaddr_eecp, 0);
+ /* Ensure PCI register is written */
+ grub_pci_read (pciaddr_eecp);
+ }
+
+ grub_dprintf ("ehci", "inithw: EHCI grub_ehci_pci_iter: ownership OK\n");
+
+ grub_ehci_init_device (regs);
+ return 0;
+}
+
+void
+grub_ehci_pci_scan (void)
+{
+ grub_pci_iterate (grub_ehci_pci_iter, NULL);
+}
diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c
new file mode 100644
index 0000000..d966fc2
--- /dev/null
+++ b/grub-core/bus/usb/ehci.c
@@ -0,0 +1,1839 @@
+/* ehci.c - EHCI Support. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/usb.h>
+#include <grub/usbtrans.h>
+#include <grub/misc.h>
+#include <grub/time.h>
+#include <grub/loader.h>
+#include <grub/disk.h>
+#include <grub/dma.h>
+#include <grub/cache.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* This simple GRUB implementation of EHCI driver:
+ * - assumes no IRQ
+ * - is not supporting isochronous transfers (iTD, siTD)
+ * - is not supporting interrupt transfers
+ */
+
+/* Capability registers offsets */
+enum
+{
+ GRUB_EHCI_EHCC_CAPLEN = 0x00, /* byte */
+ GRUB_EHCI_EHCC_VERSION = 0x02, /* word */
+ GRUB_EHCI_EHCC_SPARAMS = 0x04, /* dword */
+ GRUB_EHCI_EHCC_CPARAMS = 0x08, /* dword */
+ GRUB_EHCI_EHCC_PROUTE = 0x0c, /* 60 bits */
+};
+
+#define GRUB_EHCI_EECP_MASK (0xff << 8)
+#define GRUB_EHCI_EECP_SHIFT 8
+
+#define GRUB_EHCI_POINTER_MASK (~0x1f)
+
+/* Capability register SPARAMS bits */
+enum
+{
+ GRUB_EHCI_SPARAMS_N_PORTS = (0xf << 0),
+ GRUB_EHCI_SPARAMS_PPC = (1 << 4), /* Power port control */
+ GRUB_EHCI_SPARAMS_PRR = (1 << 7), /* Port routing rules */
+ GRUB_EHCI_SPARAMS_N_PCC = (0xf << 8), /* No of ports per comp. */
+ GRUB_EHCI_SPARAMS_NCC = (0xf << 12), /* No of com. controllers */
+ GRUB_EHCI_SPARAMS_P_IND = (1 << 16), /* Port indicators present */
+ GRUB_EHCI_SPARAMS_DEBUG_P = (0xf << 20) /* Debug port */
+};
+
+#define GRUB_EHCI_MAX_N_PORTS 15 /* Max. number of ports */
+
+/* Capability register CPARAMS bits */
+enum
+{
+ GRUB_EHCI_CPARAMS_64BIT = (1 << 0),
+ GRUB_EHCI_CPARAMS_PROG_FRAMELIST = (1 << 1),
+ GRUB_EHCI_CPARAMS_PARK_CAP = (1 << 2)
+};
+
+#define GRUB_EHCI_N_FRAMELIST 1024
+#define GRUB_EHCI_N_QH 256
+#define GRUB_EHCI_N_TD 640
+
+#define GRUB_EHCI_QH_EMPTY 1
+
+/* Operational registers offsets */
+enum
+{
+ GRUB_EHCI_COMMAND = 0x00,
+ GRUB_EHCI_STATUS = 0x04,
+ GRUB_EHCI_INTERRUPT = 0x08,
+ GRUB_EHCI_FRAME_INDEX = 0x0c,
+ GRUB_EHCI_64BIT_SEL = 0x10,
+ GRUB_EHCI_FL_BASE = 0x14,
+ GRUB_EHCI_CUR_AL_ADDR = 0x18,
+ GRUB_EHCI_CONFIG_FLAG = 0x40,
+ GRUB_EHCI_PORT_STAT_CMD = 0x44
+};
+
+/* Operational register COMMAND bits */
+enum
+{
+ GRUB_EHCI_CMD_RUNSTOP = (1 << 0),
+ GRUB_EHCI_CMD_HC_RESET = (1 << 1),
+ GRUB_EHCI_CMD_FL_SIZE = (3 << 2),
+ GRUB_EHCI_CMD_PS_ENABL = (1 << 4),
+ GRUB_EHCI_CMD_AS_ENABL = (1 << 5),
+ GRUB_EHCI_CMD_AS_ADV_D = (1 << 6),
+ GRUB_EHCI_CMD_L_HC_RES = (1 << 7),
+ GRUB_EHCI_CMD_AS_PARKM = (3 << 8),
+ GRUB_EHCI_CMD_AS_PARKE = (1 << 11),
+ GRUB_EHCI_CMD_INT_THRS = (0xff << 16)
+};
+
+/* Operational register STATUS bits */
+enum
+{
+ GRUB_EHCI_ST_INTERRUPT = (1 << 0),
+ GRUB_EHCI_ST_ERROR_INT = (1 << 1),
+ GRUB_EHCI_ST_PORT_CHG = (1 << 2),
+ GRUB_EHCI_ST_FL_ROLLOVR = (1 << 3),
+ GRUB_EHCI_ST_HS_ERROR = (1 << 4),
+ GRUB_EHCI_ST_AS_ADVANCE = (1 << 5),
+ GRUB_EHCI_ST_HC_HALTED = (1 << 12),
+ GRUB_EHCI_ST_RECLAM = (1 << 13),
+ GRUB_EHCI_ST_PS_STATUS = (1 << 14),
+ GRUB_EHCI_ST_AS_STATUS = (1 << 15)
+};
+
+/* Operational register PORT_STAT_CMD bits */
+enum
+{
+ GRUB_EHCI_PORT_CONNECT = (1 << 0),
+ GRUB_EHCI_PORT_CONNECT_CH = (1 << 1),
+ GRUB_EHCI_PORT_ENABLED = (1 << 2),
+ GRUB_EHCI_PORT_ENABLED_CH = (1 << 3),
+ GRUB_EHCI_PORT_OVERCUR = (1 << 4),
+ GRUB_EHCI_PORT_OVERCUR_CH = (1 << 5),
+ GRUB_EHCI_PORT_RESUME = (1 << 6),
+ GRUB_EHCI_PORT_SUSPEND = (1 << 7),
+ GRUB_EHCI_PORT_RESET = (1 << 8),
+ GRUB_EHCI_PORT_LINE_STAT = (3 << 10),
+ GRUB_EHCI_PORT_POWER = (1 << 12),
+ GRUB_EHCI_PORT_OWNER = (1 << 13),
+ GRUB_EHCI_PORT_INDICATOR = (3 << 14),
+ GRUB_EHCI_PORT_TEST = (0xf << 16),
+ GRUB_EHCI_PORT_WON_CONN_E = (1 << 20),
+ GRUB_EHCI_PORT_WON_DISC_E = (1 << 21),
+ GRUB_EHCI_PORT_WON_OVER_E = (1 << 22),
+
+ GRUB_EHCI_PORT_LINE_SE0 = (0 << 10),
+ GRUB_EHCI_PORT_LINE_K = (1 << 10),
+ GRUB_EHCI_PORT_LINE_J = (2 << 10),
+ GRUB_EHCI_PORT_LINE_UNDEF = (3 << 10),
+ GRUB_EHCI_PORT_LINE_LOWSP = GRUB_EHCI_PORT_LINE_K, /* K state means low speed */
+ GRUB_EHCI_PORT_WMASK = ~(GRUB_EHCI_PORT_CONNECT_CH
+ | GRUB_EHCI_PORT_ENABLED_CH
+ | GRUB_EHCI_PORT_OVERCUR_CH)
+};
+
+/* Operational register CONFIGFLAGS bits */
+enum
+{
+ GRUB_EHCI_CF_EHCI_OWNER = (1 << 0)
+};
+
+/* Queue Head & Transfer Descriptor constants */
+#define GRUB_EHCI_HPTR_OFF 5 /* Horiz. pointer bit offset */
+enum
+{
+ GRUB_EHCI_HPTR_TYPE_MASK = (3 << 1),
+ GRUB_EHCI_HPTR_TYPE_ITD = (0 << 1),
+ GRUB_EHCI_HPTR_TYPE_QH = (1 << 1),
+ GRUB_EHCI_HPTR_TYPE_SITD = (2 << 1),
+ GRUB_EHCI_HPTR_TYPE_FSTN = (3 << 1)
+};
+
+enum
+{
+ GRUB_EHCI_C = (1 << 27),
+ GRUB_EHCI_MAXPLEN_MASK = (0x7ff << 16),
+ GRUB_EHCI_H = (1 << 15),
+ GRUB_EHCI_DTC = (1 << 14),
+ GRUB_EHCI_SPEED_MASK = (3 << 12),
+ GRUB_EHCI_SPEED_FULL = (0 << 12),
+ GRUB_EHCI_SPEED_LOW = (1 << 12),
+ GRUB_EHCI_SPEED_HIGH = (2 << 12),
+ GRUB_EHCI_SPEED_RESERVED = (3 << 12),
+ GRUB_EHCI_EP_NUM_MASK = (0xf << 8),
+ GRUB_EHCI_DEVADDR_MASK = 0x7f,
+ GRUB_EHCI_TARGET_MASK = (GRUB_EHCI_EP_NUM_MASK | GRUB_EHCI_DEVADDR_MASK)
+};
+
+enum
+{
+ GRUB_EHCI_MAXPLEN_OFF = 16,
+ GRUB_EHCI_SPEED_OFF = 12,
+ GRUB_EHCI_EP_NUM_OFF = 8
+};
+
+enum
+{
+ GRUB_EHCI_MULT_MASK = (3 << 30),
+ GRUB_EHCI_MULT_RESERVED = (0 << 30),
+ GRUB_EHCI_MULT_ONE = (1 << 30),
+ GRUB_EHCI_MULT_TWO = (2 << 30),
+ GRUB_EHCI_MULT_THREE = (3 << 30),
+ GRUB_EHCI_DEVPORT_MASK = (0x7f << 23),
+ GRUB_EHCI_HUBADDR_MASK = (0x7f << 16),
+ GRUB_EHCI_CMASK_MASK = (0xff << 8),
+ GRUB_EHCI_SMASK_MASK = (0xff << 0),
+};
+
+enum
+{
+ GRUB_EHCI_MULT_OFF = 30,
+ GRUB_EHCI_DEVPORT_OFF = 23,
+ GRUB_EHCI_HUBADDR_OFF = 16,
+ GRUB_EHCI_CMASK_OFF = 8,
+ GRUB_EHCI_SMASK_OFF = 0,
+};
+
+#define GRUB_EHCI_TERMINATE (1<<0)
+
+#define GRUB_EHCI_TOGGLE (1<<31)
+
+enum
+{
+ GRUB_EHCI_TOTAL_MASK = (0x7fff << 16),
+ GRUB_EHCI_CERR_MASK = (3 << 10),
+ GRUB_EHCI_CERR_0 = (0 << 10),
+ GRUB_EHCI_CERR_1 = (1 << 10),
+ GRUB_EHCI_CERR_2 = (2 << 10),
+ GRUB_EHCI_CERR_3 = (3 << 10),
+ GRUB_EHCI_PIDCODE_OUT = (0 << 8),
+ GRUB_EHCI_PIDCODE_IN = (1 << 8),
+ GRUB_EHCI_PIDCODE_SETUP = (2 << 8),
+ GRUB_EHCI_STATUS_MASK = 0xff,
+ GRUB_EHCI_STATUS_ACTIVE = (1 << 7),
+ GRUB_EHCI_STATUS_HALTED = (1 << 6),
+ GRUB_EHCI_STATUS_BUFERR = (1 << 5),
+ GRUB_EHCI_STATUS_BABBLE = (1 << 4),
+ GRUB_EHCI_STATUS_TRANERR = (1 << 3),
+ GRUB_EHCI_STATUS_MISSDMF = (1 << 2),
+ GRUB_EHCI_STATUS_SPLITST = (1 << 1),
+ GRUB_EHCI_STATUS_PINGERR = (1 << 0)
+};
+
+enum
+{
+ GRUB_EHCI_TOTAL_OFF = 16,
+ GRUB_EHCI_CERR_OFF = 10
+};
+
+#define GRUB_EHCI_BUFPTR_MASK (0xfffff<<12)
+#define GRUB_EHCI_QHTDPTR_MASK 0xffffffe0
+
+#define GRUB_EHCI_TD_BUF_PAGES 5
+
+#define GRUB_EHCI_BUFPAGELEN 0x1000
+#define GRUB_EHCI_MAXBUFLEN 0x5000
+
+struct grub_ehci_td;
+struct grub_ehci_qh;
+typedef volatile struct grub_ehci_td *grub_ehci_td_t;
+typedef volatile struct grub_ehci_qh *grub_ehci_qh_t;
+
+/* EHCI Isochronous Transfer Descriptor */
+/* Currently not supported */
+
+/* EHCI Split Transaction Isochronous Transfer Descriptor */
+/* Currently not supported */
+
+/* EHCI Queue Element Transfer Descriptor (qTD) */
+/* Align to 32-byte boundaries */
+struct grub_ehci_td
+{
+ /* EHCI HW part */
+ grub_uint32_t next_td; /* Pointer to next qTD */
+ grub_uint32_t alt_next_td; /* Pointer to alternate next qTD */
+ grub_uint32_t token; /* Toggle, Len, Interrupt, Page, Error, PID, Status */
+ grub_uint32_t buffer_page[GRUB_EHCI_TD_BUF_PAGES]; /* Buffer pointer (+ cur. offset in page 0 */
+ /* 64-bits part */
+ grub_uint32_t buffer_page_high[GRUB_EHCI_TD_BUF_PAGES];
+ /* EHCI driver part */
+ grub_uint32_t link_td; /* pointer to next free/chained TD */
+ grub_uint32_t size;
+ grub_uint32_t pad[1]; /* padding to some multiple of 32 bytes */
+};
+
+/* EHCI Queue Head */
+/* Align to 32-byte boundaries */
+/* QH allocation is made in the similar/same way as in OHCI driver,
+ * because unlninking QH from the Asynchronous list is not so
+ * trivial as on UHCI (at least it is time consuming) */
+struct grub_ehci_qh
+{
+ /* EHCI HW part */
+ grub_uint32_t qh_hptr; /* Horiz. pointer & Terminate */
+ grub_uint32_t ep_char; /* EP characteristics */
+ grub_uint32_t ep_cap; /* EP capabilities */
+ grub_uint32_t td_current; /* current TD link pointer */
+ struct grub_ehci_td td_overlay; /* TD overlay area = 64 bytes */
+ /* EHCI driver part */
+ grub_uint32_t pad[4]; /* padding to some multiple of 32 bytes */
+};
+
+/* EHCI Periodic Frame Span Traversal Node */
+/* Currently not supported */
+
+struct grub_ehci
+{
+ volatile grub_uint32_t *iobase_ehcc; /* Capability registers */
+ volatile grub_uint32_t *iobase; /* Operational registers */
+ struct grub_pci_dma_chunk *framelist_chunk; /* Currently not used */
+ volatile grub_uint32_t *framelist_virt;
+ grub_uint32_t framelist_phys;
+ struct grub_pci_dma_chunk *qh_chunk; /* GRUB_EHCI_N_QH Queue Heads */
+ grub_ehci_qh_t qh_virt;
+ grub_uint32_t qh_phys;
+ struct grub_pci_dma_chunk *td_chunk; /* GRUB_EHCI_N_TD Transfer Descriptors */
+ grub_ehci_td_t td_virt;
+ grub_uint32_t td_phys;
+ grub_ehci_td_t tdfree_virt; /* Free Transfer Descriptors */
+ int flag64;
+ grub_uint32_t reset; /* bits 1-15 are flags if port was reset from connected time or not */
+ struct grub_ehci *next;
+};
+
+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)
+{
+ return
+ grub_le_to_cpu32 (*((volatile grub_uint32_t *) e->iobase_ehcc +
+ (addr / sizeof (grub_uint32_t))));
+}
+
+static inline grub_uint16_t
+grub_ehci_ehcc_read16 (struct grub_ehci *e, grub_uint32_t addr)
+{
+ return
+ grub_le_to_cpu16 (*((volatile grub_uint16_t *) e->iobase_ehcc +
+ (addr / sizeof (grub_uint16_t))));
+}
+
+static inline grub_uint8_t
+grub_ehci_ehcc_read8 (struct grub_ehci *e, grub_uint32_t addr)
+{
+ return *((volatile grub_uint8_t *) e->iobase_ehcc + addr);
+}
+
+/* Operational registers access functions */
+static inline grub_uint32_t
+grub_ehci_oper_read32 (struct grub_ehci *e, grub_uint32_t addr)
+{
+ return
+ grub_le_to_cpu32 (*
+ ((volatile grub_uint32_t *) e->iobase +
+ (addr / sizeof (grub_uint32_t))));
+}
+
+static inline void
+grub_ehci_oper_write32 (struct grub_ehci *e, grub_uint32_t addr,
+ grub_uint32_t value)
+{
+ *((volatile grub_uint32_t *) e->iobase + (addr / sizeof (grub_uint32_t))) =
+ grub_cpu_to_le32 (value);
+}
+
+static inline grub_uint32_t
+grub_ehci_port_read (struct grub_ehci *e, grub_uint32_t port)
+{
+ return grub_ehci_oper_read32 (e, GRUB_EHCI_PORT_STAT_CMD + port * 4);
+}
+
+static inline void
+grub_ehci_port_resbits (struct grub_ehci *e, grub_uint32_t port,
+ grub_uint32_t bits)
+{
+ grub_ehci_oper_write32 (e, GRUB_EHCI_PORT_STAT_CMD + port * 4,
+ grub_ehci_port_read (e,
+ port) & GRUB_EHCI_PORT_WMASK &
+ ~(bits));
+ grub_ehci_port_read (e, port);
+}
+
+static inline void
+grub_ehci_port_setbits (struct grub_ehci *e, grub_uint32_t port,
+ grub_uint32_t bits)
+{
+ grub_ehci_oper_write32 (e, GRUB_EHCI_PORT_STAT_CMD + port * 4,
+ (grub_ehci_port_read (e, port) &
+ GRUB_EHCI_PORT_WMASK) | bits);
+ grub_ehci_port_read (e, port);
+}
+
+/* Halt if EHCI HC not halted */
+static grub_usb_err_t
+grub_ehci_halt (struct grub_ehci *e)
+{
+ grub_uint64_t maxtime;
+
+ if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS) & GRUB_EHCI_ST_HC_HALTED) == 0) /* EHCI is not halted */
+ {
+ /* Halt EHCI */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
+ ~GRUB_EHCI_CMD_RUNSTOP
+ & grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+ /* Ensure command is written */
+ grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND);
+ maxtime = grub_get_time_ms () + 1000; /* Fix: Should be 2ms ! */
+ while (((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)
+ & GRUB_EHCI_ST_HC_HALTED) == 0)
+ && (grub_get_time_ms () < maxtime));
+ if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)
+ & GRUB_EHCI_ST_HC_HALTED) == 0)
+ return GRUB_USB_ERR_TIMEOUT;
+ }
+
+ return GRUB_USB_ERR_NONE;
+}
+
+/* EHCI HC reset */
+static grub_usb_err_t
+grub_ehci_reset (struct grub_ehci *e)
+{
+ grub_uint64_t maxtime;
+
+ sync_all_caches (e);
+
+ grub_dprintf ("ehci", "reset\n");
+
+ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
+ GRUB_EHCI_CMD_HC_RESET);
+ /* Ensure command is written */
+ grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND);
+ /* XXX: How long time could take reset of HC ? */
+ maxtime = grub_get_time_ms () + 1000;
+ while (((grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)
+ & GRUB_EHCI_CMD_HC_RESET) != 0)
+ && (grub_get_time_ms () < maxtime));
+ if ((grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)
+ & GRUB_EHCI_CMD_HC_RESET) != 0)
+ return GRUB_USB_ERR_TIMEOUT;
+
+ return GRUB_USB_ERR_NONE;
+}
+
+/* PCI iteration function... */
+void
+grub_ehci_init_device (volatile void *regs)
+{
+ struct grub_ehci *e;
+ grub_uint32_t fp;
+ int i;
+ grub_uint32_t n_ports;
+ grub_uint8_t caplen;
+
+ /* Allocate memory for the controller and fill basic values. */
+ e = grub_zalloc (sizeof (*e));
+ if (!e)
+ return;
+ e->framelist_chunk = NULL;
+ e->td_chunk = NULL;
+ e->qh_chunk = NULL;
+ e->iobase_ehcc = regs;
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CAPLEN: %02x\n",
+ grub_ehci_ehcc_read8 (e, GRUB_EHCI_EHCC_CAPLEN));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: VERSION: %04x\n",
+ grub_ehci_ehcc_read16 (e, GRUB_EHCI_EHCC_VERSION));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: SPARAMS: %08x\n",
+ grub_ehci_ehcc_read32 (e, GRUB_EHCI_EHCC_SPARAMS));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CPARAMS: %08x\n",
+ grub_ehci_ehcc_read32 (e, GRUB_EHCI_EHCC_CPARAMS));
+
+ /* Determine base address of EHCI operational registers */
+ caplen = grub_ehci_ehcc_read8 (e, GRUB_EHCI_EHCC_CAPLEN);
+#ifndef GRUB_HAVE_UNALIGNED_ACCESS
+ if (caplen & (sizeof (grub_uint32_t) - 1))
+ {
+ grub_dprintf ("ehci", "Unaligned caplen\n");
+ return;
+ }
+ e->iobase = ((volatile grub_uint32_t *) e->iobase_ehcc
+ + (caplen / sizeof (grub_uint32_t)));
+#else
+ e->iobase = (volatile grub_uint32_t *)
+ ((grub_uint8_t *) e->iobase_ehcc + caplen);
+#endif
+
+ grub_dprintf ("ehci",
+ "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08llxx\n",
+ (unsigned long long) (grub_addr_t) e->iobase_ehcc + caplen);
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: COMMAND: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: STATUS: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: INTERRUPT: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_INTERRUPT));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: FRAME_INDEX: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_FRAME_INDEX));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: FL_BASE: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_FL_BASE));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CUR_AL_ADDR: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_CUR_AL_ADDR));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CONFIG_FLAG: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_CONFIG_FLAG));
+
+ /* Check format of data structures requested by EHCI */
+ /* XXX: In fact it is not used at any place, it is prepared for future
+ * This implementation uses 32-bits pointers only */
+ e->flag64 = ((grub_ehci_ehcc_read32 (e, GRUB_EHCI_EHCC_CPARAMS)
+ & GRUB_EHCI_CPARAMS_64BIT) != 0);
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: flag64=%d\n", e->flag64);
+
+ /* Reserve a page for the frame list - it is accurate for max.
+ * possible size of framelist. But currently it is not used. */
+ e->framelist_chunk = grub_memalign_dma32 (4096, 4096);
+ if (!e->framelist_chunk)
+ goto fail;
+ e->framelist_virt = grub_dma_get_virt (e->framelist_chunk);
+ e->framelist_phys = grub_dma_get_phys (e->framelist_chunk);
+ grub_memset ((void *) e->framelist_virt, 0, 4096);
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: framelist mem=%p. OK\n",
+ e->framelist_virt);
+
+ /* Allocate memory for the QHs and register it in "e". */
+ e->qh_chunk = grub_memalign_dma32 (4096,
+ sizeof (struct grub_ehci_qh) *
+ GRUB_EHCI_N_QH);
+ if (!e->qh_chunk)
+ goto fail;
+ e->qh_virt = (grub_ehci_qh_t) grub_dma_get_virt (e->qh_chunk);
+ e->qh_phys = grub_dma_get_phys (e->qh_chunk);
+ grub_memset ((void *) e->qh_virt, 0,
+ sizeof (struct grub_ehci_qh) * GRUB_EHCI_N_QH);
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: QH mem=%p. OK\n",
+ e->qh_virt);
+
+ /* Allocate memory for the TDs and register it in "e". */
+ e->td_chunk = grub_memalign_dma32 (4096,
+ sizeof (struct grub_ehci_td) *
+ GRUB_EHCI_N_TD);
+ if (!e->td_chunk)
+ goto fail;
+ e->td_virt = (grub_ehci_td_t) grub_dma_get_virt (e->td_chunk);
+ e->td_phys = grub_dma_get_phys (e->td_chunk);
+ grub_memset ((void *) e->td_virt, 0,
+ sizeof (struct grub_ehci_td) * GRUB_EHCI_N_TD);
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: TD mem=%p. OK\n",
+ e->td_virt);
+
+ /* Setup all frame list pointers. Since no isochronous transfers
+ are supported, they all point to the (same!) queue
+ head with index 0. */
+ fp = grub_cpu_to_le32 ((e->qh_phys & GRUB_EHCI_POINTER_MASK)
+ | GRUB_EHCI_HPTR_TYPE_QH);
+ for (i = 0; i < GRUB_EHCI_N_FRAMELIST; i++)
+ e->framelist_virt[i] = fp;
+ /* Prepare chain of all TDs and set Terminate in all TDs */
+ 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_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_compile_time (GRUB_EHCI_TERMINATE);
+ e->td_virt[GRUB_EHCI_N_TD - 1].alt_next_td =
+ 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_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_compile_time (GRUB_EHCI_TERMINATE);
+ /* Also set Halted bit in token */
+ 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_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 */
+ for (i = 1; i < GRUB_EHCI_N_QH; i++)
+ {
+ e->qh_virt[i].qh_hptr =
+ grub_cpu_to_le32 ((grub_dma_virt2phys (&e->qh_virt[i],
+ e->qh_chunk) &
+ GRUB_EHCI_POINTER_MASK) | GRUB_EHCI_HPTR_TYPE_QH);
+ e->qh_virt[i].td_overlay.next_td =
+ grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
+ e->qh_virt[i].td_overlay.alt_next_td =
+ 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_compile_time (GRUB_EHCI_STATUS_HALTED);
+ }
+
+ /* Note: QH 0 and QH 1 are reserved and must not be used anywhere.
+ * QH 0 is used as empty QH for framelist
+ * QH 1 is used as starting empty QH for asynchronous schedule
+ * QH 1 must exist at any time because at least one QH linked to
+ * itself must exist in asynchronous schedule
+ * QH 1 has the H flag set to one */
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: QH/TD init. OK\n");
+
+ /* Now we can setup EHCI (maybe...) */
+
+ /* Check if EHCI is halted and halt it if not */
+ if (grub_ehci_halt (e) != GRUB_USB_ERR_NONE)
+ {
+ grub_error (GRUB_ERR_TIMEOUT,
+ "EHCI grub_ehci_pci_iter: EHCI halt timeout");
+ goto fail;
+ }
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: halted OK\n");
+
+ /* Reset EHCI */
+ if (grub_ehci_reset (e) != GRUB_USB_ERR_NONE)
+ {
+ grub_error (GRUB_ERR_TIMEOUT,
+ "EHCI grub_ehci_pci_iter: EHCI reset timeout");
+ goto fail;
+ }
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: reset OK\n");
+
+ /* Setup list address registers */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_FL_BASE, e->framelist_phys);
+ grub_ehci_oper_write32 (e, GRUB_EHCI_CUR_AL_ADDR,
+ grub_dma_virt2phys (&e->qh_virt[1],
+ e->qh_chunk));
+
+ /* Set ownership of root hub ports to EHCI */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_CONFIG_FLAG, GRUB_EHCI_CF_EHCI_OWNER);
+
+ /* Enable both lists */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
+ GRUB_EHCI_CMD_AS_ENABL
+ | GRUB_EHCI_CMD_PS_ENABL
+ | grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+
+ /* Now should be possible to power-up and enumerate ports etc. */
+ if ((grub_ehci_ehcc_read32 (e, GRUB_EHCI_EHCC_SPARAMS)
+ & GRUB_EHCI_SPARAMS_PPC) != 0)
+ { /* EHCI has port powering control */
+ /* Power on all ports */
+ n_ports = grub_ehci_ehcc_read32 (e, GRUB_EHCI_EHCC_SPARAMS)
+ & GRUB_EHCI_SPARAMS_N_PORTS;
+ for (i = 0; i < (int) n_ports; i++)
+ grub_ehci_oper_write32 (e, GRUB_EHCI_PORT_STAT_CMD + i * 4,
+ GRUB_EHCI_PORT_POWER
+ | grub_ehci_oper_read32 (e,
+ GRUB_EHCI_PORT_STAT_CMD
+ + i * 4));
+ }
+
+ /* Ensure all commands are written */
+ grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND);
+
+ /* Enable EHCI */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
+ GRUB_EHCI_CMD_RUNSTOP
+ | grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+
+ /* Ensure command is written */
+ grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND);
+
+ /* Link to ehci now that initialisation is successful. */
+ e->next = ehci;
+ ehci = e;
+
+ sync_all_caches (e);
+
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: OK at all\n");
+
+ grub_dprintf ("ehci",
+ "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08llx\n",
+ (unsigned long long) (grub_addr_t) regs);
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: COMMAND: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: STATUS: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: INTERRUPT: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_INTERRUPT));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: FRAME_INDEX: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_FRAME_INDEX));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: FL_BASE: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_FL_BASE));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CUR_AL_ADDR: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_CUR_AL_ADDR));
+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CONFIG_FLAG: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_CONFIG_FLAG));
+
+ return;
+
+fail:
+ if (e)
+ {
+ if (e->td_chunk)
+ grub_dma_free ((void *) e->td_chunk);
+ if (e->qh_chunk)
+ grub_dma_free ((void *) e->qh_chunk);
+ if (e->framelist_chunk)
+ grub_dma_free (e->framelist_chunk);
+ }
+ grub_free (e);
+
+ return;
+}
+
+static int
+grub_ehci_iterate (grub_usb_controller_iterate_hook_t hook, void *hook_data)
+{
+ struct grub_ehci *e;
+ struct grub_usb_controller dev;
+
+ for (e = ehci; e; e = e->next)
+ {
+ dev.data = e;
+ if (hook (&dev, hook_data))
+ return 1;
+ }
+
+ return 0;
+}
+
+static void
+grub_ehci_setup_qh (grub_ehci_qh_t qh, grub_usb_transfer_t transfer)
+{
+ grub_uint32_t ep_char = 0;
+ grub_uint32_t ep_cap = 0;
+
+ /* Note: Another part of code is responsible to this QH is
+ * Halted ! But it can be linked in AL, so we cannot erase or
+ * change qh_hptr ! */
+ /* We will not change any TD field because they should/must be
+ * in safe state from previous use. */
+
+ /* EP characteristic setup */
+ /* Currently not used NAK counter (RL=0),
+ * C bit set if EP is not HIGH speed and is control,
+ * Max Packet Length is taken from transfer structure,
+ * H bit = 0 (because QH[1] has this bit set),
+ * DTC bit set to 1 because we are using our own toggle bit control,
+ * SPEED is selected according to value from transfer structure,
+ * EP number is taken from transfer structure
+ * "I" bit must not be set,
+ * Device Address is taken from transfer structure
+ * */
+ if ((transfer->dev->speed != GRUB_USB_SPEED_HIGH)
+ && (transfer->type == GRUB_USB_TRANSACTION_TYPE_CONTROL))
+ ep_char |= GRUB_EHCI_C;
+ ep_char |= (transfer->max << GRUB_EHCI_MAXPLEN_OFF)
+ & GRUB_EHCI_MAXPLEN_MASK;
+ ep_char |= GRUB_EHCI_DTC;
+ switch (transfer->dev->speed)
+ {
+ case GRUB_USB_SPEED_LOW:
+ ep_char |= GRUB_EHCI_SPEED_LOW;
+ break;
+ case GRUB_USB_SPEED_FULL:
+ ep_char |= GRUB_EHCI_SPEED_FULL;
+ break;
+ case GRUB_USB_SPEED_HIGH:
+ default:
+ ep_char |= GRUB_EHCI_SPEED_HIGH;
+ /* XXX: How we will handle unknown value of speed? */
+ }
+ ep_char |= (transfer->endpoint << GRUB_EHCI_EP_NUM_OFF)
+ & GRUB_EHCI_EP_NUM_MASK;
+ ep_char |= transfer->devaddr & GRUB_EHCI_DEVADDR_MASK;
+ qh->ep_char = grub_cpu_to_le32 (ep_char);
+ /* EP capabilities setup */
+ /* MULT field - we try to use max. number
+ * PortNumber - included now in device structure referenced
+ * inside transfer structure
+ * HubAddress - included now in device structure referenced
+ * inside transfer structure
+ * SplitCompletionMask - AFAIK it is ignored in asynchronous list,
+ * InterruptScheduleMask - AFAIK it should be zero in async. list */
+ ep_cap |= GRUB_EHCI_MULT_THREE;
+ ep_cap |= (transfer->dev->split_hubport << GRUB_EHCI_DEVPORT_OFF)
+ & GRUB_EHCI_DEVPORT_MASK;
+ ep_cap |= (transfer->dev->split_hubaddr << GRUB_EHCI_HUBADDR_OFF)
+ & GRUB_EHCI_HUBADDR_MASK;
+ if (transfer->dev->speed == GRUB_USB_SPEED_LOW
+ && transfer->type != GRUB_USB_TRANSACTION_TYPE_CONTROL)
+ {
+ ep_cap |= (1<<0) << GRUB_EHCI_SMASK_OFF;
+ ep_cap |= (7<<2) << GRUB_EHCI_CMASK_OFF;
+ }
+ qh->ep_cap = grub_cpu_to_le32 (ep_cap);
+
+ grub_dprintf ("ehci", "setup_qh: qh=%p, not changed: qh_hptr=%08x\n",
+ qh, grub_le_to_cpu32 (qh->qh_hptr));
+ grub_dprintf ("ehci", "setup_qh: ep_char=%08x, ep_cap=%08x\n",
+ ep_char, ep_cap);
+ grub_dprintf ("ehci", "setup_qh: end\n");
+ grub_dprintf ("ehci", "setup_qh: not changed: td_current=%08x\n",
+ grub_le_to_cpu32 (qh->td_current));
+ grub_dprintf ("ehci", "setup_qh: not changed: next_td=%08x\n",
+ grub_le_to_cpu32 (qh->td_overlay.next_td));
+ grub_dprintf ("ehci", "setup_qh: not changed: alt_next_td=%08x\n",
+ grub_le_to_cpu32 (qh->td_overlay.alt_next_td));
+ grub_dprintf ("ehci", "setup_qh: not changed: token=%08x\n",
+ grub_le_to_cpu32 (qh->td_overlay.token));
+}
+
+static grub_ehci_qh_t
+grub_ehci_find_qh (struct grub_ehci *e, grub_usb_transfer_t transfer)
+{
+ grub_uint32_t target, mask;
+ int i;
+ grub_ehci_qh_t qh = e->qh_virt;
+ grub_ehci_qh_t head;
+ grub_uint32_t qh_phys;
+ grub_uint32_t qh_terminate =
+ GRUB_EHCI_TERMINATE | GRUB_EHCI_HPTR_TYPE_QH;
+ grub_ehci_qh_t qh_iter;
+
+ /* Prepare part of EP Characteristic to find existing QH */
+ 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_compile_time (GRUB_EHCI_TARGET_MASK);
+
+ /* low speed interrupt transfers are linked to the periodic */
+ /* schedule, everything else to the asynchronous schedule */
+ if (transfer->dev->speed == GRUB_USB_SPEED_LOW
+ && transfer->type != GRUB_USB_TRANSACTION_TYPE_CONTROL)
+ head = &qh[0];
+ else
+ head = &qh[1];
+
+ /* First try to find existing QH with proper target in proper list */
+ qh_phys = grub_le_to_cpu32( head->qh_hptr );
+ if (qh_phys != qh_terminate)
+ qh_iter = grub_dma_phys2virt ( qh_phys & GRUB_EHCI_QHTDPTR_MASK,
+ e->qh_chunk );
+ else
+ qh_iter = NULL;
+
+ for (
+ i = 0;
+ (qh_phys != qh_terminate) && (qh_iter != NULL) &&
+ (qh_iter != head) && (i < GRUB_EHCI_N_QH);
+ i++ )
+ {
+ if (target == (qh_iter->ep_char & mask))
+ {
+ /* 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;
+ }
+
+ qh_phys = grub_le_to_cpu32( qh_iter->qh_hptr );
+ if (qh_phys != qh_terminate)
+ qh_iter = grub_dma_phys2virt ( qh_phys & GRUB_EHCI_QHTDPTR_MASK,
+ e->qh_chunk );
+ else
+ qh_iter = NULL;
+ }
+
+ /* variable "i" should be never equal to GRUB_EHCI_N_QH here */
+ if (i >= GRUB_EHCI_N_QH)
+ { /* Something very bad happened in QH list(s) ! */
+ grub_dprintf ("ehci", "find_qh: Mismatch in QH list! head=%p\n",
+ head);
+ }
+
+ /* QH with target_addr does not exist, we have to find and add it */
+ for (i = 2; i < GRUB_EHCI_N_QH; i++) /* We ignore zero and first QH */
+ {
+ if (!qh[i].ep_char)
+ break; /* Found first not-allocated QH, finish */
+ }
+
+ /* Have we any free QH in array ? */
+ if (i >= GRUB_EHCI_N_QH) /* No. */
+ {
+ grub_dprintf ("ehci", "find_qh: end - no free QH\n");
+ return NULL;
+ }
+ grub_dprintf ("ehci", "find_qh: new, i=%d, QH=%p\n",
+ i, &qh[i]);
+ /* Currently we simply take next (current) QH in array, no allocation
+ * function is used. It should be no problem until we will need to
+ * de-allocate QHs of unplugged devices. */
+ /* We should preset new QH and link it into AL */
+ grub_ehci_setup_qh (&qh[i], transfer);
+
+ /* Linking - this new (last) QH will copy the QH from the head QH */
+ qh[i].qh_hptr = head->qh_hptr;
+ /* Linking - the head QH will point to this new QH */
+ head->qh_hptr = grub_cpu_to_le32 (GRUB_EHCI_HPTR_TYPE_QH
+ | grub_dma_virt2phys (&qh[i],
+ e->qh_chunk));
+
+ return &qh[i];
+}
+
+static grub_ehci_td_t
+grub_ehci_alloc_td (struct grub_ehci *e)
+{
+ grub_ehci_td_t ret;
+
+ /* Check if there is a Transfer Descriptor available. */
+ if (!e->tdfree_virt)
+ {
+ grub_dprintf ("ehci", "alloc_td: end - no free TD\n");
+ return NULL;
+ }
+
+ ret = e->tdfree_virt; /* Take current free TD */
+ /* Advance to next free TD in chain */
+ if (ret->link_td)
+ e->tdfree_virt = grub_dma_phys2virt (ret->link_td, e->td_chunk);
+ else
+ e->tdfree_virt = NULL;
+ ret->link_td = 0; /* Reset link_td in allocated TD */
+ return ret;
+}
+
+static void
+grub_ehci_free_td (struct grub_ehci *e, grub_ehci_td_t td)
+{
+ /* Chain new free TD & rest */
+ if (e->tdfree_virt)
+ td->link_td = grub_dma_virt2phys (e->tdfree_virt, e->td_chunk);
+ else
+ td->link_td = 0;
+ e->tdfree_virt = td; /* Change address of first free TD */
+}
+
+static void
+grub_ehci_free_tds (struct grub_ehci *e, grub_ehci_td_t td,
+ grub_usb_transfer_t transfer, grub_size_t * actual)
+{
+ int i; /* Index of TD in transfer */
+ grub_uint32_t token, to_transfer;
+
+ /* Note: Another part of code is responsible to this QH is
+ * INACTIVE ! */
+ *actual = 0;
+
+ /* Free the TDs in this queue and set last_trans. */
+ for (i = 0; td; i++)
+ {
+ grub_ehci_td_t tdprev;
+
+ 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 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))
+ transfer->last_trans = i;
+
+ *actual += td->size - to_transfer;
+
+ /* Unlink the TD */
+ tdprev = td;
+ if (td->link_td)
+ td = grub_dma_phys2virt (td->link_td, e->td_chunk);
+ else
+ td = NULL;
+
+ /* Free the TD. */
+ grub_ehci_free_td (e, tdprev);
+ }
+
+ /* Check if last_trans was set. If not and something was
+ * transferred (it should be all data in this case), set it
+ * to index of last TD, i.e. i-1 */
+ if (transfer && (transfer->last_trans < 0) && (*actual != 0))
+ transfer->last_trans = i - 1;
+
+ /* XXX: Fix it: last_trans may be set to bad index.
+ * Probably we should test more error flags to distinguish
+ * if TD was at least partialy executed or not at all.
+ * Generaly, we still could have problem with toggling because
+ * EHCI can probably split transactions into smaller parts then
+ * we defined in transaction even if we did not exceed MaxFrame
+ * length - it probably could happen at the end of microframe (?)
+ * and if the buffer is crossing page boundary (?). */
+}
+
+static grub_ehci_td_t
+grub_ehci_transaction (struct grub_ehci *e,
+ grub_transfer_type_t type,
+ unsigned int toggle, grub_size_t size,
+ grub_uint32_t data, grub_ehci_td_t td_alt)
+{
+ grub_ehci_td_t td;
+ grub_uint32_t token;
+ grub_uint32_t bufadr;
+ int i;
+
+ /* Test of transfer size, it can be:
+ * <= GRUB_EHCI_MAXBUFLEN if data aligned to page boundary
+ * <= GRUB_EHCI_MAXBUFLEN - GRUB_EHCI_BUFPAGELEN if not aligned
+ * (worst case)
+ */
+ if ((((data % GRUB_EHCI_BUFPAGELEN) == 0)
+ && (size > GRUB_EHCI_MAXBUFLEN))
+ ||
+ (((data % GRUB_EHCI_BUFPAGELEN) != 0)
+ && (size > (GRUB_EHCI_MAXBUFLEN - GRUB_EHCI_BUFPAGELEN))))
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "too long data buffer for EHCI transaction");
+ return 0;
+ }
+
+ /* Grab a free Transfer Descriptor and initialize it. */
+ td = grub_ehci_alloc_td (e);
+ if (!td)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "no transfer descriptors available for EHCI transfer");
+ return 0;
+ }
+
+ grub_dprintf ("ehci",
+ "transaction: type=%d, toggle=%d, size=%lu data=0x%x td=%p\n",
+ type, toggle, (unsigned long) size, data, td);
+
+ /* Fill whole TD by zeros */
+ 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_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
+ * until QH is halted. */
+ td->alt_next_td = grub_cpu_to_le32 (grub_dma_virt2phys (td_alt,
+ e->td_chunk));
+ /* token:
+ * TOGGLE - according to toggle
+ * TOTAL SIZE = size
+ * Interrupt On Complete = FALSE, we don't need IRQ
+ * Current Page = 0
+ * Error Counter = max. value = 3
+ * PID Code - according to type
+ * STATUS:
+ * ACTIVE bit should be set to one
+ * SPLIT TRANS. STATE bit should be zero. It is ignored
+ * in HIGH speed transaction, and should be zero for LOW/FULL
+ * speed to indicate state Do Split Transaction */
+ token = toggle ? GRUB_EHCI_TOGGLE : 0;
+ token |= (size << GRUB_EHCI_TOTAL_OFF) & GRUB_EHCI_TOTAL_MASK;
+ token |= GRUB_EHCI_CERR_3;
+ switch (type)
+ {
+ case GRUB_USB_TRANSFER_TYPE_IN:
+ token |= GRUB_EHCI_PIDCODE_IN;
+ break;
+ case GRUB_USB_TRANSFER_TYPE_OUT:
+ token |= GRUB_EHCI_PIDCODE_OUT;
+ break;
+ case GRUB_USB_TRANSFER_TYPE_SETUP:
+ token |= GRUB_EHCI_PIDCODE_SETUP;
+ break;
+ default: /* XXX: Should not happen, but what to do if it does ? */
+ break;
+ }
+ token |= GRUB_EHCI_STATUS_ACTIVE;
+ td->token = grub_cpu_to_le32 (token);
+
+ /* Fill buffer pointers according to size */
+ bufadr = data;
+ td->buffer_page[0] = grub_cpu_to_le32 (bufadr);
+ bufadr = ((bufadr / GRUB_EHCI_BUFPAGELEN) + 1) * GRUB_EHCI_BUFPAGELEN;
+ for (i = 1; ((bufadr - data) < size) && (i < GRUB_EHCI_TD_BUF_PAGES); i++)
+ {
+ td->buffer_page[i] = grub_cpu_to_le32 (bufadr & GRUB_EHCI_BUFPTR_MASK);
+ bufadr = ((bufadr / GRUB_EHCI_BUFPAGELEN) + 1) * GRUB_EHCI_BUFPAGELEN;
+ }
+
+ /* Remember data size for future use... */
+ td->size = (grub_uint32_t) size;
+
+ grub_dprintf ("ehci", "td=%p\n", td);
+ grub_dprintf ("ehci", "HW: next_td=%08x, alt_next_td=%08x\n",
+ grub_le_to_cpu32 (td->next_td),
+ grub_le_to_cpu32 (td->alt_next_td));
+ grub_dprintf ("ehci", "HW: token=%08x, buffer[0]=%08x\n",
+ grub_le_to_cpu32 (td->token),
+ grub_le_to_cpu32 (td->buffer_page[0]));
+ grub_dprintf ("ehci", "HW: buffer[1]=%08x, buffer[2]=%08x\n",
+ grub_le_to_cpu32 (td->buffer_page[1]),
+ grub_le_to_cpu32 (td->buffer_page[2]));
+ grub_dprintf ("ehci", "HW: buffer[3]=%08x, buffer[4]=%08x\n",
+ grub_le_to_cpu32 (td->buffer_page[3]),
+ grub_le_to_cpu32 (td->buffer_page[4]));
+ grub_dprintf ("ehci", "link_td=%08x, size=%08x\n",
+ td->link_td, td->size);
+
+ return td;
+}
+
+struct grub_ehci_transfer_controller_data
+{
+ grub_ehci_qh_t qh_virt;
+ grub_ehci_td_t td_first_virt;
+ grub_ehci_td_t td_alt_virt;
+ grub_ehci_td_t td_last_virt;
+ grub_uint32_t td_last_phys;
+};
+
+static grub_usb_err_t
+grub_ehci_setup_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer)
+{
+ struct grub_ehci *e = (struct grub_ehci *) dev->data;
+ grub_ehci_td_t td = NULL;
+ 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 */
+ 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 */
+ {
+ 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 */
+ {
+ 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));
+ if (!cdata)
+ return GRUB_USB_ERR_INTERNAL;
+ cdata->td_first_virt = NULL;
+
+ /* Allocate a queue head for the transfer queue. */
+ 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;
+ }
+
+ /* To detect short packet we need some additional "alternate" TD,
+ * allocate it first. */
+ 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_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++)
+ {
+ grub_usb_transaction_t tr = &transfer->transactions[i];
+
+ td = grub_ehci_transaction (e, tr->pid, tr->toggle, tr->size,
+ tr->data, cdata->td_alt_virt);
+
+ if (!td) /* de-allocate and free all */
+ {
+ grub_size_t actual = 0;
+
+ if (cdata->td_first_virt)
+ 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;
+ }
+
+ /* Register new TD in cdata or previous TD */
+ if (!cdata->td_first_virt)
+ cdata->td_first_virt = td;
+ else
+ {
+ td_prev->link_td = grub_dma_virt2phys (td, e->td_chunk);
+ td_prev->next_td =
+ grub_cpu_to_le32 (grub_dma_virt2phys (td, e->td_chunk));
+ }
+ td_prev = td;
+ }
+
+ /* Remember last TD */
+ 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_compile_time (GRUB_EHCI_TERMINATE);
+
+ grub_dprintf ("ehci", "setup_transfer: cdata=%p, qh=%p\n",
+ cdata,cdata->qh_virt);
+ grub_dprintf ("ehci", "setup_transfer: td_first=%p, td_alt=%p\n",
+ cdata->td_first_virt,
+ cdata->td_alt_virt);
+ grub_dprintf ("ehci", "setup_transfer: td_last=%p\n",
+ cdata->td_last_virt);
+
+ /* Start transfer: */
+ /* Unlink possible alternate pointer in QH */
+ cdata->qh_virt->td_overlay.alt_next_td =
+ 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_compile_time (0);
+
+ sync_all_caches (e);
+
+ /* Finito */
+ transfer->controller_data = cdata;
+
+ return GRUB_USB_ERR_NONE;
+}
+
+/* This function expects QH is not active.
+ * Function set Halt bit in QH TD overlay and possibly prints
+ * necessary debug information. */
+static void
+grub_ehci_pre_finish_transfer (grub_usb_transfer_t transfer)
+{
+ struct grub_ehci_transfer_controller_data *cdata =
+ transfer->controller_data;
+
+ /* Collect debug data here if necessary */
+
+ /* Set Halt bit in not active QH. AL will not attempt to do
+ * Advance Queue on QH with Halt bit set, i.e., we can then
+ * safely manipulate with QH TD part. */
+ cdata->qh_virt->td_overlay.token = (cdata->qh_virt->td_overlay.token
+ |
+ grub_cpu_to_le32_compile_time
+ (GRUB_EHCI_STATUS_HALTED)) &
+ grub_cpu_to_le32_compile_time (~GRUB_EHCI_STATUS_ACTIVE);
+
+ /* Print debug data here if necessary */
+
+}
+
+static grub_usb_err_t
+grub_ehci_parse_notrun (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer, grub_size_t * actual)
+{
+ struct grub_ehci *e = dev->data;
+ struct grub_ehci_transfer_controller_data *cdata =
+ transfer->controller_data;
+
+ grub_dprintf ("ehci", "parse_notrun: info\n");
+
+ /* QH can be in any state in this case. */
+ /* But EHCI or AL is not running, so QH is surely not active
+ * even if it has Active bit set... */
+ grub_ehci_pre_finish_transfer (transfer);
+ 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);
+
+ /* Additionally, do something with EHCI to make it running (what?) */
+ /* Try enable EHCI and AL */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
+ GRUB_EHCI_CMD_RUNSTOP | GRUB_EHCI_CMD_AS_ENABL
+ | GRUB_EHCI_CMD_PS_ENABL
+ | grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+ /* Ensure command is written */
+ grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND);
+
+ return GRUB_USB_ERR_UNRECOVERABLE;
+}
+
+static grub_usb_err_t
+grub_ehci_parse_halt (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer, grub_size_t * actual)
+{
+ struct grub_ehci *e = dev->data;
+ struct grub_ehci_transfer_controller_data *cdata =
+ transfer->controller_data;
+ grub_uint32_t token;
+ grub_usb_err_t err = GRUB_USB_ERR_NAK;
+
+ /* QH should be halted and not active in this case. */
+
+ grub_dprintf ("ehci", "parse_halt: info\n");
+
+ /* Remember token before call pre-finish function */
+ token = grub_le_to_cpu32 (cdata->qh_virt->td_overlay.token);
+
+ /* Do things like in normal finish */
+ grub_ehci_pre_finish_transfer (transfer);
+ 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);
+
+ /* 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. */
+ if ((token & GRUB_EHCI_STATUS_BABBLE) != 0)
+ err = GRUB_USB_ERR_BABBLE;
+ else if ((token & GRUB_EHCI_CERR_MASK) != 0)
+ err = GRUB_USB_ERR_STALL;
+ else if ((token & GRUB_EHCI_STATUS_TRANERR) != 0)
+ err = GRUB_USB_ERR_DATA;
+ else if ((token & GRUB_EHCI_STATUS_BUFERR) != 0)
+ err = GRUB_USB_ERR_DATA;
+ else if ((token & GRUB_EHCI_STATUS_MISSDMF) != 0)
+ err = GRUB_USB_ERR_DATA;
+
+ return err;
+}
+
+static grub_usb_err_t
+grub_ehci_parse_success (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer, grub_size_t * actual)
+{
+ struct grub_ehci *e = dev->data;
+ struct grub_ehci_transfer_controller_data *cdata =
+ transfer->controller_data;
+
+ grub_dprintf ("ehci", "parse_success: info\n");
+
+ /* QH should be not active in this case, but it is not halted. */
+ grub_ehci_pre_finish_transfer (transfer);
+ 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);
+
+ return GRUB_USB_ERR_NONE;
+}
+
+
+static grub_usb_err_t
+grub_ehci_check_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer, grub_size_t * actual)
+{
+ struct grub_ehci *e = dev->data;
+ struct grub_ehci_transfer_controller_data *cdata =
+ 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),
+ cdata, cdata->qh_virt);
+ grub_dprintf ("ehci", "check_transfer: qh_hptr=%08x, ep_char=%08x\n",
+ grub_le_to_cpu32 (cdata->qh_virt->qh_hptr),
+ grub_le_to_cpu32 (cdata->qh_virt->ep_char));
+ grub_dprintf ("ehci", "check_transfer: ep_cap=%08x, td_current=%08x\n",
+ grub_le_to_cpu32 (cdata->qh_virt->ep_cap),
+ grub_le_to_cpu32 (cdata->qh_virt->td_current));
+ grub_dprintf ("ehci", "check_transfer: next_td=%08x, alt_next_td=%08x\n",
+ grub_le_to_cpu32 (cdata->qh_virt->td_overlay.next_td),
+ grub_le_to_cpu32 (cdata->qh_virt->td_overlay.alt_next_td));
+ grub_dprintf ("ehci", "check_transfer: token=%08x, buffer[0]=%08x\n",
+ grub_le_to_cpu32 (cdata->qh_virt->td_overlay.token),
+ grub_le_to_cpu32 (cdata->qh_virt->td_overlay.buffer_page[0]));
+
+ /* Check if EHCI is running and AL is enabled */
+ if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)
+ & GRUB_EHCI_ST_HC_HALTED) != 0)
+ return grub_ehci_parse_notrun (dev, transfer, actual);
+ if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)
+ & (GRUB_EHCI_ST_AS_STATUS | GRUB_EHCI_ST_PS_STATUS)) == 0)
+ return grub_ehci_parse_notrun (dev, transfer, actual);
+
+ token = grub_le_to_cpu32 (cdata->qh_virt->td_overlay.token);
+ /* If the transfer consist from only one TD, we should check */
+ /* if the TD was really executed and deactivated - to prevent */
+ /* false detection of transfer finish. */
+ token_ftd = grub_le_to_cpu32 (cdata->td_first_virt->token);
+
+ /* Detect QH halted */
+ if ((token & GRUB_EHCI_STATUS_HALTED) != 0)
+ return grub_ehci_parse_halt (dev, transfer, actual);
+
+ /* Detect QH not active - QH is not active and no next TD */
+ if (token && ((token & GRUB_EHCI_STATUS_ACTIVE) == 0)
+ && ((token_ftd & GRUB_EHCI_STATUS_ACTIVE) == 0))
+ {
+ /* It could be finish at all or short packet condition */
+ if ((grub_le_to_cpu32 (cdata->qh_virt->td_overlay.next_td)
+ & GRUB_EHCI_TERMINATE) &&
+ ((grub_le_to_cpu32 (cdata->qh_virt->td_current)
+ & GRUB_EHCI_QHTDPTR_MASK) == cdata->td_last_phys))
+ /* Normal finish */
+ return grub_ehci_parse_success (dev, transfer, actual);
+ else if ((token & GRUB_EHCI_TOTAL_MASK) != 0)
+ /* Short packet condition */
+ /* But currently we don't handle it - higher level will do it */
+ return grub_ehci_parse_success (dev, transfer, actual);
+ }
+
+ return GRUB_USB_ERR_WAIT;
+}
+
+static grub_usb_err_t
+grub_ehci_cancel_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer)
+{
+ struct grub_ehci *e = dev->data;
+ struct grub_ehci_transfer_controller_data *cdata =
+ transfer->controller_data;
+ grub_size_t actual;
+ 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;
+
+ /* QH can be active and should be de-activated and halted */
+
+ grub_dprintf ("ehci", "cancel_transfer: begin\n");
+
+ /* First check if EHCI is running - if not, there is no problem */
+ /* to cancel any transfer. Or, if transfer is asynchronous, check */
+ /* if AL is enabled - if not, transfer can be canceled also. */
+ if (((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS) &
+ GRUB_EHCI_ST_HC_HALTED) != 0) ||
+ (!interrupt && ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS) &
+ (GRUB_EHCI_ST_AS_STATUS | GRUB_EHCI_ST_PS_STATUS)) == 0)))
+ {
+ grub_ehci_pre_finish_transfer (transfer);
+ 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;
+ }
+
+ /* EHCI and (AL or SL) are running. What to do? */
+ /* Try to Halt QH via de-scheduling QH. */
+ /* Find index of previous QH */
+ qh_phys = grub_dma_virt2phys(cdata->qh_virt, e->qh_chunk);
+ for (i = 0; i < GRUB_EHCI_N_QH; i++)
+ {
+ if ((grub_le_to_cpu32(e->qh_virt[i].qh_hptr)
+ & GRUB_EHCI_QHTDPTR_MASK) == qh_phys)
+ break;
+ }
+ if (i == GRUB_EHCI_N_QH)
+ {
+ grub_printf ("%s: prev not found, queues are corrupt\n", __func__);
+ return GRUB_USB_ERR_UNRECOVERABLE;
+ }
+ /* 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. */
+ if (cdata->qh_virt->ep_cap & GRUB_EHCI_SMASK_MASK)
+ {
+ grub_millisleep(20);
+ }
+ else
+ {
+ /* For the asynchronous schedule we use the advance doorbell to find
+ * out when the EHCI controller has read the updated QH. */
+
+ /* Ring the doorbell */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
+ GRUB_EHCI_CMD_AS_ADV_D
+ | grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+ /* Ensure command is written */
+ grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND);
+ /* Wait answer with timeout */
+ maxtime = grub_get_time_ms () + 2;
+ while (((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)
+ & GRUB_EHCI_ST_AS_ADVANCE) == 0)
+ && (grub_get_time_ms () < maxtime));
+
+ /* We do not detect the timeout because if timeout occurs, it most
+ * probably means something wrong with EHCI - maybe stopped etc. */
+
+ /* Shut up the doorbell */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
+ ~GRUB_EHCI_CMD_AS_ADV_D
+ & grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+ grub_ehci_oper_write32 (e, GRUB_EHCI_STATUS,
+ GRUB_EHCI_ST_AS_ADVANCE
+ | grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS));
+ /* Ensure command is written */
+ grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS);
+ }
+
+ /* Now is QH out of AL and we can do anything with it... */
+ grub_ehci_pre_finish_transfer (transfer);
+ grub_ehci_free_tds (e, cdata->td_first_virt, transfer, &actual);
+ grub_ehci_free_td (e, cdata->td_alt_virt);
+
+ /* "Free" the QH - link it to itself */
+ cdata->qh_virt->ep_char = 0;
+ cdata->qh_virt->qh_hptr =
+ grub_cpu_to_le32 ((grub_dma_virt2phys (cdata->qh_virt,
+ e->qh_chunk)
+ & GRUB_EHCI_POINTER_MASK) | GRUB_EHCI_HPTR_TYPE_QH);
+
+ grub_free (cdata);
+
+ grub_dprintf ("ehci", "cancel_transfer: end\n");
+
+ sync_all_caches (e);
+
+ return GRUB_USB_ERR_NONE;
+}
+
+static int
+grub_ehci_hubports (grub_usb_controller_t dev)
+{
+ struct grub_ehci *e = (struct grub_ehci *) dev->data;
+ grub_uint32_t portinfo;
+
+ portinfo = grub_ehci_ehcc_read32 (e, GRUB_EHCI_EHCC_SPARAMS)
+ & GRUB_EHCI_SPARAMS_N_PORTS;
+ grub_dprintf ("ehci", "root hub ports=%d\n", portinfo);
+ return portinfo;
+}
+
+static grub_usb_err_t
+grub_ehci_portstatus (grub_usb_controller_t dev,
+ unsigned int port, unsigned int enable)
+{
+ struct grub_ehci *e = (struct grub_ehci *) dev->data;
+ grub_uint64_t endtime;
+
+ grub_dprintf ("ehci", "portstatus: EHCI STATUS: %08x\n",
+ grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS));
+ grub_dprintf ("ehci",
+ "portstatus: begin, iobase=%p, port=%d, status=0x%02x\n",
+ e->iobase, port, grub_ehci_port_read (e, port));
+
+ /* In any case we need to disable port:
+ * - if enable==false - we should disable port
+ * - if enable==true we will do the reset and the specification says
+ * PortEnable should be FALSE in such case */
+ /* Disable the port and wait for it. */
+ grub_ehci_port_resbits (e, port, GRUB_EHCI_PORT_ENABLED);
+ endtime = grub_get_time_ms () + 1000;
+ while (grub_ehci_port_read (e, port) & GRUB_EHCI_PORT_ENABLED)
+ if (grub_get_time_ms () > endtime)
+ return GRUB_USB_ERR_TIMEOUT;
+
+ if (!enable) /* We don't need reset port */
+ {
+ grub_dprintf ("ehci", "portstatus: Disabled.\n");
+ grub_dprintf ("ehci", "portstatus: end, status=0x%02x\n",
+ grub_ehci_port_read (e, port));
+ return GRUB_USB_ERR_NONE;
+ }
+
+ grub_dprintf ("ehci", "portstatus: enable\n");
+
+ grub_boot_time ("Resetting port %d", port);
+
+ /* Now we will do reset - if HIGH speed device connected, it will
+ * result in Enabled state, otherwise port remains disabled. */
+ /* Set RESET bit for 50ms */
+ grub_ehci_port_setbits (e, port, GRUB_EHCI_PORT_RESET);
+ grub_millisleep (50);
+
+ /* Reset RESET bit and wait for the end of reset */
+ grub_ehci_port_resbits (e, port, GRUB_EHCI_PORT_RESET);
+ endtime = grub_get_time_ms () + 1000;
+ while (grub_ehci_port_read (e, port) & GRUB_EHCI_PORT_RESET)
+ if (grub_get_time_ms () > endtime)
+ return GRUB_USB_ERR_TIMEOUT;
+ grub_boot_time ("Port %d reset", port);
+ /* Remember "we did the reset" - needed by detect_dev */
+ e->reset |= (1 << port);
+ /* Test if port enabled, i.e. HIGH speed device connected */
+ if ((grub_ehci_port_read (e, port) & GRUB_EHCI_PORT_ENABLED) != 0) /* yes! */
+ {
+ grub_dprintf ("ehci", "portstatus: Enabled!\n");
+ /* "Reset recovery time" (USB spec.) */
+ grub_millisleep (10);
+ }
+ else /* no... */
+ {
+ /* FULL speed device connected - change port ownership.
+ * It results in disconnected state of this EHCI port. */
+ grub_ehci_port_setbits (e, port, GRUB_EHCI_PORT_OWNER);
+ return GRUB_USB_ERR_BADDEVICE;
+ }
+
+ /* XXX: Fix it! There is possible problem - we can say to calling
+ * function that we lost device if it is FULL speed onlu via
+ * return value <> GRUB_ERR_NONE. It (maybe) displays also error
+ * message on screen - but this situation is not error, it is normal
+ * state! */
+
+ grub_dprintf ("ehci", "portstatus: end, status=0x%02x\n",
+ grub_ehci_port_read (e, port));
+
+ return GRUB_USB_ERR_NONE;
+}
+
+static grub_usb_speed_t
+grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
+{
+ struct grub_ehci *e = (struct grub_ehci *) dev->data;
+ grub_uint32_t status, line_state;
+
+ status = grub_ehci_port_read (e, port);
+
+ /* Connect Status Change bit - it detects change of connection */
+ if (status & GRUB_EHCI_PORT_CONNECT_CH)
+ {
+ *changed = 1;
+ /* Reset bit Connect Status Change */
+ grub_ehci_port_setbits (e, port, GRUB_EHCI_PORT_CONNECT_CH);
+ }
+ else
+ *changed = 0;
+
+ if (!(status & GRUB_EHCI_PORT_CONNECT))
+ { /* We should reset related "reset" flag in not connected state */
+ e->reset &= ~(1 << port);
+ return GRUB_USB_SPEED_NONE;
+ }
+ /* Detected connected state, so we should return speed.
+ * But we can detect only LOW speed device and only at connection
+ * time when PortEnabled=FALSE. FULL / HIGH speed detection is made
+ * later by EHCI-specific reset procedure.
+ * Another thing - if detected speed is LOW at connection time,
+ * we should change port ownership to companion controller.
+ * So:
+ * 1. If we detect connected and enabled and EHCI-owned port,
+ * we can say it is HIGH speed.
+ * 2. If we detect connected and not EHCI-owned port, we can say
+ * NONE speed, because such devices are not handled by EHCI.
+ * 3. If we detect connected, not enabled but reset port, we can say
+ * NONE speed, because it means FULL device connected to port and
+ * such devices are not handled by EHCI.
+ * 4. If we detect connected, not enabled and not reset port, which
+ * has line state != "K", we will say HIGH - it could be FULL or HIGH
+ * device, we will see it later after end of EHCI-specific reset
+ * procedure.
+ * 5. If we detect connected, not enabled and not reset port, which
+ * has line state == "K", we can say NONE speed, because LOW speed
+ * device is connected and we should change port ownership. */
+ if ((status & GRUB_EHCI_PORT_ENABLED) != 0) /* Port already enabled, return high speed. */
+ return GRUB_USB_SPEED_HIGH;
+ if ((status & GRUB_EHCI_PORT_OWNER) != 0) /* EHCI is not port owner */
+ return GRUB_USB_SPEED_NONE; /* EHCI driver is ignoring this port. */
+ if ((e->reset & (1 << port)) != 0) /* Port reset was done = FULL speed */
+ return GRUB_USB_SPEED_NONE; /* EHCI driver is ignoring this port. */
+ else /* Port connected but not enabled - test port speed. */
+ {
+ line_state = status & GRUB_EHCI_PORT_LINE_STAT;
+ if (line_state != GRUB_EHCI_PORT_LINE_LOWSP)
+ return GRUB_USB_SPEED_HIGH;
+ /* Detected LOW speed device, we should change
+ * port ownership.
+ * XXX: Fix it!: There should be test if related companion
+ * controler is available ! And what to do if it does not exist ? */
+ grub_ehci_port_setbits (e, port, GRUB_EHCI_PORT_OWNER);
+ return GRUB_USB_SPEED_NONE; /* Ignore this port */
+ /* Note: Reset of PORT_OWNER bit is done by EHCI HW when
+ * device is really disconnected from port.
+ * Don't do PORT_OWNER bit reset by SW when not connected signal
+ * is detected in port register ! */
+ }
+}
+
+static grub_err_t
+grub_ehci_restore_hw (void)
+{
+ struct grub_ehci *e;
+ grub_uint32_t n_ports;
+ int i;
+
+ /* We should re-enable all EHCI HW similarly as on inithw */
+ for (e = ehci; e; e = e->next)
+ {
+ /* Check if EHCI is halted and halt it if not */
+ if (grub_ehci_halt (e) != GRUB_USB_ERR_NONE)
+ grub_error (GRUB_ERR_TIMEOUT, "restore_hw: EHCI halt timeout");
+
+ /* Reset EHCI */
+ if (grub_ehci_reset (e) != GRUB_USB_ERR_NONE)
+ grub_error (GRUB_ERR_TIMEOUT, "restore_hw: EHCI reset timeout");
+
+ /* Setup some EHCI registers and enable EHCI */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_FL_BASE, e->framelist_phys);
+ grub_ehci_oper_write32 (e, GRUB_EHCI_CUR_AL_ADDR,
+ grub_dma_virt2phys (&e->qh_virt[1],
+ e->qh_chunk));
+ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
+ GRUB_EHCI_CMD_RUNSTOP |
+ grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+
+ /* Set ownership of root hub ports to EHCI */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_CONFIG_FLAG,
+ GRUB_EHCI_CF_EHCI_OWNER);
+
+ /* Enable asynchronous list */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
+ GRUB_EHCI_CMD_AS_ENABL
+ | GRUB_EHCI_CMD_PS_ENABL
+ | grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+
+ /* Now should be possible to power-up and enumerate ports etc. */
+ if ((grub_ehci_ehcc_read32 (e, GRUB_EHCI_EHCC_SPARAMS)
+ & GRUB_EHCI_SPARAMS_PPC) != 0)
+ { /* EHCI has port powering control */
+ /* Power on all ports */
+ n_ports = grub_ehci_ehcc_read32 (e, GRUB_EHCI_EHCC_SPARAMS)
+ & GRUB_EHCI_SPARAMS_N_PORTS;
+ for (i = 0; i < (int) n_ports; i++)
+ grub_ehci_oper_write32 (e, GRUB_EHCI_PORT_STAT_CMD + i * 4,
+ GRUB_EHCI_PORT_POWER
+ | grub_ehci_oper_read32 (e,
+ GRUB_EHCI_PORT_STAT_CMD
+ + i * 4));
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_ehci_fini_hw (int noreturn __attribute__ ((unused)))
+{
+ struct grub_ehci *e;
+
+ /* We should disable all EHCI HW to prevent any DMA access etc. */
+ for (e = ehci; e; e = e->next)
+ {
+ /* Disable both lists */
+ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
+ ~(GRUB_EHCI_CMD_AS_ENABL | GRUB_EHCI_CMD_PS_ENABL)
+ & grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
+
+ /* Check if EHCI is halted and halt it if not */
+ grub_ehci_halt (e);
+
+ /* Reset EHCI */
+ grub_ehci_reset (e);
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_usb_controller_dev usb_controller = {
+ .name = "ehci",
+ .iterate = grub_ehci_iterate,
+ .setup_transfer = grub_ehci_setup_transfer,
+ .check_transfer = grub_ehci_check_transfer,
+ .cancel_transfer = grub_ehci_cancel_transfer,
+ .hubports = grub_ehci_hubports,
+ .portstatus = grub_ehci_portstatus,
+ .detect_dev = grub_ehci_detect_dev,
+ /* estimated max. count of TDs for one bulk transfer */
+ .max_bulk_tds = GRUB_EHCI_N_TD * 3 / 4
+};
+
+GRUB_MOD_INIT (ehci)
+{
+ COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_td) == 64);
+ COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_qh) == 96);
+
+ grub_stop_disk_firmware ();
+
+ grub_boot_time ("Initing EHCI hardware");
+ grub_ehci_pci_scan ();
+ grub_boot_time ("Registering EHCI driver");
+ grub_usb_controller_dev_register (&usb_controller);
+ grub_boot_time ("EHCI driver registered");
+ grub_loader_register_preboot_hook (grub_ehci_fini_hw, grub_ehci_restore_hw,
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK);
+}
+
+GRUB_MOD_FINI (ehci)
+{
+ grub_ehci_fini_hw (0);
+ grub_usb_controller_dev_unregister (&usb_controller);
+}
diff --git a/grub-core/bus/usb/ohci.c b/grub-core/bus/usb/ohci.c
new file mode 100644
index 0000000..f0be533
--- /dev/null
+++ b/grub-core/bus/usb/ohci.c
@@ -0,0 +1,1468 @@
+/* ohci.c - OHCI Support. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/usb.h>
+#include <grub/usbtrans.h>
+#include <grub/misc.h>
+#include <grub/pci.h>
+#include <grub/cpu/pci.h>
+#include <grub/cpu/io.h>
+#include <grub/time.h>
+#include <grub/cs5536.h>
+#include <grub/loader.h>
+#include <grub/disk.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_ohci_hcca
+{
+ /* Pointers to Interrupt Endpoint Descriptors. Not used by
+ GRUB. */
+ grub_uint32_t inttable[32];
+
+ /* Current frame number. */
+ grub_uint16_t framenumber;
+
+ grub_uint16_t pad;
+
+ /* List of completed TDs. */
+ grub_uint32_t donehead;
+
+ grub_uint8_t reserved[116];
+} GRUB_PACKED;
+
+/* OHCI General Transfer Descriptor */
+struct grub_ohci_td
+{
+ /* Information used to construct the TOKEN packet. */
+ grub_uint32_t token;
+ grub_uint32_t buffer; /* LittleEndian physical address */
+ grub_uint32_t next_td; /* LittleEndian physical address */
+ grub_uint32_t buffer_end; /* LittleEndian physical address */
+ /* next values are not for OHCI HW */
+ volatile struct grub_ohci_td *link_td; /* pointer to next free/chained TD
+ * pointer as uint32 */
+ grub_uint32_t prev_td_phys; /* we need it to find previous TD
+ * physical address in CPU endian */
+ grub_uint32_t tr_index; /* index of TD in transfer */
+ grub_uint8_t pad[8 - sizeof (volatile struct grub_ohci_td *)]; /* padding to 32 bytes */
+} GRUB_PACKED;
+
+/* OHCI Endpoint Descriptor. */
+struct grub_ohci_ed
+{
+ grub_uint32_t target;
+ grub_uint32_t td_tail;
+ grub_uint32_t td_head;
+ grub_uint32_t next_ed;
+} GRUB_PACKED;
+
+typedef volatile struct grub_ohci_td *grub_ohci_td_t;
+typedef volatile struct grub_ohci_ed *grub_ohci_ed_t;
+
+/* Experimental change of ED/TD allocation */
+/* Little bit similar as in UHCI */
+/* Implementation assumes:
+ * 32-bits architecture - XXX: fix for 64-bits
+ * memory allocated by grub_memalign_dma32 must be continuous
+ * in virtual and also in physical memory */
+struct grub_ohci
+{
+ volatile grub_uint32_t *iobase;
+ volatile struct grub_ohci_hcca *hcca;
+ grub_uint32_t hcca_addr;
+ struct grub_pci_dma_chunk *hcca_chunk;
+ grub_ohci_ed_t ed_ctrl; /* EDs for CONTROL */
+ grub_uint32_t ed_ctrl_addr;
+ struct grub_pci_dma_chunk *ed_ctrl_chunk;
+ grub_ohci_ed_t ed_bulk; /* EDs for BULK */
+ grub_uint32_t ed_bulk_addr;
+ struct grub_pci_dma_chunk *ed_bulk_chunk;
+ grub_ohci_td_t td; /* TDs */
+ grub_uint32_t td_addr;
+ struct grub_pci_dma_chunk *td_chunk;
+ struct grub_ohci *next;
+ grub_ohci_td_t td_free; /* Pointer to first free TD */
+};
+
+static struct grub_ohci *ohci;
+
+typedef enum
+{
+ GRUB_OHCI_REG_REVISION = 0x00,
+ GRUB_OHCI_REG_CONTROL,
+ GRUB_OHCI_REG_CMDSTATUS,
+ GRUB_OHCI_REG_INTSTATUS,
+ GRUB_OHCI_REG_INTENA,
+ GRUB_OHCI_REG_INTDIS,
+ GRUB_OHCI_REG_HCCA,
+ GRUB_OHCI_REG_PERIODIC,
+ GRUB_OHCI_REG_CONTROLHEAD,
+ GRUB_OHCI_REG_CONTROLCURR,
+ GRUB_OHCI_REG_BULKHEAD,
+ GRUB_OHCI_REG_BULKCURR,
+ GRUB_OHCI_REG_DONEHEAD,
+ GRUB_OHCI_REG_FRAME_INTERVAL,
+ GRUB_OHCI_REG_PERIODIC_START = 16,
+ GRUB_OHCI_REG_RHUBA = 18,
+ GRUB_OHCI_REG_RHUBPORT = 21,
+ GRUB_OHCI_REG_LEGACY_CONTROL = 0x100,
+ GRUB_OHCI_REG_LEGACY_INPUT = 0x104,
+ GRUB_OHCI_REG_LEGACY_OUTPUT = 0x108,
+ GRUB_OHCI_REG_LEGACY_STATUS = 0x10c
+} grub_ohci_reg_t;
+
+#define GRUB_OHCI_RHUB_PORT_POWER_MASK 0x300
+#define GRUB_OHCI_RHUB_PORT_ALL_POWERED 0x200
+
+#define GRUB_OHCI_REG_FRAME_INTERVAL_FSMPS_MASK 0x8fff0000
+#define GRUB_OHCI_REG_FRAME_INTERVAL_FSMPS_SHIFT 16
+#define GRUB_OHCI_REG_FRAME_INTERVAL_FI_SHIFT 0
+
+/* XXX: Is this choice of timings sane? */
+#define GRUB_OHCI_FSMPS 0x2778
+#define GRUB_OHCI_PERIODIC_START 0x257f
+#define GRUB_OHCI_FRAME_INTERVAL 0x2edf
+
+#define GRUB_OHCI_SET_PORT_ENABLE (1 << 1)
+#define GRUB_OHCI_CLEAR_PORT_ENABLE (1 << 0)
+#define GRUB_OHCI_SET_PORT_RESET (1 << 4)
+#define GRUB_OHCI_SET_PORT_RESET_STATUS_CHANGE (1 << 20)
+
+#define GRUB_OHCI_REG_CONTROL_BULK_ENABLE (1 << 5)
+#define GRUB_OHCI_REG_CONTROL_CONTROL_ENABLE (1 << 4)
+
+#define GRUB_OHCI_RESET_CONNECT_CHANGE (1 << 16)
+#define GRUB_OHCI_CTRL_EDS 256
+#define GRUB_OHCI_BULK_EDS 510
+#define GRUB_OHCI_TDS 640
+
+#define GRUB_OHCI_ED_ADDR_MASK 0x7ff
+
+static inline grub_ohci_ed_t
+grub_ohci_ed_phys2virt (struct grub_ohci *o, int bulk, grub_uint32_t x)
+{
+ if (!x)
+ return NULL;
+ if (bulk)
+ return (grub_ohci_ed_t) (x - o->ed_bulk_addr
+ + (grub_uint8_t *) o->ed_bulk);
+ return (grub_ohci_ed_t) (x - o->ed_ctrl_addr
+ + (grub_uint8_t *) o->ed_ctrl);
+}
+
+static grub_uint32_t
+grub_ohci_virt_to_phys (struct grub_ohci *o, int bulk, grub_ohci_ed_t x)
+{
+ if (!x)
+ return 0;
+
+ if (bulk)
+ return (grub_uint8_t *) x - (grub_uint8_t *) o->ed_bulk + o->ed_bulk_addr;
+ return (grub_uint8_t *) x - (grub_uint8_t *) o->ed_ctrl + o->ed_ctrl_addr;
+}
+
+static inline grub_ohci_td_t
+grub_ohci_td_phys2virt (struct grub_ohci *o, grub_uint32_t x)
+{
+ if (!x)
+ return NULL;
+ return (grub_ohci_td_t) (x - o->td_addr + (grub_uint8_t *) o->td);
+}
+
+static grub_uint32_t
+grub_ohci_td_virt2phys (struct grub_ohci *o, grub_ohci_td_t x)
+{
+ if (!x)
+ return 0;
+ return (grub_uint8_t *)x - (grub_uint8_t *)o->td + o->td_addr;
+}
+
+
+static grub_uint32_t
+grub_ohci_readreg32 (struct grub_ohci *o, grub_ohci_reg_t reg)
+{
+ return grub_le_to_cpu32 (*(o->iobase + reg));
+}
+
+static void
+grub_ohci_writereg32 (struct grub_ohci *o,
+ grub_ohci_reg_t reg, grub_uint32_t val)
+{
+ *(o->iobase + reg) = grub_cpu_to_le32 (val);
+}
+
+
+
+/* Iterate over all PCI devices. Determine if a device is an OHCI
+ controller. If this is the case, initialize it. */
+static int
+grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ grub_uint32_t interf;
+ grub_uint32_t base;
+ grub_pci_address_t addr;
+ struct grub_ohci *o;
+ grub_uint32_t revision;
+ int j;
+
+ /* Determine IO base address. */
+ grub_dprintf ("ohci", "pciid = %x\n", pciid);
+
+ if (pciid == GRUB_CS5536_PCIID)
+ {
+ grub_uint64_t basereg;
+
+ basereg = grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_USB_OHCI_BASE);
+ if (!(basereg & GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE))
+ {
+ /* Shouldn't happen. */
+ grub_dprintf ("ohci", "No OHCI address is assigned\n");
+ return 0;
+ }
+ base = (basereg & GRUB_CS5536_MSR_USB_BASE_ADDR_MASK);
+ basereg |= GRUB_CS5536_MSR_USB_BASE_BUS_MASTER;
+ basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_ENABLED;
+ basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_STATUS;
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_OHCI_BASE, basereg);
+ }
+ else
+ {
+ grub_uint32_t class_code;
+ grub_uint32_t class;
+ grub_uint32_t subclass;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class_code = grub_pci_read (addr) >> 8;
+
+ interf = class_code & 0xFF;
+ subclass = (class_code >> 8) & 0xFF;
+ class = class_code >> 16;
+
+ /* If this is not an OHCI controller, just return. */
+ if (class != 0x0c || subclass != 0x03 || interf != 0x10)
+ return 0;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
+ base = grub_pci_read (addr);
+
+ base &= GRUB_PCI_ADDR_MEM_MASK;
+ if (!base)
+ {
+ grub_dprintf ("ehci",
+ "EHCI: EHCI is not mapper\n");
+ return 0;
+ }
+
+ /* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write_word(addr,
+ GRUB_PCI_COMMAND_MEM_ENABLED
+ | GRUB_PCI_COMMAND_BUS_MASTER
+ | grub_pci_read_word(addr));
+
+ grub_dprintf ("ohci", "class=0x%02x 0x%02x interface 0x%02x\n",
+ class, subclass, interf);
+ }
+
+ /* Allocate memory for the controller and register it. */
+ o = grub_malloc (sizeof (*o));
+ if (! o)
+ return 1;
+ grub_memset ((void*)o, 0, sizeof (*o));
+ o->iobase = grub_pci_device_map_range (dev, base, 0x800);
+
+ grub_dprintf ("ohci", "base=%p\n", o->iobase);
+
+ /* Reserve memory for the HCCA. */
+ o->hcca_chunk = grub_memalign_dma32 (256, 256);
+ if (! o->hcca_chunk)
+ goto fail;
+ o->hcca = grub_dma_get_virt (o->hcca_chunk);
+ o->hcca_addr = grub_dma_get_phys (o->hcca_chunk);
+ grub_memset ((void*)o->hcca, 0, sizeof(*o->hcca));
+ grub_dprintf ("ohci", "hcca: chunk=%p, virt=%p, phys=0x%02x\n",
+ o->hcca_chunk, o->hcca, o->hcca_addr);
+
+ /* Reserve memory for ctrl EDs. */
+ o->ed_ctrl_chunk = grub_memalign_dma32 (16, sizeof(struct grub_ohci_ed)
+ * GRUB_OHCI_CTRL_EDS);
+ if (! o->ed_ctrl_chunk)
+ goto fail;
+ o->ed_ctrl = grub_dma_get_virt (o->ed_ctrl_chunk);
+ o->ed_ctrl_addr = grub_dma_get_phys (o->ed_ctrl_chunk);
+ /* Preset EDs */
+ 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_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);
+
+ /* Reserve memory for bulk EDs. */
+ o->ed_bulk_chunk = grub_memalign_dma32 (16, sizeof (struct grub_ohci_ed)
+ * GRUB_OHCI_BULK_EDS);
+ if (! o->ed_bulk_chunk)
+ goto fail;
+ o->ed_bulk = grub_dma_get_virt (o->ed_bulk_chunk);
+ o->ed_bulk_addr = grub_dma_get_phys (o->ed_bulk_chunk);
+ /* 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_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);
+
+ /* Reserve memory for TDs. */
+ o->td_chunk = grub_memalign_dma32 (32, sizeof(struct grub_ohci_td)*GRUB_OHCI_TDS);
+ /* Why is it aligned on 32 boundary if spec. says 16 ?
+ * We have structure 32 bytes long and we don't want cross
+ * 4K boundary inside structure. */
+ if (! o->td_chunk)
+ goto fail;
+ o->td_free = o->td = grub_dma_get_virt (o->td_chunk);
+ o->td_addr = grub_dma_get_phys (o->td_chunk);
+ /* Preset free TDs chain in TDs */
+ grub_memset ((void*)o->td, 0, sizeof(struct grub_ohci_td) * GRUB_OHCI_TDS);
+ for (j=0; j < (GRUB_OHCI_TDS-1); j++)
+ o->td[j].link_td = &o->td[j+1];
+
+ grub_dprintf ("ohci", "TDs: chunk=%p, virt=%p, phys=0x%02x\n",
+ o->td_chunk, o->td, o->td_addr);
+
+ /* Check if the OHCI revision is actually 1.0 as supported. */
+ revision = grub_ohci_readreg32 (o, GRUB_OHCI_REG_REVISION);
+ grub_dprintf ("ohci", "OHCI revision=0x%02x\n", revision & 0xFF);
+ if ((revision & 0xFF) != 0x10)
+ goto fail;
+
+ {
+ grub_uint32_t control;
+ /* Check SMM/BIOS ownership of OHCI (SMM = USB Legacy Support driver for BIOS) */
+ control = grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL);
+ if ((control & 0x100) != 0)
+ {
+ unsigned i;
+ grub_dprintf("ohci", "OHCI is owned by SMM\n");
+ /* Do change of ownership */
+ /* Ownership change request */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, (1<<3)); /* XXX: Magic. */
+ /* Waiting for SMM deactivation */
+ for (i=0; i < 10; i++)
+ {
+ if ((grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL) & 0x100) == 0)
+ {
+ grub_dprintf("ohci", "Ownership changed normally.\n");
+ break;
+ }
+ grub_millisleep (100);
+ }
+ if (i >= 10)
+ {
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL,
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL) & ~0x100);
+ grub_dprintf("ohci", "Ownership changing timeout, change forced !\n");
+ }
+ }
+ else if (((control & 0x100) == 0) &&
+ ((control & 0xc0) != 0)) /* Not owned by SMM nor reset */
+ {
+ grub_dprintf("ohci", "OHCI is owned by BIOS\n");
+ /* Do change of ownership - not implemented yet... */
+ /* In fact we probably need to do nothing ...? */
+ }
+ else
+ {
+ grub_dprintf("ohci", "OHCI is not owned by SMM nor BIOS\n");
+ /* We can setup OHCI. */
+ }
+ }
+
+ /* Suspend the OHCI by issuing a reset. */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, 1); /* XXX: Magic. */
+ grub_millisleep (1);
+ grub_dprintf ("ohci", "OHCI reset\n");
+
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_FRAME_INTERVAL,
+ (GRUB_OHCI_FSMPS
+ << GRUB_OHCI_REG_FRAME_INTERVAL_FSMPS_SHIFT)
+ | (GRUB_OHCI_FRAME_INTERVAL
+ << GRUB_OHCI_REG_FRAME_INTERVAL_FI_SHIFT));
+
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_PERIODIC_START,
+ GRUB_OHCI_PERIODIC_START);
+
+ /* Setup the HCCA. */
+ o->hcca->donehead = 0;
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_HCCA, o->hcca_addr);
+ grub_dprintf ("ohci", "OHCI HCCA\n");
+
+ /* Misc. pre-sets. */
+ o->hcca->donehead = 0;
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_INTSTATUS, 0x7f); /* Clears everything */
+ /* We don't want modify CONTROL/BULK HEAD registers.
+ * So we assign to HEAD registers zero ED from related array
+ * and we will not use this ED, it will be always skipped.
+ * It should not produce notable performance penalty (I hope). */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROLHEAD, o->ed_ctrl_addr);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROLCURR, 0);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_BULKHEAD, o->ed_bulk_addr);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_BULKCURR, 0);
+
+ /* Check OHCI Legacy Support */
+ if ((revision & 0x100) != 0)
+ {
+ grub_dprintf ("ohci", "Legacy Support registers detected\n");
+ grub_dprintf ("ohci", "Current state of legacy control reg.: 0x%04x\n",
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_LEGACY_CONTROL));
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_LEGACY_CONTROL,
+ (grub_ohci_readreg32 (o, GRUB_OHCI_REG_LEGACY_CONTROL)) & ~1);
+ grub_dprintf ("ohci", "OHCI Legacy Support disabled.\n");
+ }
+
+ /* Enable the OHCI + enable CONTROL and BULK LIST. */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL,
+ (2 << 6)
+ | GRUB_OHCI_REG_CONTROL_CONTROL_ENABLE
+ | GRUB_OHCI_REG_CONTROL_BULK_ENABLE );
+ grub_dprintf ("ohci", "OHCI enable: 0x%02x\n",
+ (grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL) >> 6) & 3);
+
+ /* Power on all ports */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBA,
+ (grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBA)
+ & ~GRUB_OHCI_RHUB_PORT_POWER_MASK)
+ | GRUB_OHCI_RHUB_PORT_ALL_POWERED);
+#if 0 /* We don't need it at all, handled via hotplugging */
+ /* Now we have hot-plugging, we need to wait for stable power only */
+ grub_millisleep (100);
+#endif
+
+ /* Link to ohci now that initialisation is successful. */
+ o->next = ohci;
+ ohci = o;
+
+ return 0;
+
+ fail:
+ if (o)
+ {
+ grub_dma_free (o->td_chunk);
+ grub_dma_free (o->ed_bulk_chunk);
+ grub_dma_free (o->ed_ctrl_chunk);
+ grub_dma_free (o->hcca_chunk);
+ }
+ grub_free (o);
+
+ return 0;
+}
+
+
+static void
+grub_ohci_inithw (void)
+{
+ grub_pci_iterate (grub_ohci_pci_iter, NULL);
+}
+
+
+
+static int
+grub_ohci_iterate (grub_usb_controller_iterate_hook_t hook, void *hook_data)
+{
+ struct grub_ohci *o;
+ struct grub_usb_controller dev;
+
+ for (o = ohci; o; o = o->next)
+ {
+ dev.data = o;
+ if (hook (&dev, hook_data))
+ return 1;
+ }
+
+ return 0;
+}
+
+static grub_ohci_ed_t
+grub_ohci_find_ed (struct grub_ohci *o, int bulk, grub_uint32_t target)
+{
+ grub_ohci_ed_t ed, ed_next;
+ grub_uint32_t target_addr = target & GRUB_OHCI_ED_ADDR_MASK;
+ int count;
+ int i;
+
+ /* Use proper values and structures. */
+ if (bulk)
+ {
+ count = GRUB_OHCI_BULK_EDS;
+ ed = o->ed_bulk;
+ ed_next = grub_ohci_ed_phys2virt(o, bulk,
+ grub_le_to_cpu32 (ed->next_ed) );
+ }
+ else
+ {
+ count = GRUB_OHCI_CTRL_EDS;
+ ed = o->ed_ctrl;
+ ed_next = grub_ohci_ed_phys2virt(o, bulk,
+ grub_le_to_cpu32 (ed->next_ed) );
+ }
+
+ /* First try to find existing ED with proper target address */
+ for (i = 0; ; )
+ {
+ if (i && /* We ignore zero ED */
+ ((ed->target & GRUB_OHCI_ED_ADDR_MASK) == target_addr))
+ return ed; /* Found proper existing ED */
+ i++;
+ if (ed_next && (i < count))
+ {
+ ed = ed_next;
+ ed_next = grub_ohci_ed_phys2virt(o, bulk,
+ grub_le_to_cpu32 (ed->next_ed) );
+ continue;
+ }
+ break;
+ }
+ /* ED with target_addr does not exist, we have to add it */
+ /* Have we any free ED in array ? */
+ if (i >= count) /* No. */
+ return NULL;
+ /* Currently we simply take next ED in array, no allocation
+ * function is used. It should be no problem until hot-plugging
+ * will be implemented, i.e. until we will need to de-allocate EDs
+ * of unplugged devices. */
+ /* We can link new ED to previous ED safely as the new ED should
+ * still have set skip bit. */
+ ed->next_ed = grub_cpu_to_le32 ( grub_ohci_virt_to_phys (o,
+ bulk, &ed[1]));
+ return &ed[1];
+}
+
+static grub_ohci_td_t
+grub_ohci_alloc_td (struct grub_ohci *o)
+{
+ grub_ohci_td_t ret;
+
+ /* Check if there is a Transfer Descriptor available. */
+ if (! o->td_free)
+ return NULL;
+
+ ret = o->td_free; /* Take current free TD */
+ o->td_free = (grub_ohci_td_t)ret->link_td; /* Advance to next free TD in chain */
+ ret->link_td = 0; /* Reset link_td in allocated TD */
+ return ret;
+}
+
+static void
+grub_ohci_free_td (struct grub_ohci *o, grub_ohci_td_t td)
+{
+ grub_memset ( (void*)td, 0, sizeof(struct grub_ohci_td) );
+ td->link_td = o->td_free; /* Cahin new free TD & rest */
+ o->td_free = td; /* Change address of first free TD */
+}
+
+static void
+grub_ohci_free_tds (struct grub_ohci *o, grub_ohci_td_t td)
+{
+ if (!td)
+ return;
+
+ /* Unchain first TD from previous TD if it is chained */
+ if (td->prev_td_phys)
+ {
+ grub_ohci_td_t td_prev_virt = grub_ohci_td_phys2virt(o,
+ td->prev_td_phys);
+
+ if (td == (grub_ohci_td_t) td_prev_virt->link_td)
+ td_prev_virt->link_td = 0;
+ }
+
+ /* Free all TDs from td (chained by link_td) */
+ while (td)
+ {
+ grub_ohci_td_t tdprev;
+
+ /* Unlink the queue. */
+ tdprev = td;
+ td = (grub_ohci_td_t) td->link_td;
+
+ /* Free the TD. */
+ grub_ohci_free_td (o, tdprev);
+ }
+}
+
+static void
+grub_ohci_transaction (grub_ohci_td_t td,
+ grub_transfer_type_t type, unsigned int toggle,
+ grub_size_t size, grub_uint32_t data)
+{
+ grub_uint32_t token;
+ grub_uint32_t buffer;
+ grub_uint32_t buffer_end;
+
+ grub_dprintf ("ohci", "OHCI transaction td=%p type=%d, toggle=%d, size=%lu\n",
+ td, type, toggle, (unsigned long) size);
+
+ switch (type)
+ {
+ case GRUB_USB_TRANSFER_TYPE_SETUP:
+ token = 0 << 19;
+ break;
+ case GRUB_USB_TRANSFER_TYPE_IN:
+ token = 2 << 19;
+ break;
+ case GRUB_USB_TRANSFER_TYPE_OUT:
+ token = 1 << 19;
+ break;
+ default:
+ token = 0;
+ break;
+ }
+
+ /* Set the token */
+ token |= ( 7 << 21); /* Never generate interrupt */
+ token |= toggle << 24;
+ token |= 1 << 25;
+
+ /* Set "Not accessed" error code */
+ token |= 15 << 28;
+
+ buffer = data;
+ buffer_end = buffer + size - 1;
+
+ /* Set correct buffer values in TD if zero transfer occurs */
+ if (size)
+ {
+ buffer = (grub_uint32_t) data;
+ buffer_end = buffer + size - 1;
+ td->buffer = grub_cpu_to_le32 (buffer);
+ td->buffer_end = grub_cpu_to_le32 (buffer_end);
+ }
+ else
+ {
+ td->buffer = 0;
+ td->buffer_end = 0;
+ }
+
+ /* Set the rest of TD */
+ td->token = grub_cpu_to_le32 (token);
+ td->next_td = 0;
+}
+
+struct grub_ohci_transfer_controller_data
+{
+ grub_uint32_t tderr_phys;
+ grub_uint32_t td_last_phys;
+ grub_ohci_ed_t ed_virt;
+ grub_ohci_td_t td_current_virt;
+ grub_ohci_td_t td_head_virt;
+};
+
+static grub_usb_err_t
+grub_ohci_setup_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer)
+{
+ struct grub_ohci *o = (struct grub_ohci *) dev->data;
+ int bulk = 0;
+ grub_ohci_td_t td_next_virt;
+ grub_uint32_t target;
+ grub_uint32_t td_head_phys;
+ grub_uint32_t td_tail_phys;
+ int i;
+ struct grub_ohci_transfer_controller_data *cdata;
+
+ cdata = grub_zalloc (sizeof (*cdata));
+ if (!cdata)
+ return GRUB_USB_ERR_INTERNAL;
+
+ /* Pre-set target for ED - we need it to find proper ED */
+ /* Set the device address. */
+ target = transfer->devaddr;
+ /* Set the endpoint. It should be masked, we need 4 bits only. */
+ target |= (transfer->endpoint & 15) << 7;
+ /* Set the device speed. */
+ target |= (transfer->dev->speed == GRUB_USB_SPEED_LOW) << 13;
+ /* Set the maximum packet size. */
+ target |= transfer->max << 16;
+
+ /* Determine if transfer type is bulk - we need to select proper ED */
+ switch (transfer->type)
+ {
+ case GRUB_USB_TRANSACTION_TYPE_BULK:
+ bulk = 1;
+ break;
+
+ case GRUB_USB_TRANSACTION_TYPE_CONTROL:
+ break;
+
+ default:
+ grub_free (cdata);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ /* Find proper ED or add new ED */
+ cdata->ed_virt = grub_ohci_find_ed (o, bulk, target);
+ if (!cdata->ed_virt)
+ {
+ grub_dprintf ("ohci","Fatal: No free ED !\n");
+ grub_free (cdata);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ /* Take pointer to first TD from ED */
+ td_head_phys = grub_le_to_cpu32 (cdata->ed_virt->td_head) & ~0xf;
+ td_tail_phys = grub_le_to_cpu32 (cdata->ed_virt->td_tail) & ~0xf;
+
+ /* Sanity check - td_head should be equal to td_tail */
+ if (td_head_phys != td_tail_phys) /* Should never happen ! */
+ {
+ grub_dprintf ("ohci", "Fatal: HEAD is not equal to TAIL !\n");
+ grub_dprintf ("ohci", "HEAD = 0x%02x, TAIL = 0x%02x\n",
+ td_head_phys, td_tail_phys);
+ /* XXX: Fix: What to do ? */
+ grub_free (cdata);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ /* Now we should handle first TD. If ED is newly allocated,
+ * we must allocate the first TD. */
+ if (!td_head_phys)
+ {
+ cdata->td_head_virt = grub_ohci_alloc_td (o);
+ if (!cdata->td_head_virt)
+ {
+ 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
+ = grub_cpu_to_le32 (grub_ohci_td_virt2phys (o, cdata->td_head_virt));
+ cdata->ed_virt->td_tail = cdata->ed_virt->td_head;
+ }
+ else
+ cdata->td_head_virt = grub_ohci_td_phys2virt ( o, td_head_phys );
+
+ /* Set TDs */
+ cdata->td_last_phys = td_head_phys; /* initial value to make compiler happy... */
+ for (i = 0, cdata->td_current_virt = cdata->td_head_virt;
+ i < transfer->transcnt; i++)
+ {
+ grub_usb_transaction_t tr = &transfer->transactions[i];
+
+ grub_ohci_transaction (cdata->td_current_virt, tr->pid, tr->toggle,
+ tr->size, tr->data);
+
+ /* Set index of TD in transfer */
+ cdata->td_current_virt->tr_index = (grub_uint32_t) i;
+
+ /* Remember last used (processed) TD phys. addr. */
+ cdata->td_last_phys = grub_ohci_td_virt2phys (o, cdata->td_current_virt);
+
+ /* Allocate next TD */
+ td_next_virt = grub_ohci_alloc_td (o);
+ if (!td_next_virt) /* No free TD, cancel transfer and free TDs except head TD */
+ {
+ if (i) /* if i==0 we have nothing to free... */
+ grub_ohci_free_tds (o, grub_ohci_td_phys2virt(o,
+ grub_le_to_cpu32 (cdata->td_head_virt->next_td)));
+ /* Reset head TD */
+ grub_memset ( (void*)cdata->td_head_virt, 0,
+ sizeof(struct grub_ohci_td) );
+ grub_dprintf ("ohci", "Fatal: No free TD !");
+ grub_free (cdata);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ /* Chain TDs */
+
+ cdata->td_current_virt->link_td = td_next_virt;
+ cdata->td_current_virt->next_td = grub_cpu_to_le32 (
+ grub_ohci_td_virt2phys (o,
+ td_next_virt) );
+ td_next_virt->prev_td_phys = grub_ohci_td_virt2phys (o,
+ cdata->td_current_virt);
+ cdata->td_current_virt = td_next_virt;
+ }
+
+ grub_dprintf ("ohci", "Tail TD (not processed) = %p\n",
+ cdata->td_current_virt);
+
+ /* Setup the Endpoint Descriptor for transfer. */
+ /* First set necessary fields in TARGET but keep (or set) skip bit */
+ /* Note: It could be simpler if speed, format and max. packet
+ * size never change after first allocation of ED.
+ * But unfortunately max. packet size may change during initial
+ * setup sequence and we must handle it. */
+ cdata->ed_virt->target = grub_cpu_to_le32 (target | (1 << 14));
+ /* Set td_tail */
+ cdata->ed_virt->td_tail
+ = grub_cpu_to_le32 (grub_ohci_td_virt2phys (o, cdata->td_current_virt));
+ /* Now reset skip bit */
+ cdata->ed_virt->target = grub_cpu_to_le32 (target);
+ /* ed_virt->td_head = grub_cpu_to_le32 (td_head); Must not be changed, it is maintained by OHCI */
+ /* ed_virt->next_ed = grub_cpu_to_le32 (0); Handled by grub_ohci_find_ed, do not change ! */
+
+ grub_dprintf ("ohci", "program OHCI\n");
+
+ /* Program the OHCI to actually transfer. */
+ switch (transfer->type)
+ {
+ case GRUB_USB_TRANSACTION_TYPE_BULK:
+ {
+ grub_dprintf ("ohci", "BULK list filled\n");
+ /* Set BulkListFilled. */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, 1 << 2);
+ /* Read back of register should ensure it is really written */
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_CMDSTATUS);
+ break;
+ }
+
+ case GRUB_USB_TRANSACTION_TYPE_CONTROL:
+ {
+ grub_dprintf ("ohci", "CONTROL list filled\n");
+ /* Set ControlListFilled. */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, 1 << 1);
+ /* Read back of register should ensure it is really written */
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_CMDSTATUS);
+ break;
+ }
+ }
+
+ transfer->controller_data = cdata;
+
+ return GRUB_USB_ERR_NONE;
+}
+
+static void
+pre_finish_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer)
+{
+ struct grub_ohci *o = dev->data;
+ struct grub_ohci_transfer_controller_data *cdata = transfer->controller_data;
+ grub_uint32_t target;
+ grub_uint32_t status;
+ grub_uint32_t control;
+ grub_uint32_t intstatus;
+
+ /* There are many ways how the loop above can finish:
+ * - normally without any error via INTSTATUS WDH bit
+ * : tderr_phys == td_last_phys, td_head == td_tail
+ * - normally with error via HALT bit in ED TD HEAD
+ * : td_head = next TD after TD with error
+ * : tderr_phys = last processed and retired TD with error,
+ * i.e. should be != 0
+ * : if bad_OHCI == TRUE, tderr_phys will be probably invalid
+ * - unrecoverable error - I never seen it but it could be
+ * : err_unrec == TRUE, other values can contain anything...
+ * - timeout, it can be caused by:
+ * -- bad USB device - some devices have some bugs, see Linux source
+ * and related links
+ * -- bad OHCI controller - e.g. lost interrupts or does not set
+ * proper bits in INTSTATUS when real IRQ not enabled etc.,
+ * see Linux source and related links
+ * One known bug is handled - if transfer finished
+ * successfully (i.e. HEAD==TAIL, last transfer TD is retired,
+ * HALT bit is not set) and WDH bit is not set in INTSTATUS - in
+ * this case we set o->bad_OHCI=TRUE and do alternate loop
+ * and error handling - but there is problem how to find retired
+ * TD with error code if HALT occurs and if DONEHEAD is not
+ * working - we need to find TD previous to current ED HEAD
+ * -- bad code of this driver or some unknown reasons - :-(
+ * it can be e.g. bad handling of EDs/TDs/toggle bit...
+ */
+
+ /* Remember target for debug and set skip flag in ED */
+ /* It should be normaly not necessary but we need it at least
+ * in case of timeout */
+ target = grub_le_to_cpu32 ( cdata->ed_virt->target );
+ cdata->ed_virt->target = grub_cpu_to_le32 (target | (1 << 14));
+ /* Read registers for debug - they should be read now because
+ * debug prints case unwanted delays, so something can happen
+ * in the meantime... */
+ control = grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL);
+ status = grub_ohci_readreg32 (o, GRUB_OHCI_REG_CMDSTATUS);
+ intstatus = grub_ohci_readreg32 (o, GRUB_OHCI_REG_INTSTATUS);
+ /* Now print debug values - to have full info what happened */
+ grub_dprintf ("ohci", "loop finished: control=0x%02x status=0x%02x\n",
+ control, status);
+ grub_dprintf ("ohci", "intstatus=0x%02x, td_last_phys=0x%02x\n",
+ intstatus, cdata->td_last_phys);
+ grub_dprintf ("ohci", "TARGET=0x%02x, HEAD=0x%02x, TAIL=0x%02x\n",
+ target,
+ grub_le_to_cpu32 (cdata->ed_virt->td_head),
+ grub_le_to_cpu32 (cdata->ed_virt->td_tail) );
+
+}
+
+static void
+finish_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer)
+{
+ struct grub_ohci *o = dev->data;
+ struct grub_ohci_transfer_controller_data *cdata = transfer->controller_data;
+
+ /* Set empty ED - set HEAD = TAIL = last (not processed) TD */
+ cdata->ed_virt->td_head = grub_cpu_to_le32 (grub_le_to_cpu32 (cdata->ed_virt->td_tail) & ~0xf);
+
+ /* At this point always should be:
+ * ED has skip bit set and halted or empty or after next SOF,
+ * i.e. it is safe to free all TDs except last not processed
+ * ED HEAD == TAIL == phys. addr. of td_current_virt */
+
+ /* Un-chainig of last TD */
+ if (cdata->td_current_virt->prev_td_phys)
+ {
+ grub_ohci_td_t td_prev_virt
+ = grub_ohci_td_phys2virt (o, cdata->td_current_virt->prev_td_phys);
+
+ if (cdata->td_current_virt == (grub_ohci_td_t) td_prev_virt->link_td)
+ td_prev_virt->link_td = 0;
+
+ cdata->td_current_virt->prev_td_phys = 0;
+ }
+
+ grub_dprintf ("ohci", "OHCI finished, freeing\n");
+ grub_ohci_free_tds (o, cdata->td_head_virt);
+ grub_free (cdata);
+}
+
+static grub_usb_err_t
+parse_halt (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer,
+ grub_size_t *actual)
+{
+ struct grub_ohci *o = dev->data;
+ struct grub_ohci_transfer_controller_data *cdata = transfer->controller_data;
+ grub_uint8_t errcode = 0;
+ grub_usb_err_t err = GRUB_USB_ERR_NAK;
+ grub_ohci_td_t tderr_virt = NULL;
+
+ *actual = 0;
+
+ pre_finish_transfer (dev, transfer);
+
+ /* First we must get proper tderr_phys value */
+ /* Retired TD with error should be previous TD to ED->td_head */
+ cdata->tderr_phys = grub_ohci_td_phys2virt (o,
+ grub_le_to_cpu32 (cdata->ed_virt->td_head) & ~0xf )
+ ->prev_td_phys;
+
+ /* Prepare pointer to last processed TD and get error code */
+ tderr_virt = grub_ohci_td_phys2virt (o, cdata->tderr_phys);
+ /* Set index of last processed TD */
+ if (tderr_virt)
+ {
+ errcode = grub_le_to_cpu32 (tderr_virt->token) >> 28;
+ transfer->last_trans = tderr_virt->tr_index;
+ }
+ else
+ transfer->last_trans = -1;
+
+ /* Evaluation of error code */
+ grub_dprintf ("ohci", "OHCI tderr_phys=0x%02x, errcode=0x%02x\n",
+ cdata->tderr_phys, errcode);
+ switch (errcode)
+ {
+ case 0:
+ /* XXX: Should not happen! */
+ grub_error (GRUB_ERR_IO, "OHCI failed without reporting the reason");
+ err = GRUB_USB_ERR_INTERNAL;
+ break;
+
+ case 1:
+ /* XXX: CRC error. */
+ err = GRUB_USB_ERR_TIMEOUT;
+ break;
+
+ case 2:
+ err = GRUB_USB_ERR_BITSTUFF;
+ break;
+
+ case 3:
+ /* XXX: Data Toggle error. */
+ err = GRUB_USB_ERR_DATA;
+ break;
+
+ case 4:
+ err = GRUB_USB_ERR_STALL;
+ break;
+
+ case 5:
+ /* XXX: Not responding. */
+ err = GRUB_USB_ERR_TIMEOUT;
+ break;
+
+ case 6:
+ /* XXX: PID Check bits failed. */
+ err = GRUB_USB_ERR_BABBLE;
+ break;
+
+ case 7:
+ /* XXX: PID unexpected failed. */
+ err = GRUB_USB_ERR_BABBLE;
+ break;
+
+ case 8:
+ /* XXX: Data overrun error. */
+ err = GRUB_USB_ERR_DATA;
+ grub_dprintf ("ohci", "Overrun, failed TD address: %p, index: %d\n",
+ tderr_virt, tderr_virt->tr_index);
+ break;
+
+ case 9:
+ /* XXX: Data underrun error. */
+ grub_dprintf ("ohci", "Underrun, failed TD address: %p, index: %d\n",
+ tderr_virt, tderr_virt->tr_index);
+ if (transfer->last_trans == -1)
+ break;
+ *actual = transfer->transactions[transfer->last_trans].size
+ - (grub_le_to_cpu32 (tderr_virt->buffer_end)
+ - grub_le_to_cpu32 (tderr_virt->buffer))
+ + transfer->transactions[transfer->last_trans].preceding;
+ err = GRUB_USB_ERR_NONE;
+ break;
+
+ case 10:
+ /* XXX: Reserved. */
+ err = GRUB_USB_ERR_NAK;
+ break;
+
+ case 11:
+ /* XXX: Reserved. */
+ err = GRUB_USB_ERR_NAK;
+ break;
+
+ case 12:
+ /* XXX: Buffer overrun. */
+ err = GRUB_USB_ERR_DATA;
+ break;
+
+ case 13:
+ /* XXX: Buffer underrun. */
+ err = GRUB_USB_ERR_DATA;
+ break;
+
+ default:
+ err = GRUB_USB_ERR_NAK;
+ break;
+ }
+
+ finish_transfer (dev, transfer);
+
+ return err;
+}
+
+static grub_usb_err_t
+parse_success (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer,
+ grub_size_t *actual)
+{
+ struct grub_ohci *o = dev->data;
+ struct grub_ohci_transfer_controller_data *cdata = transfer->controller_data;
+ grub_ohci_td_t tderr_virt = NULL;
+
+ pre_finish_transfer (dev, transfer);
+
+ /* I hope we can do it as transfer (most probably) finished OK */
+ cdata->tderr_phys = cdata->td_last_phys;
+
+ /* Prepare pointer to last processed TD */
+ tderr_virt = grub_ohci_td_phys2virt (o, cdata->tderr_phys);
+
+ /* Set index of last processed TD */
+ if (tderr_virt)
+ transfer->last_trans = tderr_virt->tr_index;
+ else
+ transfer->last_trans = -1;
+ *actual = transfer->size + 1;
+
+ finish_transfer (dev, transfer);
+
+ return GRUB_USB_ERR_NONE;
+}
+
+static grub_usb_err_t
+parse_unrec (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer,
+ grub_size_t *actual)
+{
+ struct grub_ohci *o = dev->data;
+
+ *actual = 0;
+
+ pre_finish_transfer (dev, transfer);
+
+ /* Don't try to get error code and last processed TD for proper
+ * toggle bit value - anything can be invalid */
+ grub_dprintf("ohci", "Unrecoverable error!");
+
+ /* Do OHCI reset in case of unrecoverable error - maybe we will need
+ * do more - re-enumerate bus etc. (?) */
+
+ /* Suspend the OHCI by issuing a reset. */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, 1); /* XXX: Magic. */
+ /* Read back of register should ensure it is really written */
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_CMDSTATUS);
+ grub_millisleep (1);
+ grub_dprintf ("ohci", "Unrecoverable error - OHCI reset\n");
+
+ /* Misc. resets. */
+ o->hcca->donehead = 0;
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_INTSTATUS, 0x7f); /* Clears everything */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROLHEAD, o->ed_ctrl_addr);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROLCURR, 0);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_BULKHEAD, o->ed_bulk_addr);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_BULKCURR, 0);
+ /* Read back of register should ensure it is really written */
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_INTSTATUS);
+
+ /* Enable the OHCI. */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL,
+ (2 << 6)
+ | GRUB_OHCI_REG_CONTROL_CONTROL_ENABLE
+ | GRUB_OHCI_REG_CONTROL_BULK_ENABLE );
+ finish_transfer (dev, transfer);
+
+ return GRUB_USB_ERR_UNRECOVERABLE;
+}
+
+static grub_usb_err_t
+grub_ohci_check_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer,
+ grub_size_t *actual)
+{
+ struct grub_ohci *o = dev->data;
+ struct grub_ohci_transfer_controller_data *cdata = transfer->controller_data;
+ grub_uint32_t intstatus;
+
+ /* Check transfer status */
+ intstatus = grub_ohci_readreg32 (o, GRUB_OHCI_REG_INTSTATUS);
+
+ if ((intstatus & 0x10) != 0)
+ /* Unrecoverable error - only reset can help...! */
+ return parse_unrec (dev, transfer, actual);
+
+ /* Detected a HALT. */
+ if ((grub_le_to_cpu32 (cdata->ed_virt->td_head) & 1))
+ return parse_halt (dev, transfer, actual);
+
+ /* Finished ED detection */
+ if ( (grub_le_to_cpu32 (cdata->ed_virt->td_head) & ~0xfU) ==
+ (grub_le_to_cpu32 (cdata->ed_virt->td_tail) & ~0xfU) ) /* Empty ED */
+ {
+ /* Check the HALT bit */
+ /* It looks like nonsense - it was tested previously...
+ * but it can change because OHCI is working
+ * simultaneously via DMA... */
+ if (grub_le_to_cpu32 (cdata->ed_virt->td_head) & 1)
+ return parse_halt (dev, transfer, actual);
+ else
+ return parse_success (dev, transfer, actual);
+ }
+
+ return GRUB_USB_ERR_WAIT;
+}
+
+static grub_usb_err_t
+grub_ohci_cancel_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer)
+{
+ struct grub_ohci *o = dev->data;
+ struct grub_ohci_transfer_controller_data *cdata = transfer->controller_data;
+ grub_ohci_td_t tderr_virt = NULL;
+
+ pre_finish_transfer (dev, transfer);
+
+ grub_dprintf("ohci", "Timeout !\n");
+
+ /* We should wait for next SOF to be sure that ED is unaccessed
+ * by OHCI */
+ /* SF bit reset. (SF bit indicates Start Of Frame (SOF) packet) */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_INTSTATUS, (1<<2));
+ /* Wait for new SOF */
+ while ((grub_ohci_readreg32 (o, GRUB_OHCI_REG_INTSTATUS) & 0x4) == 0);
+
+ /* Possible retired TD with error should be previous TD to ED->td_head */
+ cdata->tderr_phys
+ = grub_ohci_td_phys2virt (o, grub_le_to_cpu32 (cdata->ed_virt->td_head)
+ & ~0xf)->prev_td_phys;
+
+ tderr_virt = grub_ohci_td_phys2virt (o,cdata-> tderr_phys);
+
+ grub_dprintf ("ohci", "Cancel: tderr_phys=0x%x, tderr_virt=%p\n",
+ cdata->tderr_phys, tderr_virt);
+
+ if (tderr_virt)
+ transfer->last_trans = tderr_virt->tr_index;
+ else
+ transfer->last_trans = -1;
+
+ finish_transfer (dev, transfer);
+
+ return GRUB_USB_ERR_NONE;
+}
+
+static grub_usb_err_t
+grub_ohci_portstatus (grub_usb_controller_t dev,
+ unsigned int port, unsigned int enable)
+{
+ struct grub_ohci *o = (struct grub_ohci *) dev->data;
+ grub_uint64_t endtime;
+ int i;
+
+ grub_dprintf ("ohci", "begin of portstatus=0x%02x\n",
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port));
+
+ if (!enable) /* We don't need reset port */
+ {
+ /* Disable the port and wait for it. */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port,
+ GRUB_OHCI_CLEAR_PORT_ENABLE);
+ endtime = grub_get_time_ms () + 1000;
+ while ((grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port)
+ & (1 << 1)))
+ if (grub_get_time_ms () > endtime)
+ return GRUB_USB_ERR_TIMEOUT;
+
+ grub_dprintf ("ohci", "end of portstatus=0x%02x\n",
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port));
+ return GRUB_USB_ERR_NONE;
+ }
+
+ /* OHCI does one reset signal 10ms long but USB spec.
+ * requests 50ms for root hub (no need to be continuous).
+ * So, we do reset 5 times... */
+ for (i = 0; i < 5; i++)
+ {
+ /* Reset the port - timing of reset is done by OHCI */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port,
+ GRUB_OHCI_SET_PORT_RESET);
+
+ /* Wait for reset completion */
+ endtime = grub_get_time_ms () + 1000;
+ while (! (grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port)
+ & GRUB_OHCI_SET_PORT_RESET_STATUS_CHANGE))
+ if (grub_get_time_ms () > endtime)
+ return GRUB_USB_ERR_TIMEOUT;
+
+ /* End the reset signaling - reset the reset status change */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port,
+ GRUB_OHCI_SET_PORT_RESET_STATUS_CHANGE);
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port);
+ }
+
+ /* Enable port */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port,
+ GRUB_OHCI_SET_PORT_ENABLE);
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port);
+
+ /* Wait for signal enabled */
+ endtime = grub_get_time_ms () + 1000;
+ while (! (grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port)
+ & (1 << 1)))
+ if (grub_get_time_ms () > endtime)
+ return GRUB_USB_ERR_TIMEOUT;
+
+ /* Reset bit Connect Status Change */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port,
+ GRUB_OHCI_RESET_CONNECT_CHANGE);
+
+ /* "Reset recovery time" (USB spec.) */
+ grub_millisleep (10);
+
+ grub_dprintf ("ohci", "end of portstatus=0x%02x\n",
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port));
+
+ return GRUB_USB_ERR_NONE;
+}
+
+static grub_usb_speed_t
+grub_ohci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
+{
+ struct grub_ohci *o = (struct grub_ohci *) dev->data;
+ grub_uint32_t status;
+
+ status = grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBPORT + port);
+
+ grub_dprintf ("ohci", "detect_dev status=0x%02x\n", status);
+
+ /* Connect Status Change bit - it detects change of connection */
+ if (status & GRUB_OHCI_RESET_CONNECT_CHANGE)
+ {
+ *changed = 1;
+ /* Reset bit Connect Status Change */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port,
+ GRUB_OHCI_RESET_CONNECT_CHANGE);
+ }
+ else
+ *changed = 0;
+
+ if (! (status & 1))
+ return GRUB_USB_SPEED_NONE;
+ else if (status & (1 << 9))
+ return GRUB_USB_SPEED_LOW;
+ else
+ return GRUB_USB_SPEED_FULL;
+}
+
+static int
+grub_ohci_hubports (grub_usb_controller_t dev)
+{
+ struct grub_ohci *o = (struct grub_ohci *) dev->data;
+ grub_uint32_t portinfo;
+
+ portinfo = grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBA);
+
+ grub_dprintf ("ohci", "root hub ports=%d\n", portinfo & 0xFF);
+
+ return portinfo & 0xFF;
+}
+
+static grub_err_t
+grub_ohci_fini_hw (int noreturn __attribute__ ((unused)))
+{
+ struct grub_ohci *o;
+
+ for (o = ohci; o; o = o->next)
+ {
+ int i, nports = grub_ohci_readreg32 (o, GRUB_OHCI_REG_RHUBA) & 0xff;
+ grub_uint64_t maxtime;
+
+ /* 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_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_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
+ * more than 1ms timeout have to be applied. */
+ /* SF bit reset. (SF bit indicates Start Of Frame (SOF) packet) */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_INTSTATUS, (1<<2));
+ maxtime = grub_get_time_ms () + 2;
+ /* Wait for new SOF or timeout */
+ while ( ((grub_ohci_readreg32 (o, GRUB_OHCI_REG_INTSTATUS) & 0x4)
+ == 0) || (grub_get_time_ms () >= maxtime) );
+
+ for (i = 0; i < nports; i++)
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + i,
+ GRUB_OHCI_CLEAR_PORT_ENABLE);
+
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CMDSTATUS, 1);
+ grub_millisleep (1);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_HCCA, 0);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROLHEAD, 0);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROLCURR, 0);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_BULKHEAD, 0);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_BULKCURR, 0);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_DONEHEAD, 0);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL, 0);
+ /* Read back of register should ensure it is really written */
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_INTSTATUS);
+
+#if 0 /* Is this necessary before booting? Probably not .(?)
+ * But it must be done if module is removed ! (Or not ?)
+ * How to do it ? - Probably grub_ohci_restore_hw should be more
+ * complicated. (?)
+ * (If we do it, we need to reallocate EDs and TDs in function
+ * grub_ohci_restore_hw ! */
+
+ /* Free allocated EDs and TDs */
+ grub_dma_free (o->td_chunk);
+ grub_dma_free (o->ed_bulk_chunk);
+ grub_dma_free (o->ed_ctrl_chunk);
+ grub_dma_free (o->hcca_chunk);
+#endif
+ }
+ grub_millisleep (10);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_ohci_restore_hw (void)
+{
+ struct grub_ohci *o;
+
+ for (o = ohci; o; o = o->next)
+ {
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_HCCA, o->hcca_addr);
+ o->hcca->donehead = 0;
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_INTSTATUS, 0x7f); /* Clears everything */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROLHEAD, o->ed_ctrl_addr);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROLCURR, 0);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_BULKHEAD, o->ed_bulk_addr);
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_BULKCURR, 0);
+ /* Read back of register should ensure it is really written */
+ grub_ohci_readreg32 (o, GRUB_OHCI_REG_INTSTATUS);
+
+ /* Enable the OHCI. */
+ grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL,
+ (2 << 6)
+ | GRUB_OHCI_REG_CONTROL_CONTROL_ENABLE
+ | GRUB_OHCI_REG_CONTROL_BULK_ENABLE );
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+
+static struct grub_usb_controller_dev usb_controller =
+{
+ .name = "ohci",
+ .iterate = grub_ohci_iterate,
+ .setup_transfer = grub_ohci_setup_transfer,
+ .check_transfer = grub_ohci_check_transfer,
+ .cancel_transfer = grub_ohci_cancel_transfer,
+ .hubports = grub_ohci_hubports,
+ .portstatus = grub_ohci_portstatus,
+ .detect_dev = grub_ohci_detect_dev,
+ /* estimated max. count of TDs for one bulk transfer */
+ .max_bulk_tds = GRUB_OHCI_TDS * 3 / 4
+};
+
+static struct grub_preboot *fini_hnd;
+
+GRUB_MOD_INIT(ohci)
+{
+ COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_td) == 32);
+ COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_ed) == 16);
+
+ grub_stop_disk_firmware ();
+
+ grub_ohci_inithw ();
+ grub_usb_controller_dev_register (&usb_controller);
+ fini_hnd = grub_loader_register_preboot_hook (grub_ohci_fini_hw,
+ grub_ohci_restore_hw,
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK);
+}
+
+GRUB_MOD_FINI(ohci)
+{
+ grub_ohci_fini_hw (0);
+ grub_loader_unregister_preboot_hook (fini_hnd);
+ grub_usb_controller_dev_unregister (&usb_controller);
+}
diff --git a/grub-core/bus/usb/serial/common.c b/grub-core/bus/usb/serial/common.c
new file mode 100644
index 0000000..8e94c7d
--- /dev/null
+++ b/grub-core/bus/usb/serial/common.c
@@ -0,0 +1,139 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/serial.h>
+#include <grub/usbserial.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+void
+grub_usbserial_fini (struct grub_serial_port *port)
+{
+ port->usbdev->config[port->configno].interf[port->interfno].detach_hook = 0;
+ port->usbdev->config[port->configno].interf[port->interfno].attached = 0;
+}
+
+void
+grub_usbserial_detach (grub_usb_device_t usbdev, int configno, int interfno)
+{
+ static struct grub_serial_port *port;
+ port = usbdev->config[configno].interf[interfno].detach_data;
+
+ grub_serial_unregister (port);
+}
+
+static int usbnum = 0;
+
+int
+grub_usbserial_attach (grub_usb_device_t usbdev, int configno, int interfno,
+ struct grub_serial_driver *driver, int in_endp,
+ int out_endp)
+{
+ struct grub_serial_port *port;
+ int j;
+ struct grub_usb_desc_if *interf;
+ grub_usb_err_t err = GRUB_USB_ERR_NONE;
+
+ interf = usbdev->config[configno].interf[interfno].descif;
+
+ port = grub_zalloc (sizeof (*port));
+ if (!port)
+ {
+ grub_print_error ();
+ return 0;
+ }
+
+ port->name = grub_xasprintf ("usb%d", usbnum++);
+ if (!port->name)
+ {
+ grub_free (port);
+ grub_print_error ();
+ return 0;
+ }
+
+ port->usbdev = usbdev;
+ port->driver = driver;
+ for (j = 0; j < interf->endpointcnt; j++)
+ {
+ struct grub_usb_desc_endp *endp;
+ endp = &usbdev->config[0].interf[interfno].descendp[j];
+
+ if ((endp->endp_addr & 128) && (endp->attrib & 3) == 2
+ && (in_endp == GRUB_USB_SERIAL_ENDPOINT_LAST_MATCHING
+ || in_endp == endp->endp_addr))
+ {
+ /* Bulk IN endpoint. */
+ port->in_endp = endp;
+ }
+ else if (!(endp->endp_addr & 128) && (endp->attrib & 3) == 2
+ && (out_endp == GRUB_USB_SERIAL_ENDPOINT_LAST_MATCHING
+ || out_endp == endp->endp_addr))
+ {
+ /* Bulk OUT endpoint. */
+ port->out_endp = endp;
+ }
+ }
+
+ /* Configure device */
+ if (port->out_endp && port->in_endp)
+ err = grub_usb_set_configuration (usbdev, configno + 1);
+
+ if (!port->out_endp || !port->in_endp || err)
+ {
+ grub_free (port->name);
+ grub_free (port);
+ return 0;
+ }
+
+ port->configno = configno;
+ port->interfno = interfno;
+
+ grub_serial_config_defaults (port);
+ grub_serial_register (port);
+
+ port->usbdev->config[port->configno].interf[port->interfno].detach_hook
+ = grub_usbserial_detach;
+ port->usbdev->config[port->configno].interf[port->interfno].detach_data
+ = port;
+
+ return 1;
+}
+
+int
+grub_usbserial_fetch (struct grub_serial_port *port, grub_size_t header_size)
+{
+ grub_usb_err_t err;
+ grub_size_t actual;
+
+ if (port->bufstart < port->bufend)
+ return port->buf[port->bufstart++];
+
+ err = grub_usb_bulk_read_extended (port->usbdev, port->in_endp,
+ sizeof (port->buf), port->buf, 10,
+ &actual);
+ if (err != GRUB_USB_ERR_NONE)
+ return -1;
+
+ port->bufstart = header_size;
+ port->bufend = actual;
+ if (port->bufstart >= port->bufend)
+ return -1;
+
+ return port->buf[port->bufstart++];
+}
diff --git a/grub-core/bus/usb/serial/ftdi.c b/grub-core/bus/usb/serial/ftdi.c
new file mode 100644
index 0000000..1a99cba
--- /dev/null
+++ b/grub-core/bus/usb/serial/ftdi.c
@@ -0,0 +1,218 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/serial.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/usb.h>
+#include <grub/usbserial.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+enum
+ {
+ GRUB_FTDI_MODEM_CTRL = 0x01,
+ GRUB_FTDI_FLOW_CTRL = 0x02,
+ GRUB_FTDI_SPEED_CTRL = 0x03,
+ GRUB_FTDI_DATA_CTRL = 0x04
+ };
+
+#define GRUB_FTDI_MODEM_CTRL_DTRRTS 3
+#define GRUB_FTDI_FLOW_CTRL_DTRRTS 3
+
+/* Convert speed to divisor. */
+static grub_uint32_t
+get_divisor (unsigned int speed)
+{
+ unsigned int i;
+
+ /* The structure for speed vs. divisor. */
+ struct divisor
+ {
+ unsigned int speed;
+ grub_uint32_t div;
+ };
+
+ /* The table which lists common configurations. */
+ /* Computed with a division formula with 3MHz as base frequency. */
+ static struct divisor divisor_tab[] =
+ {
+ { 2400, 0x04e2 },
+ { 4800, 0x0271 },
+ { 9600, 0x4138 },
+ { 19200, 0x809c },
+ { 38400, 0xc04e },
+ { 57600, 0xc034 },
+ { 115200, 0x001a }
+ };
+
+ /* Set the baud rate. */
+ for (i = 0; i < ARRAY_SIZE (divisor_tab); i++)
+ if (divisor_tab[i].speed == speed)
+ return divisor_tab[i].div;
+ return 0;
+}
+
+static void
+real_config (struct grub_serial_port *port)
+{
+ grub_uint32_t divisor;
+ const grub_uint16_t parities[] = {
+ [GRUB_SERIAL_PARITY_NONE] = 0x0000,
+ [GRUB_SERIAL_PARITY_ODD] = 0x0100,
+ [GRUB_SERIAL_PARITY_EVEN] = 0x0200
+ };
+ const grub_uint16_t stop_bits[] = {
+ [GRUB_SERIAL_STOP_BITS_1] = 0x0000,
+ [GRUB_SERIAL_STOP_BITS_1_5] = 0x0800,
+ [GRUB_SERIAL_STOP_BITS_2] = 0x1000,
+ };
+
+ if (port->configured)
+ return;
+
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ GRUB_FTDI_MODEM_CTRL,
+ port->config.rtscts ? GRUB_FTDI_MODEM_CTRL_DTRRTS : 0,
+ 0, 0, 0);
+
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ GRUB_FTDI_FLOW_CTRL,
+ port->config.rtscts ? GRUB_FTDI_FLOW_CTRL_DTRRTS : 0,
+ 0, 0, 0);
+
+ divisor = get_divisor (port->config.speed);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ GRUB_FTDI_SPEED_CTRL,
+ divisor & 0xffff, divisor >> 16, 0, 0);
+
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ GRUB_FTDI_DATA_CTRL,
+ parities[port->config.parity]
+ | stop_bits[port->config.stop_bits]
+ | port->config.word_len, 0, 0, 0);
+
+ port->configured = 1;
+}
+
+/* Fetch a key. */
+static int
+ftdi_hw_fetch (struct grub_serial_port *port)
+{
+ real_config (port);
+
+ return grub_usbserial_fetch (port, 2);
+}
+
+/* Put a character. */
+static void
+ftdi_hw_put (struct grub_serial_port *port, const int c)
+{
+ char cc = c;
+
+ real_config (port);
+
+ grub_usb_bulk_write (port->usbdev, port->out_endp, 1, &cc);
+}
+
+static grub_err_t
+ftdi_hw_configure (struct grub_serial_port *port,
+ struct grub_serial_config *config)
+{
+ grub_uint16_t divisor;
+
+ divisor = get_divisor (config->speed);
+ if (divisor == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port speed"));
+
+ if (config->parity != GRUB_SERIAL_PARITY_NONE
+ && config->parity != GRUB_SERIAL_PARITY_ODD
+ && config->parity != GRUB_SERIAL_PARITY_EVEN)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port parity"));
+
+ if (config->stop_bits != GRUB_SERIAL_STOP_BITS_1
+ && config->stop_bits != GRUB_SERIAL_STOP_BITS_1_5
+ && config->stop_bits != GRUB_SERIAL_STOP_BITS_2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port stop bits number"));
+
+ if (config->word_len < 5 || config->word_len > 8)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port word length"));
+
+ port->config = *config;
+ port->configured = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_serial_driver grub_ftdi_driver =
+ {
+ .configure = ftdi_hw_configure,
+ .fetch = ftdi_hw_fetch,
+ .put = ftdi_hw_put,
+ .fini = grub_usbserial_fini
+ };
+
+static const struct
+{
+ grub_uint16_t vendor, product;
+} products[] =
+ {
+ {0x0403, 0x6001} /* QEMU virtual USBserial. */
+ };
+
+static int
+grub_ftdi_attach (grub_usb_device_t usbdev, int configno, int interfno)
+{
+ unsigned j;
+
+ for (j = 0; j < ARRAY_SIZE (products); j++)
+ if (usbdev->descdev.vendorid == products[j].vendor
+ && usbdev->descdev.prodid == products[j].product)
+ break;
+ if (j == ARRAY_SIZE (products))
+ return 0;
+
+ return grub_usbserial_attach (usbdev, configno, interfno,
+ &grub_ftdi_driver,
+ GRUB_USB_SERIAL_ENDPOINT_LAST_MATCHING,
+ GRUB_USB_SERIAL_ENDPOINT_LAST_MATCHING);
+}
+
+static struct grub_usb_attach_desc attach_hook =
+{
+ .class = 0xff,
+ .hook = grub_ftdi_attach
+};
+
+GRUB_MOD_INIT(usbserial_ftdi)
+{
+ grub_usb_register_attach_hook_class (&attach_hook);
+}
+
+GRUB_MOD_FINI(usbserial_ftdi)
+{
+ grub_serial_unregister_driver (&grub_ftdi_driver);
+ grub_usb_unregister_attach_hook_class (&attach_hook);
+}
diff --git a/grub-core/bus/usb/serial/pl2303.c b/grub-core/bus/usb/serial/pl2303.c
new file mode 100644
index 0000000..d1945a2
--- /dev/null
+++ b/grub-core/bus/usb/serial/pl2303.c
@@ -0,0 +1,231 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/serial.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/usb.h>
+#include <grub/usbserial.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Convert speed to divisor. */
+static grub_uint32_t
+is_speed_supported (unsigned int speed)
+{
+ unsigned int i;
+ unsigned int supported[] = { 2400, 4800, 9600, 19200, 38400, 57600, 115200};
+
+ for (i = 0; i < ARRAY_SIZE (supported); i++)
+ if (supported[i] == speed)
+ return 1;
+ return 0;
+}
+
+#define GRUB_PL2303_REQUEST_SET_CONFIG 0x20
+#define GRUB_PL2303_STOP_BITS_1 0x0
+#define GRUB_PL2303_STOP_BITS_1_5 0x1
+#define GRUB_PL2303_STOP_BITS_2 0x2
+
+#define GRUB_PL2303_PARITY_NONE 0
+#define GRUB_PL2303_PARITY_ODD 1
+#define GRUB_PL2303_PARITY_EVEN 2
+
+struct grub_pl2303_config
+{
+ grub_uint32_t speed;
+ grub_uint8_t stop_bits;
+ grub_uint8_t parity;
+ grub_uint8_t word_len;
+} GRUB_PACKED;
+
+static void
+real_config (struct grub_serial_port *port)
+{
+ struct grub_pl2303_config config_pl2303;
+ char xx;
+
+ if (port->configured)
+ return;
+
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
+ 1, 0x8484, 0, 1, &xx);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ 1, 0x0404, 0, 0, 0);
+
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
+ 1, 0x8484, 0, 1, &xx);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
+ 1, 0x8383, 0, 1, &xx);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
+ 1, 0x8484, 0, 1, &xx);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ 1, 0x0404, 1, 0, 0);
+
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
+ 1, 0x8484, 0, 1, &xx);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_IN,
+ 1, 0x8383, 0, 1, &xx);
+
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ 1, 0, 1, 0, 0);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ 1, 1, 0, 0, 0);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ 1, 2, 0x44, 0, 0);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ 1, 8, 0, 0, 0);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ 1, 9, 0, 0, 0);
+
+ if (port->config.stop_bits == GRUB_SERIAL_STOP_BITS_2)
+ config_pl2303.stop_bits = GRUB_PL2303_STOP_BITS_2;
+ else if (port->config.stop_bits == GRUB_SERIAL_STOP_BITS_1_5)
+ config_pl2303.stop_bits = GRUB_PL2303_STOP_BITS_1_5;
+ else
+ config_pl2303.stop_bits = GRUB_PL2303_STOP_BITS_1;
+
+ switch (port->config.parity)
+ {
+ case GRUB_SERIAL_PARITY_NONE:
+ config_pl2303.parity = GRUB_PL2303_PARITY_NONE;
+ break;
+ case GRUB_SERIAL_PARITY_ODD:
+ config_pl2303.parity = GRUB_PL2303_PARITY_ODD;
+ break;
+ case GRUB_SERIAL_PARITY_EVEN:
+ config_pl2303.parity = GRUB_PL2303_PARITY_EVEN;
+ break;
+ }
+
+ config_pl2303.word_len = port->config.word_len;
+ config_pl2303.speed = port->config.speed;
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT,
+ GRUB_PL2303_REQUEST_SET_CONFIG, 0, 0,
+ sizeof (config_pl2303), (char *) &config_pl2303);
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT,
+ 0x22, 3, 0, 0, 0);
+
+ grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
+ 1, 0, port->config.rtscts ? 0x61 : 0, 0, 0);
+ port->configured = 1;
+}
+
+/* Fetch a key. */
+static int
+pl2303_hw_fetch (struct grub_serial_port *port)
+{
+ real_config (port);
+
+ return grub_usbserial_fetch (port, 0);
+}
+
+/* Put a character. */
+static void
+pl2303_hw_put (struct grub_serial_port *port, const int c)
+{
+ char cc = c;
+
+ real_config (port);
+
+ grub_usb_bulk_write (port->usbdev, port->out_endp, 1, &cc);
+}
+
+static grub_err_t
+pl2303_hw_configure (struct grub_serial_port *port,
+ struct grub_serial_config *config)
+{
+ if (!is_speed_supported (config->speed))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port speed"));
+
+ if (config->parity != GRUB_SERIAL_PARITY_NONE
+ && config->parity != GRUB_SERIAL_PARITY_ODD
+ && config->parity != GRUB_SERIAL_PARITY_EVEN)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port parity"));
+
+ if (config->stop_bits != GRUB_SERIAL_STOP_BITS_1
+ && config->stop_bits != GRUB_SERIAL_STOP_BITS_1_5
+ && config->stop_bits != GRUB_SERIAL_STOP_BITS_2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port stop bits number"));
+
+ if (config->word_len < 5 || config->word_len > 8)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port word length"));
+
+ port->config = *config;
+ port->configured = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_serial_driver grub_pl2303_driver =
+ {
+ .configure = pl2303_hw_configure,
+ .fetch = pl2303_hw_fetch,
+ .put = pl2303_hw_put,
+ .fini = grub_usbserial_fini
+ };
+
+static const struct
+{
+ grub_uint16_t vendor, product;
+} products[] =
+ {
+ {0x067b, 0x2303}
+ };
+
+static int
+grub_pl2303_attach (grub_usb_device_t usbdev, int configno, int interfno)
+{
+ unsigned j;
+
+ for (j = 0; j < ARRAY_SIZE (products); j++)
+ if (usbdev->descdev.vendorid == products[j].vendor
+ && usbdev->descdev.prodid == products[j].product)
+ break;
+ if (j == ARRAY_SIZE (products))
+ return 0;
+
+ return grub_usbserial_attach (usbdev, configno, interfno,
+ &grub_pl2303_driver,
+ GRUB_USB_SERIAL_ENDPOINT_LAST_MATCHING,
+ GRUB_USB_SERIAL_ENDPOINT_LAST_MATCHING);
+}
+
+static struct grub_usb_attach_desc attach_hook =
+{
+ .class = 0xff,
+ .hook = grub_pl2303_attach
+};
+
+GRUB_MOD_INIT(usbserial_pl2303)
+{
+ grub_usb_register_attach_hook_class (&attach_hook);
+}
+
+GRUB_MOD_FINI(usbserial_pl2303)
+{
+ grub_serial_unregister_driver (&grub_pl2303_driver);
+ grub_usb_unregister_attach_hook_class (&attach_hook);
+}
diff --git a/grub-core/bus/usb/serial/usbdebug_late.c b/grub-core/bus/usb/serial/usbdebug_late.c
new file mode 100644
index 0000000..e88ba13
--- /dev/null
+++ b/grub-core/bus/usb/serial/usbdebug_late.c
@@ -0,0 +1,93 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010,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/serial.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/usb.h>
+#include <grub/usbserial.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+
+/* Fetch a key. */
+static int
+usbdebug_late_hw_fetch (struct grub_serial_port *port)
+{
+ return grub_usbserial_fetch (port, 0);
+}
+
+/* Put a character. */
+static void
+usbdebug_late_hw_put (struct grub_serial_port *port, const int c)
+{
+ char cc = c;
+
+ grub_usb_bulk_write (port->usbdev, port->out_endp, 1, &cc);
+}
+
+static grub_err_t
+usbdebug_late_hw_configure (struct grub_serial_port *port __attribute__ ((unused)),
+ struct grub_serial_config *config __attribute__ ((unused)))
+{
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_serial_driver grub_usbdebug_late_driver =
+ {
+ .configure = usbdebug_late_hw_configure,
+ .fetch = usbdebug_late_hw_fetch,
+ .put = usbdebug_late_hw_put,
+ .fini = grub_usbserial_fini
+ };
+
+static int
+grub_usbdebug_late_attach (grub_usb_device_t usbdev, int configno, int interfno)
+{
+ grub_usb_err_t err;
+ struct grub_usb_desc_debug debugdesc;
+
+ err = grub_usb_get_descriptor (usbdev, GRUB_USB_DESCRIPTOR_DEBUG, configno,
+ sizeof (debugdesc), (char *) &debugdesc);
+ if (err)
+ return 0;
+
+ return grub_usbserial_attach (usbdev, configno, interfno,
+ &grub_usbdebug_late_driver,
+ debugdesc.in_endp, debugdesc.out_endp);
+}
+
+static struct grub_usb_attach_desc attach_hook =
+{
+ .class = 0xff,
+ .hook = grub_usbdebug_late_attach
+};
+
+GRUB_MOD_INIT(usbserial_usbdebug_late)
+{
+ grub_usb_register_attach_hook_class (&attach_hook);
+}
+
+GRUB_MOD_FINI(usbserial_usbdebug_late)
+{
+ grub_serial_unregister_driver (&grub_usbdebug_late_driver);
+ grub_usb_unregister_attach_hook_class (&attach_hook);
+}
diff --git a/grub-core/bus/usb/uhci.c b/grub-core/bus/usb/uhci.c
new file mode 100644
index 0000000..7c5811f
--- /dev/null
+++ b/grub-core/bus/usb/uhci.c
@@ -0,0 +1,871 @@
+/* uhci.c - UHCI Support. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/usb.h>
+#include <grub/usbtrans.h>
+#include <grub/pci.h>
+#include <grub/cpu/io.h>
+#include <grub/time.h>
+#include <grub/cpu/pci.h>
+#include <grub/disk.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_UHCI_IOMASK (0x7FF << 5)
+
+#define N_QH 256
+#define N_TD 640
+
+typedef enum
+ {
+ GRUB_UHCI_REG_USBCMD = 0x00,
+ GRUB_UHCI_REG_USBINTR = 0x04,
+ GRUB_UHCI_REG_FLBASEADD = 0x08,
+ GRUB_UHCI_REG_PORTSC1 = 0x10,
+ GRUB_UHCI_REG_PORTSC2 = 0x12,
+ GRUB_UHCI_REG_USBLEGSUP = 0xc0
+ } grub_uhci_reg_t;
+
+enum
+ {
+ GRUB_UHCI_DETECT_CHANGED = (1 << 1),
+ GRUB_UHCI_DETECT_HAVE_DEVICE = 1,
+ GRUB_UHCI_DETECT_LOW_SPEED = (1 << 8)
+ };
+
+/* R/WC legacy support bits */
+enum
+ {
+ GRUB_UHCI_LEGSUP_END_A20GATE = (1 << 15),
+ GRUB_UHCI_TRAP_BY_64H_WSTAT = (1 << 11),
+ GRUB_UHCI_TRAP_BY_64H_RSTAT = (1 << 10),
+ GRUB_UHCI_TRAP_BY_60H_WSTAT = (1 << 9),
+ GRUB_UHCI_TRAP_BY_60H_RSTAT = (1 << 8)
+ };
+
+/* Reset all legacy support - clear all R/WC bits and all R/W bits */
+#define GRUB_UHCI_RESET_LEGSUP_SMI ( GRUB_UHCI_LEGSUP_END_A20GATE \
+ | GRUB_UHCI_TRAP_BY_64H_WSTAT \
+ | GRUB_UHCI_TRAP_BY_64H_RSTAT \
+ | GRUB_UHCI_TRAP_BY_60H_WSTAT \
+ | GRUB_UHCI_TRAP_BY_60H_RSTAT )
+
+/* Some UHCI commands */
+#define GRUB_UHCI_CMD_RUN_STOP (1 << 0)
+#define GRUB_UHCI_CMD_HCRESET (1 << 1)
+#define GRUB_UHCI_CMD_MAXP (1 << 7)
+
+/* Important bits in structures */
+#define GRUB_UHCI_LINK_TERMINATE 1
+#define GRUB_UHCI_LINK_QUEUE_HEAD 2
+
+enum
+ {
+ GRUB_UHCI_REG_PORTSC_CONNECT_CHANGED = 0x0002,
+ GRUB_UHCI_REG_PORTSC_PORT_ENABLED = 0x0004,
+ GRUB_UHCI_REG_PORTSC_RESUME = 0x0040,
+ GRUB_UHCI_REG_PORTSC_RESET = 0x0200,
+ GRUB_UHCI_REG_PORTSC_SUSPEND = 0x1000,
+ GRUB_UHCI_REG_PORTSC_RW = GRUB_UHCI_REG_PORTSC_PORT_ENABLED
+ | GRUB_UHCI_REG_PORTSC_RESUME | GRUB_UHCI_REG_PORTSC_RESET
+ | GRUB_UHCI_REG_PORTSC_SUSPEND,
+ /* These bits should not be written as 1 unless we really need it */
+ GRUB_UHCI_PORTSC_RWC = ((1 << 1) | (1 << 3) | (1 << 11) | (3 << 13))
+ };
+
+/* UHCI Queue Head. */
+struct grub_uhci_qh
+{
+ /* Queue head link pointer which points to the next queue head. */
+ grub_uint32_t linkptr;
+
+ /* Queue element link pointer which points to the first data object
+ within the queue. */
+ grub_uint32_t elinkptr;
+
+ /* Queue heads are aligned on 16 bytes, pad so a queue head is 16
+ bytes so we can store many in a 4K page. */
+ grub_uint8_t pad[8];
+} GRUB_PACKED;
+
+/* UHCI Transfer Descriptor. */
+struct grub_uhci_td
+{
+ /* Pointer to the next TD in the list. */
+ grub_uint32_t linkptr;
+
+ /* Control and status bits. */
+ grub_uint32_t ctrl_status;
+
+ /* All information required to transfer the Token packet. */
+ grub_uint32_t token;
+
+ /* A pointer to the data buffer, UHCI requires this pointer to be 32
+ bits. */
+ grub_uint32_t buffer;
+
+ /* Another linkptr that is not overwritten by the Host Controller.
+ This is GRUB specific. */
+ grub_uint32_t linkptr2;
+
+ /* 3 additional 32 bits words reserved for the Host Controller Driver. */
+ grub_uint32_t data[3];
+} GRUB_PACKED;
+
+typedef volatile struct grub_uhci_td *grub_uhci_td_t;
+typedef volatile struct grub_uhci_qh *grub_uhci_qh_t;
+
+struct grub_uhci
+{
+ grub_port_t iobase;
+ volatile grub_uint32_t *framelist_virt;
+ grub_uint32_t framelist_phys;
+ struct grub_pci_dma_chunk *framelist_chunk;
+
+ /* N_QH Queue Heads. */
+ struct grub_pci_dma_chunk *qh_chunk;
+ volatile grub_uhci_qh_t qh_virt;
+ grub_uint32_t qh_phys;
+
+ /* N_TD Transfer Descriptors. */
+ struct grub_pci_dma_chunk *td_chunk;
+ volatile grub_uhci_td_t td_virt;
+ grub_uint32_t td_phys;
+
+ /* Free Transfer Descriptors. */
+ grub_uhci_td_t tdfree;
+
+ int qh_busy[N_QH];
+
+ struct grub_uhci *next;
+};
+
+static struct grub_uhci *uhci;
+
+static grub_uint16_t
+grub_uhci_readreg16 (struct grub_uhci *u, grub_uhci_reg_t reg)
+{
+ return grub_inw (u->iobase + reg);
+}
+
+#if 0
+static grub_uint32_t
+grub_uhci_readreg32 (struct grub_uhci *u, grub_uhci_reg_t reg)
+{
+ return grub_inl (u->iobase + reg);
+}
+#endif
+
+static void
+grub_uhci_writereg16 (struct grub_uhci *u,
+ grub_uhci_reg_t reg, grub_uint16_t val)
+{
+ grub_outw (val, u->iobase + reg);
+}
+
+static void
+grub_uhci_writereg32 (struct grub_uhci *u,
+ grub_uhci_reg_t reg, grub_uint32_t val)
+{
+ grub_outl (val, u->iobase + reg);
+}
+
+/* Iterate over all PCI devices. Determine if a device is an UHCI
+ controller. If this is the case, initialize it. */
+static int
+grub_uhci_pci_iter (grub_pci_device_t dev,
+ grub_pci_id_t pciid __attribute__((unused)),
+ void *data __attribute__ ((unused)))
+{
+ grub_uint32_t class_code;
+ grub_uint32_t class;
+ grub_uint32_t subclass;
+ grub_uint32_t interf;
+ grub_uint32_t base;
+ grub_uint32_t fp;
+ grub_pci_address_t addr;
+ struct grub_uhci *u;
+ int i;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class_code = grub_pci_read (addr) >> 8;
+
+ interf = class_code & 0xFF;
+ subclass = (class_code >> 8) & 0xFF;
+ class = class_code >> 16;
+
+ /* If this is not an UHCI controller, just return. */
+ if (class != 0x0c || subclass != 0x03 || interf != 0x00)
+ return 0;
+
+ /* Determine IO base address. */
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG4);
+ base = grub_pci_read (addr);
+ /* Stop if there is no IO space base address defined. */
+ if ((base & GRUB_PCI_ADDR_SPACE_MASK) != GRUB_PCI_ADDR_SPACE_IO)
+ return 0;
+
+ if ((base & GRUB_UHCI_IOMASK) == 0)
+ return 0;
+
+ /* Set bus master - needed for coreboot or broken BIOSes */
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write_word(addr, GRUB_PCI_COMMAND_IO_ENABLED
+ | GRUB_PCI_COMMAND_BUS_MASTER
+ | GRUB_PCI_COMMAND_MEM_ENABLED
+ | grub_pci_read_word (addr));
+
+ grub_dprintf ("uhci", "base = %x\n", base);
+
+ /* Allocate memory for the controller and register it. */
+ u = grub_zalloc (sizeof (*u));
+ if (! u)
+ return 1;
+
+ u->iobase = (base & GRUB_UHCI_IOMASK) + GRUB_MACHINE_PCI_IO_BASE;
+
+ /* Reset PIRQ and SMI */
+ addr = grub_pci_make_address (dev, GRUB_UHCI_REG_USBLEGSUP);
+ grub_pci_write_word(addr, GRUB_UHCI_RESET_LEGSUP_SMI);
+ /* Reset the HC */
+ grub_uhci_writereg16(u, GRUB_UHCI_REG_USBCMD, GRUB_UHCI_CMD_HCRESET);
+ grub_millisleep(5);
+ /* Disable interrupts and commands (just to be safe) */
+ grub_uhci_writereg16(u, GRUB_UHCI_REG_USBINTR, 0);
+ /* Finish HC reset, HC remains disabled */
+ grub_uhci_writereg16(u, GRUB_UHCI_REG_USBCMD, 0);
+ /* Read back to be sure PCI write is done */
+ grub_uhci_readreg16(u, GRUB_UHCI_REG_USBCMD);
+
+ /* Reserve a page for the frame list. */
+ u->framelist_chunk = grub_memalign_dma32 (4096, 4096);
+ if (! u->framelist_chunk)
+ goto fail;
+ u->framelist_virt = grub_dma_get_virt (u->framelist_chunk);
+ u->framelist_phys = grub_dma_get_phys (u->framelist_chunk);
+
+ grub_dprintf ("uhci",
+ "class=0x%02x 0x%02x interface 0x%02x base=0x%x framelist=%p\n",
+ class, subclass, interf, u->iobase, u->framelist_virt);
+
+ /* The QH pointer of UHCI is only 32 bits, make sure this
+ code works on on 64 bits architectures. */
+ u->qh_chunk = grub_memalign_dma32 (4096, sizeof(struct grub_uhci_qh) * N_QH);
+ if (! u->qh_chunk)
+ goto fail;
+ u->qh_virt = grub_dma_get_virt (u->qh_chunk);
+ u->qh_phys = grub_dma_get_phys (u->qh_chunk);
+
+ /* The TD pointer of UHCI is only 32 bits, make sure this
+ code works on on 64 bits architectures. */
+ u->td_chunk = grub_memalign_dma32 (4096, sizeof(struct grub_uhci_td) * N_TD);
+ if (! u->td_chunk)
+ goto fail;
+ u->td_virt = grub_dma_get_virt (u->td_chunk);
+ u->td_phys = grub_dma_get_phys (u->td_chunk);
+
+ grub_dprintf ("uhci", "QH=%p, TD=%p\n",
+ u->qh_virt, u->td_virt);
+
+ /* Link all Transfer Descriptors in a list of available Transfer
+ Descriptors. */
+ for (i = 0; i < N_TD; i++)
+ u->td_virt[i].linkptr = u->td_phys + (i + 1) * sizeof(struct grub_uhci_td);
+ u->td_virt[N_TD - 2].linkptr = 0;
+ u->tdfree = u->td_virt;
+
+ /* Setup the frame list pointers. Since no isochronous transfers
+ are and will be supported, they all point to the (same!) queue
+ head. */
+ fp = u->qh_phys & (~15);
+ /* Mark this as a queue head. */
+ fp |= 2;
+ for (i = 0; i < 1024; i++)
+ u->framelist_virt[i] = fp;
+ /* Program the framelist address into the UHCI controller. */
+ grub_uhci_writereg32 (u, GRUB_UHCI_REG_FLBASEADD, u->framelist_phys);
+
+ /* Make the Queue Heads point to each other. */
+ for (i = 0; i < N_QH; i++)
+ {
+ /* Point to the next QH. */
+ u->qh_virt[i].linkptr = ((u->qh_phys
+ + (i + 1) * sizeof(struct grub_uhci_qh))
+ & (~15));
+
+ /* This is a QH. */
+ u->qh_virt[i].linkptr |= GRUB_UHCI_LINK_QUEUE_HEAD;
+
+ /* For the moment, do not point to a Transfer Descriptor. These
+ are set at transfer time, so just terminate it. */
+ u->qh_virt[i].elinkptr = 1;
+ }
+
+ /* The last Queue Head should terminate. */
+ u->qh_virt[N_QH - 1].linkptr = 1;
+
+ /* Enable UHCI again. */
+ grub_uhci_writereg16 (u, GRUB_UHCI_REG_USBCMD,
+ GRUB_UHCI_CMD_RUN_STOP | GRUB_UHCI_CMD_MAXP);
+
+ /* UHCI is initialized and ready for transfers. */
+ grub_dprintf ("uhci", "UHCI initialized\n");
+
+
+#if 0
+ {
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ grub_uint16_t frnum;
+
+ frnum = grub_uhci_readreg16 (u, 6);
+ grub_dprintf ("uhci", "Framenum=%d\n", frnum);
+ grub_millisleep (100);
+ }
+ }
+#endif
+
+ /* Link to uhci now that initialisation is successful. */
+ u->next = uhci;
+ uhci = u;
+
+ return 0;
+
+ fail:
+ if (u)
+ {
+ grub_dma_free (u->qh_chunk);
+ grub_dma_free (u->framelist_chunk);
+ }
+ grub_free (u);
+
+ return 1;
+}
+
+static void
+grub_uhci_inithw (void)
+{
+ grub_pci_iterate (grub_uhci_pci_iter, NULL);
+}
+
+static grub_uhci_td_t
+grub_alloc_td (struct grub_uhci *u)
+{
+ grub_uhci_td_t ret;
+
+ /* Check if there is a Transfer Descriptor available. */
+ if (! u->tdfree)
+ return NULL;
+
+ ret = u->tdfree;
+ u->tdfree = grub_dma_phys2virt (u->tdfree->linkptr, u->td_chunk);
+
+ return ret;
+}
+
+static void
+grub_free_td (struct grub_uhci *u, grub_uhci_td_t td)
+{
+ td->linkptr = grub_dma_virt2phys (u->tdfree, u->td_chunk);
+ u->tdfree = td;
+}
+
+static void
+grub_free_queue (struct grub_uhci *u, grub_uhci_qh_t qh, grub_uhci_td_t td,
+ grub_usb_transfer_t transfer, grub_size_t *actual)
+{
+ int i; /* Index of TD in transfer */
+
+ u->qh_busy[qh - u->qh_virt] = 0;
+
+ *actual = 0;
+
+ /* Free the TDs in this queue and set last_trans. */
+ for (i=0; td; i++)
+ {
+ grub_uhci_td_t tdprev;
+
+ grub_dprintf ("uhci", "Freeing %p\n", td);
+ /* Check state of TD and possibly set last_trans */
+ if (transfer && (td->linkptr & 1))
+ transfer->last_trans = i;
+
+ *actual += (td->ctrl_status + 1) & 0x7ff;
+
+ /* Unlink the queue. */
+ tdprev = td;
+ if (!td->linkptr2)
+ td = 0;
+ else
+ td = grub_dma_phys2virt (td->linkptr2, u->td_chunk);
+
+ /* Free the TD. */
+ grub_free_td (u, tdprev);
+ }
+}
+
+static grub_uhci_qh_t
+grub_alloc_qh (struct grub_uhci *u,
+ grub_transaction_type_t tr __attribute__((unused)))
+{
+ int i;
+ grub_uhci_qh_t qh;
+
+ /* Look for a Queue Head for this transfer. Skip the first QH if
+ this is a Interrupt Transfer. */
+#if 0
+ if (tr == GRUB_USB_TRANSACTION_TYPE_INTERRUPT)
+ i = 0;
+ else
+#endif
+ i = 1;
+
+ for (; i < N_QH; i++)
+ {
+ if (!u->qh_busy[i])
+ break;
+ }
+ qh = &u->qh_virt[i];
+ if (i == N_QH)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "no free queue heads available");
+ return NULL;
+ }
+
+ u->qh_busy[qh - u->qh_virt] = 1;
+
+ return qh;
+}
+
+static grub_uhci_td_t
+grub_uhci_transaction (struct grub_uhci *u, unsigned int endp,
+ grub_transfer_type_t type, unsigned int addr,
+ unsigned int toggle, grub_size_t size,
+ grub_uint32_t data, grub_usb_speed_t speed)
+{
+ grub_uhci_td_t td;
+ static const unsigned int tf[] = { 0x69, 0xE1, 0x2D };
+
+ /* XXX: Check if data is <4GB. If it isn't, just copy stuff around.
+ This is only relevant for 64 bits architectures. */
+
+ /* Grab a free Transfer Descriptor and initialize it. */
+ td = grub_alloc_td (u);
+ if (! td)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "no transfer descriptors available for UHCI transfer");
+ return 0;
+ }
+
+ grub_dprintf ("uhci",
+ "transaction: endp=%d, type=%d, addr=%d, toggle=%d, size=%lu data=0x%x td=%p\n",
+ endp, type, addr, toggle, (unsigned long) size, data, td);
+
+ /* Don't point to any TD, just terminate. */
+ td->linkptr = 1;
+
+ /* Active! Only retry a transfer 3 times. */
+ td->ctrl_status = (1 << 23) | (3 << 27) |
+ ((speed == GRUB_USB_SPEED_LOW) ? (1 << 26) : 0);
+
+ /* If zero bytes are transmitted, size is 0x7FF. Otherwise size is
+ size-1. */
+ if (size == 0)
+ size = 0x7FF;
+ else
+ size = size - 1;
+
+ /* Setup whatever is required for the token packet. */
+ td->token = ((size << 21) | (toggle << 19) | (endp << 15)
+ | (addr << 8) | tf[type]);
+
+ td->buffer = data;
+
+ return td;
+}
+
+struct grub_uhci_transfer_controller_data
+{
+ grub_uhci_qh_t qh;
+ grub_uhci_td_t td_first;
+};
+
+static grub_usb_err_t
+grub_uhci_setup_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer)
+{
+ struct grub_uhci *u = (struct grub_uhci *) dev->data;
+ grub_uhci_td_t td;
+ grub_uhci_td_t td_prev = NULL;
+ int i;
+ struct grub_uhci_transfer_controller_data *cdata;
+
+ cdata = grub_malloc (sizeof (*cdata));
+ if (!cdata)
+ return GRUB_USB_ERR_INTERNAL;
+
+ cdata->td_first = NULL;
+
+ /* Allocate a queue head for the transfer queue. */
+ cdata->qh = grub_alloc_qh (u, GRUB_USB_TRANSACTION_TYPE_CONTROL);
+ if (! cdata->qh)
+ {
+ grub_free (cdata);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ grub_dprintf ("uhci", "transfer, iobase:%08x\n", u->iobase);
+
+ for (i = 0; i < transfer->transcnt; i++)
+ {
+ grub_usb_transaction_t tr = &transfer->transactions[i];
+
+ td = grub_uhci_transaction (u, transfer->endpoint & 15, tr->pid,
+ transfer->devaddr, tr->toggle,
+ tr->size, tr->data,
+ transfer->dev->speed);
+ if (! td)
+ {
+ grub_size_t actual = 0;
+ /* Terminate and free. */
+ if (td_prev)
+ {
+ td_prev->linkptr2 = 0;
+ td_prev->linkptr = 1;
+ }
+
+ if (cdata->td_first)
+ grub_free_queue (u, cdata->qh, cdata->td_first, NULL, &actual);
+
+ grub_free (cdata);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ if (! cdata->td_first)
+ cdata->td_first = td;
+ else
+ {
+ td_prev->linkptr2 = grub_dma_virt2phys (td, u->td_chunk);
+ td_prev->linkptr = grub_dma_virt2phys (td, u->td_chunk);
+ td_prev->linkptr |= 4;
+ }
+ td_prev = td;
+ }
+ td_prev->linkptr2 = 0;
+ td_prev->linkptr = 1;
+
+ grub_dprintf ("uhci", "setup transaction %d\n", transfer->type);
+
+ /* Link it into the queue and terminate. Now the transaction can
+ take place. */
+ cdata->qh->elinkptr = grub_dma_virt2phys (cdata->td_first, u->td_chunk);
+
+ grub_dprintf ("uhci", "initiate transaction\n");
+
+ transfer->controller_data = cdata;
+
+ return GRUB_USB_ERR_NONE;
+}
+
+static grub_usb_err_t
+grub_uhci_check_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer,
+ grub_size_t *actual)
+{
+ struct grub_uhci *u = (struct grub_uhci *) dev->data;
+ grub_uhci_td_t errtd;
+ struct grub_uhci_transfer_controller_data *cdata = transfer->controller_data;
+
+ *actual = 0;
+
+ if (cdata->qh->elinkptr & ~0x0f)
+ errtd = grub_dma_phys2virt (cdata->qh->elinkptr & ~0x0f, u->qh_chunk);
+ else
+ errtd = 0;
+
+ if (errtd)
+ {
+ grub_dprintf ("uhci", ">t status=0x%02x data=0x%02x td=%p, %x\n",
+ errtd->ctrl_status, errtd->buffer & (~15), errtd,
+ cdata->qh->elinkptr);
+ }
+
+ /* Check if the transaction completed. */
+ if (cdata->qh->elinkptr & 1)
+ {
+ grub_dprintf ("uhci", "transaction complete\n");
+
+ /* Place the QH back in the free list and deallocate the associated
+ TDs. */
+ cdata->qh->elinkptr = 1;
+ grub_free_queue (u, cdata->qh, cdata->td_first, transfer, actual);
+ grub_free (cdata);
+ return GRUB_USB_ERR_NONE;
+ }
+
+ if (errtd && !(errtd->ctrl_status & (1 << 23)))
+ {
+ grub_usb_err_t err = GRUB_USB_ERR_NONE;
+
+ /* Check if the endpoint is stalled. */
+ if (errtd->ctrl_status & (1 << 22))
+ err = GRUB_USB_ERR_STALL;
+
+ /* Check if an error related to the data buffer occurred. */
+ else if (errtd->ctrl_status & (1 << 21))
+ err = GRUB_USB_ERR_DATA;
+
+ /* Check if a babble error occurred. */
+ else if (errtd->ctrl_status & (1 << 20))
+ err = GRUB_USB_ERR_BABBLE;
+
+ /* Check if a NAK occurred. */
+ else if (errtd->ctrl_status & (1 << 19))
+ err = GRUB_USB_ERR_NAK;
+
+ /* Check if a timeout occurred. */
+ else if (errtd->ctrl_status & (1 << 18))
+ err = GRUB_USB_ERR_TIMEOUT;
+
+ /* Check if a bitstuff error occurred. */
+ else if (errtd->ctrl_status & (1 << 17))
+ err = GRUB_USB_ERR_BITSTUFF;
+
+ if (err)
+ {
+ grub_dprintf ("uhci", "transaction failed\n");
+
+ /* Place the QH back in the free list and deallocate the associated
+ TDs. */
+ cdata->qh->elinkptr = 1;
+ grub_free_queue (u, cdata->qh, cdata->td_first, transfer, actual);
+ grub_free (cdata);
+
+ return err;
+ }
+ }
+
+ /* Fall through, no errors occurred, so the QH might be
+ updated. */
+ grub_dprintf ("uhci", "transaction fallthrough\n");
+
+ return GRUB_USB_ERR_WAIT;
+}
+
+static grub_usb_err_t
+grub_uhci_cancel_transfer (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer)
+{
+ struct grub_uhci *u = (struct grub_uhci *) dev->data;
+ grub_size_t actual;
+ struct grub_uhci_transfer_controller_data *cdata = transfer->controller_data;
+
+ grub_dprintf ("uhci", "transaction cancel\n");
+
+ /* Place the QH back in the free list and deallocate the associated
+ TDs. */
+ cdata->qh->elinkptr = 1;
+ grub_free_queue (u, cdata->qh, cdata->td_first, transfer, &actual);
+ grub_free (cdata);
+
+ return GRUB_USB_ERR_NONE;
+}
+
+static int
+grub_uhci_iterate (grub_usb_controller_iterate_hook_t hook, void *hook_data)
+{
+ struct grub_uhci *u;
+ struct grub_usb_controller dev;
+
+ for (u = uhci; u; u = u->next)
+ {
+ dev.data = u;
+ if (hook (&dev, hook_data))
+ return 1;
+ }
+
+ return 0;
+}
+
+static grub_usb_err_t
+grub_uhci_portstatus (grub_usb_controller_t dev,
+ unsigned int port, unsigned int enable)
+{
+ struct grub_uhci *u = (struct grub_uhci *) dev->data;
+ int reg;
+ unsigned int status;
+ grub_uint64_t endtime;
+
+ grub_dprintf ("uhci", "portstatus, iobase:%08x\n", u->iobase);
+
+ grub_dprintf ("uhci", "enable=%d port=%d\n", enable, port);
+
+ if (port == 0)
+ reg = GRUB_UHCI_REG_PORTSC1;
+ else if (port == 1)
+ reg = GRUB_UHCI_REG_PORTSC2;
+ else
+ return GRUB_USB_ERR_INTERNAL;
+
+ status = grub_uhci_readreg16 (u, reg);
+ grub_dprintf ("uhci", "detect=0x%02x\n", status);
+
+ if (!enable) /* We don't need reset port */
+ {
+ /* Disable the port. */
+ grub_uhci_writereg16 (u, reg, 0 << 2);
+ grub_dprintf ("uhci", "waiting for the port to be disabled\n");
+ endtime = grub_get_time_ms () + 1000;
+ while ((grub_uhci_readreg16 (u, reg) & (1 << 2)))
+ if (grub_get_time_ms () > endtime)
+ return GRUB_USB_ERR_TIMEOUT;
+
+ status = grub_uhci_readreg16 (u, reg);
+ grub_dprintf ("uhci", ">3detect=0x%02x\n", status);
+ return GRUB_USB_ERR_NONE;
+ }
+
+ /* Reset the port. */
+ status = grub_uhci_readreg16 (u, reg) & ~GRUB_UHCI_PORTSC_RWC;
+ grub_uhci_writereg16 (u, reg, status | (1 << 9));
+ grub_uhci_readreg16 (u, reg); /* Ensure it is writen... */
+
+ /* Wait for the reset to complete. XXX: How long exactly? */
+ grub_millisleep (50); /* For root hub should be nominaly 50ms */
+ status = grub_uhci_readreg16 (u, reg) & ~GRUB_UHCI_PORTSC_RWC;
+ grub_uhci_writereg16 (u, reg, status & ~(1 << 9));
+ grub_uhci_readreg16 (u, reg); /* Ensure it is writen... */
+
+ /* Note: some debug prints were removed because they affected reset/enable timing. */
+
+ grub_millisleep (1); /* Probably not needed at all or only few microsecs. */
+
+ /* Reset bits Connect & Enable Status Change */
+ status = grub_uhci_readreg16 (u, reg) & ~GRUB_UHCI_PORTSC_RWC;
+ grub_uhci_writereg16 (u, reg, status | (1 << 3) | GRUB_UHCI_REG_PORTSC_CONNECT_CHANGED);
+ grub_uhci_readreg16 (u, reg); /* Ensure it is writen... */
+
+ /* Enable the port. */
+ status = grub_uhci_readreg16 (u, reg) & ~GRUB_UHCI_PORTSC_RWC;
+ grub_uhci_writereg16 (u, reg, status | (1 << 2));
+ grub_uhci_readreg16 (u, reg); /* Ensure it is writen... */
+
+ endtime = grub_get_time_ms () + 1000;
+ while (! ((status = grub_uhci_readreg16 (u, reg)) & (1 << 2)))
+ if (grub_get_time_ms () > endtime)
+ return GRUB_USB_ERR_TIMEOUT;
+
+ /* Reset recovery time */
+ grub_millisleep (10);
+
+ /* Read final port status */
+ status = grub_uhci_readreg16 (u, reg);
+ grub_dprintf ("uhci", ">3detect=0x%02x\n", status);
+
+
+ return GRUB_USB_ERR_NONE;
+}
+
+static grub_usb_speed_t
+grub_uhci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
+{
+ struct grub_uhci *u = (struct grub_uhci *) dev->data;
+ int reg;
+ unsigned int status;
+
+ grub_dprintf ("uhci", "detect_dev, iobase:%08x\n", u->iobase);
+
+ if (port == 0)
+ reg = GRUB_UHCI_REG_PORTSC1;
+ else if (port == 1)
+ reg = GRUB_UHCI_REG_PORTSC2;
+ else
+ return GRUB_USB_SPEED_NONE;
+
+ status = grub_uhci_readreg16 (u, reg);
+
+ grub_dprintf ("uhci", "detect=0x%02x port=%d\n", status, port);
+
+ /* Connect Status Change bit - it detects change of connection */
+ if (status & GRUB_UHCI_DETECT_CHANGED)
+ {
+ *changed = 1;
+ /* Reset bit Connect Status Change */
+ grub_uhci_writereg16 (u, reg, (status & GRUB_UHCI_REG_PORTSC_RW)
+ | GRUB_UHCI_REG_PORTSC_CONNECT_CHANGED);
+ }
+ else
+ *changed = 0;
+
+ if (! (status & GRUB_UHCI_DETECT_HAVE_DEVICE))
+ return GRUB_USB_SPEED_NONE;
+ else if (status & GRUB_UHCI_DETECT_LOW_SPEED)
+ return GRUB_USB_SPEED_LOW;
+ else
+ return GRUB_USB_SPEED_FULL;
+}
+
+static int
+grub_uhci_hubports (grub_usb_controller_t dev __attribute__((unused)))
+{
+ /* The root hub has exactly two ports. */
+ return 2;
+}
+
+
+static struct grub_usb_controller_dev usb_controller =
+{
+ .name = "uhci",
+ .iterate = grub_uhci_iterate,
+ .setup_transfer = grub_uhci_setup_transfer,
+ .check_transfer = grub_uhci_check_transfer,
+ .cancel_transfer = grub_uhci_cancel_transfer,
+ .hubports = grub_uhci_hubports,
+ .portstatus = grub_uhci_portstatus,
+ .detect_dev = grub_uhci_detect_dev,
+ /* estimated max. count of TDs for one bulk transfer */
+ .max_bulk_tds = N_TD * 3 / 4
+};
+
+GRUB_MOD_INIT(uhci)
+{
+ grub_stop_disk_firmware ();
+
+ grub_uhci_inithw ();
+ grub_usb_controller_dev_register (&usb_controller);
+ grub_dprintf ("uhci", "registered\n");
+}
+
+GRUB_MOD_FINI(uhci)
+{
+ struct grub_uhci *u;
+
+ /* Disable all UHCI controllers. */
+ for (u = uhci; u; u = u->next)
+ grub_uhci_writereg16 (u, GRUB_UHCI_REG_USBCMD, 0);
+
+ /* Unregister the controller. */
+ grub_usb_controller_dev_unregister (&usb_controller);
+}
diff --git a/grub-core/bus/usb/usb.c b/grub-core/bus/usb/usb.c
new file mode 100644
index 0000000..7cb3cc2
--- /dev/null
+++ b/grub-core/bus/usb/usb.c
@@ -0,0 +1,346 @@
+/* usb.c - Generic USB interfaces. */
+/*
+ * 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/dl.h>
+#include <grub/mm.h>
+#include <grub/usb.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/term.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct grub_usb_attach_desc *attach_hooks;
+
+#if 0
+/* Context for grub_usb_controller_iterate. */
+struct grub_usb_controller_iterate_ctx
+{
+ grub_usb_controller_iterate_hook_t hook;
+ void *hook_data;
+ grub_usb_controller_dev_t p;
+};
+
+/* Helper for grub_usb_controller_iterate. */
+static int
+grub_usb_controller_iterate_iter (grub_usb_controller_t dev, void *data)
+{
+ struct grub_usb_controller_iterate_ctx *ctx = data;
+
+ dev->dev = ctx->p;
+ if (ctx->hook (dev, ctx->hook_data))
+ return 1;
+ return 0;
+}
+
+int
+grub_usb_controller_iterate (grub_usb_controller_iterate_hook_t hook,
+ void *hook_data)
+{
+ struct grub_usb_controller_iterate_ctx ctx = {
+ .hook = hook,
+ .hook_data = hook_data
+ };
+
+ /* Iterate over all controller drivers. */
+ for (ctx.p = grub_usb_list; ctx.p; ctx.p = ctx.p->next)
+ {
+ /* Iterate over the busses of the controllers. XXX: Actually, a
+ hub driver should do this. */
+ if (ctx.p->iterate (grub_usb_controller_iterate_iter, &ctx))
+ return 1;
+ }
+
+ return 0;
+}
+#endif
+
+
+grub_usb_err_t
+grub_usb_clear_halt (grub_usb_device_t dev, int endpoint)
+{
+ if (endpoint >= GRUB_USB_MAX_TOGGLE)
+ return GRUB_USB_ERR_BADDEVICE;
+
+ dev->toggle[endpoint] = 0;
+ return grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_STANDARD
+ | GRUB_USB_REQTYPE_TARGET_ENDP),
+ GRUB_USB_REQ_CLEAR_FEATURE,
+ GRUB_USB_FEATURE_ENDP_HALT,
+ endpoint, 0, 0);
+}
+
+grub_usb_err_t
+grub_usb_set_configuration (grub_usb_device_t dev, int configuration)
+{
+ grub_memset (dev->toggle, 0, sizeof (dev->toggle));
+
+ return grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_STANDARD
+ | GRUB_USB_REQTYPE_TARGET_DEV),
+ GRUB_USB_REQ_SET_CONFIGURATION, configuration,
+ 0, 0, NULL);
+}
+
+grub_usb_err_t
+grub_usb_get_descriptor (grub_usb_device_t dev,
+ grub_uint8_t type, grub_uint8_t index,
+ grub_size_t size, char *data)
+{
+ return grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
+ | GRUB_USB_REQTYPE_STANDARD
+ | GRUB_USB_REQTYPE_TARGET_DEV),
+ GRUB_USB_REQ_GET_DESCRIPTOR,
+ (type << 8) | index,
+ 0, size, data);
+}
+
+grub_usb_err_t
+grub_usb_device_initialize (grub_usb_device_t dev)
+{
+ struct grub_usb_desc_device *descdev;
+ struct grub_usb_desc_config config;
+ grub_usb_err_t err;
+ int i;
+
+ /* First we have to read first 8 bytes only and determine
+ * max. size of packet */
+ dev->descdev.maxsize0 = 0; /* invalidating, for safety only, can be removed if it is sure it is zero here */
+ err = grub_usb_get_descriptor (dev, GRUB_USB_DESCRIPTOR_DEVICE,
+ 0, 8, (char *) &dev->descdev);
+ if (err)
+ return err;
+
+ /* Now we have valid value in dev->descdev.maxsize0,
+ * so we can read whole device descriptor */
+ err = grub_usb_get_descriptor (dev, GRUB_USB_DESCRIPTOR_DEVICE,
+ 0, sizeof (struct grub_usb_desc_device),
+ (char *) &dev->descdev);
+ if (err)
+ return err;
+ descdev = &dev->descdev;
+
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++)
+ dev->config[i].descconf = NULL;
+
+ if (descdev->configcnt == 0 || descdev->configcnt > GRUB_USB_MAX_CONF)
+ {
+ err = GRUB_USB_ERR_BADDEVICE;
+ goto fail;
+ }
+
+ for (i = 0; i < descdev->configcnt; i++)
+ {
+ int pos;
+ int currif;
+ char *data;
+ struct grub_usb_desc *desc;
+
+ /* First just read the first 4 bytes of the configuration
+ descriptor, after that it is known how many bytes really have
+ to be read. */
+ err = grub_usb_get_descriptor (dev, GRUB_USB_DESCRIPTOR_CONFIG, i, 4,
+ (char *) &config);
+
+ data = grub_malloc (config.totallen);
+ if (! data)
+ {
+ err = GRUB_USB_ERR_INTERNAL;
+ goto fail;
+ }
+
+ dev->config[i].descconf = (struct grub_usb_desc_config *) data;
+ err = grub_usb_get_descriptor (dev, GRUB_USB_DESCRIPTOR_CONFIG, i,
+ config.totallen, data);
+ if (err)
+ goto fail;
+
+ /* Skip the configuration descriptor. */
+ pos = dev->config[i].descconf->length;
+
+ if (dev->config[i].descconf->numif > GRUB_USB_MAX_IF)
+ {
+ err = GRUB_USB_ERR_BADDEVICE;
+ goto fail;
+ }
+
+ /* Read all interfaces. */
+ for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
+ {
+ while (pos < config.totallen)
+ {
+ desc = (struct grub_usb_desc *)&data[pos];
+ if (desc->type == GRUB_USB_DESCRIPTOR_INTERFACE)
+ break;
+ if (!desc->length)
+ {
+ err = GRUB_USB_ERR_BADDEVICE;
+ goto fail;
+ }
+ pos += desc->length;
+ }
+
+ dev->config[i].interf[currif].descif
+ = (struct grub_usb_desc_if *) &data[pos];
+ pos += dev->config[i].interf[currif].descif->length;
+
+ while (pos < config.totallen)
+ {
+ desc = (struct grub_usb_desc *)&data[pos];
+ if (desc->type == GRUB_USB_DESCRIPTOR_ENDPOINT)
+ break;
+ if (!desc->length)
+ {
+ err = GRUB_USB_ERR_BADDEVICE;
+ goto fail;
+ }
+ pos += desc->length;
+ }
+
+ /* Point to the first endpoint. */
+ dev->config[i].interf[currif].descendp
+ = (struct grub_usb_desc_endp *) &data[pos];
+ pos += (sizeof (struct grub_usb_desc_endp)
+ * dev->config[i].interf[currif].descif->endpointcnt);
+ }
+ }
+
+ return GRUB_USB_ERR_NONE;
+
+ fail:
+
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++)
+ grub_free (dev->config[i].descconf);
+
+ return err;
+}
+
+void grub_usb_device_attach (grub_usb_device_t dev)
+{
+ int i;
+
+ /* XXX: Just check configuration 0 for now. */
+ for (i = 0; i < dev->config[0].descconf->numif; i++)
+ {
+ struct grub_usb_desc_if *interf;
+ struct grub_usb_attach_desc *desc;
+
+ interf = dev->config[0].interf[i].descif;
+
+ grub_dprintf ("usb", "iterate: interf=%d, class=%d, subclass=%d, protocol=%d\n",
+ i, interf->class, interf->subclass, interf->protocol);
+
+ if (dev->config[0].interf[i].attached)
+ continue;
+
+ for (desc = attach_hooks; desc; desc = desc->next)
+ if (interf->class == desc->class)
+ {
+ grub_boot_time ("Probing USB device driver class %x", desc->class);
+ if (desc->hook (dev, 0, i))
+ dev->config[0].interf[i].attached = 1;
+ grub_boot_time ("Probed USB device driver class %x", desc->class);
+ }
+
+ if (dev->config[0].interf[i].attached)
+ continue;
+
+ switch (interf->class)
+ {
+ case GRUB_USB_CLASS_MASS_STORAGE:
+ grub_dl_load ("usbms");
+ grub_print_error ();
+ break;
+ case GRUB_USB_CLASS_HID:
+ grub_dl_load ("usb_keyboard");
+ grub_print_error ();
+ break;
+ case 0xff:
+ /* FIXME: don't load useless modules. */
+ grub_dl_load ("usbserial_ftdi");
+ grub_print_error ();
+ grub_dl_load ("usbserial_pl2303");
+ grub_print_error ();
+ grub_dl_load ("usbserial_usbdebug");
+ grub_print_error ();
+ break;
+ }
+ }
+}
+
+/* Helper for grub_usb_register_attach_hook_class. */
+static int
+grub_usb_register_attach_hook_class_iter (grub_usb_device_t usbdev, void *data)
+{
+ struct grub_usb_attach_desc *desc = data;
+ struct grub_usb_desc_device *descdev = &usbdev->descdev;
+ int i;
+
+ if (descdev->class != 0 || descdev->subclass || descdev->protocol != 0
+ || descdev->configcnt == 0)
+ return 0;
+
+ /* XXX: Just check configuration 0 for now. */
+ for (i = 0; i < usbdev->config[0].descconf->numif; i++)
+ {
+ struct grub_usb_desc_if *interf;
+
+ interf = usbdev->config[0].interf[i].descif;
+
+ grub_dprintf ("usb", "iterate: interf=%d, class=%d, subclass=%d, protocol=%d\n",
+ i, interf->class, interf->subclass, interf->protocol);
+
+ if (usbdev->config[0].interf[i].attached)
+ continue;
+
+ if (interf->class != desc->class)
+ continue;
+ if (desc->hook (usbdev, 0, i))
+ usbdev->config[0].interf[i].attached = 1;
+ }
+
+ return 0;
+}
+
+void
+grub_usb_register_attach_hook_class (struct grub_usb_attach_desc *desc)
+{
+ desc->next = attach_hooks;
+ attach_hooks = desc;
+
+ grub_usb_iterate (grub_usb_register_attach_hook_class_iter, desc);
+}
+
+void
+grub_usb_unregister_attach_hook_class (struct grub_usb_attach_desc *desc)
+{
+ grub_list_remove (GRUB_AS_LIST (desc));
+}
+
+
+GRUB_MOD_INIT(usb)
+{
+ grub_term_poll_usb = grub_usb_poll_devices;
+}
+
+GRUB_MOD_FINI(usb)
+{
+ grub_term_poll_usb = NULL;
+}
diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
new file mode 100644
index 0000000..85ccf3a
--- /dev/null
+++ b/grub-core/bus/usb/usbhub.c
@@ -0,0 +1,756 @@
+/* usb.c - USB Hub Support. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/usb.h>
+#include <grub/misc.h>
+#include <grub/time.h>
+
+#define GRUB_USBHUB_MAX_DEVICES 128
+
+/* USB Supports 127 devices, with device 0 as special case. */
+static struct grub_usb_device *grub_usb_devs[GRUB_USBHUB_MAX_DEVICES];
+
+static int rescan = 0;
+static int npending = 0;
+
+struct grub_usb_hub
+{
+ struct grub_usb_hub *next;
+ grub_usb_controller_t controller;
+ int nports;
+ struct grub_usb_device **devices;
+ struct grub_usb_hub_port *ports;
+ grub_usb_device_t dev;
+};
+
+static struct grub_usb_hub *hubs;
+static grub_usb_controller_dev_t grub_usb_list;
+
+/* Add a device that currently has device number 0 and resides on
+ CONTROLLER, the Hub reported that the device speed is SPEED. */
+static grub_usb_device_t
+grub_usb_hub_add_dev (grub_usb_controller_t controller,
+ grub_usb_speed_t speed,
+ int split_hubport, int split_hubaddr)
+{
+ grub_usb_device_t dev;
+ int i;
+ grub_usb_err_t err;
+
+ grub_boot_time ("Attaching USB device");
+
+ dev = grub_zalloc (sizeof (struct grub_usb_device));
+ if (! dev)
+ return NULL;
+
+ dev->controller = *controller;
+ dev->speed = speed;
+ dev->split_hubport = split_hubport;
+ dev->split_hubaddr = split_hubaddr;
+
+ err = grub_usb_device_initialize (dev);
+ if (err)
+ {
+ grub_free (dev);
+ return NULL;
+ }
+
+ /* Assign a new address to the device. */
+ for (i = 1; i < GRUB_USBHUB_MAX_DEVICES; i++)
+ {
+ if (! grub_usb_devs[i])
+ break;
+ }
+ if (i == GRUB_USBHUB_MAX_DEVICES)
+ {
+ grub_error (GRUB_ERR_IO, "can't assign address to USB device");
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++)
+ grub_free (dev->config[i].descconf);
+ grub_free (dev);
+ return NULL;
+ }
+
+ err = grub_usb_control_msg (dev,
+ (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_STANDARD
+ | GRUB_USB_REQTYPE_TARGET_DEV),
+ GRUB_USB_REQ_SET_ADDRESS,
+ i, 0, 0, NULL);
+ if (err)
+ {
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++)
+ grub_free (dev->config[i].descconf);
+ grub_free (dev);
+ return NULL;
+ }
+
+ dev->addr = i;
+ dev->initialized = 1;
+ grub_usb_devs[i] = dev;
+
+ grub_dprintf ("usb", "Added new usb device: %p, addr=%d\n",
+ dev, i);
+ grub_dprintf ("usb", "speed=%d, split_hubport=%d, split_hubaddr=%d\n",
+ speed, split_hubport, split_hubaddr);
+
+ /* Wait "recovery interval", spec. says 2ms */
+ grub_millisleep (2);
+
+ grub_boot_time ("Probing USB device driver");
+
+ grub_usb_device_attach (dev);
+
+ grub_boot_time ("Attached USB device");
+
+ return dev;
+}
+
+
+static grub_usb_err_t
+grub_usb_add_hub (grub_usb_device_t dev)
+{
+ struct grub_usb_usb_hubdesc hubdesc;
+ grub_usb_err_t err;
+ int i;
+
+ err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_DEV),
+ GRUB_USB_REQ_GET_DESCRIPTOR,
+ (GRUB_USB_DESCRIPTOR_HUB << 8) | 0,
+ 0, sizeof (hubdesc), (char *) &hubdesc);
+ if (err)
+ return err;
+ grub_dprintf ("usb", "Hub descriptor:\n\t\t len:%d, typ:0x%02x, cnt:%d, char:0x%02x, pwg:%d, curr:%d\n",
+ hubdesc.length, hubdesc.type, hubdesc.portcnt,
+ hubdesc.characteristics, hubdesc.pwdgood,
+ hubdesc.current);
+
+ /* Activate the first configuration. Hubs should have only one conf. */
+ grub_dprintf ("usb", "Hub set configuration\n");
+ grub_usb_set_configuration (dev, 1);
+
+ dev->nports = hubdesc.portcnt;
+ dev->children = grub_calloc (hubdesc.portcnt, sizeof (dev->children[0]));
+ dev->ports = grub_calloc (dev->nports, sizeof (dev->ports[0]));
+ if (!dev->children || !dev->ports)
+ {
+ grub_free (dev->children);
+ grub_free (dev->ports);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ /* Power on all Hub ports. */
+ for (i = 1; i <= hubdesc.portcnt; i++)
+ {
+ grub_dprintf ("usb", "Power on - port %d\n", i);
+ /* Power on the port and wait for possible device connect */
+ grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_OTHER),
+ GRUB_USB_REQ_SET_FEATURE,
+ GRUB_USB_HUB_FEATURE_PORT_POWER,
+ i, 0, NULL);
+ }
+
+ /* Rest will be done on next usb poll. */
+ for (i = 0; i < dev->config[0].interf[0].descif->endpointcnt;
+ i++)
+ {
+ struct grub_usb_desc_endp *endp = NULL;
+ endp = &dev->config[0].interf[0].descendp[i];
+
+ if ((endp->endp_addr & 128) && grub_usb_get_ep_type(endp)
+ == GRUB_USB_EP_INTERRUPT)
+ {
+ grub_size_t len;
+ dev->hub_endpoint = endp;
+ len = endp->maxpacket;
+ if (len > sizeof (dev->statuschange))
+ len = sizeof (dev->statuschange);
+ dev->hub_transfer
+ = grub_usb_bulk_read_background (dev, endp, len,
+ (char *) &dev->statuschange);
+ break;
+ }
+ }
+
+ rescan = 1;
+
+ return GRUB_USB_ERR_NONE;
+}
+
+static void
+attach_root_port (struct grub_usb_hub *hub, int portno,
+ grub_usb_speed_t speed)
+{
+ grub_usb_device_t dev;
+ grub_usb_err_t err;
+
+ grub_boot_time ("After detect_dev");
+
+ /* Enable the port. */
+ err = hub->controller->dev->portstatus (hub->controller, portno, 1);
+ if (err)
+ return;
+ hub->controller->dev->pending_reset = grub_get_time_ms () + 5000;
+ npending++;
+
+ grub_millisleep (10);
+
+ grub_boot_time ("Port enabled");
+
+ /* Enable the port and create a device. */
+ /* High speed device needs not transaction translation
+ and full/low speed device cannot be connected to EHCI root hub
+ and full/low speed device connected to OHCI/UHCI needs not
+ transaction translation - e.g. hubport and hubaddr should be
+ always none (zero) for any device connected to any root hub. */
+ dev = grub_usb_hub_add_dev (hub->controller, speed, 0, 0);
+ hub->controller->dev->pending_reset = 0;
+ npending--;
+ if (! dev)
+ return;
+
+ hub->devices[portno] = dev;
+
+ /* If the device is a Hub, scan it for more devices. */
+ if (dev->descdev.class == 0x09)
+ grub_usb_add_hub (dev);
+
+ grub_boot_time ("Attached root port");
+}
+
+/* Iterate over all controllers found by the driver. */
+static int
+grub_usb_controller_dev_register_iter (grub_usb_controller_t controller, void *data)
+{
+ grub_usb_controller_dev_t usb = data;
+ struct grub_usb_hub *hub;
+
+ controller->dev = usb;
+
+ grub_boot_time ("Registering USB root hub");
+
+ hub = grub_malloc (sizeof (*hub));
+ if (!hub)
+ return GRUB_USB_ERR_INTERNAL;
+
+ hub->next = hubs;
+ hubs = hub;
+ hub->controller = grub_malloc (sizeof (*controller));
+ if (!hub->controller)
+ {
+ grub_free (hub);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ grub_memcpy (hub->controller, controller, sizeof (*controller));
+ hub->dev = 0;
+
+ /* Query the number of ports the root Hub has. */
+ hub->nports = controller->dev->hubports (controller);
+ hub->devices = grub_calloc (hub->nports, sizeof (hub->devices[0]));
+ hub->ports = grub_calloc (hub->nports, sizeof (hub->ports[0]));
+ if (!hub->devices || !hub->ports)
+ {
+ grub_free (hub->devices);
+ grub_free (hub->ports);
+ grub_free (hub->controller);
+ grub_free (hub);
+ grub_print_error ();
+ return 0;
+ }
+
+ return 0;
+}
+
+void
+grub_usb_controller_dev_unregister (grub_usb_controller_dev_t usb)
+{
+ grub_usb_controller_dev_t *p, q;
+
+ for (p = &grub_usb_list, q = *p; q; p = &(q->next), q = q->next)
+ if (q == usb)
+ {
+ *p = q->next;
+ break;
+ }
+}
+
+void
+grub_usb_controller_dev_register (grub_usb_controller_dev_t usb)
+{
+ int portno;
+ int continue_waiting = 0;
+ struct grub_usb_hub *hub;
+
+ usb->next = grub_usb_list;
+ grub_usb_list = usb;
+
+ if (usb->iterate)
+ usb->iterate (grub_usb_controller_dev_register_iter, usb);
+
+ grub_boot_time ("waiting for stable power on USB root\n");
+
+ while (1)
+ {
+ for (hub = hubs; hub; hub = hub->next)
+ if (hub->controller->dev == usb)
+ {
+ /* Wait for completion of insertion and stable power (USB spec.)
+ * Should be at least 100ms, some devices requires more...
+ * There is also another thing - some devices have worse contacts
+ * and connected signal is unstable for some time - we should handle
+ * it - but prevent deadlock in case when device is too faulty... */
+ for (portno = 0; portno < hub->nports; portno++)
+ {
+ grub_usb_speed_t speed;
+ int changed = 0;
+
+ speed = hub->controller->dev->detect_dev (hub->controller, portno,
+ &changed);
+
+ if (hub->ports[portno].state == PORT_STATE_NORMAL
+ && speed != GRUB_USB_SPEED_NONE)
+ {
+ hub->ports[portno].soft_limit_time = grub_get_time_ms () + 250;
+ hub->ports[portno].hard_limit_time = hub->ports[portno].soft_limit_time + 1750;
+ hub->ports[portno].state = PORT_STATE_WAITING_FOR_STABLE_POWER;
+ grub_boot_time ("Scheduling stable power wait for port %p:%d",
+ usb, portno);
+ continue_waiting++;
+ continue;
+ }
+
+ if (hub->ports[portno].state == PORT_STATE_WAITING_FOR_STABLE_POWER
+ && speed == GRUB_USB_SPEED_NONE)
+ {
+ hub->ports[portno].soft_limit_time = grub_get_time_ms () + 250;
+ continue;
+ }
+ if (hub->ports[portno].state == PORT_STATE_WAITING_FOR_STABLE_POWER
+ && grub_get_time_ms () > hub->ports[portno].soft_limit_time)
+ {
+ hub->ports[portno].state = PORT_STATE_STABLE_POWER;
+ grub_boot_time ("Got stable power wait for port %p:%d",
+ usb, portno);
+ continue_waiting--;
+ continue;
+ }
+ if (hub->ports[portno].state == PORT_STATE_WAITING_FOR_STABLE_POWER
+ && grub_get_time_ms () > hub->ports[portno].hard_limit_time)
+ {
+ hub->ports[portno].state = PORT_STATE_FAILED_DEVICE;
+ continue_waiting--;
+ continue;
+ }
+ }
+ }
+ if (!continue_waiting)
+ break;
+ grub_millisleep (1);
+ }
+
+ grub_boot_time ("After the stable power wait on USB root");
+
+ for (hub = hubs; hub; hub = hub->next)
+ if (hub->controller->dev == usb)
+ for (portno = 0; portno < hub->nports; portno++)
+ if (hub->ports[portno].state == PORT_STATE_STABLE_POWER)
+ {
+ grub_usb_speed_t speed;
+ int changed = 0;
+ hub->ports[portno].state = PORT_STATE_NORMAL;
+ speed = hub->controller->dev->detect_dev (hub->controller, portno, &changed);
+ attach_root_port (hub, portno, speed);
+ }
+
+ grub_boot_time ("USB root hub registered");
+}
+
+static void detach_device (grub_usb_device_t dev);
+
+static void
+detach_device (grub_usb_device_t dev)
+{
+ unsigned i;
+ int k;
+ if (!dev)
+ return;
+ if (dev->descdev.class == GRUB_USB_CLASS_HUB)
+ {
+ if (dev->hub_transfer)
+ grub_usb_cancel_transfer (dev->hub_transfer);
+
+ for (i = 0; i < dev->nports; i++)
+ detach_device (dev->children[i]);
+ grub_free (dev->children);
+ }
+ for (i = 0; i < ARRAY_SIZE (dev->config); i++)
+ if (dev->config[i].descconf)
+ for (k = 0; k < dev->config[i].descconf->numif; k++)
+ {
+ struct grub_usb_interface *inter = &dev->config[i].interf[k];
+ if (inter && inter->detach_hook)
+ inter->detach_hook (dev, i, k);
+ }
+ grub_usb_devs[dev->addr] = 0;
+}
+
+static int
+wait_power_nonroot_hub (grub_usb_device_t dev)
+{
+ grub_usb_err_t err;
+ int continue_waiting = 0;
+ unsigned i;
+
+ for (i = 1; i <= dev->nports; i++)
+ if (dev->ports[i - 1].state == PORT_STATE_WAITING_FOR_STABLE_POWER)
+ {
+ grub_uint64_t tm;
+ grub_uint32_t current_status = 0;
+
+ /* Get the port status. */
+ err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_OTHER),
+ GRUB_USB_REQ_GET_STATUS,
+ 0, i,
+ sizeof (current_status),
+ (char *) &current_status);
+ if (err)
+ {
+ dev->ports[i - 1].state = PORT_STATE_FAILED_DEVICE;
+ continue;
+ }
+ tm = grub_get_time_ms ();
+ if (!(current_status & GRUB_USB_HUB_STATUS_PORT_CONNECTED))
+ dev->ports[i - 1].soft_limit_time = tm + 250;
+ if (tm >= dev->ports[i - 1].soft_limit_time)
+ {
+ if (dev->controller.dev->pending_reset)
+ continue;
+ /* Now do reset of port. */
+ grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_OTHER),
+ GRUB_USB_REQ_SET_FEATURE,
+ GRUB_USB_HUB_FEATURE_PORT_RESET,
+ i, 0, 0);
+ dev->ports[i - 1].state = PORT_STATE_NORMAL;
+ grub_boot_time ("Resetting port %p:%d", dev, i - 1);
+
+ rescan = 1;
+ /* We cannot reset more than one device at the same time !
+ * Resetting more devices together results in very bad
+ * situation: more than one device has default address 0
+ * at the same time !!!
+ * Additionaly, we cannot perform another reset
+ * anywhere on the same OHCI controller until
+ * we will finish addressing of reseted device ! */
+ dev->controller.dev->pending_reset = grub_get_time_ms () + 5000;
+ npending++;
+ continue;
+ }
+ if (tm >= dev->ports[i - 1].hard_limit_time)
+ {
+ dev->ports[i - 1].state = PORT_STATE_FAILED_DEVICE;
+ continue;
+ }
+ continue_waiting = 1;
+ }
+ return continue_waiting && dev->controller.dev->pending_reset == 0;
+}
+
+static void
+poll_nonroot_hub (grub_usb_device_t dev)
+{
+ grub_usb_err_t err;
+ unsigned i;
+ grub_uint32_t changed;
+ grub_size_t actual, len;
+
+ if (!dev->hub_transfer)
+ return;
+
+ err = grub_usb_check_transfer (dev->hub_transfer, &actual);
+
+ if (err == GRUB_USB_ERR_WAIT)
+ return;
+
+ changed = dev->statuschange;
+
+ len = dev->hub_endpoint->maxpacket;
+ if (len > sizeof (dev->statuschange))
+ len = sizeof (dev->statuschange);
+ dev->hub_transfer
+ = grub_usb_bulk_read_background (dev, dev->hub_endpoint, len,
+ (char *) &dev->statuschange);
+
+ if (err || actual == 0 || changed == 0)
+ return;
+
+ /* Iterate over the Hub ports. */
+ for (i = 1; i <= dev->nports; i++)
+ {
+ grub_uint32_t status;
+
+ if (!(changed & (1 << i))
+ || dev->ports[i - 1].state == PORT_STATE_WAITING_FOR_STABLE_POWER)
+ continue;
+
+ /* Get the port status. */
+ err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_OTHER),
+ GRUB_USB_REQ_GET_STATUS,
+ 0, i, sizeof (status), (char *) &status);
+
+ grub_dprintf ("usb", "dev = %p, i = %d, status = %08x\n",
+ dev, i, status);
+
+ if (err)
+ continue;
+
+ /* FIXME: properly handle these conditions. */
+ if (status & GRUB_USB_HUB_STATUS_C_PORT_ENABLED)
+ grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_OTHER),
+ GRUB_USB_REQ_CLEAR_FEATURE,
+ GRUB_USB_HUB_FEATURE_C_PORT_ENABLED, i, 0, 0);
+
+ if (status & GRUB_USB_HUB_STATUS_C_PORT_SUSPEND)
+ grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_OTHER),
+ GRUB_USB_REQ_CLEAR_FEATURE,
+ GRUB_USB_HUB_FEATURE_C_PORT_SUSPEND, i, 0, 0);
+
+ if (status & GRUB_USB_HUB_STATUS_C_PORT_OVERCURRENT)
+ grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_OTHER),
+ GRUB_USB_REQ_CLEAR_FEATURE,
+ GRUB_USB_HUB_FEATURE_C_PORT_OVERCURRENT, i, 0, 0);
+
+ if (!dev->controller.dev->pending_reset &&
+ (status & GRUB_USB_HUB_STATUS_C_PORT_CONNECTED))
+ {
+ grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_OTHER),
+ GRUB_USB_REQ_CLEAR_FEATURE,
+ GRUB_USB_HUB_FEATURE_C_PORT_CONNECTED, i, 0, 0);
+
+ detach_device (dev->children[i - 1]);
+ dev->children[i - 1] = NULL;
+
+ /* Connected and status of connection changed ? */
+ if (status & GRUB_USB_HUB_STATUS_PORT_CONNECTED)
+ {
+ grub_boot_time ("Before the stable power wait portno=%d", i);
+ /* A device is actually connected to this port. */
+ /* Wait for completion of insertion and stable power (USB spec.)
+ * Should be at least 100ms, some devices requires more...
+ * There is also another thing - some devices have worse contacts
+ * and connected signal is unstable for some time - we should handle
+ * it - but prevent deadlock in case when device is too faulty... */
+ dev->ports[i - 1].soft_limit_time = grub_get_time_ms () + 250;
+ dev->ports[i - 1].hard_limit_time = dev->ports[i - 1].soft_limit_time + 1750;
+ dev->ports[i - 1].state = PORT_STATE_WAITING_FOR_STABLE_POWER;
+ grub_boot_time ("Scheduling stable power wait for port %p:%d",
+ dev, i - 1);
+ continue;
+ }
+ }
+
+ if (status & GRUB_USB_HUB_STATUS_C_PORT_RESET)
+ {
+ grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_OTHER),
+ GRUB_USB_REQ_CLEAR_FEATURE,
+ GRUB_USB_HUB_FEATURE_C_PORT_RESET, i, 0, 0);
+
+ grub_boot_time ("Port %d reset", i);
+
+ if (status & GRUB_USB_HUB_STATUS_PORT_CONNECTED)
+ {
+ grub_usb_speed_t speed;
+ grub_usb_device_t next_dev;
+ int split_hubport = 0;
+ int split_hubaddr = 0;
+
+ /* Determine the device speed. */
+ if (status & GRUB_USB_HUB_STATUS_PORT_LOWSPEED)
+ speed = GRUB_USB_SPEED_LOW;
+ else
+ {
+ if (status & GRUB_USB_HUB_STATUS_PORT_HIGHSPEED)
+ speed = GRUB_USB_SPEED_HIGH;
+ else
+ speed = GRUB_USB_SPEED_FULL;
+ }
+
+ /* Wait a recovery time after reset, spec. says 10ms */
+ grub_millisleep (10);
+
+ /* Find correct values for SPLIT hubport and hubaddr */
+ if (speed == GRUB_USB_SPEED_HIGH)
+ {
+ /* HIGH speed device needs not transaction translation */
+ split_hubport = 0;
+ split_hubaddr = 0;
+ }
+ else
+ /* FULL/LOW device needs hub port and hub address
+ for transaction translation (if connected to EHCI) */
+ if (dev->speed == GRUB_USB_SPEED_HIGH)
+ {
+ /* This port is the first FULL/LOW speed port
+ in the chain from root hub. Attached device
+ should use its port number and hub address */
+ split_hubport = i;
+ split_hubaddr = dev->addr;
+ }
+ else
+ {
+ /* This port is NOT the first FULL/LOW speed port
+ in the chain from root hub. Attached device
+ should use values inherited from some parent
+ HIGH speed hub - if any. */
+ split_hubport = dev->split_hubport;
+ split_hubaddr = dev->split_hubaddr;
+ }
+
+ /* Add the device and assign a device address to it. */
+ next_dev = grub_usb_hub_add_dev (&dev->controller, speed,
+ split_hubport, split_hubaddr);
+ if (dev->controller.dev->pending_reset)
+ {
+ dev->controller.dev->pending_reset = 0;
+ npending--;
+ }
+ if (! next_dev)
+ continue;
+
+ dev->children[i - 1] = next_dev;
+
+ /* If the device is a Hub, scan it for more devices. */
+ if (next_dev->descdev.class == 0x09)
+ grub_usb_add_hub (next_dev);
+ }
+ }
+ }
+}
+
+void
+grub_usb_poll_devices (int wait_for_completion)
+{
+ struct grub_usb_hub *hub;
+ int i;
+
+ for (hub = hubs; hub; hub = hub->next)
+ {
+ /* Do we have to recheck number of ports? */
+ /* No, it should be never changed, it should be constant. */
+ for (i = 0; i < hub->nports; i++)
+ {
+ grub_usb_speed_t speed = GRUB_USB_SPEED_NONE;
+ int changed = 0;
+
+ if (hub->controller->dev->pending_reset)
+ {
+ /* Check for possible timeout */
+ if (grub_get_time_ms () > hub->controller->dev->pending_reset)
+ {
+ /* Something went wrong, reset device was not
+ * addressed properly, timeout happened */
+ hub->controller->dev->pending_reset = 0;
+ npending--;
+ }
+ }
+ if (!hub->controller->dev->pending_reset)
+ speed = hub->controller->dev->detect_dev (hub->controller,
+ i, &changed);
+
+ if (changed)
+ {
+ detach_device (hub->devices[i]);
+ hub->devices[i] = NULL;
+ if (speed != GRUB_USB_SPEED_NONE)
+ attach_root_port (hub, i, speed);
+ }
+ }
+ }
+
+ while (1)
+ {
+ rescan = 0;
+
+ /* We should check changes of non-root hubs too. */
+ for (i = 0; i < GRUB_USBHUB_MAX_DEVICES; i++)
+ {
+ grub_usb_device_t dev = grub_usb_devs[i];
+
+ if (dev && dev->descdev.class == 0x09)
+ poll_nonroot_hub (dev);
+ }
+
+ while (1)
+ {
+ int continue_waiting = 0;
+ for (i = 0; i < GRUB_USBHUB_MAX_DEVICES; i++)
+ {
+ grub_usb_device_t dev = grub_usb_devs[i];
+
+ if (dev && dev->descdev.class == 0x09)
+ continue_waiting = continue_waiting || wait_power_nonroot_hub (dev);
+ }
+ if (!continue_waiting)
+ break;
+ grub_millisleep (1);
+ }
+
+ if (!(rescan || (npending && wait_for_completion)))
+ break;
+ grub_millisleep (25);
+ }
+}
+
+int
+grub_usb_iterate (grub_usb_iterate_hook_t hook, void *hook_data)
+{
+ int i;
+
+ for (i = 0; i < GRUB_USBHUB_MAX_DEVICES; i++)
+ {
+ if (grub_usb_devs[i])
+ {
+ if (hook (grub_usb_devs[i], hook_data))
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c
new file mode 100644
index 0000000..85f081f
--- /dev/null
+++ b/grub-core/bus/usb/usbtrans.c
@@ -0,0 +1,462 @@
+/* usbtrans.c - USB Transfers and Transactions. */
+/*
+ * 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/dl.h>
+#include <grub/dma.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/usb.h>
+#include <grub/usbtrans.h>
+#include <grub/time.h>
+#include <grub/cache.h>
+
+
+static inline unsigned int
+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 && (unsigned int) endpoint->maxpacket)
+ return endpoint->maxpacket;
+
+ return 64;
+}
+
+
+static grub_usb_err_t
+grub_usb_execute_and_wait_transfer (grub_usb_device_t dev,
+ grub_usb_transfer_t transfer,
+ int timeout, grub_size_t *actual)
+{
+ grub_usb_err_t err;
+ grub_uint64_t endtime;
+
+ err = dev->controller.dev->setup_transfer (&dev->controller, transfer);
+ if (err)
+ return err;
+ /* endtime moved behind setup transfer to prevent false timeouts
+ * while debugging... */
+ endtime = grub_get_time_ms () + timeout;
+ while (1)
+ {
+ err = dev->controller.dev->check_transfer (&dev->controller, transfer,
+ actual);
+ if (!err)
+ return GRUB_USB_ERR_NONE;
+ if (err != GRUB_USB_ERR_WAIT)
+ return err;
+ if (grub_get_time_ms () > endtime)
+ {
+ err = dev->controller.dev->cancel_transfer (&dev->controller,
+ transfer);
+ if (err)
+ return err;
+ return GRUB_USB_ERR_TIMEOUT;
+ }
+ grub_cpu_idle ();
+ }
+}
+
+grub_usb_err_t
+grub_usb_control_msg (grub_usb_device_t dev,
+ grub_uint8_t reqtype,
+ grub_uint8_t request,
+ grub_uint16_t value,
+ grub_uint16_t index,
+ grub_size_t size0, char *data_in)
+{
+ int i;
+ grub_usb_transfer_t transfer;
+ int datablocks;
+ volatile struct grub_usb_packet_setup *setupdata;
+ grub_uint32_t setupdata_addr;
+ grub_usb_err_t err;
+ unsigned int max;
+ struct grub_pci_dma_chunk *data_chunk, *setupdata_chunk;
+ volatile char *data;
+ grub_uint32_t data_addr;
+ grub_size_t size = size0;
+ grub_size_t actual;
+
+ /* FIXME: avoid allocation any kind of buffer in a first place. */
+ data_chunk = grub_memalign_dma32 (128, size ? : 16);
+ if (!data_chunk)
+ return GRUB_USB_ERR_INTERNAL;
+ data = grub_dma_get_virt (data_chunk);
+ 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);
+
+ /* Create a transfer. */
+ transfer = grub_malloc (sizeof (*transfer));
+ if (! transfer)
+ {
+ grub_dma_free (data_chunk);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ setupdata_chunk = grub_memalign_dma32 (32, sizeof (*setupdata));
+ if (! setupdata_chunk)
+ {
+ grub_free (transfer);
+ grub_dma_free (data_chunk);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ setupdata = grub_dma_get_virt (setupdata_chunk);
+ setupdata_addr = grub_dma_get_phys (setupdata_chunk);
+
+ /* Determine the maximum packet size. */
+ if (dev->descdev.maxsize0)
+ max = dev->descdev.maxsize0;
+ else
+ max = 64;
+
+ grub_dprintf ("usb", "control: transfer = %p, dev = %p\n", transfer, dev);
+
+ datablocks = (size + max - 1) / max;
+
+ /* XXX: Discriminate between different types of control
+ messages. */
+ transfer->transcnt = datablocks + 2;
+ transfer->size = size; /* XXX ? */
+ transfer->endpoint = 0;
+ transfer->devaddr = dev->addr;
+ transfer->type = GRUB_USB_TRANSACTION_TYPE_CONTROL;
+ transfer->max = max;
+ transfer->dev = dev;
+
+ /* Allocate an array of transfer data structures. */
+ transfer->transactions = grub_malloc (transfer->transcnt
+ * sizeof (struct grub_usb_transfer));
+ if (! transfer->transactions)
+ {
+ grub_free (transfer);
+ grub_dma_free (setupdata_chunk);
+ grub_dma_free (data_chunk);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ /* Build a Setup packet. XXX: Endianness. */
+ setupdata->reqtype = reqtype;
+ setupdata->request = request;
+ 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;
+ transfer->transactions[0].toggle = 0;
+
+ /* Now the data... XXX: Is this the right way to transfer control
+ transfers? */
+ for (i = 0; i < datablocks; i++)
+ {
+ grub_usb_transaction_t tr = &transfer->transactions[i + 1];
+
+ tr->size = (size > max) ? max : size;
+ /* Use the right most bit as the data toggle. Simple and
+ effective. */
+ tr->toggle = !(i & 1);
+ if (reqtype & 128)
+ tr->pid = GRUB_USB_TRANSFER_TYPE_IN;
+ else
+ tr->pid = GRUB_USB_TRANSFER_TYPE_OUT;
+ tr->data = data_addr + i * max;
+ tr->preceding = i * max;
+ size -= max;
+ }
+
+ /* End with an empty OUT transaction. */
+ transfer->transactions[datablocks + 1].size = 0;
+ transfer->transactions[datablocks + 1].data = 0;
+ if ((reqtype & 128) && datablocks)
+ transfer->transactions[datablocks + 1].pid = GRUB_USB_TRANSFER_TYPE_OUT;
+ else
+ transfer->transactions[datablocks + 1].pid = GRUB_USB_TRANSFER_TYPE_IN;
+
+ transfer->transactions[datablocks + 1].toggle = 1;
+
+ err = grub_usb_execute_and_wait_transfer (dev, transfer, 1000, &actual);
+
+ grub_dprintf ("usb", "control: err=%d\n", err);
+
+ grub_free (transfer->transactions);
+
+ grub_free (transfer);
+ 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;
+}
+
+static grub_usb_transfer_t
+grub_usb_bulk_setup_readwrite (grub_usb_device_t dev,
+ struct grub_usb_desc_endp *endpoint,
+ grub_size_t size0, char *data_in,
+ grub_transfer_type_t type)
+{
+ int i;
+ grub_usb_transfer_t transfer;
+ int datablocks;
+ unsigned int max;
+ volatile char *data;
+ grub_uint32_t data_addr;
+ struct grub_pci_dma_chunk *data_chunk;
+ grub_size_t size = size0;
+ int toggle = dev->toggle[endpoint->endp_addr];
+
+ grub_dprintf ("usb", "bulk: size=0x%02lx type=%d\n", (unsigned long) size,
+ type);
+
+ /* FIXME: avoid allocation any kind of buffer in a first place. */
+ data_chunk = grub_memalign_dma32 (128, size);
+ if (!data_chunk)
+ return NULL;
+ 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_arch_sync_dma_caches (data, size);
+ }
+
+ /* Create a transfer. */
+ transfer = grub_malloc (sizeof (struct grub_usb_transfer));
+ if (! transfer)
+ {
+ grub_dma_free (data_chunk);
+ return NULL;
+ }
+
+ max = grub_usb_bulk_maxpacket (dev, endpoint);
+
+ datablocks = ((size + max - 1) / max);
+ transfer->transcnt = datablocks;
+ transfer->size = size - 1;
+ transfer->endpoint = endpoint->endp_addr;
+ transfer->devaddr = dev->addr;
+ transfer->type = GRUB_USB_TRANSACTION_TYPE_BULK;
+ transfer->dir = type;
+ transfer->max = max;
+ transfer->dev = dev;
+ transfer->last_trans = -1; /* Reset index of last processed transaction (TD) */
+ transfer->data_chunk = data_chunk;
+ transfer->data = data_in;
+
+ /* Allocate an array of transfer data structures. */
+ transfer->transactions = grub_malloc (transfer->transcnt
+ * sizeof (struct grub_usb_transfer));
+ if (! transfer->transactions)
+ {
+ grub_free (transfer);
+ grub_dma_free (data_chunk);
+ return NULL;
+ }
+
+ /* Set up all transfers. */
+ for (i = 0; i < datablocks; i++)
+ {
+ grub_usb_transaction_t tr = &transfer->transactions[i];
+
+ tr->size = (size > max) ? max : size;
+ /* XXX: Use the right most bit as the data toggle. Simple and
+ effective. */
+ tr->toggle = toggle;
+ toggle = toggle ? 0 : 1;
+ tr->pid = type;
+ tr->data = data_addr + i * max;
+ tr->preceding = i * max;
+ size -= tr->size;
+ }
+ return transfer;
+}
+
+static void
+grub_usb_bulk_finish_readwrite (grub_usb_transfer_t transfer)
+{
+ grub_usb_device_t dev = transfer->dev;
+ int toggle = dev->toggle[transfer->endpoint];
+
+ /* We must remember proper toggle value even if some transactions
+ * were not processed - correct value should be inversion of last
+ * processed transaction (TD). */
+ if (transfer->last_trans >= 0)
+ toggle = transfer->transactions[transfer->last_trans].toggle ? 0 : 1;
+ else
+ toggle = dev->toggle[transfer->endpoint]; /* Nothing done, take original */
+ grub_dprintf ("usb", "bulk: toggle=%d\n", toggle);
+ dev->toggle[transfer->endpoint] = toggle;
+
+ if (transfer->dir == GRUB_USB_TRANSFER_TYPE_IN)
+ {
+ 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_dma_free (transfer->data_chunk);
+ grub_free (transfer);
+}
+
+static grub_usb_err_t
+grub_usb_bulk_readwrite (grub_usb_device_t dev,
+ struct grub_usb_desc_endp *endpoint,
+ grub_size_t size0, char *data_in,
+ grub_transfer_type_t type, int timeout,
+ grub_size_t *actual)
+{
+ grub_usb_err_t err;
+ grub_usb_transfer_t transfer;
+
+ transfer = grub_usb_bulk_setup_readwrite (dev, endpoint, size0,
+ data_in, type);
+ if (!transfer)
+ return GRUB_USB_ERR_INTERNAL;
+ err = grub_usb_execute_and_wait_transfer (dev, transfer, timeout, actual);
+
+ grub_usb_bulk_finish_readwrite (transfer);
+
+ return err;
+}
+
+static grub_usb_err_t
+grub_usb_bulk_readwrite_packetize (grub_usb_device_t dev,
+ struct grub_usb_desc_endp *endpoint,
+ grub_transfer_type_t type,
+ grub_size_t size, char *data)
+{
+ grub_size_t actual, transferred;
+ grub_usb_err_t err = GRUB_USB_ERR_NONE;
+ grub_size_t current_size, position;
+ grub_size_t max_bulk_transfer_len = MAX_USB_TRANSFER_LEN;
+ grub_size_t max;
+
+ if (dev->controller.dev->max_bulk_tds)
+ {
+ max = grub_usb_bulk_maxpacket (dev, endpoint);
+
+ /* Calculate max. possible length of bulk transfer */
+ max_bulk_transfer_len = dev->controller.dev->max_bulk_tds * max;
+ }
+
+ for (position = 0, transferred = 0;
+ position < size; position += max_bulk_transfer_len)
+ {
+ current_size = size - position;
+ if (current_size >= max_bulk_transfer_len)
+ current_size = max_bulk_transfer_len;
+ err = grub_usb_bulk_readwrite (dev, endpoint, current_size,
+ &data[position], type, 1000, &actual);
+ transferred += actual;
+ if (err || (current_size != actual)) break;
+ }
+
+ if (!err && transferred != size)
+ err = GRUB_USB_ERR_DATA;
+ return err;
+}
+
+grub_usb_err_t
+grub_usb_bulk_write (grub_usb_device_t dev,
+ struct grub_usb_desc_endp *endpoint,
+ grub_size_t size, char *data)
+{
+ return grub_usb_bulk_readwrite_packetize (dev, endpoint,
+ GRUB_USB_TRANSFER_TYPE_OUT,
+ size, data);
+}
+
+grub_usb_err_t
+grub_usb_bulk_read (grub_usb_device_t dev,
+ struct grub_usb_desc_endp *endpoint,
+ grub_size_t size, char *data)
+{
+ return grub_usb_bulk_readwrite_packetize (dev, endpoint,
+ GRUB_USB_TRANSFER_TYPE_IN,
+ size, data);
+}
+
+grub_usb_err_t
+grub_usb_check_transfer (grub_usb_transfer_t transfer, grub_size_t *actual)
+{
+ grub_usb_err_t err;
+ grub_usb_device_t dev = transfer->dev;
+
+ err = dev->controller.dev->check_transfer (&dev->controller, transfer,
+ actual);
+ if (err == GRUB_USB_ERR_WAIT)
+ return err;
+
+ grub_usb_bulk_finish_readwrite (transfer);
+
+ return err;
+}
+
+grub_usb_transfer_t
+grub_usb_bulk_read_background (grub_usb_device_t dev,
+ struct grub_usb_desc_endp *endpoint,
+ grub_size_t size, void *data)
+{
+ grub_usb_err_t err;
+ grub_usb_transfer_t transfer;
+
+ transfer = grub_usb_bulk_setup_readwrite (dev, endpoint, size,
+ data, GRUB_USB_TRANSFER_TYPE_IN);
+ if (!transfer)
+ return NULL;
+
+ err = dev->controller.dev->setup_transfer (&dev->controller, transfer);
+ if (err)
+ return NULL;
+
+ return transfer;
+}
+
+void
+grub_usb_cancel_transfer (grub_usb_transfer_t transfer)
+{
+ grub_usb_device_t dev = transfer->dev;
+ dev->controller.dev->cancel_transfer (&dev->controller, transfer);
+ grub_errno = GRUB_ERR_NONE;
+}
+
+grub_usb_err_t
+grub_usb_bulk_read_extended (grub_usb_device_t dev,
+ struct grub_usb_desc_endp *endpoint,
+ grub_size_t size, char *data,
+ int timeout, grub_size_t *actual)
+{
+ return grub_usb_bulk_readwrite (dev, endpoint, size, data,
+ GRUB_USB_TRANSFER_TYPE_IN, timeout, actual);
+}
diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c
new file mode 100644
index 0000000..1215f2a
--- /dev/null
+++ b/grub-core/commands/acpi.c
@@ -0,0 +1,791 @@
+/* acpi.c - modify acpi tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/extcmd.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/acpi.h>
+#include <grub/mm.h>
+#include <grub/memory.h>
+#include <grub/i18n.h>
+#include <grub/lockdown.h>
+
+#ifdef GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#include <grub/efi/api.h>
+#endif
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] = {
+ {"exclude", 'x', 0,
+ N_("Don't load host tables specified by comma-separated list."),
+ 0, ARG_TYPE_STRING},
+ {"load-only", 'n', 0,
+ N_("Load only tables specified by comma-separated list."), 0, ARG_TYPE_STRING},
+ {"v1", '1', 0, N_("Export version 1 tables to the OS."), 0, ARG_TYPE_NONE},
+ {"v2", '2', 0, N_("Export version 2 and version 3 tables to the OS."), 0, ARG_TYPE_NONE},
+ {"oemid", 'o', 0, N_("Set OEMID of RSDP, XSDT and RSDT."), 0, ARG_TYPE_STRING},
+ {"oemtable", 't', 0,
+ N_("Set OEMTABLE ID of RSDP, XSDT and RSDT."), 0, ARG_TYPE_STRING},
+ {"oemtablerev", 'r', 0,
+ N_("Set OEMTABLE revision of RSDP, XSDT and RSDT."), 0, ARG_TYPE_INT},
+ {"oemtablecreator", 'c', 0,
+ N_("Set creator field of RSDP, XSDT and RSDT."), 0, ARG_TYPE_STRING},
+ {"oemtablecreatorrev", 'd', 0,
+ N_("Set creator revision of RSDP, XSDT and RSDT."), 0, ARG_TYPE_INT},
+ /* TRANSLATORS: "hangs" here is a noun, not a verb. */
+ {"no-ebda", 'e', 0, N_("Don't update EBDA. May fix failures or hangs on some "
+ "BIOSes but makes it ineffective with OS not receiving RSDP from GRUB."),
+ 0, ARG_TYPE_NONE},
+ {0, 0, 0, 0, 0, 0}
+};
+
+/* 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;
+/* OEMID of RSDP, RSDT and XSDT. */
+static char root_oemid[6];
+/* OEMTABLE of the same tables. */
+static char root_oemtable[8];
+/* OEMREVISION of the same tables. */
+static grub_uint32_t root_oemrev;
+/* CreatorID of the same tables. */
+static char root_creator_id[4];
+/* CreatorRevision of the same tables. */
+static grub_uint32_t root_creator_rev;
+static struct grub_acpi_rsdp_v10 *rsdpv1_new = 0;
+static struct grub_acpi_rsdp_v20 *rsdpv2_new = 0;
+static char *playground = 0, *playground_ptr = 0;
+static int playground_size = 0;
+
+/* Linked list of ACPI tables. */
+struct efiemu_acpi_table
+{
+ void *addr;
+ grub_size_t size;
+ struct efiemu_acpi_table *next;
+};
+static struct efiemu_acpi_table *acpi_tables = 0;
+
+/* DSDT isn't in RSDT. So treat it specially. */
+static void *table_dsdt = 0;
+/* Pointer to recreated RSDT. */
+static void *rsdt_addr = 0;
+
+/* Allocation handles for different tables. */
+static grub_size_t dsdt_size = 0;
+
+/* Address of original FACS. */
+static grub_uint32_t facs_addr = 0;
+
+struct grub_acpi_rsdp_v20 *
+grub_acpi_get_rsdpv2 (void)
+{
+ if (rsdpv2_new)
+ return rsdpv2_new;
+ if (rsdpv1_new)
+ return 0;
+ return grub_machine_acpi_get_rsdpv2 ();
+}
+
+struct grub_acpi_rsdp_v10 *
+grub_acpi_get_rsdpv1 (void)
+{
+ if (rsdpv1_new)
+ return rsdpv1_new;
+ if (rsdpv2_new)
+ return 0;
+ return grub_machine_acpi_get_rsdpv1 ();
+}
+
+#if defined (__i386__) || defined (__x86_64__)
+
+static inline int
+iszero (grub_uint8_t *reg, int size)
+{
+ int i;
+ for (i = 0; i < size; i++)
+ if (reg[i])
+ return 0;
+ return 1;
+}
+
+/* Context for grub_acpi_create_ebda. */
+struct grub_acpi_create_ebda_ctx {
+ int ebda_len;
+ grub_uint64_t highestlow;
+};
+
+/* Helper for grub_acpi_create_ebda. */
+static int
+find_hook (grub_uint64_t start, grub_uint64_t size, grub_memory_type_t type,
+ void *data)
+{
+ struct grub_acpi_create_ebda_ctx *ctx = data;
+ grub_uint64_t end = start + size;
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+ if (end > 0x100000)
+ end = 0x100000;
+ if (end > start + ctx->ebda_len
+ && ctx->highestlow < ((end - ctx->ebda_len) & (~0xf)) )
+ ctx->highestlow = (end - ctx->ebda_len) & (~0xf);
+ return 0;
+}
+
+grub_err_t
+grub_acpi_create_ebda (void)
+{
+ struct grub_acpi_create_ebda_ctx ctx = {
+ .highestlow = 0
+ };
+ int ebda_kb_len = 0;
+ int mmapregion = 0;
+ grub_uint8_t *ebda, *v1inebda = 0, *v2inebda = 0;
+ grub_uint8_t *targetebda, *target;
+ struct grub_acpi_rsdp_v10 *v1;
+ 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;
+
+ /* FIXME: use low-memory mm allocation once it's available. */
+ grub_mmap_iterate (find_hook, &ctx);
+ targetebda = (grub_uint8_t *) (grub_addr_t) ctx.highestlow;
+ grub_dprintf ("acpi", "creating ebda @%llx\n",
+ (unsigned long long) ctx.highestlow);
+ if (! ctx.highestlow)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "couldn't find space for the new EBDA");
+
+ mmapregion = grub_mmap_register ((grub_addr_t) targetebda, ctx.ebda_len,
+ GRUB_MEMORY_RESERVED);
+ if (! mmapregion)
+ return grub_errno;
+
+ /* XXX: EBDA is unstandardized, so this implementation is heuristical. */
+ if (ebda_kb_len)
+ grub_memcpy (targetebda, ebda, 0x400);
+ else
+ grub_memset (targetebda, 0, 0x400);
+ *((grub_uint16_t *) targetebda) = ebda_kb_len + 1;
+ target = targetebda;
+
+ v1 = grub_acpi_get_rsdpv1 ();
+ v2 = grub_acpi_get_rsdpv2 ();
+ if (v2 && v2->length > 40)
+ v2 = 0;
+
+ /* First try to replace already existing rsdp. */
+ if (v2)
+ {
+ grub_dprintf ("acpi", "Scanning EBDA for old rsdpv2\n");
+ for (; target < targetebda + 0x400 - v2->length; target += 0x10)
+ if (grub_memcmp (target, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
+ && grub_byte_checksum (target,
+ sizeof (struct grub_acpi_rsdp_v10)) == 0
+ && ((struct grub_acpi_rsdp_v10 *) target)->revision != 0
+ && ((struct grub_acpi_rsdp_v20 *) target)->length <= v2->length)
+ {
+ grub_memcpy (target, v2, v2->length);
+ grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target);
+ v2inebda = target;
+ target += v2->length;
+ target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
+ v2 = 0;
+ break;
+ }
+ }
+
+ if (v1)
+ {
+ grub_dprintf ("acpi", "Scanning EBDA for old rsdpv1\n");
+ for (; target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
+ target += 0x10)
+ if (grub_memcmp (target, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
+ && grub_byte_checksum (target,
+ sizeof (struct grub_acpi_rsdp_v10)) == 0)
+ {
+ grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10));
+ grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target);
+ v1inebda = target;
+ target += sizeof (struct grub_acpi_rsdp_v10);
+ target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
+ v1 = 0;
+ break;
+ }
+ }
+
+ target = targetebda + 0x100;
+
+ /* Try contiguous zeros. */
+ if (v2)
+ {
+ grub_dprintf ("acpi", "Scanning EBDA for block of zeros\n");
+ for (; target < targetebda + 0x400 - v2->length; target += 0x10)
+ if (iszero (target, v2->length))
+ {
+ grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target);
+ grub_memcpy (target, v2, v2->length);
+ v2inebda = target;
+ target += v2->length;
+ target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
+ v2 = 0;
+ break;
+ }
+ }
+
+ if (v1)
+ {
+ grub_dprintf ("acpi", "Scanning EBDA for block of zeros\n");
+ for (; target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
+ target += 0x10)
+ if (iszero (target, sizeof (struct grub_acpi_rsdp_v10)))
+ {
+ grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target);
+ grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10));
+ v1inebda = target;
+ target += sizeof (struct grub_acpi_rsdp_v10);
+ target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
+ v1 = 0;
+ break;
+ }
+ }
+
+ if (v1 || v2)
+ {
+ grub_mmap_unregister (mmapregion);
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "couldn't find suitable spot in EBDA");
+ }
+
+ /* Remove any other RSDT. */
+ for (target = targetebda;
+ target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
+ target += 0x10)
+ if (grub_memcmp (target, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
+ && grub_byte_checksum (target,
+ sizeof (struct grub_acpi_rsdp_v10)) == 0
+ && target != v1inebda && target != v2inebda)
+ *target = 0;
+
+ grub_dprintf ("acpi", "Switching EBDA\n");
+ (*((grub_uint16_t *) 0x40e)) = ((grub_addr_t) targetebda) >> 4;
+ grub_dprintf ("acpi", "EBDA switched\n");
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+/* Create tables common to ACPIv1 and ACPIv2+ */
+static void
+setup_common_tables (void)
+{
+ struct efiemu_acpi_table *cur;
+ struct grub_acpi_table_header *rsdt;
+ grub_uint32_t *rsdt_entry;
+ int numoftables;
+
+ /* Treat DSDT. */
+ grub_memcpy (playground_ptr, table_dsdt, dsdt_size);
+ grub_free (table_dsdt);
+ table_dsdt = playground_ptr;
+ playground_ptr += dsdt_size;
+
+ /* Treat other tables. */
+ for (cur = acpi_tables; cur; cur = cur->next)
+ {
+ struct grub_acpi_fadt *fadt;
+
+ grub_memcpy (playground_ptr, cur->addr, cur->size);
+ grub_free (cur->addr);
+ cur->addr = playground_ptr;
+ playground_ptr += cur->size;
+
+ /* If it's FADT correct DSDT and FACS addresses. */
+ fadt = (struct grub_acpi_fadt *) cur->addr;
+ if (grub_memcmp (fadt->hdr.signature, GRUB_ACPI_FADT_SIGNATURE,
+ sizeof (fadt->hdr.signature)) == 0)
+ {
+ fadt->dsdt_addr = (grub_addr_t) table_dsdt;
+ fadt->facs_addr = facs_addr;
+
+ /* Does a revision 2 exist at all? */
+ if (fadt->hdr.revision >= 3)
+ {
+ fadt->dsdt_xaddr = (grub_addr_t) table_dsdt;
+ fadt->facs_xaddr = facs_addr;
+ }
+
+ /* Recompute checksum. */
+ fadt->hdr.checksum = 0;
+ fadt->hdr.checksum = 1 + ~grub_byte_checksum (fadt, fadt->hdr.length);
+ }
+ }
+
+ /* Fill RSDT entries. */
+ numoftables = 0;
+ for (cur = acpi_tables; cur; cur = cur->next)
+ numoftables++;
+
+ rsdt_addr = rsdt = (struct grub_acpi_table_header *) playground_ptr;
+ playground_ptr += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint32_t) * numoftables;
+
+ rsdt_entry = (grub_uint32_t *) (rsdt + 1);
+
+ /* Fill RSDT header. */
+ grub_memcpy (&(rsdt->signature), "RSDT", 4);
+ rsdt->length = sizeof (struct grub_acpi_table_header) + sizeof (grub_uint32_t) * numoftables;
+ rsdt->revision = 1;
+ grub_memcpy (&(rsdt->oemid), root_oemid, sizeof (rsdt->oemid));
+ grub_memcpy (&(rsdt->oemtable), root_oemtable, sizeof (rsdt->oemtable));
+ rsdt->oemrev = root_oemrev;
+ grub_memcpy (&(rsdt->creator_id), root_creator_id, sizeof (rsdt->creator_id));
+ rsdt->creator_rev = root_creator_rev;
+
+ for (cur = acpi_tables; cur; cur = cur->next)
+ *(rsdt_entry++) = (grub_addr_t) cur->addr;
+
+ /* Recompute checksum. */
+ rsdt->checksum = 0;
+ rsdt->checksum = 1 + ~grub_byte_checksum (rsdt, rsdt->length);
+}
+
+/* Regenerate ACPIv1 RSDP */
+static void
+setv1table (void)
+{
+ /* Create RSDP. */
+ rsdpv1_new = (struct grub_acpi_rsdp_v10 *) playground_ptr;
+ playground_ptr += sizeof (struct grub_acpi_rsdp_v10);
+ grub_memcpy (&(rsdpv1_new->signature), GRUB_RSDP_SIGNATURE,
+ sizeof (rsdpv1_new->signature));
+ grub_memcpy (&(rsdpv1_new->oemid), root_oemid, sizeof (rsdpv1_new->oemid));
+ rsdpv1_new->revision = 0;
+ rsdpv1_new->rsdt_addr = (grub_addr_t) rsdt_addr;
+ rsdpv1_new->checksum = 0;
+ rsdpv1_new->checksum = 1 + ~grub_byte_checksum (rsdpv1_new,
+ sizeof (*rsdpv1_new));
+ grub_dprintf ("acpi", "Generated ACPIv1 tables\n");
+}
+
+static void
+setv2table (void)
+{
+ struct grub_acpi_table_header *xsdt;
+ struct efiemu_acpi_table *cur;
+ grub_uint64_t *xsdt_entry;
+ int numoftables;
+
+ numoftables = 0;
+ for (cur = acpi_tables; cur; cur = cur->next)
+ numoftables++;
+
+ /* Create XSDT. */
+ xsdt = (struct grub_acpi_table_header *) playground_ptr;
+ playground_ptr += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint64_t) * numoftables;
+
+ xsdt_entry = (grub_uint64_t *)(xsdt + 1);
+ for (cur = acpi_tables; cur; cur = cur->next)
+ *(xsdt_entry++) = (grub_addr_t) cur->addr;
+ grub_memcpy (&(xsdt->signature), "XSDT", 4);
+ xsdt->length = sizeof (struct grub_acpi_table_header) + sizeof (grub_uint64_t) * numoftables;
+ xsdt->revision = 1;
+ grub_memcpy (&(xsdt->oemid), root_oemid, sizeof (xsdt->oemid));
+ grub_memcpy (&(xsdt->oemtable), root_oemtable, sizeof (xsdt->oemtable));
+ xsdt->oemrev = root_oemrev;
+ grub_memcpy (&(xsdt->creator_id), root_creator_id, sizeof (xsdt->creator_id));
+ xsdt->creator_rev = root_creator_rev;
+ xsdt->checksum = 0;
+ xsdt->checksum = 1 + ~grub_byte_checksum (xsdt, xsdt->length);
+
+ /* Create RSDPv2. */
+ rsdpv2_new = (struct grub_acpi_rsdp_v20 *) playground_ptr;
+ playground_ptr += sizeof (struct grub_acpi_rsdp_v20);
+ grub_memcpy (&(rsdpv2_new->rsdpv1.signature), GRUB_RSDP_SIGNATURE,
+ sizeof (rsdpv2_new->rsdpv1.signature));
+ grub_memcpy (&(rsdpv2_new->rsdpv1.oemid), root_oemid,
+ sizeof (rsdpv2_new->rsdpv1.oemid));
+ rsdpv2_new->rsdpv1.revision = rev2;
+ rsdpv2_new->rsdpv1.rsdt_addr = (grub_addr_t) rsdt_addr;
+ rsdpv2_new->rsdpv1.checksum = 0;
+ rsdpv2_new->rsdpv1.checksum = 1 + ~grub_byte_checksum
+ (&(rsdpv2_new->rsdpv1), sizeof (rsdpv2_new->rsdpv1));
+ rsdpv2_new->length = sizeof (*rsdpv2_new);
+ rsdpv2_new->xsdt_addr = (grub_addr_t) xsdt;
+ rsdpv2_new->checksum = 0;
+ rsdpv2_new->checksum = 1 + ~grub_byte_checksum (rsdpv2_new,
+ rsdpv2_new->length);
+ grub_dprintf ("acpi", "Generated ACPIv2 tables\n");
+}
+
+static void
+free_tables (void)
+{
+ struct efiemu_acpi_table *cur, *t;
+ if (table_dsdt)
+ grub_free (table_dsdt);
+ for (cur = acpi_tables; cur;)
+ {
+ t = cur;
+ grub_free (cur->addr);
+ cur = cur->next;
+ grub_free (t);
+ }
+ acpi_tables = 0;
+ table_dsdt = 0;
+}
+
+static grub_err_t
+grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ struct grub_acpi_rsdp_v10 *rsdp;
+ struct efiemu_acpi_table *cur, *t;
+ int i, mmapregion;
+ int numoftables;
+
+ /* Default values if no RSDP is found. */
+ rev1 = 1;
+ rev2 = 3;
+
+ facs_addr = 0;
+ playground = playground_ptr = 0;
+ playground_size = 0;
+
+ rsdp = (struct grub_acpi_rsdp_v10 *) grub_machine_acpi_get_rsdpv2 ();
+
+ if (! rsdp)
+ rsdp = grub_machine_acpi_get_rsdpv1 ();
+
+ grub_dprintf ("acpi", "RSDP @%p\n", rsdp);
+
+ if (rsdp)
+ {
+ grub_uint32_t *entry_ptr;
+ char *exclude = 0;
+ char *load_only = 0;
+ char *ptr;
+ /* RSDT consists of header and an array of 32-bit pointers. */
+ struct grub_acpi_table_header *rsdt;
+
+ exclude = state[0].set ? grub_strdup (state[0].arg) : 0;
+ if (exclude)
+ {
+ for (ptr = exclude; *ptr; ptr++)
+ *ptr = grub_tolower (*ptr);
+ }
+
+ load_only = state[1].set ? grub_strdup (state[1].arg) : 0;
+ if (load_only)
+ {
+ for (ptr = load_only; *ptr; ptr++)
+ *ptr = grub_tolower (*ptr);
+ }
+
+ /* Set revision variables to replicate the same version as host. */
+ rev1 = ! rsdp->revision;
+ rev2 = rsdp->revision;
+ rsdt = (struct grub_acpi_table_header *) (grub_addr_t) rsdp->rsdt_addr;
+ /* Load host tables. */
+ for (entry_ptr = (grub_uint32_t *) (rsdt + 1);
+ entry_ptr < (grub_uint32_t *) (((grub_uint8_t *) rsdt)
+ + rsdt->length);
+ entry_ptr++)
+ {
+ char signature[5];
+ struct efiemu_acpi_table *table;
+ struct grub_acpi_table_header *curtable
+ = (struct grub_acpi_table_header *) (grub_addr_t) *entry_ptr;
+ signature[4] = 0;
+ for (i = 0; i < 4;i++)
+ signature[i] = grub_tolower (curtable->signature[i]);
+
+ /* If it's FADT it contains addresses of DSDT and FACS. */
+ if (grub_strcmp (signature, "facp") == 0)
+ {
+ struct grub_acpi_table_header *dsdt;
+ struct grub_acpi_fadt *fadt = (struct grub_acpi_fadt *) curtable;
+
+ /* Set root header variables to the same values
+ as FADT by default. */
+ grub_memcpy (&root_oemid, &(fadt->hdr.oemid),
+ sizeof (root_oemid));
+ grub_memcpy (&root_oemtable, &(fadt->hdr.oemtable),
+ sizeof (root_oemtable));
+ root_oemrev = fadt->hdr.oemrev;
+ grub_memcpy (&root_creator_id, &(fadt->hdr.creator_id),
+ sizeof (root_creator_id));
+ root_creator_rev = fadt->hdr.creator_rev;
+
+ /* Load DSDT if not excluded. */
+ dsdt = (struct grub_acpi_table_header *)
+ (grub_addr_t) fadt->dsdt_addr;
+ if (dsdt && (! exclude || ! grub_strword (exclude, "dsdt"))
+ && (! load_only || grub_strword (load_only, "dsdt"))
+ && dsdt->length >= sizeof (*dsdt))
+ {
+ dsdt_size = dsdt->length;
+ table_dsdt = grub_malloc (dsdt->length);
+ if (! table_dsdt)
+ {
+ free_tables ();
+ grub_free (exclude);
+ grub_free (load_only);
+ return grub_errno;
+ }
+ grub_memcpy (table_dsdt, dsdt, dsdt->length);
+ }
+
+ /* Save FACS address. FACS shouldn't be overridden. */
+ facs_addr = fadt->facs_addr;
+ }
+
+ /* Skip excluded tables. */
+ if (exclude && grub_strword (exclude, signature))
+ continue;
+ if (load_only && ! grub_strword (load_only, signature))
+ continue;
+
+ /* Sanity check. */
+ if (curtable->length < sizeof (*curtable))
+ continue;
+
+ table = (struct efiemu_acpi_table *) grub_malloc
+ (sizeof (struct efiemu_acpi_table));
+ if (! table)
+ {
+ free_tables ();
+ grub_free (exclude);
+ grub_free (load_only);
+ return grub_errno;
+ }
+ table->size = curtable->length;
+ table->addr = grub_malloc (table->size);
+ playground_size += table->size;
+ if (! table->addr)
+ {
+ free_tables ();
+ grub_free (exclude);
+ grub_free (load_only);
+ grub_free (table);
+ return grub_errno;
+ }
+ table->next = acpi_tables;
+ acpi_tables = table;
+ grub_memcpy (table->addr, curtable, table->size);
+ }
+ grub_free (exclude);
+ grub_free (load_only);
+ }
+
+ /* Does user specify versions to generate? */
+ if (state[2].set || state[3].set)
+ {
+ rev1 = state[2].set;
+ if (state[3].set)
+ rev2 = rev2 ? : 2;
+ else
+ rev2 = 0;
+ }
+
+ /* Does user override root header information? */
+ if (state[4].set)
+ grub_strncpy (root_oemid, state[4].arg, sizeof (root_oemid));
+ if (state[5].set)
+ grub_strncpy (root_oemtable, state[5].arg, sizeof (root_oemtable));
+ if (state[6].set)
+ root_oemrev = grub_strtoul (state[6].arg, 0, 0);
+ if (state[7].set)
+ grub_strncpy (root_creator_id, state[7].arg, sizeof (root_creator_id));
+ if (state[8].set)
+ root_creator_rev = grub_strtoul (state[8].arg, 0, 0);
+
+ /* Load user tables */
+ for (i = 0; i < argc; i++)
+ {
+ grub_file_t file;
+ grub_size_t size;
+ char *buf;
+
+ file = grub_file_open (args[i], GRUB_FILE_TYPE_ACPI_TABLE);
+ if (! file)
+ {
+ free_tables ();
+ return grub_errno;
+ }
+
+ size = grub_file_size (file);
+ if (size < sizeof (struct grub_acpi_table_header))
+ {
+ grub_file_close (file);
+ free_tables ();
+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ args[i]);
+ }
+
+ buf = (char *) grub_malloc (size);
+ if (! buf)
+ {
+ grub_file_close (file);
+ free_tables ();
+ return grub_errno;
+ }
+
+ if (grub_file_read (file, buf, size) != (int) size)
+ {
+ grub_file_close (file);
+ free_tables ();
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ args[i]);
+ return grub_errno;
+ }
+ grub_file_close (file);
+
+ if (grub_memcmp (((struct grub_acpi_table_header *) buf)->signature,
+ "DSDT", 4) == 0)
+ {
+ grub_free (table_dsdt);
+ table_dsdt = buf;
+ dsdt_size = size;
+ }
+ else
+ {
+ struct efiemu_acpi_table *table;
+ table = (struct efiemu_acpi_table *) grub_malloc
+ (sizeof (struct efiemu_acpi_table));
+ if (! table)
+ {
+ free_tables ();
+ return grub_errno;
+ }
+
+ table->size = size;
+ table->addr = buf;
+ playground_size += table->size;
+
+ table->next = acpi_tables;
+ acpi_tables = table;
+ }
+ }
+
+ numoftables = 0;
+ for (cur = acpi_tables; cur; cur = cur->next)
+ numoftables++;
+
+ /* DSDT. */
+ playground_size += dsdt_size;
+ /* RSDT. */
+ playground_size += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint32_t) * numoftables;
+ /* RSDPv1. */
+ playground_size += sizeof (struct grub_acpi_rsdp_v10);
+ /* XSDT. */
+ playground_size += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint64_t) * numoftables;
+ /* RSDPv2. */
+ playground_size += sizeof (struct grub_acpi_rsdp_v20);
+
+ playground = playground_ptr
+ = grub_mmap_malign_and_register (1, playground_size, &mmapregion,
+ GRUB_MEMORY_ACPI, 0);
+
+ if (! playground)
+ {
+ free_tables ();
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "couldn't allocate space for ACPI tables");
+ }
+
+ setup_common_tables ();
+
+ /* Request space for RSDPv1. */
+ if (rev1)
+ setv1table ();
+
+ /* Request space for RSDPv2+ and XSDT. */
+ if (rev2)
+ setv2table ();
+
+ for (cur = acpi_tables; cur;)
+ {
+ t = cur;
+ cur = cur->next;
+ grub_free (t);
+ }
+ acpi_tables = 0;
+
+#if defined (__i386__) || defined (__x86_64__)
+ if (! state[9].set)
+ {
+ grub_err_t err;
+ err = grub_acpi_create_ebda ();
+ if (err)
+ {
+ rsdpv1_new = 0;
+ rsdpv2_new = 0;
+ grub_mmap_free_and_unregister (mmapregion);
+ return err;
+ }
+ }
+#endif
+
+#ifdef GRUB_MACHINE_EFI
+ {
+ struct grub_efi_guid acpi = GRUB_EFI_ACPI_TABLE_GUID;
+ struct grub_efi_guid acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
+
+ efi_call_2 (grub_efi_system_table->boot_services->install_configuration_table,
+ &acpi20, grub_acpi_get_rsdpv2 ());
+ efi_call_2 (grub_efi_system_table->boot_services->install_configuration_table,
+ &acpi, grub_acpi_get_rsdpv1 ());
+ }
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(acpi)
+{
+ cmd = grub_register_extcmd_lockdown ("acpi", grub_cmd_acpi, 0,
+ N_("[-1|-2] [--exclude=TABLE1,TABLE2|"
+ "--load-only=TABLE1,TABLE2] FILE1"
+ " [FILE2] [...]"),
+ N_("Load host ACPI tables and tables "
+ "specified by arguments."),
+ options);
+}
+
+GRUB_MOD_FINI(acpi)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c
new file mode 100644
index 0000000..9cc7f18
--- /dev/null
+++ b/grub-core/commands/acpihalt.c
@@ -0,0 +1,454 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef GRUB_DSDT_TEST
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+
+#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;
+typedef uint8_t grub_uint8_t;
+
+#endif
+
+#include <grub/acpi.h>
+#ifndef GRUB_DSDT_TEST
+#include <grub/i18n.h>
+#else
+#define _(x) x
+#define N_(x) x
+#endif
+
+#ifndef GRUB_DSDT_TEST
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/time.h>
+#include <grub/cpu/io.h>
+#endif
+
+static inline grub_uint32_t
+decode_length (const grub_uint8_t *ptr, int *numlen)
+{
+ int num_bytes, i;
+ grub_uint32_t ret;
+ if (*ptr < 64)
+ {
+ if (numlen)
+ *numlen = 1;
+ return *ptr;
+ }
+ num_bytes = *ptr >> 6;
+ if (numlen)
+ *numlen = num_bytes + 1;
+ ret = *ptr & 0xf;
+ ptr++;
+ for (i = 0; i < num_bytes; i++)
+ {
+ ret |= *ptr << (8 * i + 4);
+ ptr++;
+ }
+ return ret;
+}
+
+static inline grub_uint32_t
+skip_name_string (const grub_uint8_t *ptr, const grub_uint8_t *end)
+{
+ const grub_uint8_t *ptr0 = ptr;
+
+ while (ptr < end && (*ptr == '^' || *ptr == '\\'))
+ ptr++;
+ switch (*ptr)
+ {
+ case '.':
+ ptr++;
+ ptr += 8;
+ break;
+ case '/':
+ ptr++;
+ ptr += 1 + (*ptr) * 4;
+ break;
+ case 0:
+ ptr++;
+ break;
+ default:
+ ptr += 4;
+ break;
+ }
+ return ptr - ptr0;
+}
+
+static inline grub_uint32_t
+skip_data_ref_object (const grub_uint8_t *ptr, const grub_uint8_t *end)
+{
+ grub_dprintf ("acpi", "data type = 0x%x\n", *ptr);
+ switch (*ptr)
+ {
+ case GRUB_ACPI_OPCODE_PACKAGE:
+ case GRUB_ACPI_OPCODE_BUFFER:
+ return 1 + decode_length (ptr + 1, 0);
+ case GRUB_ACPI_OPCODE_ZERO:
+ case GRUB_ACPI_OPCODE_ONES:
+ case GRUB_ACPI_OPCODE_ONE:
+ return 1;
+ case GRUB_ACPI_OPCODE_BYTE_CONST:
+ return 2;
+ case GRUB_ACPI_OPCODE_WORD_CONST:
+ return 3;
+ case GRUB_ACPI_OPCODE_DWORD_CONST:
+ return 5;
+ case GRUB_ACPI_OPCODE_STRING_CONST:
+ {
+ const grub_uint8_t *ptr0 = ptr;
+ for (ptr++; ptr < end && *ptr; ptr++);
+ if (ptr == end)
+ return 0;
+ return ptr - ptr0 + 1;
+ }
+ default:
+ if (*ptr == '^' || *ptr == '\\' || *ptr == '_'
+ || (*ptr >= 'A' && *ptr <= 'Z'))
+ return skip_name_string (ptr, end);
+ grub_printf ("Unknown opcode 0x%x\n", *ptr);
+ return 0;
+ }
+}
+
+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;
+ int add;
+ grub_dprintf ("acpi", "Extended opcode: 0x%x\n", *ptr);
+ switch (*ptr)
+ {
+ case GRUB_ACPI_EXTOPCODE_MUTEX:
+ ptr++;
+ ptr += skip_name_string (ptr, end);
+ ptr++;
+ break;
+ case GRUB_ACPI_EXTOPCODE_EVENT_OP:
+ ptr++;
+ ptr += skip_name_string (ptr, end);
+ break;
+ case GRUB_ACPI_EXTOPCODE_OPERATION_REGION:
+ ptr++;
+ ptr += skip_name_string (ptr, end);
+ ptr++;
+ ptr += add = skip_term (ptr, end);
+ if (!add)
+ return 0;
+ ptr += add = skip_term (ptr, end);
+ if (!add)
+ return 0;
+ break;
+ case GRUB_ACPI_EXTOPCODE_FIELD_OP:
+ case GRUB_ACPI_EXTOPCODE_DEVICE_OP:
+ case GRUB_ACPI_EXTOPCODE_PROCESSOR_OP:
+ case GRUB_ACPI_EXTOPCODE_POWER_RES_OP:
+ case GRUB_ACPI_EXTOPCODE_THERMAL_ZONE_OP:
+ case GRUB_ACPI_EXTOPCODE_INDEX_FIELD_OP:
+ case GRUB_ACPI_EXTOPCODE_BANK_FIELD_OP:
+ ptr++;
+ ptr += decode_length (ptr, 0);
+ break;
+ default:
+ grub_printf ("Unexpected extended opcode: 0x%x\n", *ptr);
+ return 0;
+ }
+ 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)
+{
+ grub_uint8_t *prev = table;
+
+ if (!ptr)
+ ptr = table + sizeof (struct grub_acpi_table_header);
+ while (ptr < end && prev < ptr)
+ {
+ int add;
+ prev = ptr;
+ grub_dprintf ("acpi", "Opcode 0x%x\n", *ptr);
+ grub_dprintf ("acpi", "Tell %x\n", (unsigned) (ptr - table));
+ switch (*ptr)
+ {
+ case GRUB_ACPI_OPCODE_EXTOP:
+ ptr++;
+ ptr += add = skip_ext_op (ptr, 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:
+ {
+ ptr += 5;
+ ptr += add = skip_data_ref_object (ptr, end);
+ if (!add)
+ return -1;
+ ptr += 4;
+ break;
+ }
+ case GRUB_ACPI_OPCODE_NAME:
+ ptr++;
+ 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;
+ grub_dprintf ("acpi", "S5 found\n");
+ ptr2 += skip_name_string (ptr, end);
+ if (*ptr2 != 0x12)
+ {
+ grub_printf ("Unknown opcode in _S5: 0x%x\n", *ptr2);
+ return -1;
+ }
+ ptr2++;
+ decode_length (ptr2, &ll);
+ ptr2 += ll;
+ ptr2++;
+ switch (*ptr2)
+ {
+ case GRUB_ACPI_OPCODE_ZERO:
+ return 0;
+ case GRUB_ACPI_OPCODE_ONE:
+ return 1;
+ case GRUB_ACPI_OPCODE_BYTE_CONST:
+ return ptr2[1];
+ default:
+ grub_printf ("Unknown data type in _S5: 0x%x\n", *ptr2);
+ return -1;
+ }
+ }
+ ptr += add = skip_name_string (ptr, end);
+ if (!add)
+ return -1;
+ ptr += add = skip_data_ref_object (ptr, 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;
+ int ll;
+ grub_uint8_t *name;
+ int name_len;
+
+ ptr++;
+ add = decode_length (ptr, &ll);
+ name = ptr + ll;
+ name_len = skip_name_string (name, ptr + add);
+ if (!name_len)
+ return -1;
+ scope_sleep_type = get_sleep_type (table, name + name_len,
+ ptr + add, name, name_len);
+ if (scope_sleep_type != -2)
+ return scope_sleep_type;
+ ptr += add;
+ break;
+ }
+ case GRUB_ACPI_OPCODE_IF:
+ case GRUB_ACPI_OPCODE_METHOD:
+ {
+ ptr++;
+ ptr += decode_length (ptr, 0);
+ break;
+ }
+ default:
+ grub_printf ("Unknown opcode 0x%x\n", *ptr);
+ return -1;
+ }
+ }
+
+ return -2;
+}
+
+#ifdef GRUB_DSDT_TEST
+int
+main (int argc, char **argv)
+{
+ FILE *f;
+ size_t len;
+ unsigned char *buf;
+ if (argc < 2)
+ printf ("Usage: %s FILE\n", argv[0]);
+ f = grub_util_fopen (argv[1], "rb");
+ if (!f)
+ {
+ printf ("Couldn't open file\n");
+ return 1;
+ }
+ fseek (f, 0, SEEK_END);
+ len = ftell (f);
+ fseek (f, 0, SEEK_SET);
+ buf = malloc (len);
+ if (!buf)
+ {
+ printf (_("error: %s.\n"), _("out of memory"));
+ fclose (f);
+ return 2;
+ }
+ if (fread (buf, 1, len, f) != len)
+ {
+ printf (_("cannot read `%s': %s"), argv[1], strerror (errno));
+ free (buf);
+ fclose (f);
+ return 2;
+ }
+
+ printf ("Sleep type = %d\n", get_sleep_type (buf, NULL, buf + len, NULL, 0));
+ free (buf);
+ fclose (f);
+ return 0;
+}
+
+#else
+
+void
+grub_acpi_halt (void)
+{
+ struct grub_acpi_rsdp_v20 *rsdp2;
+ struct grub_acpi_rsdp_v10 *rsdp1;
+ struct grub_acpi_table_header *rsdt;
+ grub_uint32_t *entry_ptr;
+ grub_uint32_t port = 0;
+ int sleep_type = -1;
+
+ rsdp2 = grub_acpi_get_rsdpv2 ();
+ if (rsdp2)
+ rsdp1 = &(rsdp2->rsdpv1);
+ else
+ rsdp1 = grub_acpi_get_rsdpv1 ();
+ grub_dprintf ("acpi", "rsdp1=%p\n", rsdp1);
+ if (!rsdp1)
+ return;
+
+ rsdt = (struct grub_acpi_table_header *) (grub_addr_t) rsdp1->rsdt_addr;
+ for (entry_ptr = (grub_uint32_t *) (rsdt + 1);
+ entry_ptr < (grub_uint32_t *) (((grub_uint8_t *) rsdt)
+ + rsdt->length);
+ entry_ptr++)
+ {
+ if (grub_memcmp ((void *) (grub_addr_t) *entry_ptr, "FACP", 4) == 0)
+ {
+ struct grub_acpi_fadt *fadt
+ = ((struct grub_acpi_fadt *) (grub_addr_t) *entry_ptr);
+ struct grub_acpi_table_header *dsdt
+ = (struct grub_acpi_table_header *) (grub_addr_t) fadt->dsdt_addr;
+ grub_uint8_t *buf = (grub_uint8_t *) dsdt;
+
+ port = fadt->pm1a;
+
+ grub_dprintf ("acpi", "PM1a port=%x\n", port);
+
+ if (grub_memcmp (dsdt->signature, "DSDT",
+ sizeof (dsdt->signature)) == 0
+ && sleep_type < 0)
+ sleep_type = get_sleep_type (buf, NULL, buf + dsdt->length,
+ NULL, 0);
+ }
+ else if (grub_memcmp ((void *) (grub_addr_t) *entry_ptr, "SSDT", 4) == 0
+ && sleep_type < 0)
+ {
+ struct grub_acpi_table_header *ssdt
+ = (struct grub_acpi_table_header *) (grub_addr_t) *entry_ptr;
+ grub_uint8_t *buf = (grub_uint8_t *) ssdt;
+
+ grub_dprintf ("acpi", "SSDT = %p\n", ssdt);
+
+ sleep_type = get_sleep_type (buf, NULL, buf + ssdt->length, NULL, 0);
+ }
+ }
+
+ grub_dprintf ("acpi", "SLP_TYP = %d, port = 0x%x\n", sleep_type, port);
+ if (port && sleep_type >= 0 && sleep_type < 8)
+ grub_outw (GRUB_ACPI_SLP_EN | (sleep_type << GRUB_ACPI_SLP_TYP_OFFSET),
+ port & 0xffff);
+
+ grub_millisleep (1500);
+
+ /* TRANSLATORS: It's computer shutdown using ACPI, not disabling ACPI. */
+ grub_puts_ (N_("ACPI shutdown failed"));
+}
+#endif
diff --git a/grub-core/commands/arc/lsdev.c b/grub-core/commands/arc/lsdev.c
new file mode 100644
index 0000000..27ed0a2
--- /dev/null
+++ b/grub-core/commands/arc/lsdev.c
@@ -0,0 +1,57 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/arc/arc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Helper for grub_cmd_lsdev. */
+static int
+grub_cmd_lsdev_iter (const char *name,
+ const struct grub_arc_component *comp __attribute__ ((unused)),
+ void *data __attribute__ ((unused)))
+{
+ grub_printf ("%s\n", name);
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_lsdev (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_arc_iterate_devs (grub_cmd_lsdev_iter, 0, 0);
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lsdev)
+{
+ cmd = grub_register_command ("lsdev", grub_cmd_lsdev, "",
+ N_("List devices."));
+}
+
+GRUB_MOD_FINI(lsdev)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/blocklist.c b/grub-core/commands/blocklist.c
new file mode 100644
index 0000000..944449b
--- /dev/null
+++ b/grub-core/commands/blocklist.c
@@ -0,0 +1,160 @@
+/* blocklist.c - print the block list of a file */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Context for grub_cmd_blocklist. */
+struct blocklist_ctx
+{
+ unsigned long start_sector;
+ unsigned num_sectors;
+ int num_entries;
+ grub_disk_addr_t part_start;
+};
+
+/* Helper for grub_cmd_blocklist. */
+static void
+print_blocklist (grub_disk_addr_t sector, unsigned num,
+ unsigned offset, unsigned length, struct blocklist_ctx *ctx)
+{
+ if (ctx->num_entries++)
+ grub_printf (",");
+
+ grub_printf ("%llu", (unsigned long long) (sector - ctx->part_start));
+ if (num > 0)
+ grub_printf ("+%u", num);
+ if (offset != 0 || length != 0)
+ grub_printf ("[%u-%u]", offset, offset + length);
+}
+
+/* Helper for grub_cmd_blocklist. */
+static void
+read_blocklist (grub_disk_addr_t sector, unsigned offset, unsigned length,
+ void *data)
+{
+ struct blocklist_ctx *ctx = data;
+
+ if (ctx->num_sectors > 0)
+ {
+ if (ctx->start_sector + ctx->num_sectors == sector
+ && offset == 0 && length >= GRUB_DISK_SECTOR_SIZE)
+ {
+ ctx->num_sectors += length >> GRUB_DISK_SECTOR_BITS;
+ sector += length >> GRUB_DISK_SECTOR_BITS;
+ length &= (GRUB_DISK_SECTOR_SIZE - 1);
+ }
+
+ if (!length)
+ return;
+ print_blocklist (ctx->start_sector, ctx->num_sectors, 0, 0, ctx);
+ ctx->num_sectors = 0;
+ }
+
+ if (offset)
+ {
+ unsigned l = length + offset;
+ l &= (GRUB_DISK_SECTOR_SIZE - 1);
+ l -= offset;
+ print_blocklist (sector, 0, offset, l, ctx);
+ length -= l;
+ sector++;
+ offset = 0;
+ }
+
+ if (!length)
+ return;
+
+ if (length & (GRUB_DISK_SECTOR_SIZE - 1))
+ {
+ if (length >> GRUB_DISK_SECTOR_BITS)
+ {
+ print_blocklist (sector, length >> GRUB_DISK_SECTOR_BITS, 0, 0, ctx);
+ sector += length >> GRUB_DISK_SECTOR_BITS;
+ }
+ print_blocklist (sector, 0, 0, length & (GRUB_DISK_SECTOR_SIZE - 1), ctx);
+ }
+ else
+ {
+ ctx->start_sector = sector;
+ ctx->num_sectors = length >> GRUB_DISK_SECTOR_BITS;
+ }
+}
+
+static grub_err_t
+grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_file_t file;
+ char buf[GRUB_DISK_SECTOR_SIZE];
+ struct blocklist_ctx ctx = {
+ .start_sector = 0,
+ .num_sectors = 0,
+ .num_entries = 0,
+ .part_start = 0
+ };
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ file = grub_file_open (args[0], GRUB_FILE_TYPE_PRINT_BLOCKLIST
+ | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (! file)
+ return grub_errno;
+
+ if (! file->device->disk)
+ return grub_error (GRUB_ERR_BAD_DEVICE,
+ "this command is available only for disk devices");
+
+ ctx.part_start = grub_partition_get_start (file->device->disk->partition);
+
+ file->read_hook = read_blocklist;
+ file->read_hook_data = &ctx;
+
+ while (grub_file_read (file, buf, sizeof (buf)) > 0)
+ ;
+
+ if (ctx.num_sectors > 0)
+ print_blocklist (ctx.start_sector, ctx.num_sectors, 0, 0, &ctx);
+
+ grub_file_close (file);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(blocklist)
+{
+ cmd = grub_register_command ("blocklist", grub_cmd_blocklist,
+ N_("FILE"), N_("Print a block list."));
+}
+
+GRUB_MOD_FINI(blocklist)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/boot.c b/grub-core/commands/boot.c
new file mode 100644
index 0000000..bbca81e
--- /dev/null
+++ b/grub-core/commands/boot.c
@@ -0,0 +1,195 @@
+/* boot.c - command to boot an operating system */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/loader.h>
+#include <grub/kernel.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t (*grub_loader_boot_func) (void);
+static grub_err_t (*grub_loader_unload_func) (void);
+static int grub_loader_flags;
+
+struct grub_preboot
+{
+ grub_err_t (*preboot_func) (int);
+ grub_err_t (*preboot_rest_func) (void);
+ grub_loader_preboot_hook_prio_t prio;
+ struct grub_preboot *next;
+ struct grub_preboot *prev;
+};
+
+static int grub_loader_loaded;
+static struct grub_preboot *preboots_head = 0,
+ *preboots_tail = 0;
+
+int
+grub_loader_is_loaded (void)
+{
+ return grub_loader_loaded;
+}
+
+/* Register a preboot hook. */
+struct grub_preboot *
+grub_loader_register_preboot_hook (grub_err_t (*preboot_func) (int flags),
+ grub_err_t (*preboot_rest_func) (void),
+ grub_loader_preboot_hook_prio_t prio)
+{
+ struct grub_preboot *cur, *new_preboot;
+
+ if (! preboot_func && ! preboot_rest_func)
+ return 0;
+
+ new_preboot = (struct grub_preboot *)
+ grub_malloc (sizeof (struct grub_preboot));
+ if (! new_preboot)
+ return 0;
+
+ new_preboot->preboot_func = preboot_func;
+ new_preboot->preboot_rest_func = preboot_rest_func;
+ new_preboot->prio = prio;
+
+ for (cur = preboots_head; cur && cur->prio > prio; cur = cur->next);
+
+ if (cur)
+ {
+ new_preboot->next = cur;
+ new_preboot->prev = cur->prev;
+ cur->prev = new_preboot;
+ }
+ else
+ {
+ new_preboot->next = 0;
+ new_preboot->prev = preboots_tail;
+ preboots_tail = new_preboot;
+ }
+ if (new_preboot->prev)
+ new_preboot->prev->next = new_preboot;
+ else
+ preboots_head = new_preboot;
+
+ return new_preboot;
+}
+
+void
+grub_loader_unregister_preboot_hook (struct grub_preboot *hnd)
+{
+ struct grub_preboot *preb = hnd;
+
+ if (preb->next)
+ preb->next->prev = preb->prev;
+ else
+ preboots_tail = preb->prev;
+ if (preb->prev)
+ preb->prev->next = preb->next;
+ else
+ preboots_head = preb->next;
+
+ grub_free (preb);
+}
+
+void
+grub_loader_set (grub_err_t (*boot) (void),
+ grub_err_t (*unload) (void),
+ int flags)
+{
+ if (grub_loader_loaded && grub_loader_unload_func)
+ grub_loader_unload_func ();
+
+ grub_loader_boot_func = boot;
+ grub_loader_unload_func = unload;
+ grub_loader_flags = flags;
+
+ grub_loader_loaded = 1;
+}
+
+void
+grub_loader_unset(void)
+{
+ if (grub_loader_loaded && grub_loader_unload_func)
+ grub_loader_unload_func ();
+
+ grub_loader_boot_func = 0;
+ grub_loader_unload_func = 0;
+
+ grub_loader_loaded = 0;
+}
+
+grub_err_t
+grub_loader_boot (void)
+{
+ grub_err_t err = GRUB_ERR_NONE;
+ struct grub_preboot *cur;
+
+ if (! grub_loader_loaded)
+ return grub_error (GRUB_ERR_NO_KERNEL,
+ N_("you need to load the kernel first"));
+
+ grub_machine_fini (grub_loader_flags);
+
+ for (cur = preboots_head; cur; cur = cur->next)
+ {
+ err = cur->preboot_func (grub_loader_flags);
+ if (err)
+ {
+ for (cur = cur->prev; cur; cur = cur->prev)
+ cur->preboot_rest_func ();
+ return err;
+ }
+ }
+ err = (grub_loader_boot_func) ();
+
+ for (cur = preboots_tail; cur; cur = cur->prev)
+ if (! err)
+ err = cur->preboot_rest_func ();
+ else
+ cur->preboot_rest_func ();
+
+ return err;
+}
+
+/* boot */
+static grub_err_t
+grub_cmd_boot (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ return grub_loader_boot ();
+}
+
+
+
+static grub_command_t cmd_boot;
+
+GRUB_MOD_INIT(boot)
+{
+ cmd_boot =
+ grub_register_command ("boot", grub_cmd_boot,
+ 0, N_("Boot an operating system."));
+}
+
+GRUB_MOD_FINI(boot)
+{
+ grub_unregister_command (cmd_boot);
+}
diff --git a/grub-core/commands/boottime.c b/grub-core/commands/boottime.c
new file mode 100644
index 0000000..dcc078c
--- /dev/null
+++ b/grub-core/commands/boottime.c
@@ -0,0 +1,65 @@
+/*
+ * 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/dl.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+
+static grub_err_t
+grub_cmd_boottime (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ struct grub_boot_time *cur;
+ grub_uint64_t last_time = 0, start_time = 0;
+ if (!grub_boot_time_head)
+ {
+ grub_puts_ (N_("No boot time statistics is available\n"));
+ return 0;
+ }
+ start_time = last_time = grub_boot_time_head->tp;
+ for (cur = grub_boot_time_head; cur; cur = cur->next)
+ {
+ grub_uint32_t tmabs = cur->tp - start_time;
+ grub_uint32_t tmrel = cur->tp - last_time;
+ last_time = cur->tp;
+
+ grub_printf ("%3d.%03ds %2d.%03ds %s:%d %s\n",
+ tmabs / 1000, tmabs % 1000, tmrel / 1000, tmrel % 1000, cur->file, cur->line,
+ cur->msg);
+ }
+ return 0;
+}
+
+static grub_command_t cmd_boottime;
+
+GRUB_MOD_INIT(boottime)
+{
+ cmd_boottime =
+ grub_register_command ("boottime", grub_cmd_boottime,
+ 0, N_("Show boot time statistics."));
+}
+
+GRUB_MOD_FINI(boottime)
+{
+ grub_unregister_command (cmd_boottime);
+}
diff --git a/grub-core/commands/cacheinfo.c b/grub-core/commands/cacheinfo.c
new file mode 100644
index 0000000..d34a346
--- /dev/null
+++ b/grub-core/commands/cacheinfo.c
@@ -0,0 +1,62 @@
+/* cacheinfo.c - disk cache statistics */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#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)),
+ char *argv[] __attribute__ ((unused)))
+{
+ unsigned long hits, misses;
+
+ grub_disk_cache_get_performance (&hits, &misses);
+ if (hits + misses)
+ {
+ unsigned long ratio = hits * 10000 / (hits + misses);
+ grub_printf ("(%lu.%lu%%)\n", ratio / 100, ratio % 100);
+ grub_printf_ (N_("Disk cache statistics: hits = %lu (%lu.%02lu%%),"
+ " misses = %lu\n"), ratio / 100, ratio % 100,
+ hits, misses);
+ }
+ else
+ grub_printf ("%s\n", _("No disk cache statistics available\n"));
+
+ return 0;
+}
+
+static grub_command_t cmd_cacheinfo;
+
+GRUB_MOD_INIT(cacheinfo)
+{
+ cmd_cacheinfo =
+ grub_register_command ("cacheinfo", grub_rescue_cmd_info,
+ 0, N_("Get disk cache info."));
+}
+
+GRUB_MOD_FINI(cacheinfo)
+{
+ grub_unregister_command (cmd_cacheinfo);
+}
diff --git a/grub-core/commands/cat.c b/grub-core/commands/cat.c
new file mode 100644
index 0000000..ba5f006
--- /dev/null
+++ b/grub-core/commands/cat.c
@@ -0,0 +1,170 @@
+/* cat.c - command to show the contents of a file */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/charset.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ {"dos", -1, 0, N_("Accept DOS-style CR/NL line endings."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ int dos = 0;
+ grub_file_t file;
+ unsigned char buf[GRUB_DISK_SECTOR_SIZE];
+ grub_ssize_t size;
+ int key = GRUB_TERM_NO_KEY;
+ grub_uint32_t code = 0;
+ int count = 0;
+ unsigned char utbuf[GRUB_MAX_UTF8_PER_CODEPOINT + 1];
+ int utcount = 0;
+ int is_0d = 0;
+ int j;
+
+ if (state[0].set)
+ dos = 1;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ file = grub_file_open (args[0], GRUB_FILE_TYPE_CAT);
+ if (! file)
+ return grub_errno;
+
+ while ((size = grub_file_read (file, buf, sizeof (buf))) > 0
+ && key != GRUB_TERM_ESC)
+ {
+ int i;
+
+ for (i = 0; i < size; i++)
+ {
+ utbuf[utcount++] = buf[i];
+
+ if (is_0d && buf[i] != '\n')
+ {
+ grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
+ grub_printf ("<%x>", (int) '\r');
+ grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
+ }
+
+ is_0d = 0;
+
+ if (!grub_utf8_process (buf[i], &code, &count))
+ {
+ grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
+ for (j = 0; j < utcount - 1; j++)
+ grub_printf ("<%x>", (unsigned int) utbuf[j]);
+ code = 0;
+ count = 0;
+ if (utcount == 1 || !grub_utf8_process (buf[i], &code, &count))
+ {
+ grub_printf ("<%x>", (unsigned int) buf[i]);
+ code = 0;
+ count = 0;
+ utcount = 0;
+ grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
+ continue;
+ }
+ grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
+ utcount = 1;
+ }
+ if (count)
+ continue;
+
+ if ((code >= 0xa1 || grub_isprint (code)
+ || grub_isspace (code)) && code != '\r')
+ {
+ grub_printf ("%C", code);
+ count = 0;
+ code = 0;
+ utcount = 0;
+ continue;
+ }
+
+ if (dos && code == '\r')
+ {
+ is_0d = 1;
+ count = 0;
+ code = 0;
+ utcount = 0;
+ continue;
+ }
+
+ 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);
+ count = 0;
+ code = 0;
+ utcount = 0;
+ }
+
+ do
+ key = grub_getkey_noblock ();
+ while (key != GRUB_TERM_ESC && key != GRUB_TERM_NO_KEY);
+ }
+
+ if (is_0d)
+ {
+ grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
+ grub_printf ("<%x>", (unsigned int) '\r');
+ 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 ();
+ grub_file_close (file);
+
+ return 0;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(cat)
+{
+ cmd = grub_register_extcmd ("cat", grub_cmd_cat, 0,
+ N_("FILE"), N_("Show the contents of a file."),
+ options);
+}
+
+GRUB_MOD_FINI(cat)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/cmp.c b/grub-core/commands/cmp.c
new file mode 100644
index 0000000..e9c3b25
--- /dev/null
+++ b/grub-core/commands/cmp.c
@@ -0,0 +1,119 @@
+/* cmd.c - command to cmp an operating system */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define BUFFER_SIZE 512
+
+static grub_err_t
+grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_ssize_t rd1, rd2;
+ grub_off_t pos;
+ grub_file_t file1 = 0;
+ grub_file_t file2 = 0;
+ char *buf1 = 0;
+ char *buf2 = 0;
+
+ if (argc != 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+ grub_printf_ (N_("Compare file `%s' with `%s':\n"), args[0],
+ args[1]);
+
+ file1 = grub_file_open (args[0], GRUB_FILE_TYPE_CMP);
+ file2 = grub_file_open (args[1], GRUB_FILE_TYPE_CMP);
+ if (! file1 || ! file2)
+ goto cleanup;
+
+ if (grub_file_size (file1) != grub_file_size (file2))
+ grub_printf_ (N_("Files differ in size: %llu [%s], %llu [%s]\n"),
+ (unsigned long long) grub_file_size (file1), args[0],
+ (unsigned long long) grub_file_size (file2), args[1]);
+ else
+ {
+ pos = 0;
+
+ buf1 = grub_malloc (BUFFER_SIZE);
+ buf2 = grub_malloc (BUFFER_SIZE);
+
+ if (! buf1 || ! buf2)
+ goto cleanup;
+
+ do
+ {
+ int i;
+
+ rd1 = grub_file_read (file1, buf1, BUFFER_SIZE);
+ rd2 = grub_file_read (file2, buf2, BUFFER_SIZE);
+
+ if (rd1 != rd2)
+ goto cleanup;
+
+ for (i = 0; i < rd2; i++)
+ {
+ if (buf1[i] != buf2[i])
+ {
+ grub_printf_ (N_("Files differ at the offset %llu: 0x%x [%s], 0x%x [%s]\n"),
+ (unsigned long long) (i + pos), buf1[i],
+ args[0], buf2[i], args[1]);
+ goto cleanup;
+ }
+ }
+ pos += BUFFER_SIZE;
+
+ }
+ while (rd2);
+
+ /* TRANSLATORS: it's always exactly 2 files. */
+ grub_printf_ (N_("The files are identical.\n"));
+ }
+
+cleanup:
+
+ grub_free (buf1);
+ grub_free (buf2);
+ if (file1)
+ grub_file_close (file1);
+ if (file2)
+ grub_file_close (file2);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(cmp)
+{
+ cmd = grub_register_command ("cmp", grub_cmd_cmp,
+ N_("FILE1 FILE2"), N_("Compare two files."));
+}
+
+GRUB_MOD_FINI(cmp)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/configfile.c b/grub-core/commands/configfile.c
new file mode 100644
index 0000000..f2d2abb
--- /dev/null
+++ b/grub-core/commands/configfile.c
@@ -0,0 +1,98 @@
+/* configfile.c - command to manually load config file */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/term.h>
+#include <grub/env.h>
+#include <grub/normal.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_source (grub_command_t cmd, int argc, char **args)
+{
+ int new_env, extractor;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ extractor = (cmd->name[0] == 'e');
+ new_env = (cmd->name[extractor ? sizeof ("extract_entries_") - 1 : 0] == 'c');
+
+ if (new_env)
+ grub_cls ();
+
+ if (new_env && !extractor)
+ grub_env_context_open ();
+ if (extractor)
+ grub_env_extractor_open (!new_env);
+
+ grub_normal_execute (args[0], 1, ! new_env);
+
+ if (new_env && !extractor)
+ grub_env_context_close ();
+ if (extractor)
+ grub_env_extractor_close (!new_env);
+
+ return 0;
+}
+
+static grub_command_t cmd_configfile, cmd_source, cmd_dot;
+static grub_command_t cmd_extractor_source, cmd_extractor_configfile;
+
+GRUB_MOD_INIT(configfile)
+{
+ cmd_configfile =
+ grub_register_command ("configfile", grub_cmd_source,
+ N_("FILE"), N_("Load another config file."));
+ cmd_source =
+ grub_register_command ("source", grub_cmd_source,
+ N_("FILE"),
+ N_("Load another config file without changing context.")
+ );
+
+ cmd_extractor_source =
+ grub_register_command ("extract_entries_source", grub_cmd_source,
+ N_("FILE"),
+ N_("Load another config file without changing context but take only menu entries.")
+ );
+
+ cmd_extractor_configfile =
+ grub_register_command ("extract_entries_configfile", grub_cmd_source,
+ N_("FILE"),
+ N_("Load another config file but take only menu entries.")
+ );
+
+ cmd_dot =
+ grub_register_command (".", grub_cmd_source,
+ N_("FILE"),
+ N_("Load another config file without changing context.")
+ );
+}
+
+GRUB_MOD_FINI(configfile)
+{
+ grub_unregister_command (cmd_configfile);
+ grub_unregister_command (cmd_source);
+ grub_unregister_command (cmd_extractor_configfile);
+ grub_unregister_command (cmd_extractor_source);
+ grub_unregister_command (cmd_dot);
+}
diff --git a/grub-core/commands/date.c b/grub-core/commands/date.c
new file mode 100644
index 0000000..5cb4faf
--- /dev/null
+++ b/grub-core/commands/date.c
@@ -0,0 +1,149 @@
+/* date.c - command to display/set current datetime. */
+/*
+ * 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/dl.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/datetime.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_DATETIME_SET_YEAR 1
+#define GRUB_DATETIME_SET_MONTH 2
+#define GRUB_DATETIME_SET_DAY 4
+#define GRUB_DATETIME_SET_HOUR 8
+#define GRUB_DATETIME_SET_MINUTE 16
+#define GRUB_DATETIME_SET_SECOND 32
+
+static grub_err_t
+grub_cmd_date (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_datetime datetime;
+ int limit[6][2] = {{1980, 2079}, {1, 12}, {1, 31}, {0, 23}, {0, 59}, {0, 59}};
+ int value[6], mask;
+
+ if (argc == 0)
+ {
+ if (grub_get_datetime (&datetime))
+ return grub_errno;
+
+ grub_printf ("%d-%02d-%02d %02d:%02d:%02d %s\n",
+ datetime.year, datetime.month, datetime.day,
+ datetime.hour, datetime.minute, datetime.second,
+ grub_get_weekday_name (&datetime));
+
+ return 0;
+ }
+
+ grub_memset (&value, 0, sizeof (value));
+ mask = 0;
+
+ for (; argc; argc--, args++)
+ {
+ const char *p;
+ char c;
+ int m1, ofs, n, cur_mask;
+
+ p = args[0];
+ m1 = grub_strtoul (p, &p, 10);
+
+ c = *p;
+ if (c == '-')
+ ofs = 0;
+ else if (c == ':')
+ ofs = 3;
+ else
+ goto fail;
+
+ value[ofs] = m1;
+ cur_mask = (1 << ofs);
+ mask &= ~(cur_mask * (1 + 2 + 4));
+
+ for (n = 1; (n < 3) && (*p); n++)
+ {
+ if (*p != c)
+ goto fail;
+
+ value[ofs + n] = grub_strtoul (p + 1, &p, 10);
+ cur_mask |= (1 << (ofs + n));
+ }
+
+ if (*p)
+ goto fail;
+
+ if ((ofs == 0) && (n == 2))
+ {
+ value[ofs + 2] = value[ofs + 1];
+ value[ofs + 1] = value[ofs];
+ ofs++;
+ cur_mask <<= 1;
+ }
+
+ for (; n; n--, ofs++)
+ if ((value [ofs] < limit[ofs][0]) ||
+ (value [ofs] > limit[ofs][1]))
+ goto fail;
+
+ mask |= cur_mask;
+ }
+
+ if (grub_get_datetime (&datetime))
+ return grub_errno;
+
+ if (mask & GRUB_DATETIME_SET_YEAR)
+ datetime.year = value[0];
+
+ if (mask & GRUB_DATETIME_SET_MONTH)
+ datetime.month = value[1];
+
+ if (mask & GRUB_DATETIME_SET_DAY)
+ datetime.day = value[2];
+
+ if (mask & GRUB_DATETIME_SET_HOUR)
+ datetime.hour = value[3];
+
+ if (mask & GRUB_DATETIME_SET_MINUTE)
+ datetime.minute = value[4];
+
+ if (mask & GRUB_DATETIME_SET_SECOND)
+ datetime.second = value[5];
+
+ return grub_set_datetime (&datetime);
+
+fail:
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid datetime");
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(date)
+{
+ cmd =
+ grub_register_command ("date", grub_cmd_date,
+ N_("[[year-]month-day] [hour:minute[:second]]"),
+ N_("Display/set current datetime."));
+}
+
+GRUB_MOD_FINI(date)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/echo.c b/grub-core/commands/echo.c
new file mode 100644
index 0000000..81ba50d
--- /dev/null
+++ b/grub-core/commands/echo.c
@@ -0,0 +1,141 @@
+/* echo.c - Command to display a line of text */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/term.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ {0, 'n', 0, N_("Do not output the trailing newline."), 0, 0},
+ {0, 'e', 0, N_("Enable interpretation of backslash escapes."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ int newline = 1;
+ int i;
+
+ /* Check if `-n' was used. */
+ if (state[0].set)
+ newline = 0;
+
+ for (i = 0; i < argc; i++)
+ {
+ char *arg = *args;
+ /* Unescaping results in a string no longer than the original. */
+ char *unescaped = grub_malloc (grub_strlen (arg) + 1);
+ char *p = unescaped;
+ args++;
+
+ if (!unescaped)
+ return grub_errno;
+
+ while (*arg)
+ {
+ /* In case `-e' is used, parse backslashes. */
+ if (*arg == '\\' && state[1].set)
+ {
+ arg++;
+ if (*arg == '\0')
+ break;
+
+ switch (*arg)
+ {
+ case '\\':
+ *p++ = '\\';
+ break;
+
+ case 'a':
+ *p++ = '\a';
+ break;
+
+ case 'c':
+ newline = 0;
+ break;
+
+ case 'f':
+ *p++ = '\f';
+ break;
+
+ case 'n':
+ *p++ = '\n';
+ break;
+
+ case 'r':
+ *p++ = '\r';
+ break;
+
+ case 't':
+ *p++ = '\t';
+ break;
+
+ case 'v':
+ *p++ = '\v';
+ break;
+ }
+ arg++;
+ continue;
+ }
+
+ /* This was not an escaped character, or escaping is not
+ enabled. */
+ *p++ = *arg;
+ arg++;
+ }
+
+ *p = '\0';
+ grub_xputs (unescaped);
+ grub_free (unescaped);
+
+ /* If another argument follows, insert a space. */
+ if (i != argc - 1)
+ grub_printf (" " );
+ }
+
+ if (newline)
+ grub_printf ("\n");
+
+ grub_refresh ();
+
+ return 0;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(echo)
+{
+ cmd = grub_register_extcmd ("echo", grub_cmd_echo,
+ GRUB_COMMAND_ACCEPT_DASH
+ | GRUB_COMMAND_OPTIONS_AT_START,
+ N_("[-e|-n] STRING"), N_("Display a line of text."),
+ options);
+}
+
+GRUB_MOD_FINI(echo)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/efi/efifwsetup.c b/grub-core/commands/efi/efifwsetup.c
new file mode 100644
index 0000000..eaca032
--- /dev/null
+++ b/grub-core/commands/efi/efifwsetup.c
@@ -0,0 +1,90 @@
+/* fwsetup.c - Reboot into firmware setup menu. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2012 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_efi_uint64_t *old_os_indications;
+ grub_efi_uint64_t os_indications = GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
+ grub_err_t status;
+ grub_size_t oi_size;
+ grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+
+ grub_efi_get_variable ("OsIndications", &global, &oi_size,
+ (void **) &old_os_indications);
+
+ if (old_os_indications != NULL && oi_size == sizeof (os_indications))
+ os_indications |= *old_os_indications;
+
+ status = grub_efi_set_variable ("OsIndications", &global, &os_indications,
+ sizeof (os_indications));
+ if (status != GRUB_ERR_NONE)
+ return status;
+
+ grub_reboot ();
+
+ return GRUB_ERR_BUG;
+}
+
+static grub_command_t cmd = NULL;
+
+static grub_efi_boolean_t
+efifwsetup_is_supported (void)
+{
+ grub_efi_uint64_t *os_indications_supported = NULL;
+ grub_size_t oi_size = 0;
+ grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+
+ grub_efi_get_variable ("OsIndicationsSupported", &global, &oi_size,
+ (void **) &os_indications_supported);
+
+ if (!os_indications_supported)
+ return 0;
+
+ if (*os_indications_supported & GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI)
+ return 1;
+
+ return 0;
+}
+
+GRUB_MOD_INIT (efifwsetup)
+{
+ if (efifwsetup_is_supported ())
+ cmd = grub_register_command ("fwsetup", grub_cmd_fwsetup, NULL,
+ N_("Reboot into firmware setup menu."));
+
+}
+
+GRUB_MOD_FINI (efifwsetup)
+{
+ if (cmd)
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/efi/fixvideo.c b/grub-core/commands/efi/fixvideo.c
new file mode 100644
index 0000000..d9d54a2
--- /dev/null
+++ b/grub-core/commands/efi/fixvideo.c
@@ -0,0 +1,114 @@
+/* fixvideo.c - fix video problem in efi */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/pci.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/mm.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct grub_video_patch
+{
+ const char *name;
+ grub_uint32_t pci_id;
+ grub_uint32_t mmio_bar;
+ grub_uint32_t mmio_reg;
+ grub_uint32_t mmio_old;
+} video_patches[] =
+ {
+ {"Intel 945GM", 0x27a28086, 0, 0x71184, 0x1000000}, /* DSPBBASE */
+ {"Intel 965GM", 0x2a028086, 0, 0x7119C, 0x1000000}, /* DSPBSURF */
+ {0, 0, 0, 0, 0}
+ };
+
+static int
+scan_card (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ grub_pci_address_t addr;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ if (grub_pci_read_byte (addr + 3) == 0x3)
+ {
+ struct grub_video_patch *p = video_patches;
+
+ while (p->name)
+ {
+ if (p->pci_id == pciid)
+ {
+ grub_addr_t base;
+
+ grub_dprintf ("fixvideo", "Found graphic card: %s\n", p->name);
+ addr += 8 + p->mmio_bar * 4;
+ base = grub_pci_read (addr);
+ if ((! base) || (base & GRUB_PCI_ADDR_SPACE_IO) ||
+ (base & GRUB_PCI_ADDR_MEM_PREFETCH))
+ grub_dprintf ("fixvideo", "Invalid MMIO bar %d\n", p->mmio_bar);
+ else
+ {
+ base &= GRUB_PCI_ADDR_MEM_MASK;
+ base += p->mmio_reg;
+
+ if (*((volatile grub_uint32_t *) base) != p->mmio_old)
+ grub_dprintf ("fixvideo", "Old value doesn't match\n");
+ else
+ {
+ *((volatile grub_uint32_t *) base) = 0;
+ if (*((volatile grub_uint32_t *) base))
+ grub_dprintf ("fixvideo", "Setting MMIO fails\n");
+ }
+ }
+
+ return 1;
+ }
+ p++;
+ }
+
+ grub_dprintf ("fixvideo", "Unknown graphic card: %x\n", pciid);
+ }
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_fixvideo (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ grub_pci_iterate (scan_card, NULL);
+ return 0;
+}
+
+static grub_command_t cmd_fixvideo;
+
+GRUB_MOD_INIT(fixvideo)
+{
+ cmd_fixvideo = grub_register_command ("fix_video", grub_cmd_fixvideo,
+ 0, N_("Fix video problem."));
+
+}
+
+GRUB_MOD_FINI(fixvideo)
+{
+ grub_unregister_command (cmd_fixvideo);
+}
diff --git a/grub-core/commands/efi/loadbios.c b/grub-core/commands/efi/loadbios.c
new file mode 100644
index 0000000..5c7725f
--- /dev/null
+++ b/grub-core/commands/efi/loadbios.c
@@ -0,0 +1,222 @@
+/* loadbios.c - command to load a bios dump */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/efi/efi.h>
+#include <grub/pci.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_efi_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
+static grub_efi_guid_t acpi2_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
+static grub_efi_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
+
+#define EBDA_SEG_ADDR 0x40e
+#define LOW_MEM_ADDR 0x413
+#define FAKE_EBDA_SEG 0x9fc0
+
+#define BLANK_MEM 0xffffffff
+#define VBIOS_ADDR 0xc0000
+#define SBIOS_ADDR 0xf0000
+
+static int
+enable_rom_area (void)
+{
+ grub_pci_address_t addr;
+ grub_uint32_t *rom_ptr;
+ grub_pci_device_t dev = { .bus = 0, .device = 0, .function = 0};
+
+ rom_ptr = (grub_uint32_t *) VBIOS_ADDR;
+ if (*rom_ptr != BLANK_MEM)
+ {
+ grub_puts_ (N_("ROM image is present."));
+ return 0;
+ }
+
+ /* FIXME: should be macroified. */
+ addr = grub_pci_make_address (dev, 144);
+ grub_pci_write_byte (addr++, 0x30);
+ grub_pci_write_byte (addr++, 0x33);
+ grub_pci_write_byte (addr++, 0x33);
+ grub_pci_write_byte (addr++, 0x33);
+ grub_pci_write_byte (addr++, 0x33);
+ grub_pci_write_byte (addr++, 0x33);
+ grub_pci_write_byte (addr++, 0x33);
+ grub_pci_write_byte (addr, 0);
+
+ *rom_ptr = 0;
+ if (*rom_ptr != 0)
+ {
+ grub_puts_ (N_("Can\'t enable ROM area."));
+ return 0;
+ }
+
+ return 1;
+}
+
+static void
+lock_rom_area (void)
+{
+ grub_pci_address_t addr;
+ grub_pci_device_t dev = { .bus = 0, .device = 0, .function = 0};
+
+ /* FIXME: should be macroified. */
+ addr = grub_pci_make_address (dev, 144);
+ grub_pci_write_byte (addr++, 0x10);
+ grub_pci_write_byte (addr++, 0x11);
+ grub_pci_write_byte (addr++, 0x11);
+ grub_pci_write_byte (addr++, 0x11);
+ grub_pci_write_byte (addr, 0x11);
+}
+
+static void
+fake_bios_data (int use_rom)
+{
+ unsigned i;
+ void *acpi, *smbios;
+ grub_uint16_t *ebda_seg_ptr, *low_mem_ptr;
+
+ ebda_seg_ptr = (grub_uint16_t *) EBDA_SEG_ADDR;
+ low_mem_ptr = (grub_uint16_t *) LOW_MEM_ADDR;
+ if ((*ebda_seg_ptr) || (*low_mem_ptr))
+ return;
+
+ acpi = 0;
+ smbios = 0;
+ for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
+ {
+ grub_efi_packed_guid_t *guid =
+ &grub_efi_system_table->configuration_table[i].vendor_guid;
+
+ if (! grub_memcmp (guid, &acpi2_guid, sizeof (grub_efi_guid_t)))
+ {
+ acpi = grub_efi_system_table->configuration_table[i].vendor_table;
+ grub_dprintf ("efi", "ACPI2: %p\n", acpi);
+ }
+ else if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_guid_t)))
+ {
+ void *t;
+
+ t = grub_efi_system_table->configuration_table[i].vendor_table;
+ if (! acpi)
+ acpi = t;
+ grub_dprintf ("efi", "ACPI: %p\n", t);
+ }
+ else if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_guid_t)))
+ {
+ smbios = grub_efi_system_table->configuration_table[i].vendor_table;
+ grub_dprintf ("efi", "SMBIOS: %p\n", smbios);
+ }
+ }
+
+ *ebda_seg_ptr = FAKE_EBDA_SEG;
+ *low_mem_ptr = (FAKE_EBDA_SEG >> 6);
+
+ *((grub_uint16_t *) (FAKE_EBDA_SEG << 4)) = 640 - *low_mem_ptr;
+
+ if (acpi)
+ grub_memcpy ((char *) ((FAKE_EBDA_SEG << 4) + 16), acpi, 1024 - 16);
+
+ if ((use_rom) && (smbios))
+ grub_memcpy ((char *) SBIOS_ADDR, (char *) smbios + 16, 16);
+}
+
+static grub_err_t
+grub_cmd_fakebios (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ if (enable_rom_area ())
+ {
+ fake_bios_data (1);
+ lock_rom_area ();
+ }
+ else
+ fake_bios_data (0);
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file;
+ int size;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if (argc > 1)
+ {
+ file = grub_file_open (argv[1], GRUB_FILE_TYPE_VBE_DUMP);
+ if (! file)
+ return grub_errno;
+
+ if (file->size != 4)
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid int10 dump size");
+ else
+ grub_file_read (file, (void *) 0x40, 4);
+
+ grub_file_close (file);
+ if (grub_errno)
+ return grub_errno;
+ }
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_VBE_DUMP);
+ if (! file)
+ return grub_errno;
+
+ size = file->size;
+ if ((size < 0x10000) || (size > 0x40000))
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid bios dump size");
+ else if (enable_rom_area ())
+ {
+ grub_file_read (file, (void *) VBIOS_ADDR, size);
+ fake_bios_data (size <= 0x40000);
+ lock_rom_area ();
+ }
+
+ grub_file_close (file);
+ return grub_errno;
+}
+
+static grub_command_t cmd_fakebios, cmd_loadbios;
+
+GRUB_MOD_INIT(loadbios)
+{
+ cmd_fakebios = grub_register_command_lockdown ("fakebios", grub_cmd_fakebios,
+ 0, N_("Create BIOS-like structures for"
+ " backward compatibility with"
+ " existing OS."));
+
+ cmd_loadbios = grub_register_command_lockdown ("loadbios", grub_cmd_loadbios,
+ N_("BIOS_DUMP [INT10_DUMP]"),
+ N_("Load BIOS dump."));
+}
+
+GRUB_MOD_FINI(loadbios)
+{
+ grub_unregister_command (cmd_fakebios);
+ grub_unregister_command (cmd_loadbios);
+}
diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c
new file mode 100644
index 0000000..d1ce99a
--- /dev/null
+++ b/grub-core/commands/efi/lsefi.c
@@ -0,0 +1,155 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2012 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/efi/api.h>
+#include <grub/efi/edid.h>
+#include <grub/efi/pci.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/uga_draw.h>
+#include <grub/efi/graphics_output.h>
+#include <grub/efi/console_control.h>
+#include <grub/command.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct known_protocol
+{
+ grub_efi_guid_t guid;
+ const char *name;
+} known_protocols[] =
+ {
+ { GRUB_EFI_DISK_IO_GUID, "disk" },
+ { GRUB_EFI_BLOCK_IO_GUID, "block" },
+ { GRUB_EFI_SERIAL_IO_GUID, "serial" },
+ { GRUB_EFI_SIMPLE_NETWORK_GUID, "network" },
+ { GRUB_EFI_PXE_GUID, "pxe" },
+ { GRUB_EFI_DEVICE_PATH_GUID, "device path" },
+ { GRUB_EFI_PCI_IO_GUID, "PCI" },
+ { GRUB_EFI_PCI_ROOT_IO_GUID, "PCI root" },
+ { GRUB_EFI_EDID_ACTIVE_GUID, "active EDID" },
+ { GRUB_EFI_EDID_DISCOVERED_GUID, "discovered EDID" },
+ { GRUB_EFI_EDID_OVERRIDE_GUID, "override EDID" },
+ { GRUB_EFI_GOP_GUID, "GOP" },
+ { GRUB_EFI_UGA_DRAW_GUID, "UGA draw" },
+ { GRUB_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID, "simple text output" },
+ { GRUB_EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID, "simple text input" },
+ { GRUB_EFI_SIMPLE_POINTER_PROTOCOL_GUID, "simple pointer" },
+ { GRUB_EFI_CONSOLE_CONTROL_GUID, "console control" },
+ { GRUB_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID, "absolute pointer" },
+ { GRUB_EFI_DRIVER_BINDING_PROTOCOL_GUID, "EFI driver binding" },
+ { GRUB_EFI_LOAD_FILE_PROTOCOL_GUID, "load file" },
+ { GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, "simple FS" },
+ { GRUB_EFI_TAPE_IO_PROTOCOL_GUID, "tape I/O" },
+ { GRUB_EFI_UNICODE_COLLATION_PROTOCOL_GUID, "unicode collation" },
+ { GRUB_EFI_SCSI_IO_PROTOCOL_GUID, "SCSI I/O" },
+ { GRUB_EFI_USB2_HC_PROTOCOL_GUID, "USB host" },
+ { GRUB_EFI_DEBUG_SUPPORT_PROTOCOL_GUID, "debug support" },
+ { GRUB_EFI_DEBUGPORT_PROTOCOL_GUID, "debug port" },
+ { GRUB_EFI_DECOMPRESS_PROTOCOL_GUID, "decompress" },
+ { GRUB_EFI_LOADED_IMAGE_PROTOCOL_GUID, "loaded image" },
+ { GRUB_EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID, "device path to text" },
+ { GRUB_EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID, "device path utilities" },
+ { GRUB_EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID, "device path from text" },
+ { GRUB_EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID, "HII config routing" },
+ { GRUB_EFI_HII_DATABASE_PROTOCOL_GUID, "HII database" },
+ { GRUB_EFI_HII_STRING_PROTOCOL_GUID, "HII string" },
+ { GRUB_EFI_HII_IMAGE_PROTOCOL_GUID, "HII image" },
+ { GRUB_EFI_HII_FONT_PROTOCOL_GUID, "HII font" },
+ { GRUB_EFI_COMPONENT_NAME2_PROTOCOL_GUID, "component name 2" },
+ { GRUB_EFI_HII_CONFIGURATION_ACCESS_PROTOCOL_GUID,
+ "HII configuration access" },
+ { GRUB_EFI_USB_IO_PROTOCOL_GUID, "USB I/O" },
+ };
+
+static grub_err_t
+grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_efi_handle_t *handles;
+ grub_efi_uintn_t num_handles;
+ unsigned i, j, k;
+
+ handles = grub_efi_locate_handle (GRUB_EFI_ALL_HANDLES,
+ NULL, NULL, &num_handles);
+
+ for (i = 0; i < num_handles; i++)
+ {
+ grub_efi_handle_t handle = handles[i];
+ grub_efi_status_t status;
+ grub_efi_uintn_t num_protocols;
+ grub_efi_packed_guid_t **protocols;
+ grub_efi_device_path_t *dp;
+
+ grub_printf ("Handle %p\n", handle);
+
+ dp = grub_efi_get_device_path (handle);
+ if (dp)
+ {
+ grub_printf (" ");
+ grub_efi_print_device_path (dp);
+ }
+
+ status = efi_call_3 (grub_efi_system_table->boot_services->protocols_per_handle,
+ handle, &protocols, &num_protocols);
+ if (status != GRUB_EFI_SUCCESS) {
+ grub_printf ("Unable to retrieve protocols\n");
+ continue;
+ }
+ for (j = 0; j < num_protocols; j++)
+ {
+ for (k = 0; k < ARRAY_SIZE (known_protocols); k++)
+ if (grub_memcmp (protocols[j], &known_protocols[k].guid,
+ sizeof (known_protocols[k].guid)) == 0)
+ break;
+ if (k < ARRAY_SIZE (known_protocols))
+ grub_printf (" %s\n", known_protocols[k].name);
+ else
+ grub_printf (" %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
+ protocols[j]->data1,
+ protocols[j]->data2,
+ protocols[j]->data3,
+ (unsigned) protocols[j]->data4[0],
+ (unsigned) protocols[j]->data4[1],
+ (unsigned) protocols[j]->data4[2],
+ (unsigned) protocols[j]->data4[3],
+ (unsigned) protocols[j]->data4[4],
+ (unsigned) protocols[j]->data4[5],
+ (unsigned) protocols[j]->data4[6],
+ (unsigned) protocols[j]->data4[7]);
+ }
+
+ }
+
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lsefi)
+{
+ cmd = grub_register_command ("lsefi", grub_cmd_lsefi,
+ NULL, "Display EFI handles.");
+}
+
+GRUB_MOD_FINI(lsefi)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/efi/lsefimmap.c b/grub-core/commands/efi/lsefimmap.c
new file mode 100644
index 0000000..c85ff7f
--- /dev/null
+++ b/grub-core/commands/efi/lsefimmap.c
@@ -0,0 +1,160 @@
+/* lsefimemmap.c - Display memory map. */
+/*
+ * 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/mm.h>
+#include <grub/misc.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/command.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define ADD_MEMORY_DESCRIPTOR(desc, size) \
+ ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
+
+static grub_err_t
+grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_efi_uintn_t map_size;
+ grub_efi_memory_descriptor_t *memory_map;
+ grub_efi_memory_descriptor_t *memory_map_end;
+ grub_efi_memory_descriptor_t *desc;
+ grub_efi_uintn_t desc_size;
+
+ map_size = 0;
+ if (grub_efi_get_memory_map (&map_size, NULL, NULL, &desc_size, 0) < 0)
+ return 0;
+
+ memory_map = grub_malloc (map_size);
+ if (memory_map == NULL)
+ return grub_errno;
+ if (grub_efi_get_memory_map (&map_size, memory_map, NULL, &desc_size, 0) <= 0)
+ goto fail;
+
+ grub_printf
+ ("Type Physical start - end #Pages "
+ " Size Attributes\n");
+ memory_map_end = ADD_MEMORY_DESCRIPTOR (memory_map, map_size);
+ for (desc = memory_map;
+ desc < memory_map_end;
+ desc = ADD_MEMORY_DESCRIPTOR (desc, desc_size))
+ {
+ grub_efi_uint64_t size;
+ grub_efi_uint64_t attr;
+ static const char types_str[][9] =
+ {
+ "reserved",
+ "ldr-code",
+ "ldr-data",
+ "BS-code ",
+ "BS-data ",
+ "RT-code ",
+ "RT-data ",
+ "conv-mem",
+ "unusable",
+ "ACPI-rec",
+ "ACPI-nvs",
+ "MMIO ",
+ "IO-ports",
+ "PAL-code",
+ "persist ",
+ };
+ if (desc->type < ARRAY_SIZE (types_str))
+ grub_printf ("%s ", types_str[desc->type]);
+ else
+ grub_printf ("Unk %02x ", desc->type);
+
+ grub_printf (" %016" PRIxGRUB_UINT64_T "-%016" PRIxGRUB_UINT64_T
+ " %08" PRIxGRUB_UINT64_T,
+ desc->physical_start,
+ desc->physical_start + (desc->num_pages << 12) - 1,
+ desc->num_pages);
+
+ 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
+ grub_printf (" %6" PRIuGRUB_UINT64_T "EiB", size >> 60);
+
+ attr = desc->attribute;
+ if (attr & GRUB_EFI_MEMORY_RUNTIME)
+ grub_printf (" RT");
+ if (attr & GRUB_EFI_MEMORY_UC)
+ grub_printf (" UC");
+ if (attr & GRUB_EFI_MEMORY_WC)
+ grub_printf (" WC");
+ if (attr & GRUB_EFI_MEMORY_WT)
+ grub_printf (" WT");
+ if (attr & GRUB_EFI_MEMORY_WB)
+ grub_printf (" WB");
+ if (attr & GRUB_EFI_MEMORY_UCE)
+ grub_printf (" UCE");
+ if (attr & GRUB_EFI_MEMORY_WP)
+ grub_printf (" WP");
+ if (attr & GRUB_EFI_MEMORY_RP)
+ 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");
+ }
+
+ fail:
+ grub_free (memory_map);
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lsefimmap)
+{
+ cmd = grub_register_command ("lsefimmap", grub_cmd_lsefimmap,
+ "", "Display EFI memory map.");
+}
+
+GRUB_MOD_FINI(lsefimmap)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c
new file mode 100644
index 0000000..456198e
--- /dev/null
+++ b/grub-core/commands/efi/lsefisystab.c
@@ -0,0 +1,125 @@
+/* lsefisystab.c - Display EFI systab. */
+/*
+ * 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/mm.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/normal.h>
+#include <grub/charset.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct guid_mapping
+{
+ grub_efi_guid_t guid;
+ const char *name;
+};
+
+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_DEVICE_TREE_GUID, "DEVICE TREE"},
+ { 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_RT_PROPERTIES_TABLE_GUID, "RT PROPERTIES"},
+ { GRUB_EFI_SAL_TABLE_GUID, "SAL"},
+ { GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
+ { GRUB_EFI_SMBIOS3_TABLE_GUID, "SMBIOS3"},
+ { 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
+grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ const grub_efi_system_table_t *st = grub_efi_system_table;
+ 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);
+ {
+ char *vendor;
+ grub_uint16_t *vendor_utf16;
+ grub_printf ("Vendor: ");
+
+ for (vendor_utf16 = st->firmware_vendor; *vendor_utf16; vendor_utf16++);
+ /* Allocate extra 3 bytes to simplify math. */
+ vendor = grub_calloc (4, vendor_utf16 - st->firmware_vendor + 1);
+ if (!vendor)
+ return grub_errno;
+ *grub_utf16_to_utf8 ((grub_uint8_t *) vendor, st->firmware_vendor,
+ vendor_utf16 - st->firmware_vendor) = 0;
+ grub_printf ("%s", vendor);
+ grub_free (vendor);
+ }
+
+ grub_printf (", Version=%x\n", st->firmware_revision);
+
+ grub_printf ("%lld tables:\n", (long long) st->num_table_entries);
+ t = st->configuration_table;
+ for (i = 0; i < st->num_table_entries; i++)
+ {
+ unsigned int j;
+
+ grub_printf ("%p ", t->vendor_table);
+
+ grub_printf ("%08x-%04x-%04x-",
+ t->vendor_guid.data1, t->vendor_guid.data2,
+ t->vendor_guid.data3);
+ for (j = 0; j < 8; j++)
+ grub_printf ("%02x", t->vendor_guid.data4[j]);
+
+ for (j = 0; j < ARRAY_SIZE (guid_mappings); j++)
+ if (grub_memcmp (&guid_mappings[j].guid, &t->vendor_guid,
+ sizeof (grub_efi_guid_t)) == 0)
+ grub_printf (" %s", guid_mappings[j].name);
+
+ grub_printf ("\n");
+ t++;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lsefisystab)
+{
+ cmd = grub_register_command ("lsefisystab", grub_cmd_lsefisystab,
+ "", "Display EFI system tables.");
+}
+
+GRUB_MOD_FINI(lsefisystab)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/efi/lssal.c b/grub-core/commands/efi/lssal.c
new file mode 100644
index 0000000..5084ddd
--- /dev/null
+++ b/grub-core/commands/efi/lssal.c
@@ -0,0 +1,169 @@
+/* lssal.c - Display EFI SAL systab. */
+/*
+ * 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/mm.h>
+#include <grub/misc.h>
+#include <grub/normal.h>
+#include <grub/charset.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static void
+disp_sal (void *table)
+{
+ struct grub_efi_sal_system_table *t = table;
+ void *desc;
+ grub_uint32_t len, l, i;
+
+ grub_printf ("SAL rev: %02x, signature: %x, len:%x\n",
+ t->sal_rev, t->signature, t->total_table_len);
+ grub_printf ("nbr entry: %d, chksum: %02x, SAL version A: %02x B: %02x\n",
+ t->entry_count, t->checksum,
+ t->sal_a_version, t->sal_b_version);
+ grub_printf ("OEM-ID: %-32s\n", t->oem_id);
+ grub_printf ("Product-ID: %-32s\n", t->product_id);
+
+ desc = t->entries;
+ len = t->total_table_len - sizeof (struct grub_efi_sal_system_table);
+ if (t->total_table_len <= sizeof (struct grub_efi_sal_system_table))
+ return;
+ for (i = 0; i < t->entry_count; i++)
+ {
+ switch (*(grub_uint8_t *) desc)
+ {
+ case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR:
+ {
+ struct grub_efi_sal_system_table_entrypoint_descriptor *c = desc;
+ l = sizeof (*c);
+ grub_printf (" Entry point: PAL=%016" PRIxGRUB_UINT64_T
+ " SAL=%016" PRIxGRUB_UINT64_T " GP=%016"
+ PRIxGRUB_UINT64_T "\n",
+ c->pal_proc_addr, c->sal_proc_addr,
+ c->global_data_ptr);
+ }
+ break;
+ case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR:
+ {
+ struct grub_efi_sal_system_table_memory_descriptor *c = desc;
+ l = sizeof (*c);
+ grub_printf (" Memory descriptor entry addr=%016" PRIxGRUB_UINT64_T
+ " len=%" PRIuGRUB_UINT64_T "KB\n",
+ c->addr, c->len * 4);
+ grub_printf (" sal_used=%d attr=%x AR=%x attr_mask=%x "
+ "type=%x usage=%x\n",
+ c->sal_used, c->attr, c->ar, c->attr_mask, c->mem_type,
+ c->usage);
+ }
+ break;
+ case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES:
+ {
+ struct grub_efi_sal_system_table_platform_features *c = desc;
+ l = sizeof (*c);
+ grub_printf (" Platform features: %02x", c->flags);
+ if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK)
+ grub_printf (" BusLock");
+ if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT)
+ grub_printf (" IrqRedirect");
+ if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT)
+
+ grub_printf (" IPIRedirect");
+ if (c->flags & GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT)
+
+ grub_printf (" ITCDrift");
+ grub_printf ("\n");
+ }
+ break;
+ case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR:
+ {
+ struct grub_efi_sal_system_table_translation_register_descriptor *c
+ = desc;
+ l = sizeof (*c);
+ grub_printf (" TR type=%d num=%d va=%016" PRIxGRUB_UINT64_T
+ " pte=%016" PRIxGRUB_UINT64_T "\n",
+ c->register_type, c->register_number,
+ c->addr, c->page_size);
+ }
+ break;
+ case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE:
+ {
+ struct grub_efi_sal_system_table_purge_translation_coherence *c
+ = desc;
+ l = sizeof (*c);
+ grub_printf (" PTC coherence nbr=%d addr=%016" PRIxGRUB_UINT64_T "\n",
+ c->ndomains, c->coherence);
+ }
+ break;
+ case GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP:
+ {
+ struct grub_efi_sal_system_table_ap_wakeup *c = desc;
+ l = sizeof (*c);
+ grub_printf (" AP wake-up: mec=%d vect=%" PRIxGRUB_UINT64_T "\n",
+ c->mechanism, c->vector);
+ }
+ break;
+ default:
+ grub_printf (" unknown entry 0x%x\n", *(grub_uint8_t *)desc);
+ return;
+ }
+ desc = (grub_uint8_t *)desc + l;
+ if (len <= l)
+ return;
+ len -= l;
+ }
+}
+
+static grub_err_t
+grub_cmd_lssal (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ const grub_efi_system_table_t *st = grub_efi_system_table;
+ grub_efi_configuration_table_t *t = st->configuration_table;
+ unsigned int i;
+ grub_efi_packed_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
+
+ for (i = 0; i < st->num_table_entries; i++)
+ {
+ if (grub_memcmp (&guid, &t->vendor_guid,
+ sizeof (grub_efi_packed_guid_t)) == 0)
+ {
+ disp_sal (t->vendor_table);
+ return GRUB_ERR_NONE;
+ }
+ t++;
+ }
+ grub_printf ("SAL not found\n");
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lssal)
+{
+ cmd = grub_register_command ("lssal", grub_cmd_lssal, "",
+ "Display SAL system table.");
+}
+
+GRUB_MOD_FINI(lssal)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/efi/smbios.c b/grub-core/commands/efi/smbios.c
new file mode 100644
index 0000000..75202d5
--- /dev/null
+++ b/grub-core/commands/efi/smbios.c
@@ -0,0 +1,61 @@
+/* smbios.c - get smbios tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2019 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/smbios.h>
+#include <grub/misc.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/api.h>
+
+struct grub_smbios_eps *
+grub_machine_smbios_get_eps (void)
+{
+ unsigned i;
+ static grub_efi_packed_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
+
+ for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
+ {
+ grub_efi_packed_guid_t *guid =
+ &grub_efi_system_table->configuration_table[i].vendor_guid;
+
+ if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_packed_guid_t)))
+ return (struct grub_smbios_eps *)
+ grub_efi_system_table->configuration_table[i].vendor_table;
+ }
+
+ return 0;
+}
+
+struct grub_smbios_eps3 *
+grub_machine_smbios_get_eps3 (void)
+{
+ unsigned i;
+ static grub_efi_packed_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
+
+ for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
+ {
+ grub_efi_packed_guid_t *guid =
+ &grub_efi_system_table->configuration_table[i].vendor_guid;
+
+ if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_efi_packed_guid_t)))
+ return (struct grub_smbios_eps3 *)
+ grub_efi_system_table->configuration_table[i].vendor_table;
+ }
+
+ return 0;
+}
diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
new file mode 100644
index 0000000..a97d853
--- /dev/null
+++ b/grub-core/commands/efi/tpm.c
@@ -0,0 +1,241 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * EFI TPM support code.
+ */
+
+#include <grub/err.h>
+#include <grub/i18n.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/tpm.h>
+#include <grub/mm.h>
+#include <grub/tpm.h>
+#include <grub/term.h>
+
+typedef TCG_PCR_EVENT grub_tpm_event_t;
+
+static grub_efi_guid_t tpm_guid = EFI_TPM_GUID;
+static grub_efi_guid_t tpm2_guid = EFI_TPM2_GUID;
+
+static grub_efi_handle_t *grub_tpm_handle;
+static grub_uint8_t grub_tpm_version;
+
+static grub_int8_t tpm1_present = -1;
+static grub_int8_t tpm2_present = -1;
+
+static grub_efi_boolean_t
+grub_tpm1_present (grub_efi_tpm_protocol_t *tpm)
+{
+ grub_efi_status_t status;
+ TCG_EFI_BOOT_SERVICE_CAPABILITY caps;
+ grub_uint32_t flags;
+ grub_efi_physical_address_t eventlog, lastevent;
+
+ if (tpm1_present != -1)
+ return (grub_efi_boolean_t) tpm1_present;
+
+ caps.Size = (grub_uint8_t) sizeof (caps);
+
+ status = efi_call_5 (tpm->status_check, tpm, &caps, &flags, &eventlog,
+ &lastevent);
+
+ if (status != GRUB_EFI_SUCCESS || caps.TPMDeactivatedFlag
+ || !caps.TPMPresentFlag)
+ tpm1_present = 0;
+ else
+ tpm1_present = 1;
+
+ grub_dprintf ("tpm", "tpm1%s present\n", tpm1_present ? "" : " NOT");
+
+ return (grub_efi_boolean_t) tpm1_present;
+}
+
+static grub_efi_boolean_t
+grub_tpm2_present (grub_efi_tpm2_protocol_t *tpm)
+{
+ grub_efi_status_t status;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY caps;
+
+ caps.Size = (grub_uint8_t) sizeof (caps);
+
+ if (tpm2_present != -1)
+ return (grub_efi_boolean_t) tpm2_present;
+
+ status = efi_call_2 (tpm->get_capability, tpm, &caps);
+
+ if (status != GRUB_EFI_SUCCESS || !caps.TPMPresentFlag)
+ tpm2_present = 0;
+ else
+ tpm2_present = 1;
+
+ grub_dprintf ("tpm", "tpm2%s present\n", tpm2_present ? "" : " NOT");
+
+ return (grub_efi_boolean_t) tpm2_present;
+}
+
+static grub_efi_boolean_t
+grub_tpm_handle_find (grub_efi_handle_t *tpm_handle,
+ grub_efi_uint8_t *protocol_version)
+{
+ grub_efi_handle_t *handles;
+ grub_efi_uintn_t num_handles;
+
+ if (grub_tpm_handle != NULL)
+ {
+ *tpm_handle = grub_tpm_handle;
+ *protocol_version = grub_tpm_version;
+ return 1;
+ }
+
+ handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &tpm_guid, NULL,
+ &num_handles);
+ if (handles && num_handles > 0)
+ {
+ grub_tpm_handle = handles[0];
+ *tpm_handle = handles[0];
+ grub_tpm_version = 1;
+ *protocol_version = 1;
+ grub_dprintf ("tpm", "TPM handle Found, version: 1\n");
+ return 1;
+ }
+
+ handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &tpm2_guid, NULL,
+ &num_handles);
+ if (handles && num_handles > 0)
+ {
+ grub_tpm_handle = handles[0];
+ *tpm_handle = handles[0];
+ grub_tpm_version = 2;
+ *protocol_version = 2;
+ grub_dprintf ("tpm", "TPM handle Found, version: 2\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+static grub_err_t
+grub_efi_log_event_status (grub_efi_status_t status)
+{
+ switch (status)
+ {
+ case GRUB_EFI_SUCCESS:
+ return 0;
+ case GRUB_EFI_DEVICE_ERROR:
+ return grub_error (GRUB_ERR_IO, N_("Command failed"));
+ case GRUB_EFI_INVALID_PARAMETER:
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter"));
+ case GRUB_EFI_BUFFER_TOO_SMALL:
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Output buffer too small"));
+ case GRUB_EFI_NOT_FOUND:
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable"));
+ default:
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error"));
+ }
+}
+
+static grub_err_t
+grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
+ grub_size_t size, grub_uint8_t pcr,
+ const char *description)
+{
+ grub_tpm_event_t *event;
+ grub_efi_status_t status;
+ grub_efi_tpm_protocol_t *tpm;
+ grub_efi_physical_address_t lastevent;
+ grub_uint32_t algorithm;
+ grub_uint32_t eventnum = 0;
+
+ tpm = grub_efi_open_protocol (tpm_handle, &tpm_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+
+ if (!grub_tpm1_present (tpm))
+ return 0;
+
+ event = grub_zalloc (sizeof (*event) + grub_strlen (description) + 1);
+ if (!event)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ N_("cannot allocate TPM event buffer"));
+
+ event->PCRIndex = pcr;
+ event->EventType = EV_IPL;
+ event->EventSize = grub_strlen (description) + 1;
+ grub_memcpy (event->Event, description, event->EventSize);
+
+ algorithm = TCG_ALG_SHA;
+ status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size,
+ algorithm, event, &eventnum, &lastevent);
+ grub_free (event);
+
+ return grub_efi_log_event_status (status);
+}
+
+static grub_err_t
+grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
+ grub_size_t size, grub_uint8_t pcr,
+ const char *description)
+{
+ EFI_TCG2_EVENT *event;
+ grub_efi_status_t status;
+ grub_efi_tpm2_protocol_t *tpm;
+
+ tpm = grub_efi_open_protocol (tpm_handle, &tpm2_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+
+ if (!grub_tpm2_present (tpm))
+ return 0;
+
+ event =
+ grub_zalloc (sizeof (EFI_TCG2_EVENT) + grub_strlen (description) + 1);
+ if (!event)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ N_("cannot allocate TPM event buffer"));
+
+ event->Header.HeaderSize = sizeof (EFI_TCG2_EVENT_HEADER);
+ event->Header.HeaderVersion = 1;
+ event->Header.PCRIndex = pcr;
+ event->Header.EventType = EV_IPL;
+ event->Size =
+ sizeof (*event) - sizeof (event->Event) + grub_strlen (description) + 1;
+ grub_memcpy (event->Event, description, grub_strlen (description) + 1);
+
+ status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf,
+ (grub_uint64_t) size, event);
+ grub_free (event);
+
+ return grub_efi_log_event_status (status);
+}
+
+grub_err_t
+grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr,
+ const char *description)
+{
+ grub_efi_handle_t tpm_handle;
+ grub_efi_uint8_t protocol_version;
+
+ if (!grub_tpm_handle_find (&tpm_handle, &protocol_version))
+ return 0;
+
+ grub_dprintf ("tpm", "log_event, pcr = %d, size = 0x%" PRIxGRUB_SIZE ", %s\n",
+ pcr, size, description);
+
+ if (protocol_version == 1)
+ return grub_tpm1_log_event (tpm_handle, buf, size, pcr, description);
+ else
+ return grub_tpm2_log_event (tpm_handle, buf, size, pcr, description);
+}
diff --git a/grub-core/commands/eval.c b/grub-core/commands/eval.c
new file mode 100644
index 0000000..f826a4f
--- /dev/null
+++ b/grub-core/commands/eval.c
@@ -0,0 +1,71 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/script_sh.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/term.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_eval (grub_command_t cmd __attribute__((__unused__)),
+ int argc, char *argv[])
+{
+ int i;
+ grub_size_t size = argc; /* +1 for final zero */
+ char *str, *p;
+ grub_err_t ret;
+
+ if (argc == 0)
+ return GRUB_ERR_NONE;
+
+ for (i = 0; i < argc; i++)
+ size += grub_strlen (argv[i]);
+
+ str = p = grub_malloc (size);
+ if (!str)
+ return grub_errno;
+
+ for (i = 0; i < argc; i++)
+ {
+ p = grub_stpcpy (p, argv[i]);
+ *p++ = ' ';
+ }
+ *--p = '\0';
+
+ ret = grub_script_execute_sourcecode (str);
+ grub_free (str);
+ return ret;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(eval)
+{
+ cmd = grub_register_command ("eval", grub_cmd_eval, N_("STRING ..."),
+ N_("Evaluate arguments as GRUB commands"));
+}
+
+GRUB_MOD_FINI(eval)
+{
+ grub_unregister_command (cmd);
+}
+
diff --git a/grub-core/commands/extcmd.c b/grub-core/commands/extcmd.c
new file mode 100644
index 0000000..90a5ca2
--- /dev/null
+++ b/grub-core/commands/extcmd.c
@@ -0,0 +1,141 @@
+/* extcmd.c - support extended command */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/list.h>
+#include <grub/lockdown.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/script_sh.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+grub_err_t
+grub_extcmd_dispatcher (struct grub_command *cmd, int argc, char **args,
+ struct grub_script *script)
+{
+ int new_argc;
+ char **new_args;
+ struct grub_arg_list *state;
+ struct grub_extcmd_context context;
+ grub_err_t ret;
+ grub_extcmd_t ext = cmd->data;
+
+ context.state = 0;
+ context.extcmd = ext;
+ context.script = script;
+
+ if (! ext->options)
+ {
+ ret = (ext->func) (&context, argc, args);
+ return ret;
+ }
+
+ state = grub_arg_list_alloc (ext, argc, args);
+ if (grub_arg_parse (ext, argc, args, state, &new_args, &new_argc))
+ {
+ context.state = state;
+ ret = (ext->func) (&context, new_argc, new_args);
+ grub_free (new_args);
+ grub_free (state);
+ return ret;
+ }
+
+ grub_free (state);
+ return grub_errno;
+}
+
+static grub_err_t
+grub_extcmd_dispatch (struct grub_command *cmd, int argc, char **args)
+{
+ return grub_extcmd_dispatcher (cmd, argc, args, 0);
+}
+
+grub_extcmd_t
+grub_register_extcmd_prio (const char *name, grub_extcmd_func_t func,
+ grub_command_flags_t flags, const char *summary,
+ const char *description,
+ const struct grub_arg_option *parser,
+ int prio)
+{
+ grub_extcmd_t ext;
+ grub_command_t cmd;
+
+ ext = (grub_extcmd_t) grub_malloc (sizeof (*ext));
+ if (! ext)
+ return 0;
+
+ cmd = grub_register_command_prio (name, grub_extcmd_dispatch,
+ summary, description, prio);
+ if (! cmd)
+ {
+ grub_free (ext);
+ return 0;
+ }
+
+ cmd->flags = (flags | GRUB_COMMAND_FLAG_EXTCMD);
+ cmd->data = ext;
+
+ ext->cmd = cmd;
+ ext->func = func;
+ ext->options = parser;
+ ext->data = 0;
+
+ return ext;
+}
+
+grub_extcmd_t
+grub_register_extcmd (const char *name, grub_extcmd_func_t func,
+ grub_command_flags_t flags, const char *summary,
+ const char *description,
+ const struct grub_arg_option *parser)
+{
+ return grub_register_extcmd_prio (name, func, flags,
+ summary, description, parser, 1);
+}
+
+static grub_err_t
+grub_extcmd_lockdown (grub_extcmd_context_t ctxt __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **argv __attribute__ ((unused)))
+{
+ return grub_error (GRUB_ERR_ACCESS_DENIED,
+ N_("%s: the command is not allowed when lockdown is enforced"),
+ ctxt->extcmd->cmd->name);
+}
+
+grub_extcmd_t
+grub_register_extcmd_lockdown (const char *name, grub_extcmd_func_t func,
+ grub_command_flags_t flags, const char *summary,
+ const char *description,
+ const struct grub_arg_option *parser)
+{
+ if (grub_is_lockdown () == GRUB_LOCKDOWN_ENABLED)
+ func = grub_extcmd_lockdown;
+
+ return grub_register_extcmd (name, func, flags, summary, description, parser);
+}
+
+void
+grub_unregister_extcmd (grub_extcmd_t ext)
+{
+ grub_unregister_command (ext->cmd);
+ grub_free (ext);
+}
diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
new file mode 100644
index 0000000..9de0006
--- /dev/null
+++ b/grub-core/commands/file.c
@@ -0,0 +1,694 @@
+/*
+ * 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/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/command.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/file.h>
+#include <grub/elf.h>
+#include <grub/xen_file.h>
+#include <grub/efi/pe32.h>
+#include <grub/arm/linux.h>
+#include <grub/arm64/linux.h>
+#include <grub/i386/linux.h>
+#include <grub/xnu.h>
+#include <grub/machoload.h>
+#include <grub/fileid.h>
+
+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 unprivileged guest kernel"),
+ 0, 0},
+ {"is-x86_64-xen-domu", 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 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},
+ {"is-arm64-linux", 0, 0,
+ N_("Check if FILE is ARM64 Linux"), 0, 0},
+ {"is-ia64-linux", 0, 0,
+ N_("Check if FILE is IA64 Linux"), 0, 0},
+ {"is-mips-linux", 0, 0,
+ N_("Check if FILE is MIPS Linux"), 0, 0},
+ {"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},
+ {"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},
+ {"is-x86-linux32", 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},
+ {"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},
+
+ {"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},
+ {"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},
+ {"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-riscv32-efi", 0, 0,
+ N_("Check if FILE is RISC-V 32bit EFI file"), 0, 0},
+ {"is-riscv64-efi", 0, 0,
+ N_("Check if FILE is RISC-V 64bit 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},
+ {"is-i386-xnu", 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},
+ {"is-x86-bios-bootsector", 0, 0,
+ N_("Check if FILE is BIOS bootsector"), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+};
+
+enum
+{
+ IS_PAE_DOMU,
+ IS_64_DOMU,
+ IS_DOM0,
+ IS_MULTIBOOT,
+ IS_MULTIBOOT2,
+ IS_ARM_LINUX,
+ IS_ARM64_LINUX,
+ IS_IA64_LINUX,
+ IS_MIPS_LINUX,
+ IS_MIPSEL_LINUX,
+ IS_SPARC64_LINUX,
+ IS_POWERPC_LINUX,
+ IS_X86_LINUX,
+ IS_X86_LINUX32,
+ IS_X86_KFREEBSD,
+ IS_X86_KFREEBSD32,
+ IS_X86_KFREEBSD64,
+ IS_X86_KNETBSD,
+ IS_X86_KNETBSD32,
+ IS_X86_KNETBSD64,
+ IS_32_EFI,
+ IS_64_EFI,
+ IS_IA_EFI,
+ IS_ARM64_EFI,
+ IS_ARM_EFI,
+ IS_RISCV32_EFI,
+ IS_RISCV64_EFI,
+ IS_HIBERNATED,
+ IS_XNU64,
+ IS_XNU32,
+ IS_XNU_HIBR,
+ IS_BIOS_BOOTSECTOR,
+ OPT_TYPE_MIN = IS_PAE_DOMU,
+ OPT_TYPE_MAX = IS_BIOS_BOOTSECTOR
+};
+
+
+static grub_err_t
+grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ grub_file_t file = 0;
+ grub_elf_t elf = 0;
+ grub_err_t err;
+ int type = -1, i;
+ int ret = 0;
+ grub_macho_t macho = 0;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ for (i = OPT_TYPE_MIN; i <= OPT_TYPE_MAX; i++)
+ if (ctxt->state[i].set)
+ {
+ if (type == -1)
+ {
+ type = i;
+ continue;
+ }
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "multiple types specified");
+ }
+ if (type == -1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no type specified");
+
+ file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL);
+ if (!file)
+ return grub_errno;
+ switch (type)
+ {
+ case IS_BIOS_BOOTSECTOR:
+ {
+ grub_uint16_t sig;
+ if (grub_file_size (file) != 512)
+ break;
+ if (grub_file_seek (file, 510) == (grub_size_t) -1)
+ break;
+ if (grub_file_read (file, &sig, 2) != 2)
+ break;
+ if (sig != grub_cpu_to_le16_compile_time (0xaa55))
+ break;
+ ret = 1;
+ break;
+ }
+ case IS_IA64_LINUX:
+ {
+ Elf64_Ehdr ehdr;
+
+ if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
+ break;
+
+ if (ehdr.e_ident[EI_MAG0] != ELFMAG0
+ || ehdr.e_ident[EI_MAG1] != ELFMAG1
+ || ehdr.e_ident[EI_MAG2] != ELFMAG2
+ || ehdr.e_ident[EI_MAG3] != ELFMAG3
+ || ehdr.e_ident[EI_VERSION] != EV_CURRENT
+ || ehdr.e_version != EV_CURRENT)
+ break;
+
+ if (ehdr.e_ident[EI_CLASS] != ELFCLASS64
+ || ehdr.e_ident[EI_DATA] != ELFDATA2LSB
+ || ehdr.e_machine != grub_cpu_to_le16_compile_time (EM_IA_64))
+ break;
+
+ ret = 1;
+
+ break;
+ }
+
+ case IS_SPARC64_LINUX:
+ {
+ Elf64_Ehdr ehdr;
+
+ if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
+ break;
+
+ if (ehdr.e_ident[EI_MAG0] != ELFMAG0
+ || ehdr.e_ident[EI_MAG1] != ELFMAG1
+ || ehdr.e_ident[EI_MAG2] != ELFMAG2
+ || ehdr.e_ident[EI_MAG3] != ELFMAG3
+ || ehdr.e_ident[EI_VERSION] != EV_CURRENT
+ || ehdr.e_version != EV_CURRENT)
+ break;
+
+ if (ehdr.e_ident[EI_CLASS] != ELFCLASS64
+ || ehdr.e_ident[EI_DATA] != ELFDATA2MSB)
+ break;
+
+ if (ehdr.e_machine != grub_cpu_to_le16_compile_time (EM_SPARCV9)
+ || ehdr.e_type != grub_cpu_to_be16_compile_time (ET_EXEC))
+ break;
+
+ ret = 1;
+
+ break;
+ }
+
+ case IS_POWERPC_LINUX:
+ {
+ Elf32_Ehdr ehdr;
+
+ if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
+ break;
+
+ if (ehdr.e_ident[EI_MAG0] != ELFMAG0
+ || ehdr.e_ident[EI_MAG1] != ELFMAG1
+ || ehdr.e_ident[EI_MAG2] != ELFMAG2
+ || ehdr.e_ident[EI_MAG3] != ELFMAG3
+ || ehdr.e_ident[EI_VERSION] != EV_CURRENT
+ || ehdr.e_version != EV_CURRENT)
+ break;
+
+ if (ehdr.e_ident[EI_DATA] != ELFDATA2MSB
+ || (ehdr.e_machine != grub_cpu_to_le16_compile_time (EM_PPC)
+ && ehdr.e_machine !=
+ grub_cpu_to_le16_compile_time (EM_PPC64)))
+ break;
+
+ if (ehdr.e_type != grub_cpu_to_be16_compile_time (ET_EXEC)
+ && ehdr.e_type != grub_cpu_to_be16_compile_time (ET_DYN))
+ break;
+
+ ret = 1;
+
+ break;
+ }
+
+ case IS_MIPS_LINUX:
+ {
+ Elf32_Ehdr ehdr;
+
+ if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
+ break;
+
+ if (ehdr.e_ident[EI_MAG0] != ELFMAG0
+ || ehdr.e_ident[EI_MAG1] != ELFMAG1
+ || ehdr.e_ident[EI_MAG2] != ELFMAG2
+ || ehdr.e_ident[EI_MAG3] != ELFMAG3
+ || ehdr.e_ident[EI_VERSION] != EV_CURRENT
+ || ehdr.e_version != EV_CURRENT)
+ break;
+
+ if (ehdr.e_ident[EI_DATA] != ELFDATA2MSB
+ || ehdr.e_machine != grub_cpu_to_be16_compile_time (EM_MIPS)
+ || ehdr.e_type != grub_cpu_to_be16_compile_time (ET_EXEC))
+ break;
+
+ ret = 1;
+
+ break;
+ }
+
+ case IS_X86_KNETBSD:
+ case IS_X86_KNETBSD32:
+ case IS_X86_KNETBSD64:
+ {
+ int is32, is64;
+
+ elf = grub_elf_file (file, file->name);
+
+ if (elf->ehdr.ehdr32.e_type != grub_cpu_to_le16_compile_time (ET_EXEC)
+ || elf->ehdr.ehdr32.e_ident[EI_DATA] != ELFDATA2LSB)
+ break;
+
+ is32 = grub_elf_is_elf32 (elf);
+ is64 = grub_elf_is_elf64 (elf);
+ if (!is32 && !is64)
+ break;
+ if (!is32 && type == IS_X86_KNETBSD32)
+ break;
+ if (!is64 && type == IS_X86_KNETBSD64)
+ break;
+ if (is64)
+ ret = grub_file_check_netbsd64 (elf);
+ if (is32)
+ ret = grub_file_check_netbsd32 (elf);
+ break;
+ }
+
+ case IS_X86_KFREEBSD:
+ case IS_X86_KFREEBSD32:
+ case IS_X86_KFREEBSD64:
+ {
+ Elf32_Ehdr ehdr;
+ int is32, is64;
+
+ if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
+ break;
+
+ if (ehdr.e_ident[EI_MAG0] != ELFMAG0
+ || ehdr.e_ident[EI_MAG1] != ELFMAG1
+ || ehdr.e_ident[EI_MAG2] != ELFMAG2
+ || ehdr.e_ident[EI_MAG3] != ELFMAG3
+ || ehdr.e_ident[EI_VERSION] != EV_CURRENT
+ || ehdr.e_version != EV_CURRENT)
+ break;
+
+ if (ehdr.e_type != grub_cpu_to_le16_compile_time (ET_EXEC)
+ || ehdr.e_ident[EI_DATA] != ELFDATA2LSB)
+ break;
+
+ if (ehdr.e_ident[EI_OSABI] != ELFOSABI_FREEBSD)
+ break;
+
+ is32 = (ehdr.e_machine == grub_cpu_to_le16_compile_time (EM_386)
+ && ehdr.e_ident[EI_CLASS] == ELFCLASS32);
+ is64 = (ehdr.e_machine == grub_cpu_to_le16_compile_time (EM_X86_64)
+ && ehdr.e_ident[EI_CLASS] == ELFCLASS64);
+ if (!is32 && !is64)
+ break;
+ if (!is32 && (type == IS_X86_KFREEBSD32 || type == IS_X86_KNETBSD32))
+ break;
+ if (!is64 && (type == IS_X86_KFREEBSD64 || type == IS_X86_KNETBSD64))
+ break;
+ ret = 1;
+
+ break;
+ }
+
+
+ case IS_MIPSEL_LINUX:
+ {
+ Elf32_Ehdr ehdr;
+
+ if (grub_file_read (file, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
+ break;
+
+ if (ehdr.e_ident[EI_MAG0] != ELFMAG0
+ || ehdr.e_ident[EI_MAG1] != ELFMAG1
+ || ehdr.e_ident[EI_MAG2] != ELFMAG2
+ || ehdr.e_ident[EI_MAG3] != ELFMAG3
+ || ehdr.e_ident[EI_VERSION] != EV_CURRENT
+ || ehdr.e_version != EV_CURRENT)
+ break;
+
+ if (ehdr.e_machine != grub_cpu_to_le16_compile_time (EM_MIPS)
+ || ehdr.e_type != grub_cpu_to_le16_compile_time (ET_EXEC))
+ break;
+
+ ret = 1;
+
+ break;
+ }
+ case IS_ARM_LINUX:
+ {
+ struct linux_arm_kernel_header lh;
+
+ if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
+ break;
+ /* Short forward branch in A32 state (for Raspberry pi kernels). */
+ if (lh.code0 == grub_cpu_to_le32_compile_time (0xea000006))
+ {
+ ret = 1;
+ break;
+ }
+
+ if (lh.magic ==
+ grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM_MAGIC_SIGNATURE))
+ {
+ ret = 1;
+ break;
+ }
+ break;
+ }
+ case IS_ARM64_LINUX:
+ {
+ struct linux_arm64_kernel_header lh;
+
+ if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
+ break;
+
+ if (lh.magic ==
+ grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM64_MAGIC_SIGNATURE))
+ {
+ ret = 1;
+ break;
+ }
+ break;
+ }
+ case IS_PAE_DOMU ... IS_DOM0:
+ {
+ struct grub_xen_file_info xen_inf;
+ elf = grub_xen_file (file);
+ if (!elf)
+ break;
+ err = grub_xen_get_info (elf, &xen_inf);
+ if (err)
+ break;
+ /* Unfortuntely no way to check if kernel supports dom0. */
+ if (type == IS_DOM0)
+ ret = 1;
+ if (type == IS_PAE_DOMU)
+ ret = (xen_inf.arch == GRUB_XEN_FILE_I386_PAE
+ || xen_inf.arch == GRUB_XEN_FILE_I386_PAE_BIMODE);
+ if (type == IS_64_DOMU)
+ ret = (xen_inf.arch == GRUB_XEN_FILE_X86_64);
+ break;
+ }
+ case IS_MULTIBOOT:
+ case IS_MULTIBOOT2:
+ {
+ grub_uint32_t *buffer;
+ grub_ssize_t len;
+ grub_size_t search_size;
+ grub_uint32_t *header;
+ grub_uint32_t magic;
+ grub_size_t step;
+
+ if (type == IS_MULTIBOOT2)
+ {
+ search_size = 32768;
+ magic = grub_cpu_to_le32_compile_time (0xe85250d6);
+ step = 2;
+ }
+ else
+ {
+ search_size = 8192;
+ magic = grub_cpu_to_le32_compile_time (0x1BADB002);
+ step = 1;
+ }
+
+ buffer = grub_malloc (search_size);
+ if (!buffer)
+ break;
+
+ len = grub_file_read (file, buffer, search_size);
+ if (len < 32)
+ {
+ grub_free (buffer);
+ break;
+ }
+
+ /* 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 = buffer;
+ ((char *) header <=
+ (char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12));
+ header += step)
+ {
+ if (header[0] == magic
+ && !(grub_le_to_cpu32 (header[0])
+ + grub_le_to_cpu32 (header[1])
+ + grub_le_to_cpu32 (header[2])
+ + (type == IS_MULTIBOOT2
+ ? grub_le_to_cpu32 (header[3]) : 0)))
+ {
+ ret = 1;
+ break;
+ }
+ }
+
+ grub_free (buffer);
+ break;
+ }
+ case IS_X86_LINUX32:
+ case IS_X86_LINUX:
+ {
+ struct linux_i386_kernel_header lh;
+ if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
+ break;
+ if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55))
+ break;
+
+ if (lh.setup_sects > GRUB_LINUX_MAX_SETUP_SECTS)
+ break;
+
+ /* FIXME: some really old kernels (< 1.3.73) will fail this. */
+ if (lh.header !=
+ grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
+ || grub_le_to_cpu16 (lh.version) < 0x0200)
+ break;
+
+ if (type == IS_X86_LINUX)
+ {
+ ret = 1;
+ break;
+ }
+
+ /* 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_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
+ || grub_le_to_cpu16 (lh.version) < 0x0203)
+ break;
+
+ if (!(lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL))
+ break;
+ ret = 1;
+ break;
+ }
+ case IS_HIBERNATED:
+ {
+ grub_uint8_t hibr_file_magic[4];
+ if (grub_file_read (file, &hibr_file_magic, sizeof (hibr_file_magic))
+ != sizeof (hibr_file_magic))
+ break;
+ if (grub_memcmp ("hibr", hibr_file_magic, sizeof (hibr_file_magic)) ==
+ 0
+ || grub_memcmp ("HIBR", hibr_file_magic,
+ sizeof (hibr_file_magic)) == 0)
+ ret = 1;
+ break;
+ }
+ case IS_XNU64:
+ case IS_XNU32:
+ {
+ macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL,
+ (type == IS_XNU64));
+ if (!macho)
+ break;
+ /* FIXME: more checks? */
+ ret = 1;
+ break;
+ }
+ case IS_XNU_HIBR:
+ {
+ struct grub_xnu_hibernate_header hibhead;
+ if (grub_file_read (file, &hibhead, sizeof (hibhead))
+ != sizeof (hibhead))
+ break;
+ if (hibhead.magic !=
+ grub_cpu_to_le32_compile_time (GRUB_XNU_HIBERNATE_MAGIC))
+ break;
+ ret = 1;
+ break;
+ }
+ case IS_32_EFI:
+ case IS_64_EFI:
+ case IS_IA_EFI:
+ case IS_ARM64_EFI:
+ case IS_ARM_EFI:
+ case IS_RISCV32_EFI:
+ case IS_RISCV64_EFI:
+ {
+ char signature[4];
+ grub_uint32_t pe_offset;
+ struct grub_pe32_coff_header coff_head;
+
+ if (grub_file_read (file, signature, 2) != 2)
+ break;
+ if (signature[0] != 'M' || signature[1] != 'Z')
+ break;
+ if ((grub_ssize_t) grub_file_seek (file, 0x3c) == -1)
+ break;
+ if (grub_file_read (file, &pe_offset, 4) != 4)
+ break;
+ if ((grub_ssize_t) grub_file_seek (file, grub_le_to_cpu32 (pe_offset))
+ == -1)
+ break;
+ if (grub_file_read (file, signature, 4) != 4)
+ break;
+ if (signature[0] != 'P' || signature[1] != 'E'
+ || signature[2] != '\0' || signature[3] != '\0')
+ break;
+
+ if (grub_file_read (file, &coff_head, sizeof (coff_head))
+ != sizeof (coff_head))
+ break;
+ if (type == IS_32_EFI
+ && coff_head.machine !=
+ grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_I386))
+ break;
+ if (type == IS_64_EFI
+ && coff_head.machine !=
+ grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_X86_64))
+ break;
+ if (type == IS_IA_EFI
+ && 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_RISCV32_EFI || type == IS_RISCV64_EFI)
+ && coff_head.machine !=
+ grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_RISCV64))
+ /* TODO: Determine bitness dynamically */
+ break;
+ if (type == IS_IA_EFI || type == IS_64_EFI || type == IS_ARM64_EFI ||
+ type == IS_RISCV32_EFI || type == IS_RISCV64_EFI)
+ {
+ struct grub_pe64_optional_header o64;
+ if (grub_file_read (file, &o64, sizeof (o64)) != sizeof (o64))
+ break;
+ if (o64.magic !=
+ grub_cpu_to_le16_compile_time (GRUB_PE32_PE64_MAGIC))
+ break;
+ if (o64.subsystem !=
+ grub_cpu_to_le16_compile_time
+ (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION))
+ break;
+ ret = 1;
+ break;
+ }
+ if (type == IS_32_EFI || type == IS_ARM_EFI)
+ {
+ struct grub_pe32_optional_header o32;
+ if (grub_file_read (file, &o32, sizeof (o32)) != sizeof (o32))
+ break;
+ if (o32.magic !=
+ grub_cpu_to_le16_compile_time (GRUB_PE32_PE32_MAGIC))
+ break;
+ if (o32.subsystem !=
+ grub_cpu_to_le16_compile_time
+ (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION))
+ break;
+ ret = 1;
+ break;
+ }
+ break;
+ }
+ }
+
+ if (elf)
+ grub_elf_close (elf);
+ else if (macho)
+ grub_macho_close (macho);
+ else if (file)
+ grub_file_close (file);
+
+ if (!ret && (grub_errno == GRUB_ERR_BAD_OS || grub_errno == GRUB_ERR_NONE))
+ /* TRANSLATORS: it's a standalone boolean value,
+ opposite of "true". */
+ grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
+ return grub_errno;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(file)
+{
+ cmd = grub_register_extcmd ("file", grub_cmd_file, 0,
+ N_("OPTIONS FILE"),
+ N_("Check if FILE is of specified type."),
+ options);
+}
+
+GRUB_MOD_FINI(file)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/file32.c b/grub-core/commands/file32.c
new file mode 100644
index 0000000..0861c45
--- /dev/null
+++ b/grub-core/commands/file32.c
@@ -0,0 +1,5 @@
+#define GRUB_TARGET_WORDSIZE 32
+#define XX 32
+#define ehdrXX ehdr32
+#define grub_file_check_netbsdXX grub_file_check_netbsd32
+#include "fileXX.c"
diff --git a/grub-core/commands/file64.c b/grub-core/commands/file64.c
new file mode 100644
index 0000000..90890d4
--- /dev/null
+++ b/grub-core/commands/file64.c
@@ -0,0 +1,5 @@
+#define GRUB_TARGET_WORDSIZE 64
+#define XX 64
+#define ehdrXX ehdr64
+#define grub_file_check_netbsdXX grub_file_check_netbsd64
+#include "fileXX.c"
diff --git a/grub-core/commands/fileXX.c b/grub-core/commands/fileXX.c
new file mode 100644
index 0000000..c17d26c
--- /dev/null
+++ b/grub-core/commands/fileXX.c
@@ -0,0 +1,74 @@
+/*
+ * 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/fileid.h>
+#include <grub/elfload.h>
+#include <grub/misc.h>
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+int
+grub_file_check_netbsdXX (grub_elf_t elf)
+{
+ Elf_Shdr *s, *s0;
+
+ grub_size_t shnum = elf->ehdr.ehdrXX.e_shnum;
+ grub_size_t shentsize = elf->ehdr.ehdrXX.e_shentsize;
+ grub_size_t shsize = shnum * shentsize;
+ grub_off_t stroff;
+
+ if (!shnum || !shentsize)
+ return 0;
+
+ s0 = grub_malloc (shsize);
+ if (!s0)
+ return 0;
+
+ if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1)
+ goto fail;
+
+ if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize)
+ goto fail;
+
+ s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize);
+ stroff = s->sh_offset;
+
+ for (s = s0; s < (Elf_Shdr *) ((char *) s0 + shnum * shentsize);
+ s = (Elf_Shdr *) ((char *) s + shentsize))
+ {
+ 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)
+ goto fail;
+
+ if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name))
+ {
+ if (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
new file mode 100644
index 0000000..444e248
--- /dev/null
+++ b/grub-core/commands/gptsync.c
@@ -0,0 +1,266 @@
+/* gptsync.c - fill the mbr based on gpt entries */
+/* XXX: I don't know what to do if sector size isn't 512 bytes */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/command.h>
+#include <grub/dl.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/msdos_partition.h>
+#include <grub/partition.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/fs.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Convert a LBA address to a CHS address in the INT 13 format. */
+/* Taken from grub1. */
+/* XXX: use hardcoded geometry of C = 1024, H = 255, S = 63.
+ Is it a problem?
+*/
+static void
+lba_to_chs (grub_uint32_t lba, grub_uint8_t *cl, grub_uint8_t *ch,
+ grub_uint8_t *dh)
+{
+ grub_uint32_t cylinder, head, sector;
+ grub_uint32_t sectors = 63, heads = 255, cylinders = 1024;
+
+ sector = lba % sectors + 1;
+ head = (lba / sectors) % heads;
+ cylinder = lba / (sectors * heads);
+
+ if (cylinder >= cylinders)
+ {
+ *cl = *ch = *dh = 0xff;
+ return;
+ }
+
+ *cl = sector | ((cylinder & 0x300) >> 2);
+ *ch = cylinder & 0xFF;
+ *dh = head;
+}
+
+static grub_err_t
+grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_device_t dev;
+ struct grub_msdos_partition_mbr mbr;
+ struct grub_partition *partition;
+ grub_disk_addr_t first_sector;
+ int numactive = 0;
+ int i;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required");
+ if (argc > 4)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "only 3 partitions can be "
+ "in hybrid MBR");
+
+ if (args[0][0] == '(' && args[0][grub_strlen (args[0]) - 1] == ')')
+ {
+ args[0][grub_strlen (args[0]) - 1] = 0;
+ dev = grub_device_open (args[0] + 1);
+ args[0][grub_strlen (args[0])] = ')';
+ }
+ else
+ dev = grub_device_open (args[0]);
+
+ if (! dev)
+ return grub_errno;
+
+ if (! dev->disk)
+ {
+ grub_device_close (dev);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a disk");
+ }
+
+ /* Read the protective MBR. */
+ if (grub_disk_read (dev->disk, 0, 0, sizeof (mbr), &mbr))
+ {
+ grub_device_close (dev);
+ return grub_errno;
+ }
+
+ /* Check if it is valid. */
+ 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");
+ }
+
+ /* Make sure the MBR is a protective MBR and not a normal MBR. */
+ for (i = 0; i < 4; i++)
+ if (mbr.entries[i].type == GRUB_PC_PARTITION_TYPE_GPT_DISK)
+ break;
+ if (i == 4)
+ {
+ grub_device_close (dev);
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "no GPT partition map found");
+ }
+
+ first_sector = dev->disk->total_sectors;
+ for (i = 1; i < argc; i++)
+ {
+ char *separator, csep = 0;
+ grub_uint8_t type;
+ separator = grub_strchr (args[i], '+');
+ if (! separator)
+ separator = grub_strchr (args[i], '-');
+ if (separator)
+ {
+ csep = *separator;
+ *separator = 0;
+ }
+ partition = grub_partition_probe (dev->disk, args[i]);
+ if (separator)
+ *separator = csep;
+ if (! partition)
+ {
+ grub_device_close (dev);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ N_("no such partition"));
+ }
+
+ if (partition->start + partition->len > 0xffffffff)
+ {
+ grub_device_close (dev);
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "only partitions residing in the first 2TB "
+ "can be present in hybrid MBR");
+ }
+
+
+ if (first_sector > partition->start)
+ first_sector = partition->start;
+
+ if (separator && *(separator + 1))
+ type = grub_strtoul (separator + 1, 0, 0);
+ else
+ {
+ grub_fs_t fs = 0;
+ dev->disk->partition = partition;
+ fs = grub_fs_probe (dev);
+
+ /* Unknown filesystem isn't fatal. */
+ if (grub_errno == GRUB_ERR_UNKNOWN_FS)
+ {
+ fs = 0;
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ if (fs && grub_strcmp (fs->name, "ntfs") == 0)
+ type = GRUB_PC_PARTITION_TYPE_NTFS;
+ else if (fs && grub_strcmp (fs->name, "fat") == 0)
+ /* FIXME: detect FAT16. */
+ type = GRUB_PC_PARTITION_TYPE_FAT32_LBA;
+ else if (fs && (grub_strcmp (fs->name, "hfsplus") == 0
+ || grub_strcmp (fs->name, "hfs") == 0))
+ type = GRUB_PC_PARTITION_TYPE_HFS;
+ else
+ /* FIXME: detect more types. */
+ type = GRUB_PC_PARTITION_TYPE_EXT2FS;
+
+ dev->disk->partition = 0;
+ }
+
+ mbr.entries[i].flag = (csep == '+') ? 0x80 : 0;
+ if (csep == '+')
+ {
+ numactive++;
+ if (numactive == 2)
+ {
+ grub_device_close (dev);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "only one partition can be active");
+ }
+ }
+ mbr.entries[i].type = type;
+ mbr.entries[i].start = grub_cpu_to_le32 (partition->start);
+ lba_to_chs (partition->start,
+ &(mbr.entries[i].start_sector),
+ &(mbr.entries[i].start_cylinder),
+ &(mbr.entries[i].start_head));
+ lba_to_chs (partition->start + partition->len - 1,
+ &(mbr.entries[i].end_sector),
+ &(mbr.entries[i].end_cylinder),
+ &(mbr.entries[i].end_head));
+ mbr.entries[i].length = grub_cpu_to_le32 (partition->len);
+ grub_free (partition);
+ }
+ for (; i < 4; i++)
+ grub_memset (&(mbr.entries[i]), 0, sizeof (mbr.entries[i]));
+
+ /* The protective partition. */
+ if (first_sector > 0xffffffff)
+ first_sector = 0xffffffff;
+ else
+ 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_compile_time (1);
+ lba_to_chs (1,
+ &(mbr.entries[0].start_sector),
+ &(mbr.entries[0].start_cylinder),
+ &(mbr.entries[0].start_head));
+ lba_to_chs (first_sector,
+ &(mbr.entries[0].end_sector),
+ &(mbr.entries[0].end_cylinder),
+ &(mbr.entries[0].end_head));
+ mbr.entries[0].length = grub_cpu_to_le32 (first_sector);
+
+ mbr.signature = grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE);
+
+ if (grub_disk_write (dev->disk, 0, 0, sizeof (mbr), &mbr))
+ {
+ grub_device_close (dev);
+ return grub_errno;
+ }
+
+ grub_device_close (dev);
+
+ grub_printf_ (N_("New MBR is written to `%s'\n"), args[0]);
+
+ return GRUB_ERR_NONE;
+}
+
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(gptsync)
+{
+ (void) mod; /* To stop warning. */
+ cmd = grub_register_command ("gptsync", grub_cmd_gptsync,
+ N_("DEVICE [PARTITION[+/-[TYPE]]] ..."),
+ /* TRANSLATORS: MBR type is one-byte partition
+ type id. */
+ N_("Fill hybrid MBR of GPT drive DEVICE. "
+ "Specified partitions will be a part "
+ "of hybrid MBR. Up to 3 partitions are "
+ "allowed. TYPE is an MBR type. "
+ "+ means that partition is active. "
+ "Only one partition can be active."));
+}
+
+GRUB_MOD_FINI(gptsync)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/halt.c b/grub-core/commands/halt.c
new file mode 100644
index 0000000..f8596ec
--- /dev/null
+++ b/grub-core/commands/halt.c
@@ -0,0 +1,47 @@
+/* halt.c - command to halt the computer. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t __attribute__ ((noreturn))
+grub_cmd_halt (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_halt ();
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(halt)
+{
+ cmd = grub_register_command ("halt", grub_cmd_halt,
+ 0, N_("Halts the computer. This command does"
+ " not work on all firmware implementations."));
+}
+
+GRUB_MOD_FINI(halt)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/hashsum.c b/grub-core/commands/hashsum.c
new file mode 100644
index 0000000..b8a22b0
--- /dev/null
+++ b/grub-core/commands/hashsum.c
@@ -0,0 +1,334 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/extcmd.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/crypto.h>
+#include <grub/normal.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] = {
+ {"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING},
+ {"check", 'c', 0, N_("Check hashes of files with hash list FILE."),
+ N_("FILE"), ARG_TYPE_STRING},
+ {"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIR"),
+ ARG_TYPE_STRING},
+ {"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},
+ {"uncompress", 'u', 0, N_("Uncompress file before checksumming."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+};
+
+static struct { const char *name; const char *hashname; } aliases[] =
+ {
+ {"sha256sum", "sha256"},
+ {"sha512sum", "sha512"},
+ {"sha1sum", "sha1"},
+ {"md5sum", "md5"},
+ {"crc", "crc32"},
+ };
+
+static inline int
+hextoval (char c)
+{
+ if (c >= '0' && c <= '9')
+ return c - '0';
+ if (c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+ if (c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+ return -1;
+}
+
+static grub_err_t
+hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
+{
+ void *context;
+ grub_uint8_t *readbuf;
+#define BUF_SIZE 4096
+ readbuf = grub_malloc (BUF_SIZE);
+ if (!readbuf)
+ return grub_errno;
+ context = grub_zalloc (hash->contextsize);
+ if (!readbuf || !context)
+ goto fail;
+
+ hash->init (context);
+ while (1)
+ {
+ grub_ssize_t r;
+ r = grub_file_read (file, readbuf, BUF_SIZE);
+ if (r < 0)
+ goto fail;
+ if (r == 0)
+ break;
+ hash->write (context, readbuf, r);
+ }
+ hash->final (context);
+ grub_memcpy (result, hash->read (context), hash->mdlen);
+
+ grub_free (readbuf);
+ grub_free (context);
+
+ return GRUB_ERR_NONE;
+
+ fail:
+ grub_free (readbuf);
+ grub_free (context);
+ return grub_errno;
+}
+
+static grub_err_t
+check_list (const gcry_md_spec_t *hash, const char *hashfilename,
+ const char *prefix, int keep, int uncompress)
+{
+ grub_file_t hashlist, file;
+ char *buf = NULL;
+ grub_uint8_t expected[GRUB_CRYPTO_MAX_MDLEN];
+ grub_uint8_t actual[GRUB_CRYPTO_MAX_MDLEN];
+ grub_err_t err;
+ unsigned i;
+ unsigned unread = 0, mismatch = 0;
+
+ if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
+ return grub_error (GRUB_ERR_BUG, "mdlen is too long");
+
+ hashlist = grub_file_open (hashfilename, GRUB_FILE_TYPE_HASHLIST);
+ if (!hashlist)
+ return grub_errno;
+
+ while (grub_free (buf), (buf = grub_file_getline (hashlist)))
+ {
+ const char *p = buf;
+ while (grub_isspace (p[0]))
+ p++;
+ for (i = 0; i < hash->mdlen; i++)
+ {
+ int high, low;
+ high = hextoval (*p++);
+ low = hextoval (*p++);
+ if (high < 0 || low < 0)
+ {
+ grub_free (buf);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
+ }
+ expected[i] = (high << 4) | low;
+ }
+ if ((p[0] != ' ' && p[0] != '\t') || (p[1] != ' ' && p[1] != '\t'))
+ {
+ grub_free (buf);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
+ }
+ p += 2;
+ if (prefix)
+ {
+ char *filename;
+
+ filename = grub_xasprintf ("%s/%s", prefix, p);
+ if (!filename)
+ {
+ grub_free (buf);
+ return grub_errno;
+ }
+ file = grub_file_open (filename, GRUB_FILE_TYPE_TO_HASH
+ | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
+ : GRUB_FILE_TYPE_NONE));
+ grub_free (filename);
+ }
+ else
+ file = grub_file_open (p, GRUB_FILE_TYPE_TO_HASH
+ | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
+ : GRUB_FILE_TYPE_NONE));
+ if (!file)
+ {
+ grub_file_close (hashlist);
+ grub_free (buf);
+ return grub_errno;
+ }
+ err = hash_file (file, hash, actual);
+ grub_file_close (file);
+ if (err)
+ {
+ grub_printf_ (N_("%s: READ ERROR\n"), p);
+ if (!keep)
+ {
+ grub_file_close (hashlist);
+ grub_free (buf);
+ return err;
+ }
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ unread++;
+ continue;
+ }
+ if (grub_crypto_memcmp (expected, actual, hash->mdlen) != 0)
+ {
+ grub_printf_ (N_("%s: HASH MISMATCH\n"), p);
+ if (!keep)
+ {
+ grub_file_close (hashlist);
+ grub_free (buf);
+ return grub_error (GRUB_ERR_TEST_FAILURE,
+ "hash of '%s' mismatches", p);
+ }
+ mismatch++;
+ continue;
+ }
+ grub_printf_ (N_("%s: OK\n"), p);
+ }
+ if (mismatch || unread)
+ return grub_error (GRUB_ERR_TEST_FAILURE,
+ "%d files couldn't be read and hash "
+ "of %d files mismatches", unread, mismatch);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
+ int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ const char *hashname = NULL;
+ const char *prefix = NULL;
+ const gcry_md_spec_t *hash;
+ unsigned i;
+ int keep = state[3].set;
+ int uncompress = state[4].set;
+ unsigned unread = 0;
+
+ for (i = 0; i < ARRAY_SIZE (aliases); i++)
+ if (grub_strcmp (ctxt->extcmd->cmd->name, aliases[i].name) == 0)
+ hashname = aliases[i].hashname;
+ if (state[0].set)
+ hashname = state[0].arg;
+
+ if (!hashname)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no hash specified");
+
+ hash = grub_crypto_lookup_md_by_name (hashname);
+ if (!hash)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown hash");
+
+ if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
+ return grub_error (GRUB_ERR_BUG, "mdlen is too long");
+
+ if (state[2].set)
+ prefix = state[2].arg;
+
+ if (state[1].set)
+ {
+ if (argc != 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "--check is incompatible with file list");
+ return check_list (hash, state[1].arg, prefix, keep, uncompress);
+ }
+
+ for (i = 0; i < (unsigned) argc; i++)
+ {
+ GRUB_PROPERLY_ALIGNED_ARRAY (result, GRUB_CRYPTO_MAX_MDLEN);
+ grub_file_t file;
+ grub_err_t err;
+ unsigned j;
+ file = grub_file_open (args[i], GRUB_FILE_TYPE_TO_HASH
+ | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
+ : GRUB_FILE_TYPE_NONE));
+ if (!file)
+ {
+ if (!keep)
+ return grub_errno;
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ unread++;
+ continue;
+ }
+ err = hash_file (file, hash, result);
+ grub_file_close (file);
+ if (err)
+ {
+ if (!keep)
+ return err;
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ unread++;
+ continue;
+ }
+ for (j = 0; j < hash->mdlen; j++)
+ grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
+ grub_printf (" %s\n", args[i]);
+ }
+
+ if (unread)
+ return grub_error (GRUB_ERR_TEST_FAILURE, "%d files couldn't be read",
+ unread);
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd, cmd_md5, cmd_sha1, cmd_sha256, cmd_sha512, cmd_crc;
+
+GRUB_MOD_INIT(hashsum)
+{
+ cmd = grub_register_extcmd ("hashsum", grub_cmd_hashsum, 0,
+ N_("-h HASH [-c FILE [-p PREFIX]] "
+ "[FILE1 [FILE2 ...]]"),
+ /* TRANSLATORS: "hash checksum" is just to
+ be a bit more precise, you can treat it as
+ just "hash". */
+ N_("Compute or check hash checksum."),
+ options);
+ cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum, 0,
+ N_("[-c FILE [-p PREFIX]] "
+ "[FILE1 [FILE2 ...]]"),
+ N_("Compute or check hash checksum."),
+ options);
+ cmd_sha1 = grub_register_extcmd ("sha1sum", grub_cmd_hashsum, 0,
+ N_("[-c FILE [-p PREFIX]] "
+ "[FILE1 [FILE2 ...]]"),
+ N_("Compute or check hash checksum."),
+ options);
+ cmd_sha256 = grub_register_extcmd ("sha256sum", grub_cmd_hashsum, 0,
+ N_("[-c FILE [-p PREFIX]] "
+ "[FILE1 [FILE2 ...]]"),
+ N_("Compute or check hash checksum."),
+ options);
+ cmd_sha512 = grub_register_extcmd ("sha512sum", grub_cmd_hashsum, 0,
+ N_("[-c FILE [-p PREFIX]] "
+ "[FILE1 [FILE2 ...]]"),
+ N_("Compute or check hash checksum."),
+ options);
+
+ cmd_crc = grub_register_extcmd ("crc", grub_cmd_hashsum, 0,
+ N_("[-c FILE [-p PREFIX]] "
+ "[FILE1 [FILE2 ...]]"),
+ N_("Compute or check hash checksum."),
+ options);
+}
+
+GRUB_MOD_FINI(hashsum)
+{
+ grub_unregister_extcmd (cmd);
+ grub_unregister_extcmd (cmd_md5);
+ grub_unregister_extcmd (cmd_sha1);
+ grub_unregister_extcmd (cmd_sha256);
+ grub_unregister_extcmd (cmd_sha512);
+ grub_unregister_extcmd (cmd_crc);
+}
diff --git a/grub-core/commands/hdparm.c b/grub-core/commands/hdparm.c
new file mode 100644
index 0000000..2e2319e
--- /dev/null
+++ b/grub-core/commands/hdparm.c
@@ -0,0 +1,447 @@
+/* hdparm.c - command to get/set ATA disk parameters. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/ata.h>
+#include <grub/scsi.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/lib/hexdump.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] = {
+ {"apm", 'B', 0, N_("Set Advanced Power Management\n"
+ "(1=low, ..., 254=high, 255=off)."),
+ 0, ARG_TYPE_INT},
+ {"power", 'C', 0, N_("Display power mode."), 0, ARG_TYPE_NONE},
+ {"security-freeze", 'F', 0, N_("Freeze ATA security settings until reset."),
+ 0, ARG_TYPE_NONE},
+ {"health", 'H', 0, N_("Display SMART health status."), 0, ARG_TYPE_NONE},
+ {"aam", 'M', 0, N_("Set Automatic Acoustic Management\n"
+ "(0=off, 128=quiet, ..., 254=fast)."),
+ 0, ARG_TYPE_INT},
+ {"standby-timeout", 'S', 0, N_("Set standby timeout\n"
+ "(0=off, 1=5s, 2=10s, ..., 240=20m, 241=30m, ...)."),
+ 0, ARG_TYPE_INT},
+ {"standby", 'y', 0, N_("Set drive to standby mode."), 0, ARG_TYPE_NONE},
+ {"sleep", 'Y', 0, N_("Set drive to sleep mode."), 0, ARG_TYPE_NONE},
+ {"identify", 'i', 0, N_("Print drive identity and settings."),
+ 0, ARG_TYPE_NONE},
+ {"dumpid", 'I', 0, N_("Show raw contents of ATA IDENTIFY sector."),
+ 0, ARG_TYPE_NONE},
+ {"smart", -1, 0, N_("Disable/enable SMART (0/1)."), 0, ARG_TYPE_INT},
+ {"quiet", 'q', 0, N_("Do not print messages."), 0, ARG_TYPE_NONE},
+ {0, 0, 0, 0, 0, 0}
+};
+
+enum grub_ata_smart_commands
+ {
+ GRUB_ATA_FEAT_SMART_ENABLE = 0xd8,
+ GRUB_ATA_FEAT_SMART_DISABLE = 0xd9,
+ GRUB_ATA_FEAT_SMART_STATUS = 0xda,
+ };
+
+static int quiet = 0;
+
+static grub_err_t
+grub_hdparm_do_ata_cmd (grub_ata_t ata, grub_uint8_t cmd,
+ grub_uint8_t features, grub_uint8_t sectors,
+ void * buffer, int size)
+{
+ struct grub_disk_ata_pass_through_parms apt;
+ grub_memset (&apt, 0, sizeof (apt));
+
+ apt.taskfile.cmd = cmd;
+ apt.taskfile.features = features;
+ apt.taskfile.sectors = sectors;
+ apt.taskfile.disk = 0xE0;
+
+ apt.buffer = buffer;
+ apt.size = size;
+
+ if (ata->dev->readwrite (ata, &apt, 0))
+ return grub_errno;
+
+ return GRUB_ERR_NONE;
+}
+
+static int
+grub_hdparm_do_check_powermode_cmd (grub_ata_t ata)
+{
+ struct grub_disk_ata_pass_through_parms apt;
+ grub_memset (&apt, 0, sizeof (apt));
+
+ apt.taskfile.cmd = GRUB_ATA_CMD_CHECK_POWER_MODE;
+ apt.taskfile.disk = 0xE0;
+
+ if (ata->dev->readwrite (ata, &apt, 0))
+ return -1;
+
+ return apt.taskfile.sectors;
+}
+
+static int
+grub_hdparm_do_smart_cmd (grub_ata_t ata, grub_uint8_t features)
+{
+ struct grub_disk_ata_pass_through_parms apt;
+ grub_memset (&apt, 0, sizeof (apt));
+
+ apt.taskfile.cmd = GRUB_ATA_CMD_SMART;
+ apt.taskfile.features = features;
+ apt.taskfile.lba_mid = 0x4f;
+ apt.taskfile.lba_high = 0xc2;
+ apt.taskfile.disk = 0xE0;
+
+ if (ata->dev->readwrite (ata, &apt, 0))
+ return -1;
+
+ if (features == GRUB_ATA_FEAT_SMART_STATUS)
+ {
+ if ( apt.taskfile.lba_mid == 0x4f
+ && apt.taskfile.lba_high == 0xc2)
+ return 0; /* Good SMART status. */
+ else if ( apt.taskfile.lba_mid == 0xf4
+ && apt.taskfile.lba_high == 0x2c)
+ return 1; /* Bad SMART status. */
+ else
+ return -1;
+ }
+ return 0;
+}
+
+static grub_err_t
+grub_hdparm_simple_cmd (const char * msg,
+ grub_ata_t ata, grub_uint8_t cmd)
+{
+ if (! quiet && msg)
+ grub_printf ("%s", msg);
+
+ grub_err_t err = grub_hdparm_do_ata_cmd (ata, cmd, 0, 0, NULL, 0);
+
+ if (! quiet && msg)
+ grub_printf ("%s\n", ! err ? "" : ": not supported");
+ return err;
+}
+
+static grub_err_t
+grub_hdparm_set_val_cmd (const char * msg, int val,
+ grub_ata_t ata, grub_uint8_t cmd,
+ grub_uint8_t features, grub_uint8_t sectors)
+{
+ if (! quiet && msg && *msg)
+ {
+ if (val >= 0)
+ grub_printf ("Set %s to %d", msg, val);
+ else
+ grub_printf ("Disable %s", msg);
+ }
+
+ grub_err_t err = grub_hdparm_do_ata_cmd (ata, cmd, features, sectors,
+ NULL, 0);
+
+ if (! quiet && msg)
+ grub_printf ("%s\n", ! err ? "" : ": not supported");
+ return err;
+}
+
+static const char *
+le16_to_char (grub_uint16_t *dest, const grub_uint16_t * src16, unsigned bytes)
+{
+ unsigned i;
+ for (i = 0; i < bytes / 2; i++)
+ dest[i] = grub_swap_bytes16 (src16[i]);
+ dest[i] = 0;
+ return (char *) dest;
+}
+
+static void
+grub_hdparm_print_identify (const grub_uint16_t * idw)
+{
+ /* Print identity strings. */
+ grub_uint16_t tmp[21];
+ grub_printf ("Model: \"%.40s\"\n", le16_to_char (tmp, &idw[27], 40));
+ grub_printf ("Firmware: \"%.8s\"\n", le16_to_char (tmp, &idw[23], 8));
+ grub_printf ("Serial: \"%.20s\"\n", le16_to_char (tmp, &idw[10], 20));
+
+ /* Print AAM, APM and SMART settings. */
+ grub_uint16_t features1 = grub_le_to_cpu16 (idw[82]);
+ grub_uint16_t features2 = grub_le_to_cpu16 (idw[83]);
+ grub_uint16_t enabled1 = grub_le_to_cpu16 (idw[85]);
+ grub_uint16_t enabled2 = grub_le_to_cpu16 (idw[86]);
+
+ grub_printf ("Automatic Acoustic Management: ");
+ if (features2 & 0x0200)
+ {
+ if (enabled2 & 0x0200)
+ {
+ grub_uint16_t aam = grub_le_to_cpu16 (idw[94]);
+ grub_printf ("%u (128=quiet, ..., 254=fast, recommended=%u)\n",
+ aam & 0xff, (aam >> 8) & 0xff);
+ }
+ else
+ grub_printf ("disabled\n");
+ }
+ else
+ grub_printf ("not supported\n");
+
+ grub_printf ("Advanced Power Management: ");
+ if (features2 & 0x0008)
+ {
+ if (enabled2 & 0x0008)
+ grub_printf ("%u (1=low, ..., 254=high)\n",
+ grub_le_to_cpu16 (idw[91]) & 0xff);
+ else
+ grub_printf ("disabled\n");
+ }
+ else
+ grub_printf ("not supported\n");
+
+ grub_printf ("SMART Feature Set: ");
+ if (features1 & 0x0001)
+ grub_printf ("%sabled\n", (enabled1 & 0x0001 ? "en" : "dis"));
+ else
+ grub_printf ("not supported\n");
+
+ /* Print security settings. */
+ grub_uint16_t security = grub_le_to_cpu16 (idw[128]);
+
+ grub_printf ("ATA Security: ");
+ if (security & 0x0001)
+ grub_printf ("%s, %s, %s, %s\n",
+ (security & 0x0002 ? "ENABLED" : "disabled"),
+ (security & 0x0004 ? "**LOCKED**" : "not locked"),
+ (security & 0x0008 ? "frozen" : "NOT FROZEN"),
+ (security & 0x0010 ? "COUNT EXPIRED" : "count not expired"));
+ else
+ grub_printf ("not supported\n");
+}
+
+static void
+grub_hdparm_print_standby_tout (int timeout)
+{
+ if (timeout == 0)
+ grub_printf ("off");
+ else if (timeout <= 252 || timeout == 255)
+ {
+ int h = 0, m = 0 , s = 0;
+ if (timeout == 255)
+ {
+ m = 21;
+ s = 15;
+ }
+ else if (timeout == 252)
+ m = 21;
+ else if (timeout <= 240)
+ {
+ s = timeout * 5;
+ m = s / 60;
+ s %= 60;
+ }
+ else
+ {
+ m = (timeout - 240) * 30;
+ h = m / 60;
+ m %= 60;
+ }
+ grub_printf ("%02d:%02d:%02d", h, m, s);
+ }
+ else
+ grub_printf ("invalid or vendor-specific");
+}
+
+static int get_int_arg (const struct grub_arg_list *state)
+{
+ return (state->set ? (int)grub_strtoul (state->arg, 0, 0) : -1);
+}
+
+static grub_err_t
+grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ struct grub_ata *ata;
+ const char *diskname;
+
+ /* Check command line. */
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ if (args[0][0] == '(')
+ {
+ grub_size_t len = grub_strlen (args[0]);
+ if (args[0][len - 1] == ')')
+ args[0][len - 1] = 0;
+ diskname = &args[0][1];
+ }
+ else
+ diskname = &args[0][0];
+
+ int i = 0;
+ int apm = get_int_arg (&state[i++]);
+ int power = state[i++].set;
+ int sec_freeze = state[i++].set;
+ int health = state[i++].set;
+ int aam = get_int_arg (&state[i++]);
+ int standby_tout = get_int_arg (&state[i++]);
+ int standby_now = state[i++].set;
+ int sleep_now = state[i++].set;
+ int ident = state[i++].set;
+ int dumpid = state[i++].set;
+ int enable_smart = get_int_arg (&state[i++]);
+ quiet = state[i++].set;
+
+ /* Open disk. */
+ grub_disk_t disk = grub_disk_open (diskname);
+ if (! disk)
+ return grub_errno;
+
+ switch (disk->dev->id)
+ {
+ case GRUB_DISK_DEVICE_ATA_ID:
+ ata = disk->data;
+ break;
+ case GRUB_DISK_DEVICE_SCSI_ID:
+ if (((disk->id >> GRUB_SCSI_ID_SUBSYSTEM_SHIFT) & 0xFF)
+ == GRUB_SCSI_SUBSYSTEM_PATA
+ || (((disk->id >> GRUB_SCSI_ID_SUBSYSTEM_SHIFT) & 0xFF)
+ == GRUB_SCSI_SUBSYSTEM_AHCI))
+ {
+ ata = ((struct grub_scsi *) disk->data)->data;
+ break;
+ }
+ /* FALLTHROUGH */
+ default:
+ grub_disk_close (disk);
+ return grub_error (GRUB_ERR_IO, "not an ATA device");
+ }
+
+
+ /* Change settings. */
+ if (aam >= 0)
+ grub_hdparm_set_val_cmd ("Automatic Acoustic Management", (aam ? aam : -1),
+ ata, GRUB_ATA_CMD_SET_FEATURES,
+ (aam ? 0x42 : 0xc2), aam);
+
+ if (apm >= 0)
+ grub_hdparm_set_val_cmd ("Advanced Power Management",
+ (apm != 255 ? apm : -1), ata,
+ GRUB_ATA_CMD_SET_FEATURES,
+ (apm != 255 ? 0x05 : 0x85),
+ (apm != 255 ? apm : 0));
+
+ if (standby_tout >= 0)
+ {
+ if (! quiet)
+ {
+ grub_printf ("Set standby timeout to %d (", standby_tout);
+ grub_hdparm_print_standby_tout (standby_tout);
+ grub_printf (")");
+ }
+ /* The IDLE cmd sets disk to idle mode and configures standby timer. */
+ grub_hdparm_set_val_cmd ("", -1, ata, GRUB_ATA_CMD_IDLE, 0, standby_tout);
+ }
+
+ if (enable_smart >= 0)
+ {
+ if (! quiet)
+ grub_printf ("%sable SMART operations", (enable_smart ? "En" : "Dis"));
+ int err = grub_hdparm_do_smart_cmd (ata, (enable_smart ?
+ GRUB_ATA_FEAT_SMART_ENABLE : GRUB_ATA_FEAT_SMART_DISABLE));
+ if (! quiet)
+ grub_printf ("%s\n", err ? ": not supported" : "");
+ }
+
+ if (sec_freeze)
+ grub_hdparm_simple_cmd ("Freeze security settings", ata,
+ GRUB_ATA_CMD_SECURITY_FREEZE_LOCK);
+
+ /* Print/dump IDENTIFY. */
+ if (ident || dumpid)
+ {
+ grub_uint16_t buf[GRUB_DISK_SECTOR_SIZE / 2];
+ if (grub_hdparm_do_ata_cmd (ata, GRUB_ATA_CMD_IDENTIFY_DEVICE,
+ 0, 0, buf, sizeof (buf)))
+ grub_printf ("Cannot read ATA IDENTIFY data\n");
+ else
+ {
+ if (ident)
+ grub_hdparm_print_identify (buf);
+ if (dumpid)
+ hexdump (0, (char *) buf, sizeof (buf));
+ }
+ }
+
+ /* Check power mode. */
+ if (power)
+ {
+ grub_printf ("Disk power mode is: ");
+ int mode = grub_hdparm_do_check_powermode_cmd (ata);
+ if (mode < 0)
+ grub_printf ("unknown\n");
+ else
+ grub_printf ("%s (0x%02x)\n",
+ (mode == 0xff ? "active/idle" :
+ mode == 0x80 ? "idle" :
+ mode == 0x00 ? "standby" : "unknown"), mode);
+ }
+
+ /* Check health. */
+ int status = 0;
+ if (health)
+ {
+ if (! quiet)
+ grub_printf ("SMART status is: ");
+ int err = grub_hdparm_do_smart_cmd (ata, GRUB_ATA_FEAT_SMART_STATUS);
+ if (! quiet)
+ grub_printf ("%s\n", (err < 0 ? "unknown" :
+ err == 0 ? "OK" : "*BAD*"));
+ status = (err > 0);
+ }
+
+ /* Change power mode. */
+ if (standby_now)
+ grub_hdparm_simple_cmd ("Set disk to standby mode", ata,
+ GRUB_ATA_CMD_STANDBY_IMMEDIATE);
+
+ if (sleep_now)
+ grub_hdparm_simple_cmd ("Set disk to sleep mode", ata,
+ GRUB_ATA_CMD_SLEEP);
+
+ grub_disk_close (disk);
+
+ grub_errno = GRUB_ERR_NONE;
+ return status;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(hdparm)
+{
+ cmd = grub_register_extcmd_lockdown ("hdparm", grub_cmd_hdparm, 0,
+ N_("[OPTIONS] DISK"),
+ N_("Get/set ATA disk parameters."), options);
+}
+
+GRUB_MOD_FINI(hdparm)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/help.c b/grub-core/commands/help.c
new file mode 100644
index 0000000..f0be89b
--- /dev/null
+++ b/grub-core/commands/help.c
@@ -0,0 +1,153 @@
+/* help.c - command to show a help text. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/mm.h>
+#include <grub/normal.h>
+#include <grub/charset.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_help (grub_extcmd_context_t ctxt __attribute__ ((unused)), int argc,
+ char **args)
+{
+ int cnt = 0;
+ char *currarg;
+
+ if (argc == 0)
+ {
+ grub_command_t cmd;
+ FOR_COMMANDS(cmd)
+ {
+ if ((cmd->prio & GRUB_COMMAND_FLAG_ACTIVE))
+ {
+ struct grub_term_output *term;
+ const char *summary_translated = _(cmd->summary);
+ char *command_help;
+ grub_uint32_t *unicode_command_help;
+ grub_uint32_t *unicode_last_position;
+
+ command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated);
+ if (!command_help)
+ break;
+
+ grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help,
+ &unicode_last_position);
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ unsigned stringwidth;
+ grub_uint32_t *unicode_last_screen_position;
+
+ unicode_last_screen_position = unicode_command_help;
+
+ stringwidth = 0;
+
+ while (unicode_last_screen_position < unicode_last_position &&
+ stringwidth < ((grub_term_width (term) / 2) - 2))
+ {
+ struct grub_unicode_glyph glyph;
+ unicode_last_screen_position
+ += grub_unicode_aglomerate_comb (unicode_last_screen_position,
+ unicode_last_position
+ - unicode_last_screen_position,
+ &glyph);
+
+ stringwidth
+ += grub_term_getcharwidth (term, &glyph);
+ }
+
+ grub_print_ucs4 (unicode_command_help,
+ unicode_last_screen_position, 0, 0, term);
+ if (!(cnt % 2))
+ grub_print_spaces (term, grub_term_width (term) / 2
+ - stringwidth);
+ }
+
+ if (cnt % 2)
+ grub_printf ("\n");
+ cnt++;
+
+ grub_free (command_help);
+ grub_free (unicode_command_help);
+ }
+ }
+ if (!(cnt % 2))
+ grub_printf ("\n");
+ }
+ else
+ {
+ int i;
+ grub_command_t cmd_iter, cmd, cmd_next;
+
+ for (i = 0; i < argc; i++)
+ {
+ currarg = args[i];
+
+ FOR_COMMANDS_SAFE (cmd_iter, cmd_next)
+ {
+ if (!(cmd_iter->prio & GRUB_COMMAND_FLAG_ACTIVE))
+ continue;
+
+ if (grub_strncmp (cmd_iter->name, currarg,
+ grub_strlen (currarg)) != 0)
+ continue;
+ if (cmd_iter->flags & GRUB_COMMAND_FLAG_DYNCMD)
+ cmd = grub_dyncmd_get_cmd (cmd_iter);
+ else
+ cmd = cmd_iter;
+ if (!cmd)
+ {
+ grub_print_error ();
+ continue;
+ }
+ if (cnt++ > 0)
+ grub_printf ("\n\n");
+
+ if ((cmd->flags & GRUB_COMMAND_FLAG_EXTCMD) &&
+ ! (cmd->flags & GRUB_COMMAND_FLAG_DYNCMD))
+ grub_arg_show_help ((grub_extcmd_t) cmd->data);
+ else
+ grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name,
+ _(cmd->summary), _(cmd->description));
+ }
+ }
+ }
+
+ return 0;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(help)
+{
+ cmd = grub_register_extcmd ("help", grub_cmd_help, 0,
+ N_("[PATTERN ...]"),
+ N_("Show a help message."), 0);
+}
+
+GRUB_MOD_FINI(help)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/hexdump.c b/grub-core/commands/hexdump.c
new file mode 100644
index 0000000..eaa1246
--- /dev/null
+++ b/grub-core/commands/hexdump.c
@@ -0,0 +1,133 @@
+/* hexdump.c - command to dump the contents of a file or memory */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/lib/hexdump.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] = {
+ {"skip", 's', 0, N_("Skip offset bytes from the beginning of file."), 0,
+ ARG_TYPE_INT},
+ {"length", 'n', 0, N_("Read only LENGTH bytes."), 0, ARG_TYPE_INT},
+ {0, 0, 0, 0, 0, 0}
+};
+
+static grub_err_t
+grub_cmd_hexdump (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ char buf[GRUB_DISK_SECTOR_SIZE * 4];
+ grub_ssize_t size, length;
+ grub_disk_addr_t skip;
+ int namelen;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ namelen = grub_strlen (args[0]);
+ skip = (state[0].set) ? grub_strtoull (state[0].arg, 0, 0) : 0;
+ length = (state[1].set) ? grub_strtoul (state[1].arg, 0, 0) : 256;
+
+ if (!grub_strcmp (args[0], "(mem)"))
+ hexdump (skip, (char *) (grub_addr_t) skip, length);
+ else if ((args[0][0] == '(') && (args[0][namelen - 1] == ')'))
+ {
+ grub_disk_t disk;
+ grub_disk_addr_t sector;
+ grub_size_t ofs;
+
+ args[0][namelen - 1] = 0;
+ disk = grub_disk_open (&args[0][1]);
+ if (! disk)
+ return 0;
+
+ sector = (skip >> (GRUB_DISK_SECTOR_BITS + 2)) * 4;
+ ofs = skip & (GRUB_DISK_SECTOR_SIZE * 4 - 1);
+ while (length)
+ {
+ grub_size_t len;
+
+ len = length;
+ if (len > sizeof (buf))
+ len = sizeof (buf);
+
+ if (grub_disk_read (disk, sector, ofs, len, buf))
+ break;
+
+ hexdump (skip, buf, len);
+
+ ofs = 0;
+ skip += len;
+ length -= len;
+ sector += 4;
+ }
+
+ grub_disk_close (disk);
+ }
+ else
+ {
+ grub_file_t file;
+
+ file = grub_file_open (args[0], GRUB_FILE_TYPE_HEXCAT);
+ if (! file)
+ return 0;
+
+ file->offset = skip;
+
+ while ((size = grub_file_read (file, buf, sizeof (buf))) > 0)
+ {
+ unsigned long len;
+
+ len = ((length) && (size > length)) ? length : size;
+ hexdump (skip, buf, len);
+ skip += len;
+ if (length)
+ {
+ length -= len;
+ if (!length)
+ break;
+ }
+ }
+
+ grub_file_close (file);
+ }
+
+ return 0;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT (hexdump)
+{
+ cmd = grub_register_extcmd ("hexdump", grub_cmd_hexdump, 0,
+ N_("[OPTIONS] FILE_OR_DEVICE"),
+ N_("Show raw contents of a file or memory."),
+ options);
+}
+
+GRUB_MOD_FINI (hexdump)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/i386/cmosdump.c b/grub-core/commands/i386/cmosdump.c
new file mode 100644
index 0000000..626485c
--- /dev/null
+++ b/grub-core/commands/i386/cmosdump.c
@@ -0,0 +1,64 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,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/dl.h>
+#include <grub/command.h>
+#include <grub/misc.h>
+#include <grub/cmos.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_cmosdump (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)), char *argv[] __attribute__ ((unused)))
+{
+ int i;
+
+ for (i = 0; i < 256; i++)
+ {
+ grub_err_t err;
+ grub_uint8_t value;
+ if ((i & 0xf) == 0)
+ grub_printf ("%02x: ", i);
+
+ err = grub_cmos_read (i, &value);
+ if (err)
+ return err;
+
+ grub_printf ("%02x ", value);
+ if ((i & 0xf) == 0xf)
+ grub_printf ("\n");
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd;
+
+
+GRUB_MOD_INIT(cmosdump)
+{
+ cmd = grub_register_command ("cmosdump", grub_cmd_cmosdump,
+ 0,
+ N_("Show raw dump of the CMOS contents."));
+}
+
+GRUB_MOD_FINI(cmosdump)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/i386/cmostest.c b/grub-core/commands/i386/cmostest.c
new file mode 100644
index 0000000..9f6b56a
--- /dev/null
+++ b/grub-core/commands/i386/cmostest.c
@@ -0,0 +1,124 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/misc.h>
+#include <grub/cmos.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+parse_args (int argc, char *argv[], int *byte, int *bit)
+{
+ const char *rest;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "address required");
+
+ *byte = grub_strtoul (argv[0], &rest, 0);
+ if (*rest != ':')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "address required");
+
+ *bit = grub_strtoul (rest + 1, 0, 0);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ int byte = 0, bit = 0;
+ grub_err_t err;
+ grub_uint8_t value;
+
+ err = parse_args (argc, argv, &byte, &bit);
+ if (err)
+ return err;
+
+ err = grub_cmos_read (byte, &value);
+ if (err)
+ return err;
+
+ if (value & (1 << bit))
+ return GRUB_ERR_NONE;
+
+ return grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
+}
+
+static grub_err_t
+grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ int byte = 0, bit = 0;
+ grub_err_t err;
+ grub_uint8_t value;
+
+ err = parse_args (argc, argv, &byte, &bit);
+ if (err)
+ return err;
+ err = grub_cmos_read (byte, &value);
+ if (err)
+ return err;
+
+ return grub_cmos_write (byte, value & (~(1 << bit)));
+}
+
+static grub_err_t
+grub_cmd_cmosset (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ int byte = 0, bit = 0;
+ grub_err_t err;
+ grub_uint8_t value;
+
+ err = parse_args (argc, argv, &byte, &bit);
+ if (err)
+ return err;
+ err = grub_cmos_read (byte, &value);
+ if (err)
+ return err;
+
+ return grub_cmos_write (byte, value | (1 << bit));
+}
+
+static grub_command_t cmd, cmd_clean, cmd_set;
+
+
+GRUB_MOD_INIT(cmostest)
+{
+ cmd = grub_register_command ("cmostest", grub_cmd_cmostest,
+ N_("BYTE:BIT"),
+ N_("Test bit at BYTE:BIT in CMOS."));
+ cmd_clean = grub_register_command ("cmosclean", grub_cmd_cmosclean,
+ N_("BYTE:BIT"),
+ 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."));
+}
+
+GRUB_MOD_FINI(cmostest)
+{
+ grub_unregister_command (cmd);
+ grub_unregister_command (cmd_clean);
+ grub_unregister_command (cmd_set);
+}
diff --git a/grub-core/commands/i386/coreboot/cb_timestamps.c b/grub-core/commands/i386/coreboot/cb_timestamps.c
new file mode 100644
index 0000000..e97ea6b
--- /dev/null
+++ b/grub-core/commands/i386/coreboot/cb_timestamps.c
@@ -0,0 +1,126 @@
+/*
+ * 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/dl.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/coreboot/lbio.h>
+#include <grub/i386/tsc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_uint32_t
+tsc2ms (grub_uint64_t tsc)
+{
+ grub_uint64_t ah = tsc >> 32;
+ grub_uint64_t al = tsc & 0xffffffff;
+
+ return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate;
+}
+
+static const char *descs[] = {
+ [1] = "romstage",
+ [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",
+ [60] = "device initialize",
+ [70] = "device done",
+ [75] = "CBMEM POST",
+ [80] = "writing tables",
+ [90] = "loading payload",
+ [98] = "wake jump",
+ [99] = "selfboot jump",
+};
+
+static int
+iterate_linuxbios_table (grub_linuxbios_table_item_t table_item,
+ void *data)
+{
+ int *available = data;
+ grub_uint64_t last_tsc = 0;
+ struct grub_linuxbios_timestamp_table *ts_table;
+ unsigned i;
+
+ if (table_item->tag != GRUB_LINUXBIOS_MEMBER_TIMESTAMPS)
+ return 0;
+
+ *available = 1;
+ ts_table = (struct grub_linuxbios_timestamp_table *) (grub_addr_t)
+ *(grub_uint64_t *) (table_item + 1);
+
+ for (i = 0; i < ts_table->used; i++)
+ {
+ grub_uint32_t tmabs = tsc2ms (ts_table->entries[i].tsc);
+ grub_uint32_t tmrel = tsc2ms (ts_table->entries[i].tsc - last_tsc);
+ last_tsc = ts_table->entries[i].tsc;
+
+ grub_printf ("%3d.%03ds %2d.%03ds %02d %s\n",
+ tmabs / 1000, tmabs % 1000, tmrel / 1000, tmrel % 1000,
+ ts_table->entries[i].id,
+ (ts_table->entries[i].id < ARRAY_SIZE (descs)
+ && descs[ts_table->entries[i].id])
+ ? descs[ts_table->entries[i].id] : "");
+ }
+ return 1;
+}
+
+
+static grub_err_t
+grub_cmd_coreboot_boottime (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ int available = 0;
+
+ grub_linuxbios_table_iterate (iterate_linuxbios_table, &available);
+ if (!available)
+ {
+ grub_puts_ (N_("No boot time statistics is available\n"));
+ return 0;
+ }
+ return 0;
+}
+
+static grub_command_t cmd_boottime;
+
+GRUB_MOD_INIT(cbtime)
+{
+ cmd_boottime =
+ grub_register_command ("coreboot_boottime", grub_cmd_coreboot_boottime,
+ 0, N_("Show coreboot boot time statistics."));
+}
+
+GRUB_MOD_FINI(cbtime)
+{
+ grub_unregister_command (cmd_boottime);
+}
diff --git a/grub-core/commands/i386/coreboot/cbls.c b/grub-core/commands/i386/coreboot/cbls.c
new file mode 100644
index 0000000..102291f
--- /dev/null
+++ b/grub-core/commands/i386/coreboot/cbls.c
@@ -0,0 +1,143 @@
+/*
+ * 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/dl.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/coreboot/lbio.h>
+#include <grub/i386/tsc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const char *console_descs[] = {
+ "8250 UART",
+ "VGA",
+ "BTEXT",
+ "log buffer console",
+ "SROM",
+ "EHCI debug",
+ "memory-mapped 8250 UART"
+};
+
+static const char *descs[] = {
+ [GRUB_LINUXBIOS_MEMBER_MEMORY] = "memory map (`lsmmap' to list)",
+ [GRUB_LINUXBIOS_MEMBER_MAINBOARD] = "mainboard",
+ [4] = "version",
+ [5] = "extra version",
+ [6] = "build",
+ [7] = "compile time",
+ [8] = "compile by",
+ [9] = "compile host",
+ [0xa] = "compile domain",
+ [0xb] = "compiler",
+ [0xc] = "linker",
+ [0xd] = "assembler",
+ [0xf] = "serial",
+ [GRUB_LINUXBIOS_MEMBER_CONSOLE] = "console",
+ [GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER] = "framebuffer",
+ [0x13] = "GPIO",
+ [0x15] = "VDAT",
+ [GRUB_LINUXBIOS_MEMBER_TIMESTAMPS] = "timestamps (`coreboot_boottime' to list)",
+ [GRUB_LINUXBIOS_MEMBER_CBMEMC] = "CBMEM console (`cbmemc' to list)",
+ [0x18] = "MRC cache",
+ [0x19] = "VBNV",
+ [0xc8] = "CMOS option table",
+ [0xc9] = "CMOS option",
+ [0xca] = "CMOS option enum",
+ [0xcb] = "CMOS option defaults",
+ [0xcc] = "CMOS checksum",
+};
+
+static int
+iterate_linuxbios_table (grub_linuxbios_table_item_t table_item,
+ void *data __attribute__ ((unused)))
+{
+ if (table_item->tag < ARRAY_SIZE (descs) && descs[table_item->tag])
+ grub_printf ("tag=%02x size=%02x %s",
+ table_item->tag, table_item->size, descs[table_item->tag]);
+ else
+ grub_printf ("tag=%02x size=%02x",
+ table_item->tag, table_item->size);
+
+ switch (table_item->tag)
+ {
+ case GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER:
+ {
+ struct grub_linuxbios_table_framebuffer *fb;
+ fb = (struct grub_linuxbios_table_framebuffer *) (table_item + 1);
+
+ grub_printf (": %dx%dx%d pitch=%d lfb=0x%llx %d/%d/%d/%d %d/%d/%d/%d",
+ fb->width, fb->height,
+ fb->bpp, fb->pitch,
+ (unsigned long long) fb->lfb,
+ fb->red_mask_size, fb->green_mask_size,
+ fb->blue_mask_size, fb->reserved_mask_size,
+ fb->red_field_pos, fb->green_field_pos,
+ fb->blue_field_pos, fb->reserved_field_pos);
+ break;
+ }
+ case GRUB_LINUXBIOS_MEMBER_MAINBOARD:
+ {
+ struct grub_linuxbios_mainboard *mb;
+ mb = (struct grub_linuxbios_mainboard *) (table_item + 1);
+ grub_printf (": vendor=`%s' part_number=`%s'",
+ mb->strings + mb->vendor,
+ mb->strings + mb->part_number);
+ break;
+ }
+ case 0x04 ... 0x0d:
+ grub_printf (": `%s'", (char *) (table_item + 1));
+ break;
+ case GRUB_LINUXBIOS_MEMBER_CONSOLE:
+ {
+ grub_uint16_t *val = (grub_uint16_t *) (table_item + 1);
+ grub_printf (": id=%d", *val);
+ if (*val < ARRAY_SIZE (console_descs)
+ && console_descs[*val])
+ grub_printf (" %s", console_descs[*val]);
+ }
+ }
+ grub_printf ("\n");
+
+ return 0;
+}
+
+
+static grub_err_t
+grub_cmd_lscoreboot (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ grub_linuxbios_table_iterate (iterate_linuxbios_table, 0);
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(cbls)
+{
+ cmd =
+ grub_register_command ("lscoreboot", grub_cmd_lscoreboot,
+ 0, N_("List coreboot tables."));
+}
+
+GRUB_MOD_FINI(cbls)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/i386/cpuid.c b/grub-core/commands/i386/cpuid.c
new file mode 100644
index 0000000..42b9841
--- /dev/null
+++ b/grub-core/commands/i386/cpuid.c
@@ -0,0 +1,125 @@
+/* cpuid.c - test for CPU features */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
+ * Based on gcc/gcc/config/i386/driver-i386.c
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/command.h>
+#include <grub/extcmd.h>
+#include <grub/i386/cpuid.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ /* TRANSLATORS: "(default)" at the end means that this option is used if
+ no argument is specified. */
+ {"long-mode", 'l', 0, N_("Check if CPU supports 64-bit (long) mode (default)."), 0, 0},
+ {"pae", 'p', 0, N_("Check if CPU supports Physical Address Extension."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+enum
+ {
+ MODE_LM = 0,
+ MODE_PAE = 1
+ };
+
+enum
+ {
+ bit_PAE = (1 << 6),
+ };
+enum
+ {
+ bit_LM = (1 << 29)
+ };
+
+unsigned char grub_cpuid_has_longmode = 0, grub_cpuid_has_pae = 0;
+
+static grub_err_t
+grub_cmd_cpuid (grub_extcmd_context_t ctxt,
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ int val = 0;
+ if (ctxt->state[MODE_PAE].set)
+ val = grub_cpuid_has_pae;
+ else
+ val = grub_cpuid_has_longmode;
+ return val ? GRUB_ERR_NONE
+ /* TRANSLATORS: it's a standalone boolean value,
+ opposite of "true". */
+ : grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(cpuid)
+{
+#ifdef __x86_64__
+ /* grub-emu */
+ grub_cpuid_has_longmode = 1;
+ grub_cpuid_has_pae = 1;
+#else
+ unsigned int eax, ebx, ecx, edx;
+ unsigned int max_level;
+ unsigned int ext_level;
+
+ /* See if we can use cpuid. */
+ asm volatile ("pushfl; pushfl; popl %0; movl %0,%1; xorl %2,%0;"
+ "pushl %0; popfl; pushfl; popl %0; popfl"
+ : "=&r" (eax), "=&r" (ebx)
+ : "i" (0x00200000));
+ if (((eax ^ ebx) & 0x00200000) == 0)
+ goto done;
+
+ /* Check the highest input value for eax. */
+ grub_cpuid (0, eax, ebx, ecx, edx);
+ /* We only look at the first four characters. */
+ max_level = eax;
+ if (max_level == 0)
+ goto done;
+
+ if (max_level >= 1)
+ {
+ grub_cpuid (1, eax, ebx, ecx, edx);
+ grub_cpuid_has_pae = !!(edx & bit_PAE);
+ }
+
+ grub_cpuid (0x80000000, eax, ebx, ecx, edx);
+ ext_level = eax;
+ if (ext_level < 0x80000000)
+ goto done;
+
+ grub_cpuid (0x80000001, eax, ebx, ecx, edx);
+ grub_cpuid_has_longmode = !!(edx & bit_LM);
+done:
+#endif
+
+ cmd = grub_register_extcmd ("cpuid", grub_cmd_cpuid, 0,
+ "[-l]", N_("Check for CPU features."), options);
+}
+
+GRUB_MOD_FINI(cpuid)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/i386/pc/drivemap.c b/grub-core/commands/i386/pc/drivemap.c
new file mode 100644
index 0000000..7f7f2d4
--- /dev/null
+++ b/grub-core/commands/i386/pc/drivemap.c
@@ -0,0 +1,428 @@
+/* drivemap.c - command to manage the BIOS drive mappings. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/extcmd.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/loader.h>
+#include <grub/env.h>
+#include <grub/machine/biosnum.h>
+#include <grub/i18n.h>
+#include <grub/memory.h>
+#include <grub/machine/memory.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */
+static grub_uint32_t *const int13slot = (grub_uint32_t *) (4 * 0x13);
+
+/* Remember to update enum opt_idxs accordingly. */
+static const struct grub_arg_option options[] = {
+ /* TRANSLATORS: In this file "mapping" refers to a change GRUB makes so if
+ your language doesn't have an equivalent of "mapping" you can
+ use the word like "rerouting".
+ */
+ {"list", 'l', 0, N_("Show the current mappings."), 0, 0},
+ {"reset", 'r', 0, N_("Reset all mappings to the default values."), 0, 0},
+ {"swap", 's', 0, N_("Perform both direct and reverse mappings."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+};
+
+/* Remember to update options[] accordingly. */
+enum opt_idxs
+{
+ OPTIDX_LIST = 0,
+ OPTIDX_RESET,
+ OPTIDX_SWAP,
+};
+
+/* Realmode far ptr (2 * 16b) to the previous INT13h handler. */
+extern grub_uint32_t grub_drivemap_oldhandler;
+
+/* The type "void" is used for imported assembly labels, takes no storage and
+ serves just to take the address with &label. */
+
+/* The assembly function to replace the old INT13h handler. It does not follow
+ any C callspecs and returns with IRET. */
+extern const void grub_drivemap_handler;
+
+/* Start of the drive mappings area (space reserved at runtime). */
+extern const void grub_drivemap_mapstart;
+
+typedef struct drivemap_node
+{
+ struct drivemap_node *next;
+ grub_uint8_t newdrive;
+ grub_uint8_t redirto;
+} drivemap_node_t;
+
+typedef struct GRUB_PACKED int13map_node
+{
+ grub_uint8_t disknum;
+ grub_uint8_t mapto;
+} int13map_node_t;
+
+#define INT13H_OFFSET(x) \
+ (((grub_uint8_t *)(x)) - ((grub_uint8_t *)&grub_drivemap_handler))
+
+static drivemap_node_t *map_head;
+static void *drivemap_hook;
+static int drivemap_mmap;
+
+/* Puts the specified mapping into the table, replacing an existing mapping
+ for newdrive or adding a new one if required. */
+static grub_err_t
+drivemap_set (grub_uint8_t newdrive, grub_uint8_t redirto)
+{
+ drivemap_node_t *mapping = 0;
+ drivemap_node_t *search = map_head;
+ while (search)
+ {
+ if (search->newdrive == newdrive)
+ {
+ mapping = search;
+ break;
+ }
+ search = search->next;
+ }
+
+ /* Check for pre-existing mappings to modify before creating a new one. */
+ if (mapping)
+ mapping->redirto = redirto;
+ else
+ {
+ mapping = grub_malloc (sizeof (drivemap_node_t));
+ if (! mapping)
+ return grub_errno;
+ mapping->newdrive = newdrive;
+ mapping->redirto = redirto;
+ mapping->next = map_head;
+ map_head = mapping;
+ }
+ return GRUB_ERR_NONE;
+}
+
+/* Removes the mapping for newdrive from the table. If there is no mapping,
+ then this function behaves like a no-op on the map. */
+static void
+drivemap_remove (grub_uint8_t newdrive)
+{
+ drivemap_node_t *mapping = 0;
+ drivemap_node_t *search = map_head;
+ drivemap_node_t *previous = 0;
+
+ while (search)
+ {
+ if (search->newdrive == newdrive)
+ {
+ mapping = search;
+ break;
+ }
+ previous = search;
+ search = search->next;
+ }
+
+ if (mapping)
+ {
+ if (previous)
+ previous->next = mapping->next;
+ else
+ map_head = mapping->next;
+ grub_free (mapping);
+ }
+}
+
+/* Given a GRUB-like device name and a convenient location, stores the
+ related BIOS disk number. Accepts devices like \((f|h)dN\), with
+ 0 <= N < 128. */
+static grub_err_t
+tryparse_diskstring (const char *str, grub_uint8_t *output)
+{
+ /* Skip opening paren in order to allow both (hd0) and hd0. */
+ if (*str == '(')
+ str++;
+ if ((str[0] == 'f' || str[0] == 'h') && str[1] == 'd')
+ {
+ grub_uint8_t bios_num = (str[0] == 'h') ? 0x80 : 0x00;
+ unsigned long drivenum = grub_strtoul (str + 2, 0, 0);
+ if (grub_errno == GRUB_ERR_NONE && drivenum < 128)
+ {
+ bios_num |= drivenum;
+ if (output)
+ *output = bios_num;
+ return GRUB_ERR_NONE;
+ }
+ }
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "device format \"%s\" "
+ "invalid: must be (f|h)dN, with 0 <= N < 128", str);
+}
+
+static grub_err_t
+list_mappings (void)
+{
+ /* Show: list mappings. */
+ if (! map_head)
+ {
+ grub_puts_ (N_("No drives have been remapped"));
+ return GRUB_ERR_NONE;
+ }
+
+ /* TRANSLATORS: This is the header of mapping list.
+ On the left is how OS will see the disks and
+ on the right current GRUB vision. */
+ grub_puts_ (N_("OS disk #num ------> GRUB/BIOS device"));
+ drivemap_node_t *curnode = map_head;
+ while (curnode)
+ {
+ grub_printf ("%cD #%-3u (0x%02x) %cd%d\n",
+ (curnode->newdrive & 0x80) ? 'H' : 'F',
+ curnode->newdrive & 0x7F, curnode->newdrive,
+ (curnode->redirto & 0x80) ? 'h' : 'f',
+ curnode->redirto & 0x7F
+ );
+ curnode = curnode->next;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_drivemap (struct grub_extcmd_context *ctxt, int argc, char **args)
+{
+ if (ctxt->state[OPTIDX_LIST].set)
+ {
+ return list_mappings ();
+ }
+ else if (ctxt->state[OPTIDX_RESET].set)
+ {
+ /* Reset: just delete all mappings, freeing their memory. */
+ drivemap_node_t *curnode = map_head;
+ drivemap_node_t *prevnode = 0;
+ while (curnode)
+ {
+ prevnode = curnode;
+ curnode = curnode->next;
+ grub_free (prevnode);
+ }
+ map_head = 0;
+ return GRUB_ERR_NONE;
+ }
+ else if (!ctxt->state[OPTIDX_SWAP].set && argc == 0)
+ {
+ /* No arguments */
+ return list_mappings ();
+ }
+
+ /* Neither flag: put mapping. */
+ grub_uint8_t mapfrom = 0;
+ grub_uint8_t mapto = 0xFF;
+ grub_err_t err;
+
+ if (argc != 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+ err = tryparse_diskstring (args[0], &mapfrom);
+ if (err != GRUB_ERR_NONE)
+ return err;
+
+ err = tryparse_diskstring (args[1], &mapto);
+ if (err != GRUB_ERR_NONE)
+ return err;
+
+ if (mapto == mapfrom)
+ {
+ /* Reset to default. */
+ grub_dprintf ("drivemap", "Removing mapping for %s (%02x)\n",
+ args[0], mapfrom);
+ drivemap_remove (mapfrom);
+ return GRUB_ERR_NONE;
+ }
+ /* Set the mapping for the disk (overwrites any existing mapping). */
+ grub_dprintf ("drivemap", "%s %s (%02x) = %s (%02x)\n",
+ ctxt->state[OPTIDX_SWAP].set ? "Swapping" : "Mapping",
+ args[1], mapto, args[0], mapfrom);
+ err = drivemap_set (mapto, mapfrom);
+ /* If -s, perform the reverse mapping too (only if the first was OK). */
+ if (ctxt->state[OPTIDX_SWAP].set && err == GRUB_ERR_NONE)
+ err = drivemap_set (mapfrom, mapto);
+ return err;
+}
+
+/* Int13h handler installer - reserves conventional memory for the handler,
+ copies it over and sets the IVT entry for int13h.
+ This code rests on the assumption that GRUB does not activate any kind
+ of memory mapping apart from identity paging, since it accesses
+ realmode structures by their absolute addresses, like the IVT at 0;
+ and transforms a pmode pointer into a rmode seg:off far ptr. */
+static grub_err_t
+install_int13_handler (int noret __attribute__ ((unused)))
+{
+ /* Size of the full int13 handler "bundle", including code and map. */
+ grub_uint32_t total_size;
+ /* Base address of the space reserved for the handler bundle. */
+ grub_uint8_t *handler_base = 0;
+ /* Address of the map within the deployed bundle. */
+ int13map_node_t *handler_map;
+
+ int i;
+ int entries = 0;
+ drivemap_node_t *curentry = map_head;
+
+ /* Count entries to prepare a contiguous map block. */
+ while (curentry)
+ {
+ entries++;
+ curentry = curentry->next;
+ }
+ if (entries == 0)
+ {
+ /* No need to install the int13h handler. */
+ grub_dprintf ("drivemap", "No drives marked as remapped, not installing "
+ "our int13h handler.\n");
+ return GRUB_ERR_NONE;
+ }
+
+ grub_dprintf ("drivemap", "Installing our int13h handler\n");
+
+ /* Save the pointer to the old handler. */
+ grub_drivemap_oldhandler = *int13slot;
+ grub_dprintf ("drivemap", "Original int13 handler: %04x:%04x\n",
+ (grub_drivemap_oldhandler >> 16) & 0x0ffff,
+ grub_drivemap_oldhandler & 0x0ffff);
+
+ /* Find a rmode-segment-aligned zone in conventional memory big
+ enough to hold the handler and its data. */
+ total_size = INT13H_OFFSET (&grub_drivemap_mapstart)
+ + (entries + 1) * sizeof (int13map_node_t);
+ grub_dprintf ("drivemap", "Payload is %u bytes long\n", total_size);
+ handler_base = grub_mmap_malign_and_register (16, ALIGN_UP (total_size, 16),
+ &drivemap_mmap,
+ GRUB_MEMORY_RESERVED,
+ GRUB_MMAP_MALLOC_LOW);
+ if (! handler_base)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't reserve "
+ "memory for the int13h handler");
+
+ /* Copy int13h handler bundle to reserved area. */
+ grub_dprintf ("drivemap", "Reserved memory at %p, copying handler\n",
+ handler_base);
+ grub_memcpy (handler_base, &grub_drivemap_handler,
+ INT13H_OFFSET (&grub_drivemap_mapstart));
+
+ /* Copy the mappings to the reserved area. */
+ curentry = map_head;
+ handler_map = (int13map_node_t *) (handler_base +
+ INT13H_OFFSET (&grub_drivemap_mapstart));
+ grub_dprintf ("drivemap", "Target map at %p, copying mappings\n", handler_map);
+ for (i = 0; i < entries; ++i, curentry = curentry->next)
+ {
+ handler_map[i].disknum = curentry->newdrive;
+ handler_map[i].mapto = curentry->redirto;
+ grub_dprintf ("drivemap", "\t#%d: 0x%02x <- 0x%02x\n", i,
+ handler_map[i].disknum, handler_map[i].mapto);
+ }
+ /* Signal end-of-map. */
+ handler_map[i].disknum = 0;
+ handler_map[i].mapto = 0;
+ grub_dprintf ("drivemap", "\t#%d: 0x00 <- 0x00 (end)\n", i);
+
+ /* Install our function as the int13h handler in the IVT. */
+ *int13slot = ((grub_uint32_t) handler_base) << 12; /* Segment address. */
+ grub_dprintf ("drivemap", "New int13 handler: %04x:%04x\n",
+ (*int13slot >> 16) & 0x0ffff, *int13slot & 0x0ffff);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+uninstall_int13_handler (void)
+{
+ if (! grub_drivemap_oldhandler)
+ return GRUB_ERR_NONE;
+
+ *int13slot = grub_drivemap_oldhandler;
+ grub_mmap_free_and_unregister (drivemap_mmap);
+ grub_drivemap_oldhandler = 0;
+ grub_dprintf ("drivemap", "Restored int13 handler: %04x:%04x\n",
+ (*int13slot >> 16) & 0x0ffff, *int13slot & 0x0ffff);
+
+ return GRUB_ERR_NONE;
+}
+
+static int
+grub_get_root_biosnumber_drivemap (void)
+{
+ const char *biosnum;
+ int ret = -1;
+ grub_device_t dev;
+
+ biosnum = grub_env_get ("biosnum");
+
+ if (biosnum)
+ return grub_strtoul (biosnum, 0, 0);
+
+ dev = grub_device_open (0);
+ if (dev && dev->disk && dev->disk->dev
+ && dev->disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID)
+ {
+ drivemap_node_t *curnode = map_head;
+ ret = (int) dev->disk->id;
+ while (curnode)
+ {
+ if (curnode->redirto == ret)
+ {
+ ret = curnode->newdrive;
+ break;
+ }
+ curnode = curnode->next;
+ }
+
+ }
+
+ if (dev)
+ grub_device_close (dev);
+
+ return ret;
+}
+
+static grub_extcmd_t cmd;
+static int (*grub_get_root_biosnumber_saved) (void);
+
+GRUB_MOD_INIT (drivemap)
+{
+ grub_get_root_biosnumber_saved = grub_get_root_biosnumber;
+ grub_get_root_biosnumber = grub_get_root_biosnumber_drivemap;
+ cmd = grub_register_extcmd ("drivemap", grub_cmd_drivemap, 0,
+ N_("-l | -r | [-s] grubdev osdisk."),
+ N_("Manage the BIOS drive mappings."),
+ options);
+ drivemap_hook =
+ grub_loader_register_preboot_hook (&install_int13_handler,
+ &uninstall_int13_handler,
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_NORMAL);
+}
+
+GRUB_MOD_FINI (drivemap)
+{
+ grub_get_root_biosnumber = grub_get_root_biosnumber_saved;
+ grub_loader_unregister_preboot_hook (drivemap_hook);
+ drivemap_hook = 0;
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/i386/pc/drivemap_int13h.S b/grub-core/commands/i386/pc/drivemap_int13h.S
new file mode 100644
index 0000000..3c87521
--- /dev/null
+++ b/grub-core/commands/i386/pc/drivemap_int13h.S
@@ -0,0 +1,124 @@
+/* drivemap_int13h.S - interrupt handler for the BIOS drive remapper */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+
+#define INT13H_OFFSET(x) ((x) - LOCAL (base))
+
+.code16
+
+/* Copy starts here. When deployed, this code must be segment-aligned. */
+
+/* The replacement int13 handler. Preserve all registers. */
+FUNCTION(grub_drivemap_handler)
+LOCAL (base):
+ /* Save %dx for future restore. */
+ push %dx
+ /* Push flags. Used to simulate interrupt with original flags. */
+ pushf
+
+ /* Map the drive number (always in DL). */
+ push %ax
+ push %bx
+#ifdef __APPLE__
+ LOCAL(mapstart_offset) = INT13H_OFFSET(LOCAL (mapstart))
+ movw $LOCAL(mapstart_offset), %bx
+#else
+ movw $INT13H_OFFSET(LOCAL (mapstart)), %bx
+#endif
+
+more_remaining:
+ movw %cs:(%bx), %ax
+ cmpb %ah, %al
+ jz not_found /* DRV=DST => map end - drive not remapped, keep DL. */
+ inc %bx
+ inc %bx
+ cmpb %dl, %al
+ jnz more_remaining /* Not found, but more remaining, loop. */
+ movb %ah, %dl /* Found - drive remapped, modify DL. */
+
+not_found:
+ pop %bx
+ pop %ax
+
+ /* If the call isn't ah=0x8 or ah=0x15 we must restore %dx. */
+ cmpb $0x8, %ah
+ jz norestore
+ cmpb $0x15, %ah
+ jz norestore
+
+ /* Restore flags. */
+ popf
+ pushf
+
+#ifdef __APPLE__
+ LOCAL(oldhandler_offset) = INT13H_OFFSET (LOCAL (oldhandler))
+ lcall *%cs:LOCAL(oldhandler_offset)
+#else
+ lcall *%cs:INT13H_OFFSET (LOCAL (oldhandler))
+#endif
+
+ push %bp
+ mov %sp, %bp
+
+tail:
+ /* Save new flags below %esp so the caller will recieve new flags. */
+ pushf
+ pop %dx
+ mov %dx, 8(%bp)
+
+ pop %bp
+
+ /* Restore %dx. */
+ pop %dx
+ iret
+
+norestore:
+
+ /* Restore flags. */
+ popf
+ pushf
+
+#ifdef __APPLE__
+ lcall *%cs:LOCAL(oldhandler_offset)
+#else
+ lcall *%cs:INT13H_OFFSET (LOCAL (oldhandler))
+#endif
+
+ push %bp
+ mov %sp, %bp
+
+ /* Save %dx. So it won't be restored to original value. */
+ mov %dx, 2(%bp)
+
+ jmp tail
+
+/* Far pointer to the old handler. Stored as a CS:IP in the style of real-mode
+ IVT entries (thus PI:SC in mem). */
+VARIABLE(grub_drivemap_oldhandler)
+LOCAL (oldhandler):
+ .word 0x0, 0x0
+
+/* This label MUST be at the end of the copied block, since the installer code
+ reserves additional space for mappings at runtime and copies them over it. */
+ .align 2
+
+VARIABLE(grub_drivemap_mapstart)
+LOCAL (mapstart):
+ .byte 0
diff --git a/grub-core/commands/i386/pc/halt.c b/grub-core/commands/i386/pc/halt.c
new file mode 100644
index 0000000..1e7c2c9
--- /dev/null
+++ b/grub-core/commands/i386/pc/halt.c
@@ -0,0 +1,126 @@
+/* halt.c - command to halt the computer. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/machine/int.h>
+#include <grub/acpi.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ {"no-apm", 'n', 0, N_("Do not use APM to halt the computer."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static inline void __attribute__ ((noreturn))
+stop (void)
+{
+ while (1)
+ {
+ asm volatile ("hlt");
+ }
+}
+/*
+ * Halt the system, using APM if possible. If NO_APM is true, don't use
+ * APM even if it is available.
+ */
+void __attribute__ ((noreturn))
+grub_halt (int no_apm)
+{
+ struct grub_bios_int_registers regs;
+
+ grub_acpi_halt ();
+
+ if (no_apm)
+ stop ();
+
+ /* detect APM */
+ regs.eax = 0x5300;
+ regs.ebx = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x15, &regs);
+
+ if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
+ stop ();
+
+ /* disconnect APM first */
+ regs.eax = 0x5304;
+ regs.ebx = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x15, &regs);
+
+ /* connect APM */
+ regs.eax = 0x5301;
+ regs.ebx = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x15, &regs);
+ if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
+ stop ();
+
+ /* set APM protocol level - 1.1 or bust. (this covers APM 1.2 also) */
+ regs.eax = 0x530E;
+ regs.ebx = 0;
+ regs.ecx = 0x0101;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x15, &regs);
+ if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
+ stop ();
+
+ /* set the power state to off */
+ regs.eax = 0x5307;
+ regs.ebx = 1;
+ regs.ecx = 3;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x15, &regs);
+
+ /* shouldn't reach here */
+ stop ();
+}
+
+static grub_err_t __attribute__ ((noreturn))
+grub_cmd_halt (grub_extcmd_context_t ctxt,
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+
+{
+ struct grub_arg_list *state = ctxt->state;
+ int no_apm = 0;
+
+ if (state[0].set)
+ no_apm = 1;
+ grub_halt (no_apm);
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(halt)
+{
+ cmd = grub_register_extcmd ("halt", grub_cmd_halt, 0, "[-n]",
+ N_("Halt the system, if possible using APM."),
+ options);
+}
+
+GRUB_MOD_FINI(halt)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/i386/pc/lsapm.c b/grub-core/commands/i386/pc/lsapm.c
new file mode 100644
index 0000000..c82476d
--- /dev/null
+++ b/grub-core/commands/i386/pc/lsapm.c
@@ -0,0 +1,115 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/int.h>
+#include <grub/machine/apm.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+int
+grub_apm_get_info (struct grub_apm_info *info)
+{
+ struct grub_bios_int_registers regs;
+
+ /* detect APM */
+ regs.eax = 0x5300;
+ regs.ebx = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x15, &regs);
+
+ if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
+ return 0;
+ info->version = regs.eax & 0xffff;
+ info->flags = regs.ecx & 0xffff;
+
+ /* disconnect APM first */
+ regs.eax = 0x5304;
+ regs.ebx = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x15, &regs);
+
+ /* connect APM */
+ regs.eax = 0x5303;
+ regs.ebx = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x15, &regs);
+
+ if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
+ return 0;
+
+ info->cseg = regs.eax & 0xffff;
+ info->offset = regs.ebx;
+ info->cseg_16 = regs.ecx & 0xffff;
+ info->dseg = regs.edx & 0xffff;
+ info->cseg_len = regs.esi >> 16;
+ info->cseg_16_len = regs.esi & 0xffff;
+ info->dseg_len = regs.edi;
+
+ return 1;
+}
+
+static grub_err_t
+grub_cmd_lsapm (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)), char **args __attribute__ ((unused)))
+{
+ struct grub_apm_info info;
+ if (!grub_apm_get_info (&info))
+ return grub_error (GRUB_ERR_IO, N_("no APM found"));
+
+ grub_printf_ (N_("Version %u.%u\n"
+ "32-bit CS = 0x%x, len = 0x%x, offset = 0x%x\n"
+ "16-bit CS = 0x%x, len = 0x%x\n"
+ "DS = 0x%x, len = 0x%x\n"),
+ info.version >> 8, info.version & 0xff,
+ info.cseg, info.cseg_len, info.offset,
+ info.cseg_16, info.cseg_16_len,
+ info.dseg, info.dseg_len);
+ grub_xputs (info.flags & GRUB_APM_FLAGS_16BITPROTECTED_SUPPORTED
+ ? _("16-bit protected interface supported\n")
+ : _("16-bit protected interface unsupported\n"));
+ grub_xputs (info.flags & GRUB_APM_FLAGS_32BITPROTECTED_SUPPORTED
+ ? _("32-bit protected interface supported\n")
+ : _("32-bit protected interface unsupported\n"));
+ grub_xputs (info.flags & GRUB_APM_FLAGS_CPUIDLE_SLOWS_DOWN
+ ? _("CPU Idle slows down processor\n")
+ : _("CPU Idle doesn't slow down processor\n"));
+ grub_xputs (info.flags & GRUB_APM_FLAGS_DISABLED
+ ? _("APM disabled\n") : _("APM enabled\n"));
+ grub_xputs (info.flags & GRUB_APM_FLAGS_DISENGAGED
+ ? _("APM disengaged\n") : _("APM engaged\n"));
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lsapm)
+{
+ cmd = grub_register_command ("lsapm", grub_cmd_lsapm, 0,
+ N_("Show APM information."));
+}
+
+GRUB_MOD_FINI(lsapm)
+{
+ grub_unregister_command (cmd);
+}
+
+
diff --git a/grub-core/commands/i386/pc/play.c b/grub-core/commands/i386/pc/play.c
new file mode 100644
index 0000000..a980e46
--- /dev/null
+++ b/grub-core/commands/i386/pc/play.c
@@ -0,0 +1,197 @@
+/* play.c - command to play a tune */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Lots of this file is borrowed from GNU/Hurd generic-speaker driver. */
+
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/cpu/io.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/time.h>
+#include <grub/speaker.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define BASE_TEMPO (60 * 1000)
+
+
+#define T_REST ((grub_uint16_t) 0)
+#define T_FINE ((grub_uint16_t) -1)
+
+struct note
+{
+ grub_uint16_t pitch;
+ grub_uint16_t duration;
+};
+
+/* Returns whether playing should continue. */
+static int
+play (unsigned tempo, struct note *note)
+{
+ grub_uint64_t to;
+
+ if (note->pitch == T_FINE || grub_getkey_noblock () != GRUB_TERM_NO_KEY)
+ return 1;
+
+ grub_dprintf ("play", "pitch = %d, duration = %d\n", note->pitch,
+ note->duration);
+
+ switch (note->pitch)
+ {
+ case T_REST:
+ grub_speaker_beep_off ();
+ break;
+
+ default:
+ grub_speaker_beep_on (note->pitch);
+ break;
+ }
+
+ to = grub_get_time_ms () + BASE_TEMPO * note->duration / tempo;
+ while ((grub_get_time_ms () <= to)
+ && (grub_getkey_noblock () == GRUB_TERM_NO_KEY));
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ /* TRANSLATORS: It's musical notes, not the notes
+ you take. Play command expects arguments which can
+ be either a filename or tempo+notes.
+ This error happens if none is specified. */
+ N_("filename or tempo and notes expected"));
+
+ if (argc == 1)
+ {
+ struct note buf;
+ grub_uint32_t tempo;
+ grub_file_t file;
+
+ file = grub_file_open (args[0], GRUB_FILE_TYPE_AUDIO);
+
+ if (! file)
+ return grub_errno;
+
+ if (grub_file_read (file, &tempo, sizeof (tempo)) != sizeof (tempo))
+ {
+ grub_file_close (file);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
+ args[0]);
+ 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);
+
+ while (grub_file_read (file, &buf,
+ sizeof (struct note)) == sizeof (struct note))
+ {
+ buf.pitch = grub_le_to_cpu16 (buf.pitch);
+ buf.duration = grub_le_to_cpu16 (buf.duration);
+
+ if (play (tempo, &buf))
+ break;
+ }
+
+ grub_file_close (file);
+ }
+ else
+ {
+ const char *end;
+ unsigned tempo;
+ struct note note;
+ int i;
+
+ 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]);
+
+ grub_dprintf ("play","tempo = %d\n", tempo);
+
+ for (i = 1; i + 1 < argc; i += 2)
+ {
+ note.pitch = grub_strtoul (args[i], &end, 0);
+ if (grub_errno)
+ break;
+ if (*end)
+ {
+ grub_error (GRUB_ERR_BAD_NUMBER, N_("unrecognized number"));
+ break;
+ }
+
+ note.duration = grub_strtoul (args[i + 1], &end, 0);
+ if (grub_errno)
+ break;
+ if (*end)
+ {
+ grub_error (GRUB_ERR_BAD_NUMBER, N_("unrecognized number"));
+ break;
+ }
+
+ if (play (tempo, &note))
+ break;
+ }
+ }
+
+ grub_speaker_beep_off ();
+
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(play)
+{
+ cmd = grub_register_command ("play", grub_cmd_play,
+ N_("FILE | TEMPO [PITCH1 DURATION1] [PITCH2 DURATION2] ... "),
+ N_("Play a tune."));
+}
+
+GRUB_MOD_FINI(play)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/i386/pc/sendkey.c b/grub-core/commands/i386/pc/sendkey.c
new file mode 100644
index 0000000..26d9acd
--- /dev/null
+++ b/grub-core/commands/i386/pc/sendkey.c
@@ -0,0 +1,387 @@
+/* sendkey.c - fake keystroke. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/extcmd.h>
+#include <grub/cpu/io.h>
+#include <grub/loader.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv2+");
+
+static char sendkey[0x20];
+/* Length of sendkey. */
+static int keylen = 0;
+static int noled = 0;
+static const struct grub_arg_option options[] =
+ {
+ {"num", 'n', 0, N_("set numlock mode"), "[on|off]", ARG_TYPE_STRING},
+ {"caps", 'c', 0, N_("set capslock mode"), "[on|off]", ARG_TYPE_STRING},
+ {"scroll", 's', 0, N_("set scrolllock mode"), "[on|off]", ARG_TYPE_STRING},
+ {"insert", 0, 0, N_("set insert mode"), "[on|off]", ARG_TYPE_STRING},
+ {"pause", 0, 0, N_("set pause mode"), "[on|off]", ARG_TYPE_STRING},
+ {"left-shift", 0, 0, N_("press left shift"), "[on|off]", ARG_TYPE_STRING},
+ {"right-shift", 0, 0, N_("press right shift"), "[on|off]", ARG_TYPE_STRING},
+ {"sysrq", 0, 0, N_("press SysRq"), "[on|off]", ARG_TYPE_STRING},
+ {"numkey", 0, 0, N_("press NumLock key"), "[on|off]", ARG_TYPE_STRING},
+ {"capskey", 0, 0, N_("press CapsLock key"), "[on|off]", ARG_TYPE_STRING},
+ {"scrollkey", 0, 0, N_("press ScrollLock key"), "[on|off]", ARG_TYPE_STRING},
+ {"insertkey", 0, 0, N_("press Insert key"), "[on|off]", ARG_TYPE_STRING},
+ {"left-alt", 0, 0, N_("press left alt"), "[on|off]", ARG_TYPE_STRING},
+ {"right-alt", 0, 0, N_("press right alt"), "[on|off]", ARG_TYPE_STRING},
+ {"left-ctrl", 0, 0, N_("press left ctrl"), "[on|off]", ARG_TYPE_STRING},
+ {"right-ctrl", 0, 0, N_("press right ctrl"), "[on|off]", ARG_TYPE_STRING},
+ {"no-led", 0, 0, N_("don't update LED state"), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+static int simple_flag_offsets[]
+= {5, 6, 4, 7, 11, 1, 0, 10, 13, 14, 12, 15, 9, 3, 8, 2};
+
+static grub_uint32_t andmask = 0xffffffff, ormask = 0;
+
+struct
+keysym
+{
+ const char *unshifted_name; /* the name in unshifted state */
+ const char *shifted_name; /* the name in shifted state */
+ unsigned char unshifted_ascii; /* the ascii code in unshifted state */
+ unsigned char shifted_ascii; /* the ascii code in shifted state */
+ unsigned char keycode; /* keyboard scancode */
+};
+
+/* The table for key symbols. If the "shifted" member of an entry is
+ NULL, the entry does not have shifted state. Copied from GRUB Legacy setkey fuction */
+static struct keysym keysym_table[] =
+{
+ {"escape", 0, 0x1b, 0, 0x01},
+ {"1", "exclam", '1', '!', 0x02},
+ {"2", "at", '2', '@', 0x03},
+ {"3", "numbersign", '3', '#', 0x04},
+ {"4", "dollar", '4', '$', 0x05},
+ {"5", "percent", '5', '%', 0x06},
+ {"6", "caret", '6', '^', 0x07},
+ {"7", "ampersand", '7', '&', 0x08},
+ {"8", "asterisk", '8', '*', 0x09},
+ {"9", "parenleft", '9', '(', 0x0a},
+ {"0", "parenright", '0', ')', 0x0b},
+ {"minus", "underscore", '-', '_', 0x0c},
+ {"equal", "plus", '=', '+', 0x0d},
+ {"backspace", 0, '\b', 0, 0x0e},
+ {"tab", 0, '\t', 0, 0x0f},
+ {"q", "Q", 'q', 'Q', 0x10},
+ {"w", "W", 'w', 'W', 0x11},
+ {"e", "E", 'e', 'E', 0x12},
+ {"r", "R", 'r', 'R', 0x13},
+ {"t", "T", 't', 'T', 0x14},
+ {"y", "Y", 'y', 'Y', 0x15},
+ {"u", "U", 'u', 'U', 0x16},
+ {"i", "I", 'i', 'I', 0x17},
+ {"o", "O", 'o', 'O', 0x18},
+ {"p", "P", 'p', 'P', 0x19},
+ {"bracketleft", "braceleft", '[', '{', 0x1a},
+ {"bracketright", "braceright", ']', '}', 0x1b},
+ {"enter", 0, '\r', 0, 0x1c},
+ {"control", 0, 0, 0, 0x1d},
+ {"a", "A", 'a', 'A', 0x1e},
+ {"s", "S", 's', 'S', 0x1f},
+ {"d", "D", 'd', 'D', 0x20},
+ {"f", "F", 'f', 'F', 0x21},
+ {"g", "G", 'g', 'G', 0x22},
+ {"h", "H", 'h', 'H', 0x23},
+ {"j", "J", 'j', 'J', 0x24},
+ {"k", "K", 'k', 'K', 0x25},
+ {"l", "L", 'l', 'L', 0x26},
+ {"semicolon", "colon", ';', ':', 0x27},
+ {"quote", "doublequote", '\'', '"', 0x28},
+ {"backquote", "tilde", '`', '~', 0x29},
+ {"shift", 0, 0, 0, 0x2a},
+ {"backslash", "bar", '\\', '|', 0x2b},
+ {"z", "Z", 'z', 'Z', 0x2c},
+ {"x", "X", 'x', 'X', 0x2d},
+ {"c", "C", 'c', 'C', 0x2e},
+ {"v", "V", 'v', 'V', 0x2f},
+ {"b", "B", 'b', 'B', 0x30},
+ {"n", "N", 'n', 'N', 0x31},
+ {"m", "M", 'm', 'M', 0x32},
+ {"comma", "less", ',', '<', 0x33},
+ {"period", "greater", '.', '>', 0x34},
+ {"slash", "question", '/', '?', 0x35},
+ {"rshift", 0, 0, 0, 0x36},
+ {"numasterisk", 0, '*', 0, 0x37},
+ {"alt", 0, 0, 0, 0x38},
+ {"space", 0, ' ', 0, 0x39},
+ {"capslock", 0, 0, 0, 0x3a},
+ {"F1", 0, 0, 0, 0x3b},
+ {"F2", 0, 0, 0, 0x3c},
+ {"F3", 0, 0, 0, 0x3d},
+ {"F4", 0, 0, 0, 0x3e},
+ {"F5", 0, 0, 0, 0x3f},
+ {"F6", 0, 0, 0, 0x40},
+ {"F7", 0, 0, 0, 0x41},
+ {"F8", 0, 0, 0, 0x42},
+ {"F9", 0, 0, 0, 0x43},
+ {"F10", 0, 0, 0, 0x44},
+ {"num7", "numhome", '7', 0, 0x47},
+ {"num8", "numup", '8', 0, 0x48},
+ {"num9", "numpgup", '9', 0, 0x49},
+ {"numminus", 0, '-', 0, 0x4a},
+ {"num4", "numleft", '4', 0, 0x4b},
+ {"num5", "numcenter", '5', 0, 0x4c},
+ {"num6", "numright", '6', 0, 0x4d},
+ {"numplus", 0, '-', 0, 0x4e},
+ {"num1", "numend", '1', 0, 0x4f},
+ {"num2", "numdown", '2', 0, 0x50},
+ {"num3", "numpgdown", '3', 0, 0x51},
+ {"num0", "numinsert", '0', 0, 0x52},
+ {"numperiod", "numdelete", 0, 0x7f, 0x53},
+ {"F11", 0, 0, 0, 0x57},
+ {"F12", 0, 0, 0, 0x58},
+ {"numenter", 0, '\r', 0, 0xe0},
+ {"numslash", 0, '/', 0, 0xe0},
+ {"delete", 0, 0x7f, 0, 0xe0},
+ {"insert", 0, 0xe0, 0, 0x52},
+ {"home", 0, 0xe0, 0, 0x47},
+ {"end", 0, 0xe0, 0, 0x4f},
+ {"pgdown", 0, 0xe0, 0, 0x51},
+ {"pgup", 0, 0xe0, 0, 0x49},
+ {"down", 0, 0xe0, 0, 0x50},
+ {"up", 0, 0xe0, 0, 0x48},
+ {"left", 0, 0xe0, 0, 0x4b},
+ {"right", 0, 0xe0, 0, 0x4d}
+};
+
+/* Set a simple flag in flags variable
+ OUTOFFSET - offset of flag in FLAGS,
+ OP - action id
+*/
+static void
+grub_sendkey_set_simple_flag (int outoffset, int op)
+{
+ if (op == 2)
+ {
+ andmask |= (1 << outoffset);
+ ormask &= ~(1 << outoffset);
+ }
+ else
+ {
+ andmask &= (~(1 << outoffset));
+ if (op == 1)
+ ormask |= (1 << outoffset);
+ else
+ ormask &= ~(1 << outoffset);
+ }
+}
+
+static int
+grub_sendkey_parse_op (struct grub_arg_list state)
+{
+ if (! state.set)
+ return 2;
+
+ if (grub_strcmp (state.arg, "off") == 0 || grub_strcmp (state.arg, "0") == 0
+ || grub_strcmp (state.arg, "unpress") == 0)
+ return 0;
+
+ if (grub_strcmp (state.arg, "on") == 0 || grub_strcmp (state.arg, "1") == 0
+ || grub_strcmp (state.arg, "press") == 0)
+ return 1;
+
+ return 2;
+}
+
+static grub_uint32_t oldflags;
+
+static grub_err_t
+grub_sendkey_postboot (void)
+{
+ /* For convention: pointer to flags. */
+ grub_uint32_t *flags = (grub_uint32_t *) 0x417;
+
+ *flags = oldflags;
+
+ *((char *) 0x41a) = 0x1e;
+ *((char *) 0x41c) = 0x1e;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Set keyboard buffer to our sendkey */
+static grub_err_t
+grub_sendkey_preboot (int noret __attribute__ ((unused)))
+{
+ /* For convention: pointer to flags. */
+ grub_uint32_t *flags = (grub_uint32_t *) 0x417;
+
+ oldflags = *flags;
+
+ /* Set the sendkey. */
+ *((char *) 0x41a) = 0x1e;
+ *((char *) 0x41c) = keylen + 0x1e;
+ grub_memcpy ((char *) 0x41e, sendkey, 0x20);
+
+ /* Transform "any ctrl" to "right ctrl" flag. */
+ if (*flags & (1 << 8))
+ *flags &= ~(1 << 2);
+
+ /* Transform "any alt" to "right alt" flag. */
+ if (*flags & (1 << 9))
+ *flags &= ~(1 << 3);
+
+ *flags = (*flags & andmask) | ormask;
+
+ /* Transform "right ctrl" to "any ctrl" flag. */
+ if (*flags & (1 << 8))
+ *flags |= (1 << 2);
+
+ /* Transform "right alt" to "any alt" flag. */
+ if (*flags & (1 << 9))
+ *flags |= (1 << 3);
+
+ /* Write new LED state */
+ if (!noled)
+ {
+ int value = 0;
+ int failed;
+ /* Try 5 times */
+ for (failed = 0; failed < 5; failed++)
+ {
+ value = 0;
+ /* Send command change LEDs */
+ grub_outb (0xed, 0x60);
+
+ /* Wait */
+ do
+ value = grub_inb (0x60);
+ while ((value != 0xfa) && (value != 0xfe));
+
+ if (value == 0xfa)
+ {
+ /* Set new LEDs*/
+ grub_outb ((*flags >> 4) & 7, 0x60);
+ break;
+ }
+ }
+ }
+ return GRUB_ERR_NONE;
+}
+
+/* Helper for grub_cmd_sendkey. */
+static int
+find_key_code (char *key)
+{
+ unsigned 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)
+ return keysym_table[i].keycode;
+ else if (keysym_table[i].shifted_name
+ && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
+ return keysym_table[i].keycode;
+ }
+
+ return 0;
+}
+
+/* Helper for grub_cmd_sendkey. */
+static int
+find_ascii_code (char *key)
+{
+ unsigned 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)
+ return keysym_table[i].unshifted_ascii;
+ else if (keysym_table[i].shifted_name
+ && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
+ return keysym_table[i].shifted_ascii;
+ }
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+
+ andmask = 0xffffffff;
+ ormask = 0;
+
+ {
+ int i;
+
+ keylen = 0;
+
+ for (i = 0; i < argc && keylen < 0x20; i++)
+ {
+ int key_code;
+
+ key_code = find_key_code (args[i]);
+ if (key_code)
+ {
+ sendkey[keylen++] = find_ascii_code (args[i]);
+ sendkey[keylen++] = key_code;
+ }
+ }
+ }
+
+ {
+ unsigned 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[ARRAY_SIZE(simple_flag_offsets)].set);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd;
+static struct grub_preboot *preboot_hook;
+
+GRUB_MOD_INIT (sendkey)
+{
+ cmd = grub_register_extcmd ("sendkey", grub_cmd_sendkey, 0,
+ N_("[KEYSTROKE1] [KEYSTROKE2] ..."),
+ /* TRANSLATORS: It can emulate multiple
+ keypresses. */
+ N_("Emulate a keystroke sequence"), options);
+
+ preboot_hook
+ = grub_loader_register_preboot_hook (grub_sendkey_preboot,
+ grub_sendkey_postboot,
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_CONSOLE);
+}
+
+GRUB_MOD_FINI (sendkey)
+{
+ grub_unregister_extcmd (cmd);
+ grub_loader_unregister_preboot_hook (preboot_hook);
+}
diff --git a/grub-core/commands/i386/pc/smbios.c b/grub-core/commands/i386/pc/smbios.c
new file mode 100644
index 0000000..069d663
--- /dev/null
+++ b/grub-core/commands/i386/pc/smbios.c
@@ -0,0 +1,52 @@
+/* smbios.c - get smbios tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2019 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/acpi.h>
+#include <grub/smbios.h>
+#include <grub/misc.h>
+
+struct grub_smbios_eps *
+grub_machine_smbios_get_eps (void)
+{
+ grub_uint8_t *ptr;
+
+ grub_dprintf ("smbios", "Looking for SMBIOS EPS. Scanning BIOS\n");
+
+ for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16)
+ if (grub_memcmp (ptr, "_SM_", 4) == 0
+ && grub_byte_checksum (ptr, sizeof (struct grub_smbios_eps)) == 0)
+ return (struct grub_smbios_eps *) ptr;
+
+ return 0;
+}
+
+struct grub_smbios_eps3 *
+grub_machine_smbios_get_eps3 (void)
+{
+ grub_uint8_t *ptr;
+
+ grub_dprintf ("smbios", "Looking for SMBIOS3 EPS. Scanning BIOS\n");
+
+ for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16)
+ if (grub_memcmp (ptr, "_SM3_", 5) == 0
+ && grub_byte_checksum (ptr, sizeof (struct grub_smbios_eps3)) == 0)
+ return (struct grub_smbios_eps3 *) ptr;
+
+ return 0;
+}
diff --git a/grub-core/commands/i386/rdmsr.c b/grub-core/commands/i386/rdmsr.c
new file mode 100644
index 0000000..46c4346
--- /dev/null
+++ b/grub-core/commands/i386/rdmsr.c
@@ -0,0 +1,102 @@
+/* rdmsr.c - Read CPU model-specific registers. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2019 Free Software Foundation, Inc.
+ * Based on gcc/gcc/config/i386/driver-i386.c
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/command.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/i386/cpuid.h>
+#include <grub/i386/rdmsr.h>
+
+GRUB_MOD_LICENSE("GPLv3+");
+
+static grub_extcmd_t cmd_read;
+
+static const struct grub_arg_option options[] =
+{
+ {0, 'v', 0, N_("Save read value into variable VARNAME."),
+ N_("VARNAME"), ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+};
+
+static grub_err_t
+grub_cmd_msr_read (grub_extcmd_context_t ctxt, int argc, char **argv)
+{
+ grub_uint32_t manufacturer[3], max_cpuid, a, b, c, features, addr;
+ grub_uint64_t value;
+ const char *ptr;
+ char buf[sizeof("1122334455667788")];
+
+ /*
+ * The CPUID instruction should be used to determine whether MSRs
+ * are supported. (CPUID.01H:EDX[5] = 1)
+ */
+ if (! grub_cpu_is_cpuid_supported ())
+ return grub_error (GRUB_ERR_BUG, N_("unsupported instruction"));
+
+ grub_cpuid (0, max_cpuid, manufacturer[0], manufacturer[2], manufacturer[1]);
+
+ if (max_cpuid < 1)
+ return grub_error (GRUB_ERR_BUG, N_("unsupported instruction"));
+
+ grub_cpuid (1, a, b, c, features);
+
+ if (!(features & (1 << 5)))
+ return grub_error (GRUB_ERR_BUG, N_("unsupported instruction"));
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ grub_errno = GRUB_ERR_NONE;
+ ptr = argv[0];
+ addr = grub_strtoul (ptr, &ptr, 0);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+ if (*ptr != '\0')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
+
+ value = grub_msr_read (addr);
+
+ if (ctxt->state[0].set)
+ {
+ grub_snprintf (buf, sizeof(buf), "%llx", (unsigned long long) value);
+ grub_env_set (ctxt->state[0].arg, buf);
+ }
+ else
+ grub_printf ("0x%llx\n", (unsigned long long) value);
+
+ return GRUB_ERR_NONE;
+}
+
+GRUB_MOD_INIT(rdmsr)
+{
+ cmd_read = grub_register_extcmd ("rdmsr", grub_cmd_msr_read, 0, N_("ADDR"),
+ N_("Read a CPU model specific register."),
+ options);
+}
+
+GRUB_MOD_FINI(rdmsr)
+{
+ grub_unregister_extcmd (cmd_read);
+}
diff --git a/grub-core/commands/i386/wrmsr.c b/grub-core/commands/i386/wrmsr.c
new file mode 100644
index 0000000..1b143b8
--- /dev/null
+++ b/grub-core/commands/i386/wrmsr.c
@@ -0,0 +1,94 @@
+/* wrmsr.c - Write CPU model-specific registers. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2019 Free Software Foundation, Inc.
+ * Based on gcc/gcc/config/i386/driver-i386.c
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/command.h>
+#include <grub/extcmd.h>
+#include <grub/lockdown.h>
+#include <grub/i18n.h>
+#include <grub/i386/cpuid.h>
+#include <grub/i386/wrmsr.h>
+
+GRUB_MOD_LICENSE("GPLv3+");
+
+static grub_command_t cmd_write;
+
+static grub_err_t
+grub_cmd_msr_write (grub_command_t cmd __attribute__ ((unused)), int argc, char **argv)
+{
+ grub_uint32_t manufacturer[3], max_cpuid, a, b, c, features, addr;
+ grub_uint64_t value;
+ const char *ptr;
+
+ /*
+ * The CPUID instruction should be used to determine whether MSRs
+ * are supported. (CPUID.01H:EDX[5] = 1)
+ */
+ if (!grub_cpu_is_cpuid_supported ())
+ return grub_error (GRUB_ERR_BUG, N_("unsupported instruction"));
+
+ grub_cpuid (0, max_cpuid, manufacturer[0], manufacturer[2], manufacturer[1]);
+
+ if (max_cpuid < 1)
+ return grub_error (GRUB_ERR_BUG, N_("unsupported instruction"));
+
+ grub_cpuid (1, a, b, c, features);
+
+ if (!(features & (1 << 5)))
+ return grub_error (GRUB_ERR_BUG, N_("unsupported instruction"));
+
+ if (argc != 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+ grub_errno = GRUB_ERR_NONE;
+ ptr = argv[0];
+ addr = grub_strtoul (ptr, &ptr, 0);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+ if (*ptr != '\0')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
+
+ ptr = argv[1];
+ value = grub_strtoull (ptr, &ptr, 0);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+ if (*ptr != '\0')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
+
+ grub_msr_write (addr, value);
+
+ return GRUB_ERR_NONE;
+}
+
+GRUB_MOD_INIT(wrmsr)
+{
+ cmd_write = grub_register_command_lockdown ("wrmsr", grub_cmd_msr_write, N_("ADDR VALUE"),
+ N_("Write a value to a CPU model specific register."));
+}
+
+GRUB_MOD_FINI(wrmsr)
+{
+ grub_unregister_command (cmd_write);
+}
diff --git a/grub-core/commands/ieee1275/suspend.c b/grub-core/commands/ieee1275/suspend.c
new file mode 100644
index 0000000..b505485
--- /dev/null
+++ b/grub-core/commands/ieee1275/suspend.c
@@ -0,0 +1,51 @@
+/* suspend.c - command to suspend GRUB and return to Open Firmware */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_suspend (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_puts_ (N_("Run `go' to resume GRUB."));
+ grub_ieee1275_enter ();
+ grub_cls ();
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(ieee1275_suspend)
+{
+ cmd = grub_register_command ("suspend", grub_cmd_suspend,
+ 0, N_("Return to IEEE1275 prompt."));
+}
+
+GRUB_MOD_FINI(ieee1275_suspend)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/iorw.c b/grub-core/commands/iorw.c
new file mode 100644
index 0000000..584baec
--- /dev/null
+++ b/grub-core/commands/iorw.c
@@ -0,0 +1,156 @@
+/* memrw.c - command to read / write physical memory */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/env.h>
+#include <grub/cpu/io.h>
+#include <grub/i18n.h>
+#include <grub/lockdown.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_extcmd_t cmd_read_byte, cmd_read_word, cmd_read_dword;
+static grub_command_t cmd_write_byte, cmd_write_word, cmd_write_dword;
+
+static const struct grub_arg_option options[] =
+ {
+ {0, 'v', 0, N_("Save read value into variable VARNAME."),
+ N_("VARNAME"), ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+
+static grub_err_t
+grub_cmd_read (grub_extcmd_context_t ctxt, int argc, char **argv)
+{
+ grub_port_t addr;
+ grub_uint32_t value = 0;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ addr = grub_strtoul (argv[0], 0, 0);
+ switch (ctxt->extcmd->cmd->name[sizeof ("in") - 1])
+ {
+ case 'l':
+ value = grub_inl (addr);
+ break;
+
+ case 'w':
+ value = grub_inw (addr);
+ break;
+
+ case 'b':
+ value = grub_inb (addr);
+ break;
+ }
+
+ if (ctxt->state[0].set)
+ {
+ char buf[sizeof ("XXXXXXXX")];
+ grub_snprintf (buf, sizeof (buf), "%x", value);
+ grub_env_set (ctxt->state[0].arg, buf);
+ }
+ else
+ grub_printf ("0x%x\n", value);
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_write (grub_command_t cmd, int argc, char **argv)
+{
+ grub_port_t addr;
+ grub_uint32_t value;
+ grub_uint32_t mask = 0xffffffff;
+
+ if (argc != 2 && argc != 3)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+ addr = grub_strtoul (argv[0], 0, 0);
+ value = grub_strtoul (argv[1], 0, 0);
+ if (argc == 3)
+ mask = grub_strtoul (argv[2], 0, 0);
+ value &= mask;
+ switch (cmd->name[sizeof ("out") - 1])
+ {
+ case 'l':
+ if (mask != 0xffffffff)
+ grub_outl ((grub_inl (addr) & ~mask) | value, addr);
+ else
+ grub_outl (value, addr);
+ break;
+
+ case 'w':
+ if ((mask & 0xffff) != 0xffff)
+ grub_outw ((grub_inw (addr) & ~mask) | value, addr);
+ else
+ grub_outw (value, addr);
+ break;
+
+ case 'b':
+ if ((mask & 0xff) != 0xff)
+ grub_outb ((grub_inb (addr) & ~mask) | value, addr);
+ else
+ grub_outb (value, addr);
+ break;
+ }
+
+ return 0;
+}
+
+GRUB_MOD_INIT(memrw)
+{
+ cmd_read_byte =
+ grub_register_extcmd ("inb", grub_cmd_read, 0,
+ N_("PORT"), N_("Read 8-bit value from PORT."),
+ options);
+ cmd_read_word =
+ grub_register_extcmd ("inw", grub_cmd_read, 0,
+ N_("PORT"), N_("Read 16-bit value from PORT."),
+ options);
+ cmd_read_dword =
+ grub_register_extcmd ("inl", grub_cmd_read, 0,
+ N_("PORT"), N_("Read 32-bit value from PORT."),
+ options);
+ cmd_write_byte =
+ grub_register_command_lockdown ("outb", grub_cmd_write,
+ N_("PORT VALUE [MASK]"),
+ N_("Write 8-bit VALUE to PORT."));
+ cmd_write_word =
+ grub_register_command_lockdown ("outw", grub_cmd_write,
+ N_("PORT VALUE [MASK]"),
+ N_("Write 16-bit VALUE to PORT."));
+ cmd_write_dword =
+ grub_register_command_lockdown ("outl", grub_cmd_write,
+ N_("ADDR VALUE [MASK]"),
+ N_("Write 32-bit VALUE to PORT."));
+}
+
+GRUB_MOD_FINI(memrw)
+{
+ grub_unregister_extcmd (cmd_read_byte);
+ grub_unregister_extcmd (cmd_read_word);
+ grub_unregister_extcmd (cmd_read_dword);
+ grub_unregister_command (cmd_write_byte);
+ grub_unregister_command (cmd_write_word);
+ grub_unregister_command (cmd_write_dword);
+}
diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c
new file mode 100644
index 0000000..c05d612
--- /dev/null
+++ b/grub-core/commands/keylayouts.c
@@ -0,0 +1,307 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/term.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/time.h>
+#include <grub/dl.h>
+#include <grub/keyboard_layouts.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/file.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct grub_keyboard_layout layout_us = {
+ .keyboard_map = {
+ /* Keyboard errors. Handled by driver. */
+ /* 0x00 */ 0, 0, 0, 0,
+
+ /* 0x04 */ 'a', 'b', 'c', 'd',
+ /* 0x08 */ 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
+ /* 0x10 */ 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
+ /* 0x18 */ 'u', 'v', 'w', 'x', 'y', 'z', '1', '2',
+ /* 0x20 */ '3', '4', '5', '6', '7', '8', '9', '0',
+ /* 0x28 */ '\n', GRUB_TERM_ESC, GRUB_TERM_BACKSPACE, GRUB_TERM_TAB, ' ', '-', '=', '[',
+ /* According to usage table 0x31 should be mapped to '/'
+ but testing with real keyboard shows that 0x32 is remapped to '/'.
+ Map 0x31 to 0.
+ */
+ /* 0x30 */ ']', 0, '\\', ';', '\'', '`', ',', '.',
+ /* 0x39 is CapsLock. Handled by driver. */
+ /* 0x38 */ '/', 0, GRUB_TERM_KEY_F1, GRUB_TERM_KEY_F2,
+ /* 0x3c */ GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4,
+ /* 0x3e */ GRUB_TERM_KEY_F5, GRUB_TERM_KEY_F6,
+ /* 0x40 */ GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8,
+ /* 0x42 */ GRUB_TERM_KEY_F9, GRUB_TERM_KEY_F10,
+ /* 0x44 */ GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12,
+ /* PrtScr and ScrollLock. Not handled yet. */
+ /* 0x46 */ 0, 0,
+ /* 0x48 is Pause. Not handled yet. */
+ /* 0x48 */ 0, GRUB_TERM_KEY_INSERT,
+ /* 0x4a */ GRUB_TERM_KEY_HOME, GRUB_TERM_KEY_PPAGE,
+ /* 0x4c */ GRUB_TERM_KEY_DC, GRUB_TERM_KEY_END,
+ /* 0x4e */ GRUB_TERM_KEY_NPAGE, GRUB_TERM_KEY_RIGHT,
+ /* 0x50 */ GRUB_TERM_KEY_LEFT, GRUB_TERM_KEY_DOWN,
+ /* 0x53 is NumLock. Handled by driver. */
+ /* 0x52 */ GRUB_TERM_KEY_UP, 0,
+ /* 0x54 */ '/', '*',
+ /* 0x56 */ '-', '+',
+ /* 0x58 */ '\n', GRUB_TERM_KEY_END,
+ /* 0x5a */ GRUB_TERM_KEY_DOWN, GRUB_TERM_KEY_NPAGE,
+ /* 0x5c */ GRUB_TERM_KEY_LEFT, GRUB_TERM_KEY_CENTER,
+ /* 0x5e */ GRUB_TERM_KEY_RIGHT, GRUB_TERM_KEY_HOME,
+ /* 0x60 */ GRUB_TERM_KEY_UP, GRUB_TERM_KEY_PPAGE,
+ /* 0x62 */ GRUB_TERM_KEY_INSERT, GRUB_TERM_KEY_DC,
+ /* 0x64 */ '\\'
+ },
+ .keyboard_map_shift = {
+ /* Keyboard errors. Handled by driver. */
+ /* 0x00 */ 0, 0, 0, 0,
+
+ /* 0x04 */ 'A', 'B', 'C', 'D',
+ /* 0x08 */ 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
+ /* 0x10 */ 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+ /* 0x18 */ 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@',
+ /* 0x20 */ '#', '$', '%', '^', '&', '*', '(', ')',
+ /* 0x28 */ '\n' | GRUB_TERM_SHIFT, GRUB_TERM_ESC | GRUB_TERM_SHIFT,
+ /* 0x2a */ GRUB_TERM_BACKSPACE | GRUB_TERM_SHIFT, GRUB_TERM_TAB | GRUB_TERM_SHIFT,
+ /* 0x2c */ ' ' | GRUB_TERM_SHIFT, '_', '+', '{',
+ /* According to usage table 0x31 should be mapped to '/'
+ but testing with real keyboard shows that 0x32 is remapped to '/'.
+ Map 0x31 to 0.
+ */
+ /* 0x30 */ '}', 0, '|', ':', '"', '~', '<', '>',
+ /* 0x39 is CapsLock. Handled by driver. */
+ /* 0x38 */ '?', 0,
+ /* 0x3a */ GRUB_TERM_KEY_F1 | GRUB_TERM_SHIFT,
+ /* 0x3b */ GRUB_TERM_KEY_F2 | GRUB_TERM_SHIFT,
+ /* 0x3c */ GRUB_TERM_KEY_F3 | GRUB_TERM_SHIFT,
+ /* 0x3d */ GRUB_TERM_KEY_F4 | GRUB_TERM_SHIFT,
+ /* 0x3e */ GRUB_TERM_KEY_F5 | GRUB_TERM_SHIFT,
+ /* 0x3f */ GRUB_TERM_KEY_F6 | GRUB_TERM_SHIFT,
+ /* 0x40 */ GRUB_TERM_KEY_F7 | GRUB_TERM_SHIFT,
+ /* 0x41 */ GRUB_TERM_KEY_F8 | GRUB_TERM_SHIFT,
+ /* 0x42 */ GRUB_TERM_KEY_F9 | GRUB_TERM_SHIFT,
+ /* 0x43 */ GRUB_TERM_KEY_F10 | GRUB_TERM_SHIFT,
+ /* 0x44 */ GRUB_TERM_KEY_F11 | GRUB_TERM_SHIFT,
+ /* 0x45 */ GRUB_TERM_KEY_F12 | GRUB_TERM_SHIFT,
+ /* PrtScr and ScrollLock. Not handled yet. */
+ /* 0x46 */ 0, 0,
+ /* 0x48 is Pause. Not handled yet. */
+ /* 0x48 */ 0, GRUB_TERM_KEY_INSERT | GRUB_TERM_SHIFT,
+ /* 0x4a */ GRUB_TERM_KEY_HOME | GRUB_TERM_SHIFT,
+ /* 0x4b */ GRUB_TERM_KEY_PPAGE | GRUB_TERM_SHIFT,
+ /* 0x4c */ GRUB_TERM_KEY_DC | GRUB_TERM_SHIFT,
+ /* 0x4d */ GRUB_TERM_KEY_END | GRUB_TERM_SHIFT,
+ /* 0x4e */ GRUB_TERM_KEY_NPAGE | GRUB_TERM_SHIFT,
+ /* 0x4f */ GRUB_TERM_KEY_RIGHT | GRUB_TERM_SHIFT,
+ /* 0x50 */ GRUB_TERM_KEY_LEFT | GRUB_TERM_SHIFT,
+ /* 0x51 */ GRUB_TERM_KEY_DOWN | GRUB_TERM_SHIFT,
+ /* 0x53 is NumLock. Handled by driver. */
+ /* 0x52 */ GRUB_TERM_KEY_UP | GRUB_TERM_SHIFT, 0,
+ /* 0x54 */ '/', '*',
+ /* 0x56 */ '-', '+',
+ /* 0x58 */ '\n' | GRUB_TERM_SHIFT, '1', '2', '3', '4', '5','6', '7',
+ /* 0x60 */ '8', '9', '0', '.', '|'
+ }
+};
+
+static struct grub_keyboard_layout *grub_current_layout = &layout_us;
+
+static int
+map_key_core (int code, int status, int *alt_gr_consumed)
+{
+ *alt_gr_consumed = 0;
+
+ if (code >= GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE)
+ return 0;
+
+ if (status & GRUB_TERM_STATUS_RALT)
+ {
+ if (status & (GRUB_TERM_STATUS_LSHIFT | GRUB_TERM_STATUS_RSHIFT))
+ {
+ if (grub_current_layout->keyboard_map_shift_l3[code])
+ {
+ *alt_gr_consumed = 1;
+ return grub_current_layout->keyboard_map_shift_l3[code];
+ }
+ }
+ else if (grub_current_layout->keyboard_map_l3[code])
+ {
+ *alt_gr_consumed = 1;
+ return grub_current_layout->keyboard_map_l3[code];
+ }
+ }
+ if (status & (GRUB_TERM_STATUS_LSHIFT | GRUB_TERM_STATUS_RSHIFT))
+ return grub_current_layout->keyboard_map_shift[code];
+ else
+ return grub_current_layout->keyboard_map[code];
+}
+
+unsigned
+grub_term_map_key (grub_keyboard_key_t code, int status)
+{
+ int alt_gr_consumed = 0;
+ int key;
+
+ if (code >= 0x59 && code <= 0x63 && (status & GRUB_TERM_STATUS_NUM))
+ {
+ if (status & (GRUB_TERM_STATUS_RSHIFT | GRUB_TERM_STATUS_LSHIFT))
+ status &= ~(GRUB_TERM_STATUS_RSHIFT | GRUB_TERM_STATUS_LSHIFT);
+ else
+ status |= GRUB_TERM_STATUS_RSHIFT;
+ }
+
+ key = map_key_core (code, status, &alt_gr_consumed);
+
+ 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)
+ {
+ if ((key >= 'a') && (key <= 'z'))
+ key += 'A' - 'a';
+ else if ((key >= 'A') && (key <= 'Z'))
+ key += 'a' - 'A';
+ }
+
+ if ((status & GRUB_TERM_STATUS_LALT) ||
+ ((status & GRUB_TERM_STATUS_RALT) && !alt_gr_consumed))
+ key |= GRUB_TERM_ALT;
+ if (status & (GRUB_TERM_STATUS_LCTRL | GRUB_TERM_STATUS_RCTRL))
+ key |= GRUB_TERM_CTRL;
+
+ return key;
+}
+
+static grub_err_t
+grub_cmd_keymap (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ char *filename;
+ grub_file_t file;
+ grub_uint32_t version;
+ grub_uint8_t magic[GRUB_KEYBOARD_LAYOUTS_FILEMAGIC_SIZE];
+ struct grub_keyboard_layout *newmap = NULL;
+ unsigned i;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "file or layout name required");
+ if (argv[0][0] != '(' && argv[0][0] != '/' && argv[0][0] != '+')
+ {
+ const char *prefix = grub_env_get ("prefix");
+ if (!prefix)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("variable `%s' isn't set"), "prefix");
+ filename = grub_xasprintf ("%s/layouts/%s.gkb", prefix, argv[0]);
+ if (!filename)
+ return grub_errno;
+ }
+ else
+ filename = argv[0];
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_KEYBOARD_LAYOUT);
+ if (! file)
+ goto fail;
+
+ if (grub_file_read (file, magic, sizeof (magic)) != sizeof (magic))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("premature end of file %s"),
+ filename);
+ goto fail;
+ }
+
+ if (grub_memcmp (magic, GRUB_KEYBOARD_LAYOUTS_FILEMAGIC,
+ GRUB_KEYBOARD_LAYOUTS_FILEMAGIC_SIZE) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid magic");
+ goto fail;
+ }
+
+ if (grub_file_read (file, &version, sizeof (version)) != sizeof (version))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("premature end of file %s"),
+ filename);
+ goto fail;
+ }
+
+ if (version != grub_cpu_to_le32_compile_time (GRUB_KEYBOARD_LAYOUTS_VERSION))
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid version");
+ goto fail;
+ }
+
+ newmap = grub_malloc (sizeof (*newmap));
+ if (!newmap)
+ goto fail;
+
+ if (grub_file_read (file, newmap, sizeof (*newmap)) != sizeof (*newmap))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("premature end of file %s"),
+ filename);
+ goto fail;
+ }
+
+ for (i = 0; i < ARRAY_SIZE (newmap->keyboard_map); i++)
+ newmap->keyboard_map[i] = grub_le_to_cpu32(newmap->keyboard_map[i]);
+
+ for (i = 0; i < ARRAY_SIZE (newmap->keyboard_map_shift); i++)
+ newmap->keyboard_map_shift[i]
+ = grub_le_to_cpu32(newmap->keyboard_map_shift[i]);
+
+ for (i = 0; i < ARRAY_SIZE (newmap->keyboard_map_l3); i++)
+ newmap->keyboard_map_l3[i]
+ = grub_le_to_cpu32(newmap->keyboard_map_l3[i]);
+
+ for (i = 0; i < ARRAY_SIZE (newmap->keyboard_map_shift_l3); i++)
+ newmap->keyboard_map_shift_l3[i]
+ = grub_le_to_cpu32(newmap->keyboard_map_shift_l3[i]);
+
+ grub_current_layout = newmap;
+
+ return GRUB_ERR_NONE;
+
+ fail:
+ if (filename != argv[0])
+ grub_free (filename);
+ grub_free (newmap);
+ if (file)
+ grub_file_close (file);
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(keylayouts)
+{
+ cmd = grub_register_command ("keymap", grub_cmd_keymap,
+ 0, N_("Load a keyboard layout."));
+}
+
+GRUB_MOD_FINI(keylayouts)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/keystatus.c b/grub-core/commands/keystatus.c
new file mode 100644
index 0000000..ff3f587
--- /dev/null
+++ b/grub-core/commands/keystatus.c
@@ -0,0 +1,95 @@
+/* keystatus.c - Command to check key modifier status. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/term.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ /* TRANSLATORS: "Check" in a sense that if this key is pressed then
+ "true" is returned, otherwise "false". */
+ {"shift", 's', 0, N_("Check Shift key."), 0, 0},
+ {"ctrl", 'c', 0, N_("Check Control key."), 0, 0},
+ {"alt", 'a', 0, N_("Check Alt key."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+grub_cmd_keystatus (grub_extcmd_context_t ctxt,
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ struct grub_arg_list *state = ctxt->state;
+ int expect_mods = 0;
+ int mods;
+
+ if (state[0].set)
+ expect_mods |= (GRUB_TERM_STATUS_LSHIFT | GRUB_TERM_STATUS_RSHIFT);
+ if (state[1].set)
+ expect_mods |= (GRUB_TERM_STATUS_LCTRL | GRUB_TERM_STATUS_RCTRL);
+ if (state[2].set)
+ expect_mods |= (GRUB_TERM_STATUS_LALT | GRUB_TERM_STATUS_RALT);
+
+ grub_dprintf ("keystatus", "expect_mods: %d\n", expect_mods);
+
+ /* Without arguments, just check whether getkeystatus is supported at
+ all. */
+ if (expect_mods == 0)
+ {
+ grub_term_input_t term;
+ int nterms = 0;
+
+ FOR_ACTIVE_TERM_INPUTS (term)
+ if (!term->getkeystatus)
+ return grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
+ else
+ nterms++;
+ if (!nterms)
+ return grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
+ return 0;
+ }
+
+ mods = grub_getkeystatus ();
+ grub_dprintf ("keystatus", "mods: %d\n", mods);
+ if (mods >= 0 && (mods & expect_mods) != 0)
+ return 0;
+ else
+ return grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(keystatus)
+{
+ cmd = grub_register_extcmd ("keystatus", grub_cmd_keystatus, 0,
+ "[--shift] [--ctrl] [--alt]",
+ /* TRANSLATORS: there are 3 modifiers. */
+ N_("Check key modifier status."),
+ options);
+}
+
+GRUB_MOD_FINI(keystatus)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c
new file mode 100644
index 0000000..cc5971f
--- /dev/null
+++ b/grub-core/commands/legacycfg.c
@@ -0,0 +1,912 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000, 2001, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/normal.h>
+#include <grub/script_sh.h>
+#include <grub/i18n.h>
+#include <grub/term.h>
+#include <grub/legacy_parse.h>
+#include <grub/crypto.h>
+#include <grub/auth.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Helper for legacy_file. */
+static grub_err_t
+legacy_file_getline (char **line, int cont __attribute__ ((unused)),
+ void *data __attribute__ ((unused)))
+{
+ *line = 0;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+legacy_file (const char *filename)
+{
+ grub_file_t file;
+ char *entryname = NULL, *entrysrc = NULL;
+ grub_menu_t menu;
+ char *suffix = grub_strdup ("");
+
+ if (!suffix)
+ return grub_errno;
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_CONFIG);
+ if (! file)
+ {
+ grub_free (suffix);
+ return grub_errno;
+ }
+
+ menu = grub_env_get_menu ();
+ if (! menu)
+ {
+ menu = grub_zalloc (sizeof (*menu));
+ if (! menu)
+ {
+ grub_free (suffix);
+ return grub_errno;
+ }
+
+ grub_env_set_menu (menu);
+ }
+
+ while (1)
+ {
+ char *buf = grub_file_getline (file);
+ char *parsed = NULL;
+
+ if (!buf && grub_errno)
+ {
+ grub_file_close (file);
+ grub_free (suffix);
+ return grub_errno;
+ }
+
+ if (!buf)
+ break;
+
+ {
+ char *oldname = NULL;
+ char *newsuffix;
+ char *ptr;
+
+ for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++);
+
+ oldname = entryname;
+ parsed = grub_legacy_parse (ptr, &entryname, &newsuffix);
+ grub_free (buf);
+ buf = NULL;
+ if (newsuffix)
+ {
+ char *t;
+ grub_size_t sz;
+
+ if (grub_add (grub_strlen (suffix), grub_strlen (newsuffix), &sz) ||
+ grub_add (sz, 1, &sz))
+ {
+ grub_errno = GRUB_ERR_OUT_OF_RANGE;
+ goto fail_0;
+ }
+
+ t = suffix;
+ suffix = grub_realloc (suffix, sz);
+ if (!suffix)
+ {
+ grub_free (t);
+
+ fail_0:
+ grub_free (entrysrc);
+ grub_free (parsed);
+ grub_free (newsuffix);
+ grub_free (suffix);
+ return grub_errno;
+ }
+ grub_memcpy (suffix + grub_strlen (suffix), newsuffix,
+ grub_strlen (newsuffix) + 1);
+ grub_free (newsuffix);
+ newsuffix = NULL;
+ }
+ if (oldname != entryname && oldname)
+ {
+ const char **args = grub_malloc (sizeof (args[0]));
+ if (!args)
+ {
+ grub_file_close (file);
+ return grub_errno;
+ }
+ args[0] = oldname;
+ grub_normal_add_menu_entry (1, args, NULL, NULL, "legacy",
+ NULL, NULL,
+ entrysrc, 0);
+ grub_free (args);
+ entrysrc[0] = 0;
+ grub_free (oldname);
+ }
+ }
+
+ if (parsed && !entryname)
+ {
+ grub_normal_parse_line (parsed, legacy_file_getline, NULL);
+ grub_print_error ();
+ grub_free (parsed);
+ parsed = NULL;
+ }
+ else if (parsed)
+ {
+ if (!entrysrc)
+ entrysrc = parsed;
+ else
+ {
+ char *t;
+ grub_size_t sz;
+
+ if (grub_add (grub_strlen (entrysrc), grub_strlen (parsed), &sz) ||
+ grub_add (sz, 1, &sz))
+ {
+ grub_errno = GRUB_ERR_OUT_OF_RANGE;
+ goto fail_1;
+ }
+
+ t = entrysrc;
+ entrysrc = grub_realloc (entrysrc, sz);
+ if (!entrysrc)
+ {
+ grub_free (t);
+
+ fail_1:
+ grub_free (parsed);
+ grub_free (suffix);
+ return grub_errno;
+ }
+ grub_memcpy (entrysrc + grub_strlen (entrysrc), parsed,
+ grub_strlen (parsed) + 1);
+ grub_free (parsed);
+ parsed = NULL;
+ }
+ }
+ }
+ grub_file_close (file);
+
+ if (entryname)
+ {
+ const char **args = grub_malloc (sizeof (args[0]));
+ if (!args)
+ {
+ grub_file_close (file);
+ grub_free (suffix);
+ grub_free (entrysrc);
+ return grub_errno;
+ }
+ args[0] = entryname;
+ grub_normal_add_menu_entry (1, args, NULL, NULL, NULL,
+ NULL, NULL, entrysrc, 0);
+ grub_free (args);
+ }
+
+ grub_normal_parse_line (suffix, legacy_file_getline, NULL);
+ grub_print_error ();
+ grub_free (suffix);
+ grub_free (entrysrc);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_legacy_source (struct grub_command *cmd,
+ int argc, char **args)
+{
+ int new_env, extractor;
+ grub_err_t ret;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ extractor = (cmd->name[0] == 'e');
+ new_env = (cmd->name[extractor ? (sizeof ("extract_legacy_entries_") - 1)
+ : (sizeof ("legacy_") - 1)] == 'c');
+
+ if (new_env)
+ grub_cls ();
+
+ if (new_env && !extractor)
+ grub_env_context_open ();
+ if (extractor)
+ grub_env_extractor_open (!new_env);
+
+ ret = legacy_file (args[0]);
+
+ if (new_env)
+ {
+ grub_menu_t menu;
+ menu = grub_env_get_menu ();
+ if (menu && menu->size)
+ grub_show_menu (menu, 1, 0);
+ if (!extractor)
+ grub_env_context_close ();
+ }
+ if (extractor)
+ grub_env_extractor_close (!new_env);
+
+ return ret;
+}
+
+static enum
+ {
+ GUESS_IT, LINUX, MULTIBOOT, KFREEBSD, KNETBSD, KOPENBSD
+ } kernel_type;
+
+static grub_err_t
+grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ int i;
+#ifdef TODO
+ int no_mem_option = 0;
+#endif
+ struct grub_command *cmd;
+ char **cutargs;
+ int cutargc;
+ grub_err_t err = GRUB_ERR_NONE;
+
+ for (i = 0; i < 2; i++)
+ {
+ /* FIXME: really support this. */
+ if (argc >= 1 && grub_strcmp (args[0], "--no-mem-option") == 0)
+ {
+#ifdef TODO
+ no_mem_option = 1;
+#endif
+ argc--;
+ args++;
+ continue;
+ }
+
+ /* linux16 handles both zImages and bzImages. */
+ if (argc >= 1 && (grub_strcmp (args[0], "--type=linux") == 0
+ || grub_strcmp (args[0], "--type=biglinux") == 0))
+ {
+ kernel_type = LINUX;
+ argc--;
+ args++;
+ continue;
+ }
+
+ if (argc >= 1 && grub_strcmp (args[0], "--type=multiboot") == 0)
+ {
+ kernel_type = MULTIBOOT;
+ argc--;
+ args++;
+ continue;
+ }
+
+ if (argc >= 1 && grub_strcmp (args[0], "--type=freebsd") == 0)
+ {
+ kernel_type = KFREEBSD;
+ argc--;
+ args++;
+ continue;
+ }
+
+ if (argc >= 1 && grub_strcmp (args[0], "--type=openbsd") == 0)
+ {
+ kernel_type = KOPENBSD;
+ argc--;
+ args++;
+ continue;
+ }
+
+ if (argc >= 1 && grub_strcmp (args[0], "--type=netbsd") == 0)
+ {
+ kernel_type = KNETBSD;
+ argc--;
+ args++;
+ continue;
+ }
+ }
+
+ if (argc < 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ cutargs = grub_calloc (argc - 1, sizeof (cutargs[0]));
+ if (!cutargs)
+ return grub_errno;
+ cutargc = argc - 1;
+ grub_memcpy (cutargs + 1, args + 2, sizeof (cutargs[0]) * (argc - 2));
+ cutargs[0] = args[0];
+
+ do
+ {
+ /* First try Linux. */
+ if (kernel_type == GUESS_IT || kernel_type == LINUX)
+ {
+#ifdef GRUB_MACHINE_PCBIOS
+ cmd = grub_command_find ("linux16");
+#else
+ cmd = grub_command_find ("linux");
+#endif
+ if (cmd)
+ {
+ if (!(cmd->func) (cmd, cutargc, cutargs))
+ {
+ kernel_type = LINUX;
+ goto out;
+ }
+ }
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ /* Then multiboot. */
+ if (kernel_type == GUESS_IT || kernel_type == MULTIBOOT)
+ {
+ cmd = grub_command_find ("multiboot");
+ if (cmd)
+ {
+ if (!(cmd->func) (cmd, argc, args))
+ {
+ kernel_type = MULTIBOOT;
+ goto out;
+ }
+ }
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ {
+ int bsd_device = -1;
+ int bsd_slice = -1;
+ int bsd_part = -1;
+ {
+ grub_device_t dev;
+ const char *hdbiasstr;
+ int hdbias = 0;
+ hdbiasstr = grub_env_get ("legacy_hdbias");
+ if (hdbiasstr)
+ {
+ hdbias = grub_strtoul (hdbiasstr, 0, 0);
+ grub_errno = GRUB_ERR_NONE;
+ }
+ dev = grub_device_open (0);
+ if (dev && dev->disk
+ && dev->disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID
+ && dev->disk->id >= 0x80 && dev->disk->id <= 0x90)
+ {
+ struct grub_partition *part = dev->disk->partition;
+ bsd_device = dev->disk->id - 0x80 - hdbias;
+ if (part && (grub_strcmp (part->partmap->name, "netbsd") == 0
+ || grub_strcmp (part->partmap->name, "openbsd") == 0
+ || grub_strcmp (part->partmap->name, "bsd") == 0))
+ {
+ bsd_part = part->number;
+ part = part->parent;
+ }
+ 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. */
+ if (kernel_type == GUESS_IT || kernel_type == KFREEBSD)
+ {
+ char buf[sizeof("adXXXXXXXXXXXXsXXXXXXXXXXXXYYY")];
+ if (bsd_device != -1)
+ {
+ if (bsd_slice != -1 && bsd_part != -1)
+ grub_snprintf(buf, sizeof(buf), "ad%ds%d%c", bsd_device,
+ bsd_slice, 'a' + bsd_part);
+ else if (bsd_slice != -1)
+ grub_snprintf(buf, sizeof(buf), "ad%ds%d", bsd_device,
+ bsd_slice);
+ else
+ grub_snprintf(buf, sizeof(buf), "ad%d", bsd_device);
+ grub_env_set ("kFreeBSD.vfs.root.mountfrom", buf);
+ }
+ else
+ grub_env_unset ("kFreeBSD.vfs.root.mountfrom");
+ cmd = grub_command_find ("kfreebsd");
+ if (cmd)
+ {
+ if (!(cmd->func) (cmd, cutargc, cutargs))
+ {
+ kernel_type = KFREEBSD;
+ goto out;
+ }
+ }
+ grub_errno = GRUB_ERR_NONE;
+ }
+ {
+ char **bsdargs;
+ int bsdargc;
+ char bsddevname[sizeof ("wdXXXXXXXXXXXXY")];
+ int found = 0;
+
+ if (bsd_device == -1)
+ {
+ bsdargs = cutargs;
+ bsdargc = cutargc;
+ }
+ else
+ {
+ char rbuf[3] = "-r";
+ bsdargc = cutargc + 2;
+ bsdargs = grub_calloc (bsdargc, sizeof (bsdargs[0]));
+ if (!bsdargs)
+ {
+ err = grub_errno;
+ goto out;
+ }
+ grub_memcpy (bsdargs, args, argc * sizeof (bsdargs[0]));
+ bsdargs[argc] = rbuf;
+ bsdargs[argc + 1] = bsddevname;
+ grub_snprintf (bsddevname, sizeof (bsddevname),
+ "wd%d%c", bsd_device,
+ bsd_part != -1 ? bsd_part + 'a' : 'c');
+ }
+ if (kernel_type == GUESS_IT || kernel_type == KNETBSD)
+ {
+ cmd = grub_command_find ("knetbsd");
+ if (cmd)
+ {
+ if (!(cmd->func) (cmd, bsdargc, bsdargs))
+ {
+ kernel_type = KNETBSD;
+ found = 1;
+ goto free_bsdargs;
+ }
+ }
+ grub_errno = GRUB_ERR_NONE;
+ }
+ if (kernel_type == GUESS_IT || kernel_type == KOPENBSD)
+ {
+ cmd = grub_command_find ("kopenbsd");
+ if (cmd)
+ {
+ if (!(cmd->func) (cmd, bsdargc, bsdargs))
+ {
+ kernel_type = KOPENBSD;
+ found = 1;
+ goto free_bsdargs;
+ }
+ }
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+free_bsdargs:
+ if (bsdargs != cutargs)
+ grub_free (bsdargs);
+ if (found)
+ goto out;
+ }
+ }
+ }
+ while (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
+grub_cmd_legacy_initrd (struct grub_command *mycmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_command *cmd;
+
+ if (kernel_type == LINUX)
+ {
+#ifdef GRUB_MACHINE_PCBIOS
+ cmd = grub_command_find ("initrd16");
+#else
+ cmd = grub_command_find ("initrd");
+#endif
+ if (!cmd)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"),
+#ifdef GRUB_MACHINE_PCBIOS
+ "initrd16"
+#else
+ "initrd"
+#endif
+ );
+
+ return cmd->func (cmd, argc ? 1 : 0, args);
+ }
+ if (kernel_type == MULTIBOOT)
+ {
+ cmd = grub_command_find ("module");
+ if (!cmd)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"),
+ "module");
+
+ return cmd->func (cmd, argc, args);
+ }
+
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("you need to load the kernel first"));
+}
+
+static grub_err_t
+grub_cmd_legacy_initrdnounzip (struct grub_command *mycmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_command *cmd;
+
+ if (kernel_type == LINUX)
+ {
+ cmd = grub_command_find ("initrd16");
+ if (!cmd)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"),
+ "initrd16");
+
+ return cmd->func (cmd, argc, args);
+ }
+ if (kernel_type == MULTIBOOT)
+ {
+ 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_calloc (argc + 1, sizeof (newargs[0]));
+ if (!newargs)
+ return grub_errno;
+ grub_memcpy (newargs + 1, args, argc * sizeof (newargs[0]));
+ newargs[0] = nounzipbuf;
+
+ err = cmd->func (cmd, argc + 1, newargs);
+ grub_free (newargs);
+ return err;
+ }
+
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("you need to load the kernel first"));
+}
+
+static grub_err_t
+check_password_deny (const char *user __attribute__ ((unused)),
+ const char *entered __attribute__ ((unused)),
+ void *password __attribute__ ((unused)))
+{
+ return GRUB_ACCESS_DENIED;
+}
+
+#define MD5_HASHLEN 16
+
+struct legacy_md5_password
+{
+ grub_uint8_t *salt;
+ int saltlen;
+ grub_uint8_t hash[MD5_HASHLEN];
+};
+
+static int
+check_password_md5_real (const char *entered,
+ struct legacy_md5_password *pw)
+{
+ grub_size_t enteredlen = grub_strlen (entered);
+ unsigned char alt_result[MD5_HASHLEN];
+ unsigned char *digest;
+ grub_uint8_t *ctx;
+ grub_size_t i;
+ int ret;
+
+ ctx = grub_zalloc (GRUB_MD_MD5->contextsize);
+ if (!ctx)
+ return 0;
+
+ GRUB_MD_MD5->init (ctx);
+ GRUB_MD_MD5->write (ctx, entered, enteredlen);
+ GRUB_MD_MD5->write (ctx, pw->salt + 3, pw->saltlen - 3);
+ GRUB_MD_MD5->write (ctx, entered, enteredlen);
+ digest = GRUB_MD_MD5->read (ctx);
+ GRUB_MD_MD5->final (ctx);
+ grub_memcpy (alt_result, digest, MD5_HASHLEN);
+
+ GRUB_MD_MD5->init (ctx);
+ GRUB_MD_MD5->write (ctx, entered, enteredlen);
+ GRUB_MD_MD5->write (ctx, pw->salt, pw->saltlen); /* include the $1$ header */
+ for (i = enteredlen; i > 16; i -= 16)
+ GRUB_MD_MD5->write (ctx, alt_result, 16);
+ GRUB_MD_MD5->write (ctx, alt_result, i);
+
+ for (i = enteredlen; i > 0; i >>= 1)
+ GRUB_MD_MD5->write (ctx, entered + ((i & 1) ? enteredlen : 0), 1);
+ digest = GRUB_MD_MD5->read (ctx);
+ GRUB_MD_MD5->final (ctx);
+
+ for (i = 0; i < 1000; i++)
+ {
+ grub_memcpy (alt_result, digest, 16);
+
+ GRUB_MD_MD5->init (ctx);
+ if ((i & 1) != 0)
+ GRUB_MD_MD5->write (ctx, entered, enteredlen);
+ else
+ GRUB_MD_MD5->write (ctx, alt_result, 16);
+
+ if (i % 3 != 0)
+ GRUB_MD_MD5->write (ctx, pw->salt + 3, pw->saltlen - 3);
+
+ if (i % 7 != 0)
+ GRUB_MD_MD5->write (ctx, entered, enteredlen);
+
+ if ((i & 1) != 0)
+ GRUB_MD_MD5->write (ctx, alt_result, 16);
+ else
+ GRUB_MD_MD5->write (ctx, entered, enteredlen);
+ digest = GRUB_MD_MD5->read (ctx);
+ GRUB_MD_MD5->final (ctx);
+ }
+
+ ret = (grub_crypto_memcmp (digest, pw->hash, MD5_HASHLEN) == 0);
+ grub_free (ctx);
+ return ret;
+}
+
+static grub_err_t
+check_password_md5 (const char *user,
+ const char *entered,
+ void *password)
+{
+ if (!check_password_md5_real (entered, password))
+ return GRUB_ACCESS_DENIED;
+
+ grub_auth_authenticate (user);
+
+ return GRUB_ERR_NONE;
+}
+
+static inline int
+ib64t (char c)
+{
+ if (c == '.')
+ return 0;
+ if (c == '/')
+ return 1;
+ if (c >= '0' && c <= '9')
+ return c - '0' + 2;
+ if (c >= 'A' && c <= 'Z')
+ return c - 'A' + 12;
+ if (c >= 'a' && c <= 'z')
+ return c - 'a' + 38;
+ return -1;
+}
+
+static struct legacy_md5_password *
+parse_legacy_md5 (int argc, char **args)
+{
+ const char *salt, *saltend;
+ struct legacy_md5_password *pw = NULL;
+ int i;
+ const char *p;
+
+ if (grub_memcmp (args[0], "--md5", sizeof ("--md5")) != 0)
+ goto fail;
+ if (argc == 1)
+ goto fail;
+ if (grub_strlen(args[1]) <= 3)
+ goto fail;
+ salt = args[1];
+ saltend = grub_strchr (salt + 3, '$');
+ if (!saltend)
+ goto fail;
+ pw = grub_malloc (sizeof (*pw));
+ if (!pw)
+ goto fail;
+
+ p = saltend + 1;
+ for (i = 0; i < 5; i++)
+ {
+ int n;
+ grub_uint32_t w = 0;
+
+ for (n = 0; n < 4; n++)
+ {
+ int ww = ib64t(*p++);
+ if (ww == -1)
+ goto fail;
+ w |= ww << (n * 6);
+ }
+ pw->hash[i == 4 ? 5 : 12+i] = w & 0xff;
+ pw->hash[6+i] = (w >> 8) & 0xff;
+ pw->hash[i] = (w >> 16) & 0xff;
+ }
+ {
+ int n;
+ grub_uint32_t w = 0;
+ for (n = 0; n < 2; n++)
+ {
+ int ww = ib64t(*p++);
+ if (ww == -1)
+ goto fail;
+ w |= ww << (6 * n);
+ }
+ if (w >= 0x100)
+ goto fail;
+ pw->hash[11] = w;
+ }
+
+ pw->saltlen = saltend - salt;
+ pw->salt = (grub_uint8_t *) grub_strndup (salt, pw->saltlen);
+ if (!pw->salt)
+ goto fail;
+
+ return pw;
+
+ fail:
+ grub_free (pw);
+ return NULL;
+}
+
+static grub_err_t
+grub_cmd_legacy_password (struct grub_command *mycmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct legacy_md5_password *pw = NULL;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+ if (args[0][0] != '-' || args[0][1] != '-')
+ return grub_normal_set_password ("legacy", args[0]);
+
+ pw = parse_legacy_md5 (argc, args);
+
+ if (pw)
+ return grub_auth_register_authentication ("legacy", check_password_md5, pw);
+ else
+ /* This is to imitate minor difference between grub-legacy in GRUB2.
+ If 2 password commands are executed in a row and second one fails
+ on GRUB2 the password of first one is used, whereas in grub-legacy
+ authenthication is denied. In case of no password command was executed
+ early both versions deny any access. */
+ return grub_auth_register_authentication ("legacy", check_password_deny,
+ NULL);
+}
+
+int
+grub_legacy_check_md5_password (int argc, char **args,
+ char *entered)
+{
+ struct legacy_md5_password *pw = NULL;
+ int ret;
+
+ if (args[0][0] != '-' || args[0][1] != '-')
+ {
+ char correct[GRUB_AUTH_MAX_PASSLEN];
+
+ grub_memset (correct, 0, sizeof (correct));
+ grub_strncpy (correct, args[0], sizeof (correct));
+
+ return grub_crypto_memcmp (entered, correct, GRUB_AUTH_MAX_PASSLEN) == 0;
+ }
+
+ pw = parse_legacy_md5 (argc, args);
+
+ if (!pw)
+ return 0;
+
+ ret = check_password_md5_real (entered, pw);
+ grub_free (pw);
+ return ret;
+}
+
+static grub_err_t
+grub_cmd_legacy_check_password (struct grub_command *mycmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ char entered[GRUB_AUTH_MAX_PASSLEN];
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+ grub_puts_ (N_("Enter password: "));
+ if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN))
+ return GRUB_ACCESS_DENIED;
+
+ if (!grub_legacy_check_md5_password (argc, args,
+ entered))
+ return GRUB_ACCESS_DENIED;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd_source, cmd_configfile;
+static grub_command_t cmd_source_extract, cmd_configfile_extract;
+static grub_command_t cmd_kernel, cmd_initrd, cmd_initrdnounzip;
+static grub_command_t cmd_password, cmd_check_password;
+
+GRUB_MOD_INIT(legacycfg)
+{
+ cmd_source
+ = grub_register_command ("legacy_source",
+ grub_cmd_legacy_source,
+ N_("FILE"),
+ /* TRANSLATORS: "legacy config" means
+ "config as used by grub-legacy". */
+ N_("Parse legacy config in same context"));
+ cmd_configfile
+ = grub_register_command ("legacy_configfile",
+ grub_cmd_legacy_source,
+ N_("FILE"),
+ N_("Parse legacy config in new context"));
+ cmd_source_extract
+ = grub_register_command ("extract_legacy_entries_source",
+ grub_cmd_legacy_source,
+ N_("FILE"),
+ N_("Parse legacy config in same context taking only menu entries"));
+ cmd_configfile_extract
+ = grub_register_command ("extract_legacy_entries_configfile",
+ grub_cmd_legacy_source,
+ N_("FILE"),
+ N_("Parse legacy config in new context taking only menu entries"));
+
+ cmd_kernel = grub_register_command ("legacy_kernel",
+ grub_cmd_legacy_kernel,
+ N_("[--no-mem-option] [--type=TYPE] FILE [ARG ...]"),
+ N_("Simulate grub-legacy `kernel' command"));
+
+ cmd_initrd = grub_register_command ("legacy_initrd",
+ grub_cmd_legacy_initrd,
+ N_("FILE [ARG ...]"),
+ N_("Simulate grub-legacy `initrd' command"));
+ cmd_initrdnounzip = grub_register_command ("legacy_initrd_nounzip",
+ grub_cmd_legacy_initrdnounzip,
+ N_("FILE [ARG ...]"),
+ N_("Simulate grub-legacy `modulenounzip' command"));
+
+ cmd_password = grub_register_command ("legacy_password",
+ grub_cmd_legacy_password,
+ N_("[--md5] PASSWD [FILE]"),
+ N_("Simulate grub-legacy `password' command"));
+
+ cmd_check_password = grub_register_command ("legacy_check_password",
+ grub_cmd_legacy_check_password,
+ N_("[--md5] PASSWD [FILE]"),
+ N_("Simulate grub-legacy `password' command in menu entry mode"));
+
+}
+
+GRUB_MOD_FINI(legacycfg)
+{
+ grub_unregister_command (cmd_source);
+ grub_unregister_command (cmd_configfile);
+ grub_unregister_command (cmd_source_extract);
+ grub_unregister_command (cmd_configfile_extract);
+
+ grub_unregister_command (cmd_kernel);
+ grub_unregister_command (cmd_initrd);
+ grub_unregister_command (cmd_initrdnounzip);
+
+ grub_unregister_command (cmd_password);
+ grub_unregister_command (cmd_check_password);
+}
diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c
new file mode 100644
index 0000000..3fd664a
--- /dev/null
+++ b/grub-core/commands/loadenv.c
@@ -0,0 +1,470 @@
+/* loadenv.c - command to load/save environment variable. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/partition.h>
+#include <grub/lib/envblk.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ /* TRANSLATORS: This option is used to override default filename
+ for loading and storing environment. */
+ {"file", 'f', 0, N_("Specify filename."), 0, ARG_TYPE_PATHNAME},
+ {"skip-sig", 's', 0,
+ N_("Skip signature-checking of the environment file."), 0, ARG_TYPE_NONE},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+/* Opens 'filename' with compression filters disabled. Optionally disables the
+ PUBKEY filter (that insists upon properly signed files) as well. PUBKEY
+ filter is restored before the function returns. */
+static grub_file_t
+open_envblk_file (char *filename,
+ enum grub_file_type type)
+{
+ grub_file_t file;
+ char *buf = 0;
+
+ if (! filename)
+ {
+ const char *prefix;
+ int len;
+
+ prefix = grub_env_get ("prefix");
+ if (! prefix)
+ {
+ grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
+ return 0;
+ }
+
+ len = grub_strlen (prefix);
+ buf = grub_malloc (len + 1 + sizeof (GRUB_ENVBLK_DEFCFG));
+ if (! buf)
+ return 0;
+ filename = buf;
+
+ grub_strcpy (filename, prefix);
+ filename[len] = '/';
+ grub_strcpy (filename + len + 1, GRUB_ENVBLK_DEFCFG);
+ }
+
+ file = grub_file_open (filename, type);
+
+ grub_free (buf);
+ return file;
+}
+
+static grub_envblk_t
+read_envblk_file (grub_file_t file)
+{
+ grub_off_t offset = 0;
+ char *buf;
+ grub_size_t size = grub_file_size (file);
+ grub_envblk_t envblk;
+
+ buf = grub_malloc (size);
+ if (! buf)
+ return 0;
+
+ while (size > 0)
+ {
+ grub_ssize_t ret;
+
+ ret = grub_file_read (file, buf + offset, size);
+ if (ret <= 0)
+ {
+ grub_free (buf);
+ return 0;
+ }
+
+ size -= ret;
+ offset += ret;
+ }
+
+ envblk = grub_envblk_open (buf, offset);
+ if (! envblk)
+ {
+ grub_free (buf);
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid environment block");
+ return 0;
+ }
+
+ return envblk;
+}
+
+struct grub_env_whitelist
+{
+ grub_size_t len;
+ char **list;
+};
+typedef struct grub_env_whitelist grub_env_whitelist_t;
+
+static int
+test_whitelist_membership (const char* name,
+ const grub_env_whitelist_t* whitelist)
+{
+ grub_size_t i;
+
+ for (i = 0; i < whitelist->len; i++)
+ if (grub_strcmp (name, whitelist->list[i]) == 0)
+ return 1; /* found it */
+
+ return 0; /* not found */
+}
+
+/* Helper for grub_cmd_load_env. */
+static int
+set_var (const char *name, const char *value, void *whitelist)
+{
+ if (! whitelist)
+ {
+ grub_env_set (name, value);
+ return 0;
+ }
+
+ if (test_whitelist_membership (name,
+ (const grub_env_whitelist_t *) whitelist))
+ grub_env_set (name, value);
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_load_env (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ grub_file_t file;
+ grub_envblk_t envblk;
+ grub_env_whitelist_t whitelist;
+
+ whitelist.len = argc;
+ whitelist.list = args;
+
+ /* state[0] is the -f flag; state[1] is the --skip-sig flag */
+ file = open_envblk_file ((state[0].set) ? state[0].arg : 0,
+ GRUB_FILE_TYPE_LOADENV
+ | (state[1].set
+ ? GRUB_FILE_TYPE_SKIP_SIGNATURE : GRUB_FILE_TYPE_NONE));
+ if (! file)
+ return grub_errno;
+
+ envblk = read_envblk_file (file);
+ if (! envblk)
+ goto fail;
+
+ /* argc > 0 indicates caller provided a whitelist of variables to read. */
+ grub_envblk_iterate (envblk, argc > 0 ? &whitelist : 0, set_var);
+ grub_envblk_close (envblk);
+
+ fail:
+ grub_file_close (file);
+ return grub_errno;
+}
+
+/* Print all variables in current context. */
+static int
+print_var (const char *name, const char *value,
+ void *hook_data __attribute__ ((unused)))
+{
+ grub_printf ("%s=%s\n", name, value);
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_list_env (grub_extcmd_context_t ctxt,
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ struct grub_arg_list *state = ctxt->state;
+ grub_file_t file;
+ grub_envblk_t envblk;
+
+ file = open_envblk_file ((state[0].set) ? state[0].arg : 0,
+ GRUB_FILE_TYPE_LOADENV
+ | (state[1].set
+ ? GRUB_FILE_TYPE_SKIP_SIGNATURE : GRUB_FILE_TYPE_NONE));
+ if (! file)
+ return grub_errno;
+
+ envblk = read_envblk_file (file);
+ if (! envblk)
+ goto fail;
+
+ grub_envblk_iterate (envblk, NULL, print_var);
+ grub_envblk_close (envblk);
+
+ fail:
+ grub_file_close (file);
+ return grub_errno;
+}
+
+/* Used to maintain a variable length of blocklists internally. */
+struct blocklist
+{
+ grub_disk_addr_t sector;
+ unsigned offset;
+ unsigned length;
+ struct blocklist *next;
+};
+
+static void
+free_blocklists (struct blocklist *p)
+{
+ struct blocklist *q;
+
+ for (; p; p = q)
+ {
+ q = p->next;
+ grub_free (p);
+ }
+}
+
+static grub_err_t
+check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
+ grub_file_t file)
+{
+ grub_size_t total_length;
+ grub_size_t index;
+ grub_disk_t disk;
+ grub_disk_addr_t part_start;
+ struct blocklist *p;
+ char *buf;
+
+ /* Sanity checks. */
+ total_length = 0;
+ for (p = blocklists; p; p = p->next)
+ {
+ struct blocklist *q;
+ /* Check if any pair of blocks overlap. */
+ for (q = p->next; q; q = q->next)
+ {
+ grub_disk_addr_t s1, s2;
+ grub_disk_addr_t e1, e2;
+
+ s1 = p->sector;
+ e1 = s1 + ((p->length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
+
+ s2 = q->sector;
+ e2 = s2 + ((q->length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
+
+ if (s1 < e2 && s2 < e1)
+ {
+ /* This might be actually valid, but it is unbelievable that
+ any filesystem makes such a silly allocation. */
+ return grub_error (GRUB_ERR_BAD_FS, "malformed file");
+ }
+ }
+
+ total_length += p->length;
+ }
+
+ if (total_length != grub_file_size (file))
+ {
+ /* Maybe sparse, unallocated sectors. No way in GRUB. */
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "sparse file not allowed");
+ }
+
+ /* One more sanity check. Re-read all sectors by blocklists, and compare
+ those with the data read via a file. */
+ disk = file->device->disk;
+
+ part_start = grub_partition_get_start (disk->partition);
+
+ buf = grub_envblk_buffer (envblk);
+ char *blockbuf = NULL;
+ grub_size_t blockbuf_len = 0;
+ for (p = blocklists, index = 0; p; index += p->length, p = p->next)
+ {
+ if (p->length > blockbuf_len)
+ {
+ grub_free (blockbuf);
+ blockbuf_len = 2 * p->length;
+ blockbuf = grub_malloc (blockbuf_len);
+ if (!blockbuf)
+ return grub_errno;
+ }
+
+ if (grub_disk_read (disk, p->sector - part_start,
+ p->offset, p->length, blockbuf))
+ return grub_errno;
+
+ if (grub_memcmp (buf + index, blockbuf, p->length) != 0)
+ return grub_error (GRUB_ERR_FILE_READ_ERROR, "invalid blocklist");
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static int
+write_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
+ grub_file_t file)
+{
+ char *buf;
+ grub_disk_t disk;
+ grub_disk_addr_t part_start;
+ struct blocklist *p;
+ grub_size_t index;
+
+ buf = grub_envblk_buffer (envblk);
+ disk = file->device->disk;
+ part_start = grub_partition_get_start (disk->partition);
+
+ index = 0;
+ for (p = blocklists; p; index += p->length, p = p->next)
+ {
+ if (grub_disk_write (disk, p->sector - part_start,
+ p->offset, p->length, buf + index))
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Context for grub_cmd_save_env. */
+struct grub_cmd_save_env_ctx
+{
+ struct blocklist *head, *tail;
+};
+
+/* Store blocklists in a linked list. */
+static void
+save_env_read_hook (grub_disk_addr_t sector, unsigned offset, unsigned length,
+ void *data)
+{
+ struct grub_cmd_save_env_ctx *ctx = data;
+ struct blocklist *block;
+
+ block = grub_malloc (sizeof (*block));
+ if (! block)
+ return;
+
+ block->sector = sector;
+ block->offset = offset;
+ block->length = length;
+
+ /* Slightly complicated, because the list should be FIFO. */
+ block->next = 0;
+ if (ctx->tail)
+ ctx->tail->next = block;
+ ctx->tail = block;
+ if (! ctx->head)
+ ctx->head = block;
+}
+
+static grub_err_t
+grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ grub_file_t file;
+ grub_envblk_t envblk;
+ struct grub_cmd_save_env_ctx ctx = {
+ .head = 0,
+ .tail = 0
+ };
+
+ if (! argc)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no variable is specified");
+
+ file = open_envblk_file ((state[0].set) ? state[0].arg : 0,
+ GRUB_FILE_TYPE_SAVEENV
+ | GRUB_FILE_TYPE_SKIP_SIGNATURE);
+ if (! file)
+ return grub_errno;
+
+ if (! file->device->disk)
+ {
+ grub_file_close (file);
+ return grub_error (GRUB_ERR_BAD_DEVICE, "disk device required");
+ }
+
+ file->read_hook = save_env_read_hook;
+ file->read_hook_data = &ctx;
+ envblk = read_envblk_file (file);
+ file->read_hook = 0;
+ if (! envblk)
+ goto fail;
+
+ if (check_blocklists (envblk, ctx.head, file))
+ goto fail;
+
+ while (argc)
+ {
+ const char *value;
+
+ value = grub_env_get (args[0]);
+ if (value)
+ {
+ if (! grub_envblk_set (envblk, args[0], value))
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "environment block too small");
+ goto fail;
+ }
+ }
+ else
+ grub_envblk_delete (envblk, args[0]);
+
+ argc--;
+ args++;
+ }
+
+ write_blocklists (envblk, ctx.head, file);
+
+ fail:
+ if (envblk)
+ grub_envblk_close (envblk);
+ free_blocklists (ctx.head);
+ grub_file_close (file);
+ return grub_errno;
+}
+
+static grub_extcmd_t cmd_load, cmd_list, cmd_save;
+
+GRUB_MOD_INIT(loadenv)
+{
+ cmd_load =
+ grub_register_extcmd ("load_env", grub_cmd_load_env, 0,
+ N_("[-f FILE] [-s|--skip-sig] [variable_name_to_whitelist] [...]"),
+ N_("Load variables from environment block file."),
+ options);
+ cmd_list =
+ grub_register_extcmd ("list_env", grub_cmd_list_env, 0, N_("[-f FILE]"),
+ N_("List variables from environment block file."),
+ options);
+ cmd_save =
+ grub_register_extcmd ("save_env", grub_cmd_save_env, 0,
+ N_("[-f FILE] variable_name [...]"),
+ N_("Save variables to environment block file."),
+ options);
+}
+
+GRUB_MOD_FINI(loadenv)
+{
+ grub_unregister_extcmd (cmd_load);
+ grub_unregister_extcmd (cmd_list);
+ grub_unregister_extcmd (cmd_save);
+}
diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
new file mode 100644
index 0000000..8e98c73
--- /dev/null
+++ b/grub-core/commands/ls.c
@@ -0,0 +1,302 @@
+/* ls.c - command to list files and devices */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/device.h>
+#include <grub/term.h>
+#include <grub/partition.h>
+#include <grub/file.h>
+#include <grub/normal.h>
+#include <grub/extcmd.h>
+#include <grub/datetime.h>
+#include <grub/i18n.h>
+#include <grub/net.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ {"long", 'l', 0, N_("Show a long list with more detailed information."), 0, 0},
+ {"human-readable", 'h', 0, N_("Print sizes in a human readable format."), 0, 0},
+ {"all", 'a', 0, N_("List all files."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+/* Helper for grub_ls_list_devices. */
+static int
+grub_ls_print_devices (const char *name, void *data)
+{
+ int *longlist = data;
+
+ if (*longlist)
+ grub_normal_print_device_info (name);
+ else
+ grub_printf ("(%s) ", name);
+
+ return 0;
+}
+
+static grub_err_t
+grub_ls_list_devices (int longlist)
+{
+ grub_device_iterate (grub_ls_print_devices, &longlist);
+ grub_xputs ("\n");
+
+#if 0
+ {
+ grub_net_app_level_t proto;
+ int first = 1;
+ FOR_NET_APP_LEVEL (proto)
+ {
+ if (first)
+ grub_puts_ (N_("Network protocols:"));
+ first = 0;
+ grub_printf ("%s ", proto->name);
+ }
+ grub_xputs ("\n");
+ }
+#endif
+
+ grub_refresh ();
+
+ return 0;
+}
+
+/* Context for grub_ls_list_files. */
+struct grub_ls_list_files_ctx
+{
+ char *dirname;
+ int all;
+ int human;
+};
+
+/* Helper for grub_ls_list_files. */
+static int
+print_files (const char *filename, const struct grub_dirhook_info *info,
+ void *data)
+{
+ struct grub_ls_list_files_ctx *ctx = data;
+
+ if (ctx->all || filename[0] != '.')
+ grub_printf ("%s%s ", filename, info->dir ? "/" : "");
+
+ return 0;
+}
+
+/* Helper for grub_ls_list_files. */
+static int
+print_files_long (const char *filename, const struct grub_dirhook_info *info,
+ void *data)
+{
+ struct grub_ls_list_files_ctx *ctx = data;
+
+ if ((! ctx->all) && (filename[0] == '.'))
+ return 0;
+
+ if (! info->dir)
+ {
+ grub_file_t file;
+ char *pathname;
+
+ if (ctx->dirname[grub_strlen (ctx->dirname) - 1] == '/')
+ pathname = grub_xasprintf ("%s%s", ctx->dirname, filename);
+ else
+ pathname = grub_xasprintf ("%s/%s", ctx->dirname, filename);
+
+ if (!pathname)
+ return 1;
+
+ /* XXX: For ext2fs symlinks are detected as files while they
+ should be reported as directories. */
+ file = grub_file_open (pathname, GRUB_FILE_TYPE_GET_SIZE
+ | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (! file)
+ {
+ grub_errno = 0;
+ grub_free (pathname);
+ return 0;
+ }
+
+ if (! ctx->human)
+ grub_printf ("%-12llu", (unsigned long long) file->size);
+ else
+ grub_printf ("%-12s", grub_get_human_size (file->size,
+ GRUB_HUMAN_SIZE_SHORT));
+ grub_file_close (file);
+ grub_free (pathname);
+ }
+ else
+ grub_printf ("%-12s", _("DIR"));
+
+ if (info->mtimeset)
+ {
+ struct grub_datetime datetime;
+ grub_unixtime2datetime (info->mtime, &datetime);
+ if (ctx->human)
+ grub_printf (" %d-%02d-%02d %02d:%02d:%02d %-11s ",
+ datetime.year, datetime.month, datetime.day,
+ datetime.hour, datetime.minute,
+ datetime.second,
+ grub_get_weekday_name (&datetime));
+ else
+ grub_printf (" %04d%02d%02d%02d%02d%02d ",
+ datetime.year, datetime.month,
+ datetime.day, datetime.hour,
+ datetime.minute, datetime.second);
+ }
+ grub_printf ("%s%s\n", filename, info->dir ? "/" : "");
+
+ return 0;
+}
+
+static grub_err_t
+grub_ls_list_files (char *dirname, int longlist, int all, int human)
+{
+ char *device_name;
+ grub_fs_t fs;
+ const char *path;
+ grub_device_t dev;
+
+ device_name = grub_file_get_device_name (dirname);
+ dev = grub_device_open (device_name);
+ if (! dev)
+ goto fail;
+
+ fs = grub_fs_probe (dev);
+ path = grub_strchr (dirname, ')');
+ if (! path)
+ path = dirname;
+ else
+ path++;
+
+ if (! path && ! device_name)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
+ goto fail;
+ }
+
+ if (! *path && device_name)
+ {
+ if (grub_errno == GRUB_ERR_UNKNOWN_FS)
+ grub_errno = GRUB_ERR_NONE;
+
+#ifdef GRUB_MACHINE_IEEE1275
+ /*
+ * Close device to prevent a double open in grub_normal_print_device_info().
+ * Otherwise it may lead to hangs on some IEEE 1275 platforms.
+ */
+ grub_device_close (dev);
+ dev = NULL;
+#endif
+
+ grub_normal_print_device_info (device_name);
+ }
+ else if (fs)
+ {
+ struct grub_ls_list_files_ctx ctx = {
+ .dirname = dirname,
+ .all = all,
+ .human = human
+ };
+
+ if (longlist)
+ (fs->fs_dir) (dev, path, print_files_long, &ctx);
+ else
+ (fs->fs_dir) (dev, path, print_files, &ctx);
+
+ if (grub_errno == GRUB_ERR_BAD_FILE_TYPE
+ && path[grub_strlen (path) - 1] != '/')
+ {
+ /* PATH might be a regular file. */
+ char *p;
+ grub_file_t file;
+ struct grub_dirhook_info info;
+ grub_errno = 0;
+
+ file = grub_file_open (dirname, GRUB_FILE_TYPE_GET_SIZE
+ | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (! file)
+ goto fail;
+
+ grub_file_close (file);
+
+ p = grub_strrchr (dirname, '/') + 1;
+ dirname = grub_strndup (dirname, p - dirname);
+ if (! dirname)
+ goto fail;
+
+ all = 1;
+ grub_memset (&info, 0, sizeof (info));
+ if (longlist)
+ print_files_long (p, &info, &ctx);
+ else
+ print_files (p, &info, &ctx);
+
+ grub_free (dirname);
+ }
+
+ if (grub_errno == GRUB_ERR_NONE)
+ grub_xputs ("\n");
+
+ grub_refresh ();
+ }
+
+ fail:
+ if (dev)
+ grub_device_close (dev);
+
+ grub_free (device_name);
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_ls (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ int i;
+
+ if (argc == 0)
+ grub_ls_list_devices (state[0].set);
+ else
+ for (i = 0; i < argc; i++)
+ grub_ls_list_files (args[i], state[0].set, state[2].set,
+ state[1].set);
+
+ return 0;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(ls)
+{
+ cmd = grub_register_extcmd ("ls", grub_cmd_ls, 0,
+ N_("[-l|-h|-a] [FILE ...]"),
+ N_("List devices and files."), options);
+}
+
+GRUB_MOD_FINI(ls)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/lsacpi.c b/grub-core/commands/lsacpi.c
new file mode 100644
index 0000000..0824914
--- /dev/null
+++ b/grub-core/commands/lsacpi.c
@@ -0,0 +1,314 @@
+/* acpi.c - Display acpi tables. */
+/*
+ * 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/mm.h>
+#include <grub/misc.h>
+#include <grub/normal.h>
+#include <grub/acpi.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/dl.h>
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static void
+print_strn (grub_uint8_t *str, grub_size_t len)
+{
+ for (; *str && len; str++, len--)
+ grub_printf ("%c", *str);
+ for (len++; len; len--)
+ grub_printf (" ");
+}
+
+#define print_field(x) print_strn(x, sizeof (x))
+
+static void
+disp_acpi_table (struct grub_acpi_table_header *t)
+{
+ print_field (t->signature);
+ grub_printf ("%4" PRIuGRUB_UINT32_T "B rev=%u chksum=0x%02x (%s) OEM=", t->length, t->revision, t->checksum,
+ grub_byte_checksum (t, t->length) == 0 ? "valid" : "invalid");
+ print_field (t->oemid);
+ print_field (t->oemtable);
+ grub_printf ("OEMrev=%08" PRIxGRUB_UINT32_T " ", t->oemrev);
+ print_field (t->creator_id);
+ grub_printf (" %08" PRIxGRUB_UINT32_T "\n", t->creator_rev);
+}
+
+static void
+disp_madt_table (struct grub_acpi_madt *t)
+{
+ struct grub_acpi_madt_entry_header *d;
+ grub_uint32_t len;
+
+ disp_acpi_table (&t->hdr);
+ grub_printf ("Local APIC=%08" PRIxGRUB_UINT32_T " Flags=%08"
+ PRIxGRUB_UINT32_T "\n",
+ t->lapic_addr, t->flags);
+ len = t->hdr.length - sizeof (struct grub_acpi_madt);
+ d = t->entries;
+ for (;len > 0; len -= d->len, d = (void *) ((grub_uint8_t *) d + d->len))
+ {
+ switch (d->type)
+ {
+ case GRUB_ACPI_MADT_ENTRY_TYPE_LAPIC:
+ {
+ struct grub_acpi_madt_entry_lapic *dt = (void *) d;
+ grub_printf (" LAPIC ACPI_ID=%02x APIC_ID=%02x Flags=%08x\n",
+ dt->acpiid, dt->apicid, dt->flags);
+ if (dt->hdr.len != sizeof (*dt))
+ grub_printf (" table size mismatch %d != %d\n", dt->hdr.len,
+ (int) sizeof (*dt));
+ break;
+ }
+
+ case GRUB_ACPI_MADT_ENTRY_TYPE_IOAPIC:
+ {
+ struct grub_acpi_madt_entry_ioapic *dt = (void *) d;
+ grub_printf (" IOAPIC ID=%02x address=%08x GSI=%08x\n",
+ dt->id, dt->address, dt->global_sys_interrupt);
+ if (dt->hdr.len != sizeof (*dt))
+ grub_printf (" table size mismatch %d != %d\n", dt->hdr.len,
+ (int) sizeof (*dt));
+ if (dt->pad)
+ grub_printf (" non-zero pad: %02x\n", dt->pad);
+ break;
+ }
+
+ case GRUB_ACPI_MADT_ENTRY_TYPE_INTERRUPT_OVERRIDE:
+ {
+ struct grub_acpi_madt_entry_interrupt_override *dt = (void *) d;
+ grub_printf (" Int Override bus=%x src=%x GSI=%08x Flags=%04x\n",
+ dt->bus, dt->source, dt->global_sys_interrupt,
+ dt->flags);
+ if (dt->hdr.len != sizeof (*dt))
+ grub_printf (" table size mismatch %d != %d\n", dt->hdr.len,
+ (int) sizeof (*dt));
+ }
+ break;
+
+ case GRUB_ACPI_MADT_ENTRY_TYPE_LAPIC_NMI:
+ {
+ struct grub_acpi_madt_entry_lapic_nmi *dt = (void *) d;
+ grub_printf (" LAPIC_NMI ACPI_ID=%02x Flags=%04x lint=%02x\n",
+ dt->acpiid, dt->flags, dt->lint);
+ if (dt->hdr.len != sizeof (*dt))
+ grub_printf (" table size mismatch %d != %d\n", dt->hdr.len,
+ (int) sizeof (*dt));
+ break;
+ }
+
+ case GRUB_ACPI_MADT_ENTRY_TYPE_SAPIC:
+ {
+ struct grub_acpi_madt_entry_sapic *dt = (void *) d;
+ grub_printf (" IOSAPIC Id=%02x GSI=%08x Addr=%016" PRIxGRUB_UINT64_T
+ "\n",
+ dt->id, dt->global_sys_interrupt_base,
+ dt->addr);
+ if (dt->hdr.len != sizeof (*dt))
+ grub_printf (" table size mismatch %d != %d\n", dt->hdr.len,
+ (int) sizeof (*dt));
+ if (dt->pad)
+ grub_printf (" non-zero pad: %02x\n", dt->pad);
+
+ }
+ break;
+ case GRUB_ACPI_MADT_ENTRY_TYPE_LSAPIC:
+ {
+ struct grub_acpi_madt_entry_lsapic *dt = (void *) d;
+ grub_printf (" LSAPIC ProcId=%02x ID=%02x EID=%02x Flags=%x",
+ dt->cpu_id, dt->id, dt->eid, dt->flags);
+ if (dt->flags & GRUB_ACPI_MADT_ENTRY_SAPIC_FLAGS_ENABLED)
+ grub_printf (" Enabled\n");
+ else
+ grub_printf (" Disabled\n");
+ if (d->len > sizeof (struct grub_acpi_madt_entry_sapic))
+ grub_printf (" UID val=%08x, Str=%s\n", dt->cpu_uid,
+ dt->cpu_uid_str);
+ if (dt->hdr.len != sizeof (*dt) + grub_strlen ((char *) dt->cpu_uid_str) + 1)
+ grub_printf (" table size mismatch %d != %d\n", dt->hdr.len,
+ (int) sizeof (*dt));
+ if (dt->pad[0] || dt->pad[1] || dt->pad[2])
+ grub_printf (" non-zero pad: %02x%02x%02x\n", dt->pad[0], dt->pad[1], dt->pad[2]);
+ }
+ break;
+ case GRUB_ACPI_MADT_ENTRY_TYPE_PLATFORM_INT_SOURCE:
+ {
+ struct grub_acpi_madt_entry_platform_int_source *dt = (void *) d;
+ static const char * const platint_type[] =
+ {"Nul", "PMI", "INIT", "CPEI"};
+
+ grub_printf (" Platform INT flags=%04x type=%02x (%s)"
+ " ID=%02x EID=%02x\n",
+ dt->flags, dt->inttype,
+ (dt->inttype < ARRAY_SIZE (platint_type))
+ ? platint_type[dt->inttype] : "??", dt->cpu_id,
+ dt->cpu_eid);
+ grub_printf (" IOSAPIC Vec=%02x GSI=%08x source flags=%08x\n",
+ dt->sapic_vector, dt->global_sys_int, dt->src_flags);
+ }
+ break;
+ default:
+ grub_printf (" type=%x l=%u ", d->type, d->len);
+ grub_printf (" ??\n");
+ }
+ }
+}
+
+static void
+disp_acpi_xsdt_table (struct grub_acpi_table_header *t)
+{
+ grub_uint32_t len;
+ grub_uint64_t *desc;
+
+ disp_acpi_table (t);
+ len = t->length - sizeof (*t);
+ desc = (grub_uint64_t *) (t + 1);
+ for (; len >= sizeof (*desc); desc++, len -= sizeof (*desc))
+ {
+#if GRUB_CPU_SIZEOF_VOID_P == 4
+ if (*desc >= (1ULL << 32))
+ {
+ grub_printf ("Unreachable table\n");
+ continue;
+ }
+#endif
+ t = (struct grub_acpi_table_header *) (grub_addr_t) *desc;
+
+ if (t == NULL)
+ continue;
+
+ if (grub_memcmp (t->signature, GRUB_ACPI_MADT_SIGNATURE,
+ sizeof (t->signature)) == 0)
+ disp_madt_table ((struct grub_acpi_madt *) t);
+ else
+ disp_acpi_table (t);
+ }
+}
+
+static void
+disp_acpi_rsdt_table (struct grub_acpi_table_header *t)
+{
+ grub_uint32_t len;
+ grub_uint32_t *desc;
+
+ disp_acpi_table (t);
+ len = t->length - sizeof (*t);
+ desc = (grub_uint32_t *) (t + 1);
+ for (; len >= sizeof (*desc); desc++, len -= sizeof (*desc))
+ {
+ t = (struct grub_acpi_table_header *) (grub_addr_t) *desc;
+
+ if (t == NULL)
+ continue;
+
+ if (grub_memcmp (t->signature, GRUB_ACPI_MADT_SIGNATURE,
+ sizeof (t->signature)) == 0)
+ disp_madt_table ((struct grub_acpi_madt *) t);
+ else
+ disp_acpi_table (t);
+ }
+}
+
+static void
+disp_acpi_rsdpv1 (struct grub_acpi_rsdp_v10 *rsdp)
+{
+ print_field (rsdp->signature);
+ grub_printf ("chksum:%02x (%s), OEM-ID: ", rsdp->checksum, grub_byte_checksum (rsdp, sizeof (*rsdp)) == 0 ? "valid" : "invalid");
+ print_field (rsdp->oemid);
+ grub_printf ("rev=%d\n", rsdp->revision);
+ grub_printf ("RSDT=%08" PRIxGRUB_UINT32_T "\n", rsdp->rsdt_addr);
+}
+
+static void
+disp_acpi_rsdpv2 (struct grub_acpi_rsdp_v20 *rsdp)
+{
+ disp_acpi_rsdpv1 (&rsdp->rsdpv1);
+ grub_printf ("len=%d chksum=%02x (%s) XSDT=%016" PRIxGRUB_UINT64_T "\n", rsdp->length, rsdp->checksum, grub_byte_checksum (rsdp, rsdp->length) == 0 ? "valid" : "invalid",
+ rsdp->xsdt_addr);
+ if (rsdp->length != sizeof (*rsdp))
+ grub_printf (" length mismatch %d != %d\n", rsdp->length,
+ (int) sizeof (*rsdp));
+ if (rsdp->reserved[0] || rsdp->reserved[1] || rsdp->reserved[2])
+ grub_printf (" non-zero reserved %02x%02x%02x\n", rsdp->reserved[0], rsdp->reserved[1], rsdp->reserved[2]);
+}
+
+static const struct grub_arg_option options[] = {
+ {"v1", '1', 0, N_("Show version 1 tables only."), 0, ARG_TYPE_NONE},
+ {"v2", '2', 0, N_("Show version 2 and version 3 tables only."), 0, ARG_TYPE_NONE},
+ {0, 0, 0, 0, 0, 0}
+};
+
+static grub_err_t
+grub_cmd_lsacpi (struct grub_extcmd_context *ctxt,
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ if (!ctxt->state[1].set)
+ {
+ struct grub_acpi_rsdp_v10 *rsdp1 = grub_acpi_get_rsdpv1 ();
+ if (!rsdp1)
+ grub_printf ("No RSDPv1\n");
+ else
+ {
+ grub_printf ("RSDPv1 signature:");
+ disp_acpi_rsdpv1 (rsdp1);
+ disp_acpi_rsdt_table ((void *) (grub_addr_t) rsdp1->rsdt_addr);
+ }
+ }
+
+ if (!ctxt->state[0].set)
+ {
+ struct grub_acpi_rsdp_v20 *rsdp2 = grub_acpi_get_rsdpv2 ();
+ if (!rsdp2)
+ grub_printf ("No RSDPv2\n");
+ else
+ {
+#if GRUB_CPU_SIZEOF_VOID_P == 4
+ if (rsdp2->xsdt_addr >= (1ULL << 32))
+ grub_printf ("Unreachable RSDPv2\n");
+ else
+#endif
+ {
+ grub_printf ("RSDPv2 signature:");
+ disp_acpi_rsdpv2 (rsdp2);
+ disp_acpi_xsdt_table ((void *) (grub_addr_t) rsdp2->xsdt_addr);
+ grub_printf ("\n");
+ }
+ }
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(lsapi)
+{
+ cmd = grub_register_extcmd ("lsacpi", grub_cmd_lsacpi, 0, "[-1|-2]",
+ N_("Show ACPI information."), options);
+}
+
+GRUB_MOD_FINI(lsacpi)
+{
+ grub_unregister_extcmd (cmd);
+}
+
+
diff --git a/grub-core/commands/lsmmap.c b/grub-core/commands/lsmmap.c
new file mode 100644
index 0000000..816ee47
--- /dev/null
+++ b/grub-core/commands/lsmmap.c
@@ -0,0 +1,85 @@
+/*
+ * 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/dl.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/memory.h>
+#include <grub/mm.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#ifndef GRUB_MACHINE_EMU
+static const char *names[] =
+ {
+ [GRUB_MEMORY_AVAILABLE] = N_("available RAM"),
+ [GRUB_MEMORY_RESERVED] = N_("reserved RAM"),
+ /* TRANSLATORS: this refers to memory where ACPI tables are stored
+ and which can be used by OS once it loads ACPI tables. */
+ [GRUB_MEMORY_ACPI] = N_("ACPI reclaimable RAM"),
+ /* TRANSLATORS: this refers to memory which ACPI-compliant OS
+ 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")
+ };
+
+/* Helper for grub_cmd_lsmmap. */
+static int
+lsmmap_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data __attribute__ ((unused)))
+{
+ if (type < (int) ARRAY_SIZE (names) && type >= 0 && names[type])
+ grub_printf_ (N_("base_addr = 0x%llx, length = 0x%llx, %s\n"),
+ (long long) addr, (long long) size, _(names[type]));
+ else
+ grub_printf_ (N_("base_addr = 0x%llx, length = 0x%llx, type = 0x%x\n"),
+ (long long) addr, (long long) size, type);
+ return 0;
+}
+#endif
+
+static grub_err_t
+grub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+
+{
+#ifndef GRUB_MACHINE_EMU
+ grub_machine_mmap_iterate (lsmmap_hook, NULL);
+#endif
+
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lsmmap)
+{
+ cmd = grub_register_command ("lsmmap", grub_cmd_lsmmap,
+ 0, N_("List memory map provided by firmware."));
+}
+
+GRUB_MOD_FINI(lsmmap)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/lspci.c b/grub-core/commands/lspci.c
new file mode 100644
index 0000000..65213a3
--- /dev/null
+++ b/grub-core/commands/lspci.c
@@ -0,0 +1,238 @@
+/* lspci.c - List PCI devices. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/pci.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/mm.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_pci_classname
+{
+ int class;
+ int subclass;
+ const char *desc;
+};
+
+static const struct grub_pci_classname grub_pci_classes[] =
+ {
+ { 0, 0, "" },
+ { 1, 0, "SCSI Controller" },
+ { 1, 1, "IDE Controller" },
+ { 1, 2, "Floppy Controller" },
+ { 1, 3, "IPI Controller" },
+ { 1, 4, "RAID Controller" },
+ { 1, 6, "SATA Controller" },
+ { 1, 0x80, "Mass storage Controller" },
+ { 2, 0, "Ethernet Controller" },
+ { 2, 1, "Token Ring Controller" },
+ { 2, 2, "FDDI Controller" },
+ { 2, 3, "ATM Controller" },
+ { 2, 4, "ISDN Controller" },
+ { 2, 0x80, "Network controller" },
+ { 3, 0, "VGA Controller" },
+ { 3, 1, "XGA Controller" },
+ { 3, 2, "3D Controller" },
+ { 3, 0x80, "Display Controller" },
+ { 4, 0, "Multimedia Video Device" },
+ { 4, 1, "Multimedia Audio Device" },
+ { 4, 2, "Multimedia Telephony Device" },
+ { 4, 0x80, "Multimedia device" },
+ { 5, 0, "RAM Controller" },
+ { 5, 1, "Flash Memory Controller" },
+ { 5, 0x80, "Memory Controller" },
+ { 6, 0, "Host Bridge" },
+ { 6, 1, "ISA Bridge" },
+ { 6, 2, "EISA Bride" },
+ { 6, 3, "MCA Bridge" },
+ { 6, 4, "PCI-PCI Bridge" },
+ { 6, 5, "PCMCIA Bridge" },
+ { 6, 6, "NuBus Bridge" },
+ { 6, 7, "CardBus Bridge" },
+ { 6, 8, "Raceway Bridge" },
+ { 6, 0x80, "Unknown Bridge" },
+ { 7, 0x80, "Communication controller" },
+ { 8, 0x80, "System hardware" },
+ { 9, 0, "Keyboard Controller" },
+ { 9, 1, "Digitizer" },
+ { 9, 2, "Mouse Controller" },
+ { 9, 3, "Scanner Controller" },
+ { 9, 4, "Gameport Controller" },
+ { 9, 0x80, "Unknown Input Device" },
+ { 10, 0, "Generic Docking Station" },
+ { 10, 0x80, "Unknown Docking Station" },
+ { 11, 0, "80386 Processor" },
+ { 11, 1, "80486 Processor" },
+ { 11, 2, "Pentium Processor" },
+ { 11, 0x10, "Alpha Processor" },
+ { 11, 0x20, "PowerPC Processor" },
+ { 11, 0x30, "MIPS Processor" },
+ { 11, 0x40, "Co-Processor" },
+ { 11, 0x80, "Unknown Processor" },
+ { 12, 3, "USB Controller" },
+ { 12, 0x80, "Serial Bus Controller" },
+ { 13, 0x80, "Wireless Controller" },
+ { 14, 0, "I2O" },
+ { 15, 0, "IrDA Controller" },
+ { 15, 1, "Consumer IR" },
+ { 15, 0x10, "RF-Controller" },
+ { 15, 0x80, "Satellite Communication Controller" },
+ { 16, 0, "Network Decryption" },
+ { 16, 1, "Entertainment Decryption" },
+ { 16, 0x80, "Unknown Decryption Controller" },
+ { 17, 0, "Digital IO Module" },
+ { 17, 0x80, "Unknown Data Input System" },
+ { 0, 0, 0 },
+ };
+
+static const char *
+grub_pci_get_class (int class, int subclass)
+{
+ const struct grub_pci_classname *curr = grub_pci_classes;
+
+ while (curr->desc)
+ {
+ if (curr->class == class && curr->subclass == subclass)
+ return curr->desc;
+ curr++;
+ }
+
+ return 0;
+}
+
+static const struct grub_arg_option options[] =
+ {
+ {"iospace", 'i', 0, "show I/O spaces", 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static int iospace;
+
+static int
+grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ grub_uint32_t class;
+ const char *sclass;
+ grub_pci_address_t addr;
+ int reg;
+
+ grub_printf ("%02x:%02x.%x %04x:%04x", grub_pci_get_bus (dev),
+ grub_pci_get_device (dev), grub_pci_get_function (dev),
+ pciid & 0xFFFF, pciid >> 16);
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class = grub_pci_read (addr);
+
+ /* Lookup the class name, if there isn't a specific one,
+ retry with 0x80 to get the generic class name. */
+ sclass = grub_pci_get_class (class >> 24, (class >> 16) & 0xFF);
+ if (! sclass)
+ sclass = grub_pci_get_class (class >> 24, 0x80);
+ if (! sclass)
+ sclass = "";
+
+ grub_printf (" [%04x] %s", (class >> 16) & 0xffff, sclass);
+
+ grub_uint8_t pi = (class >> 8) & 0xff;
+ if (pi)
+ grub_printf (" [PI %02x]", pi);
+
+ grub_printf ("\n");
+
+ if (iospace)
+ {
+ reg = GRUB_PCI_REG_ADDRESSES;
+ while (reg < GRUB_PCI_REG_CIS_POINTER)
+ {
+ grub_uint64_t space;
+ addr = grub_pci_make_address (dev, reg);
+ space = grub_pci_read (addr);
+
+ reg += sizeof (grub_uint32_t);
+
+ if (space == 0)
+ continue;
+
+ switch (space & GRUB_PCI_ADDR_SPACE_MASK)
+ {
+ case GRUB_PCI_ADDR_SPACE_IO:
+ grub_printf ("\tIO space %d at 0x%llx\n",
+ (unsigned) ((reg - GRUB_PCI_REG_ADDRESSES)
+ / sizeof (grub_uint32_t)) - 1,
+ (unsigned long long)
+ (space & GRUB_PCI_ADDR_IO_MASK));
+ break;
+ case GRUB_PCI_ADDR_SPACE_MEMORY:
+ if ((space & GRUB_PCI_ADDR_MEM_TYPE_MASK)
+ == GRUB_PCI_ADDR_MEM_TYPE_64)
+ {
+ addr = grub_pci_make_address (dev, reg);
+ space |= ((grub_uint64_t) grub_pci_read (addr)) << 32;
+ reg += sizeof (grub_uint32_t);
+ grub_printf ("\t64-bit memory space %d at 0x%016llx [%s]\n",
+ (unsigned) ((reg - GRUB_PCI_REG_ADDRESSES)
+ / sizeof (grub_uint32_t)) - 2,
+ (unsigned long long)
+ (space & GRUB_PCI_ADDR_MEM_MASK),
+ space & GRUB_PCI_ADDR_MEM_PREFETCH
+ ? "prefetchable" : "non-prefetchable");
+
+ }
+ else
+ grub_printf ("\t32-bit memory space %d at 0x%016llx [%s]\n",
+ (unsigned) ((reg - GRUB_PCI_REG_ADDRESSES)
+ / sizeof (grub_uint32_t)) - 1,
+ (unsigned long long)
+ (space & GRUB_PCI_ADDR_MEM_MASK),
+ space & GRUB_PCI_ADDR_MEM_PREFETCH
+ ? "prefetchable" : "non-prefetchable");
+ break;
+ }
+ }
+ }
+
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_lspci (grub_extcmd_context_t ctxt,
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ iospace = ctxt->state[0].set;
+ grub_pci_iterate (grub_lspci_iter, NULL);
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(lspci)
+{
+ cmd = grub_register_extcmd ("lspci", grub_cmd_lspci, 0, "[-i]",
+ N_("List PCI devices."), options);
+}
+
+GRUB_MOD_FINI(lspci)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/macbless.c b/grub-core/commands/macbless.c
new file mode 100644
index 0000000..85cefd0
--- /dev/null
+++ b/grub-core/commands/macbless.c
@@ -0,0 +1,235 @@
+/* hfspbless.c - set the hfs+ boot directory. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2007,2008,2009,2012,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/command.h>
+#include <grub/fs.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/hfsplus.h>
+#include <grub/hfs.h>
+#include <grub/partition.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct find_node_context
+{
+ grub_uint64_t inode_found;
+ char *dirname;
+ enum
+ { FOUND_NONE, FOUND_FILE, FOUND_DIR } found;
+};
+
+static int
+find_inode (const char *filename,
+ const struct grub_dirhook_info *info, void *data)
+{
+ struct find_node_context *ctx = data;
+ if (!info->inodeset)
+ return 0;
+
+ if ((grub_strcmp (ctx->dirname, filename) == 0
+ || (info->case_insensitive
+ && grub_strcasecmp (ctx->dirname, filename) == 0)))
+ {
+ ctx->inode_found = info->inode;
+ ctx->found = info->dir ? FOUND_DIR : FOUND_FILE;
+ }
+ return 0;
+}
+
+grub_err_t
+grub_mac_bless_inode (grub_device_t dev, grub_uint32_t inode, int is_dir,
+ int intel)
+{
+ grub_err_t err;
+ union
+ {
+ struct grub_hfs_sblock hfs;
+ struct grub_hfsplus_volheader hfsplus;
+ } volheader;
+ grub_disk_addr_t embedded_offset;
+
+ if (intel && is_dir)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "can't bless a directory for mactel");
+ if (!intel && !is_dir)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "can't bless a file for mac PPC");
+
+ /* Read the bootblock. */
+ err = grub_disk_read (dev->disk, GRUB_HFSPLUS_SBLOCK, 0, sizeof (volheader),
+ (char *) &volheader);
+ if (err)
+ return err;
+
+ embedded_offset = 0;
+ if (grub_be_to_cpu16 (volheader.hfs.magic) == GRUB_HFS_MAGIC)
+ {
+ int extent_start;
+ int ablk_size;
+ int ablk_start;
+
+ /* See if there's an embedded HFS+ filesystem. */
+ if (grub_be_to_cpu16 (volheader.hfs.embed_sig) != GRUB_HFSPLUS_MAGIC)
+ {
+ if (intel)
+ volheader.hfs.intel_bootfile = grub_be_to_cpu32 (inode);
+ else
+ volheader.hfs.ppc_bootdir = grub_be_to_cpu32 (inode);
+ return GRUB_ERR_NONE;
+ }
+
+ /* Calculate the offset needed to translate HFS+ sector numbers. */
+ extent_start =
+ grub_be_to_cpu16 (volheader.hfs.embed_extent.first_block);
+ ablk_size = grub_be_to_cpu32 (volheader.hfs.blksz);
+ ablk_start = grub_be_to_cpu16 (volheader.hfs.first_block);
+ embedded_offset = (ablk_start
+ + ((grub_uint64_t) extent_start)
+ * (ablk_size >> GRUB_DISK_SECTOR_BITS));
+
+ err =
+ grub_disk_read (dev->disk, embedded_offset + GRUB_HFSPLUS_SBLOCK, 0,
+ sizeof (volheader), (char *) &volheader);
+ if (err)
+ return err;
+ }
+
+ if ((grub_be_to_cpu16 (volheader.hfsplus.magic) != GRUB_HFSPLUS_MAGIC)
+ && (grub_be_to_cpu16 (volheader.hfsplus.magic) != GRUB_HFSPLUSX_MAGIC))
+ return grub_error (GRUB_ERR_BAD_FS, "not a HFS+ filesystem");
+ if (intel)
+ volheader.hfsplus.intel_bootfile = grub_be_to_cpu32 (inode);
+ else
+ volheader.hfsplus.ppc_bootdir = grub_be_to_cpu32 (inode);
+
+ return grub_disk_write (dev->disk, embedded_offset + GRUB_HFSPLUS_SBLOCK, 0,
+ sizeof (volheader), (char *) &volheader);
+}
+
+grub_err_t
+grub_mac_bless_file (grub_device_t dev, const char *path_in, int intel)
+{
+ grub_fs_t fs;
+
+ char *path, *tail;
+ struct find_node_context ctx;
+
+ fs = grub_fs_probe (dev);
+ if (!fs || (grub_strcmp (fs->name, "hfsplus") != 0
+ && grub_strcmp (fs->name, "hfs") != 0))
+ return grub_error (GRUB_ERR_BAD_FS, "no suitable FS found");
+
+ path = grub_strdup (path_in);
+ if (!path)
+ return grub_errno;
+
+ tail = path + grub_strlen (path) - 1;
+
+ /* Remove trailing '/'. */
+ while (tail != path && *tail == '/')
+ *(tail--) = 0;
+
+ tail = grub_strrchr (path, '/');
+ ctx.found = 0;
+
+ if (tail)
+ {
+ *tail = 0;
+ ctx.dirname = tail + 1;
+
+ (fs->fs_dir) (dev, *path == 0 ? "/" : path, find_inode, &ctx);
+ }
+ else
+ {
+ ctx.dirname = path + 1;
+ (fs->fs_dir) (dev, "/", find_inode, &ctx);
+ }
+ if (!ctx.found)
+ {
+ grub_free (path);
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
+ path_in);
+ }
+ grub_free (path);
+
+ return grub_mac_bless_inode (dev, (grub_uint32_t) ctx.inode_found,
+ (ctx.found == FOUND_DIR), intel);
+}
+
+static grub_err_t
+grub_cmd_macbless (grub_command_t cmd, int argc, char **args)
+{
+ char *device_name;
+ char *path = 0;
+ grub_device_t dev = 0;
+ grub_err_t err;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+ device_name = grub_file_get_device_name (args[0]);
+ dev = grub_device_open (device_name);
+
+ path = grub_strchr (args[0], ')');
+ if (!path)
+ path = args[0];
+ else
+ path = path + 1;
+
+ if (!path || *path == 0 || !dev)
+ {
+ if (dev)
+ grub_device_close (dev);
+
+ grub_free (device_name);
+
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
+ }
+
+ err = grub_mac_bless_file (dev, path, cmd->name[3] == 't');
+
+ grub_device_close (dev);
+ grub_free (device_name);
+ return err;
+}
+
+static grub_command_t cmd, cmd_ppc;
+
+GRUB_MOD_INIT(macbless)
+{
+ cmd = grub_register_command ("mactelbless", grub_cmd_macbless,
+ N_("FILE"),
+ N_
+ ("Bless FILE of HFS or HFS+ partition for intel macs."));
+ cmd_ppc =
+ grub_register_command ("macppcbless", grub_cmd_macbless, N_("DIR"),
+ N_
+ ("Bless DIR of HFS or HFS+ partition for PPC macs."));
+}
+
+GRUB_MOD_FINI(macbless)
+{
+ grub_unregister_command (cmd);
+ grub_unregister_command (cmd_ppc);
+}
diff --git a/grub-core/commands/memrw.c b/grub-core/commands/memrw.c
new file mode 100644
index 0000000..d401a6d
--- /dev/null
+++ b/grub-core/commands/memrw.c
@@ -0,0 +1,158 @@
+/* memrw.c - command to read / write physical memory */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/env.h>
+#include <grub/i18n.h>
+#include <grub/lockdown.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_extcmd_t cmd_read_byte, cmd_read_word, cmd_read_dword;
+static grub_command_t cmd_write_byte, cmd_write_word, cmd_write_dword;
+
+static const struct grub_arg_option options[] =
+ {
+ {0, 'v', 0, N_("Save read value into variable VARNAME."),
+ N_("VARNAME"), ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+
+static grub_err_t
+grub_cmd_read (grub_extcmd_context_t ctxt, int argc, char **argv)
+{
+ grub_addr_t addr;
+ grub_uint32_t value = 0;
+ char buf[sizeof ("XXXXXXXX")];
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ addr = grub_strtoul (argv[0], 0, 0);
+ switch (ctxt->extcmd->cmd->name[sizeof ("read_") - 1])
+ {
+ case 'd':
+ value = *((volatile grub_uint32_t *) addr);
+ break;
+
+ case 'w':
+ value = *((volatile grub_uint16_t *) addr);
+ break;
+
+ case 'b':
+ value = *((volatile grub_uint8_t *) addr);
+ break;
+ }
+
+ if (ctxt->state[0].set)
+ {
+ grub_snprintf (buf, sizeof (buf), "%x", value);
+ grub_env_set (ctxt->state[0].arg, buf);
+ }
+ else
+ grub_printf ("0x%x\n", value);
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_write (grub_command_t cmd, int argc, char **argv)
+{
+ grub_addr_t addr;
+ grub_uint32_t value;
+ grub_uint32_t mask = 0xffffffff;
+
+ if (argc != 2 && argc != 3)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+ addr = grub_strtoul (argv[0], 0, 0);
+ value = grub_strtoul (argv[1], 0, 0);
+ if (argc == 3)
+ mask = grub_strtoul (argv[2], 0, 0);
+ value &= mask;
+ switch (cmd->name[sizeof ("write_") - 1])
+ {
+ case 'd':
+ if (mask != 0xffffffff)
+ *((volatile grub_uint32_t *) addr)
+ = (*((volatile grub_uint32_t *) addr) & ~mask) | value;
+ else
+ *((volatile grub_uint32_t *) addr) = value;
+ break;
+
+ case 'w':
+ if ((mask & 0xffff) != 0xffff)
+ *((volatile grub_uint16_t *) addr)
+ = (*((volatile grub_uint16_t *) addr) & ~mask) | value;
+ else
+ *((volatile grub_uint16_t *) addr) = value;
+ break;
+
+ case 'b':
+ if ((mask & 0xff) != 0xff)
+ *((volatile grub_uint8_t *) addr)
+ = (*((volatile grub_uint8_t *) addr) & ~mask) | value;
+ else
+ *((volatile grub_uint8_t *) addr) = value;
+ break;
+ }
+
+ return 0;
+}
+
+GRUB_MOD_INIT(memrw)
+{
+ cmd_read_byte =
+ grub_register_extcmd ("read_byte", grub_cmd_read, 0,
+ N_("ADDR"), N_("Read 8-bit value from ADDR."),
+ options);
+ cmd_read_word =
+ grub_register_extcmd ("read_word", grub_cmd_read, 0,
+ N_("ADDR"), N_("Read 16-bit value from ADDR."),
+ options);
+ cmd_read_dword =
+ grub_register_extcmd ("read_dword", grub_cmd_read, 0,
+ N_("ADDR"), N_("Read 32-bit value from ADDR."),
+ options);
+ cmd_write_byte =
+ grub_register_command_lockdown ("write_byte", grub_cmd_write,
+ N_("ADDR VALUE [MASK]"),
+ N_("Write 8-bit VALUE to ADDR."));
+ cmd_write_word =
+ grub_register_command_lockdown ("write_word", grub_cmd_write,
+ N_("ADDR VALUE [MASK]"),
+ N_("Write 16-bit VALUE to ADDR."));
+ cmd_write_dword =
+ grub_register_command_lockdown ("write_dword", grub_cmd_write,
+ N_("ADDR VALUE [MASK]"),
+ N_("Write 32-bit VALUE to ADDR."));
+}
+
+GRUB_MOD_FINI(memrw)
+{
+ grub_unregister_extcmd (cmd_read_byte);
+ grub_unregister_extcmd (cmd_read_word);
+ grub_unregister_extcmd (cmd_read_dword);
+ grub_unregister_command (cmd_write_byte);
+ grub_unregister_command (cmd_write_word);
+ grub_unregister_command (cmd_write_dword);
+}
diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c
new file mode 100644
index 0000000..720e6d8
--- /dev/null
+++ b/grub-core/commands/menuentry.c
@@ -0,0 +1,337 @@
+/* menuentry.c - menuentry command */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/normal.h>
+
+static const struct grub_arg_option options[] =
+ {
+ {"class", 1, GRUB_ARG_OPTION_REPEATABLE,
+ N_("Menu entry type."), N_("STRING"), ARG_TYPE_STRING},
+ {"users", 2, 0,
+ N_("List of users allowed to boot this entry."), N_("USERNAME[,USERNAME]"),
+ ARG_TYPE_STRING},
+ {"hotkey", 3, 0,
+ N_("Keyboard key to quickly boot this entry."), N_("KEYBOARD_KEY"), ARG_TYPE_STRING},
+ {"source", 4, 0,
+ N_("Use STRING as menu entry body."), N_("STRING"), ARG_TYPE_STRING},
+ {"id", 0, 0, N_("Menu entry identifier."), N_("STRING"), ARG_TYPE_STRING},
+ /* TRANSLATORS: menu entry can either be bootable by anyone or only by
+ handful of users. By default when security is active only superusers can
+ boot a given menu entry. With --unrestricted (this option)
+ anyone can boot it. */
+ {"unrestricted", 0, 0, N_("This entry can be booted by any user."),
+ 0, ARG_TYPE_NONE},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static struct
+{
+ const char *name;
+ int key;
+} hotkey_aliases[] =
+ {
+ {"backspace", GRUB_TERM_BACKSPACE},
+ {"tab", GRUB_TERM_TAB},
+ {"delete", GRUB_TERM_KEY_DC},
+ {"insert", GRUB_TERM_KEY_INSERT},
+ {"f1", GRUB_TERM_KEY_F1},
+ {"f2", GRUB_TERM_KEY_F2},
+ {"f3", GRUB_TERM_KEY_F3},
+ {"f4", GRUB_TERM_KEY_F4},
+ {"f5", GRUB_TERM_KEY_F5},
+ {"f6", GRUB_TERM_KEY_F6},
+ {"f7", GRUB_TERM_KEY_F7},
+ {"f8", GRUB_TERM_KEY_F8},
+ {"f9", GRUB_TERM_KEY_F9},
+ {"f10", GRUB_TERM_KEY_F10},
+ {"f11", GRUB_TERM_KEY_F11},
+ {"f12", GRUB_TERM_KEY_F12},
+ };
+
+/* Add a menu entry to the current menu context (as given by the environment
+ variable data slot `menu'). As the configuration file is read, the script
+ parser calls this when a menu entry is to be created. */
+grub_err_t
+grub_normal_add_menu_entry (int argc, const char **args,
+ char **classes, const char *id,
+ const char *users, const char *hotkey,
+ const char *prefix, const char *sourcecode,
+ int submenu)
+{
+ int menu_hotkey = 0;
+ char **menu_args = NULL;
+ char *menu_users = NULL;
+ char *menu_title = NULL;
+ char *menu_sourcecode = NULL;
+ char *menu_id = NULL;
+ struct grub_menu_entry_class *menu_classes = NULL;
+
+ grub_menu_t menu;
+ grub_menu_entry_t *last;
+
+ menu = grub_env_get_menu ();
+ if (! menu)
+ return grub_error (GRUB_ERR_MENU, "no menu context");
+
+ last = &menu->entry_list;
+
+ menu_sourcecode = grub_xasprintf ("%s%s", prefix ?: "", sourcecode);
+ if (! menu_sourcecode)
+ return grub_errno;
+
+ if (classes && classes[0])
+ {
+ int i;
+ for (i = 0; classes[i]; i++); /* count # of menuentry classes */
+ menu_classes = grub_zalloc (sizeof (struct grub_menu_entry_class)
+ * (i + 1));
+ if (! menu_classes)
+ goto fail;
+
+ for (i = 0; classes[i]; i++)
+ {
+ menu_classes[i].name = grub_strdup (classes[i]);
+ if (! menu_classes[i].name)
+ goto fail;
+ menu_classes[i].next = classes[i + 1] ? &menu_classes[i + 1] : NULL;
+ }
+ }
+
+ if (users)
+ {
+ menu_users = grub_strdup (users);
+ if (! menu_users)
+ goto fail;
+ }
+
+ if (hotkey)
+ {
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE (hotkey_aliases); i++)
+ if (grub_strcmp (hotkey, hotkey_aliases[i].name) == 0)
+ {
+ menu_hotkey = hotkey_aliases[i].key;
+ break;
+ }
+ if (i == ARRAY_SIZE (hotkey_aliases))
+ menu_hotkey = hotkey[0];
+ }
+
+ if (! argc)
+ {
+ grub_error (GRUB_ERR_MENU, "menuentry is missing title");
+ goto fail;
+ }
+
+ menu_title = grub_strdup (args[0]);
+ if (! menu_title)
+ goto fail;
+
+ menu_id = grub_strdup (id ? : menu_title);
+ if (! menu_id)
+ goto fail;
+
+ /* Save argc, args to pass as parameters to block arg later. */
+ menu_args = grub_calloc (argc + 1, sizeof (char *));
+ if (! menu_args)
+ goto fail;
+
+ {
+ int i;
+ for (i = 0; i < argc; i++)
+ {
+ menu_args[i] = grub_strdup (args[i]);
+ if (! menu_args[i])
+ goto fail;
+ }
+ menu_args[argc] = NULL;
+ }
+
+ /* Add the menu entry at the end of the list. */
+ while (*last)
+ last = &(*last)->next;
+
+ *last = grub_zalloc (sizeof (**last));
+ if (! *last)
+ goto fail;
+
+ (*last)->title = menu_title;
+ (*last)->id = menu_id;
+ (*last)->hotkey = menu_hotkey;
+ (*last)->classes = menu_classes;
+ if (menu_users)
+ (*last)->restricted = 1;
+ (*last)->users = menu_users;
+ (*last)->argc = argc;
+ (*last)->args = menu_args;
+ (*last)->sourcecode = menu_sourcecode;
+ (*last)->submenu = submenu;
+
+ menu->size++;
+ return GRUB_ERR_NONE;
+
+ fail:
+
+ grub_free (menu_sourcecode);
+ {
+ int i;
+ for (i = 0; menu_classes && menu_classes[i].name; i++)
+ grub_free (menu_classes[i].name);
+ grub_free (menu_classes);
+ }
+
+ {
+ int i;
+ for (i = 0; menu_args && menu_args[i]; i++)
+ grub_free (menu_args[i]);
+ grub_free (menu_args);
+ }
+
+ grub_free (menu_users);
+ grub_free (menu_title);
+ grub_free (menu_id);
+ return grub_errno;
+}
+
+static char *
+setparams_prefix (int argc, char **args)
+{
+ int i;
+ int j;
+ char *p;
+ char *result;
+ grub_size_t len = 10;
+
+ /* Count resulting string length */
+ for (i = 0; i < argc; i++)
+ {
+ len += 3; /* 3 = 1 space + 2 quotes */
+ p = args[i];
+ while (*p)
+ len += (*p++ == '\'' ? 4 : 1);
+ }
+
+ result = grub_malloc (len + 2);
+ if (! result)
+ return 0;
+
+ grub_strcpy (result, "setparams");
+ p = result + 9;
+
+ for (j = 0; j < argc; j++)
+ {
+ *p++ = ' ';
+ *p++ = '\'';
+ p = grub_strchrsub (p, args[j], '\'', "'\\''");
+ *p++ = '\'';
+ }
+ *p++ = '\n';
+ *p = '\0';
+ return result;
+}
+
+static grub_err_t
+grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ char ch;
+ char *src;
+ char *prefix;
+ unsigned len;
+ grub_err_t r;
+ const char *users;
+
+ if (! argc)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing arguments");
+
+ if (ctxt->state[3].set && ctxt->script)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "multiple menuentry definitions");
+
+ if (! ctxt->state[3].set && ! ctxt->script)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no menuentry definition");
+
+ if (ctxt->state[1].set)
+ users = ctxt->state[1].arg;
+ else if (ctxt->state[5].set)
+ users = NULL;
+ else
+ users = "";
+
+ if (! ctxt->script)
+ return grub_normal_add_menu_entry (argc, (const char **) args,
+ (ctxt->state[0].set ? ctxt->state[0].args
+ : NULL),
+ ctxt->state[4].arg,
+ users,
+ ctxt->state[2].arg, 0,
+ ctxt->state[3].arg,
+ ctxt->extcmd->cmd->name[0] == 's');
+
+ src = args[argc - 1];
+ args[argc - 1] = NULL;
+
+ len = grub_strlen(src);
+ ch = src[len - 1];
+ src[len - 1] = '\0';
+
+ prefix = setparams_prefix (argc - 1, args);
+ if (! prefix)
+ return grub_errno;
+
+ r = grub_normal_add_menu_entry (argc - 1, (const char **) args,
+ ctxt->state[0].args, ctxt->state[4].arg,
+ users,
+ ctxt->state[2].arg, prefix, src + 1,
+ ctxt->extcmd->cmd->name[0] == 's');
+
+ src[len - 1] = ch;
+ args[argc - 1] = src;
+ grub_free (prefix);
+ return r;
+}
+
+static grub_extcmd_t cmd, cmd_sub;
+
+void
+grub_menu_init (void)
+{
+ cmd = grub_register_extcmd ("menuentry", grub_cmd_menuentry,
+ GRUB_COMMAND_FLAG_BLOCKS
+ | GRUB_COMMAND_ACCEPT_DASH
+ | GRUB_COMMAND_FLAG_EXTRACTOR,
+ N_("BLOCK"), N_("Define a menu entry."), options);
+ cmd_sub = grub_register_extcmd ("submenu", grub_cmd_menuentry,
+ GRUB_COMMAND_FLAG_BLOCKS
+ | GRUB_COMMAND_ACCEPT_DASH
+ | GRUB_COMMAND_FLAG_EXTRACTOR,
+ N_("BLOCK"), N_("Define a submenu."),
+ options);
+}
+
+void
+grub_menu_fini (void)
+{
+ grub_unregister_extcmd (cmd);
+ grub_unregister_extcmd (cmd_sub);
+}
diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c
new file mode 100644
index 0000000..fa49893
--- /dev/null
+++ b/grub-core/commands/minicmd.c
@@ -0,0 +1,227 @@
+/* minicmd.c - commands for the rescue mode */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/term.h>
+#include <grub/loader.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* cat FILE */
+static grub_err_t
+grub_mini_cmd_cat (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file;
+ char buf[GRUB_DISK_SECTOR_SIZE];
+ grub_ssize_t size;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_CAT);
+ if (! file)
+ return grub_errno;
+
+ while ((size = grub_file_read (file, buf, sizeof (buf))) > 0)
+ {
+ int i;
+
+ for (i = 0; i < size; i++)
+ {
+ unsigned char c = buf[i];
+
+ if ((grub_isprint (c) || grub_isspace (c)) && c != '\r')
+ grub_printf ("%c", c);
+ else
+ {
+ grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
+ grub_printf ("<%x>", (int) c);
+ grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
+ }
+ }
+ }
+
+ grub_xputs ("\n");
+ grub_refresh ();
+ grub_file_close (file);
+
+ return 0;
+}
+
+/* help */
+static grub_err_t
+grub_mini_cmd_help (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ grub_command_t p;
+
+ for (p = grub_command_list; p; p = p->next)
+ grub_printf ("%s (%d%c)\t%s\n", p->name,
+ p->prio & GRUB_COMMAND_PRIO_MASK,
+ (p->prio & GRUB_COMMAND_FLAG_ACTIVE) ? '+' : '-',
+ p->description);
+
+ return 0;
+}
+
+/* dump ADDRESS [SIZE] */
+static grub_err_t
+grub_mini_cmd_dump (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_uint8_t *addr;
+ grub_size_t size = 4;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no address specified");
+
+#if GRUB_CPU_SIZEOF_VOID_P == GRUB_CPU_SIZEOF_LONG
+#define grub_strtoaddr grub_strtoul
+#else
+#define grub_strtoaddr grub_strtoull
+#endif
+
+ addr = (grub_uint8_t *) grub_strtoaddr (argv[0], 0, 0);
+ if (grub_errno)
+ return grub_errno;
+
+ if (argc > 1)
+ size = (grub_size_t) grub_strtoaddr (argv[1], 0, 0);
+
+ while (size--)
+ {
+ grub_printf ("%x%x ", *addr >> 4, *addr & 0xf);
+ addr++;
+ }
+
+ return 0;
+}
+
+/* rmmod MODULE */
+static grub_err_t
+grub_mini_cmd_rmmod (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_dl_t mod;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified");
+
+ mod = grub_dl_get (argv[0]);
+ if (! mod)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no such module");
+
+ if (grub_dl_is_persistent (mod))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "cannot unload persistent module");
+
+ if (grub_dl_ref_count (mod) > 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "cannot unload referenced module");
+
+ grub_dl_unref (mod);
+ grub_dl_unload (mod);
+
+ return 0;
+}
+
+/* lsmod */
+static grub_err_t
+grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ grub_dl_t mod;
+
+ /* TRANSLATORS: this is module list header. Name
+ is module name, Ref Count is a reference counter
+ (how many modules or open descriptors use it).
+ Dependencies are the other modules it uses.
+ */
+ grub_printf_ (N_("Name\tRef Count\tDependencies\n"));
+ FOR_DL_MODULES (mod)
+ {
+ grub_dl_dep_t dep;
+
+ grub_printf ("%s\t%d\t\t", mod->name, mod->ref_count);
+ for (dep = mod->dep; dep; dep = dep->next)
+ {
+ if (dep != mod->dep)
+ grub_xputs (",");
+
+ grub_printf ("%s", dep->mod->name);
+ }
+ grub_xputs ("\n");
+ }
+
+ return 0;
+}
+
+/* exit */
+static grub_err_t __attribute__ ((noreturn))
+grub_mini_cmd_exit (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ grub_exit ();
+ /* Not reached. */
+}
+
+static grub_command_t cmd_cat, cmd_help;
+static grub_command_t cmd_dump, cmd_rmmod, cmd_lsmod, cmd_exit;
+
+GRUB_MOD_INIT(minicmd)
+{
+ cmd_cat =
+ grub_register_command ("cat", grub_mini_cmd_cat,
+ N_("FILE"), N_("Show the contents of a file."));
+ cmd_help =
+ grub_register_command ("help", grub_mini_cmd_help,
+ 0, N_("Show this message."));
+ cmd_dump =
+ grub_register_command ("dump", grub_mini_cmd_dump,
+ N_("ADDR [SIZE]"), N_("Show memory contents."));
+ cmd_rmmod =
+ grub_register_command ("rmmod", grub_mini_cmd_rmmod,
+ N_("MODULE"), N_("Remove a module."));
+ cmd_lsmod =
+ grub_register_command ("lsmod", grub_mini_cmd_lsmod,
+ 0, N_("Show loaded modules."));
+ cmd_exit =
+ grub_register_command ("exit", grub_mini_cmd_exit,
+ 0, N_("Exit from GRUB."));
+}
+
+GRUB_MOD_FINI(minicmd)
+{
+ grub_unregister_command (cmd_cat);
+ grub_unregister_command (cmd_help);
+ grub_unregister_command (cmd_dump);
+ grub_unregister_command (cmd_rmmod);
+ grub_unregister_command (cmd_lsmod);
+ grub_unregister_command (cmd_exit);
+}
diff --git a/grub-core/commands/mips/loongson/lsspd.c b/grub-core/commands/mips/loongson/lsspd.c
new file mode 100644
index 0000000..a88ab87
--- /dev/null
+++ b/grub-core/commands/mips/loongson/lsspd.c
@@ -0,0 +1,103 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/cs5536.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_lsspd (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_pci_device_t dev;
+ grub_port_t smbbase;
+ int i;
+ grub_err_t err;
+
+ if (!grub_cs5536_find (&dev))
+ {
+ grub_puts_ (N_("No CS5536 found"));
+ return GRUB_ERR_NONE;
+ }
+ grub_printf_ (N_("CS5536 at %d:%d.%d\n"), grub_pci_get_bus (dev),
+ grub_pci_get_device (dev), grub_pci_get_function (dev));
+
+ err = grub_cs5536_init_smbus (dev, 0x7fff, &smbbase);
+ if (err)
+ return err;
+
+ /* TRANSLATORS: System management bus is often used to access components like
+ RAM (info only, not data) or batteries. I/O space is where in memory
+ its ports are. */
+ grub_printf_ (N_("System management bus controller I/O space is at 0x%x\n"),
+ smbbase);
+
+ for (i = GRUB_SMB_RAM_START_ADDR;
+ i < GRUB_SMB_RAM_START_ADDR + GRUB_SMB_RAM_NUM_MAX; i++)
+ {
+ struct grub_smbus_spd spd;
+ grub_memset (&spd, 0, sizeof (spd));
+ /* TRANSLATORS: it's shown in a report in a way
+ like number 1: ... number 2: ...
+ */
+ grub_printf_ (N_("RAM slot number %d\n"), i);
+ err = grub_cs5536_read_spd (smbbase, i, &spd);
+ if (err)
+ {
+ grub_print_error ();
+ continue;
+ }
+ grub_printf_ (N_("Written SPD bytes: %d B.\n"), spd.written_size);
+ grub_printf_ (N_("Total flash size: %d B.\n"),
+ 1 << spd.log_total_flash_size);
+ if (spd.memory_type == GRUB_SMBUS_SPD_MEMORY_TYPE_DDR2)
+ {
+ char str[sizeof (spd.ddr2.part_number) + 1];
+ grub_puts_ (N_("Memory type: DDR2."));
+ grub_memcpy (str, spd.ddr2.part_number,
+ sizeof (spd.ddr2.part_number));
+ str[sizeof (spd.ddr2.part_number)] = 0;
+ grub_printf_ (N_("Part no: %s.\n"), str);
+ }
+ else
+ grub_puts_ (N_("Memory type: Unknown."));
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lsspd)
+{
+ cmd = grub_register_command ("lsspd", grub_cmd_lsspd, 0,
+ N_("Print Memory information."));
+}
+
+GRUB_MOD_FINI(lsspd)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c
new file mode 100644
index 0000000..7c8f97f
--- /dev/null
+++ b/grub-core/commands/nativedisk.c
@@ -0,0 +1,332 @@
+/*
+ * 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/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/device.h>
+#include <grub/mm.h>
+#include <grub/fs.h>
+#include <grub/env.h>
+#include <grub/file.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const char *modnames_def[] = {
+ /* FIXME: autogenerate this. */
+#if defined (__i386__) || defined (__x86_64__) || defined (GRUB_MACHINE_MIPS_LOONGSON)
+ "pata", "ahci", "usbms", "ohci", "uhci", "ehci"
+#elif defined (GRUB_MACHINE_MIPS_QEMU_MIPS)
+ "pata"
+#else
+#error "Fill this"
+#endif
+ };
+
+static grub_err_t
+get_uuid (const char *name, char **uuid, int getnative)
+{
+ grub_device_t dev;
+ grub_fs_t fs = 0;
+
+ *uuid = 0;
+
+ dev = grub_device_open (name);
+ if (!dev)
+ return grub_errno;
+
+ if (!dev->disk)
+ {
+ grub_dprintf ("nativedisk", "Skipping non-disk\n");
+ grub_device_close (dev);
+ return 0;
+ }
+
+ switch (dev->disk->dev->id)
+ {
+ /* Firmware disks. */
+ case GRUB_DISK_DEVICE_BIOSDISK_ID:
+ case GRUB_DISK_DEVICE_OFDISK_ID:
+ case GRUB_DISK_DEVICE_OBDISK_ID:
+ case GRUB_DISK_DEVICE_EFIDISK_ID:
+ case GRUB_DISK_DEVICE_NAND_ID:
+ case GRUB_DISK_DEVICE_ARCDISK_ID:
+ case GRUB_DISK_DEVICE_HOSTDISK_ID:
+ case GRUB_DISK_DEVICE_UBOOTDISK_ID:
+ break;
+
+ /* Native disks. */
+ case GRUB_DISK_DEVICE_ATA_ID:
+ case GRUB_DISK_DEVICE_SCSI_ID:
+ case GRUB_DISK_DEVICE_XEN:
+ if (getnative)
+ break;
+ /* FALLTHROUGH */
+
+ /* Virtual disks. */
+ /* GRUB dynamically generated files. */
+ case GRUB_DISK_DEVICE_PROCFS_ID:
+ /* To access through host OS routines (grub-emu only). */
+ case GRUB_DISK_DEVICE_HOST_ID:
+ /* To access coreboot roms. */
+ case GRUB_DISK_DEVICE_CBFSDISK_ID:
+ /* GRUB-only memdisk. Can't match any of firmware devices. */
+ 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. */
+ case GRUB_DISK_DEVICE_LOOPBACK_ID:
+ case GRUB_DISK_DEVICE_DISKFILTER_ID:
+ case GRUB_DISK_DEVICE_CRYPTODISK_ID:
+ break;
+ }
+ if (dev)
+ fs = grub_fs_probe (dev);
+ if (!fs)
+ {
+ grub_device_close (dev);
+ return grub_errno;
+ }
+ if (!fs->fs_uuid || fs->fs_uuid (dev, uuid) || !*uuid)
+ {
+ grub_device_close (dev);
+
+ if (!grub_errno)
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("%s does not support UUIDs"), fs->name);
+
+ return grub_errno;
+ }
+ grub_device_close (dev);
+ return GRUB_ERR_NONE;
+}
+
+struct search_ctx
+{
+ char *root_uuid;
+ char *prefix_uuid;
+ const char *prefix_path;
+ int prefix_found, root_found;
+};
+
+static int
+iterate_device (const char *name, void *data)
+{
+ struct search_ctx *ctx = data;
+ char *cur_uuid;
+
+ if (get_uuid (name, &cur_uuid, 1))
+ {
+ if (grub_errno == GRUB_ERR_UNKNOWN_FS)
+ grub_errno = 0;
+ grub_print_error ();
+ return 0;
+ }
+
+ grub_dprintf ("nativedisk", "checking %s: %s\n", name,
+ cur_uuid);
+ if (ctx->prefix_uuid && grub_strcasecmp (cur_uuid, ctx->prefix_uuid) == 0)
+ {
+ char *prefix;
+ prefix = grub_xasprintf ("(%s)/%s", name, ctx->prefix_path);
+ grub_env_set ("prefix", prefix);
+ grub_free (prefix);
+ ctx->prefix_found = 1;
+ }
+ if (ctx->root_uuid && grub_strcasecmp (cur_uuid, ctx->root_uuid) == 0)
+ {
+ grub_env_set ("root", name);
+ ctx->root_found = 1;
+ }
+ return ctx->prefix_found && ctx->root_found;
+}
+
+static grub_err_t
+grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args_in)
+{
+ char *uuid_root = 0, *uuid_prefix, *prefdev = 0;
+ const char *prefix = 0;
+ const char *path_prefix = 0;
+ int mods_loaded = 0;
+ grub_dl_t *mods;
+ const char **args;
+ int i;
+
+ if (argc == 0)
+ {
+ argc = ARRAY_SIZE (modnames_def);
+ args = modnames_def;
+ }
+ else
+ args = (const char **) args_in;
+
+ prefix = grub_env_get ("prefix");
+
+ if (! prefix)
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
+
+ if (prefix)
+ path_prefix = (prefix[0] == '(') ? grub_strchr (prefix, ')') : NULL;
+ if (path_prefix)
+ path_prefix++;
+ else
+ path_prefix = prefix;
+
+ mods = grub_calloc (argc, sizeof (mods[0]));
+ if (!mods)
+ return grub_errno;
+
+ if (get_uuid (NULL, &uuid_root, 0))
+ {
+ grub_free (mods);
+ return grub_errno;
+ }
+
+ prefdev = grub_file_get_device_name (prefix);
+ if (grub_errno)
+ {
+ grub_print_error ();
+ prefdev = 0;
+ }
+
+ if (get_uuid (prefdev, &uuid_prefix, 0))
+ {
+ grub_free (uuid_root);
+ grub_free (prefdev);
+ grub_free (mods);
+ return grub_errno;
+ }
+
+ grub_dprintf ("nativedisk", "uuid_prefix = %s, uuid_root = %s\n",
+ uuid_prefix, uuid_root);
+
+ for (mods_loaded = 0; mods_loaded < argc; mods_loaded++)
+ {
+ char *filename;
+ grub_dl_t mod;
+ grub_file_t file = NULL;
+ grub_ssize_t size;
+ void *core = 0;
+
+ mod = grub_dl_get (args[mods_loaded]);
+ if (mod)
+ {
+ mods[mods_loaded] = 0;
+ continue;
+ }
+
+ filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM "/%s.mod",
+ prefix, args[mods_loaded]);
+ if (! filename)
+ goto fail;
+
+ file = grub_file_open (filename,
+ GRUB_FILE_TYPE_GRUB_MODULE);
+ grub_free (filename);
+ if (! file)
+ goto fail;
+
+ size = grub_file_size (file);
+ core = grub_malloc (size);
+ if (! core)
+ {
+ grub_file_close (file);
+ goto fail;
+ }
+
+ if (grub_file_read (file, core, size) != (grub_ssize_t) size)
+ {
+ grub_file_close (file);
+ grub_free (core);
+ goto fail;
+ }
+
+ grub_file_close (file);
+
+ mods[mods_loaded] = grub_dl_load_core_noinit (core, size);
+ if (! mods[mods_loaded])
+ goto fail;
+ }
+
+ for (i = 0; i < argc; i++)
+ if (mods[i])
+ grub_dl_init (mods[i]);
+
+ if (uuid_prefix || uuid_root)
+ {
+ struct search_ctx ctx;
+ grub_fs_autoload_hook_t saved_autoload;
+
+ /* No need to autoload FS since obviously we already have the necessary fs modules. */
+ saved_autoload = grub_fs_autoload_hook;
+ grub_fs_autoload_hook = 0;
+
+ ctx.root_uuid = uuid_root;
+ ctx.prefix_uuid = uuid_prefix;
+ ctx.prefix_path = path_prefix;
+ ctx.prefix_found = !uuid_prefix;
+ ctx.root_found = !uuid_root;
+
+ /* FIXME: try to guess the correct values. */
+ grub_device_iterate (iterate_device, &ctx);
+
+ grub_fs_autoload_hook = saved_autoload;
+ }
+ 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])
+ {
+ mods[i]->fini = 0;
+ grub_dl_unload (mods[i]);
+ }
+ grub_free (mods);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(nativedisk)
+{
+ cmd = grub_register_command ("nativedisk", grub_cmd_nativedisk, N_("[MODULE1 MODULE2 ...]"),
+ N_("Switch to native disk drivers. If no modules are specified default set (pata,ahci,usbms,ohci,uhci,ehci) is used"));
+}
+
+GRUB_MOD_FINI(nativedisk)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c
new file mode 100644
index 0000000..051e313
--- /dev/null
+++ b/grub-core/commands/parttool.c
@@ -0,0 +1,357 @@
+/* parttool.c - common dispatcher and parser for partition operations */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/normal.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/parttool.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv2+");
+
+static struct grub_parttool *parts = 0;
+static int curhandle = 0;
+static grub_dl_t mymod;
+static char helpmsg[] =
+ N_("Perform COMMANDS on partition.\n"
+ "Use `parttool PARTITION help' for the list "
+ "of available commands.");
+
+int
+grub_parttool_register(const char *part_name,
+ const grub_parttool_function_t func,
+ const struct grub_parttool_argdesc *args)
+{
+ struct grub_parttool *cur;
+ int nargs = 0;
+
+ if (! parts)
+ grub_dl_ref (mymod);
+
+ cur = (struct grub_parttool *) grub_malloc (sizeof (struct grub_parttool));
+ cur->next = parts;
+ cur->name = grub_strdup (part_name);
+ cur->handle = curhandle++;
+ for (nargs = 0; args[nargs].name != 0; nargs++);
+ cur->nargs = nargs;
+ cur->args = (struct grub_parttool_argdesc *)
+ grub_calloc (nargs + 1, sizeof (struct grub_parttool_argdesc));
+ if (!cur->args)
+ {
+ grub_free (cur);
+ curhandle--;
+ return -1;
+ }
+ grub_memcpy (cur->args, args,
+ (nargs + 1) * sizeof (struct grub_parttool_argdesc));
+
+ cur->func = func;
+ parts = cur;
+ return cur->handle;
+}
+
+void
+grub_parttool_unregister (int handle)
+{
+ struct grub_parttool *prev = 0, *cur, *t;
+ for (cur = parts; cur; )
+ if (cur->handle == handle)
+ {
+ grub_free (cur->args);
+ grub_free (cur->name);
+ if (prev)
+ prev->next = cur->next;
+ else
+ parts = cur->next;
+ t = cur;
+ cur = cur->next;
+ grub_free (t);
+ }
+ else
+ {
+ prev = cur;
+ cur = cur->next;
+ }
+ if (! parts)
+ grub_dl_unref (mymod);
+}
+
+static grub_err_t
+show_help (grub_device_t dev)
+{
+ int found = 0;
+ struct grub_parttool *cur;
+
+ for (cur = parts; cur; cur = cur->next)
+ if (grub_strcmp (dev->disk->partition->partmap->name, cur->name) == 0)
+ {
+ struct grub_parttool_argdesc *curarg;
+ found = 1;
+ for (curarg = cur->args; curarg->name; curarg++)
+ {
+ int spacing = 20;
+
+ spacing -= grub_strlen (curarg->name);
+ grub_printf ("%s", curarg->name);
+
+ switch (curarg->type)
+ {
+ case GRUB_PARTTOOL_ARG_BOOL:
+ grub_printf ("+/-");
+ spacing -= 3;
+ break;
+
+ case GRUB_PARTTOOL_ARG_VAL:
+ grub_xputs (_("=VAL"));
+ spacing -= 4;
+ break;
+
+ case GRUB_PARTTOOL_ARG_END:
+ break;
+ }
+ while (spacing-- > 0)
+ grub_printf (" ");
+ grub_puts_ (curarg->desc);
+ }
+ }
+ if (! found)
+ grub_printf_ (N_("Sorry, no parttool is available for %s\n"),
+ dev->disk->partition->partmap->name);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_device_t dev;
+ struct grub_parttool *cur, *ptool;
+ int *parsed;
+ int i, j;
+ grub_err_t err = GRUB_ERR_NONE;
+
+ if (argc < 1)
+ {
+ grub_puts_ (helpmsg);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "too few arguments");
+ }
+
+ if (args[0][0] == '(' && args[0][grub_strlen (args[0]) - 1] == ')')
+ {
+ args[0][grub_strlen (args[0]) - 1] = 0;
+ dev = grub_device_open (args[0] + 1);
+ args[0][grub_strlen (args[0]) - 1] = ')';
+ }
+ else
+ dev = grub_device_open (args[0]);
+
+ if (! dev)
+ return grub_errno;
+
+ if (! dev->disk)
+ {
+ grub_device_close (dev);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a disk");
+ }
+
+ if (! dev->disk->partition)
+ {
+ grub_device_close (dev);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a partition");
+ }
+
+ /* Load modules. */
+ if (! grub_no_modules)
+ {
+ const char *prefix;
+ prefix = grub_env_get ("prefix");
+ if (prefix)
+ {
+ char *filename;
+
+ filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM
+ "/parttool.lst", prefix);
+ if (filename)
+ {
+ grub_file_t file;
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
+ if (file)
+ {
+ char *buf = 0;
+ for (;; grub_free(buf))
+ {
+ char *p, *name;
+
+ buf = grub_file_getline (file);
+
+ if (! buf)
+ break;
+
+ name = buf;
+ while (grub_isspace (name[0]))
+ name++;
+
+ if (! grub_isgraph (name[0]))
+ continue;
+
+ p = grub_strchr (name, ':');
+ if (! p)
+ continue;
+
+ *p = '\0';
+ p++;
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (! grub_isgraph (*p))
+ continue;
+
+ if (grub_strcmp (name, dev->disk->partition->partmap->name)
+ != 0)
+ continue;
+
+ grub_dl_load (p);
+ }
+
+ grub_file_close (file);
+ }
+
+ grub_free (filename);
+ }
+ }
+ /* Ignore errors. */
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ if (argc == 1)
+ {
+ err = show_help (dev);
+ grub_device_close (dev);
+ return err;
+ }
+
+ for (i = 1; i < argc; i++)
+ if (grub_strcmp (args[i], "help") == 0)
+ {
+ err = show_help (dev);
+ grub_device_close (dev);
+ return err;
+ }
+
+ parsed = (int *) grub_calloc (argc, sizeof (int));
+
+ for (i = 1; i < argc; i++)
+ if (! parsed[i])
+ {
+ struct grub_parttool_argdesc *curarg;
+ struct grub_parttool_args *pargs;
+ for (cur = parts; cur; cur = cur->next)
+ if (grub_strcmp (dev->disk->partition->partmap->name, cur->name) == 0)
+ {
+ for (curarg = cur->args; curarg->name; curarg++)
+ if (grub_strncmp (curarg->name, args[i],
+ grub_strlen (curarg->name)) == 0
+ && ((curarg->type == GRUB_PARTTOOL_ARG_BOOL
+ && (args[i][grub_strlen (curarg->name)] == '+'
+ || args[i][grub_strlen (curarg->name)] == '-'
+ || args[i][grub_strlen (curarg->name)] == 0))
+ || (curarg->type == GRUB_PARTTOOL_ARG_VAL
+ && args[i][grub_strlen (curarg->name)] == '=')))
+
+ break;
+ if (curarg->name)
+ break;
+ }
+ if (! cur)
+ {
+ 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_calloc (ptool->nargs, sizeof (struct grub_parttool_args));
+ for (j = i; j < argc; j++)
+ if (! parsed[j])
+ {
+ for (curarg = ptool->args; curarg->name; curarg++)
+ if (grub_strncmp (curarg->name, args[j],
+ grub_strlen (curarg->name)) == 0
+ && ((curarg->type == GRUB_PARTTOOL_ARG_BOOL
+ && (args[j][grub_strlen (curarg->name)] == '+'
+ || args[j][grub_strlen (curarg->name)] == '-'
+ || args[j][grub_strlen (curarg->name)] == 0))
+ || (curarg->type == GRUB_PARTTOOL_ARG_VAL
+ && args[j][grub_strlen (curarg->name)] == '=')))
+ {
+ parsed[j] = 1;
+ pargs[curarg - ptool->args].set = 1;
+ switch (curarg->type)
+ {
+ case GRUB_PARTTOOL_ARG_BOOL:
+ pargs[curarg - ptool->args].bool
+ = (args[j][grub_strlen (curarg->name)] != '-');
+ break;
+
+ case GRUB_PARTTOOL_ARG_VAL:
+ pargs[curarg - ptool->args].str
+ = (args[j] + grub_strlen (curarg->name) + 1);
+ break;
+
+ case GRUB_PARTTOOL_ARG_END:
+ break;
+ }
+ }
+ }
+
+ err = ptool->func (dev, pargs);
+ grub_free (pargs);
+ if (err)
+ break;
+ }
+
+ grub_free (parsed);
+ grub_device_close (dev);
+ return err;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(parttool)
+{
+ mymod = mod;
+ cmd = grub_register_command ("parttool", grub_cmd_parttool,
+ N_("PARTITION COMMANDS"),
+ helpmsg);
+}
+
+GRUB_MOD_FINI(parttool)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/password.c b/grub-core/commands/password.c
new file mode 100644
index 0000000..6d42c9b
--- /dev/null
+++ b/grub-core/commands/password.c
@@ -0,0 +1,93 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/auth.h>
+#include <grub/crypto.h>
+#include <grub/list.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+
+static grub_err_t
+check_password (const char *user, const char *entered,
+ void *password)
+{
+ if (grub_crypto_memcmp (entered, password, GRUB_AUTH_MAX_PASSLEN) != 0)
+ return GRUB_ACCESS_DENIED;
+
+ grub_auth_authenticate (user);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_normal_set_password (const char *user, const char *password)
+{
+ grub_err_t err;
+ char *pass;
+ int copylen;
+
+ pass = grub_zalloc (GRUB_AUTH_MAX_PASSLEN);
+ if (!pass)
+ return grub_errno;
+ copylen = grub_strlen (password);
+ if (copylen >= GRUB_AUTH_MAX_PASSLEN)
+ copylen = GRUB_AUTH_MAX_PASSLEN - 1;
+ grub_memcpy (pass, password, copylen);
+
+ err = grub_auth_register_authentication (user, check_password, pass);
+ if (err)
+ {
+ grub_free (pass);
+ return err;
+ }
+ grub_dl_ref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ if (argc != 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+ return grub_normal_set_password (args[0], args[1]);
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(password)
+{
+ my_mod = mod;
+ cmd = grub_register_command ("password", grub_cmd_password,
+ N_("USER PASSWORD"),
+ N_("Set user password (plaintext). "
+ "Unrecommended and insecure."));
+}
+
+GRUB_MOD_FINI(password)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/password_pbkdf2.c b/grub-core/commands/password_pbkdf2.c
new file mode 100644
index 0000000..ab845d2
--- /dev/null
+++ b/grub-core/commands/password_pbkdf2.c
@@ -0,0 +1,209 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/auth.h>
+#include <grub/crypto.h>
+#include <grub/list.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+
+struct pbkdf2_password
+{
+ grub_uint8_t *salt;
+ grub_size_t saltlen;
+ unsigned int c;
+ grub_uint8_t *expected;
+ grub_size_t buflen;
+};
+
+static grub_err_t
+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)
+ return grub_crypto_gcry_error (GPG_ERR_OUT_OF_MEMORY);
+
+ err = grub_crypto_pbkdf2 (GRUB_MD_SHA512, (grub_uint8_t *) entered,
+ grub_strlen (entered),
+ 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_auth_authenticate (user);
+ ret = GRUB_ERR_NONE;
+ }
+
+ grub_free (buf);
+ return ret;
+}
+
+static inline int
+hex2val (char hex)
+{
+ if ('0' <= hex && hex <= '9')
+ return hex - '0';
+ if ('a' <= hex && hex <= 'f')
+ return hex - 'a' + 10;
+ if ('A' <= hex && hex <= 'F')
+ return hex - 'A' + 10;
+ return -1;
+}
+
+static grub_err_t
+grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_err_t err;
+ const char *ptr, *ptr2;
+ grub_uint8_t *ptro;
+ struct pbkdf2_password *pass;
+
+ if (argc != 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+ if (grub_memcmp (args[1], "grub.pbkdf2.sha512.",
+ sizeof ("grub.pbkdf2.sha512.") - 1) != 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid PBKDF2 password"));
+
+ ptr = args[1] + sizeof ("grub.pbkdf2.sha512.") - 1;
+
+ pass = grub_malloc (sizeof (*pass));
+ if (!pass)
+ return grub_errno;
+
+ pass->c = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ {
+ grub_free (pass);
+ return grub_errno;
+ }
+ if (*ptr != '.')
+ {
+ grub_free (pass);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid PBKDF2 password"));
+ }
+ ptr++;
+
+ ptr2 = grub_strchr (ptr, '.');
+ if (!ptr2 || ((ptr2 - ptr) & 1) || grub_strlen (ptr2 + 1) & 1)
+ {
+ grub_free (pass);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid PBKDF2 password"));
+ }
+
+ pass->saltlen = (ptr2 - ptr) >> 1;
+ pass->buflen = grub_strlen (ptr2 + 1) >> 1;
+ ptro = pass->salt = grub_malloc (pass->saltlen);
+ if (!ptro)
+ {
+ grub_free (pass);
+ return grub_errno;
+ }
+ while (ptr < ptr2)
+ {
+ int hex1, hex2;
+ hex1 = hex2val (*ptr);
+ ptr++;
+ hex2 = hex2val (*ptr);
+ ptr++;
+ if (hex1 < 0 || hex2 < 0)
+ {
+ grub_free (pass->salt);
+ grub_free (pass);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ /* TRANSLATORS: it means that the string which
+ was supposed to be a password hash doesn't
+ have a correct format, not to password
+ mismatch. */
+ N_("invalid PBKDF2 password"));
+ }
+
+ *ptro = (hex1 << 4) | hex2;
+ ptro++;
+ }
+
+ ptro = pass->expected = grub_malloc (pass->buflen);
+ if (!ptro)
+ {
+ grub_free (pass->salt);
+ grub_free (pass);
+ return grub_errno;
+ }
+ ptr = ptr2 + 1;
+ ptr2 += grub_strlen (ptr2);
+ while (ptr < ptr2)
+ {
+ int hex1, hex2;
+ hex1 = hex2val (*ptr);
+ ptr++;
+ hex2 = hex2val (*ptr);
+ ptr++;
+ if (hex1 < 0 || hex2 < 0)
+ {
+ grub_free (pass->expected);
+ grub_free (pass->salt);
+ grub_free (pass);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid PBKDF2 password"));
+ }
+
+ *ptro = (hex1 << 4) | hex2;
+ ptro++;
+ }
+
+ err = grub_auth_register_authentication (args[0], check_password, pass);
+ if (err)
+ {
+ grub_free (pass);
+ return err;
+ }
+ grub_dl_ref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(password_pbkdf2)
+{
+ my_mod = mod;
+ cmd = grub_register_command ("password_pbkdf2", grub_cmd_password,
+ N_("USER PBKDF2_PASSWORD"),
+ N_("Set user password (PBKDF2). "));
+}
+
+GRUB_MOD_FINI(password_pbkdf2)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/pcidump.c b/grub-core/commands/pcidump.c
new file mode 100644
index 0000000..f72628f
--- /dev/null
+++ b/grub-core/commands/pcidump.c
@@ -0,0 +1,174 @@
+/* lspci.c - List PCI devices. */
+/*
+ * 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/pci.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/env.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct iter_cxt
+{
+ grub_uint32_t pciid_check_mask, pciid_check_value;
+ int bus, device, function;
+ int check_bus, check_device, check_function;
+};
+
+static const struct grub_arg_option options[] =
+ {
+ {0, 'd', 0, N_("Select device by vendor and device IDs."),
+ N_("[vendor]:[device]"), ARG_TYPE_STRING},
+ {0, 's', 0, N_("Select device by its position on the bus."),
+ N_("[bus]:[slot][.func]"), ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static int
+grub_pcidump_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data)
+{
+ struct iter_cxt *ctx = data;
+ grub_pci_address_t addr;
+ int i;
+
+ if ((pciid & ctx->pciid_check_mask) != ctx->pciid_check_value)
+ return 0;
+
+ if (ctx->check_bus && grub_pci_get_bus (dev) != ctx->bus)
+ return 0;
+
+ if (ctx->check_device && grub_pci_get_device (dev) != ctx->device)
+ return 0;
+
+ if (ctx->check_function && grub_pci_get_function (dev) != ctx->function)
+ return 0;
+
+ for (i = 0; i < 256; i += 4)
+ {
+ addr = grub_pci_make_address (dev, i);
+ grub_printf ("%08x ", grub_pci_read (addr));
+ if ((i & 0xc) == 0xc)
+ grub_printf ("\n");
+ }
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_pcidump (grub_extcmd_context_t ctxt,
+ int argc __attribute__ ((unused)),
+ char **argv __attribute__ ((unused)))
+{
+ const char *ptr;
+ struct iter_cxt ctx =
+ {
+ .pciid_check_value = 0,
+ .pciid_check_mask = 0,
+ .check_bus = 0,
+ .check_device = 0,
+ .check_function = 0,
+ .bus = 0,
+ .function = 0,
+ .device = 0
+ };
+
+ if (ctxt->state[0].set)
+ {
+ ptr = ctxt->state[0].arg;
+ ctx.pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff);
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ ptr = ctxt->state[0].arg;
+ }
+ else
+ ctx.pciid_check_mask |= 0xffff;
+ if (grub_errno)
+ return grub_errno;
+ if (*ptr != ':')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':');
+ ptr++;
+ ctx.pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff) << 16;
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ grub_errno = GRUB_ERR_NONE;
+ else
+ ctx.pciid_check_mask |= 0xffff0000;
+ }
+
+ ctx.pciid_check_value &= ctx.pciid_check_mask;
+
+ if (ctxt->state[1].set)
+ {
+ const char *optr;
+
+ ptr = ctxt->state[1].arg;
+ optr = ptr;
+ ctx.bus = grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ ptr = optr;
+ }
+ else
+ ctx.check_bus = 1;
+ if (grub_errno)
+ return grub_errno;
+ if (*ptr != ':')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':');
+ ptr++;
+ optr = ptr;
+ ctx.device = grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ ptr = optr;
+ }
+ else
+ ctx.check_device = 1;
+ if (*ptr == '.')
+ {
+ ptr++;
+ ctx.function = grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno)
+ return grub_errno;
+ ctx.check_function = 1;
+ }
+ }
+
+ grub_pci_iterate (grub_pcidump_iter, &ctx);
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(pcidump)
+{
+ cmd = grub_register_extcmd ("pcidump", grub_cmd_pcidump, 0,
+ N_("[-s POSITION] [-d DEVICE]"),
+ N_("Show raw dump of the PCI configuration space."), options);
+}
+
+GRUB_MOD_FINI(pcidump)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c
new file mode 100644
index 0000000..5daa1e9
--- /dev/null
+++ b/grub-core/commands/pgp.c
@@ -0,0 +1,1018 @@
+/*
+ * 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/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/command.h>
+#include <grub/crypto.h>
+#include <grub/i18n.h>
+#include <grub/gcrypt/gcrypt.h>
+#include <grub/pubkey.h>
+#include <grub/env.h>
+#include <grub/kernel.h>
+#include <grub/extcmd.h>
+#include <grub/verify.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+enum
+ {
+ OPTION_SKIP_SIG = 0
+ };
+
+static const struct grub_arg_option options[] =
+ {
+ {"skip-sig", 's', 0,
+ N_("Skip signature-checking of the public key file."), 0, ARG_TYPE_NONE},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+read_packet_header (grub_file_t sig, grub_uint8_t *out_type, grub_size_t *len)
+{
+ grub_uint8_t type;
+ grub_uint8_t l;
+ grub_uint16_t l16;
+ grub_uint32_t l32;
+
+ /* New format. */
+ switch (grub_file_read (sig, &type, sizeof (type)))
+ {
+ case 1:
+ break;
+ case 0:
+ {
+ *out_type = 0xff;
+ return 0;
+ }
+ default:
+ if (grub_errno)
+ return grub_errno;
+ /* TRANSLATORS: it's about GNUPG signatures. */
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ }
+
+ if (type == 0)
+ {
+ *out_type = 0xfe;
+ return 0;
+ }
+
+ if (!(type & 0x80))
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ if (type & 0x40)
+ {
+ *out_type = (type & 0x3f);
+ if (grub_file_read (sig, &l, sizeof (l)) != 1)
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ if (l < 192)
+ {
+ *len = l;
+ return 0;
+ }
+ if (l < 224)
+ {
+ *len = (l - 192) << GRUB_CHAR_BIT;
+ if (grub_file_read (sig, &l, sizeof (l)) != 1)
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ *len |= l;
+ return 0;
+ }
+ if (l == 255)
+ {
+ if (grub_file_read (sig, &l32, sizeof (l32)) != sizeof (l32))
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ *len = grub_be_to_cpu32 (l32);
+ return 0;
+ }
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ }
+ *out_type = ((type >> 2) & 0xf);
+ switch (type & 0x3)
+ {
+ case 0:
+ if (grub_file_read (sig, &l, sizeof (l)) != sizeof (l))
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ *len = l;
+ return 0;
+ case 1:
+ if (grub_file_read (sig, &l16, sizeof (l16)) != sizeof (l16))
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ *len = grub_be_to_cpu16 (l16);
+ return 0;
+ case 2:
+ if (grub_file_read (sig, &l32, sizeof (l32)) != sizeof (l32))
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ *len = grub_be_to_cpu32 (l32);
+ return 0;
+ }
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+}
+
+struct signature_v4_header
+{
+ grub_uint8_t type;
+ grub_uint8_t pkeyalgo;
+ grub_uint8_t hash;
+ grub_uint16_t hashed_sub;
+} GRUB_PACKED;
+
+const char *hashes[] = {
+ [0x01] = "md5",
+ [0x02] = "sha1",
+ [0x03] = "ripemd160",
+ [0x08] = "sha256",
+ [0x09] = "sha384",
+ [0x0a] = "sha512",
+ [0x0b] = "sha224"
+};
+
+struct gcry_pk_spec *grub_crypto_pk_dsa;
+struct gcry_pk_spec *grub_crypto_pk_ecdsa;
+struct gcry_pk_spec *grub_crypto_pk_rsa;
+
+static int
+dsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval,
+ const gcry_md_spec_t *hash, struct grub_public_subkey *sk);
+static int
+rsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval,
+ const gcry_md_spec_t *hash, struct grub_public_subkey *sk);
+
+struct
+{
+ const char *name;
+ grub_size_t nmpisig;
+ grub_size_t nmpipub;
+ struct gcry_pk_spec **algo;
+ int (*pad) (gcry_mpi_t *hmpi, grub_uint8_t *hval,
+ const gcry_md_spec_t *hash, struct grub_public_subkey *sk);
+ const char *module;
+} pkalgos[] =
+ {
+ [1] = { "rsa", 1, 2, &grub_crypto_pk_rsa, rsa_pad, "gcry_rsa" },
+ [3] = { "rsa", 1, 2, &grub_crypto_pk_rsa, rsa_pad, "gcry_rsa" },
+ [17] = { "dsa", 2, 4, &grub_crypto_pk_dsa, dsa_pad, "gcry_dsa" },
+ };
+
+struct grub_public_key
+{
+ struct grub_public_key *next;
+ struct grub_public_subkey *subkeys;
+};
+
+struct grub_public_subkey
+{
+ struct grub_public_subkey *next;
+ grub_uint8_t type;
+ grub_uint32_t fingerprint[5];
+ gcry_mpi_t mpis[10];
+};
+
+static void
+free_pk (struct grub_public_key *pk)
+{
+ struct grub_public_subkey *nsk, *sk;
+ for (sk = pk->subkeys; sk; sk = nsk)
+ {
+ grub_size_t i;
+ for (i = 0; i < ARRAY_SIZE (sk->mpis); i++)
+ if (sk->mpis[i])
+ gcry_mpi_release (sk->mpis[i]);
+ nsk = sk->next;
+ grub_free (sk);
+ }
+ grub_free (pk);
+}
+
+#define READBUF_SIZE 4096
+
+struct grub_public_key *
+grub_load_public_key (grub_file_t f)
+{
+ grub_err_t err;
+ struct grub_public_key *ret;
+ struct grub_public_subkey **last = 0;
+ void *fingerprint_context = NULL;
+ grub_uint8_t *buffer = NULL;
+
+ ret = grub_zalloc (sizeof (*ret));
+ if (!ret)
+ {
+ grub_free (fingerprint_context);
+ return NULL;
+ }
+
+ buffer = grub_zalloc (READBUF_SIZE);
+ fingerprint_context = grub_zalloc (GRUB_MD_SHA1->contextsize);
+
+ if (!buffer || !fingerprint_context)
+ goto fail;
+
+ last = &ret->subkeys;
+
+ while (1)
+ {
+ grub_uint8_t type;
+ grub_size_t len;
+ grub_uint8_t v, pk;
+ grub_uint32_t creation_time;
+ grub_off_t pend;
+ struct grub_public_subkey *sk;
+ grub_size_t i;
+ grub_uint16_t len_be;
+
+ err = read_packet_header (f, &type, &len);
+
+ if (err)
+ goto fail;
+ if (type == 0xfe)
+ continue;
+ if (type == 0xff)
+ {
+ grub_free (fingerprint_context);
+ grub_free (buffer);
+ return ret;
+ }
+
+ grub_dprintf ("crypt", "len = %x\n", (int) len);
+
+ pend = grub_file_tell (f) + len;
+ if (type != 6 && type != 14
+ && type != 5 && type != 7)
+ {
+ grub_file_seek (f, pend);
+ continue;
+ }
+
+ if (grub_file_read (f, &v, sizeof (v)) != sizeof (v))
+ {
+ grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ goto fail;
+ }
+
+ grub_dprintf ("crypt", "v = %x\n", v);
+
+ if (v != 4)
+ {
+ grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ goto fail;
+ }
+ if (grub_file_read (f, &creation_time, sizeof (creation_time)) != sizeof (creation_time))
+ {
+ grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ goto fail;
+ }
+
+ grub_dprintf ("crypt", "time = %x\n", creation_time);
+
+ if (grub_file_read (f, &pk, sizeof (pk)) != sizeof (pk))
+ {
+ grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ goto fail;
+ }
+
+ grub_dprintf ("crypt", "pk = %x\n", pk);
+
+ if (pk >= ARRAY_SIZE (pkalgos) || pkalgos[pk].name == NULL)
+ {
+ grub_file_seek (f, pend);
+ continue;
+ }
+
+ sk = grub_zalloc (sizeof (struct grub_public_subkey));
+ if (!sk)
+ goto fail;
+
+ 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);
+ GRUB_MD_SHA1->write (fingerprint_context, &len_be, sizeof (len_be));
+ GRUB_MD_SHA1->write (fingerprint_context, &v, sizeof (v));
+ GRUB_MD_SHA1->write (fingerprint_context, &creation_time, sizeof (creation_time));
+ GRUB_MD_SHA1->write (fingerprint_context, &pk, sizeof (pk));
+
+ for (i = 0; i < pkalgos[pk].nmpipub; i++)
+ {
+ grub_uint16_t l;
+ grub_size_t lb;
+ if (grub_file_read (f, &l, sizeof (l)) != sizeof (l))
+ {
+ grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ 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"));
+ 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"));
+ break;
+ }
+ grub_memcpy (buffer, &l, sizeof (l));
+
+ GRUB_MD_SHA1->write (fingerprint_context, buffer, lb + sizeof (grub_uint16_t));
+
+ if (gcry_mpi_scan (&sk->mpis[i], GCRYMPI_FMT_PGP,
+ buffer, lb + sizeof (grub_uint16_t), 0))
+ {
+ grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ 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);
+
+ *last = sk;
+ last = &sk->next;
+
+ grub_dprintf ("crypt", "actual pos: %x, expected: %x\n", (int)grub_file_tell (f), (int)pend);
+
+ grub_file_seek (f, pend);
+ }
+ fail:
+ free_pk (ret);
+ grub_free (fingerprint_context);
+ grub_free (buffer);
+ return NULL;
+}
+
+struct grub_public_key *grub_pk_trusted;
+
+struct grub_public_subkey *
+grub_crypto_pk_locate_subkey (grub_uint64_t keyid, struct grub_public_key *pkey)
+{
+ struct grub_public_subkey *sk;
+ for (sk = pkey->subkeys; sk; sk = sk->next)
+ if (grub_memcmp (sk->fingerprint + 3, &keyid, 8) == 0)
+ return sk;
+ return 0;
+}
+
+struct grub_public_subkey *
+grub_crypto_pk_locate_subkey_in_trustdb (grub_uint64_t keyid)
+{
+ struct grub_public_key *pkey;
+ struct grub_public_subkey *sk;
+ for (pkey = grub_pk_trusted; pkey; pkey = pkey->next)
+ {
+ sk = grub_crypto_pk_locate_subkey (keyid, pkey);
+ if (sk)
+ return sk;
+ }
+ return 0;
+}
+
+
+static int
+dsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval,
+ const gcry_md_spec_t *hash, struct grub_public_subkey *sk)
+{
+ unsigned nbits = gcry_mpi_get_nbits (sk->mpis[1]);
+ grub_dprintf ("crypt", "must be %u bits got %d bits\n", nbits,
+ (int)(8 * hash->mdlen));
+ return gcry_mpi_scan (hmpi, GCRYMPI_FMT_USG, hval,
+ nbits / 8 < (unsigned) hash->mdlen ? nbits / 8
+ : (unsigned) hash->mdlen, 0);
+}
+
+static int
+rsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval,
+ const gcry_md_spec_t *hash, struct grub_public_subkey *sk)
+{
+ grub_size_t tlen, emlen, fflen;
+ grub_uint8_t *em, *emptr;
+ unsigned nbits = gcry_mpi_get_nbits (sk->mpis[0]);
+ int ret;
+ tlen = hash->mdlen + hash->asnlen;
+ emlen = (nbits + 7) / 8;
+ if (emlen < tlen + 11)
+ return 1;
+
+ em = grub_malloc (emlen);
+ if (!em)
+ return 1;
+
+ em[0] = 0x00;
+ em[1] = 0x01;
+ fflen = emlen - tlen - 3;
+ for (emptr = em + 2; emptr < em + 2 + fflen; emptr++)
+ *emptr = 0xff;
+ *emptr++ = 0x00;
+ grub_memcpy (emptr, hash->asnoid, hash->asnlen);
+ emptr += hash->asnlen;
+ grub_memcpy (emptr, hval, hash->mdlen);
+
+ ret = gcry_mpi_scan (hmpi, GCRYMPI_FMT_USG, em, emlen, 0);
+ grub_free (em);
+ return ret;
+}
+
+struct grub_pubkey_context
+{
+ grub_file_t sig;
+ struct signature_v4_header v4;
+ grub_uint8_t v;
+ const gcry_md_spec_t *hash;
+ void *hash_context;
+};
+
+static grub_err_t
+grub_verify_signature_init (struct grub_pubkey_context *ctxt, grub_file_t sig)
+{
+ grub_size_t len;
+ grub_uint8_t h;
+ grub_uint8_t t;
+ grub_uint8_t pk;
+ grub_err_t err;
+ grub_uint8_t type = 0;
+
+ grub_memset (ctxt, 0, sizeof (*ctxt));
+
+ err = read_packet_header (sig, &type, &len);
+ if (err)
+ return err;
+
+ if (type != 0x2)
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+
+ if (grub_file_read (sig, &ctxt->v, sizeof (ctxt->v)) != sizeof (ctxt->v))
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+
+ if (ctxt->v != 4)
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+
+ if (grub_file_read (sig, &ctxt->v4, sizeof (ctxt->v4)) != sizeof (ctxt->v4))
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+
+ h = ctxt->v4.hash;
+ t = ctxt->v4.type;
+ pk = ctxt->v4.pkeyalgo;
+
+ if (t != 0)
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+
+ if (h >= ARRAY_SIZE (hashes) || hashes[h] == NULL)
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, "unknown hash");
+
+ if (pk >= ARRAY_SIZE (pkalgos) || pkalgos[pk].name == NULL)
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+
+ ctxt->hash = grub_crypto_lookup_md_by_name (hashes[h]);
+ if (!ctxt->hash)
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, "hash `%s' not loaded", hashes[h]);
+
+ grub_dprintf ("crypt", "alive\n");
+
+ ctxt->hash_context = grub_zalloc (ctxt->hash->contextsize);
+ if (!ctxt->hash_context)
+ return grub_errno;
+
+ ctxt->hash->init (ctxt->hash_context);
+ ctxt->sig = sig;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_pubkey_write (void *ctxt_, void *buf, grub_size_t size)
+{
+ struct grub_pubkey_context *ctxt = ctxt_;
+ ctxt->hash->write (ctxt->hash_context, buf, size);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_verify_signature_real (struct grub_pubkey_context *ctxt,
+ struct grub_public_key *pkey)
+{
+ gcry_mpi_t mpis[10];
+ grub_uint8_t pk = ctxt->v4.pkeyalgo;
+ grub_size_t i;
+ grub_uint8_t *readbuf = NULL;
+ unsigned char *hval;
+ grub_ssize_t rem = grub_be_to_cpu16 (ctxt->v4.hashed_sub);
+ grub_uint32_t headlen = grub_cpu_to_be32 (rem + 6);
+ grub_uint8_t s;
+ grub_uint16_t unhashed_sub;
+ grub_ssize_t r;
+ grub_uint8_t hash_start[2];
+ gcry_mpi_t hmpi;
+ grub_uint64_t keyid = 0;
+ struct grub_public_subkey *sk;
+
+ readbuf = grub_malloc (READBUF_SIZE);
+ if (!readbuf)
+ goto fail;
+
+ ctxt->hash->write (ctxt->hash_context, &ctxt->v, sizeof (ctxt->v));
+ ctxt->hash->write (ctxt->hash_context, &ctxt->v4, sizeof (ctxt->v4));
+ while (rem)
+ {
+ r = grub_file_read (ctxt->sig, readbuf,
+ rem < READBUF_SIZE ? rem : READBUF_SIZE);
+ if (r < 0)
+ goto fail;
+ if (r == 0)
+ break;
+ ctxt->hash->write (ctxt->hash_context, readbuf, r);
+ rem -= r;
+ }
+ ctxt->hash->write (ctxt->hash_context, &ctxt->v, sizeof (ctxt->v));
+ s = 0xff;
+ ctxt->hash->write (ctxt->hash_context, &s, sizeof (s));
+ ctxt->hash->write (ctxt->hash_context, &headlen, sizeof (headlen));
+ r = grub_file_read (ctxt->sig, &unhashed_sub, sizeof (unhashed_sub));
+ if (r != sizeof (unhashed_sub))
+ goto fail;
+ {
+ grub_uint8_t *ptr;
+ grub_uint32_t l;
+ rem = grub_be_to_cpu16 (unhashed_sub);
+ if (rem > READBUF_SIZE)
+ goto fail;
+ r = grub_file_read (ctxt->sig, readbuf, rem);
+ if (r != rem)
+ goto fail;
+ for (ptr = readbuf; ptr < readbuf + rem; ptr += l)
+ {
+ if (*ptr < 192)
+ l = *ptr++;
+ else if (*ptr < 255)
+ {
+ if (ptr + 1 >= readbuf + rem)
+ break;
+ l = (((ptr[0] & ~192) << GRUB_CHAR_BIT) | ptr[1]) + 192;
+ ptr += 2;
+ }
+ else
+ {
+ if (ptr + 5 >= readbuf + rem)
+ break;
+ l = grub_be_to_cpu32 (grub_get_unaligned32 (ptr + 1));
+ ptr += 5;
+ }
+ if (*ptr == 0x10 && l >= 8)
+ keyid = grub_get_unaligned64 (ptr + 1);
+ }
+ }
+
+ ctxt->hash->final (ctxt->hash_context);
+
+ grub_dprintf ("crypt", "alive\n");
+
+ hval = ctxt->hash->read (ctxt->hash_context);
+
+ if (grub_file_read (ctxt->sig, hash_start, sizeof (hash_start)) != sizeof (hash_start))
+ goto fail;
+ if (grub_memcmp (hval, hash_start, sizeof (hash_start)) != 0)
+ goto fail;
+
+ grub_dprintf ("crypt", "@ %x\n", (int)grub_file_tell (ctxt->sig));
+
+ for (i = 0; i < pkalgos[pk].nmpisig; i++)
+ {
+ grub_uint16_t l;
+ grub_size_t lb;
+ grub_dprintf ("crypt", "alive\n");
+ if (grub_file_read (ctxt->sig, &l, sizeof (l)) != sizeof (l))
+ goto fail;
+ grub_dprintf ("crypt", "alive\n");
+ lb = (grub_be_to_cpu16 (l) + 7) / 8;
+ grub_dprintf ("crypt", "l = 0x%04x\n", grub_be_to_cpu16 (l));
+ if (lb > READBUF_SIZE - sizeof (grub_uint16_t))
+ goto fail;
+ grub_dprintf ("crypt", "alive\n");
+ if (grub_file_read (ctxt->sig, readbuf + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb)
+ goto fail;
+ grub_dprintf ("crypt", "alive\n");
+ grub_memcpy (readbuf, &l, sizeof (l));
+ grub_dprintf ("crypt", "alive\n");
+
+ if (gcry_mpi_scan (&mpis[i], GCRYMPI_FMT_PGP,
+ readbuf, lb + sizeof (grub_uint16_t), 0))
+ goto fail;
+ grub_dprintf ("crypt", "alive\n");
+ }
+
+ if (pkey)
+ sk = grub_crypto_pk_locate_subkey (keyid, pkey);
+ else
+ sk = grub_crypto_pk_locate_subkey_in_trustdb (keyid);
+ if (!sk)
+ {
+ /* TRANSLATORS: %08x is 32-bit key id. */
+ grub_error (GRUB_ERR_BAD_SIGNATURE,
+ N_("public key %08" PRIxGRUB_UINT64_T " not found"), keyid);
+ goto fail;
+ }
+
+ if (pkalgos[pk].pad (&hmpi, hval, ctxt->hash, sk))
+ goto fail;
+ if (!*pkalgos[pk].algo)
+ {
+ grub_dl_load (pkalgos[pk].module);
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ if (!*pkalgos[pk].algo)
+ {
+ grub_error (GRUB_ERR_BAD_SIGNATURE, N_("module `%s' isn't loaded"),
+ pkalgos[pk].module);
+ goto fail;
+ }
+ if ((*pkalgos[pk].algo)->verify (0, hmpi, mpis, sk->mpis, 0, 0))
+ goto fail;
+
+ grub_free (readbuf);
+
+ return GRUB_ERR_NONE;
+
+ fail:
+ grub_free (readbuf);
+ if (!grub_errno)
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
+ return grub_errno;
+}
+
+static void
+grub_pubkey_close_real (struct grub_pubkey_context *ctxt)
+{
+ if (ctxt->sig)
+ grub_file_close (ctxt->sig);
+ if (ctxt->hash_context)
+ grub_free (ctxt->hash_context);
+}
+
+static void
+grub_pubkey_close (void *ctxt)
+{
+ grub_pubkey_close_real (ctxt);
+ grub_free (ctxt);
+}
+
+grub_err_t
+grub_verify_signature (grub_file_t f, const char *fsig,
+ struct grub_public_key *pkey)
+{
+ grub_file_t sig;
+ grub_err_t err;
+ struct grub_pubkey_context ctxt;
+ grub_uint8_t *readbuf = NULL;
+
+ sig = grub_file_open (fsig,
+ GRUB_FILE_TYPE_SIGNATURE
+ | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (!sig)
+ return grub_errno;
+
+ err = grub_verify_signature_init (&ctxt, sig);
+ if (err)
+ {
+ grub_file_close (sig);
+ return err;
+ }
+
+ readbuf = grub_zalloc (READBUF_SIZE);
+ if (!readbuf)
+ goto fail;
+
+ while (1)
+ {
+ grub_ssize_t r;
+ r = grub_file_read (f, readbuf, READBUF_SIZE);
+ if (r < 0)
+ goto fail;
+ if (r == 0)
+ break;
+ err = grub_pubkey_write (&ctxt, readbuf, r);
+ if (err)
+ return err;
+ }
+
+ grub_verify_signature_real (&ctxt, pkey);
+ fail:
+ grub_pubkey_close_real (&ctxt);
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_trust (grub_extcmd_context_t ctxt,
+ int argc, char **args)
+{
+ grub_file_t pkf;
+ struct grub_public_key *pk = NULL;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ pkf = grub_file_open (args[0],
+ GRUB_FILE_TYPE_PUBLIC_KEY_TRUST
+ | GRUB_FILE_TYPE_NO_DECOMPRESS
+ | (ctxt->state[OPTION_SKIP_SIG].set
+ ? GRUB_FILE_TYPE_SKIP_SIGNATURE
+ : GRUB_FILE_TYPE_NONE));
+ if (!pkf)
+ return grub_errno;
+ pk = grub_load_public_key (pkf);
+ if (!pk)
+ {
+ grub_file_close (pkf);
+ return grub_errno;
+ }
+ grub_file_close (pkf);
+
+ pk->next = grub_pk_trusted;
+ grub_pk_trusted = pk;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_list (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ struct grub_public_key *pk = NULL;
+ struct grub_public_subkey *sk = NULL;
+
+ for (pk = grub_pk_trusted; pk; pk = pk->next)
+ for (sk = pk->subkeys; sk; sk = sk->next)
+ {
+ unsigned i;
+ for (i = 0; i < 20; i += 2)
+ grub_printf ("%02x%02x ", ((grub_uint8_t *) sk->fingerprint)[i],
+ ((grub_uint8_t *) sk->fingerprint)[i + 1]);
+ grub_printf ("\n");
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_distrust (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_uint32_t keyid, keyid_be;
+ struct grub_public_key **pkey;
+ struct grub_public_subkey *sk;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+ keyid = grub_strtoull (args[0], 0, 16);
+ if (grub_errno)
+ return grub_errno;
+ keyid_be = grub_cpu_to_be32 (keyid);
+
+ for (pkey = &grub_pk_trusted; *pkey; pkey = &((*pkey)->next))
+ {
+ struct grub_public_key *next;
+ for (sk = (*pkey)->subkeys; sk; sk = sk->next)
+ if (grub_memcmp (sk->fingerprint + 4, &keyid_be, 4) == 0)
+ break;
+ if (!sk)
+ continue;
+ next = (*pkey)->next;
+ free_pk (*pkey);
+ *pkey = next;
+ return GRUB_ERR_NONE;
+ }
+ /* TRANSLATORS: %08x is 32-bit key id. */
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("public key %08x not found"), keyid);
+}
+
+static grub_err_t
+grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
+ int argc, char **args)
+{
+ grub_file_t f = NULL;
+ grub_err_t err = GRUB_ERR_NONE;
+ struct grub_public_key *pk = NULL;
+
+ grub_dprintf ("crypt", "alive\n");
+
+ if (argc < 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+ grub_dprintf ("crypt", "alive\n");
+
+ if (argc > 2)
+ {
+ grub_file_t pkf;
+ pkf = grub_file_open (args[2],
+ GRUB_FILE_TYPE_PUBLIC_KEY
+ | GRUB_FILE_TYPE_NO_DECOMPRESS
+ | (ctxt->state[OPTION_SKIP_SIG].set
+ ? GRUB_FILE_TYPE_SKIP_SIGNATURE
+ : GRUB_FILE_TYPE_NONE));
+ if (!pkf)
+ return grub_errno;
+ pk = grub_load_public_key (pkf);
+ if (!pk)
+ {
+ grub_file_close (pkf);
+ return grub_errno;
+ }
+ grub_file_close (pkf);
+ }
+
+ f = grub_file_open (args[0], GRUB_FILE_TYPE_VERIFY_SIGNATURE);
+ if (!f)
+ {
+ err = grub_errno;
+ goto fail;
+ }
+
+ err = grub_verify_signature (f, args[1], pk);
+ fail:
+ if (f)
+ grub_file_close (f);
+ if (pk)
+ free_pk (pk);
+ return err;
+}
+
+static int sec = 0;
+
+static grub_err_t
+grub_pubkey_init (grub_file_t io, enum grub_file_type type __attribute__ ((unused)),
+ void **context, enum grub_verify_flags *flags)
+{
+ grub_file_t sig;
+ char *fsuf, *ptr;
+ grub_err_t err;
+ struct grub_pubkey_context *ctxt;
+
+ if (!sec)
+ {
+ *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION;
+ return GRUB_ERR_NONE;
+ }
+
+ fsuf = grub_malloc (grub_strlen (io->name) + sizeof (".sig"));
+ if (!fsuf)
+ return grub_errno;
+ ptr = grub_stpcpy (fsuf, io->name);
+ grub_memcpy (ptr, ".sig", sizeof (".sig"));
+
+ sig = grub_file_open (fsuf, GRUB_FILE_TYPE_SIGNATURE);
+ grub_free (fsuf);
+ if (!sig)
+ return grub_errno;
+
+ ctxt = grub_malloc (sizeof (*ctxt));
+ if (!ctxt)
+ {
+ grub_file_close (sig);
+ return grub_errno;
+ }
+ err = grub_verify_signature_init (ctxt, sig);
+ if (err)
+ {
+ grub_free (ctxt);
+ grub_file_close (sig);
+ return err;
+ }
+ *context = ctxt;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_pubkey_fini (void *ctxt)
+{
+ return grub_verify_signature_real (ctxt, NULL);
+}
+
+static char *
+grub_env_write_sec (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val)
+{
+ sec = (*val == '1') || (*val == 'e');
+ return grub_strdup (sec ? "enforce" : "no");
+}
+
+static grub_ssize_t
+pseudo_read (struct grub_file *file, char *buf, grub_size_t len)
+{
+ grub_memcpy (buf, (grub_uint8_t *) file->data + file->offset, len);
+ return len;
+}
+
+
+/* Filesystem descriptor. */
+struct grub_fs pseudo_fs =
+ {
+ .name = "pseudo",
+ .fs_read = pseudo_read
+ };
+
+struct grub_file_verifier grub_pubkey_verifier =
+ {
+ .name = "pgp",
+ .init = grub_pubkey_init,
+ .fini = grub_pubkey_fini,
+ .write = grub_pubkey_write,
+ .close = grub_pubkey_close,
+ };
+
+static grub_extcmd_t cmd, cmd_trust;
+static grub_command_t cmd_distrust, cmd_list;
+
+GRUB_MOD_INIT(pgp)
+{
+ const char *val;
+ struct grub_module_header *header;
+
+ val = grub_env_get ("check_signatures");
+ if (val && (val[0] == '1' || val[0] == 'e'))
+ sec = 1;
+ else
+ sec = 0;
+
+ grub_register_variable_hook ("check_signatures", 0, grub_env_write_sec);
+ grub_env_export ("check_signatures");
+
+ grub_pk_trusted = 0;
+ FOR_MODULES (header)
+ {
+ struct grub_file pseudo_file;
+ struct grub_public_key *pk = NULL;
+
+ grub_memset (&pseudo_file, 0, sizeof (pseudo_file));
+
+ /* Not an ELF module, skip. */
+ if (header->type != OBJ_TYPE_PUBKEY)
+ continue;
+
+ pseudo_file.fs = &pseudo_fs;
+ pseudo_file.size = (header->size - sizeof (struct grub_module_header));
+ pseudo_file.data = (char *) header + sizeof (struct grub_module_header);
+
+ pk = grub_load_public_key (&pseudo_file);
+ if (!pk)
+ grub_fatal ("error loading initial key: %s\n", grub_errmsg);
+
+ pk->next = grub_pk_trusted;
+ grub_pk_trusted = pk;
+ }
+
+ if (!val)
+ grub_env_set ("check_signatures", grub_pk_trusted ? "enforce" : "no");
+
+ cmd = grub_register_extcmd ("verify_detached", grub_cmd_verify_signature, 0,
+ N_("[-s|--skip-sig] FILE SIGNATURE_FILE [PUBKEY_FILE]"),
+ N_("Verify detached signature."),
+ options);
+ cmd_trust = grub_register_extcmd ("trust", grub_cmd_trust, 0,
+ N_("[-s|--skip-sig] PUBKEY_FILE"),
+ N_("Add PUBKEY_FILE to trusted keys."),
+ options);
+ cmd_list = grub_register_command ("list_trusted", grub_cmd_list,
+ 0,
+ N_("Show the list of trusted keys."));
+ cmd_distrust = grub_register_command ("distrust", grub_cmd_distrust,
+ N_("PUBKEY_ID"),
+ N_("Remove PUBKEY_ID from trusted keys."));
+
+ grub_verifier_register (&grub_pubkey_verifier);
+}
+
+GRUB_MOD_FINI(pgp)
+{
+ grub_verifier_unregister (&grub_pubkey_verifier);
+ grub_unregister_extcmd (cmd);
+ grub_unregister_extcmd (cmd_trust);
+ grub_unregister_command (cmd_list);
+ grub_unregister_command (cmd_distrust);
+}
diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
new file mode 100644
index 0000000..e53b611
--- /dev/null
+++ b/grub-core/commands/probe.c
@@ -0,0 +1,225 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/gpt_partition.h>
+#include <grub/net.h>
+#include <grub/fs.h>
+#include <grub/file.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/i386/pc/boot.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ {"set", 's', 0,
+ N_("Set a variable to return value."), N_("VARNAME"), ARG_TYPE_STRING},
+ /* TRANSLATORS: It's a driver that is currently in use to access
+ the diven disk. */
+ {"driver", 'd', 0, N_("Determine driver."), 0, 0},
+ {"partmap", 'p', 0, N_("Determine partition map type."), 0, 0},
+ {"fs", 'f', 0, N_("Determine filesystem type."), 0, 0},
+ {"fs-uuid", 'u', 0, N_("Determine filesystem UUID."), 0, 0},
+ {"label", 'l', 0, N_("Determine filesystem label."), 0, 0},
+ {"part-uuid", 0, 0, N_("Determine partition UUID."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ grub_device_t dev;
+ grub_fs_t fs;
+ char *ptr;
+ grub_err_t err;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required");
+
+ ptr = args[0] + grub_strlen (args[0]) - 1;
+ if (args[0][0] == '(' && *ptr == ')')
+ {
+ *ptr = 0;
+ dev = grub_device_open (args[0] + 1);
+ *ptr = ')';
+ }
+ else
+ dev = grub_device_open (args[0]);
+ if (! dev)
+ return grub_errno;
+
+ if (state[1].set)
+ {
+ const char *val = "none";
+ if (dev->net)
+ val = dev->net->protocol->name;
+ if (dev->disk)
+ val = dev->disk->dev->name;
+ if (state[0].set)
+ grub_env_set (state[0].arg, val);
+ else
+ grub_printf ("%s", val);
+ grub_device_close (dev);
+ return GRUB_ERR_NONE;
+ }
+ if (state[2].set)
+ {
+ const char *val = "none";
+ if (dev->disk && dev->disk->partition)
+ val = dev->disk->partition->partmap->name;
+ if (state[0].set)
+ grub_env_set (state[0].arg, val);
+ else
+ grub_printf ("%s", val);
+ grub_device_close (dev);
+ return GRUB_ERR_NONE;
+ }
+ if (state[6].set)
+ {
+ /* AAAABBBB-CCCC-DDDD-EEEE-FFFFFFFFFFFF + null terminator */
+ char val[37] = "none";
+ if (dev->disk && dev->disk->partition)
+ {
+ struct grub_partition *p = dev->disk->partition;
+ grub_disk_t disk = grub_disk_open(dev->disk->name);
+
+ if (!disk)
+ {
+ grub_device_close (dev);
+ return grub_errno;
+ }
+
+ if (grub_strcmp(dev->disk->partition->partmap->name, "gpt") == 0)
+ {
+ struct grub_gpt_partentry entry;
+ grub_gpt_part_guid_t *guid;
+
+ if (grub_disk_read(disk, p->offset, p->index, sizeof(entry), &entry))
+ return grub_errno;
+ guid = &entry.guid;
+ grub_snprintf (val, sizeof(val),
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ grub_le_to_cpu32 (guid->data1),
+ grub_le_to_cpu16 (guid->data2),
+ grub_le_to_cpu16 (guid->data3),
+ guid->data4[0], guid->data4[1], guid->data4[2],
+ guid->data4[3], guid->data4[4], guid->data4[5],
+ guid->data4[6], guid->data4[7]);
+ }
+ else if (grub_strcmp(dev->disk->partition->partmap->name, "msdos") == 0)
+ {
+ grub_uint32_t nt_disk_sig;
+
+ if (grub_disk_read(disk, 0, GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
+ sizeof(nt_disk_sig), &nt_disk_sig) == 0)
+ grub_snprintf (val, sizeof(val), "%08x-%02x",
+ grub_le_to_cpu32(nt_disk_sig), 1 + p->number);
+ }
+ grub_disk_close(disk);
+ }
+ if (state[0].set)
+ grub_env_set (state[0].arg, val);
+ else
+ grub_printf ("%s", val);
+ grub_device_close (dev);
+ return GRUB_ERR_NONE;
+ }
+ fs = grub_fs_probe (dev);
+ if (! fs)
+ return grub_errno;
+ if (state[3].set)
+ {
+ if (state[0].set)
+ grub_env_set (state[0].arg, fs->name);
+ else
+ grub_printf ("%s", fs->name);
+ grub_device_close (dev);
+ return GRUB_ERR_NONE;
+ }
+ if (state[4].set)
+ {
+ char *uuid;
+ if (! fs->fs_uuid)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("%s does not support UUIDs"), fs->name);
+ err = fs->fs_uuid (dev, &uuid);
+ if (err)
+ return err;
+ if (! uuid)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("%s does not support UUIDs"), fs->name);
+
+ if (state[0].set)
+ grub_env_set (state[0].arg, uuid);
+ else
+ grub_printf ("%s", uuid);
+ grub_free (uuid);
+ grub_device_close (dev);
+ return GRUB_ERR_NONE;
+ }
+ if (state[5].set)
+ {
+ char *label;
+ if (! fs->fs_label)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("filesystem `%s' does not support labels"),
+ fs->name);
+ err = fs->fs_label (dev, &label);
+ if (err)
+ return err;
+ if (! label)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("filesystem `%s' does not support labels"),
+ fs->name);
+
+ if (state[0].set)
+ grub_env_set (state[0].arg, label);
+ else
+ grub_printf ("%s", label);
+ grub_free (label);
+ grub_device_close (dev);
+ return GRUB_ERR_NONE;
+ }
+ grub_device_close (dev);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "unrecognised target");
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT (probe)
+{
+ cmd = grub_register_extcmd ("probe", grub_cmd_probe, 0, N_("DEVICE"),
+ N_("Retrieve device info."), options);
+}
+
+GRUB_MOD_FINI (probe)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/read.c b/grub-core/commands/read.c
new file mode 100644
index 0000000..fe3e88b
--- /dev/null
+++ b/grub-core/commands/read.c
@@ -0,0 +1,92 @@
+/* read.c - Command to read variables from user. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/term.h>
+#include <grub/types.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static char *
+grub_getline (void)
+{
+ int i;
+ char *line;
+ char *tmp;
+ char c;
+
+ i = 0;
+ line = grub_malloc (1 + i + sizeof('\0'));
+ if (! line)
+ return NULL;
+
+ while (1)
+ {
+ c = grub_getkey ();
+ if ((c == '\n') || (c == '\r'))
+ break;
+
+ line[i] = c;
+ if (grub_isprint (c))
+ grub_printf ("%c", c);
+ i++;
+ tmp = grub_realloc (line, 1 + i + sizeof('\0'));
+ if (! tmp)
+ {
+ grub_free (line);
+ return NULL;
+ }
+ line = tmp;
+ }
+ line[i] = '\0';
+
+ return line;
+}
+
+static grub_err_t
+grub_cmd_read (grub_command_t cmd __attribute__ ((unused)), int argc, char **args)
+{
+ char *line = grub_getline ();
+ if (! line)
+ return grub_errno;
+ if (argc > 0)
+ grub_env_set (args[0], line);
+
+ grub_free (line);
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(read)
+{
+ cmd = grub_register_command ("read", grub_cmd_read,
+ N_("[ENVVAR]"),
+ N_("Set variable with user input."));
+}
+
+GRUB_MOD_FINI(read)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/reboot.c b/grub-core/commands/reboot.c
new file mode 100644
index 0000000..46d364c
--- /dev/null
+++ b/grub-core/commands/reboot.c
@@ -0,0 +1,46 @@
+/* reboot.c - command to reboot the computer. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t __attribute__ ((noreturn))
+grub_cmd_reboot (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_reboot ();
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(reboot)
+{
+ cmd = grub_register_command ("reboot", grub_cmd_reboot,
+ 0, N_("Reboot the computer."));
+}
+
+GRUB_MOD_FINI(reboot)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/regexp.c b/grub-core/commands/regexp.c
new file mode 100644
index 0000000..612003f
--- /dev/null
+++ b/grub-core/commands/regexp.c
@@ -0,0 +1,168 @@
+/* regexp.c -- The regexp command. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/env.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/script_sh.h>
+#include <regex.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ { "set", 's', GRUB_ARG_OPTION_REPEATABLE,
+ /* TRANSLATORS: in regexp you can mark some
+ groups with parentheses. These groups are
+ then numbered and you can save some of
+ them in variables. In other programs
+ those components aree often referenced with
+ back slash, e.g. \1. Compare
+ sed -e 's,\([a-z][a-z]*\),lowercase=\1,g'
+ The whole matching component is saved in VARNAME, not its number.
+ */
+ N_("Store matched component NUMBER in VARNAME."),
+ N_("[NUMBER:]VARNAME"), ARG_TYPE_STRING },
+ { 0, 0, 0, 0, 0, 0 }
+ };
+
+static grub_err_t
+setvar (char *str, char *v, regmatch_t *m)
+{
+ char ch;
+ grub_err_t err;
+ ch = str[m->rm_eo];
+ str[m->rm_eo] = '\0';
+ err = grub_env_set (v, str + m->rm_so);
+ str[m->rm_eo] = ch;
+ return err;
+}
+
+static grub_err_t
+set_matches (char **varnames, char *str, grub_size_t nmatches,
+ regmatch_t *matches)
+{
+ int i;
+ char *p;
+ const char * q;
+ grub_err_t err;
+ unsigned long j;
+
+ for (i = 0; varnames && varnames[i]; i++)
+ {
+ err = GRUB_ERR_NONE;
+ p = grub_strchr (varnames[i], ':');
+ if (! p)
+ {
+ /* varname w/o index defaults to 1 */
+ if (nmatches < 2 || matches[1].rm_so == -1)
+ grub_env_unset (varnames[i]);
+ else
+ err = setvar (str, varnames[i], &matches[1]);
+ }
+ else
+ {
+ j = grub_strtoul (varnames[i], &q, 10);
+ if (q != p)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "invalid variable name format %s", varnames[i]);
+
+ if (nmatches <= j || matches[j].rm_so == -1)
+ grub_env_unset (p + 1);
+ else
+ err = setvar (str, p + 1, &matches[j]);
+ }
+
+ if (err != GRUB_ERR_NONE)
+ return err;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_regexp (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ regex_t regex;
+ int ret;
+ grub_size_t s;
+ char *comperr;
+ grub_err_t err;
+ regmatch_t *matches = 0;
+
+ if (argc != 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+ ret = regcomp (&regex, args[0], REG_EXTENDED);
+ if (ret)
+ goto fail;
+
+ matches = grub_calloc (regex.re_nsub + 1, sizeof (*matches));
+ if (! matches)
+ goto fail;
+
+ ret = regexec (&regex, args[1], regex.re_nsub + 1, matches, 0);
+ if (!ret)
+ {
+ err = set_matches (ctxt->state[0].args, args[1],
+ regex.re_nsub + 1, matches);
+ regfree (&regex);
+ grub_free (matches);
+ return err;
+ }
+
+ fail:
+ grub_free (matches);
+ s = regerror (ret, &regex, 0, 0);
+ comperr = grub_malloc (s);
+ if (!comperr)
+ {
+ regfree (&regex);
+ return grub_errno;
+ }
+ regerror (ret, &regex, comperr, s);
+ err = grub_error (GRUB_ERR_TEST_FAILURE, "%s", comperr);
+ regfree (&regex);
+ grub_free (comperr);
+ return err;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(regexp)
+{
+ cmd = grub_register_extcmd ("regexp", grub_cmd_regexp, 0,
+ /* TRANSLATORS: This are two arguments. So it's
+ two separate units to translate and pay
+ attention not to reverse them. */
+ N_("REGEXP STRING"),
+ N_("Test if REGEXP matches STRING."), options);
+
+ /* Setup GRUB script wildcard translator. */
+ grub_wildcard_translator = &grub_filename_translator;
+}
+
+GRUB_MOD_FINI(regexp)
+{
+ grub_unregister_extcmd (cmd);
+ grub_wildcard_translator = 0;
+}
diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c
new file mode 100644
index 0000000..ed090b3
--- /dev/null
+++ b/grub-core/commands/search.c
@@ -0,0 +1,337 @@
+/* search.c - search devices based on a file or a filesystem label */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/device.h>
+#include <grub/file.h>
+#include <grub/env.h>
+#include <grub/command.h>
+#include <grub/search.h>
+#include <grub/i18n.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct cache_entry
+{
+ struct cache_entry *next;
+ char *key;
+ char *value;
+};
+
+static struct cache_entry *cache;
+
+/* Context for FUNC_NAME. */
+struct search_ctx
+{
+ const char *key;
+ const char *var;
+ int no_floppy;
+ char **hints;
+ unsigned nhints;
+ int count;
+ int is_cache;
+};
+
+/* Helper for FUNC_NAME. */
+static int
+iterate_device (const char *name, void *data)
+{
+ struct search_ctx *ctx = data;
+ int found = 0;
+
+ /* Skip floppy drives when requested. */
+ if (ctx->no_floppy &&
+ name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
+ return 1;
+
+#ifdef DO_SEARCH_FS_UUID
+#define compare_fn grub_strcasecmp
+#else
+#define compare_fn grub_strcmp
+#endif
+
+#ifdef DO_SEARCH_FILE
+ {
+ char *buf;
+ grub_file_t file;
+
+ buf = grub_xasprintf ("(%s)%s", name, ctx->key);
+ if (! buf)
+ return 1;
+
+ file = grub_file_open (buf, GRUB_FILE_TYPE_FS_SEARCH
+ | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (file)
+ {
+ found = 1;
+ grub_file_close (file);
+ }
+ grub_free (buf);
+ }
+#else
+ {
+ /* SEARCH_FS_UUID or SEARCH_LABEL */
+ grub_device_t dev;
+ grub_fs_t fs;
+ char *quid;
+
+ dev = grub_device_open (name);
+ if (dev)
+ {
+ fs = grub_fs_probe (dev);
+
+#ifdef DO_SEARCH_FS_UUID
+#define read_fn fs_uuid
+#else
+#define read_fn fs_label
+#endif
+
+ if (fs && fs->read_fn)
+ {
+ fs->read_fn (dev, &quid);
+
+ if (grub_errno == GRUB_ERR_NONE && quid)
+ {
+ if (compare_fn (quid, ctx->key) == 0)
+ found = 1;
+
+ grub_free (quid);
+ }
+ }
+
+ grub_device_close (dev);
+ }
+ }
+#endif
+
+ if (!ctx->is_cache && found && ctx->count == 0)
+ {
+ struct cache_entry *cache_ent;
+ cache_ent = grub_malloc (sizeof (*cache_ent));
+ if (cache_ent)
+ {
+ cache_ent->key = grub_strdup (ctx->key);
+ cache_ent->value = grub_strdup (name);
+ if (cache_ent->value && cache_ent->key)
+ {
+ cache_ent->next = cache;
+ cache = cache_ent;
+ }
+ else
+ {
+ grub_free (cache_ent->value);
+ grub_free (cache_ent->key);
+ grub_free (cache_ent);
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+ else
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ if (found)
+ {
+ ctx->count++;
+ if (ctx->var)
+ grub_env_set (ctx->var, name);
+ else
+ grub_printf (" %s", name);
+ }
+
+ grub_errno = GRUB_ERR_NONE;
+ return (found && ctx->var);
+}
+
+/* Helper for FUNC_NAME. */
+static int
+part_hook (grub_disk_t disk, const grub_partition_t partition, void *data)
+{
+ struct search_ctx *ctx = data;
+ char *partition_name, *devname;
+ int ret;
+
+ partition_name = grub_partition_get_name (partition);
+ if (! partition_name)
+ return 1;
+
+ devname = grub_xasprintf ("%s,%s", disk->name, partition_name);
+ grub_free (partition_name);
+ if (!devname)
+ return 1;
+ ret = iterate_device (devname, ctx);
+ grub_free (devname);
+
+ return ret;
+}
+
+/* Helper for FUNC_NAME. */
+static void
+try (struct search_ctx *ctx)
+{
+ unsigned i;
+ struct cache_entry **prev;
+ struct cache_entry *cache_ent;
+
+ for (prev = &cache, cache_ent = *prev; cache_ent;
+ prev = &cache_ent->next, cache_ent = *prev)
+ if (compare_fn (cache_ent->key, ctx->key) == 0)
+ break;
+ if (cache_ent)
+ {
+ ctx->is_cache = 1;
+ if (iterate_device (cache_ent->value, ctx))
+ {
+ ctx->is_cache = 0;
+ return;
+ }
+ ctx->is_cache = 0;
+ /* 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);
+ }
+ }
+
+ for (i = 0; i < ctx->nhints; i++)
+ {
+ char *end;
+ if (!ctx->hints[i][0])
+ continue;
+ end = ctx->hints[i] + grub_strlen (ctx->hints[i]) - 1;
+ if (*end == ',')
+ *end = 0;
+ if (iterate_device (ctx->hints[i], ctx))
+ {
+ if (!*end)
+ *end = ',';
+ return;
+ }
+ if (!*end)
+ {
+ grub_device_t dev;
+ int ret;
+ dev = grub_device_open (ctx->hints[i]);
+ if (!dev)
+ {
+ if (!*end)
+ *end = ',';
+ continue;
+ }
+ if (!dev->disk)
+ {
+ grub_device_close (dev);
+ if (!*end)
+ *end = ',';
+ continue;
+ }
+ ret = grub_partition_iterate (dev->disk, part_hook, ctx);
+ if (!*end)
+ *end = ',';
+ grub_device_close (dev);
+ if (ret)
+ return;
+ }
+ }
+ grub_device_iterate (iterate_device, ctx);
+}
+
+void
+FUNC_NAME (const char *key, const char *var, int no_floppy,
+ char **hints, unsigned nhints)
+{
+ struct search_ctx ctx = {
+ .key = key,
+ .var = var,
+ .no_floppy = no_floppy,
+ .hints = hints,
+ .nhints = nhints,
+ .count = 0,
+ .is_cache = 0
+ };
+ grub_fs_autoload_hook_t saved_autoload;
+
+ /* First try without autoloading if we're setting variable. */
+ if (var)
+ {
+ saved_autoload = grub_fs_autoload_hook;
+ grub_fs_autoload_hook = 0;
+ try (&ctx);
+
+ /* Restore autoload hook. */
+ grub_fs_autoload_hook = saved_autoload;
+
+ /* Retry with autoload if nothing found. */
+ if (grub_errno == GRUB_ERR_NONE && ctx.count == 0)
+ try (&ctx);
+ }
+ else
+ try (&ctx);
+
+ if (grub_errno == GRUB_ERR_NONE && ctx.count == 0)
+ grub_error (GRUB_ERR_FILE_NOT_FOUND, "no such device: %s", key);
+}
+
+static grub_err_t
+grub_cmd_do_search (grub_command_t cmd __attribute__ ((unused)), int argc,
+ char **args)
+{
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0, (args + 2),
+ argc > 2 ? argc - 2 : 0);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+#ifdef DO_SEARCH_FILE
+GRUB_MOD_INIT(search_fs_file)
+#elif defined (DO_SEARCH_FS_UUID)
+GRUB_MOD_INIT(search_fs_uuid)
+#else
+GRUB_MOD_INIT(search_label)
+#endif
+{
+ cmd =
+ grub_register_command (COMMAND_NAME, grub_cmd_do_search,
+ N_("NAME [VARIABLE] [HINTS]"),
+ HELP_MESSAGE);
+}
+
+#ifdef DO_SEARCH_FILE
+GRUB_MOD_FINI(search_fs_file)
+#elif defined (DO_SEARCH_FS_UUID)
+GRUB_MOD_FINI(search_fs_uuid)
+#else
+GRUB_MOD_FINI(search_label)
+#endif
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/search_file.c b/grub-core/commands/search_file.c
new file mode 100644
index 0000000..cc2a5f9
--- /dev/null
+++ b/grub-core/commands/search_file.c
@@ -0,0 +1,5 @@
+#define DO_SEARCH_FILE 1
+#define FUNC_NAME grub_search_fs_file
+#define COMMAND_NAME "search.file"
+#define HELP_MESSAGE N_("Search devices by file. If VARIABLE is specified, the first device found is set to a variable.")
+#include "search.c"
diff --git a/grub-core/commands/search_label.c b/grub-core/commands/search_label.c
new file mode 100644
index 0000000..12e7c18
--- /dev/null
+++ b/grub-core/commands/search_label.c
@@ -0,0 +1,5 @@
+#define DO_SEARCH_FS_LABEL 1
+#define FUNC_NAME grub_search_label
+#define COMMAND_NAME "search.fs_label"
+#define HELP_MESSAGE N_("Search devices by label. If VARIABLE is specified, the first device found is set to a variable.")
+#include "search.c"
diff --git a/grub-core/commands/search_uuid.c b/grub-core/commands/search_uuid.c
new file mode 100644
index 0000000..541bcf5
--- /dev/null
+++ b/grub-core/commands/search_uuid.c
@@ -0,0 +1,5 @@
+#define DO_SEARCH_FS_UUID 1
+#define FUNC_NAME grub_search_fs_uuid
+#define COMMAND_NAME "search.fs_uuid"
+#define HELP_MESSAGE N_("Search devices by UUID. If VARIABLE is specified, the first device found is set to a variable.")
+#include "search.c"
diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c
new file mode 100644
index 0000000..47fc8eb
--- /dev/null
+++ b/grub-core/commands/search_wrap.c
@@ -0,0 +1,220 @@
+/* search.c - search devices based on a file or a filesystem label */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/env.h>
+#include <grub/extcmd.h>
+#include <grub/search.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ {"file", 'f', 0, N_("Search devices by a file."), 0, 0},
+ {"label", 'l', 0, N_("Search devices by a filesystem label."),
+ 0, 0},
+ {"fs-uuid", 'u', 0, N_("Search devices by a filesystem UUID."),
+ 0, 0},
+ {"set", 's', GRUB_ARG_OPTION_OPTIONAL,
+ N_("Set a variable to the first device found."), N_("VARNAME"),
+ ARG_TYPE_STRING},
+ {"no-floppy", 'n', 0, N_("Do not probe any floppy drive."), 0, 0},
+ {"hint", 'h', GRUB_ARG_OPTION_REPEATABLE,
+ N_("First try the device HINT. If HINT ends in comma, "
+ "also try subpartitions"), N_("HINT"), ARG_TYPE_STRING},
+ {"hint-ieee1275", 0, GRUB_ARG_OPTION_REPEATABLE,
+ N_("First try the device HINT if currently running on IEEE1275. "
+ "If HINT ends in comma, also try subpartitions"),
+ N_("HINT"), ARG_TYPE_STRING},
+ {"hint-bios", 0, GRUB_ARG_OPTION_REPEATABLE,
+ N_("First try the device HINT if currently running on BIOS. "
+ "If HINT ends in comma, also try subpartitions"),
+ N_("HINT"), ARG_TYPE_STRING},
+ {"hint-baremetal", 0, GRUB_ARG_OPTION_REPEATABLE,
+ N_("First try the device HINT if direct hardware access is supported. "
+ "If HINT ends in comma, also try subpartitions"),
+ N_("HINT"), ARG_TYPE_STRING},
+ {"hint-efi", 0, GRUB_ARG_OPTION_REPEATABLE,
+ N_("First try the device HINT if currently running on EFI. "
+ "If HINT ends in comma, also try subpartitions"),
+ N_("HINT"), ARG_TYPE_STRING},
+ {"hint-arc", 0, GRUB_ARG_OPTION_REPEATABLE,
+ N_("First try the device HINT if currently running on ARC."
+ " If HINT ends in comma, also try subpartitions"),
+ N_("HINT"), ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+enum options
+ {
+ SEARCH_FILE,
+ SEARCH_LABEL,
+ SEARCH_FS_UUID,
+ SEARCH_SET,
+ SEARCH_NO_FLOPPY,
+ SEARCH_HINT,
+ SEARCH_HINT_IEEE1275,
+ SEARCH_HINT_BIOS,
+ SEARCH_HINT_BAREMETAL,
+ SEARCH_HINT_EFI,
+ SEARCH_HINT_ARC,
+ };
+
+static grub_err_t
+grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ const char *var = 0;
+ const char *id = 0;
+ int i = 0, j = 0, nhints = 0;
+ char **hints = NULL;
+
+ if (state[SEARCH_HINT].set)
+ for (i = 0; state[SEARCH_HINT].args[i]; i++)
+ nhints++;
+
+#ifdef GRUB_MACHINE_IEEE1275
+ if (state[SEARCH_HINT_IEEE1275].set)
+ for (i = 0; state[SEARCH_HINT_IEEE1275].args[i]; i++)
+ nhints++;
+#endif
+
+#ifdef GRUB_MACHINE_EFI
+ if (state[SEARCH_HINT_EFI].set)
+ for (i = 0; state[SEARCH_HINT_EFI].args[i]; i++)
+ nhints++;
+#endif
+
+#ifdef GRUB_MACHINE_PCBIOS
+ if (state[SEARCH_HINT_BIOS].set)
+ for (i = 0; state[SEARCH_HINT_BIOS].args[i]; i++)
+ nhints++;
+#endif
+
+#ifdef GRUB_MACHINE_ARC
+ if (state[SEARCH_HINT_ARC].set)
+ for (i = 0; state[SEARCH_HINT_ARC].args[i]; i++)
+ nhints++;
+#endif
+
+ if (state[SEARCH_HINT_BAREMETAL].set)
+ for (i = 0; state[SEARCH_HINT_BAREMETAL].args[i]; i++)
+ nhints++;
+
+ hints = grub_calloc (nhints, sizeof (hints[0]));
+ if (!hints)
+ return grub_errno;
+ j = 0;
+
+ if (state[SEARCH_HINT].set)
+ for (i = 0; state[SEARCH_HINT].args[i]; i++)
+ hints[j++] = state[SEARCH_HINT].args[i];
+
+#ifdef GRUB_MACHINE_IEEE1275
+ if (state[SEARCH_HINT_IEEE1275].set)
+ for (i = 0; state[SEARCH_HINT_IEEE1275].args[i]; i++)
+ hints[j++] = state[SEARCH_HINT_IEEE1275].args[i];
+#endif
+
+#ifdef GRUB_MACHINE_EFI
+ if (state[SEARCH_HINT_EFI].set)
+ for (i = 0; state[SEARCH_HINT_EFI].args[i]; i++)
+ hints[j++] = state[SEARCH_HINT_EFI].args[i];
+#endif
+
+#ifdef GRUB_MACHINE_ARC
+ if (state[SEARCH_HINT_ARC].set)
+ for (i = 0; state[SEARCH_HINT_ARC].args[i]; i++)
+ hints[j++] = state[SEARCH_HINT_ARC].args[i];
+#endif
+
+#ifdef GRUB_MACHINE_PCBIOS
+ if (state[SEARCH_HINT_BIOS].set)
+ for (i = 0; state[SEARCH_HINT_BIOS].args[i]; i++)
+ hints[j++] = state[SEARCH_HINT_BIOS].args[i];
+#endif
+
+ if (state[SEARCH_HINT_BAREMETAL].set)
+ for (i = 0; state[SEARCH_HINT_BAREMETAL].args[i]; i++)
+ hints[j++] = state[SEARCH_HINT_BAREMETAL].args[i];
+
+ /* Skip hints for future platforms. */
+ for (j = 0; j < argc; j++)
+ if (grub_memcmp (args[j], "--hint-", sizeof ("--hint-") - 1) != 0)
+ break;
+
+ if (state[SEARCH_SET].set)
+ var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root";
+
+ if (argc != j)
+ id = args[j];
+ else if (state[SEARCH_SET].set && state[SEARCH_SET].arg)
+ {
+ id = state[SEARCH_SET].arg;
+ var = "root";
+ }
+ else
+ {
+ 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,
+ hints, nhints);
+ else if (state[SEARCH_FS_UUID].set)
+ grub_search_fs_uuid (id, var, state[SEARCH_NO_FLOPPY].set,
+ hints, nhints);
+ else if (state[SEARCH_FILE].set)
+ grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set,
+ hints, nhints);
+ else
+ grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
+
+out:
+ grub_free (hints);
+ return grub_errno;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(search)
+{
+ cmd =
+ grub_register_extcmd ("search", grub_cmd_search,
+ GRUB_COMMAND_FLAG_EXTRACTOR | GRUB_COMMAND_ACCEPT_DASH,
+ N_("[-f|-l|-u|-s|-n] [--hint HINT [--hint HINT] ...]"
+ " NAME"),
+ N_("Search devices by file, filesystem label"
+ " or filesystem UUID."
+ " If --set is specified, the first device found is"
+ " set to a variable. If no variable name is"
+ " specified, `root' is used."),
+ options);
+}
+
+GRUB_MOD_FINI(search)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/setpci.c b/grub-core/commands/setpci.c
new file mode 100644
index 0000000..8a0c91f
--- /dev/null
+++ b/grub-core/commands/setpci.c
@@ -0,0 +1,340 @@
+/* lspci.c - List PCI devices. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/pci.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/env.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct pci_register
+{
+ const char *name;
+ grub_uint16_t addr;
+ unsigned size;
+};
+
+static struct pci_register pci_registers[] =
+ {
+ {"VENDOR_ID", GRUB_PCI_REG_VENDOR , 2},
+ {"DEVICE_ID", GRUB_PCI_REG_DEVICE , 2},
+ {"COMMAND", GRUB_PCI_REG_COMMAND , 2},
+ {"STATUS", GRUB_PCI_REG_STATUS , 2},
+ {"REVISION", GRUB_PCI_REG_REVISION , 1},
+ {"CLASS_PROG", GRUB_PCI_REG_CLASS + 1 , 1},
+ {"CLASS_DEVICE", GRUB_PCI_REG_CLASS + 2 , 2},
+ {"CACHE_LINE_SIZE", GRUB_PCI_REG_CACHELINE , 1},
+ {"LATENCY_TIMER", GRUB_PCI_REG_LAT_TIMER , 1},
+ {"HEADER_TYPE", GRUB_PCI_REG_HEADER_TYPE , 1},
+ {"BIST", GRUB_PCI_REG_BIST , 1},
+ {"BASE_ADDRESS_0", GRUB_PCI_REG_ADDRESS_REG0, 4},
+ {"BASE_ADDRESS_1", GRUB_PCI_REG_ADDRESS_REG1, 4},
+ {"BASE_ADDRESS_2", GRUB_PCI_REG_ADDRESS_REG2, 4},
+ {"BASE_ADDRESS_3", GRUB_PCI_REG_ADDRESS_REG3, 4},
+ {"BASE_ADDRESS_4", GRUB_PCI_REG_ADDRESS_REG4, 4},
+ {"BASE_ADDRESS_5", GRUB_PCI_REG_ADDRESS_REG5, 4},
+ {"CARDBUS_CIS", GRUB_PCI_REG_CIS_POINTER , 4},
+ {"SUBVENDOR_ID", GRUB_PCI_REG_SUBVENDOR , 2},
+ {"SUBSYSTEM_ID", GRUB_PCI_REG_SUBSYSTEM , 2},
+ {"ROM_ADDRESS", GRUB_PCI_REG_ROM_ADDRESS , 4},
+ {"CAP_POINTER", GRUB_PCI_REG_CAP_POINTER , 1},
+ {"INTERRUPT_LINE", GRUB_PCI_REG_IRQ_LINE , 1},
+ {"INTERRUPT_PIN", GRUB_PCI_REG_IRQ_PIN , 1},
+ {"MIN_GNT", GRUB_PCI_REG_MIN_GNT , 1},
+ {"MAX_LAT", GRUB_PCI_REG_MIN_GNT , 1},
+ };
+
+static const struct grub_arg_option options[] =
+ {
+ {0, 'd', 0, N_("Select device by vendor and device IDs."),
+ N_("[vendor]:[device]"), ARG_TYPE_STRING},
+ {0, 's', 0, N_("Select device by its position on the bus."),
+ N_("[bus]:[slot][.func]"), ARG_TYPE_STRING},
+ {0, 'v', 0, N_("Save read value into variable VARNAME."),
+ N_("VARNAME"), ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_uint32_t pciid_check_mask, pciid_check_value;
+static int bus, device, function;
+static int check_bus, check_device, check_function;
+static grub_uint32_t write_mask, regwrite;
+static int regsize;
+static grub_uint16_t regaddr;
+static const char *varname;
+
+static int
+grub_setpci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ grub_uint32_t regval = 0;
+ grub_pci_address_t addr;
+
+ if ((pciid & pciid_check_mask) != pciid_check_value)
+ return 0;
+
+ if (check_bus && grub_pci_get_bus (dev) != bus)
+ return 0;
+
+ if (check_device && grub_pci_get_device (dev) != device)
+ return 0;
+
+ if (check_function && grub_pci_get_function (dev) != function)
+ return 0;
+
+ addr = grub_pci_make_address (dev, regaddr);
+
+ switch (regsize)
+ {
+ case 1:
+ regval = grub_pci_read_byte (addr);
+ break;
+
+ case 2:
+ regval = grub_pci_read_word (addr);
+ break;
+
+ case 4:
+ regval = grub_pci_read (addr);
+ break;
+ }
+
+ if (varname)
+ {
+ char buf[sizeof ("XXXXXXXX")];
+ grub_snprintf (buf, sizeof (buf), "%x", regval);
+ grub_env_set (varname, buf);
+ return 1;
+ }
+
+ if (!write_mask)
+ {
+ grub_printf (_("Register %x of %x:%02x.%x is %x\n"), regaddr,
+ grub_pci_get_bus (dev),
+ grub_pci_get_device (dev),
+ grub_pci_get_function (dev),
+ regval);
+ return 0;
+ }
+
+ regval = (regval & ~write_mask) | regwrite;
+
+ switch (regsize)
+ {
+ case 1:
+ grub_pci_write_byte (addr, regval);
+ break;
+
+ case 2:
+ grub_pci_write_word (addr, regval);
+ break;
+
+ case 4:
+ grub_pci_write (addr, regval);
+ break;
+ }
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv)
+{
+ const char *ptr;
+ unsigned i;
+
+ pciid_check_value = 0;
+ pciid_check_mask = 0;
+
+ if (ctxt->state[0].set)
+ {
+ ptr = ctxt->state[0].arg;
+ pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff);
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ ptr = ctxt->state[0].arg;
+ }
+ else
+ pciid_check_mask |= 0xffff;
+ if (grub_errno)
+ return grub_errno;
+ if (*ptr != ':')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':');
+ ptr++;
+ pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff) << 16;
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ grub_errno = GRUB_ERR_NONE;
+ else
+ pciid_check_mask |= 0xffff0000;
+ }
+
+ pciid_check_value &= pciid_check_mask;
+
+ check_bus = check_device = check_function = 0;
+
+ if (ctxt->state[1].set)
+ {
+ const char *optr;
+
+ ptr = ctxt->state[1].arg;
+ optr = ptr;
+ bus = grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ ptr = optr;
+ }
+ else
+ check_bus = 1;
+ if (grub_errno)
+ return grub_errno;
+ if (*ptr != ':')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':');
+ ptr++;
+ optr = ptr;
+ device = grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ ptr = optr;
+ }
+ else
+ check_device = 1;
+ if (*ptr == '.')
+ {
+ ptr++;
+ function = grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno)
+ return grub_errno;
+ check_function = 1;
+ }
+ }
+
+ if (ctxt->state[2].set)
+ varname = ctxt->state[2].arg;
+ else
+ varname = NULL;
+
+ write_mask = 0;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ ptr = argv[0];
+
+ for (i = 0; i < ARRAY_SIZE (pci_registers); i++)
+ {
+ if (grub_strncmp (ptr, pci_registers[i].name,
+ grub_strlen (pci_registers[i].name)) == 0)
+ break;
+ }
+ if (i == ARRAY_SIZE (pci_registers))
+ {
+ regsize = 0;
+ regaddr = grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown register");
+ }
+ else
+ {
+ regaddr = pci_registers[i].addr;
+ regsize = pci_registers[i].size;
+ ptr += grub_strlen (pci_registers[i].name);
+ }
+
+ if (grub_errno)
+ return grub_errno;
+
+ if (*ptr == '+')
+ {
+ ptr++;
+ regaddr += grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno)
+ return grub_errno;
+ }
+
+ if (grub_memcmp (ptr, ".L", sizeof (".L") - 1) == 0
+ || grub_memcmp (ptr, ".l", sizeof (".l") - 1) == 0)
+ {
+ regsize = 4;
+ ptr += sizeof (".l") - 1;
+ }
+ else if (grub_memcmp (ptr, ".W", sizeof (".W") - 1) == 0
+ || grub_memcmp (ptr, ".w", sizeof (".w") - 1) == 0)
+ {
+ regsize = 2;
+ ptr += sizeof (".w") - 1;
+ }
+ else if (grub_memcmp (ptr, ".B", sizeof (".B") - 1) == 0
+ || grub_memcmp (ptr, ".b", sizeof (".b") - 1) == 0)
+ {
+ regsize = 1;
+ ptr += sizeof (".b") - 1;
+ }
+
+ if (!regsize)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "unknown register size");
+
+ write_mask = 0;
+ if (*ptr == '=')
+ {
+ ptr++;
+ regwrite = grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno)
+ return grub_errno;
+ write_mask = 0xffffffff;
+ if (*ptr == ':')
+ {
+ ptr++;
+ write_mask = grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno)
+ return grub_errno;
+ write_mask = 0xffffffff;
+ }
+ regwrite &= write_mask;
+ }
+
+ if (write_mask && varname)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "option -v isn't valid for writes");
+
+ grub_pci_iterate (grub_setpci_iter, NULL);
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(setpci)
+{
+ cmd = grub_register_extcmd_lockdown ("setpci", grub_cmd_setpci, 0,
+ N_("[-s POSITION] [-d DEVICE] [-v VAR] "
+ "REGISTER[=VALUE[:MASK]]"),
+ N_("Manipulate PCI devices."), options);
+}
+
+GRUB_MOD_FINI(setpci)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/sleep.c b/grub-core/commands/sleep.c
new file mode 100644
index 0000000..a1370b7
--- /dev/null
+++ b/grub-core/commands/sleep.c
@@ -0,0 +1,117 @@
+/* sleep.c - Command to wait a specified number of seconds. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/term.h>
+#include <grub/time.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ {"verbose", 'v', 0, N_("Verbose countdown."), 0, 0},
+ {"interruptible", 'i', 0, N_("Allow to interrupt with ESC."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static struct grub_term_coordinate *pos;
+
+static void
+do_print (int n)
+{
+ grub_term_restore_pos (pos);
+ /* NOTE: Do not remove the trailing space characters.
+ They are required to clear the line. */
+ grub_printf ("%d ", n);
+ grub_refresh ();
+}
+
+/* Based on grub_millisleep() from kern/generic/millisleep.c. */
+static int
+grub_interruptible_millisleep (grub_uint32_t ms)
+{
+ grub_uint64_t start;
+
+ start = grub_get_time_ms ();
+
+ while (grub_get_time_ms () - start < ms)
+ if (grub_key_is_interrupt (grub_getkey_noblock ()))
+ return 1;
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_sleep (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ int n;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ n = grub_strtoul (args[0], 0, 10);
+
+ if (n == 0)
+ {
+ /* Either `0' or broken input. */
+ return 0;
+ }
+
+ grub_refresh ();
+
+ pos = grub_term_save_pos ();
+
+ for (; n; n--)
+ {
+ if (state[0].set)
+ do_print (n);
+
+ if (state[1].set)
+ {
+ if (grub_interruptible_millisleep (1000))
+ return 1;
+ }
+ else
+ grub_millisleep (1000);
+ }
+ if (state[0].set)
+ do_print (0);
+
+ return 0;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(sleep)
+{
+ cmd = grub_register_extcmd ("sleep", grub_cmd_sleep, 0,
+ N_("NUMBER_OF_SECONDS"),
+ N_("Wait for a specified number of seconds."),
+ options);
+}
+
+GRUB_MOD_FINI(sleep)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/smbios.c b/grub-core/commands/smbios.c
new file mode 100644
index 0000000..1a9086d
--- /dev/null
+++ b/grub-core/commands/smbios.c
@@ -0,0 +1,398 @@
+/* smbios.c - retrieve smbios information. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2019 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/env.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/smbios.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Abstract useful values found in either the SMBIOS3 or SMBIOS EPS. */
+static struct {
+ grub_addr_t start;
+ grub_addr_t end;
+ grub_uint16_t structures;
+} table_desc;
+
+static grub_extcmd_t cmd;
+
+/* Locate the SMBIOS entry point structure depending on the hardware. */
+struct grub_smbios_eps *
+grub_smbios_get_eps (void)
+{
+ static struct grub_smbios_eps *eps = NULL;
+
+ if (eps != NULL)
+ return eps;
+
+ eps = grub_machine_smbios_get_eps ();
+
+ return eps;
+}
+
+/* Locate the SMBIOS3 entry point structure depending on the hardware. */
+static struct grub_smbios_eps3 *
+grub_smbios_get_eps3 (void)
+{
+ static struct grub_smbios_eps3 *eps = NULL;
+
+ if (eps != NULL)
+ return eps;
+
+ eps = grub_machine_smbios_get_eps3 ();
+
+ return eps;
+}
+
+static char *
+linux_string (const char *value)
+{
+ char *out = grub_malloc( grub_strlen (value) + 1);
+ const char *src = value;
+ char *dst = out;
+
+ for (; *src; src++)
+ if (*src > ' ' && *src < 127 && *src != ':')
+ *dst++ = *src;
+
+ *dst = 0;
+ return out;
+}
+
+/*
+ * These functions convert values from the various SMBIOS structure field types
+ * into a string formatted to be returned to the user. They expect that the
+ * structure and offset were already validated. When the requested data is
+ * successfully retrieved and formatted, the pointer to the string is returned;
+ * otherwise, NULL is returned on failure. Don't free the result.
+ */
+
+static const char *
+grub_smbios_format_byte (const grub_uint8_t *structure, grub_uint8_t offset)
+{
+ static char buffer[sizeof ("255")];
+
+ grub_snprintf (buffer, sizeof (buffer), "%u", structure[offset]);
+
+ return (const char *)buffer;
+}
+
+static const char *
+grub_smbios_format_word (const grub_uint8_t *structure, grub_uint8_t offset)
+{
+ static char buffer[sizeof ("65535")];
+
+ grub_uint16_t value = grub_get_unaligned16 (structure + offset);
+ grub_snprintf (buffer, sizeof (buffer), "%u", value);
+
+ return (const char *)buffer;
+}
+
+static const char *
+grub_smbios_format_dword (const grub_uint8_t *structure, grub_uint8_t offset)
+{
+ static char buffer[sizeof ("4294967295")];
+
+ grub_uint32_t value = grub_get_unaligned32 (structure + offset);
+ grub_snprintf (buffer, sizeof (buffer), "%" PRIuGRUB_UINT32_T, value);
+
+ return (const char *)buffer;
+}
+
+static const char *
+grub_smbios_format_qword (const grub_uint8_t *structure, grub_uint8_t offset)
+{
+ static char buffer[sizeof ("18446744073709551615")];
+
+ grub_uint64_t value = grub_get_unaligned64 (structure + offset);
+ grub_snprintf (buffer, sizeof (buffer), "%" PRIuGRUB_UINT64_T, value);
+
+ return (const char *)buffer;
+}
+
+static const char *
+grub_smbios_get_string (const grub_uint8_t *structure, grub_uint8_t offset)
+{
+ const grub_uint8_t *ptr = structure + structure[1];
+ const grub_uint8_t *table_end = (const grub_uint8_t *)table_desc.end;
+ const grub_uint8_t referenced_string_number = structure[offset];
+ grub_uint8_t i;
+
+ /* A string referenced with zero is interpreted as unset. */
+ if (referenced_string_number == 0)
+ return NULL;
+
+ /* Search the string set. */
+ for (i = 1; *ptr != 0 && ptr < table_end; i++)
+ if (i == referenced_string_number)
+ {
+ const char *str = (const char *)ptr;
+ while (*ptr++ != 0)
+ if (ptr >= table_end)
+ return NULL; /* The string isn't terminated. */
+ return str;
+ }
+ else
+ while (*ptr++ != 0 && ptr < table_end);
+
+ /* The string number is greater than the number of strings in the set. */
+ return NULL;
+}
+
+static const char *
+grub_smbios_format_uuid (const grub_uint8_t *structure, grub_uint8_t offset)
+{
+ static char buffer[sizeof ("ffffffff-ffff-ffff-ffff-ffffffffffff")];
+ const grub_uint8_t *f = structure + offset; /* little-endian fields */
+ const grub_uint8_t *g = f + 8; /* byte-by-byte fields */
+
+ grub_snprintf (buffer, sizeof (buffer),
+ "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
+ "%02x%02x-%02x%02x%02x%02x%02x%02x",
+ f[3], f[2], f[1], f[0], f[5], f[4], f[7], f[6],
+ g[0], g[1], g[2], g[3], g[4], g[5], g[6], g[7]);
+
+ return (const char *)buffer;
+}
+
+/* List the field formatting functions and the number of bytes they need. */
+static const struct {
+ const char *(*format) (const grub_uint8_t *structure, grub_uint8_t offset);
+ grub_uint8_t field_length;
+} field_extractors[] = {
+ {grub_smbios_format_byte, 1},
+ {grub_smbios_format_word, 2},
+ {grub_smbios_format_dword, 4},
+ {grub_smbios_format_qword, 8},
+ {grub_smbios_get_string, 1},
+ {grub_smbios_format_uuid, 16}
+};
+
+/* List command options, with structure field getters ordered as above. */
+#define FIRST_GETTER_OPT (3)
+#define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors))
+#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1)
+
+static const struct grub_arg_option options[] = {
+ {"type", 't', 0, N_("Match structures with the given type."),
+ N_("type"), ARG_TYPE_INT},
+ {"handle", 'h', 0, N_("Match structures with the given handle."),
+ N_("handle"), ARG_TYPE_INT},
+ {"match", 'm', 0, N_("Select a structure when several match."),
+ N_("match"), ARG_TYPE_INT},
+ {"get-byte", 'b', 0, N_("Get the byte's value at the given offset."),
+ N_("offset"), ARG_TYPE_INT},
+ {"get-word", 'w', 0, N_("Get two bytes' value at the given offset."),
+ N_("offset"), ARG_TYPE_INT},
+ {"get-dword", 'd', 0, N_("Get four bytes' value at the given offset."),
+ N_("offset"), ARG_TYPE_INT},
+ {"get-qword", 'q', 0, N_("Get eight bytes' value at the given offset."),
+ N_("offset"), ARG_TYPE_INT},
+ {"get-string", 's', 0, N_("Get the string specified at the given offset."),
+ N_("offset"), ARG_TYPE_INT},
+ {"get-uuid", 'u', 0, N_("Get the UUID's value at the given offset."),
+ N_("offset"), ARG_TYPE_INT},
+ {"set", '\0', 0, N_("Store the value in the given variable name."),
+ N_("variable"), ARG_TYPE_STRING},
+ {"linux", '\0', 0, N_("Filter the result like linux does."),
+ N_("variable"), ARG_TYPE_NONE},
+ {0, 0, 0, 0, 0, 0}
+};
+
+/*
+ * Return a matching SMBIOS structure.
+ *
+ * This method can use up to three criteria for selecting a structure:
+ * - The "type" field (use -1 to ignore)
+ * - The "handle" field (use -1 to ignore)
+ * - Which to return if several match (use 0 to ignore)
+ *
+ * The return value is a pointer to the first matching structure. If no
+ * structures match the given parameters, NULL is returned.
+ */
+static const grub_uint8_t *
+grub_smbios_match_structure (const grub_int16_t type,
+ const grub_int32_t handle,
+ const grub_uint16_t match)
+{
+ const grub_uint8_t *ptr = (const grub_uint8_t *)table_desc.start;
+ const grub_uint8_t *table_end = (const grub_uint8_t *)table_desc.end;
+ grub_uint16_t structures = table_desc.structures;
+ grub_uint16_t structure_count = 0;
+ grub_uint16_t matches = 0;
+
+ while (ptr < table_end
+ && ptr[1] >= 4 /* Valid structures include the 4-byte header. */
+ && (structure_count++ < structures || structures == 0))
+ {
+ grub_uint16_t structure_handle = grub_get_unaligned16 (ptr + 2);
+ grub_uint8_t structure_type = ptr[0];
+
+ if ((handle < 0 || handle == structure_handle)
+ && (type < 0 || type == structure_type)
+ && (match == 0 || match == ++matches))
+ return ptr;
+ else
+ {
+ ptr += ptr[1];
+ while ((*ptr++ != 0 || *ptr++ != 0) && ptr < table_end);
+ }
+
+ if (structure_type == GRUB_SMBIOS_TYPE_END_OF_TABLE)
+ break;
+ }
+
+ return NULL;
+}
+
+static grub_err_t
+grub_cmd_smbios (grub_extcmd_context_t ctxt,
+ int argc __attribute__ ((unused)),
+ char **argv __attribute__ ((unused)))
+{
+ struct grub_arg_list *state = ctxt->state;
+
+ grub_int16_t type = -1;
+ grub_int32_t handle = -1;
+ grub_uint16_t match = 0;
+ grub_uint8_t offset = 0;
+
+ const grub_uint8_t *structure;
+ const char *value;
+ char *modified_value = NULL;
+ grub_int32_t option;
+ grub_int8_t field_type = -1;
+ grub_uint8_t i;
+
+ if (table_desc.start == 0)
+ return grub_error (GRUB_ERR_IO,
+ N_("the SMBIOS entry point structure was not found"));
+
+ /* Read the given filtering options. */
+ if (state[0].set)
+ {
+ option = grub_strtol (state[0].arg, NULL, 0);
+ if (option < 0 || option > 255)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("the type must be between 0 and 255"));
+ type = (grub_int16_t)option;
+ }
+ if (state[1].set)
+ {
+ option = grub_strtol (state[1].arg, NULL, 0);
+ if (option < 0 || option > 65535)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("the handle must be between 0 and 65535"));
+ handle = (grub_int32_t)option;
+ }
+ if (state[2].set)
+ {
+ option = grub_strtol (state[2].arg, NULL, 0);
+ if (option <= 0 || option > 65535)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("the match must be a positive integer"));
+ match = (grub_uint16_t)option;
+ }
+
+ /* Determine the data type of the structure field to retrieve. */
+ for (i = 0; i < ARRAY_SIZE(field_extractors); i++)
+ if (state[FIRST_GETTER_OPT + i].set)
+ {
+ if (field_type >= 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("only one --get option is usable at a time"));
+ field_type = i;
+ }
+
+ /* Require a choice of a structure field to return. */
+ if (field_type < 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("one of the --get options is required"));
+
+ /* Locate a matching SMBIOS structure. */
+ structure = grub_smbios_match_structure (type, handle, match);
+ if (structure == NULL)
+ return grub_error (GRUB_ERR_IO,
+ N_("no structure matched the given options"));
+
+ /* Ensure the requested byte offset is inside the structure. */
+ option = grub_strtol (state[FIRST_GETTER_OPT + field_type].arg, NULL, 0);
+ if (option < 0 || option >= structure[1])
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("the given offset is outside the structure"));
+
+ /* Ensure the requested data type at the offset is inside the structure. */
+ offset = (grub_uint8_t)option;
+ if (offset + field_extractors[field_type].field_length > structure[1])
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("the field ends outside the structure"));
+
+ /* Format the requested structure field into a readable string. */
+ value = field_extractors[field_type].format (structure, offset);
+ if (value == NULL)
+ return grub_error (GRUB_ERR_IO,
+ N_("failed to retrieve the structure field"));
+
+ if (state[LINUX_OPT].set)
+ value = modified_value = linux_string (value);
+
+ /* Store or print the formatted value. */
+ if (state[SETTER_OPT].set)
+ grub_env_set (state[SETTER_OPT].arg, value);
+ else
+ grub_printf ("%s\n", value);
+
+ grub_free(modified_value);
+
+ return GRUB_ERR_NONE;
+}
+
+GRUB_MOD_INIT(smbios)
+{
+ struct grub_smbios_eps3 *eps3;
+ struct grub_smbios_eps *eps;
+
+ if ((eps3 = grub_smbios_get_eps3 ()))
+ {
+ table_desc.start = (grub_addr_t)eps3->table_address;
+ table_desc.end = table_desc.start + eps3->maximum_table_length;
+ table_desc.structures = 0; /* SMBIOS3 drops the structure count. */
+ }
+ else if ((eps = grub_smbios_get_eps ()))
+ {
+ table_desc.start = (grub_addr_t)eps->intermediate.table_address;
+ table_desc.end = table_desc.start + eps->intermediate.table_length;
+ table_desc.structures = eps->intermediate.structures;
+ }
+
+ cmd = grub_register_extcmd ("smbios", grub_cmd_smbios, 0,
+ N_("[-t type] [-h handle] [-m match] "
+ "(-b|-w|-d|-q|-s|-u) offset "
+ "[--set variable]"),
+ N_("Retrieve SMBIOS information."), options);
+}
+
+GRUB_MOD_FINI(smbios)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/syslinuxcfg.c b/grub-core/commands/syslinuxcfg.c
new file mode 100644
index 0000000..7be28fa
--- /dev/null
+++ b/grub-core/commands/syslinuxcfg.c
@@ -0,0 +1,217 @@
+/*
+ * 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/types.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/normal.h>
+#include <grub/script_sh.h>
+#include <grub/i18n.h>
+#include <grub/term.h>
+#include <grub/syslinux_parse.h>
+#include <grub/crypto.h>
+#include <grub/auth.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Helper for syslinux_file. */
+static grub_err_t
+syslinux_file_getline (char **line, int cont __attribute__ ((unused)),
+ void *data __attribute__ ((unused)))
+{
+ *line = 0;
+ return GRUB_ERR_NONE;
+}
+
+static const struct grub_arg_option options[] =
+ {
+ {"root", 'r', 0,
+ N_("root directory of the syslinux disk [default=/]."),
+ N_("DIR"), ARG_TYPE_STRING},
+ {"cwd", 'c', 0,
+ N_("current directory of syslinux [default is parent directory of input file]."),
+ N_("DIR"), ARG_TYPE_STRING},
+ {"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}
+ };
+
+enum
+ {
+ OPTION_ROOT,
+ OPTION_CWD,
+ OPTION_ISOLINUX,
+ OPTION_PXELINUX,
+ OPTION_SYSLINUX
+ };
+
+static grub_err_t
+syslinux_file (grub_extcmd_context_t ctxt, const char *filename)
+{
+ char *result;
+ const char *root = ctxt->state[OPTION_ROOT].set ? ctxt->state[OPTION_ROOT].arg : "/";
+ const char *cwd = ctxt->state[OPTION_CWD].set ? ctxt->state[OPTION_CWD].arg : NULL;
+ grub_syslinux_flavour_t flav = GRUB_SYSLINUX_UNKNOWN;
+ char *cwdf = NULL;
+ grub_menu_t menu;
+
+ if (ctxt->state[OPTION_ISOLINUX].set)
+ flav = GRUB_SYSLINUX_ISOLINUX;
+ if (ctxt->state[OPTION_PXELINUX].set)
+ flav = GRUB_SYSLINUX_PXELINUX;
+ if (ctxt->state[OPTION_SYSLINUX].set)
+ flav = GRUB_SYSLINUX_SYSLINUX;
+
+ if (!cwd)
+ {
+ char *p;
+ cwdf = grub_strdup (filename);
+ if (!cwdf)
+ return grub_errno;
+ p = grub_strrchr (cwdf, '/');
+ if (!p)
+ {
+ grub_free (cwdf);
+ cwd = "/";
+ cwdf = NULL;
+ }
+ else
+ {
+ *p = '\0';
+ cwd = cwdf;
+ }
+ }
+
+ grub_dprintf ("syslinux",
+ "transforming syslinux config %s, root = %s, cwd = %s\n",
+ filename, root, cwd);
+
+ result = grub_syslinux_config_file (root, root, cwd, cwd, filename, flav);
+ if (!result)
+ return grub_errno;
+
+ grub_dprintf ("syslinux", "syslinux config transformed\n");
+
+ menu = grub_env_get_menu ();
+ if (! menu)
+ {
+ menu = grub_zalloc (sizeof (*menu));
+ if (! menu)
+ {
+ grub_free (result);
+ return grub_errno;
+ }
+
+ grub_env_set_menu (menu);
+ }
+
+ grub_normal_parse_line (result, syslinux_file_getline, NULL);
+ grub_print_error ();
+ grub_free (result);
+ grub_free (cwdf);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_syslinux_source (grub_extcmd_context_t ctxt,
+ int argc, char **args)
+{
+ int new_env, extractor;
+ grub_err_t ret;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ extractor = (ctxt->extcmd->cmd->name[0] == 'e');
+ new_env = (ctxt->extcmd->cmd->name[extractor ? (sizeof ("extract_syslinux_entries_") - 1)
+ : (sizeof ("syslinux_") - 1)] == 'c');
+
+ if (new_env)
+ grub_cls ();
+
+ if (new_env && !extractor)
+ grub_env_context_open ();
+ if (extractor)
+ grub_env_extractor_open (!new_env);
+
+ ret = syslinux_file (ctxt, args[0]);
+
+ if (new_env)
+ {
+ grub_menu_t menu;
+ menu = grub_env_get_menu ();
+ if (menu && menu->size)
+ grub_show_menu (menu, 1, 0);
+ if (!extractor)
+ grub_env_context_close ();
+ }
+ if (extractor)
+ grub_env_extractor_close (!new_env);
+
+ return ret;
+}
+
+
+static grub_extcmd_t cmd_source, cmd_configfile;
+static grub_extcmd_t cmd_source_extract, cmd_configfile_extract;
+
+GRUB_MOD_INIT(syslinuxcfg)
+{
+ cmd_source
+ = grub_register_extcmd ("syslinux_source",
+ grub_cmd_syslinux_source, 0,
+ N_("FILE"),
+ /* TRANSLATORS: "syslinux config" means
+ "config as used by syslinux". */
+ N_("Execute syslinux config in same context"),
+ options);
+ cmd_configfile
+ = grub_register_extcmd ("syslinux_configfile",
+ grub_cmd_syslinux_source, 0,
+ N_("FILE"),
+ 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_("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_("Execute syslinux config in new context taking only menu entries"),
+ options);
+}
+
+GRUB_MOD_FINI(syslinuxcfg)
+{
+ grub_unregister_extcmd (cmd_source);
+ grub_unregister_extcmd (cmd_configfile);
+ grub_unregister_extcmd (cmd_source_extract);
+ grub_unregister_extcmd (cmd_configfile_extract);
+}
diff --git a/grub-core/commands/terminal.c b/grub-core/commands/terminal.c
new file mode 100644
index 0000000..37e0ab8
--- /dev/null
+++ b/grub-core/commands/terminal.c
@@ -0,0 +1,285 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/term.h>
+#include <grub/i18n.h>
+#include <grub/misc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_term_autoload *grub_term_input_autoload = NULL;
+struct grub_term_autoload *grub_term_output_autoload = NULL;
+
+struct abstract_terminal
+{
+ struct abstract_terminal *next;
+ struct abstract_terminal *prev;
+ const char *name;
+ grub_err_t (*init) (struct abstract_terminal *term);
+ grub_err_t (*fini) (struct abstract_terminal *term);
+};
+
+static grub_err_t
+handle_command (int argc, char **args, struct abstract_terminal **enabled,
+ struct abstract_terminal **disabled,
+ struct grub_term_autoload *autoloads,
+ const char *active_str,
+ const char *available_str)
+{
+ int i;
+ struct abstract_terminal *term;
+ struct grub_term_autoload *aut;
+
+ if (argc == 0)
+ {
+ grub_puts_ (active_str);
+ for (term = *enabled; term; term = term->next)
+ grub_printf ("%s ", term->name);
+ grub_printf ("\n");
+ grub_puts_ (available_str);
+ for (term = *disabled; term; term = term->next)
+ grub_printf ("%s ", term->name);
+ /* This is quadratic but we don't expect mode than 30 terminal
+ modules ever. */
+ for (aut = autoloads; aut; aut = aut->next)
+ {
+ for (term = *disabled; term; term = term->next)
+ if (grub_strcmp (term->name, aut->name) == 0
+ || (aut->name[0] && aut->name[grub_strlen (aut->name) - 1] == '*'
+ && grub_memcmp (term->name, aut->name,
+ grub_strlen (aut->name) - 1) == 0))
+ break;
+ if (!term)
+ for (term = *enabled; term; term = term->next)
+ if (grub_strcmp (term->name, aut->name) == 0
+ || (aut->name[0] && aut->name[grub_strlen (aut->name) - 1] == '*'
+ && grub_memcmp (term->name, aut->name,
+ grub_strlen (aut->name) - 1) == 0))
+ break;
+ if (!term)
+ grub_printf ("%s ", aut->name);
+ }
+ grub_printf ("\n");
+ return GRUB_ERR_NONE;
+ }
+ i = 0;
+
+ if (grub_strcmp (args[0], "--append") == 0
+ || grub_strcmp (args[0], "--remove") == 0)
+ i++;
+
+ if (i == argc)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no terminal specified"));
+
+ for (; i < argc; i++)
+ {
+ int again = 0;
+ while (1)
+ {
+ for (term = *disabled; term; term = term->next)
+ if (grub_strcmp (args[i], term->name) == 0
+ || (grub_strcmp (args[i], "ofconsole") == 0
+ && grub_strcmp ("console", term->name) == 0))
+ break;
+ if (term == 0)
+ for (term = *enabled; term; term = term->next)
+ if (grub_strcmp (args[i], term->name) == 0
+ || (grub_strcmp (args[i], "ofconsole") == 0
+ && grub_strcmp ("console", term->name) == 0))
+ break;
+ if (term)
+ break;
+ if (again)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("terminal `%s' isn't found"),
+ args[i]);
+ for (aut = autoloads; aut; aut = aut->next)
+ if (grub_strcmp (args[i], aut->name) == 0
+ || (grub_strcmp (args[i], "ofconsole") == 0
+ && grub_strcmp ("console", aut->name) == 0)
+ || (aut->name[0] && aut->name[grub_strlen (aut->name) - 1] == '*'
+ && grub_memcmp (args[i], aut->name,
+ grub_strlen (aut->name) - 1) == 0))
+ {
+ grub_dl_t mod;
+ mod = grub_dl_load (aut->modname);
+ if (mod)
+ grub_dl_ref (mod);
+ grub_errno = GRUB_ERR_NONE;
+ break;
+ }
+ if (grub_memcmp (args[i], "serial_usb",
+ sizeof ("serial_usb") - 1) == 0
+ && grub_term_poll_usb)
+ {
+ grub_term_poll_usb (1);
+ again = 1;
+ continue;
+ }
+ if (!aut)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("terminal `%s' isn't found"),
+ args[i]);
+ again = 1;
+ }
+ }
+
+ if (grub_strcmp (args[0], "--append") == 0)
+ {
+ for (i = 1; i < argc; i++)
+ {
+ for (term = *disabled; term; term = term->next)
+ if (grub_strcmp (args[i], term->name) == 0
+ || (grub_strcmp (args[i], "ofconsole") == 0
+ && grub_strcmp ("console", term->name) == 0))
+ break;
+ if (term)
+ {
+ if (term->init && term->init (term) != GRUB_ERR_NONE)
+ return grub_errno;
+
+ grub_list_remove (GRUB_AS_LIST (term));
+ grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
+ }
+ }
+ return GRUB_ERR_NONE;
+ }
+
+ if (grub_strcmp (args[0], "--remove") == 0)
+ {
+ for (i = 1; i < argc; i++)
+ {
+ for (term = *enabled; term; term = term->next)
+ if (grub_strcmp (args[i], term->name) == 0
+ || (grub_strcmp (args[i], "ofconsole") == 0
+ && grub_strcmp ("console", term->name) == 0))
+ break;
+ if (term)
+ {
+ if (!term->next && term == *enabled)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "can't remove the last terminal");
+ grub_list_remove (GRUB_AS_LIST (term));
+ if (term->fini)
+ term->fini (term);
+ grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
+ }
+ }
+ return GRUB_ERR_NONE;
+ }
+ for (i = 0; i < argc; i++)
+ {
+ for (term = *disabled; term; term = term->next)
+ if (grub_strcmp (args[i], term->name) == 0
+ || (grub_strcmp (args[i], "ofconsole") == 0
+ && grub_strcmp ("console", term->name) == 0))
+ break;
+ if (term)
+ {
+ if (term->init && term->init (term) != GRUB_ERR_NONE)
+ return grub_errno;
+
+ grub_list_remove (GRUB_AS_LIST (term));
+ grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
+ }
+ }
+
+ {
+ struct abstract_terminal *next;
+ for (term = *enabled; term; term = next)
+ {
+ next = term->next;
+ for (i = 0; i < argc; i++)
+ if (grub_strcmp (args[i], term->name) == 0
+ || (grub_strcmp (args[i], "ofconsole") == 0
+ && grub_strcmp ("console", term->name) == 0))
+ break;
+ if (i == argc)
+ {
+ if (!term->next && term == *enabled)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "can't remove the last terminal");
+ grub_list_remove (GRUB_AS_LIST (term));
+ if (term->fini)
+ term->fini (term);
+ grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ (void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, next);
+ (void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, prev);
+ (void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, name);
+ (void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, init);
+ (void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, fini);
+ return handle_command (argc, args,
+ (struct abstract_terminal **) (void *) &grub_term_inputs,
+ (struct abstract_terminal **) (void *) &grub_term_inputs_disabled,
+ grub_term_input_autoload,
+ N_("Active input terminals:"),
+ N_("Available input terminals:"));
+}
+
+static grub_err_t
+grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, next);
+ (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, prev);
+ (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, name);
+ (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, init);
+ (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, fini);
+ return handle_command (argc, args,
+ (struct abstract_terminal **) (void *) &grub_term_outputs,
+ (struct abstract_terminal **) (void *) &grub_term_outputs_disabled,
+ grub_term_output_autoload,
+ N_("Active output terminals:"),
+ N_("Available output terminals:"));
+}
+
+static grub_command_t cmd_terminal_input, cmd_terminal_output;
+
+GRUB_MOD_INIT(terminal)
+{
+ cmd_terminal_input =
+ grub_register_command ("terminal_input", grub_cmd_terminal_input,
+ N_("[--append|--remove] "
+ "[TERMINAL1] [TERMINAL2] ..."),
+ N_("List or select an input terminal."));
+ cmd_terminal_output =
+ grub_register_command ("terminal_output", grub_cmd_terminal_output,
+ N_("[--append|--remove] "
+ "[TERMINAL1] [TERMINAL2] ..."),
+ N_("List or select an output terminal."));
+}
+
+GRUB_MOD_FINI(terminal)
+{
+ grub_unregister_command (cmd_terminal_input);
+ grub_unregister_command (cmd_terminal_output);
+}
diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c
new file mode 100644
index 0000000..62d3fb3
--- /dev/null
+++ b/grub-core/commands/test.c
@@ -0,0 +1,455 @@
+/* test.c -- The test command.. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/fs.h>
+#include <grub/device.h>
+#include <grub/file.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* A simple implementation for signed numbers. */
+static int
+grub_strtosl (char *arg, const char ** const end, int base)
+{
+ if (arg[0] == '-')
+ return -grub_strtoul (arg + 1, end, base);
+ return grub_strtoul (arg, end, base);
+}
+
+/* Context for test_parse. */
+struct test_parse_ctx
+{
+ int invert;
+ int or, and;
+ int file_exists;
+ struct grub_dirhook_info file_info;
+ char *filename;
+};
+
+/* Take care of discarding and inverting. */
+static void
+update_val (int val, struct test_parse_ctx *ctx)
+{
+ ctx->and = ctx->and && (ctx->invert ? ! val : val);
+ ctx->invert = 0;
+}
+
+/* A hook for iterating directories. */
+static int
+find_file (const char *cur_filename, const struct grub_dirhook_info *info,
+ void *data)
+{
+ struct test_parse_ctx *ctx = data;
+
+ if ((info->case_insensitive ? grub_strcasecmp (cur_filename, ctx->filename)
+ : grub_strcmp (cur_filename, ctx->filename)) == 0)
+ {
+ ctx->file_info = *info;
+ ctx->file_exists = 1;
+ return 1;
+ }
+ return 0;
+}
+
+/* Check if file exists and fetch its information. */
+static void
+get_fileinfo (char *path, struct test_parse_ctx *ctx)
+{
+ char *pathname;
+ char *device_name;
+ grub_fs_t fs;
+ grub_device_t dev;
+
+ ctx->file_exists = 0;
+ device_name = grub_file_get_device_name (path);
+ dev = grub_device_open (device_name);
+ if (! dev)
+ {
+ grub_free (device_name);
+ return;
+ }
+
+ fs = grub_fs_probe (dev);
+ if (! fs)
+ {
+ grub_free (device_name);
+ grub_device_close (dev);
+ return;
+ }
+
+ pathname = grub_strchr (path, ')');
+ if (! pathname)
+ pathname = path;
+ else
+ pathname++;
+
+ /* Remove trailing '/'. */
+ while (*pathname && pathname[grub_strlen (pathname) - 1] == '/')
+ pathname[grub_strlen (pathname) - 1] = 0;
+
+ /* Split into path and filename. */
+ ctx->filename = grub_strrchr (pathname, '/');
+ if (! ctx->filename)
+ {
+ path = grub_strdup ("/");
+ ctx->filename = pathname;
+ }
+ else
+ {
+ ctx->filename++;
+ path = grub_strdup (pathname);
+ path[ctx->filename - pathname] = 0;
+ }
+
+ /* It's the whole device. */
+ if (! *pathname)
+ {
+ ctx->file_exists = 1;
+ grub_memset (&ctx->file_info, 0, sizeof (ctx->file_info));
+ /* Root is always a directory. */
+ ctx->file_info.dir = 1;
+
+ /* Fetch writing time. */
+ ctx->file_info.mtimeset = 0;
+ if (fs->fs_mtime)
+ {
+ if (! fs->fs_mtime (dev, &ctx->file_info.mtime))
+ ctx->file_info.mtimeset = 1;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+ else
+ (fs->fs_dir) (dev, path, find_file, ctx);
+
+ grub_device_close (dev);
+ grub_free (path);
+ grub_free (device_name);
+}
+
+/* Parse a test expression starting from *argn. */
+static int
+test_parse (char **args, int *argn, int argc)
+{
+ struct test_parse_ctx ctx = {
+ .and = 1,
+ .or = 0,
+ .invert = 0
+ };
+
+ /* Here we have the real parsing. */
+ while (*argn < argc)
+ {
+ /* First try 3 argument tests. */
+ if (*argn + 2 < argc)
+ {
+ /* String tests. */
+ if (grub_strcmp (args[*argn + 1], "=") == 0
+ || grub_strcmp (args[*argn + 1], "==") == 0)
+ {
+ update_val (grub_strcmp (args[*argn], args[*argn + 2]) == 0,
+ &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn + 1], "!=") == 0)
+ {
+ update_val (grub_strcmp (args[*argn], args[*argn + 2]) != 0,
+ &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ /* GRUB extension: lexicographical sorting. */
+ if (grub_strcmp (args[*argn + 1], "<") == 0)
+ {
+ update_val (grub_strcmp (args[*argn], args[*argn + 2]) < 0,
+ &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn + 1], "<=") == 0)
+ {
+ update_val (grub_strcmp (args[*argn], args[*argn + 2]) <= 0,
+ &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn + 1], ">") == 0)
+ {
+ update_val (grub_strcmp (args[*argn], args[*argn + 2]) > 0,
+ &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn + 1], ">=") == 0)
+ {
+ update_val (grub_strcmp (args[*argn], args[*argn + 2]) >= 0,
+ &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ /* Number tests. */
+ if (grub_strcmp (args[*argn + 1], "-eq") == 0)
+ {
+ update_val (grub_strtosl (args[*argn], 0, 0)
+ == grub_strtosl (args[*argn + 2], 0, 0), &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn + 1], "-ge") == 0)
+ {
+ update_val (grub_strtosl (args[*argn], 0, 0)
+ >= grub_strtosl (args[*argn + 2], 0, 0), &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn + 1], "-gt") == 0)
+ {
+ update_val (grub_strtosl (args[*argn], 0, 0)
+ > grub_strtosl (args[*argn + 2], 0, 0), &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn + 1], "-le") == 0)
+ {
+ update_val (grub_strtosl (args[*argn], 0, 0)
+ <= grub_strtosl (args[*argn + 2], 0, 0), &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn + 1], "-lt") == 0)
+ {
+ update_val (grub_strtosl (args[*argn], 0, 0)
+ < grub_strtosl (args[*argn + 2], 0, 0), &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn + 1], "-ne") == 0)
+ {
+ update_val (grub_strtosl (args[*argn], 0, 0)
+ != grub_strtosl (args[*argn + 2], 0, 0), &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ /* GRUB extension: compare numbers skipping prefixes.
+ Useful for comparing versions. E.g. vmlinuz-2 -plt vmlinuz-11. */
+ if (grub_strcmp (args[*argn + 1], "-pgt") == 0
+ || grub_strcmp (args[*argn + 1], "-plt") == 0)
+ {
+ int i;
+ /* Skip common prefix. */
+ for (i = 0; args[*argn][i] == args[*argn + 2][i]
+ && args[*argn][i]; i++);
+
+ /* Go the digits back. */
+ i--;
+ while (grub_isdigit (args[*argn][i]) && i > 0)
+ i--;
+ i++;
+
+ if (grub_strcmp (args[*argn + 1], "-pgt") == 0)
+ update_val (grub_strtoul (args[*argn] + i, 0, 0)
+ > grub_strtoul (args[*argn + 2] + i, 0, 0), &ctx);
+ else
+ update_val (grub_strtoul (args[*argn] + i, 0, 0)
+ < grub_strtoul (args[*argn + 2] + i, 0, 0), &ctx);
+ (*argn) += 3;
+ continue;
+ }
+
+ /* -nt and -ot tests. GRUB extension: when doing -?t<bias> bias
+ will be added to the first mtime. */
+ if (grub_memcmp (args[*argn + 1], "-nt", 3) == 0
+ || grub_memcmp (args[*argn + 1], "-ot", 3) == 0)
+ {
+ struct grub_dirhook_info file1;
+ int file1exists;
+ int bias = 0;
+
+ /* Fetch fileinfo. */
+ get_fileinfo (args[*argn], &ctx);
+ file1 = ctx.file_info;
+ file1exists = ctx.file_exists;
+ get_fileinfo (args[*argn + 2], &ctx);
+
+ if (args[*argn + 1][3])
+ bias = grub_strtosl (args[*argn + 1] + 3, 0, 0);
+
+ if (grub_memcmp (args[*argn + 1], "-nt", 3) == 0)
+ update_val ((file1exists && ! ctx.file_exists)
+ || (file1.mtimeset && ctx.file_info.mtimeset
+ && file1.mtime + bias > ctx.file_info.mtime),
+ &ctx);
+ else
+ update_val ((! file1exists && ctx.file_exists)
+ || (file1.mtimeset && ctx.file_info.mtimeset
+ && file1.mtime + bias < ctx.file_info.mtime),
+ &ctx);
+ (*argn) += 3;
+ continue;
+ }
+ }
+
+ /* Two-argument tests. */
+ if (*argn + 1 < argc)
+ {
+ /* File tests. */
+ if (grub_strcmp (args[*argn], "-d") == 0)
+ {
+ get_fileinfo (args[*argn + 1], &ctx);
+ update_val (ctx.file_exists && ctx.file_info.dir, &ctx);
+ (*argn) += 2;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn], "-e") == 0)
+ {
+ get_fileinfo (args[*argn + 1], &ctx);
+ update_val (ctx.file_exists, &ctx);
+ (*argn) += 2;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn], "-f") == 0)
+ {
+ get_fileinfo (args[*argn + 1], &ctx);
+ /* FIXME: check for other types. */
+ update_val (ctx.file_exists && ! ctx.file_info.dir, &ctx);
+ (*argn) += 2;
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn], "-s") == 0)
+ {
+ grub_file_t file;
+ file = grub_file_open (args[*argn + 1], GRUB_FILE_TYPE_GET_SIZE
+ | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ update_val (file && (grub_file_size (file) != 0), &ctx);
+ if (file)
+ grub_file_close (file);
+ grub_errno = GRUB_ERR_NONE;
+ (*argn) += 2;
+ continue;
+ }
+
+ /* String tests. */
+ if (grub_strcmp (args[*argn], "-n") == 0)
+ {
+ update_val (args[*argn + 1][0], &ctx);
+
+ (*argn) += 2;
+ continue;
+ }
+ if (grub_strcmp (args[*argn], "-z") == 0)
+ {
+ update_val (! args[*argn + 1][0], &ctx);
+ (*argn) += 2;
+ continue;
+ }
+ }
+
+ /* Special modifiers. */
+
+ /* End of expression. return to parent. */
+ if (grub_strcmp (args[*argn], ")") == 0)
+ {
+ (*argn)++;
+ return ctx.or || ctx.and;
+ }
+ /* Recursively invoke if parenthesis. */
+ if (grub_strcmp (args[*argn], "(") == 0)
+ {
+ (*argn)++;
+ update_val (test_parse (args, argn, argc), &ctx);
+ continue;
+ }
+
+ if (grub_strcmp (args[*argn], "!") == 0)
+ {
+ ctx.invert = ! ctx.invert;
+ (*argn)++;
+ continue;
+ }
+ if (grub_strcmp (args[*argn], "-a") == 0)
+ {
+ (*argn)++;
+ continue;
+ }
+ if (grub_strcmp (args[*argn], "-o") == 0)
+ {
+ ctx.or = ctx.or || ctx.and;
+ ctx.and = 1;
+ (*argn)++;
+ continue;
+ }
+
+ /* No test found. Interpret if as just a string. */
+ update_val (args[*argn][0], &ctx);
+ (*argn)++;
+ }
+ return ctx.or || ctx.and;
+}
+
+static grub_err_t
+grub_cmd_test (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ int argn = 0;
+
+ if (argc >= 1 && grub_strcmp (args[argc - 1], "]") == 0)
+ argc--;
+
+ return test_parse (args, &argn, argc) ? GRUB_ERR_NONE
+ : grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
+}
+
+static grub_command_t cmd_1, cmd_2;
+
+GRUB_MOD_INIT(test)
+{
+ cmd_1 = grub_register_command ("[", grub_cmd_test,
+ N_("EXPRESSION ]"), N_("Evaluate an expression."));
+ cmd_1->flags |= GRUB_COMMAND_FLAG_EXTRACTOR;
+ cmd_2 = grub_register_command ("test", grub_cmd_test,
+ N_("EXPRESSION"), N_("Evaluate an expression."));
+ cmd_2->flags |= GRUB_COMMAND_FLAG_EXTRACTOR;
+}
+
+GRUB_MOD_FINI(test)
+{
+ grub_unregister_command (cmd_1);
+ grub_unregister_command (cmd_2);
+}
diff --git a/grub-core/commands/testload.c b/grub-core/commands/testload.c
new file mode 100644
index 0000000..ff01a05
--- /dev/null
+++ b/grub-core/commands/testload.c
@@ -0,0 +1,170 @@
+/* testload.c - load the same file in multiple ways */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2006,2007,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/term.h>
+#include <grub/loader.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Helper for grub_cmd_testload. */
+static void
+read_progress (grub_disk_addr_t sector __attribute__ ((unused)),
+ unsigned offset __attribute__ ((unused)),
+ unsigned len,
+ void *data __attribute__ ((unused)))
+{
+ for (; len >= GRUB_DISK_SECTOR_SIZE; len -= GRUB_DISK_SECTOR_SIZE)
+ grub_xputs (".");
+ if (len)
+ grub_xputs (".");
+ grub_refresh ();
+}
+
+static grub_err_t
+grub_cmd_testload (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file;
+ char *buf;
+ grub_size_t size;
+ grub_off_t pos;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_TESTLOAD);
+ if (! file)
+ return grub_errno;
+
+ size = grub_file_size (file) & ~(GRUB_DISK_SECTOR_SIZE - 1);
+ if (size == 0)
+ {
+ grub_file_close (file);
+ return GRUB_ERR_NONE;
+ }
+
+ buf = grub_malloc (size);
+ if (! buf)
+ goto fail;
+
+ grub_printf ("Reading %s sequentially", argv[0]);
+ file->read_hook = read_progress;
+ if (grub_file_read (file, buf, size) != (grub_ssize_t) size)
+ goto fail;
+ grub_printf (" Done.\n");
+
+ /* Read sequentially again. */
+ grub_printf ("Reading %s sequentially again", argv[0]);
+ grub_file_seek (file, 0);
+
+ for (pos = 0; pos < size;)
+ {
+ char sector[GRUB_DISK_SECTOR_SIZE];
+ grub_size_t curlen = GRUB_DISK_SECTOR_SIZE;
+
+ if (curlen > size - pos)
+ curlen = size - pos;
+
+ if (grub_file_read (file, sector, curlen)
+ != (grub_ssize_t) curlen)
+ goto fail;
+
+ if (grub_memcmp (sector, buf + pos, curlen) != 0)
+ {
+ grub_printf ("\nDiffers in %lld\n", (unsigned long long) pos);
+ goto fail;
+ }
+ pos += curlen;
+ }
+ grub_printf (" Done.\n");
+
+ /* Read backwards and compare. */
+ grub_printf ("Reading %s backwards", argv[0]);
+ pos = size;
+ while (pos > 0)
+ {
+ char sector[GRUB_DISK_SECTOR_SIZE];
+
+ if (pos >= GRUB_DISK_SECTOR_SIZE)
+ pos -= GRUB_DISK_SECTOR_SIZE;
+ else
+ pos = 0;
+
+ grub_file_seek (file, pos);
+
+ if (grub_file_read (file, sector, GRUB_DISK_SECTOR_SIZE)
+ != GRUB_DISK_SECTOR_SIZE)
+ goto fail;
+
+ if (grub_memcmp (sector, buf + pos, GRUB_DISK_SECTOR_SIZE) != 0)
+ {
+ int i;
+
+ grub_printf ("\nDiffers in %lld\n", (unsigned long long) pos);
+
+ for (i = 0; i < GRUB_DISK_SECTOR_SIZE; i++)
+ {
+ grub_printf ("%02x ", buf[pos + i]);
+ if ((i & 15) == 15)
+ grub_printf ("\n");
+ }
+
+ if (i)
+ grub_refresh ();
+
+ goto fail;
+ }
+ }
+ grub_printf (" Done.\n");
+
+ return GRUB_ERR_NONE;
+
+ fail:
+
+ grub_file_close (file);
+ grub_free (buf);
+
+ if (!grub_errno)
+ grub_error (GRUB_ERR_IO, "bad read");
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(testload)
+{
+ cmd =
+ grub_register_command ("testload", grub_cmd_testload,
+ N_("FILE"),
+ N_("Load the same file in multiple ways."));
+}
+
+GRUB_MOD_FINI(testload)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/testspeed.c b/grub-core/commands/testspeed.c
new file mode 100644
index 0000000..c13a9b8
--- /dev/null
+++ b/grub-core/commands/testspeed.c
@@ -0,0 +1,115 @@
+/* testspeed.c - Command to test file read speed */
+/*
+ * 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/mm.h>
+#include <grub/file.h>
+#include <grub/time.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/normal.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define DEFAULT_BLOCK_SIZE 65536
+
+static const struct grub_arg_option options[] =
+ {
+ {"size", 's', 0, N_("Specify size for each read operation"), 0, ARG_TYPE_INT},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+grub_cmd_testspeed (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ grub_uint64_t start;
+ grub_uint64_t end;
+ grub_ssize_t block_size;
+ grub_disk_addr_t total_size;
+ char *buffer;
+ grub_file_t file;
+ grub_uint64_t whole, fraction;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ block_size = (state[0].set) ?
+ grub_strtoul (state[0].arg, 0, 0) : DEFAULT_BLOCK_SIZE;
+
+ if (block_size <= 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid block size"));
+
+ buffer = grub_malloc (block_size);
+ if (buffer == NULL)
+ return grub_errno;
+
+ file = grub_file_open (args[0], GRUB_FILE_TYPE_TESTLOAD);
+ if (file == NULL)
+ goto quit;
+
+ total_size = 0;
+ start = grub_get_time_ms ();
+ while (1)
+ {
+ grub_ssize_t size = grub_file_read (file, buffer, block_size);
+ if (size <= 0)
+ break;
+ total_size += size;
+ }
+ end = grub_get_time_ms ();
+ grub_file_close (file);
+
+ grub_printf_ (N_("File size: %s\n"),
+ grub_get_human_size (total_size, GRUB_HUMAN_SIZE_NORMAL));
+ whole = grub_divmod64 (end - start, 1000, &fraction);
+ grub_printf_ (N_("Elapsed time: %d.%03d s \n"),
+ (unsigned) whole,
+ (unsigned) fraction);
+
+ if (end != start)
+ {
+ grub_uint64_t speed =
+ grub_divmod64 (total_size * 100ULL * 1000ULL, end - start, 0);
+
+ grub_printf_ (N_("Speed: %s \n"),
+ grub_get_human_size (speed,
+ GRUB_HUMAN_SIZE_SPEED));
+ }
+
+ quit:
+ grub_free (buffer);
+
+ return grub_errno;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(testspeed)
+{
+ cmd = grub_register_extcmd ("testspeed", grub_cmd_testspeed, 0, N_("[-s SIZE] FILENAME"),
+ N_("Test file read speed."),
+ options);
+}
+
+GRUB_MOD_FINI(testspeed)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/time.c b/grub-core/commands/time.c
new file mode 100644
index 0000000..40d496e
--- /dev/null
+++ b/grub-core/commands/time.c
@@ -0,0 +1,68 @@
+/* echo.c - Command to display a line of text */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/time.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+
+static grub_err_t
+grub_cmd_time (grub_command_t ctxt __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_command_t cmd;
+ grub_uint32_t start;
+ grub_uint32_t end;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no command is specified"));
+
+ cmd = grub_command_find (args[0]);
+
+ if (!cmd)
+ return grub_error (GRUB_ERR_UNKNOWN_COMMAND, N_("can't find command `%s'"),
+ args[0]);
+
+ start = grub_get_time_ms ();
+ (cmd->func) (cmd, argc - 1, &args[1]);
+ end = grub_get_time_ms ();
+
+ grub_printf_ (N_("Elapsed time: %d.%03d seconds \n"), (end - start) / 1000,
+ (end - start) % 1000);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(time)
+{
+ cmd = grub_register_command ("time", grub_cmd_time,
+ N_("COMMAND [ARGS]"),
+ N_("Measure time used by COMMAND"));
+}
+
+GRUB_MOD_FINI(time)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c
new file mode 100644
index 0000000..2052c36
--- /dev/null
+++ b/grub-core/commands/tpm.c
@@ -0,0 +1,95 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Core TPM support code.
+ */
+
+#include <grub/err.h>
+#include <grub/i18n.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/tpm.h>
+#include <grub/term.h>
+#include <grub/verify.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_tpm_verify_init (grub_file_t io,
+ enum grub_file_type type __attribute__ ((unused)),
+ void **context, enum grub_verify_flags *flags)
+{
+ *context = io->name;
+ *flags |= GRUB_VERIFY_FLAGS_SINGLE_CHUNK;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_tpm_verify_write (void *context, void *buf, grub_size_t size)
+{
+ return grub_tpm_measure (buf, size, GRUB_BINARY_PCR, context);
+}
+
+static grub_err_t
+grub_tpm_verify_string (char *str, enum grub_verify_string_type type)
+{
+ const char *prefix = NULL;
+ char *description;
+ grub_err_t status;
+
+ switch (type)
+ {
+ case GRUB_VERIFY_KERNEL_CMDLINE:
+ prefix = "kernel_cmdline: ";
+ break;
+ case GRUB_VERIFY_MODULE_CMDLINE:
+ prefix = "module_cmdline: ";
+ break;
+ case GRUB_VERIFY_COMMAND:
+ prefix = "grub_cmd: ";
+ break;
+ }
+ description = grub_malloc (grub_strlen (str) + grub_strlen (prefix) + 1);
+ if (!description)
+ return grub_errno;
+ grub_memcpy (description, prefix, grub_strlen (prefix));
+ grub_memcpy (description + grub_strlen (prefix), str,
+ grub_strlen (str) + 1);
+ status =
+ grub_tpm_measure ((unsigned char *) str, grub_strlen (str),
+ GRUB_STRING_PCR, description);
+ grub_free (description);
+ return status;
+}
+
+struct grub_file_verifier grub_tpm_verifier = {
+ .name = "tpm",
+ .init = grub_tpm_verify_init,
+ .write = grub_tpm_verify_write,
+ .verify_string = grub_tpm_verify_string,
+};
+
+GRUB_MOD_INIT (tpm)
+{
+ grub_verifier_register (&grub_tpm_verifier);
+}
+
+GRUB_MOD_FINI (tpm)
+{
+ grub_verifier_unregister (&grub_tpm_verifier);
+}
diff --git a/grub-core/commands/tr.c b/grub-core/commands/tr.c
new file mode 100644
index 0000000..ef72841
--- /dev/null
+++ b/grub-core/commands/tr.c
@@ -0,0 +1,126 @@
+/* tr.c -- The tr command. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,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/dl.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/env.h>
+#include <grub/i18n.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const struct grub_arg_option options[] =
+ {
+ { "set", 's', 0, N_("Set a variable to return value."), N_("VARNAME"), ARG_TYPE_STRING },
+ { "upcase", 'U', 0, N_("Translate to upper case."), 0, 0 },
+ { "downcase", 'D', 0, N_("Translate to lower case."), 0, 0 },
+ { 0, 0, 0, 0, 0, 0 }
+ };
+
+static const char *letters_lowercase = "abcdefghijklmnopqrstuvwxyz";
+static const char *letters_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+static grub_err_t
+grub_cmd_tr (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ char *var = 0;
+ const char *input = 0;
+ char *output = 0, *optr;
+ const char *s1 = 0;
+ const char *s2 = 0;
+ const char *iptr;
+
+ /* Select the defaults from options. */
+ if (ctxt->state[0].set) {
+ var = ctxt->state[0].arg;
+ input = grub_env_get (var);
+ }
+
+ if (ctxt->state[1].set) {
+ s1 = letters_lowercase;
+ s2 = letters_uppercase;
+ }
+
+ if (ctxt->state[2].set) {
+ s1 = letters_uppercase;
+ s2 = letters_lowercase;
+ }
+
+ /* Check for arguments and update the defaults. */
+ if (argc == 1)
+ input = args[0];
+
+ else if (argc == 2) {
+ s1 = args[0];
+ s2 = args[1];
+
+ } else if (argc == 3) {
+ s1 = args[0];
+ s2 = args[1];
+ input = args[2];
+
+ } else if (argc > 3)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many parameters");
+
+ if (!s1 || !s2 || !input)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing parameters");
+
+ if (grub_strlen (s1) != grub_strlen (s2))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "set sizes did not match");
+
+ /* Translate input into output buffer. */
+
+ output = grub_malloc (grub_strlen (input) + 1);
+ if (! output)
+ return grub_errno;
+
+ optr = output;
+ for (iptr = input; *iptr; iptr++)
+ {
+ char *p = grub_strchr (s1, *iptr);
+ if (p)
+ *optr++ = s2[p - s1];
+ else
+ *optr++ = *iptr;
+ }
+ *optr = '\0';
+
+ if (ctxt->state[0].set)
+ grub_env_set (var, output);
+ else
+ grub_printf ("%s\n", output);
+
+ grub_free (output);
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(tr)
+{
+ cmd = grub_register_extcmd ("tr", grub_cmd_tr, 0, N_("[OPTIONS] [SET1] [SET2] [STRING]"),
+ N_("Translate SET1 characters to SET2 in STRING."), options);
+}
+
+GRUB_MOD_FINI(tr)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/commands/true.c b/grub-core/commands/true.c
new file mode 100644
index 0000000..8cbba65
--- /dev/null
+++ b/grub-core/commands/true.c
@@ -0,0 +1,61 @@
+/* true.c - true and false commands. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_true (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_false (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ return grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
+}
+
+static grub_command_t cmd_true, cmd_false;
+
+
+GRUB_MOD_INIT(true)
+{
+ cmd_true =
+ grub_register_command ("true", grub_cmd_true,
+ /* TRANSLATORS: it's a command description. */
+ 0, N_("Do nothing, successfully."));
+ cmd_false =
+ grub_register_command ("false", grub_cmd_false,
+ /* TRANSLATORS: it's a command description. */
+ 0, N_("Do nothing, unsuccessfully."));
+}
+
+GRUB_MOD_FINI(true)
+{
+ grub_unregister_command (cmd_true);
+ grub_unregister_command (cmd_false);
+}
diff --git a/grub-core/commands/usbtest.c b/grub-core/commands/usbtest.c
new file mode 100644
index 0000000..2c6d93f
--- /dev/null
+++ b/grub-core/commands/usbtest.c
@@ -0,0 +1,227 @@
+/* usbtest.c - test module for USB */
+/*
+ * 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/misc.h>
+#include <grub/charset.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/usb.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const char *usb_classes[] =
+ {
+ "Unknown",
+ "Audio",
+ "Communication Interface",
+ "HID",
+ "Unknown",
+ "Physical",
+ "Image",
+ "Printer",
+ "Mass Storage",
+ "Hub",
+ "Data Interface",
+ "Smart Card",
+ "Content Security",
+ "Video"
+ };
+
+static const char *usb_endp_type[] =
+ {
+ "Control",
+ "Isochronous",
+ "Bulk",
+ "Interrupt"
+ };
+
+static const char *usb_devspeed[] =
+ {
+ "",
+ "Low",
+ "Full",
+ "High"
+ };
+
+#if __GNUC__ >= 9
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
+static grub_usb_err_t
+grub_usb_get_string (grub_usb_device_t dev, grub_uint8_t index, int langid,
+ char **string)
+{
+ struct grub_usb_desc_str descstr;
+ struct grub_usb_desc_str *descstrp;
+ grub_usb_err_t err;
+
+ /* Only get the length. */
+ err = grub_usb_control_msg (dev, 1 << 7,
+ 0x06, (3 << 8) | index,
+ langid, 1, (char *) &descstr);
+ if (err)
+ return err;
+
+ descstrp = grub_malloc (descstr.length);
+ if (! descstrp)
+ return GRUB_USB_ERR_INTERNAL;
+ err = grub_usb_control_msg (dev, 1 << 7,
+ 0x06, (3 << 8) | index,
+ langid, descstr.length, (char *) descstrp);
+
+ if (descstrp->length == 0)
+ {
+ grub_free (descstrp);
+ *string = grub_strdup ("");
+ if (! *string)
+ return GRUB_USB_ERR_INTERNAL;
+ return GRUB_USB_ERR_NONE;
+ }
+
+ *string = grub_malloc (descstr.length * 2 + 1);
+ if (! *string)
+ {
+ grub_free (descstrp);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
+ *grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str,
+ descstrp->length / 2 - 1) = 0;
+ grub_free (descstrp);
+
+ return GRUB_USB_ERR_NONE;
+}
+
+#if __GNUC__ >= 9
+#pragma GCC diagnostic pop
+#endif
+
+static void
+usb_print_str (const char *description, grub_usb_device_t dev, int idx)
+{
+ char *name = NULL;
+ grub_usb_err_t err;
+ /* XXX: LANGID */
+
+ if (! idx)
+ return;
+
+ err = grub_usb_get_string (dev, idx, 0x0409, &name);
+ if (err)
+ grub_printf ("Error %d retrieving %s\n", err, description);
+ else
+ {
+ grub_printf ("%s: `%s'\n", description, name);
+ grub_free (name);
+ }
+}
+
+static int
+usb_iterate (grub_usb_device_t dev, void *data __attribute__ ((unused)))
+{
+ struct grub_usb_desc_device *descdev;
+ int i;
+
+ descdev = &dev->descdev;
+
+ usb_print_str ("Product", dev, descdev->strprod);
+ usb_print_str ("Vendor", dev, descdev->strvendor);
+ usb_print_str ("Serial", dev, descdev->strserial);
+
+ grub_printf ("Class: (0x%02x) %s, Subclass: 0x%02x, Protocol: 0x%02x\n",
+ descdev->class, descdev->class < ARRAY_SIZE (usb_classes)
+ ? usb_classes[descdev->class] : "Unknown",
+ descdev->subclass, descdev->protocol);
+ grub_printf ("USB version %d.%d, VendorID: 0x%02x, ProductID: 0x%02x, #conf: %d\n",
+ descdev->usbrel >> 8, (descdev->usbrel >> 4) & 0x0F,
+ descdev->vendorid, descdev->prodid, descdev->configcnt);
+
+ grub_printf ("%s speed device\n", usb_devspeed[dev->speed]);
+
+ for (i = 0; i < descdev->configcnt; i++)
+ {
+ struct grub_usb_desc_config *config;
+
+ config = dev->config[i].descconf;
+ usb_print_str ("Configuration:", dev, config->strconfig);
+ }
+
+ for (i = 0; i < dev->config[0].descconf->numif; i++)
+ {
+ int j;
+ struct grub_usb_desc_if *interf;
+ interf = dev->config[0].interf[i].descif;
+
+ grub_printf ("Interface #%d: #Endpoints: %d ",
+ i, interf->endpointcnt);
+ grub_printf ("Class: (0x%02x) %s, Subclass: 0x%02x, Protocol: 0x%02x\n",
+ interf->class, interf->class < ARRAY_SIZE (usb_classes)
+ ? usb_classes[interf->class] : "Unknown",
+ interf->subclass, interf->protocol);
+
+ usb_print_str ("Interface", dev, interf->strif);
+
+ for (j = 0; j < interf->endpointcnt; j++)
+ {
+ struct grub_usb_desc_endp *endp;
+ endp = &dev->config[0].interf[i].descendp[j];
+
+ grub_printf ("Endpoint #%d: %s, max packed size: %d, transfer type: %s, latency: %d\n",
+ endp->endp_addr & 15,
+ (endp->endp_addr & 128) ? "IN" : "OUT",
+ endp->maxpacket, usb_endp_type[endp->attrib & 3],
+ endp->interval);
+ }
+ }
+
+ grub_printf("\n");
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_usbtest (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_usb_poll_devices (1);
+
+ grub_printf ("USB devices:\n\n");
+ grub_usb_iterate (usb_iterate, NULL);
+
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(usbtest)
+{
+ cmd = grub_register_command ("usb", grub_cmd_usbtest,
+ 0, N_("Test USB support."));
+}
+
+GRUB_MOD_FINI(usbtest)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/commands/videoinfo.c b/grub-core/commands/videoinfo.c
new file mode 100644
index 0000000..016a4d8
--- /dev/null
+++ b/grub-core/commands/videoinfo.c
@@ -0,0 +1,262 @@
+/* videoinfo.c - command to list video modes. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/video.h>
+#include <grub/dl.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct hook_ctx
+{
+ unsigned height, width, depth;
+ struct grub_video_mode_info *current_mode;
+};
+
+static int
+hook (const struct grub_video_mode_info *info, void *hook_arg)
+{
+ struct hook_ctx *ctx = hook_arg;
+
+ if (ctx->height && ctx->width && (info->width != ctx->width || info->height != ctx->height))
+ return 0;
+
+ if (ctx->depth && info->bpp != ctx->depth)
+ return 0;
+
+ if (info->mode_number == GRUB_VIDEO_MODE_NUMBER_INVALID)
+ grub_printf (" ");
+ else
+ {
+ if (ctx->current_mode && info->mode_number == ctx->current_mode->mode_number)
+ grub_printf ("*");
+ else
+ grub_printf (" ");
+ grub_printf (" 0x%03x ", info->mode_number);
+ }
+ grub_printf ("%4d x %4d x %2d (%4d) ", info->width, info->height, info->bpp,
+ info->pitch);
+
+ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PURE_TEXT)
+ grub_xputs (_("Text-only "));
+ /* Show mask and position details for direct color modes. */
+ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_RGB)
+ /* TRANSLATORS: "Direct color" is a mode when the color components
+ are written dirrectly into memory. */
+ grub_printf_ (N_("Direct color, mask: %d/%d/%d/%d pos: %d/%d/%d/%d"),
+ info->red_mask_size,
+ info->green_mask_size,
+ info->blue_mask_size,
+ info->reserved_mask_size,
+ info->red_field_pos,
+ info->green_field_pos,
+ info->blue_field_pos,
+ info->reserved_field_pos);
+ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
+ /* TRANSLATORS: In "paletted color" mode you write the index of the color
+ in the palette. Synonyms include "packed pixel". */
+ grub_xputs (_("Paletted "));
+ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_YUV)
+ grub_xputs (_("YUV "));
+ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PLANAR)
+ /* TRANSLATORS: "Planar" is the video memory where you have to write
+ in several different banks "plans" to control the different color
+ components of the same pixel. */
+ grub_xputs (_("Planar "));
+ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_HERCULES)
+ grub_xputs (_("Hercules "));
+ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_CGA)
+ grub_xputs (_("CGA "));
+ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_NONCHAIN4)
+ /* TRANSLATORS: Non-chain 4 is a 256-color planar
+ (unchained) video memory mode. */
+ grub_xputs (_("Non-chain 4 "));
+ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP)
+ grub_xputs (_("Monochrome "));
+ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_UNKNOWN)
+ grub_xputs (_("Unknown video mode "));
+
+ grub_xputs ("\n");
+
+ return 0;
+}
+
+static void
+print_edid (struct grub_video_edid_info *edid_info)
+{
+ unsigned int edid_width, edid_height;
+
+ if (grub_video_edid_checksum (edid_info))
+ {
+ grub_puts_ (N_(" EDID checksum invalid"));
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ grub_printf_ (N_(" EDID version: %u.%u\n"),
+ edid_info->version, edid_info->revision);
+ if (grub_video_edid_preferred_mode (edid_info, &edid_width, &edid_height)
+ == GRUB_ERR_NONE)
+ grub_printf_ (N_(" Preferred mode: %ux%u\n"), edid_width, edid_height);
+ else
+ {
+ grub_printf_ (N_(" No preferred mode available\n"));
+ grub_errno = GRUB_ERR_NONE;
+ }
+}
+
+static grub_err_t
+grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_video_adapter_t adapter;
+ grub_video_driver_id_t id;
+ struct hook_ctx ctx;
+
+ ctx.height = ctx.width = ctx.depth = 0;
+ if (argc)
+ {
+ const char *ptr;
+ ptr = args[0];
+ ctx.width = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ return grub_errno;
+ if (*ptr != 'x')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid video mode specification `%s'"),
+ args[0]);
+ ptr++;
+ ctx.height = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ return grub_errno;
+ if (*ptr == 'x')
+ {
+ ptr++;
+ ctx.depth = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ return grub_errno;
+ }
+ }
+
+#ifdef GRUB_MACHINE_PCBIOS
+ if (grub_strcmp (cmd->name, "vbeinfo") == 0)
+ grub_dl_load ("vbe");
+#endif
+
+ id = grub_video_get_driver_id ();
+
+ grub_puts_ (N_("List of supported video modes:"));
+ grub_puts_ (N_("Legend: mask/position=red/green/blue/reserved"));
+
+ FOR_VIDEO_ADAPTERS (adapter)
+ {
+ struct grub_video_mode_info info;
+ struct grub_video_edid_info edid_info;
+
+ grub_printf_ (N_("Adapter `%s':\n"), adapter->name);
+
+ if (!adapter->iterate)
+ {
+ grub_puts_ (N_(" No info available"));
+ continue;
+ }
+
+ ctx.current_mode = NULL;
+
+ if (adapter->id == id)
+ {
+ if (grub_video_get_info (&info) == GRUB_ERR_NONE)
+ ctx.current_mode = &info;
+ else
+ /* Don't worry about errors. */
+ grub_errno = GRUB_ERR_NONE;
+ }
+ else
+ {
+ if (adapter->init ())
+ {
+ grub_puts_ (N_(" Failed to initialize video adapter"));
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ }
+
+ if (adapter->print_adapter_specific_info)
+ adapter->print_adapter_specific_info ();
+
+ adapter->iterate (hook, &ctx);
+
+ if (adapter->get_edid && adapter->get_edid (&edid_info) == GRUB_ERR_NONE)
+ print_edid (&edid_info);
+ else
+ grub_errno = GRUB_ERR_NONE;
+
+ ctx.current_mode = NULL;
+
+ if (adapter->id != id)
+ {
+ if (adapter->fini ())
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ }
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd;
+#ifdef GRUB_MACHINE_PCBIOS
+static grub_command_t cmd_vbe;
+#endif
+
+GRUB_MOD_INIT(videoinfo)
+{
+ cmd = grub_register_command ("videoinfo", grub_cmd_videoinfo,
+ /* TRANSLATORS: "x" has to be entered in,
+ like an identifier, so please don't
+ use better Unicode codepoints. */
+ N_("[WxH[xD]]"),
+ N_("List available video modes. If "
+ "resolution is given show only modes"
+ " matching it."));
+#ifdef GRUB_MACHINE_PCBIOS
+ cmd_vbe = grub_register_command ("vbeinfo", grub_cmd_videoinfo,
+ /* TRANSLATORS: "x" has to be entered in,
+ like an identifier, so please don't
+ use better Unicode codepoints. */
+ N_("[WxH[xD]]"),
+ N_("List available video modes. If "
+ "resolution is given show only modes"
+ " matching it."));
+#endif
+}
+
+GRUB_MOD_FINI(videoinfo)
+{
+ grub_unregister_command (cmd);
+#ifdef GRUB_MACHINE_PCBIOS
+ grub_unregister_command (cmd_vbe);
+#endif
+}
+
diff --git a/grub-core/commands/videotest.c b/grub-core/commands/videotest.c
new file mode 100644
index 0000000..b6c181b
--- /dev/null
+++ b/grub-core/commands/videotest.c
@@ -0,0 +1,241 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/video.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/font.h>
+#include <grub/term.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/gfxmenu_view.h>
+#include <grub/env.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_err_t err;
+ grub_video_color_t color;
+ unsigned int x;
+ unsigned int y;
+ unsigned int width;
+ unsigned int height;
+ int i;
+ struct grub_video_render_target *text_layer;
+ grub_video_color_t palette[16];
+ const char *mode = NULL;
+
+#ifdef GRUB_MACHINE_PCBIOS
+ if (grub_strcmp (cmd->name, "vbetest") == 0)
+ grub_dl_load ("vbe");
+#endif
+ mode = grub_env_get ("gfxmode");
+ if (argc)
+ mode = args[0];
+ if (!mode)
+ mode = "auto";
+
+ err = grub_video_set_mode (mode, GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
+ if (err)
+ return err;
+
+ grub_video_get_viewport (&x, &y, &width, &height);
+
+ {
+ const char *str;
+ int texty;
+ grub_font_t sansbig;
+ grub_font_t sans;
+ grub_font_t sanssmall;
+ grub_font_t fixed;
+ struct grub_font_glyph *glyph;
+
+ if (grub_video_create_render_target (&text_layer, width, height,
+ GRUB_VIDEO_MODE_TYPE_RGB
+ | GRUB_VIDEO_MODE_TYPE_ALPHA)
+ || !text_layer)
+ goto fail;
+
+ grub_video_set_active_render_target (text_layer);
+
+ color = grub_video_map_rgb (0, 255, 255);
+ sansbig = grub_font_get ("Unknown Regular 16");
+ sans = grub_font_get ("Unknown Regular 16");
+ sanssmall = grub_font_get ("Unknown Regular 16");
+ fixed = grub_font_get ("Fixed 20");
+ if (! sansbig || ! sans || ! sanssmall || ! fixed)
+ return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
+
+ glyph = grub_font_get_glyph (fixed, '*');
+ grub_font_draw_glyph (glyph, color, 200 ,0);
+
+ color = grub_video_map_rgb (255, 255, 255);
+
+ texty = 32;
+ grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
+ sans, color, 16, texty);
+ texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
+
+ texty += grub_font_get_ascent (fixed);
+ grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
+ fixed, color, 16, texty);
+ texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
+
+ /* To convert Unicode characters into UTF-8 for this test, the following
+ command is useful:
+ echo -ne '\x00\x00\x26\x3A' | iconv -f UTF-32BE -t UTF-8 | od -t x1
+ This converts the Unicode character U+263A to UTF-8. */
+
+ /* Characters used:
+ Code point Description UTF-8 encoding
+ ----------- ------------------------------ --------------
+ U+263A unfilled smiley face E2 98 BA
+ U+00A1 inverted exclamation point C2 A1
+ U+00A3 British pound currency symbol C2 A3
+ U+03C4 Greek tau CF 84
+ U+00E4 lowercase letter a with umlaut C3 A4
+ U+2124 set 'Z' symbol (integers) E2 84 A4
+ U+2286 subset symbol E2 8A 86
+ U+211D set 'R' symbol (real numbers) E2 84 9D */
+
+ str =
+ "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";
+ color = grub_video_map_rgb (128, 128, 255);
+
+ /* All characters in the string exist in the 'Fixed 20' (10x20) font. */
+ texty += grub_font_get_ascent(fixed);
+ grub_font_draw_string (str, fixed, color, 16, texty);
+ texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
+
+ texty += grub_font_get_ascent(sansbig);
+ grub_font_draw_string (str, sansbig, color, 16, texty);
+ texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig);
+
+ texty += grub_font_get_ascent(sans);
+ grub_font_draw_string (str, sans, color, 16, texty);
+ texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
+
+ texty += grub_font_get_ascent(sanssmall);
+ grub_font_draw_string (str, sanssmall, color, 16, texty);
+ texty += (grub_font_get_descent (sanssmall)
+ + grub_font_get_leading (sanssmall));
+
+ glyph = grub_font_get_glyph (fixed, '*');
+
+ for (i = 0; i < 16; i++)
+ {
+ color = grub_video_map_color (i);
+ palette[i] = color;
+ grub_font_draw_glyph (glyph, color, 16 + i * 16, 220);
+ }
+ }
+
+ grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
+
+ for (i = 0; i < 5; i++)
+ {
+
+ if (i == 0 || i == 1)
+ {
+ color = grub_video_map_rgb (0, 0, 0);
+ grub_video_fill_rect (color, 0, 0, width, height);
+
+ color = grub_video_map_rgb (255, 0, 0);
+ grub_video_fill_rect (color, 0, 0, 100, 100);
+
+ color = grub_video_map_rgb (0, 255, 0);
+ grub_video_fill_rect (color, 100, 0, 100, 100);
+
+ color = grub_video_map_rgb (0, 0, 255);
+ grub_video_fill_rect (color, 200, 0, 100, 100);
+
+ color = grub_video_map_rgb (0, 255, 255);
+ grub_video_fill_rect (color, 0, 100, 100, 100);
+
+ color = grub_video_map_rgb (255, 0, 255);
+ grub_video_fill_rect (color, 100, 100, 100, 100);
+
+ color = grub_video_map_rgb (255, 255, 0);
+ grub_video_fill_rect (color, 200, 100, 100, 100);
+
+ grub_video_set_viewport (x + 150, y + 150,
+ width - 150 * 2, height - 150 * 2);
+ color = grub_video_map_rgb (77, 33, 77);
+ grub_video_fill_rect (color, 0, 0, width, height);
+ }
+
+ color = grub_video_map_rgb (i, 33, 77);
+ grub_video_fill_rect (color, 0, 0, width, height);
+ grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND, 0, 0,
+ 0, 0, width, height);
+ grub_video_swap_buffers ();
+ }
+
+ grub_getkey ();
+
+ grub_video_delete_render_target (text_layer);
+
+ grub_video_restore ();
+
+ for (i = 0; i < 16; i++)
+ grub_printf("color %d: %08x\n", i, palette[i]);
+
+ grub_errno = GRUB_ERR_NONE;
+ return grub_errno;
+
+ fail:
+ grub_video_delete_render_target (text_layer);
+ grub_video_restore ();
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+#ifdef GRUB_MACHINE_PCBIOS
+static grub_command_t cmd_vbe;
+#endif
+
+GRUB_MOD_INIT(videotest)
+{
+ cmd = grub_register_command ("videotest", grub_cmd_videotest,
+ /* TRANSLATORS: "x" has to be entered in,
+ like an identifier, so please don't
+ use better Unicode codepoints. */
+ N_("[WxH]"),
+ /* TRANSLATORS: Here, on the other hand, it's
+ nicer to use unicode cross instead of x. */
+ N_("Test video subsystem in mode WxH."));
+#ifdef GRUB_MACHINE_PCBIOS
+ cmd_vbe = grub_register_command ("vbetest", grub_cmd_videotest,
+ 0, N_("Test video subsystem."));
+#endif
+}
+
+GRUB_MOD_FINI(videotest)
+{
+ grub_unregister_command (cmd);
+#ifdef GRUB_MACHINE_PCBIOS
+ grub_unregister_command (cmd_vbe);
+#endif
+}
diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c
new file mode 100644
index 0000000..cc32903
--- /dev/null
+++ b/grub-core/commands/wildcard.c
@@ -0,0 +1,652 @@
+/* wildcard.c - Wildcard character expansion for GRUB script. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/fs.h>
+#include <grub/env.h>
+#include <grub/file.h>
+#include <grub/device.h>
+#include <grub/script_sh.h>
+#include <grub/safemath.h>
+
+#include <regex.h>
+
+static inline int isregexop (char ch);
+static char ** merge (char **lhs, char **rhs);
+static char *make_dir (const char *prefix, const char *start, const char *end);
+static int make_regex (const char *regex_start, const char *regex_end,
+ regex_t *regexp);
+static void split_path (const char *path, const char **suffix_end, const char **regex_end);
+static char ** match_devices (const regex_t *regexp, int noparts);
+static char ** match_files (const char *prefix, const char *suffix_start,
+ const char *suffix_end, const regex_t *regexp);
+
+static grub_err_t wildcard_expand (const char *s, char ***strs);
+
+struct grub_script_wildcard_translator grub_filename_translator = {
+ .expand = wildcard_expand,
+};
+
+static char **
+merge (char **dest, char **ps)
+{
+ int i;
+ int j;
+ char **p;
+ grub_size_t sz;
+
+ if (! dest)
+ return ps;
+
+ if (! ps)
+ return dest;
+
+ for (i = 0; dest[i]; i++)
+ ;
+ for (j = 0; ps[j]; j++)
+ ;
+
+ if (grub_add (i, j, &sz) ||
+ grub_add (sz, 1, &sz) ||
+ grub_mul (sz, sizeof (char *), &sz))
+ return dest;
+
+ p = grub_realloc (dest, sz);
+ if (! p)
+ {
+ grub_free (dest);
+ grub_free (ps);
+ return 0;
+ }
+
+ dest = p;
+ for (j = 0; ps[j]; j++)
+ dest[i++] = ps[j];
+ dest[i] = 0;
+
+ grub_free (ps);
+ return dest;
+}
+
+static inline int
+isregexop (char ch)
+{
+ return grub_strchr ("*.\\|+{}[]?", ch) ? 1 : 0;
+}
+
+static char *
+make_dir (const char *prefix, const char *start, const char *end)
+{
+ char ch;
+ unsigned i;
+ unsigned n;
+ char *result;
+
+ i = grub_strlen (prefix);
+ n = i + end - start;
+
+ result = grub_malloc (n + 1);
+ if (! result)
+ return 0;
+
+ grub_strcpy (result, prefix);
+ while (start < end && (ch = *start++))
+ if (ch == '\\' && isregexop (*start))
+ result[i++] = *start++;
+ else
+ result[i++] = ch;
+
+ result[i] = '\0';
+ return result;
+}
+
+static int
+make_regex (const char *start, const char *end, regex_t *regexp)
+{
+ char ch;
+ int i = 0;
+ unsigned len = end - start;
+ char *buffer;
+ grub_size_t sz;
+
+ /* Worst case size is (len * 2 + 2 + 1). */
+ if (grub_mul (len, 2, &sz) ||
+ grub_add (sz, 3, &sz))
+ return 1;
+
+ buffer = grub_malloc (sz);
+ if (! buffer)
+ return 1;
+
+ buffer[i++] = '^';
+ while (start < end)
+ {
+ /* XXX Only * and ? expansion for now. */
+ switch ((ch = *start++))
+ {
+ case '\\':
+ buffer[i++] = ch;
+ if (*start != '\0')
+ buffer[i++] = *start++;
+ break;
+
+ case '.':
+ case '(':
+ case ')':
+ case '@':
+ case '+':
+ case '|':
+ case '{':
+ case '}':
+ case '[':
+ case ']':
+ buffer[i++] = '\\';
+ buffer[i++] = ch;
+ break;
+
+ case '*':
+ buffer[i++] = '.';
+ buffer[i++] = '*';
+ break;
+
+ case '?':
+ buffer[i++] = '.';
+ break;
+
+ default:
+ buffer[i++] = ch;
+ }
+ }
+ buffer[i++] = '$';
+ buffer[i] = '\0';
+ grub_dprintf ("expand", "Regexp is %s\n", buffer);
+
+ if (regcomp (regexp, buffer, RE_SYNTAX_GNU_AWK))
+ {
+ grub_free (buffer);
+ return 1;
+ }
+
+ grub_free (buffer);
+ return 0;
+}
+
+/* Split `str' into two parts: (1) dirname that is regexop free (2)
+ dirname that has a regexop. */
+static void
+split_path (const char *str, const char **noregexop, const char **regexop)
+{
+ char ch = 0;
+ int regex = 0;
+
+ const char *end;
+ const char *split; /* points till the end of dirnaname that doesn't
+ need expansion. */
+
+ split = end = str;
+ while ((ch = *end))
+ {
+ if (ch == '\\' && end[1])
+ end++;
+
+ else if (ch == '*' || ch == '?')
+ regex = 1;
+
+ else if (ch == '/' && ! regex)
+ split = end + 1; /* forward to next regexop-free dirname */
+
+ else if (ch == '/' && regex)
+ break; /* stop at the first dirname with a regexop */
+
+ end++;
+ }
+
+ *regexop = end;
+ if (! regex)
+ *noregexop = end;
+ else
+ *noregexop = split;
+}
+
+/* Context for match_devices. */
+struct match_devices_ctx
+{
+ const regex_t *regexp;
+ int noparts;
+ int ndev;
+ char **devs;
+};
+
+/* Helper for match_devices. */
+static int
+match_devices_iter (const char *name, void *data)
+{
+ struct match_devices_ctx *ctx = data;
+ char **t;
+ char *buffer;
+ grub_size_t sz;
+
+ /* skip partitions if asked to. */
+ if (ctx->noparts && grub_strchr (name, ','))
+ return 0;
+
+ buffer = grub_xasprintf ("(%s)", name);
+ if (! buffer)
+ return 1;
+
+ grub_dprintf ("expand", "matching: %s\n", buffer);
+ if (regexec (ctx->regexp, buffer, 0, 0, 0))
+ {
+ grub_dprintf ("expand", "not matched\n");
+ fail:
+ grub_free (buffer);
+ return 0;
+ }
+
+ if (grub_add (ctx->ndev, 2, &sz) ||
+ grub_mul (sz, sizeof (char *), &sz))
+ goto fail;
+
+ t = grub_realloc (ctx->devs, sz);
+ if (! t)
+ {
+ grub_free (buffer);
+ return 1;
+ }
+
+ ctx->devs = t;
+ ctx->devs[ctx->ndev++] = buffer;
+ ctx->devs[ctx->ndev] = 0;
+ return 0;
+}
+
+static char **
+match_devices (const regex_t *regexp, int noparts)
+{
+ struct match_devices_ctx ctx = {
+ .regexp = regexp,
+ .noparts = noparts,
+ .ndev = 0,
+ .devs = 0
+ };
+ int i;
+
+ if (grub_device_iterate (match_devices_iter, &ctx))
+ goto fail;
+
+ return ctx.devs;
+
+ fail:
+
+ for (i = 0; ctx.devs && ctx.devs[i]; i++)
+ grub_free (ctx.devs[i]);
+
+ grub_free (ctx.devs);
+
+ return 0;
+}
+
+/* Context for match_files. */
+struct match_files_ctx
+{
+ const regex_t *regexp;
+ char **files;
+ unsigned nfile;
+ char *dir;
+};
+
+/* Helper for match_files. */
+static int
+match_files_iter (const char *name,
+ const struct grub_dirhook_info *info __attribute__((unused)),
+ void *data)
+{
+ struct match_files_ctx *ctx = data;
+ char **t;
+ char *buffer;
+ grub_size_t sz;
+
+ /* skip . and .. names */
+ if (grub_strcmp(".", name) == 0 || grub_strcmp("..", name) == 0)
+ return 0;
+
+ grub_dprintf ("expand", "matching: %s in %s\n", name, ctx->dir);
+ if (regexec (ctx->regexp, name, 0, 0, 0))
+ return 0;
+
+ grub_dprintf ("expand", "matched\n");
+
+ buffer = grub_xasprintf ("%s%s", ctx->dir, name);
+ if (! buffer)
+ return 1;
+
+ if (grub_add (ctx->nfile, 2, &sz) ||
+ grub_mul (sz, sizeof (char *), &sz))
+ goto fail;
+
+ t = grub_realloc (ctx->files, sz);
+ if (!t)
+ {
+ fail:
+ grub_free (buffer);
+ return 1;
+ }
+
+ ctx->files = t;
+ ctx->files[ctx->nfile++] = buffer;
+ ctx->files[ctx->nfile] = 0;
+ return 0;
+}
+
+static char **
+match_files (const char *prefix, const char *suffix, const char *end,
+ const regex_t *regexp)
+{
+ struct match_files_ctx ctx = {
+ .regexp = regexp,
+ .nfile = 0,
+ .files = 0
+ };
+ int i;
+ const char *path;
+ char *device_name;
+ grub_fs_t fs;
+ grub_device_t dev;
+
+ dev = 0;
+ device_name = 0;
+ grub_error_push ();
+
+ ctx.dir = make_dir (prefix, suffix, end);
+ if (! ctx.dir)
+ goto fail;
+
+ device_name = grub_file_get_device_name (ctx.dir);
+ dev = grub_device_open (device_name);
+ if (! dev)
+ goto fail;
+
+ fs = grub_fs_probe (dev);
+ if (! fs)
+ goto fail;
+
+ if (ctx.dir[0] == '(')
+ {
+ path = grub_strchr (ctx.dir, ')');
+ if (!path)
+ goto fail;
+ path++;
+ }
+ else
+ path = ctx.dir;
+
+ if (fs->fs_dir (dev, path, match_files_iter, &ctx))
+ goto fail;
+
+ grub_free (ctx.dir);
+ grub_device_close (dev);
+ grub_free (device_name);
+ grub_error_pop ();
+ return ctx.files;
+
+ fail:
+
+ grub_free (ctx.dir);
+
+ for (i = 0; ctx.files && ctx.files[i]; i++)
+ grub_free (ctx.files[i]);
+
+ grub_free (ctx.files);
+
+ if (dev)
+ grub_device_close (dev);
+
+ grub_free (device_name);
+
+ grub_error_pop ();
+ return 0;
+}
+
+/* Context for check_file. */
+struct check_file_ctx
+{
+ const char *basename;
+ int found;
+};
+
+/* Helper for check_file. */
+static int
+check_file_iter (const char *name, const struct grub_dirhook_info *info,
+ void *data)
+{
+ struct check_file_ctx *ctx = data;
+
+ if (ctx->basename[0] == 0
+ || (info->case_insensitive ? grub_strcasecmp (name, ctx->basename) == 0
+ : grub_strcmp (name, ctx->basename) == 0))
+ {
+ ctx->found = 1;
+ return 1;
+ }
+
+ return 0;
+}
+
+static int
+check_file (const char *dir, const char *basename)
+{
+ struct check_file_ctx ctx = {
+ .basename = basename,
+ .found = 0
+ };
+ grub_fs_t fs;
+ grub_device_t dev;
+ const char *device_name, *path;
+
+ device_name = grub_file_get_device_name (dir);
+ dev = grub_device_open (device_name);
+ if (! dev)
+ goto fail;
+
+ fs = grub_fs_probe (dev);
+ if (! fs)
+ goto fail;
+
+ if (dir[0] == '(')
+ {
+ path = grub_strchr (dir, ')');
+ if (!path)
+ goto fail;
+ path++;
+ }
+ else
+ path = dir;
+
+ fs->fs_dir (dev, path[0] ? path : "/", check_file_iter, &ctx);
+ if (grub_errno == 0 && basename[0] == 0)
+ ctx.found = 1;
+
+ fail:
+ grub_errno = 0;
+
+ return ctx.found;
+}
+
+static void
+unescape (char *out, const char *in, const char *end)
+{
+ char *optr;
+ const char *iptr;
+
+ for (optr = out, iptr = in; iptr < end;)
+ {
+ if (*iptr == '\\' && iptr + 1 < end)
+ {
+ *optr++ = iptr[1];
+ iptr += 2;
+ continue;
+ }
+ if (*iptr == '\\')
+ break;
+ *optr++ = *iptr++;
+ }
+ *optr = 0;
+}
+
+static grub_err_t
+wildcard_expand (const char *s, char ***strs)
+{
+ const char *start;
+ const char *regexop;
+ const char *noregexop;
+ char **paths = 0;
+ int had_regexp = 0;
+
+ unsigned i;
+ regex_t regexp;
+
+ *strs = 0;
+ if (s[0] != '/' && s[0] != '(' && s[0] != '*')
+ return 0;
+
+ start = s;
+ while (*start)
+ {
+ split_path (start, &noregexop, &regexop);
+
+ if (noregexop == regexop)
+ {
+ grub_dprintf ("expand", "no expansion needed\n");
+ if (paths == 0)
+ {
+ paths = grub_malloc (sizeof (char *) * 2);
+ if (!paths)
+ goto fail;
+ paths[0] = grub_malloc (regexop - start + 1);
+ if (!paths[0])
+ goto fail;
+ unescape (paths[0], start, regexop);
+ paths[1] = 0;
+ }
+ else
+ {
+ int j = 0;
+ for (i = 0; paths[i]; i++)
+ {
+ char *o, *oend;
+ char *n;
+ char *p;
+ o = paths[i];
+ oend = o + grub_strlen (o);
+ n = grub_malloc ((oend - o) + (regexop - start) + 1);
+ if (!n)
+ goto fail;
+ grub_memcpy (n, o, oend - o);
+
+ unescape (n + (oend - o), start, regexop);
+ if (had_regexp)
+ p = grub_strrchr (n, '/');
+ else
+ p = 0;
+ if (!p)
+ {
+ grub_free (o);
+ paths[j++] = n;
+ continue;
+ }
+ *p = 0;
+ if (!check_file (n, p + 1))
+ {
+ grub_dprintf ("expand", "file <%s> in <%s> not found\n",
+ p + 1, n);
+ grub_free (o);
+ grub_free (n);
+ continue;
+ }
+ *p = '/';
+ grub_free (o);
+ paths[j++] = n;
+ }
+ if (j == 0)
+ {
+ grub_free (paths);
+ paths = 0;
+ goto done;
+ }
+ paths[j] = 0;
+ }
+ grub_dprintf ("expand", "paths[0] = `%s'\n", paths[0]);
+ start = regexop;
+ continue;
+ }
+
+ if (make_regex (noregexop, regexop, &regexp))
+ goto fail;
+
+ had_regexp = 1;
+
+ if (paths == 0)
+ {
+ if (start == noregexop) /* device part has regexop */
+ paths = match_devices (&regexp, *start != '(');
+
+ else /* device part explicit wo regexop */
+ paths = match_files ("", start, noregexop, &regexp);
+ }
+ else
+ {
+ char **r = 0;
+
+ for (i = 0; paths[i]; i++)
+ {
+ char **p;
+
+ p = match_files (paths[i], start, noregexop, &regexp);
+ grub_free (paths[i]);
+ if (! p)
+ continue;
+
+ r = merge (r, p);
+ if (! r)
+ goto fail;
+ }
+ grub_free (paths);
+ paths = r;
+ }
+
+ regfree (&regexp);
+ if (! paths)
+ goto done;
+
+ start = regexop;
+ }
+
+ done:
+
+ *strs = paths;
+ return 0;
+
+ fail:
+
+ for (i = 0; paths && paths[i]; i++)
+ grub_free (paths[i]);
+ grub_free (paths);
+ regfree (&regexp);
+ return grub_errno;
+}
diff --git a/grub-core/commands/xen/lsxen.c b/grub-core/commands/xen/lsxen.c
new file mode 100644
index 0000000..9771310
--- /dev/null
+++ b/grub-core/commands/xen/lsxen.c
@@ -0,0 +1,90 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/xen.h>
+#include <grub/term.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static int
+hook (const char *dir, void *hook_data __attribute__ ((unused)))
+{
+ grub_printf ("%s\n", dir);
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_lsxen (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ char *dir;
+ grub_err_t err;
+ char *buf;
+
+ if (argc >= 1)
+ return grub_xenstore_dir (args[0], hook, NULL);
+
+ buf = grub_xenstore_get_file ("domid", NULL);
+ if (!buf)
+ return grub_errno;
+ dir = grub_xasprintf ("/local/domain/%s", buf);
+ grub_free (buf);
+ err = grub_xenstore_dir (dir, hook, NULL);
+ grub_free (dir);
+ return err;
+}
+
+static grub_err_t
+grub_cmd_catxen (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ const char *dir = "domid";
+ char *buf;
+
+ if (argc >= 1)
+ dir = args[0];
+
+ buf = grub_xenstore_get_file (dir, NULL);
+ if (!buf)
+ return grub_errno;
+ grub_xputs (buf);
+ grub_xputs ("\n");
+ grub_free (buf);
+ return GRUB_ERR_NONE;
+
+}
+
+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."));
+ cmd_cat = grub_register_command ("xen_cat", grub_cmd_catxen, N_("[DIR]"),
+ N_("List Xen storage."));
+}
+
+GRUB_MOD_FINI (lsxen)
+{
+ grub_unregister_command (cmd_ls);
+ grub_unregister_command (cmd_cat);
+}
diff --git a/grub-core/commands/xnu_uuid.c b/grub-core/commands/xnu_uuid.c
new file mode 100644
index 0000000..ae4b3a4
--- /dev/null
+++ b/grub-core/commands/xnu_uuid.c
@@ -0,0 +1,119 @@
+/* xnu_uuid.c - transform 64-bit serial number
+ to 128-bit uuid suitable for xnu. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1995,1996,1998,1999,2001,2002,
+ * 2003, 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/fs.h>
+#include <grub/file.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/crypto.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* This prefix is used by xnu and boot-132 to hash
+ together with volume serial. */
+static grub_uint8_t hash_prefix[16]
+ = {0xB3, 0xE2, 0x0F, 0x39, 0xF2, 0x92, 0x11, 0xD6,
+ 0x97, 0xA4, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC};
+
+static grub_err_t
+grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_uint64_t serial;
+ grub_uint8_t *xnu_uuid;
+ char uuid_string[sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
+ char *ptr;
+ void *ctx;
+ int low = 0;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "UUID required");
+
+ if (argc > 1 && grub_strcmp (args[0], "-l") == 0)
+ {
+ low = 1;
+ argc--;
+ args++;
+ }
+
+ serial = grub_cpu_to_be64 (grub_strtoull (args[0], 0, 16));
+
+ ctx = grub_zalloc (GRUB_MD_MD5->contextsize);
+ if (!ctx)
+ return grub_errno;
+ GRUB_MD_MD5->init (ctx);
+ GRUB_MD_MD5->write (ctx, hash_prefix, sizeof (hash_prefix));
+ GRUB_MD_MD5->write (ctx, &serial, sizeof (serial));
+ GRUB_MD_MD5->final (ctx);
+ xnu_uuid = GRUB_MD_MD5->read (ctx);
+
+ grub_snprintf (uuid_string, sizeof (uuid_string),
+ "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ (unsigned int) xnu_uuid[0], (unsigned int) xnu_uuid[1],
+ (unsigned int) xnu_uuid[2], (unsigned int) xnu_uuid[3],
+ (unsigned int) xnu_uuid[4], (unsigned int) xnu_uuid[5],
+ (unsigned int) ((xnu_uuid[6] & 0xf) | 0x30),
+ (unsigned int) xnu_uuid[7],
+ (unsigned int) ((xnu_uuid[8] & 0x3f) | 0x80),
+ (unsigned int) xnu_uuid[9],
+ (unsigned int) xnu_uuid[10], (unsigned int) xnu_uuid[11],
+ (unsigned int) xnu_uuid[12], (unsigned int) xnu_uuid[13],
+ (unsigned int) xnu_uuid[14], (unsigned int) xnu_uuid[15]);
+ if (!low)
+ for (ptr = uuid_string; *ptr; ptr++)
+ *ptr = grub_toupper (*ptr);
+ if (argc == 1)
+ grub_printf ("%s\n", uuid_string);
+ if (argc > 1)
+ grub_env_set (args[1], uuid_string);
+
+ grub_free (ctx);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd;
+
+
+GRUB_MOD_INIT (xnu_uuid)
+{
+ cmd = grub_register_command ("xnu_uuid", grub_cmd_xnu_uuid,
+ /* TRANSLATORS: GRUBUUID stands for "filesystem
+ UUID as used in GRUB". */
+ N_("[-l] GRUBUUID [VARNAME]"),
+ N_("Transform 64-bit UUID to format "
+ "suitable for XNU. If -l is given keep "
+ "it lowercase as done by blkid."));
+}
+
+GRUB_MOD_FINI (xnu_uuid)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/disk/AFSplitter.c b/grub-core/disk/AFSplitter.c
new file mode 100644
index 0000000..249163f
--- /dev/null
+++ b/grub-core/disk/AFSplitter.c
@@ -0,0 +1,95 @@
+/*
+ * AFsplitter - Anti forensic information splitter
+ * Copyright 2004, Clemens Fruhwirth <clemens@endorphin.org>
+ *
+ * AFsplitter diffuses information over a large stripe of data,
+ * therefor supporting secure data destruction.
+ *
+ * This program is grub_free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the grub_free Software Foundation; either version 2 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 Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the grub_free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <grub/crypto.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+
+GRUB_MOD_LICENSE ("GPLv2+");
+
+gcry_err_code_t AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src,
+ grub_uint8_t * dst, grub_size_t blocksize,
+ grub_size_t blocknumbers);
+
+static void
+diffuse (const gcry_md_spec_t * hash, grub_uint8_t * src,
+ grub_uint8_t * dst, grub_size_t size)
+{
+ grub_size_t i;
+ grub_uint32_t IV; /* host byte order independend hash IV */
+
+ grub_size_t fullblocks = size / hash->mdlen;
+ int padding = size % hash->mdlen;
+ grub_uint8_t final[GRUB_CRYPTO_MAX_MDLEN];
+ grub_uint8_t temp[sizeof (IV) + GRUB_CRYPTO_MAX_MDLEN];
+
+ /* hash block the whole data set with different IVs to produce
+ * more than just a single data block
+ */
+ for (i = 0; i < fullblocks; i++)
+ {
+ IV = grub_cpu_to_be32 (i);
+ grub_memcpy (temp, &IV, sizeof (IV));
+ grub_memcpy (temp + sizeof (IV), src + hash->mdlen * i, hash->mdlen);
+ grub_crypto_hash (hash, dst + hash->mdlen * i, temp,
+ sizeof (IV) + hash->mdlen);
+ }
+
+ if (padding)
+ {
+ IV = grub_cpu_to_be32 (i);
+ grub_memcpy (temp, &IV, sizeof (IV));
+ grub_memcpy (temp + sizeof (IV), src + hash->mdlen * i, padding);
+ grub_crypto_hash (hash, final, temp, sizeof (IV) + padding);
+ grub_memcpy (dst + hash->mdlen * i, final, padding);
+ }
+}
+
+/**
+ * Merges the splitted master key stored on disk into the original key
+ */
+gcry_err_code_t
+AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst,
+ grub_size_t blocksize, grub_size_t blocknumbers)
+{
+ 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;
+
+ grub_memset (bufblock, 0, blocksize);
+ for (i = 0; i < blocknumbers - 1; i++)
+ {
+ grub_crypto_xor (bufblock, src + (blocksize * i), bufblock, blocksize);
+ diffuse (hash, bufblock, bufblock, blocksize);
+ }
+ grub_crypto_xor (dst, src + (i * blocksize), bufblock, blocksize);
+
+ grub_free (bufblock);
+ return GPG_ERR_NO_ERROR;
+}
diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c
new file mode 100644
index 0000000..0e6d56c
--- /dev/null
+++ b/grub-core/disk/ahci.c
@@ -0,0 +1,1163 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/pci.h>
+#include <grub/ata.h>
+#include <grub/scsi.h>
+#include <grub/misc.h>
+#include <grub/list.h>
+#include <grub/loader.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_ahci_cmd_head
+{
+ grub_uint32_t config;
+ grub_uint32_t transferred;
+ grub_uint64_t command_table_base;
+ grub_uint32_t unused[4];
+};
+
+struct grub_ahci_prdt_entry
+{
+ grub_uint64_t data_base;
+ grub_uint32_t unused;
+ grub_uint32_t size;
+};
+
+struct grub_ahci_cmd_table
+{
+ grub_uint8_t cfis[0x40];
+ grub_uint8_t command[0x10];
+ grub_uint8_t reserved[0x30];
+ struct grub_ahci_prdt_entry prdt[1];
+};
+
+struct grub_ahci_hba_port
+{
+ grub_uint64_t command_list_base;
+ grub_uint64_t fis_base;
+ grub_uint32_t intstatus;
+ grub_uint32_t inten;
+ grub_uint32_t command;
+ grub_uint32_t unused1;
+ grub_uint32_t task_file_data;
+ grub_uint32_t sig;
+ grub_uint32_t status;
+ grub_uint32_t unused2;
+ grub_uint32_t sata_error;
+ grub_uint32_t sata_active;
+ grub_uint32_t command_issue;
+ grub_uint32_t unused3;
+ grub_uint32_t fbs;
+ grub_uint32_t unused4[15];
+};
+
+enum grub_ahci_hba_port_command
+ {
+ GRUB_AHCI_HBA_PORT_CMD_ST = 0x01,
+ GRUB_AHCI_HBA_PORT_CMD_SPIN_UP = 0x02,
+ GRUB_AHCI_HBA_PORT_CMD_POWER_ON = 0x04,
+ GRUB_AHCI_HBA_PORT_CMD_FRE = 0x10,
+ GRUB_AHCI_HBA_PORT_CMD_CR = 0x8000,
+ GRUB_AHCI_HBA_PORT_CMD_FR = 0x4000,
+ };
+
+enum grub_ahci_hba_port_int_status
+ {
+ GRUB_AHCI_HBA_PORT_IS_IFS = (1UL << 27),
+ GRUB_AHCI_HBA_PORT_IS_HBDS = (1UL << 28),
+ GRUB_AHCI_HBA_PORT_IS_HBFS = (1UL << 29),
+ GRUB_AHCI_HBA_PORT_IS_TFES = (1UL << 30),
+ };
+
+#define GRUB_AHCI_HBA_PORT_IS_FATAL_MASK ( \
+ GRUB_AHCI_HBA_PORT_IS_IFS | \
+ GRUB_AHCI_HBA_PORT_IS_HBDS | \
+ GRUB_AHCI_HBA_PORT_IS_HBFS | \
+ GRUB_AHCI_HBA_PORT_IS_TFES)
+
+struct grub_ahci_hba
+{
+ grub_uint32_t cap;
+ grub_uint32_t global_control;
+ grub_uint32_t intr_status;
+ grub_uint32_t ports_implemented;
+ grub_uint32_t unused1[6];
+ grub_uint32_t bios_handoff;
+ grub_uint32_t unused2[53];
+ struct grub_ahci_hba_port ports[32];
+};
+
+struct grub_ahci_received_fis
+{
+ char raw[4096];
+};
+
+enum
+ {
+ GRUB_AHCI_HBA_CAP_NPORTS_MASK = 0x1f
+ };
+
+enum
+ {
+ GRUB_AHCI_HBA_GLOBAL_CONTROL_RESET = 0x00000001,
+ GRUB_AHCI_HBA_GLOBAL_CONTROL_INTR_EN = 0x00000002,
+ GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN = 0x80000000,
+ };
+
+enum
+ {
+ GRUB_AHCI_BIOS_HANDOFF_BIOS_OWNED = 1,
+ GRUB_AHCI_BIOS_HANDOFF_OS_OWNED = 2,
+ GRUB_AHCI_BIOS_HANDOFF_OS_OWNERSHIP_CHANGED = 8,
+ GRUB_AHCI_BIOS_HANDOFF_RWC = 8
+ };
+
+
+struct grub_ahci_device
+{
+ struct grub_ahci_device *next;
+ struct grub_ahci_device **prev;
+ volatile struct grub_ahci_hba *hba;
+ int port;
+ int num;
+ struct grub_pci_dma_chunk *command_list_chunk;
+ volatile struct grub_ahci_cmd_head *command_list;
+ struct grub_pci_dma_chunk *command_table_chunk;
+ volatile struct grub_ahci_cmd_table *command_table;
+ struct grub_pci_dma_chunk *rfis;
+ int present;
+ int atapi;
+};
+
+static grub_err_t
+grub_ahci_readwrite_real (struct grub_ahci_device *dev,
+ struct grub_disk_ata_pass_through_parms *parms,
+ int spinup, int reset);
+
+
+enum
+ {
+ GRUB_AHCI_CONFIG_READ = 0,
+ GRUB_AHCI_CONFIG_CFIS_LENGTH_MASK = 0x1f,
+ GRUB_AHCI_CONFIG_ATAPI = 0x20,
+ GRUB_AHCI_CONFIG_WRITE = 0x40,
+ GRUB_AHCI_CONFIG_PREFETCH = 0x80,
+ GRUB_AHCI_CONFIG_RESET = 0x100,
+ GRUB_AHCI_CONFIG_BIST = 0x200,
+ GRUB_AHCI_CONFIG_CLEAR_R_OK = 0x400,
+ GRUB_AHCI_CONFIG_PMP_MASK = 0xf000,
+ GRUB_AHCI_CONFIG_PRDT_LENGTH_MASK = 0xffff0000,
+ };
+#define GRUB_AHCI_CONFIG_CFIS_LENGTH_SHIFT 0
+#define GRUB_AHCI_CONFIG_PMP_SHIFT 12
+#define GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT 16
+#define GRUB_AHCI_INTERRUPT_ON_COMPLETE 0x80000000
+
+#define GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH 0x200000
+
+static struct grub_ahci_device *grub_ahci_devices;
+static int numdevs;
+
+static int
+grub_ahci_pciinit (grub_pci_device_t dev,
+ grub_pci_id_t pciid __attribute__ ((unused)),
+ void *data __attribute__ ((unused)))
+{
+ grub_pci_address_t addr;
+ grub_uint32_t class;
+ grub_uint32_t bar;
+ unsigned i, nports;
+ volatile struct grub_ahci_hba *hba;
+
+ /* Read class. */
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class = grub_pci_read (addr);
+
+ /* Check if this class ID matches that of a PCI IDE Controller. */
+ if (class >> 8 != 0x010601)
+ return 0;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG5);
+
+ bar = grub_pci_read (addr);
+
+ if ((bar & (GRUB_PCI_ADDR_SPACE_MASK | GRUB_PCI_ADDR_MEM_TYPE_MASK
+ | GRUB_PCI_ADDR_MEM_PREFETCH))
+ != (GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32))
+ 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_MEM_ENABLED | GRUB_PCI_COMMAND_BUS_MASTER);
+
+ hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK,
+ sizeof (*hba));
+ grub_dprintf ("ahci", "dev: %x:%x.%x\n", dev.bus, dev.device, dev.function);
+
+ grub_dprintf ("ahci", "tfd[0]: %x\n",
+ hba->ports[0].task_file_data);
+ grub_dprintf ("ahci", "cmd[0]: %x\n",
+ hba->ports[0].command);
+ grub_dprintf ("ahci", "st[0]: %x\n",
+ hba->ports[0].status);
+ grub_dprintf ("ahci", "err[0]: %x\n",
+ hba->ports[0].sata_error);
+
+ grub_dprintf ("ahci", "tfd[1]: %x\n",
+ hba->ports[1].task_file_data);
+ grub_dprintf ("ahci", "cmd[1]: %x\n",
+ hba->ports[1].command);
+ grub_dprintf ("ahci", "st[1]: %x\n",
+ hba->ports[1].status);
+ grub_dprintf ("ahci", "err[1]: %x\n",
+ hba->ports[1].sata_error);
+
+ hba->ports[1].sata_error = hba->ports[1].sata_error;
+
+ grub_dprintf ("ahci", "err[1]: %x\n",
+ hba->ports[1].sata_error);
+
+ grub_dprintf ("ahci", "BH:%x\n", hba->bios_handoff);
+
+ if (! (hba->bios_handoff & GRUB_AHCI_BIOS_HANDOFF_OS_OWNED))
+ {
+ grub_uint64_t endtime;
+
+ grub_dprintf ("ahci", "Requesting AHCI ownership\n");
+ hba->bios_handoff = (hba->bios_handoff & ~GRUB_AHCI_BIOS_HANDOFF_RWC)
+ | GRUB_AHCI_BIOS_HANDOFF_OS_OWNED;
+ grub_dprintf ("ahci", "Waiting for BIOS to give up ownership\n");
+ endtime = grub_get_time_ms () + 1000;
+ while ((hba->bios_handoff & GRUB_AHCI_BIOS_HANDOFF_BIOS_OWNED)
+ && grub_get_time_ms () < endtime);
+ if (hba->bios_handoff & GRUB_AHCI_BIOS_HANDOFF_BIOS_OWNED)
+ {
+ grub_dprintf ("ahci", "Forcibly taking ownership\n");
+ hba->bios_handoff = GRUB_AHCI_BIOS_HANDOFF_OS_OWNED;
+ hba->bios_handoff |= GRUB_AHCI_BIOS_HANDOFF_OS_OWNERSHIP_CHANGED;
+ }
+ else
+ grub_dprintf ("ahci", "AHCI ownership obtained\n");
+ }
+ else
+ grub_dprintf ("ahci", "AHCI is already in OS mode\n");
+
+ grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
+
+ grub_dprintf ("ahci", "err[1]: %x\n",
+ hba->ports[1].sata_error);
+
+ if (!(hba->global_control & GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN))
+ grub_dprintf ("ahci", "AHCI is in compat mode. Switching\n");
+ else
+ grub_dprintf ("ahci", "AHCI is in AHCI mode.\n");
+
+ grub_dprintf ("ahci", "err[1]: %x\n",
+ hba->ports[1].sata_error);
+
+ grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
+
+ /* {
+ grub_uint64_t endtime;
+ hba->global_control |= 1;
+ endtime = grub_get_time_ms () + 1000;
+ while (hba->global_control & 1)
+ if (grub_get_time_ms () > endtime)
+ {
+ grub_dprintf ("ahci", "couldn't reset AHCI\n");
+ return 0;
+ }
+ }*/
+
+ grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
+
+ grub_dprintf ("ahci", "err[1]: %x\n",
+ hba->ports[1].sata_error);
+
+ for (i = 0; i < 5; i++)
+ {
+ hba->global_control |= GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN;
+ grub_millisleep (1);
+ if (hba->global_control & GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN)
+ break;
+ }
+ if (i == 5)
+ {
+ grub_dprintf ("ahci", "Couldn't put AHCI in AHCI mode\n");
+ return 0;
+ }
+
+ grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
+
+ grub_dprintf ("ahci", "err[1]: %x\n",
+ hba->ports[1].sata_error);
+
+ grub_dprintf ("ahci", "err[1]: %x\n",
+ hba->ports[1].sata_error);
+
+ grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
+
+ for (i = 0; i < 5; i++)
+ {
+ hba->global_control |= GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN;
+ grub_millisleep (1);
+ if (hba->global_control & GRUB_AHCI_HBA_GLOBAL_CONTROL_AHCI_EN)
+ break;
+ }
+ if (i == 5)
+ {
+ grub_dprintf ("ahci", "Couldn't put AHCI in AHCI mode\n");
+ return 0;
+ }
+
+ grub_dprintf ("ahci", "err[1]: %x\n",
+ hba->ports[1].sata_error);
+
+ grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
+
+ nports = (GRUB_AHCI_HBA_CAP_NPORTS_MASK) + 1;
+
+ grub_dprintf ("ahci", "%d AHCI ports, PI = 0x%x\n", nports,
+ hba->ports_implemented);
+
+ struct grub_ahci_device *adevs[GRUB_AHCI_HBA_CAP_NPORTS_MASK + 1];
+ struct grub_ahci_device *failed_adevs[GRUB_AHCI_HBA_CAP_NPORTS_MASK + 1];
+ grub_uint32_t fr_running = 0;
+
+ for (i = 0; i < nports; i++)
+ failed_adevs[i] = 0;
+ for (i = 0; i < nports; i++)
+ {
+ if (!(hba->ports_implemented & (1 << i)))
+ {
+ adevs[i] = 0;
+ continue;
+ }
+
+ adevs[i] = grub_zalloc (sizeof (*adevs[i]));
+ if (!adevs[i])
+ return 1;
+
+ adevs[i]->hba = hba;
+ adevs[i]->port = i;
+ adevs[i]->present = 1;
+ adevs[i]->num = numdevs++;
+ }
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i])
+ {
+ adevs[i]->hba->ports[adevs[i]->port].sata_error = adevs[i]->hba->ports[adevs[i]->port].sata_error;
+ 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) * 32);
+ if (!adevs[i]->command_list_chunk)
+ {
+ adevs[i] = 0;
+ continue;
+ }
+
+ adevs[i]->command_table_chunk = grub_memalign_dma32 (1024,
+ sizeof (struct grub_ahci_cmd_table));
+ if (!adevs[i]->command_table_chunk)
+ {
+ grub_dma_free (adevs[i]->command_list_chunk);
+ adevs[i] = 0;
+ continue;
+ }
+
+ 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);
+
+ grub_dprintf ("ahci", "found device ahci%d (port %d), command_table = %p, command_list = %p\n",
+ adevs[i]->num, adevs[i]->port, grub_dma_get_virt (adevs[i]->command_table_chunk),
+ grub_dma_get_virt (adevs[i]->command_list_chunk));
+
+ adevs[i]->hba->ports[adevs[i]->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
+ }
+
+ grub_uint64_t endtime;
+ endtime = grub_get_time_ms () + 1000;
+
+ while (grub_get_time_ms () < endtime)
+ {
+ for (i = 0; i < nports; i++)
+ if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
+ break;
+ if (i == nports)
+ break;
+ }
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
+ {
+ grub_dprintf ("ahci", "couldn't stop FR on port %d\n", i);
+ failed_adevs[i] = adevs[i];
+ adevs[i] = 0;
+ }
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i])
+ adevs[i]->hba->ports[adevs[i]->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
+ endtime = grub_get_time_ms () + 1000;
+
+ while (grub_get_time_ms () < endtime)
+ {
+ for (i = 0; i < nports; i++)
+ if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
+ break;
+ if (i == nports)
+ break;
+ }
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
+ {
+ grub_dprintf ("ahci", "couldn't stop CR on port %d\n", i);
+ failed_adevs[i] = adevs[i];
+ adevs[i] = 0;
+ }
+ for (i = 0; i < nports; i++)
+ if (adevs[i])
+ {
+ adevs[i]->hba->ports[adevs[i]->port].inten = 0;
+ adevs[i]->hba->ports[adevs[i]->port].intstatus = ~0;
+ // adevs[i]->hba->ports[adevs[i]->port].fbs = 0;
+
+ 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,
+ sizeof (struct grub_ahci_received_fis));
+ grub_memset ((char *) grub_dma_get_virt (adevs[i]->rfis), 0,
+ sizeof (struct grub_ahci_received_fis));
+ grub_memset ((char *) grub_dma_get_virt (adevs[i]->command_list_chunk), 0,
+ sizeof (struct grub_ahci_cmd_head));
+ grub_memset ((char *) grub_dma_get_virt (adevs[i]->command_table_chunk), 0,
+ sizeof (struct grub_ahci_cmd_table));
+ 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;
+ }
+
+ endtime = grub_get_time_ms () + 1000;
+
+ while (grub_get_time_ms () < endtime)
+ {
+ for (i = 0; i < nports; i++)
+ if (adevs[i] && !(adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
+ break;
+ if (i == nports)
+ break;
+ }
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i] && !(adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
+ {
+ grub_dprintf ("ahci", "couldn't start FR on port %d\n", i);
+ failed_adevs[i] = adevs[i];
+ adevs[i] = 0;
+ }
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i])
+ {
+ grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
+ adevs[i]->hba->ports[adevs[i]->port].sata_error);
+ fr_running |= (1 << i);
+
+ adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_SPIN_UP;
+ 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", "port: %d, err: %x\n", adevs[i]->port,
+ adevs[i]->hba->ports[adevs[i]->port].sata_error);
+ }
+
+ /* 10ms should actually be enough. */
+ endtime = grub_get_time_ms () + 100;
+
+ while (grub_get_time_ms () < endtime)
+ {
+ for (i = 0; i < nports; i++)
+ if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].status & 7) != 3)
+ break;
+ if (i == nports)
+ break;
+ }
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].status & 7) != 3)
+ {
+ grub_dprintf ("ahci", "couldn't detect device on port %d\n", i);
+ failed_adevs[i] = adevs[i];
+ adevs[i] = 0;
+ }
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i])
+ {
+ 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", "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", "port %d, err: %x\n", adevs[i]->port,
+ adevs[i]->hba->ports[adevs[i]->port].sata_error);
+
+ 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", "port %d, err: %x\n", adevs[i]->port,
+ adevs[i]->hba->ports[adevs[i]->port].sata_error);
+ }
+
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i])
+ {
+ 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", "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)
+ | 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));
+ parms2.taskfile.cmd = 8;
+ grub_ahci_readwrite_real (dev, &parms2, 1, 1);*/
+ }
+
+ endtime = grub_get_time_ms () + 32000;
+
+ 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 & (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 & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ)))
+ {
+ grub_dprintf ("ahci", "port %d is busy\n", i);
+ failed_adevs[i] = adevs[i];
+ adevs[i] = 0;
+ }
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i])
+ adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_ST;
+
+ endtime = grub_get_time_ms () + 1000;
+
+ while (grub_get_time_ms () < endtime)
+ {
+ for (i = 0; i < nports; i++)
+ if (adevs[i] && !(adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
+ break;
+ if (i == nports)
+ break;
+ }
+
+ for (i = 0; i < nports; i++)
+ if (adevs[i] && !(adevs[i]->hba->ports[adevs[i]->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
+ {
+ grub_dprintf ("ahci", "couldn't start CR on port %d\n", i);
+ 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;
+
+ endtime = grub_get_time_ms () + 1000;
+ while (grub_get_time_ms () < endtime)
+ {
+ 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_FR))
+ break;
+ if (i == nports)
+ break;
+ }
+ for (i = 0; i < nports; i++)
+ if (failed_adevs[i])
+ {
+ grub_dma_free (failed_adevs[i]->command_list_chunk);
+ grub_dma_free (failed_adevs[i]->command_table_chunk);
+ grub_dma_free (failed_adevs[i]->rfis);
+ }
+
+ for (i = 0; i < nports; i++)
+ 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])
+ {
+ grub_list_push (GRUB_AS_LIST_P (&grub_ahci_devices),
+ GRUB_AS_LIST (adevs[i]));
+ }
+
+ return 0;
+}
+
+static grub_err_t
+grub_ahci_initialize (void)
+{
+ grub_pci_iterate (grub_ahci_pciinit, NULL);
+ return grub_errno;
+}
+
+static grub_err_t
+grub_ahci_fini_hw (int noreturn __attribute__ ((unused)))
+{
+ struct grub_ahci_device *dev;
+
+ for (dev = grub_ahci_devices; dev; dev = dev->next)
+ {
+ grub_uint64_t endtime;
+
+ dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
+ endtime = grub_get_time_ms () + 1000;
+ while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
+ if (grub_get_time_ms () > endtime)
+ {
+ grub_dprintf ("ahci", "couldn't stop FR\n");
+ break;
+ }
+
+ dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
+ 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)
+ {
+ grub_dprintf ("ahci", "couldn't stop CR\n");
+ break;
+ }
+ grub_dma_free (dev->command_list_chunk);
+ grub_dma_free (dev->command_table_chunk);
+ grub_dma_free (dev->rfis);
+ dev->command_list_chunk = NULL;
+ dev->command_table_chunk = NULL;
+ dev->rfis = NULL;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static int
+reinit_port (struct grub_ahci_device *dev)
+{
+ struct grub_pci_dma_chunk *command_list;
+ struct grub_pci_dma_chunk *command_table;
+ grub_uint64_t endtime;
+
+ command_list = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head));
+ if (!command_list)
+ return 1;
+
+ command_table = grub_memalign_dma32 (1024,
+ sizeof (struct grub_ahci_cmd_table));
+ if (!command_table)
+ {
+ grub_dma_free (command_list);
+ return 1;
+ }
+
+ grub_dprintf ("ahci", "found device ahci%d (port %d)\n", dev->num, dev->port);
+
+ dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
+ endtime = grub_get_time_ms () + 1000;
+ while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
+ if (grub_get_time_ms () > endtime)
+ {
+ grub_dprintf ("ahci", "couldn't stop FR\n");
+ goto out;
+ }
+
+ dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
+ 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)
+ {
+ grub_dprintf ("ahci", "couldn't stop CR\n");
+ goto out;
+ }
+
+ dev->hba->ports[dev->port].fbs = 2;
+
+ dev->rfis = grub_memalign_dma32 (4096,
+ sizeof (struct grub_ahci_received_fis));
+ grub_memset ((char *) grub_dma_get_virt (dev->rfis), 0,
+ sizeof (struct grub_ahci_received_fis));
+ dev->hba->ports[dev->port].fis_base = grub_dma_get_phys (dev->rfis);
+ dev->hba->ports[dev->port].command_list_base
+ = grub_dma_get_phys (command_list);
+ dev->hba->ports[dev->port].command |= GRUB_AHCI_HBA_PORT_CMD_FRE;
+ while (!(dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
+ if (grub_get_time_ms () > endtime)
+ {
+ grub_dprintf ("ahci", "couldn't start FR\n");
+ dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
+ goto out;
+ }
+ dev->hba->ports[dev->port].command |= GRUB_AHCI_HBA_PORT_CMD_ST;
+ while (!(dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
+ if (grub_get_time_ms () > endtime)
+ {
+ grub_dprintf ("ahci", "couldn't start CR\n");
+ dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_CR;
+ goto out_stop_fr;
+ }
+
+ dev->hba->ports[dev->port].command
+ = (dev->hba->ports[dev->port].command & 0x0fffffff) | (1 << 28) | 2 | 4;
+
+ dev->command_list_chunk = command_list;
+ dev->command_list = grub_dma_get_virt (command_list);
+ dev->command_table_chunk = command_table;
+ dev->command_table = grub_dma_get_virt (command_table);
+ dev->command_list->command_table_base
+ = grub_dma_get_phys (command_table);
+
+ return 0;
+ out_stop_fr:
+ dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
+ endtime = grub_get_time_ms () + 1000;
+ while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_FR))
+ if (grub_get_time_ms () > endtime)
+ {
+ grub_dprintf ("ahci", "couldn't stop FR\n");
+ break;
+ }
+ out:
+ grub_dma_free (command_list);
+ grub_dma_free (command_table);
+ grub_dma_free (dev->rfis);
+ return 1;
+}
+
+static grub_err_t
+grub_ahci_restore_hw (void)
+{
+ struct grub_ahci_device **pdev;
+
+ for (pdev = &grub_ahci_devices; *pdev; pdev = &((*pdev)->next))
+ if (reinit_port (*pdev))
+ {
+ struct grub_ahci_device *odev;
+ odev = *pdev;
+ *pdev = (*pdev)->next;
+ grub_free (odev);
+ }
+ return GRUB_ERR_NONE;
+}
+
+
+
+
+static int
+grub_ahci_iterate (grub_ata_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ struct grub_ahci_device *dev;
+
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ FOR_LIST_ELEMENTS(dev, grub_ahci_devices)
+ if (hook (GRUB_SCSI_SUBSYSTEM_AHCI, dev->num, hook_data))
+ return 1;
+
+ return 0;
+}
+
+#if 0
+static int
+find_free_cmd_slot (struct grub_ahci_device *dev)
+{
+ int i;
+ for (i = 0; i < 32; i++)
+ {
+ if (dev->hda->ports[dev->port].command_issue & (1 << i))
+ continue;
+ if (dev->hda->ports[dev->port].sata_active & (1 << i))
+ continue;
+ return i;
+ }
+ return -1;
+}
+#endif
+
+enum
+ {
+ GRUB_AHCI_FIS_REG_H2D = 0x27
+ };
+
+static const int register_map[11] = { 3 /* Features */,
+ 12 /* Sectors */,
+ 4 /* LBA low */,
+ 5 /* LBA mid */,
+ 6 /* LBA high */,
+ 7 /* Device */,
+ 2 /* CMD register */,
+ 13 /* Sectors 48 */,
+ 8 /* LBA48 low */,
+ 9 /* LBA48 mid */,
+ 10 /* LBA48 high */ };
+
+static grub_err_t
+grub_ahci_reset_port (struct grub_ahci_device *dev, int force)
+{
+ grub_uint64_t endtime;
+
+ dev->hba->ports[dev->port].sata_error = dev->hba->ports[dev->port].sata_error;
+
+ if (force || (dev->hba->ports[dev->port].command_issue & 1)
+ || (dev->hba->ports[dev->port].task_file_data & 0x80))
+ {
+ 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)
+ {
+ grub_dprintf ("ahci", "couldn't stop CR");
+ return grub_error (GRUB_ERR_IO, "couldn't stop CR");
+ }
+ dev->hba->ports[dev->port].command |= 8;
+ while (dev->hba->ports[dev->port].command & 8)
+ if (grub_get_time_ms () > endtime)
+ {
+ grub_dprintf ("ahci", "couldn't set CLO\n");
+ dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
+ return grub_error (GRUB_ERR_IO, "couldn't set CLO");
+ }
+
+ dev->hba->ports[dev->port].command |= GRUB_AHCI_HBA_PORT_CMD_ST;
+ while (!(dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
+ if (grub_get_time_ms () > endtime)
+ {
+ grub_dprintf ("ahci", "couldn't stop CR");
+ dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
+ return grub_error (GRUB_ERR_IO, "couldn't stop CR");
+ }
+ dev->hba->ports[dev->port].sata_error = dev->hba->ports[dev->port].sata_error;
+ grub_memset (&parms2, 0, sizeof (parms2));
+ parms2.taskfile.cmd = 8;
+ return grub_ahci_readwrite_real (dev, &parms2, 1, 1);
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_ahci_readwrite_real (struct grub_ahci_device *dev,
+ struct grub_disk_ata_pass_through_parms *parms,
+ int spinup, int reset)
+{
+ struct grub_pci_dma_chunk *bufc;
+ grub_uint64_t endtime;
+ unsigned i;
+ grub_err_t err = GRUB_ERR_NONE;
+
+ grub_dprintf ("ahci", "AHCI tfd = %x\n",
+ dev->hba->ports[dev->port].task_file_data);
+
+ if (!reset)
+ grub_ahci_reset_port (dev, 0);
+
+ grub_dprintf ("ahci", "AHCI tfd = %x\n",
+ dev->hba->ports[dev->port].task_file_data);
+ dev->hba->ports[dev->port].task_file_data = 0;
+ dev->hba->ports[dev->port].command_issue = 0;
+ grub_dprintf ("ahci", "AHCI tfd = %x\n",
+ dev->hba->ports[dev->port].task_file_data);
+
+ dev->hba->ports[dev->port].sata_error = dev->hba->ports[dev->port].sata_error;
+
+ grub_dprintf("ahci", "grub_ahci_read (size=%llu, cmdsize = %llu)\n",
+ (unsigned long long) parms->size,
+ (unsigned long long) parms->cmdsize);
+
+ if (parms->cmdsize != 0 && parms->cmdsize != 12 && parms->cmdsize != 16)
+ return grub_error (GRUB_ERR_BUG, "incorrect ATAPI command size");
+
+ if (parms->size > GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH)
+ return grub_error (GRUB_ERR_BUG, "too big data buffer");
+
+ 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,
+ dev->command_list);
+ /* FIXME: support port multipliers. */
+ dev->command_list[0].config
+ = (5 << GRUB_AHCI_CONFIG_CFIS_LENGTH_SHIFT)
+ // | GRUB_AHCI_CONFIG_CLEAR_R_OK
+ | (0 << GRUB_AHCI_CONFIG_PMP_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].transferred = 0;
+ dev->command_list[0].command_table_base
+ = grub_dma_get_phys (dev->command_table_chunk);
+
+ grub_memset ((char *) dev->command_list[0].unused, 0,
+ sizeof (dev->command_list[0].unused));
+
+ grub_memset ((char *) &dev->command_table[0], 0,
+ sizeof (dev->command_table[0]));
+ grub_dprintf ("ahci", "AHCI tfd = %x\n",
+ dev->hba->ports[dev->port].task_file_data);
+
+ if (parms->cmdsize)
+ grub_memcpy ((char *) dev->command_table[0].command, parms->cmd,
+ parms->cmdsize);
+
+ grub_dprintf ("ahci", "AHCI tfd = %x\n",
+ dev->hba->ports[dev->port].task_file_data);
+
+ dev->command_table[0].cfis[0] = GRUB_AHCI_FIS_REG_H2D;
+ dev->command_table[0].cfis[1] = 0x80;
+ for (i = 0; i < sizeof (parms->taskfile.raw); i++)
+ dev->command_table[0].cfis[register_map[i]] = parms->taskfile.raw[i];
+
+ grub_dprintf ("ahci", "cfis: %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ dev->command_table[0].cfis[0], dev->command_table[0].cfis[1],
+ dev->command_table[0].cfis[2], dev->command_table[0].cfis[3],
+ dev->command_table[0].cfis[4], dev->command_table[0].cfis[5],
+ dev->command_table[0].cfis[6], dev->command_table[0].cfis[7]);
+ grub_dprintf ("ahci", "cfis: %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ dev->command_table[0].cfis[8], dev->command_table[0].cfis[9],
+ dev->command_table[0].cfis[10], dev->command_table[0].cfis[11],
+ dev->command_table[0].cfis[12], dev->command_table[0].cfis[13],
+ dev->command_table[0].cfis[14], dev->command_table[0].cfis[15]);
+
+ dev->command_table[0].prdt[0].data_base = grub_dma_get_phys (bufc);
+ dev->command_table[0].prdt[0].unused = 0;
+ dev->command_table[0].prdt[0].size = (parms->size - 1);
+
+ grub_dprintf ("ahci", "PRDT = %" PRIxGRUB_UINT64_T ", %x, %x (%"
+ PRIuGRUB_SIZE ")\n",
+ dev->command_table[0].prdt[0].data_base,
+ dev->command_table[0].prdt[0].unused,
+ dev->command_table[0].prdt[0].size,
+ (grub_size_t) ((char *) &dev->command_table[0].prdt[0]
+ - (char *) &dev->command_table[0]));
+
+ if (parms->write)
+ grub_memcpy ((char *) grub_dma_get_virt (bufc), parms->buffer, parms->size);
+
+ 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",
+ dev->hba->ports[dev->port].inten);
+ grub_dprintf ("ahci", "AHCI intstatus = %x\n",
+ dev->hba->ports[dev->port].intstatus);
+
+ dev->hba->ports[dev->port].inten = 0xffffffff;//(1 << 2) | (1 << 5);
+ dev->hba->ports[dev->port].intstatus = 0xffffffff;//(1 << 2) | (1 << 5);
+ grub_dprintf ("ahci", "AHCI inten = %x\n",
+ dev->hba->ports[dev->port].inten);
+ grub_dprintf ("ahci", "AHCI tfd = %x\n",
+ dev->hba->ports[dev->port].task_file_data);
+ dev->hba->ports[dev->port].sata_active = 1;
+ dev->hba->ports[dev->port].command_issue = 1;
+ grub_dprintf ("ahci", "AHCI sig = %x\n", dev->hba->ports[dev->port].sig);
+ grub_dprintf ("ahci", "AHCI tfd = %x\n",
+ dev->hba->ports[dev->port].task_file_data);
+
+ endtime = grub_get_time_ms () + (spinup ? 20000 : 20000);
+ while ((dev->hba->ports[dev->port].command_issue & 1))
+ if (grub_get_time_ms () > endtime ||
+ (dev->hba->ports[dev->port].intstatus & GRUB_AHCI_HBA_PORT_IS_FATAL_MASK))
+ {
+ grub_dprintf ("ahci", "AHCI status <%x %x %x %x>\n",
+ dev->hba->ports[dev->port].command_issue,
+ dev->hba->ports[dev->port].sata_active,
+ dev->hba->ports[dev->port].intstatus,
+ dev->hba->ports[dev->port].task_file_data);
+ dev->hba->ports[dev->port].command_issue = 0;
+ if (dev->hba->ports[dev->port].intstatus & GRUB_AHCI_HBA_PORT_IS_FATAL_MASK)
+ err = grub_error (GRUB_ERR_IO, "AHCI transfer error");
+ else
+ err = grub_error (GRUB_ERR_IO, "AHCI transfer timed out");
+ if (!reset)
+ grub_ahci_reset_port (dev, 1);
+ break;
+ }
+
+ grub_dprintf ("ahci", "AHCI command completed <%x %x %x %x %x, %x %x>\n",
+ 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].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]);
+ grub_dprintf ("ahci",
+ "last PIO FIS %08x %08x %08x %08x %08x %08x %08x %08x\n",
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x08],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x09],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x0a],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x0b],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x0c],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x0d],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x0e],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x0f]);
+ grub_dprintf ("ahci",
+ "last REG FIS %08x %08x %08x %08x %08x %08x %08x %08x\n",
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x10],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x11],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x12],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x13],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x14],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x15],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x16],
+ ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x17]);
+
+ if (!parms->write)
+ grub_memcpy (parms->buffer, (char *) grub_dma_get_virt (bufc), parms->size);
+ grub_dma_free (bufc);
+
+ return err;
+}
+
+static grub_err_t
+grub_ahci_readwrite (grub_ata_t disk,
+ struct grub_disk_ata_pass_through_parms *parms,
+ int spinup)
+{
+ return grub_ahci_readwrite_real (disk->data, parms, spinup, 0);
+}
+
+static grub_err_t
+grub_ahci_open (int id, int devnum, struct grub_ata *ata)
+{
+ struct grub_ahci_device *dev;
+
+ if (id != GRUB_SCSI_SUBSYSTEM_AHCI)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not an AHCI device");
+
+ FOR_LIST_ELEMENTS(dev, grub_ahci_devices)
+ if (dev->num == devnum)
+ break;
+
+ if (! dev)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such AHCI device");
+
+ grub_dprintf ("ahci", "opening AHCI dev `ahci%d'\n", dev->num);
+
+ ata->data = dev;
+ ata->dma = 1;
+ ata->atapi = dev->atapi;
+ ata->maxbuffer = GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH;
+ ata->present = &dev->present;
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_ata_dev grub_ahci_dev =
+ {
+ .iterate = grub_ahci_iterate,
+ .open = grub_ahci_open,
+ .readwrite = grub_ahci_readwrite,
+ };
+
+
+
+static struct grub_preboot *fini_hnd;
+
+GRUB_MOD_INIT(ahci)
+{
+ grub_stop_disk_firmware ();
+
+ /* AHCI initialization. */
+ grub_ahci_initialize ();
+
+ /* AHCI devices are handled by scsi.mod. */
+ grub_ata_dev_register (&grub_ahci_dev);
+
+ fini_hnd = grub_loader_register_preboot_hook (grub_ahci_fini_hw,
+ grub_ahci_restore_hw,
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK);
+}
+
+GRUB_MOD_FINI(ahci)
+{
+ grub_ahci_fini_hw (0);
+ grub_loader_unregister_preboot_hook (fini_hnd);
+
+ grub_ata_dev_unregister (&grub_ahci_dev);
+}
diff --git a/grub-core/disk/arc/arcdisk.c b/grub-core/disk/arc/arcdisk.c
new file mode 100644
index 0000000..c94039a
--- /dev/null
+++ b/grub-core/disk/arc/arcdisk.c
@@ -0,0 +1,325 @@
+/* ofdisk.c - Open Firmware disk access. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2006,2007,2008,2009,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/disk.h>
+#include <grub/mm.h>
+#include <grub/arc/arc.h>
+#include <grub/i18n.h>
+
+static grub_arc_fileno_t last_handle = 0;
+static char *last_path = NULL;
+static int handle_writable = 0;
+
+static int lnum = 0;
+
+struct arcdisk_hash_ent
+{
+ char *devpath;
+ int num;
+ struct arcdisk_hash_ent *next;
+};
+
+#define ARCDISK_HASH_SZ 8
+static struct arcdisk_hash_ent *arcdisk_hash[ARCDISK_HASH_SZ];
+
+static int
+arcdisk_hash_fn (const char *devpath)
+{
+ int hash = 0;
+ while (*devpath)
+ hash ^= *devpath++;
+ return (hash & (ARCDISK_HASH_SZ - 1));
+}
+
+static struct arcdisk_hash_ent *
+arcdisk_hash_find (const char *devpath)
+{
+ struct arcdisk_hash_ent *p = arcdisk_hash[arcdisk_hash_fn (devpath)];
+
+ while (p)
+ {
+ if (!grub_strcmp (p->devpath, devpath))
+ break;
+ p = p->next;
+ }
+ return p;
+}
+
+static struct arcdisk_hash_ent *
+arcdisk_hash_add (char *devpath)
+{
+ struct arcdisk_hash_ent *p;
+ struct arcdisk_hash_ent **head = &arcdisk_hash[arcdisk_hash_fn(devpath)];
+
+ p = grub_malloc (sizeof (*p));
+ if (!p)
+ return NULL;
+
+ p->devpath = devpath;
+ p->next = *head;
+ p->num = lnum++;
+ *head = p;
+ return p;
+}
+
+
+/* Context for grub_arcdisk_iterate. */
+struct grub_arcdisk_iterate_ctx
+{
+ grub_disk_dev_iterate_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_arcdisk_iterate. */
+static int
+grub_arcdisk_iterate_iter (const char *name,
+ const struct grub_arc_component *comp, void *data)
+{
+ struct grub_arcdisk_iterate_ctx *ctx = data;
+
+ if (!(comp->type == GRUB_ARC_COMPONENT_TYPE_DISK
+ || comp->type == GRUB_ARC_COMPONENT_TYPE_FLOPPY
+ || comp->type == GRUB_ARC_COMPONENT_TYPE_TAPE))
+ return 0;
+ return ctx->hook (name, ctx->hook_data);
+}
+
+static int
+grub_arcdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ struct grub_arcdisk_iterate_ctx ctx = { hook, hook_data };
+
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ return grub_arc_iterate_devs (grub_arcdisk_iterate_iter, &ctx, 1);
+}
+
+#ifdef GRUB_CPU_MIPSEL
+#define RAW_SUFFIX "partition(0)"
+#else
+#define RAW_SUFFIX "partition(10)"
+#endif
+
+static grub_err_t
+reopen (const char *name, int writable)
+{
+ grub_arc_fileno_t handle;
+
+ if (last_path && grub_strcmp (last_path, name) == 0
+ && (!writable || handle_writable))
+ {
+ grub_dprintf ("arcdisk", "using already opened %s\n", name);
+ return GRUB_ERR_NONE;
+ }
+ if (last_path)
+ {
+ GRUB_ARC_FIRMWARE_VECTOR->close (last_handle);
+ grub_free (last_path);
+ last_path = NULL;
+ last_handle = 0;
+ handle_writable = 0;
+ }
+ if (GRUB_ARC_FIRMWARE_VECTOR->open (name,
+ writable ? GRUB_ARC_FILE_ACCESS_OPEN_RW
+ : GRUB_ARC_FILE_ACCESS_OPEN_RO, &handle))
+ {
+ grub_dprintf ("arcdisk", "couldn't open %s\n", name);
+ return grub_error (GRUB_ERR_IO, "couldn't open %s", name);
+ }
+ handle_writable = writable;
+ last_path = grub_strdup (name);
+ if (!last_path)
+ return grub_errno;
+ last_handle = handle;
+ grub_dprintf ("arcdisk", "opened %s\n", name);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_arcdisk_open (const char *name, grub_disk_t disk)
+{
+ char *fullname;
+ grub_err_t err;
+ grub_arc_err_t r;
+ struct grub_arc_fileinfo info;
+ struct arcdisk_hash_ent *hash;
+
+ if (grub_memcmp (name, "arc/", 4) != 0)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not arc device");
+ fullname = grub_arc_alt_name_to_norm (name, RAW_SUFFIX);
+ disk->data = fullname;
+ grub_dprintf ("arcdisk", "opening %s\n", fullname);
+
+ hash = arcdisk_hash_find (fullname);
+ if (!hash)
+ hash = arcdisk_hash_add (fullname);
+ if (!hash)
+ return grub_errno;
+
+ err = reopen (fullname, 0);
+ if (err)
+ return err;
+
+ r = GRUB_ARC_FIRMWARE_VECTOR->getfileinformation (last_handle, &info);
+ if (r)
+ {
+ grub_uint64_t res = 0;
+ int i;
+
+ grub_dprintf ("arcdisk", "couldn't retrieve size: %ld\n", r);
+ for (i = 40; i >= 9; i--)
+ {
+ grub_uint64_t pos = res | (1ULL << i);
+ char buf[512];
+ long unsigned count = 0;
+ grub_dprintf ("arcdisk",
+ "seek to 0x%" PRIxGRUB_UINT64_T "\n", pos);
+ if (GRUB_ARC_FIRMWARE_VECTOR->seek (last_handle, &pos, 0))
+ continue;
+ if (GRUB_ARC_FIRMWARE_VECTOR->read (last_handle, buf,
+ 0x200, &count))
+ continue;
+ if (count == 0)
+ continue;
+ res |= (1ULL << i);
+ }
+ grub_dprintf ("arcdisk",
+ "determined disk size 0x%" PRIxGRUB_UINT64_T "\n", res);
+ disk->total_sectors = (res + 0x200) >> 9;
+ }
+ else
+ disk->total_sectors = (info.end >> 9);
+
+ disk->id = hash->num;
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_arcdisk_close (grub_disk_t disk)
+{
+ grub_free (disk->data);
+}
+
+static grub_err_t
+grub_arcdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_err_t err;
+ grub_uint64_t pos = sector << 9;
+ unsigned long count;
+ grub_uint64_t totl = size << 9;
+ grub_arc_err_t r;
+
+ err = reopen (disk->data, 0);
+ if (err)
+ return err;
+ r = GRUB_ARC_FIRMWARE_VECTOR->seek (last_handle, &pos, 0);
+ if (r)
+ {
+ grub_dprintf ("arcdisk", "seek to 0x%" PRIxGRUB_UINT64_T " failed: %ld\n",
+ pos, r);
+ return grub_error (GRUB_ERR_IO, "couldn't seek");
+ }
+
+ while (totl)
+ {
+ if (GRUB_ARC_FIRMWARE_VECTOR->read (last_handle, buf,
+ totl, &count))
+ return grub_error (GRUB_ERR_READ_ERROR,
+ N_("failure reading sector 0x%llx "
+ "from `%s'"),
+ (unsigned long long) sector,
+ disk->name);
+ totl -= count;
+ buf += count;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_arcdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, const char *buf)
+{
+ grub_err_t err;
+ grub_uint64_t pos = sector << 9;
+ unsigned long count;
+ grub_uint64_t totl = size << 9;
+ grub_arc_err_t r;
+
+ err = reopen (disk->data, 1);
+ if (err)
+ return err;
+ r = GRUB_ARC_FIRMWARE_VECTOR->seek (last_handle, &pos, 0);
+ if (r)
+ {
+ grub_dprintf ("arcdisk", "seek to 0x%" PRIxGRUB_UINT64_T " failed: %ld\n",
+ pos, r);
+ return grub_error (GRUB_ERR_IO, "couldn't seek");
+ }
+
+ while (totl)
+ {
+ if (GRUB_ARC_FIRMWARE_VECTOR->write (last_handle, buf,
+ totl, &count))
+ return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx "
+ "to `%s'"),
+ (unsigned long long) sector,
+ disk->name);
+ totl -= count;
+ buf += count;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_disk_dev grub_arcdisk_dev =
+ {
+ .name = "arcdisk",
+ .id = GRUB_DISK_DEVICE_ARCDISK_ID,
+ .disk_iterate = grub_arcdisk_iterate,
+ .disk_open = grub_arcdisk_open,
+ .disk_close = grub_arcdisk_close,
+ .disk_read = grub_arcdisk_read,
+ .disk_write = grub_arcdisk_write,
+ .next = 0
+ };
+
+void
+grub_arcdisk_init (void)
+{
+ grub_disk_dev_register (&grub_arcdisk_dev);
+}
+
+void
+grub_arcdisk_fini (void)
+{
+ if (last_path)
+ {
+ GRUB_ARC_FIRMWARE_VECTOR->close (last_handle);
+ grub_free (last_path);
+ last_path = NULL;
+ last_handle = 0;
+ }
+
+ grub_disk_dev_unregister (&grub_arcdisk_dev);
+}
diff --git a/grub-core/disk/ata.c b/grub-core/disk/ata.c
new file mode 100644
index 0000000..3620a28
--- /dev/null
+++ b/grub-core/disk/ata.c
@@ -0,0 +1,685 @@
+/* ata.c - ATA disk access. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/ata.h>
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/scsi.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_ata_dev_t grub_ata_dev_list;
+
+/* Byteorder has to be changed before strings can be read. */
+static void
+grub_ata_strncpy (grub_uint16_t *dst16, grub_uint16_t *src16, grub_size_t len)
+{
+ unsigned int i;
+
+ for (i = 0; i < len / 2; i++)
+ *(dst16++) = grub_swap_bytes16 (*(src16++));
+ *dst16 = 0;
+}
+
+static void
+grub_ata_dumpinfo (struct grub_ata *dev, grub_uint16_t *info)
+{
+ grub_uint16_t text[21];
+
+ /* The device information was read, dump it for debugging. */
+ grub_ata_strncpy (text, info + 10, 20);
+ grub_dprintf ("ata", "Serial: %s\n", (char *) text);
+ grub_ata_strncpy (text, info + 23, 8);
+ grub_dprintf ("ata", "Firmware: %s\n", (char *) text);
+ grub_ata_strncpy (text, info + 27, 40);
+ grub_dprintf ("ata", "Model: %s\n", (char *) text);
+
+ if (! dev->atapi)
+ {
+ grub_dprintf ("ata", "Addressing: %d\n", dev->addr);
+ grub_dprintf ("ata", "Sectors: %lld\n", (unsigned long long) dev->size);
+ grub_dprintf ("ata", "Sector size: %u\n", 1U << dev->log_sector_size);
+ }
+}
+
+static grub_err_t
+grub_atapi_identify (struct grub_ata *dev)
+{
+ struct grub_disk_ata_pass_through_parms parms;
+ grub_uint16_t *info;
+ grub_err_t err;
+
+ info = grub_malloc (GRUB_DISK_SECTOR_SIZE);
+ if (! info)
+ return grub_errno;
+
+ grub_memset (&parms, 0, sizeof (parms));
+ parms.taskfile.disk = 0xE0;
+ parms.taskfile.cmd = GRUB_ATA_CMD_IDENTIFY_PACKET_DEVICE;
+ parms.size = GRUB_DISK_SECTOR_SIZE;
+ parms.buffer = info;
+
+ err = dev->dev->readwrite (dev, &parms, *dev->present);
+ if (err)
+ {
+ *dev->present = 0;
+ return err;
+ }
+
+ if (parms.size != GRUB_DISK_SECTOR_SIZE)
+ {
+ *dev->present = 0;
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "device cannot be identified");
+ }
+
+ dev->atapi = 1;
+
+ grub_ata_dumpinfo (dev, info);
+
+ grub_free (info);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_ata_identify (struct grub_ata *dev)
+{
+ struct grub_disk_ata_pass_through_parms parms;
+ grub_uint64_t *info64;
+ grub_uint32_t *info32;
+ grub_uint16_t *info16;
+ grub_err_t err;
+
+ if (dev->atapi)
+ return grub_atapi_identify (dev);
+
+ info64 = grub_malloc (GRUB_DISK_SECTOR_SIZE);
+ info32 = (grub_uint32_t *) info64;
+ info16 = (grub_uint16_t *) info64;
+ if (! info16)
+ return grub_errno;
+
+ grub_memset (&parms, 0, sizeof (parms));
+ parms.buffer = info16;
+ parms.size = GRUB_DISK_SECTOR_SIZE;
+ parms.taskfile.disk = 0xE0;
+
+ parms.taskfile.cmd = GRUB_ATA_CMD_IDENTIFY_DEVICE;
+
+ err = dev->dev->readwrite (dev, &parms, *dev->present);
+
+ if (err || parms.size != GRUB_DISK_SECTOR_SIZE)
+ {
+ grub_uint8_t sts = parms.taskfile.status;
+ grub_free (info16);
+ grub_errno = GRUB_ERR_NONE;
+ if ((sts & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ
+ | GRUB_ATA_STATUS_ERR)) == GRUB_ATA_STATUS_ERR
+ && (parms.taskfile.error & 0x04 /* ABRT */))
+ /* Device without ATA IDENTIFY, try ATAPI. */
+ return grub_atapi_identify (dev);
+
+ else if (sts == 0x00)
+ {
+ *dev->present = 0;
+ /* No device, return error but don't print message. */
+ return GRUB_ERR_UNKNOWN_DEVICE;
+ }
+ else
+ {
+ *dev->present = 0;
+ /* Other Error. */
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "device cannot be identified");
+ }
+ }
+
+ /* Now it is certain that this is not an ATAPI device. */
+ dev->atapi = 0;
+
+ /* CHS is always supported. */
+ dev->addr = GRUB_ATA_CHS;
+
+ /* Check if LBA is supported. */
+ if (info16[49] & grub_cpu_to_le16_compile_time ((1 << 9)))
+ {
+ /* Check if LBA48 is supported. */
+ if (info16[83] & grub_cpu_to_le16_compile_time ((1 << 10)))
+ dev->addr = GRUB_ATA_LBA48;
+ else
+ dev->addr = GRUB_ATA_LBA;
+ }
+
+ /* Determine the amount of sectors. */
+ if (dev->addr != GRUB_ATA_LBA48)
+ dev->size = grub_le_to_cpu32 (info32[30]);
+ else
+ dev->size = grub_le_to_cpu64 (info64[25]);
+
+ if (info16[106] & grub_cpu_to_le16_compile_time ((1 << 12)))
+ {
+ grub_uint32_t secsize;
+ secsize = grub_le_to_cpu32 (grub_get_unaligned32 (&info16[117]));
+ if (secsize & (secsize - 1) || !secsize
+ || secsize > 1048576)
+ secsize = 256;
+ for (dev->log_sector_size = 0;
+ (1U << dev->log_sector_size) < secsize;
+ dev->log_sector_size++);
+ dev->log_sector_size++;
+ }
+ else
+ dev->log_sector_size = 9;
+
+ /* Read CHS information. */
+ dev->cylinders = grub_le_to_cpu16 (info16[1]);
+ dev->heads = grub_le_to_cpu16 (info16[3]);
+ dev->sectors_per_track = grub_le_to_cpu16 (info16[6]);
+
+ grub_ata_dumpinfo (dev, info16);
+
+ grub_free (info16);
+
+ return 0;
+}
+
+static grub_err_t
+grub_ata_setaddress (struct grub_ata *dev,
+ struct grub_disk_ata_pass_through_parms *parms,
+ grub_disk_addr_t sector,
+ grub_size_t size,
+ grub_ata_addressing_t addressing)
+{
+ switch (addressing)
+ {
+ case GRUB_ATA_CHS:
+ {
+ unsigned int cylinder;
+ unsigned int head;
+ unsigned int sect;
+
+ if (dev->sectors_per_track == 0
+ || dev->heads == 0)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "sector %" PRIxGRUB_UINT64_T " 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)
+ / dev->heads);
+ head = ((grub_uint32_t) sector / dev->sectors_per_track) % dev->heads;
+
+ if (sect > dev->sectors_per_track
+ || cylinder > dev->cylinders
+ || head > dev->heads)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "sector %" PRIxGRUB_UINT64_T " cannot be "
+ "addressed using CHS addressing",
+ sector);
+
+ parms->taskfile.disk = 0xE0 | head;
+ parms->taskfile.sectnum = sect;
+ parms->taskfile.cyllsb = cylinder & 0xFF;
+ parms->taskfile.cylmsb = cylinder >> 8;
+
+ break;
+ }
+
+ case GRUB_ATA_LBA:
+ if (size == 256)
+ size = 0;
+ parms->taskfile.disk = 0xE0 | ((sector >> 24) & 0x0F);
+
+ parms->taskfile.sectors = size;
+ parms->taskfile.lba_low = sector & 0xFF;
+ parms->taskfile.lba_mid = (sector >> 8) & 0xFF;
+ parms->taskfile.lba_high = (sector >> 16) & 0xFF;
+ break;
+
+ case GRUB_ATA_LBA48:
+ if (size == 65536)
+ size = 0;
+
+ parms->taskfile.disk = 0xE0;
+
+ /* Set "Previous". */
+ parms->taskfile.sectors = size & 0xFF;
+ parms->taskfile.lba_low = sector & 0xFF;
+ parms->taskfile.lba_mid = (sector >> 8) & 0xFF;
+ parms->taskfile.lba_high = (sector >> 16) & 0xFF;
+
+ /* Set "Current". */
+ parms->taskfile.sectors48 = (size >> 8) & 0xFF;
+ parms->taskfile.lba48_low = (sector >> 24) & 0xFF;
+ parms->taskfile.lba48_mid = (sector >> 32) & 0xFF;
+ parms->taskfile.lba48_high = (sector >> 40) & 0xFF;
+
+ break;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf, int rw)
+{
+ struct grub_ata *ata = disk->data;
+
+ grub_ata_addressing_t addressing = ata->addr;
+ grub_size_t batch;
+ int cmd, cmd_write;
+ grub_size_t nsectors = 0;
+
+ grub_dprintf("ata", "grub_ata_readwrite (size=%llu, rw=%d)\n",
+ (unsigned long long) size, rw);
+
+ if (addressing == GRUB_ATA_LBA48 && ((sector + size) >> 28) != 0)
+ {
+ if (ata->dma)
+ {
+ cmd = GRUB_ATA_CMD_READ_SECTORS_DMA_EXT;
+ cmd_write = GRUB_ATA_CMD_WRITE_SECTORS_DMA_EXT;
+ }
+ else
+ {
+ cmd = GRUB_ATA_CMD_READ_SECTORS_EXT;
+ cmd_write = GRUB_ATA_CMD_WRITE_SECTORS_EXT;
+ }
+ }
+ else
+ {
+ if (addressing == GRUB_ATA_LBA48)
+ addressing = GRUB_ATA_LBA;
+ if (ata->dma)
+ {
+ cmd = GRUB_ATA_CMD_READ_SECTORS_DMA;
+ cmd_write = GRUB_ATA_CMD_WRITE_SECTORS_DMA;
+ }
+ else
+ {
+ cmd = GRUB_ATA_CMD_READ_SECTORS;
+ cmd_write = GRUB_ATA_CMD_WRITE_SECTORS;
+ }
+ }
+
+ if (addressing != GRUB_ATA_CHS)
+ batch = 256;
+ else
+ batch = 1;
+
+ while (nsectors < size)
+ {
+ struct grub_disk_ata_pass_through_parms parms;
+ grub_err_t err;
+
+ if (size - nsectors < batch)
+ batch = size - nsectors;
+
+ grub_dprintf("ata", "rw=%d, sector=%llu, batch=%llu\n", rw, (unsigned long long) sector, (unsigned long long) batch);
+ grub_memset (&parms, 0, sizeof (parms));
+ grub_ata_setaddress (ata, &parms, sector, batch, addressing);
+ parms.taskfile.cmd = (! rw ? cmd : cmd_write);
+ parms.buffer = buf;
+ parms.size = batch << ata->log_sector_size;
+ parms.write = rw;
+ if (ata->dma)
+ parms.dma = 1;
+
+ err = ata->dev->readwrite (ata, &parms, 0);
+ if (err)
+ return err;
+ if (parms.size != batch << ata->log_sector_size)
+ return grub_error (GRUB_ERR_READ_ERROR, "incomplete read");
+ buf += batch << ata->log_sector_size;
+ sector += batch;
+ nsectors += batch;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+
+
+static inline void
+grub_ata_real_close (struct grub_ata *ata)
+{
+ if (ata->dev->close)
+ ata->dev->close (ata);
+}
+
+static struct grub_ata *
+grub_ata_real_open (int id, int bus)
+{
+ struct grub_ata *ata;
+ grub_ata_dev_t p;
+
+ ata = grub_zalloc (sizeof (*ata));
+ if (!ata)
+ return NULL;
+ for (p = grub_ata_dev_list; p; p = p->next)
+ {
+ grub_err_t err;
+ if (p->open (id, bus, ata))
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ ata->dev = p;
+ /* Use the IDENTIFY DEVICE command to query the device. */
+ err = grub_ata_identify (ata);
+ if (err)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATA device");
+ grub_free (ata);
+ return NULL;
+ }
+ return ata;
+ }
+ grub_free (ata);
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATA device");
+ return NULL;
+}
+
+/* Context for grub_ata_iterate. */
+struct grub_ata_iterate_ctx
+{
+ grub_disk_dev_iterate_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_ata_iterate. */
+static int
+grub_ata_iterate_iter (int id, int bus, void *data)
+{
+ struct grub_ata_iterate_ctx *ctx = data;
+ struct grub_ata *ata;
+ int ret;
+ char devname[40];
+
+ ata = grub_ata_real_open (id, bus);
+
+ if (!ata)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+ if (ata->atapi)
+ {
+ grub_ata_real_close (ata);
+ return 0;
+ }
+ grub_snprintf (devname, sizeof (devname),
+ "%s%d", grub_scsi_names[id], bus);
+ ret = ctx->hook (devname, ctx->hook_data);
+ grub_ata_real_close (ata);
+ return ret;
+}
+
+static int
+grub_ata_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ struct grub_ata_iterate_ctx ctx = { hook, hook_data };
+ grub_ata_dev_t p;
+
+ for (p = grub_ata_dev_list; p; p = p->next)
+ if (p->iterate && p->iterate (grub_ata_iterate_iter, &ctx, pull))
+ return 1;
+ return 0;
+}
+
+static grub_err_t
+grub_ata_open (const char *name, grub_disk_t disk)
+{
+ unsigned id, bus;
+ struct grub_ata *ata;
+
+ for (id = 0; id < GRUB_SCSI_NUM_SUBSYSTEMS; id++)
+ if (grub_strncmp (grub_scsi_names[id], name,
+ grub_strlen (grub_scsi_names[id])) == 0
+ && grub_isdigit (name[grub_strlen (grub_scsi_names[id])]))
+ break;
+ if (id == GRUB_SCSI_NUM_SUBSYSTEMS)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not an ATA harddisk");
+ bus = grub_strtoul (name + grub_strlen (grub_scsi_names[id]), 0, 0);
+ ata = grub_ata_real_open (id, bus);
+ if (!ata)
+ return grub_errno;
+
+ if (ata->atapi)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not an ATA harddisk");
+
+ disk->total_sectors = ata->size;
+ disk->max_agglomerate = (ata->maxbuffer >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS));
+ if (disk->max_agglomerate > (256U >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS - ata->log_sector_size)))
+ disk->max_agglomerate = (256U >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS - ata->log_sector_size));
+
+ disk->log_sector_size = ata->log_sector_size;
+
+ disk->id = grub_make_scsi_id (id, bus, 0);
+
+ disk->data = ata;
+
+ return 0;
+}
+
+static void
+grub_ata_close (grub_disk_t disk)
+{
+ struct grub_ata *ata = disk->data;
+ grub_ata_real_close (ata);
+}
+
+static grub_err_t
+grub_ata_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ return grub_ata_readwrite (disk, sector, size, buf, 0);
+}
+
+static grub_err_t
+grub_ata_write (grub_disk_t disk,
+ grub_disk_addr_t sector,
+ grub_size_t size,
+ const char *buf)
+{
+ return grub_ata_readwrite (disk, sector, size, (char *) buf, 1);
+}
+
+static struct grub_disk_dev grub_atadisk_dev =
+ {
+ .name = "ATA",
+ .id = GRUB_DISK_DEVICE_ATA_ID,
+ .disk_iterate = grub_ata_iterate,
+ .disk_open = grub_ata_open,
+ .disk_close = grub_ata_close,
+ .disk_read = grub_ata_read,
+ .disk_write = grub_ata_write,
+ .next = 0
+ };
+
+
+
+/* ATAPI code. */
+
+static grub_err_t
+grub_atapi_read (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
+ grub_size_t size, char *buf)
+{
+ struct grub_ata *dev = scsi->data;
+ struct grub_disk_ata_pass_through_parms parms;
+ grub_err_t err;
+
+ grub_dprintf("ata", "grub_atapi_read (size=%llu)\n", (unsigned long long) size);
+ grub_memset (&parms, 0, sizeof (parms));
+
+ parms.taskfile.disk = 0;
+ parms.taskfile.features = 0;
+ parms.taskfile.atapi_ireason = 0;
+ parms.taskfile.atapi_cnthigh = size >> 8;
+ parms.taskfile.atapi_cntlow = size & 0xff;
+ parms.taskfile.cmd = GRUB_ATA_CMD_PACKET;
+ parms.cmd = cmd;
+ parms.cmdsize = cmdsize;
+
+ parms.size = size;
+ parms.buffer = buf;
+
+ err = dev->dev->readwrite (dev, &parms, 0);
+ if (err)
+ return err;
+
+ if (parms.size != size)
+ return grub_error (GRUB_ERR_READ_ERROR, "incomplete ATAPI read");
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_atapi_write (struct grub_scsi *scsi __attribute__((unused)),
+ grub_size_t cmdsize __attribute__((unused)),
+ char *cmd __attribute__((unused)),
+ grub_size_t size __attribute__((unused)),
+ const char *buf __attribute__((unused)))
+{
+ // XXX: scsi.mod does not use write yet.
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "ATAPI write not implemented");
+}
+
+static grub_err_t
+grub_atapi_open (int id, int bus, struct grub_scsi *scsi)
+{
+ struct grub_ata *ata;
+
+ ata = grub_ata_real_open (id, bus);
+ if (!ata)
+ return grub_errno;
+
+ if (! ata->atapi)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATAPI device");
+
+ scsi->data = ata;
+ scsi->luns = 1;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Context for grub_atapi_iterate. */
+struct grub_atapi_iterate_ctx
+{
+ grub_scsi_dev_iterate_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_atapi_iterate. */
+static int
+grub_atapi_iterate_iter (int id, int bus, void *data)
+{
+ struct grub_atapi_iterate_ctx *ctx = data;
+ struct grub_ata *ata;
+ int ret;
+
+ ata = grub_ata_real_open (id, bus);
+
+ if (!ata)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+ if (!ata->atapi)
+ {
+ grub_ata_real_close (ata);
+ return 0;
+ }
+ ret = ctx->hook (id, bus, 1, ctx->hook_data);
+ grub_ata_real_close (ata);
+ return ret;
+}
+
+static int
+grub_atapi_iterate (grub_scsi_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ struct grub_atapi_iterate_ctx ctx = { hook, hook_data };
+ grub_ata_dev_t p;
+
+ for (p = grub_ata_dev_list; p; p = p->next)
+ if (p->iterate && p->iterate (grub_atapi_iterate_iter, &ctx, pull))
+ return 1;
+ return 0;
+}
+
+static void
+grub_atapi_close (grub_scsi_t disk)
+{
+ struct grub_ata *ata = disk->data;
+ grub_ata_real_close (ata);
+}
+
+
+void
+grub_ata_dev_register (grub_ata_dev_t dev)
+{
+ dev->next = grub_ata_dev_list;
+ grub_ata_dev_list = dev;
+}
+
+void
+grub_ata_dev_unregister (grub_ata_dev_t dev)
+{
+ grub_ata_dev_t *p, q;
+
+ for (p = &grub_ata_dev_list, q = *p; q; p = &(q->next), q = q->next)
+ if (q == dev)
+ {
+ *p = q->next;
+ break;
+ }
+}
+
+static struct grub_scsi_dev grub_atapi_dev =
+ {
+ .iterate = grub_atapi_iterate,
+ .open = grub_atapi_open,
+ .close = grub_atapi_close,
+ .read = grub_atapi_read,
+ .write = grub_atapi_write,
+ .next = 0
+ };
+
+
+
+GRUB_MOD_INIT(ata)
+{
+ grub_disk_dev_register (&grub_atadisk_dev);
+
+ /* ATAPI devices are handled by scsi.mod. */
+ grub_scsi_dev_register (&grub_atapi_dev);
+}
+
+GRUB_MOD_FINI(ata)
+{
+ grub_scsi_dev_unregister (&grub_atapi_dev);
+ grub_disk_dev_unregister (&grub_atadisk_dev);
+}
diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
new file mode 100644
index 0000000..90f82b2
--- /dev/null
+++ b/grub-core/disk/cryptodisk.c
@@ -0,0 +1,1331 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2007,2010,2011,2019 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/cryptodisk.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/fs.h>
+#include <grub/file.h>
+#include <grub/procfs.h>
+#include <grub/partition.h>
+
+#ifdef GRUB_UTIL
+#include <grub/emu/hostdisk.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+grub_cryptodisk_dev_t grub_cryptodisk_list;
+
+static const struct grub_arg_option options[] =
+ {
+ {"uuid", 'u', 0, N_("Mount by UUID."), 0, 0},
+ /* TRANSLATORS: It's still restricted to cryptodisks only. */
+ {"all", 'a', 0, N_("Mount all."), 0, 0},
+ {"boot", 'b', 0, N_("Mount all volumes with `boot' flag set."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+/* Our irreducible polynom is x^128+x^7+x^2+x+1. Lowest byte of it is: */
+#define GF_POLYNOM 0x87
+static inline int GF_PER_SECTOR (const struct grub_cryptodisk *dev)
+{
+ return 1U << (dev->log_sector_size - GRUB_CRYPTODISK_GF_LOG_BYTES);
+}
+
+static grub_cryptodisk_t cryptodisk_list = NULL;
+static grub_uint8_t last_cryptodisk_id = 0;
+
+static void
+gf_mul_x (grub_uint8_t *g)
+{
+ int over = 0, over2 = 0;
+ unsigned j;
+
+ for (j = 0; j < GRUB_CRYPTODISK_GF_BYTES; j++)
+ {
+ over2 = !!(g[j] & 0x80);
+ g[j] <<= 1;
+ g[j] |= over;
+ over = over2;
+ }
+ if (over)
+ g[0] ^= GF_POLYNOM;
+}
+
+
+static void
+gf_mul_x_be (grub_uint8_t *g)
+{
+ int over = 0, over2 = 0;
+ int j;
+
+ for (j = (int) GRUB_CRYPTODISK_GF_BYTES - 1; j >= 0; j--)
+ {
+ over2 = !!(g[j] & 0x80);
+ g[j] <<= 1;
+ g[j] |= over;
+ over = over2;
+ }
+ if (over)
+ g[GRUB_CRYPTODISK_GF_BYTES - 1] ^= GF_POLYNOM;
+}
+
+static void
+gf_mul_be (grub_uint8_t *o, const grub_uint8_t *a, const grub_uint8_t *b)
+{
+ unsigned i;
+ grub_uint8_t t[GRUB_CRYPTODISK_GF_BYTES];
+ grub_memset (o, 0, GRUB_CRYPTODISK_GF_BYTES);
+ grub_memcpy (t, b, GRUB_CRYPTODISK_GF_BYTES);
+ for (i = 0; i < GRUB_CRYPTODISK_GF_SIZE; i++)
+ {
+ if (((a[GRUB_CRYPTODISK_GF_BYTES - i / GRUB_CHAR_BIT - 1] >> (i % GRUB_CHAR_BIT))) & 1)
+ grub_crypto_xor (o, o, t, GRUB_CRYPTODISK_GF_BYTES);
+ gf_mul_x_be (t);
+ }
+}
+
+static gcry_err_code_t
+grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher,
+ void *out, void *in, grub_size_t size,
+ void *iv)
+{
+ grub_uint8_t *inptr, *outptr, *end;
+ grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
+ grub_size_t blocksize;
+ if (!cipher->cipher->decrypt)
+ return GPG_ERR_NOT_SUPPORTED;
+ 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 += blocksize, outptr += blocksize)
+ {
+ grub_memcpy (ivt, inptr, blocksize);
+ cipher->cipher->decrypt (cipher->ctx, outptr, inptr);
+ grub_crypto_xor (outptr, outptr, iv, blocksize);
+ grub_crypto_xor (iv, ivt, outptr, blocksize);
+ }
+ return GPG_ERR_NO_ERROR;
+}
+
+static gcry_err_code_t
+grub_crypto_pcbc_encrypt (grub_crypto_cipher_handle_t cipher,
+ void *out, void *in, grub_size_t size,
+ void *iv)
+{
+ grub_uint8_t *inptr, *outptr, *end;
+ grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
+ grub_size_t blocksize;
+ if (!cipher->cipher->encrypt)
+ return GPG_ERR_NOT_SUPPORTED;
+ 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 += blocksize, outptr += 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, blocksize);
+ }
+ return GPG_ERR_NO_ERROR;
+}
+
+struct lrw_sector
+{
+ grub_uint8_t low[GRUB_CRYPTODISK_GF_BYTES];
+ grub_uint8_t high[GRUB_CRYPTODISK_GF_BYTES];
+ grub_uint8_t low_byte, low_byte_c;
+};
+
+static void
+generate_lrw_sector (struct lrw_sector *sec,
+ const struct grub_cryptodisk *dev,
+ const grub_uint8_t *iv)
+{
+ grub_uint8_t idx[GRUB_CRYPTODISK_GF_BYTES];
+ grub_uint16_t c;
+ int j;
+ grub_memcpy (idx, iv, GRUB_CRYPTODISK_GF_BYTES);
+ sec->low_byte = (idx[GRUB_CRYPTODISK_GF_BYTES - 1]
+ & (GF_PER_SECTOR (dev) - 1));
+ sec->low_byte_c = (((GF_PER_SECTOR (dev) - 1) & ~sec->low_byte) + 1);
+ idx[GRUB_CRYPTODISK_GF_BYTES - 1] &= ~(GF_PER_SECTOR (dev) - 1);
+ gf_mul_be (sec->low, dev->lrw_key, idx);
+ if (!sec->low_byte)
+ return;
+
+ c = idx[GRUB_CRYPTODISK_GF_BYTES - 1] + GF_PER_SECTOR (dev);
+ if (c & 0x100)
+ {
+ for (j = GRUB_CRYPTODISK_GF_BYTES - 2; j >= 0; j--)
+ {
+ idx[j]++;
+ if (idx[j] != 0)
+ break;
+ }
+ }
+ idx[GRUB_CRYPTODISK_GF_BYTES - 1] = c;
+ gf_mul_be (sec->high, dev->lrw_key, idx);
+}
+
+static void __attribute__ ((unused))
+lrw_xor (const struct lrw_sector *sec,
+ const struct grub_cryptodisk *dev,
+ grub_uint8_t *b)
+{
+ unsigned i;
+
+ for (i = 0; i < sec->low_byte_c * GRUB_CRYPTODISK_GF_BYTES;
+ i += GRUB_CRYPTODISK_GF_BYTES)
+ grub_crypto_xor (b + i, b + i, sec->low, GRUB_CRYPTODISK_GF_BYTES);
+ grub_crypto_xor (b, b, dev->lrw_precalc + GRUB_CRYPTODISK_GF_BYTES * sec->low_byte,
+ sec->low_byte_c * GRUB_CRYPTODISK_GF_BYTES);
+ if (!sec->low_byte)
+ return;
+
+ for (i = sec->low_byte_c * GRUB_CRYPTODISK_GF_BYTES;
+ i < (1U << dev->log_sector_size); i += GRUB_CRYPTODISK_GF_BYTES)
+ grub_crypto_xor (b + i, b + i, sec->high, GRUB_CRYPTODISK_GF_BYTES);
+ grub_crypto_xor (b + sec->low_byte_c * GRUB_CRYPTODISK_GF_BYTES,
+ b + sec->low_byte_c * GRUB_CRYPTODISK_GF_BYTES,
+ dev->lrw_precalc, sec->low_byte * GRUB_CRYPTODISK_GF_BYTES);
+}
+
+static gcry_err_code_t
+grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
+ grub_uint8_t * data, grub_size_t len,
+ grub_disk_addr_t sector, grub_size_t log_sector_size,
+ int do_encrypt)
+{
+ grub_size_t i;
+ gcry_err_code_t err;
+
+ if (dev->cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
+ return GPG_ERR_INV_ARG;
+
+ /* The only mode without IV. */
+ if (dev->mode == GRUB_CRYPTODISK_MODE_ECB && !dev->rekey)
+ return (do_encrypt ? grub_crypto_ecb_encrypt (dev->cipher, data, data, len)
+ : grub_crypto_ecb_decrypt (dev->cipher, data, data, len));
+
+ for (i = 0; i < len; i += (1U << log_sector_size))
+ {
+ grub_size_t sz = ((dev->cipher->cipher->blocksize
+ + sizeof (grub_uint32_t) - 1)
+ / sizeof (grub_uint32_t));
+ grub_uint32_t iv[(GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE + 3) / 4];
+
+ if (dev->rekey)
+ {
+ grub_uint64_t zone = sector >> dev->rekey_shift;
+ if (zone != dev->last_rekey)
+ {
+ err = dev->rekey (dev, zone);
+ if (err)
+ return err;
+ dev->last_rekey = zone;
+ }
+ }
+
+ grub_memset (iv, 0, sizeof (iv));
+ switch (dev->mode_iv)
+ {
+ case GRUB_CRYPTODISK_MODE_IV_NULL:
+ break;
+ case GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64_HASH:
+ {
+ grub_uint64_t tmp;
+ void *ctx;
+
+ ctx = grub_zalloc (dev->iv_hash->contextsize);
+ if (!ctx)
+ return GPG_ERR_OUT_OF_MEMORY;
+
+ tmp = grub_cpu_to_le64 (sector << log_sector_size);
+ dev->iv_hash->init (ctx);
+ dev->iv_hash->write (ctx, dev->iv_prefix, dev->iv_prefix_len);
+ dev->iv_hash->write (ctx, &tmp, sizeof (tmp));
+ dev->iv_hash->final (ctx);
+
+ grub_memcpy (iv, dev->iv_hash->read (ctx), sizeof (iv));
+ grub_free (ctx);
+ }
+ break;
+ case GRUB_CRYPTODISK_MODE_IV_PLAIN64:
+ case GRUB_CRYPTODISK_MODE_IV_PLAIN:
+ /*
+ * The IV is a 32 or 64 bit value of the dm-crypt native sector
+ * number. If using 32 bit IV mode, zero out the most significant
+ * 32 bits.
+ */
+ {
+ grub_uint64_t iv64;
+
+ iv64 = grub_cpu_to_le64 (sector << (log_sector_size
+ - GRUB_CRYPTODISK_IV_LOG_SIZE));
+ grub_set_unaligned64 (iv, iv64);
+ if (dev->mode_iv == GRUB_CRYPTODISK_MODE_IV_PLAIN)
+ iv[1] = 0;
+ }
+ break;
+ case GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64:
+ /* The IV is the 64 bit byte offset of the sector. */
+ iv[1] = grub_cpu_to_le32 (sector >> (GRUB_TYPE_BITS (iv[1])
+ - log_sector_size));
+ iv[0] = grub_cpu_to_le32 ((sector << log_sector_size)
+ & GRUB_TYPE_U_MAX (iv[0]));
+ break;
+ case GRUB_CRYPTODISK_MODE_IV_BENBI:
+ {
+ grub_uint64_t num = (sector << dev->benbi_log) + 1;
+ iv[sz - 2] = grub_cpu_to_be32 (num >> GRUB_TYPE_BITS (iv[0]));
+ iv[sz - 1] = grub_cpu_to_be32 (num & GRUB_TYPE_U_MAX (iv[0]));
+ }
+ break;
+ case GRUB_CRYPTODISK_MODE_IV_ESSIV:
+ iv[0] = grub_cpu_to_le32 (sector & GRUB_TYPE_U_MAX (iv[0]));
+ err = grub_crypto_ecb_encrypt (dev->essiv_cipher, iv, iv,
+ dev->cipher->cipher->blocksize);
+ if (err)
+ return err;
+ }
+
+ switch (dev->mode)
+ {
+ case GRUB_CRYPTODISK_MODE_CBC:
+ if (do_encrypt)
+ err = grub_crypto_cbc_encrypt (dev->cipher, data + i, data + i,
+ ((grub_size_t) 1 << log_sector_size), iv);
+ else
+ err = grub_crypto_cbc_decrypt (dev->cipher, data + i, data + i,
+ ((grub_size_t) 1 << log_sector_size), iv);
+ if (err)
+ return err;
+ break;
+
+ case GRUB_CRYPTODISK_MODE_PCBC:
+ if (do_encrypt)
+ err = grub_crypto_pcbc_encrypt (dev->cipher, data + i, data + i,
+ ((grub_size_t) 1 << log_sector_size), iv);
+ else
+ err = grub_crypto_pcbc_decrypt (dev->cipher, data + i, data + i,
+ ((grub_size_t) 1 << log_sector_size), iv);
+ if (err)
+ return err;
+ break;
+ case GRUB_CRYPTODISK_MODE_XTS:
+ {
+ unsigned j;
+ err = grub_crypto_ecb_encrypt (dev->secondary_cipher, iv, iv,
+ dev->cipher->cipher->blocksize);
+ if (err)
+ return err;
+
+ for (j = 0; j < (1U << log_sector_size);
+ j += dev->cipher->cipher->blocksize)
+ {
+ grub_crypto_xor (data + i + j, data + i + j, iv,
+ dev->cipher->cipher->blocksize);
+ if (do_encrypt)
+ err = grub_crypto_ecb_encrypt (dev->cipher, data + i + j,
+ data + i + j,
+ dev->cipher->cipher->blocksize);
+ else
+ err = grub_crypto_ecb_decrypt (dev->cipher, data + i + j,
+ data + i + j,
+ dev->cipher->cipher->blocksize);
+ if (err)
+ return err;
+ grub_crypto_xor (data + i + j, data + i + j, iv,
+ dev->cipher->cipher->blocksize);
+ gf_mul_x ((grub_uint8_t *) iv);
+ }
+ }
+ break;
+ case GRUB_CRYPTODISK_MODE_LRW:
+ {
+ struct lrw_sector sec;
+
+ generate_lrw_sector (&sec, dev, (grub_uint8_t *) iv);
+ lrw_xor (&sec, dev, data + i);
+
+ if (do_encrypt)
+ err = grub_crypto_ecb_encrypt (dev->cipher, data + i,
+ data + i,
+ (1U << log_sector_size));
+ else
+ err = grub_crypto_ecb_decrypt (dev->cipher, data + i,
+ data + i,
+ (1U << log_sector_size));
+ if (err)
+ return err;
+ lrw_xor (&sec, dev, data + i);
+ }
+ break;
+ case GRUB_CRYPTODISK_MODE_ECB:
+ if (do_encrypt)
+ err = grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i,
+ (1U << log_sector_size));
+ else
+ err = grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i,
+ (1U << log_sector_size));
+ if (err)
+ return err;
+ break;
+ default:
+ return GPG_ERR_NOT_IMPLEMENTED;
+ }
+ sector++;
+ }
+ return GPG_ERR_NO_ERROR;
+}
+
+gcry_err_code_t
+grub_cryptodisk_decrypt (struct grub_cryptodisk *dev,
+ grub_uint8_t * data, grub_size_t len,
+ grub_disk_addr_t sector, grub_size_t log_sector_size)
+{
+ return grub_cryptodisk_endecrypt (dev, data, len, sector, log_sector_size, 0);
+}
+
+grub_err_t
+grub_cryptodisk_setcipher (grub_cryptodisk_t crypt, const char *ciphername, const char *ciphermode)
+{
+ const char *cipheriv = NULL;
+ grub_crypto_cipher_handle_t cipher = NULL, secondary_cipher = NULL;
+ grub_crypto_cipher_handle_t essiv_cipher = NULL;
+ const gcry_md_spec_t *essiv_hash = NULL;
+ const struct gcry_cipher_spec *ciph;
+ grub_cryptodisk_mode_t mode;
+ grub_cryptodisk_mode_iv_t mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN64;
+ int benbi_log = 0;
+ grub_err_t ret = GRUB_ERR_NONE;
+
+ ciph = grub_crypto_lookup_cipher_by_name (ciphername);
+ if (!ciph)
+ {
+ ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, "Cipher %s isn't available",
+ ciphername);
+ goto err;
+ }
+
+ /* Configure the cipher used for the bulk data. */
+ cipher = grub_crypto_cipher_open (ciph);
+ if (!cipher)
+ {
+ ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, "Cipher %s could not be initialized",
+ ciphername);
+ goto err;
+ }
+
+ /* Configure the cipher mode. */
+ if (grub_strcmp (ciphermode, "ecb") == 0)
+ {
+ mode = GRUB_CRYPTODISK_MODE_ECB;
+ mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN;
+ cipheriv = NULL;
+ }
+ else if (grub_strcmp (ciphermode, "plain") == 0)
+ {
+ mode = GRUB_CRYPTODISK_MODE_CBC;
+ mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN;
+ cipheriv = NULL;
+ }
+ else if (grub_memcmp (ciphermode, "cbc-", sizeof ("cbc-") - 1) == 0)
+ {
+ mode = GRUB_CRYPTODISK_MODE_CBC;
+ cipheriv = ciphermode + sizeof ("cbc-") - 1;
+ }
+ else if (grub_memcmp (ciphermode, "pcbc-", sizeof ("pcbc-") - 1) == 0)
+ {
+ mode = GRUB_CRYPTODISK_MODE_PCBC;
+ cipheriv = ciphermode + sizeof ("pcbc-") - 1;
+ }
+ else if (grub_memcmp (ciphermode, "xts-", sizeof ("xts-") - 1) == 0)
+ {
+ mode = GRUB_CRYPTODISK_MODE_XTS;
+ cipheriv = ciphermode + sizeof ("xts-") - 1;
+ secondary_cipher = grub_crypto_cipher_open (ciph);
+ if (!secondary_cipher)
+ {
+ ret = grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ "Secondary cipher %s isn't available", ciphername);
+ goto err;
+ }
+ if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
+ {
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Unsupported XTS block size: %" PRIuGRUB_SIZE,
+ cipher->cipher->blocksize);
+ goto err;
+ }
+ if (secondary_cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
+ {
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Unsupported XTS block size: %" PRIuGRUB_SIZE,
+ secondary_cipher->cipher->blocksize);
+ goto err;
+ }
+ }
+ else if (grub_memcmp (ciphermode, "lrw-", sizeof ("lrw-") - 1) == 0)
+ {
+ mode = GRUB_CRYPTODISK_MODE_LRW;
+ cipheriv = ciphermode + sizeof ("lrw-") - 1;
+ if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
+ {
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Unsupported LRW block size: %" PRIuGRUB_SIZE,
+ cipher->cipher->blocksize);
+ goto err;
+ }
+ }
+ else
+ {
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown cipher mode: %s",
+ ciphermode);
+ goto err;
+ }
+
+ if (cipheriv == NULL)
+ ;
+ else if (grub_memcmp (cipheriv, "plain64", sizeof ("plain64") - 1) == 0)
+ mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN64;
+ else if (grub_memcmp (cipheriv, "plain", sizeof ("plain") - 1) == 0)
+ mode_iv = GRUB_CRYPTODISK_MODE_IV_PLAIN;
+ else if (grub_memcmp (cipheriv, "benbi", sizeof ("benbi") - 1) == 0)
+ {
+ if (cipher->cipher->blocksize & (cipher->cipher->blocksize - 1)
+ || cipher->cipher->blocksize == 0)
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Unsupported benbi blocksize: %" PRIuGRUB_SIZE,
+ 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++);
+ mode_iv = GRUB_CRYPTODISK_MODE_IV_BENBI;
+ }
+ else if (grub_memcmp (cipheriv, "null", sizeof ("null") - 1) == 0)
+ mode_iv = GRUB_CRYPTODISK_MODE_IV_NULL;
+ else if (grub_memcmp (cipheriv, "essiv:", sizeof ("essiv:") - 1) == 0)
+ {
+ const char *hash_str = cipheriv + 6;
+
+ mode_iv = GRUB_CRYPTODISK_MODE_IV_ESSIV;
+
+ /* Configure the hash and cipher used for ESSIV. */
+ essiv_hash = grub_crypto_lookup_md_by_name (hash_str);
+ if (!essiv_hash)
+ {
+ ret = grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ "Couldn't load %s hash", hash_str);
+ goto err;
+ }
+ essiv_cipher = grub_crypto_cipher_open (ciph);
+ if (!essiv_cipher)
+ {
+ ret = grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ "Couldn't load %s cipher", ciphername);
+ goto err;
+ }
+ }
+ else
+ {
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown IV mode: %s",
+ cipheriv);
+ goto err;
+ }
+
+ crypt->cipher = cipher;
+ crypt->benbi_log = benbi_log;
+ crypt->mode = mode;
+ crypt->mode_iv = mode_iv;
+ crypt->secondary_cipher = secondary_cipher;
+ crypt->essiv_cipher = essiv_cipher;
+ crypt->essiv_hash = essiv_hash;
+
+err:
+ if (ret)
+ {
+ grub_crypto_cipher_close (cipher);
+ grub_crypto_cipher_close (secondary_cipher);
+ }
+ return ret;
+}
+
+gcry_err_code_t
+grub_cryptodisk_setkey (grub_cryptodisk_t dev, grub_uint8_t *key, grub_size_t keysize)
+{
+ gcry_err_code_t err;
+ int real_keysize;
+
+ real_keysize = keysize;
+ if (dev->mode == GRUB_CRYPTODISK_MODE_XTS)
+ real_keysize /= 2;
+ if (dev->mode == GRUB_CRYPTODISK_MODE_LRW)
+ real_keysize -= dev->cipher->cipher->blocksize;
+
+ /* Set the PBKDF2 output as the cipher key. */
+ err = grub_crypto_cipher_set_key (dev->cipher, key, real_keysize);
+ if (err)
+ return err;
+ grub_memcpy (dev->key, key, keysize);
+ dev->keysize = keysize;
+
+ /* Configure ESSIV if necessary. */
+ if (dev->mode_iv == GRUB_CRYPTODISK_MODE_IV_ESSIV)
+ {
+ grub_size_t essiv_keysize = dev->essiv_hash->mdlen;
+ grub_uint8_t hashed_key[GRUB_CRYPTO_MAX_MDLEN];
+ if (essiv_keysize > GRUB_CRYPTO_MAX_MDLEN)
+ return GPG_ERR_INV_ARG;
+
+ grub_crypto_hash (dev->essiv_hash, hashed_key, key, keysize);
+ err = grub_crypto_cipher_set_key (dev->essiv_cipher,
+ hashed_key, essiv_keysize);
+ if (err)
+ return err;
+ }
+ if (dev->mode == GRUB_CRYPTODISK_MODE_XTS)
+ {
+ err = grub_crypto_cipher_set_key (dev->secondary_cipher,
+ key + real_keysize,
+ keysize / 2);
+ if (err)
+ return err;
+ }
+
+ if (dev->mode == GRUB_CRYPTODISK_MODE_LRW)
+ {
+ unsigned i;
+ grub_uint8_t idx[GRUB_CRYPTODISK_GF_BYTES];
+
+ grub_free (dev->lrw_precalc);
+ grub_memcpy (dev->lrw_key, key + real_keysize,
+ dev->cipher->cipher->blocksize);
+ dev->lrw_precalc = grub_malloc ((1U << dev->log_sector_size));
+ if (!dev->lrw_precalc)
+ return GPG_ERR_OUT_OF_MEMORY;
+ grub_memset (idx, 0, GRUB_CRYPTODISK_GF_BYTES);
+ for (i = 0; i < (1U << dev->log_sector_size);
+ i += GRUB_CRYPTODISK_GF_BYTES)
+ {
+ idx[GRUB_CRYPTODISK_GF_BYTES - 1] = i / GRUB_CRYPTODISK_GF_BYTES;
+ gf_mul_be (dev->lrw_precalc + i, idx, dev->lrw_key);
+ }
+ }
+ return GPG_ERR_NO_ERROR;
+}
+
+static int
+grub_cryptodisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ grub_cryptodisk_t i;
+
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ for (i = cryptodisk_list; i != NULL; i = i->next)
+ {
+ char buf[30];
+ grub_snprintf (buf, sizeof (buf), "crypto%lu", i->id);
+ if (hook (buf, hook_data))
+ return 1;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cryptodisk_open (const char *name, grub_disk_t disk)
+{
+ grub_cryptodisk_t dev;
+
+ if (grub_memcmp (name, "crypto", sizeof ("crypto") - 1) != 0)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "No such device");
+
+ if (grub_memcmp (name, "cryptouuid/", sizeof ("cryptouuid/") - 1) == 0)
+ {
+ for (dev = cryptodisk_list; dev != NULL; dev = dev->next)
+ if (grub_strcasecmp (name + sizeof ("cryptouuid/") - 1, dev->uuid) == 0)
+ break;
+ }
+ else
+ {
+ unsigned long id = grub_strtoul (name + sizeof ("crypto") - 1, 0, 0);
+ if (grub_errno)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "No such device");
+ /* Search for requested device in the list of CRYPTODISK devices. */
+ for (dev = cryptodisk_list; dev != NULL; dev = dev->next)
+ if (dev->id == id)
+ break;
+ }
+ if (!dev)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "No such device");
+
+ disk->log_sector_size = dev->log_sector_size;
+
+#ifdef GRUB_UTIL
+ if (dev->cheat)
+ {
+ if (!GRUB_UTIL_FD_IS_VALID (dev->cheat_fd))
+ dev->cheat_fd = grub_util_fd_open (dev->cheat, GRUB_UTIL_FD_O_RDONLY);
+ if (!GRUB_UTIL_FD_IS_VALID (dev->cheat_fd))
+ return grub_error (GRUB_ERR_IO, N_("cannot open `%s': %s"),
+ dev->cheat, grub_util_fd_strerror ());
+ }
+#endif
+
+ if (!dev->source_disk)
+ {
+ grub_dprintf ("cryptodisk", "Opening device %s\n", name);
+ /* Try to open the source disk and populate the requested disk. */
+ dev->source_disk = grub_disk_open (dev->source);
+ if (!dev->source_disk)
+ return grub_errno;
+ }
+
+ disk->data = dev;
+ disk->total_sectors = dev->total_sectors;
+ disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
+ disk->id = dev->id;
+ dev->ref++;
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_cryptodisk_close (grub_disk_t disk)
+{
+ grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
+ grub_dprintf ("cryptodisk", "Closing disk\n");
+
+ dev->ref--;
+
+ if (dev->ref != 0)
+ return;
+#ifdef GRUB_UTIL
+ if (dev->cheat)
+ {
+ grub_util_fd_close (dev->cheat_fd);
+ dev->cheat_fd = GRUB_UTIL_FD_INVALID;
+ }
+#endif
+ grub_disk_close (dev->source_disk);
+ dev->source_disk = NULL;
+}
+
+static grub_err_t
+grub_cryptodisk_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
+ grub_err_t err;
+ gcry_err_code_t gcry_err;
+
+#ifdef GRUB_UTIL
+ if (dev->cheat)
+ {
+ int r;
+ r = grub_util_fd_seek (dev->cheat_fd, sector << disk->log_sector_size);
+ if (r)
+ return grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot seek `%s': %s"),
+ dev->cheat, grub_util_fd_strerror ());
+ if (grub_util_fd_read (dev->cheat_fd, buf, size << disk->log_sector_size)
+ != (ssize_t) (size << disk->log_sector_size))
+ return grub_error (GRUB_ERR_READ_ERROR, N_("cannot read `%s': %s"),
+ dev->cheat, grub_util_fd_strerror ());
+ return GRUB_ERR_NONE;
+ }
+#endif
+
+ grub_dprintf ("cryptodisk",
+ "Reading %" PRIuGRUB_SIZE " sectors from sector 0x%"
+ PRIxGRUB_UINT64_T " with offset of %" PRIuGRUB_UINT64_T "\n",
+ size, sector, dev->offset_sectors);
+
+ err = grub_disk_read (dev->source_disk,
+ grub_disk_from_native_sector (disk, sector + dev->offset_sectors),
+ 0, size << disk->log_sector_size, buf);
+ if (err)
+ {
+ grub_dprintf ("cryptodisk", "grub_disk_read failed with error %d\n", err);
+ return err;
+ }
+ gcry_err = grub_cryptodisk_endecrypt (dev, (grub_uint8_t *) buf,
+ size << disk->log_sector_size,
+ sector, dev->log_sector_size, 0);
+ return grub_crypto_gcry_error (gcry_err);
+}
+
+static grub_err_t
+grub_cryptodisk_write (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, const char *buf)
+{
+ grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
+ gcry_err_code_t gcry_err;
+ char *tmp;
+ grub_err_t err;
+
+#ifdef GRUB_UTIL
+ if (dev->cheat)
+ {
+ int r;
+ r = grub_util_fd_seek (dev->cheat_fd, sector << disk->log_sector_size);
+ if (r)
+ return grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot seek `%s': %s"),
+ dev->cheat, grub_util_fd_strerror ());
+ if (grub_util_fd_write (dev->cheat_fd, buf, size << disk->log_sector_size)
+ != (ssize_t) (size << disk->log_sector_size))
+ return grub_error (GRUB_ERR_READ_ERROR, N_("cannot read `%s': %s"),
+ dev->cheat, grub_util_fd_strerror ());
+ return GRUB_ERR_NONE;
+ }
+#endif
+
+ tmp = grub_malloc (size << disk->log_sector_size);
+ if (!tmp)
+ return grub_errno;
+ grub_memcpy (tmp, buf, size << disk->log_sector_size);
+
+ grub_dprintf ("cryptodisk",
+ "Writing %" PRIuGRUB_SIZE " sectors to sector 0x%"
+ PRIxGRUB_UINT64_T " with offset of %" PRIuGRUB_UINT64_T "\n",
+ size, sector, dev->offset_sectors);
+
+ gcry_err = grub_cryptodisk_endecrypt (dev, (grub_uint8_t *) tmp,
+ size << disk->log_sector_size,
+ sector, disk->log_sector_size, 1);
+ if (gcry_err)
+ {
+ grub_free (tmp);
+ return grub_crypto_gcry_error (gcry_err);
+ }
+
+ /* Since ->write was called so disk.mod is loaded but be paranoid */
+ sector = sector + dev->offset_sectors;
+ if (grub_disk_write_weak)
+ err = grub_disk_write_weak (dev->source_disk,
+ grub_disk_from_native_sector (disk, sector),
+ 0, size << disk->log_sector_size, tmp);
+ else
+ err = grub_error (GRUB_ERR_BUG, "disk.mod not loaded");
+ grub_free (tmp);
+ return err;
+}
+
+#ifdef GRUB_UTIL
+static grub_disk_memberlist_t
+grub_cryptodisk_memberlist (grub_disk_t disk)
+{
+ grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
+ grub_disk_memberlist_t list = NULL;
+
+ list = grub_malloc (sizeof (*list));
+ if (list)
+ {
+ list->disk = dev->source_disk;
+ list->next = NULL;
+ }
+
+ return list;
+}
+#endif
+
+static void
+cryptodisk_cleanup (void)
+{
+#if 0
+ grub_cryptodisk_t dev = cryptodisk_list;
+ grub_cryptodisk_t tmp;
+
+ while (dev != NULL)
+ {
+ grub_free (dev->source);
+ grub_free (dev->cipher);
+ grub_free (dev->secondary_cipher);
+ grub_free (dev->essiv_cipher);
+ tmp = dev->next;
+ grub_free (dev);
+ dev = tmp;
+ }
+#endif
+}
+
+grub_err_t
+grub_cryptodisk_insert (grub_cryptodisk_t newdev, const char *name,
+ grub_disk_t source)
+{
+ newdev->source = grub_strdup (name);
+ if (!newdev->source)
+ {
+ grub_free (newdev);
+ return grub_errno;
+ }
+
+ 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;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_cryptodisk_t
+grub_cryptodisk_get_by_uuid (const char *uuid)
+{
+ grub_cryptodisk_t dev;
+ for (dev = cryptodisk_list; dev != NULL; dev = dev->next)
+ if (grub_strcasecmp (dev->uuid, uuid) == 0)
+ return dev;
+ return NULL;
+}
+
+grub_cryptodisk_t
+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)
+ if ((disk->partition && grub_partition_get_start (disk->partition) == dev->partition_start) ||
+ (!disk->partition && dev->partition_start == 0))
+ return dev;
+ return NULL;
+}
+
+#ifdef GRUB_UTIL
+grub_err_t
+grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
+ grub_disk_t source, const char *cheat)
+{
+ newdev->cheat = grub_strdup (cheat);
+ newdev->source = grub_strdup (name);
+ if (!newdev->source || !newdev->cheat)
+ {
+ grub_free (newdev->source);
+ grub_free (newdev->cheat);
+ return grub_errno;
+ }
+
+ 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;
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_util_cryptodisk_get_abstraction (grub_disk_t disk,
+ void (*cb) (const char *val, void *data),
+ void *data)
+{
+ grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
+
+ cb ("cryptodisk", data);
+ cb (dev->modname, data);
+
+ if (dev->cipher)
+ cb (dev->cipher->cipher->modname, data);
+ if (dev->secondary_cipher)
+ cb (dev->secondary_cipher->cipher->modname, data);
+ if (dev->essiv_cipher)
+ cb (dev->essiv_cipher->cipher->modname, data);
+ if (dev->hash)
+ cb (dev->hash->modname, data);
+ if (dev->essiv_hash)
+ cb (dev->essiv_hash->modname, data);
+ if (dev->iv_hash)
+ cb (dev->iv_hash->modname, data);
+}
+
+const char *
+grub_util_cryptodisk_get_uuid (grub_disk_t disk)
+{
+ grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
+ return dev->uuid;
+}
+
+#endif
+
+static int check_boot, have_it;
+static char *search_uuid;
+
+static void
+cryptodisk_close (grub_cryptodisk_t dev)
+{
+ grub_crypto_cipher_close (dev->cipher);
+ grub_crypto_cipher_close (dev->secondary_cipher);
+ grub_crypto_cipher_close (dev->essiv_cipher);
+ grub_free (dev);
+}
+
+static grub_err_t
+grub_cryptodisk_scan_device_real (const char *name, grub_disk_t source)
+{
+ grub_err_t err;
+ grub_cryptodisk_t dev;
+ grub_cryptodisk_dev_t cr;
+
+ dev = grub_cryptodisk_get_by_source_disk (source);
+
+ if (dev)
+ return GRUB_ERR_NONE;
+
+ FOR_CRYPTODISK_DEVS (cr)
+ {
+ dev = cr->scan (source, search_uuid, check_boot);
+ if (grub_errno)
+ return grub_errno;
+ if (!dev)
+ continue;
+
+ err = cr->recover_key (source, dev);
+ if (err)
+ {
+ cryptodisk_close (dev);
+ return err;
+ }
+
+ grub_cryptodisk_insert (dev, name, source);
+
+ have_it = 1;
+
+ return GRUB_ERR_NONE;
+ }
+ return GRUB_ERR_NONE;
+}
+
+#ifdef GRUB_UTIL
+#include <grub/util/misc.h>
+grub_err_t
+grub_cryptodisk_cheat_mount (const char *sourcedev, const char *cheat)
+{
+ grub_err_t err;
+ grub_cryptodisk_t dev;
+ grub_cryptodisk_dev_t cr;
+ grub_disk_t source;
+
+ /* Try to open disk. */
+ source = grub_disk_open (sourcedev);
+ if (!source)
+ return grub_errno;
+
+ dev = grub_cryptodisk_get_by_source_disk (source);
+
+ if (dev)
+ {
+ grub_disk_close (source);
+ return GRUB_ERR_NONE;
+ }
+
+ FOR_CRYPTODISK_DEVS (cr)
+ {
+ dev = cr->scan (source, search_uuid, check_boot);
+ if (grub_errno)
+ return grub_errno;
+ if (!dev)
+ continue;
+
+ grub_util_info ("cheatmounted %s (%s) at %s", sourcedev, dev->modname,
+ cheat);
+ err = grub_cryptodisk_cheat_insert (dev, sourcedev, source, cheat);
+ grub_disk_close (source);
+ if (err)
+ grub_free (dev);
+
+ return GRUB_ERR_NONE;
+ }
+
+ grub_disk_close (source);
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+static int
+grub_cryptodisk_scan_device (const char *name,
+ void *data __attribute__ ((unused)))
+{
+ grub_err_t err;
+ grub_disk_t source;
+
+ /* Try to open disk. */
+ source = grub_disk_open (name);
+ if (!source)
+ {
+ grub_print_error ();
+ return 0;
+ }
+
+ err = grub_cryptodisk_scan_device_real (name, source);
+
+ grub_disk_close (source);
+
+ if (err)
+ grub_print_error ();
+ return have_it && search_uuid ? 1 : 0;
+}
+
+static grub_err_t
+grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+
+ if (argc < 1 && !state[1].set && !state[2].set)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required");
+
+ have_it = 0;
+ if (state[0].set)
+ {
+ grub_cryptodisk_t dev;
+
+ dev = grub_cryptodisk_get_by_uuid (args[0]);
+ if (dev)
+ {
+ grub_dprintf ("cryptodisk",
+ "already mounted as crypto%lu\n", dev->id);
+ return GRUB_ERR_NONE;
+ }
+
+ check_boot = state[2].set;
+ search_uuid = args[0];
+ grub_device_iterate (&grub_cryptodisk_scan_device, NULL);
+ search_uuid = NULL;
+
+ if (!have_it)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no such cryptodisk found");
+ return GRUB_ERR_NONE;
+ }
+ else if (state[1].set || (argc == 0 && state[2].set))
+ {
+ search_uuid = NULL;
+ check_boot = state[2].set;
+ grub_device_iterate (&grub_cryptodisk_scan_device, NULL);
+ search_uuid = NULL;
+ return GRUB_ERR_NONE;
+ }
+ else
+ {
+ grub_err_t err;
+ grub_disk_t disk;
+ grub_cryptodisk_t dev;
+ char *diskname;
+ char *disklast = NULL;
+ grub_size_t len;
+
+ search_uuid = NULL;
+ check_boot = state[2].set;
+ diskname = args[0];
+ len = grub_strlen (diskname);
+ if (len && diskname[0] == '(' && diskname[len - 1] == ')')
+ {
+ disklast = &diskname[len - 1];
+ *disklast = '\0';
+ diskname++;
+ }
+
+ disk = grub_disk_open (diskname);
+ if (!disk)
+ {
+ 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 (diskname, disk);
+
+ grub_disk_close (disk);
+ if (disklast)
+ *disklast = ')';
+
+ return err;
+ }
+}
+
+static struct grub_disk_dev grub_cryptodisk_dev = {
+ .name = "cryptodisk",
+ .id = GRUB_DISK_DEVICE_CRYPTODISK_ID,
+ .disk_iterate = grub_cryptodisk_iterate,
+ .disk_open = grub_cryptodisk_open,
+ .disk_close = grub_cryptodisk_close,
+ .disk_read = grub_cryptodisk_read,
+ .disk_write = grub_cryptodisk_write,
+#ifdef GRUB_UTIL
+ .disk_memberlist = grub_cryptodisk_memberlist,
+#endif
+ .next = 0
+};
+
+static char
+hex (grub_uint8_t val)
+{
+ if (val < 10)
+ return '0' + val;
+ return 'a' + val - 10;
+}
+
+/* Open a file named NAME and initialize FILE. */
+static char *
+luks_script_get (grub_size_t *sz)
+{
+ grub_cryptodisk_t i;
+ grub_size_t size = 0;
+ char *ptr, *ret;
+
+ *sz = 0;
+
+ for (i = cryptodisk_list; i != NULL; i = i->next)
+ if (grub_strcmp (i->modname, "luks") == 0)
+ {
+ size += sizeof ("luks_mount ");
+ size += grub_strlen (i->uuid);
+ size += grub_strlen (i->cipher->cipher->name);
+ size += 54;
+ if (i->essiv_hash)
+ size += grub_strlen (i->essiv_hash->name);
+ size += i->keysize * 2;
+ }
+
+ ret = grub_malloc (size + 1);
+ if (!ret)
+ return 0;
+
+ ptr = ret;
+
+ for (i = cryptodisk_list; i != NULL; i = i->next)
+ if (grub_strcmp (i->modname, "luks") == 0)
+ {
+ unsigned j;
+ const char *iptr;
+ ptr = grub_stpcpy (ptr, "luks_mount ");
+ ptr = grub_stpcpy (ptr, i->uuid);
+ *ptr++ = ' ';
+ grub_snprintf (ptr, 21, "%" PRIuGRUB_UINT64_T " ", i->offset_sectors);
+ while (*ptr)
+ ptr++;
+ for (iptr = i->cipher->cipher->name; *iptr; iptr++)
+ *ptr++ = grub_tolower (*iptr);
+ switch (i->mode)
+ {
+ case GRUB_CRYPTODISK_MODE_ECB:
+ ptr = grub_stpcpy (ptr, "-ecb");
+ break;
+ case GRUB_CRYPTODISK_MODE_CBC:
+ ptr = grub_stpcpy (ptr, "-cbc");
+ break;
+ case GRUB_CRYPTODISK_MODE_PCBC:
+ ptr = grub_stpcpy (ptr, "-pcbc");
+ break;
+ case GRUB_CRYPTODISK_MODE_XTS:
+ ptr = grub_stpcpy (ptr, "-xts");
+ break;
+ case GRUB_CRYPTODISK_MODE_LRW:
+ ptr = grub_stpcpy (ptr, "-lrw");
+ break;
+ }
+
+ switch (i->mode_iv)
+ {
+ case GRUB_CRYPTODISK_MODE_IV_NULL:
+ ptr = grub_stpcpy (ptr, "-null");
+ break;
+ case GRUB_CRYPTODISK_MODE_IV_PLAIN:
+ ptr = grub_stpcpy (ptr, "-plain");
+ break;
+ case GRUB_CRYPTODISK_MODE_IV_PLAIN64:
+ ptr = grub_stpcpy (ptr, "-plain64");
+ break;
+ case GRUB_CRYPTODISK_MODE_IV_BENBI:
+ ptr = grub_stpcpy (ptr, "-benbi");
+ break;
+ case GRUB_CRYPTODISK_MODE_IV_ESSIV:
+ ptr = grub_stpcpy (ptr, "-essiv:");
+ ptr = grub_stpcpy (ptr, i->essiv_hash->name);
+ break;
+ case GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64:
+ case GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64_HASH:
+ break;
+ }
+ *ptr++ = ' ';
+ for (j = 0; j < i->keysize; j++)
+ {
+ *ptr++ = hex (i->key[j] >> 4);
+ *ptr++ = hex (i->key[j] & 0xf);
+ }
+ *ptr++ = '\n';
+ }
+ *ptr = '\0';
+ *sz = ptr - ret;
+ return ret;
+}
+
+struct grub_procfs_entry luks_script =
+{
+ .name = "luks_script",
+ .get_contents = luks_script_get
+};
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT (cryptodisk)
+{
+ grub_disk_dev_register (&grub_cryptodisk_dev);
+ cmd = grub_register_extcmd ("cryptomount", grub_cmd_cryptomount, 0,
+ N_("SOURCE|-u UUID|-a|-b"),
+ N_("Mount a crypto device."), options);
+ grub_procfs_register ("luks_script", &luks_script);
+}
+
+GRUB_MOD_FINI (cryptodisk)
+{
+ grub_disk_dev_unregister (&grub_cryptodisk_dev);
+ cryptodisk_cleanup ();
+ grub_unregister_extcmd (cmd);
+ grub_procfs_unregister (&luks_script);
+}
diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
new file mode 100644
index 0000000..0320115
--- /dev/null
+++ b/grub-core/disk/diskfilter.c
@@ -0,0 +1,1351 @@
+/* diskfilter.c - module to read RAID arrays. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/diskfilter.h>
+#include <grub/partition.h>
+#ifdef GRUB_UTIL
+#include <grub/i18n.h>
+#include <grub/util/misc.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Linked list of DISKFILTER arrays. */
+static struct grub_diskfilter_vg *array_list;
+grub_raid5_recover_func_t grub_raid5_recover_func;
+grub_raid6_recover_func_t grub_raid6_recover_func;
+grub_diskfilter_t grub_diskfilter_list;
+static int inscnt = 0;
+static int lv_num = 0;
+
+static struct grub_diskfilter_lv *
+find_lv (const char *name);
+static int is_lv_readable (struct grub_diskfilter_lv *lv, int easily);
+
+
+
+static grub_err_t
+is_node_readable (const struct grub_diskfilter_node *node, int easily)
+{
+ /* Check whether we actually know the physical volume we want to
+ read from. */
+ if (node->pv)
+ return !!(node->pv->disk);
+ if (node->lv)
+ return is_lv_readable (node->lv, easily);
+ return 0;
+}
+
+static int
+is_lv_readable (struct grub_diskfilter_lv *lv, int easily)
+{
+ unsigned i, j;
+ if (!lv)
+ return 0;
+ for (i = 0; i < lv->segment_count; i++)
+ {
+ int need = lv->segments[i].node_count, have = 0;
+ switch (lv->segments[i].type)
+ {
+ 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;
+
+ case GRUB_DISKFILTER_MIRROR:
+ need = 1;
+ break;
+
+ case GRUB_DISKFILTER_RAID10:
+ {
+ unsigned int n;
+ n = lv->segments[i].layout & 0xFF;
+ if (n == 1)
+ n = (lv->segments[i].layout >> 8) & 0xFF;
+ need = lv->segments[i].node_count - n + 1;
+ }
+ break;
+ }
+ for (j = 0; j < lv->segments[i].node_count; j++)
+ {
+ if (is_node_readable (lv->segments[i].nodes + j, easily))
+ have++;
+ if (have >= need)
+ break;
+ }
+ if (have < need)
+ return 0;
+ }
+
+ return 1;
+}
+
+static grub_err_t
+insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id,
+ struct grub_diskfilter_vg *array,
+ grub_disk_addr_t start_sector,
+ grub_diskfilter_t diskfilter __attribute__ ((unused)));
+
+static int
+is_valid_diskfilter_name (const char *name)
+{
+ return (grub_memcmp (name, "md", sizeof ("md") - 1) == 0
+ || grub_memcmp (name, "lvm/", sizeof ("lvm/") - 1) == 0
+ || grub_memcmp (name, "lvmid/", sizeof ("lvmid/") - 1) == 0
+ || grub_memcmp (name, "ldm/", sizeof ("ldm/") - 1) == 0);
+}
+
+/* Helper for scan_disk. */
+static int
+scan_disk_partition_iter (grub_disk_t disk, grub_partition_t p, void *data)
+{
+ const char *name = data;
+ struct grub_diskfilter_vg *arr;
+ grub_disk_addr_t start_sector;
+ struct grub_diskfilter_pv_id id;
+ grub_diskfilter_t diskfilter;
+
+ grub_dprintf ("diskfilter", "Scanning for DISKFILTER devices on disk %s\n",
+ name);
+#ifdef GRUB_UTIL
+ grub_util_info ("Scanning for DISKFILTER devices on disk %s", name);
+#endif
+
+ disk->partition = p;
+
+ for (arr = array_list; arr != NULL; arr = arr->next)
+ {
+ struct grub_diskfilter_pv *m;
+ for (m = arr->pvs; m; m = m->next)
+ if (m->disk && m->disk->id == disk->id
+ && m->disk->dev->id == disk->dev->id
+ && m->part_start == grub_partition_get_start (disk->partition)
+ && m->part_size == grub_disk_native_sectors (disk))
+ return 0;
+ }
+
+ for (diskfilter = grub_diskfilter_list; diskfilter; diskfilter = diskfilter->next)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("Scanning for %s devices on disk %s",
+ diskfilter->name, name);
+#endif
+ id.uuid = 0;
+ id.uuidlen = 0;
+ arr = diskfilter->detect (disk, &id, &start_sector);
+ if (arr &&
+ (! insert_array (disk, &id, arr, start_sector, diskfilter)))
+ {
+ if (id.uuidlen)
+ grub_free (id.uuid);
+ return 0;
+ }
+ if (arr && id.uuidlen)
+ grub_free (id.uuid);
+
+ /* This error usually means it's not diskfilter, no need to display
+ it. */
+ if (grub_errno != GRUB_ERR_OUT_OF_RANGE)
+ grub_print_error ();
+
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ return 0;
+}
+
+static int
+scan_disk (const char *name, int accept_diskfilter)
+{
+ grub_disk_t disk;
+ static int scan_depth = 0;
+
+ if (!accept_diskfilter && is_valid_diskfilter_name (name))
+ return 0;
+
+ if (scan_depth > 100)
+ return 0;
+
+ scan_depth++;
+ disk = grub_disk_open (name);
+ if (!disk)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ scan_depth--;
+ return 0;
+ }
+ scan_disk_partition_iter (disk, 0, (void *) name);
+ grub_partition_iterate (disk, scan_disk_partition_iter, (void *) name);
+ grub_disk_close (disk);
+ scan_depth--;
+ return 0;
+}
+
+static int
+scan_disk_hook (const char *name, void *data __attribute__ ((unused)))
+{
+ return scan_disk (name, 0);
+}
+
+static void
+scan_devices (const char *arname)
+{
+ grub_disk_dev_t p;
+ grub_disk_pull_t pull;
+ struct grub_diskfilter_vg *vg;
+ struct grub_diskfilter_lv *lv = NULL;
+ int scan_depth;
+ int need_rescan;
+
+ for (pull = 0; pull < GRUB_DISK_PULL_MAX; pull++)
+ for (p = grub_disk_dev_list; p; p = p->next)
+ if (p->id != GRUB_DISK_DEVICE_DISKFILTER_ID
+ && p->disk_iterate)
+ {
+ if ((p->disk_iterate) (scan_disk_hook, NULL, pull))
+ return;
+ if (arname && is_lv_readable (find_lv (arname), 1))
+ return;
+ }
+
+ scan_depth = 0;
+ need_rescan = 1;
+ while (need_rescan && scan_depth++ < 100)
+ {
+ need_rescan = 0;
+ for (vg = array_list; vg; vg = vg->next)
+ {
+ if (vg->lvs)
+ for (lv = vg->lvs; lv; lv = lv->next)
+ if (!lv->scanned && lv->fullname && lv->became_readable_at)
+ {
+ scan_disk (lv->fullname, 1);
+ lv->scanned = 1;
+ need_rescan = 1;
+ }
+ }
+ }
+
+ if (need_rescan)
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "DISKFILTER scan depth exceeded");
+}
+
+static int
+grub_diskfilter_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ struct grub_diskfilter_vg *array;
+ int islcnt = 0;
+
+ if (pull == GRUB_DISK_PULL_RESCAN)
+ {
+ islcnt = inscnt + 1;
+ scan_devices (NULL);
+ }
+
+ if (pull != GRUB_DISK_PULL_NONE && pull != GRUB_DISK_PULL_RESCAN)
+ return 0;
+
+ for (array = array_list; array; array = array->next)
+ {
+ struct grub_diskfilter_lv *lv;
+ if (array->lvs)
+ for (lv = array->lvs; lv; lv = lv->next)
+ if (lv->visible && lv->fullname && lv->became_readable_at >= islcnt)
+ {
+ if (hook (lv->fullname, hook_data))
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+#ifdef GRUB_UTIL
+static grub_disk_memberlist_t
+grub_diskfilter_memberlist (grub_disk_t disk)
+{
+ struct grub_diskfilter_lv *lv = disk->data;
+ grub_disk_memberlist_t list = NULL, tmp;
+ struct grub_diskfilter_pv *pv;
+ grub_disk_pull_t pull;
+ grub_disk_dev_t p;
+ struct grub_diskfilter_vg *vg;
+ struct grub_diskfilter_lv *lv2 = NULL;
+
+ if (!lv->vg->pvs)
+ return NULL;
+
+ pv = lv->vg->pvs;
+ while (pv && pv->disk)
+ pv = pv->next;
+
+ for (pull = 0; pv && pull < GRUB_DISK_PULL_MAX; pull++)
+ for (p = grub_disk_dev_list; pv && p; p = p->next)
+ if (p->id != GRUB_DISK_DEVICE_DISKFILTER_ID
+ && p->disk_iterate)
+ {
+ (p->disk_iterate) (scan_disk_hook, NULL, pull);
+ while (pv && pv->disk)
+ pv = pv->next;
+ }
+
+ for (vg = array_list; pv && vg; vg = vg->next)
+ {
+ if (vg->lvs)
+ for (lv2 = vg->lvs; pv && lv2; lv2 = lv2->next)
+ if (!lv2->scanned && lv2->fullname && lv2->became_readable_at)
+ {
+ scan_disk (lv2->fullname, 1);
+ lv2->scanned = 1;
+ while (pv && pv->disk)
+ pv = pv->next;
+ }
+ }
+
+ for (pv = lv->vg->pvs; pv; pv = pv->next)
+ {
+ if (!pv->disk)
+ {
+ /* TRANSLATORS: This message kicks in during the detection of
+ which modules needs to be included in core image. This happens
+ in the case of degraded RAID and means that autodetection may
+ fail to include some of modules. It's an installation time
+ message, not runtime message. */
+ grub_util_warn (_("Couldn't find physical volume `%s'."
+ " Some modules may be missing from core image."),
+ pv->name);
+ continue;
+ }
+ tmp = grub_malloc (sizeof (*tmp));
+ tmp->disk = pv->disk;
+ tmp->next = list;
+ list = tmp;
+ }
+
+ return list;
+}
+
+void
+grub_diskfilter_get_partmap (grub_disk_t disk,
+ void (*cb) (const char *pm, void *data),
+ void *data)
+{
+ struct grub_diskfilter_lv *lv = disk->data;
+ struct grub_diskfilter_pv *pv;
+
+ if (lv->vg->pvs)
+ for (pv = lv->vg->pvs; pv; pv = pv->next)
+ {
+ grub_size_t s;
+ if (!pv->disk)
+ {
+ /* TRANSLATORS: This message kicks in during the detection of
+ which modules needs to be included in core image. This happens
+ in the case of degraded RAID and means that autodetection may
+ fail to include some of modules. It's an installation time
+ message, not runtime message. */
+ grub_util_warn (_("Couldn't find physical volume `%s'."
+ " Some modules may be missing from core image."),
+ pv->name);
+ continue;
+ }
+ for (s = 0; pv->partmaps[s]; s++)
+ cb (pv->partmaps[s], data);
+ }
+}
+
+static const char *
+grub_diskfilter_getname (struct grub_disk *disk)
+{
+ struct grub_diskfilter_lv *array = disk->data;
+
+ return array->vg->driver->name;
+}
+#endif
+
+static inline char
+hex2ascii (int c)
+{
+ if (c >= 10)
+ return 'a' + c - 10;
+ return c + '0';
+}
+
+static struct grub_diskfilter_lv *
+find_lv (const char *name)
+{
+ struct grub_diskfilter_vg *vg;
+ struct grub_diskfilter_lv *lv = NULL;
+
+ for (vg = array_list; vg; vg = vg->next)
+ {
+ if (vg->lvs)
+ for (lv = vg->lvs; lv; lv = lv->next)
+ if (((lv->fullname && grub_strcmp (lv->fullname, name) == 0)
+ || (lv->idname && grub_strcmp (lv->idname, name) == 0))
+ && is_lv_readable (lv, 0))
+ return lv;
+ }
+ return NULL;
+}
+
+static grub_err_t
+grub_diskfilter_open (const char *name, grub_disk_t disk)
+{
+ struct grub_diskfilter_lv *lv;
+
+ if (!is_valid_diskfilter_name (name))
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown DISKFILTER device %s",
+ name);
+
+ lv = find_lv (name);
+
+ if (! lv)
+ {
+ scan_devices (name);
+ if (grub_errno)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+ lv = find_lv (name);
+ }
+
+ if (!lv)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown DISKFILTER device %s",
+ name);
+
+ disk->id = lv->number;
+ disk->data = lv;
+
+ disk->total_sectors = lv->size;
+ disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
+ return 0;
+}
+
+static void
+grub_diskfilter_close (grub_disk_t disk __attribute ((unused)))
+{
+ return;
+}
+
+static grub_err_t
+read_lv (struct grub_diskfilter_lv *lv, grub_disk_addr_t sector,
+ grub_size_t size, char *buf);
+
+grub_err_t
+grub_diskfilter_read_node (const struct grub_diskfilter_node *node,
+ grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ /* Check whether we actually know the physical volume we want to
+ read from. */
+ if (node->pv)
+ {
+ if (node->pv->disk)
+ return grub_disk_read (node->pv->disk, sector + node->start
+ + node->pv->start_sector,
+ 0, size << GRUB_DISK_SECTOR_BITS, buf);
+ else
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ N_("physical volume %s not found"), node->pv->name);
+
+ }
+ if (node->lv)
+ return read_lv (node->lv, sector + node->start, size, buf);
+ 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)
+{
+ grub_err_t err;
+ switch (seg->type)
+ {
+ case GRUB_DISKFILTER_STRIPED:
+ 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:
+ {
+ grub_disk_addr_t read_sector, far_ofs;
+ grub_uint64_t disknr, b, near, far, ofs;
+ unsigned int i, j;
+
+ read_sector = grub_divmod64 (sector, seg->stripe_size, &b);
+ far = ofs = near = 1;
+ far_ofs = 0;
+
+ if (seg->type == 1)
+ near = seg->node_count;
+ else if (seg->type == 10)
+ {
+ near = seg->layout & 0xFF;
+ far = (seg->layout >> 8) & 0xFF;
+ if (seg->layout >> 16)
+ {
+ ofs = far;
+ far_ofs = 1;
+ }
+ else
+ far_ofs = grub_divmod64 (seg->raid_member_size,
+ far * seg->stripe_size, 0);
+
+ far_ofs *= seg->stripe_size;
+ }
+
+ read_sector = grub_divmod64 (read_sector * near,
+ seg->node_count,
+ &disknr);
+
+ ofs *= seg->stripe_size;
+ read_sector *= ofs;
+
+ while (1)
+ {
+ grub_size_t read_size;
+
+ read_size = seg->stripe_size - b;
+ if (read_size > size)
+ read_size = size;
+
+ err = 0;
+ for (i = 0; i < near; i++)
+ {
+ unsigned int k;
+
+ k = disknr;
+ err = 0;
+ for (j = 0; j < far; j++)
+ {
+ if (grub_errno == GRUB_ERR_READ_ERROR
+ || grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
+ grub_errno = GRUB_ERR_NONE;
+
+ err = grub_diskfilter_read_node (&seg->nodes[k],
+ read_sector
+ + j * far_ofs + b,
+ read_size,
+ buf);
+ if (! err)
+ break;
+ else if (err != GRUB_ERR_READ_ERROR
+ && err != GRUB_ERR_UNKNOWN_DEVICE)
+ return err;
+ k++;
+ if (k == seg->node_count)
+ k = 0;
+ }
+
+ if (! err)
+ break;
+
+ disknr++;
+ if (disknr == seg->node_count)
+ {
+ disknr = 0;
+ read_sector += ofs;
+ }
+ }
+
+ if (err)
+ return err;
+
+ buf += read_size << GRUB_DISK_SECTOR_BITS;
+ size -= read_size;
+ if (! size)
+ return GRUB_ERR_NONE;
+
+ b = 0;
+ disknr += (near - i);
+ while (disknr >= seg->node_count)
+ {
+ disknr -= seg->node_count;
+ read_sector += ofs;
+ }
+ }
+ }
+
+ case GRUB_DISKFILTER_RAID4:
+ case GRUB_DISKFILTER_RAID5:
+ case GRUB_DISKFILTER_RAID6:
+ {
+ grub_disk_addr_t read_sector;
+ grub_uint64_t b, p, n, disknr, e;
+
+ /* n = 1 for level 4 and 5, 2 for level 6. */
+ n = seg->type / 3;
+
+ /* Find the first sector to read. */
+ read_sector = grub_divmod64 (sector, seg->stripe_size, &b);
+ read_sector = grub_divmod64 (read_sector, seg->node_count - n,
+ &disknr);
+ if (seg->type >= 5)
+ {
+ grub_divmod64 (read_sector, seg->node_count, &p);
+
+ if (! (seg->layout & GRUB_RAID_LAYOUT_RIGHT_MASK))
+ p = seg->node_count - 1 - p;
+
+ if (seg->layout & GRUB_RAID_LAYOUT_SYMMETRIC_MASK)
+ {
+ disknr += p + n;
+ }
+ else
+ {
+ grub_uint32_t q;
+
+ q = p + (n - 1);
+ if (q >= seg->node_count)
+ q -= seg->node_count;
+
+ if (disknr >= p)
+ disknr += n;
+ else if (disknr >= q)
+ disknr += q + 1;
+ }
+
+ if (disknr >= seg->node_count)
+ disknr -= seg->node_count;
+ }
+ else
+ p = seg->node_count - n;
+ read_sector *= seg->stripe_size;
+
+ while (1)
+ {
+ grub_size_t read_size;
+ int next_level;
+
+ read_size = seg->stripe_size - b;
+ if (read_size > size)
+ read_size = size;
+
+ e = 0;
+ /* Reset read error. */
+ if (grub_errno == GRUB_ERR_READ_ERROR
+ || grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
+ grub_errno = GRUB_ERR_NONE;
+
+ err = grub_diskfilter_read_node (&seg->nodes[disknr],
+ read_sector + b,
+ read_size,
+ buf);
+
+ if ((err) && (err != GRUB_ERR_READ_ERROR
+ && err != GRUB_ERR_UNKNOWN_DEVICE))
+ return err;
+ e++;
+
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ if (seg->type == GRUB_DISKFILTER_RAID6)
+ {
+ err = ((grub_raid6_recover_func) ?
+ (*grub_raid6_recover_func) (seg, disknr, p,
+ buf, read_sector + b,
+ read_size) :
+ grub_error (GRUB_ERR_BAD_DEVICE,
+ N_("module `%s' isn't loaded"),
+ "raid6rec"));
+ }
+ else
+ {
+ err = ((grub_raid5_recover_func) ?
+ (*grub_raid5_recover_func) (seg, disknr,
+ buf, read_sector + b,
+ read_size) :
+ grub_error (GRUB_ERR_BAD_DEVICE,
+ N_("module `%s' isn't loaded"),
+ "raid5rec"));
+ }
+
+ if (err)
+ return err;
+ }
+
+ buf += read_size << GRUB_DISK_SECTOR_BITS;
+ size -= read_size;
+ sector += read_size;
+ if (! size)
+ break;
+
+ b = 0;
+ disknr++;
+
+ if (seg->layout & GRUB_RAID_LAYOUT_SYMMETRIC_MASK)
+ {
+ if (disknr == seg->node_count)
+ disknr = 0;
+
+ next_level = (disknr == p);
+ }
+ else
+ {
+ if (disknr == p)
+ disknr += n;
+
+ next_level = (disknr >= seg->node_count);
+ }
+
+ if (next_level)
+ {
+ read_sector += seg->stripe_size;
+
+ if (seg->type >= 5)
+ {
+ if (seg->layout & GRUB_RAID_LAYOUT_RIGHT_MASK)
+ p = (p == seg->node_count - 1) ? 0 : p + 1;
+ else
+ p = (p == 0) ? seg->node_count - 1 : p - 1;
+
+ if (seg->layout & GRUB_RAID_LAYOUT_SYMMETRIC_MASK)
+ {
+ disknr = p + n;
+ if (disknr >= seg->node_count)
+ disknr -= seg->node_count;
+ }
+ else
+ {
+ disknr -= seg->node_count;
+ if ((disknr >= p && disknr < p + n)
+ || (disknr + seg->node_count >= p
+ && disknr + seg->node_count < p + n))
+ disknr = p + n;
+ if (disknr >= seg->node_count)
+ disknr -= seg->node_count;
+ }
+ }
+ else
+ disknr = 0;
+ }
+ }
+ }
+ return GRUB_ERR_NONE;
+ default:
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unsupported RAID level %d", seg->type);
+ }
+}
+
+static grub_err_t
+read_lv (struct grub_diskfilter_lv *lv, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ if (!lv)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume");
+
+ while (size)
+ {
+ grub_err_t err = 0;
+ struct grub_diskfilter_vg *vg = lv->vg;
+ struct grub_diskfilter_segment *seg = lv->segments;
+ grub_uint64_t extent;
+ grub_uint64_t to_read;
+
+ extent = grub_divmod64 (sector, vg->extent_size, NULL);
+
+ /* Find the right segment. */
+ {
+ unsigned int i;
+ for (i = 0; i < lv->segment_count; i++)
+ {
+ if ((seg->start_extent <= extent)
+ && ((seg->start_extent + seg->extent_count) > extent))
+ break;
+ seg++;
+ }
+ if (i == lv->segment_count)
+ return grub_error (GRUB_ERR_READ_ERROR, "incorrect segment");
+ }
+ to_read = ((seg->start_extent + seg->extent_count)
+ * vg->extent_size) - sector;
+ if (to_read > size)
+ to_read = size;
+
+ err = read_segment (seg, sector - seg->start_extent * vg->extent_size,
+ to_read, buf);
+ if (err)
+ return err;
+
+ size -= to_read;
+ sector += to_read;
+ buf += to_read << GRUB_DISK_SECTOR_BITS;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_diskfilter_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ return read_lv (disk->data, sector, size, buf);
+}
+
+static grub_err_t
+grub_diskfilter_write (grub_disk_t disk __attribute ((unused)),
+ grub_disk_addr_t sector __attribute ((unused)),
+ grub_size_t size __attribute ((unused)),
+ const char *buf __attribute ((unused)))
+{
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "diskfilter writes are not supported");
+}
+
+struct grub_diskfilter_vg *
+grub_diskfilter_get_vg_by_uuid (grub_size_t uuidlen, char *uuid)
+{
+ struct grub_diskfilter_vg *p;
+
+ for (p = array_list; p != NULL; p = p->next)
+ if ((p->uuid_len == uuidlen) &&
+ (! grub_memcmp (p->uuid, uuid, p->uuid_len)))
+ return p;
+ return NULL;
+}
+
+grub_err_t
+grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
+{
+ struct grub_diskfilter_lv *lv, *p;
+ struct grub_diskfilter_vg *vgp;
+ unsigned i;
+
+ grub_dprintf ("diskfilter", "Found array %s\n", vg->name);
+#ifdef GRUB_UTIL
+ grub_util_info ("Found array %s", vg->name);
+#endif
+
+ 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)
+ {
+ grub_size_t len;
+ int max_used_number = 0, need_new_name = 0;
+ len = grub_strlen (lv->fullname);
+ for (vgp = array_list; vgp; vgp = vgp->next)
+ for (p = vgp->lvs; p; p = p->next)
+ {
+ int cur_num;
+ char *num;
+ const char *end;
+ if (!p->fullname)
+ continue;
+ if (grub_strncmp (p->fullname, lv->fullname, len) != 0)
+ continue;
+ if (p->fullname[len] == 0)
+ {
+ need_new_name = 1;
+ continue;
+ }
+ num = p->fullname + len + 1;
+ if (!grub_isdigit (num[0]))
+ continue;
+ cur_num = grub_strtoul (num, &end, 10);
+ if (end[0])
+ continue;
+ if (cur_num > max_used_number)
+ max_used_number = cur_num;
+ }
+ if (need_new_name)
+ {
+ char *tmp;
+ tmp = grub_xasprintf ("%s_%d", lv->fullname, max_used_number + 1);
+ if (!tmp)
+ return grub_errno;
+ grub_free (lv->fullname);
+ lv->fullname = tmp;
+ }
+ }
+ }
+ /* Add our new array to the list. */
+ vg->next = array_list;
+ array_list = vg;
+ return GRUB_ERR_NONE;
+}
+
+struct grub_diskfilter_vg *
+grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
+ const char *name, grub_uint64_t disk_size,
+ grub_uint64_t stripe_size,
+ int layout, int level)
+{
+ struct grub_diskfilter_vg *array;
+ int i;
+ grub_size_t j;
+ grub_uint64_t totsize;
+ struct grub_diskfilter_pv *pv;
+ grub_err_t err;
+
+ switch (level)
+ {
+ case 1:
+ totsize = disk_size;
+ break;
+
+ case 10:
+ {
+ int n;
+ 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);
+ }
+ break;
+
+ case 0:
+ case 4:
+ case 5:
+ case 6:
+ totsize = (nmemb - ((unsigned) level / 3U)) * disk_size;
+ break;
+
+ default:
+ grub_free (uuid);
+ return NULL;
+ }
+
+ array = grub_diskfilter_get_vg_by_uuid (uuidlen, uuid);
+ if (array)
+ {
+ if (array->lvs && array->lvs->size < totsize)
+ {
+ array->lvs->size = totsize;
+ if (array->lvs->segments)
+ array->lvs->segments->extent_count = totsize;
+ }
+
+ if (array->lvs && array->lvs->segments
+ && array->lvs->segments->raid_member_size > disk_size)
+ array->lvs->segments->raid_member_size = disk_size;
+
+ grub_free (uuid);
+ return array;
+ }
+ array = grub_zalloc (sizeof (*array));
+ if (!array)
+ {
+ grub_free (uuid);
+ return NULL;
+ }
+ array->uuid = uuid;
+ array->uuid_len = uuidlen;
+ if (name)
+ {
+ /* Strip off the homehost if present. */
+ char *colon = grub_strchr (name, ':');
+ char *new_name = grub_xasprintf ("md/%s",
+ colon ? colon + 1 : name);
+
+ if (! new_name)
+ goto fail;
+
+ array->name = new_name;
+ }
+
+ array->extent_size = 1;
+ array->lvs = grub_zalloc (sizeof (*array->lvs));
+ if (!array->lvs)
+ goto fail;
+ array->lvs->segment_count = 1;
+ array->lvs->visible = 1;
+ 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)
+ goto fail;
+
+ grub_memcpy (array->lvs->idname, "mduuid/", sizeof ("mduuid/") - 1);
+ for (j = 0; j < uuidlen; j++)
+ {
+ array->lvs->idname[sizeof ("mduuid/") - 1 + 2 * j]
+ = hex2ascii (((unsigned char) uuid[j] >> 4));
+ array->lvs->idname[sizeof ("mduuid/") - 1 + 2 * j + 1]
+ = hex2ascii (((unsigned char) uuid[j] & 0xf));
+ }
+ array->lvs->idname[sizeof ("mduuid/") - 1 + 2 * uuidlen] = '\0';
+
+ array->lvs->size = totsize;
+
+ array->lvs->segments = grub_zalloc (sizeof (*array->lvs->segments));
+ if (!array->lvs->segments)
+ goto fail;
+ array->lvs->segments->stripe_size = stripe_size;
+ array->lvs->segments->layout = layout;
+ array->lvs->segments->start_extent = 0;
+ array->lvs->segments->extent_count = totsize;
+ array->lvs->segments->type = level;
+ array->lvs->segments->node_count = nmemb;
+ array->lvs->segments->raid_member_size = disk_size;
+ array->lvs->segments->nodes
+ = grub_calloc (nmemb, sizeof (array->lvs->segments->nodes[0]));
+ array->lvs->segments->stripe_size = stripe_size;
+ for (i = 0; i < nmemb; i++)
+ {
+ pv = grub_zalloc (sizeof (*pv));
+ if (!pv)
+ goto fail;
+ pv->id.uuidlen = 0;
+ pv->id.id = i;
+ pv->next = array->pvs;
+ array->pvs = pv;
+ array->lvs->segments->nodes[i].pv = pv;
+ }
+
+ err = grub_diskfilter_vg_register (array);
+ if (err)
+ goto fail;
+
+ return array;
+
+ fail:
+ 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;
+}
+
+static grub_err_t
+insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id,
+ struct grub_diskfilter_vg *array,
+ grub_disk_addr_t start_sector,
+ grub_diskfilter_t diskfilter __attribute__ ((unused)))
+{
+ struct grub_diskfilter_pv *pv;
+
+ grub_dprintf ("diskfilter", "Inserting %s (+%lld,%lld) into %s (%s)\n", disk->name,
+ (unsigned long long) grub_partition_get_start (disk->partition),
+ (unsigned long long) grub_disk_native_sectors (disk),
+ array->name, diskfilter->name);
+#ifdef GRUB_UTIL
+ grub_util_info ("Inserting %s (+%" GRUB_HOST_PRIuLONG_LONG ",%"
+ GRUB_HOST_PRIuLONG_LONG ") into %s (%s)\n", disk->name,
+ (unsigned long long) grub_partition_get_start (disk->partition),
+ (unsigned long long) grub_disk_native_sectors (disk),
+ array->name, diskfilter->name);
+ array->driver = diskfilter;
+#endif
+
+ for (pv = array->pvs; pv; pv = pv->next)
+ if (id->uuidlen == pv->id.uuidlen
+ && id->uuidlen
+ ? (grub_memcmp (pv->id.uuid, id->uuid, id->uuidlen) == 0)
+ : (pv->id.id == id->id))
+ {
+ struct grub_diskfilter_lv *lv;
+ /* FIXME: Check whether the update time of the superblocks are
+ the same. */
+ if (pv->disk && grub_disk_native_sectors (disk) >= pv->part_size)
+ return GRUB_ERR_NONE;
+ pv->disk = grub_disk_open (disk->name);
+ if (!pv->disk)
+ return grub_errno;
+ /* This could happen to LVM on RAID, pv->disk points to the
+ raid device, we shouldn't change it. */
+ pv->start_sector -= pv->part_start;
+ pv->part_start = grub_partition_get_start (disk->partition);
+ pv->part_size = grub_disk_native_sectors (disk);
+
+#ifdef GRUB_UTIL
+ {
+ grub_size_t s = 1;
+ grub_partition_t p;
+ for (p = disk->partition; p; p = p->parent)
+ s++;
+ pv->partmaps = xcalloc (s, sizeof (pv->partmaps[0]));
+ s = 0;
+ for (p = disk->partition; p; p = p->parent)
+ pv->partmaps[s++] = xstrdup (p->partmap->name);
+ pv->partmaps[s++] = 0;
+ }
+#endif
+ if (start_sector != (grub_uint64_t)-1)
+ pv->start_sector = start_sector;
+ pv->start_sector += pv->part_start;
+ /* Add the device to the array. */
+ for (lv = array->lvs; lv; lv = lv->next)
+ if (!lv->became_readable_at && lv->fullname && is_lv_readable (lv, 0))
+ lv->became_readable_at = ++inscnt;
+ break;
+ }
+
+ return 0;
+}
+
+static void
+free_array (void)
+{
+ while (array_list)
+ {
+ struct grub_diskfilter_vg *vg;
+ struct grub_diskfilter_pv *pv;
+ struct grub_diskfilter_lv *lv;
+
+ vg = array_list;
+ array_list = array_list->next;
+
+ while ((pv = vg->pvs))
+ {
+ vg->pvs = pv->next;
+ grub_free (pv->name);
+ if (pv->disk)
+ grub_disk_close (pv->disk);
+ if (pv->id.uuidlen)
+ grub_free (pv->id.uuid);
+#ifdef GRUB_UTIL
+ grub_free (pv->partmaps);
+#endif
+ grub_free (pv->internal_id);
+ grub_free (pv);
+ }
+
+ while ((lv = vg->lvs))
+ {
+ unsigned i;
+ vg->lvs = lv->next;
+ 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);
+ grub_free (lv->internal_id);
+ grub_free (lv);
+ }
+
+ grub_free (vg->uuid);
+ grub_free (vg->name);
+ grub_free (vg);
+ }
+
+ array_list = 0;
+}
+
+#ifdef GRUB_UTIL
+struct grub_diskfilter_pv *
+grub_diskfilter_get_pv_from_disk (grub_disk_t disk,
+ struct grub_diskfilter_vg **vg_out)
+{
+ struct grub_diskfilter_pv *pv;
+ struct grub_diskfilter_vg *vg;
+
+ scan_disk (disk->name, 1);
+ for (vg = array_list; vg; vg = vg->next)
+ for (pv = vg->pvs; pv; pv = pv->next)
+ {
+ if (pv->disk && pv->disk->id == disk->id
+ && pv->disk->dev->id == disk->dev->id
+ && pv->part_start == grub_partition_get_start (disk->partition)
+ && pv->part_size == grub_disk_native_sectors (disk))
+ {
+ if (vg_out)
+ *vg_out = vg;
+ return pv;
+ }
+ }
+ return NULL;
+}
+#endif
+
+static struct grub_disk_dev grub_diskfilter_dev =
+ {
+ .name = "diskfilter",
+ .id = GRUB_DISK_DEVICE_DISKFILTER_ID,
+ .disk_iterate = grub_diskfilter_iterate,
+ .disk_open = grub_diskfilter_open,
+ .disk_close = grub_diskfilter_close,
+ .disk_read = grub_diskfilter_read,
+ .disk_write = grub_diskfilter_write,
+#ifdef GRUB_UTIL
+ .disk_memberlist = grub_diskfilter_memberlist,
+ .disk_raidname = grub_diskfilter_getname,
+#endif
+ .next = 0
+ };
+
+
+GRUB_MOD_INIT(diskfilter)
+{
+ grub_disk_dev_register (&grub_diskfilter_dev);
+}
+
+GRUB_MOD_FINI(diskfilter)
+{
+ grub_disk_dev_unregister (&grub_diskfilter_dev);
+ free_array ();
+}
diff --git a/grub-core/disk/dmraid_nvidia.c b/grub-core/disk/dmraid_nvidia.c
new file mode 100644
index 0000000..6372663
--- /dev/null
+++ b/grub-core/disk/dmraid_nvidia.c
@@ -0,0 +1,196 @@
+/* dmraid_nvidia.c - module to handle Nvidia fakeraid. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/diskfilter.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define NV_SIGNATURES 4
+
+#define NV_IDLE 0
+#define NV_SCDB_INIT_RAID 2
+#define NV_SCDB_REBUILD_RAID 3
+#define NV_SCDB_UPGRADE_RAID 4
+#define NV_SCDB_SYNC_RAID 5
+
+#define NV_LEVEL_UNKNOWN 0x00
+#define NV_LEVEL_JBOD 0xFF
+#define NV_LEVEL_0 0x80
+#define NV_LEVEL_1 0x81
+#define NV_LEVEL_3 0x83
+#define NV_LEVEL_5 0x85
+#define NV_LEVEL_10 0x8a
+#define NV_LEVEL_1_0 0x8180
+
+#define NV_ARRAY_FLAG_BOOT 1 /* BIOS use only. */
+#define NV_ARRAY_FLAG_ERROR 2 /* Degraded or offline. */
+#define NV_ARRAY_FLAG_PARITY_VALID 4 /* RAID-3/5 parity valid. */
+
+struct grub_nv_array
+{
+ grub_uint32_t version;
+ grub_uint32_t signature[NV_SIGNATURES];
+ grub_uint8_t raid_job_code;
+ grub_uint8_t stripe_width;
+ grub_uint8_t total_volumes;
+ grub_uint8_t original_width;
+ grub_uint32_t raid_level;
+ grub_uint32_t stripe_block_size;
+ grub_uint32_t stripe_block_size_bytes;
+ grub_uint32_t stripe_block_size_log2;
+ grub_uint32_t stripe_mask;
+ grub_uint32_t stripe_size;
+ grub_uint32_t stripe_size_bytes;
+ grub_uint32_t raid_job_mask;
+ grub_uint32_t original_capacity;
+ grub_uint32_t flags;
+};
+
+#define NV_ID_LEN 8
+#define NV_ID_STRING "NVIDIA"
+#define NV_VERSION 100
+
+#define NV_PRODID_LEN 16
+#define NV_PRODREV_LEN 4
+
+struct grub_nv_super
+{
+ char vendor[NV_ID_LEN]; /* 0x00 - 0x07 ID string. */
+ grub_uint32_t size; /* 0x08 - 0x0B Size of metadata in dwords. */
+ grub_uint32_t chksum; /* 0x0C - 0x0F Checksum of this struct. */
+ grub_uint16_t version; /* 0x10 - 0x11 NV version. */
+ grub_uint8_t unit_number; /* 0x12 Disk index in array. */
+ grub_uint8_t reserved; /* 0x13. */
+ grub_uint32_t capacity; /* 0x14 - 0x17 Array capacity in sectors. */
+ grub_uint32_t sector_size; /* 0x18 - 0x1B Sector size. */
+ char prodid[NV_PRODID_LEN]; /* 0x1C - 0x2B Array product ID. */
+ char prodrev[NV_PRODREV_LEN]; /* 0x2C - 0x2F Array product revision */
+ grub_uint32_t unit_flags; /* 0x30 - 0x33 Flags for this disk */
+ struct grub_nv_array array; /* Array information */
+} GRUB_PACKED;
+
+static struct grub_diskfilter_vg *
+grub_dmraid_nv_detect (grub_disk_t disk,
+ struct grub_diskfilter_pv_id *id,
+ grub_disk_addr_t *start_sector)
+{
+ grub_disk_addr_t sector;
+ 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)
+ /* Skip partition. */
+ return NULL;
+
+ sector = grub_disk_native_sectors (disk);
+ if (sector == GRUB_DISK_SIZE_UNKNOWN)
+ /* Not raid. */
+ return NULL;
+ sector -= 2;
+ if (grub_disk_read (disk, sector, 0, sizeof (sb), &sb))
+ return NULL;
+
+ if (grub_memcmp (sb.vendor, NV_ID_STRING, 6))
+ /* Not raid. */
+ return NULL;
+
+ if (sb.version != NV_VERSION)
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unknown version: %d.%d", sb.version >> 8, sb.version & 0xFF);
+ 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;
+ if (total_volumes == 0)
+ /* Not RAID. */
+ return NULL;
+ disk_size = capacity / total_volumes;
+ break;
+
+ case NV_LEVEL_1:
+ level = 1;
+ disk_size = sb.capacity;
+ break;
+
+ case NV_LEVEL_5:
+ level = 5;
+ if (total_volumes == 0 || total_volumes == 1)
+ /* Not RAID. */
+ return NULL;
+ disk_size = capacity / (total_volumes - 1);
+ break;
+
+ default:
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unsupported RAID level: %d", sb.array.raid_level);
+ return NULL;
+ }
+
+ uuid = grub_malloc (sizeof (sb.array.signature));
+ if (! uuid)
+ return NULL;
+
+ grub_memcpy (uuid, (char *) &sb.array.signature,
+ sizeof (sb.array.signature));
+
+ id->uuidlen = 0;
+ id->id = sb.unit_number;
+
+ *start_sector = 0;
+
+ return grub_diskfilter_make_raid (sizeof (sb.array.signature),
+ uuid, sb.array.total_volumes,
+ "nv", disk_size,
+ sb.array.stripe_block_size,
+ GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC,
+ level);
+}
+
+static struct grub_diskfilter grub_dmraid_nv_dev =
+{
+ .name = "dmraid_nv",
+ .detect = grub_dmraid_nv_detect,
+ .next = 0
+};
+
+GRUB_MOD_INIT(dm_nv)
+{
+ grub_diskfilter_register_front (&grub_dmraid_nv_dev);
+}
+
+GRUB_MOD_FINI(dm_nv)
+{
+ grub_diskfilter_unregister (&grub_dmraid_nv_dev);
+}
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
new file mode 100644
index 0000000..f077b5f
--- /dev/null
+++ b/grub-core/disk/efi/efidisk.c
@@ -0,0 +1,902 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/term.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/disk.h>
+
+struct grub_efidisk_data
+{
+ grub_efi_handle_t handle;
+ grub_efi_device_path_t *device_path;
+ grub_efi_device_path_t *last_device_path;
+ grub_efi_block_io_t *block_io;
+ struct grub_efidisk_data *next;
+};
+
+/* GUID. */
+static grub_efi_guid_t block_io_guid = GRUB_EFI_BLOCK_IO_GUID;
+
+static struct grub_efidisk_data *fd_devices;
+static struct grub_efidisk_data *hd_devices;
+static struct grub_efidisk_data *cd_devices;
+
+static struct grub_efidisk_data *
+make_devices (void)
+{
+ grub_efi_uintn_t num_handles;
+ grub_efi_handle_t *handles;
+ grub_efi_handle_t *handle;
+ struct grub_efidisk_data *devices = 0;
+
+ /* Find handles which support the disk io interface. */
+ handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &block_io_guid,
+ 0, &num_handles);
+ if (! handles)
+ return 0;
+
+ /* Make a linked list of devices. */
+ for (handle = handles; num_handles--; handle++)
+ {
+ grub_efi_device_path_t *dp;
+ grub_efi_device_path_t *ldp;
+ struct grub_efidisk_data *d;
+ grub_efi_block_io_t *bio;
+
+ dp = grub_efi_get_device_path (*handle);
+ if (! dp)
+ continue;
+
+ ldp = grub_efi_find_last_device_path (dp);
+ if (! ldp)
+ /* This is empty. Why? */
+ continue;
+
+ bio = grub_efi_open_protocol (*handle, &block_io_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (! bio)
+ /* This should not happen... Why? */
+ continue;
+
+ /* iPXE adds stub Block IO protocol to loaded image device handle. It is
+ completely non-functional and simply returns an error for every method.
+ So attempt to detect and skip it. Magic number is literal "iPXE" and
+ check block size as well */
+ /* FIXME: shoud we close it? We do not do it elsewhere */
+ if (bio->media && bio->media->media_id == 0x69505845U &&
+ bio->media->block_size == 1)
+ continue;
+
+ d = grub_malloc (sizeof (*d));
+ if (! d)
+ {
+ /* Uggh. */
+ grub_free (handles);
+ while (devices)
+ {
+ d = devices->next;
+ grub_free (devices);
+ devices = d;
+ }
+ return 0;
+ }
+
+ d->handle = *handle;
+ d->device_path = dp;
+ d->last_device_path = ldp;
+ d->block_io = bio;
+ d->next = devices;
+ devices = d;
+ }
+
+ grub_free (handles);
+
+ return devices;
+}
+
+/* Find the parent device. */
+static struct grub_efidisk_data *
+find_parent_device (struct grub_efidisk_data *devices,
+ struct grub_efidisk_data *d)
+{
+ grub_efi_device_path_t *dp, *ldp;
+ struct grub_efidisk_data *parent;
+
+ dp = grub_efi_duplicate_device_path (d->device_path);
+ if (! dp)
+ return 0;
+
+ ldp = grub_efi_find_last_device_path (dp);
+ if (! ldp)
+ return 0;
+
+ ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
+ ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ ldp->length = sizeof (*ldp);
+
+ for (parent = devices; parent; parent = parent->next)
+ {
+ /* Ignore itself. */
+ if (parent == d)
+ continue;
+
+ if (grub_efi_compare_device_paths (parent->device_path, dp) == 0)
+ break;
+ }
+
+ grub_free (dp);
+ return parent;
+}
+
+static int
+is_child (struct grub_efidisk_data *child,
+ struct grub_efidisk_data *parent)
+{
+ grub_efi_device_path_t *dp, *ldp;
+ int ret;
+
+ dp = grub_efi_duplicate_device_path (child->device_path);
+ if (! dp)
+ return 0;
+
+ ldp = grub_efi_find_last_device_path (dp);
+ if (! ldp)
+ return 0;
+
+ ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
+ ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ ldp->length = sizeof (*ldp);
+
+ ret = (grub_efi_compare_device_paths (dp, parent->device_path) == 0);
+ grub_free (dp);
+ return ret;
+}
+
+#define FOR_CHILDREN(p, dev) for (p = dev; p; p = p->next) if (is_child (p, d))
+
+/* Add a device into a list of devices in an ascending order. */
+static void
+add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
+{
+ struct grub_efidisk_data **p;
+ struct grub_efidisk_data *n;
+
+ for (p = devices; *p; p = &((*p)->next))
+ {
+ int ret;
+
+ 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);
+ if (ret == 0)
+ return;
+ else if (ret > 0)
+ break;
+ }
+
+ n = grub_malloc (sizeof (*n));
+ if (! n)
+ return;
+
+ grub_memcpy (n, d, sizeof (*n));
+ n->next = (*p);
+ (*p) = n;
+}
+
+/* Name the devices. */
+static void
+name_devices (struct grub_efidisk_data *devices)
+{
+ struct grub_efidisk_data *d;
+
+ /* First, identify devices by media device paths. */
+ for (d = devices; d; d = d->next)
+ {
+ grub_efi_device_path_t *dp;
+
+ dp = d->last_device_path;
+ if (! dp)
+ continue;
+
+ if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
+ {
+ int is_hard_drive = 0;
+
+ switch (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp))
+ {
+ case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
+ is_hard_drive = 1;
+ /* Intentionally fall through. */
+ case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
+ {
+ struct grub_efidisk_data *parent, *parent2;
+
+ parent = find_parent_device (devices, d);
+ if (!parent)
+ {
+#ifdef DEBUG_NAMES
+ grub_printf ("skipping orphaned partition: ");
+ grub_efi_print_device_path (d->device_path);
+#endif
+ break;
+ }
+ parent2 = find_parent_device (devices, parent);
+ if (parent2)
+ {
+#ifdef DEBUG_NAMES
+ grub_printf ("skipping subpartition: ");
+ grub_efi_print_device_path (d->device_path);
+#endif
+ /* Mark itself as used. */
+ d->last_device_path = 0;
+ break;
+ }
+ if (!parent->last_device_path)
+ {
+ d->last_device_path = 0;
+ break;
+ }
+ if (is_hard_drive)
+ {
+#ifdef DEBUG_NAMES
+ grub_printf ("adding a hard drive by a partition: ");
+ grub_efi_print_device_path (parent->device_path);
+#endif
+ add_device (&hd_devices, parent);
+ }
+ else
+ {
+#ifdef DEBUG_NAMES
+ grub_printf ("adding a cdrom by a partition: ");
+ grub_efi_print_device_path (parent->device_path);
+#endif
+ add_device (&cd_devices, parent);
+ }
+
+ /* Mark the parent as used. */
+ parent->last_device_path = 0;
+ }
+ /* Mark itself as used. */
+ d->last_device_path = 0;
+ break;
+
+ default:
+#ifdef DEBUG_NAMES
+ grub_printf ("skipping other type: ");
+ grub_efi_print_device_path (d->device_path);
+#endif
+ /* For now, ignore the others. */
+ break;
+ }
+ }
+ else
+ {
+#ifdef DEBUG_NAMES
+ grub_printf ("skipping non-media: ");
+ grub_efi_print_device_path (d->device_path);
+#endif
+ }
+ }
+
+ /* Let's see what can be added more. */
+ for (d = devices; d; d = d->next)
+ {
+ grub_efi_device_path_t *dp;
+ grub_efi_block_io_media_t *m;
+ int is_floppy = 0;
+
+ dp = d->last_device_path;
+ 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)
+ == GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE)
+ {
+ grub_efi_acpi_device_path_t *acpi
+ = (grub_efi_acpi_device_path_t *) dp;
+ /* Floppy EISA ID. */
+ if (acpi->hid == 0x60441d0 || acpi->hid == 0x70041d0
+ || acpi->hid == 0x70141d1)
+ is_floppy = 1;
+ }
+ if (is_floppy)
+ {
+#ifdef DEBUG_NAMES
+ grub_printf ("adding a floppy: ");
+ grub_efi_print_device_path (d->device_path);
+#endif
+ add_device (&fd_devices, d);
+ }
+ else if (m->read_only && m->block_size > GRUB_DISK_SECTOR_SIZE)
+ {
+ /* This check is too heuristic, but assume that this is a
+ CDROM drive. */
+#ifdef DEBUG_NAMES
+ grub_printf ("adding a cdrom by guessing: ");
+ grub_efi_print_device_path (d->device_path);
+#endif
+ add_device (&cd_devices, d);
+ }
+ else
+ {
+ /* The default is a hard drive. */
+#ifdef DEBUG_NAMES
+ grub_printf ("adding a hard drive by guessing: ");
+ grub_efi_print_device_path (d->device_path);
+#endif
+ add_device (&hd_devices, d);
+ }
+ }
+}
+
+static void
+free_devices (struct grub_efidisk_data *devices)
+{
+ struct grub_efidisk_data *p, *q;
+
+ for (p = devices; p; p = q)
+ {
+ q = p->next;
+ grub_free (p);
+ }
+}
+
+/* Enumerate all disks to name devices. */
+static void
+enumerate_disks (void)
+{
+ struct grub_efidisk_data *devices;
+
+ devices = make_devices ();
+ if (! devices)
+ return;
+
+ name_devices (devices);
+ free_devices (devices);
+}
+
+static int
+grub_efidisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ struct grub_efidisk_data *d;
+ char buf[16];
+ int count;
+
+ switch (pull)
+ {
+ case GRUB_DISK_PULL_NONE:
+ for (d = hd_devices, count = 0; d; d = d->next, count++)
+ {
+ grub_snprintf (buf, sizeof (buf), "hd%d", count);
+ grub_dprintf ("efidisk", "iterating %s\n", buf);
+ if (hook (buf, hook_data))
+ return 1;
+ }
+ break;
+ case GRUB_DISK_PULL_REMOVABLE:
+ for (d = fd_devices, count = 0; d; d = d->next, count++)
+ {
+ grub_snprintf (buf, sizeof (buf), "fd%d", count);
+ grub_dprintf ("efidisk", "iterating %s\n", buf);
+ if (hook (buf, hook_data))
+ return 1;
+ }
+
+ for (d = cd_devices, count = 0; d; d = d->next, count++)
+ {
+ grub_snprintf (buf, sizeof (buf), "cd%d", count);
+ grub_dprintf ("efidisk", "iterating %s\n", buf);
+ if (hook (buf, hook_data))
+ return 1;
+ }
+ break;
+ default:
+ return 0;
+ }
+
+ return 0;
+}
+
+static int
+get_drive_number (const char *name)
+{
+ unsigned long drive;
+
+ if ((name[0] != 'f' && name[0] != 'h' && name[0] != 'c') || name[1] != 'd')
+ goto fail;
+
+ drive = grub_strtoul (name + 2, 0, 10);
+ if (grub_errno != GRUB_ERR_NONE)
+ goto fail;
+
+ return (int) drive ;
+
+ fail:
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a efidisk");
+ return -1;
+}
+
+static struct grub_efidisk_data *
+get_device (struct grub_efidisk_data *devices, int num)
+{
+ struct grub_efidisk_data *d;
+
+ for (d = devices; d && num; d = d->next, num--)
+ ;
+
+ if (num == 0)
+ return d;
+
+ return 0;
+}
+
+static grub_err_t
+grub_efidisk_open (const char *name, struct grub_disk *disk)
+{
+ int num;
+ struct grub_efidisk_data *d = 0;
+ grub_efi_block_io_media_t *m;
+
+ grub_dprintf ("efidisk", "opening %s\n", name);
+
+ num = get_drive_number (name);
+ if (num < 0)
+ return grub_errno;
+
+ switch (name[0])
+ {
+ case 'f':
+ d = get_device (fd_devices, num);
+ break;
+ case 'c':
+ d = get_device (cd_devices, num);
+ break;
+ case 'h':
+ d = get_device (hd_devices, num);
+ break;
+ default:
+ /* Never reach here. */
+ break;
+ }
+
+ if (! d)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such device");
+
+ disk->id = ((num << GRUB_CHAR_BIT) | name[0]);
+ 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, 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);
+ if (m->block_size & (m->block_size - 1) || !m->block_size)
+ return grub_error (GRUB_ERR_IO, "invalid sector size %d",
+ m->block_size);
+ for (disk->log_sector_size = 0;
+ (1U << disk->log_sector_size) < m->block_size;
+ disk->log_sector_size++);
+ disk->data = d;
+
+ grub_dprintf ("efidisk", "opening %s succeeded\n", name);
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_efidisk_close (struct grub_disk *disk __attribute__ ((unused)))
+{
+ /* EFI disks do not allocate extra memory, so nothing to do here. */
+ grub_dprintf ("efidisk", "closing %s\n", disk->name);
+}
+
+static grub_efi_status_t
+grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf, int wr)
+{
+ 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;
+
+ /* 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
+grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_efi_status_t status;
+
+ grub_dprintf ("efidisk",
+ "reading 0x%lx sectors at the sector 0x%llx from %s\n",
+ (unsigned long) size, (unsigned long long) sector, disk->name);
+
+ status = grub_efidisk_readwrite (disk, sector, size, buf, 0);
+
+ 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,
+ disk->name);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
+ grub_size_t size, const char *buf)
+{
+ grub_efi_status_t status;
+
+ grub_dprintf ("efidisk",
+ "writing 0x%lx sectors at the sector 0x%llx to %s\n",
+ (unsigned long) size, (unsigned long long) sector, disk->name);
+
+ status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1);
+
+ 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);
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_disk_dev grub_efidisk_dev =
+ {
+ .name = "efidisk",
+ .id = GRUB_DISK_DEVICE_EFIDISK_ID,
+ .disk_iterate = grub_efidisk_iterate,
+ .disk_open = grub_efidisk_open,
+ .disk_close = grub_efidisk_close,
+ .disk_read = grub_efidisk_read,
+ .disk_write = grub_efidisk_write,
+ .next = 0
+ };
+
+void
+grub_efidisk_fini (void)
+{
+ free_devices (fd_devices);
+ free_devices (hd_devices);
+ free_devices (cd_devices);
+ fd_devices = 0;
+ hd_devices = 0;
+ cd_devices = 0;
+ grub_disk_dev_unregister (&grub_efidisk_dev);
+}
+
+void
+grub_efidisk_init (void)
+{
+ grub_disk_firmware_fini = grub_efidisk_fini;
+
+ enumerate_disks ();
+ grub_disk_dev_register (&grub_efidisk_dev);
+}
+
+/* Some utility functions to map GRUB devices with EFI devices. */
+grub_efi_handle_t
+grub_efidisk_get_device_handle (grub_disk_t disk)
+{
+ struct grub_efidisk_data *d;
+ char type;
+
+ if (disk->dev->id != GRUB_DISK_DEVICE_EFIDISK_ID)
+ return 0;
+
+ d = disk->data;
+ type = disk->name[0];
+
+ switch (type)
+ {
+ case 'f':
+ /* This is the simplest case. */
+ return d->handle;
+
+ case 'c':
+ /* FIXME: probably this is not correct. */
+ return d->handle;
+
+ case 'h':
+ /* If this is the whole disk, just return its own data. */
+ if (! disk->partition)
+ return d->handle;
+
+ /* Otherwise, we must query the corresponding device to the firmware. */
+ {
+ struct grub_efidisk_data *devices;
+ grub_efi_handle_t handle = 0;
+ struct grub_efidisk_data *c;
+
+ devices = make_devices ();
+ FOR_CHILDREN (c, devices)
+ {
+ grub_efi_hard_drive_device_path_t *hd;
+
+ hd = (grub_efi_hard_drive_device_path_t *) c->last_device_path;
+
+ if ((GRUB_EFI_DEVICE_PATH_TYPE (c->last_device_path)
+ == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
+ && (GRUB_EFI_DEVICE_PATH_SUBTYPE (c->last_device_path)
+ == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)
+ && (grub_partition_get_start (disk->partition)
+ == (hd->partition_start << (disk->log_sector_size
+ - GRUB_DISK_SECTOR_BITS)))
+ && (grub_partition_get_len (disk->partition)
+ == (hd->partition_size << (disk->log_sector_size
+ - GRUB_DISK_SECTOR_BITS))))
+ {
+ handle = c->handle;
+ break;
+ }
+ }
+
+ free_devices (devices);
+
+ if (handle != 0)
+ return handle;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+#define NEEDED_BUFLEN sizeof ("XdXXXXXXXXXX")
+static inline int
+get_diskname_from_path_real (const grub_efi_device_path_t *path,
+ struct grub_efidisk_data *head,
+ char *buf)
+{
+ int count = 0;
+ struct grub_efidisk_data *d;
+ for (d = head, count = 0; d; d = d->next, count++)
+ if (grub_efi_compare_device_paths (d->device_path, path) == 0)
+ {
+ grub_snprintf (buf, NEEDED_BUFLEN - 1, "d%d", count);
+ return 1;
+ }
+ return 0;
+}
+
+static inline int
+get_diskname_from_path (const grub_efi_device_path_t *path,
+ char *buf)
+{
+ if (get_diskname_from_path_real (path, hd_devices, buf + 1))
+ {
+ buf[0] = 'h';
+ return 1;
+ }
+
+ if (get_diskname_from_path_real (path, fd_devices, buf + 1))
+ {
+ buf[0] = 'f';
+ return 1;
+ }
+
+ if (get_diskname_from_path_real (path, cd_devices, buf + 1))
+ {
+ buf[0] = 'c';
+ return 1;
+ }
+ return 0;
+}
+
+/* Context for grub_efidisk_get_device_name. */
+struct grub_efidisk_get_device_name_ctx
+{
+ char *partition_name;
+ grub_efi_hard_drive_device_path_t *hd;
+};
+
+/* Helper for grub_efidisk_get_device_name.
+ Find the identical partition. */
+static int
+grub_efidisk_get_device_name_iter (grub_disk_t disk,
+ const grub_partition_t part, void *data)
+{
+ struct grub_efidisk_get_device_name_ctx *ctx = data;
+
+ if (grub_partition_get_start (part)
+ == (ctx->hd->partition_start << (disk->log_sector_size
+ - GRUB_DISK_SECTOR_BITS))
+ && grub_partition_get_len (part)
+ == (ctx->hd->partition_size << (disk->log_sector_size
+ - GRUB_DISK_SECTOR_BITS)))
+ {
+ ctx->partition_name = grub_partition_get_name (part);
+ return 1;
+ }
+
+ return 0;
+}
+
+char *
+grub_efidisk_get_device_name (grub_efi_handle_t *handle)
+{
+ grub_efi_device_path_t *dp, *ldp;
+ char device_name[NEEDED_BUFLEN];
+
+ dp = grub_efi_get_device_path (handle);
+ if (! dp)
+ return 0;
+
+ ldp = grub_efi_find_last_device_path (dp);
+ if (! ldp)
+ return 0;
+
+ if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
+ && (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))
+ {
+ struct grub_efidisk_get_device_name_ctx ctx;
+ char *dev_name;
+ grub_efi_device_path_t *dup_dp;
+ grub_disk_t parent = 0;
+
+ /* It is necessary to duplicate the device path so that GRUB
+ can overwrite it. */
+ dup_dp = grub_efi_duplicate_device_path (dp);
+ if (! dup_dp)
+ return 0;
+
+ while (1)
+ {
+ grub_efi_device_path_t *dup_ldp;
+ dup_ldp = grub_efi_find_last_device_path (dup_dp);
+ if (! dup_ldp)
+ break;
+
+ 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;
+
+ 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);
+ }
+
+ if (!get_diskname_from_path (dup_dp, device_name))
+ {
+ grub_free (dup_dp);
+ return 0;
+ }
+
+ parent = grub_disk_open (device_name);
+ grub_free (dup_dp);
+
+ if (! parent)
+ return 0;
+
+ /* Find a partition which matches the hard drive device path. */
+ ctx.partition_name = NULL;
+ ctx.hd = (grub_efi_hard_drive_device_path_t *) ldp;
+ if (ctx.hd->partition_start == 0
+ && (ctx.hd->partition_size << (parent->log_sector_size
+ - GRUB_DISK_SECTOR_BITS))
+ == grub_disk_native_sectors (parent))
+ {
+ dev_name = grub_strdup (parent->name);
+ }
+ else
+ {
+ grub_partition_iterate (parent, grub_efidisk_get_device_name_iter,
+ &ctx);
+
+ 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);
+ return grub_strdup (device_name);
+ }
+
+ dev_name = grub_xasprintf ("%s,%s", parent->name,
+ ctx.partition_name);
+ grub_free (ctx.partition_name);
+ }
+ grub_disk_close (parent);
+
+ return dev_name;
+ }
+ /* This may be guessed device - floppy, cdrom or entire disk. */
+ if (!get_diskname_from_path (dp, device_name))
+ return 0;
+ return grub_strdup (device_name);
+}
diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c
new file mode 100644
index 0000000..2f34a35
--- /dev/null
+++ b/grub-core/disk/geli.c
@@ -0,0 +1,595 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2007,2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This file is loosely based on FreeBSD geli implementation
+ (but no code was directly copied). FreeBSD geli is distributed under
+ following terms: */
+/*-
+ * Copyright (c) 2005-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <grub/cryptodisk.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/err.h>
+#include <grub/disk.h>
+#include <grub/crypto.h>
+#include <grub/partition.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Dirty trick to solve circular dependency. */
+#ifdef GRUB_UTIL
+
+#include <grub/util/misc.h>
+
+#undef GRUB_MD_SHA256
+#undef GRUB_MD_SHA512
+
+static const gcry_md_spec_t *
+grub_md_sha256_real (void)
+{
+ const gcry_md_spec_t *ret;
+ ret = grub_crypto_lookup_md_by_name ("sha256");
+ if (!ret)
+ grub_util_error ("%s", _("Couldn't load sha256"));
+ return ret;
+}
+
+static const gcry_md_spec_t *
+grub_md_sha512_real (void)
+{
+ const gcry_md_spec_t *ret;
+ ret = grub_crypto_lookup_md_by_name ("sha512");
+ if (!ret)
+ grub_util_error ("%s", _("Couldn't load sha512"));
+ return ret;
+}
+
+#define GRUB_MD_SHA256 grub_md_sha256_real()
+#define GRUB_MD_SHA512 grub_md_sha512_real()
+#endif
+
+struct grub_geli_key
+{
+ grub_uint8_t iv_key[64];
+ grub_uint8_t cipher_key[64];
+ grub_uint8_t hmac[64];
+} GRUB_PACKED;
+
+struct grub_geli_phdr
+{
+ grub_uint8_t magic[16];
+#define GELI_MAGIC "GEOM::ELI"
+ grub_uint32_t version;
+ grub_uint32_t flags;
+ grub_uint16_t alg;
+ grub_uint16_t keylen;
+ grub_uint16_t unused3[5];
+ grub_uint32_t sector_size;
+ grub_uint8_t keys_used;
+ grub_uint32_t niter;
+ grub_uint8_t salt[64];
+ struct grub_geli_key keys[2];
+} GRUB_PACKED;
+
+enum
+ {
+ GRUB_GELI_FLAGS_ONETIME = 1,
+ GRUB_GELI_FLAGS_BOOT = 2,
+ };
+
+/* FIXME: support version 0. */
+/* FIXME: support big-endian pre-version-4 volumes. */
+/* FIXME: support for keyfiles. */
+/* FIXME: support for HMAC. */
+const char *algorithms[] = {
+ [0x01] = "des",
+ [0x02] = "3des",
+ [0x03] = "blowfish",
+ [0x04] = "cast5",
+ /* FIXME: 0x05 is skipjack, but we don't have it. */
+ [0x0b] = "aes",
+ /* FIXME: 0x10 is null. */
+ [0x15] = "camellia128",
+ [0x16] = "aes"
+};
+
+#define MAX_PASSPHRASE 256
+
+static gcry_err_code_t
+geli_rekey (struct grub_cryptodisk *dev, grub_uint64_t zoneno)
+{
+ gcry_err_code_t gcry_err;
+ const struct {
+ char magic[4];
+ grub_uint64_t zone;
+ } GRUB_PACKED tohash
+ = { {'e', 'k', 'e', 'y'}, grub_cpu_to_le64 (zoneno) };
+ GRUB_PROPERLY_ALIGNED_ARRAY (key, GRUB_CRYPTO_MAX_MDLEN);
+
+ if (dev->hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
+ return GPG_ERR_INV_ARG;
+
+ grub_dprintf ("geli", "rekeying %" PRIuGRUB_UINT64_T " keysize=%d\n",
+ zoneno, dev->rekey_derived_size);
+ gcry_err = grub_crypto_hmac_buffer (dev->hash, dev->rekey_key, 64,
+ &tohash, sizeof (tohash), key);
+ if (gcry_err)
+ return gcry_err;
+
+ return grub_cryptodisk_setkey (dev, (grub_uint8_t *) key,
+ dev->rekey_derived_size);
+}
+
+static inline gcry_err_code_t
+make_uuid (const struct grub_geli_phdr *header,
+ char *uuid)
+{
+ grub_uint8_t uuidbin[GRUB_CRYPTODISK_MAX_UUID_LENGTH];
+ gcry_err_code_t err;
+ grub_uint8_t *iptr;
+ char *optr;
+
+ if (2 * GRUB_MD_SHA256->mdlen + 1 > GRUB_CRYPTODISK_MAX_UUID_LENGTH)
+ return GPG_ERR_TOO_LARGE;
+ err = grub_crypto_hmac_buffer (GRUB_MD_SHA256,
+ header->salt, sizeof (header->salt),
+ "uuid", sizeof ("uuid") - 1, uuidbin);
+ if (err)
+ return err;
+
+ optr = uuid;
+ for (iptr = uuidbin; iptr < &uuidbin[GRUB_MD_SHA256->mdlen]; iptr++)
+ {
+ grub_snprintf (optr, 3, "%02x", *iptr);
+ optr += 2;
+ }
+ *optr = 0;
+ return GPG_ERR_NO_ERROR;
+}
+
+#ifdef GRUB_UTIL
+
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/misc.h>
+
+char *
+grub_util_get_geli_uuid (const char *dev)
+{
+ grub_util_fd_t fd;
+ grub_uint64_t s;
+ unsigned log_secsize;
+ grub_uint8_t hdr[512];
+ struct grub_geli_phdr *header;
+ char *uuid;
+ gcry_err_code_t err;
+
+ fd = grub_util_fd_open (dev, GRUB_UTIL_FD_O_RDONLY);
+
+ if (!GRUB_UTIL_FD_IS_VALID (fd))
+ return NULL;
+
+ s = grub_util_get_fd_size (fd, dev, &log_secsize);
+ s >>= log_secsize;
+ 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)
+ grub_util_error ("%s", _("couldn't read ELI metadata"));
+
+ grub_util_fd_close (fd);
+
+ COMPILE_TIME_ASSERT (sizeof (header) <= 512);
+ header = (void *) &hdr;
+
+ /* Look for GELI magic sequence. */
+ if (grub_memcmp (header->magic, GELI_MAGIC, sizeof (GELI_MAGIC))
+ || 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)
+ {
+ grub_free (uuid);
+ return NULL;
+ }
+
+ return uuid;
+}
+#endif
+
+static grub_cryptodisk_t
+configure_ciphers (grub_disk_t disk, const char *check_uuid,
+ int boot_only)
+{
+ grub_cryptodisk_t newdev;
+ struct grub_geli_phdr header;
+ grub_crypto_cipher_handle_t cipher = NULL, secondary_cipher = NULL;
+ const struct gcry_cipher_spec *ciph;
+ const char *ciphername = NULL;
+ gcry_err_code_t gcry_err;
+ char uuid[GRUB_CRYPTODISK_MAX_UUID_LENGTH];
+ grub_disk_addr_t sector;
+ grub_err_t err;
+
+ if (2 * GRUB_MD_SHA256->mdlen + 1 > GRUB_CRYPTODISK_MAX_UUID_LENGTH)
+ return NULL;
+
+ sector = grub_disk_native_sectors (disk);
+ if (sector == GRUB_DISK_SIZE_UNKNOWN || sector == 0)
+ return NULL;
+
+ /* Read the GELI header. */
+ err = grub_disk_read (disk, sector - 1, 0, sizeof (header), &header);
+ if (err)
+ return NULL;
+
+ /* Look for GELI magic sequence. */
+ if (grub_memcmp (header.magic, GELI_MAGIC, sizeof (GELI_MAGIC))
+ || grub_le_to_cpu32 (header.version) > 7
+ || grub_le_to_cpu32 (header.version) < 1)
+ {
+ grub_dprintf ("geli", "wrong magic %02x\n", header.magic[0]);
+ return NULL;
+ }
+
+ if ((grub_le_to_cpu32 (header.sector_size)
+ & (grub_le_to_cpu32 (header.sector_size) - 1))
+ || grub_le_to_cpu32 (header.sector_size) == 0)
+ {
+ grub_dprintf ("geli", "incorrect sector size %d\n",
+ grub_le_to_cpu32 (header.sector_size));
+ return NULL;
+ }
+
+ if (grub_le_to_cpu32 (header.flags) & GRUB_GELI_FLAGS_ONETIME)
+ {
+ grub_dprintf ("geli", "skipping one-time volume\n");
+ return NULL;
+ }
+
+ if (boot_only && !(grub_le_to_cpu32 (header.flags) & GRUB_GELI_FLAGS_BOOT))
+ {
+ grub_dprintf ("geli", "not a boot volume\n");
+ return NULL;
+ }
+
+ gcry_err = make_uuid (&header, uuid);
+ if (gcry_err)
+ {
+ grub_crypto_gcry_error (gcry_err);
+ return NULL;
+ }
+
+ if (check_uuid && grub_strcasecmp (check_uuid, uuid) != 0)
+ {
+ grub_dprintf ("geli", "%s != %s\n", uuid, check_uuid);
+ return NULL;
+ }
+
+ if (grub_le_to_cpu16 (header.alg) >= ARRAY_SIZE (algorithms)
+ || algorithms[grub_le_to_cpu16 (header.alg)] == NULL)
+ {
+ grub_error (GRUB_ERR_FILE_NOT_FOUND, "Cipher 0x%x unknown",
+ grub_le_to_cpu16 (header.alg));
+ return NULL;
+ }
+
+ ciphername = algorithms[grub_le_to_cpu16 (header.alg)];
+ ciph = grub_crypto_lookup_cipher_by_name (ciphername);
+ if (!ciph)
+ {
+ grub_error (GRUB_ERR_FILE_NOT_FOUND, "Cipher %s isn't available",
+ ciphername);
+ return NULL;
+ }
+
+ /* Configure the cipher used for the bulk data. */
+ cipher = grub_crypto_cipher_open (ciph);
+ if (!cipher)
+ return NULL;
+
+ if (grub_le_to_cpu16 (header.alg) == 0x16)
+ {
+ secondary_cipher = grub_crypto_cipher_open (ciph);
+ if (!secondary_cipher)
+ {
+ 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)
+ {
+ grub_crypto_cipher_close (cipher);
+ grub_crypto_cipher_close (secondary_cipher);
+ return NULL;
+ }
+ newdev->cipher = cipher;
+ newdev->secondary_cipher = secondary_cipher;
+ newdev->offset_sectors = 0;
+ newdev->source_disk = NULL;
+ newdev->benbi_log = 0;
+ if (grub_le_to_cpu16 (header.alg) == 0x16)
+ {
+ newdev->mode = GRUB_CRYPTODISK_MODE_XTS;
+ newdev->mode_iv = GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64;
+ }
+ else
+ {
+ newdev->mode = GRUB_CRYPTODISK_MODE_CBC;
+ newdev->mode_iv = GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64_HASH;
+ }
+ newdev->essiv_cipher = NULL;
+ newdev->essiv_hash = NULL;
+ newdev->hash = GRUB_MD_SHA512;
+ newdev->iv_hash = GRUB_MD_SHA256;
+
+ for (newdev->log_sector_size = 0;
+ (1U << newdev->log_sector_size) < grub_le_to_cpu32 (header.sector_size);
+ newdev->log_sector_size++);
+
+ if (grub_le_to_cpu32 (header.version) >= 5)
+ {
+ newdev->rekey = geli_rekey;
+ newdev->rekey_shift = 20;
+ }
+
+ newdev->modname = "geli";
+
+ newdev->total_sectors = grub_disk_native_sectors (disk) - 1;
+ grub_memcpy (newdev->uuid, uuid, sizeof (newdev->uuid));
+ COMPILE_TIME_ASSERT (sizeof (newdev->uuid) >= 32 * 2 + 1);
+ return newdev;
+}
+
+static grub_err_t
+recover_key (grub_disk_t source, grub_cryptodisk_t dev)
+{
+ grub_size_t keysize;
+ grub_uint8_t digest[GRUB_CRYPTO_MAX_MDLEN];
+ 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;
+ struct grub_geli_phdr header;
+ char *tmp;
+ grub_disk_addr_t sector;
+ grub_err_t err;
+
+ if (dev->cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
+ return grub_error (GRUB_ERR_BUG, "cipher block is too long");
+
+ if (dev->hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
+ return grub_error (GRUB_ERR_BUG, "mdlen is too long");
+
+ sector = grub_disk_native_sectors (source);
+ if (sector == GRUB_DISK_SIZE_UNKNOWN || sector == 0)
+ return grub_error (GRUB_ERR_BUG, "not a geli");
+
+ /* Read the GELI header. */
+ err = grub_disk_read (source, sector - 1, 0, sizeof (header), &header);
+ if (err)
+ return err;
+
+ keysize = grub_le_to_cpu16 (header.keylen) / GRUB_CHAR_BIT;
+ grub_memset (zero, 0, sizeof (zero));
+
+ grub_puts_ (N_("Attempting to decrypt master key..."));
+
+ /* Get the passphrase from the user. */
+ tmp = NULL;
+ if (source->partition)
+ tmp = grub_partition_get_name (source->partition);
+ grub_printf_ (N_("Enter passphrase for %s%s%s (%s): "), source->name,
+ source->partition ? "," : "", tmp ? : "",
+ dev->uuid);
+ grub_free (tmp);
+ if (!grub_password_get (passphrase, MAX_PASSPHRASE))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Passphrase not supplied");
+
+ /* Calculate the PBKDF2 of the user supplied passphrase. */
+ if (grub_le_to_cpu32 (header.niter) != 0)
+ {
+ grub_uint8_t pbkdf_key[64];
+ gcry_err = grub_crypto_pbkdf2 (dev->hash, (grub_uint8_t *) passphrase,
+ grub_strlen (passphrase),
+ header.salt,
+ sizeof (header.salt),
+ grub_le_to_cpu32 (header.niter),
+ pbkdf_key, sizeof (pbkdf_key));
+
+ if (gcry_err)
+ return grub_crypto_gcry_error (gcry_err);
+
+ gcry_err = grub_crypto_hmac_buffer (dev->hash, NULL, 0, pbkdf_key,
+ sizeof (pbkdf_key), geomkey);
+ if (gcry_err)
+ return grub_crypto_gcry_error (gcry_err);
+ }
+ else
+ {
+ struct grub_crypto_hmac_handle *hnd;
+
+ hnd = grub_crypto_hmac_init (dev->hash, NULL, 0);
+ if (!hnd)
+ return grub_crypto_gcry_error (GPG_ERR_OUT_OF_MEMORY);
+
+ grub_crypto_hmac_write (hnd, header.salt, sizeof (header.salt));
+ grub_crypto_hmac_write (hnd, passphrase, grub_strlen (passphrase));
+
+ gcry_err = grub_crypto_hmac_fini (hnd, geomkey);
+ if (gcry_err)
+ return grub_crypto_gcry_error (gcry_err);
+ }
+
+ gcry_err = grub_crypto_hmac_buffer (dev->hash, geomkey,
+ dev->hash->mdlen, "\1", 1, digest);
+ if (gcry_err)
+ return grub_crypto_gcry_error (gcry_err);
+
+ gcry_err = grub_crypto_hmac_buffer (dev->hash, geomkey,
+ dev->hash->mdlen, "\0", 1, verify_key);
+ if (gcry_err)
+ return grub_crypto_gcry_error (gcry_err);
+
+ grub_dprintf ("geli", "keylen = %" PRIuGRUB_SIZE "\n", keysize);
+
+ /* Try to recover master key from each active keyslot. */
+ for (i = 0; i < ARRAY_SIZE (header.keys); i++)
+ {
+ struct grub_geli_key candidate_key;
+ grub_uint8_t key_hmac[GRUB_CRYPTO_MAX_MDLEN];
+
+ /* Check if keyslot is enabled. */
+ if (! (header.keys_used & (1 << i)))
+ continue;
+
+ grub_dprintf ("geli", "Trying keyslot %d\n", i);
+
+ gcry_err = grub_crypto_cipher_set_key (dev->cipher,
+ digest, keysize);
+ if (gcry_err)
+ return grub_crypto_gcry_error (gcry_err);
+
+ gcry_err = grub_crypto_cbc_decrypt (dev->cipher, &candidate_key,
+ &header.keys[i],
+ sizeof (candidate_key),
+ zero);
+ if (gcry_err)
+ return grub_crypto_gcry_error (gcry_err);
+
+ gcry_err = grub_crypto_hmac_buffer (dev->hash, verify_key,
+ dev->hash->mdlen,
+ &candidate_key,
+ (sizeof (candidate_key)
+ - sizeof (candidate_key.hmac)),
+ key_hmac);
+ if (gcry_err)
+ return grub_crypto_gcry_error (gcry_err);
+
+ if (grub_memcmp (candidate_key.hmac, key_hmac, dev->hash->mdlen) != 0)
+ 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)
+ {
+ grub_size_t real_keysize = keysize;
+ if (grub_le_to_cpu16 (header.alg) == 0x16)
+ real_keysize *= 2;
+ gcry_err = grub_cryptodisk_setkey (dev, candidate_key.cipher_key,
+ real_keysize);
+ if (gcry_err)
+ return grub_crypto_gcry_error (gcry_err);
+ }
+ else
+ {
+ grub_size_t real_keysize = keysize;
+ if (grub_le_to_cpu16 (header.alg) == 0x16)
+ real_keysize *= 2;
+
+ 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 (geli_cipher_key));
+ }
+
+ dev->iv_prefix_len = sizeof (candidate_key.iv_key);
+ grub_memcpy (dev->iv_prefix, candidate_key.iv_key,
+ sizeof (candidate_key.iv_key));
+
+ COMPILE_TIME_ASSERT (sizeof (dev->iv_prefix) >= sizeof (candidate_key.iv_key));
+
+ return GRUB_ERR_NONE;
+ }
+
+ return GRUB_ACCESS_DENIED;
+}
+
+struct grub_cryptodisk_dev geli_crypto = {
+ .scan = configure_ciphers,
+ .recover_key = recover_key
+};
+
+GRUB_MOD_INIT (geli)
+{
+ grub_cryptodisk_dev_register (&geli_crypto);
+}
+
+GRUB_MOD_FINI (geli)
+{
+ grub_cryptodisk_dev_unregister (&geli_crypto);
+}
diff --git a/grub-core/disk/host.c b/grub-core/disk/host.c
new file mode 100644
index 0000000..c151d22
--- /dev/null
+++ b/grub-core/disk/host.c
@@ -0,0 +1,103 @@
+/* host.c - Dummy disk driver to provide access to the hosts filesystem */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* When using the disk, make a reference to this module. Otherwise
+ the user will end up with a useless module :-). */
+
+#include <config.h>
+#include <config-util.h>
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/emu/hostdisk.h>
+
+int grub_disk_host_i_want_a_reference;
+
+static int
+grub_host_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ if (hook ("host", hook_data))
+ return 1;
+ return 0;
+}
+
+static grub_err_t
+grub_host_open (const char *name, grub_disk_t disk)
+{
+ if (grub_strcmp (name, "host"))
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a host disk");
+
+ disk->total_sectors = 0;
+ disk->id = 0;
+
+ disk->data = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_host_close (grub_disk_t disk __attribute((unused)))
+{
+}
+
+static grub_err_t
+grub_host_read (grub_disk_t disk __attribute((unused)),
+ grub_disk_addr_t sector __attribute((unused)),
+ grub_size_t size __attribute((unused)),
+ char *buf __attribute((unused)))
+{
+ return GRUB_ERR_OUT_OF_RANGE;
+}
+
+static grub_err_t
+grub_host_write (grub_disk_t disk __attribute ((unused)),
+ grub_disk_addr_t sector __attribute ((unused)),
+ grub_size_t size __attribute ((unused)),
+ const char *buf __attribute ((unused)))
+{
+ return GRUB_ERR_OUT_OF_RANGE;
+}
+
+static struct grub_disk_dev grub_host_dev =
+ {
+ /* The only important line in this file :-) */
+ .name = "host",
+ .id = GRUB_DISK_DEVICE_HOST_ID,
+ .disk_iterate = grub_host_iterate,
+ .disk_open = grub_host_open,
+ .disk_close = grub_host_close,
+ .disk_read = grub_host_read,
+ .disk_write = grub_host_write,
+ .next = 0
+ };
+
+GRUB_MOD_INIT(host)
+{
+ grub_disk_dev_register (&grub_host_dev);
+}
+
+GRUB_MOD_FINI(host)
+{
+ grub_disk_dev_unregister (&grub_host_dev);
+}
diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c
new file mode 100644
index 0000000..8ca250c
--- /dev/null
+++ b/grub-core/disk/i386/pc/biosdisk.c
@@ -0,0 +1,688 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/biosdisk.h>
+#include <grub/machine/kernel.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/int.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/term.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static int cd_drive = 0;
+static int grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap);
+
+static int grub_biosdisk_get_num_floppies (void)
+{
+ struct grub_bios_int_registers regs;
+ int drive;
+
+ /* reset the disk system first */
+ regs.eax = 0;
+ regs.edx = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+
+ grub_bios_interrupt (0x13, &regs);
+
+ for (drive = 0; drive < 2; drive++)
+ {
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT | GRUB_CPU_INT_FLAGS_CARRY;
+ regs.edx = drive;
+
+ /* call GET DISK TYPE */
+ regs.eax = 0x1500;
+ grub_bios_interrupt (0x13, &regs);
+ if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
+ break;
+
+ /* check if this drive exists */
+ if (!(regs.eax & 0x300))
+ break;
+ }
+
+ return drive;
+}
+
+/*
+ * Call IBM/MS INT13 Extensions (int 13 %ah=AH) for DRIVE. DAP
+ * is passed for disk address packet. If an error occurs, return
+ * non-zero, otherwise zero.
+ */
+
+static int
+grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap)
+{
+ struct grub_bios_int_registers regs;
+ regs.eax = ah << 8;
+ /* compute the address of disk_address_packet */
+ regs.ds = (((grub_addr_t) dap) & 0xffff0000) >> 4;
+ regs.esi = (((grub_addr_t) dap) & 0xffff);
+ regs.edx = drive;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+
+ grub_bios_interrupt (0x13, &regs);
+ return (regs.eax >> 8) & 0xff;
+}
+
+/*
+ * Call standard and old INT13 (int 13 %ah=AH) for DRIVE. Read/write
+ * NSEC sectors from COFF/HOFF/SOFF into SEGMENT. If an error occurs,
+ * return non-zero, otherwise zero.
+ */
+static int
+grub_biosdisk_rw_standard (int ah, int drive, int coff, int hoff,
+ int soff, int nsec, int segment)
+{
+ int ret, i;
+
+ /* Try 3 times. */
+ for (i = 0; i < 3; i++)
+ {
+ struct grub_bios_int_registers regs;
+
+ /* set up CHS information */
+ /* set %ch to low eight bits of cylinder */
+ regs.ecx = (coff << 8) & 0xff00;
+ /* set bits 6-7 of %cl to high two bits of cylinder */
+ regs.ecx |= (coff >> 2) & 0xc0;
+ /* set bits 0-5 of %cl to sector */
+ regs.ecx |= soff & 0x3f;
+
+ /* set %dh to head and %dl to drive */
+ regs.edx = (drive & 0xff) | ((hoff << 8) & 0xff00);
+ /* set %ah to AH */
+ regs.eax = (ah << 8) & 0xff00;
+ /* set %al to NSEC */
+ regs.eax |= nsec & 0xff;
+
+ regs.ebx = 0;
+ regs.es = segment;
+
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+
+ grub_bios_interrupt (0x13, &regs);
+ /* check if successful */
+ if (!(regs.flags & GRUB_CPU_INT_FLAGS_CARRY))
+ return 0;
+
+ /* save return value */
+ ret = regs.eax >> 8;
+
+ /* if fail, reset the disk system */
+ regs.eax = 0;
+ regs.edx = (drive & 0xff);
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x13, &regs);
+ }
+ return ret;
+}
+
+/*
+ * Check if LBA is supported for DRIVE. If it is supported, then return
+ * the major version of extensions, otherwise zero.
+ */
+static int
+grub_biosdisk_check_int13_extensions (int drive)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.edx = drive & 0xff;
+ regs.eax = 0x4100;
+ regs.ebx = 0x55aa;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x13, &regs);
+
+ if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
+ return 0;
+
+ if ((regs.ebx & 0xffff) != 0xaa55)
+ return 0;
+
+ /* check if AH=0x42 is supported */
+ if (!(regs.ecx & 1))
+ return 0;
+
+ return (regs.eax >> 8) & 0xff;
+}
+
+/*
+ * Return the geometry of DRIVE in CYLINDERS, HEADS and SECTORS. If an
+ * error occurs, then return non-zero, otherwise zero.
+ */
+static int
+grub_biosdisk_get_diskinfo_standard (int drive,
+ unsigned long *cylinders,
+ unsigned long *heads,
+ unsigned long *sectors)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x0800;
+ regs.edx = drive & 0xff;
+
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x13, &regs);
+
+ /* Check if unsuccessful. Ignore return value if carry isn't set to
+ workaround some buggy BIOSes. */
+ if ((regs.flags & GRUB_CPU_INT_FLAGS_CARRY) && ((regs.eax & 0xff00) != 0))
+ return (regs.eax & 0xff00) >> 8;
+
+ /* bogus BIOSes may not return an error number */
+ /* 0 sectors means no disk */
+ if (!(regs.ecx & 0x3f))
+ /* XXX 0x60 is one of the unused error numbers */
+ return 0x60;
+
+ /* the number of heads is counted from zero */
+ *heads = ((regs.edx >> 8) & 0xff) + 1;
+ *cylinders = (((regs.ecx >> 8) & 0xff) | ((regs.ecx << 2) & 0x0300)) + 1;
+ *sectors = regs.ecx & 0x3f;
+ return 0;
+}
+
+static int
+grub_biosdisk_get_diskinfo_real (int drive, void *drp, grub_uint16_t ax)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = ax;
+
+ /* compute the address of drive parameters */
+ regs.esi = ((grub_addr_t) drp) & 0xf;
+ regs.ds = ((grub_addr_t) drp) >> 4;
+ regs.edx = drive & 0xff;
+
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x13, &regs);
+
+ /* Check if unsuccessful. Ignore return value if carry isn't set to
+ workaround some buggy BIOSes. */
+ if ((regs.flags & GRUB_CPU_INT_FLAGS_CARRY) && ((regs.eax & 0xff00) != 0))
+ return (regs.eax & 0xff00) >> 8;
+
+ return 0;
+}
+
+/*
+ * Return the cdrom information of DRIVE in CDRP. If an error occurs,
+ * then return non-zero, otherwise zero.
+ */
+static int
+grub_biosdisk_get_cdinfo_int13_extensions (int drive, void *cdrp)
+{
+ return grub_biosdisk_get_diskinfo_real (drive, cdrp, 0x4b01);
+}
+
+/*
+ * Return the geometry of DRIVE in a drive parameters, DRP. If an error
+ * occurs, then return non-zero, otherwise zero.
+ */
+static int
+grub_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp)
+{
+ return grub_biosdisk_get_diskinfo_real (drive, drp, 0x4800);
+}
+
+static int
+grub_biosdisk_get_drive (const char *name)
+{
+ unsigned long drive;
+
+ if (name[0] == 'c' && name[1] == 'd' && name[2] == 0 && cd_drive)
+ return cd_drive;
+
+ if ((name[0] != 'f' && name[0] != 'h') || name[1] != 'd')
+ goto fail;
+
+ drive = grub_strtoul (name + 2, 0, 10);
+ if (grub_errno != GRUB_ERR_NONE)
+ goto fail;
+
+ if (name[0] == 'h')
+ drive += 0x80;
+
+ return (int) drive ;
+
+ fail:
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a biosdisk");
+ return -1;
+}
+
+static int
+grub_biosdisk_call_hook (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ int drive)
+{
+ char name[10];
+
+ if (cd_drive && drive == cd_drive)
+ return hook ("cd", hook_data);
+
+ grub_snprintf (name, sizeof (name),
+ (drive & 0x80) ? "hd%d" : "fd%d", drive & (~0x80));
+ return hook (name, hook_data);
+}
+
+static int
+grub_biosdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ int num_floppies;
+ int drive;
+
+ /* For hard disks, attempt to read the MBR. */
+ switch (pull)
+ {
+ case GRUB_DISK_PULL_NONE:
+ for (drive = 0x80; drive < 0x90; drive++)
+ {
+ if (grub_biosdisk_rw_standard (0x02, drive, 0, 0, 1, 1,
+ GRUB_MEMORY_MACHINE_SCRATCH_SEG) != 0)
+ {
+ grub_dprintf ("disk", "Read error when probing drive 0x%2x\n", drive);
+ break;
+ }
+
+ if (grub_biosdisk_call_hook (hook, hook_data, drive))
+ return 1;
+ }
+ return 0;
+
+ case GRUB_DISK_PULL_REMOVABLE:
+ if (cd_drive)
+ {
+ if (grub_biosdisk_call_hook (hook, hook_data, cd_drive))
+ return 1;
+ }
+
+ /* For floppy disks, we can get the number safely. */
+ num_floppies = grub_biosdisk_get_num_floppies ();
+ for (drive = 0; drive < num_floppies; drive++)
+ if (grub_biosdisk_call_hook (hook, hook_data, drive))
+ return 1;
+ return 0;
+ default:
+ return 0;
+ }
+ return 0;
+}
+
+static grub_err_t
+grub_biosdisk_open (const char *name, grub_disk_t disk)
+{
+ grub_uint64_t total_sectors = 0;
+ int drive;
+ struct grub_biosdisk_data *data;
+
+ drive = grub_biosdisk_get_drive (name);
+ if (drive < 0)
+ return grub_errno;
+
+ disk->id = drive;
+
+ data = (struct grub_biosdisk_data *) grub_zalloc (sizeof (*data));
+ if (! data)
+ return grub_errno;
+
+ data->drive = drive;
+
+ if ((cd_drive) && (drive == cd_drive))
+ {
+ data->flags = GRUB_BIOSDISK_FLAG_LBA | GRUB_BIOSDISK_FLAG_CDROM;
+ data->sectors = 8;
+ disk->log_sector_size = 11;
+ /* TODO: get the correct size. */
+ total_sectors = GRUB_DISK_SIZE_UNKNOWN;
+ }
+ else
+ {
+ /* HDD */
+ int version;
+
+ disk->log_sector_size = 9;
+
+ version = grub_biosdisk_check_int13_extensions (drive);
+ if (version)
+ {
+ struct grub_biosdisk_drp *drp
+ = (struct grub_biosdisk_drp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+
+ /* Clear out the DRP. */
+ grub_memset (drp, 0, sizeof (*drp));
+ drp->size = sizeof (*drp);
+ if (! grub_biosdisk_get_diskinfo_int13_extensions (drive, drp))
+ {
+ data->flags = GRUB_BIOSDISK_FLAG_LBA;
+
+ if (drp->total_sectors)
+ total_sectors = drp->total_sectors;
+ else
+ /* 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 = ((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
+ && drp->bytes_per_sector <= 16384)
+ {
+ for (disk->log_sector_size = 0;
+ (1 << disk->log_sector_size) < drp->bytes_per_sector;
+ disk->log_sector_size++);
+ }
+ }
+ }
+ }
+
+ if (! (data->flags & GRUB_BIOSDISK_FLAG_CDROM))
+ {
+ if (grub_biosdisk_get_diskinfo_standard (drive,
+ &data->cylinders,
+ &data->heads,
+ &data->sectors) != 0)
+ {
+ if (total_sectors && (data->flags & GRUB_BIOSDISK_FLAG_LBA))
+ {
+ data->sectors = 63;
+ data->heads = 255;
+ data->cylinders
+ = grub_divmod64 (total_sectors
+ + data->heads * data->sectors - 1,
+ data->heads * data->sectors, 0);
+ }
+ else
+ {
+ grub_free (data);
+ return grub_error (GRUB_ERR_BAD_DEVICE, "%s cannot get C/H/S values", disk->name);
+ }
+ }
+
+ if (data->sectors == 0)
+ data->sectors = 63;
+ if (data->heads == 0)
+ data->heads = 255;
+
+ if (! total_sectors)
+ total_sectors = ((grub_uint64_t) data->cylinders)
+ * data->heads * data->sectors;
+ }
+
+ disk->total_sectors = total_sectors;
+ /* Limit the max to 0x7f because of Phoenix EDD. */
+ disk->max_agglomerate = 0x7f >> GRUB_DISK_CACHE_BITS;
+ COMPILE_TIME_ASSERT ((0x7f >> GRUB_DISK_CACHE_BITS
+ << (GRUB_DISK_SECTOR_BITS + GRUB_DISK_CACHE_BITS))
+ + sizeof (struct grub_biosdisk_dap)
+ < GRUB_MEMORY_MACHINE_SCRATCH_SIZE);
+
+ disk->data = data;
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_biosdisk_close (grub_disk_t disk)
+{
+ grub_free (disk->data);
+}
+
+/* For readability. */
+#define GRUB_BIOSDISK_READ 0
+#define GRUB_BIOSDISK_WRITE 1
+
+#define GRUB_BIOSDISK_CDROM_RETRY_COUNT 3
+
+static grub_err_t
+grub_biosdisk_rw (int cmd, grub_disk_t disk,
+ grub_disk_addr_t sector, grub_size_t size,
+ unsigned segment)
+{
+ 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;
+
+ dap = (struct grub_biosdisk_dap *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR
+ + (data->sectors
+ << disk->log_sector_size));
+ dap->length = sizeof (*dap);
+ dap->reserved = 0;
+ dap->blocks = size;
+ dap->buffer = segment << 16; /* The format SEGMENT:ADDRESS. */
+ dap->block = sector;
+
+ if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
+ {
+ int i;
+
+ if (cmd)
+ return grub_error (GRUB_ERR_WRITE_ERROR, N_("cannot write to CD-ROM"));
+
+ for (i = 0; i < GRUB_BIOSDISK_CDROM_RETRY_COUNT; i++)
+ if (! grub_biosdisk_rw_int13_extensions (0x42, data->drive, dap))
+ break;
+
+ if (i == GRUB_BIOSDISK_CDROM_RETRY_COUNT)
+ return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
+ "from `%s'"),
+ (unsigned long long) sector,
+ disk->name);
+ }
+ else
+ if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap))
+ {
+ /* Fall back to the CHS mode. */
+ data->flags &= ~GRUB_BIOSDISK_FLAG_LBA;
+ disk->total_sectors = data->cylinders * data->heads * data->sectors;
+ return grub_biosdisk_rw (cmd, disk, sector, size, segment);
+ }
+ }
+ else
+ {
+ unsigned coff, hoff, soff;
+ unsigned head;
+
+ /* It is impossible to reach over 8064 MiB (a bit less than LBA24) with
+ the traditional CHS access. */
+ if (sector >
+ 1024 /* cylinders */ *
+ 256 /* heads */ *
+ 63 /* spt */)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("attempt to read or write outside of disk `%s'"),
+ disk->name);
+
+ soff = ((grub_uint32_t) sector) % data->sectors + 1;
+ head = ((grub_uint32_t) sector) / data->sectors;
+ hoff = head % data->heads;
+ coff = head / data->heads;
+
+ if (coff >= data->cylinders)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("attempt to read or write outside of disk `%s'"),
+ disk->name);
+
+ if (grub_biosdisk_rw_standard (cmd + 0x02, data->drive,
+ coff, hoff, soff, size, segment))
+ {
+ switch (cmd)
+ {
+ case GRUB_BIOSDISK_READ:
+ return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
+ "from `%s'"),
+ (unsigned long long) sector,
+ disk->name);
+ case GRUB_BIOSDISK_WRITE:
+ return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx "
+ "to `%s'"),
+ (unsigned long long) sector,
+ disk->name);
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/* Return the number of sectors which can be read safely at a time. */
+static grub_size_t
+get_safe_sectors (grub_disk_t disk, grub_disk_addr_t sector)
+{
+ grub_size_t size;
+ grub_uint64_t offset;
+ struct grub_biosdisk_data *data = disk->data;
+ grub_uint32_t sectors = data->sectors;
+
+ /* OFFSET = SECTOR % SECTORS */
+ grub_divmod64 (sector, sectors, &offset);
+
+ size = sectors - offset;
+
+ return size;
+}
+
+static grub_err_t
+grub_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ while (size)
+ {
+ grub_size_t len;
+
+ len = get_safe_sectors (disk, sector);
+
+ if (len > size)
+ len = size;
+
+ if (grub_biosdisk_rw (GRUB_BIOSDISK_READ, disk, sector, len,
+ GRUB_MEMORY_MACHINE_SCRATCH_SEG))
+ return grub_errno;
+
+ grub_memcpy (buf, (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR,
+ len << disk->log_sector_size);
+
+ buf += len << disk->log_sector_size;
+ sector += len;
+ size -= len;
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, const char *buf)
+{
+ struct grub_biosdisk_data *data = disk->data;
+
+ if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
+ return grub_error (GRUB_ERR_IO, N_("cannot write to CD-ROM"));
+
+ while (size)
+ {
+ grub_size_t len;
+
+ len = get_safe_sectors (disk, sector);
+ if (len > size)
+ len = size;
+
+ grub_memcpy ((void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR, buf,
+ len << disk->log_sector_size);
+
+ if (grub_biosdisk_rw (GRUB_BIOSDISK_WRITE, disk, sector, len,
+ GRUB_MEMORY_MACHINE_SCRATCH_SEG))
+ return grub_errno;
+
+ buf += len << disk->log_sector_size;
+ sector += len;
+ size -= len;
+ }
+
+ return grub_errno;
+}
+
+static struct grub_disk_dev grub_biosdisk_dev =
+ {
+ .name = "biosdisk",
+ .id = GRUB_DISK_DEVICE_BIOSDISK_ID,
+ .disk_iterate = grub_biosdisk_iterate,
+ .disk_open = grub_biosdisk_open,
+ .disk_close = grub_biosdisk_close,
+ .disk_read = grub_biosdisk_read,
+ .disk_write = grub_biosdisk_write,
+ .next = 0
+ };
+
+static void
+grub_disk_biosdisk_fini (void)
+{
+ grub_disk_dev_unregister (&grub_biosdisk_dev);
+}
+
+GRUB_MOD_INIT(biosdisk)
+{
+ struct grub_biosdisk_cdrp *cdrp
+ = (struct grub_biosdisk_cdrp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ grub_uint8_t boot_drive;
+
+ if (grub_disk_firmware_is_tainted)
+ {
+ grub_puts_ (N_("Native disk drivers are in use. "
+ "Refusing to use firmware disk interface."));
+ return;
+ }
+ grub_disk_firmware_fini = grub_disk_biosdisk_fini;
+
+ grub_memset (cdrp, 0, sizeof (*cdrp));
+ cdrp->size = sizeof (*cdrp);
+ cdrp->media_type = 0xFF;
+ boot_drive = (grub_boot_device >> 24);
+ if ((! grub_biosdisk_get_cdinfo_int13_extensions (boot_drive, cdrp))
+ && ((cdrp->media_type & GRUB_BIOSDISK_CDTYPE_MASK)
+ == GRUB_BIOSDISK_CDTYPE_NO_EMUL))
+ cd_drive = cdrp->drive_no;
+ /* Since diskboot.S rejects devices over 0x90 it must be a CD booted with
+ cdboot.S
+ */
+ if (boot_drive >= 0x90)
+ cd_drive = boot_drive;
+
+ grub_disk_dev_register (&grub_biosdisk_dev);
+}
+
+GRUB_MOD_FINI(biosdisk)
+{
+ grub_disk_biosdisk_fini ();
+}
diff --git a/grub-core/disk/ieee1275/nand.c b/grub-core/disk/ieee1275/nand.c
new file mode 100644
index 0000000..bcf3a06
--- /dev/null
+++ b/grub-core/disk/ieee1275/nand.c
@@ -0,0 +1,242 @@
+/* nand.c - NAND flash disk access. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_nand_data
+{
+ grub_ieee1275_ihandle_t handle;
+ grub_uint32_t block_size;
+};
+
+static int
+grub_nand_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ static int have_nand = -1;
+
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ if (have_nand == -1)
+ {
+ struct grub_ieee1275_devalias alias;
+
+ have_nand = 0;
+ FOR_IEEE1275_DEVALIASES(alias)
+ if (grub_strcmp (alias.name, "nand") == 0)
+ {
+ have_nand = 1;
+ break;
+ }
+ grub_ieee1275_devalias_free (&alias);
+ }
+
+ if (have_nand)
+ return hook ("nand", hook_data);
+
+ return 0;
+}
+
+static grub_err_t
+grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf);
+
+static grub_err_t
+grub_nand_open (const char *name, grub_disk_t disk)
+{
+ grub_ieee1275_ihandle_t dev_ihandle = 0;
+ struct grub_nand_data *data = 0;
+ const char *devname;
+ struct size_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t result;
+ grub_ieee1275_cell_t size1;
+ grub_ieee1275_cell_t size2;
+ } args;
+
+ if (grub_memcmp (name, "nand/", sizeof ("nand/") - 1) == 0)
+ devname = name + sizeof ("nand/") - 1;
+ else if (grub_strcmp (name, "nand") == 0)
+ devname = name;
+ else
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a NAND device");
+
+ data = grub_malloc (sizeof (*data));
+ if (! data)
+ goto fail;
+
+ grub_ieee1275_open (devname, &dev_ihandle);
+ if (! dev_ihandle)
+ {
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
+ goto fail;
+ }
+
+ data->handle = dev_ihandle;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2);
+ args.method = (grub_ieee1275_cell_t) "block-size";
+ args.ihandle = dev_ihandle;
+ args.result = 1;
+
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
+ {
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get block size");
+ goto fail;
+ }
+
+ 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";
+ args.ihandle = dev_ihandle;
+ args.result = 1;
+
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
+ {
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get disk size");
+ goto fail;
+ }
+
+ disk->total_sectors = args.size1;
+ disk->total_sectors <<= 32;
+ disk->total_sectors += args.size2;
+ disk->total_sectors >>= GRUB_DISK_SECTOR_BITS;
+
+ disk->id = dev_ihandle;
+
+ disk->data = data;
+
+ return 0;
+
+fail:
+ if (dev_ihandle)
+ grub_ieee1275_close (dev_ihandle);
+ grub_free (data);
+ return grub_errno;
+}
+
+static void
+grub_nand_close (grub_disk_t disk)
+{
+ grub_ieee1275_close (((struct grub_nand_data *) disk->data)->handle);
+ grub_free (disk->data);
+}
+
+static grub_err_t
+grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ struct grub_nand_data *data = disk->data;
+ grub_size_t bsize, ofs;
+
+ struct read_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t ofs;
+ grub_ieee1275_cell_t page;
+ grub_ieee1275_cell_t len;
+ grub_ieee1275_cell_t buf;
+ grub_ieee1275_cell_t result;
+ } args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
+ args.method = (grub_ieee1275_cell_t) "pio-read";
+ args.ihandle = data->handle;
+ args.buf = (grub_ieee1275_cell_t) buf;
+ args.page = (grub_ieee1275_cell_t) ((grub_size_t) sector / data->block_size);
+
+ ofs = ((grub_size_t) sector % data->block_size) << GRUB_DISK_SECTOR_BITS;
+ size <<= GRUB_DISK_SECTOR_BITS;
+ bsize = (data->block_size << GRUB_DISK_SECTOR_BITS);
+
+ do
+ {
+ grub_size_t len;
+
+ len = (ofs + size > bsize) ? (bsize - ofs) : size;
+
+ args.len = (grub_ieee1275_cell_t) len;
+ args.ofs = (grub_ieee1275_cell_t) ofs;
+ args.result = 1;
+
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
+ return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
+ "from `%s'"),
+ (unsigned long long) sector,
+ disk->name);
+
+ ofs = 0;
+ size -= len;
+ args.buf += len;
+ args.page++;
+ } while (size);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_nand_write (grub_disk_t disk __attribute ((unused)),
+ grub_disk_addr_t sector __attribute ((unused)),
+ grub_size_t size __attribute ((unused)),
+ const char *buf __attribute ((unused)))
+{
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "nand write is not supported");
+}
+
+static struct grub_disk_dev grub_nand_dev =
+ {
+ .name = "nand",
+ .id = GRUB_DISK_DEVICE_NAND_ID,
+ .disk_iterate = grub_nand_iterate,
+ .disk_open = grub_nand_open,
+ .disk_close = grub_nand_close,
+ .disk_read = grub_nand_read,
+ .disk_write = grub_nand_write,
+ .next = 0
+ };
+
+GRUB_MOD_INIT(nand)
+{
+ grub_disk_dev_register (&grub_nand_dev);
+}
+
+GRUB_MOD_FINI(nand)
+{
+ grub_disk_dev_unregister (&grub_nand_dev);
+}
diff --git a/grub-core/disk/ieee1275/obdisk.c b/grub-core/disk/ieee1275/obdisk.c
new file mode 100644
index 0000000..ec413c3
--- /dev/null
+++ b/grub-core/disk/ieee1275/obdisk.c
@@ -0,0 +1,1076 @@
+/* obdisk.c - Open Boot disk access. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2019 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/disk.h>
+#include <grub/env.h>
+#include <grub/i18n.h>
+#include <grub/kernel.h>
+#include <grub/list.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/scsicmd.h>
+#include <grub/time.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/ieee1275/obdisk.h>
+
+#define IEEE1275_DEV "ieee1275/"
+#define IEEE1275_DISK_ALIAS "/disk@"
+
+struct disk_dev
+{
+ struct disk_dev *next;
+ struct disk_dev **prev;
+ char *name;
+ char *raw_name;
+ char *grub_devpath;
+ char *grub_alias_devpath;
+ grub_ieee1275_ihandle_t ihandle;
+ grub_uint32_t block_size;
+ grub_uint64_t num_blocks;
+ unsigned int log_sector_size;
+ grub_uint32_t opened;
+ grub_uint32_t valid;
+ grub_uint32_t boot_dev;
+};
+
+struct parent_dev
+{
+ struct parent_dev *next;
+ struct parent_dev **prev;
+ char *name;
+ char *type;
+ grub_ieee1275_ihandle_t ihandle;
+ grub_uint32_t address_cells;
+};
+
+static struct grub_scsi_test_unit_ready tur =
+{
+ .opcode = grub_scsi_cmd_test_unit_ready,
+ .lun = 0,
+ .reserved1 = 0,
+ .reserved2 = 0,
+ .reserved3 = 0,
+ .control = 0,
+};
+
+static int disks_enumerated;
+static struct disk_dev *disk_devs;
+static struct parent_dev *parent_devs;
+
+static const char *block_blacklist[] = {
+ /* Requires additional work in grub before being able to be used. */
+ "/iscsi-hba",
+ /* This block device should never be used by grub. */
+ "/reboot-memory@0",
+ 0
+};
+
+#define STRCMP(a, b) ((a) && (b) && (grub_strcmp (a, b) == 0))
+
+static char *
+strip_ob_partition (char *path)
+{
+ char *sptr;
+
+ sptr = grub_strstr (path, ":");
+
+ if (sptr != NULL)
+ *sptr = '\0';
+
+ return path;
+}
+
+static void
+escape_commas (const char *src, char *dest)
+{
+ const char *iptr;
+
+ for (iptr = src; *iptr; )
+ {
+ if (*iptr == ',')
+ *dest++ ='\\';
+
+ *dest++ = *iptr++;
+ }
+
+ *dest = '\0';
+}
+
+static int
+count_commas (const char *src)
+{
+ int count = 0;
+
+ for ( ; *src; src++)
+ if (*src == ',')
+ count++;
+
+ return count;
+}
+
+
+static char *
+decode_grub_devname (const char *name)
+{
+ char *devpath = grub_malloc (grub_strlen (name) + 1);
+ char *p, c;
+
+ if (devpath == NULL)
+ return NULL;
+
+ /* Un-escape commas. */
+ p = devpath;
+ while ((c = *name++) != '\0')
+ {
+ if (c == '\\' && *name == ',')
+ {
+ *p++ = ',';
+ name++;
+ }
+ else
+ *p++ = c;
+ }
+
+ *p++ = '\0';
+
+ return devpath;
+}
+
+static char *
+encode_grub_devname (const char *path)
+{
+ char *encoding, *optr;
+
+ if (path == NULL)
+ return NULL;
+
+ encoding = grub_malloc (sizeof (IEEE1275_DEV) + count_commas (path) +
+ grub_strlen (path) + 1);
+
+ if (encoding == NULL)
+ {
+ grub_print_error ();
+ return NULL;
+ }
+
+ optr = grub_stpcpy (encoding, IEEE1275_DEV);
+ escape_commas (path, optr);
+ return encoding;
+}
+
+static char *
+get_parent_devname (const char *devname)
+{
+ char *parent, *pptr;
+
+ parent = grub_strdup (devname);
+
+ if (parent == NULL)
+ {
+ grub_print_error ();
+ return NULL;
+ }
+
+ pptr = grub_strstr (parent, IEEE1275_DISK_ALIAS);
+
+ if (pptr != NULL)
+ *pptr = '\0';
+
+ return parent;
+}
+
+static void
+free_parent_dev (struct parent_dev *parent)
+{
+ if (parent != NULL)
+ {
+ grub_free (parent->name);
+ grub_free (parent->type);
+ grub_free (parent);
+ }
+}
+
+static struct parent_dev *
+init_parent (const char *parent)
+{
+ struct parent_dev *op;
+
+ op = grub_zalloc (sizeof (struct parent_dev));
+
+ if (op == NULL)
+ {
+ grub_print_error ();
+ return NULL;
+ }
+
+ op->name = grub_strdup (parent);
+ op->type = grub_malloc (IEEE1275_MAX_PROP_LEN);
+
+ if ((op->name == NULL) || (op->type == NULL))
+ {
+ grub_print_error ();
+ free_parent_dev (op);
+ return NULL;
+ }
+
+ return op;
+}
+
+static struct parent_dev *
+open_new_parent (const char *parent)
+{
+ struct parent_dev *op = init_parent(parent);
+ grub_ieee1275_ihandle_t ihandle;
+ grub_ieee1275_phandle_t phandle;
+ grub_uint32_t address_cells = 2;
+
+ if (op == NULL)
+ return NULL;
+
+ grub_ieee1275_open (parent, &ihandle);
+
+ if (ihandle == 0)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, "unable to open %s", parent);
+ grub_print_error ();
+ free_parent_dev (op);
+ return NULL;
+ }
+
+ if (grub_ieee1275_instance_to_package (ihandle, &phandle))
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, "unable to get parent %s", parent);
+ grub_print_error ();
+ free_parent_dev (op);
+ return NULL;
+ }
+
+ /*
+ * IEEE Std 1275-1994 page 110: A missing "address-cells" property
+ * signifies that the number of address cells is two. So ignore on error.
+ */
+ if (grub_ieee1275_get_integer_property (phandle, "#address-cells",
+ &address_cells,
+ sizeof (address_cells), 0) != 0)
+ address_cells = 2;
+
+ grub_ieee1275_get_property (phandle, "device_type", op->type,
+ IEEE1275_MAX_PROP_LEN, NULL);
+
+ op->ihandle = ihandle;
+ op->address_cells = address_cells;
+ return op;
+}
+
+static struct parent_dev *
+open_parent (const char *parent)
+{
+ struct parent_dev *op;
+
+ op = grub_named_list_find (GRUB_AS_NAMED_LIST (parent_devs), parent);
+
+ if (op == NULL)
+ {
+ op = open_new_parent (parent);
+
+ if (op != NULL)
+ grub_list_push (GRUB_AS_LIST_P (&parent_devs), GRUB_AS_LIST (op));
+ }
+
+ return op;
+}
+
+static void
+display_parents (void)
+{
+ struct parent_dev *parent;
+
+ grub_printf ("-------------------- PARENTS --------------------\n");
+
+ FOR_LIST_ELEMENTS (parent, parent_devs)
+ {
+ grub_printf ("name: %s\n", parent->name);
+ grub_printf ("type: %s\n", parent->type);
+ grub_printf ("address_cells %x\n", parent->address_cells);
+ }
+
+ grub_printf ("-------------------------------------------------\n");
+}
+
+static char *
+canonicalise_4cell_ua (grub_ieee1275_ihandle_t ihandle, char *unit_address)
+{
+ grub_uint32_t phy_lo, phy_hi, lun_lo, lun_hi;
+ int valid_phy = 0;
+ grub_size_t size;
+ char *canon = NULL;
+
+ valid_phy = grub_ieee1275_decode_unit4 (ihandle, unit_address,
+ grub_strlen (unit_address), &phy_lo,
+ &phy_hi, &lun_lo, &lun_hi);
+
+ if ((valid_phy == 0) && (phy_hi != 0xffffffff))
+ canon = grub_ieee1275_encode_uint4 (ihandle, phy_lo, phy_hi,
+ lun_lo, lun_hi, &size);
+
+ return canon;
+}
+
+static char *
+canonicalise_disk (const char *devname)
+{
+ char *canon, *parent;
+ struct parent_dev *op;
+
+ canon = grub_ieee1275_canonicalise_devname (devname);
+
+ if (canon == NULL)
+ {
+ /* This should not happen. */
+ grub_error (GRUB_ERR_BAD_DEVICE, "canonicalise devname failed");
+ grub_print_error ();
+ return NULL;
+ }
+
+ /* Don't try to open the parent of a virtual device. */
+ if (grub_strstr (canon, "virtual-devices"))
+ return canon;
+
+ parent = get_parent_devname (canon);
+
+ if (parent == NULL)
+ return NULL;
+
+ op = open_parent (parent);
+
+ /*
+ * Devices with 4 address cells can have many different types of addressing
+ * (phy, wwn, and target lun). Use the parents encode-unit / decode-unit
+ * to find the true canonical name.
+ */
+ if ((op) && (op->address_cells == 4))
+ {
+ char *unit_address, *real_unit_address, *real_canon;
+ grub_size_t real_unit_str_len;
+
+ unit_address = grub_strstr (canon, IEEE1275_DISK_ALIAS);
+ unit_address += grub_strlen (IEEE1275_DISK_ALIAS);
+
+ if (unit_address == NULL)
+ {
+ /*
+ * This should not be possible, but return the canonical name for
+ * the non-disk block device.
+ */
+ grub_free (parent);
+ return (canon);
+ }
+
+ real_unit_address = canonicalise_4cell_ua (op->ihandle, unit_address);
+
+ if (real_unit_address == NULL)
+ {
+ /*
+ * This is not an error, since this function could be called with a devalias
+ * containing a drive that isn't installed in the system.
+ */
+ grub_free (parent);
+ return NULL;
+ }
+
+ real_unit_str_len = grub_strlen (op->name) + sizeof (IEEE1275_DISK_ALIAS)
+ + grub_strlen (real_unit_address);
+
+ real_canon = grub_malloc (real_unit_str_len);
+
+ grub_snprintf (real_canon, real_unit_str_len, "%s/disk@%s",
+ op->name, real_unit_address);
+
+ grub_free (canon);
+ canon = real_canon;
+ }
+
+ grub_free (parent);
+ return (canon);
+}
+
+static struct disk_dev *
+add_canon_disk (const char *cname)
+{
+ struct disk_dev *dev;
+
+ dev = grub_zalloc (sizeof (struct disk_dev));
+
+ if (dev == NULL)
+ goto failed;
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_RAW_DEVNAMES))
+ {
+ /*
+ * Append :nolabel to the end of all SPARC disks.
+ * nolabel is mutually exclusive with all other
+ * arguments and allows a client program to open
+ * the entire (raw) disk. Any disk label is ignored.
+ */
+ dev->raw_name = grub_malloc (grub_strlen (cname) + sizeof (":nolabel"));
+
+ if (dev->raw_name == NULL)
+ goto failed;
+
+ grub_snprintf (dev->raw_name, grub_strlen (cname) + sizeof (":nolabel"),
+ "%s:nolabel", cname);
+ }
+
+ /*
+ * Don't use grub_ieee1275_encode_devname here, the devpath in grub.cfg doesn't
+ * understand device aliases, which the layer above sometimes sends us.
+ */
+ dev->grub_devpath = encode_grub_devname(cname);
+
+ if (dev->grub_devpath == NULL)
+ goto failed;
+
+ dev->name = grub_strdup (cname);
+
+ if (dev->name == NULL)
+ goto failed;
+
+ dev->valid = 1;
+ grub_list_push (GRUB_AS_LIST_P (&disk_devs), GRUB_AS_LIST (dev));
+ return dev;
+
+ failed:
+ grub_print_error ();
+
+ if (dev != NULL)
+ {
+ grub_free (dev->name);
+ grub_free (dev->grub_devpath);
+ grub_free (dev->raw_name);
+ }
+
+ grub_free (dev);
+ return NULL;
+}
+
+static grub_err_t
+add_disk (const char *path)
+{
+ grub_err_t ret = GRUB_ERR_NONE;
+ struct disk_dev *dev;
+ char *canon;
+
+ canon = canonicalise_disk (path);
+ dev = grub_named_list_find (GRUB_AS_NAMED_LIST (disk_devs), canon);
+
+ if ((canon != NULL) && (dev == NULL))
+ {
+ struct disk_dev *ob_device;
+
+ ob_device = add_canon_disk (canon);
+
+ if (ob_device == NULL)
+ ret = grub_error (GRUB_ERR_OUT_OF_MEMORY, "failure to add disk");
+ }
+ else if (dev != NULL)
+ dev->valid = 1;
+
+ grub_free (canon);
+ return (ret);
+}
+
+static grub_err_t
+grub_obdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *dest)
+{
+ grub_err_t ret = GRUB_ERR_NONE;
+ struct disk_dev *dev;
+ unsigned long long pos;
+ grub_ssize_t result = 0;
+
+ if (disk->data == NULL)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "invalid disk data");
+
+ dev = (struct disk_dev *)disk->data;
+ pos = sector << disk->log_sector_size;
+ grub_ieee1275_seek (dev->ihandle, pos, &result);
+
+ if (result < 0)
+ {
+ dev->opened = 0;
+ return grub_error (GRUB_ERR_READ_ERROR, "seek error, can't seek block %llu",
+ (long long) sector);
+ }
+
+ grub_ieee1275_read (dev->ihandle, dest, size << disk->log_sector_size,
+ &result);
+
+ if (result != (grub_ssize_t) (size << disk->log_sector_size))
+ {
+ dev->opened = 0;
+ return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
+ "from `%s'"),
+ (unsigned long long) sector,
+ disk->name);
+ }
+ return ret;
+}
+
+static void
+grub_obdisk_close (grub_disk_t disk)
+{
+ grub_memset (disk, 0, sizeof (*disk));
+}
+
+static void
+scan_usb_disk (const char *parent)
+{
+ struct parent_dev *op;
+ grub_ssize_t result;
+
+ op = open_parent (parent);
+
+ if (op == NULL)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, "unable to open %s", parent);
+ grub_print_error ();
+ return;
+ }
+
+ if ((grub_ieee1275_set_address (op->ihandle, 0, 0) == 0) &&
+ (grub_ieee1275_no_data_command (op->ihandle, &tur, &result) == 0) &&
+ (result == 0))
+ {
+ char *buf;
+
+ buf = grub_malloc (IEEE1275_MAX_PATH_LEN);
+
+ if (buf == NULL)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "disk scan failure");
+ grub_print_error ();
+ return;
+ }
+
+ grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "%s/disk@0", parent);
+ add_disk (buf);
+ grub_free (buf);
+ }
+}
+
+static void
+scan_nvme_disk (const char *path)
+{
+ char *buf;
+
+ buf = grub_malloc (IEEE1275_MAX_PATH_LEN);
+
+ if (buf == NULL)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "disk scan failure");
+ grub_print_error ();
+ return;
+ }
+
+ grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "%s/disk@1", path);
+ add_disk (buf);
+ grub_free (buf);
+}
+
+static void
+scan_sparc_sas_2cell (struct parent_dev *op)
+{
+ grub_ssize_t result;
+ grub_uint8_t tgt;
+ char *buf;
+
+ buf = grub_malloc (IEEE1275_MAX_PATH_LEN);
+
+ if (buf == NULL)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "disk scan failure");
+ grub_print_error ();
+ return;
+ }
+
+ for (tgt = 0; tgt < 0xf; tgt++)
+ {
+
+ if ((grub_ieee1275_set_address(op->ihandle, tgt, 0) == 0) &&
+ (grub_ieee1275_no_data_command (op->ihandle, &tur, &result) == 0) &&
+ (result == 0))
+ {
+
+ grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "%s/disk@%"
+ PRIxGRUB_UINT32_T, op->name, tgt);
+
+ add_disk (buf);
+ }
+ }
+}
+
+static void
+scan_sparc_sas_4cell (struct parent_dev *op)
+{
+ grub_uint16_t exp;
+ grub_uint8_t phy;
+ char *buf;
+
+ buf = grub_malloc (IEEE1275_MAX_PATH_LEN);
+
+ if (buf == NULL)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "disk scan failure");
+ grub_print_error ();
+ return;
+ }
+
+ /*
+ * Cycle thru the potential for dual ported SAS disks
+ * behind a SAS expander.
+ */
+ for (exp = 0; exp <= 0x100; exp+=0x100)
+
+ /* The current limit is 32 disks on a phy. */
+ for (phy = 0; phy < 0x20; phy++)
+ {
+ char *canon = NULL;
+
+ grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "p%" PRIxGRUB_UINT32_T ",0",
+ exp | phy);
+
+ canon = canonicalise_4cell_ua (op->ihandle, buf);
+
+ if (canon != NULL)
+ {
+ grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "%s/disk@%s",
+ op->name, canon);
+
+ add_disk (buf);
+ grub_free (canon);
+ }
+ }
+
+ grub_free (buf);
+}
+
+static void
+scan_sparc_sas_disk (const char *parent)
+{
+ struct parent_dev *op;
+
+ op = open_parent (parent);
+
+ if ((op != NULL) && (op->address_cells == 4))
+ scan_sparc_sas_4cell (op);
+ else if ((op != NULL) && (op->address_cells == 2))
+ scan_sparc_sas_2cell (op);
+}
+
+static void
+iterate_devtree (const struct grub_ieee1275_devalias *alias)
+{
+ struct grub_ieee1275_devalias child;
+
+ if ((grub_strcmp (alias->type, "scsi-2") == 0) ||
+ (grub_strcmp (alias->type, "scsi-sas") == 0))
+ return scan_sparc_sas_disk (alias->path);
+
+ else if (grub_strcmp (alias->type, "nvme") == 0)
+ return scan_nvme_disk (alias->path);
+
+ else if (grub_strcmp (alias->type, "scsi-usb") == 0)
+ return scan_usb_disk (alias->path);
+
+ else if (grub_strcmp (alias->type, "block") == 0)
+ {
+ const char **bl = block_blacklist;
+
+ while (*bl != NULL)
+ {
+ if (grub_strstr (alias->path, *bl))
+ return;
+ bl++;
+ }
+
+ add_disk (alias->path);
+ return;
+ }
+
+ FOR_IEEE1275_DEVCHILDREN (alias->path, child)
+ iterate_devtree (&child);
+}
+
+static void
+enumerate_disks (void)
+{
+ struct grub_ieee1275_devalias alias;
+
+ FOR_IEEE1275_DEVCHILDREN("/", alias)
+ iterate_devtree (&alias);
+}
+
+static grub_err_t
+add_bootpath (void)
+{
+ struct disk_dev *ob_device;
+ grub_err_t ret = GRUB_ERR_NONE;
+ char *dev, *alias;
+ char *type;
+
+ dev = grub_ieee1275_get_boot_dev ();
+
+ if (dev == NULL)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "failure adding boot device");
+
+ type = grub_ieee1275_get_device_type (dev);
+
+ if (type == NULL)
+ {
+ grub_free (dev);
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "failure adding boot device");
+ }
+
+ alias = NULL;
+
+ if (grub_strcmp (type, "network") != 0)
+ {
+ dev = strip_ob_partition (dev);
+ ob_device = add_canon_disk (dev);
+
+ if (ob_device == NULL)
+ ret = grub_error (GRUB_ERR_OUT_OF_MEMORY, "failure adding boot device");
+
+ ob_device->valid = 1;
+
+ alias = grub_ieee1275_get_devname (dev);
+
+ if (alias && grub_strcmp (alias, dev) != 0)
+ ob_device->grub_alias_devpath = grub_ieee1275_encode_devname (dev);
+
+ ob_device->boot_dev = 1;
+ }
+
+ grub_free (type);
+ grub_free (dev);
+ grub_free (alias);
+ return ret;
+}
+
+static void
+enumerate_aliases (void)
+{
+ struct grub_ieee1275_devalias alias;
+
+ /*
+ * Some block device aliases are not in canonical form
+ *
+ * For example:
+ *
+ * disk3 /pci@301/pci@1/scsi@0/disk@p3
+ * disk2 /pci@301/pci@1/scsi@0/disk@p2
+ * disk1 /pci@301/pci@1/scsi@0/disk@p1
+ * disk /pci@301/pci@1/scsi@0/disk@p0
+ * disk0 /pci@301/pci@1/scsi@0/disk@p0
+ *
+ * None of these devices are in canonical form.
+ *
+ * Also, just because there is a devalias, doesn't mean there is a disk
+ * at that location. And a valid boot block device doesn't have to have
+ * a devalias at all.
+ *
+ * At this point, all valid disks have been found in the system
+ * and devaliases that point to canonical names are stored in the
+ * disk_devs list already.
+ */
+ FOR_IEEE1275_DEVALIASES (alias)
+ {
+ struct disk_dev *dev;
+ char *canon;
+
+ if (grub_strcmp (alias.type, "block") != 0)
+ continue;
+
+ canon = canonicalise_disk (alias.name);
+
+ if (canon == NULL)
+ /* This is not an error, a devalias could point to a nonexistent disk. */
+ continue;
+
+ dev = grub_named_list_find (GRUB_AS_NAMED_LIST (disk_devs), canon);
+
+ if (dev != NULL)
+ {
+ /*
+ * If more than one alias points to the same device,
+ * remove the previous one unless it is the boot dev,
+ * since the upper level will use the first one. The reason
+ * all the others are redone is in the case of hot-plugging
+ * a disk. If the boot disk gets hot-plugged, it will come
+ * thru here with a different name without the boot_dev flag
+ * set.
+ */
+ if ((dev->boot_dev) && (dev->grub_alias_devpath))
+ continue;
+
+ grub_free (dev->grub_alias_devpath);
+ dev->grub_alias_devpath = grub_ieee1275_encode_devname (alias.path);
+ }
+ grub_free (canon);
+ }
+}
+
+static void
+display_disks (void)
+{
+ struct disk_dev *dev;
+
+ grub_printf ("--------------------- DISKS ---------------------\n");
+
+ FOR_LIST_ELEMENTS (dev, disk_devs)
+ {
+ grub_printf ("name: %s\n", dev->name);
+ grub_printf ("grub_devpath: %s\n", dev->grub_devpath);
+ grub_printf ("grub_alias_devpath: %s\n", dev->grub_alias_devpath);
+ grub_printf ("valid: %s\n", (dev->valid) ? "yes" : "no");
+ grub_printf ("boot_dev: %s\n", (dev->boot_dev) ? "yes" : "no");
+ grub_printf ("opened: %s\n", (dev->ihandle) ? "yes" : "no");
+ grub_printf ("block size: %" PRIuGRUB_UINT32_T "\n",
+ dev->block_size);
+ grub_printf ("num blocks: %" PRIuGRUB_UINT64_T "\n",
+ dev->num_blocks);
+ grub_printf ("log sector size: %" PRIuGRUB_UINT32_T "\n",
+ dev->log_sector_size);
+ grub_printf ("\n");
+ }
+
+ grub_printf ("-------------------------------------------------\n");
+}
+
+static void
+display_stats (void)
+{
+ const char *debug = grub_env_get ("debug");
+
+ if (debug == NULL)
+ return;
+
+ if (grub_strword (debug, "all") || grub_strword (debug, "obdisk"))
+ {
+ display_parents ();
+ display_disks ();
+ }
+}
+
+static void
+invalidate_all_disks (void)
+{
+ struct disk_dev *dev = NULL;
+
+ if (disks_enumerated != 0)
+ FOR_LIST_ELEMENTS (dev, disk_devs)
+ dev->valid = 0;
+}
+
+static struct disk_dev *
+find_legacy_grub_devpath (const char *name)
+{
+ struct disk_dev *dev = NULL;
+ char *canon, *devpath = NULL;
+
+ devpath = decode_grub_devname (name + sizeof ("ieee1275"));
+ canon = canonicalise_disk (devpath);
+
+ if (canon != NULL)
+ dev = grub_named_list_find (GRUB_AS_NAMED_LIST (disk_devs), canon);
+
+ grub_free (devpath);
+ grub_free (canon);
+ return dev;
+}
+
+static void
+enumerate_devices (void)
+{
+ invalidate_all_disks ();
+ enumerate_disks ();
+ enumerate_aliases ();
+ disks_enumerated = 1;
+ display_stats ();
+}
+
+static struct disk_dev *
+find_grub_devpath_real (const char *name)
+{
+ struct disk_dev *dev = NULL;
+
+ FOR_LIST_ELEMENTS (dev, disk_devs)
+ {
+ if ((STRCMP (dev->grub_devpath, name))
+ || (STRCMP (dev->grub_alias_devpath, name)))
+ break;
+ }
+
+ return dev;
+}
+
+static struct disk_dev *
+find_grub_devpath (const char *name)
+{
+ struct disk_dev *dev = NULL;
+ int enumerated;
+
+ do {
+ enumerated = disks_enumerated;
+ dev = find_grub_devpath_real (name);
+
+ if (dev != NULL)
+ break;
+
+ dev = find_legacy_grub_devpath (name);
+
+ if (dev != NULL)
+ break;
+
+ enumerate_devices ();
+ } while (enumerated == 0);
+
+ return dev;
+}
+
+static int
+grub_obdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ struct disk_dev *dev;
+ const char *name;
+
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ enumerate_devices ();
+
+ FOR_LIST_ELEMENTS (dev, disk_devs)
+ {
+ if (dev->valid == 1)
+ {
+ if (dev->grub_alias_devpath)
+ name = dev->grub_alias_devpath;
+ else
+ name = dev->grub_devpath;
+
+ if (hook (name, hook_data))
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static grub_err_t
+grub_obdisk_open (const char *name, grub_disk_t disk)
+{
+ grub_ieee1275_ihandle_t ihandle = 0;
+ struct disk_dev *dev = NULL;
+
+ if (grub_strncmp (name, IEEE1275_DEV, sizeof (IEEE1275_DEV) - 1) != 0)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not IEEE1275 device");
+
+ dev = find_grub_devpath (name);
+
+ if (dev == NULL)
+ {
+ grub_printf ("UNKNOWN DEVICE: %s\n", name);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "%s", name);
+ }
+
+ if (dev->opened == 0)
+ {
+ if (dev->raw_name != NULL)
+ grub_ieee1275_open (dev->raw_name, &ihandle);
+ else
+ grub_ieee1275_open (dev->name, &ihandle);
+
+ if (ihandle == 0)
+ {
+ grub_printf ("Can't open device %s\n", name);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device %s", name);
+ }
+
+ dev->block_size = grub_ieee1275_get_block_size (ihandle);
+ dev->num_blocks = grub_ieee1275_num_blocks (ihandle);
+
+ if (dev->num_blocks == 0)
+ dev->num_blocks = grub_ieee1275_num_blocks64 (ihandle);
+
+ if (dev->num_blocks == 0)
+ dev->num_blocks = GRUB_DISK_SIZE_UNKNOWN;
+
+ if (dev->block_size != 0)
+ {
+ for (dev->log_sector_size = 0;
+ (1U << dev->log_sector_size) < dev->block_size;
+ dev->log_sector_size++);
+ }
+ else
+ dev->log_sector_size = 9;
+
+ dev->ihandle = ihandle;
+ dev->opened = 1;
+ }
+
+ disk->total_sectors = dev->num_blocks;
+ disk->id = dev->ihandle;
+ disk->data = dev;
+ disk->log_sector_size = dev->log_sector_size;
+ return GRUB_ERR_NONE;
+}
+
+
+static struct grub_disk_dev grub_obdisk_dev =
+ {
+ .name = "obdisk",
+ .id = GRUB_DISK_DEVICE_OBDISK_ID,
+ .disk_iterate = grub_obdisk_iterate,
+ .disk_open = grub_obdisk_open,
+ .disk_close = grub_obdisk_close,
+ .disk_read = grub_obdisk_read,
+ };
+
+void
+grub_obdisk_init (void)
+{
+ grub_disk_firmware_fini = grub_obdisk_fini;
+ add_bootpath ();
+ grub_disk_dev_register (&grub_obdisk_dev);
+}
+
+void
+grub_obdisk_fini (void)
+{
+ struct disk_dev *dev;
+
+ FOR_LIST_ELEMENTS (dev, disk_devs)
+ {
+ if (dev->opened != 0)
+ grub_ieee1275_close (dev->ihandle);
+ }
+
+ grub_disk_dev_unregister (&grub_obdisk_dev);
+}
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
new file mode 100644
index 0000000..03674cb
--- /dev/null
+++ b/grub-core/disk/ieee1275/ofdisk.c
@@ -0,0 +1,741 @@
+/* ofdisk.c - Open Firmware disk access. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/ieee1275/ofdisk.h>
+#include <grub/i18n.h>
+#include <grub/time.h>
+
+static char *last_devpath;
+static grub_ieee1275_ihandle_t last_ihandle;
+
+struct ofdisk_hash_ent
+{
+ char *devpath;
+ char *open_path;
+ char *grub_devpath;
+ int is_boot;
+ int is_removable;
+ int block_size_fails;
+ /* Pointer to shortest available name on nodes representing canonical names,
+ otherwise NULL. */
+ const char *shortest;
+ const char *grub_shortest;
+ 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];
+
+static int
+ofdisk_hash_fn (const char *devpath)
+{
+ int hash = 0;
+ while (*devpath)
+ hash ^= *devpath++;
+ return (hash & (OFDISK_HASH_SZ - 1));
+}
+
+static struct ofdisk_hash_ent *
+ofdisk_hash_find (const char *devpath)
+{
+ struct ofdisk_hash_ent *p = ofdisk_hash[ofdisk_hash_fn(devpath)];
+
+ while (p)
+ {
+ if (!grub_strcmp (p->devpath, devpath))
+ break;
+ p = p->next;
+ }
+ return p;
+}
+
+static struct ofdisk_hash_ent *
+ofdisk_hash_add_real (char *devpath)
+{
+ struct ofdisk_hash_ent *p;
+ struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)];
+ const char *iptr;
+ char *optr;
+
+ p = grub_zalloc (sizeof (*p));
+ if (!p)
+ return NULL;
+
+ p->devpath = devpath;
+
+ p->grub_devpath = grub_malloc (sizeof ("ieee1275/")
+ + 2 * grub_strlen (p->devpath));
+
+ if (!p->grub_devpath)
+ {
+ grub_free (p);
+ return NULL;
+ }
+
+ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0))
+ {
+ p->open_path = grub_malloc (grub_strlen (p->devpath) + 3);
+ if (!p->open_path)
+ {
+ grub_free (p->grub_devpath);
+ grub_free (p);
+ return NULL;
+ }
+ optr = grub_stpcpy (p->open_path, p->devpath);
+ *optr++ = ':';
+ *optr++ = '0';
+ *optr = '\0';
+ }
+ else
+ p->open_path = p->devpath;
+
+ optr = grub_stpcpy (p->grub_devpath, "ieee1275/");
+ for (iptr = p->devpath; *iptr; )
+ {
+ if (*iptr == ',')
+ *optr++ = '\\';
+ *optr++ = *iptr++;
+ }
+ *optr = 0;
+
+ p->next = *head;
+ *head = p;
+ return p;
+}
+
+static int
+check_string_removable (const char *str)
+{
+ const char *ptr = grub_strrchr (str, '/');
+
+ if (ptr)
+ ptr++;
+ else
+ ptr = str;
+ return (grub_strncmp (ptr, "cdrom", 5) == 0 || grub_strncmp (ptr, "fd", 2) == 0);
+}
+
+static struct ofdisk_hash_ent *
+ofdisk_hash_add (char *devpath, char *curcan)
+{
+ struct ofdisk_hash_ent *p, *pcan;
+
+ p = ofdisk_hash_add_real (devpath);
+
+ grub_dprintf ("disk", "devpath = %s, canonical = %s\n", devpath, curcan);
+
+ if (!curcan)
+ {
+ p->shortest = p->devpath;
+ p->grub_shortest = p->grub_devpath;
+ if (check_string_removable (devpath))
+ p->is_removable = 1;
+ return p;
+ }
+
+ pcan = ofdisk_hash_find (curcan);
+ if (!pcan)
+ pcan = ofdisk_hash_add_real (curcan);
+ else
+ grub_free (curcan);
+
+ if (check_string_removable (devpath) || check_string_removable (curcan))
+ pcan->is_removable = 1;
+
+ if (!pcan)
+ grub_errno = GRUB_ERR_NONE;
+ else
+ {
+ if (!pcan->shortest
+ || grub_strlen (pcan->shortest) > grub_strlen (devpath))
+ {
+ pcan->shortest = p->devpath;
+ pcan->grub_shortest = p->grub_devpath;
+ }
+ }
+
+ return p;
+}
+
+static void
+dev_iterate_real (const char *name, const char *path)
+{
+ struct ofdisk_hash_ent *op;
+
+ grub_dprintf ("disk", "disk name = %s, path = %s\n", name,
+ path);
+
+ op = ofdisk_hash_find (path);
+ if (!op)
+ {
+ char *name_dup = grub_strdup (name);
+ char *can = grub_strdup (path);
+ if (!name_dup || !can)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_free (name_dup);
+ grub_free (can);
+ return;
+ }
+ op = ofdisk_hash_add (name_dup, can);
+ }
+ return;
+}
+
+static void
+dev_iterate (const struct grub_ieee1275_devalias *alias)
+{
+ if (grub_strcmp (alias->type, "vscsi") == 0)
+ {
+ static grub_ieee1275_ihandle_t ihandle;
+ struct set_color_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t catch_result;
+ grub_ieee1275_cell_t nentries;
+ grub_ieee1275_cell_t table;
+ }
+ args;
+ char *buf, *bufptr;
+ unsigned i;
+
+ 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;
+ args.table = 0;
+ args.nentries = 0;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || args.catch_result)
+ {
+ grub_ieee1275_close (ihandle);
+ return;
+ }
+
+ buf = grub_malloc (grub_strlen (alias->path) + 32);
+ if (!buf)
+ return;
+ bufptr = grub_stpcpy (buf, alias->path);
+
+ for (i = 0; i < args.nentries; i++)
+ {
+ grub_uint64_t *ptr;
+
+ ptr = *(grub_uint64_t **) (args.table + 4 + 8 * i);
+ while (*ptr)
+ {
+ grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
+ dev_iterate_real (buf, buf);
+ }
+ }
+ grub_ieee1275_close (ihandle);
+ 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_calloc (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)
+ {
+ dev_iterate_real (alias->path, alias->path);
+ return;
+ }
+
+ {
+ struct grub_ieee1275_devalias child;
+
+ FOR_IEEE1275_DEVCHILDREN(alias->path, child)
+ dev_iterate (&child);
+ }
+}
+
+static void
+scan (void)
+{
+ struct grub_ieee1275_devalias alias;
+ FOR_IEEE1275_DEVALIASES(alias)
+ {
+ if (grub_strcmp (alias.type, "block") != 0)
+ continue;
+ dev_iterate_real (alias.name, alias.path);
+ }
+
+ FOR_IEEE1275_DEVCHILDREN("/", alias)
+ dev_iterate (&alias);
+}
+
+static int
+grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ unsigned i;
+
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ scan ();
+
+ for (i = 0; i < ARRAY_SIZE (ofdisk_hash); i++)
+ {
+ static struct ofdisk_hash_ent *ent;
+ for (ent = ofdisk_hash[i]; ent; ent = ent->next)
+ {
+ if (!ent->shortest)
+ continue;
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY))
+ {
+ grub_ieee1275_phandle_t dev;
+ char tmp[8];
+
+ if (grub_ieee1275_finddevice (ent->devpath, &dev))
+ {
+ grub_dprintf ("disk", "finddevice (%s) failed\n",
+ ent->devpath);
+ continue;
+ }
+
+ if (grub_ieee1275_get_property (dev, "iconname", tmp,
+ sizeof tmp, 0))
+ {
+ grub_dprintf ("disk", "get iconname failed\n");
+ continue;
+ }
+
+ if (grub_strcmp (tmp, "sdmmc") != 0)
+ {
+ grub_dprintf ("disk", "device is not an SD card\n");
+ continue;
+ }
+ }
+
+ if (!ent->is_boot && ent->is_removable)
+ continue;
+
+ if (hook (ent->grub_shortest, hook_data))
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static char *
+compute_dev_path (const char *name)
+{
+ char *devpath = grub_malloc (grub_strlen (name) + 3);
+ char *p, c;
+
+ if (!devpath)
+ return NULL;
+
+ /* Un-escape commas. */
+ p = devpath;
+ while ((c = *name++) != '\0')
+ {
+ if (c == '\\' && *name == ',')
+ {
+ *p++ = ',';
+ name++;
+ }
+ else
+ *p++ = c;
+ }
+
+ *p++ = '\0';
+
+ return devpath;
+}
+
+static grub_err_t
+grub_ofdisk_open (const char *name, grub_disk_t disk)
+{
+ grub_ieee1275_phandle_t dev;
+ char *devpath;
+ /* 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,
+ "not IEEE1275 device");
+ devpath = compute_dev_path (name + sizeof ("ieee1275/") - 1);
+ if (! devpath)
+ return grub_errno;
+
+ grub_dprintf ("disk", "Opening `%s'.\n", devpath);
+
+ if (grub_ieee1275_finddevice (devpath, &dev))
+ {
+ grub_free (devpath);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "can't read device properties");
+ }
+
+ if (grub_ieee1275_get_property (dev, "device_type", prop, sizeof (prop),
+ &actual))
+ {
+ grub_free (devpath);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't read the device type");
+ }
+
+ if (grub_strcmp (prop, "block"))
+ {
+ grub_free (devpath);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a block device");
+ }
+
+ /* 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. */
+ disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN;
+
+ {
+ struct ofdisk_hash_ent *op;
+ op = ofdisk_hash_find (devpath);
+ if (!op)
+ op = ofdisk_hash_add (devpath, NULL);
+ if (!op)
+ {
+ 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;
+}
+
+static void
+grub_ofdisk_close (grub_disk_t disk)
+{
+ if (disk->data == last_devpath)
+ {
+ if (last_ihandle)
+ grub_ieee1275_close (last_ihandle);
+ last_ihandle = 0;
+ last_devpath = NULL;
+ }
+ disk->data = 0;
+}
+
+static grub_err_t
+grub_ofdisk_prepare (grub_disk_t disk, grub_disk_addr_t sector)
+{
+ grub_ssize_t status;
+ unsigned long long pos;
+
+ if (disk->data != last_devpath)
+ {
+ if (last_ihandle)
+ grub_ieee1275_close (last_ihandle);
+ last_ihandle = 0;
+ last_devpath = NULL;
+
+ grub_ieee1275_open (disk->data, &last_ihandle);
+ if (! last_ihandle)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
+ last_devpath = disk->data;
+ }
+
+ pos = sector << disk->log_sector_size;
+
+ grub_ieee1275_seek (last_ihandle, pos, &status);
+ if (status < 0)
+ return grub_error (GRUB_ERR_READ_ERROR,
+ "seek error, can't seek block %llu",
+ (long long) sector);
+ return 0;
+}
+
+static grub_err_t
+grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_err_t err;
+ grub_ssize_t actual;
+ err = grub_ofdisk_prepare (disk, sector);
+ if (err)
+ return err;
+ grub_ieee1275_read (last_ihandle, buf, size << disk->log_sector_size,
+ &actual);
+ if (actual != (grub_ssize_t) (size << disk->log_sector_size))
+ return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
+ "from `%s'"),
+ (unsigned long long) sector,
+ disk->name);
+
+ return 0;
+}
+
+static grub_err_t
+grub_ofdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, const char *buf)
+{
+ grub_err_t err;
+ grub_ssize_t actual;
+ err = grub_ofdisk_prepare (disk, sector);
+ if (err)
+ return err;
+ grub_ieee1275_write (last_ihandle, buf, size << disk->log_sector_size,
+ &actual);
+ if (actual != (grub_ssize_t) (size << disk->log_sector_size))
+ return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx "
+ "to `%s'"),
+ (unsigned long long) sector,
+ disk->name);
+
+ return 0;
+}
+
+static struct grub_disk_dev grub_ofdisk_dev =
+ {
+ .name = "ofdisk",
+ .id = GRUB_DISK_DEVICE_OFDISK_ID,
+ .disk_iterate = grub_ofdisk_iterate,
+ .disk_open = grub_ofdisk_open,
+ .disk_close = grub_ofdisk_close,
+ .disk_read = grub_ofdisk_read,
+ .disk_write = grub_ofdisk_write,
+ .next = 0
+ };
+
+static void
+insert_bootpath (void)
+{
+ char *bootpath;
+ grub_ssize_t bootpath_size;
+ char *type;
+
+ if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath",
+ &bootpath_size)
+ || bootpath_size <= 0)
+ {
+ /* Should never happen. */
+ grub_printf ("/chosen/bootpath property missing!\n");
+ return;
+ }
+
+ bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64);
+ if (! bootpath)
+ {
+ grub_print_error ();
+ return;
+ }
+ grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath,
+ (grub_size_t) bootpath_size + 1, 0);
+ bootpath[bootpath_size] = '\0';
+
+ /* Transform an OF device path to a GRUB path. */
+
+ type = grub_ieee1275_get_device_type (bootpath);
+ if (!(type && grub_strcmp (type, "network") == 0))
+ {
+ struct ofdisk_hash_ent *op;
+ char *device = grub_ieee1275_get_devname (bootpath);
+ op = ofdisk_hash_add (device, NULL);
+ op->is_boot = 1;
+ }
+ grub_free (type);
+ grub_free (bootpath);
+}
+
+void
+grub_ofdisk_fini (void)
+{
+ if (last_ihandle)
+ grub_ieee1275_close (last_ihandle);
+ last_ihandle = 0;
+ last_devpath = NULL;
+
+ grub_disk_dev_unregister (&grub_ofdisk_dev);
+}
+
+void
+grub_ofdisk_init (void)
+{
+ grub_disk_firmware_fini = grub_ofdisk_fini;
+
+ insert_bootpath ();
+
+ grub_disk_dev_register (&grub_ofdisk_dev);
+}
+
+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
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t result;
+ grub_ieee1275_cell_t size1;
+ grub_ieee1275_cell_t size2;
+ } args_ieee1275;
+
+ if (last_ihandle)
+ grub_ieee1275_close (last_ihandle);
+
+ last_ihandle = 0;
+ last_devpath = NULL;
+
+ grub_ieee1275_open (device, &last_ihandle);
+ 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;
+
+ 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
new file mode 100644
index 0000000..4577a51
--- /dev/null
+++ b/grub-core/disk/ldm.c
@@ -0,0 +1,1110 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/diskfilter.h>
+#include <grub/msdos_partition.h>
+#include <grub/gpt_partition.h>
+#include <grub/i18n.h>
+#include <grub/safemath.h>
+
+#ifdef GRUB_UTIL
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define LDM_GUID_STRLEN 64
+#define LDM_NAME_STRLEN 32
+
+typedef grub_uint8_t *grub_ldm_id_t;
+
+enum { STRIPE = 1, SPANNED = 2, RAID5 = 3 };
+
+#define LDM_LABEL_SECTOR 6
+struct grub_ldm_vblk {
+ char magic[4];
+ grub_uint8_t unused1[12];
+ grub_uint16_t update_status;
+ grub_uint8_t flags;
+ grub_uint8_t type;
+ grub_uint32_t unused2;
+ grub_uint8_t dynamic[104];
+} GRUB_PACKED;
+#define LDM_VBLK_MAGIC "VBLK"
+
+enum
+ {
+ STATUS_CONSISTENT = 0,
+ STATUS_STILL_ACTIVE = 1,
+ STATUS_NOT_ACTIVE_YET = 2
+ };
+
+enum
+ {
+ ENTRY_COMPONENT = 0x32,
+ ENTRY_PARTITION = 0x33,
+ ENTRY_DISK = 0x34,
+ ENTRY_VOLUME = 0x51,
+ };
+
+struct grub_ldm_label
+{
+ char magic[8];
+ grub_uint32_t unused1;
+ grub_uint16_t ver_major;
+ grub_uint16_t ver_minor;
+ grub_uint8_t unused2[32];
+ char disk_guid[LDM_GUID_STRLEN];
+ char host_guid[LDM_GUID_STRLEN];
+ char group_guid[LDM_GUID_STRLEN];
+ char group_name[LDM_NAME_STRLEN];
+ grub_uint8_t unused3[11];
+ grub_uint64_t pv_start;
+ grub_uint64_t pv_size;
+ grub_uint64_t config_start;
+ grub_uint64_t config_size;
+} GRUB_PACKED;
+
+
+#define LDM_MAGIC "PRIVHEAD"
+
+
+
+static inline grub_uint64_t
+read_int (grub_uint8_t *in, grub_size_t s)
+{
+ grub_uint8_t *ptr2;
+ grub_uint64_t ret;
+ ret = 0;
+ for (ptr2 = in; ptr2 < in + s; ptr2++)
+ {
+ ret <<= 8;
+ ret |= *ptr2;
+ }
+ return ret;
+}
+
+static int
+check_ldm_partition (grub_disk_t disk __attribute__ ((unused)), const grub_partition_t p, void *data)
+{
+ int *has_ldm = data;
+
+ if (p->number >= 4)
+ return 1;
+ if (p->msdostype == GRUB_PC_PARTITION_TYPE_LDM)
+ {
+ *has_ldm = 1;
+ return 1;
+ }
+ return 0;
+}
+
+static int
+msdos_has_ldm_partition (grub_disk_t dsk)
+{
+ grub_err_t err;
+ int has_ldm = 0;
+
+ err = grub_partition_msdos_iterate (dsk, check_ldm_partition, &has_ldm);
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+
+ return has_ldm;
+}
+
+static const grub_gpt_part_guid_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
+
+/* Helper for gpt_ldm_sector. */
+static int
+gpt_ldm_sector_iter (grub_disk_t disk, const grub_partition_t p, void *data)
+{
+ grub_disk_addr_t *sector = data;
+ struct grub_gpt_partentry gptdata;
+ grub_partition_t p2;
+
+ p2 = disk->partition;
+ disk->partition = p->parent;
+ if (grub_disk_read (disk, p->offset, p->index,
+ sizeof (gptdata), &gptdata))
+ {
+ disk->partition = p2;
+ return 0;
+ }
+ disk->partition = p2;
+
+ if (! grub_memcmp (&gptdata.type, &ldm_type, 16))
+ {
+ *sector = p->start + p->len - 1;
+ return 1;
+ }
+ return 0;
+}
+
+static grub_disk_addr_t
+gpt_ldm_sector (grub_disk_t dsk)
+{
+ grub_disk_addr_t sector = 0;
+ grub_err_t err;
+
+ err = grub_gpt_partition_map_iterate (dsk, gpt_ldm_sector_iter, &sector);
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+ return sector;
+}
+
+static struct grub_diskfilter_vg *
+make_vg (grub_disk_t disk,
+ const struct grub_ldm_label *label)
+{
+ grub_disk_addr_t startsec, endsec, cursec;
+ struct grub_diskfilter_vg *vg;
+ grub_err_t err;
+
+ /* First time we see this volume group. We've to create the
+ whole volume group structure. */
+ vg = grub_malloc (sizeof (*vg));
+ if (! vg)
+ return NULL;
+ vg->extent_size = 1;
+ vg->name = grub_malloc (LDM_NAME_STRLEN + 1);
+ vg->uuid = grub_malloc (LDM_GUID_STRLEN + 1);
+ if (! vg->uuid || !vg->name)
+ {
+ grub_free (vg->uuid);
+ grub_free (vg->name);
+ grub_free (vg);
+ return NULL;
+ }
+ grub_memcpy (vg->uuid, label->group_guid, LDM_GUID_STRLEN);
+ grub_memcpy (vg->name, label->group_name, LDM_NAME_STRLEN);
+ vg->name[LDM_NAME_STRLEN] = 0;
+ vg->uuid[LDM_GUID_STRLEN] = 0;
+ vg->uuid_len = grub_strlen (vg->uuid);
+
+ vg->lvs = NULL;
+ vg->pvs = NULL;
+
+ startsec = grub_be_to_cpu64 (label->config_start);
+ endsec = startsec + grub_be_to_cpu64 (label->config_size);
+
+ /* First find disks. */
+ for (cursec = startsec + 0x12; cursec < endsec; cursec++)
+ {
+ struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE
+ / sizeof (struct grub_ldm_vblk)];
+ unsigned i;
+ err = grub_disk_read (disk, cursec, 0,
+ sizeof(vblk), &vblk);
+ if (err)
+ goto fail2;
+
+ for (i = 0; i < ARRAY_SIZE (vblk); i++)
+ {
+ struct grub_diskfilter_pv *pv;
+ grub_uint8_t *ptr;
+ if (grub_memcmp (vblk[i].magic, LDM_VBLK_MAGIC,
+ sizeof (vblk[i].magic)) != 0)
+ continue;
+ if (grub_be_to_cpu16 (vblk[i].update_status)
+ != STATUS_CONSISTENT
+ && grub_be_to_cpu16 (vblk[i].update_status)
+ != STATUS_STILL_ACTIVE)
+ continue;
+ if (vblk[i].type != ENTRY_DISK)
+ continue;
+ pv = grub_zalloc (sizeof (*pv));
+ if (!pv)
+ goto fail2;
+
+ pv->disk = 0;
+ ptr = vblk[i].dynamic;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic
+ + sizeof (vblk[i].dynamic))
+ {
+ grub_free (pv);
+ goto fail2;
+ }
+ pv->internal_id = grub_malloc (ptr[0] + 2);
+ if (!pv->internal_id)
+ {
+ grub_free (pv);
+ goto fail2;
+ }
+ grub_memcpy (pv->internal_id, ptr, (grub_size_t) ptr[0] + 1);
+ pv->internal_id[(grub_size_t) ptr[0] + 1] = 0;
+
+ ptr += *ptr + 1;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic
+ + sizeof (vblk[i].dynamic))
+ {
+ grub_free (pv);
+ goto fail2;
+ }
+ /* ptr = name. */
+ ptr += *ptr + 1;
+ if (ptr + *ptr + 1
+ >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ grub_free (pv);
+ goto fail2;
+ }
+ pv->id.uuidlen = *ptr;
+ pv->id.uuid = grub_malloc (pv->id.uuidlen + 1);
+ grub_memcpy (pv->id.uuid, ptr + 1, pv->id.uuidlen);
+ pv->id.uuid[pv->id.uuidlen] = 0;
+
+ pv->next = vg->pvs;
+ vg->pvs = pv;
+ }
+ }
+
+ /* Then find LVs. */
+ for (cursec = startsec + 0x12; cursec < endsec; cursec++)
+ {
+ struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE
+ / sizeof (struct grub_ldm_vblk)];
+ unsigned i;
+ grub_size_t sz;
+ err = grub_disk_read (disk, cursec, 0,
+ sizeof(vblk), &vblk);
+ if (err)
+ goto fail2;
+
+ for (i = 0; i < ARRAY_SIZE (vblk); i++)
+ {
+ struct grub_diskfilter_lv *lv;
+ grub_uint8_t *ptr;
+ if (grub_memcmp (vblk[i].magic, LDM_VBLK_MAGIC,
+ sizeof (vblk[i].magic)) != 0)
+ continue;
+ if (grub_be_to_cpu16 (vblk[i].update_status)
+ != STATUS_CONSISTENT
+ && grub_be_to_cpu16 (vblk[i].update_status)
+ != STATUS_STILL_ACTIVE)
+ continue;
+ if (vblk[i].type != ENTRY_VOLUME)
+ continue;
+ lv = grub_zalloc (sizeof (*lv));
+ if (!lv)
+ goto fail2;
+
+ lv->vg = vg;
+ lv->segment_count = 1;
+ lv->segment_alloc = 1;
+ lv->visible = 1;
+ lv->segments = grub_zalloc (sizeof (*lv->segments));
+ if (!lv->segments)
+ {
+ grub_free (lv);
+ goto fail2;
+ }
+ lv->segments->start_extent = 0;
+ lv->segments->type = GRUB_DISKFILTER_MIRROR;
+ lv->segments->node_count = 0;
+ lv->segments->node_alloc = 8;
+ lv->segments->nodes = grub_calloc (lv->segments->node_alloc,
+ sizeof (*lv->segments->nodes));
+ if (!lv->segments->nodes)
+ {
+ grub_free (lv);
+ goto fail2;
+ }
+ ptr = vblk[i].dynamic;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic
+ + sizeof (vblk[i].dynamic))
+ {
+ grub_free (lv);
+ goto fail2;
+ }
+ lv->internal_id = grub_malloc ((grub_size_t) ptr[0] + 2);
+ if (!lv->internal_id)
+ {
+ grub_free (lv);
+ goto fail2;
+ }
+ grub_memcpy (lv->internal_id, ptr, ptr[0] + 1);
+ lv->internal_id[ptr[0] + 1] = 0;
+
+ ptr += *ptr + 1;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic
+ + sizeof (vblk[i].dynamic))
+ {
+ grub_free (lv);
+ goto fail2;
+ }
+ if (grub_add (*ptr, 1, &sz))
+ {
+ grub_free (lv->internal_id);
+ grub_free (lv);
+ goto fail2;
+ }
+ lv->name = grub_malloc (sz);
+ if (!lv->name)
+ {
+ grub_free (lv->internal_id);
+ grub_free (lv);
+ goto fail2;
+ }
+ grub_memcpy (lv->name, ptr + 1, *ptr);
+ lv->name[*ptr] = 0;
+ lv->fullname = grub_xasprintf ("ldm/%s/%s",
+ vg->uuid, lv->name);
+ if (!lv->fullname)
+ {
+ grub_free (lv->internal_id);
+ grub_free (lv->name);
+ grub_free (lv);
+ goto fail2;
+ }
+ ptr += *ptr + 1;
+ if (ptr + *ptr + 1
+ >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ grub_free (lv->internal_id);
+ grub_free (lv->name);
+ grub_free (lv);
+ goto fail2;
+ }
+ /* ptr = volume type. */
+ ptr += *ptr + 1;
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ grub_free (lv->internal_id);
+ grub_free (lv->name);
+ grub_free (lv);
+ goto fail2;
+ }
+ /* ptr = flags. */
+ ptr += *ptr + 1;
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ grub_free (lv->internal_id);
+ grub_free (lv->name);
+ grub_free (lv);
+ goto fail2;
+ }
+
+ /* Skip state, type, unknown, volume number, zeros, flags. */
+ ptr += 14 + 1 + 1 + 1 + 3 + 1;
+ /* ptr = number of children. */
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ grub_free (lv->internal_id);
+ grub_free (lv->name);
+ grub_free (lv);
+ goto fail2;
+ }
+ ptr += *ptr + 1;
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ grub_free (lv->internal_id);
+ grub_free (lv->name);
+ grub_free (lv);
+ goto fail2;
+ }
+
+ /* Skip 2 more fields. */
+ ptr += 8 + 8;
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
+ || ptr + *ptr + 1>= vblk[i].dynamic
+ + sizeof (vblk[i].dynamic))
+ {
+ grub_free (lv->internal_id);
+ grub_free (lv->name);
+ grub_free (lv);
+ goto fail2;
+ }
+ lv->size = read_int (ptr + 1, *ptr);
+ lv->segments->extent_count = lv->size;
+
+ lv->next = vg->lvs;
+ vg->lvs = lv;
+ }
+ }
+
+ /* Now the components. */
+ for (cursec = startsec + 0x12; cursec < endsec; cursec++)
+ {
+ struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE
+ / sizeof (struct grub_ldm_vblk)];
+ unsigned i;
+ err = grub_disk_read (disk, cursec, 0,
+ sizeof(vblk), &vblk);
+ if (err)
+ goto fail2;
+
+ for (i = 0; i < ARRAY_SIZE (vblk); i++)
+ {
+ struct grub_diskfilter_lv *comp;
+ struct grub_diskfilter_lv *lv;
+ grub_uint8_t type;
+
+ grub_uint8_t *ptr;
+ if (grub_memcmp (vblk[i].magic, LDM_VBLK_MAGIC,
+ sizeof (vblk[i].magic)) != 0)
+ continue;
+ if (grub_be_to_cpu16 (vblk[i].update_status)
+ != STATUS_CONSISTENT
+ && grub_be_to_cpu16 (vblk[i].update_status)
+ != STATUS_STILL_ACTIVE)
+ continue;
+ if (vblk[i].type != ENTRY_COMPONENT)
+ continue;
+ comp = grub_zalloc (sizeof (*comp));
+ if (!comp)
+ goto fail2;
+ comp->visible = 0;
+ comp->name = 0;
+ comp->fullname = 0;
+
+ ptr = vblk[i].dynamic;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ goto fail2;
+ }
+ comp->internal_id = grub_malloc ((grub_size_t) ptr[0] + 2);
+ if (!comp->internal_id)
+ {
+ grub_free (comp);
+ goto fail2;
+ }
+ grub_memcpy (comp->internal_id, ptr, ptr[0] + 1);
+ comp->internal_id[ptr[0] + 1] = 0;
+
+ ptr += *ptr + 1;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ /* ptr = name. */
+ ptr += *ptr + 1;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ /* ptr = state. */
+ ptr += *ptr + 1;
+ type = *ptr++;
+ /* skip zeros. */
+ ptr += 4;
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+
+ /* ptr = number of children. */
+ ptr += *ptr + 1;
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ ptr += 8 + 8;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic
+ + sizeof (vblk[i].dynamic))
+ {
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ for (lv = vg->lvs; lv; lv = lv->next)
+ {
+ if (lv->internal_id[0] == ptr[0]
+ && grub_memcmp (lv->internal_id + 1, ptr + 1, ptr[0]) == 0)
+ break;
+ }
+ if (!lv)
+ {
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ continue;
+ }
+ comp->size = lv->size;
+ if (type == SPANNED)
+ {
+ comp->segment_alloc = 8;
+ comp->segment_count = 0;
+ comp->segments = grub_calloc (comp->segment_alloc,
+ sizeof (*comp->segments));
+ if (!comp->segments)
+ {
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ }
+ else
+ {
+ comp->segment_alloc = 1;
+ comp->segment_count = 1;
+ comp->segments = grub_malloc (sizeof (*comp->segments));
+ if (!comp->segments)
+ {
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ comp->segments->start_extent = 0;
+ comp->segments->extent_count = lv->size;
+ comp->segments->layout = 0;
+ if (type == STRIPE)
+ comp->segments->type = GRUB_DISKFILTER_STRIPED;
+ else if (type == RAID5)
+ {
+ comp->segments->type = GRUB_DISKFILTER_RAID5;
+ comp->segments->layout = GRUB_RAID_LAYOUT_SYMMETRIC_MASK;
+ }
+ else
+ {
+ grub_free (comp->segments);
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ ptr += *ptr + 1;
+ ptr++;
+ if (!(vblk[i].flags & 0x10))
+ {
+ grub_free (comp->segments);
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
+ || ptr + *ptr + 1 >= vblk[i].dynamic
+ + sizeof (vblk[i].dynamic))
+ {
+ grub_free (comp->segments);
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ comp->segments->stripe_size = read_int (ptr + 1, *ptr);
+ ptr += *ptr + 1;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic
+ + sizeof (vblk[i].dynamic))
+ {
+ grub_free (comp->segments);
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ comp->segments->node_count = read_int (ptr + 1, *ptr);
+ comp->segments->node_alloc = comp->segments->node_count;
+ comp->segments->nodes = grub_calloc (comp->segments->node_alloc,
+ sizeof (*comp->segments->nodes));
+ if (!lv->segments->nodes)
+ {
+ grub_free (comp->segments);
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ }
+
+ if (lv->segments->node_alloc == lv->segments->node_count)
+ {
+ void *t;
+ grub_size_t sz;
+
+ if (grub_mul (lv->segments->node_alloc, 2, &lv->segments->node_alloc) ||
+ grub_mul (lv->segments->node_alloc, sizeof (*lv->segments->nodes), &sz))
+ {
+ grub_free (comp->segments->nodes);
+ grub_free (comp->segments);
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+
+ t = grub_realloc (lv->segments->nodes, sz);
+ if (!t)
+ {
+ grub_free (comp->segments->nodes);
+ grub_free (comp->segments);
+ grub_free (comp->internal_id);
+ grub_free (comp);
+ goto fail2;
+ }
+ lv->segments->nodes = t;
+ }
+ lv->segments->nodes[lv->segments->node_count].pv = 0;
+ lv->segments->nodes[lv->segments->node_count].start = 0;
+ lv->segments->nodes[lv->segments->node_count++].lv = comp;
+ comp->next = vg->lvs;
+ vg->lvs = comp;
+ }
+ }
+ /* Partitions. */
+ for (cursec = startsec + 0x12; cursec < endsec; cursec++)
+ {
+ struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE
+ / sizeof (struct grub_ldm_vblk)];
+ unsigned i;
+ err = grub_disk_read (disk, cursec, 0,
+ sizeof(vblk), &vblk);
+ if (err)
+ goto fail2;
+
+ for (i = 0; i < ARRAY_SIZE (vblk); i++)
+ {
+ struct grub_diskfilter_lv *comp;
+ struct grub_diskfilter_node part;
+ grub_disk_addr_t start, size;
+
+ grub_uint8_t *ptr;
+ part.name = 0;
+ if (grub_memcmp (vblk[i].magic, LDM_VBLK_MAGIC,
+ sizeof (vblk[i].magic)) != 0)
+ continue;
+ if (grub_be_to_cpu16 (vblk[i].update_status)
+ != STATUS_CONSISTENT
+ && grub_be_to_cpu16 (vblk[i].update_status)
+ != STATUS_STILL_ACTIVE)
+ continue;
+ if (vblk[i].type != ENTRY_PARTITION)
+ continue;
+ part.lv = 0;
+ part.pv = 0;
+
+ ptr = vblk[i].dynamic;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ goto fail2;
+ }
+ /* ID */
+ ptr += *ptr + 1;
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ goto fail2;
+ }
+ /* ptr = name. */
+ ptr += *ptr + 1;
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ goto fail2;
+ }
+
+ /* skip zeros and logcommit id. */
+ ptr += 4 + 8;
+ if (ptr + 16 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ goto fail2;
+ }
+ part.start = read_int (ptr, 8);
+ start = read_int (ptr + 8, 8);
+ ptr += 16;
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
+ || ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ goto fail2;
+ }
+ size = read_int (ptr + 1, *ptr);
+ ptr += *ptr + 1;
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
+ || ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ goto fail2;
+ }
+
+ for (comp = vg->lvs; comp; comp = comp->next)
+ if (comp->internal_id[0] == ptr[0]
+ && grub_memcmp (ptr + 1, comp->internal_id + 1,
+ comp->internal_id[0]) == 0)
+ goto out;
+ continue;
+ out:
+ if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
+ || ptr + *ptr + 1 >= vblk[i].dynamic + sizeof (vblk[i].dynamic))
+ {
+ goto fail2;
+ }
+ ptr += *ptr + 1;
+ struct grub_diskfilter_pv *pv;
+ for (pv = vg->pvs; pv; pv = pv->next)
+ if (pv->internal_id[0] == ptr[0]
+ && grub_memcmp (pv->internal_id + 1, ptr + 1, ptr[0]) == 0)
+ part.pv = pv;
+
+ if (comp->segment_alloc == 1)
+ {
+ unsigned node_index;
+ ptr += *ptr + 1;
+ if (ptr + *ptr + 1 >= vblk[i].dynamic
+ + sizeof (vblk[i].dynamic))
+ {
+ goto fail2;
+ }
+ node_index = read_int (ptr + 1, *ptr);
+ if (node_index < comp->segments->node_count)
+ comp->segments->nodes[node_index] = part;
+ }
+ else
+ {
+ if (comp->segment_alloc == comp->segment_count)
+ {
+ void *t;
+ grub_size_t sz;
+
+ if (grub_mul (comp->segment_alloc, 2, &comp->segment_alloc) ||
+ grub_mul (comp->segment_alloc, sizeof (*comp->segments), &sz))
+ goto fail2;
+
+ t = grub_realloc (comp->segments, sz);
+ if (!t)
+ goto fail2;
+ comp->segments = t;
+ }
+ comp->segments[comp->segment_count].start_extent = start;
+ comp->segments[comp->segment_count].extent_count = size;
+ comp->segments[comp->segment_count].type = GRUB_DISKFILTER_STRIPED;
+ comp->segments[comp->segment_count].node_count = 1;
+ comp->segments[comp->segment_count].node_alloc = 1;
+ comp->segments[comp->segment_count].nodes
+ = grub_malloc (sizeof (*comp->segments[comp->segment_count].nodes));
+ if (!comp->segments[comp->segment_count].nodes)
+ goto fail2;
+ comp->segments[comp->segment_count].nodes[0] = part;
+ comp->segment_count++;
+ }
+ }
+ }
+ if (grub_diskfilter_vg_register (vg))
+ goto fail2;
+ return vg;
+ fail2:
+ {
+ struct grub_diskfilter_lv *lv, *next_lv;
+ struct grub_diskfilter_pv *pv, *next_pv;
+ for (lv = vg->lvs; lv; lv = next_lv)
+ {
+ unsigned i;
+ for (i = 0; i < lv->segment_count; i++)
+ grub_free (lv->segments[i].nodes);
+
+ next_lv = lv->next;
+ grub_free (lv->segments);
+ grub_free (lv->internal_id);
+ grub_free (lv->name);
+ grub_free (lv->fullname);
+ grub_free (lv);
+ }
+ for (pv = vg->pvs; pv; pv = next_pv)
+ {
+ next_pv = pv->next;
+ grub_free (pv->id.uuid);
+ grub_free (pv);
+ }
+ }
+ grub_free (vg->uuid);
+ grub_free (vg);
+ return NULL;
+}
+
+static struct grub_diskfilter_vg *
+grub_ldm_detect (grub_disk_t disk,
+ struct grub_diskfilter_pv_id *id,
+ grub_disk_addr_t *start_sector)
+{
+ grub_err_t err;
+ struct grub_ldm_label label;
+ struct grub_diskfilter_vg *vg;
+
+#ifdef GRUB_UTIL
+ grub_util_info ("scanning %s for LDM", disk->name);
+#endif
+
+ {
+ int i;
+ int has_ldm = msdos_has_ldm_partition (disk);
+ for (i = 0; i < 3; i++)
+ {
+ grub_disk_addr_t sector = LDM_LABEL_SECTOR;
+ switch (i)
+ {
+ case 0:
+ if (!has_ldm)
+ continue;
+ sector = LDM_LABEL_SECTOR;
+ break;
+ case 1:
+ /* LDM is never inside a partition. */
+ if (!has_ldm || disk->partition)
+ continue;
+ sector = grub_disk_native_sectors (disk);
+ if (sector == GRUB_DISK_SIZE_UNKNOWN)
+ continue;
+ sector--;
+ break;
+ /* FIXME: try the third copy. */
+ case 2:
+ sector = gpt_ldm_sector (disk);
+ if (!sector)
+ continue;
+ break;
+ }
+ err = grub_disk_read (disk, sector, 0,
+ sizeof(label), &label);
+ if (err)
+ return NULL;
+ if (grub_memcmp (label.magic, LDM_MAGIC, sizeof (label.magic)) == 0
+ && grub_be_to_cpu16 (label.ver_major) == 0x02
+ && grub_be_to_cpu16 (label.ver_minor) >= 0x0b
+ && grub_be_to_cpu16 (label.ver_minor) <= 0x0c)
+ break;
+ }
+
+ /* Return if we didn't find a label. */
+ if (i == 3)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("no LDM signature found");
+#endif
+ return NULL;
+ }
+ }
+
+ id->uuid = grub_malloc (LDM_GUID_STRLEN + 1);
+ if (!id->uuid)
+ return NULL;
+ grub_memcpy (id->uuid, label.disk_guid, LDM_GUID_STRLEN);
+ id->uuid[LDM_GUID_STRLEN] = 0;
+ id->uuidlen = grub_strlen ((char *) id->uuid);
+ *start_sector = grub_be_to_cpu64 (label.pv_start);
+
+ {
+ grub_size_t s;
+ for (s = 0; s < LDM_GUID_STRLEN && label.group_guid[s]; s++);
+ vg = grub_diskfilter_get_vg_by_uuid (s, label.group_guid);
+ if (! vg)
+ vg = make_vg (disk, &label);
+ }
+
+ if (!vg)
+ {
+ grub_free (id->uuid);
+ return NULL;
+ }
+ return vg;
+}
+
+#ifdef GRUB_UTIL
+
+char *
+grub_util_get_ldm (grub_disk_t disk, grub_disk_addr_t start)
+{
+ struct grub_diskfilter_pv *pv = NULL;
+ struct grub_diskfilter_vg *vg = NULL;
+ struct grub_diskfilter_lv *res = 0, *lv, *res_lv = 0;
+
+ pv = grub_diskfilter_get_pv_from_disk (disk, &vg);
+
+ if (!pv)
+ return NULL;
+
+ for (lv = vg->lvs; lv; lv = lv->next)
+ if (lv->segment_count == 1 && lv->segments->node_count == 1
+ && lv->segments->type == GRUB_DISKFILTER_STRIPED
+ && lv->segments->nodes->pv == pv
+ && lv->segments->nodes->start + pv->start_sector == start)
+ {
+ res_lv = lv;
+ break;
+ }
+ if (!res_lv)
+ return NULL;
+ for (lv = vg->lvs; lv; lv = lv->next)
+ if (lv->segment_count == 1 && lv->segments->node_count == 1
+ && lv->segments->type == GRUB_DISKFILTER_MIRROR
+ && lv->segments->nodes->lv == res_lv)
+ {
+ res = lv;
+ break;
+ }
+ if (res && res->fullname)
+ return grub_strdup (res->fullname);
+ return NULL;
+}
+
+int
+grub_util_is_ldm (grub_disk_t disk)
+{
+ int i;
+ int has_ldm = msdos_has_ldm_partition (disk);
+ for (i = 0; i < 3; i++)
+ {
+ grub_disk_addr_t sector = LDM_LABEL_SECTOR;
+ grub_err_t err;
+ struct grub_ldm_label label;
+
+ switch (i)
+ {
+ case 0:
+ if (!has_ldm)
+ continue;
+ sector = LDM_LABEL_SECTOR;
+ break;
+ case 1:
+ /* LDM is never inside a partition. */
+ if (!has_ldm || disk->partition)
+ continue;
+ sector = grub_disk_native_sectors (disk);
+ if (sector == GRUB_DISK_SIZE_UNKNOWN)
+ continue;
+ sector--;
+ break;
+ /* FIXME: try the third copy. */
+ case 2:
+ sector = gpt_ldm_sector (disk);
+ if (!sector)
+ continue;
+ break;
+ }
+ err = grub_disk_read (disk, sector, 0, sizeof(label), &label);
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+ /* This check is more relaxed on purpose. */
+ if (grub_memcmp (label.magic, LDM_MAGIC, sizeof (label.magic)) == 0)
+ return 1;
+ }
+
+ return 0;
+}
+
+grub_err_t
+grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
+ unsigned int max_nsectors,
+ grub_embed_type_t embed_type,
+ grub_disk_addr_t **sectors)
+{
+ struct grub_diskfilter_pv *pv = NULL;
+ struct grub_diskfilter_vg *vg;
+ struct grub_diskfilter_lv *lv;
+ unsigned i;
+
+ if (embed_type != GRUB_EMBED_PCBIOS)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "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);
+ if (!pv)
+ return grub_error (GRUB_ERR_BUG, "disk isn't LDM");
+ for (lv = vg->lvs; lv; lv = lv->next)
+ {
+ struct grub_diskfilter_lv *comp;
+
+ if (!lv->visible || !lv->fullname)
+ continue;
+
+ if (lv->segment_count != 1)
+ continue;
+ if (lv->segments->type != GRUB_DISKFILTER_MIRROR
+ || lv->segments->node_count != 1
+ || lv->segments->start_extent != 0
+ || lv->segments->extent_count != lv->size)
+ continue;
+
+ comp = lv->segments->nodes->lv;
+ if (!comp)
+ continue;
+
+ if (comp->segment_count != 1 || comp->size != lv->size)
+ continue;
+ if (comp->segments->type != GRUB_DISKFILTER_STRIPED
+ || comp->segments->node_count != 1
+ || comp->segments->start_extent != 0
+ || comp->segments->extent_count != lv->size)
+ continue;
+
+ /* How to implement proper check is to be discussed. */
+#if 1
+ if (1)
+ continue;
+#else
+ if (grub_strcmp (lv->name, "Volume5") != 0)
+ continue;
+#endif
+ if (lv->size < *nsectors)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ /* TRANSLATORS: it's a partition for embedding,
+ not a partition embed into something. GRUB
+ install tools put core.img into a place
+ usable for bootloaders (called generically
+ "embedding zone") and this operation is
+ called "embedding". */
+ N_("your LDM Embedding Partition is too small;"
+ " embedding won't be possible"));
+ *nsectors = lv->size;
+ if (*nsectors > max_nsectors)
+ *nsectors = max_nsectors;
+ *sectors = grub_calloc (*nsectors, sizeof (**sectors));
+ if (!*sectors)
+ return grub_errno;
+ for (i = 0; i < *nsectors; i++)
+ (*sectors)[i] = (lv->segments->nodes->start
+ + comp->segments->nodes->start
+ + comp->segments->nodes->pv->start_sector + i);
+ return GRUB_ERR_NONE;
+ }
+
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ /* TRANSLATORS: it's a partition for embedding,
+ not a partition embed into something. */
+ N_("this LDM has no Embedding Partition;"
+ " embedding won't be possible"));
+}
+#endif
+
+static struct grub_diskfilter grub_ldm_dev = {
+ .name = "ldm",
+ .detect = grub_ldm_detect,
+ .next = 0
+};
+
+GRUB_MOD_INIT (ldm)
+{
+ grub_diskfilter_register_back (&grub_ldm_dev);
+}
+
+GRUB_MOD_FINI (ldm)
+{
+ grub_diskfilter_unregister (&grub_ldm_dev);
+}
diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c
new file mode 100644
index 0000000..41bebd1
--- /dev/null
+++ b/grub-core/disk/loopback.c
@@ -0,0 +1,240 @@
+/* loopback.c - command to add loopback devices. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_loopback
+{
+ char *devname;
+ grub_file_t file;
+ struct grub_loopback *next;
+ unsigned long id;
+};
+
+static struct grub_loopback *loopback_list;
+static unsigned long last_id = 0;
+
+static const struct grub_arg_option options[] =
+ {
+ /* TRANSLATORS: The disk is simply removed from the list of available ones,
+ not wiped, avoid to scare user. */
+ {"delete", 'd', 0, N_("Delete the specified loopback drive."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+/* Delete the loopback device NAME. */
+static grub_err_t
+delete_loopback (const char *name)
+{
+ struct grub_loopback *dev;
+ struct grub_loopback **prev;
+
+ /* Search for the device. */
+ for (dev = loopback_list, prev = &loopback_list;
+ dev;
+ prev = &dev->next, dev = dev->next)
+ if (grub_strcmp (dev->devname, name) == 0)
+ break;
+
+ if (! dev)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "device not found");
+
+ /* Remove the device from the list. */
+ *prev = dev->next;
+
+ grub_free (dev->devname);
+ grub_file_close (dev->file);
+ grub_free (dev);
+
+ return 0;
+}
+
+/* The command to add and remove loopback devices. */
+static grub_err_t
+grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ grub_file_t file;
+ struct grub_loopback *newdev;
+ grub_err_t ret;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required");
+
+ /* Check if `-d' was used. */
+ if (state[0].set)
+ return delete_loopback (args[0]);
+
+ if (argc < 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ /* Check that a device with requested name does not already exist. */
+ for (newdev = loopback_list; newdev; newdev = newdev->next)
+ if (grub_strcmp (newdev->devname, args[0]) == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name already exists");
+
+ file = grub_file_open (args[1], GRUB_FILE_TYPE_LOOPBACK
+ | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (! file)
+ return grub_errno;
+
+ /* Unable to replace it, make a new entry. */
+ newdev = grub_malloc (sizeof (struct grub_loopback));
+ if (! newdev)
+ goto fail;
+
+ newdev->devname = grub_strdup (args[0]);
+ if (! newdev->devname)
+ {
+ grub_free (newdev);
+ goto fail;
+ }
+
+ newdev->file = file;
+ newdev->id = last_id++;
+
+ /* Add the new entry to the list. */
+ newdev->next = loopback_list;
+ loopback_list = newdev;
+
+ return 0;
+
+fail:
+ ret = grub_errno;
+ grub_file_close (file);
+ return ret;
+}
+
+
+static int
+grub_loopback_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ struct grub_loopback *d;
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+ for (d = loopback_list; d; d = d->next)
+ {
+ if (hook (d->devname, hook_data))
+ return 1;
+ }
+ return 0;
+}
+
+static grub_err_t
+grub_loopback_open (const char *name, grub_disk_t disk)
+{
+ struct grub_loopback *dev;
+
+ for (dev = loopback_list; dev; dev = dev->next)
+ if (grub_strcmp (dev->devname, name) == 0)
+ break;
+
+ if (! dev)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
+
+ /* Use the filesize for the disk size, round up to a complete sector. */
+ if (dev->file->size != GRUB_FILE_SIZE_UNKNOWN)
+ disk->total_sectors = ((dev->file->size + GRUB_DISK_SECTOR_SIZE - 1)
+ / GRUB_DISK_SECTOR_SIZE);
+ else
+ disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN;
+ /* Avoid reading more than 512M. */
+ disk->max_agglomerate = 1 << (29 - GRUB_DISK_SECTOR_BITS
+ - GRUB_DISK_CACHE_BITS);
+
+ disk->id = dev->id;
+
+ disk->data = dev;
+
+ return 0;
+}
+
+static grub_err_t
+grub_loopback_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_file_t file = ((struct grub_loopback *) disk->data)->file;
+ grub_off_t pos;
+
+ grub_file_seek (file, sector << GRUB_DISK_SECTOR_BITS);
+
+ grub_file_read (file, buf, size << GRUB_DISK_SECTOR_BITS);
+ if (grub_errno)
+ return grub_errno;
+
+ /* In case there is more data read than there is available, in case
+ of files that are not a multiple of GRUB_DISK_SECTOR_SIZE, fill
+ the rest with zeros. */
+ pos = (sector + size) << GRUB_DISK_SECTOR_BITS;
+ if (pos > file->size)
+ {
+ grub_size_t amount = pos - file->size;
+ grub_memset (buf + (size << GRUB_DISK_SECTOR_BITS) - amount, 0, amount);
+ }
+
+ return 0;
+}
+
+static grub_err_t
+grub_loopback_write (grub_disk_t disk __attribute ((unused)),
+ grub_disk_addr_t sector __attribute ((unused)),
+ grub_size_t size __attribute ((unused)),
+ const char *buf __attribute ((unused)))
+{
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "loopback write is not supported");
+}
+
+static struct grub_disk_dev grub_loopback_dev =
+ {
+ .name = "loopback",
+ .id = GRUB_DISK_DEVICE_LOOPBACK_ID,
+ .disk_iterate = grub_loopback_iterate,
+ .disk_open = grub_loopback_open,
+ .disk_read = grub_loopback_read,
+ .disk_write = grub_loopback_write,
+ .next = 0
+ };
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(loopback)
+{
+ cmd = grub_register_extcmd ("loopback", grub_cmd_loopback, 0,
+ N_("[-d] DEVICENAME FILE."),
+ /* TRANSLATORS: The file itself is not destroyed
+ or transformed into drive. */
+ N_("Make a virtual drive from a file."), options);
+ grub_disk_dev_register (&grub_loopback_dev);
+}
+
+GRUB_MOD_FINI(loopback)
+{
+ grub_unregister_extcmd (cmd);
+ grub_disk_dev_unregister (&grub_loopback_dev);
+}
diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c
new file mode 100644
index 0000000..13103ea
--- /dev/null
+++ b/grub-core/disk/luks.c
@@ -0,0 +1,329 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2007,2010,2011,2019 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/cryptodisk.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/err.h>
+#include <grub/disk.h>
+#include <grub/crypto.h>
+#include <grub/partition.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define MAX_PASSPHRASE 256
+
+#define LUKS_KEY_ENABLED 0x00AC71F3
+
+/* On disk LUKS header */
+struct grub_luks_phdr
+{
+ grub_uint8_t magic[6];
+#define LUKS_MAGIC "LUKS\xBA\xBE"
+ grub_uint16_t version;
+ char cipherName[32];
+ char cipherMode[32];
+ char hashSpec[32];
+ grub_uint32_t payloadOffset;
+ grub_uint32_t keyBytes;
+ grub_uint8_t mkDigest[20];
+ grub_uint8_t mkDigestSalt[32];
+ grub_uint32_t mkDigestIterations;
+ char uuid[40];
+ struct
+ {
+ grub_uint32_t active;
+ grub_uint32_t passwordIterations;
+ grub_uint8_t passwordSalt[32];
+ grub_uint32_t keyMaterialOffset;
+ grub_uint32_t stripes;
+ } keyblock[8];
+} GRUB_PACKED;
+
+typedef struct grub_luks_phdr *grub_luks_phdr_t;
+
+gcry_err_code_t AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src,
+ grub_uint8_t * dst, grub_size_t blocksize,
+ grub_size_t blocknumbers);
+
+static grub_cryptodisk_t
+configure_ciphers (grub_disk_t disk, const char *check_uuid,
+ int check_boot)
+{
+ grub_cryptodisk_t newdev;
+ const char *iptr;
+ struct grub_luks_phdr header;
+ char *optr;
+ char uuid[sizeof (header.uuid) + 1];
+ char ciphername[sizeof (header.cipherName) + 1];
+ char ciphermode[sizeof (header.cipherMode) + 1];
+ char hashspec[sizeof (header.hashSpec) + 1];
+ grub_err_t err;
+
+ if (check_boot)
+ return NULL;
+
+ /* Read the LUKS header. */
+ err = grub_disk_read (disk, 0, 0, sizeof (header), &header);
+ if (err)
+ {
+ if (err == GRUB_ERR_OUT_OF_RANGE)
+ grub_errno = GRUB_ERR_NONE;
+ return NULL;
+ }
+
+ /* Look for LUKS magic sequence. */
+ if (grub_memcmp (header.magic, LUKS_MAGIC, sizeof (header.magic))
+ || grub_be_to_cpu16 (header.version) != 1)
+ return NULL;
+
+ grub_memset (uuid, 0, sizeof (uuid));
+ optr = uuid;
+ for (iptr = header.uuid; iptr < &header.uuid[ARRAY_SIZE (header.uuid)];
+ iptr++)
+ {
+ if (*iptr != '-')
+ *optr++ = *iptr;
+ }
+ *optr = 0;
+
+ if (check_uuid && grub_strcasecmp (check_uuid, uuid) != 0)
+ {
+ grub_dprintf ("luks", "%s != %s\n", uuid, check_uuid);
+ return NULL;
+ }
+
+ /* Make sure that strings are null terminated. */
+ grub_memcpy (ciphername, header.cipherName, sizeof (header.cipherName));
+ ciphername[sizeof (header.cipherName)] = 0;
+ grub_memcpy (ciphermode, header.cipherMode, sizeof (header.cipherMode));
+ ciphermode[sizeof (header.cipherMode)] = 0;
+ grub_memcpy (hashspec, header.hashSpec, sizeof (header.hashSpec));
+ hashspec[sizeof (header.hashSpec)] = 0;
+
+ newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
+ if (!newdev)
+ return NULL;
+ newdev->offset_sectors = grub_be_to_cpu32 (header.payloadOffset);
+ newdev->source_disk = NULL;
+ newdev->log_sector_size = GRUB_LUKS1_LOG_SECTOR_SIZE;
+ newdev->total_sectors = grub_disk_native_sectors (disk) - newdev->offset_sectors;
+ grub_memcpy (newdev->uuid, uuid, sizeof (uuid));
+ newdev->modname = "luks";
+
+ /* Configure the hash used for the AF splitter and HMAC. */
+ newdev->hash = grub_crypto_lookup_md_by_name (hashspec);
+ if (!newdev->hash)
+ {
+ grub_free (newdev);
+ grub_error (GRUB_ERR_FILE_NOT_FOUND, "Couldn't load %s hash",
+ hashspec);
+ return NULL;
+ }
+
+ err = grub_cryptodisk_setcipher (newdev, ciphername, ciphermode);
+ if (err)
+ {
+ grub_free (newdev);
+ return NULL;
+ }
+
+ COMPILE_TIME_ASSERT (sizeof (newdev->uuid) >= sizeof (uuid));
+ return newdev;
+}
+
+static grub_err_t
+luks_recover_key (grub_disk_t source,
+ grub_cryptodisk_t dev)
+{
+ struct grub_luks_phdr header;
+ grub_size_t keysize;
+ grub_uint8_t *split_key = NULL;
+ char passphrase[MAX_PASSPHRASE] = "";
+ grub_uint8_t candidate_digest[sizeof (header.mkDigest)];
+ unsigned i;
+ grub_size_t length;
+ grub_err_t err;
+ grub_size_t max_stripes = 1;
+ char *tmp;
+
+ err = grub_disk_read (source, 0, 0, sizeof (header), &header);
+ if (err)
+ return err;
+
+ grub_puts_ (N_("Attempting to decrypt master key..."));
+ keysize = grub_be_to_cpu32 (header.keyBytes);
+ if (keysize > GRUB_CRYPTODISK_MAX_KEYLEN)
+ return grub_error (GRUB_ERR_BAD_FS, "key is too long");
+
+ for (i = 0; i < ARRAY_SIZE (header.keyblock); i++)
+ if (grub_be_to_cpu32 (header.keyblock[i].active) == LUKS_KEY_ENABLED
+ && grub_be_to_cpu32 (header.keyblock[i].stripes) > max_stripes)
+ max_stripes = grub_be_to_cpu32 (header.keyblock[i].stripes);
+
+ split_key = grub_calloc (keysize, max_stripes);
+ if (!split_key)
+ return grub_errno;
+
+ /* Get the passphrase from the user. */
+ tmp = NULL;
+ if (source->partition)
+ tmp = grub_partition_get_name (source->partition);
+ grub_printf_ (N_("Enter passphrase for %s%s%s (%s): "), source->name,
+ source->partition ? "," : "", tmp ? : "",
+ dev->uuid);
+ grub_free (tmp);
+ if (!grub_password_get (passphrase, MAX_PASSPHRASE))
+ {
+ grub_free (split_key);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Passphrase not supplied");
+ }
+
+ /* Try to recover master key from each active keyslot. */
+ for (i = 0; i < ARRAY_SIZE (header.keyblock); i++)
+ {
+ gcry_err_code_t gcry_err;
+ grub_uint8_t candidate_key[GRUB_CRYPTODISK_MAX_KEYLEN];
+ grub_uint8_t digest[GRUB_CRYPTODISK_MAX_KEYLEN];
+
+ /* Check if keyslot is enabled. */
+ if (grub_be_to_cpu32 (header.keyblock[i].active) != LUKS_KEY_ENABLED)
+ continue;
+
+ grub_dprintf ("luks", "Trying keyslot %d\n", i);
+
+ /* Calculate the PBKDF2 of the user supplied passphrase. */
+ gcry_err = grub_crypto_pbkdf2 (dev->hash, (grub_uint8_t *) passphrase,
+ grub_strlen (passphrase),
+ header.keyblock[i].passwordSalt,
+ sizeof (header.keyblock[i].passwordSalt),
+ grub_be_to_cpu32 (header.keyblock[i].
+ passwordIterations),
+ digest, keysize);
+
+ if (gcry_err)
+ {
+ grub_free (split_key);
+ return grub_crypto_gcry_error (gcry_err);
+ }
+
+ grub_dprintf ("luks", "PBKDF2 done\n");
+
+ gcry_err = grub_cryptodisk_setkey (dev, digest, keysize);
+ if (gcry_err)
+ {
+ grub_free (split_key);
+ return grub_crypto_gcry_error (gcry_err);
+ }
+
+ length = (keysize * grub_be_to_cpu32 (header.keyblock[i].stripes));
+
+ /* Read and decrypt the key material from the disk. */
+ err = grub_disk_read (source,
+ grub_be_to_cpu32 (header.keyblock
+ [i].keyMaterialOffset), 0,
+ length, split_key);
+ if (err)
+ {
+ grub_free (split_key);
+ return err;
+ }
+
+ gcry_err = grub_cryptodisk_decrypt (dev, split_key, length, 0,
+ GRUB_LUKS1_LOG_SECTOR_SIZE);
+ if (gcry_err)
+ {
+ grub_free (split_key);
+ return grub_crypto_gcry_error (gcry_err);
+ }
+
+ /* Merge the decrypted key material to get the candidate master key. */
+ gcry_err = AF_merge (dev->hash, split_key, candidate_key, keysize,
+ grub_be_to_cpu32 (header.keyblock[i].stripes));
+ if (gcry_err)
+ {
+ grub_free (split_key);
+ return grub_crypto_gcry_error (gcry_err);
+ }
+
+ grub_dprintf ("luks", "candidate key recovered\n");
+
+ /* Calculate the PBKDF2 of the candidate master key. */
+ gcry_err = grub_crypto_pbkdf2 (dev->hash, candidate_key,
+ grub_be_to_cpu32 (header.keyBytes),
+ header.mkDigestSalt,
+ sizeof (header.mkDigestSalt),
+ grub_be_to_cpu32
+ (header.mkDigestIterations),
+ candidate_digest,
+ sizeof (candidate_digest));
+ if (gcry_err)
+ {
+ grub_free (split_key);
+ return grub_crypto_gcry_error (gcry_err);
+ }
+
+ /* Compare the calculated PBKDF2 to the digest stored
+ in the header to see if it's correct. */
+ if (grub_memcmp (candidate_digest, header.mkDigest,
+ sizeof (header.mkDigest)) != 0)
+ {
+ grub_dprintf ("luks", "bad digest\n");
+ continue;
+ }
+
+ /* TRANSLATORS: It's a cryptographic key slot: one element of an array
+ where each element is either empty or holds a key. */
+ grub_printf_ (N_("Slot %d opened\n"), i);
+
+ /* Set the master key. */
+ gcry_err = grub_cryptodisk_setkey (dev, candidate_key, keysize);
+ if (gcry_err)
+ {
+ grub_free (split_key);
+ return grub_crypto_gcry_error (gcry_err);
+ }
+
+ grub_free (split_key);
+
+ return GRUB_ERR_NONE;
+ }
+
+ grub_free (split_key);
+ return GRUB_ACCESS_DENIED;
+}
+
+struct grub_cryptodisk_dev luks_crypto = {
+ .scan = configure_ciphers,
+ .recover_key = luks_recover_key
+};
+
+GRUB_MOD_INIT (luks)
+{
+ COMPILE_TIME_ASSERT (sizeof (((struct grub_luks_phdr *) 0)->uuid)
+ < GRUB_CRYPTODISK_MAX_UUID_LENGTH);
+ grub_cryptodisk_dev_register (&luks_crypto);
+}
+
+GRUB_MOD_FINI (luks)
+{
+ grub_cryptodisk_dev_unregister (&luks_crypto);
+}
diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
new file mode 100644
index 0000000..371a53b
--- /dev/null
+++ b/grub-core/disk/luks2.c
@@ -0,0 +1,791 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2019 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/cryptodisk.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/err.h>
+#include <grub/disk.h>
+#include <grub/crypto.h>
+#include <grub/partition.h>
+#include <grub/i18n.h>
+
+#include <base64.h>
+#include <json.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define LUKS_MAGIC_1ST "LUKS\xBA\xBE"
+#define LUKS_MAGIC_2ND "SKUL\xBA\xBE"
+
+#define MAX_PASSPHRASE 256
+
+enum grub_luks2_kdf_type
+{
+ LUKS2_KDF_TYPE_ARGON2I,
+ LUKS2_KDF_TYPE_PBKDF2
+};
+typedef enum grub_luks2_kdf_type grub_luks2_kdf_type_t;
+
+/* On disk LUKS header */
+struct grub_luks2_header
+{
+ char magic[6];
+ grub_uint16_t version;
+ grub_uint64_t hdr_size;
+ grub_uint64_t seqid;
+ char label[48];
+ char csum_alg[32];
+ grub_uint8_t salt[64];
+ char uuid[40];
+ char subsystem[48];
+ grub_uint64_t hdr_offset;
+ char _padding[184];
+ grub_uint8_t csum[64];
+ char _padding4096[7*512];
+} GRUB_PACKED;
+typedef struct grub_luks2_header grub_luks2_header_t;
+
+struct grub_luks2_keyslot
+{
+ /* The integer key to the associative array of keyslots. */
+ grub_uint64_t idx;
+ grub_int64_t key_size;
+ grub_int64_t priority;
+ struct
+ {
+ const char *encryption;
+ grub_uint64_t offset;
+ grub_uint64_t size;
+ grub_int64_t key_size;
+ } area;
+ struct
+ {
+ const char *hash;
+ grub_int64_t stripes;
+ } af;
+ struct
+ {
+ grub_luks2_kdf_type_t type;
+ const char *salt;
+ union
+ {
+ struct
+ {
+ grub_int64_t time;
+ grub_int64_t memory;
+ grub_int64_t cpus;
+ } argon2i;
+ struct
+ {
+ const char *hash;
+ grub_int64_t iterations;
+ } pbkdf2;
+ } u;
+ } kdf;
+};
+typedef struct grub_luks2_keyslot grub_luks2_keyslot_t;
+
+struct grub_luks2_segment
+{
+ grub_uint64_t idx;
+ grub_uint64_t offset;
+ const char *size;
+ const char *encryption;
+ grub_int64_t sector_size;
+};
+typedef struct grub_luks2_segment grub_luks2_segment_t;
+
+struct grub_luks2_digest
+{
+ grub_uint64_t idx;
+ /* Both keyslots and segments are interpreted as bitfields here */
+ grub_uint64_t keyslots;
+ grub_uint64_t segments;
+ const char *salt;
+ const char *digest;
+ const char *hash;
+ grub_int64_t iterations;
+};
+typedef struct grub_luks2_digest grub_luks2_digest_t;
+
+gcry_err_code_t AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src,
+ grub_uint8_t * dst, grub_size_t blocksize,
+ grub_size_t blocknumbers);
+
+static grub_err_t
+luks2_parse_keyslot (grub_luks2_keyslot_t *out, const grub_json_t *keyslot)
+{
+ grub_json_t area, af, kdf;
+ const char *type;
+
+ if (grub_json_getstring (&type, keyslot, "type"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing or invalid keyslot");
+ else if (grub_strcmp (type, "luks2"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported keyslot type %s", type);
+ else if (grub_json_getint64 (&out->key_size, keyslot, "key_size"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing keyslot information");
+ if (grub_json_getint64 (&out->priority, keyslot, "priority"))
+ out->priority = 1;
+
+ if (grub_json_getvalue (&area, keyslot, "area") ||
+ grub_json_getstring (&type, &area, "type"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing or invalid key area");
+ else if (grub_strcmp (type, "raw"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported key area type: %s", type);
+ else if (grub_json_getuint64 (&out->area.offset, &area, "offset") ||
+ grub_json_getuint64 (&out->area.size, &area, "size") ||
+ grub_json_getstring (&out->area.encryption, &area, "encryption") ||
+ grub_json_getint64 (&out->area.key_size, &area, "key_size"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing key area information");
+
+ if (grub_json_getvalue (&kdf, keyslot, "kdf") ||
+ grub_json_getstring (&type, &kdf, "type") ||
+ grub_json_getstring (&out->kdf.salt, &kdf, "salt"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing or invalid KDF");
+ else if (!grub_strcmp (type, "argon2i") || !grub_strcmp (type, "argon2id"))
+ {
+ out->kdf.type = LUKS2_KDF_TYPE_ARGON2I;
+ if (grub_json_getint64 (&out->kdf.u.argon2i.time, &kdf, "time") ||
+ grub_json_getint64 (&out->kdf.u.argon2i.memory, &kdf, "memory") ||
+ grub_json_getint64 (&out->kdf.u.argon2i.cpus, &kdf, "cpus"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing Argon2i parameters");
+ }
+ else if (!grub_strcmp (type, "pbkdf2"))
+ {
+ out->kdf.type = LUKS2_KDF_TYPE_PBKDF2;
+ if (grub_json_getstring (&out->kdf.u.pbkdf2.hash, &kdf, "hash") ||
+ grub_json_getint64 (&out->kdf.u.pbkdf2.iterations, &kdf, "iterations"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing PBKDF2 parameters");
+ }
+ else
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported KDF type %s", type);
+
+ if (grub_json_getvalue (&af, keyslot, "af") ||
+ grub_json_getstring (&type, &af, "type"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing or invalid area");
+ if (grub_strcmp (type, "luks1"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported AF type %s", type);
+ if (grub_json_getint64 (&out->af.stripes, &af, "stripes") ||
+ grub_json_getstring (&out->af.hash, &af, "hash"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing AF parameters");
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+luks2_parse_segment (grub_luks2_segment_t *out, const grub_json_t *segment)
+{
+ const char *type;
+
+ if (grub_json_getstring (&type, segment, "type"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid segment type");
+ else if (grub_strcmp (type, "crypt"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported segment type %s", type);
+
+ if (grub_json_getuint64 (&out->offset, segment, "offset") ||
+ grub_json_getstring (&out->size, segment, "size") ||
+ grub_json_getstring (&out->encryption, segment, "encryption") ||
+ grub_json_getint64 (&out->sector_size, segment, "sector_size"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing segment parameters");
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+luks2_parse_digest (grub_luks2_digest_t *out, const grub_json_t *digest)
+{
+ grub_json_t segments, keyslots, o;
+ grub_size_t i, size;
+ grub_uint64_t bit;
+ const char *type;
+
+ if (grub_json_getstring (&type, digest, "type"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid digest type");
+ else if (grub_strcmp (type, "pbkdf2"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported digest type %s", type);
+
+ if (grub_json_getvalue (&segments, digest, "segments") ||
+ grub_json_getvalue (&keyslots, digest, "keyslots") ||
+ grub_json_getstring (&out->salt, digest, "salt") ||
+ grub_json_getstring (&out->digest, digest, "digest") ||
+ grub_json_getstring (&out->hash, digest, "hash") ||
+ grub_json_getint64 (&out->iterations, digest, "iterations"))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Missing digest parameters");
+
+ if (grub_json_getsize (&size, &segments))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Digest references no segments");
+
+ out->segments = 0;
+ for (i = 0; i < size; i++)
+ {
+ if (grub_json_getchild (&o, &segments, i) ||
+ grub_json_getuint64 (&bit, &o, NULL))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid segment");
+ out->segments |= (1 << bit);
+ }
+
+ if (grub_json_getsize (&size, &keyslots))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Digest references no keyslots");
+
+ out->keyslots = 0;
+ for (i = 0; i < size; i++)
+ {
+ if (grub_json_getchild (&o, &keyslots, i) ||
+ grub_json_getuint64 (&bit, &o, NULL))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid keyslot");
+ out->keyslots |= (1 << bit);
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+luks2_get_keyslot (grub_luks2_keyslot_t *k, grub_luks2_digest_t *d, grub_luks2_segment_t *s,
+ const grub_json_t *root, grub_size_t keyslot_json_idx)
+{
+ grub_json_t keyslots, keyslot, digests, digest, segments, segment;
+ grub_size_t json_idx, size;
+
+ /* Get nth keyslot */
+ if (grub_json_getvalue (&keyslots, root, "keyslots") ||
+ grub_json_getchild (&keyslot, &keyslots, keyslot_json_idx) ||
+ grub_json_getuint64 (&k->idx, &keyslot, NULL) ||
+ grub_json_getchild (&keyslot, &keyslot, 0) ||
+ luks2_parse_keyslot (k, &keyslot))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not parse keyslot index %" PRIuGRUB_SIZE, keyslot_json_idx);
+
+ /* Get digest that matches the keyslot. */
+ if (grub_json_getvalue (&digests, root, "digests") ||
+ grub_json_getsize (&size, &digests))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not get digests");
+ for (json_idx = 0; json_idx < size; json_idx++)
+ {
+ if (grub_json_getchild (&digest, &digests, json_idx) ||
+ grub_json_getuint64 (&d->idx, &digest, NULL) ||
+ grub_json_getchild (&digest, &digest, 0) ||
+ luks2_parse_digest (d, &digest))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not parse digest index %" PRIuGRUB_SIZE, json_idx);
+
+ if ((d->keyslots & (1 << k->idx)))
+ break;
+ }
+ if (json_idx == size)
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, "No digest for keyslot \"%" PRIuGRUB_UINT64_T "\"", k->idx);
+
+ /* Get segment that matches the digest. */
+ if (grub_json_getvalue (&segments, root, "segments") ||
+ grub_json_getsize (&size, &segments))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not get segments");
+ for (json_idx = 0; json_idx < size; json_idx++)
+ {
+ if (grub_json_getchild (&segment, &segments, json_idx) ||
+ grub_json_getuint64 (&s->idx, &segment, NULL) ||
+ grub_json_getchild (&segment, &segment, 0) ||
+ luks2_parse_segment (s, &segment))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not parse segment index %" PRIuGRUB_SIZE, json_idx);
+
+ if ((d->segments & (1 << s->idx)))
+ break;
+ }
+ if (json_idx == size)
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, "No segment for digest \"%" PRIuGRUB_UINT64_T "\"", d->idx);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Determine whether to use primary or secondary header */
+static grub_err_t
+luks2_read_header (grub_disk_t disk, grub_luks2_header_t *outhdr)
+{
+ grub_luks2_header_t primary, secondary, *header = &primary;
+ grub_err_t ret;
+
+ /* Read the primary LUKS header. */
+ ret = grub_disk_read (disk, 0, 0, sizeof (primary), &primary);
+ if (ret)
+ return ret;
+
+ /* Look for LUKS magic sequence. */
+ if (grub_memcmp (primary.magic, LUKS_MAGIC_1ST, sizeof (primary.magic)) ||
+ grub_be_to_cpu16 (primary.version) != 2)
+ return GRUB_ERR_BAD_SIGNATURE;
+
+ /* Read the secondary header. */
+ ret = grub_disk_read (disk, 0, grub_be_to_cpu64 (primary.hdr_size), sizeof (secondary), &secondary);
+ if (ret)
+ return ret;
+
+ /* Look for LUKS magic sequence. */
+ if (grub_memcmp (secondary.magic, LUKS_MAGIC_2ND, sizeof (secondary.magic)) ||
+ grub_be_to_cpu16 (secondary.version) != 2)
+ return GRUB_ERR_BAD_SIGNATURE;
+
+ if (grub_be_to_cpu64 (primary.seqid) < grub_be_to_cpu64 (secondary.seqid))
+ header = &secondary;
+ grub_memcpy (outhdr, header, sizeof (*header));
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_cryptodisk_t
+luks2_scan (grub_disk_t disk, const char *check_uuid, int check_boot)
+{
+ grub_cryptodisk_t cryptodisk;
+ grub_luks2_header_t header;
+ char uuid[sizeof (header.uuid) + 1];
+ grub_size_t i, j;
+
+ if (check_boot)
+ return NULL;
+
+ if (luks2_read_header (disk, &header))
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return NULL;
+ }
+
+ for (i = 0, j = 0; i < sizeof (header.uuid); i++)
+ if (header.uuid[i] != '-')
+ uuid[j++] = header.uuid[i];
+ uuid[j] = '\0';
+
+ if (check_uuid && grub_strcasecmp (check_uuid, uuid) != 0)
+ return NULL;
+
+ cryptodisk = grub_zalloc (sizeof (*cryptodisk));
+ if (!cryptodisk)
+ return NULL;
+
+ COMPILE_TIME_ASSERT (sizeof (cryptodisk->uuid) >= sizeof (uuid));
+ grub_memcpy (cryptodisk->uuid, uuid, sizeof (uuid));
+
+ cryptodisk->modname = "luks2";
+ return cryptodisk;
+}
+
+static grub_err_t
+luks2_verify_key (grub_luks2_digest_t *d, grub_uint8_t *candidate_key,
+ grub_size_t candidate_key_len)
+{
+ grub_uint8_t candidate_digest[GRUB_CRYPTODISK_MAX_KEYLEN];
+ grub_uint8_t digest[GRUB_CRYPTODISK_MAX_KEYLEN], salt[GRUB_CRYPTODISK_MAX_KEYLEN];
+ grub_size_t saltlen = sizeof (salt), digestlen = sizeof (digest);
+ const gcry_md_spec_t *hash;
+ gcry_err_code_t gcry_ret;
+
+ /* Decode both digest and salt */
+ if (!base64_decode (d->digest, grub_strlen (d->digest), (char *)digest, &digestlen))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid digest");
+ if (!base64_decode (d->salt, grub_strlen (d->salt), (char *)salt, &saltlen))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid digest salt");
+
+ /* Configure the hash used for the digest. */
+ hash = grub_crypto_lookup_md_by_name (d->hash);
+ if (!hash)
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, "Couldn't load %s hash", d->hash);
+
+ /* Calculate the candidate key's digest */
+ gcry_ret = grub_crypto_pbkdf2 (hash,
+ candidate_key, candidate_key_len,
+ salt, saltlen,
+ d->iterations,
+ candidate_digest, digestlen);
+ if (gcry_ret)
+ return grub_crypto_gcry_error (gcry_ret);
+
+ if (grub_memcmp (candidate_digest, digest, digestlen) != 0)
+ return grub_error (GRUB_ERR_ACCESS_DENIED, "Mismatching digests");
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+luks2_decrypt_key (grub_uint8_t *out_key,
+ grub_disk_t source, grub_cryptodisk_t crypt,
+ grub_luks2_keyslot_t *k,
+ const grub_uint8_t *passphrase, grub_size_t passphraselen)
+{
+ grub_uint8_t area_key[GRUB_CRYPTODISK_MAX_KEYLEN];
+ grub_uint8_t salt[GRUB_CRYPTODISK_MAX_KEYLEN];
+ grub_uint8_t *split_key = NULL;
+ grub_size_t saltlen = sizeof (salt);
+ char cipher[32], *p;
+ const gcry_md_spec_t *hash;
+ gcry_err_code_t gcry_ret;
+ grub_err_t ret;
+
+ if (!base64_decode (k->kdf.salt, grub_strlen (k->kdf.salt),
+ (char *)salt, &saltlen))
+ {
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid keyslot salt");
+ goto err;
+ }
+
+ /* Calculate the binary area key of the user supplied passphrase. */
+ switch (k->kdf.type)
+ {
+ case LUKS2_KDF_TYPE_ARGON2I:
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Argon2 not supported");
+ goto err;
+ case LUKS2_KDF_TYPE_PBKDF2:
+ hash = grub_crypto_lookup_md_by_name (k->kdf.u.pbkdf2.hash);
+ if (!hash)
+ {
+ ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, "Couldn't load %s hash",
+ k->kdf.u.pbkdf2.hash);
+ goto err;
+ }
+
+ gcry_ret = grub_crypto_pbkdf2 (hash, (grub_uint8_t *) passphrase,
+ passphraselen,
+ salt, saltlen,
+ k->kdf.u.pbkdf2.iterations,
+ area_key, k->area.key_size);
+ if (gcry_ret)
+ {
+ ret = grub_crypto_gcry_error (gcry_ret);
+ goto err;
+ }
+
+ break;
+ }
+
+ /* Set up disk encryption parameters for the key area */
+ grub_strncpy (cipher, k->area.encryption, sizeof (cipher));
+ p = grub_memchr (cipher, '-', grub_strlen (cipher));
+ if (!p)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid encryption");
+ *p = '\0';
+
+ ret = grub_cryptodisk_setcipher (crypt, cipher, p + 1);
+ if (ret)
+ return ret;
+
+ gcry_ret = grub_cryptodisk_setkey (crypt, area_key, k->area.key_size);
+ if (gcry_ret)
+ {
+ ret = grub_crypto_gcry_error (gcry_ret);
+ goto err;
+ }
+
+ /* Read and decrypt the binary key area with the area key. */
+ split_key = grub_malloc (k->area.size);
+ if (!split_key)
+ {
+ ret = grub_errno;
+ goto err;
+ }
+
+ grub_errno = GRUB_ERR_NONE;
+ ret = grub_disk_read (source, 0, k->area.offset, k->area.size, split_key);
+ if (ret)
+ {
+ grub_error (GRUB_ERR_IO, "Read error: %s\n", grub_errmsg);
+ goto err;
+ }
+
+ /*
+ * The key slots area is always encrypted in 512-byte sectors,
+ * regardless of encrypted data sector size.
+ */
+ gcry_ret = grub_cryptodisk_decrypt (crypt, split_key, k->area.size, 0,
+ GRUB_LUKS1_LOG_SECTOR_SIZE);
+ if (gcry_ret)
+ {
+ ret = grub_crypto_gcry_error (gcry_ret);
+ goto err;
+ }
+
+ /* Configure the hash used for anti-forensic merging. */
+ hash = grub_crypto_lookup_md_by_name (k->af.hash);
+ if (!hash)
+ {
+ ret = grub_error (GRUB_ERR_FILE_NOT_FOUND, "Couldn't load %s hash",
+ k->af.hash);
+ goto err;
+ }
+
+ /* Merge the decrypted key material to get the candidate master key. */
+ gcry_ret = AF_merge (hash, split_key, out_key, k->key_size, k->af.stripes);
+ if (gcry_ret)
+ {
+ ret = grub_crypto_gcry_error (gcry_ret);
+ goto err;
+ }
+
+ grub_dprintf ("luks2", "Candidate key recovered\n");
+
+ err:
+ grub_free (split_key);
+ return ret;
+}
+
+static grub_err_t
+luks2_recover_key (grub_disk_t source,
+ grub_cryptodisk_t crypt)
+{
+ grub_uint8_t candidate_key[GRUB_CRYPTODISK_MAX_KEYLEN];
+ char passphrase[MAX_PASSPHRASE], cipher[32];
+ char *json_header = NULL, *part = NULL, *ptr;
+ grub_size_t candidate_key_len = 0, json_idx, size;
+ grub_luks2_header_t header;
+ grub_luks2_keyslot_t keyslot;
+ grub_luks2_digest_t digest;
+ grub_luks2_segment_t segment;
+ gcry_err_code_t gcry_ret;
+ grub_json_t *json = NULL, keyslots;
+ grub_err_t ret;
+
+ ret = luks2_read_header (source, &header);
+ if (ret)
+ return ret;
+
+ json_header = grub_zalloc (grub_be_to_cpu64 (header.hdr_size) - sizeof (header));
+ if (!json_header)
+ return GRUB_ERR_OUT_OF_MEMORY;
+
+ /* Read the JSON area. */
+ ret = grub_disk_read (source, 0, grub_be_to_cpu64 (header.hdr_offset) + sizeof (header),
+ grub_be_to_cpu64 (header.hdr_size) - sizeof (header), json_header);
+ if (ret)
+ goto err;
+
+ ptr = grub_memchr (json_header, 0, grub_be_to_cpu64 (header.hdr_size) - sizeof (header));
+ if (!ptr)
+ goto err;
+
+ ret = grub_json_parse (&json, json_header, grub_be_to_cpu64 (header.hdr_size));
+ if (ret)
+ {
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid LUKS2 JSON header");
+ goto err;
+ }
+
+ /* Get the passphrase from the user. */
+ if (source->partition)
+ part = grub_partition_get_name (source->partition);
+ grub_printf_ (N_("Enter passphrase for %s%s%s (%s): "), source->name,
+ source->partition ? "," : "", part ? : "",
+ crypt->uuid);
+ if (!grub_password_get (passphrase, MAX_PASSPHRASE))
+ {
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Passphrase not supplied");
+ goto err;
+ }
+
+ if (grub_json_getvalue (&keyslots, json, "keyslots") ||
+ grub_json_getsize (&size, &keyslots))
+ {
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "Could not get keyslots");
+ goto err;
+ }
+
+ if (grub_disk_native_sectors (source) == GRUB_DISK_SIZE_UNKNOWN)
+ {
+ /* FIXME: Allow use of source disk, and maybe cause errors in read. */
+ grub_dprintf ("luks2", "Source disk %s has an unknown size, "
+ "conservatively returning error\n", source->name);
+ ret = grub_error (GRUB_ERR_BUG, "Unknown size of luks2 source device");
+ goto err;
+ }
+
+ /* Try all keyslot */
+ for (json_idx = 0; json_idx < size; json_idx++)
+ {
+ char indexstr[21]; /* log10(2^64) ~ 20, plus NUL character. */
+ typeof (source->total_sectors) max_crypt_sectors = 0;
+
+ grub_errno = GRUB_ERR_NONE;
+ ret = luks2_get_keyslot (&keyslot, &digest, &segment, json, json_idx);
+ if (ret)
+ goto err;
+ if (grub_errno != GRUB_ERR_NONE)
+ grub_dprintf ("luks2", "Ignoring unhandled error %d from luks2_get_keyslot\n", grub_errno);
+
+ if (keyslot.priority == 0)
+ {
+ grub_dprintf ("luks2", "Ignoring keyslot \"%" PRIuGRUB_UINT64_T "\" due to priority\n", keyslot.idx);
+ continue;
+ }
+
+ grub_dprintf ("luks2", "Trying keyslot \"%" PRIuGRUB_UINT64_T "\"\n", keyslot.idx);
+
+ /* Sector size should be one of 512, 1024, 2048, or 4096. */
+ if (!(segment.sector_size == 512 || segment.sector_size == 1024 ||
+ segment.sector_size == 2048 || segment.sector_size == 4096))
+ {
+ grub_dprintf ("luks2", "Segment \"%" PRIuGRUB_UINT64_T "\" sector"
+ " size %" PRIuGRUB_UINT64_T " is not one of"
+ " 512, 1024, 2048, or 4096\n",
+ segment.idx, segment.sector_size);
+ continue;
+ }
+
+ /* Set up disk according to keyslot's segment. */
+ crypt->offset_sectors = grub_divmod64 (segment.offset, segment.sector_size, NULL);
+ crypt->log_sector_size = grub_log2ull (segment.sector_size);
+ /* Set to the source disk/partition size, which is the maximum we allow. */
+ max_crypt_sectors = grub_disk_native_sectors (source);
+ max_crypt_sectors = grub_convert_sector (max_crypt_sectors, GRUB_DISK_SECTOR_BITS,
+ crypt->log_sector_size);
+
+ if (max_crypt_sectors < crypt->offset_sectors)
+ {
+ grub_dprintf ("luks2", "Segment \"%" PRIuGRUB_UINT64_T "\" has offset"
+ " %" PRIuGRUB_UINT64_T " which is greater than"
+ " source disk size %" PRIuGRUB_UINT64_T ","
+ " skipping\n", segment.idx, crypt->offset_sectors,
+ max_crypt_sectors);
+ continue;
+ }
+
+ if (grub_strcmp (segment.size, "dynamic") == 0)
+ crypt->total_sectors = max_crypt_sectors - crypt->offset_sectors;
+ else
+ {
+ grub_errno = GRUB_ERR_NONE;
+
+ /* Convert segment.size to sectors, rounding up to nearest sector */
+ crypt->total_sectors = grub_strtoull (segment.size, NULL, 10);
+
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ crypt->total_sectors = ALIGN_UP (crypt->total_sectors,
+ 1 << crypt->log_sector_size);
+ crypt->total_sectors >>= crypt->log_sector_size;
+ }
+ else if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ {
+ grub_dprintf ("luks2", "Segment \"%" PRIuGRUB_UINT64_T "\" size"
+ " \"%s\" is not a parsable number,"
+ " skipping keyslot\n",
+ segment.idx, segment.size);
+ continue;
+ }
+ else if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ {
+ /*
+ * There was an overflow in parsing segment.size, so disk must
+ * be very large or the string is incorrect.
+ *
+ * TODO: Allow reading of at least up max_crypt_sectors. Really,
+ * its very unlikely one would be booting from such a large drive
+ * anyway. Use another smaller LUKS2 boot device.
+ */
+ grub_dprintf ("luks2", "Segment \"%" PRIuGRUB_UINT64_T "\" size"
+ " %s overflowed 64-bit unsigned integer,"
+ " skipping keyslot\n", segment.idx, segment.size);
+ continue;
+ }
+ }
+
+ if (crypt->total_sectors == 0)
+ {
+ grub_dprintf ("luks2", "Segment \"%" PRIuGRUB_UINT64_T "\" has zero"
+ " sectors, skipping\n", segment.idx);
+ continue;
+ }
+ else if (max_crypt_sectors < (crypt->offset_sectors + crypt->total_sectors))
+ {
+ grub_dprintf ("luks2", "Segment \"%" PRIuGRUB_UINT64_T "\" has last"
+ " data position greater than source disk size,"
+ " the end of the crypto device will be"
+ " inaccessible\n", segment.idx);
+
+ /* Allow decryption up to the end of the source disk. */
+ crypt->total_sectors = max_crypt_sectors - crypt->offset_sectors;
+ }
+
+ ret = luks2_decrypt_key (candidate_key, source, crypt, &keyslot,
+ (const grub_uint8_t *) passphrase, grub_strlen (passphrase));
+ if (ret)
+ {
+ grub_dprintf ("luks2", "Decryption with keyslot \"%" PRIuGRUB_UINT64_T "\" failed: %s\n",
+ keyslot.idx, grub_errmsg);
+ continue;
+ }
+
+ ret = luks2_verify_key (&digest, candidate_key, keyslot.key_size);
+ if (ret)
+ {
+ grub_dprintf ("luks2", "Could not open keyslot \"%" PRIuGRUB_UINT64_T "\": %s\n",
+ keyslot.idx, grub_errmsg);
+ continue;
+ }
+
+ grub_snprintf (indexstr, sizeof (indexstr) - 1, "%" PRIuGRUB_UINT64_T, keyslot.idx);
+ /*
+ * TRANSLATORS: It's a cryptographic key slot: one element of an array
+ * where each element is either empty or holds a key.
+ */
+ grub_printf_ (N_("Slot \"%s\" opened\n"), indexstr);
+
+ candidate_key_len = keyslot.key_size;
+ break;
+ }
+ if (candidate_key_len == 0)
+ {
+ ret = grub_error (GRUB_ERR_ACCESS_DENIED, "Invalid passphrase");
+ goto err;
+ }
+
+ /* Set up disk cipher. */
+ grub_strncpy (cipher, segment.encryption, sizeof (cipher));
+ ptr = grub_memchr (cipher, '-', grub_strlen (cipher));
+ if (!ptr)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid encryption");
+ *ptr = '\0';
+
+ ret = grub_cryptodisk_setcipher (crypt, cipher, ptr + 1);
+ if (ret)
+ goto err;
+
+ /* Set the master key. */
+ gcry_ret = grub_cryptodisk_setkey (crypt, candidate_key, candidate_key_len);
+ if (gcry_ret)
+ {
+ ret = grub_crypto_gcry_error (gcry_ret);
+ goto err;
+ }
+
+ err:
+ grub_free (part);
+ grub_free (json_header);
+ grub_json_free (json);
+ return ret;
+}
+
+static struct grub_cryptodisk_dev luks2_crypto = {
+ .scan = luks2_scan,
+ .recover_key = luks2_recover_key
+};
+
+GRUB_MOD_INIT (luks2)
+{
+ grub_cryptodisk_dev_register (&luks2_crypto);
+}
+
+GRUB_MOD_FINI (luks2)
+{
+ grub_cryptodisk_dev_unregister (&luks2_crypto);
+}
diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c
new file mode 100644
index 0000000..8257159
--- /dev/null
+++ b/grub-core/disk/lvm.c
@@ -0,0 +1,1091 @@
+/* lvm.c - module to read Logical Volumes. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/lvm.h>
+#include <grub/partition.h>
+#include <grub/i18n.h>
+#include <grub/safemath.h>
+
+#ifdef GRUB_UTIL
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct cache_lv
+{
+ struct grub_diskfilter_lv *lv;
+ char *cache_pool;
+ char *origin;
+ struct cache_lv *next;
+};
+
+
+/* Go the string STR and return the number after STR. *P will point
+ at the number. In case STR is not found, *P will be NULL and the
+ return value will be 0. */
+static grub_uint64_t
+grub_lvm_getvalue (const char ** const p, const char *str)
+{
+ *p = grub_strstr (*p, str);
+ if (! *p)
+ return 0;
+ *p += grub_strlen (str);
+ return grub_strtoull (*p, p, 10);
+}
+
+#if 0
+static int
+grub_lvm_checkvalue (char **p, char *str, char *tmpl)
+{
+ int tmpllen = grub_strlen (tmpl);
+ *p = grub_strstr (*p, str);
+ if (! *p)
+ return 0;
+ *p += grub_strlen (str);
+ if (**p != '"')
+ return 0;
+ return (grub_memcmp (*p + 1, tmpl, tmpllen) == 0 && (*p)[tmpllen + 1] == '"');
+}
+#endif
+
+static int
+grub_lvm_check_flag (const char *p, const char *str, const char *flag)
+{
+ grub_size_t len_str = grub_strlen (str), len_flag = grub_strlen (flag);
+ while (1)
+ {
+ const char *q;
+ p = grub_strstr (p, str);
+ if (! p)
+ return 0;
+ p += len_str;
+ if (grub_memcmp (p, " = [", sizeof (" = [") - 1) != 0)
+ continue;
+ q = p + sizeof (" = [") - 1;
+ while (1)
+ {
+ while (grub_isspace (*q))
+ q++;
+ if (*q != '"')
+ return 0;
+ q++;
+ if (grub_memcmp (q, flag, len_flag) == 0 && q[len_flag] == '"')
+ return 1;
+ while (*q != '"')
+ q++;
+ q++;
+ if (*q == ']')
+ return 0;
+ q++;
+ }
+ }
+}
+
+static void
+grub_lvm_free_cache_lvs (struct cache_lv *cache_lvs)
+{
+ struct cache_lv *cache;
+
+ while ((cache = cache_lvs))
+ {
+ cache_lvs = cache_lvs->next;
+
+ if (cache->lv)
+ {
+ unsigned int i;
+
+ for (i = 0; i < cache->lv->segment_count; ++i)
+ if (cache->lv->segments)
+ grub_free (cache->lv->segments[i].nodes);
+ grub_free (cache->lv->segments);
+ grub_free (cache->lv->fullname);
+ grub_free (cache->lv->idname);
+ grub_free (cache->lv->name);
+ }
+ grub_free (cache->lv);
+ grub_free (cache->origin);
+ grub_free (cache->cache_pool);
+ grub_free (cache);
+ }
+}
+
+static struct grub_diskfilter_vg *
+grub_lvm_detect (grub_disk_t disk,
+ struct grub_diskfilter_pv_id *id,
+ grub_disk_addr_t *start_sector)
+{
+ grub_err_t err;
+ grub_uint64_t mda_offset, mda_size;
+ grub_size_t ptr;
+ char buf[GRUB_LVM_LABEL_SIZE];
+ char vg_id[GRUB_LVM_ID_STRLEN+1];
+ char pv_id[GRUB_LVM_ID_STRLEN+1];
+ char *metadatabuf, *mda_end, *vgname;
+ const char *p, *q;
+ struct grub_lvm_label_header *lh = (struct grub_lvm_label_header *) buf;
+ struct grub_lvm_pv_header *pvh;
+ struct grub_lvm_disk_locn *dlocn;
+ struct grub_lvm_mda_header *mdah;
+ struct grub_lvm_raw_locn *rlocn;
+ unsigned int i, j;
+ grub_size_t vgname_len;
+ struct grub_diskfilter_vg *vg;
+ struct grub_diskfilter_pv *pv;
+
+ /* Search for label. */
+ for (i = 0; i < GRUB_LVM_LABEL_SCAN_SECTORS; i++)
+ {
+ err = grub_disk_read (disk, i, 0, sizeof(buf), buf);
+ if (err)
+ goto fail;
+
+ if ((! grub_strncmp ((char *)lh->id, GRUB_LVM_LABEL_ID,
+ sizeof (lh->id)))
+ && (! grub_strncmp ((char *)lh->type, GRUB_LVM_LVM2_LABEL,
+ sizeof (lh->type))))
+ break;
+ }
+
+ /* Return if we didn't find a label. */
+ if (i == GRUB_LVM_LABEL_SCAN_SECTORS)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("no LVM signature found");
+#endif
+ goto fail;
+ }
+
+ /*
+ * We read a grub_lvm_pv_header and then 2 grub_lvm_disk_locns that
+ * immediately follow the PV header. Make sure we have space for both.
+ */
+ if (grub_le_to_cpu32 (lh->offset_xl) >=
+ GRUB_LVM_LABEL_SIZE - sizeof (struct grub_lvm_pv_header) -
+ 2 * sizeof (struct grub_lvm_disk_locn))
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("LVM PV header/disk locations are beyond the end of the block");
+#endif
+ goto fail;
+ }
+
+ pvh = (struct grub_lvm_pv_header *) (buf + grub_le_to_cpu32(lh->offset_xl));
+
+ for (i = 0, j = 0; i < GRUB_LVM_ID_LEN; i++)
+ {
+ pv_id[j++] = pvh->pv_uuid[i];
+ if ((i != 1) && (i != 29) && (i % 4 == 1))
+ pv_id[j++] = '-';
+ }
+ pv_id[j] = '\0';
+
+ dlocn = pvh->disk_areas_xl;
+
+ dlocn++;
+ /* Is it possible to have multiple data/metadata areas? I haven't
+ seen devices that have it. */
+ if (dlocn->offset)
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "we don't support multiple LVM data areas");
+
+#ifdef GRUB_UTIL
+ grub_util_info ("we don't support multiple LVM data areas");
+#endif
+ goto fail;
+ }
+
+ dlocn++;
+ mda_offset = grub_le_to_cpu64 (dlocn->offset);
+ mda_size = grub_le_to_cpu64 (dlocn->size);
+
+ /* It's possible to have multiple copies of metadata areas, we just use the
+ first one. */
+
+ /* Allocate buffer space for the circular worst-case scenario. */
+ metadatabuf = grub_calloc (2, mda_size);
+ if (! metadatabuf)
+ goto fail;
+
+ err = grub_disk_read (disk, 0, mda_offset, mda_size, metadatabuf);
+ if (err)
+ goto fail2;
+
+ mdah = (struct grub_lvm_mda_header *) metadatabuf;
+ if ((grub_strncmp ((char *)mdah->magic, GRUB_LVM_FMTT_MAGIC,
+ sizeof (mdah->magic)))
+ || (grub_le_to_cpu32 (mdah->version) != GRUB_LVM_FMTT_VERSION))
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unknown LVM metadata header");
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown LVM metadata header");
+#endif
+ goto fail2;
+ }
+
+ rlocn = mdah->raw_locns;
+ if (grub_le_to_cpu64 (rlocn->offset) >= grub_le_to_cpu64 (mda_size))
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("metadata offset is beyond end of metadata area");
+#endif
+ goto fail2;
+ }
+
+ if (grub_le_to_cpu64 (rlocn->offset) + grub_le_to_cpu64 (rlocn->size) >
+ grub_le_to_cpu64 (mdah->size))
+ {
+ if (2 * mda_size < GRUB_LVM_MDA_HEADER_SIZE ||
+ (grub_le_to_cpu64 (rlocn->offset) + grub_le_to_cpu64 (rlocn->size) -
+ grub_le_to_cpu64 (mdah->size) > mda_size - GRUB_LVM_MDA_HEADER_SIZE))
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("cannot copy metadata wrap in circular buffer");
+#endif
+ goto fail2;
+ }
+
+ /* Metadata is circular. Copy the wrap in place. */
+ grub_memcpy (metadatabuf + mda_size,
+ metadatabuf + GRUB_LVM_MDA_HEADER_SIZE,
+ grub_le_to_cpu64 (rlocn->offset) +
+ grub_le_to_cpu64 (rlocn->size) -
+ grub_le_to_cpu64 (mdah->size));
+ }
+
+ if (grub_add ((grub_size_t)metadatabuf,
+ (grub_size_t)grub_le_to_cpu64 (rlocn->offset),
+ &ptr))
+ {
+ error_parsing_metadata:
+#ifdef GRUB_UTIL
+ grub_util_info ("error parsing metadata");
+#endif
+ goto fail2;
+ }
+
+ p = q = (char *)ptr;
+
+ if (grub_add ((grub_size_t)metadatabuf, (grub_size_t)mda_size, &ptr))
+ goto error_parsing_metadata;
+
+ mda_end = (char *)ptr;
+
+ while (*q != ' ' && q < mda_end)
+ q++;
+
+ if (q == mda_end)
+ goto error_parsing_metadata;
+
+ vgname_len = q - p;
+ vgname = grub_malloc (vgname_len + 1);
+ if (!vgname)
+ goto fail2;
+
+ grub_memcpy (vgname, p, vgname_len);
+ vgname[vgname_len] = '\0';
+
+ p = grub_strstr (q, "id = \"");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("couldn't find ID");
+#endif
+ goto fail3;
+ }
+ p += sizeof ("id = \"") - 1;
+ grub_memcpy (vg_id, p, GRUB_LVM_ID_STRLEN);
+ vg_id[GRUB_LVM_ID_STRLEN] = '\0';
+
+ vg = grub_diskfilter_get_vg_by_uuid (GRUB_LVM_ID_STRLEN, vg_id);
+
+ if (! vg)
+ {
+ struct cache_lv *cache_lvs = NULL;
+
+ /* First time we see this volume group. We've to create the
+ whole volume group structure. */
+ vg = grub_malloc (sizeof (*vg));
+ if (! vg)
+ goto fail3;
+ vg->name = vgname;
+ vg->uuid = grub_malloc (GRUB_LVM_ID_STRLEN);
+ if (! vg->uuid)
+ goto fail3;
+ grub_memcpy (vg->uuid, vg_id, GRUB_LVM_ID_STRLEN);
+ vg->uuid_len = GRUB_LVM_ID_STRLEN;
+
+ vg->extent_size = grub_lvm_getvalue (&p, "extent_size = ");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown extent size");
+#endif
+ goto fail4;
+ }
+
+ vg->lvs = NULL;
+ vg->pvs = NULL;
+
+ p = grub_strstr (p, "physical_volumes {");
+ if (p)
+ {
+ p += sizeof ("physical_volumes {") - 1;
+
+ /* Add all the pvs to the volume group. */
+ while (1)
+ {
+ grub_ssize_t s;
+ while (grub_isspace (*p) && p < mda_end)
+ p++;
+
+ if (p == mda_end)
+ goto fail4;
+
+ if (*p == '}')
+ break;
+
+ pv = grub_zalloc (sizeof (*pv));
+ q = p;
+ while (*q != ' ' && q < mda_end)
+ q++;
+
+ if (q == mda_end)
+ goto pvs_fail_noname;
+
+ s = q - p;
+ pv->name = grub_malloc (s + 1);
+ grub_memcpy (pv->name, p, s);
+ pv->name[s] = '\0';
+
+ p = grub_strstr (p, "id = \"");
+ if (p == NULL)
+ goto pvs_fail;
+ p += sizeof("id = \"") - 1;
+
+ pv->id.uuid = grub_malloc (GRUB_LVM_ID_STRLEN);
+ if (!pv->id.uuid)
+ goto pvs_fail;
+ grub_memcpy (pv->id.uuid, p, GRUB_LVM_ID_STRLEN);
+ pv->id.uuidlen = GRUB_LVM_ID_STRLEN;
+
+ pv->start_sector = grub_lvm_getvalue (&p, "pe_start = ");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown pe_start");
+#endif
+ goto pvs_fail;
+ }
+
+ p = grub_strchr (p, '}');
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("error parsing pe_start");
+#endif
+ goto pvs_fail;
+ }
+ p++;
+
+ pv->disk = NULL;
+ pv->next = vg->pvs;
+ vg->pvs = pv;
+
+ continue;
+ pvs_fail:
+ grub_free (pv->name);
+ pvs_fail_noname:
+ grub_free (pv);
+ goto fail4;
+ }
+ }
+ else
+ goto fail4;
+
+ p = grub_strstr (p, "logical_volumes {");
+ if (p)
+ {
+ p += sizeof ("logical_volumes {") - 1;
+
+ /* And add all the lvs to the volume group. */
+ while (1)
+ {
+ grub_ssize_t s;
+ int skip_lv = 0;
+ struct grub_diskfilter_lv *lv;
+ struct grub_diskfilter_segment *seg;
+ int is_pvmove;
+
+ while (grub_isspace (*p) && p < mda_end)
+ p++;
+
+ if (p == mda_end)
+ goto fail4;
+
+ if (*p == '}')
+ break;
+
+ lv = grub_zalloc (sizeof (*lv));
+
+ q = p;
+ while (*q != ' ' && q < mda_end)
+ q++;
+
+ if (q == mda_end)
+ goto lvs_fail;
+
+ s = q - p;
+ lv->name = grub_strndup (p, s);
+ if (!lv->name)
+ goto lvs_fail;
+
+ {
+ const char *iptr;
+ char *optr;
+
+ /*
+ * This is kind of hard to read with our safe (but rather
+ * baroque) math primatives, but it boils down to:
+ *
+ * sz0 = vgname_len * 2 + 1 +
+ * s * 2 + 1 +
+ * sizeof ("lvm/") - 1;
+ */
+ grub_size_t sz0 = vgname_len, sz1 = s;
+
+ if (grub_mul (sz0, 2, &sz0) ||
+ grub_add (sz0, 1, &sz0) ||
+ grub_mul (sz1, 2, &sz1) ||
+ grub_add (sz1, 1, &sz1) ||
+ grub_add (sz0, sz1, &sz0) ||
+ grub_add (sz0, sizeof ("lvm/") - 1, &sz0))
+ goto lvs_fail;
+
+ lv->fullname = grub_malloc (sz0);
+ if (!lv->fullname)
+ goto lvs_fail;
+
+ grub_memcpy (lv->fullname, "lvm/", sizeof ("lvm/") - 1);
+ optr = lv->fullname + sizeof ("lvm/") - 1;
+ for (iptr = vgname; iptr < vgname + vgname_len; iptr++)
+ {
+ *optr++ = *iptr;
+ if (*iptr == '-')
+ *optr++ = '-';
+ }
+ *optr++ = '-';
+ for (iptr = p; iptr < p + s; iptr++)
+ {
+ *optr++ = *iptr;
+ if (*iptr == '-')
+ *optr++ = '-';
+ }
+ *optr++ = 0;
+ lv->idname = grub_malloc (sizeof ("lvmid/")
+ + 2 * GRUB_LVM_ID_STRLEN + 1);
+ if (!lv->idname)
+ goto lvs_fail;
+ grub_memcpy (lv->idname, "lvmid/",
+ sizeof ("lvmid/") - 1);
+ grub_memcpy (lv->idname + sizeof ("lvmid/") - 1,
+ vg_id, GRUB_LVM_ID_STRLEN);
+ lv->idname[sizeof ("lvmid/") - 1 + GRUB_LVM_ID_STRLEN] = '/';
+
+ p = grub_strstr (q, "id = \"");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("couldn't find ID");
+#endif
+ goto lvs_fail;
+ }
+ p += sizeof ("id = \"") - 1;
+ grub_memcpy (lv->idname + sizeof ("lvmid/") - 1
+ + GRUB_LVM_ID_STRLEN + 1,
+ p, GRUB_LVM_ID_STRLEN);
+ lv->idname[sizeof ("lvmid/") - 1 + 2 * GRUB_LVM_ID_STRLEN + 1] = '\0';
+ }
+
+ lv->size = 0;
+
+ lv->visible = grub_lvm_check_flag (p, "status", "VISIBLE");
+ is_pvmove = grub_lvm_check_flag (p, "status", "PVMOVE");
+
+ lv->segment_count = grub_lvm_getvalue (&p, "segment_count = ");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown segment_count");
+#endif
+ goto lvs_fail;
+ }
+ lv->segments = grub_calloc (lv->segment_count, sizeof (*seg));
+ seg = lv->segments;
+
+ for (i = 0; i < lv->segment_count; i++)
+ {
+
+ p = grub_strstr (p, "segment");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown segment");
+#endif
+ goto lvs_segment_fail;
+ }
+
+ seg->start_extent = grub_lvm_getvalue (&p, "start_extent = ");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown start_extent");
+#endif
+ goto lvs_segment_fail;
+ }
+ seg->extent_count = grub_lvm_getvalue (&p, "extent_count = ");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown extent_count");
+#endif
+ goto lvs_segment_fail;
+ }
+
+ p = grub_strstr (p, "type = \"");
+ if (p == NULL)
+ goto lvs_segment_fail;
+ p += sizeof("type = \"") - 1;
+
+ lv->size += seg->extent_count * vg->extent_size;
+
+ if (grub_memcmp (p, "striped\"",
+ sizeof ("striped\"") - 1) == 0)
+ {
+ struct grub_diskfilter_node *stripe;
+
+ seg->type = GRUB_DISKFILTER_STRIPED;
+ seg->node_count = grub_lvm_getvalue (&p, "stripe_count = ");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown stripe_count");
+#endif
+ goto lvs_segment_fail;
+ }
+
+ if (seg->node_count != 1)
+ {
+ seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown stripe_size");
+#endif
+ goto lvs_segment_fail;
+ }
+ }
+
+ seg->nodes = grub_calloc (seg->node_count,
+ sizeof (*stripe));
+ stripe = seg->nodes;
+
+ p = grub_strstr (p, "stripes = [");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown stripes");
+#endif
+ goto lvs_segment_fail2;
+ }
+ p += sizeof("stripes = [") - 1;
+
+ for (j = 0; j < seg->node_count; j++)
+ {
+ p = grub_strchr (p, '"');
+ if (p == NULL)
+ goto lvs_segment_fail2;
+ q = ++p;
+ while (q < mda_end && *q != '"')
+ q++;
+
+ if (q == mda_end)
+ goto lvs_segment_fail2;
+
+ s = q - p;
+
+ stripe->name = grub_malloc (s + 1);
+ if (stripe->name == NULL)
+ goto lvs_segment_fail2;
+
+ grub_memcpy (stripe->name, p, s);
+ stripe->name[s] = '\0';
+
+ p = q + 1;
+
+ stripe->start = grub_lvm_getvalue (&p, ",")
+ * vg->extent_size;
+ if (p == NULL)
+ {
+ grub_free (stripe->name);
+ goto lvs_segment_fail2;
+ }
+
+ stripe++;
+ }
+ }
+ else if (grub_memcmp (p, "mirror\"", sizeof ("mirror\"") - 1)
+ == 0)
+ {
+ seg->type = GRUB_DISKFILTER_MIRROR;
+ seg->node_count = grub_lvm_getvalue (&p, "mirror_count = ");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown mirror_count");
+#endif
+ goto lvs_segment_fail;
+ }
+
+ seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
+ * seg->node_count);
+
+ p = grub_strstr (p, "mirrors = [");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown mirrors");
+#endif
+ goto lvs_segment_fail2;
+ }
+ p += sizeof("mirrors = [") - 1;
+
+ for (j = 0; j < seg->node_count; j++)
+ {
+ char *lvname;
+
+ p = grub_strchr (p, '"');
+ if (p == NULL)
+ goto lvs_segment_fail2;
+ q = ++p;
+ while (q < mda_end && *q != '"')
+ q++;
+
+ if (q == mda_end)
+ goto lvs_segment_fail2;
+
+ s = q - p;
+
+ lvname = grub_malloc (s + 1);
+ if (lvname == NULL)
+ goto lvs_segment_fail2;
+
+ grub_memcpy (lvname, p, s);
+ lvname[s] = '\0';
+ seg->nodes[j].name = lvname;
+ p = q + 1;
+ }
+ /* Only first (original) is ok with in progress pvmove. */
+ 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')
+ || 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;
+ break;
+ case '5':
+ seg->type = GRUB_DISKFILTER_RAID5;
+ seg->layout = GRUB_RAID_LAYOUT_LEFT_SYMMETRIC;
+ break;
+ case '6':
+ seg->type = GRUB_DISKFILTER_RAID6;
+ seg->layout = (GRUB_RAID_LAYOUT_RIGHT_ASYMMETRIC
+ | GRUB_RAID_LAYOUT_MUL_FROM_POS);
+ break;
+ }
+ seg->node_count = grub_lvm_getvalue (&p, "device_count = ");
+
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown device_count");
+#endif
+ goto lvs_segment_fail;
+ }
+
+ 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");
+#endif
+ goto lvs_segment_fail;
+ }
+ }
+
+ seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
+ * seg->node_count);
+
+ p = grub_strstr (p, "raids = [");
+ if (p == NULL)
+ {
+#ifdef GRUB_UTIL
+ grub_util_info ("unknown raids");
+#endif
+ goto lvs_segment_fail2;
+ }
+ p += sizeof("raids = [") - 1;
+
+ for (j = 0; j < seg->node_count; j++)
+ {
+ char *lvname;
+
+ p = grub_strchr (p, '"');
+ p = p ? grub_strchr (p + 1, '"') : 0;
+ p = p ? grub_strchr (p + 1, '"') : 0;
+ if (p == NULL)
+ goto lvs_segment_fail2;
+ q = ++p;
+ while (*q != '"')
+ q++;
+
+ s = q - p;
+
+ lvname = grub_malloc (s + 1);
+ if (lvname == NULL)
+ goto lvs_segment_fail2;
+
+ grub_memcpy (lvname, p, s);
+ lvname[s] = '\0';
+ seg->nodes[j].name = lvname;
+ p = q + 1;
+ }
+ if (seg->type == GRUB_DISKFILTER_RAID4)
+ {
+ char *tmp;
+ tmp = seg->nodes[0].name;
+ grub_memmove (seg->nodes, seg->nodes + 1,
+ sizeof (seg->nodes[0])
+ * (seg->node_count - 1));
+ seg->nodes[seg->node_count - 1].name = tmp;
+ }
+ }
+ else if (grub_memcmp (p, "cache\"",
+ sizeof ("cache\"") - 1) == 0)
+ {
+ struct cache_lv *cache = NULL;
+
+ char *p2, *p3;
+ grub_size_t sz;
+
+ cache = grub_zalloc (sizeof (*cache));
+ if (!cache)
+ goto cache_lv_fail;
+ cache->lv = grub_zalloc (sizeof (*cache->lv));
+ if (!cache->lv)
+ goto cache_lv_fail;
+ grub_memcpy (cache->lv, lv, sizeof (*cache->lv));
+
+ if (lv->fullname)
+ {
+ cache->lv->fullname = grub_strdup (lv->fullname);
+ if (!cache->lv->fullname)
+ goto cache_lv_fail;
+ }
+ if (lv->idname)
+ {
+ cache->lv->idname = grub_strdup (lv->idname);
+ if (!cache->lv->idname)
+ goto cache_lv_fail;
+ }
+ if (lv->name)
+ {
+ cache->lv->name = grub_strdup (lv->name);
+ if (!cache->lv->name)
+ goto cache_lv_fail;
+ }
+
+ skip_lv = 1;
+
+ p2 = grub_strstr (p, "cache_pool = \"");
+ if (!p2)
+ goto cache_lv_fail;
+
+ p2 = grub_strchr (p2, '"');
+ if (!p2)
+ goto cache_lv_fail;
+
+ p3 = ++p2;
+ if (p3 == mda_end)
+ goto cache_lv_fail;
+ p3 = grub_strchr (p3, '"');
+ if (!p3)
+ goto cache_lv_fail;
+
+ sz = p3 - p2;
+
+ cache->cache_pool = grub_malloc (sz + 1);
+ if (!cache->cache_pool)
+ goto cache_lv_fail;
+ grub_memcpy (cache->cache_pool, p2, sz);
+ cache->cache_pool[sz] = '\0';
+
+ p2 = grub_strstr (p, "origin = \"");
+ if (!p2)
+ goto cache_lv_fail;
+
+ p2 = grub_strchr (p2, '"');
+ if (!p2)
+ goto cache_lv_fail;
+
+ p3 = ++p2;
+ if (p3 == mda_end)
+ goto cache_lv_fail;
+ p3 = grub_strchr (p3, '"');
+ if (!p3)
+ goto cache_lv_fail;
+
+ sz = p3 - p2;
+
+ cache->origin = grub_malloc (sz + 1);
+ if (!cache->origin)
+ goto cache_lv_fail;
+ grub_memcpy (cache->origin, p2, sz);
+ cache->origin[sz] = '\0';
+
+ cache->next = cache_lvs;
+ cache_lvs = cache;
+ break;
+
+ cache_lv_fail:
+ if (cache)
+ {
+ grub_free (cache->origin);
+ grub_free (cache->cache_pool);
+ if (cache->lv)
+ {
+ grub_free (cache->lv->fullname);
+ grub_free (cache->lv->idname);
+ grub_free (cache->lv->name);
+ }
+ grub_free (cache->lv);
+ grub_free (cache);
+ }
+ grub_lvm_free_cache_lvs (cache_lvs);
+ goto fail4;
+ }
+ else
+ {
+#ifdef GRUB_UTIL
+ char *p2;
+ p2 = grub_strchr (p, '"');
+ if (p2)
+ *p2 = 0;
+ grub_util_info ("unknown LVM type %s", p);
+ if (p2)
+ *p2 ='"';
+#endif
+ /* Found a non-supported type, give up and move on. */
+ skip_lv = 1;
+ break;
+ }
+
+ seg++;
+
+ continue;
+ lvs_segment_fail2:
+ grub_free (seg->nodes);
+ lvs_segment_fail:
+ goto fail4;
+ }
+
+ if (p != NULL)
+ p = grub_strchr (p, '}');
+ if (p == NULL)
+ goto lvs_fail;
+ p += 3;
+
+ if (skip_lv)
+ {
+ grub_free (lv->name);
+ grub_free (lv);
+ continue;
+ }
+
+ lv->vg = vg;
+ lv->next = vg->lvs;
+ vg->lvs = lv;
+
+ continue;
+ lvs_fail:
+ grub_free (lv->name);
+ grub_free (lv);
+ goto fail4;
+ }
+ }
+
+ /* Match lvs. */
+ {
+ struct grub_diskfilter_lv *lv1;
+ struct grub_diskfilter_lv *lv2;
+ for (lv1 = vg->lvs; lv1; lv1 = lv1->next)
+ for (i = 0; i < lv1->segment_count; i++)
+ for (j = 0; j < lv1->segments[i].node_count; j++)
+ {
+ if (vg->pvs)
+ for (pv = vg->pvs; pv; pv = pv->next)
+ {
+ if (! grub_strcmp (pv->name,
+ lv1->segments[i].nodes[j].name))
+ {
+ lv1->segments[i].nodes[j].pv = pv;
+ break;
+ }
+ }
+ if (lv1->segments[i].nodes[j].pv == NULL)
+ for (lv2 = vg->lvs; lv2; lv2 = lv2->next)
+ {
+ if (lv1 == lv2)
+ continue;
+ if (grub_strcmp (lv2->name,
+ lv1->segments[i].nodes[j].name) == 0)
+ lv1->segments[i].nodes[j].lv = lv2;
+ }
+ }
+
+ }
+
+ {
+ struct cache_lv *cache;
+
+ for (cache = cache_lvs; cache; cache = cache->next)
+ {
+ struct grub_diskfilter_lv *lv;
+
+ for (lv = vg->lvs; lv; lv = lv->next)
+ if (grub_strcmp (lv->name, cache->origin) == 0)
+ break;
+ if (lv)
+ {
+ cache->lv->segments = grub_calloc (lv->segment_count, sizeof (*lv->segments));
+ if (!cache->lv->segments)
+ {
+ grub_lvm_free_cache_lvs (cache_lvs);
+ goto fail4;
+ }
+ grub_memcpy (cache->lv->segments, lv->segments, lv->segment_count * sizeof (*lv->segments));
+
+ for (i = 0; i < lv->segment_count; ++i)
+ {
+ struct grub_diskfilter_node *nodes = lv->segments[i].nodes;
+ grub_size_t node_count = lv->segments[i].node_count;
+
+ cache->lv->segments[i].nodes = grub_calloc (node_count, sizeof (*nodes));
+ if (!cache->lv->segments[i].nodes)
+ {
+ for (j = 0; j < i; ++j)
+ grub_free (cache->lv->segments[j].nodes);
+ grub_free (cache->lv->segments);
+ cache->lv->segments = NULL;
+ grub_lvm_free_cache_lvs (cache_lvs);
+ goto fail4;
+ }
+ grub_memcpy (cache->lv->segments[i].nodes, nodes, node_count * sizeof (*nodes));
+ }
+
+ if (cache->lv->segments)
+ {
+ cache->lv->segment_count = lv->segment_count;
+ cache->lv->vg = vg;
+ cache->lv->next = vg->lvs;
+ vg->lvs = cache->lv;
+ cache->lv = NULL;
+ }
+ }
+ }
+ }
+
+ grub_lvm_free_cache_lvs (cache_lvs);
+ if (grub_diskfilter_vg_register (vg))
+ goto fail4;
+ }
+ else
+ {
+ grub_free (vgname);
+ }
+
+ id->uuid = grub_malloc (GRUB_LVM_ID_STRLEN);
+ if (!id->uuid)
+ goto fail4;
+ grub_memcpy (id->uuid, pv_id, GRUB_LVM_ID_STRLEN);
+ id->uuidlen = GRUB_LVM_ID_STRLEN;
+ grub_free (metadatabuf);
+ *start_sector = -1;
+ return vg;
+
+ /* Failure path. */
+ fail4:
+ grub_free (vg);
+ fail3:
+ grub_free (vgname);
+
+ fail2:
+ grub_free (metadatabuf);
+ fail:
+ return NULL;
+}
+
+
+
+static struct grub_diskfilter grub_lvm_dev = {
+ .name = "lvm",
+ .detect = grub_lvm_detect,
+ .next = 0
+};
+
+GRUB_MOD_INIT (lvm)
+{
+ grub_diskfilter_register_back (&grub_lvm_dev);
+}
+
+GRUB_MOD_FINI (lvm)
+{
+ grub_diskfilter_unregister (&grub_lvm_dev);
+}
diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c
new file mode 100644
index 0000000..38444b0
--- /dev/null
+++ b/grub-core/disk/mdraid1x_linux.c
@@ -0,0 +1,233 @@
+/* mdraid_linux.c - module to handle Linux Software RAID. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/diskfilter.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Linux RAID on disk structures and constants,
+ copied from include/linux/raid/md_p.h. */
+
+#define SB_MAGIC 0xa92b4efc
+
+/*
+ * The version-1 superblock :
+ * All numeric fields are little-endian.
+ *
+ * Total size: 256 bytes plus 2 per device.
+ * 1K allows 384 devices.
+ */
+
+struct grub_raid_super_1x
+{
+ /* Constant array information - 128 bytes. */
+ grub_uint32_t magic; /* MD_SB_MAGIC: 0xa92b4efc - little endian. */
+ grub_uint32_t major_version; /* 1. */
+ grub_uint32_t feature_map; /* Bit 0 set if 'bitmap_offset' is meaningful. */
+ grub_uint32_t pad0; /* Always set to 0 when writing. */
+
+ grub_uint8_t set_uuid[16]; /* User-space generated. */
+ char set_name[32]; /* Set and interpreted by user-space. */
+
+ grub_uint64_t ctime; /* Lo 40 bits are seconds, top 24 are microseconds or 0. */
+ grub_uint32_t level; /* -4 (multipath), -1 (linear), 0,1,4,5. */
+ grub_uint32_t layout; /* only for raid5 and raid10 currently. */
+ grub_uint64_t size; /* Used size of component devices, in 512byte sectors. */
+
+ grub_uint32_t chunksize; /* In 512byte sectors. */
+ grub_uint32_t raid_disks;
+ grub_uint32_t bitmap_offset; /* Sectors after start of superblock that bitmap starts
+ * NOTE: signed, so bitmap can be before superblock
+ * only meaningful of feature_map[0] is set.
+ */
+
+ /* These are only valid with feature bit '4'. */
+ grub_uint32_t new_level; /* New level we are reshaping to. */
+ grub_uint64_t reshape_position; /* Next address in array-space for reshape. */
+ grub_uint32_t delta_disks; /* Change in number of raid_disks. */
+ grub_uint32_t new_layout; /* New layout. */
+ grub_uint32_t new_chunk; /* New chunk size (512byte sectors). */
+ grub_uint8_t pad1[128 - 124]; /* Set to 0 when written. */
+
+ /* Constant this-device information - 64 bytes. */
+ grub_uint64_t data_offset; /* Sector start of data, often 0. */
+ grub_uint64_t data_size; /* Sectors in this device that can be used for data. */
+ grub_uint64_t super_offset; /* Sector start of this superblock. */
+ grub_uint64_t recovery_offset; /* Sectors before this offset (from data_offset) have been recovered. */
+ grub_uint32_t dev_number; /* Permanent identifier of this device - not role in raid. */
+ grub_uint32_t cnt_corrected_read; /* Number of read errors that were corrected by re-writing. */
+ grub_uint8_t device_uuid[16]; /* User-space setable, ignored by kernel. */
+ grub_uint8_t devflags; /* Per-device flags. Only one defined... */
+ grub_uint8_t pad2[64 - 57]; /* Set to 0 when writing. */
+
+ /* Array state information - 64 bytes. */
+ grub_uint64_t utime; /* 40 bits second, 24 btes microseconds. */
+ grub_uint64_t events; /* Incremented when superblock updated. */
+ grub_uint64_t resync_offset; /* Data before this offset (from data_offset) known to be in sync. */
+ grub_uint32_t sb_csum; /* Checksum upto devs[max_dev]. */
+ grub_uint32_t max_dev; /* Size of devs[] array to consider. */
+ grub_uint8_t pad3[64 - 32]; /* Set to 0 when writing. */
+
+ /* Device state information. Indexed by dev_number.
+ * 2 bytes per device.
+ * Note there are no per-device state flags. State information is rolled
+ * into the 'roles' value. If a device is spare or faulty, then it doesn't
+ * have a meaningful role.
+ */
+ grub_uint16_t dev_roles[0]; /* Role in array, or 0xffff for a spare, or 0xfffe for faulty. */
+};
+/* Could be GRUB_PACKED, but since all members in this struct
+ are already appropriately aligned, we can omit this and avoid suboptimal
+ assembly in some cases. */
+
+#define WriteMostly1 1 /* Mask for writemostly flag in above devflags. */
+
+static struct grub_diskfilter_vg *
+grub_mdraid_detect (grub_disk_t disk,
+ struct grub_diskfilter_pv_id *id,
+ grub_disk_addr_t *start_sector)
+{
+ grub_uint64_t size;
+ grub_uint8_t minor_version;
+
+ size = grub_disk_native_sectors (disk);
+
+ /* Check for an 1.x superblock.
+ * It's always aligned to a 4K boundary
+ * and depending on the minor version it can be:
+ * 0: At least 8K, but less than 12K, from end of device
+ * 1: At start of device
+ * 2: 4K from start of device.
+ */
+
+ for (minor_version = 0; minor_version < 3; ++minor_version)
+ {
+ grub_disk_addr_t sector = 0;
+ struct grub_raid_super_1x sb;
+ grub_uint16_t role;
+ grub_uint32_t level;
+ struct grub_diskfilter_vg *array;
+ char *uuid;
+
+ if (size == GRUB_DISK_SIZE_UNKNOWN && minor_version == 0)
+ continue;
+
+ switch (minor_version)
+ {
+ case 0:
+ sector = (size - 8 * 2) & ~(4 * 2 - 1);
+ break;
+ case 1:
+ sector = 0;
+ break;
+ case 2:
+ sector = 4 * 2;
+ break;
+ }
+
+ if (grub_disk_read (disk, sector, 0, sizeof (struct grub_raid_super_1x),
+ &sb))
+ return NULL;
+
+ if (sb.magic != grub_cpu_to_le32_compile_time (SB_MAGIC)
+ || grub_le_to_cpu64 (sb.super_offset) != sector)
+ continue;
+
+ if (sb.major_version != grub_cpu_to_le32_compile_time (1))
+ /* Unsupported version. */
+ return NULL;
+
+ level = grub_le_to_cpu32 (sb.level);
+
+ /* Multipath. */
+ if ((int) level == -4)
+ level = 1;
+
+ if (level != 0 && level != 1 && level != 4 &&
+ level != 5 && level != 6 && level != 10)
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "Unsupported RAID level: %d", sb.level);
+ return NULL;
+ }
+
+ if (grub_le_to_cpu32 (sb.dev_number) >=
+ grub_le_to_cpu32 (sb.max_dev))
+ /* Spares aren't implemented. */
+ return NULL;
+
+ if (grub_disk_read (disk, sector,
+ (char *) (sb.dev_roles + grub_le_to_cpu32 (sb.dev_number))
+ - (char *) &sb,
+ sizeof (role), &role))
+ return NULL;
+
+ if (grub_le_to_cpu16 (role)
+ >= grub_le_to_cpu32 (sb.raid_disks))
+ /* Spares aren't implemented. */
+ return NULL;
+
+ id->uuidlen = 0;
+ id->id = grub_le_to_cpu16 (role);
+
+ uuid = grub_malloc (16);
+ if (!uuid)
+ return NULL;
+
+ grub_memcpy (uuid, sb.set_uuid, 16);
+
+ *start_sector = grub_le_to_cpu64 (sb.data_offset);
+
+ array = grub_diskfilter_make_raid (16, uuid,
+ grub_le_to_cpu32 (sb.raid_disks),
+ sb.set_name,
+ (sb.size)
+ ? grub_le_to_cpu64 (sb.size)
+ : grub_le_to_cpu64 (sb.data_size),
+ grub_le_to_cpu32 (sb.chunksize),
+ grub_le_to_cpu32 (sb.layout),
+ grub_le_to_cpu32 (sb.level));
+
+ return array;
+ }
+
+ /* not 1.x raid. */
+ return NULL;
+}
+
+static struct grub_diskfilter grub_mdraid_dev = {
+ .name = "mdraid1x",
+ .detect = grub_mdraid_detect,
+ .next = 0
+};
+
+GRUB_MOD_INIT (mdraid1x)
+{
+ grub_diskfilter_register_front (&grub_mdraid_dev);
+}
+
+GRUB_MOD_FINI (mdraid1x)
+{
+ grub_diskfilter_unregister (&grub_mdraid_dev);
+}
diff --git a/grub-core/disk/mdraid_linux.c b/grub-core/disk/mdraid_linux.c
new file mode 100644
index 0000000..e40216f
--- /dev/null
+++ b/grub-core/disk/mdraid_linux.c
@@ -0,0 +1,298 @@
+/* mdraid_linux.c - module to handle Linux Software RAID. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/diskfilter.h>
+
+/* Linux RAID on disk structures and constants,
+ copied from include/linux/raid/md_p.h. */
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#ifdef MODE_BIGENDIAN
+#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_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_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)
+#define RESERVED_SECTORS (RESERVED_BYTES / 512)
+
+#define NEW_SIZE_SECTORS(x) ((x & ~(RESERVED_SECTORS - 1)) \
+ - RESERVED_SECTORS)
+
+#define SB_BYTES 4096
+#define SB_WORDS (SB_BYTES / 4)
+#define SB_SECTORS (SB_BYTES / 512)
+
+/*
+ * The following are counted in 32-bit words
+ */
+#define SB_GENERIC_OFFSET 0
+
+#define SB_PERSONALITY_OFFSET 64
+#define SB_DISKS_OFFSET 128
+#define SB_DESCRIPTOR_OFFSET 992
+
+#define SB_GENERIC_CONSTANT_WORDS 32
+#define SB_GENERIC_STATE_WORDS 32
+#define SB_GENERIC_WORDS (SB_GENERIC_CONSTANT_WORDS + \
+ SB_GENERIC_STATE_WORDS)
+
+#define SB_PERSONALITY_WORDS 64
+#define SB_DESCRIPTOR_WORDS 32
+#define SB_DISKS 27
+#define SB_DISKS_WORDS (SB_DISKS * SB_DESCRIPTOR_WORDS)
+
+#define SB_RESERVED_WORDS (1024 \
+ - SB_GENERIC_WORDS \
+ - SB_PERSONALITY_WORDS \
+ - SB_DISKS_WORDS \
+ - SB_DESCRIPTOR_WORDS)
+
+#define SB_EQUAL_WORDS (SB_GENERIC_WORDS \
+ + SB_PERSONALITY_WORDS \
+ + SB_DISKS_WORDS)
+
+/*
+ * Device "operational" state bits
+ */
+#define DISK_FAULTY 0
+#define DISK_ACTIVE 1
+#define DISK_SYNC 2
+#define DISK_REMOVED 3
+
+#define DISK_WRITEMOSTLY 9
+
+#define SB_MAGIC 0xa92b4efc
+
+/*
+ * Superblock state bits
+ */
+#define SB_CLEAN 0
+#define SB_ERRORS 1
+
+#define SB_BITMAP_PRESENT 8
+
+struct grub_raid_disk_09
+{
+ grub_uint32_t number; /* Device number in the entire set. */
+ grub_uint32_t major; /* Device major number. */
+ grub_uint32_t minor; /* Device minor number. */
+ grub_uint32_t raid_disk; /* The role of the device in the raid set. */
+ grub_uint32_t state; /* Operational state. */
+ grub_uint32_t reserved[SB_DESCRIPTOR_WORDS - 5];
+};
+
+struct grub_raid_super_09
+{
+ /*
+ * Constant generic information
+ */
+ grub_uint32_t md_magic; /* MD identifier. */
+ grub_uint32_t major_version; /* Major version. */
+ grub_uint32_t minor_version; /* Minor version. */
+ grub_uint32_t patch_version; /* Patchlevel version. */
+ grub_uint32_t gvalid_words; /* Number of used words in this section. */
+ grub_uint32_t set_uuid0; /* Raid set identifier. */
+ grub_uint32_t ctime; /* Creation time. */
+ grub_uint32_t level; /* Raid personality. */
+ grub_uint32_t size; /* Apparent size of each individual disk. */
+ grub_uint32_t nr_disks; /* Total disks in the raid set. */
+ grub_uint32_t raid_disks; /* Disks in a fully functional raid set. */
+ grub_uint32_t md_minor; /* Preferred MD minor device number. */
+ grub_uint32_t not_persistent; /* Does it have a persistent superblock. */
+ grub_uint32_t set_uuid1; /* Raid set identifier #2. */
+ grub_uint32_t set_uuid2; /* Raid set identifier #3. */
+ grub_uint32_t set_uuid3; /* Raid set identifier #4. */
+ grub_uint32_t gstate_creserved[SB_GENERIC_CONSTANT_WORDS - 16];
+
+ /*
+ * Generic state information
+ */
+ grub_uint32_t utime; /* Superblock update time. */
+ grub_uint32_t state; /* State bits (clean, ...). */
+ grub_uint32_t active_disks; /* Number of currently active disks. */
+ grub_uint32_t working_disks; /* Number of working disks. */
+ grub_uint32_t failed_disks; /* Number of failed disks. */
+ grub_uint32_t spare_disks; /* Number of spare disks. */
+ grub_uint32_t sb_csum; /* Checksum of the whole superblock. */
+ grub_uint64_t events; /* Superblock update count. */
+ grub_uint64_t cp_events; /* Checkpoint update count. */
+ grub_uint32_t recovery_cp; /* Recovery checkpoint sector count. */
+ grub_uint32_t gstate_sreserved[SB_GENERIC_STATE_WORDS - 12];
+
+ /*
+ * Personality information
+ */
+ grub_uint32_t layout; /* The array's physical layout. */
+ grub_uint32_t chunk_size; /* Chunk size in bytes. */
+ grub_uint32_t root_pv; /* LV root PV. */
+ grub_uint32_t root_block; /* LV root block. */
+ grub_uint32_t pstate_reserved[SB_PERSONALITY_WORDS - 4];
+
+ /*
+ * Disks information
+ */
+ struct grub_raid_disk_09 disks[SB_DISKS];
+
+ /*
+ * Reserved
+ */
+ grub_uint32_t reserved[SB_RESERVED_WORDS];
+
+ /*
+ * Active descriptor
+ */
+ struct grub_raid_disk_09 this_disk;
+} GRUB_PACKED;
+
+static struct grub_diskfilter_vg *
+grub_mdraid_detect (grub_disk_t disk,
+ struct grub_diskfilter_pv_id *id,
+ grub_disk_addr_t *start_sector)
+{
+ grub_disk_addr_t sector;
+ grub_uint64_t size;
+ struct grub_raid_super_09 *sb = NULL;
+ grub_uint32_t *uuid;
+ grub_uint32_t level;
+ struct grub_diskfilter_vg *ret;
+
+ /* The sector where the mdraid 0.90 superblock is stored, if available. */
+ size = grub_disk_native_sectors (disk);
+ if (size == GRUB_DISK_SIZE_UNKNOWN)
+ /* not 0.9x raid. */
+ return NULL;
+ sector = NEW_SIZE_SECTORS (size);
+
+ sb = grub_malloc (sizeof (*sb));
+ if (!sb)
+ return NULL;
+
+ if (grub_disk_read (disk, sector, 0, SB_BYTES, sb))
+ goto fail;
+
+ /* Look whether there is a mdraid 0.90 superblock. */
+ if (sb->md_magic != grub_cpu_to_md32_compile_time (SB_MAGIC))
+ /* not 0.9x raid. */
+ goto fail;
+
+ if (sb->major_version != grub_cpu_to_md32_compile_time (0)
+ || sb->minor_version != grub_cpu_to_md32_compile_time (90))
+ /* Unsupported version. */
+ goto fail;
+
+ /* No need for explicit check that sb->size is 0 (unspecified) since
+ 0 >= non-0 is false. */
+ if (((grub_disk_addr_t) grub_md_to_cpu32 (sb->size)) * 2 >= size)
+ goto fail;
+
+ /* FIXME: Check the checksum. */
+
+ level = grub_md_to_cpu32 (sb->level);
+ /* Multipath. */
+ if ((int) level == -4)
+ level = 1;
+
+ if (level != 0 && level != 1 && level != 4 &&
+ level != 5 && level != 6 && level != 10)
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unsupported RAID level: %d", level);
+ goto fail;
+ }
+ if (grub_md_to_cpu32 (sb->this_disk.number) == 0xffff
+ || grub_md_to_cpu32 (sb->this_disk.number) == 0xfffe)
+ /* Spares aren't implemented. */
+ goto fail;
+
+ uuid = grub_malloc (16);
+ if (!uuid)
+ goto fail;
+
+ uuid[0] = grub_swap_bytes32 (sb->set_uuid0);
+ uuid[1] = grub_swap_bytes32 (sb->set_uuid1);
+ uuid[2] = grub_swap_bytes32 (sb->set_uuid2);
+ uuid[3] = grub_swap_bytes32 (sb->set_uuid3);
+
+ *start_sector = 0;
+
+ id->uuidlen = 0;
+ id->id = grub_md_to_cpu32 (sb->this_disk.number);
+
+ char buf[32];
+ grub_snprintf (buf, sizeof (buf), "md%d", grub_md_to_cpu32 (sb->md_minor));
+ ret = grub_diskfilter_make_raid (16, (char *) uuid,
+ grub_md_to_cpu32 (sb->raid_disks), buf,
+ (sb->size) ? ((grub_disk_addr_t)
+ grub_md_to_cpu32 (sb->size)) * 2
+ : sector,
+ grub_md_to_cpu32 (sb->chunk_size) >> 9,
+ grub_md_to_cpu32 (sb->layout),
+ level);
+ grub_free (sb);
+ return ret;
+
+ fail:
+ grub_free (sb);
+ return NULL;
+}
+
+static struct grub_diskfilter grub_mdraid_dev = {
+#ifdef MODE_BIGENDIAN
+ .name = "mdraid09_be",
+#else
+ .name = "mdraid09",
+#endif
+ .detect = grub_mdraid_detect,
+ .next = 0
+};
+
+#ifdef MODE_BIGENDIAN
+GRUB_MOD_INIT (mdraid09_be)
+#else
+GRUB_MOD_INIT (mdraid09)
+#endif
+{
+ grub_diskfilter_register_front (&grub_mdraid_dev);
+}
+
+#ifdef MODE_BIGENDIAN
+GRUB_MOD_FINI (mdraid09_be)
+#else
+GRUB_MOD_FINI (mdraid09)
+#endif
+{
+ grub_diskfilter_unregister (&grub_mdraid_dev);
+}
diff --git a/grub-core/disk/mdraid_linux_be.c b/grub-core/disk/mdraid_linux_be.c
new file mode 100644
index 0000000..539bcf4
--- /dev/null
+++ b/grub-core/disk/mdraid_linux_be.c
@@ -0,0 +1,2 @@
+#define MODE_BIGENDIAN 1
+#include "mdraid_linux.c"
diff --git a/grub-core/disk/memdisk.c b/grub-core/disk/memdisk.c
new file mode 100644
index 0000000..613779c
--- /dev/null
+++ b/grub-core/disk/memdisk.c
@@ -0,0 +1,116 @@
+/* memdisk.c - Access embedded memory disk. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static char *memdisk_addr;
+static grub_off_t memdisk_size = 0;
+
+static int
+grub_memdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ return hook ("memdisk", hook_data);
+}
+
+static grub_err_t
+grub_memdisk_open (const char *name, grub_disk_t disk)
+{
+ if (grub_strcmp (name, "memdisk"))
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a memdisk");
+
+ disk->total_sectors = memdisk_size / GRUB_DISK_SECTOR_SIZE;
+ disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
+ disk->id = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_memdisk_close (grub_disk_t disk __attribute((unused)))
+{
+}
+
+static grub_err_t
+grub_memdisk_read (grub_disk_t disk __attribute((unused)), grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_memcpy (buf, memdisk_addr + (sector << GRUB_DISK_SECTOR_BITS), size << GRUB_DISK_SECTOR_BITS);
+ return 0;
+}
+
+static grub_err_t
+grub_memdisk_write (grub_disk_t disk __attribute((unused)), grub_disk_addr_t sector,
+ grub_size_t size, const char *buf)
+{
+ grub_memcpy (memdisk_addr + (sector << GRUB_DISK_SECTOR_BITS), buf, size << GRUB_DISK_SECTOR_BITS);
+ return 0;
+}
+
+static struct grub_disk_dev grub_memdisk_dev =
+ {
+ .name = "memdisk",
+ .id = GRUB_DISK_DEVICE_MEMDISK_ID,
+ .disk_iterate = grub_memdisk_iterate,
+ .disk_open = grub_memdisk_open,
+ .disk_close = grub_memdisk_close,
+ .disk_read = grub_memdisk_read,
+ .disk_write = grub_memdisk_write,
+ .next = 0
+ };
+
+GRUB_MOD_INIT(memdisk)
+{
+ struct grub_module_header *header;
+ FOR_MODULES (header)
+ if (header->type == OBJ_TYPE_MEMDISK)
+ {
+ char *memdisk_orig_addr;
+ memdisk_orig_addr = (char *) header + sizeof (struct grub_module_header);
+
+ grub_dprintf ("memdisk", "Found memdisk image at %p\n", memdisk_orig_addr);
+
+ memdisk_size = header->size - sizeof (struct grub_module_header);
+ memdisk_addr = grub_malloc (memdisk_size);
+
+ grub_dprintf ("memdisk", "Copying memdisk image to dynamic memory\n");
+ grub_memmove (memdisk_addr, memdisk_orig_addr, memdisk_size);
+
+ grub_disk_dev_register (&grub_memdisk_dev);
+ break;
+ }
+}
+
+GRUB_MOD_FINI(memdisk)
+{
+ if (! memdisk_size)
+ return;
+ grub_free (memdisk_addr);
+ grub_disk_dev_unregister (&grub_memdisk_dev);
+}
diff --git a/grub-core/disk/pata.c b/grub-core/disk/pata.c
new file mode 100644
index 0000000..c757e65
--- /dev/null
+++ b/grub-core/disk/pata.c
@@ -0,0 +1,556 @@
+/* ata_pthru.c - ATA pass through for ata.mod. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/ata.h>
+#include <grub/scsi.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
+#include <grub/pci.h>
+#include <grub/cs5536.h>
+#else
+#define GRUB_MACHINE_PCI_IO_BASE 0xb4000000
+#endif
+#include <grub/time.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* At the moment, only two IDE ports are supported. */
+static const grub_port_t grub_pata_ioaddress[] = { GRUB_ATA_CH0_PORT1,
+ GRUB_ATA_CH1_PORT1 };
+
+struct grub_pata_device
+{
+ /* IDE port to use. */
+ int port;
+
+ /* IO addresses on which the registers for this device can be
+ found. */
+ grub_port_t ioaddress;
+
+ /* Two devices can be connected to a single cable. Use this field
+ to select device 0 (commonly known as "master") or device 1
+ (commonly known as "slave"). */
+ int device;
+
+ int present;
+
+ struct grub_pata_device *next;
+};
+
+static struct grub_pata_device *grub_pata_devices;
+
+static inline void
+grub_pata_regset (struct grub_pata_device *dev, int reg, int val)
+{
+ grub_outb (val, dev->ioaddress + reg);
+}
+
+static inline grub_uint8_t
+grub_pata_regget (struct grub_pata_device *dev, int reg)
+{
+ return grub_inb (dev->ioaddress + reg);
+}
+
+/* Wait for !BSY. */
+static grub_err_t
+grub_pata_wait_not_busy (struct grub_pata_device *dev, int milliseconds)
+{
+ /* ATA requires 400ns (after a write to CMD register) or
+ 1 PIO cycle (after a DRQ block transfer) before
+ first check of BSY. */
+ grub_millisleep (1);
+
+ int i = 1;
+ grub_uint8_t sts;
+ while ((sts = grub_pata_regget (dev, GRUB_ATA_REG_STATUS))
+ & GRUB_ATA_STATUS_BUSY)
+ {
+ if (i >= milliseconds)
+ {
+ grub_dprintf ("pata", "timeout: %dms, status=0x%x\n",
+ milliseconds, sts);
+ return grub_error (GRUB_ERR_TIMEOUT, "PATA timeout");
+ }
+
+ grub_millisleep (1);
+ i++;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static inline grub_err_t
+grub_pata_check_ready (struct grub_pata_device *dev, int spinup)
+{
+ if (grub_pata_regget (dev, GRUB_ATA_REG_STATUS) & GRUB_ATA_STATUS_BUSY)
+ return grub_pata_wait_not_busy (dev, spinup ? GRUB_ATA_TOUT_SPINUP
+ : GRUB_ATA_TOUT_STD);
+
+ return GRUB_ERR_NONE;
+}
+
+static inline void
+grub_pata_wait (void)
+{
+ grub_millisleep (50);
+}
+
+#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
+#define grub_ata_to_cpu16(x) ((grub_uint16_t) (x))
+#define grub_cpu_to_ata16(x) ((grub_uint16_t) (x))
+#else
+#define grub_ata_to_cpu16 grub_le_to_cpu16
+#define grub_cpu_to_ata16 grub_cpu_to_le16
+#endif
+
+static void
+grub_pata_pio_read (struct grub_pata_device *dev, char *buf, grub_size_t size)
+{
+ unsigned int i;
+
+ /* Read in the data, word by word. */
+ for (i = 0; i < size / 2; i++)
+ grub_set_unaligned16 (buf + 2 * i,
+ grub_ata_to_cpu16 (grub_inw(dev->ioaddress
+ + GRUB_ATA_REG_DATA)));
+ if (size & 1)
+ buf[size - 1] = (char) grub_ata_to_cpu16 (grub_inw (dev->ioaddress
+ + GRUB_ATA_REG_DATA));
+}
+
+static void
+grub_pata_pio_write (struct grub_pata_device *dev, char *buf, grub_size_t size)
+{
+ unsigned int i;
+
+ /* Write the data, word by word. */
+ for (i = 0; i < size / 2; i++)
+ grub_outw(grub_cpu_to_ata16 (grub_get_unaligned16 (buf + 2 * i)), dev->ioaddress + GRUB_ATA_REG_DATA);
+}
+
+/* ATA pass through support, used by hdparm.mod. */
+static grub_err_t
+grub_pata_readwrite (struct grub_ata *disk,
+ struct grub_disk_ata_pass_through_parms *parms,
+ int spinup)
+{
+ struct grub_pata_device *dev = (struct grub_pata_device *) disk->data;
+ grub_size_t nread = 0;
+ int i;
+
+ if (! (parms->cmdsize == 0 || parms->cmdsize == 12))
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "ATAPI non-12 byte commands not supported");
+
+ grub_dprintf ("pata", "pata_pass_through: cmd=0x%x, features=0x%x, sectors=0x%x\n",
+ parms->taskfile.cmd,
+ parms->taskfile.features,
+ parms->taskfile.sectors);
+ grub_dprintf ("pata", "lba_high=0x%x, lba_mid=0x%x, lba_low=0x%x, size=%"
+ PRIuGRUB_SIZE "\n",
+ parms->taskfile.lba_high,
+ parms->taskfile.lba_mid,
+ parms->taskfile.lba_low, parms->size);
+
+ /* Set registers. */
+ grub_pata_regset (dev, GRUB_ATA_REG_DISK, (dev->device << 4)
+ | (parms->taskfile.disk & 0xef));
+ if (grub_pata_check_ready (dev, spinup))
+ return grub_errno;
+
+ for (i = GRUB_ATA_REG_SECTORS; i <= GRUB_ATA_REG_LBAHIGH; i++)
+ grub_pata_regset (dev, i,
+ parms->taskfile.raw[7 + (i - GRUB_ATA_REG_SECTORS)]);
+ for (i = GRUB_ATA_REG_FEATURES; i <= GRUB_ATA_REG_LBAHIGH; i++)
+ grub_pata_regset (dev, i, parms->taskfile.raw[i - GRUB_ATA_REG_FEATURES]);
+
+ /* Start command. */
+ grub_pata_regset (dev, GRUB_ATA_REG_CMD, parms->taskfile.cmd);
+
+ /* Wait for !BSY. */
+ if (grub_pata_wait_not_busy (dev, GRUB_ATA_TOUT_DATA))
+ return grub_errno;
+
+ /* Check status. */
+ grub_int8_t sts = grub_pata_regget (dev, GRUB_ATA_REG_STATUS);
+ grub_dprintf ("pata", "status=0x%x\n", sts);
+
+ if (parms->cmdsize)
+ {
+ grub_uint8_t irs;
+ /* Wait for !BSY. */
+ if (grub_pata_wait_not_busy (dev, GRUB_ATA_TOUT_DATA))
+ return grub_errno;
+
+ irs = grub_pata_regget (dev, GRUB_ATAPI_REG_IREASON);
+ /* OK if DRQ is asserted and interrupt reason is as expected. */
+ if (!((sts & GRUB_ATA_STATUS_DRQ)
+ && (irs & GRUB_ATAPI_IREASON_MASK) == GRUB_ATAPI_IREASON_CMD_OUT))
+ return grub_error (GRUB_ERR_READ_ERROR, "ATAPI protocol error");
+ /* Write the packet. */
+ grub_pata_pio_write (dev, parms->cmd, parms->cmdsize);
+ }
+
+ /* Transfer data. */
+ while (nread < parms->size
+ && (sts & (GRUB_ATA_STATUS_DRQ | GRUB_ATA_STATUS_ERR))
+ == GRUB_ATA_STATUS_DRQ)
+ {
+ unsigned cnt;
+
+ /* Wait for !BSY. */
+ if (grub_pata_wait_not_busy (dev, GRUB_ATA_TOUT_DATA))
+ return grub_errno;
+
+ if (parms->cmdsize)
+ {
+ if ((grub_pata_regget (dev, GRUB_ATAPI_REG_IREASON)
+ & GRUB_ATAPI_IREASON_MASK) != GRUB_ATAPI_IREASON_DATA_IN)
+ return grub_error (GRUB_ERR_READ_ERROR, "ATAPI protocol error");
+
+ cnt = grub_pata_regget (dev, GRUB_ATAPI_REG_CNTHIGH) << 8
+ | grub_pata_regget (dev, GRUB_ATAPI_REG_CNTLOW);
+ grub_dprintf("pata", "DRQ count=%u\n", cnt);
+
+ /* Count of last transfer may be uneven. */
+ if (! (0 < cnt && cnt <= parms->size - nread
+ && (! (cnt & 1) || cnt == parms->size - nread)))
+ return grub_error (GRUB_ERR_READ_ERROR,
+ "invalid ATAPI transfer count");
+ }
+ else
+ cnt = GRUB_DISK_SECTOR_SIZE;
+ if (cnt > parms->size - nread)
+ cnt = parms->size - nread;
+
+ if (parms->write)
+ grub_pata_pio_write (dev, (char *) parms->buffer + nread, cnt);
+ else
+ grub_pata_pio_read (dev, (char *) parms->buffer + nread, cnt);
+
+ nread += cnt;
+ }
+ if (parms->write)
+ {
+ /* Check for write error. */
+ if (grub_pata_wait_not_busy (dev, GRUB_ATA_TOUT_DATA))
+ return grub_errno;
+
+ if (grub_pata_regget (dev, GRUB_ATA_REG_STATUS)
+ & (GRUB_ATA_STATUS_DRQ | GRUB_ATA_STATUS_ERR))
+ return grub_error (GRUB_ERR_WRITE_ERROR, "ATA write error");
+ }
+ parms->size = nread;
+
+ /* Wait for !BSY. */
+ if (grub_pata_wait_not_busy (dev, GRUB_ATA_TOUT_DATA))
+ return grub_errno;
+
+ /* Return registers. */
+ for (i = GRUB_ATA_REG_ERROR; i <= GRUB_ATA_REG_STATUS; i++)
+ parms->taskfile.raw[i - GRUB_ATA_REG_FEATURES] = grub_pata_regget (dev, i);
+
+ grub_dprintf ("pata", "status=0x%x, error=0x%x, sectors=0x%x\n",
+ parms->taskfile.status,
+ parms->taskfile.error,
+ parms->taskfile.sectors);
+
+ if (parms->taskfile.status
+ & (GRUB_ATA_STATUS_DRQ | GRUB_ATA_STATUS_ERR))
+ return grub_error (GRUB_ERR_READ_ERROR, "PATA passthrough failed");
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+check_device (struct grub_pata_device *dev)
+{
+ grub_pata_regset (dev, GRUB_ATA_REG_DISK, dev->device << 4);
+ grub_pata_wait ();
+
+ /* Try to detect if the port is in use by writing to it,
+ waiting for a while and reading it again. If the value
+ was preserved, there is a device connected. */
+ grub_pata_regset (dev, GRUB_ATA_REG_SECTORS, 0x5A);
+ grub_pata_wait ();
+ grub_uint8_t sec = grub_pata_regget (dev, GRUB_ATA_REG_SECTORS);
+ grub_dprintf ("ata", "sectors=0x%x\n", sec);
+ if (sec != 0x5A)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no device connected");
+
+ /* The above test may detect a second (slave) device
+ connected to a SATA controller which supports only one
+ (master) device. It is not safe to use the status register
+ READY bit to check for controller channel existence. Some
+ ATAPI commands (RESET, DIAGNOSTIC) may clear this bit. */
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_pata_device_initialize (int port, int device, int addr)
+{
+ struct grub_pata_device *dev;
+ struct grub_pata_device **devp;
+ grub_err_t err;
+
+ grub_dprintf ("pata", "detecting device %d,%d (0x%x)\n",
+ port, device, addr);
+
+ dev = grub_malloc (sizeof(*dev));
+ if (! dev)
+ return grub_errno;
+
+ /* Setup the device information. */
+ dev->port = port;
+ dev->device = device;
+ dev->ioaddress = addr + GRUB_MACHINE_PCI_IO_BASE;
+ dev->present = 1;
+ dev->next = NULL;
+
+ /* Register the device. */
+ for (devp = &grub_pata_devices; *devp; devp = &(*devp)->next);
+ *devp = dev;
+
+ err = check_device (dev);
+ if (err == GRUB_ERR_UNKNOWN_DEVICE)
+ {
+ grub_dprintf ("pata", "%s\n", grub_errmsg);
+ grub_error_pop ();
+ }
+
+ if (err)
+ grub_print_error ();
+
+ return 0;
+}
+
+#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
+static int
+grub_pata_pciinit (grub_pci_device_t dev,
+ grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ static int compat_use[2] = { 0 };
+ grub_pci_address_t addr;
+ grub_uint32_t class;
+ grub_uint32_t bar1;
+ grub_uint32_t bar2;
+ int rega;
+ int i;
+ static int controller = 0;
+ int cs5536 = 0;
+ int nports = 2;
+
+ /* Read class. */
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class = grub_pci_read (addr);
+
+ /* AMD CS5536 Southbridge. */
+ if (pciid == GRUB_CS5536_PCIID)
+ {
+ cs5536 = 1;
+ nports = 1;
+ }
+
+ /* Check if this class ID matches that of a PCI IDE Controller. */
+ if (!cs5536 && (class >> 16 != 0x0101))
+ return 0;
+
+ for (i = 0; i < nports; i++)
+ {
+ /* Set to 0 when the channel operated in compatibility mode. */
+ int compat;
+
+ /* We don't support non-compatibility mode for CS5536. */
+ if (cs5536)
+ compat = 0;
+ else
+ compat = (class >> (8 + 2 * i)) & 1;
+
+ rega = 0;
+
+ /* If the channel is in compatibility mode, just assign the
+ default registers. */
+ if (compat == 0 && !compat_use[i])
+ {
+ rega = grub_pata_ioaddress[i];
+ compat_use[i] = 1;
+ }
+ else if (compat)
+ {
+ /* Read the BARs, which either contain a mmapped IO address
+ or the IO port address. */
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESSES
+ + sizeof (grub_uint64_t) * i);
+ bar1 = grub_pci_read (addr);
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESSES
+ + sizeof (grub_uint64_t) * i
+ + sizeof (grub_uint32_t));
+ bar2 = grub_pci_read (addr);
+
+ /* Check if the BARs describe an IO region. */
+ if ((bar1 & 1) && (bar2 & 1) && (bar1 & ~3))
+ {
+ rega = bar1 & ~3;
+ 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_dprintf ("pata",
+ "PCI dev (%d,%d,%d) compat=%d rega=0x%x\n",
+ grub_pci_get_bus (dev), grub_pci_get_device (dev),
+ grub_pci_get_function (dev), compat, rega);
+
+ if (rega)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_pata_device_initialize (controller * 2 + i, 0, rega);
+
+ /* Most errors raised by grub_ata_device_initialize() are harmless.
+ They just indicate this particular drive is not responding, most
+ likely because it doesn't exist. We might want to ignore specific
+ error types here, instead of printing them. */
+ if (grub_errno)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ grub_pata_device_initialize (controller * 2 + i, 1, rega);
+
+ /* Likewise. */
+ if (grub_errno)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+ }
+
+ controller++;
+
+ return 0;
+}
+
+static grub_err_t
+grub_pata_initialize (void)
+{
+ grub_pci_iterate (grub_pata_pciinit, NULL);
+ return 0;
+}
+#else
+static grub_err_t
+grub_pata_initialize (void)
+{
+ int i;
+ for (i = 0; i < 2; i++)
+ {
+ grub_pata_device_initialize (i, 0, grub_pata_ioaddress[i]);
+ grub_pata_device_initialize (i, 1, grub_pata_ioaddress[i]);
+ }
+ return 0;
+}
+#endif
+
+static grub_err_t
+grub_pata_open (int id, int devnum, struct grub_ata *ata)
+{
+ struct grub_pata_device *dev;
+ struct grub_pata_device *devfnd = 0;
+ grub_err_t err;
+
+ if (id != GRUB_SCSI_SUBSYSTEM_PATA)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a PATA device");
+
+ for (dev = grub_pata_devices; dev; dev = dev->next)
+ {
+ if (dev->port * 2 + dev->device == devnum)
+ {
+ devfnd = dev;
+ break;
+ }
+ }
+
+ grub_dprintf ("pata", "opening PATA dev `ata%d'\n", devnum);
+
+ if (! devfnd)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such PATA device");
+
+ err = check_device (devfnd);
+ if (err)
+ return err;
+
+ ata->data = devfnd;
+ ata->dma = 0;
+ ata->maxbuffer = 256 * 512;
+ ata->present = &devfnd->present;
+
+ return GRUB_ERR_NONE;
+}
+
+static int
+grub_pata_iterate (grub_ata_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ struct grub_pata_device *dev;
+
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ for (dev = grub_pata_devices; dev; dev = dev->next)
+ if (hook (GRUB_SCSI_SUBSYSTEM_PATA, dev->port * 2 + dev->device,
+ hook_data))
+ return 1;
+
+ return 0;
+}
+
+
+static struct grub_ata_dev grub_pata_dev =
+ {
+ .iterate = grub_pata_iterate,
+ .open = grub_pata_open,
+ .readwrite = grub_pata_readwrite,
+ };
+
+
+
+
+GRUB_MOD_INIT(ata_pthru)
+{
+ grub_stop_disk_firmware ();
+
+ /* ATA initialization. */
+ grub_pata_initialize ();
+
+ grub_ata_dev_register (&grub_pata_dev);
+}
+
+GRUB_MOD_FINI(ata_pthru)
+{
+ grub_ata_dev_unregister (&grub_pata_dev);
+}
diff --git a/grub-core/disk/raid5_recover.c b/grub-core/disk/raid5_recover.c
new file mode 100644
index 0000000..4ace917
--- /dev/null
+++ b/grub-core/disk/raid5_recover.c
@@ -0,0 +1,76 @@
+/* raid5_recover.c - module to recover from faulty RAID4/5 arrays. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/diskfilter.h>
+#include <grub/crypto.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_raid5_recover (struct grub_diskfilter_segment *array, int disknr,
+ char *buf, grub_disk_addr_t sector, grub_size_t size)
+{
+ char *buf2;
+ int i;
+
+ size <<= GRUB_DISK_SECTOR_BITS;
+ buf2 = grub_malloc (size);
+ if (!buf2)
+ return grub_errno;
+
+ grub_memset (buf, 0, size);
+
+ for (i = 0; i < (int) array->node_count; i++)
+ {
+ grub_err_t err;
+
+ if (i == disknr)
+ continue;
+
+ err = grub_diskfilter_read_node (&array->nodes[i], sector,
+ size >> GRUB_DISK_SECTOR_BITS, buf2);
+
+ if (err)
+ {
+ grub_free (buf2);
+ return err;
+ }
+
+ grub_crypto_xor (buf, buf, buf2, size);
+ }
+
+ grub_free (buf2);
+
+ return GRUB_ERR_NONE;
+}
+
+GRUB_MOD_INIT(raid5rec)
+{
+ grub_raid5_recover_func = grub_raid5_recover;
+}
+
+GRUB_MOD_FINI(raid5rec)
+{
+ grub_raid5_recover_func = 0;
+}
diff --git a/grub-core/disk/raid6_recover.c b/grub-core/disk/raid6_recover.c
new file mode 100644
index 0000000..75fe464
--- /dev/null
+++ b/grub-core/disk/raid6_recover.c
@@ -0,0 +1,218 @@
+/* raid6_recover.c - module to recover from faulty RAID6 arrays. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/diskfilter.h>
+#include <grub/crypto.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* x**y. */
+static grub_uint8_t powx[255 * 2];
+/* Such an s that x**s = y */
+static unsigned powx_inv[256];
+static const grub_uint8_t poly = 0x1d;
+
+static void
+grub_raid_block_mulx (unsigned mul, char *buf, grub_size_t size)
+{
+ grub_size_t i;
+ grub_uint8_t *p;
+
+ p = (grub_uint8_t *) buf;
+ for (i = 0; i < size; i++, p++)
+ if (*p)
+ *p = powx[mul + powx_inv[*p]];
+}
+
+static void
+grub_raid6_init_table (void)
+{
+ unsigned i;
+
+ grub_uint8_t cur = 1;
+ for (i = 0; i < 255; i++)
+ {
+ powx[i] = cur;
+ powx[i + 255] = cur;
+ powx_inv[cur] = i;
+ if (cur & 0x80)
+ cur = (cur << 1) ^ poly;
+ else
+ cur <<= 1;
+ }
+}
+
+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
+raid6_recover_read_node (void *data, int disknr,
+ grub_uint64_t sector,
+ void *buf, grub_size_t size)
+{
+ struct grub_diskfilter_segment *array = data;
+
+ return grub_diskfilter_read_node (&array->nodes[disknr],
+ (grub_disk_addr_t)sector,
+ size >> GRUB_DISK_SECTOR_BITS, buf);
+}
+
+grub_err_t
+grub_raid6_recover_gen (void *data, grub_uint64_t nstripes, int disknr, int p,
+ char *buf, grub_uint64_t sector, grub_size_t size,
+ int layout, raid_recover_read_t read_func)
+{
+ int i, q, pos;
+ int bad1 = -1, bad2 = -1;
+ char *pbuf = 0, *qbuf = 0;
+
+ pbuf = grub_zalloc (size);
+ if (!pbuf)
+ goto quit;
+
+ qbuf = grub_zalloc (size);
+ if (!qbuf)
+ goto quit;
+
+ q = p + 1;
+ if (q == (int) nstripes)
+ q = 0;
+
+ pos = q + 1;
+ if (pos == (int) nstripes)
+ pos = 0;
+
+ for (i = 0; i < (int) nstripes - 2; i++)
+ {
+ int c;
+ if (layout & GRUB_RAID_LAYOUT_MUL_FROM_POS)
+ c = pos;
+ else
+ c = i;
+ if (pos == disknr)
+ bad1 = c;
+ else
+ {
+ if (!read_func (data, pos, sector, buf, size))
+ {
+ grub_crypto_xor (pbuf, pbuf, buf, size);
+ grub_raid_block_mulx (c, buf, size);
+ grub_crypto_xor (qbuf, qbuf, buf, size);
+ }
+ else
+ {
+ /* Too many bad devices */
+ if (bad2 >= 0)
+ goto quit;
+
+ bad2 = c;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+
+ pos++;
+ if (pos == (int) nstripes)
+ pos = 0;
+ }
+
+ /* Invalid disknr or p */
+ if (bad1 < 0)
+ goto quit;
+
+ if (bad2 < 0)
+ {
+ /* One bad device */
+ if (!read_func (data, p, sector, buf, size))
+ {
+ grub_crypto_xor (buf, buf, pbuf, size);
+ goto quit;
+ }
+
+ grub_errno = GRUB_ERR_NONE;
+ if (read_func (data, q, sector, buf, size))
+ goto quit;
+
+ grub_crypto_xor (buf, buf, qbuf, size);
+ grub_raid_block_mulx (255 - bad1, buf,
+ size);
+ }
+ else
+ {
+ /* Two bad devices */
+ unsigned c;
+
+ if (read_func (data, p, sector, buf, size))
+ goto quit;
+
+ grub_crypto_xor (pbuf, pbuf, buf, size);
+
+ if (read_func (data, q, sector, buf, size))
+ goto quit;
+
+ grub_crypto_xor (qbuf, qbuf, buf, size);
+
+ c = mod_255((255 ^ bad1)
+ + (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)]));
+ grub_raid_block_mulx (c, qbuf, size);
+
+ c = mod_255((unsigned) bad2 + c);
+ grub_raid_block_mulx (c, pbuf, size);
+
+ grub_crypto_xor (pbuf, pbuf, qbuf, size);
+ grub_memcpy (buf, pbuf, size);
+ }
+
+quit:
+ grub_free (pbuf);
+ grub_free (qbuf);
+
+ return grub_errno;
+}
+
+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)
+{
+ return grub_raid6_recover_gen (array, array->node_count, disknr, p, buf,
+ sector, size << GRUB_DISK_SECTOR_BITS,
+ array->layout, raid6_recover_read_node);
+}
+
+GRUB_MOD_INIT(raid6rec)
+{
+ grub_raid6_init_table ();
+ grub_raid6_recover_func = grub_raid6_recover;
+}
+
+GRUB_MOD_FINI(raid6rec)
+{
+ grub_raid6_recover_func = 0;
+}
diff --git a/grub-core/disk/scsi.c b/grub-core/disk/scsi.c
new file mode 100644
index 0000000..70767cf
--- /dev/null
+++ b/grub-core/disk/scsi.c
@@ -0,0 +1,766 @@
+/* scsi.c - scsi support. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/scsi.h>
+#include <grub/scsicmd.h>
+#include <grub/time.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+
+static grub_scsi_dev_t grub_scsi_dev_list;
+
+const char grub_scsi_names[GRUB_SCSI_NUM_SUBSYSTEMS][5] = {
+ [GRUB_SCSI_SUBSYSTEM_USBMS] = "usb",
+ [GRUB_SCSI_SUBSYSTEM_PATA] = "ata",
+ [GRUB_SCSI_SUBSYSTEM_AHCI] = "ahci"
+};
+
+void
+grub_scsi_dev_register (grub_scsi_dev_t dev)
+{
+ dev->next = grub_scsi_dev_list;
+ grub_scsi_dev_list = dev;
+}
+
+void
+grub_scsi_dev_unregister (grub_scsi_dev_t dev)
+{
+ grub_scsi_dev_t *p, q;
+
+ for (p = &grub_scsi_dev_list, q = *p; q; p = &(q->next), q = q->next)
+ if (q == dev)
+ {
+ *p = q->next;
+ break;
+ }
+}
+
+
+/* Check result of previous operation. */
+static grub_err_t
+grub_scsi_request_sense (grub_scsi_t scsi)
+{
+ struct grub_scsi_request_sense rs;
+ struct grub_scsi_request_sense_data rsd;
+ grub_err_t err;
+
+ rs.opcode = grub_scsi_cmd_request_sense;
+ rs.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
+ rs.reserved1 = 0;
+ rs.reserved2 = 0;
+ rs.alloc_length = 0x12; /* XXX: Hardcoded for now */
+ rs.control = 0;
+ grub_memset (rs.pad, 0, sizeof(rs.pad));
+
+ err = scsi->dev->read (scsi, sizeof (rs), (char *) &rs,
+ sizeof (rsd), (char *) &rsd);
+ if (err)
+ return err;
+
+ return GRUB_ERR_NONE;
+}
+/* Self commenting... */
+static grub_err_t
+grub_scsi_test_unit_ready (grub_scsi_t scsi)
+{
+ struct grub_scsi_test_unit_ready tur;
+ grub_err_t err;
+ grub_err_t err_sense;
+
+ tur.opcode = grub_scsi_cmd_test_unit_ready;
+ tur.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
+ tur.reserved1 = 0;
+ tur.reserved2 = 0;
+ tur.reserved3 = 0;
+ tur.control = 0;
+ grub_memset (tur.pad, 0, sizeof(tur.pad));
+
+ err = scsi->dev->read (scsi, sizeof (tur), (char *) &tur,
+ 0, NULL);
+
+ /* Each SCSI command should be followed by Request Sense.
+ If not so, many devices STALLs or definitely freezes. */
+ err_sense = grub_scsi_request_sense (scsi);
+ if (err_sense != GRUB_ERR_NONE)
+ grub_errno = err;
+ /* err_sense is ignored for now and Request Sense Data also... */
+
+ if (err)
+ return err;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Determine if the device is removable and the type of the device
+ SCSI. */
+static grub_err_t
+grub_scsi_inquiry (grub_scsi_t scsi)
+{
+ struct grub_scsi_inquiry iq;
+ struct grub_scsi_inquiry_data iqd;
+ grub_err_t err;
+ grub_err_t err_sense;
+
+ iq.opcode = grub_scsi_cmd_inquiry;
+ iq.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
+ iq.page = 0;
+ iq.reserved = 0;
+ iq.alloc_length = 0x24; /* XXX: Hardcoded for now */
+ iq.control = 0;
+ grub_memset (iq.pad, 0, sizeof(iq.pad));
+
+ err = scsi->dev->read (scsi, sizeof (iq), (char *) &iq,
+ sizeof (iqd), (char *) &iqd);
+
+ /* Each SCSI command should be followed by Request Sense.
+ If not so, many devices STALLs or definitely freezes. */
+ err_sense = grub_scsi_request_sense (scsi);
+ if (err_sense != GRUB_ERR_NONE)
+ grub_errno = err;
+ /* err_sense is ignored for now and Request Sense Data also... */
+
+ if (err)
+ return err;
+
+ scsi->devtype = iqd.devtype & GRUB_SCSI_DEVTYPE_MASK;
+ scsi->removable = iqd.rmb >> GRUB_SCSI_REMOVABLE_BIT;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Read the capacity and block size of SCSI. */
+static grub_err_t
+grub_scsi_read_capacity10 (grub_scsi_t scsi)
+{
+ struct grub_scsi_read_capacity10 rc;
+ struct grub_scsi_read_capacity10_data rcd;
+ grub_err_t err;
+ grub_err_t err_sense;
+
+ rc.opcode = grub_scsi_cmd_read_capacity10;
+ rc.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
+ rc.logical_block_addr = 0;
+ rc.reserved1 = 0;
+ rc.reserved2 = 0;
+ rc.PMI = 0;
+ rc.control = 0;
+ rc.pad = 0;
+
+ err = scsi->dev->read (scsi, sizeof (rc), (char *) &rc,
+ sizeof (rcd), (char *) &rcd);
+
+ /* Each SCSI command should be followed by Request Sense.
+ If not so, many devices STALLs or definitely freezes. */
+ err_sense = grub_scsi_request_sense (scsi);
+ if (err_sense != GRUB_ERR_NONE)
+ grub_errno = err;
+/* err_sense is ignored for now and Request Sense Data also... */
+
+ if (err)
+ return err;
+
+ scsi->last_block = grub_be_to_cpu32 (rcd.last_block);
+ scsi->blocksize = grub_be_to_cpu32 (rcd.blocksize);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Read the capacity and block size of SCSI. */
+static grub_err_t
+grub_scsi_read_capacity16 (grub_scsi_t scsi)
+{
+ struct grub_scsi_read_capacity16 rc;
+ struct grub_scsi_read_capacity16_data rcd;
+ grub_err_t err;
+ grub_err_t err_sense;
+
+ 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_compile_time (sizeof (rcd));
+ rc.PMI = 0;
+ rc.control = 0;
+
+ err = scsi->dev->read (scsi, sizeof (rc), (char *) &rc,
+ sizeof (rcd), (char *) &rcd);
+
+ /* Each SCSI command should be followed by Request Sense.
+ If not so, many devices STALLs or definitely freezes. */
+ err_sense = grub_scsi_request_sense (scsi);
+ if (err_sense != GRUB_ERR_NONE)
+ grub_errno = err;
+/* err_sense is ignored for now and Request Sense Data also... */
+
+ if (err)
+ return err;
+
+ scsi->last_block = grub_be_to_cpu64 (rcd.last_block);
+ scsi->blocksize = grub_be_to_cpu32 (rcd.blocksize);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Send a SCSI request for DISK: read SIZE sectors starting with
+ sector SECTOR to BUF. */
+static grub_err_t
+grub_scsi_read10 (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_scsi_t scsi;
+ struct grub_scsi_read10 rd;
+ grub_err_t err;
+ grub_err_t err_sense;
+
+ scsi = disk->data;
+
+ rd.opcode = grub_scsi_cmd_read10;
+ rd.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
+ rd.lba = grub_cpu_to_be32 (sector);
+ rd.reserved = 0;
+ rd.size = grub_cpu_to_be16 (size);
+ rd.reserved2 = 0;
+ rd.pad = 0;
+
+ err = scsi->dev->read (scsi, sizeof (rd), (char *) &rd, size * scsi->blocksize, buf);
+
+ /* Each SCSI command should be followed by Request Sense.
+ If not so, many devices STALLs or definitely freezes. */
+ err_sense = grub_scsi_request_sense (scsi);
+ if (err_sense != GRUB_ERR_NONE)
+ grub_errno = err;
+ /* err_sense is ignored for now and Request Sense Data also... */
+
+ return err;
+}
+
+/* Send a SCSI request for DISK: read SIZE sectors starting with
+ sector SECTOR to BUF. */
+static grub_err_t
+grub_scsi_read12 (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_scsi_t scsi;
+ struct grub_scsi_read12 rd;
+ grub_err_t err;
+ grub_err_t err_sense;
+
+ scsi = disk->data;
+
+ rd.opcode = grub_scsi_cmd_read12;
+ rd.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
+ rd.lba = grub_cpu_to_be32 (sector);
+ rd.size = grub_cpu_to_be32 (size);
+ rd.reserved = 0;
+ rd.control = 0;
+
+ err = scsi->dev->read (scsi, sizeof (rd), (char *) &rd, size * scsi->blocksize, buf);
+
+ /* Each SCSI command should be followed by Request Sense.
+ If not so, many devices STALLs or definitely freezes. */
+ err_sense = grub_scsi_request_sense (scsi);
+ if (err_sense != GRUB_ERR_NONE)
+ grub_errno = err;
+ /* err_sense is ignored for now and Request Sense Data also... */
+
+ return err;
+}
+
+/* Send a SCSI request for DISK: read SIZE sectors starting with
+ sector SECTOR to BUF. */
+static grub_err_t
+grub_scsi_read16 (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_scsi_t scsi;
+ struct grub_scsi_read16 rd;
+ grub_err_t err;
+ grub_err_t err_sense;
+
+ scsi = disk->data;
+
+ rd.opcode = grub_scsi_cmd_read16;
+ rd.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
+ rd.lba = grub_cpu_to_be64 (sector);
+ rd.size = grub_cpu_to_be32 (size);
+ rd.reserved = 0;
+ rd.control = 0;
+
+ err = scsi->dev->read (scsi, sizeof (rd), (char *) &rd, size * scsi->blocksize, buf);
+
+ /* Each SCSI command should be followed by Request Sense.
+ If not so, many devices STALLs or definitely freezes. */
+ err_sense = grub_scsi_request_sense (scsi);
+ if (err_sense != GRUB_ERR_NONE)
+ grub_errno = err;
+ /* err_sense is ignored for now and Request Sense Data also... */
+
+ return err;
+}
+
+/* Send a SCSI request for DISK: write the data stored in BUF to SIZE
+ sectors starting with SECTOR. */
+static grub_err_t
+grub_scsi_write10 (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, const char *buf)
+{
+ grub_scsi_t scsi;
+ struct grub_scsi_write10 wr;
+ grub_err_t err;
+ grub_err_t err_sense;
+
+ scsi = disk->data;
+
+ wr.opcode = grub_scsi_cmd_write10;
+ wr.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
+ wr.lba = grub_cpu_to_be32 (sector);
+ wr.reserved = 0;
+ wr.size = grub_cpu_to_be16 (size);
+ wr.reserved2 = 0;
+ wr.pad = 0;
+
+ err = scsi->dev->write (scsi, sizeof (wr), (char *) &wr, size * scsi->blocksize, buf);
+
+ /* Each SCSI command should be followed by Request Sense.
+ If not so, many devices STALLs or definitely freezes. */
+ err_sense = grub_scsi_request_sense (scsi);
+ if (err_sense != GRUB_ERR_NONE)
+ grub_errno = err;
+ /* err_sense is ignored for now and Request Sense Data also... */
+
+ return err;
+}
+
+#if 0
+
+/* Send a SCSI request for DISK: write the data stored in BUF to SIZE
+ sectors starting with SECTOR. */
+static grub_err_t
+grub_scsi_write12 (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_scsi_t scsi;
+ struct grub_scsi_write12 wr;
+ grub_err_t err;
+ grub_err_t err_sense;
+
+ scsi = disk->data;
+
+ wr.opcode = grub_scsi_cmd_write12;
+ wr.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
+ wr.lba = grub_cpu_to_be32 (sector);
+ wr.size = grub_cpu_to_be32 (size);
+ wr.reserved = 0;
+ wr.control = 0;
+
+ err = scsi->dev->write (scsi, sizeof (wr), (char *) &wr, size * scsi->blocksize, buf);
+
+ /* Each SCSI command should be followed by Request Sense.
+ If not so, many devices STALLs or definitely freezes. */
+ err_sense = grub_scsi_request_sense (scsi);
+ if (err_sense != GRUB_ERR_NONE)
+ grub_errno = err;
+ /* err_sense is ignored for now and Request Sense Data also... */
+
+ return err;
+}
+#endif
+
+/* Send a SCSI request for DISK: write the data stored in BUF to SIZE
+ sectors starting with SECTOR. */
+static grub_err_t
+grub_scsi_write16 (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, const char *buf)
+{
+ grub_scsi_t scsi;
+ struct grub_scsi_write16 wr;
+ grub_err_t err;
+ grub_err_t err_sense;
+
+ scsi = disk->data;
+
+ wr.opcode = grub_scsi_cmd_write16;
+ wr.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
+ wr.lba = grub_cpu_to_be64 (sector);
+ wr.size = grub_cpu_to_be32 (size);
+ wr.reserved = 0;
+ wr.control = 0;
+
+ err = scsi->dev->write (scsi, sizeof (wr), (char *) &wr, size * scsi->blocksize, buf);
+
+ /* Each SCSI command should be followed by Request Sense.
+ If not so, many devices STALLs or definitely freezes. */
+ err_sense = grub_scsi_request_sense (scsi);
+ if (err_sense != GRUB_ERR_NONE)
+ grub_errno = err;
+ /* err_sense is ignored for now and Request Sense Data also... */
+
+ return err;
+}
+
+
+
+/* Context for grub_scsi_iterate. */
+struct grub_scsi_iterate_ctx
+{
+ grub_disk_dev_iterate_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_scsi_iterate. */
+static int
+scsi_iterate (int id, int bus, int luns, void *data)
+{
+ struct grub_scsi_iterate_ctx *ctx = data;
+ int i;
+
+ /* In case of a single LUN, just return `usbX'. */
+ if (luns == 1)
+ {
+ char *sname;
+ int ret;
+ sname = grub_xasprintf ("%s%d", grub_scsi_names[id], bus);
+ if (!sname)
+ return 1;
+ ret = ctx->hook (sname, ctx->hook_data);
+ grub_free (sname);
+ return ret;
+ }
+
+ /* In case of multiple LUNs, every LUN will get a prefix to
+ distinguish it. */
+ for (i = 0; i < luns; i++)
+ {
+ char *sname;
+ int ret;
+ sname = grub_xasprintf ("%s%d%c", grub_scsi_names[id], bus, 'a' + i);
+ if (!sname)
+ return 1;
+ ret = ctx->hook (sname, ctx->hook_data);
+ grub_free (sname);
+ if (ret)
+ return 1;
+ }
+ return 0;
+}
+
+static int
+grub_scsi_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ struct grub_scsi_iterate_ctx ctx = { hook, hook_data };
+ grub_scsi_dev_t p;
+
+ for (p = grub_scsi_dev_list; p; p = p->next)
+ if (p->iterate && (p->iterate) (scsi_iterate, &ctx, pull))
+ return 1;
+
+ return 0;
+}
+
+static grub_err_t
+grub_scsi_open (const char *name, grub_disk_t disk)
+{
+ grub_scsi_dev_t p;
+ grub_scsi_t scsi;
+ grub_err_t err;
+ int lun, bus;
+ grub_uint64_t maxtime;
+ const char *nameend;
+ unsigned id;
+
+ nameend = name + grub_strlen (name) - 1;
+ /* Try to detect a LUN ('a'-'z'), otherwise just use the first
+ LUN. */
+ if (nameend >= name && *nameend >= 'a' && *nameend <= 'z')
+ {
+ lun = *nameend - 'a';
+ nameend--;
+ }
+ else
+ lun = 0;
+
+ while (nameend >= name && grub_isdigit (*nameend))
+ nameend--;
+
+ if (!nameend[1] || !grub_isdigit (nameend[1]))
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a SCSI disk");
+
+ bus = grub_strtoul (nameend + 1, 0, 0);
+
+ scsi = grub_malloc (sizeof (*scsi));
+ if (! scsi)
+ return grub_errno;
+
+ for (id = 0; id < ARRAY_SIZE (grub_scsi_names); id++)
+ if (grub_strncmp (grub_scsi_names[id], name, nameend - name) == 0)
+ break;
+
+ if (id == ARRAY_SIZE (grub_scsi_names))
+ {
+ grub_free (scsi);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a SCSI disk");
+ }
+
+ for (p = grub_scsi_dev_list; p; p = p->next)
+ {
+ if (p->open (id, bus, scsi))
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ disk->id = grub_make_scsi_id (id, bus, lun);
+ disk->data = scsi;
+ scsi->dev = p;
+ scsi->lun = lun;
+ scsi->bus = bus;
+
+ grub_dprintf ("scsi", "dev opened\n");
+
+ err = grub_scsi_inquiry (scsi);
+ if (err)
+ {
+ grub_free (scsi);
+ grub_dprintf ("scsi", "inquiry failed\n");
+ return err;
+ }
+
+ grub_dprintf ("scsi", "inquiry: devtype=0x%02x removable=%d\n",
+ scsi->devtype, scsi->removable);
+
+ /* Try to be conservative about the device types
+ supported. */
+ if (scsi->devtype != grub_scsi_devtype_direct
+ && scsi->devtype != grub_scsi_devtype_cdrom)
+ {
+ grub_free (scsi);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "unknown SCSI device");
+ }
+
+ /* According to USB MS tests specification, issue Test Unit Ready
+ * until OK */
+ maxtime = grub_get_time_ms () + 5000; /* It is safer value */
+ do
+ {
+ /* Timeout is necessary - for example in case when we have
+ * universal card reader with more LUNs and we have only
+ * one card inserted (or none), so only one LUN (or none)
+ * will be ready - and we want not to hang... */
+ if (grub_get_time_ms () > maxtime)
+ {
+ err = GRUB_ERR_READ_ERROR;
+ grub_free (scsi);
+ grub_dprintf ("scsi", "LUN is not ready - timeout\n");
+ return err;
+ }
+ err = grub_scsi_test_unit_ready (scsi);
+ }
+ while (err == GRUB_ERR_READ_ERROR);
+ /* Reset grub_errno !
+ * It is set to some error code in loop before... */
+ grub_errno = GRUB_ERR_NONE;
+
+ /* Read capacity of media */
+ err = grub_scsi_read_capacity10 (scsi);
+ if (err)
+ {
+ grub_free (scsi);
+ grub_dprintf ("scsi", "READ CAPACITY10 failed\n");
+ return err;
+ }
+
+ if (scsi->last_block == 0xffffffff)
+ {
+ err = grub_scsi_read_capacity16 (scsi);
+ if (err)
+ {
+ grub_free (scsi);
+ grub_dprintf ("scsi", "READ CAPACITY16 failed\n");
+ return err;
+ }
+ }
+
+ disk->total_sectors = scsi->last_block + 1;
+ /* PATA doesn't support more than 32K reads.
+ Not sure about AHCI and USB. If it's confirmed that either of
+ them can do bigger reads reliably this value can be moved to 'scsi'
+ structure. */
+ disk->max_agglomerate = 32768 >> (GRUB_DISK_SECTOR_BITS
+ + GRUB_DISK_CACHE_BITS);
+
+ if (scsi->blocksize & (scsi->blocksize - 1) || !scsi->blocksize)
+ {
+ grub_error (GRUB_ERR_IO, "invalid sector size %d",
+ scsi->blocksize);
+ grub_free (scsi);
+ return grub_errno;
+ }
+ for (disk->log_sector_size = 0;
+ (1U << disk->log_sector_size) < scsi->blocksize;
+ disk->log_sector_size++);
+
+ grub_dprintf ("scsi", "last_block=%" PRIuGRUB_UINT64_T ", blocksize=%u\n",
+ scsi->last_block, scsi->blocksize);
+ grub_dprintf ("scsi", "Disk total sectors = %llu\n",
+ (unsigned long long) disk->total_sectors);
+
+ return GRUB_ERR_NONE;
+ }
+
+ grub_free (scsi);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a SCSI disk");
+}
+
+static void
+grub_scsi_close (grub_disk_t disk)
+{
+ grub_scsi_t scsi;
+
+ scsi = disk->data;
+ if (scsi->dev->close)
+ scsi->dev->close (scsi);
+ grub_free (scsi);
+}
+
+static grub_err_t
+grub_scsi_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_scsi_t scsi;
+
+ scsi = disk->data;
+
+ grub_err_t err;
+ /* Depending on the type, select a read function. */
+ switch (scsi->devtype)
+ {
+ case grub_scsi_devtype_direct:
+ if (sector >> 32)
+ err = grub_scsi_read16 (disk, sector, size, buf);
+ else
+ err = grub_scsi_read10 (disk, sector, size, buf);
+ if (err)
+ return err;
+ break;
+
+ case grub_scsi_devtype_cdrom:
+ if (sector >> 32)
+ err = grub_scsi_read16 (disk, sector, size, buf);
+ else
+ err = grub_scsi_read12 (disk, sector, size, buf);
+ if (err)
+ return err;
+ break;
+ }
+
+ return GRUB_ERR_NONE;
+
+#if 0 /* Workaround - it works - but very slowly, from some reason
+ * unknown to me (specially on OHCI). Do not use it. */
+ /* Split transfer requests to device sector size because */
+ /* some devices are not able to transfer more than 512-1024 bytes */
+ grub_err_t err = GRUB_ERR_NONE;
+
+ for ( ; size; size--)
+ {
+ /* Depending on the type, select a read function. */
+ switch (scsi->devtype)
+ {
+ case grub_scsi_devtype_direct:
+ err = grub_scsi_read10 (disk, sector, 1, buf);
+ break;
+
+ case grub_scsi_devtype_cdrom:
+ err = grub_scsi_read12 (disk, sector, 1, buf);
+ break;
+
+ default: /* This should not happen */
+ return GRUB_ERR_READ_ERROR;
+ }
+ if (err)
+ return err;
+ sector++;
+ buf += scsi->blocksize;
+ }
+
+ return err;
+#endif
+}
+
+static grub_err_t
+grub_scsi_write (grub_disk_t disk,
+ grub_disk_addr_t sector,
+ grub_size_t size,
+ const char *buf)
+{
+ grub_scsi_t scsi;
+
+ scsi = disk->data;
+
+ if (scsi->devtype == grub_scsi_devtype_cdrom)
+ return grub_error (GRUB_ERR_IO, N_("cannot write to CD-ROM"));
+
+ grub_err_t err;
+ /* Depending on the type, select a read function. */
+ switch (scsi->devtype)
+ {
+ case grub_scsi_devtype_direct:
+ if (sector >> 32)
+ err = grub_scsi_write16 (disk, sector, size, buf);
+ else
+ err = grub_scsi_write10 (disk, sector, size, buf);
+ if (err)
+ return err;
+ break;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+
+static struct grub_disk_dev grub_scsi_dev =
+ {
+ .name = "scsi",
+ .id = GRUB_DISK_DEVICE_SCSI_ID,
+ .disk_iterate = grub_scsi_iterate,
+ .disk_open = grub_scsi_open,
+ .disk_close = grub_scsi_close,
+ .disk_read = grub_scsi_read,
+ .disk_write = grub_scsi_write,
+ .next = 0
+ };
+
+GRUB_MOD_INIT(scsi)
+{
+ grub_disk_dev_register (&grub_scsi_dev);
+}
+
+GRUB_MOD_FINI(scsi)
+{
+ grub_disk_dev_unregister (&grub_scsi_dev);
+}
diff --git a/grub-core/disk/uboot/ubootdisk.c b/grub-core/disk/uboot/ubootdisk.c
new file mode 100644
index 0000000..2d115a9
--- /dev/null
+++ b/grub-core/disk/uboot/ubootdisk.c
@@ -0,0 +1,307 @@
+/* ubootdisk.c - disk subsystem support for U-Boot platforms */
+/*
+ * 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/disk.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/partition.h>
+#include <grub/term.h>
+#include <grub/types.h>
+#include <grub/uboot/disk.h>
+#include <grub/uboot/uboot.h>
+#include <grub/uboot/api_public.h>
+
+static struct ubootdisk_data *hd_devices;
+static int hd_num;
+static int hd_max;
+
+/*
+ * grub_ubootdisk_register():
+ * Called for each disk device enumerated as part of U-Boot initialization
+ * code.
+ */
+grub_err_t
+grub_ubootdisk_register (struct device_info *newdev)
+{
+ struct ubootdisk_data *d;
+
+#define STOR_TYPE(x) ((x) & 0x0ff0)
+ switch (STOR_TYPE (newdev->type))
+ {
+ case DT_STOR_IDE:
+ case DT_STOR_SATA:
+ case DT_STOR_SCSI:
+ case DT_STOR_MMC:
+ case DT_STOR_USB:
+ /* hd */
+ if (hd_num == hd_max)
+ {
+ int new_num;
+ new_num = (hd_max ? hd_max * 2 : 1);
+ d = grub_realloc(hd_devices,
+ sizeof (struct ubootdisk_data) * new_num);
+ if (!d)
+ return grub_errno;
+ hd_devices = d;
+ hd_max = new_num;
+ }
+
+ d = &hd_devices[hd_num];
+ hd_num++;
+ break;
+ default:
+ return GRUB_ERR_BAD_DEVICE;
+ break;
+ }
+
+ d->dev = newdev;
+ d->cookie = newdev->cookie;
+ d->opencount = 0;
+
+ return 0;
+}
+
+/*
+ * uboot_disk_iterate():
+ * Iterator over enumerated disk devices.
+ */
+static int
+uboot_disk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ char buf[16];
+ int count;
+
+ switch (pull)
+ {
+ case GRUB_DISK_PULL_NONE:
+ /* "hd" - built-in mass-storage */
+ for (count = 0 ; count < hd_num; count++)
+ {
+ grub_snprintf (buf, sizeof (buf) - 1, "hd%d", count);
+ grub_dprintf ("ubootdisk", "iterating %s\n", buf);
+ if (hook (buf, hook_data))
+ return 1;
+ }
+ break;
+ default:
+ return 0;
+ }
+
+ return 0;
+}
+
+/* Helper function for uboot_disk_open. */
+static struct ubootdisk_data *
+get_hd_device (int num)
+{
+ if (num < hd_num)
+ return &hd_devices[num];
+
+ return NULL;
+}
+
+/*
+ * uboot_disk_open():
+ * Opens a disk device already enumerated.
+ */
+static grub_err_t
+uboot_disk_open (const char *name, struct grub_disk *disk)
+{
+ struct ubootdisk_data *d;
+ struct device_info *devinfo;
+ int num;
+ int retval;
+
+ grub_dprintf ("ubootdisk", "Opening '%s'\n", name);
+
+ num = grub_strtoul (name + 2, 0, 10);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_dprintf ("ubootdisk", "Opening '%s' failed, invalid number\n",
+ name);
+ goto fail;
+ }
+
+ if (name[1] != 'd')
+ {
+ grub_dprintf ("ubootdisk", "Opening '%s' failed, invalid name\n", name);
+ goto fail;
+ }
+
+ switch (name[0])
+ {
+ case 'h':
+ d = get_hd_device (num);
+ break;
+ default:
+ goto fail;
+ }
+
+ if (!d)
+ goto fail;
+
+ /*
+ * Subsystems may call open on the same device recursively - but U-Boot
+ * does not deal with this. So simply keep track of number of calls and
+ * return success if already open.
+ */
+ if (d->opencount > 0)
+ {
+ grub_dprintf ("ubootdisk", "(%s) already open\n", disk->name);
+ d->opencount++;
+ retval = 0;
+ }
+ else
+ {
+ retval = grub_uboot_dev_open (d->dev);
+ if (retval != 0)
+ goto fail;
+ d->opencount = 1;
+ }
+
+ grub_dprintf ("ubootdisk", "cookie: 0x%08x\n", (grub_addr_t) d->cookie);
+ disk->id = (grub_addr_t) d->cookie;
+
+ devinfo = d->dev;
+
+ d->block_size = devinfo->di_stor.block_size;
+ if (d->block_size == 0)
+ return grub_error (GRUB_ERR_IO, "no block size");
+
+ for (disk->log_sector_size = 0;
+ (1U << disk->log_sector_size) < d->block_size;
+ disk->log_sector_size++);
+
+ grub_dprintf ("ubootdisk", "(%s) blocksize=%d, log_sector_size=%d\n",
+ disk->name, d->block_size, disk->log_sector_size);
+
+ if (devinfo->di_stor.block_count)
+ disk->total_sectors = devinfo->di_stor.block_count;
+ else
+ disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN;
+
+ disk->data = d;
+
+ return GRUB_ERR_NONE;
+
+fail:
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such device");
+}
+
+static void
+uboot_disk_close (struct grub_disk *disk)
+{
+ struct ubootdisk_data *d;
+ int retval;
+
+ d = disk->data;
+
+ /*
+ * In mirror of open function, keep track of number of calls to close and
+ * send on to U-Boot only when opencount would decrease to 0.
+ */
+ if (d->opencount > 1)
+ {
+ grub_dprintf ("ubootdisk", "Closed (%s)\n", disk->name);
+
+ d->opencount--;
+ }
+ else if (d->opencount == 1)
+ {
+ retval = grub_uboot_dev_close (d->dev);
+ d->opencount--;
+ grub_dprintf ("ubootdisk", "closed %s (%d)\n", disk->name, retval);
+ }
+ else
+ {
+ grub_dprintf ("ubootdisk", "device %s not open!\n", disk->name);
+ }
+}
+
+/*
+ * uboot_disk_read():
+ * Called from within disk subsystem to read a sequence of blocks into the
+ * disk cache. Maps directly on top of U-Boot API, only wrap in some error
+ * handling.
+ */
+static grub_err_t
+uboot_disk_read (struct grub_disk *disk,
+ grub_disk_addr_t offset, grub_size_t numblocks, char *buf)
+{
+ struct ubootdisk_data *d;
+ grub_size_t real_size;
+ int retval;
+
+ d = disk->data;
+
+ retval = grub_uboot_dev_read (d->dev, buf, numblocks, offset, &real_size);
+ grub_dprintf ("ubootdisk",
+ "retval=%d, numblocks=%d, real_size=%llu, sector=%llu\n",
+ retval, numblocks, (grub_uint64_t) real_size,
+ (grub_uint64_t) offset);
+ if (retval != 0)
+ return grub_error (GRUB_ERR_IO, "U-Boot disk read error");
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+uboot_disk_write (struct grub_disk *disk,
+ grub_disk_addr_t offset, grub_size_t numblocks, const char *buf)
+{
+ struct ubootdisk_data *d;
+ int retval;
+
+ d = disk->data;
+
+ retval = grub_uboot_dev_write (d->dev, buf, numblocks, offset);
+ grub_dprintf ("ubootdisk",
+ "retval=%d, numblocks=%d, sector=%llu\n",
+ retval, numblocks, (grub_uint64_t) offset);
+
+ if (retval != 0)
+ return grub_error (GRUB_ERR_IO, "U-Boot disk write error");
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_disk_dev grub_ubootdisk_dev = {
+ .name = "ubootdisk",
+ .id = GRUB_DISK_DEVICE_UBOOTDISK_ID,
+ .disk_iterate = uboot_disk_iterate,
+ .disk_open = uboot_disk_open,
+ .disk_close = uboot_disk_close,
+ .disk_read = uboot_disk_read,
+ .disk_write = uboot_disk_write,
+ .next = 0
+};
+
+void
+grub_ubootdisk_init (void)
+{
+ grub_disk_dev_register (&grub_ubootdisk_dev);
+}
+
+void
+grub_ubootdisk_fini (void)
+{
+ grub_disk_dev_unregister (&grub_ubootdisk_dev);
+}
diff --git a/grub-core/disk/usbms.c b/grub-core/disk/usbms.c
new file mode 100644
index 0000000..380ca4c
--- /dev/null
+++ b/grub-core/disk/usbms.c
@@ -0,0 +1,660 @@
+/* usbms.c - USB Mass Storage Support. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/usb.h>
+#include <grub/scsi.h>
+#include <grub/scsicmd.h>
+#include <grub/misc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_USBMS_DIRECTION_BIT 7
+
+/* Length of CBI command should be always 12 bytes */
+#define GRUB_USBMS_CBI_CMD_SIZE 12
+/* CBI class-specific USB request ADSC - it sends CBI (scsi) command to
+ * device in DATA stage */
+#define GRUB_USBMS_CBI_ADSC_REQ 0x00
+
+/* The USB Mass Storage Command Block Wrapper. */
+struct grub_usbms_cbw
+{
+ grub_uint32_t signature;
+ grub_uint32_t tag;
+ grub_uint32_t transfer_length;
+ grub_uint8_t flags;
+ grub_uint8_t lun;
+ grub_uint8_t length;
+ grub_uint8_t cbwcb[16];
+} GRUB_PACKED;
+
+struct grub_usbms_csw
+{
+ grub_uint32_t signature;
+ grub_uint32_t tag;
+ grub_uint32_t residue;
+ grub_uint8_t status;
+} GRUB_PACKED;
+
+struct grub_usbms_dev
+{
+ struct grub_usb_device *dev;
+
+ int luns;
+
+ int config;
+ int interface;
+ struct grub_usb_desc_endp *in;
+ struct grub_usb_desc_endp *out;
+
+ int subclass;
+ int protocol;
+ struct grub_usb_desc_endp *intrpt;
+};
+typedef struct grub_usbms_dev *grub_usbms_dev_t;
+
+/* FIXME: remove limit. */
+#define MAX_USBMS_DEVICES 128
+static grub_usbms_dev_t grub_usbms_devices[MAX_USBMS_DEVICES];
+static int first_available_slot = 0;
+
+static grub_usb_err_t
+grub_usbms_cbi_cmd (grub_usb_device_t dev, int interface,
+ grub_uint8_t *cbicb)
+{
+ return grub_usb_control_msg (dev,
+ GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT,
+ GRUB_USBMS_CBI_ADSC_REQ, 0, interface,
+ GRUB_USBMS_CBI_CMD_SIZE, (char*)cbicb);
+}
+
+static grub_usb_err_t
+grub_usbms_cbi_reset (grub_usb_device_t dev, int interface)
+{
+ /* Prepare array with Command Block Reset (=CBR) */
+ /* CBI specific communication reset command should be send to device
+ * via CBI USB class specific request ADCS */
+ struct grub_cbi_reset
+ {
+ grub_uint8_t opcode; /* 0x1d = SEND DIAGNOSTIC */
+ grub_uint8_t lun; /* 7-5 LUN, 4-0 flags - for CBR always = 0x04 */
+ grub_uint8_t pad[10];
+ /* XXX: There is collision between CBI and UFI specifications:
+ * CBI says 0xff, UFI says 0x00 ... probably it does
+ * not matter ... (?) */
+ } cbicb = { 0x1d, 0x04,
+ { 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff }
+ };
+
+ return grub_usbms_cbi_cmd (dev, interface, (grub_uint8_t *)&cbicb);
+}
+
+static grub_usb_err_t
+grub_usbms_bo_reset (grub_usb_device_t dev, int interface)
+{
+ return grub_usb_control_msg (dev, 0x21, 255, 0, interface, 0, 0);
+}
+
+static grub_usb_err_t
+grub_usbms_reset (grub_usbms_dev_t dev)
+{
+ if (dev->protocol == GRUB_USBMS_PROTOCOL_BULK)
+ return grub_usbms_bo_reset (dev->dev, dev->interface);
+ else
+ return grub_usbms_cbi_reset (dev->dev, dev->interface);
+}
+
+static void
+grub_usbms_detach (grub_usb_device_t usbdev, int config, int interface)
+{
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE (grub_usbms_devices); i++)
+ if (grub_usbms_devices[i] && grub_usbms_devices[i]->dev == usbdev
+ && grub_usbms_devices[i]->interface == interface
+ && grub_usbms_devices[i]->config == config)
+ {
+ grub_free (grub_usbms_devices[i]);
+ grub_usbms_devices[i] = 0;
+ }
+}
+
+static int
+grub_usbms_attach (grub_usb_device_t usbdev, int configno, int interfno)
+{
+ struct grub_usb_desc_if *interf
+ = usbdev->config[configno].interf[interfno].descif;
+ int j;
+ grub_uint8_t luns = 0;
+ unsigned curnum;
+ grub_usb_err_t err = GRUB_USB_ERR_NONE;
+
+ grub_boot_time ("Attaching USB mass storage");
+
+ if (first_available_slot == ARRAY_SIZE (grub_usbms_devices))
+ return 0;
+
+ curnum = first_available_slot;
+ first_available_slot++;
+
+ interf = usbdev->config[configno].interf[interfno].descif;
+
+ if ((interf->subclass != GRUB_USBMS_SUBCLASS_BULK
+ /* Experimental support of RBC, MMC-2, UFI, SFF-8070i devices */
+ && interf->subclass != GRUB_USBMS_SUBCLASS_RBC
+ && interf->subclass != GRUB_USBMS_SUBCLASS_MMC2
+ && interf->subclass != GRUB_USBMS_SUBCLASS_UFI
+ && interf->subclass != GRUB_USBMS_SUBCLASS_SFF8070 )
+ || (interf->protocol != GRUB_USBMS_PROTOCOL_BULK
+ && interf->protocol != GRUB_USBMS_PROTOCOL_CBI
+ && interf->protocol != GRUB_USBMS_PROTOCOL_CB))
+ return 0;
+
+ grub_usbms_devices[curnum] = grub_zalloc (sizeof (struct grub_usbms_dev));
+ if (! grub_usbms_devices[curnum])
+ return 0;
+
+ grub_usbms_devices[curnum]->dev = usbdev;
+ grub_usbms_devices[curnum]->interface = interfno;
+ grub_usbms_devices[curnum]->subclass = interf->subclass;
+ grub_usbms_devices[curnum]->protocol = interf->protocol;
+
+ grub_dprintf ("usbms", "alive\n");
+
+ /* Iterate over all endpoints of this interface, at least a
+ IN and OUT bulk endpoint are required. */
+ for (j = 0; j < interf->endpointcnt; j++)
+ {
+ struct grub_usb_desc_endp *endp;
+ endp = &usbdev->config[0].interf[interfno].descendp[j];
+
+ if ((endp->endp_addr & 128) && (endp->attrib & 3) == 2)
+ /* Bulk IN endpoint. */
+ grub_usbms_devices[curnum]->in = endp;
+ else if (!(endp->endp_addr & 128) && (endp->attrib & 3) == 2)
+ /* Bulk OUT endpoint. */
+ grub_usbms_devices[curnum]->out = endp;
+ else if ((endp->endp_addr & 128) && (endp->attrib & 3) == 3)
+ /* Interrupt (IN) endpoint. */
+ grub_usbms_devices[curnum]->intrpt = endp;
+ }
+
+ if (!grub_usbms_devices[curnum]->in || !grub_usbms_devices[curnum]->out
+ || ((grub_usbms_devices[curnum]->protocol == GRUB_USBMS_PROTOCOL_CBI)
+ && !grub_usbms_devices[curnum]->intrpt))
+ {
+ grub_free (grub_usbms_devices[curnum]);
+ grub_usbms_devices[curnum] = 0;
+ return 0;
+ }
+
+ grub_dprintf ("usbms", "alive\n");
+
+ /* XXX: Activate the first configuration. */
+ grub_usb_set_configuration (usbdev, 1);
+
+ /* Query the amount of LUNs. */
+ if (grub_usbms_devices[curnum]->protocol == GRUB_USBMS_PROTOCOL_BULK)
+ { /* Only Bulk only devices support Get Max LUN command */
+ err = grub_usb_control_msg (usbdev, 0xA1, 254, 0, interfno, 1, (char *) &luns);
+
+ if (err)
+ {
+ /* In case of a stall, clear the stall. */
+ if (err == GRUB_USB_ERR_STALL)
+ {
+ grub_usb_clear_halt (usbdev, grub_usbms_devices[curnum]->in->endp_addr);
+ grub_usb_clear_halt (usbdev, grub_usbms_devices[curnum]->out->endp_addr);
+ }
+ /* Just set the amount of LUNs to one. */
+ grub_errno = GRUB_ERR_NONE;
+ grub_usbms_devices[curnum]->luns = 1;
+ }
+ else
+ /* luns = 0 means one LUN with ID 0 present ! */
+ /* We get from device not number of LUNs but highest
+ * LUN number. LUNs are numbered from 0,
+ * i.e. number of LUNs is luns+1 ! */
+ grub_usbms_devices[curnum]->luns = luns + 1;
+ }
+ else
+ /* XXX: Does CBI devices support multiple LUNs ?
+ * I.e., should we detect number of device's LUNs ? (How?) */
+ grub_usbms_devices[curnum]->luns = 1;
+
+ grub_dprintf ("usbms", "alive\n");
+
+ usbdev->config[configno].interf[interfno].detach_hook = grub_usbms_detach;
+
+ grub_boot_time ("Attached USB mass storage");
+
+#if 0 /* All this part should be probably deleted.
+ * This make trouble on some devices if they are not in
+ * Phase Error state - and there they should be not in such state...
+ * Bulk only mass storage reset procedure should be used only
+ * on place and in time when it is really necessary. */
+ /* Reset recovery procedure */
+ /* Bulk-Only Mass Storage Reset, after the reset commands
+ will be accepted. */
+ grub_usbms_reset (usbdev, i);
+ grub_usb_clear_halt (usbdev, usbms->in->endp_addr);
+ grub_usb_clear_halt (usbdev, usbms->out->endp_addr);
+#endif
+
+ return 1;
+}
+
+
+
+static int
+grub_usbms_iterate (grub_scsi_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ unsigned i;
+
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ grub_usb_poll_devices (1);
+
+ for (i = 0; i < ARRAY_SIZE (grub_usbms_devices); i++)
+ if (grub_usbms_devices[i])
+ {
+ if (hook (GRUB_SCSI_SUBSYSTEM_USBMS, i, grub_usbms_devices[i]->luns,
+ hook_data))
+ return 1;
+ }
+
+ return 0;
+}
+
+static grub_err_t
+grub_usbms_transfer_bo (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
+ grub_size_t size, char *buf, int read_write)
+{
+ struct grub_usbms_cbw cbw;
+ grub_usbms_dev_t dev = (grub_usbms_dev_t) scsi->data;
+ struct grub_usbms_csw status;
+ static grub_uint32_t tag = 0;
+ grub_usb_err_t err = GRUB_USB_ERR_NONE;
+ grub_usb_err_t errCSW = GRUB_USB_ERR_NONE;
+ int retrycnt = 3 + 1;
+
+ tag++;
+
+ retry:
+ retrycnt--;
+ if (retrycnt == 0)
+ return grub_error (GRUB_ERR_IO, "USB Mass Storage stalled");
+
+ /* Setup the request. */
+ grub_memset (&cbw, 0, sizeof (cbw));
+ 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;
+ cbw.lun = scsi->lun; /* In USB MS CBW are LUN bits on another place than in SCSI CDB, both should be set correctly. */
+ cbw.length = cmdsize;
+ grub_memcpy (cbw.cbwcb, cmd, cmdsize);
+
+ /* Debug print of CBW content. */
+ grub_dprintf ("usb", "CBW: sign=0x%08x tag=0x%08x len=0x%08x\n",
+ cbw.signature, cbw.tag, cbw.transfer_length);
+ grub_dprintf ("usb", "CBW: flags=0x%02x lun=0x%02x CB_len=0x%02x\n",
+ cbw.flags, cbw.lun, cbw.length);
+ grub_dprintf ("usb", "CBW: cmd:\n %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ cbw.cbwcb[ 0], cbw.cbwcb[ 1], cbw.cbwcb[ 2], cbw.cbwcb[ 3],
+ cbw.cbwcb[ 4], cbw.cbwcb[ 5], cbw.cbwcb[ 6], cbw.cbwcb[ 7],
+ cbw.cbwcb[ 8], cbw.cbwcb[ 9], cbw.cbwcb[10], cbw.cbwcb[11],
+ cbw.cbwcb[12], cbw.cbwcb[13], cbw.cbwcb[14], cbw.cbwcb[15]);
+
+ /* Write the request.
+ * XXX: Error recovery is maybe still not fully correct. */
+ err = grub_usb_bulk_write (dev->dev, dev->out,
+ sizeof (cbw), (char *) &cbw);
+ if (err)
+ {
+ if (err == GRUB_USB_ERR_STALL)
+ {
+ grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
+ goto CheckCSW;
+ }
+ goto retry;
+ }
+
+ /* Read/write the data, (maybe) according to specification. */
+ if (size && (read_write == 0))
+ {
+ err = grub_usb_bulk_read (dev->dev, dev->in, size, buf);
+ grub_dprintf ("usb", "read: %d %d\n", err, GRUB_USB_ERR_STALL);
+ if (err)
+ {
+ if (err == GRUB_USB_ERR_STALL)
+ grub_usb_clear_halt (dev->dev, dev->in->endp_addr);
+ goto CheckCSW;
+ }
+ /* Debug print of received data. */
+ grub_dprintf ("usb", "buf:\n");
+ if (size <= 64)
+ {
+ unsigned i;
+ for (i = 0; i < size; i++)
+ grub_dprintf ("usb", "0x%02x: 0x%02x\n", i, buf[i]);
+ }
+ else
+ grub_dprintf ("usb", "Too much data for debug print...\n");
+ }
+ else if (size)
+ {
+ err = grub_usb_bulk_write (dev->dev, dev->out, size, buf);
+ grub_dprintf ("usb", "write: %d %d\n", err, GRUB_USB_ERR_STALL);
+ grub_dprintf ("usb", "First 16 bytes of sent data:\n %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ buf[ 0], buf[ 1], buf[ 2], buf[ 3],
+ buf[ 4], buf[ 5], buf[ 6], buf[ 7],
+ buf[ 8], buf[ 9], buf[10], buf[11],
+ buf[12], buf[13], buf[14], buf[15]);
+ if (err)
+ {
+ if (err == GRUB_USB_ERR_STALL)
+ grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
+ goto CheckCSW;
+ }
+ /* Debug print of sent data. */
+ if (size <= 256)
+ {
+ unsigned i;
+ for (i=0; i<size; i++)
+ grub_dprintf ("usb", "0x%02x: 0x%02x\n", i, buf[i]);
+ }
+ else
+ grub_dprintf ("usb", "Too much data for debug print...\n");
+ }
+
+ /* Read the status - (maybe) according to specification. */
+CheckCSW:
+ errCSW = grub_usb_bulk_read (dev->dev, dev->in,
+ sizeof (status), (char *) &status);
+ if (errCSW)
+ {
+ grub_usb_clear_halt (dev->dev, dev->in->endp_addr);
+ errCSW = grub_usb_bulk_read (dev->dev, dev->in,
+ sizeof (status), (char *) &status);
+ if (errCSW)
+ { /* Bulk-only reset device. */
+ grub_dprintf ("usb", "Bulk-only reset device - errCSW\n");
+ grub_usbms_reset (dev);
+ grub_usb_clear_halt (dev->dev, dev->in->endp_addr);
+ grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
+ goto retry;
+ }
+ }
+
+ /* Debug print of CSW content. */
+ grub_dprintf ("usb", "CSW: sign=0x%08x tag=0x%08x resid=0x%08x\n",
+ status.signature, status.tag, status.residue);
+ grub_dprintf ("usb", "CSW: status=0x%02x\n", status.status);
+
+ /* If phase error or not valid signature, do bulk-only reset device. */
+ if ((status.status == 2) ||
+ (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);
+ grub_usb_clear_halt (dev->dev, dev->in->endp_addr);
+ grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
+
+ goto retry;
+ }
+
+ /* If "command failed" status or data transfer failed -> error */
+ if ((status.status || err) && !read_write)
+ return grub_error (GRUB_ERR_READ_ERROR,
+ "error communication with USB Mass Storage device");
+ else if ((status.status || err) && read_write)
+ return grub_error (GRUB_ERR_WRITE_ERROR,
+ "error communication with USB Mass Storage device");
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_usbms_transfer_cbi (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
+ grub_size_t size, char *buf, int read_write)
+{
+ grub_usbms_dev_t dev = (grub_usbms_dev_t) scsi->data;
+ int retrycnt = 3 + 1;
+ grub_usb_err_t err = GRUB_USB_ERR_NONE;
+ grub_uint8_t cbicb[GRUB_USBMS_CBI_CMD_SIZE];
+ grub_uint16_t status;
+
+ retry:
+ retrycnt--;
+ if (retrycnt == 0)
+ return grub_error (GRUB_ERR_IO, "USB Mass Storage CBI failed");
+
+ /* Setup the request. */
+ grub_memset (cbicb, 0, sizeof (cbicb));
+ grub_memcpy (cbicb, cmd,
+ cmdsize >= GRUB_USBMS_CBI_CMD_SIZE
+ ? GRUB_USBMS_CBI_CMD_SIZE
+ : cmdsize);
+
+ /* Debug print of CBIcb content. */
+ grub_dprintf ("usb", "cbicb:\n %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ cbicb[ 0], cbicb[ 1], cbicb[ 2], cbicb[ 3],
+ cbicb[ 4], cbicb[ 5], cbicb[ 6], cbicb[ 7],
+ cbicb[ 8], cbicb[ 9], cbicb[10], cbicb[11]);
+
+ /* Write the request.
+ * XXX: Error recovery is maybe not correct. */
+ err = grub_usbms_cbi_cmd (dev->dev, dev->interface, cbicb);
+ if (err)
+ {
+ grub_dprintf ("usb", "CBI cmdcb setup err=%d\n", err);
+ if (err == GRUB_USB_ERR_STALL)
+ {
+ /* Stall in this place probably means bad or unsupported
+ * command, so we will not try it again. */
+ return grub_error (GRUB_ERR_IO, "USB Mass Storage CBI request failed");
+ }
+ else if (dev->protocol == GRUB_USBMS_PROTOCOL_CBI)
+ {
+ /* Try to get status from interrupt pipe */
+ err = grub_usb_bulk_read (dev->dev, dev->intrpt,
+ 2, (char*)&status);
+ grub_dprintf ("usb", "CBI cmdcb setup status: err=%d, status=0x%x\n", err, status);
+ }
+ /* Any other error could be transport problem, try it again */
+ goto retry;
+ }
+
+ /* Read/write the data, (maybe) according to specification. */
+ if (size && (read_write == 0))
+ {
+ err = grub_usb_bulk_read (dev->dev, dev->in, size, buf);
+ grub_dprintf ("usb", "read: %d\n", err);
+ if (err)
+ {
+ if (err == GRUB_USB_ERR_STALL)
+ grub_usb_clear_halt (dev->dev, dev->in->endp_addr);
+ goto retry;
+ }
+ }
+ else if (size)
+ {
+ err = grub_usb_bulk_write (dev->dev, dev->out, size, buf);
+ grub_dprintf ("usb", "write: %d\n", err);
+ if (err)
+ {
+ if (err == GRUB_USB_ERR_STALL)
+ grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
+ goto retry;
+ }
+ }
+
+ /* XXX: It is not clear to me yet, how to check status of CBI
+ * data transfer on devices without interrupt pipe.
+ * AFAIK there is probably no status phase to indicate possibly
+ * bad transported data.
+ * Maybe we should do check on higher level, i.e. issue RequestSense
+ * command (we do it already in scsi.c) and check returned values
+ * (we do not it yet) - ? */
+ if (dev->protocol == GRUB_USBMS_PROTOCOL_CBI)
+ { /* Check status in interrupt pipe */
+ err = grub_usb_bulk_read (dev->dev, dev->intrpt,
+ 2, (char*)&status);
+ grub_dprintf ("usb", "read status: %d\n", err);
+ if (err)
+ {
+ /* Try to reset device, because it is probably not standard
+ * situation */
+ grub_usbms_reset (dev);
+ grub_usb_clear_halt (dev->dev, dev->in->endp_addr);
+ grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
+ grub_usb_clear_halt (dev->dev, dev->intrpt->endp_addr);
+ goto retry;
+ }
+ if (dev->subclass == GRUB_USBMS_SUBCLASS_UFI)
+ {
+ /* These devices should return bASC and bASCQ */
+ if (status != 0)
+ /* Some error, currently we don't care what it is... */
+ goto retry;
+ }
+ else if (dev->subclass == GRUB_USBMS_SUBCLASS_RBC)
+ {
+ /* XXX: I don't understand what returns RBC subclass devices,
+ * so I don't check it - maybe somebody helps ? */
+ }
+ else
+ {
+ /* Any other device should return bType = 0 and some bValue */
+ if (status & 0xff)
+ return grub_error (GRUB_ERR_IO, "USB Mass Storage CBI status type != 0");
+ status = (status & 0x0300) >> 8;
+ switch (status)
+ {
+ case 0 : /* OK */
+ break;
+ case 1 : /* Fail */
+ goto retry;
+ break;
+ case 2 : /* Phase error */
+ case 3 : /* Persistent Failure */
+ grub_dprintf ("usb", "CBI reset device - phase error or persistent failure\n");
+ grub_usbms_reset (dev);
+ grub_usb_clear_halt (dev->dev, dev->in->endp_addr);
+ grub_usb_clear_halt (dev->dev, dev->out->endp_addr);
+ grub_usb_clear_halt (dev->dev, dev->intrpt->endp_addr);
+ goto retry;
+ break;
+ }
+ }
+ }
+
+ if (err)
+ return grub_error (GRUB_ERR_IO, "USB error %d", err);
+
+ return GRUB_ERR_NONE;
+}
+
+
+static grub_err_t
+grub_usbms_transfer (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
+ grub_size_t size, char *buf, int read_write)
+{
+ grub_usbms_dev_t dev = (grub_usbms_dev_t) scsi->data;
+
+ if (dev->protocol == GRUB_USBMS_PROTOCOL_BULK)
+ return grub_usbms_transfer_bo (scsi, cmdsize, cmd, size, buf,
+ read_write);
+ else
+ return grub_usbms_transfer_cbi (scsi, cmdsize, cmd, size, buf,
+ read_write);
+}
+
+static grub_err_t
+grub_usbms_read (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
+ grub_size_t size, char *buf)
+{
+ return grub_usbms_transfer (scsi, cmdsize, cmd, size, buf, 0);
+}
+
+static grub_err_t
+grub_usbms_write (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
+ grub_size_t size, const char *buf)
+{
+ return grub_usbms_transfer (scsi, cmdsize, cmd, size, (char *) buf, 1);
+}
+
+static grub_err_t
+grub_usbms_open (int id, int devnum, struct grub_scsi *scsi)
+{
+ if (id != GRUB_SCSI_SUBSYSTEM_USBMS)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "not USB Mass Storage device");
+
+ if (!grub_usbms_devices[devnum])
+ grub_usb_poll_devices (1);
+
+ if (!grub_usbms_devices[devnum])
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "unknown USB Mass Storage device");
+
+ scsi->data = grub_usbms_devices[devnum];
+ scsi->luns = grub_usbms_devices[devnum]->luns;
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_scsi_dev grub_usbms_dev =
+ {
+ .iterate = grub_usbms_iterate,
+ .open = grub_usbms_open,
+ .read = grub_usbms_read,
+ .write = grub_usbms_write
+ };
+
+static struct grub_usb_attach_desc attach_hook =
+{
+ .class = GRUB_USB_CLASS_MASS_STORAGE,
+ .hook = grub_usbms_attach
+};
+
+GRUB_MOD_INIT(usbms)
+{
+ grub_usb_register_attach_hook_class (&attach_hook);
+ grub_scsi_dev_register (&grub_usbms_dev);
+}
+
+GRUB_MOD_FINI(usbms)
+{
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE (grub_usbms_devices); i++)
+ {
+ grub_usbms_devices[i]->dev->config[grub_usbms_devices[i]->config]
+ .interf[grub_usbms_devices[i]->interface].detach_hook = 0;
+ grub_usbms_devices[i]->dev->config[grub_usbms_devices[i]->config]
+ .interf[grub_usbms_devices[i]->interface].attached = 0;
+ }
+ grub_usb_unregister_attach_hook_class (&attach_hook);
+ grub_scsi_dev_unregister (&grub_usbms_dev);
+}
diff --git a/grub-core/disk/xen/xendisk.c b/grub-core/disk/xen/xendisk.c
new file mode 100644
index 0000000..d6612ee
--- /dev/null
+++ b/grub-core/disk/xen/xendisk.c
@@ -0,0 +1,485 @@
+/*
+ * 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/disk.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/term.h>
+#include <grub/i18n.h>
+#include <grub/xen.h>
+#include <grub/time.h>
+#include <xen/io/blkif.h>
+
+struct virtdisk
+{
+ int handle;
+ char *fullname;
+ char *backend_dir;
+ char *frontend_dir;
+ struct blkif_sring *shared_page;
+ struct blkif_front_ring ring;
+ grub_xen_grant_t grant;
+ grub_xen_evtchn_t evtchn;
+ void *dma_page;
+ grub_xen_grant_t dma_grant;
+ struct virtdisk *compat_next;
+};
+
+#define xen_wmb() mb()
+#define xen_mb() mb()
+
+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,
+ grub_disk_pull_t pull)
+{
+ grub_size_t i;
+
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ for (i = 0; i < vdiskcnt; i++)
+ if (hook (virtdisks[i].fullname, hook_data))
+ return 1;
+ return 0;
+}
+
+static grub_err_t
+grub_virtdisk_open (const char *name, grub_disk_t disk)
+{
+ int i;
+ grub_uint32_t secsize;
+ char fdir[200];
+ char *buf;
+ int num = -1;
+ struct virtdisk *vd;
+
+ /* 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 (!vd)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk");
+ disk->data = vd;
+ disk->id = vd - virtdisks;
+
+ grub_snprintf (fdir, sizeof (fdir), "%s/sectors", vd->backend_dir);
+ buf = grub_xenstore_get_file (fdir, NULL);
+ if (!buf)
+ return grub_errno;
+ disk->total_sectors = grub_strtoull (buf, 0, 10);
+ if (grub_errno)
+ return grub_errno;
+
+ grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", vd->backend_dir);
+ buf = grub_xenstore_get_file (fdir, NULL);
+ if (!buf)
+ return grub_errno;
+ secsize = grub_strtoull (buf, 0, 10);
+ if (grub_errno)
+ return grub_errno;
+
+ if ((secsize & (secsize - 1)) || !secsize || secsize < 512
+ || secsize > GRUB_XEN_PAGE_SIZE)
+ return grub_error (GRUB_ERR_IO, "unsupported sector size %d", secsize);
+
+ for (disk->log_sector_size = 0;
+ (1U << disk->log_sector_size) < secsize; disk->log_sector_size++);
+
+ disk->total_sectors >>= disk->log_sector_size - 9;
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_virtdisk_close (grub_disk_t disk __attribute__ ((unused)))
+{
+}
+
+static grub_err_t
+grub_virtdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ struct virtdisk *data = disk->data;
+
+ while (size)
+ {
+ grub_size_t cur;
+ struct blkif_request *req;
+ struct blkif_response *resp;
+ int sta = 0;
+ struct evtchn_send send;
+ cur = size;
+ if (cur > (unsigned) (GRUB_XEN_PAGE_SIZE >> disk->log_sector_size))
+ cur = GRUB_XEN_PAGE_SIZE >> disk->log_sector_size;
+ while (RING_FULL (&data->ring))
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ req = RING_GET_REQUEST (&data->ring, data->ring.req_prod_pvt);
+ req->operation = BLKIF_OP_READ;
+ req->nr_segments = 1;
+ req->handle = data->handle;
+ req->id = 0;
+ req->sector_number = sector << (disk->log_sector_size - 9);
+ req->seg[0].gref = data->dma_grant;
+ req->seg[0].first_sect = 0;
+ req->seg[0].last_sect = (cur << (disk->log_sector_size - 9)) - 1;
+ data->ring.req_prod_pvt++;
+ RING_PUSH_REQUESTS (&data->ring);
+ mb ();
+ send.port = data->evtchn;
+ grub_xen_event_channel_op (EVTCHNOP_send, &send);
+
+ while (!RING_HAS_UNCONSUMED_RESPONSES (&data->ring))
+ {
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ mb ();
+ }
+ while (1)
+ {
+ int wtd;
+ RING_FINAL_CHECK_FOR_RESPONSES (&data->ring, wtd);
+ if (!wtd)
+ break;
+ resp = RING_GET_RESPONSE (&data->ring, data->ring.rsp_cons);
+ data->ring.rsp_cons++;
+ if (resp->status)
+ sta = resp->status;
+ }
+ if (sta)
+ return grub_error (GRUB_ERR_IO, "read failed");
+ grub_memcpy (buf, data->dma_page, cur << disk->log_sector_size);
+ size -= cur;
+ sector += cur;
+ buf += cur << disk->log_sector_size;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_virtdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, const char *buf)
+{
+ struct virtdisk *data = disk->data;
+
+ while (size)
+ {
+ grub_size_t cur;
+ struct blkif_request *req;
+ struct blkif_response *resp;
+ int sta = 0;
+ struct evtchn_send send;
+ cur = size;
+ if (cur > (unsigned) (GRUB_XEN_PAGE_SIZE >> disk->log_sector_size))
+ cur = GRUB_XEN_PAGE_SIZE >> disk->log_sector_size;
+
+ grub_memcpy (data->dma_page, buf, cur << disk->log_sector_size);
+
+ while (RING_FULL (&data->ring))
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ req = RING_GET_REQUEST (&data->ring, data->ring.req_prod_pvt);
+ req->operation = BLKIF_OP_WRITE;
+ req->nr_segments = 1;
+ req->handle = data->handle;
+ req->id = 0;
+ req->sector_number = sector << (disk->log_sector_size - 9);
+ req->seg[0].gref = data->dma_grant;
+ req->seg[0].first_sect = 0;
+ req->seg[0].last_sect = (cur << (disk->log_sector_size - 9)) - 1;
+ data->ring.req_prod_pvt++;
+ RING_PUSH_REQUESTS (&data->ring);
+ mb ();
+ send.port = data->evtchn;
+ grub_xen_event_channel_op (EVTCHNOP_send, &send);
+
+ while (!RING_HAS_UNCONSUMED_RESPONSES (&data->ring))
+ {
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ mb ();
+ }
+ while (1)
+ {
+ int wtd;
+ RING_FINAL_CHECK_FOR_RESPONSES (&data->ring, wtd);
+ if (!wtd)
+ break;
+ resp = RING_GET_RESPONSE (&data->ring, data->ring.rsp_cons);
+ data->ring.rsp_cons++;
+ if (resp->status)
+ sta = resp->status;
+ }
+ if (sta)
+ return grub_error (GRUB_ERR_IO, "write failed");
+ size -= cur;
+ sector += cur;
+ buf += cur << disk->log_sector_size;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_disk_dev grub_virtdisk_dev = {
+ .name = "xen",
+ .id = GRUB_DISK_DEVICE_XEN,
+ .disk_iterate = grub_virtdisk_iterate,
+ .disk_open = grub_virtdisk_open,
+ .disk_close = grub_virtdisk_close,
+ .disk_read = grub_virtdisk_read,
+ .disk_write = grub_virtdisk_write,
+ .next = 0
+};
+
+static int
+count (const char *dir __attribute__ ((unused)), void *data)
+{
+ grub_size_t *ctr = data;
+ (*ctr)++;
+
+ return 0;
+}
+
+static int
+fill (const char *dir, void *data)
+{
+ grub_size_t *ctr = data;
+ domid_t dom;
+ /* "dir" is just a number, at most 19 characters. */
+ char fdir[200];
+ char num[20];
+ 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)
+ return 1;
+ virtdisks[vdiskcnt].handle = grub_strtoul (dir, 0, 10);
+ if (grub_errno)
+ {
+ grub_errno = 0;
+ return 0;
+ }
+ virtdisks[vdiskcnt].fullname = 0;
+ virtdisks[vdiskcnt].backend_dir = 0;
+
+ grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/backend", dir);
+ virtdisks[vdiskcnt].backend_dir = grub_xenstore_get_file (fdir, NULL);
+ if (!virtdisks[vdiskcnt].backend_dir)
+ goto out_fail_1;
+
+ grub_snprintf (fdir, sizeof (fdir), "%s/dev",
+ virtdisks[vdiskcnt].backend_dir);
+ buf = grub_xenstore_get_file (fdir, NULL);
+ if (!buf)
+ {
+ grub_errno = 0;
+ virtdisks[vdiskcnt].fullname = grub_xasprintf ("xenid/%s", dir);
+ }
+ else
+ {
+ virtdisks[vdiskcnt].fullname = grub_xasprintf ("xen/%s", (char *) buf);
+ grub_free (buf);
+ }
+ if (!virtdisks[vdiskcnt].fullname)
+ goto out_fail_1;
+
+ grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/backend-id", dir);
+ buf = grub_xenstore_get_file (fdir, NULL);
+ if (!buf)
+ goto out_fail_1;
+
+ dom = grub_strtoul (buf, 0, 10);
+ grub_free (buf);
+ if (grub_errno)
+ goto out_fail_1;
+
+ virtdisks[vdiskcnt].shared_page =
+ grub_xen_alloc_shared_page (dom, &virtdisks[vdiskcnt].grant);
+ if (!virtdisks[vdiskcnt].shared_page)
+ goto out_fail_1;
+
+ virtdisks[vdiskcnt].dma_page =
+ grub_xen_alloc_shared_page (dom, &virtdisks[vdiskcnt].dma_grant);
+ if (!virtdisks[vdiskcnt].dma_page)
+ goto out_fail_2;
+
+ alloc_unbound.dom = DOMID_SELF;
+ alloc_unbound.remote_dom = dom;
+
+ grub_xen_event_channel_op (EVTCHNOP_alloc_unbound, &alloc_unbound);
+ virtdisks[vdiskcnt].evtchn = alloc_unbound.port;
+
+ SHARED_RING_INIT (virtdisks[vdiskcnt].shared_page);
+ FRONT_RING_INIT (&virtdisks[vdiskcnt].ring, virtdisks[vdiskcnt].shared_page,
+ GRUB_XEN_PAGE_SIZE);
+
+ grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/ring-ref", dir);
+ grub_snprintf (num, sizeof (num), "%u", virtdisks[vdiskcnt].grant);
+ err = grub_xenstore_write_file (fdir, num, grub_strlen (num));
+ if (err)
+ goto out_fail_3;
+
+ grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/event-channel", dir);
+ grub_snprintf (num, sizeof (num), "%u", virtdisks[vdiskcnt].evtchn);
+ err = grub_xenstore_write_file (fdir, num, grub_strlen (num));
+ if (err)
+ goto out_fail_3;
+
+ grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/protocol", dir);
+ err = grub_xenstore_write_file (fdir, XEN_IO_PROTO_ABI_NATIVE,
+ grub_strlen (XEN_IO_PROTO_ABI_NATIVE));
+ if (err)
+ goto out_fail_3;
+
+ struct gnttab_dump_table dt;
+ dt.dom = DOMID_SELF;
+ grub_xen_grant_table_op (GNTTABOP_dump_table, (void *) &dt, 1);
+
+ grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s/state", dir);
+ err = grub_xenstore_write_file (fdir, "3", 1);
+ if (err)
+ goto out_fail_3;
+
+ while (1)
+ {
+ grub_snprintf (fdir, sizeof (fdir), "%s/state",
+ virtdisks[vdiskcnt].backend_dir);
+ buf = grub_xenstore_get_file (fdir, NULL);
+ if (!buf)
+ goto out_fail_3;
+ if (grub_strcmp (buf, "2") != 0)
+ break;
+ grub_free (buf);
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ }
+ grub_dprintf ("xen", "state=%s\n", (char *) buf);
+ grub_free (buf);
+
+ grub_snprintf (fdir, sizeof (fdir), "device/vbd/%s", dir);
+
+ 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;
+
+out_fail_3:
+ grub_xen_free_shared_page (virtdisks[vdiskcnt].dma_page);
+out_fail_2:
+ grub_xen_free_shared_page (virtdisks[vdiskcnt].shared_page);
+out_fail_1:
+ grub_free (virtdisks[vdiskcnt].backend_dir);
+ grub_free (virtdisks[vdiskcnt].fullname);
+
+ grub_errno = 0;
+ return 0;
+}
+
+void
+grub_xendisk_init (void)
+{
+ grub_size_t ctr = 0;
+ if (grub_xenstore_dir ("device/vbd", count, &ctr))
+ grub_errno = 0;
+
+ if (!ctr)
+ return;
+
+ virtdisks = grub_calloc (ctr, sizeof (virtdisks[0]));
+ if (!virtdisks)
+ return;
+ if (grub_xenstore_dir ("device/vbd", fill, &ctr))
+ grub_errno = 0;
+
+ grub_disk_dev_register (&grub_virtdisk_dev);
+}
+
+void
+grub_xendisk_fini (void)
+{
+ char fdir[200];
+ unsigned i;
+
+ for (i = 0; i < vdiskcnt; i++)
+ {
+ char *buf;
+ struct evtchn_close close_op = {.port = virtdisks[i].evtchn };
+
+ grub_snprintf (fdir, sizeof (fdir), "%s/state",
+ virtdisks[i].frontend_dir);
+ grub_xenstore_write_file (fdir, "6", 1);
+
+ while (1)
+ {
+ grub_snprintf (fdir, sizeof (fdir), "%s/state",
+ virtdisks[i].backend_dir);
+ buf = grub_xenstore_get_file (fdir, NULL);
+ grub_dprintf ("xen", "state=%s\n", (char *) buf);
+
+ if (!buf || grub_strcmp (buf, "6") == 0)
+ break;
+ grub_free (buf);
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ }
+ grub_free (buf);
+
+ grub_snprintf (fdir, sizeof (fdir), "%s/ring-ref",
+ virtdisks[i].frontend_dir);
+ grub_xenstore_write_file (fdir, NULL, 0);
+
+ grub_snprintf (fdir, sizeof (fdir), "%s/event-channel",
+ virtdisks[i].frontend_dir);
+ grub_xenstore_write_file (fdir, NULL, 0);
+
+ grub_xen_free_shared_page (virtdisks[i].dma_page);
+ grub_xen_free_shared_page (virtdisks[i].shared_page);
+
+ grub_xen_event_channel_op (EVTCHNOP_close, &close_op);
+
+ /* Prepare for handoff. */
+ grub_snprintf (fdir, sizeof (fdir), "%s/state",
+ virtdisks[i].frontend_dir);
+ grub_xenstore_write_file (fdir, "1", 1);
+ }
+}
diff --git a/grub-core/efiemu/i386/coredetect.c b/grub-core/efiemu/i386/coredetect.c
new file mode 100644
index 0000000..a262b53
--- /dev/null
+++ b/grub-core/efiemu/i386/coredetect.c
@@ -0,0 +1,27 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/efiemu/efiemu.h>
+#include <grub/command.h>
+#include <grub/i386/cpuid.h>
+
+const char *
+grub_efiemu_get_default_core_name (void)
+{
+ return grub_cpuid_has_longmode ? "efiemu64.o" : "efiemu32.o";
+}
diff --git a/grub-core/efiemu/i386/loadcore32.c b/grub-core/efiemu/i386/loadcore32.c
new file mode 100644
index 0000000..e746df8
--- /dev/null
+++ b/grub-core/efiemu/i386/loadcore32.c
@@ -0,0 +1,121 @@
+/* i386 CPU-specific part of loadcore.c for 32-bit mode */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/cpu/efiemu.h>
+#include <grub/elf.h>
+#include <grub/i18n.h>
+
+/* Check if EHDR is a valid ELF header. */
+int
+grub_arch_efiemu_check_header32 (void *ehdr)
+{
+ Elf32_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+ return (e->e_ident[EI_CLASS] == ELFCLASS32
+ && e->e_ident[EI_DATA] == ELFDATA2LSB
+ && e->e_machine == EM_386);
+}
+
+/* Relocate symbols. */
+grub_err_t
+grub_arch_efiemu_relocate_symbols32 (grub_efiemu_segment_t segs,
+ struct grub_efiemu_elf_sym *elfsyms,
+ void *ehdr)
+{
+ unsigned i;
+ Elf32_Ehdr *e = ehdr;
+ Elf32_Shdr *s;
+ grub_err_t err;
+
+ grub_dprintf ("efiemu", "relocating symbols %d %d\n",
+ e->e_shoff, e->e_shnum);
+
+ for (i = 0, s = (Elf32_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize))
+ if (s->sh_type == SHT_REL)
+ {
+ grub_efiemu_segment_t seg;
+ grub_dprintf ("efiemu", "shtrel\n");
+
+ /* Find the target segment. */
+ for (seg = segs; seg; seg = seg->next)
+ if (seg->section == s->sh_info)
+ break;
+
+ if (seg)
+ {
+ Elf32_Rel *rel, *max;
+
+ for (rel = (Elf32_Rel *) ((char *) e + s->sh_offset),
+ max = rel + s->sh_size / s->sh_entsize;
+ rel < max;
+ rel++)
+ {
+ Elf32_Word *addr;
+ struct grub_efiemu_elf_sym sym;
+ if (seg->size < rel->r_offset)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ addr = (Elf32_Word *)
+ ((char *) grub_efiemu_mm_obtain_request (seg->handle)
+ + seg->off + rel->r_offset);
+ sym = elfsyms[ELF32_R_SYM (rel->r_info)];
+
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_386_32:
+ err = grub_efiemu_write_value (addr, sym.off + *addr,
+ sym.handle, 0,
+ seg->ptv_rel_needed,
+ sizeof (grub_uint32_t));
+ if (err)
+ return err;
+
+ break;
+
+ case R_386_PC32:
+ err = grub_efiemu_write_value (addr, sym.off + *addr
+ - rel->r_offset
+ - seg->off, sym.handle,
+ seg->handle,
+ seg->ptv_rel_needed,
+ sizeof (grub_uint32_t));
+ if (err)
+ return err;
+ break;
+ default:
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%x is not implemented yet"),
+ ELF_R_TYPE (rel->r_info));
+ }
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+
diff --git a/grub-core/efiemu/i386/loadcore64.c b/grub-core/efiemu/i386/loadcore64.c
new file mode 100644
index 0000000..ae476ef
--- /dev/null
+++ b/grub-core/efiemu/i386/loadcore64.c
@@ -0,0 +1,138 @@
+/* i386 CPU-specific part of loadcore.c for 32-bit mode */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/cpu/efiemu.h>
+#include <grub/elf.h>
+#include <grub/i18n.h>
+
+/* Check if EHDR is a valid ELF header. */
+int
+grub_arch_efiemu_check_header64 (void *ehdr)
+{
+ Elf64_Ehdr *e = ehdr;
+
+ return (e->e_ident[EI_CLASS] == ELFCLASS64
+ && e->e_ident[EI_DATA] == ELFDATA2LSB
+ && e->e_machine == EM_X86_64);
+}
+
+/* Relocate symbols. */
+grub_err_t
+grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
+ struct grub_efiemu_elf_sym *elfsyms,
+ void *ehdr)
+{
+ unsigned i;
+ Elf64_Ehdr *e = ehdr;
+ Elf64_Shdr *s;
+ grub_err_t err;
+
+ for (i = 0, s = (Elf64_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf64_Shdr *) ((char *) s + e->e_shentsize))
+ if (s->sh_type == SHT_RELA)
+ {
+ grub_efiemu_segment_t seg;
+ grub_dprintf ("efiemu", "shtrel\n");
+
+ /* Find the target segment. */
+ for (seg = segs; seg; seg = seg->next)
+ if (seg->section == s->sh_info)
+ break;
+
+ if (seg)
+ {
+ Elf64_Rela *rel, *max;
+
+ for (rel = (Elf64_Rela *) ((char *) e + s->sh_offset),
+ max = rel + (unsigned long) s->sh_size
+ / (unsigned long)s->sh_entsize;
+ rel < max;
+ rel++)
+ {
+ void *addr;
+ grub_uint32_t *addr32;
+ grub_uint64_t *addr64;
+ struct grub_efiemu_elf_sym sym;
+ if (seg->size < rel->r_offset)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ addr =
+ ((char *) grub_efiemu_mm_obtain_request (seg->handle)
+ + seg->off + rel->r_offset);
+ addr32 = (grub_uint32_t *) addr;
+ addr64 = (grub_uint64_t *) addr;
+ sym = elfsyms[ELF64_R_SYM (rel->r_info)];
+
+ switch (ELF64_R_TYPE (rel->r_info))
+ {
+ case R_X86_64_64:
+ err = grub_efiemu_write_value (addr,
+ *addr64 + rel->r_addend
+ + sym.off, sym.handle,
+ 0, seg->ptv_rel_needed,
+ sizeof (grub_uint64_t));
+ if (err)
+ return err;
+ break;
+
+ case R_X86_64_PC32:
+ case R_X86_64_PLT32:
+ err = grub_efiemu_write_value (addr,
+ *addr32 + rel->r_addend
+ + sym.off
+ - rel->r_offset - seg->off,
+ sym.handle, seg->handle,
+ seg->ptv_rel_needed,
+ sizeof (grub_uint32_t));
+ if (err)
+ return err;
+ break;
+
+ case R_X86_64_32:
+ case R_X86_64_32S:
+ err = grub_efiemu_write_value (addr,
+ *addr32 + rel->r_addend
+ + sym.off, sym.handle,
+ 0, seg->ptv_rel_needed,
+ sizeof (grub_uint32_t));
+ if (err)
+ return err;
+ break;
+ default:
+ {
+ char rel_info[17]; /* log16(2^64) = 16, plus NUL. */
+
+ grub_snprintf (rel_info, sizeof (rel_info) - 1, "%" PRIxGRUB_UINT64_T,
+ ELF_R_TYPE (rel->r_info));
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%s is not implemented yet"), rel_info);
+ }
+ }
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/efiemu/i386/nocfgtables.c b/grub-core/efiemu/i386/nocfgtables.c
new file mode 100644
index 0000000..775f1d0
--- /dev/null
+++ b/grub-core/efiemu/i386/nocfgtables.c
@@ -0,0 +1,30 @@
+/* Register SMBIOS and ACPI tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/acpi.h>
+
+grub_err_t
+grub_machine_efiemu_init_tables (void)
+{
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/efiemu/i386/pc/cfgtables.c b/grub-core/efiemu/i386/pc/cfgtables.c
new file mode 100644
index 0000000..e5fffb7
--- /dev/null
+++ b/grub-core/efiemu/i386/pc/cfgtables.c
@@ -0,0 +1,69 @@
+/* Register SMBIOS and ACPI tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/acpi.h>
+#include <grub/smbios.h>
+
+grub_err_t
+grub_machine_efiemu_init_tables (void)
+{
+ void *table;
+ grub_err_t err;
+ grub_efi_guid_t smbios = GRUB_EFI_SMBIOS_TABLE_GUID;
+ grub_efi_guid_t acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
+ grub_efi_guid_t acpi = GRUB_EFI_ACPI_TABLE_GUID;
+
+ err = grub_efiemu_unregister_configuration_table (smbios);
+ if (err)
+ return err;
+ err = grub_efiemu_unregister_configuration_table (acpi);
+ if (err)
+ return err;
+ err = grub_efiemu_unregister_configuration_table (acpi20);
+ if (err)
+ return err;
+
+ table = grub_acpi_get_rsdpv1 ();
+ if (table)
+ {
+ err = grub_efiemu_register_configuration_table (acpi, 0, 0, table);
+ if (err)
+ return err;
+ }
+ table = grub_acpi_get_rsdpv2 ();
+ if (table)
+ {
+ err = grub_efiemu_register_configuration_table (acpi20, 0, 0, table);
+ if (err)
+ return err;
+ }
+ table = grub_smbios_get_eps ();
+ if (table)
+ {
+ err = grub_efiemu_register_configuration_table (smbios, 0, 0, table);
+ if (err)
+ return err;
+ }
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/efiemu/loadcore.c b/grub-core/efiemu/loadcore.c
new file mode 100644
index 0000000..2b92462
--- /dev/null
+++ b/grub-core/efiemu/loadcore.c
@@ -0,0 +1,387 @@
+/* Load runtime image of EFIemu. Functions specific to 32/64-bit mode */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/cpu/efiemu.h>
+#include <grub/elf.h>
+#include <grub/i18n.h>
+
+/* ELF symbols and their values */
+static struct grub_efiemu_elf_sym *grub_efiemu_elfsyms = 0;
+static int grub_efiemu_nelfsyms = 0;
+
+/* Return the address of a section whose index is N. */
+static grub_err_t
+grub_efiemu_get_section_addr (grub_efiemu_segment_t segs, unsigned n,
+ int *handle, grub_off_t *off)
+{
+ grub_efiemu_segment_t seg;
+
+ for (seg = segs; seg; seg = seg->next)
+ if (seg->section == n)
+ {
+ *handle = seg->handle;
+ *off = seg->off;
+ return GRUB_ERR_NONE;
+ }
+
+ return grub_error (GRUB_ERR_BAD_OS, "section %d not found", n);
+}
+
+grub_err_t
+SUFFIX (grub_efiemu_loadcore_unload) (void)
+{
+ grub_free (grub_efiemu_elfsyms);
+ grub_efiemu_elfsyms = 0;
+ return GRUB_ERR_NONE;
+}
+
+/* Check if EHDR is a valid ELF header. */
+int
+SUFFIX (grub_efiemu_check_header) (void *ehdr, grub_size_t size)
+{
+ Elf_Ehdr *e = ehdr;
+
+ /* Check the header size. */
+ if (size < sizeof (Elf_Ehdr))
+ return 0;
+
+ /* Check the magic numbers. */
+ if (!SUFFIX (grub_arch_efiemu_check_header) (ehdr)
+ || e->e_ident[EI_MAG0] != ELFMAG0
+ || e->e_ident[EI_MAG1] != ELFMAG1
+ || e->e_ident[EI_MAG2] != ELFMAG2
+ || e->e_ident[EI_MAG3] != ELFMAG3
+ || e->e_ident[EI_VERSION] != EV_CURRENT
+ || e->e_version != EV_CURRENT)
+ return 0;
+
+ return 1;
+}
+
+/* Load all segments from memory specified by E. */
+static grub_err_t
+grub_efiemu_load_segments (grub_efiemu_segment_t segs, const Elf_Ehdr *e)
+{
+ Elf_Shdr *s;
+ grub_efiemu_segment_t cur;
+
+ grub_dprintf ("efiemu", "loading segments\n");
+
+ for (cur=segs; cur; cur = cur->next)
+ {
+ s = (Elf_Shdr *)cur->srcptr;
+
+ if ((s->sh_flags & SHF_ALLOC) && s->sh_size)
+ {
+ void *addr;
+
+ addr = (grub_uint8_t *) grub_efiemu_mm_obtain_request (cur->handle)
+ + cur->off;
+
+ switch (s->sh_type)
+ {
+ case SHT_PROGBITS:
+ grub_memcpy (addr, (char *) e + s->sh_offset, s->sh_size);
+ break;
+ case SHT_NOBITS:
+ grub_memset (addr, 0, s->sh_size);
+ break;
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/* Get a string at offset OFFSET from strtab */
+static char *
+grub_efiemu_get_string (unsigned offset, const Elf_Ehdr *e)
+{
+ unsigned i;
+ Elf_Shdr *s;
+
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+ if (s->sh_type == SHT_STRTAB && offset < s->sh_size)
+ return (char *) e + s->sh_offset + offset;
+ return 0;
+}
+
+/* Request memory for segments and fill segments info */
+static grub_err_t
+grub_efiemu_init_segments (grub_efiemu_segment_t *segs, const Elf_Ehdr *e)
+{
+ unsigned i;
+ Elf_Shdr *s;
+
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+ {
+ if (s->sh_flags & SHF_ALLOC)
+ {
+ grub_efiemu_segment_t seg;
+ seg = (grub_efiemu_segment_t) grub_malloc (sizeof (*seg));
+ if (! seg)
+ return grub_errno;
+
+ if (s->sh_size)
+ {
+ seg->handle
+ = grub_efiemu_request_memalign
+ (s->sh_addralign, s->sh_size,
+ s->sh_flags & SHF_EXECINSTR ? GRUB_EFI_RUNTIME_SERVICES_CODE
+ : GRUB_EFI_RUNTIME_SERVICES_DATA);
+ if (seg->handle < 0)
+ {
+ grub_free (seg);
+ return grub_errno;
+ }
+ seg->off = 0;
+ }
+
+ /*
+ .text-physical doesn't need to be relocated when switching to
+ virtual mode
+ */
+ if (!grub_strcmp (grub_efiemu_get_string (s->sh_name, e),
+ ".text-physical"))
+ seg->ptv_rel_needed = 0;
+ else
+ seg->ptv_rel_needed = 1;
+ seg->size = s->sh_size;
+ seg->section = i;
+ seg->next = *segs;
+ seg->srcptr = s;
+ *segs = seg;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/* Count symbols and relocators and allocate/request memory for them */
+static grub_err_t
+grub_efiemu_count_symbols (const Elf_Ehdr *e)
+{
+ unsigned i;
+ Elf_Shdr *s;
+ int num = 0;
+
+ /* Symbols */
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+ if (s->sh_type == SHT_SYMTAB)
+ break;
+
+ if (i == e->e_shnum)
+ return grub_error (GRUB_ERR_BAD_OS, N_("no symbol table"));
+
+ grub_efiemu_nelfsyms = (unsigned) s->sh_size / (unsigned) s->sh_entsize;
+ grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *)
+ grub_calloc (grub_efiemu_nelfsyms, sizeof (struct grub_efiemu_elf_sym));
+
+ /* Relocators */
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+ if (s->sh_type == SHT_REL || s->sh_type == SHT_RELA)
+ num += ((unsigned) s->sh_size) / ((unsigned) s->sh_entsize);
+
+ grub_efiemu_request_symbols (num);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Fill grub_efiemu_elfsyms with symbol values */
+static grub_err_t
+grub_efiemu_resolve_symbols (grub_efiemu_segment_t segs, Elf_Ehdr *e)
+{
+ unsigned i;
+ Elf_Shdr *s;
+ Elf_Sym *sym;
+ const char *str;
+ Elf_Word size, entsize;
+
+ grub_dprintf ("efiemu", "resolving symbols\n");
+
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+ if (s->sh_type == SHT_SYMTAB)
+ break;
+
+ if (i == e->e_shnum)
+ return grub_error (GRUB_ERR_BAD_OS, N_("no symbol table"));
+
+ sym = (Elf_Sym *) ((char *) e + s->sh_offset);
+ size = s->sh_size;
+ entsize = s->sh_entsize;
+
+ s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shentsize * s->sh_link);
+ str = (char *) e + s->sh_offset;
+
+ for (i = 0;
+ i < size / entsize;
+ i++, sym = (Elf_Sym *) ((char *) sym + entsize))
+ {
+ unsigned char type = ELF_ST_TYPE (sym->st_info);
+ unsigned char bind = ELF_ST_BIND (sym->st_info);
+ int handle;
+ grub_off_t off;
+ grub_err_t err;
+ const char *name = str + sym->st_name;
+ grub_efiemu_elfsyms[i].section = sym->st_shndx;
+ switch (type)
+ {
+ case STT_NOTYPE:
+ /* Resolve a global symbol. */
+ if (sym->st_name != 0 && sym->st_shndx == 0)
+ {
+ err = grub_efiemu_resolve_symbol (name, &handle, &off);
+ if (err)
+ return err;
+ grub_efiemu_elfsyms[i].handle = handle;
+ grub_efiemu_elfsyms[i].off = off;
+ }
+ else
+ sym->st_value = 0;
+ break;
+
+ case STT_OBJECT:
+ err = grub_efiemu_get_section_addr (segs, sym->st_shndx,
+ &handle, &off);
+ if (err)
+ return err;
+
+ off += sym->st_value;
+ if (bind != STB_LOCAL)
+ {
+ err = grub_efiemu_register_symbol (name, handle, off);
+ if (err)
+ return err;
+ }
+ grub_efiemu_elfsyms[i].handle = handle;
+ grub_efiemu_elfsyms[i].off = off;
+ break;
+
+ case STT_FUNC:
+ err = grub_efiemu_get_section_addr (segs, sym->st_shndx,
+ &handle, &off);
+ if (err)
+ return err;
+
+ off += sym->st_value;
+ if (bind != STB_LOCAL)
+ {
+ err = grub_efiemu_register_symbol (name, handle, off);
+ if (err)
+ return err;
+ }
+ grub_efiemu_elfsyms[i].handle = handle;
+ grub_efiemu_elfsyms[i].off = off;
+ break;
+
+ case STT_SECTION:
+ err = grub_efiemu_get_section_addr (segs, sym->st_shndx,
+ &handle, &off);
+ if (err)
+ {
+ grub_efiemu_elfsyms[i].handle = 0;
+ grub_efiemu_elfsyms[i].off = 0;
+ grub_errno = GRUB_ERR_NONE;
+ break;
+ }
+
+ grub_efiemu_elfsyms[i].handle = handle;
+ grub_efiemu_elfsyms[i].off = off;
+ break;
+
+ case STT_FILE:
+ grub_efiemu_elfsyms[i].handle = 0;
+ grub_efiemu_elfsyms[i].off = 0;
+ break;
+
+ default:
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "unknown symbol type `%d'", (int) type);
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/* Load runtime to the memory and request memory for definitive location*/
+grub_err_t
+SUFFIX (grub_efiemu_loadcore_init) (void *core, const char *filename,
+ grub_size_t core_size,
+ grub_efiemu_segment_t *segments)
+{
+ Elf_Ehdr *e = (Elf_Ehdr *) core;
+ grub_err_t err;
+
+ if (e->e_type != ET_REL)
+ 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 + (grub_uint32_t) e->e_shentsize * e->e_shnum)
+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+
+ err = grub_efiemu_init_segments (segments, core);
+ if (err)
+ return err;
+ err = grub_efiemu_count_symbols (core);
+ if (err)
+ return err;
+
+ grub_efiemu_request_symbols (1);
+ return GRUB_ERR_NONE;
+}
+
+/* Load runtime definitively */
+grub_err_t
+SUFFIX (grub_efiemu_loadcore_load) (void *core,
+ grub_size_t core_size
+ __attribute__ ((unused)),
+ grub_efiemu_segment_t segments)
+{
+ grub_err_t err;
+ err = grub_efiemu_load_segments (segments, core);
+ if (err)
+ return err;
+
+ err = grub_efiemu_resolve_symbols (segments, core);
+ if (err)
+ return err;
+
+ err = SUFFIX (grub_arch_efiemu_relocate_symbols) (segments,
+ grub_efiemu_elfsyms,
+ core);
+ if (err)
+ return err;
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/efiemu/loadcore32.c b/grub-core/efiemu/loadcore32.c
new file mode 100644
index 0000000..c1e033b
--- /dev/null
+++ b/grub-core/efiemu/loadcore32.c
@@ -0,0 +1,22 @@
+/* This file contains definitions so that loadcore.c compiles for 32-bit */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define SUFFIX(x) x ## 32
+#define GRUB_TARGET_WORDSIZE 32
+#include "loadcore.c"
diff --git a/grub-core/efiemu/loadcore64.c b/grub-core/efiemu/loadcore64.c
new file mode 100644
index 0000000..ce7284f
--- /dev/null
+++ b/grub-core/efiemu/loadcore64.c
@@ -0,0 +1,22 @@
+/* This file contains definitions so that loadcore.c compiles for 64-bit */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define SUFFIX(x) x ## 64
+#define GRUB_TARGET_WORDSIZE 64
+#include "loadcore.c"
diff --git a/grub-core/efiemu/loadcore_common.c b/grub-core/efiemu/loadcore_common.c
new file mode 100644
index 0000000..64d7960
--- /dev/null
+++ b/grub-core/efiemu/loadcore_common.c
@@ -0,0 +1,196 @@
+/* Load runtime image of EFIemu. Functions common to 32/64-bit mode */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/cpu/efiemu.h>
+
+/* Are we in 32 or 64-bit mode?*/
+static grub_efiemu_mode_t grub_efiemu_mode = GRUB_EFIEMU_NOTLOADED;
+/* Runtime ELF file */
+static grub_ssize_t efiemu_core_size;
+static void *efiemu_core = 0;
+/* Linked list of segments */
+static grub_efiemu_segment_t efiemu_segments = 0;
+
+/* equivalent to sizeof (grub_efi_uintn_t) but taking the mode into account*/
+int
+grub_efiemu_sizeof_uintn_t (void)
+{
+ if (grub_efiemu_mode == GRUB_EFIEMU32)
+ return 4;
+ if (grub_efiemu_mode == GRUB_EFIEMU64)
+ return 8;
+ return 0;
+}
+
+/* Check the header and set mode */
+static grub_err_t
+grub_efiemu_check_header (void *ehdr, grub_size_t size,
+ grub_efiemu_mode_t *mode)
+{
+ /* Check the magic numbers. */
+ if ((*mode == GRUB_EFIEMU_NOTLOADED || *mode == GRUB_EFIEMU32)
+ && grub_efiemu_check_header32 (ehdr,size))
+ {
+ *mode = GRUB_EFIEMU32;
+ return GRUB_ERR_NONE;
+ }
+ if ((*mode == GRUB_EFIEMU_NOTLOADED || *mode == GRUB_EFIEMU64)
+ && grub_efiemu_check_header64 (ehdr,size))
+ {
+ *mode = GRUB_EFIEMU64;
+ return GRUB_ERR_NONE;
+ }
+ return grub_error (GRUB_ERR_BAD_OS, "invalid ELF magic");
+}
+
+/* Unload segments */
+static int
+grub_efiemu_unload_segs (grub_efiemu_segment_t seg)
+{
+ grub_efiemu_segment_t segn;
+ for (; seg; seg = segn)
+ {
+ segn = seg->next;
+ grub_efiemu_mm_return_request (seg->handle);
+ grub_free (seg);
+ }
+ return 1;
+}
+
+
+grub_err_t
+grub_efiemu_loadcore_unload(void)
+{
+ switch (grub_efiemu_mode)
+ {
+ case GRUB_EFIEMU32:
+ grub_efiemu_loadcore_unload32 ();
+ break;
+
+ case GRUB_EFIEMU64:
+ grub_efiemu_loadcore_unload64 ();
+ break;
+
+ default:
+ break;
+ }
+
+ grub_efiemu_mode = GRUB_EFIEMU_NOTLOADED;
+
+ grub_free (efiemu_core);
+ efiemu_core = 0;
+
+ grub_efiemu_unload_segs (efiemu_segments);
+ efiemu_segments = 0;
+
+ grub_efiemu_free_syms ();
+
+ return GRUB_ERR_NONE;
+}
+
+/* Load runtime file and do some initial preparations */
+grub_err_t
+grub_efiemu_loadcore_init (grub_file_t file,
+ const char *filename)
+{
+ grub_err_t err;
+
+ efiemu_core_size = grub_file_size (file);
+ efiemu_core = 0;
+ efiemu_core = grub_malloc (efiemu_core_size);
+ if (! efiemu_core)
+ return grub_errno;
+
+ if (grub_file_read (file, efiemu_core, efiemu_core_size)
+ != (int) efiemu_core_size)
+ {
+ grub_free (efiemu_core);
+ efiemu_core = 0;
+ return grub_errno;
+ }
+
+ if (grub_efiemu_check_header (efiemu_core, efiemu_core_size,
+ &grub_efiemu_mode))
+ {
+ grub_free (efiemu_core);
+ efiemu_core = 0;
+ return GRUB_ERR_BAD_MODULE;
+ }
+
+ switch (grub_efiemu_mode)
+ {
+ case GRUB_EFIEMU32:
+ err = grub_efiemu_loadcore_init32 (efiemu_core, filename,
+ efiemu_core_size,
+ &efiemu_segments);
+ if (err)
+ {
+ grub_free (efiemu_core);
+ efiemu_core = 0;
+ grub_efiemu_mode = GRUB_EFIEMU_NOTLOADED;
+ return err;
+ }
+ break;
+
+ case GRUB_EFIEMU64:
+ err = grub_efiemu_loadcore_init64 (efiemu_core, filename,
+ efiemu_core_size,
+ &efiemu_segments);
+ if (err)
+ {
+ grub_free (efiemu_core);
+ efiemu_core = 0;
+ grub_efiemu_mode = GRUB_EFIEMU_NOTLOADED;
+ return err;
+ }
+ break;
+
+ default:
+ return grub_error (GRUB_ERR_BUG, "unknown EFI runtime");
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_efiemu_loadcore_load (void)
+{
+ grub_err_t err;
+ switch (grub_efiemu_mode)
+ {
+ case GRUB_EFIEMU32:
+ err = grub_efiemu_loadcore_load32 (efiemu_core, efiemu_core_size,
+ efiemu_segments);
+ if (err)
+ grub_efiemu_loadcore_unload ();
+ return err;
+ case GRUB_EFIEMU64:
+ err = grub_efiemu_loadcore_load64 (efiemu_core, efiemu_core_size,
+ efiemu_segments);
+ if (err)
+ grub_efiemu_loadcore_unload ();
+ return err;
+ default:
+ return grub_error (GRUB_ERR_BUG, "unknown EFI runtime");
+ }
+}
diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c
new file mode 100644
index 0000000..a819347
--- /dev/null
+++ b/grub-core/efiemu/main.c
@@ -0,0 +1,328 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This is an emulation of EFI runtime services.
+ This allows a more uniform boot on i386 machines.
+ As it emulates only runtime service it isn't able
+ to chainload EFI bootloader on non-EFI system. */
+
+
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* System table. Two version depending on mode */
+grub_efi_system_table32_t *grub_efiemu_system_table32 = 0;
+grub_efi_system_table64_t *grub_efiemu_system_table64 = 0;
+/* Modules may need to execute some actions after memory allocation happens */
+static struct grub_efiemu_prepare_hook *efiemu_prepare_hooks = 0;
+/* Linked list of configuration tables */
+static struct grub_efiemu_configuration_table *efiemu_config_tables = 0;
+static int prepared = 0;
+
+/* Free all allocated space */
+grub_err_t
+grub_efiemu_unload (void)
+{
+ struct grub_efiemu_configuration_table *cur, *d;
+ struct grub_efiemu_prepare_hook *curhook, *d2;
+ grub_efiemu_loadcore_unload ();
+
+ grub_efiemu_mm_unload ();
+
+ for (cur = efiemu_config_tables; cur;)
+ {
+ d = cur->next;
+ if (cur->unload)
+ cur->unload (cur->data);
+ grub_free (cur);
+ cur = d;
+ }
+ efiemu_config_tables = 0;
+
+ for (curhook = efiemu_prepare_hooks; curhook;)
+ {
+ d2 = curhook->next;
+ if (curhook->unload)
+ curhook->unload (curhook->data);
+ grub_free (curhook);
+ curhook = d2;
+ }
+ efiemu_prepare_hooks = 0;
+
+ prepared = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Remove previously registered table from the list */
+grub_err_t
+grub_efiemu_unregister_configuration_table (grub_efi_guid_t guid)
+{
+ struct grub_efiemu_configuration_table *cur, *prev;
+
+ /* Special treating if head is to remove */
+ while (efiemu_config_tables
+ && !grub_memcmp (&(efiemu_config_tables->guid), &guid, sizeof (guid)))
+ {
+ if (efiemu_config_tables->unload)
+ efiemu_config_tables->unload (efiemu_config_tables->data);
+ cur = efiemu_config_tables->next;
+ grub_free (efiemu_config_tables);
+ efiemu_config_tables = cur;
+ }
+ if (!efiemu_config_tables)
+ return GRUB_ERR_NONE;
+
+ /* Remove from chain */
+ for (prev = efiemu_config_tables, cur = prev->next; cur;)
+ if (grub_memcmp (&(cur->guid), &guid, sizeof (guid)) == 0)
+ {
+ if (cur->unload)
+ cur->unload (cur->data);
+ prev->next = cur->next;
+ grub_free (cur);
+ cur = prev->next;
+ }
+ else
+ {
+ prev = cur;
+ cur = cur->next;
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_efiemu_register_prepare_hook (grub_err_t (*hook) (void *data),
+ void (*unload) (void *data),
+ void *data)
+{
+ struct grub_efiemu_prepare_hook *nhook;
+ nhook = (struct grub_efiemu_prepare_hook *) grub_malloc (sizeof (*nhook));
+ if (! nhook)
+ return grub_errno;
+ nhook->hook = hook;
+ nhook->unload = unload;
+ nhook->data = data;
+ nhook->next = efiemu_prepare_hooks;
+ efiemu_prepare_hooks = nhook;
+ return GRUB_ERR_NONE;
+}
+
+/* Register a configuration table either supplying the address directly
+ or with a hook
+*/
+grub_err_t
+grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
+ void * (*get_table) (void *data),
+ void (*unload) (void *data),
+ void *data)
+{
+ struct grub_efiemu_configuration_table *tbl;
+ grub_err_t err;
+
+ err = grub_efiemu_unregister_configuration_table (guid);
+ if (err)
+ return err;
+
+ tbl = (struct grub_efiemu_configuration_table *) grub_malloc (sizeof (*tbl));
+ if (! tbl)
+ return grub_errno;
+
+ tbl->guid = guid;
+ tbl->get_table = get_table;
+ tbl->unload = unload;
+ tbl->data = data;
+ tbl->next = efiemu_config_tables;
+ efiemu_config_tables = tbl;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_efiemu_unload (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *args[] __attribute__ ((unused)))
+{
+ return grub_efiemu_unload ();
+}
+
+static grub_err_t
+grub_cmd_efiemu_prepare (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *args[] __attribute__ ((unused)))
+{
+ return grub_efiemu_prepare ();
+}
+
+
+
+/* Load the runtime from the file FILENAME. */
+static grub_err_t
+grub_efiemu_load_file (const char *filename)
+{
+ grub_file_t file;
+ grub_err_t err;
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE);
+ if (! file)
+ return grub_errno;
+
+ err = grub_efiemu_mm_init ();
+ if (err)
+ {
+ grub_file_close (file);
+ grub_efiemu_unload ();
+ return err;
+ }
+
+ grub_dprintf ("efiemu", "mm initialized\n");
+
+ err = grub_efiemu_loadcore_init (file, filename);
+ if (err)
+ {
+ grub_file_close (file);
+ grub_efiemu_unload ();
+ return err;
+ }
+
+ grub_file_close (file);
+
+ /* For configuration tables entry in system table. */
+ grub_efiemu_request_symbols (1);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_efiemu_autocore (void)
+{
+ const char *prefix;
+ char *filename;
+ const char *suffix;
+ grub_err_t err;
+
+ if (grub_efiemu_sizeof_uintn_t () != 0)
+ return GRUB_ERR_NONE;
+
+ prefix = grub_env_get ("prefix");
+
+ if (! prefix)
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ N_("variable `%s' isn't set"), "prefix");
+
+ suffix = grub_efiemu_get_default_core_name ();
+
+ filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM "/%s",
+ prefix, suffix);
+ if (! filename)
+ return grub_errno;
+
+ err = grub_efiemu_load_file (filename);
+ grub_free (filename);
+ if (err)
+ return err;
+#ifndef GRUB_MACHINE_EMU
+ err = grub_machine_efiemu_init_tables ();
+ if (err)
+ return err;
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_efiemu_prepare (void)
+{
+ grub_err_t err;
+
+ if (prepared)
+ return GRUB_ERR_NONE;
+
+ err = grub_efiemu_autocore ();
+ if (err)
+ return err;
+
+ grub_dprintf ("efiemu", "Preparing %d-bit efiemu\n",
+ 8 * grub_efiemu_sizeof_uintn_t ());
+
+ /* Create NVRAM. */
+ grub_efiemu_pnvram ();
+
+ prepared = 1;
+
+ if (grub_efiemu_sizeof_uintn_t () == 4)
+ return grub_efiemu_prepare32 (efiemu_prepare_hooks, efiemu_config_tables);
+ else
+ return grub_efiemu_prepare64 (efiemu_prepare_hooks, efiemu_config_tables);
+}
+
+
+static grub_err_t
+grub_cmd_efiemu_load (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *args[])
+{
+ grub_err_t err;
+
+ grub_efiemu_unload ();
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ err = grub_efiemu_load_file (args[0]);
+ if (err)
+ return err;
+#ifndef GRUB_MACHINE_EMU
+ err = grub_machine_efiemu_init_tables ();
+ if (err)
+ return err;
+#endif
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd_loadcore, cmd_prepare, cmd_unload;
+
+GRUB_MOD_INIT(efiemu)
+{
+ cmd_loadcore = grub_register_command ("efiemu_loadcore",
+ grub_cmd_efiemu_load,
+ N_("FILE"),
+ N_("Load and initialize EFI emulator."));
+ cmd_prepare = grub_register_command ("efiemu_prepare",
+ grub_cmd_efiemu_prepare,
+ 0,
+ N_("Finalize loading of EFI emulator."));
+ cmd_unload = grub_register_command ("efiemu_unload", grub_cmd_efiemu_unload,
+ 0,
+ N_("Unload EFI emulator."));
+}
+
+GRUB_MOD_FINI(efiemu)
+{
+ grub_unregister_command (cmd_loadcore);
+ grub_unregister_command (cmd_prepare);
+ grub_unregister_command (cmd_unload);
+}
diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c
new file mode 100644
index 0000000..9b8e0d0
--- /dev/null
+++ b/grub-core/efiemu/mm.c
@@ -0,0 +1,677 @@
+/* Memory management for efiemu */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ To keep efiemu runtime contiguous this mm is special.
+ It uses deferred allocation.
+ In the first stage you may request memory with grub_efiemu_request_memalign
+ It will give you a handle with which in the second phase you can access your
+ memory with grub_efiemu_mm_obtain_request (handle). It's guaranteed that
+ subsequent calls with the same handle return the same result. You can't request any additional memory once you're in the second phase
+*/
+
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/memory.h>
+
+struct grub_efiemu_memrequest
+{
+ struct grub_efiemu_memrequest *next;
+ grub_efi_memory_type_t type;
+ grub_size_t size;
+ grub_size_t align_overhead;
+ int handle;
+ void *val;
+};
+/* Linked list of requested memory. */
+static struct grub_efiemu_memrequest *memrequests = 0;
+/* Memory map. */
+static grub_efi_memory_descriptor_t *efiemu_mmap = 0;
+/* Pointer to allocated memory */
+static void *resident_memory = 0;
+/* Size of requested memory per type */
+static grub_size_t requested_memory[GRUB_EFI_MAX_MEMORY_TYPE];
+/* How many slots is allocated for memory_map and how many are already used */
+static int mmap_reserved_size = 0, mmap_num = 0;
+
+/* Add a memory region to map*/
+static grub_err_t
+grub_efiemu_add_to_mmap (grub_uint64_t start, grub_uint64_t size,
+ grub_efi_memory_type_t type)
+{
+ grub_uint64_t page_start, npages;
+
+ /* Extend map if necessary*/
+ if (mmap_num >= mmap_reserved_size)
+ {
+ void *old;
+ mmap_reserved_size = 2 * (mmap_reserved_size + 1);
+ old = efiemu_mmap;
+ efiemu_mmap = (grub_efi_memory_descriptor_t *)
+ grub_realloc (efiemu_mmap, mmap_reserved_size
+ * sizeof (grub_efi_memory_descriptor_t));
+ if (!efiemu_mmap)
+ {
+ grub_free (old);
+ return grub_errno;
+ }
+ }
+
+ /* Fill slot*/
+ page_start = start - (start % GRUB_EFIEMU_PAGESIZE);
+ npages = (size + (start % GRUB_EFIEMU_PAGESIZE) + GRUB_EFIEMU_PAGESIZE - 1)
+ / GRUB_EFIEMU_PAGESIZE;
+ efiemu_mmap[mmap_num].physical_start = page_start;
+ efiemu_mmap[mmap_num].virtual_start = page_start;
+ efiemu_mmap[mmap_num].num_pages = npages;
+ efiemu_mmap[mmap_num].type = type;
+ mmap_num++;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Request a resident memory of type TYPE of size SIZE aligned at ALIGN
+ ALIGN must be a divisor of page size (if it's a divisor of 4096
+ it should be ok on all platforms)
+ */
+int
+grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
+ grub_efi_memory_type_t type)
+{
+ grub_size_t align_overhead;
+ struct grub_efiemu_memrequest *ret, *cur, *prev;
+ /* Check that the request is correct */
+ 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 */
+ align_overhead = align - (requested_memory[type]%align);
+ if (align_overhead == align)
+ align_overhead = 0;
+ requested_memory[type] += align_overhead + size;
+
+ /* Remember the request */
+ ret = grub_zalloc (sizeof (*ret));
+ if (!ret)
+ return -1;
+ ret->type = type;
+ ret->size = size;
+ ret->align_overhead = align_overhead;
+ prev = 0;
+
+ /* Add request to the end of the chain.
+ It should be at the end because otherwise alignment isn't guaranteed */
+ for (cur = memrequests; cur; prev = cur, cur = cur->next);
+ if (prev)
+ {
+ ret->handle = prev->handle + 1;
+ prev->next = ret;
+ }
+ else
+ {
+ ret->handle = 1; /* Avoid 0 handle*/
+ memrequests = ret;
+ }
+ return ret->handle;
+}
+
+/* Really allocate the memory */
+static grub_err_t
+efiemu_alloc_requests (void)
+{
+ grub_size_t align_overhead = 0;
+ grub_uint8_t *curptr, *typestart;
+ struct grub_efiemu_memrequest *cur;
+ grub_size_t total_alloc = 0;
+ unsigned i;
+ /* Order of memory regions */
+ grub_efi_memory_type_t reqorder[] =
+ {
+ /* First come regions usable by OS*/
+ GRUB_EFI_LOADER_CODE,
+ GRUB_EFI_LOADER_DATA,
+ GRUB_EFI_BOOT_SERVICES_CODE,
+ GRUB_EFI_BOOT_SERVICES_DATA,
+ GRUB_EFI_CONVENTIONAL_MEMORY,
+ GRUB_EFI_ACPI_RECLAIM_MEMORY,
+
+ /* Then memory used by runtime */
+ /* This way all our regions are in a single block */
+ GRUB_EFI_RUNTIME_SERVICES_CODE,
+ GRUB_EFI_RUNTIME_SERVICES_DATA,
+ GRUB_EFI_ACPI_MEMORY_NVS,
+
+ /* And then unavailable memory types. This is more for a completeness.
+ You should double think before allocating memory of any of these types
+ */
+ GRUB_EFI_UNUSABLE_MEMORY,
+ 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 */
+ for (i = 0; i < sizeof (reqorder) / sizeof (reqorder[0]); i++)
+ {
+ align_overhead = GRUB_EFIEMU_PAGESIZE
+ - (requested_memory[reqorder[i]] % GRUB_EFIEMU_PAGESIZE);
+ if (align_overhead == GRUB_EFIEMU_PAGESIZE)
+ align_overhead = 0;
+ total_alloc += requested_memory[reqorder[i]] + align_overhead;
+ }
+
+ /* Allocate the whole memory in one block */
+ resident_memory = grub_memalign (GRUB_EFIEMU_PAGESIZE, total_alloc);
+ if (!resident_memory)
+ return grub_errno;
+
+ /* Split the memory into blocks by type */
+ curptr = resident_memory;
+ for (i = 0; i < sizeof (reqorder) / sizeof (reqorder[0]); i++)
+ {
+ if (!requested_memory[reqorder[i]])
+ continue;
+ typestart = curptr;
+
+ /* Write pointers to requests */
+ for (cur = memrequests; cur; cur = cur->next)
+ if (cur->type == reqorder[i])
+ {
+ curptr = ((grub_uint8_t *)curptr) + cur->align_overhead;
+ cur->val = curptr;
+ curptr = ((grub_uint8_t *)curptr) + cur->size;
+ }
+
+ /* Ensure that the regions are page-aligned */
+ align_overhead = GRUB_EFIEMU_PAGESIZE
+ - (requested_memory[reqorder[i]] % GRUB_EFIEMU_PAGESIZE);
+ if (align_overhead == GRUB_EFIEMU_PAGESIZE)
+ align_overhead = 0;
+ curptr = ((grub_uint8_t *) curptr) + align_overhead;
+
+ /* Add the region to memory map */
+ grub_efiemu_add_to_mmap ((grub_addr_t) typestart,
+ curptr - typestart, reqorder[i]);
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/* Get a pointer to requested memory from handle */
+void *
+grub_efiemu_mm_obtain_request (int handle)
+{
+ struct grub_efiemu_memrequest *cur;
+ for (cur = memrequests; cur; cur = cur->next)
+ if (cur->handle == handle)
+ return cur->val;
+ return 0;
+}
+
+/* Get type of requested memory by handle */
+grub_efi_memory_type_t
+grub_efiemu_mm_get_type (int handle)
+{
+ struct grub_efiemu_memrequest *cur;
+ for (cur = memrequests; cur; cur = cur->next)
+ if (cur->handle == handle)
+ return cur->type;
+ return 0;
+}
+
+/* Free a request */
+void
+grub_efiemu_mm_return_request (int handle)
+{
+ struct grub_efiemu_memrequest *cur, *prev;
+
+ /* Remove head if necessary */
+ while (memrequests && memrequests->handle == handle)
+ {
+ cur = memrequests->next;
+ grub_free (memrequests);
+ memrequests = cur;
+ }
+ if (!memrequests)
+ return;
+
+ /* Remove request from a middle of chain*/
+ for (prev = memrequests, cur = prev->next; cur;)
+ if (cur->handle == handle)
+ {
+ prev->next = cur->next;
+ grub_free (cur);
+ cur = prev->next;
+ }
+ else
+ {
+ prev = cur;
+ cur = prev->next;
+ }
+}
+
+/* Helper for grub_efiemu_mmap_init. */
+static int
+bounds_hook (grub_uint64_t addr __attribute__ ((unused)),
+ grub_uint64_t size __attribute__ ((unused)),
+ grub_memory_type_t type __attribute__ ((unused)),
+ void *data __attribute__ ((unused)))
+{
+ mmap_reserved_size++;
+ return 0;
+}
+
+/* Reserve space for memory map */
+static grub_err_t
+grub_efiemu_mmap_init (void)
+{
+ // the place for memory used by efiemu itself
+ mmap_reserved_size = GRUB_EFI_MAX_MEMORY_TYPE + 1;
+
+#ifndef GRUB_MACHINE_EMU
+ grub_machine_mmap_iterate (bounds_hook, NULL);
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+/* This is a drop-in replacement of grub_efi_get_memory_map */
+/* Get the memory map as defined in the EFI spec. Return 1 if successful,
+ return 0 if partial, or return -1 if an error occurs. */
+int
+grub_efiemu_get_memory_map (grub_efi_uintn_t *memory_map_size,
+ grub_efi_memory_descriptor_t *memory_map,
+ grub_efi_uintn_t *map_key,
+ grub_efi_uintn_t *descriptor_size,
+ grub_efi_uint32_t *descriptor_version)
+{
+ if (!efiemu_mmap)
+ {
+ grub_error (GRUB_ERR_INVALID_COMMAND,
+ "you need to first launch efiemu_prepare");
+ return -1;
+ }
+
+ if (*memory_map_size < mmap_num * sizeof (grub_efi_memory_descriptor_t))
+ {
+ *memory_map_size = mmap_num * sizeof (grub_efi_memory_descriptor_t);
+ return 0;
+ }
+
+ *memory_map_size = mmap_num * sizeof (grub_efi_memory_descriptor_t);
+ grub_memcpy (memory_map, efiemu_mmap, *memory_map_size);
+ if (descriptor_size)
+ *descriptor_size = sizeof (grub_efi_memory_descriptor_t);
+ if (descriptor_version)
+ *descriptor_version = 1;
+ if (map_key)
+ *map_key = 0;
+
+ return 1;
+}
+
+grub_err_t
+grub_efiemu_finish_boot_services (grub_efi_uintn_t *memory_map_size,
+ grub_efi_memory_descriptor_t *memory_map,
+ grub_efi_uintn_t *map_key,
+ grub_efi_uintn_t *descriptor_size,
+ grub_efi_uint32_t *descriptor_version)
+{
+ int val = grub_efiemu_get_memory_map (memory_map_size,
+ memory_map, map_key,
+ descriptor_size,
+ descriptor_version);
+ if (val == 1)
+ return GRUB_ERR_NONE;
+ if (val == -1)
+ return grub_errno;
+ return grub_error (GRUB_ERR_IO, "memory map buffer is too small");
+}
+
+
+/* Free everything */
+grub_err_t
+grub_efiemu_mm_unload (void)
+{
+ struct grub_efiemu_memrequest *cur, *d;
+ for (cur = memrequests; cur;)
+ {
+ d = cur->next;
+ grub_free (cur);
+ cur = d;
+ }
+ memrequests = 0;
+ grub_memset (&requested_memory, 0, sizeof (requested_memory));
+ grub_free (resident_memory);
+ resident_memory = 0;
+ grub_free (efiemu_mmap);
+ efiemu_mmap = 0;
+ mmap_reserved_size = mmap_num = 0;
+ return GRUB_ERR_NONE;
+}
+
+/* This function should be called before doing any requests */
+grub_err_t
+grub_efiemu_mm_init (void)
+{
+ grub_err_t err;
+
+ err = grub_efiemu_mm_unload ();
+ if (err)
+ return err;
+
+ grub_efiemu_mmap_init ();
+
+ return GRUB_ERR_NONE;
+}
+
+/* Helper for grub_efiemu_mmap_fill. */
+static int
+fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data __attribute__ ((unused)))
+ {
+ switch (type)
+ {
+ case GRUB_MEMORY_AVAILABLE:
+ return grub_efiemu_add_to_mmap (addr, size,
+ GRUB_EFI_CONVENTIONAL_MEMORY);
+
+ case GRUB_MEMORY_ACPI:
+ return grub_efiemu_add_to_mmap (addr, size,
+ GRUB_EFI_ACPI_RECLAIM_MEMORY);
+
+ case GRUB_MEMORY_NVS:
+ 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);
+ /* FALLTHROUGH */
+ case GRUB_MEMORY_RESERVED:
+ return grub_efiemu_add_to_mmap (addr, size,
+ GRUB_EFI_UNUSABLE_MEMORY);
+ }
+ }
+
+/* Copy host memory map */
+static grub_err_t
+grub_efiemu_mmap_fill (void)
+{
+#ifndef GRUB_MACHINE_EMU
+ grub_machine_mmap_iterate (fill_hook, NULL);
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ unsigned i;
+
+ for (i = 0; i < (unsigned) mmap_num; i++)
+ switch (efiemu_mmap[i].type)
+ {
+ case GRUB_EFI_RUNTIME_SERVICES_CODE:
+ hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
+ GRUB_MEMORY_CODE, hook_data);
+ break;
+
+ case GRUB_EFI_UNUSABLE_MEMORY:
+ hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
+ GRUB_MEMORY_BADRAM, hook_data);
+ break;
+
+ case GRUB_EFI_RESERVED_MEMORY_TYPE:
+ case GRUB_EFI_RUNTIME_SERVICES_DATA:
+ case GRUB_EFI_MEMORY_MAPPED_IO:
+ case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
+ case GRUB_EFI_PAL_CODE:
+ default:
+ hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
+ GRUB_MEMORY_RESERVED, hook_data);
+ break;
+
+ case GRUB_EFI_LOADER_CODE:
+ case GRUB_EFI_LOADER_DATA:
+ case GRUB_EFI_BOOT_SERVICES_CODE:
+ case GRUB_EFI_BOOT_SERVICES_DATA:
+ case GRUB_EFI_CONVENTIONAL_MEMORY:
+ hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
+ GRUB_MEMORY_AVAILABLE, hook_data);
+ break;
+
+ case GRUB_EFI_ACPI_RECLAIM_MEMORY:
+ hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
+ GRUB_MEMORY_ACPI, hook_data);
+ break;
+
+ case GRUB_EFI_ACPI_MEMORY_NVS:
+ 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;
+}
+
+
+/* This function resolves overlapping regions and sorts the memory map
+ It uses scanline (sweeping) algorithm
+ */
+static grub_err_t
+grub_efiemu_mmap_sort_and_uniq (void)
+{
+ /* If same page is used by multiple types it's resolved
+ according to priority
+ 0 - free memory
+ 1 - memory immediately usable after ExitBootServices
+ 2 - memory usable after loading ACPI tables
+ 3 - efiemu memory
+ 4 - unusable memory
+ */
+ int priority[GRUB_EFI_MAX_MEMORY_TYPE] =
+ {
+ [GRUB_EFI_RESERVED_MEMORY_TYPE] = 4,
+ [GRUB_EFI_LOADER_CODE] = 1,
+ [GRUB_EFI_LOADER_DATA] = 1,
+ [GRUB_EFI_BOOT_SERVICES_CODE] = 1,
+ [GRUB_EFI_BOOT_SERVICES_DATA] = 1,
+ [GRUB_EFI_RUNTIME_SERVICES_CODE] = 3,
+ [GRUB_EFI_RUNTIME_SERVICES_DATA] = 3,
+ [GRUB_EFI_CONVENTIONAL_MEMORY] = 0,
+ [GRUB_EFI_UNUSABLE_MEMORY] = 4,
+ [GRUB_EFI_ACPI_RECLAIM_MEMORY] = 2,
+ [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_PERSISTENT_MEMORY] = 4
+ };
+
+ int i, j, k, done;
+
+ /* Scanline events */
+ struct grub_efiemu_mmap_scan
+ {
+ /* At which memory address*/
+ grub_uint64_t pos;
+ /* 0 = region starts, 1 = region ends */
+ int type;
+ /* Which type of memory region */
+ grub_efi_memory_type_t memtype;
+ };
+ struct grub_efiemu_mmap_scan *scanline_events;
+ struct grub_efiemu_mmap_scan t;
+
+ /* Previous scanline event */
+ grub_uint64_t lastaddr;
+ int lasttype;
+ /* Current scanline event */
+ int curtype;
+ /* how many regions of given type overlap at current location */
+ int present[GRUB_EFI_MAX_MEMORY_TYPE];
+ /* Here is stored the resulting memory map*/
+ grub_efi_memory_descriptor_t *result;
+
+ /* Initialize variables*/
+ grub_memset (present, 0, sizeof (int) * GRUB_EFI_MAX_MEMORY_TYPE);
+ scanline_events = (struct grub_efiemu_mmap_scan *)
+ grub_calloc (mmap_num, sizeof (struct grub_efiemu_mmap_scan) * 2);
+
+ /* Number of chunks can't increase more than by factor of 2 */
+ result = (grub_efi_memory_descriptor_t *)
+ grub_calloc (mmap_num, sizeof (grub_efi_memory_descriptor_t) * 2);
+ if (!result || !scanline_events)
+ {
+ grub_free (result);
+ grub_free (scanline_events);
+ return grub_errno;
+ }
+
+ /* Register scanline events */
+ for (i = 0; i < mmap_num; i++)
+ {
+ scanline_events[2 * i].pos = efiemu_mmap[i].physical_start;
+ scanline_events[2 * i].type = 0;
+ scanline_events[2 * i].memtype = efiemu_mmap[i].type;
+ scanline_events[2 * i + 1].pos = efiemu_mmap[i].physical_start
+ + efiemu_mmap[i].num_pages * GRUB_EFIEMU_PAGESIZE;
+ scanline_events[2 * i + 1].type = 1;
+ scanline_events[2 * i + 1].memtype = efiemu_mmap[i].type;
+ }
+
+ /* Primitive bubble sort. It has complexity O(n^2) but since we're
+ unlikely to have more than 100 chunks it's probably one of the
+ fastest for one purpose */
+ done = 1;
+ while (done)
+ {
+ done = 0;
+ for (i = 0; i < 2 * mmap_num - 1; i++)
+ if (scanline_events[i + 1].pos < scanline_events[i].pos)
+ {
+ t = scanline_events[i + 1];
+ scanline_events[i + 1] = scanline_events[i];
+ scanline_events[i] = t;
+ done = 1;
+ }
+ }
+
+ /* Pointer in resulting memory map */
+ j = 0;
+ lastaddr = scanline_events[0].pos;
+ lasttype = scanline_events[0].memtype;
+ for (i = 0; i < 2 * mmap_num; i++)
+ {
+ /* Process event */
+ if (scanline_events[i].type)
+ present[scanline_events[i].memtype]--;
+ else
+ present[scanline_events[i].memtype]++;
+
+ /* Determine current region type */
+ curtype = -1;
+ for (k = 0; k < GRUB_EFI_MAX_MEMORY_TYPE; k++)
+ if (present[k] && (curtype == -1 || priority[k] > priority[curtype]))
+ curtype = k;
+
+ /* Add memory region to resulting map if necessary */
+ if ((curtype == -1 || curtype != lasttype)
+ && lastaddr != scanline_events[i].pos
+ && lasttype != -1)
+ {
+ result[j].virtual_start = result[j].physical_start = lastaddr;
+ result[j].num_pages = (scanline_events[i].pos - lastaddr)
+ / GRUB_EFIEMU_PAGESIZE;
+ result[j].type = lasttype;
+
+ /* We set runtime attribute on pages we need to be mapped */
+ result[j].attribute
+ = (lasttype == GRUB_EFI_RUNTIME_SERVICES_CODE
+ || lasttype == GRUB_EFI_RUNTIME_SERVICES_DATA)
+ ? GRUB_EFI_MEMORY_RUNTIME : 0;
+ grub_dprintf ("efiemu",
+ "mmap entry: type %d start 0x%llx 0x%llx pages\n",
+ result[j].type,
+ result[j].physical_start, result[j].num_pages);
+ j++;
+ }
+
+ /* Update last values if necessary */
+ if (curtype == -1 || curtype != lasttype)
+ {
+ lasttype = curtype;
+ lastaddr = scanline_events[i].pos;
+ }
+ }
+
+ grub_free (scanline_events);
+
+ /* Shrink resulting memory map to really used size and replace efiemu_mmap
+ by new value */
+ grub_free (efiemu_mmap);
+ efiemu_mmap = grub_realloc (result, j * sizeof (*result));
+ return GRUB_ERR_NONE;
+}
+
+/* This function is called to switch from first to second phase */
+grub_err_t
+grub_efiemu_mm_do_alloc (void)
+{
+ grub_err_t err;
+
+ /* Preallocate mmap */
+ efiemu_mmap = (grub_efi_memory_descriptor_t *)
+ grub_calloc (mmap_reserved_size, sizeof (grub_efi_memory_descriptor_t));
+ if (!efiemu_mmap)
+ {
+ grub_efiemu_unload ();
+ return grub_errno;
+ }
+
+ err = efiemu_alloc_requests ();
+ if (err)
+ return err;
+ err = grub_efiemu_mmap_fill ();
+ if (err)
+ return err;
+ return grub_efiemu_mmap_sort_and_uniq ();
+}
diff --git a/grub-core/efiemu/pnvram.c b/grub-core/efiemu/pnvram.c
new file mode 100644
index 0000000..dd42bc6
--- /dev/null
+++ b/grub-core/efiemu/pnvram.c
@@ -0,0 +1,269 @@
+/* Export pnvram and some variables for runtime */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/charset.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/efiemu/runtime.h>
+#include <grub/extcmd.h>
+
+/* Place for final location of variables */
+static int nvram_handle = 0;
+static int nvramsize_handle = 0;
+static int high_monotonic_count_handle = 0;
+static int timezone_handle = 0;
+static int accuracy_handle = 0;
+static int daylight_handle = 0;
+
+static grub_size_t nvramsize;
+
+/* Parse signed value */
+static int
+grub_strtosl (const char *arg, const char ** const end, int base)
+{
+ if (arg[0] == '-')
+ return -grub_strtoul (arg + 1, end, base);
+ return grub_strtoul (arg, end, base);
+}
+
+static inline int
+hextoval (char c)
+{
+ if (c >= '0' && c <= '9')
+ return c - '0';
+ if (c >= 'a' && c <= 'z')
+ return c - 'a' + 10;
+ if (c >= 'A' && c <= 'Z')
+ return c - 'A' + 10;
+ return 0;
+}
+
+static inline grub_err_t
+unescape (char *in, char *out, char *outmax, int *len)
+{
+ char *ptr, *dptr;
+ dptr = out;
+ for (ptr = in; *ptr && dptr < outmax; )
+ if (*ptr == '%' && ptr[1] && ptr[2])
+ {
+ *dptr = (hextoval (ptr[1]) << 4) | (hextoval (ptr[2]));
+ ptr += 3;
+ dptr++;
+ }
+ else
+ {
+ *dptr = *ptr;
+ ptr++;
+ dptr++;
+ }
+ if (dptr == outmax)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "too many NVRAM variables for reserved variable space."
+ " Try increasing EfiEmu.pnvram.size");
+ *len = dptr - out;
+ return 0;
+}
+
+/* Export stuff for efiemu */
+static grub_err_t
+nvram_set (void * data __attribute__ ((unused)))
+{
+ const char *env;
+ /* Take definitive pointers */
+ char *nvram = grub_efiemu_mm_obtain_request (nvram_handle);
+ grub_uint32_t *nvramsize_def
+ = grub_efiemu_mm_obtain_request (nvramsize_handle);
+ grub_uint32_t *high_monotonic_count
+ = grub_efiemu_mm_obtain_request (high_monotonic_count_handle);
+ grub_int16_t *timezone
+ = grub_efiemu_mm_obtain_request (timezone_handle);
+ grub_uint8_t *daylight
+ = grub_efiemu_mm_obtain_request (daylight_handle);
+ grub_uint32_t *accuracy
+ = grub_efiemu_mm_obtain_request (accuracy_handle);
+ char *nvramptr;
+ struct grub_env_var *var;
+
+ /* Copy to definitive loaction */
+ grub_dprintf ("efiemu", "preparing pnvram\n");
+
+ env = grub_env_get ("EfiEmu.pnvram.high_monotonic_count");
+ *high_monotonic_count = env ? grub_strtoul (env, 0, 0) : 1;
+ env = grub_env_get ("EfiEmu.pnvram.timezone");
+ *timezone = env ? grub_strtosl (env, 0, 0) : GRUB_EFI_UNSPECIFIED_TIMEZONE;
+ env = grub_env_get ("EfiEmu.pnvram.accuracy");
+ *accuracy = env ? grub_strtoul (env, 0, 0) : 50000000;
+ env = grub_env_get ("EfiEmu.pnvram.daylight");
+ *daylight = env ? grub_strtoul (env, 0, 0) : 0;
+
+ nvramptr = nvram;
+ grub_memset (nvram, 0, nvramsize);
+ FOR_SORTED_ENV (var)
+ {
+ const char *guid;
+ char *attr, *name, *varname;
+ struct efi_variable *efivar;
+ int len = 0;
+ int i;
+ grub_uint64_t guidcomp;
+
+ if (grub_memcmp (var->name, "EfiEmu.pnvram.",
+ sizeof ("EfiEmu.pnvram.") - 1) != 0)
+ continue;
+
+ guid = var->name + sizeof ("EfiEmu.pnvram.") - 1;
+
+ attr = grub_strchr (guid, '.');
+ if (!attr)
+ continue;
+ attr++;
+
+ name = grub_strchr (attr, '.');
+ if (!name)
+ continue;
+ name++;
+
+ efivar = (struct efi_variable *) nvramptr;
+ if (nvramptr - nvram + sizeof (struct efi_variable) > nvramsize)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "too many NVRAM variables for reserved variable space."
+ " Try increasing EfiEmu.pnvram.size");
+
+ nvramptr += sizeof (struct efi_variable);
+
+ efivar->guid.data1 = grub_cpu_to_le32 (grub_strtoul (guid, &guid, 16));
+ if (*guid != '-')
+ continue;
+ guid++;
+
+ efivar->guid.data2 = grub_cpu_to_le16 (grub_strtoul (guid, &guid, 16));
+ if (*guid != '-')
+ continue;
+ guid++;
+
+ efivar->guid.data3 = grub_cpu_to_le16 (grub_strtoul (guid, &guid, 16));
+ if (*guid != '-')
+ continue;
+ guid++;
+
+ guidcomp = grub_strtoull (guid, 0, 16);
+ for (i = 0; i < 8; i++)
+ efivar->guid.data4[i] = (guidcomp >> (56 - 8 * i)) & 0xff;
+
+ efivar->attributes = grub_strtoull (attr, 0, 16);
+
+ varname = grub_malloc (grub_strlen (name) + 1);
+ if (! varname)
+ return grub_errno;
+
+ if (unescape (name, varname, varname + grub_strlen (name) + 1, &len))
+ break;
+
+ len = grub_utf8_to_utf16 ((grub_uint16_t *) nvramptr,
+ (nvramsize - (nvramptr - nvram)) / 2,
+ (grub_uint8_t *) varname, len, NULL);
+
+ nvramptr += 2 * len;
+ *((grub_uint16_t *) nvramptr) = 0;
+ nvramptr += 2;
+ efivar->namelen = 2 * len + 2;
+
+ if (unescape (var->value, nvramptr, nvram + nvramsize, &len))
+ {
+ efivar->namelen = 0;
+ break;
+ }
+
+ nvramptr += len;
+
+ efivar->size = len;
+ }
+ if (grub_errno)
+ return grub_errno;
+
+ *nvramsize_def = nvramsize;
+
+ /* Register symbols */
+ grub_efiemu_register_symbol ("efiemu_variables", nvram_handle, 0);
+ grub_efiemu_register_symbol ("efiemu_varsize", nvramsize_handle, 0);
+ grub_efiemu_register_symbol ("efiemu_high_monotonic_count",
+ high_monotonic_count_handle, 0);
+ grub_efiemu_register_symbol ("efiemu_time_zone", timezone_handle, 0);
+ grub_efiemu_register_symbol ("efiemu_time_daylight", daylight_handle, 0);
+ grub_efiemu_register_symbol ("efiemu_time_accuracy",
+ accuracy_handle, 0);
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+nvram_unload (void * data __attribute__ ((unused)))
+{
+ grub_efiemu_mm_return_request (nvram_handle);
+ grub_efiemu_mm_return_request (nvramsize_handle);
+ grub_efiemu_mm_return_request (high_monotonic_count_handle);
+ grub_efiemu_mm_return_request (timezone_handle);
+ grub_efiemu_mm_return_request (accuracy_handle);
+ grub_efiemu_mm_return_request (daylight_handle);
+}
+
+grub_err_t
+grub_efiemu_pnvram (void)
+{
+ const char *size;
+ grub_err_t err;
+
+ nvramsize = 0;
+
+ size = grub_env_get ("EfiEmu.pnvram.size");
+ if (size)
+ nvramsize = grub_strtoul (size, 0, 0);
+
+ if (!nvramsize)
+ nvramsize = 2048;
+
+ err = grub_efiemu_register_prepare_hook (nvram_set, nvram_unload, 0);
+ if (err)
+ return err;
+
+ nvram_handle
+ = grub_efiemu_request_memalign (1, nvramsize,
+ GRUB_EFI_RUNTIME_SERVICES_DATA);
+ nvramsize_handle
+ = grub_efiemu_request_memalign (1, sizeof (grub_uint32_t),
+ GRUB_EFI_RUNTIME_SERVICES_DATA);
+ high_monotonic_count_handle
+ = grub_efiemu_request_memalign (1, sizeof (grub_uint32_t),
+ GRUB_EFI_RUNTIME_SERVICES_DATA);
+ timezone_handle
+ = grub_efiemu_request_memalign (1, sizeof (grub_uint16_t),
+ GRUB_EFI_RUNTIME_SERVICES_DATA);
+ daylight_handle
+ = grub_efiemu_request_memalign (1, sizeof (grub_uint8_t),
+ GRUB_EFI_RUNTIME_SERVICES_DATA);
+ accuracy_handle
+ = grub_efiemu_request_memalign (1, sizeof (grub_uint32_t),
+ GRUB_EFI_RUNTIME_SERVICES_DATA);
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/efiemu/prepare.c b/grub-core/efiemu/prepare.c
new file mode 100644
index 0000000..99ddb5a
--- /dev/null
+++ b/grub-core/efiemu/prepare.c
@@ -0,0 +1,169 @@
+/* Prepare efiemu. E.g. allocate memory, load the runtime
+ to appropriate place, etc */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/crypto.h>
+
+grub_err_t
+SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
+ struct grub_efiemu_configuration_table
+ *config_tables)
+{
+ grub_err_t err;
+ int conftable_handle;
+ struct grub_efiemu_configuration_table *cur;
+ struct grub_efiemu_prepare_hook *curhook;
+
+ int cntconftables = 0;
+ struct SUFFIX (grub_efiemu_configuration_table) *conftables = 0;
+ int i;
+ int handle;
+ grub_off_t off;
+
+ grub_dprintf ("efiemu", "Preparing EfiEmu\n");
+
+ /* Request space for the list of configuration tables */
+ for (cur = config_tables; cur; cur = cur->next)
+ cntconftables++;
+ conftable_handle
+ = grub_efiemu_request_memalign (GRUB_EFIEMU_PAGESIZE,
+ cntconftables * sizeof (*conftables),
+ GRUB_EFI_RUNTIME_SERVICES_DATA);
+
+ /* Switch from phase 1 (counting) to phase 2 (real job) */
+ grub_efiemu_alloc_syms ();
+ grub_efiemu_mm_do_alloc ();
+ grub_efiemu_write_sym_markers ();
+
+ grub_efiemu_system_table32 = 0;
+ grub_efiemu_system_table64 = 0;
+
+ /* Execute hooks */
+ for (curhook = prepare_hooks; curhook; curhook = curhook->next)
+ curhook->hook (curhook->data);
+
+ /* Move runtime to its due place */
+ err = grub_efiemu_loadcore_load ();
+ if (err)
+ {
+ grub_efiemu_unload ();
+ return err;
+ }
+
+ err = grub_efiemu_resolve_symbol ("efiemu_system_table", &handle, &off);
+ if (err)
+ {
+ grub_efiemu_unload ();
+ return err;
+ }
+
+ SUFFIX (grub_efiemu_system_table)
+ = (struct SUFFIX (grub_efi_system_table) *)
+ ((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
+
+ /* Put pointer to the list of configuration tables in system 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 */
+ conftables = (struct SUFFIX (grub_efiemu_configuration_table) *)
+ grub_efiemu_mm_obtain_request (conftable_handle);
+ i = 0;
+ for (cur = config_tables; cur; cur = cur->next, i++)
+ {
+ grub_memcpy (&(conftables[i].vendor_guid), &(cur->guid),
+ sizeof (cur->guid));
+ if (cur->get_table)
+ conftables[i].vendor_table = (grub_addr_t) cur->get_table (cur->data);
+ else
+ conftables[i].vendor_table = (grub_addr_t) cur->data;
+ }
+
+ err = SUFFIX (grub_efiemu_crc) ();
+ if (err)
+ {
+ grub_efiemu_unload ();
+ return err;
+ }
+
+ grub_dprintf ("efiemu","system_table = %p, conftables = %p (%d entries)\n",
+ SUFFIX (grub_efiemu_system_table), conftables, cntconftables);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+SUFFIX (grub_efiemu_crc) (void)
+{
+ grub_err_t err;
+ int handle;
+ grub_off_t off;
+ struct SUFFIX (grub_efiemu_runtime_services) *runtime_services;
+ grub_uint32_t crc32_val;
+
+ if (GRUB_MD_CRC32->mdlen != 4)
+ return grub_error (GRUB_ERR_BUG, "incorrect mdlen");
+
+ /* compute CRC32 of runtime_services */
+ err = grub_efiemu_resolve_symbol ("efiemu_runtime_services",
+ &handle, &off);
+ if (err)
+ return err;
+
+ runtime_services = (struct SUFFIX (grub_efiemu_runtime_services) *)
+ ((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
+
+ runtime_services->hdr.crc32 = 0;
+
+ grub_crypto_hash (GRUB_MD_CRC32, &crc32_val,
+ runtime_services, runtime_services->hdr.header_size);
+ runtime_services->hdr.crc32 =
+ grub_be_to_cpu32(crc32_val);
+
+ err = grub_efiemu_resolve_symbol ("efiemu_system_table", &handle, &off);
+ if (err)
+ return err;
+
+ /* compute CRC32 of system table */
+ SUFFIX (grub_efiemu_system_table)->hdr.crc32 = 0;
+ grub_crypto_hash (GRUB_MD_CRC32, &crc32_val,
+ SUFFIX (grub_efiemu_system_table),
+ SUFFIX (grub_efiemu_system_table)->hdr.header_size);
+ SUFFIX (grub_efiemu_system_table)->hdr.crc32 =
+ grub_be_to_cpu32(crc32_val);
+
+ grub_dprintf ("efiemu","system_table = %p, runtime_services = %p\n",
+ SUFFIX (grub_efiemu_system_table), runtime_services);
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/efiemu/prepare32.c b/grub-core/efiemu/prepare32.c
new file mode 100644
index 0000000..fd6109e
--- /dev/null
+++ b/grub-core/efiemu/prepare32.c
@@ -0,0 +1,22 @@
+/* This file contains definitions so that prepare.c compiles for 32-bit */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define SUFFIX(x) x ## 32
+
+#include "prepare.c"
diff --git a/grub-core/efiemu/prepare64.c b/grub-core/efiemu/prepare64.c
new file mode 100644
index 0000000..811f558
--- /dev/null
+++ b/grub-core/efiemu/prepare64.c
@@ -0,0 +1,22 @@
+/* This file contains definitions so that prepare.c compiles for 64-bit */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define SUFFIX(x) x ## 64
+
+#include "prepare.c"
diff --git a/grub-core/efiemu/runtime/config.h b/grub-core/efiemu/runtime/config.h
new file mode 100644
index 0000000..c9fe027
--- /dev/null
+++ b/grub-core/efiemu/runtime/config.h
@@ -0,0 +1,36 @@
+/* This is a pseudo config.h so that types.h compiles nicely */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define GRUB_TYPES_CPU_HEADER 1
+
+#ifdef __i386__
+# define SIZEOF_VOID_P 4
+# define SIZEOF_LONG 4
+# define GRUB_TARGET_SIZEOF_VOID_P 4
+# define GRUB_TARGET_SIZEOF_LONG 4
+# define EFI_FUNC(x) x
+#elif defined (__x86_64__)
+# define SIZEOF_VOID_P 8
+# define SIZEOF_LONG 8
+# define GRUB_TARGET_SIZEOF_VOID_P 8
+# define GRUB_TARGET_SIZEOF_LONG 8
+# define EFI_FUNC(x) x ## _real
+#else
+#error "Unknown architecture"
+#endif
diff --git a/grub-core/efiemu/runtime/efiemu.S b/grub-core/efiemu/runtime/efiemu.S
new file mode 100644
index 0000000..b502314
--- /dev/null
+++ b/grub-core/efiemu/runtime/efiemu.S
@@ -0,0 +1,159 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+
+/*
+ * x86_64 uses registry to pass parameters. Unfortunately, gcc and efi use
+ * different call conversion, so we need to do some conversion.
+ *
+ * gcc:
+ * %rdi, %rsi, %rdx, %rcx, %r8, %r9, 8(%rsp), 16(%rsp), ...
+ *
+ * efi:
+ * %rcx, %rdx, %r8, %r9, 32(%rsp), 40(%rsp), 48(%rsp), ...
+ *
+ */
+
+ .file "efiemu.S"
+ .text
+
+FUNCTION (efiemu_get_time)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ mov %rdx, %rsi
+ call efiemu_get_time_real
+ pop %rsi
+ pop %rdi
+ ret
+
+FUNCTION (efiemu_set_time)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ call efiemu_set_time_real
+ pop %rsi
+ pop %rdi
+ ret
+
+
+FUNCTION (efiemu_get_wakeup_time)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ mov %rdx, %rsi
+ mov %r8, %rdx
+ call efiemu_get_wakeup_time_real
+ pop %rsi
+ pop %rdi
+ ret
+
+FUNCTION (efiemu_set_wakeup_time)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ mov %rdx, %rsi
+ call efiemu_set_wakeup_time_real
+ pop %rsi
+ pop %rdi
+ ret
+
+FUNCTION (efiemu_get_variable)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ mov %rdx, %rsi
+ mov %r8, %rdx
+ mov %r9, %rcx
+ mov 56(%rsp), %r8
+ call efiemu_get_variable_real
+ pop %rsi
+ pop %rdi
+ ret
+
+FUNCTION (efiemu_get_next_variable_name)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ mov %rdx, %rsi
+ mov %r8, %rdx
+ call efiemu_get_next_variable_name_real
+ pop %rsi
+ pop %rdi
+ ret
+
+FUNCTION (efiemu_set_variable)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ mov %rdx, %rsi
+ mov %r8, %rdx
+ mov %r9, %rcx
+ mov 56(%rsp), %r8
+ call efiemu_set_variable_real
+ pop %rsi
+ pop %rdi
+ ret
+
+FUNCTION (efiemu_get_next_high_monotonic_count)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ call efiemu_get_next_high_monotonic_count_real
+ pop %rsi
+ pop %rdi
+ ret
+
+FUNCTION (efiemu_reset_system)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ mov %rdx, %rsi
+ mov %r8, %rdx
+ mov %r9, %rcx
+ call efiemu_reset_system_real
+ pop %rsi
+ pop %rdi
+ ret
+
+ /* The following functions are always called in physical mode */
+ .section ".text-physical", "ax"
+
+FUNCTION (efiemu_set_virtual_address_map)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ mov %rdx, %rsi
+ mov %r8, %rdx
+ mov %r9, %rcx
+ call efiemu_set_virtual_address_map_real
+ pop %rsi
+ pop %rdi
+ ret
+
+FUNCTION (efiemu_convert_pointer)
+ push %rdi
+ push %rsi
+ mov %rcx, %rdi
+ mov %rdx, %rsi
+ call efiemu_convert_pointer_real
+ pop %rsi
+ pop %rdi
+ ret
+
diff --git a/grub-core/efiemu/runtime/efiemu.c b/grub-core/efiemu/runtime/efiemu.c
new file mode 100644
index 0000000..5db1f34
--- /dev/null
+++ b/grub-core/efiemu/runtime/efiemu.c
@@ -0,0 +1,636 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This is an emulation of EFI runtime services.
+ This allows a more uniform boot on i386 machines.
+ As it emulates only runtime serviceit isn't able
+ to chainload EFI bootloader on non-EFI system (TODO) */
+
+#ifdef __i386__
+#include <grub/i386/types.h>
+#else
+#include <grub/x86_64/types.h>
+#endif
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/efi/api.h>
+#include <grub/efiemu/runtime.h>
+
+grub_efi_status_t
+efiemu_get_time (grub_efi_time_t *time,
+ grub_efi_time_capabilities_t *capabilities);
+grub_efi_status_t
+efiemu_set_time (grub_efi_time_t *time);
+
+grub_efi_status_t
+efiemu_get_wakeup_time (grub_efi_boolean_t *enabled,
+ grub_efi_boolean_t *pending,
+ grub_efi_time_t *time);
+grub_efi_status_t
+efiemu_set_wakeup_time (grub_efi_boolean_t enabled,
+ grub_efi_time_t *time);
+
+#ifdef __APPLE__
+#define PHYSICAL_ATTRIBUTE __attribute__ ((section("_text-physical, _text-physical")));
+#else
+#define PHYSICAL_ATTRIBUTE __attribute__ ((section(".text-physical")));
+#endif
+
+grub_efi_status_t
+efiemu_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
+ grub_efi_uintn_t descriptor_size,
+ grub_efi_uint32_t descriptor_version,
+ grub_efi_memory_descriptor_t *virtual_map)
+ PHYSICAL_ATTRIBUTE;
+
+grub_efi_status_t
+efiemu_convert_pointer (grub_efi_uintn_t debug_disposition,
+ void **address)
+ PHYSICAL_ATTRIBUTE;
+
+grub_efi_status_t
+efiemu_get_variable (grub_efi_char16_t *variable_name,
+ const grub_efi_guid_t *vendor_guid,
+ grub_efi_uint32_t *attributes,
+ grub_efi_uintn_t *data_size,
+ void *data);
+
+grub_efi_status_t
+efiemu_get_next_variable_name (grub_efi_uintn_t *variable_name_size,
+ grub_efi_char16_t *variable_name,
+ grub_efi_guid_t *vendor_guid);
+
+grub_efi_status_t
+efiemu_set_variable (grub_efi_char16_t *variable_name,
+ const grub_efi_guid_t *vendor_guid,
+ grub_efi_uint32_t attributes,
+ grub_efi_uintn_t data_size,
+ void *data);
+grub_efi_status_t
+efiemu_get_next_high_monotonic_count (grub_efi_uint32_t *high_count);
+void
+efiemu_reset_system (grub_efi_reset_type_t reset_type,
+ grub_efi_status_t reset_status,
+ grub_efi_uintn_t data_size,
+ grub_efi_char16_t *reset_data);
+
+grub_efi_status_t
+EFI_FUNC (efiemu_set_virtual_address_map) (grub_efi_uintn_t,
+ grub_efi_uintn_t,
+ grub_efi_uint32_t,
+ grub_efi_memory_descriptor_t *)
+ PHYSICAL_ATTRIBUTE;
+grub_efi_status_t
+EFI_FUNC (efiemu_convert_pointer) (grub_efi_uintn_t debug_disposition,
+ void **address)
+ PHYSICAL_ATTRIBUTE;
+static grub_uint32_t
+efiemu_getcrc32 (grub_uint32_t crc, void *buf, int size)
+ PHYSICAL_ATTRIBUTE;
+static void
+init_crc32_table (void)
+ PHYSICAL_ATTRIBUTE;
+static grub_uint32_t
+reflect (grub_uint32_t ref, int len)
+ PHYSICAL_ATTRIBUTE;
+
+/*
+ The log. It's used when examining memory dump
+*/
+static grub_uint8_t loge[1000] = "EFIEMULOG";
+static int logn = 9;
+#define LOG(x) { if (logn<900) loge[logn++]=x; }
+
+/* Interface with grub */
+extern grub_uint8_t efiemu_ptv_relocated;
+struct grub_efi_runtime_services efiemu_runtime_services;
+struct grub_efi_system_table efiemu_system_table;
+extern struct grub_efiemu_ptv_rel efiemu_ptv_relloc[];
+extern grub_uint8_t efiemu_variables[];
+extern grub_uint32_t efiemu_varsize;
+extern grub_uint32_t efiemu_high_monotonic_count;
+extern grub_int16_t efiemu_time_zone;
+extern grub_uint8_t efiemu_time_daylight;
+extern grub_uint32_t efiemu_time_accuracy;
+
+/* Some standard functions because we need to be standalone */
+static void
+efiemu_memcpy (void *to, const void *from, int count)
+{
+ int i;
+ for (i = 0; i < count; i++)
+ ((grub_uint8_t *) to)[i] = ((const grub_uint8_t *) from)[i];
+}
+
+static int
+efiemu_str16equal (grub_uint16_t *a, grub_uint16_t *b)
+{
+ grub_uint16_t *ptr1, *ptr2;
+ for (ptr1=a,ptr2=b; *ptr1 && *ptr2 == *ptr1; ptr1++, ptr2++);
+ return *ptr2 == *ptr1;
+}
+
+static grub_size_t
+efiemu_str16len (grub_uint16_t *a)
+{
+ grub_uint16_t *ptr1;
+ for (ptr1 = a; *ptr1; ptr1++);
+ return ptr1 - a;
+}
+
+static int
+efiemu_memequal (const void *a, const void *b, grub_size_t n)
+{
+ grub_uint8_t *ptr1, *ptr2;
+ for (ptr1 = (grub_uint8_t *) a, ptr2 = (grub_uint8_t *)b;
+ ptr1 < (grub_uint8_t *)a + n && *ptr2 == *ptr1; ptr1++, ptr2++);
+ return ptr1 == a + n;
+}
+
+static void
+efiemu_memset (grub_uint8_t *a, grub_uint8_t b, grub_size_t n)
+{
+ grub_uint8_t *ptr1;
+ for (ptr1=a; ptr1 < a + n; ptr1++)
+ *ptr1 = b;
+}
+
+static inline void
+write_cmos (grub_uint8_t addr, grub_uint8_t val)
+{
+ asm volatile ("outb %%al,$0x70\n"
+ "mov %%cl, %%al\n"
+ "outb %%al,$0x71": :"a" (addr), "c" (val));
+}
+
+static inline grub_uint8_t
+read_cmos (grub_uint8_t addr)
+{
+ grub_uint8_t ret;
+ asm volatile ("outb %%al, $0x70\n"
+ "inb $0x71, %%al": "=a"(ret) :"a" (addr));
+ return ret;
+}
+
+/* Needed by some gcc versions */
+int __stack_chk_fail ()
+{
+ return 0;
+}
+
+/* The function that implement runtime services as specified in
+ EFI specification */
+static inline grub_uint8_t
+bcd_to_hex (grub_uint8_t in)
+{
+ return 10 * ((in & 0xf0) >> 4) + (in & 0x0f);
+}
+
+grub_efi_status_t
+EFI_FUNC (efiemu_get_time) (grub_efi_time_t *time,
+ grub_efi_time_capabilities_t *capabilities)
+{
+ LOG ('a');
+ grub_uint8_t state;
+ state = read_cmos (0xb);
+ if (!(state & (1 << 2)))
+ {
+ time->year = 2000 + bcd_to_hex (read_cmos (0x9));
+ time->month = bcd_to_hex (read_cmos (0x8));
+ time->day = bcd_to_hex (read_cmos (0x7));
+ time->hour = bcd_to_hex (read_cmos (0x4));
+ if (time->hour >= 81)
+ time->hour -= 80 - 12;
+ if (time->hour == 24)
+ time->hour = 0;
+ time->minute = bcd_to_hex (read_cmos (0x2));
+ time->second = bcd_to_hex (read_cmos (0x0));
+ }
+ else
+ {
+ time->year = 2000 + read_cmos (0x9);
+ time->month = read_cmos (0x8);
+ time->day = read_cmos (0x7);
+ time->hour = read_cmos (0x4);
+ if (time->hour >= 0x81)
+ time->hour -= 0x80 - 12;
+ if (time->hour == 24)
+ time->hour = 0;
+ time->minute = read_cmos (0x2);
+ time->second = read_cmos (0x0);
+ }
+ time->nanosecond = 0;
+ time->pad1 = 0;
+ time->pad2 = 0;
+ time->time_zone = efiemu_time_zone;
+ time->daylight = efiemu_time_daylight;
+ capabilities->resolution = 1;
+ capabilities->accuracy = efiemu_time_accuracy;
+ capabilities->sets_to_zero = 0;
+ return GRUB_EFI_SUCCESS;
+}
+
+grub_efi_status_t
+EFI_FUNC (efiemu_set_time) (grub_efi_time_t *time)
+{
+ LOG ('b');
+ grub_uint8_t state;
+ state = read_cmos (0xb);
+ write_cmos (0xb, state | 0x6);
+ write_cmos (0x9, time->year - 2000);
+ write_cmos (0x8, time->month);
+ write_cmos (0x7, time->day);
+ write_cmos (0x4, time->hour);
+ write_cmos (0x2, time->minute);
+ write_cmos (0x0, time->second);
+ efiemu_time_zone = time->time_zone;
+ efiemu_time_daylight = time->daylight;
+ return GRUB_EFI_SUCCESS;
+}
+
+/* Following 2 functions are vendor specific. So announce it as unsupported */
+grub_efi_status_t
+EFI_FUNC (efiemu_get_wakeup_time) (grub_efi_boolean_t *enabled,
+ grub_efi_boolean_t *pending,
+ grub_efi_time_t *time)
+{
+ LOG ('c');
+ return GRUB_EFI_UNSUPPORTED;
+}
+
+grub_efi_status_t
+EFI_FUNC (efiemu_set_wakeup_time) (grub_efi_boolean_t enabled,
+ grub_efi_time_t *time)
+{
+ LOG ('d');
+ return GRUB_EFI_UNSUPPORTED;
+}
+
+static grub_uint32_t crc32_table [256];
+
+static grub_uint32_t
+reflect (grub_uint32_t ref, int len)
+{
+ grub_uint32_t result = 0;
+ int i;
+
+ for (i = 1; i <= len; i++)
+ {
+ if (ref & 1)
+ result |= 1 << (len - i);
+ ref >>= 1;
+ }
+
+ return result;
+}
+
+static void
+init_crc32_table (void)
+{
+ grub_uint32_t polynomial = 0x04c11db7;
+ int i, j;
+
+ for(i = 0; i < 256; i++)
+ {
+ crc32_table[i] = reflect(i, 8) << 24;
+ for (j = 0; j < 8; j++)
+ crc32_table[i] = (crc32_table[i] << 1) ^
+ (crc32_table[i] & (1 << 31) ? polynomial : 0);
+ crc32_table[i] = reflect(crc32_table[i], 32);
+ }
+}
+
+static grub_uint32_t
+efiemu_getcrc32 (grub_uint32_t crc, void *buf, int size)
+{
+ int i;
+ grub_uint8_t *data = buf;
+
+ if (! crc32_table[1])
+ init_crc32_table ();
+
+ crc^= 0xffffffff;
+
+ for (i = 0; i < size; i++)
+ {
+ crc = (crc >> 8) ^ crc32_table[(crc & 0xFF) ^ *data];
+ data++;
+ }
+
+ return crc ^ 0xffffffff;
+}
+
+
+grub_efi_status_t EFI_FUNC
+(efiemu_set_virtual_address_map) (grub_efi_uintn_t memory_map_size,
+ grub_efi_uintn_t descriptor_size,
+ grub_efi_uint32_t descriptor_version,
+ grub_efi_memory_descriptor_t *virtual_map)
+{
+ struct grub_efiemu_ptv_rel *cur_relloc;
+
+ LOG ('e');
+
+ /* Ensure that we are called only once */
+ if (efiemu_ptv_relocated)
+ return GRUB_EFI_UNSUPPORTED;
+ efiemu_ptv_relocated = 1;
+
+ /* Correct addresses using information supplied by grub */
+ for (cur_relloc = efiemu_ptv_relloc; cur_relloc->size;cur_relloc++)
+ {
+ grub_int64_t corr = 0;
+ grub_efi_memory_descriptor_t *descptr;
+
+ /* Compute correction */
+ for (descptr = virtual_map;
+ ((grub_uint8_t *) descptr - (grub_uint8_t *) virtual_map)
+ < memory_map_size;
+ descptr = (grub_efi_memory_descriptor_t *)
+ ((grub_uint8_t *) descptr + descriptor_size))
+ {
+ if (descptr->type == cur_relloc->plustype)
+ corr += descptr->virtual_start - descptr->physical_start;
+ if (descptr->type == cur_relloc->minustype)
+ corr -= descptr->virtual_start - descptr->physical_start;
+ }
+
+ /* Apply correction */
+ switch (cur_relloc->size)
+ {
+ case 8:
+ *((grub_uint64_t *) (grub_addr_t) cur_relloc->addr) += corr;
+ break;
+ case 4:
+ *((grub_uint32_t *) (grub_addr_t) cur_relloc->addr) += corr;
+ break;
+ case 2:
+ *((grub_uint16_t *) (grub_addr_t) cur_relloc->addr) += corr;
+ break;
+ case 1:
+ *((grub_uint8_t *) (grub_addr_t) cur_relloc->addr) += corr;
+ break;
+ }
+ }
+
+ /* Recompute crc32 of system table and runtime services */
+ efiemu_system_table.hdr.crc32 = 0;
+ efiemu_system_table.hdr.crc32 = efiemu_getcrc32
+ (0, &efiemu_system_table, sizeof (efiemu_system_table));
+
+ efiemu_runtime_services.hdr.crc32 = 0;
+ efiemu_runtime_services.hdr.crc32 = efiemu_getcrc32
+ (0, &efiemu_runtime_services, sizeof (efiemu_runtime_services));
+
+ return GRUB_EFI_SUCCESS;
+}
+
+/* since efiemu_set_virtual_address_map corrects all the pointers
+ we don't need efiemu_convert_pointer */
+grub_efi_status_t
+EFI_FUNC (efiemu_convert_pointer) (grub_efi_uintn_t debug_disposition,
+ void **address)
+{
+ LOG ('f');
+ return GRUB_EFI_UNSUPPORTED;
+}
+
+/* Next comes variable services. Because we have no vendor-independent
+ way to store these variables we have no non-volatility */
+
+/* Find variable by name and GUID. */
+static struct efi_variable *
+find_variable (const grub_efi_guid_t *vendor_guid,
+ grub_efi_char16_t *variable_name)
+{
+ grub_uint8_t *ptr;
+ struct efi_variable *efivar;
+
+ for (ptr = efiemu_variables; ptr < efiemu_variables + efiemu_varsize; )
+ {
+ efivar = (struct efi_variable *) ptr;
+ if (!efivar->namelen)
+ return 0;
+ if (efiemu_str16equal((grub_efi_char16_t *)(efivar + 1), variable_name)
+ && efiemu_memequal (&(efivar->guid), vendor_guid,
+ sizeof (efivar->guid)))
+ return efivar;
+ ptr += efivar->namelen + efivar->size + sizeof (*efivar);
+ }
+ return 0;
+}
+
+grub_efi_status_t
+EFI_FUNC (efiemu_get_variable) (grub_efi_char16_t *variable_name,
+ const grub_efi_guid_t *vendor_guid,
+ grub_efi_uint32_t *attributes,
+ grub_efi_uintn_t *data_size,
+ void *data)
+{
+ struct efi_variable *efivar;
+ LOG ('g');
+ efivar = find_variable (vendor_guid, variable_name);
+ if (!efivar)
+ return GRUB_EFI_NOT_FOUND;
+ if (*data_size < efivar->size)
+ {
+ *data_size = efivar->size;
+ return GRUB_EFI_BUFFER_TOO_SMALL;
+ }
+ *data_size = efivar->size;
+ efiemu_memcpy (data, (grub_uint8_t *)(efivar + 1) + efivar->namelen,
+ efivar->size);
+ *attributes = efivar->attributes;
+
+ return GRUB_EFI_SUCCESS;
+}
+
+grub_efi_status_t EFI_FUNC
+(efiemu_get_next_variable_name) (grub_efi_uintn_t *variable_name_size,
+ grub_efi_char16_t *variable_name,
+ grub_efi_guid_t *vendor_guid)
+{
+ struct efi_variable *efivar;
+ LOG ('l');
+
+ if (!variable_name_size || !variable_name || !vendor_guid)
+ return GRUB_EFI_INVALID_PARAMETER;
+ if (variable_name[0])
+ {
+ efivar = find_variable (vendor_guid, variable_name);
+ if (!efivar)
+ return GRUB_EFI_NOT_FOUND;
+ efivar = (struct efi_variable *)((grub_uint8_t *)efivar
+ + efivar->namelen
+ + efivar->size + sizeof (*efivar));
+ }
+ else
+ efivar = (struct efi_variable *) (efiemu_variables);
+
+ LOG ('m');
+ if ((grub_uint8_t *)efivar >= efiemu_variables + efiemu_varsize
+ || !efivar->namelen)
+ return GRUB_EFI_NOT_FOUND;
+ if (*variable_name_size < efivar->namelen)
+ {
+ *variable_name_size = efivar->namelen;
+ return GRUB_EFI_BUFFER_TOO_SMALL;
+ }
+
+ efiemu_memcpy (variable_name, efivar + 1, efivar->namelen);
+ efiemu_memcpy (vendor_guid, &(efivar->guid),
+ sizeof (efivar->guid));
+
+ LOG('h');
+ return GRUB_EFI_SUCCESS;
+}
+
+grub_efi_status_t
+EFI_FUNC (efiemu_set_variable) (grub_efi_char16_t *variable_name,
+ const grub_efi_guid_t *vendor_guid,
+ grub_efi_uint32_t attributes,
+ grub_efi_uintn_t data_size,
+ void *data)
+{
+ struct efi_variable *efivar;
+ grub_uint8_t *ptr;
+ LOG('i');
+ if (!variable_name[0])
+ return GRUB_EFI_INVALID_PARAMETER;
+ efivar = find_variable (vendor_guid, variable_name);
+
+ /* Delete variable if any */
+ if (efivar)
+ {
+ efiemu_memcpy (efivar, (grub_uint8_t *)(efivar + 1)
+ + efivar->namelen + efivar->size,
+ (efiemu_variables + efiemu_varsize)
+ - ((grub_uint8_t *)(efivar + 1)
+ + efivar->namelen + efivar->size));
+ efiemu_memset (efiemu_variables + efiemu_varsize
+ - (sizeof (*efivar) + efivar->namelen + efivar->size),
+ 0, (sizeof (*efivar) + efivar->namelen + efivar->size));
+ }
+
+ if (!data_size)
+ return GRUB_EFI_SUCCESS;
+
+ for (ptr = efiemu_variables; ptr < efiemu_variables + efiemu_varsize; )
+ {
+ efivar = (struct efi_variable *) ptr;
+ ptr += efivar->namelen + efivar->size + sizeof (*efivar);
+ if (!efivar->namelen)
+ break;
+ }
+ if ((grub_uint8_t *)(efivar + 1) + data_size
+ + 2 * (efiemu_str16len (variable_name) + 1)
+ >= efiemu_variables + efiemu_varsize)
+ return GRUB_EFI_OUT_OF_RESOURCES;
+
+ efiemu_memcpy (&(efivar->guid), vendor_guid, sizeof (efivar->guid));
+ efivar->namelen = 2 * (efiemu_str16len (variable_name) + 1);
+ efivar->size = data_size;
+ efivar->attributes = attributes;
+ efiemu_memcpy (efivar + 1, variable_name,
+ 2 * (efiemu_str16len (variable_name) + 1));
+ efiemu_memcpy ((grub_uint8_t *)(efivar + 1)
+ + 2 * (efiemu_str16len (variable_name) + 1),
+ data, data_size);
+
+ return GRUB_EFI_SUCCESS;
+}
+
+grub_efi_status_t EFI_FUNC
+(efiemu_get_next_high_monotonic_count) (grub_efi_uint32_t *high_count)
+{
+ LOG ('j');
+ if (!high_count)
+ return GRUB_EFI_INVALID_PARAMETER;
+ *high_count = ++efiemu_high_monotonic_count;
+ return GRUB_EFI_SUCCESS;
+}
+
+/* To implement it with APM we need to go to real mode. It's too much hassle
+ Besides EFI specification says that this function shouldn't be used
+ on systems supporting ACPI
+ */
+void
+EFI_FUNC (efiemu_reset_system) (grub_efi_reset_type_t reset_type,
+ grub_efi_status_t reset_status,
+ grub_efi_uintn_t data_size,
+ grub_efi_char16_t *reset_data)
+{
+ LOG ('k');
+}
+
+struct grub_efi_runtime_services efiemu_runtime_services =
+{
+ .hdr =
+ {
+ .signature = GRUB_EFIEMU_RUNTIME_SERVICES_SIGNATURE,
+ .revision = 0x0001000a,
+ .header_size = sizeof (struct grub_efi_runtime_services),
+ .crc32 = 0, /* filled later*/
+ .reserved = 0
+ },
+ .get_time = efiemu_get_time,
+ .set_time = efiemu_set_time,
+ .get_wakeup_time = efiemu_get_wakeup_time,
+ .set_wakeup_time = efiemu_set_wakeup_time,
+
+ .set_virtual_address_map = efiemu_set_virtual_address_map,
+ .convert_pointer = efiemu_convert_pointer,
+
+ .get_variable = efiemu_get_variable,
+ .get_next_variable_name = efiemu_get_next_variable_name,
+ .set_variable = efiemu_set_variable,
+ .get_next_high_monotonic_count = efiemu_get_next_high_monotonic_count,
+
+ .reset_system = efiemu_reset_system
+};
+
+
+static grub_uint16_t efiemu_vendor[] =
+ {'G', 'R', 'U', 'B', ' ', 'E', 'F', 'I', ' ',
+ 'R', 'U', 'N', 'T', 'I', 'M', 'E', 0};
+
+struct grub_efi_system_table efiemu_system_table =
+{
+ .hdr =
+ {
+ .signature = GRUB_EFIEMU_SYSTEM_TABLE_SIGNATURE,
+ .revision = 0x0001000a,
+ .header_size = sizeof (struct grub_efi_system_table),
+ .crc32 = 0, /* filled later*/
+ .reserved = 0
+ },
+ .firmware_vendor = efiemu_vendor,
+ .firmware_revision = 0x0001000a,
+ .console_in_handler = 0,
+ .con_in = 0,
+ .console_out_handler = 0,
+ .con_out = 0,
+ .standard_error_handle = 0,
+ .std_err = 0,
+ .runtime_services = &efiemu_runtime_services,
+ .boot_services = 0,
+ .num_table_entries = 0,
+ .configuration_table = 0
+};
+
diff --git a/grub-core/efiemu/symbols.c b/grub-core/efiemu/symbols.c
new file mode 100644
index 0000000..cc14855
--- /dev/null
+++ b/grub-core/efiemu/symbols.c
@@ -0,0 +1,272 @@
+/* Code for managing symbols and pointers in efiemu */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/efiemu/efiemu.h>
+#include <grub/efiemu/runtime.h>
+#include <grub/i18n.h>
+
+static int ptv_written = 0;
+static int ptv_alloc = 0;
+static int ptv_handle = 0;
+static int relocated_handle = 0;
+static int ptv_requested = 0;
+static struct grub_efiemu_sym *efiemu_syms = 0;
+
+struct grub_efiemu_sym
+{
+ struct grub_efiemu_sym *next;
+ char *name;
+ int handle;
+ grub_off_t off;
+};
+
+void
+grub_efiemu_free_syms (void)
+{
+ struct grub_efiemu_sym *cur, *d;
+ for (cur = efiemu_syms; cur;)
+ {
+ d = cur->next;
+ grub_free (cur->name);
+ grub_free (cur);
+ cur = d;
+ }
+ efiemu_syms = 0;
+ ptv_written = 0;
+ ptv_alloc = 0;
+ ptv_requested = 0;
+ grub_efiemu_mm_return_request (ptv_handle);
+ ptv_handle = 0;
+ grub_efiemu_mm_return_request (relocated_handle);
+ relocated_handle = 0;
+}
+
+/* Announce that the module will need NUM allocators */
+/* Because of deferred memory allocation all the relocators have to be
+ announced during phase 1*/
+grub_err_t
+grub_efiemu_request_symbols (int num)
+{
+ if (ptv_alloc)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "symbols have already been allocated");
+ if (num < 0)
+ return grub_error (GRUB_ERR_BUG,
+ "can't request negative symbols");
+ ptv_requested += num;
+ return GRUB_ERR_NONE;
+}
+
+/* Resolve the symbol name NAME and set HANDLE and OFF accordingly */
+grub_err_t
+grub_efiemu_resolve_symbol (const char *name, int *handle, grub_off_t *off)
+{
+ struct grub_efiemu_sym *cur;
+ for (cur = efiemu_syms; cur; cur = cur->next)
+ if (!grub_strcmp (name, cur->name))
+ {
+ *handle = cur->handle;
+ *off = cur->off;
+ return GRUB_ERR_NONE;
+ }
+ grub_dprintf ("efiemu", "%s not found\n", name);
+ return grub_error (GRUB_ERR_BAD_OS, N_("symbol `%s' not found"), name);
+}
+
+/* Register symbol named NAME in memory handle HANDLE at offset OFF */
+grub_err_t
+grub_efiemu_register_symbol (const char *name, int handle, grub_off_t off)
+{
+ struct grub_efiemu_sym *cur;
+ cur = (struct grub_efiemu_sym *) grub_malloc (sizeof (*cur));
+ grub_dprintf ("efiemu", "registering symbol '%s'\n", name);
+ if (!cur)
+ return grub_errno;
+ cur->name = grub_strdup (name);
+ cur->next = efiemu_syms;
+ cur->handle = handle;
+ cur->off = off;
+ efiemu_syms = cur;
+
+ return 0;
+}
+
+/* Go from phase 1 to phase 2. Must be called before similar function in mm.c */
+grub_err_t
+grub_efiemu_alloc_syms (void)
+{
+ ptv_alloc = ptv_requested;
+ ptv_handle = grub_efiemu_request_memalign
+ (1, (ptv_requested + 1) * sizeof (struct grub_efiemu_ptv_rel),
+ GRUB_EFI_RUNTIME_SERVICES_DATA);
+ relocated_handle = grub_efiemu_request_memalign
+ (1, sizeof (grub_uint8_t), GRUB_EFI_RUNTIME_SERVICES_DATA);
+
+ grub_efiemu_register_symbol ("efiemu_ptv_relocated", relocated_handle, 0);
+ grub_efiemu_register_symbol ("efiemu_ptv_relloc", ptv_handle, 0);
+ return grub_errno;
+}
+
+grub_err_t
+grub_efiemu_write_sym_markers (void)
+{
+ struct grub_efiemu_ptv_rel *ptv_rels
+ = grub_efiemu_mm_obtain_request (ptv_handle);
+ grub_uint8_t *relocated = grub_efiemu_mm_obtain_request (relocated_handle);
+ grub_memset (ptv_rels, 0, (ptv_requested + 1)
+ * sizeof (struct grub_efiemu_ptv_rel));
+ *relocated = 0;
+ return GRUB_ERR_NONE;
+}
+
+/* Write value (pointer to memory PLUS_HANDLE)
+ - (pointer to memory MINUS_HANDLE) + VALUE to ADDR assuming that the
+ size SIZE bytes. If PTV_NEEDED is 1 then announce it to runtime that this
+ value needs to be recomputed before going to virtual mode
+*/
+grub_err_t
+grub_efiemu_write_value (void *addr, grub_uint32_t value, int plus_handle,
+ int minus_handle, int ptv_needed, int size)
+{
+ /* Announce relocator to runtime */
+ if (ptv_needed)
+ {
+ struct grub_efiemu_ptv_rel *ptv_rels
+ = grub_efiemu_mm_obtain_request (ptv_handle);
+
+ if (ptv_needed && ptv_written >= ptv_alloc)
+ return grub_error (GRUB_ERR_BUG,
+ "your module didn't declare efiemu "
+ " relocators correctly");
+
+ if (minus_handle)
+ ptv_rels[ptv_written].minustype
+ = grub_efiemu_mm_get_type (minus_handle);
+ else
+ ptv_rels[ptv_written].minustype = 0;
+
+ if (plus_handle)
+ ptv_rels[ptv_written].plustype
+ = grub_efiemu_mm_get_type (plus_handle);
+ else
+ ptv_rels[ptv_written].plustype = 0;
+
+ ptv_rels[ptv_written].addr = (grub_addr_t) addr;
+ ptv_rels[ptv_written].size = size;
+ ptv_written++;
+
+ /* memset next value to zero to mark the end */
+ grub_memset (&ptv_rels[ptv_written], 0, sizeof (ptv_rels[ptv_written]));
+ }
+
+ /* Compute the value */
+ if (minus_handle)
+ value -= (grub_addr_t) grub_efiemu_mm_obtain_request (minus_handle);
+
+ if (plus_handle)
+ value += (grub_addr_t) grub_efiemu_mm_obtain_request (plus_handle);
+
+ /* Write the value */
+ switch (size)
+ {
+ case 8:
+ *((grub_uint64_t *) addr) = value;
+ break;
+ case 4:
+ *((grub_uint32_t *) addr) = value;
+ break;
+ case 2:
+ *((grub_uint16_t *) addr) = value;
+ break;
+ case 1:
+ *((grub_uint8_t *) addr) = value;
+ break;
+ default:
+ return grub_error (GRUB_ERR_BUG, "wrong symbol size");
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_efiemu_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
+ grub_efi_uintn_t descriptor_size,
+ grub_efi_uint32_t descriptor_version
+ __attribute__ ((unused)),
+ grub_efi_memory_descriptor_t *virtual_map)
+{
+ grub_uint8_t *ptv_relocated;
+ struct grub_efiemu_ptv_rel *cur_relloc;
+ struct grub_efiemu_ptv_rel *ptv_rels;
+
+ ptv_relocated = grub_efiemu_mm_obtain_request (relocated_handle);
+ ptv_rels = grub_efiemu_mm_obtain_request (ptv_handle);
+
+ /* Ensure that we are called only once */
+ if (*ptv_relocated)
+ return grub_error (GRUB_ERR_BUG, "EfiEmu is already relocated");
+ *ptv_relocated = 1;
+
+ /* Correct addresses using information supplied by grub */
+ for (cur_relloc = ptv_rels; cur_relloc->size; cur_relloc++)
+ {
+ grub_int64_t corr = 0;
+ grub_efi_memory_descriptor_t *descptr;
+
+ /* Compute correction */
+ for (descptr = virtual_map;
+ (grub_size_t) ((grub_uint8_t *) descptr
+ - (grub_uint8_t *) virtual_map) < memory_map_size;
+ descptr = (grub_efi_memory_descriptor_t *)
+ ((grub_uint8_t *) descptr + descriptor_size))
+ {
+ if (descptr->type == cur_relloc->plustype)
+ corr += descptr->virtual_start - descptr->physical_start;
+ if (descptr->type == cur_relloc->minustype)
+ corr -= descptr->virtual_start - descptr->physical_start;
+ }
+
+ /* Apply correction */
+ switch (cur_relloc->size)
+ {
+ case 8:
+ *((grub_uint64_t *) (grub_addr_t) cur_relloc->addr) += corr;
+ break;
+ case 4:
+ *((grub_uint32_t *) (grub_addr_t) cur_relloc->addr) += corr;
+ break;
+ case 2:
+ *((grub_uint16_t *) (grub_addr_t) cur_relloc->addr) += corr;
+ break;
+ case 1:
+ *((grub_uint8_t *) (grub_addr_t) cur_relloc->addr) += corr;
+ break;
+ }
+ }
+
+ /* Recompute crc32 of system table and runtime services */
+
+ if (grub_efiemu_sizeof_uintn_t () == 4)
+ return grub_efiemu_crc32 ();
+ else
+ return grub_efiemu_crc64 ();
+}
diff --git a/grub-core/font/font.c b/grub-core/font/font.c
new file mode 100644
index 0000000..d09bb38
--- /dev/null
+++ b/grub-core/font/font.c
@@ -0,0 +1,1611 @@
+/* font.c - Font API and font file loader. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/bufio.h>
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/font.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/video.h>
+#include <grub/bitmap.h>
+#include <grub/charset.h>
+#include <grub/unicode.h>
+#include <grub/fontformat.h>
+#include <grub/env.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#if HAVE_FONT_SOURCE
+#include "ascii.h"
+#endif
+
+#ifndef FONT_DEBUG
+#define FONT_DEBUG 0
+#endif
+
+struct char_index_entry
+{
+ grub_uint32_t code;
+ grub_uint8_t storage_flags;
+ grub_uint32_t offset;
+
+ /* Glyph if loaded, or NULL otherwise. */
+ struct grub_font_glyph *glyph;
+};
+
+#define FONT_WEIGHT_NORMAL 100
+#define FONT_WEIGHT_BOLD 200
+#define ASCII_BITMAP_SIZE 16
+
+/* Definition of font registry. */
+struct grub_font_node *grub_font_list;
+
+static int register_font (grub_font_t font);
+static void font_init (grub_font_t font);
+static void free_font (grub_font_t font);
+static void remove_font (grub_font_t font);
+
+struct font_file_section
+{
+ /* The file this section is in. */
+ grub_file_t file;
+
+ /* FOURCC name of the section. */
+ char name[4];
+
+ /* Length of the section contents. */
+ grub_uint32_t length;
+
+ /* Set by open_section() on EOF. */
+ int eof;
+};
+
+/* Replace unknown glyphs with a rounded question mark. */
+static grub_uint8_t unknown_glyph_bitmap[] = {
+ /* 76543210 */
+ 0x7C, /* ooooo */
+ 0x82, /* o o */
+ 0xBA, /* o ooo o */
+ 0xAA, /* o o o o */
+ 0xAA, /* o o o o */
+ 0x8A, /* o o o */
+ 0x9A, /* o oo o */
+ 0x92, /* o o o */
+ 0x92, /* o o o */
+ 0x92, /* o o o */
+ 0x92, /* o o o */
+ 0x82, /* o o */
+ 0x92, /* o o o */
+ 0x82, /* o o */
+ 0x7C, /* ooooo */
+ 0x00 /* */
+};
+
+/* The "unknown glyph" glyph, used as a last resort. */
+static struct grub_font_glyph *unknown_glyph;
+
+/* The font structure used when no other font is loaded. This functions
+ as a "Null Object" pattern, so that code everywhere does not have to
+ check for a NULL grub_font_t to avoid dereferencing a null pointer. */
+static struct grub_font null_font;
+
+/* Flag to ensure module is initialized only once. */
+static grub_uint8_t font_loader_initialized;
+
+#if HAVE_FONT_SOURCE
+static struct grub_font_glyph *ascii_font_glyph[0x80];
+#endif
+
+static struct grub_font_glyph *
+ascii_glyph_lookup (grub_uint32_t code)
+{
+#if HAVE_FONT_SOURCE
+ static int ascii_failback_initialized = 0;
+
+ if (code >= 0x80)
+ return NULL;
+
+ if (ascii_failback_initialized == 0)
+ {
+ int current;
+ for (current = 0; current < 0x80; current++)
+ {
+ ascii_font_glyph[current] =
+ grub_malloc (sizeof (struct grub_font_glyph) + ASCII_BITMAP_SIZE);
+
+ ascii_font_glyph[current]->width = 8;
+ ascii_font_glyph[current]->height = 16;
+ ascii_font_glyph[current]->offset_x = 0;
+ ascii_font_glyph[current]->offset_y = -2;
+ ascii_font_glyph[current]->device_width = 8;
+ ascii_font_glyph[current]->font = NULL;
+
+ grub_memcpy (ascii_font_glyph[current]->bitmap,
+ &ascii_bitmaps[current * ASCII_BITMAP_SIZE],
+ ASCII_BITMAP_SIZE);
+ }
+
+ ascii_failback_initialized = 1;
+ }
+
+ return ascii_font_glyph[code];
+#else
+ (void) code;
+ return NULL;
+#endif
+}
+
+void
+grub_font_loader_init (void)
+{
+ /* Only initialize font loader once. */
+ if (font_loader_initialized)
+ return;
+
+ /* Make glyph for unknown glyph. */
+ unknown_glyph = grub_malloc (sizeof (struct grub_font_glyph)
+ + sizeof (unknown_glyph_bitmap));
+ if (!unknown_glyph)
+ return;
+
+ unknown_glyph->width = 8;
+ unknown_glyph->height = 16;
+ unknown_glyph->offset_x = 0;
+ unknown_glyph->offset_y = -3;
+ unknown_glyph->device_width = 8;
+ grub_memcpy (unknown_glyph->bitmap,
+ unknown_glyph_bitmap, sizeof (unknown_glyph_bitmap));
+
+ /* Initialize the null font. */
+ font_init (&null_font);
+ /* FIXME: Fix this slightly improper cast. */
+ null_font.name = (char *) "<No Font>";
+ null_font.ascent = unknown_glyph->height - 3;
+ null_font.descent = 3;
+ null_font.max_char_width = unknown_glyph->width;
+ null_font.max_char_height = unknown_glyph->height;
+
+ font_loader_initialized = 1;
+}
+
+/* Initialize the font object with initial default values. */
+static void
+font_init (grub_font_t font)
+{
+ font->name = 0;
+ font->file = 0;
+ font->family = 0;
+ font->point_size = 0;
+ font->weight = 0;
+
+ /* Default leading value, not in font file yet. */
+ font->leading = 1;
+
+ font->max_char_width = 0;
+ font->max_char_height = 0;
+ font->ascent = 0;
+ font->descent = 0;
+ font->num_chars = 0;
+ font->char_index = 0;
+ font->bmp_idx = 0;
+}
+
+/* Open the next section in the file.
+
+ On success, the section name is stored in section->name and the length in
+ section->length, and 0 is returned. On failure, 1 is returned and
+ grub_errno is set appropriately with an error message.
+
+ If 1 is returned due to being at the end of the file, then section->eof is
+ set to 1; otherwise, section->eof is set to 0. */
+static int
+open_section (grub_file_t file, struct font_file_section *section)
+{
+ grub_ssize_t retval;
+ grub_uint32_t raw_length;
+
+ section->file = file;
+ section->eof = 0;
+
+ /* Read the FOURCC section name. */
+ retval = grub_file_read (file, section->name, 4);
+ if (retval >= 0 && retval < 4)
+ {
+ /* EOF encountered. */
+ section->eof = 1;
+ return 1;
+ }
+ else if (retval < 0)
+ {
+ /* Read error. */
+ return 1;
+ }
+
+ /* Read the big-endian 32-bit section length. */
+ retval = grub_file_read (file, &raw_length, 4);
+ if (retval >= 0 && retval < 4)
+ {
+ /* EOF encountered. */
+ section->eof = 1;
+ return 1;
+ }
+ else if (retval < 0)
+ {
+ /* Read error. */
+ return 1;
+ }
+
+ /* Convert byte-order and store in *length. */
+ section->length = grub_be_to_cpu32 (raw_length);
+
+ return 0;
+}
+
+/* Size in bytes of each character index (CHIX section)
+ entry in the font file. */
+#define FONT_CHAR_INDEX_ENTRY_SIZE (4 + 1 + 4)
+
+/* Load the character index (CHIX) section contents from the font file. This
+ presumes that the position of FILE is positioned immediately after the
+ section length for the CHIX section (i.e., at the start of the section
+ contents). Returns 0 upon success, nonzero for failure (in which case
+ grub_errno is set appropriately). */
+static int
+load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
+ grub_font *font)
+{
+ unsigned i;
+ grub_uint32_t last_code;
+
+#if FONT_DEBUG >= 2
+ grub_dprintf ("font", "load_font_index(sect_length=%d)\n", sect_length);
+#endif
+
+ /* Sanity check: ensure section length is divisible by the entry size. */
+ if ((sect_length % FONT_CHAR_INDEX_ENTRY_SIZE) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_FONT,
+ "font file format error: character index length %d "
+ "is not a multiple of the entry size %d",
+ sect_length, FONT_CHAR_INDEX_ENTRY_SIZE);
+ return 1;
+ }
+
+ /* Calculate the number of characters. */
+ font->num_chars = sect_length / FONT_CHAR_INDEX_ENTRY_SIZE;
+
+ /* Allocate the character index array. */
+ font->char_index = grub_calloc (font->num_chars, sizeof (struct char_index_entry));
+ if (!font->char_index)
+ return 1;
+ font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t));
+ if (!font->bmp_idx)
+ return 1;
+ grub_memset (font->bmp_idx, 0xff, 0x10000 * sizeof (grub_uint16_t));
+
+
+#if FONT_DEBUG >= 2
+ grub_dprintf ("font", "num_chars=%d)\n", font->num_chars);
+#endif
+
+ last_code = 0;
+
+ /* Load the character index data from the file. */
+ for (i = 0; i < font->num_chars; i++)
+ {
+ struct char_index_entry *entry = &font->char_index[i];
+
+ /* Read code point value; convert to native byte order. */
+ if (grub_file_read (file, &entry->code, 4) != 4)
+ return 1;
+ entry->code = grub_be_to_cpu32 (entry->code);
+
+ /* Verify that characters are in ascending order. */
+ if (i != 0 && entry->code <= last_code)
+ {
+ grub_error (GRUB_ERR_BAD_FONT,
+ "font characters not in ascending order: %u <= %u",
+ entry->code, last_code);
+ return 1;
+ }
+
+ if (entry->code < 0x10000)
+ font->bmp_idx[entry->code] = i;
+
+ last_code = entry->code;
+
+ /* Read storage flags byte. */
+ if (grub_file_read (file, &entry->storage_flags, 1) != 1)
+ return 1;
+
+ /* Read glyph data offset; convert to native byte order. */
+ if (grub_file_read (file, &entry->offset, 4) != 4)
+ return 1;
+ entry->offset = grub_be_to_cpu32 (entry->offset);
+
+ /* No glyph loaded. Will be loaded on demand and cached thereafter. */
+ entry->glyph = 0;
+
+#if FONT_DEBUG >= 5
+ /* Print the 1st 10 characters. */
+ if (i < 10)
+ grub_dprintf ("font", "c=%d o=%d\n", entry->code, entry->offset);
+#endif
+ }
+
+ return 0;
+}
+
+/* Read the contents of the specified section as a string, which is
+ allocated on the heap. Returns 0 if there is an error. */
+static char *
+read_section_as_string (struct font_file_section *section)
+{
+ char *str;
+ grub_size_t sz;
+ grub_ssize_t ret;
+
+ if (grub_add (section->length, 1, &sz))
+ return NULL;
+
+ str = grub_malloc (sz);
+ if (!str)
+ return 0;
+
+ ret = grub_file_read (section->file, str, section->length);
+ if (ret < 0 || ret != (grub_ssize_t) section->length)
+ {
+ grub_free (str);
+ return 0;
+ }
+
+ str[section->length] = '\0';
+ return str;
+}
+
+/* Read the contents of the current section as a 16-bit integer value,
+ which is stored into *VALUE.
+ Returns 0 upon success, nonzero upon failure. */
+static int
+read_section_as_short (struct font_file_section *section,
+ grub_int16_t * value)
+{
+ grub_uint16_t raw_value;
+
+ if (section->length != 2)
+ {
+ grub_error (GRUB_ERR_BAD_FONT,
+ "font file format error: section %c%c%c%c length "
+ "is %d but should be 2",
+ section->name[0], section->name[1],
+ section->name[2], section->name[3], section->length);
+ return 1;
+ }
+ if (grub_file_read (section->file, &raw_value, 2) != 2)
+ return 1;
+
+ *value = grub_be_to_cpu16 (raw_value);
+ return 0;
+}
+
+/* Load a font and add it to the beginning of the global font list.
+ Returns 0 upon success, nonzero upon failure. */
+grub_font_t
+grub_font_load (const char *filename)
+{
+ grub_file_t file = 0;
+ struct font_file_section section;
+ char magic[4];
+ grub_font_t font = 0;
+
+#if FONT_DEBUG >= 1
+ grub_dprintf ("font", "add_font(%s)\n", filename);
+#endif
+
+ if (filename[0] == '(' || filename[0] == '/' || filename[0] == '+')
+ file = grub_buffile_open (filename, GRUB_FILE_TYPE_FONT, 1024);
+ else
+ {
+ const char *prefix = grub_env_get ("prefix");
+ char *fullname, *ptr;
+ if (!prefix)
+ {
+ grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"),
+ "prefix");
+ goto fail;
+ }
+ fullname = grub_malloc (grub_strlen (prefix) + grub_strlen (filename) + 1
+ + sizeof ("/fonts/") + sizeof (".pf2"));
+ if (!fullname)
+ goto fail;
+ ptr = grub_stpcpy (fullname, prefix);
+ ptr = grub_stpcpy (ptr, "/fonts/");
+ ptr = grub_stpcpy (ptr, filename);
+ ptr = grub_stpcpy (ptr, ".pf2");
+ *ptr = 0;
+ file = grub_buffile_open (fullname, GRUB_FILE_TYPE_FONT, 1024);
+ grub_free (fullname);
+ }
+ if (!file)
+ goto fail;
+
+#if FONT_DEBUG >= 3
+ grub_dprintf ("font", "file opened\n");
+#endif
+
+ /* Read the FILE section. It indicates the file format. */
+ if (open_section (file, &section) != 0)
+ goto fail;
+
+#if FONT_DEBUG >= 3
+ grub_dprintf ("font", "opened FILE section\n");
+#endif
+ if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FILE,
+ sizeof (FONT_FORMAT_SECTION_NAMES_FILE) - 1) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_FONT,
+ "font file format error: 1st section must be FILE");
+ goto fail;
+ }
+
+#if FONT_DEBUG >= 3
+ grub_dprintf ("font", "section name ok\n");
+#endif
+ if (section.length != 4)
+ {
+ grub_error (GRUB_ERR_BAD_FONT,
+ "font file format error (file type ID length is %d "
+ "but should be 4)", section.length);
+ goto fail;
+ }
+
+#if FONT_DEBUG >= 3
+ grub_dprintf ("font", "section length ok\n");
+#endif
+ /* Check the file format type code. */
+ if (grub_file_read (file, magic, 4) != 4)
+ goto fail;
+
+#if FONT_DEBUG >= 3
+ grub_dprintf ("font", "read magic ok\n");
+#endif
+
+ if (grub_memcmp (magic, FONT_FORMAT_PFF2_MAGIC, 4) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_FONT, "invalid font magic %x %x %x %x",
+ magic[0], magic[1], magic[2], magic[3]);
+ goto fail;
+ }
+
+#if FONT_DEBUG >= 3
+ grub_dprintf ("font", "compare magic ok\n");
+#endif
+
+ /* Allocate the font object. */
+ font = (grub_font_t) grub_zalloc (sizeof (struct grub_font));
+ if (!font)
+ goto fail;
+
+ font_init (font);
+ font->file = file;
+
+#if FONT_DEBUG >= 3
+ grub_dprintf ("font", "allocate font ok; loading font info\n");
+#endif
+
+ /* Load the font information. */
+ while (1)
+ {
+ if (open_section (file, &section) != 0)
+ {
+ if (section.eof)
+ break; /* Done reading the font file. */
+ else
+ goto fail;
+ }
+
+#if FONT_DEBUG >= 2
+ grub_dprintf ("font", "opened section %c%c%c%c ok\n",
+ section.name[0], section.name[1],
+ section.name[2], section.name[3]);
+#endif
+
+ if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FONT_NAME,
+ sizeof (FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0)
+ {
+ if (font->name != NULL)
+ {
+ grub_error (GRUB_ERR_BAD_FONT, "invalid font file: too many NAME sections");
+ goto fail;
+ }
+
+ font->name = read_section_as_string (&section);
+ if (!font->name)
+ goto fail;
+ }
+ else if (grub_memcmp (section.name,
+ FONT_FORMAT_SECTION_NAMES_POINT_SIZE,
+ sizeof (FONT_FORMAT_SECTION_NAMES_POINT_SIZE) -
+ 1) == 0)
+ {
+ if (read_section_as_short (&section, &font->point_size) != 0)
+ goto fail;
+ }
+ else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_WEIGHT,
+ sizeof (FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1)
+ == 0)
+ {
+ char *wt;
+ wt = read_section_as_string (&section);
+ if (!wt)
+ continue;
+ /* Convert the weight string 'normal' or 'bold' into a number. */
+ if (grub_strcmp (wt, "normal") == 0)
+ font->weight = FONT_WEIGHT_NORMAL;
+ else if (grub_strcmp (wt, "bold") == 0)
+ font->weight = FONT_WEIGHT_BOLD;
+ grub_free (wt);
+ }
+ else if (grub_memcmp (section.name,
+ FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH,
+ sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH)
+ - 1) == 0)
+ {
+ if (read_section_as_short (&section, &font->max_char_width) != 0)
+ goto fail;
+ }
+ else if (grub_memcmp (section.name,
+ FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT,
+ sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT)
+ - 1) == 0)
+ {
+ if (read_section_as_short (&section, &font->max_char_height) != 0)
+ goto fail;
+ }
+ else if (grub_memcmp (section.name,
+ FONT_FORMAT_SECTION_NAMES_ASCENT,
+ sizeof (FONT_FORMAT_SECTION_NAMES_ASCENT) - 1)
+ == 0)
+ {
+ if (read_section_as_short (&section, &font->ascent) != 0)
+ goto fail;
+ }
+ else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DESCENT,
+ sizeof (FONT_FORMAT_SECTION_NAMES_DESCENT) - 1)
+ == 0)
+ {
+ if (read_section_as_short (&section, &font->descent) != 0)
+ goto fail;
+ }
+ else if (grub_memcmp (section.name,
+ FONT_FORMAT_SECTION_NAMES_CHAR_INDEX,
+ sizeof (FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) -
+ 1) == 0)
+ {
+ if (load_font_index (file, section.length, font) != 0)
+ goto fail;
+ }
+ else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DATA,
+ sizeof (FONT_FORMAT_SECTION_NAMES_DATA) - 1) == 0)
+ {
+ /* When the DATA section marker is reached, we stop reading. */
+ break;
+ }
+ else
+ {
+ /* Unhandled section type, simply skip past it. */
+#if FONT_DEBUG >= 3
+ grub_dprintf ("font", "Unhandled section type, skipping.\n");
+#endif
+ grub_off_t section_end = grub_file_tell (file) + section.length;
+ if ((int) grub_file_seek (file, section_end) == -1)
+ goto fail;
+ }
+ }
+
+ if (!font->name)
+ {
+ grub_dprintf ("font", "Font has no name.\n");
+ font->name = grub_strdup ("Unknown");
+ }
+
+#if FONT_DEBUG >= 1
+ grub_dprintf ("font", "Loaded font `%s'.\n"
+ "Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n",
+ font->name,
+ font->ascent, font->descent,
+ font->max_char_width, font->max_char_height, font->num_chars);
+#endif
+
+ if (font->max_char_width == 0
+ || font->max_char_height == 0
+ || font->num_chars == 0
+ || font->char_index == 0 || font->ascent == 0 || font->descent == 0)
+ {
+ grub_error (GRUB_ERR_BAD_FONT,
+ "invalid font file: missing some required data");
+ goto fail;
+ }
+
+ /* Add the font to the global font registry. */
+ if (register_font (font) != 0)
+ goto fail;
+
+ return font;
+
+fail:
+ if (file)
+ grub_file_close (file);
+ if (font)
+ font->file = 0;
+
+ free_font (font);
+ return 0;
+}
+
+/* Read a 16-bit big-endian integer from FILE, convert it to native byte
+ order, and store it in *VALUE.
+ Returns 0 on success, 1 on failure. */
+static int
+read_be_uint16 (grub_file_t file, grub_uint16_t * value)
+{
+ if (grub_file_read (file, value, 2) != 2)
+ return 1;
+ *value = grub_be_to_cpu16 (*value);
+ return 0;
+}
+
+static int
+read_be_int16 (grub_file_t file, grub_int16_t * value)
+{
+ /* For the signed integer version, use the same code as for unsigned. */
+ return read_be_uint16 (file, (grub_uint16_t *) value);
+}
+
+/* Return a pointer to the character index entry for the glyph corresponding to
+ the codepoint CODE in the font FONT. If not found, return zero. */
+static inline struct char_index_entry *
+find_glyph (const grub_font_t font, grub_uint32_t code)
+{
+ struct char_index_entry *table;
+ grub_size_t lo;
+ grub_size_t hi;
+ grub_size_t mid;
+
+ table = font->char_index;
+
+ /* Use BMP index if possible. */
+ if (code < 0x10000 && font->bmp_idx)
+ {
+ if (font->bmp_idx[code] == 0xffff)
+ return 0;
+ return &table[font->bmp_idx[code]];
+ }
+
+ /* Do a binary search in `char_index', which is ordered by code point. */
+ lo = 0;
+ hi = font->num_chars - 1;
+
+ if (!table)
+ return 0;
+
+ while (lo <= hi)
+ {
+ mid = lo + (hi - lo) / 2;
+ if (code < table[mid].code)
+ hi = mid - 1;
+ else if (code > table[mid].code)
+ lo = mid + 1;
+ else
+ return &table[mid];
+ }
+
+ return 0;
+}
+
+/* Get a glyph for the Unicode character CODE in FONT. The glyph is loaded
+ from the font file if has not been loaded yet.
+ Returns a pointer to the glyph if found, or 0 if it is not found. */
+static struct grub_font_glyph *
+grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
+{
+ struct char_index_entry *index_entry;
+
+ index_entry = find_glyph (font, code);
+ if (index_entry)
+ {
+ struct grub_font_glyph *glyph = 0;
+ grub_uint16_t width;
+ grub_uint16_t height;
+ grub_int16_t xoff;
+ grub_int16_t yoff;
+ grub_int16_t dwidth;
+ int len;
+
+ if (index_entry->glyph)
+ /* Return cached glyph. */
+ return index_entry->glyph;
+
+ if (!font->file)
+ /* No open file, can't load any glyphs. */
+ return 0;
+
+ /* Make sure we can find glyphs for error messages. Push active
+ error message to error stack and reset error message. */
+ grub_error_push ();
+
+ grub_file_seek (font->file, index_entry->offset);
+
+ /* Read the glyph width, height, and baseline. */
+ if (read_be_uint16 (font->file, &width) != 0
+ || read_be_uint16 (font->file, &height) != 0
+ || read_be_int16 (font->file, &xoff) != 0
+ || read_be_int16 (font->file, &yoff) != 0
+ || read_be_int16 (font->file, &dwidth) != 0)
+ {
+ remove_font (font);
+ return 0;
+ }
+
+ len = (width * height + 7) / 8;
+ glyph = grub_malloc (sizeof (struct grub_font_glyph) + len);
+ if (!glyph)
+ {
+ remove_font (font);
+ return 0;
+ }
+
+ glyph->font = font;
+ glyph->width = width;
+ glyph->height = height;
+ glyph->offset_x = xoff;
+ glyph->offset_y = yoff;
+ glyph->device_width = dwidth;
+
+ /* Don't try to read empty bitmaps (e.g., space characters). */
+ if (len != 0)
+ {
+ if (grub_file_read (font->file, glyph->bitmap, len) != len)
+ {
+ remove_font (font);
+ grub_free (glyph);
+ return 0;
+ }
+ }
+
+ /* Restore old error message. */
+ grub_error_pop ();
+
+ /* Cache the glyph. */
+ index_entry->glyph = glyph;
+
+ return glyph;
+ }
+
+ return 0;
+}
+
+/* Free the memory used by FONT.
+ This should not be called if the font has been made available to
+ users (once it is added to the global font list), since there would
+ be the possibility of a dangling pointer. */
+static void
+free_font (grub_font_t font)
+{
+ if (font)
+ {
+ if (font->file)
+ grub_file_close (font->file);
+ grub_free (font->name);
+ grub_free (font->family);
+ grub_free (font->char_index);
+ grub_free (font->bmp_idx);
+ grub_free (font);
+ }
+}
+
+/* Add FONT to the global font registry.
+ Returns 0 upon success, nonzero on failure
+ (the font was not registered). */
+static int
+register_font (grub_font_t font)
+{
+ struct grub_font_node *node = 0;
+
+ node = grub_malloc (sizeof (struct grub_font_node));
+ if (!node)
+ return 1;
+
+ node->value = font;
+ node->next = grub_font_list;
+ grub_font_list = node;
+
+ return 0;
+}
+
+/* Remove the font from the global font list. We don't actually free the
+ font's memory since users could be holding references to the font. */
+static void
+remove_font (grub_font_t font)
+{
+ struct grub_font_node **nextp, *cur;
+
+ for (nextp = &grub_font_list, cur = *nextp;
+ cur; nextp = &cur->next, cur = cur->next)
+ {
+ if (cur->value == font)
+ {
+ *nextp = cur->next;
+
+ /* Free the node, but not the font itself. */
+ grub_free (cur);
+
+ return;
+ }
+ }
+}
+
+/* Get a font from the list of loaded fonts. This function will return
+ another font if the requested font is not available. If no fonts are
+ loaded, then a special 'null font' is returned, which contains no glyphs,
+ but is not a null pointer so the caller may omit checks for NULL. */
+grub_font_t
+grub_font_get (const char *font_name)
+{
+ struct grub_font_node *node;
+
+ for (node = grub_font_list; node; node = node->next)
+ {
+ grub_font_t font = node->value;
+ if (grub_strcmp (font->name, font_name) == 0)
+ return font;
+ }
+
+ /* If no font by that name is found, return the first font in the list
+ as a fallback. */
+ if (grub_font_list && grub_font_list->value)
+ return grub_font_list->value;
+ else
+ /* The null_font is a last resort. */
+ return &null_font;
+}
+
+/* Get the full name of the font. */
+const char *
+grub_font_get_name (grub_font_t font)
+{
+ return font->name;
+}
+
+/* Get the maximum width of any character in the font in pixels. */
+int
+grub_font_get_max_char_width (grub_font_t font)
+{
+ return font->max_char_width;
+}
+
+/* Get the distance in pixels from the baseline to the lowest descenders
+ (for instance, in a lowercase 'y', 'g', etc.). */
+int
+grub_font_get_descent (grub_font_t font)
+{
+ return font->descent;
+}
+
+/* FIXME: not correct for all fonts. */
+int
+grub_font_get_xheight (grub_font_t font)
+{
+ return font->ascent / 2;
+}
+
+/* Get the *standard leading* of the font in pixel, which is the spacing
+ between two lines of text. Specifically, it is the space between the
+ descent of one line and the ascent of the next line. This is included
+ in the *height* metric. */
+int
+grub_font_get_leading (grub_font_t font)
+{
+ return font->leading;
+}
+
+/* Get the distance in pixels between baselines of adjacent lines of text. */
+int
+grub_font_get_height (grub_font_t font)
+{
+ return font->ascent + font->descent + font->leading;
+}
+
+/* Get the glyph for FONT corresponding to the Unicode code point CODE.
+ Returns the ASCII glyph for the code if no other fonts are available.
+ The glyphs are cached once loaded. */
+struct grub_font_glyph *
+grub_font_get_glyph (grub_font_t font, grub_uint32_t code)
+{
+ struct grub_font_glyph *glyph = 0;
+ if (font)
+ glyph = grub_font_get_glyph_internal (font, code);
+ if (glyph == 0)
+ {
+ glyph = ascii_glyph_lookup (code);
+ }
+ return glyph;
+}
+
+
+/* Calculate a subject value representing "how similar" two fonts are.
+ This is used to prioritize the order that fonts are scanned for missing
+ glyphs. The object is to select glyphs from the most similar font
+ possible, for the best appearance.
+ The heuristic is crude, but it helps greatly when fonts of similar
+ sizes are used so that tiny 8 point glyphs are not mixed into a string
+ of 24 point text unless there is no other choice. */
+static int
+get_font_diversity (grub_font_t a, grub_font_t b)
+{
+ int d;
+
+ d = 0;
+
+ if (a->ascent && b->ascent)
+ d += grub_abs (a->ascent - b->ascent) * 8;
+ else
+ /* Penalty for missing attributes. */
+ d += 50;
+
+ if (a->max_char_height && b->max_char_height)
+ d += grub_abs (a->max_char_height - b->max_char_height) * 8;
+ else
+ /* Penalty for missing attributes. */
+ d += 50;
+
+ /* Weight is a minor factor. */
+ d += (a->weight != b->weight) ? 5 : 0;
+
+ return d;
+}
+
+/* Get a glyph corresponding to the codepoint CODE. If FONT contains the
+ specified glyph, then it is returned. Otherwise, all other loaded fonts
+ are searched until one is found that contains a glyph for CODE.
+ If no glyph is available for CODE in the loaded fonts, then a glyph
+ representing an unknown character is returned.
+ This function never returns NULL.
+ The returned glyph is owned by the font manager and should not be freed
+ by the caller. The glyphs are cached. */
+struct grub_font_glyph *
+grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code)
+{
+ struct grub_font_glyph *glyph;
+ struct grub_font_node *node;
+ /* Keep track of next node, in case there's an I/O error in
+ grub_font_get_glyph_internal() and the font is removed from the list. */
+ struct grub_font_node *next;
+ /* Information on the best glyph found so far, to help find the glyph in
+ the best matching to the requested one. */
+ int best_diversity;
+ struct grub_font_glyph *best_glyph;
+
+ if (font)
+ {
+ /* First try to get the glyph from the specified font. */
+ glyph = grub_font_get_glyph_internal (font, code);
+ if (glyph)
+ return glyph;
+ }
+
+ /* Otherwise, search all loaded fonts for the glyph and use the one from
+ the font that best matches the requested font. */
+ best_diversity = 10000;
+ best_glyph = 0;
+
+ for (node = grub_font_list; node; node = next)
+ {
+ grub_font_t curfont;
+
+ curfont = node->value;
+ next = node->next;
+
+ glyph = grub_font_get_glyph_internal (curfont, code);
+ if (glyph && !font)
+ return glyph;
+ if (glyph)
+ {
+ int d;
+
+ d = get_font_diversity (curfont, font);
+ if (d < best_diversity)
+ {
+ best_diversity = d;
+ best_glyph = glyph;
+ }
+ }
+ }
+
+ return best_glyph;
+}
+
+#if 0
+static struct grub_font_glyph *
+grub_font_dup_glyph (struct grub_font_glyph *glyph)
+{
+ static struct grub_font_glyph *ret;
+ ret = grub_malloc (sizeof (*ret) + (glyph->width * glyph->height + 7) / 8);
+ if (!ret)
+ return NULL;
+ grub_memcpy (ret, glyph, sizeof (*ret)
+ + (glyph->width * glyph->height + 7) / 8);
+ return ret;
+}
+#endif
+
+/* FIXME: suboptimal. */
+static void
+grub_font_blit_glyph (struct grub_font_glyph *target,
+ struct grub_font_glyph *src, unsigned dx, unsigned dy)
+{
+ unsigned src_bit, tgt_bit, src_byte, tgt_byte;
+ unsigned i, j;
+ for (i = 0; i < src->height; i++)
+ {
+ src_bit = (src->width * i) % 8;
+ src_byte = (src->width * i) / 8;
+ tgt_bit = (target->width * (dy + i) + dx) % 8;
+ tgt_byte = (target->width * (dy + i) + dx) / 8;
+ for (j = 0; j < src->width; j++)
+ {
+ target->bitmap[tgt_byte] |= ((src->bitmap[src_byte] << src_bit)
+ & 0x80) >> tgt_bit;
+ src_bit++;
+ tgt_bit++;
+ if (src_bit == 8)
+ {
+ src_byte++;
+ src_bit = 0;
+ }
+ if (tgt_bit == 8)
+ {
+ tgt_byte++;
+ tgt_bit = 0;
+ }
+ }
+ }
+}
+
+static void
+grub_font_blit_glyph_mirror (struct grub_font_glyph *target,
+ struct grub_font_glyph *src,
+ unsigned dx, unsigned dy)
+{
+ unsigned tgt_bit, src_byte, tgt_byte;
+ signed src_bit;
+ unsigned i, j;
+ for (i = 0; i < src->height; i++)
+ {
+ src_bit = (src->width * i + src->width - 1) % 8;
+ src_byte = (src->width * i + src->width - 1) / 8;
+ tgt_bit = (target->width * (dy + i) + dx) % 8;
+ tgt_byte = (target->width * (dy + i) + dx) / 8;
+ for (j = 0; j < src->width; j++)
+ {
+ target->bitmap[tgt_byte] |= ((src->bitmap[src_byte] << src_bit)
+ & 0x80) >> tgt_bit;
+ src_bit--;
+ tgt_bit++;
+ if (src_bit == -1)
+ {
+ src_byte--;
+ src_bit = 7;
+ }
+ if (tgt_bit == 8)
+ {
+ tgt_byte++;
+ tgt_bit = 0;
+ }
+ }
+ }
+}
+
+/* Context for blit_comb. */
+struct blit_comb_ctx
+{
+ struct grub_font_glyph *glyph;
+ int *device_width;
+ struct grub_video_signed_rect bounds;
+};
+
+/* Helper for blit_comb. */
+static void
+do_blit (struct grub_font_glyph *src, signed dx, signed dy,
+ struct blit_comb_ctx *ctx)
+{
+ if (ctx->glyph)
+ grub_font_blit_glyph (ctx->glyph, src, dx - ctx->glyph->offset_x,
+ (ctx->glyph->height + ctx->glyph->offset_y) + dy);
+ if (dx < ctx->bounds.x)
+ {
+ ctx->bounds.width += ctx->bounds.x - dx;
+ ctx->bounds.x = dx;
+ }
+ if (ctx->bounds.y > -src->height - dy)
+ {
+ ctx->bounds.height += ctx->bounds.y - (-src->height - dy);
+ ctx->bounds.y = (-src->height - dy);
+ }
+ if (dx + src->width - ctx->bounds.x >= (signed) ctx->bounds.width)
+ ctx->bounds.width = dx + src->width - ctx->bounds.x + 1;
+ if ((signed) ctx->bounds.height < src->height + (-src->height - dy)
+ - ctx->bounds.y)
+ ctx->bounds.height = src->height + (-src->height - dy) - ctx->bounds.y;
+}
+
+/* Helper for blit_comb. */
+static inline void
+add_device_width (int val, struct blit_comb_ctx *ctx)
+{
+ if (ctx->glyph)
+ ctx->glyph->device_width += val;
+ if (ctx->device_width)
+ *ctx->device_width += val;
+}
+
+static void
+blit_comb (const struct grub_unicode_glyph *glyph_id,
+ struct grub_font_glyph *glyph,
+ struct grub_video_signed_rect *bounds_out,
+ struct grub_font_glyph *main_glyph,
+ struct grub_font_glyph **combining_glyphs, int *device_width)
+{
+ struct blit_comb_ctx ctx = {
+ .glyph = glyph,
+ .device_width = device_width
+ };
+ unsigned i;
+ signed above_rightx, above_righty;
+ signed above_leftx, above_lefty;
+ signed below_rightx, below_righty;
+ signed min_devwidth = 0;
+ const struct grub_unicode_combining *comb;
+
+ if (glyph)
+ glyph->device_width = main_glyph->device_width;
+ if (device_width)
+ *device_width = main_glyph->device_width;
+
+ ctx.bounds.x = main_glyph->offset_x;
+ ctx.bounds.y = main_glyph->offset_y;
+ ctx.bounds.width = main_glyph->width;
+ ctx.bounds.height = main_glyph->height;
+
+ above_rightx = main_glyph->offset_x + main_glyph->width;
+ above_righty = ctx.bounds.y + ctx.bounds.height;
+
+ above_leftx = main_glyph->offset_x;
+ above_lefty = ctx.bounds.y + ctx.bounds.height;
+
+ below_rightx = ctx.bounds.x + ctx.bounds.width;
+ below_righty = ctx.bounds.y;
+
+ comb = grub_unicode_get_comb (glyph_id);
+
+ for (i = 0; i < glyph_id->ncomb; i++)
+ {
+ grub_int16_t space = 0;
+ /* Center by default. */
+ grub_int16_t targetx;
+
+ if (!combining_glyphs[i])
+ continue;
+ targetx = (ctx.bounds.width - combining_glyphs[i]->width) / 2 + ctx.bounds.x;
+ /* CGJ is to avoid diacritics reordering. */
+ if (comb[i].code
+ == GRUB_UNICODE_COMBINING_GRAPHEME_JOINER)
+ continue;
+ switch (comb[i].type)
+ {
+ case GRUB_UNICODE_COMB_OVERLAY:
+ do_blit (combining_glyphs[i],
+ targetx,
+ (ctx.bounds.height - combining_glyphs[i]->height) / 2
+ - (ctx.bounds.height + ctx.bounds.y), &ctx);
+ if (min_devwidth < combining_glyphs[i]->width)
+ min_devwidth = combining_glyphs[i]->width;
+ break;
+
+ case GRUB_UNICODE_COMB_ATTACHED_ABOVE_RIGHT:
+ do_blit (combining_glyphs[i], above_rightx, -above_righty, &ctx);
+ above_rightx += combining_glyphs[i]->width;
+ break;
+
+ case GRUB_UNICODE_COMB_ABOVE_RIGHT:
+ do_blit (combining_glyphs[i], above_rightx,
+ -(above_righty + combining_glyphs[i]->height), &ctx);
+ above_rightx += combining_glyphs[i]->width;
+ break;
+
+ case GRUB_UNICODE_COMB_ABOVE_LEFT:
+ above_leftx -= combining_glyphs[i]->width;
+ do_blit (combining_glyphs[i], above_leftx,
+ -(above_lefty + combining_glyphs[i]->height), &ctx);
+ break;
+
+ case GRUB_UNICODE_COMB_BELOW_RIGHT:
+ do_blit (combining_glyphs[i], below_rightx, below_righty, &ctx);
+ below_rightx += combining_glyphs[i]->width;
+ break;
+
+ case GRUB_UNICODE_COMB_HEBREW_HOLAM:
+ if (glyph_id->base != GRUB_UNICODE_HEBREW_WAW)
+ targetx =
+ main_glyph->offset_x - combining_glyphs[i]->width -
+ (combining_glyphs[i]->width + 3) / 4;
+ goto above_on_main;
+
+ case GRUB_UNICODE_COMB_HEBREW_SIN_DOT:
+ targetx = main_glyph->offset_x + combining_glyphs[i]->width / 4;
+ goto above_on_main;
+
+ case GRUB_UNICODE_COMB_HEBREW_SHIN_DOT:
+ targetx =
+ main_glyph->width + main_glyph->offset_x -
+ combining_glyphs[i]->width;
+ above_on_main:
+ space = combining_glyphs[i]->offset_y
+ - grub_font_get_xheight (combining_glyphs[i]->font) - 1;
+ if (space <= 0)
+ space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
+ do_blit (combining_glyphs[i], targetx,
+ -(main_glyph->height + main_glyph->offset_y + space
+ + combining_glyphs[i]->height), &ctx);
+ if (min_devwidth < combining_glyphs[i]->width)
+ min_devwidth = combining_glyphs[i]->width;
+ break;
+
+ /* TODO: Put dammah, fathah and alif nearer to shadda. */
+ case GRUB_UNICODE_COMB_SYRIAC_SUPERSCRIPT_ALAPH:
+ case GRUB_UNICODE_COMB_ARABIC_DAMMAH:
+ case GRUB_UNICODE_COMB_ARABIC_DAMMATAN:
+ case GRUB_UNICODE_COMB_ARABIC_FATHATAN:
+ case GRUB_UNICODE_COMB_ARABIC_FATHAH:
+ case GRUB_UNICODE_COMB_ARABIC_SUPERSCRIPT_ALIF:
+ case GRUB_UNICODE_COMB_ARABIC_SUKUN:
+ case GRUB_UNICODE_COMB_ARABIC_SHADDA:
+ case GRUB_UNICODE_COMB_HEBREW_RAFE:
+ case GRUB_UNICODE_STACK_ABOVE:
+ stacked_above:
+ space = combining_glyphs[i]->offset_y
+ - 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
+ + combining_glyphs[i]->height), &ctx);
+ if (min_devwidth < combining_glyphs[i]->width)
+ min_devwidth = combining_glyphs[i]->width;
+ break;
+
+ case GRUB_UNICODE_COMB_HEBREW_DAGESH:
+ do_blit (combining_glyphs[i], targetx,
+ -(ctx.bounds.height / 2 + ctx.bounds.y
+ + combining_glyphs[i]->height / 2), &ctx);
+ if (min_devwidth < combining_glyphs[i]->width)
+ min_devwidth = combining_glyphs[i]->width;
+ break;
+
+ case GRUB_UNICODE_COMB_HEBREW_SHEVA:
+ case GRUB_UNICODE_COMB_HEBREW_HIRIQ:
+ case GRUB_UNICODE_COMB_HEBREW_QAMATS:
+ case GRUB_UNICODE_COMB_HEBREW_TSERE:
+ case GRUB_UNICODE_COMB_HEBREW_SEGOL:
+ /* TODO: placement in final kaf and under reish. */
+
+ case GRUB_UNICODE_COMB_HEBREW_HATAF_SEGOL:
+ case GRUB_UNICODE_COMB_HEBREW_HATAF_PATAH:
+ case GRUB_UNICODE_COMB_HEBREW_HATAF_QAMATS:
+ case GRUB_UNICODE_COMB_HEBREW_PATAH:
+ case GRUB_UNICODE_COMB_HEBREW_QUBUTS:
+ case GRUB_UNICODE_COMB_HEBREW_METEG:
+ /* TODO: Put kasra and kasratan under shadda. */
+ case GRUB_UNICODE_COMB_ARABIC_KASRA:
+ case GRUB_UNICODE_COMB_ARABIC_KASRATAN:
+ /* I don't know how ypogegrammeni differs from subscript. */
+ case GRUB_UNICODE_COMB_YPOGEGRAMMENI:
+ case GRUB_UNICODE_STACK_BELOW:
+ stacked_below:
+ space = -(combining_glyphs[i]->offset_y
+ + 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),
+ &ctx);
+ if (min_devwidth < combining_glyphs[i]->width)
+ min_devwidth = combining_glyphs[i]->width;
+ break;
+
+ case GRUB_UNICODE_COMB_MN:
+ switch (comb[i].code)
+ {
+ case GRUB_UNICODE_THAANA_ABAFILI:
+ case GRUB_UNICODE_THAANA_AABAAFILI:
+ case GRUB_UNICODE_THAANA_UBUFILI:
+ case GRUB_UNICODE_THAANA_OOBOOFILI:
+ case GRUB_UNICODE_THAANA_EBEFILI:
+ case GRUB_UNICODE_THAANA_EYBEYFILI:
+ case GRUB_UNICODE_THAANA_OBOFILI:
+ case GRUB_UNICODE_THAANA_OABOAFILI:
+ case GRUB_UNICODE_THAANA_SUKUN:
+ goto stacked_above;
+ case GRUB_UNICODE_THAANA_IBIFILI:
+ case GRUB_UNICODE_THAANA_EEBEEFILI:
+ goto stacked_below;
+ }
+ /* Fall through. */
+ default:
+ {
+ /* Default handling. Just draw combining character on top
+ of base character.
+ FIXME: support more unicode types correctly.
+ */
+ do_blit (combining_glyphs[i],
+ main_glyph->device_width
+ + combining_glyphs[i]->offset_x,
+ -(combining_glyphs[i]->height
+ + combining_glyphs[i]->offset_y), &ctx);
+ add_device_width (combining_glyphs[i]->device_width, &ctx);
+ }
+ }
+ }
+ add_device_width ((above_rightx >
+ below_rightx ? above_rightx : below_rightx) -
+ (main_glyph->offset_x + main_glyph->width), &ctx);
+ add_device_width (above_leftx - main_glyph->offset_x, &ctx);
+ if (glyph && glyph->device_width < min_devwidth)
+ glyph->device_width = min_devwidth;
+ if (device_width && *device_width < min_devwidth)
+ *device_width = min_devwidth;
+
+ if (bounds_out)
+ *bounds_out = ctx.bounds;
+}
+
+static struct grub_font_glyph *
+grub_font_construct_dry_run (grub_font_t hinted_font,
+ const struct grub_unicode_glyph *glyph_id,
+ struct grub_video_signed_rect *bounds,
+ struct grub_font_glyph **combining_glyphs,
+ int *device_width)
+{
+ struct grub_font_glyph *main_glyph = NULL;
+ grub_uint32_t desired_attributes = 0;
+ unsigned i;
+ grub_uint32_t base = glyph_id->base;
+ const struct grub_unicode_combining *comb;
+
+ if (glyph_id->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED)
+ desired_attributes |= GRUB_FONT_CODE_RIGHT_JOINED;
+
+ if (glyph_id->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED)
+ desired_attributes |= GRUB_FONT_CODE_LEFT_JOINED;
+
+ comb = grub_unicode_get_comb (glyph_id);
+
+ if (base == 'i' || base == 'j')
+ {
+ for (i = 0; i < glyph_id->ncomb; i++)
+ if (comb[i].type == GRUB_UNICODE_STACK_ABOVE)
+ break;
+ if (i < glyph_id->ncomb && base == 'i')
+ base = GRUB_UNICODE_DOTLESS_LOWERCASE_I;
+ if (i < glyph_id->ncomb && base == 'j')
+ base = GRUB_UNICODE_DOTLESS_LOWERCASE_J;
+ }
+
+ main_glyph = grub_font_get_glyph_with_fallback (hinted_font, base
+ | desired_attributes);
+
+ if (!main_glyph)
+ main_glyph = grub_font_get_glyph_with_fallback (hinted_font,
+ base);
+
+ /* Glyph not available in any font. Use ASCII fallback. */
+ if (!main_glyph)
+ main_glyph = ascii_glyph_lookup (base);
+
+ /* Glyph not available in any font. Return unknown glyph. */
+ if (!main_glyph)
+ return NULL;
+
+ if (device_width)
+ *device_width = main_glyph->device_width;
+
+ if (!glyph_id->ncomb && !glyph_id->attributes)
+ return main_glyph;
+
+ if (glyph_id->ncomb && !combining_glyphs)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return main_glyph;
+ }
+
+ for (i = 0; i < glyph_id->ncomb; i++)
+ combining_glyphs[i]
+ = grub_font_get_glyph_with_fallback (main_glyph->font,
+ comb[i].code);
+
+ blit_comb (glyph_id, NULL, bounds, main_glyph, combining_glyphs,
+ device_width);
+
+ return main_glyph;
+}
+
+static struct grub_font_glyph **render_combining_glyphs = 0;
+static grub_size_t render_max_comb_glyphs = 0;
+
+static void
+ensure_comb_space (const struct grub_unicode_glyph *glyph_id)
+{
+ if (glyph_id->ncomb <= render_max_comb_glyphs)
+ return;
+
+ render_max_comb_glyphs = 2 * glyph_id->ncomb;
+ if (render_max_comb_glyphs < 8)
+ render_max_comb_glyphs = 8;
+ grub_free (render_combining_glyphs);
+ render_combining_glyphs = grub_malloc (render_max_comb_glyphs
+ * sizeof (render_combining_glyphs[0]));
+ if (!render_combining_glyphs)
+ grub_errno = 0;
+}
+
+int
+grub_font_get_constructed_device_width (grub_font_t hinted_font,
+ const struct grub_unicode_glyph
+ *glyph_id)
+{
+ int ret;
+ struct grub_font_glyph *main_glyph;
+
+ ensure_comb_space (glyph_id);
+
+ main_glyph = grub_font_construct_dry_run (hinted_font, glyph_id, NULL,
+ render_combining_glyphs, &ret);
+ if (!main_glyph)
+ return unknown_glyph->device_width;
+ return ret;
+}
+
+struct grub_font_glyph *
+grub_font_construct_glyph (grub_font_t hinted_font,
+ const struct grub_unicode_glyph *glyph_id)
+{
+ struct grub_font_glyph *main_glyph;
+ struct grub_video_signed_rect bounds;
+ static struct grub_font_glyph *glyph = 0;
+ static grub_size_t max_glyph_size = 0;
+
+ ensure_comb_space (glyph_id);
+
+ main_glyph = grub_font_construct_dry_run (hinted_font, glyph_id,
+ &bounds, render_combining_glyphs,
+ NULL);
+
+ if (!main_glyph)
+ return unknown_glyph;
+
+ if (!render_combining_glyphs && glyph_id->ncomb)
+ return main_glyph;
+
+ if (!glyph_id->ncomb && !glyph_id->attributes)
+ return main_glyph;
+
+ if (max_glyph_size < sizeof (*glyph) + (bounds.width * bounds.height + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT)
+ {
+ grub_free (glyph);
+ max_glyph_size = (sizeof (*glyph) + (bounds.width * bounds.height + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT) * 2;
+ if (max_glyph_size < 8)
+ max_glyph_size = 8;
+ glyph = grub_malloc (max_glyph_size);
+ }
+ if (!glyph)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return main_glyph;
+ }
+
+ grub_memset (glyph, 0, sizeof (*glyph)
+ + (bounds.width * bounds.height
+ + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT);
+
+ glyph->font = main_glyph->font;
+ glyph->width = bounds.width;
+ glyph->height = bounds.height;
+ glyph->offset_x = bounds.x;
+ glyph->offset_y = bounds.y;
+
+ if (glyph_id->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR)
+ grub_font_blit_glyph_mirror (glyph, main_glyph,
+ main_glyph->offset_x - glyph->offset_x,
+ (glyph->height + glyph->offset_y)
+ - (main_glyph->height +
+ main_glyph->offset_y));
+ else
+ grub_font_blit_glyph (glyph, main_glyph,
+ main_glyph->offset_x - glyph->offset_x,
+ (glyph->height + glyph->offset_y)
+ - (main_glyph->height + main_glyph->offset_y));
+
+ blit_comb (glyph_id, glyph, NULL, main_glyph, render_combining_glyphs, NULL);
+
+ return glyph;
+}
+
+/* Draw the specified glyph at (x, y). The y coordinate designates the
+ baseline of the character, while the x coordinate designates the left
+ side location of the character. */
+grub_err_t
+grub_font_draw_glyph (struct grub_font_glyph * glyph,
+ grub_video_color_t color, int left_x, int baseline_y)
+{
+ struct grub_video_bitmap glyph_bitmap;
+
+ /* Don't try to draw empty glyphs (U+0020, etc.). */
+ if (glyph->width == 0 || glyph->height == 0)
+ return GRUB_ERR_NONE;
+
+ glyph_bitmap.mode_info.width = glyph->width;
+ glyph_bitmap.mode_info.height = glyph->height;
+ glyph_bitmap.mode_info.mode_type
+ = (1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
+ glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED;
+ glyph_bitmap.mode_info.bpp = 1;
+
+ /* Really 1 bit per pixel. */
+ glyph_bitmap.mode_info.bytes_per_pixel = 0;
+
+ /* Packed densely as bits. */
+ glyph_bitmap.mode_info.pitch = glyph->width;
+
+ glyph_bitmap.mode_info.number_of_colors = 2;
+ glyph_bitmap.mode_info.bg_red = 0;
+ glyph_bitmap.mode_info.bg_green = 0;
+ glyph_bitmap.mode_info.bg_blue = 0;
+ glyph_bitmap.mode_info.bg_alpha = 0;
+ grub_video_unmap_color (color,
+ &glyph_bitmap.mode_info.fg_red,
+ &glyph_bitmap.mode_info.fg_green,
+ &glyph_bitmap.mode_info.fg_blue,
+ &glyph_bitmap.mode_info.fg_alpha);
+ glyph_bitmap.data = glyph->bitmap;
+
+ int bitmap_left = left_x + glyph->offset_x;
+ int bitmap_bottom = baseline_y - glyph->offset_y;
+ int bitmap_top = bitmap_bottom - glyph->height;
+
+ return grub_video_blit_bitmap (&glyph_bitmap, GRUB_VIDEO_BLIT_BLEND,
+ bitmap_left, bitmap_top,
+ 0, 0, glyph->width, glyph->height);
+}
diff --git a/grub-core/font/font_cmd.c b/grub-core/font/font_cmd.c
new file mode 100644
index 0000000..f3b36f2
--- /dev/null
+++ b/grub-core/font/font_cmd.c
@@ -0,0 +1,92 @@
+/* font_cmd.c - Font command definition. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/font.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+static grub_err_t
+loadfont_command (grub_command_t cmd __attribute__ ((unused)),
+ int argc,
+ char **args)
+{
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ while (argc--)
+ if (grub_font_load (*args++) == 0)
+ {
+ if (!grub_errno)
+ return grub_error (GRUB_ERR_BAD_FONT, "invalid font");
+ return grub_errno;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+lsfonts_command (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ struct grub_font_node *node;
+
+ grub_puts_ (N_("Loaded fonts:"));
+ for (node = grub_font_list; node; node = node->next)
+ {
+ grub_font_t font = node->value;
+ grub_printf ("%s\n", grub_font_get_name (font));
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd_loadfont, cmd_lsfonts;
+
+#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_COREBOOT)
+void grub_font_init (void)
+#else
+GRUB_MOD_INIT(font)
+#endif
+{
+ grub_font_loader_init ();
+
+ cmd_loadfont =
+ grub_register_command ("loadfont", loadfont_command,
+ N_("FILE..."),
+ N_("Specify one or more font files to load."));
+ cmd_lsfonts =
+ grub_register_command ("lsfonts", lsfonts_command,
+ 0, N_("List the loaded fonts."));
+}
+
+#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_COREBOOT)
+void grub_font_fini (void)
+#else
+GRUB_MOD_FINI(font)
+#endif
+{
+ /* TODO: Determine way to free allocated resources.
+ Warning: possible pointer references could be in use. */
+
+ grub_unregister_command (cmd_loadfont);
+ grub_unregister_command (cmd_lsfonts);
+}
diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c
new file mode 100644
index 0000000..cafcd0f
--- /dev/null
+++ b/grub-core/fs/affs.c
@@ -0,0 +1,709 @@
+/* affs.c - Amiga Fast FileSystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+#include <grub/charset.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* The affs bootblock. */
+struct grub_affs_bblock
+{
+ grub_uint8_t type[3];
+ grub_uint8_t flags;
+ grub_uint32_t checksum;
+ grub_uint32_t rootblock;
+} GRUB_PACKED;
+
+/* Set if the filesystem is a AFFS filesystem. Otherwise this is an
+ OFS filesystem. */
+#define GRUB_AFFS_FLAG_FFS 1
+
+/* The affs rootblock. */
+struct grub_affs_rblock
+{
+ grub_uint32_t type;
+ grub_uint8_t unused1[8];
+ grub_uint32_t htsize;
+ grub_uint32_t unused2;
+ grub_uint32_t checksum;
+ grub_uint32_t hashtable[1];
+} GRUB_PACKED;
+
+struct grub_affs_time
+{
+ grub_int32_t day;
+ grub_uint32_t min;
+ grub_uint32_t hz;
+} GRUB_PACKED;
+
+/* The second part of a file header block. */
+struct grub_affs_file
+{
+ grub_uint8_t unused1[12];
+ grub_uint32_t size;
+ grub_uint8_t unused2[92];
+ struct grub_affs_time mtime;
+ grub_uint8_t namelen;
+ grub_uint8_t name[30];
+ grub_uint8_t unused3[5];
+ grub_uint32_t hardlink;
+ grub_uint32_t unused4[6];
+ grub_uint32_t next;
+ grub_uint32_t parent;
+ grub_uint32_t extension;
+ grub_uint32_t type;
+} GRUB_PACKED;
+
+/* The location of `struct grub_affs_file' relative to the end of a
+ file header block. */
+#define GRUB_AFFS_FILE_LOCATION 200
+
+/* The offset in both the rootblock and the file header block for the
+ hashtable, symlink and block pointers (all synonyms). */
+#define GRUB_AFFS_HASHTABLE_OFFSET 24
+#define GRUB_AFFS_BLOCKPTR_OFFSET 24
+#define GRUB_AFFS_SYMLINK_OFFSET 24
+
+enum
+ {
+ GRUB_AFFS_FILETYPE_DIR = 2,
+ GRUB_AFFS_FILETYPE_SYMLINK = 3,
+ GRUB_AFFS_FILETYPE_HARDLINK = 0xfffffffc,
+ GRUB_AFFS_FILETYPE_REG = 0xfffffffd
+ };
+
+#define AFFS_MAX_LOG_BLOCK_SIZE 4
+#define AFFS_MAX_SUPERBLOCK 1
+
+
+
+struct grub_fshelp_node
+{
+ struct grub_affs_data *data;
+ grub_uint32_t block;
+ struct grub_fshelp_node *parent;
+ struct grub_affs_file di;
+ grub_uint32_t *block_cache;
+ grub_uint32_t last_block_cache;
+};
+
+/* Information about a "mounted" affs filesystem. */
+struct grub_affs_data
+{
+ struct grub_affs_bblock bblock;
+ struct grub_fshelp_node diropen;
+ grub_disk_t disk;
+
+ /* Log blocksize in sectors. */
+ int log_blocksize;
+
+ /* The number of entries in the hashtable. */
+ unsigned int htsize;
+};
+
+static grub_dl_t my_mod;
+
+
+static grub_disk_addr_t
+grub_affs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
+{
+ grub_uint32_t target, curblock;
+ grub_uint32_t pos;
+ struct grub_affs_file file;
+ struct grub_affs_data *data = node->data;
+ grub_uint64_t mod;
+
+ if (!node->block_cache)
+ {
+ node->block_cache = grub_malloc (((grub_be_to_cpu32 (node->di.size)
+ >> (9 + node->data->log_blocksize))
+ / data->htsize + 2)
+ * sizeof (node->block_cache[0]));
+ if (!node->block_cache)
+ return -1;
+ node->last_block_cache = 0;
+ node->block_cache[0] = node->block;
+ }
+
+ /* Files are at most 2G on AFFS, so no need for 64-bit division. */
+ target = (grub_uint32_t) fileblock / data->htsize;
+ mod = (grub_uint32_t) fileblock % data->htsize;
+ /* Find the block that points to the fileblock we are looking up by
+ following the chain until the right table is reached. */
+ for (curblock = node->last_block_cache + 1; curblock < target + 1; curblock++)
+ {
+ grub_disk_read (data->disk,
+ (((grub_uint64_t) node->block_cache[curblock - 1] + 1)
+ << data->log_blocksize) - 1,
+ GRUB_DISK_SECTOR_SIZE - GRUB_AFFS_FILE_LOCATION,
+ sizeof (file), &file);
+ if (grub_errno)
+ return 0;
+
+ node->block_cache[curblock] = grub_be_to_cpu32 (file.extension);
+ node->last_block_cache = curblock;
+ }
+
+ /* Translate the fileblock to the block within the right table. */
+ grub_disk_read (data->disk, (grub_uint64_t) node->block_cache[target]
+ << data->log_blocksize,
+ GRUB_AFFS_BLOCKPTR_OFFSET
+ + (data->htsize - mod - 1) * sizeof (pos),
+ sizeof (pos), &pos);
+ if (grub_errno)
+ return 0;
+
+ return grub_be_to_cpu32 (pos);
+}
+
+static struct grub_affs_data *
+grub_affs_mount (grub_disk_t disk)
+{
+ struct grub_affs_data *data;
+ grub_uint32_t *rootblock = 0;
+ struct grub_affs_rblock *rblock = 0;
+ int log_blocksize = 0;
+ int bsnum = 0;
+
+ data = grub_zalloc (sizeof (struct grub_affs_data));
+ if (!data)
+ return 0;
+
+ for (bsnum = 0; bsnum < AFFS_MAX_SUPERBLOCK + 1; bsnum++)
+ {
+ /* Read the bootblock. */
+ grub_disk_read (disk, bsnum, 0, sizeof (struct grub_affs_bblock),
+ &data->bblock);
+ if (grub_errno)
+ goto fail;
+
+ /* Make sure this is an affs filesystem. */
+ if (grub_strncmp ((char *) (data->bblock.type), "DOS", 3) != 0
+ /* Test if the filesystem is a OFS filesystem. */
+ || !(data->bblock.flags & GRUB_AFFS_FLAG_FFS))
+ continue;
+
+ /* No sane person uses more than 8KB for a block. At least I hope
+ for that person because in that case this won't work. */
+ if (!rootblock)
+ rootblock = grub_malloc (GRUB_DISK_SECTOR_SIZE
+ << AFFS_MAX_LOG_BLOCK_SIZE);
+ if (!rootblock)
+ goto fail;
+
+ rblock = (struct grub_affs_rblock *) rootblock;
+
+ /* The filesystem blocksize is not stored anywhere in the filesystem
+ itself. One way to determine it is try reading blocks for the
+ rootblock until the checksum is correct. */
+ for (log_blocksize = 0; log_blocksize <= AFFS_MAX_LOG_BLOCK_SIZE;
+ log_blocksize++)
+ {
+ grub_uint32_t *currblock = rootblock;
+ unsigned int i;
+ grub_uint32_t checksum = 0;
+
+ /* Read the rootblock. */
+ grub_disk_read (disk,
+ (grub_uint64_t) grub_be_to_cpu32 (data->bblock.rootblock)
+ << log_blocksize, 0,
+ GRUB_DISK_SECTOR_SIZE << log_blocksize, rootblock);
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ {
+ grub_errno = 0;
+ break;
+ }
+ if (grub_errno)
+ goto fail;
+
+ if (rblock->type != grub_cpu_to_be32_compile_time (2)
+ || rblock->htsize == 0
+ || currblock[(GRUB_DISK_SECTOR_SIZE << log_blocksize)
+ / sizeof (*currblock) - 1]
+ != grub_cpu_to_be32_compile_time (1))
+ continue;
+
+ for (i = 0; i < (GRUB_DISK_SECTOR_SIZE << log_blocksize)
+ / sizeof (*currblock);
+ i++)
+ checksum += grub_be_to_cpu32 (currblock[i]);
+
+ if (checksum == 0)
+ {
+ data->log_blocksize = log_blocksize;
+ data->disk = disk;
+ data->htsize = grub_be_to_cpu32 (rblock->htsize);
+ data->diropen.data = data;
+ data->diropen.block = grub_be_to_cpu32 (data->bblock.rootblock);
+ data->diropen.parent = NULL;
+ grub_memcpy (&data->diropen.di, rootblock,
+ sizeof (data->diropen.di));
+ grub_free (rootblock);
+
+ return data;
+ }
+ }
+ }
+
+ fail:
+ if (grub_errno == GRUB_ERR_NONE || grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not an AFFS filesystem");
+
+ grub_free (data);
+ grub_free (rootblock);
+ return 0;
+}
+
+
+static char *
+grub_affs_read_symlink (grub_fshelp_node_t node)
+{
+ struct grub_affs_data *data = node->data;
+ grub_uint8_t *latin1, *utf8;
+ const grub_size_t symlink_size = ((GRUB_DISK_SECTOR_SIZE
+ << data->log_blocksize) - GRUB_AFFS_SYMLINK_OFFSET);
+
+ latin1 = grub_malloc (symlink_size + 1);
+ if (!latin1)
+ return 0;
+
+ grub_disk_read (data->disk,
+ (grub_uint64_t) node->block << data->log_blocksize,
+ GRUB_AFFS_SYMLINK_OFFSET,
+ symlink_size, latin1);
+ if (grub_errno)
+ {
+ grub_free (latin1);
+ return 0;
+ }
+ latin1[symlink_size] = 0;
+ utf8 = grub_calloc (GRUB_MAX_UTF8_PER_LATIN1 + 1, symlink_size);
+ if (!utf8)
+ {
+ grub_free (latin1);
+ return 0;
+ }
+ *grub_latin1_to_utf8 (utf8, latin1, symlink_size) = '\0';
+ grub_dprintf ("affs", "Symlink: `%s'\n", utf8);
+ grub_free (latin1);
+ if (utf8[0] == ':')
+ utf8[0] = '/';
+ return (char *) utf8;
+}
+
+
+/* Helper for grub_affs_iterate_dir. */
+static int
+grub_affs_create_node (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data,
+ struct grub_fshelp_node **node,
+ grub_uint32_t **hashtable,
+ grub_uint32_t block, const struct grub_affs_file *fil)
+{
+ struct grub_affs_data *data = dir->data;
+ int type = GRUB_FSHELP_REG;
+ grub_uint8_t name_u8[sizeof (fil->name) * GRUB_MAX_UTF8_PER_LATIN1 + 1];
+ grub_size_t len;
+ unsigned int nest;
+
+ *node = grub_zalloc (sizeof (**node));
+ if (!*node)
+ {
+ grub_free (*hashtable);
+ return 1;
+ }
+
+ (*node)->data = data;
+ (*node)->block = block;
+ (*node)->parent = dir;
+
+ len = fil->namelen;
+ if (len > sizeof (fil->name))
+ len = sizeof (fil->name);
+ *grub_latin1_to_utf8 (name_u8, fil->name, len) = '\0';
+
+ (*node)->di = *fil;
+ for (nest = 0; nest < 8; nest++)
+ {
+ switch ((*node)->di.type)
+ {
+ case grub_cpu_to_be32_compile_time (GRUB_AFFS_FILETYPE_REG):
+ type = GRUB_FSHELP_REG;
+ break;
+ case grub_cpu_to_be32_compile_time (GRUB_AFFS_FILETYPE_DIR):
+ type = GRUB_FSHELP_DIR;
+ break;
+ case grub_cpu_to_be32_compile_time (GRUB_AFFS_FILETYPE_SYMLINK):
+ type = GRUB_FSHELP_SYMLINK;
+ break;
+ case grub_cpu_to_be32_compile_time (GRUB_AFFS_FILETYPE_HARDLINK):
+ {
+ grub_err_t err;
+ (*node)->block = grub_be_to_cpu32 ((*node)->di.hardlink);
+ err = grub_disk_read (data->disk,
+ (((grub_uint64_t) (*node)->block + 1) << data->log_blocksize)
+ - 1,
+ GRUB_DISK_SECTOR_SIZE - GRUB_AFFS_FILE_LOCATION,
+ sizeof ((*node)->di), (char *) &(*node)->di);
+ if (err)
+ return 1;
+ continue;
+ }
+ default:
+ return 0;
+ }
+ break;
+ }
+
+ if (nest == 8)
+ return 0;
+
+ type |= GRUB_FSHELP_CASE_INSENSITIVE;
+
+ if (hook ((char *) name_u8, type, *node, hook_data))
+ {
+ grub_free (*hashtable);
+ *node = 0;
+ return 1;
+ }
+ *node = 0;
+ return 0;
+}
+
+static int
+grub_affs_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ unsigned int i;
+ struct grub_affs_file file;
+ struct grub_fshelp_node *node, *orig_node;
+ struct grub_affs_data *data = dir->data;
+ grub_uint32_t *hashtable;
+
+ /* Create the directory entries for `.' and `..'. */
+ node = orig_node = grub_zalloc (sizeof (*node));
+ if (!node)
+ return 1;
+
+ *node = *dir;
+ if (hook (".", GRUB_FSHELP_DIR, node, hook_data))
+ return 1;
+ if (dir->parent)
+ {
+ *node = *dir->parent;
+ if (hook ("..", GRUB_FSHELP_DIR, node, hook_data))
+ return 1;
+ }
+
+ hashtable = grub_calloc (data->htsize, sizeof (*hashtable));
+ if (!hashtable)
+ return 1;
+
+ grub_disk_read (data->disk,
+ (grub_uint64_t) dir->block << data->log_blocksize,
+ GRUB_AFFS_HASHTABLE_OFFSET,
+ data->htsize * sizeof (*hashtable), (char *) hashtable);
+ if (grub_errno)
+ goto fail;
+
+ for (i = 0; i < data->htsize; i++)
+ {
+ grub_uint32_t next;
+
+ if (!hashtable[i])
+ continue;
+
+ /* Every entry in the hashtable can be chained. Read the entire
+ chain. */
+ next = grub_be_to_cpu32 (hashtable[i]);
+
+ while (next)
+ {
+ grub_disk_read (data->disk,
+ (((grub_uint64_t) next + 1) << data->log_blocksize)
+ - 1,
+ GRUB_DISK_SECTOR_SIZE - GRUB_AFFS_FILE_LOCATION,
+ sizeof (file), (char *) &file);
+ if (grub_errno)
+ goto fail;
+
+ if (grub_affs_create_node (dir, hook, hook_data, &node, &hashtable,
+ next, &file))
+ {
+ /* Node has been replaced in function. */
+ grub_free (orig_node);
+ return 1;
+ }
+
+ next = grub_be_to_cpu32 (file.next);
+ }
+ }
+
+ fail:
+ grub_free (orig_node);
+ grub_free (hashtable);
+ return 0;
+}
+
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_affs_open (struct grub_file *file, const char *name)
+{
+ struct grub_affs_data *data;
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_affs_mount (file->device->disk);
+ if (!data)
+ goto fail;
+
+ grub_fshelp_find_file (name, &data->diropen, &fdiro, grub_affs_iterate_dir,
+ grub_affs_read_symlink, GRUB_FSHELP_REG);
+ if (grub_errno)
+ goto fail;
+
+ file->size = grub_be_to_cpu32 (fdiro->di.size);
+ data->diropen = *fdiro;
+ grub_free (fdiro);
+
+ file->data = data;
+ file->offset = 0;
+
+ return 0;
+
+ fail:
+ if (data && fdiro != &data->diropen)
+ grub_free (fdiro);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_affs_close (grub_file_t file)
+{
+ struct grub_affs_data *data =
+ (struct grub_affs_data *) file->data;
+
+ grub_free (data->diropen.block_cache);
+ grub_free (file->data);
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Read LEN bytes data from FILE into BUF. */
+static grub_ssize_t
+grub_affs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_affs_data *data =
+ (struct grub_affs_data *) file->data;
+
+ return grub_fshelp_read_file (data->diropen.data->disk, &data->diropen,
+ file->read_hook, file->read_hook_data,
+ file->offset, len, buf, grub_affs_read_block,
+ grub_be_to_cpu32 (data->diropen.di.size),
+ data->log_blocksize, 0);
+}
+
+static grub_int32_t
+aftime2ctime (const struct grub_affs_time *t)
+{
+ return grub_be_to_cpu32 (t->day) * 86400
+ + grub_be_to_cpu32 (t->min) * 60
+ + grub_be_to_cpu32 (t->hz) / 50
+ + 8 * 365 * 86400 + 86400 * 2;
+}
+
+/* Context for grub_affs_dir. */
+struct grub_affs_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_affs_dir. */
+static int
+grub_affs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_affs_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ info.mtimeset = 1;
+ info.mtime = aftime2ctime (&node->di.mtime);
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_affs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_affs_dir_ctx ctx = { hook, hook_data };
+ struct grub_affs_data *data = 0;
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_affs_mount (device->disk);
+ if (!data)
+ goto fail;
+
+ grub_fshelp_find_file (path, &data->diropen, &fdiro, grub_affs_iterate_dir,
+ grub_affs_read_symlink, GRUB_FSHELP_DIR);
+ if (grub_errno)
+ goto fail;
+
+ grub_affs_iterate_dir (fdiro, grub_affs_dir_iter, &ctx);
+
+ fail:
+ if (data && fdiro != &data->diropen)
+ grub_free (fdiro);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+
+static grub_err_t
+grub_affs_label (grub_device_t device, char **label)
+{
+ struct grub_affs_data *data;
+ struct grub_affs_file file;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_affs_mount (disk);
+ if (data)
+ {
+ grub_size_t len;
+ /* The rootblock maps quite well on a file header block, it's
+ something we can use here. */
+ grub_disk_read (data->disk,
+ (((grub_uint64_t)
+ grub_be_to_cpu32 (data->bblock.rootblock) + 1)
+ << data->log_blocksize) - 1,
+ GRUB_DISK_SECTOR_SIZE - GRUB_AFFS_FILE_LOCATION,
+ sizeof (file), &file);
+ if (grub_errno)
+ return grub_errno;
+
+ len = file.namelen;
+ if (len > sizeof (file.name))
+ len = sizeof (file.name);
+ *label = grub_calloc (GRUB_MAX_UTF8_PER_LATIN1 + 1, len);
+ if (*label)
+ *grub_latin1_to_utf8 ((grub_uint8_t *) *label, file.name, len) = '\0';
+ }
+ else
+ *label = 0;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_affs_mtime (grub_device_t device, grub_int64_t *t)
+{
+ struct grub_affs_data *data;
+ grub_disk_t disk = device->disk;
+ struct grub_affs_time af_time;
+
+ *t = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_affs_mount (disk);
+ if (!data)
+ {
+ grub_dl_unref (my_mod);
+ return grub_errno;
+ }
+
+ grub_disk_read (data->disk,
+ (((grub_uint64_t)
+ grub_be_to_cpu32 (data->bblock.rootblock) + 1)
+ << data->log_blocksize) - 1,
+ GRUB_DISK_SECTOR_SIZE - 40,
+ sizeof (af_time), &af_time);
+ if (grub_errno)
+ {
+ grub_dl_unref (my_mod);
+ grub_free (data);
+ return grub_errno;
+ }
+
+ *t = aftime2ctime (&af_time);
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return GRUB_ERR_NONE;
+}
+
+
+static struct grub_fs grub_affs_fs =
+ {
+ .name = "affs",
+ .fs_dir = grub_affs_dir,
+ .fs_open = grub_affs_open,
+ .fs_read = grub_affs_read,
+ .fs_close = grub_affs_close,
+ .fs_label = grub_affs_label,
+ .fs_mtime = grub_affs_mtime,
+
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 0,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(affs)
+{
+ grub_fs_register (&grub_affs_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(affs)
+{
+ grub_fs_unregister (&grub_affs_fs);
+}
diff --git a/grub-core/fs/afs.c b/grub-core/fs/afs.c
new file mode 100644
index 0000000..00a5e31
--- /dev/null
+++ b/grub-core/fs/afs.c
@@ -0,0 +1,3 @@
+#define MODE_AFS 1
+#include "bfs.c"
+
diff --git a/grub-core/fs/archelp.c b/grub-core/fs/archelp.c
new file mode 100644
index 0000000..0cf544f
--- /dev/null
+++ b/grub-core/fs/archelp.c
@@ -0,0 +1,301 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009,2013 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/archelp.h>
+#include <grub/err.h>
+#include <grub/fs.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static inline void
+canonicalize (char *name)
+{
+ char *iptr, *optr;
+ for (iptr = name, optr = name; *iptr; )
+ {
+ while (*iptr == '/')
+ iptr++;
+ if (iptr[0] == '.' && (iptr[1] == '/' || iptr[1] == 0))
+ {
+ iptr++;
+ continue;
+ }
+ if (iptr[0] == '.' && iptr[1] == '.' && (iptr[2] == '/' || iptr[2] == 0))
+ {
+ iptr += 2;
+ if (optr == name)
+ continue;
+ for (optr -= 2; optr >= name && *optr != '/'; optr--);
+ optr++;
+ continue;
+ }
+ while (*iptr && *iptr != '/')
+ *optr++ = *iptr++;
+ if (*iptr)
+ *optr++ = *iptr++;
+ }
+ *optr = 0;
+}
+
+static grub_err_t
+handle_symlink (struct grub_archelp_data *data,
+ struct grub_archelp_ops *arcops,
+ const char *fn, char **name,
+ grub_uint32_t mode, int *restart)
+{
+ grub_size_t flen;
+ char *target;
+ char *ptr;
+ char *lastslash;
+ grub_size_t prefixlen;
+ char *rest;
+ char *linktarget;
+ grub_size_t linktarget_len;
+
+ *restart = 0;
+
+ if ((mode & GRUB_ARCHELP_ATTR_TYPE) != GRUB_ARCHELP_ATTR_LNK
+ || !arcops->get_link_target)
+ return GRUB_ERR_NONE;
+ flen = grub_strlen (fn);
+ if (grub_memcmp (*name, fn, flen) != 0
+ || ((*name)[flen] != 0 && (*name)[flen] != '/'))
+ return GRUB_ERR_NONE;
+ rest = *name + flen;
+ lastslash = rest;
+ if (*rest)
+ rest++;
+ while (lastslash >= *name && *lastslash != '/')
+ lastslash--;
+ if (lastslash >= *name)
+ prefixlen = lastslash - *name;
+ else
+ prefixlen = 0;
+
+ if (prefixlen)
+ prefixlen++;
+
+ linktarget = arcops->get_link_target (data);
+ if (!linktarget)
+ return grub_errno;
+ if (linktarget[0] == '\0')
+ return GRUB_ERR_NONE;
+ linktarget_len = grub_strlen (linktarget);
+ target = grub_malloc (linktarget_len + grub_strlen (*name) + 2);
+ if (!target)
+ return grub_errno;
+
+ grub_strcpy (target + prefixlen, linktarget);
+ grub_free (linktarget);
+ if (target[prefixlen] == '/')
+ {
+ ptr = grub_stpcpy (target, target + prefixlen);
+ ptr = grub_stpcpy (ptr, rest);
+ *ptr = 0;
+ grub_dprintf ("archelp", "symlink redirected %s to %s\n",
+ *name, target);
+ grub_free (*name);
+
+ canonicalize (target);
+ *name = target;
+ *restart = 1;
+ return GRUB_ERR_NONE;
+ }
+ if (prefixlen)
+ {
+ grub_memcpy (target, *name, prefixlen);
+ target[prefixlen-1] = '/';
+ }
+ grub_strcpy (target + prefixlen + linktarget_len, rest);
+ grub_dprintf ("archelp", "symlink redirected %s to %s\n",
+ *name, target);
+ grub_free (*name);
+ canonicalize (target);
+ *name = target;
+ *restart = 1;
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_archelp_dir (struct grub_archelp_data *data,
+ struct grub_archelp_ops *arcops,
+ const char *path_in,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ char *prev, *name, *path, *ptr;
+ grub_size_t len;
+ int symlinknest = 0;
+
+ path = grub_strdup (path_in + 1);
+ if (!path)
+ return grub_errno;
+ canonicalize (path);
+ for (ptr = path + grub_strlen (path) - 1; ptr >= path && *ptr == '/'; ptr--)
+ *ptr = 0;
+
+ prev = 0;
+
+ len = grub_strlen (path);
+ while (1)
+ {
+ grub_int32_t mtime;
+ grub_uint32_t mode;
+ grub_err_t err;
+
+ if (arcops->find_file (data, &name, &mtime, &mode))
+ goto fail;
+
+ if (mode == GRUB_ARCHELP_ATTR_END)
+ break;
+
+ canonicalize (name);
+
+ if (grub_memcmp (path, name, len) == 0
+ && (name[len] == 0 || name[len] == '/' || len == 0))
+ {
+ char *p, *n;
+
+ n = name + len;
+ while (*n == '/')
+ n++;
+
+ p = grub_strchr (n, '/');
+ if (p)
+ *p = 0;
+
+ if (((!prev) || (grub_strcmp (prev, name) != 0)) && *n != 0)
+ {
+ struct grub_dirhook_info info;
+ grub_memset (&info, 0, sizeof (info));
+ info.dir = (p != NULL) || ((mode & GRUB_ARCHELP_ATTR_TYPE)
+ == GRUB_ARCHELP_ATTR_DIR);
+ if (!(mode & GRUB_ARCHELP_ATTR_NOTIME))
+ {
+ info.mtime = mtime;
+ info.mtimeset = 1;
+ }
+ if (hook (n, &info, hook_data))
+ {
+ grub_free (name);
+ goto fail;
+ }
+ grub_free (prev);
+ prev = name;
+ }
+ else
+ {
+ int restart = 0;
+ err = handle_symlink (data, arcops, name,
+ &path, mode, &restart);
+ grub_free (name);
+ if (err)
+ goto fail;
+ if (restart)
+ {
+ len = grub_strlen (path);
+ if (++symlinknest == 8)
+ {
+ grub_error (GRUB_ERR_SYMLINK_LOOP,
+ N_("too deep nesting of symlinks"));
+ goto fail;
+ }
+ arcops->rewind (data);
+ }
+ }
+ }
+ else
+ grub_free (name);
+ }
+
+fail:
+
+ grub_free (path);
+ grub_free (prev);
+
+ return grub_errno;
+}
+
+grub_err_t
+grub_archelp_open (struct grub_archelp_data *data,
+ struct grub_archelp_ops *arcops,
+ const char *name_in)
+{
+ char *fn;
+ char *name = grub_strdup (name_in + 1);
+ int symlinknest = 0;
+
+ if (!name)
+ return grub_errno;
+
+ canonicalize (name);
+
+ while (1)
+ {
+ grub_uint32_t mode;
+ grub_int32_t mtime;
+ int restart;
+
+ if (arcops->find_file (data, &fn, &mtime, &mode))
+ goto fail;
+
+ if (mode == GRUB_ARCHELP_ATTR_END)
+ {
+ grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name_in);
+ break;
+ }
+
+ canonicalize (fn);
+
+ if (handle_symlink (data, arcops, fn, &name, mode, &restart))
+ {
+ grub_free (fn);
+ goto fail;
+ }
+
+ if (restart)
+ {
+ arcops->rewind (data);
+ if (++symlinknest == 8)
+ {
+ grub_error (GRUB_ERR_SYMLINK_LOOP,
+ N_("too deep nesting of symlinks"));
+ goto fail;
+ }
+ goto no_match;
+ }
+
+ if (grub_strcmp (name, fn) != 0)
+ goto no_match;
+
+ grub_free (fn);
+ grub_free (name);
+
+ return GRUB_ERR_NONE;
+
+ no_match:
+
+ grub_free (fn);
+ }
+
+fail:
+ grub_free (name);
+
+ return grub_errno;
+}
diff --git a/grub-core/fs/bfs.c b/grub-core/fs/bfs.c
new file mode 100644
index 0000000..47dbe20
--- /dev/null
+++ b/grub-core/fs/bfs.c
@@ -0,0 +1,1117 @@
+/* bfs.c - The Bee File System. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ Based on the book "Practical File System Design by Dominic Giampaolo
+ with corrections and completitions based on Haiku code.
+*/
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/i18n.h>
+#include <grub/fshelp.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#ifdef MODE_AFS
+#define BTREE_ALIGN 4
+#define SUPERBLOCK 2
+#else
+#define BTREE_ALIGN 8
+#define SUPERBLOCK 1
+#endif
+
+#define grub_bfs_to_cpu16 grub_le_to_cpu16
+#define grub_bfs_to_cpu32 grub_le_to_cpu32
+#define grub_bfs_to_cpu64 grub_le_to_cpu64
+#define grub_cpu_to_bfs32_compile_time grub_cpu_to_le32_compile_time
+
+#ifdef MODE_AFS
+#define grub_bfs_to_cpu_treehead grub_bfs_to_cpu32
+#else
+#define grub_bfs_to_cpu_treehead grub_bfs_to_cpu16
+#endif
+
+#ifdef MODE_AFS
+#define SUPER_BLOCK_MAGIC1 0x41465331
+#else
+#define SUPER_BLOCK_MAGIC1 0x42465331
+#endif
+#define SUPER_BLOCK_MAGIC2 0xdd121031
+#define SUPER_BLOCK_MAGIC3 0x15b6830e
+#define POINTER_INVALID 0xffffffffffffffffULL
+
+#define ATTR_TYPE 0160000
+#define ATTR_REG 0100000
+#define ATTR_DIR 0040000
+#define ATTR_LNK 0120000
+
+#define DOUBLE_INDIRECT_SHIFT 2
+
+#define LOG_EXTENT_SIZE 3
+struct grub_bfs_extent
+{
+ grub_uint32_t ag;
+ grub_uint16_t start;
+ grub_uint16_t len;
+} GRUB_PACKED;
+
+struct grub_bfs_superblock
+{
+ char label[32];
+ grub_uint32_t magic1;
+ grub_uint32_t unused1;
+ grub_uint32_t bsize;
+ grub_uint32_t log2_bsize;
+ grub_uint8_t unused[20];
+ grub_uint32_t magic2;
+ grub_uint32_t unused2;
+ grub_uint32_t log2_ag_size;
+ grub_uint8_t unused3[32];
+ grub_uint32_t magic3;
+ struct grub_bfs_extent root_dir;
+} GRUB_PACKED;
+
+struct grub_bfs_inode
+{
+ grub_uint8_t unused[20];
+ grub_uint32_t mode;
+ grub_uint32_t flags;
+#ifdef MODE_AFS
+ grub_uint8_t unused2[12];
+#else
+ grub_uint8_t unused2[8];
+#endif
+ grub_uint64_t mtime;
+ grub_uint8_t unused3[8];
+ struct grub_bfs_extent attr;
+ grub_uint8_t unused4[12];
+
+ union
+ {
+ struct
+ {
+ struct grub_bfs_extent direct[12];
+ grub_uint64_t max_direct_range;
+ struct grub_bfs_extent indirect;
+ grub_uint64_t max_indirect_range;
+ struct grub_bfs_extent double_indirect;
+ grub_uint64_t max_double_indirect_range;
+ grub_uint64_t size;
+ grub_uint32_t pad[4];
+ } GRUB_PACKED;
+ char inplace_link[144];
+ } GRUB_PACKED;
+ grub_uint8_t small_data[0];
+} GRUB_PACKED;
+
+enum
+{
+ LONG_SYMLINK = 0x40
+};
+
+struct grub_bfs_small_data_element_header
+{
+ grub_uint32_t type;
+ grub_uint16_t name_len;
+ grub_uint16_t value_len;
+} GRUB_PACKED;
+
+struct grub_bfs_btree_header
+{
+ grub_uint32_t magic;
+#ifdef MODE_AFS
+ grub_uint64_t root;
+ grub_uint32_t level;
+ grub_uint32_t node_size;
+ grub_uint32_t unused;
+#else
+ grub_uint32_t node_size;
+ grub_uint32_t level;
+ grub_uint32_t unused;
+ grub_uint64_t root;
+#endif
+ grub_uint32_t unused2[2];
+} GRUB_PACKED;
+
+struct grub_bfs_btree_node
+{
+ grub_uint64_t unused;
+ grub_uint64_t right;
+ grub_uint64_t overflow;
+#ifdef MODE_AFS
+ grub_uint32_t count_keys;
+ grub_uint32_t total_key_len;
+#else
+ grub_uint16_t count_keys;
+ grub_uint16_t total_key_len;
+#endif
+} GRUB_PACKED;
+
+struct grub_bfs_data
+{
+ struct grub_bfs_superblock sb;
+ struct grub_bfs_inode ino;
+};
+
+/* Context for grub_bfs_dir. */
+struct grub_bfs_dir_ctx
+{
+ grub_device_t device;
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+ struct grub_bfs_superblock sb;
+};
+
+static grub_err_t
+read_extent (grub_disk_t disk,
+ const struct grub_bfs_superblock *sb,
+ const struct grub_bfs_extent *in,
+ grub_off_t off, grub_off_t byteoff, void *buf, grub_size_t len)
+{
+#ifdef MODE_AFS
+ return grub_disk_read (disk, ((grub_bfs_to_cpu32 (in->ag)
+ << (grub_bfs_to_cpu32 (sb->log2_ag_size)
+ - GRUB_DISK_SECTOR_BITS))
+ + ((grub_bfs_to_cpu16 (in->start) + off)
+ << (grub_bfs_to_cpu32 (sb->log2_bsize)
+ - GRUB_DISK_SECTOR_BITS))),
+ byteoff, len, buf);
+#else
+ return grub_disk_read (disk, (((grub_bfs_to_cpu32 (in->ag)
+ << grub_bfs_to_cpu32 (sb->log2_ag_size))
+ + grub_bfs_to_cpu16 (in->start) + off)
+ << (grub_bfs_to_cpu32 (sb->log2_bsize)
+ - GRUB_DISK_SECTOR_BITS)),
+ byteoff, len, buf);
+#endif
+}
+
+#ifdef MODE_AFS
+#define RANGE_SHIFT grub_bfs_to_cpu32 (sb->log2_bsize)
+#else
+#define RANGE_SHIFT 0
+#endif
+
+static grub_err_t
+read_bfs_file (grub_disk_t disk,
+ const struct grub_bfs_superblock *sb,
+ const struct grub_bfs_inode *ino,
+ grub_off_t off, void *buf, grub_size_t len,
+ grub_disk_read_hook_t read_hook, void *read_hook_data)
+{
+ if (len == 0)
+ return GRUB_ERR_NONE;
+
+ if (off + len > grub_bfs_to_cpu64 (ino->size))
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("attempt to read past the end of file"));
+
+ if (off < (grub_bfs_to_cpu64 (ino->max_direct_range) << RANGE_SHIFT))
+ {
+ unsigned i;
+ grub_uint64_t pos = 0;
+ for (i = 0; i < ARRAY_SIZE (ino->direct); i++)
+ {
+ grub_uint64_t newpos;
+ newpos = pos + (((grub_uint64_t) grub_bfs_to_cpu16 (ino->direct[i].len))
+ << grub_bfs_to_cpu32 (sb->log2_bsize));
+ if (newpos > off)
+ {
+ grub_size_t read_size;
+ grub_err_t err;
+ read_size = newpos - off;
+ if (read_size > len)
+ read_size = len;
+ disk->read_hook = read_hook;
+ disk->read_hook_data = read_hook_data;
+ err = read_extent (disk, sb, &ino->direct[i], 0, off - pos,
+ buf, read_size);
+ disk->read_hook = 0;
+ if (err)
+ return err;
+ off += read_size;
+ len -= read_size;
+ buf = (char *) buf + read_size;
+ if (len == 0)
+ return GRUB_ERR_NONE;
+ }
+ pos = newpos;
+ }
+ }
+
+ if (off < (grub_bfs_to_cpu64 (ino->max_direct_range) << RANGE_SHIFT))
+ return grub_error (GRUB_ERR_BAD_FS, "incorrect direct blocks");
+
+ if (off < (grub_bfs_to_cpu64 (ino->max_indirect_range) << RANGE_SHIFT))
+ {
+ unsigned i;
+ struct grub_bfs_extent *entries;
+ grub_size_t nentries;
+ grub_err_t err;
+ grub_uint64_t pos = (grub_bfs_to_cpu64 (ino->max_direct_range)
+ << RANGE_SHIFT);
+ nentries = (((grub_size_t) grub_bfs_to_cpu16 (ino->indirect.len))
+ << (grub_bfs_to_cpu32 (sb->log2_bsize) - LOG_EXTENT_SIZE));
+ entries = grub_malloc (nentries << LOG_EXTENT_SIZE);
+ if (!entries)
+ return grub_errno;
+ err = read_extent (disk, sb, &ino->indirect, 0, 0,
+ entries, nentries << LOG_EXTENT_SIZE);
+ for (i = 0; i < nentries; i++)
+ {
+ grub_uint64_t newpos;
+ newpos = pos + (((grub_uint64_t) grub_bfs_to_cpu16 (entries[i].len))
+ << grub_bfs_to_cpu32 (sb->log2_bsize));
+ if (newpos > off)
+ {
+ grub_size_t read_size;
+ read_size = newpos - off;
+ if (read_size > len)
+ read_size = len;
+ disk->read_hook = read_hook;
+ disk->read_hook_data = read_hook_data;
+ err = read_extent (disk, sb, &entries[i], 0, off - pos,
+ buf, read_size);
+ disk->read_hook = 0;
+ if (err)
+ {
+ grub_free (entries);
+ return err;
+ }
+ off += read_size;
+ len -= read_size;
+ buf = (char *) buf + read_size;
+ if (len == 0)
+ {
+ grub_free (entries);
+ return GRUB_ERR_NONE;
+ }
+ }
+ pos = newpos;
+ }
+ grub_free (entries);
+ }
+
+ if (off < (grub_bfs_to_cpu64 (ino->max_indirect_range) << RANGE_SHIFT))
+ return grub_error (GRUB_ERR_BAD_FS, "incorrect indirect blocks");
+
+ {
+ struct grub_bfs_extent *l1_entries, *l2_entries;
+ grub_size_t nl1_entries, nl2_entries;
+ grub_off_t last_l1n = ~0ULL;
+ grub_err_t err;
+ nl1_entries = (((grub_uint64_t) grub_bfs_to_cpu16 (ino->double_indirect.len))
+ << (grub_bfs_to_cpu32 (sb->log2_bsize) - LOG_EXTENT_SIZE));
+ l1_entries = grub_malloc (nl1_entries << LOG_EXTENT_SIZE);
+ if (!l1_entries)
+ return grub_errno;
+ nl2_entries = 0;
+ l2_entries = grub_malloc (1 << (DOUBLE_INDIRECT_SHIFT
+ + grub_bfs_to_cpu32 (sb->log2_bsize)));
+ if (!l2_entries)
+ {
+ grub_free (l1_entries);
+ return grub_errno;
+ }
+ err = read_extent (disk, sb, &ino->double_indirect, 0, 0,
+ l1_entries, nl1_entries << LOG_EXTENT_SIZE);
+ if (err)
+ {
+ grub_free (l1_entries);
+ grub_free (l2_entries);
+ return err;
+ }
+
+ while (len > 0)
+ {
+ grub_off_t boff, l2n, l1n;
+ grub_size_t read_size;
+ grub_off_t double_indirect_offset;
+ double_indirect_offset = off
+ - grub_bfs_to_cpu64 (ino->max_indirect_range);
+ boff = (double_indirect_offset
+ & ((1 << (grub_bfs_to_cpu32 (sb->log2_bsize)
+ + DOUBLE_INDIRECT_SHIFT)) - 1));
+ l2n = ((double_indirect_offset >> (grub_bfs_to_cpu32 (sb->log2_bsize)
+ + DOUBLE_INDIRECT_SHIFT))
+ & ((1 << (grub_bfs_to_cpu32 (sb->log2_bsize) - LOG_EXTENT_SIZE
+ + DOUBLE_INDIRECT_SHIFT)) - 1));
+ l1n =
+ (double_indirect_offset >>
+ (2 * grub_bfs_to_cpu32 (sb->log2_bsize) - LOG_EXTENT_SIZE +
+ 2 * DOUBLE_INDIRECT_SHIFT));
+ if (l1n > nl1_entries)
+ {
+ grub_free (l1_entries);
+ grub_free (l2_entries);
+ return grub_error (GRUB_ERR_BAD_FS,
+ "incorrect double-indirect block");
+ }
+ if (l1n != last_l1n)
+ {
+ nl2_entries = (((grub_uint64_t) grub_bfs_to_cpu16 (l1_entries[l1n].len))
+ << (grub_bfs_to_cpu32 (sb->log2_bsize)
+ - LOG_EXTENT_SIZE));
+ if (nl2_entries > (1U << (grub_bfs_to_cpu32 (sb->log2_bsize)
+ - LOG_EXTENT_SIZE
+ + DOUBLE_INDIRECT_SHIFT)))
+ nl2_entries = (1 << (grub_bfs_to_cpu32 (sb->log2_bsize)
+ - LOG_EXTENT_SIZE
+ + DOUBLE_INDIRECT_SHIFT));
+ err = read_extent (disk, sb, &l1_entries[l1n], 0, 0,
+ l2_entries, nl2_entries << LOG_EXTENT_SIZE);
+ if (err)
+ {
+ grub_free (l1_entries);
+ grub_free (l2_entries);
+ return err;
+ }
+ last_l1n = l1n;
+ }
+ if (l2n > nl2_entries)
+ {
+ grub_free (l1_entries);
+ grub_free (l2_entries);
+ return grub_error (GRUB_ERR_BAD_FS,
+ "incorrect double-indirect block");
+ }
+
+ read_size = (1 << (grub_bfs_to_cpu32 (sb->log2_bsize)
+ + DOUBLE_INDIRECT_SHIFT)) - boff;
+ if (read_size > len)
+ read_size = len;
+ disk->read_hook = read_hook;
+ disk->read_hook_data = read_hook_data;
+ err = read_extent (disk, sb, &l2_entries[l2n], 0, boff,
+ buf, read_size);
+ disk->read_hook = 0;
+ if (err)
+ {
+ grub_free (l1_entries);
+ grub_free (l2_entries);
+ return err;
+ }
+ off += read_size;
+ len -= read_size;
+ buf = (char *) buf + read_size;
+ }
+ return GRUB_ERR_NONE;
+ }
+}
+
+static grub_err_t
+read_b_node (grub_disk_t disk,
+ const struct grub_bfs_superblock *sb,
+ const struct grub_bfs_inode *ino,
+ grub_uint64_t node_off,
+ struct grub_bfs_btree_node **node,
+ char **key_data, grub_uint16_t **keylen_idx,
+ grub_unaligned_uint64_t **key_values)
+{
+ void *ret;
+ struct grub_bfs_btree_node node_head;
+ grub_size_t total_size;
+ grub_err_t err;
+
+ *node = NULL;
+ *key_data = NULL;
+ *keylen_idx = NULL;
+ *key_values = NULL;
+
+ err = read_bfs_file (disk, sb, ino, node_off, &node_head, sizeof (node_head),
+ 0, 0);
+ if (err)
+ return err;
+
+ total_size = ALIGN_UP (sizeof (node_head) +
+ grub_bfs_to_cpu_treehead
+ (node_head.total_key_len),
+ BTREE_ALIGN) +
+ grub_bfs_to_cpu_treehead (node_head.count_keys) *
+ sizeof (grub_uint16_t)
+ + grub_bfs_to_cpu_treehead (node_head.count_keys) *
+ sizeof (grub_uint64_t);
+
+ ret = grub_malloc (total_size);
+ if (!ret)
+ return grub_errno;
+
+ err = read_bfs_file (disk, sb, ino, node_off, ret, total_size, 0, 0);
+ if (err)
+ {
+ grub_free (ret);
+ return err;
+ }
+
+ *node = ret;
+ *key_data = (char *) ret + sizeof (node_head);
+ *keylen_idx = (grub_uint16_t *) ret
+ + ALIGN_UP (sizeof (node_head) +
+ grub_bfs_to_cpu_treehead (node_head.total_key_len),
+ BTREE_ALIGN) / 2;
+ *key_values = (grub_unaligned_uint64_t *)
+ (*keylen_idx +
+ grub_bfs_to_cpu_treehead (node_head.count_keys));
+
+ return GRUB_ERR_NONE;
+}
+
+static int
+iterate_in_b_tree (grub_disk_t disk,
+ const struct grub_bfs_superblock *sb,
+ const struct grub_bfs_inode *ino,
+ int (*hook) (const char *name, grub_uint64_t value,
+ struct grub_bfs_dir_ctx *ctx),
+ struct grub_bfs_dir_ctx *ctx)
+{
+ struct grub_bfs_btree_header head;
+ grub_err_t err;
+ int level;
+ grub_uint64_t node_off;
+
+ err = read_bfs_file (disk, sb, ino, 0, &head, sizeof (head), 0, 0);
+ if (err)
+ return 0;
+ node_off = grub_bfs_to_cpu64 (head.root);
+
+ level = grub_bfs_to_cpu32 (head.level) - 1;
+ while (level--)
+ {
+ struct grub_bfs_btree_node node;
+ grub_uint64_t key_value;
+ err = read_bfs_file (disk, sb, ino, node_off, &node, sizeof (node),
+ 0, 0);
+ if (err)
+ return 0;
+ err = read_bfs_file (disk, sb, ino, node_off
+ + ALIGN_UP (sizeof (node) +
+ grub_bfs_to_cpu_treehead (node.
+ total_key_len),
+ BTREE_ALIGN) +
+ grub_bfs_to_cpu_treehead (node.count_keys) *
+ sizeof (grub_uint16_t), &key_value,
+ sizeof (grub_uint64_t), 0, 0);
+ if (err)
+ return 0;
+
+ node_off = grub_bfs_to_cpu64 (key_value);
+ }
+
+ while (1)
+ {
+ struct grub_bfs_btree_node *node;
+ char *key_data;
+ grub_uint16_t *keylen_idx;
+ grub_unaligned_uint64_t *key_values;
+ unsigned i;
+ grub_uint16_t start = 0, end = 0;
+
+ err = read_b_node (disk, sb, ino,
+ node_off,
+ &node,
+ &key_data,
+ &keylen_idx,
+ &key_values);
+
+ if (err)
+ return 0;
+
+ for (i = 0; i < grub_bfs_to_cpu_treehead (node->count_keys); i++)
+ {
+ char c;
+ start = end;
+ end = grub_bfs_to_cpu16 (keylen_idx[i]);
+ if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end)
+ end = grub_bfs_to_cpu_treehead (node->total_key_len);
+ c = key_data[end];
+ key_data[end] = 0;
+ if (hook (key_data + start, grub_bfs_to_cpu64 (key_values[i].val),
+ ctx))
+ {
+ grub_free (node);
+ return 1;
+ }
+ key_data[end] = c;
+ }
+ node_off = grub_bfs_to_cpu64 (node->right);
+ grub_free (node);
+ if (node_off == POINTER_INVALID)
+ return 0;
+ }
+}
+
+static int
+bfs_strcmp (const char *a, const char *b, grub_size_t alen)
+{
+ char ac, bc;
+ while (*b && alen)
+ {
+ if (*a != *b)
+ break;
+
+ a++;
+ b++;
+ alen--;
+ }
+
+ ac = alen ? *a : 0;
+ bc = *b;
+
+#ifdef MODE_AFS
+ return (int) (grub_int8_t) ac - (int) (grub_int8_t) bc;
+#else
+ return (int) (grub_uint8_t) ac - (int) (grub_uint8_t) bc;
+#endif
+}
+
+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_uint64_t * res)
+{
+ struct grub_bfs_btree_header head;
+ grub_err_t err;
+ int level;
+ grub_uint64_t node_off;
+
+ err = read_bfs_file (disk, sb, ino, 0, &head, sizeof (head), 0, 0);
+ if (err)
+ return err;
+ node_off = grub_bfs_to_cpu64 (head.root);
+
+ level = grub_bfs_to_cpu32 (head.level) - 1;
+ while (1)
+ {
+ struct grub_bfs_btree_node *node;
+ char *key_data;
+ grub_uint16_t *keylen_idx;
+ grub_unaligned_uint64_t *key_values;
+ int lg, j;
+ unsigned i;
+
+ err = read_b_node (disk, sb, ino, node_off, &node, &key_data, &keylen_idx, &key_values);
+ if (err)
+ return err;
+
+ if (node->count_keys == 0)
+ {
+ grub_free (node);
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
+ name);
+ }
+
+ for (lg = 0; grub_bfs_to_cpu_treehead (node->count_keys) >> lg; lg++);
+
+ i = 0;
+
+ for (j = lg - 1; j >= 0; j--)
+ {
+ int cmp;
+ grub_uint16_t start = 0, end = 0;
+ if ((i | (1 << j)) >= grub_bfs_to_cpu_treehead (node->count_keys))
+ continue;
+ start = grub_bfs_to_cpu16 (keylen_idx[(i | (1 << j)) - 1]);
+ 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);
+ if (cmp == 0 && level == 0)
+ {
+ *res = grub_bfs_to_cpu64 (key_values[i | (1 << j)].val);
+ grub_free (node);
+ return GRUB_ERR_NONE;
+ }
+#ifdef MODE_AFS
+ if (cmp <= 0)
+#else
+ if (cmp < 0)
+#endif
+ i |= (1 << j);
+ }
+ if (i == 0)
+ {
+ grub_uint16_t end = 0;
+ int cmp;
+ 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);
+ if (cmp == 0 && level == 0)
+ {
+ *res = grub_bfs_to_cpu64 (key_values[0].val);
+ grub_free (node);
+ return GRUB_ERR_NONE;
+ }
+#ifdef MODE_AFS
+ if (cmp > 0 && level != 0)
+#else
+ if (cmp >= 0 && level != 0)
+#endif
+ {
+ node_off = grub_bfs_to_cpu64 (key_values[0].val);
+ level--;
+ grub_free (node);
+ continue;
+ }
+ else if (level != 0
+ && grub_bfs_to_cpu_treehead (node->count_keys) >= 2)
+ {
+ node_off = grub_bfs_to_cpu64 (key_values[1].val);
+ level--;
+ grub_free (node);
+ continue;
+ }
+ }
+ else if (level != 0
+ && i + 1 < grub_bfs_to_cpu_treehead (node->count_keys))
+ {
+ node_off = grub_bfs_to_cpu64 (key_values[i + 1].val);
+ level--;
+ grub_free (node);
+ continue;
+ }
+ if (node->overflow != POINTER_INVALID)
+ {
+ node_off = grub_bfs_to_cpu64 (node->overflow);
+ /* This level-- isn't specified but is needed. */
+ level--;
+ grub_free (node);
+ continue;
+ }
+ grub_free (node);
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
+ name);
+ }
+}
+
+struct grub_fshelp_node
+{
+ grub_disk_t disk;
+ const struct grub_bfs_superblock *sb;
+ struct grub_bfs_inode ino;
+};
+
+static grub_err_t
+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;
+
+ err = find_in_b_tree (dir->disk, dir->sb, &dir->ino, name, &res);
+ if (err)
+ return err;
+
+ *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 char *
+read_symlink (grub_fshelp_node_t node)
+{
+ char *alloc = NULL;
+ grub_err_t err;
+
+#ifndef MODE_AFS
+ if (!(grub_bfs_to_cpu32 (node->ino.flags) & LONG_SYMLINK))
+ {
+ alloc = grub_malloc (sizeof (node->ino.inplace_link) + 1);
+ if (!alloc)
+ {
+ return NULL;
+ }
+ 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)
+ {
+ 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
+mount (grub_disk_t disk, struct grub_bfs_superblock *sb)
+{
+ grub_err_t err;
+ err = grub_disk_read (disk, SUPERBLOCK, 0, sizeof (*sb), sb);
+ if (err == GRUB_ERR_OUT_OF_RANGE)
+ return grub_error (GRUB_ERR_BAD_FS,
+#ifdef MODE_AFS
+ "not an AFS filesystem"
+#else
+ "not a BFS filesystem"
+#endif
+ );
+ if (err)
+ return err;
+ if (sb->magic1 != grub_cpu_to_bfs32_compile_time (SUPER_BLOCK_MAGIC1)
+ || sb->magic2 != grub_cpu_to_bfs32_compile_time (SUPER_BLOCK_MAGIC2)
+ || sb->magic3 != grub_cpu_to_bfs32_compile_time (SUPER_BLOCK_MAGIC3)
+ || sb->bsize == 0
+ || (grub_bfs_to_cpu32 (sb->bsize)
+ != (1U << grub_bfs_to_cpu32 (sb->log2_bsize)))
+ || grub_bfs_to_cpu32 (sb->log2_bsize) < GRUB_DISK_SECTOR_BITS)
+ return grub_error (GRUB_ERR_BAD_FS,
+#ifdef MODE_AFS
+ "not an AFS filesystem"
+#else
+ "not a BFS filesystem"
+#endif
+ );
+ return GRUB_ERR_NONE;
+}
+
+/* Helper for grub_bfs_dir. */
+static int
+grub_bfs_dir_iter (const char *name, grub_uint64_t value,
+ struct grub_bfs_dir_ctx *ctx)
+{
+ grub_err_t err2;
+ struct grub_bfs_inode ino;
+ struct grub_dirhook_info info;
+
+ err2 = grub_disk_read (ctx->device->disk, value
+ << (grub_bfs_to_cpu32 (ctx->sb.log2_bsize)
+ - GRUB_DISK_SECTOR_BITS), 0,
+ sizeof (ino), (char *) &ino);
+ if (err2)
+ {
+ grub_print_error ();
+ return 0;
+ }
+
+ info.mtimeset = 1;
+#ifdef MODE_AFS
+ info.mtime =
+ grub_divmod64 (grub_bfs_to_cpu64 (ino.mtime), 1000000, 0);
+#else
+ info.mtime = grub_bfs_to_cpu64 (ino.mtime) >> 16;
+#endif
+ info.dir = ((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) == ATTR_DIR);
+ return ctx->hook (name, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_bfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_bfs_dir_ctx ctx = {
+ .device = device,
+ .hook = hook,
+ .hook_data = hook_data
+ };
+ grub_err_t err;
+
+ err = mount (device->disk, &ctx.sb);
+ if (err)
+ return err;
+
+ {
+ struct grub_bfs_inode ino;
+ err = find_file (path, device->disk, &ctx.sb, &ino, GRUB_FSHELP_DIR);
+ if (err)
+ return err;
+ iterate_in_b_tree (device->disk, &ctx.sb, &ino, grub_bfs_dir_iter,
+ &ctx);
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_bfs_open (struct grub_file *file, const char *name)
+{
+ struct grub_bfs_superblock sb;
+ grub_err_t err;
+
+ err = mount (file->device->disk, &sb);
+ if (err)
+ return err;
+
+ {
+ struct grub_bfs_inode ino;
+ struct grub_bfs_data *data;
+ err = find_file (name, file->device->disk, &sb, &ino, GRUB_FSHELP_REG);
+ if (err)
+ return err;
+
+ data = grub_zalloc (sizeof (struct grub_bfs_data));
+ if (!data)
+ return grub_errno;
+ data->sb = sb;
+ grub_memcpy (&data->ino, &ino, sizeof (data->ino));
+ file->data = data;
+ file->size = grub_bfs_to_cpu64 (ino.size);
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_bfs_close (grub_file_t file)
+{
+ grub_free (file->data);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_ssize_t
+grub_bfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ grub_err_t err;
+ struct grub_bfs_data *data = file->data;
+
+ err = read_bfs_file (file->device->disk, &data->sb,
+ &data->ino, file->offset, buf, len,
+ file->read_hook, file->read_hook_data);
+ if (err)
+ return -1;
+ return len;
+}
+
+static grub_err_t
+grub_bfs_label (grub_device_t device, char **label)
+{
+ struct grub_bfs_superblock sb;
+ grub_err_t err;
+
+ *label = 0;
+
+ err = mount (device->disk, &sb);
+ if (err)
+ return err;
+
+ *label = grub_strndup (sb.label, sizeof (sb.label));
+ return GRUB_ERR_NONE;
+}
+
+#ifndef MODE_AFS
+static grub_ssize_t
+read_bfs_attr (grub_disk_t disk,
+ const struct grub_bfs_superblock *sb,
+ struct grub_bfs_inode *ino,
+ const char *name, void *buf, grub_size_t len)
+{
+ grub_uint8_t *ptr = (grub_uint8_t *) ino->small_data;
+ grub_uint8_t *end = ((grub_uint8_t *) ino + grub_bfs_to_cpu32 (sb->bsize));
+
+ while (ptr + sizeof (struct grub_bfs_small_data_element_header) < end)
+ {
+ struct grub_bfs_small_data_element_header *el;
+ char *el_name;
+ grub_uint8_t *data;
+ el = (struct grub_bfs_small_data_element_header *) ptr;
+ if (el->name_len == 0)
+ break;
+ el_name = (char *) (el + 1);
+ data = (grub_uint8_t *) el_name + grub_bfs_to_cpu16 (el->name_len) + 3;
+ ptr = data + grub_bfs_to_cpu16 (el->value_len) + 1;
+ if (grub_memcmp (name, el_name, grub_bfs_to_cpu16 (el->name_len)) == 0
+ && name[el->name_len] == 0)
+ {
+ grub_size_t copy;
+ copy = len;
+ if (grub_bfs_to_cpu16 (el->value_len) > copy)
+ copy = grub_bfs_to_cpu16 (el->value_len);
+ grub_memcpy (buf, data, copy);
+ return copy;
+ }
+ }
+
+ if (ino->attr.len != 0)
+ {
+ grub_size_t read;
+ grub_err_t err;
+ grub_uint64_t res;
+
+ err = read_extent (disk, sb, &ino->attr, 0, 0, ino,
+ grub_bfs_to_cpu32 (sb->bsize));
+ if (err)
+ return -1;
+
+ err = find_in_b_tree (disk, sb, ino, name, &res);
+ if (err)
+ return -1;
+ grub_disk_read (disk, res
+ << (grub_bfs_to_cpu32 (sb->log2_bsize)
+ - GRUB_DISK_SECTOR_BITS), 0,
+ grub_bfs_to_cpu32 (sb->bsize), (char *) ino);
+ read = grub_bfs_to_cpu64 (ino->size);
+ if (read > len)
+ read = len;
+
+ err = read_bfs_file (disk, sb, ino, 0, buf, read, 0, 0);
+ if (err)
+ return -1;
+ return read;
+ }
+ return -1;
+}
+
+static grub_err_t
+grub_bfs_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_bfs_superblock sb;
+ grub_err_t err;
+ struct grub_bfs_inode *ino;
+ grub_uint64_t vid;
+
+ *uuid = 0;
+
+ err = mount (device->disk, &sb);
+ if (err)
+ return err;
+
+ ino = grub_malloc (grub_bfs_to_cpu32 (sb.bsize));
+ if (!ino)
+ return grub_errno;
+
+ err = read_extent (device->disk, &sb, &sb.root_dir, 0, 0,
+ ino, grub_bfs_to_cpu32 (sb.bsize));
+ if (err)
+ {
+ grub_free (ino);
+ return err;
+ }
+ if (read_bfs_attr (device->disk, &sb, ino, "be:volume_id",
+ &vid, sizeof (vid)) == sizeof (vid))
+ *uuid =
+ grub_xasprintf ("%016" PRIxGRUB_UINT64_T, grub_bfs_to_cpu64 (vid));
+
+ grub_free (ino);
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+static struct grub_fs grub_bfs_fs = {
+#ifdef MODE_AFS
+ .name = "afs",
+#else
+ .name = "bfs",
+#endif
+ .fs_dir = grub_bfs_dir,
+ .fs_open = grub_bfs_open,
+ .fs_read = grub_bfs_read,
+ .fs_close = grub_bfs_close,
+ .fs_label = grub_bfs_label,
+#ifndef MODE_AFS
+ .fs_uuid = grub_bfs_uuid,
+#endif
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 1,
+#endif
+};
+
+#ifdef MODE_AFS
+GRUB_MOD_INIT (afs)
+#else
+GRUB_MOD_INIT (bfs)
+#endif
+{
+ COMPILE_TIME_ASSERT (1 << LOG_EXTENT_SIZE ==
+ sizeof (struct grub_bfs_extent));
+ grub_fs_register (&grub_bfs_fs);
+}
+
+#ifdef MODE_AFS
+GRUB_MOD_FINI (afs)
+#else
+GRUB_MOD_FINI (bfs)
+#endif
+{
+ grub_fs_unregister (&grub_bfs_fs);
+}
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
new file mode 100644
index 0000000..6320303
--- /dev/null
+++ b/grub-core/fs/btrfs.c
@@ -0,0 +1,2216 @@
+/* btrfs.c - B-tree file system. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011,2012,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/>.
+ */
+
+/*
+ * Tell zstd to expose functions that aren't part of the stable API, which
+ * aren't safe to use when linking against a dynamic library. We vendor in a
+ * specific zstd version, so we know what we're getting. We need these unstable
+ * functions to provide our own allocator, which uses grub_malloc(), to zstd.
+ */
+#define ZSTD_STATIC_LINKING_ONLY
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/lib/crc.h>
+#include <grub/deflate.h>
+#include <minilzo.h>
+#include <zstd.h>
+#include <grub/i18n.h>
+#include <grub/btrfs.h>
+#include <grub/crypto.h>
+#include <grub/diskfilter.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_BTRFS_SIGNATURE "_BHRfS_M"
+
+/* From http://www.oberhumer.com/opensource/lzo/lzofaq.php
+ * LZO will expand incompressible data by a little amount. I still haven't
+ * computed the exact values, but I suggest using these formulas for
+ * a worst-case expansion calculation:
+ *
+ * output_block_size = input_block_size + (input_block_size / 16) + 64 + 3
+ * */
+#define GRUB_BTRFS_LZO_BLOCK_SIZE 4096
+#define GRUB_BTRFS_LZO_BLOCK_MAX_CSIZE (GRUB_BTRFS_LZO_BLOCK_SIZE + \
+ (GRUB_BTRFS_LZO_BLOCK_SIZE / 16) + 64 + 3)
+
+#define ZSTD_BTRFS_MAX_WINDOWLOG 17
+#define ZSTD_BTRFS_MAX_INPUT (1 << ZSTD_BTRFS_MAX_WINDOWLOG)
+
+typedef grub_uint8_t grub_btrfs_checksum_t[0x20];
+typedef grub_uint16_t grub_btrfs_uuid_t[8];
+
+struct grub_btrfs_device
+{
+ grub_uint64_t device_id;
+ grub_uint64_t size;
+ grub_uint8_t dummy[0x62 - 0x10];
+} GRUB_PACKED;
+
+struct grub_btrfs_superblock
+{
+ grub_btrfs_checksum_t checksum;
+ grub_btrfs_uuid_t uuid;
+ grub_uint8_t dummy[0x10];
+ grub_uint8_t signature[sizeof (GRUB_BTRFS_SIGNATURE) - 1];
+ grub_uint64_t generation;
+ grub_uint64_t root_tree;
+ grub_uint64_t chunk_tree;
+ grub_uint8_t dummy2[0x20];
+ grub_uint64_t root_dir_objectid;
+ grub_uint8_t dummy3[0x41];
+ struct grub_btrfs_device this_device;
+ char label[0x100];
+ grub_uint8_t dummy4[0x100];
+ grub_uint8_t bootstrap_mapping[0x800];
+} GRUB_PACKED;
+
+struct btrfs_header
+{
+ grub_btrfs_checksum_t checksum;
+ grub_btrfs_uuid_t uuid;
+ grub_uint64_t bytenr;
+ grub_uint8_t dummy[0x28];
+ grub_uint32_t nitems;
+ grub_uint8_t level;
+} GRUB_PACKED;
+
+struct grub_btrfs_device_desc
+{
+ grub_device_t dev;
+ grub_uint64_t id;
+};
+
+struct grub_btrfs_data
+{
+ struct grub_btrfs_superblock sblock;
+ grub_uint64_t tree;
+ grub_uint64_t inode;
+
+ struct grub_btrfs_device_desc *devices_attached;
+ unsigned n_devices_attached;
+ unsigned n_devices_allocated;
+
+ /* Cached extent data. */
+ grub_uint64_t extstart;
+ grub_uint64_t extend;
+ grub_uint64_t extino;
+ grub_uint64_t exttree;
+ grub_size_t extsize;
+ struct grub_btrfs_extent_data *extent;
+};
+
+struct grub_btrfs_chunk_item
+{
+ grub_uint64_t size;
+ grub_uint64_t dummy;
+ grub_uint64_t stripe_length;
+ grub_uint64_t type;
+#define GRUB_BTRFS_CHUNK_TYPE_BITS_DONTCARE 0x07
+#define GRUB_BTRFS_CHUNK_TYPE_SINGLE 0x00
+#define GRUB_BTRFS_CHUNK_TYPE_RAID0 0x08
+#define GRUB_BTRFS_CHUNK_TYPE_RAID1 0x10
+#define GRUB_BTRFS_CHUNK_TYPE_DUPLICATED 0x20
+#define GRUB_BTRFS_CHUNK_TYPE_RAID10 0x40
+#define GRUB_BTRFS_CHUNK_TYPE_RAID5 0x80
+#define GRUB_BTRFS_CHUNK_TYPE_RAID6 0x100
+#define GRUB_BTRFS_CHUNK_TYPE_RAID1C3 0x200
+#define GRUB_BTRFS_CHUNK_TYPE_RAID1C4 0x400
+ grub_uint8_t dummy2[0xc];
+ grub_uint16_t nstripes;
+ grub_uint16_t nsubstripes;
+} GRUB_PACKED;
+
+struct grub_btrfs_chunk_stripe
+{
+ grub_uint64_t device_id;
+ grub_uint64_t offset;
+ grub_btrfs_uuid_t device_uuid;
+} GRUB_PACKED;
+
+struct grub_btrfs_leaf_node
+{
+ struct grub_btrfs_key key;
+ grub_uint32_t offset;
+ grub_uint32_t size;
+} GRUB_PACKED;
+
+struct grub_btrfs_internal_node
+{
+ struct grub_btrfs_key key;
+ grub_uint64_t addr;
+ grub_uint64_t dummy;
+} GRUB_PACKED;
+
+struct grub_btrfs_dir_item
+{
+ struct grub_btrfs_key key;
+ grub_uint8_t dummy[8];
+ grub_uint16_t m;
+ grub_uint16_t n;
+#define GRUB_BTRFS_DIR_ITEM_TYPE_REGULAR 1
+#define GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY 2
+#define GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK 7
+ grub_uint8_t type;
+ char name[0];
+} GRUB_PACKED;
+
+struct grub_btrfs_leaf_descriptor
+{
+ unsigned depth;
+ unsigned allocated;
+ struct
+ {
+ grub_disk_addr_t addr;
+ unsigned iter;
+ unsigned maxiter;
+ int leaf;
+ } *data;
+};
+
+struct grub_btrfs_time
+{
+ grub_int64_t sec;
+ grub_uint32_t nanosec;
+} GRUB_PACKED;
+
+struct grub_btrfs_inode
+{
+ grub_uint8_t dummy1[0x10];
+ grub_uint64_t size;
+ grub_uint8_t dummy2[0x70];
+ struct grub_btrfs_time mtime;
+} GRUB_PACKED;
+
+struct grub_btrfs_extent_data
+{
+ grub_uint64_t dummy;
+ grub_uint64_t size;
+ grub_uint8_t compression;
+ grub_uint8_t encryption;
+ grub_uint16_t encoding;
+ grub_uint8_t type;
+ union
+ {
+ char inl[0];
+ struct
+ {
+ grub_uint64_t laddr;
+ grub_uint64_t compressed_size;
+ grub_uint64_t offset;
+ grub_uint64_t filled;
+ };
+ };
+} GRUB_PACKED;
+
+#define GRUB_BTRFS_EXTENT_INLINE 0
+#define GRUB_BTRFS_EXTENT_REGULAR 1
+
+#define GRUB_BTRFS_COMPRESSION_NONE 0
+#define GRUB_BTRFS_COMPRESSION_ZLIB 1
+#define GRUB_BTRFS_COMPRESSION_LZO 2
+#define GRUB_BTRFS_COMPRESSION_ZSTD 3
+
+#define GRUB_BTRFS_OBJECT_ID_CHUNK 0x100
+
+static grub_disk_addr_t superblock_sectors[] = { 64 * 2, 64 * 1024 * 2,
+ 256 * 1048576 * 2, 1048576ULL * 1048576ULL * 2
+};
+
+static grub_err_t
+grub_btrfs_read_logical (struct grub_btrfs_data *data,
+ grub_disk_addr_t addr, void *buf, grub_size_t size,
+ int recursion_depth);
+
+static grub_err_t
+read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb)
+{
+ struct grub_btrfs_superblock sblock;
+ unsigned i;
+ grub_err_t err = GRUB_ERR_NONE;
+ for (i = 0; i < ARRAY_SIZE (superblock_sectors); i++)
+ {
+ /* Don't try additional superblocks beyond device size. */
+ if (i && (grub_le_to_cpu64 (sblock.this_device.size)
+ >> GRUB_DISK_SECTOR_BITS) <= superblock_sectors[i])
+ break;
+ err = grub_disk_read (disk, superblock_sectors[i], 0,
+ sizeof (sblock), &sblock);
+ if (err == GRUB_ERR_OUT_OF_RANGE)
+ break;
+
+ if (grub_memcmp ((char *) sblock.signature, GRUB_BTRFS_SIGNATURE,
+ sizeof (GRUB_BTRFS_SIGNATURE) - 1) != 0)
+ break;
+ if (i == 0 || grub_le_to_cpu64 (sblock.generation)
+ > grub_le_to_cpu64 (sb->generation))
+ grub_memcpy (sb, &sblock, sizeof (sblock));
+ }
+
+ if ((err == GRUB_ERR_OUT_OF_RANGE || !err) && i == 0)
+ return grub_error (GRUB_ERR_BAD_FS, "not a Btrfs filesystem");
+
+ if (err == GRUB_ERR_OUT_OF_RANGE)
+ grub_errno = err = GRUB_ERR_NONE;
+
+ return err;
+}
+
+static int
+key_cmp (const struct grub_btrfs_key *a, const struct grub_btrfs_key *b)
+{
+ if (grub_le_to_cpu64 (a->object_id) < grub_le_to_cpu64 (b->object_id))
+ return -1;
+ if (grub_le_to_cpu64 (a->object_id) > grub_le_to_cpu64 (b->object_id))
+ return +1;
+
+ if (a->type < b->type)
+ return -1;
+ if (a->type > b->type)
+ return +1;
+
+ if (grub_le_to_cpu64 (a->offset) < grub_le_to_cpu64 (b->offset))
+ return -1;
+ if (grub_le_to_cpu64 (a->offset) > grub_le_to_cpu64 (b->offset))
+ return +1;
+ return 0;
+}
+
+static void
+free_iterator (struct grub_btrfs_leaf_descriptor *desc)
+{
+ grub_free (desc->data);
+}
+
+static grub_err_t
+check_btrfs_header (struct grub_btrfs_data *data, struct btrfs_header *header,
+ grub_disk_addr_t addr)
+{
+ if (grub_le_to_cpu64 (header->bytenr) != addr)
+ {
+ grub_dprintf ("btrfs", "btrfs_header.bytenr is not equal node addr\n");
+ return grub_error (GRUB_ERR_BAD_FS,
+ "header bytenr is not equal node addr");
+ }
+ if (grub_memcmp (data->sblock.uuid, header->uuid, sizeof(grub_btrfs_uuid_t)))
+ {
+ grub_dprintf ("btrfs", "btrfs_header.uuid doesn't match sblock uuid\n");
+ return grub_error (GRUB_ERR_BAD_FS,
+ "header uuid doesn't match sblock uuid");
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+save_ref (struct grub_btrfs_leaf_descriptor *desc,
+ grub_disk_addr_t addr, unsigned i, unsigned m, int l)
+{
+ desc->depth++;
+ if (desc->allocated < desc->depth)
+ {
+ void *newdata;
+ grub_size_t sz;
+
+ if (grub_mul (desc->allocated, 2, &desc->allocated) ||
+ grub_mul (desc->allocated, sizeof (desc->data[0]), &sz))
+ return GRUB_ERR_OUT_OF_RANGE;
+
+ newdata = grub_realloc (desc->data, sz);
+ if (!newdata)
+ return grub_errno;
+ desc->data = newdata;
+ }
+ desc->data[desc->depth - 1].addr = addr;
+ desc->data[desc->depth - 1].iter = i;
+ desc->data[desc->depth - 1].maxiter = m;
+ desc->data[desc->depth - 1].leaf = l;
+ return GRUB_ERR_NONE;
+}
+
+static int
+next (struct grub_btrfs_data *data,
+ struct grub_btrfs_leaf_descriptor *desc,
+ grub_disk_addr_t * outaddr, grub_size_t * outsize,
+ struct grub_btrfs_key *key_out)
+{
+ grub_err_t err;
+ struct grub_btrfs_leaf_node leaf;
+
+ for (; desc->depth > 0; desc->depth--)
+ {
+ desc->data[desc->depth - 1].iter++;
+ if (desc->data[desc->depth - 1].iter
+ < desc->data[desc->depth - 1].maxiter)
+ break;
+ }
+ if (desc->depth == 0)
+ return 0;
+ while (!desc->data[desc->depth - 1].leaf)
+ {
+ struct grub_btrfs_internal_node node;
+ struct btrfs_header head;
+
+ err = grub_btrfs_read_logical (data, desc->data[desc->depth - 1].iter
+ * sizeof (node)
+ + sizeof (struct btrfs_header)
+ + desc->data[desc->depth - 1].addr,
+ &node, sizeof (node), 0);
+ if (err)
+ return -err;
+
+ err = grub_btrfs_read_logical (data, grub_le_to_cpu64 (node.addr),
+ &head, sizeof (head), 0);
+ if (err)
+ return -err;
+ check_btrfs_header (data, &head, grub_le_to_cpu64 (node.addr));
+
+ save_ref (desc, grub_le_to_cpu64 (node.addr), 0,
+ grub_le_to_cpu32 (head.nitems), !head.level);
+ }
+ err = grub_btrfs_read_logical (data, desc->data[desc->depth - 1].iter
+ * sizeof (leaf)
+ + sizeof (struct btrfs_header)
+ + desc->data[desc->depth - 1].addr, &leaf,
+ sizeof (leaf), 0);
+ if (err)
+ return -err;
+ *outsize = grub_le_to_cpu32 (leaf.size);
+ *outaddr = desc->data[desc->depth - 1].addr + sizeof (struct btrfs_header)
+ + grub_le_to_cpu32 (leaf.offset);
+ *key_out = leaf.key;
+ return 1;
+}
+
+static grub_err_t
+lower_bound (struct grub_btrfs_data *data,
+ const struct grub_btrfs_key *key_in,
+ struct grub_btrfs_key *key_out,
+ grub_uint64_t root,
+ grub_disk_addr_t *outaddr, grub_size_t *outsize,
+ struct grub_btrfs_leaf_descriptor *desc,
+ int recursion_depth)
+{
+ grub_disk_addr_t addr = grub_le_to_cpu64 (root);
+ int depth = -1;
+
+ if (desc)
+ {
+ desc->allocated = 16;
+ desc->depth = 0;
+ desc->data = grub_calloc (desc->allocated, sizeof (desc->data[0]));
+ if (!desc->data)
+ return grub_errno;
+ }
+
+ /* > 2 would work as well but be robust and allow a bit more just in case.
+ */
+ if (recursion_depth > 10)
+ return grub_error (GRUB_ERR_BAD_FS, "too deep btrfs virtual nesting");
+
+ grub_dprintf ("btrfs",
+ "retrieving %" PRIxGRUB_UINT64_T
+ " %x %" PRIxGRUB_UINT64_T "\n",
+ key_in->object_id, key_in->type, key_in->offset);
+
+ while (1)
+ {
+ grub_err_t err;
+ struct btrfs_header head;
+
+ reiter:
+ depth++;
+ /* FIXME: preread few nodes into buffer. */
+ err = grub_btrfs_read_logical (data, addr, &head, sizeof (head),
+ recursion_depth + 1);
+ if (err)
+ return err;
+ check_btrfs_header (data, &head, addr);
+ addr += sizeof (head);
+ if (head.level)
+ {
+ unsigned i;
+ struct grub_btrfs_internal_node node, node_last;
+ int have_last = 0;
+ grub_memset (&node_last, 0, sizeof (node_last));
+ for (i = 0; i < grub_le_to_cpu32 (head.nitems); i++)
+ {
+ err = grub_btrfs_read_logical (data, addr + i * sizeof (node),
+ &node, sizeof (node),
+ recursion_depth + 1);
+ if (err)
+ return err;
+
+ grub_dprintf ("btrfs",
+ "internal node (depth %d) %" PRIxGRUB_UINT64_T
+ " %x %" PRIxGRUB_UINT64_T "\n", depth,
+ node.key.object_id, node.key.type,
+ node.key.offset);
+
+ if (key_cmp (&node.key, key_in) == 0)
+ {
+ err = GRUB_ERR_NONE;
+ if (desc)
+ err = save_ref (desc, addr - sizeof (head), i,
+ grub_le_to_cpu32 (head.nitems), 0);
+ if (err)
+ return err;
+ addr = grub_le_to_cpu64 (node.addr);
+ goto reiter;
+ }
+ if (key_cmp (&node.key, key_in) > 0)
+ break;
+ node_last = node;
+ have_last = 1;
+ }
+ if (have_last)
+ {
+ err = GRUB_ERR_NONE;
+ if (desc)
+ err = save_ref (desc, addr - sizeof (head), i - 1,
+ grub_le_to_cpu32 (head.nitems), 0);
+ if (err)
+ return err;
+ addr = grub_le_to_cpu64 (node_last.addr);
+ goto reiter;
+ }
+ *outsize = 0;
+ *outaddr = 0;
+ grub_memset (key_out, 0, sizeof (*key_out));
+ if (desc)
+ return save_ref (desc, addr - sizeof (head), -1,
+ grub_le_to_cpu32 (head.nitems), 0);
+ return GRUB_ERR_NONE;
+ }
+ {
+ unsigned i;
+ struct grub_btrfs_leaf_node leaf, leaf_last;
+ int have_last = 0;
+ for (i = 0; i < grub_le_to_cpu32 (head.nitems); i++)
+ {
+ err = grub_btrfs_read_logical (data, addr + i * sizeof (leaf),
+ &leaf, sizeof (leaf),
+ recursion_depth + 1);
+ if (err)
+ return err;
+
+ grub_dprintf ("btrfs",
+ "leaf (depth %d) %" PRIxGRUB_UINT64_T
+ " %x %" PRIxGRUB_UINT64_T "\n", depth,
+ leaf.key.object_id, leaf.key.type, leaf.key.offset);
+
+ if (key_cmp (&leaf.key, key_in) == 0)
+ {
+ grub_memcpy (key_out, &leaf.key, sizeof (*key_out));
+ *outsize = grub_le_to_cpu32 (leaf.size);
+ *outaddr = addr + grub_le_to_cpu32 (leaf.offset);
+ if (desc)
+ return save_ref (desc, addr - sizeof (head), i,
+ grub_le_to_cpu32 (head.nitems), 1);
+ return GRUB_ERR_NONE;
+ }
+
+ if (key_cmp (&leaf.key, key_in) > 0)
+ break;
+
+ have_last = 1;
+ leaf_last = leaf;
+ }
+
+ if (have_last)
+ {
+ grub_memcpy (key_out, &leaf_last.key, sizeof (*key_out));
+ *outsize = grub_le_to_cpu32 (leaf_last.size);
+ *outaddr = addr + grub_le_to_cpu32 (leaf_last.offset);
+ if (desc)
+ return save_ref (desc, addr - sizeof (head), i - 1,
+ grub_le_to_cpu32 (head.nitems), 1);
+ return GRUB_ERR_NONE;
+ }
+ *outsize = 0;
+ *outaddr = 0;
+ grub_memset (key_out, 0, sizeof (*key_out));
+ if (desc)
+ return save_ref (desc, addr - sizeof (head), -1,
+ grub_le_to_cpu32 (head.nitems), 1);
+ return GRUB_ERR_NONE;
+ }
+ }
+}
+
+/* Context for find_device. */
+struct find_device_ctx
+{
+ struct grub_btrfs_data *data;
+ grub_uint64_t id;
+ grub_device_t dev_found;
+};
+
+/* Helper for find_device. */
+static int
+find_device_iter (const char *name, void *data)
+{
+ struct find_device_ctx *ctx = data;
+ grub_device_t dev;
+ grub_err_t err;
+ struct grub_btrfs_superblock sb;
+
+ dev = grub_device_open (name);
+ if (!dev)
+ return 0;
+ if (!dev->disk)
+ {
+ grub_device_close (dev);
+ return 0;
+ }
+ err = read_sblock (dev->disk, &sb);
+ if (err == GRUB_ERR_BAD_FS)
+ {
+ grub_device_close (dev);
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+ if (err)
+ {
+ grub_device_close (dev);
+ grub_print_error ();
+ return 0;
+ }
+ if (grub_memcmp (ctx->data->sblock.uuid, sb.uuid, sizeof (sb.uuid)) != 0
+ || sb.this_device.device_id != ctx->id)
+ {
+ grub_device_close (dev);
+ return 0;
+ }
+
+ ctx->dev_found = dev;
+ return 1;
+}
+
+static grub_device_t
+find_device (struct grub_btrfs_data *data, grub_uint64_t id)
+{
+ struct find_device_ctx ctx = {
+ .data = data,
+ .id = id,
+ .dev_found = NULL
+ };
+ unsigned i;
+
+ for (i = 0; i < data->n_devices_attached; i++)
+ if (id == data->devices_attached[i].id)
+ return data->devices_attached[i].dev;
+
+ grub_device_iterate (find_device_iter, &ctx);
+
+ data->n_devices_attached++;
+ if (data->n_devices_attached > data->n_devices_allocated)
+ {
+ void *tmp;
+ grub_size_t sz;
+
+ if (grub_mul (data->n_devices_attached, 2, &data->n_devices_allocated) ||
+ grub_add (data->n_devices_allocated, 1, &data->n_devices_allocated) ||
+ grub_mul (data->n_devices_allocated, sizeof (data->devices_attached[0]), &sz))
+ goto fail;
+
+ data->devices_attached = grub_realloc (tmp = data->devices_attached, sz);
+ if (!data->devices_attached)
+ {
+ data->devices_attached = tmp;
+
+ fail:
+ if (ctx.dev_found)
+ grub_device_close (ctx.dev_found);
+ return NULL;
+ }
+ }
+ data->devices_attached[data->n_devices_attached - 1].id = id;
+ data->devices_attached[data->n_devices_attached - 1].dev = ctx.dev_found;
+ return ctx.dev_found;
+}
+
+static grub_err_t
+btrfs_read_from_chunk (struct grub_btrfs_data *data,
+ struct grub_btrfs_chunk_item *chunk,
+ grub_uint64_t stripen, grub_uint64_t stripe_offset,
+ int redundancy, grub_uint64_t csize,
+ void *buf)
+{
+ struct grub_btrfs_chunk_stripe *stripe;
+ grub_disk_addr_t paddr;
+ grub_device_t dev;
+ grub_err_t err;
+
+ stripe = (struct grub_btrfs_chunk_stripe *) (chunk + 1);
+ /* Right now the redundancy handling is easy.
+ With RAID5-like it will be more difficult. */
+ stripe += stripen + redundancy;
+
+ paddr = grub_le_to_cpu64 (stripe->offset) + stripe_offset;
+
+ grub_dprintf ("btrfs", "stripe %" PRIxGRUB_UINT64_T
+ " maps to 0x%" PRIxGRUB_UINT64_T "\n"
+ "reading paddr 0x%" PRIxGRUB_UINT64_T "\n",
+ stripen, stripe->offset, paddr);
+
+ dev = find_device (data, stripe->device_id);
+ if (!dev)
+ {
+ grub_dprintf ("btrfs",
+ "couldn't find a necessary member device "
+ "of multi-device filesystem\n");
+ grub_errno = GRUB_ERR_NONE;
+ return GRUB_ERR_READ_ERROR;
+ }
+
+ err = grub_disk_read (dev->disk, paddr >> GRUB_DISK_SECTOR_BITS,
+ paddr & (GRUB_DISK_SECTOR_SIZE - 1),
+ csize, buf);
+ return err;
+}
+
+struct raid56_buffer {
+ void *buf;
+ int data_is_valid;
+};
+
+static void
+rebuild_raid5 (char *dest, struct raid56_buffer *buffers,
+ grub_uint64_t nstripes, grub_uint64_t csize)
+{
+ grub_uint64_t i;
+ int first;
+
+ for(i = 0; buffers[i].data_is_valid && i < nstripes; i++);
+
+ if (i == nstripes)
+ {
+ grub_dprintf ("btrfs", "called rebuild_raid5(), but all disks are OK\n");
+ return;
+ }
+
+ grub_dprintf ("btrfs", "rebuilding RAID 5 stripe #%" PRIuGRUB_UINT64_T "\n", i);
+
+ for (i = 0, first = 1; i < nstripes; i++)
+ {
+ if (!buffers[i].data_is_valid)
+ continue;
+
+ if (first) {
+ grub_memcpy(dest, buffers[i].buf, csize);
+ first = 0;
+ } else
+ grub_crypto_xor (dest, dest, buffers[i].buf, csize);
+ }
+}
+
+static grub_err_t
+raid6_recover_read_buffer (void *data, int disk_nr,
+ grub_uint64_t addr __attribute__ ((unused)),
+ void *dest, grub_size_t size)
+{
+ struct raid56_buffer *buffers = data;
+
+ if (!buffers[disk_nr].data_is_valid)
+ return grub_errno = GRUB_ERR_READ_ERROR;
+
+ grub_memcpy(dest, buffers[disk_nr].buf, size);
+
+ return grub_errno = GRUB_ERR_NONE;
+}
+
+static void
+rebuild_raid6 (struct raid56_buffer *buffers, grub_uint64_t nstripes,
+ grub_uint64_t csize, grub_uint64_t parities_pos, void *dest,
+ grub_uint64_t stripen)
+
+{
+ grub_raid6_recover_gen (buffers, nstripes, stripen, parities_pos,
+ dest, 0, csize, 0, raid6_recover_read_buffer);
+}
+
+static grub_err_t
+raid56_read_retry (struct grub_btrfs_data *data,
+ struct grub_btrfs_chunk_item *chunk,
+ grub_uint64_t stripe_offset, grub_uint64_t stripen,
+ grub_uint64_t csize, void *buf, grub_uint64_t parities_pos)
+{
+ struct raid56_buffer *buffers;
+ grub_uint64_t nstripes = grub_le_to_cpu16 (chunk->nstripes);
+ grub_uint64_t chunk_type = grub_le_to_cpu64 (chunk->type);
+ grub_err_t ret = GRUB_ERR_OUT_OF_MEMORY;
+ grub_uint64_t i, failed_devices;
+
+ buffers = grub_calloc (nstripes, sizeof (*buffers));
+ if (!buffers)
+ goto cleanup;
+
+ for (i = 0; i < nstripes; i++)
+ {
+ buffers[i].buf = grub_zalloc (csize);
+ if (!buffers[i].buf)
+ goto cleanup;
+ }
+
+ for (failed_devices = 0, i = 0; i < nstripes; i++)
+ {
+ struct grub_btrfs_chunk_stripe *stripe;
+ grub_disk_addr_t paddr;
+ grub_device_t dev;
+ grub_err_t err;
+
+ /*
+ * The struct grub_btrfs_chunk_stripe array lives
+ * behind struct grub_btrfs_chunk_item.
+ */
+ stripe = (struct grub_btrfs_chunk_stripe *) (chunk + 1) + i;
+
+ paddr = grub_le_to_cpu64 (stripe->offset) + stripe_offset;
+ grub_dprintf ("btrfs", "reading paddr %" PRIxGRUB_UINT64_T
+ " from stripe ID %" PRIxGRUB_UINT64_T "\n",
+ paddr, stripe->device_id);
+
+ dev = find_device (data, stripe->device_id);
+ if (!dev)
+ {
+ grub_dprintf ("btrfs", "stripe %" PRIuGRUB_UINT64_T " FAILED (dev ID %"
+ PRIxGRUB_UINT64_T ")\n", i, stripe->device_id);
+ failed_devices++;
+ continue;
+ }
+
+ err = grub_disk_read (dev->disk, paddr >> GRUB_DISK_SECTOR_BITS,
+ paddr & (GRUB_DISK_SECTOR_SIZE - 1),
+ csize, buffers[i].buf);
+ if (err == GRUB_ERR_NONE)
+ {
+ buffers[i].data_is_valid = 1;
+ grub_dprintf ("btrfs", "stripe %" PRIuGRUB_UINT64_T " OK (dev ID %"
+ PRIxGRUB_UINT64_T ")\n", i, stripe->device_id);
+ }
+ else
+ {
+ grub_dprintf ("btrfs", "stripe %" PRIuGRUB_UINT64_T
+ " READ FAILED (dev ID %" PRIxGRUB_UINT64_T ")\n",
+ i, stripe->device_id);
+ failed_devices++;
+ }
+ }
+
+ if (failed_devices > 1 && (chunk_type & GRUB_BTRFS_CHUNK_TYPE_RAID5))
+ {
+ grub_dprintf ("btrfs", "not enough disks for RAID 5: total %" PRIuGRUB_UINT64_T
+ ", missing %" PRIuGRUB_UINT64_T "\n",
+ nstripes, failed_devices);
+ ret = GRUB_ERR_READ_ERROR;
+ goto cleanup;
+ }
+ else if (failed_devices > 2 && (chunk_type & GRUB_BTRFS_CHUNK_TYPE_RAID6))
+ {
+ grub_dprintf ("btrfs", "not enough disks for RAID 6: total %" PRIuGRUB_UINT64_T
+ ", missing %" PRIuGRUB_UINT64_T "\n",
+ nstripes, failed_devices);
+ ret = GRUB_ERR_READ_ERROR;
+ goto cleanup;
+ }
+ else
+ grub_dprintf ("btrfs", "enough disks for RAID 5: total %"
+ PRIuGRUB_UINT64_T ", missing %" PRIuGRUB_UINT64_T "\n",
+ nstripes, failed_devices);
+
+ /* We have enough disks. So, rebuild the data. */
+ if (chunk_type & GRUB_BTRFS_CHUNK_TYPE_RAID5)
+ rebuild_raid5 (buf, buffers, nstripes, csize);
+ else
+ rebuild_raid6 (buffers, nstripes, csize, parities_pos, buf, stripen);
+
+ ret = GRUB_ERR_NONE;
+ cleanup:
+ if (buffers)
+ for (i = 0; i < nstripes; i++)
+ grub_free (buffers[i].buf);
+ grub_free (buffers);
+
+ return ret;
+}
+
+static grub_err_t
+grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
+ void *buf, grub_size_t size, int recursion_depth)
+{
+ while (size > 0)
+ {
+ grub_uint8_t *ptr;
+ struct grub_btrfs_key *key;
+ struct grub_btrfs_chunk_item *chunk;
+ grub_uint64_t csize;
+ grub_err_t err = 0;
+ struct grub_btrfs_key key_out;
+ int challoc = 0;
+ struct grub_btrfs_key key_in;
+ grub_size_t chsize;
+ grub_disk_addr_t chaddr;
+
+ grub_dprintf ("btrfs", "searching for laddr %" PRIxGRUB_UINT64_T "\n",
+ addr);
+ for (ptr = data->sblock.bootstrap_mapping;
+ ptr < data->sblock.bootstrap_mapping
+ + sizeof (data->sblock.bootstrap_mapping)
+ - sizeof (struct grub_btrfs_key);)
+ {
+ key = (struct grub_btrfs_key *) ptr;
+ if (key->type != GRUB_BTRFS_ITEM_TYPE_CHUNK)
+ break;
+ chunk = (struct grub_btrfs_chunk_item *) (key + 1);
+ grub_dprintf ("btrfs",
+ "%" PRIxGRUB_UINT64_T " %" PRIxGRUB_UINT64_T " \n",
+ grub_le_to_cpu64 (key->offset),
+ grub_le_to_cpu64 (chunk->size));
+ if (grub_le_to_cpu64 (key->offset) <= addr
+ && addr < grub_le_to_cpu64 (key->offset)
+ + grub_le_to_cpu64 (chunk->size))
+ goto chunk_found;
+ ptr += sizeof (*key) + sizeof (*chunk)
+ + sizeof (struct grub_btrfs_chunk_stripe)
+ * grub_le_to_cpu16 (chunk->nstripes);
+ }
+
+ key_in.object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK);
+ key_in.type = GRUB_BTRFS_ITEM_TYPE_CHUNK;
+ key_in.offset = grub_cpu_to_le64 (addr);
+ err = lower_bound (data, &key_in, &key_out,
+ data->sblock.chunk_tree,
+ &chaddr, &chsize, NULL, recursion_depth);
+ if (err)
+ return err;
+ key = &key_out;
+ if (key->type != GRUB_BTRFS_ITEM_TYPE_CHUNK
+ || !(grub_le_to_cpu64 (key->offset) <= addr))
+ return grub_error (GRUB_ERR_BAD_FS,
+ "couldn't find the chunk descriptor");
+
+ chunk = grub_malloc (chsize);
+ if (!chunk)
+ return grub_errno;
+
+ challoc = 1;
+ err = grub_btrfs_read_logical (data, chaddr, chunk, chsize,
+ recursion_depth);
+ if (err)
+ {
+ grub_free (chunk);
+ return err;
+ }
+
+ chunk_found:
+ {
+ 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;
+ int is_raid56;
+ grub_uint64_t parities_pos = 0;
+
+ is_raid56 = !!(grub_le_to_cpu64 (chunk->type) &
+ (GRUB_BTRFS_CHUNK_TYPE_RAID5 |
+ GRUB_BTRFS_CHUNK_TYPE_RAID6));
+
+ if (grub_le_to_cpu64 (chunk->size) <= off)
+ {
+ grub_dprintf ("btrfs", "no chunk\n");
+ return grub_error (GRUB_ERR_BAD_FS,
+ "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),
+ nstripes,
+ grub_le_to_cpu16 (chunk->nsubstripes),
+ chunk_stripe_length);
+
+ switch (grub_le_to_cpu64 (chunk->type)
+ & ~GRUB_BTRFS_CHUNK_TYPE_BITS_DONTCARE)
+ {
+ case GRUB_BTRFS_CHUNK_TYPE_SINGLE:
+ {
+ grub_uint64_t stripe_length;
+ grub_dprintf ("btrfs", "single\n");
+ stripe_length = grub_divmod64 (grub_le_to_cpu64 (chunk->size),
+ nstripes,
+ NULL);
+ if (stripe_length == 0)
+ stripe_length = 512;
+ stripen = grub_divmod64 (off, stripe_length, &stripe_offset);
+ csize = (stripen + 1) * stripe_length - off;
+ break;
+ }
+ case GRUB_BTRFS_CHUNK_TYPE_RAID1C4:
+ redundancy++;
+ /* fall through */
+ case GRUB_BTRFS_CHUNK_TYPE_RAID1C3:
+ redundancy++;
+ /* fall through */
+ case GRUB_BTRFS_CHUNK_TYPE_DUPLICATED:
+ case GRUB_BTRFS_CHUNK_TYPE_RAID1:
+ {
+ grub_dprintf ("btrfs", "RAID1 (copies: %d)\n", ++redundancy);
+ stripen = 0;
+ stripe_offset = off;
+ csize = grub_le_to_cpu64 (chunk->size) - off;
+ break;
+ }
+ case GRUB_BTRFS_CHUNK_TYPE_RAID0:
+ {
+ grub_uint64_t middle, high;
+ grub_uint64_t low;
+ grub_dprintf ("btrfs", "RAID0\n");
+ middle = grub_divmod64 (off,
+ chunk_stripe_length,
+ &low);
+
+ high = grub_divmod64 (middle, nstripes,
+ &stripen);
+ stripe_offset =
+ 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,
+ chunk_stripe_length,
+ &low);
+
+ high = grub_divmod64 (middle,
+ nstripes / nsubstripes ? : 1,
+ &stripen);
+ stripen *= nsubstripes;
+ redundancy = nsubstripes;
+ stripe_offset = low + chunk_stripe_length
+ * high;
+ csize = chunk_stripe_length - low;
+ break;
+ }
+ case GRUB_BTRFS_CHUNK_TYPE_RAID5:
+ case GRUB_BTRFS_CHUNK_TYPE_RAID6:
+ {
+ grub_uint64_t nparities, stripe_nr, high, low;
+
+ redundancy = 1; /* no redundancy for now */
+
+ if (grub_le_to_cpu64 (chunk->type) & GRUB_BTRFS_CHUNK_TYPE_RAID5)
+ {
+ grub_dprintf ("btrfs", "RAID5\n");
+ nparities = 1;
+ }
+ else
+ {
+ grub_dprintf ("btrfs", "RAID6\n");
+ nparities = 2;
+ }
+
+ /*
+ * RAID 6 layout consists of several stripes spread over
+ * the disks, e.g.:
+ *
+ * Disk_0 Disk_1 Disk_2 Disk_3
+ * A0 B0 P0 Q0
+ * Q1 A1 B1 P1
+ * P2 Q2 A2 B2
+ *
+ * Note: placement of the parities depend on row number.
+ *
+ * Pay attention that the btrfs terminology may differ from
+ * terminology used in other RAID implementations, e.g. LVM,
+ * dm or md. The main difference is that btrfs calls contiguous
+ * block of data on a given disk, e.g. A0, stripe instead of chunk.
+ *
+ * The variables listed below have following meaning:
+ * - stripe_nr is the stripe number excluding the parities
+ * (A0 = 0, B0 = 1, A1 = 2, B1 = 3, etc.),
+ * - high is the row number (0 for A0...Q0, 1 for Q1...P1, etc.),
+ * - stripen is the disk number in a row (0 for A0, Q1, P2,
+ * 1 for B0, A1, Q2, etc.),
+ * - off is the logical address to read,
+ * - chunk_stripe_length is the size of a stripe (typically 64 KiB),
+ * - nstripes is the number of disks in a row,
+ * - low is the offset of the data inside a stripe,
+ * - stripe_offset is the data offset in an array,
+ * - csize is the "potential" data to read; it will be reduced
+ * to size if the latter is smaller,
+ * - nparities is the number of parities (1 for RAID 5, 2 for
+ * RAID 6); used only in RAID 5/6 code.
+ */
+ stripe_nr = grub_divmod64 (off, chunk_stripe_length, &low);
+
+ /*
+ * stripen is computed without the parities
+ * (0 for A0, A1, A2, 1 for B0, B1, B2, etc.).
+ */
+ if (nparities >= nstripes)
+ return grub_error (GRUB_ERR_BAD_FS,
+ "invalid RAID5/6: nparities >= nstripes");
+ high = grub_divmod64 (stripe_nr, nstripes - nparities, &stripen);
+
+ /*
+ * The stripes are spread over the disks. Every each row their
+ * positions are shifted by 1 place. So, the real disks number
+ * change. Hence, we have to take into account current row number
+ * modulo nstripes (0 for A0, 1 for A1, 2 for A2, etc.).
+ */
+ grub_divmod64 (high + stripen, nstripes, &stripen);
+
+ /*
+ * parities_pos is equal to ((high - nparities) % nstripes)
+ * (see the diagram above). However, (high - nparities) can
+ * be negative, e.g. when high == 0, leading to an incorrect
+ * results. (high + nstripes - nparities) is always positive and
+ * modulo nstripes is equal to ((high - nparities) % nstripes).
+ */
+ grub_divmod64 (high + nstripes - nparities, nstripes, &parities_pos);
+
+ stripe_offset = chunk_stripe_length * high + low;
+ csize = chunk_stripe_length - low;
+
+ break;
+ }
+ default:
+ grub_dprintf ("btrfs", "unsupported RAID\n");
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unsupported RAID flags %" PRIxGRUB_UINT64_T,
+ grub_le_to_cpu64 (chunk->type));
+ }
+ if (csize == 0)
+ return grub_error (GRUB_ERR_BUG,
+ "couldn't find the chunk descriptor");
+ if (csize > (grub_uint64_t) size)
+ csize = size;
+
+ for (j = 0; j < 2; j++)
+ {
+ 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),
+ grub_le_to_cpu16 (chunk->nsubstripes),
+ grub_le_to_cpu64 (chunk->stripe_length));
+ grub_dprintf ("btrfs", "reading laddr 0x%" PRIxGRUB_UINT64_T "\n",
+ addr);
+
+ if (is_raid56)
+ {
+ err = btrfs_read_from_chunk (data, chunk, stripen,
+ stripe_offset,
+ 0, /* no mirror */
+ csize, buf);
+ grub_errno = GRUB_ERR_NONE;
+ if (err)
+ err = raid56_read_retry (data, chunk, stripe_offset,
+ stripen, csize, buf, parities_pos);
+ }
+ else
+ for (i = 0; i < redundancy; i++)
+ {
+ err = btrfs_read_from_chunk (data, chunk, stripen,
+ stripe_offset,
+ i, /* redundancy */
+ csize, buf);
+ if (!err)
+ break;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ if (!err)
+ break;
+ }
+ if (err)
+ return grub_errno = err;
+ }
+ size -= csize;
+ buf = (grub_uint8_t *) buf + csize;
+ addr += csize;
+ if (challoc)
+ grub_free (chunk);
+ }
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_btrfs_data *
+grub_btrfs_mount (grub_device_t dev)
+{
+ struct grub_btrfs_data *data;
+ grub_err_t err;
+
+ if (!dev->disk)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not BtrFS");
+ return NULL;
+ }
+
+ data = grub_zalloc (sizeof (*data));
+ if (!data)
+ return NULL;
+
+ err = read_sblock (dev->disk, &data->sblock);
+ if (err)
+ {
+ grub_free (data);
+ return NULL;
+ }
+
+ data->n_devices_allocated = 16;
+ data->devices_attached = grub_malloc (sizeof (data->devices_attached[0])
+ * data->n_devices_allocated);
+ if (!data->devices_attached)
+ {
+ grub_free (data);
+ return NULL;
+ }
+ data->n_devices_attached = 1;
+ data->devices_attached[0].dev = dev;
+ data->devices_attached[0].id = data->sblock.this_device.device_id;
+
+ return data;
+}
+
+static void
+grub_btrfs_unmount (struct grub_btrfs_data *data)
+{
+ unsigned i;
+ /* The device 0 is closed one layer upper. */
+ for (i = 1; i < data->n_devices_attached; i++)
+ if (data->devices_attached[i].dev)
+ grub_device_close (data->devices_attached[i].dev);
+ grub_free (data->devices_attached);
+ grub_free (data->extent);
+ grub_free (data);
+}
+
+static grub_err_t
+grub_btrfs_read_inode (struct grub_btrfs_data *data,
+ struct grub_btrfs_inode *inode, grub_uint64_t num,
+ grub_uint64_t tree)
+{
+ struct grub_btrfs_key key_in, key_out;
+ grub_disk_addr_t elemaddr;
+ grub_size_t elemsize;
+ grub_err_t err;
+
+ key_in.object_id = num;
+ key_in.type = GRUB_BTRFS_ITEM_TYPE_INODE_ITEM;
+ key_in.offset = 0;
+
+ err = lower_bound (data, &key_in, &key_out, tree, &elemaddr, &elemsize, NULL,
+ 0);
+ if (err)
+ return err;
+ if (num != key_out.object_id
+ || key_out.type != GRUB_BTRFS_ITEM_TYPE_INODE_ITEM)
+ return grub_error (GRUB_ERR_BAD_FS, "inode not found");
+
+ return grub_btrfs_read_logical (data, elemaddr, inode, sizeof (*inode), 0);
+}
+
+static void *grub_zstd_malloc (void *state __attribute__((unused)), size_t size)
+{
+ return grub_malloc (size);
+}
+
+static void grub_zstd_free (void *state __attribute__((unused)), void *address)
+{
+ return grub_free (address);
+}
+
+static ZSTD_customMem grub_zstd_allocator (void)
+{
+ ZSTD_customMem allocator;
+
+ allocator.customAlloc = &grub_zstd_malloc;
+ allocator.customFree = &grub_zstd_free;
+ allocator.opaque = NULL;
+
+ return allocator;
+}
+
+static grub_ssize_t
+grub_btrfs_zstd_decompress (char *ibuf, grub_size_t isize, grub_off_t off,
+ char *obuf, grub_size_t osize)
+{
+ void *allocated = NULL;
+ char *otmpbuf = obuf;
+ grub_size_t otmpsize = osize;
+ ZSTD_DCtx *dctx = NULL;
+ grub_size_t zstd_ret;
+ grub_ssize_t ret = -1;
+
+ /*
+ * Zstd will fail if it can't fit the entire output in the destination
+ * buffer, so if osize isn't large enough, allocate a temporary buffer.
+ */
+ if (otmpsize < ZSTD_BTRFS_MAX_INPUT)
+ {
+ allocated = grub_malloc (ZSTD_BTRFS_MAX_INPUT);
+ if (!allocated)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed allocate a zstd buffer");
+ goto err;
+ }
+ otmpbuf = (char *) allocated;
+ otmpsize = ZSTD_BTRFS_MAX_INPUT;
+ }
+
+ /* Create the ZSTD_DCtx. */
+ dctx = ZSTD_createDCtx_advanced (grub_zstd_allocator ());
+ if (!dctx)
+ {
+ /* ZSTD_createDCtx_advanced() only fails if it is out of memory. */
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed to create a zstd context");
+ goto err;
+ }
+
+ /*
+ * Get the real input size, there may be junk at the
+ * end of the frame.
+ */
+ isize = ZSTD_findFrameCompressedSize (ibuf, isize);
+ if (ZSTD_isError (isize))
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "zstd data corrupted");
+ goto err;
+ }
+
+ /* Decompress and check for errors. */
+ zstd_ret = ZSTD_decompressDCtx (dctx, otmpbuf, otmpsize, ibuf, isize);
+ if (ZSTD_isError (zstd_ret))
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "zstd data corrupted");
+ goto err;
+ }
+
+ /*
+ * Move the requested data into the obuf. obuf may be equal
+ * to otmpbuf, which is why grub_memmove() is required.
+ */
+ grub_memmove (obuf, otmpbuf + off, osize);
+ ret = osize;
+
+err:
+ grub_free (allocated);
+ ZSTD_freeDCtx (dctx);
+
+ return ret;
+}
+
+static grub_ssize_t
+grub_btrfs_lzo_decompress(char *ibuf, grub_size_t isize, grub_off_t off,
+ char *obuf, grub_size_t osize)
+{
+ grub_uint32_t total_size, cblock_size;
+ grub_size_t ret = 0;
+ char *ibuf0 = ibuf;
+
+ total_size = grub_le_to_cpu32 (grub_get_unaligned32 (ibuf));
+ ibuf += sizeof (total_size);
+
+ if (isize < total_size)
+ return -1;
+
+ /* Jump forward to first block with requested data. */
+ while (off >= GRUB_BTRFS_LZO_BLOCK_SIZE)
+ {
+ /* Don't let following uint32_t cross the page boundary. */
+ if (((ibuf - ibuf0) & 0xffc) == 0xffc)
+ ibuf = ((ibuf - ibuf0 + 3) & ~3) + ibuf0;
+
+ cblock_size = grub_le_to_cpu32 (grub_get_unaligned32 (ibuf));
+ ibuf += sizeof (cblock_size);
+
+ if (cblock_size > GRUB_BTRFS_LZO_BLOCK_MAX_CSIZE)
+ return -1;
+
+ off -= GRUB_BTRFS_LZO_BLOCK_SIZE;
+ ibuf += cblock_size;
+ }
+
+ while (osize > 0)
+ {
+ lzo_uint usize = GRUB_BTRFS_LZO_BLOCK_SIZE;
+
+ /* Don't let following uint32_t cross the page boundary. */
+ if (((ibuf - ibuf0) & 0xffc) == 0xffc)
+ ibuf = ((ibuf - ibuf0 + 3) & ~3) + ibuf0;
+
+ cblock_size = grub_le_to_cpu32 (grub_get_unaligned32 (ibuf));
+ ibuf += sizeof (cblock_size);
+
+ if (cblock_size > GRUB_BTRFS_LZO_BLOCK_MAX_CSIZE)
+ return -1;
+
+ /* Block partially filled with requested data. */
+ if (off > 0 || osize < GRUB_BTRFS_LZO_BLOCK_SIZE)
+ {
+ grub_size_t to_copy = GRUB_BTRFS_LZO_BLOCK_SIZE - off;
+ grub_uint8_t *buf;
+
+ if (to_copy > osize)
+ to_copy = osize;
+
+ buf = grub_malloc (GRUB_BTRFS_LZO_BLOCK_SIZE);
+ if (!buf)
+ return -1;
+
+ if (lzo1x_decompress_safe ((lzo_bytep)ibuf, cblock_size, buf, &usize,
+ NULL) != LZO_E_OK)
+ {
+ grub_free (buf);
+ return -1;
+ }
+
+ if (to_copy > usize)
+ to_copy = usize;
+ grub_memcpy(obuf, buf + off, to_copy);
+
+ osize -= to_copy;
+ ret += to_copy;
+ obuf += to_copy;
+ ibuf += cblock_size;
+ off = 0;
+
+ grub_free (buf);
+ continue;
+ }
+
+ /* Decompress whole block directly to output buffer. */
+ if (lzo1x_decompress_safe ((lzo_bytep)ibuf, cblock_size, (lzo_bytep)obuf,
+ &usize, NULL) != LZO_E_OK)
+ return -1;
+
+ osize -= usize;
+ ret += usize;
+ obuf += usize;
+ ibuf += cblock_size;
+ }
+
+ return ret;
+}
+
+static grub_ssize_t
+grub_btrfs_extent_read (struct grub_btrfs_data *data,
+ grub_uint64_t ino, grub_uint64_t tree,
+ grub_off_t pos0, char *buf, grub_size_t len)
+{
+ grub_off_t pos = pos0;
+ while (len)
+ {
+ grub_size_t csize;
+ grub_err_t err;
+ grub_off_t extoff;
+ if (!data->extent || data->extstart > pos || data->extino != ino
+ || data->exttree != tree || data->extend <= pos)
+ {
+ struct grub_btrfs_key key_in, key_out;
+ grub_disk_addr_t elemaddr;
+ grub_size_t elemsize;
+
+ grub_free (data->extent);
+ key_in.object_id = ino;
+ key_in.type = GRUB_BTRFS_ITEM_TYPE_EXTENT_ITEM;
+ key_in.offset = grub_cpu_to_le64 (pos);
+ err = lower_bound (data, &key_in, &key_out, tree,
+ &elemaddr, &elemsize, NULL, 0);
+ if (err)
+ return -1;
+ if (key_out.object_id != ino
+ || key_out.type != GRUB_BTRFS_ITEM_TYPE_EXTENT_ITEM)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "extent not found");
+ return -1;
+ }
+ if ((grub_ssize_t) elemsize < ((char *) &data->extent->inl
+ - (char *) data->extent))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "extent descriptor is too short");
+ return -1;
+ }
+ data->extstart = grub_le_to_cpu64 (key_out.offset);
+ data->extsize = elemsize;
+ data->extent = grub_malloc (elemsize);
+ data->extino = ino;
+ data->exttree = tree;
+ if (!data->extent)
+ return grub_errno;
+
+ err = grub_btrfs_read_logical (data, elemaddr, data->extent,
+ elemsize, 0);
+ if (err)
+ return err;
+
+ 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->filled + sizeof (data->extent->filled))
+ data->extend =
+ data->extstart + grub_le_to_cpu64 (data->extent->filled);
+
+ grub_dprintf ("btrfs", "regular extent 0x%" PRIxGRUB_UINT64_T "+0x%"
+ PRIxGRUB_UINT64_T "\n",
+ grub_le_to_cpu64 (key_out.offset),
+ grub_le_to_cpu64 (data->extent->size));
+ if (data->extend <= pos)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "extent not found");
+ return -1;
+ }
+ }
+ csize = data->extend - pos;
+ extoff = pos - data->extstart;
+ if (csize > len)
+ csize = len;
+
+ if (data->extent->encryption)
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "encryption not supported");
+ return -1;
+ }
+
+ if (data->extent->compression != GRUB_BTRFS_COMPRESSION_NONE
+ && data->extent->compression != GRUB_BTRFS_COMPRESSION_ZLIB
+ && data->extent->compression != GRUB_BTRFS_COMPRESSION_LZO
+ && data->extent->compression != GRUB_BTRFS_COMPRESSION_ZSTD)
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "compression type 0x%x not supported",
+ data->extent->compression);
+ return -1;
+ }
+
+ if (data->extent->encoding)
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "encoding not supported");
+ return -1;
+ }
+
+ switch (data->extent->type)
+ {
+ case GRUB_BTRFS_EXTENT_INLINE:
+ if (data->extent->compression == GRUB_BTRFS_COMPRESSION_ZLIB)
+ {
+ if (grub_zlib_decompress (data->extent->inl, data->extsize -
+ ((grub_uint8_t *) data->extent->inl
+ - (grub_uint8_t *) data->extent),
+ extoff, buf, csize)
+ != (grub_ssize_t) csize)
+ {
+ 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)
+ {
+ if (grub_btrfs_lzo_decompress(data->extent->inl, data->extsize -
+ ((grub_uint8_t *) data->extent->inl
+ - (grub_uint8_t *) data->extent),
+ extoff, buf, csize)
+ != (grub_ssize_t) csize)
+ return -1;
+ }
+ else if (data->extent->compression == GRUB_BTRFS_COMPRESSION_ZSTD)
+ {
+ if (grub_btrfs_zstd_decompress (data->extent->inl, data->extsize -
+ ((grub_uint8_t *) data->extent->inl
+ - (grub_uint8_t *) data->extent),
+ extoff, buf, csize)
+ != (grub_ssize_t) csize)
+ return -1;
+ }
+ else
+ grub_memcpy (buf, data->extent->inl + extoff, csize);
+ break;
+ case GRUB_BTRFS_EXTENT_REGULAR:
+ if (!data->extent->laddr)
+ {
+ grub_memset (buf, 0, csize);
+ break;
+ }
+
+ if (data->extent->compression != GRUB_BTRFS_COMPRESSION_NONE)
+ {
+ char *tmp;
+ grub_uint64_t zsize;
+ grub_ssize_t ret;
+
+ zsize = grub_le_to_cpu64 (data->extent->compressed_size);
+ tmp = grub_malloc (zsize);
+ if (!tmp)
+ return -1;
+ err = grub_btrfs_read_logical (data,
+ grub_le_to_cpu64 (data->extent->laddr),
+ tmp, zsize, 0);
+ if (err)
+ {
+ grub_free (tmp);
+ return -1;
+ }
+
+ if (data->extent->compression == GRUB_BTRFS_COMPRESSION_ZLIB)
+ ret = grub_zlib_decompress (tmp, zsize, extoff
+ + grub_le_to_cpu64 (data->extent->offset),
+ buf, csize);
+ else if (data->extent->compression == GRUB_BTRFS_COMPRESSION_LZO)
+ ret = grub_btrfs_lzo_decompress (tmp, zsize, extoff
+ + grub_le_to_cpu64 (data->extent->offset),
+ buf, csize);
+ else if (data->extent->compression == GRUB_BTRFS_COMPRESSION_ZSTD)
+ ret = grub_btrfs_zstd_decompress (tmp, zsize, extoff
+ + grub_le_to_cpu64 (data->extent->offset),
+ buf, csize);
+ else
+ ret = -1;
+
+ grub_free (tmp);
+
+ if (ret != (grub_ssize_t) csize)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "premature end of compressed");
+ return -1;
+ }
+
+ break;
+ }
+ err = grub_btrfs_read_logical (data,
+ grub_le_to_cpu64 (data->extent->laddr)
+ + grub_le_to_cpu64 (data->extent->offset)
+ + extoff, buf, csize, 0);
+ if (err)
+ return -1;
+ break;
+ default:
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unsupported extent type 0x%x", data->extent->type);
+ return -1;
+ }
+ buf += csize;
+ pos += csize;
+ len -= csize;
+ }
+ return pos - pos0;
+}
+
+static grub_err_t
+get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key,
+ grub_uint64_t *tree, grub_uint8_t *type)
+{
+ grub_err_t err;
+ grub_disk_addr_t elemaddr;
+ grub_size_t elemsize;
+ struct grub_btrfs_key key_out, key_in;
+ struct grub_btrfs_root_item ri;
+
+ 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,
+ data->sblock.root_tree,
+ &elemaddr, &elemsize, NULL, 0);
+ if (err)
+ return err;
+ if (key_in.object_id != key_out.object_id
+ || key_in.type != key_out.type
+ || key_in.offset != key_out.offset)
+ return grub_error (GRUB_ERR_BAD_FS, "no root");
+ err = grub_btrfs_read_logical (data, elemaddr, &ri,
+ sizeof (ri), 0);
+ if (err)
+ return err;
+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
+ key->offset = 0;
+ key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK);
+ *tree = ri.tree;
+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+find_path (struct grub_btrfs_data *data,
+ const char *path, struct grub_btrfs_key *key,
+ grub_uint64_t *tree, grub_uint8_t *type)
+{
+ const char *slash = path;
+ grub_err_t err;
+ grub_disk_addr_t elemaddr;
+ grub_size_t elemsize;
+ grub_size_t allocated = 0;
+ struct grub_btrfs_dir_item *direl = NULL;
+ struct grub_btrfs_key key_out;
+ const char *ctoken;
+ grub_size_t ctokenlen;
+ char *path_alloc = NULL;
+ char *origpath = NULL;
+ unsigned symlinks_max = 32;
+
+ err = get_root (data, key, tree, type);
+ if (err)
+ return err;
+
+ origpath = grub_strdup (path);
+ if (!origpath)
+ return grub_errno;
+
+ while (1)
+ {
+ while (path[0] == '/')
+ path++;
+ if (!path[0])
+ break;
+ slash = grub_strchr (path, '/');
+ if (!slash)
+ slash = path + grub_strlen (path);
+ ctoken = path;
+ ctokenlen = slash - path;
+
+ if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
+ {
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+ }
+
+ if (ctokenlen == 1 && ctoken[0] == '.')
+ {
+ path = slash;
+ continue;
+ }
+ if (ctokenlen == 2 && ctoken[0] == '.' && ctoken[1] == '.')
+ {
+ key->type = GRUB_BTRFS_ITEM_TYPE_INODE_REF;
+ key->offset = -1;
+
+ err = lower_bound (data, key, &key_out, *tree, &elemaddr, &elemsize,
+ NULL, 0);
+ if (err)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return err;
+ }
+
+ if (key_out.type != key->type
+ || key->object_id != key_out.object_id)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ err = grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
+ grub_free (origpath);
+ return err;
+ }
+
+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
+ key->object_id = key_out.offset;
+
+ path = slash;
+
+ continue;
+ }
+
+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
+ key->offset = grub_cpu_to_le64 (~grub_getcrc32c (1, ctoken, ctokenlen));
+
+ err = lower_bound (data, key, &key_out, *tree, &elemaddr, &elemsize,
+ NULL, 0);
+ if (err)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return err;
+ }
+ if (key_cmp (key, &key_out) != 0)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ err = grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
+ grub_free (origpath);
+ return err;
+ }
+
+ struct grub_btrfs_dir_item *cdirel;
+ if (elemsize > allocated)
+ {
+ allocated = 2 * elemsize;
+ grub_free (direl);
+ direl = grub_malloc (allocated + 1);
+ if (!direl)
+ {
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return grub_errno;
+ }
+ }
+
+ err = grub_btrfs_read_logical (data, elemaddr, direl, elemsize, 0);
+ if (err)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return err;
+ }
+
+ for (cdirel = direl;
+ (grub_uint8_t *) cdirel - (grub_uint8_t *) direl
+ < (grub_ssize_t) elemsize;
+ cdirel = (void *) ((grub_uint8_t *) (direl + 1)
+ + grub_le_to_cpu16 (cdirel->n)
+ + grub_le_to_cpu16 (cdirel->m)))
+ {
+ if (ctokenlen == grub_le_to_cpu16 (cdirel->n)
+ && grub_memcmp (cdirel->name, ctoken, ctokenlen) == 0)
+ break;
+ }
+ if ((grub_uint8_t *) cdirel - (grub_uint8_t *) direl
+ >= (grub_ssize_t) elemsize)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ err = grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
+ grub_free (origpath);
+ return err;
+ }
+
+ path = slash;
+ if (cdirel->type == GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK)
+ {
+ struct grub_btrfs_inode inode;
+ char *tmp;
+ if (--symlinks_max == 0)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return grub_error (GRUB_ERR_SYMLINK_LOOP,
+ N_("too deep nesting of symlinks"));
+ }
+
+ err = grub_btrfs_read_inode (data, &inode,
+ cdirel->key.object_id, *tree);
+ if (err)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return err;
+ }
+ tmp = grub_malloc (grub_le_to_cpu64 (inode.size)
+ + grub_strlen (path) + 1);
+ if (!tmp)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return grub_errno;
+ }
+
+ if (grub_btrfs_extent_read (data, cdirel->key.object_id,
+ *tree, 0, tmp,
+ grub_le_to_cpu64 (inode.size))
+ != (grub_ssize_t) grub_le_to_cpu64 (inode.size))
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ grub_free (origpath);
+ grub_free (tmp);
+ return grub_errno;
+ }
+ grub_memcpy (tmp + grub_le_to_cpu64 (inode.size), path,
+ grub_strlen (path) + 1);
+ grub_free (path_alloc);
+ path = path_alloc = tmp;
+ if (path[0] == '/')
+ {
+ err = get_root (data, key, tree, type);
+ if (err)
+ return err;
+ }
+ continue;
+ }
+ *type = cdirel->type;
+
+ switch (cdirel->key.type)
+ {
+ case GRUB_BTRFS_ITEM_TYPE_ROOT_ITEM:
+ {
+ struct grub_btrfs_root_item ri;
+ err = lower_bound (data, &cdirel->key, &key_out,
+ data->sblock.root_tree,
+ &elemaddr, &elemsize, NULL, 0);
+ if (err)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return err;
+ }
+ if (cdirel->key.object_id != key_out.object_id
+ || cdirel->key.type != key_out.type)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ err = grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
+ grub_free (origpath);
+ return err;
+ }
+ err = grub_btrfs_read_logical (data, elemaddr, &ri,
+ sizeof (ri), 0);
+ if (err)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return err;
+ }
+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
+ key->offset = 0;
+ key->object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK);
+ *tree = ri.tree;
+ break;
+ }
+ case GRUB_BTRFS_ITEM_TYPE_INODE_ITEM:
+ if (*slash && *type == GRUB_BTRFS_DIR_ITEM_TYPE_REGULAR)
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ err = grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
+ grub_free (origpath);
+ return err;
+ }
+ *key = cdirel->key;
+ if (*type == GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
+ key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
+ break;
+ default:
+ grub_free (path_alloc);
+ grub_free (origpath);
+ grub_free (direl);
+ return grub_error (GRUB_ERR_BAD_FS, "unrecognised object type 0x%x",
+ cdirel->key.type);
+ }
+ }
+
+ grub_free (direl);
+ grub_free (origpath);
+ grub_free (path_alloc);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_btrfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_btrfs_data *data = grub_btrfs_mount (device);
+ struct grub_btrfs_key key_in, key_out;
+ grub_err_t err;
+ grub_disk_addr_t elemaddr;
+ grub_size_t elemsize;
+ grub_size_t allocated = 0;
+ struct grub_btrfs_dir_item *direl = NULL;
+ struct grub_btrfs_leaf_descriptor desc;
+ int r = 0;
+ grub_uint64_t tree;
+ grub_uint8_t type;
+
+ if (!data)
+ return grub_errno;
+
+ err = find_path (data, path, &key_in, &tree, &type);
+ if (err)
+ {
+ grub_btrfs_unmount (data);
+ return err;
+ }
+ if (type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
+ {
+ grub_btrfs_unmount (data);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+ }
+
+ err = lower_bound (data, &key_in, &key_out, tree,
+ &elemaddr, &elemsize, &desc, 0);
+ if (err)
+ {
+ grub_btrfs_unmount (data);
+ return err;
+ }
+ if (key_out.type != GRUB_BTRFS_ITEM_TYPE_DIR_ITEM
+ || key_out.object_id != key_in.object_id)
+ {
+ r = next (data, &desc, &elemaddr, &elemsize, &key_out);
+ if (r <= 0)
+ goto out;
+ }
+ do
+ {
+ struct grub_btrfs_dir_item *cdirel;
+ if (key_out.type != GRUB_BTRFS_ITEM_TYPE_DIR_ITEM
+ || key_out.object_id != key_in.object_id)
+ {
+ r = 0;
+ break;
+ }
+ if (elemsize > allocated)
+ {
+ allocated = 2 * elemsize;
+ grub_free (direl);
+ direl = grub_malloc (allocated + 1);
+ if (!direl)
+ {
+ r = -grub_errno;
+ break;
+ }
+ }
+
+ err = grub_btrfs_read_logical (data, elemaddr, direl, elemsize, 0);
+ if (err)
+ {
+ r = -err;
+ break;
+ }
+
+ for (cdirel = direl;
+ (grub_uint8_t *) cdirel - (grub_uint8_t *) direl
+ < (grub_ssize_t) elemsize;
+ cdirel = (void *) ((grub_uint8_t *) (direl + 1)
+ + grub_le_to_cpu16 (cdirel->n)
+ + grub_le_to_cpu16 (cdirel->m)))
+ {
+ char c;
+ struct grub_btrfs_inode inode;
+ struct grub_dirhook_info info;
+ err = grub_btrfs_read_inode (data, &inode, cdirel->key.object_id,
+ tree);
+ grub_memset (&info, 0, sizeof (info));
+ if (err)
+ grub_errno = GRUB_ERR_NONE;
+ else
+ {
+ info.mtime = grub_le_to_cpu64 (inode.mtime.sec);
+ info.mtimeset = 1;
+ }
+ c = cdirel->name[grub_le_to_cpu16 (cdirel->n)];
+ cdirel->name[grub_le_to_cpu16 (cdirel->n)] = 0;
+ info.dir = (cdirel->type == GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY);
+ if (hook (cdirel->name, &info, hook_data))
+ goto out;
+ cdirel->name[grub_le_to_cpu16 (cdirel->n)] = c;
+ }
+ r = next (data, &desc, &elemaddr, &elemsize, &key_out);
+ }
+ while (r > 0);
+
+out:
+ grub_free (direl);
+
+ free_iterator (&desc);
+ grub_btrfs_unmount (data);
+
+ return -r;
+}
+
+static grub_err_t
+grub_btrfs_open (struct grub_file *file, const char *name)
+{
+ struct grub_btrfs_data *data = grub_btrfs_mount (file->device);
+ grub_err_t err;
+ struct grub_btrfs_inode inode;
+ grub_uint8_t type;
+ struct grub_btrfs_key key_in;
+
+ if (!data)
+ return grub_errno;
+
+ err = find_path (data, name, &key_in, &data->tree, &type);
+ if (err)
+ {
+ grub_btrfs_unmount (data);
+ return err;
+ }
+ if (type != GRUB_BTRFS_DIR_ITEM_TYPE_REGULAR)
+ {
+ grub_btrfs_unmount (data);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
+ }
+
+ data->inode = key_in.object_id;
+ err = grub_btrfs_read_inode (data, &inode, data->inode, data->tree);
+ if (err)
+ {
+ grub_btrfs_unmount (data);
+ return err;
+ }
+
+ file->data = data;
+ file->size = grub_le_to_cpu64 (inode.size);
+
+ return err;
+}
+
+static grub_err_t
+grub_btrfs_close (grub_file_t file)
+{
+ grub_btrfs_unmount (file->data);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_ssize_t
+grub_btrfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_btrfs_data *data = file->data;
+
+ return grub_btrfs_extent_read (data, data->inode,
+ data->tree, file->offset, buf, len);
+}
+
+static grub_err_t
+grub_btrfs_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_btrfs_data *data;
+
+ *uuid = NULL;
+
+ data = grub_btrfs_mount (device);
+ if (!data)
+ return grub_errno;
+
+ *uuid = grub_xasprintf ("%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
+ grub_be_to_cpu16 (data->sblock.uuid[0]),
+ grub_be_to_cpu16 (data->sblock.uuid[1]),
+ grub_be_to_cpu16 (data->sblock.uuid[2]),
+ grub_be_to_cpu16 (data->sblock.uuid[3]),
+ grub_be_to_cpu16 (data->sblock.uuid[4]),
+ grub_be_to_cpu16 (data->sblock.uuid[5]),
+ grub_be_to_cpu16 (data->sblock.uuid[6]),
+ grub_be_to_cpu16 (data->sblock.uuid[7]));
+
+ grub_btrfs_unmount (data);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_btrfs_label (grub_device_t device, char **label)
+{
+ struct grub_btrfs_data *data;
+
+ *label = NULL;
+
+ data = grub_btrfs_mount (device);
+ if (!data)
+ return grub_errno;
+
+ *label = grub_strndup (data->sblock.label, sizeof (data->sblock.label));
+
+ grub_btrfs_unmount (data);
+
+ return grub_errno;
+}
+
+#ifdef GRUB_UTIL
+static grub_err_t
+grub_btrfs_embed (grub_device_t device __attribute__ ((unused)),
+ unsigned int *nsectors,
+ unsigned int max_nsectors,
+ grub_embed_type_t embed_type,
+ grub_disk_addr_t **sectors)
+{
+ unsigned i;
+
+ if (embed_type != GRUB_EMBED_PCBIOS)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "BtrFS currently supports only PC-BIOS embedding");
+
+ if (64 * 2 - 1 < *nsectors)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("your core.img is unusually large. "
+ "It won't fit in the embedding area"));
+
+ *nsectors = 64 * 2 - 1;
+ if (*nsectors > max_nsectors)
+ *nsectors = max_nsectors;
+ *sectors = grub_calloc (*nsectors, sizeof (**sectors));
+ if (!*sectors)
+ return grub_errno;
+ for (i = 0; i < *nsectors; i++)
+ (*sectors)[i] = i + 1;
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+static struct grub_fs grub_btrfs_fs = {
+ .name = "btrfs",
+ .fs_dir = grub_btrfs_dir,
+ .fs_open = grub_btrfs_open,
+ .fs_read = grub_btrfs_read,
+ .fs_close = grub_btrfs_close,
+ .fs_uuid = grub_btrfs_uuid,
+ .fs_label = grub_btrfs_label,
+#ifdef GRUB_UTIL
+ .fs_embed = grub_btrfs_embed,
+ .reserved_first_sector = 1,
+ .blocklist_install = 0,
+#endif
+};
+
+GRUB_MOD_INIT (btrfs)
+{
+ grub_fs_register (&grub_btrfs_fs);
+}
+
+GRUB_MOD_FINI (btrfs)
+{
+ grub_fs_unregister (&grub_btrfs_fs);
+}
diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c
new file mode 100644
index 0000000..581215e
--- /dev/null
+++ b/grub-core/fs/cbfs.c
@@ -0,0 +1,402 @@
+/* cbfs.c - cbfs and tar filesystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009,2013 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/archelp.h>
+
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+#include <grub/cbfs_core.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+
+struct grub_archelp_data
+{
+ grub_disk_t disk;
+ grub_off_t hofs, next_hofs;
+ grub_off_t dofs;
+ grub_off_t size;
+ grub_off_t cbfs_start;
+ grub_off_t cbfs_end;
+ grub_off_t cbfs_align;
+};
+
+static grub_err_t
+grub_cbfs_find_file (struct grub_archelp_data *data, char **name,
+ grub_int32_t *mtime,
+ grub_uint32_t *mode)
+{
+ grub_size_t offset;
+ for (;;
+ data->dofs = data->hofs + offset,
+ data->next_hofs = ALIGN_UP (data->dofs + data->size, data->cbfs_align))
+ {
+ struct cbfs_file hd;
+ grub_size_t namesize;
+
+ data->hofs = data->next_hofs;
+
+ if (data->hofs >= data->cbfs_end)
+ {
+ *mode = GRUB_ARCHELP_ATTR_END;
+ return GRUB_ERR_NONE;
+ }
+
+ if (grub_disk_read (data->disk, 0, data->hofs, sizeof (hd), &hd))
+ return grub_errno;
+
+ if (grub_memcmp (hd.magic, CBFS_FILE_MAGIC, sizeof (hd.magic)) != 0)
+ {
+ *mode = GRUB_ARCHELP_ATTR_END;
+ return GRUB_ERR_NONE;
+ }
+ data->size = grub_be_to_cpu32 (hd.len);
+ (void) mtime;
+ offset = grub_be_to_cpu32 (hd.offset);
+
+ *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
+
+ namesize = offset;
+ if (namesize >= sizeof (hd))
+ namesize -= sizeof (hd);
+ if (namesize == 0)
+ continue;
+ *name = grub_malloc (namesize + 1);
+ if (*name == NULL)
+ return grub_errno;
+
+ if (grub_disk_read (data->disk, 0, data->hofs + sizeof (hd),
+ namesize, *name))
+ {
+ grub_free (*name);
+ return grub_errno;
+ }
+
+ if ((*name)[0] == '\0')
+ {
+ grub_free (*name);
+ *name = NULL;
+ continue;
+ }
+
+ (*name)[namesize] = 0;
+
+ data->dofs = data->hofs + offset;
+ data->next_hofs = ALIGN_UP (data->dofs + data->size, data->cbfs_align);
+ return GRUB_ERR_NONE;
+ }
+}
+
+static void
+grub_cbfs_rewind (struct grub_archelp_data *data)
+{
+ data->next_hofs = data->cbfs_start;
+}
+
+static struct grub_archelp_ops arcops =
+ {
+ .find_file = grub_cbfs_find_file,
+ .rewind = grub_cbfs_rewind
+ };
+
+static int
+validate_head (struct cbfs_header *head)
+{
+ return (head->magic == grub_cpu_to_be32_compile_time (CBFS_HEADER_MAGIC)
+ && (head->version
+ == grub_cpu_to_be32_compile_time (CBFS_HEADER_VERSION1)
+ || head->version
+ == grub_cpu_to_be32_compile_time (CBFS_HEADER_VERSION2))
+ && (grub_be_to_cpu32 (head->bootblocksize)
+ < grub_be_to_cpu32 (head->romsize))
+ && (grub_be_to_cpu32 (head->offset)
+ < grub_be_to_cpu32 (head->romsize))
+ && (grub_be_to_cpu32 (head->offset)
+ + grub_be_to_cpu32 (head->bootblocksize)
+ < grub_be_to_cpu32 (head->romsize))
+ && head->align != 0
+ && (head->align & (head->align - 1)) == 0
+ && head->romsize != 0);
+}
+
+static struct grub_archelp_data *
+grub_cbfs_mount (grub_disk_t disk)
+{
+ struct cbfs_file hd;
+ struct grub_archelp_data *data = NULL;
+ grub_uint32_t ptr;
+ grub_off_t header_off;
+ struct cbfs_header head;
+
+ if (grub_disk_native_sectors (disk) == GRUB_DISK_SIZE_UNKNOWN)
+ goto fail;
+
+ if (grub_disk_read (disk, grub_disk_native_sectors (disk) - 1,
+ GRUB_DISK_SECTOR_SIZE - sizeof (ptr),
+ sizeof (ptr), &ptr))
+ goto fail;
+
+ ptr = grub_cpu_to_le32 (ptr);
+ header_off = (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS)
+ + (grub_int32_t) ptr;
+
+ if (grub_disk_read (disk, 0, header_off,
+ sizeof (head), &head))
+ goto fail;
+
+ if (!validate_head (&head))
+ goto fail;
+
+ data = (struct grub_archelp_data *) grub_zalloc (sizeof (*data));
+ if (!data)
+ goto fail;
+
+ data->cbfs_start = (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS)
+ - (grub_be_to_cpu32 (head.romsize) - grub_be_to_cpu32 (head.offset));
+ data->cbfs_end = (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS)
+ - grub_be_to_cpu32 (head.bootblocksize);
+ data->cbfs_align = grub_be_to_cpu32 (head.align);
+
+ if (data->cbfs_start >= (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS))
+ goto fail;
+ if (data->cbfs_end > (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS))
+ data->cbfs_end = (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS);
+
+ data->next_hofs = data->cbfs_start;
+
+ if (grub_disk_read (disk, 0, data->cbfs_start, sizeof (hd), &hd))
+ goto fail;
+
+ if (grub_memcmp (hd.magic, CBFS_FILE_MAGIC, sizeof (CBFS_FILE_MAGIC) - 1))
+ goto fail;
+
+ data->disk = disk;
+
+ return data;
+
+fail:
+ grub_free (data);
+ grub_error (GRUB_ERR_BAD_FS, "not a cbfs filesystem");
+ return 0;
+}
+
+static grub_err_t
+grub_cbfs_dir (grub_device_t device, const char *path_in,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_archelp_data *data;
+ grub_err_t err;
+
+ data = grub_cbfs_mount (device->disk);
+ if (!data)
+ return grub_errno;
+
+ err = grub_archelp_dir (data, &arcops,
+ path_in, hook, hook_data);
+
+ grub_free (data);
+
+ return err;
+}
+
+static grub_err_t
+grub_cbfs_open (grub_file_t file, const char *name_in)
+{
+ struct grub_archelp_data *data;
+ grub_err_t err;
+
+ data = grub_cbfs_mount (file->device->disk);
+ if (!data)
+ return grub_errno;
+
+ err = grub_archelp_open (data, &arcops, name_in);
+ if (err)
+ {
+ grub_free (data);
+ }
+ else
+ {
+ file->data = data;
+ file->size = data->size;
+ }
+ return err;
+}
+
+static grub_ssize_t
+grub_cbfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_archelp_data *data;
+ grub_ssize_t ret;
+
+ data = file->data;
+ data->disk->read_hook = file->read_hook;
+ data->disk->read_hook_data = file->read_hook_data;
+
+ ret = (grub_disk_read (data->disk, 0, data->dofs + file->offset,
+ len, buf)) ? -1 : (grub_ssize_t) len;
+ data->disk->read_hook = 0;
+
+ return ret;
+}
+
+static grub_err_t
+grub_cbfs_close (grub_file_t file)
+{
+ struct grub_archelp_data *data;
+
+ data = file->data;
+ grub_free (data);
+
+ return grub_errno;
+}
+
+#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) \
+ && !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
+
+static char *cbfsdisk_addr;
+static grub_off_t cbfsdisk_size = 0;
+
+static int
+grub_cbfsdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ return hook ("cbfsdisk", hook_data);
+}
+
+static grub_err_t
+grub_cbfsdisk_open (const char *name, grub_disk_t disk)
+{
+ if (grub_strcmp (name, "cbfsdisk"))
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a cbfsdisk");
+
+ disk->total_sectors = cbfsdisk_size / GRUB_DISK_SECTOR_SIZE;
+ disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
+ disk->id = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_cbfsdisk_close (grub_disk_t disk __attribute((unused)))
+{
+}
+
+static grub_err_t
+grub_cbfsdisk_read (grub_disk_t disk __attribute((unused)),
+ grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ grub_memcpy (buf, cbfsdisk_addr + (sector << GRUB_DISK_SECTOR_BITS),
+ size << GRUB_DISK_SECTOR_BITS);
+ return 0;
+}
+
+static grub_err_t
+grub_cbfsdisk_write (grub_disk_t disk __attribute__ ((unused)),
+ grub_disk_addr_t sector __attribute__ ((unused)),
+ grub_size_t size __attribute__ ((unused)),
+ const char *buf __attribute__ ((unused)))
+{
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "rom flashing isn't implemented yet");
+}
+
+static struct grub_disk_dev grub_cbfsdisk_dev =
+ {
+ .name = "cbfsdisk",
+ .id = GRUB_DISK_DEVICE_CBFSDISK_ID,
+ .disk_iterate = grub_cbfsdisk_iterate,
+ .disk_open = grub_cbfsdisk_open,
+ .disk_close = grub_cbfsdisk_close,
+ .disk_read = grub_cbfsdisk_read,
+ .disk_write = grub_cbfsdisk_write,
+ .next = 0
+ };
+
+static void
+init_cbfsdisk (void)
+{
+ grub_uint32_t ptr;
+ struct cbfs_header *head;
+
+ ptr = *(grub_uint32_t *) 0xfffffffc;
+ head = (struct cbfs_header *) (grub_addr_t) ptr;
+ 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),
+ GRUB_DISK_SECTOR_SIZE);
+ cbfsdisk_addr = (void *) (grub_addr_t) (0x100000000ULL - cbfsdisk_size);
+
+ grub_disk_dev_register (&grub_cbfsdisk_dev);
+}
+
+static void
+fini_cbfsdisk (void)
+{
+ if (! cbfsdisk_size)
+ return;
+ grub_disk_dev_unregister (&grub_cbfsdisk_dev);
+}
+
+#endif
+
+static struct grub_fs grub_cbfs_fs = {
+ .name = "cbfs",
+ .fs_dir = grub_cbfs_dir,
+ .fs_open = grub_cbfs_open,
+ .fs_read = grub_cbfs_read,
+ .fs_close = grub_cbfs_close,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 0,
+ .blocklist_install = 0,
+#endif
+};
+
+GRUB_MOD_INIT (cbfs)
+{
+#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
+ init_cbfsdisk ();
+#endif
+ grub_fs_register (&grub_cbfs_fs);
+}
+
+GRUB_MOD_FINI (cbfs)
+{
+ grub_fs_unregister (&grub_cbfs_fs);
+#if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
+ fini_cbfsdisk ();
+#endif
+}
diff --git a/grub-core/fs/cpio.c b/grub-core/fs/cpio.c
new file mode 100644
index 0000000..dab5f98
--- /dev/null
+++ b/grub-core/fs/cpio.c
@@ -0,0 +1,61 @@
+/* cpio.c - cpio and tar filesystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009,2013 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+
+/* cpio support */
+#define ALIGN_CPIO(x) (ALIGN_UP ((x), 2))
+#define MAGIC "\xc7\x71"
+struct head
+{
+ grub_uint16_t magic[1];
+ grub_uint16_t dev;
+ grub_uint16_t ino;
+ grub_uint16_t mode[1];
+ grub_uint16_t uid;
+ grub_uint16_t gid;
+ grub_uint16_t nlink;
+ grub_uint16_t rdev;
+ grub_uint16_t mtime[2];
+ grub_uint16_t namesize[1];
+ grub_uint16_t filesize[2];
+} GRUB_PACKED;
+
+static inline unsigned long long
+read_number (const grub_uint16_t *arr, grub_size_t size)
+{
+ long long ret = 0;
+ while (size--)
+ ret = (ret << 16) | grub_le_to_cpu16 (*arr++);
+ return ret;
+}
+
+#define FSNAME "cpiofs"
+
+#include "cpio_common.c"
+
+GRUB_MOD_INIT (cpio)
+{
+ grub_fs_register (&grub_cpio_fs);
+}
+
+GRUB_MOD_FINI (cpio)
+{
+ grub_fs_unregister (&grub_cpio_fs);
+}
diff --git a/grub-core/fs/cpio_be.c b/grub-core/fs/cpio_be.c
new file mode 100644
index 0000000..8465488
--- /dev/null
+++ b/grub-core/fs/cpio_be.c
@@ -0,0 +1,61 @@
+/* cpio.c - cpio and tar filesystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009,2013 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+
+#define ALIGN_CPIO(x) (ALIGN_UP ((x), 2))
+#define MAGIC "\x71\xc7"
+
+struct head
+{
+ grub_uint16_t magic[1];
+ grub_uint16_t dev;
+ grub_uint16_t ino;
+ grub_uint16_t mode[1];
+ grub_uint16_t uid;
+ grub_uint16_t gid;
+ grub_uint16_t nlink;
+ grub_uint16_t rdev;
+ grub_uint16_t mtime[2];
+ grub_uint16_t namesize[1];
+ grub_uint16_t filesize[2];
+} GRUB_PACKED;
+
+static inline unsigned long long
+read_number (const grub_uint16_t *arr, grub_size_t size)
+{
+ long long ret = 0;
+ while (size--)
+ ret = (ret << 16) | grub_be_to_cpu16 (*arr++);
+ return ret;
+}
+
+#define FSNAME "cpiofs_be"
+
+#include "cpio_common.c"
+
+GRUB_MOD_INIT (cpio_be)
+{
+ grub_fs_register (&grub_cpio_fs);
+}
+
+GRUB_MOD_FINI (cpio_be)
+{
+ grub_fs_unregister (&grub_cpio_fs);
+}
diff --git a/grub-core/fs/cpio_common.c b/grub-core/fs/cpio_common.c
new file mode 100644
index 0000000..4e885d6
--- /dev/null
+++ b/grub-core/fs/cpio_common.c
@@ -0,0 +1,253 @@
+/* cpio.c - cpio and tar filesystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009,2013 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+#include <grub/archelp.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_archelp_data
+{
+ grub_disk_t disk;
+ grub_off_t hofs;
+ grub_off_t next_hofs;
+ grub_off_t dofs;
+ grub_off_t size;
+};
+
+#if __GNUC__ >= 9
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
+static grub_err_t
+grub_cpio_find_file (struct grub_archelp_data *data, char **name,
+ grub_int32_t *mtime, grub_uint32_t *mode)
+{
+ struct head hd;
+ grub_size_t namesize;
+ grub_uint32_t modeval;
+
+ data->hofs = data->next_hofs;
+
+ if (grub_disk_read (data->disk, 0, data->hofs, sizeof (hd), &hd))
+ return grub_errno;
+
+ if (grub_memcmp (hd.magic, MAGIC, sizeof (hd.magic)) != 0
+#ifdef MAGIC2
+ && grub_memcmp (hd.magic, MAGIC2, sizeof (hd.magic)) != 0
+#endif
+ )
+ return grub_error (GRUB_ERR_BAD_FS, "invalid cpio archive");
+ data->size = read_number (hd.filesize, ARRAY_SIZE (hd.filesize));
+ if (mtime)
+ *mtime = read_number (hd.mtime, ARRAY_SIZE (hd.mtime));
+ modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
+ namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize));
+
+ /* 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)
+ return grub_errno;
+
+ if (grub_disk_read (data->disk, 0, data->hofs + sizeof (hd),
+ namesize, *name))
+ {
+ grub_free (*name);
+ return grub_errno;
+ }
+ (*name)[namesize] = 0;
+
+ if (data->size == 0 && modeval == 0 && namesize == 11
+ && grub_memcmp(*name, "TRAILER!!!", 11) == 0)
+ {
+ *mode = GRUB_ARCHELP_ATTR_END;
+ grub_free (*name);
+ return GRUB_ERR_NONE;
+ }
+
+ data->dofs = data->hofs + ALIGN_CPIO (sizeof (hd) + namesize);
+ data->next_hofs = data->dofs + ALIGN_CPIO (data->size);
+ return GRUB_ERR_NONE;
+}
+
+#if __GNUC__ >= 9
+#pragma GCC diagnostic pop
+#endif
+
+static char *
+grub_cpio_get_link_target (struct grub_archelp_data *data)
+{
+ char *ret;
+ grub_err_t err;
+
+ if (data->size == 0)
+ return grub_strdup ("");
+ ret = grub_malloc (data->size + 1);
+ if (!ret)
+ return NULL;
+
+ err = grub_disk_read (data->disk, 0, data->dofs, data->size,
+ ret);
+ if (err)
+ {
+ grub_free (ret);
+ return NULL;
+ }
+ ret[data->size] = '\0';
+ return ret;
+}
+
+static void
+grub_cpio_rewind (struct grub_archelp_data *data)
+{
+ data->next_hofs = 0;
+}
+
+static struct grub_archelp_ops arcops =
+ {
+ .find_file = grub_cpio_find_file,
+ .get_link_target = grub_cpio_get_link_target,
+ .rewind = grub_cpio_rewind
+ };
+
+static struct grub_archelp_data *
+grub_cpio_mount (grub_disk_t disk)
+{
+ struct head hd;
+ struct grub_archelp_data *data;
+
+ if (grub_disk_read (disk, 0, 0, sizeof (hd), &hd))
+ goto fail;
+
+ if (grub_memcmp (hd.magic, MAGIC, sizeof (MAGIC) - 1)
+#ifdef MAGIC2
+ && grub_memcmp (hd.magic, MAGIC2, sizeof (MAGIC2) - 1)
+#endif
+ )
+ goto fail;
+
+ data = (struct grub_archelp_data *) grub_zalloc (sizeof (*data));
+ if (!data)
+ goto fail;
+
+ data->disk = disk;
+
+ return data;
+
+fail:
+ grub_error (GRUB_ERR_BAD_FS, "not a " FSNAME " filesystem");
+ return 0;
+}
+
+static grub_err_t
+grub_cpio_dir (grub_device_t device, const char *path_in,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_archelp_data *data;
+ grub_err_t err;
+
+ data = grub_cpio_mount (device->disk);
+ if (!data)
+ return grub_errno;
+
+ err = grub_archelp_dir (data, &arcops,
+ path_in, hook, hook_data);
+
+ grub_free (data);
+
+ return err;
+}
+
+static grub_err_t
+grub_cpio_open (grub_file_t file, const char *name_in)
+{
+ struct grub_archelp_data *data;
+ grub_err_t err;
+
+ data = grub_cpio_mount (file->device->disk);
+ if (!data)
+ return grub_errno;
+
+ err = grub_archelp_open (data, &arcops, name_in);
+ if (err)
+ {
+ grub_free (data);
+ }
+ else
+ {
+ file->data = data;
+ file->size = data->size;
+ }
+ return err;
+}
+
+static grub_ssize_t
+grub_cpio_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_archelp_data *data;
+ grub_ssize_t ret;
+
+ data = file->data;
+ data->disk->read_hook = file->read_hook;
+ data->disk->read_hook_data = file->read_hook_data;
+
+ ret = (grub_disk_read (data->disk, 0, data->dofs + file->offset,
+ len, buf)) ? -1 : (grub_ssize_t) len;
+ data->disk->read_hook = 0;
+
+ return ret;
+}
+
+static grub_err_t
+grub_cpio_close (grub_file_t file)
+{
+ struct grub_archelp_data *data;
+
+ data = file->data;
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static struct grub_fs grub_cpio_fs = {
+ .name = FSNAME,
+ .fs_dir = grub_cpio_dir,
+ .fs_open = grub_cpio_open,
+ .fs_read = grub_cpio_read,
+ .fs_close = grub_cpio_close,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 0,
+ .blocklist_install = 0,
+#endif
+};
diff --git a/grub-core/fs/exfat.c b/grub-core/fs/exfat.c
new file mode 100644
index 0000000..fe149dd
--- /dev/null
+++ b/grub-core/fs/exfat.c
@@ -0,0 +1,2 @@
+#define MODE_EXFAT 1
+#include "fat.c"
diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c
new file mode 100644
index 0000000..e7dd78e
--- /dev/null
+++ b/grub-core/fs/ext2.c
@@ -0,0 +1,1107 @@
+/* ext2.c - Second Extended filesystem */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Magic value used to identify an ext2 filesystem. */
+#define EXT2_MAGIC 0xEF53
+/* Amount of indirect blocks in an inode. */
+#define INDIRECT_BLOCKS 12
+
+/* The good old revision and the default inode size. */
+#define EXT2_GOOD_OLD_REVISION 0
+#define EXT2_GOOD_OLD_INODE_SIZE 128
+
+/* Filetype used in directory entry. */
+#define FILETYPE_UNKNOWN 0
+#define FILETYPE_REG 1
+#define FILETYPE_DIRECTORY 2
+#define FILETYPE_SYMLINK 7
+
+/* Filetype information as used in inodes. */
+#define FILETYPE_INO_MASK 0170000
+#define FILETYPE_INO_REG 0100000
+#define FILETYPE_INO_DIRECTORY 0040000
+#define FILETYPE_INO_SYMLINK 0120000
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Log2 size of ext2 block in 512 blocks. */
+#define LOG2_EXT2_BLOCK_SIZE(data) \
+ (grub_le_to_cpu32 (data->sblock.log2_block_size) + 1)
+
+/* Log2 size of ext2 block in bytes. */
+#define LOG2_BLOCK_SIZE(data) \
+ (grub_le_to_cpu32 (data->sblock.log2_block_size) + 10)
+
+/* The size of an ext2 block in bytes. */
+#define EXT2_BLOCK_SIZE(data) (1U << LOG2_BLOCK_SIZE (data))
+
+/* The revision level. */
+#define EXT2_REVISION(data) grub_le_to_cpu32 (data->sblock.revision_level)
+
+/* The inode size. */
+#define EXT2_INODE_SIZE(data) \
+ (data->sblock.revision_level \
+ == grub_cpu_to_le32_compile_time (EXT2_GOOD_OLD_REVISION) \
+ ? EXT2_GOOD_OLD_INODE_SIZE \
+ : grub_le_to_cpu16 (data->sblock.inode_size))
+
+/* Superblock filesystem feature flags (RW compatible)
+ * A filesystem with any of these enabled can be read and written by a driver
+ * that does not understand them without causing metadata/data corruption. */
+#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
+#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
+#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
+#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
+#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
+#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
+/* Superblock filesystem feature flags (RO compatible)
+ * A filesystem with any of these enabled can be safely read by a driver that
+ * does not understand them, but should not be written to, usually because
+ * additional metadata is required. */
+#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
+#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
+#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
+#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
+#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
+#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
+/* Superblock filesystem feature flags (back-incompatible)
+ * A filesystem with any of these enabled should not be attempted to be read
+ * by a driver that does not understand them, since they usually indicate
+ * metadata format changes that might confuse the reader. */
+#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
+#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
+#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
+#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Volume is journal device */
+#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_ENCRYPT 0x10000
+
+/* The set of back-incompatible features this driver DOES support. Add (OR)
+ * flags here as the related features are implemented into the driver. */
+#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_ENCRYPT)
+/* List of rationales for the ignored "incompatible" features:
+ * needs_recovery: Not really back-incompatible - was added as such to forbid
+ * ext2 drivers from mounting an ext3 volume with a dirty
+ * 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.
+ * 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
+
+#define EXT3_JOURNAL_DESCRIPTOR_BLOCK 1
+#define EXT3_JOURNAL_COMMIT_BLOCK 2
+#define EXT3_JOURNAL_SUPERBLOCK_V1 3
+#define EXT3_JOURNAL_SUPERBLOCK_V2 4
+#define EXT3_JOURNAL_REVOKE_BLOCK 5
+
+#define EXT3_JOURNAL_FLAG_ESCAPE 1
+#define EXT3_JOURNAL_FLAG_SAME_UUID 2
+#define EXT3_JOURNAL_FLAG_DELETED 4
+#define EXT3_JOURNAL_FLAG_LAST_TAG 8
+
+#define EXT4_ENCRYPT_FLAG 0x800
+#define EXT4_EXTENTS_FLAG 0x80000
+
+/* The ext2 superblock. */
+struct grub_ext2_sblock
+{
+ grub_uint32_t total_inodes;
+ grub_uint32_t total_blocks;
+ grub_uint32_t reserved_blocks;
+ grub_uint32_t free_blocks;
+ grub_uint32_t free_inodes;
+ grub_uint32_t first_data_block;
+ grub_uint32_t log2_block_size;
+ grub_uint32_t log2_fragment_size;
+ grub_uint32_t blocks_per_group;
+ grub_uint32_t fragments_per_group;
+ grub_uint32_t inodes_per_group;
+ grub_uint32_t mtime;
+ grub_uint32_t utime;
+ grub_uint16_t mnt_count;
+ grub_uint16_t max_mnt_count;
+ grub_uint16_t magic;
+ grub_uint16_t fs_state;
+ grub_uint16_t error_handling;
+ grub_uint16_t minor_revision_level;
+ grub_uint32_t lastcheck;
+ grub_uint32_t checkinterval;
+ grub_uint32_t creator_os;
+ grub_uint32_t revision_level;
+ grub_uint16_t uid_reserved;
+ grub_uint16_t gid_reserved;
+ grub_uint32_t first_inode;
+ grub_uint16_t inode_size;
+ grub_uint16_t block_group_number;
+ grub_uint32_t feature_compatibility;
+ grub_uint32_t feature_incompat;
+ grub_uint32_t feature_ro_compat;
+ grub_uint16_t uuid[8];
+ char volume_name[16];
+ char last_mounted_on[64];
+ grub_uint32_t compression_info;
+ grub_uint8_t prealloc_blocks;
+ grub_uint8_t prealloc_dir_blocks;
+ grub_uint16_t reserved_gdt_blocks;
+ grub_uint8_t journal_uuid[16];
+ grub_uint32_t journal_inum;
+ grub_uint32_t journal_dev;
+ grub_uint32_t last_orphan;
+ grub_uint32_t hash_seed[4];
+ grub_uint8_t def_hash_version;
+ grub_uint8_t jnl_backup_type;
+ grub_uint16_t group_desc_size;
+ grub_uint32_t default_mount_opts;
+ grub_uint32_t first_meta_bg;
+ grub_uint32_t mkfs_time;
+ grub_uint32_t jnl_blocks[17];
+};
+
+/* The ext2 blockgroup. */
+struct grub_ext2_block_group
+{
+ grub_uint32_t block_id;
+ grub_uint32_t inode_id;
+ grub_uint32_t inode_table_id;
+ grub_uint16_t free_blocks;
+ grub_uint16_t free_inodes;
+ grub_uint16_t used_dirs;
+ grub_uint16_t pad;
+ grub_uint32_t reserved[3];
+ grub_uint32_t block_id_hi;
+ grub_uint32_t inode_id_hi;
+ grub_uint32_t inode_table_id_hi;
+ grub_uint16_t free_blocks_hi;
+ grub_uint16_t free_inodes_hi;
+ grub_uint16_t used_dirs_hi;
+ grub_uint16_t pad2;
+ grub_uint32_t reserved2[3];
+};
+
+/* The ext2 inode. */
+struct grub_ext2_inode
+{
+ grub_uint16_t mode;
+ grub_uint16_t uid;
+ grub_uint32_t size;
+ grub_uint32_t atime;
+ grub_uint32_t ctime;
+ grub_uint32_t mtime;
+ grub_uint32_t dtime;
+ grub_uint16_t gid;
+ grub_uint16_t nlinks;
+ grub_uint32_t blockcnt; /* Blocks of 512 bytes!! */
+ grub_uint32_t flags;
+ grub_uint32_t osd1;
+ union
+ {
+ struct datablocks
+ {
+ grub_uint32_t dir_blocks[INDIRECT_BLOCKS];
+ grub_uint32_t indir_block;
+ grub_uint32_t double_indir_block;
+ grub_uint32_t triple_indir_block;
+ } blocks;
+ char symlink[60];
+ };
+ grub_uint32_t version;
+ grub_uint32_t acl;
+ grub_uint32_t size_high;
+ grub_uint32_t fragment_addr;
+ grub_uint32_t osd2[3];
+};
+
+/* The header of an ext2 directory entry. */
+struct ext2_dirent
+{
+ grub_uint32_t inode;
+ grub_uint16_t direntlen;
+#define MAX_NAMELEN 255
+ grub_uint8_t namelen;
+ grub_uint8_t filetype;
+};
+
+struct grub_ext3_journal_header
+{
+ grub_uint32_t magic;
+ grub_uint32_t block_type;
+ grub_uint32_t sequence;
+};
+
+struct grub_ext3_journal_revoke_header
+{
+ struct grub_ext3_journal_header header;
+ grub_uint32_t count;
+ grub_uint32_t data[0];
+};
+
+struct grub_ext3_journal_block_tag
+{
+ grub_uint32_t block;
+ grub_uint32_t flags;
+};
+
+struct grub_ext3_journal_sblock
+{
+ struct grub_ext3_journal_header header;
+ grub_uint32_t block_size;
+ grub_uint32_t maxlen;
+ grub_uint32_t first;
+ grub_uint32_t sequence;
+ grub_uint32_t start;
+};
+
+#define EXT4_EXT_MAGIC 0xf30a
+
+struct grub_ext4_extent_header
+{
+ grub_uint16_t magic;
+ grub_uint16_t entries;
+ grub_uint16_t max;
+ grub_uint16_t depth;
+ grub_uint32_t generation;
+};
+
+struct grub_ext4_extent
+{
+ grub_uint32_t block;
+ grub_uint16_t len;
+ grub_uint16_t start_hi;
+ grub_uint32_t start;
+};
+
+struct grub_ext4_extent_idx
+{
+ grub_uint32_t block;
+ grub_uint32_t leaf;
+ grub_uint16_t leaf_hi;
+ grub_uint16_t unused;
+};
+
+struct grub_fshelp_node
+{
+ struct grub_ext2_data *data;
+ struct grub_ext2_inode inode;
+ int ino;
+ int inode_read;
+};
+
+/* Information about a "mounted" ext2 filesystem. */
+struct grub_ext2_data
+{
+ struct grub_ext2_sblock sblock;
+ int log_group_desc_size;
+ grub_disk_t disk;
+ struct grub_ext2_inode *inode;
+ struct grub_fshelp_node diropen;
+};
+
+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));
+}
+
+/* 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, 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)
+ + block)
+ << LOG2_EXT2_BLOCK_SIZE (data)), offset,
+ sizeof (struct grub_ext2_block_group), blkgrp);
+}
+
+static struct grub_ext4_extent_header *
+grub_ext4_find_leaf (struct grub_ext2_data *data,
+ struct grub_ext4_extent_header *ext_block,
+ grub_uint32_t fileblock)
+{
+ struct grub_ext4_extent_idx *index;
+ void *buf = NULL;
+
+ while (1)
+ {
+ int i;
+ grub_disk_addr_t block;
+
+ index = (struct grub_ext4_extent_idx *) (ext_block + 1);
+
+ if (ext_block->magic != grub_cpu_to_le16_compile_time (EXT4_EXT_MAGIC))
+ goto fail;
+
+ if (ext_block->depth == 0)
+ return ext_block;
+
+ for (i = 0; i < grub_le_to_cpu16 (ext_block->entries); i++)
+ {
+ if (fileblock < grub_le_to_cpu32(index[i].block))
+ break;
+ }
+
+ if (--i < 0)
+ goto fail;
+
+ block = grub_le_to_cpu16 (index[i].leaf_hi);
+ block = (block << 32) | grub_le_to_cpu32 (index[i].leaf);
+ if (!buf)
+ buf = grub_malloc (EXT2_BLOCK_SIZE(data));
+ if (!buf)
+ goto fail;
+ if (grub_disk_read (data->disk,
+ block << LOG2_EXT2_BLOCK_SIZE (data),
+ 0, EXT2_BLOCK_SIZE(data), buf))
+ goto fail;
+
+ ext_block = buf;
+ }
+ fail:
+ grub_free (buf);
+ return 0;
+}
+
+static grub_disk_addr_t
+grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
+{
+ struct grub_ext2_data *data = node->data;
+ struct grub_ext2_inode *inode = &node->inode;
+ unsigned int blksz = EXT2_BLOCK_SIZE (data);
+ grub_disk_addr_t blksz_quarter = blksz / 4;
+ int log2_blksz = LOG2_EXT2_BLOCK_SIZE (data);
+ int log_perblock = log2_blksz + 9 - 2;
+ grub_uint32_t indir;
+ int shift;
+
+ if (inode->flags & grub_cpu_to_le32_compile_time (EXT4_EXTENTS_FLAG))
+ {
+ struct grub_ext4_extent_header *leaf;
+ struct grub_ext4_extent *ext;
+ int i;
+ grub_disk_addr_t ret;
+
+ leaf = grub_ext4_find_leaf (data, (struct grub_ext4_extent_header *) inode->blocks.dir_blocks, fileblock);
+ if (! leaf)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid extent");
+ return -1;
+ }
+
+ ext = (struct grub_ext4_extent *) (leaf + 1);
+ for (i = 0; i < grub_le_to_cpu16 (leaf->entries); i++)
+ {
+ if (fileblock < grub_le_to_cpu32 (ext[i].block))
+ break;
+ }
+
+ if (--i >= 0)
+ {
+ fileblock -= grub_le_to_cpu32 (ext[i].block);
+ if (fileblock >= grub_le_to_cpu16 (ext[i].len))
+ ret = 0;
+ else
+ {
+ grub_disk_addr_t start;
+
+ start = grub_le_to_cpu16 (ext[i].start_hi);
+ start = (start << 32) + grub_le_to_cpu32 (ext[i].start);
+
+ ret = fileblock + start;
+ }
+ }
+ else
+ {
+ grub_error (GRUB_ERR_BAD_FS, "something wrong with extent");
+ ret = -1;
+ }
+
+ if (leaf != (struct grub_ext4_extent_header *) inode->blocks.dir_blocks)
+ grub_free (leaf);
+
+ return ret;
+ }
+
+ /* Direct blocks. */
+ if (fileblock < INDIRECT_BLOCKS)
+ return grub_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]);
+ fileblock -= INDIRECT_BLOCKS;
+ /* Indirect. */
+ if (fileblock < blksz_quarter)
+ {
+ indir = inode->blocks.indir_block;
+ shift = 0;
+ goto indirect;
+ }
+ fileblock -= blksz_quarter;
+ /* Double indirect. */
+ if (fileblock < blksz_quarter * blksz_quarter)
+ {
+ indir = inode->blocks.double_indir_block;
+ shift = 1;
+ goto indirect;
+ }
+ fileblock -= blksz_quarter * blksz_quarter;
+ /* Triple indirect. */
+ if (fileblock < blksz_quarter * blksz_quarter * (blksz_quarter + 1))
+ {
+ indir = inode->blocks.triple_indir_block;
+ shift = 2;
+ goto indirect;
+ }
+ 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,
+ ((fileblock >> (log_perblock * shift))
+ & ((1 << log_perblock) - 1))
+ * sizeof (indir),
+ sizeof (indir), &indir))
+ return -1;
+ } while (shift--);
+
+ return grub_le_to_cpu32 (indir);
+}
+
+/* Read LEN bytes from the file described by DATA starting with byte
+ POS. Return the amount of read bytes in READ. */
+static grub_ssize_t
+grub_ext2_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)
+{
+ return grub_fshelp_read_file (node->data->disk, node,
+ read_hook, read_hook_data,
+ pos, len, buf, grub_ext2_read_block,
+ grub_cpu_to_le32 (node->inode.size)
+ | (((grub_off_t) grub_cpu_to_le32 (node->inode.size_high)) << 32),
+ LOG2_EXT2_BLOCK_SIZE (node->data), 0);
+
+}
+
+
+/* Read the inode INO for the file described by DATA into INODE. */
+static grub_err_t
+grub_ext2_read_inode (struct grub_ext2_data *data,
+ int ino, struct grub_ext2_inode *inode)
+{
+ struct grub_ext2_block_group blkgrp;
+ struct grub_ext2_sblock *sblock = &data->sblock;
+ int inodes_per_block;
+ unsigned int blkno;
+ unsigned int blkoff;
+ grub_disk_addr_t base;
+
+ /* It is easier to calculate if the first inode is 0. */
+ ino--;
+
+ grub_ext2_blockgroup (data,
+ ino / grub_le_to_cpu32 (sblock->inodes_per_group),
+ &blkgrp);
+ if (grub_errno)
+ return grub_errno;
+
+ inodes_per_block = EXT2_BLOCK_SIZE (data) / EXT2_INODE_SIZE (data);
+ blkno = (ino % grub_le_to_cpu32 (sblock->inodes_per_group))
+ / inodes_per_block;
+ blkoff = (ino % grub_le_to_cpu32 (sblock->inodes_per_group))
+ % inodes_per_block;
+
+ base = grub_le_to_cpu32 (blkgrp.inode_table_id);
+ if (data->log_group_desc_size >= 6)
+ base |= (((grub_disk_addr_t) grub_le_to_cpu32 (blkgrp.inode_table_id_hi))
+ << 32);
+
+ /* Read the inode. */
+ if (grub_disk_read (data->disk,
+ ((base + blkno) << LOG2_EXT2_BLOCK_SIZE (data)),
+ EXT2_INODE_SIZE (data) * blkoff,
+ sizeof (struct grub_ext2_inode), inode))
+ return grub_errno;
+
+ return 0;
+}
+
+static struct grub_ext2_data *
+grub_ext2_mount (grub_disk_t disk)
+{
+ struct grub_ext2_data *data;
+
+ data = grub_malloc (sizeof (struct grub_ext2_data));
+ if (!data)
+ return 0;
+
+ /* Read the superblock. */
+ grub_disk_read (disk, 1 * 2, 0, sizeof (struct grub_ext2_sblock),
+ &data->sblock);
+ if (grub_errno)
+ goto fail;
+
+ /* 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
+ || 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;
+ }
+
+ /* Check the FS doesn't have feature bits enabled that we don't support. */
+ if (data->sblock.revision_level != grub_cpu_to_le32_compile_time (EXT2_GOOD_OLD_REVISION)
+ && (data->sblock.feature_incompat
+ & grub_cpu_to_le32_compile_time (~(EXT2_DRIVER_SUPPORTED_INCOMPAT
+ | EXT2_DRIVER_IGNORED_INCOMPAT))))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "filesystem has unsupported incompatible features");
+ goto fail;
+ }
+
+ if (data->sblock.revision_level != grub_cpu_to_le32_compile_time (EXT2_GOOD_OLD_REVISION)
+ && (data->sblock.feature_incompat
+ & grub_cpu_to_le32_compile_time (EXT4_FEATURE_INCOMPAT_64BIT))
+ && data->sblock.group_desc_size != 0
+ && ((data->sblock.group_desc_size & (data->sblock.group_desc_size - 1))
+ == 0)
+ && (data->sblock.group_desc_size & grub_cpu_to_le16_compile_time (0x1fe0)))
+ {
+ grub_uint16_t b = grub_le_to_cpu16 (data->sblock.group_desc_size);
+ for (data->log_group_desc_size = 0; b != (1 << data->log_group_desc_size);
+ data->log_group_desc_size++);
+ }
+ else
+ data->log_group_desc_size = 5;
+
+ data->disk = disk;
+
+ data->diropen.data = data;
+ data->diropen.ino = 2;
+ data->diropen.inode_read = 1;
+
+ data->inode = &data->diropen.inode;
+
+ grub_ext2_read_inode (data, 2, data->inode);
+ if (grub_errno)
+ goto fail;
+
+ return data;
+
+ fail:
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not an ext2 filesystem");
+
+ grub_free (data);
+ return 0;
+}
+
+static char *
+grub_ext2_read_symlink (grub_fshelp_node_t node)
+{
+ char *symlink;
+ struct grub_fshelp_node *diro = node;
+ grub_size_t sz;
+
+ if (! diro->inode_read)
+ {
+ grub_ext2_read_inode (diro->data, diro->ino, &diro->inode);
+ if (grub_errno)
+ return 0;
+
+ if (diro->inode.flags & grub_cpu_to_le32_compile_time (EXT4_ENCRYPT_FLAG))
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "symlink is encrypted");
+ return 0;
+ }
+ }
+
+ if (grub_add (grub_le_to_cpu32 (diro->inode.size), 1, &sz))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+ return NULL;
+ }
+
+ symlink = grub_malloc (sz);
+ if (! symlink)
+ return 0;
+
+ /*
+ * If the filesize of the symlink is equal to or bigger than 60 the symlink
+ * is stored in a separate block, otherwise it is stored in the inode.
+ */
+ if (grub_le_to_cpu32 (diro->inode.size) < sizeof (diro->inode.symlink))
+ grub_memcpy (symlink,
+ diro->inode.symlink,
+ grub_le_to_cpu32 (diro->inode.size));
+ else
+ {
+ grub_ext2_read_file (diro, 0, 0, 0,
+ grub_le_to_cpu32 (diro->inode.size),
+ symlink);
+ if (grub_errno)
+ {
+ grub_free (symlink);
+ return 0;
+ }
+ }
+
+ symlink[grub_le_to_cpu32 (diro->inode.size)] = '\0';
+ return symlink;
+}
+
+static int
+grub_ext2_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ unsigned int fpos = 0;
+ struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
+
+ if (! diro->inode_read)
+ {
+ grub_ext2_read_inode (diro->data, diro->ino, &diro->inode);
+ if (grub_errno)
+ return 0;
+ }
+
+ if (diro->inode.flags & grub_cpu_to_le32_compile_time (EXT4_ENCRYPT_FLAG))
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "directory is encrypted");
+ return 0;
+ }
+
+ /* Search the file. */
+ while (fpos < grub_le_to_cpu32 (diro->inode.size))
+ {
+ struct ext2_dirent dirent;
+
+ grub_ext2_read_file (diro, 0, 0, fpos, sizeof (struct ext2_dirent),
+ (char *) &dirent);
+ if (grub_errno)
+ return 0;
+
+ if (dirent.direntlen == 0)
+ return 0;
+
+ if (dirent.inode != 0 && dirent.namelen != 0)
+ {
+ char filename[MAX_NAMELEN + 1];
+ struct grub_fshelp_node *fdiro;
+ enum grub_fshelp_filetype type = GRUB_FSHELP_UNKNOWN;
+
+ grub_ext2_read_file (diro, 0, 0, fpos + sizeof (struct ext2_dirent),
+ dirent.namelen, filename);
+ if (grub_errno)
+ return 0;
+
+ fdiro = grub_malloc (sizeof (struct grub_fshelp_node));
+ if (! fdiro)
+ return 0;
+
+ fdiro->data = diro->data;
+ fdiro->ino = grub_le_to_cpu32 (dirent.inode);
+
+ filename[dirent.namelen] = '\0';
+
+ if (dirent.filetype != FILETYPE_UNKNOWN)
+ {
+ fdiro->inode_read = 0;
+
+ if (dirent.filetype == FILETYPE_DIRECTORY)
+ type = GRUB_FSHELP_DIR;
+ else if (dirent.filetype == FILETYPE_SYMLINK)
+ type = GRUB_FSHELP_SYMLINK;
+ else if (dirent.filetype == FILETYPE_REG)
+ type = GRUB_FSHELP_REG;
+ }
+ else
+ {
+ /* The filetype can not be read from the dirent, read
+ the inode to get more information. */
+ grub_ext2_read_inode (diro->data,
+ grub_le_to_cpu32 (dirent.inode),
+ &fdiro->inode);
+ if (grub_errno)
+ {
+ grub_free (fdiro);
+ return 0;
+ }
+
+ fdiro->inode_read = 1;
+
+ if ((grub_le_to_cpu16 (fdiro->inode.mode)
+ & FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY)
+ type = GRUB_FSHELP_DIR;
+ else if ((grub_le_to_cpu16 (fdiro->inode.mode)
+ & FILETYPE_INO_MASK) == FILETYPE_INO_SYMLINK)
+ type = GRUB_FSHELP_SYMLINK;
+ else if ((grub_le_to_cpu16 (fdiro->inode.mode)
+ & FILETYPE_INO_MASK) == FILETYPE_INO_REG)
+ type = GRUB_FSHELP_REG;
+ }
+
+ if (hook (filename, type, fdiro, hook_data))
+ return 1;
+ }
+
+ fpos += grub_le_to_cpu16 (dirent.direntlen);
+ }
+
+ return 0;
+}
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_ext2_open (struct grub_file *file, const char *name)
+{
+ struct grub_ext2_data *data;
+ struct grub_fshelp_node *fdiro = 0;
+ grub_err_t err;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_ext2_mount (file->device->disk);
+ if (! data)
+ {
+ err = grub_errno;
+ goto fail;
+ }
+
+ err = grub_fshelp_find_file (name, &data->diropen, &fdiro,
+ grub_ext2_iterate_dir,
+ grub_ext2_read_symlink, GRUB_FSHELP_REG);
+ if (err)
+ goto fail;
+
+ if (! fdiro->inode_read)
+ {
+ err = grub_ext2_read_inode (data, fdiro->ino, &fdiro->inode);
+ if (err)
+ goto fail;
+ }
+
+ if (fdiro->inode.flags & grub_cpu_to_le32_compile_time (EXT4_ENCRYPT_FLAG))
+ {
+ err = grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "file is encrypted");
+ goto fail;
+ }
+
+ grub_memcpy (data->inode, &fdiro->inode, sizeof (struct grub_ext2_inode));
+ grub_free (fdiro);
+
+ file->size = grub_le_to_cpu32 (data->inode->size);
+ file->size |= ((grub_off_t) grub_le_to_cpu32 (data->inode->size_high)) << 32;
+ file->data = data;
+ file->offset = 0;
+
+ return 0;
+
+ fail:
+ if (fdiro != &data->diropen)
+ grub_free (fdiro);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return err;
+}
+
+static grub_err_t
+grub_ext2_close (grub_file_t file)
+{
+ grub_free (file->data);
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Read LEN bytes data from FILE into BUF. */
+static grub_ssize_t
+grub_ext2_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_ext2_data *data = (struct grub_ext2_data *) file->data;
+
+ return grub_ext2_read_file (&data->diropen,
+ file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+
+/* Context for grub_ext2_dir. */
+struct grub_ext2_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+ struct grub_ext2_data *data;
+};
+
+/* Helper for grub_ext2_dir. */
+static int
+grub_ext2_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_ext2_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ if (! node->inode_read)
+ {
+ grub_ext2_read_inode (ctx->data, node->ino, &node->inode);
+ if (!grub_errno)
+ node->inode_read = 1;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ if (node->inode_read)
+ {
+ info.mtimeset = 1;
+ info.mtime = grub_le_to_cpu32 (node->inode.mtime);
+ }
+
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_ext2_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
+ void *hook_data)
+{
+ struct grub_ext2_dir_ctx ctx = {
+ .hook = hook,
+ .hook_data = hook_data
+ };
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ ctx.data = grub_ext2_mount (device->disk);
+ if (! ctx.data)
+ goto fail;
+
+ grub_fshelp_find_file (path, &ctx.data->diropen, &fdiro,
+ grub_ext2_iterate_dir, grub_ext2_read_symlink,
+ GRUB_FSHELP_DIR);
+ if (grub_errno)
+ goto fail;
+
+ grub_ext2_iterate_dir (fdiro, grub_ext2_dir_iter, &ctx);
+
+ fail:
+ if (fdiro != &ctx.data->diropen)
+ grub_free (fdiro);
+ grub_free (ctx.data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_ext2_label (grub_device_t device, char **label)
+{
+ struct grub_ext2_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_ext2_mount (disk);
+ if (data)
+ *label = grub_strndup (data->sblock.volume_name,
+ sizeof (data->sblock.volume_name));
+ else
+ *label = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_ext2_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_ext2_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_ext2_mount (disk);
+ if (data)
+ {
+ *uuid = grub_xasprintf ("%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
+ grub_be_to_cpu16 (data->sblock.uuid[0]),
+ grub_be_to_cpu16 (data->sblock.uuid[1]),
+ grub_be_to_cpu16 (data->sblock.uuid[2]),
+ grub_be_to_cpu16 (data->sblock.uuid[3]),
+ grub_be_to_cpu16 (data->sblock.uuid[4]),
+ grub_be_to_cpu16 (data->sblock.uuid[5]),
+ grub_be_to_cpu16 (data->sblock.uuid[6]),
+ grub_be_to_cpu16 (data->sblock.uuid[7]));
+ }
+ else
+ *uuid = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+/* Get mtime. */
+static grub_err_t
+grub_ext2_mtime (grub_device_t device, grub_int64_t *tm)
+{
+ struct grub_ext2_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_ext2_mount (disk);
+ if (!data)
+ *tm = 0;
+ else
+ *tm = grub_le_to_cpu32 (data->sblock.utime);
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+
+}
+
+
+
+static struct grub_fs grub_ext2_fs =
+ {
+ .name = "ext2",
+ .fs_dir = grub_ext2_dir,
+ .fs_open = grub_ext2_open,
+ .fs_read = grub_ext2_read,
+ .fs_close = grub_ext2_close,
+ .fs_label = grub_ext2_label,
+ .fs_uuid = grub_ext2_uuid,
+ .fs_mtime = grub_ext2_mtime,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(ext2)
+{
+ grub_fs_register (&grub_ext2_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(ext2)
+{
+ grub_fs_unregister (&grub_ext2_fs);
+}
diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c
new file mode 100644
index 0000000..8a9992c
--- /dev/null
+++ b/grub-core/fs/f2fs.c
@@ -0,0 +1,1328 @@
+/*
+ * f2fs.c - Flash-Friendly File System
+ *
+ * Written by Jaegeuk Kim <jaegeuk@kernel.org>
+ *
+ * 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/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/charset.h>
+#include <grub/fshelp.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* F2FS Magic Number. */
+#define F2FS_SUPER_MAGIC 0xf2f52010
+
+#define CHECKSUM_OFFSET 4092 /* Must be aligned 4 bytes. */
+#define U32_CHECKSUM_OFFSET (CHECKSUM_OFFSET >> 2)
+#define CRCPOLY_LE 0xedb88320
+
+/* Byte-size offset. */
+#define F2FS_SUPER_OFFSET ((grub_disk_addr_t)1024)
+#define F2FS_SUPER_OFFSET0 (F2FS_SUPER_OFFSET >> GRUB_DISK_SECTOR_BITS)
+#define F2FS_SUPER_OFFSET1 ((F2FS_SUPER_OFFSET + F2FS_BLKSIZE) >> \
+ GRUB_DISK_SECTOR_BITS)
+
+/* 9 bits for 512 bytes. */
+#define F2FS_MIN_LOG_SECTOR_SIZE 9
+
+/* Support only 4KB block. */
+#define F2FS_BLK_BITS 12
+#define F2FS_BLKSIZE (1 << F2FS_BLK_BITS)
+#define F2FS_BLK_SEC_BITS (F2FS_BLK_BITS - GRUB_DISK_SECTOR_BITS)
+
+#define VERSION_LEN 256
+#define F2FS_MAX_EXTENSION 64
+
+#define CP_COMPACT_SUM_FLAG 0x00000004
+#define CP_UMOUNT_FLAG 0x00000001
+
+#define MAX_ACTIVE_LOGS 16
+#define MAX_ACTIVE_NODE_LOGS 8
+#define MAX_ACTIVE_DATA_LOGS 8
+#define NR_CURSEG_DATA_TYPE 3
+#define NR_CURSEG_NODE_TYPE 3
+#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE)
+
+#define ENTRIES_IN_SUM 512
+#define SUMMARY_SIZE 7
+#define SUM_FOOTER_SIZE 5
+#define JENTRY_SIZE (sizeof(struct grub_f2fs_nat_jent))
+#define SUM_ENTRIES_SIZE (SUMMARY_SIZE * ENTRIES_IN_SUM)
+#define SUM_JOURNAL_SIZE (F2FS_BLKSIZE - SUM_FOOTER_SIZE - SUM_ENTRIES_SIZE)
+#define NAT_JOURNAL_ENTRIES ((SUM_JOURNAL_SIZE - 2) / JENTRY_SIZE)
+#define NAT_JOURNAL_RESERVED ((SUM_JOURNAL_SIZE - 2) % JENTRY_SIZE)
+
+#define NAT_ENTRY_SIZE (sizeof(struct grub_f2fs_nat_entry))
+#define NAT_ENTRY_PER_BLOCK (F2FS_BLKSIZE / NAT_ENTRY_SIZE)
+
+#define F2FS_NAME_LEN 255
+#define F2FS_SLOT_LEN 8
+#define NR_DENTRY_IN_BLOCK 214
+#define SIZE_OF_DIR_ENTRY 11 /* By byte. */
+#define BITS_PER_BYTE 8
+#define SIZE_OF_DENTRY_BITMAP ((NR_DENTRY_IN_BLOCK + BITS_PER_BYTE - 1) / \
+ BITS_PER_BYTE)
+#define SIZE_OF_RESERVED (F2FS_BLKSIZE - \
+ ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \
+ NR_DENTRY_IN_BLOCK + SIZE_OF_DENTRY_BITMAP))
+
+#define F2FS_INLINE_XATTR_ADDRS 50 /* 200 bytes for inline xattrs. */
+#define DEF_ADDRS_PER_INODE 923 /* Address Pointers in an Inode. */
+
+#define ADDRS_PER_BLOCK 1018 /* Address Pointers in a Direct Block. */
+#define NIDS_PER_BLOCK 1018 /* Node IDs in an Indirect Block. */
+#define NODE_DIR1_BLOCK (DEF_ADDRS_PER_INODE + 1)
+#define NODE_DIR2_BLOCK (DEF_ADDRS_PER_INODE + 2)
+#define NODE_IND1_BLOCK (DEF_ADDRS_PER_INODE + 3)
+#define NODE_IND2_BLOCK (DEF_ADDRS_PER_INODE + 4)
+#define NODE_DIND_BLOCK (DEF_ADDRS_PER_INODE + 5)
+
+#define MAX_INLINE_DATA (4 * (DEF_ADDRS_PER_INODE - \
+ F2FS_INLINE_XATTR_ADDRS - 1))
+#define NR_INLINE_DENTRY (MAX_INLINE_DATA * BITS_PER_BYTE / \
+ ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \
+ BITS_PER_BYTE + 1))
+#define INLINE_DENTRY_BITMAP_SIZE ((NR_INLINE_DENTRY + BITS_PER_BYTE - 1) / \
+ BITS_PER_BYTE)
+#define INLINE_RESERVED_SIZE (MAX_INLINE_DATA - \
+ ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \
+ NR_INLINE_DENTRY + \
+ INLINE_DENTRY_BITMAP_SIZE))
+#define CURSEG_HOT_DATA 0
+
+#define CKPT_FLAG_SET(ckpt, f) (ckpt)->ckpt_flags & \
+ grub_cpu_to_le32_compile_time (f)
+
+#define F2FS_INLINE_XATTR 0x01 /* File inline xattr flag. */
+#define F2FS_INLINE_DATA 0x02 /* File inline data flag. */
+#define F2FS_INLINE_DENTRY 0x04 /* File inline dentry flag. */
+#define F2FS_DATA_EXIST 0x08 /* File inline data exist flag. */
+#define F2FS_INLINE_DOTS 0x10 /* File having implicit dot dentries. */
+
+#define MAX_VOLUME_NAME 512
+
+enum FILE_TYPE
+{
+ F2FS_FT_UNKNOWN,
+ F2FS_FT_REG_FILE = 1,
+ F2FS_FT_DIR = 2,
+ F2FS_FT_SYMLINK = 7
+};
+
+struct grub_f2fs_superblock
+{
+ grub_uint32_t magic;
+ grub_uint16_t dummy1[2];
+ grub_uint32_t log_sectorsize;
+ grub_uint32_t log_sectors_per_block;
+ grub_uint32_t log_blocksize;
+ grub_uint32_t log_blocks_per_seg;
+ grub_uint32_t segs_per_sec;
+ grub_uint32_t secs_per_zone;
+ grub_uint32_t checksum_offset;
+ grub_uint8_t dummy2[40];
+ grub_uint32_t cp_blkaddr;
+ grub_uint32_t sit_blkaddr;
+ grub_uint32_t nat_blkaddr;
+ grub_uint32_t ssa_blkaddr;
+ grub_uint32_t main_blkaddr;
+ grub_uint32_t root_ino;
+ grub_uint32_t node_ino;
+ grub_uint32_t meta_ino;
+ grub_uint8_t uuid[16];
+ grub_uint16_t volume_name[MAX_VOLUME_NAME];
+ grub_uint32_t extension_count;
+ grub_uint8_t extension_list[F2FS_MAX_EXTENSION][8];
+ grub_uint32_t cp_payload;
+ grub_uint8_t version[VERSION_LEN];
+ grub_uint8_t init_version[VERSION_LEN];
+} GRUB_PACKED;
+
+struct grub_f2fs_checkpoint
+{
+ grub_uint64_t checkpoint_ver;
+ grub_uint64_t user_block_count;
+ grub_uint64_t valid_block_count;
+ grub_uint32_t rsvd_segment_count;
+ grub_uint32_t overprov_segment_count;
+ grub_uint32_t free_segment_count;
+ grub_uint32_t cur_node_segno[MAX_ACTIVE_NODE_LOGS];
+ grub_uint16_t cur_node_blkoff[MAX_ACTIVE_NODE_LOGS];
+ grub_uint32_t cur_data_segno[MAX_ACTIVE_DATA_LOGS];
+ grub_uint16_t cur_data_blkoff[MAX_ACTIVE_DATA_LOGS];
+ grub_uint32_t ckpt_flags;
+ grub_uint32_t cp_pack_total_block_count;
+ grub_uint32_t cp_pack_start_sum;
+ grub_uint32_t valid_node_count;
+ grub_uint32_t valid_inode_count;
+ grub_uint32_t next_free_nid;
+ grub_uint32_t sit_ver_bitmap_bytesize;
+ grub_uint32_t nat_ver_bitmap_bytesize;
+ grub_uint32_t checksum_offset;
+ grub_uint64_t elapsed_time;
+ grub_uint8_t alloc_type[MAX_ACTIVE_LOGS];
+ grub_uint8_t sit_nat_version_bitmap[3900];
+ grub_uint32_t checksum;
+} GRUB_PACKED;
+
+struct grub_f2fs_nat_entry {
+ grub_uint8_t version;
+ grub_uint32_t ino;
+ grub_uint32_t block_addr;
+} GRUB_PACKED;
+
+struct grub_f2fs_nat_jent
+{
+ grub_uint32_t nid;
+ struct grub_f2fs_nat_entry ne;
+} GRUB_PACKED;
+
+struct grub_f2fs_nat_journal {
+ grub_uint16_t n_nats;
+ struct grub_f2fs_nat_jent entries[NAT_JOURNAL_ENTRIES];
+ grub_uint8_t reserved[NAT_JOURNAL_RESERVED];
+} GRUB_PACKED;
+
+struct grub_f2fs_nat_block {
+ struct grub_f2fs_nat_entry ne[NAT_ENTRY_PER_BLOCK];
+} GRUB_PACKED;
+
+struct grub_f2fs_dir_entry
+{
+ grub_uint32_t hash_code;
+ grub_uint32_t ino;
+ grub_uint16_t name_len;
+ grub_uint8_t file_type;
+} GRUB_PACKED;
+
+struct grub_f2fs_inline_dentry
+{
+ grub_uint8_t dentry_bitmap[INLINE_DENTRY_BITMAP_SIZE];
+ grub_uint8_t reserved[INLINE_RESERVED_SIZE];
+ struct grub_f2fs_dir_entry dentry[NR_INLINE_DENTRY];
+ grub_uint8_t filename[NR_INLINE_DENTRY][F2FS_SLOT_LEN];
+} GRUB_PACKED;
+
+struct grub_f2fs_dentry_block {
+ grub_uint8_t dentry_bitmap[SIZE_OF_DENTRY_BITMAP];
+ grub_uint8_t reserved[SIZE_OF_RESERVED];
+ struct grub_f2fs_dir_entry dentry[NR_DENTRY_IN_BLOCK];
+ grub_uint8_t filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN];
+} GRUB_PACKED;
+
+struct grub_f2fs_inode
+{
+ grub_uint16_t i_mode;
+ grub_uint8_t i_advise;
+ grub_uint8_t i_inline;
+ grub_uint32_t i_uid;
+ grub_uint32_t i_gid;
+ grub_uint32_t i_links;
+ grub_uint64_t i_size;
+ grub_uint64_t i_blocks;
+ grub_uint64_t i_atime;
+ grub_uint64_t i_ctime;
+ grub_uint64_t i_mtime;
+ grub_uint32_t i_atime_nsec;
+ grub_uint32_t i_ctime_nsec;
+ grub_uint32_t i_mtime_nsec;
+ grub_uint32_t i_generation;
+ grub_uint32_t i_current_depth;
+ grub_uint32_t i_xattr_nid;
+ grub_uint32_t i_flags;
+ grub_uint32_t i_pino;
+ grub_uint32_t i_namelen;
+ grub_uint8_t i_name[F2FS_NAME_LEN];
+ grub_uint8_t i_dir_level;
+ grub_uint8_t i_ext[12];
+ grub_uint32_t i_addr[DEF_ADDRS_PER_INODE];
+ grub_uint32_t i_nid[5];
+} GRUB_PACKED;
+
+struct grub_direct_node {
+ grub_uint32_t addr[ADDRS_PER_BLOCK];
+} GRUB_PACKED;
+
+struct grub_indirect_node {
+ grub_uint32_t nid[NIDS_PER_BLOCK];
+} GRUB_PACKED;
+
+struct grub_f2fs_node
+{
+ union
+ {
+ struct grub_f2fs_inode i;
+ struct grub_direct_node dn;
+ struct grub_indirect_node in;
+ /* Should occupy F2FS_BLKSIZE totally. */
+ char buf[F2FS_BLKSIZE - 40];
+ };
+ grub_uint8_t dummy[40];
+} GRUB_PACKED;
+
+struct grub_fshelp_node
+{
+ struct grub_f2fs_data *data;
+ struct grub_f2fs_node inode;
+ grub_uint32_t ino;
+ int inode_read;
+};
+
+struct grub_f2fs_data
+{
+ struct grub_f2fs_superblock sblock;
+ struct grub_f2fs_checkpoint ckpt;
+
+ grub_uint32_t root_ino;
+ grub_uint32_t blocks_per_seg;
+ grub_uint32_t cp_blkaddr;
+ grub_uint32_t nat_blkaddr;
+
+ struct grub_f2fs_nat_journal nat_j;
+ char *nat_bitmap;
+
+ grub_disk_t disk;
+ struct grub_f2fs_node *inode;
+ struct grub_fshelp_node diropen;
+};
+
+struct grub_f2fs_dir_iter_ctx
+{
+ struct grub_f2fs_data *data;
+ grub_fshelp_iterate_dir_hook_t hook;
+ void *hook_data;
+ grub_uint8_t *bitmap;
+ grub_uint8_t (*filename)[F2FS_SLOT_LEN];
+ struct grub_f2fs_dir_entry *dentry;
+ int max;
+};
+
+struct grub_f2fs_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+ struct grub_f2fs_data *data;
+};
+
+static grub_dl_t my_mod;
+
+static int
+grub_f2fs_test_bit_le (int nr, const grub_uint8_t *addr)
+{
+ return addr[nr >> 3] & (1 << (nr & 7));
+}
+
+static char *
+get_inline_addr (struct grub_f2fs_inode *inode)
+{
+ return (char *) &inode->i_addr[1];
+}
+
+static grub_uint64_t
+grub_f2fs_file_size (struct grub_f2fs_inode *inode)
+{
+ return grub_le_to_cpu64 (inode->i_size);
+}
+
+static grub_uint32_t
+start_cp_addr (struct grub_f2fs_data *data)
+{
+ struct grub_f2fs_checkpoint *ckpt = &data->ckpt;
+ grub_uint32_t start_addr = data->cp_blkaddr;
+
+ if (!(ckpt->checkpoint_ver & grub_cpu_to_le64_compile_time(1)))
+ return start_addr + data->blocks_per_seg;
+
+ return start_addr;
+}
+
+static grub_uint32_t
+start_sum_block (struct grub_f2fs_data *data)
+{
+ struct grub_f2fs_checkpoint *ckpt = &data->ckpt;
+
+ return start_cp_addr (data) + grub_le_to_cpu32 (ckpt->cp_pack_start_sum);
+}
+
+static grub_uint32_t
+sum_blk_addr (struct grub_f2fs_data *data, int base, int type)
+{
+ struct grub_f2fs_checkpoint *ckpt = &data->ckpt;
+
+ return start_cp_addr (data) +
+ grub_le_to_cpu32 (ckpt->cp_pack_total_block_count) -
+ (base + 1) + type;
+}
+
+static void *
+nat_bitmap_ptr (struct grub_f2fs_data *data)
+{
+ struct grub_f2fs_checkpoint *ckpt = &data->ckpt;
+ grub_uint32_t offset;
+
+ if (grub_le_to_cpu32 (data->sblock.cp_payload) > 0)
+ return ckpt->sit_nat_version_bitmap;
+
+ offset = grub_le_to_cpu32 (ckpt->sit_ver_bitmap_bytesize);
+
+ return ckpt->sit_nat_version_bitmap + offset;
+}
+
+static grub_uint32_t
+get_node_id (struct grub_f2fs_node *rn, int off, int inode_block)
+{
+ if (inode_block)
+ return grub_le_to_cpu32 (rn->i.i_nid[off - NODE_DIR1_BLOCK]);
+
+ return grub_le_to_cpu32 (rn->in.nid[off]);
+}
+
+static grub_err_t
+grub_f2fs_block_read (struct grub_f2fs_data *data, grub_uint32_t blkaddr,
+ void *buf)
+{
+ return grub_disk_read (data->disk,
+ ((grub_disk_addr_t)blkaddr) << F2FS_BLK_SEC_BITS,
+ 0, F2FS_BLKSIZE, buf);
+}
+
+/* CRC32 */
+static grub_uint32_t
+grub_f2fs_cal_crc32 (const void *buf, const grub_uint32_t len)
+{
+ grub_uint32_t crc = F2FS_SUPER_MAGIC;
+ unsigned char *p = (unsigned char *)buf;
+ grub_uint32_t tmp = len;
+ int i;
+
+ while (tmp--)
+ {
+ crc ^= *p++;
+ for (i = 0; i < 8; i++)
+ crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
+ }
+
+ return crc;
+}
+
+static int
+grub_f2fs_crc_valid (grub_uint32_t blk_crc, void *buf, const grub_uint32_t len)
+{
+ grub_uint32_t cal_crc = 0;
+
+ cal_crc = grub_f2fs_cal_crc32 (buf, len);
+
+ return (cal_crc == blk_crc) ? 1 : 0;
+}
+
+static int
+grub_f2fs_test_bit (grub_uint32_t nr, const char *p)
+{
+ int mask;
+
+ p += (nr >> 3);
+ mask = 1 << (7 - (nr & 0x07));
+
+ return mask & *p;
+}
+
+static int
+grub_f2fs_sanity_check_sb (struct grub_f2fs_superblock *sb)
+{
+ grub_uint32_t log_sectorsize, log_sectors_per_block;
+
+ if (sb->magic != grub_cpu_to_le32_compile_time (F2FS_SUPER_MAGIC))
+ return -1;
+
+ if (sb->log_blocksize != grub_cpu_to_le32_compile_time (F2FS_BLK_BITS))
+ return -1;
+
+ log_sectorsize = grub_le_to_cpu32 (sb->log_sectorsize);
+ log_sectors_per_block = grub_le_to_cpu32 (sb->log_sectors_per_block);
+
+ if (log_sectorsize > F2FS_BLK_BITS)
+ return -1;
+
+ if (log_sectorsize < F2FS_MIN_LOG_SECTOR_SIZE)
+ return -1;
+
+ if (log_sectors_per_block + log_sectorsize != F2FS_BLK_BITS)
+ return -1;
+
+ return 0;
+}
+
+static int
+grub_f2fs_read_sb (struct grub_f2fs_data *data, grub_disk_addr_t offset)
+{
+ grub_disk_t disk = data->disk;
+ grub_err_t err;
+
+ /* Read first super block. */
+ err = grub_disk_read (disk, offset, 0, sizeof (data->sblock), &data->sblock);
+ if (err)
+ return -1;
+
+ return grub_f2fs_sanity_check_sb (&data->sblock);
+}
+
+static void *
+validate_checkpoint (struct grub_f2fs_data *data, grub_uint32_t cp_addr,
+ grub_uint64_t *version)
+{
+ grub_uint32_t *cp_page_1, *cp_page_2;
+ struct grub_f2fs_checkpoint *cp_block;
+ grub_uint64_t cur_version = 0, pre_version = 0;
+ grub_uint32_t crc = 0;
+ grub_uint32_t crc_offset;
+ grub_err_t err;
+
+ /* Read the 1st cp block in this CP pack. */
+ cp_page_1 = grub_malloc (F2FS_BLKSIZE);
+ if (!cp_page_1)
+ return NULL;
+
+ err = grub_f2fs_block_read (data, cp_addr, cp_page_1);
+ if (err)
+ goto invalid_cp1;
+
+ cp_block = (struct grub_f2fs_checkpoint *)cp_page_1;
+ crc_offset = grub_le_to_cpu32 (cp_block->checksum_offset);
+ if (crc_offset != CHECKSUM_OFFSET)
+ goto invalid_cp1;
+
+ crc = grub_le_to_cpu32 (*(cp_page_1 + U32_CHECKSUM_OFFSET));
+ if (!grub_f2fs_crc_valid (crc, cp_block, crc_offset))
+ goto invalid_cp1;
+
+ pre_version = grub_le_to_cpu64 (cp_block->checkpoint_ver);
+
+ /* Read the 2nd cp block in this CP pack. */
+ cp_page_2 = grub_malloc (F2FS_BLKSIZE);
+ if (!cp_page_2)
+ goto invalid_cp1;
+
+ cp_addr += grub_le_to_cpu32 (cp_block->cp_pack_total_block_count) - 1;
+
+ err = grub_f2fs_block_read (data, cp_addr, cp_page_2);
+ if (err)
+ goto invalid_cp2;
+
+ cp_block = (struct grub_f2fs_checkpoint *)cp_page_2;
+ crc_offset = grub_le_to_cpu32 (cp_block->checksum_offset);
+ if (crc_offset != CHECKSUM_OFFSET)
+ goto invalid_cp2;
+
+ crc = grub_le_to_cpu32 (*(cp_page_2 + U32_CHECKSUM_OFFSET));
+ if (!grub_f2fs_crc_valid (crc, cp_block, crc_offset))
+ goto invalid_cp2;
+
+ cur_version = grub_le_to_cpu64 (cp_block->checkpoint_ver);
+ if (cur_version == pre_version)
+ {
+ *version = cur_version;
+ grub_free (cp_page_2);
+
+ return cp_page_1;
+ }
+
+ invalid_cp2:
+ grub_free (cp_page_2);
+
+ invalid_cp1:
+ grub_free (cp_page_1);
+
+ return NULL;
+}
+
+static grub_err_t
+grub_f2fs_read_cp (struct grub_f2fs_data *data)
+{
+ void *cp1, *cp2, *cur_page;
+ grub_uint64_t cp1_version = 0, cp2_version = 0;
+ grub_uint64_t cp_start_blk_no;
+
+ /*
+ * Finding out valid cp block involves read both
+ * sets (cp pack1 and cp pack 2).
+ */
+ cp_start_blk_no = data->cp_blkaddr;
+ cp1 = validate_checkpoint (data, cp_start_blk_no, &cp1_version);
+ if (!cp1 && grub_errno)
+ return grub_errno;
+
+ /* The second checkpoint pack should start at the next segment. */
+ cp_start_blk_no += data->blocks_per_seg;
+ cp2 = validate_checkpoint (data, cp_start_blk_no, &cp2_version);
+ if (!cp2 && grub_errno)
+ {
+ grub_free (cp1);
+ return grub_errno;
+ }
+
+ if (cp1 && cp2)
+ cur_page = (cp2_version > cp1_version) ? cp2 : cp1;
+ else if (cp1)
+ cur_page = cp1;
+ else if (cp2)
+ cur_page = cp2;
+ else
+ return grub_error (GRUB_ERR_BAD_FS, "no checkpoints");
+
+ grub_memcpy (&data->ckpt, cur_page, F2FS_BLKSIZE);
+
+ grub_free (cp1);
+ grub_free (cp2);
+
+ return 0;
+}
+
+static grub_err_t
+get_nat_journal (struct grub_f2fs_data *data)
+{
+ grub_uint32_t block;
+ char *buf;
+ grub_err_t err;
+
+ buf = grub_malloc (F2FS_BLKSIZE);
+ if (!buf)
+ return grub_errno;
+
+ if (CKPT_FLAG_SET(&data->ckpt, CP_COMPACT_SUM_FLAG))
+ block = start_sum_block (data);
+ else if (CKPT_FLAG_SET (&data->ckpt, CP_UMOUNT_FLAG))
+ block = sum_blk_addr (data, NR_CURSEG_TYPE, CURSEG_HOT_DATA);
+ else
+ block = sum_blk_addr (data, NR_CURSEG_DATA_TYPE, CURSEG_HOT_DATA);
+
+ err = grub_f2fs_block_read (data, block, buf);
+ if (err)
+ goto fail;
+
+ if (CKPT_FLAG_SET (&data->ckpt, CP_COMPACT_SUM_FLAG))
+ grub_memcpy (&data->nat_j, buf, SUM_JOURNAL_SIZE);
+ else
+ grub_memcpy (&data->nat_j, buf + SUM_ENTRIES_SIZE, SUM_JOURNAL_SIZE);
+
+ fail:
+ grub_free (buf);
+
+ return err;
+}
+
+static grub_uint32_t
+get_blkaddr_from_nat_journal (struct grub_f2fs_data *data, grub_uint32_t nid)
+{
+ grub_uint16_t n = grub_le_to_cpu16 (data->nat_j.n_nats);
+ grub_uint32_t blkaddr = 0;
+ grub_uint16_t i;
+
+ for (i = 0; i < n; i++)
+ {
+ if (grub_le_to_cpu32 (data->nat_j.entries[i].nid) == nid)
+ {
+ blkaddr = grub_le_to_cpu32 (data->nat_j.entries[i].ne.block_addr);
+ break;
+ }
+ }
+
+ return blkaddr;
+}
+
+static grub_uint32_t
+get_node_blkaddr (struct grub_f2fs_data *data, grub_uint32_t nid)
+{
+ struct grub_f2fs_nat_block *nat_block;
+ grub_uint32_t seg_off, block_off, entry_off, block_addr;
+ grub_uint32_t blkaddr;
+ grub_err_t err;
+
+ blkaddr = get_blkaddr_from_nat_journal (data, nid);
+ if (blkaddr)
+ return blkaddr;
+
+ nat_block = grub_malloc (F2FS_BLKSIZE);
+ if (!nat_block)
+ return 0;
+
+ block_off = nid / NAT_ENTRY_PER_BLOCK;
+ entry_off = nid % NAT_ENTRY_PER_BLOCK;
+
+ seg_off = block_off / data->blocks_per_seg;
+ block_addr = data->nat_blkaddr +
+ ((seg_off * data->blocks_per_seg) << 1) +
+ (block_off & (data->blocks_per_seg - 1));
+
+ if (grub_f2fs_test_bit (block_off, data->nat_bitmap))
+ block_addr += data->blocks_per_seg;
+
+ err = grub_f2fs_block_read (data, block_addr, nat_block);
+ if (err)
+ {
+ grub_free (nat_block);
+ return 0;
+ }
+
+ blkaddr = grub_le_to_cpu32 (nat_block->ne[entry_off].block_addr);
+
+ grub_free (nat_block);
+
+ return blkaddr;
+}
+
+static int
+grub_get_node_path (struct grub_f2fs_inode *inode, grub_uint32_t block,
+ grub_uint32_t offset[4], grub_uint32_t noffset[4])
+{
+ grub_uint32_t direct_blks = ADDRS_PER_BLOCK;
+ grub_uint32_t dptrs_per_blk = NIDS_PER_BLOCK;
+ grub_uint32_t indirect_blks = ADDRS_PER_BLOCK * NIDS_PER_BLOCK;
+ grub_uint32_t dindirect_blks = indirect_blks * NIDS_PER_BLOCK;
+ grub_uint32_t direct_index = DEF_ADDRS_PER_INODE;
+ int n = 0;
+ int level = -1;
+
+ if (inode->i_inline & F2FS_INLINE_XATTR)
+ direct_index -= F2FS_INLINE_XATTR_ADDRS;
+
+ noffset[0] = 0;
+
+ if (block < direct_index)
+ {
+ offset[n] = block;
+ level = 0;
+ goto got;
+ }
+
+ block -= direct_index;
+ if (block < direct_blks)
+ {
+ offset[n++] = NODE_DIR1_BLOCK;
+ noffset[n] = 1;
+ offset[n] = block;
+ level = 1;
+ goto got;
+ }
+
+ block -= direct_blks;
+ if (block < direct_blks)
+ {
+ offset[n++] = NODE_DIR2_BLOCK;
+ noffset[n] = 2;
+ offset[n] = block;
+ level = 1;
+ goto got;
+ }
+
+ block -= direct_blks;
+ if (block < indirect_blks)
+ {
+ offset[n++] = NODE_IND1_BLOCK;
+ noffset[n] = 3;
+ offset[n++] = block / direct_blks;
+ noffset[n] = 4 + offset[n - 1];
+ offset[n] = block % direct_blks;
+ level = 2;
+ goto got;
+ }
+
+ block -= indirect_blks;
+ if (block < indirect_blks)
+ {
+ offset[n++] = NODE_IND2_BLOCK;
+ noffset[n] = 4 + dptrs_per_blk;
+ offset[n++] = block / direct_blks;
+ noffset[n] = 5 + dptrs_per_blk + offset[n - 1];
+ offset[n] = block % direct_blks;
+ level = 2;
+ goto got;
+ }
+
+ block -= indirect_blks;
+ if (block < dindirect_blks)
+ {
+ offset[n++] = NODE_DIND_BLOCK;
+ noffset[n] = 5 + (dptrs_per_blk * 2);
+ offset[n++] = block / indirect_blks;
+ noffset[n] = 6 + (dptrs_per_blk * 2) +
+ offset[n - 1] * (dptrs_per_blk + 1);
+ offset[n++] = (block / direct_blks) % dptrs_per_blk;
+ noffset[n] = 7 + (dptrs_per_blk * 2) +
+ offset[n - 2] * (dptrs_per_blk + 1) + offset[n - 1];
+ offset[n] = block % direct_blks;
+ level = 3;
+ goto got;
+ }
+
+ got:
+ return level;
+}
+
+static grub_err_t
+grub_f2fs_read_node (struct grub_f2fs_data *data,
+ grub_uint32_t nid, struct grub_f2fs_node *np)
+{
+ grub_uint32_t blkaddr;
+
+ blkaddr = get_node_blkaddr (data, nid);
+ if (!blkaddr)
+ return grub_errno;
+
+ return grub_f2fs_block_read (data, blkaddr, np);
+}
+
+static struct grub_f2fs_data *
+grub_f2fs_mount (grub_disk_t disk)
+{
+ struct grub_f2fs_data *data;
+ grub_err_t err;
+
+ data = grub_malloc (sizeof (*data));
+ if (!data)
+ return NULL;
+
+ data->disk = disk;
+
+ if (grub_f2fs_read_sb (data, F2FS_SUPER_OFFSET0))
+ {
+ if (grub_f2fs_read_sb (data, F2FS_SUPER_OFFSET1))
+ {
+ if (grub_errno == GRUB_ERR_NONE)
+ grub_error (GRUB_ERR_BAD_FS,
+ "not a F2FS filesystem (no superblock)");
+ goto fail;
+ }
+ }
+
+ data->root_ino = grub_le_to_cpu32 (data->sblock.root_ino);
+ data->cp_blkaddr = grub_le_to_cpu32 (data->sblock.cp_blkaddr);
+ data->nat_blkaddr = grub_le_to_cpu32 (data->sblock.nat_blkaddr);
+ data->blocks_per_seg = 1 <<
+ grub_le_to_cpu32 (data->sblock.log_blocks_per_seg);
+
+ err = grub_f2fs_read_cp (data);
+ if (err)
+ goto fail;
+
+ data->nat_bitmap = nat_bitmap_ptr (data);
+
+ err = get_nat_journal (data);
+ if (err)
+ goto fail;
+
+ data->diropen.data = data;
+ data->diropen.ino = data->root_ino;
+ data->diropen.inode_read = 1;
+ data->inode = &data->diropen.inode;
+
+ err = grub_f2fs_read_node (data, data->root_ino, data->inode);
+ if (err)
+ goto fail;
+
+ return data;
+
+ fail:
+ grub_free (data);
+
+ return NULL;
+}
+
+/* Guarantee inline_data was handled by caller. */
+static grub_disk_addr_t
+grub_f2fs_get_block (grub_fshelp_node_t node, grub_disk_addr_t block_ofs)
+{
+ struct grub_f2fs_data *data = node->data;
+ struct grub_f2fs_inode *inode = &node->inode.i;
+ grub_uint32_t offset[4], noffset[4], nids[4];
+ struct grub_f2fs_node *node_block;
+ grub_uint32_t block_addr = -1;
+ int level, i;
+
+ level = grub_get_node_path (inode, block_ofs, offset, noffset);
+
+ if (level < 0)
+ return -1;
+
+ if (level == 0)
+ return grub_le_to_cpu32 (inode->i_addr[offset[0]]);
+
+ node_block = grub_malloc (F2FS_BLKSIZE);
+ if (!node_block)
+ return -1;
+
+ nids[1] = get_node_id (&node->inode, offset[0], 1);
+
+ /* Get indirect or direct nodes. */
+ for (i = 1; i <= level; i++)
+ {
+ grub_f2fs_read_node (data, nids[i], node_block);
+ if (grub_errno)
+ goto fail;
+
+ if (i < level)
+ nids[i + 1] = get_node_id (node_block, offset[i], 0);
+ }
+
+ block_addr = grub_le_to_cpu32 (node_block->dn.addr[offset[level]]);
+
+ fail:
+ grub_free (node_block);
+
+ return block_addr;
+}
+
+static grub_ssize_t
+grub_f2fs_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)
+{
+ struct grub_f2fs_inode *inode = &node->inode.i;
+ grub_off_t filesize = grub_f2fs_file_size (inode);
+ char *inline_addr = get_inline_addr (inode);
+
+ if (inode->i_inline & F2FS_INLINE_DATA)
+ {
+ if (filesize > MAX_INLINE_DATA)
+ return -1;
+
+ if (len > filesize - pos)
+ len = filesize - pos;
+
+ grub_memcpy (buf, inline_addr + pos, len);
+ return len;
+ }
+
+ return grub_fshelp_read_file (node->data->disk, node,
+ read_hook, read_hook_data,
+ pos, len, buf, grub_f2fs_get_block,
+ filesize,
+ F2FS_BLK_SEC_BITS, 0);
+}
+
+static char *
+grub_f2fs_read_symlink (grub_fshelp_node_t node)
+{
+ char *symlink;
+ struct grub_fshelp_node *diro = node;
+ grub_uint64_t filesize;
+
+ if (!diro->inode_read)
+ {
+ grub_f2fs_read_node (diro->data, diro->ino, &diro->inode);
+ if (grub_errno)
+ return 0;
+ }
+
+ filesize = grub_f2fs_file_size(&diro->inode.i);
+
+ symlink = grub_malloc (filesize + 1);
+ if (!symlink)
+ return 0;
+
+ grub_f2fs_read_file (diro, 0, 0, 0, filesize, symlink);
+ if (grub_errno)
+ {
+ grub_free (symlink);
+ return 0;
+ }
+
+ symlink[filesize] = '\0';
+
+ return symlink;
+}
+
+static int
+grub_f2fs_check_dentries (struct grub_f2fs_dir_iter_ctx *ctx)
+{
+ struct grub_fshelp_node *fdiro;
+ int i;
+
+ for (i = 0; i < ctx->max;)
+ {
+ char *filename;
+ enum grub_fshelp_filetype type = GRUB_FSHELP_UNKNOWN;
+ enum FILE_TYPE ftype;
+ int name_len;
+ int ret;
+
+ if (grub_f2fs_test_bit_le (i, ctx->bitmap) == 0)
+ {
+ i++;
+ continue;
+ }
+
+ ftype = ctx->dentry[i].file_type;
+ name_len = grub_le_to_cpu16 (ctx->dentry[i].name_len);
+ filename = grub_malloc (name_len + 1);
+ if (!filename)
+ return 0;
+
+ grub_memcpy (filename, ctx->filename[i], name_len);
+ filename[name_len] = 0;
+
+ fdiro = grub_malloc (sizeof (struct grub_fshelp_node));
+ if (!fdiro)
+ {
+ grub_free(filename);
+ return 0;
+ }
+
+ if (ftype == F2FS_FT_DIR)
+ type = GRUB_FSHELP_DIR;
+ else if (ftype == F2FS_FT_SYMLINK)
+ type = GRUB_FSHELP_SYMLINK;
+ else if (ftype == F2FS_FT_REG_FILE)
+ type = GRUB_FSHELP_REG;
+
+ fdiro->data = ctx->data;
+ fdiro->ino = grub_le_to_cpu32 (ctx->dentry[i].ino);
+ fdiro->inode_read = 0;
+
+ ret = ctx->hook (filename, type, fdiro, ctx->hook_data);
+ grub_free(filename);
+ if (ret)
+ return 1;
+
+ i += (name_len + F2FS_SLOT_LEN - 1) / F2FS_SLOT_LEN;
+ }
+
+ return 0;
+}
+
+static int
+grub_f2fs_iterate_inline_dir (struct grub_f2fs_inode *dir,
+ struct grub_f2fs_dir_iter_ctx *ctx)
+{
+ struct grub_f2fs_inline_dentry *de_blk;
+
+ de_blk = (struct grub_f2fs_inline_dentry *) get_inline_addr (dir);
+
+ ctx->bitmap = de_blk->dentry_bitmap;
+ ctx->dentry = de_blk->dentry;
+ ctx->filename = de_blk->filename;
+ ctx->max = NR_INLINE_DENTRY;
+
+ return grub_f2fs_check_dentries (ctx);
+}
+
+static int
+grub_f2fs_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
+ struct grub_f2fs_inode *inode;
+ struct grub_f2fs_dir_iter_ctx ctx = {
+ .data = diro->data,
+ .hook = hook,
+ .hook_data = hook_data
+ };
+ grub_off_t fpos = 0;
+
+ if (!diro->inode_read)
+ {
+ grub_f2fs_read_node (diro->data, diro->ino, &diro->inode);
+ if (grub_errno)
+ return 0;
+ }
+
+ inode = &diro->inode.i;
+
+ if (inode->i_inline & F2FS_INLINE_DENTRY)
+ return grub_f2fs_iterate_inline_dir (inode, &ctx);
+
+ while (fpos < grub_f2fs_file_size (inode))
+ {
+ struct grub_f2fs_dentry_block *de_blk;
+ char *buf;
+ int ret;
+
+ buf = grub_zalloc (F2FS_BLKSIZE);
+ if (!buf)
+ return 0;
+
+ grub_f2fs_read_file (diro, 0, 0, fpos, F2FS_BLKSIZE, buf);
+ if (grub_errno)
+ {
+ grub_free (buf);
+ return 0;
+ }
+
+ de_blk = (struct grub_f2fs_dentry_block *) buf;
+
+ ctx.bitmap = de_blk->dentry_bitmap;
+ ctx.dentry = de_blk->dentry;
+ ctx.filename = de_blk->filename;
+ ctx.max = NR_DENTRY_IN_BLOCK;
+
+ ret = grub_f2fs_check_dentries (&ctx);
+ grub_free (buf);
+ if (ret)
+ return 1;
+
+ fpos += F2FS_BLKSIZE;
+ }
+
+ return 0;
+}
+
+static int
+grub_f2fs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_f2fs_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ if (!node->inode_read)
+ {
+ grub_f2fs_read_node (ctx->data, node->ino, &node->inode);
+ if (!grub_errno)
+ node->inode_read = 1;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ if (node->inode_read)
+ {
+ info.mtimeset = 1;
+ info.mtime = grub_le_to_cpu64 (node->inode.i.i_mtime);
+ }
+
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ grub_free (node);
+
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_f2fs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_f2fs_dir_ctx ctx = {
+ .hook = hook,
+ .hook_data = hook_data
+ };
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ ctx.data = grub_f2fs_mount (device->disk);
+ if (!ctx.data)
+ goto fail;
+
+ grub_fshelp_find_file (path, &ctx.data->diropen, &fdiro,
+ grub_f2fs_iterate_dir, grub_f2fs_read_symlink,
+ GRUB_FSHELP_DIR);
+ if (grub_errno)
+ goto fail;
+
+ grub_f2fs_iterate_dir (fdiro, grub_f2fs_dir_iter, &ctx);
+
+ fail:
+ if (fdiro != &ctx.data->diropen)
+ grub_free (fdiro);
+ grub_free (ctx.data);
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_f2fs_open (struct grub_file *file, const char *name)
+{
+ struct grub_f2fs_data *data = NULL;
+ struct grub_fshelp_node *fdiro = 0;
+ struct grub_f2fs_inode *inode;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_f2fs_mount (file->device->disk);
+ if (!data)
+ goto fail;
+
+ grub_fshelp_find_file (name, &data->diropen, &fdiro,
+ grub_f2fs_iterate_dir, grub_f2fs_read_symlink,
+ GRUB_FSHELP_REG);
+ if (grub_errno)
+ goto fail;
+
+ if (!fdiro->inode_read)
+ {
+ grub_f2fs_read_node (data, fdiro->ino, &fdiro->inode);
+ if (grub_errno)
+ goto fail;
+ }
+
+ grub_memcpy (data->inode, &fdiro->inode, sizeof (*data->inode));
+ grub_free (fdiro);
+
+ inode = &(data->inode->i);
+ file->size = grub_f2fs_file_size (inode);
+ file->data = data;
+ file->offset = 0;
+
+ if (inode->i_inline & F2FS_INLINE_DATA && file->size > MAX_INLINE_DATA)
+ grub_error (GRUB_ERR_BAD_FS, "corrupted inline_data: need fsck");
+
+ return 0;
+
+ fail:
+ if (fdiro != &data->diropen)
+ grub_free (fdiro);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_ssize_t
+grub_f2fs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_f2fs_data *data = (struct grub_f2fs_data *) file->data;
+
+ return grub_f2fs_read_file (&data->diropen,
+ file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+static grub_err_t
+grub_f2fs_close (grub_file_t file)
+{
+ struct grub_f2fs_data *data = (struct grub_f2fs_data *) file->data;
+
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_uint8_t *
+grub_f2fs_utf16_to_utf8 (grub_uint16_t *in_buf_le)
+{
+ grub_uint16_t in_buf[MAX_VOLUME_NAME];
+ grub_uint8_t *out_buf;
+ int len = 0;
+
+ out_buf = grub_malloc (MAX_VOLUME_NAME * GRUB_MAX_UTF8_PER_UTF16 + 1);
+ if (!out_buf)
+ return NULL;
+
+ while (*in_buf_le != 0 && len < MAX_VOLUME_NAME) {
+ in_buf[len] = grub_le_to_cpu16 (in_buf_le[len]);
+ len++;
+ }
+
+ *grub_utf16_to_utf8 (out_buf, in_buf, len) = '\0';
+
+ return out_buf;
+}
+
+#if __GNUC__ >= 9
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
+static grub_err_t
+grub_f2fs_label (grub_device_t device, char **label)
+{
+ struct grub_f2fs_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_f2fs_mount (disk);
+ if (data)
+ *label = (char *) grub_f2fs_utf16_to_utf8 (data->sblock.volume_name);
+ else
+ *label = NULL;
+
+ grub_free (data);
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+#if __GNUC__ >= 9
+#pragma GCC diagnostic pop
+#endif
+
+static grub_err_t
+grub_f2fs_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_f2fs_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_f2fs_mount (disk);
+ if (data)
+ {
+ *uuid =
+ grub_xasprintf
+ ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ data->sblock.uuid[0], data->sblock.uuid[1],
+ data->sblock.uuid[2], data->sblock.uuid[3],
+ data->sblock.uuid[4], data->sblock.uuid[5],
+ data->sblock.uuid[6], data->sblock.uuid[7],
+ data->sblock.uuid[8], data->sblock.uuid[9],
+ data->sblock.uuid[10], data->sblock.uuid[11],
+ data->sblock.uuid[12], data->sblock.uuid[13],
+ data->sblock.uuid[14], data->sblock.uuid[15]);
+ }
+ else
+ *uuid = NULL;
+
+ grub_free (data);
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static struct grub_fs grub_f2fs_fs = {
+ .name = "f2fs",
+ .fs_dir = grub_f2fs_dir,
+ .fs_open = grub_f2fs_open,
+ .fs_read = grub_f2fs_read,
+ .fs_close = grub_f2fs_close,
+ .fs_label = grub_f2fs_label,
+ .fs_uuid = grub_f2fs_uuid,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 0,
+#endif
+ .next = 0
+};
+
+GRUB_MOD_INIT (f2fs)
+{
+ grub_fs_register (&grub_f2fs_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (f2fs)
+{
+ grub_fs_unregister (&grub_f2fs_fs);
+}
diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c
new file mode 100644
index 0000000..dd82e4e
--- /dev/null
+++ b/grub-core/fs/fat.c
@@ -0,0 +1,1329 @@
+/* fat.c - FAT filesystem */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/fs.h>
+#include <grub/disk.h>
+#include <grub/file.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/charset.h>
+#include <grub/datetime.h>
+#ifndef MODE_EXFAT
+#include <grub/fat.h>
+#else
+#include <grub/exfat.h>
+#endif
+#include <grub/fshelp.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+enum
+ {
+ GRUB_FAT_ATTR_READ_ONLY = 0x01,
+ GRUB_FAT_ATTR_HIDDEN = 0x02,
+ GRUB_FAT_ATTR_SYSTEM = 0x04,
+#ifndef MODE_EXFAT
+ GRUB_FAT_ATTR_VOLUME_ID = 0x08,
+#endif
+ GRUB_FAT_ATTR_DIRECTORY = 0x10,
+ GRUB_FAT_ATTR_ARCHIVE = 0x20,
+
+#ifndef MODE_EXFAT
+ GRUB_FAT_ATTR_LONG_NAME = (GRUB_FAT_ATTR_READ_ONLY
+ | GRUB_FAT_ATTR_HIDDEN
+ | GRUB_FAT_ATTR_SYSTEM
+ | GRUB_FAT_ATTR_VOLUME_ID),
+#endif
+ GRUB_FAT_ATTR_VALID = (GRUB_FAT_ATTR_READ_ONLY
+ | GRUB_FAT_ATTR_HIDDEN
+ | GRUB_FAT_ATTR_SYSTEM
+ | GRUB_FAT_ATTR_DIRECTORY
+ | GRUB_FAT_ATTR_ARCHIVE
+#ifndef MODE_EXFAT
+ | GRUB_FAT_ATTR_VOLUME_ID
+#endif
+ )
+ };
+
+#ifdef MODE_EXFAT
+typedef struct grub_exfat_bpb grub_current_fat_bpb_t;
+#else
+typedef struct grub_fat_bpb grub_current_fat_bpb_t;
+#endif
+
+#ifdef MODE_EXFAT
+enum
+ {
+ FLAG_CONTIGUOUS = 2
+ };
+struct grub_fat_dir_entry
+{
+ grub_uint8_t entry_type;
+ union
+ {
+ grub_uint8_t placeholder[31];
+ struct {
+ grub_uint8_t secondary_count;
+ grub_uint16_t checksum;
+ grub_uint16_t attr;
+ grub_uint16_t reserved1;
+ grub_uint32_t c_time;
+ grub_uint32_t m_time;
+ grub_uint32_t a_time;
+ grub_uint8_t c_time_tenth;
+ grub_uint8_t m_time_tenth;
+ grub_uint8_t a_time_tenth;
+ grub_uint8_t reserved2[9];
+ } GRUB_PACKED file;
+ struct {
+ grub_uint8_t flags;
+ grub_uint8_t reserved1;
+ grub_uint8_t name_length;
+ grub_uint16_t name_hash;
+ grub_uint16_t reserved2;
+ grub_uint64_t valid_size;
+ grub_uint32_t reserved3;
+ grub_uint32_t first_cluster;
+ grub_uint64_t file_size;
+ } GRUB_PACKED stream_extension;
+ struct {
+ grub_uint8_t flags;
+ grub_uint16_t str[15];
+ } GRUB_PACKED file_name;
+ struct {
+ grub_uint8_t character_count;
+ grub_uint16_t str[15];
+ } GRUB_PACKED volume_label;
+ } GRUB_PACKED type_specific;
+} GRUB_PACKED;
+
+struct grub_fat_dir_node
+{
+ grub_uint32_t attr;
+ grub_uint32_t first_cluster;
+ grub_uint64_t file_size;
+ grub_uint64_t valid_size;
+ int have_stream;
+ int is_contiguous;
+};
+
+typedef struct grub_fat_dir_node grub_fat_dir_node_t;
+
+#else
+struct grub_fat_dir_entry
+{
+ grub_uint8_t name[11];
+ grub_uint8_t attr;
+ grub_uint8_t nt_reserved;
+ grub_uint8_t c_time_tenth;
+ grub_uint16_t c_time;
+ grub_uint16_t c_date;
+ grub_uint16_t a_date;
+ grub_uint16_t first_cluster_high;
+ grub_uint16_t w_time;
+ grub_uint16_t w_date;
+ grub_uint16_t first_cluster_low;
+ grub_uint32_t file_size;
+} GRUB_PACKED;
+
+struct grub_fat_long_name_entry
+{
+ grub_uint8_t id;
+ grub_uint16_t name1[5];
+ grub_uint8_t attr;
+ grub_uint8_t reserved;
+ grub_uint8_t checksum;
+ grub_uint16_t name2[6];
+ grub_uint16_t first_cluster;
+ grub_uint16_t name3[2];
+} GRUB_PACKED;
+
+typedef struct grub_fat_dir_entry grub_fat_dir_node_t;
+
+#endif
+
+struct grub_fat_data
+{
+ int logical_sector_bits;
+ grub_uint32_t num_sectors;
+
+ grub_uint32_t fat_sector;
+ grub_uint32_t sectors_per_fat;
+ int fat_size;
+
+ grub_uint32_t root_cluster;
+#ifndef MODE_EXFAT
+ grub_uint32_t root_sector;
+ grub_uint32_t num_root_sectors;
+#endif
+
+ int cluster_bits;
+ grub_uint32_t cluster_eof_mark;
+ 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;
+#ifndef MODE_EXFAT
+ grub_uint32_t file_size;
+#else
+ grub_uint64_t file_size;
+#endif
+ grub_uint32_t file_cluster;
+ grub_uint32_t cur_cluster_num;
+ grub_uint32_t cur_cluster;
+
+#ifdef MODE_EXFAT
+ int is_contiguous;
+#endif
+};
+
+static grub_dl_t my_mod;
+
+#ifndef MODE_EXFAT
+static int
+fat_log2 (unsigned x)
+{
+ int i;
+
+ if (x == 0)
+ return -1;
+
+ for (i = 0; (x & 1) == 0; i++)
+ x >>= 1;
+
+ if (x != 1)
+ return -1;
+
+ return i;
+}
+#endif
+
+static struct grub_fat_data *
+grub_fat_mount (grub_disk_t disk)
+{
+ grub_current_fat_bpb_t bpb;
+ struct grub_fat_data *data = 0;
+ grub_uint32_t first_fat, magic;
+
+ if (! disk)
+ goto fail;
+
+ data = (struct grub_fat_data *) grub_malloc (sizeof (*data));
+ if (! data)
+ goto fail;
+
+ /* Read the BPB. */
+ if (grub_disk_read (disk, 0, 0, sizeof (bpb), &bpb))
+ goto fail;
+
+#ifdef MODE_EXFAT
+ if (grub_memcmp ((const char *) bpb.oem_name, "EXFAT ",
+ sizeof (bpb.oem_name)) != 0)
+ goto fail;
+#endif
+
+ /* Get the sizes of logical sectors and clusters. */
+#ifdef MODE_EXFAT
+ data->logical_sector_bits = bpb.bytes_per_sector_shift;
+#else
+ data->logical_sector_bits =
+ fat_log2 (grub_le_to_cpu16 (bpb.bytes_per_sector));
+#endif
+ if (data->logical_sector_bits < GRUB_DISK_SECTOR_BITS
+ || data->logical_sector_bits >= 16)
+ goto fail;
+ data->logical_sector_bits -= GRUB_DISK_SECTOR_BITS;
+
+#ifdef MODE_EXFAT
+ data->cluster_bits = bpb.sectors_per_cluster_shift;
+#else
+ data->cluster_bits = fat_log2 (bpb.sectors_per_cluster);
+#endif
+ if (data->cluster_bits < 0 || data->cluster_bits > 25)
+ goto fail;
+ data->cluster_bits += data->logical_sector_bits;
+
+ /* Get information about FATs. */
+#ifdef MODE_EXFAT
+ data->fat_sector = (grub_le_to_cpu32 (bpb.num_reserved_sectors)
+ << data->logical_sector_bits);
+#else
+ data->fat_sector = (grub_le_to_cpu16 (bpb.num_reserved_sectors)
+ << data->logical_sector_bits);
+#endif
+ if (data->fat_sector == 0)
+ goto fail;
+
+#ifdef MODE_EXFAT
+ data->sectors_per_fat = (grub_le_to_cpu32 (bpb.sectors_per_fat)
+ << data->logical_sector_bits);
+#else
+ data->sectors_per_fat = ((bpb.sectors_per_fat_16
+ ? grub_le_to_cpu16 (bpb.sectors_per_fat_16)
+ : grub_le_to_cpu32 (bpb.version_specific.fat32.sectors_per_fat_32))
+ << data->logical_sector_bits);
+#endif
+ if (data->sectors_per_fat == 0)
+ goto fail;
+
+ /* Get the number of sectors in this volume. */
+#ifdef MODE_EXFAT
+ data->num_sectors = ((grub_le_to_cpu64 (bpb.num_total_sectors))
+ << data->logical_sector_bits);
+#else
+ data->num_sectors = ((bpb.num_total_sectors_16
+ ? grub_le_to_cpu16 (bpb.num_total_sectors_16)
+ : grub_le_to_cpu32 (bpb.num_total_sectors_32))
+ << data->logical_sector_bits);
+#endif
+ if (data->num_sectors == 0)
+ goto fail;
+
+ /* Get information about the root directory. */
+ if (bpb.num_fats == 0)
+ goto fail;
+
+#ifndef MODE_EXFAT
+ data->root_sector = data->fat_sector + bpb.num_fats * data->sectors_per_fat;
+ data->num_root_sectors
+ = ((((grub_uint32_t) grub_le_to_cpu16 (bpb.num_root_entries)
+ * sizeof (struct grub_fat_dir_entry)
+ + grub_le_to_cpu16 (bpb.bytes_per_sector) - 1)
+ >> (data->logical_sector_bits + GRUB_DISK_SECTOR_BITS))
+ << (data->logical_sector_bits));
+#endif
+
+#ifdef MODE_EXFAT
+ data->cluster_sector = (grub_le_to_cpu32 (bpb.cluster_offset)
+ << data->logical_sector_bits);
+ data->num_clusters = (grub_le_to_cpu32 (bpb.cluster_count)
+ << data->logical_sector_bits);
+#else
+ data->cluster_sector = data->root_sector + data->num_root_sectors;
+ data->num_clusters = (((data->num_sectors - data->cluster_sector)
+ >> data->cluster_bits)
+ + 2);
+#endif
+
+ if (data->num_clusters <= 2)
+ goto fail;
+
+#ifdef MODE_EXFAT
+ {
+ /* exFAT. */
+ data->root_cluster = grub_le_to_cpu32 (bpb.root_cluster);
+ data->fat_size = 32;
+ data->cluster_eof_mark = 0xffffffff;
+
+ if ((bpb.volume_flags & grub_cpu_to_le16_compile_time (0x1))
+ && bpb.num_fats > 1)
+ data->fat_sector += data->sectors_per_fat;
+ }
+#else
+ if (! bpb.sectors_per_fat_16)
+ {
+ /* FAT32. */
+ grub_uint16_t flags = grub_le_to_cpu16 (bpb.version_specific.fat32.extended_flags);
+
+ data->root_cluster = grub_le_to_cpu32 (bpb.version_specific.fat32.root_cluster);
+ data->fat_size = 32;
+ data->cluster_eof_mark = 0x0ffffff8;
+
+ if (flags & 0x80)
+ {
+ /* Get an active FAT. */
+ unsigned active_fat = flags & 0xf;
+
+ if (active_fat > bpb.num_fats)
+ goto fail;
+
+ data->fat_sector += active_fat * data->sectors_per_fat;
+ }
+
+ if (bpb.num_root_entries != 0 || bpb.version_specific.fat32.fs_version != 0)
+ goto fail;
+ }
+ else
+ {
+ /* FAT12 or FAT16. */
+ data->root_cluster = ~0U;
+
+ if (data->num_clusters <= 4085 + 2)
+ {
+ /* FAT12. */
+ data->fat_size = 12;
+ data->cluster_eof_mark = 0x0ff8;
+ }
+ else
+ {
+ /* FAT16. */
+ data->fat_size = 16;
+ data->cluster_eof_mark = 0xfff8;
+ }
+ }
+#endif
+
+ /* More sanity checks. */
+ if (data->num_sectors <= data->fat_sector)
+ goto fail;
+
+ if (grub_disk_read (disk,
+ data->fat_sector,
+ 0,
+ sizeof (first_fat),
+ &first_fat))
+ goto fail;
+
+ first_fat = grub_le_to_cpu32 (first_fat);
+
+ if (data->fat_size == 32)
+ {
+ first_fat &= 0x0fffffff;
+ magic = 0x0fffff00;
+ }
+ else if (data->fat_size == 16)
+ {
+ first_fat &= 0x0000ffff;
+ magic = 0xff00;
+ }
+ else
+ {
+ first_fat &= 0x00000fff;
+ magic = 0x0f00;
+ }
+
+ /* Serial number. */
+#ifdef MODE_EXFAT
+ data->uuid = grub_le_to_cpu32 (bpb.num_serial);
+#else
+ if (bpb.sectors_per_fat_16)
+ data->uuid = grub_le_to_cpu32 (bpb.version_specific.fat12_or_fat16.num_serial);
+ else
+ data->uuid = grub_le_to_cpu32 (bpb.version_specific.fat32.num_serial);
+#endif
+
+#ifndef MODE_EXFAT
+ /* Ignore the 3rd bit, because some BIOSes assigns 0xF0 to the media
+ descriptor, even if it is a so-called superfloppy (e.g. an USB key).
+ The check may be too strict for this kind of stupid BIOSes, as
+ they overwrite the media descriptor. */
+ if ((first_fat | 0x8) != (magic | bpb.media | 0x8))
+ goto fail;
+#else
+ (void) magic;
+#endif
+
+ return data;
+
+ fail:
+
+ grub_free (data);
+ grub_error (GRUB_ERR_BAD_FS, "not a FAT filesystem");
+ return 0;
+}
+
+static grub_ssize_t
+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)
+{
+ grub_size_t size;
+ grub_uint32_t logical_cluster;
+ unsigned logical_cluster_bits;
+ grub_ssize_t ret = 0;
+ unsigned long sector;
+
+#ifndef MODE_EXFAT
+ /* This is a special case. FAT12 and FAT16 doesn't have the root directory
+ in clusters. */
+ if (node->file_cluster == ~0U)
+ {
+ size = (node->data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset;
+ if (size > len)
+ size = len;
+
+ if (grub_disk_read (disk, node->data->root_sector, offset, size, buf))
+ return -1;
+
+ return size;
+ }
+#endif
+
+#ifdef MODE_EXFAT
+ if (node->is_contiguous)
+ {
+ /* Read the data here. */
+ 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;
+ grub_disk_read (disk, sector + (offset >> GRUB_DISK_SECTOR_BITS),
+ offset & (GRUB_DISK_SECTOR_SIZE - 1), len, buf);
+ disk->read_hook = 0;
+ if (grub_errno)
+ return -1;
+
+ return len;
+ }
+#endif
+
+ /* Calculate the logical cluster number and offset. */
+ 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 < node->cur_cluster_num)
+ {
+ node->cur_cluster_num = 0;
+ node->cur_cluster = node->file_cluster;
+ }
+
+ while (len)
+ {
+ while (logical_cluster > node->cur_cluster_num)
+ {
+ /* Find next cluster. */
+ grub_uint32_t next_cluster;
+ grub_uint32_t fat_offset;
+
+ switch (node->data->fat_size)
+ {
+ case 32:
+ fat_offset = node->cur_cluster << 2;
+ break;
+ case 16:
+ fat_offset = node->cur_cluster << 1;
+ break;
+ default:
+ /* case 12: */
+ fat_offset = node->cur_cluster + (node->cur_cluster >> 1);
+ break;
+ }
+
+ /* Read the FAT. */
+ 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 (node->data->fat_size)
+ {
+ case 16:
+ next_cluster &= 0xFFFF;
+ break;
+ case 12:
+ if (node->cur_cluster & 1)
+ next_cluster >>= 4;
+
+ next_cluster &= 0x0FFF;
+ break;
+ }
+
+ grub_dprintf ("fat", "fat_size=%d, next_cluster=%u\n",
+ node->data->fat_size, next_cluster);
+
+ /* Check the end. */
+ if (next_cluster >= node->data->cluster_eof_mark)
+ return ret;
+
+ if (next_cluster < 2 || next_cluster >= node->data->num_clusters)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid cluster %u",
+ next_cluster);
+ return -1;
+ }
+
+ node->cur_cluster = next_cluster;
+ node->cur_cluster_num++;
+ }
+
+ /* Read the data here. */
+ sector = (node->data->cluster_sector
+ + ((node->cur_cluster - 2)
+ << node->data->cluster_bits));
+ size = (1 << logical_cluster_bits) - offset;
+ if (size > len)
+ size = len;
+
+ disk->read_hook = read_hook;
+ disk->read_hook_data = read_hook_data;
+ grub_disk_read (disk, sector, offset, size, buf);
+ disk->read_hook = 0;
+ if (grub_errno)
+ return -1;
+
+ len -= size;
+ buf += size;
+ ret += size;
+ logical_cluster++;
+ offset = 0;
+ }
+
+ return ret;
+}
+
+struct grub_fat_iterate_context
+{
+#ifdef MODE_EXFAT
+ struct grub_fat_dir_node dir;
+ struct grub_fat_dir_entry entry;
+#else
+ struct grub_fat_dir_entry dir;
+#endif
+ char *filename;
+ grub_uint16_t *unibuf;
+ grub_ssize_t offset;
+};
+
+static grub_err_t
+grub_fat_iterate_init (struct grub_fat_iterate_context *ctxt)
+{
+ ctxt->offset = -sizeof (struct grub_fat_dir_entry);
+
+#ifndef MODE_EXFAT
+ /* Allocate space enough to hold a long name. */
+ ctxt->filename = grub_malloc (0x40 * 13 * GRUB_MAX_UTF8_PER_UTF16 + 1);
+ ctxt->unibuf = (grub_uint16_t *) grub_malloc (0x40 * 13 * 2);
+#else
+ ctxt->unibuf = grub_malloc (15 * 256 * 2);
+ ctxt->filename = grub_malloc (15 * 256 * GRUB_MAX_UTF8_PER_UTF16 + 1);
+#endif
+
+ if (! ctxt->filename || ! ctxt->unibuf)
+ {
+ grub_free (ctxt->filename);
+ grub_free (ctxt->unibuf);
+ return grub_errno;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_fat_iterate_fini (struct grub_fat_iterate_context *ctxt)
+{
+ grub_free (ctxt->filename);
+ grub_free (ctxt->unibuf);
+}
+
+#ifdef MODE_EXFAT
+static grub_err_t
+grub_fat_iterate_dir_next (grub_fshelp_node_t node,
+ struct grub_fat_iterate_context *ctxt)
+{
+ grub_memset (&ctxt->dir, 0, sizeof (ctxt->dir));
+ while (1)
+ {
+ struct grub_fat_dir_entry *dir = &ctxt->entry;
+
+ ctxt->offset += sizeof (*dir);
+
+ if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (*dir),
+ (char *) dir)
+ != sizeof (*dir))
+ break;
+
+ if (dir->entry_type == 0)
+ break;
+ if (!(dir->entry_type & 0x80))
+ continue;
+
+ if (dir->entry_type == 0x85)
+ {
+ unsigned i, nsec, slots = 0;
+
+ nsec = dir->type_specific.file.secondary_count;
+
+ ctxt->dir.attr = grub_cpu_to_le16 (dir->type_specific.file.attr);
+ ctxt->dir.have_stream = 0;
+ for (i = 0; i < nsec; i++)
+ {
+ struct grub_fat_dir_entry sec;
+ ctxt->offset += sizeof (sec);
+ if (grub_fat_read_data (node->disk, node, 0, 0,
+ ctxt->offset, sizeof (sec), (char *) &sec)
+ != sizeof (sec))
+ break;
+ if (!(sec.entry_type & 0x80))
+ continue;
+ if (!(sec.entry_type & 0x40))
+ break;
+ switch (sec.entry_type)
+ {
+ case 0xc0:
+ ctxt->dir.first_cluster = grub_cpu_to_le32 (sec.type_specific.stream_extension.first_cluster);
+ ctxt->dir.valid_size
+ = grub_cpu_to_le64 (sec.type_specific.stream_extension.valid_size);
+ ctxt->dir.file_size
+ = grub_cpu_to_le64 (sec.type_specific.stream_extension.file_size);
+ ctxt->dir.have_stream = 1;
+ ctxt->dir.is_contiguous = !!(sec.type_specific.stream_extension.flags
+ & grub_cpu_to_le16_compile_time (FLAG_CONTIGUOUS));
+ break;
+ case 0xc1:
+ {
+ int j;
+ for (j = 0; j < 15; j++)
+ ctxt->unibuf[slots * 15 + j]
+ = grub_le_to_cpu16 (sec.type_specific.file_name.str[j]);
+ slots++;
+ }
+ break;
+ default:
+ grub_dprintf ("exfat", "unknown secondary type 0x%02x\n",
+ sec.entry_type);
+ }
+ }
+
+ if (i != nsec)
+ {
+ ctxt->offset -= sizeof (*dir);
+ continue;
+ }
+
+ *grub_utf16_to_utf8 ((grub_uint8_t *) ctxt->filename, ctxt->unibuf,
+ slots * 15) = '\0';
+
+ return 0;
+ }
+ /* Allocation bitmap. */
+ if (dir->entry_type == 0x81)
+ continue;
+ /* Upcase table. */
+ if (dir->entry_type == 0x82)
+ continue;
+ /* Volume label. */
+ if (dir->entry_type == 0x83)
+ continue;
+ grub_dprintf ("exfat", "unknown primary type 0x%02x\n",
+ dir->entry_type);
+ }
+ return grub_errno ? : GRUB_ERR_EOF;
+}
+
+/*
+ * Convert a timestamp in exFAT format to seconds since the UNIX epoch
+ * according to sections 7.4.8 and 7.4.9 in the exFAT specification.
+ * https://docs.microsoft.com/en-us/windows/win32/fileio/exfat-specification
+ */
+static int
+grub_exfat_timestamp (grub_uint32_t field, grub_uint8_t msec, grub_int64_t *nix) {
+ struct grub_datetime datetime = {
+ .year = (field >> 25) + 1980,
+ .month = (field & 0x01E00000) >> 21,
+ .day = (field & 0x001F0000) >> 16,
+ .hour = (field & 0x0000F800) >> 11,
+ .minute = (field & 0x000007E0) >> 5,
+ .second = (field & 0x0000001F) * 2 + (msec >= 100 ? 1 : 0),
+ };
+
+ /* The conversion below allows seconds=60, so don't trust its validation. */
+ if ((field & 0x1F) > 29)
+ return 0;
+
+ /* Validate the 10-msec field even though it is rounded down to seconds. */
+ if (msec > 199)
+ return 0;
+
+ return grub_datetime2unixtime (&datetime, nix);
+}
+
+#else
+
+static grub_err_t
+grub_fat_iterate_dir_next (grub_fshelp_node_t node,
+ struct grub_fat_iterate_context *ctxt)
+{
+ char *filep = 0;
+ int checksum = -1;
+ int slot = -1, slots = -1;
+
+ while (1)
+ {
+ unsigned i;
+
+ /* Adjust the offset. */
+ ctxt->offset += sizeof (ctxt->dir);
+
+ /* Read a directory entry. */
+ 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)
+ break;
+
+ /* Handle long name entries. */
+ if (ctxt->dir.attr == GRUB_FAT_ATTR_LONG_NAME)
+ {
+ struct grub_fat_long_name_entry *long_name
+ = (struct grub_fat_long_name_entry *) &ctxt->dir;
+ grub_uint8_t id = long_name->id;
+
+ if (id & 0x40)
+ {
+ id &= 0x3f;
+ slots = slot = id;
+ checksum = long_name->checksum;
+ }
+
+ if (id != slot || slot == 0 || checksum != long_name->checksum)
+ {
+ checksum = -1;
+ continue;
+ }
+
+ slot--;
+ grub_memcpy (ctxt->unibuf + slot * 13, long_name->name1, 5 * 2);
+ grub_memcpy (ctxt->unibuf + slot * 13 + 5, long_name->name2, 6 * 2);
+ grub_memcpy (ctxt->unibuf + slot * 13 + 11, long_name->name3, 2 * 2);
+ continue;
+ }
+
+ /* Check if this entry is valid. */
+ if (ctxt->dir.name[0] == 0xe5 || (ctxt->dir.attr & ~GRUB_FAT_ATTR_VALID))
+ continue;
+
+ /* This is a workaround for Japanese. */
+ if (ctxt->dir.name[0] == 0x05)
+ ctxt->dir.name[0] = 0xe5;
+
+ if (checksum != -1 && slot == 0)
+ {
+ grub_uint8_t sum;
+
+ for (sum = 0, i = 0; i < sizeof (ctxt->dir.name); i++)
+ sum = ((sum >> 1) | (sum << 7)) + ctxt->dir.name[i];
+
+ if (sum == checksum)
+ {
+ int u;
+
+ for (u = 0; u < slots * 13; u++)
+ ctxt->unibuf[u] = grub_le_to_cpu16 (ctxt->unibuf[u]);
+
+ *grub_utf16_to_utf8 ((grub_uint8_t *) ctxt->filename,
+ ctxt->unibuf,
+ slots * 13) = '\0';
+
+ return GRUB_ERR_NONE;
+ }
+
+ checksum = -1;
+ }
+
+ /* Convert the 8.3 file name. */
+ filep = ctxt->filename;
+ if (ctxt->dir.attr & GRUB_FAT_ATTR_VOLUME_ID)
+ {
+ for (i = 0; i < sizeof (ctxt->dir.name) && ctxt->dir.name[i]; i++)
+ *filep++ = ctxt->dir.name[i];
+ while (i > 0 && ctxt->dir.name[i - 1] == ' ')
+ {
+ filep--;
+ i--;
+ }
+ }
+ else
+ {
+ for (i = 0; i < 8 && ctxt->dir.name[i]; i++)
+ *filep++ = grub_tolower (ctxt->dir.name[i]);
+ while (i > 0 && ctxt->dir.name[i - 1] == ' ')
+ {
+ filep--;
+ i--;
+ }
+
+ /* 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]);
+ while (i > 8 && ctxt->dir.name[i - 1] == ' ')
+ {
+ filep--;
+ i--;
+ }
+
+ if (i == 8)
+ filep--;
+ }
+ *filep = '\0';
+ return GRUB_ERR_NONE;
+ }
+
+ return grub_errno ? : GRUB_ERR_EOF;
+}
+
+/*
+ * Convert a date and time in FAT format to seconds since the UNIX epoch
+ * according to sections 11.3.5 and 11.3.6 in ECMA-107.
+ * https://www.ecma-international.org/publications/files/ECMA-ST/Ecma-107.pdf
+ */
+static int
+grub_fat_timestamp (grub_uint16_t time, grub_uint16_t date, grub_int64_t *nix) {
+ struct grub_datetime datetime = {
+ .year = (date >> 9) + 1980,
+ .month = (date & 0x01E0) >> 5,
+ .day = (date & 0x001F),
+ .hour = (time >> 11),
+ .minute = (time & 0x07E0) >> 5,
+ .second = (time & 0x001F) * 2,
+ };
+
+ /* The conversion below allows seconds=60, so don't trust its validation. */
+ if ((time & 0x1F) > 29)
+ return 0;
+
+ return grub_datetime2unixtime (&datetime, nix);
+}
+
+#endif
+
+static grub_err_t lookup_file (grub_fshelp_node_t node,
+ const char *name,
+ grub_fshelp_node_t *foundnode,
+ enum grub_fshelp_filetype *foundtype)
+{
+ grub_err_t err;
+ struct grub_fat_iterate_context ctxt;
+
+ err = grub_fat_iterate_init (&ctxt);
+ if (err)
+ return err;
+
+ while (!(err = grub_fat_iterate_dir_next (node, &ctxt)))
+ {
+
+#ifdef MODE_EXFAT
+ if (!ctxt.dir.have_stream)
+ continue;
+#else
+ if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID)
+ continue;
+#endif
+
+ if (grub_strcasecmp (name, ctxt.filename) == 0)
+ {
+ *foundnode = grub_malloc (sizeof (struct grub_fshelp_node));
+ if (!*foundnode)
+ return grub_errno;
+ (*foundnode)->attr = ctxt.dir.attr;
+#ifdef MODE_EXFAT
+ (*foundnode)->file_size = ctxt.dir.file_size;
+ (*foundnode)->file_cluster = ctxt.dir.first_cluster;
+ (*foundnode)->is_contiguous = ctxt.dir.is_contiguous;
+#else
+ (*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
+ (*foundnode)->cur_cluster_num = ~0U;
+ (*foundnode)->data = node->data;
+ (*foundnode)->disk = node->disk;
+
+ *foundtype = ((*foundnode)->attr & GRUB_FAT_ATTR_DIRECTORY) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG;
+
+ grub_fat_iterate_fini (&ctxt);
+ return GRUB_ERR_NONE;
+ }
+ }
+
+ grub_fat_iterate_fini (&ctxt);
+ if (err == GRUB_ERR_EOF)
+ err = 0;
+
+ return err;
+
+}
+
+static grub_err_t
+grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
+ void *hook_data)
+{
+ struct grub_fat_data *data = 0;
+ grub_disk_t disk = device->disk;
+ grub_fshelp_node_t found = NULL;
+ grub_err_t err;
+ struct grub_fat_iterate_context ctxt;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_fat_mount (disk);
+ if (! data)
+ goto fail;
+
+ 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;
+
+ while (!(err = grub_fat_iterate_dir_next (found, &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)
+ continue;
+ info.mtimeset = grub_exfat_timestamp (grub_le_to_cpu32 (ctxt.entry.type_specific.file.m_time),
+ ctxt.entry.type_specific.file.m_time_tenth,
+ &info.mtime);
+#else
+ if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID)
+ continue;
+ info.mtimeset = grub_fat_timestamp (grub_le_to_cpu16 (ctxt.dir.w_time),
+ grub_le_to_cpu16 (ctxt.dir.w_date),
+ &info.mtime);
+#endif
+ if (info.mtimeset == 0)
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "invalid modification timestamp for %s", path);
+
+ if (hook (ctxt.filename, &info, hook_data))
+ break;
+ }
+ grub_fat_iterate_fini (&ctxt);
+ if (err == GRUB_ERR_EOF)
+ err = 0;
+
+ fail:
+ if (found != &root)
+ grub_free (found);
+
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_fat_open (grub_file_t file, const char *name)
+{
+ struct grub_fat_data *data = 0;
+ 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 (disk);
+ if (! data)
+ goto fail;
+
+ 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 (name, &root, &found, lookup_file, NULL, GRUB_FSHELP_REG);
+ if (err)
+ goto fail;
+
+ 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);
+
+ return grub_errno;
+}
+
+static grub_ssize_t
+grub_fat_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ return grub_fat_read_data (file->device->disk, file->data,
+ file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+static grub_err_t
+grub_fat_close (grub_file_t file)
+{
+ grub_fshelp_node_t node = file->data;
+
+ grub_free (node->data);
+ grub_free (node);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+#ifdef MODE_EXFAT
+static grub_err_t
+grub_fat_label (grub_device_t device, char **label)
+{
+ struct grub_fat_dir_entry dir;
+ grub_ssize_t offset = -sizeof(dir);
+ 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,
+ };
+
+ 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, &root, 0, 0,
+ offset, sizeof (dir), (char *) &dir)
+ != sizeof (dir))
+ break;
+
+ if (dir.entry_type == 0)
+ break;
+ if (!(dir.entry_type & 0x80))
+ continue;
+
+ /* Volume label. */
+ if (dir.entry_type == 0x83)
+ {
+ grub_size_t chc;
+ grub_uint16_t t[ARRAY_SIZE (dir.type_specific.volume_label.str)];
+ grub_size_t i;
+ *label = grub_malloc (ARRAY_SIZE (dir.type_specific.volume_label.str)
+ * GRUB_MAX_UTF8_PER_UTF16 + 1);
+ if (!*label)
+ {
+ grub_free (root.data);
+ return grub_errno;
+ }
+ chc = dir.type_specific.volume_label.character_count;
+ if (chc > ARRAY_SIZE (dir.type_specific.volume_label.str))
+ chc = ARRAY_SIZE (dir.type_specific.volume_label.str);
+ for (i = 0; i < chc; i++)
+ t[i] = grub_le_to_cpu16 (dir.type_specific.volume_label.str[i]);
+ *grub_utf16_to_utf8 ((grub_uint8_t *) *label, t, chc) = '\0';
+ }
+ }
+
+ grub_free (root.data);
+ return grub_errno;
+}
+
+#else
+
+static grub_err_t
+grub_fat_label (grub_device_t device, char **label)
+{
+ 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);
+
+ root.data = grub_fat_mount (disk);
+ if (! root.data)
+ goto fail;
+
+ root.file_cluster = root.data->root_cluster;
+
+ err = grub_fat_iterate_init (&ctxt);
+ if (err)
+ goto fail;
+
+ 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);
+ break;
+ }
+
+ grub_fat_iterate_fini (&ctxt);
+
+ fail:
+
+ grub_dl_unref (my_mod);
+
+ grub_free (root.data);
+
+ return grub_errno;
+}
+
+#endif
+
+static grub_err_t
+grub_fat_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_fat_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_fat_mount (disk);
+ if (data)
+ {
+ char *ptr;
+ *uuid = grub_xasprintf ("%04x-%04x",
+ (grub_uint16_t) (data->uuid >> 16),
+ (grub_uint16_t) data->uuid);
+ for (ptr = *uuid; ptr && *ptr; ptr++)
+ *ptr = grub_toupper (*ptr);
+ }
+ else
+ *uuid = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+#ifdef GRUB_UTIL
+#ifndef MODE_EXFAT
+grub_disk_addr_t
+grub_fat_get_cluster_sector (grub_disk_t disk, grub_uint64_t *sec_per_lcn)
+#else
+grub_disk_addr_t
+ grub_exfat_get_cluster_sector (grub_disk_t disk, grub_uint64_t *sec_per_lcn)
+#endif
+{
+ grub_disk_addr_t ret;
+ struct grub_fat_data *data;
+ data = grub_fat_mount (disk);
+ if (!data)
+ return 0;
+ ret = data->cluster_sector;
+
+ *sec_per_lcn = 1ULL << data->cluster_bits;
+
+ grub_free (data);
+ return ret;
+}
+#endif
+
+static struct grub_fs grub_fat_fs =
+ {
+#ifdef MODE_EXFAT
+ .name = "exfat",
+#else
+ .name = "fat",
+#endif
+ .fs_dir = grub_fat_dir,
+ .fs_open = grub_fat_open,
+ .fs_read = grub_fat_read,
+ .fs_close = grub_fat_close,
+ .fs_label = grub_fat_label,
+ .fs_uuid = grub_fat_uuid,
+#ifdef GRUB_UTIL
+#ifdef MODE_EXFAT
+ /* ExFAT BPB is 30 larger than FAT32 one. */
+ .reserved_first_sector = 0,
+#else
+ .reserved_first_sector = 1,
+#endif
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+#ifdef MODE_EXFAT
+GRUB_MOD_INIT(exfat)
+#else
+GRUB_MOD_INIT(fat)
+#endif
+{
+ COMPILE_TIME_ASSERT (sizeof (struct grub_fat_dir_entry) == 32);
+ grub_fs_register (&grub_fat_fs);
+ my_mod = mod;
+}
+#ifdef MODE_EXFAT
+GRUB_MOD_FINI(exfat)
+#else
+GRUB_MOD_FINI(fat)
+#endif
+{
+ grub_fs_unregister (&grub_fat_fs);
+}
+
diff --git a/grub-core/fs/fshelp.c b/grub-core/fs/fshelp.c
new file mode 100644
index 0000000..a2d0d29
--- /dev/null
+++ b/grub-core/fs/fshelp.c
@@ -0,0 +1,441 @@
+/* fshelp.c -- Filesystem helper functions */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2005,2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/fshelp.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+
+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;
+
+ /* Global options. */
+ int symlinknest;
+
+ /* 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)
+ 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_iter_ctx *ctx = data;
+
+ if (filetype == GRUB_FSHELP_UNKNOWN ||
+ ((filetype & GRUB_FSHELP_CASE_INSENSITIVE)
+ ? 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->foundnode = node;
+ *ctx->foundtype = filetype;
+ return 1;
+}
+
+static grub_err_t
+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)
+{
+ 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;
+}
+
+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)
+ {
+ char c;
+ grub_fshelp_node_t foundnode = NULL;
+ enum grub_fshelp_filetype foundtype = 0;
+
+ /* Remove all leading slashes. */
+ while (*name == '/')
+ name++;
+
+ /* Found the node! */
+ if (! *name)
+ return 0;
+
+ /* Extract the actual part from the pathname. */
+ 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->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] == '.')
+ {
+ go_up_a_level (ctx);
+ continue;
+ }
+
+ /* Iterate over the directory. */
+ 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;
+
+ if (err)
+ return err;
+
+ if (!foundnode)
+ break;
+
+ push_node (ctx, foundnode, foundtype);
+
+ /* Read in the symlink and follow it. */
+ if (ctx->currnode->type == GRUB_FSHELP_SYMLINK)
+ {
+ char *symlink;
+
+ /* Test if the symlink does not loop. */
+ if (++ctx->symlinknest == 8)
+ return grub_error (GRUB_ERR_SYMLINK_LOOP,
+ N_("too deep nesting of symlinks"));
+
+ symlink = read_symlink (ctx->currnode->node);
+
+ if (!symlink)
+ return grub_errno;
+
+ /* The symlink is an absolute path, go back to the root inode. */
+ if (symlink[0] == '/')
+ {
+ 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. */
+ find_file (symlink, iterate_dir, lookup_file, read_symlink, ctx);
+ grub_free (symlink);
+
+ if (grub_errno)
+ return grub_errno;
+ }
+ }
+
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
+ ctx->path);
+}
+
+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,
+ .symlinknest = 0,
+ .currnode = 0
+ };
+ grub_err_t err;
+ enum grub_fshelp_filetype foundtype;
+ char *duppath;
+
+ if (!path || path[0] != '/')
+ {
+ return grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
+ }
+
+ 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 && foundtype != expecttype)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
+ 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
+ the DATA argument to READ_HOOK. GET_BLOCK is used to translate
+ file blocks to disk blocks. The file is FILESIZE bytes big and the
+ blocks have a size of LOG2BLOCKSIZE (in log2). */
+grub_ssize_t
+grub_fshelp_read_file (grub_disk_t disk, 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_addr_t (*get_block) (grub_fshelp_node_t node,
+ grub_disk_addr_t block),
+ grub_off_t filesize, int log2blocksize,
+ grub_disk_addr_t blocks_start)
+{
+ grub_disk_addr_t i, blockcnt;
+ int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS);
+
+ /*
+ * Catch blatantly invalid log2blocksize. We could be a lot stricter, but
+ * this is the most permissive we can be before we start to see integer
+ * overflow/underflow issues.
+ */
+ if (log2blocksize + GRUB_DISK_SECTOR_BITS >= 31)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("blocksize too large"));
+ return -1;
+ }
+
+ 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;
+
+ blockcnt = ((len + pos) + blocksize - 1) >> (log2blocksize + GRUB_DISK_SECTOR_BITS);
+
+ for (i = pos >> (log2blocksize + GRUB_DISK_SECTOR_BITS); i < blockcnt; i++)
+ {
+ grub_disk_addr_t blknr;
+ int blockoff = pos & (blocksize - 1);
+ int blockend = blocksize;
+
+ int skipfirst = 0;
+
+ blknr = get_block (node, i);
+ if (grub_errno)
+ return -1;
+
+ blknr = blknr << log2blocksize;
+
+ /* Last block. */
+ if (i == blockcnt - 1)
+ {
+ blockend = (len + pos) & (blocksize - 1);
+
+ /* The last portion is exactly blocksize. */
+ if (! blockend)
+ blockend = blocksize;
+ }
+
+ /* First block. */
+ if (i == (pos >> (log2blocksize + GRUB_DISK_SECTOR_BITS)))
+ {
+ skipfirst = blockoff;
+ blockend -= skipfirst;
+ }
+
+ /* If the block number is 0 this block is not stored on disk but
+ is zero filled instead. */
+ if (blknr)
+ {
+ disk->read_hook = read_hook;
+ disk->read_hook_data = read_hook_data;
+
+ grub_disk_read (disk, blknr + blocks_start, skipfirst,
+ blockend, buf);
+ disk->read_hook = 0;
+ if (grub_errno)
+ return -1;
+ }
+ else
+ grub_memset (buf, 0, blockend);
+
+ buf += blocksize - skipfirst;
+ }
+
+ return len;
+}
diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c
new file mode 100644
index 0000000..f419965
--- /dev/null
+++ b/grub-core/fs/hfs.c
@@ -0,0 +1,1446 @@
+/* hfs.c - HFS. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* HFS is documented at
+ http://developer.apple.com/documentation/mac/Files/Files-2.html */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/hfs.h>
+#include <grub/i18n.h>
+#include <grub/fshelp.h>
+#include <grub/lockdown.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_HFS_SBLOCK 2
+#define GRUB_HFS_EMBED_HFSPLUS_SIG 0x482B
+
+#define GRUB_HFS_BLKS (data->blksz >> 9)
+
+#define GRUB_HFS_NODE_LEAF 0xFF
+
+/* The two supported filesystems a record can have. */
+enum
+ {
+ GRUB_HFS_FILETYPE_DIR = 1,
+ GRUB_HFS_FILETYPE_FILE = 2
+ };
+
+/* Catalog node ID (CNID). */
+enum grub_hfs_cnid_type
+ {
+ GRUB_HFS_CNID_ROOT_PARENT = 1,
+ GRUB_HFS_CNID_ROOT = 2,
+ GRUB_HFS_CNID_EXT = 3,
+ GRUB_HFS_CNID_CAT = 4,
+ GRUB_HFS_CNID_BAD = 5
+ };
+
+/* A node descriptor. This is the header of every node. */
+struct grub_hfs_node
+{
+ grub_uint32_t next;
+ grub_uint32_t prev;
+ grub_uint8_t type;
+ grub_uint8_t level;
+ grub_uint16_t reccnt;
+ grub_uint16_t unused;
+} GRUB_PACKED;
+
+/* The head of the B*-Tree. */
+struct grub_hfs_treeheader
+{
+ grub_uint16_t tree_depth;
+ /* The number of the first node. */
+ grub_uint32_t root_node;
+ grub_uint32_t leaves;
+ grub_uint32_t first_leaf;
+ grub_uint32_t last_leaf;
+ grub_uint16_t node_size;
+ grub_uint16_t key_size;
+ grub_uint32_t nodes;
+ grub_uint32_t free_nodes;
+ grub_uint8_t unused[76];
+} GRUB_PACKED;
+
+/* The state of a mounted HFS filesystem. */
+struct grub_hfs_data
+{
+ struct grub_hfs_sblock sblock;
+ grub_disk_t disk;
+ grub_hfs_datarecord_t extents;
+ int fileid;
+ int size;
+ int ext_root;
+ int ext_size;
+ int cat_root;
+ int cat_size;
+ int blksz;
+ int log2_blksz;
+ int rootdir;
+};
+
+/* The key as used on disk in a catalog tree. This is used to lookup
+ file/directory nodes by parent directory ID and filename. */
+struct grub_hfs_catalog_key
+{
+ grub_uint8_t unused;
+ grub_uint32_t parent_dir;
+
+ /* Filename length. */
+ grub_uint8_t strlen;
+
+ /* Filename. */
+ grub_uint8_t str[31];
+} GRUB_PACKED;
+
+/* The key as used on disk in a extent overflow tree. Using this key
+ the extents can be looked up using a fileid and logical start block
+ as index. */
+struct grub_hfs_extent_key
+{
+ /* The kind of fork. This is used to store meta information like
+ icons, attributes, etc. We will only use the datafork, which is
+ 0. */
+ grub_uint8_t forktype;
+ grub_uint32_t fileid;
+ grub_uint16_t first_block;
+} GRUB_PACKED;
+
+/* A directory record. This is used to find out the directory ID. */
+struct grub_hfs_dirrec
+{
+ /* For a directory, type == 1. */
+ grub_uint8_t type;
+ grub_uint8_t unused[5];
+ grub_uint32_t dirid;
+ grub_uint32_t ctime;
+ grub_uint32_t mtime;
+} GRUB_PACKED;
+
+/* Information about a file. */
+struct grub_hfs_filerec
+{
+ /* For a file, type == 2. */
+ grub_uint8_t type;
+ grub_uint8_t unused[19];
+ grub_uint32_t fileid;
+ grub_uint8_t unused2[2];
+ grub_uint32_t size;
+ grub_uint8_t unused3[18];
+ grub_uint32_t mtime;
+ grub_uint8_t unused4[22];
+
+ /* The first 3 extents of the file. The other extents can be found
+ in the extent overflow file. */
+ grub_hfs_datarecord_t extents;
+} GRUB_PACKED;
+
+/* A record descriptor, both key and data, used to pass to call back
+ functions. */
+struct grub_hfs_record
+{
+ void *key;
+ grub_size_t keylen;
+ void *data;
+ grub_size_t datalen;
+};
+
+static grub_dl_t my_mod;
+
+static int grub_hfs_find_node (struct grub_hfs_data *, char *,
+ grub_uint32_t, int, char *, grub_size_t);
+
+/* Find block BLOCK of the file FILE in the mounted UFS filesystem
+ DATA. The first 3 extents are described by DAT. If cache is set,
+ using caching to improve non-random reads. */
+static unsigned int
+grub_hfs_block (struct grub_hfs_data *data, grub_hfs_datarecord_t dat,
+ int file, int block, int cache)
+{
+ grub_hfs_datarecord_t dr;
+ int pos = 0;
+ struct grub_hfs_extent_key key;
+
+ int tree = 0;
+ static int cache_file = 0;
+ static int cache_pos = 0;
+ static grub_hfs_datarecord_t cache_dr;
+
+ grub_memcpy (dr, dat, sizeof (dr));
+
+ key.forktype = 0;
+ key.fileid = grub_cpu_to_be32 (file);
+
+ if (cache && cache_file == file && block > cache_pos)
+ {
+ pos = cache_pos;
+ key.first_block = grub_cpu_to_be16 (pos);
+ grub_memcpy (dr, cache_dr, sizeof (cache_dr));
+ }
+
+ for (;;)
+ {
+ int i;
+
+ /* Try all 3 extents. */
+ for (i = 0; i < 3; i++)
+ {
+ /* Check if the block is stored in this extent. */
+ if (grub_be_to_cpu16 (dr[i].count) + pos > block)
+ {
+ int first = grub_be_to_cpu16 (dr[i].first_block);
+
+ /* If the cache is enabled, store the current position
+ in the tree. */
+ if (tree && cache)
+ {
+ cache_file = file;
+ cache_pos = pos;
+ grub_memcpy (cache_dr, dr, sizeof (cache_dr));
+ }
+
+ return (grub_be_to_cpu16 (data->sblock.first_block)
+ + (first + block - pos) * GRUB_HFS_BLKS);
+ }
+
+ /* Try the next extent. */
+ pos += grub_be_to_cpu16 (dr[i].count);
+ }
+
+ /* Lookup the block in the extent overflow file. */
+ key.first_block = grub_cpu_to_be16 (pos);
+ tree = 1;
+ grub_hfs_find_node (data, (char *) &key, data->ext_root,
+ 1, (char *) &dr, sizeof (dr));
+ if (grub_errno)
+ return 0;
+ }
+}
+
+
+/* Read LEN bytes from the file described by DATA starting with byte
+ POS. Return the amount of read bytes in READ. */
+static grub_ssize_t
+grub_hfs_read_file (struct grub_hfs_data *data,
+ grub_disk_read_hook_t read_hook, void *read_hook_data,
+ grub_uint32_t pos, grub_size_t len, char *buf)
+{
+ grub_off_t i;
+ grub_off_t blockcnt;
+
+ /* Files are at most 2G/4G - 1 bytes on hfs. Avoid 64-bit division.
+ Moreover len > 0 as checked in upper layer. */
+ blockcnt = (len + pos - 1) / data->blksz + 1;
+
+ for (i = pos / data->blksz; i < blockcnt; i++)
+ {
+ grub_disk_addr_t blknr;
+ grub_off_t blockoff;
+ grub_off_t blockend = data->blksz;
+
+ int skipfirst = 0;
+
+ blockoff = pos % data->blksz;
+
+ blknr = grub_hfs_block (data, data->extents, data->fileid, i, 1);
+ if (grub_errno)
+ return -1;
+
+ /* Last block. */
+ if (i == blockcnt - 1)
+ {
+ blockend = (len + pos) % data->blksz;
+
+ /* The last portion is exactly EXT2_BLOCK_SIZE (data). */
+ if (! blockend)
+ blockend = data->blksz;
+ }
+
+ /* First block. */
+ if (i == pos / data->blksz)
+ {
+ skipfirst = blockoff;
+ blockend -= skipfirst;
+ }
+
+ /* If the block number is 0 this block is not stored on disk but
+ is zero filled instead. */
+ if (blknr)
+ {
+ data->disk->read_hook = read_hook;
+ data->disk->read_hook_data = read_hook_data;
+ grub_disk_read (data->disk, blknr, skipfirst,
+ blockend, buf);
+ data->disk->read_hook = 0;
+ if (grub_errno)
+ return -1;
+ }
+
+ buf += data->blksz - skipfirst;
+ }
+
+ return len;
+}
+
+
+/* Mount the filesystem on the disk DISK. */
+static struct grub_hfs_data *
+grub_hfs_mount (grub_disk_t disk)
+{
+ struct grub_hfs_data *data;
+ struct grub_hfs_catalog_key key;
+ struct grub_hfs_dirrec dir;
+ int first_block;
+
+ struct
+ {
+ struct grub_hfs_node node;
+ struct grub_hfs_treeheader head;
+ } treehead;
+
+ data = grub_malloc (sizeof (struct grub_hfs_data));
+ if (!data)
+ return 0;
+
+ /* Read the superblock. */
+ if (grub_disk_read (disk, GRUB_HFS_SBLOCK, 0,
+ sizeof (struct grub_hfs_sblock), &data->sblock))
+ goto fail;
+
+ /* 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");
+ goto fail;
+ }
+
+ /* Check if this is an embedded HFS+ filesystem. */
+ if (grub_be_to_cpu16 (data->sblock.embed_sig) == GRUB_HFS_EMBED_HFSPLUS_SIG)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "embedded HFS+ filesystem");
+ goto fail;
+ }
+
+ data->blksz = grub_be_to_cpu32 (data->sblock.blksz);
+ data->disk = disk;
+
+ /* Lookup the root node of the extent overflow tree. */
+ first_block = ((grub_be_to_cpu16 (data->sblock.extent_recs[0].first_block)
+ * GRUB_HFS_BLKS)
+ + grub_be_to_cpu16 (data->sblock.first_block));
+
+ if (grub_disk_read (data->disk, first_block, 0,
+ sizeof (treehead), &treehead))
+ goto fail;
+ data->ext_root = grub_be_to_cpu32 (treehead.head.root_node);
+ data->ext_size = grub_be_to_cpu16 (treehead.head.node_size);
+
+ /* Lookup the root node of the catalog tree. */
+ first_block = ((grub_be_to_cpu16 (data->sblock.catalog_recs[0].first_block)
+ * GRUB_HFS_BLKS)
+ + grub_be_to_cpu16 (data->sblock.first_block));
+ if (grub_disk_read (data->disk, first_block, 0,
+ sizeof (treehead), &treehead))
+ goto fail;
+ 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_compile_time (1);
+ key.strlen = data->sblock.volname[0];
+ grub_strcpy ((char *) key.str, (char *) (data->sblock.volname + 1));
+
+ if (grub_hfs_find_node (data, (char *) &key, data->cat_root,
+ 0, (char *) &dir, sizeof (dir)) == 0)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "cannot find the HFS root directory");
+ goto fail;
+ }
+
+ if (grub_errno)
+ goto fail;
+
+ data->rootdir = grub_be_to_cpu32 (dir.dirid);
+
+ return data;
+ fail:
+ grub_free (data);
+
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not a HFS filesystem");
+
+ return 0;
+}
+
+/* Compare the K1 and K2 catalog file keys using HFS character ordering. */
+static int
+grub_hfs_cmp_catkeys (const struct grub_hfs_catalog_key *k1,
+ const struct grub_hfs_catalog_key *k2)
+{
+ /* Taken from hfsutils 3.2.6 and converted to a readable form */
+ static const unsigned char hfs_charorder[256] = {
+ [0x00] = 0,
+ [0x01] = 1,
+ [0x02] = 2,
+ [0x03] = 3,
+ [0x04] = 4,
+ [0x05] = 5,
+ [0x06] = 6,
+ [0x07] = 7,
+ [0x08] = 8,
+ [0x09] = 9,
+ [0x0A] = 10,
+ [0x0B] = 11,
+ [0x0C] = 12,
+ [0x0D] = 13,
+ [0x0E] = 14,
+ [0x0F] = 15,
+ [0x10] = 16,
+ [0x11] = 17,
+ [0x12] = 18,
+ [0x13] = 19,
+ [0x14] = 20,
+ [0x15] = 21,
+ [0x16] = 22,
+ [0x17] = 23,
+ [0x18] = 24,
+ [0x19] = 25,
+ [0x1A] = 26,
+ [0x1B] = 27,
+ [0x1C] = 28,
+ [0x1D] = 29,
+ [0x1E] = 30,
+ [0x1F] = 31,
+ [' '] = 32, [0xCA] = 32,
+ ['!'] = 33,
+ ['"'] = 34,
+ [0xD2] = 35,
+ [0xD3] = 36,
+ [0xC7] = 37,
+ [0xC8] = 38,
+ ['#'] = 39,
+ ['$'] = 40,
+ ['%'] = 41,
+ ['&'] = 42,
+ ['\''] = 43,
+ [0xD4] = 44,
+ [0xD5] = 45,
+ ['('] = 46,
+ [')'] = 47,
+ ['*'] = 48,
+ ['+'] = 49,
+ [','] = 50,
+ ['-'] = 51,
+ ['.'] = 52,
+ ['/'] = 53,
+ ['0'] = 54,
+ ['1'] = 55,
+ ['2'] = 56,
+ ['3'] = 57,
+ ['4'] = 58,
+ ['5'] = 59,
+ ['6'] = 60,
+ ['7'] = 61,
+ ['8'] = 62,
+ ['9'] = 63,
+ [':'] = 64,
+ [';'] = 65,
+ ['<'] = 66,
+ ['='] = 67,
+ ['>'] = 68,
+ ['?'] = 69,
+ ['@'] = 70,
+ ['A'] = 71, ['a'] = 71,
+ [0x88] = 72, [0xCB] = 72,
+ [0x80] = 73, [0x8A] = 73,
+ [0x8B] = 74, [0xCC] = 74,
+ [0x81] = 75, [0x8C] = 75,
+ [0xAE] = 76, [0xBE] = 76,
+ ['`'] = 77,
+ [0x87] = 78,
+ [0x89] = 79,
+ [0xBB] = 80,
+ ['B'] = 81, ['b'] = 81,
+ ['C'] = 82, ['c'] = 82,
+ [0x82] = 83, [0x8D] = 83,
+ ['D'] = 84, ['d'] = 84,
+ ['E'] = 85, ['e'] = 85,
+ [0x83] = 86, [0x8E] = 86,
+ [0x8F] = 87,
+ [0x90] = 88,
+ [0x91] = 89,
+ ['F'] = 90, ['f'] = 90,
+ ['G'] = 91, ['g'] = 91,
+ ['H'] = 92, ['h'] = 92,
+ ['I'] = 93, ['i'] = 93,
+ [0x92] = 94,
+ [0x93] = 95,
+ [0x94] = 96,
+ [0x95] = 97,
+ ['J'] = 98, ['j'] = 98,
+ ['K'] = 99, ['k'] = 99,
+ ['L'] = 100, ['l'] = 100,
+ ['M'] = 101, ['m'] = 101,
+ ['N'] = 102, ['n'] = 102,
+ [0x84] = 103, [0x96] = 103,
+ ['O'] = 104, ['o'] = 104,
+ [0x85] = 105, [0x9A] = 105,
+ [0x9B] = 106, [0xCD] = 106,
+ [0xAF] = 107, [0xBF] = 107,
+ [0xCE] = 108, [0xCF] = 108,
+ [0x97] = 109,
+ [0x98] = 110,
+ [0x99] = 111,
+ [0xBC] = 112,
+ ['P'] = 113, ['p'] = 113,
+ ['Q'] = 114, ['q'] = 114,
+ ['R'] = 115, ['r'] = 115,
+ ['S'] = 116, ['s'] = 116,
+ [0xA7] = 117,
+ ['T'] = 118, ['t'] = 118,
+ ['U'] = 119, ['u'] = 119,
+ [0x86] = 120, [0x9F] = 120,
+ [0x9C] = 121,
+ [0x9D] = 122,
+ [0x9E] = 123,
+ ['V'] = 124, ['v'] = 124,
+ ['W'] = 125, ['w'] = 125,
+ ['X'] = 126, ['x'] = 126,
+ ['Y'] = 127, ['y'] = 127,
+ [0xD8] = 128,
+ ['Z'] = 129, ['z'] = 129,
+ ['['] = 130,
+ ['\\'] = 131,
+ [']'] = 132,
+ ['^'] = 133,
+ ['_'] = 134,
+ ['{'] = 135,
+ ['|'] = 136,
+ ['}'] = 137,
+ ['~'] = 138,
+ [0x7F] = 139,
+ [0xA0] = 140,
+ [0xA1] = 141,
+ [0xA2] = 142,
+ [0xA3] = 143,
+ [0xA4] = 144,
+ [0xA5] = 145,
+ [0xA6] = 146,
+ [0xA8] = 147,
+ [0xA9] = 148,
+ [0xAA] = 149,
+ [0xAB] = 150,
+ [0xAC] = 151,
+ [0xAD] = 152,
+ [0xB0] = 153,
+ [0xB1] = 154,
+ [0xB2] = 155,
+ [0xB3] = 156,
+ [0xB4] = 157,
+ [0xB5] = 158,
+ [0xB6] = 159,
+ [0xB7] = 160,
+ [0xB8] = 161,
+ [0xB9] = 162,
+ [0xBA] = 163,
+ [0xBD] = 164,
+ [0xC0] = 165,
+ [0xC1] = 166,
+ [0xC2] = 167,
+ [0xC3] = 168,
+ [0xC4] = 169,
+ [0xC5] = 170,
+ [0xC6] = 171,
+ [0xC9] = 172,
+ [0xD0] = 173,
+ [0xD1] = 174,
+ [0xD6] = 175,
+ [0xD7] = 176,
+ [0xD9] = 177,
+ [0xDA] = 178,
+ [0xDB] = 179,
+ [0xDC] = 180,
+ [0xDD] = 181,
+ [0xDE] = 182,
+ [0xDF] = 183,
+ [0xE0] = 184,
+ [0xE1] = 185,
+ [0xE2] = 186,
+ [0xE3] = 187,
+ [0xE4] = 188,
+ [0xE5] = 189,
+ [0xE6] = 190,
+ [0xE7] = 191,
+ [0xE8] = 192,
+ [0xE9] = 193,
+ [0xEA] = 194,
+ [0xEB] = 195,
+ [0xEC] = 196,
+ [0xED] = 197,
+ [0xEE] = 198,
+ [0xEF] = 199,
+ [0xF0] = 200,
+ [0xF1] = 201,
+ [0xF2] = 202,
+ [0xF3] = 203,
+ [0xF4] = 204,
+ [0xF5] = 205,
+ [0xF6] = 206,
+ [0xF7] = 207,
+ [0xF8] = 208,
+ [0xF9] = 209,
+ [0xFA] = 210,
+ [0xFB] = 211,
+ [0xFC] = 212,
+ [0xFD] = 213,
+ [0xFE] = 214,
+ [0xFF] = 215,
+ };
+ int i;
+ int cmp;
+ int minlen = (k1->strlen < k2->strlen) ? k1->strlen : k2->strlen;
+
+ cmp = (grub_be_to_cpu32 (k1->parent_dir) - grub_be_to_cpu32 (k2->parent_dir));
+ if (cmp != 0)
+ return cmp;
+
+ for (i = 0; i < minlen; i++)
+ {
+ cmp = (hfs_charorder[k1->str[i]] - hfs_charorder[k2->str[i]]);
+ if (cmp != 0)
+ return cmp;
+ }
+
+ /* Shorter strings precede long ones. */
+ return (k1->strlen - k2->strlen);
+}
+
+
+/* Compare the K1 and K2 extent overflow file keys. */
+static int
+grub_hfs_cmp_extkeys (const struct grub_hfs_extent_key *k1,
+ const struct grub_hfs_extent_key *k2)
+{
+ int cmp = k1->forktype - k2->forktype;
+ if (cmp == 0)
+ cmp = grub_be_to_cpu32 (k1->fileid) - grub_be_to_cpu32 (k2->fileid);
+ if (cmp == 0)
+ cmp = (grub_be_to_cpu16 (k1->first_block)
+ - grub_be_to_cpu16 (k2->first_block));
+ return cmp;
+}
+
+
+/* Iterate the records in the node with index IDX in the mounted HFS
+ filesystem DATA. This node holds data of the type TYPE (0 =
+ catalog node, 1 = extent overflow node). If this is set, continue
+ iterating to the next node. For every records, call NODE_HOOK. */
+static grub_err_t
+grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
+ int this, int (*node_hook) (struct grub_hfs_node *hnd,
+ struct grub_hfs_record *,
+ void *hook_arg),
+ void *hook_arg)
+{
+ grub_size_t nodesize = type == 0 ? data->cat_size : data->ext_size;
+
+ union node_union
+ {
+ struct grub_hfs_node node;
+ char rawnode[0];
+ grub_uint16_t offsets[0];
+ } *node;
+
+ if (nodesize < sizeof (struct grub_hfs_node))
+ nodesize = sizeof (struct grub_hfs_node);
+
+ node = grub_malloc (nodesize);
+ if (!node)
+ return grub_errno;
+
+ do
+ {
+ int i;
+ struct grub_hfs_extent *dat;
+ int blk;
+ grub_uint16_t reccnt;
+
+ dat = (struct grub_hfs_extent *) (type == 0
+ ? (&data->sblock.catalog_recs)
+ : (&data->sblock.extent_recs));
+
+ /* Read the node into memory. */
+ blk = grub_hfs_block (data, dat,
+ (type == 0) ? GRUB_HFS_CNID_CAT : GRUB_HFS_CNID_EXT,
+ idx / (data->blksz / nodesize), 0);
+ blk += (idx % (data->blksz / nodesize));
+
+ if (grub_errno || grub_disk_read (data->disk, blk, 0,
+ nodesize, node))
+ {
+ grub_free (node);
+ 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 < reccnt; i++)
+ {
+ int pos = (nodesize >> 1) - 1 - i;
+ struct pointer
+ {
+ grub_uint8_t keylen;
+ grub_uint8_t key;
+ } GRUB_PACKED *pnt;
+ 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 - off - pnt->keylen - 1
+ };
+
+ if (node_hook (&node->node, &rec, hook_arg))
+ {
+ grub_free (node);
+ return 0;
+ }
+ }
+
+ idx = grub_be_to_cpu32 (node->node.next);
+ } while (idx && this);
+ grub_free (node);
+ return 0;
+}
+
+struct grub_hfs_find_node_node_found_ctx
+{
+ int found;
+ int isleaf;
+ int done;
+ int type;
+ const char *key;
+ char *datar;
+ grub_size_t datalen;
+};
+
+static int
+grub_hfs_find_node_node_found (struct grub_hfs_node *hnd, struct grub_hfs_record *rec,
+ void *hook_arg)
+{
+ struct grub_hfs_find_node_node_found_ctx *ctx = hook_arg;
+ int cmp = 1;
+
+ if (ctx->type == 0)
+ cmp = grub_hfs_cmp_catkeys (rec->key, (const void *) ctx->key);
+ else
+ cmp = grub_hfs_cmp_extkeys (rec->key, (const void *) ctx->key);
+
+ /* If the key is smaller or equal to the current node, mark the
+ entry. In case of a non-leaf mode it will be used to lookup
+ the rest of the tree. */
+ if (cmp <= 0)
+ ctx->found = grub_be_to_cpu32 (grub_get_unaligned32 (rec->data));
+ else /* The key can not be found in the tree. */
+ return 1;
+
+ /* Check if this node is a leaf node. */
+ if (hnd->type == GRUB_HFS_NODE_LEAF)
+ {
+ ctx->isleaf = 1;
+
+ /* Found it!!!! */
+ if (cmp == 0)
+ {
+ ctx->done = 1;
+
+ grub_memcpy (ctx->datar, rec->data,
+ rec->datalen < ctx->datalen ? rec->datalen : ctx->datalen);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+
+/* Lookup a record in the mounted filesystem DATA using the key KEY.
+ The index of the node on top of the tree is IDX. The tree is of
+ the type TYPE (0 = catalog node, 1 = extent overflow node). Return
+ the data in DATAR with a maximum length of DATALEN. */
+static int
+grub_hfs_find_node (struct grub_hfs_data *data, char *key,
+ grub_uint32_t idx, int type, char *datar, grub_size_t datalen)
+{
+ struct grub_hfs_find_node_node_found_ctx ctx =
+ {
+ .found = -1,
+ .isleaf = 0,
+ .done = 0,
+ .type = type,
+ .key = key,
+ .datar = datar,
+ .datalen = datalen
+ };
+
+ do
+ {
+ ctx.found = -1;
+
+ if (grub_hfs_iterate_records (data, type, idx, 0, grub_hfs_find_node_node_found, &ctx))
+ return 0;
+
+ if (ctx.found == -1)
+ return 0;
+
+ idx = ctx.found;
+ } while (! ctx.isleaf);
+
+ return ctx.done;
+}
+
+struct grub_hfs_iterate_dir_node_found_ctx
+{
+ grub_uint32_t dir_be;
+ int found;
+ int isleaf;
+ grub_uint32_t next;
+ int (*hook) (struct grub_hfs_record *, void *hook_arg);
+ void *hook_arg;
+};
+
+static int
+grub_hfs_iterate_dir_node_found (struct grub_hfs_node *hnd, struct grub_hfs_record *rec,
+ void *hook_arg)
+{
+ struct grub_hfs_iterate_dir_node_found_ctx *ctx = hook_arg;
+ struct grub_hfs_catalog_key *ckey = rec->key;
+
+ /* The lowest key possible with DIR as root directory. */
+ const struct grub_hfs_catalog_key key = {0, ctx->dir_be, 0, ""};
+
+ if (grub_hfs_cmp_catkeys (rec->key, &key) <= 0)
+ ctx->found = grub_be_to_cpu32 (grub_get_unaligned32 (rec->data));
+
+ if (hnd->type == 0xFF && ckey->strlen > 0)
+ {
+ ctx->isleaf = 1;
+ ctx->next = grub_be_to_cpu32 (hnd->next);
+
+ /* An entry was found. */
+ if (ckey->parent_dir == ctx->dir_be)
+ return ctx->hook (rec, ctx->hook_arg);
+ }
+
+ return 0;
+}
+
+static int
+grub_hfs_iterate_dir_it_dir (struct grub_hfs_node *hnd __attribute ((unused)),
+ struct grub_hfs_record *rec,
+ void *hook_arg)
+{
+ struct grub_hfs_catalog_key *ckey = rec->key;
+ struct grub_hfs_iterate_dir_node_found_ctx *ctx = hook_arg;
+
+ /* Stop when the entries do not match anymore. */
+ if (ckey->parent_dir != ctx->dir_be)
+ return 1;
+
+ return ctx->hook (rec, ctx->hook_arg);
+}
+
+
+/* Iterate over the directory with the id DIR. The tree is searched
+ starting with the node ROOT_IDX. For every entry in this directory
+ call HOOK. */
+static grub_err_t
+grub_hfs_iterate_dir (struct grub_hfs_data *data, grub_uint32_t root_idx,
+ grub_uint32_t dir, int (*hook) (struct grub_hfs_record *, void *hook_arg),
+ void *hook_arg)
+{
+ struct grub_hfs_iterate_dir_node_found_ctx ctx =
+ {
+ .dir_be = grub_cpu_to_be32 (dir),
+ .found = -1,
+ .isleaf = 0,
+ .next = 0,
+ .hook = hook,
+ .hook_arg = hook_arg
+ };
+
+ do
+ {
+ ctx.found = -1;
+
+ if (grub_hfs_iterate_records (data, 0, root_idx, 0, grub_hfs_iterate_dir_node_found, &ctx))
+ return grub_errno;
+
+ if (ctx.found == -1)
+ return 0;
+
+ root_idx = ctx.found;
+ } while (! ctx.isleaf);
+
+ /* If there was a matching record in this leaf node, continue the
+ iteration until the last record was found. */
+ grub_hfs_iterate_records (data, 0, ctx.next, 1, grub_hfs_iterate_dir_it_dir, &ctx);
+ return grub_errno;
+}
+
+#define MAX_UTF8_PER_MAC_ROMAN 3
+
+static const char macroman[0x80][MAX_UTF8_PER_MAC_ROMAN + 1] =
+ {
+ /* 80 */ "\xc3\x84",
+ /* 81 */ "\xc3\x85",
+ /* 82 */ "\xc3\x87",
+ /* 83 */ "\xc3\x89",
+ /* 84 */ "\xc3\x91",
+ /* 85 */ "\xc3\x96",
+ /* 86 */ "\xc3\x9c",
+ /* 87 */ "\xc3\xa1",
+ /* 88 */ "\xc3\xa0",
+ /* 89 */ "\xc3\xa2",
+ /* 8A */ "\xc3\xa4",
+ /* 8B */ "\xc3\xa3",
+ /* 8C */ "\xc3\xa5",
+ /* 8D */ "\xc3\xa7",
+ /* 8E */ "\xc3\xa9",
+ /* 8F */ "\xc3\xa8",
+ /* 90 */ "\xc3\xaa",
+ /* 91 */ "\xc3\xab",
+ /* 92 */ "\xc3\xad",
+ /* 93 */ "\xc3\xac",
+ /* 94 */ "\xc3\xae",
+ /* 95 */ "\xc3\xaf",
+ /* 96 */ "\xc3\xb1",
+ /* 97 */ "\xc3\xb3",
+ /* 98 */ "\xc3\xb2",
+ /* 99 */ "\xc3\xb4",
+ /* 9A */ "\xc3\xb6",
+ /* 9B */ "\xc3\xb5",
+ /* 9C */ "\xc3\xba",
+ /* 9D */ "\xc3\xb9",
+ /* 9E */ "\xc3\xbb",
+ /* 9F */ "\xc3\xbc",
+ /* A0 */ "\xe2\x80\xa0",
+ /* A1 */ "\xc2\xb0",
+ /* A2 */ "\xc2\xa2",
+ /* A3 */ "\xc2\xa3",
+ /* A4 */ "\xc2\xa7",
+ /* A5 */ "\xe2\x80\xa2",
+ /* A6 */ "\xc2\xb6",
+ /* A7 */ "\xc3\x9f",
+ /* A8 */ "\xc2\xae",
+ /* A9 */ "\xc2\xa9",
+ /* AA */ "\xe2\x84\xa2",
+ /* AB */ "\xc2\xb4",
+ /* AC */ "\xc2\xa8",
+ /* AD */ "\xe2\x89\xa0",
+ /* AE */ "\xc3\x86",
+ /* AF */ "\xc3\x98",
+ /* B0 */ "\xe2\x88\x9e",
+ /* B1 */ "\xc2\xb1",
+ /* B2 */ "\xe2\x89\xa4",
+ /* B3 */ "\xe2\x89\xa5",
+ /* B4 */ "\xc2\xa5",
+ /* B5 */ "\xc2\xb5",
+ /* B6 */ "\xe2\x88\x82",
+ /* B7 */ "\xe2\x88\x91",
+ /* B8 */ "\xe2\x88\x8f",
+ /* B9 */ "\xcf\x80",
+ /* BA */ "\xe2\x88\xab",
+ /* BB */ "\xc2\xaa",
+ /* BC */ "\xc2\xba",
+ /* BD */ "\xce\xa9",
+ /* BE */ "\xc3\xa6",
+ /* BF */ "\xc3\xb8",
+ /* C0 */ "\xc2\xbf",
+ /* C1 */ "\xc2\xa1",
+ /* C2 */ "\xc2\xac",
+ /* C3 */ "\xe2\x88\x9a",
+ /* C4 */ "\xc6\x92",
+ /* C5 */ "\xe2\x89\x88",
+ /* C6 */ "\xe2\x88\x86",
+ /* C7 */ "\xc2\xab",
+ /* C8 */ "\xc2\xbb",
+ /* C9 */ "\xe2\x80\xa6",
+ /* CA */ "\xc2\xa0",
+ /* CB */ "\xc3\x80",
+ /* CC */ "\xc3\x83",
+ /* CD */ "\xc3\x95",
+ /* CE */ "\xc5\x92",
+ /* CF */ "\xc5\x93",
+ /* D0 */ "\xe2\x80\x93",
+ /* D1 */ "\xe2\x80\x94",
+ /* D2 */ "\xe2\x80\x9c",
+ /* D3 */ "\xe2\x80\x9d",
+ /* D4 */ "\xe2\x80\x98",
+ /* D5 */ "\xe2\x80\x99",
+ /* D6 */ "\xc3\xb7",
+ /* D7 */ "\xe2\x97\x8a",
+ /* D8 */ "\xc3\xbf",
+ /* D9 */ "\xc5\xb8",
+ /* DA */ "\xe2\x81\x84",
+ /* DB */ "\xe2\x82\xac",
+ /* DC */ "\xe2\x80\xb9",
+ /* DD */ "\xe2\x80\xba",
+ /* DE */ "\xef\xac\x81",
+ /* DF */ "\xef\xac\x82",
+ /* E0 */ "\xe2\x80\xa1",
+ /* E1 */ "\xc2\xb7",
+ /* E2 */ "\xe2\x80\x9a",
+ /* E3 */ "\xe2\x80\x9e",
+ /* E4 */ "\xe2\x80\xb0",
+ /* E5 */ "\xc3\x82",
+ /* E6 */ "\xc3\x8a",
+ /* E7 */ "\xc3\x81",
+ /* E8 */ "\xc3\x8b",
+ /* E9 */ "\xc3\x88",
+ /* EA */ "\xc3\x8d",
+ /* EB */ "\xc3\x8e",
+ /* EC */ "\xc3\x8f",
+ /* ED */ "\xc3\x8c",
+ /* EE */ "\xc3\x93",
+ /* EF */ "\xc3\x94",
+ /* F0 */ "\xef\xa3\xbf",
+ /* F1 */ "\xc3\x92",
+ /* F2 */ "\xc3\x9a",
+ /* F3 */ "\xc3\x9b",
+ /* F4 */ "\xc3\x99",
+ /* F5 */ "\xc4\xb1",
+ /* F6 */ "\xcb\x86",
+ /* F7 */ "\xcb\x9c",
+ /* F8 */ "\xc2\xaf",
+ /* F9 */ "\xcb\x98",
+ /* FA */ "\xcb\x99",
+ /* FB */ "\xcb\x9a",
+ /* FC */ "\xc2\xb8",
+ /* FD */ "\xcb\x9d",
+ /* FE */ "\xcb\x9b",
+ /* FF */ "\xcb\x87",
+ };
+
+static void
+macroman_to_utf8 (char *to, const grub_uint8_t *from, grub_size_t len,
+ int translate_slash)
+{
+ char *optr = to;
+ const grub_uint8_t *iptr;
+
+ for (iptr = from; iptr < from + len && *iptr; iptr++)
+ {
+ /* Translate '/' to ':' as per HFS spec. */
+ if (*iptr == '/' && translate_slash)
+ {
+ *optr++ = ':';
+ continue;
+ }
+ if (!(*iptr & 0x80))
+ {
+ *optr++ = *iptr;
+ continue;
+ }
+ optr = grub_stpcpy (optr, macroman[*iptr & 0x7f]);
+ }
+ *optr = 0;
+}
+
+static grub_ssize_t
+utf8_to_macroman (grub_uint8_t *to, const char *from)
+{
+ grub_uint8_t *end = to + 31;
+ grub_uint8_t *optr = to;
+ const char *iptr = from;
+
+ while (*iptr && optr < end)
+ {
+ int i, clen;
+ /* Translate ':' to '/' as per HFS spec. */
+ if (*iptr == ':')
+ {
+ *optr++ = '/';
+ iptr++;
+ continue;
+ }
+ if (!(*iptr & 0x80))
+ {
+ *optr++ = *iptr++;
+ continue;
+ }
+ clen = 2;
+ if ((*iptr & 0xf0) == 0xe0)
+ clen++;
+ for (i = 0; i < 0x80; i++)
+ if (grub_memcmp (macroman[i], iptr, clen) == 0)
+ break;
+ if (i == 0x80)
+ break;
+ *optr++ = i | 0x80;
+ iptr += clen;
+ }
+ /* Too long or not encodable. */
+ if (*iptr)
+ return -1;
+ 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,
+ grub_fshelp_node_t *found,
+ enum grub_fshelp_filetype exptype)
+{
+ struct grub_fshelp_node root = {
+ .data = data,
+ .inode = data->rootdir,
+ .fdrec = {
+ .frec = {
+ .type = GRUB_HFS_FILETYPE_DIR
+ }
+ }
+ };
+ grub_err_t err;
+
+ err = grub_fshelp_find_file_lookup (path, &root, found, lookup_file, NULL, exptype);
+
+ if (&root == *found)
+ {
+ *found = grub_malloc (sizeof (root));
+ if (!*found)
+ return grub_errno;
+ grub_memcpy (*found, &root, sizeof (root));
+ }
+ return err;
+}
+
+struct grub_hfs_dir_hook_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+static int
+grub_hfs_dir_hook (struct grub_hfs_record *rec, void *hook_arg)
+{
+ struct grub_hfs_dir_hook_ctx *ctx = hook_arg;
+ struct grub_hfs_dirrec *drec = rec->data;
+ struct grub_hfs_filerec *frec = rec->data;
+ struct grub_hfs_catalog_key *ckey = rec->key;
+ char fname[sizeof (ckey->str) * MAX_UTF8_PER_MAC_ROMAN + 1];
+ struct grub_dirhook_info info;
+ grub_size_t len;
+
+ grub_memset (fname, 0, sizeof (fname));
+
+ grub_memset (&info, 0, sizeof (info));
+
+ len = ckey->strlen;
+ if (len > sizeof (ckey->str))
+ len = sizeof (ckey->str);
+ macroman_to_utf8 (fname, ckey->str, len, 1);
+
+ info.case_insensitive = 1;
+
+ if (drec->type == GRUB_HFS_FILETYPE_DIR)
+ {
+ info.dir = 1;
+ info.mtimeset = 1;
+ info.inodeset = 1;
+ info.mtime = grub_be_to_cpu32 (drec->mtime) - 2082844800;
+ info.inode = grub_be_to_cpu32 (drec->dirid);
+ return ctx->hook (fname, &info, ctx->hook_data);
+ }
+ if (frec->type == GRUB_HFS_FILETYPE_FILE)
+ {
+ info.dir = 0;
+ info.mtimeset = 1;
+ info.inodeset = 1;
+ info.mtime = grub_be_to_cpu32 (frec->mtime) - 2082844800;
+ info.inode = grub_be_to_cpu32 (frec->fileid);
+ return ctx->hook (fname, &info, ctx->hook_data);
+ }
+
+ return 0;
+}
+
+
+static grub_err_t
+grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
+ void *hook_data)
+{
+ struct grub_hfs_data *data;
+ 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);
+ if (!data)
+ goto fail;
+
+ /* First the directory ID for the directory. */
+ if (grub_hfs_find_dir (data, path, &found, GRUB_FSHELP_DIR))
+ goto fail;
+
+ 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);
+
+ return grub_errno;
+}
+
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_hfs_open (struct grub_file *file, const char *name)
+{
+ struct grub_hfs_data *data;
+ grub_fshelp_node_t found = NULL;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_hfs_mount (file->device->disk);
+
+ if (!data)
+ {
+ grub_dl_unref (my_mod);
+ return grub_errno;
+ }
+
+ if (grub_hfs_find_dir (data, name, &found, GRUB_FSHELP_REG))
+ {
+ grub_free (data);
+ grub_free (found);
+ grub_dl_unref (my_mod);
+ return grub_errno;
+ }
+
+ 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;
+}
+
+static grub_ssize_t
+grub_hfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_hfs_data *data =
+ (struct grub_hfs_data *) file->data;
+
+ return grub_hfs_read_file (data, file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+
+static grub_err_t
+grub_hfs_close (grub_file_t file)
+{
+ grub_free (file->data);
+
+ grub_dl_unref (my_mod);
+
+ return 0;
+}
+
+
+static grub_err_t
+grub_hfs_label (grub_device_t device, char **label)
+{
+ struct grub_hfs_data *data;
+
+ data = grub_hfs_mount (device->disk);
+
+ if (data)
+ {
+ grub_size_t len = data->sblock.volname[0];
+ if (len > sizeof (data->sblock.volname) - 1)
+ len = sizeof (data->sblock.volname) - 1;
+ *label = grub_calloc (MAX_UTF8_PER_MAC_ROMAN + 1, len);
+ if (*label)
+ macroman_to_utf8 (*label, data->sblock.volname + 1,
+ len + 1, 0);
+ }
+ else
+ *label = 0;
+
+ grub_free (data);
+ return grub_errno;
+}
+
+static grub_err_t
+grub_hfs_mtime (grub_device_t device, grub_int64_t *tm)
+{
+ struct grub_hfs_data *data;
+
+ data = grub_hfs_mount (device->disk);
+
+ if (data)
+ *tm = grub_be_to_cpu32 (data->sblock.mtime) - 2082844800;
+ else
+ *tm = 0;
+
+ grub_free (data);
+ return grub_errno;
+}
+
+static grub_err_t
+grub_hfs_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_hfs_data *data;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_hfs_mount (device->disk);
+ if (data && data->sblock.num_serial != 0)
+ {
+ *uuid = grub_xasprintf ("%016llx",
+ (unsigned long long)
+ grub_be_to_cpu64 (data->sblock.num_serial));
+ }
+ else
+ *uuid = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+
+static struct grub_fs grub_hfs_fs =
+ {
+ .name = "hfs",
+ .fs_dir = grub_hfs_dir,
+ .fs_open = grub_hfs_open,
+ .fs_read = grub_hfs_read,
+ .fs_close = grub_hfs_close,
+ .fs_label = grub_hfs_label,
+ .fs_uuid = grub_hfs_uuid,
+ .fs_mtime = grub_hfs_mtime,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(hfs)
+{
+ if (!grub_is_lockdown ())
+ grub_fs_register (&grub_hfs_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(hfs)
+{
+ if (!grub_is_lockdown())
+ grub_fs_unregister (&grub_hfs_fs);
+}
diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c
new file mode 100644
index 0000000..19c7b33
--- /dev/null
+++ b/grub-core/fs/hfsplus.c
@@ -0,0 +1,1160 @@
+/* hfsplus.c - HFS+ Filesystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* HFS+ is documented at http://developer.apple.com/technotes/tn/tn1150.html */
+
+#define grub_fshelp_node grub_hfsplus_file
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+#include <grub/hfs.h>
+#include <grub/charset.h>
+#include <grub/hfsplus.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* The type of node. */
+enum grub_hfsplus_btnode_type
+ {
+ GRUB_HFSPLUS_BTNODE_TYPE_LEAF = -1,
+ GRUB_HFSPLUS_BTNODE_TYPE_INDEX = 0,
+ GRUB_HFSPLUS_BTNODE_TYPE_HEADER = 1,
+ GRUB_HFSPLUS_BTNODE_TYPE_MAP = 2,
+ };
+
+/* The header of a HFS+ B+ Tree. */
+struct grub_hfsplus_btheader
+{
+ grub_uint16_t depth;
+ grub_uint32_t root;
+ grub_uint32_t leaf_records;
+ grub_uint32_t first_leaf_node;
+ grub_uint32_t last_leaf_node;
+ grub_uint16_t nodesize;
+ grub_uint16_t keysize;
+ grub_uint32_t total_nodes;
+ grub_uint32_t free_nodes;
+ grub_uint16_t reserved1;
+ grub_uint32_t clump_size; /* ignored */
+ grub_uint8_t btree_type;
+ grub_uint8_t key_compare;
+ grub_uint32_t attributes;
+} GRUB_PACKED;
+
+struct grub_hfsplus_catfile
+{
+ grub_uint16_t type;
+ grub_uint16_t flags;
+ grub_uint32_t parentid; /* Thread only. */
+ grub_uint32_t fileid;
+ grub_uint8_t unused1[4];
+ grub_uint32_t mtime;
+ grub_uint8_t unused2[22];
+ grub_uint16_t mode;
+ grub_uint8_t unused3[44];
+ struct grub_hfsplus_forkdata data;
+ struct grub_hfsplus_forkdata resource;
+} GRUB_PACKED;
+
+/* Filetype information as used in inodes. */
+#define GRUB_HFSPLUS_FILEMODE_MASK 0170000
+#define GRUB_HFSPLUS_FILEMODE_REG 0100000
+#define GRUB_HFSPLUS_FILEMODE_DIRECTORY 0040000
+#define GRUB_HFSPLUS_FILEMODE_SYMLINK 0120000
+
+/* Some pre-defined file IDs. */
+enum
+ {
+ GRUB_HFSPLUS_FILEID_ROOTDIR = 2,
+ GRUB_HFSPLUS_FILEID_OVERFLOW = 3,
+ GRUB_HFSPLUS_FILEID_CATALOG = 4,
+ GRUB_HFSPLUS_FILEID_ATTR = 8
+ };
+
+enum grub_hfsplus_filetype
+ {
+ GRUB_HFSPLUS_FILETYPE_DIR = 1,
+ GRUB_HFSPLUS_FILETYPE_REG = 2,
+ GRUB_HFSPLUS_FILETYPE_DIR_THREAD = 3,
+ GRUB_HFSPLUS_FILETYPE_REG_THREAD = 4
+ };
+
+#define GRUB_HFSPLUSX_BINARYCOMPARE 0xBC
+#define GRUB_HFSPLUSX_CASEFOLDING 0xCF
+
+static grub_dl_t my_mod;
+
+
+
+grub_err_t (*grub_hfsplus_open_compressed) (struct grub_fshelp_node *node);
+grub_ssize_t (*grub_hfsplus_read_compressed) (struct grub_hfsplus_file *node,
+ grub_off_t pos,
+ grub_size_t len,
+ char *buf);
+
+/* Find the extent that points to FILEBLOCK. If it is not in one of
+ the 8 extents described by EXTENT, return -1. In that case set
+ FILEBLOCK to the next block. */
+static grub_disk_addr_t
+grub_hfsplus_find_block (struct grub_hfsplus_extent *extent,
+ grub_disk_addr_t *fileblock)
+{
+ int i;
+ grub_disk_addr_t blksleft = *fileblock;
+
+ /* First lookup the file in the given extents. */
+ for (i = 0; i < 8; i++)
+ {
+ if (blksleft < grub_be_to_cpu32 (extent[i].count))
+ return grub_be_to_cpu32 (extent[i].start) + blksleft;
+ blksleft -= grub_be_to_cpu32 (extent[i].count);
+ }
+
+ *fileblock = blksleft;
+ return 0xffffffffffffffffULL;
+}
+
+static int grub_hfsplus_cmp_extkey (struct grub_hfsplus_key *keya,
+ struct grub_hfsplus_key_internal *keyb);
+
+/* Search for the block FILEBLOCK inside the file NODE. Return the
+ blocknumber of this block on disk. */
+static grub_disk_addr_t
+grub_hfsplus_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
+{
+ struct grub_hfsplus_btnode *nnode = 0;
+ grub_disk_addr_t blksleft = fileblock;
+ struct grub_hfsplus_extent *extents = node->compressed
+ ? &node->resource_extents[0] : &node->extents[0];
+
+ while (1)
+ {
+ struct grub_hfsplus_extkey *key;
+ struct grub_hfsplus_key_internal extoverflow;
+ grub_disk_addr_t blk;
+ grub_off_t ptr;
+
+ /* Try to find this block in the current set of extents. */
+ blk = grub_hfsplus_find_block (extents, &blksleft);
+
+ /* The previous iteration of this loop allocated memory. The
+ code above used this memory, it can be freed now. */
+ grub_free (nnode);
+ nnode = 0;
+
+ if (blk != 0xffffffffffffffffULL)
+ return blk;
+
+ /* For the extent overflow file, extra extents can't be found in
+ the extent overflow file. If this happens, you found a
+ bug... */
+ if (node->fileid == GRUB_HFSPLUS_FILEID_OVERFLOW)
+ {
+ grub_error (GRUB_ERR_READ_ERROR,
+ "extra extents found in an extend overflow file");
+ break;
+ }
+
+ /*
+ * If the extent overflow tree isn't ready yet, we can't look
+ * in it. This can happen where the catalog file is corrupted.
+ */
+ if (!node->data->extoverflow_tree_ready)
+ {
+ grub_error (GRUB_ERR_BAD_FS,
+ "attempted to read extent overflow tree before loading");
+ break;
+ }
+
+ /* Set up the key to look for in the extent overflow file. */
+ extoverflow.extkey.fileid = node->fileid;
+ extoverflow.extkey.type = 0;
+ extoverflow.extkey.start = fileblock - blksleft;
+ extoverflow.extkey.type = node->compressed ? 0xff : 0;
+ if (grub_hfsplus_btree_search (&node->data->extoverflow_tree,
+ &extoverflow,
+ grub_hfsplus_cmp_extkey, &nnode, &ptr)
+ || !nnode)
+ {
+ grub_error (GRUB_ERR_READ_ERROR,
+ "no block found for the file id 0x%x and the block"
+ " offset 0x%" PRIuGRUB_UINT64_T,
+ node->fileid, fileblock);
+ break;
+ }
+
+ /* The extent overflow file has 8 extents right after the key. */
+ key = (struct grub_hfsplus_extkey *)
+ grub_hfsplus_btree_recptr (&node->data->extoverflow_tree, nnode, ptr);
+ extents = (struct grub_hfsplus_extent *) (key + 1);
+
+ /* The block wasn't found. Perhaps the next iteration will find
+ it. The last block we found is stored in BLKSLEFT now. */
+ }
+
+ grub_free (nnode);
+
+ /* Too bad, you lose. */
+ return -1;
+}
+
+
+/* Read LEN bytes from the file described by DATA starting with byte
+ POS. Return the amount of read bytes in READ. */
+grub_ssize_t
+grub_hfsplus_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)
+{
+ return grub_fshelp_read_file (node->data->disk, node,
+ read_hook, read_hook_data,
+ pos, len, buf, grub_hfsplus_read_block,
+ node->size,
+ node->data->log2blksize - GRUB_DISK_SECTOR_BITS,
+ node->data->embedded_offset);
+}
+
+static struct grub_hfsplus_data *
+grub_hfsplus_mount (grub_disk_t disk)
+{
+ struct grub_hfsplus_data *data;
+ struct grub_hfsplus_btheader header;
+ struct grub_hfsplus_btnode node;
+ grub_uint16_t magic;
+ union {
+ struct grub_hfs_sblock hfs;
+ struct grub_hfsplus_volheader hfsplus;
+ } volheader;
+
+ data = grub_malloc (sizeof (*data));
+ if (!data)
+ return 0;
+
+ data->disk = disk;
+ data->extoverflow_tree_ready = 0;
+
+ /* Read the bootblock. */
+ grub_disk_read (disk, GRUB_HFSPLUS_SBLOCK, 0, sizeof (volheader),
+ &volheader);
+ if (grub_errno)
+ goto fail;
+
+ data->embedded_offset = 0;
+ if (grub_be_to_cpu16 (volheader.hfs.magic) == GRUB_HFS_MAGIC)
+ {
+ grub_disk_addr_t extent_start;
+ grub_disk_addr_t ablk_size;
+ grub_disk_addr_t ablk_start;
+
+ /* See if there's an embedded HFS+ filesystem. */
+ if (grub_be_to_cpu16 (volheader.hfs.embed_sig) != GRUB_HFSPLUS_MAGIC)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not a HFS+ filesystem");
+ goto fail;
+ }
+
+ /* Calculate the offset needed to translate HFS+ sector numbers. */
+ extent_start = grub_be_to_cpu16 (volheader.hfs.embed_extent.first_block);
+ ablk_size = grub_be_to_cpu32 (volheader.hfs.blksz);
+ ablk_start = grub_be_to_cpu16 (volheader.hfs.first_block);
+ data->embedded_offset = (ablk_start
+ + extent_start
+ * (ablk_size >> GRUB_DISK_SECTOR_BITS));
+
+ grub_disk_read (disk, data->embedded_offset + GRUB_HFSPLUS_SBLOCK, 0,
+ sizeof (volheader), &volheader);
+ if (grub_errno)
+ goto fail;
+ }
+
+ /* Make sure this is an HFS+ filesystem. XXX: Do we really support
+ HFX? */
+ magic = grub_be_to_cpu16 (volheader.hfsplus.magic);
+ if (((magic != GRUB_HFSPLUS_MAGIC) && (magic != GRUB_HFSPLUSX_MAGIC))
+ || volheader.hfsplus.blksize == 0
+ || ((volheader.hfsplus.blksize & (volheader.hfsplus.blksize - 1)) != 0)
+ || grub_be_to_cpu32 (volheader.hfsplus.blksize) < GRUB_DISK_SECTOR_SIZE)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not a HFS+ filesystem");
+ goto fail;
+ }
+
+ grub_memcpy (&data->volheader, &volheader.hfsplus,
+ sizeof (volheader.hfsplus));
+
+ for (data->log2blksize = 0;
+ (1U << data->log2blksize) < grub_be_to_cpu32 (data->volheader.blksize);
+ data->log2blksize++);
+
+ /* Make a new node for the catalog tree. */
+ data->catalog_tree.file.data = data;
+ data->catalog_tree.file.fileid = GRUB_HFSPLUS_FILEID_CATALOG;
+ data->catalog_tree.file.compressed = 0;
+ grub_memcpy (&data->catalog_tree.file.extents,
+ data->volheader.catalog_file.extents,
+ sizeof data->volheader.catalog_file.extents);
+ data->catalog_tree.file.size =
+ grub_be_to_cpu64 (data->volheader.catalog_file.size);
+
+ data->attr_tree.file.data = data;
+ data->attr_tree.file.fileid = GRUB_HFSPLUS_FILEID_ATTR;
+ grub_memcpy (&data->attr_tree.file.extents,
+ data->volheader.attr_file.extents,
+ sizeof data->volheader.attr_file.extents);
+
+ data->attr_tree.file.size =
+ grub_be_to_cpu64 (data->volheader.attr_file.size);
+ data->attr_tree.file.compressed = 0;
+
+ /* Make a new node for the extent overflow file. */
+ data->extoverflow_tree.file.data = data;
+ data->extoverflow_tree.file.fileid = GRUB_HFSPLUS_FILEID_OVERFLOW;
+ data->extoverflow_tree.file.compressed = 0;
+ grub_memcpy (&data->extoverflow_tree.file.extents,
+ data->volheader.extents_file.extents,
+ sizeof data->volheader.catalog_file.extents);
+
+ data->extoverflow_tree.file.size =
+ grub_be_to_cpu64 (data->volheader.extents_file.size);
+
+ /* Read the essential information about the trees. */
+ if (grub_hfsplus_read_file (&data->catalog_tree.file, 0, 0,
+ sizeof (struct grub_hfsplus_btnode),
+ sizeof (header), (char *) &header) <= 0)
+ goto fail;
+
+ data->catalog_tree.root = grub_be_to_cpu32 (header.root);
+ data->catalog_tree.nodesize = grub_be_to_cpu16 (header.nodesize);
+ 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)
+ goto fail;
+
+ data->extoverflow_tree.root = grub_be_to_cpu32 (header.root);
+
+ if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0, 0,
+ sizeof (node), (char *) &node) <= 0)
+ goto fail;
+
+ 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;
+
+ data->extoverflow_tree_ready = 1;
+
+ if (grub_hfsplus_read_file (&data->attr_tree.file, 0, 0,
+ sizeof (struct grub_hfsplus_btnode),
+ sizeof (header), (char *) &header) <= 0)
+ {
+ grub_errno = 0;
+ data->attr_tree.root = 0;
+ data->attr_tree.nodesize = 0;
+ }
+ else
+ {
+ data->attr_tree.root = grub_be_to_cpu32 (header.root);
+ data->attr_tree.nodesize = grub_be_to_cpu16 (header.nodesize);
+ }
+
+ data->dirroot.data = data;
+ data->dirroot.fileid = GRUB_HFSPLUS_FILEID_ROOTDIR;
+
+ return data;
+
+ fail:
+
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not a HFS+ filesystem");
+
+ grub_free (data);
+ return 0;
+}
+
+/* Compare the on disk catalog key KEYA with the catalog key we are
+ looking for (KEYB). */
+static int
+grub_hfsplus_cmp_catkey (struct grub_hfsplus_key *keya,
+ struct grub_hfsplus_key_internal *keyb)
+{
+ struct grub_hfsplus_catkey *catkey_a = &keya->catkey;
+ struct grub_hfsplus_catkey_internal *catkey_b = &keyb->catkey;
+ int diff;
+ grub_size_t len;
+
+ /* Safe unsigned comparison */
+ grub_uint32_t aparent = grub_be_to_cpu32 (catkey_a->parent);
+ if (aparent > catkey_b->parent)
+ return 1;
+ if (aparent < catkey_b->parent)
+ return -1;
+
+ len = grub_be_to_cpu16 (catkey_a->namelen);
+ if (len > catkey_b->namelen)
+ len = catkey_b->namelen;
+ /* Since it's big-endian memcmp gives the same result as manually comparing
+ uint16_t but may be faster. */
+ diff = grub_memcmp (catkey_a->name, catkey_b->name,
+ len * sizeof (catkey_a->name[0]));
+ if (diff == 0)
+ diff = grub_be_to_cpu16 (catkey_a->namelen) - catkey_b->namelen;
+
+ return diff;
+}
+
+/* Compare the on disk catalog key KEYA with the catalog key we are
+ looking for (KEYB). */
+static int
+grub_hfsplus_cmp_catkey_id (struct grub_hfsplus_key *keya,
+ struct grub_hfsplus_key_internal *keyb)
+{
+ struct grub_hfsplus_catkey *catkey_a = &keya->catkey;
+ struct grub_hfsplus_catkey_internal *catkey_b = &keyb->catkey;
+
+ /* Safe unsigned comparison */
+ grub_uint32_t aparent = grub_be_to_cpu32 (catkey_a->parent);
+ if (aparent > catkey_b->parent)
+ return 1;
+ if (aparent < catkey_b->parent)
+ return -1;
+
+ return 0;
+}
+
+/* Compare the on disk extent overflow key KEYA with the extent
+ overflow key we are looking for (KEYB). */
+static int
+grub_hfsplus_cmp_extkey (struct grub_hfsplus_key *keya,
+ struct grub_hfsplus_key_internal *keyb)
+{
+ struct grub_hfsplus_extkey *extkey_a = &keya->extkey;
+ struct grub_hfsplus_extkey_internal *extkey_b = &keyb->extkey;
+ grub_uint32_t akey;
+
+ /* Safe unsigned comparison */
+ akey = grub_be_to_cpu32 (extkey_a->fileid);
+ if (akey > extkey_b->fileid)
+ return 1;
+ if (akey < extkey_b->fileid)
+ return -1;
+
+ if (extkey_a->type > extkey_b->type)
+ return 1;
+ if (extkey_a->type < extkey_b->type)
+ return -1;
+
+ if (extkey_a->type > extkey_b->type)
+ return +1;
+
+ if (extkey_a->type < extkey_b->type)
+ return -1;
+
+ akey = grub_be_to_cpu32 (extkey_a->start);
+ if (akey > extkey_b->start)
+ return 1;
+ if (akey < extkey_b->start)
+ return -1;
+ return 0;
+}
+
+static char *
+grub_hfsplus_read_symlink (grub_fshelp_node_t node)
+{
+ char *symlink;
+ grub_ssize_t numread;
+ grub_size_t sz = node->size;
+
+ if (grub_add (sz, 1, &sz))
+ return NULL;
+
+ symlink = grub_malloc (sz);
+ if (!symlink)
+ return 0;
+
+ numread = grub_hfsplus_read_file (node, 0, 0, 0, node->size, symlink);
+ if (numread != (grub_ssize_t) node->size)
+ {
+ grub_free (symlink);
+ return 0;
+ }
+ symlink[node->size] = '\0';
+
+ return symlink;
+}
+
+static int
+grub_hfsplus_btree_iterate_node (struct grub_hfsplus_btree *btree,
+ struct grub_hfsplus_btnode *first_node,
+ grub_disk_addr_t first_rec,
+ int (*hook) (void *record, void *hook_arg),
+ void *hook_arg)
+{
+ grub_disk_addr_t rec;
+ grub_uint64_t saved_node = -1;
+ grub_uint64_t node_count = 0;
+
+ for (;;)
+ {
+ char *cnode = (char *) first_node;
+
+ /* Iterate over all records in this node. */
+ for (rec = first_rec; rec < grub_be_to_cpu16 (first_node->count); rec++)
+ {
+ if (hook (grub_hfsplus_btree_recptr (btree, first_node, rec), hook_arg))
+ return 1;
+ }
+
+ if (! first_node->next)
+ break;
+
+ if (node_count && first_node->next == saved_node)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "HFS+ btree loop");
+ return 0;
+ }
+ if (!(node_count & (node_count - 1)))
+ saved_node = first_node->next;
+ node_count++;
+
+ if (grub_hfsplus_read_file (&btree->file, 0, 0,
+ (((grub_disk_addr_t)
+ grub_be_to_cpu32 (first_node->next))
+ * btree->nodesize),
+ btree->nodesize, cnode) <= 0)
+ return 1;
+
+ /* Don't skip any record in the next iteration. */
+ first_rec = 0;
+ }
+
+ return 0;
+}
+
+/* Lookup the node described by KEY in the B+ Tree BTREE. Compare
+ keys using the function COMPARE_KEYS. When a match is found,
+ return the node in MATCHNODE and a pointer to the data in this node
+ in KEYOFFSET. MATCHNODE should be freed by the caller. */
+grub_err_t
+grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
+ struct grub_hfsplus_key_internal *key,
+ int (*compare_keys) (struct grub_hfsplus_key *keya,
+ struct grub_hfsplus_key_internal *keyb),
+ struct grub_hfsplus_btnode **matchnode,
+ grub_off_t *keyoffset)
+{
+ grub_uint64_t currnode;
+ char *node;
+ struct grub_hfsplus_btnode *nodedesc;
+ grub_disk_addr_t rec;
+ grub_uint64_t save_node;
+ grub_uint64_t node_count = 0;
+
+ if (!btree->nodesize)
+ {
+ *matchnode = 0;
+ return 0;
+ }
+
+ node = grub_malloc (btree->nodesize);
+ if (! node)
+ return grub_errno;
+
+ currnode = btree->root;
+ save_node = currnode - 1;
+ while (1)
+ {
+ int match = 0;
+
+ if (save_node == currnode)
+ {
+ grub_free (node);
+ return grub_error (GRUB_ERR_BAD_FS, "HFS+ btree loop");
+ }
+ if (!(node_count & (node_count - 1)))
+ save_node = currnode;
+ node_count++;
+
+ /* Read a node. */
+ if (grub_hfsplus_read_file (&btree->file, 0, 0,
+ (grub_disk_addr_t) currnode
+ * (grub_disk_addr_t) btree->nodesize,
+ btree->nodesize, (char *) node) <= 0)
+ {
+ grub_free (node);
+ return grub_error (GRUB_ERR_BAD_FS, "couldn't read i-node");
+ }
+
+ nodedesc = (struct grub_hfsplus_btnode *) node;
+
+ /* Find the record in this tree. */
+ for (rec = 0; rec < grub_be_to_cpu16 (nodedesc->count); rec++)
+ {
+ struct grub_hfsplus_key *currkey;
+ currkey = grub_hfsplus_btree_recptr (btree, nodedesc, rec);
+
+ /* The action that has to be taken depend on the type of
+ record. */
+ if (nodedesc->type == GRUB_HFSPLUS_BTNODE_TYPE_LEAF
+ && compare_keys (currkey, key) == 0)
+ {
+ /* An exact match was found! */
+
+ *matchnode = nodedesc;
+ *keyoffset = rec;
+
+ return 0;
+ }
+ else if (nodedesc->type == GRUB_HFSPLUS_BTNODE_TYPE_INDEX)
+ {
+ void *pointer;
+
+ /* The place where the key could have been found didn't
+ contain the key. This means that the previous match
+ is the one that should be followed. */
+ if (compare_keys (currkey, key) > 0)
+ break;
+
+ /* Mark the last key which is lower or equal to the key
+ that we are looking for. The last match that is
+ found will be used to locate the child which can
+ contain the record. */
+ pointer = ((char *) currkey
+ + grub_be_to_cpu16 (currkey->keylen)
+ + 2);
+
+ if ((char *) pointer > node + btree->nodesize - 2)
+ return grub_error (GRUB_ERR_BAD_FS, "HFS+ key beyond end of node");
+
+ currnode = grub_be_to_cpu32 (grub_get_unaligned32 (pointer));
+ match = 1;
+ }
+ }
+
+ /* No match is found, no record with this key exists in the
+ tree. */
+ if (! match)
+ {
+ *matchnode = 0;
+ grub_free (node);
+ return 0;
+ }
+ }
+}
+
+struct list_nodes_ctx
+{
+ int ret;
+ grub_fshelp_node_t dir;
+ grub_fshelp_iterate_dir_hook_t hook;
+ void *hook_data;
+};
+
+static int
+list_nodes (void *record, void *hook_arg)
+{
+ struct grub_hfsplus_catkey *catkey;
+ char *filename;
+ int i;
+ struct grub_fshelp_node *node;
+ grub_uint16_t *keyname;
+ struct grub_hfsplus_catfile *fileinfo;
+ enum grub_fshelp_filetype type = GRUB_FSHELP_UNKNOWN;
+ struct list_nodes_ctx *ctx = hook_arg;
+
+ catkey = (struct grub_hfsplus_catkey *) record;
+
+ fileinfo =
+ (struct grub_hfsplus_catfile *) ((char *) record
+ + grub_be_to_cpu16 (catkey->keylen)
+ + 2 + (grub_be_to_cpu16(catkey->keylen)
+ % 2));
+
+ /* Stop iterating when the last directory entry is found. */
+ if (grub_be_to_cpu32 (catkey->parent) != ctx->dir->fileid)
+ return 1;
+
+ /* Determine the type of the node that is found. */
+ switch (fileinfo->type)
+ {
+ case grub_cpu_to_be16_compile_time (GRUB_HFSPLUS_FILETYPE_REG):
+ {
+ int mode = (grub_be_to_cpu16 (fileinfo->mode)
+ & GRUB_HFSPLUS_FILEMODE_MASK);
+
+ if (mode == GRUB_HFSPLUS_FILEMODE_REG)
+ type = GRUB_FSHELP_REG;
+ else if (mode == GRUB_HFSPLUS_FILEMODE_SYMLINK)
+ type = GRUB_FSHELP_SYMLINK;
+ else
+ type = GRUB_FSHELP_UNKNOWN;
+ break;
+ }
+ case grub_cpu_to_be16_compile_time (GRUB_HFSPLUS_FILETYPE_DIR):
+ type = GRUB_FSHELP_DIR;
+ break;
+ case grub_cpu_to_be16_compile_time (GRUB_HFSPLUS_FILETYPE_DIR_THREAD):
+ if (ctx->dir->fileid == 2)
+ return 0;
+ node = grub_malloc (sizeof (*node));
+ if (!node)
+ return 1;
+ node->data = ctx->dir->data;
+ node->mtime = 0;
+ node->size = 0;
+ node->fileid = grub_be_to_cpu32 (fileinfo->parentid);
+
+ ctx->ret = ctx->hook ("..", GRUB_FSHELP_DIR, node, ctx->hook_data);
+ return ctx->ret;
+ }
+
+ if (type == GRUB_FSHELP_UNKNOWN)
+ return 0;
+
+ filename = grub_calloc (grub_be_to_cpu16 (catkey->namelen),
+ GRUB_MAX_UTF8_PER_UTF16 + 1);
+ if (! filename)
+ return 0;
+
+ keyname = grub_calloc (grub_be_to_cpu16 (catkey->namelen), sizeof (*keyname));
+ if (!keyname)
+ {
+ grub_free (filename);
+ return 0;
+ }
+
+ /* Make sure the byte order of the UTF16 string is correct. */
+ for (i = 0; i < grub_be_to_cpu16 (catkey->namelen); i++)
+ {
+ keyname[i] = grub_be_to_cpu16 (catkey->name[i]);
+
+ if (keyname[i] == '/')
+ keyname[i] = ':';
+
+ /* If the name is obviously invalid, skip this node. */
+ if (keyname[i] == 0)
+ {
+ grub_free (keyname);
+ grub_free (filename);
+ return 0;
+ }
+ }
+
+ *grub_utf16_to_utf8 ((grub_uint8_t *) filename, keyname,
+ grub_be_to_cpu16 (catkey->namelen)) = '\0';
+
+ grub_free (keyname);
+
+ /* hfs+ is case insensitive. */
+ if (! ctx->dir->data->case_sensitive)
+ type |= GRUB_FSHELP_CASE_INSENSITIVE;
+
+ /* A valid node is found; setup the node and call the
+ callback function. */
+ node = grub_malloc (sizeof (*node));
+ if (!node)
+ {
+ grub_free (filename);
+ return 1;
+ }
+ node->data = ctx->dir->data;
+ node->compressed = 0;
+ node->cbuf = 0;
+ node->compress_index = 0;
+
+ grub_memcpy (node->extents, fileinfo->data.extents,
+ sizeof (node->extents));
+ grub_memcpy (node->resource_extents, fileinfo->resource.extents,
+ sizeof (node->resource_extents));
+ node->mtime = grub_be_to_cpu32 (fileinfo->mtime) - 2082844800;
+ node->size = grub_be_to_cpu64 (fileinfo->data.size);
+ node->resource_size = grub_be_to_cpu64 (fileinfo->resource.size);
+ node->fileid = grub_be_to_cpu32 (fileinfo->fileid);
+
+ ctx->ret = ctx->hook (filename, type, node, ctx->hook_data);
+
+ grub_free (filename);
+
+ return ctx->ret;
+}
+
+static int
+grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ struct list_nodes_ctx ctx =
+ {
+ .ret = 0,
+ .dir = dir,
+ .hook = hook,
+ .hook_data = hook_data
+ };
+
+ struct grub_hfsplus_key_internal intern;
+ struct grub_hfsplus_btnode *node = NULL;
+ grub_disk_addr_t ptr = 0;
+
+ {
+ struct grub_fshelp_node *fsnode;
+ fsnode = grub_malloc (sizeof (*fsnode));
+ if (!fsnode)
+ return 1;
+ *fsnode = *dir;
+ if (hook (".", GRUB_FSHELP_DIR, fsnode, hook_data))
+ return 1;
+ }
+
+ /* Create a key that points to the first entry in the directory. */
+ intern.catkey.parent = dir->fileid;
+ intern.catkey.name = 0;
+ intern.catkey.namelen = 0;
+
+ /* First lookup the first entry. */
+ if (grub_hfsplus_btree_search (&dir->data->catalog_tree, &intern,
+ grub_hfsplus_cmp_catkey, &node, &ptr)
+ || !node)
+ return 0;
+
+ /* Iterate over all entries in this directory. */
+ grub_hfsplus_btree_iterate_node (&dir->data->catalog_tree, node, ptr,
+ list_nodes, &ctx);
+
+ grub_free (node);
+
+ return ctx.ret;
+}
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_hfsplus_open (struct grub_file *file, const char *name)
+{
+ struct grub_hfsplus_data *data;
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_hfsplus_mount (file->device->disk);
+ if (!data)
+ goto fail;
+
+ grub_fshelp_find_file (name, &data->dirroot, &fdiro,
+ grub_hfsplus_iterate_dir,
+ grub_hfsplus_read_symlink, GRUB_FSHELP_REG);
+ if (grub_errno)
+ goto fail;
+
+ if (grub_hfsplus_open_compressed)
+ {
+ grub_err_t err;
+ err = grub_hfsplus_open_compressed (fdiro);
+ if (err)
+ goto fail;
+ }
+
+ file->size = fdiro->size;
+ data->opened_file = *fdiro;
+ grub_free (fdiro);
+
+ file->data = data;
+ file->offset = 0;
+
+ return 0;
+
+ fail:
+ if (data && fdiro != &data->dirroot)
+ grub_free (fdiro);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+
+static grub_err_t
+grub_hfsplus_close (grub_file_t file)
+{
+ struct grub_hfsplus_data *data =
+ (struct grub_hfsplus_data *) file->data;
+
+ grub_free (data->opened_file.cbuf);
+ grub_free (data->opened_file.compress_index);
+
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Read LEN bytes data from FILE into BUF. */
+static grub_ssize_t
+grub_hfsplus_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_hfsplus_data *data =
+ (struct grub_hfsplus_data *) file->data;
+
+ data->opened_file.file = file;
+
+ if (grub_hfsplus_read_compressed && data->opened_file.compressed)
+ return grub_hfsplus_read_compressed (&data->opened_file,
+ file->offset, len, buf);
+
+ return grub_hfsplus_read_file (&data->opened_file,
+ file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+/* Context for grub_hfsplus_dir. */
+struct grub_hfsplus_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_hfsplus_dir. */
+static int
+grub_hfsplus_dir_iter (const char *filename,
+ enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_hfsplus_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ info.mtimeset = 1;
+ info.mtime = node->mtime;
+ info.inodeset = 1;
+ info.inode = node->fileid;
+ info.case_insensitive = !! (filetype & GRUB_FSHELP_CASE_INSENSITIVE);
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_hfsplus_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_hfsplus_dir_ctx ctx = { hook, hook_data };
+ struct grub_hfsplus_data *data = 0;
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_hfsplus_mount (device->disk);
+ if (!data)
+ goto fail;
+
+ /* Find the directory that should be opened. */
+ grub_fshelp_find_file (path, &data->dirroot, &fdiro,
+ grub_hfsplus_iterate_dir,
+ grub_hfsplus_read_symlink, GRUB_FSHELP_DIR);
+ if (grub_errno)
+ goto fail;
+
+ /* Iterate over all entries in this directory. */
+ grub_hfsplus_iterate_dir (fdiro, grub_hfsplus_dir_iter, &ctx);
+
+ fail:
+ if (data && fdiro != &data->dirroot)
+ grub_free (fdiro);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+
+static grub_err_t
+grub_hfsplus_label (grub_device_t device, char **label)
+{
+ struct grub_hfsplus_data *data;
+ grub_disk_t disk = device->disk;
+ struct grub_hfsplus_catkey *catkey;
+ int i, label_len;
+ grub_uint16_t *label_name;
+ struct grub_hfsplus_key_internal intern;
+ struct grub_hfsplus_btnode *node = NULL;
+ grub_disk_addr_t ptr = 0;
+
+ *label = 0;
+
+ data = grub_hfsplus_mount (disk);
+ if (!data)
+ return grub_errno;
+
+ /* Create a key that points to the label. */
+ intern.catkey.parent = 1;
+ intern.catkey.name = 0;
+ intern.catkey.namelen = 0;
+
+ /* First lookup the first entry. */
+ if (grub_hfsplus_btree_search (&data->catalog_tree, &intern,
+ grub_hfsplus_cmp_catkey_id, &node, &ptr)
+ || !node)
+ {
+ grub_free (data);
+ return 0;
+ }
+
+ catkey = (struct grub_hfsplus_catkey *)
+ grub_hfsplus_btree_recptr (&data->catalog_tree, node, ptr);
+
+ label_len = grub_be_to_cpu16 (catkey->namelen);
+
+ /* Ensure that the length is >= 0. */
+ if (label_len < 0)
+ label_len = 0;
+
+ /* Ensure label length is at most 255 Unicode characters. */
+ if (label_len > 255)
+ label_len = 255;
+
+ label_name = grub_calloc (label_len, sizeof (*label_name));
+ if (!label_name)
+ {
+ grub_free (node);
+ grub_free (data);
+ return grub_errno;
+ }
+
+ for (i = 0; i < label_len; i++)
+ {
+ label_name[i] = grub_be_to_cpu16 (catkey->name[i]);
+
+ /* If the name is obviously invalid, skip this node. */
+ if (label_name[i] == 0)
+ {
+ grub_free (label_name);
+ grub_free (node);
+ grub_free (data);
+ return 0;
+ }
+ }
+
+ *label = grub_calloc (label_len, GRUB_MAX_UTF8_PER_UTF16 + 1);
+ if (! *label)
+ {
+ grub_free (label_name);
+ grub_free (node);
+ grub_free (data);
+ return grub_errno;
+ }
+
+ *grub_utf16_to_utf8 ((grub_uint8_t *) (*label), label_name,
+ label_len) = '\0';
+
+ grub_free (label_name);
+ grub_free (node);
+ grub_free (data);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Get mtime. */
+static grub_err_t
+grub_hfsplus_mtime (grub_device_t device, grub_int64_t *tm)
+{
+ struct grub_hfsplus_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_hfsplus_mount (disk);
+ if (!data)
+ *tm = 0;
+ else
+ *tm = grub_be_to_cpu32 (data->volheader.utime) - 2082844800;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+
+}
+
+static grub_err_t
+grub_hfsplus_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_hfsplus_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_hfsplus_mount (disk);
+ if (data)
+ {
+ *uuid = grub_xasprintf ("%016llx",
+ (unsigned long long)
+ grub_be_to_cpu64 (data->volheader.num_serial));
+ }
+ else
+ *uuid = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+
+static struct grub_fs grub_hfsplus_fs =
+ {
+ .name = "hfsplus",
+ .fs_dir = grub_hfsplus_dir,
+ .fs_open = grub_hfsplus_open,
+ .fs_read = grub_hfsplus_read,
+ .fs_close = grub_hfsplus_close,
+ .fs_label = grub_hfsplus_label,
+ .fs_mtime = grub_hfsplus_mtime,
+ .fs_uuid = grub_hfsplus_uuid,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(hfsplus)
+{
+ grub_fs_register (&grub_hfsplus_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(hfsplus)
+{
+ grub_fs_unregister (&grub_hfsplus_fs);
+}
diff --git a/grub-core/fs/hfspluscomp.c b/grub-core/fs/hfspluscomp.c
new file mode 100644
index 0000000..d76f3f1
--- /dev/null
+++ b/grub-core/fs/hfspluscomp.c
@@ -0,0 +1,317 @@
+/*
+ * 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/>.
+ */
+
+/* HFS+ is documented at http://developer.apple.com/technotes/tn/tn1150.html */
+
+#include <grub/hfsplus.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/deflate.h>
+#include <grub/file.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* big-endian. */
+struct grub_hfsplus_compress_header1
+{
+ grub_uint32_t header_size;
+ grub_uint32_t end_descriptor_offset;
+ grub_uint32_t total_compressed_size_including_seek_blocks_and_header2;
+ grub_uint32_t value_0x32;
+ grub_uint8_t unused[0xf0];
+} GRUB_PACKED;
+
+/* big-endian. */
+struct grub_hfsplus_compress_header2
+{
+ grub_uint32_t total_compressed_size_including_seek_blocks;
+} GRUB_PACKED;
+
+/* little-endian. */
+struct grub_hfsplus_compress_header3
+{
+ grub_uint32_t num_chunks;
+} GRUB_PACKED;
+
+/* little-endian. */
+struct grub_hfsplus_compress_block_descriptor
+{
+ grub_uint32_t offset;
+ grub_uint32_t size;
+};
+
+struct grub_hfsplus_compress_end_descriptor
+{
+ grub_uint8_t always_the_same[50];
+} GRUB_PACKED;
+
+struct grub_hfsplus_attr_header
+{
+ grub_uint8_t unused[3];
+ grub_uint8_t type;
+ grub_uint32_t unknown[1];
+ grub_uint64_t size;
+} GRUB_PACKED;
+
+struct grub_hfsplus_compress_attr
+{
+ grub_uint32_t magic;
+ grub_uint32_t type;
+ grub_uint32_t uncompressed_inline_size;
+ grub_uint32_t always_0;
+} GRUB_PACKED;
+
+enum
+ {
+ HFSPLUS_COMPRESSION_INLINE = 3,
+ HFSPLUS_COMPRESSION_RESOURCE = 4
+ };
+
+static int
+grub_hfsplus_cmp_attrkey (struct grub_hfsplus_key *keya,
+ struct grub_hfsplus_key_internal *keyb)
+{
+ struct grub_hfsplus_attrkey *attrkey_a = &keya->attrkey;
+ struct grub_hfsplus_attrkey_internal *attrkey_b = &keyb->attrkey;
+ grub_uint32_t aparent = grub_be_to_cpu32 (attrkey_a->cnid);
+ grub_size_t len;
+ int diff;
+
+ if (aparent > attrkey_b->cnid)
+ return 1;
+ if (aparent < attrkey_b->cnid)
+ return -1;
+
+ len = grub_be_to_cpu16 (attrkey_a->namelen);
+ if (len > attrkey_b->namelen)
+ len = attrkey_b->namelen;
+ /* Since it's big-endian memcmp gives the same result as manually comparing
+ uint16_t but may be faster. */
+ diff = grub_memcmp (attrkey_a->name, attrkey_b->name,
+ len * sizeof (attrkey_a->name[0]));
+ if (diff == 0)
+ diff = grub_be_to_cpu16 (attrkey_a->namelen) - attrkey_b->namelen;
+ return diff;
+}
+
+#define HFSPLUS_COMPRESS_BLOCK_SIZE 65536
+
+static grub_ssize_t
+hfsplus_read_compressed_real (struct grub_hfsplus_file *node,
+ grub_off_t pos, grub_size_t len, char *buf)
+{
+ char *tmp_buf = 0;
+ grub_size_t len0 = len;
+
+ if (node->compressed == 1)
+ {
+ grub_memcpy (buf, node->cbuf + pos, len);
+ if (grub_file_progress_hook && node->file)
+ grub_file_progress_hook (0, 0, len, node->file);
+ return len;
+ }
+
+ while (len)
+ {
+ grub_uint32_t block = pos / HFSPLUS_COMPRESS_BLOCK_SIZE;
+ grub_size_t curlen = HFSPLUS_COMPRESS_BLOCK_SIZE
+ - (pos % HFSPLUS_COMPRESS_BLOCK_SIZE);
+
+ if (curlen > len)
+ curlen = len;
+
+ if (node->cbuf_block != block)
+ {
+ grub_uint32_t sz = grub_le_to_cpu32 (node->compress_index[block].size);
+ grub_size_t ts;
+ if (!tmp_buf)
+ tmp_buf = grub_malloc (HFSPLUS_COMPRESS_BLOCK_SIZE);
+ if (!tmp_buf)
+ return -1;
+ if (grub_hfsplus_read_file (node, 0, 0,
+ grub_le_to_cpu32 (node->compress_index[block].start) + 0x104,
+ sz, tmp_buf)
+ != (grub_ssize_t) sz)
+ {
+ grub_free (tmp_buf);
+ return -1;
+ }
+ ts = HFSPLUS_COMPRESS_BLOCK_SIZE;
+ 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) != (grub_ssize_t) ts)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "premature end of compressed");
+
+ grub_free (tmp_buf);
+ return -1;
+ }
+ node->cbuf_block = block;
+ }
+ grub_memcpy (buf, node->cbuf + (pos % HFSPLUS_COMPRESS_BLOCK_SIZE),
+ curlen);
+ if (grub_file_progress_hook && node->file)
+ grub_file_progress_hook (0, 0, curlen, node->file);
+ buf += curlen;
+ pos += curlen;
+ len -= curlen;
+ }
+ grub_free (tmp_buf);
+ return len0;
+}
+
+static grub_err_t
+hfsplus_open_compressed_real (struct grub_hfsplus_file *node)
+{
+ grub_err_t err;
+ struct grub_hfsplus_btnode *attr_node;
+ grub_off_t attr_off;
+ struct grub_hfsplus_key_internal key;
+ struct grub_hfsplus_attr_header *attr_head;
+ struct grub_hfsplus_compress_attr *cmp_head;
+#define c grub_cpu_to_be16_compile_time
+ const grub_uint16_t compress_attr_name[] =
+ {
+ c('c'), c('o'), c('m'), c('.'), c('a'), c('p'), c('p'), c('l'), c('e'),
+ c('.'), c('d'), c('e'), c('c'), c('m'), c('p'), c('f'), c('s') };
+#undef c
+ if (node->size)
+ return 0;
+
+ key.attrkey.cnid = node->fileid;
+ key.attrkey.namelen = sizeof (compress_attr_name) / sizeof (compress_attr_name[0]);
+ key.attrkey.name = compress_attr_name;
+
+ err = grub_hfsplus_btree_search (&node->data->attr_tree, &key,
+ grub_hfsplus_cmp_attrkey,
+ &attr_node, &attr_off);
+ if (err || !attr_node)
+ {
+ grub_errno = 0;
+ return 0;
+ }
+
+ attr_head = (struct grub_hfsplus_attr_header *)
+ ((char *) grub_hfsplus_btree_recptr (&node->data->attr_tree,
+ attr_node, attr_off)
+ + sizeof (struct grub_hfsplus_attrkey) + sizeof (compress_attr_name));
+ if (attr_head->type != 0x10
+ || !(attr_head->size & grub_cpu_to_be64_compile_time(~0xfULL)))
+ {
+ grub_free (attr_node);
+ return 0;
+ }
+ cmp_head = (struct grub_hfsplus_compress_attr *) (attr_head + 1);
+ if (cmp_head->magic != grub_cpu_to_be32_compile_time (0x66706d63))
+ {
+ grub_free (attr_node);
+ return 0;
+ }
+ node->size = grub_le_to_cpu32 (cmp_head->uncompressed_inline_size);
+
+ if (cmp_head->type == grub_cpu_to_le32_compile_time (HFSPLUS_COMPRESSION_RESOURCE))
+ {
+ grub_uint32_t index_size;
+ node->compressed = 2;
+
+ if (grub_hfsplus_read_file (node, 0, 0,
+ 0x104, sizeof (index_size),
+ (char *) &index_size)
+ != 4)
+ {
+ node->compressed = 0;
+ grub_free (attr_node);
+ grub_errno = 0;
+ return 0;
+ }
+ node->compress_index_size = grub_le_to_cpu32 (index_size);
+ node->compress_index = grub_malloc (node->compress_index_size
+ * sizeof (node->compress_index[0]));
+ if (!node->compress_index)
+ {
+ node->compressed = 0;
+ grub_free (attr_node);
+ return grub_errno;
+ }
+ if (grub_hfsplus_read_file (node, 0, 0,
+ 0x104 + sizeof (index_size),
+ node->compress_index_size
+ * sizeof (node->compress_index[0]),
+ (char *) node->compress_index)
+ != (grub_ssize_t) (node->compress_index_size
+ * sizeof (node->compress_index[0])))
+ {
+ node->compressed = 0;
+ grub_free (attr_node);
+ grub_free (node->compress_index);
+ grub_errno = 0;
+ return 0;
+ }
+
+ node->cbuf_block = -1;
+
+ node->cbuf = grub_malloc (HFSPLUS_COMPRESS_BLOCK_SIZE);
+ grub_free (attr_node);
+ if (!node->cbuf)
+ {
+ node->compressed = 0;
+ grub_free (node->compress_index);
+ return grub_errno;
+ }
+ return 0;
+ }
+ if (cmp_head->type != HFSPLUS_COMPRESSION_INLINE)
+ {
+ grub_free (attr_node);
+ return 0;
+ }
+
+ node->cbuf = grub_malloc (node->size);
+ if (!node->cbuf)
+ return grub_errno;
+
+ if (grub_zlib_decompress ((char *) (cmp_head + 1),
+ grub_cpu_to_be64 (attr_head->size)
+ - sizeof (*cmp_head), 0,
+ 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;
+}
+
+GRUB_MOD_INIT(hfspluscomp)
+{
+ grub_hfsplus_open_compressed = hfsplus_open_compressed_real;
+ grub_hfsplus_read_compressed = hfsplus_read_compressed_real;
+}
+
+GRUB_MOD_FINI(hfspluscomp)
+{
+ grub_hfsplus_open_compressed = 0;
+ grub_hfsplus_read_compressed = 0;
+}
diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c
new file mode 100644
index 0000000..ac01195
--- /dev/null
+++ b/grub-core/fs/iso9660.c
@@ -0,0 +1,1162 @@
+/* iso9660.c - iso9660 implementation with extensions:
+ SUSP, Rock Ridge. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+#include <grub/charset.h>
+#include <grub/datetime.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_ISO9660_FSTYPE_DIR 0040000
+#define GRUB_ISO9660_FSTYPE_REG 0100000
+#define GRUB_ISO9660_FSTYPE_SYMLINK 0120000
+#define GRUB_ISO9660_FSTYPE_MASK 0170000
+
+#define GRUB_ISO9660_LOG2_BLKSZ 2
+#define GRUB_ISO9660_BLKSZ 2048
+
+#define GRUB_ISO9660_RR_DOT 2
+#define GRUB_ISO9660_RR_DOTDOT 4
+
+#define GRUB_ISO9660_VOLDESC_BOOT 0
+#define GRUB_ISO9660_VOLDESC_PRIMARY 1
+#define GRUB_ISO9660_VOLDESC_SUPP 2
+#define GRUB_ISO9660_VOLDESC_PART 3
+#define GRUB_ISO9660_VOLDESC_END 255
+
+/* The head of a volume descriptor. */
+struct grub_iso9660_voldesc
+{
+ grub_uint8_t type;
+ grub_uint8_t magic[5];
+ grub_uint8_t version;
+} GRUB_PACKED;
+
+struct grub_iso9660_date2
+{
+ grub_uint8_t year;
+ grub_uint8_t month;
+ grub_uint8_t day;
+ grub_uint8_t hour;
+ grub_uint8_t minute;
+ grub_uint8_t second;
+ grub_uint8_t offset;
+} GRUB_PACKED;
+
+/* A directory entry. */
+struct grub_iso9660_dir
+{
+ grub_uint8_t len;
+ grub_uint8_t ext_sectors;
+ grub_uint32_t first_sector;
+ grub_uint32_t first_sector_be;
+ grub_uint32_t size;
+ grub_uint32_t size_be;
+ struct grub_iso9660_date2 mtime;
+ grub_uint8_t flags;
+ grub_uint8_t unused2[6];
+#define MAX_NAMELEN 255
+ grub_uint8_t namelen;
+} GRUB_PACKED;
+
+struct grub_iso9660_date
+{
+ grub_uint8_t year[4];
+ grub_uint8_t month[2];
+ grub_uint8_t day[2];
+ grub_uint8_t hour[2];
+ grub_uint8_t minute[2];
+ grub_uint8_t second[2];
+ grub_uint8_t hundredth[2];
+ grub_uint8_t offset;
+} GRUB_PACKED;
+
+/* The primary volume descriptor. Only little endian is used. */
+struct grub_iso9660_primary_voldesc
+{
+ struct grub_iso9660_voldesc voldesc;
+ grub_uint8_t unused1[33];
+ grub_uint8_t volname[32];
+ grub_uint8_t unused2[16];
+ grub_uint8_t escape[32];
+ grub_uint8_t unused3[12];
+ grub_uint32_t path_table_size;
+ grub_uint8_t unused4[4];
+ grub_uint32_t path_table;
+ grub_uint8_t unused5[12];
+ struct grub_iso9660_dir rootdir;
+ grub_uint8_t unused6[624];
+ struct grub_iso9660_date created;
+ struct grub_iso9660_date modified;
+} GRUB_PACKED;
+
+/* A single entry in the path table. */
+struct grub_iso9660_path
+{
+ grub_uint8_t len;
+ grub_uint8_t sectors;
+ grub_uint32_t first_sector;
+ grub_uint16_t parentdir;
+ grub_uint8_t name[0];
+} GRUB_PACKED;
+
+/* An entry in the System Usage area of the directory entry. */
+struct grub_iso9660_susp_entry
+{
+ grub_uint8_t sig[2];
+ grub_uint8_t len;
+ grub_uint8_t version;
+ grub_uint8_t data[0];
+} GRUB_PACKED;
+
+/* The CE entry. This is used to describe the next block where data
+ can be found. */
+struct grub_iso9660_susp_ce
+{
+ struct grub_iso9660_susp_entry entry;
+ grub_uint32_t blk;
+ grub_uint32_t blk_be;
+ grub_uint32_t off;
+ grub_uint32_t off_be;
+ grub_uint32_t len;
+ grub_uint32_t len_be;
+} GRUB_PACKED;
+
+struct grub_iso9660_data
+{
+ struct grub_iso9660_primary_voldesc voldesc;
+ grub_disk_t disk;
+ int rockridge;
+ int susp_skip;
+ int joliet;
+ struct grub_fshelp_node *node;
+};
+
+struct grub_fshelp_node
+{
+ struct grub_iso9660_data *data;
+ grub_size_t have_dirents, alloc_dirents;
+ int have_symlink;
+ struct grub_iso9660_dir dirents[8];
+ char symlink[0];
+};
+
+enum
+ {
+ FLAG_TYPE_PLAIN = 0,
+ FLAG_TYPE_DIR = 2,
+ FLAG_TYPE = 3,
+ FLAG_MORE_EXTENTS = 0x80
+ };
+
+static grub_dl_t my_mod;
+
+
+static grub_err_t
+iso9660_to_unixtime (const struct grub_iso9660_date *i, grub_int64_t *nix)
+{
+ struct grub_datetime datetime;
+
+ if (! i->year[0] && ! i->year[1]
+ && ! i->year[2] && ! i->year[3]
+ && ! i->month[0] && ! i->month[1]
+ && ! i->day[0] && ! i->day[1]
+ && ! i->hour[0] && ! i->hour[1]
+ && ! i->minute[0] && ! i->minute[1]
+ && ! i->second[0] && ! i->second[1]
+ && ! i->hundredth[0] && ! i->hundredth[1])
+ return grub_error (GRUB_ERR_BAD_NUMBER, "empty date");
+ datetime.year = (i->year[0] - '0') * 1000 + (i->year[1] - '0') * 100
+ + (i->year[2] - '0') * 10 + (i->year[3] - '0');
+ datetime.month = (i->month[0] - '0') * 10 + (i->month[1] - '0');
+ datetime.day = (i->day[0] - '0') * 10 + (i->day[1] - '0');
+ datetime.hour = (i->hour[0] - '0') * 10 + (i->hour[1] - '0');
+ datetime.minute = (i->minute[0] - '0') * 10 + (i->minute[1] - '0');
+ datetime.second = (i->second[0] - '0') * 10 + (i->second[1] - '0');
+
+ if (!grub_datetime2unixtime (&datetime, nix))
+ return grub_error (GRUB_ERR_BAD_NUMBER, "incorrect date");
+ *nix -= i->offset * 60 * 15;
+ return GRUB_ERR_NONE;
+}
+
+static int
+iso9660_to_unixtime2 (const struct grub_iso9660_date2 *i, grub_int64_t *nix)
+{
+ struct grub_datetime datetime;
+
+ datetime.year = i->year + 1900;
+ datetime.month = i->month;
+ datetime.day = i->day;
+ datetime.hour = i->hour;
+ datetime.minute = i->minute;
+ datetime.second = i->second;
+
+ if (!grub_datetime2unixtime (&datetime, nix))
+ return 0;
+ *nix -= i->offset * 60 * 15;
+ return 1;
+}
+
+static grub_err_t
+read_node (grub_fshelp_node_t node, grub_off_t off, grub_size_t len, char *buf)
+{
+ grub_size_t i = 0;
+
+ while (len > 0)
+ {
+ grub_size_t toread;
+ grub_err_t err;
+ while (i < node->have_dirents
+ && off >= grub_le_to_cpu32 (node->dirents[i].size))
+ {
+ off -= grub_le_to_cpu32 (node->dirents[i].size);
+ i++;
+ }
+ if (i == node->have_dirents)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "read out of range");
+ toread = grub_le_to_cpu32 (node->dirents[i].size);
+ if (toread > len)
+ toread = len;
+ err = grub_disk_read (node->data->disk,
+ ((grub_disk_addr_t) grub_le_to_cpu32 (node->dirents[i].first_sector)) << GRUB_ISO9660_LOG2_BLKSZ,
+ off, toread, buf);
+ if (err)
+ return err;
+ len -= toread;
+ off += toread;
+ buf += toread;
+ }
+ return GRUB_ERR_NONE;
+}
+
+/* Iterate over the susp entries, starting with block SUA_BLOCK on the
+ offset SUA_POS with a size of SUA_SIZE bytes. Hook is called for
+ every entry. */
+static grub_err_t
+grub_iso9660_susp_iterate (grub_fshelp_node_t node, grub_off_t off,
+ grub_ssize_t sua_size,
+ grub_err_t (*hook)
+ (struct grub_iso9660_susp_entry *entry, void *hook_arg),
+ void *hook_arg)
+{
+ char *sua;
+ struct grub_iso9660_susp_entry *entry;
+ grub_err_t err;
+
+ if (sua_size <= 0)
+ return GRUB_ERR_NONE;
+
+ sua = grub_malloc (sua_size);
+ if (!sua)
+ return grub_errno;
+
+ /* Load a part of the System Usage Area. */
+ err = read_node (node, off, sua_size, sua);
+ if (err)
+ return err;
+
+ for (entry = (struct grub_iso9660_susp_entry *) sua; (char *) entry < (char *) sua + sua_size - 1 && entry->len > 0;
+ entry = (struct grub_iso9660_susp_entry *)
+ ((char *) entry + entry->len))
+ {
+ /* The last entry. */
+ if (grub_strncmp ((char *) entry->sig, "ST", 2) == 0)
+ break;
+
+ /* Additional entries are stored elsewhere. */
+ if (grub_strncmp ((char *) entry->sig, "CE", 2) == 0)
+ {
+ struct grub_iso9660_susp_ce *ce;
+ grub_disk_addr_t ce_block;
+
+ ce = (struct grub_iso9660_susp_ce *) entry;
+ sua_size = grub_le_to_cpu32 (ce->len);
+ off = grub_le_to_cpu32 (ce->off);
+ ce_block = grub_le_to_cpu32 (ce->blk) << GRUB_ISO9660_LOG2_BLKSZ;
+
+ grub_free (sua);
+ sua = grub_malloc (sua_size);
+ if (!sua)
+ return grub_errno;
+
+ /* Load a part of the System Usage Area. */
+ err = grub_disk_read (node->data->disk, ce_block, off,
+ sua_size, sua);
+ if (err)
+ return err;
+
+ entry = (struct grub_iso9660_susp_entry *) sua;
+ }
+
+ if (hook (entry, hook_arg))
+ {
+ grub_free (sua);
+ return 0;
+ }
+ }
+
+ grub_free (sua);
+ return 0;
+}
+
+static char *
+grub_iso9660_convert_string (grub_uint8_t *us, int len)
+{
+ char *p;
+ int i;
+ grub_uint16_t t[MAX_NAMELEN / 2 + 1];
+
+ p = grub_calloc (len, GRUB_MAX_UTF8_PER_UTF16 + 1);
+ if (! p)
+ return NULL;
+
+ for (i=0; i<len; i++)
+ t[i] = grub_be_to_cpu16 (grub_get_unaligned16 (us + 2 * i));
+
+ *grub_utf16_to_utf8 ((grub_uint8_t *) p, t, len) = '\0';
+
+ return p;
+}
+
+static grub_err_t
+susp_iterate_set_rockridge (struct grub_iso9660_susp_entry *susp_entry,
+ void *_data)
+{
+ struct grub_iso9660_data *data = _data;
+ /* The "ER" entry is used to detect extensions. The
+ `IEEE_P1285' extension means Rock ridge. */
+ if (grub_strncmp ((char *) susp_entry->sig, "ER", 2) == 0)
+ {
+ data->rockridge = 1;
+ return 1;
+ }
+ return 0;
+}
+
+static grub_err_t
+set_rockridge (struct grub_iso9660_data *data)
+{
+ int sua_pos;
+ int sua_size;
+ char *sua;
+ struct grub_iso9660_dir rootdir;
+ struct grub_iso9660_susp_entry *entry;
+
+ data->rockridge = 0;
+
+ /* Read the system use area and test it to see if SUSP is
+ supported. */
+ if (grub_disk_read (data->disk,
+ (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector)
+ << GRUB_ISO9660_LOG2_BLKSZ), 0,
+ sizeof (rootdir), (char *) &rootdir))
+ return grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
+
+ sua_pos = (sizeof (rootdir) + rootdir.namelen
+ + (rootdir.namelen % 2) - 1);
+ sua_size = rootdir.len - sua_pos;
+
+ if (!sua_size)
+ return GRUB_ERR_NONE;
+
+ sua = grub_malloc (sua_size);
+ if (! sua)
+ return grub_errno;
+
+ if (grub_disk_read (data->disk,
+ (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector)
+ << GRUB_ISO9660_LOG2_BLKSZ), sua_pos,
+ sua_size, sua))
+ {
+ grub_free (sua);
+ return grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
+ }
+
+ entry = (struct grub_iso9660_susp_entry *) sua;
+
+ /* Test if the SUSP protocol is used on this filesystem. */
+ if (grub_strncmp ((char *) entry->sig, "SP", 2) == 0)
+ {
+ struct grub_fshelp_node rootnode;
+
+ rootnode.data = data;
+ rootnode.alloc_dirents = ARRAY_SIZE (rootnode.dirents);
+ rootnode.have_dirents = 1;
+ rootnode.have_symlink = 0;
+ rootnode.dirents[0] = data->voldesc.rootdir;
+
+ /* The 2nd data byte stored how many bytes are skipped every time
+ to get to the SUA (System Usage Area). */
+ data->susp_skip = entry->data[2];
+ entry = (struct grub_iso9660_susp_entry *) ((char *) entry + entry->len);
+
+ /* Iterate over the entries in the SUA area to detect
+ extensions. */
+ if (grub_iso9660_susp_iterate (&rootnode,
+ sua_pos, sua_size, susp_iterate_set_rockridge,
+ data))
+ {
+ grub_free (sua);
+ return grub_errno;
+ }
+ }
+ grub_free (sua);
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_iso9660_data *
+grub_iso9660_mount (grub_disk_t disk)
+{
+ struct grub_iso9660_data *data = 0;
+ struct grub_iso9660_primary_voldesc voldesc;
+ int block;
+
+ data = grub_zalloc (sizeof (struct grub_iso9660_data));
+ if (! data)
+ return 0;
+
+ data->disk = disk;
+
+ block = 16;
+ do
+ {
+ int copy_voldesc = 0;
+
+ /* Read the superblock. */
+ if (grub_disk_read (disk, block << GRUB_ISO9660_LOG2_BLKSZ, 0,
+ sizeof (struct grub_iso9660_primary_voldesc),
+ (char *) &voldesc))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
+ goto fail;
+ }
+
+ if (grub_strncmp ((char *) voldesc.voldesc.magic, "CD001", 5) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
+ goto fail;
+ }
+
+ if (voldesc.voldesc.type == GRUB_ISO9660_VOLDESC_PRIMARY)
+ copy_voldesc = 1;
+ else if (!data->rockridge
+ && (voldesc.voldesc.type == GRUB_ISO9660_VOLDESC_SUPP)
+ && (voldesc.escape[0] == 0x25) && (voldesc.escape[1] == 0x2f)
+ &&
+ ((voldesc.escape[2] == 0x40) || /* UCS-2 Level 1. */
+ (voldesc.escape[2] == 0x43) || /* UCS-2 Level 2. */
+ (voldesc.escape[2] == 0x45))) /* UCS-2 Level 3. */
+ {
+ copy_voldesc = 1;
+ data->joliet = 1;
+ }
+
+ if (copy_voldesc)
+ {
+ grub_memcpy((char *) &data->voldesc, (char *) &voldesc,
+ sizeof (struct grub_iso9660_primary_voldesc));
+ if (set_rockridge (data))
+ goto fail;
+ }
+
+ block++;
+ } while (voldesc.voldesc.type != GRUB_ISO9660_VOLDESC_END);
+
+ return data;
+
+ fail:
+ grub_free (data);
+ return 0;
+}
+
+
+static char *
+grub_iso9660_read_symlink (grub_fshelp_node_t node)
+{
+ return node->have_symlink
+ ? grub_strdup (node->symlink
+ + (node->have_dirents) * sizeof (node->dirents[0])
+ - sizeof (node->dirents)) : grub_strdup ("");
+}
+
+static grub_off_t
+get_node_size (grub_fshelp_node_t node)
+{
+ grub_off_t ret = 0;
+ grub_size_t i;
+
+ for (i = 0; i < node->have_dirents; i++)
+ ret += grub_le_to_cpu32 (node->dirents[i].size);
+ return ret;
+}
+
+struct iterate_dir_ctx
+{
+ char *filename;
+ int filename_alloc;
+ enum grub_fshelp_filetype type;
+ char *symlink;
+ int was_continue;
+};
+
+ /* Extend the symlink. */
+static void
+add_part (struct iterate_dir_ctx *ctx,
+ const char *part,
+ int len2)
+{
+ int size = ctx->symlink ? grub_strlen (ctx->symlink) : 0;
+ grub_size_t sz;
+ char *new;
+
+ if (grub_add (size, len2, &sz) ||
+ grub_add (sz, 1, &sz))
+ return;
+
+ new = grub_realloc (ctx->symlink, sz);
+ if (!new)
+ {
+ grub_free (ctx->symlink);
+ ctx->symlink = NULL;
+ return;
+ }
+ ctx->symlink = new;
+
+ grub_memcpy (ctx->symlink + size, part, len2);
+ ctx->symlink[size + len2] = 0;
+}
+
+static grub_err_t
+susp_iterate_dir (struct grub_iso9660_susp_entry *entry,
+ void *_ctx)
+{
+ struct iterate_dir_ctx *ctx = _ctx;
+
+ /* The filename in the rock ridge entry. */
+ if (grub_strncmp ("NM", (char *) entry->sig, 2) == 0)
+ {
+ /* The flags are stored at the data position 0, here the
+ filename type is stored. */
+ /* FIXME: Fix this slightly improper cast. */
+ if (entry->data[0] & GRUB_ISO9660_RR_DOT)
+ ctx->filename = (char *) ".";
+ else if (entry->data[0] & GRUB_ISO9660_RR_DOTDOT)
+ ctx->filename = (char *) "..";
+ else if (entry->len >= 5)
+ {
+ grub_size_t off = 0, csize = 1;
+ char *old;
+ grub_size_t sz;
+
+ csize = entry->len - 5;
+ old = ctx->filename;
+ if (ctx->filename_alloc)
+ {
+ off = grub_strlen (ctx->filename);
+ if (grub_add (csize, off, &sz) ||
+ grub_add (sz, 1, &sz))
+ return GRUB_ERR_OUT_OF_RANGE;
+ ctx->filename = grub_realloc (ctx->filename, sz);
+ }
+ else
+ {
+ off = 0;
+ if (grub_add (csize, 1, &sz))
+ return GRUB_ERR_OUT_OF_RANGE;
+ ctx->filename = grub_zalloc (sz);
+ }
+ if (!ctx->filename)
+ {
+ ctx->filename = old;
+ return grub_errno;
+ }
+ ctx->filename_alloc = 1;
+ grub_memcpy (ctx->filename + off, (char *) &entry->data[1], csize);
+ ctx->filename[off + csize] = '\0';
+ }
+ }
+ /* The mode information (st_mode). */
+ else if (grub_strncmp ((char *) entry->sig, "PX", 2) == 0)
+ {
+ /* At position 0 of the PX record the st_mode information is
+ stored (little-endian). */
+ grub_uint32_t mode = ((entry->data[0] + (entry->data[1] << 8))
+ & GRUB_ISO9660_FSTYPE_MASK);
+
+ switch (mode)
+ {
+ case GRUB_ISO9660_FSTYPE_DIR:
+ ctx->type = GRUB_FSHELP_DIR;
+ break;
+ case GRUB_ISO9660_FSTYPE_REG:
+ ctx->type = GRUB_FSHELP_REG;
+ break;
+ case GRUB_ISO9660_FSTYPE_SYMLINK:
+ ctx->type = GRUB_FSHELP_SYMLINK;
+ break;
+ default:
+ ctx->type = GRUB_FSHELP_UNKNOWN;
+ }
+ }
+ else if (grub_strncmp ("SL", (char *) entry->sig, 2) == 0)
+ {
+ unsigned int pos = 1;
+
+ /* The symlink is not stored as a POSIX symlink, translate it. */
+ while (pos + sizeof (*entry) < entry->len)
+ {
+ /* The current position is the `Component Flag'. */
+ switch (entry->data[pos] & 30)
+ {
+ case 0:
+ {
+ /* The data on pos + 2 is the actual data, pos + 1
+ is the length. Both are part of the `Component
+ Record'. */
+ if (ctx->symlink && !ctx->was_continue)
+ {
+ add_part (ctx, "/", 1);
+ if (grub_errno)
+ return grub_errno;
+ }
+
+ add_part (ctx, (char *) &entry->data[pos + 2],
+ entry->data[pos + 1]);
+ ctx->was_continue = (entry->data[pos] & 1);
+ break;
+ }
+
+ case 2:
+ add_part (ctx, "./", 2);
+ break;
+
+ case 4:
+ add_part (ctx, "../", 3);
+ break;
+
+ case 8:
+ add_part (ctx, "/", 1);
+ break;
+ }
+
+ /* Check if grub_realloc() failed in add_part(). */
+ if (grub_errno)
+ return grub_errno;
+
+ /* In pos + 1 the length of the `Component Record' is
+ stored. */
+ pos += entry->data[pos + 1] + 2;
+ }
+
+ /* Check if `grub_realloc' failed. */
+ if (grub_errno)
+ return grub_errno;
+ }
+
+ return 0;
+}
+
+static int
+grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ struct grub_iso9660_dir dirent;
+ grub_off_t offset = 0;
+ grub_off_t len;
+ struct iterate_dir_ctx ctx;
+
+ len = get_node_size (dir);
+
+ for (; offset < len; offset += dirent.len)
+ {
+ ctx.symlink = 0;
+ ctx.was_continue = 0;
+
+ if (read_node (dir, offset, sizeof (dirent), (char *) &dirent))
+ return 0;
+
+ /* The end of the block, skip to the next one. */
+ if (!dirent.len)
+ {
+ offset = (offset / GRUB_ISO9660_BLKSZ + 1) * GRUB_ISO9660_BLKSZ;
+ continue;
+ }
+
+ {
+ char name[MAX_NAMELEN + 1];
+ int nameoffset = offset + sizeof (dirent);
+ struct grub_fshelp_node *node;
+ int sua_off = (sizeof (dirent) + dirent.namelen + 1
+ - (dirent.namelen % 2));
+ int sua_size = dirent.len - sua_off;
+
+ sua_off += offset + dir->data->susp_skip;
+
+ ctx.filename = 0;
+ ctx.filename_alloc = 0;
+ ctx.type = GRUB_FSHELP_UNKNOWN;
+
+ if (dir->data->rockridge
+ && grub_iso9660_susp_iterate (dir, sua_off, sua_size,
+ susp_iterate_dir, &ctx))
+ return 0;
+
+ /* Read the name. */
+ if (read_node (dir, nameoffset, dirent.namelen, (char *) name))
+ return 0;
+
+ node = grub_malloc (sizeof (struct grub_fshelp_node));
+ if (!node)
+ return 0;
+
+ node->alloc_dirents = ARRAY_SIZE (node->dirents);
+ node->have_dirents = 1;
+
+ /* Setup a new node. */
+ node->data = dir->data;
+ node->have_symlink = 0;
+
+ /* If the filetype was not stored using rockridge, use
+ whatever is stored in the iso9660 filesystem. */
+ if (ctx.type == GRUB_FSHELP_UNKNOWN)
+ {
+ if ((dirent.flags & FLAG_TYPE) == FLAG_TYPE_DIR)
+ ctx.type = GRUB_FSHELP_DIR;
+ else
+ ctx.type = GRUB_FSHELP_REG;
+ }
+
+ /* . and .. */
+ if (!ctx.filename && dirent.namelen == 1 && name[0] == 0)
+ ctx.filename = (char *) ".";
+
+ if (!ctx.filename && dirent.namelen == 1 && name[0] == 1)
+ ctx.filename = (char *) "..";
+
+ /* The filename was not stored in a rock ridge entry. Read it
+ from the iso9660 filesystem. */
+ if (!dir->data->joliet && !ctx.filename)
+ {
+ char *ptr;
+ name[dirent.namelen] = '\0';
+ ctx.filename = grub_strrchr (name, ';');
+ if (ctx.filename)
+ *ctx.filename = '\0';
+ /* ISO9660 names are not case-preserving. */
+ ctx.type |= GRUB_FSHELP_CASE_INSENSITIVE;
+ for (ptr = name; *ptr; ptr++)
+ *ptr = grub_tolower (*ptr);
+ if (ptr != name && *(ptr - 1) == '.')
+ *(ptr - 1) = 0;
+ ctx.filename = name;
+ }
+
+ if (dir->data->joliet && !ctx.filename)
+ {
+ char *semicolon;
+
+ ctx.filename = grub_iso9660_convert_string
+ ((grub_uint8_t *) name, dirent.namelen >> 1);
+
+ semicolon = grub_strrchr (ctx.filename, ';');
+ if (semicolon)
+ *semicolon = '\0';
+
+ ctx.filename_alloc = 1;
+ }
+
+ node->dirents[0] = dirent;
+ while (dirent.flags & FLAG_MORE_EXTENTS)
+ {
+ offset += dirent.len;
+ if (read_node (dir, offset, sizeof (dirent), (char *) &dirent))
+ {
+ if (ctx.filename_alloc)
+ grub_free (ctx.filename);
+ grub_free (node);
+ return 0;
+ }
+ if (node->have_dirents >= node->alloc_dirents)
+ {
+ struct grub_fshelp_node *new_node;
+ grub_size_t sz;
+
+ if (grub_mul (node->alloc_dirents, 2, &node->alloc_dirents) ||
+ grub_sub (node->alloc_dirents, ARRAY_SIZE (node->dirents), &sz) ||
+ grub_mul (sz, sizeof (node->dirents[0]), &sz) ||
+ grub_add (sz, sizeof (struct grub_fshelp_node), &sz))
+ goto fail_0;
+
+ new_node = grub_realloc (node, sz);
+ if (!new_node)
+ {
+ fail_0:
+ if (ctx.filename_alloc)
+ grub_free (ctx.filename);
+ grub_free (node);
+ return 0;
+ }
+ node = new_node;
+ }
+ node->dirents[node->have_dirents++] = dirent;
+ }
+ if (ctx.symlink)
+ {
+ if ((node->alloc_dirents - node->have_dirents)
+ * sizeof (node->dirents[0]) < grub_strlen (ctx.symlink) + 1)
+ {
+ struct grub_fshelp_node *new_node;
+ grub_size_t sz;
+
+ if (grub_sub (node->alloc_dirents, ARRAY_SIZE (node->dirents), &sz) ||
+ grub_mul (sz, sizeof (node->dirents[0]), &sz) ||
+ grub_add (sz, sizeof (struct grub_fshelp_node) + 1, &sz) ||
+ grub_add (sz, grub_strlen (ctx.symlink), &sz))
+ goto fail_1;
+
+ new_node = grub_realloc (node, sz);
+ if (!new_node)
+ {
+ fail_1:
+ if (ctx.filename_alloc)
+ grub_free (ctx.filename);
+ grub_free (node);
+ return 0;
+ }
+ node = new_node;
+ }
+ node->have_symlink = 1;
+ grub_strcpy (node->symlink
+ + node->have_dirents * sizeof (node->dirents[0])
+ - sizeof (node->dirents), ctx.symlink);
+ grub_free (ctx.symlink);
+ ctx.symlink = 0;
+ ctx.was_continue = 0;
+ }
+ if (hook (ctx.filename, ctx.type, node, hook_data))
+ {
+ if (ctx.filename_alloc)
+ grub_free (ctx.filename);
+ return 1;
+ }
+ if (ctx.filename_alloc)
+ grub_free (ctx.filename);
+ }
+ }
+
+ return 0;
+}
+
+
+
+/* Context for grub_iso9660_dir. */
+struct grub_iso9660_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_iso9660_dir. */
+static int
+grub_iso9660_dir_iter (const char *filename,
+ enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_iso9660_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ info.mtimeset = !!iso9660_to_unixtime2 (&node->dirents[0].mtime, &info.mtime);
+
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_iso9660_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_iso9660_dir_ctx ctx = { hook, hook_data };
+ struct grub_iso9660_data *data = 0;
+ struct grub_fshelp_node rootnode;
+ struct grub_fshelp_node *foundnode;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_iso9660_mount (device->disk);
+ if (! data)
+ goto fail;
+
+ rootnode.data = data;
+ rootnode.alloc_dirents = 0;
+ rootnode.have_dirents = 1;
+ rootnode.have_symlink = 0;
+ rootnode.dirents[0] = data->voldesc.rootdir;
+
+ /* Use the fshelp function to traverse the path. */
+ if (grub_fshelp_find_file (path, &rootnode,
+ &foundnode,
+ grub_iso9660_iterate_dir,
+ grub_iso9660_read_symlink,
+ GRUB_FSHELP_DIR))
+ goto fail;
+
+ /* List the files in the directory. */
+ grub_iso9660_iterate_dir (foundnode, grub_iso9660_dir_iter, &ctx);
+
+ if (foundnode != &rootnode)
+ grub_free (foundnode);
+
+ fail:
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_iso9660_open (struct grub_file *file, const char *name)
+{
+ struct grub_iso9660_data *data;
+ struct grub_fshelp_node rootnode;
+ struct grub_fshelp_node *foundnode;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_iso9660_mount (file->device->disk);
+ if (!data)
+ goto fail;
+
+ rootnode.data = data;
+ rootnode.alloc_dirents = 0;
+ rootnode.have_dirents = 1;
+ rootnode.have_symlink = 0;
+ rootnode.dirents[0] = data->voldesc.rootdir;
+
+ /* Use the fshelp function to traverse the path. */
+ if (grub_fshelp_find_file (name, &rootnode,
+ &foundnode,
+ grub_iso9660_iterate_dir,
+ grub_iso9660_read_symlink,
+ GRUB_FSHELP_REG))
+ goto fail;
+
+ data->node = foundnode;
+ file->data = data;
+ file->size = get_node_size (foundnode);
+ file->offset = 0;
+
+ return 0;
+
+ fail:
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+static grub_ssize_t
+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;
+ err = read_node (data->node, file->offset, len, buf);
+ data->disk->read_hook = NULL;
+
+ if (err || grub_errno)
+ return -1;
+
+ return len;
+}
+
+
+static grub_err_t
+grub_iso9660_close (grub_file_t file)
+{
+ struct grub_iso9660_data *data =
+ (struct grub_iso9660_data *) file->data;
+ grub_free (data->node);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+
+static grub_err_t
+grub_iso9660_label (grub_device_t device, char **label)
+{
+ struct grub_iso9660_data *data;
+ data = grub_iso9660_mount (device->disk);
+
+ if (data)
+ {
+ if (data->joliet)
+ *label = grub_iso9660_convert_string (data->voldesc.volname, 16);
+ else
+ *label = grub_strndup ((char *) data->voldesc.volname, 32);
+ if (*label)
+ {
+ char *ptr;
+ for (ptr = *label; *ptr;ptr++);
+ ptr--;
+ while (ptr >= *label && *ptr == ' ')
+ *ptr-- = 0;
+ }
+
+ grub_free (data);
+ }
+ else
+ *label = 0;
+
+ return grub_errno;
+}
+
+
+static grub_err_t
+grub_iso9660_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_iso9660_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_iso9660_mount (disk);
+ if (data)
+ {
+ if (! data->voldesc.modified.year[0] && ! data->voldesc.modified.year[1]
+ && ! data->voldesc.modified.year[2] && ! data->voldesc.modified.year[3]
+ && ! data->voldesc.modified.month[0] && ! data->voldesc.modified.month[1]
+ && ! data->voldesc.modified.day[0] && ! data->voldesc.modified.day[1]
+ && ! data->voldesc.modified.hour[0] && ! data->voldesc.modified.hour[1]
+ && ! data->voldesc.modified.minute[0] && ! data->voldesc.modified.minute[1]
+ && ! data->voldesc.modified.second[0] && ! data->voldesc.modified.second[1]
+ && ! data->voldesc.modified.hundredth[0] && ! data->voldesc.modified.hundredth[1])
+ {
+ grub_error (GRUB_ERR_BAD_NUMBER, "no creation date in filesystem to generate UUID");
+ *uuid = NULL;
+ }
+ else
+ {
+ *uuid = grub_xasprintf ("%c%c%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c",
+ data->voldesc.modified.year[0],
+ data->voldesc.modified.year[1],
+ data->voldesc.modified.year[2],
+ data->voldesc.modified.year[3],
+ data->voldesc.modified.month[0],
+ data->voldesc.modified.month[1],
+ data->voldesc.modified.day[0],
+ data->voldesc.modified.day[1],
+ data->voldesc.modified.hour[0],
+ data->voldesc.modified.hour[1],
+ data->voldesc.modified.minute[0],
+ data->voldesc.modified.minute[1],
+ data->voldesc.modified.second[0],
+ data->voldesc.modified.second[1],
+ data->voldesc.modified.hundredth[0],
+ data->voldesc.modified.hundredth[1]);
+ }
+ }
+ else
+ *uuid = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+/* Get writing time of filesystem. */
+static grub_err_t
+grub_iso9660_mtime (grub_device_t device, grub_int64_t *timebuf)
+{
+ struct grub_iso9660_data *data;
+ grub_disk_t disk = device->disk;
+ grub_err_t err;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_iso9660_mount (disk);
+ if (!data)
+ {
+ grub_dl_unref (my_mod);
+ return grub_errno;
+ }
+ err = iso9660_to_unixtime (&data->voldesc.modified, timebuf);
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return err;
+}
+
+
+
+
+static struct grub_fs grub_iso9660_fs =
+ {
+ .name = "iso9660",
+ .fs_dir = grub_iso9660_dir,
+ .fs_open = grub_iso9660_open,
+ .fs_read = grub_iso9660_read,
+ .fs_close = grub_iso9660_close,
+ .fs_label = grub_iso9660_label,
+ .fs_uuid = grub_iso9660_uuid,
+ .fs_mtime = grub_iso9660_mtime,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(iso9660)
+{
+ grub_fs_register (&grub_iso9660_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(iso9660)
+{
+ grub_fs_unregister (&grub_iso9660_fs);
+}
diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c
new file mode 100644
index 0000000..6f7c439
--- /dev/null
+++ b/grub-core/fs/jfs.c
@@ -0,0 +1,973 @@
+/* jfs.c - JFS. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/charset.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_JFS_MAX_SYMLNK_CNT 8
+#define GRUB_JFS_FILETYPE_MASK 0170000
+#define GRUB_JFS_FILETYPE_REG 0100000
+#define GRUB_JFS_FILETYPE_LNK 0120000
+#define GRUB_JFS_FILETYPE_DIR 0040000
+
+#define GRUB_JFS_SBLOCK 64
+#define GRUB_JFS_AGGR_INODE 2
+#define GRUB_JFS_FS1_INODE_BLK 104
+
+#define GRUB_JFS_TREE_LEAF 2
+
+struct grub_jfs_sblock
+{
+ /* The magic for JFS. It should contain the string "JFS1". */
+ grub_uint8_t magic[4];
+ grub_uint32_t version;
+ grub_uint64_t ag_size;
+
+ /* The size of a filesystem block in bytes. XXX: currently only
+ 4096 was tested. */
+ grub_uint32_t blksz;
+ grub_uint16_t log2_blksz;
+ grub_uint8_t unused[14];
+ grub_uint32_t flags;
+ grub_uint8_t unused3[61];
+ char volname[11];
+ grub_uint8_t unused2[24];
+ grub_uint8_t uuid[16];
+ char volname2[16];
+};
+
+struct grub_jfs_extent
+{
+ /* The length of the extent in filesystem blocks. */
+ grub_uint16_t length;
+ grub_uint8_t length2;
+
+ /* The physical offset of the first block on the disk. */
+ grub_uint8_t blk1;
+ grub_uint32_t blk2;
+} GRUB_PACKED;
+
+#define GRUB_JFS_IAG_INODES_OFFSET 3072
+#define GRUB_JFS_IAG_INODES_COUNT 128
+
+struct grub_jfs_iag
+{
+ grub_uint8_t unused[GRUB_JFS_IAG_INODES_OFFSET];
+ struct grub_jfs_extent inodes[GRUB_JFS_IAG_INODES_COUNT];
+} GRUB_PACKED;
+
+
+/* The head of the tree used to find extents. */
+struct grub_jfs_treehead
+{
+ grub_uint64_t next;
+ grub_uint64_t prev;
+
+ grub_uint8_t flags;
+ grub_uint8_t unused;
+
+ grub_uint16_t count;
+ grub_uint16_t max;
+ grub_uint8_t unused2[10];
+} GRUB_PACKED;
+
+/* A node in the extent tree. */
+struct grub_jfs_tree_extent
+{
+ grub_uint8_t flags;
+ grub_uint16_t unused;
+
+ /* The offset is the key used to lookup an extent. */
+ grub_uint8_t offset1;
+ grub_uint32_t offset2;
+
+ struct grub_jfs_extent extent;
+} GRUB_PACKED;
+
+/* The tree of directory entries. */
+struct grub_jfs_tree_dir
+{
+ /* Pointers to the previous and next tree headers of other nodes on
+ this level. */
+ grub_uint64_t nextb;
+ grub_uint64_t prevb;
+
+ grub_uint8_t flags;
+
+ /* The amount of dirents in this node. */
+ grub_uint8_t count;
+ grub_uint8_t freecnt;
+ grub_uint8_t freelist;
+ grub_uint8_t maxslot;
+
+ /* The location of the sorted array of pointers to dirents. */
+ grub_uint8_t sindex;
+ grub_uint8_t unused[10];
+} GRUB_PACKED;
+
+/* An internal node in the dirents tree. */
+struct grub_jfs_internal_dirent
+{
+ struct grub_jfs_extent ex;
+ grub_uint8_t next;
+ grub_uint8_t len;
+ grub_uint16_t namepart[11];
+} GRUB_PACKED;
+
+/* A leaf node in the dirents tree. */
+struct grub_jfs_leaf_dirent
+{
+ /* The inode for this dirent. */
+ grub_uint32_t inode;
+ grub_uint8_t next;
+
+ /* The size of the name. */
+ grub_uint8_t len;
+ grub_uint16_t namepart[11];
+ grub_uint32_t index;
+} GRUB_PACKED;
+
+/* A leaf in the dirents tree. This one is used if the previously
+ dirent was not big enough to store the name. */
+struct grub_jfs_leaf_next_dirent
+{
+ grub_uint8_t next;
+ grub_uint8_t len;
+ grub_uint16_t namepart[15];
+} GRUB_PACKED;
+
+struct grub_jfs_time
+{
+ grub_int32_t sec;
+ grub_int32_t nanosec;
+} GRUB_PACKED;
+
+struct grub_jfs_inode
+{
+ grub_uint32_t stamp;
+ grub_uint32_t fileset;
+ grub_uint32_t inode;
+ grub_uint8_t unused[12];
+ grub_uint64_t size;
+ grub_uint8_t unused2[20];
+ grub_uint32_t mode;
+ struct grub_jfs_time atime;
+ struct grub_jfs_time ctime;
+ struct grub_jfs_time mtime;
+ grub_uint8_t unused3[48];
+ grub_uint8_t unused4[96];
+
+ union
+ {
+ /* The tree describing the extents of the file. */
+ struct GRUB_PACKED
+ {
+ struct grub_jfs_treehead tree;
+ struct grub_jfs_tree_extent extents[16];
+ } file;
+ union
+ {
+ /* The tree describing the dirents. */
+ struct
+ {
+ grub_uint8_t unused[16];
+ grub_uint8_t flags;
+
+ /* Amount of dirents in this node. */
+ grub_uint8_t count;
+ grub_uint8_t freecnt;
+ grub_uint8_t freelist;
+ grub_uint32_t idotdot;
+ grub_uint8_t sorted[8];
+ } header;
+ struct grub_jfs_leaf_dirent dirents[8];
+ } GRUB_PACKED dir;
+ /* Fast symlink. */
+ struct
+ {
+ grub_uint8_t unused[32];
+ grub_uint8_t path[256];
+ } symlink;
+ } GRUB_PACKED;
+} GRUB_PACKED;
+
+struct grub_jfs_data
+{
+ struct grub_jfs_sblock sblock;
+ grub_disk_t disk;
+ struct grub_jfs_inode fileset;
+ struct grub_jfs_inode currinode;
+ int caseins;
+ int pos;
+ int linknest;
+ int namecomponentlen;
+} GRUB_PACKED;
+
+struct grub_jfs_diropen
+{
+ int index;
+ union
+ {
+ struct grub_jfs_tree_dir header;
+ struct grub_jfs_leaf_dirent dirent[0];
+ struct grub_jfs_leaf_next_dirent next_dirent[0];
+ grub_uint8_t sorted[0];
+ } GRUB_PACKED *dirpage;
+ struct grub_jfs_data *data;
+ struct grub_jfs_inode *inode;
+ int count;
+ grub_uint8_t *sorted;
+ struct grub_jfs_leaf_dirent *leaf;
+ struct grub_jfs_leaf_next_dirent *next_leaf;
+
+ /* The filename and inode of the last read dirent. */
+ /* On-disk name is at most 255 UTF-16 codepoints.
+ Every UTF-16 codepoint is at most 4 UTF-8 bytes.
+ */
+ char name[256 * GRUB_MAX_UTF8_PER_UTF16 + 1];
+ grub_uint32_t ino;
+} GRUB_PACKED;
+
+
+static grub_dl_t my_mod;
+
+static grub_err_t grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino);
+
+static grub_int64_t
+getblk (struct grub_jfs_treehead *treehead,
+ struct grub_jfs_tree_extent *extents,
+ int max_extents,
+ struct grub_jfs_data *data,
+ grub_uint64_t blk)
+{
+ int found = -1;
+ int i;
+
+ for (i = 0; i < grub_le_to_cpu16 (treehead->count) - 2 &&
+ i < max_extents; i++)
+ {
+ if (treehead->flags & GRUB_JFS_TREE_LEAF)
+ {
+ /* Read the leafnode. */
+ if (grub_le_to_cpu32 (extents[i].offset2) <= blk
+ && ((grub_le_to_cpu16 (extents[i].extent.length))
+ + (extents[i].extent.length2 << 16)
+ + grub_le_to_cpu32 (extents[i].offset2)) > blk)
+ return (blk - grub_le_to_cpu32 (extents[i].offset2)
+ + grub_le_to_cpu32 (extents[i].extent.blk2));
+ }
+ else
+ if (blk >= grub_le_to_cpu32 (extents[i].offset2))
+ found = i;
+ }
+
+ if (found != -1)
+ {
+ grub_int64_t ret = -1;
+ struct
+ {
+ struct grub_jfs_treehead treehead;
+ struct grub_jfs_tree_extent extents[254];
+ } *tree;
+
+ tree = grub_zalloc (sizeof (*tree));
+ if (!tree)
+ return -1;
+
+ if (!grub_disk_read (data->disk,
+ ((grub_disk_addr_t) grub_le_to_cpu32 (extents[found].extent.blk2))
+ << (grub_le_to_cpu16 (data->sblock.log2_blksz)
+ - GRUB_DISK_SECTOR_BITS), 0,
+ sizeof (*tree), (char *) tree))
+ {
+ if (grub_memcmp (&tree->treehead, treehead, sizeof (struct grub_jfs_treehead)) ||
+ grub_memcmp (&tree->extents, extents, 254 * sizeof (struct grub_jfs_tree_extent)))
+ ret = getblk (&tree->treehead, &tree->extents[0], 254, data, blk);
+ else
+ {
+ grub_error (GRUB_ERR_BAD_FS, "jfs: infinite recursion detected");
+ ret = -1;
+ }
+ }
+ grub_free (tree);
+ return ret;
+ }
+
+ return -1;
+}
+
+/* Get the block number for the block BLK in the node INODE in the
+ mounted filesystem DATA. */
+static grub_int64_t
+grub_jfs_blkno (struct grub_jfs_data *data, struct grub_jfs_inode *inode,
+ grub_uint64_t blk)
+{
+ return getblk (&inode->file.tree, &inode->file.extents[0], 16, data, blk);
+}
+
+
+static grub_err_t
+grub_jfs_read_inode (struct grub_jfs_data *data, grub_uint32_t ino,
+ struct grub_jfs_inode *inode)
+{
+ struct grub_jfs_extent iag_inodes[GRUB_JFS_IAG_INODES_COUNT];
+ grub_uint32_t iagnum = ino / 4096;
+ unsigned inoext = (ino % 4096) / 32;
+ unsigned inonum = (ino % 4096) % 32;
+ grub_uint64_t iagblk;
+ grub_uint64_t inoblk;
+
+ iagblk = grub_jfs_blkno (data, &data->fileset, iagnum + 1);
+ if (grub_errno)
+ return grub_errno;
+
+ /* Read in the IAG. */
+ if (grub_disk_read (data->disk,
+ iagblk << (grub_le_to_cpu16 (data->sblock.log2_blksz)
+ - GRUB_DISK_SECTOR_BITS),
+ GRUB_JFS_IAG_INODES_OFFSET,
+ sizeof (iag_inodes), &iag_inodes))
+ return grub_errno;
+
+ inoblk = grub_le_to_cpu32 (iag_inodes[inoext].blk2);
+ inoblk <<= (grub_le_to_cpu16 (data->sblock.log2_blksz)
+ - GRUB_DISK_SECTOR_BITS);
+ inoblk += inonum;
+
+ if (grub_disk_read (data->disk, inoblk, 0,
+ sizeof (struct grub_jfs_inode), inode))
+ return grub_errno;
+
+ return 0;
+}
+
+
+static struct grub_jfs_data *
+grub_jfs_mount (grub_disk_t disk)
+{
+ struct grub_jfs_data *data = 0;
+
+ data = grub_malloc (sizeof (struct grub_jfs_data));
+ if (!data)
+ return 0;
+
+ /* Read the superblock. */
+ if (grub_disk_read (disk, GRUB_JFS_SBLOCK, 0,
+ sizeof (struct grub_jfs_sblock), &data->sblock))
+ goto fail;
+
+ if (grub_strncmp ((char *) (data->sblock.magic), "JFS1", 4))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not a JFS filesystem");
+ goto fail;
+ }
+
+ if (data->sblock.blksz == 0
+ || grub_le_to_cpu32 (data->sblock.blksz)
+ != (1U << grub_le_to_cpu16 (data->sblock.log2_blksz))
+ || grub_le_to_cpu16 (data->sblock.log2_blksz) < GRUB_DISK_SECTOR_BITS)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not a JFS filesystem");
+ goto fail;
+ }
+
+ data->disk = disk;
+ data->pos = 0;
+ data->linknest = 0;
+
+ /* Read the inode of the first fileset. */
+ if (grub_disk_read (data->disk, GRUB_JFS_FS1_INODE_BLK, 0,
+ sizeof (struct grub_jfs_inode), &data->fileset))
+ goto fail;
+
+ if (data->sblock.flags & grub_cpu_to_le32_compile_time (0x00200000))
+ data->namecomponentlen = 11;
+ else
+ data->namecomponentlen = 13;
+
+ if (data->sblock.flags & grub_cpu_to_le32_compile_time (0x40000000))
+ data->caseins = 1;
+ else
+ data->caseins = 0;
+
+ return data;
+
+ fail:
+ grub_free (data);
+
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not a JFS filesystem");
+
+ return 0;
+}
+
+
+static struct grub_jfs_diropen *
+grub_jfs_opendir (struct grub_jfs_data *data, struct grub_jfs_inode *inode)
+{
+ struct grub_jfs_internal_dirent *de;
+ struct grub_jfs_diropen *diro;
+ grub_disk_addr_t blk;
+
+ de = (struct grub_jfs_internal_dirent *) inode->dir.dirents;
+
+ if (!((grub_le_to_cpu32 (inode->mode)
+ & GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_DIR))
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+ return 0;
+ }
+
+ diro = grub_zalloc (sizeof (struct grub_jfs_diropen));
+ if (!diro)
+ return 0;
+
+ diro->data = data;
+ diro->inode = inode;
+
+ /* Check if the entire tree is contained within the inode. */
+ if (inode->file.tree.flags & GRUB_JFS_TREE_LEAF)
+ {
+ diro->leaf = inode->dir.dirents;
+ diro->next_leaf = (struct grub_jfs_leaf_next_dirent *) de;
+ diro->sorted = inode->dir.header.sorted;
+ diro->count = inode->dir.header.count;
+
+ return diro;
+ }
+
+ diro->dirpage = grub_malloc (grub_le_to_cpu32 (data->sblock.blksz));
+ if (!diro->dirpage)
+ {
+ grub_free (diro);
+ return 0;
+ }
+
+ blk = grub_le_to_cpu32 (de[inode->dir.header.sorted[0]].ex.blk2);
+ blk <<= (grub_le_to_cpu16 (data->sblock.log2_blksz) - GRUB_DISK_SECTOR_BITS);
+
+ /* Read in the nodes until we are on the leaf node level. */
+ do
+ {
+ int index;
+ if (grub_disk_read (data->disk, blk, 0,
+ grub_le_to_cpu32 (data->sblock.blksz),
+ diro->dirpage->sorted))
+ {
+ grub_free (diro->dirpage);
+ grub_free (diro);
+ return 0;
+ }
+
+ de = (struct grub_jfs_internal_dirent *) diro->dirpage->dirent;
+ index = diro->dirpage->sorted[diro->dirpage->header.sindex * 32];
+ blk = (grub_le_to_cpu32 (de[index].ex.blk2)
+ << (grub_le_to_cpu16 (data->sblock.log2_blksz)
+ - GRUB_DISK_SECTOR_BITS));
+ } while (!(diro->dirpage->header.flags & GRUB_JFS_TREE_LEAF));
+
+ diro->leaf = diro->dirpage->dirent;
+ diro->next_leaf = diro->dirpage->next_dirent;
+ diro->sorted = &diro->dirpage->sorted[diro->dirpage->header.sindex * 32];
+ diro->count = diro->dirpage->header.count;
+
+ return diro;
+}
+
+
+static void
+grub_jfs_closedir (struct grub_jfs_diropen *diro)
+{
+ if (!diro)
+ return;
+ grub_free (diro->dirpage);
+ grub_free (diro);
+}
+
+static void
+le_to_cpu16_copy (grub_uint16_t *out, grub_uint16_t *in, grub_size_t len)
+{
+ while (len--)
+ *out++ = grub_le_to_cpu16 (*in++);
+}
+
+#if __GNUC__ >= 9
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
+/* Read in the next dirent from the directory described by DIRO. */
+static grub_err_t
+grub_jfs_getent (struct grub_jfs_diropen *diro)
+{
+ int strpos = 0;
+ struct grub_jfs_leaf_dirent *leaf;
+ struct grub_jfs_leaf_next_dirent *next_leaf;
+ int len;
+ int nextent;
+ grub_uint16_t filename[256];
+
+ /* The last node, read in more. */
+ if (diro->index == diro->count)
+ {
+ grub_disk_addr_t next;
+
+ /* If the inode contains the entry tree or if this was the last
+ node, there is nothing to read. */
+ if ((diro->inode->file.tree.flags & GRUB_JFS_TREE_LEAF)
+ || !grub_le_to_cpu64 (diro->dirpage->header.nextb))
+ return GRUB_ERR_OUT_OF_RANGE;
+
+ next = grub_le_to_cpu64 (diro->dirpage->header.nextb);
+ next <<= (grub_le_to_cpu16 (diro->data->sblock.log2_blksz)
+ - GRUB_DISK_SECTOR_BITS);
+
+ if (grub_disk_read (diro->data->disk, next, 0,
+ grub_le_to_cpu32 (diro->data->sblock.blksz),
+ diro->dirpage->sorted))
+ return grub_errno;
+
+ diro->leaf = diro->dirpage->dirent;
+ diro->next_leaf = diro->dirpage->next_dirent;
+ diro->sorted = &diro->dirpage->sorted[diro->dirpage->header.sindex * 32];
+ diro->count = diro->dirpage->header.count;
+ diro->index = 0;
+ }
+
+ leaf = &diro->leaf[diro->sorted[diro->index]];
+ next_leaf = &diro->next_leaf[diro->index];
+
+ len = leaf->len;
+ if (!len)
+ {
+ diro->index++;
+ return grub_jfs_getent (diro);
+ }
+
+ le_to_cpu16_copy (filename + strpos, leaf->namepart, len < diro->data->namecomponentlen ? len
+ : diro->data->namecomponentlen);
+ strpos += len < diro->data->namecomponentlen ? len
+ : diro->data->namecomponentlen;
+ diro->ino = grub_le_to_cpu32 (leaf->inode);
+ len -= diro->data->namecomponentlen;
+
+ /* Move down to the leaf level. */
+ nextent = leaf->next;
+ if (leaf->next != 255 && len > 0)
+ do
+ {
+ next_leaf = &diro->next_leaf[nextent];
+ le_to_cpu16_copy (filename + strpos, next_leaf->namepart, len < 15 ? len : 15);
+ strpos += len < 15 ? len : 15;
+
+ len -= 15;
+ nextent = next_leaf->next;
+ } while (next_leaf->next != 255 && len > 0);
+
+ diro->index++;
+
+ /* Convert the temporary UTF16 filename to UTF8. */
+ *grub_utf16_to_utf8 ((grub_uint8_t *) (diro->name), filename, strpos) = '\0';
+
+ return 0;
+}
+
+#if __GNUC__ >= 9
+#pragma GCC diagnostic pop
+#endif
+
+/* Read LEN bytes from the file described by DATA starting with byte
+ POS. Return the amount of read bytes in READ. */
+static grub_ssize_t
+grub_jfs_read_file (struct grub_jfs_data *data,
+ grub_disk_read_hook_t read_hook, void *read_hook_data,
+ grub_off_t pos, grub_size_t len, char *buf)
+{
+ grub_off_t i;
+ grub_off_t blockcnt;
+
+ blockcnt = (len + pos + grub_le_to_cpu32 (data->sblock.blksz) - 1)
+ >> grub_le_to_cpu16 (data->sblock.log2_blksz);
+
+ for (i = pos >> grub_le_to_cpu16 (data->sblock.log2_blksz); i < blockcnt; i++)
+ {
+ grub_disk_addr_t blknr;
+ grub_uint32_t blockoff = pos & (grub_le_to_cpu32 (data->sblock.blksz) - 1);
+ grub_uint32_t blockend = grub_le_to_cpu32 (data->sblock.blksz);
+
+ grub_uint64_t skipfirst = 0;
+
+ blknr = grub_jfs_blkno (data, &data->currinode, i);
+ if (grub_errno)
+ return -1;
+
+ /* Last block. */
+ if (i == blockcnt - 1)
+ {
+ blockend = (len + pos) & (grub_le_to_cpu32 (data->sblock.blksz) - 1);
+
+ if (!blockend)
+ blockend = grub_le_to_cpu32 (data->sblock.blksz);
+ }
+
+ /* First block. */
+ if (i == (pos >> grub_le_to_cpu16 (data->sblock.log2_blksz)))
+ {
+ skipfirst = blockoff;
+ blockend -= skipfirst;
+ }
+
+ data->disk->read_hook = read_hook;
+ data->disk->read_hook_data = read_hook_data;
+ grub_disk_read (data->disk,
+ blknr << (grub_le_to_cpu16 (data->sblock.log2_blksz)
+ - GRUB_DISK_SECTOR_BITS),
+ skipfirst, blockend, buf);
+
+ data->disk->read_hook = 0;
+ if (grub_errno)
+ return -1;
+
+ buf += grub_le_to_cpu32 (data->sblock.blksz) - skipfirst;
+ }
+
+ return len;
+}
+
+
+/* Find the file with the pathname PATH on the filesystem described by
+ DATA. */
+static grub_err_t
+grub_jfs_find_file (struct grub_jfs_data *data, const char *path,
+ grub_uint32_t start_ino)
+{
+ const char *name;
+ const char *next = path;
+ struct grub_jfs_diropen *diro = NULL;
+
+ if (grub_jfs_read_inode (data, start_ino, &data->currinode))
+ return grub_errno;
+
+ while (1)
+ {
+ name = next;
+ while (*name == '/')
+ name++;
+ if (name[0] == 0)
+ return GRUB_ERR_NONE;
+ for (next = name; *next && *next != '/'; next++);
+
+ if (name[0] == '.' && name + 1 == next)
+ continue;
+
+ if (name[0] == '.' && name[1] == '.' && name + 2 == next)
+ {
+ grub_uint32_t ino = grub_le_to_cpu32 (data->currinode.dir.header.idotdot);
+
+ if (grub_jfs_read_inode (data, ino, &data->currinode))
+ return grub_errno;
+
+ continue;
+ }
+
+ diro = grub_jfs_opendir (data, &data->currinode);
+ if (!diro)
+ return grub_errno;
+
+ for (;;)
+ {
+ if (grub_jfs_getent (diro) == GRUB_ERR_OUT_OF_RANGE)
+ {
+ grub_jfs_closedir (diro);
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
+ }
+
+ /* Check if the current direntry matches the current part of the
+ pathname. */
+ if ((data->caseins ? grub_strncasecmp (name, diro->name, next - name) == 0
+ : grub_strncmp (name, diro->name, next - name) == 0) && !diro->name[next - name])
+ {
+ grub_uint32_t ino = diro->ino;
+ grub_uint32_t dirino = grub_le_to_cpu32 (data->currinode.inode);
+
+ grub_jfs_closedir (diro);
+ diro = 0;
+
+ if (grub_jfs_read_inode (data, ino, &data->currinode))
+ break;
+
+ /* Check if this is a symlink. */
+ if ((grub_le_to_cpu32 (data->currinode.mode)
+ & GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_LNK)
+ {
+ grub_jfs_lookup_symlink (data, dirino);
+ if (grub_errno)
+ return grub_errno;
+ }
+
+ break;
+ }
+ }
+ }
+}
+
+
+static grub_err_t
+grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino)
+{
+ grub_size_t size = grub_le_to_cpu64 (data->currinode.size);
+ char *symlink;
+
+ if (++data->linknest > GRUB_JFS_MAX_SYMLNK_CNT)
+ return grub_error (GRUB_ERR_SYMLINK_LOOP, N_("too deep nesting of symlinks"));
+
+ symlink = grub_malloc (size + 1);
+ if (!symlink)
+ return grub_errno;
+ if (size <= sizeof (data->currinode.symlink.path))
+ grub_memcpy (symlink, (char *) (data->currinode.symlink.path), size);
+ else if (grub_jfs_read_file (data, 0, 0, 0, size, symlink) < 0)
+ {
+ grub_free (symlink);
+ return grub_errno;
+ }
+
+ symlink[size] = '\0';
+
+ /* The symlink is an absolute path, go back to the root inode. */
+ if (symlink[0] == '/')
+ ino = 2;
+
+ grub_jfs_find_file (data, symlink, ino);
+
+ grub_free (symlink);
+
+ return grub_errno;
+}
+
+
+static grub_err_t
+grub_jfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_jfs_data *data = 0;
+ struct grub_jfs_diropen *diro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_jfs_mount (device->disk);
+ if (!data)
+ goto fail;
+
+ if (grub_jfs_find_file (data, path, GRUB_JFS_AGGR_INODE))
+ goto fail;
+
+ diro = grub_jfs_opendir (data, &data->currinode);
+ if (!diro)
+ goto fail;
+
+ /* Iterate over the dirents in the directory that was found. */
+ while (grub_jfs_getent (diro) != GRUB_ERR_OUT_OF_RANGE)
+ {
+ struct grub_jfs_inode inode;
+ struct grub_dirhook_info info;
+ grub_memset (&info, 0, sizeof (info));
+
+ if (grub_jfs_read_inode (data, diro->ino, &inode))
+ goto fail;
+
+ info.dir = (grub_le_to_cpu32 (inode.mode)
+ & GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_DIR;
+ info.mtimeset = 1;
+ info.mtime = grub_le_to_cpu32 (inode.mtime.sec);
+ if (hook (diro->name, &info, hook_data))
+ goto fail;
+ }
+
+ /* XXX: GRUB_ERR_OUT_OF_RANGE is used for the last dirent. */
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_errno = 0;
+
+ fail:
+ grub_jfs_closedir (diro);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_jfs_open (struct grub_file *file, const char *name)
+{
+ struct grub_jfs_data *data;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_jfs_mount (file->device->disk);
+ if (!data)
+ goto fail;
+
+ grub_jfs_find_file (data, name, GRUB_JFS_AGGR_INODE);
+ if (grub_errno)
+ goto fail;
+
+ /* It is only possible for open regular files. */
+ if (! ((grub_le_to_cpu32 (data->currinode.mode)
+ & GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_REG))
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
+ goto fail;
+ }
+
+ file->data = data;
+ file->size = grub_le_to_cpu64 (data->currinode.size);
+
+ return 0;
+
+ fail:
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+static grub_ssize_t
+grub_jfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_jfs_data *data =
+ (struct grub_jfs_data *) file->data;
+
+ return grub_jfs_read_file (data, file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+
+static grub_err_t
+grub_jfs_close (grub_file_t file)
+{
+ grub_free (file->data);
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_jfs_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_jfs_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_jfs_mount (disk);
+ if (data)
+ {
+ *uuid = grub_xasprintf ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
+ "%02x%02x%02x%02x%02x%02x",
+ data->sblock.uuid[0], data->sblock.uuid[1],
+ data->sblock.uuid[2], data->sblock.uuid[3],
+ data->sblock.uuid[4], data->sblock.uuid[5],
+ data->sblock.uuid[6], data->sblock.uuid[7],
+ data->sblock.uuid[8], data->sblock.uuid[9],
+ data->sblock.uuid[10], data->sblock.uuid[11],
+ data->sblock.uuid[12], data->sblock.uuid[13],
+ data->sblock.uuid[14], data->sblock.uuid[15]);
+ }
+ else
+ *uuid = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_jfs_label (grub_device_t device, char **label)
+{
+ struct grub_jfs_data *data;
+ data = grub_jfs_mount (device->disk);
+
+ if (data)
+ {
+ if (data->sblock.volname2[0] < ' ')
+ {
+ char *ptr;
+ ptr = data->sblock.volname + sizeof (data->sblock.volname) - 1;
+ while (ptr >= data->sblock.volname && *ptr == ' ')
+ ptr--;
+ *label = grub_strndup (data->sblock.volname,
+ ptr - data->sblock.volname + 1);
+ }
+ else
+ *label = grub_strndup (data->sblock.volname2,
+ sizeof (data->sblock.volname2));
+ }
+ else
+ *label = 0;
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+static struct grub_fs grub_jfs_fs =
+ {
+ .name = "jfs",
+ .fs_dir = grub_jfs_dir,
+ .fs_open = grub_jfs_open,
+ .fs_read = grub_jfs_read,
+ .fs_close = grub_jfs_close,
+ .fs_label = grub_jfs_label,
+ .fs_uuid = grub_jfs_uuid,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(jfs)
+{
+ grub_fs_register (&grub_jfs_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(jfs)
+{
+ grub_fs_unregister (&grub_jfs_fs);
+}
diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c
new file mode 100644
index 0000000..3cd18c8
--- /dev/null
+++ b/grub-core/fs/minix.c
@@ -0,0 +1,758 @@
+/* minix.c - The minix filesystem, version 1 and 2. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2005,2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#ifdef MODE_MINIX3
+#define GRUB_MINIX_MAGIC 0x4D5A
+#elif defined(MODE_MINIX2)
+#define GRUB_MINIX_MAGIC 0x2468
+#define GRUB_MINIX_MAGIC_30 0x2478
+#else
+#define GRUB_MINIX_MAGIC 0x137F
+#define GRUB_MINIX_MAGIC_30 0x138F
+#endif
+
+#define EXT2_MAGIC 0xEF53
+
+#define GRUB_MINIX_INODE_DIR_BLOCKS 7
+#define GRUB_MINIX_LOG2_BSIZE 1
+#define GRUB_MINIX_ROOT_INODE 1
+#define GRUB_MINIX_MAX_SYMLNK_CNT 8
+#define GRUB_MINIX_SBLOCK 2
+
+#define GRUB_MINIX_IFDIR 0040000U
+#define GRUB_MINIX_IFLNK 0120000U
+
+#ifdef MODE_BIGENDIAN
+#define grub_cpu_to_minix16_compile_time grub_cpu_to_be16_compile_time
+#define grub_minix_to_cpu16 grub_be_to_cpu16
+#define grub_minix_to_cpu32 grub_be_to_cpu32
+#else
+#define grub_cpu_to_minix16_compile_time grub_cpu_to_le16_compile_time
+#define grub_minix_to_cpu16 grub_le_to_cpu16
+#define grub_minix_to_cpu32 grub_le_to_cpu32
+#endif
+
+#if defined(MODE_MINIX2) || defined(MODE_MINIX3)
+typedef grub_uint32_t grub_minix_uintn_t;
+#define grub_minix_to_cpu_n grub_minix_to_cpu32
+#else
+typedef grub_uint16_t grub_minix_uintn_t;
+#define grub_minix_to_cpu_n grub_minix_to_cpu16
+#endif
+
+#ifdef MODE_MINIX3
+typedef grub_uint32_t grub_minix_ino_t;
+#define grub_minix_to_cpu_ino grub_minix_to_cpu32
+#else
+typedef grub_uint16_t grub_minix_ino_t;
+#define grub_minix_to_cpu_ino grub_minix_to_cpu16
+#endif
+
+#define GRUB_MINIX_INODE_SIZE(data) (grub_minix_to_cpu32 (data->inode.size))
+#define GRUB_MINIX_INODE_MODE(data) (grub_minix_to_cpu16 (data->inode.mode))
+#define GRUB_MINIX_INODE_DIR_ZONES(data,blk) (grub_minix_to_cpu_n \
+ (data->inode.dir_zones[blk]))
+#define GRUB_MINIX_INODE_INDIR_ZONE(data) (grub_minix_to_cpu_n \
+ (data->inode.indir_zone))
+#define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_to_cpu_n \
+ (data->inode.double_indir_zone))
+
+
+#ifdef MODE_MINIX3
+struct grub_minix_sblock
+{
+ grub_uint32_t inode_cnt;
+ grub_uint16_t zone_cnt;
+ grub_uint16_t inode_bmap_size;
+ grub_uint16_t zone_bmap_size;
+ grub_uint16_t first_data_zone;
+ grub_uint16_t log2_zone_size;
+ grub_uint16_t pad;
+ grub_uint32_t max_file_size;
+ grub_uint32_t zones;
+ grub_uint16_t magic;
+
+ grub_uint16_t pad2;
+ grub_uint16_t block_size;
+ grub_uint8_t disk_version;
+};
+#else
+struct grub_minix_sblock
+{
+ grub_uint16_t inode_cnt;
+ grub_uint16_t zone_cnt;
+ grub_uint16_t inode_bmap_size;
+ grub_uint16_t zone_bmap_size;
+ grub_uint16_t first_data_zone;
+ grub_uint16_t log2_zone_size;
+ grub_uint32_t max_file_size;
+ grub_uint16_t magic;
+};
+#endif
+
+#if defined(MODE_MINIX3) || defined(MODE_MINIX2)
+struct grub_minix_inode
+{
+ grub_uint16_t mode;
+ grub_uint16_t nlinks;
+ grub_uint16_t uid;
+ grub_uint16_t gid;
+ grub_uint32_t size;
+ grub_uint32_t atime;
+ grub_uint32_t mtime;
+ grub_uint32_t ctime;
+ grub_uint32_t dir_zones[7];
+ grub_uint32_t indir_zone;
+ grub_uint32_t double_indir_zone;
+ grub_uint32_t triple_indir_zone;
+};
+#else
+struct grub_minix_inode
+{
+ grub_uint16_t mode;
+ grub_uint16_t uid;
+ grub_uint32_t size;
+ grub_uint32_t mtime;
+ grub_uint8_t gid;
+ grub_uint8_t nlinks;
+ grub_uint16_t dir_zones[7];
+ grub_uint16_t indir_zone;
+ grub_uint16_t double_indir_zone;
+};
+
+#endif
+
+#if defined(MODE_MINIX3)
+#define MAX_MINIX_FILENAME_SIZE 60
+#else
+#define MAX_MINIX_FILENAME_SIZE 30
+#endif
+
+/* Information about a "mounted" minix filesystem. */
+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;
+ int filename_size;
+ grub_size_t block_size;
+};
+
+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_minix_uintn_t zone,
+ grub_minix_uintn_t num)
+{
+ grub_minix_uintn_t indirn;
+ grub_disk_read (data->disk,
+ 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);
+}
+
+static grub_minix_uintn_t
+grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk)
+{
+ grub_minix_uintn_t indir;
+
+ /* Direct block. */
+ if (blk < GRUB_MINIX_INODE_DIR_BLOCKS)
+ return GRUB_MINIX_INODE_DIR_ZONES (data, blk);
+
+ /* Indirect block. */
+ blk -= GRUB_MINIX_INODE_DIR_BLOCKS;
+ if (blk < data->block_per_zone)
+ {
+ indir = grub_get_indir (data, GRUB_MINIX_INODE_INDIR_ZONE (data), blk);
+ return indir;
+ }
+
+ /* Double indirect block. */
+ 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 / data->block_per_zone);
+
+ indir = grub_get_indir (data, indir, blk % data->block_per_zone);
+
+ return indir;
+ }
+
+#if defined (MODE_MINIX3) || defined (MODE_MINIX2)
+ 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 / 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;
+ }
+#endif
+
+ /* This should never happen. */
+ grub_error (GRUB_ERR_OUT_OF_RANGE, "file bigger than maximum size");
+
+ return 0;
+}
+
+
+/* Read LEN bytes from the file described by DATA starting with byte
+ POS. Return the amount of read bytes in READ. */
+static grub_ssize_t
+grub_minix_read_file (struct grub_minix_data *data,
+ grub_disk_read_hook_t read_hook, void *read_hook_data,
+ grub_off_t pos, grub_size_t len, char *buf)
+{
+ grub_uint32_t i;
+ grub_uint32_t blockcnt;
+ 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;
+ if (len == 0)
+ return 0;
+
+ /* Files are at most 2G/4G - 1 bytes on minixfs. Avoid 64-bit division. */
+ blockcnt = ((grub_uint32_t) ((len + pos - 1)
+ >> GRUB_DISK_SECTOR_BITS)) / data->block_size + 1;
+ posblock = (((grub_uint32_t) pos)
+ / (data->block_size << GRUB_DISK_SECTOR_BITS));
+ blockoff = (((grub_uint32_t) pos)
+ % (data->block_size << GRUB_DISK_SECTOR_BITS));
+
+ for (i = posblock; i < blockcnt; i++)
+ {
+ grub_minix_uintn_t blknr;
+ grub_uint64_t blockend = data->block_size << GRUB_DISK_SECTOR_BITS;
+ grub_off_t skipfirst = 0;
+
+ blknr = grub_minix_get_file_block (data, i);
+ if (grub_errno)
+ return -1;
+
+ /* Last block. */
+ if (i == blockcnt - 1)
+ {
+ /* len + pos < 4G (checked above), so it doesn't overflow. */
+ blockend = (((grub_uint32_t) (len + pos))
+ % (data->block_size << GRUB_DISK_SECTOR_BITS));
+
+ if (!blockend)
+ blockend = data->block_size << GRUB_DISK_SECTOR_BITS;
+ }
+
+ /* First block. */
+ if (i == posblock)
+ {
+ skipfirst = blockoff;
+ blockend -= skipfirst;
+ }
+
+ data->disk->read_hook = read_hook;
+ data->disk->read_hook_data = read_hook_data;
+ grub_disk_read (data->disk,
+ grub_minix_zone2sect(data, blknr),
+ skipfirst, blockend, buf);
+ data->disk->read_hook = 0;
+ if (grub_errno)
+ return -1;
+
+ buf += (data->block_size << GRUB_DISK_SECTOR_BITS) - skipfirst;
+ }
+
+ return len;
+}
+
+
+/* Read inode INO from the mounted filesystem described by DATA. This
+ inode is used by default now. */
+static grub_err_t
+grub_minix_read_inode (struct grub_minix_data *data, grub_minix_ino_t ino)
+{
+ struct grub_minix_sblock *sblock = &data->sblock;
+
+ /* Block in which the inode is stored. */
+ grub_disk_addr_t block;
+ data->ino = ino;
+
+ /* The first inode in minix is inode 1. */
+ ino--;
+ 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
+ / sizeof (struct grub_minix_inode))
+ * sizeof (struct grub_minix_inode));
+
+ grub_disk_read (data->disk, block, offs,
+ sizeof (struct grub_minix_inode), &data->inode);
+
+ return GRUB_ERR_NONE;
+}
+
+
+/* Lookup the symlink the current inode points to. INO is the inode
+ number of the directory the symlink is relative to. */
+static grub_err_t
+grub_minix_lookup_symlink (struct grub_minix_data *data, grub_minix_ino_t ino)
+{
+ char *symlink;
+ grub_size_t sz = GRUB_MINIX_INODE_SIZE (data);
+
+ if (++data->linknest > GRUB_MINIX_MAX_SYMLNK_CNT)
+ return grub_error (GRUB_ERR_SYMLINK_LOOP, N_("too deep nesting of symlinks"));
+
+ symlink = grub_malloc (sz + 1);
+ if (!symlink)
+ return grub_errno;
+ if (grub_minix_read_file (data, 0, 0, 0, sz, symlink) < 0)
+ return grub_errno;
+
+ symlink[sz] = '\0';
+
+ /* The symlink is an absolute path, go back to the root inode. */
+ if (symlink[0] == '/')
+ ino = GRUB_MINIX_ROOT_INODE;
+
+ /* Now load in the old inode. */
+ if (grub_minix_read_inode (data, ino))
+ return grub_errno;
+
+ grub_minix_find_file (data, symlink);
+
+ return grub_errno;
+}
+
+
+/* Find the file with the pathname PATH on the filesystem described by
+ DATA. */
+static grub_err_t
+grub_minix_find_file (struct grub_minix_data *data, const char *path)
+{
+ const char *name;
+ const char *next = path;
+ unsigned int pos = 0;
+ grub_minix_ino_t dirino;
+
+ while (1)
+ {
+ name = next;
+ /* Skip the first slash. */
+ while (*name == '/')
+ name++;
+ if (!*name)
+ return GRUB_ERR_NONE;
+
+ if ((GRUB_MINIX_INODE_MODE (data)
+ & GRUB_MINIX_IFDIR) != GRUB_MINIX_IFDIR)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+
+ /* Extract the actual part from the pathname. */
+ for (next = name; *next && *next != '/'; next++);
+
+ for (pos = 0; ; )
+ {
+ grub_minix_ino_t ino;
+ char filename[MAX_MINIX_FILENAME_SIZE + 1];
+
+ if (pos >= GRUB_MINIX_INODE_SIZE (data))
+ {
+ grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
+ return grub_errno;
+ }
+
+ if (grub_minix_read_file (data, 0, 0, pos, sizeof (ino),
+ (char *) &ino) < 0)
+ return grub_errno;
+ if (grub_minix_read_file (data, 0, 0, pos + sizeof (ino),
+ data->filename_size, (char *) filename)< 0)
+ return grub_errno;
+
+ pos += sizeof (ino) + data->filename_size;
+
+ filename[data->filename_size] = '\0';
+
+ /* Check if the current direntry matches the current part of the
+ pathname. */
+ if (grub_strncmp (name, filename, next - name) == 0
+ && filename[next - name] == '\0')
+ {
+ dirino = data->ino;
+ grub_minix_read_inode (data, grub_minix_to_cpu_ino (ino));
+
+ /* Follow the symlink. */
+ if ((GRUB_MINIX_INODE_MODE (data)
+ & GRUB_MINIX_IFLNK) == GRUB_MINIX_IFLNK)
+ {
+ grub_minix_lookup_symlink (data, dirino);
+ if (grub_errno)
+ return grub_errno;
+ }
+
+ break;
+ }
+ }
+ }
+}
+
+
+/* Mount the filesystem on the disk DISK. */
+static struct grub_minix_data *
+grub_minix_mount (grub_disk_t disk)
+{
+ struct grub_minix_data *data = NULL;
+ grub_uint16_t ext2_marker;
+
+ grub_disk_read (disk, 2, 56, sizeof (ext2_marker), &ext2_marker);
+ if (grub_errno != GRUB_ERR_NONE)
+ goto fail;
+
+ /*
+ * The ext2 filesystems can sometimes be mistakenly identified as MINIX, e.g.
+ * due to the number of free ext2 inodes being written to the same location
+ * where the MINIX superblock magic is found. Avoid such situations by
+ * skipping any filesystems that have the ext2 superblock magic.
+ */
+ if (ext2_marker == grub_cpu_to_le16_compile_time (EXT2_MAGIC))
+ goto fail;
+
+ data = grub_malloc (sizeof (struct grub_minix_data));
+ if (!data)
+ return 0;
+
+ /* Read the superblock. */
+ grub_disk_read (disk, GRUB_MINIX_SBLOCK, 0,
+ sizeof (struct grub_minix_sblock),&data->sblock);
+ if (grub_errno)
+ goto fail;
+
+ if (data->sblock.magic == grub_cpu_to_minix16_compile_time (GRUB_MINIX_MAGIC))
+ {
+#if !defined(MODE_MINIX3)
+ data->filename_size = 14;
+#else
+ data->filename_size = 60;
+#endif
+ }
+#if !defined(MODE_MINIX3)
+ else if (data->sblock.magic
+ == grub_cpu_to_minix16_compile_time (GRUB_MINIX_MAGIC_30))
+ data->filename_size = 30;
+#endif
+ else
+ goto fail;
+
+ /* 20 means 1G zones. We could support up to 31 but already 1G isn't
+ supported by anything else. */
+ if (grub_minix_to_cpu16 (data->sblock.log2_zone_size) >= 20)
+ goto fail;
+
+ data->disk = disk;
+ data->linknest = 0;
+#ifdef MODE_MINIX3
+ /* These tests are endian-independent. No need to byteswap. */
+ if (data->sblock.block_size == 0xffff)
+ data->block_size = 2;
+ else
+ {
+ if ((data->sblock.block_size == grub_cpu_to_minix16_compile_time (0x200))
+ || (data->sblock.block_size == 0)
+ || (data->sblock.block_size & grub_cpu_to_minix16_compile_time (0x1ff)))
+ goto fail;
+ data->block_size = grub_minix_to_cpu16 (data->sblock.block_size)
+ >> GRUB_DISK_SECTOR_BITS;
+ }
+#else
+ 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:
+ grub_free (data);
+#if defined(MODE_MINIX3)
+ grub_error (GRUB_ERR_BAD_FS, "not a minix3 filesystem");
+#elif defined(MODE_MINIX2)
+ grub_error (GRUB_ERR_BAD_FS, "not a minix2 filesystem");
+#else
+ grub_error (GRUB_ERR_BAD_FS, "not a minix filesystem");
+#endif
+ return 0;
+}
+
+static grub_err_t
+grub_minix_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_minix_data *data = 0;
+ unsigned int pos = 0;
+
+ data = grub_minix_mount (device->disk);
+ if (!data)
+ return grub_errno;
+
+ grub_minix_read_inode (data, GRUB_MINIX_ROOT_INODE);
+ if (grub_errno)
+ goto fail;
+
+ grub_minix_find_file (data, path);
+ if (grub_errno)
+ goto fail;
+
+ if ((GRUB_MINIX_INODE_MODE (data) & GRUB_MINIX_IFDIR) != GRUB_MINIX_IFDIR)
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+ goto fail;
+ }
+
+ while (pos < GRUB_MINIX_INODE_SIZE (data))
+ {
+ grub_minix_ino_t ino;
+ char filename[MAX_MINIX_FILENAME_SIZE + 1];
+ grub_minix_ino_t dirino = data->ino;
+ struct grub_dirhook_info info;
+ grub_memset (&info, 0, sizeof (info));
+
+
+ if (grub_minix_read_file (data, 0, 0, pos, sizeof (ino),
+ (char *) &ino) < 0)
+ return grub_errno;
+
+ if (grub_minix_read_file (data, 0, 0, pos + sizeof (ino),
+ data->filename_size,
+ (char *) filename) < 0)
+ return grub_errno;
+ filename[data->filename_size] = '\0';
+ if (!ino)
+ {
+ pos += sizeof (ino) + data->filename_size;
+ continue;
+ }
+
+ grub_minix_read_inode (data, grub_minix_to_cpu_ino (ino));
+ info.dir = ((GRUB_MINIX_INODE_MODE (data)
+ & GRUB_MINIX_IFDIR) == GRUB_MINIX_IFDIR);
+ info.mtimeset = 1;
+ info.mtime = grub_minix_to_cpu32 (data->inode.mtime);
+
+ if (hook (filename, &info, hook_data) ? 1 : 0)
+ break;
+
+ /* Load the old inode back in. */
+ grub_minix_read_inode (data, dirino);
+
+ pos += sizeof (ino) + data->filename_size;
+ }
+
+ fail:
+ grub_free (data);
+ return grub_errno;
+}
+
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_minix_open (struct grub_file *file, const char *name)
+{
+ struct grub_minix_data *data;
+ data = grub_minix_mount (file->device->disk);
+ if (!data)
+ return grub_errno;
+
+ /* Open the inode op the root directory. */
+ grub_minix_read_inode (data, GRUB_MINIX_ROOT_INODE);
+ if (grub_errno)
+ {
+ grub_free (data);
+ return grub_errno;
+ }
+
+ if (!name || name[0] != '/')
+ {
+ grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), name);
+ return grub_errno;
+ }
+
+ /* Traverse the directory tree to the node that should be
+ opened. */
+ grub_minix_find_file (data, name);
+ if (grub_errno)
+ {
+ grub_free (data);
+ return grub_errno;
+ }
+
+ file->data = data;
+ file->size = GRUB_MINIX_INODE_SIZE (data);
+
+ return GRUB_ERR_NONE;
+}
+
+
+static grub_ssize_t
+grub_minix_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_minix_data *data =
+ (struct grub_minix_data *) file->data;
+
+ return grub_minix_read_file (data, file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+
+static grub_err_t
+grub_minix_close (grub_file_t file)
+{
+ grub_free (file->data);
+
+ return GRUB_ERR_NONE;
+}
+
+
+
+static struct grub_fs grub_minix_fs =
+ {
+#ifdef MODE_BIGENDIAN
+#if defined(MODE_MINIX3)
+ .name = "minix3_be",
+#elif defined(MODE_MINIX2)
+ .name = "minix2_be",
+#else
+ .name = "minix_be",
+#endif
+#else
+#if defined(MODE_MINIX3)
+ .name = "minix3",
+#elif defined(MODE_MINIX2)
+ .name = "minix2",
+#else
+ .name = "minix",
+#endif
+#endif
+ .fs_dir = grub_minix_dir,
+ .fs_open = grub_minix_open,
+ .fs_read = grub_minix_read,
+ .fs_close = grub_minix_close,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+#ifdef MODE_BIGENDIAN
+#if defined(MODE_MINIX3)
+GRUB_MOD_INIT(minix3_be)
+#elif defined(MODE_MINIX2)
+GRUB_MOD_INIT(minix2_be)
+#else
+GRUB_MOD_INIT(minix_be)
+#endif
+#else
+#if defined(MODE_MINIX3)
+GRUB_MOD_INIT(minix3)
+#elif defined(MODE_MINIX2)
+GRUB_MOD_INIT(minix2)
+#else
+GRUB_MOD_INIT(minix)
+#endif
+#endif
+{
+ grub_fs_register (&grub_minix_fs);
+ my_mod = mod;
+}
+
+#ifdef MODE_BIGENDIAN
+#if defined(MODE_MINIX3)
+GRUB_MOD_FINI(minix3_be)
+#elif defined(MODE_MINIX2)
+GRUB_MOD_FINI(minix2_be)
+#else
+GRUB_MOD_FINI(minix_be)
+#endif
+#else
+#if defined(MODE_MINIX3)
+GRUB_MOD_FINI(minix3)
+#elif defined(MODE_MINIX2)
+GRUB_MOD_FINI(minix2)
+#else
+GRUB_MOD_FINI(minix)
+#endif
+#endif
+{
+ grub_fs_unregister (&grub_minix_fs);
+}
diff --git a/grub-core/fs/minix2.c b/grub-core/fs/minix2.c
new file mode 100644
index 0000000..0fcd4b1
--- /dev/null
+++ b/grub-core/fs/minix2.c
@@ -0,0 +1,2 @@
+#define MODE_MINIX2 1
+#include "minix.c"
diff --git a/grub-core/fs/minix2_be.c b/grub-core/fs/minix2_be.c
new file mode 100644
index 0000000..cb786df
--- /dev/null
+++ b/grub-core/fs/minix2_be.c
@@ -0,0 +1,3 @@
+#define MODE_MINIX2 1
+#define MODE_BIGENDIAN 1
+#include "minix.c"
diff --git a/grub-core/fs/minix3.c b/grub-core/fs/minix3.c
new file mode 100644
index 0000000..58a21d2
--- /dev/null
+++ b/grub-core/fs/minix3.c
@@ -0,0 +1,2 @@
+#define MODE_MINIX3 1
+#include "minix.c"
diff --git a/grub-core/fs/minix3_be.c b/grub-core/fs/minix3_be.c
new file mode 100644
index 0000000..d0305e4
--- /dev/null
+++ b/grub-core/fs/minix3_be.c
@@ -0,0 +1,3 @@
+#define MODE_MINIX3 1
+#define MODE_BIGENDIAN 1
+#include "minix.c"
diff --git a/grub-core/fs/minix_be.c b/grub-core/fs/minix_be.c
new file mode 100644
index 0000000..fade347
--- /dev/null
+++ b/grub-core/fs/minix_be.c
@@ -0,0 +1,2 @@
+#define MODE_BIGENDIAN 1
+#include "minix.c"
diff --git a/grub-core/fs/newc.c b/grub-core/fs/newc.c
new file mode 100644
index 0000000..4fb8b2e
--- /dev/null
+++ b/grub-core/fs/newc.c
@@ -0,0 +1,73 @@
+/* cpio.c - cpio and tar filesystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009,2013 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+
+#define ALIGN_CPIO(x) (ALIGN_UP ((x), 4))
+#define MAGIC "070701"
+#define MAGIC2 "070702"
+struct head
+{
+ char magic[6];
+ char ino[8];
+ char mode[8];
+ char uid[8];
+ char gid[8];
+ char nlink[8];
+ char mtime[8];
+ char filesize[8];
+ char devmajor[8];
+ char devminor[8];
+ char rdevmajor[8];
+ char rdevminor[8];
+ char namesize[8];
+ char check[8];
+} GRUB_PACKED;
+
+static inline unsigned long long
+read_number (const char *str, grub_size_t size)
+{
+ unsigned long long ret = 0;
+ while (size-- && grub_isxdigit (*str))
+ {
+ char dig = *str++;
+ if (dig >= '0' && dig <= '9')
+ dig &= 0xf;
+ else if (dig >= 'a' && dig <= 'f')
+ dig -= 'a' - 10;
+ else
+ dig -= 'A' - 10;
+ ret = (ret << 4) | (dig);
+ }
+ return ret;
+}
+
+#define FSNAME "newc"
+
+#include "cpio_common.c"
+
+GRUB_MOD_INIT (newc)
+{
+ grub_fs_register (&grub_cpio_fs);
+}
+
+GRUB_MOD_FINI (newc)
+{
+ grub_fs_unregister (&grub_cpio_fs);
+}
diff --git a/grub-core/fs/nilfs2.c b/grub-core/fs/nilfs2.c
new file mode 100644
index 0000000..3c248a9
--- /dev/null
+++ b/grub-core/fs/nilfs2.c
@@ -0,0 +1,1241 @@
+/*
+ * nilfs2.c - New Implementation of Log filesystem
+ *
+ * Written by Jiro SEKIBA <jir@unicus.jp>
+ *
+ * Copyright (C) 2003,2004,2005,2007,2008,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/* Filetype information as used in inodes. */
+#define FILETYPE_INO_MASK 0170000
+#define FILETYPE_INO_REG 0100000
+#define FILETYPE_INO_DIRECTORY 0040000
+#define FILETYPE_INO_SYMLINK 0120000
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define NILFS_INODE_BMAP_SIZE 7
+
+#define NILFS_SUPORT_REV 2
+
+/* Magic value used to identify an nilfs2 filesystem. */
+#define NILFS2_SUPER_MAGIC 0x3434
+/* nilfs btree node flag. */
+#define NILFS_BTREE_NODE_ROOT 0x01
+
+/* nilfs btree node level. */
+#define NILFS_BTREE_LEVEL_DATA 0
+#define NILFS_BTREE_LEVEL_NODE_MIN (NILFS_BTREE_LEVEL_DATA + 1)
+
+/* nilfs 1st super block posission from beginning of the partition
+ in 512 block size */
+#define NILFS_1ST_SUPER_BLOCK 2
+/* nilfs 2nd super block posission from beginning of the partition
+ in 512 block size */
+#define NILFS_2ND_SUPER_BLOCK(devsize) (((devsize >> 3) - 1) << 3)
+
+#define LOG_INODE_SIZE 7
+struct grub_nilfs2_inode
+{
+ grub_uint64_t i_blocks;
+ grub_uint64_t i_size;
+ grub_uint64_t i_ctime;
+ grub_uint64_t i_mtime;
+ grub_uint32_t i_ctime_nsec;
+ grub_uint32_t i_mtime_nsec;
+ grub_uint32_t i_uid;
+ grub_uint32_t i_gid;
+ grub_uint16_t i_mode;
+ grub_uint16_t i_links_count;
+ grub_uint32_t i_flags;
+ grub_uint64_t i_bmap[NILFS_INODE_BMAP_SIZE];
+#define i_device_code i_bmap[0]
+ grub_uint64_t i_xattr;
+ grub_uint32_t i_generation;
+ grub_uint32_t i_pad;
+};
+
+struct grub_nilfs2_super_root
+{
+ grub_uint32_t sr_sum;
+ grub_uint16_t sr_bytes;
+ grub_uint16_t sr_flags;
+ grub_uint64_t sr_nongc_ctime;
+ struct grub_nilfs2_inode sr_dat;
+ struct grub_nilfs2_inode sr_cpfile;
+ struct grub_nilfs2_inode sr_sufile;
+};
+
+struct grub_nilfs2_super_block
+{
+ grub_uint32_t s_rev_level;
+ grub_uint16_t s_minor_rev_level;
+ grub_uint16_t s_magic;
+ grub_uint16_t s_bytes;
+ grub_uint16_t s_flags;
+ grub_uint32_t s_crc_seed;
+ grub_uint32_t s_sum;
+ grub_uint32_t s_log_block_size;
+ grub_uint64_t s_nsegments;
+ grub_uint64_t s_dev_size;
+ grub_uint64_t s_first_data_block;
+ grub_uint32_t s_blocks_per_segment;
+ grub_uint32_t s_r_segments_percentage;
+ grub_uint64_t s_last_cno;
+ grub_uint64_t s_last_pseg;
+ grub_uint64_t s_last_seq;
+ grub_uint64_t s_free_blocks_count;
+ grub_uint64_t s_ctime;
+ grub_uint64_t s_mtime;
+ grub_uint64_t s_wtime;
+ grub_uint16_t s_mnt_count;
+ grub_uint16_t s_max_mnt_count;
+ grub_uint16_t s_state;
+ grub_uint16_t s_errors;
+ grub_uint64_t s_lastcheck;
+ grub_uint32_t s_checkinterval;
+ grub_uint32_t s_creator_os;
+ grub_uint16_t s_def_resuid;
+ grub_uint16_t s_def_resgid;
+ grub_uint32_t s_first_ino;
+ grub_uint16_t s_inode_size;
+ grub_uint16_t s_dat_entry_size;
+ grub_uint16_t s_checkpoint_size;
+ grub_uint16_t s_segment_usage_size;
+ grub_uint8_t s_uuid[16];
+ char s_volume_name[80];
+ grub_uint32_t s_c_interval;
+ grub_uint32_t s_c_block_max;
+ grub_uint32_t s_reserved[192];
+};
+
+struct grub_nilfs2_dir_entry
+{
+ grub_uint64_t inode;
+ grub_uint16_t rec_len;
+#define MAX_NAMELEN 255
+ grub_uint8_t name_len;
+ grub_uint8_t file_type;
+#if 0 /* followed by file name. */
+ char name[NILFS_NAME_LEN];
+ char pad;
+#endif
+} GRUB_PACKED;
+
+enum
+{
+ NILFS_FT_UNKNOWN,
+ NILFS_FT_REG_FILE,
+ NILFS_FT_DIR,
+ NILFS_FT_CHRDEV,
+ NILFS_FT_BLKDEV,
+ NILFS_FT_FIFO,
+ NILFS_FT_SOCK,
+ NILFS_FT_SYMLINK,
+ NILFS_FT_MAX
+};
+
+struct grub_nilfs2_finfo
+{
+ grub_uint64_t fi_ino;
+ grub_uint64_t fi_cno;
+ grub_uint32_t fi_nblocks;
+ grub_uint32_t fi_ndatablk;
+};
+
+struct grub_nilfs2_binfo_v
+{
+ grub_uint64_t bi_vblocknr;
+ grub_uint64_t bi_blkoff;
+};
+
+struct grub_nilfs2_binfo_dat
+{
+ grub_uint64_t bi_blkoff;
+ grub_uint8_t bi_level;
+ grub_uint8_t bi_pad[7];
+};
+
+union grub_nilfs2_binfo
+{
+ struct grub_nilfs2_binfo_v bi_v;
+ struct grub_nilfs2_binfo_dat bi_dat;
+};
+
+struct grub_nilfs2_segment_summary
+{
+ grub_uint32_t ss_datasum;
+ grub_uint32_t ss_sumsum;
+ grub_uint32_t ss_magic;
+ grub_uint16_t ss_bytes;
+ grub_uint16_t ss_flags;
+ grub_uint64_t ss_seq;
+ grub_uint64_t ss_create;
+ grub_uint64_t ss_next;
+ grub_uint32_t ss_nblocks;
+ grub_uint32_t ss_nfinfo;
+ grub_uint32_t ss_sumbytes;
+ grub_uint32_t ss_pad;
+};
+
+struct grub_nilfs2_btree_node
+{
+ grub_uint8_t bn_flags;
+ grub_uint8_t bn_level;
+ grub_uint16_t bn_nchildren;
+ grub_uint32_t bn_pad;
+ grub_uint64_t keys[0];
+};
+
+struct grub_nilfs2_palloc_group_desc
+{
+ grub_uint32_t pg_nfrees;
+};
+
+#define LOG_SIZE_GROUP_DESC 2
+
+#define LOG_NILFS_DAT_ENTRY_SIZE 5
+struct grub_nilfs2_dat_entry
+{
+ grub_uint64_t de_blocknr;
+ grub_uint64_t de_start;
+ grub_uint64_t de_end;
+ grub_uint64_t de_rsv;
+};
+
+struct grub_nilfs2_snapshot_list
+{
+ grub_uint64_t ssl_next;
+ grub_uint64_t ssl_prev;
+};
+
+struct grub_nilfs2_cpfile_header
+{
+ grub_uint64_t ch_ncheckpoints;
+ grub_uint64_t ch_nsnapshots;
+ struct grub_nilfs2_snapshot_list ch_snapshot_list;
+};
+
+struct grub_nilfs2_checkpoint
+{
+ grub_uint32_t cp_flags;
+ grub_uint32_t cp_checkpoints_count;
+ struct grub_nilfs2_snapshot_list cp_snapshot_list;
+ grub_uint64_t cp_cno;
+ grub_uint64_t cp_create;
+ grub_uint64_t cp_nblk_inc;
+ grub_uint64_t cp_inodes_count;
+ grub_uint64_t cp_blocks_count;
+ struct grub_nilfs2_inode cp_ifile_inode;
+};
+
+
+#define NILFS_BMAP_LARGE 0x1
+#define NILFS_BMAP_SIZE (NILFS_INODE_BMAP_SIZE * sizeof(grub_uint64_t))
+
+/* nilfs extra padding for nonroot btree node. */
+#define NILFS_BTREE_NODE_EXTRA_PAD_SIZE (sizeof(grub_uint64_t))
+#define NILFS_BTREE_ROOT_SIZE NILFS_BMAP_SIZE
+#define NILFS_BTREE_ROOT_NCHILDREN_MAX \
+ ((NILFS_BTREE_ROOT_SIZE - sizeof(struct nilfs_btree_node)) / \
+ (sizeof(grub_uint64_t) + sizeof(grub_uint64_t)) )
+
+
+struct grub_fshelp_node
+{
+ struct grub_nilfs2_data *data;
+ struct grub_nilfs2_inode inode;
+ grub_uint64_t ino;
+ int inode_read;
+};
+
+struct grub_nilfs2_data
+{
+ struct grub_nilfs2_super_block sblock;
+ struct grub_nilfs2_super_root sroot;
+ struct grub_nilfs2_inode ifile;
+ grub_disk_t disk;
+ struct grub_nilfs2_inode *inode;
+ struct grub_fshelp_node diropen;
+};
+
+/* Log2 size of nilfs2 block in 512 blocks. */
+#define LOG2_NILFS2_BLOCK_SIZE(data) \
+ (grub_le_to_cpu32 (data->sblock.s_log_block_size) + 1)
+
+/* Log2 size of nilfs2 block in bytes. */
+#define LOG2_BLOCK_SIZE(data) \
+ (grub_le_to_cpu32 (data->sblock.s_log_block_size) + 10)
+
+/* The size of an nilfs2 block in bytes. */
+#define NILFS2_BLOCK_SIZE(data) (1 << LOG2_BLOCK_SIZE (data))
+
+static grub_uint64_t
+grub_nilfs2_dat_translate (struct grub_nilfs2_data *data, grub_uint64_t key);
+static grub_dl_t my_mod;
+
+
+
+static inline unsigned long
+grub_nilfs2_log_palloc_entries_per_group (struct grub_nilfs2_data *data)
+{
+ return LOG2_BLOCK_SIZE (data) + 3;
+}
+
+static inline grub_uint64_t
+grub_nilfs2_palloc_group (struct grub_nilfs2_data *data,
+ grub_uint64_t nr, grub_uint64_t * offset)
+{
+ *offset = nr & ((1 << grub_nilfs2_log_palloc_entries_per_group (data)) - 1);
+ return nr >> grub_nilfs2_log_palloc_entries_per_group (data);
+}
+
+static inline grub_uint32_t
+grub_nilfs2_palloc_log_groups_per_desc_block (struct grub_nilfs2_data *data)
+{
+ return LOG2_BLOCK_SIZE (data) - LOG_SIZE_GROUP_DESC;
+
+ COMPILE_TIME_ASSERT (sizeof (struct grub_nilfs2_palloc_group_desc)
+ == (1 << LOG_SIZE_GROUP_DESC));
+}
+
+static inline grub_uint32_t
+grub_nilfs2_log_entries_per_block_log (struct grub_nilfs2_data *data,
+ unsigned long log_entry_size)
+{
+ return LOG2_BLOCK_SIZE (data) - log_entry_size;
+}
+
+
+static inline grub_uint32_t
+grub_nilfs2_blocks_per_group_log (struct grub_nilfs2_data *data,
+ unsigned long log_entry_size)
+{
+ return (1 << (grub_nilfs2_log_palloc_entries_per_group (data)
+ - grub_nilfs2_log_entries_per_block_log (data,
+ log_entry_size))) + 1;
+}
+
+static inline grub_uint32_t
+grub_nilfs2_blocks_per_desc_block_log (struct grub_nilfs2_data *data,
+ unsigned long log_entry_size)
+{
+ return(grub_nilfs2_blocks_per_group_log (data, log_entry_size)
+ << grub_nilfs2_palloc_log_groups_per_desc_block (data)) + 1;
+}
+
+static inline grub_uint32_t
+grub_nilfs2_palloc_desc_block_offset_log (struct grub_nilfs2_data *data,
+ unsigned long group,
+ unsigned long log_entry_size)
+{
+ grub_uint32_t desc_block =
+ group >> grub_nilfs2_palloc_log_groups_per_desc_block (data);
+ return desc_block * grub_nilfs2_blocks_per_desc_block_log (data,
+ log_entry_size);
+}
+
+static inline grub_uint32_t
+grub_nilfs2_palloc_bitmap_block_offset (struct grub_nilfs2_data *data,
+ unsigned long group,
+ unsigned long log_entry_size)
+{
+ unsigned long desc_offset = group
+ & ((1 << grub_nilfs2_palloc_log_groups_per_desc_block (data)) - 1);
+
+ return grub_nilfs2_palloc_desc_block_offset_log (data, group, log_entry_size)
+ + 1
+ + desc_offset * grub_nilfs2_blocks_per_group_log (data, log_entry_size);
+}
+
+static inline grub_uint32_t
+grub_nilfs2_palloc_entry_offset_log (struct grub_nilfs2_data *data,
+ grub_uint64_t nr,
+ unsigned long log_entry_size)
+{
+ unsigned long group;
+ grub_uint64_t group_offset;
+
+ group = grub_nilfs2_palloc_group (data, nr, &group_offset);
+
+ return grub_nilfs2_palloc_bitmap_block_offset (data, group,
+ log_entry_size) + 1 +
+ (group_offset >> grub_nilfs2_log_entries_per_block_log (data,
+ log_entry_size));
+
+}
+
+static inline struct grub_nilfs2_btree_node *
+grub_nilfs2_btree_get_root (struct grub_nilfs2_inode *inode)
+{
+ return (struct grub_nilfs2_btree_node *) &inode->i_bmap[0];
+}
+
+static inline int
+grub_nilfs2_btree_get_level (struct grub_nilfs2_btree_node *node)
+{
+ return node->bn_level;
+}
+
+static inline grub_uint64_t *
+grub_nilfs2_btree_node_dkeys (struct grub_nilfs2_btree_node *node)
+{
+ return (node->keys +
+ ((node->bn_flags & NILFS_BTREE_NODE_ROOT) ?
+ 0 : (NILFS_BTREE_NODE_EXTRA_PAD_SIZE / sizeof (grub_uint64_t))));
+}
+
+static inline grub_uint64_t
+grub_nilfs2_btree_node_get_key (struct grub_nilfs2_btree_node *node,
+ int index)
+{
+ return grub_le_to_cpu64 (*(grub_nilfs2_btree_node_dkeys (node) + index));
+}
+
+static inline int
+grub_nilfs2_btree_node_nchildren_max (struct grub_nilfs2_data *data,
+ struct grub_nilfs2_btree_node *node)
+{
+ int node_children_max = ((NILFS2_BLOCK_SIZE (data) -
+ sizeof (struct grub_nilfs2_btree_node) -
+ NILFS_BTREE_NODE_EXTRA_PAD_SIZE) /
+ (sizeof (grub_uint64_t) + sizeof (grub_uint64_t)));
+
+ return (node->bn_flags & NILFS_BTREE_NODE_ROOT) ? 3 : node_children_max;
+}
+
+static inline int
+grub_nilfs2_btree_node_lookup (struct grub_nilfs2_data *data,
+ struct grub_nilfs2_btree_node *node,
+ grub_uint64_t key, int *indexp)
+{
+ grub_uint64_t nkey;
+ int index = 0, low, high, s;
+
+ low = 0;
+
+ high = grub_le_to_cpu16 (node->bn_nchildren) - 1;
+ if (high >= grub_nilfs2_btree_node_nchildren_max (data, node))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "too many children");
+ *indexp = index;
+ return 0;
+ }
+
+ s = 0;
+ while (low <= high)
+ {
+ index = (low + high) / 2;
+ nkey = grub_nilfs2_btree_node_get_key (node, index);
+ if (nkey == key)
+ {
+ *indexp = index;
+ return 1;
+ }
+ else if (nkey < key)
+ {
+ low = index + 1;
+ s = -1;
+ }
+ else
+ {
+ high = index - 1;
+ s = 1;
+ }
+ }
+
+ if (node->bn_level > NILFS_BTREE_LEVEL_NODE_MIN)
+ {
+ if (s > 0 && index > 0)
+ index--;
+ }
+ else if (s < 0)
+ index++;
+
+ *indexp = index;
+ return s == 0;
+}
+
+static inline grub_uint64_t *
+grub_nilfs2_btree_node_dptrs (struct grub_nilfs2_data *data,
+ struct grub_nilfs2_btree_node *node)
+{
+ return (grub_uint64_t *) (grub_nilfs2_btree_node_dkeys (node) +
+ grub_nilfs2_btree_node_nchildren_max (data,
+ node));
+}
+
+static inline grub_uint64_t
+grub_nilfs2_btree_node_get_ptr (struct grub_nilfs2_data *data,
+ struct grub_nilfs2_btree_node *node,
+ int index)
+{
+ return
+ grub_le_to_cpu64 (*(grub_nilfs2_btree_node_dptrs (data, node) + index));
+}
+
+static inline int
+grub_nilfs2_btree_get_nonroot_node (struct grub_nilfs2_data *data,
+ grub_uint64_t ptr, void *block)
+{
+ grub_disk_t disk = data->disk;
+ unsigned int nilfs2_block_count = (1 << LOG2_NILFS2_BLOCK_SIZE (data));
+
+ return grub_disk_read (disk, ptr * nilfs2_block_count, 0,
+ NILFS2_BLOCK_SIZE (data), block);
+}
+
+static grub_uint64_t
+grub_nilfs2_btree_lookup (struct grub_nilfs2_data *data,
+ struct grub_nilfs2_inode *inode,
+ grub_uint64_t key, int need_translate)
+{
+ struct grub_nilfs2_btree_node *node;
+ void *block;
+ grub_uint64_t ptr;
+ int level, found = 0, index;
+
+ block = grub_malloc (NILFS2_BLOCK_SIZE (data));
+ if (!block)
+ return -1;
+
+ node = grub_nilfs2_btree_get_root (inode);
+ level = grub_nilfs2_btree_get_level (node);
+
+ found = grub_nilfs2_btree_node_lookup (data, node, key, &index);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ goto fail;
+
+ ptr = grub_nilfs2_btree_node_get_ptr (data, node, index);
+ if (need_translate)
+ ptr = grub_nilfs2_dat_translate (data, ptr);
+
+ for (level--; level >= NILFS_BTREE_LEVEL_NODE_MIN; level--)
+ {
+ grub_nilfs2_btree_get_nonroot_node (data, ptr, block);
+ if (grub_errno)
+ {
+ goto fail;
+ }
+ node = (struct grub_nilfs2_btree_node *) block;
+
+ if (node->bn_level != level)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "btree level mismatch\n");
+ goto fail;
+ }
+
+ if (!found)
+ found = grub_nilfs2_btree_node_lookup (data, node, key, &index);
+ else
+ index = 0;
+
+ if (index < grub_nilfs2_btree_node_nchildren_max (data, node) &&
+ grub_errno == GRUB_ERR_NONE)
+ {
+ ptr = grub_nilfs2_btree_node_get_ptr (data, node, index);
+ if (need_translate)
+ ptr = grub_nilfs2_dat_translate (data, ptr);
+ }
+ else
+ {
+ grub_error (GRUB_ERR_BAD_FS, "btree corruption\n");
+ goto fail;
+ }
+ }
+
+ grub_free (block);
+
+ if (!found)
+ return -1;
+
+ return ptr;
+ fail:
+ grub_free (block);
+ return -1;
+}
+
+static inline grub_uint64_t
+grub_nilfs2_direct_lookup (struct grub_nilfs2_inode *inode, grub_uint64_t key)
+{
+ if (1 + key > 6)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "key is too large");
+ return 0xffffffffffffffff;
+ }
+ return grub_le_to_cpu64 (inode->i_bmap[1 + key]);
+}
+
+static inline grub_uint64_t
+grub_nilfs2_bmap_lookup (struct grub_nilfs2_data *data,
+ struct grub_nilfs2_inode *inode,
+ grub_uint64_t key, int need_translate)
+{
+ struct grub_nilfs2_btree_node *root = grub_nilfs2_btree_get_root (inode);
+ if (root->bn_flags & NILFS_BMAP_LARGE)
+ return grub_nilfs2_btree_lookup (data, inode, key, need_translate);
+ else
+ {
+ grub_uint64_t ptr;
+ ptr = grub_nilfs2_direct_lookup (inode, key);
+ if (ptr != ((grub_uint64_t) 0xffffffffffffffff) && need_translate)
+ ptr = grub_nilfs2_dat_translate (data, ptr);
+ return ptr;
+ }
+}
+
+static grub_uint64_t
+grub_nilfs2_dat_translate (struct grub_nilfs2_data *data, grub_uint64_t key)
+{
+ struct grub_nilfs2_dat_entry entry;
+ grub_disk_t disk = data->disk;
+ grub_uint64_t pptr;
+ grub_uint64_t blockno, offset;
+ unsigned int nilfs2_block_count = (1 << LOG2_NILFS2_BLOCK_SIZE (data));
+
+ blockno = grub_nilfs2_palloc_entry_offset_log (data, key,
+ LOG_NILFS_DAT_ENTRY_SIZE);
+
+ offset = ((key * sizeof (struct grub_nilfs2_dat_entry))
+ & ((1 << LOG2_BLOCK_SIZE (data)) - 1));
+
+ pptr = grub_nilfs2_bmap_lookup (data, &data->sroot.sr_dat, blockno, 0);
+ if (pptr == (grub_uint64_t) - 1)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "btree lookup failure");
+ return -1;
+ }
+
+ grub_disk_read (disk, pptr * nilfs2_block_count, offset,
+ sizeof (struct grub_nilfs2_dat_entry), &entry);
+
+ return grub_le_to_cpu64 (entry.de_blocknr);
+}
+
+
+static grub_disk_addr_t
+grub_nilfs2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
+{
+ struct grub_nilfs2_data *data = node->data;
+ struct grub_nilfs2_inode *inode = &node->inode;
+ grub_uint64_t pptr = -1;
+
+ pptr = grub_nilfs2_bmap_lookup (data, inode, fileblock, 1);
+ if (pptr == (grub_uint64_t) - 1)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "btree lookup failure");
+ return -1;
+ }
+
+ return pptr;
+}
+
+/* Read LEN bytes from the file described by DATA starting with byte
+ POS. Return the amount of read bytes in READ. */
+static grub_ssize_t
+grub_nilfs2_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)
+{
+ return grub_fshelp_read_file (node->data->disk, node,
+ read_hook, read_hook_data,
+ pos, len, buf, grub_nilfs2_read_block,
+ grub_le_to_cpu64 (node->inode.i_size),
+ LOG2_NILFS2_BLOCK_SIZE (node->data), 0);
+
+}
+
+static grub_err_t
+grub_nilfs2_read_checkpoint (struct grub_nilfs2_data *data,
+ grub_uint64_t cpno,
+ struct grub_nilfs2_checkpoint *cpp)
+{
+ grub_uint64_t blockno;
+ grub_uint64_t offset;
+ grub_uint64_t pptr;
+ grub_disk_t disk = data->disk;
+ unsigned int nilfs2_block_count = (1 << LOG2_NILFS2_BLOCK_SIZE (data));
+
+ /* Assume sizeof(struct grub_nilfs2_cpfile_header) <
+ sizeof(struct grub_nilfs2_checkpoint).
+ */
+ blockno = grub_divmod64 (cpno, NILFS2_BLOCK_SIZE (data) /
+ sizeof (struct grub_nilfs2_checkpoint), &offset);
+
+ pptr = grub_nilfs2_bmap_lookup (data, &data->sroot.sr_cpfile, blockno, 1);
+ if (pptr == (grub_uint64_t) - 1)
+ {
+ return grub_error (GRUB_ERR_BAD_FS, "btree lookup failure");
+ }
+
+ return grub_disk_read (disk, pptr * nilfs2_block_count,
+ offset * sizeof (struct grub_nilfs2_checkpoint),
+ sizeof (struct grub_nilfs2_checkpoint), cpp);
+}
+
+static inline grub_err_t
+grub_nilfs2_read_last_checkpoint (struct grub_nilfs2_data *data,
+ struct grub_nilfs2_checkpoint *cpp)
+{
+ return grub_nilfs2_read_checkpoint (data,
+ grub_le_to_cpu64 (data->
+ sblock.s_last_cno),
+ cpp);
+}
+
+/* Read the inode INO for the file described by DATA into INODE. */
+static grub_err_t
+grub_nilfs2_read_inode (struct grub_nilfs2_data *data,
+ grub_uint64_t ino, struct grub_nilfs2_inode *inodep)
+{
+ grub_uint64_t blockno;
+ grub_uint64_t offset;
+ grub_uint64_t pptr;
+ grub_disk_t disk = data->disk;
+ unsigned int nilfs2_block_count = (1 << LOG2_NILFS2_BLOCK_SIZE (data));
+
+ blockno = grub_nilfs2_palloc_entry_offset_log (data, ino,
+ LOG_INODE_SIZE);
+
+ offset = ((sizeof (struct grub_nilfs2_inode) * ino)
+ & ((1 << LOG2_BLOCK_SIZE (data)) - 1));
+ pptr = grub_nilfs2_bmap_lookup (data, &data->ifile, blockno, 1);
+ if (pptr == (grub_uint64_t) - 1)
+ {
+ return grub_error (GRUB_ERR_BAD_FS, "btree lookup failure");
+ }
+
+ return grub_disk_read (disk, pptr * nilfs2_block_count, offset,
+ sizeof (struct grub_nilfs2_inode), inodep);
+}
+
+static int
+grub_nilfs2_valid_sb (struct grub_nilfs2_super_block *sbp)
+{
+ if (grub_le_to_cpu16 (sbp->s_magic) != NILFS2_SUPER_MAGIC)
+ return 0;
+
+ 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;
+}
+
+static grub_err_t
+grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
+{
+ grub_disk_t disk = data->disk;
+ struct grub_nilfs2_super_block sb2;
+ grub_uint64_t partition_size;
+ int valid[2];
+ int swp = 0;
+ grub_err_t err;
+
+ /* Read first super block. */
+ err = grub_disk_read (disk, NILFS_1ST_SUPER_BLOCK, 0,
+ sizeof (struct grub_nilfs2_super_block), &data->sblock);
+ if (err)
+ return err;
+ /* Make sure if 1st super block is valid. */
+ valid[0] = grub_nilfs2_valid_sb (&data->sblock);
+
+ if (valid[0])
+ partition_size = (grub_le_to_cpu64 (data->sblock.s_dev_size)
+ >> GRUB_DISK_SECTOR_BITS);
+ else
+ partition_size = grub_disk_native_sectors (disk);
+ if (partition_size != GRUB_DISK_SIZE_UNKNOWN)
+ {
+ /* Read second super block. */
+ err = grub_disk_read (disk, NILFS_2ND_SUPER_BLOCK (partition_size), 0,
+ sizeof (struct grub_nilfs2_super_block), &sb2);
+ if (err)
+ {
+ valid[1] = 0;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ else
+ /* Make sure if 2nd super block is valid. */
+ valid[1] = grub_nilfs2_valid_sb (&sb2);
+ }
+ else
+ /* 2nd super block may not exist, so it's invalid. */
+ valid[1] = 0;
+
+ if (!valid[0] && !valid[1])
+ return grub_error (GRUB_ERR_BAD_FS, "not a nilfs2 filesystem");
+
+ swp = valid[1] && (!valid[0] ||
+ grub_le_to_cpu64 (data->sblock.s_last_cno) <
+ grub_le_to_cpu64 (sb2.s_last_cno));
+
+ /* swap if first super block is invalid or older than second one. */
+ if (swp)
+ grub_memcpy (&data->sblock, &sb2,
+ sizeof (struct grub_nilfs2_super_block));
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_nilfs2_data *
+grub_nilfs2_mount (grub_disk_t disk)
+{
+ struct grub_nilfs2_data *data;
+ struct grub_nilfs2_segment_summary ss;
+ struct grub_nilfs2_checkpoint last_checkpoint;
+ grub_uint64_t last_pseg;
+ grub_uint32_t nblocks;
+ unsigned int nilfs2_block_count;
+
+ data = grub_malloc (sizeof (struct grub_nilfs2_data));
+ if (!data)
+ return 0;
+
+ data->disk = disk;
+
+ /* Read the superblock. */
+ grub_nilfs2_load_sb (data);
+ if (grub_errno)
+ goto fail;
+
+ nilfs2_block_count = (1 << LOG2_NILFS2_BLOCK_SIZE (data));
+
+ /* Read the last segment summary. */
+ last_pseg = grub_le_to_cpu64 (data->sblock.s_last_pseg);
+ grub_disk_read (disk, last_pseg * nilfs2_block_count, 0,
+ sizeof (struct grub_nilfs2_segment_summary), &ss);
+
+ if (grub_errno)
+ goto fail;
+
+ /* Read the super root block. */
+ nblocks = grub_le_to_cpu32 (ss.ss_nblocks);
+ grub_disk_read (disk, (last_pseg + (nblocks - 1)) * nilfs2_block_count, 0,
+ sizeof (struct grub_nilfs2_super_root), &data->sroot);
+
+ if (grub_errno)
+ goto fail;
+
+ grub_nilfs2_read_last_checkpoint (data, &last_checkpoint);
+
+ if (grub_errno)
+ goto fail;
+
+ grub_memcpy (&data->ifile, &last_checkpoint.cp_ifile_inode,
+ sizeof (struct grub_nilfs2_inode));
+
+ data->diropen.data = data;
+ data->diropen.ino = 2;
+ data->diropen.inode_read = 1;
+ data->inode = &data->diropen.inode;
+
+ grub_nilfs2_read_inode (data, 2, data->inode);
+
+ return data;
+
+fail:
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not a nilfs2 filesystem");
+
+ grub_free (data);
+ return 0;
+}
+
+static char *
+grub_nilfs2_read_symlink (grub_fshelp_node_t node)
+{
+ char *symlink;
+ struct grub_fshelp_node *diro = node;
+
+ if (!diro->inode_read)
+ {
+ grub_nilfs2_read_inode (diro->data, diro->ino, &diro->inode);
+ if (grub_errno)
+ return 0;
+ }
+
+ symlink = grub_malloc (grub_le_to_cpu64 (diro->inode.i_size) + 1);
+ if (!symlink)
+ return 0;
+
+ grub_nilfs2_read_file (diro, 0, 0, 0,
+ grub_le_to_cpu64 (diro->inode.i_size), symlink);
+ if (grub_errno)
+ {
+ grub_free (symlink);
+ return 0;
+ }
+
+ symlink[grub_le_to_cpu64 (diro->inode.i_size)] = '\0';
+ return symlink;
+}
+
+static int
+grub_nilfs2_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ grub_off_t fpos = 0;
+ struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
+
+ if (!diro->inode_read)
+ {
+ grub_nilfs2_read_inode (diro->data, diro->ino, &diro->inode);
+ if (grub_errno)
+ return 0;
+ }
+
+ /* Iterate files. */
+ while (fpos < grub_le_to_cpu64 (diro->inode.i_size))
+ {
+ struct grub_nilfs2_dir_entry dirent;
+
+ grub_nilfs2_read_file (diro, 0, 0, fpos,
+ sizeof (struct grub_nilfs2_dir_entry),
+ (char *) &dirent);
+ if (grub_errno)
+ return 0;
+
+ if (dirent.rec_len == 0)
+ return 0;
+
+ if (dirent.name_len != 0)
+ {
+ char filename[MAX_NAMELEN + 1];
+ struct grub_fshelp_node *fdiro;
+ enum grub_fshelp_filetype type = GRUB_FSHELP_UNKNOWN;
+
+ grub_nilfs2_read_file (diro, 0, 0,
+ fpos + sizeof (struct grub_nilfs2_dir_entry),
+ dirent.name_len, filename);
+ if (grub_errno)
+ return 0;
+
+ fdiro = grub_malloc (sizeof (struct grub_fshelp_node));
+ if (!fdiro)
+ return 0;
+
+ fdiro->data = diro->data;
+ fdiro->ino = grub_le_to_cpu64 (dirent.inode);
+
+ filename[dirent.name_len] = '\0';
+
+ if (dirent.file_type != NILFS_FT_UNKNOWN)
+ {
+ fdiro->inode_read = 0;
+
+ if (dirent.file_type == NILFS_FT_DIR)
+ type = GRUB_FSHELP_DIR;
+ else if (dirent.file_type == NILFS_FT_SYMLINK)
+ type = GRUB_FSHELP_SYMLINK;
+ else if (dirent.file_type == NILFS_FT_REG_FILE)
+ type = GRUB_FSHELP_REG;
+ }
+ else
+ {
+ /* The filetype can not be read from the dirent, read
+ the inode to get more information. */
+ grub_nilfs2_read_inode (diro->data,
+ grub_le_to_cpu64 (dirent.inode),
+ &fdiro->inode);
+ if (grub_errno)
+ {
+ grub_free (fdiro);
+ return 0;
+ }
+
+ fdiro->inode_read = 1;
+
+ if ((grub_le_to_cpu16 (fdiro->inode.i_mode)
+ & FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY)
+ type = GRUB_FSHELP_DIR;
+ else if ((grub_le_to_cpu16 (fdiro->inode.i_mode)
+ & FILETYPE_INO_MASK) == FILETYPE_INO_SYMLINK)
+ type = GRUB_FSHELP_SYMLINK;
+ else if ((grub_le_to_cpu16 (fdiro->inode.i_mode)
+ & FILETYPE_INO_MASK) == FILETYPE_INO_REG)
+ type = GRUB_FSHELP_REG;
+ }
+
+ if (hook (filename, type, fdiro, hook_data))
+ return 1;
+ }
+
+ fpos += grub_le_to_cpu16 (dirent.rec_len);
+ }
+
+ return 0;
+}
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_nilfs2_open (struct grub_file *file, const char *name)
+{
+ struct grub_nilfs2_data *data = NULL;
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_nilfs2_mount (file->device->disk);
+ if (!data)
+ goto fail;
+
+ grub_fshelp_find_file (name, &data->diropen, &fdiro,
+ grub_nilfs2_iterate_dir, grub_nilfs2_read_symlink,
+ GRUB_FSHELP_REG);
+ if (grub_errno)
+ goto fail;
+
+ if (!fdiro->inode_read)
+ {
+ grub_nilfs2_read_inode (data, fdiro->ino, &fdiro->inode);
+ if (grub_errno)
+ goto fail;
+ }
+
+ grub_memcpy (data->inode, &fdiro->inode, sizeof (struct grub_nilfs2_inode));
+ grub_free (fdiro);
+
+ file->size = grub_le_to_cpu64 (data->inode->i_size);
+ file->data = data;
+ file->offset = 0;
+
+ return 0;
+
+fail:
+ if (fdiro != &data->diropen)
+ grub_free (fdiro);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_nilfs2_close (grub_file_t file)
+{
+ grub_free (file->data);
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Read LEN bytes data from FILE into BUF. */
+static grub_ssize_t
+grub_nilfs2_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_nilfs2_data *data = (struct grub_nilfs2_data *) file->data;
+
+ return grub_nilfs2_read_file (&data->diropen,
+ file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+/* Context for grub_nilfs2_dir. */
+struct grub_nilfs2_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+ struct grub_nilfs2_data *data;
+};
+
+/* Helper for grub_nilfs2_dir. */
+static int
+grub_nilfs2_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_nilfs2_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ if (!node->inode_read)
+ {
+ grub_nilfs2_read_inode (ctx->data, node->ino, &node->inode);
+ if (!grub_errno)
+ node->inode_read = 1;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ if (node->inode_read)
+ {
+ info.mtimeset = 1;
+ info.mtime = grub_le_to_cpu64 (node->inode.i_mtime);
+ }
+
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_nilfs2_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_nilfs2_dir_ctx ctx = {
+ .hook = hook,
+ .hook_data = hook_data
+ };
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ ctx.data = grub_nilfs2_mount (device->disk);
+ if (!ctx.data)
+ goto fail;
+
+ grub_fshelp_find_file (path, &ctx.data->diropen, &fdiro,
+ grub_nilfs2_iterate_dir, grub_nilfs2_read_symlink,
+ GRUB_FSHELP_DIR);
+ if (grub_errno)
+ goto fail;
+
+ grub_nilfs2_iterate_dir (fdiro, grub_nilfs2_dir_iter, &ctx);
+
+fail:
+ if (fdiro != &ctx.data->diropen)
+ grub_free (fdiro);
+ grub_free (ctx.data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_nilfs2_label (grub_device_t device, char **label)
+{
+ struct grub_nilfs2_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_nilfs2_mount (disk);
+ if (data)
+ *label = grub_strndup (data->sblock.s_volume_name,
+ sizeof (data->sblock.s_volume_name));
+ else
+ *label = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_nilfs2_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_nilfs2_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_nilfs2_mount (disk);
+ if (data)
+ {
+ *uuid =
+ grub_xasprintf
+ ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ data->sblock.s_uuid[0], data->sblock.s_uuid[1],
+ data->sblock.s_uuid[2], data->sblock.s_uuid[3],
+ data->sblock.s_uuid[4], data->sblock.s_uuid[5],
+ data->sblock.s_uuid[6], data->sblock.s_uuid[7],
+ data->sblock.s_uuid[8], data->sblock.s_uuid[9],
+ data->sblock.s_uuid[10], data->sblock.s_uuid[11],
+ data->sblock.s_uuid[12], data->sblock.s_uuid[13],
+ data->sblock.s_uuid[14], data->sblock.s_uuid[15]);
+ }
+ else
+ *uuid = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+/* Get mtime. */
+static grub_err_t
+grub_nilfs2_mtime (grub_device_t device, grub_int64_t * tm)
+{
+ struct grub_nilfs2_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_nilfs2_mount (disk);
+ if (!data)
+ *tm = 0;
+ else
+ *tm = (grub_int32_t) grub_le_to_cpu64 (data->sblock.s_wtime);
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+
+static struct grub_fs grub_nilfs2_fs = {
+ .name = "nilfs2",
+ .fs_dir = grub_nilfs2_dir,
+ .fs_open = grub_nilfs2_open,
+ .fs_read = grub_nilfs2_read,
+ .fs_close = grub_nilfs2_close,
+ .fs_label = grub_nilfs2_label,
+ .fs_uuid = grub_nilfs2_uuid,
+ .fs_mtime = grub_nilfs2_mtime,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 0,
+#endif
+ .next = 0
+};
+
+GRUB_MOD_INIT (nilfs2)
+{
+ COMPILE_TIME_ASSERT ((1 << LOG_NILFS_DAT_ENTRY_SIZE)
+ == sizeof (struct
+ grub_nilfs2_dat_entry));
+ COMPILE_TIME_ASSERT (1 << LOG_INODE_SIZE
+ == sizeof (struct grub_nilfs2_inode));
+ grub_fs_register (&grub_nilfs2_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (nilfs2)
+{
+ grub_fs_unregister (&grub_nilfs2_fs);
+}
diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c
new file mode 100644
index 0000000..2f34f76
--- /dev/null
+++ b/grub-core/fs/ntfs.c
@@ -0,0 +1,1237 @@
+/* ntfs.c - NTFS filesystem */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009 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/>.
+ */
+
+#define grub_fshelp_node grub_ntfs_file
+
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/fshelp.h>
+#include <grub/ntfs.h>
+#include <grub/charset.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+
+#define grub_fshelp_node grub_ntfs_file
+
+static inline grub_uint16_t
+u16at (void *ptr, grub_size_t ofs)
+{
+ return grub_le_to_cpu16 (grub_get_unaligned16 ((char *) ptr + ofs));
+}
+
+static inline grub_uint32_t
+u32at (void *ptr, grub_size_t ofs)
+{
+ return grub_le_to_cpu32 (grub_get_unaligned32 ((char *) ptr + ofs));
+}
+
+static inline grub_uint64_t
+u64at (void *ptr, grub_size_t ofs)
+{
+ return grub_le_to_cpu64 (grub_get_unaligned64 ((char *) ptr + ofs));
+}
+
+grub_ntfscomp_func_t grub_ntfscomp_func;
+
+static grub_err_t
+fixup (grub_uint8_t *buf, grub_size_t len, const grub_uint8_t *magic)
+{
+ grub_uint16_t ss;
+ grub_uint8_t *pu;
+ grub_uint16_t us;
+
+ COMPILE_TIME_ASSERT ((1 << GRUB_NTFS_BLK_SHR) == GRUB_DISK_SECTOR_SIZE);
+
+ if (grub_memcmp (buf, magic, 4))
+ return grub_error (GRUB_ERR_BAD_FS, "%s label not found", magic);
+
+ ss = u16at (buf, 6) - 1;
+ if (ss != len)
+ return grub_error (GRUB_ERR_BAD_FS, "size not match");
+ pu = buf + u16at (buf, 4);
+ us = u16at (pu, 0);
+ buf -= 2;
+ while (ss > 0)
+ {
+ buf += GRUB_DISK_SECTOR_SIZE;
+ pu += 2;
+ if (u16at (buf, 0) != us)
+ return grub_error (GRUB_ERR_BAD_FS, "fixup signature not match");
+ buf[0] = pu[0];
+ buf[1] = pu[1];
+ ss--;
+ }
+
+ return 0;
+}
+
+static grub_err_t read_mft (struct grub_ntfs_data *data, grub_uint8_t *buf,
+ grub_uint64_t mftno);
+static grub_err_t read_attr (struct grub_ntfs_attr *at, grub_uint8_t *dest,
+ grub_disk_addr_t ofs, grub_size_t len,
+ int cached,
+ grub_disk_read_hook_t read_hook,
+ void *read_hook_data);
+
+static grub_err_t read_data (struct grub_ntfs_attr *at, grub_uint8_t *pa,
+ grub_uint8_t *dest,
+ grub_disk_addr_t ofs, grub_size_t len,
+ int cached,
+ grub_disk_read_hook_t read_hook,
+ void *read_hook_data);
+
+static void
+init_attr (struct grub_ntfs_attr *at, struct grub_ntfs_file *mft)
+{
+ at->mft = mft;
+ at->flags = (mft == &mft->data->mmft) ? GRUB_NTFS_AF_MMFT : 0;
+ at->attr_nxt = mft->buf + u16at (mft->buf, 0x14);
+ at->attr_end = at->emft_buf = at->edat_buf = at->sbuf = NULL;
+}
+
+static void
+free_attr (struct grub_ntfs_attr *at)
+{
+ grub_free (at->emft_buf);
+ grub_free (at->edat_buf);
+ grub_free (at->sbuf);
+}
+
+static grub_uint8_t *
+find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr)
+{
+ if (at->flags & GRUB_NTFS_AF_ALST)
+ {
+ retry:
+ while (at->attr_nxt < at->attr_end)
+ {
+ at->attr_cur = at->attr_nxt;
+ at->attr_nxt += u16at (at->attr_cur, 4);
+ if ((*at->attr_cur == attr) || (attr == 0))
+ {
+ grub_uint8_t *new_pos;
+
+ if (at->flags & GRUB_NTFS_AF_MMFT)
+ {
+ if ((grub_disk_read
+ (at->mft->data->disk, u32at (at->attr_cur, 0x10), 0,
+ 512, at->emft_buf))
+ ||
+ (grub_disk_read
+ (at->mft->data->disk, u32at (at->attr_cur, 0x14), 0,
+ 512, at->emft_buf + 512)))
+ return NULL;
+
+ if (fixup (at->emft_buf, at->mft->data->mft_size,
+ (const grub_uint8_t *) "FILE"))
+ return NULL;
+ }
+ else
+ {
+ if (read_mft (at->mft->data, at->emft_buf,
+ u32at (at->attr_cur, 0x10)))
+ return NULL;
+ }
+
+ new_pos = &at->emft_buf[u16at (at->emft_buf, 0x14)];
+ while (*new_pos != 0xFF)
+ {
+ if ((*new_pos == *at->attr_cur)
+ && (u16at (new_pos, 0xE) == u16at (at->attr_cur, 0x18)))
+ {
+ return new_pos;
+ }
+ new_pos += u16at (new_pos, 4);
+ }
+ grub_error (GRUB_ERR_BAD_FS,
+ "can\'t find 0x%X in attribute list",
+ (unsigned char) *at->attr_cur);
+ return NULL;
+ }
+ }
+ return NULL;
+ }
+ at->attr_cur = at->attr_nxt;
+ while (*at->attr_cur != 0xFF)
+ {
+ at->attr_nxt += u16at (at->attr_cur, 4);
+ if (*at->attr_cur == GRUB_NTFS_AT_ATTRIBUTE_LIST)
+ at->attr_end = at->attr_cur;
+ if ((*at->attr_cur == attr) || (attr == 0))
+ return at->attr_cur;
+ at->attr_cur = at->attr_nxt;
+ }
+ if (at->attr_end)
+ {
+ grub_uint8_t *pa;
+
+ at->emft_buf = grub_malloc (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR);
+ if (at->emft_buf == NULL)
+ return NULL;
+
+ pa = at->attr_end;
+ if (pa[8])
+ {
+ grub_uint32_t n;
+
+ n = ((u32at (pa, 0x30) + GRUB_DISK_SECTOR_SIZE - 1)
+ & (~(GRUB_DISK_SECTOR_SIZE - 1)));
+ at->attr_cur = at->attr_end;
+ at->edat_buf = grub_malloc (n);
+ if (!at->edat_buf)
+ return NULL;
+ if (read_data (at, pa, at->edat_buf, 0, n, 0, 0, 0))
+ {
+ grub_error (GRUB_ERR_BAD_FS,
+ "fail to read non-resident attribute list");
+ return NULL;
+ }
+ at->attr_nxt = at->edat_buf;
+ at->attr_end = at->edat_buf + u32at (pa, 0x30);
+ }
+ else
+ {
+ at->attr_nxt = at->attr_end + u16at (pa, 0x14);
+ at->attr_end = at->attr_end + u32at (pa, 4);
+ }
+ at->flags |= GRUB_NTFS_AF_ALST;
+ while (at->attr_nxt < at->attr_end)
+ {
+ if ((*at->attr_nxt == attr) || (attr == 0))
+ break;
+ at->attr_nxt += u16at (at->attr_nxt, 4);
+ }
+ if (at->attr_nxt >= at->attr_end)
+ return NULL;
+
+ if ((at->flags & GRUB_NTFS_AF_MMFT) && (attr == GRUB_NTFS_AT_DATA))
+ {
+ at->flags |= GRUB_NTFS_AF_GPOS;
+ at->attr_cur = at->attr_nxt;
+ pa = at->attr_cur;
+ grub_set_unaligned32 ((char *) pa + 0x10,
+ grub_cpu_to_le32 (at->mft->data->mft_start));
+ grub_set_unaligned32 ((char *) pa + 0x14,
+ grub_cpu_to_le32 (at->mft->data->mft_start
+ + 1));
+ pa = at->attr_nxt + u16at (pa, 4);
+ while (pa < at->attr_end)
+ {
+ if (*pa != attr)
+ break;
+ if (read_attr
+ (at, pa + 0x10,
+ u32at (pa, 0x10) * (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR),
+ at->mft->data->mft_size << GRUB_NTFS_BLK_SHR, 0, 0, 0))
+ return NULL;
+ pa += u16at (pa, 4);
+ }
+ at->attr_nxt = at->attr_cur;
+ at->flags &= ~GRUB_NTFS_AF_GPOS;
+ }
+ goto retry;
+ }
+ return NULL;
+}
+
+static grub_uint8_t *
+locate_attr (struct grub_ntfs_attr *at, struct grub_ntfs_file *mft,
+ grub_uint8_t attr)
+{
+ grub_uint8_t *pa;
+
+ init_attr (at, mft);
+ pa = find_attr (at, attr);
+ if (pa == NULL)
+ return NULL;
+ if ((at->flags & GRUB_NTFS_AF_ALST) == 0)
+ {
+ while (1)
+ {
+ pa = find_attr (at, attr);
+ if (pa == NULL)
+ break;
+ if (at->flags & GRUB_NTFS_AF_ALST)
+ return pa;
+ }
+ grub_errno = GRUB_ERR_NONE;
+ free_attr (at);
+ init_attr (at, mft);
+ pa = find_attr (at, attr);
+ }
+ return pa;
+}
+
+static grub_disk_addr_t
+read_run_data (const grub_uint8_t *run, int nn, int sig)
+{
+ grub_uint64_t r = 0;
+
+ if (sig && nn && (run[nn - 1] & 0x80))
+ r = -1;
+
+ grub_memcpy (&r, run, nn);
+
+ return grub_le_to_cpu64 (r);
+}
+
+grub_err_t
+grub_ntfs_read_run_list (struct grub_ntfs_rlst * ctx)
+{
+ grub_uint8_t c1, c2;
+ grub_disk_addr_t val;
+ grub_uint8_t *run;
+
+ run = ctx->cur_run;
+retry:
+ c1 = ((*run) & 0x7);
+ c2 = ((*run) >> 4) & 0x7;
+ run++;
+ if (!c1)
+ {
+ if ((ctx->attr) && (ctx->attr->flags & GRUB_NTFS_AF_ALST))
+ {
+ grub_disk_read_hook_t save_hook;
+
+ save_hook = ctx->comp.disk->read_hook;
+ ctx->comp.disk->read_hook = 0;
+ run = find_attr (ctx->attr, *ctx->attr->attr_cur);
+ ctx->comp.disk->read_hook = save_hook;
+ if (run)
+ {
+ if (run[8] == 0)
+ return grub_error (GRUB_ERR_BAD_FS,
+ "$DATA should be non-resident");
+
+ run += u16at (run, 0x20);
+ ctx->curr_lcn = 0;
+ goto retry;
+ }
+ }
+ return grub_error (GRUB_ERR_BAD_FS, "run list overflown");
+ }
+ ctx->curr_vcn = ctx->next_vcn;
+ ctx->next_vcn += read_run_data (run, c1, 0); /* length of current VCN */
+ run += c1;
+ val = read_run_data (run, c2, 1); /* offset to previous LCN */
+ run += c2;
+ ctx->curr_lcn += val;
+ if (val == 0)
+ ctx->flags |= GRUB_NTFS_RF_BLNK;
+ else
+ ctx->flags &= ~GRUB_NTFS_RF_BLNK;
+ ctx->cur_run = run;
+ return 0;
+}
+
+static grub_disk_addr_t
+grub_ntfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t block)
+{
+ struct grub_ntfs_rlst *ctx;
+
+ ctx = (struct grub_ntfs_rlst *) node;
+ if (block >= ctx->next_vcn)
+ {
+ if (grub_ntfs_read_run_list (ctx))
+ return -1;
+ return ctx->curr_lcn;
+ }
+ else
+ return (ctx->flags & GRUB_NTFS_RF_BLNK) ? 0 : (block -
+ ctx->curr_vcn + ctx->curr_lcn);
+}
+
+static grub_err_t
+read_data (struct grub_ntfs_attr *at, grub_uint8_t *pa, grub_uint8_t *dest,
+ grub_disk_addr_t ofs, grub_size_t len, int cached,
+ grub_disk_read_hook_t read_hook, void *read_hook_data)
+{
+ struct grub_ntfs_rlst cc, *ctx;
+
+ if (len == 0)
+ return 0;
+
+ grub_memset (&cc, 0, sizeof (cc));
+ ctx = &cc;
+ ctx->attr = at;
+ ctx->comp.log_spc = at->mft->data->log_spc;
+ ctx->comp.disk = at->mft->data->disk;
+
+ if (read_hook == grub_file_progress_hook)
+ ctx->file = read_hook_data;
+
+ if (pa[8] == 0)
+ {
+ if (ofs + len > u32at (pa, 0x10))
+ return grub_error (GRUB_ERR_BAD_FS, "read out of range");
+ grub_memcpy (dest, pa + u32at (pa, 0x14) + ofs, len);
+ return 0;
+ }
+
+ ctx->cur_run = pa + u16at (pa, 0x20);
+
+ ctx->next_vcn = u32at (pa, 0x10);
+ ctx->curr_lcn = 0;
+
+ if ((pa[0xC] & GRUB_NTFS_FLAG_COMPRESSED)
+ && !(at->flags & GRUB_NTFS_AF_GPOS))
+ {
+ if (!cached)
+ return grub_error (GRUB_ERR_BAD_FS, "attribute can\'t be compressed");
+
+ return (grub_ntfscomp_func) ? grub_ntfscomp_func (dest, ofs, len, ctx)
+ : grub_error (GRUB_ERR_BAD_FS, N_("module `%s' isn't loaded"),
+ "ntfscomp");
+ }
+
+ ctx->target_vcn = ofs >> (GRUB_NTFS_BLK_SHR + ctx->comp.log_spc);
+ while (ctx->next_vcn <= ctx->target_vcn)
+ {
+ if (grub_ntfs_read_run_list (ctx))
+ return grub_errno;
+ }
+
+ if (at->flags & GRUB_NTFS_AF_GPOS)
+ {
+ grub_disk_addr_t st0, st1;
+ grub_uint64_t m;
+
+ m = (ofs >> GRUB_NTFS_BLK_SHR) & ((1 << ctx->comp.log_spc) - 1);
+
+ st0 =
+ ((ctx->target_vcn - ctx->curr_vcn + ctx->curr_lcn) << ctx->comp.log_spc) + m;
+ st1 = st0 + 1;
+ if (st1 ==
+ (ctx->next_vcn - ctx->curr_vcn + ctx->curr_lcn) << ctx->comp.log_spc)
+ {
+ if (grub_ntfs_read_run_list (ctx))
+ return grub_errno;
+ st1 = ctx->curr_lcn << ctx->comp.log_spc;
+ }
+ grub_set_unaligned32 (dest, grub_cpu_to_le32 (st0));
+ grub_set_unaligned32 (dest + 4, grub_cpu_to_le32 (st1));
+ return 0;
+ }
+
+ grub_fshelp_read_file (ctx->comp.disk, (grub_fshelp_node_t) ctx,
+ read_hook, read_hook_data, ofs, len,
+ (char *) dest,
+ grub_ntfs_read_block, ofs + len,
+ ctx->comp.log_spc, 0);
+ return grub_errno;
+}
+
+static grub_err_t
+read_attr (struct grub_ntfs_attr *at, grub_uint8_t *dest, grub_disk_addr_t ofs,
+ grub_size_t len, int cached,
+ grub_disk_read_hook_t read_hook, void *read_hook_data)
+{
+ grub_uint8_t *save_cur;
+ grub_uint8_t attr;
+ grub_uint8_t *pp;
+ grub_err_t ret;
+
+ save_cur = at->attr_cur;
+ at->attr_nxt = at->attr_cur;
+ attr = *at->attr_nxt;
+ if (at->flags & GRUB_NTFS_AF_ALST)
+ {
+ grub_uint8_t *pa;
+ grub_disk_addr_t vcn;
+
+ /* If compression is possible make sure that we include possible
+ compressed block size. */
+ if (GRUB_NTFS_LOG_COM_SEC >= at->mft->data->log_spc)
+ vcn = ((ofs >> GRUB_NTFS_COM_LOG_LEN)
+ << (GRUB_NTFS_LOG_COM_SEC - at->mft->data->log_spc)) & ~0xFULL;
+ else
+ vcn = ofs >> (at->mft->data->log_spc + GRUB_NTFS_BLK_SHR);
+ pa = at->attr_nxt + u16at (at->attr_nxt, 4);
+ while (pa < at->attr_end)
+ {
+ if (*pa != attr)
+ break;
+ if (u32at (pa, 8) > vcn)
+ break;
+ at->attr_nxt = pa;
+ pa += u16at (pa, 4);
+ }
+ }
+ pp = find_attr (at, attr);
+ if (pp)
+ ret = read_data (at, pp, dest, ofs, len, cached,
+ read_hook, read_hook_data);
+ else
+ ret =
+ (grub_errno) ? grub_errno : grub_error (GRUB_ERR_BAD_FS,
+ "attribute not found");
+ at->attr_cur = save_cur;
+ return ret;
+}
+
+static grub_err_t
+read_mft (struct grub_ntfs_data *data, grub_uint8_t *buf, grub_uint64_t mftno)
+{
+ if (read_attr
+ (&data->mmft.attr, buf, mftno * ((grub_disk_addr_t) data->mft_size << GRUB_NTFS_BLK_SHR),
+ data->mft_size << GRUB_NTFS_BLK_SHR, 0, 0, 0))
+ return grub_error (GRUB_ERR_BAD_FS, "read MFT 0x%llx fails", (unsigned long long) mftno);
+ return fixup (buf, data->mft_size, (const grub_uint8_t *) "FILE");
+}
+
+static grub_err_t
+init_file (struct grub_ntfs_file *mft, grub_uint64_t mftno)
+{
+ unsigned short flag;
+
+ mft->inode_read = 1;
+
+ mft->buf = grub_malloc (mft->data->mft_size << GRUB_NTFS_BLK_SHR);
+ if (mft->buf == NULL)
+ return grub_errno;
+
+ if (read_mft (mft->data, mft->buf, mftno))
+ return grub_errno;
+
+ flag = u16at (mft->buf, 0x16);
+ if ((flag & 1) == 0)
+ return grub_error (GRUB_ERR_BAD_FS, "MFT 0x%llx is not in use",
+ (unsigned long long) mftno);
+
+ if ((flag & 2) == 0)
+ {
+ grub_uint8_t *pa;
+
+ pa = locate_attr (&mft->attr, mft, GRUB_NTFS_AT_DATA);
+ if (pa == NULL)
+ return grub_error (GRUB_ERR_BAD_FS, "no $DATA in MFT 0x%llx",
+ (unsigned long long) mftno);
+
+ if (!pa[8])
+ mft->size = u32at (pa, 0x10);
+ else
+ mft->size = u64at (pa, 0x30);
+
+ if ((mft->attr.flags & GRUB_NTFS_AF_ALST) == 0)
+ mft->attr.attr_end = 0; /* Don't jump to attribute list */
+ }
+ else
+ init_attr (&mft->attr, mft);
+
+ return 0;
+}
+
+static void
+free_file (struct grub_ntfs_file *mft)
+{
+ free_attr (&mft->attr);
+ grub_free (mft->buf);
+}
+
+static char *
+get_utf8 (grub_uint8_t *in, grub_size_t len)
+{
+ grub_uint8_t *buf;
+ grub_uint16_t *tmp;
+ grub_size_t i;
+
+ buf = grub_calloc (len, GRUB_MAX_UTF8_PER_UTF16 + 1);
+ tmp = grub_calloc (len, sizeof (tmp[0]));
+ if (!buf || !tmp)
+ {
+ grub_free (buf);
+ grub_free (tmp);
+ return NULL;
+ }
+ for (i = 0; i < len; i++)
+ tmp[i] = grub_le_to_cpu16 (grub_get_unaligned16 (in + 2 * i));
+ *grub_utf16_to_utf8 (buf, tmp, len) = '\0';
+ grub_free (tmp);
+ return (char *) buf;
+}
+
+static int
+list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ grub_uint8_t *np;
+ int ns;
+
+ while (1)
+ {
+ grub_uint8_t namespace;
+ char *ustr;
+
+ if (pos[0xC] & 2) /* end signature */
+ break;
+
+ np = pos + 0x50;
+ ns = *(np++);
+ namespace = *(np++);
+
+ /*
+ * Ignore files in DOS namespace, as they will reappear as Win32
+ * names.
+ */
+ if ((ns) && (namespace != 2))
+ {
+ enum grub_fshelp_filetype type;
+ struct grub_ntfs_file *fdiro;
+ grub_uint32_t attr;
+
+ attr = u32at (pos, 0x48);
+ if (attr & GRUB_NTFS_ATTR_REPARSE)
+ type = GRUB_FSHELP_SYMLINK;
+ else if (attr & GRUB_NTFS_ATTR_DIRECTORY)
+ type = GRUB_FSHELP_DIR;
+ else
+ type = GRUB_FSHELP_REG;
+
+ fdiro = grub_zalloc (sizeof (struct grub_ntfs_file));
+ if (!fdiro)
+ return 0;
+
+ fdiro->data = diro->data;
+ fdiro->ino = u64at (pos, 0) & 0xffffffffffffULL;
+ fdiro->mtime = u64at (pos, 0x20);
+
+ ustr = get_utf8 (np, ns);
+ if (ustr == NULL)
+ {
+ grub_free (fdiro);
+ return 0;
+ }
+ if (namespace)
+ type |= GRUB_FSHELP_CASE_INSENSITIVE;
+
+ if (hook (ustr, type, fdiro, hook_data))
+ {
+ grub_free (ustr);
+ return 1;
+ }
+
+ grub_free (ustr);
+ }
+ pos += u16at (pos, 8);
+ }
+ return 0;
+}
+
+struct symlink_descriptor
+{
+ grub_uint32_t type;
+ grub_uint32_t total_len;
+ grub_uint16_t off1;
+ grub_uint16_t len1;
+ grub_uint16_t off2;
+ grub_uint16_t len2;
+} GRUB_PACKED;
+
+static char *
+grub_ntfs_read_symlink (grub_fshelp_node_t node)
+{
+ struct grub_ntfs_file *mft;
+ struct symlink_descriptor symdesc;
+ grub_err_t err;
+ grub_uint8_t *buf16;
+ char *buf, *end;
+ grub_size_t len;
+ grub_uint8_t *pa;
+ grub_size_t off;
+
+ mft = (struct grub_ntfs_file *) node;
+
+ mft->buf = grub_malloc (mft->data->mft_size << GRUB_NTFS_BLK_SHR);
+ if (mft->buf == NULL)
+ return NULL;
+
+ if (read_mft (mft->data, mft->buf, mft->ino))
+ return NULL;
+
+ pa = locate_attr (&mft->attr, mft, GRUB_NTFS_AT_SYMLINK);
+ if (pa == NULL)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "no $SYMLINK in MFT 0x%llx",
+ (unsigned long long) mft->ino);
+ return NULL;
+ }
+
+ err = read_attr (&mft->attr, (grub_uint8_t *) &symdesc, 0,
+ sizeof (struct symlink_descriptor), 1, 0, 0);
+ if (err)
+ return NULL;
+
+ switch (grub_cpu_to_le32 (symdesc.type))
+ {
+ case 0xa000000c:
+ off = (sizeof (struct symlink_descriptor) + 4
+ + grub_cpu_to_le32 (symdesc.off1));
+ len = grub_cpu_to_le32 (symdesc.len1);
+ break;
+ case 0xa0000003:
+ off = (sizeof (struct symlink_descriptor)
+ + grub_cpu_to_le32 (symdesc.off1));
+ len = grub_cpu_to_le32 (symdesc.len1);
+ break;
+ default:
+ grub_error (GRUB_ERR_BAD_FS, "symlink type invalid (%x)",
+ grub_cpu_to_le32 (symdesc.type));
+ return NULL;
+ }
+
+ buf16 = grub_malloc (len);
+ if (!buf16)
+ return NULL;
+
+ err = read_attr (&mft->attr, buf16, off, len, 1, 0, 0);
+ if (err)
+ return NULL;
+
+ buf = get_utf8 (buf16, len / 2);
+ if (!buf)
+ {
+ grub_free (buf16);
+ return NULL;
+ }
+ grub_free (buf16);
+
+ for (end = buf; *end; end++)
+ if (*end == '\\')
+ *end = '/';
+
+ /* Split the sequence to avoid GCC thinking that this is a trigraph. */
+ if (grub_memcmp (buf, "/?" "?/", 4) == 0 && buf[5] == ':' && buf[6] == '/'
+ && grub_isalpha (buf[4]))
+ {
+ grub_memmove (buf, buf + 6, end - buf + 1 - 6);
+ end -= 6;
+ }
+ return buf;
+}
+
+static int
+grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ grub_uint8_t *bitmap;
+ struct grub_ntfs_attr attr, *at;
+ grub_uint8_t *cur_pos, *indx, *bmp;
+ int ret = 0;
+ grub_size_t bitmap_len;
+ struct grub_ntfs_file *mft;
+
+ mft = (struct grub_ntfs_file *) dir;
+
+ if (!mft->inode_read)
+ {
+ if (init_file (mft, mft->ino))
+ return 0;
+ }
+
+ indx = NULL;
+ bmp = NULL;
+
+ at = &attr;
+ init_attr (at, mft);
+ while (1)
+ {
+ cur_pos = find_attr (at, GRUB_NTFS_AT_INDEX_ROOT);
+ if (cur_pos == NULL)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "no $INDEX_ROOT");
+ goto done;
+ }
+
+ /* Resident, Namelen=4, Offset=0x18, Flags=0x00, Name="$I30" */
+ if ((u32at (cur_pos, 8) != 0x180400) ||
+ (u32at (cur_pos, 0x18) != 0x490024) ||
+ (u32at (cur_pos, 0x1C) != 0x300033))
+ continue;
+ cur_pos += u16at (cur_pos, 0x14);
+ if (*cur_pos != 0x30) /* Not filename index */
+ continue;
+ break;
+ }
+
+ cur_pos += 0x10; /* Skip index root */
+ ret = list_file (mft, cur_pos + u16at (cur_pos, 0), hook, hook_data);
+ if (ret)
+ goto done;
+
+ bitmap = NULL;
+ bitmap_len = 0;
+ free_attr (at);
+ init_attr (at, mft);
+ while ((cur_pos = find_attr (at, GRUB_NTFS_AT_BITMAP)) != NULL)
+ {
+ int ofs;
+
+ ofs = cur_pos[0xA];
+ /* Namelen=4, Name="$I30" */
+ if ((cur_pos[9] == 4) &&
+ (u32at (cur_pos, ofs) == 0x490024) &&
+ (u32at (cur_pos, ofs + 4) == 0x300033))
+ {
+ int is_resident = (cur_pos[8] == 0);
+
+ bitmap_len = ((is_resident) ? u32at (cur_pos, 0x10) :
+ u32at (cur_pos, 0x28));
+
+ bmp = grub_malloc (bitmap_len);
+ if (bmp == NULL)
+ goto done;
+
+ if (is_resident)
+ {
+ grub_memcpy (bmp, cur_pos + u16at (cur_pos, 0x14),
+ bitmap_len);
+ }
+ else
+ {
+ if (read_data (at, cur_pos, bmp, 0, bitmap_len, 0, 0, 0))
+ {
+ grub_error (GRUB_ERR_BAD_FS,
+ "fails to read non-resident $BITMAP");
+ goto done;
+ }
+ bitmap_len = u32at (cur_pos, 0x30);
+ }
+
+ bitmap = bmp;
+ break;
+ }
+ }
+
+ free_attr (at);
+ cur_pos = locate_attr (at, mft, GRUB_NTFS_AT_INDEX_ALLOCATION);
+ while (cur_pos != NULL)
+ {
+ /* Non-resident, Namelen=4, Offset=0x40, Flags=0, Name="$I30" */
+ if ((u32at (cur_pos, 8) == 0x400401) &&
+ (u32at (cur_pos, 0x40) == 0x490024) &&
+ (u32at (cur_pos, 0x44) == 0x300033))
+ break;
+ cur_pos = find_attr (at, GRUB_NTFS_AT_INDEX_ALLOCATION);
+ }
+
+ if ((!cur_pos) && (bitmap))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "$BITMAP without $INDEX_ALLOCATION");
+ goto done;
+ }
+
+ if (bitmap)
+ {
+ grub_disk_addr_t i;
+ grub_uint8_t v;
+
+ indx = grub_malloc (mft->data->idx_size << GRUB_NTFS_BLK_SHR);
+ if (indx == NULL)
+ goto done;
+
+ v = 1;
+ for (i = 0; i < (grub_disk_addr_t)bitmap_len * 8; i++)
+ {
+ if (*bitmap & v)
+ {
+ if ((read_attr
+ (at, indx, i * (mft->data->idx_size << GRUB_NTFS_BLK_SHR),
+ (mft->data->idx_size << GRUB_NTFS_BLK_SHR), 0, 0, 0))
+ || (fixup (indx, mft->data->idx_size,
+ (const grub_uint8_t *) "INDX")))
+ goto done;
+ ret = list_file (mft, &indx[0x18 + u16at (indx, 0x18)],
+ hook, hook_data);
+ if (ret)
+ goto done;
+ }
+ v <<= 1;
+ if (!v)
+ {
+ v = 1;
+ bitmap++;
+ }
+ }
+ }
+
+done:
+ free_attr (at);
+ grub_free (indx);
+ grub_free (bmp);
+
+ return ret;
+}
+
+static struct grub_ntfs_data *
+grub_ntfs_mount (grub_disk_t disk)
+{
+ struct grub_ntfs_bpb bpb;
+ struct grub_ntfs_data *data = 0;
+ grub_uint32_t spc;
+
+ if (!disk)
+ goto fail;
+
+ data = (struct grub_ntfs_data *) grub_zalloc (sizeof (*data));
+ if (!data)
+ goto fail;
+
+ data->disk = disk;
+
+ /* Read the BPB. */
+ if (grub_disk_read (disk, 0, 0, sizeof (bpb), &bpb))
+ goto fail;
+
+ if (grub_memcmp ((char *) &bpb.oem_name, "NTFS", 4) != 0
+ || bpb.sectors_per_cluster == 0
+ || (bpb.sectors_per_cluster & (bpb.sectors_per_cluster - 1)) != 0
+ || bpb.bytes_per_sector == 0
+ || (bpb.bytes_per_sector & (bpb.bytes_per_sector - 1)) != 0)
+ goto fail;
+
+ spc = (((grub_uint32_t) bpb.sectors_per_cluster
+ * (grub_uint32_t) grub_le_to_cpu16 (bpb.bytes_per_sector))
+ >> GRUB_NTFS_BLK_SHR);
+ if (spc == 0)
+ goto fail;
+
+ for (data->log_spc = 0; (1U << data->log_spc) < spc; data->log_spc++);
+
+ 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);
+
+ data->mft_start = grub_le_to_cpu64 (bpb.mft_lcn) << data->log_spc;
+
+ if ((data->mft_size > GRUB_NTFS_MAX_MFT) || (data->idx_size > GRUB_NTFS_MAX_IDX))
+ goto fail;
+
+ data->mmft.data = data;
+ data->cmft.data = data;
+
+ data->mmft.buf = grub_malloc (data->mft_size << GRUB_NTFS_BLK_SHR);
+ if (!data->mmft.buf)
+ goto fail;
+
+ if (grub_disk_read
+ (disk, data->mft_start, 0, data->mft_size << GRUB_NTFS_BLK_SHR, data->mmft.buf))
+ goto fail;
+
+ data->uuid = grub_le_to_cpu64 (bpb.num_serial);
+
+ if (fixup (data->mmft.buf, data->mft_size, (const grub_uint8_t *) "FILE"))
+ goto fail;
+
+ if (!locate_attr (&data->mmft.attr, &data->mmft, GRUB_NTFS_AT_DATA))
+ goto fail;
+
+ if (init_file (&data->cmft, GRUB_NTFS_FILE_ROOT))
+ goto fail;
+
+ return data;
+
+fail:
+ grub_error (GRUB_ERR_BAD_FS, "not an ntfs filesystem");
+
+ if (data)
+ {
+ free_file (&data->mmft);
+ free_file (&data->cmft);
+ grub_free (data);
+ }
+ return 0;
+}
+
+/* Context for grub_ntfs_dir. */
+struct grub_ntfs_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_ntfs_dir. */
+static int
+grub_ntfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_ntfs_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ info.mtimeset = 1;
+ info.mtime = grub_divmod64 (node->mtime, 10000000, 0)
+ - 86400ULL * 365 * (1970 - 1601)
+ - 86400ULL * ((1970 - 1601) / 4) + 86400ULL * ((1970 - 1601) / 100);
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_ntfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_ntfs_dir_ctx ctx = { hook, hook_data };
+ struct grub_ntfs_data *data = 0;
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_ntfs_mount (device->disk);
+ if (!data)
+ goto fail;
+
+ grub_fshelp_find_file (path, &data->cmft, &fdiro, grub_ntfs_iterate_dir,
+ grub_ntfs_read_symlink, GRUB_FSHELP_DIR);
+
+ if (grub_errno)
+ goto fail;
+
+ grub_ntfs_iterate_dir (fdiro, grub_ntfs_dir_iter, &ctx);
+
+fail:
+ if ((fdiro) && (fdiro != &data->cmft))
+ {
+ free_file (fdiro);
+ grub_free (fdiro);
+ }
+ if (data)
+ {
+ free_file (&data->mmft);
+ free_file (&data->cmft);
+ grub_free (data);
+ }
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_ntfs_open (grub_file_t file, const char *name)
+{
+ struct grub_ntfs_data *data = 0;
+ struct grub_fshelp_node *mft = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_ntfs_mount (file->device->disk);
+ if (!data)
+ goto fail;
+
+ grub_fshelp_find_file (name, &data->cmft, &mft, grub_ntfs_iterate_dir,
+ grub_ntfs_read_symlink, GRUB_FSHELP_REG);
+
+ if (grub_errno)
+ goto fail;
+
+ if (mft != &data->cmft)
+ {
+ free_file (&data->cmft);
+ grub_memcpy (&data->cmft, mft, sizeof (*mft));
+ grub_free (mft);
+ if (!data->cmft.inode_read)
+ {
+ if (init_file (&data->cmft, data->cmft.ino))
+ goto fail;
+ }
+ }
+
+ file->size = data->cmft.size;
+ file->data = data;
+ file->offset = 0;
+
+ return 0;
+
+fail:
+ if (data)
+ {
+ free_file (&data->mmft);
+ free_file (&data->cmft);
+ grub_free (data);
+ }
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_ssize_t
+grub_ntfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_ntfs_file *mft;
+
+ mft = &((struct grub_ntfs_data *) file->data)->cmft;
+ if (file->read_hook)
+ mft->attr.save_pos = 1;
+
+ read_attr (&mft->attr, (grub_uint8_t *) buf, file->offset, len, 1,
+ file->read_hook, file->read_hook_data);
+ return (grub_errno) ? -1 : (grub_ssize_t) len;
+}
+
+static grub_err_t
+grub_ntfs_close (grub_file_t file)
+{
+ struct grub_ntfs_data *data;
+
+ data = file->data;
+
+ if (data)
+ {
+ free_file (&data->mmft);
+ free_file (&data->cmft);
+ grub_free (data);
+ }
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_ntfs_label (grub_device_t device, char **label)
+{
+ struct grub_ntfs_data *data = 0;
+ struct grub_fshelp_node *mft = 0;
+ grub_uint8_t *pa;
+
+ grub_dl_ref (my_mod);
+
+ *label = 0;
+
+ data = grub_ntfs_mount (device->disk);
+ if (!data)
+ goto fail;
+
+ grub_fshelp_find_file ("/$Volume", &data->cmft, &mft, grub_ntfs_iterate_dir,
+ 0, GRUB_FSHELP_REG);
+
+ if (grub_errno)
+ goto fail;
+
+ if (!mft->inode_read)
+ {
+ mft->buf = grub_malloc (mft->data->mft_size << GRUB_NTFS_BLK_SHR);
+ if (mft->buf == NULL)
+ goto fail;
+
+ if (read_mft (mft->data, mft->buf, mft->ino))
+ goto fail;
+ }
+
+ init_attr (&mft->attr, mft);
+ pa = find_attr (&mft->attr, GRUB_NTFS_AT_VOLUME_NAME);
+ if ((pa) && (pa[8] == 0) && (u32at (pa, 0x10)))
+ {
+ int len;
+
+ len = u32at (pa, 0x10) / 2;
+ pa += u16at (pa, 0x14);
+ *label = get_utf8 (pa, len);
+ }
+
+fail:
+ if ((mft) && (mft != &data->cmft))
+ {
+ free_file (mft);
+ grub_free (mft);
+ }
+ if (data)
+ {
+ free_file (&data->mmft);
+ free_file (&data->cmft);
+ grub_free (data);
+ }
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_ntfs_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_ntfs_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_ntfs_mount (disk);
+ if (data)
+ {
+ char *ptr;
+ *uuid = grub_xasprintf ("%016llx", (unsigned long long) data->uuid);
+ if (*uuid)
+ for (ptr = *uuid; *ptr; ptr++)
+ *ptr = grub_toupper (*ptr);
+ free_file (&data->mmft);
+ free_file (&data->cmft);
+ grub_free (data);
+ }
+ else
+ *uuid = NULL;
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static struct grub_fs grub_ntfs_fs =
+ {
+ .name = "ntfs",
+ .fs_dir = grub_ntfs_dir,
+ .fs_open = grub_ntfs_open,
+ .fs_read = grub_ntfs_read,
+ .fs_close = grub_ntfs_close,
+ .fs_label = grub_ntfs_label,
+ .fs_uuid = grub_ntfs_uuid,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+};
+
+GRUB_MOD_INIT (ntfs)
+{
+ grub_fs_register (&grub_ntfs_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (ntfs)
+{
+ grub_fs_unregister (&grub_ntfs_fs);
+}
diff --git a/grub-core/fs/ntfscomp.c b/grub-core/fs/ntfscomp.c
new file mode 100644
index 0000000..3cd97d3
--- /dev/null
+++ b/grub-core/fs/ntfscomp.c
@@ -0,0 +1,443 @@
+/* ntfscomp.c - compression support for the NTFS filesystem */
+/*
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/ntfs.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+decomp_nextvcn (struct grub_ntfs_comp *cc)
+{
+ if (cc->comp_head >= cc->comp_tail)
+ return grub_error (GRUB_ERR_BAD_FS, "compression block overflown");
+ if (grub_disk_read
+ (cc->disk,
+ (cc->comp_table[cc->comp_head].next_lcn -
+ (cc->comp_table[cc->comp_head].next_vcn - cc->cbuf_vcn)) << cc->log_spc,
+ 0,
+ 1 << (cc->log_spc + GRUB_NTFS_BLK_SHR), cc->cbuf))
+ return grub_errno;
+ cc->cbuf_vcn++;
+ if ((cc->cbuf_vcn >= cc->comp_table[cc->comp_head].next_vcn))
+ cc->comp_head++;
+ cc->cbuf_ofs = 0;
+ return 0;
+}
+
+static grub_err_t
+decomp_getch (struct grub_ntfs_comp *cc, grub_uint8_t *res)
+{
+ if (cc->cbuf_ofs >= (1U << (cc->log_spc + GRUB_NTFS_BLK_SHR)))
+ {
+ if (decomp_nextvcn (cc))
+ return grub_errno;
+ }
+ *res = cc->cbuf[cc->cbuf_ofs++];
+ return 0;
+}
+
+static grub_err_t
+decomp_get16 (struct grub_ntfs_comp *cc, grub_uint16_t * res)
+{
+ grub_uint8_t c1 = 0, c2 = 0;
+
+ if ((decomp_getch (cc, &c1)) || (decomp_getch (cc, &c2)))
+ return grub_errno;
+ *res = ((grub_uint16_t) c2) * 256 + ((grub_uint16_t) c1);
+ return 0;
+}
+
+/* Decompress a block (4096 bytes) */
+static grub_err_t
+decomp_block (struct grub_ntfs_comp *cc, grub_uint8_t *dest)
+{
+ grub_uint16_t flg, cnt;
+
+ if (decomp_get16 (cc, &flg))
+ return grub_errno;
+ cnt = (flg & 0xFFF) + 1;
+
+ if (dest)
+ {
+ if (flg & 0x8000)
+ {
+ grub_uint8_t tag;
+ grub_uint32_t bits, copied;
+
+ bits = copied = tag = 0;
+ while (cnt > 0)
+ {
+ if (copied > GRUB_NTFS_COM_LEN)
+ return grub_error (GRUB_ERR_BAD_FS,
+ "compression block too large");
+
+ if (!bits)
+ {
+ if (decomp_getch (cc, &tag))
+ return grub_errno;
+
+ bits = 8;
+ cnt--;
+ if (cnt <= 0)
+ break;
+ }
+ if (tag & 1)
+ {
+ grub_uint32_t i, len, delta, code, lmask, dshift;
+ grub_uint16_t word = 0;
+
+ if (decomp_get16 (cc, &word))
+ return grub_errno;
+
+ code = word;
+ cnt -= 2;
+
+ if (!copied)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "nontext window empty");
+ return 0;
+ }
+
+ for (i = copied - 1, lmask = 0xFFF, dshift = 12; i >= 0x10;
+ i >>= 1)
+ {
+ lmask >>= 1;
+ dshift--;
+ }
+
+ delta = code >> dshift;
+ len = (code & lmask) + 3;
+
+ for (i = 0; i < len; i++)
+ {
+ dest[copied] = dest[copied - delta - 1];
+ copied++;
+ }
+ }
+ else
+ {
+ grub_uint8_t ch = 0;
+
+ if (decomp_getch (cc, &ch))
+ return grub_errno;
+ dest[copied++] = ch;
+ cnt--;
+ }
+ tag >>= 1;
+ bits--;
+ }
+ return 0;
+ }
+ else
+ {
+ if (cnt != GRUB_NTFS_COM_LEN)
+ return grub_error (GRUB_ERR_BAD_FS,
+ "invalid compression block size");
+ }
+ }
+
+ while (cnt > 0)
+ {
+ int n;
+
+ n = (1 << (cc->log_spc + GRUB_NTFS_BLK_SHR)) - cc->cbuf_ofs;
+ if (n > cnt)
+ n = cnt;
+ if ((dest) && (n))
+ {
+ grub_memcpy (dest, &cc->cbuf[cc->cbuf_ofs], n);
+ dest += n;
+ }
+ cnt -= n;
+ cc->cbuf_ofs += n;
+ if ((cnt) && (decomp_nextvcn (cc)))
+ return grub_errno;
+ }
+ return 0;
+}
+
+static grub_err_t
+read_block (struct grub_ntfs_rlst *ctx, grub_uint8_t *buf, grub_size_t num)
+{
+ int log_cpb = GRUB_NTFS_LOG_COM_SEC - ctx->comp.log_spc;
+
+ while (num)
+ {
+ grub_size_t nn;
+
+ if ((ctx->target_vcn & 0xF) == 0)
+ {
+
+ if (ctx->comp.comp_head != ctx->comp.comp_tail
+ && !(ctx->flags & GRUB_NTFS_RF_BLNK))
+ return grub_error (GRUB_ERR_BAD_FS, "invalid compression block");
+ ctx->comp.comp_head = ctx->comp.comp_tail = 0;
+ ctx->comp.cbuf_vcn = ctx->target_vcn;
+ ctx->comp.cbuf_ofs = (1 << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR));
+ if (ctx->target_vcn >= ctx->next_vcn)
+ {
+ if (grub_ntfs_read_run_list (ctx))
+ return grub_errno;
+ }
+ while (ctx->target_vcn + 16 > ctx->next_vcn)
+ {
+ if (ctx->flags & GRUB_NTFS_RF_BLNK)
+ break;
+ ctx->comp.comp_table[ctx->comp.comp_tail].next_vcn = ctx->next_vcn;
+ ctx->comp.comp_table[ctx->comp.comp_tail].next_lcn =
+ ctx->curr_lcn + ctx->next_vcn - ctx->curr_vcn;
+ ctx->comp.comp_tail++;
+ if (grub_ntfs_read_run_list (ctx))
+ return grub_errno;
+ }
+ }
+
+ nn = (16 - (unsigned) (ctx->target_vcn & 0xF)) >> log_cpb;
+ if (nn > num)
+ nn = num;
+ num -= nn;
+
+ if (ctx->flags & GRUB_NTFS_RF_BLNK)
+ {
+ ctx->target_vcn += nn << log_cpb;
+ if (ctx->comp.comp_tail == 0)
+ {
+ if (buf)
+ {
+ grub_memset (buf, 0, nn * GRUB_NTFS_COM_LEN);
+ buf += nn * GRUB_NTFS_COM_LEN;
+ if (grub_file_progress_hook && ctx->file)
+ grub_file_progress_hook (0, 0, nn * GRUB_NTFS_COM_LEN,
+ ctx->file);
+ }
+ }
+ else
+ {
+ while (nn)
+ {
+ if (decomp_block (&ctx->comp, buf))
+ return grub_errno;
+ if (buf)
+ buf += GRUB_NTFS_COM_LEN;
+ if (grub_file_progress_hook && ctx->file)
+ grub_file_progress_hook (0, 0, GRUB_NTFS_COM_LEN,
+ ctx->file);
+ nn--;
+ }
+ }
+ }
+ else
+ {
+ nn <<= log_cpb;
+ while ((ctx->comp.comp_head < ctx->comp.comp_tail) && (nn))
+ {
+ grub_disk_addr_t tt;
+
+ tt =
+ ctx->comp.comp_table[ctx->comp.comp_head].next_vcn -
+ ctx->target_vcn;
+ if (tt > nn)
+ tt = nn;
+ ctx->target_vcn += tt;
+ if (buf)
+ {
+ if (grub_disk_read
+ (ctx->comp.disk,
+ (ctx->comp.comp_table[ctx->comp.comp_head].next_lcn -
+ (ctx->comp.comp_table[ctx->comp.comp_head].next_vcn -
+ ctx->target_vcn)) << ctx->comp.log_spc, 0,
+ tt << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR), buf))
+ return grub_errno;
+ if (grub_file_progress_hook && ctx->file)
+ grub_file_progress_hook (0, 0,
+ tt << (ctx->comp.log_spc
+ + GRUB_NTFS_BLK_SHR),
+ ctx->file);
+ buf += tt << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
+ }
+ nn -= tt;
+ if (ctx->target_vcn >=
+ ctx->comp.comp_table[ctx->comp.comp_head].next_vcn)
+ ctx->comp.comp_head++;
+ }
+ if (nn)
+ {
+ if (buf)
+ {
+ if (grub_disk_read
+ (ctx->comp.disk,
+ (ctx->target_vcn - ctx->curr_vcn +
+ ctx->curr_lcn) << ctx->comp.log_spc, 0,
+ nn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR), buf))
+ return grub_errno;
+ buf += nn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
+ if (grub_file_progress_hook && ctx->file)
+ grub_file_progress_hook (0, 0,
+ nn << (ctx->comp.log_spc
+ + GRUB_NTFS_BLK_SHR),
+ ctx->file);
+ }
+ ctx->target_vcn += nn;
+ }
+ }
+ }
+ return 0;
+}
+
+static grub_err_t
+ntfscomp (grub_uint8_t *dest, grub_disk_addr_t ofs,
+ grub_size_t len, struct grub_ntfs_rlst *ctx)
+{
+ grub_err_t ret;
+ grub_disk_addr_t vcn;
+
+ if (ctx->attr->sbuf)
+ {
+ if ((ofs & (~(GRUB_NTFS_COM_LEN - 1))) == ctx->attr->save_pos)
+ {
+ grub_disk_addr_t n;
+
+ n = GRUB_NTFS_COM_LEN - (ofs - ctx->attr->save_pos);
+ if (n > len)
+ n = len;
+
+ grub_memcpy (dest, ctx->attr->sbuf + ofs - ctx->attr->save_pos, n);
+ if (grub_file_progress_hook && ctx->file)
+ grub_file_progress_hook (0, 0, n, ctx->file);
+ if (n == len)
+ return 0;
+
+ dest += n;
+ len -= n;
+ ofs += n;
+ }
+ }
+ else
+ {
+ ctx->attr->sbuf = grub_malloc (GRUB_NTFS_COM_LEN);
+ if (ctx->attr->sbuf == NULL)
+ return grub_errno;
+ ctx->attr->save_pos = 1;
+ }
+
+ vcn = ctx->target_vcn = (ofs >> GRUB_NTFS_COM_LOG_LEN) * (GRUB_NTFS_COM_SEC >> ctx->comp.log_spc);
+ ctx->target_vcn &= ~0xFULL;
+ while (ctx->next_vcn <= ctx->target_vcn)
+ {
+ if (grub_ntfs_read_run_list (ctx))
+ return grub_errno;
+ }
+
+ ctx->comp.comp_head = ctx->comp.comp_tail = 0;
+ ctx->comp.cbuf = grub_malloc (1 << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR));
+ if (!ctx->comp.cbuf)
+ return 0;
+
+ ret = 0;
+
+ //ctx->comp.disk->read_hook = read_hook;
+ //ctx->comp.disk->read_hook_data = read_hook_data;
+
+ if ((vcn > ctx->target_vcn) &&
+ (read_block
+ (ctx, NULL, (vcn - ctx->target_vcn) >> (GRUB_NTFS_LOG_COM_SEC - ctx->comp.log_spc))))
+ {
+ ret = grub_errno;
+ goto quit;
+ }
+
+ if (ofs % GRUB_NTFS_COM_LEN)
+ {
+ grub_uint32_t t, n, o;
+ void *file = ctx->file;
+
+ ctx->file = 0;
+
+ t = ctx->target_vcn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
+ if (read_block (ctx, ctx->attr->sbuf, 1))
+ {
+ ret = grub_errno;
+ goto quit;
+ }
+
+ ctx->file = file;
+
+ ctx->attr->save_pos = t;
+
+ o = ofs % GRUB_NTFS_COM_LEN;
+ n = GRUB_NTFS_COM_LEN - o;
+ if (n > len)
+ n = len;
+ grub_memcpy (dest, &ctx->attr->sbuf[o], n);
+ if (grub_file_progress_hook && ctx->file)
+ grub_file_progress_hook (0, 0, n, ctx->file);
+ if (n == len)
+ goto quit;
+ dest += n;
+ len -= n;
+ }
+
+ if (read_block (ctx, dest, len / GRUB_NTFS_COM_LEN))
+ {
+ ret = grub_errno;
+ goto quit;
+ }
+
+ dest += (len / GRUB_NTFS_COM_LEN) * GRUB_NTFS_COM_LEN;
+ len = len % GRUB_NTFS_COM_LEN;
+ if (len)
+ {
+ grub_uint32_t t;
+ void *file = ctx->file;
+
+ ctx->file = 0;
+ t = ctx->target_vcn << (ctx->comp.log_spc + GRUB_NTFS_BLK_SHR);
+ if (read_block (ctx, ctx->attr->sbuf, 1))
+ {
+ ret = grub_errno;
+ goto quit;
+ }
+
+ ctx->attr->save_pos = t;
+
+ grub_memcpy (dest, ctx->attr->sbuf, len);
+ if (grub_file_progress_hook && file)
+ grub_file_progress_hook (0, 0, len, file);
+ }
+
+quit:
+ //ctx->comp.disk->read_hook = 0;
+ if (ctx->comp.cbuf)
+ grub_free (ctx->comp.cbuf);
+ return ret;
+}
+
+GRUB_MOD_INIT (ntfscomp)
+{
+ grub_ntfscomp_func = ntfscomp;
+}
+
+GRUB_MOD_FINI (ntfscomp)
+{
+ grub_ntfscomp_func = NULL;
+}
diff --git a/grub-core/fs/odc.c b/grub-core/fs/odc.c
new file mode 100644
index 0000000..7900006
--- /dev/null
+++ b/grub-core/fs/odc.c
@@ -0,0 +1,61 @@
+/* cpio.c - cpio and tar filesystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009,2013 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+
+#define ALIGN_CPIO(x) x
+
+#define MAGIC "070707"
+struct head
+{
+ char magic[6];
+ char dev[6];
+ char ino[6];
+ char mode[6];
+ char uid[6];
+ char gid[6];
+ char nlink[6];
+ char rdev[6];
+ char mtime[11];
+ char namesize[6];
+ char filesize[11];
+} GRUB_PACKED;
+
+static inline unsigned long long
+read_number (const char *str, grub_size_t size)
+{
+ unsigned long long ret = 0;
+ while (size-- && *str >= '0' && *str <= '7')
+ ret = (ret << 3) | (*str++ & 0xf);
+ return ret;
+}
+
+#define FSNAME "odc"
+
+#include "cpio_common.c"
+
+GRUB_MOD_INIT (odc)
+{
+ grub_fs_register (&grub_cpio_fs);
+}
+
+GRUB_MOD_FINI (odc)
+{
+ grub_fs_unregister (&grub_cpio_fs);
+}
diff --git a/grub-core/fs/proc.c b/grub-core/fs/proc.c
new file mode 100644
index 0000000..5f51650
--- /dev/null
+++ b/grub-core/fs/proc.c
@@ -0,0 +1,203 @@
+/*
+ * 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/procfs.h>
+#include <grub/disk.h>
+#include <grub/fs.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/archelp.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_procfs_entry *grub_procfs_entries;
+
+static int
+grub_procdev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ return hook ("proc", hook_data);
+}
+
+static grub_err_t
+grub_procdev_open (const char *name, grub_disk_t disk)
+{
+ if (grub_strcmp (name, "proc"))
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a procfs disk");
+
+ disk->total_sectors = 0;
+ disk->id = 0;
+
+ disk->data = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_procdev_close (grub_disk_t disk __attribute((unused)))
+{
+}
+
+static grub_err_t
+grub_procdev_read (grub_disk_t disk __attribute((unused)),
+ grub_disk_addr_t sector __attribute((unused)),
+ grub_size_t size __attribute((unused)),
+ char *buf __attribute((unused)))
+{
+ return GRUB_ERR_OUT_OF_RANGE;
+}
+
+static grub_err_t
+grub_procdev_write (grub_disk_t disk __attribute ((unused)),
+ grub_disk_addr_t sector __attribute ((unused)),
+ grub_size_t size __attribute ((unused)),
+ const char *buf __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)
+{
+ char *data = file->data;
+
+ grub_memcpy (buf, data + file->offset, len);
+
+ return len;
+}
+
+static grub_err_t
+grub_procfs_close (grub_file_t file)
+{
+ char *data;
+
+ data = file->data;
+ grub_free (data);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_procfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ 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");
+
+ 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)
+{
+ 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 = {
+ .name = "proc",
+ .id = GRUB_DISK_DEVICE_PROCFS_ID,
+ .disk_iterate = grub_procdev_iterate,
+ .disk_open = grub_procdev_open,
+ .disk_close = grub_procdev_close,
+ .disk_read = grub_procdev_read,
+ .disk_write = grub_procdev_write,
+ .next = 0
+};
+
+static struct grub_fs grub_procfs_fs =
+ {
+ .name = "procfs",
+ .fs_dir = grub_procfs_dir,
+ .fs_open = grub_procfs_open,
+ .fs_read = grub_procfs_read,
+ .fs_close = grub_procfs_close,
+ .next = 0
+ };
+
+GRUB_MOD_INIT (procfs)
+{
+ grub_disk_dev_register (&grub_procfs_dev);
+ grub_fs_register (&grub_procfs_fs);
+}
+
+GRUB_MOD_FINI (procfs)
+{
+ grub_disk_dev_unregister (&grub_procfs_dev);
+ grub_fs_unregister (&grub_procfs_fs);
+}
diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c
new file mode 100644
index 0000000..af6a226
--- /dev/null
+++ b/grub-core/fs/reiserfs.c
@@ -0,0 +1,1427 @@
+/* reiserfs.c - ReiserFS versions up to 3.6 */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,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/>.
+ */
+
+/*
+ TODO:
+ implement journal handling (ram replay)
+ test tail packing & direct files
+ validate partition label position
+*/
+
+#if 0
+# define GRUB_REISERFS_DEBUG
+# define GRUB_REISERFS_JOURNALING
+# define GRUB_HEXDUMP
+#endif
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define MIN(a, b) \
+ ({ typeof (a) _a = (a); \
+ typeof (b) _b = (b); \
+ _a < _b ? _a : _b; })
+
+#define MAX(a, b) \
+ ({ typeof (a) _a = (a); \
+ typeof (b) _b = (b); \
+ _a > _b ? _a : _b; })
+
+#define REISERFS_SUPER_BLOCK_OFFSET 0x10000
+#define REISERFS_MAGIC_LEN 12
+#define REISERFS_MAGIC_STRING "ReIsEr"
+#define REISERFS_MAGIC_DESC_BLOCK "ReIsErLB"
+/* If the 3rd bit of an item state is set, then it's visible. */
+#define GRUB_REISERFS_VISIBLE_MASK ((grub_uint16_t) 0x04)
+
+#define S_IFLNK 0xA000
+
+static grub_dl_t my_mod;
+
+#define assert(boolean) real_assert (boolean, GRUB_FILE, __LINE__)
+static inline void
+real_assert (int boolean, const char *file, const int line)
+{
+ if (! boolean)
+ grub_printf ("Assertion failed at %s:%d\n", file, line);
+}
+
+enum grub_reiserfs_item_type
+ {
+ GRUB_REISERFS_STAT,
+ GRUB_REISERFS_DIRECTORY,
+ GRUB_REISERFS_DIRECT,
+ GRUB_REISERFS_INDIRECT,
+ /* Matches both _DIRECT and _INDIRECT when searching. */
+ GRUB_REISERFS_ANY,
+ GRUB_REISERFS_UNKNOWN
+ };
+
+struct grub_reiserfs_superblock
+{
+ grub_uint32_t block_count;
+ grub_uint32_t block_free_count;
+ grub_uint32_t root_block;
+ grub_uint32_t journal_block;
+ grub_uint32_t journal_device;
+ grub_uint32_t journal_original_size;
+ grub_uint32_t journal_max_transaction_size;
+ grub_uint32_t journal_block_count;
+ grub_uint32_t journal_max_batch;
+ grub_uint32_t journal_max_commit_age;
+ grub_uint32_t journal_max_transaction_age;
+ grub_uint16_t block_size;
+ grub_uint16_t oid_max_size;
+ grub_uint16_t oid_current_size;
+ grub_uint16_t state;
+ grub_uint8_t magic_string[REISERFS_MAGIC_LEN];
+ grub_uint32_t function_hash_code;
+ grub_uint16_t tree_height;
+ grub_uint16_t bitmap_number;
+ grub_uint16_t version;
+ grub_uint16_t reserved;
+ grub_uint32_t inode_generation;
+ grub_uint8_t unused[4];
+ grub_uint16_t uuid[8];
+ char label[16];
+} GRUB_PACKED;
+
+struct grub_reiserfs_journal_header
+{
+ grub_uint32_t last_flush_uid;
+ grub_uint32_t unflushed_offset;
+ grub_uint32_t mount_id;
+} GRUB_PACKED;
+
+struct grub_reiserfs_description_block
+{
+ grub_uint32_t id;
+ grub_uint32_t len;
+ grub_uint32_t mount_id;
+ grub_uint32_t real_blocks[0];
+} GRUB_PACKED;
+
+struct grub_reiserfs_commit_block
+{
+ grub_uint32_t id;
+ grub_uint32_t len;
+ grub_uint32_t real_blocks[0];
+} GRUB_PACKED;
+
+struct grub_reiserfs_stat_item_v1
+{
+ grub_uint16_t mode;
+ grub_uint16_t hardlink_count;
+ grub_uint16_t uid;
+ grub_uint16_t gid;
+ grub_uint32_t size;
+ grub_uint32_t atime;
+ grub_uint32_t mtime;
+ grub_uint32_t ctime;
+ grub_uint32_t rdev;
+ grub_uint32_t first_direct_byte;
+} GRUB_PACKED;
+
+struct grub_reiserfs_stat_item_v2
+{
+ grub_uint16_t mode;
+ grub_uint16_t reserved;
+ grub_uint32_t hardlink_count;
+ grub_uint64_t size;
+ grub_uint32_t uid;
+ grub_uint32_t gid;
+ grub_uint32_t atime;
+ grub_uint32_t mtime;
+ grub_uint32_t ctime;
+ grub_uint32_t blocks;
+ grub_uint32_t first_direct_byte;
+} GRUB_PACKED;
+
+struct grub_reiserfs_key
+{
+ grub_uint32_t directory_id;
+ grub_uint32_t object_id;
+ union
+ {
+ struct
+ {
+ grub_uint32_t offset;
+ grub_uint32_t type;
+ } GRUB_PACKED v1;
+ struct
+ {
+ grub_uint64_t offset_type;
+ } GRUB_PACKED v2;
+ } u;
+} GRUB_PACKED;
+
+struct grub_reiserfs_item_header
+{
+ struct grub_reiserfs_key key;
+ union
+ {
+ grub_uint16_t free_space;
+ grub_uint16_t entry_count;
+ } GRUB_PACKED u;
+ grub_uint16_t item_size;
+ grub_uint16_t item_location;
+ grub_uint16_t version;
+} GRUB_PACKED;
+
+struct grub_reiserfs_block_header
+{
+ grub_uint16_t level;
+ grub_uint16_t item_count;
+ grub_uint16_t free_space;
+ grub_uint16_t reserved;
+ struct grub_reiserfs_key block_right_delimiting_key;
+} GRUB_PACKED;
+
+struct grub_reiserfs_disk_child
+{
+ grub_uint32_t block_number;
+ grub_uint16_t size;
+ grub_uint16_t reserved;
+} GRUB_PACKED;
+
+struct grub_reiserfs_directory_header
+{
+ grub_uint32_t offset;
+ grub_uint32_t directory_id;
+ grub_uint32_t object_id;
+ grub_uint16_t location;
+ grub_uint16_t state;
+} GRUB_PACKED;
+
+struct grub_fshelp_node
+{
+ struct grub_reiserfs_data *data;
+ grub_uint32_t block_number; /* 0 if node is not found. */
+ grub_uint16_t block_position;
+ grub_uint64_t next_offset;
+ grub_int32_t mtime;
+ grub_off_t size;
+ enum grub_reiserfs_item_type type; /* To know how to read the header. */
+ struct grub_reiserfs_item_header header;
+};
+
+/* Returned when opening a file. */
+struct grub_reiserfs_data
+{
+ struct grub_reiserfs_superblock superblock;
+ grub_disk_t disk;
+};
+
+static grub_ssize_t
+grub_reiserfs_read_real (struct grub_fshelp_node *node,
+ grub_off_t off, char *buf, grub_size_t len,
+ grub_disk_read_hook_t read_hook,
+ void *read_hook_data);
+
+/* Internal-only functions. Not to be used outside of this file. */
+
+/* Return the type of given v2 key. */
+static enum grub_reiserfs_item_type
+grub_reiserfs_get_key_v2_type (const struct grub_reiserfs_key *key)
+{
+ switch (grub_le_to_cpu64 (key->u.v2.offset_type) >> 60)
+ {
+ case 0:
+ return GRUB_REISERFS_STAT;
+ case 15:
+ return GRUB_REISERFS_ANY;
+ case 3:
+ return GRUB_REISERFS_DIRECTORY;
+ case 2:
+ return GRUB_REISERFS_DIRECT;
+ case 1:
+ return GRUB_REISERFS_INDIRECT;
+ }
+ return GRUB_REISERFS_UNKNOWN;
+}
+
+/* Return the type of given v1 key. */
+static enum grub_reiserfs_item_type
+grub_reiserfs_get_key_v1_type (const struct grub_reiserfs_key *key)
+{
+ switch (grub_le_to_cpu32 (key->u.v1.type))
+ {
+ case 0:
+ return GRUB_REISERFS_STAT;
+ case 555:
+ return GRUB_REISERFS_ANY;
+ case 500:
+ return GRUB_REISERFS_DIRECTORY;
+ case 0x20000000:
+ case 0xFFFFFFFF:
+ return GRUB_REISERFS_DIRECT;
+ case 0x10000000:
+ case 0xFFFFFFFE:
+ return GRUB_REISERFS_INDIRECT;
+ }
+ return GRUB_REISERFS_UNKNOWN;
+}
+
+/* Return 1 if the given key is version 1 key, 2 otherwise. */
+static int
+grub_reiserfs_get_key_version (const struct grub_reiserfs_key *key)
+{
+ return grub_reiserfs_get_key_v1_type (key) == GRUB_REISERFS_UNKNOWN ? 2 : 1;
+}
+
+#ifdef GRUB_HEXDUMP
+static void
+grub_hexdump (char *buffer, grub_size_t len)
+{
+ grub_size_t a;
+ for (a = 0; a < len; a++)
+ {
+ if (! (a & 0x0F))
+ grub_printf ("\n%08x ", a);
+ grub_printf ("%02x ",
+ ((unsigned int) ((unsigned char *) buffer)[a]) & 0xFF);
+ }
+ grub_printf ("\n");
+}
+#endif
+
+#ifdef GRUB_REISERFS_DEBUG
+static grub_uint64_t
+grub_reiserfs_get_key_offset (const struct grub_reiserfs_key *key);
+
+static enum grub_reiserfs_item_type
+grub_reiserfs_get_key_type (const struct grub_reiserfs_key *key);
+
+static void
+grub_reiserfs_print_key (const struct grub_reiserfs_key *key)
+{
+ unsigned int a;
+ char *reiserfs_type_strings[] = {
+ "stat ",
+ "directory",
+ "direct ",
+ "indirect ",
+ "any ",
+ "unknown "
+ };
+
+ for (a = 0; a < sizeof (struct grub_reiserfs_key); a++)
+ grub_printf ("%02x ", ((unsigned int) ((unsigned char *) key)[a]) & 0xFF);
+ grub_printf ("parent id = 0x%08x, self id = 0x%08x, type = %s, offset = ",
+ grub_le_to_cpu32 (key->directory_id),
+ grub_le_to_cpu32 (key->object_id),
+ reiserfs_type_strings [grub_reiserfs_get_key_type (key)]);
+ if (grub_reiserfs_get_key_version (key) == 1)
+ grub_printf("%08x", (unsigned int) grub_reiserfs_get_key_offset (key));
+ else
+ grub_printf("0x%07x%08x",
+ (unsigned) (grub_reiserfs_get_key_offset (key) >> 32),
+ (unsigned) (grub_reiserfs_get_key_offset (key) & 0xFFFFFFFF));
+ grub_printf ("\n");
+}
+#endif
+
+/* Return the offset of given key. */
+static grub_uint64_t
+grub_reiserfs_get_key_offset (const struct grub_reiserfs_key *key)
+{
+ if (grub_reiserfs_get_key_version (key) == 1)
+ return grub_le_to_cpu32 (key->u.v1.offset);
+ else
+ return grub_le_to_cpu64 (key->u.v2.offset_type) & (~0ULL >> 4);
+}
+
+/* Set the offset of given key. */
+static void
+grub_reiserfs_set_key_offset (struct grub_reiserfs_key *key,
+ grub_uint64_t value)
+{
+ if (grub_reiserfs_get_key_version (key) == 1)
+ key->u.v1.offset = grub_cpu_to_le32 (value);
+ else
+ key->u.v2.offset_type \
+ = ((key->u.v2.offset_type & grub_cpu_to_le64_compile_time (15ULL << 60))
+ | grub_cpu_to_le64 (value & (~0ULL >> 4)));
+}
+
+/* Return the type of given key. */
+static enum grub_reiserfs_item_type
+grub_reiserfs_get_key_type (const struct grub_reiserfs_key *key)
+{
+ if (grub_reiserfs_get_key_version (key) == 1)
+ return grub_reiserfs_get_key_v1_type (key);
+ else
+ return grub_reiserfs_get_key_v2_type (key);
+}
+
+/* Set the type of given key, with given version number. */
+static void
+grub_reiserfs_set_key_type (struct grub_reiserfs_key *key,
+ enum grub_reiserfs_item_type grub_type,
+ int version)
+{
+ grub_uint32_t type;
+
+ switch (grub_type)
+ {
+ case GRUB_REISERFS_STAT:
+ type = 0;
+ break;
+ case GRUB_REISERFS_ANY:
+ type = (version == 1) ? 555 : 15;
+ break;
+ case GRUB_REISERFS_DIRECTORY:
+ type = (version == 1) ? 500 : 3;
+ break;
+ case GRUB_REISERFS_DIRECT:
+ type = (version == 1) ? 0xFFFFFFFF : 2;
+ break;
+ case GRUB_REISERFS_INDIRECT:
+ type = (version == 1) ? 0xFFFFFFFE : 1;
+ break;
+ default:
+ return;
+ }
+
+ if (version == 1)
+ key->u.v1.type = grub_cpu_to_le32 (type);
+ else
+ key->u.v2.offset_type
+ = ((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);
+}
+
+/* -1 if key 1 if lower than key 2.
+ 0 if key 1 is equal to key 2.
+ 1 if key 1 is higher than key 2. */
+static int
+grub_reiserfs_compare_keys (const struct grub_reiserfs_key *key1,
+ const struct grub_reiserfs_key *key2)
+{
+ grub_uint64_t offset1, offset2;
+ enum grub_reiserfs_item_type type1, type2;
+ grub_uint32_t id1, id2;
+
+ if (! key1 || ! key2)
+ return -2;
+
+ id1 = grub_le_to_cpu32 (key1->directory_id);
+ id2 = grub_le_to_cpu32 (key2->directory_id);
+ if (id1 < id2)
+ return -1;
+ if (id1 > id2)
+ return 1;
+
+ id1 = grub_le_to_cpu32 (key1->object_id);
+ id2 = grub_le_to_cpu32 (key2->object_id);
+ if (id1 < id2)
+ return -1;
+ if (id1 > id2)
+ return 1;
+
+ offset1 = grub_reiserfs_get_key_offset (key1);
+ offset2 = grub_reiserfs_get_key_offset (key2);
+ if (offset1 < offset2)
+ return -1;
+ if (offset1 > offset2)
+ return 1;
+
+ type1 = grub_reiserfs_get_key_type (key1);
+ type2 = grub_reiserfs_get_key_type (key2);
+ if ((type1 == GRUB_REISERFS_ANY
+ && (type2 == GRUB_REISERFS_DIRECT
+ || type2 == GRUB_REISERFS_INDIRECT))
+ || (type2 == GRUB_REISERFS_ANY
+ && (type1 == GRUB_REISERFS_DIRECT
+ || type1 == GRUB_REISERFS_INDIRECT)))
+ return 0;
+ if (type1 < type2)
+ return -1;
+ if (type1 > type2)
+ return 1;
+
+ return 0;
+}
+
+/* Find the item identified by KEY in mounted filesystem DATA, and fill ITEM
+ accordingly to what was found. */
+static grub_err_t
+grub_reiserfs_get_item (struct grub_reiserfs_data *data,
+ const struct grub_reiserfs_key *key,
+ struct grub_fshelp_node *item, int exact)
+{
+ grub_uint32_t block_number;
+ struct grub_reiserfs_block_header *block_header = 0;
+ struct grub_reiserfs_key *block_key = 0;
+ grub_uint16_t block_size, item_count, current_level;
+ grub_uint16_t i;
+ grub_uint16_t previous_level = ~0;
+ struct grub_reiserfs_item_header *item_headers = 0;
+
+#if 0
+ if (! data)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "data is NULL");
+ goto fail;
+ }
+
+ if (! key)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "key is NULL");
+ goto fail;
+ }
+
+ if (! item)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "item is NULL");
+ goto fail;
+ }
+#endif
+
+ block_size = grub_le_to_cpu16 (data->superblock.block_size);
+ block_number = grub_le_to_cpu32 (data->superblock.root_block);
+#ifdef GRUB_REISERFS_DEBUG
+ grub_printf("Searching for ");
+ grub_reiserfs_print_key (key);
+#endif
+ block_header = grub_malloc (block_size);
+ if (! block_header)
+ goto fail;
+
+ item->next_offset = 0;
+ do
+ {
+ grub_disk_read (data->disk,
+ block_number * (block_size >> GRUB_DISK_SECTOR_BITS),
+ (((grub_off_t) block_number * block_size)
+ & (GRUB_DISK_SECTOR_SIZE - 1)),
+ block_size, block_header);
+ if (grub_errno)
+ goto fail;
+ current_level = grub_le_to_cpu16 (block_header->level);
+ grub_dprintf ("reiserfs_tree", " at level %d\n", current_level);
+ if (current_level >= previous_level)
+ {
+ grub_dprintf ("reiserfs_tree", "level loop detected, aborting\n");
+ grub_error (GRUB_ERR_BAD_FS, "level loop");
+ goto fail;
+ }
+ previous_level = current_level;
+ item_count = grub_le_to_cpu16 (block_header->item_count);
+ grub_dprintf ("reiserfs_tree", " number of contained items : %d\n",
+ item_count);
+ if (current_level > 1)
+ {
+ /* Internal node. Navigate to the child that should contain
+ the searched key. */
+ struct grub_reiserfs_key *keys
+ = (struct grub_reiserfs_key *) (block_header + 1);
+ struct grub_reiserfs_disk_child *children
+ = ((struct grub_reiserfs_disk_child *)
+ (keys + item_count));
+
+ for (i = 0;
+ i < item_count
+ && grub_reiserfs_compare_keys (key, &(keys[i])) >= 0;
+ i++)
+ {
+#ifdef GRUB_REISERFS_DEBUG
+ grub_printf("i %03d/%03d ", i + 1, item_count + 1);
+ grub_reiserfs_print_key (&(keys[i]));
+#endif
+ }
+ block_number = grub_le_to_cpu32 (children[i].block_number);
+ if ((i < item_count) && (key->directory_id == keys[i].directory_id)
+ && (key->object_id == keys[i].object_id))
+ item->next_offset = grub_reiserfs_get_key_offset(&(keys[i]));
+#ifdef GRUB_REISERFS_DEBUG
+ if (i == item_count
+ || grub_reiserfs_compare_keys (key, &(keys[i])) == 0)
+ grub_printf(">");
+ else
+ grub_printf("<");
+ if (i < item_count)
+ {
+ grub_printf (" %03d/%03d ", i + 1, item_count + 1);
+ grub_reiserfs_print_key (&(keys[i]));
+ if (i + 1 < item_count)
+ {
+ grub_printf ("+ %03d/%03d ", i + 2, item_count);
+ grub_reiserfs_print_key (&(keys[i + 1]));
+ }
+ }
+ else
+ grub_printf ("Accessing rightmost child at block %d.\n",
+ block_number);
+#endif
+ }
+ else
+ {
+ /* Leaf node. Check that the key is actually present. */
+ item_headers
+ = (struct grub_reiserfs_item_header *) (block_header + 1);
+ for (i = 0;
+ i < item_count;
+ i++)
+ {
+ int val;
+ val = grub_reiserfs_compare_keys (key, &(item_headers[i].key));
+ if (val == 0)
+ {
+ block_key = &(item_headers[i].key);
+ break;
+ }
+ if (val < 0 && exact)
+ break;
+ if (val < 0)
+ {
+ if (i == 0)
+ {
+ grub_error (GRUB_ERR_READ_ERROR, "unexpected btree node");
+ goto fail;
+ }
+ i--;
+ block_key = &(item_headers[i].key);
+ break;
+ }
+ }
+ if (!exact && i == item_count)
+ {
+ if (i == 0)
+ {
+ grub_error (GRUB_ERR_READ_ERROR, "unexpected btree node");
+ goto fail;
+ }
+ i--;
+ block_key = &(item_headers[i].key);
+ }
+ }
+ }
+ while (current_level > 1);
+
+ item->data = data;
+
+ if (!block_key)
+ {
+ item->block_number = 0;
+ item->block_position = 0;
+ item->type = GRUB_REISERFS_UNKNOWN;
+#ifdef GRUB_REISERFS_DEBUG
+ grub_printf("Not found.\n");
+#endif
+ }
+ else
+ {
+ item->block_number = block_number;
+ item->block_position = i;
+ item->type = grub_reiserfs_get_key_type (block_key);
+ grub_memcpy (&(item->header), &(item_headers[i]),
+ sizeof (struct grub_reiserfs_item_header));
+#ifdef GRUB_REISERFS_DEBUG
+ grub_printf ("F %03d/%03d ", i + 1, item_count);
+ grub_reiserfs_print_key (block_key);
+#endif
+ }
+
+ assert (grub_errno == GRUB_ERR_NONE);
+ grub_free (block_header);
+ return GRUB_ERR_NONE;
+
+ fail:
+ assert (grub_errno != GRUB_ERR_NONE);
+ grub_free (block_header);
+ assert (grub_errno != GRUB_ERR_NONE);
+ return grub_errno;
+}
+
+/* Return the path of the file which is pointed at by symlink NODE. */
+static char *
+grub_reiserfs_read_symlink (grub_fshelp_node_t node)
+{
+ char *symlink_buffer = 0;
+ grub_size_t len = node->size;
+ grub_ssize_t ret;
+
+ symlink_buffer = grub_malloc (len + 1);
+ if (! symlink_buffer)
+ return 0;
+
+ ret = grub_reiserfs_read_real (node, 0, symlink_buffer, len, 0, 0);
+ if (ret < 0)
+ {
+ grub_free (symlink_buffer);
+ return 0;
+ }
+
+ symlink_buffer[ret] = 0;
+ return symlink_buffer;
+}
+
+/* Fill the mounted filesystem structure and return it. */
+static struct grub_reiserfs_data *
+grub_reiserfs_mount (grub_disk_t disk)
+{
+ struct grub_reiserfs_data *data = 0;
+ data = grub_malloc (sizeof (*data));
+ if (! data)
+ goto fail;
+ grub_disk_read (disk, REISERFS_SUPER_BLOCK_OFFSET / GRUB_DISK_SECTOR_SIZE,
+ 0, sizeof (data->superblock), &(data->superblock));
+ if (grub_errno)
+ goto fail;
+ if (grub_memcmp (data->superblock.magic_string,
+ REISERFS_MAGIC_STRING, sizeof (REISERFS_MAGIC_STRING) - 1))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not a ReiserFS filesystem");
+ goto fail;
+ }
+ data->disk = disk;
+ return data;
+
+ fail:
+ /* Disk is too small to contain a ReiserFS. */
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not a ReiserFS filesystem");
+
+ grub_free (data);
+ return 0;
+}
+
+/* Call HOOK for each file in directory ITEM. */
+static int
+grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
+ grub_fshelp_iterate_dir_hook_t hook,
+ void *hook_data)
+{
+ struct grub_reiserfs_data *data = item->data;
+ struct grub_reiserfs_block_header *block_header = 0;
+ grub_uint16_t block_size, block_position;
+ grub_uint32_t block_number;
+ grub_uint64_t next_offset = item->next_offset;
+ int ret = 0;
+
+ if (item->type != GRUB_REISERFS_DIRECTORY)
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+ goto fail;
+ }
+ block_size = grub_le_to_cpu16 (data->superblock.block_size);
+ block_header = grub_malloc (block_size + 1);
+ if (! block_header)
+ goto fail;
+ block_number = item->block_number;
+ block_position = item->block_position;
+ grub_dprintf ("reiserfs", "Iterating directory...\n");
+ do
+ {
+ struct grub_reiserfs_directory_header *directory_headers;
+ struct grub_fshelp_node directory_item;
+ grub_uint16_t entry_count, entry_number;
+ struct grub_reiserfs_item_header *item_headers;
+
+ grub_disk_read (data->disk,
+ block_number * (block_size >> GRUB_DISK_SECTOR_BITS),
+ (((grub_off_t) block_number * block_size)
+ & (GRUB_DISK_SECTOR_SIZE - 1)),
+ block_size, (char *) block_header);
+ if (grub_errno)
+ goto fail;
+
+ ((char *) block_header)[block_size] = 0;
+
+#if 0
+ if (grub_le_to_cpu16 (block_header->level) != 1)
+ {
+ grub_error (GRUB_ERR_BAD_FS,
+ "reiserfs: block %d is not a leaf block",
+ block_number);
+ goto fail;
+ }
+#endif
+
+ item_headers = (struct grub_reiserfs_item_header *) (block_header + 1);
+ directory_headers
+ = ((struct grub_reiserfs_directory_header *)
+ ((char *) block_header
+ + grub_le_to_cpu16 (item_headers[block_position].item_location)));
+ entry_count
+ = grub_le_to_cpu16 (item_headers[block_position].u.entry_count);
+ for (entry_number = 0; entry_number < entry_count; entry_number++)
+ {
+ struct grub_reiserfs_directory_header *directory_header
+ = &directory_headers[entry_number];
+ grub_uint16_t entry_state
+ = grub_le_to_cpu16 (directory_header->state);
+ grub_fshelp_node_t entry_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;
+ grub_reiserfs_set_key_type (&entry_key, GRUB_REISERFS_DIRECTORY,
+ 2);
+ grub_reiserfs_set_key_offset (&entry_key, 1);
+
+ entry_item = grub_malloc (sizeof (*entry_item));
+ if (! entry_item)
+ goto fail;
+
+ if (grub_reiserfs_get_item (data, &entry_key, entry_item, 1)
+ != GRUB_ERR_NONE)
+ {
+ grub_free (entry_item);
+ goto fail;
+ }
+
+ if (entry_item->type == GRUB_REISERFS_DIRECTORY)
+ entry_type = GRUB_FSHELP_DIR;
+ else
+ {
+ grub_uint32_t entry_block_number;
+ /* Order is very important here.
+ First set the offset to 0 using current key version.
+ Then change the key type, which affects key version
+ detection. */
+ grub_reiserfs_set_key_offset (&entry_key, 0);
+ grub_reiserfs_set_key_type (&entry_key, GRUB_REISERFS_STAT,
+ 2);
+ if (grub_reiserfs_get_item (data, &entry_key, entry_item, 1)
+ != GRUB_ERR_NONE)
+ {
+ grub_free (entry_item);
+ goto fail;
+ }
+
+ if (entry_item->block_number != 0)
+ {
+ grub_uint16_t entry_version;
+ entry_version
+ = grub_le_to_cpu16 (entry_item->header.version);
+ entry_block_number = entry_item->block_number;
+#if 0
+ grub_dprintf ("reiserfs",
+ "version %04x block %08x (%08x) position %08x\n",
+ entry_version, entry_block_number,
+ ((grub_disk_addr_t) entry_block_number * block_size) / GRUB_DISK_SECTOR_SIZE,
+ grub_le_to_cpu16 (entry_item->header.item_location));
+#endif
+ if (entry_version == 0) /* Version 1 stat item. */
+ {
+ struct grub_reiserfs_stat_item_v1 entry_v1_stat;
+ grub_disk_read (data->disk,
+ entry_block_number * (block_size >> GRUB_DISK_SECTOR_BITS),
+ grub_le_to_cpu16 (entry_item->header.item_location),
+ sizeof (entry_v1_stat),
+ (char *) &entry_v1_stat);
+ if (grub_errno)
+ goto fail;
+#if 0
+ grub_dprintf ("reiserfs",
+ "%04x %04x %04x %04x %08x %08x | %08x %08x %08x %08x\n",
+ grub_le_to_cpu16 (entry_v1_stat.mode),
+ grub_le_to_cpu16 (entry_v1_stat.hardlink_count),
+ grub_le_to_cpu16 (entry_v1_stat.uid),
+ grub_le_to_cpu16 (entry_v1_stat.gid),
+ grub_le_to_cpu32 (entry_v1_stat.size),
+ grub_le_to_cpu32 (entry_v1_stat.atime),
+ grub_le_to_cpu32 (entry_v1_stat.mtime),
+ grub_le_to_cpu32 (entry_v1_stat.ctime),
+ grub_le_to_cpu32 (entry_v1_stat.rdev),
+ grub_le_to_cpu32 (entry_v1_stat.first_direct_byte));
+ grub_dprintf ("reiserfs",
+ "%04x %04x %04x %04x %08x %08x | %08x %08x %08x %08x\n",
+ entry_v1_stat.mode,
+ entry_v1_stat.hardlink_count,
+ entry_v1_stat.uid,
+ entry_v1_stat.gid,
+ entry_v1_stat.size,
+ entry_v1_stat.atime,
+ entry_v1_stat.mtime,
+ entry_v1_stat.ctime,
+ entry_v1_stat.rdev,
+ entry_v1_stat.first_direct_byte);
+#endif
+ entry_item->mtime = grub_le_to_cpu32 (entry_v1_stat.mtime);
+ if ((grub_le_to_cpu16 (entry_v1_stat.mode) & S_IFLNK)
+ == S_IFLNK)
+ entry_type = GRUB_FSHELP_SYMLINK;
+ else
+ entry_type = GRUB_FSHELP_REG;
+ entry_item->size = (grub_off_t) grub_le_to_cpu32 (entry_v1_stat.size);
+ }
+ else
+ {
+ struct grub_reiserfs_stat_item_v2 entry_v2_stat;
+ grub_disk_read (data->disk,
+ entry_block_number * (block_size >> GRUB_DISK_SECTOR_BITS),
+ grub_le_to_cpu16 (entry_item->header.item_location),
+ sizeof (entry_v2_stat),
+ (char *) &entry_v2_stat);
+ if (grub_errno)
+ goto fail;
+#if 0
+ grub_dprintf ("reiserfs",
+ "%04x %04x %08x %08x%08x | %08x %08x %08x %08x | %08x %08x %08x\n",
+ grub_le_to_cpu16 (entry_v2_stat.mode),
+ grub_le_to_cpu16 (entry_v2_stat.reserved),
+ grub_le_to_cpu32 (entry_v2_stat.hardlink_count),
+ (unsigned int) (grub_le_to_cpu64 (entry_v2_stat.size) >> 32),
+ (unsigned int) (grub_le_to_cpu64 (entry_v2_stat.size) && 0xFFFFFFFF),
+ grub_le_to_cpu32 (entry_v2_stat.uid),
+ grub_le_to_cpu32 (entry_v2_stat.gid),
+ grub_le_to_cpu32 (entry_v2_stat.atime),
+ grub_le_to_cpu32 (entry_v2_stat.mtime),
+ grub_le_to_cpu32 (entry_v2_stat.ctime),
+ grub_le_to_cpu32 (entry_v2_stat.blocks),
+ grub_le_to_cpu32 (entry_v2_stat.first_direct_byte));
+ grub_dprintf ("reiserfs",
+ "%04x %04x %08x %08x%08x | %08x %08x %08x %08x | %08x %08x %08x\n",
+ entry_v2_stat.mode,
+ entry_v2_stat.reserved,
+ entry_v2_stat.hardlink_count,
+ (unsigned int) (entry_v2_stat.size >> 32),
+ (unsigned int) (entry_v2_stat.size && 0xFFFFFFFF),
+ entry_v2_stat.uid,
+ entry_v2_stat.gid,
+ entry_v2_stat.atime,
+ entry_v2_stat.mtime,
+ entry_v2_stat.ctime,
+ entry_v2_stat.blocks,
+ entry_v2_stat.first_direct_byte);
+#endif
+ entry_item->mtime = grub_le_to_cpu32 (entry_v2_stat.mtime);
+ entry_item->size = (grub_off_t) grub_le_to_cpu64 (entry_v2_stat.size);
+ if ((grub_le_to_cpu16 (entry_v2_stat.mode) & S_IFLNK)
+ == S_IFLNK)
+ entry_type = GRUB_FSHELP_SYMLINK;
+ else
+ entry_type = GRUB_FSHELP_REG;
+ }
+ }
+ else
+ {
+ /* Pseudo file ".." never has stat block. */
+ 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);
+ grub_free (entry_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:
+ ;
+ }
+
+ if (next_offset == 0)
+ break;
+
+ grub_reiserfs_set_key_offset (&(item_headers[block_position].key),
+ next_offset);
+ if (grub_reiserfs_get_item (data, &(item_headers[block_position].key),
+ &directory_item, 1) != GRUB_ERR_NONE)
+ goto fail;
+ block_number = directory_item.block_number;
+ block_position = directory_item.block_position;
+ next_offset = directory_item.next_offset;
+ }
+ while (block_number);
+
+ found:
+ assert (grub_errno == GRUB_ERR_NONE);
+ grub_free (block_header);
+ return ret;
+ fail:
+ assert (grub_errno != GRUB_ERR_NONE);
+ grub_free (block_header);
+ return 0;
+}
+
+/****************************************************************************/
+/* grub api functions */
+/****************************************************************************/
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_reiserfs_open (struct grub_file *file, const char *name)
+{
+ struct grub_reiserfs_data *data = 0;
+ struct grub_fshelp_node root, *found = 0;
+ struct grub_reiserfs_key key;
+
+ grub_dl_ref (my_mod);
+ data = grub_reiserfs_mount (file->device->disk);
+ if (! data)
+ goto fail;
+ 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);
+ if (grub_reiserfs_get_item (data, &key, &root, 1) != GRUB_ERR_NONE)
+ goto fail;
+ if (root.block_number == 0)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "unable to find root item");
+ goto fail; /* Should never happen since checked at mount. */
+ }
+ grub_fshelp_find_file (name, &root, &found,
+ grub_reiserfs_iterate_dir,
+ grub_reiserfs_read_symlink, GRUB_FSHELP_REG);
+ if (grub_errno)
+ goto fail;
+ file->size = found->size;
+
+ grub_dprintf ("reiserfs", "file size : %d (%08x%08x)\n",
+ (unsigned int) file->size,
+ (unsigned int) (file->size >> 32), (unsigned int) file->size);
+ file->offset = 0;
+ file->data = found;
+ return GRUB_ERR_NONE;
+
+ fail:
+ assert (grub_errno != GRUB_ERR_NONE);
+ if (found != &root)
+ grub_free (found);
+ grub_free (data);
+ grub_dl_unref (my_mod);
+ return grub_errno;
+}
+
+static grub_ssize_t
+grub_reiserfs_read_real (struct grub_fshelp_node *node,
+ grub_off_t off, char *buf, grub_size_t len,
+ grub_disk_read_hook_t read_hook, void *read_hook_data)
+{
+ unsigned int indirect_block, indirect_block_count;
+ struct grub_reiserfs_key key;
+ struct grub_reiserfs_data *data = node->data;
+ struct grub_fshelp_node found;
+ grub_uint16_t block_size = grub_le_to_cpu16 (data->superblock.block_size);
+ grub_uint16_t item_size;
+ grub_uint32_t *indirect_block_ptr = 0;
+ grub_uint64_t current_key_offset = 1;
+ grub_off_t initial_position, current_position, final_position, length;
+ grub_disk_addr_t block;
+ grub_off_t offset;
+
+ key.directory_id = node->header.key.directory_id;
+ key.object_id = node->header.key.object_id;
+ key.u.v2.offset_type = 0;
+ grub_reiserfs_set_key_type (&key, GRUB_REISERFS_ANY, 2);
+ initial_position = off;
+ current_position = 0;
+ final_position = MIN (len + initial_position, node->size);
+ grub_dprintf ("reiserfs",
+ "Reading from %lld to %lld (%lld instead of requested %ld)\n",
+ (unsigned long long) initial_position,
+ (unsigned long long) final_position,
+ (unsigned long long) (final_position - initial_position),
+ (unsigned long) len);
+
+ grub_reiserfs_set_key_offset (&key, initial_position + 1);
+
+ if (grub_reiserfs_get_item (data, &key, &found, 0) != GRUB_ERR_NONE)
+ goto fail;
+
+ if (found.block_number == 0)
+ {
+ grub_error (GRUB_ERR_READ_ERROR, "offset %lld not found",
+ (unsigned long long) initial_position);
+ goto fail;
+ }
+
+ current_key_offset = grub_reiserfs_get_key_offset (&found.header.key);
+ current_position = current_key_offset - 1;
+
+ while (current_position < final_position)
+ {
+ grub_reiserfs_set_key_offset (&key, current_key_offset);
+
+ if (grub_reiserfs_get_item (data, &key, &found, 1) != GRUB_ERR_NONE)
+ goto fail;
+ if (found.block_number == 0)
+ goto fail;
+ item_size = grub_le_to_cpu16 (found.header.item_size);
+ switch (found.type)
+ {
+ case GRUB_REISERFS_DIRECT:
+ 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)
+ {
+ offset = MAX ((signed) (initial_position - current_position), 0);
+ length = (MIN (item_size, final_position - current_position)
+ - offset);
+ grub_dprintf ("reiserfs",
+ "Reading direct block %u from %u to %u...\n",
+ (unsigned) block, (unsigned) offset,
+ (unsigned) (offset + length));
+ found.data->disk->read_hook = read_hook;
+ found.data->disk->read_hook_data = read_hook_data;
+ grub_disk_read (found.data->disk,
+ block,
+ offset
+ + grub_le_to_cpu16 (found.header.item_location),
+ length, buf);
+ found.data->disk->read_hook = 0;
+ if (grub_errno)
+ goto fail;
+ buf += length;
+ current_position += offset + length;
+ }
+ else
+ current_position += item_size;
+ break;
+ case GRUB_REISERFS_INDIRECT:
+ indirect_block_count = item_size / sizeof (*indirect_block_ptr);
+ indirect_block_ptr = grub_malloc (item_size);
+ if (! indirect_block_ptr)
+ goto fail;
+ grub_disk_read (found.data->disk,
+ found.block_number * (block_size >> GRUB_DISK_SECTOR_BITS),
+ grub_le_to_cpu16 (found.header.item_location),
+ item_size, indirect_block_ptr);
+ if (grub_errno)
+ goto fail;
+ found.data->disk->read_hook = read_hook;
+ found.data->disk->read_hook_data = read_hook_data;
+ for (indirect_block = 0;
+ indirect_block < indirect_block_count
+ && current_position < final_position;
+ indirect_block++)
+ {
+ block = grub_le_to_cpu32 (indirect_block_ptr[indirect_block]) *
+ (block_size >> GRUB_DISK_SECTOR_BITS);
+ grub_dprintf ("reiserfs_blocktype", "I: %u\n", (unsigned) block);
+ if (current_position + block_size >= initial_position)
+ {
+ offset = MAX ((signed) (initial_position - current_position),
+ 0);
+ length = (MIN (block_size, final_position - current_position)
+ - offset);
+ grub_dprintf ("reiserfs",
+ "Reading indirect block %u from %u to %u...\n",
+ (unsigned) block, (unsigned) offset,
+ (unsigned) (offset + length));
+#if 0
+ grub_dprintf ("reiserfs",
+ "\nib=%04d/%04d, ip=%d, cp=%d, fp=%d, off=%d, l=%d, tl=%d\n",
+ indirect_block + 1, indirect_block_count,
+ initial_position, current_position,
+ final_position, offset, length, len);
+#endif
+ grub_disk_read (found.data->disk, block, offset, length, buf);
+ if (grub_errno)
+ goto fail;
+ buf += length;
+ current_position += offset + length;
+ }
+ else
+ current_position += block_size;
+ }
+ found.data->disk->read_hook = 0;
+ grub_free (indirect_block_ptr);
+ indirect_block_ptr = 0;
+ break;
+ default:
+ goto fail;
+ }
+ current_key_offset = current_position + 1;
+ }
+
+ grub_dprintf ("reiserfs",
+ "Have successfully read %lld bytes (%ld requested)\n",
+ (unsigned long long) (current_position - initial_position),
+ (unsigned long) len);
+ return current_position - initial_position;
+
+#if 0
+ switch (found.type)
+ {
+ case GRUB_REISERFS_DIRECT:
+ read_length = MIN (len, item_size - file->offset);
+ grub_disk_read (found.data->disk,
+ (found.block_number * block_size) / GRUB_DISK_SECTOR_SIZE,
+ grub_le_to_cpu16 (found.header.item_location) + file->offset,
+ read_length, buf);
+ if (grub_errno)
+ goto fail;
+ break;
+ case GRUB_REISERFS_INDIRECT:
+ indirect_block_count = item_size / sizeof (*indirect_block_ptr);
+ indirect_block_ptr = grub_malloc (item_size);
+ if (!indirect_block_ptr)
+ goto fail;
+ grub_disk_read (found.data->disk,
+ (found.block_number * block_size) / GRUB_DISK_SECTOR_SIZE,
+ grub_le_to_cpu16 (found.header.item_location),
+ item_size, (char *) indirect_block_ptr);
+ if (grub_errno)
+ goto fail;
+ len = MIN (len, file->size - file->offset);
+ for (indirect_block = file->offset / block_size;
+ indirect_block < indirect_block_count && read_length < len;
+ indirect_block++)
+ {
+ read = MIN (block_size, len - read_length);
+ grub_disk_read (found.data->disk,
+ (grub_le_to_cpu32 (indirect_block_ptr[indirect_block]) * block_size) / GRUB_DISK_SECTOR_SIZE,
+ file->offset % block_size, read,
+ ((void *) buf) + read_length);
+ if (grub_errno)
+ goto fail;
+ read_length += read;
+ }
+ grub_free (indirect_block_ptr);
+ break;
+ default:
+ goto fail;
+ }
+
+ return read_length;
+#endif
+
+ fail:
+ grub_free (indirect_block_ptr);
+ return -1;
+}
+
+static grub_ssize_t
+grub_reiserfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ return grub_reiserfs_read_real (file->data, file->offset, buf, len,
+ file->read_hook, file->read_hook_data);
+}
+
+/* Close the file FILE. */
+static grub_err_t
+grub_reiserfs_close (grub_file_t file)
+{
+ struct grub_fshelp_node *node = file->data;
+ struct grub_reiserfs_data *data = node->data;
+
+ grub_free (data);
+ grub_free (node);
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+/* Context for grub_reiserfs_dir. */
+struct grub_reiserfs_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_reiserfs_dir. */
+static int
+grub_reiserfs_dir_iter (const char *filename,
+ enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_reiserfs_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ info.mtimeset = 1;
+ info.mtime = node->mtime;
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+/* Call HOOK with each file under DIR. */
+static grub_err_t
+grub_reiserfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_reiserfs_dir_ctx ctx = { hook, hook_data };
+ struct grub_reiserfs_data *data = 0;
+ struct grub_fshelp_node root, *found;
+ struct grub_reiserfs_key root_key;
+
+ grub_dl_ref (my_mod);
+ data = grub_reiserfs_mount (device->disk);
+ if (! data)
+ goto fail;
+ 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);
+ if (grub_reiserfs_get_item (data, &root_key, &root, 1) != GRUB_ERR_NONE)
+ goto fail;
+ if (root.block_number == 0)
+ {
+ grub_error(GRUB_ERR_BAD_FS, "root not found");
+ goto fail;
+ }
+ grub_fshelp_find_file (path, &root, &found, grub_reiserfs_iterate_dir,
+ grub_reiserfs_read_symlink, GRUB_FSHELP_DIR);
+ if (grub_errno)
+ goto fail;
+ grub_reiserfs_iterate_dir (found, grub_reiserfs_dir_iter, &ctx);
+ grub_free (data);
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+
+ fail:
+ grub_free (data);
+ grub_dl_unref (my_mod);
+ return grub_errno;
+}
+
+/* Return the label of the device DEVICE in LABEL. The label is
+ returned in a grub_malloc'ed buffer and should be freed by the
+ caller. */
+static grub_err_t
+grub_reiserfs_label (grub_device_t device, char **label)
+{
+ struct grub_reiserfs_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_reiserfs_mount (disk);
+ if (data)
+ {
+ *label = grub_strndup (data->superblock.label,
+ sizeof (data->superblock.label));
+ }
+ else
+ *label = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_reiserfs_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_reiserfs_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ *uuid = NULL;
+ data = grub_reiserfs_mount (disk);
+ if (data)
+ {
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE (data->superblock.uuid); i++)
+ if (data->superblock.uuid[i])
+ break;
+ if (i < ARRAY_SIZE (data->superblock.uuid))
+ *uuid = grub_xasprintf ("%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
+ grub_be_to_cpu16 (data->superblock.uuid[0]),
+ grub_be_to_cpu16 (data->superblock.uuid[1]),
+ grub_be_to_cpu16 (data->superblock.uuid[2]),
+ grub_be_to_cpu16 (data->superblock.uuid[3]),
+ grub_be_to_cpu16 (data->superblock.uuid[4]),
+ grub_be_to_cpu16 (data->superblock.uuid[5]),
+ grub_be_to_cpu16 (data->superblock.uuid[6]),
+ grub_be_to_cpu16 (data->superblock.uuid[7]));
+ }
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static struct grub_fs grub_reiserfs_fs =
+ {
+ .name = "reiserfs",
+ .fs_dir = grub_reiserfs_dir,
+ .fs_open = grub_reiserfs_open,
+ .fs_read = grub_reiserfs_read,
+ .fs_close = grub_reiserfs_close,
+ .fs_label = grub_reiserfs_label,
+ .fs_uuid = grub_reiserfs_uuid,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(reiserfs)
+{
+ grub_fs_register (&grub_reiserfs_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(reiserfs)
+{
+ grub_fs_unregister (&grub_reiserfs_fs);
+}
diff --git a/grub-core/fs/romfs.c b/grub-core/fs/romfs.c
new file mode 100644
index 0000000..d97b8fb
--- /dev/null
+++ b/grub-core/fs/romfs.c
@@ -0,0 +1,484 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/file.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/disk.h>
+#include <grub/fs.h>
+#include <grub/fshelp.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_romfs_superblock
+{
+ char magic[8];
+#define GRUB_ROMFS_MAGIC "-rom1fs-"
+ grub_uint32_t total_size;
+ grub_uint32_t chksum;
+ char label[0];
+};
+
+struct grub_romfs_file_header
+{
+ grub_uint32_t next_file;
+ grub_uint32_t spec;
+ grub_uint32_t size;
+ grub_uint32_t chksum;
+ char name[0];
+};
+
+struct grub_romfs_data
+{
+ grub_disk_addr_t first_file;
+ grub_disk_t disk;
+};
+
+struct grub_fshelp_node
+{
+ grub_disk_addr_t addr;
+ struct grub_romfs_data *data;
+ grub_disk_addr_t data_addr;
+ /* Not filled for root. */
+ struct grub_romfs_file_header file;
+};
+
+#define GRUB_ROMFS_ALIGN 16
+#define GRUB_ROMFS_TYPE_MASK 7
+#define GRUB_ROMFS_TYPE_HARDLINK 0
+#define GRUB_ROMFS_TYPE_DIRECTORY 1
+#define GRUB_ROMFS_TYPE_REGULAR 2
+#define GRUB_ROMFS_TYPE_SYMLINK 3
+
+static grub_err_t
+do_checksum (void *in, grub_size_t insize)
+{
+ grub_uint32_t *a = in;
+ grub_size_t sz = insize / 4;
+ grub_uint32_t *b = a + sz;
+ grub_uint32_t csum = 0;
+
+ while (a < b)
+ csum += grub_be_to_cpu32 (*a++);
+ if (csum)
+ return grub_error (GRUB_ERR_BAD_FS, "invalid checksum");
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_romfs_data *
+grub_romfs_mount (grub_device_t dev)
+{
+ union {
+ struct grub_romfs_superblock sb;
+ char d[512];
+ } sb;
+ grub_err_t err;
+ char *ptr;
+ grub_disk_addr_t sec = 0;
+ struct grub_romfs_data *data;
+ if (!dev->disk)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not a disk");
+ return NULL;
+ }
+ err = grub_disk_read (dev->disk, 0, 0, sizeof (sb), &sb);
+ if (err == GRUB_ERR_OUT_OF_RANGE)
+ err = grub_errno = GRUB_ERR_BAD_FS;
+ if (err)
+ return NULL;
+ if (grub_be_to_cpu32 (sb.sb.total_size) < sizeof (sb))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "too short filesystem");
+ return NULL;
+ }
+ if (grub_memcmp (sb.sb.magic, GRUB_ROMFS_MAGIC,
+ sizeof (sb.sb.magic)) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not romfs");
+ return NULL;
+ }
+ err = do_checksum (&sb, sizeof (sb) < grub_be_to_cpu32 (sb.sb.total_size) ?
+ sizeof (sb) : grub_be_to_cpu32 (sb.sb.total_size));
+ if (err)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "checksum incorrect");
+ return NULL;
+ }
+ for (ptr = sb.sb.label; (void *) ptr < (void *) (&sb + 1)
+ && ptr - sb.d < (grub_ssize_t) grub_be_to_cpu32 (sb.sb.total_size); ptr++)
+ if (!*ptr)
+ break;
+ while ((void *) ptr == &sb + 1)
+ {
+ sec++;
+ err = grub_disk_read (dev->disk, sec, 0, sizeof (sb), &sb);
+ if (err == GRUB_ERR_OUT_OF_RANGE)
+ err = grub_errno = GRUB_ERR_BAD_FS;
+ if (err)
+ return NULL;
+ for (ptr = sb.d; (void *) ptr < (void *) (&sb + 1)
+ && (ptr - sb.d + (sec << GRUB_DISK_SECTOR_BITS)
+ < grub_be_to_cpu32 (sb.sb.total_size));
+ ptr++)
+ if (!*ptr)
+ break;
+ }
+ data = grub_malloc (sizeof (*data));
+ if (!data)
+ return NULL;
+ data->first_file = ALIGN_UP (ptr + 1 - sb.d, GRUB_ROMFS_ALIGN)
+ + (sec << GRUB_DISK_SECTOR_BITS);
+ data->disk = dev->disk;
+ return data;
+}
+
+static char *
+grub_romfs_read_symlink (grub_fshelp_node_t node)
+{
+ char *ret;
+ grub_err_t err;
+ ret = grub_malloc (grub_be_to_cpu32 (node->file.size) + 1);
+ if (!ret)
+ return NULL;
+ err = grub_disk_read (node->data->disk,
+ (node->data_addr) >> GRUB_DISK_SECTOR_BITS,
+ (node->data_addr) & (GRUB_DISK_SECTOR_SIZE - 1),
+ grub_be_to_cpu32 (node->file.size), ret);
+ if (err)
+ {
+ grub_free (ret);
+ return NULL;
+ }
+ ret[grub_be_to_cpu32 (node->file.size)] = 0;
+ return ret;
+}
+
+static int
+grub_romfs_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ grub_disk_addr_t caddr;
+ struct grub_romfs_file_header hdr;
+ unsigned nptr;
+ unsigned i, j;
+ grub_size_t a = 0;
+ grub_properly_aligned_t *name = NULL;
+
+ for (caddr = dir->data_addr; caddr;
+ caddr = grub_be_to_cpu32 (hdr.next_file) & ~(GRUB_ROMFS_ALIGN - 1))
+ {
+ grub_disk_addr_t naddr = caddr + sizeof (hdr);
+ grub_uint32_t csum = 0;
+ enum grub_fshelp_filetype filetype = GRUB_FSHELP_UNKNOWN;
+ struct grub_fshelp_node *node = NULL;
+ grub_err_t err;
+
+ err = grub_disk_read (dir->data->disk, caddr >> GRUB_DISK_SECTOR_BITS,
+ caddr & (GRUB_DISK_SECTOR_SIZE - 1),
+ sizeof (hdr), &hdr);
+ if (err)
+ {
+ grub_free (name);
+ return 1;
+ }
+ for (nptr = 0; ; nptr++, naddr += 16)
+ {
+ if (a <= nptr)
+ {
+ grub_properly_aligned_t *on;
+ a = 2 * (nptr + 1);
+ on = name;
+ name = grub_realloc (name, a * 16);
+ if (!name)
+ {
+ grub_free (on);
+ return 1;
+ }
+ }
+ COMPILE_TIME_ASSERT (16 % sizeof (name[0]) == 0);
+ err = grub_disk_read (dir->data->disk, naddr >> GRUB_DISK_SECTOR_BITS,
+ naddr & (GRUB_DISK_SECTOR_SIZE - 1),
+ 16, name + (16 / sizeof (name[0])) * nptr);
+ if (err)
+ return 1;
+ for (j = 0; j < 16; j++)
+ if (!((char *) name)[16 * nptr + j])
+ break;
+ if (j != 16)
+ break;
+ }
+ for (i = 0; i < sizeof (hdr) / sizeof (grub_uint32_t); i++)
+ csum += grub_be_to_cpu32 (((grub_uint32_t *) &hdr)[i]);
+ for (i = 0; i < (nptr + 1) * 4; i++)
+ csum += grub_be_to_cpu32 (((grub_uint32_t *) name)[i]);
+ if (csum != 0)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid checksum");
+ grub_free (name);
+ return 1;
+ }
+ node = grub_malloc (sizeof (*node));
+ if (!node)
+ return 1;
+ node->addr = caddr;
+ node->data_addr = caddr + (nptr + 1) * 16 + sizeof (hdr);
+ node->data = dir->data;
+ node->file = hdr;
+ switch (grub_be_to_cpu32 (hdr.next_file) & GRUB_ROMFS_TYPE_MASK)
+ {
+ case GRUB_ROMFS_TYPE_REGULAR:
+ filetype = GRUB_FSHELP_REG;
+ break;
+ case GRUB_ROMFS_TYPE_SYMLINK:
+ filetype = GRUB_FSHELP_SYMLINK;
+ break;
+ case GRUB_ROMFS_TYPE_DIRECTORY:
+ node->data_addr = grub_be_to_cpu32 (hdr.spec);
+ filetype = GRUB_FSHELP_DIR;
+ break;
+ case GRUB_ROMFS_TYPE_HARDLINK:
+ {
+ grub_disk_addr_t laddr;
+ node->addr = laddr = grub_be_to_cpu32 (hdr.spec);
+ err = grub_disk_read (dir->data->disk,
+ laddr >> GRUB_DISK_SECTOR_BITS,
+ laddr & (GRUB_DISK_SECTOR_SIZE - 1),
+ sizeof (node->file), &node->file);
+ if (err)
+ return 1;
+ if ((grub_be_to_cpu32 (node->file.next_file) & GRUB_ROMFS_TYPE_MASK)
+ == GRUB_ROMFS_TYPE_REGULAR
+ || (grub_be_to_cpu32 (node->file.next_file)
+ & GRUB_ROMFS_TYPE_MASK) == GRUB_ROMFS_TYPE_SYMLINK)
+ {
+ laddr += sizeof (hdr);
+ while (1)
+ {
+ char buf[16];
+ err = grub_disk_read (dir->data->disk,
+ laddr >> GRUB_DISK_SECTOR_BITS,
+ laddr & (GRUB_DISK_SECTOR_SIZE - 1),
+ 16, buf);
+ if (err)
+ return 1;
+ for (i = 0; i < 16; i++)
+ if (!buf[i])
+ break;
+ if (i != 16)
+ break;
+ laddr += 16;
+ }
+ node->data_addr = laddr + 16;
+ }
+ if ((grub_be_to_cpu32 (node->file.next_file)
+ & GRUB_ROMFS_TYPE_MASK) == GRUB_ROMFS_TYPE_REGULAR)
+ filetype = GRUB_FSHELP_REG;
+ if ((grub_be_to_cpu32 (node->file.next_file)
+ & GRUB_ROMFS_TYPE_MASK) == GRUB_ROMFS_TYPE_SYMLINK)
+ filetype = GRUB_FSHELP_SYMLINK;
+ if ((grub_be_to_cpu32 (node->file.next_file) & GRUB_ROMFS_TYPE_MASK)
+ == GRUB_ROMFS_TYPE_DIRECTORY)
+ {
+ node->data_addr = grub_be_to_cpu32 (node->file.spec);
+ filetype = GRUB_FSHELP_DIR;
+ }
+
+ break;
+ }
+ }
+
+ if (hook ((char *) name, filetype, node, hook_data))
+ {
+ grub_free (name);
+ return 1;
+ }
+ }
+ grub_free (name);
+ return 0;
+}
+
+/* Context for grub_romfs_dir. */
+struct grub_romfs_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_romfs_dir. */
+static int
+grub_romfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_romfs_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_romfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_romfs_dir_ctx ctx = { hook, hook_data };
+ struct grub_romfs_data *data = 0;
+ struct grub_fshelp_node *fdiro = 0, start;
+
+ data = grub_romfs_mount (device);
+ if (! data)
+ goto fail;
+
+ start.addr = data->first_file;
+ start.data_addr = data->first_file;
+ start.data = data;
+ grub_fshelp_find_file (path, &start, &fdiro, grub_romfs_iterate_dir,
+ grub_romfs_read_symlink, GRUB_FSHELP_DIR);
+ if (grub_errno)
+ goto fail;
+
+ grub_romfs_iterate_dir (fdiro, grub_romfs_dir_iter, &ctx);
+
+ fail:
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_romfs_open (struct grub_file *file, const char *name)
+{
+ struct grub_romfs_data *data = 0;
+ struct grub_fshelp_node *fdiro = 0, start;
+
+ data = grub_romfs_mount (file->device);
+ if (! data)
+ goto fail;
+
+ start.addr = data->first_file;
+ start.data_addr = data->first_file;
+ start.data = data;
+
+ grub_fshelp_find_file (name, &start, &fdiro, grub_romfs_iterate_dir,
+ grub_romfs_read_symlink, GRUB_FSHELP_REG);
+ if (grub_errno)
+ goto fail;
+
+ file->size = grub_be_to_cpu32 (fdiro->file.size);
+ file->data = fdiro;
+ return GRUB_ERR_NONE;
+
+ fail:
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static grub_ssize_t
+grub_romfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_fshelp_node *data = file->data;
+
+ /* XXX: The file is stored in as a single extent. */
+ data->data->disk->read_hook = file->read_hook;
+ data->data->disk->read_hook_data = file->read_hook_data;
+ grub_disk_read (data->data->disk,
+ (data->data_addr + file->offset) >> GRUB_DISK_SECTOR_BITS,
+ (data->data_addr + file->offset) & (GRUB_DISK_SECTOR_SIZE - 1),
+ len, buf);
+ data->data->disk->read_hook = NULL;
+
+ if (grub_errno)
+ return -1;
+
+ return len;
+}
+
+static grub_err_t
+grub_romfs_close (grub_file_t file)
+{
+ struct grub_fshelp_node *data = file->data;
+
+ grub_free (data->data);
+ grub_free (data);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_romfs_label (grub_device_t device, char **label)
+{
+ struct grub_romfs_data *data;
+ grub_err_t err;
+
+ *label = NULL;
+
+ data = grub_romfs_mount (device);
+ if (!data)
+ return grub_errno;
+ *label = grub_malloc (data->first_file + 1
+ - sizeof (struct grub_romfs_superblock));
+ if (!*label)
+ {
+ grub_free (data);
+ return grub_errno;
+ }
+ err = grub_disk_read (device->disk, 0, sizeof (struct grub_romfs_superblock),
+ data->first_file
+ - sizeof (struct grub_romfs_superblock),
+ *label);
+ if (err)
+ {
+ grub_free (data);
+ grub_free (*label);
+ *label = NULL;
+ return err;
+ }
+ (*label)[data->first_file - sizeof (struct grub_romfs_superblock)] = 0;
+ grub_free (data);
+ return GRUB_ERR_NONE;
+}
+
+
+static struct grub_fs grub_romfs_fs =
+ {
+ .name = "romfs",
+ .fs_dir = grub_romfs_dir,
+ .fs_open = grub_romfs_open,
+ .fs_read = grub_romfs_read,
+ .fs_close = grub_romfs_close,
+ .fs_label = grub_romfs_label,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 0,
+ .blocklist_install = 0,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(romfs)
+{
+ grub_fs_register (&grub_romfs_fs);
+}
+
+GRUB_MOD_FINI(romfs)
+{
+ grub_fs_unregister (&grub_romfs_fs);
+}
diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c
new file mode 100644
index 0000000..983e880
--- /dev/null
+++ b/grub-core/fs/sfs.c
@@ -0,0 +1,789 @@
+/* sfs.c - Amiga Smart FileSystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+#include <grub/charset.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* The common header for a block. */
+struct grub_sfs_bheader
+{
+ grub_uint8_t magic[4];
+ grub_uint32_t chksum;
+ grub_uint32_t ipointtomyself;
+} GRUB_PACKED;
+
+/* The sfs rootblock. */
+struct grub_sfs_rblock
+{
+ struct grub_sfs_bheader header;
+ grub_uint32_t version;
+ grub_uint32_t createtime;
+ grub_uint8_t flags;
+ grub_uint8_t unused1[31];
+ grub_uint32_t blocksize;
+ grub_uint8_t unused2[40];
+ grub_uint8_t unused3[8];
+ grub_uint32_t rootobject;
+ grub_uint32_t btree;
+} GRUB_PACKED;
+
+enum
+ {
+ FLAGS_CASE_SENSITIVE = 0x80
+ };
+
+/* A SFS object container. */
+struct grub_sfs_obj
+{
+ grub_uint8_t unused1[4];
+ grub_uint32_t nodeid;
+ grub_uint8_t unused2[4];
+ union
+ {
+ struct
+ {
+ grub_uint32_t first_block;
+ grub_uint32_t size;
+ } GRUB_PACKED file;
+ struct
+ {
+ grub_uint32_t hashtable;
+ grub_uint32_t dir_objc;
+ } GRUB_PACKED dir;
+ } file_dir;
+ grub_uint32_t mtime;
+ grub_uint8_t type;
+ grub_uint8_t filename[1];
+ grub_uint8_t comment[1];
+} GRUB_PACKED;
+
+#define GRUB_SFS_TYPE_DELETED 32
+#define GRUB_SFS_TYPE_SYMLINK 64
+#define GRUB_SFS_TYPE_DIR 128
+
+/* A SFS object container. */
+struct grub_sfs_objc
+{
+ struct grub_sfs_bheader header;
+ grub_uint32_t parent;
+ grub_uint32_t next;
+ grub_uint32_t prev;
+ /* The amount of objects depends on the blocksize. */
+ struct grub_sfs_obj objects[1];
+} GRUB_PACKED;
+
+struct grub_sfs_btree_node
+{
+ grub_uint32_t key;
+ grub_uint32_t data;
+} GRUB_PACKED;
+
+struct grub_sfs_btree_extent
+{
+ grub_uint32_t key;
+ grub_uint32_t next;
+ grub_uint32_t prev;
+ grub_uint16_t size;
+} GRUB_PACKED;
+
+struct grub_sfs_btree
+{
+ struct grub_sfs_bheader header;
+ grub_uint16_t nodes;
+ grub_uint8_t leaf;
+ grub_uint8_t nodesize;
+ /* Normally this can be kind of node, but just extents are
+ supported. */
+ struct grub_sfs_btree_node node[1];
+} GRUB_PACKED;
+
+
+
+struct cache_entry
+{
+ grub_uint32_t off;
+ grub_uint32_t block;
+};
+
+struct grub_fshelp_node
+{
+ struct grub_sfs_data *data;
+ grub_uint32_t block;
+ grub_uint32_t size;
+ grub_uint32_t mtime;
+ grub_uint32_t cache_off;
+ grub_uint32_t next_extent;
+ grub_size_t cache_allocated;
+ grub_size_t cache_size;
+ struct cache_entry *cache;
+};
+
+/* Information about a "mounted" sfs filesystem. */
+struct grub_sfs_data
+{
+ struct grub_sfs_rblock rblock;
+ struct grub_fshelp_node diropen;
+ grub_disk_t disk;
+
+ /* Log of blocksize in sectors. */
+ int log_blocksize;
+
+ int fshelp_flags;
+
+ /* Label of the filesystem. */
+ char *label;
+};
+
+static grub_dl_t my_mod;
+
+
+/* Lookup the extent starting with BLOCK in the filesystem described
+ by DATA. Return the extent size in SIZE and the following extent
+ in NEXTEXT. */
+static grub_err_t
+grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block,
+ grub_uint32_t *size, grub_uint32_t *nextext)
+{
+ char *treeblock;
+ 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 (blocksize);
+ if (!treeblock)
+ return grub_errno;
+
+ next = grub_be_to_cpu32 (data->rblock.btree);
+ tree = (struct grub_sfs_btree *) treeblock;
+
+ /* 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, blocksize, treeblock);
+ if (grub_errno)
+ {
+ grub_free (treeblock);
+ return grub_errno;
+ }
+
+ 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) \
+ ((struct grub_sfs_btree_node *) (((char *) &(tree)->node[0]) \
+ + (index) * (tree)->nodesize))
+
+ /* Follow the tree down to the leaf level. */
+ if ((grub_be_to_cpu32 (EXTNODE(tree, i)->key) <= block)
+ && !tree->leaf)
+ {
+ next = grub_be_to_cpu32 (EXTNODE (tree, i)->data);
+ break;
+ }
+
+ /* If the leaf level is reached, just find the correct extent. */
+ if (grub_be_to_cpu32 (EXTNODE (tree, i)->key) == block && tree->leaf)
+ {
+ struct grub_sfs_btree_extent *extent;
+ extent = (struct grub_sfs_btree_extent *) EXTNODE (tree, i);
+
+ /* We found a correct leaf. */
+ *size = grub_be_to_cpu16 (extent->size);
+ *nextext = grub_be_to_cpu32 (extent->next);
+
+ grub_free (treeblock);
+ return 0;
+ }
+
+#undef EXTNODE
+
+ }
+ } while (!tree->leaf);
+
+ grub_free (treeblock);
+
+ return grub_error (GRUB_ERR_FILE_READ_ERROR, "SFS extent not found");
+}
+
+static grub_disk_addr_t
+grub_sfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
+{
+ grub_uint32_t blk;
+ grub_uint32_t size = 0;
+ grub_uint32_t next = 0;
+ grub_disk_addr_t off;
+ struct grub_sfs_data *data = node->data;
+
+ /* In case of the first block we don't have to lookup the
+ extent, the minimum size is always 1. */
+ if (fileblock == 0)
+ return node->block;
+
+ if (!node->cache)
+ {
+ grub_size_t cache_size;
+ /* Assume half-max extents (32768 sectors). */
+ cache_size = ((node->size >> (data->log_blocksize + GRUB_DISK_SECTOR_BITS
+ + 15))
+ + 3);
+ if (cache_size < 8)
+ cache_size = 8;
+
+ node->cache_off = 0;
+ node->next_extent = node->block;
+ node->cache_size = 0;
+
+ node->cache = grub_calloc (cache_size, sizeof (node->cache[0]));
+ if (!node->cache)
+ {
+ grub_errno = 0;
+ node->cache_allocated = 0;
+ }
+ else
+ {
+ node->cache_allocated = cache_size;
+ node->cache[0].off = 0;
+ node->cache[0].block = node->block;
+ }
+ }
+
+ if (fileblock < node->cache_off)
+ {
+ unsigned int i = 0;
+ int j, lg;
+ for (lg = 0; node->cache_size >> lg; lg++);
+
+ for (j = lg - 1; j >= 0; j--)
+ if ((i | (1 << j)) < node->cache_size
+ && node->cache[(i | (1 << j))].off <= fileblock)
+ i |= (1 << j);
+ return node->cache[i].block + fileblock - node->cache[i].off;
+ }
+
+ off = node->cache_off;
+ blk = node->next_extent;
+
+ while (blk)
+ {
+ grub_err_t err;
+
+ err = grub_sfs_read_extent (node->data, blk, &size, &next);
+ if (err)
+ return 0;
+
+ if (node->cache && node->cache_size >= node->cache_allocated)
+ {
+ struct cache_entry *e = node->cache;
+ grub_size_t sz;
+
+ if (grub_mul (node->cache_allocated, 2 * sizeof (e[0]), &sz))
+ goto fail;
+
+ e = grub_realloc (node->cache, sz);
+ if (!e)
+ {
+ fail:
+ grub_errno = 0;
+ grub_free (node->cache);
+ node->cache = 0;
+ }
+ else
+ {
+ node->cache_allocated *= 2;
+ node->cache = e;
+ }
+ }
+
+ if (node->cache)
+ {
+ node->cache_off = off + size;
+ node->next_extent = next;
+ node->cache[node->cache_size].off = off;
+ node->cache[node->cache_size].block = blk;
+ node->cache_size++;
+ }
+
+ if (fileblock - off < size)
+ return fileblock - off + blk;
+
+ off += size;
+
+ blk = next;
+ }
+
+ grub_error (GRUB_ERR_FILE_READ_ERROR,
+ "reading a SFS block outside the extent");
+
+ return 0;
+}
+
+
+/* Read LEN bytes from the file described by DATA starting with byte
+ POS. Return the amount of read bytes in READ. */
+static grub_ssize_t
+grub_sfs_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)
+{
+ return grub_fshelp_read_file (node->data->disk, node,
+ read_hook, read_hook_data,
+ pos, len, buf, grub_sfs_read_block,
+ node->size, node->data->log_blocksize, 0);
+}
+
+
+static struct grub_sfs_data *
+grub_sfs_mount (grub_disk_t disk)
+{
+ struct grub_sfs_data *data;
+ struct grub_sfs_objc *rootobjc;
+ char *rootobjc_data = 0;
+ grub_uint32_t blk;
+ unsigned int max_len;
+
+ data = grub_malloc (sizeof (*data));
+ if (!data)
+ return 0;
+
+ /* Read the rootblock. */
+ grub_disk_read (disk, 0, 0, sizeof (struct grub_sfs_rblock),
+ &data->rblock);
+ if (grub_errno)
+ goto fail;
+
+ /* Make sure this is a sfs filesystem. */
+ if (grub_strncmp ((char *) (data->rblock.header.magic), "SFS", 4)
+ || data->rblock.blocksize == 0
+ || (data->rblock.blocksize & (data->rblock.blocksize - 1)) != 0
+ || (data->rblock.blocksize & grub_cpu_to_be32_compile_time (0xf00001ff)))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not a SFS filesystem");
+ goto fail;
+ }
+
+ for (data->log_blocksize = 9;
+ (1U << data->log_blocksize) < grub_be_to_cpu32 (data->rblock.blocksize);
+ data->log_blocksize++);
+ data->log_blocksize -= GRUB_DISK_SECTOR_BITS;
+ if (data->rblock.flags & FLAGS_CASE_SENSITIVE)
+ data->fshelp_flags = 0;
+ else
+ data->fshelp_flags = GRUB_FSHELP_CASE_INSENSITIVE;
+ rootobjc_data = grub_malloc (GRUB_DISK_SECTOR_SIZE << data->log_blocksize);
+ if (! rootobjc_data)
+ goto fail;
+
+ /* Read the root object container. */
+ grub_disk_read (disk, ((grub_disk_addr_t) grub_be_to_cpu32 (data->rblock.rootobject))
+ << data->log_blocksize, 0,
+ GRUB_DISK_SECTOR_SIZE << data->log_blocksize, rootobjc_data);
+ if (grub_errno)
+ goto fail;
+
+ rootobjc = (struct grub_sfs_objc *) rootobjc_data;
+
+ blk = grub_be_to_cpu32 (rootobjc->objects[0].file_dir.dir.dir_objc);
+ data->diropen.size = 0;
+ data->diropen.block = blk;
+ data->diropen.data = data;
+ data->diropen.cache = 0;
+ data->disk = disk;
+
+ /* We only read 1 block of data, so truncate the name if needed. */
+ max_len = ((GRUB_DISK_SECTOR_SIZE << data->log_blocksize)
+ - 24 /* offsetof (struct grub_sfs_objc, objects) */
+ - 25); /* offsetof (struct grub_sfs_obj, filename) */
+ data->label = grub_zalloc (max_len + 1);
+ grub_strncpy (data->label, (char *) rootobjc->objects[0].filename, max_len);
+
+ grub_free (rootobjc_data);
+ return data;
+
+ fail:
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not an SFS filesystem");
+
+ grub_free (data);
+ grub_free (rootobjc_data);
+ return 0;
+}
+
+
+static char *
+grub_sfs_read_symlink (grub_fshelp_node_t node)
+{
+ struct grub_sfs_data *data = node->data;
+ char *symlink;
+ char *block;
+
+ block = grub_malloc (GRUB_DISK_SECTOR_SIZE << data->log_blocksize);
+ if (!block)
+ return 0;
+
+ grub_disk_read (data->disk, ((grub_disk_addr_t) node->block)
+ << data->log_blocksize,
+ 0, GRUB_DISK_SECTOR_SIZE << data->log_blocksize, block);
+ if (grub_errno)
+ {
+ grub_free (block);
+ return 0;
+ }
+
+ /* This is just a wild guess, but it always worked for me. How the
+ SLNK block looks like is not documented in the SFS docs. */
+ symlink = grub_malloc (((GRUB_DISK_SECTOR_SIZE << data->log_blocksize)
+ - 24) * GRUB_MAX_UTF8_PER_LATIN1 + 1);
+ if (!symlink)
+ {
+ grub_free (block);
+ return 0;
+ }
+ *grub_latin1_to_utf8 ((grub_uint8_t *) symlink, (grub_uint8_t *) &block[24],
+ (GRUB_DISK_SECTOR_SIZE << data->log_blocksize) - 24) = '\0';
+ grub_free (block);
+ return symlink;
+}
+
+/* Helper for grub_sfs_iterate_dir. */
+static int
+grub_sfs_create_node (struct grub_fshelp_node **node,
+ struct grub_sfs_data *data,
+ const char *name,
+ grub_uint32_t block, grub_uint32_t size, int type,
+ grub_uint32_t mtime,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ grub_size_t len = grub_strlen (name);
+ grub_uint8_t *name_u8;
+ int ret;
+ grub_size_t sz;
+
+ if (grub_mul (len, GRUB_MAX_UTF8_PER_LATIN1, &sz) ||
+ grub_add (sz, 1, &sz))
+ return 1;
+
+ *node = grub_malloc (sizeof (**node));
+ if (!*node)
+ return 1;
+ name_u8 = grub_malloc (sz);
+ if (!name_u8)
+ {
+ grub_free (*node);
+ return 1;
+ }
+
+ (*node)->data = data;
+ (*node)->size = size;
+ (*node)->block = block;
+ (*node)->mtime = mtime;
+ (*node)->cache = 0;
+ (*node)->cache_off = 0;
+ (*node)->next_extent = block;
+ (*node)->cache_size = 0;
+ (*node)->cache_allocated = 0;
+
+ *grub_latin1_to_utf8 (name_u8, (const grub_uint8_t *) name, len) = '\0';
+
+ ret = hook ((char *) name_u8, type | data->fshelp_flags, *node, hook_data);
+ grub_free (name_u8);
+ return ret;
+}
+
+static int
+grub_sfs_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ struct grub_fshelp_node *node = 0;
+ struct grub_sfs_data *data = dir->data;
+ char *objc_data;
+ struct grub_sfs_objc *objc;
+ unsigned int next = dir->block;
+ grub_uint32_t pos;
+
+ objc_data = grub_malloc (GRUB_DISK_SECTOR_SIZE << data->log_blocksize);
+ if (!objc_data)
+ goto fail;
+
+ /* The Object container can consist of multiple blocks, iterate over
+ every block. */
+ while (next)
+ {
+ grub_disk_read (data->disk, ((grub_disk_addr_t) next)
+ << data->log_blocksize, 0,
+ GRUB_DISK_SECTOR_SIZE << data->log_blocksize, objc_data);
+ if (grub_errno)
+ goto fail;
+
+ objc = (struct grub_sfs_objc *) objc_data;
+
+ pos = (char *) &objc->objects[0] - (char *) objc;
+
+ /* Iterate over all entries in this block. */
+ while (pos + sizeof (struct grub_sfs_obj)
+ < (1U << (GRUB_DISK_SECTOR_BITS + data->log_blocksize)))
+ {
+ struct grub_sfs_obj *obj;
+ obj = (struct grub_sfs_obj *) ((char *) objc + pos);
+ const char *filename = (const char *) obj->filename;
+ grub_size_t len;
+ enum grub_fshelp_filetype type;
+ grub_uint32_t block;
+
+ /* The filename and comment dynamically increase the size of
+ the object. */
+ len = grub_strlen (filename);
+ len += grub_strlen (filename + len + 1);
+
+ pos += sizeof (*obj) + len;
+ /* Round up to a multiple of two bytes. */
+ pos = ((pos + 1) >> 1) << 1;
+
+ if (filename[0] == 0)
+ continue;
+
+ /* First check if the file was not deleted. */
+ if (obj->type & GRUB_SFS_TYPE_DELETED)
+ continue;
+ else if (obj->type & GRUB_SFS_TYPE_SYMLINK)
+ type = GRUB_FSHELP_SYMLINK;
+ else if (obj->type & GRUB_SFS_TYPE_DIR)
+ type = GRUB_FSHELP_DIR;
+ else
+ type = GRUB_FSHELP_REG;
+
+ if (type == GRUB_FSHELP_DIR)
+ block = grub_be_to_cpu32 (obj->file_dir.dir.dir_objc);
+ else
+ block = grub_be_to_cpu32 (obj->file_dir.file.first_block);
+
+ if (grub_sfs_create_node (&node, data, filename, block,
+ grub_be_to_cpu32 (obj->file_dir.file.size),
+ type, grub_be_to_cpu32 (obj->mtime),
+ hook, hook_data))
+ {
+ grub_free (objc_data);
+ return 1;
+ }
+ }
+
+ next = grub_be_to_cpu32 (objc->next);
+ }
+
+ fail:
+ grub_free (objc_data);
+ return 0;
+}
+
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_sfs_open (struct grub_file *file, const char *name)
+{
+ struct grub_sfs_data *data;
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_sfs_mount (file->device->disk);
+ if (!data)
+ goto fail;
+
+ grub_fshelp_find_file (name, &data->diropen, &fdiro, grub_sfs_iterate_dir,
+ grub_sfs_read_symlink, GRUB_FSHELP_REG);
+ if (grub_errno)
+ goto fail;
+
+ file->size = fdiro->size;
+ data->diropen = *fdiro;
+ grub_free (fdiro);
+
+ file->data = data;
+ file->offset = 0;
+
+ return 0;
+
+ fail:
+ if (data && fdiro != &data->diropen)
+ grub_free (fdiro);
+ if (data)
+ grub_free (data->label);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+
+static grub_err_t
+grub_sfs_close (grub_file_t file)
+{
+ struct grub_sfs_data *data = (struct grub_sfs_data *) file->data;
+
+ grub_free (data->diropen.cache);
+ grub_free (data->label);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+
+/* Read LEN bytes data from FILE into BUF. */
+static grub_ssize_t
+grub_sfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_sfs_data *data = (struct grub_sfs_data *) file->data;
+
+ return grub_sfs_read_file (&data->diropen,
+ file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+
+/* Context for grub_sfs_dir. */
+struct grub_sfs_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_sfs_dir. */
+static int
+grub_sfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_sfs_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ info.mtime = node->mtime + 8 * 365 * 86400 + 86400 * 2;
+ info.mtimeset = 1;
+ grub_free (node->cache);
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_sfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_sfs_dir_ctx ctx = { hook, hook_data };
+ struct grub_sfs_data *data = 0;
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_sfs_mount (device->disk);
+ if (!data)
+ goto fail;
+
+ grub_fshelp_find_file (path, &data->diropen, &fdiro, grub_sfs_iterate_dir,
+ grub_sfs_read_symlink, GRUB_FSHELP_DIR);
+ if (grub_errno)
+ goto fail;
+
+ grub_sfs_iterate_dir (fdiro, grub_sfs_dir_iter, &ctx);
+
+ fail:
+ if (data && fdiro != &data->diropen)
+ grub_free (fdiro);
+ if (data)
+ grub_free (data->label);
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+
+static grub_err_t
+grub_sfs_label (grub_device_t device, char **label)
+{
+ struct grub_sfs_data *data;
+ grub_disk_t disk = device->disk;
+
+ data = grub_sfs_mount (disk);
+ if (data)
+ {
+ grub_size_t sz, len = grub_strlen (data->label);
+
+ if (grub_mul (len, GRUB_MAX_UTF8_PER_LATIN1, &sz) ||
+ grub_add (sz, 1, &sz))
+ return GRUB_ERR_OUT_OF_RANGE;
+
+ *label = grub_malloc (sz);
+ if (*label)
+ *grub_latin1_to_utf8 ((grub_uint8_t *) *label,
+ (const grub_uint8_t *) data->label,
+ len) = '\0';
+ grub_free (data->label);
+ }
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+static struct grub_fs grub_sfs_fs =
+ {
+ .name = "sfs",
+ .fs_dir = grub_sfs_dir,
+ .fs_open = grub_sfs_open,
+ .fs_read = grub_sfs_read,
+ .fs_close = grub_sfs_close,
+ .fs_label = grub_sfs_label,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 0,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(sfs)
+{
+ grub_fs_register (&grub_sfs_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(sfs)
+{
+ grub_fs_unregister (&grub_sfs_fs);
+}
diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c
new file mode 100644
index 0000000..6dd731e
--- /dev/null
+++ b/grub-core/fs/squash4.c
@@ -0,0 +1,1042 @@
+/* squash4.c - SquashFS */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+#include <grub/deflate.h>
+#include <grub/safemath.h>
+#include <minilzo.h>
+
+#include "xz.h"
+#include "xz_stream.h"
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/*
+ object format Pointed by
+ superblock RAW Fixed offset (0)
+ data RAW ? Fixed offset (60)
+ inode table Chunk superblock
+ dir table Chunk superblock
+ fragment table Chunk unk1
+ unk1 RAW, Chunk superblock
+ unk2 RAW superblock
+ UID/GID Chunk exttblptr
+ exttblptr RAW superblock
+
+ UID/GID table is the array ot uint32_t
+ unk1 contains pointer to fragment table followed by some chunk.
+ unk2 containts one uint64_t
+*/
+
+struct grub_squash_super
+{
+ grub_uint32_t magic;
+#define SQUASH_MAGIC 0x73717368
+ grub_uint32_t dummy1;
+ grub_uint32_t creation_time;
+ grub_uint32_t block_size;
+ grub_uint32_t dummy2;
+ grub_uint16_t compression;
+ grub_uint16_t dummy3;
+ grub_uint64_t dummy4;
+ grub_uint16_t root_ino_offset;
+ grub_uint32_t root_ino_chunk;
+ grub_uint16_t dummy5;
+ grub_uint64_t total_size;
+ grub_uint64_t exttbloffset;
+ grub_uint64_t dummy6;
+ grub_uint64_t inodeoffset;
+ grub_uint64_t diroffset;
+ grub_uint64_t unk1offset;
+ grub_uint64_t unk2offset;
+} GRUB_PACKED;
+
+/* Chunk-based */
+struct grub_squash_inode
+{
+ /* Same values as direlem types. */
+ grub_uint16_t type;
+ grub_uint16_t dummy[3];
+ grub_uint32_t mtime;
+ grub_uint32_t dummy2;
+ union
+ {
+ struct {
+ grub_uint32_t chunk;
+ grub_uint32_t fragment;
+ grub_uint32_t offset;
+ grub_uint32_t size;
+ grub_uint32_t block_size[0];
+ } GRUB_PACKED file;
+ struct {
+ grub_uint64_t chunk;
+ grub_uint64_t size;
+ grub_uint32_t dummy1[3];
+ grub_uint32_t fragment;
+ grub_uint32_t offset;
+ grub_uint32_t dummy3;
+ grub_uint32_t block_size[0];
+ } GRUB_PACKED long_file;
+ struct {
+ grub_uint32_t chunk;
+ grub_uint32_t dummy;
+ grub_uint16_t size;
+ grub_uint16_t offset;
+ } GRUB_PACKED dir;
+ struct {
+ grub_uint32_t dummy1;
+ grub_uint32_t size;
+ grub_uint32_t chunk;
+ grub_uint32_t dummy2;
+ grub_uint16_t dummy3;
+ grub_uint16_t offset;
+ } GRUB_PACKED long_dir;
+ struct {
+ grub_uint32_t dummy;
+ grub_uint32_t namelen;
+ char name[0];
+ } GRUB_PACKED symlink;
+ } GRUB_PACKED;
+} GRUB_PACKED;
+
+struct grub_squash_cache_inode
+{
+ struct grub_squash_inode ino;
+ grub_disk_addr_t ino_chunk;
+ grub_uint16_t ino_offset;
+ grub_uint32_t *block_sizes;
+ grub_disk_addr_t *cumulated_block_sizes;
+};
+
+/* Chunk-based. */
+struct grub_squash_dirent_header
+{
+ /* Actually the value is the number of elements - 1. */
+ grub_uint32_t nelems;
+ grub_uint32_t ino_chunk;
+ grub_uint32_t dummy;
+} GRUB_PACKED;
+
+struct grub_squash_dirent
+{
+ grub_uint16_t ino_offset;
+ grub_uint16_t dummy;
+ grub_uint16_t type;
+ /* Actually the value is the length of name - 1. */
+ grub_uint16_t namelen;
+ char name[0];
+} GRUB_PACKED;
+
+enum
+ {
+ SQUASH_TYPE_DIR = 1,
+ SQUASH_TYPE_REGULAR = 2,
+ SQUASH_TYPE_SYMLINK = 3,
+ SQUASH_TYPE_LONG_DIR = 8,
+ SQUASH_TYPE_LONG_REGULAR = 9,
+ };
+
+
+struct grub_squash_frag_desc
+{
+ grub_uint64_t offset;
+ grub_uint32_t size;
+ grub_uint32_t dummy;
+} GRUB_PACKED;
+
+enum
+ {
+ SQUASH_CHUNK_FLAGS = 0x8000,
+ SQUASH_CHUNK_UNCOMPRESSED = 0x8000
+ };
+
+enum
+ {
+ SQUASH_BLOCK_FLAGS = 0x1000000,
+ SQUASH_BLOCK_UNCOMPRESSED = 0x1000000
+ };
+
+enum
+ {
+ COMPRESSION_ZLIB = 1,
+ COMPRESSION_LZO = 3,
+ COMPRESSION_XZ = 4,
+ };
+
+
+#define SQUASH_CHUNK_SIZE 0x2000
+#define XZBUFSIZ 0x2000
+
+struct grub_squash_data
+{
+ grub_disk_t disk;
+ struct grub_squash_super sb;
+ struct grub_squash_cache_inode ino;
+ grub_uint64_t fragments;
+ int log2_blksz;
+ grub_size_t blksz;
+ grub_ssize_t (*decompress) (char *inbuf, grub_size_t insize, grub_off_t off,
+ char *outbuf, grub_size_t outsize,
+ struct grub_squash_data *data);
+ struct xz_dec *xzdec;
+ char *xzbuf;
+};
+
+struct grub_fshelp_node
+{
+ struct grub_squash_data *data;
+ struct grub_squash_inode ino;
+ grub_size_t stsize;
+ struct
+ {
+ grub_disk_addr_t ino_chunk;
+ grub_uint16_t ino_offset;
+ } stack[1];
+};
+
+static grub_err_t
+read_chunk (struct grub_squash_data *data, void *buf, grub_size_t len,
+ grub_uint64_t chunk_start, grub_off_t offset)
+{
+ while (len > 0)
+ {
+ grub_uint64_t csize;
+ grub_uint16_t d;
+ grub_err_t err;
+ while (1)
+ {
+ err = grub_disk_read (data->disk,
+ chunk_start >> GRUB_DISK_SECTOR_BITS,
+ chunk_start & (GRUB_DISK_SECTOR_SIZE - 1),
+ sizeof (d), &d);
+ if (err)
+ return err;
+ if (offset < SQUASH_CHUNK_SIZE)
+ break;
+ offset -= SQUASH_CHUNK_SIZE;
+ chunk_start += 2 + (grub_le_to_cpu16 (d) & ~SQUASH_CHUNK_FLAGS);
+ }
+
+ csize = SQUASH_CHUNK_SIZE - offset;
+ if (csize > len)
+ csize = len;
+
+ if (grub_le_to_cpu16 (d) & SQUASH_CHUNK_UNCOMPRESSED)
+ {
+ grub_disk_addr_t a = chunk_start + 2 + offset;
+ err = grub_disk_read (data->disk, (a >> GRUB_DISK_SECTOR_BITS),
+ a & (GRUB_DISK_SECTOR_SIZE - 1),
+ csize, buf);
+ if (err)
+ return err;
+ }
+ else
+ {
+ char *tmp;
+ grub_size_t bsize = grub_le_to_cpu16 (d) & ~SQUASH_CHUNK_FLAGS;
+ grub_disk_addr_t a = chunk_start + 2;
+ tmp = grub_malloc (bsize);
+ if (!tmp)
+ return grub_errno;
+ /* FIXME: buffer uncompressed data. */
+ err = grub_disk_read (data->disk, (a >> GRUB_DISK_SECTOR_BITS),
+ a & (GRUB_DISK_SECTOR_SIZE - 1),
+ bsize, tmp);
+ if (err)
+ {
+ grub_free (tmp);
+ return err;
+ }
+
+ if (data->decompress (tmp, bsize, offset,
+ buf, csize, data) < 0)
+ {
+ grub_free (tmp);
+ return grub_errno;
+ }
+ grub_free (tmp);
+ }
+ len -= csize;
+ offset += csize;
+ buf = (char *) buf + csize;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_ssize_t
+zlib_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
+ char *outbuf, grub_size_t outsize,
+ struct grub_squash_data *data __attribute__ ((unused)))
+{
+ return grub_zlib_decompress (inbuf, insize, off, outbuf, outsize);
+}
+
+static grub_ssize_t
+lzo_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
+ char *outbuf, grub_size_t len, struct grub_squash_data *data)
+{
+ lzo_uint usize = data->blksz;
+ grub_uint8_t *udata;
+
+ if (usize < 8192)
+ usize = 8192;
+
+ udata = grub_malloc (usize);
+ if (!udata)
+ return -1;
+
+ if (lzo1x_decompress_safe ((grub_uint8_t *) inbuf,
+ insize, udata, &usize, NULL) != LZO_E_OK)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "incorrect compressed chunk");
+ grub_free (udata);
+ return -1;
+ }
+ grub_memcpy (outbuf, udata + off, len);
+ grub_free (udata);
+ return len;
+}
+
+static grub_ssize_t
+xz_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
+ char *outbuf, grub_size_t len, struct grub_squash_data *data)
+{
+ grub_size_t ret = 0;
+ grub_off_t pos = 0;
+ struct xz_buf buf;
+
+ xz_dec_reset (data->xzdec);
+ buf.in = (grub_uint8_t *) inbuf;
+ buf.in_pos = 0;
+ buf.in_size = insize;
+ buf.out = (grub_uint8_t *) data->xzbuf;
+ buf.out_pos = 0;
+ buf.out_size = XZBUFSIZ;
+
+ while (len)
+ {
+ enum xz_ret xzret;
+
+ buf.out_pos = 0;
+
+ xzret = xz_dec_run (data->xzdec, &buf);
+
+ if (xzret != XZ_OK && xzret != XZ_STREAM_END)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "invalid xz chunk");
+ return -1;
+ }
+ if (pos + buf.out_pos >= off)
+ {
+ grub_ssize_t outoff = pos - off;
+ grub_size_t l;
+ if (outoff >= 0)
+ {
+ l = buf.out_pos;
+ if (l > len)
+ l = len;
+ grub_memcpy (outbuf + outoff, buf.out, l);
+ }
+ else
+ {
+ outoff = -outoff;
+ l = buf.out_pos - outoff;
+ if (l > len)
+ l = len;
+ grub_memcpy (outbuf, buf.out + outoff, l);
+ }
+ ret += l;
+ len -= l;
+ }
+ pos += buf.out_pos;
+ if (xzret == XZ_STREAM_END)
+ break;
+ }
+ return ret;
+}
+
+static struct grub_squash_data *
+squash_mount (grub_disk_t disk)
+{
+ struct grub_squash_super sb;
+ grub_err_t err;
+ struct grub_squash_data *data;
+ grub_uint64_t frag;
+
+ err = grub_disk_read (disk, 0, 0, sizeof (sb), &sb);
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not a squash4");
+ if (err)
+ return NULL;
+ if (sb.magic != grub_cpu_to_le32_compile_time (SQUASH_MAGIC)
+ || sb.block_size == 0
+ || ((sb.block_size - 1) & sb.block_size))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not squash4");
+ return NULL;
+ }
+
+ err = grub_disk_read (disk,
+ grub_le_to_cpu64 (sb.unk1offset)
+ >> GRUB_DISK_SECTOR_BITS,
+ grub_le_to_cpu64 (sb.unk1offset)
+ & (GRUB_DISK_SECTOR_SIZE - 1), sizeof (frag), &frag);
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not a squash4");
+ if (err)
+ return NULL;
+
+ data = grub_zalloc (sizeof (*data));
+ if (!data)
+ return NULL;
+ data->sb = sb;
+ data->disk = disk;
+ data->fragments = grub_le_to_cpu64 (frag);
+
+ switch (sb.compression)
+ {
+ case grub_cpu_to_le16_compile_time (COMPRESSION_ZLIB):
+ data->decompress = zlib_decompress;
+ break;
+ case grub_cpu_to_le16_compile_time (COMPRESSION_LZO):
+ data->decompress = lzo_decompress;
+ break;
+ case grub_cpu_to_le16_compile_time (COMPRESSION_XZ):
+ data->decompress = xz_decompress;
+ data->xzbuf = grub_malloc (XZBUFSIZ);
+ if (!data->xzbuf)
+ {
+ grub_free (data);
+ return NULL;
+ }
+ data->xzdec = xz_dec_init (1 << 16);
+ if (!data->xzdec)
+ {
+ grub_free (data->xzbuf);
+ grub_free (data);
+ return NULL;
+ }
+ break;
+ default:
+ grub_free (data);
+ grub_error (GRUB_ERR_BAD_FS, "unsupported compression %d",
+ grub_le_to_cpu16 (sb.compression));
+ return NULL;
+ }
+
+ data->blksz = grub_le_to_cpu32 (data->sb.block_size);
+ for (data->log2_blksz = 0;
+ (1U << data->log2_blksz) < data->blksz;
+ data->log2_blksz++);
+
+ return data;
+}
+
+static char *
+grub_squash_read_symlink (grub_fshelp_node_t node)
+{
+ char *ret;
+ grub_err_t err;
+ grub_size_t sz;
+
+ if (grub_add (grub_le_to_cpu32 (node->ino.symlink.namelen), 1, &sz))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+ return NULL;
+ }
+
+ ret = grub_malloc (sz);
+ if (!ret)
+ return NULL;
+
+ err = read_chunk (node->data, ret,
+ grub_le_to_cpu32 (node->ino.symlink.namelen),
+ grub_le_to_cpu64 (node->data->sb.inodeoffset)
+ + node->stack[node->stsize - 1].ino_chunk,
+ node->stack[node->stsize - 1].ino_offset
+ + (node->ino.symlink.name - (char *) &node->ino));
+ if (err)
+ {
+ grub_free (ret);
+ return NULL;
+ }
+ ret[grub_le_to_cpu32 (node->ino.symlink.namelen)] = 0;
+ return ret;
+}
+
+static int
+grub_squash_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ grub_uint32_t off;
+ grub_uint32_t endoff;
+ grub_uint64_t chunk;
+ unsigned i;
+
+ /* FIXME: why - 3 ? */
+ switch (dir->ino.type)
+ {
+ case grub_cpu_to_le16_compile_time (SQUASH_TYPE_DIR):
+ off = grub_le_to_cpu16 (dir->ino.dir.offset);
+ endoff = grub_le_to_cpu16 (dir->ino.dir.size) + off - 3;
+ chunk = grub_le_to_cpu32 (dir->ino.dir.chunk);
+ break;
+ case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_DIR):
+ off = grub_le_to_cpu16 (dir->ino.long_dir.offset);
+ endoff = grub_le_to_cpu16 (dir->ino.long_dir.size) + off - 3;
+ chunk = grub_le_to_cpu32 (dir->ino.long_dir.chunk);
+ break;
+ default:
+ grub_error (GRUB_ERR_BAD_FS, "unexpected ino type 0x%x",
+ grub_le_to_cpu16 (dir->ino.type));
+ return 0;
+ }
+
+ {
+ grub_fshelp_node_t node;
+ grub_size_t sz;
+
+ if (grub_mul (dir->stsize, sizeof (dir->stack[0]), &sz) ||
+ grub_add (sz, sizeof (*node), &sz))
+ return 0;
+
+ node = grub_malloc (sz);
+ if (!node)
+ return 0;
+ grub_memcpy (node, dir, sz);
+ if (hook (".", GRUB_FSHELP_DIR, node, hook_data))
+ return 1;
+
+ if (dir->stsize != 1)
+ {
+ grub_err_t err;
+
+ if (grub_mul (dir->stsize, sizeof (dir->stack[0]), &sz) ||
+ grub_add (sz, sizeof (*node), &sz))
+ return 0;
+
+ node = grub_malloc (sz);
+ if (!node)
+ return 0;
+
+ grub_memcpy (node, dir, sz);
+
+ node->stsize--;
+ err = read_chunk (dir->data, &node->ino, sizeof (node->ino),
+ grub_le_to_cpu64 (dir->data->sb.inodeoffset)
+ + node->stack[node->stsize - 1].ino_chunk,
+ node->stack[node->stsize - 1].ino_offset);
+ if (err)
+ return 0;
+
+ if (hook ("..", GRUB_FSHELP_DIR, node, hook_data))
+ return 1;
+ }
+ }
+
+ while (off < endoff)
+ {
+ struct grub_squash_dirent_header dh;
+ grub_err_t err;
+
+ err = read_chunk (dir->data, &dh, sizeof (dh),
+ grub_le_to_cpu64 (dir->data->sb.diroffset)
+ + chunk, off);
+ if (err)
+ return 0;
+ off += sizeof (dh);
+ for (i = 0; i < (unsigned) grub_le_to_cpu32 (dh.nelems) + 1; i++)
+ {
+ char *buf;
+ int r;
+ struct grub_fshelp_node *node;
+ enum grub_fshelp_filetype filetype = GRUB_FSHELP_REG;
+ struct grub_squash_dirent di;
+ struct grub_squash_inode ino;
+ grub_size_t sz;
+
+ err = read_chunk (dir->data, &di, sizeof (di),
+ grub_le_to_cpu64 (dir->data->sb.diroffset)
+ + chunk, off);
+ if (err)
+ return 0;
+ off += sizeof (di);
+
+ err = read_chunk (dir->data, &ino, sizeof (ino),
+ grub_le_to_cpu64 (dir->data->sb.inodeoffset)
+ + grub_le_to_cpu32 (dh.ino_chunk),
+ grub_cpu_to_le16 (di.ino_offset));
+ if (err)
+ return 0;
+
+ buf = grub_malloc (grub_le_to_cpu16 (di.namelen) + 2);
+ if (!buf)
+ return 0;
+ err = read_chunk (dir->data, buf,
+ grub_le_to_cpu16 (di.namelen) + 1,
+ grub_le_to_cpu64 (dir->data->sb.diroffset)
+ + chunk, off);
+ if (err)
+ return 0;
+
+ off += grub_le_to_cpu16 (di.namelen) + 1;
+ buf[grub_le_to_cpu16 (di.namelen) + 1] = 0;
+ if (grub_le_to_cpu16 (di.type) == SQUASH_TYPE_DIR)
+ filetype = GRUB_FSHELP_DIR;
+ if (grub_le_to_cpu16 (di.type) == SQUASH_TYPE_SYMLINK)
+ filetype = GRUB_FSHELP_SYMLINK;
+
+ if (grub_add (dir->stsize, 1, &sz) ||
+ grub_mul (sz, sizeof (dir->stack[0]), &sz) ||
+ grub_add (sz, sizeof (*node), &sz))
+ return 0;
+
+ node = grub_malloc (sz);
+ if (! node)
+ return 0;
+
+ grub_memcpy (node, dir, sz - sizeof(dir->stack[0]));
+
+ node->ino = ino;
+ node->stack[node->stsize].ino_chunk = grub_le_to_cpu32 (dh.ino_chunk);
+ node->stack[node->stsize].ino_offset = grub_le_to_cpu16 (di.ino_offset);
+ node->stsize++;
+ r = hook (buf, filetype, node, hook_data);
+
+ grub_free (buf);
+ if (r)
+ return r;
+ }
+ }
+ return 0;
+}
+
+static grub_err_t
+make_root_node (struct grub_squash_data *data, struct grub_fshelp_node *root)
+{
+ grub_memset (root, 0, sizeof (*root));
+ root->data = data;
+ root->stsize = 1;
+ root->stack[0].ino_chunk = grub_le_to_cpu32 (data->sb.root_ino_chunk);
+ root->stack[0].ino_offset = grub_cpu_to_le16 (data->sb.root_ino_offset);
+ return read_chunk (data, &root->ino, sizeof (root->ino),
+ grub_le_to_cpu64 (data->sb.inodeoffset)
+ + root->stack[0].ino_chunk,
+ root->stack[0].ino_offset);
+}
+
+static void
+squash_unmount (struct grub_squash_data *data)
+{
+ if (data->xzdec)
+ xz_dec_end (data->xzdec);
+ grub_free (data->xzbuf);
+ grub_free (data->ino.cumulated_block_sizes);
+ grub_free (data->ino.block_sizes);
+ grub_free (data);
+}
+
+
+/* Context for grub_squash_dir. */
+struct grub_squash_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_squash_dir. */
+static int
+grub_squash_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_squash_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ info.mtimeset = 1;
+ info.mtime = grub_le_to_cpu32 (node->ino.mtime);
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_squash_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_squash_dir_ctx ctx = { hook, hook_data };
+ struct grub_squash_data *data = 0;
+ struct grub_fshelp_node *fdiro = 0;
+ struct grub_fshelp_node root;
+ grub_err_t err;
+
+ data = squash_mount (device->disk);
+ if (! data)
+ return grub_errno;
+
+ err = make_root_node (data, &root);
+ if (err)
+ return err;
+
+ grub_fshelp_find_file (path, &root, &fdiro, grub_squash_iterate_dir,
+ grub_squash_read_symlink, GRUB_FSHELP_DIR);
+ if (!grub_errno)
+ grub_squash_iterate_dir (fdiro, grub_squash_dir_iter, &ctx);
+
+ squash_unmount (data);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_squash_open (struct grub_file *file, const char *name)
+{
+ struct grub_squash_data *data = 0;
+ struct grub_fshelp_node *fdiro = 0;
+ struct grub_fshelp_node root;
+ grub_err_t err;
+
+ data = squash_mount (file->device->disk);
+ if (! data)
+ return grub_errno;
+
+ err = make_root_node (data, &root);
+ if (err)
+ return err;
+
+ grub_fshelp_find_file (name, &root, &fdiro, grub_squash_iterate_dir,
+ grub_squash_read_symlink, GRUB_FSHELP_REG);
+ if (grub_errno)
+ {
+ squash_unmount (data);
+ return grub_errno;
+ }
+
+ file->data = data;
+ data->ino.ino = fdiro->ino;
+ data->ino.block_sizes = NULL;
+ data->ino.cumulated_block_sizes = NULL;
+ data->ino.ino_chunk = fdiro->stack[fdiro->stsize - 1].ino_chunk;
+ data->ino.ino_offset = fdiro->stack[fdiro->stsize - 1].ino_offset;
+
+ switch (fdiro->ino.type)
+ {
+ case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR):
+ file->size = grub_le_to_cpu64 (fdiro->ino.long_file.size);
+ break;
+ case grub_cpu_to_le16_compile_time (SQUASH_TYPE_REGULAR):
+ file->size = grub_le_to_cpu32 (fdiro->ino.file.size);
+ break;
+ default:
+ {
+ grub_uint16_t type = grub_le_to_cpu16 (fdiro->ino.type);
+ grub_free (fdiro);
+ squash_unmount (data);
+ return grub_error (GRUB_ERR_BAD_FS, "unexpected ino type 0x%x", type);
+ }
+ }
+
+ grub_free (fdiro);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_ssize_t
+direct_read (struct grub_squash_data *data,
+ struct grub_squash_cache_inode *ino,
+ grub_off_t off, char *buf, grub_size_t len)
+{
+ grub_err_t err = GRUB_ERR_NONE;
+ grub_off_t cumulated_uncompressed_size = 0;
+ grub_uint64_t a = 0;
+ grub_size_t i;
+ grub_size_t origlen = len;
+
+ switch (ino->ino.type)
+ {
+ case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR):
+ a = grub_le_to_cpu64 (ino->ino.long_file.chunk);
+ break;
+ case grub_cpu_to_le16_compile_time (SQUASH_TYPE_REGULAR):
+ a = grub_le_to_cpu32 (ino->ino.file.chunk);
+ break;
+ }
+
+ if (!ino->block_sizes)
+ {
+ grub_off_t total_size = 0;
+ grub_size_t total_blocks;
+ grub_size_t block_offset = 0;
+ switch (ino->ino.type)
+ {
+ case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR):
+ total_size = grub_le_to_cpu64 (ino->ino.long_file.size);
+ block_offset = ((char *) &ino->ino.long_file.block_size
+ - (char *) &ino->ino);
+ break;
+ case grub_cpu_to_le16_compile_time (SQUASH_TYPE_REGULAR):
+ total_size = grub_le_to_cpu32 (ino->ino.file.size);
+ block_offset = ((char *) &ino->ino.file.block_size
+ - (char *) &ino->ino);
+ break;
+ }
+ total_blocks = ((total_size + data->blksz - 1) >> data->log2_blksz);
+ ino->block_sizes = grub_malloc (total_blocks
+ * sizeof (ino->block_sizes[0]));
+ ino->cumulated_block_sizes = grub_malloc (total_blocks
+ * sizeof (ino->cumulated_block_sizes[0]));
+ if (!ino->block_sizes || !ino->cumulated_block_sizes)
+ {
+ grub_free (ino->block_sizes);
+ grub_free (ino->cumulated_block_sizes);
+ ino->block_sizes = 0;
+ ino->cumulated_block_sizes = 0;
+ return -1;
+ }
+ err = read_chunk (data, ino->block_sizes,
+ total_blocks * sizeof (ino->block_sizes[0]),
+ grub_le_to_cpu64 (data->sb.inodeoffset)
+ + ino->ino_chunk,
+ ino->ino_offset + block_offset);
+ if (err)
+ {
+ grub_free (ino->block_sizes);
+ grub_free (ino->cumulated_block_sizes);
+ ino->block_sizes = 0;
+ ino->cumulated_block_sizes = 0;
+ return -1;
+ }
+ ino->cumulated_block_sizes[0] = 0;
+ for (i = 1; i < total_blocks; i++)
+ ino->cumulated_block_sizes[i] = ino->cumulated_block_sizes[i - 1]
+ + (grub_le_to_cpu32 (ino->block_sizes[i - 1]) & ~SQUASH_BLOCK_FLAGS);
+ }
+
+ if (a == 0)
+ a = sizeof (struct grub_squash_super);
+ i = off >> data->log2_blksz;
+ cumulated_uncompressed_size = data->blksz * (grub_disk_addr_t) i;
+ while (cumulated_uncompressed_size < off + len)
+ {
+ grub_size_t boff, curread;
+ boff = off - cumulated_uncompressed_size;
+ curread = data->blksz - boff;
+ if (curread > len)
+ curread = len;
+ if (!ino->block_sizes[i])
+ {
+ /* Sparse block */
+ grub_memset (buf, '\0', curread);
+ }
+ else if (!(ino->block_sizes[i]
+ & grub_cpu_to_le32_compile_time (SQUASH_BLOCK_UNCOMPRESSED)))
+ {
+ char *block;
+ grub_size_t csize;
+ csize = grub_le_to_cpu32 (ino->block_sizes[i]) & ~SQUASH_BLOCK_FLAGS;
+ block = grub_malloc (csize);
+ if (!block)
+ return -1;
+ err = grub_disk_read (data->disk,
+ (ino->cumulated_block_sizes[i] + a)
+ >> GRUB_DISK_SECTOR_BITS,
+ (ino->cumulated_block_sizes[i] + a)
+ & (GRUB_DISK_SECTOR_SIZE - 1),
+ csize, block);
+ if (err)
+ {
+ grub_free (block);
+ return -1;
+ }
+ if (data->decompress (block, csize, boff, buf, curread, data)
+ != (grub_ssize_t) curread)
+ {
+ grub_free (block);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_FS, "incorrect compressed chunk");
+ return -1;
+ }
+ grub_free (block);
+ }
+ else
+ err = grub_disk_read (data->disk,
+ (ino->cumulated_block_sizes[i] + a + boff)
+ >> GRUB_DISK_SECTOR_BITS,
+ (ino->cumulated_block_sizes[i] + a + boff)
+ & (GRUB_DISK_SECTOR_SIZE - 1),
+ curread, buf);
+ if (err)
+ return -1;
+ off += curread;
+ len -= curread;
+ buf += curread;
+ cumulated_uncompressed_size += grub_le_to_cpu32 (data->sb.block_size);
+ i++;
+ }
+ return origlen;
+}
+
+
+static grub_ssize_t
+grub_squash_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_squash_data *data = file->data;
+ struct grub_squash_cache_inode *ino = &data->ino;
+ grub_off_t off = file->offset;
+ grub_err_t err;
+ grub_uint64_t a, b;
+ grub_uint32_t fragment = 0;
+ int compressed = 0;
+ struct grub_squash_frag_desc frag;
+ grub_off_t direct_len;
+ grub_uint64_t mask = grub_le_to_cpu32 (data->sb.block_size) - 1;
+ grub_size_t orig_len = len;
+
+ switch (ino->ino.type)
+ {
+ case grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR):
+ fragment = grub_le_to_cpu32 (ino->ino.long_file.fragment);
+ break;
+ case grub_cpu_to_le16_compile_time (SQUASH_TYPE_REGULAR):
+ fragment = grub_le_to_cpu32 (ino->ino.file.fragment);
+ break;
+ }
+
+ /* Squash may pack file tail as fragment. So read initial part directly and
+ get tail from fragments */
+ direct_len = fragment == 0xffffffff ? file->size : file->size & ~mask;
+ if (off < direct_len)
+ {
+ grub_size_t read_len = direct_len - off;
+ grub_ssize_t res;
+
+ if (read_len > len)
+ read_len = len;
+ res = direct_read (data, ino, off, buf, read_len);
+ if ((grub_size_t) res != read_len)
+ return -1; /* FIXME: is short read possible here? */
+ len -= read_len;
+ if (!len)
+ return read_len;
+ buf += read_len;
+ off = 0;
+ }
+ else
+ off -= direct_len;
+
+ err = read_chunk (data, &frag, sizeof (frag),
+ data->fragments, sizeof (frag) * fragment);
+ if (err)
+ return -1;
+ a = grub_le_to_cpu64 (frag.offset);
+ compressed = !(frag.size & grub_cpu_to_le32_compile_time (SQUASH_BLOCK_UNCOMPRESSED));
+ if (ino->ino.type == grub_cpu_to_le16_compile_time (SQUASH_TYPE_LONG_REGULAR))
+ b = grub_le_to_cpu32 (ino->ino.long_file.offset) + off;
+ else
+ b = grub_le_to_cpu32 (ino->ino.file.offset) + off;
+
+ /* FIXME: cache uncompressed chunks. */
+ if (compressed)
+ {
+ char *block;
+ block = grub_malloc (grub_le_to_cpu32 (frag.size));
+ if (!block)
+ return -1;
+ err = grub_disk_read (data->disk,
+ a >> GRUB_DISK_SECTOR_BITS,
+ a & (GRUB_DISK_SECTOR_SIZE - 1),
+ grub_le_to_cpu32 (frag.size), block);
+ if (err)
+ {
+ grub_free (block);
+ return -1;
+ }
+ if (data->decompress (block, grub_le_to_cpu32 (frag.size),
+ b, buf, len, data)
+ != (grub_ssize_t) len)
+ {
+ grub_free (block);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_FS, "incorrect compressed chunk");
+ return -1;
+ }
+ grub_free (block);
+ }
+ else
+ {
+ err = grub_disk_read (data->disk, (a + b) >> GRUB_DISK_SECTOR_BITS,
+ (a + b) & (GRUB_DISK_SECTOR_SIZE - 1), len, buf);
+ if (err)
+ return -1;
+ }
+ return orig_len;
+}
+
+static grub_err_t
+grub_squash_close (grub_file_t file)
+{
+ squash_unmount (file->data);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_squash_mtime (grub_device_t dev, grub_int64_t *tm)
+{
+ struct grub_squash_data *data = 0;
+
+ data = squash_mount (dev->disk);
+ if (! data)
+ return grub_errno;
+ *tm = grub_le_to_cpu32 (data->sb.creation_time);
+ squash_unmount (data);
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_fs grub_squash_fs =
+ {
+ .name = "squash4",
+ .fs_dir = grub_squash_dir,
+ .fs_open = grub_squash_open,
+ .fs_read = grub_squash_read,
+ .fs_close = grub_squash_close,
+ .fs_mtime = grub_squash_mtime,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 0,
+ .blocklist_install = 0,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(squash4)
+{
+ grub_fs_register (&grub_squash_fs);
+}
+
+GRUB_MOD_FINI(squash4)
+{
+ grub_fs_unregister (&grub_squash_fs);
+}
+
diff --git a/grub-core/fs/tar.c b/grub-core/fs/tar.c
new file mode 100644
index 0000000..c551ed6
--- /dev/null
+++ b/grub-core/fs/tar.c
@@ -0,0 +1,345 @@
+/* cpio.c - cpio and tar filesystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009,2013 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/archelp.h>
+
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* tar support */
+#define MAGIC "ustar"
+struct head
+{
+ char name[100];
+ char mode[8];
+ char uid[8];
+ char gid[8];
+ char size[12];
+ char mtime[12];
+ char chksum[8];
+ char typeflag;
+ char linkname[100];
+ char magic[6];
+ char version[2];
+ char uname[32];
+ char gname[32];
+ char devmajor[8];
+ char devminor[8];
+ char prefix[155];
+} GRUB_PACKED;
+
+static inline unsigned long long
+read_number (const char *str, grub_size_t size)
+{
+ unsigned long long ret = 0;
+ while (size-- && *str >= '0' && *str <= '7')
+ ret = (ret << 3) | (*str++ & 0xf);
+ return ret;
+}
+
+struct grub_archelp_data
+{
+ grub_disk_t disk;
+ grub_off_t hofs, next_hofs;
+ grub_off_t dofs;
+ grub_off_t size;
+ char *linkname;
+ grub_size_t linkname_alloc;
+};
+
+static grub_err_t
+grub_cpio_find_file (struct grub_archelp_data *data, char **name,
+ grub_int32_t *mtime,
+ grub_uint32_t *mode)
+{
+ struct head hd;
+ int reread = 0, have_longname = 0, have_longlink = 0;
+
+ data->hofs = data->next_hofs;
+
+ for (reread = 0; reread < 3; reread++)
+ {
+ if (grub_disk_read (data->disk, 0, data->hofs, sizeof (hd), &hd))
+ return grub_errno;
+
+ if (!hd.name[0] && !hd.prefix[0])
+ {
+ *mode = GRUB_ARCHELP_ATTR_END;
+ return GRUB_ERR_NONE;
+ }
+
+ if (grub_memcmp (hd.magic, MAGIC, sizeof (MAGIC) - 1))
+ return grub_error (GRUB_ERR_BAD_FS, "invalid tar archive");
+
+ if (hd.typeflag == 'L')
+ {
+ grub_err_t err;
+ grub_size_t namesize = read_number (hd.size, sizeof (hd.size));
+ *name = grub_malloc (namesize + 1);
+ if (*name == NULL)
+ return grub_errno;
+ err = grub_disk_read (data->disk, 0,
+ data->hofs + GRUB_DISK_SECTOR_SIZE, namesize,
+ *name);
+ (*name)[namesize] = 0;
+ if (err)
+ return err;
+ data->hofs += GRUB_DISK_SECTOR_SIZE
+ + ((namesize + GRUB_DISK_SECTOR_SIZE - 1) &
+ ~(GRUB_DISK_SECTOR_SIZE - 1));
+ have_longname = 1;
+ continue;
+ }
+
+ if (hd.typeflag == 'K')
+ {
+ grub_err_t err;
+ grub_size_t linksize = read_number (hd.size, sizeof (hd.size));
+ if (data->linkname_alloc < linksize + 1)
+ {
+ char *n;
+ n = grub_calloc (2, linksize + 1);
+ if (!n)
+ return grub_errno;
+ grub_free (data->linkname);
+ data->linkname = n;
+ data->linkname_alloc = 2 * (linksize + 1);
+ }
+
+ err = grub_disk_read (data->disk, 0,
+ data->hofs + GRUB_DISK_SECTOR_SIZE, linksize,
+ data->linkname);
+ if (err)
+ return err;
+ data->linkname[linksize] = 0;
+ data->hofs += GRUB_DISK_SECTOR_SIZE
+ + ((linksize + GRUB_DISK_SECTOR_SIZE - 1) &
+ ~(GRUB_DISK_SECTOR_SIZE - 1));
+ have_longlink = 1;
+ continue;
+ }
+
+ if (!have_longname)
+ {
+ grub_size_t extra_size = 0;
+
+ while (extra_size < sizeof (hd.prefix)
+ && hd.prefix[extra_size])
+ extra_size++;
+ *name = grub_malloc (sizeof (hd.name) + extra_size + 2);
+ if (*name == NULL)
+ return grub_errno;
+ if (hd.prefix[0])
+ {
+ grub_memcpy (*name, hd.prefix, extra_size);
+ (*name)[extra_size++] = '/';
+ }
+ grub_memcpy (*name + extra_size, hd.name, sizeof (hd.name));
+ (*name)[extra_size + sizeof (hd.name)] = 0;
+ }
+
+ data->size = read_number (hd.size, sizeof (hd.size));
+ data->dofs = data->hofs + GRUB_DISK_SECTOR_SIZE;
+ data->next_hofs = data->dofs + ((data->size + GRUB_DISK_SECTOR_SIZE - 1) &
+ ~(GRUB_DISK_SECTOR_SIZE - 1));
+ if (mtime)
+ *mtime = read_number (hd.mtime, sizeof (hd.mtime));
+ if (mode)
+ {
+ *mode = read_number (hd.mode, sizeof (hd.mode));
+ switch (hd.typeflag)
+ {
+ /* Hardlink. */
+ case '1':
+ /* Symlink. */
+ case '2':
+ *mode |= GRUB_ARCHELP_ATTR_LNK;
+ break;
+ case '0':
+ *mode |= GRUB_ARCHELP_ATTR_FILE;
+ break;
+ case '5':
+ *mode |= GRUB_ARCHELP_ATTR_DIR;
+ break;
+ }
+ }
+ if (!have_longlink)
+ {
+ if (data->linkname_alloc < 101)
+ {
+ char *n;
+ n = grub_malloc (101);
+ if (!n)
+ return grub_errno;
+ grub_free (data->linkname);
+ data->linkname = n;
+ data->linkname_alloc = 101;
+ }
+ grub_memcpy (data->linkname, hd.linkname, sizeof (hd.linkname));
+ data->linkname[100] = 0;
+ }
+ return GRUB_ERR_NONE;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static char *
+grub_cpio_get_link_target (struct grub_archelp_data *data)
+{
+ return grub_strdup (data->linkname);
+}
+
+static void
+grub_cpio_rewind (struct grub_archelp_data *data)
+{
+ data->next_hofs = 0;
+}
+
+static struct grub_archelp_ops arcops =
+ {
+ .find_file = grub_cpio_find_file,
+ .get_link_target = grub_cpio_get_link_target,
+ .rewind = grub_cpio_rewind
+ };
+
+static struct grub_archelp_data *
+grub_cpio_mount (grub_disk_t disk)
+{
+ struct head hd;
+ struct grub_archelp_data *data;
+
+ if (grub_disk_read (disk, 0, 0, sizeof (hd), &hd))
+ goto fail;
+
+ if (grub_memcmp (hd.magic, MAGIC, sizeof (MAGIC) - 1))
+ goto fail;
+
+ data = (struct grub_archelp_data *) grub_zalloc (sizeof (*data));
+ if (!data)
+ goto fail;
+
+ data->disk = disk;
+
+ return data;
+
+fail:
+ grub_error (GRUB_ERR_BAD_FS, "not a tarfs filesystem");
+ return 0;
+}
+
+static grub_err_t
+grub_cpio_dir (grub_device_t device, const char *path_in,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_archelp_data *data;
+ grub_err_t err;
+
+ data = grub_cpio_mount (device->disk);
+ if (!data)
+ return grub_errno;
+
+ err = grub_archelp_dir (data, &arcops,
+ path_in, hook, hook_data);
+
+ grub_free (data->linkname);
+ grub_free (data);
+
+ return err;
+}
+
+static grub_err_t
+grub_cpio_open (grub_file_t file, const char *name_in)
+{
+ struct grub_archelp_data *data;
+ grub_err_t err;
+
+ data = grub_cpio_mount (file->device->disk);
+ if (!data)
+ return grub_errno;
+
+ err = grub_archelp_open (data, &arcops, name_in);
+ if (err)
+ {
+ grub_free (data->linkname);
+ grub_free (data);
+ }
+ else
+ {
+ file->data = data;
+ file->size = data->size;
+ }
+ return err;
+}
+
+static grub_ssize_t
+grub_cpio_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_archelp_data *data;
+ grub_ssize_t ret;
+
+ data = file->data;
+
+ data->disk->read_hook = file->read_hook;
+ data->disk->read_hook_data = file->read_hook_data;
+ ret = (grub_disk_read (data->disk, 0, data->dofs + file->offset,
+ len, buf)) ? -1 : (grub_ssize_t) len;
+ data->disk->read_hook = 0;
+
+ return ret;
+}
+
+static grub_err_t
+grub_cpio_close (grub_file_t file)
+{
+ struct grub_archelp_data *data;
+
+ data = file->data;
+ grub_free (data->linkname);
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static struct grub_fs grub_cpio_fs = {
+ .name = "tarfs",
+ .fs_dir = grub_cpio_dir,
+ .fs_open = grub_cpio_open,
+ .fs_read = grub_cpio_read,
+ .fs_close = grub_cpio_close,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 0,
+ .blocklist_install = 0,
+#endif
+};
+
+GRUB_MOD_INIT (tar)
+{
+ grub_fs_register (&grub_cpio_fs);
+}
+
+GRUB_MOD_FINI (tar)
+{
+ grub_fs_unregister (&grub_cpio_fs);
+}
diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c
new file mode 100644
index 0000000..2ac5c1d
--- /dev/null
+++ b/grub-core/fs/udf.c
@@ -0,0 +1,1392 @@
+/* udf.c - Universal Disk Format filesystem. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+#include <grub/charset.h>
+#include <grub/datetime.h>
+#include <grub/udf.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_UDF_MAX_PDS 2
+#define GRUB_UDF_MAX_PMS 6
+
+#define U16 grub_le_to_cpu16
+#define U32 grub_le_to_cpu32
+#define U64 grub_le_to_cpu64
+
+#define GRUB_UDF_TAG_IDENT_PVD 0x0001
+#define GRUB_UDF_TAG_IDENT_AVDP 0x0002
+#define GRUB_UDF_TAG_IDENT_VDP 0x0003
+#define GRUB_UDF_TAG_IDENT_IUVD 0x0004
+#define GRUB_UDF_TAG_IDENT_PD 0x0005
+#define GRUB_UDF_TAG_IDENT_LVD 0x0006
+#define GRUB_UDF_TAG_IDENT_USD 0x0007
+#define GRUB_UDF_TAG_IDENT_TD 0x0008
+#define GRUB_UDF_TAG_IDENT_LVID 0x0009
+
+#define GRUB_UDF_TAG_IDENT_FSD 0x0100
+#define GRUB_UDF_TAG_IDENT_FID 0x0101
+#define GRUB_UDF_TAG_IDENT_AED 0x0102
+#define GRUB_UDF_TAG_IDENT_IE 0x0103
+#define GRUB_UDF_TAG_IDENT_TE 0x0104
+#define GRUB_UDF_TAG_IDENT_FE 0x0105
+#define GRUB_UDF_TAG_IDENT_EAHD 0x0106
+#define GRUB_UDF_TAG_IDENT_USE 0x0107
+#define GRUB_UDF_TAG_IDENT_SBD 0x0108
+#define GRUB_UDF_TAG_IDENT_PIE 0x0109
+#define GRUB_UDF_TAG_IDENT_EFE 0x010A
+
+#define GRUB_UDF_ICBTAG_TYPE_UNDEF 0x00
+#define GRUB_UDF_ICBTAG_TYPE_USE 0x01
+#define GRUB_UDF_ICBTAG_TYPE_PIE 0x02
+#define GRUB_UDF_ICBTAG_TYPE_IE 0x03
+#define GRUB_UDF_ICBTAG_TYPE_DIRECTORY 0x04
+#define GRUB_UDF_ICBTAG_TYPE_REGULAR 0x05
+#define GRUB_UDF_ICBTAG_TYPE_BLOCK 0x06
+#define GRUB_UDF_ICBTAG_TYPE_CHAR 0x07
+#define GRUB_UDF_ICBTAG_TYPE_EA 0x08
+#define GRUB_UDF_ICBTAG_TYPE_FIFO 0x09
+#define GRUB_UDF_ICBTAG_TYPE_SOCKET 0x0A
+#define GRUB_UDF_ICBTAG_TYPE_TE 0x0B
+#define GRUB_UDF_ICBTAG_TYPE_SYMLINK 0x0C
+#define GRUB_UDF_ICBTAG_TYPE_STREAMDIR 0x0D
+
+#define GRUB_UDF_ICBTAG_FLAG_AD_MASK 0x0007
+#define GRUB_UDF_ICBTAG_FLAG_AD_SHORT 0x0000
+#define GRUB_UDF_ICBTAG_FLAG_AD_LONG 0x0001
+#define GRUB_UDF_ICBTAG_FLAG_AD_EXT 0x0002
+#define GRUB_UDF_ICBTAG_FLAG_AD_IN_ICB 0x0003
+
+#define GRUB_UDF_EXT_NORMAL 0x00000000
+#define GRUB_UDF_EXT_NREC_ALLOC 0x40000000
+#define GRUB_UDF_EXT_NREC_NALLOC 0x80000000
+#define GRUB_UDF_EXT_MASK 0xC0000000
+
+#define GRUB_UDF_FID_CHAR_HIDDEN 0x01
+#define GRUB_UDF_FID_CHAR_DIRECTORY 0x02
+#define GRUB_UDF_FID_CHAR_DELETED 0x04
+#define GRUB_UDF_FID_CHAR_PARENT 0x08
+#define GRUB_UDF_FID_CHAR_METADATA 0x10
+
+#define GRUB_UDF_STD_IDENT_BEA01 "BEA01"
+#define GRUB_UDF_STD_IDENT_BOOT2 "BOOT2"
+#define GRUB_UDF_STD_IDENT_CD001 "CD001"
+#define GRUB_UDF_STD_IDENT_CDW02 "CDW02"
+#define GRUB_UDF_STD_IDENT_NSR02 "NSR02"
+#define GRUB_UDF_STD_IDENT_NSR03 "NSR03"
+#define GRUB_UDF_STD_IDENT_TEA01 "TEA01"
+
+#define GRUB_UDF_CHARSPEC_TYPE_CS0 0x00
+#define GRUB_UDF_CHARSPEC_TYPE_CS1 0x01
+#define GRUB_UDF_CHARSPEC_TYPE_CS2 0x02
+#define GRUB_UDF_CHARSPEC_TYPE_CS3 0x03
+#define GRUB_UDF_CHARSPEC_TYPE_CS4 0x04
+#define GRUB_UDF_CHARSPEC_TYPE_CS5 0x05
+#define GRUB_UDF_CHARSPEC_TYPE_CS6 0x06
+#define GRUB_UDF_CHARSPEC_TYPE_CS7 0x07
+#define GRUB_UDF_CHARSPEC_TYPE_CS8 0x08
+
+#define GRUB_UDF_PARTMAP_TYPE_1 1
+#define GRUB_UDF_PARTMAP_TYPE_2 2
+
+struct grub_udf_lb_addr
+{
+ grub_uint32_t block_num;
+ grub_uint16_t part_ref;
+} GRUB_PACKED;
+
+struct grub_udf_short_ad
+{
+ grub_uint32_t length;
+ grub_uint32_t position;
+} GRUB_PACKED;
+
+struct grub_udf_long_ad
+{
+ grub_uint32_t length;
+ struct grub_udf_lb_addr block;
+ grub_uint8_t imp_use[6];
+} GRUB_PACKED;
+
+struct grub_udf_extent_ad
+{
+ grub_uint32_t length;
+ grub_uint32_t start;
+} GRUB_PACKED;
+
+struct grub_udf_charspec
+{
+ grub_uint8_t charset_type;
+ grub_uint8_t charset_info[63];
+} GRUB_PACKED;
+
+struct grub_udf_timestamp
+{
+ grub_uint16_t type_and_timezone;
+ grub_uint16_t year;
+ grub_uint8_t month;
+ grub_uint8_t day;
+ grub_uint8_t hour;
+ grub_uint8_t minute;
+ grub_uint8_t second;
+ grub_uint8_t centi_seconds;
+ grub_uint8_t hundreds_of_micro_seconds;
+ grub_uint8_t micro_seconds;
+} GRUB_PACKED;
+
+struct grub_udf_regid
+{
+ grub_uint8_t flags;
+ grub_uint8_t ident[23];
+ grub_uint8_t ident_suffix[8];
+} GRUB_PACKED;
+
+struct grub_udf_tag
+{
+ grub_uint16_t tag_ident;
+ grub_uint16_t desc_version;
+ grub_uint8_t tag_checksum;
+ grub_uint8_t reserved;
+ grub_uint16_t tag_serial_number;
+ grub_uint16_t desc_crc;
+ grub_uint16_t desc_crc_length;
+ grub_uint32_t tag_location;
+} GRUB_PACKED;
+
+struct grub_udf_fileset
+{
+ struct grub_udf_tag tag;
+ struct grub_udf_timestamp datetime;
+ grub_uint16_t interchange_level;
+ grub_uint16_t max_interchange_level;
+ grub_uint32_t charset_list;
+ grub_uint32_t max_charset_list;
+ grub_uint32_t fileset_num;
+ grub_uint32_t fileset_desc_num;
+ struct grub_udf_charspec vol_charset;
+ grub_uint8_t vol_ident[128];
+ struct grub_udf_charspec fileset_charset;
+ grub_uint8_t fileset_ident[32];
+ grub_uint8_t copyright_file_ident[32];
+ grub_uint8_t abstract_file_ident[32];
+ struct grub_udf_long_ad root_icb;
+ struct grub_udf_regid domain_ident;
+ struct grub_udf_long_ad next_ext;
+ struct grub_udf_long_ad streamdir_icb;
+} GRUB_PACKED;
+
+struct grub_udf_icbtag
+{
+ grub_uint32_t prior_recorded_num_direct_entries;
+ grub_uint16_t strategy_type;
+ grub_uint16_t strategy_parameter;
+ grub_uint16_t num_entries;
+ grub_uint8_t reserved;
+ grub_uint8_t file_type;
+ struct grub_udf_lb_addr parent_idb;
+ grub_uint16_t flags;
+} GRUB_PACKED;
+
+struct grub_udf_file_ident
+{
+ struct grub_udf_tag tag;
+ grub_uint16_t version_num;
+ grub_uint8_t characteristics;
+#define MAX_FILE_IDENT_LENGTH 256
+ grub_uint8_t file_ident_length;
+ struct grub_udf_long_ad icb;
+ grub_uint16_t imp_use_length;
+} GRUB_PACKED;
+
+struct grub_udf_file_entry
+{
+ struct grub_udf_tag tag;
+ struct grub_udf_icbtag icbtag;
+ grub_uint32_t uid;
+ grub_uint32_t gid;
+ grub_uint32_t permissions;
+ grub_uint16_t link_count;
+ grub_uint8_t record_format;
+ grub_uint8_t record_display_attr;
+ grub_uint32_t record_length;
+ grub_uint64_t file_size;
+ grub_uint64_t blocks_recorded;
+ struct grub_udf_timestamp access_time;
+ struct grub_udf_timestamp modification_time;
+ struct grub_udf_timestamp attr_time;
+ grub_uint32_t checkpoint;
+ struct grub_udf_long_ad extended_attr_idb;
+ struct grub_udf_regid imp_ident;
+ grub_uint64_t unique_id;
+ grub_uint32_t ext_attr_length;
+ grub_uint32_t alloc_descs_length;
+ grub_uint8_t ext_attr[0];
+} GRUB_PACKED;
+
+struct grub_udf_extended_file_entry
+{
+ struct grub_udf_tag tag;
+ struct grub_udf_icbtag icbtag;
+ grub_uint32_t uid;
+ grub_uint32_t gid;
+ grub_uint32_t permissions;
+ grub_uint16_t link_count;
+ grub_uint8_t record_format;
+ grub_uint8_t record_display_attr;
+ grub_uint32_t record_length;
+ grub_uint64_t file_size;
+ grub_uint64_t object_size;
+ grub_uint64_t blocks_recorded;
+ struct grub_udf_timestamp access_time;
+ struct grub_udf_timestamp modification_time;
+ struct grub_udf_timestamp create_time;
+ struct grub_udf_timestamp attr_time;
+ grub_uint32_t checkpoint;
+ grub_uint32_t reserved;
+ struct grub_udf_long_ad extended_attr_icb;
+ struct grub_udf_long_ad streamdir_icb;
+ struct grub_udf_regid imp_ident;
+ grub_uint64_t unique_id;
+ grub_uint32_t ext_attr_length;
+ grub_uint32_t alloc_descs_length;
+ grub_uint8_t ext_attr[0];
+} GRUB_PACKED;
+
+struct grub_udf_vrs
+{
+ grub_uint8_t type;
+ grub_uint8_t magic[5];
+ grub_uint8_t version;
+} GRUB_PACKED;
+
+struct grub_udf_avdp
+{
+ struct grub_udf_tag tag;
+ struct grub_udf_extent_ad vds;
+} GRUB_PACKED;
+
+struct grub_udf_pd
+{
+ struct grub_udf_tag tag;
+ grub_uint32_t seq_num;
+ grub_uint16_t flags;
+ grub_uint16_t part_num;
+ struct grub_udf_regid contents;
+ grub_uint8_t contents_use[128];
+ grub_uint32_t access_type;
+ grub_uint32_t start;
+ grub_uint32_t length;
+} GRUB_PACKED;
+
+struct grub_udf_partmap
+{
+ grub_uint8_t type;
+ grub_uint8_t length;
+ union
+ {
+ struct
+ {
+ grub_uint16_t seq_num;
+ grub_uint16_t part_num;
+ } type1;
+
+ struct
+ {
+ grub_uint8_t ident[62];
+ } type2;
+ };
+} GRUB_PACKED;
+
+struct grub_udf_pvd
+{
+ struct grub_udf_tag tag;
+ grub_uint32_t seq_num;
+ grub_uint32_t pvd_num;
+ grub_uint8_t ident[32];
+ grub_uint16_t vol_seq_num;
+ grub_uint16_t max_vol_seq_num;
+ grub_uint16_t interchange_level;
+ grub_uint16_t max_interchange_level;
+ grub_uint32_t charset_list;
+ grub_uint32_t max_charset_list;
+ grub_uint8_t volset_ident[128];
+ struct grub_udf_charspec desc_charset;
+ struct grub_udf_charspec expl_charset;
+ struct grub_udf_extent_ad vol_abstract;
+ struct grub_udf_extent_ad vol_copyright;
+ struct grub_udf_regid app_ident;
+ struct grub_udf_timestamp recording_time;
+ struct grub_udf_regid imp_ident;
+ grub_uint8_t imp_use[64];
+ grub_uint32_t pred_vds_loc;
+ grub_uint16_t flags;
+ grub_uint8_t reserved[22];
+} GRUB_PACKED;
+
+struct grub_udf_lvd
+{
+ struct grub_udf_tag tag;
+ grub_uint32_t seq_num;
+ struct grub_udf_charspec charset;
+ grub_uint8_t ident[128];
+ grub_uint32_t bsize;
+ struct grub_udf_regid domain_ident;
+ struct grub_udf_long_ad root_fileset;
+ grub_uint32_t map_table_length;
+ grub_uint32_t num_part_maps;
+ struct grub_udf_regid imp_ident;
+ grub_uint8_t imp_use[128];
+ struct grub_udf_extent_ad integrity_seq_ext;
+ grub_uint8_t part_maps[1608];
+} GRUB_PACKED;
+
+struct grub_udf_aed
+{
+ struct grub_udf_tag tag;
+ grub_uint32_t prev_ae;
+ grub_uint32_t ae_len;
+} GRUB_PACKED;
+
+struct grub_udf_data
+{
+ grub_disk_t disk;
+ struct grub_udf_pvd pvd;
+ struct grub_udf_lvd lvd;
+ struct grub_udf_pd pds[GRUB_UDF_MAX_PDS];
+ struct grub_udf_partmap *pms[GRUB_UDF_MAX_PMS];
+ struct grub_udf_long_ad root_icb;
+ int npd, npm, lbshift;
+};
+
+struct grub_fshelp_node
+{
+ struct grub_udf_data *data;
+ int part_ref;
+ union
+ {
+ struct grub_udf_file_entry fe;
+ struct grub_udf_extended_file_entry efe;
+ char raw[0];
+ } block;
+};
+
+static inline grub_size_t
+get_fshelp_size (struct grub_udf_data *data)
+{
+ struct grub_fshelp_node *x = NULL;
+ return sizeof (*x)
+ + (1 << (GRUB_DISK_SECTOR_BITS
+ + data->lbshift)) - sizeof (x->block);
+}
+
+static grub_dl_t my_mod;
+
+static grub_uint32_t
+grub_udf_get_block (struct grub_udf_data *data,
+ grub_uint16_t part_ref, grub_uint32_t block)
+{
+ part_ref = U16 (part_ref);
+
+ if (part_ref >= data->npm)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid part ref");
+ return 0;
+ }
+
+ return (U32 (data->pds[data->pms[part_ref]->type1.part_num].start)
+ + U32 (block));
+}
+
+static grub_err_t
+grub_udf_read_icb (struct grub_udf_data *data,
+ struct grub_udf_long_ad *icb,
+ struct grub_fshelp_node *node)
+{
+ grub_uint32_t block;
+
+ block = grub_udf_get_block (data,
+ icb->block.part_ref,
+ icb->block.block_num);
+
+ if (grub_errno)
+ return grub_errno;
+
+ if (grub_disk_read (data->disk, block << data->lbshift, 0,
+ 1 << (GRUB_DISK_SECTOR_BITS
+ + data->lbshift),
+ &node->block))
+ return grub_errno;
+
+ if ((U16 (node->block.fe.tag.tag_ident) != GRUB_UDF_TAG_IDENT_FE) &&
+ (U16 (node->block.fe.tag.tag_ident) != GRUB_UDF_TAG_IDENT_EFE))
+ return grub_error (GRUB_ERR_BAD_FS, "invalid fe/efe descriptor");
+
+ node->part_ref = icb->block.part_ref;
+ node->data = data;
+ return 0;
+}
+
+static grub_disk_addr_t
+grub_udf_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
+{
+ char *buf = NULL;
+ char *ptr;
+ grub_ssize_t len;
+ grub_disk_addr_t filebytes;
+
+ switch (U16 (node->block.fe.tag.tag_ident))
+ {
+ case GRUB_UDF_TAG_IDENT_FE:
+ ptr = (char *) &node->block.fe.ext_attr[0] + U32 (node->block.fe.ext_attr_length);
+ len = U32 (node->block.fe.alloc_descs_length);
+ break;
+
+ case GRUB_UDF_TAG_IDENT_EFE:
+ ptr = (char *) &node->block.efe.ext_attr[0] + U32 (node->block.efe.ext_attr_length);
+ len = U32 (node->block.efe.alloc_descs_length);
+ break;
+
+ default:
+ grub_error (GRUB_ERR_BAD_FS, "invalid file entry");
+ return 0;
+ }
+
+ if ((U16 (node->block.fe.icbtag.flags) & GRUB_UDF_ICBTAG_FLAG_AD_MASK)
+ == GRUB_UDF_ICBTAG_FLAG_AD_SHORT)
+ {
+ struct grub_udf_short_ad *ad = (struct grub_udf_short_ad *) ptr;
+
+ filebytes = fileblock * U32 (node->data->lvd.bsize);
+ while (len >= (grub_ssize_t) sizeof (struct grub_udf_short_ad))
+ {
+ grub_uint32_t adlen = U32 (ad->length) & 0x3fffffff;
+ grub_uint32_t adtype = U32 (ad->length) >> 30;
+ if (adtype == 3)
+ {
+ struct grub_udf_aed *extension;
+ grub_disk_addr_t sec = grub_udf_get_block(node->data,
+ node->part_ref,
+ ad->position);
+ if (!buf)
+ {
+ buf = grub_malloc (U32 (node->data->lvd.bsize));
+ if (!buf)
+ return 0;
+ }
+ if (grub_disk_read (node->data->disk, sec << node->data->lbshift,
+ 0, adlen, buf))
+ goto fail;
+
+ extension = (struct grub_udf_aed *) buf;
+ if (U16 (extension->tag.tag_ident) != GRUB_UDF_TAG_IDENT_AED)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid aed tag");
+ goto fail;
+ }
+
+ len = U32 (extension->ae_len);
+ ad = (struct grub_udf_short_ad *)
+ (buf + sizeof (struct grub_udf_aed));
+ continue;
+ }
+
+ if (filebytes < adlen)
+ {
+ grub_uint32_t ad_pos = ad->position;
+ grub_free (buf);
+ return ((U32 (ad_pos) & GRUB_UDF_EXT_MASK) ? 0 :
+ (grub_udf_get_block (node->data, node->part_ref, ad_pos)
+ + (filebytes >> (GRUB_DISK_SECTOR_BITS
+ + node->data->lbshift))));
+ }
+
+ filebytes -= adlen;
+ ad++;
+ len -= sizeof (struct grub_udf_short_ad);
+ }
+ }
+ else
+ {
+ struct grub_udf_long_ad *ad = (struct grub_udf_long_ad *) ptr;
+
+ filebytes = fileblock * U32 (node->data->lvd.bsize);
+ while (len >= (grub_ssize_t) sizeof (struct grub_udf_long_ad))
+ {
+ grub_uint32_t adlen = U32 (ad->length) & 0x3fffffff;
+ grub_uint32_t adtype = U32 (ad->length) >> 30;
+ if (adtype == 3)
+ {
+ struct grub_udf_aed *extension;
+ grub_disk_addr_t sec = grub_udf_get_block(node->data,
+ ad->block.part_ref,
+ ad->block.block_num);
+ if (!buf)
+ {
+ buf = grub_malloc (U32 (node->data->lvd.bsize));
+ if (!buf)
+ return 0;
+ }
+ if (grub_disk_read (node->data->disk, sec << node->data->lbshift,
+ 0, adlen, buf))
+ goto fail;
+
+ extension = (struct grub_udf_aed *) buf;
+ if (U16 (extension->tag.tag_ident) != GRUB_UDF_TAG_IDENT_AED)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid aed tag");
+ goto fail;
+ }
+
+ len = U32 (extension->ae_len);
+ ad = (struct grub_udf_long_ad *)
+ (buf + sizeof (struct grub_udf_aed));
+ continue;
+ }
+
+ if (filebytes < adlen)
+ {
+ grub_uint32_t ad_block_num = ad->block.block_num;
+ grub_uint32_t ad_part_ref = ad->block.part_ref;
+ grub_free (buf);
+ return ((U32 (ad_block_num) & GRUB_UDF_EXT_MASK) ? 0 :
+ (grub_udf_get_block (node->data, ad_part_ref,
+ ad_block_num)
+ + (filebytes >> (GRUB_DISK_SECTOR_BITS
+ + node->data->lbshift))));
+ }
+
+ filebytes -= adlen;
+ ad++;
+ len -= sizeof (struct grub_udf_long_ad);
+ }
+ }
+
+fail:
+ grub_free (buf);
+
+ return 0;
+}
+
+static grub_ssize_t
+grub_udf_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)
+{
+ switch (U16 (node->block.fe.icbtag.flags) & GRUB_UDF_ICBTAG_FLAG_AD_MASK)
+ {
+ case GRUB_UDF_ICBTAG_FLAG_AD_IN_ICB:
+ {
+ char *ptr;
+
+ ptr = ((U16 (node->block.fe.tag.tag_ident) == GRUB_UDF_TAG_IDENT_FE) ?
+ ((char *) &node->block.fe.ext_attr[0]
+ + U32 (node->block.fe.ext_attr_length)) :
+ ((char *) &node->block.efe.ext_attr[0]
+ + U32 (node->block.efe.ext_attr_length)));
+
+ grub_memcpy (buf, ptr + pos, len);
+
+ return len;
+ }
+
+ case GRUB_UDF_ICBTAG_FLAG_AD_EXT:
+ grub_error (GRUB_ERR_BAD_FS, "invalid extent type");
+ return 0;
+ }
+
+ return grub_fshelp_read_file (node->data->disk, node,
+ read_hook, read_hook_data,
+ pos, len, buf, grub_udf_read_block,
+ U64 (node->block.fe.file_size),
+ node->data->lbshift, 0);
+}
+
+static unsigned sblocklist[] = { 256, 512, 0 };
+
+static struct grub_udf_data *
+grub_udf_mount (grub_disk_t disk)
+{
+ struct grub_udf_data *data = 0;
+ struct grub_udf_fileset root_fs;
+ unsigned *sblklist;
+ grub_uint32_t block, vblock;
+ int i, lbshift;
+
+ data = grub_malloc (sizeof (struct grub_udf_data));
+ if (!data)
+ return 0;
+
+ data->disk = disk;
+
+ /* Search for Anchor Volume Descriptor Pointer (AVDP)
+ * and determine logical block size. */
+ block = 0;
+ for (lbshift = 0; lbshift < 4; lbshift++)
+ {
+ for (sblklist = sblocklist; *sblklist; sblklist++)
+ {
+ struct grub_udf_avdp avdp;
+
+ if (grub_disk_read (disk, *sblklist << lbshift, 0,
+ sizeof (struct grub_udf_avdp), &avdp))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
+ goto fail;
+ }
+
+ if (U16 (avdp.tag.tag_ident) == GRUB_UDF_TAG_IDENT_AVDP &&
+ U32 (avdp.tag.tag_location) == *sblklist)
+ {
+ block = U32 (avdp.vds.start);
+ break;
+ }
+ }
+
+ if (block)
+ break;
+ }
+
+ if (!block)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
+ goto fail;
+ }
+ data->lbshift = lbshift;
+
+ /* Search for Volume Recognition Sequence (VRS). */
+ for (vblock = (32767 >> (lbshift + GRUB_DISK_SECTOR_BITS)) + 1;;
+ vblock += (2047 >> (lbshift + GRUB_DISK_SECTOR_BITS)) + 1)
+ {
+ struct grub_udf_vrs vrs;
+
+ if (grub_disk_read (disk, vblock << lbshift, 0,
+ sizeof (struct grub_udf_vrs), &vrs))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
+ goto fail;
+ }
+
+ if ((!grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_NSR03, 5)) ||
+ (!grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_NSR02, 5)))
+ break;
+
+ if ((grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_BEA01, 5)) &&
+ (grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_BOOT2, 5)) &&
+ (grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_CD001, 5)) &&
+ (grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_CDW02, 5)) &&
+ (grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_TEA01, 5)))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
+ goto fail;
+ }
+ }
+
+ data->npd = data->npm = 0;
+ /* Locate Partition Descriptor (PD) and Logical Volume Descriptor (LVD). */
+ while (1)
+ {
+ struct grub_udf_tag tag;
+
+ if (grub_disk_read (disk, block << lbshift, 0,
+ sizeof (struct grub_udf_tag), &tag))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
+ goto fail;
+ }
+
+ tag.tag_ident = U16 (tag.tag_ident);
+ if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PVD)
+ {
+ if (grub_disk_read (disk, block << lbshift, 0,
+ sizeof (struct grub_udf_pvd),
+ &data->pvd))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
+ goto fail;
+ }
+ }
+ else if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PD)
+ {
+ if (data->npd >= GRUB_UDF_MAX_PDS)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "too many PDs");
+ goto fail;
+ }
+
+ if (grub_disk_read (disk, block << lbshift, 0,
+ sizeof (struct grub_udf_pd),
+ &data->pds[data->npd]))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
+ goto fail;
+ }
+
+ data->npd++;
+ }
+ else if (tag.tag_ident == GRUB_UDF_TAG_IDENT_LVD)
+ {
+ int k;
+
+ struct grub_udf_partmap *ppm;
+
+ if (grub_disk_read (disk, block << lbshift, 0,
+ sizeof (struct grub_udf_lvd),
+ &data->lvd))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
+ goto fail;
+ }
+
+ if (data->npm + U32 (data->lvd.num_part_maps) > GRUB_UDF_MAX_PMS)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "too many partition maps");
+ goto fail;
+ }
+
+ ppm = (struct grub_udf_partmap *) &data->lvd.part_maps;
+ for (k = U32 (data->lvd.num_part_maps); k > 0; k--)
+ {
+ if (ppm->type != GRUB_UDF_PARTMAP_TYPE_1)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "partmap type not supported");
+ goto fail;
+ }
+
+ data->pms[data->npm++] = ppm;
+ ppm = (struct grub_udf_partmap *) ((char *) ppm +
+ U32 (ppm->length));
+ }
+ }
+ else if (tag.tag_ident > GRUB_UDF_TAG_IDENT_TD)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid tag ident");
+ goto fail;
+ }
+ else if (tag.tag_ident == GRUB_UDF_TAG_IDENT_TD)
+ break;
+
+ block++;
+ }
+
+ for (i = 0; i < data->npm; i++)
+ {
+ int j;
+
+ for (j = 0; j < data->npd; j++)
+ if (data->pms[i]->type1.part_num == data->pds[j].part_num)
+ {
+ data->pms[i]->type1.part_num = j;
+ break;
+ }
+
+ if (j == data->npd)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "can\'t find PD");
+ goto fail;
+ }
+ }
+
+ block = grub_udf_get_block (data,
+ data->lvd.root_fileset.block.part_ref,
+ data->lvd.root_fileset.block.block_num);
+
+ if (grub_errno)
+ goto fail;
+
+ if (grub_disk_read (disk, block << lbshift, 0,
+ sizeof (struct grub_udf_fileset), &root_fs))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
+ goto fail;
+ }
+
+ if (U16 (root_fs.tag.tag_ident) != GRUB_UDF_TAG_IDENT_FSD)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid fileset descriptor");
+ goto fail;
+ }
+
+ data->root_icb = root_fs.root_icb;
+
+ return data;
+
+fail:
+ grub_free (data);
+ return 0;
+}
+
+#ifdef GRUB_UTIL
+grub_disk_addr_t
+grub_udf_get_cluster_sector (grub_disk_t disk, grub_uint64_t *sec_per_lcn)
+{
+ grub_disk_addr_t ret;
+ static struct grub_udf_data *data;
+
+ data = grub_udf_mount (disk);
+ if (!data)
+ return 0;
+
+ ret = U32 (data->pds[data->pms[0]->type1.part_num].start);
+ *sec_per_lcn = 1ULL << data->lbshift;
+ grub_free (data);
+ return ret;
+}
+#endif
+
+static char *
+read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf)
+{
+ grub_uint16_t *utf16 = NULL;
+ grub_size_t utf16len = 0;
+
+ if (sz == 0)
+ return NULL;
+
+ if (raw[0] != 8 && raw[0] != 16)
+ return NULL;
+
+ if (raw[0] == 8)
+ {
+ unsigned i;
+ utf16len = sz - 1;
+ utf16 = grub_calloc (utf16len, sizeof (utf16[0]));
+ if (!utf16)
+ return NULL;
+ for (i = 0; i < utf16len; i++)
+ utf16[i] = raw[i + 1];
+ }
+ if (raw[0] == 16)
+ {
+ unsigned i;
+ utf16len = (sz - 1) / 2;
+ utf16 = grub_calloc (utf16len, sizeof (utf16[0]));
+ if (!utf16)
+ return NULL;
+ for (i = 0; i < utf16len; i++)
+ utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2];
+ }
+ if (!outbuf)
+ {
+ grub_size_t size;
+
+ if (grub_mul (utf16len, GRUB_MAX_UTF8_PER_UTF16, &size) ||
+ grub_add (size, 1, &size))
+ goto fail;
+
+ outbuf = grub_malloc (size);
+ }
+ if (outbuf)
+ *grub_utf16_to_utf8 ((grub_uint8_t *) outbuf, utf16, utf16len) = '\0';
+
+ fail:
+ grub_free (utf16);
+ return outbuf;
+}
+
+static char *
+read_dstring (const grub_uint8_t *raw, grub_size_t sz)
+{
+ grub_size_t len;
+
+ if (raw[0] == 0) {
+ char *outbuf = grub_malloc (1);
+ if (!outbuf)
+ return NULL;
+ outbuf[0] = 0;
+ return outbuf;
+ }
+
+ len = raw[sz - 1];
+ if (len > sz - 1)
+ len = sz - 1;
+ return read_string (raw, len, NULL);
+}
+
+static int
+grub_udf_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ grub_fshelp_node_t child;
+ struct grub_udf_file_ident dirent;
+ grub_off_t offset = 0;
+
+ child = grub_malloc (get_fshelp_size (dir->data));
+ if (!child)
+ return 0;
+
+ /* The current directory is not stored. */
+ grub_memcpy (child, dir, get_fshelp_size (dir->data));
+
+ if (hook (".", GRUB_FSHELP_DIR, child, hook_data))
+ return 1;
+
+ while (offset < U64 (dir->block.fe.file_size))
+ {
+ if (grub_udf_read_file (dir, 0, 0, offset, sizeof (dirent),
+ (char *) &dirent) != sizeof (dirent))
+ return 0;
+
+ if (U16 (dirent.tag.tag_ident) != GRUB_UDF_TAG_IDENT_FID)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid fid tag");
+ return 0;
+ }
+
+ offset += sizeof (dirent) + U16 (dirent.imp_use_length);
+ if (!(dirent.characteristics & GRUB_UDF_FID_CHAR_DELETED))
+ {
+ child = grub_malloc (get_fshelp_size (dir->data));
+ if (!child)
+ return 0;
+
+ if (grub_udf_read_icb (dir->data, &dirent.icb, child))
+ {
+ grub_free (child);
+ return 0;
+ }
+ if (dirent.characteristics & GRUB_UDF_FID_CHAR_PARENT)
+ {
+ /* This is the parent directory. */
+ if (hook ("..", GRUB_FSHELP_DIR, child, hook_data))
+ return 1;
+ }
+ else
+ {
+ enum grub_fshelp_filetype type;
+ char *filename;
+ grub_uint8_t raw[MAX_FILE_IDENT_LENGTH];
+
+ type = ((dirent.characteristics & GRUB_UDF_FID_CHAR_DIRECTORY) ?
+ (GRUB_FSHELP_DIR) : (GRUB_FSHELP_REG));
+ if (child->block.fe.icbtag.file_type == GRUB_UDF_ICBTAG_TYPE_SYMLINK)
+ type = GRUB_FSHELP_SYMLINK;
+
+ if ((grub_udf_read_file (dir, 0, 0, offset,
+ dirent.file_ident_length,
+ (char *) raw))
+ != dirent.file_ident_length)
+ {
+ grub_free (child);
+ return 0;
+ }
+
+ filename = read_string (raw, dirent.file_ident_length, 0);
+ if (!filename)
+ {
+ /* As the hook won't get called. */
+ grub_free (child);
+ grub_print_error ();
+ }
+
+ if (filename && hook (filename, type, child, hook_data))
+ {
+ grub_free (filename);
+ return 1;
+ }
+ grub_free (filename);
+ }
+ }
+
+ /* Align to dword boundary. */
+ offset = (offset + dirent.file_ident_length + 3) & (~3);
+ }
+
+ return 0;
+}
+
+static char *
+grub_udf_read_symlink (grub_fshelp_node_t node)
+{
+ grub_size_t sz = U64 (node->block.fe.file_size);
+ grub_uint8_t *raw;
+ const grub_uint8_t *ptr;
+ char *out = NULL, *optr;
+
+ if (sz < 4)
+ return NULL;
+ raw = grub_malloc (sz);
+ if (!raw)
+ return NULL;
+ if (grub_udf_read_file (node, NULL, NULL, 0, sz, (char *) raw) < 0)
+ goto fail_1;
+
+ if (grub_mul (sz, 2, &sz) ||
+ grub_add (sz, 1, &sz))
+ goto fail_0;
+
+ out = grub_malloc (sz);
+ if (!out)
+ {
+ fail_0:
+ grub_free (raw);
+ return NULL;
+ }
+
+ optr = out;
+
+ for (ptr = raw; ptr < raw + sz; )
+ {
+ grub_size_t s;
+ if ((grub_size_t) (ptr - raw + 4) > sz)
+ goto fail_1;
+ if (!(ptr[2] == 0 && ptr[3] == 0))
+ goto fail_1;
+ s = 4 + ptr[1];
+ if ((grub_size_t) (ptr - raw + s) > sz)
+ goto fail_1;
+ switch (*ptr)
+ {
+ case 1:
+ if (ptr[1])
+ goto fail_1;
+ /* Fallthrough. */
+ case 2:
+ /* in 4 bytes. out: 1 byte. */
+ optr = out;
+ *optr++ = '/';
+ break;
+ case 3:
+ /* in 4 bytes. out: 3 bytes. */
+ if (optr != out)
+ *optr++ = '/';
+ *optr++ = '.';
+ *optr++ = '.';
+ break;
+ case 4:
+ /* in 4 bytes. out: 2 bytes. */
+ if (optr != out)
+ *optr++ = '/';
+ *optr++ = '.';
+ break;
+ case 5:
+ /* in 4 + n bytes. out, at most: 1 + 2 * n bytes. */
+ if (optr != out)
+ *optr++ = '/';
+ if (!read_string (ptr + 4, s - 4, optr))
+ goto fail_1;
+ optr += grub_strlen (optr);
+ break;
+ default:
+ goto fail_1;
+ }
+ ptr += s;
+ }
+ *optr = 0;
+ grub_free (raw);
+ return out;
+
+ fail_1:
+ grub_free (raw);
+ grub_free (out);
+ grub_error (GRUB_ERR_BAD_FS, "invalid symlink");
+ return NULL;
+}
+
+/* Context for grub_udf_dir. */
+struct grub_udf_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_udf_dir. */
+static int
+grub_udf_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_udf_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+ const struct grub_udf_timestamp *tstamp = NULL;
+
+ grub_memset (&info, 0, sizeof (info));
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ if (U16 (node->block.fe.tag.tag_ident) == GRUB_UDF_TAG_IDENT_FE)
+ tstamp = &node->block.fe.modification_time;
+ else if (U16 (node->block.fe.tag.tag_ident) == GRUB_UDF_TAG_IDENT_EFE)
+ tstamp = &node->block.efe.modification_time;
+
+ if (tstamp && (U16 (tstamp->type_and_timezone) & 0xf000) == 0x1000)
+ {
+ grub_int16_t tz;
+ struct grub_datetime datetime;
+
+ datetime.year = U16 (tstamp->year);
+ datetime.month = tstamp->month;
+ datetime.day = tstamp->day;
+ datetime.hour = tstamp->hour;
+ datetime.minute = tstamp->minute;
+ datetime.second = tstamp->second;
+
+ tz = U16 (tstamp->type_and_timezone) & 0xfff;
+ if (tz & 0x800)
+ tz |= 0xf000;
+ if (tz == -2047)
+ tz = 0;
+
+ info.mtimeset = !!grub_datetime2unixtime (&datetime, &info.mtime);
+
+ info.mtime -= 60 * tz;
+ }
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_udf_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_udf_dir_ctx ctx = { hook, hook_data };
+ struct grub_udf_data *data = 0;
+ struct grub_fshelp_node *rootnode = 0;
+ struct grub_fshelp_node *foundnode = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_udf_mount (device->disk);
+ if (!data)
+ goto fail;
+
+ rootnode = grub_malloc (get_fshelp_size (data));
+ if (!rootnode)
+ goto fail;
+
+ if (grub_udf_read_icb (data, &data->root_icb, rootnode))
+ goto fail;
+
+ if (grub_fshelp_find_file (path, rootnode,
+ &foundnode,
+ grub_udf_iterate_dir, grub_udf_read_symlink,
+ GRUB_FSHELP_DIR))
+ goto fail;
+
+ grub_udf_iterate_dir (foundnode, grub_udf_dir_iter, &ctx);
+
+ if (foundnode != rootnode)
+ grub_free (foundnode);
+
+fail:
+ grub_free (rootnode);
+
+ grub_free (data);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_udf_open (struct grub_file *file, const char *name)
+{
+ struct grub_udf_data *data;
+ struct grub_fshelp_node *rootnode = 0;
+ struct grub_fshelp_node *foundnode;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_udf_mount (file->device->disk);
+ if (!data)
+ goto fail;
+
+ rootnode = grub_malloc (get_fshelp_size (data));
+ if (!rootnode)
+ goto fail;
+
+ if (grub_udf_read_icb (data, &data->root_icb, rootnode))
+ goto fail;
+
+ if (grub_fshelp_find_file (name, rootnode,
+ &foundnode,
+ grub_udf_iterate_dir, grub_udf_read_symlink,
+ GRUB_FSHELP_REG))
+ goto fail;
+
+ file->data = foundnode;
+ file->offset = 0;
+ file->size = U64 (foundnode->block.fe.file_size);
+
+ grub_free (rootnode);
+
+ return 0;
+
+fail:
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+ grub_free (rootnode);
+
+ return grub_errno;
+}
+
+static grub_ssize_t
+grub_udf_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_fshelp_node *node = (struct grub_fshelp_node *) file->data;
+
+ return grub_udf_read_file (node, file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+static grub_err_t
+grub_udf_close (grub_file_t file)
+{
+ if (file->data)
+ {
+ struct grub_fshelp_node *node = (struct grub_fshelp_node *) file->data;
+
+ grub_free (node->data);
+ grub_free (node);
+ }
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_udf_label (grub_device_t device, char **label)
+{
+ struct grub_udf_data *data;
+ data = grub_udf_mount (device->disk);
+
+ if (data)
+ {
+ *label = read_dstring (data->lvd.ident, sizeof (data->lvd.ident));
+ grub_free (data);
+ }
+ else
+ *label = 0;
+
+ return grub_errno;
+}
+
+static char *
+gen_uuid_from_volset (char *volset_ident)
+{
+ grub_size_t i;
+ grub_size_t len;
+ grub_size_t nonhexpos;
+ grub_uint8_t buf[17];
+ char *uuid;
+
+ len = grub_strlen (volset_ident);
+ if (len < 8)
+ return NULL;
+
+ uuid = grub_malloc (17);
+ if (!uuid)
+ return NULL;
+
+ if (len > 16)
+ len = 16;
+
+ grub_memset (buf, 0, sizeof (buf));
+ grub_memcpy (buf, volset_ident, len);
+
+ nonhexpos = 16;
+ for (i = 0; i < 16; ++i)
+ {
+ if (!grub_isxdigit (buf[i]))
+ {
+ nonhexpos = i;
+ break;
+ }
+ }
+
+ if (nonhexpos < 8)
+ {
+ grub_snprintf (uuid, 17, "%02x%02x%02x%02x%02x%02x%02x%02x",
+ buf[0], buf[1], buf[2], buf[3],
+ buf[4], buf[5], buf[6], buf[7]);
+ }
+ else if (nonhexpos < 16)
+ {
+ for (i = 0; i < 8; ++i)
+ uuid[i] = grub_tolower (buf[i]);
+ grub_snprintf (uuid+8, 9, "%02x%02x%02x%02x",
+ buf[8], buf[9], buf[10], buf[11]);
+ }
+ else
+ {
+ for (i = 0; i < 16; ++i)
+ uuid[i] = grub_tolower (buf[i]);
+ uuid[16] = 0;
+ }
+
+ return uuid;
+}
+
+static grub_err_t
+grub_udf_uuid (grub_device_t device, char **uuid)
+{
+ char *volset_ident;
+ struct grub_udf_data *data;
+ data = grub_udf_mount (device->disk);
+
+ if (data)
+ {
+ volset_ident = read_dstring (data->pvd.volset_ident, sizeof (data->pvd.volset_ident));
+ if (volset_ident)
+ {
+ *uuid = gen_uuid_from_volset (volset_ident);
+ grub_free (volset_ident);
+ }
+ else
+ *uuid = 0;
+ grub_free (data);
+ }
+ else
+ *uuid = 0;
+
+ return grub_errno;
+}
+
+static struct grub_fs grub_udf_fs = {
+ .name = "udf",
+ .fs_dir = grub_udf_dir,
+ .fs_open = grub_udf_open,
+ .fs_read = grub_udf_read,
+ .fs_close = grub_udf_close,
+ .fs_label = grub_udf_label,
+ .fs_uuid = grub_udf_uuid,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 1,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+};
+
+GRUB_MOD_INIT (udf)
+{
+ grub_fs_register (&grub_udf_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (udf)
+{
+ grub_fs_unregister (&grub_udf_fs);
+}
diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c
new file mode 100644
index 0000000..34a698b
--- /dev/null
+++ b/grub-core/fs/ufs.c
@@ -0,0 +1,918 @@
+/* ufs.c - Unix File System */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#ifdef MODE_UFS2
+#define GRUB_UFS_MAGIC 0x19540119
+#else
+#define GRUB_UFS_MAGIC 0x11954
+#endif
+
+#define GRUB_UFS_INODE 2
+#define GRUB_UFS_FILETYPE_DIR 4
+#define GRUB_UFS_FILETYPE_LNK 10
+#define GRUB_UFS_MAX_SYMLNK_CNT 8
+
+#define GRUB_UFS_DIRBLKS 12
+#define GRUB_UFS_INDIRBLKS 3
+
+#define GRUB_UFS_ATTR_TYPE 0160000
+#define GRUB_UFS_ATTR_FILE 0100000
+#define GRUB_UFS_ATTR_DIR 0040000
+#define GRUB_UFS_ATTR_LNK 0120000
+
+#define GRUB_UFS_VOLNAME_LEN 32
+
+#ifdef MODE_BIGENDIAN
+#define grub_ufs_to_cpu16 grub_be_to_cpu16
+#define grub_ufs_to_cpu32 grub_be_to_cpu32
+#define grub_ufs_to_cpu64 grub_be_to_cpu64
+#define grub_cpu_to_ufs32_compile_time grub_cpu_to_be32_compile_time
+#else
+#define grub_ufs_to_cpu16 grub_le_to_cpu16
+#define grub_ufs_to_cpu32 grub_le_to_cpu32
+#define grub_ufs_to_cpu64 grub_le_to_cpu64
+#define grub_cpu_to_ufs32_compile_time grub_cpu_to_le32_compile_time
+#endif
+
+#ifdef MODE_UFS2
+typedef grub_uint64_t grub_ufs_blk_t;
+static inline grub_disk_addr_t
+grub_ufs_to_cpu_blk (grub_ufs_blk_t blk)
+{
+ return grub_ufs_to_cpu64 (blk);
+}
+#else
+typedef grub_uint32_t grub_ufs_blk_t;
+static inline grub_disk_addr_t
+grub_ufs_to_cpu_blk (grub_ufs_blk_t blk)
+{
+ return grub_ufs_to_cpu32 (blk);
+}
+#endif
+
+/* Calculate in which group the inode can be found. */
+#define UFS_BLKSZ(sblock) (grub_ufs_to_cpu32 (sblock->bsize))
+#define UFS_LOG_BLKSZ(sblock) (data->log2_blksz)
+
+#ifdef MODE_UFS2
+#define INODE_ENDIAN(data,field,bits1,bits2) grub_ufs_to_cpu##bits2 (data->inode.field)
+#else
+#define INODE_ENDIAN(data,field,bits1,bits2) grub_ufs_to_cpu##bits1 (data->inode.field)
+#endif
+
+#define INODE_SIZE(data) grub_ufs_to_cpu64 (data->inode.size)
+#define INODE_MODE(data) grub_ufs_to_cpu16 (data->inode.mode)
+#ifdef MODE_UFS2
+#define LOG_INODE_BLKSZ 3
+#else
+#define LOG_INODE_BLKSZ 2
+#endif
+#ifdef MODE_UFS2
+#define UFS_INODE_PER_BLOCK 2
+#else
+#define UFS_INODE_PER_BLOCK 4
+#endif
+#define INODE_DIRBLOCKS(data,blk) INODE_ENDIAN \
+ (data,blocks.dir_blocks[blk],32,64)
+#define INODE_INDIRBLOCKS(data,blk) INODE_ENDIAN \
+ (data,blocks.indir_blocks[blk],32,64)
+
+/* The blocks on which the superblock can be found. */
+static int sblocklist[] = { 128, 16, 0, 512, -1 };
+
+struct grub_ufs_sblock
+{
+ grub_uint8_t unused[16];
+ /* The offset of the inodes in the cylinder group. */
+ grub_uint32_t inoblk_offs;
+
+ grub_uint8_t unused2[4];
+
+ /* The start of the cylinder group. */
+ grub_uint32_t cylg_offset;
+ grub_uint32_t cylg_mask;
+
+ grub_uint32_t mtime;
+ grub_uint8_t unused4[12];
+
+ /* The size of a block in bytes. */
+ grub_int32_t bsize;
+ grub_uint8_t unused5[48];
+
+ /* The size of filesystem blocks to disk blocks. */
+ grub_uint32_t log2_blksz;
+ grub_uint8_t unused6[40];
+ grub_uint32_t uuidhi;
+ grub_uint32_t uuidlow;
+ grub_uint8_t unused7[32];
+
+ /* Inodes stored per cylinder group. */
+ grub_uint32_t ino_per_group;
+
+ /* The frags per cylinder group. */
+ grub_uint32_t frags_per_group;
+
+ grub_uint8_t unused8[488];
+
+ /* Volume name for UFS2. */
+ grub_uint8_t volume_name[GRUB_UFS_VOLNAME_LEN];
+ grub_uint8_t unused9[360];
+
+ grub_uint64_t mtime2;
+ grub_uint8_t unused10[292];
+
+ /* Magic value to check if this is really a UFS filesystem. */
+ grub_uint32_t magic;
+};
+
+#ifdef MODE_UFS2
+/* UFS inode. */
+struct grub_ufs_inode
+{
+ grub_uint16_t mode;
+ grub_uint16_t nlinks;
+ grub_uint32_t uid;
+ grub_uint32_t gid;
+ grub_uint32_t blocksize;
+ grub_uint64_t size;
+ grub_int64_t nblocks;
+ grub_uint64_t atime;
+ grub_uint64_t mtime;
+ grub_uint64_t ctime;
+ grub_uint64_t create_time;
+ grub_uint32_t atime_usec;
+ grub_uint32_t mtime_usec;
+ grub_uint32_t ctime_usec;
+ grub_uint32_t create_time_sec;
+ grub_uint32_t gen;
+ grub_uint32_t kernel_flags;
+ grub_uint32_t flags;
+ grub_uint32_t extsz;
+ grub_uint64_t ext[2];
+ union
+ {
+ struct
+ {
+ grub_uint64_t dir_blocks[GRUB_UFS_DIRBLKS];
+ grub_uint64_t indir_blocks[GRUB_UFS_INDIRBLKS];
+ } blocks;
+ grub_uint8_t symlink[(GRUB_UFS_DIRBLKS + GRUB_UFS_INDIRBLKS) * 8];
+ };
+
+ grub_uint8_t unused[24];
+} GRUB_PACKED;
+#else
+/* UFS inode. */
+struct grub_ufs_inode
+{
+ grub_uint16_t mode;
+ grub_uint16_t nlinks;
+ grub_uint16_t uid;
+ grub_uint16_t gid;
+ grub_uint64_t size;
+ grub_uint32_t atime;
+ grub_uint32_t atime_usec;
+ grub_uint32_t mtime;
+ grub_uint32_t mtime_usec;
+ grub_uint32_t ctime;
+ grub_uint32_t ctime_usec;
+ union
+ {
+ struct
+ {
+ grub_uint32_t dir_blocks[GRUB_UFS_DIRBLKS];
+ grub_uint32_t indir_blocks[GRUB_UFS_INDIRBLKS];
+ } blocks;
+ grub_uint8_t symlink[(GRUB_UFS_DIRBLKS + GRUB_UFS_INDIRBLKS) * 4];
+ };
+ grub_uint32_t flags;
+ grub_uint32_t nblocks;
+ grub_uint32_t gen;
+ grub_uint32_t unused;
+ grub_uint8_t pad[12];
+} GRUB_PACKED;
+#endif
+
+/* Directory entry. */
+struct grub_ufs_dirent
+{
+ grub_uint32_t ino;
+ grub_uint16_t direntlen;
+ union
+ {
+ grub_uint16_t namelen;
+ struct
+ {
+ grub_uint8_t filetype_bsd;
+ grub_uint8_t namelen_bsd;
+ };
+ };
+} GRUB_PACKED;
+
+/* Information about a "mounted" ufs filesystem. */
+struct grub_ufs_data
+{
+ struct grub_ufs_sblock sblock;
+ grub_disk_t disk;
+ struct grub_ufs_inode inode;
+ int ino;
+ int linknest;
+ int log2_blksz;
+};
+
+static grub_dl_t my_mod;
+
+/* Forward declaration. */
+static grub_err_t grub_ufs_find_file (struct grub_ufs_data *data,
+ const char *path);
+
+
+static grub_disk_addr_t
+grub_ufs_get_file_block (struct grub_ufs_data *data, grub_disk_addr_t blk)
+{
+ unsigned long indirsz;
+ int log2_blksz, log_indirsz;
+
+ /* Direct. */
+ if (blk < GRUB_UFS_DIRBLKS)
+ return INODE_DIRBLOCKS (data, blk);
+
+ log2_blksz = grub_ufs_to_cpu32 (data->sblock.log2_blksz);
+
+ blk -= GRUB_UFS_DIRBLKS;
+
+ log_indirsz = data->log2_blksz - LOG_INODE_BLKSZ;
+ indirsz = 1 << log_indirsz;
+
+ /* Single indirect block. */
+ if (blk < indirsz)
+ {
+ grub_ufs_blk_t indir;
+ grub_disk_read (data->disk,
+ ((grub_disk_addr_t) INODE_INDIRBLOCKS (data, 0))
+ << log2_blksz,
+ blk * sizeof (indir), sizeof (indir), &indir);
+ return indir;
+ }
+ blk -= indirsz;
+
+ /* Double indirect block. */
+ if (blk < (grub_disk_addr_t) indirsz * (grub_disk_addr_t) indirsz)
+ {
+ grub_ufs_blk_t indir;
+
+ grub_disk_read (data->disk,
+ ((grub_disk_addr_t) INODE_INDIRBLOCKS (data, 1))
+ << log2_blksz,
+ (blk >> log_indirsz) * sizeof (indir),
+ sizeof (indir), &indir);
+ grub_disk_read (data->disk,
+ grub_ufs_to_cpu_blk (indir) << log2_blksz,
+ (blk & ((1 << log_indirsz) - 1)) * sizeof (indir),
+ sizeof (indir), &indir);
+
+ return indir;
+ }
+
+ blk -= (grub_disk_addr_t) indirsz * (grub_disk_addr_t) indirsz;
+
+ /* Triple indirect block. */
+ if (!(blk >> (3 * log_indirsz)))
+ {
+ grub_ufs_blk_t indir;
+
+ grub_disk_read (data->disk,
+ ((grub_disk_addr_t) INODE_INDIRBLOCKS (data, 2))
+ << log2_blksz,
+ (blk >> (2 * log_indirsz)) * sizeof (indir),
+ sizeof (indir), &indir);
+ grub_disk_read (data->disk,
+ grub_ufs_to_cpu_blk (indir) << log2_blksz,
+ ((blk >> log_indirsz)
+ & ((1 << log_indirsz) - 1)) * sizeof (indir),
+ sizeof (indir), &indir);
+
+ grub_disk_read (data->disk,
+ grub_ufs_to_cpu_blk (indir) << log2_blksz,
+ (blk & ((1 << log_indirsz) - 1)) * sizeof (indir),
+ sizeof (indir), &indir);
+
+ return indir;
+ }
+
+ grub_error (GRUB_ERR_BAD_FS,
+ "ufs does not support quadruple indirect blocks");
+ return 0;
+}
+
+
+/* Read LEN bytes from the file described by DATA starting with byte
+ POS. Return the amount of read bytes in READ. */
+static grub_ssize_t
+grub_ufs_read_file (struct grub_ufs_data *data,
+ grub_disk_read_hook_t read_hook, void *read_hook_data,
+ grub_off_t pos, grub_size_t len, char *buf)
+{
+ struct grub_ufs_sblock *sblock = &data->sblock;
+ grub_off_t i;
+ grub_off_t blockcnt;
+
+ /* Adjust len so it we can't read past the end of the file. */
+ if (len + pos > INODE_SIZE (data))
+ len = INODE_SIZE (data) - pos;
+
+ blockcnt = (len + pos + UFS_BLKSZ (sblock) - 1) >> UFS_LOG_BLKSZ (sblock);
+
+ for (i = pos >> UFS_LOG_BLKSZ (sblock); i < blockcnt; i++)
+ {
+ grub_disk_addr_t blknr;
+ grub_off_t blockoff;
+ grub_off_t blockend = UFS_BLKSZ (sblock);
+
+ int skipfirst = 0;
+
+ blockoff = pos & (UFS_BLKSZ (sblock) - 1);
+
+ blknr = grub_ufs_get_file_block (data, i);
+ if (grub_errno)
+ return -1;
+
+ /* Last block. */
+ if (i == blockcnt - 1)
+ {
+ blockend = (len + pos) & (UFS_BLKSZ (sblock) - 1);
+
+ if (!blockend)
+ blockend = UFS_BLKSZ (sblock);
+ }
+
+ /* First block. */
+ if (i == (pos >> UFS_LOG_BLKSZ (sblock)))
+ {
+ skipfirst = blockoff;
+ blockend -= skipfirst;
+ }
+
+ /* XXX: If the block number is 0 this block is not stored on
+ disk but is zero filled instead. */
+ if (blknr)
+ {
+ data->disk->read_hook = read_hook;
+ data->disk->read_hook_data = read_hook_data;
+ grub_disk_read (data->disk,
+ blknr << grub_ufs_to_cpu32 (data->sblock.log2_blksz),
+ skipfirst, blockend, buf);
+ data->disk->read_hook = 0;
+ if (grub_errno)
+ return -1;
+ }
+ else
+ grub_memset (buf, 0, blockend);
+
+ buf += UFS_BLKSZ (sblock) - skipfirst;
+ }
+
+ return len;
+}
+
+/* Read inode INO from the mounted filesystem described by DATA. This
+ inode is used by default now. */
+static grub_err_t
+grub_ufs_read_inode (struct grub_ufs_data *data, int ino, char *inode)
+{
+ struct grub_ufs_sblock *sblock = &data->sblock;
+
+ /* Determine the group the inode is in. */
+ int group = ino / grub_ufs_to_cpu32 (sblock->ino_per_group);
+
+ /* Determine the inode within the group. */
+ int grpino = ino % grub_ufs_to_cpu32 (sblock->ino_per_group);
+
+ /* The first block of the group. */
+ int grpblk = group * (grub_ufs_to_cpu32 (sblock->frags_per_group));
+
+#ifndef MODE_UFS2
+ grpblk += grub_ufs_to_cpu32 (sblock->cylg_offset)
+ * (group & (~grub_ufs_to_cpu32 (sblock->cylg_mask)));
+#endif
+
+ if (!inode)
+ {
+ inode = (char *) &data->inode;
+ data->ino = ino;
+ }
+
+ grub_disk_read (data->disk,
+ ((grub_ufs_to_cpu32 (sblock->inoblk_offs) + grpblk)
+ << grub_ufs_to_cpu32 (data->sblock.log2_blksz))
+ + grpino / UFS_INODE_PER_BLOCK,
+ (grpino % UFS_INODE_PER_BLOCK)
+ * sizeof (struct grub_ufs_inode),
+ sizeof (struct grub_ufs_inode),
+ inode);
+
+ return grub_errno;
+}
+
+
+/* Lookup the symlink the current inode points to. INO is the inode
+ number of the directory the symlink is relative to. */
+static grub_err_t
+grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
+{
+ char *symlink;
+ grub_size_t sz = INODE_SIZE (data);
+
+ if (++data->linknest > GRUB_UFS_MAX_SYMLNK_CNT)
+ return grub_error (GRUB_ERR_SYMLINK_LOOP, N_("too deep nesting of symlinks"));
+
+ symlink = grub_malloc (sz + 1);
+ if (!symlink)
+ return grub_errno;
+ /* Normally we should just check that data->inode.nblocks == 0.
+ However old Linux doesn't maintain nblocks correctly and so it's always
+ 0. If size is bigger than inline space then the symlink is surely not
+ inline. */
+ /* Check against zero is paylindromic, no need to swap. */
+ if (data->inode.nblocks == 0
+ && INODE_SIZE (data) <= sizeof (data->inode.symlink))
+ grub_strcpy (symlink, (char *) data->inode.symlink);
+ else
+ {
+ 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. */
+ if (symlink[0] == '/')
+ ino = GRUB_UFS_INODE;
+
+ /* Now load in the old inode. */
+ if (grub_ufs_read_inode (data, ino, 0))
+ {
+ grub_free (symlink);
+ return grub_errno;
+ }
+
+ grub_ufs_find_file (data, symlink);
+
+ grub_free (symlink);
+
+ return grub_errno;
+}
+
+
+/* Find the file with the pathname PATH on the filesystem described by
+ DATA. */
+static grub_err_t
+grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
+{
+ const char *name;
+ const char *next = path;
+ unsigned int pos = 0;
+ int dirino;
+ char *filename;
+
+ /* We reject filenames longer than the one we're looking
+ for without reading, so this allocation is enough. */
+ filename = grub_malloc (grub_strlen (path) + 2);
+ if (!filename)
+ return grub_errno;
+
+ while (1)
+ {
+ struct grub_ufs_dirent dirent;
+
+ name = next;
+ /* Skip the first slash. */
+ while (*name == '/')
+ name++;
+ if (*name == 0)
+ {
+ grub_free (filename);
+ return GRUB_ERR_NONE;
+ }
+
+ if ((INODE_MODE(data) & GRUB_UFS_ATTR_TYPE)
+ != GRUB_UFS_ATTR_DIR)
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ N_("not a directory"));
+ goto fail;
+ }
+
+ /* Extract the actual part from the pathname. */
+ for (next = name; *next && *next != '/'; next++);
+ for (pos = 0; ; pos += grub_ufs_to_cpu16 (dirent.direntlen))
+ {
+ int namelen;
+
+ if (pos >= INODE_SIZE (data))
+ {
+ grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ N_("file `%s' not found"),
+ path);
+ goto fail;
+ }
+
+ if (grub_ufs_read_file (data, 0, 0, pos, sizeof (dirent),
+ (char *) &dirent) < 0)
+ goto fail;
+
+#ifdef MODE_UFS2
+ namelen = dirent.namelen_bsd;
+#else
+ namelen = grub_ufs_to_cpu16 (dirent.namelen);
+#endif
+ if (namelen < next - name)
+ continue;
+
+ if (grub_ufs_read_file (data, 0, 0, pos + sizeof (dirent),
+ next - name + (namelen != next - name),
+ filename) < 0)
+ goto fail;
+
+ if (grub_strncmp (name, filename, next - name) == 0
+ && (namelen == next - name || filename[next - name] == '\0'))
+ {
+ dirino = data->ino;
+ grub_ufs_read_inode (data, grub_ufs_to_cpu32 (dirent.ino), 0);
+
+ if ((INODE_MODE(data) & GRUB_UFS_ATTR_TYPE)
+ == GRUB_UFS_ATTR_LNK)
+ {
+ grub_ufs_lookup_symlink (data, dirino);
+ if (grub_errno)
+ goto fail;
+ }
+
+ break;
+ }
+ }
+ }
+ fail:
+ grub_free (filename);
+ return grub_errno;
+}
+
+
+/* Mount the filesystem on the disk DISK. */
+static struct grub_ufs_data *
+grub_ufs_mount (grub_disk_t disk)
+{
+ struct grub_ufs_data *data;
+ int *sblklist = sblocklist;
+
+ data = grub_malloc (sizeof (struct grub_ufs_data));
+ if (!data)
+ return 0;
+
+ /* Find a UFS sblock. */
+ while (*sblklist != -1)
+ {
+ grub_disk_read (disk, *sblklist, 0, sizeof (struct grub_ufs_sblock),
+ &data->sblock);
+ if (grub_errno)
+ goto fail;
+
+ /* No need to byteswap bsize in this check. It works the same on both
+ 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.ino_per_group != 0)
+ {
+ for (data->log2_blksz = 0;
+ (1U << data->log2_blksz) < grub_ufs_to_cpu32 (data->sblock.bsize);
+ data->log2_blksz++);
+
+ data->disk = disk;
+ data->linknest = 0;
+ return data;
+ }
+ sblklist++;
+ }
+
+ fail:
+
+ if (grub_errno == GRUB_ERR_NONE || grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ {
+#ifdef MODE_UFS2
+ grub_error (GRUB_ERR_BAD_FS, "not an ufs2 filesystem");
+#else
+ grub_error (GRUB_ERR_BAD_FS, "not an ufs1 filesystem");
+#endif
+ }
+
+ grub_free (data);
+
+ return 0;
+}
+
+
+static grub_err_t
+grub_ufs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_ufs_data *data;
+ unsigned int pos = 0;
+
+ data = grub_ufs_mount (device->disk);
+ if (!data)
+ return grub_errno;
+
+ grub_ufs_read_inode (data, GRUB_UFS_INODE, 0);
+ if (grub_errno)
+ return grub_errno;
+
+ if (!path || path[0] != '/')
+ {
+ grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
+ return grub_errno;
+ }
+
+ grub_ufs_find_file (data, path);
+ if (grub_errno)
+ goto fail;
+
+ if ((INODE_MODE (data) & GRUB_UFS_ATTR_TYPE) != GRUB_UFS_ATTR_DIR)
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+ goto fail;
+ }
+
+ while (pos < INODE_SIZE (data))
+ {
+ struct grub_ufs_dirent dirent;
+ int namelen;
+
+ if (grub_ufs_read_file (data, 0, 0, pos, sizeof (dirent),
+ (char *) &dirent) < 0)
+ break;
+
+ if (dirent.direntlen == 0)
+ break;
+
+#ifdef MODE_UFS2
+ namelen = dirent.namelen_bsd;
+#else
+ namelen = grub_ufs_to_cpu16 (dirent.namelen);
+#endif
+
+ char *filename = grub_malloc (namelen + 1);
+ if (!filename)
+ goto fail;
+ struct grub_dirhook_info info;
+ struct grub_ufs_inode inode;
+
+ grub_memset (&info, 0, sizeof (info));
+
+ if (grub_ufs_read_file (data, 0, 0, pos + sizeof (dirent),
+ namelen, filename) < 0)
+ {
+ grub_free (filename);
+ break;
+ }
+
+ filename[namelen] = '\0';
+ grub_ufs_read_inode (data, grub_ufs_to_cpu32 (dirent.ino),
+ (char *) &inode);
+
+ info.dir = ((grub_ufs_to_cpu16 (inode.mode) & GRUB_UFS_ATTR_TYPE)
+ == GRUB_UFS_ATTR_DIR);
+#ifdef MODE_UFS2
+ info.mtime = grub_ufs_to_cpu64 (inode.mtime);
+#else
+ info.mtime = grub_ufs_to_cpu32 (inode.mtime);
+#endif
+ info.mtimeset = 1;
+
+ if (hook (filename, &info, hook_data))
+ {
+ grub_free (filename);
+ break;
+ }
+
+ grub_free (filename);
+
+ pos += grub_ufs_to_cpu16 (dirent.direntlen);
+ }
+
+ fail:
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_ufs_open (struct grub_file *file, const char *name)
+{
+ struct grub_ufs_data *data;
+ data = grub_ufs_mount (file->device->disk);
+ if (!data)
+ return grub_errno;
+
+ grub_ufs_read_inode (data, 2, 0);
+ if (grub_errno)
+ {
+ grub_free (data);
+ return grub_errno;
+ }
+
+ if (!name || name[0] != '/')
+ {
+ grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), name);
+ return grub_errno;
+ }
+
+ grub_ufs_find_file (data, name);
+ if (grub_errno)
+ {
+ grub_free (data);
+ return grub_errno;
+ }
+
+ file->data = data;
+ file->size = INODE_SIZE (data);
+
+ return GRUB_ERR_NONE;
+}
+
+
+static grub_ssize_t
+grub_ufs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_ufs_data *data =
+ (struct grub_ufs_data *) file->data;
+
+ return grub_ufs_read_file (data, file->read_hook, file->read_hook_data,
+ file->offset, len, buf);
+}
+
+
+static grub_err_t
+grub_ufs_close (grub_file_t file)
+{
+ grub_free (file->data);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_ufs_label (grub_device_t device, char **label)
+{
+ struct grub_ufs_data *data = 0;
+
+ grub_dl_ref (my_mod);
+
+ *label = 0;
+
+ data = grub_ufs_mount (device->disk);
+ if (data)
+ *label = grub_strdup ((char *) data->sblock.volume_name);
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_ufs_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_ufs_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_ufs_mount (disk);
+ if (data && (data->sblock.uuidhi != 0 || data->sblock.uuidlow != 0))
+ *uuid = grub_xasprintf ("%08x%08x",
+ (unsigned) grub_ufs_to_cpu32 (data->sblock.uuidhi),
+ (unsigned) grub_ufs_to_cpu32 (data->sblock.uuidlow));
+ else
+ *uuid = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+/* Get mtime. */
+static grub_err_t
+grub_ufs_mtime (grub_device_t device, grub_int64_t *tm)
+{
+ struct grub_ufs_data *data = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_ufs_mount (device->disk);
+ if (!data)
+ *tm = 0;
+ else
+ {
+ *tm = grub_ufs_to_cpu32 (data->sblock.mtime);
+#ifdef MODE_UFS2
+ if (*tm < (grub_int64_t) grub_ufs_to_cpu64 (data->sblock.mtime2))
+ *tm = grub_ufs_to_cpu64 (data->sblock.mtime2);
+#endif
+ }
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+
+static struct grub_fs grub_ufs_fs =
+ {
+#ifdef MODE_UFS2
+ .name = "ufs2",
+#else
+#ifdef MODE_BIGENDIAN
+ .name = "ufs1_be",
+#else
+ .name = "ufs1",
+#endif
+#endif
+ .fs_dir = grub_ufs_dir,
+ .fs_open = grub_ufs_open,
+ .fs_read = grub_ufs_read,
+ .fs_close = grub_ufs_close,
+ .fs_label = grub_ufs_label,
+ .fs_uuid = grub_ufs_uuid,
+ .fs_mtime = grub_ufs_mtime,
+ /* FIXME: set reserved_first_sector. */
+#ifdef GRUB_UTIL
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+#ifdef MODE_UFS2
+GRUB_MOD_INIT(ufs2)
+#else
+#ifdef MODE_BIGENDIAN
+GRUB_MOD_INIT(ufs1_be)
+#else
+GRUB_MOD_INIT(ufs1)
+#endif
+#endif
+{
+ grub_fs_register (&grub_ufs_fs);
+ my_mod = mod;
+}
+
+#ifdef MODE_UFS2
+GRUB_MOD_FINI(ufs2)
+#else
+#ifdef MODE_BIGENDIAN
+GRUB_MOD_FINI(ufs1_be)
+#else
+GRUB_MOD_FINI(ufs1)
+#endif
+#endif
+{
+ grub_fs_unregister (&grub_ufs_fs);
+}
+
diff --git a/grub-core/fs/ufs2.c b/grub-core/fs/ufs2.c
new file mode 100644
index 0000000..7f4eb95
--- /dev/null
+++ b/grub-core/fs/ufs2.c
@@ -0,0 +1,3 @@
+/* ufs2.c - Unix File System 2 */
+#define MODE_UFS2 1
+#include "ufs.c"
diff --git a/grub-core/fs/ufs_be.c b/grub-core/fs/ufs_be.c
new file mode 100644
index 0000000..a58f75a
--- /dev/null
+++ b/grub-core/fs/ufs_be.c
@@ -0,0 +1,2 @@
+#define MODE_BIGENDIAN 1
+#include "ufs.c"
diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
new file mode 100644
index 0000000..0f524c3
--- /dev/null
+++ b/grub-core/fs/xfs.c
@@ -0,0 +1,1211 @@
+/* xfs.c - XFS. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/time.h>
+#include <grub/types.h>
+#include <grub/fshelp.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define XFS_INODE_EXTENTS 9
+
+#define XFS_INODE_FORMAT_INO 1
+#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)
+
+/* Inode flags2 flags */
+#define XFS_DIFLAG2_BIGTIME_BIT 3
+#define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT)
+
+/* incompat feature flags */
+#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */
+#define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */
+#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */
+#define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */
+#define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */
+
+/*
+ * Directory entries with ftype are explicitly handled by GRUB code.
+ *
+ * We do not currently read the inode btrees, so it is safe to read filesystems
+ * with the XFS_SB_FEAT_INCOMPAT_SPINODES feature.
+ *
+ * We do not currently verify metadata UUID, so it is safe to read filesystems
+ * with the XFS_SB_FEAT_INCOMPAT_META_UUID feature.
+ */
+#define XFS_SB_FEAT_INCOMPAT_SUPPORTED \
+ (XFS_SB_FEAT_INCOMPAT_FTYPE | \
+ XFS_SB_FEAT_INCOMPAT_SPINODES | \
+ XFS_SB_FEAT_INCOMPAT_META_UUID | \
+ XFS_SB_FEAT_INCOMPAT_BIGTIME | \
+ XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR)
+
+struct grub_xfs_sblock
+{
+ grub_uint8_t magic[4];
+ grub_uint32_t bsize;
+ grub_uint8_t unused1[24];
+ grub_uint16_t uuid[8];
+ grub_uint8_t unused2[8];
+ grub_uint64_t rootino;
+ grub_uint8_t unused3[20];
+ grub_uint32_t agsize;
+ 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;
+ grub_uint8_t log2_inode;
+ grub_uint8_t log2_inop;
+ 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 largeino;
+ union
+ {
+ grub_uint32_t i4;
+ grub_uint64_t i8;
+ } 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 / 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;
+
+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
+{
+ grub_uint8_t magic[4];
+ grub_uint16_t level;
+ grub_uint16_t numrecs;
+ grub_uint64_t left;
+ grub_uint64_t right;
+ /* 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;
+
+struct grub_xfs_time_legacy
+{
+ grub_uint32_t sec;
+ grub_uint32_t nanosec;
+} GRUB_PACKED;
+
+struct grub_xfs_inode
+{
+ grub_uint8_t magic[2];
+ grub_uint16_t mode;
+ grub_uint8_t version;
+ grub_uint8_t format;
+ grub_uint8_t unused2[26];
+ grub_uint64_t atime;
+ grub_uint64_t mtime;
+ grub_uint64_t ctime;
+ grub_uint64_t size;
+ grub_uint64_t nblocks;
+ grub_uint32_t extsize;
+ grub_uint32_t nextents;
+ grub_uint16_t unused3;
+ grub_uint8_t fork_offset;
+ grub_uint8_t unused4[37];
+ grub_uint64_t flags2;
+ grub_uint8_t unused5[48];
+} GRUB_PACKED;
+
+#define XFS_V3_INODE_SIZE sizeof(struct grub_xfs_inode)
+/* Size of struct grub_xfs_inode until fork_offset (included). */
+#define XFS_V2_INODE_SIZE (XFS_V3_INODE_SIZE - 92)
+
+struct grub_xfs_dirblock_tail
+{
+ grub_uint32_t leaf_count;
+ grub_uint32_t leaf_stale;
+} GRUB_PACKED;
+
+struct grub_fshelp_node
+{
+ struct grub_xfs_data *data;
+ grub_uint64_t ino;
+ int inode_read;
+ struct grub_xfs_inode inode;
+};
+
+struct grub_xfs_data
+{
+ struct grub_xfs_sblock sblock;
+ grub_disk_t disk;
+ int pos;
+ int bsize;
+ grub_uint32_t agsize;
+ unsigned int hasftype:1;
+ unsigned int hascrc:1;
+ struct grub_fshelp_node diropen;
+};
+
+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;
+}
+
+static int
+grub_xfs_sb_needs_repair (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) &&
+ (data->sblock.sb_features_incompat &
+ grub_cpu_to_be32_compile_time (XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR)));
+}
+
+/* Filetype information as used in inodes. */
+#define FILETYPE_INO_MASK 0170000
+#define FILETYPE_INO_REG 0100000
+#define FILETYPE_INO_DIRECTORY 0040000
+#define FILETYPE_INO_SYMLINK 0120000
+
+static inline int
+GRUB_XFS_INO_AGBITS(struct grub_xfs_data *data)
+{
+ return ((data)->sblock.log2_agblk + (data)->sblock.log2_inop);
+}
+
+static inline grub_uint64_t
+GRUB_XFS_INO_INOINAG (struct grub_xfs_data *data,
+ grub_uint64_t ino)
+{
+ 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 (ino >> GRUB_XFS_INO_AGBITS (data));
+}
+
+static inline grub_disk_addr_t
+GRUB_XFS_FSB_TO_BLOCK (struct grub_xfs_data *data, grub_disk_addr_t fsb)
+{
+ return ((fsb >> data->sblock.log2_agblk) * data->agsize
+ + (fsb & ((1LL << data->sblock.log2_agblk) - 1)));
+}
+
+static inline grub_uint64_t
+GRUB_XFS_EXTENT_OFFSET (struct grub_xfs_extent *exts, int ex)
+{
+ 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 (struct grub_xfs_extent *exts, int ex)
+{
+ return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex].raw[1])
+ & (0x1ff)) << 43
+ | (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 (struct grub_xfs_extent *exts, int ex)
+{
+ return (grub_be_to_cpu32 (exts[ex].raw[3]) & ((1 << 21) - 1));
+}
+
+
+static inline grub_uint64_t
+grub_xfs_inode_block (struct grub_xfs_data *data,
+ grub_uint64_t ino)
+{
+ long long int inoinag = GRUB_XFS_INO_INOINAG (data, ino);
+ long long ag = GRUB_XFS_INO_AG (data, ino);
+ long long block;
+
+ block = (inoinag >> data->sblock.log2_inop) + ag * data->agsize;
+ block <<= (data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS);
+ return block;
+}
+
+
+static inline int
+grub_xfs_inode_offset (struct grub_xfs_data *data,
+ grub_uint64_t ino)
+{
+ int inoag = GRUB_XFS_INO_INOINAG (data, ino);
+ return ((inoag & ((1 << data->sblock.log2_inop) - 1)) <<
+ 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,
+ struct grub_xfs_inode *inode)
+{
+ 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, grub_xfs_inode_size(data),
+ inode))
+ return grub_errno;
+
+ if (grub_strncmp ((char *) inode->magic, "IN", 2))
+ return grub_error (GRUB_ERR_BAD_FS, "not a correct XFS inode");
+
+ 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;
+ struct grub_xfs_extent *exts;
+ grub_uint64_t ret = 0;
+
+ if (node->inode.format == XFS_INODE_FORMAT_BTREE)
+ {
+ struct grub_xfs_btree_root *root;
+ const char *keys;
+ int recoffset;
+
+ leaf = grub_malloc (node->data->bsize);
+ if (leaf == 0)
+ return 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 = (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 < get_fsb(keys, i))
+ break;
+ }
+
+ /* Sparse block. */
+ if (i == 0)
+ {
+ grub_free (leaf);
+ return 0;
+ }
+
+ if (grub_disk_read (node->data->disk,
+ 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 ((!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");
+ return 0;
+ }
+
+ nrec = grub_be_to_cpu16 (leaf->numrecs);
+ 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 = (struct grub_xfs_extent *) keys;
+ }
+ else if (node->inode.format == XFS_INODE_FORMAT_EXT)
+ {
+ nrec = grub_be_to_cpu32 (node->inode.nextents);
+ exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode);
+ }
+ else
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "XFS does not support inode format %d yet",
+ node->inode.format);
+ return 0;
+ }
+
+ /* Iterate over each extent to figure out which extent has
+ the block we are looking for. */
+ for (ex = 0; ex < nrec; ex++)
+ {
+ grub_uint64_t start = GRUB_XFS_EXTENT_BLOCK (exts, ex);
+ grub_uint64_t offset = GRUB_XFS_EXTENT_OFFSET (exts, ex);
+ grub_uint64_t size = GRUB_XFS_EXTENT_SIZE (exts, ex);
+
+ /* Sparse block. */
+ if (fileblock < offset)
+ break;
+ else if (fileblock < offset + size)
+ {
+ ret = (fileblock - offset + start);
+ break;
+ }
+ }
+
+ grub_free (leaf);
+
+ return GRUB_XFS_FSB_TO_BLOCK(node->data, ret);
+}
+
+
+/* Read LEN bytes from the file described by DATA starting with byte
+ 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_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) + header_size,
+ node->data->sblock.log2_bsize
+ - GRUB_DISK_SECTOR_BITS, 0);
+}
+
+
+static char *
+grub_xfs_read_symlink (grub_fshelp_node_t node)
+{
+ 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 (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;
+
+ 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);
+ return 0;
+ }
+ symlink[size] = '\0';
+ return symlink;
+ }
+ }
+
+ return 0;
+}
+
+
+static enum grub_fshelp_filetype
+grub_xfs_mode_to_filetype (grub_uint16_t mode)
+{
+ if ((grub_be_to_cpu16 (mode)
+ & FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY)
+ return GRUB_FSHELP_DIR;
+ else if ((grub_be_to_cpu16 (mode)
+ & FILETYPE_INO_MASK) == FILETYPE_INO_SYMLINK)
+ return GRUB_FSHELP_SYMLINK;
+ else if ((grub_be_to_cpu16 (mode)
+ & FILETYPE_INO_MASK) == FILETYPE_INO_REG)
+ return GRUB_FSHELP_REG;
+ return GRUB_FSHELP_UNKNOWN;
+}
+
+
+/* Context for grub_xfs_iterate_dir. */
+struct grub_xfs_iterate_dir_ctx
+{
+ grub_fshelp_iterate_dir_hook_t hook;
+ void *hook_data;
+ struct grub_fshelp_node *diro;
+};
+
+/* Helper for grub_xfs_iterate_dir. */
+static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
+ struct grub_xfs_iterate_dir_ctx *ctx)
+{
+ struct grub_fshelp_node *fdiro;
+ grub_err_t err;
+
+ fdiro = grub_malloc (grub_xfs_fshelp_size(ctx->diro->data) + 1);
+ if (!fdiro)
+ {
+ grub_print_error ();
+ return 0;
+ }
+
+ /* The inode should be read, otherwise the filetype can
+ not be determined. */
+ fdiro->ino = ino;
+ fdiro->inode_read = 1;
+ fdiro->data = ctx->diro->data;
+ err = grub_xfs_read_inode (ctx->diro->data, ino, &fdiro->inode);
+ if (err)
+ {
+ grub_print_error ();
+ return 0;
+ }
+
+ return ctx->hook (filename, grub_xfs_mode_to_filetype (fdiro->inode.mode),
+ fdiro, ctx->hook_data);
+}
+
+static int
+grub_xfs_iterate_dir (grub_fshelp_node_t dir,
+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
+{
+ struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
+ struct grub_xfs_iterate_dir_ctx ctx = {
+ .hook = hook,
+ .hook_data = hook_data,
+ .diro = diro
+ };
+
+ switch (diro->inode.format)
+ {
+ case XFS_INODE_FORMAT_INO:
+ {
+ 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 (head->parent.i4);
+ else
+ parent = grub_be_to_cpu64 (head->parent.i8);
+
+ /* Synthesize the direntries for `.' and `..'. */
+ if (iterate_dir_call_hook (diro->ino, ".", &ctx))
+ return 1;
+
+ if (iterate_dir_call_hook (parent, "..", &ctx))
+ return 1;
+
+ for (i = 0; i < head->count; i++)
+ {
+ grub_uint64_t ino;
+ grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de);
+ grub_uint8_t c;
+
+ /* inopos might be unaligned. */
+ if (smallino)
+ ino = (((grub_uint32_t) inopos[0]) << 24)
+ | (((grub_uint32_t) inopos[1]) << 16)
+ | (((grub_uint32_t) inopos[2]) << 8)
+ | (((grub_uint32_t) inopos[3]) << 0);
+ else
+ ino = (((grub_uint64_t) inopos[0]) << 56)
+ | (((grub_uint64_t) inopos[1]) << 48)
+ | (((grub_uint64_t) inopos[2]) << 40)
+ | (((grub_uint64_t) inopos[3]) << 32)
+ | (((grub_uint64_t) inopos[4]) << 24)
+ | (((grub_uint64_t) inopos[5]) << 16)
+ | (((grub_uint64_t) inopos[6]) << 8)
+ | (((grub_uint64_t) inopos[7]) << 0);
+
+ c = de->name[de->len];
+ de->name[de->len] = '\0';
+ if (iterate_dir_call_hook (ino, de->name, &ctx))
+ {
+ de->name[de->len] = c;
+ return 1;
+ }
+ de->name[de->len] = c;
+
+ de = grub_xfs_inline_next_de(dir->data, head, de);
+ }
+ break;
+ }
+
+ case XFS_INODE_FORMAT_BTREE:
+ case XFS_INODE_FORMAT_EXT:
+ {
+ grub_ssize_t numread;
+ char *dirblock;
+ grub_uint64_t blk;
+ int dirblk_size, dirblk_log2;
+
+ dirblk_log2 = (dir->data->sblock.log2_bsize
+ + dir->data->sblock.log2_dirblk);
+ dirblk_size = 1 << dirblk_log2;
+
+ dirblock = grub_malloc (dirblk_size);
+ if (! dirblock)
+ return 0;
+
+ /* Iterate over every block the directory has. */
+ for (blk = 0;
+ blk < (grub_be_to_cpu64 (dir->inode.size)
+ >> dirblk_log2);
+ blk++)
+ {
+ struct grub_xfs_dir2_entry *direntry =
+ grub_xfs_first_de(dir->data, dirblock);
+ int entries;
+ 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, 0);
+ if (numread != dirblk_size)
+ return 0;
+
+ entries = (grub_be_to_cpu32 (tail->leaf_count)
+ - grub_be_to_cpu32 (tail->leaf_stale));
+
+ if (!entries)
+ continue;
+
+ /* Iterate over all entries within this block. */
+ while ((char *)direntry < (char *)tail)
+ {
+ grub_uint8_t *freetag;
+ char *filename;
+
+ freetag = (grub_uint8_t *) direntry;
+
+ if (grub_get_unaligned16 (freetag) == 0XFFFF)
+ {
+ grub_uint8_t *skip = (freetag + sizeof (grub_uint16_t));
+
+ /* This entry is not used, go to the next one. */
+ direntry = (struct grub_xfs_dir2_entry *)
+ (((char *)direntry) +
+ grub_be_to_cpu16 (grub_get_unaligned16 (skip)));
+
+ continue;
+ }
+
+ 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 (grub_be_to_cpu64(direntry->inode),
+ filename, &ctx))
+ {
+ grub_free (dirblock);
+ return 1;
+ }
+
+ /* Check if last direntry in this block is
+ reached. */
+ entries--;
+ if (!entries)
+ break;
+
+ /* Select the next directory entry. */
+ direntry = grub_xfs_next_de(dir->data, direntry);
+ }
+ }
+ grub_free (dirblock);
+ break;
+ }
+
+ default:
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "XFS does not support inode format %d yet",
+ diro->inode.format);
+ }
+ return 0;
+}
+
+
+static struct grub_xfs_data *
+grub_xfs_mount (grub_disk_t disk)
+{
+ struct grub_xfs_data *data = 0;
+ grub_size_t sz;
+
+ data = grub_zalloc (sizeof (struct grub_xfs_data));
+ 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_xfs_sb_valid(data))
+ goto fail;
+
+ if (grub_xfs_sb_needs_repair (data))
+ grub_dprintf ("xfs", "XFS filesystem needs repair, boot may fail\n");
+
+ if (grub_add (grub_xfs_inode_size (data),
+ sizeof (struct grub_xfs_data) - sizeof (struct grub_xfs_inode) + 1, &sz))
+ goto fail;
+
+ data = grub_realloc (data, sz);
+
+ if (! data)
+ goto fail;
+
+ data->diropen.data = data;
+ 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);
+
+ return data;
+ fail:
+
+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+ grub_error (GRUB_ERR_BAD_FS, "not an XFS filesystem");
+
+ grub_free (data);
+
+ return 0;
+}
+
+
+/* Context for grub_xfs_dir. */
+struct grub_xfs_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+};
+
+/* Bigtime inodes helpers. */
+#define XFS_BIGTIME_EPOCH_OFFSET (-(grub_int64_t) GRUB_INT32_MIN)
+
+static int grub_xfs_inode_has_bigtime (const struct grub_xfs_inode *inode)
+{
+ return inode->version >= 3 &&
+ (inode->flags2 & grub_cpu_to_be64_compile_time (XFS_DIFLAG2_BIGTIME));
+}
+
+static grub_int64_t
+grub_xfs_get_inode_time (struct grub_xfs_inode *inode)
+{
+ struct grub_xfs_time_legacy *lts;
+
+ if (grub_xfs_inode_has_bigtime (inode))
+ return grub_divmod64 (grub_be_to_cpu64 (inode->mtime), NSEC_PER_SEC, NULL) - XFS_BIGTIME_EPOCH_OFFSET;
+
+ lts = (struct grub_xfs_time_legacy *) &inode->mtime;
+ return grub_be_to_cpu32 (lts->sec);
+}
+
+/* Helper for grub_xfs_dir. */
+static int
+grub_xfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node, void *data)
+{
+ struct grub_xfs_dir_ctx *ctx = data;
+ struct grub_dirhook_info info;
+
+ grub_memset (&info, 0, sizeof (info));
+ if (node->inode_read)
+ {
+ info.mtimeset = 1;
+ info.mtime = grub_xfs_get_inode_time (&node->inode);
+ }
+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
+ grub_free (node);
+ return ctx->hook (filename, &info, ctx->hook_data);
+}
+
+static grub_err_t
+grub_xfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_xfs_dir_ctx ctx = { hook, hook_data };
+ struct grub_xfs_data *data = 0;
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_xfs_mount (device->disk);
+ if (!data)
+ goto mount_fail;
+
+ grub_fshelp_find_file (path, &data->diropen, &fdiro, grub_xfs_iterate_dir,
+ grub_xfs_read_symlink, GRUB_FSHELP_DIR);
+ if (grub_errno)
+ goto fail;
+
+ grub_xfs_iterate_dir (fdiro, grub_xfs_dir_iter, &ctx);
+
+ fail:
+ if (fdiro != &data->diropen)
+ grub_free (fdiro);
+ grub_free (data);
+
+ mount_fail:
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_xfs_open (struct grub_file *file, const char *name)
+{
+ struct grub_xfs_data *data;
+ struct grub_fshelp_node *fdiro = 0;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_xfs_mount (file->device->disk);
+ if (!data)
+ goto mount_fail;
+
+ grub_fshelp_find_file (name, &data->diropen, &fdiro, grub_xfs_iterate_dir,
+ grub_xfs_read_symlink, GRUB_FSHELP_REG);
+ if (grub_errno)
+ goto fail;
+
+ if (!fdiro->inode_read)
+ {
+ grub_xfs_read_inode (data, fdiro->ino, &fdiro->inode);
+ if (grub_errno)
+ goto fail;
+ }
+
+ if (fdiro != &data->diropen)
+ {
+ grub_memcpy (&data->diropen, fdiro, grub_xfs_fshelp_size(data));
+ grub_free (fdiro);
+ }
+
+ file->size = grub_be_to_cpu64 (data->diropen.inode.size);
+ file->data = data;
+ file->offset = 0;
+
+ return 0;
+
+ fail:
+ if (fdiro != &data->diropen)
+ grub_free (fdiro);
+ grub_free (data);
+
+ mount_fail:
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+
+static grub_ssize_t
+grub_xfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_xfs_data *data =
+ (struct grub_xfs_data *) file->data;
+
+ return grub_xfs_read_file (&data->diropen,
+ file->read_hook, file->read_hook_data,
+ file->offset, len, buf, 0);
+}
+
+
+static grub_err_t
+grub_xfs_close (grub_file_t file)
+{
+ grub_free (file->data);
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+
+static grub_err_t
+grub_xfs_label (grub_device_t device, char **label)
+{
+ struct grub_xfs_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_xfs_mount (disk);
+ if (data)
+ *label = grub_strndup ((char *) (data->sblock.label), 12);
+ else
+ *label = 0;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_xfs_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_xfs_data *data;
+ grub_disk_t disk = device->disk;
+
+ grub_dl_ref (my_mod);
+
+ data = grub_xfs_mount (disk);
+ if (data)
+ {
+ *uuid = grub_xasprintf ("%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
+ grub_be_to_cpu16 (data->sblock.uuid[0]),
+ grub_be_to_cpu16 (data->sblock.uuid[1]),
+ grub_be_to_cpu16 (data->sblock.uuid[2]),
+ grub_be_to_cpu16 (data->sblock.uuid[3]),
+ grub_be_to_cpu16 (data->sblock.uuid[4]),
+ grub_be_to_cpu16 (data->sblock.uuid[5]),
+ grub_be_to_cpu16 (data->sblock.uuid[6]),
+ grub_be_to_cpu16 (data->sblock.uuid[7]));
+ }
+ else
+ *uuid = NULL;
+
+ grub_dl_unref (my_mod);
+
+ grub_free (data);
+
+ return grub_errno;
+}
+
+
+
+static struct grub_fs grub_xfs_fs =
+ {
+ .name = "xfs",
+ .fs_dir = grub_xfs_dir,
+ .fs_open = grub_xfs_open,
+ .fs_read = grub_xfs_read,
+ .fs_close = grub_xfs_close,
+ .fs_label = grub_xfs_label,
+ .fs_uuid = grub_xfs_uuid,
+#ifdef GRUB_UTIL
+ .reserved_first_sector = 0,
+ .blocklist_install = 1,
+#endif
+ .next = 0
+ };
+
+GRUB_MOD_INIT(xfs)
+{
+ grub_fs_register (&grub_xfs_fs);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(xfs)
+{
+ grub_fs_unregister (&grub_xfs_fs);
+}
diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c
new file mode 100644
index 0000000..cf4d2ab
--- /dev/null
+++ b/grub-core/fs/zfs/zfs.c
@@ -0,0 +1,4406 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2009,2010,2011 Free Software Foundation, Inc.
+ * Copyright 2010 Sun Microsystems, Inc.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ *
+ * GRUB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * The zfs plug-in routines for GRUB are:
+ *
+ * zfs_mount() - locates a valid uberblock of the root pool and reads
+ * in its MOS at the memory address MOS.
+ *
+ * zfs_open() - locates a plain file object by following the MOS
+ * and places its dnode at the memory address DNODE.
+ *
+ * zfs_read() - read in the data blocks pointed by the DNODE.
+ *
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/zfs/zfs.h>
+#include <grub/zfs/zio.h>
+#include <grub/zfs/dnode.h>
+#include <grub/zfs/uberblock_impl.h>
+#include <grub/zfs/vdev_impl.h>
+#include <grub/zfs/zio_checksum.h>
+#include <grub/zfs/zap_impl.h>
+#include <grub/zfs/zap_leaf.h>
+#include <grub/zfs/zfs_znode.h>
+#include <grub/zfs/dmu.h>
+#include <grub/zfs/dmu_objset.h>
+#include <grub/zfs/sa_impl.h>
+#include <grub/zfs/dsl_dir.h>
+#include <grub/zfs/dsl_dataset.h>
+#include <grub/deflate.h>
+#include <grub/crypto.h>
+#include <grub/i18n.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define ZPOOL_PROP_BOOTFS "bootfs"
+
+/*
+ * For nvlist manipulation. (from nvpair.h)
+ */
+#define NV_ENCODE_NATIVE 0
+#define NV_ENCODE_XDR 1
+#define NV_BIG_ENDIAN 0
+#define NV_LITTLE_ENDIAN 1
+#define DATA_TYPE_UINT64 8
+#define DATA_TYPE_STRING 9
+#define DATA_TYPE_NVLIST 19
+#define DATA_TYPE_NVLIST_ARRAY 20
+
+#ifndef GRUB_UTIL
+static grub_dl_t my_mod;
+#endif
+
+#define P2PHASE(x, align) ((x) & ((align) - 1))
+
+static inline grub_disk_addr_t
+DVA_OFFSET_TO_PHYS_SECTOR (grub_disk_addr_t offset)
+{
+ return ((offset + VDEV_LABEL_START_SIZE) >> SPA_MINBLOCKSHIFT);
+}
+
+/*
+ * FAT ZAP data structures
+ */
+#define ZFS_CRC64_POLY 0xC96C5795D7870F42ULL /* ECMA-182, reflected form */
+static inline grub_uint64_t
+ZAP_HASH_IDX (grub_uint64_t hash, grub_uint64_t n)
+{
+ return (((n) == 0) ? 0 : ((hash) >> (64 - (n))));
+}
+
+#define CHAIN_END 0xffff /* end of the chunk chain */
+
+/*
+ * The amount of space within the chunk available for the array is:
+ * chunk size - space for type (1) - space for next pointer (2)
+ */
+#define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3)
+
+static inline int
+ZAP_LEAF_HASH_SHIFT (int bs)
+{
+ return bs - 5;
+}
+
+static inline int
+ZAP_LEAF_HASH_NUMENTRIES (int bs)
+{
+ return 1 << ZAP_LEAF_HASH_SHIFT(bs);
+}
+
+static inline grub_size_t
+LEAF_HASH (int bs, grub_uint64_t h, zap_leaf_phys_t *l)
+{
+ return ((ZAP_LEAF_HASH_NUMENTRIES (bs)-1)
+ & ((h) >> (64 - ZAP_LEAF_HASH_SHIFT (bs) - l->l_hdr.lh_prefix_len)));
+}
+
+/*
+ * The amount of space available for chunks is:
+ * block size shift - hash entry size (2) * number of hash
+ * entries - header space (2*chunksize)
+ */
+static inline int
+ZAP_LEAF_NUMCHUNKS (int bs)
+{
+ return (((1U << bs) - 2 * ZAP_LEAF_HASH_NUMENTRIES (bs)) /
+ ZAP_LEAF_CHUNKSIZE - 2);
+}
+
+/*
+ * The chunks start immediately after the hash table. The end of the
+ * hash table is at l_hash + HASH_NUMENTRIES, which we simply cast to a
+ * chunk_t.
+ */
+static inline zap_leaf_chunk_t *
+ZAP_LEAF_CHUNK (zap_leaf_phys_t *l, int bs, int idx)
+{
+ grub_properly_aligned_t *l_entries;
+
+ l_entries = (grub_properly_aligned_t *) ALIGN_UP((grub_addr_t)l->l_hash, sizeof (grub_properly_aligned_t));
+ return &((zap_leaf_chunk_t *) (l_entries
+ + (ZAP_LEAF_HASH_NUMENTRIES(bs) * 2)
+ / sizeof (grub_properly_aligned_t)))[idx];
+}
+
+static inline struct zap_leaf_entry *
+ZAP_LEAF_ENTRY(zap_leaf_phys_t *l, int bs, int idx)
+{
+ return &ZAP_LEAF_CHUNK(l, bs, idx)->l_entry;
+}
+
+
+/*
+ * Decompression Entry - lzjb & lz4
+ */
+
+extern grub_err_t lzjb_decompress (void *, void *, grub_size_t, grub_size_t);
+
+extern grub_err_t lz4_decompress (void *, void *, grub_size_t, grub_size_t);
+
+typedef grub_err_t zfs_decomp_func_t (void *s_start, void *d_start,
+ grub_size_t s_len, grub_size_t d_len);
+typedef struct decomp_entry
+{
+ const char *name;
+ zfs_decomp_func_t *decomp_func;
+} decomp_entry_t;
+
+/*
+ * Signature for checksum functions.
+ */
+typedef void zio_checksum_t(const void *data, grub_uint64_t size,
+ grub_zfs_endian_t endian, zio_cksum_t *zcp);
+
+/*
+ * Information about each checksum function.
+ */
+typedef struct zio_checksum_info {
+ zio_checksum_t *ci_func; /* checksum function for each byteorder */
+ int ci_correctable; /* number of correctable bits */
+ int ci_eck; /* uses zio embedded checksum? */
+ const char *ci_name; /* descriptive name */
+} zio_checksum_info_t;
+
+typedef struct dnode_end
+{
+ dnode_phys_t dn;
+ grub_zfs_endian_t endian;
+} dnode_end_t;
+
+struct grub_zfs_device_desc
+{
+ enum { DEVICE_LEAF, DEVICE_MIRROR, DEVICE_RAIDZ } type;
+ grub_uint64_t id;
+ grub_uint64_t guid;
+ unsigned ashift;
+ unsigned max_children_ashift;
+
+ /* Valid only for non-leafs. */
+ unsigned n_children;
+ struct grub_zfs_device_desc *children;
+
+ /* Valid only for RAIDZ. */
+ unsigned nparity;
+
+ /* Valid only for leaf devices. */
+ grub_device_t dev;
+ grub_disk_addr_t vdev_phys_sector;
+ uberblock_t current_uberblock;
+ int original;
+};
+
+struct subvolume
+{
+ dnode_end_t mdn;
+ grub_uint64_t obj;
+ grub_uint64_t case_insensitive;
+ grub_size_t nkeys;
+ struct
+ {
+ grub_crypto_cipher_handle_t cipher;
+ grub_uint64_t txg;
+ grub_uint64_t algo;
+ } *keyring;
+};
+
+struct grub_zfs_data
+{
+ /* cache for a file block of the currently zfs_open()-ed file */
+ char *file_buf;
+ grub_uint64_t file_start;
+ grub_uint64_t file_end;
+
+ /* cache for a dnode block */
+ dnode_phys_t *dnode_buf;
+ dnode_phys_t *dnode_mdn;
+ grub_uint64_t dnode_start;
+ grub_uint64_t dnode_end;
+ grub_zfs_endian_t dnode_endian;
+
+ dnode_end_t mos;
+ dnode_end_t dnode;
+ struct subvolume subvol;
+
+ struct grub_zfs_device_desc *devices_attached;
+ unsigned n_devices_attached;
+ unsigned n_devices_allocated;
+ struct grub_zfs_device_desc *device_original;
+
+ uberblock_t current_uberblock;
+
+ grub_uint64_t guid;
+};
+
+/* Context for grub_zfs_dir. */
+struct grub_zfs_dir_ctx
+{
+ grub_fs_dir_hook_t hook;
+ void *hook_data;
+ struct grub_zfs_data *data;
+};
+
+grub_err_t (*grub_zfs_decrypt) (grub_crypto_cipher_handle_t cipher,
+ grub_uint64_t algo,
+ void *nonce,
+ char *buf, grub_size_t size,
+ const grub_uint32_t *expected_mac,
+ grub_zfs_endian_t endian) = NULL;
+grub_crypto_cipher_handle_t (*grub_zfs_load_key) (const struct grub_zfs_key *key,
+ grub_size_t keysize,
+ grub_uint64_t salt,
+ grub_uint64_t algo) = NULL;
+/*
+ * List of pool features that the grub implementation of ZFS supports for
+ * read. Note that features that are only required for write do not need
+ * to be listed here since grub opens pools in read-only mode.
+ */
+#define MAX_SUPPORTED_FEATURE_STRLEN 50
+static const char *spa_feature_names[] = {
+ "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 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) == (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
+zle_decompress (void *s, void *d,
+ grub_size_t slen, grub_size_t dlen)
+{
+ grub_uint8_t *iptr, *optr;
+ grub_size_t clen;
+ for (iptr = s, optr = d; iptr < (grub_uint8_t *) s + slen
+ && optr < (grub_uint8_t *) d + dlen;)
+ {
+ if (*iptr & 0x80)
+ clen = ((*iptr) & 0x7f) + 0x41;
+ else
+ clen = ((*iptr) & 0x3f) + 1;
+ if ((grub_ssize_t) clen > (grub_uint8_t *) d + dlen - optr)
+ clen = (grub_uint8_t *) d + dlen - optr;
+ if (*iptr & 0x40 || *iptr & 0x80)
+ {
+ grub_memset (optr, 0, clen);
+ iptr++;
+ optr += clen;
+ continue;
+ }
+ if ((grub_ssize_t) clen > (grub_uint8_t *) s + slen - iptr - 1)
+ clen = (grub_uint8_t *) s + slen - iptr - 1;
+ grub_memcpy (optr, iptr + 1, clen);
+ optr += clen;
+ iptr += clen + 1;
+ }
+ if (optr < (grub_uint8_t *) d + dlen)
+ grub_memset (optr, 0, (grub_uint8_t *) d + dlen - optr);
+ return GRUB_ERR_NONE;
+}
+
+static decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = {
+ {"inherit", NULL}, /* ZIO_COMPRESS_INHERIT */
+ {"on", lzjb_decompress}, /* ZIO_COMPRESS_ON */
+ {"off", NULL}, /* ZIO_COMPRESS_OFF */
+ {"lzjb", lzjb_decompress}, /* ZIO_COMPRESS_LZJB */
+ {"empty", NULL}, /* ZIO_COMPRESS_EMPTY */
+ {"gzip-1", zlib_decompress}, /* ZIO_COMPRESS_GZIP1 */
+ {"gzip-2", zlib_decompress}, /* ZIO_COMPRESS_GZIP2 */
+ {"gzip-3", zlib_decompress}, /* ZIO_COMPRESS_GZIP3 */
+ {"gzip-4", zlib_decompress}, /* ZIO_COMPRESS_GZIP4 */
+ {"gzip-5", zlib_decompress}, /* ZIO_COMPRESS_GZIP5 */
+ {"gzip-6", zlib_decompress}, /* ZIO_COMPRESS_GZIP6 */
+ {"gzip-7", zlib_decompress}, /* ZIO_COMPRESS_GZIP7 */
+ {"gzip-8", zlib_decompress}, /* ZIO_COMPRESS_GZIP8 */
+ {"gzip-9", zlib_decompress}, /* ZIO_COMPRESS_GZIP9 */
+ {"zle", zle_decompress}, /* ZIO_COMPRESS_ZLE */
+ {"lz4", lz4_decompress}, /* ZIO_COMPRESS_LZ4 */
+};
+
+static grub_err_t zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian,
+ void *buf, struct grub_zfs_data *data);
+
+/*
+ * Our own version of log2(). Same thing as highbit()-1.
+ */
+static int
+zfs_log2 (grub_uint64_t num)
+{
+ int i = 0;
+
+ while (num > 1)
+ {
+ i++;
+ num = num >> 1;
+ }
+
+ return i;
+}
+
+/* Checksum Functions */
+static void
+zio_checksum_off (const void *buf __attribute__ ((unused)),
+ grub_uint64_t size __attribute__ ((unused)),
+ grub_zfs_endian_t endian __attribute__ ((unused)),
+ zio_cksum_t * zcp)
+{
+ ZIO_SET_CHECKSUM (zcp, 0, 0, 0, 0);
+}
+
+/* Checksum Table and Values */
+static zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = {
+ {NULL, 0, 0, "inherit"},
+ {NULL, 0, 0, "on"},
+ {zio_checksum_off, 0, 0, "off"},
+ {zio_checksum_SHA256, 1, 1, "label"},
+ {zio_checksum_SHA256, 1, 1, "gang_header"},
+ {NULL, 0, 0, "zilog"},
+ {fletcher_2, 0, 0, "fletcher2"},
+ {fletcher_4, 1, 0, "fletcher4"},
+ {zio_checksum_SHA256, 1, 0, "SHA256"},
+ {NULL, 0, 0, "zilog2"},
+ {zio_checksum_SHA256, 1, 0, "SHA256+MAC"},
+};
+
+/*
+ * zio_checksum_verify: Provides support for checksum verification.
+ *
+ * Fletcher2, Fletcher4, and SHA256 are supported.
+ *
+ */
+static grub_err_t
+zio_checksum_verify (zio_cksum_t zc, grub_uint32_t checksum,
+ grub_zfs_endian_t endian,
+ char *buf, grub_size_t size)
+{
+ zio_eck_t *zec = (zio_eck_t *) (buf + size) - 1;
+ zio_checksum_info_t *ci = &zio_checksum_table[checksum];
+ zio_cksum_t actual_cksum, expected_cksum;
+
+ if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func == NULL)
+ {
+ grub_dprintf ("zfs", "unknown checksum function %d\n", checksum);
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unknown checksum function %d", checksum);
+ }
+
+ if (ci->ci_eck)
+ {
+ expected_cksum = zec->zec_cksum;
+ zec->zec_cksum = zc;
+ ci->ci_func (buf, size, endian, &actual_cksum);
+ zec->zec_cksum = expected_cksum;
+ zc = expected_cksum;
+ }
+ else
+ ci->ci_func (buf, size, endian, &actual_cksum);
+
+ if (grub_memcmp (&actual_cksum, &zc,
+ checksum != ZIO_CHECKSUM_SHA256_MAC ? 32 : 20) != 0)
+ {
+ grub_dprintf ("zfs", "checksum %s verification failed\n", ci->ci_name);
+ grub_dprintf ("zfs", "actual checksum %016llx %016llx %016llx %016llx\n",
+ (unsigned long long) actual_cksum.zc_word[0],
+ (unsigned long long) actual_cksum.zc_word[1],
+ (unsigned long long) actual_cksum.zc_word[2],
+ (unsigned long long) actual_cksum.zc_word[3]);
+ grub_dprintf ("zfs", "expected checksum %016llx %016llx %016llx %016llx\n",
+ (unsigned long long) zc.zc_word[0],
+ (unsigned long long) zc.zc_word[1],
+ (unsigned long long) zc.zc_word[2],
+ (unsigned long long) zc.zc_word[3]);
+ return grub_error (GRUB_ERR_BAD_FS, N_("checksum verification failed"));
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/*
+ * vdev_uberblock_compare takes two uberblock structures and returns an integer
+ * indicating the more recent of the two.
+ * Return Value = 1 if ub2 is more recent
+ * Return Value = -1 if ub1 is more recent
+ * The most recent uberblock is determined using its transaction number and
+ * timestamp. The uberblock with the highest transaction number is
+ * considered "newer". If the transaction numbers of the two blocks match, the
+ * timestamps are compared to determine the "newer" of the two.
+ */
+static int
+vdev_uberblock_compare (uberblock_t * ub1, uberblock_t * ub2)
+{
+ grub_zfs_endian_t ub1_endian, ub2_endian;
+ if (grub_zfs_to_cpu64 (ub1->ub_magic, GRUB_ZFS_LITTLE_ENDIAN)
+ == UBERBLOCK_MAGIC)
+ ub1_endian = GRUB_ZFS_LITTLE_ENDIAN;
+ else
+ ub1_endian = GRUB_ZFS_BIG_ENDIAN;
+ if (grub_zfs_to_cpu64 (ub2->ub_magic, GRUB_ZFS_LITTLE_ENDIAN)
+ == UBERBLOCK_MAGIC)
+ ub2_endian = GRUB_ZFS_LITTLE_ENDIAN;
+ else
+ ub2_endian = GRUB_ZFS_BIG_ENDIAN;
+
+ if (grub_zfs_to_cpu64 (ub1->ub_txg, ub1_endian)
+ < grub_zfs_to_cpu64 (ub2->ub_txg, ub2_endian))
+ return -1;
+ if (grub_zfs_to_cpu64 (ub1->ub_txg, ub1_endian)
+ > grub_zfs_to_cpu64 (ub2->ub_txg, ub2_endian))
+ return 1;
+
+ if (grub_zfs_to_cpu64 (ub1->ub_timestamp, ub1_endian)
+ < grub_zfs_to_cpu64 (ub2->ub_timestamp, ub2_endian))
+ return -1;
+ if (grub_zfs_to_cpu64 (ub1->ub_timestamp, ub1_endian)
+ > grub_zfs_to_cpu64 (ub2->ub_timestamp, ub2_endian))
+ return 1;
+
+ return 0;
+}
+
+/*
+ * Three pieces of information are needed to verify an uberblock: the magic
+ * number, the version number, and the checksum.
+ *
+ * Currently Implemented: version number, magic number, checksum
+ *
+ */
+static grub_err_t
+uberblock_verify (uberblock_phys_t * ub, grub_uint64_t offset,
+ grub_size_t s)
+{
+ uberblock_t *uber = &ub->ubp_uberblock;
+ grub_err_t err;
+ grub_zfs_endian_t endian = GRUB_ZFS_UNKNOWN_ENDIAN;
+ zio_cksum_t zc;
+
+ if (grub_zfs_to_cpu64 (uber->ub_magic, GRUB_ZFS_LITTLE_ENDIAN)
+ == UBERBLOCK_MAGIC
+ && SPA_VERSION_IS_SUPPORTED(grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_LITTLE_ENDIAN)))
+ endian = GRUB_ZFS_LITTLE_ENDIAN;
+
+ if (grub_zfs_to_cpu64 (uber->ub_magic, GRUB_ZFS_BIG_ENDIAN) == UBERBLOCK_MAGIC
+ && SPA_VERSION_IS_SUPPORTED(grub_zfs_to_cpu64 (uber->ub_version, GRUB_ZFS_BIG_ENDIAN)))
+ endian = GRUB_ZFS_BIG_ENDIAN;
+
+ if (endian == GRUB_ZFS_UNKNOWN_ENDIAN)
+ return grub_error (GRUB_ERR_BAD_FS, "invalid uberblock magic");
+
+ grub_memset (&zc, 0, sizeof (zc));
+
+ zc.zc_word[0] = grub_cpu_to_zfs64 (offset, endian);
+ err = zio_checksum_verify (zc, ZIO_CHECKSUM_LABEL, endian,
+ (char *) ub, s);
+
+ return err;
+}
+
+/*
+ * Find the best uberblock.
+ * Return:
+ * Success - Pointer to the best uberblock.
+ * Failure - NULL
+ */
+static uberblock_phys_t *
+find_bestub (uberblock_phys_t * ub_array,
+ const struct grub_zfs_device_desc *desc)
+{
+ uberblock_phys_t *ubbest = NULL, *ubptr;
+ int i;
+ grub_disk_addr_t offset;
+ grub_err_t err = GRUB_ERR_NONE;
+ int ub_shift;
+
+ ub_shift = desc->ashift;
+ if (ub_shift < VDEV_UBERBLOCK_SHIFT)
+ ub_shift = VDEV_UBERBLOCK_SHIFT;
+
+ for (i = 0; i < (VDEV_UBERBLOCK_RING >> ub_shift); i++)
+ {
+ offset = (desc->vdev_phys_sector << SPA_MINBLOCKSHIFT) + VDEV_PHYS_SIZE
+ + (i << ub_shift);
+
+ ubptr = (uberblock_phys_t *) ((grub_properly_aligned_t *) ub_array
+ + ((i << ub_shift)
+ / sizeof (grub_properly_aligned_t)));
+ err = uberblock_verify (ubptr, offset, (grub_size_t) 1 << ub_shift);
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ if (ubbest == NULL
+ || vdev_uberblock_compare (&(ubptr->ubp_uberblock),
+ &(ubbest->ubp_uberblock)) > 0)
+ ubbest = ubptr;
+ }
+ if (!ubbest)
+ grub_errno = err;
+
+ return ubbest;
+}
+
+static inline grub_size_t
+get_psize (blkptr_t * bp, grub_zfs_endian_t endian)
+{
+ return ((((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) >> 16) & 0xffff) + 1)
+ << SPA_MINBLOCKSHIFT);
+}
+
+static grub_uint64_t
+dva_get_offset (const dva_t *dva, grub_zfs_endian_t endian)
+{
+ grub_dprintf ("zfs", "dva=%llx, %llx\n",
+ (unsigned long long) dva->dva_word[0],
+ (unsigned long long) dva->dva_word[1]);
+ return grub_zfs_to_cpu64 ((dva)->dva_word[1],
+ endian) << SPA_MINBLOCKSHIFT;
+}
+
+static grub_err_t
+zfs_fetch_nvlist (struct grub_zfs_device_desc *diskdesc, char **nvlist)
+{
+ grub_err_t err;
+
+ *nvlist = 0;
+
+ if (!diskdesc->dev)
+ return grub_error (GRUB_ERR_BUG, "member drive unknown");
+
+ *nvlist = grub_malloc (VDEV_PHYS_SIZE);
+
+ /* Read in the vdev name-value pair list (112K). */
+ err = grub_disk_read (diskdesc->dev->disk, diskdesc->vdev_phys_sector, 0,
+ VDEV_PHYS_SIZE, *nvlist);
+ if (err)
+ {
+ grub_free (*nvlist);
+ *nvlist = 0;
+ return err;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+fill_vdev_info_real (struct grub_zfs_data *data,
+ const char *nvlist,
+ struct grub_zfs_device_desc *fill,
+ struct grub_zfs_device_desc *insert,
+ int *inserted,
+ unsigned ashift)
+{
+ char *type;
+
+ type = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_TYPE);
+
+ if (!type)
+ return grub_errno;
+
+ if (!grub_zfs_nvlist_lookup_uint64 (nvlist, "id", &(fill->id)))
+ {
+ grub_free (type);
+ return grub_error (GRUB_ERR_BAD_FS, "couldn't find vdev id");
+ }
+
+ if (!grub_zfs_nvlist_lookup_uint64 (nvlist, "guid", &(fill->guid)))
+ {
+ grub_free (type);
+ return grub_error (GRUB_ERR_BAD_FS, "couldn't find vdev id");
+ }
+
+ {
+ grub_uint64_t par;
+ if (grub_zfs_nvlist_lookup_uint64 (nvlist, "ashift", &par))
+ fill->ashift = par;
+ else if (ashift != 0xffffffff)
+ fill->ashift = ashift;
+ else
+ {
+ grub_free (type);
+ return grub_error (GRUB_ERR_BAD_FS, "couldn't find ashift");
+ }
+ }
+
+ fill->max_children_ashift = 0;
+
+ if (grub_strcmp (type, VDEV_TYPE_DISK) == 0
+ || grub_strcmp (type, VDEV_TYPE_FILE) == 0)
+ {
+ fill->type = DEVICE_LEAF;
+
+ if (!fill->dev && fill->guid == insert->guid)
+ {
+ fill->dev = insert->dev;
+ fill->vdev_phys_sector = insert->vdev_phys_sector;
+ fill->current_uberblock = insert->current_uberblock;
+ fill->original = insert->original;
+ if (!data->device_original)
+ data->device_original = fill;
+ insert->ashift = fill->ashift;
+ *inserted = 1;
+ }
+
+ grub_free (type);
+
+ return GRUB_ERR_NONE;
+ }
+
+ if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0
+ || grub_strcmp (type, VDEV_TYPE_RAIDZ) == 0)
+ {
+ int nelm, i;
+
+ if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0)
+ fill->type = DEVICE_MIRROR;
+ else
+ {
+ grub_uint64_t par;
+ fill->type = DEVICE_RAIDZ;
+ if (!grub_zfs_nvlist_lookup_uint64 (nvlist, "nparity", &par))
+ {
+ grub_free (type);
+ return grub_error (GRUB_ERR_BAD_FS, "couldn't find raidz parity");
+ }
+ fill->nparity = par;
+ }
+
+ nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm (nvlist,
+ ZPOOL_CONFIG_CHILDREN);
+
+ if (nelm <= 0)
+ {
+ grub_free (type);
+ return grub_error (GRUB_ERR_BAD_FS, "incorrect mirror VDEV");
+ }
+
+ if (!fill->children)
+ {
+ fill->n_children = nelm;
+
+ fill->children = grub_zalloc (fill->n_children
+ * sizeof (fill->children[0]));
+ }
+
+ for (i = 0; i < nelm; i++)
+ {
+ char *child;
+ grub_err_t err;
+
+ child = grub_zfs_nvlist_lookup_nvlist_array
+ (nvlist, ZPOOL_CONFIG_CHILDREN, i);
+
+ err = fill_vdev_info_real (data, child, &fill->children[i], insert,
+ inserted, fill->ashift);
+
+ grub_free (child);
+
+ if (err)
+ {
+ grub_free (type);
+ return err;
+ }
+ if (fill->children[i].ashift > fill->max_children_ashift)
+ fill->max_children_ashift = fill->children[i].ashift;
+ }
+ grub_free (type);
+ return GRUB_ERR_NONE;
+ }
+
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "vdev %s isn't supported", type);
+ grub_free (type);
+ return grub_errno;
+}
+
+static grub_err_t
+fill_vdev_info (struct grub_zfs_data *data,
+ char *nvlist, struct grub_zfs_device_desc *diskdesc,
+ int *inserted)
+{
+ grub_uint64_t id;
+ unsigned i;
+
+ *inserted = 0;
+
+ if (!grub_zfs_nvlist_lookup_uint64 (nvlist, "id", &id))
+ return grub_error (GRUB_ERR_BAD_FS, "couldn't find vdev id");
+
+ for (i = 0; i < data->n_devices_attached; i++)
+ if (data->devices_attached[i].id == id)
+ return fill_vdev_info_real (data, nvlist, &data->devices_attached[i],
+ diskdesc, inserted, 0xffffffff);
+
+ data->n_devices_attached++;
+ if (data->n_devices_attached > data->n_devices_allocated)
+ {
+ void *tmp;
+ grub_size_t sz;
+
+ if (grub_mul (data->n_devices_attached, 2, &data->n_devices_allocated) ||
+ grub_add (data->n_devices_allocated, 1, &data->n_devices_allocated) ||
+ grub_mul (data->n_devices_allocated, sizeof (data->devices_attached[0]), &sz))
+ return GRUB_ERR_OUT_OF_RANGE;
+
+ data->devices_attached = grub_realloc (tmp = data->devices_attached, sz);
+ if (!data->devices_attached)
+ {
+ data->devices_attached = tmp;
+ return grub_errno;
+ }
+ }
+
+ grub_memset (&data->devices_attached[data->n_devices_attached - 1],
+ 0, sizeof (data->devices_attached[data->n_devices_attached - 1]));
+
+ return fill_vdev_info_real (data, nvlist,
+ &data->devices_attached[data->n_devices_attached - 1],
+ diskdesc, inserted, 0xffffffff);
+}
+
+/*
+ * For a given XDR packed nvlist, verify the first 4 bytes and move on.
+ *
+ * An XDR packed nvlist is encoded as (comments from nvs_xdr_create) :
+ *
+ * encoding method/host endian (4 bytes)
+ * nvl_version (4 bytes)
+ * nvl_nvflag (4 bytes)
+ * encoded nvpairs:
+ * encoded size of the nvpair (4 bytes)
+ * decoded size of the nvpair (4 bytes)
+ * name string size (4 bytes)
+ * name string data (sizeof(NV_ALIGN4(string))
+ * data type (4 bytes)
+ * # of elements in the nvpair (4 bytes)
+ * data
+ * 2 zero's for the last nvpair
+ * (end of the entire list) (8 bytes)
+ *
+ */
+
+/*
+ * The nvlist_next_nvpair() function returns a handle to the next nvpair in the
+ * list following nvpair. If nvpair is NULL, the first pair is returned. If
+ * nvpair is the last pair in the nvlist, NULL is returned.
+ */
+static const char *
+nvlist_next_nvpair (const char *nvl, const char *nvpair)
+{
+ const char *nvp;
+ int encode_size;
+ int name_len;
+ if (nvl == NULL)
+ return NULL;
+
+ if (nvpair == NULL)
+ {
+ /* skip over header, nvl_version and nvl_nvflag */
+ nvpair = nvl + 4 * 3;
+ }
+ else
+ {
+ /* skip to the next nvpair */
+ encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvpair));
+ nvpair += encode_size;
+ /*If encode_size equals 0 nvlist_next_nvpair would return
+ * the same pair received in input, leading to an infinite loop.
+ * If encode_size is less than 0, this will move the pointer
+ * backwards, *possibly* examinining two times the same nvpair
+ * and potentially getting into an infinite loop. */
+ if(encode_size <= 0)
+ {
+ grub_dprintf ("zfs", "nvpair with size <= 0\n");
+ grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist");
+ return NULL;
+ }
+ }
+ /* 8 bytes of 0 marks the end of the list */
+ if (grub_get_unaligned64 (nvpair) == 0)
+ return NULL;
+ /*consistency checks*/
+ if (nvpair + 4 * 3 >= nvl + VDEV_PHYS_SIZE)
+ {
+ grub_dprintf ("zfs", "nvlist overflow\n");
+ grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist");
+ return NULL;
+ }
+ encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvpair));
+
+ nvp = nvpair + 4*2;
+ name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp));
+ nvp += 4;
+
+ nvp = nvp + ((name_len + 3) & ~3); // align
+ if (nvp + 4 >= nvl + VDEV_PHYS_SIZE
+ || encode_size < 0
+ || nvp + 4 + encode_size > nvl + VDEV_PHYS_SIZE)
+ {
+ grub_dprintf ("zfs", "nvlist overflow\n");
+ grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist");
+ return NULL;
+ }
+ /* end consistency checks */
+
+ return nvpair;
+}
+
+/*
+ * This function returns 0 on success and 1 on failure. On success, a string
+ * containing the name of nvpair is saved in buf.
+ */
+static int
+nvpair_name (const char *nvp, char **buf, grub_size_t *buflen)
+{
+ /* skip over encode/decode size */
+ nvp += 4 * 2;
+
+ *buf = (char *) (nvp + 4);
+ *buflen = grub_be_to_cpu32 (grub_get_unaligned32 (nvp));
+
+ return 0;
+}
+
+/*
+ * This function retrieves the value of the nvpair in the form of enumerated
+ * type data_type_t.
+ */
+static int
+nvpair_type (const char *nvp)
+{
+ int name_len, type;
+
+ /* skip over encode/decode size */
+ nvp += 4 * 2;
+
+ /* skip over name_len */
+ name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp));
+ nvp += 4;
+
+ /* skip over name */
+ nvp = nvp + ((name_len + 3) & ~3); /* align */
+
+ type = grub_be_to_cpu32 (grub_get_unaligned32 (nvp));
+
+ return type;
+}
+
+static int
+nvpair_value (const char *nvp,char **val,
+ grub_size_t *size_out, grub_size_t *nelm_out)
+{
+ int name_len,nelm,encode_size;
+
+ /* skip over encode/decode size */
+ encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvp));
+ nvp += 8;
+
+ /* skip over name_len */
+ name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp));
+ nvp += 4;
+
+ /* skip over name */
+ nvp = nvp + ((name_len + 3) & ~3); /* align */
+
+ /* skip over type */
+ nvp += 4;
+ nelm = grub_be_to_cpu32 (grub_get_unaligned32 (nvp));
+ nvp +=4;
+ if (nelm < 1)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "empty nvpair");
+ return 0;
+ }
+ *val = (char *) nvp;
+ *size_out = encode_size;
+ if (nelm_out)
+ *nelm_out = nelm;
+
+ return 1;
+}
+
+/*
+ * Check the disk label information and retrieve needed vdev name-value pairs.
+ *
+ */
+static grub_err_t
+check_pool_label (struct grub_zfs_data *data,
+ struct grub_zfs_device_desc *diskdesc,
+ int *inserted, int original)
+{
+ grub_uint64_t pool_state, txg = 0;
+ char *nvlist,*features;
+#if 0
+ char *nv;
+#endif
+ grub_uint64_t poolguid;
+ grub_uint64_t version;
+ int found;
+ grub_err_t err;
+ grub_zfs_endian_t endian;
+ vdev_phys_t *phys;
+ zio_cksum_t emptycksum;
+
+ *inserted = 0;
+
+ err = zfs_fetch_nvlist (diskdesc, &nvlist);
+ if (err)
+ return err;
+
+ phys = (vdev_phys_t*) nvlist;
+ if (grub_zfs_to_cpu64 (phys->vp_zbt.zec_magic,
+ GRUB_ZFS_LITTLE_ENDIAN)
+ == ZEC_MAGIC)
+ endian = GRUB_ZFS_LITTLE_ENDIAN;
+ else if (grub_zfs_to_cpu64 (phys->vp_zbt.zec_magic,
+ GRUB_ZFS_BIG_ENDIAN)
+ == ZEC_MAGIC)
+ endian = GRUB_ZFS_BIG_ENDIAN;
+ else
+ {
+ grub_free (nvlist);
+ return grub_error (GRUB_ERR_BAD_FS,
+ "bad vdev_phys_t.vp_zbt.zec_magic number");
+ }
+ /* Now check the integrity of the vdev_phys_t structure though checksum. */
+ ZIO_SET_CHECKSUM(&emptycksum, diskdesc->vdev_phys_sector << 9, 0, 0, 0);
+ err = zio_checksum_verify (emptycksum, ZIO_CHECKSUM_LABEL, endian,
+ nvlist, VDEV_PHYS_SIZE);
+ if (err)
+ return err;
+
+ grub_dprintf ("zfs", "check 2 passed\n");
+
+ found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_STATE,
+ &pool_state);
+ if (! found)
+ {
+ grub_free (nvlist);
+ if (! grub_errno)
+ grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_POOL_STATE " not found");
+ return grub_errno;
+ }
+ grub_dprintf ("zfs", "check 3 passed\n");
+
+ if (pool_state == POOL_STATE_DESTROYED)
+ {
+ grub_free (nvlist);
+ return grub_error (GRUB_ERR_BAD_FS, "zpool is marked as destroyed");
+ }
+ grub_dprintf ("zfs", "check 4 passed\n");
+
+ found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_TXG, &txg);
+ if (!found)
+ {
+ grub_free (nvlist);
+ if (! grub_errno)
+ grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_POOL_TXG " not found");
+ return grub_errno;
+ }
+ grub_dprintf ("zfs", "check 6 passed\n");
+
+ /* not an active device */
+ if (txg == 0)
+ {
+ grub_free (nvlist);
+ return grub_error (GRUB_ERR_BAD_FS, "zpool isn't active");
+ }
+ grub_dprintf ("zfs", "check 7 passed\n");
+
+ found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_VERSION,
+ &version);
+ if (! found)
+ {
+ grub_free (nvlist);
+ if (! grub_errno)
+ grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_VERSION " not found");
+ return grub_errno;
+ }
+ grub_dprintf ("zfs", "check 8 passed\n");
+
+ if (!SPA_VERSION_IS_SUPPORTED(version))
+ {
+ grub_free (nvlist);
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "too new version %llu > %llu",
+ (unsigned long long) version,
+ (unsigned long long) SPA_VERSION_BEFORE_FEATURES);
+ }
+ grub_dprintf ("zfs", "check 9 passed\n");
+
+ found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_GUID,
+ &(diskdesc->guid));
+ if (! found)
+ {
+ grub_free (nvlist);
+ if (! grub_errno)
+ grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_GUID " not found");
+ return grub_errno;
+ }
+
+ found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_GUID,
+ &poolguid);
+ if (! found)
+ {
+ grub_free (nvlist);
+ if (! grub_errno)
+ grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_POOL_GUID " not found");
+ return grub_errno;
+ }
+
+ grub_dprintf ("zfs", "check 11 passed\n");
+
+ 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);
+
+ if (!nv)
+ {
+ grub_free (nvlist);
+ return grub_error (GRUB_ERR_BAD_FS, "couldn't find vdev tree");
+ }
+ err = fill_vdev_info (data, nv, diskdesc, inserted);
+ if (err)
+ {
+ grub_free (nv);
+ grub_free (nvlist);
+ return err;
+ }
+ grub_free (nv);
+ }
+ grub_dprintf ("zfs", "check 10 passed\n");
+ features = grub_zfs_nvlist_lookup_nvlist(nvlist,
+ ZPOOL_CONFIG_FEATURES_FOR_READ);
+ if (features)
+ {
+ const char *nvp=NULL;
+ char name[MAX_SUPPORTED_FEATURE_STRLEN + 1];
+ char *nameptr;
+ grub_size_t namelen;
+ while ((nvp = nvlist_next_nvpair(features, nvp)) != NULL)
+ {
+ nvpair_name (nvp, &nameptr, &namelen);
+ if(namelen > MAX_SUPPORTED_FEATURE_STRLEN)
+ namelen = MAX_SUPPORTED_FEATURE_STRLEN;
+ grub_memcpy (name, nameptr, namelen);
+ name[namelen] = '\0';
+ grub_dprintf("zfs","str=%s\n",name);
+ if (check_feature(name,1, NULL) != 0)
+ {
+ grub_dprintf("zfs","feature missing in check_pool_label:%s\n",name);
+ err= grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET," check_pool_label missing feature '%s' for read",name);
+ return err;
+ }
+ }
+ }
+ grub_dprintf ("zfs", "check 12 passed (feature flags)\n");
+ grub_free (nvlist);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+scan_disk (grub_device_t dev, struct grub_zfs_data *data,
+ int original, int *inserted)
+{
+ int label = 0;
+ uberblock_phys_t *ub_array, *ubbest = NULL;
+ vdev_boot_header_t *bh;
+ grub_err_t err;
+ int vdevnum;
+ struct grub_zfs_device_desc desc;
+
+ ub_array = grub_malloc (VDEV_UBERBLOCK_RING);
+ if (!ub_array)
+ return grub_errno;
+
+ bh = grub_malloc (VDEV_BOOT_HEADER_SIZE);
+ if (!bh)
+ {
+ grub_free (ub_array);
+ return grub_errno;
+ }
+
+ vdevnum = VDEV_LABELS;
+
+ desc.dev = dev;
+ desc.original = original;
+
+ /* Don't check back labels on CDROM. */
+ if (grub_disk_native_sectors (dev->disk) == GRUB_DISK_SIZE_UNKNOWN)
+ vdevnum = VDEV_LABELS / 2;
+
+ for (label = 0; ubbest == NULL && label < vdevnum; label++)
+ {
+ desc.vdev_phys_sector
+ = label * (sizeof (vdev_label_t) >> SPA_MINBLOCKSHIFT)
+ + ((VDEV_SKIP_SIZE + VDEV_BOOT_HEADER_SIZE) >> SPA_MINBLOCKSHIFT)
+ + (label < VDEV_LABELS / 2 ? 0 :
+ ALIGN_DOWN (grub_disk_native_sectors (dev->disk), sizeof (vdev_label_t))
+ - VDEV_LABELS * (sizeof (vdev_label_t) >> SPA_MINBLOCKSHIFT));
+
+ /* Read in the uberblock ring (128K). */
+ err = grub_disk_read (dev->disk, desc.vdev_phys_sector
+ + (VDEV_PHYS_SIZE >> SPA_MINBLOCKSHIFT),
+ 0, VDEV_UBERBLOCK_RING, (char *) ub_array);
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ grub_dprintf ("zfs", "label ok %d\n", label);
+
+ err = check_pool_label (data, &desc, inserted, original);
+ if (err || !*inserted)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ ubbest = find_bestub (ub_array, &desc);
+ if (!ubbest)
+ {
+ grub_dprintf ("zfs", "No uberblock found\n");
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ grub_memmove (&(desc.current_uberblock),
+ &ubbest->ubp_uberblock, sizeof (uberblock_t));
+ if (original)
+ grub_memmove (&(data->current_uberblock),
+ &ubbest->ubp_uberblock, sizeof (uberblock_t));
+
+#if 0
+ if (find_best_root &&
+ vdev_uberblock_compare (&ubbest->ubp_uberblock,
+ &(current_uberblock)) <= 0)
+ continue;
+#endif
+ grub_free (ub_array);
+ grub_free (bh);
+ return GRUB_ERR_NONE;
+ }
+
+ grub_free (ub_array);
+ grub_free (bh);
+
+ return grub_error (GRUB_ERR_BAD_FS, "couldn't find a valid label");
+}
+
+/* Helper for scan_devices. */
+static int
+scan_devices_iter (const char *name, void *hook_data)
+{
+ struct grub_zfs_data *data = hook_data;
+ grub_device_t dev;
+ grub_err_t err;
+ int inserted;
+
+ dev = grub_device_open (name);
+ if (!dev)
+ return 0;
+ if (!dev->disk)
+ {
+ grub_device_close (dev);
+ return 0;
+ }
+ err = scan_disk (dev, data, 0, &inserted);
+ if (err == GRUB_ERR_BAD_FS)
+ {
+ grub_device_close (dev);
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+ if (err)
+ {
+ grub_device_close (dev);
+ grub_print_error ();
+ return 0;
+ }
+
+ if (!inserted)
+ grub_device_close (dev);
+
+ return 0;
+}
+
+static grub_err_t
+scan_devices (struct grub_zfs_data *data)
+{
+ grub_device_iterate (scan_devices_iter, data);
+ return GRUB_ERR_NONE;
+}
+
+/* x**y. */
+static grub_uint8_t powx[255 * 2];
+/* Such an s that x**s = y */
+static int powx_inv[256];
+static const grub_uint8_t poly = 0x1d;
+
+/* perform the operation a ^= b * (x ** (known_idx * recovery_pow) ) */
+static inline void
+xor_out (grub_uint8_t *a, const grub_uint8_t *b, grub_size_t s,
+ unsigned known_idx, unsigned recovery_pow)
+{
+ unsigned add;
+
+ /* Simple xor. */
+ if (known_idx == 0 || recovery_pow == 0)
+ {
+ grub_crypto_xor (a, a, b, s);
+ return;
+ }
+ add = (known_idx * recovery_pow) % 255;
+ for (;s--; b++, a++)
+ if (*b)
+ *a ^= powx[powx_inv[*b] + add];
+}
+
+static inline grub_uint8_t
+gf_mul (grub_uint8_t a, grub_uint8_t b)
+{
+ if (a == 0 || b == 0)
+ return 0;
+ return powx[powx_inv[a] + powx_inv[b]];
+}
+
+#define MAX_NBUFS 4
+
+static grub_err_t
+recovery (grub_uint8_t *bufs[4], grub_size_t s, const int nbufs,
+ const unsigned *powers,
+ const unsigned *idx)
+{
+ grub_dprintf ("zfs", "recovering %u buffers\n", nbufs);
+ /* Now we have */
+ /* b_i = sum (r_j* (x ** (powers[i] * idx[j])))*/
+ /* Let's invert the matrix in question. */
+ switch (nbufs)
+ {
+ /* Easy: r_0 = bufs[0] / (x << (powers[i] * idx[j])). */
+ case 1:
+ {
+ int add;
+ grub_uint8_t *a;
+ if (powers[0] == 0 || idx[0] == 0)
+ return GRUB_ERR_NONE;
+ add = 255 - ((powers[0] * idx[0]) % 255);
+ for (a = bufs[0]; s--; a++)
+ if (*a)
+ *a = powx[powx_inv[*a] + add];
+ return GRUB_ERR_NONE;
+ }
+ /* Case 2x2: Let's use the determinant formula. */
+ case 2:
+ {
+ grub_uint8_t det, det_inv;
+ grub_uint8_t matrixinv[2][2];
+ unsigned i;
+ /* The determinant is: */
+ det = (powx[(powers[0] * idx[0] + powers[1] * idx[1]) % 255]
+ ^ powx[(powers[0] * idx[1] + powers[1] * idx[0]) % 255]);
+ if (det == 0)
+ return grub_error (GRUB_ERR_BAD_FS, "singular recovery matrix");
+ det_inv = powx[255 - powx_inv[det]];
+ matrixinv[0][0] = gf_mul (powx[(powers[1] * idx[1]) % 255], det_inv);
+ matrixinv[1][1] = gf_mul (powx[(powers[0] * idx[0]) % 255], det_inv);
+ matrixinv[0][1] = gf_mul (powx[(powers[0] * idx[1]) % 255], det_inv);
+ matrixinv[1][0] = gf_mul (powx[(powers[1] * idx[0]) % 255], det_inv);
+ for (i = 0; i < s; i++)
+ {
+ grub_uint8_t b0, b1;
+ b0 = bufs[0][i];
+ b1 = bufs[1][i];
+
+ bufs[0][i] = (gf_mul (b0, matrixinv[0][0])
+ ^ gf_mul (b1, matrixinv[0][1]));
+ bufs[1][i] = (gf_mul (b0, matrixinv[1][0])
+ ^ gf_mul (b1, matrixinv[1][1]));
+ }
+ return GRUB_ERR_NONE;
+ }
+ /* Otherwise use Gauss. */
+ case 3:
+ {
+ grub_uint8_t matrix1[MAX_NBUFS][MAX_NBUFS], matrix2[MAX_NBUFS][MAX_NBUFS];
+ int i, j, k;
+
+ for (i = 0; i < nbufs; i++)
+ for (j = 0; j < nbufs; j++)
+ matrix1[i][j] = powx[(powers[i] * idx[j]) % 255];
+ for (i = 0; i < nbufs; i++)
+ for (j = 0; j < nbufs; j++)
+ matrix2[i][j] = 0;
+ for (i = 0; i < nbufs; i++)
+ matrix2[i][i] = 1;
+
+ for (i = 0; i < nbufs; i++)
+ {
+ grub_uint8_t mul;
+ for (j = i; j < nbufs; j++)
+ if (matrix1[i][j])
+ break;
+ if (j == nbufs)
+ return grub_error (GRUB_ERR_BAD_FS, "singular recovery matrix");
+ if (j != i)
+ {
+ int xchng;
+ xchng = j;
+ for (j = 0; j < nbufs; j++)
+ {
+ grub_uint8_t t;
+ t = matrix1[xchng][j];
+ matrix1[xchng][j] = matrix1[i][j];
+ matrix1[i][j] = t;
+ }
+ for (j = 0; j < nbufs; j++)
+ {
+ grub_uint8_t t;
+ t = matrix2[xchng][j];
+ matrix2[xchng][j] = matrix2[i][j];
+ matrix2[i][j] = t;
+ }
+ }
+ mul = powx[255 - powx_inv[matrix1[i][i]]];
+ for (j = 0; j < nbufs; j++)
+ matrix1[i][j] = gf_mul (matrix1[i][j], mul);
+ for (j = 0; j < nbufs; j++)
+ matrix2[i][j] = gf_mul (matrix2[i][j], mul);
+ for (j = i + 1; j < nbufs; j++)
+ {
+ mul = matrix1[j][i];
+ for (k = 0; k < nbufs; k++)
+ matrix1[j][k] ^= gf_mul (matrix1[i][k], mul);
+ for (k = 0; k < nbufs; k++)
+ matrix2[j][k] ^= gf_mul (matrix2[i][k], mul);
+ }
+ }
+ for (i = nbufs - 1; i >= 0; i--)
+ {
+ for (j = 0; j < i; j++)
+ {
+ grub_uint8_t mul;
+ mul = matrix1[j][i];
+ for (k = 0; k < nbufs; k++)
+ matrix1[j][k] ^= gf_mul (matrix1[i][k], mul);
+ for (k = 0; k < nbufs; k++)
+ matrix2[j][k] ^= gf_mul (matrix2[i][k], mul);
+ }
+ }
+
+ for (i = 0; i < (int) s; i++)
+ {
+ grub_uint8_t b[MAX_NBUFS];
+ for (j = 0; j < nbufs; j++)
+ b[j] = bufs[j][i];
+ for (j = 0; j < nbufs; j++)
+ {
+ bufs[j][i] = 0;
+ for (k = 0; k < nbufs; k++)
+ bufs[j][i] ^= gf_mul (matrix2[j][k], b[k]);
+ }
+ }
+ return GRUB_ERR_NONE;
+ }
+ default:
+ return grub_error (GRUB_ERR_BUG, "too big matrix");
+ }
+}
+
+static grub_err_t
+read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
+ grub_size_t len, void *buf)
+{
+ switch (desc->type)
+ {
+ case DEVICE_LEAF:
+ {
+ grub_uint64_t sector;
+ sector = DVA_OFFSET_TO_PHYS_SECTOR (offset);
+ if (!desc->dev)
+ {
+ return grub_error (GRUB_ERR_BAD_FS,
+ N_("couldn't find a necessary member device "
+ "of multi-device filesystem"));
+ }
+ /* read in a data block */
+ return grub_disk_read (desc->dev->disk, sector, 0, len, buf);
+ }
+ case DEVICE_MIRROR:
+ {
+ grub_err_t err = GRUB_ERR_NONE;
+ unsigned i;
+ if (desc->n_children <= 0)
+ return grub_error (GRUB_ERR_BAD_FS,
+ "non-positive number of mirror children");
+ for (i = 0; i < desc->n_children; i++)
+ {
+ err = read_device (offset, &desc->children[i],
+ len, buf);
+ if (!err)
+ break;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ grub_errno = err;
+
+ return err;
+ }
+ case DEVICE_RAIDZ:
+ {
+ unsigned c = 0;
+ grub_uint64_t high;
+ grub_uint64_t devn;
+ grub_uint64_t m;
+ grub_uint32_t s, orig_s;
+ void *orig_buf = buf;
+ grub_size_t orig_len = len;
+ grub_uint8_t *recovery_buf[4];
+ grub_size_t recovery_len[4];
+ unsigned recovery_idx[4];
+ unsigned failed_devices = 0;
+ int idx, orig_idx;
+
+ if (desc->nparity < 1 || desc->nparity > 3)
+ 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;
+
+ high = grub_divmod64 ((offset >> desc->ashift),
+ desc->n_children, &m);
+ if (desc->nparity == 2)
+ c = 2;
+ if (desc->nparity == 3)
+ c = 3;
+ if (((len + (1 << desc->ashift) - 1) >> desc->ashift)
+ >= (desc->n_children - desc->nparity))
+ idx = (desc->n_children - desc->nparity - 1);
+ else
+ idx = ((len + (1 << desc->ashift) - 1) >> desc->ashift) - 1;
+ orig_idx = idx;
+ while (len > 0)
+ {
+ grub_size_t csize;
+ grub_uint32_t bsize;
+ grub_err_t err;
+ bsize = s / (desc->n_children - desc->nparity);
+
+ if (desc->nparity == 1
+ && ((offset >> (desc->ashift + 20 - desc->max_children_ashift))
+ & 1) == c)
+ c++;
+
+ high = grub_divmod64 ((offset >> desc->ashift) + c,
+ desc->n_children, &devn);
+ csize = (grub_size_t) bsize << desc->ashift;
+ if (csize > len)
+ csize = len;
+
+ grub_dprintf ("zfs", "RAIDZ mapping 0x%" PRIxGRUB_UINT64_T
+ "+%u (%" PRIxGRUB_SIZE ", %" PRIxGRUB_UINT32_T
+ ") -> (0x%" PRIxGRUB_UINT64_T ", 0x%"
+ PRIxGRUB_UINT64_T ")\n",
+ offset >> desc->ashift, c, len, bsize, high,
+ devn);
+ err = read_device ((high << desc->ashift)
+ | (offset & ((1 << desc->ashift) - 1)),
+ &desc->children[devn],
+ csize, buf);
+ if (err && failed_devices < desc->nparity)
+ {
+ recovery_buf[failed_devices] = buf;
+ recovery_len[failed_devices] = csize;
+ recovery_idx[failed_devices] = idx;
+ failed_devices++;
+ grub_errno = err = 0;
+ }
+ if (err)
+ return err;
+
+ c++;
+ idx--;
+ s--;
+ buf = (char *) buf + csize;
+ len -= csize;
+ }
+ if (failed_devices)
+ {
+ unsigned redundancy_pow[4];
+ unsigned cur_redundancy_pow = 0;
+ unsigned n_redundancy = 0;
+ unsigned i, j;
+ grub_err_t err;
+
+ /* Compute mul. x**s has a period of 255. */
+ if (powx[0] == 0)
+ {
+ grub_uint8_t cur = 1;
+ for (i = 0; i < 255; i++)
+ {
+ powx[i] = cur;
+ powx[i + 255] = cur;
+ powx_inv[cur] = i;
+ if (cur & 0x80)
+ cur = (cur << 1) ^ poly;
+ else
+ cur <<= 1;
+ }
+ }
+
+ /* Read redundancy data. */
+ for (n_redundancy = 0, cur_redundancy_pow = 0;
+ n_redundancy < failed_devices;
+ cur_redundancy_pow++)
+ {
+ high = grub_divmod64 ((offset >> desc->ashift)
+ + cur_redundancy_pow
+ + ((desc->nparity == 1)
+ && ((offset >> (desc->ashift + 20
+ - desc->max_children_ashift))
+ & 1)),
+ desc->n_children, &devn);
+ err = read_device ((high << desc->ashift)
+ | (offset & ((1 << desc->ashift) - 1)),
+ &desc->children[devn],
+ recovery_len[n_redundancy],
+ recovery_buf[n_redundancy]);
+ /* Ignore error if we may still have enough devices. */
+ if (err && n_redundancy + desc->nparity - cur_redundancy_pow - 1
+ >= failed_devices)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ if (err)
+ return err;
+ redundancy_pow[n_redundancy] = cur_redundancy_pow;
+ n_redundancy++;
+ }
+ /* Now xor-our the parts we already know. */
+ buf = orig_buf;
+ len = orig_len;
+ s = orig_s;
+ idx = orig_idx;
+
+ while (len > 0)
+ {
+ grub_size_t csize = s;
+ csize = ((csize / (desc->n_children - desc->nparity))
+ << desc->ashift);
+ if (csize > len)
+ csize = len;
+
+ for (j = 0; j < failed_devices; j++)
+ if (buf == recovery_buf[j])
+ break;
+
+ if (j == failed_devices)
+ for (j = 0; j < failed_devices; j++)
+ xor_out (recovery_buf[j], buf,
+ csize < recovery_len[j] ? csize : recovery_len[j],
+ idx, redundancy_pow[j]);
+
+ s--;
+ buf = (char *) buf + csize;
+ len -= csize;
+ idx--;
+ }
+ for (i = 0; i < failed_devices
+ && recovery_len[i] == recovery_len[0];
+ i++);
+ /* Since the chunks have variable length handle the last block
+ separately. */
+ if (i != failed_devices)
+ {
+ grub_uint8_t *tmp_recovery_buf[4];
+ for (j = 0; j < i; j++)
+ tmp_recovery_buf[j] = recovery_buf[j] + recovery_len[failed_devices - 1];
+ err = recovery (tmp_recovery_buf, recovery_len[0] - recovery_len[failed_devices - 1], i, redundancy_pow,
+ recovery_idx);
+ if (err)
+ return err;
+ }
+ err = recovery (recovery_buf, recovery_len[failed_devices - 1],
+ failed_devices, redundancy_pow, recovery_idx);
+ if (err)
+ return err;
+ }
+ return GRUB_ERR_NONE;
+ }
+ }
+ return grub_error (GRUB_ERR_BAD_FS, "unsupported device type");
+}
+
+static grub_err_t
+read_dva (const dva_t *dva,
+ grub_zfs_endian_t endian, struct grub_zfs_data *data,
+ void *buf, grub_size_t len)
+{
+ grub_uint64_t offset;
+ unsigned i;
+ grub_err_t err = 0;
+ int try = 0;
+ offset = dva_get_offset (dva, endian);
+
+ for (try = 0; try < 2; try++)
+ {
+ for (i = 0; i < data->n_devices_attached; i++)
+ if (data->devices_attached[i].id == DVA_GET_VDEV (dva))
+ {
+ err = read_device (offset, &data->devices_attached[i], len, buf);
+ if (!err)
+ return GRUB_ERR_NONE;
+ break;
+ }
+ if (try == 1)
+ break;
+ err = scan_devices (data);
+ if (err)
+ return err;
+ }
+ if (!err)
+ return grub_error (GRUB_ERR_BAD_FS, "unknown device %d",
+ (int) DVA_GET_VDEV (dva));
+ return err;
+}
+
+/*
+ * Read a block of data based on the gang block address dva,
+ * and put its data in buf.
+ *
+ */
+static grub_err_t
+zio_read_gang (blkptr_t * bp, grub_zfs_endian_t endian, dva_t * dva, void *buf,
+ struct grub_zfs_data *data)
+{
+ zio_gbh_phys_t *zio_gb;
+ unsigned i;
+ grub_err_t err;
+ zio_cksum_t zc;
+
+ grub_memset (&zc, 0, sizeof (zc));
+
+ zio_gb = grub_malloc (SPA_GANGBLOCKSIZE);
+ if (!zio_gb)
+ return grub_errno;
+ grub_dprintf ("zfs", endian == GRUB_ZFS_LITTLE_ENDIAN ? "little-endian gang\n"
+ :"big-endian gang\n");
+
+ err = read_dva (dva, endian, data, zio_gb, SPA_GANGBLOCKSIZE);
+ if (err)
+ {
+ grub_free (zio_gb);
+ return err;
+ }
+
+ /* XXX */
+ /* self checksuming the gang block header */
+ ZIO_SET_CHECKSUM (&zc, DVA_GET_VDEV (dva),
+ dva_get_offset (dva, endian), bp->blk_birth, 0);
+ err = zio_checksum_verify (zc, ZIO_CHECKSUM_GANG_HEADER, endian,
+ (char *) zio_gb, SPA_GANGBLOCKSIZE);
+ if (err)
+ {
+ grub_free (zio_gb);
+ return err;
+ }
+
+ endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1;
+
+ for (i = 0; i < SPA_GBH_NBLKPTRS; i++)
+ {
+ if (BP_IS_HOLE(&zio_gb->zg_blkptr[i]))
+ continue;
+
+ err = zio_read_data (&zio_gb->zg_blkptr[i], endian, buf, data);
+ if (err)
+ {
+ grub_free (zio_gb);
+ return err;
+ }
+ buf = (char *) buf + get_psize (&zio_gb->zg_blkptr[i], endian);
+ }
+ grub_free (zio_gb);
+ return GRUB_ERR_NONE;
+}
+
+/*
+ * Read in a block of raw data to buf.
+ */
+static grub_err_t
+zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, void *buf,
+ struct grub_zfs_data *data)
+{
+ int i, psize;
+ grub_err_t err = GRUB_ERR_NONE;
+
+ psize = get_psize (bp, endian);
+
+ /* pick a good dva from the block pointer */
+ for (i = 0; i < SPA_DVAS_PER_BP; i++)
+ {
+ if (bp->blk_dva[i].dva_word[0] == 0 && bp->blk_dva[i].dva_word[1] == 0)
+ continue;
+
+ if ((grub_zfs_to_cpu64 (bp->blk_dva[i].dva_word[1], endian)>>63) & 1)
+ err = zio_read_gang (bp, endian, &bp->blk_dva[i], buf, data);
+ else
+ err = read_dva (&bp->blk_dva[i], endian, data, buf, psize);
+ if (!err)
+ return GRUB_ERR_NONE;
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ if (!err)
+ err = grub_error (GRUB_ERR_BAD_FS, "couldn't find a valid DVA");
+ grub_errno = err;
+
+ return err;
+}
+
+/*
+ * 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.
+ */
+static grub_err_t
+zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf,
+ grub_size_t *size, struct grub_zfs_data *data)
+{
+ grub_size_t lsize, psize;
+ unsigned int comp, encrypted;
+ char *compbuf = NULL;
+ grub_err_t err;
+ zio_cksum_t zc = bp->blk_cksum;
+ grub_uint32_t checksum;
+
+ *buf = NULL;
+
+ checksum = (grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 40) & 0xff;
+ comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0x7f;
+ encrypted = ((grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 60) & 3);
+ 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=%llu)\n",
+ (long long unsigned int) 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;
+
+ if (comp >= ZIO_COMPRESS_FUNCTIONS)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "compression algorithm %u not supported\n", (unsigned int) comp);
+
+ if (comp != ZIO_COMPRESS_OFF && decomp_table[comp].decomp_func == NULL)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "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));
+ else
+ compbuf = *buf = grub_malloc (lsize);
+ if (! compbuf)
+ return grub_errno;
+
+ grub_dprintf ("zfs", "endian = %d\n", endian);
+ 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;
+ }
+
+ if (!BP_IS_EMBEDDED(bp))
+ {
+ 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)
+ {
+ if (!grub_zfs_decrypt)
+ err = grub_error (GRUB_ERR_BAD_FS,
+ N_("module `%s' isn't loaded"),
+ "zfscrypt");
+ else
+ {
+ unsigned i, besti = 0;
+ grub_uint64_t bestval = 0;
+ for (i = 0; i < data->subvol.nkeys; i++)
+ if (data->subvol.keyring[i].txg <= grub_zfs_to_cpu64 (bp->blk_birth,
+ endian)
+ && data->subvol.keyring[i].txg > bestval)
+ {
+ besti = i;
+ bestval = data->subvol.keyring[i].txg;
+ }
+ if (bestval == 0)
+ {
+ grub_free (compbuf);
+ *buf = NULL;
+ grub_dprintf ("zfs", "no key for txg %" PRIxGRUB_UINT64_T "\n",
+ grub_zfs_to_cpu64 (bp->blk_birth,
+ endian));
+ return grub_error (GRUB_ERR_BAD_FS, "no key found in keychain");
+ }
+ grub_dprintf ("zfs", "using key %u (%" PRIxGRUB_UINT64_T
+ ", %p) for txg %" PRIxGRUB_UINT64_T "\n",
+ besti, data->subvol.keyring[besti].txg,
+ data->subvol.keyring[besti].cipher,
+ grub_zfs_to_cpu64 (bp->blk_birth,
+ endian));
+ err = grub_zfs_decrypt (data->subvol.keyring[besti].cipher,
+ data->subvol.keyring[besti].algo,
+ &(bp)->blk_dva[encrypted],
+ compbuf, psize, zc.zc_mac,
+ endian);
+ }
+ if (err)
+ {
+ grub_free (compbuf);
+ *buf = NULL;
+ return err;
+ }
+ }
+
+ if (comp != ZIO_COMPRESS_OFF)
+ {
+ *buf = grub_malloc (lsize);
+ if (!*buf)
+ {
+ grub_free (compbuf);
+ return grub_errno;
+ }
+
+ err = decomp_table[comp].decomp_func (compbuf, *buf, psize, lsize);
+ grub_free (compbuf);
+ if (err)
+ {
+ grub_free (*buf);
+ *buf = NULL;
+ return err;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/*
+ * Get the block from a block id.
+ * push the block onto the stack.
+ *
+ */
+static grub_err_t
+dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
+ grub_zfs_endian_t *endian_out, struct grub_zfs_data *data)
+{
+ int level;
+ grub_off_t idx;
+ blkptr_t *bp_array = dn->dn.dn_blkptr;
+ int epbs = dn->dn.dn_indblkshift - SPA_BLKPTRSHIFT;
+ blkptr_t *bp;
+ void *tmpbuf = 0;
+ grub_zfs_endian_t endian;
+ grub_err_t err = GRUB_ERR_NONE;
+
+ bp = grub_malloc (sizeof (blkptr_t));
+ if (!bp)
+ return grub_errno;
+
+ endian = dn->endian;
+ for (level = dn->dn.dn_nlevels - 1; level >= 0; level--)
+ {
+ grub_dprintf ("zfs", "endian = %d\n", endian);
+ idx = (blkid >> (epbs * level)) & ((1 << epbs) - 1);
+ *bp = bp_array[idx];
+ if (bp_array != dn->dn.dn_blkptr)
+ {
+ grub_free (bp_array);
+ bp_array = 0;
+ }
+
+ if (BP_IS_HOLE (bp))
+ {
+ grub_size_t size = grub_zfs_to_cpu16 (dn->dn.dn_datablkszsec,
+ dn->endian)
+ << SPA_MINBLOCKSHIFT;
+ *buf = grub_malloc (size);
+ if (!*buf)
+ {
+ err = grub_errno;
+ break;
+ }
+ grub_memset (*buf, 0, size);
+ endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1;
+ break;
+ }
+ if (level == 0)
+ {
+ grub_dprintf ("zfs", "endian = %d\n", endian);
+ err = zio_read (bp, endian, buf, 0, data);
+ endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1;
+ break;
+ }
+ grub_dprintf ("zfs", "endian = %d\n", endian);
+ err = zio_read (bp, endian, &tmpbuf, 0, data);
+ endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1;
+ if (err)
+ break;
+ bp_array = tmpbuf;
+ }
+ if (bp_array != dn->dn.dn_blkptr)
+ grub_free (bp_array);
+ if (endian_out)
+ *endian_out = endian;
+
+ grub_free (bp);
+ return err;
+}
+
+/*
+ * mzap_lookup: Looks up property described by "name" and returns the value
+ * in "value".
+ */
+static grub_err_t
+mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian,
+ grub_uint32_t objsize, const char *name, grub_uint64_t * value,
+ int case_insensitive)
+{
+ 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++)
+ {
+ if (case_insensitive ? (grub_strcasecmp (mzap_ent[i].mze_name, name) == 0)
+ : (grub_strcmp (mzap_ent[i].mze_name, name) == 0))
+ {
+ *value = grub_zfs_to_cpu64 (mzap_ent[i].mze_value, endian);
+ return GRUB_ERR_NONE;
+ }
+ }
+
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name);
+}
+
+static int
+mzap_iterate (mzap_phys_t * zapobj, grub_zfs_endian_t endian, int objsize,
+ int (*hook) (const char *name, grub_uint64_t val,
+ struct grub_zfs_dir_ctx *ctx),
+ struct grub_zfs_dir_ctx *ctx)
+{
+ int i, chunks;
+ mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk;
+
+ chunks = objsize / MZAP_ENT_LEN - 1;
+ for (i = 0; i < chunks; i++)
+ {
+ grub_dprintf ("zfs", "zap: name = %s, value = %llx, cd = %x\n",
+ mzap_ent[i].mze_name, (long long)mzap_ent[i].mze_value,
+ (int)mzap_ent[i].mze_cd);
+ if (hook (mzap_ent[i].mze_name,
+ grub_zfs_to_cpu64 (mzap_ent[i].mze_value, endian), ctx))
+ return 1;
+ }
+
+ return 0;
+}
+
+static grub_uint64_t
+zap_hash (grub_uint64_t salt, const char *name,
+ int case_insensitive)
+{
+ static grub_uint64_t table[256];
+ const grub_uint8_t *cp;
+ grub_uint8_t c;
+ grub_uint64_t crc = salt;
+
+ if (table[128] == 0)
+ {
+ grub_uint64_t *ct;
+ int i, j;
+ for (i = 0; i < 256; i++)
+ {
+ for (ct = table + i, *ct = i, j = 8; j > 0; j--)
+ *ct = (*ct >> 1) ^ (-(*ct & 1) & ZFS_CRC64_POLY);
+ }
+ }
+
+ if (case_insensitive)
+ for (cp = (const grub_uint8_t *) name; (c = *cp) != '\0'; cp++)
+ crc = (crc >> 8) ^ table[(crc ^ grub_toupper (c)) & 0xFF];
+ else
+ for (cp = (const grub_uint8_t *) name; (c = *cp) != '\0'; cp++)
+ crc = (crc >> 8) ^ table[(crc ^ c) & 0xFF];
+
+ /*
+ * Only use 28 bits, since we need 4 bits in the cookie for the
+ * collision differentiator. We MUST use the high bits, since
+ * those are the onces that we first pay attention to when
+ * chosing the bucket.
+ */
+ crc &= ~((1ULL << (64 - ZAP_HASHBITS)) - 1);
+
+ return crc;
+}
+
+/*
+ * Only to be used on 8-bit arrays.
+ * array_len is actual len in bytes (not encoded le_value_length).
+ * buf is null-terminated.
+ */
+
+static inline int
+name_cmp (const char *s1, const char *s2, grub_size_t n,
+ int case_insensitive)
+{
+ const char *t1 = (const char *) s1;
+ const char *t2 = (const char *) s2;
+
+ if (!case_insensitive)
+ return grub_memcmp (t1, t2, n);
+
+ while (n--)
+ {
+ if (grub_toupper (*t1) != grub_toupper (*t2))
+ return (int) grub_toupper (*t1) - (int) grub_toupper (*t2);
+
+ t1++;
+ t2++;
+ }
+
+ return 0;
+}
+
+/* XXX */
+static int
+zap_leaf_array_equal (zap_leaf_phys_t * l, grub_zfs_endian_t endian,
+ int blksft, int chunk, grub_size_t array_len,
+ const char *buf, int case_insensitive)
+{
+ grub_size_t bseen = 0;
+
+ while (bseen < array_len)
+ {
+ struct zap_leaf_array *la = &ZAP_LEAF_CHUNK (l, blksft, chunk)->l_array;
+ grub_size_t toread = array_len - bseen;
+
+ if (toread > ZAP_LEAF_ARRAY_BYTES)
+ toread = ZAP_LEAF_ARRAY_BYTES;
+
+ if (chunk >= ZAP_LEAF_NUMCHUNKS (blksft))
+ return 0;
+
+ if (name_cmp ((char *) la->la_array, buf + bseen, toread,
+ case_insensitive) != 0)
+ break;
+ chunk = grub_zfs_to_cpu16 (la->la_next, endian);
+ bseen += toread;
+ }
+ return (bseen == array_len);
+}
+
+/* XXX */
+static grub_err_t
+zap_leaf_array_get (zap_leaf_phys_t * l, grub_zfs_endian_t endian, int blksft,
+ int chunk, grub_size_t array_len, char *buf)
+{
+ grub_size_t bseen = 0;
+
+ while (bseen < array_len)
+ {
+ struct zap_leaf_array *la = &ZAP_LEAF_CHUNK (l, blksft, chunk)->l_array;
+ grub_size_t toread = array_len - bseen;
+
+ if (toread > ZAP_LEAF_ARRAY_BYTES)
+ toread = ZAP_LEAF_ARRAY_BYTES;
+
+ if (chunk >= ZAP_LEAF_NUMCHUNKS (blksft))
+ /* Don't use grub_error because this error is to be ignored. */
+ return GRUB_ERR_BAD_FS;
+
+ grub_memcpy (buf + bseen,la->la_array, toread);
+ chunk = grub_zfs_to_cpu16 (la->la_next, endian);
+ bseen += toread;
+ }
+ return GRUB_ERR_NONE;
+}
+
+
+/*
+ * Given a zap_leaf_phys_t, walk thru the zap leaf chunks to get the
+ * value for the property "name".
+ *
+ */
+/* XXX */
+static grub_err_t
+zap_leaf_lookup (zap_leaf_phys_t * l, grub_zfs_endian_t endian,
+ int blksft, grub_uint64_t h,
+ const char *name, grub_uint64_t * value,
+ int case_insensitive)
+{
+ grub_uint16_t chunk;
+ struct zap_leaf_entry *le;
+
+ /* Verify if this is a valid leaf block */
+ if (grub_zfs_to_cpu64 (l->l_hdr.lh_block_type, endian) != ZBT_LEAF)
+ return grub_error (GRUB_ERR_BAD_FS, "invalid leaf type");
+ if (grub_zfs_to_cpu32 (l->l_hdr.lh_magic, endian) != ZAP_LEAF_MAGIC)
+ return grub_error (GRUB_ERR_BAD_FS, "invalid leaf magic");
+
+ for (chunk = grub_zfs_to_cpu16 (l->l_hash[LEAF_HASH (blksft, h, l)], endian);
+ chunk != CHAIN_END; chunk = grub_zfs_to_cpu16 (le->le_next, endian))
+ {
+
+ if (chunk >= ZAP_LEAF_NUMCHUNKS (blksft))
+ return grub_error (GRUB_ERR_BAD_FS, "invalid chunk number");
+
+ le = ZAP_LEAF_ENTRY (l, blksft, chunk);
+
+ /* Verify the chunk entry */
+ if (le->le_type != ZAP_CHUNK_ENTRY)
+ return grub_error (GRUB_ERR_BAD_FS, "invalid chunk entry");
+
+ if (grub_zfs_to_cpu64 (le->le_hash,endian) != h)
+ continue;
+
+ grub_dprintf ("zfs", "fzap: length %d\n", (int) le->le_name_length);
+
+ if (zap_leaf_array_equal (l, endian, blksft,
+ grub_zfs_to_cpu16 (le->le_name_chunk,endian),
+ grub_zfs_to_cpu16 (le->le_name_length, endian),
+ name, case_insensitive))
+ {
+ struct zap_leaf_array *la;
+
+ if (le->le_int_size != 8 || grub_zfs_to_cpu16 (le->le_value_length,
+ endian) != 1)
+ return grub_error (GRUB_ERR_BAD_FS, "invalid leaf chunk entry");
+
+ /* get the uint64_t property value */
+ la = &ZAP_LEAF_CHUNK (l, blksft, le->le_value_chunk)->l_array;
+
+ *value = grub_be_to_cpu64 (la->la_array64);
+
+ return GRUB_ERR_NONE;
+ }
+ }
+
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name);
+}
+
+
+/* Verify if this is a fat zap header block */
+static grub_err_t
+zap_verify (zap_phys_t *zap, grub_zfs_endian_t endian)
+{
+ if (grub_zfs_to_cpu64 (zap->zap_magic, endian) != (grub_uint64_t) ZAP_MAGIC)
+ return grub_error (GRUB_ERR_BAD_FS, "bad ZAP magic");
+
+ if (zap->zap_salt == 0)
+ return grub_error (GRUB_ERR_BAD_FS, "bad ZAP salt");
+
+ return GRUB_ERR_NONE;
+}
+
+/*
+ * Fat ZAP lookup
+ *
+ */
+/* XXX */
+static grub_err_t
+fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap,
+ const char *name, grub_uint64_t * value,
+ struct grub_zfs_data *data, int case_insensitive)
+{
+ void *l;
+ grub_uint64_t hash, idx, blkid;
+ int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec,
+ zap_dnode->endian) << DNODE_SHIFT);
+ grub_err_t err;
+ grub_zfs_endian_t leafendian;
+
+ err = zap_verify (zap, zap_dnode->endian);
+ if (err)
+ return err;
+
+ hash = zap_hash (zap->zap_salt, name, case_insensitive);
+
+ /* get block id from index */
+ if (zap->zap_ptrtbl.zt_numblks != 0)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "external pointer tables not supported");
+ idx = ZAP_HASH_IDX (hash, zap->zap_ptrtbl.zt_shift);
+ blkid = grub_zfs_to_cpu64 (((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))], zap_dnode->endian);
+
+ /* Get the leaf block */
+ if ((1U << blksft) < sizeof (zap_leaf_phys_t))
+ return grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small");
+ err = dmu_read (zap_dnode, blkid, &l, &leafendian, data);
+ if (err)
+ return err;
+
+ err = zap_leaf_lookup (l, leafendian, blksft, hash, name, value,
+ case_insensitive);
+ grub_free (l);
+ return err;
+}
+
+/* XXX */
+static int
+fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap,
+ grub_size_t name_elem_length,
+ int (*hook) (const void *name, grub_size_t name_length,
+ const void *val_in,
+ grub_size_t nelem, grub_size_t elemsize,
+ void *data),
+ void *hook_data, struct grub_zfs_data *data)
+{
+ zap_leaf_phys_t *l;
+ void *l_in;
+ grub_uint64_t idx, idx2, blkid;
+ grub_uint16_t chunk;
+ int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec,
+ zap_dnode->endian) << DNODE_SHIFT);
+ grub_err_t err;
+ grub_zfs_endian_t endian;
+
+ if (zap_verify (zap, zap_dnode->endian))
+ return 0;
+
+ /* get block id from index */
+ if (zap->zap_ptrtbl.zt_numblks != 0)
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "external pointer tables not supported");
+ return 0;
+ }
+ /* Get the leaf block */
+ if ((1U << blksft) < sizeof (zap_leaf_phys_t))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small");
+ return 0;
+ }
+ for (idx = 0; idx < (1ULL << zap->zap_ptrtbl.zt_shift); idx++)
+ {
+ blkid = grub_zfs_to_cpu64 (((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))],
+ zap_dnode->endian);
+
+ for (idx2 = 0; idx2 < idx; idx2++)
+ if (blkid == grub_zfs_to_cpu64 (((grub_uint64_t *) zap)[idx2 + (1 << (blksft - 3 - 1))],
+ zap_dnode->endian))
+ break;
+ if (idx2 != idx)
+ continue;
+
+ err = dmu_read (zap_dnode, blkid, &l_in, &endian, data);
+ l = l_in;
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ /* Verify if this is a valid leaf block */
+ if (grub_zfs_to_cpu64 (l->l_hdr.lh_block_type, endian) != ZBT_LEAF)
+ {
+ grub_free (l);
+ continue;
+ }
+ if (grub_zfs_to_cpu32 (l->l_hdr.lh_magic, endian) != ZAP_LEAF_MAGIC)
+ {
+ grub_free (l);
+ continue;
+ }
+
+ for (chunk = 0; chunk < ZAP_LEAF_NUMCHUNKS (blksft); chunk++)
+ {
+ char *buf;
+ struct zap_leaf_entry *le;
+ char *val;
+ grub_size_t val_length;
+ le = ZAP_LEAF_ENTRY (l, blksft, chunk);
+
+ /* Verify the chunk entry */
+ if (le->le_type != ZAP_CHUNK_ENTRY)
+ continue;
+
+ buf = grub_malloc (grub_zfs_to_cpu16 (le->le_name_length, endian)
+ * name_elem_length + 1);
+ if (zap_leaf_array_get (l, endian, blksft,
+ grub_zfs_to_cpu16 (le->le_name_chunk,
+ endian),
+ grub_zfs_to_cpu16 (le->le_name_length,
+ endian)
+ * name_elem_length, buf))
+ {
+ grub_free (buf);
+ continue;
+ }
+ buf[le->le_name_length * name_elem_length] = 0;
+
+ val_length = ((int) le->le_value_length
+ * (int) le->le_int_size);
+ val = grub_malloc (grub_zfs_to_cpu16 (val_length, endian));
+ if (zap_leaf_array_get (l, endian, blksft,
+ grub_zfs_to_cpu16 (le->le_value_chunk,
+ endian),
+ val_length, val))
+ {
+ grub_free (buf);
+ grub_free (val);
+ continue;
+ }
+
+ if (hook (buf, le->le_name_length,
+ val, le->le_value_length, le->le_int_size, hook_data))
+ {
+ grub_free (l);
+ return 1;
+ }
+ grub_free (buf);
+ grub_free (val);
+ }
+ grub_free (l);
+ }
+ return 0;
+}
+
+/*
+ * Read in the data of a zap object and find the value for a matching
+ * property name.
+ *
+ */
+static grub_err_t
+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;
+ grub_uint32_t size;
+ void *zapbuf;
+ grub_err_t err;
+ grub_zfs_endian_t endian;
+
+ grub_dprintf ("zfs", "looking for '%s'\n", name);
+
+ /* Read in the first block of the zap object data. */
+ 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)
+ return err;
+ block_type = grub_zfs_to_cpu64 (*((grub_uint64_t *) zapbuf), endian);
+
+ grub_dprintf ("zfs", "zap read\n");
+
+ if (block_type == ZBT_MICRO)
+ {
+ grub_dprintf ("zfs", "micro zap\n");
+ err = mzap_lookup (zapbuf, endian, size, name, val,
+ case_insensitive);
+ grub_dprintf ("zfs", "returned %d\n", err);
+ grub_free (zapbuf);
+ return err;
+ }
+ else if (block_type == ZBT_HEADER)
+ {
+ grub_dprintf ("zfs", "fat zap\n");
+ /* this is a fat zap */
+ err = fzap_lookup (zap_dnode, zapbuf, name, val, data,
+ case_insensitive);
+ grub_dprintf ("zfs", "returned %d\n", err);
+ grub_free (zapbuf);
+ return err;
+ }
+
+ return grub_error (GRUB_ERR_BAD_FS, "unknown ZAP type");
+}
+
+/* Context for zap_iterate_u64. */
+struct zap_iterate_u64_ctx
+{
+ int (*hook) (const char *, grub_uint64_t, struct grub_zfs_dir_ctx *);
+ struct grub_zfs_dir_ctx *dir_ctx;
+};
+
+/* Helper for zap_iterate_u64. */
+static int
+zap_iterate_u64_transform (const void *name,
+ grub_size_t namelen __attribute__ ((unused)),
+ const void *val_in,
+ grub_size_t nelem,
+ grub_size_t elemsize,
+ void *data)
+{
+ struct zap_iterate_u64_ctx *ctx = data;
+
+ if (elemsize != sizeof (grub_uint64_t) || nelem != 1)
+ return 0;
+ return ctx->hook (name, grub_be_to_cpu64 (*(const grub_uint64_t *) val_in),
+ ctx->dir_ctx);
+}
+
+static int
+zap_iterate_u64 (dnode_end_t * zap_dnode,
+ int (*hook) (const char *name, grub_uint64_t val,
+ struct grub_zfs_dir_ctx *ctx),
+ struct grub_zfs_data *data, struct grub_zfs_dir_ctx *ctx)
+{
+ grub_uint64_t block_type;
+ int size;
+ void *zapbuf;
+ grub_err_t err;
+ int ret;
+ grub_zfs_endian_t endian;
+
+ /* Read in the first block of the zap object data. */
+ size = 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)
+ return 0;
+ block_type = grub_zfs_to_cpu64 (*((grub_uint64_t *) zapbuf), endian);
+
+ grub_dprintf ("zfs", "zap iterate\n");
+
+ if (block_type == ZBT_MICRO)
+ {
+ grub_dprintf ("zfs", "micro zap\n");
+ ret = mzap_iterate (zapbuf, endian, size, hook, ctx);
+ grub_free (zapbuf);
+ return ret;
+ }
+ else if (block_type == ZBT_HEADER)
+ {
+ struct zap_iterate_u64_ctx transform_ctx = {
+ .hook = hook,
+ .dir_ctx = ctx
+ };
+
+ grub_dprintf ("zfs", "fat zap\n");
+ /* this is a fat zap */
+ ret = fzap_iterate (zap_dnode, zapbuf, 1,
+ zap_iterate_u64_transform, &transform_ctx, data);
+ grub_free (zapbuf);
+ return ret;
+ }
+ grub_error (GRUB_ERR_BAD_FS, "unknown ZAP type");
+ return 0;
+}
+
+static int
+zap_iterate (dnode_end_t * zap_dnode,
+ grub_size_t nameelemlen,
+ int (*hook) (const void *name, grub_size_t namelen,
+ const void *val_in,
+ grub_size_t nelem, grub_size_t elemsize,
+ void *data),
+ void *hook_data, struct grub_zfs_data *data)
+{
+ grub_uint64_t block_type;
+ void *zapbuf;
+ grub_err_t err;
+ int ret;
+ grub_zfs_endian_t endian;
+
+ /* Read in the first block of the zap object data. */
+ err = dmu_read (zap_dnode, 0, &zapbuf, &endian, data);
+ if (err)
+ return 0;
+ block_type = grub_zfs_to_cpu64 (*((grub_uint64_t *) zapbuf), endian);
+
+ grub_dprintf ("zfs", "zap iterate\n");
+
+ if (block_type == ZBT_MICRO)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "micro ZAP where FAT ZAP expected");
+ return 0;
+ }
+ if (block_type == ZBT_HEADER)
+ {
+ grub_dprintf ("zfs", "fat zap\n");
+ /* this is a fat zap */
+ ret = fzap_iterate (zap_dnode, zapbuf, nameelemlen, hook, hook_data,
+ data);
+ grub_free (zapbuf);
+ return ret;
+ }
+ grub_error (GRUB_ERR_BAD_FS, "unknown ZAP type");
+ return 0;
+}
+
+
+/*
+ * Get the dnode of an object number from the metadnode of an object set.
+ *
+ * Input
+ * mdn - metadnode to get the object dnode
+ * objnum - object number for the object dnode
+ * buf - data buffer that holds the returning dnode
+ */
+static grub_err_t
+dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type,
+ dnode_end_t * buf, struct grub_zfs_data *data)
+{
+ grub_uint64_t blkid, blksz; /* the block id this object dnode is in */
+ int epbs; /* shift of number of dnodes in a block */
+ int idx; /* index within a block */
+ void *dnbuf;
+ grub_err_t err;
+ grub_zfs_endian_t endian;
+
+ blksz = grub_zfs_to_cpu16 (mdn->dn.dn_datablkszsec,
+ mdn->endian) << SPA_MINBLOCKSHIFT;
+ epbs = zfs_log2 (blksz) - DNODE_SHIFT;
+
+ /* While this should never happen, we should check that epbs is not negative. */
+ if (epbs < 0)
+ epbs = 0;
+
+ blkid = objnum >> epbs;
+ idx = objnum & ((1 << epbs) - 1);
+
+ if (data->dnode_buf != NULL && grub_memcmp (data->dnode_mdn, mdn,
+ sizeof (*mdn)) == 0
+ && objnum >= data->dnode_start && objnum < data->dnode_end)
+ {
+ grub_memmove (&(buf->dn), &(data->dnode_buf)[idx], DNODE_SIZE);
+ buf->endian = data->dnode_endian;
+ if (type && buf->dn.dn_type != type)
+ return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type");
+ return GRUB_ERR_NONE;
+ }
+
+ grub_dprintf ("zfs", "endian = %d, blkid=%llx\n", mdn->endian,
+ (unsigned long long) blkid);
+ err = dmu_read (mdn, blkid, &dnbuf, &endian, data);
+ if (err)
+ return err;
+ grub_dprintf ("zfs", "alive\n");
+
+ grub_free (data->dnode_buf);
+ grub_free (data->dnode_mdn);
+ data->dnode_mdn = grub_malloc (sizeof (*mdn));
+ if (! data->dnode_mdn)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ data->dnode_buf = 0;
+ }
+ else
+ {
+ grub_memcpy (data->dnode_mdn, mdn, sizeof (*mdn));
+ data->dnode_buf = dnbuf;
+ data->dnode_start = blkid << epbs;
+ data->dnode_end = (blkid + 1) << epbs;
+ data->dnode_endian = endian;
+ }
+
+ grub_memmove (&(buf->dn), (dnode_phys_t *) dnbuf + idx, DNODE_SIZE);
+ buf->endian = endian;
+ if (type && buf->dn.dn_type != type)
+ return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type");
+
+ return GRUB_ERR_NONE;
+}
+
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+
+/*
+ * Get the file dnode for a given file name where mdn is the meta dnode
+ * for this ZFS object set. When found, place the file dnode in dn.
+ * The 'path' argument will be mangled.
+ *
+ */
+static grub_err_t
+dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
+ struct grub_zfs_data *data)
+{
+ grub_uint64_t objnum, version;
+ char *cname, ch;
+ grub_err_t err = GRUB_ERR_NONE;
+ char *path, *path_buf;
+ struct dnode_chain
+ {
+ struct dnode_chain *next;
+ dnode_end_t dn;
+ };
+ struct dnode_chain *dnode_path = 0, *dn_new, *root;
+
+ dn_new = grub_malloc (sizeof (*dn_new));
+ if (! dn_new)
+ return grub_errno;
+ dn_new->next = 0;
+ dnode_path = root = dn_new;
+
+ err = dnode_get (&subvol->mdn, MASTER_NODE_OBJ, DMU_OT_MASTER_NODE,
+ &(dnode_path->dn), data);
+ if (err)
+ {
+ grub_free (dn_new);
+ return err;
+ }
+
+ err = zap_lookup (&(dnode_path->dn), ZPL_VERSION_STR, &version,
+ data, 0);
+ if (err)
+ {
+ grub_free (dn_new);
+ return err;
+ }
+
+ if (version > ZPL_VERSION)
+ {
+ grub_free (dn_new);
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "too new ZPL version");
+ }
+
+ err = zap_lookup (&(dnode_path->dn), "casesensitivity",
+ &subvol->case_insensitive,
+ data, 0);
+ if (err == GRUB_ERR_FILE_NOT_FOUND)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ subvol->case_insensitive = 0;
+ }
+
+ err = zap_lookup (&(dnode_path->dn), ZFS_ROOT_OBJ, &objnum, data, 0);
+ if (err)
+ {
+ grub_free (dn_new);
+ return err;
+ }
+
+ err = dnode_get (&subvol->mdn, objnum, 0, &(dnode_path->dn), data);
+ if (err)
+ {
+ grub_free (dn_new);
+ return err;
+ }
+
+ path = path_buf = grub_strdup (path_in);
+ if (!path_buf)
+ {
+ grub_free (dn_new);
+ return grub_errno;
+ }
+
+ while (1)
+ {
+ /* skip leading slashes */
+ while (*path == '/')
+ path++;
+ if (!*path)
+ break;
+ /* get the next component name */
+ cname = path;
+ while (*path && *path != '/')
+ path++;
+ /* Skip dot. */
+ if (cname + 1 == path && cname[0] == '.')
+ continue;
+ /* Handle double dot. */
+ if (cname + 2 == path && cname[0] == '.' && cname[1] == '.')
+ {
+ if (dn_new->next)
+ {
+ dn_new = dnode_path;
+ dnode_path = dn_new->next;
+ grub_free (dn_new);
+ }
+ else
+ {
+ err = grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ "can't resolve ..");
+ break;
+ }
+ continue;
+ }
+
+ ch = *path;
+ *path = 0; /* ensure null termination */
+
+ if (dnode_path->dn.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS)
+ {
+ err = grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+ break;
+ }
+ err = zap_lookup (&(dnode_path->dn), cname, &objnum,
+ data, subvol->case_insensitive);
+ if (err)
+ break;
+
+ dn_new = grub_malloc (sizeof (*dn_new));
+ if (! dn_new)
+ {
+ err = grub_errno;
+ break;
+ }
+ dn_new->next = dnode_path;
+ dnode_path = dn_new;
+
+ objnum = ZFS_DIRENT_OBJ (objnum);
+ err = dnode_get (&subvol->mdn, objnum, 0, &(dnode_path->dn), data);
+ if (err)
+ break;
+
+ *path = ch;
+ if (dnode_path->dn.dn.dn_bonustype == DMU_OT_ZNODE
+ && ((grub_zfs_to_cpu64(((znode_phys_t *) DN_BONUS (&dnode_path->dn.dn))->zp_mode, dnode_path->dn.endian) >> 12) & 0xf) == 0xa)
+ {
+ char *sym_value;
+ grub_size_t sym_sz;
+ int free_symval = 0;
+ char *oldpath = path, *oldpathbuf = path_buf;
+ sym_value = ((char *) DN_BONUS (&dnode_path->dn.dn) + sizeof (struct znode_phys));
+
+ sym_sz = grub_zfs_to_cpu64 (((znode_phys_t *) DN_BONUS (&dnode_path->dn.dn))->zp_size, dnode_path->dn.endian);
+
+ if (dnode_path->dn.dn.dn_flags & 1)
+ {
+ grub_size_t block;
+ grub_size_t blksz;
+ blksz = (grub_zfs_to_cpu16 (dnode_path->dn.dn.dn_datablkszsec,
+ dnode_path->dn.endian)
+ << SPA_MINBLOCKSHIFT);
+
+ if (blksz == 0)
+ {
+ err = grub_error (GRUB_ERR_BAD_FS, "0-sized block");
+ break;
+ }
+
+ sym_value = grub_malloc (sym_sz);
+ if (!sym_value)
+ {
+ err = grub_errno;
+ break;
+ }
+
+ for (block = 0; block < (sym_sz + blksz - 1) / blksz; block++)
+ {
+ void *t;
+ grub_size_t movesize;
+
+ err = dmu_read (&(dnode_path->dn), block, &t, 0, data);
+ if (err)
+ {
+ grub_free (sym_value);
+ break;
+ }
+
+ movesize = sym_sz - block * blksz;
+ if (movesize > blksz)
+ movesize = blksz;
+
+ grub_memcpy (sym_value + block * blksz, t, movesize);
+ grub_free (t);
+ }
+ if (err)
+ break;
+ free_symval = 1;
+ }
+ path = path_buf = grub_malloc (sym_sz + grub_strlen (oldpath) + 1);
+ if (!path_buf)
+ {
+ grub_free (oldpathbuf);
+ if (free_symval)
+ grub_free (sym_value);
+ err = grub_errno;
+ break;
+ }
+ grub_memcpy (path, sym_value, sym_sz);
+ if (free_symval)
+ grub_free (sym_value);
+ path [sym_sz] = 0;
+ grub_memcpy (path + grub_strlen (path), oldpath,
+ grub_strlen (oldpath) + 1);
+
+ grub_free (oldpathbuf);
+ if (path[0] != '/')
+ {
+ dn_new = dnode_path;
+ dnode_path = dn_new->next;
+ grub_free (dn_new);
+ }
+ else while (dnode_path != root)
+ {
+ dn_new = dnode_path;
+ dnode_path = dn_new->next;
+ grub_free (dn_new);
+ }
+ }
+ if (dnode_path->dn.dn.dn_bonustype == DMU_OT_SA)
+ {
+ void *sahdrp;
+ int hdrsize;
+
+ if (dnode_path->dn.dn.dn_bonuslen != 0)
+ {
+ sahdrp = DN_BONUS (&dnode_path->dn.dn);
+ }
+ else if (dnode_path->dn.dn.dn_flags & DNODE_FLAG_SPILL_BLKPTR)
+ {
+ blkptr_t *bp = &dnode_path->dn.dn.dn_spill;
+
+ err = zio_read (bp, dnode_path->dn.endian, &sahdrp, NULL, data);
+ if (err)
+ break;
+ }
+ else
+ {
+ err = grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt");
+ break;
+ }
+
+ hdrsize = SA_HDR_SIZE (((sa_hdr_phys_t *) sahdrp));
+
+ if (((grub_zfs_to_cpu64 (grub_get_unaligned64 ((char *) sahdrp
+ + hdrsize
+ + SA_TYPE_OFFSET),
+ dnode_path->dn.endian) >> 12) & 0xf) == 0xa)
+ {
+ char *sym_value = (char *) sahdrp + hdrsize + SA_SYMLINK_OFFSET;
+ grub_size_t sym_sz =
+ grub_zfs_to_cpu64 (grub_get_unaligned64 ((char *) sahdrp
+ + hdrsize
+ + SA_SIZE_OFFSET),
+ dnode_path->dn.endian);
+ char *oldpath = path, *oldpathbuf = path_buf;
+ path = path_buf = grub_malloc (sym_sz + grub_strlen (oldpath) + 1);
+ if (!path_buf)
+ {
+ grub_free (oldpathbuf);
+ err = grub_errno;
+ break;
+ }
+ grub_memcpy (path, sym_value, sym_sz);
+ path [sym_sz] = 0;
+ grub_memcpy (path + grub_strlen (path), oldpath,
+ grub_strlen (oldpath) + 1);
+
+ grub_free (oldpathbuf);
+ if (path[0] != '/')
+ {
+ dn_new = dnode_path;
+ dnode_path = dn_new->next;
+ grub_free (dn_new);
+ }
+ else while (dnode_path != root)
+ {
+ dn_new = dnode_path;
+ dnode_path = dn_new->next;
+ grub_free (dn_new);
+ }
+ }
+ }
+ }
+
+ if (!err)
+ grub_memcpy (dn, &(dnode_path->dn), sizeof (*dn));
+
+ while (dnode_path)
+ {
+ dn_new = dnode_path->next;
+ grub_free (dnode_path);
+ dnode_path = dn_new;
+ }
+ grub_free (path_buf);
+ return err;
+}
+
+#if 0
+/*
+ * Get the default 'bootfs' property value from the rootpool.
+ *
+ */
+static grub_err_t
+get_default_bootfsobj (dnode_phys_t * mosmdn, grub_uint64_t * obj,
+ struct grub_zfs_data *data)
+{
+ grub_uint64_t objnum = 0;
+ dnode_phys_t *dn;
+ if (!dn)
+ return grub_errno;
+
+ if ((grub_errno = dnode_get (mosmdn, DMU_POOL_DIRECTORY_OBJECT,
+ DMU_OT_OBJECT_DIRECTORY, dn, data)))
+ {
+ grub_free (dn);
+ return (grub_errno);
+ }
+
+ /*
+ * find the object number for 'pool_props', and get the dnode
+ * of the 'pool_props'.
+ */
+ if (zap_lookup (dn, DMU_POOL_PROPS, &objnum, data))
+ {
+ grub_free (dn);
+ return (GRUB_ERR_BAD_FS);
+ }
+ if ((grub_errno = dnode_get (mosmdn, objnum, DMU_OT_POOL_PROPS, dn, data)))
+ {
+ grub_free (dn);
+ return (grub_errno);
+ }
+ if (zap_lookup (dn, ZPOOL_PROP_BOOTFS, &objnum, data))
+ {
+ grub_free (dn);
+ return (GRUB_ERR_BAD_FS);
+ }
+
+ if (!objnum)
+ {
+ grub_free (dn);
+ return (GRUB_ERR_BAD_FS);
+ }
+
+ *obj = objnum;
+ return (0);
+}
+#endif
+/*
+ * Given a MOS metadnode, get the metadnode of a given filesystem name (fsname),
+ * e.g. pool/rootfs, or a given object number (obj), e.g. the object number
+ * of pool/rootfs.
+ *
+ * If no fsname and no obj are given, return the DSL_DIR metadnode.
+ * If fsname is given, return its metadnode and its matching object number.
+ * If only obj is given, return the metadnode for this object number.
+ *
+ */
+static grub_err_t
+get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname,
+ dnode_end_t * mdn, struct grub_zfs_data *data)
+{
+ grub_uint64_t objnum;
+ grub_err_t err;
+
+ grub_dprintf ("zfs", "endian = %d\n", mosmdn->endian);
+
+ err = dnode_get (mosmdn, DMU_POOL_DIRECTORY_OBJECT,
+ DMU_OT_OBJECT_DIRECTORY, mdn, data);
+ if (err)
+ return err;
+
+ grub_dprintf ("zfs", "alive\n");
+
+ err = zap_lookup (mdn, DMU_POOL_ROOT_DATASET, &objnum, data, 0);
+ if (err)
+ return err;
+
+ grub_dprintf ("zfs", "alive\n");
+
+ err = dnode_get (mosmdn, objnum, 0, mdn, data);
+ if (err)
+ return err;
+
+ grub_dprintf ("zfs", "alive\n");
+
+ while (*fsname)
+ {
+ grub_uint64_t childobj;
+ char *cname, ch;
+
+ while (*fsname == '/')
+ fsname++;
+
+ if (! *fsname || *fsname == '@')
+ break;
+
+ cname = fsname;
+ while (*fsname && *fsname != '/')
+ fsname++;
+ ch = *fsname;
+ *fsname = 0;
+
+ childobj = grub_zfs_to_cpu64 ((((dsl_dir_phys_t *) DN_BONUS (&mdn->dn)))->dd_child_dir_zapobj, mdn->endian);
+ err = dnode_get (mosmdn, childobj,
+ DMU_OT_DSL_DIR_CHILD_MAP, mdn, data);
+ if (err)
+ return err;
+
+ err = zap_lookup (mdn, cname, &objnum, data, 0);
+ if (err)
+ return err;
+
+ err = dnode_get (mosmdn, objnum, 0, mdn, data);
+ if (err)
+ return err;
+
+ *fsname = ch;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
+{
+ void *osp;
+ blkptr_t *bp;
+ grub_size_t ospsize = 0;
+ grub_err_t err;
+
+ grub_dprintf ("zfs", "endian = %d\n", mdn->endian);
+
+ bp = &(((dsl_dataset_phys_t *) DN_BONUS (&mdn->dn))->ds_bp);
+ err = zio_read (bp, mdn->endian, &osp, &ospsize, data);
+ if (err)
+ return err;
+ if (ospsize < OBJSET_PHYS_SIZE_V14)
+ {
+ grub_free (osp);
+ return grub_error (GRUB_ERR_BAD_FS, "too small osp");
+ }
+
+ mdn->endian = (grub_zfs_to_cpu64 (bp->blk_prop, mdn->endian)>>63) & 1;
+ grub_memmove ((char *) &(mdn->dn),
+ (char *) &((objset_phys_t *) osp)->os_meta_dnode, DNODE_SIZE);
+ grub_free (osp);
+ return GRUB_ERR_NONE;
+}
+
+/* Context for dnode_get_fullpath. */
+struct dnode_get_fullpath_ctx
+{
+ struct subvolume *subvol;
+ grub_uint64_t salt;
+ int keyn;
+};
+
+/* Helper for dnode_get_fullpath. */
+static int
+count_zap_keys (const void *name __attribute__ ((unused)),
+ grub_size_t namelen __attribute__ ((unused)),
+ const void *val_in __attribute__ ((unused)),
+ grub_size_t nelem __attribute__ ((unused)),
+ grub_size_t elemsize __attribute__ ((unused)),
+ void *data)
+{
+ struct dnode_get_fullpath_ctx *ctx = data;
+
+ ctx->subvol->nkeys++;
+ return 0;
+}
+
+/* Helper for dnode_get_fullpath. */
+static int
+load_zap_key (const void *name, grub_size_t namelen, const void *val_in,
+ grub_size_t nelem, grub_size_t elemsize, void *data)
+{
+ struct dnode_get_fullpath_ctx *ctx = data;
+
+ if (namelen != 1)
+ {
+ grub_dprintf ("zfs", "Unexpected key index size %" PRIuGRUB_SIZE "\n",
+ namelen);
+ return 0;
+ }
+
+ if (elemsize != 1)
+ {
+ grub_dprintf ("zfs", "Unexpected key element size %" PRIuGRUB_SIZE "\n",
+ elemsize);
+ return 0;
+ }
+
+ ctx->subvol->keyring[ctx->keyn].txg =
+ grub_be_to_cpu64 (*(grub_uint64_t *) name);
+ ctx->subvol->keyring[ctx->keyn].algo =
+ grub_le_to_cpu64 (*(grub_uint64_t *) val_in);
+ ctx->subvol->keyring[ctx->keyn].cipher =
+ grub_zfs_load_key (val_in, nelem, ctx->salt,
+ ctx->subvol->keyring[ctx->keyn].algo);
+ ctx->keyn++;
+ return 0;
+}
+
+static grub_err_t
+dnode_get_fullpath (const char *fullpath, struct subvolume *subvol,
+ dnode_end_t * dn, int *isfs,
+ struct grub_zfs_data *data)
+{
+ char *fsname, *snapname;
+ const char *ptr_at, *filename;
+ grub_uint64_t headobj;
+ grub_uint64_t keychainobj;
+ grub_err_t err;
+
+ ptr_at = grub_strchr (fullpath, '@');
+ if (! ptr_at)
+ {
+ *isfs = 1;
+ filename = 0;
+ snapname = 0;
+ fsname = grub_strdup (fullpath);
+ }
+ else
+ {
+ const char *ptr_slash = grub_strchr (ptr_at, '/');
+
+ *isfs = 0;
+ fsname = grub_malloc (ptr_at - fullpath + 1);
+ if (!fsname)
+ return grub_errno;
+ grub_memcpy (fsname, fullpath, ptr_at - fullpath);
+ fsname[ptr_at - fullpath] = 0;
+ if (ptr_at[1] && ptr_at[1] != '/')
+ {
+ snapname = grub_malloc (ptr_slash - ptr_at);
+ if (!snapname)
+ {
+ grub_free (fsname);
+ return grub_errno;
+ }
+ grub_memcpy (snapname, ptr_at + 1, ptr_slash - ptr_at - 1);
+ snapname[ptr_slash - ptr_at - 1] = 0;
+ }
+ else
+ snapname = 0;
+ if (ptr_slash)
+ filename = ptr_slash;
+ else
+ filename = "/";
+ grub_dprintf ("zfs", "fsname = '%s' snapname='%s' filename = '%s'\n",
+ fsname, snapname, filename);
+ }
+ grub_dprintf ("zfs", "alive\n");
+ err = get_filesystem_dnode (&(data->mos), fsname, dn, data);
+ if (err)
+ {
+ grub_free (fsname);
+ grub_free (snapname);
+ return err;
+ }
+
+ grub_dprintf ("zfs", "alive\n");
+
+ headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&dn->dn))->dd_head_dataset_obj, dn->endian);
+
+ grub_dprintf ("zfs", "endian = %d\n", subvol->mdn.endian);
+
+ err = dnode_get (&(data->mos), headobj, 0, &subvol->mdn, data);
+ if (err)
+ {
+ grub_free (fsname);
+ grub_free (snapname);
+ return err;
+ }
+ grub_dprintf ("zfs", "endian = %d\n", subvol->mdn.endian);
+
+ keychainobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&dn->dn))->keychain, dn->endian);
+ if (grub_zfs_load_key && keychainobj)
+ {
+ struct dnode_get_fullpath_ctx ctx = {
+ .subvol = subvol,
+ .keyn = 0
+ };
+ dnode_end_t keychain_dn, props_dn;
+ grub_uint64_t propsobj;
+ propsobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&dn->dn))->dd_props_zapobj, dn->endian);
+
+ err = dnode_get (&(data->mos), propsobj, DMU_OT_DSL_PROPS,
+ &props_dn, data);
+ if (err)
+ {
+ grub_free (fsname);
+ grub_free (snapname);
+ return err;
+ }
+
+ err = zap_lookup (&props_dn, "salt", &ctx.salt, data, 0);
+ if (err == GRUB_ERR_FILE_NOT_FOUND)
+ {
+ err = 0;
+ grub_errno = 0;
+ ctx.salt = 0;
+ }
+ if (err)
+ {
+ grub_dprintf ("zfs", "failed here\n");
+ return err;
+ }
+
+ err = dnode_get (&(data->mos), keychainobj, DMU_OT_DSL_KEYCHAIN,
+ &keychain_dn, data);
+ if (err)
+ {
+ grub_free (fsname);
+ grub_free (snapname);
+ return err;
+ }
+ subvol->nkeys = 0;
+ zap_iterate (&keychain_dn, 8, count_zap_keys, &ctx, data);
+ subvol->keyring = grub_calloc (subvol->nkeys, sizeof (subvol->keyring[0]));
+ if (!subvol->keyring)
+ {
+ grub_free (fsname);
+ grub_free (snapname);
+ return err;
+ }
+ zap_iterate (&keychain_dn, 8, load_zap_key, &ctx, data);
+ }
+
+ if (snapname)
+ {
+ grub_uint64_t snapobj;
+
+ snapobj = grub_zfs_to_cpu64 (((dsl_dataset_phys_t *) DN_BONUS (&subvol->mdn.dn))->ds_snapnames_zapobj, subvol->mdn.endian);
+
+ err = dnode_get (&(data->mos), snapobj,
+ DMU_OT_DSL_DS_SNAP_MAP, &subvol->mdn, data);
+ if (!err)
+ err = zap_lookup (&subvol->mdn, snapname, &headobj, data, 0);
+ if (!err)
+ err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET,
+ &subvol->mdn, data);
+ if (err)
+ {
+ grub_free (fsname);
+ grub_free (snapname);
+ return err;
+ }
+ }
+
+ subvol->obj = headobj;
+
+ make_mdn (&subvol->mdn, data);
+
+ grub_dprintf ("zfs", "endian = %d\n", subvol->mdn.endian);
+
+ if (*isfs)
+ {
+ grub_free (fsname);
+ grub_free (snapname);
+ return GRUB_ERR_NONE;
+ }
+ err = dnode_get_path (subvol, filename, dn, data);
+ grub_free (fsname);
+ grub_free (snapname);
+ return err;
+}
+
+static int
+nvlist_find_value (const char *nvlist_in, const char *name,
+ int valtype, char **val,
+ grub_size_t *size_out, grub_size_t *nelm_out)
+{
+ grub_size_t nvp_name_len, name_len = grub_strlen(name);
+ int type;
+ const char *nvpair=NULL,*nvlist=nvlist_in;
+ char *nvp_name;
+
+ /* Verify if the 1st and 2nd byte in the nvlist are valid. */
+ /* NOTE: independently of what endianness header announces all
+ subsequent values are big-endian. */
+ if (nvlist[0] != NV_ENCODE_XDR || (nvlist[1] != NV_LITTLE_ENDIAN
+ && nvlist[1] != NV_BIG_ENDIAN))
+ {
+ grub_dprintf ("zfs", "incorrect nvlist header\n");
+ grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist");
+ return 0;
+ }
+
+ /*
+ * Loop thru the nvpair list
+ * The XDR representation of an integer is in big-endian byte order.
+ */
+ while ((nvpair=nvlist_next_nvpair(nvlist,nvpair)))
+ {
+ nvpair_name(nvpair,&nvp_name, &nvp_name_len);
+ type = nvpair_type(nvpair);
+ if (type == valtype
+ && (nvp_name_len == name_len
+ || (nvp_name_len > name_len && nvp_name[name_len] == '\0'))
+ && grub_memcmp (nvp_name, name, name_len) == 0)
+ {
+ return nvpair_value(nvpair,val,size_out,nelm_out);
+ }
+ }
+ return 0;
+}
+
+int
+grub_zfs_nvlist_lookup_uint64 (const char *nvlist, const char *name,
+ grub_uint64_t * out)
+{
+ char *nvpair;
+ grub_size_t size;
+ int found;
+
+ found = nvlist_find_value (nvlist, name, DATA_TYPE_UINT64, &nvpair, &size, 0);
+ if (!found)
+ return 0;
+ if (size < sizeof (grub_uint64_t))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid uint64");
+ return 0;
+ }
+
+ *out = grub_be_to_cpu64 (grub_get_unaligned64 (nvpair));
+ return 1;
+}
+
+char *
+grub_zfs_nvlist_lookup_string (const char *nvlist, const char *name)
+{
+ char *nvpair;
+ char *ret;
+ grub_size_t slen;
+ grub_size_t size;
+ int found;
+
+ found = nvlist_find_value (nvlist, name, DATA_TYPE_STRING, &nvpair, &size, 0);
+ if (!found)
+ return 0;
+ if (size < 4)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid string");
+ return 0;
+ }
+ slen = grub_be_to_cpu32 (grub_get_unaligned32 (nvpair));
+ if (slen > size - 4)
+ slen = size - 4;
+ ret = grub_malloc (slen + 1);
+ if (!ret)
+ return 0;
+ grub_memcpy (ret, nvpair + 4, slen);
+ ret[slen] = 0;
+ return ret;
+}
+
+char *
+grub_zfs_nvlist_lookup_nvlist (const char *nvlist, const char *name)
+{
+ char *nvpair;
+ char *ret;
+ grub_size_t size, sz;
+ int found;
+
+ found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST, &nvpair,
+ &size, 0);
+ if (!found)
+ return 0;
+
+ if (grub_add (size, 3 * sizeof (grub_uint32_t), &sz))
+ return 0;
+
+ ret = grub_zalloc (sz);
+ if (!ret)
+ return 0;
+ grub_memcpy (ret, nvlist, sizeof (grub_uint32_t));
+
+ grub_memcpy (ret + sizeof (grub_uint32_t), nvpair, size);
+ return ret;
+}
+
+int
+grub_zfs_nvlist_lookup_nvlist_array_get_nelm (const char *nvlist,
+ const char *name)
+{
+ char *nvpair;
+ grub_size_t nelm, size;
+ int found;
+
+ found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST_ARRAY, &nvpair,
+ &size, &nelm);
+ if (! found)
+ return -1;
+ return nelm;
+}
+
+static int
+get_nvlist_size (const char *beg, const char *limit)
+{
+ const char *ptr;
+ grub_uint32_t encode_size;
+
+ ptr = beg + 8;
+
+ while (ptr < limit
+ && (encode_size = grub_be_to_cpu32 (grub_get_unaligned32 (ptr))))
+ ptr += encode_size; /* goto the next nvpair */
+ ptr += 8;
+ return (ptr > limit) ? -1 : (ptr - beg);
+}
+
+char *
+grub_zfs_nvlist_lookup_nvlist_array (const char *nvlist, const char *name,
+ grub_size_t index)
+{
+ char *nvpair, *nvpairptr;
+ int found;
+ char *ret;
+ grub_size_t size;
+ unsigned i;
+ grub_size_t nelm;
+ int elemsize = 0;
+
+ found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST_ARRAY, &nvpair,
+ &size, &nelm);
+ if (!found)
+ return 0;
+ if (index >= nelm)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, "trying to lookup past nvlist array");
+ return 0;
+ }
+
+ nvpairptr = nvpair;
+
+ for (i = 0; i < index; i++)
+ {
+ int r;
+ r = get_nvlist_size (nvpairptr, nvpair + size);
+
+ if (r < 0)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist array");
+ return NULL;
+ }
+ nvpairptr += r;
+ }
+
+ elemsize = get_nvlist_size (nvpairptr, nvpair + size);
+
+ if (elemsize < 0)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist array");
+ return 0;
+ }
+
+ ret = grub_zalloc (elemsize + sizeof (grub_uint32_t));
+ if (!ret)
+ return 0;
+ grub_memcpy (ret, nvlist, sizeof (grub_uint32_t));
+
+ grub_memcpy (ret + sizeof (grub_uint32_t), nvpairptr, elemsize);
+ return ret;
+}
+
+static void
+unmount_device (struct grub_zfs_device_desc *desc)
+{
+ unsigned i;
+ switch (desc->type)
+ {
+ case DEVICE_LEAF:
+ if (!desc->original && desc->dev)
+ grub_device_close (desc->dev);
+ return;
+ case DEVICE_RAIDZ:
+ case DEVICE_MIRROR:
+ for (i = 0; i < desc->n_children; i++)
+ unmount_device (&desc->children[i]);
+ grub_free (desc->children);
+ return;
+ }
+}
+
+static void
+zfs_unmount (struct grub_zfs_data *data)
+{
+ unsigned i;
+ for (i = 0; i < data->n_devices_attached; i++)
+ unmount_device (&data->devices_attached[i]);
+ grub_free (data->devices_attached);
+ grub_free (data->dnode_buf);
+ grub_free (data->dnode_mdn);
+ grub_free (data->file_buf);
+ for (i = 0; i < data->subvol.nkeys; i++)
+ grub_crypto_cipher_close (data->subvol.keyring[i].cipher);
+ grub_free (data->subvol.keyring);
+ grub_free (data);
+}
+
+/*
+ * zfs_mount() locates a valid uberblock of the root pool and read in its MOS
+ * to the memory address MOS.
+ *
+ */
+static struct grub_zfs_data *
+zfs_mount (grub_device_t dev)
+{
+ struct grub_zfs_data *data = 0;
+ grub_err_t err;
+ void *osp = 0;
+ grub_size_t ospsize;
+ grub_zfs_endian_t ub_endian = GRUB_ZFS_UNKNOWN_ENDIAN;
+ uberblock_t *ub;
+ int inserted;
+
+ if (! dev->disk)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, "not a disk");
+ return 0;
+ }
+
+ data = grub_zalloc (sizeof (*data));
+ if (!data)
+ return 0;
+#if 0
+ /* if it's our first time here, zero the best uberblock out */
+ if (data->best_drive == 0 && data->best_part == 0 && find_best_root)
+ grub_memset (&current_uberblock, 0, sizeof (uberblock_t));
+#endif
+
+ data->n_devices_allocated = 16;
+ data->devices_attached = grub_malloc (sizeof (data->devices_attached[0])
+ * data->n_devices_allocated);
+ data->n_devices_attached = 0;
+ err = scan_disk (dev, data, 1, &inserted);
+ if (err)
+ {
+ zfs_unmount (data);
+ return NULL;
+ }
+
+ ub = &(data->current_uberblock);
+ ub_endian = (grub_zfs_to_cpu64 (ub->ub_magic,
+ GRUB_ZFS_LITTLE_ENDIAN) == UBERBLOCK_MAGIC
+ ? GRUB_ZFS_LITTLE_ENDIAN : GRUB_ZFS_BIG_ENDIAN);
+
+ err = zio_read (&ub->ub_rootbp, ub_endian,
+ &osp, &ospsize, data);
+ if (err)
+ {
+ zfs_unmount (data);
+ return NULL;
+ }
+
+ if (ospsize < OBJSET_PHYS_SIZE_V14)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "OSP too small");
+ grub_free (osp);
+ zfs_unmount (data);
+ return NULL;
+ }
+
+ if (ub->ub_version >= SPA_VERSION_FEATURES &&
+ check_mos_features(&((objset_phys_t *) osp)->os_meta_dnode,ub_endian,
+ data) != 0)
+ {
+ 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);
+ data->mos.endian = (grub_zfs_to_cpu64 (ub->ub_rootbp.blk_prop,
+ ub_endian) >> 63) & 1;
+ grub_free (osp);
+
+ return data;
+}
+
+grub_err_t
+grub_zfs_fetch_nvlist (grub_device_t dev, char **nvlist)
+{
+ struct grub_zfs_data *zfs;
+ grub_err_t err;
+
+ zfs = zfs_mount (dev);
+ if (!zfs)
+ return grub_errno;
+ err = zfs_fetch_nvlist (zfs->device_original, nvlist);
+ zfs_unmount (zfs);
+ return err;
+}
+
+static grub_err_t
+zfs_label (grub_device_t device, char **label)
+{
+ char *nvlist;
+ grub_err_t err;
+ struct grub_zfs_data *data;
+
+ data = zfs_mount (device);
+ if (! data)
+ return grub_errno;
+
+ err = zfs_fetch_nvlist (data->device_original, &nvlist);
+ if (err)
+ {
+ zfs_unmount (data);
+ return err;
+ }
+
+ *label = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME);
+ grub_free (nvlist);
+ zfs_unmount (data);
+ return grub_errno;
+}
+
+static grub_err_t
+zfs_uuid (grub_device_t device, char **uuid)
+{
+ struct grub_zfs_data *data;
+
+ *uuid = 0;
+
+ data = zfs_mount (device);
+ if (! data)
+ return grub_errno;
+
+ *uuid = grub_xasprintf ("%016llx", (long long unsigned) data->guid);
+ zfs_unmount (data);
+ if (! *uuid)
+ return grub_errno;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+zfs_mtime (grub_device_t device, grub_int64_t *mt)
+{
+ struct grub_zfs_data *data;
+ grub_zfs_endian_t ub_endian = GRUB_ZFS_UNKNOWN_ENDIAN;
+ uberblock_t *ub;
+
+ *mt = 0;
+
+ data = zfs_mount (device);
+ if (! data)
+ return grub_errno;
+
+ ub = &(data->current_uberblock);
+ ub_endian = (grub_zfs_to_cpu64 (ub->ub_magic,
+ GRUB_ZFS_LITTLE_ENDIAN) == UBERBLOCK_MAGIC
+ ? GRUB_ZFS_LITTLE_ENDIAN : GRUB_ZFS_BIG_ENDIAN);
+
+ *mt = grub_zfs_to_cpu64 (ub->ub_timestamp, ub_endian);
+ zfs_unmount (data);
+ return GRUB_ERR_NONE;
+}
+
+/*
+ * zfs_open() locates a file in the rootpool by following the
+ * MOS and places the dnode of the file in the memory address DNODE.
+ */
+static grub_err_t
+grub_zfs_open (struct grub_file *file, const char *fsfilename)
+{
+ struct grub_zfs_data *data;
+ grub_err_t err;
+ int isfs;
+
+ data = zfs_mount (file->device);
+ if (! data)
+ return grub_errno;
+
+ err = dnode_get_fullpath (fsfilename, &(data->subvol),
+ &(data->dnode), &isfs, data);
+ if (err)
+ {
+ zfs_unmount (data);
+ return err;
+ }
+
+ if (isfs)
+ {
+ zfs_unmount (data);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("missing `%c' symbol"), '@');
+ }
+
+ /* We found the dnode for this file. Verify if it is a plain file. */
+ if (data->dnode.dn.dn_type != DMU_OT_PLAIN_FILE_CONTENTS)
+ {
+ zfs_unmount (data);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
+ }
+
+ /* get the file size and set the file position to 0 */
+
+ /*
+ * For DMU_OT_SA we will need to locate the SIZE attribute
+ * attribute, which could be either in the bonus buffer
+ * or the "spill" block.
+ */
+ if (data->dnode.dn.dn_bonustype == DMU_OT_SA)
+ {
+ void *sahdrp;
+ int hdrsize;
+
+ if (data->dnode.dn.dn_bonuslen != 0)
+ {
+ sahdrp = (sa_hdr_phys_t *) DN_BONUS (&data->dnode.dn);
+ }
+ else if (data->dnode.dn.dn_flags & DNODE_FLAG_SPILL_BLKPTR)
+ {
+ blkptr_t *bp = &data->dnode.dn.dn_spill;
+
+ err = zio_read (bp, data->dnode.endian, &sahdrp, NULL, data);
+ if (err)
+ return err;
+ }
+ else
+ {
+ return grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt");
+ }
+
+ hdrsize = SA_HDR_SIZE (((sa_hdr_phys_t *) sahdrp));
+ file->size = grub_zfs_to_cpu64 (grub_get_unaligned64 ((char *) sahdrp + hdrsize + SA_SIZE_OFFSET), data->dnode.endian);
+ }
+ else if (data->dnode.dn.dn_bonustype == DMU_OT_ZNODE)
+ {
+ file->size = grub_zfs_to_cpu64 (((znode_phys_t *) DN_BONUS (&data->dnode.dn))->zp_size, data->dnode.endian);
+ }
+ else
+ return grub_error (GRUB_ERR_BAD_FS, "bad bonus type");
+
+ file->data = data;
+ file->offset = 0;
+
+#ifndef GRUB_UTIL
+ grub_dl_ref (my_mod);
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_ssize_t
+grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_zfs_data *data = (struct grub_zfs_data *) file->data;
+ grub_size_t blksz, movesize;
+ grub_size_t length;
+ grub_size_t read;
+ grub_err_t err;
+
+ /*
+ * If offset is in memory, move it into the buffer provided and return.
+ */
+ if (file->offset >= data->file_start
+ && file->offset + len <= data->file_end)
+ {
+ grub_memmove (buf, data->file_buf + file->offset - data->file_start,
+ len);
+ return 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
+ * read in as large a chunk as there is space available, but for
+ * now, this only reads in one data block at a time.
+ */
+ length = len;
+ read = 0;
+ while (length)
+ {
+ void *t;
+ /*
+ * Find requested blkid and the offset within that block.
+ */
+ grub_uint64_t blkid = grub_divmod64 (file->offset + read, blksz, 0);
+ grub_free (data->file_buf);
+ data->file_buf = 0;
+
+ err = dmu_read (&(data->dnode), blkid, &t,
+ 0, data);
+ data->file_buf = t;
+ if (err)
+ {
+ data->file_buf = NULL;
+ data->file_start = data->file_end = 0;
+ return -1;
+ }
+
+ data->file_start = blkid * blksz;
+ data->file_end = data->file_start + blksz;
+
+ movesize = data->file_end - file->offset - read;
+ if (movesize > length)
+ movesize = length;
+
+ grub_memmove (buf, data->file_buf + file->offset + read
+ - data->file_start, movesize);
+ buf += movesize;
+ length -= movesize;
+ read += movesize;
+ }
+
+ return len;
+}
+
+static grub_err_t
+grub_zfs_close (grub_file_t file)
+{
+ zfs_unmount ((struct grub_zfs_data *) file->data);
+
+#ifndef GRUB_UTIL
+ grub_dl_unref (my_mod);
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_zfs_getmdnobj (grub_device_t dev, const char *fsfilename,
+ grub_uint64_t *mdnobj)
+{
+ struct grub_zfs_data *data;
+ grub_err_t err;
+ int isfs;
+
+ data = zfs_mount (dev);
+ if (! data)
+ return grub_errno;
+
+ err = dnode_get_fullpath (fsfilename, &(data->subvol),
+ &(data->dnode), &isfs, data);
+ *mdnobj = data->subvol.obj;
+ zfs_unmount (data);
+ return err;
+}
+
+static grub_err_t
+fill_fs_info (struct grub_dirhook_info *info,
+ dnode_end_t mdn, struct grub_zfs_data *data)
+{
+ grub_err_t err;
+ dnode_end_t dn;
+ grub_uint64_t objnum;
+ grub_uint64_t headobj;
+
+ grub_memset (info, 0, sizeof (*info));
+
+ info->dir = 1;
+
+ if (mdn.dn.dn_type == DMU_OT_DSL_DIR)
+ {
+ 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, 0, &mdn, data);
+ if (err)
+ {
+ grub_dprintf ("zfs", "failed here\n");
+ return err;
+ }
+ }
+ err = make_mdn (&mdn, data);
+ if (err)
+ return err;
+ err = dnode_get (&mdn, MASTER_NODE_OBJ, DMU_OT_MASTER_NODE,
+ &dn, data);
+ if (err)
+ {
+ grub_dprintf ("zfs", "failed here\n");
+ return err;
+ }
+
+ err = zap_lookup (&dn, ZFS_ROOT_OBJ, &objnum, data, 0);
+ if (err)
+ {
+ grub_dprintf ("zfs", "failed here\n");
+ return err;
+ }
+
+ err = dnode_get (&mdn, objnum, 0, &dn, data);
+ if (err)
+ {
+ grub_dprintf ("zfs", "failed here\n");
+ return err;
+ }
+
+ if (dn.dn.dn_bonustype == DMU_OT_SA)
+ {
+ void *sahdrp;
+ int hdrsize;
+
+ if (dn.dn.dn_bonuslen != 0)
+ {
+ sahdrp = (sa_hdr_phys_t *) DN_BONUS (&dn.dn);
+ }
+ else if (dn.dn.dn_flags & DNODE_FLAG_SPILL_BLKPTR)
+ {
+ blkptr_t *bp = &dn.dn.dn_spill;
+
+ err = zio_read (bp, dn.endian, &sahdrp, NULL, data);
+ if (err)
+ return err;
+ }
+ else
+ {
+ grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt");
+ return grub_errno;
+ }
+
+ hdrsize = SA_HDR_SIZE (((sa_hdr_phys_t *) sahdrp));
+ info->mtimeset = 1;
+ info->mtime = grub_zfs_to_cpu64 (grub_get_unaligned64 ((char *) sahdrp + hdrsize + SA_MTIME_OFFSET), dn.endian);
+ }
+
+ if (dn.dn.dn_bonustype == DMU_OT_ZNODE)
+ {
+ info->mtimeset = 1;
+ info->mtime = grub_zfs_to_cpu64 (((znode_phys_t *) DN_BONUS (&dn.dn))->zp_mtime[0], dn.endian);
+ }
+ return 0;
+}
+
+/* Helper for grub_zfs_dir. */
+static int
+iterate_zap (const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx)
+{
+ grub_err_t err;
+ struct grub_dirhook_info info;
+
+ dnode_end_t dn;
+ grub_memset (&info, 0, sizeof (info));
+
+ 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)
+ {
+ void *sahdrp;
+ int hdrsize;
+
+ if (dn.dn.dn_bonuslen != 0)
+ {
+ sahdrp = (sa_hdr_phys_t *) DN_BONUS (&ctx->data->dnode.dn);
+ }
+ else if (dn.dn.dn_flags & DNODE_FLAG_SPILL_BLKPTR)
+ {
+ blkptr_t *bp = &dn.dn.dn_spill;
+
+ err = zio_read (bp, dn.endian, &sahdrp, NULL, ctx->data);
+ if (err)
+ {
+ grub_print_error ();
+ return 0;
+ }
+ }
+ else
+ {
+ grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt");
+ grub_print_error ();
+ return 0;
+ }
+
+ hdrsize = SA_HDR_SIZE (((sa_hdr_phys_t *) sahdrp));
+ info.mtimeset = 1;
+ info.mtime = grub_zfs_to_cpu64 (grub_get_unaligned64 ((char *) sahdrp + hdrsize + SA_MTIME_OFFSET), dn.endian);
+ info.case_insensitive = ctx->data->subvol.case_insensitive;
+ }
+
+ if (dn.dn.dn_bonustype == DMU_OT_ZNODE)
+ {
+ info.mtimeset = 1;
+ info.mtime = grub_zfs_to_cpu64 (((znode_phys_t *) DN_BONUS (&dn.dn))->zp_mtime[0],
+ dn.endian);
+ }
+ info.dir = (dn.dn.dn_type == DMU_OT_DIRECTORY_CONTENTS);
+ grub_dprintf ("zfs", "type=%d, name=%s\n",
+ (int)dn.dn.dn_type, (char *)name);
+ return ctx->hook (name, &info, ctx->hook_data);
+}
+
+/* Helper for grub_zfs_dir. */
+static int
+iterate_zap_fs (const char *name, grub_uint64_t val,
+ struct grub_zfs_dir_ctx *ctx)
+{
+ grub_err_t err;
+ struct grub_dirhook_info info;
+
+ dnode_end_t mdn;
+ err = dnode_get (&(ctx->data->mos), val, 0, &mdn, ctx->data);
+ if (err)
+ {
+ grub_errno = 0;
+ return 0;
+ }
+ if (mdn.dn.dn_type != DMU_OT_DSL_DIR)
+ return 0;
+
+ err = fill_fs_info (&info, mdn, ctx->data);
+ if (err)
+ {
+ grub_errno = 0;
+ return 0;
+ }
+ return ctx->hook (name, &info, ctx->hook_data);
+}
+
+/* Helper for grub_zfs_dir. */
+static int
+iterate_zap_snap (const char *name, grub_uint64_t val,
+ struct grub_zfs_dir_ctx *ctx)
+{
+ grub_err_t err;
+ struct grub_dirhook_info info;
+ char *name2;
+ int ret;
+
+ dnode_end_t mdn;
+
+ err = dnode_get (&(ctx->data->mos), val, 0, &mdn, ctx->data);
+ if (err)
+ {
+ grub_errno = 0;
+ return 0;
+ }
+
+ if (mdn.dn.dn_type != DMU_OT_DSL_DATASET)
+ return 0;
+
+ err = fill_fs_info (&info, mdn, ctx->data);
+ if (err)
+ {
+ grub_errno = 0;
+ return 0;
+ }
+
+ name2 = grub_malloc (grub_strlen (name) + 2);
+ name2[0] = '@';
+ grub_memcpy (name2 + 1, name, grub_strlen (name) + 1);
+ ret = ctx->hook (name2, &info, ctx->hook_data);
+ grub_free (name2);
+ return ret;
+}
+
+static grub_err_t
+grub_zfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ struct grub_zfs_dir_ctx ctx = {
+ .hook = hook,
+ .hook_data = hook_data
+ };
+ struct grub_zfs_data *data;
+ grub_err_t err;
+ int isfs;
+
+ data = zfs_mount (device);
+ if (! data)
+ return grub_errno;
+ err = dnode_get_fullpath (path, &(data->subvol), &(data->dnode), &isfs, data);
+ if (err)
+ {
+ zfs_unmount (data);
+ return err;
+ }
+ ctx.data = data;
+
+ if (isfs)
+ {
+ grub_uint64_t childobj, headobj;
+ grub_uint64_t snapobj;
+ dnode_end_t dn;
+ struct grub_dirhook_info info;
+
+ err = fill_fs_info (&info, data->dnode, data);
+ if (err)
+ {
+ zfs_unmount (data);
+ return err;
+ }
+ if (hook ("@", &info, hook_data))
+ {
+ zfs_unmount (data);
+ return GRUB_ERR_NONE;
+ }
+
+ childobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&data->dnode.dn))->dd_child_dir_zapobj, data->dnode.endian);
+ headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&data->dnode.dn))->dd_head_dataset_obj, data->dnode.endian);
+ err = dnode_get (&(data->mos), childobj,
+ DMU_OT_DSL_DIR_CHILD_MAP, &dn, data);
+ if (err)
+ {
+ zfs_unmount (data);
+ return err;
+ }
+
+ zap_iterate_u64 (&dn, iterate_zap_fs, data, &ctx);
+
+ err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &dn, data);
+ if (err)
+ {
+ zfs_unmount (data);
+ return err;
+ }
+
+ snapobj = grub_zfs_to_cpu64 (((dsl_dataset_phys_t *) DN_BONUS (&dn.dn))->ds_snapnames_zapobj, dn.endian);
+
+ err = dnode_get (&(data->mos), snapobj,
+ DMU_OT_DSL_DS_SNAP_MAP, &dn, data);
+ if (err)
+ {
+ zfs_unmount (data);
+ return err;
+ }
+
+ zap_iterate_u64 (&dn, iterate_zap_snap, data, &ctx);
+ }
+ else
+ {
+ if (data->dnode.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS)
+ {
+ zfs_unmount (data);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+ }
+ zap_iterate_u64 (&(data->dnode), iterate_zap, data, &ctx);
+ }
+ zfs_unmount (data);
+ return grub_errno;
+}
+
+static int
+check_feature (const char *name, grub_uint64_t val,
+ struct grub_zfs_dir_ctx *ctx __attribute__((unused)))
+{
+ int i;
+ if (val == 0)
+ return 0;
+ if (name[0] == 0)
+ return 0;
+ for (i = 0; spa_feature_names[i] != NULL; i++)
+ if (grub_strcmp (name, spa_feature_names[i]) == 0)
+ return 0;
+ return 1;
+}
+
+/*
+ * Checks whether the MOS features that are active are supported by this
+ * (GRUB's) implementation of ZFS.
+ *
+ * Return:
+ * 0: Success.
+ * errnum: Failure.
+ */
+
+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_err_t errnum = 0;
+ dnode_end_t dn,mosmdn;
+ mzap_phys_t* mzp;
+ grub_zfs_endian_t endianzap;
+ int size;
+ grub_memmove(&(mosmdn.dn),mosmdn_phys,sizeof(dnode_phys_t));
+ mosmdn.endian=endian;
+ errnum = dnode_get(&mosmdn, DMU_POOL_DIRECTORY_OBJECT,
+ DMU_OT_OBJECT_DIRECTORY, &dn,data);
+ if (errnum != 0)
+ return errnum;
+
+ /*
+ * Find the object number for 'features_for_read' and retrieve its
+ * corresponding dnode. Note that we don't check features_for_write
+ * because GRUB is not opening the pool for write.
+ */
+ errnum = zap_lookup(&dn, DMU_POOL_FEATURES_FOR_READ, &objnum, data,0);
+ if (errnum != 0)
+ return errnum;
+
+ errnum = dnode_get(&mosmdn, objnum, DMU_OTN_ZAP_METADATA, &dn, data);
+ if (errnum != 0)
+ return errnum;
+
+ errnum = dmu_read(&dn, 0, (void**)&mzp, &endianzap,data);
+ if (errnum != 0)
+ return errnum;
+
+ size = grub_zfs_to_cpu16 (dn.dn.dn_datablkszsec, dn.endian) << SPA_MINBLOCKSHIFT;
+ return mzap_iterate (mzp,endianzap, size, check_feature,NULL);
+}
+
+
+#ifdef GRUB_UTIL
+static grub_err_t
+grub_zfs_embed (grub_device_t device __attribute__ ((unused)),
+ unsigned int *nsectors,
+ unsigned int max_nsectors,
+ grub_embed_type_t embed_type,
+ grub_disk_addr_t **sectors)
+{
+ unsigned i;
+
+ if (embed_type != GRUB_EMBED_PCBIOS)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "ZFS currently supports only PC-BIOS embedding");
+
+ if ((VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS) < *nsectors)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("your core.img is unusually large. "
+ "It won't fit in the embedding area"));
+
+ *nsectors = (VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS);
+ if (*nsectors > max_nsectors)
+ *nsectors = max_nsectors;
+ *sectors = grub_calloc (*nsectors, sizeof (**sectors));
+ if (!*sectors)
+ return grub_errno;
+ for (i = 0; i < *nsectors; i++)
+ (*sectors)[i] = i + (VDEV_BOOT_OFFSET >> GRUB_DISK_SECTOR_BITS);
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+static struct grub_fs grub_zfs_fs = {
+ .name = "zfs",
+ .fs_dir = grub_zfs_dir,
+ .fs_open = grub_zfs_open,
+ .fs_read = grub_zfs_read,
+ .fs_close = grub_zfs_close,
+ .fs_label = zfs_label,
+ .fs_uuid = zfs_uuid,
+ .fs_mtime = zfs_mtime,
+#ifdef GRUB_UTIL
+ .fs_embed = grub_zfs_embed,
+ .reserved_first_sector = 1,
+ .blocklist_install = 0,
+#endif
+ .next = 0
+};
+
+GRUB_MOD_INIT (zfs)
+{
+ COMPILE_TIME_ASSERT (sizeof (zap_leaf_chunk_t) == ZAP_LEAF_CHUNKSIZE);
+ grub_fs_register (&grub_zfs_fs);
+#ifndef GRUB_UTIL
+ my_mod = mod;
+#endif
+}
+
+GRUB_MOD_FINI (zfs)
+{
+ grub_fs_unregister (&grub_zfs_fs);
+}
diff --git a/grub-core/fs/zfs/zfs_fletcher.c b/grub-core/fs/zfs/zfs_fletcher.c
new file mode 100644
index 0000000..7d27b05
--- /dev/null
+++ b/grub-core/fs/zfs/zfs_fletcher.c
@@ -0,0 +1,84 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
+ * Copyright 2007 Sun Microsystems, Inc.
+ *
+ * GRUB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/zfs/zfs.h>
+#include <grub/zfs/zio.h>
+#include <grub/zfs/dnode.h>
+#include <grub/zfs/uberblock_impl.h>
+#include <grub/zfs/vdev_impl.h>
+#include <grub/zfs/zio_checksum.h>
+#include <grub/zfs/zap_impl.h>
+#include <grub/zfs/zap_leaf.h>
+#include <grub/zfs/zfs_znode.h>
+#include <grub/zfs/dmu.h>
+#include <grub/zfs/dmu_objset.h>
+#include <grub/zfs/dsl_dir.h>
+#include <grub/zfs/dsl_dataset.h>
+
+void
+fletcher_2(const void *buf, grub_uint64_t size, grub_zfs_endian_t endian,
+ zio_cksum_t *zcp)
+{
+ const grub_uint64_t *ip = buf;
+ const grub_uint64_t *ipend = ip + (size / sizeof (grub_uint64_t));
+ grub_uint64_t a0, b0, a1, b1;
+
+ for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2)
+ {
+ a0 += grub_zfs_to_cpu64 (ip[0], endian);
+ a1 += grub_zfs_to_cpu64 (ip[1], endian);
+ b0 += a0;
+ b1 += a1;
+ }
+
+ zcp->zc_word[0] = grub_cpu_to_zfs64 (a0, endian);
+ zcp->zc_word[1] = grub_cpu_to_zfs64 (a1, endian);
+ zcp->zc_word[2] = grub_cpu_to_zfs64 (b0, endian);
+ zcp->zc_word[3] = grub_cpu_to_zfs64 (b1, endian);
+}
+
+void
+fletcher_4 (const void *buf, grub_uint64_t size, grub_zfs_endian_t endian,
+ zio_cksum_t *zcp)
+{
+ const grub_uint32_t *ip = buf;
+ const grub_uint32_t *ipend = ip + (size / sizeof (grub_uint32_t));
+ grub_uint64_t a, b, c, d;
+
+ for (a = b = c = d = 0; ip < ipend; ip++)
+ {
+ a += grub_zfs_to_cpu32 (ip[0], endian);;
+ b += a;
+ c += b;
+ d += c;
+ }
+
+ zcp->zc_word[0] = grub_cpu_to_zfs64 (a, endian);
+ zcp->zc_word[1] = grub_cpu_to_zfs64 (b, endian);
+ zcp->zc_word[2] = grub_cpu_to_zfs64 (c, endian);
+ zcp->zc_word[3] = grub_cpu_to_zfs64 (d, endian);
+}
+
diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c
new file mode 100644
index 0000000..5453822
--- /dev/null
+++ b/grub-core/fs/zfs/zfs_lz4.c
@@ -0,0 +1,285 @@
+/*
+ * LZ4 - Fast LZ compression algorithm
+ * Header File
+ * Copyright (C) 2011-2013, Yann Collet.
+ * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You can contact the author at :
+ * - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
+ * - LZ4 source repository : http://code.google.com/p/lz4/
+ */
+
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+
+static int LZ4_uncompress_unknownOutputSize(const char *source, char *dest,
+ int isize, int maxOutputSize);
+
+/*
+ * CPU Feature Detection
+ */
+
+/* 32 or 64 bits ? */
+#if (GRUB_CPU_SIZEOF_VOID_P == 8)
+#define LZ4_ARCH64 1
+#else
+#define LZ4_ARCH64 0
+#endif
+
+/*
+ * Compiler Options
+ */
+
+
+#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+
+#if (GCC_VERSION >= 302) || (defined (__INTEL_COMPILER) && __INTEL_COMPILER >= 800) || defined(__clang__)
+#define expect(expr, value) (__builtin_expect((expr), (value)))
+#else
+#define expect(expr, value) (expr)
+#endif
+
+#define likely(expr) expect((expr) != 0, 1)
+#define unlikely(expr) expect((expr) != 0, 0)
+
+/* Basic types */
+#define BYTE grub_uint8_t
+#define U16 grub_uint16_t
+#define U32 grub_uint32_t
+#define S32 grub_int32_t
+#define U64 grub_uint64_t
+
+typedef struct _U16_S {
+ U16 v;
+} GRUB_PACKED U16_S;
+typedef struct _U32_S {
+ U32 v;
+} GRUB_PACKED U32_S;
+typedef struct _U64_S {
+ U64 v;
+} GRUB_PACKED U64_S;
+
+#define A64(x) (((U64_S *)(x))->v)
+#define A32(x) (((U32_S *)(x))->v)
+#define A16(x) (((U16_S *)(x))->v)
+
+/*
+ * Constants
+ */
+#define MINMATCH 4
+
+#define COPYLENGTH 8
+#define LASTLITERALS 5
+
+#define ML_BITS 4
+#define ML_MASK ((1U<<ML_BITS)-1)
+#define RUN_BITS (8-ML_BITS)
+#define RUN_MASK ((1U<<RUN_BITS)-1)
+
+/*
+ * Architecture-specific macros
+ */
+#if LZ4_ARCH64
+#define STEPSIZE 8
+#define UARCH U64
+#define AARCH A64
+#define LZ4_COPYSTEP(s, d) A64(d) = A64(s); d += 8; s += 8;
+#define LZ4_COPYPACKET(s, d) LZ4_COPYSTEP(s, d)
+#define LZ4_SECURECOPY(s, d, e) if (d < e) LZ4_WILDCOPY(s, d, e)
+#define HTYPE U32
+#define INITBASE(base) const BYTE* const base = ip
+#else
+#define STEPSIZE 4
+#define UARCH U32
+#define AARCH A32
+#define LZ4_COPYSTEP(s, d) A32(d) = A32(s); d += 4; s += 4;
+#define LZ4_COPYPACKET(s, d) LZ4_COPYSTEP(s, d); LZ4_COPYSTEP(s, d);
+#define LZ4_SECURECOPY LZ4_WILDCOPY
+#define HTYPE const BYTE*
+#define INITBASE(base) const int base = 0
+#endif
+
+#define LZ4_READ_LITTLEENDIAN_16(d, s, p) { d = (s) - grub_le_to_cpu16 (A16 (p)); }
+#define LZ4_WRITE_LITTLEENDIAN_16(p, v) { A16(p) = grub_cpu_to_le16 (v); p += 2; }
+
+/* Macros */
+#define LZ4_WILDCOPY(s, d, e) do { LZ4_COPYPACKET(s, d) } while (d < e);
+
+/* Decompression functions */
+grub_err_t
+lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len);
+
+grub_err_t
+lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len)
+{
+ const BYTE *src = s_start;
+ U32 bufsiz = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) |
+ src[3];
+
+ /* invalid compressed buffer size encoded at start */
+ if (bufsiz + 4 > s_len)
+ return grub_error(GRUB_ERR_BAD_FS,"lz4 decompression failed.");
+
+ /*
+ * Returns 0 on success (decompression function returned non-negative)
+ * and appropriate error on failure (decompression function returned negative).
+ */
+ return (LZ4_uncompress_unknownOutputSize((char*)s_start + 4, d_start, bufsiz,
+ d_len) < 0)?grub_error(GRUB_ERR_BAD_FS,"lz4 decompression failed."):0;
+}
+
+static int
+LZ4_uncompress_unknownOutputSize(const char *source,
+ char *dest, int isize, int maxOutputSize)
+{
+ /* Local Variables */
+ const BYTE * ip = (const BYTE *) source;
+ const BYTE *const iend = ip + isize;
+ const BYTE * ref;
+
+ BYTE * op = (BYTE *) dest;
+ BYTE *const oend = op + maxOutputSize;
+ BYTE *cpy;
+
+ grub_size_t dec[] = { 0, 3, 2, 3, 0, 0, 0, 0 };
+
+ /* Main Loop */
+ while (ip < iend) {
+ BYTE token;
+ int length;
+
+ /* get runlength */
+ token = *ip++;
+ if ((length = (token >> ML_BITS)) == RUN_MASK) {
+ int s = 255;
+ while ((ip < iend) && (s == 255)) {
+ s = *ip++;
+ length += s;
+ }
+ }
+ /* 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)) {
+ if (cpy > oend)
+ /*
+ * Error: request to write beyond destination
+ * buffer.
+ */
+ goto _output_error;
+ if (ip + length > iend)
+ /*
+ * Error : request to read beyond source
+ * buffer.
+ */
+ goto _output_error;
+ grub_memcpy(op, ip, length);
+ op += length;
+ ip += length;
+ if (ip < iend)
+ /* Error : LZ4 format violation */
+ goto _output_error;
+ /* Necessarily EOF, due to parsing restrictions. */
+ break;
+ }
+ LZ4_WILDCOPY(ip, op, cpy);
+ ip -= (op - cpy);
+ op = cpy;
+
+ /* get offset */
+ LZ4_READ_LITTLEENDIAN_16(ref, cpy, ip);
+ ip += 2;
+ if (ref < (BYTE * const) dest)
+ /*
+ * Error: offset creates reference outside of
+ * destination buffer.
+ */
+ goto _output_error;
+
+ /* get matchlength */
+ if ((length = (token & ML_MASK)) == ML_MASK) {
+ while (ip < iend) {
+ int s = *ip++;
+ length += s;
+ if (s == 255)
+ continue;
+ break;
+ }
+ }
+ /* copy repeated sequence */
+ if unlikely(op - ref < STEPSIZE) {
+#if LZ4_ARCH64
+ grub_size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
+ grub_size_t dec2 = dec2table[op - ref];
+#else
+ const int dec2 = 0;
+#endif
+ *op++ = *ref++;
+ *op++ = *ref++;
+ *op++ = *ref++;
+ *op++ = *ref++;
+ ref -= dec[op - ref];
+ A32(op) = A32(ref);
+ op += STEPSIZE - 4;
+ ref -= dec2;
+ } else {
+ LZ4_COPYSTEP(ref, op);
+ }
+ cpy = op + length - (STEPSIZE - 4);
+ if (cpy > oend - COPYLENGTH) {
+ if (cpy > oend)
+ /*
+ * Error: request to write outside of
+ * destination buffer.
+ */
+ goto _output_error;
+ LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
+ while (op < cpy)
+ *op++ = *ref++;
+ op = cpy;
+ if (op == oend)
+ /*
+ * Check EOF (should never happen, since last
+ * 5 bytes are supposed to be literals).
+ */
+ break;
+ continue;
+ }
+ LZ4_SECURECOPY(ref, op, cpy);
+ op = cpy; /* correction */
+ }
+
+ /* end of decoding */
+ return (int)(((char *)op) - dest);
+
+ /* write overflow error detected */
+ _output_error:
+ return (int)(-(((char *)ip) - source));
+}
diff --git a/grub-core/fs/zfs/zfs_lzjb.c b/grub-core/fs/zfs/zfs_lzjb.c
new file mode 100644
index 0000000..62b5ea6
--- /dev/null
+++ b/grub-core/fs/zfs/zfs_lzjb.c
@@ -0,0 +1,93 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
+ * Copyright 2007 Sun Microsystems, Inc.
+ *
+ * GRUB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/zfs/zfs.h>
+#include <grub/zfs/zio.h>
+#include <grub/zfs/dnode.h>
+#include <grub/zfs/uberblock_impl.h>
+#include <grub/zfs/vdev_impl.h>
+#include <grub/zfs/zio_checksum.h>
+#include <grub/zfs/zap_impl.h>
+#include <grub/zfs/zap_leaf.h>
+#include <grub/zfs/zfs_znode.h>
+#include <grub/zfs/dmu.h>
+#include <grub/zfs/dmu_objset.h>
+#include <grub/zfs/dsl_dir.h>
+#include <grub/zfs/dsl_dataset.h>
+
+#define MATCH_BITS 6
+#define MATCH_MIN 3
+#define OFFSET_MASK ((1 << (16 - MATCH_BITS)) - 1)
+
+/*
+ * Decompression Entry - lzjb
+ */
+#ifndef NBBY
+#define NBBY 8
+#endif
+
+grub_err_t
+lzjb_decompress (void *s_start, void *d_start, grub_size_t s_len,
+ grub_size_t d_len);
+
+grub_err_t
+lzjb_decompress (void *s_start, void *d_start, grub_size_t s_len,
+ grub_size_t d_len)
+{
+ grub_uint8_t *src = s_start;
+ grub_uint8_t *dst = d_start;
+ grub_uint8_t *d_end = (grub_uint8_t *) d_start + d_len;
+ grub_uint8_t *s_end = (grub_uint8_t *) s_start + s_len;
+ grub_uint8_t *cpy, copymap = 0;
+ int copymask = 1 << (NBBY - 1);
+
+ while (dst < d_end && src < s_end)
+ {
+ if ((copymask <<= 1) == (1 << NBBY))
+ {
+ copymask = 1;
+ copymap = *src++;
+ }
+ if (src >= s_end)
+ return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed");
+ if (copymap & copymask)
+ {
+ int mlen = (src[0] >> (NBBY - MATCH_BITS)) + MATCH_MIN;
+ int offset = ((src[0] << NBBY) | src[1]) & OFFSET_MASK;
+ src += 2;
+ cpy = dst - offset;
+ if (src > s_end || cpy < (grub_uint8_t *) d_start)
+ return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed");
+ while (--mlen >= 0 && dst < d_end)
+ *dst++ = *cpy++;
+ }
+ else
+ *dst++ = *src++;
+ }
+ if (dst < d_end)
+ return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed");
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/fs/zfs/zfs_sha256.c b/grub-core/fs/zfs/zfs_sha256.c
new file mode 100644
index 0000000..a181f07
--- /dev/null
+++ b/grub-core/fs/zfs/zfs_sha256.c
@@ -0,0 +1,143 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
+ * Copyright 2007 Sun Microsystems, Inc.
+ *
+ * GRUB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/zfs/zfs.h>
+#include <grub/zfs/zio.h>
+#include <grub/zfs/dnode.h>
+#include <grub/zfs/uberblock_impl.h>
+#include <grub/zfs/vdev_impl.h>
+#include <grub/zfs/zio_checksum.h>
+#include <grub/zfs/zap_impl.h>
+#include <grub/zfs/zap_leaf.h>
+#include <grub/zfs/zfs_znode.h>
+#include <grub/zfs/dmu.h>
+#include <grub/zfs/dmu_objset.h>
+#include <grub/zfs/dsl_dir.h>
+#include <grub/zfs/dsl_dataset.h>
+
+/*
+ * SHA-256 checksum, as specified in FIPS 180-2, available at:
+ * http://csrc.nist.gov/cryptval
+ *
+ * This is a very compact implementation of SHA-256.
+ * It is designed to be simple and portable, not to be fast.
+ */
+
+/*
+ * The literal definitions according to FIPS180-2 would be:
+ *
+ * Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z)))
+ * Maj(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
+ *
+ * We use logical equivalents which require one less op.
+ */
+#define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
+#define Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y))))
+#define Rot32(x, s) (((x) >> s) | ((x) << (32 - s)))
+#define SIGMA0(x) (Rot32(x, 2) ^ Rot32(x, 13) ^ Rot32(x, 22))
+#define SIGMA1(x) (Rot32(x, 6) ^ Rot32(x, 11) ^ Rot32(x, 25))
+#define sigma0(x) (Rot32(x, 7) ^ Rot32(x, 18) ^ ((x) >> 3))
+#define sigma1(x) (Rot32(x, 17) ^ Rot32(x, 19) ^ ((x) >> 10))
+
+static const grub_uint32_t SHA256_K[64] = {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+};
+
+static void
+SHA256Transform(grub_uint32_t *H, const grub_uint8_t *cp)
+{
+ grub_uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64];
+
+ for (t = 0; t < 16; t++, cp += 4)
+ W[t] = (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3];
+
+ for (t = 16; t < 64; t++)
+ W[t] = sigma1(W[t - 2]) + W[t - 7] +
+ sigma0(W[t - 15]) + W[t - 16];
+
+ a = H[0]; b = H[1]; c = H[2]; d = H[3];
+ e = H[4]; f = H[5]; g = H[6]; h = H[7];
+
+ for (t = 0; t < 64; t++) {
+ T1 = h + SIGMA1(e) + Ch(e, f, g) + SHA256_K[t] + W[t];
+ T2 = SIGMA0(a) + Maj(a, b, c);
+ h = g; g = f; f = e; e = d + T1;
+ d = c; c = b; b = a; a = T1 + T2;
+ }
+
+ H[0] += a; H[1] += b; H[2] += c; H[3] += d;
+ H[4] += e; H[5] += f; H[6] += g; H[7] += h;
+}
+
+void
+zio_checksum_SHA256(const void *buf, grub_uint64_t size,
+ grub_zfs_endian_t endian, zio_cksum_t *zcp)
+{
+ grub_uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
+ 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
+ grub_uint8_t pad[128];
+ unsigned padsize = size & 63;
+ unsigned i;
+
+ for (i = 0; i < size - padsize; i += 64)
+ SHA256Transform(H, (grub_uint8_t *)buf + i);
+
+ for (i = 0; i < padsize; i++)
+ pad[i] = ((grub_uint8_t *)buf)[i];
+
+ for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++)
+ pad[padsize] = 0;
+
+ for (i = 0; i < 8; i++)
+ pad[padsize++] = (size << 3) >> (56 - 8 * i);
+
+ for (i = 0; i < padsize && i <= 64; i += 64)
+ SHA256Transform(H, pad + i);
+
+ zcp->zc_word[0] = grub_cpu_to_zfs64 ((grub_uint64_t)H[0] << 32 | H[1],
+ endian);
+ zcp->zc_word[1] = grub_cpu_to_zfs64 ((grub_uint64_t)H[2] << 32 | H[3],
+ endian);
+ zcp->zc_word[2] = grub_cpu_to_zfs64 ((grub_uint64_t)H[4] << 32 | H[5],
+ endian);
+ zcp->zc_word[3] = grub_cpu_to_zfs64 ((grub_uint64_t)H[6] << 32 | H[7],
+ endian);
+}
diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c
new file mode 100644
index 0000000..de3b015
--- /dev/null
+++ b/grub-core/fs/zfs/zfscrypt.c
@@ -0,0 +1,491 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/err.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/safemath.h>
+#include <grub/dl.h>
+#include <grub/types.h>
+#include <grub/zfs/zfs.h>
+#include <grub/zfs/zio.h>
+#include <grub/zfs/dnode.h>
+#include <grub/zfs/uberblock_impl.h>
+#include <grub/zfs/vdev_impl.h>
+#include <grub/zfs/zio_checksum.h>
+#include <grub/zfs/zap_impl.h>
+#include <grub/zfs/zap_leaf.h>
+#include <grub/zfs/zfs_znode.h>
+#include <grub/zfs/dmu.h>
+#include <grub/zfs/dmu_objset.h>
+#include <grub/zfs/sa_impl.h>
+#include <grub/zfs/dsl_dir.h>
+#include <grub/zfs/dsl_dataset.h>
+#include <grub/crypto.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/*
+ Mostly based on following article:
+ https://blogs.oracle.com/darren/entry/zfs_encryption_what_is_on
+ */
+
+enum grub_zfs_algo
+ {
+ GRUB_ZFS_ALGO_CCM,
+ GRUB_ZFS_ALGO_GCM,
+ };
+
+struct grub_zfs_key
+{
+ grub_uint64_t algo;
+ grub_uint8_t enc_nonce[13];
+ grub_uint8_t unused[3];
+ grub_uint8_t enc_key[48];
+ grub_uint8_t unknown_purpose_nonce[13];
+ grub_uint8_t unused2[3];
+ grub_uint8_t unknown_purpose_key[48];
+};
+
+struct grub_zfs_wrap_key
+{
+ struct grub_zfs_wrap_key *next;
+ grub_size_t keylen;
+ int is_passphrase;
+ grub_uint64_t key[0];
+};
+
+static struct grub_zfs_wrap_key *zfs_wrap_keys;
+
+grub_err_t
+grub_zfs_add_key (grub_uint8_t *key_in,
+ grub_size_t keylen,
+ int passphrase)
+{
+ struct grub_zfs_wrap_key *key;
+ grub_size_t sz;
+
+ if (!passphrase && keylen > 32)
+ keylen = 32;
+ if (grub_add (sizeof (*key), keylen, &sz))
+ return GRUB_ERR_OUT_OF_RANGE;
+ key = grub_malloc (sz);
+ if (!key)
+ return grub_errno;
+ key->is_passphrase = passphrase;
+ key->keylen = keylen;
+ grub_memcpy (key->key, key_in, keylen);
+ key->next = zfs_wrap_keys;
+ zfs_wrap_keys = key;
+ return GRUB_ERR_NONE;
+}
+
+static gcry_err_code_t
+grub_ccm_decrypt (grub_crypto_cipher_handle_t cipher,
+ grub_uint8_t *out, const grub_uint8_t *in,
+ grub_size_t psize,
+ void *mac_out, const void *nonce,
+ unsigned l, unsigned m)
+{
+ grub_uint8_t iv[16];
+ grub_uint8_t mul[16];
+ grub_uint32_t mac[4];
+ unsigned i, j;
+ gcry_err_code_t err;
+
+ grub_memcpy (iv + 1, nonce, 15 - l);
+
+ iv[0] = (l - 1) | (((m-2) / 2) << 3);
+ for (j = 0; j < l; j++)
+ iv[15 - j] = psize >> (8 * j);
+ err = grub_crypto_ecb_encrypt (cipher, mac, iv, 16);
+ if (err)
+ return err;
+
+ iv[0] = l - 1;
+
+ for (i = 0; i < (psize + 15) / 16; i++)
+ {
+ grub_size_t csize;
+ csize = 16;
+ if (csize > psize - 16 * i)
+ csize = psize - 16 * i;
+ for (j = 0; j < l; j++)
+ iv[15 - j] = (i + 1) >> (8 * j);
+ err = grub_crypto_ecb_encrypt (cipher, mul, iv, 16);
+ if (err)
+ return err;
+ grub_crypto_xor (out + 16 * i, in + 16 * i, mul, csize);
+ grub_crypto_xor (mac, mac, out + 16 * i, csize);
+ err = grub_crypto_ecb_encrypt (cipher, mac, mac, 16);
+ if (err)
+ return err;
+ }
+ for (j = 0; j < l; j++)
+ iv[15 - j] = 0;
+ err = grub_crypto_ecb_encrypt (cipher, mul, iv, 16);
+ if (err)
+ return err;
+ if (mac_out)
+ grub_crypto_xor (mac_out, mac, mul, m);
+ return GPG_ERR_NO_ERROR;
+}
+
+static void
+grub_gcm_mul_x (grub_uint8_t *a)
+{
+ int i;
+ int c = 0, d = 0;
+ for (i = 0; i < 16; i++)
+ {
+ c = a[i] & 0x1;
+ a[i] = (a[i] >> 1) | (d << 7);
+ d = c;
+ }
+ if (d)
+ a[0] ^= 0xe1;
+}
+
+static void
+grub_gcm_mul (grub_uint8_t *a, const grub_uint8_t *b)
+{
+ grub_uint8_t res[16], bs[16];
+ int i;
+ grub_memcpy (bs, b, 16);
+ grub_memset (res, 0, 16);
+ for (i = 0; i < 128; i++)
+ {
+ if ((a[i / 8] << (i % 8)) & 0x80)
+ grub_crypto_xor (res, res, bs, 16);
+ grub_gcm_mul_x (bs);
+ }
+
+ grub_memcpy (a, res, 16);
+}
+
+static gcry_err_code_t
+grub_gcm_decrypt (grub_crypto_cipher_handle_t cipher,
+ grub_uint8_t *out, const grub_uint8_t *in,
+ grub_size_t psize,
+ void *mac_out, const void *nonce,
+ unsigned nonce_len, unsigned m)
+{
+ grub_uint8_t iv[16];
+ grub_uint8_t mul[16];
+ grub_uint8_t mac[16], h[16], mac_xor[16];
+ unsigned i, j;
+ gcry_err_code_t err;
+
+ grub_memset (mac, 0, sizeof (mac));
+
+ err = grub_crypto_ecb_encrypt (cipher, h, mac, 16);
+ if (err)
+ return err;
+
+ if (nonce_len == 12)
+ {
+ grub_memcpy (iv, nonce, 12);
+ iv[12] = 0;
+ iv[13] = 0;
+ iv[14] = 0;
+ iv[15] = 1;
+ }
+ else
+ {
+ grub_memset (iv, 0, sizeof (iv));
+ grub_memcpy (iv, nonce, nonce_len);
+ grub_gcm_mul (iv, h);
+ iv[15] ^= nonce_len * 8;
+ grub_gcm_mul (iv, h);
+ }
+
+ err = grub_crypto_ecb_encrypt (cipher, mac_xor, iv, 16);
+ if (err)
+ return err;
+
+ for (i = 0; i < (psize + 15) / 16; i++)
+ {
+ grub_size_t csize;
+ csize = 16;
+ if (csize > psize - 16 * i)
+ csize = psize - 16 * i;
+ for (j = 0; j < 4; j++)
+ {
+ iv[15 - j]++;
+ if (iv[15 - j] != 0)
+ break;
+ }
+ grub_crypto_xor (mac, mac, in + 16 * i, csize);
+ grub_gcm_mul (mac, h);
+ err = grub_crypto_ecb_encrypt (cipher, mul, iv, 16);
+ if (err)
+ return err;
+ grub_crypto_xor (out + 16 * i, in + 16 * i, mul, csize);
+ }
+ for (j = 0; j < 8; j++)
+ mac[15 - j] ^= ((((grub_uint64_t) psize) * 8) >> (8 * j));
+ grub_gcm_mul (mac, h);
+
+ if (mac_out)
+ grub_crypto_xor (mac_out, mac, mac_xor, m);
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+static gcry_err_code_t
+algo_decrypt (grub_crypto_cipher_handle_t cipher, grub_uint64_t algo,
+ grub_uint8_t *out, const grub_uint8_t *in,
+ grub_size_t psize,
+ void *mac_out, const void *nonce,
+ unsigned l, unsigned m)
+{
+ switch (algo)
+ {
+ case 0:
+ return grub_ccm_decrypt (cipher, out, in, psize,
+ mac_out, nonce, l, m);
+ case 1:
+ return grub_gcm_decrypt (cipher, out, in, psize,
+ mac_out, nonce,
+ 15 - l, m);
+ default:
+ return GPG_ERR_CIPHER_ALGO;
+ }
+}
+
+static grub_err_t
+grub_zfs_decrypt_real (grub_crypto_cipher_handle_t cipher,
+ grub_uint64_t algo,
+ void *nonce,
+ char *buf, grub_size_t size,
+ const grub_uint32_t *expected_mac,
+ grub_zfs_endian_t endian)
+{
+ grub_uint32_t mac[4];
+ unsigned i;
+ grub_uint32_t sw[4];
+ gcry_err_code_t err;
+
+ grub_memcpy (sw, nonce, 16);
+ if (endian != GRUB_ZFS_BIG_ENDIAN)
+ for (i = 0; i < 4; i++)
+ sw[i] = grub_swap_bytes32 (sw[i]);
+
+ if (!cipher)
+ return grub_error (GRUB_ERR_ACCESS_DENIED,
+ N_("no decryption key available"));
+ err = algo_decrypt (cipher, algo,
+ (grub_uint8_t *) buf,
+ (grub_uint8_t *) buf,
+ size, mac,
+ sw + 1, 3, 12);
+ if (err)
+ return grub_crypto_gcry_error (err);
+
+ for (i = 0; i < 3; i++)
+ if (grub_zfs_to_cpu32 (expected_mac[i], endian)
+ != grub_be_to_cpu32 (mac[i]))
+ return grub_error (GRUB_ERR_BAD_FS, N_("MAC verification failed"));
+ return GRUB_ERR_NONE;
+}
+
+static grub_crypto_cipher_handle_t
+grub_zfs_load_key_real (const struct grub_zfs_key *key,
+ grub_size_t keysize,
+ grub_uint64_t salt,
+ grub_uint64_t algo)
+{
+ unsigned keylen;
+ struct grub_zfs_wrap_key *wrap_key;
+ grub_crypto_cipher_handle_t ret = NULL;
+
+ if (keysize != sizeof (*key))
+ {
+ grub_dprintf ("zfs", "Unexpected key size %" PRIuGRUB_SIZE "\n", keysize);
+ return 0;
+ }
+
+ if (grub_memcmp (key->enc_key + 32, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16)
+ == 0)
+ keylen = 16;
+ else if (grub_memcmp (key->enc_key + 40, "\0\0\0\0\0\0\0\0", 8) == 0)
+ keylen = 24;
+ else
+ keylen = 32;
+
+ for (wrap_key = zfs_wrap_keys; wrap_key; wrap_key = wrap_key->next)
+ {
+ grub_crypto_cipher_handle_t cipher;
+ grub_uint8_t decrypted[32], mac[32], wrap_key_real[32];
+ gcry_err_code_t err;
+ cipher = grub_crypto_cipher_open (GRUB_CIPHER_AES);
+ if (!cipher)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+ grub_memset (wrap_key_real, 0, sizeof (wrap_key_real));
+ err = 0;
+ if (!wrap_key->is_passphrase)
+ grub_memcpy(wrap_key_real, wrap_key->key,
+ wrap_key->keylen < keylen ? wrap_key->keylen : keylen);
+ else
+ err = grub_crypto_pbkdf2 (GRUB_MD_SHA1,
+ (const grub_uint8_t *) wrap_key->key,
+ wrap_key->keylen,
+ (const grub_uint8_t *) &salt, sizeof (salt),
+ 1000, wrap_key_real, keylen);
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_crypto_cipher_close (cipher);
+ continue;
+ }
+
+ err = grub_crypto_cipher_set_key (cipher, wrap_key_real,
+ keylen);
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_crypto_cipher_close (cipher);
+ continue;
+ }
+
+ err = algo_decrypt (cipher, algo, decrypted, key->unknown_purpose_key, 32,
+ mac, key->unknown_purpose_nonce, 2, 16);
+ if (err || (grub_crypto_memcmp (mac, key->unknown_purpose_key + 32, 16)
+ != 0))
+ {
+ grub_dprintf ("zfs", "key loading failed\n");
+ grub_errno = GRUB_ERR_NONE;
+ grub_crypto_cipher_close (cipher);
+ continue;
+ }
+
+ err = algo_decrypt (cipher, algo, decrypted, key->enc_key, keylen, mac,
+ key->enc_nonce, 2, 16);
+ if (err || grub_crypto_memcmp (mac, key->enc_key + keylen, 16) != 0)
+ {
+ 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);
+ grub_crypto_cipher_close (cipher);
+ continue;
+ }
+ grub_crypto_cipher_close (cipher);
+ return ret;
+ }
+ return NULL;
+}
+
+static const struct grub_arg_option options[] =
+ {
+ {"raw", 'r', 0, N_("Assume input is raw."), 0, 0},
+ {"hex", 'h', 0, N_("Assume input is hex."), 0, 0},
+ {"passphrase", 'p', 0, N_("Assume input is passphrase."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+grub_cmd_zfs_key (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ grub_uint8_t buf[1024];
+ grub_ssize_t real_size;
+
+ if (argc > 0)
+ {
+ grub_file_t file;
+ file = grub_file_open (args[0], GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY);
+ if (!file)
+ return grub_errno;
+ real_size = grub_file_read (file, buf, 1024);
+ if (real_size < 0)
+ return grub_errno;
+ }
+ else
+ {
+ grub_xputs (_("Enter ZFS password: "));
+ if (!grub_password_get ((char *) buf, 1023))
+ return grub_errno;
+ real_size = grub_strlen ((char *) buf);
+ }
+
+ if (ctxt->state[1].set)
+ {
+ int i;
+ grub_err_t err;
+ for (i = 0; i < real_size / 2; i++)
+ {
+ char c1 = grub_tolower (buf[2 * i]) - '0';
+ char c2 = grub_tolower (buf[2 * i + 1]) - '0';
+ if (c1 > 9)
+ c1 += '0' - 'a' + 10;
+ if (c2 > 9)
+ c2 += '0' - 'a' + 10;
+ buf[i] = (c1 << 4) | c2;
+ }
+ err = grub_zfs_add_key (buf, real_size / 2, 0);
+ if (err)
+ return err;
+ return GRUB_ERR_NONE;
+ }
+
+ return grub_zfs_add_key (buf, real_size,
+ ctxt->state[2].set
+ || (argc == 0 && !ctxt->state[0].set
+ && !ctxt->state[1].set));
+}
+
+static grub_extcmd_t cmd_key;
+
+GRUB_MOD_INIT(zfscrypt)
+{
+ grub_zfs_decrypt = grub_zfs_decrypt_real;
+ grub_zfs_load_key = grub_zfs_load_key_real;
+ cmd_key = grub_register_extcmd ("zfskey", grub_cmd_zfs_key, 0,
+ N_("[-h|-p|-r] [FILE]"),
+ N_("Import ZFS wrapping key stored in FILE."),
+ options);
+}
+
+GRUB_MOD_FINI(zfscrypt)
+{
+ grub_zfs_decrypt = 0;
+ grub_zfs_load_key = 0;
+ grub_unregister_extcmd (cmd_key);
+}
diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c
new file mode 100644
index 0000000..bf29180
--- /dev/null
+++ b/grub-core/fs/zfs/zfsinfo.c
@@ -0,0 +1,441 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
+ * Copyright 2008 Sun Microsystems, Inc.
+ *
+ * GRUB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/zfs/zfs.h>
+#include <grub/device.h>
+#include <grub/file.h>
+#include <grub/command.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/env.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static inline void
+print_tabs (int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ grub_printf (" ");
+}
+
+static grub_err_t
+print_state (char *nvlist, int tab)
+{
+ grub_uint64_t ival;
+ int isok = 1;
+
+ print_tabs (tab);
+
+ if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_REMOVED, &ival))
+ {
+ grub_puts_ (N_("Virtual device is removed"));
+ isok = 0;
+ }
+
+ if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival))
+ {
+ grub_puts_ (N_("Virtual device is faulted"));
+ isok = 0;
+ }
+
+ if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_OFFLINE, &ival))
+ {
+ grub_puts_ (N_("Virtual device is offline"));
+ isok = 0;
+ }
+
+ if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival))
+ /* TRANSLATORS: degraded doesn't mean broken but that some of
+ component are missing but virtual device as whole is still usable. */
+ grub_puts_ (N_("Virtual device is degraded"));
+
+ if (isok)
+ grub_puts_ (N_("Virtual device is online"));
+ grub_xputs ("\n");
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+print_vdev_info (char *nvlist, int tab)
+{
+ char *type = 0;
+
+ type = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_TYPE);
+
+ if (!type)
+ {
+ print_tabs (tab);
+ grub_puts_ (N_("Incorrect virtual device: no type available"));
+ return grub_errno;
+ }
+
+ if (grub_strcmp (type, VDEV_TYPE_DISK) == 0)
+ {
+ char *bootpath = 0;
+ char *path = 0;
+ char *devid = 0;
+
+ print_tabs (tab);
+ /* TRANSLATORS: The virtual devices form a tree (in graph-theoretical
+ sense). The nodes like mirror or raidz have children: member devices.
+ The "real" devices which actually store data are called "leafs"
+ (again borrowed from graph theory) and can be either disks
+ (or partitions) or files. */
+ grub_puts_ (N_("Leaf virtual device (file or disk)"));
+
+ print_state (nvlist, tab);
+
+ bootpath =
+ grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_PHYS_PATH);
+ print_tabs (tab);
+ if (!bootpath)
+ grub_puts_ (N_("Bootpath: unavailable\n"));
+ else
+ grub_printf_ (N_("Bootpath: %s\n"), bootpath);
+
+ path = grub_zfs_nvlist_lookup_string (nvlist, "path");
+ print_tabs (tab);
+ if (!path)
+ grub_puts_ (N_("Path: unavailable"));
+ else
+ grub_printf_ (N_("Path: %s\n"), path);
+
+ devid = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_DEVID);
+ print_tabs (tab);
+ if (!devid)
+ grub_puts_ (N_("Devid: unavailable"));
+ else
+ grub_printf_ (N_("Devid: %s\n"), devid);
+ 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)
+ {
+ int nelm, i;
+
+ nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm
+ (nvlist, ZPOOL_CONFIG_CHILDREN);
+
+ if(is_mirror){
+ grub_puts_ (N_("This VDEV is a mirror"));
+ }
+ else if(is_raidz){
+ grub_uint64_t parity;
+ grub_zfs_nvlist_lookup_uint64(nvlist,"nparity",&parity);
+ grub_printf_ (N_("This VDEV is a RAIDZ%llu\n"),(unsigned long long)parity);
+ }
+ print_tabs (tab);
+ if (nelm <= 0)
+ {
+ grub_puts_ (N_("Incorrect VDEV"));
+ return GRUB_ERR_NONE;
+ }
+ grub_printf_ (N_("VDEV with %d children\n"), nelm);
+ print_state (nvlist, tab);
+ for (i = 0; i < nelm; i++)
+ {
+ char *child;
+
+ child = grub_zfs_nvlist_lookup_nvlist_array
+ (nvlist, ZPOOL_CONFIG_CHILDREN, i);
+
+ print_tabs (tab);
+ if (!child)
+ {
+ /* TRANSLATORS: it's the element carying the number %d, not
+ total element number. And the number itself is fine,
+ only the element isn't.
+ */
+ grub_printf_ (N_("VDEV element number %d isn't correct\n"), i);
+ continue;
+ }
+
+ /* TRANSLATORS: it's the element carying the number %d, not
+ total element number. This is used in enumeration
+ "Element number 1", "Element number 2", ... */
+ grub_printf_ (N_("VDEV element number %d:\n"), i);
+ print_vdev_info (child, tab + 1);
+
+ grub_free (child);
+ }
+ return GRUB_ERR_NONE;
+ }
+
+ print_tabs (tab);
+ grub_printf_ (N_("Unknown virtual device type: %s\n"), type);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+get_bootpath (char *nvlist, char **bootpath, char **devid)
+{
+ char *type = 0;
+
+ type = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_TYPE);
+
+ if (!type)
+ return grub_errno;
+
+ if (grub_strcmp (type, VDEV_TYPE_DISK) == 0)
+ {
+ *bootpath = grub_zfs_nvlist_lookup_string (nvlist,
+ ZPOOL_CONFIG_PHYS_PATH);
+ *devid = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_DEVID);
+ if (!*bootpath || !*devid)
+ {
+ grub_free (*bootpath);
+ grub_free (*devid);
+ *bootpath = 0;
+ *devid = 0;
+ }
+ return GRUB_ERR_NONE;
+ }
+
+ if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0)
+ {
+ int nelm, i;
+
+ nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm
+ (nvlist, ZPOOL_CONFIG_CHILDREN);
+
+ for (i = 0; i < nelm; i++)
+ {
+ char *child;
+
+ child = grub_zfs_nvlist_lookup_nvlist_array (nvlist,
+ ZPOOL_CONFIG_CHILDREN,
+ i);
+
+ get_bootpath (child, bootpath, devid);
+
+ grub_free (child);
+
+ if (*bootpath && *devid)
+ return GRUB_ERR_NONE;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static const char *poolstates[] = {
+ /* TRANSLATORS: Here we speak about ZFS pools it's semi-marketing,
+ semi-technical term by Sun/Oracle and should be translated in sync with
+ other ZFS-related software and documentation. */
+ [POOL_STATE_ACTIVE] = N_("Pool state: active"),
+ [POOL_STATE_EXPORTED] = N_("Pool state: exported"),
+ [POOL_STATE_DESTROYED] = N_("Pool state: destroyed"),
+ [POOL_STATE_SPARE] = N_("Pool state: reserved for hot spare"),
+ [POOL_STATE_L2CACHE] = N_("Pool state: level 2 ARC device"),
+ [POOL_STATE_UNINITIALIZED] = N_("Pool state: uninitialized"),
+ [POOL_STATE_UNAVAIL] = N_("Pool state: unavailable"),
+ [POOL_STATE_POTENTIALLY_ACTIVE] = N_("Pool state: potentially active")
+};
+
+static grub_err_t
+grub_cmd_zfsinfo (grub_command_t cmd __attribute__ ((unused)), int argc,
+ char **args)
+{
+ grub_device_t dev;
+ char *devname;
+ grub_err_t err;
+ char *nvlist = 0;
+ char *nv = 0;
+ char *poolname;
+ grub_uint64_t guid;
+ grub_uint64_t pool_state;
+ int found;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ if (args[0][0] == '(' && args[0][grub_strlen (args[0]) - 1] == ')')
+ {
+ devname = grub_strdup (args[0] + 1);
+ if (devname)
+ devname[grub_strlen (devname) - 1] = 0;
+ }
+ else
+ devname = grub_strdup (args[0]);
+ if (!devname)
+ return grub_errno;
+
+ dev = grub_device_open (devname);
+ grub_free (devname);
+ if (!dev)
+ return grub_errno;
+
+ err = grub_zfs_fetch_nvlist (dev, &nvlist);
+
+ grub_device_close (dev);
+
+ if (err)
+ return err;
+
+ poolname = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME);
+ if (!poolname)
+ grub_puts_ (N_("Pool name: unavailable"));
+ else
+ grub_printf_ (N_("Pool name: %s\n"), poolname);
+
+ found =
+ grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_GUID, &guid);
+ if (!found)
+ grub_puts_ (N_("Pool GUID: unavailable"));
+ else
+ grub_printf_ (N_("Pool GUID: %016llx\n"), (long long unsigned) guid);
+
+ found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_STATE,
+ &pool_state);
+ if (!found)
+ grub_puts_ (N_("Unable to retrieve pool state"));
+ else if (pool_state >= ARRAY_SIZE (poolstates))
+ grub_puts_ (N_("Unrecognized pool state"));
+ else
+ grub_puts_ (poolstates[pool_state]);
+
+ nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE);
+
+ if (!nv)
+ /* TRANSLATORS: There are undetermined number of virtual devices
+ in a device tree, not just one.
+ */
+ grub_puts_ (N_("No virtual device tree available"));
+ else
+ print_vdev_info (nv, 1);
+
+ grub_free (nv);
+ grub_free (nvlist);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc,
+ char **args)
+{
+ grub_device_t dev;
+ char *devname;
+ grub_err_t err;
+ char *nvlist = 0;
+ char *nv = 0;
+ char *bootpath = 0, *devid = 0;
+ char *fsname;
+ char *bootfs;
+ char *poolname;
+ grub_uint64_t mdnobj;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ devname = grub_file_get_device_name (args[0]);
+ if (devname == NULL)
+ return GRUB_ERR_OUT_OF_MEMORY;
+
+ dev = grub_device_open (devname);
+ grub_free (devname);
+ if (!dev)
+ return grub_errno;
+
+ err = grub_zfs_fetch_nvlist (dev, &nvlist);
+
+ fsname = grub_strchr (args[0], ')');
+ if (fsname)
+ fsname++;
+ else
+ fsname = args[0];
+
+ if (!err)
+ err = grub_zfs_getmdnobj (dev, fsname, &mdnobj);
+
+ grub_device_close (dev);
+
+ if (err)
+ return err;
+
+ poolname = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME);
+ if (!poolname)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_FS, "No poolname found");
+ return grub_errno;
+ }
+
+ nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE);
+
+ if (nv)
+ get_bootpath (nv, &bootpath, &devid);
+
+ grub_free (nv);
+ grub_free (nvlist);
+
+ bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu%s%s%s%s%s%s",
+ poolname, (unsigned long long) mdnobj,
+ bootpath ? ",bootpath=\"" : "",
+ bootpath ? : "",
+ bootpath ? "\"" : "",
+ devid ? ",diskdevid=\"" : "",
+ devid ? : "",
+ devid ? "\"" : "");
+ if (!bootfs)
+ return grub_errno;
+ if (argc >= 2)
+ grub_env_set (args[1], bootfs);
+ else
+ grub_printf ("%s\n", bootfs);
+
+ grub_free (bootfs);
+ grub_free (poolname);
+ grub_free (bootpath);
+ grub_free (devid);
+
+ return GRUB_ERR_NONE;
+}
+
+
+static grub_command_t cmd_info, cmd_bootfs;
+
+GRUB_MOD_INIT (zfsinfo)
+{
+ cmd_info = grub_register_command ("zfsinfo", grub_cmd_zfsinfo,
+ N_("DEVICE"),
+ N_("Print ZFS info about DEVICE."));
+ cmd_bootfs = grub_register_command ("zfs-bootfs", grub_cmd_zfs_bootfs,
+ N_("FILESYSTEM [VARIABLE]"),
+ N_("Print ZFS-BOOTFSOBJ or store it into VARIABLE"));
+}
+
+GRUB_MOD_FINI (zfsinfo)
+{
+ grub_unregister_command (cmd_info);
+ grub_unregister_command (cmd_bootfs);
+}
diff --git a/grub-core/gdb/cstub.c b/grub-core/gdb/cstub.c
new file mode 100644
index 0000000..b64acd7
--- /dev/null
+++ b/grub-core/gdb/cstub.c
@@ -0,0 +1,366 @@
+/* cstub.c - machine independent portion of remote GDB stub */
+/*
+ * Copyright (C) 2006 Lubomir Kundrak
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/misc.h>
+#include <grub/cpu/gdb.h>
+#include <grub/gdb.h>
+#include <grub/serial.h>
+#include <grub/backtrace.h>
+
+static const char hexchars[] = "0123456789abcdef";
+int grub_gdb_regs[GRUB_MACHINE_NR_REGS];
+
+#define GRUB_GDB_COMBUF_SIZE 400 /* At least sizeof(grub_gdb_regs)*2 are needed for
+ register packets. */
+static char grub_gdb_inbuf[GRUB_GDB_COMBUF_SIZE + 1];
+static char grub_gdb_outbuf[GRUB_GDB_COMBUF_SIZE + 1];
+
+struct grub_serial_port *grub_gdb_port;
+
+static int
+hex (char ch)
+{
+ if ((ch >= 'a') && (ch <= 'f'))
+ return (ch - 'a' + 10);
+ if ((ch >= '0') && (ch <= '9'))
+ return (ch - '0');
+ if ((ch >= 'A') && (ch <= 'F'))
+ return (ch - 'A' + 10);
+ return (-1);
+}
+
+/* Scan for the sequence $<data>#<checksum>. */
+static char *
+grub_gdb_getpacket (void)
+{
+ char *buffer = &grub_gdb_inbuf[0];
+ unsigned char checksum;
+ unsigned char xmitcsum;
+ int count;
+ int ch;
+
+ while (1)
+ {
+ /* Wait around for the start character, ignore all other
+ characters. */
+ while ((ch = grub_serial_port_fetch (grub_gdb_port)) != '$');
+
+ retry:
+ checksum = 0;
+ xmitcsum = -1;
+ count = 0;
+
+ /* Now read until a # or end of buffer is found. */
+ while (count < GRUB_GDB_COMBUF_SIZE)
+ {
+ do
+ ch = grub_serial_port_fetch (grub_gdb_port);
+ while (ch < 0);
+ if (ch == '$')
+ goto retry;
+ if (ch == '#')
+ break;
+ checksum += ch;
+ buffer[count] = ch;
+ count = count + 1;
+ }
+ buffer[count] = 0;
+ if (ch == '#')
+ {
+ do
+ ch = grub_serial_port_fetch (grub_gdb_port);
+ while (ch < 0);
+ xmitcsum = hex (ch) << 4;
+ do
+ ch = grub_serial_port_fetch (grub_gdb_port);
+ while (ch < 0);
+ xmitcsum += hex (ch);
+
+ if (checksum != xmitcsum)
+ grub_serial_port_put (grub_gdb_port, '-'); /* Failed checksum. */
+ else
+ {
+ grub_serial_port_put (grub_gdb_port, '+'); /* Successful transfer. */
+
+ /* If a sequence char is present, reply the sequence ID. */
+ if (buffer[2] == ':')
+ {
+ grub_serial_port_put (grub_gdb_port, buffer[0]);
+ grub_serial_port_put (grub_gdb_port, buffer[1]);
+
+ return &buffer[3];
+ }
+ return &buffer[0];
+ }
+ }
+ }
+}
+
+/* Send the packet in buffer. */
+static void
+grub_gdb_putpacket (char *buffer)
+{
+ grub_uint8_t checksum;
+
+ /* $<packet info>#<checksum>. */
+ do
+ {
+ char *ptr;
+ grub_serial_port_put (grub_gdb_port, '$');
+ checksum = 0;
+
+ for (ptr = buffer; *ptr; ptr++)
+ {
+ grub_serial_port_put (grub_gdb_port, *ptr);
+ checksum += *ptr;
+ }
+
+ grub_serial_port_put (grub_gdb_port, '#');
+ grub_serial_port_put (grub_gdb_port, hexchars[checksum >> 4]);
+ grub_serial_port_put (grub_gdb_port, hexchars[checksum & 0xf]);
+ }
+ while (grub_serial_port_fetch (grub_gdb_port) != '+');
+}
+
+/* Convert the memory pointed to by mem into hex, placing result in buf.
+ Return a pointer to the last char put in buf (NULL). */
+static char *
+grub_gdb_mem2hex (char *mem, char *buf, grub_size_t count)
+{
+ grub_size_t i;
+ unsigned char ch;
+
+ for (i = 0; i < count; i++)
+ {
+ ch = *mem++;
+ *buf++ = hexchars[ch >> 4];
+ *buf++ = hexchars[ch % 16];
+ }
+ *buf = 0;
+ return (buf);
+}
+
+/* Convert the hex array pointed to by buf into binary to be placed in mem.
+ Return a pointer to the character after the last byte written. */
+static char *
+grub_gdb_hex2mem (char *buf, char *mem, int count)
+{
+ int i;
+ unsigned char ch;
+
+ for (i = 0; i < count; i++)
+ {
+ ch = hex (*buf++) << 4;
+ ch = ch + hex (*buf++);
+ *mem++ = ch;
+ }
+ return (mem);
+}
+
+/* Convert hex characters to int and return the number of characters
+ processed. */
+static int
+grub_gdb_hex2int (char **ptr, grub_uint64_t *int_value)
+{
+ int num_chars = 0;
+ int hex_value;
+
+ *int_value = 0;
+
+ while (**ptr)
+ {
+ hex_value = hex (**ptr);
+ if (hex_value >= 0)
+ {
+ *int_value = (*int_value << 4) | hex_value;
+ num_chars++;
+ }
+ else
+ break;
+
+ (*ptr)++;
+ }
+
+ return (num_chars);
+}
+
+/* This function does all command procesing for interfacing to gdb. */
+void __attribute__ ((regparm(3)))
+grub_gdb_trap (int trap_no)
+{
+ unsigned int sig_no;
+ int stepping;
+ grub_uint64_t addr;
+ grub_uint64_t length;
+ char *ptr;
+
+ if (!grub_gdb_port)
+ {
+ grub_printf ("Unhandled exception 0x%x at ", trap_no);
+ grub_backtrace_print_address ((void *) grub_gdb_regs[PC]);
+ grub_printf ("\n");
+ grub_backtrace_pointer ((void *) grub_gdb_regs[EBP]);
+ grub_fatal ("Unhandled exception");
+ }
+
+ sig_no = grub_gdb_trap2sig (trap_no);
+
+ ptr = grub_gdb_outbuf;
+
+ /* Reply to host that an exception has occurred. */
+
+ *ptr++ = 'T'; /* Notify gdb with signo, PC, FP and SP. */
+
+ *ptr++ = hexchars[sig_no >> 4];
+ *ptr++ = hexchars[sig_no & 0xf];
+
+ /* Stack pointer. */
+ *ptr++ = hexchars[SP];
+ *ptr++ = ':';
+ ptr = grub_gdb_mem2hex ((char *) &grub_gdb_regs[ESP], ptr, 4);
+ *ptr++ = ';';
+
+ /* Frame pointer. */
+ *ptr++ = hexchars[FP];
+ *ptr++ = ':';
+ ptr = grub_gdb_mem2hex ((char *) &grub_gdb_regs[EBP], ptr, 4);
+ *ptr++ = ';';
+
+ /* Program counter. */
+ *ptr++ = hexchars[PC];
+ *ptr++ = ':';
+ ptr = grub_gdb_mem2hex ((char *) &grub_gdb_regs[PC], ptr, 4);
+ *ptr++ = ';';
+
+ *ptr = '\0';
+
+ grub_gdb_putpacket (grub_gdb_outbuf);
+
+ stepping = 0;
+
+ while (1)
+ {
+ grub_gdb_outbuf[0] = 0;
+ ptr = grub_gdb_getpacket ();
+
+ switch (*ptr++)
+ {
+ case '?':
+ grub_gdb_outbuf[0] = 'S';
+ grub_gdb_outbuf[1] = hexchars[sig_no >> 4];
+ grub_gdb_outbuf[2] = hexchars[sig_no & 0xf];
+ grub_gdb_outbuf[3] = 0;
+ break;
+
+ /* Return values of the CPU registers. */
+ case 'g':
+ grub_gdb_mem2hex ((char *) grub_gdb_regs, grub_gdb_outbuf,
+ sizeof (grub_gdb_regs));
+ break;
+
+ /* Set values of the CPU registers -- return OK. */
+ case 'G':
+ grub_gdb_hex2mem (ptr, (char *) grub_gdb_regs,
+ sizeof (grub_gdb_regs));
+ grub_strcpy (grub_gdb_outbuf, "OK");
+ break;
+
+ /* Set the value of a single CPU register -- return OK. */
+ case 'P':
+ {
+ grub_uint64_t regno;
+
+ if (grub_gdb_hex2int (&ptr, &regno) && *ptr++ == '=')
+ if (regno < GRUB_MACHINE_NR_REGS)
+ {
+ grub_gdb_hex2mem (ptr, (char *) &grub_gdb_regs[regno], 4);
+ grub_strcpy (grub_gdb_outbuf, "OK");
+ break;
+ }
+ /* FIXME: GDB requires setting orig_eax. I don't know what's
+ this register is about. For now just simulate setting any
+ registers. */
+ grub_strcpy (grub_gdb_outbuf, /*"E01"*/ "OK");
+ break;
+ }
+
+ /* mAA..AA,LLLL: Read LLLL bytes at address AA..AA. */
+ case 'm':
+ /* Try to read %x,%x. Set ptr = 0 if successful. */
+ if (grub_gdb_hex2int (&ptr, &addr))
+ if (*(ptr++) == ',')
+ if (grub_gdb_hex2int (&ptr, &length))
+ {
+ ptr = 0;
+ grub_gdb_mem2hex ((char *) (grub_addr_t) addr,
+ grub_gdb_outbuf, length);
+ }
+ if (ptr)
+ grub_strcpy (grub_gdb_outbuf, "E01");
+ break;
+
+ /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA -- return OK. */
+ case 'M':
+ /* Try to read %x,%x. Set ptr = 0 if successful. */
+ if (grub_gdb_hex2int (&ptr, &addr))
+ if (*(ptr++) == ',')
+ if (grub_gdb_hex2int (&ptr, &length))
+ if (*(ptr++) == ':')
+ {
+ grub_gdb_hex2mem (ptr, (char *) (grub_addr_t) addr, length);
+ grub_strcpy (grub_gdb_outbuf, "OK");
+ ptr = 0;
+ }
+ if (ptr)
+ {
+ grub_strcpy (grub_gdb_outbuf, "E02");
+ }
+ break;
+
+ /* sAA..AA: Step one instruction from AA..AA(optional). */
+ case 's':
+ stepping = 1;
+ /* FALLTHROUGH */
+
+ /* cAA..AA: Continue at address AA..AA(optional). */
+ case 'c':
+ /* try to read optional parameter, pc unchanged if no parm */
+ if (grub_gdb_hex2int (&ptr, &addr))
+ grub_gdb_regs[PC] = addr;
+
+ /* Clear the trace bit. */
+ grub_gdb_regs[PS] &= 0xfffffeff;
+
+ /* Set the trace bit if we're stepping. */
+ if (stepping)
+ grub_gdb_regs[PS] |= 0x100;
+
+ return;
+
+ /* Kill the program. */
+ case 'k':
+ /* Do nothing. */
+ return;
+ }
+
+ /* Reply to the request. */
+ grub_gdb_putpacket (grub_gdb_outbuf);
+ }
+}
+
diff --git a/grub-core/gdb/gdb.c b/grub-core/gdb/gdb.c
new file mode 100644
index 0000000..1818cb6
--- /dev/null
+++ b/grub-core/gdb/gdb.c
@@ -0,0 +1,104 @@
+/* gdb.c - gdb remote stub module */
+/*
+ * Copyright (C) 2003 Free Software Foundation, Inc.
+ * Copyright (C) 2006 Lubomir Kundrak
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/normal.h>
+#include <grub/term.h>
+#include <grub/cpu/gdb.h>
+#include <grub/gdb.h>
+#include <grub/serial.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_gdbstub (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_serial_port *port;
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "port required");
+ port = grub_serial_find (args[0]);
+ if (!port)
+ return grub_errno;
+ grub_gdb_port = port;
+ /* TRANSLATORS: at this position GRUB waits for the user to do an action
+ in remote debugger, namely to tell it to establish connection. */
+ grub_puts_ (N_("Now connect the remote debugger, please."));
+ grub_gdb_breakpoint ();
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_gdbstop (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_gdb_port = NULL;
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_gdb_break (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ if (!grub_gdb_port)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "No GDB stub is running");
+ grub_gdb_breakpoint ();
+ return 0;
+}
+
+static grub_command_t cmd, cmd_stop, cmd_break;
+
+GRUB_MOD_INIT (gdb)
+{
+ grub_gdb_idtinit ();
+ cmd = grub_register_command_lockdown ("gdbstub", grub_cmd_gdbstub,
+ N_("PORT"),
+ /*
+ * TRANSLATORS: GDB stub is a small part of
+ * GDB functionality running on local host
+ * which allows remote debugger to
+ * connect to it.
+ */
+ N_("Start GDB stub on given port"));
+ cmd_break = grub_register_command_lockdown ("gdbstub_break", grub_cmd_gdb_break,
+ /*
+ * TRANSLATORS: this refers to triggering
+ * a breakpoint so that the user will land
+ * into GDB.
+ */
+ 0, N_("Break into GDB"));
+ cmd_stop = grub_register_command_lockdown ("gdbstub_stop", grub_cmd_gdbstop,
+ 0, N_("Stop GDB stub"));
+}
+
+GRUB_MOD_FINI (gdb)
+{
+ grub_unregister_command (cmd);
+ grub_unregister_command (cmd_stop);
+ grub_gdb_idtrestore ();
+}
+
diff --git a/grub-core/gdb/i386/idt.c b/grub-core/gdb/i386/idt.c
new file mode 100644
index 0000000..69bfcb0
--- /dev/null
+++ b/grub-core/gdb/i386/idt.c
@@ -0,0 +1,78 @@
+/* idt.c - routines for constructing IDT fot the GDB stub */
+/*
+ * Copyright (C) 2006 Lubomir Kundrak
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/machine/memory.h>
+#include <grub/misc.h>
+#include <grub/cpu/gdb.h>
+#include <grub/gdb.h>
+
+static struct grub_cpu_interrupt_gate grub_gdb_idt[GRUB_GDB_LAST_TRAP + 1]
+ __attribute__ ((aligned(16)));
+
+/* Sets up a gate descriptor in the IDT table. */
+static void
+grub_idt_gate (struct grub_cpu_interrupt_gate *gate, void (*offset) (void),
+ grub_uint16_t selector, grub_uint8_t type, grub_uint8_t dpl)
+{
+ gate->offset_lo = (int) offset & 0xffff;
+ gate->selector = selector & 0xffff;
+ gate->unused = 0;
+ gate->gate = (type & 0x1f) | ((dpl & 0x3) << 5) | 0x80;
+ gate->offset_hi = ((int) offset >> 16) & 0xffff;
+}
+
+static struct grub_cpu_idt_descriptor grub_gdb_orig_idt_desc
+ __attribute__ ((aligned(16)));
+static struct grub_cpu_idt_descriptor grub_gdb_idt_desc
+ __attribute__ ((aligned(16)));
+
+/* Set up interrupt and trap handler descriptors in IDT. */
+void
+grub_gdb_idtinit (void)
+{
+ int i;
+ grub_uint16_t seg;
+
+ asm volatile ("xorl %%eax, %%eax\n"
+ "mov %%cs, %%ax\n" :"=a" (seg));
+
+ for (i = 0; i <= GRUB_GDB_LAST_TRAP; i++)
+ {
+ grub_idt_gate (&grub_gdb_idt[i],
+ grub_gdb_trapvec[i], seg,
+ GRUB_CPU_TRAP_GATE, 0);
+ }
+
+ grub_gdb_idt_desc.base = (grub_addr_t) grub_gdb_idt;
+ grub_gdb_idt_desc.limit = sizeof (grub_gdb_idt) - 1;
+ asm volatile ("sidt %0" : : "m" (grub_gdb_orig_idt_desc));
+ asm volatile ("lidt %0" : : "m" (grub_gdb_idt_desc));
+}
+
+void
+grub_gdb_idtrestore (void)
+{
+ asm volatile ("lidt %0" : : "m" (grub_gdb_orig_idt_desc));
+}
+
+void
+grub_gdb_breakpoint (void)
+{
+ asm volatile ("int $3");
+}
diff --git a/grub-core/gdb/i386/machdep.S b/grub-core/gdb/i386/machdep.S
new file mode 100644
index 0000000..f96d2b9
--- /dev/null
+++ b/grub-core/gdb/i386/machdep.S
@@ -0,0 +1,245 @@
+/* machdep.S - machine dependent assembly routines for the GDB stub */
+/*
+ * Copyright (C) 2006 Lubomir Kundrak
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/cpu/gdb.h>
+#include <grub/symbol.h>
+
+#define EC_PRESENT 1
+#define EC_ABSENT 0
+
+#define GRUB_GDB_STACKSIZE 40000
+
+#define SEP ,
+
+#ifdef __APPLE__
+ .zerofill __DATA, __bss, LOCAL(grub_gdb_stack_end), GRUB_GDB_STACKSIZE, 4
+ LOCAL(grub_gdb_stack) = LOCAL(grub_gdb_stack_end)
+#else
+/*
+ * The .data index for the address vector.
+ */
+
+#define VECTOR 1
+
+ .bss
+ .space GRUB_GDB_STACKSIZE
+VARIABLE(grub_gdb_stack)
+#endif
+
+/*
+ * Supplemental macros for register saving/restoration
+ * on exception handler entry/leave.
+ */
+
+#ifdef __APPLE__
+.macro save32
+#define REG $0
+#define NDX $1
+#else
+.macro save32 reg ndx
+#define REG \reg
+#define NDX \ndx
+#endif
+ movl REG, EXT_C(grub_gdb_regs)+(NDX * 4)
+.endm
+
+#undef REG
+#undef NDX
+
+#ifdef __APPLE__
+.macro save16
+#define REG $0
+#define NDX $1
+#else
+.macro save16 reg ndx
+#define REG \reg
+#define NDX \ndx
+#endif
+ xorl %eax, %eax
+ movw REG, EXT_C(grub_gdb_regs)+(NDX * 4)
+ movw %ax, EXT_C(grub_gdb_regs)+(NDX * 4 + 2)
+ movl EXT_C(grub_gdb_regs)+(EAX * 4), %eax
+.endm
+
+#undef REG
+#undef NDX
+
+#ifdef __APPLE__
+.macro load32
+#define NDX $0
+#define REG $1
+#else
+.macro load32 ndx reg
+#define REG \reg
+#define NDX \ndx
+#endif
+ movl EXT_C(grub_gdb_regs)+(NDX * 4), REG
+.endm
+
+#undef REG
+#undef NDX
+
+#ifdef __APPLE__
+.macro load16
+#define NDX $0
+#define REG $1
+#else
+.macro load16 ndx reg
+#define NDX \ndx
+#define REG \reg
+#endif
+ movw EXT_C(grub_gdb_regs)+(NDX * 4), REG
+.endm
+
+#undef REG
+#undef NDX
+
+.macro save_context
+ save32 %eax, EAX
+
+ save32 %ecx, ECX
+ save32 %edx, EDX
+ save32 %ebx, EBX
+ save32 %ebp, EBP
+ save32 %esi, ESI
+ save32 %edi, EDI
+
+ popl %ebx
+ save32 %ebx, EIP
+ popl %ebx
+ save32 %ebx, CS
+ popl %ebx
+ save32 %ebx, EFLAGS
+
+ save32 %esp, ESP
+
+ save16 %ds, DS
+ save16 %es, ES
+ save16 %fs, FS
+ save16 %gs, GS
+ save16 %ss, SS
+.endm
+
+.macro load_context
+ load16 SS, %ss
+ load32 ESP, %esp
+
+ load32 EBP, %ebp
+ load32 ESI, %esi
+ load32 EDI, %edi
+
+ load16 DS, %ds
+ load16 ES, %es
+ load16 FS, %fs
+ load16 GS, %gs
+
+ load32 EFLAGS, %eax
+ pushl %eax
+ load32 CS, %eax
+ pushl %eax
+ load32 EIP, %eax
+ pushl %eax
+
+ load32 EBX, %ebx
+ load32 EDX, %edx
+ load32 ECX, %ecx
+ load32 EAX, %eax
+.endm
+
+/*
+ * This macro creates handlers for a given range of exception numbers
+ * and adds their addresses to the grub_gdb_trapvec array.
+ */
+
+#ifdef __APPLE__
+.macro ent
+#define EC $0
+#define BEG $1
+#define END $2
+#else
+.macro ent ec beg end=0
+#define EC \ec
+#define BEG \beg
+#define END \end
+#endif
+
+ /*
+ * Wrapper body itself.
+ */
+
+ .text
+1:
+ .if EC
+ add MACRO_DOLLAR(4), %esp
+ .endif
+
+ save_context
+#ifdef __APPLE__
+ mov $LOCAL(grub_gdb_stack), %esp
+#else
+ mov $EXT_C(grub_gdb_stack), %esp
+#endif
+ mov $(BEG), %eax /* trap number */
+ call EXT_C(grub_gdb_trap)
+ load_context
+ iret
+
+ /*
+ * Address entry in trapvec array.
+ */
+
+#ifdef __APPLE__
+ .section __DATA, VECTOR
+#else
+ .data VECTOR
+#endif
+ .long 1b
+
+ /*
+ * Next... (recursion).
+ */
+
+ .if END-BEG > 0
+#ifdef __APPLE__
+ ent EC, (BEG+1), END
+#else
+ ent \ec "(\beg+1)" \end
+#endif
+ .endif
+.endm
+
+/*
+ * Here does the actual construction of the address array and handlers
+ * take place.
+ */
+#ifdef __APPLE__
+ .section __DATA, VECTOR
+#else
+ .data VECTOR
+#endif
+VARIABLE(grub_gdb_trapvec)
+ ent EC_ABSENT, 0, 7
+ ent EC_PRESENT, 8
+ ent EC_ABSENT, 9
+ ent EC_PRESENT, 10, 14
+ /*
+ * You may have to split this further or as(1)
+ * will complain about nesting being too deep.
+ */
+ ent EC_ABSENT, 15, GRUB_GDB_LAST_TRAP
diff --git a/grub-core/gdb/i386/signal.c b/grub-core/gdb/i386/signal.c
new file mode 100644
index 0000000..1ac3bbd
--- /dev/null
+++ b/grub-core/gdb/i386/signal.c
@@ -0,0 +1,53 @@
+/* idt.c - routines for constructing IDT fot the GDB stub */
+/*
+ * Copyright (C) 2006 Lubomir Kundrak
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/machine/memory.h>
+#include <grub/misc.h>
+#include <grub/cpu/gdb.h>
+#include <grub/gdb.h>
+
+/* Converting CPU trap number to UNIX signal number as
+ described in System V ABI i386 Processor Supplement, 3-25. */
+unsigned int
+grub_gdb_trap2sig (int trap_no)
+{
+ const int signals[] = {
+ SIGFPE, /* 0: Divide error fault */
+ SIGTRAP, /* 1: Single step trap fault */
+ SIGABRT, /* 2: # Nonmaskable interrupt */
+ SIGTRAP, /* 3: Breakpoint trap */
+ SIGSEGV, /* 4: Overflow trap */
+ SIGSEGV, /* 5: Bounds check fault */
+ SIGILL, /* 6: Invalid opcode fault */
+ SIGFPE, /* 7: No coprocessor fault */
+ SIGABRT, /* 8: # Double fault abort */
+ SIGSEGV, /* 9: Coprocessor overrun abort */
+ SIGSEGV, /* 10: Invalid TSS fault */
+ SIGSEGV, /* 11: Segment not present fault */
+ SIGSEGV, /* 12: Stack exception fault */
+ SIGSEGV, /* 13: General protection fault abort */
+ SIGSEGV, /* 14: Page fault */
+ SIGABRT, /* 15: (reserved) */
+ SIGFPE, /* 16: Coprocessor error fault */
+ SIGUSR1 /* other */
+ };
+
+ return signals[trap_no < 17 ? trap_no : 17];
+}
+
diff --git a/grub-core/gdb_grub.in b/grub-core/gdb_grub.in
new file mode 100644
index 0000000..e322d3d
--- /dev/null
+++ b/grub-core/gdb_grub.in
@@ -0,0 +1,85 @@
+###
+### Load debuging information about GNU GRUB 2 modules into GDB
+### automatically. Needs readelf, Perl and gmodule.pl script
+###
+### Has to be launched from the writable and trusted
+### directory containing *.image and *.module
+###
+### $Id: .gdbinit,v 1.1 2006/05/14 11:38:08 lkundrak Exp $
+### Lubomir Kundrak <lkudrak@skosi.org>
+###
+
+# Add section numbers and addresses to .segments.tmp
+define dump_module_sections
+ set $mod = $arg0
+
+ # FIXME: save logging status
+ set logging file .segments.tmp
+ set logging redirect on
+ set logging overwrite off
+ set logging on
+
+ printf "%s", $mod->name
+ set $segment = $mod->segment
+ while ($segment)
+ printf " %i 0x%lx", $segment->section, $segment->addr
+ set $segment = $segment->next
+ end
+ printf "\n"
+
+ set logging off
+ # FIXME: restore logging status
+end
+document dump_module_sections
+ Gather information about module whose mod structure was
+ given for use with match_and_load_symbols
+end
+
+# Generate and execute GDB commands and delete temporary files
+# afterwards
+define match_and_load_symbols
+ shell perl gmodule.pl <.segments.tmp >.loadsym.gdb
+ source .loadsym.gdb
+ shell rm -f .segments.tmp .loadsym.gdb
+end
+document match_and_load_symbols
+ Launch script, that matches section names with information
+ generated by dump_module_sections and load debugging info
+ apropriately
+end
+
+###
+
+define load_module
+ dump_module_sections $arg0
+ match_and_load_symbols
+end
+document load_module
+ Load debugging information for module given as argument.
+end
+
+define load_all_modules
+ set $this = grub_dl_head
+ while ($this != 0)
+ dump_module_sections $this
+ set $this = $this->next
+ end
+ match_and_load_symbols
+end
+document load_all_modules
+ Load debugging information for all loaded modules.
+end
+
+###
+
+set confirm off
+file kernel.exec
+target remote :1234
+
+# inform when module is loaded
+break grub_dl_add
+commands
+ silent
+ load_module mod
+ cont
+end
diff --git a/grub-core/genemuinit.sh b/grub-core/genemuinit.sh
new file mode 100644
index 0000000..8c6bb1c
--- /dev/null
+++ b/grub-core/genemuinit.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+#
+# Copyright (C) 2002,2005,2007 Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+nm="$1"
+shift
+
+cat <<EOF
+/* This file is automatically generated by geninit.sh. DO NOT EDIT! */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "grub_emu_init.h"
+
+EOF
+
+cat <<EOF
+void
+grub_init_all (void)
+{
+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 ();"
+ fi
+done
+
+cat <<EOF
+}
+EOF
+
+cat <<EOF
+void
+grub_fini_all (void)
+{
+EOF
+
+for line in $mods; do
+ if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then
+ echo "grub_${line%%.*}_fini ();"
+ fi
+done
+
+cat <<EOF
+}
+EOF
diff --git a/grub-core/genemuinitheader.sh b/grub-core/genemuinitheader.sh
new file mode 100644
index 0000000..a99a15d
--- /dev/null
+++ b/grub-core/genemuinitheader.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+#
+# Copyright (C) 2005,2007 Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+nm="$1"
+shift
+
+cat <<EOF
+/* This file is automatically generated by gensymlist.sh. DO NOT EDIT! */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+EOF
+
+cat <<EOF
+void grub_init_all (void);
+void grub_fini_all (void);
+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);"
+ fi
+ if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then
+ echo "void grub_${line%%.*}_fini (void);"
+ fi
+done
diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in
new file mode 100644
index 0000000..1250589
--- /dev/null
+++ b/grub-core/genmod.sh.in
@@ -0,0 +1,103 @@
+#! @BUILD_SHEBANG@
+set -e
+
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+#
+# Example:
+#
+# genmod.sh moddep.lst normal.module build-grub-module-verifier normal.mod
+#
+
+moddep=$1
+infile=$2
+outfile=$4
+
+tmpfile=${outfile}.tmp
+modname=`echo $infile | sed -e 's@\.module.*$@@'`
+
+if ! grep ^$modname: $moddep >/dev/null; then
+ echo "warning: moddep.lst has no dependencies for $modname" >&2
+ exit 0
+fi
+
+deps=`grep ^$modname: $moddep | sed s@^.*:@@`
+
+# remove old files if any
+rm -f $tmpfile $outfile
+
+if test x@TARGET_APPLE_LINKER@ != x1; then
+ # stripout .modname and .moddeps sections from input module
+ @TARGET_OBJCOPY@ -R .modname -R .moddeps $infile $tmpfile
+
+ # Attach .modname and .moddeps sections
+ t1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
+ printf "$modname\0" >$t1
+
+ t2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
+ for dep in $deps; do printf "$dep\0" >> $t2; done
+
+ if test -n "$deps"; then
+ @TARGET_OBJCOPY@ --add-section .modname=$t1 --add-section .moddeps=$t2 $tmpfile
+ else
+ @TARGET_OBJCOPY@ --add-section .modname=$t1 $tmpfile
+ fi
+ rm -f $t1 $t2
+
+ if test x@platform@ != xemu; then
+ @TARGET_STRIP@ --strip-unneeded \
+ -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 .gnu.build.attributes \
+ -R .rel.gnu.build.attributes \
+ -R .rela.gnu.build.attributes \
+ -R .eh_frame -R .rela.eh_frame -R .rel.eh_frame \
+ -R .note -R .comment -R .ARM.exidx $tmpfile || exit 1
+ fi
+ if ! test -z "${TARGET_OBJ2ELF}"; then
+ "${TARGET_OBJ2ELF}" $tmpfile || exit 1
+ fi
+else
+ tmpfile2=${outfile}.tmp2
+ t1=${outfile}.t1.c
+ t2=${outfile}.t2.c
+
+ # remove old files if any
+ rm -f $t1 $t2
+
+ cp $infile $tmpfile
+
+ # Attach .modname and .moddeps sections
+ echo "char modname[] __attribute__ ((section(\"_modname, _modname\"))) = \"$modname\";" >$t1
+
+ for dep in $deps; do echo "char moddep_$dep[] __attribute__ ((section(\"_moddeps, _moddeps\"))) = \"$dep\";" >>$t2; done
+
+ if test -n "$deps"; then
+ @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $t2 $tmpfile -Wl,-r,-d
+ else
+ @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $tmpfile -Wl,-r,-d
+ fi
+ rm -f $t1 $t2 $tmpfile
+ mv $tmpfile2 $tmpfile
+
+ cp $tmpfile $tmpfile.bin
+ @TARGET_OBJCONV@ -f@TARGET_MODULE_FORMAT@ \
+ -nr:_grub_mod_init:grub_mod_init \
+ -nr:_grub_mod_fini:grub_mod_fini \
+ -wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1
+ rm -f $tmpfile.bin
+fi
+if test x@platform@ != xemu; then
+ ./build-grub-module-verifier@BUILD_EXEEXT@ $tmpfile @target_cpu@ @platform@
+fi
+mv $tmpfile $outfile
diff --git a/grub-core/genmoddep.awk b/grub-core/genmoddep.awk
new file mode 100644
index 0000000..04c2863
--- /dev/null
+++ b/grub-core/genmoddep.awk
@@ -0,0 +1,102 @@
+#! /usr/bin/awk -f
+#
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This genmoddep.awk is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+# Read symbols' info from stdin.
+BEGIN {
+ error = 0
+}
+
+{
+ if ($1 == "defined") {
+ if ($3 !~ /^\.refptr\./ && $3 in symtab) {
+ printf "%s in %s is duplicated in %s\n", $3, $2, symtab[$3] >"/dev/stderr";
+ error++;
+ }
+ symtab[$3] = $2;
+ modtab[$2] = "" modtab[$2]
+ } else if ($1 == "undefined") {
+ if ($3 in symtab)
+ modtab[$2] = modtab[$2] " " symtab[$3];
+ else if ($3 != "__gnu_local_gp" && $3 != "_gp_disp") {
+ printf "%s in %s is not defined\n", $3, $2 >"/dev/stderr";
+ error++;
+ }
+ }
+ else {
+ printf "error: %u: unrecognized input format\n", NR >"/dev/stderr";
+ error++;
+ }
+}
+
+# Output the result.
+END {
+ if (error >= 1)
+ exit 1;
+
+ total_depcount = 0
+
+ for (mod in modtab) {
+ # Remove duplications.
+ split(modtab[mod], depmods, " ");
+ for (depmod in uniqmods) {
+ delete uniqmods[depmod];
+ }
+ for (i in depmods) {
+ depmod = depmods[i];
+ # Ignore kernel, as always loaded.
+ if (depmod != "kernel" && depmod != mod)
+ 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;
+ }
+ printf "all_video:%s\n", modlist;
+}
diff --git a/grub-core/gensyminfo.sh.in b/grub-core/gensyminfo.sh.in
new file mode 100644
index 0000000..9bc7675
--- /dev/null
+++ b/grub-core/gensyminfo.sh.in
@@ -0,0 +1,37 @@
+#! @BUILD_SHEBANG@
+set -e
+
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+#
+# Example:
+#
+# gensyms.sh normal.module
+#
+
+module=$1
+modname=`echo $module | sed -e 's@\.module.*$@@'`
+
+# Print all symbols defined by module
+if test x"@TARGET_NMFLAGS_DEFINED_ONLY@" = x && test x"@TARGET_NMFLAGS_MINUS_P@" = x; then
+ @TARGET_NM@ -g -p $module | \
+ sed -n "s@^\([0-9a-fA-F]*\) *[TBRDS] *\([^ ]*\).*@defined $modname \2@p"
+elif test x"@TARGET_NMFLAGS_DEFINED_ONLY@" = x; then
+ @TARGET_NM@ -g @TARGET_NMFLAGS_MINUS_P@ -p $module | \
+ sed -n "s@^\([^ ]*\) *[TBRDS] *\([0-9a-fA-F]*\).*@defined $modname \1@p"
+else
+ @TARGET_NM@ -g --defined-only @TARGET_NMFLAGS_MINUS_P@ -p $module | \
+ sed "s@^\([^ ]*\).*@defined $modname \1@g"
+fi
+
+# Print all undefined symbols used by module
+@TARGET_NM@ -u @TARGET_NMFLAGS_MINUS_P@ -p $module | sed "s@^\([^ ]*\).*@undefined $modname \1@g"
diff --git a/grub-core/gensymlist.sh b/grub-core/gensymlist.sh
new file mode 100644
index 0000000..5beaabd
--- /dev/null
+++ b/grub-core/gensymlist.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+#
+# Copyright (C) 2002,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+#
+# This gensymlist.sh.in is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+cat <<EOF
+/* This file is automatically generated by gensymlist.sh. DO NOT EDIT! */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+EOF
+
+for i in $*; do
+ echo "#include <$i>"
+done
+
+cat <<EOF
+
+#define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
+
+#pragma GCC diagnostic ignored "-Wmissing-format-attribute"
+
+void
+grub_register_exported_symbols (void)
+{
+EOF
+
+cat <<EOF
+ struct symtab { const char *name; void *addr; int isfunc; };
+ struct symtab *p;
+ static struct symtab tab[] =
+ {
+EOF
+
+(while read LINE; do echo $LINE; done) \
+ | grep -v '^#' \
+ | sed -n \
+ -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/ {"\1", \1, 1},/;p;}' \
+ -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/ {"\1", (void *) \&\1, 0},/;p;}' \
+ | sort -u
+
+cat <<EOF
+ {0, 0, 0}
+ };
+
+ COMPILE_TIME_ASSERT (sizeof (tab) > sizeof (tab[0]));
+ for (p = tab; p->name; p++)
+ grub_dl_register_symbol (p->name, p->addr, p->isfunc, 0);
+}
+EOF
diff --git a/grub-core/gentrigtables.c b/grub-core/gentrigtables.c
new file mode 100644
index 0000000..fface6e
--- /dev/null
+++ b/grub-core/gentrigtables.c
@@ -0,0 +1,57 @@
+/* Generate trigonometric function tables. */
+/*
+ * 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/>.
+ */
+
+#define _GNU_SOURCE 1
+
+#include <grub/trig.h>
+#include <math.h>
+#include <stdio.h>
+
+int
+main (int argc __attribute__ ((unused)),
+ char **argv __attribute__ ((unused)))
+{
+ int i;
+
+ printf ("#include <grub/types.h>\n");
+ printf ("#include <grub/dl.h>\n");
+ printf ("\n");
+
+ printf ("/* Under copyright legislature such automated output isn't\n");
+ printf ("covered by any copyright. Hence it's public domain. Public\n");
+ printf ("domain works can be dual-licenced with any license. */\n");
+ printf ("GRUB_MOD_LICENSE (\"GPLv3+\");");
+ printf ("GRUB_MOD_DUAL_LICENSE (\"Public Domain\");");
+
+#define TAB(op) \
+ printf ("const grub_int16_t grub_trig_" #op "tab[] =\n{"); \
+ for (i = 0; i < GRUB_TRIG_ANGLE_MAX; i++) \
+ { \
+ double x = i * 2 * M_PI / GRUB_TRIG_ANGLE_MAX; \
+ if (i % 10 == 0) \
+ printf ("\n "); \
+ printf ("%d,", (int) (round (op (x) * GRUB_TRIG_FRACTION_SCALE))); \
+ } \
+ printf ("\n};\n")
+
+ TAB(sin);
+ TAB(cos);
+
+ return 0;
+}
diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c
new file mode 100644
index 0000000..4d02e62
--- /dev/null
+++ b/grub-core/gettext/gettext.c
@@ -0,0 +1,542 @@
+/* gettext.c - gettext module */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/normal.h>
+#include <grub/file.h>
+#include <grub/kernel.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/*
+ .mo file information from:
+ http://www.gnu.org/software/autoconf/manual/gettext/MO-Files.html .
+*/
+
+static const char *(*grub_gettext_original) (const char *s);
+
+struct grub_gettext_msg
+{
+ char *name;
+ char *translated;
+};
+
+struct header
+{
+ grub_uint32_t magic;
+ grub_uint32_t version;
+ grub_uint32_t number_of_strings;
+ grub_uint32_t offset_original;
+ grub_uint32_t offset_translation;
+};
+
+struct string_descriptor
+{
+ grub_uint32_t length;
+ grub_uint32_t offset;
+};
+
+struct grub_gettext_context
+{
+ grub_file_t fd_mo;
+ grub_off_t grub_gettext_offset_original;
+ grub_off_t grub_gettext_offset_translation;
+ grub_size_t grub_gettext_max;
+ int grub_gettext_max_log;
+ struct grub_gettext_msg *grub_gettext_msg_list;
+};
+
+static struct grub_gettext_context main_context, secondary_context;
+
+#define MO_MAGIC_NUMBER 0x950412de
+
+static grub_err_t
+grub_gettext_pread (grub_file_t file, void *buf, grub_size_t len,
+ grub_off_t offset)
+{
+ if (len == 0)
+ return GRUB_ERR_NONE;
+ if (grub_file_seek (file, offset) == (grub_off_t) - 1)
+ return grub_errno;
+ if (grub_file_read (file, buf, len) != (grub_ssize_t) len)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_READ_ERROR, N_("premature end of file"));
+ return grub_errno;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static char *
+grub_gettext_getstr_from_position (struct grub_gettext_context *ctx,
+ grub_off_t off,
+ grub_size_t position)
+{
+ grub_off_t internal_position;
+ grub_size_t length;
+ grub_off_t offset;
+ char *translation;
+ struct string_descriptor desc;
+ grub_err_t err;
+
+ internal_position = (off + position * sizeof (desc));
+
+ err = grub_gettext_pread (ctx->fd_mo, (char *) &desc,
+ sizeof (desc), internal_position);
+ if (err)
+ return NULL;
+ length = grub_cpu_to_le32 (desc.length);
+ offset = grub_cpu_to_le32 (desc.offset);
+
+ translation = grub_malloc (length + 1);
+ if (!translation)
+ return NULL;
+
+ err = grub_gettext_pread (ctx->fd_mo, translation, length, offset);
+ if (err)
+ {
+ grub_free (translation);
+ return NULL;
+ }
+ translation[length] = '\0';
+
+ return translation;
+}
+
+static const char *
+grub_gettext_gettranslation_from_position (struct grub_gettext_context *ctx,
+ grub_size_t position)
+{
+ if (!ctx->grub_gettext_msg_list[position].translated)
+ ctx->grub_gettext_msg_list[position].translated
+ = grub_gettext_getstr_from_position (ctx,
+ ctx->grub_gettext_offset_translation,
+ position);
+ return ctx->grub_gettext_msg_list[position].translated;
+}
+
+static const char *
+grub_gettext_getstring_from_position (struct grub_gettext_context *ctx,
+ grub_size_t position)
+{
+ if (!ctx->grub_gettext_msg_list[position].name)
+ ctx->grub_gettext_msg_list[position].name
+ = grub_gettext_getstr_from_position (ctx,
+ ctx->grub_gettext_offset_original,
+ position);
+ return ctx->grub_gettext_msg_list[position].name;
+}
+
+static const char *
+grub_gettext_translate_real (struct grub_gettext_context *ctx,
+ const char *orig)
+{
+ grub_size_t current = 0;
+ int i;
+ const char *current_string;
+ static int depth = 0;
+
+ if (!ctx->grub_gettext_msg_list || !ctx->fd_mo)
+ return NULL;
+
+ /* Shouldn't happen. Just a precaution if our own code
+ calls gettext somehow. */
+ if (depth > 2)
+ return NULL;
+ depth++;
+
+ /* Make sure we can use grub_gettext_translate for error messages. Push
+ active error message to error stack and reset error message. */
+ grub_error_push ();
+
+ for (i = ctx->grub_gettext_max_log; i >= 0; i--)
+ {
+ grub_size_t test;
+ int cmp;
+
+ test = current | (1 << i);
+ if (test >= ctx->grub_gettext_max)
+ continue;
+
+ current_string = grub_gettext_getstring_from_position (ctx, test);
+
+ if (!current_string)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_error_pop ();
+ depth--;
+ return NULL;
+ }
+
+ /* Search by bisection. */
+ cmp = grub_strcmp (current_string, orig);
+ if (cmp <= 0)
+ current = test;
+ if (cmp == 0)
+ {
+ const char *ret = 0;
+ ret = grub_gettext_gettranslation_from_position (ctx, current);
+ if (!ret)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_error_pop ();
+ depth--;
+ return NULL;
+ }
+ grub_error_pop ();
+ depth--;
+ return ret;
+ }
+ }
+
+ if (current == 0 && ctx->grub_gettext_max != 0)
+ {
+ current_string = grub_gettext_getstring_from_position (ctx, 0);
+
+ if (!current_string)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_error_pop ();
+ depth--;
+ return NULL;
+ }
+
+ if (grub_strcmp (current_string, orig) == 0)
+ {
+ const char *ret = 0;
+ ret = grub_gettext_gettranslation_from_position (ctx, current);
+ if (!ret)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_error_pop ();
+ depth--;
+ return NULL;
+ }
+ grub_error_pop ();
+ depth--;
+ return ret;
+ }
+ }
+
+ grub_error_pop ();
+ depth--;
+ return NULL;
+}
+
+static const char *
+grub_gettext_translate (const char *orig)
+{
+ const char *ret;
+ if (orig[0] == 0)
+ return orig;
+
+ ret = grub_gettext_translate_real (&main_context, orig);
+ if (ret)
+ return ret;
+ ret = grub_gettext_translate_real (&secondary_context, orig);
+ if (ret)
+ return ret;
+ return orig;
+}
+
+static void
+grub_gettext_delete_list (struct grub_gettext_context *ctx)
+{
+ struct grub_gettext_msg *l = ctx->grub_gettext_msg_list;
+ grub_size_t i;
+
+ if (!l)
+ return;
+ ctx->grub_gettext_msg_list = 0;
+ for (i = 0; i < ctx->grub_gettext_max; i++)
+ grub_free (l[i].name);
+ /* Don't delete the translated message because could be in use. */
+ grub_free (l);
+ if (ctx->fd_mo)
+ grub_file_close (ctx->fd_mo);
+ ctx->fd_mo = 0;
+ grub_memset (ctx, 0, sizeof (*ctx));
+}
+
+/* This is similar to grub_file_open. */
+static grub_err_t
+grub_mofile_open (struct grub_gettext_context *ctx,
+ const char *filename)
+{
+ struct header head;
+ grub_err_t err;
+ grub_file_t fd;
+
+ /* Using fd_mo and not another variable because
+ it's needed for grub_gettext_get_info. */
+
+ fd = grub_file_open (filename, GRUB_FILE_TYPE_GETTEXT_CATALOG);
+
+ if (!fd)
+ return grub_errno;
+
+ err = grub_gettext_pread (fd, &head, sizeof (head), 0);
+ if (err)
+ {
+ grub_file_close (fd);
+ return err;
+ }
+
+ if (head.magic != grub_cpu_to_le32_compile_time (MO_MAGIC_NUMBER))
+ {
+ grub_file_close (fd);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "mo: invalid mo magic in file: %s", filename);
+ }
+
+ if (head.version != 0)
+ {
+ grub_file_close (fd);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "mo: invalid mo version in file: %s", filename);
+ }
+
+ ctx->grub_gettext_offset_original = grub_le_to_cpu32 (head.offset_original);
+ ctx->grub_gettext_offset_translation = grub_le_to_cpu32 (head.offset_translation);
+ ctx->grub_gettext_max = grub_le_to_cpu32 (head.number_of_strings);
+ for (ctx->grub_gettext_max_log = 0; ctx->grub_gettext_max >> ctx->grub_gettext_max_log;
+ ctx->grub_gettext_max_log++);
+
+ ctx->grub_gettext_msg_list = grub_zalloc (ctx->grub_gettext_max
+ * sizeof (ctx->grub_gettext_msg_list[0]));
+ if (!ctx->grub_gettext_msg_list)
+ {
+ grub_file_close (fd);
+ return grub_errno;
+ }
+ ctx->fd_mo = fd;
+ if (grub_gettext != grub_gettext_translate)
+ {
+ grub_gettext_original = grub_gettext;
+ grub_gettext = grub_gettext_translate;
+ }
+ return 0;
+}
+
+/* Returning grub_file_t would be more natural, but grub_mofile_open assigns
+ to fd_mo anyway ... */
+static grub_err_t
+grub_mofile_open_lang (struct grub_gettext_context *ctx,
+ const char *part1, const char *part2, const char *locale)
+{
+ char *mo_file;
+ grub_err_t err;
+
+ /* mo_file e.g.: /boot/grub/locale/ca.mo */
+
+ mo_file = grub_xasprintf ("%s%s/%s.mo", part1, part2, locale);
+ if (!mo_file)
+ return grub_errno;
+
+ err = grub_mofile_open (ctx, mo_file);
+ grub_free (mo_file);
+
+ /* Will try adding .gz as well. */
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ mo_file = grub_xasprintf ("%s%s/%s.mo.gz", part1, part2, locale);
+ if (!mo_file)
+ return grub_errno;
+ err = grub_mofile_open (ctx, mo_file);
+ grub_free (mo_file);
+ }
+
+ /* Will try adding .gmo as well. */
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ mo_file = grub_xasprintf ("%s%s/%s.gmo", part1, part2, locale);
+ if (!mo_file)
+ return grub_errno;
+ err = grub_mofile_open (ctx, mo_file);
+ grub_free (mo_file);
+ }
+
+ return err;
+}
+
+static grub_err_t
+grub_gettext_init_ext (struct grub_gettext_context *ctx,
+ const char *locale,
+ const char *locale_dir, const char *prefix)
+{
+ const char *part1, *part2;
+ grub_err_t err;
+
+ grub_gettext_delete_list (ctx);
+
+ if (!locale || locale[0] == 0)
+ return 0;
+
+ part1 = locale_dir;
+ part2 = "";
+ if (!part1 || part1[0] == 0)
+ {
+ part1 = prefix;
+ part2 = "/locale";
+ }
+
+ if (!part1 || part1[0] == 0)
+ return 0;
+
+ err = grub_mofile_open_lang (ctx, part1, part2, locale);
+
+ /* ll_CC didn't work, so try ll. */
+ if (err)
+ {
+ char *lang = grub_strdup (locale);
+ char *underscore = lang ? grub_strchr (lang, '_') : 0;
+
+ if (underscore)
+ {
+ *underscore = '\0';
+ grub_errno = GRUB_ERR_NONE;
+ err = grub_mofile_open_lang (ctx, part1, part2, lang);
+ }
+
+ grub_free (lang);
+ }
+
+ if (locale[0] == 'e' && locale[1] == 'n'
+ && (locale[2] == '\0' || locale[2] == '_'))
+ grub_errno = err = GRUB_ERR_NONE;
+ return err;
+}
+
+static char *
+grub_gettext_env_write_lang (struct grub_env_var *var
+ __attribute__ ((unused)), const char *val)
+{
+ grub_err_t err;
+ err = grub_gettext_init_ext (&main_context, val, grub_env_get ("locale_dir"),
+ grub_env_get ("prefix"));
+ if (err)
+ grub_print_error ();
+
+ err = grub_gettext_init_ext (&secondary_context, val,
+ grub_env_get ("secondary_locale_dir"), 0);
+ if (err)
+ grub_print_error ();
+
+ return grub_strdup (val);
+}
+
+void
+grub_gettext_reread_prefix (const char *val)
+{
+ grub_err_t err;
+ err = grub_gettext_init_ext (&main_context, grub_env_get ("lang"),
+ grub_env_get ("locale_dir"),
+ val);
+ if (err)
+ grub_print_error ();
+}
+
+static char *
+read_main (struct grub_env_var *var
+ __attribute__ ((unused)), const char *val)
+{
+ grub_err_t err;
+ err = grub_gettext_init_ext (&main_context, grub_env_get ("lang"), val,
+ grub_env_get ("prefix"));
+ if (err)
+ grub_print_error ();
+ return grub_strdup (val);
+}
+
+static char *
+read_secondary (struct grub_env_var *var
+ __attribute__ ((unused)), const char *val)
+{
+ grub_err_t err;
+ err = grub_gettext_init_ext (&secondary_context, grub_env_get ("lang"), val,
+ 0);
+ if (err)
+ grub_print_error ();
+
+ return grub_strdup (val);
+}
+
+static grub_err_t
+grub_cmd_translate (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ const char *translation;
+ translation = grub_gettext_translate (args[0]);
+ grub_printf ("%s\n", translation);
+ return 0;
+}
+
+GRUB_MOD_INIT (gettext)
+{
+ const char *lang;
+ grub_err_t err;
+
+ lang = grub_env_get ("lang");
+
+ err = grub_gettext_init_ext (&main_context, lang, grub_env_get ("locale_dir"),
+ grub_env_get ("prefix"));
+ if (err)
+ grub_print_error ();
+ err = grub_gettext_init_ext (&secondary_context, lang,
+ grub_env_get ("secondary_locale_dir"), 0);
+ if (err)
+ grub_print_error ();
+
+ grub_register_variable_hook ("locale_dir", NULL, read_main);
+ grub_register_variable_hook ("secondary_locale_dir", NULL, read_secondary);
+
+ grub_register_command_p1 ("gettext", grub_cmd_translate,
+ N_("STRING"),
+ /* TRANSLATORS: It refers to passing the string through gettext.
+ So it's "translate" in the same meaning as in what you're
+ doing now.
+ */
+ N_("Translates the string with the current settings."));
+
+ /* Reload .mo file information if lang changes. */
+ grub_register_variable_hook ("lang", NULL, grub_gettext_env_write_lang);
+
+ /* Preserve hooks after context changes. */
+ grub_env_export ("lang");
+ grub_env_export ("locale_dir");
+ grub_env_export ("secondary_locale_dir");
+}
+
+GRUB_MOD_FINI (gettext)
+{
+ grub_gettext_delete_list (&main_context);
+ grub_gettext_delete_list (&secondary_context);
+
+ grub_gettext = grub_gettext_original;
+}
diff --git a/grub-core/gfxmenu/font.c b/grub-core/gfxmenu/font.c
new file mode 100644
index 0000000..756c24f
--- /dev/null
+++ b/grub-core/gfxmenu/font.c
@@ -0,0 +1,116 @@
+/* font.c - Font API and font file loader. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/bufio.h>
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/font.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/video.h>
+#include <grub/bitmap.h>
+#include <grub/charset.h>
+#include <grub/unicode.h>
+#include <grub/fontformat.h>
+#include <grub/gfxmenu_view.h>
+
+/* Draw a UTF-8 string of text on the current video render target.
+ The x coordinate specifies the starting x position for the first character,
+ while the y coordinate specifies the baseline position.
+ If the string contains a character that FONT does not contain, then
+ a glyph from another loaded font may be used instead. */
+grub_err_t
+grub_font_draw_string (const char *str, grub_font_t font,
+ grub_video_color_t color,
+ int left_x, int baseline_y)
+{
+ int x;
+ 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)
+ return grub_errno;
+
+ visual_len = grub_bidi_logical_to_visual (logical, logical_len, &visual,
+ 0, 0, 0, 0, 0, 0, 0);
+ grub_free (logical);
+ if (visual_len < 0)
+ return grub_errno;
+
+ err = GRUB_ERR_NONE;
+ for (ptr = visual, x = left_x; ptr < visual + visual_len; ptr++)
+ {
+ struct grub_font_glyph *glyph;
+ glyph = grub_font_construct_glyph (font, ptr);
+ if (!glyph)
+ {
+ err = grub_errno;
+ goto out;
+ }
+ err = grub_font_draw_glyph (glyph, color, x, baseline_y);
+ if (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 err;
+}
+
+/* Get the width in pixels of the specified UTF-8 string, when rendered in
+ in the specified font (but falling back on other fonts for glyphs that
+ are missing). */
+int
+grub_font_get_string_width (grub_font_t font, const char *str)
+{
+ int width = 0;
+ grub_uint32_t *ptr;
+ grub_ssize_t logical_len;
+ grub_uint32_t *logical;
+
+ logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0);
+ if (logical_len < 0)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+
+ for (ptr = logical; ptr < logical + logical_len;)
+ {
+ struct grub_unicode_glyph glyph;
+
+ ptr += grub_unicode_aglomerate_comb (ptr,
+ logical_len - (ptr - logical),
+ &glyph);
+ width += grub_font_get_constructed_device_width (font, &glyph);
+
+ grub_unicode_destroy_glyph (&glyph);
+ }
+ grub_free (logical);
+
+ return width;
+}
diff --git a/grub-core/gfxmenu/gfxmenu.c b/grub-core/gfxmenu/gfxmenu.c
new file mode 100644
index 0000000..8a17dda
--- /dev/null
+++ b/grub-core/gfxmenu/gfxmenu.c
@@ -0,0 +1,150 @@
+/* gfxmenu.c - Graphical menu interface controller. */
+/*
+ * 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/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/video.h>
+#include <grub/gfxterm.h>
+#include <grub/bitmap.h>
+#include <grub/bitmap_scale.h>
+#include <grub/term.h>
+#include <grub/env.h>
+#include <grub/normal.h>
+#include <grub/gfxwidgets.h>
+#include <grub/menu.h>
+#include <grub/menu_viewer.h>
+#include <grub/gfxmenu_model.h>
+#include <grub/gfxmenu_view.h>
+#include <grub/time.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_gfxmenu_view_t cached_view;
+
+static void
+grub_gfxmenu_viewer_fini (void *data __attribute__ ((unused)))
+{
+}
+
+/* FIXME: Previously 't' changed to text menu is it necessary? */
+static grub_err_t
+grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
+{
+ grub_gfxmenu_view_t view = NULL;
+ const char *theme_path;
+ char *full_theme_path = 0;
+ struct grub_menu_viewer *instance;
+ grub_err_t err;
+ struct grub_video_mode_info mode_info;
+
+ theme_path = grub_env_get ("theme");
+ if (! theme_path)
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"),
+ "theme");
+
+ 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;
+ prefix = grub_env_get ("prefix");
+ full_theme_path = grub_xasprintf ("%s/themes/%s",
+ prefix,
+ theme_path);
+ }
+
+ if (!cached_view || grub_strcmp (cached_view->theme_path,
+ full_theme_path ? : theme_path) != 0
+ || cached_view->screen.width != mode_info.width
+ || cached_view->screen.height != mode_info.height)
+ {
+ grub_gfxmenu_view_destroy (cached_view);
+ /* Create the view. */
+ cached_view = grub_gfxmenu_view_new (full_theme_path ? : theme_path,
+ mode_info.width,
+ mode_info.height);
+ }
+ grub_free (full_theme_path);
+
+ if (! cached_view)
+ {
+ grub_free (instance);
+ return grub_errno;
+ }
+
+ view = cached_view;
+
+ view->double_repaint = (mode_info.mode_type
+ & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED)
+ && !(mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP);
+ view->selected = entry;
+ view->menu = menu;
+ view->nested = nested;
+ view->first_timeout = -1;
+
+ grub_video_set_viewport (0, 0, mode_info.width, mode_info.height);
+ if (view->double_repaint)
+ {
+ grub_video_swap_buffers ();
+ grub_video_set_viewport (0, 0, mode_info.width, mode_info.height);
+ }
+
+ grub_gfxmenu_view_draw (view);
+
+ instance->data = view;
+ instance->set_chosen_entry = grub_gfxmenu_set_chosen_entry;
+ instance->fini = grub_gfxmenu_viewer_fini;
+ instance->print_timeout = grub_gfxmenu_print_timeout;
+ instance->clear_timeout = grub_gfxmenu_clear_timeout;
+
+ grub_menu_register_viewer (instance);
+
+ return GRUB_ERR_NONE;
+}
+
+GRUB_MOD_INIT (gfxmenu)
+{
+ struct grub_term_output *term;
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ if (grub_gfxmenu_try_hook && term->fullscreen)
+ {
+ term->fullscreen ();
+ break;
+ }
+
+ grub_gfxmenu_try_hook = grub_gfxmenu_try;
+}
+
+GRUB_MOD_FINI (gfxmenu)
+{
+ grub_gfxmenu_view_destroy (cached_view);
+ grub_gfxmenu_try_hook = NULL;
+}
diff --git a/grub-core/gfxmenu/gui_box.c b/grub-core/gfxmenu/gui_box.c
new file mode 100644
index 0000000..37bab3f
--- /dev/null
+++ b/grub-core/gfxmenu/gui_box.c
@@ -0,0 +1,428 @@
+/* gui_box.c - GUI container that stack components. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/gui.h>
+#include <grub/gui_string_util.h>
+
+struct component_node
+{
+ grub_gui_component_t component;
+ struct component_node *next;
+ struct component_node *prev;
+};
+
+typedef struct grub_gui_box *grub_gui_box_t;
+
+typedef void (*layout_func_t) (grub_gui_box_t self, int modify_layout,
+ unsigned *minimal_width,
+ unsigned *minimal_height);
+
+struct grub_gui_box
+{
+ struct grub_gui_container container;
+
+ grub_gui_container_t parent;
+ grub_video_rect_t bounds;
+ char *id;
+
+ /* Doubly linked list of components with dummy head & tail nodes. */
+ struct component_node chead;
+ struct component_node ctail;
+
+ /* The layout function: differs for vertical and horizontal boxes. */
+ layout_func_t layout_func;
+};
+
+static void
+box_destroy (void *vself)
+{
+ grub_gui_box_t self = vself;
+ struct component_node *cur;
+ struct component_node *next;
+ for (cur = self->chead.next; cur != &self->ctail; cur = next)
+ {
+ /* Copy the 'next' pointer, since we need it for the next iteration,
+ and we're going to free the memory it is stored in. */
+ next = cur->next;
+ /* Destroy the child component. */
+ cur->component->ops->destroy (cur->component);
+ /* Free the linked list node. */
+ grub_free (cur);
+ }
+ grub_free (self);
+}
+
+static const char *
+box_get_id (void *vself)
+{
+ grub_gui_box_t self = vself;
+ return self->id;
+}
+
+static int
+box_is_instance (void *vself __attribute__((unused)), const char *type)
+{
+ return (grub_strcmp (type, "component") == 0
+ || grub_strcmp (type, "container") == 0);
+}
+
+static void
+layout_horizontally (grub_gui_box_t self, int modify_layout,
+ unsigned *min_width, unsigned *min_height)
+{
+ /* Start at the left (chead) and set the x coordinates as we go right. */
+ /* All components have their width set to the box's width. */
+
+ struct component_node *cur;
+ unsigned w = 0, mwfrac = 0, h = 0, x = 0;
+ grub_fixed_signed_t wfrac = 0;
+ int bogus_frac = 0;
+
+ for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
+ {
+ grub_gui_component_t c = cur->component;
+ unsigned mw = 0, mh = 0;
+
+ if (c->ops->get_minimal_size)
+ c->ops->get_minimal_size (c, &mw, &mh);
+
+ if (c->h > (signed) h)
+ h = c->h;
+ if (mh > h)
+ h = mh;
+ wfrac += c->wfrac;
+ w += c->w;
+ if (mw - c->w > 0)
+ mwfrac += mw - c->w;
+ }
+ if (wfrac > GRUB_FIXED_1 || (w > 0 && wfrac == GRUB_FIXED_1))
+ bogus_frac = 1;
+
+ if (min_width)
+ {
+ if (wfrac < GRUB_FIXED_1)
+ *min_width = grub_fixed_sfs_divide (w, GRUB_FIXED_1 - wfrac);
+ else
+ *min_width = w;
+ if (*min_width < w + mwfrac)
+ *min_width = w + mwfrac;
+ }
+ if (min_height)
+ *min_height = h;
+
+ if (!modify_layout)
+ return;
+
+ for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
+ {
+ grub_video_rect_t r;
+ grub_gui_component_t c = cur->component;
+ unsigned mw = 0, mh = 0;
+
+ r.x = x;
+ r.y = 0;
+ r.height = h;
+
+ if (c->ops->get_minimal_size)
+ c->ops->get_minimal_size (c, &mw, &mh);
+
+ r.width = c->w;
+ if (!bogus_frac)
+ r.width += grub_fixed_sfs_multiply (self->bounds.width, c->wfrac);
+
+ if (r.width < mw)
+ r.width = mw;
+
+ c->ops->set_bounds (c, &r);
+
+ x += r.width;
+ }
+}
+
+static void
+layout_vertically (grub_gui_box_t self, int modify_layout,
+ unsigned *min_width, unsigned *min_height)
+{
+ /* Start at the top (chead) and set the y coordinates as we go rdown. */
+ /* All components have their height set to the box's height. */
+
+ struct component_node *cur;
+ unsigned h = 0, mhfrac = 0, w = 0, y = 0;
+ grub_fixed_signed_t hfrac = 0;
+ int bogus_frac = 0;
+
+ for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
+ {
+ grub_gui_component_t c = cur->component;
+ unsigned mw = 0, mh = 0;
+
+ if (c->ops->get_minimal_size)
+ c->ops->get_minimal_size (c, &mw, &mh);
+
+ if (c->w > (signed) w)
+ w = c->w;
+ if (mw > w)
+ w = mw;
+ hfrac += c->hfrac;
+ h += c->h;
+ if (mh - c->h > 0)
+ mhfrac += mh - c->h;
+ }
+ if (hfrac > GRUB_FIXED_1 || (h > 0 && hfrac == GRUB_FIXED_1))
+ bogus_frac = 1;
+
+ if (min_height)
+ {
+ if (hfrac < GRUB_FIXED_1)
+ *min_height = grub_fixed_sfs_divide (h, GRUB_FIXED_1 - hfrac);
+ else
+ *min_height = h;
+ if (*min_height < h + mhfrac)
+ *min_height = h + mhfrac;
+ }
+ if (min_width)
+ *min_width = w;
+
+ if (!modify_layout)
+ return;
+
+ for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
+ {
+ grub_video_rect_t r;
+ grub_gui_component_t c = cur->component;
+ unsigned mw = 0, mh = 0;
+
+ r.x = 0;
+ r.y = y;
+ r.width = w;
+
+ if (c->ops->get_minimal_size)
+ c->ops->get_minimal_size (c, &mw, &mh);
+
+ r.height = c->h;
+ if (!bogus_frac)
+ r.height += grub_fixed_sfs_multiply (self->bounds.height, c->hfrac);
+
+ if (r.height < mh)
+ r.height = mh;
+
+ c->ops->set_bounds (c, &r);
+
+ y += r.height;
+ }
+}
+
+static void
+box_paint (void *vself, const grub_video_rect_t *region)
+{
+ grub_gui_box_t self = vself;
+
+ struct component_node *cur;
+ grub_video_rect_t vpsave;
+
+ grub_video_area_status_t box_area_status;
+ grub_video_get_area_status (&box_area_status);
+
+ grub_gui_set_viewport (&self->bounds, &vpsave);
+ for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
+ {
+ grub_gui_component_t comp = cur->component;
+ grub_video_rect_t r;
+ comp->ops->get_bounds(comp, &r);
+
+ if (!grub_video_have_common_points (region, &r))
+ continue;
+
+ /* Paint the child. */
+ if (box_area_status == GRUB_VIDEO_AREA_ENABLED
+ && grub_video_bounds_inside_region (&r, region))
+ grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
+ comp->ops->paint (comp, region);
+ if (box_area_status == GRUB_VIDEO_AREA_ENABLED)
+ grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
+ }
+ grub_gui_restore_viewport (&vpsave);
+}
+
+static void
+box_set_parent (void *vself, grub_gui_container_t parent)
+{
+ grub_gui_box_t self = vself;
+ self->parent = parent;
+}
+
+static grub_gui_container_t
+box_get_parent (void *vself)
+{
+ grub_gui_box_t self = vself;
+ return self->parent;
+}
+
+static void
+box_set_bounds (void *vself, const grub_video_rect_t *bounds)
+{
+ grub_gui_box_t self = vself;
+ self->bounds = *bounds;
+ self->layout_func (self, 1, 0, 0); /* Relayout the children. */
+}
+
+static void
+box_get_bounds (void *vself, grub_video_rect_t *bounds)
+{
+ grub_gui_box_t self = vself;
+ *bounds = self->bounds;
+}
+
+/* The box's preferred size is based on the preferred sizes
+ of its children. */
+static void
+box_get_minimal_size (void *vself, unsigned *width, unsigned *height)
+{
+ grub_gui_box_t self = vself;
+ self->layout_func (self, 0, width, height); /* Just calculate the size. */
+}
+
+static grub_err_t
+box_set_property (void *vself, const char *name, const char *value)
+{
+ grub_gui_box_t self = vself;
+ if (grub_strcmp (name, "id") == 0)
+ {
+ grub_free (self->id);
+ if (value)
+ {
+ self->id = grub_strdup (value);
+ if (! self->id)
+ return grub_errno;
+ }
+ else
+ self->id = 0;
+ }
+
+ return grub_errno;
+}
+
+static void
+box_add (void *vself, grub_gui_component_t comp)
+{
+ grub_gui_box_t self = vself;
+ struct component_node *node;
+ node = grub_malloc (sizeof (*node));
+ if (! node)
+ return; /* Note: probably should handle the error. */
+ node->component = comp;
+ /* Insert the node before the tail. */
+ node->prev = self->ctail.prev;
+ node->prev->next = node;
+ node->next = &self->ctail;
+ node->next->prev = node;
+
+ comp->ops->set_parent (comp, (grub_gui_container_t) self);
+ self->layout_func (self, 1, 0, 0); /* Relayout the children. */
+}
+
+static void
+box_remove (void *vself, grub_gui_component_t comp)
+{
+ grub_gui_box_t self = vself;
+ struct component_node *cur;
+ for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
+ {
+ if (cur->component == comp)
+ {
+ /* Unlink 'cur' from the list. */
+ cur->prev->next = cur->next;
+ cur->next->prev = cur->prev;
+ /* Free the node's memory (but don't destroy the component). */
+ grub_free (cur);
+ /* Must not loop again, since 'cur' would be dereferenced! */
+ return;
+ }
+ }
+}
+
+static void
+box_iterate_children (void *vself,
+ grub_gui_component_callback cb, void *userdata)
+{
+ grub_gui_box_t self = vself;
+ struct component_node *cur;
+ for (cur = self->chead.next; cur != &self->ctail; cur = cur->next)
+ cb (cur->component, userdata);
+}
+
+static struct grub_gui_component_ops box_comp_ops =
+ {
+ .destroy = box_destroy,
+ .get_id = box_get_id,
+ .is_instance = box_is_instance,
+ .paint = box_paint,
+ .set_parent = box_set_parent,
+ .get_parent = box_get_parent,
+ .set_bounds = box_set_bounds,
+ .get_bounds = box_get_bounds,
+ .get_minimal_size = box_get_minimal_size,
+ .set_property = box_set_property
+ };
+
+static struct grub_gui_container_ops box_ops =
+{
+ .add = box_add,
+ .remove = box_remove,
+ .iterate_children = box_iterate_children
+};
+
+/* Box constructor. Specify the appropriate layout function to create
+ a horizontal or vertical stacking box. */
+static grub_gui_box_t
+box_new (layout_func_t layout_func)
+{
+ grub_gui_box_t box;
+ box = grub_zalloc (sizeof (*box));
+ if (! box)
+ return 0;
+ box->container.ops = &box_ops;
+ box->container.component.ops = &box_comp_ops;
+ box->chead.next = &box->ctail;
+ box->ctail.prev = &box->chead;
+ box->layout_func = layout_func;
+ return box;
+}
+
+/* Create a new container that stacks its child components horizontally,
+ from left to right. Each child get a width corresponding to its
+ preferred width. The height of each child is set the maximum of the
+ preferred heights of all children. */
+grub_gui_container_t
+grub_gui_hbox_new (void)
+{
+ return (grub_gui_container_t) box_new (layout_horizontally);
+}
+
+/* Create a new container that stacks its child components verticallyj,
+ from top to bottom. Each child get a height corresponding to its
+ preferred height. The width of each child is set the maximum of the
+ preferred widths of all children. */
+grub_gui_container_t
+grub_gui_vbox_new (void)
+{
+ return (grub_gui_container_t) box_new (layout_vertically);
+}
diff --git a/grub-core/gfxmenu/gui_canvas.c b/grub-core/gfxmenu/gui_canvas.c
new file mode 100644
index 0000000..a054912
--- /dev/null
+++ b/grub-core/gfxmenu/gui_canvas.c
@@ -0,0 +1,278 @@
+/* gui_canvas.c - GUI container allowing manually placed components. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/gui.h>
+#include <grub/gui_string_util.h>
+
+/* TODO Add layering so that components can be properly overlaid. */
+
+struct component_node
+{
+ grub_gui_component_t component;
+ struct component_node *next;
+};
+
+struct grub_gui_canvas
+{
+ struct grub_gui_container container;
+
+ grub_gui_container_t parent;
+ grub_video_rect_t bounds;
+ char *id;
+ /* Component list (dummy head node). */
+ struct component_node components;
+};
+
+typedef struct grub_gui_canvas *grub_gui_canvas_t;
+
+static void
+canvas_destroy (void *vself)
+{
+ grub_gui_canvas_t self = vself;
+ struct component_node *cur;
+ struct component_node *next;
+ for (cur = self->components.next; cur; cur = next)
+ {
+ /* Copy the 'next' pointer, since we need it for the next iteration,
+ and we're going to free the memory it is stored in. */
+ next = cur->next;
+ /* Destroy the child component. */
+ cur->component->ops->destroy (cur->component);
+ /* Free the linked list node. */
+ grub_free (cur);
+ }
+ grub_free (self);
+}
+
+static const char *
+canvas_get_id (void *vself)
+{
+ grub_gui_canvas_t self = vself;
+ return self->id;
+}
+
+static int
+canvas_is_instance (void *vself __attribute__((unused)), const char *type)
+{
+ return (grub_strcmp (type, "component") == 0
+ || grub_strcmp (type, "container") == 0);
+}
+
+static void
+canvas_paint (void *vself, const grub_video_rect_t *region)
+{
+ grub_gui_canvas_t self = vself;
+
+ struct component_node *cur;
+ grub_video_rect_t vpsave;
+
+ grub_video_area_status_t canvas_area_status;
+ grub_video_get_area_status (&canvas_area_status);
+
+ grub_gui_set_viewport (&self->bounds, &vpsave);
+ for (cur = self->components.next; cur; cur = cur->next)
+ {
+ grub_video_rect_t r;
+ grub_gui_component_t comp;
+ signed x, y, w, h;
+
+ comp = cur->component;
+
+ w = grub_fixed_sfs_multiply (self->bounds.width, comp->wfrac) + comp->w;
+ h = grub_fixed_sfs_multiply (self->bounds.height, comp->hfrac) + comp->h;
+ x = grub_fixed_sfs_multiply (self->bounds.width, comp->xfrac) + comp->x;
+ y = grub_fixed_sfs_multiply (self->bounds.height, comp->yfrac) + comp->y;
+
+ if (comp->ops->get_minimal_size)
+ {
+ unsigned mw;
+ unsigned mh;
+ comp->ops->get_minimal_size (comp, &mw, &mh);
+ if (w < (signed) mw)
+ w = mw;
+ if (h < (signed) mh)
+ h = mh;
+ }
+
+ /* Sanity checks. */
+ if (w <= 0)
+ w = 32;
+ if (h <= 0)
+ h = 32;
+
+ if (x >= (signed) self->bounds.width)
+ x = self->bounds.width - 32;
+ if (y >= (signed) self->bounds.height)
+ y = self->bounds.height - 32;
+
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+
+ if (x + w >= (signed) self->bounds.width)
+ w = self->bounds.width - x;
+ if (y + h >= (signed) self->bounds.height)
+ h = self->bounds.height - y;
+
+ r.x = x;
+ r.y = y;
+ r.width = w;
+ r.height = h;
+ comp->ops->set_bounds (comp, &r);
+
+ if (!grub_video_have_common_points (region, &r))
+ continue;
+
+ /* Paint the child. */
+ if (canvas_area_status == GRUB_VIDEO_AREA_ENABLED
+ && grub_video_bounds_inside_region (&r, region))
+ grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
+ comp->ops->paint (comp, region);
+ if (canvas_area_status == GRUB_VIDEO_AREA_ENABLED)
+ grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
+ }
+ grub_gui_restore_viewport (&vpsave);
+}
+
+static void
+canvas_set_parent (void *vself, grub_gui_container_t parent)
+{
+ grub_gui_canvas_t self = vself;
+ self->parent = parent;
+}
+
+static grub_gui_container_t
+canvas_get_parent (void *vself)
+{
+ grub_gui_canvas_t self = vself;
+ return self->parent;
+}
+
+static void
+canvas_set_bounds (void *vself, const grub_video_rect_t *bounds)
+{
+ grub_gui_canvas_t self = vself;
+ self->bounds = *bounds;
+}
+
+static void
+canvas_get_bounds (void *vself, grub_video_rect_t *bounds)
+{
+ grub_gui_canvas_t self = vself;
+ *bounds = self->bounds;
+}
+
+static grub_err_t
+canvas_set_property (void *vself, const char *name, const char *value)
+{
+ grub_gui_canvas_t self = vself;
+ if (grub_strcmp (name, "id") == 0)
+ {
+ grub_free (self->id);
+ if (value)
+ {
+ self->id = grub_strdup (value);
+ if (! self->id)
+ return grub_errno;
+ }
+ else
+ self->id = 0;
+ }
+ return grub_errno;
+}
+
+static void
+canvas_add (void *vself, grub_gui_component_t comp)
+{
+ grub_gui_canvas_t self = vself;
+ struct component_node *node;
+ node = grub_malloc (sizeof (*node));
+ if (! node)
+ return; /* Note: probably should handle the error. */
+ node->component = comp;
+ node->next = self->components.next;
+ self->components.next = node;
+ comp->ops->set_parent (comp, (grub_gui_container_t) self);
+}
+
+static void
+canvas_remove (void *vself, grub_gui_component_t comp)
+{
+ grub_gui_canvas_t self = vself;
+ struct component_node *cur;
+ struct component_node *prev;
+ prev = &self->components;
+ for (cur = self->components.next; cur; prev = cur, cur = cur->next)
+ {
+ if (cur->component == comp)
+ {
+ /* Unlink 'cur' from the list. */
+ prev->next = cur->next;
+ /* Free the node's memory (but don't destroy the component). */
+ grub_free (cur);
+ /* Must not loop again, since 'cur' would be dereferenced! */
+ return;
+ }
+ }
+}
+
+static void
+canvas_iterate_children (void *vself,
+ grub_gui_component_callback cb, void *userdata)
+{
+ grub_gui_canvas_t self = vself;
+ struct component_node *cur;
+ for (cur = self->components.next; cur; cur = cur->next)
+ cb (cur->component, userdata);
+}
+
+static struct grub_gui_component_ops canvas_comp_ops =
+{
+ .destroy = canvas_destroy,
+ .get_id = canvas_get_id,
+ .is_instance = canvas_is_instance,
+ .paint = canvas_paint,
+ .set_parent = canvas_set_parent,
+ .get_parent = canvas_get_parent,
+ .set_bounds = canvas_set_bounds,
+ .get_bounds = canvas_get_bounds,
+ .set_property = canvas_set_property
+};
+
+static struct grub_gui_container_ops canvas_ops =
+{
+ .add = canvas_add,
+ .remove = canvas_remove,
+ .iterate_children = canvas_iterate_children
+};
+
+grub_gui_container_t
+grub_gui_canvas_new (void)
+{
+ grub_gui_canvas_t canvas;
+ canvas = grub_zalloc (sizeof (*canvas));
+ if (! canvas)
+ return 0;
+ canvas->container.ops = &canvas_ops;
+ canvas->container.component.ops = &canvas_comp_ops;
+ return (grub_gui_container_t) canvas;
+}
diff --git a/grub-core/gfxmenu/gui_circular_progress.c b/grub-core/gfxmenu/gui_circular_progress.c
new file mode 100644
index 0000000..7578bfb
--- /dev/null
+++ b/grub-core/gfxmenu/gui_circular_progress.c
@@ -0,0 +1,331 @@
+/* gui_circular_process.c - GUI circular progress indicator component. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/gui.h>
+#include <grub/font.h>
+#include <grub/gui_string_util.h>
+#include <grub/gfxmenu_view.h>
+#include <grub/gfxwidgets.h>
+#include <grub/trig.h>
+
+struct grub_gui_circular_progress
+{
+ struct grub_gui_progress progress;
+
+ grub_gui_container_t parent;
+ grub_video_rect_t bounds;
+ char *id;
+ int visible;
+ int start;
+ int end;
+ int value;
+ unsigned num_ticks;
+ int start_angle;
+ int ticks_disappear;
+ char *theme_dir;
+ int need_to_load_pixmaps;
+ char *center_file;
+ char *tick_file;
+ struct grub_video_bitmap *center_bitmap;
+ struct grub_video_bitmap *tick_bitmap;
+};
+
+typedef struct grub_gui_circular_progress *circular_progress_t;
+
+static void
+circprog_destroy (void *vself)
+{
+ circular_progress_t self = vself;
+ grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
+ grub_free (self);
+}
+
+static const char *
+circprog_get_id (void *vself)
+{
+ circular_progress_t self = vself;
+ return self->id;
+}
+
+static int
+circprog_is_instance (void *vself __attribute__((unused)), const char *type)
+{
+ return grub_strcmp (type, "component") == 0;
+}
+
+static struct grub_video_bitmap *
+load_bitmap (const char *dir, const char *file)
+{
+ struct grub_video_bitmap *bitmap;
+ char *abspath;
+
+ /* Check arguments. */
+ if (! dir || ! file)
+ return 0;
+
+ /* Resolve to an absolute path. */
+ abspath = grub_resolve_relative_path (dir, file);
+ if (! abspath)
+ return 0;
+
+ /* Load the image. */
+ grub_errno = GRUB_ERR_NONE;
+ grub_video_bitmap_load (&bitmap, abspath);
+ grub_errno = GRUB_ERR_NONE;
+
+ grub_free (abspath);
+ return bitmap;
+}
+
+static int
+check_pixmaps (circular_progress_t self)
+{
+ if (self->need_to_load_pixmaps)
+ {
+ if (self->center_bitmap)
+ grub_video_bitmap_destroy (self->center_bitmap);
+ self->center_bitmap = load_bitmap (self->theme_dir, self->center_file);
+ self->tick_bitmap = load_bitmap (self->theme_dir, self->tick_file);
+ self->need_to_load_pixmaps = 0;
+ }
+
+ return (self->center_bitmap != 0 && self->tick_bitmap != 0);
+}
+
+static void
+circprog_paint (void *vself, const grub_video_rect_t *region)
+{
+ circular_progress_t self = vself;
+
+ if (! self->visible)
+ return;
+
+ if (!grub_video_have_common_points (region, &self->bounds))
+ return;
+
+ if (! check_pixmaps (self))
+ return;
+
+ grub_video_rect_t vpsave;
+ grub_gui_set_viewport (&self->bounds, &vpsave);
+
+ int width = self->bounds.width;
+ int height = self->bounds.height;
+ int center_width = grub_video_bitmap_get_width (self->center_bitmap);
+ int center_height = grub_video_bitmap_get_height (self->center_bitmap);
+ int tick_width = grub_video_bitmap_get_width (self->tick_bitmap);
+ int tick_height = grub_video_bitmap_get_height (self->tick_bitmap);
+ grub_video_blit_bitmap (self->center_bitmap, GRUB_VIDEO_BLIT_BLEND,
+ (width - center_width) / 2,
+ (height - center_height) / 2, 0, 0,
+ center_width, center_height);
+
+ if (self->num_ticks)
+ {
+ 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);
+}
+
+static void
+circprog_set_parent (void *vself, grub_gui_container_t parent)
+{
+ circular_progress_t self = vself;
+ self->parent = parent;
+}
+
+static grub_gui_container_t
+circprog_get_parent (void *vself)
+{
+ circular_progress_t self = vself;
+ return self->parent;
+}
+
+static void
+circprog_set_bounds (void *vself, const grub_video_rect_t *bounds)
+{
+ circular_progress_t self = vself;
+ self->bounds = *bounds;
+}
+
+static void
+circprog_get_bounds (void *vself, grub_video_rect_t *bounds)
+{
+ circular_progress_t self = vself;
+ *bounds = self->bounds;
+}
+
+static void
+circprog_set_state (void *vself, int visible, int start,
+ int current, int end)
+{
+ circular_progress_t self = vself;
+ self->visible = visible;
+ self->start = start;
+ self->value = current;
+ self->end = end;
+}
+
+static int
+parse_angle (const char *value)
+{
+ const char *ptr;
+ int angle;
+
+ angle = grub_strtol (value, &ptr, 10);
+ if (grub_errno)
+ return 0;
+ while (grub_isspace (*ptr))
+ ptr++;
+ if (grub_strcmp (ptr, "deg") == 0
+ /* Unicode symbol of degrees (a circle, U+b0). Put here in UTF-8 to
+ avoid potential problem with text file reesncoding */
+ || grub_strcmp (ptr, "\xc2\xb0") == 0)
+ angle = grub_divide_round (angle * 64, 90);
+ return angle;
+}
+
+static grub_err_t
+circprog_set_property (void *vself, const char *name, const char *value)
+{
+ circular_progress_t self = vself;
+ if (grub_strcmp (name, "num_ticks") == 0)
+ {
+ self->num_ticks = grub_strtoul (value, 0, 10);
+ }
+ else if (grub_strcmp (name, "start_angle") == 0)
+ {
+ self->start_angle = parse_angle (value);
+ }
+ else if (grub_strcmp (name, "ticks_disappear") == 0)
+ {
+ self->ticks_disappear = grub_strcmp (value, "false") != 0;
+ }
+ else if (grub_strcmp (name, "center_bitmap") == 0)
+ {
+ self->need_to_load_pixmaps = 1;
+ grub_free (self->center_file);
+ self->center_file = value ? grub_strdup (value) : 0;
+ }
+ else if (grub_strcmp (name, "tick_bitmap") == 0)
+ {
+ self->need_to_load_pixmaps = 1;
+ grub_free (self->tick_file);
+ self->tick_file = value ? grub_strdup (value) : 0;
+ }
+ else if (grub_strcmp (name, "theme_dir") == 0)
+ {
+ self->need_to_load_pixmaps = 1;
+ grub_free (self->theme_dir);
+ self->theme_dir = value ? grub_strdup (value) : 0;
+ }
+ else if (grub_strcmp (name, "id") == 0)
+ {
+ grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
+ grub_free (self->id);
+ if (value)
+ self->id = grub_strdup (value);
+ else
+ self->id = 0;
+ if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
+ == 0)
+ grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
+ circprog_set_state);
+ }
+ return grub_errno;
+}
+
+static struct grub_gui_component_ops circprog_ops =
+{
+ .destroy = circprog_destroy,
+ .get_id = circprog_get_id,
+ .is_instance = circprog_is_instance,
+ .paint = circprog_paint,
+ .set_parent = circprog_set_parent,
+ .get_parent = circprog_get_parent,
+ .set_bounds = circprog_set_bounds,
+ .get_bounds = circprog_get_bounds,
+ .set_property = circprog_set_property
+};
+
+static struct grub_gui_progress_ops circprog_prog_ops =
+ {
+ .set_state = circprog_set_state
+ };
+
+grub_gui_component_t
+grub_gui_circular_progress_new (void)
+{
+ circular_progress_t self;
+ self = grub_zalloc (sizeof (*self));
+ if (! self)
+ return 0;
+ self->progress.ops = &circprog_prog_ops;
+ self->progress.component.ops = &circprog_ops;
+ self->visible = 1;
+ self->num_ticks = 64;
+ self->start_angle = -64;
+
+ return (grub_gui_component_t) self;
+}
diff --git a/grub-core/gfxmenu/gui_image.c b/grub-core/gfxmenu/gui_image.c
new file mode 100644
index 0000000..6b2e976
--- /dev/null
+++ b/grub-core/gfxmenu/gui_image.c
@@ -0,0 +1,270 @@
+/* gui_image.c - GUI component to display an image. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/gui.h>
+#include <grub/gui_string_util.h>
+#include <grub/bitmap.h>
+#include <grub/bitmap_scale.h>
+
+struct grub_gui_image
+{
+ struct grub_gui_component component;
+
+ grub_gui_container_t parent;
+ grub_video_rect_t bounds;
+ char *id;
+ char *theme_dir;
+ struct grub_video_bitmap *raw_bitmap;
+ struct grub_video_bitmap *bitmap;
+};
+
+typedef struct grub_gui_image *grub_gui_image_t;
+
+static void
+image_destroy (void *vself)
+{
+ grub_gui_image_t self = vself;
+
+ /* Free the scaled bitmap, unless it's a reference to the raw bitmap. */
+ if (self->bitmap && (self->bitmap != self->raw_bitmap))
+ grub_video_bitmap_destroy (self->bitmap);
+ if (self->raw_bitmap)
+ grub_video_bitmap_destroy (self->raw_bitmap);
+
+ grub_free (self);
+}
+
+static const char *
+image_get_id (void *vself)
+{
+ grub_gui_image_t self = vself;
+ return self->id;
+}
+
+static int
+image_is_instance (void *vself __attribute__((unused)), const char *type)
+{
+ return grub_strcmp (type, "component") == 0;
+}
+
+static void
+image_paint (void *vself, const grub_video_rect_t *region)
+{
+ grub_gui_image_t self = vself;
+ grub_video_rect_t vpsave;
+
+ if (! self->bitmap)
+ return;
+ if (!grub_video_have_common_points (region, &self->bounds))
+ return;
+
+ grub_gui_set_viewport (&self->bounds, &vpsave);
+ grub_video_blit_bitmap (self->bitmap, GRUB_VIDEO_BLIT_BLEND,
+ 0, 0, 0, 0,
+ grub_video_bitmap_get_width (self->bitmap),
+ grub_video_bitmap_get_height (self->bitmap));
+ grub_gui_restore_viewport (&vpsave);
+}
+
+static void
+image_set_parent (void *vself, grub_gui_container_t parent)
+{
+ grub_gui_image_t self = vself;
+ self->parent = parent;
+}
+
+static grub_gui_container_t
+image_get_parent (void *vself)
+{
+ grub_gui_image_t self = vself;
+ return self->parent;
+}
+
+static grub_err_t
+rescale_image (grub_gui_image_t self)
+{
+ signed width;
+ signed height;
+
+ if (! self->raw_bitmap)
+ {
+ if (self->bitmap)
+ {
+ grub_video_bitmap_destroy (self->bitmap);
+ self->bitmap = 0;
+ }
+ return grub_errno;
+ }
+
+ width = self->bounds.width;
+ height = self->bounds.height;
+
+ if (self->bitmap
+ && ((signed) grub_video_bitmap_get_width (self->bitmap) == width)
+ && ((signed) grub_video_bitmap_get_height (self->bitmap) == height))
+ {
+ /* Nothing to do; already the right size. */
+ return grub_errno;
+ }
+
+ /* Free any old scaled bitmap,
+ *unless* it's a reference to the raw bitmap. */
+ if (self->bitmap && (self->bitmap != self->raw_bitmap))
+ grub_video_bitmap_destroy (self->bitmap);
+
+ self->bitmap = 0;
+
+ /* Create a scaled bitmap, unless the requested size is the same
+ as the raw size -- in that case a reference is made. */
+ if ((signed) grub_video_bitmap_get_width (self->raw_bitmap) == width
+ && (signed) grub_video_bitmap_get_height (self->raw_bitmap) == height)
+ {
+ self->bitmap = self->raw_bitmap;
+ return grub_errno;
+ }
+
+ /* Don't scale to an invalid size. */
+ if (width <= 0 || height <= 0)
+ return grub_errno;
+
+ /* Create the scaled bitmap. */
+ grub_video_bitmap_create_scaled (&self->bitmap,
+ width,
+ height,
+ self->raw_bitmap,
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
+ return grub_errno;
+}
+
+static void
+image_set_bounds (void *vself, const grub_video_rect_t *bounds)
+{
+ grub_gui_image_t self = vself;
+ self->bounds = *bounds;
+ rescale_image (self);
+}
+
+static void
+image_get_bounds (void *vself, grub_video_rect_t *bounds)
+{
+ grub_gui_image_t self = vself;
+ *bounds = self->bounds;
+}
+
+/* FIXME: inform rendering system it's not forced minimum. */
+static void
+image_get_minimal_size (void *vself, unsigned *width, unsigned *height)
+{
+ grub_gui_image_t self = vself;
+
+ if (self->raw_bitmap)
+ {
+ *width = grub_video_bitmap_get_width (self->raw_bitmap);
+ *height = grub_video_bitmap_get_height (self->raw_bitmap);
+ }
+ else
+ {
+ *width = 0;
+ *height = 0;
+ }
+}
+
+static grub_err_t
+load_image (grub_gui_image_t self, const char *path)
+{
+ struct grub_video_bitmap *bitmap;
+ if (grub_video_bitmap_load (&bitmap, path) != GRUB_ERR_NONE)
+ return grub_errno;
+
+ if (self->bitmap && (self->bitmap != self->raw_bitmap))
+ {
+ grub_video_bitmap_destroy (self->bitmap);
+ self->bitmap = 0;
+ }
+ if (self->raw_bitmap)
+ grub_video_bitmap_destroy (self->raw_bitmap);
+
+ self->raw_bitmap = bitmap;
+ return rescale_image (self);
+}
+
+static grub_err_t
+image_set_property (void *vself, const char *name, const char *value)
+{
+ grub_gui_image_t self = vself;
+ if (grub_strcmp (name, "theme_dir") == 0)
+ {
+ grub_free (self->theme_dir);
+ self->theme_dir = grub_strdup (value);
+ }
+ else if (grub_strcmp (name, "file") == 0)
+ {
+ char *absvalue;
+ grub_err_t err;
+
+ /* Resolve to an absolute path. */
+ if (! self->theme_dir)
+ return grub_error (GRUB_ERR_BUG, "unspecified theme_dir");
+ absvalue = grub_resolve_relative_path (self->theme_dir, value);
+ if (! absvalue)
+ return grub_errno;
+
+ err = load_image (self, absvalue);
+ grub_free (absvalue);
+
+ return err;
+ }
+ else if (grub_strcmp (name, "id") == 0)
+ {
+ grub_free (self->id);
+ if (value)
+ self->id = grub_strdup (value);
+ else
+ self->id = 0;
+ }
+ return grub_errno;
+}
+
+static struct grub_gui_component_ops image_ops =
+{
+ .destroy = image_destroy,
+ .get_id = image_get_id,
+ .is_instance = image_is_instance,
+ .paint = image_paint,
+ .set_parent = image_set_parent,
+ .get_parent = image_get_parent,
+ .set_bounds = image_set_bounds,
+ .get_bounds = image_get_bounds,
+ .get_minimal_size = image_get_minimal_size,
+ .set_property = image_set_property
+};
+
+grub_gui_component_t
+grub_gui_image_new (void)
+{
+ grub_gui_image_t image;
+ image = grub_zalloc (sizeof (*image));
+ if (! image)
+ return 0;
+ image->component.ops = &image_ops;
+ return (grub_gui_component_t) image;
+}
+
diff --git a/grub-core/gfxmenu/gui_label.c b/grub-core/gfxmenu/gui_label.c
new file mode 100644
index 0000000..1c19054
--- /dev/null
+++ b/grub-core/gfxmenu/gui_label.c
@@ -0,0 +1,277 @@
+/* gui_label.c - GUI component to display a line of text. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/gui.h>
+#include <grub/font.h>
+#include <grub/gui_string_util.h>
+#include <grub/i18n.h>
+#include <grub/color.h>
+
+static const char *align_options[] =
+{
+ "left",
+ "center",
+ "right",
+ 0
+};
+
+enum align_mode {
+ align_left,
+ align_center,
+ align_right
+};
+
+struct grub_gui_label
+{
+ struct grub_gui_component comp;
+
+ grub_gui_container_t parent;
+ grub_video_rect_t bounds;
+ char *id;
+ int visible;
+ char *text;
+ char *template;
+ grub_font_t font;
+ grub_video_rgba_color_t color;
+ int value;
+ enum align_mode align;
+};
+
+typedef struct grub_gui_label *grub_gui_label_t;
+
+static void
+label_destroy (void *vself)
+{
+ grub_gui_label_t self = vself;
+ grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
+ grub_free (self->text);
+ grub_free (self->template);
+ grub_free (self);
+}
+
+static const char *
+label_get_id (void *vself)
+{
+ grub_gui_label_t self = vself;
+ return self->id;
+}
+
+static int
+label_is_instance (void *vself __attribute__((unused)), const char *type)
+{
+ return grub_strcmp (type, "component") == 0;
+}
+
+static void
+label_paint (void *vself, const grub_video_rect_t *region)
+{
+ grub_gui_label_t self = vself;
+
+ if (! self->visible)
+ return;
+
+ if (!grub_video_have_common_points (region, &self->bounds))
+ return;
+
+ /* Calculate the starting x coordinate. */
+ int left_x;
+ if (self->align == align_left)
+ left_x = 0;
+ else if (self->align == align_center)
+ left_x = (self->bounds.width
+ - grub_font_get_string_width (self->font, self->text)) / 2;
+ else if (self->align == align_right)
+ left_x = (self->bounds.width
+ - grub_font_get_string_width (self->font, self->text));
+ else
+ return; /* Invalid alignment. */
+
+ if (left_x < 0 || left_x > (int) self->bounds.width)
+ left_x = 0;
+
+ grub_video_rect_t vpsave;
+ grub_gui_set_viewport (&self->bounds, &vpsave);
+ grub_font_draw_string (self->text,
+ self->font,
+ grub_video_map_rgba_color (self->color),
+ left_x,
+ grub_font_get_ascent (self->font));
+ grub_gui_restore_viewport (&vpsave);
+}
+
+static void
+label_set_parent (void *vself, grub_gui_container_t parent)
+{
+ grub_gui_label_t self = vself;
+ self->parent = parent;
+}
+
+static grub_gui_container_t
+label_get_parent (void *vself)
+{
+ grub_gui_label_t self = vself;
+ return self->parent;
+}
+
+static void
+label_set_bounds (void *vself, const grub_video_rect_t *bounds)
+{
+ grub_gui_label_t self = vself;
+ self->bounds = *bounds;
+}
+
+static void
+label_get_bounds (void *vself, grub_video_rect_t *bounds)
+{
+ grub_gui_label_t self = vself;
+ *bounds = self->bounds;
+}
+
+static void
+label_get_minimal_size (void *vself, unsigned *width, unsigned *height)
+{
+ grub_gui_label_t self = vself;
+ *width = grub_font_get_string_width (self->font, self->text);
+ *height = (grub_font_get_ascent (self->font)
+ + 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)))
+{
+ grub_gui_label_t self = vself;
+ self->value = -current;
+ self->visible = visible;
+ grub_free (self->text);
+ self->text = grub_xasprintf (self->template ? : "%d", self->value);
+}
+
+static grub_err_t
+label_set_property (void *vself, const char *name, const char *value)
+{
+ grub_gui_label_t self = vself;
+ if (grub_strcmp (name, "text") == 0)
+ {
+ grub_free (self->text);
+ grub_free (self->template);
+ if (! value)
+ {
+ self->template = NULL;
+ self->text = grub_strdup ("");
+ }
+ else
+ {
+ if (grub_strcmp (value, "@KEYMAP_LONG@") == 0)
+ value = _("Press enter to boot the selected OS, "
+ "`e' to edit the commands before booting "
+ "or `c' for a command-line. ESC to return previous menu.");
+ else if (grub_strcmp (value, "@KEYMAP_MIDDLE@") == 0)
+ value = _("Press enter to boot the selected OS, "
+ "`e' to edit the commands before booting "
+ "or `c' for a command-line.");
+ else if (grub_strcmp (value, "@KEYMAP_SHORT@") == 0)
+ value = _("enter: boot, `e': options, `c': cmd-line");
+ /* FIXME: Add more templates here if needed. */
+
+ if (grub_printf_fmt_check(value, "%d") != GRUB_ERR_NONE)
+ value = ""; /* Unsupported format. */
+
+ self->template = grub_strdup (value);
+ self->text = grub_xasprintf (value, self->value);
+ }
+ }
+ else if (grub_strcmp (name, "font") == 0)
+ {
+ self->font = grub_font_get (value);
+ }
+ else if (grub_strcmp (name, "color") == 0)
+ {
+ grub_video_parse_color (value, &self->color);
+ }
+ else if (grub_strcmp (name, "align") == 0)
+ {
+ int i;
+ for (i = 0; align_options[i]; i++)
+ {
+ if (grub_strcmp (align_options[i], value) == 0)
+ {
+ self->align = i; /* Set the alignment mode. */
+ break;
+ }
+ }
+ }
+ else if (grub_strcmp (name, "visible") == 0)
+ {
+ self->visible = grub_strcmp (value, "false") != 0;
+ }
+ else if (grub_strcmp (name, "id") == 0)
+ {
+ grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
+ grub_free (self->id);
+ if (value)
+ self->id = grub_strdup (value);
+ else
+ self->id = 0;
+ if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
+ == 0)
+ grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
+ label_set_state);
+ }
+ return GRUB_ERR_NONE;
+}
+
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
+static struct grub_gui_component_ops label_ops =
+{
+ .destroy = label_destroy,
+ .get_id = label_get_id,
+ .is_instance = label_is_instance,
+ .paint = label_paint,
+ .set_parent = label_set_parent,
+ .get_parent = label_get_parent,
+ .set_bounds = label_set_bounds,
+ .get_bounds = label_get_bounds,
+ .get_minimal_size = label_get_minimal_size,
+ .set_property = label_set_property
+};
+
+grub_gui_component_t
+grub_gui_label_new (void)
+{
+ grub_gui_label_t label;
+ label = grub_zalloc (sizeof (*label));
+ if (! label)
+ return 0;
+ label->comp.ops = &label_ops;
+ label->visible = 1;
+ label->text = grub_strdup ("");
+ label->font = grub_font_get ("Unknown Regular 16");
+ label->color.red = 0;
+ label->color.green = 0;
+ label->color.blue = 0;
+ label->color.alpha = 255;
+ label->align = align_left;
+ return (grub_gui_component_t) label;
+}
diff --git a/grub-core/gfxmenu/gui_list.c b/grub-core/gfxmenu/gui_list.c
new file mode 100644
index 0000000..df334a6
--- /dev/null
+++ b/grub-core/gfxmenu/gui_list.c
@@ -0,0 +1,953 @@
+/* gui_list.c - GUI component to display a selectable list of items. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/gui.h>
+#include <grub/gui_string_util.h>
+#include <grub/gfxmenu_view.h>
+#include <grub/gfxwidgets.h>
+#include <grub/color.h>
+
+enum scrollbar_slice_mode {
+ SCROLLBAR_SLICE_WEST,
+ SCROLLBAR_SLICE_CENTER,
+ SCROLLBAR_SLICE_EAST
+};
+
+struct grub_gui_list_impl
+{
+ struct grub_gui_list list;
+
+ grub_gui_container_t parent;
+ grub_video_rect_t bounds;
+ char *id;
+ int visible;
+
+ int icon_width;
+ int icon_height;
+ int item_height;
+ int item_padding;
+ int item_icon_space;
+ int item_spacing;
+ grub_font_t item_font;
+ int selected_item_font_inherit;
+ grub_font_t selected_item_font;
+ grub_video_rgba_color_t item_color;
+ int selected_item_color_inherit;
+ grub_video_rgba_color_t selected_item_color;
+
+ int draw_scrollbar;
+ int need_to_recreate_scrollbar;
+ char *scrollbar_frame_pattern;
+ char *scrollbar_thumb_pattern;
+ grub_gfxmenu_box_t scrollbar_frame;
+ grub_gfxmenu_box_t scrollbar_thumb;
+ int scrollbar_thumb_overlay;
+ int scrollbar_width;
+ enum scrollbar_slice_mode scrollbar_slice;
+ int scrollbar_left_pad;
+ int scrollbar_right_pad;
+ int scrollbar_top_pad;
+ int scrollbar_bottom_pad;
+
+ int first_shown_index;
+
+ int need_to_recreate_boxes;
+ char *theme_dir;
+ char *menu_box_pattern;
+ char *item_box_pattern;
+ int selected_item_box_pattern_inherit;
+ char *selected_item_box_pattern;
+ grub_gfxmenu_box_t menu_box;
+ grub_gfxmenu_box_t selected_item_box;
+ grub_gfxmenu_box_t item_box;
+
+ grub_gfxmenu_icon_manager_t icon_manager;
+
+ grub_gfxmenu_view_t view;
+};
+
+typedef struct grub_gui_list_impl *list_impl_t;
+
+static void
+list_destroy (void *vself)
+{
+ list_impl_t self = vself;
+
+ grub_free (self->theme_dir);
+ grub_free (self->menu_box_pattern);
+ grub_free (self->item_box_pattern);
+ grub_free (self->selected_item_box_pattern);
+ if (self->menu_box)
+ self->menu_box->destroy (self->menu_box);
+ if (self->item_box)
+ self->item_box->destroy (self->item_box);
+ if (self->selected_item_box)
+ self->selected_item_box->destroy (self->selected_item_box);
+ if (self->icon_manager)
+ grub_gfxmenu_icon_manager_destroy (self->icon_manager);
+ if (self->scrollbar_thumb)
+ self->scrollbar_thumb->destroy (self->scrollbar_thumb);
+ if (self->scrollbar_frame)
+ self->scrollbar_frame->destroy (self->scrollbar_frame);
+ grub_free (self->scrollbar_thumb_pattern);
+ grub_free (self->scrollbar_frame_pattern);
+ grub_free (self);
+}
+
+static int
+get_num_shown_items (list_impl_t self)
+{
+ int boxpad = self->item_padding;
+ int item_vspace = self->item_spacing;
+ int item_height = self->item_height;
+
+ grub_gfxmenu_box_t box = self->menu_box;
+ int box_top_pad = box->get_top_pad (box);
+ int box_bottom_pad = box->get_bottom_pad (box);
+ grub_gfxmenu_box_t itembox = self->item_box;
+ grub_gfxmenu_box_t selbox = self->selected_item_box;
+ int item_top_pad = itembox->get_top_pad (itembox);
+ int item_bottom_pad = itembox->get_bottom_pad (itembox);
+ int sel_top_pad = selbox->get_top_pad (selbox);
+ int sel_bottom_pad = selbox->get_bottom_pad (selbox);
+ 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);
+}
+
+static int
+check_boxes (list_impl_t self)
+{
+ if (self->need_to_recreate_boxes)
+ {
+ grub_gui_recreate_box (&self->menu_box,
+ self->menu_box_pattern,
+ self->theme_dir);
+
+ grub_gui_recreate_box (&self->item_box,
+ self->item_box_pattern,
+ self->theme_dir);
+
+ grub_gui_recreate_box (&self->selected_item_box,
+ self->selected_item_box_pattern,
+ self->theme_dir);
+
+ self->need_to_recreate_boxes = 0;
+ }
+
+ return (self->menu_box != 0 && self->selected_item_box != 0
+ && self->item_box != 0);
+}
+
+static int
+check_scrollbar (list_impl_t self)
+{
+ if (self->need_to_recreate_scrollbar)
+ {
+ grub_gui_recreate_box (&self->scrollbar_frame,
+ self->scrollbar_frame_pattern,
+ self->theme_dir);
+
+ grub_gui_recreate_box (&self->scrollbar_thumb,
+ self->scrollbar_thumb_pattern,
+ self->theme_dir);
+
+ self->need_to_recreate_scrollbar = 0;
+ }
+
+ if (self->scrollbar_frame == 0 || self->scrollbar_thumb == 0)
+ return 0;
+
+ /* Sanity checks. */
+ grub_gfxmenu_box_t frame = self->scrollbar_frame;
+ grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
+ grub_gfxmenu_box_t menu = self->menu_box;
+ int min_width = frame->get_left_pad (frame)
+ + frame->get_right_pad (frame);
+ int min_height = frame->get_top_pad (frame)
+ + frame->get_bottom_pad (frame)
+ + self->scrollbar_top_pad + self->scrollbar_bottom_pad
+ + menu->get_top_pad (menu)
+ + menu->get_bottom_pad (menu);
+ if (!self->scrollbar_thumb_overlay)
+ {
+ min_width += thumb->get_left_pad (thumb)
+ + thumb->get_right_pad (thumb);
+ min_height += thumb->get_top_pad (thumb)
+ + thumb->get_bottom_pad (thumb);
+ }
+ if (min_width <= self->scrollbar_width
+ && min_height <= (int) self->bounds.height)
+ return 1;
+
+ /* Unprintable dimenstions. */
+ self->draw_scrollbar = 0;
+ return 0;
+}
+
+static const char *
+list_get_id (void *vself)
+{
+ list_impl_t self = vself;
+ return self->id;
+}
+
+static int
+list_is_instance (void *vself __attribute__((unused)), const char *type)
+{
+ return (grub_strcmp (type, "component") == 0
+ || grub_strcmp (type, "list") == 0);
+}
+
+static struct grub_video_bitmap *
+get_item_icon (list_impl_t self, int item_index)
+{
+ grub_menu_entry_t entry;
+ entry = grub_menu_get_entry (self->view->menu, item_index);
+ if (! entry)
+ return 0;
+
+ return grub_gfxmenu_icon_manager_get_icon (self->icon_manager, entry);
+}
+
+static void
+make_selected_item_visible (list_impl_t self)
+{
+ int selected_index = self->view->selected;
+ if (selected_index < 0)
+ return; /* No item is selected. */
+ int num_shown_items = get_num_shown_items (self);
+ int last_shown_index = self->first_shown_index + (num_shown_items - 1);
+ if (selected_index < self->first_shown_index)
+ self->first_shown_index = selected_index;
+ else if (selected_index > last_shown_index)
+ self->first_shown_index = selected_index - (num_shown_items - 1);
+}
+
+/* Draw a scrollbar on the menu. */
+static void
+draw_scrollbar (list_impl_t self,
+ int value, int extent, int min, int max,
+ int scrollbar_width, int scrollbar_height)
+{
+ unsigned thumby, thumbheight;
+
+ grub_gfxmenu_box_t frame = self->scrollbar_frame;
+ grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
+ int frame_vertical_pad = (frame->get_top_pad (frame)
+ + frame->get_bottom_pad (frame));
+ int frame_horizontal_pad = (frame->get_left_pad (frame)
+ + frame->get_right_pad (frame));
+ unsigned thumb_vertical_pad = (thumb->get_top_pad (thumb)
+ + thumb->get_bottom_pad (thumb));
+ int thumb_horizontal_pad = (thumb->get_left_pad (thumb)
+ + thumb->get_right_pad (thumb));
+ int tracktop = frame->get_top_pad (frame);
+ unsigned tracklen;
+ if (scrollbar_height <= frame_vertical_pad)
+ tracklen = 0;
+ else
+ tracklen = scrollbar_height - frame_vertical_pad;
+ frame->set_content_size (frame,
+ scrollbar_width - frame_horizontal_pad,
+ tracklen);
+ if (self->scrollbar_thumb_overlay)
+ {
+ tracklen += thumb_vertical_pad;
+ tracktop -= thumb->get_top_pad (thumb);
+ }
+ if (value <= min || max <= min)
+ thumby = 0;
+ else
+ thumby = ((unsigned) tracklen * (value - min))
+ / ((unsigned) (max - min));
+ if (max <= min)
+ thumbheight = 1;
+ else
+ thumbheight = ((unsigned) (tracklen * extent)
+ / ((unsigned) (max - min))) + 1;
+ /* Rare occasion: too many entries or too low height. */
+ if (thumbheight < thumb_vertical_pad)
+ {
+ thumbheight = thumb_vertical_pad;
+ if (value <= min || max <= extent
+ || tracklen <= thumb_vertical_pad)
+ thumby = 0;
+ else
+ thumby = ((unsigned) ((tracklen - thumb_vertical_pad) * (value - min))
+ / ((unsigned)(max - extent)));
+ }
+ thumby += tracktop;
+ int thumbx = frame->get_left_pad (frame);
+ int thumbwidth = scrollbar_width - frame_horizontal_pad;
+ if (!self->scrollbar_thumb_overlay)
+ thumbwidth -= thumb_horizontal_pad;
+ else
+ thumbx -= thumb->get_left_pad (thumb);
+ thumb->set_content_size (thumb, thumbwidth,
+ thumbheight - thumb_vertical_pad);
+ frame->draw (frame, 0, 0);
+ thumb->draw (thumb, thumbx, thumby);
+}
+
+/* Draw the list of items. */
+static void
+draw_menu (list_impl_t self, int num_shown_items)
+{
+ if (! self->menu_box || ! self->selected_item_box || ! self->item_box)
+ return;
+
+ int boxpad = self->item_padding;
+ int icon_text_space = self->item_icon_space;
+ int item_vspace = self->item_spacing;
+
+ int ascent = grub_font_get_ascent (self->item_font);
+ int descent = grub_font_get_descent (self->item_font);
+ int selected_ascent = grub_font_get_ascent (self->selected_item_font);
+ int selected_descent = grub_font_get_descent (self->selected_item_font);
+ int text_box_height = self->item_height;
+
+ make_selected_item_visible (self);
+
+ grub_gfxmenu_box_t itembox = self->item_box;
+ grub_gfxmenu_box_t selbox = self->selected_item_box;
+ int item_leftpad = itembox->get_left_pad (itembox);
+ int item_rightpad = itembox->get_right_pad (itembox);
+ int item_border_width = item_leftpad + item_rightpad;
+ int item_toppad = itembox->get_top_pad (itembox);
+ int sel_leftpad = selbox->get_left_pad (selbox);
+ int sel_rightpad = selbox->get_right_pad (selbox);
+ int sel_border_width = sel_leftpad + sel_rightpad;
+ int sel_toppad = selbox->get_top_pad (selbox);
+
+ int max_leftpad = grub_max (item_leftpad, sel_leftpad);
+ int max_toppad = grub_max (item_toppad, sel_toppad);
+ int item_top = 0;
+ int menu_index;
+ int visible_index;
+ struct grub_video_rect oviewport;
+
+ grub_video_get_viewport (&oviewport.x, &oviewport.y,
+ &oviewport.width, &oviewport.height);
+ grub_video_set_viewport (oviewport.x + boxpad,
+ oviewport.y + boxpad,
+ oviewport.width - 2 * boxpad,
+ oviewport.height - 2 * boxpad);
+
+ int cwidth = oviewport.width - 2 * boxpad;
+
+ itembox->set_content_size (itembox, cwidth - item_border_width,
+ text_box_height);
+ selbox->set_content_size (selbox, cwidth - sel_border_width,
+ text_box_height);
+
+ int text_left_offset = self->icon_width + icon_text_space;
+ int item_text_top_offset = (text_box_height - (ascent + descent)) / 2 + ascent;
+ int sel_text_top_offset = (text_box_height - (selected_ascent
+ + selected_descent)) / 2
+ + selected_ascent;
+
+ grub_video_rect_t svpsave, sviewport;
+ sviewport.x = max_leftpad + text_left_offset;
+ int text_viewport_width = cwidth - sviewport.x;
+ sviewport.height = text_box_height;
+
+ grub_video_color_t item_color;
+ grub_video_color_t sel_color;
+ item_color = grub_video_map_rgba_color (self->item_color);
+ sel_color = grub_video_map_rgba_color (self->selected_item_color);
+
+ int item_box_top_offset = max_toppad - item_toppad;
+ int sel_box_top_offset = max_toppad - sel_toppad;
+ int item_viewport_width = text_viewport_width - item_rightpad;
+ int sel_viewport_width = text_viewport_width - sel_rightpad;
+ int tmp_icon_top_offset = (text_box_height - self->icon_height) / 2;
+ int item_icon_top_offset = item_toppad + tmp_icon_top_offset;
+ int sel_icon_top_offset = sel_toppad + tmp_icon_top_offset;
+
+ for (visible_index = 0, menu_index = self->first_shown_index;
+ visible_index < num_shown_items && menu_index < self->view->menu->size;
+ visible_index++, menu_index++)
+ {
+ int is_selected = (menu_index == self->view->selected);
+ struct grub_video_bitmap *icon;
+ grub_font_t font;
+ grub_video_color_t color;
+ int text_top_offset;
+ int top_pad;
+ int icon_top_offset;
+ int viewport_width;
+
+ if (is_selected)
+ {
+ selbox->draw (selbox, 0, item_top + sel_box_top_offset);
+ font = self->selected_item_font;
+ color = sel_color;
+ text_top_offset = sel_text_top_offset;
+ top_pad = sel_toppad;
+ icon_top_offset = sel_icon_top_offset;
+ viewport_width = sel_viewport_width;
+ }
+ else
+ {
+ itembox->draw (itembox, 0, item_top + item_box_top_offset);
+ font = self->item_font;
+ color = item_color;
+ text_top_offset = item_text_top_offset;
+ top_pad = item_toppad;
+ icon_top_offset = item_icon_top_offset;
+ viewport_width = item_viewport_width;
+ }
+
+ icon = get_item_icon (self, menu_index);
+ if (icon != 0)
+ grub_video_blit_bitmap (icon, GRUB_VIDEO_BLIT_BLEND,
+ max_leftpad,
+ item_top + icon_top_offset,
+ 0, 0, self->icon_width, self->icon_height);
+
+ const char *item_title =
+ grub_menu_get_entry (self->view->menu, menu_index)->title;
+
+ sviewport.y = item_top + top_pad;
+ sviewport.width = viewport_width;
+ grub_gui_set_viewport (&sviewport, &svpsave);
+ grub_font_draw_string (item_title,
+ font,
+ color,
+ 0,
+ text_top_offset);
+ grub_gui_restore_viewport (&svpsave);
+
+ item_top += text_box_height + item_vspace;
+ }
+ grub_video_set_viewport (oviewport.x,
+ oviewport.y,
+ oviewport.width,
+ oviewport.height);
+}
+
+static void
+list_paint (void *vself, const grub_video_rect_t *region)
+{
+ list_impl_t self = vself;
+ grub_video_rect_t vpsave;
+
+ if (! self->visible)
+ return;
+ if (!grub_video_have_common_points (region, &self->bounds))
+ return;
+
+ check_boxes (self);
+
+ if (! self->menu_box || ! self->selected_item_box || ! self->item_box)
+ return;
+
+ grub_gui_set_viewport (&self->bounds, &vpsave);
+ {
+ grub_gfxmenu_box_t box = self->menu_box;
+ int box_left_pad = box->get_left_pad (box);
+ int box_top_pad = box->get_top_pad (box);
+ int box_right_pad = box->get_right_pad (box);
+ int box_bottom_pad = box->get_bottom_pad (box);
+ grub_video_rect_t vpsave2, content_rect;
+ int num_shown_items = get_num_shown_items (self);
+ int drawing_scrollbar = (self->draw_scrollbar
+ && (num_shown_items < self->view->menu->size)
+ && check_scrollbar (self));
+ int scrollbar_width = self->scrollbar_width;
+
+ content_rect.x = box_left_pad;
+ content_rect.y = box_top_pad;
+ content_rect.width = self->bounds.width - box_left_pad - box_right_pad;
+ content_rect.height = self->bounds.height - box_top_pad - box_bottom_pad;
+
+ box->set_content_size (box, content_rect.width, content_rect.height);
+
+ box->draw (box, 0, 0);
+
+ switch (self->scrollbar_slice)
+ {
+ case SCROLLBAR_SLICE_WEST:
+ content_rect.x += self->scrollbar_right_pad;
+ content_rect.width -= self->scrollbar_right_pad;
+ break;
+ case SCROLLBAR_SLICE_CENTER:
+ if (drawing_scrollbar)
+ content_rect.width -= scrollbar_width + self->scrollbar_left_pad
+ + self->scrollbar_right_pad;
+ break;
+ case SCROLLBAR_SLICE_EAST:
+ content_rect.width -= self->scrollbar_left_pad;
+ break;
+ }
+
+ grub_gui_set_viewport (&content_rect, &vpsave2);
+ draw_menu (self, num_shown_items);
+ grub_gui_restore_viewport (&vpsave2);
+
+ if (drawing_scrollbar)
+ {
+ content_rect.y += self->scrollbar_top_pad;
+ content_rect.height -= self->scrollbar_top_pad
+ + self->scrollbar_bottom_pad;
+ content_rect.width = scrollbar_width;
+ switch (self->scrollbar_slice)
+ {
+ case SCROLLBAR_SLICE_WEST:
+ if (box_left_pad > scrollbar_width)
+ {
+ content_rect.x = box_left_pad - scrollbar_width;
+ content_rect.width = scrollbar_width;
+ }
+ else
+ {
+ content_rect.x = 0;
+ content_rect.width = box_left_pad;
+ }
+ break;
+ case SCROLLBAR_SLICE_CENTER:
+ content_rect.x = self->bounds.width - box_right_pad
+ - scrollbar_width - self->scrollbar_right_pad;
+ content_rect.width = scrollbar_width;
+ break;
+ case SCROLLBAR_SLICE_EAST:
+ content_rect.x = self->bounds.width - box_right_pad;
+ content_rect.width = box_right_pad;
+ break;
+ }
+
+ grub_gui_set_viewport (&content_rect, &vpsave2);
+ draw_scrollbar (self,
+ self->first_shown_index, num_shown_items,
+ 0, self->view->menu->size,
+ scrollbar_width,
+ content_rect.height);
+ grub_gui_restore_viewport (&vpsave2);
+ }
+ }
+
+ grub_gui_restore_viewport (&vpsave);
+}
+
+static void
+list_set_parent (void *vself, grub_gui_container_t parent)
+{
+ list_impl_t self = vself;
+ self->parent = parent;
+}
+
+static grub_gui_container_t
+list_get_parent (void *vself)
+{
+ list_impl_t self = vself;
+ return self->parent;
+}
+
+static void
+list_set_bounds (void *vself, const grub_video_rect_t *bounds)
+{
+ list_impl_t self = vself;
+ self->bounds = *bounds;
+}
+
+static void
+list_get_bounds (void *vself, grub_video_rect_t *bounds)
+{
+ list_impl_t self = vself;
+ *bounds = self->bounds;
+}
+
+static void
+list_get_minimal_size (void *vself, unsigned *width, unsigned *height)
+{
+ list_impl_t self = vself;
+
+ if (check_boxes (self))
+ {
+ int boxpad = self->item_padding;
+ int item_vspace = self->item_spacing;
+ int item_height = self->item_height;
+ int num_items = 3;
+
+ grub_gfxmenu_box_t box = self->menu_box;
+ int box_left_pad = box->get_left_pad (box);
+ int box_top_pad = box->get_top_pad (box);
+ int box_right_pad = box->get_right_pad (box);
+ int box_bottom_pad = box->get_bottom_pad (box);
+ unsigned width_s;
+
+ grub_gfxmenu_box_t selbox = self->selected_item_box;
+ int sel_top_pad = selbox->get_top_pad (selbox);
+ int sel_bottom_pad = selbox->get_bottom_pad (selbox);
+ int sel_left_pad = selbox->get_left_pad (selbox);
+ int sel_right_pad = selbox->get_right_pad (selbox);
+
+ grub_gfxmenu_box_t itembox = self->item_box;
+ int item_top_pad = itembox->get_top_pad (itembox);
+ int item_bottom_pad = itembox->get_bottom_pad (itembox);
+ int item_left_pad = itembox->get_left_pad (itembox);
+ int item_right_pad = itembox->get_right_pad (itembox);
+
+ int max_left_pad = grub_max (item_left_pad, sel_left_pad);
+ int max_right_pad = grub_max (item_right_pad, sel_right_pad);
+ int max_top_pad = grub_max (item_top_pad, sel_top_pad);
+ int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
+
+ *width = grub_font_get_string_width (self->item_font, "Typical OS");
+ width_s = grub_font_get_string_width (self->selected_item_font,
+ "Typical OS");
+ if (*width < width_s)
+ *width = width_s;
+
+ *width += 2 * boxpad + box_left_pad + box_right_pad
+ + max_left_pad + max_right_pad
+ + self->item_icon_space + self->icon_width;
+
+ switch (self->scrollbar_slice)
+ {
+ case SCROLLBAR_SLICE_WEST:
+ *width += self->scrollbar_right_pad;
+ break;
+ case SCROLLBAR_SLICE_CENTER:
+ *width += self->scrollbar_width + self->scrollbar_left_pad
+ + self->scrollbar_right_pad;
+ break;
+ case SCROLLBAR_SLICE_EAST:
+ *width += self->scrollbar_left_pad;
+ break;
+ }
+
+ /* Set the menu box height to fit the items. */
+ *height = (item_height * num_items
+ + item_vspace * (num_items - 1)
+ + 2 * boxpad
+ + box_top_pad + box_bottom_pad
+ + max_top_pad + max_bottom_pad);
+ }
+ else
+ {
+ *width = 0;
+ *height = 0;
+ }
+}
+
+static grub_err_t
+list_set_property (void *vself, const char *name, const char *value)
+{
+ list_impl_t self = vself;
+ if (grub_strcmp (name, "item_font") == 0)
+ {
+ self->item_font = grub_font_get (value);
+ if (self->selected_item_font_inherit)
+ self->selected_item_font = self->item_font;
+ }
+ else if (grub_strcmp (name, "selected_item_font") == 0)
+ {
+ if (! value || grub_strcmp (value, "inherit") == 0)
+ {
+ self->selected_item_font = self->item_font;
+ self->selected_item_font_inherit = 1;
+ }
+ else
+ {
+ self->selected_item_font = grub_font_get (value);
+ self->selected_item_font_inherit = 0;
+ }
+ }
+ else if (grub_strcmp (name, "item_color") == 0)
+ {
+ grub_video_rgba_color_t color;
+ if (grub_video_parse_color (value, &color) == GRUB_ERR_NONE)
+ {
+ self->item_color = color;
+ if (self->selected_item_color_inherit)
+ self->selected_item_color = self->item_color;
+ }
+ }
+ else if (grub_strcmp (name, "selected_item_color") == 0)
+ {
+ if (! value || grub_strcmp (value, "inherit") == 0)
+ {
+ self->selected_item_color = self->item_color;
+ self->selected_item_color_inherit = 1;
+ }
+ else
+ {
+ grub_video_rgba_color_t color;
+ if (grub_video_parse_color (value, &color)
+ == GRUB_ERR_NONE)
+ {
+ self->selected_item_color = color;
+ self->selected_item_color_inherit = 0;
+ }
+ }
+ }
+ else if (grub_strcmp (name, "icon_width") == 0)
+ {
+ self->icon_width = grub_strtol (value, 0, 10);
+ grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
+ self->icon_width,
+ self->icon_height);
+ }
+ else if (grub_strcmp (name, "icon_height") == 0)
+ {
+ self->icon_height = grub_strtol (value, 0, 10);
+ grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
+ self->icon_width,
+ self->icon_height);
+ }
+ else if (grub_strcmp (name, "item_height") == 0)
+ {
+ self->item_height = grub_strtol (value, 0, 10);
+ }
+ else if (grub_strcmp (name, "item_padding") == 0)
+ {
+ self->item_padding = grub_strtol (value, 0, 10);
+ }
+ else if (grub_strcmp (name, "item_icon_space") == 0)
+ {
+ self->item_icon_space = grub_strtol (value, 0, 10);
+ }
+ else if (grub_strcmp (name, "item_spacing") == 0)
+ {
+ self->item_spacing = grub_strtol (value, 0, 10);
+ }
+ else if (grub_strcmp (name, "visible") == 0)
+ {
+ self->visible = grub_strcmp (value, "false") != 0;
+ }
+ else if (grub_strcmp (name, "menu_pixmap_style") == 0)
+ {
+ self->need_to_recreate_boxes = 1;
+ grub_free (self->menu_box_pattern);
+ self->menu_box_pattern = value ? grub_strdup (value) : 0;
+ }
+ else if (grub_strcmp (name, "item_pixmap_style") == 0)
+ {
+ self->need_to_recreate_boxes = 1;
+ grub_free (self->item_box_pattern);
+ self->item_box_pattern = value ? grub_strdup (value) : 0;
+ if (self->selected_item_box_pattern_inherit)
+ {
+ grub_free (self->selected_item_box_pattern);
+ self->selected_item_box_pattern = value ? grub_strdup (value) : 0;
+ }
+ }
+ else if (grub_strcmp (name, "selected_item_pixmap_style") == 0)
+ {
+ if (!value || grub_strcmp (value, "inherit") == 0)
+ {
+ grub_free (self->selected_item_box_pattern);
+ char *tmp = self->item_box_pattern;
+ self->selected_item_box_pattern = tmp ? grub_strdup (tmp) : 0;
+ self->selected_item_box_pattern_inherit = 1;
+ }
+ else
+ {
+ self->need_to_recreate_boxes = 1;
+ grub_free (self->selected_item_box_pattern);
+ self->selected_item_box_pattern = grub_strdup (value);
+ self->selected_item_box_pattern_inherit = 0;
+ }
+ }
+ else if (grub_strcmp (name, "scrollbar_frame") == 0)
+ {
+ self->need_to_recreate_scrollbar = 1;
+ grub_free (self->scrollbar_frame_pattern);
+ self->scrollbar_frame_pattern = value ? grub_strdup (value) : 0;
+ }
+ else if (grub_strcmp (name, "scrollbar_thumb") == 0)
+ {
+ self->need_to_recreate_scrollbar = 1;
+ grub_free (self->scrollbar_thumb_pattern);
+ self->scrollbar_thumb_pattern = value ? grub_strdup (value) : 0;
+ }
+ else if (grub_strcmp (name, "scrollbar_thumb_overlay") == 0)
+ {
+ self->scrollbar_thumb_overlay = grub_strcmp (value, "true") == 0;
+ }
+ else if (grub_strcmp (name, "scrollbar_width") == 0)
+ {
+ self->scrollbar_width = grub_strtol (value, 0, 10);
+ }
+ else if (grub_strcmp (name, "scrollbar_slice") == 0)
+ {
+ if (grub_strcmp (value, "west") == 0)
+ self->scrollbar_slice = SCROLLBAR_SLICE_WEST;
+ else if (grub_strcmp (value, "center") == 0)
+ self->scrollbar_slice = SCROLLBAR_SLICE_CENTER;
+ else if (grub_strcmp (value, "east") == 0)
+ self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
+ }
+ else if (grub_strcmp (name, "scrollbar_left_pad") == 0)
+ {
+ self->scrollbar_left_pad = grub_strtol (value, 0, 10);
+ }
+ else if (grub_strcmp (name, "scrollbar_right_pad") == 0)
+ {
+ self->scrollbar_right_pad = grub_strtol (value, 0, 10);
+ }
+ else if (grub_strcmp (name, "scrollbar_top_pad") == 0)
+ {
+ self->scrollbar_top_pad = grub_strtol (value, 0, 10);
+ }
+ else if (grub_strcmp (name, "scrollbar_bottom_pad") == 0)
+ {
+ self->scrollbar_bottom_pad = grub_strtol (value, 0, 10);
+ }
+ else if (grub_strcmp (name, "scrollbar") == 0)
+ {
+ self->draw_scrollbar = grub_strcmp (value, "false") != 0;
+ }
+ else if (grub_strcmp (name, "theme_dir") == 0)
+ {
+ self->need_to_recreate_boxes = 1;
+ grub_free (self->theme_dir);
+ self->theme_dir = value ? grub_strdup (value) : 0;
+ }
+ else if (grub_strcmp (name, "id") == 0)
+ {
+ grub_free (self->id);
+ if (value)
+ self->id = grub_strdup (value);
+ else
+ self->id = 0;
+ }
+ return grub_errno;
+}
+
+/* Set necessary information that the gfxmenu view provides. */
+static void
+list_set_view_info (void *vself,
+ grub_gfxmenu_view_t view)
+{
+ list_impl_t self = vself;
+ grub_gfxmenu_icon_manager_set_theme_path (self->icon_manager,
+ view->theme_path);
+ self->view = view;
+}
+
+/* Refresh list variables */
+static void
+list_refresh_info (void *vself,
+ grub_gfxmenu_view_t view)
+{
+ list_impl_t self = vself;
+ if (view->nested)
+ self->first_shown_index = 0;
+}
+
+static struct grub_gui_component_ops list_comp_ops =
+ {
+ .destroy = list_destroy,
+ .get_id = list_get_id,
+ .is_instance = list_is_instance,
+ .paint = list_paint,
+ .set_parent = list_set_parent,
+ .get_parent = list_get_parent,
+ .set_bounds = list_set_bounds,
+ .get_bounds = list_get_bounds,
+ .get_minimal_size = list_get_minimal_size,
+ .set_property = list_set_property
+ };
+
+static struct grub_gui_list_ops list_ops =
+{
+ .set_view_info = list_set_view_info,
+ .refresh_list = list_refresh_info
+};
+
+grub_gui_component_t
+grub_gui_list_new (void)
+{
+ list_impl_t self;
+ grub_font_t default_font;
+ grub_video_rgba_color_t default_fg_color;
+
+ self = grub_zalloc (sizeof (*self));
+ if (! self)
+ return 0;
+
+ self->list.ops = &list_ops;
+ self->list.component.ops = &list_comp_ops;
+
+ self->visible = 1;
+
+ default_font = grub_font_get ("Unknown Regular 16");
+ default_fg_color = grub_video_rgba_color_rgb (0, 0, 0);
+
+ self->icon_width = 32;
+ self->icon_height = 32;
+ self->item_height = 42;
+ self->item_padding = 14;
+ self->item_icon_space = 4;
+ self->item_spacing = 16;
+ self->item_font = default_font;
+ self->selected_item_font_inherit = 1; /* Default to using the item_font. */
+ self->selected_item_font = default_font;
+ self->item_color = default_fg_color;
+ self->selected_item_color_inherit = 1; /* Default to using the item_color. */
+ self->selected_item_color = default_fg_color;
+
+ self->draw_scrollbar = 1;
+ self->need_to_recreate_scrollbar = 1;
+ self->scrollbar_frame = 0;
+ self->scrollbar_thumb = 0;
+ self->scrollbar_frame_pattern = 0;
+ self->scrollbar_thumb_pattern = 0;
+ self->scrollbar_thumb_overlay = 0;
+ self->scrollbar_width = 16;
+ self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
+ self->scrollbar_left_pad = 2;
+ self->scrollbar_right_pad = 0;
+ self->scrollbar_top_pad = 0;
+ self->scrollbar_bottom_pad = 0;
+
+ self->first_shown_index = 0;
+
+ self->need_to_recreate_boxes = 0;
+ self->theme_dir = 0;
+ self->menu_box_pattern = 0;
+ self->item_box_pattern = 0;
+ self->selected_item_box_pattern_inherit = 1;/*Default to using the item_box.*/
+ self->selected_item_box_pattern = 0;
+ self->menu_box = grub_gfxmenu_create_box (0, 0);
+ self->item_box = grub_gfxmenu_create_box (0, 0);
+ self->selected_item_box = grub_gfxmenu_create_box (0, 0);
+
+ self->icon_manager = grub_gfxmenu_icon_manager_new ();
+ if (! self->icon_manager)
+ {
+ self->list.component.ops->destroy (self);
+ return 0;
+ }
+ grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
+ self->icon_width,
+ self->icon_height);
+ return (grub_gui_component_t) self;
+}
diff --git a/grub-core/gfxmenu/gui_progress_bar.c b/grub-core/gfxmenu/gui_progress_bar.c
new file mode 100644
index 0000000..ace85a1
--- /dev/null
+++ b/grub-core/gfxmenu/gui_progress_bar.c
@@ -0,0 +1,457 @@
+/* gui_progress_bar.c - GUI progress bar component. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/gui.h>
+#include <grub/font.h>
+#include <grub/gui_string_util.h>
+#include <grub/gfxmenu_view.h>
+#include <grub/gfxwidgets.h>
+#include <grub/i18n.h>
+#include <grub/color.h>
+
+struct grub_gui_progress_bar
+{
+ struct grub_gui_progress progress;
+
+ grub_gui_container_t parent;
+ grub_video_rect_t bounds;
+ char *id;
+ int visible;
+ int start;
+ int end;
+ int value;
+ char *template;
+ grub_font_t font;
+ grub_video_rgba_color_t text_color;
+ grub_video_rgba_color_t border_color;
+ grub_video_rgba_color_t bg_color;
+ grub_video_rgba_color_t fg_color;
+
+ char *theme_dir;
+ int need_to_recreate_pixmaps;
+ int pixmapbar_available;
+ char *bar_pattern;
+ char *highlight_pattern;
+ grub_gfxmenu_box_t bar_box;
+ grub_gfxmenu_box_t highlight_box;
+ int highlight_overlay;
+};
+
+typedef struct grub_gui_progress_bar *grub_gui_progress_bar_t;
+
+static void
+progress_bar_destroy (void *vself)
+{
+ grub_gui_progress_bar_t self = vself;
+ grub_free (self->theme_dir);
+ grub_free (self->template);
+ grub_free (self->id);
+ grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
+ grub_free (self);
+}
+
+static const char *
+progress_bar_get_id (void *vself)
+{
+ grub_gui_progress_bar_t self = vself;
+ return self->id;
+}
+
+static int
+progress_bar_is_instance (void *vself __attribute__((unused)), const char *type)
+{
+ return grub_strcmp (type, "component") == 0;
+}
+
+static int
+check_pixmaps (grub_gui_progress_bar_t self)
+{
+ if (!self->pixmapbar_available)
+ return 0;
+ if (self->need_to_recreate_pixmaps)
+ {
+ grub_gui_recreate_box (&self->bar_box,
+ self->bar_pattern,
+ self->theme_dir);
+
+ grub_gui_recreate_box (&self->highlight_box,
+ self->highlight_pattern,
+ self->theme_dir);
+
+ self->need_to_recreate_pixmaps = 0;
+ }
+
+ return (self->bar_box != 0 && self->highlight_box != 0);
+}
+
+static void
+draw_filled_rect_bar (grub_gui_progress_bar_t self)
+{
+ /* Set the progress bar's frame. */
+ grub_video_rect_t f;
+ f.x = 1;
+ f.y = 1;
+ f.width = self->bounds.width - 2;
+ f.height = self->bounds.height - 2;
+
+ /* Border. */
+ grub_video_fill_rect (grub_video_map_rgba_color (self->border_color),
+ f.x - 1, f.y - 1,
+ f.width + 2, f.height + 2);
+
+ /* Bar background. */
+ 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);
+
+ /* Bar foreground. */
+ grub_video_fill_rect (grub_video_map_rgba_color (self->fg_color),
+ f.x, f.y,
+ barwidth, f.height);
+}
+
+static void
+draw_pixmap_bar (grub_gui_progress_bar_t self)
+{
+ grub_gfxmenu_box_t bar = self->bar_box;
+ grub_gfxmenu_box_t hl = self->highlight_box;
+ int w = self->bounds.width;
+ int h = self->bounds.height;
+ int bar_l_pad = bar->get_left_pad (bar);
+ int bar_r_pad = bar->get_right_pad (bar);
+ int bar_t_pad = bar->get_top_pad (bar);
+ int bar_b_pad = bar->get_bottom_pad (bar);
+ int bar_h_pad = bar_l_pad + bar_r_pad;
+ int bar_v_pad = bar_t_pad + bar_b_pad;
+ int hl_l_pad = hl->get_left_pad (hl);
+ int hl_r_pad = hl->get_right_pad (hl);
+ int hl_t_pad = hl->get_top_pad (hl);
+ int hl_b_pad = hl->get_bottom_pad (hl);
+ int hl_h_pad = hl_l_pad + hl_r_pad;
+ int hl_v_pad = hl_t_pad + hl_b_pad;
+ int tracklen = w - bar_h_pad;
+ int trackheight = h - bar_v_pad;
+ int barwidth;
+ int hlheight = trackheight;
+ int hlx = bar_l_pad;
+ int hly = bar_t_pad;
+
+ bar->set_content_size (bar, tracklen, trackheight);
+ bar->draw (bar, 0, 0);
+
+ if (self->highlight_overlay)
+ {
+ tracklen += hl_h_pad;
+ hlx -= hl_l_pad;
+ hly -= hl_t_pad;
+ }
+ else
+ hlheight -= hl_v_pad;
+
+ if (self->value <= self->start
+ || self->end <= self->start)
+ barwidth = 0;
+ else
+ barwidth = ((unsigned) (tracklen * (self->value - self->start))
+ / ((unsigned) (self->end - self->start)));
+
+ if (barwidth >= hl_h_pad)
+ {
+ hl->set_content_size (hl, barwidth - hl_h_pad, hlheight);
+ hl->draw (hl, hlx, hly);
+ }
+}
+
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
+static void
+draw_text (grub_gui_progress_bar_t self)
+{
+ if (self->template)
+ {
+ grub_font_t font = self->font;
+ grub_video_color_t text_color =
+ grub_video_map_rgba_color (self->text_color);
+ int width = self->bounds.width;
+ int height = self->bounds.height;
+ char *text;
+ text = grub_xasprintf (self->template,
+ self->value > 0 ? self->value : -self->value);
+ if (!text)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+ /* Center the text. */
+ int text_width = grub_font_get_string_width (font, text);
+ int x = (width - text_width) / 2;
+ int y = ((height - grub_font_get_descent (font)) / 2
+ + grub_font_get_ascent (font) / 2);
+ grub_font_draw_string (text, font, text_color, x, y);
+ grub_free (text);
+ }
+}
+
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
+static void
+progress_bar_paint (void *vself, const grub_video_rect_t *region)
+{
+ grub_gui_progress_bar_t self = vself;
+ grub_video_rect_t vpsave;
+
+ if (! self->visible)
+ return;
+ if (!grub_video_have_common_points (region, &self->bounds))
+ return;
+
+ if (self->end == self->start)
+ return;
+
+ grub_gui_set_viewport (&self->bounds, &vpsave);
+
+ if (check_pixmaps (self))
+ draw_pixmap_bar (self);
+ else
+ draw_filled_rect_bar (self);
+
+ draw_text (self);
+
+ grub_gui_restore_viewport (&vpsave);
+}
+
+static void
+progress_bar_set_parent (void *vself, grub_gui_container_t parent)
+{
+ grub_gui_progress_bar_t self = vself;
+ self->parent = parent;
+}
+
+static grub_gui_container_t
+progress_bar_get_parent (void *vself)
+{
+ grub_gui_progress_bar_t self = vself;
+ return self->parent;
+}
+
+static void
+progress_bar_set_bounds (void *vself, const grub_video_rect_t *bounds)
+{
+ grub_gui_progress_bar_t self = vself;
+ self->bounds = *bounds;
+}
+
+static void
+progress_bar_get_bounds (void *vself, grub_video_rect_t *bounds)
+{
+ grub_gui_progress_bar_t self = vself;
+ *bounds = self->bounds;
+}
+
+static void
+progress_bar_get_minimal_size (void *vself,
+ unsigned *width, unsigned *height)
+{
+ unsigned min_width = 0;
+ unsigned min_height = 0;
+ grub_gui_progress_bar_t self = vself;
+
+ if (self->template)
+ {
+ min_width = grub_font_get_string_width (self->font, self->template);
+ min_width += grub_font_get_string_width (self->font, "XXXXXXXXXX");
+ min_height = grub_font_get_descent (self->font)
+ + grub_font_get_ascent (self->font);
+ }
+ if (check_pixmaps (self))
+ {
+ grub_gfxmenu_box_t bar = self->bar_box;
+ grub_gfxmenu_box_t hl = self->highlight_box;
+ min_width += bar->get_left_pad (bar) + bar->get_right_pad (bar);
+ min_height += bar->get_top_pad (bar) + bar->get_bottom_pad (bar);
+ if (!self->highlight_overlay)
+ {
+ min_width += hl->get_left_pad (hl) + hl->get_right_pad (hl);
+ min_height += hl->get_top_pad (hl) + hl->get_bottom_pad (hl);
+ }
+ }
+ else
+ {
+ min_height += 2;
+ min_width += 2;
+ }
+ *width = 200;
+ if (*width < min_width)
+ *width = min_width;
+ *height = 28;
+ if (*height < min_height)
+ *height = min_height;
+}
+
+static void
+progress_bar_set_state (void *vself, int visible, int start,
+ int current, int end)
+{
+ grub_gui_progress_bar_t self = vself;
+ self->visible = visible;
+ self->start = start;
+ self->value = current;
+ self->end = end;
+}
+
+static grub_err_t
+progress_bar_set_property (void *vself, const char *name, const char *value)
+{
+ grub_gui_progress_bar_t self = vself;
+ if (grub_strcmp (name, "text") == 0)
+ {
+ grub_free (self->template);
+ if (grub_strcmp (value, "@TIMEOUT_NOTIFICATION_LONG@") == 0)
+ value
+ = _("The highlighted entry will be executed automatically in %ds.");
+ else if (grub_strcmp (value, "@TIMEOUT_NOTIFICATION_MIDDLE@") == 0)
+ /* TRANSLATORS: 's' stands for seconds.
+ It's a standalone timeout notification.
+ Please use the short form in your language. */
+ value = _("%ds remaining.");
+ else if (grub_strcmp (value, "@TIMEOUT_NOTIFICATION_SHORT@") == 0)
+ /* TRANSLATORS: 's' stands for seconds.
+ It's a standalone timeout notification.
+ Please use the shortest form available in you language. */
+ value = _("%ds");
+
+ if (grub_printf_fmt_check(value, "%d") != GRUB_ERR_NONE)
+ value = ""; /* Unsupported format. */
+
+ self->template = grub_strdup (value);
+ }
+ else if (grub_strcmp (name, "font") == 0)
+ {
+ self->font = grub_font_get (value);
+ }
+ else if (grub_strcmp (name, "text_color") == 0)
+ {
+ grub_video_parse_color (value, &self->text_color);
+ }
+ else if (grub_strcmp (name, "border_color") == 0)
+ {
+ grub_video_parse_color (value, &self->border_color);
+ }
+ else if (grub_strcmp (name, "bg_color") == 0)
+ {
+ grub_video_parse_color (value, &self->bg_color);
+ }
+ else if (grub_strcmp (name, "fg_color") == 0)
+ {
+ grub_video_parse_color (value, &self->fg_color);
+ }
+ else if (grub_strcmp (name, "bar_style") == 0)
+ {
+ self->need_to_recreate_pixmaps = 1;
+ self->pixmapbar_available = 1;
+ grub_free (self->bar_pattern);
+ self->bar_pattern = value ? grub_strdup (value) : 0;
+ }
+ else if (grub_strcmp (name, "highlight_style") == 0)
+ {
+ self->need_to_recreate_pixmaps = 1;
+ self->pixmapbar_available = 1;
+ grub_free (self->highlight_pattern);
+ self->highlight_pattern = value ? grub_strdup (value) : 0;
+ }
+ else if (grub_strcmp (name, "highlight_overlay") == 0)
+ {
+ self->highlight_overlay = grub_strcmp (value, "true") == 0;
+ }
+ else if (grub_strcmp (name, "theme_dir") == 0)
+ {
+ self->need_to_recreate_pixmaps = 1;
+ grub_free (self->theme_dir);
+ self->theme_dir = value ? grub_strdup (value) : 0;
+ }
+ else if (grub_strcmp (name, "id") == 0)
+ {
+ grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
+ grub_free (self->id);
+ if (value)
+ self->id = grub_strdup (value);
+ else
+ self->id = 0;
+ if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
+ == 0)
+ grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
+ progress_bar_set_state);
+ }
+ return grub_errno;
+}
+
+static struct grub_gui_component_ops progress_bar_ops =
+{
+ .destroy = progress_bar_destroy,
+ .get_id = progress_bar_get_id,
+ .is_instance = progress_bar_is_instance,
+ .paint = progress_bar_paint,
+ .set_parent = progress_bar_set_parent,
+ .get_parent = progress_bar_get_parent,
+ .set_bounds = progress_bar_set_bounds,
+ .get_bounds = progress_bar_get_bounds,
+ .get_minimal_size = progress_bar_get_minimal_size,
+ .set_property = progress_bar_set_property
+};
+
+static struct grub_gui_progress_ops progress_bar_pb_ops =
+ {
+ .set_state = progress_bar_set_state
+ };
+
+grub_gui_component_t
+grub_gui_progress_bar_new (void)
+{
+ grub_gui_progress_bar_t self;
+ self = grub_zalloc (sizeof (*self));
+ if (! self)
+ return 0;
+
+ self->progress.ops = &progress_bar_pb_ops;
+ self->progress.component.ops = &progress_bar_ops;
+ self->visible = 1;
+ self->font = grub_font_get ("Unknown Regular 16");
+ grub_video_rgba_color_t black = { .red = 0, .green = 0, .blue = 0, .alpha = 255 };
+ grub_video_rgba_color_t gray = { .red = 128, .green = 128, .blue = 128, .alpha = 255 };
+ grub_video_rgba_color_t lightgray = { .red = 200, .green = 200, .blue = 200, .alpha = 255 };
+ self->text_color = black;
+ self->border_color = black;
+ self->bg_color = gray;
+ self->fg_color = lightgray;
+ self->highlight_overlay = 0;
+
+ return (grub_gui_component_t) self;
+}
diff --git a/grub-core/gfxmenu/gui_string_util.c b/grub-core/gfxmenu/gui_string_util.c
new file mode 100644
index 0000000..ba1e1ea
--- /dev/null
+++ b/grub-core/gfxmenu/gui_string_util.c
@@ -0,0 +1,206 @@
+/* gui_string_util.c - String utilities used by the GUI system. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/gui_string_util.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+
+/* Create a new NUL-terminated string on the heap as a substring of BUF.
+ The range of buf included is the half-open interval [START,END).
+ The index START is inclusive, END is exclusive. */
+char *
+grub_new_substring (const char *buf,
+ grub_size_t start, grub_size_t end)
+{
+ if (end < start)
+ return 0;
+ grub_size_t len = end - start;
+ char *s = grub_malloc (len + 1);
+ if (! s)
+ return 0;
+ grub_memcpy (s, buf + start, len);
+ s[len] = '\0';
+ return s;
+}
+
+/* Eliminate "." and ".." path elements from PATH. A new heap-allocated
+ string is returned. */
+static char *
+canonicalize_path (const char *path)
+{
+ int i;
+ const char *p;
+ char *newpath = 0;
+
+ /* Count the path components in path. */
+ int components = 1;
+ for (p = path; *p; p++)
+ if (*p == '/')
+ components++;
+
+ char **path_array = grub_calloc (components, sizeof (*path_array));
+ if (! path_array)
+ return 0;
+
+ /* Initialize array elements to NULL pointers; in case once of the
+ allocations fails, the cleanup code can just call grub_free() for all
+ pointers in the array. */
+ for (i = 0; i < components; i++)
+ path_array[i] = 0;
+
+ /* Parse the path into path_array. */
+ p = path;
+ for (i = 0; i < components && p; i++)
+ {
+ /* Find the end of the path element. */
+ const char *end = grub_strchr (p, '/');
+ if (!end)
+ end = p + grub_strlen (p);
+
+ /* Copy the element. */
+ path_array[i] = grub_new_substring (p, 0, end - p);
+ if (! path_array[i])
+ goto cleanup;
+
+ /* Advance p to point to the start of the next element, or NULL. */
+ if (*end)
+ p = end + 1;
+ else
+ p = 0;
+ }
+
+ /* Eliminate '.' and '..' elements from the path array. */
+ int newpath_length = 0;
+ for (i = components - 1; i >= 0; --i)
+ {
+ if (! grub_strcmp (path_array[i], "."))
+ {
+ grub_free (path_array[i]);
+ path_array[i] = 0;
+ }
+ else if (! grub_strcmp (path_array[i], "..")
+ && i > 0)
+ {
+ /* Delete the '..' and the prior path element. */
+ grub_free (path_array[i]);
+ path_array[i] = 0;
+ --i;
+ grub_free (path_array[i]);
+ path_array[i] = 0;
+ }
+ else
+ {
+ newpath_length += grub_strlen (path_array[i]) + 1;
+ }
+ }
+
+ /* Construct a new path string. */
+ newpath = grub_malloc (newpath_length + 1);
+ if (! newpath)
+ goto cleanup;
+
+ newpath[0] = '\0';
+ char *newpath_end = newpath;
+ int first = 1;
+ for (i = 0; i < components; i++)
+ {
+ char *element = path_array[i];
+ if (element)
+ {
+ /* For all components but the first, prefix with a slash. */
+ if (! first)
+ newpath_end = grub_stpcpy (newpath_end, "/");
+ newpath_end = grub_stpcpy (newpath_end, element);
+ first = 0;
+ }
+ }
+
+cleanup:
+ for (i = 0; i < components; i++)
+ grub_free (path_array[i]);
+ grub_free (path_array);
+
+ return newpath;
+}
+
+/* Return a new heap-allocated string representing to absolute path
+ to the file referred to by PATH. If PATH is an absolute path, then
+ the returned path is a copy of PATH. If PATH is a relative path, then
+ BASE is with PATH used to construct the absolute path. */
+char *
+grub_resolve_relative_path (const char *base, const char *path)
+{
+ char *abspath;
+ char *canonpath;
+ char *p;
+ grub_size_t l;
+
+ /* If PATH is an absolute path, then just use it as is. */
+ if (path[0] == '/' || path[0] == '(')
+ return canonicalize_path (path);
+
+ abspath = grub_malloc (grub_strlen (base) + grub_strlen (path) + 3);
+ if (! abspath)
+ return 0;
+
+ /* Concatenate BASE and PATH. */
+ p = grub_stpcpy (abspath, base);
+ l = grub_strlen (abspath);
+ if (l == 0 || abspath[l-1] != '/')
+ {
+ *p = '/';
+ p++;
+ *p = 0;
+ }
+ grub_stpcpy (p, path);
+
+ canonpath = canonicalize_path (abspath);
+ if (! canonpath)
+ return abspath;
+
+ grub_free (abspath);
+ return canonpath;
+}
+
+/* Get the path of the directory where the file at FILE_PATH is located.
+ FILE_PATH should refer to a file, not a directory. The returned path
+ includes a trailing slash.
+ This does not handle GRUB "(hd0,0)" paths properly yet since it only
+ looks at slashes. */
+char *
+grub_get_dirname (const char *file_path)
+{
+ int i;
+ int last_slash;
+
+ last_slash = -1;
+ for (i = grub_strlen (file_path) - 1; i >= 0; --i)
+ {
+ if (file_path[i] == '/')
+ {
+ last_slash = i;
+ break;
+ }
+ }
+ if (last_slash == -1)
+ return grub_strdup ("/");
+
+ return grub_new_substring (file_path, 0, last_slash + 1);
+}
diff --git a/grub-core/gfxmenu/gui_util.c b/grub-core/gfxmenu/gui_util.c
new file mode 100644
index 0000000..eba7bb3
--- /dev/null
+++ b/grub-core/gfxmenu/gui_util.c
@@ -0,0 +1,101 @@
+/* gui_util.c - GUI utility functions. */
+/*
+ * 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/mm.h>
+#include <grub/misc.h>
+#include <grub/gui.h>
+#include <grub/gui_string_util.h>
+
+
+struct find_by_id_state
+{
+ const char *match_id;
+ grub_gui_component_callback match_callback;
+ void *match_userdata;
+};
+
+static void
+find_by_id_recursively (grub_gui_component_t component, void *userdata)
+{
+ struct find_by_id_state *state;
+ const char *id;
+
+ state = (struct find_by_id_state *) userdata;
+ id = component->ops->get_id (component);
+ if (id && grub_strcmp (id, state->match_id) == 0)
+ state->match_callback (component, state->match_userdata);
+
+ if (component->ops->is_instance (component, "container"))
+ {
+ grub_gui_container_t container;
+ container = (grub_gui_container_t) component;
+ container->ops->iterate_children (container,
+ find_by_id_recursively,
+ state);
+ }
+}
+
+void
+grub_gui_find_by_id (grub_gui_component_t root,
+ const char *id,
+ grub_gui_component_callback cb,
+ void *userdata)
+{
+ struct find_by_id_state state;
+ state.match_id = id;
+ state.match_callback = cb;
+ state.match_userdata = userdata;
+ find_by_id_recursively (root, &state);
+}
+
+
+struct iterate_recursively_state
+{
+ grub_gui_component_callback callback;
+ void *userdata;
+};
+
+static
+void iterate_recursively_cb (grub_gui_component_t component, void *userdata)
+{
+ struct iterate_recursively_state *state;
+
+ state = (struct iterate_recursively_state *) userdata;
+ state->callback (component, state->userdata);
+
+ if (component->ops->is_instance (component, "container"))
+ {
+ grub_gui_container_t container;
+ container = (grub_gui_container_t) component;
+ container->ops->iterate_children (container,
+ iterate_recursively_cb,
+ state);
+ }
+}
+
+void
+grub_gui_iterate_recursively (grub_gui_component_t root,
+ grub_gui_component_callback cb,
+ void *userdata)
+{
+ struct iterate_recursively_state state;
+ state.callback = cb;
+ state.userdata = userdata;
+ iterate_recursively_cb (root, &state);
+}
diff --git a/grub-core/gfxmenu/icon_manager.c b/grub-core/gfxmenu/icon_manager.c
new file mode 100644
index 0000000..1894682
--- /dev/null
+++ b/grub-core/gfxmenu/icon_manager.c
@@ -0,0 +1,257 @@
+/* icon_manager.c - gfxmenu icon manager. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/gui_string_util.h>
+#include <grub/bitmap.h>
+#include <grub/bitmap_scale.h>
+#include <grub/menu.h>
+#include <grub/icon_manager.h>
+#include <grub/env.h>
+
+/* Currently hard coded to '.png' extension. */
+static const char icon_extension[] = ".png";
+
+typedef struct icon_entry
+{
+ char *class_name;
+ struct grub_video_bitmap *bitmap;
+ struct icon_entry *next;
+} *icon_entry_t;
+
+struct grub_gfxmenu_icon_manager
+{
+ char *theme_path;
+ int icon_width;
+ int icon_height;
+
+ /* Icon cache: linked list w/ dummy head node. */
+ struct icon_entry cache;
+};
+
+
+/* Create a new icon manager and return a point to it. */
+grub_gfxmenu_icon_manager_t
+grub_gfxmenu_icon_manager_new (void)
+{
+ grub_gfxmenu_icon_manager_t mgr;
+ mgr = grub_malloc (sizeof (*mgr));
+ if (! mgr)
+ return 0;
+
+ mgr->theme_path = 0;
+ mgr->icon_width = 0;
+ mgr->icon_height = 0;
+
+ /* Initialize the dummy head node. */
+ mgr->cache.class_name = 0;
+ mgr->cache.bitmap = 0;
+ mgr->cache.next = 0;
+
+ return mgr;
+}
+
+/* Destroy the icon manager MGR, freeing all resources used by it.
+
+Note: Any bitmaps returned by grub_gfxmenu_icon_manager_get_icon()
+are destroyed and must not be used by the caller after this function
+is called. */
+void
+grub_gfxmenu_icon_manager_destroy (grub_gfxmenu_icon_manager_t mgr)
+{
+ grub_gfxmenu_icon_manager_clear_cache (mgr);
+ grub_free (mgr->theme_path);
+ grub_free (mgr);
+}
+
+/* Clear the icon cache. */
+void
+grub_gfxmenu_icon_manager_clear_cache (grub_gfxmenu_icon_manager_t mgr)
+{
+ icon_entry_t cur;
+ icon_entry_t next;
+ for (cur = mgr->cache.next; cur; cur = next)
+ {
+ next = cur->next;
+ grub_free (cur->class_name);
+ grub_video_bitmap_destroy (cur->bitmap);
+ grub_free (cur);
+ }
+ mgr->cache.next = 0;
+}
+
+/* Set the theme path. If the theme path is changed, the icon cache
+ is cleared. */
+void
+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)
+ 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);
+ mgr->theme_path = path ? grub_strdup (path) : 0;
+}
+
+/* Set the icon size. When icons are requested from the icon manager,
+ they are scaled to this size before being returned. If the size is
+ changed, the icon cache is cleared. */
+void
+grub_gfxmenu_icon_manager_set_icon_size (grub_gfxmenu_icon_manager_t mgr,
+ int width, int height)
+{
+ /* If the width or height is changed, we must clear the cache, since the
+ scaled bitmaps are stored in the cache. */
+ if (width != mgr->icon_width || height != mgr->icon_height)
+ grub_gfxmenu_icon_manager_clear_cache (mgr);
+
+ mgr->icon_width = width;
+ mgr->icon_height = height;
+}
+
+/* Try to load an icon for the specified CLASS_NAME in the directory DIR.
+ Returns 0 if the icon could not be loaded, or returns a pointer to a new
+ bitmap if it was successful. */
+static struct grub_video_bitmap *
+try_loading_icon (grub_gfxmenu_icon_manager_t mgr,
+ const char *dir, const char *class_name)
+{
+ char *path, *ptr;
+
+ path = grub_malloc (grub_strlen (dir) + grub_strlen (class_name)
+ + grub_strlen (icon_extension) + 3);
+ if (! path)
+ return 0;
+
+ ptr = grub_stpcpy (path, dir);
+ if (path == ptr || ptr[-1] != '/')
+ *ptr++ = '/';
+ ptr = grub_stpcpy (ptr, class_name);
+ ptr = grub_stpcpy (ptr, icon_extension);
+ *ptr = '\0';
+
+ struct grub_video_bitmap *raw_bitmap;
+ grub_video_bitmap_load (&raw_bitmap, path);
+ grub_free (path);
+ grub_errno = GRUB_ERR_NONE; /* Critical to clear the error!! */
+ if (! raw_bitmap)
+ return 0;
+
+ struct grub_video_bitmap *scaled_bitmap;
+ grub_video_bitmap_create_scaled (&scaled_bitmap,
+ mgr->icon_width, mgr->icon_height,
+ raw_bitmap,
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
+ grub_video_bitmap_destroy (raw_bitmap);
+ if (! scaled_bitmap)
+ return 0;
+
+ return scaled_bitmap;
+}
+
+/* Get the icon for the specified class CLASS_NAME. If an icon for
+ CLASS_NAME already exists in the cache, then a reference to the cached
+ bitmap is returned. If it is not cached, then it is loaded and cached.
+ If no icon could be could for CLASS_NAME, then 0 is returned. */
+static struct grub_video_bitmap *
+get_icon_by_class (grub_gfxmenu_icon_manager_t mgr, const char *class_name)
+{
+ /* First check the icon cache. */
+ icon_entry_t entry;
+ for (entry = mgr->cache.next; entry; entry = entry->next)
+ {
+ if (grub_strcmp (entry->class_name, class_name) == 0)
+ return entry->bitmap;
+ }
+
+ if (! mgr->theme_path)
+ return 0;
+
+ /* Otherwise, we search for an icon to load. */
+ char *theme_dir = grub_get_dirname (mgr->theme_path);
+ char *icons_dir;
+ struct grub_video_bitmap *icon;
+ icon = 0;
+ /* First try the theme's own icons, from "grub/themes/NAME/icons/" */
+ icons_dir = grub_resolve_relative_path (theme_dir, "icons/");
+ if (icons_dir)
+ {
+ icon = try_loading_icon (mgr, icons_dir, class_name);
+ grub_free (icons_dir);
+ }
+
+ grub_free (theme_dir);
+ if (! icon)
+ {
+ const char *icondir;
+
+ icondir = grub_env_get ("icondir");
+ if (icondir)
+ icon = try_loading_icon (mgr, icondir, class_name);
+ }
+
+ /* No icon was found. */
+ /* This should probably be noted in the cache, so that a search is not
+ performed each time an icon for CLASS_NAME is requested. */
+ if (! icon)
+ return 0;
+
+ /* Insert a new cache entry for this icon. */
+ entry = grub_malloc (sizeof (*entry));
+ if (! entry)
+ {
+ grub_video_bitmap_destroy (icon);
+ return 0;
+ }
+ entry->class_name = grub_strdup (class_name);
+ entry->bitmap = icon;
+ entry->next = mgr->cache.next;
+ mgr->cache.next = entry; /* Link it into the cache. */
+ return entry->bitmap;
+}
+
+/* Get the best available icon for ENTRY. Beginning with the first class
+ listed in the menu entry and proceeding forward, an icon for each class
+ is searched for. The first icon found is returned. The returned icon
+ is scaled to the size specified by
+ grub_gfxmenu_icon_manager_set_icon_size().
+
+ Note: Bitmaps returned by this function are destroyed when the
+ icon manager is destroyed.
+ */
+struct grub_video_bitmap *
+grub_gfxmenu_icon_manager_get_icon (grub_gfxmenu_icon_manager_t mgr,
+ grub_menu_entry_t entry)
+{
+ struct grub_menu_entry_class *c;
+ struct grub_video_bitmap *icon;
+
+ /* Try each class in succession. */
+ icon = 0;
+ for (c = entry->classes; c && ! icon; c = c->next)
+ icon = get_icon_by_class (mgr, c->name);
+ return icon;
+}
diff --git a/grub-core/gfxmenu/theme_loader.c b/grub-core/gfxmenu/theme_loader.c
new file mode 100644
index 0000000..eae8308
--- /dev/null
+++ b/grub-core/gfxmenu/theme_loader.c
@@ -0,0 +1,828 @@
+/* theme_loader.c - Theme file loader for gfxmenu. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/file.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/video.h>
+#include <grub/gui_string_util.h>
+#include <grub/bitmap.h>
+#include <grub/bitmap_scale.h>
+#include <grub/gfxwidgets.h>
+#include <grub/gfxmenu_view.h>
+#include <grub/gui.h>
+#include <grub/color.h>
+
+static grub_err_t
+parse_proportional_spec (const char *value, signed *abs, grub_fixed_signed_t *prop);
+
+/* Construct a new box widget using ABSPATTERN to find the pixmap files for
+ it, storing the new box instance at *BOXPTR.
+ PATTERN should be of the form: "(hd0,0)/somewhere/style*.png".
+ The '*' then gets substituted with the various pixmap names that the
+ box uses. */
+static grub_err_t
+recreate_box_absolute (grub_gfxmenu_box_t *boxptr, const char *abspattern)
+{
+ char *prefix;
+ char *suffix;
+ char *star;
+ grub_gfxmenu_box_t box;
+
+ star = grub_strchr (abspattern, '*');
+ if (! star)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "missing `*' in box pixmap pattern `%s'", abspattern);
+
+ /* Prefix: Get the part before the '*'. */
+ prefix = grub_malloc (star - abspattern + 1);
+ if (! prefix)
+ return grub_errno;
+
+ grub_memcpy (prefix, abspattern, star - abspattern);
+ prefix[star - abspattern] = '\0';
+
+ /* Suffix: Everything after the '*' is the suffix. */
+ suffix = star + 1;
+
+ box = grub_gfxmenu_create_box (prefix, suffix);
+ grub_free (prefix);
+ if (! box)
+ return grub_errno;
+
+ if (*boxptr)
+ (*boxptr)->destroy (*boxptr);
+ *boxptr = box;
+ return grub_errno;
+}
+
+
+/* Construct a new box widget using PATTERN to find the pixmap files for it,
+ storing the new widget at *BOXPTR. PATTERN should be of the form:
+ "somewhere/style*.png". The '*' then gets substituted with the various
+ pixmap names that the widget uses.
+
+ Important! The value of *BOXPTR must be initialized! It must either
+ (1) Be 0 (a NULL pointer), or
+ (2) Be a pointer to a valid 'grub_gfxmenu_box_t' instance.
+ In this case, the previous instance is destroyed. */
+grub_err_t
+grub_gui_recreate_box (grub_gfxmenu_box_t *boxptr,
+ const char *pattern, const char *theme_dir)
+{
+ char *abspattern;
+
+ /* Check arguments. */
+ if (! pattern)
+ {
+ /* If no pixmap pattern is given, then just create an empty box. */
+ if (*boxptr)
+ (*boxptr)->destroy (*boxptr);
+ *boxptr = grub_gfxmenu_create_box (0, 0);
+ return grub_errno;
+ }
+
+ if (! theme_dir)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "styled box missing theme directory");
+
+ /* Resolve to an absolute path. */
+ abspattern = grub_resolve_relative_path (theme_dir, pattern);
+ if (! abspattern)
+ return grub_errno;
+
+ /* Create the box. */
+ recreate_box_absolute (boxptr, abspattern);
+ grub_free (abspattern);
+ return grub_errno;
+}
+
+static grub_err_t
+theme_get_unsigned_int_from_proportional (const char *value,
+ unsigned absolute_value,
+ unsigned int *parsed_value)
+{
+ grub_err_t err;
+ grub_fixed_signed_t frac;
+ signed pixels;
+ err = parse_proportional_spec (value, &pixels, &frac);
+ if (err != GRUB_ERR_NONE)
+ return err;
+ int result = grub_fixed_sfs_multiply (absolute_value, frac) + pixels;
+ if (result < 0)
+ result = 0;
+ *parsed_value = result;
+ return GRUB_ERR_NONE;
+}
+
+/* Set the specified property NAME on the view to the given string VALUE.
+ The caller is responsible for the lifetimes of NAME and VALUE. */
+static grub_err_t
+theme_set_string (grub_gfxmenu_view_t view,
+ const char *name,
+ const char *value,
+ const char *theme_dir,
+ const char *filename,
+ int line_num,
+ int col_num)
+{
+ if (! grub_strcmp ("title-font", name))
+ view->title_font = grub_font_get (value);
+ else if (! grub_strcmp ("message-font", name))
+ view->message_font = grub_font_get (value);
+ else if (! grub_strcmp ("terminal-font", name))
+ {
+ grub_free (view->terminal_font_name);
+ view->terminal_font_name = grub_strdup (value);
+ if (! view->terminal_font_name)
+ return grub_errno;
+ }
+ else if (! grub_strcmp ("title-color", name))
+ grub_video_parse_color (value, &view->title_color);
+ else if (! grub_strcmp ("message-color", name))
+ grub_video_parse_color (value, &view->message_color);
+ else if (! grub_strcmp ("message-bg-color", name))
+ grub_video_parse_color (value, &view->message_bg_color);
+ else if (! grub_strcmp ("desktop-image", name))
+ {
+ struct grub_video_bitmap *raw_bitmap;
+ char *path;
+ path = grub_resolve_relative_path (theme_dir, value);
+ if (! path)
+ return grub_errno;
+ if (grub_video_bitmap_load (&raw_bitmap, path) != GRUB_ERR_NONE)
+ {
+ grub_free (path);
+ return grub_errno;
+ }
+ grub_free(path);
+ grub_video_bitmap_destroy (view->raw_desktop_image);
+ view->raw_desktop_image = raw_bitmap;
+ }
+ else if (! grub_strcmp ("desktop-image-scale-method", name))
+ {
+ if (! value || ! grub_strcmp ("stretch", value))
+ view->desktop_image_scale_method =
+ GRUB_VIDEO_BITMAP_SELECTION_METHOD_STRETCH;
+ else if (! grub_strcmp ("crop", value))
+ view->desktop_image_scale_method =
+ GRUB_VIDEO_BITMAP_SELECTION_METHOD_CROP;
+ else if (! grub_strcmp ("padding", value))
+ view->desktop_image_scale_method =
+ GRUB_VIDEO_BITMAP_SELECTION_METHOD_PADDING;
+ else if (! grub_strcmp ("fitwidth", value))
+ view->desktop_image_scale_method =
+ GRUB_VIDEO_BITMAP_SELECTION_METHOD_FITWIDTH;
+ else if (! grub_strcmp ("fitheight", value))
+ view->desktop_image_scale_method =
+ GRUB_VIDEO_BITMAP_SELECTION_METHOD_FITHEIGHT;
+ else
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Unsupported scale method: %s",
+ value);
+ }
+ else if (! grub_strcmp ("desktop-image-h-align", name))
+ {
+ if (! grub_strcmp ("left", value))
+ view->desktop_image_h_align = GRUB_VIDEO_BITMAP_H_ALIGN_LEFT;
+ else if (! grub_strcmp ("center", value))
+ view->desktop_image_h_align = GRUB_VIDEO_BITMAP_H_ALIGN_CENTER;
+ else if (! grub_strcmp ("right", value))
+ view->desktop_image_h_align = GRUB_VIDEO_BITMAP_H_ALIGN_RIGHT;
+ else
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Unsupported horizontal align method: %s",
+ value);
+ }
+ else if (! grub_strcmp ("desktop-image-v-align", name))
+ {
+ if (! grub_strcmp ("top", value))
+ view->desktop_image_v_align = GRUB_VIDEO_BITMAP_V_ALIGN_TOP;
+ else if (! grub_strcmp ("center", value))
+ view->desktop_image_v_align = GRUB_VIDEO_BITMAP_V_ALIGN_CENTER;
+ else if (! grub_strcmp ("bottom", value))
+ view->desktop_image_v_align = GRUB_VIDEO_BITMAP_V_ALIGN_BOTTOM;
+ else
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Unsupported vertical align method: %s",
+ value);
+ }
+ else if (! grub_strcmp ("desktop-color", name))
+ grub_video_parse_color (value, &view->desktop_color);
+ else if (! grub_strcmp ("terminal-box", name))
+ {
+ grub_err_t err;
+ err = grub_gui_recreate_box (&view->terminal_box, value, theme_dir);
+ if (err != GRUB_ERR_NONE)
+ return err;
+ }
+ else if (! grub_strcmp ("terminal-border", name))
+ {
+ view->terminal_border = grub_strtoul (value, 0, 10);
+ if (grub_errno)
+ return grub_errno;
+ }
+ else if (! grub_strcmp ("terminal-left", name))
+ {
+ unsigned int tmp;
+ int err = theme_get_unsigned_int_from_proportional (value,
+ view->screen.width,
+ &tmp);
+ if (err != GRUB_ERR_NONE)
+ return err;
+ view->terminal_rect.x = tmp;
+ }
+ else if (! grub_strcmp ("terminal-top", name))
+ {
+ unsigned int tmp;
+ int err = theme_get_unsigned_int_from_proportional (value,
+ view->screen.height,
+ &tmp);
+ if (err != GRUB_ERR_NONE)
+ return err;
+ view->terminal_rect.y = tmp;
+ }
+ else if (! grub_strcmp ("terminal-width", name))
+ {
+ unsigned int tmp;
+ int err = theme_get_unsigned_int_from_proportional (value,
+ view->screen.width,
+ &tmp);
+ if (err != GRUB_ERR_NONE)
+ return err;
+ view->terminal_rect.width = tmp;
+ }
+ else if (! grub_strcmp ("terminal-height", name))
+ {
+ unsigned int tmp;
+ int err = theme_get_unsigned_int_from_proportional (value,
+ view->screen.height,
+ &tmp);
+ if (err != GRUB_ERR_NONE)
+ return err;
+ view->terminal_rect.height = tmp;
+ }
+ else if (! grub_strcmp ("title-text", name))
+ {
+ grub_free (view->title_text);
+ view->title_text = grub_strdup (value);
+ if (! view->title_text)
+ return grub_errno;
+ }
+ else
+ {
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "%s:%d:%d unknown property `%s'",
+ filename, line_num, col_num, name);
+ }
+ return grub_errno;
+}
+
+struct parsebuf
+{
+ char *buf;
+ int pos;
+ int len;
+ int line_num;
+ int col_num;
+ const char *filename;
+ char *theme_dir;
+ grub_gfxmenu_view_t view;
+};
+
+static int
+has_more (struct parsebuf *p)
+{
+ return p->pos < p->len;
+}
+
+static int
+read_char (struct parsebuf *p)
+{
+ if (has_more (p))
+ {
+ char c;
+ c = p->buf[p->pos++];
+ if (c == '\n')
+ {
+ p->line_num++;
+ p->col_num = 1;
+ }
+ else
+ {
+ p->col_num++;
+ }
+ return c;
+ }
+ else
+ return -1;
+}
+
+static int
+peek_char (struct parsebuf *p)
+{
+ if (has_more (p))
+ return p->buf[p->pos];
+ else
+ return -1;
+}
+
+static int
+is_whitespace (char c)
+{
+ return (c == ' '
+ || c == '\t'
+ || c == '\r'
+ || c == '\n'
+ || c == '\f');
+}
+
+static void
+skip_whitespace (struct parsebuf *p)
+{
+ while (has_more (p) && is_whitespace(peek_char (p)))
+ read_char (p);
+}
+
+static void
+advance_to_next_line (struct parsebuf *p)
+{
+ int c;
+
+ /* Eat characters up to the newline. */
+ do
+ {
+ c = read_char (p);
+ }
+ while (c != -1 && c != '\n');
+}
+
+static int
+is_identifier_char (int c)
+{
+ return (c != -1
+ && (grub_isalpha(c)
+ || grub_isdigit(c)
+ || c == '_'
+ || c == '-'));
+}
+
+static char *
+read_identifier (struct parsebuf *p)
+{
+ /* Index of the first character of the identifier in p->buf. */
+ int start;
+ /* Next index after the last character of the identifer in p->buf. */
+ int end;
+
+ skip_whitespace (p);
+
+ /* Capture the start of the identifier. */
+ start = p->pos;
+
+ /* Scan for the end. */
+ while (is_identifier_char (peek_char (p)))
+ read_char (p);
+ end = p->pos;
+
+ if (end - start < 1)
+ return 0;
+
+ return grub_new_substring (p->buf, start, end);
+}
+
+static char *
+read_expression (struct parsebuf *p)
+{
+ int start;
+ int end;
+
+ skip_whitespace (p);
+ if (peek_char (p) == '"')
+ {
+ /* Read as a quoted string.
+ The quotation marks are not included in the expression value. */
+ /* Skip opening quotation mark. */
+ read_char (p);
+ start = p->pos;
+ while (has_more (p) && peek_char (p) != '"')
+ read_char (p);
+ end = p->pos;
+ /* Skip the terminating quotation mark. */
+ read_char (p);
+ }
+ else if (peek_char (p) == '(')
+ {
+ /* Read as a parenthesized string -- for tuples/coordinates. */
+ /* The parentheses are included in the expression value. */
+ int c;
+
+ start = p->pos;
+ do
+ {
+ c = read_char (p);
+ }
+ while (c != -1 && c != ')');
+ end = p->pos;
+ }
+ else if (has_more (p))
+ {
+ /* Read as a single word -- for numeric values or words without
+ whitespace. */
+ start = p->pos;
+ while (has_more (p) && ! is_whitespace (peek_char (p)))
+ read_char (p);
+ end = p->pos;
+ }
+ else
+ {
+ /* The end of the theme file has been reached. */
+ grub_error (GRUB_ERR_IO, "%s:%d:%d expression expected in theme file",
+ p->filename, p->line_num, p->col_num);
+ return 0;
+ }
+
+ return grub_new_substring (p->buf, start, end);
+}
+
+static grub_err_t
+parse_proportional_spec (const char *value, signed *abs, grub_fixed_signed_t *prop)
+{
+ signed num;
+ const char *ptr;
+ int sig = 0;
+ *abs = 0;
+ *prop = 0;
+ ptr = value;
+ while (*ptr)
+ {
+ sig = 0;
+
+ while (*ptr == '-' || *ptr == '+')
+ {
+ if (*ptr == '-')
+ sig = !sig;
+ ptr++;
+ }
+
+ num = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ return grub_errno;
+ if (sig)
+ num = -num;
+ if (*ptr == '%')
+ {
+ *prop += grub_fixed_fsf_divide (grub_signed_to_fixed (num), 100);
+ ptr++;
+ }
+ else
+ *abs += num;
+ }
+ return GRUB_ERR_NONE;
+}
+
+
+/* Read a GUI object specification from the theme file.
+ Any components created will be added to the GUI container PARENT. */
+static grub_err_t
+read_object (struct parsebuf *p, grub_gui_container_t parent)
+{
+ grub_video_rect_t bounds;
+
+ char *name;
+ name = read_identifier (p);
+ if (! name)
+ goto cleanup;
+
+ grub_gui_component_t component = 0;
+ if (grub_strcmp (name, "label") == 0)
+ {
+ component = grub_gui_label_new ();
+ }
+ else if (grub_strcmp (name, "image") == 0)
+ {
+ component = grub_gui_image_new ();
+ }
+ else if (grub_strcmp (name, "vbox") == 0)
+ {
+ component = (grub_gui_component_t) grub_gui_vbox_new ();
+ }
+ else if (grub_strcmp (name, "hbox") == 0)
+ {
+ component = (grub_gui_component_t) grub_gui_hbox_new ();
+ }
+ else if (grub_strcmp (name, "canvas") == 0)
+ {
+ component = (grub_gui_component_t) grub_gui_canvas_new ();
+ }
+ else if (grub_strcmp (name, "progress_bar") == 0)
+ {
+ component = grub_gui_progress_bar_new ();
+ }
+ else if (grub_strcmp (name, "circular_progress") == 0)
+ {
+ component = grub_gui_circular_progress_new ();
+ }
+ else if (grub_strcmp (name, "boot_menu") == 0)
+ {
+ component = grub_gui_list_new ();
+ }
+ else
+ {
+ /* Unknown type. */
+ grub_error (GRUB_ERR_IO, "%s:%d:%d unknown object type `%s'",
+ p->filename, p->line_num, p->col_num, name);
+ goto cleanup;
+ }
+
+ if (! component)
+ goto cleanup;
+
+ /* Inform the component about the theme so it can find its resources. */
+ component->ops->set_property (component, "theme_dir", p->theme_dir);
+ component->ops->set_property (component, "theme_path", p->filename);
+
+ /* Add the component as a child of PARENT. */
+ bounds.x = 0;
+ bounds.y = 0;
+ bounds.width = -1;
+ bounds.height = -1;
+ component->ops->set_bounds (component, &bounds);
+ parent->ops->add (parent, component);
+
+ skip_whitespace (p);
+ if (read_char (p) != '{')
+ {
+ grub_error (GRUB_ERR_IO,
+ "%s:%d:%d expected `{' after object type name `%s'",
+ p->filename, p->line_num, p->col_num, name);
+ goto cleanup;
+ }
+
+ while (has_more (p))
+ {
+ skip_whitespace (p);
+
+ /* Check whether the end has been encountered. */
+ if (peek_char (p) == '}')
+ {
+ /* Skip the closing brace. */
+ read_char (p);
+ break;
+ }
+
+ if (peek_char (p) == '#')
+ {
+ /* Skip comments. */
+ advance_to_next_line (p);
+ continue;
+ }
+
+ if (peek_char (p) == '+')
+ {
+ /* Skip the '+'. */
+ read_char (p);
+
+ /* Check whether this component is a container. */
+ if (component->ops->is_instance (component, "container"))
+ {
+ /* Read the sub-object recursively and add it as a child. */
+ if (read_object (p, (grub_gui_container_t) component) != 0)
+ goto cleanup;
+ /* After reading the sub-object, resume parsing, expecting
+ another property assignment or sub-object definition. */
+ continue;
+ }
+ else
+ {
+ grub_error (GRUB_ERR_IO,
+ "%s:%d:%d attempted to add object to non-container",
+ p->filename, p->line_num, p->col_num);
+ goto cleanup;
+ }
+ }
+
+ char *property;
+ property = read_identifier (p);
+ if (! property)
+ {
+ grub_error (GRUB_ERR_IO, "%s:%d:%d identifier expected in theme file",
+ p->filename, p->line_num, p->col_num);
+ goto cleanup;
+ }
+
+ skip_whitespace (p);
+ if (read_char (p) != '=')
+ {
+ grub_error (GRUB_ERR_IO,
+ "%s:%d:%d expected `=' after property name `%s'",
+ p->filename, p->line_num, p->col_num, property);
+ grub_free (property);
+ goto cleanup;
+ }
+ skip_whitespace (p);
+
+ char *value;
+ value = read_expression (p);
+ if (! value)
+ {
+ grub_free (property);
+ goto cleanup;
+ }
+
+ /* Handle the property value. */
+ if (grub_strcmp (property, "left") == 0)
+ parse_proportional_spec (value, &component->x, &component->xfrac);
+ else if (grub_strcmp (property, "top") == 0)
+ parse_proportional_spec (value, &component->y, &component->yfrac);
+ else if (grub_strcmp (property, "width") == 0)
+ parse_proportional_spec (value, &component->w, &component->wfrac);
+ else if (grub_strcmp (property, "height") == 0)
+ parse_proportional_spec (value, &component->h, &component->hfrac);
+ else
+ /* General property handling. */
+ component->ops->set_property (component, property, value);
+
+ grub_free (value);
+ grub_free (property);
+ if (grub_errno != GRUB_ERR_NONE)
+ goto cleanup;
+ }
+
+cleanup:
+ grub_free (name);
+ return grub_errno;
+}
+
+static grub_err_t
+read_property (struct parsebuf *p)
+{
+ char *name;
+
+ /* Read the property name. */
+ name = read_identifier (p);
+ if (! name)
+ {
+ advance_to_next_line (p);
+ return grub_errno;
+ }
+
+ /* Skip whitespace before separator. */
+ skip_whitespace (p);
+
+ /* Read separator. */
+ if (read_char (p) != ':')
+ {
+ grub_error (GRUB_ERR_IO,
+ "%s:%d:%d missing separator after property name `%s'",
+ p->filename, p->line_num, p->col_num, name);
+ goto done;
+ }
+
+ /* Skip whitespace after separator. */
+ skip_whitespace (p);
+
+ /* Get the value based on its type. */
+ if (peek_char (p) == '"')
+ {
+ /* String value (e.g., '"My string"'). */
+ char *value = read_expression (p);
+ if (! value)
+ {
+ grub_error (GRUB_ERR_IO, "%s:%d:%d missing property value",
+ p->filename, p->line_num, p->col_num);
+ goto done;
+ }
+ /* If theme_set_string results in an error, grub_errno will be returned
+ below. */
+ theme_set_string (p->view, name, value, p->theme_dir,
+ p->filename, p->line_num, p->col_num);
+ grub_free (value);
+ }
+ else
+ {
+ grub_error (GRUB_ERR_IO,
+ "%s:%d:%d property value invalid; "
+ "enclose literal values in quotes (\")",
+ p->filename, p->line_num, p->col_num);
+ goto done;
+ }
+
+done:
+ grub_free (name);
+ return grub_errno;
+}
+
+/* Set properties on the view based on settings from the specified
+ theme file. */
+grub_err_t
+grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
+{
+ grub_file_t file;
+ struct parsebuf p;
+
+ p.view = view;
+ p.theme_dir = grub_get_dirname (theme_path);
+
+ file = grub_file_open (theme_path, GRUB_FILE_TYPE_THEME);
+ if (! file)
+ {
+ grub_free (p.theme_dir);
+ return grub_errno;
+ }
+
+ p.len = grub_file_size (file);
+ p.buf = grub_malloc (p.len);
+ p.pos = 0;
+ p.line_num = 1;
+ p.col_num = 1;
+ p.filename = theme_path;
+ if (! p.buf)
+ {
+ grub_file_close (file);
+ grub_free (p.theme_dir);
+ return grub_errno;
+ }
+ if (grub_file_read (file, p.buf, p.len) != p.len)
+ {
+ grub_free (p.buf);
+ grub_file_close (file);
+ grub_free (p.theme_dir);
+ return grub_errno;
+ }
+
+ if (view->canvas)
+ 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);
+
+ while (has_more (&p))
+ {
+ /* Skip comments (lines beginning with #). */
+ if (peek_char (&p) == '#')
+ {
+ advance_to_next_line (&p);
+ continue;
+ }
+
+ /* Find the first non-whitespace character. */
+ skip_whitespace (&p);
+
+ /* Handle the content. */
+ if (peek_char (&p) == '+')
+ {
+ /* Skip the '+'. */
+ read_char (&p);
+ read_object (&p, view->canvas);
+ }
+ else
+ {
+ read_property (&p);
+ }
+
+ if (grub_errno != GRUB_ERR_NONE)
+ goto fail;
+ }
+
+ /* Set the new theme path. */
+ grub_free (view->theme_path);
+ view->theme_path = grub_strdup (theme_path);
+ goto cleanup;
+
+fail:
+ if (view->canvas)
+ {
+ view->canvas->component.ops->destroy (view->canvas);
+ view->canvas = 0;
+ }
+
+cleanup:
+ grub_free (p.buf);
+ grub_file_close (file);
+ grub_free (p.theme_dir);
+ return grub_errno;
+}
diff --git a/grub-core/gfxmenu/view.c b/grub-core/gfxmenu/view.c
new file mode 100644
index 0000000..ad5e82b
--- /dev/null
+++ b/grub-core/gfxmenu/view.c
@@ -0,0 +1,647 @@
+/* view.c - Graphical menu interface MVC view. */
+/*
+ * 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/file.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/normal.h>
+#include <grub/video.h>
+#include <grub/gfxterm.h>
+#include <grub/bitmap.h>
+#include <grub/bitmap_scale.h>
+#include <grub/term.h>
+#include <grub/gfxwidgets.h>
+#include <grub/time.h>
+#include <grub/menu.h>
+#include <grub/menu_viewer.h>
+#include <grub/gfxmenu_view.h>
+#include <grub/gui_string_util.h>
+#include <grub/icon_manager.h>
+#include <grub/i18n.h>
+
+static void
+init_terminal (grub_gfxmenu_view_t view);
+static void
+init_background (grub_gfxmenu_view_t view);
+static grub_gfxmenu_view_t term_view;
+
+/* Create a new view object, loading the theme specified by THEME_PATH and
+ associating MODEL with the view. */
+grub_gfxmenu_view_t
+grub_gfxmenu_view_new (const char *theme_path,
+ int width, int height)
+{
+ grub_gfxmenu_view_t view;
+ grub_font_t default_font;
+ grub_video_rgba_color_t default_fg_color;
+ grub_video_rgba_color_t default_bg_color;
+
+ view = grub_malloc (sizeof (*view));
+ if (! view)
+ return 0;
+
+ while (grub_gfxmenu_timeout_notifications)
+ {
+ struct grub_gfxmenu_timeout_notify *p;
+ p = grub_gfxmenu_timeout_notifications;
+ grub_gfxmenu_timeout_notifications = grub_gfxmenu_timeout_notifications->next;
+ grub_free (p);
+ }
+
+ view->screen.x = 0;
+ view->screen.y = 0;
+ view->screen.width = width;
+ view->screen.height = height;
+
+ view->need_to_check_sanity = 1;
+ view->terminal_border = 3;
+ view->terminal_rect.width = view->screen.width * 7 / 10;
+ view->terminal_rect.height = view->screen.height * 7 / 10;
+ view->terminal_rect.x = view->screen.x + (view->screen.width
+ - view->terminal_rect.width) / 2;
+ view->terminal_rect.y = view->screen.y + (view->screen.height
+ - view->terminal_rect.height) / 2;
+
+ default_font = grub_font_get ("Unknown Regular 16");
+ default_fg_color = grub_video_rgba_color_rgb (0, 0, 0);
+ default_bg_color = grub_video_rgba_color_rgb (255, 255, 255);
+
+ view->canvas = 0;
+
+ view->title_font = default_font;
+ view->message_font = default_font;
+ view->terminal_font_name = grub_strdup ("Fixed 10");
+ view->title_color = default_fg_color;
+ view->message_color = default_bg_color;
+ view->message_bg_color = default_fg_color;
+ view->raw_desktop_image = 0;
+ view->scaled_desktop_image = 0;
+ view->desktop_image_scale_method = GRUB_VIDEO_BITMAP_SELECTION_METHOD_STRETCH;
+ view->desktop_image_h_align = GRUB_VIDEO_BITMAP_H_ALIGN_CENTER;
+ view->desktop_image_v_align = GRUB_VIDEO_BITMAP_V_ALIGN_CENTER;
+ view->desktop_color = default_bg_color;
+ view->terminal_box = grub_gfxmenu_create_box (0, 0);
+ view->title_text = grub_strdup (_("GRUB Boot Menu"));
+ view->progress_message_text = 0;
+ view->theme_path = 0;
+
+ /* Set the timeout bar's frame. */
+ view->progress_message_frame.width = view->screen.width * 4 / 5;
+ view->progress_message_frame.height = 50;
+ view->progress_message_frame.x = view->screen.x
+ + (view->screen.width - view->progress_message_frame.width) / 2;
+ view->progress_message_frame.y = view->screen.y
+ + view->screen.height - 90 - 20 - view->progress_message_frame.height;
+
+ if (grub_gfxmenu_view_load_theme (view, theme_path) != 0)
+ {
+ grub_gfxmenu_view_destroy (view);
+ return 0;
+ }
+
+ return view;
+}
+
+/* Destroy the view object. All used memory is freed. */
+void
+grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view)
+{
+ if (!view)
+ return;
+ while (grub_gfxmenu_timeout_notifications)
+ {
+ struct grub_gfxmenu_timeout_notify *p;
+ p = grub_gfxmenu_timeout_notifications;
+ grub_gfxmenu_timeout_notifications = grub_gfxmenu_timeout_notifications->next;
+ grub_free (p);
+ }
+ grub_video_bitmap_destroy (view->raw_desktop_image);
+ grub_video_bitmap_destroy (view->scaled_desktop_image);
+ if (view->terminal_box)
+ view->terminal_box->destroy (view->terminal_box);
+ grub_free (view->terminal_font_name);
+ grub_free (view->title_text);
+ grub_free (view->progress_message_text);
+ grub_free (view->theme_path);
+ if (view->canvas)
+ view->canvas->component.ops->destroy (view->canvas);
+ grub_free (view);
+}
+
+static void
+redraw_background (grub_gfxmenu_view_t view,
+ const grub_video_rect_t *bounds)
+{
+ if (view->scaled_desktop_image)
+ {
+ struct grub_video_bitmap *img = view->scaled_desktop_image;
+ grub_video_blit_bitmap (img, GRUB_VIDEO_BLIT_REPLACE,
+ bounds->x, bounds->y,
+ bounds->x - view->screen.x,
+ bounds->y - view->screen.y,
+ bounds->width, bounds->height);
+ }
+ else
+ {
+ grub_video_fill_rect (grub_video_map_rgba_color (view->desktop_color),
+ bounds->x, bounds->y,
+ bounds->width, bounds->height);
+ }
+}
+
+static void
+draw_title (grub_gfxmenu_view_t view)
+{
+ if (! view->title_text)
+ return;
+
+ /* Center the title. */
+ int title_width = grub_font_get_string_width (view->title_font,
+ view->title_text);
+ int x = (view->screen.width - title_width) / 2;
+ int y = 40 + grub_font_get_ascent (view->title_font);
+ grub_font_draw_string (view->title_text,
+ view->title_font,
+ grub_video_map_rgba_color (view->title_color),
+ x, y);
+}
+
+struct progress_value_data
+{
+ int visible;
+ int start;
+ int end;
+ int value;
+};
+
+struct grub_gfxmenu_timeout_notify *grub_gfxmenu_timeout_notifications;
+
+static void
+update_timeouts (int visible, int start, int value, int end)
+{
+ struct grub_gfxmenu_timeout_notify *cur;
+
+ for (cur = grub_gfxmenu_timeout_notifications; cur; cur = cur->next)
+ cur->set_state (cur->self, visible, start, value, end);
+}
+
+static void
+redraw_timeouts (struct grub_gfxmenu_view *view)
+{
+ struct grub_gfxmenu_timeout_notify *cur;
+
+ for (cur = grub_gfxmenu_timeout_notifications; cur; cur = cur->next)
+ {
+ grub_video_rect_t bounds;
+ cur->self->ops->get_bounds (cur->self, &bounds);
+ grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
+ grub_gfxmenu_view_redraw (view, &bounds);
+ }
+}
+
+void
+grub_gfxmenu_print_timeout (int timeout, void *data)
+{
+ struct grub_gfxmenu_view *view = data;
+
+ if (view->first_timeout == -1)
+ view->first_timeout = timeout;
+
+ update_timeouts (1, -view->first_timeout, -timeout, 0);
+ redraw_timeouts (view);
+ grub_video_swap_buffers ();
+ if (view->double_repaint)
+ redraw_timeouts (view);
+}
+
+void
+grub_gfxmenu_clear_timeout (void *data)
+{
+ struct grub_gfxmenu_view *view = data;
+
+ update_timeouts (0, 1, 0, 0);
+ redraw_timeouts (view);
+ grub_video_swap_buffers ();
+ if (view->double_repaint)
+ redraw_timeouts (view);
+}
+
+static void
+update_menu_visit (grub_gui_component_t component,
+ void *userdata)
+{
+ grub_gfxmenu_view_t view;
+ view = userdata;
+ if (component->ops->is_instance (component, "list"))
+ {
+ grub_gui_list_t list = (grub_gui_list_t) component;
+ list->ops->set_view_info (list, view);
+ }
+}
+
+/* Update any boot menu components with the current menu model and
+ theme path. */
+static void
+update_menu_components (grub_gfxmenu_view_t view)
+{
+ grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
+ update_menu_visit, view);
+}
+
+static void
+refresh_menu_visit (grub_gui_component_t component,
+ void *userdata)
+{
+ grub_gfxmenu_view_t view;
+ view = userdata;
+ if (component->ops->is_instance (component, "list"))
+ {
+ grub_gui_list_t list = (grub_gui_list_t) component;
+ list->ops->refresh_list (list, view);
+ }
+}
+
+/* Refresh list information (useful for submenus) */
+static void
+refresh_menu_components (grub_gfxmenu_view_t view)
+{
+ grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
+ refresh_menu_visit, view);
+}
+
+static void
+draw_message (grub_gfxmenu_view_t view)
+{
+ char *text = view->progress_message_text;
+ grub_video_rect_t f = view->progress_message_frame;
+ if (! text)
+ return;
+
+ grub_font_t font = view->message_font;
+ grub_video_color_t color = grub_video_map_rgba_color (view->message_color);
+
+ /* Border. */
+ grub_video_fill_rect (color,
+ f.x-1, f.y-1, f.width+2, f.height+2);
+ /* Fill. */
+ grub_video_fill_rect (grub_video_map_rgba_color (view->message_bg_color),
+ f.x, f.y, f.width, f.height);
+
+ /* Center the text. */
+ int text_width = grub_font_get_string_width (font, text);
+ int x = f.x + (f.width - text_width) / 2;
+ int y = (f.y + (f.height - grub_font_get_descent (font)) / 2
+ + grub_font_get_ascent (font) / 2);
+ grub_font_draw_string (text, font, color, x, y);
+}
+
+void
+grub_gfxmenu_view_redraw (grub_gfxmenu_view_t view,
+ const grub_video_rect_t *region)
+{
+ if (grub_video_have_common_points (&view->terminal_rect, region))
+ grub_gfxterm_schedule_repaint ();
+
+ grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
+ grub_video_area_status_t area_status;
+ grub_video_get_area_status (&area_status);
+ if (area_status == GRUB_VIDEO_AREA_ENABLED)
+ grub_video_set_region (region->x, region->y,
+ region->width, region->height);
+
+ redraw_background (view, region);
+ if (view->canvas)
+ view->canvas->component.ops->paint (view->canvas, region);
+ draw_title (view);
+ if (grub_video_have_common_points (&view->progress_message_frame, region))
+ draw_message (view);
+
+ if (area_status == GRUB_VIDEO_AREA_ENABLED)
+ grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
+}
+
+void
+grub_gfxmenu_view_draw (grub_gfxmenu_view_t view)
+{
+ init_terminal (view);
+
+ init_background (view);
+
+ /* Clear the screen; there may be garbage left over in video memory. */
+ grub_video_fill_rect (grub_video_map_rgb (0, 0, 0),
+ view->screen.x, view->screen.y,
+ view->screen.width, view->screen.height);
+ grub_video_swap_buffers ();
+ if (view->double_repaint)
+ grub_video_fill_rect (grub_video_map_rgb (0, 0, 0),
+ view->screen.x, view->screen.y,
+ view->screen.width, view->screen.height);
+
+ refresh_menu_components (view);
+ update_menu_components (view);
+
+ grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
+ grub_gfxmenu_view_redraw (view, &view->screen);
+ grub_video_swap_buffers ();
+ if (view->double_repaint)
+ {
+ grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
+ grub_gfxmenu_view_redraw (view, &view->screen);
+ }
+
+}
+
+static void
+redraw_menu_visit (grub_gui_component_t component,
+ void *userdata)
+{
+ grub_gfxmenu_view_t view;
+ view = userdata;
+ if (component->ops->is_instance (component, "list"))
+ {
+ grub_video_rect_t bounds;
+
+ component->ops->get_bounds (component, &bounds);
+ grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
+ grub_gfxmenu_view_redraw (view, &bounds);
+ }
+}
+
+void
+grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view)
+{
+ update_menu_components (view);
+
+ grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
+ redraw_menu_visit, view);
+ grub_video_swap_buffers ();
+ if (view->double_repaint)
+ {
+ grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
+ redraw_menu_visit, view);
+ }
+}
+
+void
+grub_gfxmenu_set_chosen_entry (int entry, void *data)
+{
+ grub_gfxmenu_view_t view = data;
+
+ view->selected = entry;
+ grub_gfxmenu_redraw_menu (view);
+}
+
+static void
+grub_gfxmenu_draw_terminal_box (void)
+{
+ grub_gfxmenu_box_t term_box;
+
+ term_box = term_view->terminal_box;
+ if (!term_box)
+ return;
+
+ grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
+
+ term_box->set_content_size (term_box, term_view->terminal_rect.width,
+ term_view->terminal_rect.height);
+
+ term_box->draw (term_box,
+ term_view->terminal_rect.x - term_box->get_left_pad (term_box),
+ term_view->terminal_rect.y - term_box->get_top_pad (term_box));
+}
+
+static void
+get_min_terminal (grub_font_t terminal_font,
+ unsigned int border_width,
+ unsigned int *min_terminal_width,
+ unsigned int *min_terminal_height)
+{
+ struct grub_font_glyph *glyph;
+ glyph = grub_font_get_glyph (terminal_font, 'M');
+ *min_terminal_width = (glyph? glyph->device_width : 8) * 80
+ + 2 * border_width;
+ *min_terminal_height = grub_font_get_max_char_height (terminal_font) * 24
+ + 2 * border_width;
+}
+
+static void
+terminal_sanity_check (grub_gfxmenu_view_t view)
+{
+ if (!view->need_to_check_sanity)
+ return;
+
+ /* terminal_font was checked before in the init_terminal function. */
+ grub_font_t terminal_font = grub_font_get (view->terminal_font_name);
+
+ /* Non-negative numbers below. */
+ int scr_x = view->screen.x;
+ int scr_y = view->screen.y;
+ int scr_width = view->screen.width;
+ int scr_height = view->screen.height;
+ int term_x = view->terminal_rect.x;
+ int term_y = view->terminal_rect.y;
+ int term_width = view->terminal_rect.width;
+ int term_height = view->terminal_rect.height;
+
+ /* Check that border_width isn't too big. */
+ unsigned int border_width = view->terminal_border;
+ unsigned int min_terminal_width;
+ unsigned int min_terminal_height;
+ get_min_terminal (terminal_font, border_width,
+ &min_terminal_width, &min_terminal_height);
+ if (border_width > 3 && ((int) min_terminal_width >= scr_width
+ || (int) min_terminal_height >= scr_height))
+ {
+ border_width = 3;
+ get_min_terminal (terminal_font, border_width,
+ &min_terminal_width, &min_terminal_height);
+ }
+
+ /* Sanity checks. */
+ if (term_width > scr_width)
+ term_width = scr_width;
+ if (term_height > scr_height)
+ term_height = scr_height;
+
+ if (scr_width <= (int) min_terminal_width
+ || scr_height <= (int) min_terminal_height)
+ {
+ /* The screen resulution is too low. Use all space, except a small border
+ to show the user, that it is a window. Then center the window. */
+ term_width = scr_width - 6 * border_width;
+ term_height = scr_height - 6 * border_width;
+ term_x = scr_x + (scr_width - term_width) / 2;
+ term_y = scr_y + (scr_height - term_height) / 2;
+ }
+ else if (term_width < (int) min_terminal_width
+ || term_height < (int) min_terminal_height)
+ {
+ /* The screen resolution is big enough. Make sure, that terminal screen
+ dimensions aren't less than minimal values. Then center the window. */
+ term_width = (int) min_terminal_width;
+ term_height = (int) min_terminal_height;
+ term_x = scr_x + (scr_width - term_width) / 2;
+ term_y = scr_y + (scr_height - term_height) / 2;
+ }
+
+ /* At this point w and h are satisfying. */
+ if (term_x + term_width > scr_width)
+ term_x = scr_width - term_width;
+ if (term_y + term_height > scr_height)
+ term_y = scr_height - term_height;
+
+ /* Write down corrected data. */
+ view->terminal_rect.x = (unsigned int) term_x;
+ view->terminal_rect.y = (unsigned int) term_y;
+ view->terminal_rect.width = (unsigned int) term_width;
+ view->terminal_rect.height = (unsigned int) term_height;
+ view->terminal_border = border_width;
+
+ view->need_to_check_sanity = 0;
+}
+
+static void
+init_terminal (grub_gfxmenu_view_t view)
+{
+ grub_font_t terminal_font;
+
+ terminal_font = grub_font_get (view->terminal_font_name);
+ if (!terminal_font)
+ {
+ grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
+ return;
+ }
+
+ /* Check that terminal window size and position are sane. */
+ terminal_sanity_check (view);
+
+ term_view = view;
+
+ /* Note: currently there is no API for changing the gfxterm font
+ on the fly, so whatever font the initially loaded theme specifies
+ will be permanent. */
+ grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY,
+ view->terminal_rect.x,
+ view->terminal_rect.y,
+ view->terminal_rect.width,
+ view->terminal_rect.height,
+ view->double_repaint,
+ terminal_font,
+ view->terminal_border);
+ grub_gfxterm_decorator_hook = grub_gfxmenu_draw_terminal_box;
+}
+
+static void
+init_background (grub_gfxmenu_view_t view)
+{
+ if (view->scaled_desktop_image)
+ return;
+
+ struct grub_video_bitmap *scaled_bitmap;
+ if (view->desktop_image_scale_method ==
+ GRUB_VIDEO_BITMAP_SELECTION_METHOD_STRETCH)
+ grub_video_bitmap_create_scaled (&scaled_bitmap,
+ view->screen.width,
+ view->screen.height,
+ view->raw_desktop_image,
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
+ else
+ grub_video_bitmap_scale_proportional (&scaled_bitmap,
+ view->screen.width,
+ view->screen.height,
+ view->raw_desktop_image,
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST,
+ view->desktop_image_scale_method,
+ view->desktop_image_v_align,
+ view->desktop_image_h_align);
+ if (! scaled_bitmap)
+ return;
+ view->scaled_desktop_image = scaled_bitmap;
+
+}
+
+/* FIXME: previously notifications were displayed in special case.
+ Is it necessary?
+ */
+#if 0
+/* Sets MESSAGE as the progress message for the view.
+ MESSAGE can be 0, in which case no message is displayed. */
+static void
+set_progress_message (grub_gfxmenu_view_t view, const char *message)
+{
+ grub_free (view->progress_message_text);
+ if (message)
+ view->progress_message_text = grub_strdup (message);
+ else
+ view->progress_message_text = 0;
+}
+
+static void
+notify_booting (grub_menu_entry_t entry, void *userdata)
+{
+ grub_gfxmenu_view_t view = (grub_gfxmenu_view_t) userdata;
+
+ char *s = grub_malloc (100 + grub_strlen (entry->title));
+ if (!s)
+ return;
+
+ grub_sprintf (s, "Booting '%s'", entry->title);
+ set_progress_message (view, s);
+ grub_free (s);
+ grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
+ grub_video_swap_buffers ();
+ if (view->double_repaint)
+ grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
+}
+
+static void
+notify_fallback (grub_menu_entry_t entry, void *userdata)
+{
+ grub_gfxmenu_view_t view = (grub_gfxmenu_view_t) userdata;
+
+ char *s = grub_malloc (100 + grub_strlen (entry->title));
+ if (!s)
+ return;
+
+ grub_sprintf (s, "Falling back to '%s'", entry->title);
+ set_progress_message (view, s);
+ grub_free (s);
+ grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
+ grub_video_swap_buffers ();
+ if (view->double_repaint)
+ grub_gfxmenu_view_redraw (view, &view->progress_message_frame);
+}
+
+static void
+notify_execution_failure (void *userdata __attribute__ ((unused)))
+{
+}
+
+
+static struct grub_menu_execute_callback execute_callback =
+{
+ .notify_booting = notify_booting,
+ .notify_fallback = notify_fallback,
+ .notify_failure = notify_execution_failure
+};
+
+#endif
diff --git a/grub-core/gfxmenu/widget-box.c b/grub-core/gfxmenu/widget-box.c
new file mode 100644
index 0000000..470597d
--- /dev/null
+++ b/grub-core/gfxmenu/widget-box.c
@@ -0,0 +1,360 @@
+/* widget_box.c - Pixmap-stylized box widget. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/video.h>
+#include <grub/bitmap.h>
+#include <grub/bitmap_scale.h>
+#include <grub/gfxwidgets.h>
+
+enum box_pixmaps
+{
+ BOX_PIXMAP_NW, BOX_PIXMAP_NE, BOX_PIXMAP_SE, BOX_PIXMAP_SW,
+ BOX_PIXMAP_N, BOX_PIXMAP_E, BOX_PIXMAP_S, BOX_PIXMAP_W,
+ BOX_PIXMAP_CENTER
+};
+
+static const char *box_pixmap_names[] = {
+ /* Corners: */
+ "nw", "ne", "se", "sw",
+ /* Sides: */
+ "n", "e", "s", "w",
+ /* Center: */
+ "c"
+};
+
+#define BOX_NUM_PIXMAPS (sizeof(box_pixmap_names)/sizeof(*box_pixmap_names))
+
+static int
+get_height (struct grub_video_bitmap *bitmap)
+{
+ if (bitmap)
+ return grub_video_bitmap_get_height (bitmap);
+ else
+ return 0;
+}
+
+static int
+get_width (struct grub_video_bitmap *bitmap)
+{
+ if (bitmap)
+ return grub_video_bitmap_get_width (bitmap);
+ else
+ return 0;
+}
+
+static void
+blit (grub_gfxmenu_box_t self, int pixmap_index, int x, int y)
+{
+ struct grub_video_bitmap *bitmap;
+ bitmap = self->scaled_pixmaps[pixmap_index];
+ if (! bitmap)
+ return;
+ grub_video_blit_bitmap (bitmap, GRUB_VIDEO_BLIT_BLEND,
+ x, y, 0, 0,
+ grub_video_bitmap_get_width (bitmap),
+ grub_video_bitmap_get_height (bitmap));
+}
+
+static void
+draw (grub_gfxmenu_box_t self, int x, int y)
+{
+ int height_n;
+ int width_w;
+ int tmp;
+
+ /* Count maximum height of NW, N, NE. */
+ height_n = get_height (self->scaled_pixmaps[BOX_PIXMAP_NW]);
+ tmp = get_height (self->scaled_pixmaps[BOX_PIXMAP_N]);
+ if (tmp > height_n)
+ height_n = tmp;
+ tmp = get_height (self->scaled_pixmaps[BOX_PIXMAP_NE]);
+ if (tmp > height_n)
+ height_n = tmp;
+
+ /* Count maximum width of NW, W, SW. */
+ width_w = get_width (self->scaled_pixmaps[BOX_PIXMAP_NW]);
+ tmp = get_width (self->scaled_pixmaps[BOX_PIXMAP_W]);
+ if (tmp > width_w)
+ width_w = tmp;
+ tmp = get_width (self->scaled_pixmaps[BOX_PIXMAP_SW]);
+ if (tmp > width_w)
+ width_w = tmp;
+
+ /* Draw sides. */
+ blit (self, BOX_PIXMAP_N, x + width_w, y);
+ blit (self, BOX_PIXMAP_S, x + width_w, y + height_n + self->content_height);
+ blit (self, BOX_PIXMAP_E, x + width_w + self->content_width, y + height_n);
+ blit (self, BOX_PIXMAP_W, x, y + height_n);
+
+ /* Draw corners. */
+ blit (self, BOX_PIXMAP_NW, x, y);
+ blit (self, BOX_PIXMAP_NE, x + width_w + self->content_width, y);
+ blit (self, BOX_PIXMAP_SE,
+ x + width_w + self->content_width,
+ y + height_n + self->content_height);
+ blit (self, BOX_PIXMAP_SW, x, y + height_n + self->content_height);
+
+ /* Draw center. */
+ blit (self, BOX_PIXMAP_CENTER, x + width_w, y + height_n);
+}
+
+static grub_err_t
+scale_pixmap (grub_gfxmenu_box_t self, int i, int w, int h)
+{
+ struct grub_video_bitmap **scaled = &self->scaled_pixmaps[i];
+ struct grub_video_bitmap *raw = self->raw_pixmaps[i];
+
+ if (raw == 0)
+ return grub_errno;
+
+ if (w == -1)
+ w = grub_video_bitmap_get_width (raw);
+ if (h == -1)
+ h = grub_video_bitmap_get_height (raw);
+
+ if (*scaled == 0
+ || ((int) grub_video_bitmap_get_width (*scaled) != w)
+ || ((int) grub_video_bitmap_get_height (*scaled) != h))
+ {
+ if (*scaled)
+ {
+ grub_video_bitmap_destroy (*scaled);
+ *scaled = 0;
+ }
+
+ /* Don't try to create a bitmap with a zero dimension. */
+ if (w != 0 && h != 0)
+ grub_video_bitmap_create_scaled (scaled, w, h, raw,
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
+ }
+
+ return grub_errno;
+}
+
+static void
+set_content_size (grub_gfxmenu_box_t self,
+ int width, int height)
+{
+ self->content_width = width;
+ self->content_height = height;
+
+ /* Resize sides to match the width and height. */
+ /* It is assumed that the corners width/height match the adjacent sides. */
+
+ /* Resize N and S sides to match width. */
+ if (scale_pixmap(self, BOX_PIXMAP_N, width, -1) != GRUB_ERR_NONE)
+ return;
+ if (scale_pixmap(self, BOX_PIXMAP_S, width, -1) != GRUB_ERR_NONE)
+ return;
+
+ /* Resize E and W sides to match height. */
+ if (scale_pixmap(self, BOX_PIXMAP_E, -1, height) != GRUB_ERR_NONE)
+ return;
+ if (scale_pixmap(self, BOX_PIXMAP_W, -1, height) != GRUB_ERR_NONE)
+ return;
+
+ /* Don't scale the corners--they are assumed to match the sides. */
+ if (scale_pixmap(self, BOX_PIXMAP_NW, -1, -1) != GRUB_ERR_NONE)
+ return;
+ if (scale_pixmap(self, BOX_PIXMAP_SW, -1, -1) != GRUB_ERR_NONE)
+ return;
+ if (scale_pixmap(self, BOX_PIXMAP_NE, -1, -1) != GRUB_ERR_NONE)
+ return;
+ if (scale_pixmap(self, BOX_PIXMAP_SE, -1, -1) != GRUB_ERR_NONE)
+ return;
+
+ /* Scale the center area. */
+ if (scale_pixmap(self, BOX_PIXMAP_CENTER, width, height) != GRUB_ERR_NONE)
+ return;
+}
+
+static int
+get_border_width (grub_gfxmenu_box_t self)
+{
+ return (get_width (self->raw_pixmaps[BOX_PIXMAP_E])
+ + get_width (self->raw_pixmaps[BOX_PIXMAP_W]));
+}
+
+static int
+get_left_pad (grub_gfxmenu_box_t self)
+{
+ int v, c;
+
+ v = get_width (self->raw_pixmaps[BOX_PIXMAP_W]);
+ c = get_width (self->raw_pixmaps[BOX_PIXMAP_NW]);
+ if (c > v)
+ v = c;
+ c = get_width (self->raw_pixmaps[BOX_PIXMAP_SW]);
+ if (c > v)
+ v = c;
+
+ return v;
+}
+
+static int
+get_top_pad (grub_gfxmenu_box_t self)
+{
+ int v, c;
+
+ v = get_height (self->raw_pixmaps[BOX_PIXMAP_N]);
+ c = get_height (self->raw_pixmaps[BOX_PIXMAP_NW]);
+ if (c > v)
+ v = c;
+ c = get_height (self->raw_pixmaps[BOX_PIXMAP_NE]);
+ if (c > v)
+ v = c;
+
+ return v;
+}
+
+static int
+get_right_pad (grub_gfxmenu_box_t self)
+{
+ int v, c;
+
+ v = get_width (self->raw_pixmaps[BOX_PIXMAP_E]);
+ c = get_width (self->raw_pixmaps[BOX_PIXMAP_NE]);
+ if (c > v)
+ v = c;
+ c = get_width (self->raw_pixmaps[BOX_PIXMAP_SE]);
+ if (c > v)
+ v = c;
+
+ return v;
+}
+
+static int
+get_bottom_pad (grub_gfxmenu_box_t self)
+{
+ int v, c;
+
+ v = get_height (self->raw_pixmaps[BOX_PIXMAP_S]);
+ c = get_height (self->raw_pixmaps[BOX_PIXMAP_SW]);
+ if (c > v)
+ v = c;
+ c = get_height (self->raw_pixmaps[BOX_PIXMAP_SE]);
+ if (c > v)
+ v = c;
+
+ return v;
+}
+
+static void
+destroy (grub_gfxmenu_box_t self)
+{
+ unsigned i;
+ for (i = 0; i < BOX_NUM_PIXMAPS; i++)
+ {
+ if (self->raw_pixmaps[i])
+ grub_video_bitmap_destroy(self->raw_pixmaps[i]);
+ self->raw_pixmaps[i] = 0;
+
+ if (self->scaled_pixmaps[i])
+ grub_video_bitmap_destroy(self->scaled_pixmaps[i]);
+ self->scaled_pixmaps[i] = 0;
+ }
+ grub_free (self->raw_pixmaps);
+ self->raw_pixmaps = 0;
+ grub_free (self->scaled_pixmaps);
+ self->scaled_pixmaps = 0;
+
+ /* Free self: must be the last step! */
+ grub_free (self);
+}
+
+
+/* Create a new box. If PIXMAPS_PREFIX and PIXMAPS_SUFFIX are both non-null,
+ then an attempt is made to load the north, south, east, west, northwest,
+ northeast, southeast, southwest, and center pixmaps.
+ If either PIXMAPS_PREFIX or PIXMAPS_SUFFIX is 0, then no pixmaps are
+ loaded, and the box has zero-width borders and is drawn transparent. */
+grub_gfxmenu_box_t
+grub_gfxmenu_create_box (const char *pixmaps_prefix,
+ const char *pixmaps_suffix)
+{
+ unsigned i;
+ grub_gfxmenu_box_t box;
+
+ box = (grub_gfxmenu_box_t) grub_malloc (sizeof (*box));
+ if (! box)
+ return 0;
+
+ box->content_width = 0;
+ box->content_height = 0;
+ box->raw_pixmaps =
+ (struct grub_video_bitmap **)
+ grub_calloc (BOX_NUM_PIXMAPS, sizeof (struct grub_video_bitmap *));
+ box->scaled_pixmaps =
+ (struct grub_video_bitmap **)
+ grub_calloc (BOX_NUM_PIXMAPS, sizeof (struct grub_video_bitmap *));
+
+ /* Initialize all pixmap pointers to NULL so that proper destruction can
+ be performed if an error is encountered partway through construction. */
+ for (i = 0; i < BOX_NUM_PIXMAPS; i++)
+ box->raw_pixmaps[i] = 0;
+ for (i = 0; i < BOX_NUM_PIXMAPS; i++)
+ box->scaled_pixmaps[i] = 0;
+
+ /* Load the pixmaps. */
+ for (i = 0; i < BOX_NUM_PIXMAPS; i++)
+ {
+ if (pixmaps_prefix && pixmaps_suffix)
+ {
+ char *path;
+ char *path_end;
+
+ path = grub_malloc (grub_strlen (pixmaps_prefix)
+ + grub_strlen (box_pixmap_names[i])
+ + grub_strlen (pixmaps_suffix)
+ + 1);
+ if (! path)
+ goto fail_and_destroy;
+
+ /* Construct the specific path for this pixmap. */
+ path_end = grub_stpcpy (path, pixmaps_prefix);
+ path_end = grub_stpcpy (path_end, box_pixmap_names[i]);
+ path_end = grub_stpcpy (path_end, pixmaps_suffix);
+
+ grub_video_bitmap_load (&box->raw_pixmaps[i], path);
+ grub_free (path);
+
+ /* Ignore missing pixmaps. */
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+
+ box->draw = draw;
+ box->set_content_size = set_content_size;
+ box->get_border_width = get_border_width;
+
+ box->get_left_pad = get_left_pad;
+ box->get_top_pad = get_top_pad;
+ box->get_right_pad = get_right_pad;
+ box->get_bottom_pad = get_bottom_pad;
+ box->destroy = destroy;
+ return box;
+
+fail_and_destroy:
+ destroy (box);
+ return 0;
+}
diff --git a/grub-core/gmodule.pl.in b/grub-core/gmodule.pl.in
new file mode 100644
index 0000000..78aa1e6
--- /dev/null
+++ b/grub-core/gmodule.pl.in
@@ -0,0 +1,30 @@
+###
+### Generate GDB commands, that load symbols for specified module,
+### with proper section relocations. See .gdbinit
+###
+### $Id: gmodule.pl,v 1.2 2006/05/14 11:38:42 lkundrak Exp lkundrak $
+### Lubomir Kundrak <lkudrak@skosi.org>
+###
+
+use strict;
+
+while (<>) {
+ my ($name, %sections) = split;
+
+ print "add-symbol-file $name.module";
+
+ open (READELF, "readelf -S $name.mod |") or die;
+ while (<READELF>) {
+ /\[\s*(\d+)\]\s+(\.\S+)/ or next;
+
+ if ($2 eq '.text') {
+ print " $sections{$1}";
+ next;
+ }
+
+ print " -s $2 $sections{$1}"
+ if ($sections{$1} ne '0x0' and $sections{$1} ne '');
+ };
+ close (READELF);
+ print "\n";
+}
diff --git a/grub-core/hello/hello.c b/grub-core/hello/hello.c
new file mode 100644
index 0000000..456b7c3
--- /dev/null
+++ b/grub-core/hello/hello.c
@@ -0,0 +1,51 @@
+/* hello.c - test module for dynamic loading */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2007 Free Software Foundation, Inc.
+ * Copyright (C) 2003 NIIBE Yutaka <gniibe@m17n.org>
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_hello (grub_extcmd_context_t ctxt __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_printf ("%s\n", _("Hello World"));
+ return 0;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(hello)
+{
+ cmd = grub_register_extcmd ("hello", grub_cmd_hello, 0, 0,
+ N_("Say `Hello World'."), 0);
+}
+
+GRUB_MOD_FINI(hello)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/hook/datehook.c b/grub-core/hook/datehook.c
new file mode 100644
index 0000000..ac75908
--- /dev/null
+++ b/grub-core/hook/datehook.c
@@ -0,0 +1,110 @@
+/* datehook.c - Module to install datetime hooks. */
+/*
+ * 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/dl.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/normal.h>
+#include <grub/datetime.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const char *grub_datetime_names[] =
+{
+ "YEAR",
+ "MONTH",
+ "DAY",
+ "HOUR",
+ "MINUTE",
+ "SECOND",
+ "WEEKDAY",
+};
+
+static const char *
+grub_read_hook_datetime (struct grub_env_var *var,
+ const char *val __attribute__ ((unused)))
+{
+ struct grub_datetime datetime;
+ static char buf[6];
+
+ buf[0] = 0;
+ if (! grub_get_datetime (&datetime))
+ {
+ int i;
+
+ for (i = 0; i < 7; i++)
+ if (grub_strcmp (var->name, grub_datetime_names[i]) == 0)
+ {
+ int n;
+
+ switch (i)
+ {
+ case 0:
+ n = datetime.year;
+ break;
+ case 1:
+ n = datetime.month;
+ break;
+ case 2:
+ n = datetime.day;
+ break;
+ case 3:
+ n = datetime.hour;
+ break;
+ case 4:
+ n = datetime.minute;
+ break;
+ case 5:
+ n = datetime.second;
+ break;
+ default:
+ return grub_get_weekday_name (&datetime);
+ }
+
+ grub_snprintf (buf, sizeof (buf), "%d", n);
+ break;
+ }
+ }
+
+ return buf;
+}
+
+GRUB_MOD_INIT(datehook)
+{
+ unsigned i;
+
+ for (i = 0; i < ARRAY_SIZE (grub_datetime_names); i++)
+ {
+ grub_register_variable_hook (grub_datetime_names[i],
+ grub_read_hook_datetime, 0);
+ grub_env_export (grub_datetime_names[i]);
+ }
+}
+
+GRUB_MOD_FINI(datehook)
+{
+ unsigned i;
+
+ for (i = 0; i < ARRAY_SIZE (grub_datetime_names); i++)
+ {
+ grub_register_variable_hook (grub_datetime_names[i], 0, 0);
+ grub_env_unset (grub_datetime_names[i]);
+ }
+}
diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c
new file mode 100644
index 0000000..a458c3a
--- /dev/null
+++ b/grub-core/io/bufio.c
@@ -0,0 +1,214 @@
+/* bufio.c - buffered io access */
+/*
+ * 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/err.h>
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/fs.h>
+#include <grub/bufio.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_BUFIO_DEF_SIZE 8192
+#define GRUB_BUFIO_MAX_SIZE 1048576
+
+struct grub_bufio
+{
+ grub_file_t file;
+ grub_size_t block_size;
+ grub_size_t buffer_len;
+ grub_off_t buffer_at;
+ char buffer[0];
+};
+typedef struct grub_bufio *grub_bufio_t;
+
+static struct grub_fs grub_bufio_fs;
+
+grub_file_t
+grub_bufio_open (grub_file_t io, grub_size_t size)
+{
+ grub_file_t file;
+ grub_bufio_t bufio = 0;
+
+ file = (grub_file_t) grub_zalloc (sizeof (*file));
+ if (! file)
+ return 0;
+
+ if (size == 0)
+ size = GRUB_BUFIO_DEF_SIZE;
+ else if (size > GRUB_BUFIO_MAX_SIZE)
+ size = GRUB_BUFIO_MAX_SIZE;
+
+ if (size > io->size)
+ size = ((io->size > GRUB_BUFIO_MAX_SIZE) ? GRUB_BUFIO_MAX_SIZE :
+ io->size);
+
+ /*
+ * Round up size to power of 2 which the binary math to
+ * calculate next_buf in grub_bufio_read() requires.
+ */
+ while (size & (size - 1))
+ size = (size | (size - 1)) + 1;
+
+ bufio = grub_zalloc (sizeof (struct grub_bufio) + size);
+ if (! bufio)
+ {
+ grub_free (file);
+ return 0;
+ }
+
+ bufio->file = io;
+ bufio->block_size = size;
+
+ file->device = io->device;
+ file->size = io->size;
+ file->data = bufio;
+ file->fs = &grub_bufio_fs;
+ file->not_easily_seekable = io->not_easily_seekable;
+
+ return file;
+}
+
+grub_file_t
+grub_buffile_open (const char *name, enum grub_file_type type, grub_size_t size)
+{
+ grub_file_t io, file;
+
+ io = grub_file_open (name, type);
+ if (! io)
+ return 0;
+
+ file = grub_bufio_open (io, size);
+ if (! file)
+ {
+ grub_file_close (io);
+ return 0;
+ }
+
+ return file;
+}
+
+static grub_ssize_t
+grub_bufio_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ grub_size_t res = 0;
+ grub_off_t next_buf;
+ grub_bufio_t bufio = file->data;
+ grub_ssize_t really_read;
+
+ if (file->size == GRUB_FILE_SIZE_UNKNOWN)
+ file->size = bufio->file->size;
+
+ /* First part: use whatever we already have in the buffer. */
+ if ((file->offset >= bufio->buffer_at) &&
+ (file->offset < bufio->buffer_at + bufio->buffer_len))
+ {
+ grub_size_t n;
+ grub_uint64_t pos;
+
+ pos = file->offset - bufio->buffer_at;
+ n = bufio->buffer_len - pos;
+ if (n > len)
+ n = len;
+
+ grub_memcpy (buf, &bufio->buffer[pos], n);
+ len -= n;
+ res += n;
+
+ buf += n;
+ }
+ if (len == 0)
+ return res;
+
+ /* Need to read some more. */
+ next_buf = (file->offset + res + len - 1) & ~((grub_off_t) bufio->block_size - 1);
+ /* Now read between file->offset + res and bufio->buffer_at. */
+ if (file->offset + res < next_buf)
+ {
+ grub_size_t read_now;
+ read_now = next_buf - (file->offset + res);
+ grub_file_seek (bufio->file, file->offset + res);
+ really_read = grub_file_read (bufio->file, buf, read_now);
+ if (really_read < 0)
+ return -1;
+ if (file->size == GRUB_FILE_SIZE_UNKNOWN)
+ file->size = bufio->file->size;
+ len -= really_read;
+ buf += really_read;
+ res += really_read;
+
+ /* Partial read. File ended unexpectedly. Save the last chunk in buffer.
+ */
+ if (really_read != (grub_ssize_t) read_now)
+ {
+ bufio->buffer_len = really_read;
+ if (bufio->buffer_len > bufio->block_size)
+ bufio->buffer_len = bufio->block_size;
+ bufio->buffer_at = file->offset + res - bufio->buffer_len;
+ grub_memcpy (&bufio->buffer[0], buf - bufio->buffer_len,
+ bufio->buffer_len);
+ return res;
+ }
+ }
+
+ /* Read into buffer. */
+ grub_file_seek (bufio->file, next_buf);
+ really_read = grub_file_read (bufio->file, bufio->buffer,
+ bufio->block_size);
+ if (really_read < 0)
+ return -1;
+ bufio->buffer_at = next_buf;
+ bufio->buffer_len = really_read;
+
+ if (file->size == GRUB_FILE_SIZE_UNKNOWN)
+ file->size = bufio->file->size;
+
+ if (len > bufio->buffer_len)
+ len = bufio->buffer_len;
+ grub_memcpy (buf, &bufio->buffer[file->offset + res - next_buf], len);
+ res += len;
+
+ return res;
+}
+
+static grub_err_t
+grub_bufio_close (grub_file_t file)
+{
+ grub_bufio_t bufio = file->data;
+
+ grub_file_close (bufio->file);
+ grub_free (bufio);
+
+ file->device = 0;
+
+ return grub_errno;
+}
+
+static struct grub_fs grub_bufio_fs =
+ {
+ .name = "bufio",
+ .fs_dir = 0,
+ .fs_open = 0,
+ .fs_read = grub_bufio_read,
+ .fs_close = grub_bufio_close,
+ .fs_label = 0,
+ .next = 0
+ };
diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c
new file mode 100644
index 0000000..aea86a0
--- /dev/null
+++ b/grub-core/io/gzio.c
@@ -0,0 +1,1444 @@
+/* gzio.c - decompression support for gzip */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2005,2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Most of this file was originally the source file "inflate.c", written
+ * by Mark Adler. It has been very heavily modified. In particular, the
+ * original would run through the whole file at once, and this version can
+ * be stopped and restarted on any boundary during the decompression process.
+ *
+ * The license and header comments that file are included here.
+ */
+
+/* inflate.c -- Not copyrighted 1992 by Mark Adler
+ version c10p1, 10 January 1993 */
+
+/* You can do whatever you like with this source file, though I would
+ prefer that if you modify it and redistribute it that you include
+ comments to that effect with your name and the date. Thank you.
+ */
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/fs.h>
+#include <grub/file.h>
+#include <grub/dl.h>
+#include <grub/deflate.h>
+#include <grub/i18n.h>
+#include <grub/crypto.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/*
+ * Window Size
+ *
+ * This must be a power of two, and at least 32K for zip's deflate method
+ */
+
+#define WSIZE 0x8000
+
+
+#define INBUFSIZ 0x2000
+
+/* The state stored in filesystem-specific data. */
+struct grub_gzio
+{
+ /* The underlying file object. */
+ grub_file_t file;
+ /* If input is in memory following fields are used instead of file. */
+ grub_size_t mem_input_size, mem_input_off;
+ grub_uint8_t *mem_input;
+ /* The offset at which the data starts in the underlying file. */
+ grub_off_t data_offset;
+ /* The type of current block. */
+ int block_type;
+ /* The length of current block. */
+ int block_len;
+ /* The flag of the last block. */
+ int last_block;
+ /* The flag of codes. */
+ int code_state;
+ /* The length of a copy. */
+ unsigned inflate_n;
+ /* The index of a copy. */
+ unsigned inflate_d;
+ /* The input buffer. */
+ grub_uint8_t inbuf[INBUFSIZ];
+ int inbuf_d;
+ /* The bit buffer. */
+ unsigned long bb;
+ /* The bits in the bit buffer. */
+ unsigned bk;
+ /* The sliding window in uncompressed data. */
+ grub_uint8_t slide[WSIZE];
+ /* Current position in the slide. */
+ unsigned wp;
+ /* The literal/length code table. */
+ struct huft *tl;
+ /* The distance code table. */
+ struct huft *td;
+ /* The checksum algorithm */
+ const gcry_md_spec_t *hdesc;
+ /* The wanted checksum */
+ grub_uint32_t orig_checksum;
+ /* The uncompressed length */
+ grub_size_t orig_len;
+ /* Context for checksum calculation */
+ grub_uint8_t *hcontext;
+ /* The lookup bits for the literal/length code table. */
+ int bl;
+ /* The lookup bits for the distance code table. */
+ int bd;
+ /* The original offset value. */
+ grub_off_t saved_offset;
+};
+typedef struct grub_gzio *grub_gzio_t;
+
+/* Declare the filesystem structure for grub_gzio_open. */
+static struct grub_fs grub_gzio_fs;
+
+/* Function prototypes */
+static void initialize_tables (grub_gzio_t);
+
+/* Eat variable-length header fields. */
+static int
+eat_field (grub_file_t file, int len)
+{
+ char ch = 1;
+ int not_retval = 1;
+
+ do
+ {
+ if (len >= 0)
+ {
+ if (! (len--))
+ break;
+ }
+ else
+ {
+ if (! ch)
+ break;
+ }
+ }
+ while ((not_retval = grub_file_read (file, &ch, 1)) == 1);
+
+ return ! not_retval;
+}
+
+
+/* Little-Endian defines for the 2-byte magic numbers for gzip files. */
+#define GZIP_MAGIC grub_le_to_cpu16 (0x8B1F)
+#define OLD_GZIP_MAGIC grub_le_to_cpu16 (0x9E1F)
+
+/* Compression methods (see algorithm.doc) */
+#define GRUB_GZ_STORED 0
+#define GRUB_GZ_COMPRESSED 1
+#define GRUB_GZ_PACKED 2
+#define GRUB_GZ_LZHED 3
+/* methods 4 to 7 reserved */
+#define GRUB_GZ_DEFLATED 8
+#define GRUB_GZ_MAX_METHODS 9
+
+/* gzip flag byte */
+#define GRUB_GZ_ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
+#define GRUB_GZ_CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
+#define GRUB_GZ_EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
+#define GRUB_GZ_ORIG_NAME 0x08 /* bit 3 set: original file name present */
+#define GRUB_GZ_COMMENT 0x10 /* bit 4 set: file comment present */
+#define GRUB_GZ_ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
+#define GRUB_GZ_RESERVED 0xC0 /* bit 6,7: reserved */
+
+#define GRUB_GZ_UNSUPPORTED_FLAGS (GRUB_GZ_CONTINUATION | GRUB_GZ_ENCRYPTED | GRUB_GZ_RESERVED)
+
+/* inflate block codes */
+#define INFLATE_STORED 0
+#define INFLATE_FIXED 1
+#define INFLATE_DYNAMIC 2
+
+typedef unsigned char uch;
+typedef unsigned short ush;
+typedef unsigned long ulg;
+
+static int
+test_gzip_header (grub_file_t file)
+{
+ struct {
+ grub_uint16_t magic;
+ grub_uint8_t method;
+ grub_uint8_t flags;
+ grub_uint32_t timestamp;
+ grub_uint8_t extra_flags;
+ grub_uint8_t os_type;
+ } hdr;
+ grub_uint16_t extra_len;
+ grub_uint32_t crc32;
+ grub_gzio_t gzio = file->data;
+
+ if (grub_file_tell (gzio->file) != 0)
+ grub_file_seek (gzio->file, 0);
+
+ /*
+ * This checks if the file is gzipped. If a problem occurs here
+ * (other than a real error with the disk) then we don't think it
+ * is a compressed file, and simply mark it as such.
+ */
+ if (grub_file_read (gzio->file, &hdr, 10) != 10
+ || ((hdr.magic != GZIP_MAGIC)
+ && (hdr.magic != OLD_GZIP_MAGIC)))
+ return 0;
+
+ /*
+ * This does consistency checking on the header data. If a
+ * problem occurs from here on, then we have corrupt or otherwise
+ * bad data, and the error should be reported to the user.
+ */
+ if (hdr.method != GRUB_GZ_DEFLATED
+ || (hdr.flags & GRUB_GZ_UNSUPPORTED_FLAGS)
+ || ((hdr.flags & GRUB_GZ_EXTRA_FIELD)
+ && (grub_file_read (gzio->file, &extra_len, 2) != 2
+ || eat_field (gzio->file,
+ grub_le_to_cpu16 (extra_len))))
+ || ((hdr.flags & GRUB_GZ_ORIG_NAME) && eat_field (gzio->file, -1))
+ || ((hdr.flags & GRUB_GZ_COMMENT) && eat_field (gzio->file, -1)))
+ return 0;
+
+ gzio->data_offset = grub_file_tell (gzio->file);
+
+ /* FIXME: don't do this on not easily seekable files. */
+ {
+ grub_file_seek (gzio->file, grub_file_size (gzio->file) - 8);
+ if (grub_file_read (gzio->file, &crc32, 4) != 4)
+ return 0;
+ gzio->orig_checksum = grub_le_to_cpu32 (crc32);
+ if (grub_file_read (gzio->file, &gzio->orig_len, 4) != 4)
+ return 0;
+ /* FIXME: this does not handle files whose original size is over 4GB.
+ But how can we know the real original size? */
+ file->size = grub_le_to_cpu32 (gzio->orig_len);
+ }
+
+ initialize_tables (gzio);
+
+ return 1;
+}
+
+
+/* Huffman code lookup table entry--this entry is four bytes for machines
+ that have 16-bit pointers (e.g. PC's in the small or medium model).
+ Valid extra bits are 0..13. e == 15 is EOB (end of block), e == 16
+ means that v is a literal, 16 < e < 32 means that v is a pointer to
+ the next table, which codes e - 16 bits, and lastly e == 99 indicates
+ an unused code. If a code with e == 99 is looked up, this implies an
+ error in the data. */
+struct huft
+{
+ uch e; /* number of extra bits or operation */
+ uch b; /* number of bits in this code or subcode */
+ union
+ {
+ ush n; /* literal, length base, or distance base */
+ struct huft *t; /* pointer to next level of table */
+ }
+ v;
+};
+
+
+/* The inflate algorithm uses a sliding 32K byte window on the uncompressed
+ stream to find repeated byte strings. This is implemented here as a
+ circular buffer. The index is updated simply by incrementing and then
+ and'ing with 0x7fff (32K-1). */
+/* It is left to other modules to supply the 32K area. It is assumed
+ to be usable as if it were declared "uch slide[32768];" or as just
+ "uch *slide;" and then malloc'ed in the latter case. The definition
+ must be in unzip.h, included above. */
+
+
+/* Tables for deflate from PKZIP's appnote.txt. */
+static unsigned bitorder[] =
+{ /* Order of the bit length code lengths */
+ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
+static ush cplens[] =
+{ /* Copy lengths for literal codes 257..285 */
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
+ 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
+ /* note: see note #13 above about the 258 in this list. */
+static ush cplext[] =
+{ /* Extra bits for literal codes 257..285 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
+ 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */
+static ush cpdist[] =
+{ /* Copy offsets for distance codes 0..29 */
+ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
+ 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
+ 8193, 12289, 16385, 24577};
+static ush cpdext[] =
+{ /* Extra bits for distance codes */
+ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
+ 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
+ 12, 12, 13, 13};
+
+
+/*
+ Huffman code decoding is performed using a multi-level table lookup.
+ The fastest way to decode is to simply build a lookup table whose
+ size is determined by the longest code. However, the time it takes
+ to build this table can also be a factor if the data being decoded
+ is not very long. The most common codes are necessarily the
+ shortest codes, so those codes dominate the decoding time, and hence
+ the speed. The idea is you can have a shorter table that decodes the
+ shorter, more probable codes, and then point to subsidiary tables for
+ the longer codes. The time it costs to decode the longer codes is
+ then traded against the time it takes to make longer tables.
+
+ This results of this trade are in the variables lbits and dbits
+ below. lbits is the number of bits the first level table for literal/
+ length codes can decode in one step, and dbits is the same thing for
+ the distance codes. Subsequent tables are also less than or equal to
+ those sizes. These values may be adjusted either when all of the
+ codes are shorter than that, in which case the longest code length in
+ bits is used, or when the shortest code is *longer* than the requested
+ table size, in which case the length of the shortest code in bits is
+ used.
+
+ There are two different values for the two tables, since they code a
+ different number of possibilities each. The literal/length table
+ codes 286 possible values, or in a flat code, a little over eight
+ bits. The distance table codes 30 possible values, or a little less
+ than five bits, flat. The optimum values for speed end up being
+ about one bit more than those, so lbits is 8+1 and dbits is 5+1.
+ The optimum values may differ though from machine to machine, and
+ possibly even between compilers. Your mileage may vary.
+ */
+
+
+static int lbits = 9; /* bits in base literal/length lookup table */
+static int dbits = 6; /* bits in base distance lookup table */
+
+
+/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
+#define BMAX 16 /* maximum bit length of any code (16 for explode) */
+#define N_MAX 288 /* maximum number of codes in any set */
+
+
+/* Macros for inflate() bit peeking and grabbing.
+ The usage is:
+
+ NEEDBITS(j)
+ x = b & mask_bits[j];
+ DUMPBITS(j)
+
+ where NEEDBITS makes sure that b has at least j bits in it, and
+ DUMPBITS removes the bits from b. The macros use the variable k
+ for the number of bits in b. Normally, b and k are register
+ variables for speed, and are initialized at the beginning of a
+ routine that uses these macros from a global bit buffer and count.
+
+ If we assume that EOB will be the longest code, then we will never
+ ask for bits with NEEDBITS that are beyond the end of the stream.
+ So, NEEDBITS should not read any more bytes than are needed to
+ meet the request. Then no bytes need to be "returned" to the buffer
+ at the end of the last block.
+
+ However, this assumption is not true for fixed blocks--the EOB code
+ is 7 bits, but the other literal/length codes can be 8 or 9 bits.
+ (The EOB code is shorter than other codes because fixed blocks are
+ generally short. So, while a block always has an EOB, many other
+ literal/length codes have a significantly lower probability of
+ showing up at all.) However, by making the first table have a
+ lookup of seven bits, the EOB code will be found in that first
+ lookup, and so will not require that too many bits be pulled from
+ the stream.
+ */
+
+static ush mask_bits[] =
+{
+ 0x0000,
+ 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
+ 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
+};
+
+#define NEEDBITS(n) do {while(k<(n)){b|=((ulg)get_byte(gzio))<<k;k+=8;}} while (0)
+#define DUMPBITS(n) do {b>>=(n);k-=(n);} while (0)
+
+static int
+get_byte (grub_gzio_t gzio)
+{
+ if (gzio->mem_input)
+ {
+ if (gzio->mem_input_off < gzio->mem_input_size)
+ return gzio->mem_input[gzio->mem_input_off++];
+ return 0;
+ }
+
+ if (gzio->file && (grub_file_tell (gzio->file)
+ == (grub_off_t) gzio->data_offset
+ || gzio->inbuf_d == INBUFSIZ))
+ {
+ gzio->inbuf_d = 0;
+ grub_file_read (gzio->file, gzio->inbuf, INBUFSIZ);
+ }
+
+ return gzio->inbuf[gzio->inbuf_d++];
+}
+
+static void
+gzio_seek (grub_gzio_t gzio, grub_off_t off)
+{
+ if (gzio->mem_input)
+ {
+ if (off > gzio->mem_input_size)
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("attempt to seek outside of the file"));
+ else
+ gzio->mem_input_off = off;
+ }
+ else
+ grub_file_seek (gzio->file, off);
+}
+
+/* more function prototypes */
+static int huft_build (unsigned *, unsigned, unsigned, ush *, ush *,
+ struct huft **, int *);
+static int huft_free (struct huft *);
+static int inflate_codes_in_window (grub_gzio_t);
+
+
+/* Given a list of code lengths and a maximum table size, make a set of
+ tables to decode that set of codes. Return zero on success, one if
+ the given code set is incomplete (the tables are still built in this
+ case), two if the input is invalid (all zero length codes or an
+ oversubscribed set of lengths), and three if not enough memory. */
+
+static int
+huft_build (unsigned *b, /* code lengths in bits (all assumed <= BMAX) */
+ unsigned n, /* number of codes (assumed <= N_MAX) */
+ unsigned s, /* number of simple-valued codes (0..s-1) */
+ ush * d, /* list of base values for non-simple codes */
+ ush * e, /* list of extra bits for non-simple codes */
+ struct huft **t, /* result: starting table */
+ int *m) /* maximum lookup bits, returns actual */
+{
+ unsigned a; /* counter for codes of length k */
+ unsigned c[BMAX + 1]; /* bit length count table */
+ unsigned f; /* i repeats in table every f entries */
+ int g; /* maximum code length */
+ int h; /* table level */
+ register unsigned i; /* counter, current code */
+ register unsigned j; /* counter */
+ register int k; /* number of bits in current code */
+ int l; /* bits per table (returned in m) */
+ register unsigned *p; /* pointer into c[], b[], or v[] */
+ register struct huft *q; /* points to current table */
+ struct huft r; /* table entry for structure assignment */
+ struct huft *u[BMAX]; /* table stack */
+ unsigned v[N_MAX]; /* values in order of bit length */
+ register int w; /* bits before this table == (l * h) */
+ unsigned x[BMAX + 1]; /* bit offsets, then code stack */
+ unsigned *xp; /* pointer into x */
+ int y; /* number of dummy codes added */
+ unsigned z; /* number of entries in current table */
+
+ /* Generate counts for each bit length */
+ grub_memset ((char *) c, 0, sizeof (c));
+ p = b;
+ i = n;
+ do
+ {
+ c[*p]++; /* assume all entries <= BMAX */
+ p++; /* Can't combine with above line (Solaris bug) */
+ }
+ while (--i);
+ if (c[0] == n) /* null input--all zero length codes */
+ {
+ *t = (struct huft *) NULL;
+ *m = 0;
+ return 0;
+ }
+
+ /* Find minimum and maximum length, bound *m by those */
+ l = *m;
+ for (j = 1; j <= BMAX; j++)
+ if (c[j])
+ break;
+ k = j; /* minimum code length */
+ if ((unsigned) l < j)
+ l = j;
+ for (i = BMAX; i; i--)
+ if (c[i])
+ break;
+ g = i; /* maximum code length */
+ if ((unsigned) l > i)
+ l = i;
+ *m = l;
+
+ /* Adjust last length count to fill out codes, if needed */
+ for (y = 1 << j; j < i; j++, y <<= 1)
+ if ((y -= c[j]) < 0)
+ return 2; /* bad input: more codes than bits */
+ if ((y -= c[i]) < 0)
+ return 2;
+ c[i] += y;
+
+ /* Generate starting offsets into the value table for each length */
+ x[1] = j = 0;
+ p = c + 1;
+ xp = x + 2;
+ while (--i)
+ { /* note that i == g from above */
+ *xp++ = (j += *p++);
+ }
+
+ /* Make a table of values in order of bit lengths */
+ grub_memset (v, N_MAX, ARRAY_SIZE (v));
+ p = b;
+ i = 0;
+ do
+ {
+ if ((j = *p++) != 0)
+ v[x[j]++] = i;
+ }
+ while (++i < n);
+
+ /* Generate the Huffman codes and for each, make the table entries */
+ x[0] = i = 0; /* first Huffman code is zero */
+ p = v; /* grab values in bit order */
+ h = -1; /* no tables yet--level -1 */
+ w = -l; /* bits decoded == (l * h) */
+ u[0] = (struct huft *) NULL; /* just to keep compilers happy */
+ q = (struct huft *) NULL; /* ditto */
+ z = 0; /* ditto */
+
+ /* go through the bit lengths (k already is bits in shortest code) */
+ for (; k <= g; k++)
+ {
+ a = c[k];
+ while (a--)
+ {
+ /* here i is the Huffman code of length k bits for value *p */
+ /* make tables up to required level */
+ while (k > w + l)
+ {
+ h++;
+ w += l; /* previous table always l bits */
+
+ /* compute minimum size table less than or equal to l bits */
+ z = (z = (unsigned) (g - w)) > (unsigned) l ? (unsigned) l : z; /* upper limit on table size */
+ if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
+ { /* too few codes for k-w bit table */
+ f -= a + 1; /* deduct codes from patterns left */
+ xp = c + k;
+ while (++j < z) /* try smaller tables up to z bits */
+ {
+ if ((f <<= 1) <= *++xp)
+ break; /* enough codes to use up j bits */
+ f -= *xp; /* else deduct codes from patterns */
+ }
+ }
+ z = 1 << j; /* table entries for j-bit table */
+
+ /* allocate and link in new table */
+ q = (struct huft *) grub_calloc (z + 1, sizeof (struct huft));
+ if (! q)
+ {
+ if (h)
+ huft_free (u[0]);
+ return 3;
+ }
+
+ *t = q + 1; /* link to list for huft_free() */
+ *(t = &(q->v.t)) = (struct huft *) NULL;
+ u[h] = ++q; /* table starts after link */
+
+ /* connect to last table, if there is one */
+ if (h)
+ {
+ x[h] = i; /* save pattern for backing up */
+ r.b = (uch) l; /* bits to dump before this table */
+ r.e = (uch) (16 + j); /* bits in this table */
+ r.v.t = q; /* pointer to this table */
+ j = i >> (w - l); /* (get around Turbo C bug) */
+ u[h - 1][j] = r; /* connect to last table */
+ }
+ }
+
+ /* set up table entry in r */
+ r.b = (uch) (k - w);
+ if (p >= v + n)
+ r.e = 99; /* out of values--invalid code */
+ else if (*p < s)
+ {
+ r.e = (uch) (*p < 256 ? 16 : 15); /* 256 is end-of-block code */
+ r.v.n = (ush) (*p); /* simple code is just the value */
+ p++; /* one compiler does not like *p++ */
+ }
+ else if (*p < N_MAX)
+ {
+ r.e = (uch) e[*p - s]; /* non-simple--look up in lists */
+ r.v.n = d[*p++ - s];
+ }
+ else
+ {
+ /* Detected an uninitialised value, abort. */
+ if (h)
+ huft_free (u[0]);
+ return 2;
+ }
+
+ /* fill code-like entries with r */
+ f = 1 << (k - w);
+ for (j = i >> w; j < z; j += f)
+ q[j] = r;
+
+ /* backwards increment the k-bit code i */
+ for (j = 1 << (k - 1); i & j; j >>= 1)
+ i ^= j;
+ i ^= j;
+
+ /* backup over finished tables */
+ while ((i & ((1 << w) - 1)) != x[h])
+ {
+ h--; /* don't need to update q */
+ w -= l;
+ }
+ }
+ }
+
+ /* Return true (1) if we were given an incomplete table */
+ return y != 0 && g != 1;
+}
+
+
+/* Free the malloc'ed tables built by huft_build(), which makes a linked
+ list of the tables it made, with the links in a dummy first entry of
+ each table. */
+static int
+huft_free (struct huft *t)
+{
+ register struct huft *p, *q;
+
+
+ /* Go through linked list, freeing from the malloced (t[-1]) address. */
+ p = t;
+ while (p != (struct huft *) NULL)
+ {
+ q = (--p)->v.t;
+ grub_free ((char *) p);
+ p = q;
+ }
+ return 0;
+}
+
+
+/*
+ * inflate (decompress) the codes in a deflated (compressed) block.
+ * Return an error code or zero if it all goes ok.
+ */
+
+static int
+inflate_codes_in_window (grub_gzio_t gzio)
+{
+ register unsigned e; /* table entry flag/number of extra bits */
+ unsigned n, d; /* length and index for copy */
+ unsigned w; /* current window position */
+ struct huft *t; /* pointer to table entry */
+ unsigned ml, md; /* masks for bl and bd bits */
+ register ulg b; /* bit buffer */
+ register unsigned k; /* number of bits in bit buffer */
+
+ /* make local copies of globals */
+ d = gzio->inflate_d;
+ n = gzio->inflate_n;
+ b = gzio->bb; /* initialize bit buffer */
+ k = gzio->bk;
+ w = gzio->wp; /* initialize window position */
+
+ /* inflate the coded data */
+ ml = mask_bits[gzio->bl]; /* precompute masks for speed */
+ md = mask_bits[gzio->bd];
+ for (;;) /* do until end of block */
+ {
+ if (! gzio->code_state)
+ {
+
+ if (gzio->tl == NULL)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "NULL gzio->tl");
+ return 1;
+ }
+
+ NEEDBITS ((unsigned) gzio->bl);
+ if ((e = (t = gzio->tl + ((unsigned) b & ml))->e) > 16)
+ do
+ {
+ if (e == 99)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "an unused code found");
+ return 1;
+ }
+ DUMPBITS (t->b);
+ e -= 16;
+ NEEDBITS (e);
+ }
+ while ((e = (t = t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16);
+ DUMPBITS (t->b);
+
+ if (e == 16) /* then it's a literal */
+ {
+ gzio->slide[w++] = (uch) t->v.n;
+ if (w == WSIZE)
+ break;
+ }
+ else
+ /* it's an EOB or a length */
+ {
+ /* exit if end of block */
+ if (e == 15)
+ {
+ gzio->block_len = 0;
+ break;
+ }
+
+ /* get length of block to copy */
+ NEEDBITS (e);
+ n = t->v.n + ((unsigned) b & mask_bits[e]);
+ DUMPBITS (e);
+
+ if (gzio->td == NULL)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "NULL gzio->td");
+ return 1;
+ }
+
+ /* decode distance of block to copy */
+ NEEDBITS ((unsigned) gzio->bd);
+ if ((e = (t = gzio->td + ((unsigned) b & md))->e) > 16)
+ do
+ {
+ if (e == 99)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "an unused code found");
+ return 1;
+ }
+ DUMPBITS (t->b);
+ e -= 16;
+ NEEDBITS (e);
+ }
+ while ((e = (t = t->v.t + ((unsigned) b & mask_bits[e]))->e)
+ > 16);
+ DUMPBITS (t->b);
+ NEEDBITS (e);
+ d = w - t->v.n - ((unsigned) b & mask_bits[e]);
+ DUMPBITS (e);
+ gzio->code_state++;
+ }
+ }
+
+ if (gzio->code_state)
+ {
+ /* do the copy */
+ do
+ {
+ n -= (e = (e = WSIZE - ((d &= WSIZE - 1) > w ? d : w)) > n ? n
+ : e);
+
+ if (w - d >= e)
+ {
+ grub_memmove (gzio->slide + w, gzio->slide + d, e);
+ w += e;
+ d += e;
+ }
+ else
+ /* purposefully use the overlap for extra copies here!! */
+ {
+ while (e--)
+ gzio->slide[w++] = gzio->slide[d++];
+ }
+
+ if (w == WSIZE)
+ break;
+ }
+ while (n);
+
+ if (! n)
+ gzio->code_state--;
+
+ /* did we break from the loop too soon? */
+ if (w == WSIZE)
+ break;
+ }
+ }
+
+ /* restore the globals from the locals */
+ gzio->inflate_d = d;
+ gzio->inflate_n = n;
+ gzio->wp = w; /* restore global window pointer */
+ gzio->bb = b; /* restore global bit buffer */
+ gzio->bk = k;
+
+ return ! gzio->block_len;
+}
+
+
+/* get header for an inflated type 0 (stored) block. */
+
+static void
+init_stored_block (grub_gzio_t gzio)
+{
+ register ulg b; /* bit buffer */
+ register unsigned k; /* number of bits in bit buffer */
+
+ /* make local copies of globals */
+ b = gzio->bb; /* initialize bit buffer */
+ k = gzio->bk;
+
+ /* go to byte boundary */
+ DUMPBITS (k & 7);
+
+ /* get the length and its complement */
+ NEEDBITS (16);
+ gzio->block_len = ((unsigned) b & 0xffff);
+ DUMPBITS (16);
+ NEEDBITS (16);
+ if (gzio->block_len != (int) ((~b) & 0xffff))
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "the length of a stored block does not match");
+ DUMPBITS (16);
+
+ /* restore global variables */
+ gzio->bb = b;
+ gzio->bk = k;
+}
+
+
+/* get header for an inflated type 1 (fixed Huffman codes) block. We should
+ either replace this with a custom decoder, or at least precompute the
+ Huffman tables. */
+
+static void
+init_fixed_block (grub_gzio_t gzio)
+{
+ int i; /* temporary variable */
+ unsigned l[288]; /* length list for huft_build */
+
+ /* set up literal table */
+ for (i = 0; i < 144; i++)
+ l[i] = 8;
+ for (; i < 256; i++)
+ l[i] = 9;
+ for (; i < 280; i++)
+ l[i] = 7;
+ for (; i < 288; i++) /* make a complete, but wrong code set */
+ l[i] = 8;
+ gzio->bl = 7;
+ if (huft_build (l, 288, 257, cplens, cplext, &gzio->tl, &gzio->bl) != 0)
+ {
+ if (grub_errno == GRUB_ERR_NONE)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "failed in building a Huffman code table");
+ return;
+ }
+
+ /* set up distance table */
+ for (i = 0; i < 30; i++) /* make an incomplete code set */
+ l[i] = 5;
+ gzio->bd = 5;
+ if (huft_build (l, 30, 0, cpdist, cpdext, &gzio->td, &gzio->bd) > 1)
+ {
+ if (grub_errno == GRUB_ERR_NONE)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "failed in building a Huffman code table");
+ huft_free (gzio->tl);
+ gzio->tl = 0;
+ return;
+ }
+
+ /* indicate we're now working on a block */
+ gzio->code_state = 0;
+ gzio->block_len++;
+}
+
+
+/* get header for an inflated type 2 (dynamic Huffman codes) block. */
+
+static void
+init_dynamic_block (grub_gzio_t gzio)
+{
+ int i; /* temporary variables */
+ unsigned j;
+ unsigned l; /* last length */
+ unsigned m; /* mask for bit lengths table */
+ unsigned n; /* number of lengths to get */
+ unsigned nb; /* number of bit length codes */
+ unsigned nl; /* number of literal/length codes */
+ unsigned nd; /* number of distance codes */
+ unsigned ll[286 + 30]; /* literal/length and distance code lengths */
+ register ulg b; /* bit buffer */
+ register unsigned k; /* number of bits in bit buffer */
+
+ /* make local bit buffer */
+ b = gzio->bb;
+ k = gzio->bk;
+
+ /* read in table lengths */
+ NEEDBITS (5);
+ nl = 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */
+ DUMPBITS (5);
+ NEEDBITS (5);
+ nd = 1 + ((unsigned) b & 0x1f); /* number of distance codes */
+ DUMPBITS (5);
+ NEEDBITS (4);
+ nb = 4 + ((unsigned) b & 0xf); /* number of bit length codes */
+ DUMPBITS (4);
+ if (nl > 286 || nd > 30)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "too much data");
+ return;
+ }
+
+ /* read in bit-length-code lengths */
+ for (j = 0; j < nb; j++)
+ {
+ NEEDBITS (3);
+ ll[bitorder[j]] = (unsigned) b & 7;
+ DUMPBITS (3);
+ }
+ for (; j < 19; j++)
+ ll[bitorder[j]] = 0;
+
+ /* build decoding table for trees--single level, 7 bit lookup */
+ gzio->bl = 7;
+ if (huft_build (ll, 19, 19, NULL, NULL, &gzio->tl, &gzio->bl) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "failed in building a Huffman code table");
+ return;
+ }
+
+ /* read in literal and distance code lengths */
+ n = nl + nd;
+ m = mask_bits[gzio->bl];
+ i = l = 0;
+
+ if (gzio->tl == NULL)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "NULL gzio->tl");
+ return;
+ }
+
+ while ((unsigned) i < n)
+ {
+ NEEDBITS ((unsigned) gzio->bl);
+ j = (gzio->td = gzio->tl + ((unsigned) b & m))->b;
+ DUMPBITS (j);
+ j = gzio->td->v.n;
+ if (j < 16) /* length of code in bits (0..15) */
+ ll[i++] = l = j; /* save last length in l */
+ else if (j == 16) /* repeat last length 3 to 6 times */
+ {
+ NEEDBITS (2);
+ j = 3 + ((unsigned) b & 3);
+ DUMPBITS (2);
+ if ((unsigned) i + j > n)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "too many codes found");
+ goto fail;
+ }
+ while (j--)
+ ll[i++] = l;
+ }
+ else if (j == 17) /* 3 to 10 zero length codes */
+ {
+ NEEDBITS (3);
+ j = 3 + ((unsigned) b & 7);
+ DUMPBITS (3);
+ if ((unsigned) i + j > n)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "too many codes found");
+ goto fail;
+ }
+ while (j--)
+ ll[i++] = 0;
+ l = 0;
+ }
+ else
+ /* j == 18: 11 to 138 zero length codes */
+ {
+ NEEDBITS (7);
+ j = 11 + ((unsigned) b & 0x7f);
+ DUMPBITS (7);
+ if ((unsigned) i + j > n)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "too many codes found");
+ goto fail;
+ }
+ while (j--)
+ ll[i++] = 0;
+ l = 0;
+ }
+ }
+
+ /* free decoding table for trees */
+ huft_free (gzio->tl);
+ gzio->td = 0;
+ gzio->tl = 0;
+
+ /* restore the global bit buffer */
+ gzio->bb = b;
+ gzio->bk = k;
+
+ /* build the decoding tables for literal/length and distance codes */
+ gzio->bl = lbits;
+ if (huft_build (ll, nl, 257, cplens, cplext, &gzio->tl, &gzio->bl) != 0)
+ {
+ gzio->tl = 0;
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "failed in building a Huffman code table");
+ return;
+ }
+ gzio->bd = dbits;
+ if (huft_build (ll + nl, nd, 0, cpdist, cpdext, &gzio->td, &gzio->bd) != 0)
+ {
+ huft_free (gzio->tl);
+ gzio->tl = 0;
+ gzio->td = 0;
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "failed in building a Huffman code table");
+ return;
+ }
+
+ /* indicate we're now working on a block */
+ gzio->code_state = 0;
+ gzio->block_len++;
+ return;
+
+ fail:
+ huft_free (gzio->tl);
+ gzio->td = NULL;
+ gzio->tl = NULL;
+}
+
+
+static void
+get_new_block (grub_gzio_t gzio)
+{
+ register ulg b; /* bit buffer */
+ register unsigned k; /* number of bits in bit buffer */
+
+ /* make local bit buffer */
+ b = gzio->bb;
+ k = gzio->bk;
+
+ /* read in last block bit */
+ NEEDBITS (1);
+ gzio->last_block = (int) b & 1;
+ DUMPBITS (1);
+
+ /* read in block type */
+ NEEDBITS (2);
+ gzio->block_type = (unsigned) b & 3;
+ DUMPBITS (2);
+
+ /* restore the global bit buffer */
+ gzio->bb = b;
+ gzio->bk = k;
+
+ switch (gzio->block_type)
+ {
+ case INFLATE_STORED:
+ init_stored_block (gzio);
+ break;
+ case INFLATE_FIXED:
+ init_fixed_block (gzio);
+ break;
+ case INFLATE_DYNAMIC:
+ init_dynamic_block (gzio);
+ break;
+ default:
+ break;
+ }
+}
+
+
+static void
+inflate_window (grub_gzio_t gzio)
+{
+ /* initialize window */
+ gzio->wp = 0;
+
+ /*
+ * Main decompression loop.
+ */
+
+ while (gzio->wp < WSIZE && grub_errno == GRUB_ERR_NONE)
+ {
+ if (! gzio->block_len)
+ {
+ if (gzio->last_block)
+ break;
+
+ get_new_block (gzio);
+ }
+
+ if (gzio->block_type > INFLATE_DYNAMIC)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "unknown block type %d", gzio->block_type);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ return;
+
+ /*
+ * Expand stored block here.
+ */
+ if (gzio->block_type == INFLATE_STORED)
+ {
+ int w = gzio->wp;
+
+ /*
+ * This is basically a glorified pass-through
+ */
+
+ while (gzio->block_len && w < WSIZE && grub_errno == GRUB_ERR_NONE)
+ {
+ gzio->slide[w++] = get_byte (gzio);
+ gzio->block_len--;
+ }
+
+ gzio->wp = w;
+
+ continue;
+ }
+
+ /*
+ * Expand other kind of block.
+ */
+
+ if (inflate_codes_in_window (gzio))
+ {
+ huft_free (gzio->tl);
+ huft_free (gzio->td);
+ gzio->tl = 0;
+ gzio->td = 0;
+ }
+ }
+
+ gzio->saved_offset += gzio->wp;
+
+ if (gzio->hcontext)
+ {
+ gzio->hdesc->write (gzio->hcontext, gzio->slide, gzio->wp);
+
+ if (gzio->saved_offset == gzio->orig_len)
+ {
+ grub_uint32_t csum;
+
+ gzio->hdesc->final (gzio->hcontext);
+ csum = grub_get_unaligned32 (gzio->hdesc->read (gzio->hcontext));
+ csum = grub_be_to_cpu32 (csum);
+ if (csum != gzio->orig_checksum)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "checksum mismatch %08x/%08x",
+ gzio->orig_checksum, csum);
+ }
+ }
+}
+
+
+static void
+initialize_tables (grub_gzio_t gzio)
+{
+ gzio->saved_offset = 0;
+ gzio_seek (gzio, gzio->data_offset);
+
+ /* Initialize the bit buffer. */
+ gzio->bk = 0;
+ gzio->bb = 0;
+
+ /* Reset partial decompression code. */
+ gzio->last_block = 0;
+ gzio->block_len = 0;
+
+ /* Reset memory allocation stuff. */
+ huft_free (gzio->tl);
+ huft_free (gzio->td);
+ gzio->tl = NULL;
+ gzio->td = NULL;
+
+ if (gzio->hcontext)
+ gzio->hdesc->init(gzio->hcontext);
+}
+
+
+/* Open a new decompressing object on the top of IO. If TRANSPARENT is true,
+ even if IO does not contain data compressed by gzip, return a valid file
+ object. Note that this function won't close IO, even if an error occurs. */
+static grub_file_t
+grub_gzio_open (grub_file_t io, enum grub_file_type type)
+{
+ grub_file_t file;
+ grub_gzio_t gzio = 0;
+
+ if (type & GRUB_FILE_TYPE_NO_DECOMPRESS)
+ return io;
+
+ file = (grub_file_t) grub_zalloc (sizeof (*file));
+ if (! file)
+ return 0;
+
+ gzio = grub_zalloc (sizeof (*gzio));
+ if (! gzio)
+ {
+ grub_free (file);
+ return 0;
+ }
+
+ gzio->file = io;
+
+ gzio->hdesc = GRUB_MD_CRC32;
+ gzio->hcontext = grub_malloc(gzio->hdesc->contextsize);
+
+ file->device = io->device;
+ file->data = gzio;
+ file->fs = &grub_gzio_fs;
+ file->not_easily_seekable = 1;
+
+ if (! test_gzip_header (file))
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_free (gzio->hcontext);
+ grub_free (gzio);
+ grub_free (file);
+ grub_file_seek (io, 0);
+
+ return io;
+ }
+
+ 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)
+{
+ grub_uint8_t cmf, flg;
+
+ cmf = get_byte (gzio);
+ flg = get_byte (gzio);
+
+ /* Check that compression method is DEFLATE. */
+ if ((cmf & 0xf) != GRUB_GZ_DEFLATED)
+ {
+ /* TRANSLATORS: It's about given file having some strange format, not
+ complete lack of gzip support. */
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, N_("unsupported gzip format"));
+ return 0;
+ }
+
+ /* 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;
+ }
+
+ /* Dictionary isn't supported. */
+ if (flg & 0x20)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, N_("unsupported gzip format"));
+ return 0;
+ }
+
+ gzio->data_offset = 2;
+ initialize_tables (gzio);
+
+ return 1;
+}
+
+static grub_ssize_t
+grub_gzio_read_real (grub_gzio_t gzio, grub_off_t offset,
+ char *buf, grub_size_t len)
+{
+ grub_ssize_t ret = 0;
+
+ /* Do we reset decompression to the beginning of the file? */
+ if (gzio->saved_offset > offset + WSIZE)
+ initialize_tables (gzio);
+
+ /*
+ * This loop operates upon uncompressed data only. The only
+ * special thing it does is to make sure the decompression
+ * window is within the range of data it needs.
+ */
+
+ while (len > 0 && grub_errno == GRUB_ERR_NONE)
+ {
+ register grub_size_t size;
+ register char *srcaddr;
+
+ while (offset >= gzio->saved_offset)
+ {
+ inflate_window (gzio);
+ if (gzio->wp == 0)
+ goto out;
+ }
+
+ if (gzio->wp == 0)
+ goto out;
+
+ srcaddr = (char *) ((offset & (WSIZE - 1)) + gzio->slide);
+ size = gzio->saved_offset - offset;
+ if (size > len)
+ size = len;
+
+ grub_memmove (buf, srcaddr, size);
+
+ buf += size;
+ len -= size;
+ ret += size;
+ offset += size;
+ }
+
+ out:
+ if (grub_errno != GRUB_ERR_NONE)
+ ret = -1;
+
+ return ret;
+}
+
+static grub_ssize_t
+grub_gzio_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ grub_ssize_t ret;
+ ret = grub_gzio_read_real (file->data, file->offset, buf, len);
+
+ if (!grub_errno && ret != (grub_ssize_t) len)
+ {
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "premature end of compressed");
+ ret = -1;
+ }
+ return ret;
+}
+
+/* Release everything, including the underlying file object. */
+static grub_err_t
+grub_gzio_close (grub_file_t file)
+{
+ grub_gzio_t gzio = file->data;
+
+ grub_file_close (gzio->file);
+ huft_free (gzio->tl);
+ huft_free (gzio->td);
+ grub_free (gzio->hcontext);
+ grub_free (gzio);
+
+ /* No need to close the same device twice. */
+ file->device = 0;
+ file->name = 0;
+
+ return grub_errno;
+}
+
+grub_ssize_t
+grub_zlib_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
+ char *outbuf, grub_size_t outsize)
+{
+ grub_gzio_t gzio = 0;
+ grub_ssize_t ret;
+
+ gzio = grub_zalloc (sizeof (*gzio));
+ if (! gzio)
+ return -1;
+ gzio->mem_input = (grub_uint8_t *) inbuf;
+ gzio->mem_input_size = insize;
+ gzio->mem_input_off = 0;
+
+ if (!test_zlib_header (gzio))
+ {
+ grub_free (gzio);
+ return -1;
+ }
+
+ ret = grub_gzio_read_real (gzio, off, outbuf, outsize);
+ grub_free (gzio);
+
+ /* FIXME: Check Adler. */
+ return ret;
+}
+
+grub_ssize_t
+grub_deflate_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
+ char *outbuf, grub_size_t outsize)
+{
+ grub_gzio_t gzio = 0;
+ grub_ssize_t ret;
+
+ gzio = grub_zalloc (sizeof (*gzio));
+ if (! gzio)
+ return -1;
+ gzio->mem_input = (grub_uint8_t *) inbuf;
+ gzio->mem_input_size = insize;
+ gzio->mem_input_off = 0;
+
+ initialize_tables (gzio);
+
+ ret = grub_gzio_read_real (gzio, off, outbuf, outsize);
+ grub_free (gzio);
+
+ return ret;
+}
+
+
+
+static struct grub_fs grub_gzio_fs =
+ {
+ .name = "gzio",
+ .fs_dir = 0,
+ .fs_open = 0,
+ .fs_read = grub_gzio_read,
+ .fs_close = grub_gzio_close,
+ .fs_label = 0,
+ .next = 0
+ };
+
+GRUB_MOD_INIT(gzio)
+{
+ grub_file_filter_register (GRUB_FILE_FILTER_GZIO, grub_gzio_open);
+}
+
+GRUB_MOD_FINI(gzio)
+{
+ grub_file_filter_unregister (GRUB_FILE_FILTER_GZIO);
+}
diff --git a/grub-core/io/lzopio.c b/grub-core/io/lzopio.c
new file mode 100644
index 0000000..a7d4425
--- /dev/null
+++ b/grub-core/io/lzopio.c
@@ -0,0 +1,546 @@
+/* lzopio.c - decompression support for lzop */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/err.h>
+#include <grub/mm.h>
+#include <grub/file.h>
+#include <grub/fs.h>
+#include <grub/dl.h>
+#include <grub/crypto.h>
+#include <minilzo.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define LZOP_MAGIC "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a"
+#define LZOP_MAGIC_SIZE 9
+#define LZOP_CHECK_SIZE 4
+#define LZOP_NEW_LIB 0x0940
+
+/* Header flags - copied from conf.h of LZOP source code. */
+#define F_ADLER32_D 0x00000001L
+#define F_ADLER32_C 0x00000002L
+#define F_STDIN 0x00000004L
+#define F_STDOUT 0x00000008L
+#define F_NAME_DEFAULT 0x00000010L
+#define F_DOSISH 0x00000020L
+#define F_H_EXTRA_FIELD 0x00000040L
+#define F_H_GMTDIFF 0x00000080L
+#define F_CRC32_D 0x00000100L
+#define F_CRC32_C 0x00000200L
+#define F_MULTIPART 0x00000400L
+#define F_H_FILTER 0x00000800L
+#define F_H_CRC32 0x00001000L
+#define F_H_PATH 0x00002000L
+#define F_MASK 0x00003FFFL
+
+struct block_header
+{
+ grub_uint32_t usize;
+ grub_uint32_t csize;
+ grub_uint32_t ucheck;
+ grub_uint32_t ccheck;
+ unsigned char *cdata;
+ unsigned char *udata;
+};
+
+struct grub_lzopio
+{
+ grub_file_t file;
+ int has_ccheck;
+ int has_ucheck;
+ const gcry_md_spec_t *ucheck_fun;
+ const gcry_md_spec_t *ccheck_fun;
+ grub_off_t saved_off; /* Rounded down to block boundary. */
+ grub_off_t start_block_off;
+ struct block_header block;
+};
+
+typedef struct grub_lzopio *grub_lzopio_t;
+static struct grub_fs grub_lzopio_fs;
+
+/* Some helper functions. On errors memory allocated by those function is free
+ * either on close() so no risk of leaks. This makes functions simpler. */
+
+/* Read block header from file, after successful exit file points to
+ * beginning of block data. */
+static int
+read_block_header (struct grub_lzopio *lzopio)
+{
+ lzopio->saved_off += lzopio->block.usize;
+
+ /* Free cached block data if any. */
+ grub_free (lzopio->block.udata);
+ grub_free (lzopio->block.cdata);
+ lzopio->block.udata = NULL;
+ lzopio->block.cdata = NULL;
+
+ if (grub_file_read (lzopio->file, &lzopio->block.usize,
+ sizeof (lzopio->block.usize)) !=
+ sizeof (lzopio->block.usize))
+ return -1;
+
+ lzopio->block.usize = grub_be_to_cpu32 (lzopio->block.usize);
+
+ /* Last block has uncompressed data size == 0 and no other fields. */
+ if (lzopio->block.usize == 0)
+ {
+ if (grub_file_tell (lzopio->file) == grub_file_size (lzopio->file))
+ return 0;
+ else
+ return -1;
+ }
+
+ /* Read compressed data block size. */
+ if (grub_file_read (lzopio->file, &lzopio->block.csize,
+ sizeof (lzopio->block.csize)) !=
+ sizeof (lzopio->block.csize))
+ return -1;
+
+ lzopio->block.csize = grub_be_to_cpu32 (lzopio->block.csize);
+
+ /* Corrupted. */
+ if (lzopio->block.csize > lzopio->block.usize)
+ return -1;
+
+ /* Read checksum of uncompressed data. */
+ if (lzopio->has_ucheck)
+ {
+ if (grub_file_read (lzopio->file, &lzopio->block.ucheck,
+ sizeof (lzopio->block.ucheck)) !=
+ sizeof (lzopio->block.ucheck))
+ return -1;
+ }
+
+ /* Read checksum of compressed data. */
+ if (lzopio->has_ccheck)
+ {
+ /* Incompressible data block. */
+ if (lzopio->block.csize == lzopio->block.usize)
+ {
+ lzopio->block.ccheck = lzopio->block.ucheck;
+ }
+ else
+ {
+ if (grub_file_read (lzopio->file, &lzopio->block.ccheck,
+ sizeof (lzopio->block.ccheck)) !=
+ sizeof (lzopio->block.ccheck))
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/* Read block data into memory. File must be set to beginning of block data.
+ * Can't be called on last block. */
+static int
+read_block_data (struct grub_lzopio *lzopio)
+{
+ lzopio->block.cdata = grub_malloc (lzopio->block.csize);
+ if (!lzopio->block.cdata)
+ return -1;
+
+ if (grub_file_read (lzopio->file, lzopio->block.cdata, lzopio->block.csize)
+ != (grub_ssize_t) lzopio->block.csize)
+ return -1;
+
+ if (lzopio->ccheck_fun)
+ {
+ grub_uint8_t computed_hash[GRUB_CRYPTO_MAX_MDLEN];
+
+ if (lzopio->ccheck_fun->mdlen > GRUB_CRYPTO_MAX_MDLEN)
+ return -1;
+
+ grub_crypto_hash (lzopio->ccheck_fun, computed_hash,
+ lzopio->block.cdata,
+ lzopio->block.csize);
+
+ if (grub_memcmp
+ (computed_hash, &lzopio->block.ccheck,
+ sizeof (lzopio->block.ccheck)) != 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+/* Read block data, uncompressed and also store it in memory. */
+/* XXX Investigate possibility of in-place decompression to reduce memory
+ * footprint. Or try to uncompress directly to buf if possible. */
+static int
+uncompress_block (struct grub_lzopio *lzopio)
+{
+ lzo_uint usize = lzopio->block.usize;
+
+ if (read_block_data (lzopio) < 0)
+ return -1;
+
+ /* Incompressible data. */
+ if (lzopio->block.csize == lzopio->block.usize)
+ {
+ lzopio->block.udata = lzopio->block.cdata;
+ lzopio->block.cdata = NULL;
+ }
+ else
+ {
+ lzopio->block.udata = grub_malloc (lzopio->block.usize);
+ if (!lzopio->block.udata)
+ return -1;
+
+ if (lzo1x_decompress_safe (lzopio->block.cdata, lzopio->block.csize,
+ lzopio->block.udata, &usize, NULL)
+ != LZO_E_OK)
+ return -1;
+
+ if (lzopio->ucheck_fun)
+ {
+ grub_uint8_t computed_hash[GRUB_CRYPTO_MAX_MDLEN];
+
+ if (lzopio->ucheck_fun->mdlen > GRUB_CRYPTO_MAX_MDLEN)
+ return -1;
+
+ grub_crypto_hash (lzopio->ucheck_fun, computed_hash,
+ lzopio->block.udata,
+ lzopio->block.usize);
+
+ if (grub_memcmp
+ (computed_hash, &lzopio->block.ucheck,
+ sizeof (lzopio->block.ucheck)) != 0)
+ return -1;
+ }
+
+ /* Compressed data can be free now. */
+ grub_free (lzopio->block.cdata);
+ lzopio->block.cdata = NULL;
+ }
+
+ return 0;
+}
+
+/* Jump to next block and read its header. */
+static int
+jump_block (struct grub_lzopio *lzopio)
+{
+ /* only jump if block was not decompressed (and read from disk) */
+ if (!lzopio->block.udata)
+ {
+ grub_off_t off = grub_file_tell (lzopio->file) + lzopio->block.csize;
+
+ if (grub_file_seek (lzopio->file, off) == ((grub_off_t) - 1))
+ return -1;
+ }
+
+ return read_block_header (lzopio);
+}
+
+static int
+calculate_uncompressed_size (grub_file_t file)
+{
+ grub_lzopio_t lzopio = file->data;
+ grub_off_t usize_total = 0;
+
+ if (read_block_header (lzopio) < 0)
+ return -1;
+
+ /* FIXME: Don't do this for not easily seekable files. */
+ while (lzopio->block.usize != 0)
+ {
+ usize_total += lzopio->block.usize;
+
+ if (jump_block (lzopio) < 0)
+ return -1;
+ }
+
+ file->size = usize_total;
+
+ return 0;
+}
+
+struct lzop_header
+{
+ grub_uint8_t magic[LZOP_MAGIC_SIZE];
+ grub_uint16_t lzop_version;
+ grub_uint16_t lib_version;
+ grub_uint16_t lib_version_ext;
+ grub_uint8_t method;
+ grub_uint8_t level;
+ grub_uint32_t flags;
+ /* grub_uint32_t filter; */ /* No filters support. Rarely used anyway. */
+ grub_uint32_t mode;
+ grub_uint32_t mtime_lo;
+ grub_uint32_t mtime_hi;
+ grub_uint8_t name_len;
+} GRUB_PACKED;
+
+static int
+test_header (grub_file_t file)
+{
+ grub_lzopio_t lzopio = file->data;
+ struct lzop_header header;
+ grub_uint32_t flags, checksum;
+ const gcry_md_spec_t *hcheck;
+ grub_uint8_t *context = NULL;
+ grub_uint8_t *name = NULL;
+
+ if (grub_file_read (lzopio->file, &header, sizeof (header)) != sizeof (header))
+ return 0;
+
+ if (grub_memcmp (header.magic, LZOP_MAGIC, LZOP_MAGIC_SIZE) != 0)
+ return 0;
+
+ if (grub_be_to_cpu16(header.lib_version) < LZOP_NEW_LIB)
+ return 0;
+
+ /* Too new version, should upgrade minilzo? */
+ if (grub_be_to_cpu16 (header.lib_version_ext) > MINILZO_VERSION)
+ return 0;
+
+ flags = grub_be_to_cpu32 (header.flags);
+
+ if (flags & F_CRC32_D)
+ {
+ lzopio->has_ucheck = 1;
+ lzopio->ucheck_fun = grub_crypto_lookup_md_by_name ("crc32");
+ }
+ else if (flags & F_ADLER32_D)
+ {
+ lzopio->has_ucheck = 1;
+ lzopio->ucheck_fun = grub_crypto_lookup_md_by_name ("adler32");
+ }
+
+ if (flags & F_CRC32_C)
+ {
+ lzopio->has_ccheck = 1;
+ lzopio->ccheck_fun = grub_crypto_lookup_md_by_name ("crc32");
+ }
+ else if (flags & F_ADLER32_C)
+ {
+ lzopio->has_ccheck = 1;
+ lzopio->ccheck_fun = grub_crypto_lookup_md_by_name ("adler32");
+ }
+
+ if (flags & F_H_CRC32)
+ hcheck = grub_crypto_lookup_md_by_name ("crc32");
+ else
+ hcheck = grub_crypto_lookup_md_by_name ("adler32");
+
+ if (hcheck) {
+ context = grub_malloc(hcheck->contextsize);
+ if (! context)
+ return 0;
+
+ hcheck->init(context);
+
+ /* MAGIC is not included in check calculation. */
+ hcheck->write(context, &header.lzop_version, sizeof(header)- LZOP_MAGIC_SIZE);
+ }
+
+ if (header.name_len != 0)
+ {
+ name = grub_malloc (header.name_len);
+ if (! name)
+ {
+ grub_free (context);
+ return 0;
+ }
+
+ if (grub_file_read (lzopio->file, name, header.name_len) !=
+ header.name_len)
+ {
+ grub_free(name);
+ goto CORRUPTED;
+ }
+
+ if (hcheck)
+ hcheck->write(context, name, header.name_len);
+
+ grub_free(name);
+ }
+
+ if (hcheck)
+ hcheck->final(context);
+
+ if (grub_file_read (lzopio->file, &checksum, sizeof (checksum)) !=
+ sizeof (checksum))
+ goto CORRUPTED;
+
+ if (hcheck && grub_memcmp (&checksum, hcheck->read(context), sizeof(checksum)) != 0)
+ goto CORRUPTED;
+
+ lzopio->start_block_off = grub_file_tell (lzopio->file);
+
+ if (calculate_uncompressed_size (file) < 0)
+ goto CORRUPTED;
+
+ /* Get back to start block. */
+ grub_file_seek (lzopio->file, lzopio->start_block_off);
+
+ /* Read first block - grub_lzopio_read() expects valid block. */
+ if (read_block_header (lzopio) < 0)
+ goto CORRUPTED;
+
+ lzopio->saved_off = 0;
+ return 1;
+
+CORRUPTED:
+ return 0;
+}
+
+static grub_file_t
+grub_lzopio_open (grub_file_t io, enum grub_file_type type)
+{
+ grub_file_t file;
+ grub_lzopio_t lzopio;
+
+ if (type & GRUB_FILE_TYPE_NO_DECOMPRESS)
+ return io;
+
+ file = (grub_file_t) grub_zalloc (sizeof (*file));
+ if (!file)
+ return 0;
+
+ lzopio = grub_zalloc (sizeof (*lzopio));
+ if (!lzopio)
+ {
+ grub_free (file);
+ return 0;
+ }
+
+ lzopio->file = io;
+
+ file->device = io->device;
+ file->data = lzopio;
+ file->fs = &grub_lzopio_fs;
+ file->size = GRUB_FILE_SIZE_UNKNOWN;
+ file->not_easily_seekable = 1;
+
+ if (grub_file_tell (lzopio->file) != 0)
+ grub_file_seek (lzopio->file, 0);
+
+ if (!test_header (file))
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_file_seek (io, 0);
+ grub_free (lzopio);
+ grub_free (file);
+
+ return io;
+ }
+
+ return file;
+}
+
+static grub_ssize_t
+grub_lzopio_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ grub_lzopio_t lzopio = file->data;
+ grub_ssize_t ret = 0;
+ grub_off_t off;
+
+ /* Backward seek before last read block. */
+ if (lzopio->saved_off > grub_file_tell (file))
+ {
+ grub_file_seek (lzopio->file, lzopio->start_block_off);
+
+ if (read_block_header (lzopio) < 0)
+ goto CORRUPTED;
+
+ lzopio->saved_off = 0;
+ }
+
+ /* Forward to first block with requested data. */
+ while (lzopio->saved_off + lzopio->block.usize <= grub_file_tell (file))
+ {
+ /* EOF, could be possible files with unknown size. */
+ if (lzopio->block.usize == 0)
+ return 0;
+
+ if (jump_block (lzopio) < 0)
+ goto CORRUPTED;
+ }
+
+ off = grub_file_tell (file) - lzopio->saved_off;
+
+ while (len != 0 && lzopio->block.usize != 0)
+ {
+ grub_size_t to_copy;
+
+ /* Block not decompressed yet. */
+ if (!lzopio->block.udata && uncompress_block (lzopio) < 0)
+ goto CORRUPTED;
+
+ /* Copy requested data into buffer. */
+ to_copy = lzopio->block.usize - off;
+ if (to_copy > len)
+ to_copy = len;
+ grub_memcpy (buf, lzopio->block.udata + off, to_copy);
+
+ len -= to_copy;
+ buf += to_copy;
+ ret += to_copy;
+ off = 0;
+
+ /* Read next block if needed. */
+ if (len > 0 && read_block_header (lzopio) < 0)
+ goto CORRUPTED;
+ }
+
+ return ret;
+
+CORRUPTED:
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, N_("lzop file corrupted"));
+ return -1;
+}
+
+/* Release everything, including the underlying file object. */
+static grub_err_t
+grub_lzopio_close (grub_file_t file)
+{
+ grub_lzopio_t lzopio = file->data;
+
+ grub_file_close (lzopio->file);
+ grub_free (lzopio->block.cdata);
+ grub_free (lzopio->block.udata);
+ grub_free (lzopio);
+
+ /* Device must not be closed twice. */
+ file->device = 0;
+ file->name = 0;
+ return grub_errno;
+}
+
+static struct grub_fs grub_lzopio_fs = {
+ .name = "lzopio",
+ .fs_dir = 0,
+ .fs_open = 0,
+ .fs_read = grub_lzopio_read,
+ .fs_close = grub_lzopio_close,
+ .fs_label = 0,
+ .next = 0
+};
+
+GRUB_MOD_INIT (lzopio)
+{
+ grub_file_filter_register (GRUB_FILE_FILTER_LZOPIO, grub_lzopio_open);
+}
+
+GRUB_MOD_FINI (lzopio)
+{
+ grub_file_filter_unregister (GRUB_FILE_FILTER_LZOPIO);
+}
diff --git a/grub-core/io/offset.c b/grub-core/io/offset.c
new file mode 100644
index 0000000..7e2db4a
--- /dev/null
+++ b/grub-core/io/offset.c
@@ -0,0 +1,112 @@
+/*
+ * 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/file.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_offset_file
+{
+ grub_file_t parent;
+ grub_off_t off;
+};
+
+static grub_ssize_t
+grub_offset_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_offset_file *data = file->data;
+ if (grub_file_seek (data->parent, data->off + file->offset) == (grub_off_t) -1)
+ return -1;
+ return grub_file_read (data->parent, buf, len);
+}
+
+static grub_err_t
+grub_offset_close (grub_file_t file)
+{
+ struct grub_offset_file *data = file->data;
+
+ if (data->parent)
+ grub_file_close (data->parent);
+
+ /* No need to close the same device twice. */
+ file->device = 0;
+
+ return 0;
+}
+
+static struct grub_fs grub_offset_fs = {
+ .name = "offset",
+ .fs_dir = 0,
+ .fs_open = 0,
+ .fs_read = grub_offset_read,
+ .fs_close = grub_offset_close,
+ .fs_label = 0,
+ .next = 0
+};
+
+void
+grub_file_offset_close (grub_file_t file)
+{
+ struct grub_offset_file *off_data = file->data;
+ off_data->parent = NULL;
+ grub_file_close (file);
+}
+
+grub_file_t
+grub_file_offset_open (grub_file_t parent, enum grub_file_type type,
+ grub_off_t start, grub_off_t size)
+{
+ struct grub_offset_file *off_data;
+ grub_file_t off_file, last_off_file;
+ grub_file_filter_id_t filter;
+
+ off_file = grub_zalloc (sizeof (*off_file));
+ off_data = grub_zalloc (sizeof (*off_data));
+ if (!off_file || !off_data)
+ {
+ grub_free (off_file);
+ grub_free (off_data);
+ return 0;
+ }
+
+ off_data->off = start;
+ off_data->parent = parent;
+
+ off_file->device = parent->device;
+ off_file->data = off_data;
+ off_file->fs = &grub_offset_fs;
+ off_file->size = size;
+
+ last_off_file = NULL;
+ for (filter = GRUB_FILE_FILTER_COMPRESSION_FIRST;
+ off_file && filter <= GRUB_FILE_FILTER_COMPRESSION_LAST; filter++)
+ if (grub_file_filters[filter])
+ {
+ last_off_file = off_file;
+ off_file = grub_file_filters[filter] (off_file, type);
+ }
+
+ if (!off_file)
+ {
+ off_data->parent = NULL;
+ grub_file_close (last_off_file);
+ return 0;
+ }
+ return off_file;
+}
diff --git a/grub-core/io/xzio.c b/grub-core/io/xzio.c
new file mode 100644
index 0000000..516c4df
--- /dev/null
+++ b/grub-core/io/xzio.c
@@ -0,0 +1,346 @@
+/* xzio.c - decompression support for xz */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/fs.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#include "xz.h"
+#include "xz_stream.h"
+
+#define XZBUFSIZ 0x2000
+#define VLI_MAX_DIGITS 9
+#define XZ_STREAM_FOOTER_SIZE 12
+
+struct grub_xzio
+{
+ grub_file_t file;
+ struct xz_buf buf;
+ struct xz_dec *dec;
+ grub_uint8_t inbuf[XZBUFSIZ];
+ grub_uint8_t outbuf[XZBUFSIZ];
+ grub_off_t saved_offset;
+};
+
+typedef struct grub_xzio *grub_xzio_t;
+static struct grub_fs grub_xzio_fs;
+
+static grub_size_t
+decode_vli (const grub_uint8_t buf[], grub_size_t size_max,
+ grub_uint64_t *num)
+{
+ if (size_max == 0)
+ return 0;
+
+ if (size_max > VLI_MAX_DIGITS)
+ size_max = VLI_MAX_DIGITS;
+
+ *num = buf[0] & 0x7F;
+ grub_size_t i = 0;
+
+ while (buf[i++] & 0x80)
+ {
+ if (i >= size_max || buf[i] == 0x00)
+ return 0;
+
+ *num |= (uint64_t) (buf[i] & 0x7F) << (i * 7);
+ }
+
+ return i;
+}
+
+static grub_ssize_t
+read_vli (grub_file_t file, grub_uint64_t *num)
+{
+ grub_uint8_t buf[VLI_MAX_DIGITS];
+ grub_ssize_t read_bytes;
+ grub_size_t dec;
+
+ read_bytes = grub_file_read (file, buf, VLI_MAX_DIGITS);
+ if (read_bytes < 0)
+ return -1;
+
+ dec = decode_vli (buf, read_bytes, num);
+ grub_file_seek (file, file->offset - (read_bytes - dec));
+ return dec;
+}
+
+/* Function xz_dec_run() should consume header and ask for more (XZ_OK)
+ * else file is corrupted (or options not supported) or not xz. */
+static int
+test_header (grub_file_t file)
+{
+ grub_xzio_t xzio = file->data;
+ enum xz_ret ret;
+
+ xzio->buf.in_size = grub_file_read (xzio->file, xzio->inbuf,
+ STREAM_HEADER_SIZE);
+
+ if (xzio->buf.in_size != STREAM_HEADER_SIZE)
+ return 0;
+
+ ret = xz_dec_run (xzio->dec, &xzio->buf);
+
+ if (ret == XZ_FORMAT_ERROR)
+ return 0;
+
+ if (ret != XZ_OK)
+ return 0;
+
+ return 1;
+}
+
+/* Try to find out size of uncompressed data,
+ * also do some footer sanity checks. */
+static int
+test_footer (grub_file_t file)
+{
+ grub_xzio_t xzio = file->data;
+ grub_uint8_t footer[FOOTER_MAGIC_SIZE];
+ grub_uint32_t backsize;
+ grub_uint8_t imarker;
+ grub_uint64_t uncompressed_size_total = 0;
+ grub_uint64_t uncompressed_size;
+ grub_uint64_t records;
+
+ grub_file_seek (xzio->file, xzio->file->size - FOOTER_MAGIC_SIZE);
+ if (grub_file_read (xzio->file, footer, FOOTER_MAGIC_SIZE)
+ != FOOTER_MAGIC_SIZE
+ || grub_memcmp (footer, FOOTER_MAGIC, FOOTER_MAGIC_SIZE) != 0)
+ goto ERROR;
+
+ grub_file_seek (xzio->file, xzio->file->size - 8);
+ if (grub_file_read (xzio->file, &backsize, sizeof (backsize))
+ != sizeof (backsize))
+ goto ERROR;
+
+ /* Calculate real backward size. */
+ backsize = (grub_le_to_cpu32 (backsize) + 1) * 4;
+
+ /* Set file to the beginning of stream index. */
+ grub_file_seek (xzio->file,
+ xzio->file->size - XZ_STREAM_FOOTER_SIZE - backsize);
+
+ /* Test index marker. */
+ if (grub_file_read (xzio->file, &imarker, sizeof (imarker))
+ != sizeof (imarker) && imarker != 0x00)
+ goto ERROR;
+
+ if (read_vli (xzio->file, &records) <= 0)
+ goto ERROR;
+
+ for (; records != 0; records--)
+ {
+ if (read_vli (xzio->file, &uncompressed_size) <= 0) /* Ignore unpadded. */
+ goto ERROR;
+ if (read_vli (xzio->file, &uncompressed_size) <= 0) /* Uncompressed. */
+ goto ERROR;
+
+ uncompressed_size_total += uncompressed_size;
+ }
+
+ file->size = uncompressed_size_total;
+ grub_file_seek (xzio->file, STREAM_HEADER_SIZE);
+ return 1;
+
+ERROR:
+ return 0;
+}
+
+static grub_file_t
+grub_xzio_open (grub_file_t io, enum grub_file_type type)
+{
+ grub_file_t file;
+ grub_xzio_t xzio;
+
+ if (type & GRUB_FILE_TYPE_NO_DECOMPRESS)
+ return io;
+
+ file = (grub_file_t) grub_zalloc (sizeof (*file));
+ if (!file)
+ return 0;
+
+ xzio = grub_zalloc (sizeof (*xzio));
+ if (!xzio)
+ {
+ grub_free (file);
+ return 0;
+ }
+
+ xzio->file = io;
+
+ file->device = io->device;
+ file->data = xzio;
+ file->fs = &grub_xzio_fs;
+ file->size = GRUB_FILE_SIZE_UNKNOWN;
+ file->not_easily_seekable = 1;
+
+ if (grub_file_tell (xzio->file) != 0)
+ grub_file_seek (xzio->file, 0);
+
+ /* Allocated 64KiB for dictionary.
+ * Decoder will relocate if bigger is needed. */
+ xzio->dec = xz_dec_init (1 << 16);
+ if (!xzio->dec)
+ {
+ grub_free (file);
+ grub_free (xzio);
+ return 0;
+ }
+
+ xzio->buf.in = xzio->inbuf;
+ xzio->buf.out = xzio->outbuf;
+ xzio->buf.out_size = XZBUFSIZ;
+
+ /* FIXME: don't test footer on not easily seekable files. */
+ if (!test_header (file) || !test_footer (file))
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_file_seek (io, 0);
+ xz_dec_end (xzio->dec);
+ grub_free (xzio);
+ grub_free (file);
+
+ return io;
+ }
+
+ return file;
+}
+
+static grub_ssize_t
+grub_xzio_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ grub_ssize_t ret = 0;
+ grub_ssize_t readret;
+ enum xz_ret xzret;
+ grub_xzio_t xzio = file->data;
+ grub_off_t current_offset;
+
+ /* If seek backward need to reset decoder and start from beginning of file.
+ TODO Possible improvement by jumping blocks. */
+ if (file->offset < xzio->saved_offset)
+ {
+ xz_dec_reset (xzio->dec);
+ xzio->saved_offset = 0;
+ xzio->buf.out_pos = 0;
+ xzio->buf.in_pos = 0;
+ xzio->buf.in_size = 0;
+ grub_file_seek (xzio->file, 0);
+ }
+
+ current_offset = xzio->saved_offset;
+
+ while (len > 0)
+ {
+ xzio->buf.out_size = file->offset + ret + len - current_offset;
+ if (xzio->buf.out_size > XZBUFSIZ)
+ xzio->buf.out_size = XZBUFSIZ;
+ /* Feed input. */
+ if (xzio->buf.in_pos == xzio->buf.in_size)
+ {
+ readret = grub_file_read (xzio->file, xzio->inbuf, XZBUFSIZ);
+ if (readret < 0)
+ return -1;
+ xzio->buf.in_size = readret;
+ xzio->buf.in_pos = 0;
+ }
+
+ xzret = xz_dec_run (xzio->dec, &xzio->buf);
+ switch (xzret)
+ {
+ case XZ_MEMLIMIT_ERROR:
+ case XZ_FORMAT_ERROR:
+ case XZ_OPTIONS_ERROR:
+ case XZ_DATA_ERROR:
+ case XZ_BUF_ERROR:
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ N_("xz file corrupted or unsupported block options"));
+ return -1;
+ default:
+ break;
+ }
+
+ {
+ grub_off_t new_offset = current_offset + xzio->buf.out_pos;
+
+ if (file->offset <= new_offset)
+ /* Store first chunk of data in buffer. */
+ {
+ grub_size_t delta = new_offset - (file->offset + ret);
+ grub_memmove (buf, xzio->buf.out + (xzio->buf.out_pos - delta),
+ delta);
+ len -= delta;
+ buf += delta;
+ ret += delta;
+ }
+ current_offset = new_offset;
+ }
+ xzio->buf.out_pos = 0;
+
+ if (xzret == XZ_STREAM_END) /* Stream end, EOF. */
+ break;
+ }
+
+ if (ret >= 0)
+ xzio->saved_offset = file->offset + ret;
+
+ return ret;
+}
+
+/* Release everything, including the underlying file object. */
+static grub_err_t
+grub_xzio_close (grub_file_t file)
+{
+ grub_xzio_t xzio = file->data;
+
+ xz_dec_end (xzio->dec);
+
+ grub_file_close (xzio->file);
+ grub_free (xzio);
+
+ /* Device must not be closed twice. */
+ file->device = 0;
+ file->name = 0;
+ return grub_errno;
+}
+
+static struct grub_fs grub_xzio_fs = {
+ .name = "xzio",
+ .fs_dir = 0,
+ .fs_open = 0,
+ .fs_read = grub_xzio_read,
+ .fs_close = grub_xzio_close,
+ .fs_label = 0,
+ .next = 0
+};
+
+GRUB_MOD_INIT (xzio)
+{
+ grub_file_filter_register (GRUB_FILE_FILTER_XZIO, grub_xzio_open);
+}
+
+GRUB_MOD_FINI (xzio)
+{
+ grub_file_filter_unregister (GRUB_FILE_FILTER_XZIO);
+}
diff --git a/grub-core/kern/acpi.c b/grub-core/kern/acpi.c
new file mode 100644
index 0000000..5746ac0
--- /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
new file mode 100644
index 0000000..354a069
--- /dev/null
+++ b/grub-core/kern/arm/cache.S
@@ -0,0 +1,123 @@
+/*
+ * 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/symbol.h>
+
+ .file "cache.S"
+ .text
+ .syntax unified
+#if !defined (__thumb2__) || !defined (ARMV7)
+ .arm
+#else
+ .thumb
+#endif
+
+#if !defined (ARMV6) && !defined (ARMV7)
+# error Unsupported architecture version!
+#endif
+
+ .align 2
+
+/*
+ * Simple cache maintenance functions
+ */
+
+@ r0 - *beg (inclusive)
+@ r1 - *end (exclusive)
+@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
+1: cmp r0, r1
+ bge 2f
+#ifdef ARMV6
+ mcr p15, 0, r0, c7, c10, 1 @ Clean data cache line by MVA
+#else
+ mcr p15, 0, r0, c7, c11, 1 @ DCCMVAU
+#endif
+ add r0, r0, r2 @ Next line
+ b 1b
+2: DSB
+ bx lr
+
+@ r0 - *beg (inclusive)
+@ r1 - *end (exclusive)
+#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
+1: cmp r0, r1
+ bge 2f
+ mcr p15, 0, r0, c7, c5, 1 @ ICIMVAU
+ add r0, r0, r2 @ Next line
+ b 1b
+ @ Branch predictor invalidate all
+2: mcr p15, 0, r0, c7, c5, 6 @ BPIALL
+ DSB
+ ISB
+ bx lr
+
+#ifdef ARMV6
+FUNCTION(grub_arm_disable_caches_mmu_armv6)
+#else
+FUNCTION(grub_arm_disable_caches_mmu_armv7)
+#endif
+
+ push {r4, lr}
+
+ @ disable D-cache
+ mrc p15, 0, r0, c1, c0, 0
+ bic r0, r0, #(1 << 2)
+ mcr p15, 0, r0, c1, c0, 0
+ DSB
+ ISB
+
+ @ clean/invalidate D-cache
+ bl clean_invalidate_dcache
+
+ @ disable I-cache
+ mrc p15, 0, r0, c1, c0, 0
+ bic r0, r0, #(1 << 12)
+ mcr p15, 0, r0, c1, c0, 0
+ DSB
+ ISB
+
+ @ invalidate I-cache (also invalidates branch predictors)
+ mcr p15, 0, r0, c7, c5, 0
+ DSB
+ ISB
+
+ @ clear SCTLR M bit
+ mrc p15, 0, r0, c1, c0, 0
+ bic r0, r0, #(1 << 0)
+ mcr p15, 0, r0, c1, c0, 0
+
+ mcr p15, 0, r0, c8, c7, 0 @ invalidate TLB
+ mcr p15, 0, r0, c7, c5, 6 @ invalidate branch predictor
+ DSB
+ ISB
+
+ pop {r4, lr}
+ bx lr
+
diff --git a/grub-core/kern/arm/cache.c b/grub-core/kern/arm/cache.c
new file mode 100644
index 0000000..6c75193
--- /dev/null
+++ b/grub-core/kern/arm/cache.c
@@ -0,0 +1,311 @@
+#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. */
+static enum
+ {
+ ARCH_UNKNOWN,
+ ARCH_ARMV5_WRITE_THROUGH,
+ ARCH_ARMV6,
+ ARCH_ARMV6_UNIFIED,
+ ARCH_ARMV7
+ } type = ARCH_UNKNOWN;
+
+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_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_clean_dcache_range_poc_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);
+grub_uint32_t grub_arm_cache_type (void);
+
+static void
+probe_caches (void)
+{
+ grub_uint32_t main_id, cache_type;
+
+ /* Read main ID Register */
+ main_id = grub_arm_main_id ();
+
+ switch ((main_id >> 16) & 0xf)
+ {
+ case 0x3:
+ 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);
+ }
+
+ /* Read Cache Type Register */
+ cache_type = grub_arm_cache_type ();
+
+ switch (cache_type >> 24)
+ {
+ case 0x00:
+ case 0x01:
+ grub_arch_cache_dlinesz = 8 << ((cache_type >> 12) & 3);
+ grub_arch_cache_ilinesz = 8 << (cache_type & 3);
+ type = ARCH_ARMV5_WRITE_THROUGH;
+ break;
+ case 0x04:
+ case 0x0a:
+ case 0x0c:
+ case 0x0e:
+ case 0x1c:
+ grub_arch_cache_dlinesz = 8 << ((cache_type >> 12) & 3);
+ grub_arch_cache_ilinesz = 8 << (cache_type & 3);
+ type = ARCH_ARMV6_UNIFIED;
+ break;
+ case 0x05:
+ case 0x0b:
+ case 0x0d:
+ case 0x0f:
+ case 0x1d:
+ grub_arch_cache_dlinesz = 8 << ((cache_type >> 12) & 3);
+ grub_arch_cache_ilinesz = 8 << (cache_type & 3);
+ type = ARCH_ARMV6;
+ break;
+ default:
+ /*
+ * The CTR register is pretty much unchanged from v7 onwards,
+ * and is guaranteed to be backward compatible (the IDC/DIC bits
+ * allow certain CMOs to be elided, but performing them is never
+ * wrong), hence handling it like its AArch64 equivalent.
+ */
+ grub_arch_cache_dlinesz = 4 << ((cache_type >> 16) & 0xf);
+ grub_arch_cache_ilinesz = 4 << (cache_type & 0xf);
+ type = ARCH_ARMV7;
+ }
+ 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_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_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:
+ case ARCH_ARMV6_UNIFIED:
+ break;
+ /* Pacify GCC. */
+ case ARCH_UNKNOWN:
+ break;
+ }
+}
+
+void
+grub_arch_sync_dma_caches (volatile 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_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_ARMV5_WRITE_THROUGH:
+ case ARCH_ARMV6_UNIFIED:
+ grub_arm_clean_dcache_range_armv6 (start, end, grub_arch_cache_dlinesz);
+ break;
+ case ARCH_ARMV7:
+ grub_arm_clean_dcache_range_poc_armv7 (start, end, grub_arch_cache_dlinesz);
+ grub_arm_invalidate_icache_range_armv7 (start, end,
+ grub_arch_cache_ilinesz);
+ break;
+ /* Pacify GCC. */
+ case ARCH_UNKNOWN:
+ break;
+ }
+}
+
+void
+grub_arm_disable_caches_mmu (void)
+{
+ if (type == ARCH_UNKNOWN)
+ probe_caches ();
+ switch (type)
+ {
+ case ARCH_ARMV5_WRITE_THROUGH:
+ case ARCH_ARMV6_UNIFIED:
+ case ARCH_ARMV6:
+ grub_arm_disable_caches_mmu_armv6 ();
+ break;
+ case ARCH_ARMV7:
+ grub_arm_disable_caches_mmu_armv7 ();
+ break;
+ /* Pacify GCC. */
+ case ARCH_UNKNOWN:
+ break;
+ }
+}
diff --git a/grub-core/kern/arm/cache_armv6.S b/grub-core/kern/arm/cache_armv6.S
new file mode 100644
index 0000000..dfaded0
--- /dev/null
+++ b/grub-core/kern/arm/cache_armv6.S
@@ -0,0 +1,72 @@
+/*
+ * 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/symbol.h>
+
+ .file "cache_armv6.S"
+ .text
+ .syntax unified
+ .arm
+
+# define DMB mcr p15, 0, r0, c7, c10, 5
+# define DSB mcr p15, 0, r0, c7, c10, 4
+# define ISB mcr p15, 0, r0, c7, c5, 4
+#define ARMV6 1
+
+clean_invalidate_dcache:
+ mcr p15, 0, r0, c7, c14, 0 @ Clean/Invalidate D-cache
+ bx lr
+
+#include "cache.S"
+
+FUNCTION(grub_arm_main_id)
+ mrc p15, 0, r0, c0, c0, 0
+ bx lr
+
+FUNCTION(grub_arm_cache_type)
+ mrc p15, 0, r0, c0, c0, 1
+ 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/cache_armv7.S b/grub-core/kern/arm/cache_armv7.S
new file mode 100644
index 0000000..5ae76a3
--- /dev/null
+++ b/grub-core/kern/arm/cache_armv7.S
@@ -0,0 +1,138 @@
+/*
+ * 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/symbol.h>
+
+ .file "cache_armv7.S"
+ .text
+ .syntax unified
+#if !defined (__thumb2__)
+ .arch armv7a
+ .arm
+#else
+ .arch armv7
+ .thumb
+#endif
+# define DMB dmb
+# define DSB dsb
+# define ISB isb
+#define ARMV7 1
+
+FUNCTION(grub_arm_clean_dcache_range_poc_armv7)
+ DSB
+ @ Clean data cache for range to point-of-coherence
+1: cmp r0, r1
+ bge 2f
+ mcr p15, 0, r0, c7, c14, 1 @ DCCMVAC
+ add r0, r0, r2 @ Next line
+ b 1b
+2: DSB
+ bx lr
+
+
+ @ r0 - CLIDR
+ @ r1 - LoC
+ @ r2 - current level
+ @ r3 - num sets
+ @ r4 - num ways
+ @ r5 - current set
+ @ r6 - current way
+ @ r7 - line size
+ @ r8 - scratch
+ @ r9 - scratch
+ @ r10 - scratch
+ @ r11 - scratch
+clean_invalidate_dcache:
+ push {r4-r12, lr}
+ mrc p15, 1, r0, c0, c0, 1 @ Read CLIDR
+ lsr r1, r0, #24 @ Extract LoC
+ and r1, r1, #0x7
+
+ mov r2, #0 @ First level, L1
+2: and r8, r0, #7 @ cache type at current level
+ cmp r8, #2
+ blt 5f @ instruction only, or none, skip level
+
+ @ set current cache level/type (for CCSIDR read)
+ lsl r8, r2, #1
+ mcr p15, 2, r8, c0, c0, 0 @ Write CSSELR (level, type: data/uni)
+
+ @ read current cache information
+ mrc p15, 1, r8, c0, c0, 0 @ Read CCSIDR
+ lsr r3, r8, #13 @ Number of sets -1
+
+ @ Keep only 14 bits of r3
+ lsl r3, r3, #18
+ lsr r3, r3, #18
+
+ lsr r4, r8, #3 @ Number of ways -1
+
+ @ Keep only 9 bits of r4
+ lsl r4, r4, #23
+ lsr r4, r4, #23
+
+ and r7, r8, #7 @ log2(line size in words) - 2
+ add r7, r7, #2 @ adjust
+ mov r8, #1
+ lsl r7, r8, r7 @ -> line size in words
+ lsl r7, r7, #2 @ -> bytes
+
+ @ set loop
+ mov r5, #0 @ current set = 0
+3: lsl r8, r2, #1 @ insert level
+ clz r9, r7 @ calculate set field offset
+ mov r10, #31
+ sub r9, r10, r9
+ lsl r10, r5, r9
+ orr r8, r8, r10 @ insert set field
+
+ @ way loop
+ @ calculate way field offset
+ mov r6, #0 @ current way = 0
+ add r10, r4, #1
+ clz r9, r10 @ r9 = way field offset
+ add r9, r9, #1
+4: lsl r10, r6, r9
+ orr r11, r8, r10 @ insert way field
+
+ @ clean and invalidate line by set/way
+ mcr p15, 0, r11, c7, c14, 2 @ DCCISW
+
+ @ next way
+ add r6, r6, #1
+ cmp r6, r4
+ ble 4b
+
+ @ next set
+ add r5, r5, #1
+ cmp r5, r3
+ ble 3b
+
+ @ next level
+5: lsr r0, r0, #3 @ align next level CLIDR 'type' field
+ add r2, r2, #1 @ increment cache level counter
+ cmp r2, r1
+ blt 2b @ outer loop
+
+ @ return
+6: DSB
+ ISB
+ pop {r4-r12, lr}
+ bx lr
+
+#include "cache.S" \ No newline at end of file
diff --git a/grub-core/kern/arm/compiler-rt.S b/grub-core/kern/arm/compiler-rt.S
new file mode 100644
index 0000000..645b42f
--- /dev/null
+++ b/grub-core/kern/arm/compiler-rt.S
@@ -0,0 +1,86 @@
+/*
+ * 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/symbol.h>
+#include <grub/dl.h>
+
+ .file "misc.S"
+ .text
+ .syntax unified
+#if !defined (__thumb2__)
+ .arm
+#else
+ .thumb
+#endif
+
+ .align 2
+
+FUNCTION(__muldi3)
+FUNCTION(__aeabi_lmul)
+ stmfd sp!, {r4, fp}
+ add fp, sp, #4
+ sub sp, sp, #16
+ str r0, [fp, #-12]
+ str r1, [fp, #-8]
+ str r2, [fp, #-20]
+ str r3, [fp, #-16]
+ ldr r3, [fp, #-8]
+ ldr r2, [fp, #-20]
+ mul r2, r3, r2
+ ldr r3, [fp, #-16]
+ ldr r1, [fp, #-12]
+ mul r3, r1, r3
+ add r2, r2, r3
+ ldr r0, [fp, #-12]
+ ldr r1, [fp, #-20]
+ umull r3, r4, r0, r1
+ add r2, r2, r4
+ mov r4, r2
+ mov r0, r3
+ mov r1, r4
+ mov sp, fp
+ sub sp, sp, #4
+ ldmfd sp!, {r4, fp}
+ bx lr
+
+ .macro division32 parent
+
+ 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, #8] @ Extract remainder
+ ldmfd sp!, {r3,lr} @ Pop into an unused arg/scratch register
+ add sp, sp, #8
+ bx lr
+ .endm
+
+FUNCTION(__aeabi_uidivmod)
+ division32 grub_divmod32
+FUNCTION(__aeabi_idivmod)
+ division32 grub_divmod32s
+
+/*
+ * Null divide-by-zero handler
+ */
+FUNCTION(__aeabi_unwind_cpp_pr0)
+FUNCTION(raise)
+ mov r0, #0
+ bx lr
+
+ END
diff --git a/grub-core/kern/arm/coreboot/cbtable.c b/grub-core/kern/arm/coreboot/cbtable.c
new file mode 100644
index 0000000..8a655bb
--- /dev/null
+++ b/grub-core/kern/arm/coreboot/cbtable.c
@@ -0,0 +1,40 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,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/coreboot/lbio.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/arm/startup.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+grub_linuxbios_table_header_t
+grub_linuxbios_get_tables (void)
+{
+ grub_linuxbios_table_header_t table_header
+ = (grub_linuxbios_table_header_t) grub_arm_saved_registers.r[0];
+
+ if (!grub_linuxbios_check_signature (table_header))
+ return 0;
+
+ return table_header;
+}
diff --git a/grub-core/kern/arm/coreboot/coreboot.S b/grub-core/kern/arm/coreboot/coreboot.S
new file mode 100644
index 0000000..a110452
--- /dev/null
+++ b/grub-core/kern/arm/coreboot/coreboot.S
@@ -0,0 +1,44 @@
+/*
+ * 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/symbol.h>
+
+ .file "coreboot.S"
+ .text
+ .syntax unified
+#if !defined (__thumb2__)
+ .arch armv7a
+ .arm
+#else
+ .arch armv7
+ .thumb
+#endif
+
+FUNCTION(grub_arm_pfr1)
+ mrc p15, 0, r0, c0, c1, 1
+ bx lr
+
+FUNCTION(grub_armv7_get_timer_value)
+ isb
+ mrrc p15, 1, r0, r1, c14
+ bx lr
+
+FUNCTION(grub_armv7_get_timer_frequency)
+ mrc p15, 0, r0, c14, c0, 0
+ bx lr
+
diff --git a/grub-core/kern/arm/coreboot/dma.c b/grub-core/kern/arm/coreboot/dma.c
new file mode 100644
index 0000000..2c2a627
--- /dev/null
+++ b/grub-core/kern/arm/coreboot/dma.c
@@ -0,0 +1,59 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/dma.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/mm_private.h>
+#include <grub/cache.h>
+
+struct grub_pci_dma_chunk *
+grub_memalign_dma32 (grub_size_t align, grub_size_t size)
+{
+ void *ret;
+ if (align < 64)
+ align = 64;
+ size = ALIGN_UP (size, align);
+ ret = grub_memalign (align, size);
+ if (!ret)
+ return 0;
+ grub_arch_sync_dma_caches (ret, size);
+ return ret;
+}
+
+void
+grub_dma_free (struct grub_pci_dma_chunk *ch)
+{
+ grub_size_t size = (((struct grub_mm_header *) ch) - 1)->size * GRUB_MM_ALIGN;
+ grub_arch_sync_dma_caches (ch, size);
+ grub_free (ch);
+}
+
+volatile void *
+grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
+{
+ return (void *) ch;
+}
+
+grub_uint32_t
+grub_dma_get_phys (struct grub_pci_dma_chunk *ch)
+{
+ return (grub_uint32_t) (grub_addr_t) ch;
+}
+
diff --git a/grub-core/kern/arm/coreboot/init.c b/grub-core/kern/arm/coreboot/init.c
new file mode 100644
index 0000000..8d8c5b8
--- /dev/null
+++ b/grub-core/kern/arm/coreboot/init.c
@@ -0,0 +1,151 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,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/kernel.h>
+#include <grub/mm.h>
+#include <grub/memory.h>
+#include <grub/machine/console.h>
+#include <grub/machine/kernel.h>
+#include <grub/offsets.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/loader.h>
+#include <grub/env.h>
+#include <grub/cache.h>
+#include <grub/time.h>
+#include <grub/symbol.h>
+#include <grub/video.h>
+#include <grub/coreboot/lbio.h>
+#include <grub/fdtbus.h>
+
+extern grub_uint8_t _start[];
+extern grub_uint8_t _end[];
+extern grub_uint8_t _edata[];
+grub_addr_t start_of_ram = ~(grub_addr_t)0;
+
+void __attribute__ ((noreturn))
+grub_exit (void)
+{
+ /* We can't use grub_fatal() in this function. This would create an infinite
+ loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */
+ while (1)
+ grub_cpu_idle ();
+}
+
+static grub_uint64_t modend;
+static int have_memory = 0;
+
+/* Helper for grub_machine_init. */
+static int
+heap_init (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data __attribute__ ((unused)))
+{
+ grub_uint64_t begin = addr, end = addr + size;
+
+#if GRUB_CPU_SIZEOF_VOID_P == 4
+ /* Restrict ourselves to 32-bit memory space. */
+ if (begin > GRUB_ULONG_MAX)
+ return 0;
+ if (end > GRUB_ULONG_MAX)
+ end = GRUB_ULONG_MAX;
+#endif
+
+ if (start_of_ram > begin)
+ start_of_ram = begin;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+
+ if (modend && begin < modend)
+ {
+ if (begin < (grub_addr_t)_start)
+ {
+ grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) ((grub_addr_t)_start - begin));
+ have_memory = 1;
+ }
+ begin = modend;
+ }
+
+ /* Avoid DMA problems. */
+ if (end >= 0xfe000000)
+ end = 0xfe000000;
+
+ if (end <= begin)
+ return 0;
+
+ grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - begin));
+
+ have_memory = 1;
+
+ return 0;
+}
+
+void
+grub_machine_init (void)
+{
+ struct grub_module_header *header;
+ void *dtb = 0;
+ grub_size_t dtb_size = 0;
+
+ modend = grub_modules_get_end ();
+
+ grub_video_coreboot_fb_early_init ();
+
+ grub_machine_mmap_iterate (heap_init, NULL);
+ if (!have_memory)
+ grub_fatal ("No memory found");
+
+ grub_video_coreboot_fb_late_init ();
+
+ grub_font_init ();
+ grub_gfxterm_init ();
+
+ FOR_MODULES (header)
+ if (header->type == OBJ_TYPE_DTB)
+ {
+ char *dtb_orig_addr, *dtb_copy;
+ dtb_orig_addr = (char *) header + sizeof (struct grub_module_header);
+
+ dtb_size = header->size - sizeof (struct grub_module_header);
+ dtb = dtb_copy = grub_malloc (dtb_size);
+ grub_memmove (dtb_copy, dtb_orig_addr, dtb_size);
+ break;
+ }
+ if (!dtb)
+ grub_fatal ("No DTB found");
+ grub_fdtbus_init (dtb, dtb_size);
+
+ grub_rk3288_spi_init ();
+
+ grub_machine_timer_init ();
+ grub_cros_init ();
+ grub_pl050_init ();
+}
+
+void
+grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
+ char **path __attribute__ ((unused)))
+{
+}
+
+void
+grub_machine_fini (int flags __attribute__ ((unused)))
+{
+}
diff --git a/grub-core/kern/arm/coreboot/timer.c b/grub-core/kern/arm/coreboot/timer.c
new file mode 100644
index 0000000..d97b844
--- /dev/null
+++ b/grub-core/kern/arm/coreboot/timer.c
@@ -0,0 +1,101 @@
+/*
+ * 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/mm.h>
+#include <grub/machine/kernel.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/time.h>
+#include <grub/fdtbus.h>
+#include <grub/misc.h>
+
+grub_uint64_t
+grub_armv7_get_timer_value(void);
+
+grub_uint32_t
+grub_armv7_get_timer_frequency(void);
+
+grub_uint32_t
+grub_arm_pfr1(void);
+
+static int have_timer = 0;
+static volatile grub_uint32_t *sp804_regs;
+
+static grub_uint64_t
+sp804_get_time_ms (void)
+{
+ static grub_uint32_t high, last_low;
+ grub_uint32_t low = ~sp804_regs[1];
+ if (last_low > low)
+ high++;
+ last_low = low;
+ return grub_divmod64 ((((grub_uint64_t) high) << 32) | low,
+ 1000, 0);
+}
+
+static grub_err_t
+sp804_attach(const struct grub_fdtbus_dev *dev)
+{
+ if (have_timer)
+ return GRUB_ERR_NONE;
+ sp804_regs = grub_fdtbus_map_reg (dev, 0, 0);
+ if (!grub_fdtbus_is_mapping_valid (sp804_regs))
+ return grub_error (GRUB_ERR_IO, "could not map sp804: %p", sp804_regs);
+ grub_install_get_time_ms (sp804_get_time_ms);
+ have_timer = 1;
+ return GRUB_ERR_NONE;
+}
+
+struct grub_fdtbus_driver sp804 =
+{
+ .compatible = "arm,sp804",
+ .attach = sp804_attach
+};
+
+static grub_uint32_t timer_frequency_in_khz;
+
+static grub_uint64_t
+generic_get_time_ms (void)
+{
+ return grub_divmod64 (grub_armv7_get_timer_value(), timer_frequency_in_khz, 0);
+}
+
+static int
+try_generic_timer (void)
+{
+ if (((grub_arm_pfr1 () >> 16) & 0xf) != 1)
+ return 0;
+ grub_printf ("freq = %x\n", grub_armv7_get_timer_frequency());
+ timer_frequency_in_khz = 0x016e3600 / 1000; //grub_armv7_get_timer_frequency() / 1000;
+ if (timer_frequency_in_khz == 0)
+ return 0;
+ grub_install_get_time_ms (generic_get_time_ms);
+ have_timer = 1;
+ return 1;
+}
+
+void
+grub_machine_timer_init (void)
+{
+ grub_fdtbus_register (&sp804);
+
+ if (!have_timer)
+ try_generic_timer ();
+ if (!have_timer)
+ grub_fatal ("No timer found");
+}
diff --git a/grub-core/kern/arm/dl.c b/grub-core/kern/arm/dl.c
new file mode 100644
index 0000000..eab9d17
--- /dev/null
+++ b/grub-core/kern/arm/dl.c
@@ -0,0 +1,280 @@
+/* dl.c - arch-dependent part of loadable module support */
+/*
+ * 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/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+#include <grub/arm/reloc.h>
+
+struct trampoline_arm
+{
+#define ARM_LOAD_IP 0xe59fc000
+#define ARM_BX 0xe12fff1c
+#define ARM_MOV_PC 0xe1a0f00c
+ grub_uint32_t load_ip; /* ldr ip, [pc] */
+ grub_uint32_t bx; /* bx ip or mov pc, ip*/
+ grub_uint32_t addr;
+};
+
+static grub_uint16_t thumb_template[8] =
+ {
+ 0x468c, /* mov ip, r1 */
+ 0x4903, /* ldr r1, [pc, #12] ; (10 <.text+0x10>) */
+ /* Exchange R1 and IP in limited Thumb instruction set.
+ IP gets negated but we compensate it by C code. */
+ /* R1 IP */
+ /* -A R1 */
+ 0x4461, /* add r1, ip */ /* R1-A R1 */
+ 0x4249, /* negs r1, r1 */ /* A-R1 R1 */
+ 0x448c, /* add ip, r1 */ /* A-R1 A */
+ 0x4249, /* negs r1, r1 */ /* R1-A A */
+ 0x4461, /* add r1, ip */ /* R1 A */
+ 0x4760 /* bx ip */
+ };
+
+struct trampoline_thumb
+{
+ grub_uint16_t template[8];
+ grub_uint32_t neg_addr;
+};
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+grub_err_t
+grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
+ grub_size_t *got)
+{
+ const Elf_Ehdr *e = ehdr;
+ const Elf_Shdr *s;
+ unsigned i;
+
+ *tramp = 0;
+ *got = 0;
+
+ for (i = 0, s = (const Elf_Shdr *) ((grub_addr_t) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (const Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize))
+ if (s->sh_type == SHT_REL)
+ {
+ const Elf_Rel *rel, *max;
+
+ for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset),
+ 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:
+ case R_ARM_JUMP24:
+ {
+ *tramp += sizeof (struct trampoline_arm);
+ break;
+ }
+ case R_ARM_THM_CALL:
+ case R_ARM_THM_JUMP24:
+ case R_ARM_THM_JUMP19:
+ {
+ *tramp += sizeof (struct trampoline_thumb);
+ break;
+ }
+ }
+ }
+
+ grub_dprintf ("dl", "trampoline size %x\n", *tramp);
+
+ return GRUB_ERR_NONE;
+}
+
+/*************************************************
+ * Runtime dynamic linker with helper functions. *
+ *************************************************/
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ Elf_Rel *rel, *max;
+
+ for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
+ max = (Elf_Rel *) ((char *) rel + s->sh_size);
+ rel < max;
+ rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
+ {
+ Elf_Addr *target, sym_addr;
+ grub_err_t retval;
+ Elf_Sym *sym;
+
+ if (seg->size < rel->r_offset)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+ target = (void *) ((char *) seg->addr + rel->r_offset);
+ sym = (Elf_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel->r_info));
+
+ sym_addr = sym->st_value;
+
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case R_ARM_ABS32:
+ {
+ /* Data will be naturally aligned */
+ retval = grub_arm_reloc_abs32 (target, sym_addr);
+ if (retval != GRUB_ERR_NONE)
+ return retval;
+ }
+ break;
+ case R_ARM_CALL:
+ case R_ARM_JUMP24:
+ {
+ grub_int32_t offset;
+
+ sym_addr += grub_arm_jump24_get_offset (target);
+ offset = sym_addr - (grub_uint32_t) target;
+
+ if ((sym_addr & 1) || !grub_arm_jump24_check_offset (offset))
+ {
+ struct trampoline_arm *tp = mod->trampptr;
+ mod->trampptr = tp + 1;
+ tp->load_ip = ARM_LOAD_IP;
+ tp->bx = (sym_addr & 1) ? ARM_BX : ARM_MOV_PC;
+ tp->addr = sym_addr + 8;
+ offset = (grub_uint8_t *) tp - (grub_uint8_t *) target - 8;
+ }
+ if (!grub_arm_jump24_check_offset (offset))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "trampoline out of range");
+ grub_arm_jump24_set_offset (target, offset);
+ }
+ break;
+ case R_ARM_THM_CALL:
+ case R_ARM_THM_JUMP24:
+ {
+ /* Thumb instructions can be 16-bit aligned */
+ grub_int32_t offset;
+
+ sym_addr += grub_arm_thm_call_get_offset ((grub_uint16_t *) target);
+
+ grub_dprintf ("dl", " sym_addr = 0x%08x\n", sym_addr);
+ if (ELF_ST_TYPE (sym->st_info) != STT_FUNC)
+ sym_addr |= 1;
+
+ offset = sym_addr - (grub_uint32_t) target;
+
+ grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n",
+ target, sym_addr, offset);
+
+ if (!(sym_addr & 1) || (offset < -0x200000 || offset >= 0x200000))
+ {
+ struct trampoline_thumb *tp = mod->trampptr;
+ mod->trampptr = tp + 1;
+ grub_memcpy (tp->template, thumb_template, sizeof (tp->template));
+ tp->neg_addr = -sym_addr - 4;
+ offset = ((grub_uint8_t *) tp - (grub_uint8_t *) target - 4) | 1;
+ }
+
+ if (offset < -0x200000 || offset >= 0x200000)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "trampoline out of range");
+
+ grub_dprintf ("dl", " relative destination = %p\n",
+ (char *) target + offset);
+
+ retval = grub_arm_thm_call_set_offset ((grub_uint16_t *) target, offset);
+ if (retval != GRUB_ERR_NONE)
+ return retval;
+ }
+ break;
+ /* Happens when compiled with -march=armv4. Since currently we need
+ at least armv5, keep bx as-is.
+ */
+ case R_ARM_V4BX:
+ break;
+ case R_ARM_THM_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 */
+ grub_int32_t offset;
+
+ sym_addr += grub_arm_thm_jump19_get_offset ((grub_uint16_t *) target);
+
+ if (ELF_ST_TYPE (sym->st_info) != STT_FUNC)
+ sym_addr |= 1;
+
+ offset = sym_addr - (grub_uint32_t) target;
+
+ if (!grub_arm_thm_jump19_check_offset (offset)
+ || !(sym_addr & 1))
+ {
+ struct trampoline_thumb *tp = mod->trampptr;
+ mod->trampptr = tp + 1;
+ grub_memcpy (tp->template, thumb_template, sizeof (tp->template));
+ tp->neg_addr = -sym_addr - 4;
+ offset = ((grub_uint8_t *) tp - (grub_uint8_t *) target - 4) | 1;
+ }
+
+ if (!grub_arm_thm_jump19_check_offset (offset))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "trampoline out of range");
+
+ grub_arm_thm_jump19_set_offset ((grub_uint16_t *) target, offset);
+ }
+ break;
+ default:
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%x is not implemented yet"),
+ ELF_R_TYPE (rel->r_info));
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+
+/*
+ * Check if EHDR is a valid ELF header.
+ */
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ Elf_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+ if (e->e_ident[EI_CLASS] != ELFCLASS32
+ || e->e_ident[EI_DATA] != ELFDATA2LSB || e->e_machine != EM_ARM)
+ return grub_error (GRUB_ERR_BAD_OS,
+ N_("invalid arch-dependent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/arm/dl_helper.c b/grub-core/kern/arm/dl_helper.c
new file mode 100644
index 0000000..21d77f7
--- /dev/null
+++ b/grub-core/kern/arm/dl_helper.c
@@ -0,0 +1,245 @@
+/* dl.c - arch-dependent part of loadable module support */
+/*
+ * 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/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#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
+ *
+ * Simple relocation of 32-bit value (in literal pool)
+ */
+grub_err_t
+grub_arm_reloc_abs32 (Elf32_Word *target, Elf32_Addr sym_addr)
+{
+ Elf32_Addr tmp;
+
+ tmp = grub_le_to_cpu32 (*target);
+ tmp += sym_addr;
+ *target = grub_cpu_to_le32 (tmp);
+
+ return GRUB_ERR_NONE;
+}
+
+/********************************************************************
+ * Thumb (T32) relocations: *
+ * *
+ * 32-bit Thumb instructions can be 16-bit aligned, and are fetched *
+ * little-endian, requiring some additional fiddling. *
+ ********************************************************************/
+
+grub_int32_t
+grub_arm_thm_call_get_offset (grub_uint16_t *target)
+{
+ grub_uint32_t sign, j1, j2;
+ grub_uint32_t insword;
+ grub_int32_t offset;
+
+ insword = thumb_get_instruction_word (target);
+
+ /* Extract bitfields from instruction words */
+ sign = (insword >> 26) & 1;
+ j1 = (insword >> 13) & 1;
+ j2 = (insword >> 11) & 1;
+ offset = (sign << 24) | ((~(j1 ^ sign) & 1) << 23) |
+ ((~(j2 ^ sign) & 1) << 22) |
+ ((insword & 0x03ff0000) >> 4) | ((insword & 0x000007ff) << 1);
+
+ /* Sign adjust and calculate offset */
+ if (offset & (1 << 24))
+ offset -= (1 << 25);
+
+ return offset;
+}
+
+grub_err_t
+grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset)
+{
+ grub_uint32_t sign, j1, j2;
+ const grub_uint32_t insmask = 0xf800d000;
+ grub_uint32_t insword;
+ int is_blx;
+
+ insword = thumb_get_instruction_word (target);
+
+ if (((insword >> 12) & 0xd) == 0xc)
+ is_blx = 1;
+ else
+ is_blx = 0;
+
+ if (!is_blx && !(offset & 1))
+ return grub_error (GRUB_ERR_BAD_MODULE, "bl/b.w targettting ARM");
+
+ /* Transform blx into bl if necessarry. */
+ if (is_blx && (offset & 1))
+ insword |= (1 << 12);
+
+ /* Reassemble instruction word */
+ sign = (offset >> 24) & 1;
+ j1 = sign ^ (~(offset >> 23) & 1);
+ j2 = sign ^ (~(offset >> 22) & 1);
+ insword = (insword & insmask) |
+ (sign << 26) |
+ (((offset >> 12) & 0x03ff) << 16) |
+ (j1 << 13) | (j2 << 11) | ((offset >> 1) & 0x07ff);
+
+ thumb_set_instruction_word (target, insword);
+
+ grub_dprintf ("dl", " *insword = 0x%08x", insword);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_int32_t
+grub_arm_thm_jump19_get_offset (grub_uint16_t *target)
+{
+ grub_int32_t offset;
+ grub_uint32_t insword;
+
+ insword = thumb_get_instruction_word (target);
+
+ /* Extract and sign extend offset */
+ offset = ((insword >> 26) & 1) << 19
+ | ((insword >> 11) & 1) << 18
+ | ((insword >> 13) & 1) << 17
+ | ((insword >> 16) & 0x3f) << 11
+ | (insword & 0x7ff);
+ offset <<= 1;
+ if (offset & (1 << 20))
+ offset -= (1 << 21);
+
+ return offset;
+}
+
+void
+grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset)
+{
+ grub_uint32_t insword;
+ const grub_uint32_t insmask = 0xfbc0d000;
+
+ offset >>= 1;
+ offset &= 0xfffff;
+
+ insword = thumb_get_instruction_word (target);
+
+ /* Reassemble instruction word and write back */
+ insword &= insmask;
+ insword |= ((offset >> 19) & 1) << 26
+ | ((offset >> 18) & 1) << 11
+ | ((offset >> 17) & 1) << 13
+ | ((offset >> 11) & 0x3f) << 16
+ | (offset & 0x7ff);
+ thumb_set_instruction_word (target, insword);
+}
+
+int
+grub_arm_thm_jump19_check_offset (grub_int32_t offset)
+{
+ if ((offset > 1048574) || (offset < -1048576))
+ return 0;
+ 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: *
+ * *
+ * ARM instructions are 32-bit in size and 32-bit aligned. *
+ ***********************************************************/
+
+grub_int32_t
+grub_arm_jump24_get_offset (grub_uint32_t *target)
+{
+ grub_int32_t offset;
+ grub_uint32_t insword;
+
+ insword = grub_le_to_cpu32 (*target);
+
+ offset = (insword & 0x00ffffff) << 2;
+ if (offset & 0x02000000)
+ offset -= 0x04000000;
+ return offset;
+}
+
+int
+grub_arm_jump24_check_offset (grub_int32_t offset)
+{
+ if (offset >= 0x02000000 || offset < -0x02000000)
+ return 0;
+ return 1;
+}
+
+void
+grub_arm_jump24_set_offset (grub_uint32_t *target,
+ grub_int32_t offset)
+{
+ grub_uint32_t insword;
+
+ insword = grub_le_to_cpu32 (*target);
+
+ insword &= 0xff000000;
+ insword |= (offset >> 2) & 0x00ffffff;
+
+ *target = grub_cpu_to_le32 (insword);
+}
diff --git a/grub-core/kern/arm/efi/init.c b/grub-core/kern/arm/efi/init.c
new file mode 100644
index 0000000..40c3b46
--- /dev/null
+++ b/grub-core/kern/arm/efi/init.c
@@ -0,0 +1,77 @@
+/* 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 tmr;
+static grub_efi_event_t tmr_evt;
+
+static grub_uint64_t
+grub_efi_get_time_ms (void)
+{
+ return tmr;
+}
+
+static void
+increment_timer (grub_efi_event_t event __attribute__ ((unused)),
+ void *context __attribute__ ((unused)))
+{
+ tmr += 10;
+}
+
+void
+grub_machine_init (void)
+{
+ grub_efi_boot_services_t *b;
+
+ grub_efi_init ();
+
+ b = grub_efi_system_table->boot_services;
+
+ 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, 100000);
+
+ grub_install_get_time_ms (grub_efi_get_time_ms);
+}
+
+void
+grub_machine_fini (int flags)
+{
+ grub_efi_boot_services_t *b;
+
+ if (!(flags & GRUB_LOADER_FLAG_NORETURN))
+ return;
+
+ b = grub_efi_system_table->boot_services;
+
+ efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_CANCEL, 0);
+ efi_call_1 (b->close_event, tmr_evt);
+
+ grub_efi_fini ();
+
+ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY))
+ grub_efi_memory_fini ();
+}
diff --git a/grub-core/kern/arm/efi/startup.S b/grub-core/kern/arm/efi/startup.S
new file mode 100644
index 0000000..9f82653
--- /dev/null
+++ b/grub-core/kern/arm/efi/startup.S
@@ -0,0 +1,36 @@
+/*
+ * (C) Copyright 2013 Free Software Foundation
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#include <grub/symbol.h>
+
+ .file "startup.S"
+ .text
+ .arm
+FUNCTION(_start)
+ /*
+ * EFI_SYSTEM_TABLE and EFI_HANDLE are passed in r1/r0.
+ */
+ ldr ip, =EXT_C(grub_efi_image_handle)
+ str r0, [ip]
+ ldr ip, =EXT_C(grub_efi_system_table)
+ str r1, [ip]
+ ldr ip, =EXT_C(grub_main)
+ bx ip
+ END
diff --git a/grub-core/kern/arm/startup.S b/grub-core/kern/arm/startup.S
new file mode 100644
index 0000000..3946fe8
--- /dev/null
+++ b/grub-core/kern/arm/startup.S
@@ -0,0 +1,177 @@
+/*
+ * 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/offsets.h>
+#include <grub/symbol.h>
+#include <grub/machine/kernel.h>
+
+/*
+ * GRUB is called from U-Boot as a Linux Kernel type image, which
+ * means among other things that it always enters in ARM state.
+ *
+ * coreboot starts in ARM mode as well.
+ *
+ * Overview of GRUB image layout:
+ *
+ * _start:
+ * Entry point (1 ARM branch instruction, to "codestart")
+ * grub_total_module_size:
+ * Data field: Size of included module blob
+ * (when generated by grub-mkimage)
+ * codestart:
+ * Remainder of statically-linked executable code and data.
+ * __bss_start:
+ * Start of included module blob.
+ * Also where global/static variables are located.
+ * _end:
+ * End of bss region (but not necessarily module blob).
+ * <stack>:
+ * <modules>:
+ * Loadable modules, post relocation.
+ * <heap>:
+ */
+
+ .text
+ .arm
+FUNCTION(_start)
+ b codestart
+
+ @ Size of final image integrated module blob - set by grub-mkimage
+ .org _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
+VARIABLE(grub_total_module_size)
+ .long 0
+
+VARIABLE(grub_modbase)
+ .long 0
+bss_start_ptr:
+ .long EXT_C(__bss_start)
+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 {r0-r12,lr} @ store U-Boot context (sp in r12)
+
+ adr r1, _start
+ ldr r0, bss_start_ptr @ src
+ add r0, r0, r1
+
+ 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
+ add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
+ mvn r1, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
+ 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
+
+ str r1, EXT_C(grub_modbase)
+
+ /* Coreboot already places modules at right place. */
+#ifndef GRUB_MACHINE_COREBOOT
+ add r1, r1, r2
+ add r0, r0, r2
+ sub r1, r1, #4
+ sub r0, r0, #4
+
+1: ldr r3, [r0], #-4 @ r3 = *src--
+ str r3, [r1], #-4 @ *dst-- = r3
+ subs r2, #4 @ remaining -= 4
+ bne 1b @ while remaining != 0
+#endif
+
+ @ Since we _are_ the C run-time, we need to manually zero the BSS
+ @ region before continuing
+ ldr r0, bss_start_ptr @ zero from here
+ @ If unaligned, bytewise zero until base address aligned.
+ mov r2, #0
+1: tst r0, #3
+ beq 2f
+ strb r2, [r0], #1
+ b 1b
+2: ldr r1, end_ptr @ to here
+1: str r2, [r0], #4
+ cmp r0, r1
+ bne 1b
+
+ b EXT_C(grub_main)
+
+ .align 3
+@ U-boot/coreboot context stack space
+VARIABLE(grub_arm_saved_registers)
+ .long 0 @ r0
+ .long 0 @ r1
+ .long 0 @ r2
+ .long 0 @ r3
+ .long 0 @ r4
+ .long 0 @ r5
+ .long 0 @ r6
+ .long 0 @ r7
+ .long 0 @ r8
+ .long 0 @ r9
+ .long 0 @ r10
+ .long 0 @ r11
+ .long 0 @ sp
+ .long 0 @ lr
+entry_state:
diff --git a/grub-core/kern/arm/uboot/init.c b/grub-core/kern/arm/uboot/init.c
new file mode 100644
index 0000000..2a6aa3f
--- /dev/null
+++ b/grub-core/kern/arm/uboot/init.c
@@ -0,0 +1,70 @@
+/* init.c - generic U-Boot initialization and finalization */
+/*
+ * 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/uboot/uboot.h>
+#include <grub/arm/startup.h>
+#include <grub/uboot/api_public.h>
+
+extern int (*grub_uboot_syscall_ptr) (int, int *, ...);
+
+grub_uint32_t
+grub_uboot_get_machine_type (void)
+{
+ return grub_arm_saved_registers.r[1];
+}
+
+grub_addr_t
+grub_uboot_get_boot_data (void)
+{
+ return grub_arm_saved_registers.r[2];
+}
+
+int
+grub_uboot_api_init (void)
+{
+ struct api_signature *start, *end;
+ struct api_signature *p;
+ grub_addr_t grub_uboot_search_hint = grub_arm_saved_registers.sp;
+ if (grub_uboot_search_hint)
+ {
+ /* Extended search range to work around Trim Slice U-Boot issue */
+ start = (struct api_signature *) ((grub_uboot_search_hint & ~0x000fffff)
+ - 0x00500000);
+ end =
+ (struct api_signature *) ((grub_addr_t) start + UBOOT_API_SEARCH_LEN -
+ API_SIG_MAGLEN + 0x00500000);
+ }
+ else
+ {
+ start = 0;
+ end = (struct api_signature *) (256 * 1024 * 1024);
+ }
+
+ /* Structure alignment is (at least) 8 bytes */
+ for (p = start; p < end; p = (void *) ((grub_addr_t) p + 8))
+ {
+ if (grub_memcmp (&(p->magic), API_SIG_MAGIC, API_SIG_MAGLEN) == 0)
+ {
+ grub_uboot_syscall_ptr = p->syscall;
+ return p->version;
+ }
+ }
+
+ return 0;
+}
diff --git a/grub-core/kern/arm/uboot/uboot.S b/grub-core/kern/arm/uboot/uboot.S
new file mode 100644
index 0000000..d128775
--- /dev/null
+++ b/grub-core/kern/arm/uboot/uboot.S
@@ -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/offsets.h>
+#include <grub/symbol.h>
+#include <grub/machine/kernel.h>
+
+ /*
+ * uboot_syscall():
+ * This function is effectively a veneer, so it cannot
+ * modify the stack or corrupt any registers other than
+ * r12 (ip). Furthermore it needs to restore r8 for
+ * U-Boot (Global Data Pointer) and preserve it for Grub.
+ */
+FUNCTION(grub_uboot_syscall)
+ str r8, transition_space
+ str lr, transition_space + 4
+ str r9, transition_space + 8
+
+ ldr ip, saved_registers_ptr
+ ldr r8, [ip, #4 * 8]
+ ldr r9, [ip, #4 * 9]
+
+ bl do_syscall
+
+ ldr r8, transition_space
+ ldr lr, transition_space + 4
+ ldr r9, transition_space + 8
+
+ bx lr
+do_syscall:
+
+ ldr ip, grub_uboot_syscall_ptr
+ bx ip
+
+FUNCTION(grub_uboot_return)
+ ldr ip, saved_registers_ptr
+ ldr sp, [ip, #4 * 4]
+ pop {r4-r12, lr}
+ mov sp, r12
+ bx lr
+
+
+ .align 3
+
+@ GRUB context stack space
+transition_space:
+ .long 0 @ r8
+ .long 0 @ lr
+ .long 0 @ r9
+
+saved_registers_ptr:
+ .long EXT_C(grub_arm_saved_registers)
+
+VARIABLE(grub_uboot_syscall_ptr)
+ .long 0 @
+
+ END
diff --git a/grub-core/kern/arm64/cache.c b/grub-core/kern/arm64/cache.c
new file mode 100644
index 0000000..b84383d
--- /dev/null
+++ b/grub-core/kern/arm64/cache.c
@@ -0,0 +1,63 @@
+/*
+ * 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/cache.h>
+#include <grub/misc.h>
+
+static grub_int64_t dlinesz;
+static grub_int64_t ilinesz;
+
+/* Prototypes for asm functions. */
+void grub_arch_clean_dcache_range (grub_addr_t beg, grub_addr_t end,
+ grub_uint64_t line_size);
+void grub_arch_invalidate_icache_range (grub_addr_t beg, grub_addr_t end,
+ grub_uint64_t line_size);
+
+static void
+probe_caches (void)
+{
+ grub_uint64_t cache_type;
+
+ /* Read Cache Type Register */
+ asm volatile ("mrs %0, ctr_el0": "=r"(cache_type));
+
+ dlinesz = 4 << ((cache_type >> 16) & 0xf);
+ ilinesz = 4 << (cache_type & 0xf);
+
+ grub_dprintf("cache", "D$ line size: %lld\n", (long long) dlinesz);
+ grub_dprintf("cache", "I$ line size: %lld\n", (long long) ilinesz);
+}
+
+void
+grub_arch_sync_caches (void *address, grub_size_t len)
+{
+ grub_uint64_t start, end, max_align;
+
+ if (dlinesz == 0)
+ probe_caches();
+ if (dlinesz == 0)
+ grub_fatal ("Unknown cache line size!");
+
+ max_align = dlinesz > ilinesz ? dlinesz : ilinesz;
+
+ start = ALIGN_DOWN ((grub_uint64_t) address, max_align);
+ end = ALIGN_UP ((grub_uint64_t) address + len, max_align);
+
+ grub_arch_clean_dcache_range (start, end, dlinesz);
+ grub_arch_invalidate_icache_range (start, end, ilinesz);
+}
diff --git a/grub-core/kern/arm64/cache_flush.S b/grub-core/kern/arm64/cache_flush.S
new file mode 100644
index 0000000..e064f7e
--- /dev/null
+++ b/grub-core/kern/arm64/cache_flush.S
@@ -0,0 +1,55 @@
+/*
+ * 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/symbol.h>
+
+ .file "cache_flush.S"
+ .text
+
+/*
+ * Simple cache maintenance functions
+ */
+
+// x0 - *beg (inclusive)
+// x1 - *end (exclusive)
+// x2 - line size
+FUNCTION(grub_arch_clean_dcache_range)
+ // Clean data cache for range to point-of-unification
+1: cmp x0, x1
+ b.ge 2f
+ dc cvau, x0 // Clean Virtual Address to PoU
+ add x0, x0, x2 // Next line
+ b 1b
+2: dsb ish
+ isb
+ ret
+
+// x0 - *beg (inclusive)
+// x1 - *end (exclusive)
+// x2 - line size
+FUNCTION(grub_arch_invalidate_icache_range)
+ // Invalidate instruction cache for range to point-of-unification
+1: cmp x0, x1
+ b.ge 2f
+ ic ivau, x0 // Invalidate Virtual Address to PoU
+ add x0, x0, x2 // Next line
+ b 1b
+ // Branch predictor invalidation not needed on AArch64
+2: dsb ish
+ isb
+ ret
diff --git a/grub-core/kern/arm64/dl.c b/grub-core/kern/arm64/dl.c
new file mode 100644
index 0000000..512e5a8
--- /dev/null
+++ b/grub-core/kern/arm64/dl.c
@@ -0,0 +1,198 @@
+/* dl.c - arch-dependent part of loadable module support */
+/*
+ * 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/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+#include <grub/cpu/reloc.h>
+
+#define LDR 0x58000050
+#define BR 0xd61f0200
+
+
+/*
+ * Check if EHDR is a valid ELF header.
+ */
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ Elf_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+ if (e->e_ident[EI_CLASS] != ELFCLASS64
+ || e->e_ident[EI_DATA] != ELFDATA2LSB || e->e_machine != EM_AARCH64)
+ return grub_error (GRUB_ERR_BAD_OS,
+ N_("invalid arch-dependent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+/*
+ * Unified function for both REL and RELA
+ */
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ Elf_Rel *rel, *max;
+ unsigned unmatched_adr_got_page = 0;
+
+ for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
+ max = (Elf_Rel *) ((char *) rel + s->sh_size);
+ rel < max;
+ rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
+ {
+ Elf_Sym *sym;
+ void *place;
+ grub_uint64_t sym_addr;
+
+ if (rel->r_offset >= seg->size)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ sym = (Elf_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel->r_info));
+
+ sym_addr = sym->st_value;
+ if (s->sh_type == SHT_RELA)
+ sym_addr += ((Elf_Rela *) rel)->r_addend;
+
+ place = (void *) ((grub_addr_t) seg->addr + rel->r_offset);
+
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case R_AARCH64_ABS64:
+ {
+ grub_uint64_t *abs_place = place;
+
+ grub_dprintf ("dl", " reloc_abs64 %p => 0x%016llx\n",
+ place, (unsigned long long) sym_addr);
+
+ *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:
+ {
+ grub_int64_t offset = sym_addr - (grub_uint64_t) place;
+
+ if (!grub_arm_64_check_xxxx26_offset (offset))
+ {
+ struct grub_arm64_trampoline *tp = mod->trampptr;
+ mod->trampptr = tp + 1;
+ tp->ldr = LDR;
+ tp->br = BR;
+ tp->addr = sym_addr;
+ offset = (grub_uint8_t *) tp - (grub_uint8_t *) place;
+ }
+
+ if (!grub_arm_64_check_xxxx26_offset (offset))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "trampoline out of range");
+
+ grub_arm64_set_xxxx26_offset (place, offset);
+ }
+ break;
+ case R_AARCH64_PREL32:
+ {
+ grub_int64_t value;
+ Elf64_Word *addr32 = place;
+ value = ((grub_int32_t) *addr32) + sym_addr -
+ (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");
+ grub_dprintf("dl", " reloc_prel32 %p => 0x%016llx\n",
+ place, (unsigned long long) sym_addr);
+ *addr32 = value;
+ }
+ break;
+ case R_AARCH64_ADR_GOT_PAGE:
+ {
+ grub_uint64_t *gp = mod->gotptr;
+ Elf_Rela *rel2;
+ grub_int64_t gpoffset = ((grub_uint64_t) gp & ~0xfffULL) - (((grub_uint64_t) place) & ~0xfffULL);
+ *gp = (grub_uint64_t) sym_addr;
+ mod->gotptr = gp + 1;
+ unmatched_adr_got_page++;
+ grub_dprintf("dl", " reloc_got %p => 0x%016llx (0x%016llx)\n",
+ place, (unsigned long long) sym_addr, (unsigned long long) gp);
+ if (!grub_arm64_check_hi21_signed (gpoffset))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "HI21 out of range");
+ grub_arm64_set_hi21(place, gpoffset);
+ for (rel2 = (Elf_Rela *) ((char *) rel + s->sh_entsize);
+ rel2 < (Elf_Rela *) max;
+ rel2 = (Elf_Rela *) ((char *) rel2 + s->sh_entsize))
+ if (ELF_R_SYM (rel2->r_info)
+ == ELF_R_SYM (rel->r_info)
+ && ((Elf_Rela *) rel)->r_addend == rel2->r_addend
+ && ELF_R_TYPE (rel2->r_info) == R_AARCH64_LD64_GOT_LO12_NC)
+ {
+ grub_arm64_set_abs_lo12_ldst64 ((void *) ((grub_addr_t) seg->addr + rel2->r_offset),
+ (grub_uint64_t)gp);
+ break;
+ }
+ if (rel2 >= (Elf_Rela *) max)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "ADR_GOT_PAGE without matching LD64_GOT_LO12_NC");
+ }
+ break;
+ case R_AARCH64_LD64_GOT_LO12_NC:
+ if (unmatched_adr_got_page == 0)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "LD64_GOT_LO12_NC without matching ADR_GOT_PAGE");
+ unmatched_adr_got_page--;
+ 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:
+ {
+ char rel_info[17]; /* log16(2^64) = 16, plus NUL. */
+
+ grub_snprintf (rel_info, sizeof (rel_info) - 1, "%" PRIxGRUB_UINT64_T,
+ ELF_R_TYPE (rel->r_info));
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%s is not implemented yet"), rel_info);
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/arm64/dl_helper.c b/grub-core/kern/arm64/dl_helper.c
new file mode 100644
index 0000000..e00c198
--- /dev/null
+++ b/grub-core/kern/arm64/dl_helper.c
@@ -0,0 +1,134 @@
+/* dl_helper.c - relocation helper functions for modules and grub-mkimage */
+/*
+ * 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/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+#include <grub/arm64/reloc.h>
+
+/*
+ * grub_arm64_reloc_xxxx26():
+ *
+ * JUMP26/CALL26 relocations for B and BL instructions.
+ */
+
+int
+grub_arm_64_check_xxxx26_offset (grub_int64_t offset)
+{
+ const grub_ssize_t offset_low = -(1 << 27), offset_high = (1 << 27) - 1;
+
+ if ((offset < offset_low) || (offset > offset_high))
+ return 0;
+ return 1;
+}
+
+void
+grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset)
+{
+ const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfc000000);
+
+ grub_dprintf ("dl", " reloc_xxxx64 %p %c= 0x%llx\n",
+ place, offset > 0 ? '+' : '-',
+ offset < 0 ? (long long) -(unsigned long long) offset : 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;
+}
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+grub_err_t
+grub_arm64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
+ grub_size_t *got)
+{
+ const Elf64_Ehdr *e = ehdr;
+ const Elf64_Shdr *s;
+ unsigned i;
+
+ *tramp = 0;
+ *got = 0;
+
+ for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu64 (e->e_shoff));
+ i < grub_le_to_cpu16 (e->e_shnum);
+ i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize)))
+ if (s->sh_type == grub_cpu_to_le32_compile_time (SHT_REL)
+ || s->sh_type == grub_cpu_to_le32_compile_time (SHT_RELA))
+ {
+ const Elf64_Rela *rel, *max;
+
+ for (rel = (Elf64_Rela *) ((char *) e + grub_le_to_cpu64 (s->sh_offset)),
+ max = (const Elf64_Rela *) ((char *) rel + grub_le_to_cpu64 (s->sh_size));
+ rel < max; rel = (const Elf64_Rela *) ((char *) rel + grub_le_to_cpu64 (s->sh_entsize)))
+ switch (ELF64_R_TYPE (rel->r_info))
+ {
+ case R_AARCH64_CALL26:
+ case R_AARCH64_JUMP26:
+ *tramp += sizeof (struct grub_arm64_trampoline);
+ break;
+ case R_AARCH64_ADR_GOT_PAGE:
+ *got += 8;
+ break;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/arm64/efi/init.c b/grub-core/kern/arm64/efi/init.c
new file mode 100644
index 0000000..5010cae
--- /dev/null
+++ b/grub-core/kern/arm64/efi/init.c
@@ -0,0 +1,63 @@
+/* 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 ();
+
+ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY))
+ grub_efi_memory_fini ();
+}
diff --git a/grub-core/kern/arm64/efi/startup.S b/grub-core/kern/arm64/efi/startup.S
new file mode 100644
index 0000000..666a7ee
--- /dev/null
+++ b/grub-core/kern/arm64/efi/startup.S
@@ -0,0 +1,39 @@
+/*
+ * 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/symbol.h>
+
+ .file "startup.S"
+ .text
+FUNCTION(_start)
+ /*
+ * EFI_SYSTEM_TABLE and EFI_HANDLE are passed in x1/x0.
+ */
+ ldr x2, efi_image_handle_val
+ str x0, [x2]
+ ldr x2, efi_system_table_val
+ str x1, [x2]
+ ldr x2, grub_main_val
+ br x2
+grub_main_val:
+ .quad EXT_C(grub_main)
+efi_system_table_val:
+ .quad EXT_C(grub_efi_system_table)
+efi_image_handle_val:
+ .quad EXT_C(grub_efi_image_handle)
+
diff --git a/grub-core/kern/buffer.c b/grub-core/kern/buffer.c
new file mode 100644
index 0000000..9f5f8b8
--- /dev/null
+++ b/grub-core/kern/buffer.c
@@ -0,0 +1,117 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2021 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/buffer.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/safemath.h>
+#include <grub/types.h>
+
+grub_buffer_t
+grub_buffer_new (grub_size_t sz)
+{
+ struct grub_buffer *ret;
+
+ ret = (struct grub_buffer *) grub_malloc (sizeof (*ret));
+ if (ret == NULL)
+ return NULL;
+
+ ret->data = (grub_uint8_t *) grub_malloc (sz);
+ if (ret->data == NULL)
+ {
+ grub_free (ret);
+ return NULL;
+ }
+
+ ret->sz = sz;
+ ret->pos = 0;
+ ret->used = 0;
+
+ return ret;
+}
+
+void
+grub_buffer_free (grub_buffer_t buf)
+{
+ grub_free (buf->data);
+ grub_free (buf);
+}
+
+grub_err_t
+grub_buffer_ensure_space (grub_buffer_t buf, grub_size_t req)
+{
+ grub_uint8_t *d;
+ grub_size_t newsz = 1;
+
+ /* Is the current buffer size adequate? */
+ if (buf->sz >= req)
+ return GRUB_ERR_NONE;
+
+ /* Find the smallest power-of-2 size that satisfies the request. */
+ while (newsz < req)
+ {
+ if (newsz == 0)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("requested buffer size is too large"));
+ newsz <<= 1;
+ }
+
+ d = (grub_uint8_t *) grub_realloc (buf->data, newsz);
+ if (d == NULL)
+ return grub_errno;
+
+ buf->data = d;
+ buf->sz = newsz;
+
+ return GRUB_ERR_NONE;
+}
+
+void *
+grub_buffer_take_data (grub_buffer_t buf)
+{
+ void *data = buf->data;
+
+ buf->data = NULL;
+ buf->sz = buf->pos = buf->used = 0;
+
+ return data;
+}
+
+void
+grub_buffer_reset (grub_buffer_t buf)
+{
+ buf->pos = buf->used = 0;
+}
+
+grub_err_t
+grub_buffer_advance_read_pos (grub_buffer_t buf, grub_size_t n)
+{
+ grub_size_t newpos;
+
+ if (grub_add (buf->pos, n, &newpos))
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+
+ if (newpos > buf->used)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("new read is position beyond the end of the written data"));
+
+ buf->pos = newpos;
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/command.c b/grub-core/kern/command.c
new file mode 100644
index 0000000..4aabcd4
--- /dev/null
+++ b/grub-core/kern/command.c
@@ -0,0 +1,111 @@
+/* command.c - support basic command */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/lockdown.h>
+#include <grub/mm.h>
+#include <grub/command.h>
+
+grub_command_t grub_command_list;
+
+grub_command_t
+grub_register_command_prio (const char *name,
+ grub_command_func_t func,
+ const char *summary,
+ const char *description,
+ int prio)
+{
+ grub_command_t cmd;
+ int inactive = 0;
+
+ grub_command_t *p, q;
+
+ cmd = (grub_command_t) grub_zalloc (sizeof (*cmd));
+ if (! cmd)
+ return 0;
+
+ cmd->name = name;
+ cmd->func = func;
+ cmd->summary = (summary) ? summary : "";
+ cmd->description = description;
+
+ cmd->flags = 0;
+ cmd->prio = prio;
+
+ for (p = &grub_command_list, q = *p; q; p = &(q->next), q = q->next)
+ {
+ int r;
+
+ r = grub_strcmp (cmd->name, q->name);
+ if (r < 0)
+ break;
+ if (r > 0)
+ continue;
+
+ if (cmd->prio >= (q->prio & GRUB_COMMAND_PRIO_MASK))
+ {
+ q->prio &= ~GRUB_COMMAND_FLAG_ACTIVE;
+ break;
+ }
+
+ inactive = 1;
+ }
+
+ *p = cmd;
+ cmd->next = q;
+ if (q)
+ q->prev = &cmd->next;
+ cmd->prev = p;
+
+ if (! inactive)
+ cmd->prio |= GRUB_COMMAND_FLAG_ACTIVE;
+
+ return cmd;
+}
+
+static grub_err_t
+grub_cmd_lockdown (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **argv __attribute__ ((unused)))
+
+{
+ return grub_error (GRUB_ERR_ACCESS_DENIED,
+ N_("%s: the command is not allowed when lockdown is enforced"),
+ cmd->name);
+}
+
+grub_command_t
+grub_register_command_lockdown (const char *name,
+ grub_command_func_t func,
+ const char *summary,
+ const char *description)
+{
+ if (grub_is_lockdown () == GRUB_LOCKDOWN_ENABLED)
+ func = grub_cmd_lockdown;
+
+ return grub_register_command_prio (name, func, summary, description, 0);
+}
+
+void
+grub_unregister_command (grub_command_t cmd)
+{
+ if ((cmd->prio & GRUB_COMMAND_FLAG_ACTIVE) && (cmd->next))
+ cmd->next->prio |= GRUB_COMMAND_FLAG_ACTIVE;
+ grub_list_remove (GRUB_AS_LIST (cmd));
+ grub_free (cmd);
+}
diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c
new file mode 100644
index 0000000..2057c2e
--- /dev/null
+++ b/grub-core/kern/compiler-rt.c
@@ -0,0 +1,464 @@
+/* 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__) || \
+ (defined(__riscv) && (__riscv_xlen == 32))
+
+/* 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__) || defined(__riscv)
+
+/* 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
+
+#if defined(__mips__) || defined(__riscv) || defined(__sparc__)
+/* Based on libgcc from gcc suite. */
+int
+__clzsi2 (grub_uint32_t val)
+{
+ int i = 32;
+ int j = 16;
+ int temp;
+
+ for (; j; j >>= 1)
+ {
+ if ((temp = val) >> j)
+ {
+ if (j == 1)
+ {
+ return (i - 2);
+ }
+ else
+ {
+ i -= j;
+ val = temp;
+ }
+ }
+ }
+ return (i - val);
+}
+#endif
+
+#if defined(__mips__) || defined(__riscv) || defined(__sparc__)
+int
+__clzdi2 (grub_uint64_t val)
+{
+ if (val >> 32)
+ {
+ return __clzsi2 (val >> 32);
+ }
+ else
+ {
+ return __clzsi2 (val) + 32;
+ }
+}
+#endif
diff --git a/grub-core/kern/coreboot/cbtable.c b/grub-core/kern/coreboot/cbtable.c
new file mode 100644
index 0000000..aec63db
--- /dev/null
+++ b/grub-core/kern/coreboot/cbtable.c
@@ -0,0 +1,72 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,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/i386/coreboot/memory.h>
+#include <grub/coreboot/lbio.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+/* Helper for grub_linuxbios_table_iterate. */
+int
+grub_linuxbios_check_signature (grub_linuxbios_table_header_t tbl_header)
+{
+ if (! grub_memcmp (tbl_header->signature, "LBIO", 4))
+ return 1;
+
+ return 0;
+}
+
+grub_err_t
+grub_linuxbios_table_iterate (int (*hook) (grub_linuxbios_table_item_t,
+ void *),
+ void *hook_data)
+{
+ grub_linuxbios_table_header_t table_header = grub_linuxbios_get_tables ();
+ grub_linuxbios_table_item_t table_item;
+
+ if (!table_header)
+ return 0;
+
+signature_found:
+
+ table_item =
+ (grub_linuxbios_table_item_t) ((char *) table_header +
+ table_header->header_size);
+ for (; table_item < (grub_linuxbios_table_item_t) ((char *) table_header
+ + table_header->header_size
+ + table_header->table_size);
+ table_item = (grub_linuxbios_table_item_t) ((char *) table_item + table_item->size))
+ {
+ if (table_item->tag == GRUB_LINUXBIOS_MEMBER_LINK
+ && grub_linuxbios_check_signature ((grub_linuxbios_table_header_t) (grub_addr_t)
+ *(grub_uint64_t *) (table_item + 1)))
+ {
+ table_header = (grub_linuxbios_table_header_t) (grub_addr_t)
+ *(grub_uint64_t *) (table_item + 1);
+ goto signature_found;
+ }
+ if (hook (table_item, hook_data))
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/grub-core/kern/coreboot/mmap.c b/grub-core/kern/coreboot/mmap.c
new file mode 100644
index 0000000..caf8f7c
--- /dev/null
+++ b/grub-core/kern/coreboot/mmap.c
@@ -0,0 +1,100 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,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/memory.h>
+#include <grub/coreboot/lbio.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+
+/* Context for grub_machine_mmap_iterate. */
+struct grub_machine_mmap_iterate_ctx
+{
+ grub_memory_hook_t hook;
+ void *hook_data;
+};
+
+#define GRUB_MACHINE_MEMORY_BADRAM 5
+
+/* Helper for grub_machine_mmap_iterate. */
+static int
+iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data)
+{
+ struct grub_machine_mmap_iterate_ctx *ctx = data;
+ mem_region_t mem_region;
+
+ if (table_item->tag != GRUB_LINUXBIOS_MEMBER_MEMORY)
+ return 0;
+
+ mem_region =
+ (mem_region_t) ((long) table_item +
+ sizeof (struct grub_linuxbios_table_item));
+ for (; (long) mem_region < (long) table_item + (long) table_item->size;
+ mem_region++)
+ {
+ grub_uint64_t start = mem_region->addr;
+ grub_uint64_t end = mem_region->addr + mem_region->size;
+#ifdef __i386__
+ /* 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;
+ }
+#endif
+ if (ctx->hook (start, end - start,
+ /* Multiboot mmaps match with the coreboot mmap
+ definition. Therefore, we can just pass type
+ through. */
+ mem_region->type,
+ ctx->hook_data))
+ return 1;
+ }
+
+ return 0;
+}
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ struct grub_machine_mmap_iterate_ctx ctx = { hook, hook_data };
+
+ grub_linuxbios_table_iterate (iterate_linuxbios_table, &ctx);
+
+ return 0;
+}
diff --git a/grub-core/kern/corecmd.c b/grub-core/kern/corecmd.c
new file mode 100644
index 0000000..fc54f43
--- /dev/null
+++ b/grub-core/kern/corecmd.c
@@ -0,0 +1,189 @@
+/* corecmd.c - critical commands which are registered in kernel */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/err.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/file.h>
+#include <grub/device.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+/* set ENVVAR=VALUE */
+static grub_err_t
+grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ char *var;
+ char *val;
+
+ if (argc < 1)
+ {
+ struct grub_env_var *env;
+ FOR_SORTED_ENV (env)
+ grub_printf ("%s=%s\n", env->name, grub_env_get (env->name));
+ return 0;
+ }
+
+ var = argv[0];
+ val = grub_strchr (var, '=');
+ if (! val)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "not an assignment");
+
+ val[0] = 0;
+ grub_env_set (var, val + 1);
+ val[0] = '=';
+
+ return 0;
+}
+
+static grub_err_t
+grub_core_cmd_unset (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("one argument expected"));
+
+ grub_env_unset (argv[0]);
+ return 0;
+}
+
+/* insmod MODULE */
+static grub_err_t
+grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_dl_t mod;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ if (argv[0][0] == '/' || argv[0][0] == '(' || argv[0][0] == '+')
+ mod = grub_dl_load_file (argv[0]);
+ else
+ mod = grub_dl_load (argv[0]);
+
+ if (mod)
+ grub_dl_ref (mod);
+
+ return 0;
+}
+
+static int
+grub_mini_print_devices (const char *name, void *data __attribute__ ((unused)))
+{
+ grub_printf ("(%s) ", name);
+
+ return 0;
+}
+
+static int
+grub_mini_print_files (const char *filename,
+ const struct grub_dirhook_info *info,
+ void *data __attribute__ ((unused)))
+{
+ grub_printf ("%s%s ", filename, info->dir ? "/" : "");
+
+ return 0;
+}
+
+/* ls [ARG] */
+static grub_err_t
+grub_core_cmd_ls (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ if (argc < 1)
+ {
+ grub_device_iterate (grub_mini_print_devices, NULL);
+ grub_xputs ("\n");
+ grub_refresh ();
+ }
+ else
+ {
+ char *device_name;
+ grub_device_t dev = 0;
+ grub_fs_t fs;
+ char *path;
+
+ device_name = grub_file_get_device_name (argv[0]);
+ if (grub_errno)
+ goto fail;
+ dev = grub_device_open (device_name);
+ if (! dev)
+ goto fail;
+
+ fs = grub_fs_probe (dev);
+ path = grub_strchr (argv[0], ')');
+ if (! path)
+ path = argv[0];
+ else
+ path++;
+
+ if (! *path && ! device_name)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
+ goto fail;
+ }
+
+ if (! *path)
+ {
+ if (grub_errno == GRUB_ERR_UNKNOWN_FS)
+ grub_errno = GRUB_ERR_NONE;
+
+ grub_printf ("(%s): Filesystem is %s.\n",
+ device_name, fs ? fs->name : "unknown");
+ }
+ else if (fs)
+ {
+ (fs->fs_dir) (dev, path, grub_mini_print_files, NULL);
+ grub_xputs ("\n");
+ grub_refresh ();
+ }
+
+ fail:
+ if (dev)
+ grub_device_close (dev);
+
+ grub_free (device_name);
+ }
+
+ return grub_errno;
+}
+
+void
+grub_register_core_commands (void)
+{
+ grub_command_t cmd;
+ cmd = grub_register_command ("set", grub_core_cmd_set,
+ N_("[ENVVAR=VALUE]"),
+ N_("Set an environment variable."));
+ if (cmd)
+ cmd->flags |= GRUB_COMMAND_FLAG_EXTRACTOR;
+ grub_register_command ("unset", grub_core_cmd_unset,
+ N_("ENVVAR"),
+ N_("Remove an environment variable."));
+ grub_register_command ("ls", grub_core_cmd_ls,
+ N_("[ARG]"), N_("List devices or files."));
+ grub_register_command ("insmod", grub_core_cmd_insmod,
+ N_("MODULE"), N_("Insert a module."));
+}
diff --git a/grub-core/kern/device.c b/grub-core/kern/device.c
new file mode 100644
index 0000000..73b8ecc
--- /dev/null
+++ b/grub-core/kern/device.c
@@ -0,0 +1,191 @@
+/* device.c - device manager */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/net.h>
+#include <grub/fs.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/partition.h>
+#include <grub/i18n.h>
+
+grub_net_t (*grub_net_open) (const char *name) = NULL;
+
+grub_device_t
+grub_device_open (const char *name)
+{
+ grub_device_t dev = 0;
+
+ if (! name)
+ {
+ name = grub_env_get ("root");
+ if (name == NULL || *name == '\0')
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, N_("variable `%s' isn't set"), "root");
+ goto fail;
+ }
+ }
+
+ dev = grub_malloc (sizeof (*dev));
+ if (! dev)
+ goto fail;
+
+ dev->net = NULL;
+ /* Try to open a disk. */
+ dev->disk = grub_disk_open (name);
+ if (dev->disk)
+ return dev;
+ if (grub_net_open && grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ dev->net = grub_net_open (name);
+ }
+
+ if (dev->net)
+ return dev;
+
+ fail:
+ grub_free (dev);
+
+ return 0;
+}
+
+grub_err_t
+grub_device_close (grub_device_t device)
+{
+ if (device->disk)
+ grub_disk_close (device->disk);
+
+ if (device->net)
+ {
+ grub_free (device->net->server);
+ grub_free (device->net);
+ }
+
+ grub_free (device);
+
+ return grub_errno;
+}
+
+struct part_ent
+{
+ struct part_ent *next;
+ char *name;
+};
+
+/* Context for grub_device_iterate. */
+struct grub_device_iterate_ctx
+{
+ grub_device_iterate_hook_t hook;
+ void *hook_data;
+ struct part_ent *ents;
+};
+
+/* Helper for grub_device_iterate. */
+static int
+iterate_partition (grub_disk_t disk, const grub_partition_t partition,
+ void *data)
+{
+ struct grub_device_iterate_ctx *ctx = data;
+ struct part_ent *p;
+ char *part_name;
+
+ p = grub_malloc (sizeof (*p));
+ if (!p)
+ {
+ return 1;
+ }
+
+ part_name = grub_partition_get_name (partition);
+ if (!part_name)
+ {
+ grub_free (p);
+ return 1;
+ }
+ p->name = grub_xasprintf ("%s,%s", disk->name, part_name);
+ grub_free (part_name);
+ if (!p->name)
+ {
+ grub_free (p);
+ return 1;
+ }
+
+ p->next = ctx->ents;
+ ctx->ents = p;
+
+ return 0;
+}
+
+/* Helper for grub_device_iterate. */
+static int
+iterate_disk (const char *disk_name, void *data)
+{
+ struct grub_device_iterate_ctx *ctx = data;
+ grub_device_t dev;
+
+ if (ctx->hook (disk_name, ctx->hook_data))
+ return 1;
+
+ dev = grub_device_open (disk_name);
+ if (! dev)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+
+ if (dev->disk)
+ {
+ struct part_ent *p;
+ int ret = 0;
+
+ ctx->ents = NULL;
+ (void) grub_partition_iterate (dev->disk, iterate_partition, ctx);
+ grub_device_close (dev);
+
+ grub_errno = GRUB_ERR_NONE;
+
+ p = ctx->ents;
+ while (p != NULL)
+ {
+ struct part_ent *next = p->next;
+
+ if (!ret)
+ ret = ctx->hook (p->name, ctx->hook_data);
+ grub_free (p->name);
+ grub_free (p);
+ p = next;
+ }
+
+ return ret;
+ }
+
+ grub_device_close (dev);
+ return 0;
+}
+
+int
+grub_device_iterate (grub_device_iterate_hook_t hook, void *hook_data)
+{
+ struct grub_device_iterate_ctx ctx = { hook, hook_data, NULL };
+
+ /* Only disk devices are supported at the moment. */
+ return grub_disk_dev_iterate (iterate_disk, &ctx);
+}
diff --git a/grub-core/kern/disk.c b/grub-core/kern/disk.c
new file mode 100644
index 0000000..e1b0e07
--- /dev/null
+++ b/grub-core/kern/disk.c
@@ -0,0 +1,544 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/disk.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/partition.h>
+#include <grub/misc.h>
+#include <grub/time.h>
+#include <grub/file.h>
+#include <grub/i18n.h>
+
+#define GRUB_CACHE_TIMEOUT 2
+
+/* The last time the disk was used. */
+static grub_uint64_t grub_last_time = 0;
+
+struct grub_disk_cache grub_disk_cache_table[GRUB_DISK_CACHE_NUM];
+
+void (*grub_disk_firmware_fini) (void);
+int grub_disk_firmware_is_tainted;
+
+#if DISK_CACHE_STATS
+static unsigned long grub_disk_cache_hits;
+static unsigned long grub_disk_cache_misses;
+
+void
+grub_disk_cache_get_performance (unsigned long *hits, unsigned long *misses)
+{
+ *hits = grub_disk_cache_hits;
+ *misses = grub_disk_cache_misses;
+}
+#endif
+
+grub_err_t (*grub_disk_write_weak) (grub_disk_t disk,
+ grub_disk_addr_t sector,
+ grub_off_t offset,
+ grub_size_t size,
+ const void *buf);
+#include "disk_common.c"
+
+void
+grub_disk_cache_invalidate_all (void)
+{
+ unsigned i;
+
+ for (i = 0; i < GRUB_DISK_CACHE_NUM; i++)
+ {
+ struct grub_disk_cache *cache = grub_disk_cache_table + i;
+
+ if (cache->data && ! cache->lock)
+ {
+ grub_free (cache->data);
+ cache->data = 0;
+ }
+ }
+}
+
+static char *
+grub_disk_cache_fetch (unsigned long dev_id, unsigned long disk_id,
+ grub_disk_addr_t sector)
+{
+ struct grub_disk_cache *cache;
+ unsigned cache_index;
+
+ cache_index = grub_disk_cache_get_index (dev_id, disk_id, sector);
+ cache = grub_disk_cache_table + cache_index;
+
+ if (cache->dev_id == dev_id && cache->disk_id == disk_id
+ && cache->sector == sector)
+ {
+ cache->lock = 1;
+#if DISK_CACHE_STATS
+ grub_disk_cache_hits++;
+#endif
+ return cache->data;
+ }
+
+#if DISK_CACHE_STATS
+ grub_disk_cache_misses++;
+#endif
+
+ return 0;
+}
+
+static void
+grub_disk_cache_unlock (unsigned long dev_id, unsigned long disk_id,
+ grub_disk_addr_t sector)
+{
+ struct grub_disk_cache *cache;
+ unsigned cache_index;
+
+ cache_index = grub_disk_cache_get_index (dev_id, disk_id, sector);
+ cache = grub_disk_cache_table + cache_index;
+
+ if (cache->dev_id == dev_id && cache->disk_id == disk_id
+ && cache->sector == sector)
+ cache->lock = 0;
+}
+
+static grub_err_t
+grub_disk_cache_store (unsigned long dev_id, unsigned long disk_id,
+ grub_disk_addr_t sector, const char *data)
+{
+ unsigned cache_index;
+ struct grub_disk_cache *cache;
+
+ cache_index = grub_disk_cache_get_index (dev_id, disk_id, sector);
+ cache = grub_disk_cache_table + cache_index;
+
+ cache->lock = 1;
+ grub_free (cache->data);
+ cache->data = 0;
+ cache->lock = 0;
+
+ cache->data = grub_malloc (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
+ if (! cache->data)
+ return grub_errno;
+
+ grub_memcpy (cache->data, data,
+ GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
+ cache->dev_id = dev_id;
+ cache->disk_id = disk_id;
+ cache->sector = sector;
+
+ return GRUB_ERR_NONE;
+}
+
+
+
+grub_disk_dev_t grub_disk_dev_list;
+
+void
+grub_disk_dev_register (grub_disk_dev_t dev)
+{
+ dev->next = grub_disk_dev_list;
+ grub_disk_dev_list = dev;
+}
+
+void
+grub_disk_dev_unregister (grub_disk_dev_t dev)
+{
+ grub_disk_dev_t *p, q;
+
+ for (p = &grub_disk_dev_list, q = *p; q; p = &(q->next), q = q->next)
+ if (q == dev)
+ {
+ *p = q->next;
+ break;
+ }
+}
+
+/* Return the location of the first ',', if any, which is not
+ escaped by a '\'. */
+static const char *
+find_part_sep (const char *name)
+{
+ const char *p = name;
+ char c;
+
+ while ((c = *p++) != '\0')
+ {
+ if (c == '\\' && *p == ',')
+ p++;
+ else if (c == ',')
+ return p - 1;
+ }
+ return NULL;
+}
+
+grub_disk_t
+grub_disk_open (const char *name)
+{
+ const char *p;
+ grub_disk_t disk;
+ grub_disk_dev_t dev;
+ char *raw = (char *) name;
+ grub_uint64_t current_time;
+
+ grub_dprintf ("disk", "Opening `%s'...\n", name);
+
+ disk = (grub_disk_t) grub_zalloc (sizeof (*disk));
+ if (! disk)
+ return 0;
+ disk->log_sector_size = GRUB_DISK_SECTOR_BITS;
+ /* Default 1MiB of maximum agglomerate. */
+ disk->max_agglomerate = 1048576 >> (GRUB_DISK_SECTOR_BITS
+ + GRUB_DISK_CACHE_BITS);
+
+ p = find_part_sep (name);
+ if (p)
+ {
+ grub_size_t len = p - name;
+
+ raw = grub_malloc (len + 1);
+ if (! raw)
+ goto fail;
+
+ grub_memcpy (raw, name, len);
+ raw[len] = '\0';
+ disk->name = grub_strdup (raw);
+ }
+ else
+ disk->name = grub_strdup (name);
+ if (! disk->name)
+ goto fail;
+
+ for (dev = grub_disk_dev_list; dev; dev = dev->next)
+ {
+ if ((dev->disk_open) (raw, disk) == GRUB_ERR_NONE)
+ break;
+ else if (grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
+ grub_errno = GRUB_ERR_NONE;
+ else
+ goto fail;
+ }
+
+ if (! dev)
+ {
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"),
+ name);
+ goto fail;
+ }
+ if (disk->log_sector_size > GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS
+ || disk->log_sector_size < GRUB_DISK_SECTOR_BITS)
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "sector sizes of %d bytes aren't supported yet",
+ (1 << disk->log_sector_size));
+ goto fail;
+ }
+
+ disk->dev = dev;
+
+ if (p)
+ {
+ disk->partition = grub_partition_probe (disk, p + 1);
+ if (! disk->partition)
+ {
+ /* TRANSLATORS: It means that the specified partition e.g.
+ hd0,msdos1=/dev/sda1 doesn't exist. */
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("no such partition"));
+ goto fail;
+ }
+ }
+
+ /* The cache will be invalidated about 2 seconds after a device was
+ closed. */
+ current_time = grub_get_time_ms ();
+
+ if (current_time > (grub_last_time
+ + GRUB_CACHE_TIMEOUT * 1000))
+ grub_disk_cache_invalidate_all ();
+
+ grub_last_time = current_time;
+
+ fail:
+
+ if (raw && raw != name)
+ grub_free (raw);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_error_push ();
+ grub_dprintf ("disk", "Opening `%s' failed.\n", name);
+ grub_error_pop ();
+
+ grub_disk_close (disk);
+ return 0;
+ }
+
+ return disk;
+}
+
+void
+grub_disk_close (grub_disk_t disk)
+{
+ grub_partition_t part;
+ grub_dprintf ("disk", "Closing `%s'.\n", disk->name);
+
+ if (disk->dev && disk->dev->disk_close)
+ (disk->dev->disk_close) (disk);
+
+ /* Reset the timer. */
+ grub_last_time = grub_get_time_ms ();
+
+ while (disk->partition)
+ {
+ part = disk->partition->parent;
+ grub_free (disk->partition);
+ disk->partition = part;
+ }
+ grub_free ((void *) disk->name);
+ grub_free (disk);
+}
+
+/* Small read (less than cache size and not pass across cache unit boundaries).
+ sector is already adjusted and is divisible by cache unit size.
+ */
+static grub_err_t
+grub_disk_read_small_real (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_off_t offset, grub_size_t size, void *buf)
+{
+ char *data;
+ char *tmp_buf;
+
+ /* Fetch the cache. */
+ data = grub_disk_cache_fetch (disk->dev->id, disk->id, sector);
+ if (data)
+ {
+ /* Just copy it! */
+ grub_memcpy (buf, data + offset, size);
+ grub_disk_cache_unlock (disk->dev->id, disk->id, sector);
+ return GRUB_ERR_NONE;
+ }
+
+ /* Allocate a temporary buffer. */
+ tmp_buf = grub_malloc (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
+ if (! tmp_buf)
+ return grub_errno;
+
+ /* Otherwise read data from the disk actually. */
+ if (disk->total_sectors == GRUB_DISK_SIZE_UNKNOWN
+ || sector + GRUB_DISK_CACHE_SIZE
+ < (disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)))
+ {
+ grub_err_t err;
+ err = (disk->dev->disk_read) (disk, transform_sector (disk, sector),
+ 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. */
+ grub_memcpy (buf, tmp_buf + offset, size);
+ grub_disk_cache_store (disk->dev->id, disk->id,
+ sector, tmp_buf);
+ grub_free (tmp_buf);
+ return GRUB_ERR_NONE;
+ }
+ }
+
+ grub_free (tmp_buf);
+ grub_errno = GRUB_ERR_NONE;
+
+ {
+ /* Uggh... Failed. Instead, just read necessary data. */
+ unsigned num;
+ grub_disk_addr_t aligned_sector;
+
+ sector += (offset >> GRUB_DISK_SECTOR_BITS);
+ offset &= ((1 << GRUB_DISK_SECTOR_BITS) - 1);
+ aligned_sector = (sector & ~((1ULL << (disk->log_sector_size
+ - GRUB_DISK_SECTOR_BITS))
+ - 1));
+ offset += ((sector - aligned_sector) << GRUB_DISK_SECTOR_BITS);
+ num = ((size + offset + (1ULL << (disk->log_sector_size))
+ - 1) >> (disk->log_sector_size));
+
+ tmp_buf = grub_malloc (num << disk->log_sector_size);
+ if (!tmp_buf)
+ return grub_errno;
+
+ if ((disk->dev->disk_read) (disk, transform_sector (disk, aligned_sector),
+ num, tmp_buf))
+ {
+ grub_error_push ();
+ grub_dprintf ("disk", "%s read failed\n", disk->name);
+ grub_error_pop ();
+ grub_free (tmp_buf);
+ return grub_errno;
+ }
+ grub_memcpy (buf, tmp_buf + offset, size);
+ grub_free (tmp_buf);
+ return GRUB_ERR_NONE;
+ }
+}
+
+static grub_err_t
+grub_disk_read_small (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_off_t offset, grub_size_t size, void *buf)
+{
+ grub_err_t err;
+
+ err = grub_disk_read_small_real (disk, sector, offset, size, buf);
+ if (err)
+ return err;
+ if (disk->read_hook)
+ (disk->read_hook) (sector + (offset >> GRUB_DISK_SECTOR_BITS),
+ offset & (GRUB_DISK_SECTOR_SIZE - 1),
+ size, disk->read_hook_data);
+ return GRUB_ERR_NONE;
+}
+
+/* Read data from the disk. */
+grub_err_t
+grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_off_t offset, grub_size_t size, void *buf)
+{
+ /* First of all, check if the region is within the disk. */
+ if (grub_disk_adjust_range (disk, &sector, &offset, size) != GRUB_ERR_NONE)
+ {
+ grub_error_push ();
+ grub_dprintf ("disk", "Read out of range: sector 0x%llx (%s).\n",
+ (unsigned long long) sector, grub_errmsg);
+ grub_error_pop ();
+ return grub_errno;
+ }
+
+ /* First read until first cache boundary. */
+ if (offset || (sector & (GRUB_DISK_CACHE_SIZE - 1)))
+ {
+ grub_disk_addr_t start_sector;
+ grub_size_t pos;
+ grub_err_t err;
+ grub_size_t len;
+
+ 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);
+ if (len > size)
+ len = size;
+ err = grub_disk_read_small (disk, start_sector,
+ offset + pos, len, buf);
+ if (err)
+ return err;
+ buf = (char *) buf + len;
+ size -= len;
+ offset += len;
+ sector += (offset >> GRUB_DISK_SECTOR_BITS);
+ offset &= ((1 << GRUB_DISK_SECTOR_BITS) - 1);
+ }
+
+ /* Until SIZE is zero... */
+ while (size >= (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS))
+ {
+ char *data = NULL;
+ grub_disk_addr_t agglomerate;
+ grub_err_t err;
+
+ /* agglomerate read until we find a first cached entry. */
+ for (agglomerate = 0; agglomerate
+ < (size >> (GRUB_DISK_SECTOR_BITS + GRUB_DISK_CACHE_BITS))
+ && agglomerate < disk->max_agglomerate;
+ agglomerate++)
+ {
+ data = grub_disk_cache_fetch (disk->dev->id, disk->id,
+ sector + (agglomerate
+ << GRUB_DISK_CACHE_BITS));
+ if (data)
+ break;
+ }
+
+ if (data)
+ {
+ grub_memcpy ((char *) buf
+ + (agglomerate << (GRUB_DISK_CACHE_BITS
+ + GRUB_DISK_SECTOR_BITS)),
+ data, GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
+ grub_disk_cache_unlock (disk->dev->id, disk->id,
+ sector + (agglomerate
+ << GRUB_DISK_CACHE_BITS));
+ }
+
+ if (agglomerate)
+ {
+ grub_disk_addr_t i;
+
+ err = (disk->dev->disk_read) (disk, transform_sector (disk, sector),
+ agglomerate << (GRUB_DISK_CACHE_BITS
+ + GRUB_DISK_SECTOR_BITS
+ - disk->log_sector_size),
+ buf);
+ if (err)
+ return err;
+
+ for (i = 0; i < agglomerate; i ++)
+ grub_disk_cache_store (disk->dev->id, disk->id,
+ sector + (i << GRUB_DISK_CACHE_BITS),
+ (char *) buf
+ + (i << (GRUB_DISK_CACHE_BITS
+ + GRUB_DISK_SECTOR_BITS)));
+
+
+ if (disk->read_hook)
+ (disk->read_hook) (sector, 0, agglomerate << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS),
+ disk->read_hook_data);
+
+ sector += agglomerate << GRUB_DISK_CACHE_BITS;
+ size -= agglomerate << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS);
+ buf = (char *) buf
+ + (agglomerate << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS));
+ }
+
+ if (data)
+ {
+ if (disk->read_hook)
+ (disk->read_hook) (sector, 0, (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS),
+ disk->read_hook_data);
+ sector += GRUB_DISK_CACHE_SIZE;
+ buf = (char *) buf + (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
+ size -= (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
+ }
+ }
+
+ /* And now read the last part. */
+ if (size)
+ {
+ grub_err_t err;
+ err = grub_disk_read_small (disk, sector, 0, size, buf);
+ if (err)
+ return err;
+ }
+
+ return grub_errno;
+}
+
+grub_uint64_t
+grub_disk_native_sectors (grub_disk_t disk)
+{
+ if (disk->partition)
+ return grub_partition_get_len (disk->partition);
+ else if (disk->total_sectors != GRUB_DISK_SIZE_UNKNOWN)
+ return disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
+ else
+ return GRUB_DISK_SIZE_UNKNOWN;
+}
diff --git a/grub-core/kern/disk_common.c b/grub-core/kern/disk_common.c
new file mode 100644
index 0000000..e09fba8
--- /dev/null
+++ b/grub-core/kern/disk_common.c
@@ -0,0 +1,66 @@
+/* This function performs three tasks:
+ - Make sectors disk relative from partition relative.
+ - Normalize offset to be less than the sector size.
+ - Verify that the range is inside the partition. */
+static grub_err_t
+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;
+
+ for (part = disk->partition; part; part = part->parent)
+ {
+ grub_disk_addr_t start;
+ grub_uint64_t len;
+
+ start = part->start;
+ len = part->len;
+
+ if (*sector >= len
+ || len - *sector < ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
+ >> GRUB_DISK_SECTOR_BITS))
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("attempt to read or write outside of partition"));
+
+ *sector += start;
+ }
+
+ /* 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 sizes.
+ * Clamp the size to GRUB_DISK_MAX_SECTORS. Just one condition is enough
+ * since GRUB_DISK_SIZE_UNKNOWN is always above GRUB_DISK_MAX_SECTORS,
+ * assuming a maximum 4 KiB sector size.
+ */
+ if (total_sectors > GRUB_DISK_MAX_SECTORS)
+ total_sectors = GRUB_DISK_MAX_SECTORS;
+
+ 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);
+
+ return GRUB_ERR_NONE;
+}
+
+static inline grub_disk_addr_t
+transform_sector (grub_disk_t disk, grub_disk_addr_t sector)
+{
+ return sector >> (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
+}
+
+static unsigned
+grub_disk_cache_get_index (unsigned long dev_id, unsigned long disk_id,
+ grub_disk_addr_t sector)
+{
+ return ((dev_id * 524287UL + disk_id * 2606459UL
+ + ((unsigned) (sector >> GRUB_DISK_CACHE_BITS)))
+ % GRUB_DISK_CACHE_NUM);
+}
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
new file mode 100644
index 0000000..48f8a79
--- /dev/null
+++ b/grub-core/kern/dl.c
@@ -0,0 +1,825 @@
+/* dl.c - loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Force native word size */
+#define GRUB_TARGET_WORDSIZE (8 * GRUB_CPU_SIZEOF_VOID_P)
+
+#include <config.h>
+#include <grub/elf.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <grub/file.h>
+#include <grub/env.h>
+#include <grub/cache.h>
+#include <grub/i18n.h>
+
+/* Platforms where modules are in a readonly area of memory. */
+#if defined(GRUB_MACHINE_QEMU)
+#define GRUB_MODULES_MACHINE_READONLY
+#endif
+
+
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+grub_dl_t grub_dl_head = 0;
+
+grub_err_t
+grub_dl_add (grub_dl_t mod);
+
+/* Keep global so that GDB scripts work. */
+grub_err_t
+grub_dl_add (grub_dl_t mod)
+{
+ if (grub_dl_get (mod->name))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "`%s' is already loaded", mod->name);
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_dl_remove (grub_dl_t mod)
+{
+ grub_dl_t *p, q;
+
+ for (p = &grub_dl_head, q = *p; q; p = &q->next, q = *p)
+ if (q == mod)
+ {
+ *p = q->next;
+ return;
+ }
+}
+
+
+
+struct grub_symbol
+{
+ struct grub_symbol *next;
+ const char *name;
+ void *addr;
+ int isfunc;
+ grub_dl_t mod; /* The module to which this symbol belongs. */
+};
+typedef struct grub_symbol *grub_symbol_t;
+
+/* The size of the symbol table. */
+#define GRUB_SYMTAB_SIZE 509
+
+/* The symbol table (using an open-hash). */
+static struct grub_symbol *grub_symtab[GRUB_SYMTAB_SIZE];
+
+/* Simple hash function. */
+static unsigned
+grub_symbol_hash (const char *s)
+{
+ unsigned key = 0;
+
+ while (*s)
+ key = key * 65599 + *s++;
+
+ return (key + (key >> 5)) % GRUB_SYMTAB_SIZE;
+}
+
+/* Resolve the symbol name NAME and return the address.
+ Return NULL, if not found. */
+static grub_symbol_t
+grub_dl_resolve_symbol (const char *name)
+{
+ grub_symbol_t sym;
+
+ for (sym = grub_symtab[grub_symbol_hash (name)]; sym; sym = sym->next)
+ if (grub_strcmp (sym->name, name) == 0)
+ return sym;
+
+ return 0;
+}
+
+/* Register a symbol with the name NAME and the address ADDR. */
+grub_err_t
+grub_dl_register_symbol (const char *name, void *addr, int isfunc,
+ grub_dl_t mod)
+{
+ grub_symbol_t sym;
+ unsigned k;
+
+ sym = (grub_symbol_t) grub_malloc (sizeof (*sym));
+ if (! sym)
+ return grub_errno;
+
+ if (mod)
+ {
+ sym->name = grub_strdup (name);
+ if (! sym->name)
+ {
+ grub_free (sym);
+ return grub_errno;
+ }
+ }
+ else
+ sym->name = name;
+
+ sym->addr = addr;
+ sym->mod = mod;
+ sym->isfunc = isfunc;
+
+ k = grub_symbol_hash (name);
+ sym->next = grub_symtab[k];
+ grub_symtab[k] = sym;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Unregister all the symbols defined in the module MOD. */
+static void
+grub_dl_unregister_symbols (grub_dl_t mod)
+{
+ unsigned i;
+
+ if (! mod)
+ grub_fatal ("core symbols cannot be unregistered");
+
+ for (i = 0; i < GRUB_SYMTAB_SIZE; i++)
+ {
+ grub_symbol_t sym, *p, q;
+
+ for (p = &grub_symtab[i], sym = *p; sym; sym = q)
+ {
+ q = sym->next;
+ if (sym->mod == mod)
+ {
+ *p = q;
+ grub_free ((void *) sym->name);
+ grub_free (sym);
+ }
+ else
+ p = &sym->next;
+ }
+ }
+}
+
+/* Return the address of a section whose index is N. */
+static void *
+grub_dl_get_section_addr (grub_dl_t mod, unsigned n)
+{
+ grub_dl_segment_t seg;
+
+ for (seg = mod->segment; seg; seg = seg->next)
+ if (seg->section == n)
+ return seg->addr;
+
+ return 0;
+}
+
+/* Check if EHDR is a valid ELF header. */
+static grub_err_t
+grub_dl_check_header (void *ehdr, grub_size_t size)
+{
+ Elf_Ehdr *e = ehdr;
+ grub_err_t err;
+
+ /* Check the header size. */
+ if (size < sizeof (Elf_Ehdr))
+ return grub_error (GRUB_ERR_BAD_OS, "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
+ || e->e_version != EV_CURRENT)
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic"));
+
+ err = grub_arch_dl_check_header (ehdr);
+ if (err)
+ return err;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Load all segments from memory specified by E. */
+static grub_err_t
+grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
+{
+ unsigned i;
+ const Elf_Shdr *s;
+ grub_size_t tsize = 0, talign = 1;
+#if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv)
+ grub_size_t tramp;
+ grub_size_t got;
+ grub_err_t err;
+#endif
+ char *ptr;
+
+ for (i = 0, s = (const Elf_Shdr *)((const char *) e + e->e_shoff);
+ i < e->e_shnum;
+ 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)
+ talign = s->sh_addralign;
+ }
+
+#if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv)
+ err = grub_arch_dl_get_tramp_got_size (e, &tramp, &got);
+ if (err)
+ return err;
+ tsize += ALIGN_UP (tramp, GRUB_ARCH_DL_TRAMP_ALIGN);
+ if (talign < GRUB_ARCH_DL_TRAMP_ALIGN)
+ talign = GRUB_ARCH_DL_TRAMP_ALIGN;
+ tsize += ALIGN_UP (got, GRUB_ARCH_DL_GOT_ALIGN);
+ if (talign < GRUB_ARCH_DL_GOT_ALIGN)
+ talign = GRUB_ARCH_DL_GOT_ALIGN;
+#endif
+
+#ifdef GRUB_MACHINE_EMU
+ mod->base = grub_osdep_dl_memalign (talign, tsize);
+#else
+ mod->base = grub_memalign (talign, tsize);
+#endif
+ if (!mod->base)
+ return grub_errno;
+ mod->sz = tsize;
+ ptr = mod->base;
+
+ for (i = 0, s = (Elf_Shdr *)((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *)((char *) s + e->e_shentsize))
+ {
+ if (s->sh_flags & SHF_ALLOC)
+ {
+ grub_dl_segment_t seg;
+
+ seg = (grub_dl_segment_t) grub_malloc (sizeof (*seg));
+ if (! seg)
+ return grub_errno;
+
+ if (s->sh_size)
+ {
+ void *addr;
+
+ ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, s->sh_addralign);
+ addr = ptr;
+ ptr += s->sh_size;
+
+ switch (s->sh_type)
+ {
+ case SHT_PROGBITS:
+ grub_memcpy (addr, (char *) e + s->sh_offset, s->sh_size);
+ break;
+ case SHT_NOBITS:
+ grub_memset (addr, 0, s->sh_size);
+ break;
+ }
+
+ seg->addr = addr;
+ }
+ else
+ seg->addr = 0;
+
+ seg->size = s->sh_size;
+ seg->section = i;
+ seg->next = mod->segment;
+ mod->segment = seg;
+ }
+ }
+#if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv)
+ ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN);
+ mod->tramp = ptr;
+ mod->trampptr = ptr;
+ ptr += tramp;
+ ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_GOT_ALIGN);
+ mod->got = ptr;
+ mod->gotptr = ptr;
+ ptr += got;
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
+{
+ unsigned i;
+ Elf_Shdr *s;
+ Elf_Sym *sym;
+ const char *str;
+ Elf_Word size, entsize;
+
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+ 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_ERR_NONE;
+
+#ifdef GRUB_MODULES_MACHINE_READONLY
+ mod->symtab = grub_malloc (s->sh_size);
+ if (!mod->symtab)
+ return grub_errno;
+ grub_memcpy (mod->symtab, (char *) e + s->sh_offset, s->sh_size);
+#else
+ mod->symtab = (Elf_Sym *) ((char *) e + s->sh_offset);
+#endif
+ mod->symsize = s->sh_entsize;
+ sym = mod->symtab;
+ size = s->sh_size;
+ entsize = s->sh_entsize;
+
+ s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shentsize * s->sh_link);
+ str = (char *) e + s->sh_offset;
+
+ for (i = 0;
+ i < size / entsize;
+ i++, sym = (Elf_Sym *) ((char *) sym + entsize))
+ {
+ unsigned char type = ELF_ST_TYPE (sym->st_info);
+ unsigned char bind = ELF_ST_BIND (sym->st_info);
+ const char *name = str + sym->st_name;
+
+ switch (type)
+ {
+ case STT_NOTYPE:
+ case STT_OBJECT:
+ /* Resolve a global symbol. */
+ if (sym->st_name != 0 && sym->st_shndx == 0)
+ {
+ grub_symbol_t nsym = grub_dl_resolve_symbol (name);
+ if (! nsym)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ N_("symbol `%s' not found"), name);
+ sym->st_value = (Elf_Addr) nsym->addr;
+ if (nsym->isfunc)
+ sym->st_info = ELF_ST_INFO (bind, STT_FUNC);
+ }
+ else
+ {
+ sym->st_value += (Elf_Addr) grub_dl_get_section_addr (mod,
+ sym->st_shndx);
+ if (bind != STB_LOCAL)
+ if (grub_dl_register_symbol (name, (void *) sym->st_value, 0, mod))
+ return grub_errno;
+ }
+ break;
+
+ case STT_FUNC:
+ sym->st_value += (Elf_Addr) grub_dl_get_section_addr (mod,
+ sym->st_shndx);
+#ifdef __ia64__
+ {
+ /* FIXME: free descriptor once it's not used anymore. */
+ char **desc;
+ desc = grub_malloc (2 * sizeof (char *));
+ if (!desc)
+ return grub_errno;
+ desc[0] = (void *) sym->st_value;
+ desc[1] = mod->base;
+ sym->st_value = (grub_addr_t) desc;
+ }
+#endif
+ if (bind != STB_LOCAL)
+ if (grub_dl_register_symbol (name, (void *) sym->st_value, 1, mod))
+ return grub_errno;
+ if (grub_strcmp (name, "grub_mod_init") == 0)
+ mod->init = (void (*) (grub_dl_t)) sym->st_value;
+ else if (grub_strcmp (name, "grub_mod_fini") == 0)
+ mod->fini = (void (*) (void)) sym->st_value;
+ break;
+
+ case STT_SECTION:
+ sym->st_value = (Elf_Addr) grub_dl_get_section_addr (mod,
+ sym->st_shndx);
+ break;
+
+ case STT_FILE:
+ sym->st_value = 0;
+ break;
+
+ default:
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "unknown symbol type `%d'", (int) type);
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static Elf_Shdr *
+grub_dl_find_section (Elf_Ehdr *e, const char *name)
+{
+ Elf_Shdr *s;
+ const char *str;
+ unsigned i;
+
+ s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize);
+ str = (char *) e + s->sh_offset;
+
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+ if (grub_strcmp (str + s->sh_name, name) == 0)
+ return s;
+ return NULL;
+}
+
+/* Me, Vladimir Serbinenko, hereby I add this module check as per new
+ GNU module policy. Note that this license check is informative only.
+ Modules have to be licensed under GPLv3 or GPLv3+ (optionally
+ multi-licensed under other licences as well) independently of the
+ presence of this check and solely by linking (module loading in GRUB
+ constitutes linking) and GRUB core being licensed under GPLv3+.
+ Be sure to understand your license obligations.
+*/
+static grub_err_t
+grub_dl_check_license (Elf_Ehdr *e)
+{
+ Elf_Shdr *s = grub_dl_find_section (e, ".module_license");
+ if (s && (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0
+ || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3+") == 0
+ || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0))
+ return GRUB_ERR_NONE;
+ return grub_error (GRUB_ERR_BAD_MODULE, "incompatible license");
+}
+
+static grub_err_t
+grub_dl_resolve_name (grub_dl_t mod, Elf_Ehdr *e)
+{
+ Elf_Shdr *s;
+
+ s = grub_dl_find_section (e, ".modname");
+ if (!s)
+ return grub_error (GRUB_ERR_BAD_MODULE, "no module name found");
+
+ mod->name = grub_strdup ((char *) e + s->sh_offset);
+ if (! mod->name)
+ return grub_errno;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_dl_resolve_dependencies (grub_dl_t mod, Elf_Ehdr *e)
+{
+ Elf_Shdr *s;
+
+ s = grub_dl_find_section (e, ".moddeps");
+
+ if (!s)
+ return GRUB_ERR_NONE;
+
+ const char *name = (char *) e + s->sh_offset;
+ const char *max = name + s->sh_size;
+
+ while ((name < max) && (*name))
+ {
+ grub_dl_t m;
+ grub_dl_dep_t dep;
+
+ m = grub_dl_load (name);
+ if (! m)
+ return grub_errno;
+
+ grub_dl_ref (m);
+
+ dep = (grub_dl_dep_t) grub_malloc (sizeof (*dep));
+ if (! dep)
+ return grub_errno;
+
+ dep->mod = m;
+ dep->next = mod->dep;
+ mod->dep = dep;
+
+ name += grub_strlen (name) + 1;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+int
+grub_dl_ref (grub_dl_t mod)
+{
+ grub_dl_dep_t dep;
+
+ if (!mod)
+ return 0;
+
+ for (dep = mod->dep; dep; dep = dep->next)
+ grub_dl_ref (dep->mod);
+
+ return ++mod->ref_count;
+}
+
+int
+grub_dl_unref (grub_dl_t mod)
+{
+ grub_dl_dep_t dep;
+
+ if (!mod)
+ return 0;
+
+ for (dep = mod->dep; dep; dep = dep->next)
+ grub_dl_unref (dep->mod);
+
+ return --mod->ref_count;
+}
+
+int
+grub_dl_ref_count (grub_dl_t mod)
+{
+ if (mod == NULL)
+ return 0;
+
+ return mod->ref_count;
+}
+
+static void
+grub_dl_flush_cache (grub_dl_t mod)
+{
+ grub_dprintf ("modules", "flushing 0x%lx bytes at %p\n",
+ (unsigned long) mod->sz, mod->base);
+ grub_arch_sync_caches (mod->base, mod->sz);
+}
+
+static grub_err_t
+grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
+{
+ Elf_Ehdr *e = ehdr;
+ Elf_Shdr *s;
+ unsigned i;
+
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+ if (s->sh_type == SHT_REL || s->sh_type == SHT_RELA)
+ {
+ grub_dl_segment_t seg;
+ grub_err_t err;
+
+ /* Find the target segment. */
+ for (seg = mod->segment; seg; seg = seg->next)
+ if (seg->section == s->sh_info)
+ break;
+
+ 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;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/* Load a module from core memory. */
+grub_dl_t
+grub_dl_load_core_noinit (void *addr, grub_size_t size)
+{
+ Elf_Ehdr *e;
+ grub_dl_t mod;
+
+ grub_dprintf ("modules", "module at %p, size 0x%lx\n", addr,
+ (unsigned long) size);
+ e = addr;
+ if (grub_dl_check_header (e, size))
+ return 0;
+
+ if (e->e_type != ET_REL)
+ {
+ grub_error (GRUB_ERR_BAD_MODULE, N_("this ELF file is not of the right type"));
+ return 0;
+ }
+
+ /* Make sure that every section is within the core. */
+ 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;
+ }
+
+ mod = (grub_dl_t) grub_zalloc (sizeof (*mod));
+ if (! mod)
+ return 0;
+
+ mod->ref_count = 1;
+
+ grub_dprintf ("modules", "relocating to %p\n", mod);
+ /* Me, Vladimir Serbinenko, hereby I add this module check as per new
+ GNU module policy. Note that this license check is informative only.
+ Modules have to be licensed under GPLv3 or GPLv3+ (optionally
+ multi-licensed under other licences as well) independently of the
+ presence of this check and solely by linking (module loading in GRUB
+ constitutes linking) and GRUB core being licensed under GPLv3+.
+ Be sure to understand your license obligations.
+ */
+ if (grub_dl_check_license (e)
+ || grub_dl_resolve_name (mod, e)
+ || grub_dl_resolve_dependencies (mod, e)
+ || grub_dl_load_segments (mod, e)
+ || grub_dl_resolve_symbols (mod, e)
+ || grub_dl_relocate_symbols (mod, e))
+ {
+ mod->fini = 0;
+ grub_dl_unload (mod);
+ return 0;
+ }
+
+ grub_dl_flush_cache (mod);
+
+ grub_dprintf ("modules", "module name: %s\n", mod->name);
+ grub_dprintf ("modules", "init function: %p\n", mod->init);
+
+ if (grub_dl_add (mod))
+ {
+ grub_dl_unload (mod);
+ return 0;
+ }
+
+ return mod;
+}
+
+grub_dl_t
+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)
+ return NULL;
+
+ grub_boot_time ("Initing module %s", mod->name);
+ grub_dl_init (mod);
+ grub_boot_time ("Module %s inited", mod->name);
+
+ return mod;
+}
+
+/* Load a module from the file FILENAME. */
+grub_dl_t
+grub_dl_load_file (const char *filename)
+{
+ grub_file_t file = NULL;
+ grub_ssize_t size;
+ void *core = 0;
+ grub_dl_t mod = 0;
+
+ grub_boot_time ("Loading module %s", filename);
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE);
+ if (! file)
+ return 0;
+
+ size = grub_file_size (file);
+ core = grub_malloc (size);
+ if (! core)
+ {
+ grub_file_close (file);
+ return 0;
+ }
+
+ if (grub_file_read (file, core, size) != (int) size)
+ {
+ grub_file_close (file);
+ grub_free (core);
+ return 0;
+ }
+
+ /* We must close this before we try to process dependencies.
+ Some disk backends do not handle gracefully multiple concurrent
+ opens of the same device. */
+ grub_file_close (file);
+
+ mod = grub_dl_load_core (core, size);
+ grub_free (core);
+ if (! mod)
+ return 0;
+
+ mod->ref_count--;
+ return mod;
+}
+
+/* Load a module using a symbolic name. */
+grub_dl_t
+grub_dl_load (const char *name)
+{
+ char *filename;
+ grub_dl_t mod;
+ const char *grub_dl_dir = grub_env_get ("prefix");
+
+ mod = grub_dl_get (name);
+ if (mod)
+ return mod;
+
+ if (grub_no_modules)
+ return 0;
+
+ if (! grub_dl_dir) {
+ grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
+ return 0;
+ }
+
+ filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM "/%s.mod",
+ grub_dl_dir, name);
+ if (! filename)
+ return 0;
+
+ mod = grub_dl_load_file (filename);
+ grub_free (filename);
+
+ if (! mod)
+ return 0;
+
+ if (grub_strcmp (mod->name, name) != 0)
+ grub_error (GRUB_ERR_BAD_MODULE, "mismatched names");
+
+ return mod;
+}
+
+/* Unload the module MOD. */
+int
+grub_dl_unload (grub_dl_t mod)
+{
+ grub_dl_dep_t dep, depn;
+
+ if (mod->ref_count > 0)
+ return 0;
+
+ if (mod->fini)
+ (mod->fini) ();
+
+ grub_dl_remove (mod);
+ grub_dl_unregister_symbols (mod);
+
+ for (dep = mod->dep; dep; dep = depn)
+ {
+ depn = dep->next;
+
+ grub_dl_unload (dep->mod);
+
+ grub_free (dep);
+ }
+
+#ifdef GRUB_MACHINE_EMU
+ grub_dl_osdep_dl_free (mod->base);
+#else
+ grub_free (mod->base);
+#endif
+ grub_free (mod->name);
+#ifdef GRUB_MODULES_MACHINE_READONLY
+ grub_free (mod->symtab);
+#endif
+ grub_free (mod);
+ return 1;
+}
+
+/* Unload unneeded modules. */
+void
+grub_dl_unload_unneeded (void)
+{
+ /* Because grub_dl_remove modifies the list of modules, this
+ implementation is tricky. */
+ grub_dl_t p = grub_dl_head;
+
+ while (p)
+ {
+ if (grub_dl_unload (p))
+ {
+ p = grub_dl_head;
+ continue;
+ }
+
+ p = p->next;
+ }
+}
diff --git a/grub-core/kern/efi/acpi.c b/grub-core/kern/efi/acpi.c
new file mode 100644
index 0000000..74f8cd1
--- /dev/null
+++ b/grub-core/kern/efi/acpi.c
@@ -0,0 +1,59 @@
+/* acpi.c - get acpi tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/acpi.h>
+#include <grub/misc.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/api.h>
+
+struct grub_acpi_rsdp_v10 *
+grub_machine_acpi_get_rsdpv1 (void)
+{
+ unsigned i;
+ static grub_efi_packed_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
+
+ for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
+ {
+ grub_efi_packed_guid_t *guid =
+ &grub_efi_system_table->configuration_table[i].vendor_guid;
+
+ if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_packed_guid_t)))
+ return (struct grub_acpi_rsdp_v10 *)
+ grub_efi_system_table->configuration_table[i].vendor_table;
+ }
+ return 0;
+}
+
+struct grub_acpi_rsdp_v20 *
+grub_machine_acpi_get_rsdpv2 (void)
+{
+ unsigned i;
+ static grub_efi_packed_guid_t acpi20_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
+
+ for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
+ {
+ grub_efi_packed_guid_t *guid =
+ &grub_efi_system_table->configuration_table[i].vendor_guid;
+
+ if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_efi_packed_guid_t)))
+ return (struct grub_acpi_rsdp_v20 *)
+ grub_efi_system_table->configuration_table[i].vendor_table;
+ }
+ return 0;
+}
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
new file mode 100644
index 0000000..8cff7be
--- /dev/null
+++ b/grub-core/kern/efi/efi.c
@@ -0,0 +1,1017 @@
+/* efi.c - generic EFI support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/charset.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/console_control.h>
+#include <grub/efi/pe32.h>
+#include <grub/time.h>
+#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;
+
+/* The pointer to a system table. Filled in by the startup code. */
+grub_efi_system_table_t *grub_efi_system_table;
+
+static grub_efi_guid_t console_control_guid = GRUB_EFI_CONSOLE_CONTROL_GUID;
+static grub_efi_guid_t loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
+static grub_efi_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
+
+void *
+grub_efi_locate_protocol (grub_efi_guid_t *protocol, void *registration)
+{
+ void *interface;
+ grub_efi_status_t status;
+
+ status = efi_call_3 (grub_efi_system_table->boot_services->locate_protocol,
+ protocol, registration, &interface);
+ if (status != GRUB_EFI_SUCCESS)
+ return 0;
+
+ return interface;
+}
+
+/* Return the array of handles which meet the requirement. If successful,
+ the number of handles is stored in NUM_HANDLES. The array is allocated
+ from the heap. */
+grub_efi_handle_t *
+grub_efi_locate_handle (grub_efi_locate_search_type_t search_type,
+ grub_efi_guid_t *protocol,
+ void *search_key,
+ grub_efi_uintn_t *num_handles)
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_status_t status;
+ grub_efi_handle_t *buffer;
+ grub_efi_uintn_t buffer_size = 8 * sizeof (grub_efi_handle_t);
+
+ buffer = grub_malloc (buffer_size);
+ if (! buffer)
+ return 0;
+
+ b = grub_efi_system_table->boot_services;
+ status = efi_call_5 (b->locate_handle, search_type, protocol, search_key,
+ &buffer_size, buffer);
+ if (status == GRUB_EFI_BUFFER_TOO_SMALL)
+ {
+ grub_free (buffer);
+ buffer = grub_malloc (buffer_size);
+ if (! buffer)
+ return 0;
+
+ status = efi_call_5 (b->locate_handle, search_type, protocol, search_key,
+ &buffer_size, buffer);
+ }
+
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_free (buffer);
+ return 0;
+ }
+
+ *num_handles = buffer_size / sizeof (grub_efi_handle_t);
+ return buffer;
+}
+
+void *
+grub_efi_open_protocol (grub_efi_handle_t handle,
+ grub_efi_guid_t *protocol,
+ grub_efi_uint32_t attributes)
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_status_t status;
+ void *interface;
+
+ b = grub_efi_system_table->boot_services;
+ status = efi_call_6 (b->open_protocol, handle,
+ protocol,
+ &interface,
+ grub_efi_image_handle,
+ 0,
+ attributes);
+ if (status != GRUB_EFI_SUCCESS)
+ return 0;
+
+ return interface;
+}
+
+int
+grub_efi_set_text_mode (int on)
+{
+ grub_efi_console_control_protocol_t *c;
+ grub_efi_screen_mode_t mode, new_mode;
+
+ c = grub_efi_locate_protocol (&console_control_guid, 0);
+ if (! c)
+ /* No console control protocol instance available, assume it is
+ already in text mode. */
+ return 1;
+
+ if (efi_call_4 (c->get_mode, c, &mode, 0, 0) != GRUB_EFI_SUCCESS)
+ return 0;
+
+ new_mode = on ? GRUB_EFI_SCREEN_TEXT : GRUB_EFI_SCREEN_GRAPHICS;
+ if (mode != new_mode)
+ if (efi_call_2 (c->set_mode, c, new_mode) != GRUB_EFI_SUCCESS)
+ return 0;
+
+ return 1;
+}
+
+void
+grub_efi_stall (grub_efi_uintn_t microseconds)
+{
+ efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
+}
+
+grub_efi_loaded_image_t *
+grub_efi_get_loaded_image (grub_efi_handle_t image_handle)
+{
+ return grub_efi_open_protocol (image_handle,
+ &loaded_image_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+}
+
+void
+grub_reboot (void)
+{
+ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN |
+ GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY);
+ efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
+ GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL);
+ for (;;) ;
+}
+
+void
+grub_exit (void)
+{
+ 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 (;;) ;
+}
+
+grub_err_t
+grub_efi_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
+ grub_efi_uintn_t descriptor_size,
+ grub_efi_uint32_t descriptor_version,
+ grub_efi_memory_descriptor_t *virtual_map)
+{
+ grub_efi_runtime_services_t *r;
+ grub_efi_status_t status;
+
+ r = grub_efi_system_table->runtime_services;
+ status = efi_call_4 (r->set_virtual_address_map, memory_map_size,
+ descriptor_size, descriptor_version, virtual_map);
+
+ if (status == GRUB_EFI_SUCCESS)
+ return GRUB_ERR_NONE;
+
+ return grub_error (GRUB_ERR_IO, "set_virtual_address_map failed");
+}
+
+grub_err_t
+grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid,
+ void *data, grub_size_t datasize)
+{
+ grub_efi_status_t status;
+ grub_efi_runtime_services_t *r;
+ grub_efi_char16_t *var16;
+ grub_size_t len, len16;
+
+ len = grub_strlen (var);
+ len16 = len * GRUB_MAX_UTF16_PER_UTF8;
+ var16 = grub_calloc (len16 + 1, sizeof (var16[0]));
+ if (!var16)
+ return grub_errno;
+ len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL);
+ var16[len16] = 0;
+
+ r = grub_efi_system_table->runtime_services;
+
+ status = efi_call_5 (r->set_variable, var16, guid,
+ (GRUB_EFI_VARIABLE_NON_VOLATILE
+ | GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS
+ | GRUB_EFI_VARIABLE_RUNTIME_ACCESS),
+ datasize, data);
+ grub_free (var16);
+ if (status == GRUB_EFI_SUCCESS)
+ return GRUB_ERR_NONE;
+
+ return grub_error (GRUB_ERR_IO, "could not set EFI variable `%s'", var);
+}
+
+grub_efi_status_t
+grub_efi_get_variable_with_attributes (const char *var,
+ const grub_efi_guid_t *guid,
+ grub_size_t *datasize_out,
+ void **data_out,
+ grub_efi_uint32_t *attributes)
+{
+ grub_efi_status_t status;
+ grub_efi_uintn_t datasize = 0;
+ grub_efi_runtime_services_t *r;
+ grub_efi_char16_t *var16;
+ void *data;
+ grub_size_t len, len16;
+
+ *data_out = NULL;
+ *datasize_out = 0;
+
+ len = grub_strlen (var);
+ len16 = len * GRUB_MAX_UTF16_PER_UTF8;
+ var16 = grub_calloc (len16 + 1, sizeof (var16[0]));
+ if (!var16)
+ return GRUB_EFI_OUT_OF_RESOURCES;
+ len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL);
+ var16[len16] = 0;
+
+ r = grub_efi_system_table->runtime_services;
+
+ status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, NULL);
+
+ if (status != GRUB_EFI_BUFFER_TOO_SMALL || !datasize)
+ {
+ grub_free (var16);
+ return status;
+ }
+
+ data = grub_malloc (datasize);
+ if (!data)
+ {
+ grub_free (var16);
+ return GRUB_EFI_OUT_OF_RESOURCES;
+ }
+
+ status = efi_call_5 (r->get_variable, var16, guid, attributes, &datasize, data);
+ grub_free (var16);
+
+ if (status == GRUB_EFI_SUCCESS)
+ {
+ *data_out = data;
+ *datasize_out = datasize;
+ return status;
+ }
+
+ grub_free (data);
+ return status;
+}
+
+grub_efi_status_t
+grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
+ grub_size_t *datasize_out, void **data_out)
+{
+ return grub_efi_get_variable_with_attributes (var, guid, datasize_out, data_out, NULL);
+}
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+/* Search the mods section from the PE32/PE32+ image. This code uses
+ a PE32 header, but should work with PE32+ as well. */
+grub_addr_t
+grub_efi_modules_addr (void)
+{
+ grub_efi_loaded_image_t *image;
+ struct grub_pe32_header *header;
+ struct grub_pe32_coff_header *coff_header;
+ struct grub_pe32_section_table *sections;
+ struct grub_pe32_section_table *section;
+ struct grub_module_info *info;
+ grub_uint16_t i;
+
+ image = grub_efi_get_loaded_image (grub_efi_image_handle);
+ if (! image)
+ return 0;
+
+ header = image->image_base;
+ coff_header = &(header->coff_header);
+ sections
+ = (struct grub_pe32_section_table *) ((char *) coff_header
+ + sizeof (*coff_header)
+ + coff_header->optional_header_size);
+
+ for (i = 0, section = sections;
+ i < coff_header->num_sections;
+ i++, section++)
+ {
+ if (grub_strcmp (section->name, "mods") == 0)
+ break;
+ }
+
+ if (i == coff_header->num_sections)
+ {
+ grub_dprintf("sections", "section %d is last section; invalid.\n", i);
+ return 0;
+ }
+
+ info = (struct grub_module_info *) ((char *) image->image_base
+ + section->virtual_address);
+ if (section->name[0] != '.' && info->magic != GRUB_MODULE_MAGIC)
+ {
+ grub_dprintf("sections",
+ "section %d has bad magic %08x, should be %08x\n",
+ i, info->magic, GRUB_MODULE_MAGIC);
+ return 0;
+ }
+
+ grub_dprintf("sections", "returning section info for section %d: \"%s\"\n",
+ i, section->name);
+ return (grub_addr_t) info;
+}
+
+#pragma GCC diagnostic error "-Wcast-align"
+
+char *
+grub_efi_get_filename (grub_efi_device_path_t *dp0)
+{
+ char *name = 0, *p, *pi;
+ grub_size_t filesize = 0;
+ grub_efi_device_path_t *dp;
+
+ if (!dp0)
+ return NULL;
+
+ dp = dp0;
+
+ while (dp)
+ {
+ grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
+ grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
+
+ if (type == GRUB_EFI_END_DEVICE_PATH_TYPE)
+ break;
+ if (type == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
+ && subtype == GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE)
+ {
+ grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
+
+ if (len < 4)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "malformed EFI Device Path node has length=%d", len);
+ return NULL;
+ }
+ len = (len - 4) / sizeof (grub_efi_char16_t);
+ filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 2;
+ }
+
+ dp = GRUB_EFI_NEXT_DEVICE_PATH (dp);
+ }
+
+ if (!filesize)
+ return NULL;
+
+ dp = dp0;
+
+ p = name = grub_malloc (filesize);
+ if (!name)
+ return NULL;
+
+ while (dp)
+ {
+ grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
+ grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
+
+ if (type == GRUB_EFI_END_DEVICE_PATH_TYPE)
+ break;
+ else if (type == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
+ && subtype == GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE)
+ {
+ grub_efi_file_path_device_path_t *fp;
+ grub_efi_uint16_t len;
+ grub_efi_char16_t *dup_name;
+
+ *p++ = '/';
+
+ len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
+ if (len < 4)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "malformed EFI Device Path node has length=%d", len);
+ grub_free (name);
+ return NULL;
+ }
+
+ len = (len - 4) / sizeof (grub_efi_char16_t);
+ fp = (grub_efi_file_path_device_path_t *) dp;
+ /* According to EFI spec Path Name is NULL terminated */
+ while (len > 0 && fp->path_name[len - 1] == 0)
+ len--;
+
+ dup_name = grub_calloc (len, sizeof (*dup_name));
+ if (!dup_name)
+ {
+ grub_free (name);
+ return NULL;
+ }
+ p = (char *) grub_utf16_to_utf8 ((unsigned char *) p,
+ grub_memcpy (dup_name, fp->path_name, len * sizeof (*dup_name)),
+ len);
+ grub_free (dup_name);
+ }
+
+ dp = GRUB_EFI_NEXT_DEVICE_PATH (dp);
+ }
+
+ *p = '\0';
+
+ 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;
+}
+
+grub_efi_device_path_t *
+grub_efi_get_device_path (grub_efi_handle_t handle)
+{
+ return grub_efi_open_protocol (handle, &device_path_guid,
+ 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))
+ {
+ grub_size_t len = GRUB_EFI_DEVICE_PATH_LENGTH (p);
+
+ /*
+ * In the event that we find a node that's completely garbage, for
+ * example if we get to 0x7f 0x01 0x02 0x00 ... (EndInstance with a size
+ * of 2), GRUB_EFI_END_ENTIRE_DEVICE_PATH() will be true and
+ * GRUB_EFI_NEXT_DEVICE_PATH() will return NULL, so we won't continue,
+ * and neither should our consumers, but there won't be any error raised
+ * even though the device path is junk.
+ *
+ * This keeps us from passing junk down back to our caller.
+ */
+ if (len < 4)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "malformed EFI Device Path node has length=%" PRIuGRUB_SIZE, len);
+ return NULL;
+ }
+
+ total_size += len;
+ 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)
+{
+ while (GRUB_EFI_DEVICE_PATH_VALID (dp))
+ {
+ grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
+ grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
+ grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
+
+ switch (type)
+ {
+ case GRUB_EFI_END_DEVICE_PATH_TYPE:
+ switch (subtype)
+ {
+ case GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE:
+ grub_printf ("/EndEntire\n");
+ //grub_putchar ('\n');
+ break;
+ case GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE:
+ grub_printf ("/EndThis\n");
+ //grub_putchar ('\n');
+ break;
+ default:
+ grub_printf ("/EndUnknown(%x)\n", (unsigned) subtype);
+ break;
+ }
+ break;
+
+ case GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE:
+ switch (subtype)
+ {
+ case GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE:
+ {
+ grub_efi_pccard_device_path_t *pccard
+ = (grub_efi_pccard_device_path_t *) dp;
+ grub_printf ("/PCCARD(%x)",
+ (unsigned) pccard->function);
+ }
+ break;
+ case GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE:
+ 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_efi_controller_device_path_t *) dp;
+ grub_printf ("/Ctrl(%x)",
+ (unsigned) controller->controller_number);
+ }
+ break;
+ default:
+ grub_printf ("/UnknownHW(%x)", (unsigned) subtype);
+ break;
+ }
+ break;
+
+ case GRUB_EFI_ACPI_DEVICE_PATH_TYPE:
+ switch (subtype)
+ {
+ case GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ 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);
+ 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);
+ else
+ grub_printf ("%s)", GRUB_EFI_EXPANDED_ACPI_CIDSTR (dp));
+ }
+ break;
+ default:
+ grub_printf ("/UnknownACPI(%x)", (unsigned) subtype);
+ break;
+ }
+ break;
+
+ case GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE:
+ switch (subtype)
+ {
+ case GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_SCSI_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_1394_DEVICE_PATH_SUBTYPE:
+ {
+ 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_efi_usb_device_path_t *) dp;
+ grub_printf ("/USB(%x,%x)",
+ (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_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);
+ }
+ break;
+ case GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE:
+ {
+ 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_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);
+ }
+ break;
+ case GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_UART_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_SATA_DEVICE_PATH_SUBTYPE:
+ {
+ 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;
+ }
+ break;
+
+ case GRUB_EFI_MEDIA_DEVICE_PATH_TYPE:
+ switch (subtype)
+ {
+ case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
+ {
+ grub_efi_hard_drive_device_path_t *hd = (grub_efi_hard_drive_device_path_t *) dp;
+ grub_printf ("/HD(%u,%llx,%llx,%02x%02x%02x%02x%02x%02x%02x%02x,%x,%x)",
+ hd->partition_number,
+ (unsigned long long) hd->partition_start,
+ (unsigned long long) hd->partition_size,
+ (unsigned) hd->partition_signature[0],
+ (unsigned) hd->partition_signature[1],
+ (unsigned) hd->partition_signature[2],
+ (unsigned) hd->partition_signature[3],
+ (unsigned) hd->partition_signature[4],
+ (unsigned) hd->partition_signature[5],
+ (unsigned) hd->partition_signature[6],
+ (unsigned) hd->partition_signature[7],
+ (unsigned) hd->partmap_type,
+ (unsigned) hd->signature_type);
+ }
+ break;
+ case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
+ {
+ 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);
+ }
+ break;
+ case GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE:
+ dump_vendor_path ("Media",
+ (grub_efi_vendor_device_path_t *) dp);
+ break;
+ case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
+ {
+ grub_efi_file_path_device_path_t *fp;
+ grub_uint8_t *buf;
+ fp = (grub_efi_file_path_device_path_t *) dp;
+ buf = grub_malloc ((len - 4) * 2 + 1);
+ if (buf)
+ {
+ grub_efi_char16_t *dup_name = grub_malloc (len - 4);
+ if (!dup_name)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_printf ("/File((null))");
+ grub_free (buf);
+ break;
+ }
+ *grub_utf16_to_utf8 (buf, grub_memcpy (dup_name, fp->path_name, len - 4),
+ (len - 4) / sizeof (grub_efi_char16_t))
+ = '\0';
+ grub_free (dup_name);
+ }
+ else
+ grub_errno = GRUB_ERR_NONE;
+ grub_printf ("/File(%s)", buf);
+ grub_free (buf);
+ }
+ break;
+ case GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE:
+ {
+ 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]);
+ }
+ break;
+ default:
+ grub_printf ("/UnknownMedia(%x)", (unsigned) subtype);
+ break;
+ }
+ break;
+
+ case GRUB_EFI_BIOS_DEVICE_PATH_TYPE:
+ switch (subtype)
+ {
+ case GRUB_EFI_BIOS_DEVICE_PATH_SUBTYPE:
+ {
+ 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,
+ (char *) (dp + 1));
+ }
+ break;
+ default:
+ grub_printf ("/UnknownBIOS(%x)", (unsigned) subtype);
+ break;
+ }
+ break;
+
+ default:
+ grub_printf ("/UnknownType(%x,%x)\n",
+ (unsigned) type,
+ (unsigned) subtype);
+ return;
+ break;
+ }
+
+ if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
+ break;
+
+ dp = (grub_efi_device_path_t *) ((char *) dp + len);
+ }
+}
+
+/* Compare device paths. */
+int
+grub_efi_compare_device_paths (const grub_efi_device_path_t *dp1,
+ const grub_efi_device_path_t *dp2)
+{
+ if (! dp1 || ! dp2)
+ /* Return non-zero. */
+ return 1;
+
+ if (dp1 == dp2)
+ return 0;
+
+ while (GRUB_EFI_DEVICE_PATH_VALID (dp1) && GRUB_EFI_DEVICE_PATH_VALID (dp2))
+ {
+ grub_efi_uint8_t type1, type2;
+ grub_efi_uint8_t subtype1, subtype2;
+ grub_efi_uint16_t len1, len2;
+ int ret;
+
+ type1 = GRUB_EFI_DEVICE_PATH_TYPE (dp1);
+ type2 = GRUB_EFI_DEVICE_PATH_TYPE (dp2);
+
+ if (type1 != type2)
+ return (int) type2 - (int) type1;
+
+ subtype1 = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp1);
+ subtype2 = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp2);
+
+ if (subtype1 != subtype2)
+ return (int) subtype1 - (int) subtype2;
+
+ len1 = GRUB_EFI_DEVICE_PATH_LENGTH (dp1);
+ len2 = GRUB_EFI_DEVICE_PATH_LENGTH (dp2);
+
+ if (len1 != len2)
+ return (int) len1 - (int) len2;
+
+ ret = grub_memcmp (dp1, dp2, len1);
+ if (ret != 0)
+ return ret;
+
+ if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp1))
+ break;
+
+ dp1 = (grub_efi_device_path_t *) ((char *) dp1 + len1);
+ dp2 = (grub_efi_device_path_t *) ((char *) dp2 + len2);
+ }
+
+ /*
+ * There's no "right" answer here, but we probably don't want to call a valid
+ * dp and an invalid dp equal, so pick one way or the other.
+ */
+ if (GRUB_EFI_DEVICE_PATH_VALID (dp1) && !GRUB_EFI_DEVICE_PATH_VALID (dp2))
+ return 1;
+ else if (!GRUB_EFI_DEVICE_PATH_VALID (dp1) && GRUB_EFI_DEVICE_PATH_VALID (dp2))
+ return -1;
+
+ return 0;
+}
diff --git a/grub-core/kern/efi/fdt.c b/grub-core/kern/efi/fdt.c
new file mode 100644
index 0000000..30100c6
--- /dev/null
+++ b/grub-core/kern/efi/fdt.c
@@ -0,0 +1,43 @@
+/* fdt.c - EFI Flattened Device Tree interaction */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/efi/efi.h>
+#include <grub/mm.h>
+
+void *
+grub_efi_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;
+}
diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
new file mode 100644
index 0000000..7facacf
--- /dev/null
+++ b/grub-core/kern/efi/init.c
@@ -0,0 +1,149 @@
+/* init.c - generic EFI initialization and finalization */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/efi/efi.h>
+#include <grub/efi/console.h>
+#include <grub/efi/disk.h>
+#include <grub/efi/sb.h>
+#include <grub/lockdown.h>
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/mm.h>
+#include <grub/kernel.h>
+#include <grub/stack_protector.h>
+
+#ifdef GRUB_STACK_PROTECTOR
+
+static grub_efi_guid_t rng_protocol_guid = GRUB_EFI_RNG_PROTOCOL_GUID;
+
+/*
+ * Don't put this on grub_efi_init()'s local stack to avoid it
+ * getting a stack check.
+ */
+static grub_efi_uint8_t stack_chk_guard_buf[32];
+
+grub_addr_t __stack_chk_guard;
+
+void __attribute__ ((noreturn))
+__stack_chk_fail (void)
+{
+ /*
+ * Assume it's not safe to call into EFI Boot Services. Sorry, that
+ * means no console message here.
+ */
+ do
+ {
+ /* Do not optimize out the loop. */
+ asm volatile ("");
+ }
+ while (1);
+}
+
+static void
+stack_protector_init (void)
+{
+ grub_efi_rng_protocol_t *rng;
+
+ /* Set up the stack canary. Make errors here non-fatal for now. */
+ rng = grub_efi_locate_protocol (&rng_protocol_guid, NULL);
+ if (rng != NULL)
+ {
+ grub_efi_status_t status;
+
+ status = efi_call_4 (rng->get_rng, rng, NULL, sizeof (stack_chk_guard_buf),
+ stack_chk_guard_buf);
+ if (status == GRUB_EFI_SUCCESS)
+ grub_memcpy (&__stack_chk_guard, stack_chk_guard_buf, sizeof (__stack_chk_guard));
+ }
+}
+#else
+static void
+stack_protector_init (void)
+{
+}
+#endif
+
+grub_addr_t grub_modbase;
+
+void
+grub_efi_init (void)
+{
+ grub_modbase = grub_efi_modules_addr ();
+ /* First of all, initialize the console so that GRUB can display
+ messages. */
+ grub_console_init ();
+
+ stack_protector_init ();
+
+ /* Initialize the memory management system. */
+ grub_efi_mm_init ();
+
+ /*
+ * Lockdown the GRUB and register the shim_lock verifier
+ * if the UEFI Secure Boot is enabled.
+ */
+ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED)
+ {
+ grub_lockdown ();
+ grub_shim_lock_verifier_setup ();
+ }
+
+ efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer,
+ 0, 0, 0, NULL);
+
+ grub_efidisk_init ();
+}
+
+void (*grub_efi_net_config) (grub_efi_handle_t hnd,
+ char **device,
+ char **path);
+
+void
+grub_machine_get_bootlocation (char **device, char **path)
+{
+ grub_efi_loaded_image_t *image = NULL;
+ char *p;
+
+ image = grub_efi_get_loaded_image (grub_efi_image_handle);
+ if (!image)
+ return;
+ *device = grub_efidisk_get_device_name (image->device_handle);
+ if (!*device && grub_efi_net_config)
+ {
+ grub_efi_net_config (image->device_handle, device, path);
+ return;
+ }
+
+ *path = grub_efi_get_filename (image->file_path);
+ if (*path)
+ {
+ /* Get the directory. */
+ p = grub_strrchr (*path, '/');
+ if (p)
+ *p = '\0';
+ }
+}
+
+void
+grub_efi_fini (void)
+{
+ grub_efidisk_fini ();
+ grub_console_fini ();
+}
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
new file mode 100644
index 0000000..9838fb2
--- /dev/null
+++ b/grub-core/kern/efi/mm.c
@@ -0,0 +1,691 @@
+/* mm.c - generic EFI memory management */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/cpu/efi/memory.h>
+
+#if defined (__i386__) || defined (__x86_64__)
+#include <grub/pci.h>
+#endif
+
+#define NEXT_MEMORY_DESCRIPTOR(desc, size) \
+ ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
+
+#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12)
+#define BYTES_TO_PAGES_DOWN(bytes) ((bytes) >> 12)
+#define PAGES_TO_BYTES(pages) ((pages) << 12)
+
+/* The size of a memory map obtained from the firmware. This must be
+ a multiplier of 4KB. */
+#define MEMORY_MAP_SIZE 0x3000
+
+/* The minimum and maximum heap size for GRUB itself. */
+#define MIN_HEAP_SIZE 0x100000
+#define MAX_HEAP_SIZE (1600 * 0x100000)
+
+static void *finish_mmap_buf = 0;
+static grub_efi_uintn_t finish_mmap_size = 0;
+static grub_efi_uintn_t finish_key = 0;
+static grub_efi_uintn_t finish_desc_size;
+static grub_efi_uint32_t finish_desc_version;
+int grub_efi_is_finished = 0;
+
+/*
+ * We need to roll back EFI allocations on exit. Remember allocations that
+ * we'll free on exit.
+ */
+struct efi_allocation;
+struct efi_allocation {
+ grub_efi_physical_address_t address;
+ grub_efi_uint64_t pages;
+ struct efi_allocation *next;
+};
+static struct efi_allocation *efi_allocated_memory;
+
+static void
+grub_efi_store_alloc (grub_efi_physical_address_t address,
+ grub_efi_uintn_t pages)
+{
+ grub_efi_boot_services_t *b;
+ struct efi_allocation *alloc;
+ grub_efi_status_t status;
+
+ b = grub_efi_system_table->boot_services;
+ status = efi_call_3 (b->allocate_pool, GRUB_EFI_LOADER_DATA,
+ sizeof(*alloc), (void**)&alloc);
+
+ if (status == GRUB_EFI_SUCCESS)
+ {
+ alloc->next = efi_allocated_memory;
+ alloc->address = address;
+ alloc->pages = pages;
+ efi_allocated_memory = alloc;
+ }
+ else
+ grub_printf ("Could not malloc memory to remember EFI allocation. "
+ "Exiting GRUB won't free all memory.\n");
+}
+
+static void
+grub_efi_drop_alloc (grub_efi_physical_address_t address,
+ grub_efi_uintn_t pages)
+{
+ struct efi_allocation *ea, *eap;
+ grub_efi_boot_services_t *b;
+
+ b = grub_efi_system_table->boot_services;
+
+ for (eap = NULL, ea = efi_allocated_memory; ea; eap = ea, ea = ea->next)
+ {
+ if (ea->address != address || ea->pages != pages)
+ continue;
+
+ /* Remove the current entry from the list. */
+ if (eap)
+ eap->next = ea->next;
+ else
+ efi_allocated_memory = ea->next;
+
+ /* Then free the memory backing it. */
+ efi_call_1 (b->free_pool, ea);
+
+ /* And leave, we're done. */
+ break;
+ }
+}
+
+/* Allocate pages. Return the pointer to the first of allocated pages. */
+void *
+grub_efi_allocate_pages_real (grub_efi_physical_address_t address,
+ grub_efi_uintn_t pages,
+ grub_efi_allocate_type_t alloctype,
+ grub_efi_memory_type_t memtype)
+{
+ grub_efi_status_t status;
+ grub_efi_boot_services_t *b;
+
+ /* Limit the memory access to less than 4GB for 32-bit platforms. */
+ if (address > GRUB_EFI_MAX_USABLE_ADDRESS)
+ {
+ char inv_addr[17], max_addr[17]; /* log16(2^64) = 16, plus NUL. */
+
+ grub_snprintf (inv_addr, sizeof (inv_addr) - 1, "%" PRIxGRUB_UINT64_T,
+ address);
+ grub_snprintf (max_addr, sizeof (max_addr) - 1, "%" PRIxGRUB_UINT64_T,
+ (grub_efi_uint64_t) GRUB_EFI_MAX_USABLE_ADDRESS);
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid memory address (0x%s > 0x%s)"), inv_addr, max_addr);
+ return NULL;
+ }
+
+ b = grub_efi_system_table->boot_services;
+ status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return NULL;
+ }
+
+ if (address == 0)
+ {
+ /* Uggh, the address 0 was allocated... This is too annoying,
+ so reallocate another one. */
+ address = GRUB_EFI_MAX_USABLE_ADDRESS;
+ status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address);
+ grub_efi_free_pages (0, pages);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return NULL;
+ }
+ }
+
+ grub_efi_store_alloc (address, pages);
+
+ return (void *) ((grub_addr_t) address);
+}
+
+void *
+grub_efi_allocate_any_pages (grub_efi_uintn_t pages)
+{
+ return grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS,
+ pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS,
+ GRUB_EFI_LOADER_DATA);
+}
+
+void *
+grub_efi_allocate_fixed (grub_efi_physical_address_t address,
+ grub_efi_uintn_t pages)
+{
+ return grub_efi_allocate_pages_real (address, pages,
+ GRUB_EFI_ALLOCATE_ADDRESS,
+ GRUB_EFI_LOADER_DATA);
+}
+
+/* Free pages starting from ADDRESS. */
+void
+grub_efi_free_pages (grub_efi_physical_address_t address,
+ grub_efi_uintn_t pages)
+{
+ grub_efi_boot_services_t *b;
+
+ b = grub_efi_system_table->boot_services;
+ efi_call_2 (b->free_pages, address, pages);
+
+ grub_efi_drop_alloc (address, pages);
+}
+
+#if defined (__i386__) || defined (__x86_64__)
+
+/* Helper for stop_broadcom. */
+static int
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ grub_pci_address_t addr;
+ grub_uint8_t cap;
+ grub_uint16_t pm_state;
+
+ if ((pciid & 0xffff) != GRUB_PCI_VENDOR_BROADCOM)
+ return 0;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ if (grub_pci_read (addr) >> 24 != GRUB_PCI_CLASS_NETWORK)
+ return 0;
+ cap = grub_pci_find_capability (dev, GRUB_PCI_CAP_POWER_MANAGEMENT);
+ if (!cap)
+ return 0;
+ addr = grub_pci_make_address (dev, cap + 4);
+ pm_state = grub_pci_read_word (addr);
+ pm_state = pm_state | 0x03;
+ grub_pci_write_word (addr, pm_state);
+ grub_pci_read_word (addr);
+ return 0;
+}
+
+static void
+stop_broadcom (void)
+{
+ grub_pci_iterate (find_card, NULL);
+}
+
+#endif
+
+grub_err_t
+grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf,
+ grub_efi_uintn_t *map_key,
+ grub_efi_uintn_t *efi_desc_size,
+ grub_efi_uint32_t *efi_desc_version)
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_status_t status;
+
+#if defined (__i386__) || defined (__x86_64__)
+ const grub_uint16_t apple[] = { 'A', 'p', 'p', 'l', 'e' };
+ int is_apple;
+
+ is_apple = (grub_memcmp (grub_efi_system_table->firmware_vendor,
+ apple, sizeof (apple)) == 0);
+#endif
+
+ while (1)
+ {
+ if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key,
+ &finish_desc_size, &finish_desc_version) < 0)
+ return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map");
+
+ if (outbuf && *outbuf_size < finish_mmap_size)
+ return grub_error (GRUB_ERR_IO, "memory map buffer is too small");
+
+ finish_mmap_buf = grub_malloc (finish_mmap_size);
+ if (!finish_mmap_buf)
+ return grub_errno;
+
+ if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &finish_key,
+ &finish_desc_size, &finish_desc_version) <= 0)
+ {
+ grub_free (finish_mmap_buf);
+ return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map");
+ }
+
+ b = grub_efi_system_table->boot_services;
+ status = efi_call_2 (b->exit_boot_services, grub_efi_image_handle,
+ finish_key);
+ if (status == GRUB_EFI_SUCCESS)
+ break;
+
+ if (status != GRUB_EFI_INVALID_PARAMETER)
+ {
+ grub_free (finish_mmap_buf);
+ return grub_error (GRUB_ERR_IO, "couldn't terminate EFI services");
+ }
+
+ grub_free (finish_mmap_buf);
+ grub_printf ("Trying to terminate EFI services again\n");
+ }
+ grub_efi_is_finished = 1;
+ if (outbuf_size)
+ *outbuf_size = finish_mmap_size;
+ if (outbuf)
+ grub_memcpy (outbuf, finish_mmap_buf, finish_mmap_size);
+ if (map_key)
+ *map_key = finish_key;
+ if (efi_desc_size)
+ *efi_desc_size = finish_desc_size;
+ if (efi_desc_version)
+ *efi_desc_version = finish_desc_version;
+
+#if defined (__i386__) || defined (__x86_64__)
+ if (is_apple)
+ stop_broadcom ();
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+/*
+ * To obtain the UEFI memory map, we must pass a buffer of sufficient size
+ * to hold the entire map. This function returns a sane start value for
+ * buffer size.
+ */
+grub_efi_uintn_t
+grub_efi_find_mmap_size (void)
+{
+ grub_efi_uintn_t mmap_size = 0;
+ grub_efi_uintn_t desc_size;
+
+ if (grub_efi_get_memory_map (&mmap_size, NULL, NULL, &desc_size, 0) < 0)
+ {
+ grub_error (GRUB_ERR_IO, "cannot get EFI memory map size");
+ return 0;
+ }
+
+ /*
+ * Add an extra page, since UEFI can alter the memory map itself on
+ * callbacks or explicit calls, including console output.
+ */
+ return ALIGN_UP (mmap_size + GRUB_EFI_PAGE_SIZE, GRUB_EFI_PAGE_SIZE);
+}
+
+/* Get the memory map as defined in the EFI spec. Return 1 if successful,
+ return 0 if partial, or return -1 if an error occurs. */
+int
+grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size,
+ grub_efi_memory_descriptor_t *memory_map,
+ grub_efi_uintn_t *map_key,
+ grub_efi_uintn_t *descriptor_size,
+ grub_efi_uint32_t *descriptor_version)
+{
+ grub_efi_status_t status;
+ 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)
+ {
+ int ret = 1;
+
+ if (memory_map != NULL)
+ {
+ if (*memory_map_size < finish_mmap_size)
+ {
+ grub_memcpy (memory_map, finish_mmap_buf, *memory_map_size);
+ ret = 0;
+ }
+ else
+ grub_memcpy (memory_map, finish_mmap_buf, finish_mmap_size);
+ }
+ else
+ {
+ /*
+ * Incomplete, no buffer to copy into, same as
+ * GRUB_EFI_BUFFER_TOO_SMALL below.
+ */
+ ret = 0;
+ }
+ *memory_map_size = finish_mmap_size;
+ if (map_key)
+ *map_key = finish_key;
+ if (descriptor_size)
+ *descriptor_size = finish_desc_size;
+ if (descriptor_version)
+ *descriptor_version = finish_desc_version;
+ return ret;
+ }
+
+ /* Allow some parameters to be missing. */
+ if (! map_key)
+ 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)
+ return 0;
+ else
+ return -1;
+}
+
+/* Sort the memory map in place. */
+static void
+sort_memory_map (grub_efi_memory_descriptor_t *memory_map,
+ grub_efi_uintn_t desc_size,
+ grub_efi_memory_descriptor_t *memory_map_end)
+{
+ grub_efi_memory_descriptor_t *d1;
+ grub_efi_memory_descriptor_t *d2;
+
+ for (d1 = memory_map;
+ d1 < memory_map_end;
+ d1 = NEXT_MEMORY_DESCRIPTOR (d1, desc_size))
+ {
+ grub_efi_memory_descriptor_t *max_desc = d1;
+
+ for (d2 = NEXT_MEMORY_DESCRIPTOR (d1, desc_size);
+ d2 < memory_map_end;
+ d2 = NEXT_MEMORY_DESCRIPTOR (d2, desc_size))
+ {
+ if (max_desc->num_pages < d2->num_pages)
+ max_desc = d2;
+ }
+
+ if (max_desc != d1)
+ {
+ grub_efi_memory_descriptor_t tmp;
+
+ tmp = *d1;
+ *d1 = *max_desc;
+ *max_desc = tmp;
+ }
+ }
+}
+
+/* Filter the descriptors. GRUB needs only available memory. */
+static grub_efi_memory_descriptor_t *
+filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
+ grub_efi_memory_descriptor_t *filtered_memory_map,
+ grub_efi_uintn_t desc_size,
+ grub_efi_memory_descriptor_t *memory_map_end)
+{
+ grub_efi_memory_descriptor_t *desc;
+ grub_efi_memory_descriptor_t *filtered_desc;
+
+ for (desc = memory_map, filtered_desc = filtered_memory_map;
+ desc < memory_map_end;
+ desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
+ {
+ if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
+#if 1
+ && desc->physical_start <= GRUB_EFI_MAX_USABLE_ADDRESS
+#endif
+ && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
+ && desc->num_pages != 0)
+ {
+ grub_memcpy (filtered_desc, desc, desc_size);
+
+ /* Avoid less than 1MB, because some loaders seem to be confused. */
+ if (desc->physical_start < 0x100000)
+ {
+ desc->num_pages -= BYTES_TO_PAGES (0x100000
+ - desc->physical_start);
+ desc->physical_start = 0x100000;
+ }
+
+#if 1
+ if (BYTES_TO_PAGES (filtered_desc->physical_start)
+ + filtered_desc->num_pages
+ > BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_USABLE_ADDRESS))
+ filtered_desc->num_pages
+ = (BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_USABLE_ADDRESS)
+ - BYTES_TO_PAGES (filtered_desc->physical_start));
+#endif
+
+ if (filtered_desc->num_pages == 0)
+ continue;
+
+ filtered_desc = NEXT_MEMORY_DESCRIPTOR (filtered_desc, desc_size);
+ }
+ }
+
+ return filtered_desc;
+}
+
+/* Return the total number of pages. */
+static grub_efi_uint64_t
+get_total_pages (grub_efi_memory_descriptor_t *memory_map,
+ grub_efi_uintn_t desc_size,
+ grub_efi_memory_descriptor_t *memory_map_end)
+{
+ grub_efi_memory_descriptor_t *desc;
+ grub_efi_uint64_t total = 0;
+
+ for (desc = memory_map;
+ desc < memory_map_end;
+ desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
+ total += desc->num_pages;
+
+ return total;
+}
+
+/* Add memory regions. */
+static void
+add_memory_regions (grub_efi_memory_descriptor_t *memory_map,
+ grub_efi_uintn_t desc_size,
+ grub_efi_memory_descriptor_t *memory_map_end,
+ grub_efi_uint64_t required_pages)
+{
+ grub_efi_memory_descriptor_t *desc;
+
+ for (desc = memory_map;
+ desc < memory_map_end;
+ desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
+ {
+ grub_efi_uint64_t pages;
+ grub_efi_physical_address_t start;
+ void *addr;
+
+ start = desc->physical_start;
+ pages = desc->num_pages;
+ if (pages > required_pages)
+ {
+ start += PAGES_TO_BYTES (pages - required_pages);
+ pages = required_pages;
+ }
+
+ addr = grub_efi_allocate_pages_real (start, pages,
+ GRUB_EFI_ALLOCATE_ADDRESS,
+ GRUB_EFI_LOADER_CODE);
+ if (! addr)
+ grub_fatal ("cannot allocate conventional memory %p with %u pages",
+ (void *) ((grub_addr_t) start),
+ (unsigned) pages);
+
+ grub_mm_init_region (addr, PAGES_TO_BYTES (pages));
+
+ required_pages -= pages;
+ if (required_pages == 0)
+ break;
+ }
+
+ if (required_pages > 0)
+ grub_fatal ("too little memory");
+}
+
+void
+grub_efi_memory_fini (void)
+{
+ /*
+ * Free all stale allocations. grub_efi_free_pages() will remove
+ * the found entry from the list and it will always find the first
+ * list entry (efi_allocated_memory is the list start). Hence we
+ * remove all entries from the list until none is left altogether.
+ */
+ while (efi_allocated_memory)
+ grub_efi_free_pages (efi_allocated_memory->address,
+ efi_allocated_memory->pages);
+}
+
+#if 0
+/* Print the memory map. */
+static void
+print_memory_map (grub_efi_memory_descriptor_t *memory_map,
+ grub_efi_uintn_t desc_size,
+ grub_efi_memory_descriptor_t *memory_map_end)
+{
+ grub_efi_memory_descriptor_t *desc;
+ int i;
+
+ for (desc = memory_map, i = 0;
+ desc < memory_map_end;
+ desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size), i++)
+ {
+ grub_printf ("MD: t=%x, p=%llx, v=%llx, n=%llx, a=%llx\n",
+ desc->type, desc->physical_start, desc->virtual_start,
+ desc->num_pages, desc->attribute);
+ }
+}
+#endif
+
+void
+grub_efi_mm_init (void)
+{
+ grub_efi_memory_descriptor_t *memory_map;
+ grub_efi_memory_descriptor_t *memory_map_end;
+ grub_efi_memory_descriptor_t *filtered_memory_map;
+ grub_efi_memory_descriptor_t *filtered_memory_map_end;
+ grub_efi_uintn_t map_size;
+ grub_efi_uintn_t desc_size;
+ grub_efi_uint64_t total_pages;
+ grub_efi_uint64_t required_pages;
+ int mm_status;
+
+ /* Prepare a memory region to store two memory maps. */
+ memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
+ if (! memory_map)
+ grub_fatal ("cannot allocate memory");
+
+ /* Obtain descriptors for available memory. */
+ map_size = MEMORY_MAP_SIZE;
+
+ mm_status = grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0);
+
+ if (mm_status == 0)
+ {
+ grub_efi_free_pages
+ ((grub_efi_physical_address_t) ((grub_addr_t) memory_map),
+ 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
+
+ /* Freeing/allocating operations may increase memory map size. */
+ map_size += desc_size * 32;
+
+ memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (map_size));
+ if (! memory_map)
+ grub_fatal ("cannot allocate memory");
+
+ mm_status = grub_efi_get_memory_map (&map_size, memory_map, 0,
+ &desc_size, 0);
+ }
+
+ if (mm_status < 0)
+ grub_fatal ("cannot get memory map");
+
+ memory_map_end = NEXT_MEMORY_DESCRIPTOR (memory_map, map_size);
+
+ filtered_memory_map = memory_map_end;
+
+ filtered_memory_map_end = filter_memory_map (memory_map, filtered_memory_map,
+ desc_size, memory_map_end);
+
+ /* By default, request a quarter of the available memory. */
+ total_pages = get_total_pages (filtered_memory_map, desc_size,
+ filtered_memory_map_end);
+ required_pages = (total_pages >> 2);
+ if (required_pages < BYTES_TO_PAGES (MIN_HEAP_SIZE))
+ required_pages = BYTES_TO_PAGES (MIN_HEAP_SIZE);
+ else if (required_pages > BYTES_TO_PAGES (MAX_HEAP_SIZE))
+ required_pages = BYTES_TO_PAGES (MAX_HEAP_SIZE);
+
+ /* Sort the filtered descriptors, so that GRUB can allocate pages
+ from smaller regions. */
+ sort_memory_map (filtered_memory_map, desc_size, filtered_memory_map_end);
+
+ /* Allocate memory regions for GRUB's memory management. */
+ add_memory_regions (filtered_memory_map, desc_size,
+ filtered_memory_map_end, required_pages);
+
+#if 0
+ /* For debug. */
+ map_size = MEMORY_MAP_SIZE;
+
+ if (grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0) < 0)
+ grub_fatal ("cannot get memory map");
+
+ grub_printf ("printing memory map\n");
+ print_memory_map (memory_map, desc_size,
+ NEXT_MEMORY_DESCRIPTOR (memory_map, map_size));
+ grub_fatal ("Debug. ");
+#endif
+
+ /* Release the memory maps. */
+ grub_efi_free_pages ((grub_addr_t) memory_map,
+ 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
+}
+
+#if defined (__aarch64__) || defined (__arm__) || defined (__riscv)
+grub_err_t
+grub_efi_get_ram_base(grub_addr_t *base_addr)
+{
+ grub_efi_memory_descriptor_t *memory_map, *desc;
+ grub_efi_uintn_t memory_map_size, desc_size;
+ int ret;
+
+ memory_map_size = grub_efi_find_mmap_size();
+
+ memory_map = grub_malloc (memory_map_size);
+ if (! memory_map)
+ return GRUB_ERR_OUT_OF_MEMORY;
+ ret = grub_efi_get_memory_map (&memory_map_size, memory_map, NULL,
+ &desc_size, NULL);
+
+ if (ret < 1)
+ return GRUB_ERR_BUG;
+
+ for (desc = memory_map, *base_addr = GRUB_EFI_MAX_USABLE_ADDRESS;
+ (grub_addr_t) desc < ((grub_addr_t) memory_map + memory_map_size);
+ desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
+ if (desc->attribute & GRUB_EFI_MEMORY_WB)
+ *base_addr = grub_min (*base_addr, desc->physical_start);
+
+ grub_free(memory_map);
+
+ return GRUB_ERR_NONE;
+}
+#endif
diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c
new file mode 100644
index 0000000..c52ec62
--- /dev/null
+++ b/grub-core/kern/efi/sb.c
@@ -0,0 +1,188 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2020 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * UEFI Secure Boot related checkings.
+ */
+
+#include <grub/efi/efi.h>
+#include <grub/efi/pe32.h>
+#include <grub/efi/sb.h>
+#include <grub/env.h>
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/i386/linux.h>
+#include <grub/kernel.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/verify.h>
+
+static grub_efi_guid_t shim_lock_guid = GRUB_EFI_SHIM_LOCK_GUID;
+
+/*
+ * Determine whether we're in secure boot mode.
+ *
+ * Please keep the logic in sync with the Linux kernel,
+ * drivers/firmware/efi/libstub/secureboot.c:efi_get_secureboot().
+ */
+grub_uint8_t
+grub_efi_get_secureboot (void)
+{
+ static grub_efi_guid_t efi_variable_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+ grub_efi_status_t status;
+ grub_efi_uint32_t attr = 0;
+ grub_size_t size = 0;
+ grub_uint8_t *secboot = NULL;
+ grub_uint8_t *setupmode = NULL;
+ grub_uint8_t *moksbstate = NULL;
+ grub_uint8_t secureboot = GRUB_EFI_SECUREBOOT_MODE_UNKNOWN;
+ const char *secureboot_str = "UNKNOWN";
+
+ status = grub_efi_get_variable ("SecureBoot", &efi_variable_guid,
+ &size, (void **) &secboot);
+
+ if (status == GRUB_EFI_NOT_FOUND)
+ {
+ secureboot = GRUB_EFI_SECUREBOOT_MODE_DISABLED;
+ goto out;
+ }
+
+ if (status != GRUB_EFI_SUCCESS)
+ goto out;
+
+ status = grub_efi_get_variable ("SetupMode", &efi_variable_guid,
+ &size, (void **) &setupmode);
+
+ if (status != GRUB_EFI_SUCCESS)
+ goto out;
+
+ if ((*secboot == 0) || (*setupmode == 1))
+ {
+ secureboot = GRUB_EFI_SECUREBOOT_MODE_DISABLED;
+ goto out;
+ }
+
+ /*
+ * See if a user has put the shim into insecure mode. If so, and if the
+ * variable doesn't have the runtime attribute set, we might as well
+ * honor that.
+ */
+ status = grub_efi_get_variable_with_attributes ("MokSBState", &shim_lock_guid,
+ &size, (void **) &moksbstate, &attr);
+
+ /* If it fails, we don't care why. Default to secure. */
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ secureboot = GRUB_EFI_SECUREBOOT_MODE_ENABLED;
+ goto out;
+ }
+
+ if (!(attr & GRUB_EFI_VARIABLE_RUNTIME_ACCESS) && *moksbstate == 1)
+ {
+ secureboot = GRUB_EFI_SECUREBOOT_MODE_DISABLED;
+ goto out;
+ }
+
+ secureboot = GRUB_EFI_SECUREBOOT_MODE_ENABLED;
+
+ out:
+ grub_free (moksbstate);
+ grub_free (setupmode);
+ grub_free (secboot);
+
+ if (secureboot == GRUB_EFI_SECUREBOOT_MODE_DISABLED)
+ secureboot_str = "Disabled";
+ else if (secureboot == GRUB_EFI_SECUREBOOT_MODE_ENABLED)
+ secureboot_str = "Enabled";
+
+ grub_dprintf ("efi", "UEFI Secure Boot state: %s\n", secureboot_str);
+
+ return secureboot;
+}
+
+static grub_err_t
+shim_lock_verifier_init (grub_file_t io __attribute__ ((unused)),
+ enum grub_file_type type,
+ void **context __attribute__ ((unused)),
+ enum grub_verify_flags *flags)
+{
+ *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION;
+
+ switch (type & GRUB_FILE_TYPE_MASK)
+ {
+ case GRUB_FILE_TYPE_LINUX_KERNEL:
+ case GRUB_FILE_TYPE_MULTIBOOT_KERNEL:
+ case GRUB_FILE_TYPE_BSD_KERNEL:
+ case GRUB_FILE_TYPE_XNU_KERNEL:
+ case GRUB_FILE_TYPE_PLAN9_KERNEL:
+ case GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE:
+ *flags = GRUB_VERIFY_FLAGS_SINGLE_CHUNK;
+
+ /* Fall through. */
+
+ default:
+ return GRUB_ERR_NONE;
+ }
+}
+
+static grub_err_t
+shim_lock_verifier_write (void *context __attribute__ ((unused)), void *buf, grub_size_t size)
+{
+ grub_efi_shim_lock_protocol_t *sl = grub_efi_locate_protocol (&shim_lock_guid, 0);
+
+ if (!sl)
+ return grub_error (GRUB_ERR_ACCESS_DENIED, N_("shim_lock protocol not found"));
+
+ if (sl->verify (buf, size) != GRUB_EFI_SUCCESS)
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad shim signature"));
+
+ return GRUB_ERR_NONE;
+}
+
+struct grub_file_verifier shim_lock_verifier =
+ {
+ .name = "shim_lock_verifier",
+ .init = shim_lock_verifier_init,
+ .write = shim_lock_verifier_write
+ };
+
+void
+grub_shim_lock_verifier_setup (void)
+{
+ struct grub_module_header *header;
+ grub_efi_shim_lock_protocol_t *sl =
+ grub_efi_locate_protocol (&shim_lock_guid, 0);
+
+ /* shim_lock is missing, check if GRUB image is built with --disable-shim-lock. */
+ if (!sl)
+ {
+ FOR_MODULES (header)
+ {
+ if (header->type == OBJ_TYPE_DISABLE_SHIM_LOCK)
+ return;
+ }
+ }
+
+ /* Secure Boot is off. Do not load shim_lock. */
+ if (grub_efi_get_secureboot () != GRUB_EFI_SECUREBOOT_MODE_ENABLED)
+ return;
+
+ /* Enforce shim_lock_verifier. */
+ grub_verifier_register (&shim_lock_verifier);
+
+ grub_env_set ("shim_lock", "y");
+ grub_env_export ("shim_lock");
+}
diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c
new file mode 100644
index 0000000..9d7149b
--- /dev/null
+++ b/grub-core/kern/elf.c
@@ -0,0 +1,212 @@
+/* elf.c - load ELF files */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/elf.h>
+#include <grub/elfload.h>
+#include <grub/file.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+
+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)
+{
+ Elf32_Ehdr *e = &elf->ehdr.ehdr32;
+
+ 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)
+ 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;
+}
+
+grub_err_t
+grub_elf_close (grub_elf_t elf)
+{
+ grub_file_t file = elf->file;
+
+ grub_free (elf->phdrs);
+ grub_free (elf->filename);
+ grub_free (elf);
+
+ if (file)
+ grub_file_close (file);
+
+ return grub_errno;
+}
+
+grub_elf_t
+grub_elf_file (grub_file_t file, const char *filename)
+{
+ grub_elf_t elf;
+
+ elf = grub_zalloc (sizeof (*elf));
+ if (! elf)
+ return 0;
+
+ elf->file = file;
+
+ if (grub_file_seek (elf->file, 0) == (grub_off_t) -1)
+ goto fail;
+
+ if (grub_file_read (elf->file, &elf->ehdr, sizeof (elf->ehdr))
+ != sizeof (elf->ehdr))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
+ filename);
+ goto fail;
+ }
+
+ if (grub_elf_check_header (elf))
+ goto fail;
+
+ elf->filename = grub_strdup (filename);
+ if (!elf->filename)
+ goto fail;
+
+ return elf;
+
+fail:
+ grub_free (elf->filename);
+ grub_free (elf->phdrs);
+ grub_free (elf);
+ return 0;
+}
+
+grub_elf_t
+grub_elf_open (const char *name, enum grub_file_type type)
+{
+ grub_file_t file;
+ grub_elf_t elf;
+
+ file = grub_file_open (name, type);
+ if (! file)
+ return 0;
+
+ elf = grub_elf_file (file, name);
+ if (! elf)
+ grub_file_close (file);
+
+ return elf;
+}
+
+
+#define grub_swap_bytes_halfXX grub_swap_bytes16
+#define grub_swap_bytes_wordXX grub_swap_bytes32
+
+/* 32-bit */
+#define ehdrXX ehdr32
+#define ELFCLASSXX ELFCLASS32
+#define ElfXX_Addr Elf32_Addr
+#define grub_elfXX_size grub_elf32_size
+#define grub_elfXX_load grub_elf32_load
+#define FOR_ELFXX_PHDRS FOR_ELF32_PHDRS
+#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"
+
+#undef ehdrXX
+#undef ELFCLASSXX
+#undef ElfXX_Addr
+#undef grub_elfXX_size
+#undef grub_elfXX_load
+#undef FOR_ELFXX_PHDRS
+#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 */
+#define ehdrXX ehdr64
+#define ELFCLASSXX ELFCLASS64
+#define ElfXX_Addr Elf64_Addr
+#define grub_elfXX_size grub_elf64_size
+#define grub_elfXX_load grub_elf64_load
+#define FOR_ELFXX_PHDRS FOR_ELF64_PHDRS
+#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
new file mode 100644
index 0000000..1859d18
--- /dev/null
+++ b/grub-core/kern/elfXX.c
@@ -0,0 +1,207 @@
+int
+grub_elf_is_elfXX (grub_elf_t elf)
+{
+ return elf->ehdr.ehdrXX.e_ident[EI_CLASS] == ELFCLASSXX;
+}
+
+grub_err_t
+grub_elfXX_load_phdrs (grub_elf_t elf)
+{
+ grub_ssize_t phdrs_size;
+
+ if (elf->phdrs)
+ return GRUB_ERR_NONE;
+
+ 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,
+ (unsigned long) phdrs_size);
+
+ elf->phdrs = grub_malloc (phdrs_size);
+ if (! elf->phdrs)
+ return grub_errno;
+
+ if ((grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_phoff) == (grub_off_t) -1)
+ || (grub_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
+ elf->filename);
+ 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;
+}
+
+/* Calculate the amount of memory spanned by the segments. */
+grub_size_t
+grub_elfXX_size (grub_elf_t elf,
+ ElfXX_Addr *base, grub_uintXX_t *max_align)
+{
+ ElfXX_Addr segments_start = (ElfXX_Addr) -1;
+ ElfXX_Addr segments_end = 0;
+ int nr_phdrs = 0;
+ grub_uint32_t curr_align = 1;
+ ElfXX_Phdr *phdr;
+
+ /* Run through the program headers to calculate the total memory size we
+ * should claim. */
+ FOR_ELFXX_PHDRS (elf, phdr)
+ {
+ /* Only consider loadable segments. */
+ if (phdr->p_type != PT_LOAD)
+ continue;
+ nr_phdrs++;
+ if (phdr->p_paddr < segments_start)
+ segments_start = phdr->p_paddr;
+ if (phdr->p_paddr + phdr->p_memsz > segments_end)
+ segments_end = phdr->p_paddr + phdr->p_memsz;
+ if (curr_align < phdr->p_align)
+ curr_align = phdr->p_align;
+ }
+
+ if (base)
+ *base = 0;
+
+ if (nr_phdrs == 0)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "no program headers present");
+ return 0;
+ }
+
+ if (segments_end < segments_start)
+ {
+ /* Very bad addresses. */
+ grub_error (GRUB_ERR_BAD_OS, "bad program header load addresses");
+ return 0;
+ }
+
+ if (base)
+ *base = segments_start;
+ if (max_align)
+ *max_align = curr_align;
+ return segments_end - segments_start;
+}
+
+grub_err_t
+grub_elfXX_load (grub_elf_t elf, const char *filename,
+ void *load_offset, enum grub_elf_load_flags load_flags,
+ grub_addr_t *base, grub_size_t *size)
+{
+ grub_addr_t load_base = (grub_addr_t) -1ULL;
+ grub_size_t load_size = 0;
+ ElfXX_Phdr *phdr;
+
+ FOR_ELFXX_PHDRS(elf, phdr)
+ {
+ grub_addr_t load_addr;
+
+ if (phdr->p_type != PT_LOAD && !((load_flags & GRUB_ELF_LOAD_FLAGS_LOAD_PT_DYNAMIC) && phdr->p_type == PT_DYNAMIC))
+ continue;
+
+ load_addr = (grub_addr_t) phdr->p_paddr;
+ switch (load_flags & GRUB_ELF_LOAD_FLAGS_BITS)
+ {
+ case GRUB_ELF_LOAD_FLAGS_ALL_BITS:
+ break;
+ case GRUB_ELF_LOAD_FLAGS_28BITS:
+ load_addr &= 0xFFFFFFF;
+ break;
+ case GRUB_ELF_LOAD_FLAGS_30BITS:
+ load_addr &= 0x3FFFFFFF;
+ break;
+ case GRUB_ELF_LOAD_FLAGS_62BITS:
+ load_addr &= 0x3FFFFFFFFFFFFFFFULL;
+ break;
+ }
+ load_addr += (grub_addr_t) load_offset;
+
+ if (load_addr < load_base)
+ load_base = load_addr;
+
+ grub_dprintf ("elf", "Loading segment at 0x%llx, size 0x%llx\n",
+ (unsigned long long) load_addr,
+ (unsigned long long) phdr->p_memsz);
+
+ if (grub_file_seek (elf->file, phdr->p_offset) == (grub_off_t) -1)
+ return grub_errno;
+
+ if (phdr->p_filesz)
+ {
+ grub_ssize_t read;
+ read = grub_file_read (elf->file, (void *) load_addr, phdr->p_filesz);
+ if (read != (grub_ssize_t) phdr->p_filesz)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
+ filename);
+ return grub_errno;
+ }
+ }
+
+ if (phdr->p_filesz < phdr->p_memsz)
+ grub_memset ((void *) (grub_addr_t) (load_addr + phdr->p_filesz),
+ 0, phdr->p_memsz - phdr->p_filesz);
+
+ load_size += phdr->p_memsz;
+ }
+
+ if (base)
+ *base = load_base;
+ if (size)
+ *size = load_size;
+
+ 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
new file mode 100644
index 0000000..1668858
--- /dev/null
+++ b/grub-core/kern/emu/argp_common.c
@@ -0,0 +1,41 @@
+/* grub-setup.c - make GRUB usable */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,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 <config.h>
+#include <config-util.h>
+
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+
+#define _GNU_SOURCE 1
+#include <stdlib.h>
+#include <unistd.h>
+#include <progname.h>
+#include <argp.h>
+
+/* Print the version information. */
+static void
+print_version (FILE *stream, struct argp_state *state)
+{
+ fprintf (stream, "%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
+}
+void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+
+/* Set the bug report address */
+const char *argp_program_bug_address = "<"PACKAGE_BUGREPORT">";
diff --git a/grub-core/kern/emu/cache.c b/grub-core/kern/emu/cache.c
new file mode 100644
index 0000000..113682c
--- /dev/null
+++ b/grub-core/kern/emu/cache.c
@@ -0,0 +1,35 @@
+#ifndef GRUB_MACHINE_EMU
+#error "This source is only meant for grub-emu platform"
+#endif
+
+#include <grub/cache.h>
+
+#if defined(__ia64__)
+#include "../ia64/cache.c"
+#elif defined (__arm__) || defined (__aarch64__)
+
+void __clear_cache (void *beg, void *end);
+
+void
+grub_arch_sync_caches (void *address, grub_size_t len)
+{
+ __clear_cache (address, (char *) address + len);
+}
+
+#elif defined (__mips__)
+void _flush_cache (void *address, grub_size_t len, int type);
+
+void
+grub_arch_sync_caches (void *address, grub_size_t len)
+{
+ return _flush_cache (address, len, 0);
+}
+
+#elif defined(__riscv)
+void
+grub_arch_sync_caches (void *address, grub_size_t len)
+{
+}
+
+#endif
+
diff --git a/grub-core/kern/emu/cache_s.S b/grub-core/kern/emu/cache_s.S
new file mode 100644
index 0000000..2245cdd
--- /dev/null
+++ b/grub-core/kern/emu/cache_s.S
@@ -0,0 +1,15 @@
+#ifndef GRUB_MACHINE_EMU
+#error "This source is only meant for grub-emu platform"
+#endif
+
+#if defined(__i386__) || defined(__x86_64__)
+/* Nothing is necessary. */
+#elif defined(__sparc__)
+#include "../sparc64/cache.S"
+#elif defined(__powerpc__)
+#include "../powerpc/cache.S"
+#elif defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \
+ defined(__mips__) || defined(__riscv)
+#else
+#error "No target cpu type is defined"
+#endif
diff --git a/grub-core/kern/emu/full.c b/grub-core/kern/emu/full.c
new file mode 100644
index 0000000..e8d63b1
--- /dev/null
+++ b/grub-core/kern/emu/full.c
@@ -0,0 +1,69 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/dl.h>
+#include <grub/env.h>
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/disk.h>
+
+const int grub_no_modules = 1;
+
+void
+grub_register_exported_symbols (void)
+{
+}
+
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ (void) ehdr;
+ return GRUB_ERR_BAD_MODULE;
+}
+
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ (void) mod;
+ (void) ehdr;
+ (void) s;
+ (void) seg;
+ return GRUB_ERR_BAD_MODULE;
+}
+
+#if !defined (__i386__) && !defined (__x86_64__)
+grub_err_t
+grub_arch_dl_get_tramp_got_size (const void *ehdr __attribute__ ((unused)),
+ grub_size_t *tramp, grub_size_t *got)
+{
+ *tramp = 0;
+ *got = 0;
+ return GRUB_ERR_BAD_MODULE;
+}
+#endif
+
+#ifdef GRUB_LINKER_HAVE_INIT
+void
+grub_arch_dl_init_linker (void)
+{
+}
+#endif
+
diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c
new file mode 100644
index 0000000..d975265
--- /dev/null
+++ b/grub-core/kern/emu/hostdisk.c
@@ -0,0 +1,686 @@
+/* hostdisk.c - emulate biosdisk */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+#ifdef __linux__
+# include <sys/ioctl.h> /* ioctl */
+# include <sys/mount.h>
+# ifndef BLKFLSBUF
+# define BLKFLSBUF _IO (0x12,97) /* flush buffer cache */
+# endif /* ! BLKFLSBUF */
+#endif /* __linux__ */
+
+static struct
+{
+ char *drive;
+ char *device;
+ int device_map;
+} map[256];
+
+static int
+unescape_cmp (const char *a, const char *b_escaped)
+{
+ while (*a || *b_escaped)
+ {
+ if (*b_escaped == '\\' && b_escaped[1] != 0)
+ b_escaped++;
+ if (*a < *b_escaped)
+ return -1;
+ if (*a > *b_escaped)
+ return +1;
+ a++;
+ b_escaped++;
+ }
+ if (*a)
+ return +1;
+ if (*b_escaped)
+ return -1;
+ return 0;
+}
+
+static int
+find_grub_drive (const char *name)
+{
+ unsigned int i;
+
+ if (name)
+ {
+ for (i = 0; i < ARRAY_SIZE (map); i++)
+ if (map[i].drive && unescape_cmp (map[i].drive, name) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+static int
+find_free_slot (void)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE (map); i++)
+ if (! map[i].drive)
+ return i;
+
+ return -1;
+}
+
+static int
+grub_util_biosdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
+ grub_disk_pull_t pull)
+{
+ unsigned i;
+
+ if (pull != GRUB_DISK_PULL_NONE)
+ return 0;
+
+ for (i = 0; i < ARRAY_SIZE (map); i++)
+ if (map[i].drive && hook (map[i].drive, hook_data))
+ return 1;
+
+ return 0;
+}
+
+static grub_err_t
+grub_util_biosdisk_open (const char *name, grub_disk_t disk)
+{
+ int drive;
+ struct grub_util_hostdisk_data *data;
+
+ drive = find_grub_drive (name);
+ grub_util_info ("drive = %d", drive);
+ if (drive < 0)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "no mapping exists for `%s'", name);
+
+ disk->id = drive;
+ disk->data = data = xmalloc (sizeof (struct grub_util_hostdisk_data));
+ data->dev = NULL;
+ data->access_mode = 0;
+ data->fd = GRUB_UTIL_FD_INVALID;
+ data->is_disk = 0;
+ data->device_map = map[drive].device_map;
+
+ /* Get the size. */
+ {
+ grub_util_fd_t fd;
+
+ fd = grub_util_fd_open (map[drive].device, GRUB_UTIL_FD_O_RDONLY);
+
+ if (!GRUB_UTIL_FD_IS_VALID(fd))
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("cannot open `%s': %s"),
+ map[drive].device, grub_util_fd_strerror ());
+
+ disk->total_sectors = grub_util_get_fd_size (fd, map[drive].device,
+ &disk->log_sector_size);
+ disk->total_sectors >>= disk->log_sector_size;
+ disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
+
+#if GRUB_UTIL_FD_STAT_IS_FUNCTIONAL
+ {
+ struct stat st;
+# if GRUB_DISK_DEVS_ARE_CHAR
+ if (fstat (fd, &st) >= 0 && S_ISCHR (st.st_mode))
+# else
+ if (fstat (fd, &st) >= 0 && S_ISBLK (st.st_mode))
+# endif
+ data->is_disk = 1;
+ }
+#endif
+
+ grub_util_fd_close (fd);
+
+ grub_util_info ("the size of %s is %" GRUB_HOST_PRIuLONG_LONG,
+ name, (unsigned long long) disk->total_sectors);
+
+ return GRUB_ERR_NONE;
+ }
+}
+
+const char *
+grub_hostdisk_os_dev_to_grub_drive (const char *os_disk, int add)
+{
+ unsigned int i;
+ char *canon;
+
+ canon = grub_canonicalize_file_name (os_disk);
+ if (!canon)
+ canon = xstrdup (os_disk);
+
+ for (i = 0; i < ARRAY_SIZE (map); i++)
+ if (! map[i].device)
+ break;
+ else if (strcmp (map[i].device, canon) == 0)
+ {
+ free (canon);
+ return map[i].drive;
+ }
+
+ if (!add)
+ {
+ free (canon);
+ return NULL;
+ }
+
+ if (i == ARRAY_SIZE (map))
+ /* TRANSLATORS: it refers to the lack of free slots. */
+ grub_util_error ("%s", _("device count exceeds limit"));
+
+ map[i].device = canon;
+ map[i].drive = xmalloc (sizeof ("hostdisk/") + strlen (os_disk));
+ strcpy (map[i].drive, "hostdisk/");
+ strcpy (map[i].drive + sizeof ("hostdisk/") - 1, os_disk);
+ map[i].device_map = 0;
+
+ grub_hostdisk_flush_initial_buffer (os_disk);
+
+ return map[i].drive;
+}
+
+#ifndef __linux__
+grub_util_fd_t
+grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags,
+ grub_disk_addr_t *max)
+{
+ grub_util_fd_t fd;
+ struct grub_util_hostdisk_data *data = disk->data;
+
+ *max = ~0ULL;
+
+ flags |= GRUB_UTIL_FD_O_SYNC;
+
+ if (data->dev && strcmp (data->dev, map[disk->id].device) == 0 &&
+ data->access_mode == (flags & O_ACCMODE))
+ {
+ grub_dprintf ("hostdisk", "reusing open device `%s'\n", data->dev);
+ fd = data->fd;
+ }
+ else
+ {
+ free (data->dev);
+ data->dev = 0;
+ if (GRUB_UTIL_FD_IS_VALID(data->fd))
+ {
+ if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY)
+ grub_util_fd_sync (data->fd);
+ grub_util_fd_close (data->fd);
+ data->fd = GRUB_UTIL_FD_INVALID;
+ }
+
+ fd = grub_util_fd_open (map[disk->id].device, flags);
+ if (GRUB_UTIL_FD_IS_VALID(fd))
+ {
+ data->dev = xstrdup (map[disk->id].device);
+ data->access_mode = (flags & O_ACCMODE);
+ data->fd = fd;
+ }
+ }
+
+ if (!GRUB_UTIL_FD_IS_VALID(data->fd))
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot open `%s': %s"),
+ map[disk->id].device, grub_util_fd_strerror ());
+ return GRUB_UTIL_FD_INVALID;
+ }
+
+ if (grub_util_fd_seek (fd, sector << disk->log_sector_size))
+ {
+ grub_util_fd_close (fd);
+ grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot seek `%s': %s"),
+ map[disk->id].device, grub_util_fd_strerror ());
+
+ return GRUB_UTIL_FD_INVALID;
+ }
+
+ return fd;
+}
+#endif
+
+
+static grub_err_t
+grub_util_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf)
+{
+ while (size)
+ {
+ grub_util_fd_t fd;
+ grub_disk_addr_t max = ~0ULL;
+ fd = grub_util_fd_open_device (disk, sector, GRUB_UTIL_FD_O_RDONLY, &max);
+ if (!GRUB_UTIL_FD_IS_VALID (fd))
+ return grub_errno;
+
+#ifdef __linux__
+ if (sector == 0)
+ /* Work around a bug in Linux ez remapping. Linux remaps all
+ sectors that are read together with the MBR in one read. It
+ should only remap the MBR, so we split the read in two
+ parts. -jochen */
+ max = 1;
+#endif /* __linux__ */
+
+ if (max > size)
+ max = size;
+
+ if (grub_util_fd_read (fd, buf, max << disk->log_sector_size)
+ != (ssize_t) (max << disk->log_sector_size))
+ return grub_error (GRUB_ERR_READ_ERROR, N_("cannot read `%s': %s"),
+ map[disk->id].device, grub_util_fd_strerror ());
+ size -= max;
+ buf += (max << disk->log_sector_size);
+ sector += max;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_util_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_size_t size, const char *buf)
+{
+ while (size)
+ {
+ grub_util_fd_t fd;
+ grub_disk_addr_t max = ~0ULL;
+ fd = grub_util_fd_open_device (disk, sector, GRUB_UTIL_FD_O_WRONLY, &max);
+ if (!GRUB_UTIL_FD_IS_VALID (fd))
+ return grub_errno;
+
+#ifdef __linux__
+ if (sector == 0)
+ /* Work around a bug in Linux ez remapping. Linux remaps all
+ sectors that are write together with the MBR in one write. It
+ should only remap the MBR, so we split the write in two
+ parts. -jochen */
+ max = 1;
+#endif /* __linux__ */
+
+ if (max > size)
+ max = size;
+
+ if (grub_util_fd_write (fd, buf, max << disk->log_sector_size)
+ != (ssize_t) (max << disk->log_sector_size))
+ return grub_error (GRUB_ERR_WRITE_ERROR, N_("cannot write to `%s': %s"),
+ map[disk->id].device, grub_util_fd_strerror ());
+ size -= max;
+ buf += (max << disk->log_sector_size);
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_util_biosdisk_flush (struct grub_disk *disk)
+{
+ struct grub_util_hostdisk_data *data = disk->data;
+
+ if (disk->dev->id != GRUB_DISK_DEVICE_BIOSDISK_ID)
+ return GRUB_ERR_NONE;
+ if (!GRUB_UTIL_FD_IS_VALID (data->fd))
+ {
+ grub_disk_addr_t max;
+ data->fd = grub_util_fd_open_device (disk, 0, GRUB_UTIL_FD_O_RDONLY, &max);
+ if (!GRUB_UTIL_FD_IS_VALID (data->fd))
+ return grub_errno;
+ }
+ grub_util_fd_sync (data->fd);
+#ifdef __linux__
+ if (data->is_disk)
+ ioctl (data->fd, BLKFLSBUF, 0);
+#endif
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_util_biosdisk_close (struct grub_disk *disk)
+{
+ struct grub_util_hostdisk_data *data = disk->data;
+
+ free (data->dev);
+ if (GRUB_UTIL_FD_IS_VALID (data->fd))
+ {
+ if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY)
+ grub_util_biosdisk_flush (disk);
+ grub_util_fd_close (data->fd);
+ }
+ free (data);
+}
+
+static struct grub_disk_dev grub_util_biosdisk_dev =
+ {
+ .name = "hostdisk",
+ .id = GRUB_DISK_DEVICE_HOSTDISK_ID,
+ .disk_iterate = grub_util_biosdisk_iterate,
+ .disk_open = grub_util_biosdisk_open,
+ .disk_close = grub_util_biosdisk_close,
+ .disk_read = grub_util_biosdisk_read,
+ .disk_write = grub_util_biosdisk_write,
+ .next = 0
+ };
+
+static int
+grub_util_check_file_presence (const char *p)
+{
+#if !GRUB_UTIL_FD_STAT_IS_FUNCTIONAL
+ grub_util_fd_t h;
+ h = grub_util_fd_open (p, GRUB_UTIL_FD_O_RDONLY);
+ if (!GRUB_UTIL_FD_IS_VALID(h))
+ return 0;
+ grub_util_fd_close (h);
+ return 1;
+#else
+ struct stat st;
+
+ if (stat (p, &st) == -1)
+ return 0;
+ return 1;
+#endif
+}
+
+static void
+read_device_map (const char *dev_map)
+{
+ FILE *fp;
+ char buf[1024]; /* XXX */
+ int lineno = 0;
+
+ if (!dev_map || dev_map[0] == '\0')
+ {
+ grub_util_info ("no device.map");
+ return;
+ }
+
+ fp = grub_util_fopen (dev_map, "r");
+ if (! fp)
+ {
+ grub_util_info (_("cannot open `%s': %s"), dev_map, strerror (errno));
+ return;
+ }
+
+ while (fgets (buf, sizeof (buf), fp))
+ {
+ char *p = buf;
+ char *e;
+ char *drive_e, *drive_p;
+ int drive;
+
+ lineno++;
+
+ /* Skip leading spaces. */
+ while (*p && grub_isspace (*p))
+ p++;
+
+ /* If the first character is `#' or NUL, skip this line. */
+ if (*p == '\0' || *p == '#')
+ continue;
+
+ if (*p != '(')
+ {
+ char *tmp;
+ tmp = xasprintf (_("missing `%c' symbol"), '(');
+ grub_util_error ("%s:%d: %s", dev_map, lineno, tmp);
+ }
+
+ p++;
+ /* Find a free slot. */
+ drive = find_free_slot ();
+ if (drive < 0)
+ grub_util_error ("%s:%d: %s", dev_map, lineno, _("device count exceeds limit"));
+
+ e = p;
+ p = strchr (p, ')');
+ if (! p)
+ {
+ char *tmp;
+ tmp = xasprintf (_("missing `%c' symbol"), ')');
+ grub_util_error ("%s:%d: %s", dev_map, lineno, tmp);
+ }
+
+ map[drive].drive = 0;
+ if ((e[0] == 'f' || e[0] == 'h' || e[0] == 'c') && e[1] == 'd')
+ {
+ char *ptr;
+ for (ptr = e + 2; ptr < p; ptr++)
+ if (!grub_isdigit (*ptr))
+ break;
+ if (ptr == p)
+ {
+ map[drive].drive = xmalloc (p - e + sizeof ('\0'));
+ strncpy (map[drive].drive, e, p - e + sizeof ('\0'));
+ map[drive].drive[p - e] = '\0';
+ }
+ if (*ptr == ',')
+ {
+ *p = 0;
+
+ /* TRANSLATORS: Only one entry is ignored. However the suggestion
+ is to correct/delete the whole file.
+ device.map is a file indicating which
+ devices are available at boot time. Fedora populated it with
+ entries like (hd0,1) /dev/sda1 which would mean that every
+ partition is a separate disk for BIOS. Such entries were
+ inactive in GRUB due to its bug which is now gone. Without
+ this additional check these entries would be harmful now.
+ */
+ grub_util_warn (_("the device.map entry `%s' is invalid. "
+ "Ignoring it. Please correct or "
+ "delete your device.map"), e);
+ continue;
+ }
+ }
+ drive_e = e;
+ drive_p = p;
+ map[drive].device_map = 1;
+
+ p++;
+ /* Skip leading spaces. */
+ while (*p && grub_isspace (*p))
+ p++;
+
+ if (*p == '\0')
+ grub_util_error ("%s:%d: %s", dev_map, lineno, _("filename expected"));
+
+ /* NUL-terminate the filename. */
+ e = p;
+ while (*e && ! grub_isspace (*e))
+ e++;
+ *e = '\0';
+
+ if (!grub_util_check_file_presence (p))
+ {
+ free (map[drive].drive);
+ map[drive].drive = NULL;
+ grub_util_info ("Cannot stat `%s', skipping", p);
+ continue;
+ }
+
+ /* 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 = grub_canonicalize_file_name (p);
+ if (! map[drive].device)
+ map[drive].device = xstrdup (p);
+
+ if (!map[drive].drive)
+ {
+ char c;
+ map[drive].drive = xmalloc (sizeof ("hostdisk/") + strlen (p));
+ memcpy (map[drive].drive, "hostdisk/", sizeof ("hostdisk/") - 1);
+ strcpy (map[drive].drive + sizeof ("hostdisk/") - 1, p);
+ c = *drive_p;
+ *drive_p = 0;
+ /* TRANSLATORS: device.map is a filename. Not to be translated.
+ device.map specifies disk correspondance overrides. Previously
+ one could create any kind of device name with this. Due to
+ some problems we decided to limit it to just a handful
+ possibilities. */
+ grub_util_warn (_("the drive name `%s' in device.map is incorrect. "
+ "Using %s instead. "
+ "Please use the form [hfc]d[0-9]* "
+ "(E.g. `hd0' or `cd')"),
+ drive_e, map[drive].drive);
+ *drive_p = c;
+ }
+
+ grub_util_info ("adding `%s' -> `%s' from device.map", map[drive].drive,
+ map[drive].device);
+
+ grub_hostdisk_flush_initial_buffer (map[drive].device);
+ }
+
+ fclose (fp);
+}
+
+void
+grub_util_biosdisk_init (const char *dev_map)
+{
+ read_device_map (dev_map);
+ grub_disk_dev_register (&grub_util_biosdisk_dev);
+}
+
+void
+grub_util_biosdisk_fini (void)
+{
+ unsigned i;
+
+ for (i = 0; i < ARRAY_SIZE(map); i++)
+ {
+ if (map[i].drive)
+ free (map[i].drive);
+ if (map[i].device)
+ free (map[i].device);
+ map[i].drive = map[i].device = NULL;
+ }
+
+ grub_disk_dev_unregister (&grub_util_biosdisk_dev);
+}
+
+const char *
+grub_util_biosdisk_get_compatibility_hint (grub_disk_t disk)
+{
+ if (disk->dev != &grub_util_biosdisk_dev || map[disk->id].device_map)
+ return disk->name;
+ return 0;
+}
+
+const char *
+grub_util_biosdisk_get_osdev (grub_disk_t disk)
+{
+ if (disk->dev != &grub_util_biosdisk_dev)
+ return 0;
+
+ return map[disk->id].device;
+}
+
+
+static char *
+grub_util_path_concat_real (size_t n, int ext, va_list ap)
+{
+ size_t totlen = 0;
+ char **l = xcalloc (n + ext, sizeof (l[0]));
+ char *r, *p, *pi;
+ size_t i;
+ int first = 1;
+
+ for (i = 0; i < n + ext; i++)
+ {
+ l[i] = va_arg (ap, char *);
+ if (l[i])
+ totlen += strlen (l[i]) + 1;
+ }
+
+ r = xmalloc (totlen + 10);
+
+ p = r;
+ for (i = 0; i < n; i++)
+ {
+ pi = l[i];
+ if (!pi)
+ continue;
+ while (*pi == '/')
+ pi++;
+ if ((p != r || (pi != l[i] && first)) && (p == r || *(p - 1) != '/'))
+ *p++ = '/';
+ first = 0;
+ p = grub_stpcpy (p, pi);
+ while (p != r && p != r + 1 && *(p - 1) == '/')
+ p--;
+ }
+
+ if (ext && l[i])
+ p = grub_stpcpy (p, l[i]);
+
+ *p = '\0';
+
+ free (l);
+
+ return r;
+}
+
+char *
+grub_util_path_concat (size_t n, ...)
+{
+ va_list ap;
+ char *r;
+
+ va_start (ap, n);
+
+ r = grub_util_path_concat_real (n, 0, ap);
+
+ va_end (ap);
+
+ return r;
+}
+
+char *
+grub_util_path_concat_ext (size_t n, ...)
+{
+ va_list ap;
+ char *r;
+
+ va_start (ap, n);
+
+ r = grub_util_path_concat_real (n, 1, ap);
+
+ va_end (ap);
+
+ return r;
+}
diff --git a/grub-core/kern/emu/hostfs.c b/grub-core/kern/emu/hostfs.c
new file mode 100644
index 0000000..cb53210
--- /dev/null
+++ b/grub-core/kern/emu/hostfs.c
@@ -0,0 +1,200 @@
+/* hostfs.c - Dummy filesystem to provide access to the hosts filesystem */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config-util.h>
+
+#include <grub/fs.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/util/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/i18n.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+static int
+is_dir (const char *path, const char *name)
+{
+ int len1 = strlen(path);
+ int len2 = strlen(name);
+ int ret;
+
+ char *pathname = xmalloc (len1 + 1 + len2 + 1 + 13);
+ strcpy (pathname, path);
+
+ /* Avoid UNC-path "//name" on Cygwin. */
+ if (len1 > 0 && pathname[len1 - 1] != '/')
+ strcat (pathname, "/");
+
+ strcat (pathname, name);
+
+ ret = grub_util_is_directory (pathname);
+ free (pathname);
+ return ret;
+}
+
+struct grub_hostfs_data
+{
+ char *filename;
+ grub_util_fd_t f;
+};
+
+static grub_err_t
+grub_hostfs_dir (grub_device_t device, const char *path,
+ grub_fs_dir_hook_t hook, void *hook_data)
+{
+ grub_util_fd_dir_t dir;
+
+ /* Check if the disk is our dummy disk. */
+ if (grub_strcmp (device->disk->name, "host"))
+ return grub_error (GRUB_ERR_BAD_FS, "not a hostfs");
+
+ dir = grub_util_fd_opendir (path);
+ if (! dir)
+ return grub_error (GRUB_ERR_BAD_FILENAME,
+ N_("can't open `%s': %s"), path,
+ grub_util_fd_strerror ());
+
+ while (1)
+ {
+ grub_util_fd_dirent_t de;
+ struct grub_dirhook_info info;
+ grub_memset (&info, 0, sizeof (info));
+
+ de = grub_util_fd_readdir (dir);
+ if (! de)
+ break;
+
+ info.dir = !! is_dir (path, de->d_name);
+ hook (de->d_name, &info, hook_data);
+
+ }
+
+ grub_util_fd_closedir (dir);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Open a file named NAME and initialize FILE. */
+static grub_err_t
+grub_hostfs_open (struct grub_file *file, const char *name)
+{
+ grub_util_fd_t f;
+ struct grub_hostfs_data *data;
+
+ f = grub_util_fd_open (name, GRUB_UTIL_FD_O_RDONLY);
+ if (! GRUB_UTIL_FD_IS_VALID (f))
+ return grub_error (GRUB_ERR_BAD_FILENAME,
+ N_("can't open `%s': %s"), name,
+ strerror (errno));
+ data = grub_malloc (sizeof (*data));
+ if (!data)
+ {
+ grub_util_fd_close (f);
+ return grub_errno;
+ }
+ data->filename = grub_strdup (name);
+ if (!data->filename)
+ {
+ grub_free (data);
+ grub_util_fd_close (f);
+ return grub_errno;
+ }
+
+ data->f = f;
+
+ file->data = data;
+
+ file->size = grub_util_get_fd_size (f, name, NULL);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_ssize_t
+grub_hostfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_hostfs_data *data;
+
+ data = file->data;
+ if (grub_util_fd_seek (data->f, file->offset) != 0)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("cannot seek `%s': %s"),
+ data->filename, grub_util_fd_strerror ());
+ return -1;
+ }
+
+ unsigned int s = grub_util_fd_read (data->f, buf, len);
+ if (s != len)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("cannot read `%s': %s"),
+ data->filename, grub_util_fd_strerror ());
+
+ return (signed) s;
+}
+
+static grub_err_t
+grub_hostfs_close (grub_file_t file)
+{
+ struct grub_hostfs_data *data;
+
+ data = file->data;
+ grub_util_fd_close (data->f);
+ grub_free (data->filename);
+ grub_free (data);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_hostfs_label (grub_device_t device __attribute ((unused)),
+ char **label __attribute ((unused)))
+{
+ *label = 0;
+ return GRUB_ERR_NONE;
+}
+
+#undef open
+#undef close
+
+static struct grub_fs grub_hostfs_fs =
+ {
+ .name = "hostfs",
+ .fs_dir = grub_hostfs_dir,
+ .fs_open = grub_hostfs_open,
+ .fs_read = grub_hostfs_read,
+ .fs_close = grub_hostfs_close,
+ .fs_label = grub_hostfs_label,
+ .next = 0
+ };
+
+
+
+GRUB_MOD_INIT(hostfs)
+{
+ grub_fs_register (&grub_hostfs_fs);
+}
+
+GRUB_MOD_FINI(hostfs)
+{
+ grub_fs_unregister (&grub_hostfs_fs);
+}
diff --git a/grub-core/kern/emu/lite.c b/grub-core/kern/emu/lite.c
new file mode 100644
index 0000000..b327d4e
--- /dev/null
+++ b/grub-core/kern/emu/lite.c
@@ -0,0 +1,47 @@
+#include <config.h>
+#include <grub/emu/misc.h>
+
+#ifndef GRUB_MACHINE_EMU
+#error "This source is only meant for grub-emu platform"
+#endif
+
+#if defined(__i386__)
+#include "../i386/dl.c"
+#elif defined(__x86_64__)
+#include "../x86_64/dl.c"
+#elif defined(__sparc__)
+#include "../sparc64/dl.c"
+#elif defined(__mips__)
+#include "../mips/dl.c"
+#elif defined(__powerpc__)
+#include "../powerpc/dl.c"
+#elif defined(__ia64__)
+#include "../ia64/dl_helper.c"
+#include "../ia64/dl.c"
+#elif defined(__arm__)
+#include "../arm/dl_helper.c"
+#include "../arm/dl.c"
+#elif defined(__aarch64__)
+#include "../arm64/dl_helper.c"
+#include "../arm64/dl.c"
+#elif defined(__riscv)
+#include "../riscv/dl.c"
+#else
+#error "No target cpu type is defined"
+#endif
+
+const int grub_no_modules = 0;
+
+/* grub-emu-lite supports dynamic module loading, so it won't have any
+ embedded modules. */
+void
+grub_init_all (void)
+{
+ return;
+}
+
+void
+grub_fini_all (void)
+{
+ return;
+}
diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c
new file mode 100644
index 0000000..425bb96
--- /dev/null
+++ b/grub-core/kern/emu/main.c
@@ -0,0 +1,286 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <config-util.h>
+
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <setjmp.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/types.h>
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/setjmp.h>
+#include <grub/fs.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/time.h>
+#include <grub/emu/console.h>
+#include <grub/emu/misc.h>
+#include <grub/kernel.h>
+#include <grub/normal.h>
+#include <grub/emu/getroot.h>
+#include <grub/env.h>
+#include <grub/partition.h>
+#include <grub/i18n.h>
+#include <grub/loader.h>
+#include <grub/util/misc.h>
+
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+
+#include "progname.h"
+#include <argp.h>
+
+#define ENABLE_RELOCATABLE 0
+
+/* Used for going back to the main function. */
+static jmp_buf main_env;
+
+/* Store the prefix specified by an argument. */
+static char *root_dev = NULL, *dir = NULL;
+
+grub_addr_t grub_modbase = 0;
+
+void
+grub_reboot (void)
+{
+ longjmp (main_env, 1);
+ grub_fatal ("longjmp failed");
+}
+
+void
+grub_exit (void)
+{
+ grub_reboot ();
+}
+
+void
+grub_machine_init (void)
+{
+}
+
+void
+grub_machine_get_bootlocation (char **device, char **path)
+{
+ *device = root_dev;
+ *path = dir;
+}
+
+void
+grub_machine_fini (int flags)
+{
+ if (flags & GRUB_LOADER_FLAG_NORETURN)
+ grub_console_fini ();
+}
+
+
+
+#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},
+ {"hold", 'H', N_("SECS"), OPTION_ARG_OPTIONAL, N_("wait until a debugger will attach"), 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)))
+{
+ switch (key)
+ {
+ case 'd':
+ return xasprintf (text, DEFAULT_DIRECTORY);
+ case 'm':
+ return xasprintf (text, DEFAULT_DEVICE_MAP);
+ default:
+ return (char *) text;
+ }
+}
+
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
+struct arguments
+{
+ const char *dev_map;
+ const char *mem_disk;
+ int hold;
+};
+
+static error_t
+argp_parser (int key, char *arg, struct argp_state *state)
+{
+ /* Get the input argument from argp_parse, which we
+ know is a pointer to our arguments structure. */
+ struct arguments *arguments = state->input;
+
+ switch (key)
+ {
+ case OPT_MEMDISK:
+ arguments->mem_disk = arg;
+ break;
+ case 'r':
+ free (root_dev);
+ root_dev = xstrdup (arg);
+ break;
+ case 'd':
+ free (dir);
+ dir = xstrdup (arg);
+ break;
+ case 'm':
+ arguments->dev_map = arg;
+ break;
+ case 'H':
+ arguments->hold = (arg ? atoi (arg) : -1);
+ break;
+ case 'v':
+ verbosity++;
+ break;
+
+ case ARGP_KEY_ARG:
+ {
+ /* Too many arguments. */
+ fprintf (stderr, _("Unknown extra argument `%s'."), arg);
+ fprintf (stderr, "\n");
+ argp_usage (state);
+ }
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+static struct argp argp = {
+ options, argp_parser, NULL,
+ N_("GRUB emulator."),
+ NULL, help_filter, NULL
+};
+
+
+
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+
+int
+main (int argc, char *argv[])
+{
+ struct arguments arguments =
+ {
+ .dev_map = DEFAULT_DEVICE_MAP,
+ .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);
+
+ dir = xstrdup (DEFAULT_DIRECTORY);
+
+ if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
+ {
+ fprintf (stderr, "%s", _("Error in parsing command line arguments\n"));
+ 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)
+ /* TRANSLATORS: In this case GRUB tells user what he has to do. */
+ printf (_("Run `gdb %s %d', and set ARGS.HOLD to zero.\n"),
+ program_name, (int) getpid ());
+ while (hold)
+ {
+ if (hold > 0)
+ hold--;
+
+ sleep (1);
+ }
+
+ signal (SIGINT, SIG_IGN);
+ grub_console_init ();
+ grub_host_init ();
+
+ /* XXX: This is a bit unportable. */
+ grub_util_biosdisk_init (arguments.dev_map);
+
+ grub_init_all ();
+
+ grub_hostfs_init ();
+
+ /* Make sure that there is a root device. */
+ if (! root_dev)
+ root_dev = grub_strdup ("host");
+
+ dir = xstrdup (dir);
+
+ /* Start GRUB! */
+ if (setjmp (main_env) == 0)
+ grub_main ();
+
+ grub_fini_all ();
+ grub_hostfs_fini ();
+ grub_host_fini ();
+
+ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN);
+
+ return 0;
+}
diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c
new file mode 100644
index 0000000..dfd8a8e
--- /dev/null
+++ b/grub-core/kern/emu/misc.c
@@ -0,0 +1,216 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_BUILD
+#include <config-util.h>
+#endif
+#include <config.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/env.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/time.h>
+#include <grub/emu/misc.h>
+
+int verbosity;
+
+void
+grub_util_warn (const char *fmt, ...)
+{
+ va_list ap;
+
+ fprintf (stderr, _("%s: warning:"), program_name);
+ fprintf (stderr, " ");
+ va_start (ap, fmt);
+ vfprintf (stderr, fmt, ap);
+ va_end (ap);
+ fprintf (stderr, ".\n");
+ fflush (stderr);
+}
+
+void
+grub_util_info (const char *fmt, ...)
+{
+ if (verbosity > 0)
+ {
+ va_list ap;
+
+ fprintf (stderr, _("%s: info:"), program_name);
+ fprintf (stderr, " ");
+ va_start (ap, fmt);
+ vfprintf (stderr, fmt, ap);
+ va_end (ap);
+ fprintf (stderr, ".\n");
+ fflush (stderr);
+ }
+}
+
+void
+grub_util_error (const char *fmt, ...)
+{
+ va_list ap;
+
+ fprintf (stderr, _("%s: error:"), program_name);
+ fprintf (stderr, " ");
+ va_start (ap, fmt);
+ vfprintf (stderr, fmt, ap);
+ va_end (ap);
+ fprintf (stderr, ".\n");
+ exit (1);
+}
+
+void *
+xcalloc (grub_size_t nmemb, grub_size_t size)
+{
+ void *p;
+
+ p = calloc (nmemb, size);
+ if (!p)
+ grub_util_error ("%s", _("out of memory"));
+
+ return p;
+}
+
+void *
+xmalloc (grub_size_t size)
+{
+ void *p;
+
+ p = malloc (size);
+ if (! p)
+ grub_util_error ("%s", _("out of memory"));
+
+ return p;
+}
+
+void *
+xrealloc (void *ptr, grub_size_t size)
+{
+ ptr = realloc (ptr, size);
+ if (! ptr)
+ grub_util_error ("%s", _("out of memory"));
+
+ return ptr;
+}
+
+char *
+xstrdup (const char *str)
+{
+ size_t len;
+ char *newstr;
+
+ len = strlen (str);
+ newstr = (char *) xmalloc (len + 1);
+ memcpy (newstr, str, len + 1);
+
+ return newstr;
+}
+
+#if !defined (GRUB_MKFONT) && !defined (GRUB_BUILD)
+char *
+xasprintf (const char *fmt, ...)
+{
+ va_list ap;
+ char *result;
+
+ va_start (ap, fmt);
+ result = grub_xvasprintf (fmt, ap);
+ va_end (ap);
+ if (!result)
+ grub_util_error ("%s", _("out of memory"));
+
+ return result;
+}
+#endif
+
+#if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL)
+void
+grub_exit (void)
+{
+ exit (1);
+}
+#endif
+
+grub_uint64_t
+grub_get_time_ms (void)
+{
+ struct timeval tv;
+
+ gettimeofday (&tv, 0);
+
+ 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/emu/mm.c b/grub-core/kern/emu/mm.c
new file mode 100644
index 0000000..4d1046a
--- /dev/null
+++ b/grub-core/kern/emu/mm.c
@@ -0,0 +1,75 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config-util.h>
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <stdlib.h>
+#include <string.h>
+#include <grub/i18n.h>
+
+void *
+grub_calloc (grub_size_t nmemb, grub_size_t size)
+{
+ void *ret;
+ ret = calloc (nmemb, size);
+ if (!ret)
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return ret;
+}
+
+void *
+grub_malloc (grub_size_t size)
+{
+ void *ret;
+ ret = malloc (size);
+ if (!ret)
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return ret;
+}
+
+void *
+grub_zalloc (grub_size_t size)
+{
+ void *ret;
+
+ ret = grub_malloc (size);
+ if (!ret)
+ return NULL;
+ memset (ret, 0, size);
+ return ret;
+}
+
+void
+grub_free (void *ptr)
+{
+ if (ptr)
+ free (ptr);
+}
+
+void *
+grub_realloc (void *ptr, grub_size_t size)
+{
+ void *ret;
+ ret = realloc (ptr, size);
+ if (!ret)
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return ret;
+}
diff --git a/grub-core/kern/emu/time.c b/grub-core/kern/emu/time.c
new file mode 100644
index 0000000..5da8092
--- /dev/null
+++ b/grub-core/kern/emu/time.c
@@ -0,0 +1,46 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/datetime.h>
+#include <time.h>
+
+grub_err_t
+grub_get_datetime (struct grub_datetime *datetime)
+{
+ struct tm *mytm;
+ time_t mytime;
+
+ mytime = time (&mytime);
+ mytm = gmtime (&mytime);
+
+ datetime->year = mytm->tm_year + 1900;
+ datetime->month = mytm->tm_mon + 1;
+ datetime->day = mytm->tm_mday;
+ datetime->hour = mytm->tm_hour;
+ datetime->minute = mytm->tm_min;
+ datetime->second = mytm->tm_sec;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_set_datetime (struct grub_datetime *datetime __attribute__ ((unused)))
+{
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "no clock setting routine available");
+}
diff --git a/grub-core/kern/env.c b/grub-core/kern/env.c
new file mode 100644
index 0000000..c408626
--- /dev/null
+++ b/grub-core/kern/env.c
@@ -0,0 +1,238 @@
+/* env.c - Environment variables */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/env.h>
+#include <grub/env_private.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+
+/* The initial context. */
+static struct grub_env_context initial_context;
+
+/* The current context. */
+struct grub_env_context *grub_current_context = &initial_context;
+
+/* Return the hash representation of the string S. */
+static unsigned int
+grub_env_hashval (const char *s)
+{
+ unsigned int i = 0;
+
+ /* XXX: This can be done much more efficiently. */
+ while (*s)
+ i += 5 * *(s++);
+
+ return i % HASHSZ;
+}
+
+static struct grub_env_var *
+grub_env_find (const char *name)
+{
+ struct grub_env_var *var;
+ int idx = grub_env_hashval (name);
+
+ /* Look for the variable in the current context. */
+ for (var = grub_current_context->vars[idx]; var; var = var->next)
+ if (grub_strcmp (var->name, name) == 0)
+ return var;
+
+ return 0;
+}
+
+static void
+grub_env_insert (struct grub_env_context *context,
+ struct grub_env_var *var)
+{
+ int idx = grub_env_hashval (var->name);
+
+ /* Insert the variable into the hashtable. */
+ var->prevp = &context->vars[idx];
+ var->next = context->vars[idx];
+ if (var->next)
+ var->next->prevp = &(var->next);
+ context->vars[idx] = var;
+}
+
+static void
+grub_env_remove (struct grub_env_var *var)
+{
+ /* Remove the entry from the variable table. */
+ *var->prevp = var->next;
+ if (var->next)
+ var->next->prevp = var->prevp;
+}
+
+grub_err_t
+grub_env_set (const char *name, const char *val)
+{
+ struct grub_env_var *var;
+
+ /* If the variable does already exist, just update the variable. */
+ var = grub_env_find (name);
+ if (var)
+ {
+ char *old = var->value;
+
+ if (var->write_hook)
+ var->value = var->write_hook (var, val);
+ else
+ var->value = grub_strdup (val);
+
+ if (! var->value)
+ {
+ var->value = old;
+ return grub_errno;
+ }
+
+ grub_free (old);
+ return GRUB_ERR_NONE;
+ }
+
+ /* The variable does not exist, so create a new one. */
+ var = grub_zalloc (sizeof (*var));
+ if (! var)
+ return grub_errno;
+
+ var->name = grub_strdup (name);
+ if (! var->name)
+ goto fail;
+
+ var->value = grub_strdup (val);
+ if (! var->value)
+ goto fail;
+
+ grub_env_insert (grub_current_context, var);
+
+ return GRUB_ERR_NONE;
+
+ fail:
+ grub_free (var->name);
+ grub_free (var->value);
+ grub_free (var);
+
+ return grub_errno;
+}
+
+const char *
+grub_env_get (const char *name)
+{
+ struct grub_env_var *var;
+
+ var = grub_env_find (name);
+ if (! var)
+ return 0;
+
+ if (var->read_hook)
+ return var->read_hook (var, var->value);
+
+ return var->value;
+}
+
+void
+grub_env_unset (const char *name)
+{
+ struct grub_env_var *var;
+
+ var = grub_env_find (name);
+ if (! var)
+ return;
+
+ if (var->read_hook || var->write_hook)
+ {
+ grub_env_set (name, "");
+ return;
+ }
+
+ grub_env_remove (var);
+
+ grub_free (var->name);
+ grub_free (var->value);
+ grub_free (var);
+}
+
+struct grub_env_var *
+grub_env_update_get_sorted (void)
+{
+ struct grub_env_var *sorted_list = 0;
+ int i;
+
+ /* Add variables associated with this context into a sorted list. */
+ for (i = 0; i < HASHSZ; i++)
+ {
+ struct grub_env_var *var;
+
+ for (var = grub_current_context->vars[i]; var; var = var->next)
+ {
+ struct grub_env_var *p, **q;
+
+ for (q = &sorted_list, p = *q; p; q = &((*q)->sorted_next), p = *q)
+ {
+ if (grub_strcmp (p->name, var->name) > 0)
+ break;
+ }
+
+ var->sorted_next = *q;
+ *q = var;
+ }
+ }
+
+ return sorted_list;
+}
+
+grub_err_t
+grub_register_variable_hook (const char *name,
+ grub_env_read_hook_t read_hook,
+ grub_env_write_hook_t write_hook)
+{
+ struct grub_env_var *var = grub_env_find (name);
+
+ if (! var)
+ {
+ if (grub_env_set (name, "") != GRUB_ERR_NONE)
+ return grub_errno;
+
+ var = grub_env_find (name);
+ /* XXX Insert an assertion? */
+ }
+
+ var->read_hook = read_hook;
+ var->write_hook = write_hook;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_env_export (const char *name)
+{
+ struct grub_env_var *var;
+
+ var = grub_env_find (name);
+ if (! var)
+ {
+ grub_err_t err;
+
+ err = grub_env_set (name, "");
+ if (err)
+ return err;
+ var = grub_env_find (name);
+ }
+ var->global = 1;
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c
new file mode 100644
index 0000000..53c734d
--- /dev/null
+++ b/grub-core/kern/err.c
@@ -0,0 +1,122 @@
+/* err.c - error handling routines */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <stdarg.h>
+#include <grub/i18n.h>
+
+#define GRUB_ERROR_STACK_SIZE 10
+
+grub_err_t grub_errno;
+char grub_errmsg[GRUB_MAX_ERRMSG];
+int grub_err_printed_errors;
+
+static struct grub_error_saved grub_error_stack_items[GRUB_ERROR_STACK_SIZE];
+
+static int grub_error_stack_pos;
+static int grub_error_stack_assert;
+
+grub_err_t
+grub_error (grub_err_t n, const char *fmt, ...)
+{
+ va_list ap;
+
+ grub_errno = n;
+
+ va_start (ap, fmt);
+ grub_vsnprintf (grub_errmsg, sizeof (grub_errmsg), _(fmt), ap);
+ va_end (ap);
+
+ return n;
+}
+
+void
+grub_error_push (void)
+{
+ /* Only add items to stack, if there is enough room. */
+ if (grub_error_stack_pos < GRUB_ERROR_STACK_SIZE)
+ {
+ /* Copy active error message to stack. */
+ grub_error_stack_items[grub_error_stack_pos].grub_errno = grub_errno;
+ grub_memcpy (grub_error_stack_items[grub_error_stack_pos].errmsg,
+ grub_errmsg,
+ sizeof (grub_errmsg));
+
+ /* Advance to next error stack position. */
+ grub_error_stack_pos++;
+ }
+ else
+ {
+ /* There is no room for new error message. Discard new error message
+ and mark error stack assertion flag. */
+ grub_error_stack_assert = 1;
+ }
+
+ /* Allow further operation of other components by resetting
+ active errno to GRUB_ERR_NONE. */
+ grub_errno = GRUB_ERR_NONE;
+}
+
+int
+grub_error_pop (void)
+{
+ if (grub_error_stack_pos > 0)
+ {
+ /* Pop error message from error stack to current active error. */
+ grub_error_stack_pos--;
+
+ grub_errno = grub_error_stack_items[grub_error_stack_pos].grub_errno;
+ grub_memcpy (grub_errmsg,
+ grub_error_stack_items[grub_error_stack_pos].errmsg,
+ sizeof (grub_errmsg));
+
+ return 1;
+ }
+ else
+ {
+ /* There is no more items on error stack, reset to no error state. */
+ grub_errno = GRUB_ERR_NONE;
+
+ return 0;
+ }
+}
+
+void
+grub_print_error (void)
+{
+ /* Print error messages in reverse order. First print active error message
+ and then empty error stack. */
+ do
+ {
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_err_printf (_("error: %s.\n"), grub_errmsg);
+ grub_err_printed_errors++;
+ }
+ }
+ while (grub_error_pop ());
+
+ /* If there was an assert while using error stack, report about it. */
+ if (grub_error_stack_assert)
+ {
+ grub_err_printf ("assert: error stack overflow detected!\n");
+ grub_error_stack_assert = 0;
+ }
+}
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
new file mode 100644
index 0000000..5845445
--- /dev/null
+++ b/grub-core/kern/file.c
@@ -0,0 +1,218 @@
+/* file.c - file I/O functions */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/net.h>
+#include <grub/mm.h>
+#include <grub/fs.h>
+#include <grub/device.h>
+#include <grub/i18n.h>
+
+void (*EXPORT_VAR (grub_grubnet_fini)) (void);
+
+grub_file_filter_t grub_file_filters[GRUB_FILE_FILTER_MAX];
+
+/* Get the device part of the filename NAME. It is enclosed by parentheses. */
+char *
+grub_file_get_device_name (const char *name)
+{
+ if (name[0] == '(')
+ {
+ char *p = grub_strchr (name, ')');
+ char *ret;
+
+ if (! p)
+ {
+ grub_error (GRUB_ERR_BAD_FILENAME, N_("missing `%c' symbol"), ')');
+ return 0;
+ }
+
+ ret = (char *) grub_malloc (p - name);
+ if (! ret)
+ return 0;
+
+ grub_memcpy (ret, name + 1, p - name - 1);
+ ret[p - name - 1] = '\0';
+ return ret;
+ }
+
+ return 0;
+}
+
+grub_file_t
+grub_file_open (const char *name, enum grub_file_type type)
+{
+ grub_device_t device = 0;
+ grub_file_t file = 0, last_file = 0;
+ char *device_name;
+ const char *file_name;
+ grub_file_filter_id_t filter;
+
+ device_name = grub_file_get_device_name (name);
+ if (grub_errno)
+ goto fail;
+
+ /* Get the file part of NAME. */
+ file_name = (name[0] == '(') ? grub_strchr (name, ')') : NULL;
+ if (file_name)
+ file_name++;
+ else
+ file_name = name;
+
+ device = grub_device_open (device_name);
+ grub_free (device_name);
+ if (! device)
+ goto fail;
+
+ file = (grub_file_t) grub_zalloc (sizeof (*file));
+ if (! file)
+ goto fail;
+
+ file->device = device;
+
+ /* 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
+ {
+ file->fs = grub_fs_probe (device);
+ if (! file->fs)
+ goto fail;
+ }
+
+ if ((file->fs->fs_open) (file, file_name) != GRUB_ERR_NONE)
+ goto fail;
+
+ file->name = grub_strdup (name);
+ grub_errno = GRUB_ERR_NONE;
+
+ for (filter = 0; file && filter < ARRAY_SIZE (grub_file_filters);
+ filter++)
+ if (grub_file_filters[filter])
+ {
+ last_file = file;
+ file = grub_file_filters[filter] (file, type);
+ if (file && file != last_file)
+ {
+ file->name = grub_strdup (name);
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+ if (!file)
+ grub_file_close (last_file);
+
+ return file;
+
+ fail:
+ if (device)
+ grub_device_close (device);
+
+ /* if (net) grub_net_close (net); */
+
+ grub_free (file);
+
+ return 0;
+}
+
+grub_disk_read_hook_t grub_file_progress_hook;
+
+grub_ssize_t
+grub_file_read (grub_file_t file, void *buf, grub_size_t len)
+{
+ grub_ssize_t res;
+ grub_disk_read_hook_t read_hook;
+ void *read_hook_data;
+
+ if (file->offset > file->size)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("attempt to read past the end of file"));
+ return -1;
+ }
+
+ if (len == 0)
+ return 0;
+
+ if (len > file->size - file->offset)
+ len = file->size - file->offset;
+
+ /* Prevent an overflow. */
+ if ((grub_ssize_t) len < 0)
+ len >>= 1;
+
+ if (len == 0)
+ return 0;
+ read_hook = file->read_hook;
+ read_hook_data = file->read_hook_data;
+ if (!file->read_hook)
+ {
+ file->read_hook = grub_file_progress_hook;
+ file->read_hook_data = file;
+ file->progress_offset = file->offset;
+ }
+ res = (file->fs->fs_read) (file, buf, len);
+ file->read_hook = read_hook;
+ file->read_hook_data = read_hook_data;
+ if (res > 0)
+ file->offset += res;
+
+ return res;
+}
+
+grub_err_t
+grub_file_close (grub_file_t file)
+{
+ if (file->fs->fs_close)
+ (file->fs->fs_close) (file);
+
+ if (file->device)
+ grub_device_close (file->device);
+ grub_free (file->name);
+ grub_free (file);
+ return grub_errno;
+}
+
+grub_off_t
+grub_file_seek (grub_file_t file, grub_off_t offset)
+{
+ grub_off_t old;
+
+ if (offset > file->size)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("attempt to seek outside of the file"));
+ return -1;
+ }
+
+ old = file->offset;
+ file->offset = offset;
+
+ return old;
+}
diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c
new file mode 100644
index 0000000..c698295
--- /dev/null
+++ b/grub-core/kern/fs.c
@@ -0,0 +1,253 @@
+/* fs.c - filesystem manager */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/disk.h>
+#include <grub/net.h>
+#include <grub/fs.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+#include <grub/i18n.h>
+
+grub_fs_t grub_fs_list = 0;
+
+grub_fs_autoload_hook_t grub_fs_autoload_hook = 0;
+
+/* Helper for grub_fs_probe. */
+static int
+probe_dummy_iter (const char *filename __attribute__ ((unused)),
+ const struct grub_dirhook_info *info __attribute__ ((unused)),
+ void *data __attribute__ ((unused)))
+{
+ return 1;
+}
+
+grub_fs_t
+grub_fs_probe (grub_device_t device)
+{
+ grub_fs_t p;
+
+ if (device->disk)
+ {
+ /* Make it sure not to have an infinite recursive calls. */
+ static int count = 0;
+
+ for (p = grub_fs_list; p; p = p->next)
+ {
+ grub_dprintf ("fs", "Detecting %s...\n", p->name);
+
+ /* This is evil: newly-created just mounted BtrFS after copying all
+ GRUB files has a very peculiar unrecoverable corruption which
+ will be fixed at sync but we'd rather not do a global sync and
+ syncing just files doesn't seem to help. Relax the check for
+ this time. */
+#ifdef GRUB_UTIL
+ if (grub_strcmp (p->name, "btrfs") == 0)
+ {
+ char *label = 0;
+ p->fs_uuid (device, &label);
+ if (label)
+ grub_free (label);
+ }
+ else
+#endif
+ (p->fs_dir) (device, "/", probe_dummy_iter, NULL);
+ if (grub_errno == GRUB_ERR_NONE)
+ return p;
+
+ grub_error_push ();
+ grub_dprintf ("fs", "%s detection failed.\n", p->name);
+ grub_error_pop ();
+
+ if (grub_errno != GRUB_ERR_BAD_FS
+ && grub_errno != GRUB_ERR_OUT_OF_RANGE)
+ return 0;
+
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ /* Let's load modules automatically. */
+ if (grub_fs_autoload_hook && count == 0)
+ {
+ count++;
+
+ while (grub_fs_autoload_hook ())
+ {
+ p = grub_fs_list;
+
+ (p->fs_dir) (device, "/", probe_dummy_iter, NULL);
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ count--;
+ return p;
+ }
+
+ if (grub_errno != GRUB_ERR_BAD_FS
+ && grub_errno != GRUB_ERR_OUT_OF_RANGE)
+ {
+ count--;
+ return 0;
+ }
+
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ count--;
+ }
+ }
+ else if (device->net && device->net->fs)
+ return device->net->fs;
+
+ grub_error (GRUB_ERR_UNKNOWN_FS, N_("unknown filesystem"));
+ return 0;
+}
+
+
+
+/* Block list support routines. */
+
+struct grub_fs_block
+{
+ grub_disk_addr_t offset;
+ unsigned long length;
+};
+
+static grub_err_t
+grub_fs_blocklist_open (grub_file_t file, const char *name)
+{
+ const char *p = name;
+ unsigned num = 0;
+ unsigned i;
+ grub_disk_t disk = file->device->disk;
+ struct grub_fs_block *blocks;
+ grub_size_t max_sectors;
+
+ /* First, count the number of blocks. */
+ do
+ {
+ num++;
+ p = grub_strchr (p, ',');
+ if (p)
+ p++;
+ }
+ while (p);
+
+ /* Allocate a block list. */
+ blocks = grub_calloc (num + 1, sizeof (struct grub_fs_block));
+ if (! blocks)
+ return 0;
+
+ file->size = 0;
+ max_sectors = grub_disk_from_native_sector (disk, disk->total_sectors);
+ p = (char *) name;
+ for (i = 0; i < num; i++)
+ {
+ if (*p != '+')
+ {
+ blocks[i].offset = grub_strtoull (p, &p, 0);
+ if (grub_errno != GRUB_ERR_NONE || *p != '+')
+ {
+ grub_error (GRUB_ERR_BAD_FILENAME,
+ N_("invalid file name `%s'"), name);
+ goto fail;
+ }
+ }
+
+ p++;
+ blocks[i].length = grub_strtoul (p, &p, 0);
+ if (grub_errno != GRUB_ERR_NONE
+ || blocks[i].length == 0
+ || (*p && *p != ',' && ! grub_isspace (*p)))
+ {
+ grub_error (GRUB_ERR_BAD_FILENAME,
+ N_("invalid file name `%s'"), name);
+ goto fail;
+ }
+
+ if (max_sectors < blocks[i].offset + blocks[i].length)
+ {
+ grub_error (GRUB_ERR_BAD_FILENAME, "beyond the total sectors");
+ goto fail;
+ }
+
+ file->size += (blocks[i].length << GRUB_DISK_SECTOR_BITS);
+ p++;
+ }
+
+ file->data = blocks;
+
+ return GRUB_ERR_NONE;
+
+ fail:
+ grub_free (blocks);
+ return grub_errno;
+}
+
+static grub_ssize_t
+grub_fs_blocklist_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ struct grub_fs_block *p;
+ grub_disk_addr_t sector;
+ grub_off_t offset;
+ grub_ssize_t ret = 0;
+
+ if (len > file->size - file->offset)
+ len = file->size - file->offset;
+
+ sector = (file->offset >> GRUB_DISK_SECTOR_BITS);
+ offset = (file->offset & (GRUB_DISK_SECTOR_SIZE - 1));
+ for (p = file->data; p->length && len > 0; p++)
+ {
+ if (sector < p->length)
+ {
+ grub_size_t size;
+
+ size = len;
+ if (((size + offset + GRUB_DISK_SECTOR_SIZE - 1)
+ >> GRUB_DISK_SECTOR_BITS) > p->length - sector)
+ size = ((p->length - sector) << GRUB_DISK_SECTOR_BITS) - offset;
+
+ if (grub_disk_read (file->device->disk, p->offset + sector, offset,
+ size, buf) != GRUB_ERR_NONE)
+ return -1;
+
+ ret += size;
+ len -= size;
+ sector -= ((size + offset) >> GRUB_DISK_SECTOR_BITS);
+ offset = ((size + offset) & (GRUB_DISK_SECTOR_SIZE - 1));
+ }
+ else
+ sector -= p->length;
+ }
+
+ return ret;
+}
+
+struct grub_fs grub_fs_blocklist =
+ {
+ .name = "blocklist",
+ .fs_dir = 0,
+ .fs_open = grub_fs_blocklist_open,
+ .fs_read = grub_fs_blocklist_read,
+ .fs_close = 0,
+ .next = 0
+ };
diff --git a/grub-core/kern/generic/millisleep.c b/grub-core/kern/generic/millisleep.c
new file mode 100644
index 0000000..9d5971f
--- /dev/null
+++ b/grub-core/kern/generic/millisleep.c
@@ -0,0 +1,39 @@
+/* millisleep.c - generic millisleep function.
+ * The generic implementation of these functions can be used for architectures
+ * or platforms that do not have a more specialized implementation. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/time.h>
+
+void
+grub_millisleep (grub_uint32_t ms)
+{
+ grub_uint64_t start;
+
+ start = grub_get_time_ms ();
+
+ /* Instead of setting an end time and looping while the current time is
+ less than that, comparing the elapsed sleep time with the desired sleep
+ time handles the (unlikely!) case that the timer would wrap around
+ during the sleep. */
+
+ while (grub_get_time_ms () - start < ms)
+ grub_cpu_idle ();
+}
diff --git a/grub-core/kern/generic/rtc_get_time_ms.c b/grub-core/kern/generic/rtc_get_time_ms.c
new file mode 100644
index 0000000..3e39c8f
--- /dev/null
+++ b/grub-core/kern/generic/rtc_get_time_ms.c
@@ -0,0 +1,38 @@
+/* rtc_get_time_ms.c - get_time_ms implementation using platform RTC.
+ * The generic implementation of these functions can be used for architectures
+ * or platforms that do not have a more specialized implementation. */
+/*
+ * 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/time.h>
+#include <grub/misc.h>
+#include <grub/machine/time.h>
+
+/* Calculate the time in milliseconds since the epoch based on the RTC. */
+grub_uint64_t
+grub_rtc_get_time_ms (void)
+{
+ /* By dimensional analysis:
+
+ 1000 ms N rtc ticks 1 s
+ ------- * ----------- * ----------- = 1000*N/T ms
+ 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 ? : 1000, 0);
+}
diff --git a/grub-core/kern/i386/coreboot/cbtable.c b/grub-core/kern/i386/coreboot/cbtable.c
new file mode 100644
index 0000000..34a2b59
--- /dev/null
+++ b/grub-core/kern/i386/coreboot/cbtable.c
@@ -0,0 +1,44 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,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/i386/coreboot/memory.h>
+#include <grub/coreboot/lbio.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+grub_linuxbios_table_header_t
+grub_linuxbios_get_tables (void)
+{
+ grub_linuxbios_table_header_t table_header;
+ /* Assuming table_header is aligned to its size (8 bytes). */
+ for (table_header = (grub_linuxbios_table_header_t) 0x500;
+ table_header < (grub_linuxbios_table_header_t) 0x1000; table_header++)
+ if (grub_linuxbios_check_signature (table_header))
+ return table_header;
+
+ for (table_header = (grub_linuxbios_table_header_t) 0xf0000;
+ table_header < (grub_linuxbios_table_header_t) 0x100000; table_header++)
+ if (grub_linuxbios_check_signature (table_header))
+ return table_header;
+
+ return 0;
+}
diff --git a/grub-core/kern/i386/coreboot/init.c b/grub-core/kern/i386/coreboot/init.c
new file mode 100644
index 0000000..3314f02
--- /dev/null
+++ b/grub-core/kern/i386/coreboot/init.c
@@ -0,0 +1,143 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,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/kernel.h>
+#include <grub/mm.h>
+#include <grub/machine/time.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/console.h>
+#include <grub/offsets.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/loader.h>
+#include <grub/env.h>
+#include <grub/cache.h>
+#include <grub/time.h>
+#include <grub/symbol.h>
+#include <grub/cpu/io.h>
+#include <grub/cpu/floppy.h>
+#include <grub/cpu/tsc.h>
+#include <grub/video.h>
+
+extern grub_uint8_t _start[];
+extern grub_uint8_t _end[];
+extern grub_uint8_t _edata[];
+
+void __attribute__ ((noreturn))
+grub_exit (void)
+{
+ /* We can't use grub_fatal() in this function. This would create an infinite
+ loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */
+ while (1)
+ grub_cpu_idle ();
+}
+
+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
+heap_init (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data __attribute__ ((unused)))
+{
+ grub_uint64_t begin = addr, end = addr + size;
+
+#if GRUB_CPU_SIZEOF_VOID_P == 4
+ /* Restrict ourselves to 32-bit memory space. */
+ if (begin > GRUB_ULONG_MAX)
+ return 0;
+ if (end > GRUB_ULONG_MAX)
+ end = GRUB_ULONG_MAX;
+#endif
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+
+ /* Avoid the lower memory. */
+ if (begin < GRUB_MEMORY_MACHINE_LOWER_SIZE)
+ begin = GRUB_MEMORY_MACHINE_LOWER_SIZE;
+
+ if (modend && begin < modend)
+ begin = modend;
+
+ if (end <= begin)
+ return 0;
+
+ grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - begin));
+
+ have_memory = 1;
+
+ return 0;
+}
+
+#ifndef GRUB_MACHINE_MULTIBOOT
+
+void
+grub_machine_init (void)
+{
+ modend = grub_modules_get_end ();
+
+ grub_video_coreboot_fb_early_init ();
+
+ 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 ();
+
+ grub_font_init ();
+ grub_gfxterm_init ();
+
+ grub_tsc_init ();
+}
+
+#else
+
+void
+grub_machine_init (void)
+{
+ modend = grub_modules_get_end ();
+
+ grub_vga_text_init ();
+
+ grub_machine_mmap_init ();
+ grub_machine_mmap_iterate (heap_init, NULL);
+
+ grub_tsc_init ();
+}
+
+#endif
+
+void
+grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
+ char **path __attribute__ ((unused)))
+{
+}
+
+void
+grub_machine_fini (int flags)
+{
+ if (flags & GRUB_LOADER_FLAG_NORETURN)
+ grub_vga_text_fini ();
+ grub_stop_floppy ();
+}
diff --git a/grub-core/kern/i386/coreboot/startup.S b/grub-core/kern/i386/coreboot/startup.S
new file mode 100644
index 0000000..df6adba
--- /dev/null
+++ b/grub-core/kern/i386/coreboot/startup.S
@@ -0,0 +1,62 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/machine/memory.h>
+#include <grub/offsets.h>
+#include <multiboot.h>
+#include <multiboot2.h>
+
+/*
+ * Note: GRUB is compiled with the options -mrtd and -mregparm=3.
+ * So the first three arguments are passed in %eax, %edx, and %ecx,
+ * respectively, and if a function has a fixed number of arguments
+ * and the number if greater than three, the function must return
+ * with "ret $N" where N is ((the number of arguments) - 3) * 4.
+ */
+
+ .file "startup.S"
+ .text
+ .globl start, _start
+start:
+_start:
+#ifdef GRUB_MACHINE_MULTIBOOT
+ cmpl $MULTIBOOT_BOOTLOADER_MAGIC, %eax
+ jne 0f
+ movl %ebx, EXT_C(startup_multiboot_info)
+0:
+#endif
+
+ /* initialize the stack */
+ movl $GRUB_MEMORY_MACHINE_PROT_STACK, %esp
+
+ /* jump to the main body of C code */
+ jmp EXT_C(grub_main)
+
+/*
+ * Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
+ */
+ .p2align 2 /* force 4-byte alignment */
+multiboot_header:
+ /* magic */
+ .long 0x1BADB002
+ /* flags */
+ .long MULTIBOOT_MEMORY_INFO
+ /* checksum */
+ .long -0x1BADB002 - MULTIBOOT_MEMORY_INFO
+
diff --git a/grub-core/kern/i386/dl.c b/grub-core/kern/i386/dl.c
new file mode 100644
index 0000000..1346da5
--- /dev/null
+++ b/grub-core/kern/i386/dl.c
@@ -0,0 +1,81 @@
+/* dl-386.c - arch-dependent part of loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/i18n.h>
+
+/* Check if EHDR is a valid ELF header. */
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ Elf_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+ if (e->e_ident[EI_CLASS] != ELFCLASS32
+ || e->e_ident[EI_DATA] != ELFDATA2LSB
+ || e->e_machine != EM_386)
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
+
+/* Relocate symbols. */
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ Elf_Rel *rel, *max;
+
+ for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
+ max = (Elf_Rel *) ((char *) rel + s->sh_size);
+ rel < max;
+ rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
+ {
+ Elf_Word *addr;
+ Elf_Sym *sym;
+
+ if (seg->size < rel->r_offset)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
+ sym = (Elf_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel->r_info));
+
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case R_386_32:
+ *addr += sym->st_value;
+ break;
+
+ case R_386_PC32:
+ *addr += (sym->st_value - (grub_addr_t) addr);
+ break;
+ default:
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%x is not implemented yet"),
+ ELF_R_TYPE (rel->r_info));
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/i386/efi/init.c b/grub-core/kern/i386/efi/init.c
new file mode 100644
index 0000000..46476e2
--- /dev/null
+++ b/grub-core/kern/i386/efi/init.c
@@ -0,0 +1,48 @@
+/* init.c - initialize an x86-based EFI system */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/cache.h>
+#include <grub/kernel.h>
+#include <grub/efi/efi.h>
+#include <grub/i386/tsc.h>
+#include <grub/loader.h>
+
+void
+grub_machine_init (void)
+{
+ grub_efi_init ();
+ grub_tsc_init ();
+}
+
+void
+grub_machine_fini (int flags)
+{
+ if (!(flags & GRUB_LOADER_FLAG_NORETURN))
+ return;
+
+ grub_efi_fini ();
+
+ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY))
+ grub_efi_memory_fini ();
+}
diff --git a/grub-core/kern/i386/efi/startup.S b/grub-core/kern/i386/efi/startup.S
new file mode 100644
index 0000000..fc5ea3d
--- /dev/null
+++ b/grub-core/kern/i386/efi/startup.S
@@ -0,0 +1,36 @@
+/* startup.S - bootstrap GRUB itself */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/symbol.h>
+
+ .file "startup.S"
+ .text
+ .globl start, _start
+start:
+_start:
+ /*
+ * EFI_SYSTEM_TABLE * and EFI_HANDLE are passed on the stack.
+ */
+ movl 4(%esp), %eax
+ movl %eax, EXT_C(grub_efi_image_handle)
+ movl 8(%esp), %eax
+ movl %eax, EXT_C(grub_efi_system_table)
+ call EXT_C(grub_main)
+ ret
diff --git a/grub-core/kern/i386/efi/tsc.c b/grub-core/kern/i386/efi/tsc.c
new file mode 100644
index 0000000..4b93ba8
--- /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/ieee1275/startup.S b/grub-core/kern/i386/ieee1275/startup.S
new file mode 100644
index 0000000..62cf348
--- /dev/null
+++ b/grub-core/kern/i386/ieee1275/startup.S
@@ -0,0 +1,40 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/offsets.h>
+#include <multiboot.h>
+#include <multiboot2.h>
+
+/*
+ * Note: GRUB is compiled with the options -mrtd and -mregparm=3.
+ * So the first three arguments are passed in %eax, %edx, and %ecx,
+ * respectively, and if a function has a fixed number of arguments
+ * and the number if greater than three, the function must return
+ * with "ret $N" where N is ((the number of arguments) - 3) * 4.
+ */
+
+ .file "startup.S"
+ .text
+ .globl start, _start
+
+start:
+_start:
+ movl %eax, EXT_C(grub_ieee1275_entry_fn)
+ jmp EXT_C(grub_main)
+
diff --git a/grub-core/kern/i386/int.S b/grub-core/kern/i386/int.S
new file mode 100644
index 0000000..862a542
--- /dev/null
+++ b/grub-core/kern/i386/int.S
@@ -0,0 +1,134 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+FUNCTION(grub_bios_interrupt)
+ pushf
+ cli
+ popf
+ pushl %ebp
+ pushl %ecx
+ pushl %eax
+ pushl %ebx
+ pushl %esi
+ pushl %edi
+ pushl %edx
+
+ movb %al, intno
+ movl (%edx), %eax
+ movl %eax, LOCAL(bios_register_eax)
+ movw 4(%edx), %ax
+ movw %ax, LOCAL(bios_register_es)
+ movw 6(%edx), %ax
+ movw %ax, LOCAL(bios_register_ds)
+ movw 8(%edx), %ax
+ movw %ax, LOCAL(bios_register_flags)
+
+ movl 12(%edx), %ebx
+ movl 16(%edx), %ecx
+ movl 20(%edx), %edi
+ 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
+ cli
+
+ mov %ds, %ax
+ push %ax
+
+ /* movw imm16, %ax*/
+ .byte 0xb8
+LOCAL(bios_register_es):
+ .short 0
+ movw %ax, %es
+ /* movw imm16, %ax*/
+ .byte 0xb8
+LOCAL(bios_register_ds):
+ .short 0
+ movw %ax, %ds
+
+ /* movw imm16, %ax*/
+ .byte 0xb8
+LOCAL(bios_register_flags):
+ .short 0
+ push %ax
+ popf
+
+ /* movl imm32, %eax*/
+ .byte 0x66, 0xb8
+LOCAL(bios_register_eax):
+ .long 0
+
+ /* int imm8. */
+ .byte 0xcd
+intno:
+ .byte 0
+
+ movl %eax, %cs:LOCAL(bios_register_eax)
+ movw %ds, %ax
+ movw %ax, %cs:LOCAL(bios_register_ds)
+ pop %ax
+ mov %ax, %ds
+ pushf
+ pop %ax
+ movw %ax, LOCAL(bios_register_flags)
+ mov %es, %ax
+ movw %ax, LOCAL(bios_register_es)
+
+ popf
+
+VARIABLE(grub_bios_via_workaround2)
+ .byte 0x90, 0x90
+
+ REAL_TO_PROT
+ .code32
+
+ popl %eax
+
+ movl %ebx, 12(%eax)
+ movl %ecx, 16(%eax)
+ movl %edi, 20(%eax)
+ movl %esi, 24(%eax)
+ movl %edx, 28(%eax)
+
+ movl %eax, %edx
+
+ movl LOCAL(bios_register_eax), %eax
+ movl %eax, (%edx)
+ movw LOCAL(bios_register_es), %ax
+ movw %ax, 4(%edx)
+ movw LOCAL(bios_register_ds), %ax
+ movw %ax, 6(%edx)
+ movw LOCAL(bios_register_flags), %ax
+ movw %ax, 8(%edx)
+
+ popl %edi
+ popl %esi
+ popl %ebx
+ popl %eax
+ popl %ecx
+ popl %ebp
+ ret
diff --git a/grub-core/kern/i386/multiboot_mmap.c b/grub-core/kern/i386/multiboot_mmap.c
new file mode 100644
index 0000000..e8f4f34
--- /dev/null
+++ b/grub-core/kern/i386/multiboot_mmap.c
@@ -0,0 +1,73 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/memory.h>
+#include <grub/types.h>
+#include <grub/multiboot.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+
+/* A pointer to the MBI in its initial location. */
+struct multiboot_info *startup_multiboot_info;
+
+/* The MBI has to be copied to our BSS so that it won't be
+ overwritten. This is its final location. */
+static struct multiboot_info kern_multiboot_info;
+
+/* Unfortunately we can't use heap at this point. But 32 looks like a sane
+ limit (used by memtest86). */
+static grub_uint8_t mmap_entries[sizeof (struct multiboot_mmap_entry) * 32];
+
+void
+grub_machine_mmap_init (void)
+{
+ if (! startup_multiboot_info)
+ grub_fatal ("Unable to find Multiboot Information (is CONFIG_MULTIBOOT disabled in coreboot?)");
+
+ /* Move MBI to a safe place. */
+ grub_memmove (&kern_multiboot_info, startup_multiboot_info, sizeof (struct multiboot_info));
+
+ if ((kern_multiboot_info.flags & MULTIBOOT_INFO_MEM_MAP) == 0)
+ grub_fatal ("Missing Multiboot memory information");
+
+ /* Move the memory map to a safe place. */
+ if (kern_multiboot_info.mmap_length > sizeof (mmap_entries))
+ {
+ grub_printf ("WARNING: Memory map size exceeds limit (0x%x > 0x%x); it will be truncated\n",
+ kern_multiboot_info.mmap_length, sizeof (mmap_entries));
+ kern_multiboot_info.mmap_length = sizeof (mmap_entries);
+ }
+ grub_memmove (mmap_entries, (void *) kern_multiboot_info.mmap_addr, kern_multiboot_info.mmap_length);
+ kern_multiboot_info.mmap_addr = (grub_uint32_t) mmap_entries;
+}
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ struct multiboot_mmap_entry *entry = (void *) kern_multiboot_info.mmap_addr;
+
+ while ((unsigned long) entry < kern_multiboot_info.mmap_addr + kern_multiboot_info.mmap_length)
+ {
+ if (hook (entry->addr, entry->len, entry->type, hook_data))
+ break;
+
+ entry = (void *) ((grub_addr_t) entry + entry->size + sizeof (entry->size));
+ }
+
+ return 0;
+}
diff --git a/grub-core/kern/i386/pc/acpi.c b/grub-core/kern/i386/pc/acpi.c
new file mode 100644
index 0000000..297f5d0
--- /dev/null
+++ b/grub-core/kern/i386/pc/acpi.c
@@ -0,0 +1,83 @@
+/* acpi.c - get acpi tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/acpi.h>
+#include <grub/misc.h>
+
+struct grub_acpi_rsdp_v10 *
+grub_machine_acpi_get_rsdpv1 (void)
+{
+ int ebda_len;
+ grub_uint8_t *ebda, *ptr;
+
+ 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) /* 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)
+ 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;
+ return 0;
+}
+
+struct grub_acpi_rsdp_v20 *
+grub_machine_acpi_get_rsdpv2 (void)
+{
+ int ebda_len;
+ grub_uint8_t *ebda, *ptr;
+
+ 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) /* 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
+ && ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024
+ && grub_byte_checksum (ptr, ((struct grub_acpi_rsdp_v20 *) ptr)->length)
+ == 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)
+ 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
+ && ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024
+ && grub_byte_checksum (ptr, ((struct grub_acpi_rsdp_v20 *) ptr)->length)
+ == 0)
+ return (struct grub_acpi_rsdp_v20 *) ptr;
+ return 0;
+}
diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c
new file mode 100644
index 0000000..27bc68b
--- /dev/null
+++ b/grub-core/kern/i386/pc/init.c
@@ -0,0 +1,271 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/kernel.h>
+#include <grub/mm.h>
+#include <grub/machine/boot.h>
+#include <grub/i386/floppy.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/console.h>
+#include <grub/machine/kernel.h>
+#include <grub/machine/int.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/loader.h>
+#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>
+
+struct mem_region
+{
+ grub_addr_t addr;
+ grub_size_t size;
+};
+
+#define MAX_REGIONS 32
+
+static struct mem_region mem_regions[MAX_REGIONS];
+static int num_regions;
+
+void (*grub_pc_net_config) (char **device, char **path);
+
+/*
+ * return the real time in ticks, of which there are about
+ * 18-20 per second
+ */
+grub_uint64_t
+grub_rtc_get_time_ms (void)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x1a, &regs);
+
+ return ((regs.ecx << 16) | (regs.edx & 0xffff)) * 55ULL;
+}
+
+void
+grub_machine_get_bootlocation (char **device, char **path)
+{
+ char *ptr;
+ grub_uint8_t boot_drive, dos_part, bsd_part;
+
+ boot_drive = (grub_boot_device >> 24);
+ dos_part = (grub_boot_device >> 16);
+ bsd_part = (grub_boot_device >> 8);
+
+ /* No hardcoded root partition - make it from the boot drive and the
+ partition number encoded at the install time. */
+ if (boot_drive == GRUB_BOOT_MACHINE_PXE_DL)
+ {
+ if (grub_pc_net_config)
+ grub_pc_net_config (device, path);
+ return;
+ }
+
+ /* XXX: This should be enough. */
+#define DEV_SIZE 100
+ *device = grub_malloc (DEV_SIZE);
+ ptr = *device;
+ grub_snprintf (*device, DEV_SIZE,
+ "%cd%u", (boot_drive & 0x80) ? 'h' : 'f',
+ boot_drive & 0x7f);
+ ptr += grub_strlen (ptr);
+
+ if (dos_part != 0xff)
+ grub_snprintf (ptr, DEV_SIZE - (ptr - *device),
+ ",%u", dos_part + 1);
+ ptr += grub_strlen (ptr);
+
+ if (bsd_part != 0xff)
+ grub_snprintf (ptr, DEV_SIZE - (ptr - *device), ",%u",
+ bsd_part + 1);
+ ptr += grub_strlen (ptr);
+ *ptr = 0;
+}
+
+/* Add a memory region. */
+static void
+add_mem_region (grub_addr_t addr, grub_size_t size)
+{
+ if (num_regions == MAX_REGIONS)
+ /* Ignore. */
+ return;
+
+ mem_regions[num_regions].addr = addr;
+ mem_regions[num_regions].size = size;
+ num_regions++;
+}
+
+/* Compact memory regions. */
+static void
+compact_mem_regions (void)
+{
+ int i, j;
+
+ /* Sort them. */
+ for (i = 0; i < num_regions - 1; i++)
+ for (j = i + 1; j < num_regions; j++)
+ if (mem_regions[i].addr > mem_regions[j].addr)
+ {
+ struct mem_region tmp = mem_regions[i];
+ mem_regions[i] = mem_regions[j];
+ mem_regions[j] = tmp;
+ }
+
+ /* Merge overlaps. */
+ for (i = 0; i < num_regions - 1; i++)
+ if (mem_regions[i].addr + mem_regions[i].size >= mem_regions[i + 1].addr)
+ {
+ j = i + 1;
+
+ if (mem_regions[i].addr + mem_regions[i].size
+ < mem_regions[j].addr + mem_regions[j].size)
+ mem_regions[i].size = (mem_regions[j].addr + mem_regions[j].size
+ - mem_regions[i].addr);
+
+ grub_memmove (mem_regions + j, mem_regions + j + 1,
+ (num_regions - j - 1) * sizeof (struct mem_region));
+ i--;
+ num_regions--;
+ }
+}
+
+grub_addr_t grub_modbase;
+extern grub_uint8_t _start[], _edata[];
+
+/* Helper for grub_machine_init. */
+static int
+mmap_iterate_hook (grub_uint64_t addr, grub_uint64_t size,
+ grub_memory_type_t type,
+ void *data __attribute__ ((unused)))
+{
+ /* Avoid the lower memory. */
+ if (addr < GRUB_MEMORY_MACHINE_UPPER_START)
+ {
+ if (size <= GRUB_MEMORY_MACHINE_UPPER_START - addr)
+ return 0;
+
+ size -= GRUB_MEMORY_MACHINE_UPPER_START - addr;
+ addr = GRUB_MEMORY_MACHINE_UPPER_START;
+ }
+
+ /* Ignore >4GB. */
+ if (addr <= 0xFFFFFFFF && type == GRUB_MEMORY_AVAILABLE)
+ {
+ grub_size_t len;
+
+ len = (grub_size_t) ((addr + size > 0xFFFFFFFF)
+ ? 0xFFFFFFFF - addr
+ : size);
+ add_mem_region (addr, len);
+ }
+
+ 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)
+{
+ int i;
+#if 0
+ int grub_lower_mem;
+#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. */
+ grub_console_init ();
+
+ /* This sanity check is useless since top of GRUB_MEMORY_MACHINE_RESERVED_END
+ is used for stack and if it's unavailable we wouldn't have gotten so far.
+ */
+#if 0
+ grub_lower_mem = grub_get_conv_memsize () << 10;
+
+ /* Sanity check. */
+ if (grub_lower_mem < GRUB_MEMORY_MACHINE_RESERVED_END)
+ grub_fatal ("too small memory");
+#endif
+
+/* FIXME: This prevents loader/i386/linux.c from using low memory. When our
+ heap implements support for requesting a chunk in low memory, this should
+ no longer be a problem. */
+#if 0
+ /* Add the lower memory into free memory. */
+ if (grub_lower_mem >= GRUB_MEMORY_MACHINE_RESERVED_END)
+ add_mem_region (GRUB_MEMORY_MACHINE_RESERVED_END,
+ grub_lower_mem - GRUB_MEMORY_MACHINE_RESERVED_END);
+#endif
+
+ grub_machine_mmap_iterate (mmap_iterate_hook, NULL);
+
+ compact_mem_regions ();
+
+ modend = grub_modules_get_end ();
+ for (i = 0; i < num_regions; i++)
+ {
+ grub_addr_t beg = mem_regions[i].addr;
+ grub_addr_t fin = mem_regions[i].addr + mem_regions[i].size;
+ if (modend && beg < modend)
+ beg = modend;
+ if (beg >= fin)
+ continue;
+ grub_mm_init_region ((void *) beg, fin - beg);
+ }
+
+ grub_tsc_init ();
+}
+
+void
+grub_machine_fini (int flags)
+{
+ if (flags & GRUB_LOADER_FLAG_NORETURN)
+ grub_console_fini ();
+ grub_stop_floppy ();
+}
diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c
new file mode 100644
index 0000000..c0c3c35
--- /dev/null
+++ b/grub-core/kern/i386/pc/mmap.c
@@ -0,0 +1,193 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/memory.h>
+#include <grub/machine/int.h>
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+
+struct grub_machine_mmap_entry
+{
+ grub_uint32_t size;
+ grub_uint64_t addr;
+ grub_uint64_t len;
+#define GRUB_MACHINE_MEMORY_AVAILABLE 1
+#define GRUB_MACHINE_MEMORY_RESERVED 2
+#define GRUB_MACHINE_MEMORY_ACPI 3
+#define GRUB_MACHINE_MEMORY_NVS 4
+#define GRUB_MACHINE_MEMORY_BADRAM 5
+ grub_uint32_t type;
+} GRUB_PACKED;
+
+
+/*
+ *
+ * grub_get_conv_memsize(i) : return the conventional memory size in KB.
+ * BIOS call "INT 12H" to get conventional memory size
+ * The return value in AX.
+ */
+static inline grub_uint16_t
+grub_get_conv_memsize (void)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x12, &regs);
+ return regs.eax & 0xffff;
+}
+
+/*
+ * grub_get_ext_memsize() : return the extended memory size in KB.
+ * BIOS call "INT 15H, AH=88H" to get extended memory size
+ * The return value in AX.
+ *
+ */
+static inline grub_uint16_t
+grub_get_ext_memsize (void)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x8800;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x15, &regs);
+ return regs.eax & 0xffff;
+}
+
+/* Get a packed EISA memory map. Lower 16 bits are between 1MB and 16MB
+ in 1KB parts, and upper 16 bits are above 16MB in 64KB parts. If error, return zero.
+ BIOS call "INT 15H, AH=E801H" to get EISA memory map,
+ AX = memory between 1M and 16M in 1K parts.
+ BX = memory above 16M in 64K parts.
+*/
+
+static inline grub_uint32_t
+grub_get_eisa_mmap (void)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ regs.eax = 0xe801;
+ grub_bios_interrupt (0x15, &regs);
+
+ if ((regs.eax & 0xff00) == 0x8600)
+ return 0;
+
+ return (regs.eax & 0xffff) | (regs.ebx << 16);
+}
+
+/*
+ *
+ * grub_get_mmap_entry(addr, cont) : address and old continuation value (zero to
+ * start), for the Query System Address Map BIOS call.
+ *
+ * Sets the first 4-byte int value of "addr" to the size returned by
+ * the call. If the call fails, sets it to zero.
+ *
+ * Returns: new (non-zero) continuation value, 0 if done.
+ */
+/* Get a memory map entry. Return next continuation value. Zero means
+ the end. */
+static grub_uint32_t
+grub_get_mmap_entry (struct grub_machine_mmap_entry *entry,
+ grub_uint32_t cont)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+
+ /* place address (+4) in ES:DI */
+ regs.es = ((grub_addr_t) &entry->addr) >> 4;
+ regs.edi = ((grub_addr_t) &entry->addr) & 0xf;
+
+ /* set continuation value */
+ regs.ebx = cont;
+
+ /* set default maximum buffer size */
+ regs.ecx = sizeof (*entry) - sizeof (entry->size);
+
+ /* set EDX to 'SMAP' */
+ regs.edx = 0x534d4150;
+
+ regs.eax = 0xe820;
+ grub_bios_interrupt (0x15, &regs);
+
+ /* write length of buffer (zero if error) into ADDR */
+ if ((regs.flags & GRUB_CPU_INT_FLAGS_CARRY) || regs.eax != 0x534d4150
+ || regs.ecx < 0x14 || regs.ecx > 0x400)
+ entry->size = 0;
+ else
+ entry->size = regs.ecx;
+
+ /* return the continuation value */
+ return regs.ebx;
+}
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ 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;
+
+ while (1)
+ {
+ grub_memset (entry, 0, sizeof (*entry));
+
+ cont = grub_get_mmap_entry (entry, cont);
+
+ if (!entry->size)
+ 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;
+
+ if (! cont)
+ break;
+ }
+
+ if (!e820_works)
+ {
+ grub_uint32_t eisa_mmap = grub_get_eisa_mmap ();
+
+ if (hook (0x0, ((grub_uint32_t) grub_get_conv_memsize ()) << 10,
+ GRUB_MEMORY_AVAILABLE, hook_data))
+ return 0;
+
+ if (eisa_mmap)
+ {
+ if (hook (0x100000, (eisa_mmap & 0xFFFF) << 10,
+ GRUB_MEMORY_AVAILABLE, hook_data) == 0)
+ hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MEMORY_AVAILABLE,
+ hook_data);
+ }
+ else
+ hook (0x100000, ((grub_uint32_t) grub_get_ext_memsize ()) << 10,
+ GRUB_MEMORY_AVAILABLE, hook_data);
+ }
+
+ return 0;
+}
diff --git a/grub-core/kern/i386/pc/startup.S b/grub-core/kern/i386/pc/startup.S
new file mode 100644
index 0000000..b8a9b33
--- /dev/null
+++ b/grub-core/kern/i386/pc/startup.S
@@ -0,0 +1,217 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008,2009,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/*
+ * Note: These functions defined in this file may be called from C.
+ * Be careful of that you must not modify some registers. Quote
+ * from gcc-2.95.2/gcc/config/i386/i386.h:
+
+ 1 for registers not available across function calls.
+ These must include the FIXED_REGISTERS and also any
+ registers that can be used without being saved.
+ The latter must include the registers where values are returned
+ and the register where structure-value addresses are passed.
+ Aside from that, you can include as many other registers as you like.
+
+ ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg
+{ 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
+ */
+
+/*
+ * Note: GRUB is compiled with the options -mrtd and -mregparm=3.
+ * So the first three arguments are passed in %eax, %edx, and %ecx,
+ * respectively, and if a function has a fixed number of arguments
+ * and the number is greater than three, the function must return
+ * with "ret $N" where N is ((the number of arguments) - 3) * 4.
+ */
+
+#include <config.h>
+#include <grub/symbol.h>
+#include <multiboot.h>
+#ifdef __APPLE__
+#include <grub/i386/pc/memory.h>
+#endif
+
+ .file "startup.S"
+
+ .text
+
+ .globl start, _start, __start
+start:
+_start:
+__start:
+#ifdef __APPLE__
+LOCAL(start):
+#endif
+ .code32
+
+ movl %ecx, (LOCAL(real_to_prot_addr) - _start) (%esi)
+ movl %edi, (LOCAL(prot_to_real_addr) - _start) (%esi)
+ movl %eax, (EXT_C(grub_realidt) - _start) (%esi)
+
+ /* copy back the decompressed part (except the modules) */
+#ifdef __APPLE__
+ movl $EXT_C(_edata), %ecx
+ subl $LOCAL(start), %ecx
+#else
+ movl $(_edata - _start), %ecx
+#endif
+ movl $(_start), %edi
+ rep
+ movsb
+
+ movl $LOCAL (cont), %esi
+ jmp *%esi
+LOCAL(cont):
+
+#if 0
+ /* copy modules before cleaning out the bss */
+ movl EXT_C(grub_total_module_size), %ecx
+ movl EXT_C(grub_kernel_image_size), %esi
+ addl %ecx, %esi
+ addl $_start, %esi
+ decl %esi
+ movl $END_SYMBOL, %edi
+ addl %ecx, %edi
+ decl %edi
+ std
+ rep
+ movsb
+#endif
+
+#ifdef __APPLE__
+ /* clean out the bss */
+ movl $EXT_C(_edata), %edi
+
+ /* compute the bss length */
+ movl $GRUB_MEMORY_MACHINE_SCRATCH_ADDR, %ecx
+#else
+ /* clean out the bss */
+ movl $BSS_START_SYMBOL, %edi
+
+ /* compute the bss length */
+ movl $END_SYMBOL, %ecx
+#endif
+ subl %edi, %ecx
+
+ /* clean out */
+ xorl %eax, %eax
+ cld
+ rep
+ stosb
+
+ movl %edx, EXT_C(grub_boot_device)
+
+ /*
+ * Call the start of main body of C code.
+ */
+ call EXT_C(grub_main)
+
+LOCAL(real_to_prot_addr):
+ .long 0
+LOCAL(prot_to_real_addr):
+ .long 0
+
+ .macro PROT_TO_REAL
+ movl LOCAL(prot_to_real_addr), %eax
+ call *%eax
+ .endm
+
+ .macro REAL_TO_PROT
+ movl LOCAL(real_to_prot_addr), %eax
+ calll *%eax
+ .endm
+
+/*
+ * grub_exit()
+ *
+ * Exit the system.
+ */
+FUNCTION(grub_exit)
+ PROT_TO_REAL
+ .code16
+ /* Tell the BIOS a boot failure. If this does not work, reboot. */
+ int $0x18
+ /* set 0x472 to 0x0000 for cold boot (0x1234 for warm boot) */
+ xorw %ax, %ax
+ movw $0x0472, %di
+ movw %ax, (%di)
+ ljmp $0xf000, $0xfff0
+ .code32
+
+/*
+ * int grub_pxe_call (int func, void* data, grub_uint32_t pxe_rm_entry);
+ */
+FUNCTION(grub_pxe_call)
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %esi
+ pushl %edi
+ pushl %ebx
+
+ movl %ecx, %ebx
+ movl %eax, %ecx
+ movl %edx, %eax
+ andl $0xF, %eax
+ shrl $4, %edx
+ shll $16, %edx
+ addl %eax, %edx
+
+ PROT_TO_REAL
+ .code16
+
+ pushl %ebx
+ pushl %edx
+ pushw %cx
+ movw %sp, %bx
+ lcall *%ss:6(%bx)
+ cld
+ addw $10, %sp
+ movw %ax, %cx
+
+ REAL_TO_PROT
+ .code32
+
+ movzwl %cx, %eax
+
+ popl %ebx
+ popl %edi
+ popl %esi
+ popl %ebp
+ ret
+
+#include "../int.S"
+
+VARIABLE(grub_realidt)
+ .long 0
+
+#ifdef __APPLE__
+ /* Older versions of objconv assume that there is the same number
+ of text and data sections. Hence this dummy. */
+ .section __TEXT, __zz_dummy
+ .byte 0
+ .globl EXT_C(_edata)
+ .globl EXT_C(grub_boot_device)
+ .zerofill __DATA, __aa_before_bss, EXT_C(_edata), 1, 0
+ .zerofill __DATA, __bss, EXT_C(grub_boot_device), 4, 2
+#else
+ .bss
+VARIABLE(grub_boot_device)
+ .long 0
+#endif
diff --git a/grub-core/kern/i386/qemu/init.c b/grub-core/kern/i386/qemu/init.c
new file mode 100644
index 0000000..271b6fb
--- /dev/null
+++ b/grub-core/kern/i386/qemu/init.c
@@ -0,0 +1,276 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,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/kernel.h>
+#include <grub/mm.h>
+#include <grub/machine/time.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/console.h>
+#include <grub/offsets.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/loader.h>
+#include <grub/env.h>
+#include <grub/cache.h>
+#include <grub/time.h>
+#include <grub/symbol.h>
+#include <grub/cpu/io.h>
+#include <grub/cpu/floppy.h>
+#include <grub/cpu/tsc.h>
+#include <grub/machine/kernel.h>
+#include <grub/pci.h>
+
+extern grub_uint8_t _start[];
+extern grub_uint8_t _end[];
+extern grub_uint8_t _edata[];
+
+void __attribute__ ((noreturn))
+grub_exit (void)
+{
+ /* We can't use grub_fatal() in this function. This would create an infinite
+ loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */
+ while (1)
+ grub_cpu_idle ();
+}
+
+grub_addr_t grub_modbase;
+
+/* Helper for grub_machine_init. */
+static int
+heap_init (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data __attribute__ ((unused)))
+{
+ grub_uint64_t begin = addr, end = addr + size;
+
+#if GRUB_CPU_SIZEOF_VOID_P == 4
+ /* Restrict ourselves to 32-bit memory space. */
+ if (begin > GRUB_ULONG_MAX)
+ return 0;
+ if (end > GRUB_ULONG_MAX)
+ end = GRUB_ULONG_MAX;
+#endif
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+
+ /* Avoid the lower memory. */
+ if (begin < GRUB_MEMORY_MACHINE_LOWER_SIZE)
+ begin = GRUB_MEMORY_MACHINE_LOWER_SIZE;
+
+ if (end <= begin)
+ return 0;
+
+ grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - begin));
+
+ return 0;
+}
+
+struct resource
+{
+ grub_pci_device_t dev;
+ grub_size_t size;
+ unsigned type:4;
+ unsigned bar:3;
+};
+
+struct iterator_ctx
+{
+ struct resource *resources;
+ grub_size_t nresources;
+};
+
+/* We don't support bridges, so can't have more than 32 devices. */
+#define MAX_DEVICES 32
+
+static int
+find_resources (grub_pci_device_t dev,
+ grub_pci_id_t pciid __attribute__ ((unused)),
+ void *data)
+{
+ struct iterator_ctx *ctx = data;
+ int bar;
+
+ if (ctx->nresources >= MAX_DEVICES * 6)
+ return 1;
+
+ for (bar = 0; bar < 6; bar++)
+ {
+ grub_pci_address_t addr;
+ grub_uint32_t ones, zeros, mask;
+ struct resource *res;
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0
+ + 4 * bar);
+ grub_pci_write (addr, 0xffffffff);
+ grub_pci_read (addr);
+ ones = grub_pci_read (addr);
+ grub_pci_write (addr, 0);
+ grub_pci_read (addr);
+ zeros = grub_pci_read (addr);
+ if (ones == zeros)
+ continue;
+ res = &ctx->resources[ctx->nresources++];
+ if ((zeros & GRUB_PCI_ADDR_SPACE_MASK) == GRUB_PCI_ADDR_SPACE_IO)
+ mask = GRUB_PCI_ADDR_SPACE_MASK;
+ else
+ mask = (GRUB_PCI_ADDR_MEM_TYPE_MASK | GRUB_PCI_ADDR_SPACE_MASK | GRUB_PCI_ADDR_MEM_PREFETCH);
+
+ res->type = ones & mask;
+ res->dev = dev;
+ res->bar = bar;
+ res->size = (~((zeros ^ ones)) | mask) + 1;
+ if ((zeros & (GRUB_PCI_ADDR_MEM_TYPE_MASK | GRUB_PCI_ADDR_SPACE_MASK))
+ == (GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_64))
+ bar++;
+ }
+ return 0;
+}
+
+static int
+enable_cards (grub_pci_device_t dev,
+ grub_pci_id_t pciid __attribute__ ((unused)),
+ void *data __attribute__ ((unused)))
+{
+ grub_uint16_t cmd = 0;
+ grub_pci_address_t addr;
+ grub_uint32_t class;
+ int bar;
+
+ for (bar = 0; bar < 6; bar++)
+ {
+ grub_uint32_t val;
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0
+ + 4 * bar);
+ val = grub_pci_read (addr);
+ if (!val)
+ continue;
+ if ((val & GRUB_PCI_ADDR_SPACE_MASK) == GRUB_PCI_ADDR_SPACE_IO)
+ cmd |= GRUB_PCI_COMMAND_IO_ENABLED;
+ else
+ cmd |= GRUB_PCI_COMMAND_MEM_ENABLED;
+ }
+
+ class = (grub_pci_read (addr) >> 16) & 0xffff;
+
+ if (class == GRUB_PCI_CLASS_SUBCLASS_VGA)
+ cmd |= GRUB_PCI_COMMAND_IO_ENABLED
+ | GRUB_PCI_COMMAND_MEM_ENABLED;
+
+ if (class == GRUB_PCI_CLASS_SUBCLASS_USB)
+ return 0;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write (addr, cmd);
+
+ return 0;
+}
+
+static void
+grub_pci_assign_addresses (void)
+{
+ struct iterator_ctx ctx;
+
+ {
+ struct resource resources[MAX_DEVICES * 6];
+ int done;
+ unsigned i;
+ ctx.nresources = 0;
+ ctx.resources = resources;
+ grub_uint32_t memptr = 0xf0000000;
+ grub_uint16_t ioptr = 0x1000;
+
+ grub_pci_iterate (find_resources, &ctx);
+ /* FIXME: do we need a better sort here? */
+ do
+ {
+ done = 0;
+ for (i = 0; i + 1 < ctx.nresources; i++)
+ if (resources[i].size < resources[i+1].size)
+ {
+ struct resource t;
+ t = resources[i];
+ resources[i] = resources[i+1];
+ resources[i+1] = t;
+ done = 1;
+ }
+ }
+ while (done);
+
+ for (i = 0; i < ctx.nresources; i++)
+ {
+ grub_pci_address_t addr;
+ addr = grub_pci_make_address (resources[i].dev,
+ GRUB_PCI_REG_ADDRESS_REG0
+ + 4 * resources[i].bar);
+ if ((resources[i].type & GRUB_PCI_ADDR_SPACE_MASK)
+ == GRUB_PCI_ADDR_SPACE_IO)
+ {
+ grub_pci_write (addr, ioptr | resources[i].type);
+ ioptr += resources[i].size;
+ }
+ else
+ {
+ grub_pci_write (addr, memptr | resources[i].type);
+ memptr += resources[i].size;
+ if ((resources[i].type & (GRUB_PCI_ADDR_MEM_TYPE_MASK
+ | GRUB_PCI_ADDR_SPACE_MASK))
+ == (GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_64))
+ {
+ addr = grub_pci_make_address (resources[i].dev,
+ GRUB_PCI_REG_ADDRESS_REG0
+ + 4 * resources[i].bar + 4);
+ grub_pci_write (addr, 0);
+ }
+ }
+ }
+ grub_pci_iterate (enable_cards, NULL);
+ }
+}
+
+void
+grub_machine_init (void)
+{
+ grub_modbase = grub_core_entry_addr + (_edata - _start);
+
+ grub_pci_assign_addresses ();
+
+ grub_qemu_init_cirrus ();
+
+ grub_vga_text_init ();
+
+ grub_machine_mmap_init ();
+ grub_machine_mmap_iterate (heap_init, NULL);
+
+
+ grub_tsc_init ();
+}
+
+void
+grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
+ char **path __attribute__ ((unused)))
+{
+}
+
+void
+grub_machine_fini (int flags)
+{
+ if (flags & GRUB_LOADER_FLAG_NORETURN)
+ grub_vga_text_fini ();
+ grub_stop_floppy ();
+}
diff --git a/grub-core/kern/i386/qemu/mmap.c b/grub-core/kern/i386/qemu/mmap.c
new file mode 100644
index 0000000..f449637
--- /dev/null
+++ b/grub-core/kern/i386/qemu/mmap.c
@@ -0,0 +1,107 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/i386/memory.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/boot.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/cmos.h>
+#include <grub/offsets.h>
+
+#define QEMU_CMOS_MEMSIZE_HIGH 0x35
+#define QEMU_CMOS_MEMSIZE_LOW 0x34
+
+#define QEMU_CMOS_MEMSIZE2_HIGH 0x31
+#define QEMU_CMOS_MEMSIZE2_LOW 0x30
+
+#define min(a,b) ((a) > (b) ? (b) : (a))
+
+extern char _start[];
+extern char _end[];
+
+static grub_uint64_t mem_size, above_4g;
+
+void
+grub_machine_mmap_init (void)
+{
+ grub_uint8_t high, low, b, c, d;
+ grub_cmos_read (QEMU_CMOS_MEMSIZE_HIGH, &high);
+ grub_cmos_read (QEMU_CMOS_MEMSIZE_LOW, &low);
+ mem_size = ((grub_uint64_t) high) << 24
+ | ((grub_uint64_t) low) << 16;
+ if (mem_size > 0)
+ {
+ /* Don't ask... */
+ mem_size += (16 * 1024 * 1024);
+ }
+ else
+ {
+ grub_cmos_read (QEMU_CMOS_MEMSIZE2_HIGH, &high);
+ grub_cmos_read (QEMU_CMOS_MEMSIZE2_LOW, &low);
+ mem_size
+ = ((((grub_uint64_t) high) << 18) | (((grub_uint64_t) low) << 10))
+ + 1024 * 1024;
+ }
+
+ grub_cmos_read (0x5b, &b);
+ grub_cmos_read (0x5c, &c);
+ grub_cmos_read (0x5d, &d);
+ above_4g = (((grub_uint64_t) b) << 16)
+ | (((grub_uint64_t) c) << 24)
+ | (((grub_uint64_t) d) << 32);
+}
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ if (hook (0x0,
+ (grub_addr_t) _start,
+ GRUB_MEMORY_AVAILABLE, hook_data))
+ return 1;
+
+ if (hook ((grub_addr_t) _end,
+ 0xa0000 - (grub_addr_t) _end,
+ GRUB_MEMORY_AVAILABLE, hook_data))
+ return 1;
+
+ if (hook (GRUB_MEMORY_MACHINE_UPPER,
+ 0x100000 - GRUB_MEMORY_MACHINE_UPPER,
+ GRUB_MEMORY_RESERVED, hook_data))
+ return 1;
+
+ /* Everything else is free. */
+ if (hook (0x100000,
+ min (mem_size, (grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE) - 0x100000,
+ GRUB_MEMORY_AVAILABLE, hook_data))
+ return 1;
+
+ /* Protect boot.img, which contains the gdt. It is mapped at the top of memory
+ (it is also mapped below 0x100000, but we already reserved that area). */
+ if (hook ((grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE,
+ GRUB_BOOT_MACHINE_SIZE,
+ GRUB_MEMORY_RESERVED, hook_data))
+ return 1;
+
+ if (above_4g != 0 && hook (0x100000000ULL, above_4g,
+ GRUB_MEMORY_AVAILABLE, hook_data))
+ return 1;
+
+ return 0;
+}
diff --git a/grub-core/kern/i386/qemu/startup.S b/grub-core/kern/i386/qemu/startup.S
new file mode 100644
index 0000000..0d89858
--- /dev/null
+++ b/grub-core/kern/i386/qemu/startup.S
@@ -0,0 +1,75 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/symbol.h>
+
+#include <grub/machine/memory.h>
+#include <grub/machine/kernel.h>
+
+ .text
+ .code32
+ .globl _start
+_start:
+ jmp codestart
+
+ .org GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR
+VARIABLE(grub_core_entry_addr)
+ .long 0
+
+codestart:
+ /* Relocate to low memory. First we figure out our location.
+ We will derive the rom start address from it. */
+ call 1f
+1: popl %esi
+
+ /* Rom size is a multiple of 64 kiB. With this we get the
+ value of `grub_core_entry_addr' in %esi. */
+ xorw %si, %si
+
+ movl $(_edata - _start), %ecx
+ movl $_start, %edi
+ cld
+ rep
+ movsb
+ ljmp $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $1f
+1:
+
+ /* clean out the bss */
+ movl $BSS_START_SYMBOL, %edi
+
+ /* compute the bss length */
+ movl $END_SYMBOL, %ecx
+ subl %edi, %ecx
+
+ /* clean out */
+ xorl %eax, %eax
+ cld
+ rep
+ stosb
+
+ /*
+ * Call the start of main body of C code.
+ */
+ call EXT_C(grub_main)
+
+ /* This should never happen. */
+ cli
+1:
+ hlt
+ jmp 1b
diff --git a/grub-core/kern/i386/realmode.S b/grub-core/kern/i386/realmode.S
new file mode 100644
index 0000000..265cdcb
--- /dev/null
+++ b/grub-core/kern/i386/realmode.S
@@ -0,0 +1,281 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/memory.h>
+
+/*
+ * Note: These functions defined in this file may be called from C.
+ * Be careful of that you must not modify some registers. Quote
+ * from gcc-2.95.2/gcc/config/i386/i386.h:
+
+ 1 for registers not available across function calls.
+ These must include the FIXED_REGISTERS and also any
+ registers that can be used without being saved.
+ The latter must include the registers where values are returned
+ and the register where structure-value addresses are passed.
+ Aside from that, you can include as many other registers as you like.
+
+ ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg
+{ 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
+ */
+
+/*
+ * Note: GRUB is compiled with the options -mrtd and -mregparm=3.
+ * So the first three arguments are passed in %eax, %edx, and %ecx,
+ * respectively, and if a function has a fixed number of arguments
+ * and the number if greater than three, the function must return
+ * with "ret $N" where N is ((the number of arguments) - 3) * 4.
+ */
+
+/*
+ * This is the area for all of the special variables.
+ */
+
+protstack:
+ .long GRUB_MEMORY_MACHINE_PROT_STACK
+
+ .macro PROT_TO_REAL
+ call prot_to_real
+ .endm
+
+ .macro REAL_TO_PROT
+ calll real_to_prot
+ .endm
+
+/*
+ * This is the Global Descriptor Table
+ *
+ * An entry, a "Segment Descriptor", looks like this:
+ *
+ * 31 24 19 16 7 0
+ * ------------------------------------------------------------
+ * | | |B| |A| | | |1|0|E|W|A| |
+ * | BASE 31..24 |G|/|L|V| LIMIT |P|DPL| TYPE | BASE 23:16 | 4
+ * | | |D| |L| 19..16| | |1|1|C|R|A| |
+ * ------------------------------------------------------------
+ * | | |
+ * | BASE 15..0 | LIMIT 15..0 | 0
+ * | | |
+ * ------------------------------------------------------------
+ *
+ * Note the ordering of the data items is reversed from the above
+ * description.
+ */
+
+ .p2align 5 /* force 32-byte alignment */
+gdt:
+ .word 0, 0
+ .byte 0, 0, 0, 0
+
+ /* -- code segment --
+ * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
+ * type = 32bit code execute/read, DPL = 0
+ */
+ .word 0xFFFF, 0
+ .byte 0, 0x9A, 0xCF, 0
+
+ /* -- data segment --
+ * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
+ * type = 32 bit data read/write, DPL = 0
+ */
+ .word 0xFFFF, 0
+ .byte 0, 0x92, 0xCF, 0
+
+ /* -- 16 bit real mode CS --
+ * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present
+ * type = 16 bit code execute/read only/conforming, DPL = 0
+ */
+ .word 0xFFFF, 0
+ .byte 0, 0x9E, 0, 0
+
+ /* -- 16 bit real mode DS --
+ * base = 0x00000000, limit 0x0FFFF (1 B Granularity), present
+ * type = 16 bit data read/write, DPL = 0
+ */
+ .word 0xFFFF, 0
+ .byte 0, 0x92, 0, 0
+
+
+ .p2align 5
+/* this is the GDT descriptor */
+gdtdesc:
+ .word 0x27 /* limit */
+ .long gdt /* addr */
+LOCAL(realidt):
+ .word 0x400
+ .long 0
+protidt:
+ .word 0
+ .long 0
+
+/*
+ * These next two routines, "real_to_prot" and "prot_to_real" are structured
+ * in a very specific way. Be very careful when changing them.
+ *
+ * NOTE: Use of either one messes up %eax and %ebp.
+ */
+
+real_to_prot:
+ .code16
+ cli
+
+ /* load the GDT register */
+ xorw %ax, %ax
+ movw %ax, %ds
+#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
+ orl $GRUB_MEMORY_CPU_CR0_PE_ON, %eax
+ movl %eax, %cr0
+
+ /* jump to relocation, flush prefetch queue, and reload %cs */
+ ljmpl $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg
+
+ .code32
+protcseg:
+ /* reload other segment registers */
+ movw $GRUB_MEMORY_MACHINE_PROT_MODE_DSEG, %ax
+ movw %ax, %ds
+ movw %ax, %es
+ movw %ax, %fs
+ movw %ax, %gs
+ movw %ax, %ss
+
+ /* put the return address in a known safe location */
+ movl (%esp), %eax
+ movl %eax, GRUB_MEMORY_MACHINE_REAL_STACK
+
+ /* get protected mode stack */
+ movl protstack, %eax
+ movl %eax, %esp
+ movl %eax, %ebp
+
+ /* get return address onto the right stack */
+ movl GRUB_MEMORY_MACHINE_REAL_STACK, %eax
+ movl %eax, (%esp)
+
+ /* zero %eax */
+ xorl %eax, %eax
+
+ sidt LOCAL(realidt)
+ lidt protidt
+
+ /* 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.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+prot_to_real:
+ /* just in case, set GDT */
+ lgdt gdtdesc
+
+ sidt protidt
+ lidt LOCAL(realidt)
+
+ /* save the protected mode stack */
+ movl %esp, %eax
+ movl %eax, protstack
+
+ /* get the return address */
+ movl (%esp), %eax
+ movl %eax, GRUB_MEMORY_MACHINE_REAL_STACK
+
+ /* set up new stack */
+ movl $GRUB_MEMORY_MACHINE_REAL_STACK, %eax
+ movl %eax, %esp
+ movl %eax, %ebp
+
+ /* set up segment limits */
+ movw $GRUB_MEMORY_MACHINE_PSEUDO_REAL_DSEG, %ax
+ movw %ax, %ds
+ movw %ax, %es
+ movw %ax, %fs
+ movw %ax, %gs
+ movw %ax, %ss
+
+ /* this might be an extra step */
+ /* jump to a 16 bit segment */
+ ljmp $GRUB_MEMORY_MACHINE_PSEUDO_REAL_CSEG, $tmpcseg
+
+tmpcseg:
+ .code16
+
+ /* clear the PE bit of CR0 */
+ movl %cr0, %eax
+ andl $(~GRUB_MEMORY_CPU_CR0_PE_ON), %eax
+ movl %eax, %cr0
+
+ /* flush prefetch queue, reload %cs */
+ ljmpl $0, $realcseg
+
+realcseg:
+ /* we are in real mode now
+ * set up the real mode segment registers : DS, SS, ES
+ */
+ /* zero %eax */
+ xorl %eax, %eax
+
+ movw %ax, %ds
+ movw %ax, %es
+ movw %ax, %fs
+ movw %ax, %gs
+ movw %ax, %ss
+
+#ifdef GRUB_MACHINE_PCBIOS
+ /* restore interrupts */
+ sti
+#endif
+
+ /* return on new stack! */
+ retl
+#endif
+ .code32
diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
new file mode 100644
index 0000000..9293b16
--- /dev/null
+++ b/grub-core/kern/i386/tsc.c
@@ -0,0 +1,78 @@
+/* kern/i386/tsc.c - x86 TSC time source implementation
+ * Requires Pentium or better x86 CPU that supports the RDTSC instruction.
+ * This module calibrates 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/cpuid.h>
+
+/* This defines the value TSC had at the epoch (that is, when we calibrated it). */
+static grub_uint64_t tsc_boot_time;
+
+/* Calibrated TSC rate. (In ms per 2^32 ticks) */
+/* We assume that the tick is less than 1 ms and hence this value fits
+ in 32-bit. */
+grub_uint32_t grub_tsc_rate;
+
+static grub_uint64_t
+grub_tsc_get_time_ms (void)
+{
+ grub_uint64_t a = grub_get_tsc () - tsc_boot_time;
+ grub_uint64_t ah = a >> 32;
+ grub_uint64_t al = a & 0xffffffff;
+
+ return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate;
+}
+
+static int
+calibrate_tsc_hardcode (void)
+{
+ grub_tsc_rate = 5368;/* 800 MHz */
+ return 1;
+}
+
+void
+grub_tsc_init (void)
+{
+ 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 ();
+
+#if defined (GRUB_MACHINE_XEN) || defined (GRUB_MACHINE_XEN_PVH)
+ (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
+#elif defined (GRUB_MACHINE_EFI)
+ (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || 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 0000000..67990bf
--- /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 0000000..c9c3616
--- /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/hypercall.S b/grub-core/kern/i386/xen/hypercall.S
new file mode 100644
index 0000000..09d75c3
--- /dev/null
+++ b/grub-core/kern/i386/xen/hypercall.S
@@ -0,0 +1,43 @@
+/* hypercall.S - wrappers for Xen hypercalls */
+/*
+ * 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/symbol.h>
+#include <grub/xen.h>
+
+FUNCTION(grub_xen_hypercall)
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %esi
+ pushl %edi
+ pushl %ebx
+
+ /* call number already in %eax. */
+ /* %edx -> %ebx*/
+ /* %ecx -> %ecx*/
+ movl %edx, %ebx
+ movl 8(%ebp), %edx
+ movl 12(%ebp), %esi
+ movl 16(%ebp), %edi
+ movl 20(%ebp), %ebp
+ int $0x82
+ popl %ebx
+ popl %edi
+ popl %esi
+ popl %ebp
+ ret
diff --git a/grub-core/kern/i386/xen/pvh.c b/grub-core/kern/i386/xen/pvh.c
new file mode 100644
index 0000000..91fbca8
--- /dev/null
+++ b/grub-core/kern/i386/xen/pvh.c
@@ -0,0 +1,369 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/memory.h>
+#include <grub/mm.h>
+#include <grub/i386/cpuid.h>
+#include <grub/i386/io.h>
+#include <grub/xen.h>
+#include <xen/hvm/start_info.h>
+#include <grub/i386/linux.h>
+#include <grub/machine/kernel.h>
+#include <grub/machine/memory.h>
+#include <xen/hvm/params.h>
+#include <xen/memory.h>
+
+#define XEN_MEMORY_MAP_SIZE 128
+
+grub_uint64_t grub_rsdp_addr;
+
+static char hypercall_page[GRUB_XEN_PAGE_SIZE]
+ __attribute__ ((aligned (GRUB_XEN_PAGE_SIZE)));
+
+static grub_uint32_t xen_cpuid_base;
+static struct start_info grub_xen_start_page;
+static struct grub_e820_mmap_entry map[XEN_MEMORY_MAP_SIZE];
+static unsigned int nr_map_entries;
+
+static void
+grub_xen_cons_msg (const char *msg)
+{
+ const char *c;
+
+ for (c = msg; *c; c++)
+ grub_outb (*c, XEN_HVM_DEBUGCONS_IOPORT);
+}
+
+static void
+grub_xen_panic (const char *msg)
+{
+ grub_xen_cons_msg (msg);
+ grub_xen_cons_msg ("System halted!\n");
+
+ asm volatile ("cli");
+
+ while (1)
+ {
+ asm volatile ("hlt");
+ }
+}
+
+static void
+grub_xen_cpuid_base (void)
+{
+ grub_uint32_t base, eax, signature[3];
+
+ for (base = 0x40000000; base < 0x40010000; base += 0x100)
+ {
+ grub_cpuid (base, eax, signature[0], signature[1], signature[2]);
+ if (!grub_memcmp ("XenVMMXenVMM", signature, 12) && (eax - base) >= 2)
+ {
+ xen_cpuid_base = base;
+ return;
+ }
+ }
+
+ grub_xen_panic ("Found no Xen signature!\n");
+}
+
+static void
+grub_xen_setup_hypercall_page (void)
+{
+ grub_uint32_t msr, addr, eax, ebx, ecx, edx;
+
+ /* Get base address of Xen-specific MSRs. */
+ grub_cpuid (xen_cpuid_base + 2, eax, ebx, ecx, edx);
+ msr = ebx;
+ addr = (grub_uint32_t) (&hypercall_page);
+
+ /* Specify hypercall page address for Xen. */
+ asm volatile ("wrmsr" : : "c" (msr), "a" (addr), "d" (0) : "memory");
+}
+
+int
+grub_xen_hypercall (grub_uint32_t callno, grub_uint32_t a0,
+ grub_uint32_t a1, grub_uint32_t a2,
+ grub_uint32_t a3, grub_uint32_t a4,
+ grub_uint32_t a5 __attribute__ ((unused)))
+{
+ grub_uint32_t res;
+
+ asm volatile ("call *%[callno]"
+ : "=a" (res), "+b" (a0), "+c" (a1), "+d" (a2),
+ "+S" (a3), "+D" (a4)
+ : [callno] "a" (&hypercall_page[callno * 32])
+ : "memory");
+ return res;
+}
+
+static grub_uint32_t
+grub_xen_get_param (int idx)
+{
+ struct xen_hvm_param xhv;
+ int r;
+
+ xhv.domid = DOMID_SELF;
+ xhv.index = idx;
+ r = grub_xen_hypercall (__HYPERVISOR_hvm_op, HVMOP_get_param,
+ (grub_uint32_t) (&xhv), 0, 0, 0, 0);
+ if (r < 0)
+ grub_xen_panic ("Could not get parameter from Xen!\n");
+ return xhv.value;
+}
+
+static void *
+grub_xen_add_physmap (unsigned int space, void *addr)
+{
+ struct xen_add_to_physmap xatp;
+
+ xatp.domid = DOMID_SELF;
+ xatp.idx = 0;
+ xatp.space = space;
+ xatp.gpfn = (grub_addr_t) addr >> GRUB_XEN_LOG_PAGE_SIZE;
+ if (grub_xen_hypercall (__HYPERVISOR_memory_op, XENMEM_add_to_physmap,
+ (grub_uint32_t) (&xatp), 0, 0, 0, 0))
+ grub_xen_panic ("Memory_op hypercall failed!\n");
+ return addr;
+}
+
+static void
+grub_xen_sort_mmap (void)
+{
+ grub_uint64_t from, to;
+ unsigned int i;
+ struct grub_e820_mmap_entry tmp;
+
+ /* Align map entries to page boundaries. */
+ for (i = 0; i < nr_map_entries; i++)
+ {
+ from = map[i].addr;
+ to = from + map[i].len;
+ if (map[i].type == GRUB_MEMORY_AVAILABLE)
+ {
+ from = ALIGN_UP (from, GRUB_XEN_PAGE_SIZE);
+ to = ALIGN_DOWN (to, GRUB_XEN_PAGE_SIZE);
+ }
+ else
+ {
+ from = ALIGN_DOWN (from, GRUB_XEN_PAGE_SIZE);
+ to = ALIGN_UP (to, GRUB_XEN_PAGE_SIZE);
+ }
+ map[i].addr = from;
+ map[i].len = to - from;
+ }
+
+ again:
+ /* Sort entries by start address. */
+ for (i = 1; i < nr_map_entries; i++)
+ {
+ if (map[i].addr >= map[i - 1].addr)
+ continue;
+ tmp = map[i];
+ map[i] = map[i - 1];
+ map[i - 1] = tmp;
+ i = 0;
+ }
+
+ /* Detect overlapping areas. */
+ for (i = 1; i < nr_map_entries; i++)
+ {
+ if (map[i].addr >= map[i - 1].addr + map[i - 1].len)
+ continue;
+ tmp = map[i - 1];
+ map[i - 1].len = map[i].addr - map[i - 1].addr;
+ if (map[i].addr + map[i].len >= tmp.addr + tmp.len)
+ continue;
+ if (nr_map_entries < ARRAY_SIZE (map))
+ {
+ map[nr_map_entries].addr = map[i].addr + map[i].len;
+ map[nr_map_entries].len = tmp.addr + tmp.len - map[nr_map_entries].addr;
+ map[nr_map_entries].type = tmp.type;
+ nr_map_entries++;
+ goto again;
+ }
+ }
+
+ /* Merge adjacent entries. */
+ for (i = 1; i < nr_map_entries; i++)
+ {
+ if (map[i].type == map[i - 1].type &&
+ map[i].addr == map[i - 1].addr + map[i - 1].len)
+ {
+ map[i - 1].len += map[i].len;
+ map[i] = map[nr_map_entries - 1];
+ nr_map_entries--;
+ goto again;
+ }
+ }
+}
+
+static void
+grub_xen_get_mmap (void)
+{
+ struct xen_memory_map memmap;
+
+ memmap.nr_entries = ARRAY_SIZE (map);
+ set_xen_guest_handle (memmap.buffer, map);
+ if (grub_xen_hypercall (__HYPERVISOR_memory_op, XENMEM_memory_map,
+ (grub_uint32_t) (&memmap), 0, 0, 0, 0))
+ grub_xen_panic ("Could not get memory map from Xen!\n");
+ nr_map_entries = memmap.nr_entries;
+
+ grub_xen_sort_mmap ();
+}
+
+static void
+grub_xen_set_mmap (void)
+{
+ struct xen_foreign_memory_map memmap;
+
+ memmap.domid = DOMID_SELF;
+ memmap.map.nr_entries = nr_map_entries;
+ set_xen_guest_handle (memmap.map.buffer, map);
+ grub_xen_hypercall (__HYPERVISOR_memory_op, XENMEM_set_memory_map,
+ (grub_uint32_t) (&memmap), 0, 0, 0, 0);
+}
+
+static void
+grub_xen_mm_init_regions (void)
+{
+ grub_uint64_t modend, from, to;
+ unsigned int i;
+
+ modend = grub_modules_get_end ();
+
+ for (i = 0; i < nr_map_entries; i++)
+ {
+ if (map[i].type != GRUB_MEMORY_AVAILABLE)
+ continue;
+ from = map[i].addr;
+ to = from + map[i].len;
+ if (from < modend)
+ from = modend;
+ if (from >= to || from >= (1ULL << 32))
+ continue;
+ if (to > (1ULL << 32))
+ to = 1ULL << 32;
+ grub_mm_init_region ((void *) (grub_addr_t) from, to - from);
+ }
+}
+
+static grub_uint64_t
+grub_xen_find_page (grub_uint64_t start)
+{
+ unsigned int i, j;
+ grub_uint64_t last = start;
+
+ /*
+ * Try to find a e820 map hole below 4G.
+ * Relies on page-aligned entries (addr and len) and input (start).
+ */
+
+ for (i = 0; i < nr_map_entries; i++)
+ {
+ if (last > map[i].addr + map[i].len)
+ continue;
+ if (last < map[i].addr)
+ return last;
+ if ((map[i].addr >> 32) || ((map[i].addr + map[i].len) >> 32))
+ break;
+ last = map[i].addr + map[i].len;
+ }
+ if (i == nr_map_entries)
+ return last;
+
+ /* No hole found, use the highest RAM page below 4G and reserve it. */
+ if (nr_map_entries == ARRAY_SIZE (map))
+ grub_xen_panic ("Memory map size limit reached!\n");
+ for (i = 0, j = 0; i < nr_map_entries; i++)
+ {
+ if (map[i].type != GRUB_MEMORY_AVAILABLE)
+ continue;
+ if (map[i].addr >> 32)
+ break;
+ j = i;
+ if ((map[i].addr + map[i].len) >> 32)
+ break;
+ }
+ if (map[j].type != GRUB_MEMORY_AVAILABLE)
+ grub_xen_panic ("No free memory page found!\n");
+ if ((map[j].addr + map[j].len) >> 32)
+ last = (1ULL << 32) - GRUB_XEN_PAGE_SIZE;
+ else
+ last = map[j].addr + map[j].len - GRUB_XEN_PAGE_SIZE;
+ map[nr_map_entries].addr = last;
+ map[nr_map_entries].len = GRUB_XEN_PAGE_SIZE;
+ map[nr_map_entries].type = GRUB_MEMORY_RESERVED;
+ nr_map_entries++;
+ grub_xen_sort_mmap ();
+
+ return last;
+}
+
+void
+grub_xen_setup_pvh (void)
+{
+ grub_addr_t par;
+
+ grub_xen_cpuid_base ();
+ grub_xen_setup_hypercall_page ();
+ grub_xen_get_mmap ();
+
+ /* Setup Xen data. */
+ grub_xen_start_page_addr = &grub_xen_start_page;
+
+ par = grub_xen_get_param (HVM_PARAM_CONSOLE_PFN);
+ grub_xen_start_page_addr->console.domU.mfn = par;
+ grub_xen_xcons = (void *) (grub_addr_t) (par << GRUB_XEN_LOG_PAGE_SIZE);
+ par = grub_xen_get_param (HVM_PARAM_CONSOLE_EVTCHN);
+ grub_xen_start_page_addr->console.domU.evtchn = par;
+
+ par = grub_xen_get_param (HVM_PARAM_STORE_PFN);
+ grub_xen_start_page_addr->store_mfn = par;
+ grub_xen_xenstore = (void *) (grub_addr_t) (par << GRUB_XEN_LOG_PAGE_SIZE);
+ par = grub_xen_get_param (HVM_PARAM_STORE_EVTCHN);
+ grub_xen_start_page_addr->store_evtchn = par;
+
+ par = grub_xen_find_page (0);
+ grub_xen_grant_table = grub_xen_add_physmap (XENMAPSPACE_grant_table,
+ (void *) par);
+ par = grub_xen_find_page (par + GRUB_XEN_PAGE_SIZE);
+ grub_xen_shared_info = grub_xen_add_physmap (XENMAPSPACE_shared_info,
+ (void *) par);
+ grub_xen_set_mmap ();
+
+ grub_xen_mm_init_regions ();
+
+ grub_rsdp_addr = pvh_start_info->rsdp_paddr;
+}
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ unsigned int i;
+
+ for (i = 0; i < nr_map_entries; i++)
+ {
+ if (map[i].len && hook (map[i].addr, map[i].len, map[i].type, hook_data))
+ break;
+ }
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/i386/xen/startup.S b/grub-core/kern/i386/xen/startup.S
new file mode 100644
index 0000000..fbe8300
--- /dev/null
+++ b/grub-core/kern/i386/xen/startup.S
@@ -0,0 +1,38 @@
+/* startup.S - bootstrap GRUB itself */
+/*
+ * 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 <config.h>
+#include <grub/symbol.h>
+
+ .file "startup.S"
+ .text
+ .globl start, _start
+ .code32
+
+start:
+_start:
+ leal LOCAL(stack_end), %esp
+ movl %esi, EXT_C(grub_xen_start_page_addr)
+
+ call EXT_C(grub_main)
+ /* Doesn't return. */
+
+ .bss
+ .space (1 << 22)
+LOCAL(stack_end):
diff --git a/grub-core/kern/i386/xen/startup_pvh.S b/grub-core/kern/i386/xen/startup_pvh.S
new file mode 100644
index 0000000..363c318
--- /dev/null
+++ b/grub-core/kern/i386/xen/startup_pvh.S
@@ -0,0 +1,81 @@
+/* startup.S - bootstrap GRUB itself */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/symbol.h>
+#include <grub/machine/memory.h>
+
+ .file "startup_pvh.S"
+ .text
+ .globl start, _start
+ .code32
+
+start:
+_start:
+ cld
+ lgdt gdtdesc
+ ljmp $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $1f
+1:
+ movl $GRUB_MEMORY_MACHINE_PROT_MODE_DSEG, %eax
+ mov %eax, %ds
+ mov %eax, %es
+ mov %eax, %fs
+ mov %eax, %gs
+ mov %eax, %ss
+ leal LOCAL(stack_end), %esp
+
+ /* Save address of start info structure. */
+ mov %ebx, pvh_start_info
+ call EXT_C(grub_main)
+ /* Doesn't return. */
+
+ .p2align 3
+gdt:
+ .word 0, 0
+ .byte 0, 0, 0, 0
+
+ /* -- code segment --
+ * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
+ * type = 32bit code execute/read, DPL = 0
+ */
+ .word 0xFFFF, 0
+ .byte 0, 0x9A, 0xCF, 0
+
+ /* -- data segment --
+ * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
+ * type = 32 bit data read/write, DPL = 0
+ */
+ .word 0xFFFF, 0
+ .byte 0, 0x92, 0xCF, 0
+
+ .p2align 3
+/* this is the GDT descriptor */
+gdtdesc:
+ .word 0x17 /* limit */
+ .long gdt /* addr */
+
+ .p2align 2
+/* Saved pointer to start info structure. */
+ .globl pvh_start_info
+pvh_start_info:
+ .long 0
+
+ .bss
+ .space GRUB_MEMORY_MACHINE_PROT_STACK_SIZE
+LOCAL(stack_end):
diff --git a/grub-core/kern/i386/xen/tsc.c b/grub-core/kern/i386/xen/tsc.c
new file mode 100644
index 0000000..8792b30
--- /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/ia64/cache.c b/grub-core/kern/ia64/cache.c
new file mode 100644
index 0000000..13efd30
--- /dev/null
+++ b/grub-core/kern/ia64/cache.c
@@ -0,0 +1,35 @@
+/* init.c - initialize an ia64-based EFI system */
+/*
+ * 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/cache.h>
+
+void
+grub_arch_sync_caches (void *address, grub_size_t len)
+{
+ /* Cache line length is at least 32. */
+ len += (grub_uint64_t)address & 0x1f;
+ grub_uint64_t a = (grub_uint64_t)address & ~0x1f;
+
+ /* Flush data. */
+ for (len = (len + 31) & ~0x1f; len > 0; len -= 0x20, a += 0x20)
+ asm volatile ("fc.i %0" : : "r" (a));
+ /* Sync and serialize. Maybe extra. */
+ asm volatile (";; sync.i;; srlz.i;;");
+}
diff --git a/grub-core/kern/ia64/dl.c b/grub-core/kern/ia64/dl.c
new file mode 100644
index 0000000..db59300
--- /dev/null
+++ b/grub-core/kern/ia64/dl.c
@@ -0,0 +1,150 @@
+/* dl.c - arch-dependent part of loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+#include <grub/ia64/reloc.h>
+
+#define MASK19 ((1 << 19) - 1)
+#define MASK20 ((1 << 20) - 1)
+
+/* Check if EHDR is a valid ELF header. */
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ Elf_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+ if (e->e_ident[EI_CLASS] != ELFCLASS64
+ || e->e_ident[EI_DATA] != ELFDATA2LSB
+ || e->e_machine != EM_IA_64)
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+/* Relocate symbols. */
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ Elf_Rela *rel, *max;
+
+ for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
+ max = (Elf_Rela *) ((char *) rel + s->sh_size);
+ rel < max;
+ rel = (Elf_Rela *) ((char *) rel + s->sh_entsize))
+ {
+ grub_addr_t addr;
+ Elf_Sym *sym;
+ grub_uint64_t value;
+
+ if (seg->size < (rel->r_offset & ~3))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ addr = (grub_addr_t) seg->addr + rel->r_offset;
+ sym = (Elf_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel->r_info));
+
+ /* On the PPC the value does not have an explicit
+ addend, add it. */
+ value = sym->st_value + rel->r_addend;
+
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case R_IA64_PCREL21B:
+ {
+ grub_int64_t noff;
+ if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
+ {
+ struct grub_ia64_trampoline *tr = mod->trampptr;
+ grub_ia64_make_trampoline (tr, value);
+ noff = ((char *) tr - (char *) (addr & ~3)) >> 4;
+ mod->trampptr = tr + 1;
+ }
+ else
+ noff = ((char *) value - (char *) (addr & ~3)) >> 4;
+
+ if ((noff & ~MASK19) && ((-noff) & ~MASK19))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "jump offset too big (%lx)", noff);
+ grub_ia64_add_value_to_slot_20b (addr, noff);
+ }
+ break;
+ case R_IA64_SEGREL64LSB:
+ *(grub_uint64_t *) addr += value - (grub_addr_t) seg->addr;
+ break;
+ case R_IA64_FPTR64LSB:
+ case R_IA64_DIR64LSB:
+ *(grub_uint64_t *) addr += value;
+ break;
+ case R_IA64_PCREL64LSB:
+ *(grub_uint64_t *) addr += value - addr;
+ break;
+ case R_IA64_GPREL64I:
+ grub_ia64_set_immu64 (addr, value - (grub_addr_t) mod->base);
+ break;
+ case R_IA64_GPREL22:
+ if ((value - (grub_addr_t) mod->base) & ~MASK20)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "gprel offset too big (%lx)",
+ value - (grub_addr_t) mod->base);
+ grub_ia64_add_value_to_slot_21 (addr, value - (grub_addr_t) mod->base);
+ break;
+
+ case R_IA64_LTOFF22X:
+ case R_IA64_LTOFF22:
+ if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
+ value = *(grub_uint64_t *) sym->st_value + rel->r_addend;
+ /* Fallthrough. */
+ case R_IA64_LTOFF_FPTR22:
+ {
+ grub_uint64_t *gpptr = mod->gotptr;
+ *gpptr = value;
+ if (((grub_addr_t) gpptr - (grub_addr_t) mod->base) & ~MASK20)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "gprel offset too big (%lx)",
+ (grub_addr_t) gpptr - (grub_addr_t) mod->base);
+ grub_ia64_add_value_to_slot_21 (addr, (grub_addr_t) gpptr - (grub_addr_t) mod->base);
+ mod->gotptr = gpptr + 1;
+ break;
+ }
+ /* We treat LTOFF22X as LTOFF22, so we can ignore LDXMOV. */
+ case R_IA64_LDXMOV:
+ break;
+ default:
+ {
+ char rel_info[17]; /* log16(2^64) = 16, plus NUL. */
+
+ grub_snprintf (rel_info, sizeof (rel_info) - 1, "%" PRIxGRUB_UINT64_T,
+ ELF_R_TYPE (rel->r_info));
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%s is not implemented yet"), rel_info);
+ }
+ }
+ }
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/ia64/dl_helper.c b/grub-core/kern/ia64/dl_helper.c
new file mode 100644
index 0000000..c601595
--- /dev/null
+++ b/grub-core/kern/ia64/dl_helper.c
@@ -0,0 +1,241 @@
+/* dl.c - arch-dependent part of loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+#include <grub/ia64/reloc.h>
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+#define MASK20 ((1 << 20) - 1)
+#define MASK3 (~(grub_addr_t) 3)
+
+void
+grub_ia64_set_immu64 (grub_addr_t addr, grub_uint64_t val)
+{
+ /* Copied from binutils. */
+ grub_uint64_t *ptr = ((grub_uint64_t *) (addr & MASK3));
+ grub_uint64_t t0, t1;
+
+ t0 = grub_le_to_cpu64 (ptr[0]);
+ t1 = grub_le_to_cpu64 (ptr[1]);
+
+ /* tmpl/s: bits 0.. 5 in t0
+ slot 0: bits 5..45 in t0
+ slot 1: bits 46..63 in t0, bits 0..22 in t1
+ slot 2: bits 23..63 in t1 */
+
+ /* First, clear the bits that form the 64 bit constant. */
+ t0 &= ~(0x3ffffLL << 46);
+ t1 &= ~(0x7fffffLL
+ | (( (0x07fLL << 13) | (0x1ffLL << 27)
+ | (0x01fLL << 22) | (0x001LL << 21)
+ | (0x001LL << 36)) << 23));
+
+ t0 |= ((val >> 22) & 0x03ffffLL) << 46; /* 18 lsbs of imm41 */
+ t1 |= ((val >> 40) & 0x7fffffLL) << 0; /* 23 msbs of imm41 */
+ t1 |= ( (((val >> 0) & 0x07f) << 13) /* imm7b */
+ | (((val >> 7) & 0x1ff) << 27) /* imm9d */
+ | (((val >> 16) & 0x01f) << 22) /* imm5c */
+ | (((val >> 21) & 0x001) << 21) /* ic */
+ | (((val >> 63) & 0x001) << 36)) << 23; /* i */
+
+ ptr[0] = t0;
+ ptr[1] = t1;
+}
+
+void
+grub_ia64_add_value_to_slot_20b (grub_addr_t addr, grub_uint32_t value)
+{
+ grub_uint32_t val;
+ switch (addr & 3)
+ {
+ case 0:
+ val = grub_le_to_cpu32 (grub_get_unaligned32 (((grub_uint8_t *)
+ (addr & MASK3) + 2)));
+ val = (((((val & MASK20) + value) & MASK20) << 2)
+ | (val & ~(MASK20 << 2)));
+ grub_set_unaligned32 (((grub_uint8_t *) (addr & MASK3) + 2),
+ grub_cpu_to_le32 (val));
+ break;
+ case 1:
+ val = grub_le_to_cpu32 (grub_get_unaligned32 (((grub_uint8_t *)
+ (addr & MASK3) + 7)));
+ val = ((((((val >> 3) & MASK20) + value) & MASK20) << 3)
+ | (val & ~(MASK20 << 3)));
+ grub_set_unaligned32 (((grub_uint8_t *) (addr & MASK3) + 7),
+ grub_cpu_to_le32 (val));
+ break;
+ case 2:
+ val = grub_le_to_cpu32 (grub_get_unaligned32 (((grub_uint8_t *)
+ (addr & MASK3) + 12)));
+ val = ((((((val >> 4) & MASK20) + value) & MASK20) << 4)
+ | (val & ~(MASK20 << 4)));
+ grub_set_unaligned32 (((grub_uint8_t *) (addr & MASK3) + 12),
+ grub_cpu_to_le32 (val));
+ break;
+ }
+}
+
+#define MASKF21 ( ((1 << 23) - 1) & ~((1 << 7) | (1 << 8)) )
+
+static grub_uint32_t
+add_value_to_slot_21_real (grub_uint32_t a, grub_uint32_t value)
+{
+ grub_uint32_t high, mid, low, c;
+ low = (a & 0x00007f);
+ mid = (a & 0x7fc000) >> 7;
+ high = (a & 0x003e00) << 7;
+ c = (low | mid | high) + value;
+ return (c & 0x7f) | ((c << 7) & 0x7fc000) | ((c >> 7) & 0x0003e00); //0x003e00
+}
+
+void
+grub_ia64_add_value_to_slot_21 (grub_addr_t addr, grub_uint32_t value)
+{
+ grub_uint32_t val;
+ switch (addr & 3)
+ {
+ case 0:
+ val = grub_le_to_cpu32 (grub_get_unaligned32 (((grub_uint8_t *)
+ (addr & MASK3) + 2)));
+ val = ((add_value_to_slot_21_real (((val >> 2) & MASKF21), value)
+ & MASKF21) << 2) | (val & ~(MASKF21 << 2));
+ grub_set_unaligned32 (((grub_uint8_t *) (addr & MASK3) + 2),
+ grub_cpu_to_le32 (val));
+ break;
+ case 1:
+ val = grub_le_to_cpu32 (grub_get_unaligned32 (((grub_uint8_t *)
+ (addr & MASK3) + 7)));
+ val = ((add_value_to_slot_21_real (((val >> 3) & MASKF21), value)
+ & MASKF21) << 3) | (val & ~(MASKF21 << 3));
+ grub_set_unaligned32 (((grub_uint8_t *) (addr & MASK3) + 7),
+ grub_cpu_to_le32 (val));
+ break;
+ case 2:
+ val = grub_le_to_cpu32 (grub_get_unaligned32 (((grub_uint8_t *)
+ (addr & MASK3) + 12)));
+ val = ((add_value_to_slot_21_real (((val >> 4) & MASKF21), value)
+ & MASKF21) << 4) | (val & ~(MASKF21 << 4));
+ grub_set_unaligned32 (((grub_uint8_t *) (addr & MASK3) + 12),
+ grub_cpu_to_le32 (val));
+ break;
+ }
+}
+
+static const grub_uint8_t nopm[5] =
+ {
+ /* [MLX] nop.m 0x0 */
+ 0x05, 0x00, 0x00, 0x00, 0x01
+ };
+
+#ifdef GRUB_UTIL
+static grub_uint8_t jump[0x20] =
+ {
+ /* [MMI] add r15=r15,r1;; */
+ 0x0b, 0x78, 0x3c, 0x02, 0x00, 0x20,
+ /* ld8 r16=[r15],8 */
+ 0x00, 0x41, 0x3c, 0x30, 0x28, 0xc0,
+ /* mov r14=r1;; */
+ 0x01, 0x08, 0x00, 0x84,
+ /* [MIB] ld8 r1=[r15] */
+ 0x11, 0x08, 0x00, 0x1e, 0x18, 0x10,
+ /* mov b6=r16 */
+ 0x60, 0x80, 0x04, 0x80, 0x03, 0x00,
+ /* br.few b6;; */
+ 0x60, 0x00, 0x80, 0x00
+ };
+#else
+static const grub_uint8_t jump[0x20] =
+ {
+ /* ld8 r16=[r15],8 */
+ 0x02, 0x80, 0x20, 0x1e, 0x18, 0x14,
+ /* mov r14=r1;; */
+ 0xe0, 0x00, 0x04, 0x00, 0x42, 0x00,
+ /* nop.i 0x0 */
+ 0x00, 0x00, 0x04, 0x00,
+ /* ld8 r1=[r15] */
+ 0x11, 0x08, 0x00, 0x1e, 0x18, 0x10,
+ /* mov b6=r16 */
+ 0x60, 0x80, 0x04, 0x80, 0x03, 0x00,
+ /* br.few b6;; */
+ 0x60, 0x00, 0x80, 0x00
+ };
+#endif
+
+void
+grub_ia64_make_trampoline (struct grub_ia64_trampoline *tr, grub_uint64_t addr)
+{
+ grub_memcpy (tr->nop, nopm, sizeof (tr->nop));
+ tr->addr_hi[0] = ((addr & 0xc00000) >> 16);
+ tr->addr_hi[1] = (addr >> 24) & 0xff;
+ tr->addr_hi[2] = (addr >> 32) & 0xff;
+ tr->addr_hi[3] = (addr >> 40) & 0xff;
+ tr->addr_hi[4] = (addr >> 48) & 0xff;
+ tr->addr_hi[5] = (addr >> 56) & 0xff;
+ tr->e0 = 0xe0;
+ tr->addr_lo[0] = ((addr & 0x000f) << 4) | 0x01;
+ tr->addr_lo[1] = (((addr & 0x0070) >> 4) | ((addr & 0x070000) >> 11)
+ | ((addr & 0x200000) >> 17));
+ tr->addr_lo[2] = ((addr & 0x1f80) >> 5) | ((addr & 0x180000) >> 19);
+ tr->addr_lo[3] = ((addr & 0xe000) >> 13) | 0x60;
+ grub_memcpy (tr->jump, jump, sizeof (tr->jump));
+}
+
+grub_err_t
+grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
+ grub_size_t *got)
+{
+ const Elf64_Ehdr *e = ehdr;
+ grub_size_t cntt = 0, cntg = 0;
+ const Elf64_Shdr *s;
+ unsigned i;
+
+ for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu64 (e->e_shoff));
+ i < grub_le_to_cpu16 (e->e_shnum);
+ i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize)))
+ if (s->sh_type == grub_cpu_to_le32_compile_time (SHT_RELA))
+ {
+ const Elf64_Rela *rel, *max;
+
+ for (rel = (Elf64_Rela *) ((char *) e + grub_le_to_cpu64 (s->sh_offset)),
+ max = (const Elf64_Rela *) ((char *) rel + grub_le_to_cpu64 (s->sh_size));
+ rel < max; rel = (const Elf64_Rela *) ((char *) rel + grub_le_to_cpu64 (s->sh_entsize)))
+ switch (ELF64_R_TYPE (grub_le_to_cpu64 (rel->r_info)))
+ {
+ case R_IA64_PCREL21B:
+ cntt++;
+ break;
+ case R_IA64_LTOFF_FPTR22:
+ case R_IA64_LTOFF22X:
+ case R_IA64_LTOFF22:
+ cntg++;
+ break;
+ }
+ }
+ *tramp = cntt * sizeof (struct grub_ia64_trampoline);
+ *got = cntg * sizeof (grub_uint64_t);
+
+ return GRUB_ERR_NONE;
+}
+
diff --git a/grub-core/kern/ia64/efi/init.c b/grub-core/kern/ia64/efi/init.c
new file mode 100644
index 0000000..f196557
--- /dev/null
+++ b/grub-core/kern/ia64/efi/init.c
@@ -0,0 +1,80 @@
+/* init.c - initialize an ia64-based EFI system */
+/*
+ * 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/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/kernel.h>
+#include <grub/efi/efi.h>
+#include <grub/loader.h>
+
+static grub_uint64_t divisor = 1;
+
+static grub_uint64_t
+get_itc (void)
+{
+ grub_uint64_t ret;
+ asm volatile ("mov %0=ar.itc" : "=r" (ret));
+ return ret;
+}
+
+grub_uint64_t
+grub_rtc_get_time_ms (void)
+{
+ return get_itc () / divisor;
+}
+
+void
+grub_machine_init (void)
+{
+ grub_efi_event_t event;
+ grub_uint64_t before, after;
+ grub_efi_uintn_t idx;
+ grub_efi_init ();
+
+ efi_call_5 (grub_efi_system_table->boot_services->create_event,
+ GRUB_EFI_EVT_TIMER, GRUB_EFI_TPL_CALLBACK, 0, 0, &event);
+
+ before = get_itc ();
+ efi_call_3 (grub_efi_system_table->boot_services->set_timer, event,
+ GRUB_EFI_TIMER_RELATIVE, 200000);
+ efi_call_3 (grub_efi_system_table->boot_services->wait_for_event, 1,
+ &event, &idx);
+ after = get_itc ();
+ efi_call_1 (grub_efi_system_table->boot_services->close_event, event);
+ divisor = (after - before + 5) / 20;
+ if (divisor == 0)
+ divisor = 800000;
+ grub_install_get_time_ms (grub_rtc_get_time_ms);
+}
+
+void
+grub_machine_fini (int flags)
+{
+ if (!(flags & GRUB_LOADER_FLAG_NORETURN))
+ return;
+
+ grub_efi_fini ();
+
+ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY))
+ grub_efi_memory_fini ();
+}
diff --git a/grub-core/kern/ia64/efi/startup.S b/grub-core/kern/ia64/efi/startup.S
new file mode 100644
index 0000000..d75c6d7
--- /dev/null
+++ b/grub-core/kern/ia64/efi/startup.S
@@ -0,0 +1,44 @@
+/*
+ * 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/symbol.h>
+#include <grub/offsets.h>
+
+ .text
+ .psr abi64
+ .psr lsb
+ .lsb
+
+ .global _start
+ .proc _start
+_start:
+ alloc loc0=ar.pfs,2,4,0,0
+ mov loc1=rp
+ addl loc2=@gprel(grub_efi_image_handle),gp
+ addl loc3=@gprel(grub_efi_system_table),gp
+ ;;
+ st8 [loc2]=in0
+ st8 [loc3]=in1
+ br.call.sptk.few rp=grub_main
+ ;;
+ mov ar.pfs=loc0
+ mov rp=loc1
+ ;;
+ br.ret.sptk.few rp
+
+ .endp _start
diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c
new file mode 100644
index 0000000..20cbbd7
--- /dev/null
+++ b/grub-core/kern/ieee1275/cmain.c
@@ -0,0 +1,220 @@
+/* cmain.c - Startup code for the PowerPC. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/ieee1275/ieee1275.h>
+
+int (*grub_ieee1275_entry_fn) (void *) GRUB_IEEE1275_ENTRY_FN_ATTRIBUTE;
+
+grub_ieee1275_phandle_t grub_ieee1275_chosen;
+grub_ieee1275_ihandle_t grub_ieee1275_mmu;
+
+static grub_uint32_t grub_ieee1275_flags;
+
+
+
+int
+grub_ieee1275_test_flag (enum grub_ieee1275_flag flag)
+{
+ return (grub_ieee1275_flags & (1 << flag));
+}
+
+void
+grub_ieee1275_set_flag (enum grub_ieee1275_flag flag)
+{
+ grub_ieee1275_flags |= (1 << flag);
+}
+
+static void
+grub_ieee1275_find_options (void)
+{
+ grub_ieee1275_phandle_t root;
+ grub_ieee1275_phandle_t options;
+ grub_ieee1275_phandle_t openprom;
+ grub_ieee1275_phandle_t bootrom;
+ int rc;
+ grub_uint32_t realmode = 0;
+ char tmp[256];
+ int is_smartfirmware = 0;
+ int is_olpc = 0;
+ int is_qemu = 0;
+ grub_ssize_t actual;
+
+#ifdef __sparc__
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0);
+#endif
+
+ grub_ieee1275_finddevice ("/", &root);
+ grub_ieee1275_finddevice ("/options", &options);
+ grub_ieee1275_finddevice ("/openprom", &openprom);
+
+ rc = grub_ieee1275_get_integer_property (options, "real-mode?", &realmode,
+ sizeof realmode, 0);
+ if (((rc >= 0) && realmode) || (grub_ieee1275_mmu == 0))
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
+
+ rc = grub_ieee1275_get_property (openprom, "CodeGen-copyright",
+ tmp, sizeof (tmp), 0);
+ if (rc >= 0 && !grub_strncmp (tmp, "SmartFirmware(tm)",
+ sizeof ("SmartFirmware(tm)") - 1))
+ is_smartfirmware = 1;
+
+ rc = grub_ieee1275_get_property (root, "architecture",
+ tmp, sizeof (tmp), 0);
+ if (rc >= 0 && !grub_strcmp (tmp, "OLPC"))
+ is_olpc = 1;
+
+ rc = grub_ieee1275_get_property (root, "model",
+ tmp, sizeof (tmp), 0);
+ 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);
+
+ /* Old Macs have no key repeat, newer ones have fully working one.
+ The ones inbetween when repeated key generates an escaoe sequence
+ only the escape is repeated. With this workaround however a fast
+ e.g. down arrow-ESC is perceived as down arrow-down arrow which is
+ also annoying but is less so than the original bug of exiting from
+ the current window on arrow repeat. To avoid unaffected users suffering
+ from this workaround match only exact models known to have this bug.
+ */
+ if (rc >= 0 && grub_strcmp (tmp, "PowerBook3,3") == 0)
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_REPEAT);
+
+ rc = grub_ieee1275_get_property (root, "compatible",
+ tmp, sizeof (tmp), &actual);
+ if (rc >= 0)
+ {
+ char *ptr;
+
+ if (grub_strncmp (tmp, "sun4v", 5) == 0)
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_RAW_DEVNAMES);
+ for (ptr = tmp; ptr - tmp < actual; ptr += grub_strlen (ptr) + 1)
+ {
+ if (grub_memcmp (ptr, "MacRISC", sizeof ("MacRISC") - 1) == 0
+ && (ptr[sizeof ("MacRISC") - 1] == 0
+ || grub_isdigit (ptr[sizeof ("MacRISC") - 1])))
+ {
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN);
+ break;
+ }
+ }
+ }
+
+ if (is_smartfirmware)
+ {
+ /* Broken in all versions */
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT);
+
+ /* There are two incompatible ways of checking the version number. Try
+ both. */
+ rc = grub_ieee1275_get_property (openprom, "SmartFirmware-version",
+ tmp, sizeof (tmp), 0);
+ if (rc < 0)
+ rc = grub_ieee1275_get_property (openprom, "firmware-version",
+ tmp, sizeof (tmp), 0);
+ if (rc >= 0)
+ {
+ /* It is tempting to implement a version parser to set the flags for
+ e.g. 1.3 and below. However, there's a special situation here.
+ 3rd party updates which fix the partition bugs are common, and for
+ some reason their fixes aren't being merged into trunk. So for
+ example we know that 1.2 and 1.3 are broken, but there's 1.2.99
+ and 1.3.99 which are known good (and applying this workaround
+ would cause breakage). */
+ if (!grub_strcmp (tmp, "1.0")
+ || !grub_strcmp (tmp, "1.1")
+ || !grub_strcmp (tmp, "1.2")
+ || !grub_strcmp (tmp, "1.3"))
+ {
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS);
+ }
+ }
+ }
+
+ if (is_olpc)
+ {
+ /* OLPC / XO laptops have three kinds of storage devices:
+
+ - NAND flash. These are accessible via OFW callbacks, but:
+ - Follow strange semantics, imposed by hardware constraints.
+ - Its ABI is undocumented, and not stable.
+ They lack "device_type" property, which conveniently makes GRUB
+ skip them.
+
+ - USB drives. Not accessible, because OFW shuts down the controller
+ in order to prevent collisions with applications accessing it
+ directly. Even worse, attempts to access it will NOT return
+ control to the caller, so we have to avoid probing them.
+
+ - SD cards. These work fine.
+
+ To avoid breakage, we only need to skip USB probing. However,
+ since detecting SD cards is more reliable, we do that instead.
+ */
+
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_HAS_CURSORONOFF);
+ }
+
+ if (is_qemu)
+ {
+ /* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM);
+
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_HAS_CURSORONOFF);
+ }
+
+ if (! grub_ieee1275_finddevice ("/rom/boot-rom", &bootrom)
+ || ! grub_ieee1275_finddevice ("/boot-rom", &bootrom))
+ {
+ rc = grub_ieee1275_get_property (bootrom, "model", tmp, sizeof (tmp), 0);
+ if (rc >= 0 && !grub_strncmp (tmp, "PPC Open Hack'Ware",
+ sizeof ("PPC Open Hack'Ware") - 1))
+ {
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_ANSI);
+ }
+ }
+}
+
+void
+grub_ieee1275_init (void)
+{
+ grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);
+
+ if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen, "mmu", &grub_ieee1275_mmu,
+ sizeof grub_ieee1275_mmu, 0) < 0)
+ grub_ieee1275_mmu = 0;
+
+ grub_ieee1275_find_options ();
+}
diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
new file mode 100644
index 0000000..86f81a3
--- /dev/null
+++ b/grub-core/kern/ieee1275/ieee1275.c
@@ -0,0 +1,809 @@
+/* of.c - Access the Open Firmware client interface. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+
+#define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_cell_t) -1)
+#define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_cell_t) 0)
+#define IEEE1275_CELL_INVALID ((grub_ieee1275_cell_t) -1)
+
+
+
+int
+grub_ieee1275_finddevice (const char *name, grub_ieee1275_phandle_t *phandlep)
+{
+ struct find_device_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t device;
+ grub_ieee1275_cell_t phandle;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1);
+ args.device = (grub_ieee1275_cell_t) name;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ *phandlep = args.phandle;
+ if (args.phandle == IEEE1275_PHANDLE_INVALID)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle,
+ const char *property, void *buf,
+ grub_size_t size, grub_ssize_t *actual)
+{
+ struct get_property_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t phandle;
+ grub_ieee1275_cell_t prop;
+ grub_ieee1275_cell_t buf;
+ grub_ieee1275_cell_t buflen;
+ grub_ieee1275_cell_t size;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1);
+ args.phandle = phandle;
+ args.prop = (grub_ieee1275_cell_t) property;
+ args.buf = (grub_ieee1275_cell_t) buf;
+ args.buflen = (grub_ieee1275_cell_t) size;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ if (actual)
+ *actual = (grub_ssize_t) args.size;
+ if (args.size == IEEE1275_CELL_INVALID)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_get_integer_property (grub_ieee1275_phandle_t phandle,
+ const char *property, grub_uint32_t *buf,
+ grub_size_t size, grub_ssize_t *actual)
+{
+ int ret;
+ ret = grub_ieee1275_get_property (phandle, property, (void *) buf, size, actual);
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ /* Integer properties are always in big endian. */
+ if (ret == 0)
+ {
+ unsigned int i;
+ size /= sizeof (grub_uint32_t);
+ for (i = 0; i < size; i++)
+ buf[i] = grub_be_to_cpu32 (buf[i]);
+ }
+#endif
+ return ret;
+}
+
+int
+grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop,
+ char *prop)
+{
+ struct get_property_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t phandle;
+ grub_ieee1275_cell_t prev_prop;
+ grub_ieee1275_cell_t next_prop;
+ grub_ieee1275_cell_t flags;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1);
+ args.phandle = phandle;
+ args.prev_prop = (grub_ieee1275_cell_t) prev_prop;
+ args.next_prop = (grub_ieee1275_cell_t) prop;
+ args.flags = (grub_ieee1275_cell_t) -1;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ return (int) args.flags;
+}
+
+int
+grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle,
+ const char *prop, grub_ssize_t *length)
+{
+ struct get_property_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t phandle;
+ grub_ieee1275_cell_t prop;
+ grub_ieee1275_cell_t length;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1);
+ args.phandle = phandle;
+ args.prop = (grub_ieee1275_cell_t) prop;
+ args.length = (grub_ieee1275_cell_t) -1;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ *length = args.length;
+ if (args.length == IEEE1275_CELL_INVALID)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle,
+ grub_ieee1275_phandle_t *phandlep)
+{
+ struct instance_to_package_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t phandle;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1);
+ args.ihandle = ihandle;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ *phandlep = args.phandle;
+ if (args.phandle == IEEE1275_PHANDLE_INVALID)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle,
+ char *path, grub_size_t len,
+ grub_ssize_t *actual)
+{
+ struct instance_to_package_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t phandle;
+ grub_ieee1275_cell_t buf;
+ grub_ieee1275_cell_t buflen;
+ grub_ieee1275_cell_t actual;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1);
+ args.phandle = phandle;
+ args.buf = (grub_ieee1275_cell_t) path;
+ args.buflen = (grub_ieee1275_cell_t) len;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ if (actual)
+ *actual = args.actual;
+ if (args.actual == IEEE1275_CELL_INVALID)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
+ char *path, grub_size_t len,
+ grub_ssize_t *actual)
+{
+ struct instance_to_path_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t buf;
+ grub_ieee1275_cell_t buflen;
+ grub_ieee1275_cell_t actual;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1);
+ args.ihandle = ihandle;
+ args.buf = (grub_ieee1275_cell_t) path;
+ args.buflen = (grub_ieee1275_cell_t) len;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ if (actual)
+ *actual = args.actual;
+ if (args.actual == IEEE1275_CELL_INVALID)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer,
+ grub_size_t len, grub_ssize_t *actualp)
+{
+ struct write_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t buf;
+ grub_ieee1275_cell_t len;
+ grub_ieee1275_cell_t actual;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "write", 3, 1);
+ args.ihandle = ihandle;
+ args.buf = (grub_ieee1275_cell_t) buffer;
+ args.len = (grub_ieee1275_cell_t) len;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ if (actualp)
+ *actualp = args.actual;
+ return 0;
+}
+
+int
+grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
+ grub_size_t len, grub_ssize_t *actualp)
+{
+ struct write_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t buf;
+ grub_ieee1275_cell_t len;
+ grub_ieee1275_cell_t actual;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "read", 3, 1);
+ args.ihandle = ihandle;
+ args.buf = (grub_ieee1275_cell_t) buffer;
+ args.len = (grub_ieee1275_cell_t) len;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ if (actualp)
+ *actualp = args.actual;
+ return 0;
+}
+
+int
+grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, grub_disk_addr_t pos,
+ grub_ssize_t *result)
+{
+ struct write_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t pos_hi;
+ grub_ieee1275_cell_t pos_lo;
+ grub_ieee1275_cell_t result;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1);
+ args.ihandle = ihandle;
+ /* To prevent stupid gcc warning. */
+#if GRUB_IEEE1275_CELL_SIZEOF >= 8
+ args.pos_hi = 0;
+ args.pos_lo = pos;
+#else
+ args.pos_hi = (grub_ieee1275_cell_t) (pos >> (8 * GRUB_IEEE1275_CELL_SIZEOF));
+ args.pos_lo = (grub_ieee1275_cell_t)
+ (pos & ((1ULL << (8 * GRUB_IEEE1275_CELL_SIZEOF)) - 1));
+#endif
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+
+ if (result)
+ *result = args.result;
+ return 0;
+}
+
+int
+grub_ieee1275_peer (grub_ieee1275_phandle_t node,
+ grub_ieee1275_phandle_t *result)
+{
+ struct peer_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t node;
+ grub_ieee1275_cell_t result;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1);
+ args.node = node;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ *result = args.result;
+ if (args.result == 0)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_child (grub_ieee1275_phandle_t node,
+ grub_ieee1275_phandle_t *result)
+{
+ struct child_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t node;
+ grub_ieee1275_cell_t result;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "child", 1, 1);
+ args.node = node;
+ args.result = IEEE1275_PHANDLE_INVALID;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ *result = args.result;
+ if (args.result == 0)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_parent (grub_ieee1275_phandle_t node,
+ grub_ieee1275_phandle_t *result)
+{
+ struct parent_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t node;
+ grub_ieee1275_cell_t result;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1);
+ args.node = node;
+ args.result = IEEE1275_PHANDLE_INVALID;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ *result = args.result;
+ return 0;
+}
+
+int
+grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch)
+{
+ struct enter_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t command;
+ grub_ieee1275_cell_t catch;
+ }
+ args;
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET))
+ return -1;
+
+ INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1);
+ args.command = (grub_ieee1275_cell_t) command;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ if (catch)
+ *catch = args.catch;
+ return 0;
+}
+
+int
+grub_ieee1275_enter (void)
+{
+ struct enter_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "enter", 0, 0);
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ return 0;
+}
+
+void
+grub_ieee1275_exit (void)
+{
+ struct exit_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0);
+
+ IEEE1275_CALL_ENTRY_FN (&args);
+ for (;;) ;
+}
+
+int
+grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
+{
+ struct open_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t path;
+ grub_ieee1275_cell_t result;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
+ args.path = (grub_ieee1275_cell_t) path;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ *result = args.result;
+ if (args.result == IEEE1275_IHANDLE_INVALID)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
+{
+ struct close_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t ihandle;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
+ args.ihandle = ihandle;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+
+ return 0;
+}
+
+int
+grub_ieee1275_decode_unit4 (grub_ieee1275_ihandle_t ihandle,
+ void *addr, grub_size_t size,
+ grub_uint32_t *phy_lo, grub_uint32_t *phy_hi,
+ grub_uint32_t *lun_lo, grub_uint32_t *lun_hi)
+{
+ struct decode_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t size;
+ grub_ieee1275_cell_t addr;
+ grub_ieee1275_cell_t catch_result;
+ grub_ieee1275_cell_t tgt_h;
+ grub_ieee1275_cell_t tgt_l;
+ grub_ieee1275_cell_t lun_h;
+ grub_ieee1275_cell_t lun_l;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 5);
+ args.method = (grub_ieee1275_cell_t) "decode-unit";
+ args.ihandle = ihandle;
+ args.size = size;
+ args.addr = (grub_ieee1275_cell_t) addr;
+ args.catch_result = 1;
+
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, "decode-unit failed\n");
+ return -1;
+ }
+
+ *phy_lo = args.tgt_l;
+ *phy_hi = args.tgt_h;
+ *lun_lo = args.lun_l;
+ *lun_hi = args.lun_h;
+ return 0;
+}
+
+char *
+grub_ieee1275_encode_uint4 (grub_ieee1275_ihandle_t ihandle,
+ grub_uint32_t phy_lo, grub_uint32_t phy_hi,
+ grub_uint32_t lun_lo, grub_uint32_t lun_hi,
+ grub_size_t *size)
+{
+ char *addr;
+ struct encode_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t tgt_h;
+ grub_ieee1275_cell_t tgt_l;
+ grub_ieee1275_cell_t lun_h;
+ grub_ieee1275_cell_t lun_l;
+ grub_ieee1275_cell_t catch_result;
+ grub_ieee1275_cell_t size;
+ grub_ieee1275_cell_t addr;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 3);
+ args.method = (grub_ieee1275_cell_t) "encode-unit";
+ args.ihandle = ihandle;
+
+ args.tgt_l = phy_lo;
+ args.tgt_h = phy_hi;
+ args.lun_l = lun_lo;
+ args.lun_h = lun_hi;
+ args.catch_result = 1;
+
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, "encode-unit failed\n");
+ return 0;
+ }
+
+ addr = (void *)args.addr;
+ *size = args.size;
+ addr = grub_strdup ((char *)args.addr);
+ return addr;
+}
+
+int
+grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align,
+ grub_addr_t *result)
+{
+ struct claim_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t addr;
+ grub_ieee1275_cell_t size;
+ grub_ieee1275_cell_t align;
+ grub_ieee1275_cell_t base;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1);
+ args.addr = (grub_ieee1275_cell_t) addr;
+ args.size = (grub_ieee1275_cell_t) size;
+ args.align = (grub_ieee1275_cell_t) align;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ if (result)
+ *result = args.base;
+ if (args.base == IEEE1275_CELL_INVALID)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_release (grub_addr_t addr, grub_size_t size)
+{
+ struct release_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t addr;
+ grub_ieee1275_cell_t size;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "release", 2, 0);
+ args.addr = addr;
+ args.size = size;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle,
+ const char *propname, const void *buf,
+ grub_size_t size, grub_ssize_t *actual)
+{
+ struct set_property_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t phandle;
+ grub_ieee1275_cell_t propname;
+ grub_ieee1275_cell_t buf;
+ grub_ieee1275_cell_t size;
+ grub_ieee1275_cell_t actual;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1);
+ args.size = (grub_ieee1275_cell_t) size;
+ args.buf = (grub_ieee1275_cell_t) buf;
+ args.propname = (grub_ieee1275_cell_t) propname;
+ args.phandle = (grub_ieee1275_cell_t) phandle;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ *actual = args.actual;
+ if ((args.actual == IEEE1275_CELL_INVALID) || (args.actual != args.size))
+ return -1;
+ return 0;
+}
+
+int
+grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle,
+ int index, int r, int g, int b)
+{
+ struct set_color_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t index;
+ grub_ieee1275_cell_t b;
+ grub_ieee1275_cell_t g;
+ grub_ieee1275_cell_t r;
+ grub_ieee1275_cell_t catch_result;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
+ args.method = (grub_ieee1275_cell_t) "color!";
+ args.ihandle = ihandle;
+ args.index = index;
+ args.r = r;
+ args.g = g;
+ args.b = b;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ return args.catch_result;
+}
+
+int
+grub_ieee1275_milliseconds (grub_uint32_t *msecs)
+{
+ struct milliseconds_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t msecs;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "milliseconds", 0, 1);
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ *msecs = args.msecs;
+ return 0;
+}
+
+int
+grub_ieee1275_set_address (grub_ieee1275_ihandle_t ihandle,
+ grub_uint32_t target, grub_uint32_t lun)
+{
+ struct set_address
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t tgt;
+ grub_ieee1275_cell_t lun;
+ grub_ieee1275_cell_t catch_result;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 1);
+
+ /*
+ * IEEE 1275-1994 Standard for Boot (Initialization Configuration)
+ * Firmware: Core Requirements and Practices
+ * E.3.2.2 Bus-specific methods for bus nodes
+ *
+ * A package implementing the scsi-2 device type shall implement the
+ * following bus-specific method:
+ *
+ * set-address ( unit# target# -- )
+ * Sets the SCSI target number (0x0..0xf) and unit number (0..7) to which
+ * subsequent commands apply.
+ */
+ args.method = (grub_ieee1275_cell_t) "set-address";
+ args.ihandle = ihandle;
+ args.tgt = target;
+ args.lun = lun;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+
+ return args.catch_result;
+}
+
+int
+grub_ieee1275_no_data_command (grub_ieee1275_ihandle_t ihandle,
+ const void *cmd_addr, grub_ssize_t *result)
+{
+ struct set_address
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t cmd_addr;
+ grub_ieee1275_cell_t error;
+ grub_ieee1275_cell_t catch_result;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 2);
+
+ /*
+ * IEEE 1275-1994 Standard for Boot (Initialization Configuration)
+ * Firmware: Core Requirements and Practices
+ *
+ * E.3.2.2 Bus-specific methods for bus nodes
+ *
+ * A package implementing the scsi-2 device type shall implement the
+ * following bus-specific method:
+ *
+ * no-data-command ( cmd-addr -- error? )
+ * Executes a simple SCSI command, automatically retrying under
+ * certain conditions. cmd-addr is the address of a 6-byte command buffer
+ * containing an SCSI command that does not have a data transfer phase.
+ * Executes the command, retrying indefinitely with the same retry criteria
+ * as retry-command.
+ *
+ * error? is nonzero if an error occurred, zero otherwise.
+ * NOTE no-data-command is a convenience function. It provides
+ * no capabilities that are not present in retry-command, but for
+ * those commands that meet its restrictions, it is easier to use.
+ */
+ args.method = (grub_ieee1275_cell_t) "no-data-command";
+ args.ihandle = ihandle;
+ args.cmd_addr = (grub_ieee1275_cell_t) cmd_addr;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+
+ if (result)
+ *result = args.error;
+
+ return args.catch_result;
+}
+
+int
+grub_ieee1275_get_block_size (grub_ieee1275_ihandle_t ihandle)
+{
+ struct size_args_ieee1275
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t result;
+ grub_ieee1275_cell_t size;
+ } args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2);
+ args.method = (grub_ieee1275_cell_t) "block-size";
+ args.ihandle = ihandle;
+ args.result = 1;
+
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
+ return 0;
+
+ return args.size;
+}
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
new file mode 100644
index 0000000..d483e35
--- /dev/null
+++ b/grub-core/kern/ieee1275/init.c
@@ -0,0 +1,322 @@
+/* init.c -- Initialize GRUB on the newworld mac (PPC). */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/kernel.h>
+#include <grub/dl.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/partition.h>
+#include <grub/normal.h>
+#include <grub/fs.h>
+#include <grub/setjmp.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/time.h>
+#include <grub/ieee1275/console.h>
+#include <grub/ieee1275/ofdisk.h>
+#ifdef __sparc__
+#include <grub/ieee1275/obdisk.h>
+#endif
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/net.h>
+#include <grub/offsets.h>
+#include <grub/memory.h>
+#include <grub/loader.h>
+#ifdef __i386__
+#include <grub/cpu/tsc.h>
+#endif
+#ifdef __sparc__
+#include <grub/machine/kernel.h>
+#endif
+
+/* The minimal heap size we can live with. */
+#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[];
+
+#ifdef __sparc__
+grub_addr_t grub_ieee1275_original_stack;
+#endif
+
+void
+grub_exit (void)
+{
+ grub_ieee1275_exit ();
+}
+
+/* Translate an OF filesystem path (separated by backslashes), into a GRUB
+ path (separated by forward slashes). */
+static void
+grub_translate_ieee1275_path (char *filepath)
+{
+ char *backslash;
+
+ backslash = grub_strchr (filepath, '\\');
+ while (backslash != 0)
+ {
+ *backslash = '/';
+ backslash = grub_strchr (filepath, '\\');
+ }
+}
+
+void (*grub_ieee1275_net_config) (const char *dev, char **device, char **path,
+ char *bootpath);
+void
+grub_machine_get_bootlocation (char **device, char **path)
+{
+ char *bootpath;
+ char *filename;
+ char *type;
+
+ bootpath = grub_ieee1275_get_boot_dev ();
+ if (! bootpath)
+ return;
+
+ /* Transform an OF device path to a GRUB path. */
+
+ type = grub_ieee1275_get_device_type (bootpath);
+ if (type && grub_strcmp (type, "network") == 0)
+ {
+ char *dev, *canon;
+ char *ptr;
+ dev = grub_ieee1275_get_aliasdevname (bootpath);
+ canon = grub_ieee1275_canonicalise_devname (dev);
+ if (! canon)
+ return;
+ ptr = canon + grub_strlen (canon) - 1;
+ while (ptr > canon && (*ptr == ',' || *ptr == ':'))
+ ptr--;
+ ptr++;
+ *ptr = 0;
+
+ if (grub_ieee1275_net_config)
+ grub_ieee1275_net_config (canon, device, path, bootpath);
+ grub_free (dev);
+ grub_free (canon);
+ }
+ else
+ *device = grub_ieee1275_encode_devname (bootpath);
+ grub_free (type);
+
+ filename = grub_ieee1275_get_filename (bootpath);
+ if (filename)
+ {
+ char *lastslash = grub_strrchr (filename, '\\');
+
+ /* Truncate at last directory. */
+ if (lastslash)
+ {
+ *lastslash = '\0';
+ grub_translate_ieee1275_path (filename);
+
+ *path = filename;
+ }
+ }
+ grub_free (bootpath);
+}
+
+/* Claim some available memory in the first /memory node. */
+#ifdef __sparc__
+static void
+grub_claim_heap (void)
+{
+ grub_mm_init_region ((void *) (grub_modules_get_end ()
+ + GRUB_KERNEL_MACHINE_STACK_SIZE), 0x200000);
+}
+#else
+/* Helper for grub_claim_heap. */
+static int
+heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type,
+ void *data)
+{
+ unsigned long *total = data;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM))
+ {
+ if (addr + len <= 0x180000)
+ return 0;
+
+ if (addr < 0x180000)
+ {
+ len = addr + len - 0x180000;
+ addr = 0x180000;
+ }
+ }
+ len -= 1; /* Required for some firmware. */
+
+ /* Never exceed HEAP_MAX_SIZE */
+ if (*total + len > HEAP_MAX_SIZE)
+ len = HEAP_MAX_SIZE - *total;
+
+ /* Avoid claiming anything above HEAP_MAX_ADDR, if possible. */
+ if ((addr < HEAP_MAX_ADDR) && /* if it's too late, don't bother */
+ (addr + len > HEAP_MAX_ADDR) && /* if it wasn't available anyway, don't bother */
+ (*total + (HEAP_MAX_ADDR - addr) > HEAP_MIN_SIZE)) /* only limit ourselves when we can afford to */
+ len = HEAP_MAX_ADDR - addr;
+
+ /* In theory, firmware should already prevent this from happening by not
+ listing our own image in /memory/available. The check below is intended
+ as a safeguard in case that doesn't happen. However, it doesn't protect
+ us from corrupting our module area, which extends up to a
+ yet-undetermined region above _end. */
+ if ((addr < (grub_addr_t) _end) && ((addr + len) > (grub_addr_t) _start))
+ {
+ grub_printf ("Warning: attempt to claim over our own code!\n");
+ len = 0;
+ }
+
+ if (len)
+ {
+ grub_err_t err;
+ /* Claim and use it. */
+ err = grub_claimmap (addr, len);
+ if (err)
+ return err;
+ grub_mm_init_region ((void *) (grub_addr_t) addr, len);
+ }
+
+ *total += len;
+ if (*total >= HEAP_MAX_SIZE)
+ return 1;
+
+ return 0;
+}
+
+static void
+grub_claim_heap (void)
+{
+ unsigned long total = 0;
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM))
+ heap_init (GRUB_IEEE1275_STATIC_HEAP_START, GRUB_IEEE1275_STATIC_HEAP_LEN,
+ 1, &total);
+ else
+ grub_machine_mmap_iterate (heap_init, &total);
+}
+#endif
+
+static void
+grub_parse_cmdline (void)
+{
+ grub_ssize_t actual;
+ char args[256];
+
+ if (grub_ieee1275_get_property (grub_ieee1275_chosen, "bootargs", &args,
+ sizeof args, &actual) == 0
+ && actual > 1)
+ {
+ int i = 0;
+
+ while (i < actual)
+ {
+ char *command = &args[i];
+ char *end;
+ char *val;
+
+ end = grub_strchr (command, ';');
+ if (end == 0)
+ i = actual; /* No more commands after this one. */
+ else
+ {
+ *end = '\0';
+ i += end - command + 1;
+ while (grub_isspace(args[i]))
+ i++;
+ }
+
+ /* Process command. */
+ val = grub_strchr (command, '=');
+ if (val)
+ {
+ *val = '\0';
+ grub_env_set (command, val + 1);
+ }
+ }
+ }
+}
+
+grub_addr_t grub_modbase;
+
+void
+grub_machine_init (void)
+{
+ grub_modbase = ALIGN_UP((grub_addr_t) _end
+ + GRUB_KERNEL_MACHINE_MOD_GAP,
+ GRUB_KERNEL_MACHINE_MOD_ALIGN);
+ grub_ieee1275_init ();
+
+ grub_console_init_early ();
+ grub_claim_heap ();
+ grub_console_init_lately ();
+#ifdef __sparc__
+ grub_obdisk_init ();
+#else
+ grub_ofdisk_init ();
+#endif
+ grub_parse_cmdline ();
+
+#ifdef __i386__
+ grub_tsc_init ();
+#else
+ grub_install_get_time_ms (grub_rtc_get_time_ms);
+#endif
+}
+
+void
+grub_machine_fini (int flags)
+{
+ if (flags & GRUB_LOADER_FLAG_NORETURN)
+ {
+#ifdef __sparc__
+ grub_obdisk_fini ();
+#else
+ grub_ofdisk_fini ();
+#endif
+ grub_console_fini ();
+ }
+}
+
+grub_uint64_t
+grub_rtc_get_time_ms (void)
+{
+ grub_uint32_t msecs = 0;
+
+ grub_ieee1275_milliseconds (&msecs);
+
+ return msecs;
+}
diff --git a/grub-core/kern/ieee1275/mmap.c b/grub-core/kern/ieee1275/mmap.c
new file mode 100644
index 0000000..bf325ea
--- /dev/null
+++ b/grub-core/kern/ieee1275/mmap.c
@@ -0,0 +1,83 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/memory.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/types.h>
+
+grub_err_t
+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[128];
+ grub_ssize_t available_size;
+ grub_uint32_t address_cells = 1;
+ grub_uint32_t size_cells = 1;
+ int i;
+
+ /* Determine the format of each entry in `available'. */
+ grub_ieee1275_finddevice ("/", &root);
+ grub_ieee1275_get_integer_property (root, "#address-cells", &address_cells,
+ sizeof address_cells, 0);
+ grub_ieee1275_get_integer_property (root, "#size-cells", &size_cells,
+ sizeof size_cells, 0);
+
+ if (size_cells > address_cells)
+ address_cells = size_cells;
+
+ /* Load `/memory/available'. */
+ if (grub_ieee1275_finddevice ("/memory", &memory))
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "couldn't find /memory node");
+ if (grub_ieee1275_get_integer_property (memory, "available", available,
+ 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))
+ {
+ address_cells = 1;
+ size_cells = 1;
+ }
+
+ /* Decode each entry and call `hook'. */
+ i = 0;
+ available_size /= sizeof (grub_uint32_t);
+ while (i < available_size)
+ {
+ grub_uint64_t address;
+ grub_uint64_t size;
+
+ address = available[i++];
+ if (address_cells == 2)
+ address = (address << 32) | available[i++];
+
+ size = available[i++];
+ if (size_cells == 2)
+ size = (size << 32) | available[i++];
+
+ if (hook (address, size, GRUB_MEMORY_AVAILABLE, hook_data))
+ break;
+ }
+
+ return grub_errno;
+}
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
new file mode 100644
index 0000000..4d493ab
--- /dev/null
+++ b/grub-core/kern/ieee1275/openfw.c
@@ -0,0 +1,593 @@
+/* openfw.c -- Open firmware support functions. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/net.h>
+
+enum grub_ieee1275_parse_type
+{
+ GRUB_PARSE_FILENAME,
+ GRUB_PARSE_PARTITION,
+ GRUB_PARSE_DEVICE,
+ GRUB_PARSE_DEVICE_TYPE
+};
+
+static int
+fill_alias (struct grub_ieee1275_devalias *alias)
+{
+ grub_ssize_t actual;
+
+ if (grub_ieee1275_get_property (alias->phandle, "device_type", alias->type,
+ IEEE1275_MAX_PROP_LEN, &actual))
+ alias->type[0] = 0;
+
+ if (alias->parent_dev == alias->phandle)
+ return 0;
+
+ if (grub_ieee1275_package_to_path (alias->phandle, alias->path,
+ IEEE1275_MAX_PATH_LEN, &actual))
+ return 0;
+
+ if (grub_strcmp (alias->parent_path, alias->path) == 0)
+ return 0;
+
+ if (grub_ieee1275_get_property (alias->phandle, "name", alias->name,
+ IEEE1275_MAX_PROP_LEN, &actual))
+ return 0;
+ grub_dprintf ("devalias", "device path=%s\n", alias->path);
+ return 1;
+}
+
+void
+grub_ieee1275_devalias_free (struct grub_ieee1275_devalias *alias)
+{
+ grub_free (alias->name);
+ grub_free (alias->type);
+ grub_free (alias->path);
+ grub_free (alias->parent_path);
+ alias->name = 0;
+ alias->type = 0;
+ alias->path = 0;
+ alias->parent_path = 0;
+ alias->phandle = GRUB_IEEE1275_PHANDLE_INVALID;
+}
+
+void
+grub_ieee1275_children_peer (struct grub_ieee1275_devalias *alias)
+{
+ while (grub_ieee1275_peer (alias->phandle, &alias->phandle) != -1)
+ if (fill_alias (alias))
+ return;
+ grub_ieee1275_devalias_free (alias);
+}
+
+void
+grub_ieee1275_children_first (const char *devpath,
+ struct grub_ieee1275_devalias *alias)
+{
+ grub_ieee1275_phandle_t dev;
+
+ grub_dprintf ("devalias", "iterating children of %s\n",
+ devpath);
+
+ alias->name = 0;
+ alias->path = 0;
+ alias->parent_path = 0;
+ alias->type = 0;
+
+ if (grub_ieee1275_finddevice (devpath, &dev))
+ return;
+
+ if (grub_ieee1275_child (dev, &alias->phandle))
+ return;
+
+ alias->type = grub_malloc (IEEE1275_MAX_PROP_LEN);
+ if (!alias->type)
+ return;
+ alias->path = grub_malloc (IEEE1275_MAX_PATH_LEN);
+ if (!alias->path)
+ {
+ grub_free (alias->type);
+ return;
+ }
+ alias->parent_path = grub_strdup (devpath);
+ if (!alias->parent_path)
+ {
+ grub_free (alias->path);
+ grub_free (alias->type);
+ return;
+ }
+
+ alias->name = grub_malloc (IEEE1275_MAX_PROP_LEN);
+ if (!alias->name)
+ {
+ grub_free (alias->path);
+ grub_free (alias->type);
+ grub_free (alias->parent_path);
+ return;
+ }
+ if (!fill_alias (alias))
+ grub_ieee1275_children_peer (alias);
+}
+
+static int
+iterate_recursively (const char *path,
+ int (*hook) (struct grub_ieee1275_devalias *alias))
+{
+ struct grub_ieee1275_devalias alias;
+ int ret = 0;
+
+ FOR_IEEE1275_DEVCHILDREN(path, alias)
+ {
+ ret = hook (&alias);
+ if (ret)
+ break;
+ ret = iterate_recursively (alias.path, hook);
+ if (ret)
+ break;
+ }
+ grub_ieee1275_devalias_free (&alias);
+ return ret;
+}
+
+int
+grub_ieee1275_devices_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
+{
+ return iterate_recursively ("/", hook);
+}
+
+void
+grub_ieee1275_devalias_init_iterator (struct grub_ieee1275_devalias *alias)
+{
+ alias->name = 0;
+ alias->path = 0;
+ alias->parent_path = 0;
+ alias->type = 0;
+
+ grub_dprintf ("devalias", "iterating aliases\n");
+
+ if (grub_ieee1275_finddevice ("/aliases", &alias->parent_dev))
+ return;
+
+ alias->name = grub_malloc (IEEE1275_MAX_PROP_LEN);
+ if (!alias->name)
+ return;
+
+ alias->type = grub_malloc (IEEE1275_MAX_PROP_LEN);
+ if (!alias->type)
+ {
+ grub_free (alias->name);
+ alias->name = 0;
+ return;
+ }
+
+ alias->name[0] = '\0';
+}
+
+int
+grub_ieee1275_devalias_next (struct grub_ieee1275_devalias *alias)
+{
+ if (!alias->name)
+ return 0;
+ while (1)
+ {
+ grub_ssize_t pathlen;
+ grub_ssize_t actual;
+ char *tmp;
+
+ if (alias->path)
+ {
+ grub_free (alias->path);
+ alias->path = 0;
+ }
+ tmp = grub_strdup (alias->name);
+ if (grub_ieee1275_next_property (alias->parent_dev, tmp,
+ alias->name) <= 0)
+ {
+ grub_free (tmp);
+ grub_ieee1275_devalias_free (alias);
+ return 0;
+ }
+ grub_free (tmp);
+
+ grub_dprintf ("devalias", "devalias name = %s\n", alias->name);
+
+ grub_ieee1275_get_property_length (alias->parent_dev, alias->name, &pathlen);
+
+ /* The property `name' is a special case we should skip. */
+ if (grub_strcmp (alias->name, "name") == 0)
+ continue;
+
+ /* Sun's OpenBoot often doesn't zero terminate the device alias
+ strings, so we will add a NULL byte at the end explicitly. */
+ pathlen += 1;
+
+ alias->path = grub_malloc (pathlen + 1);
+ if (! alias->path)
+ {
+ grub_ieee1275_devalias_free (alias);
+ return 0;
+ }
+
+ if (grub_ieee1275_get_property (alias->parent_dev, alias->name, alias->path,
+ pathlen, &actual) || actual < 0)
+ {
+ grub_dprintf ("devalias", "get_property (%s) failed\n", alias->name);
+ grub_free (alias->path);
+ continue;
+ }
+ if (actual > pathlen)
+ actual = pathlen;
+ alias->path[actual] = '\0';
+ alias->path[pathlen] = '\0';
+
+ if (grub_ieee1275_finddevice (alias->path, &alias->phandle))
+ {
+ grub_dprintf ("devalias", "finddevice (%s) failed\n", alias->path);
+ grub_free (alias->path);
+ alias->path = 0;
+ continue;
+ }
+
+ if (grub_ieee1275_get_property (alias->phandle, "device_type", alias->type,
+ IEEE1275_MAX_PROP_LEN, &actual))
+ {
+ /* NAND device don't have device_type property. */
+ alias->type[0] = 0;
+ }
+ return 1;
+ }
+}
+
+/* Call the "map" method of /chosen/mmu. */
+int
+grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
+ grub_uint32_t mode)
+{
+ struct map_args {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t mode;
+ grub_ieee1275_cell_t size;
+ grub_ieee1275_cell_t virt;
+#ifdef __sparc__
+ grub_ieee1275_cell_t phys_high;
+#endif
+ grub_ieee1275_cell_t phys_low;
+ grub_ieee1275_cell_t catch_result;
+ } args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method",
+#ifdef __sparc__
+ 7,
+#else
+ 6,
+#endif
+ 1);
+ args.method = (grub_ieee1275_cell_t) "map";
+ args.ihandle = grub_ieee1275_mmu;
+#ifdef __sparc__
+ args.phys_high = 0;
+#endif
+ args.phys_low = phys;
+ args.virt = virt;
+ args.size = size;
+ args.mode = mode; /* Format is WIMG0PP. */
+ args.catch_result = (grub_ieee1275_cell_t) -1;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+
+ return args.catch_result;
+}
+
+grub_err_t
+grub_claimmap (grub_addr_t addr, grub_size_t size)
+{
+ if (grub_ieee1275_claim (addr, size, 0, 0))
+ return -1;
+
+ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE)
+ && grub_ieee1275_map (addr, addr, size, 0x00))
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "map failed: address 0x%llx, size 0x%llx\n",
+ (long long) addr, (long long) size);
+ grub_ieee1275_release (addr, size);
+ return grub_errno;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/* Get the device arguments of the Open Firmware node name `path'. */
+static char *
+grub_ieee1275_get_devargs (const char *path)
+{
+ char *colon = grub_strchr (path, ':');
+
+ if (! colon)
+ return 0;
+
+ return grub_strdup (colon + 1);
+}
+
+/* Get the device path of the Open Firmware node name `path'. */
+char *
+grub_ieee1275_get_devname (const char *path)
+{
+ char *colon = grub_strchr (path, ':');
+ int pathlen = grub_strlen (path);
+ struct grub_ieee1275_devalias curalias;
+ if (colon)
+ pathlen = (int)(colon - path);
+
+ /* Try to find an alias for this device. */
+ FOR_IEEE1275_DEVALIASES (curalias)
+ /* briQ firmware can change capitalization in /chosen/bootpath. */
+ if (grub_strncasecmp (curalias.path, path, pathlen) == 0
+ && curalias.path[pathlen] == 0)
+ {
+ char *newpath;
+ newpath = grub_strdup (curalias.name);
+ grub_ieee1275_devalias_free (&curalias);
+ return newpath;
+ }
+
+ return grub_strndup (path, pathlen);
+}
+
+static char *
+grub_ieee1275_parse_args (const char *path, enum grub_ieee1275_parse_type ptype)
+{
+ char type[64]; /* XXX check size. */
+ char *device = grub_ieee1275_get_devname (path);
+ char *ret = 0;
+ grub_ieee1275_phandle_t dev;
+
+ /* We need to know what type of device it is in order to parse the full
+ file path properly. */
+ if (grub_ieee1275_finddevice (device, &dev))
+ {
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "device %s not found", device);
+ goto fail;
+ }
+ if (grub_ieee1275_get_property (dev, "device_type", &type, sizeof type, 0))
+ {
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "device %s lacks a device_type property", device);
+ goto fail;
+ }
+
+ switch (ptype)
+ {
+ case GRUB_PARSE_DEVICE:
+ ret = grub_strdup (device);
+ break;
+ case GRUB_PARSE_DEVICE_TYPE:
+ ret = grub_strdup (type);
+ break;
+ case GRUB_PARSE_FILENAME:
+ {
+ char *comma;
+ char *args;
+
+ args = grub_ieee1275_get_devargs (path);
+ if (!args)
+ /* Shouldn't happen. */
+ return 0;
+
+ /* The syntax of the device arguments is defined in the CHRP and PReP
+ IEEE1275 bindings: "[partition][,[filename]]". */
+ comma = grub_strchr (args, ',');
+
+ if (comma)
+ {
+ char *filepath = comma + 1;
+
+ /* Make sure filepath has leading backslash. */
+ if (filepath[0] != '\\')
+ ret = grub_xasprintf ("\\%s", filepath);
+ else
+ ret = grub_strdup (filepath);
+ }
+ grub_free (args);
+ }
+ break;
+ case GRUB_PARSE_PARTITION:
+ {
+ char *comma;
+ char *args;
+
+ if (grub_strcmp ("block", type) != 0)
+ goto unknown;
+
+ args = grub_ieee1275_get_devargs (path);
+ if (!args)
+ /* Shouldn't happen. */
+ return 0;
+
+ comma = grub_strchr (args, ',');
+ if (!comma)
+ ret = grub_strdup (args);
+ else
+ ret = grub_strndup (args, (grub_size_t)(comma - args));
+ /* Consistently provide numbered partitions to GRUB.
+ OpenBOOT traditionally uses alphabetical partition
+ specifiers. */
+ if (ret[0] >= 'a' && ret[0] <= 'z')
+ ret[0] = '1' + (ret[0] - 'a');
+ grub_free (args);
+ }
+ break;
+ default:
+ unknown:
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unsupported type %s for device %s", type, device);
+ }
+
+fail:
+ grub_free (device);
+ return ret;
+}
+
+char *
+grub_ieee1275_get_device_type (const char *path)
+{
+ return grub_ieee1275_parse_args (path, GRUB_PARSE_DEVICE_TYPE);
+}
+
+char *
+grub_ieee1275_get_aliasdevname (const char *path)
+{
+ return grub_ieee1275_parse_args (path, GRUB_PARSE_DEVICE);
+}
+
+char *
+grub_ieee1275_get_filename (const char *path)
+{
+ return grub_ieee1275_parse_args (path, GRUB_PARSE_FILENAME);
+}
+
+/* Convert a device name from IEEE1275 syntax to GRUB syntax. */
+char *
+grub_ieee1275_encode_devname (const char *path)
+{
+ char *device = grub_ieee1275_get_devname (path);
+ char *partition;
+ char *encoding;
+ char *optr;
+ const char *iptr;
+
+ if (! device)
+ return 0;
+
+ encoding = grub_malloc (sizeof ("ieee1275/") + 2 * grub_strlen (device)
+ + sizeof (",XXXXXXXXXXXX"));
+ if (!encoding)
+ {
+ grub_free (device);
+ return 0;
+ }
+
+ partition = grub_ieee1275_parse_args (path, GRUB_PARSE_PARTITION);
+
+ optr = grub_stpcpy (encoding, "ieee1275/");
+ for (iptr = device; *iptr; )
+ {
+ if (*iptr == ',')
+ *optr++ ='\\';
+ *optr++ = *iptr++;
+ }
+ if (partition && partition[0])
+ {
+ unsigned int partno = grub_strtoul (partition, 0, 0);
+
+ *optr++ = ',';
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS))
+ /* GRUB partition 1 is OF partition 0. */
+ partno++;
+
+ grub_snprintf (optr, sizeof ("XXXXXXXXXXXX"), "%d", partno);
+ }
+ else
+ *optr = '\0';
+
+ grub_free (partition);
+ grub_free (device);
+
+ return encoding;
+}
+
+/* Resolve aliases. */
+char *
+grub_ieee1275_canonicalise_devname (const char *path)
+{
+ struct canon_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t path;
+ grub_ieee1275_cell_t buf;
+ grub_ieee1275_cell_t inlen;
+ grub_ieee1275_cell_t outlen;
+ }
+ args;
+ char *buf = NULL;
+ grub_size_t bufsize = 64;
+ int i;
+
+ for (i = 0; i < 2; i++)
+ {
+ grub_free (buf);
+
+ buf = grub_malloc (bufsize);
+ if (!buf)
+ return NULL;
+
+ INIT_IEEE1275_COMMON (&args.common, "canon", 3, 1);
+ args.path = (grub_ieee1275_cell_t) path;
+ args.buf = (grub_ieee1275_cell_t) buf;
+ args.inlen = (grub_ieee1275_cell_t) (bufsize - 1);
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return 0;
+ if (args.outlen > bufsize - 1)
+ {
+ bufsize = args.outlen + 2;
+ continue;
+ }
+ return buf;
+ }
+ /* Shouldn't reach here. */
+ grub_free (buf);
+ return NULL;
+}
+
+char *
+grub_ieee1275_get_boot_dev (void)
+{
+ char *bootpath;
+ grub_ssize_t bootpath_size;
+
+ if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath",
+ &bootpath_size)
+ || bootpath_size <= 0)
+ {
+ /* Should never happen. */
+ grub_printf ("/chosen/bootpath property missing!\n");
+ return NULL;
+ }
+
+ bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64);
+ if (! bootpath)
+ {
+ grub_print_error ();
+ return NULL;
+ }
+ grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath,
+ (grub_size_t) bootpath_size + 1, 0);
+ bootpath[bootpath_size] = '\0';
+
+ return bootpath;
+}
diff --git a/grub-core/kern/list.c b/grub-core/kern/list.c
new file mode 100644
index 0000000..a256bb3
--- /dev/null
+++ b/grub-core/kern/list.c
@@ -0,0 +1,55 @@
+/* list.c - grub list function */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/list.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+
+void *
+grub_named_list_find (grub_named_list_t head, const char *name)
+{
+ grub_named_list_t item;
+
+ FOR_LIST_ELEMENTS (item, head)
+ if (grub_strcmp (item->name, name) == 0)
+ return item;
+
+ return NULL;
+}
+
+void
+grub_list_push (grub_list_t *head, grub_list_t item)
+{
+ item->prev = head;
+ if (*head)
+ (*head)->prev = &item->next;
+ item->next = *head;
+ *head = item;
+}
+
+void
+grub_list_remove (grub_list_t item)
+{
+ if (item->prev)
+ *item->prev = item->next;
+ if (item->next)
+ item->next->prev = item->prev;
+ item->next = 0;
+ item->prev = 0;
+}
diff --git a/grub-core/kern/lockdown.c b/grub-core/kern/lockdown.c
new file mode 100644
index 0000000..0bc70fd
--- /dev/null
+++ b/grub-core/kern/lockdown.c
@@ -0,0 +1,84 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2020 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <grub/dl.h>
+#include <grub/env.h>
+#include <grub/file.h>
+#include <grub/lockdown.h>
+#include <grub/verify.h>
+
+static int lockdown = GRUB_LOCKDOWN_DISABLED;
+
+static grub_err_t
+lockdown_verifier_init (grub_file_t io __attribute__ ((unused)),
+ enum grub_file_type type,
+ void **context __attribute__ ((unused)),
+ enum grub_verify_flags *flags)
+{
+ *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION;
+
+ switch (type & GRUB_FILE_TYPE_MASK)
+ {
+ case GRUB_FILE_TYPE_GRUB_MODULE:
+ case GRUB_FILE_TYPE_LINUX_KERNEL:
+ case GRUB_FILE_TYPE_MULTIBOOT_KERNEL:
+ case GRUB_FILE_TYPE_XEN_HYPERVISOR:
+ case GRUB_FILE_TYPE_BSD_KERNEL:
+ case GRUB_FILE_TYPE_XNU_KERNEL:
+ case GRUB_FILE_TYPE_PLAN9_KERNEL:
+ case GRUB_FILE_TYPE_NTLDR:
+ case GRUB_FILE_TYPE_TRUECRYPT:
+ case GRUB_FILE_TYPE_FREEDOS:
+ case GRUB_FILE_TYPE_PXECHAINLOADER:
+ case GRUB_FILE_TYPE_PCCHAINLOADER:
+ case GRUB_FILE_TYPE_COREBOOT_CHAINLOADER:
+ case GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE:
+ case GRUB_FILE_TYPE_ACPI_TABLE:
+ case GRUB_FILE_TYPE_DEVICE_TREE_IMAGE:
+ *flags = GRUB_VERIFY_FLAGS_DEFER_AUTH;
+
+ /* Fall through. */
+
+ default:
+ return GRUB_ERR_NONE;
+ }
+}
+
+struct grub_file_verifier lockdown_verifier =
+ {
+ .name = "lockdown_verifier",
+ .init = lockdown_verifier_init,
+ };
+
+void
+grub_lockdown (void)
+{
+ lockdown = GRUB_LOCKDOWN_ENABLED;
+
+ grub_verifier_register (&lockdown_verifier);
+
+ grub_env_set ("lockdown", "y");
+ grub_env_export ("lockdown");
+}
+
+int
+grub_is_lockdown (void)
+{
+ return lockdown;
+}
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
new file mode 100644
index 0000000..73967e2
--- /dev/null
+++ b/grub-core/kern/main.c
@@ -0,0 +1,316 @@
+/* main.c - the kernel main routine */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2006,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/symbol.h>
+#include <grub/dl.h>
+#include <grub/term.h>
+#include <grub/file.h>
+#include <grub/device.h>
+#include <grub/env.h>
+#include <grub/mm.h>
+#include <grub/command.h>
+#include <grub/reader.h>
+#include <grub/parser.h>
+#include <grub/verify.h>
+
+#ifdef GRUB_MACHINE_PCBIOS
+#include <grub/machine/memory.h>
+#endif
+
+grub_addr_t
+grub_modules_get_end (void)
+{
+ struct grub_module_info *modinfo;
+
+ modinfo = (struct grub_module_info *) grub_modbase;
+
+ /* Check if there are any modules. */
+ if ((modinfo == 0) || modinfo->magic != GRUB_MODULE_MAGIC)
+ return grub_modbase;
+
+ return grub_modbase + modinfo->size;
+}
+
+/* Load all modules in core. */
+static void
+grub_load_modules (void)
+{
+ struct grub_module_header *header;
+ FOR_MODULES (header)
+ {
+ /* Not an ELF module, skip. */
+ if (header->type != OBJ_TYPE_ELF)
+ continue;
+
+ if (! grub_dl_load_core ((char *) header + sizeof (struct grub_module_header),
+ (header->size - sizeof (struct grub_module_header))))
+ grub_fatal ("%s", grub_errmsg);
+
+ if (grub_errno)
+ grub_print_error ();
+ }
+}
+
+static char *load_config;
+
+static void
+grub_load_config (void)
+{
+ struct grub_module_header *header;
+ FOR_MODULES (header)
+ {
+ /* Not an embedded config, skip. */
+ if (header->type != OBJ_TYPE_CONFIG)
+ continue;
+
+ load_config = grub_malloc (header->size - sizeof (struct grub_module_header) + 1);
+ if (!load_config)
+ {
+ grub_print_error ();
+ break;
+ }
+ grub_memcpy (load_config, (char *) header +
+ sizeof (struct grub_module_header),
+ header->size - sizeof (struct grub_module_header));
+ load_config[header->size - sizeof (struct grub_module_header)] = 0;
+ break;
+ }
+}
+
+/* Write hook for the environment variables of root. Remove surrounding
+ parentheses, if any. */
+static char *
+grub_env_write_root (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val)
+{
+ /* XXX Is it better to check the existence of the device? */
+ grub_size_t len = grub_strlen (val);
+
+ if (val[0] == '(' && val[len - 1] == ')')
+ return grub_strndup (val + 1, len - 2);
+
+ return grub_strdup (val);
+}
+
+static void
+grub_set_prefix_and_root (void)
+{
+ char *device = NULL;
+ char *path = NULL;
+ char *fwdevice = NULL;
+ char *fwpath = NULL;
+ char *prefix = NULL;
+ struct grub_module_header *header;
+
+ FOR_MODULES (header)
+ if (header->type == OBJ_TYPE_PREFIX)
+ prefix = (char *) header + sizeof (struct grub_module_header);
+
+ grub_register_variable_hook ("root", 0, grub_env_write_root);
+
+ grub_machine_get_bootlocation (&fwdevice, &fwpath);
+
+ if (fwdevice)
+ {
+ char *cmdpath;
+
+ cmdpath = grub_xasprintf ("(%s)%s", fwdevice, fwpath ? : "");
+ if (cmdpath)
+ {
+ grub_env_set ("cmdpath", cmdpath);
+ grub_env_export ("cmdpath");
+ grub_free (cmdpath);
+ }
+ }
+
+ if (prefix)
+ {
+ char *pptr = NULL;
+ if (prefix[0] == '(')
+ {
+ pptr = grub_strrchr (prefix, ')');
+ if (pptr)
+ {
+ device = grub_strndup (prefix + 1, pptr - prefix - 1);
+ pptr++;
+ }
+ }
+ if (!pptr)
+ pptr = prefix;
+ if (pptr[0])
+ path = grub_strdup (pptr);
+ }
+
+ if (!device && fwdevice)
+ device = fwdevice;
+ else if (fwdevice && (device[0] == ',' || !device[0]))
+ {
+ /* We have a partition, but still need to fill in the drive. */
+ char *comma, *new_device;
+
+ for (comma = fwdevice; *comma; )
+ {
+ if (comma[0] == '\\' && comma[1] == ',')
+ {
+ comma += 2;
+ continue;
+ }
+ if (*comma == ',')
+ break;
+ comma++;
+ }
+ if (*comma)
+ {
+ char *drive = grub_strndup (fwdevice, comma - fwdevice);
+ new_device = grub_xasprintf ("%s%s", drive, device);
+ grub_free (drive);
+ }
+ else
+ new_device = grub_xasprintf ("%s%s", fwdevice, device);
+
+ grub_free (fwdevice);
+ grub_free (device);
+ device = new_device;
+ }
+ else
+ grub_free (fwdevice);
+ if (fwpath && !path)
+ {
+ grub_size_t len = grub_strlen (fwpath);
+ while (len > 1 && fwpath[len - 1] == '/')
+ fwpath[--len] = 0;
+ if (len >= sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1
+ && grub_memcmp (fwpath + len - (sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1), GRUB_TARGET_CPU "-" GRUB_PLATFORM,
+ sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1) == 0)
+ fwpath[len - (sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1)] = 0;
+ path = fwpath;
+ }
+ else
+ grub_free (fwpath);
+ if (device)
+ {
+ char *prefix_set;
+
+ prefix_set = grub_xasprintf ("(%s)%s", device, path ? : "");
+ if (prefix_set)
+ {
+ grub_env_set ("prefix", prefix_set);
+ grub_free (prefix_set);
+ }
+ grub_env_set ("root", device);
+ }
+
+ grub_free (device);
+ grub_free (path);
+ grub_print_error ();
+}
+
+/* Load the normal mode module and execute the normal mode if possible. */
+static void
+grub_load_normal_mode (void)
+{
+ /* Load the module. */
+ grub_dl_load ("normal");
+
+ /* Print errors if any. */
+ grub_print_error ();
+ grub_errno = 0;
+
+ grub_command_execute ("normal", 0, 0);
+}
+
+static void
+reclaim_module_space (void)
+{
+ grub_addr_t modstart, modend;
+
+ if (!grub_modbase)
+ return;
+
+#ifdef GRUB_MACHINE_PCBIOS
+ modstart = GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR;
+#else
+ modstart = grub_modbase;
+#endif
+ modend = grub_modules_get_end ();
+ grub_modbase = 0;
+
+#if GRUB_KERNEL_PRELOAD_SPACE_REUSABLE
+ grub_mm_init_region ((void *) modstart, modend - modstart);
+#else
+ (void) modstart;
+ (void) modend;
+#endif
+}
+
+/* The main routine. */
+void __attribute__ ((noreturn))
+grub_main (void)
+{
+ /* First of all, initialize the machine. */
+ grub_machine_init ();
+
+ grub_boot_time ("After machine init.");
+
+ /* Hello. */
+ grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
+ grub_printf ("Welcome to GRUB!\n\n");
+ grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
+
+ /* Init verifiers API. */
+ grub_verifiers_init ();
+
+ grub_load_config ();
+
+ grub_boot_time ("Before loading embedded modules.");
+
+ /* Load pre-loaded modules and free the space. */
+ grub_register_exported_symbols ();
+#ifdef GRUB_LINKER_HAVE_INIT
+ grub_arch_dl_init_linker ();
+#endif
+ grub_load_modules ();
+
+ grub_boot_time ("After loading embedded modules.");
+
+ /* It is better to set the root device as soon as possible,
+ for convenience. */
+ grub_set_prefix_and_root ();
+ grub_env_export ("root");
+ grub_env_export ("prefix");
+
+ /* Reclaim space used for modules. */
+ reclaim_module_space ();
+
+ grub_boot_time ("After reclaiming module space.");
+
+ grub_register_core_commands ();
+
+ grub_boot_time ("Before execution of embedded config.");
+
+ if (load_config)
+ grub_parser_execute (load_config);
+
+ grub_boot_time ("After execution of embedded config. Attempt to go to normal mode");
+
+ grub_load_normal_mode ();
+ grub_rescue_run ();
+}
diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c
new file mode 100644
index 0000000..2ed3ff3
--- /dev/null
+++ b/grub-core/kern/mips/arc/init.c
@@ -0,0 +1,463 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/time.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/machine/kernel.h>
+#include <grub/machine/memory.h>
+#include <grub/arc/console.h>
+#include <grub/cpu/memory.h>
+#include <grub/cpu/time.h>
+#include <grub/memory.h>
+#include <grub/term.h>
+#include <grub/arc/arc.h>
+#include <grub/offsets.h>
+#include <grub/i18n.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+
+const char *type_names[] = {
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ NULL,
+#endif
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ "eisa", "tc", "scsi", "dti", "multi", "disk", "tape", "cdrom", "worm",
+ "serial", "net", "video", "par", "point", "key", "audio", "other",
+ "rdisk", "fdisk", "tape", "modem", "monitor", "print", "pointer",
+ "keyboard", "term",
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ "other",
+#endif
+ "line", "network", NULL
+};
+
+static int
+iterate_rec (const char *prefix, const struct grub_arc_component *parent,
+ grub_arc_iterate_devs_hook_t hook, void *hook_data,
+ int alt_names)
+{
+ const struct grub_arc_component *comp;
+ FOR_ARC_CHILDREN(comp, parent)
+ {
+ char *name;
+ const char *cname = NULL;
+ if (comp->type < ARRAY_SIZE (type_names))
+ cname = type_names[comp->type];
+ if (!cname)
+ cname = "unknown";
+ if (alt_names)
+ name = grub_xasprintf ("%s/%s%lu", prefix, cname, comp->key);
+ else
+ name = grub_xasprintf ("%s%s(%lu)", prefix, cname, comp->key);
+ if (!name)
+ return 1;
+ if (hook (name, comp, hook_data))
+ {
+ grub_free (name);
+ return 1;
+ }
+ if (iterate_rec ((parent ? name : prefix), comp, hook, hook_data,
+ alt_names))
+ {
+ grub_free (name);
+ return 1;
+ }
+ grub_free (name);
+ }
+ return 0;
+}
+
+int
+grub_arc_iterate_devs (grub_arc_iterate_devs_hook_t hook, void *hook_data,
+ int alt_names)
+{
+ return iterate_rec ((alt_names ? "arc" : ""), NULL, hook, hook_data,
+ alt_names);
+}
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ struct grub_arc_memory_descriptor *cur = NULL;
+ while (1)
+ {
+ grub_memory_type_t type;
+ cur = GRUB_ARC_FIRMWARE_VECTOR->getmemorydescriptor (cur);
+ if (!cur)
+ return GRUB_ERR_NONE;
+ switch (cur->type)
+ {
+ case GRUB_ARC_MEMORY_EXCEPTION_BLOCK:
+ case GRUB_ARC_MEMORY_SYSTEM_PARAMETER_BLOCK:
+ case GRUB_ARC_MEMORY_FW_PERMANENT:
+ default:
+ type = GRUB_MEMORY_RESERVED;
+ break;
+
+ case GRUB_ARC_MEMORY_FW_TEMPORARY:
+ case GRUB_ARC_MEMORY_FREE:
+ case GRUB_ARC_MEMORY_LOADED:
+ case GRUB_ARC_MEMORY_FREE_CONTIGUOUS:
+ type = GRUB_MEMORY_AVAILABLE;
+ break;
+ case GRUB_ARC_MEMORY_BADRAM:
+ type = GRUB_MEMORY_BADRAM;
+ break;
+ }
+ if (hook (((grub_uint64_t) cur->start_page) << 12,
+ ((grub_uint64_t) cur->num_pages) << 12, type, hook_data))
+ return GRUB_ERR_NONE;
+ }
+}
+
+char *
+grub_arc_alt_name_to_norm (const char *name, const char *suffix)
+{
+ char *optr;
+ const char *iptr;
+ char * ret = grub_malloc (2 * grub_strlen (name) + grub_strlen (suffix));
+ int state = 0;
+
+ if (!ret)
+ return NULL;
+ optr = ret;
+ for (iptr = name + 4; *iptr; iptr++)
+ if (state == 0)
+ {
+ if (!grub_isdigit (*iptr))
+ *optr++ = *iptr;
+ else
+ {
+ *optr++ = '(';
+ *optr++ = *iptr;
+ state = 1;
+ }
+ }
+ else
+ {
+ if (grub_isdigit (*iptr))
+ *optr++ = *iptr;
+ else
+ {
+ *optr++ = ')';
+ state = 0;
+ }
+ }
+ if (state)
+ *optr++ = ')';
+ grub_strcpy (optr, suffix);
+ return ret;
+}
+
+static char *
+norm_name_to_alt (const char *name)
+{
+ char *optr;
+ const char *iptr;
+ int state = 0;
+ char * ret = grub_malloc (grub_strlen (name) + sizeof ("arc/"));
+
+ if (!ret)
+ return NULL;
+ optr = grub_stpcpy (ret, "arc/");
+ for (iptr = name; *iptr; iptr++)
+ {
+ if (state == 3)
+ {
+ *optr++ = '/';
+ state = 0;
+ }
+ if (*iptr == '(')
+ {
+ state = 1;
+ continue;
+ }
+ if (*iptr == ')')
+ {
+ if (state == 1)
+ *optr++ = '0';
+ state = 3;
+ continue;
+ }
+ *optr++ = *iptr;
+ if (state == 1)
+ state = 2;
+ }
+ *optr = '\0';
+ return ret;
+}
+
+extern grub_uint32_t grub_total_modules_size __attribute__ ((section(".text")));
+grub_addr_t grub_modbase;
+
+extern char _end[];
+static char boot_location[256];
+
+void
+grub_machine_init (void)
+{
+ struct grub_arc_memory_descriptor *cur = NULL;
+ grub_addr_t modend;
+
+ grub_memcpy (boot_location,
+ (char *) (GRUB_DECOMPRESSOR_LINK_ADDR - 256), 256);
+
+ grub_modbase = ALIGN_UP ((grub_addr_t) _end, GRUB_KERNEL_MACHINE_MOD_ALIGN);
+ modend = grub_modbase + grub_total_modules_size;
+ grub_console_init_early ();
+
+ /* FIXME: measure this. */
+ grub_arch_cpuclock = 150000000;
+ grub_install_get_time_ms (grub_rtc_get_time_ms);
+
+ while (1)
+ {
+ grub_uint64_t start, end;
+ cur = GRUB_ARC_FIRMWARE_VECTOR->getmemorydescriptor (cur);
+ if (!cur)
+ break;
+ if (cur->type != GRUB_ARC_MEMORY_FREE
+ && cur->type != GRUB_ARC_MEMORY_LOADED
+ && cur->type != GRUB_ARC_MEMORY_FREE_CONTIGUOUS)
+ continue;
+ start = ((grub_uint64_t) cur->start_page) << 12;
+ end = ((grub_uint64_t) cur->num_pages) << 12;
+ end += start;
+ if ((grub_uint64_t) start < (modend & 0x1fffffff))
+ start = (modend & 0x1fffffff);
+ if ((grub_uint64_t) end > 0x20000000)
+ end = 0x20000000;
+ if (end > start)
+ grub_mm_init_region ((void *) (grub_addr_t) (start | 0x80000000),
+ end - start);
+ }
+
+ grub_console_init_lately ();
+
+ grub_arcdisk_init ();
+}
+
+void
+grub_machine_fini (int flags __attribute__ ((unused)))
+{
+}
+
+void
+grub_halt (void)
+{
+ GRUB_ARC_FIRMWARE_VECTOR->powerdown ();
+
+ grub_millisleep (1500);
+
+ grub_puts_ (N_("Shutdown failed"));
+ grub_refresh ();
+ while (1);
+}
+
+void
+grub_exit (void)
+{
+ GRUB_ARC_FIRMWARE_VECTOR->exit ();
+
+ grub_millisleep (1500);
+
+ grub_puts_ (N_("Exit failed"));
+ grub_refresh ();
+ while (1);
+}
+
+static char *
+get_part (char *dev)
+{
+ char *ptr;
+ if (!*dev)
+ return 0;
+ ptr = dev + grub_strlen (dev) - 1;
+ if (ptr == dev || *ptr != ')')
+ return 0;
+ ptr--;
+ while (grub_isdigit (*ptr) && ptr > dev)
+ ptr--;
+ if (*ptr != '(' || ptr == dev)
+ return 0;
+ ptr--;
+ if (ptr - dev < (int) sizeof ("partition") - 2)
+ return 0;
+ ptr -= sizeof ("partition") - 2;
+ if (grub_memcmp (ptr, "partition", sizeof ("partition") - 1) != 0)
+ return 0;
+ return ptr;
+}
+
+static grub_disk_addr_t
+get_partition_offset (char *part, grub_disk_addr_t *en)
+{
+ grub_arc_fileno_t handle;
+ grub_disk_addr_t ret = -1;
+ struct grub_arc_fileinfo info;
+ grub_arc_err_t r;
+
+ if (GRUB_ARC_FIRMWARE_VECTOR->open (part, GRUB_ARC_FILE_ACCESS_OPEN_RO,
+ &handle))
+ return -1;
+
+ r = GRUB_ARC_FIRMWARE_VECTOR->getfileinformation (handle, &info);
+ if (!r)
+ {
+ ret = (info.start >> 9);
+ *en = (info.end >> 9);
+ }
+ GRUB_ARC_FIRMWARE_VECTOR->close (handle);
+ return ret;
+}
+
+struct get_device_name_ctx
+{
+ char *partition_name;
+ grub_disk_addr_t poff, pend;
+};
+
+static int
+get_device_name_iter (grub_disk_t disk __attribute__ ((unused)),
+ const grub_partition_t part, void *data)
+{
+ struct get_device_name_ctx *ctx = data;
+
+ if (grub_partition_get_start (part) == ctx->poff
+ && grub_partition_get_len (part) == ctx->pend)
+ {
+ ctx->partition_name = grub_partition_get_name (part);
+ return 1;
+ }
+
+ return 0;
+}
+
+void
+grub_machine_get_bootlocation (char **device, char **path)
+{
+ char *loaddev = boot_location;
+ char *pptr, *partptr;
+ char *dname;
+ grub_disk_addr_t poff = -1, pend = -1;
+ struct get_device_name_ctx ctx;
+ grub_disk_t parent = 0;
+ unsigned i;
+
+ for (i = 0; i < ARRAY_SIZE (type_names); i++)
+ if (type_names[i]
+ && grub_memcmp (loaddev, type_names[i], grub_strlen (type_names[i])) == 0
+ && loaddev[grub_strlen (type_names[i])] == '(')
+ break;
+ if (i == ARRAY_SIZE (type_names))
+ pptr = loaddev;
+ else
+ for (pptr = loaddev; *pptr && *pptr != '/' && *pptr != '\\'; pptr++);
+ if (*pptr)
+ {
+ char *iptr, *optr;
+ char sep = *pptr;
+ *path = grub_malloc (grub_strlen (pptr) + 1);
+ if (!*path)
+ return;
+ for (iptr = pptr, optr = *path; *iptr; iptr++, optr++)
+ if (*iptr == sep)
+ *optr = '/';
+ else
+ *optr = *iptr;
+ *optr = '\0';
+ *path = grub_strdup (pptr);
+ *pptr = '\0';
+ }
+
+ if (*loaddev == '\0')
+ {
+ const char *syspart = 0;
+
+ if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmware_vector_length
+ >= (unsigned) ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable + 1)
+ - (char *) GRUB_ARC_FIRMWARE_VECTOR)
+ && GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable)
+ syspart = GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable ("SystemPartition");
+ if (!syspart)
+ return;
+ loaddev = grub_strdup (syspart);
+ }
+
+ partptr = get_part (loaddev);
+ if (partptr)
+ {
+ poff = get_partition_offset (loaddev, &pend);
+ *partptr = '\0';
+ }
+ dname = norm_name_to_alt (loaddev);
+ if (poff == (grub_addr_t) -1)
+ {
+ *device = dname;
+ if (loaddev != boot_location)
+ grub_free (loaddev);
+ return;
+ }
+
+ parent = grub_disk_open (dname);
+ if (!parent)
+ {
+ *device = dname;
+ if (loaddev != boot_location)
+ grub_free (loaddev);
+ return;
+ }
+
+ if (poff == 0
+ && pend == grub_disk_native_sectors (parent))
+ {
+ grub_disk_close (parent);
+ *device = dname;
+ if (loaddev != boot_location)
+ grub_free (loaddev);
+ return;
+ }
+
+ ctx.partition_name = NULL;
+ ctx.poff = poff;
+ ctx.pend = pend;
+
+ grub_partition_iterate (parent, get_device_name_iter, &ctx);
+ grub_disk_close (parent);
+
+ if (! ctx.partition_name)
+ {
+ *device = dname;
+ if (loaddev != boot_location)
+ grub_free (loaddev);
+ return;
+ }
+
+ *device = grub_xasprintf ("%s,%s", dname,
+ ctx.partition_name);
+ grub_free (ctx.partition_name);
+ grub_free (dname);
+ if (loaddev != boot_location)
+ grub_free (loaddev);
+}
diff --git a/grub-core/kern/mips/cache.S b/grub-core/kern/mips/cache.S
new file mode 100644
index 0000000..fa331ec
--- /dev/null
+++ b/grub-core/kern/mips/cache.S
@@ -0,0 +1,70 @@
+
+#include <grub/symbol.h>
+
+ .set noreorder
+ .set nomacro
+
+FUNCTION (grub_arch_sync_caches)
+#include "cache_flush.S"
+ j $ra
+ nop
+
+FUNCTION (grub_arch_sync_dma_caches)
+ move $t2, $a0
+ addu $t3, $a0, $a1
+ srl $t2, $t2, 5
+ sll $t2, $t2, 5
+ addu $t3, $t3, 0x1f
+ srl $t3, $t3, 5
+ sll $t3, $t3, 5
+ move $t0, $t2
+ subu $t1, $t3, $t2
+1:
+ cache_op 1, 0($t0)
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ cache_op 1, 1($t0)
+ cache_op 1, 2($t0)
+ cache_op 1, 3($t0)
+
+ addiu $t1, $t1, -0x20
+ bne $t1, $zero, 1b
+ addiu $t0, $t0, 0x20
+#else
+ addiu $t1, $t1, -4
+ bne $t1, $zero, 1b
+ addiu $t0, $t0, 0x4
+#endif
+ sync_op
+ move $t0, $t2
+ subu $t1, $t3, $t2
+2:
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ cache_op 0, 0($t0)
+ addiu $t1, $t1, -0x20
+ bne $t1, $zero, 2b
+ addiu $t0, $t0, 0x20
+#else
+ cache_op 0, 0($t0)
+ addiu $t1, $t1, -4
+ bne $t1, $zero, 2b
+ addiu $t0, $t0, 0x4
+#endif
+ sync_op
+ move $t0, $t2
+ subu $t1, $t3, $t2
+2:
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ cache_op 23, 0($t0)
+ addiu $t1, $t1, -0x20
+ bne $t1, $zero, 2b
+ addiu $t0, $t0, 0x20
+#else
+ cache_op 23, 0($t0)
+ addiu $t1, $t1, -0x4
+ bne $t1, $zero, 2b
+ addiu $t0, $t0, 0x4
+#endif
+ sync_op
+
+ jr $ra
+ nop
diff --git a/grub-core/kern/mips/cache_flush.S b/grub-core/kern/mips/cache_flush.S
new file mode 100644
index 0000000..89961a0
--- /dev/null
+++ b/grub-core/kern/mips/cache_flush.S
@@ -0,0 +1,54 @@
+#ifndef CACHE_OP_DEFINED
+#define CACHE_OP_DEFINED 1
+ .macro cache_op op addr
+ .set mips3
+ cache \op, \addr
+ .set mips1
+ .endm
+ .macro sync_op
+ .set mips3
+ sync
+ .set mips1
+ .endm
+#endif
+
+ move $t2, $a0
+ addu $t3, $a0, $a1
+ srl $t2, $t2, 5
+ sll $t2, $t2, 5
+ addu $t3, $t3, 0x1f
+ srl $t3, $t3, 5
+ sll $t3, $t3, 5
+ move $t0, $t2
+ subu $t1, $t3, $t2
+1:
+ cache_op 1, 0($t0)
+ /* All four ways. */
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ cache_op 1, 1($t0)
+ cache_op 1, 2($t0)
+ cache_op 1, 3($t0)
+ addiu $t1, $t1, -0x20
+ bne $t1, $zero, 1b
+ addiu $t0, $t0, 0x20
+
+#else
+ addiu $t1, $t1, -0x4
+ bne $t1, $zero, 1b
+ addiu $t0, $t0, 0x4
+#endif
+ sync_op
+ move $t0, $t2
+ subu $t1, $t3, $t2
+2:
+ cache_op 0, 0($t0)
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ addiu $t1, $t1, -0x20
+ bne $t1, $zero, 2b
+ addiu $t0, $t0, 0x20
+#else
+ addiu $t1, $t1, -0x4
+ bne $t1, $zero, 2b
+ addiu $t0, $t0, 0x4
+#endif
+ sync_op
diff --git a/grub-core/kern/mips/dl.c b/grub-core/kern/mips/dl.c
new file mode 100644
index 0000000..5d7d299
--- /dev/null
+++ b/grub-core/kern/mips/dl.c
@@ -0,0 +1,274 @@
+/* dl-386.c - arch-dependent part of loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/cpu/types.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+
+/* Dummy __gnu_local_gp. Resolved by linker. */
+static char __gnu_local_gp_dummy;
+static char _gp_disp_dummy;
+
+/* Check if EHDR is a valid ELF header. */
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ Elf_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ if (e->e_ident[EI_CLASS] != ELFCLASS32
+ || e->e_ident[EI_DATA] != ELFDATA2MSB
+ || e->e_machine != EM_MIPS)
+#else
+ if (e->e_ident[EI_CLASS] != ELFCLASS32
+ || e->e_ident[EI_DATA] != ELFDATA2LSB
+ || e->e_machine != EM_MIPS)
+#endif
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+grub_err_t
+grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
+ grub_size_t *got)
+{
+ const Elf_Ehdr *e = ehdr;
+ const Elf_Shdr *s;
+ /* FIXME: suboptimal. */
+ grub_size_t gp_size = 0;
+ unsigned i;
+
+ *tramp = 0;
+ *got = 0;
+
+ for (i = 0, s = (const Elf_Shdr *) ((const char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (const Elf_Shdr *) ((const char *) s + e->e_shentsize))
+ if (s->sh_type == SHT_REL)
+ {
+ const Elf_Rel *rel, *max;
+
+ for (rel = (const Elf_Rel *) ((const char *) e + s->sh_offset),
+ max = rel + s->sh_size / s->sh_entsize;
+ rel < max;
+ rel++)
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case R_MIPS_GOT16:
+ case R_MIPS_CALL16:
+ case R_MIPS_GPREL32:
+ gp_size += 4;
+ break;
+ }
+ }
+
+ if (gp_size > 0x08000)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "__gnu_local_gp is too big\n");
+
+ *got = gp_size;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Relocate symbols. */
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ grub_uint32_t gp0;
+ Elf_Ehdr *e = ehdr;
+
+ if (!mod->reginfo)
+ {
+ unsigned i;
+ Elf_Shdr *ri;
+
+ /* Find reginfo. */
+ for (i = 0, ri = (Elf_Shdr *) ((char *) ehdr + e->e_shoff);
+ i < e->e_shnum;
+ i++, ri = (Elf_Shdr *) ((char *) ri + e->e_shentsize))
+ if (ri->sh_type == SHT_MIPS_REGINFO)
+ break;
+ if (i == e->e_shnum)
+ return grub_error (GRUB_ERR_BAD_MODULE, "no reginfo found");
+ mod->reginfo = (grub_uint32_t *)((char *) ehdr + ri->sh_offset);
+ }
+
+ gp0 = mod->reginfo[5];
+ Elf_Rel *rel, *max;
+
+ for (rel = (Elf_Rel *) ((char *) e + s->sh_offset),
+ max = (Elf_Rel *) ((char *) rel + s->sh_size);
+ rel < max;
+ rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
+ {
+ grub_uint8_t *addr;
+ Elf_Sym *sym;
+ grub_uint32_t sym_value;
+
+ if (seg->size < rel->r_offset)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ addr = (grub_uint8_t *) ((char *) seg->addr + rel->r_offset);
+ 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)
+ {
+ sym_value = (grub_addr_t) mod->got - (grub_addr_t) addr;
+ if (ELF_R_TYPE (rel->r_info) == R_MIPS_LO16)
+ /* ABI mandates +4 even if partner lui doesn't
+ immediately precede addiu. */
+ sym_value += 4;
+ }
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case R_MIPS_HI16:
+ {
+ grub_uint32_t value;
+ Elf_Rel *rel2;
+
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ addr += 2;
+#endif
+
+ /* Handle partner lo16 relocation. Lower part is
+ treated as signed. Hence add 0x8000 to compensate.
+ */
+ value = (*(grub_uint16_t *) addr << 16)
+ + sym_value + 0x8000;
+ for (rel2 = rel + 1; rel2 < max; rel2++)
+ if (ELF_R_SYM (rel2->r_info)
+ == ELF_R_SYM (rel->r_info)
+ && ELF_R_TYPE (rel2->r_info) == R_MIPS_LO16)
+ {
+ value += *(grub_int16_t *)
+ ((char *) seg->addr + rel2->r_offset
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ + 2
+#endif
+ );
+ break;
+ }
+ *(grub_uint16_t *) addr = (value >> 16) & 0xffff;
+ }
+ break;
+ case R_MIPS_LO16:
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ addr += 2;
+#endif
+ *(grub_uint16_t *) addr += sym_value & 0xffff;
+ break;
+ case R_MIPS_32:
+ *(grub_uint32_t *) addr += sym_value;
+ break;
+ case R_MIPS_GPREL32:
+ *(grub_uint32_t *) addr = sym_value
+ + *(grub_uint32_t *) addr + gp0 - (grub_uint32_t)mod->got;
+ break;
+
+ case R_MIPS_26:
+ {
+ grub_uint32_t value;
+ grub_uint32_t raw;
+ raw = (*(grub_uint32_t *) addr) & 0x3ffffff;
+ value = raw << 2;
+ value += sym_value;
+ raw = (value >> 2) & 0x3ffffff;
+
+ *(grub_uint32_t *) addr =
+ raw | ((*(grub_uint32_t *) addr) & 0xfc000000);
+ }
+ break;
+ case R_MIPS_GOT16:
+ if (ELF_ST_BIND (sym->st_info) == STB_LOCAL)
+ {
+ Elf_Rel *rel2;
+ /* Handle partner lo16 relocation. Lower part is
+ treated as signed. Hence add 0x8000 to compensate.
+ */
+ sym_value += (*(grub_uint16_t *) addr << 16)
+ + 0x8000;
+ for (rel2 = rel + 1; rel2 < max; rel2++)
+ if (ELF_R_SYM (rel2->r_info)
+ == ELF_R_SYM (rel->r_info)
+ && ELF_R_TYPE (rel2->r_info) == R_MIPS_LO16)
+ {
+ sym_value += *(grub_int16_t *)
+ ((char *) seg->addr + rel2->r_offset
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ + 2
+#endif
+ );
+ break;
+ }
+ sym_value &= 0xffff0000;
+ *(grub_uint16_t *) addr = 0;
+ }
+ /* Fallthrough. */
+ case R_MIPS_CALL16:
+ {
+ grub_uint32_t *gpptr = mod->gotptr;
+ /* FIXME: reuse*/
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ addr += 2;
+#endif
+ *gpptr = sym_value + *(grub_uint16_t *) addr;
+ *(grub_uint16_t *) addr
+ = sizeof (grub_uint32_t) * (gpptr - (grub_uint32_t *) mod->got);
+ mod->gotptr = gpptr + 1;
+ break;
+ }
+ case R_MIPS_JALR:
+ break;
+ default:
+ {
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%x is not implemented yet"),
+ ELF_R_TYPE (rel->r_info));
+ }
+ break;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_arch_dl_init_linker (void)
+{
+ grub_dl_register_symbol ("__gnu_local_gp", &__gnu_local_gp_dummy, 0, 0);
+ grub_dl_register_symbol ("_gp_disp", &_gp_disp_dummy, 0, 0);
+}
+
diff --git a/grub-core/kern/mips/init.c b/grub-core/kern/mips/init.c
new file mode 100644
index 0000000..14b8752
--- /dev/null
+++ b/grub-core/kern/mips/init.c
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/kernel.h>
+#include <grub/env.h>
+#include <grub/cpu/time.h>
+#include <grub/cpu/mips.h>
+
+/* FIXME: use interrupt to count high. */
+grub_uint64_t
+grub_get_rtc (void)
+{
+ static grub_uint32_t high = 0;
+ static grub_uint32_t last = 0;
+ grub_uint32_t low;
+
+ asm volatile ("mfc0 %0, " GRUB_CPU_MIPS_COP0_TIMER_COUNT : "=r" (low));
+ if (low < last)
+ high++;
+ last = low;
+
+ return (((grub_uint64_t) high) << 32) | low;
+}
diff --git a/grub-core/kern/mips/loongson/init.c b/grub-core/kern/mips/loongson/init.c
new file mode 100644
index 0000000..7b96531
--- /dev/null
+++ b/grub-core/kern/mips/loongson/init.c
@@ -0,0 +1,320 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/time.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/machine/time.h>
+#include <grub/machine/kernel.h>
+#include <grub/machine/memory.h>
+#include <grub/memory.h>
+#include <grub/mips/loongson.h>
+#include <grub/cs5536.h>
+#include <grub/term.h>
+#include <grub/cpu/memory.h>
+#include <grub/i18n.h>
+#include <grub/video.h>
+#include <grub/terminfo.h>
+#include <grub/keyboard_layouts.h>
+#include <grub/serial.h>
+#include <grub/loader.h>
+#include <grub/at_keyboard.h>
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ hook (GRUB_ARCH_LOWMEMPSTART, grub_arch_memsize << 20,
+ GRUB_MEMORY_AVAILABLE, hook_data);
+ hook (GRUB_ARCH_HIGHMEMPSTART, grub_arch_highmemsize << 20,
+ GRUB_MEMORY_AVAILABLE, hook_data);
+ return GRUB_ERR_NONE;
+}
+
+/* Helper for init_pci. */
+static int
+set_card (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ grub_pci_address_t addr;
+ /* We could use grub_pci_assign_addresses for this but we prefer to
+ have exactly same memory map as on pmon. */
+ switch (pciid)
+ {
+ case GRUB_LOONGSON_OHCI_PCIID:
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
+ grub_pci_write (addr, 0x5025000);
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write_word (addr, GRUB_PCI_COMMAND_SERR_ENABLE
+ | GRUB_PCI_COMMAND_PARITY_ERROR
+ | GRUB_PCI_COMMAND_BUS_MASTER
+ | GRUB_PCI_COMMAND_MEM_ENABLED);
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_STATUS);
+ grub_pci_write_word (addr, 0x0200 | GRUB_PCI_STATUS_CAPABILITIES);
+ break;
+ case GRUB_LOONGSON_EHCI_PCIID:
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
+ grub_pci_write (addr, 0x5026000);
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write_word (addr, GRUB_PCI_COMMAND_SERR_ENABLE
+ | GRUB_PCI_COMMAND_PARITY_ERROR
+ | GRUB_PCI_COMMAND_BUS_MASTER
+ | GRUB_PCI_COMMAND_MEM_ENABLED);
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_STATUS);
+ grub_pci_write_word (addr, (1 << GRUB_PCI_STATUS_DEVSEL_TIMING_SHIFT)
+ | GRUB_PCI_STATUS_CAPABILITIES);
+ break;
+ }
+ return 0;
+}
+
+static void
+init_pci (void)
+{
+ *((volatile grub_uint32_t *) GRUB_CPU_LOONGSON_PCI_HIT1_SEL_LO) = 0x8000000c;
+ *((volatile grub_uint32_t *) GRUB_CPU_LOONGSON_PCI_HIT1_SEL_HI) = 0xffffffff;
+
+ /* Setup PCI controller. */
+ *((volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
+ + GRUB_PCI_REG_COMMAND))
+ = GRUB_PCI_COMMAND_PARITY_ERROR | GRUB_PCI_COMMAND_BUS_MASTER
+ | GRUB_PCI_COMMAND_MEM_ENABLED;
+ *((volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
+ + GRUB_PCI_REG_STATUS))
+ = (1 << GRUB_PCI_STATUS_DEVSEL_TIMING_SHIFT)
+ | GRUB_PCI_STATUS_FAST_B2B_CAPABLE | GRUB_PCI_STATUS_66MHZ_CAPABLE
+ | GRUB_PCI_STATUS_CAPABILITIES;
+
+ *((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
+ + GRUB_PCI_REG_CACHELINE)) = 0xff;
+ *((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
+ + GRUB_PCI_REG_ADDRESS_REG0))
+ = 0x80000000 | GRUB_PCI_ADDR_MEM_TYPE_64 | GRUB_PCI_ADDR_MEM_PREFETCH;
+ *((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
+ + GRUB_PCI_REG_ADDRESS_REG1)) = 0;
+
+ grub_pci_iterate (set_card, NULL);
+}
+
+void
+grub_machine_init (void)
+{
+ grub_addr_t modend;
+ grub_uint32_t prid;
+
+ asm volatile ("mfc0 %0, " GRUB_CPU_LOONGSON_COP0_PRID : "=r" (prid));
+
+ switch (prid)
+ {
+ /* Loongson 2E. */
+ case 0x6302:
+ grub_arch_machine = GRUB_ARCH_MACHINE_FULOONG2E;
+ grub_bonito_type = GRUB_BONITO_2F;
+ break;
+ /* Loongson 2F. */
+ case 0x6303:
+ if (grub_arch_machine != GRUB_ARCH_MACHINE_FULOONG2F
+ && grub_arch_machine != GRUB_ARCH_MACHINE_YEELOONG)
+ grub_arch_machine = GRUB_ARCH_MACHINE_YEELOONG;
+ grub_bonito_type = GRUB_BONITO_2F;
+ break;
+ /* Loongson 3A. */
+ case 0x6305:
+ grub_arch_machine = GRUB_ARCH_MACHINE_YEELOONG_3A;
+ grub_bonito_type = GRUB_BONITO_3A;
+ break;
+ }
+
+ /* FIXME: measure this. */
+ if (grub_arch_busclock == 0)
+ {
+ grub_arch_busclock = 66000000;
+ grub_arch_cpuclock = 797000000;
+ }
+
+ grub_install_get_time_ms (grub_rtc_get_time_ms);
+
+ if (grub_arch_memsize == 0)
+ {
+ grub_port_t smbbase;
+ grub_err_t err;
+ grub_pci_device_t dev;
+ struct grub_smbus_spd spd;
+ unsigned totalmem;
+ int i;
+
+ if (!grub_cs5536_find (&dev))
+ grub_fatal ("No CS5536 found\n");
+
+ err = grub_cs5536_init_smbus (dev, 0x7ff, &smbbase);
+ if (err)
+ grub_fatal ("Couldn't init SMBus: %s\n", grub_errmsg);
+
+ /* Yeeloong and Fuloong have only one memory slot. */
+ err = grub_cs5536_read_spd (smbbase, GRUB_SMB_RAM_START_ADDR, &spd);
+ if (err)
+ grub_fatal ("Couldn't read SPD: %s\n", grub_errmsg);
+ for (i = 5; i < 13; i++)
+ if (spd.ddr2.rank_capacity & (1 << (i & 7)))
+ break;
+ /* Something is wrong. */
+ if (i == 13)
+ totalmem = 256;
+ else
+ totalmem = ((spd.ddr2.num_of_ranks
+ & GRUB_SMBUS_SPD_MEMORY_NUM_OF_RANKS_MASK) + 1) << (i + 2);
+
+ if (totalmem >= 256)
+ {
+ grub_arch_memsize = 256;
+ grub_arch_highmemsize = totalmem - 256;
+ }
+ else
+ {
+ grub_arch_memsize = totalmem;
+ grub_arch_highmemsize = 0;
+ }
+
+ grub_cs5536_init_geode (dev);
+
+ init_pci ();
+ }
+
+ modend = grub_modules_get_end ();
+ grub_mm_init_region ((void *) modend, (grub_arch_memsize << 20)
+ - (modend - GRUB_ARCH_LOWMEMVSTART));
+ /* FIXME: use upper memory as well. */
+
+ /* Initialize output terminal (can't be done earlier, as gfxterm
+ relies on a working heap. */
+ grub_video_sm712_init ();
+ grub_video_sis315pro_init ();
+ grub_video_radeon_fuloong2e_init ();
+ grub_video_radeon_yeeloong3a_init ();
+ grub_font_init ();
+ grub_gfxterm_init ();
+
+ grub_keylayouts_init ();
+ if (grub_arch_machine == GRUB_ARCH_MACHINE_YEELOONG
+ || grub_arch_machine == GRUB_ARCH_MACHINE_YEELOONG_3A)
+ grub_at_keyboard_init ();
+
+ grub_terminfo_init ();
+ grub_serial_init ();
+
+ grub_boot_init ();
+}
+
+void
+grub_machine_fini (int flags __attribute__ ((unused)))
+{
+}
+
+static int
+halt_via (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ grub_uint16_t pm;
+ grub_pci_address_t addr;
+
+ if (pciid != 0x30571106)
+ return 0;
+
+ addr = grub_pci_make_address (dev, 0x40);
+ pm = grub_pci_read (addr) & ~1;
+
+ if (pm == 0)
+ {
+ grub_pci_write (addr, 0x1801);
+ pm = 0x1800;
+ }
+
+ addr = grub_pci_make_address (dev, 0x80);
+ grub_pci_write_byte (addr, 0xff);
+
+ 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);
+
+ /* FIXME: This one is derived from qemu. Check on real hardware. */
+ grub_outw (0x2000, pm + 4 + GRUB_MACHINE_PCI_IO_BASE);
+ grub_millisleep (5000);
+
+ return 0;
+}
+
+void
+grub_halt (void)
+{
+ switch (grub_arch_machine)
+ {
+ case GRUB_ARCH_MACHINE_FULOONG2E:
+ grub_pci_iterate (halt_via, NULL);
+ break;
+ case GRUB_ARCH_MACHINE_FULOONG2F:
+ {
+ grub_pci_device_t dev;
+ grub_port_t p;
+ if (grub_cs5536_find (&dev))
+ {
+ p = (grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_GPIO_BAR)
+ & GRUB_CS5536_LBAR_ADDR_MASK) + GRUB_MACHINE_PCI_IO_BASE;
+ grub_outl ((1 << 13), p + 4);
+ grub_outl ((1 << 29), p);
+ grub_millisleep (5000);
+ }
+ }
+ break;
+ case GRUB_ARCH_MACHINE_YEELOONG:
+ grub_outb (grub_inb (GRUB_CPU_LOONGSON_GPIOCFG)
+ & ~GRUB_CPU_YEELOONG_SHUTDOWN_GPIO, GRUB_CPU_LOONGSON_GPIOCFG);
+ grub_millisleep (1500);
+ break;
+ case GRUB_ARCH_MACHINE_YEELOONG_3A:
+ grub_millisleep (1);
+ grub_outb (0x4e, GRUB_MACHINE_PCI_IO_BASE_3A | 0x66);
+ grub_millisleep (1);
+ grub_outb (2, GRUB_MACHINE_PCI_IO_BASE_3A | 0x62);
+ grub_millisleep (5000);
+ break;
+ }
+
+ grub_puts_ (N_("Shutdown failed"));
+ grub_refresh ();
+ while (1);
+}
+
+void
+grub_exit (void)
+{
+ grub_halt ();
+}
+
+void
+grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
+ char **path __attribute__ ((unused)))
+{
+}
+
+extern char _end[];
+grub_addr_t grub_modbase = (grub_addr_t) _end;
+
diff --git a/grub-core/kern/mips/qemu_mips/init.c b/grub-core/kern/mips/qemu_mips/init.c
new file mode 100644
index 0000000..be88b77
--- /dev/null
+++ b/grub-core/kern/mips/qemu_mips/init.c
@@ -0,0 +1,105 @@
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/time.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/kernel.h>
+#include <grub/machine/console.h>
+#include <grub/cpu/memory.h>
+#include <grub/memory.h>
+#include <grub/video.h>
+#include <grub/terminfo.h>
+#include <grub/keyboard_layouts.h>
+#include <grub/serial.h>
+#include <grub/loader.h>
+#include <grub/at_keyboard.h>
+
+static inline int
+probe_mem (grub_addr_t addr)
+{
+ volatile grub_uint8_t *ptr = (grub_uint8_t *) (0xa0000000 | addr);
+ grub_uint8_t c = *ptr;
+ *ptr = 0xAA;
+ if (*ptr != 0xAA)
+ return 0;
+ *ptr = 0x55;
+ if (*ptr != 0x55)
+ return 0;
+ *ptr = c;
+ return 1;
+}
+
+void
+grub_machine_init (void)
+{
+ grub_addr_t modend;
+
+ if (grub_arch_memsize == 0)
+ {
+ int i;
+
+ for (i = 27; i >= 0; i--)
+ if (probe_mem (grub_arch_memsize | (1 << i)))
+ grub_arch_memsize |= (1 << i);
+ grub_arch_memsize++;
+ }
+
+ /* FIXME: measure this. */
+ grub_arch_cpuclock = 200000000;
+
+ modend = grub_modules_get_end ();
+ grub_mm_init_region ((void *) modend, grub_arch_memsize
+ - (modend - GRUB_ARCH_LOWMEMVSTART));
+
+ grub_install_get_time_ms (grub_rtc_get_time_ms);
+
+ grub_keylayouts_init ();
+ grub_at_keyboard_init ();
+
+ grub_qemu_init_cirrus ();
+ grub_vga_text_init ();
+
+ grub_terminfo_init ();
+ grub_serial_init ();
+
+ grub_boot_init ();
+}
+
+void
+grub_machine_fini (int flags __attribute__ ((unused)))
+{
+}
+
+void
+grub_exit (void)
+{
+ grub_halt ();
+}
+
+void
+grub_halt (void)
+{
+ grub_outl (42, 0xbfbf0004);
+ while (1);
+}
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ hook (0, grub_arch_memsize, GRUB_MEMORY_AVAILABLE, hook_data);
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
+ char **path __attribute__ ((unused)))
+{
+}
+
+extern char _end[];
+grub_addr_t grub_modbase = (grub_addr_t) _end;
+
diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S
new file mode 100644
index 0000000..1fdb58a
--- /dev/null
+++ b/grub-core/kern/mips/startup.S
@@ -0,0 +1,126 @@
+/* startup.S - Startup code for the MIPS. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/offsets.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/kernel.h>
+#include <grub/offsets.h>
+#include <grub/mips/asm.h>
+
+#define BASE_ADDR 8
+
+ .globl __start, _start, start
+ .set noreorder
+ .set nomacro
+__start:
+_start:
+start:
+.extern __bss_start
+.extern _end
+ bal cont
+ nop
+
+ .org GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
+VARIABLE(grub_total_modules_size)
+ .long 0
+
+VARIABLE (grub_arch_busclock)
+ .long 0
+VARIABLE (grub_arch_cpuclock)
+ .long 0
+VARIABLE (grub_arch_memsize)
+ .long 0
+VARIABLE (grub_arch_highmemsize)
+ .long 0
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+VARIABLE (grub_arch_machine)
+ .long GRUB_ARCH_MACHINE_FULOONG2F
+#endif
+cont:
+ /* Save our base. */
+ move $s0, $ra
+
+#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
+ lui $t1, %hi(grub_arch_busclock)
+ addiu $t1, %lo(grub_arch_busclock)
+ sw $s4, 8($t1)
+#endif
+
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ lui $t1, %hi(grub_arch_busclock)
+ addiu $t1, %lo(grub_arch_busclock)
+ sw $s2, 0($t1)
+ sw $s3, 4($t1)
+ sw $s4, 8($t1)
+ sw $s5, 12($t1)
+ sw $s7, 16($t1)
+#endif
+
+ /* Move the modules out of BSS. */
+ lui $t2, %hi(__bss_start)
+ addiu $t2, %lo(__bss_start)
+
+ lui $t1, %hi(_end)
+ addiu $t1, %lo(_end)
+ addiu $t1, (GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
+ li $t3, (GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
+ nor $t3, $t3, $0
+ and $t1, $t1, $t3
+
+ lw $t3, (GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE - BASE_ADDR)($s0)
+
+ /* Backward copy. */
+ add $t1, $t1, $t3
+ add $t2, $t2, $t3
+ addiu $t1, $t1, -1
+ addiu $t2, $t2, -1
+
+ /* $t2 is source. $t1 is destination. $t3 is size. */
+modulesmovcont:
+ beq $t3, $0, modulesmovdone
+ nop
+ lb GRUB_ASM_T4, 0($t2)
+ sb GRUB_ASM_T4, 0($t1)
+ addiu $t2, $t2, -1
+ addiu $t1, $t1, -1
+ b modulesmovcont
+ addiu $t3, $t3, -1
+modulesmovdone:
+
+ /* Clean BSS. */
+
+ lui $t1, %hi(__bss_start)
+ addiu $t1, $t1, %lo(__bss_start)
+ lui $t2, %hi(_end)
+ addiu $t2, $t2, %lo(_end)
+bsscont:
+ sb $0,0($t1)
+ addiu $t1, $t1, 1
+ sltu $t3, $t1, $t2
+ bne $t3, $0, bsscont
+ nop
+
+ lui $t9, %hi(grub_main)
+ addiu $t9, %lo(grub_main)
+
+ lui $sp, %hi(GRUB_MACHINE_MEMORY_STACK_HIGH)
+ jr $t9
+ addiu $sp, $sp, %lo(GRUB_MACHINE_MEMORY_STACK_HIGH)
+
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
new file mode 100644
index 0000000..3af336e
--- /dev/null
+++ b/grub-core/kern/misc.c
@@ -0,0 +1,1267 @@
+/* misc.c - definitions of misc functions */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <stdarg.h>
+#include <grub/term.h>
+#include <grub/env.h>
+#include <grub/i18n.h>
+
+union printf_arg
+{
+ /* Yes, type is also part of union as the moment we fill the value
+ we don't need to store its type anymore (when we'll need it, we'll
+ have format spec again. So save some space. */
+ enum
+ {
+ INT, LONG, LONGLONG,
+ UNSIGNED_INT = 3, UNSIGNED_LONG, UNSIGNED_LONGLONG,
+ STRING
+ } type;
+ long long ll;
+};
+
+struct printf_args
+{
+ union printf_arg prealloc[32];
+ union printf_arg *ptr;
+ grub_size_t count;
+};
+
+static void
+parse_printf_args (const char *fmt0, struct printf_args *args,
+ va_list args_in);
+static int
+grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
+ struct printf_args *args);
+
+static void
+free_printf_args (struct printf_args *args)
+{
+ if (args->ptr != args->prealloc)
+ grub_free (args->ptr);
+}
+
+static int
+grub_iswordseparator (int c)
+{
+ return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&');
+}
+
+/* grub_gettext_dummy is not translating anything. */
+static const char *
+grub_gettext_dummy (const char *s)
+{
+ return s;
+}
+
+const char* (*grub_gettext) (const char *s) = grub_gettext_dummy;
+
+void *
+grub_memmove (void *dest, const void *src, grub_size_t n)
+{
+ char *d = (char *) dest;
+ const char *s = (const char *) src;
+
+ if (d < s)
+ while (n--)
+ *d++ = *s++;
+ else
+ {
+ d += n;
+ s += n;
+
+ while (n--)
+ *--d = *--s;
+ }
+
+ return dest;
+}
+
+char *
+grub_strcpy (char *dest, const char *src)
+{
+ char *p = dest;
+
+ while ((*p++ = *src++) != '\0')
+ ;
+
+ return dest;
+}
+
+int
+grub_printf (const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start (ap, fmt);
+ ret = grub_vprintf (fmt, ap);
+ va_end (ap);
+
+ return ret;
+}
+
+int
+grub_printf_ (const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start (ap, fmt);
+ ret = grub_vprintf (_(fmt), ap);
+ va_end (ap);
+
+ return ret;
+}
+
+int
+grub_puts_ (const char *s)
+{
+ return grub_puts (_(s));
+}
+
+#if defined (__APPLE__) && ! defined (GRUB_UTIL)
+int
+grub_err_printf (const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start (ap, fmt);
+ ret = grub_vprintf (fmt, ap);
+ va_end (ap);
+
+ return ret;
+}
+#endif
+
+#if ! defined (__APPLE__) && ! defined (GRUB_UTIL)
+int grub_err_printf (const char *fmt, ...)
+__attribute__ ((alias("grub_printf")));
+#endif
+
+int
+grub_debug_enabled (const char * condition)
+{
+ const char *debug;
+
+ debug = grub_env_get ("debug");
+ if (!debug)
+ return 0;
+
+ if (grub_strword (debug, "all") || grub_strword (debug, condition))
+ return 1;
+
+ return 0;
+}
+
+void
+grub_real_dprintf (const char *file, const int line, const char *condition,
+ const char *fmt, ...)
+{
+ va_list args;
+
+ if (grub_debug_enabled (condition))
+ {
+ grub_printf ("%s:%d: ", file, line);
+ va_start (args, fmt);
+ grub_vprintf (fmt, args);
+ va_end (args);
+ grub_refresh ();
+ }
+}
+
+#define PREALLOC_SIZE 255
+
+int
+grub_vprintf (const char *fmt, va_list ap)
+{
+ grub_size_t s;
+ static char buf[PREALLOC_SIZE + 1];
+ char *curbuf = buf;
+ struct printf_args args;
+
+ parse_printf_args (fmt, &args, ap);
+
+ s = grub_vsnprintf_real (buf, PREALLOC_SIZE, fmt, &args);
+ if (s > PREALLOC_SIZE)
+ {
+ curbuf = grub_malloc (s + 1);
+ if (!curbuf)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ buf[PREALLOC_SIZE - 3] = '.';
+ buf[PREALLOC_SIZE - 2] = '.';
+ buf[PREALLOC_SIZE - 1] = '.';
+ buf[PREALLOC_SIZE] = 0;
+ curbuf = buf;
+ }
+ else
+ s = grub_vsnprintf_real (curbuf, s, fmt, &args);
+ }
+
+ free_printf_args (&args);
+
+ grub_xputs (curbuf);
+
+ if (curbuf != buf)
+ grub_free (curbuf);
+
+ return s;
+}
+
+int
+grub_memcmp (const void *s1, const void *s2, grub_size_t n)
+{
+ const grub_uint8_t *t1 = s1;
+ const grub_uint8_t *t2 = s2;
+
+ while (n--)
+ {
+ if (*t1 != *t2)
+ return (int) *t1 - (int) *t2;
+
+ t1++;
+ t2++;
+ }
+
+ return 0;
+}
+
+int
+grub_strcmp (const char *s1, const char *s2)
+{
+ while (*s1 && *s2)
+ {
+ if (*s1 != *s2)
+ break;
+
+ s1++;
+ s2++;
+ }
+
+ return (int) (grub_uint8_t) *s1 - (int) (grub_uint8_t) *s2;
+}
+
+int
+grub_strncmp (const char *s1, const char *s2, grub_size_t n)
+{
+ if (n == 0)
+ return 0;
+
+ while (*s1 && *s2 && --n)
+ {
+ if (*s1 != *s2)
+ break;
+
+ s1++;
+ s2++;
+ }
+
+ return (int) (grub_uint8_t) *s1 - (int) (grub_uint8_t) *s2;
+}
+
+char *
+grub_strchr (const char *s, int c)
+{
+ do
+ {
+ if (*s == c)
+ return (char *) s;
+ }
+ while (*s++);
+
+ return 0;
+}
+
+char *
+grub_strrchr (const char *s, int c)
+{
+ char *p = NULL;
+
+ do
+ {
+ if (*s == c)
+ p = (char *) s;
+ }
+ while (*s++);
+
+ return p;
+}
+
+int
+grub_strword (const char *haystack, const char *needle)
+{
+ const char *n_pos = needle;
+
+ while (grub_iswordseparator (*haystack))
+ haystack++;
+
+ while (*haystack)
+ {
+ /* Crawl both the needle and the haystack word we're on. */
+ while(*haystack && !grub_iswordseparator (*haystack)
+ && *haystack == *n_pos)
+ {
+ haystack++;
+ n_pos++;
+ }
+
+ /* If we reached the end of both words at the same time, the word
+ is found. If not, eat everything in the haystack that isn't the
+ next word (or the end of string) and "reset" the needle. */
+ if ( (!*haystack || grub_iswordseparator (*haystack))
+ && (!*n_pos || grub_iswordseparator (*n_pos)))
+ return 1;
+ else
+ {
+ n_pos = needle;
+ while (*haystack && !grub_iswordseparator (*haystack))
+ haystack++;
+ while (grub_iswordseparator (*haystack))
+ haystack++;
+ }
+ }
+
+ return 0;
+}
+
+int
+grub_isspace (int c)
+{
+ return (c == '\n' || c == '\r' || c == ' ' || c == '\t');
+}
+
+unsigned long
+grub_strtoul (const char * restrict str, const char ** const restrict end,
+ int base)
+{
+ unsigned long long num;
+
+ num = grub_strtoull (str, end, base);
+#if GRUB_CPU_SIZEOF_LONG != 8
+ if (num > ~0UL)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+ return ~0UL;
+ }
+#endif
+
+ return (unsigned long) num;
+}
+
+unsigned long long
+grub_strtoull (const char * restrict str, const char ** const restrict end,
+ int base)
+{
+ unsigned long long num = 0;
+ int found = 0;
+
+ /* Skip white spaces. */
+ /* grub_isspace checks that *str != '\0'. */
+ while (grub_isspace (*str))
+ str++;
+
+ /* Guess the base, if not specified. The prefix `0x' means 16, and
+ the prefix `0' means 8. */
+ if (str[0] == '0')
+ {
+ if (str[1] == 'x')
+ {
+ if (base == 0 || base == 16)
+ {
+ base = 16;
+ str += 2;
+ }
+ }
+ else if (base == 0 && str[1] >= '0' && str[1] <= '7')
+ base = 8;
+ }
+
+ if (base == 0)
+ base = 10;
+
+ while (*str)
+ {
+ unsigned long digit;
+
+ digit = grub_tolower (*str) - '0';
+ if (digit >= 'a' - '0')
+ digit += '0' - 'a' + 10;
+ else if (digit > 9)
+ break;
+
+ if (digit >= (unsigned long) base)
+ break;
+
+ found = 1;
+
+ /* NUM * BASE + DIGIT > ~0ULL */
+ if (num > grub_divmod64 (~0ULL - digit, base, 0))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("overflow is detected"));
+
+ if (end)
+ *end = (char *) str;
+
+ return ~0ULL;
+ }
+
+ num = num * base + digit;
+ str++;
+ }
+
+ if (! found)
+ {
+ grub_error (GRUB_ERR_BAD_NUMBER,
+ N_("unrecognized number"));
+
+ if (end)
+ *end = (char *) str;
+
+ return 0;
+ }
+
+ if (end)
+ *end = (char *) str;
+
+ return num;
+}
+
+char *
+grub_strdup (const char *s)
+{
+ grub_size_t len;
+ char *p;
+
+ len = grub_strlen (s) + 1;
+ p = (char *) grub_malloc (len);
+ if (! p)
+ return 0;
+
+ return grub_memcpy (p, s, len);
+}
+
+char *
+grub_strndup (const char *s, grub_size_t n)
+{
+ grub_size_t len;
+ char *p;
+
+ len = grub_strlen (s);
+ if (len > n)
+ len = n;
+ p = (char *) grub_malloc (len + 1);
+ if (! p)
+ return 0;
+
+ grub_memcpy (p, s, len);
+ p[len] = '\0';
+ return p;
+}
+
+/* clang detects that we're implementing here a memset so it decides to
+ optimise and calls memset resulting in infinite recursion. With volatile
+ we make it not optimise in this way. */
+#ifdef __clang__
+#define VOLATILE_CLANG volatile
+#else
+#define VOLATILE_CLANG
+#endif
+
+void *
+grub_memset (void *s, int c, grub_size_t len)
+{
+ void *p = s;
+ grub_uint8_t pattern8 = c;
+
+ if (len >= 3 * sizeof (unsigned long))
+ {
+ unsigned long patternl = 0;
+ grub_size_t i;
+
+ for (i = 0; i < sizeof (unsigned long); i++)
+ patternl |= ((unsigned long) pattern8) << (8 * i);
+
+ while (len > 0 && (((grub_addr_t) p) & (sizeof (unsigned long) - 1)))
+ {
+ *(VOLATILE_CLANG grub_uint8_t *) p = pattern8;
+ p = (grub_uint8_t *) p + 1;
+ len--;
+ }
+ while (len >= sizeof (unsigned long))
+ {
+ *(VOLATILE_CLANG unsigned long *) p = patternl;
+ p = (unsigned long *) p + 1;
+ len -= sizeof (unsigned long);
+ }
+ }
+
+ while (len > 0)
+ {
+ *(VOLATILE_CLANG grub_uint8_t *) p = pattern8;
+ p = (grub_uint8_t *) p + 1;
+ len--;
+ }
+
+ return s;
+}
+
+grub_size_t
+grub_strlen (const char *s)
+{
+ const char *p = s;
+
+ while (*p)
+ p++;
+
+ return p - s;
+}
+
+static inline void
+grub_reverse (char *str)
+{
+ char *p = str + grub_strlen (str) - 1;
+
+ while (str < p)
+ {
+ char tmp;
+
+ tmp = *str;
+ *str = *p;
+ *p = tmp;
+ str++;
+ p--;
+ }
+}
+
+/* Divide N by D, return the quotient, and store the remainder in *R. */
+grub_uint64_t
+grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
+{
+ /* This algorithm is typically implemented by hardware. The idea
+ is to get the highest bit in N, 64 times, by keeping
+ upper(N * 2^i) = (Q * D + M), where upper
+ represents the high 64 bits in 128-bits space. */
+ unsigned bits = 64;
+ grub_uint64_t q = 0;
+ grub_uint64_t m = 0;
+
+ /* ARM and IA64 don't have a fast 32-bit division.
+ Using that code would just make us use software division routines, calling
+ ourselves indirectly and hence getting infinite recursion.
+ */
+#if !GRUB_DIVISION_IN_SOFTWARE
+ /* Skip the slow computation if 32-bit arithmetic is possible. */
+ if (n < 0xffffffff && d < 0xffffffff)
+ {
+ if (r)
+ *r = ((grub_uint32_t) n) % (grub_uint32_t) d;
+
+ return ((grub_uint32_t) n) / (grub_uint32_t) d;
+ }
+#endif
+
+ while (bits--)
+ {
+ m <<= 1;
+
+ if (n & (1ULL << 63))
+ m |= 1;
+
+ q <<= 1;
+ n <<= 1;
+
+ if (m >= d)
+ {
+ q |= 1;
+ m -= d;
+ }
+ }
+
+ if (r)
+ *r = m;
+
+ return q;
+}
+
+/* Convert a long long value to a string. This function avoids 64-bit
+ modular arithmetic or divisions. */
+static inline char *
+grub_lltoa (char *str, int c, unsigned long long n)
+{
+ unsigned base = ((c == 'x') || (c == 'X')) ? 16 : 10;
+ char *p;
+
+ if ((long long) n < 0 && c == 'd')
+ {
+ n = (unsigned long long) (-((long long) n));
+ *str++ = '-';
+ }
+
+ p = str;
+
+ if (base == 16)
+ do
+ {
+ unsigned d = (unsigned) (n & 0xf);
+ *p++ = (d > 9) ? d + ((c == 'x') ? 'a' : 'A') - 10 : d + '0';
+ }
+ while (n >>= 4);
+ else
+ /* BASE == 10 */
+ do
+ {
+ grub_uint64_t m;
+
+ n = grub_divmod64 (n, 10, &m);
+ *p++ = m + '0';
+ }
+ while (n);
+
+ *p = 0;
+
+ grub_reverse (str);
+ return p;
+}
+
+/*
+ * Parse printf() fmt0 string into args arguments.
+ *
+ * The parsed arguments are either used by a printf() function to format the fmt0
+ * string or they are used to compare a format string from an untrusted source
+ * against a format string with expected arguments.
+ *
+ * When the fmt_check is set to !0, e.g. 1, then this function is executed in
+ * printf() format check mode. This enforces stricter rules for parsing the
+ * fmt0 to limit exposure to possible errors in printf() handling. It also
+ * disables positional parameters, "$", because some formats, e.g "%s%1$d",
+ * cannot be validated with the current implementation.
+ *
+ * The max_args allows to set a maximum number of accepted arguments. If the fmt0
+ * string defines more arguments than the max_args then the parse_printf_arg_fmt()
+ * function returns an error. This is currently used for format check only.
+ */
+static grub_err_t
+parse_printf_arg_fmt (const char *fmt0, struct printf_args *args,
+ int fmt_check, grub_size_t max_args)
+{
+ const char *fmt;
+ char c;
+ grub_size_t n = 0;
+
+ args->count = 0;
+
+ COMPILE_TIME_ASSERT (sizeof (int) == sizeof (grub_uint32_t));
+ COMPILE_TIME_ASSERT (sizeof (int) <= sizeof (long long));
+ COMPILE_TIME_ASSERT (sizeof (long) <= sizeof (long long));
+ COMPILE_TIME_ASSERT (sizeof (long long) == sizeof (void *)
+ || sizeof (int) == sizeof (void *));
+
+ fmt = fmt0;
+ while ((c = *fmt++) != 0)
+ {
+ if (c != '%')
+ continue;
+
+ if (*fmt =='-')
+ fmt++;
+
+ while (grub_isdigit (*fmt))
+ fmt++;
+
+ if (*fmt == '$')
+ {
+ if (fmt_check)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "positional arguments are not supported");
+ fmt++;
+ }
+
+ if (*fmt =='-')
+ fmt++;
+
+ while (grub_isdigit (*fmt))
+ fmt++;
+
+ if (*fmt =='.')
+ fmt++;
+
+ while (grub_isdigit (*fmt))
+ fmt++;
+
+ c = *fmt++;
+ if (c == 'l')
+ c = *fmt++;
+ if (c == 'l')
+ c = *fmt++;
+
+ switch (c)
+ {
+ case 'p':
+ case 'x':
+ case 'X':
+ case 'u':
+ case 'd':
+ case 'c':
+ case 'C':
+ case 's':
+ args->count++;
+ break;
+ case '%':
+ /* "%%" is the escape sequence to output "%". */
+ break;
+ default:
+ if (fmt_check)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "unexpected format");
+ break;
+ }
+ }
+
+ if (fmt_check && args->count > max_args)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many arguments");
+
+ if (args->count <= ARRAY_SIZE (args->prealloc))
+ args->ptr = args->prealloc;
+ else
+ {
+ args->ptr = grub_calloc (args->count, sizeof (args->ptr[0]));
+ if (!args->ptr)
+ {
+ if (fmt_check)
+ return grub_errno;
+
+ grub_errno = GRUB_ERR_NONE;
+ args->ptr = args->prealloc;
+ args->count = ARRAY_SIZE (args->prealloc);
+ }
+ }
+
+ grub_memset (args->ptr, 0, args->count * sizeof (args->ptr[0]));
+
+ fmt = fmt0;
+ n = 0;
+ while ((c = *fmt++) != 0)
+ {
+ int longfmt = 0;
+ grub_size_t curn;
+ const char *p;
+
+ if (c != '%')
+ continue;
+
+ curn = n++;
+
+ if (*fmt =='-')
+ fmt++;
+
+ p = fmt;
+
+ while (grub_isdigit (*fmt))
+ fmt++;
+
+ if (*fmt == '$')
+ {
+ curn = grub_strtoull (p, 0, 10) - 1;
+ fmt++;
+ }
+
+ if (*fmt =='-')
+ fmt++;
+
+ while (grub_isdigit (*fmt))
+ fmt++;
+
+ if (*fmt =='.')
+ fmt++;
+
+ while (grub_isdigit (*fmt))
+ fmt++;
+
+ c = *fmt++;
+ if (c == '%')
+ {
+ n--;
+ continue;
+ }
+
+ if (c == 'l')
+ {
+ c = *fmt++;
+ longfmt = 1;
+ }
+ if (c == 'l')
+ {
+ c = *fmt++;
+ longfmt = 2;
+ }
+ if (curn >= args->count)
+ continue;
+ switch (c)
+ {
+ case 'x':
+ case 'X':
+ case 'u':
+ args->ptr[curn].type = UNSIGNED_INT + longfmt;
+ break;
+ case 'd':
+ args->ptr[curn].type = INT + longfmt;
+ break;
+ case 'p':
+ if (sizeof (void *) == sizeof (long long))
+ args->ptr[curn].type = UNSIGNED_LONGLONG;
+ else
+ args->ptr[curn].type = UNSIGNED_INT;
+ break;
+ case 's':
+ args->ptr[curn].type = STRING;
+ break;
+ case 'C':
+ case 'c':
+ args->ptr[curn].type = INT;
+ break;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+parse_printf_args (const char *fmt0, struct printf_args *args, va_list args_in)
+{
+ grub_size_t n;
+
+ parse_printf_arg_fmt (fmt0, args, 0, 0);
+
+ for (n = 0; n < args->count; n++)
+ switch (args->ptr[n].type)
+ {
+ case INT:
+ args->ptr[n].ll = va_arg (args_in, int);
+ break;
+ case LONG:
+ args->ptr[n].ll = va_arg (args_in, long);
+ break;
+ case UNSIGNED_INT:
+ args->ptr[n].ll = va_arg (args_in, unsigned int);
+ break;
+ case UNSIGNED_LONG:
+ args->ptr[n].ll = va_arg (args_in, unsigned long);
+ break;
+ case LONGLONG:
+ case UNSIGNED_LONGLONG:
+ args->ptr[n].ll = va_arg (args_in, long long);
+ break;
+ case STRING:
+ if (sizeof (void *) == sizeof (long long))
+ args->ptr[n].ll = va_arg (args_in, long long);
+ else
+ args->ptr[n].ll = va_arg (args_in, unsigned int);
+ break;
+ }
+}
+
+static inline void __attribute__ ((always_inline))
+write_char (char *str, grub_size_t *count, grub_size_t max_len, unsigned char ch)
+{
+ if (*count < max_len)
+ str[*count] = ch;
+
+ (*count)++;
+}
+
+static int
+grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
+ struct printf_args *args)
+{
+ char c;
+ grub_size_t n = 0;
+ grub_size_t count = 0;
+ const char *fmt;
+
+ fmt = fmt0;
+
+ while ((c = *fmt++) != 0)
+ {
+ unsigned int format1 = 0;
+ unsigned int format2 = ~ 0U;
+ char zerofill = ' ';
+ char rightfill = 0;
+ grub_size_t curn;
+
+ if (c != '%')
+ {
+ write_char (str, &count, max_len,c);
+ continue;
+ }
+
+ curn = n++;
+
+ rescan:;
+
+ if (*fmt =='-')
+ {
+ rightfill = 1;
+ fmt++;
+ }
+
+ /* Read formatting parameters. */
+ if (grub_isdigit (*fmt))
+ {
+ if (fmt[0] == '0')
+ zerofill = '0';
+ format1 = grub_strtoul (fmt, &fmt, 10);
+ }
+
+ if (*fmt == '.')
+ fmt++;
+
+ if (grub_isdigit (*fmt))
+ format2 = grub_strtoul (fmt, &fmt, 10);
+
+ if (*fmt == '$')
+ {
+ curn = format1 - 1;
+ fmt++;
+ format1 = 0;
+ format2 = ~ 0U;
+ zerofill = ' ';
+ rightfill = 0;
+
+ goto rescan;
+ }
+
+ c = *fmt++;
+ if (c == 'l')
+ c = *fmt++;
+ if (c == 'l')
+ c = *fmt++;
+
+ if (c == '%')
+ {
+ write_char (str, &count, max_len,c);
+ n--;
+ continue;
+ }
+
+ if (curn >= args->count)
+ continue;
+
+ long long curarg = args->ptr[curn].ll;
+
+ switch (c)
+ {
+ case 'p':
+ write_char (str, &count, max_len, '0');
+ write_char (str, &count, max_len, 'x');
+ c = 'x';
+ /* Fall through. */
+ case 'x':
+ case 'X':
+ case 'u':
+ case 'd':
+ {
+ char tmp[32];
+ const char *p = tmp;
+ grub_size_t len;
+ grub_size_t fill;
+
+ len = grub_lltoa (tmp, c, curarg) - tmp;
+ fill = len < format1 ? format1 - len : 0;
+ if (! rightfill)
+ while (fill--)
+ write_char (str, &count, max_len, zerofill);
+ while (*p)
+ write_char (str, &count, max_len, *p++);
+ if (rightfill)
+ while (fill--)
+ write_char (str, &count, max_len, zerofill);
+ }
+ break;
+
+ case 'c':
+ write_char (str, &count, max_len,curarg & 0xff);
+ break;
+
+ case 'C':
+ {
+ grub_uint32_t code = curarg;
+ int shift;
+ unsigned mask;
+
+ if (code <= 0x7f)
+ {
+ shift = 0;
+ mask = 0;
+ }
+ else if (code <= 0x7ff)
+ {
+ shift = 6;
+ mask = 0xc0;
+ }
+ else if (code <= 0xffff)
+ {
+ shift = 12;
+ mask = 0xe0;
+ }
+ else if (code <= 0x10ffff)
+ {
+ shift = 18;
+ mask = 0xf0;
+ }
+ else
+ {
+ code = '?';
+ shift = 0;
+ mask = 0;
+ }
+
+ write_char (str, &count, max_len,mask | (code >> shift));
+
+ for (shift -= 6; shift >= 0; shift -= 6)
+ write_char (str, &count, max_len,0x80 | (0x3f & (code >> shift)));
+ }
+ break;
+
+ case 's':
+ {
+ grub_size_t len = 0;
+ grub_size_t fill;
+ const char *p = ((char *) (grub_addr_t) curarg) ? : "(null)";
+ grub_size_t i;
+
+ while (len < format2 && p[len])
+ len++;
+
+ fill = len < format1 ? format1 - len : 0;
+
+ if (!rightfill)
+ while (fill--)
+ write_char (str, &count, max_len, zerofill);
+
+ for (i = 0; i < len; i++)
+ write_char (str, &count, max_len,*p++);
+
+ if (rightfill)
+ while (fill--)
+ write_char (str, &count, max_len, zerofill);
+ }
+
+ break;
+
+ default:
+ write_char (str, &count, max_len,c);
+ break;
+ }
+ }
+
+ if (count < max_len)
+ str[count] = '\0';
+ else
+ str[max_len] = '\0';
+ return count;
+}
+
+int
+grub_vsnprintf (char *str, grub_size_t n, const char *fmt, va_list ap)
+{
+ grub_size_t ret;
+ struct printf_args args;
+
+ if (!n)
+ return 0;
+
+ n--;
+
+ parse_printf_args (fmt, &args, ap);
+
+ ret = grub_vsnprintf_real (str, n, fmt, &args);
+
+ free_printf_args (&args);
+
+ return ret < n ? ret : n;
+}
+
+int
+grub_snprintf (char *str, grub_size_t n, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start (ap, fmt);
+ ret = grub_vsnprintf (str, n, fmt, ap);
+ va_end (ap);
+
+ return ret;
+}
+
+char *
+grub_xvasprintf (const char *fmt, va_list ap)
+{
+ grub_size_t s, as = PREALLOC_SIZE;
+ char *ret;
+ struct printf_args args;
+
+ parse_printf_args (fmt, &args, ap);
+
+ while (1)
+ {
+ ret = grub_malloc (as + 1);
+ if (!ret)
+ {
+ free_printf_args (&args);
+ return NULL;
+ }
+
+ s = grub_vsnprintf_real (ret, as, fmt, &args);
+
+ if (s <= as)
+ {
+ free_printf_args (&args);
+ return ret;
+ }
+
+ grub_free (ret);
+ as = s;
+ }
+}
+
+char *
+grub_xasprintf (const char *fmt, ...)
+{
+ va_list ap;
+ char *ret;
+
+ va_start (ap, fmt);
+ ret = grub_xvasprintf (fmt, ap);
+ va_end (ap);
+
+ return ret;
+}
+
+grub_err_t
+grub_printf_fmt_check (const char *fmt, const char *fmt_expected)
+{
+ struct printf_args args_expected, args_fmt;
+ grub_err_t ret;
+ grub_size_t n;
+
+ if (fmt == NULL || fmt_expected == NULL)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid format");
+
+ ret = parse_printf_arg_fmt (fmt_expected, &args_expected, 1, GRUB_SIZE_MAX);
+ if (ret != GRUB_ERR_NONE)
+ return ret;
+
+ /* Limit parsing to the number of expected arguments. */
+ ret = parse_printf_arg_fmt (fmt, &args_fmt, 1, args_expected.count);
+ if (ret != GRUB_ERR_NONE)
+ {
+ free_printf_args (&args_expected);
+ return ret;
+ }
+
+ for (n = 0; n < args_fmt.count; n++)
+ if (args_fmt.ptr[n].type != args_expected.ptr[n].type)
+ {
+ ret = grub_error (GRUB_ERR_BAD_ARGUMENT, "arguments types do not match");
+ break;
+ }
+
+ free_printf_args (&args_expected);
+ free_printf_args (&args_fmt);
+
+ return ret;
+}
+
+
+/* Abort GRUB. This function does not return. */
+static void __attribute__ ((noreturn))
+grub_abort (void)
+{
+ grub_printf ("\nAborted.");
+
+#ifndef GRUB_UTIL
+ if (grub_term_inputs)
+#endif
+ {
+ grub_printf (" Press any key to exit.");
+ grub_getkey ();
+ }
+
+ grub_exit ();
+}
+
+void
+grub_fatal (const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ grub_vprintf (_(fmt), ap);
+ va_end (ap);
+
+ grub_refresh ();
+
+ grub_abort ();
+}
+
+#if BOOT_TIME_STATS
+
+#include <grub/time.h>
+
+struct grub_boot_time *grub_boot_time_head;
+static struct grub_boot_time **boot_time_last = &grub_boot_time_head;
+
+void
+grub_real_boot_time (const char *file,
+ const int line,
+ const char *fmt, ...)
+{
+ struct grub_boot_time *n;
+ va_list args;
+
+ grub_error_push ();
+ n = grub_malloc (sizeof (*n));
+ if (!n)
+ {
+ grub_errno = 0;
+ grub_error_pop ();
+ return;
+ }
+ n->file = file;
+ n->line = line;
+ n->tp = grub_get_time_ms ();
+ n->next = 0;
+
+ va_start (args, fmt);
+ n->msg = grub_xvasprintf (fmt, args);
+ va_end (args);
+
+ *boot_time_last = n;
+ boot_time_last = &n->next;
+
+ grub_errno = 0;
+ grub_error_pop ();
+}
+#endif
diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
new file mode 100644
index 0000000..c070afc
--- /dev/null
+++ b/grub-core/kern/mm.c
@@ -0,0 +1,664 @@
+/* mm.c - functions for memory manager */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ The design of this memory manager.
+
+ This is a simple implementation of malloc with a few extensions. These are
+ the extensions:
+
+ - memalign is implemented efficiently.
+
+ - multiple regions may be used as free space. They may not be
+ contiguous.
+
+ Regions are managed by a singly linked list, and the meta information is
+ stored in the beginning of each region. Space after the meta information
+ is used to allocate memory.
+
+ The memory space is used as cells instead of bytes for simplicity. This
+ is important for some CPUs which may not access multiple bytes at a time
+ when the first byte is not aligned at a certain boundary (typically,
+ 4-byte or 8-byte). The size of each cell is equal to the size of struct
+ grub_mm_header, so the header of each allocated/free block fits into one
+ cell precisely. One cell is 16 bytes on 32-bit platforms and 32 bytes
+ on 64-bit platforms.
+
+ There are two types of blocks: allocated blocks and free blocks.
+
+ In allocated blocks, the header of each block has only its size. Note that
+ this size is based on cells but not on bytes. The header is located right
+ before the returned pointer, that is, the header resides at the previous
+ cell.
+
+ Free blocks constitutes a ring, using a singly linked list. The first free
+ block is pointed to by the meta information of a region. The allocator
+ attempts to pick up the second block instead of the first one. This is
+ a typical optimization against defragmentation, and makes the
+ implementation a bit easier.
+
+ For safety, both allocated blocks and free ones are marked by magic
+ numbers. Whenever anything unexpected is detected, GRUB aborts the
+ operation.
+ */
+
+#include <config.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/disk.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+#include <grub/mm_private.h>
+#include <grub/safemath.h>
+
+#ifdef MM_DEBUG
+# undef grub_calloc
+# undef grub_malloc
+# undef grub_zalloc
+# undef grub_realloc
+# undef grub_free
+# undef grub_memalign
+#endif
+
+
+
+grub_mm_region_t grub_mm_base;
+
+/* Get a header from the pointer PTR, and set *P and *R to a pointer
+ to the header and a pointer to its region, respectively. PTR must
+ be allocated. */
+static void
+get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r)
+{
+ if ((grub_addr_t) ptr & (GRUB_MM_ALIGN - 1))
+ grub_fatal ("unaligned pointer %p", ptr);
+
+ for (*r = grub_mm_base; *r; *r = (*r)->next)
+ if ((grub_addr_t) ptr > (grub_addr_t) ((*r) + 1)
+ && (grub_addr_t) ptr <= (grub_addr_t) ((*r) + 1) + (*r)->size)
+ break;
+
+ if (! *r)
+ grub_fatal ("out of range pointer %p", ptr);
+
+ *p = (grub_mm_header_t) ptr - 1;
+ if ((*p)->magic == GRUB_MM_FREE_MAGIC)
+ grub_fatal ("double free at %p", *p);
+ if ((*p)->magic != GRUB_MM_ALLOC_MAGIC)
+ grub_fatal ("alloc magic is broken at %p: %lx", *p,
+ (unsigned long) (*p)->magic);
+}
+
+/* Initialize a region starting from ADDR and whose size is SIZE,
+ to use it as free space. */
+void
+grub_mm_init_region (void *addr, grub_size_t size)
+{
+ grub_mm_header_t h;
+ grub_mm_region_t r, *p, q;
+
+#if 0
+ grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size);
+#endif
+
+ /* Exclude last 4K to avoid overflows. */
+ /* If addr + 0x1000 overflows then whole region is in excluded zone. */
+ if ((grub_addr_t) addr > ~((grub_addr_t) 0x1000))
+ return;
+
+ /* If addr + 0x1000 + size overflows then decrease size. */
+ if (((grub_addr_t) addr + 0x1000) > ~(grub_addr_t) size)
+ size = ((grub_addr_t) -0x1000) - (grub_addr_t) addr;
+
+ for (p = &grub_mm_base, q = *p; q; p = &(q->next), q = *p)
+ if ((grub_uint8_t *) addr + size + q->pre_size == (grub_uint8_t *) q)
+ {
+ r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN);
+ *r = *q;
+ r->pre_size += size;
+
+ if (r->pre_size >> GRUB_MM_ALIGN_LOG2)
+ {
+ h = (grub_mm_header_t) (r + 1);
+ h->size = (r->pre_size >> GRUB_MM_ALIGN_LOG2);
+ h->magic = GRUB_MM_ALLOC_MAGIC;
+ r->size += h->size << GRUB_MM_ALIGN_LOG2;
+ r->pre_size &= (GRUB_MM_ALIGN - 1);
+ *p = r;
+ grub_free (h + 1);
+ }
+ *p = r;
+ return;
+ }
+
+ /* Allocate a region from the head. */
+ r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN);
+
+ /* If this region is too small, ignore it. */
+ if (size < GRUB_MM_ALIGN + (char *) r - (char *) addr + sizeof (*r))
+ return;
+
+ size -= (char *) r - (char *) addr + sizeof (*r);
+
+ h = (grub_mm_header_t) (r + 1);
+ h->next = h;
+ h->magic = GRUB_MM_FREE_MAGIC;
+ h->size = (size >> GRUB_MM_ALIGN_LOG2);
+
+ r->first = h;
+ r->pre_size = (grub_addr_t) r - (grub_addr_t) addr;
+ r->size = (h->size << GRUB_MM_ALIGN_LOG2);
+
+ /* Find where to insert this region. Put a smaller one before bigger ones,
+ to prevent fragmentation. */
+ for (p = &grub_mm_base, q = *p; q; p = &(q->next), q = *p)
+ if (q->size > r->size)
+ break;
+
+ *p = r;
+ r->next = q;
+}
+
+/* Allocate the number of units N with the alignment ALIGN from the ring
+ buffer starting from *FIRST. ALIGN must be a power of two. Both N and
+ ALIGN are in units of GRUB_MM_ALIGN. Return a non-NULL if successful,
+ otherwise return NULL. */
+static void *
+grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
+{
+ grub_mm_header_t p, q;
+
+ /* When everything is allocated side effect is that *first will have alloc
+ magic marked, meaning that there is no room in this region. */
+ if ((*first)->magic == GRUB_MM_ALLOC_MAGIC)
+ return 0;
+
+ /* Try to search free slot for allocation in this memory region. */
+ for (q = *first, p = q->next; ; q = p, p = p->next)
+ {
+ grub_off_t extra;
+
+ extra = ((grub_addr_t) (p + 1) >> GRUB_MM_ALIGN_LOG2) & (align - 1);
+ if (extra)
+ extra = align - extra;
+
+ if (! p)
+ grub_fatal ("null in the ring");
+
+ if (p->magic != GRUB_MM_FREE_MAGIC)
+ grub_fatal ("free magic is broken at %p: 0x%x", p, p->magic);
+
+ if (p->size >= n + extra)
+ {
+ extra += (p->size - extra - n) & (~(align - 1));
+ if (extra == 0 && p->size == n)
+ {
+ /* There is no special alignment requirement and memory block
+ is complete match.
+
+ 1. Just mark memory block as allocated and remove it from
+ free list.
+
+ Result:
+ +---------------+ previous block's next
+ | alloc, size=n | |
+ +---------------+ v
+ */
+ q->next = p->next;
+ }
+ else if (align == 1 || p->size == n + extra)
+ {
+ /* There might be alignment requirement, when taking it into
+ account memory block fits in.
+
+ 1. Allocate new area at end of memory block.
+ 2. Reduce size of available blocks from original node.
+ 3. Mark new area as allocated and "remove" it from free
+ list.
+
+ Result:
+ +---------------+
+ | free, size-=n | next --+
+ +---------------+ |
+ | alloc, size=n | |
+ +---------------+ v
+ */
+
+ p->size -= n;
+ p += p->size;
+ }
+ else if (extra == 0)
+ {
+ grub_mm_header_t r;
+
+ r = p + extra + n;
+ r->magic = GRUB_MM_FREE_MAGIC;
+ r->size = p->size - extra - n;
+ r->next = p->next;
+ q->next = r;
+
+ if (q == p)
+ {
+ q = r;
+ r->next = r;
+ }
+ }
+ else
+ {
+ /* There is alignment requirement and there is room in memory
+ block. Split memory block to three pieces.
+
+ 1. Create new memory block right after section being
+ allocated. Mark it as free.
+ 2. Add new memory block to free chain.
+ 3. Mark current memory block having only extra blocks.
+ 4. Advance to aligned block and mark that as allocated and
+ "remove" it from free list.
+
+ Result:
+ +------------------------------+
+ | free, size=extra | next --+
+ +------------------------------+ |
+ | alloc, size=n | |
+ +------------------------------+ |
+ | free, size=orig.size-extra-n | <------+, next --+
+ +------------------------------+ v
+ */
+ grub_mm_header_t r;
+
+ r = p + extra + n;
+ r->magic = GRUB_MM_FREE_MAGIC;
+ r->size = p->size - extra - n;
+ r->next = p;
+
+ p->size = extra;
+ q->next = r;
+ p += extra;
+ }
+
+ p->magic = GRUB_MM_ALLOC_MAGIC;
+ p->size = n;
+
+ /* Mark find as a start marker for next allocation to fasten it.
+ This will have side effect of fragmenting memory as small
+ pieces before this will be un-used. */
+ /* So do it only for chunks under 64K. */
+ if (n < (0x8000 >> GRUB_MM_ALIGN_LOG2)
+ || *first == p)
+ *first = q;
+
+ return p + 1;
+ }
+
+ /* Search was completed without result. */
+ if (p == *first)
+ break;
+ }
+
+ return 0;
+}
+
+/* Allocate SIZE bytes with the alignment ALIGN and return the pointer. */
+void *
+grub_memalign (grub_size_t align, grub_size_t size)
+{
+ grub_mm_region_t r;
+ grub_size_t n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
+ int count = 0;
+
+ 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;
+
+ again:
+
+ for (r = grub_mm_base; r; r = r->next)
+ {
+ void *p;
+
+ p = grub_real_malloc (&(r->first), n, align);
+ if (p)
+ return p;
+ }
+
+ /* If failed, increase free memory somehow. */
+ switch (count)
+ {
+ case 0:
+ /* Invalidate disk caches. */
+ grub_disk_cache_invalidate_all ();
+ count++;
+ goto again;
+
+#if 0
+ case 1:
+ /* Unload unneeded modules. */
+ grub_dl_unload_unneeded ();
+ count++;
+ goto again;
+#endif
+
+ default:
+ break;
+ }
+
+ fail:
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return 0;
+}
+
+/*
+ * Allocate NMEMB instances of SIZE bytes and return the pointer, or error on
+ * integer overflow.
+ */
+void *
+grub_calloc (grub_size_t nmemb, grub_size_t size)
+{
+ void *ret;
+ grub_size_t sz = 0;
+
+ if (grub_mul (nmemb, size, &sz))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+ return NULL;
+ }
+
+ ret = grub_memalign (0, sz);
+ if (!ret)
+ return NULL;
+
+ grub_memset (ret, 0, sz);
+ return ret;
+}
+
+/* Allocate SIZE bytes and return the pointer. */
+void *
+grub_malloc (grub_size_t size)
+{
+ return grub_memalign (0, size);
+}
+
+/* Allocate SIZE bytes, clear them and return the pointer. */
+void *
+grub_zalloc (grub_size_t size)
+{
+ void *ret;
+
+ ret = grub_memalign (0, size);
+ if (ret)
+ grub_memset (ret, 0, size);
+
+ return ret;
+}
+
+/* Deallocate the pointer PTR. */
+void
+grub_free (void *ptr)
+{
+ grub_mm_header_t p;
+ grub_mm_region_t r;
+
+ if (! ptr)
+ return;
+
+ get_header_from_pointer (ptr, &p, &r);
+
+ if (r->first->magic == GRUB_MM_ALLOC_MAGIC)
+ {
+ p->magic = GRUB_MM_FREE_MAGIC;
+ r->first = p->next = p;
+ }
+ else
+ {
+ grub_mm_header_t q, s;
+
+#if 0
+ q = r->first;
+ do
+ {
+ grub_printf ("%s:%d: q=%p, q->size=0x%x, q->magic=0x%x\n",
+ GRUB_FILE, __LINE__, q, q->size, q->magic);
+ q = q->next;
+ }
+ while (q != r->first);
+#endif
+
+ for (s = r->first, q = s->next; q <= p || q->next >= p; s = q, q = s->next)
+ {
+ if (q->magic != GRUB_MM_FREE_MAGIC)
+ grub_fatal ("free magic is broken at %p: 0x%x", q, q->magic);
+
+ if (q <= q->next && (q > p || q->next < p))
+ break;
+ }
+
+ p->magic = GRUB_MM_FREE_MAGIC;
+ p->next = q->next;
+ q->next = p;
+
+ if (p->next + p->next->size == p)
+ {
+ p->magic = 0;
+
+ p->next->size += p->size;
+ q->next = p->next;
+ p = p->next;
+ }
+
+ r->first = q;
+
+ if (q == p + p->size)
+ {
+ q->magic = 0;
+ p->size += q->size;
+ if (q == s)
+ s = p;
+ s->next = p;
+ q = s;
+ }
+
+ r->first = q;
+ }
+}
+
+/* Reallocate SIZE bytes and return the pointer. The contents will be
+ the same as that of PTR. */
+void *
+grub_realloc (void *ptr, grub_size_t size)
+{
+ grub_mm_header_t p;
+ grub_mm_region_t r;
+ void *q;
+ grub_size_t n;
+
+ if (! ptr)
+ return grub_malloc (size);
+
+ if (! size)
+ {
+ grub_free (ptr);
+ return 0;
+ }
+
+ /* FIXME: Not optimal. */
+ n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
+ get_header_from_pointer (ptr, &p, &r);
+
+ if (p->size >= n)
+ return ptr;
+
+ q = grub_malloc (size);
+ if (! q)
+ return q;
+
+ /* We've already checked that p->size < n. */
+ grub_memcpy (q, ptr, p->size << GRUB_MM_ALIGN_LOG2);
+ grub_free (ptr);
+ return q;
+}
+
+#ifdef MM_DEBUG
+int grub_mm_debug = 0;
+
+void
+grub_mm_dump_free (void)
+{
+ grub_mm_region_t r;
+
+ for (r = grub_mm_base; r; r = r->next)
+ {
+ grub_mm_header_t p;
+
+ /* Follow the free list. */
+ p = r->first;
+ do
+ {
+ if (p->magic != GRUB_MM_FREE_MAGIC)
+ grub_fatal ("free magic is broken at %p: 0x%x", p, p->magic);
+
+ grub_printf ("F:%p:%u:%p\n",
+ p, (unsigned int) p->size << GRUB_MM_ALIGN_LOG2, p->next);
+ p = p->next;
+ }
+ while (p != r->first);
+ }
+
+ grub_printf ("\n");
+}
+
+void
+grub_mm_dump (unsigned lineno)
+{
+ grub_mm_region_t r;
+
+ grub_printf ("called at line %u\n", lineno);
+ for (r = grub_mm_base; r; r = r->next)
+ {
+ grub_mm_header_t p;
+
+ for (p = (grub_mm_header_t) ALIGN_UP ((grub_addr_t) (r + 1),
+ GRUB_MM_ALIGN);
+ (grub_addr_t) p < (grub_addr_t) (r+1) + r->size;
+ p++)
+ {
+ switch (p->magic)
+ {
+ case GRUB_MM_FREE_MAGIC:
+ grub_printf ("F:%p:%u:%p\n",
+ p, (unsigned int) p->size << GRUB_MM_ALIGN_LOG2, p->next);
+ break;
+ case GRUB_MM_ALLOC_MAGIC:
+ grub_printf ("A:%p:%u\n", p, (unsigned int) p->size << GRUB_MM_ALIGN_LOG2);
+ break;
+ }
+ }
+ }
+
+ grub_printf ("\n");
+}
+
+void *
+grub_debug_calloc (const char *file, int line, grub_size_t nmemb, grub_size_t size)
+{
+ void *ptr;
+
+ if (grub_mm_debug)
+ grub_printf ("%s:%d: calloc (0x%" PRIxGRUB_SIZE ", 0x%" PRIxGRUB_SIZE ") = ",
+ file, line, nmemb, size);
+ ptr = grub_calloc (nmemb, size);
+ if (grub_mm_debug)
+ grub_printf ("%p\n", ptr);
+ return ptr;
+}
+
+void *
+grub_debug_malloc (const char *file, int line, grub_size_t size)
+{
+ void *ptr;
+
+ if (grub_mm_debug)
+ grub_printf ("%s:%d: malloc (0x%" PRIxGRUB_SIZE ") = ", file, line, size);
+ ptr = grub_malloc (size);
+ if (grub_mm_debug)
+ grub_printf ("%p\n", ptr);
+ return ptr;
+}
+
+void *
+grub_debug_zalloc (const char *file, int line, grub_size_t size)
+{
+ void *ptr;
+
+ if (grub_mm_debug)
+ grub_printf ("%s:%d: zalloc (0x%" PRIxGRUB_SIZE ") = ", file, line, size);
+ ptr = grub_zalloc (size);
+ if (grub_mm_debug)
+ grub_printf ("%p\n", ptr);
+ return ptr;
+}
+
+void
+grub_debug_free (const char *file, int line, void *ptr)
+{
+ if (grub_mm_debug)
+ grub_printf ("%s:%d: free (%p)\n", file, line, ptr);
+ grub_free (ptr);
+}
+
+void *
+grub_debug_realloc (const char *file, int line, void *ptr, grub_size_t size)
+{
+ if (grub_mm_debug)
+ grub_printf ("%s:%d: realloc (%p, 0x%" PRIxGRUB_SIZE ") = ", file, line, ptr, size);
+ ptr = grub_realloc (ptr, size);
+ if (grub_mm_debug)
+ grub_printf ("%p\n", ptr);
+ return ptr;
+}
+
+void *
+grub_debug_memalign (const char *file, int line, grub_size_t align,
+ grub_size_t size)
+{
+ void *ptr;
+
+ if (grub_mm_debug)
+ grub_printf ("%s:%d: memalign (0x%" PRIxGRUB_SIZE ", 0x%" PRIxGRUB_SIZE
+ ") = ", file, line, align, size);
+ ptr = grub_memalign (align, size);
+ if (grub_mm_debug)
+ grub_printf ("%p\n", ptr);
+ return ptr;
+}
+
+#endif /* MM_DEBUG */
diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c
new file mode 100644
index 0000000..6ab7aa4
--- /dev/null
+++ b/grub-core/kern/parser.c
@@ -0,0 +1,342 @@
+/* parser.c - the part of the parser that can return partial tokens */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2009,2021 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/parser.h>
+#include <grub/buffer.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+
+
+/* All the possible state transitions on the command line. If a
+ transition can not be found, it is assumed that there is no
+ transition and keep_value is assumed to be 1. */
+static struct grub_parser_state_transition state_transitions[] = {
+ {GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_QUOTE, '\'', 0},
+ {GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_DQUOTE, '\"', 0},
+ {GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_VAR, '$', 0},
+ {GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_ESC, '\\', 0},
+
+ {GRUB_PARSER_STATE_ESC, GRUB_PARSER_STATE_TEXT, 0, 1},
+
+ {GRUB_PARSER_STATE_QUOTE, GRUB_PARSER_STATE_TEXT, '\'', 0},
+
+ {GRUB_PARSER_STATE_DQUOTE, GRUB_PARSER_STATE_TEXT, '\"', 0},
+ {GRUB_PARSER_STATE_DQUOTE, GRUB_PARSER_STATE_QVAR, '$', 0},
+
+ {GRUB_PARSER_STATE_VAR, GRUB_PARSER_STATE_VARNAME2, '{', 0},
+ {GRUB_PARSER_STATE_VAR, GRUB_PARSER_STATE_VARNAME, 0, 1},
+ {GRUB_PARSER_STATE_VARNAME, GRUB_PARSER_STATE_TEXT, ' ', 1},
+ {GRUB_PARSER_STATE_VARNAME, GRUB_PARSER_STATE_TEXT, '\t', 1},
+ {GRUB_PARSER_STATE_VARNAME2, GRUB_PARSER_STATE_TEXT, '}', 0},
+
+ {GRUB_PARSER_STATE_QVAR, GRUB_PARSER_STATE_QVARNAME2, '{', 0},
+ {GRUB_PARSER_STATE_QVAR, GRUB_PARSER_STATE_QVARNAME, 0, 1},
+ {GRUB_PARSER_STATE_QVARNAME, GRUB_PARSER_STATE_TEXT, '\"', 0},
+ {GRUB_PARSER_STATE_QVARNAME, GRUB_PARSER_STATE_DQUOTE, ' ', 1},
+ {GRUB_PARSER_STATE_QVARNAME, GRUB_PARSER_STATE_DQUOTE, '\t', 1},
+ {GRUB_PARSER_STATE_QVARNAME2, GRUB_PARSER_STATE_DQUOTE, '}', 0},
+
+ {0, 0, 0, 0}
+};
+
+
+/* Determines the state following STATE, determined by C. */
+grub_parser_state_t
+grub_parser_cmdline_state (grub_parser_state_t state, char c, char *result)
+{
+ struct grub_parser_state_transition *transition;
+ struct grub_parser_state_transition default_transition;
+
+ default_transition.to_state = state;
+ default_transition.keep_value = 1;
+
+ /* Look for a good translation. */
+ for (transition = state_transitions; transition->from_state; transition++)
+ {
+ if (transition->from_state != state)
+ continue;
+ /* An exact match was found, use it. */
+ if (transition->input == c)
+ break;
+
+ if (grub_isspace (transition->input) && !grub_isalpha (c)
+ && !grub_isdigit (c) && c != '_')
+ break;
+
+ /* A less perfect match was found, use this one if no exact
+ match can be found. */
+ if (transition->input == 0)
+ break;
+ }
+
+ if (!transition->from_state)
+ transition = &default_transition;
+
+ if (transition->keep_value)
+ *result = c;
+ else
+ *result = 0;
+ return transition->to_state;
+}
+
+
+/* Helper for grub_parser_split_cmdline. */
+static inline int
+check_varstate (grub_parser_state_t s)
+{
+ return (s == GRUB_PARSER_STATE_VARNAME
+ || s == GRUB_PARSER_STATE_VARNAME2
+ || s == GRUB_PARSER_STATE_QVARNAME
+ || s == GRUB_PARSER_STATE_QVARNAME2);
+}
+
+
+static grub_err_t
+add_var (grub_buffer_t varname, grub_buffer_t buf,
+ grub_parser_state_t state, grub_parser_state_t newstate)
+{
+ const char *val;
+
+ /* Check if a variable was being read in and the end of the name
+ was reached. */
+ if (!(check_varstate (state) && !check_varstate (newstate)))
+ return GRUB_ERR_NONE;
+
+ if (grub_buffer_append_char (varname, '\0') != GRUB_ERR_NONE)
+ return grub_errno;
+
+ val = grub_env_get ((const char *) grub_buffer_peek_data (varname));
+ grub_buffer_reset (varname);
+ if (!val)
+ return GRUB_ERR_NONE;
+
+ /* Insert the contents of the variable in the buffer. */
+ return grub_buffer_append_data (buf, val, grub_strlen (val));
+}
+
+static grub_err_t
+terminate_arg (grub_buffer_t buffer, int *argc)
+{
+ grub_size_t unread = grub_buffer_get_unread_bytes (buffer);
+
+ if (unread == 0)
+ return GRUB_ERR_NONE;
+
+ if (*(const char *) grub_buffer_peek_data_at (buffer, unread - 1) == '\0')
+ return GRUB_ERR_NONE;
+
+ if (grub_buffer_append_char (buffer, '\0') != GRUB_ERR_NONE)
+ return grub_errno;
+
+ (*argc)++;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+process_char (char c, grub_buffer_t buffer, grub_buffer_t varname,
+ grub_parser_state_t state, int *argc,
+ grub_parser_state_t *newstate)
+{
+ char use;
+
+ *newstate = grub_parser_cmdline_state (state, c, &use);
+
+ /*
+ * If a variable was being processed and this character does
+ * not describe the variable anymore, write the variable to
+ * the buffer.
+ */
+ if (add_var (varname, buffer, state, *newstate) != GRUB_ERR_NONE)
+ return grub_errno;
+
+ if (check_varstate (*newstate))
+ {
+ if (use)
+ return grub_buffer_append_char (varname, use);
+ }
+ else if (*newstate == GRUB_PARSER_STATE_TEXT &&
+ state != GRUB_PARSER_STATE_ESC && grub_isspace (use))
+ {
+ /*
+ * Don't add more than one argument if multiple
+ * spaces are used.
+ */
+ return terminate_arg (buffer, argc);
+ }
+ else if (use)
+ return grub_buffer_append_char (buffer, use);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_parser_split_cmdline (const char *cmdline,
+ grub_reader_getline_t getline, void *getline_data,
+ int *argc, char ***argv)
+{
+ grub_parser_state_t state = GRUB_PARSER_STATE_TEXT;
+ grub_buffer_t buffer, varname;
+ char *rd = (char *) cmdline;
+ char *rp = rd;
+ int i;
+
+ *argc = 0;
+ *argv = NULL;
+
+ buffer = grub_buffer_new (1024);
+ if (buffer == NULL)
+ return grub_errno;
+
+ varname = grub_buffer_new (200);
+ if (varname == NULL)
+ goto fail;
+
+ do
+ {
+ if (rp == NULL || *rp == '\0')
+ {
+ if (rd != cmdline)
+ {
+ grub_free (rd);
+ rd = rp = NULL;
+ }
+ if (getline)
+ {
+ getline (&rd, 1, getline_data);
+ rp = rd;
+ }
+ else
+ break;
+ }
+
+ if (!rd)
+ break;
+
+ for (; *rp != '\0'; rp++)
+ {
+ grub_parser_state_t newstate;
+
+ if (process_char (*rp, buffer, varname, state, argc,
+ &newstate) != GRUB_ERR_NONE)
+ goto fail;
+
+ state = newstate;
+ }
+ }
+ while (state != GRUB_PARSER_STATE_TEXT && !check_varstate (state));
+
+ /* A special case for when the last character was part of a
+ variable. */
+ if (add_var (varname, buffer, state, GRUB_PARSER_STATE_TEXT) != GRUB_ERR_NONE)
+ goto fail;
+
+ /* Ensure that the last argument is terminated. */
+ if (terminate_arg (buffer, argc) != GRUB_ERR_NONE)
+ goto fail;
+
+ /* If there are no args, then we're done. */
+ if (!*argc)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ goto out;
+ }
+
+ *argv = grub_calloc (*argc + 1, sizeof (char *));
+ if (!*argv)
+ goto fail;
+
+ /* The arguments are separated with 0's, setup argv so it points to
+ the right values. */
+ for (i = 0; i < *argc; i++)
+ {
+ char *arg;
+
+ if (i > 0)
+ {
+ if (grub_buffer_advance_read_pos (buffer, 1) != GRUB_ERR_NONE)
+ goto fail;
+ }
+
+ arg = (char *) grub_buffer_peek_data (buffer);
+ if (arg == NULL ||
+ grub_buffer_advance_read_pos (buffer, grub_strlen (arg)) != GRUB_ERR_NONE)
+ goto fail;
+
+ (*argv)[i] = arg;
+ }
+
+ /* Keep memory for the return values. */
+ grub_buffer_take_data (buffer);
+
+ grub_errno = GRUB_ERR_NONE;
+
+ out:
+ if (rd != cmdline)
+ grub_free (rd);
+ grub_buffer_free (buffer);
+ grub_buffer_free (varname);
+
+ return grub_errno;
+
+ fail:
+ grub_free (*argv);
+ goto out;
+}
+
+/* Helper for grub_parser_execute. */
+static grub_err_t
+grub_parser_execute_getline (char **line, int cont __attribute__ ((unused)),
+ void *data)
+{
+ char **source = data;
+ char *p;
+
+ if (!*source)
+ {
+ *line = 0;
+ return 0;
+ }
+
+ p = grub_strchr (*source, '\n');
+
+ if (p)
+ *line = grub_strndup (*source, p - *source);
+ else
+ *line = grub_strdup (*source);
+ *source = p ? p + 1 : 0;
+ return 0;
+}
+
+grub_err_t
+grub_parser_execute (char *source)
+{
+ while (source)
+ {
+ char *line;
+
+ 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/partition.c b/grub-core/kern/partition.c
new file mode 100644
index 0000000..3068c4d
--- /dev/null
+++ b/grub-core/kern/partition.c
@@ -0,0 +1,279 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/partition.h>
+#include <grub/disk.h>
+#include <grub/i18n.h>
+
+#ifdef GRUB_UTIL
+#include <grub/util/misc.h>
+#endif
+
+grub_partition_map_t grub_partition_map_list;
+
+/*
+ * Checks that disk->partition contains part. This function assumes that the
+ * start of part is relative to the start of disk->partition. Returns 1 if
+ * disk->partition is null.
+ */
+static int
+grub_partition_check_containment (const grub_disk_t disk,
+ const grub_partition_t part)
+{
+ if (disk->partition == NULL)
+ return 1;
+
+ if (part->start + part->len > disk->partition->len)
+ {
+ char *partname;
+
+ partname = grub_partition_get_name (disk->partition);
+ grub_dprintf ("partition", "sub-partition %s%d of (%s,%s) ends after parent.\n",
+ part->partmap->name, part->number + 1, disk->name, partname);
+#ifdef GRUB_UTIL
+ grub_util_warn (_("Discarding improperly nested partition (%s,%s,%s%d)"),
+ disk->name, partname, part->partmap->name, part->number + 1);
+#endif
+ grub_free (partname);
+
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Context for grub_partition_map_probe. */
+struct grub_partition_map_probe_ctx
+{
+ int partnum;
+ grub_partition_t p;
+};
+
+/* Helper for grub_partition_map_probe. */
+static int
+probe_iter (grub_disk_t dsk, const grub_partition_t partition, void *data)
+{
+ struct grub_partition_map_probe_ctx *ctx = data;
+
+ if (ctx->partnum != partition->number)
+ return 0;
+
+ if (!(grub_partition_check_containment (dsk, partition)))
+ return 0;
+
+ ctx->p = (grub_partition_t) grub_malloc (sizeof (*ctx->p));
+ if (! ctx->p)
+ return 1;
+
+ grub_memcpy (ctx->p, partition, sizeof (*ctx->p));
+ return 1;
+}
+
+static grub_partition_t
+grub_partition_map_probe (const grub_partition_map_t partmap,
+ grub_disk_t disk, int partnum)
+{
+ struct grub_partition_map_probe_ctx ctx = {
+ .partnum = partnum,
+ .p = 0
+ };
+
+ partmap->iterate (disk, probe_iter, &ctx);
+ if (grub_errno)
+ goto fail;
+
+ return ctx.p;
+
+ fail:
+ grub_free (ctx.p);
+ return 0;
+}
+
+grub_partition_t
+grub_partition_probe (struct grub_disk *disk, const char *str)
+{
+ grub_partition_t part;
+ grub_partition_t curpart = 0;
+ grub_partition_t tail;
+ const char *ptr;
+
+ if (str == NULL)
+ return 0;
+
+ part = tail = disk->partition;
+
+ for (ptr = str; *ptr;)
+ {
+ grub_partition_map_t partmap;
+ int num;
+ const char *partname, *partname_end;
+
+ partname = ptr;
+ while (*ptr && grub_isalpha (*ptr))
+ ptr++;
+ partname_end = ptr;
+ num = grub_strtoul (ptr, &ptr, 0) - 1;
+
+ curpart = 0;
+ /* Use the first partition map type found. */
+ FOR_PARTITION_MAPS(partmap)
+ {
+ if (partname_end != partname &&
+ (grub_strncmp (partmap->name, partname, partname_end - partname)
+ != 0 || partmap->name[partname_end - partname] != 0))
+ continue;
+
+ disk->partition = part;
+ curpart = grub_partition_map_probe (partmap, disk, num);
+ disk->partition = tail;
+ if (curpart)
+ break;
+
+ if (grub_errno == GRUB_ERR_BAD_PART_TABLE)
+ {
+ /* Continue to next partition map type. */
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ break;
+ }
+
+ if (! curpart)
+ {
+ while (part)
+ {
+ curpart = part->parent;
+ grub_free (part);
+ part = curpart;
+ }
+ return 0;
+ }
+ curpart->parent = part;
+ part = curpart;
+ if (! ptr || *ptr != ',')
+ break;
+ ptr++;
+ }
+
+ return part;
+}
+
+/* Context for grub_partition_iterate. */
+struct grub_partition_iterate_ctx
+{
+ int ret;
+ grub_partition_iterate_hook_t hook;
+ void *hook_data;
+};
+
+/* Helper for grub_partition_iterate. */
+static int
+part_iterate (grub_disk_t dsk, const grub_partition_t partition, void *data)
+{
+ struct grub_partition_iterate_ctx *ctx = data;
+ struct grub_partition p = *partition;
+
+ if (!(grub_partition_check_containment (dsk, partition)))
+ return 0;
+
+ p.parent = dsk->partition;
+ dsk->partition = 0;
+ if (ctx->hook (dsk, &p, ctx->hook_data))
+ {
+ ctx->ret = 1;
+ return 1;
+ }
+ if (p.start != 0)
+ {
+ const struct grub_partition_map *partmap;
+ dsk->partition = &p;
+ FOR_PARTITION_MAPS(partmap)
+ {
+ grub_err_t err;
+ err = partmap->iterate (dsk, part_iterate, ctx);
+ if (err)
+ grub_errno = GRUB_ERR_NONE;
+ if (ctx->ret)
+ break;
+ }
+ }
+ dsk->partition = p.parent;
+ return ctx->ret;
+}
+
+int
+grub_partition_iterate (struct grub_disk *disk,
+ grub_partition_iterate_hook_t hook, void *hook_data)
+{
+ struct grub_partition_iterate_ctx ctx = {
+ .ret = 0,
+ .hook = hook,
+ .hook_data = hook_data
+ };
+ const struct grub_partition_map *partmap;
+
+ FOR_PARTITION_MAPS(partmap)
+ {
+ grub_err_t err;
+ err = partmap->iterate (disk, part_iterate, &ctx);
+ if (err)
+ grub_errno = GRUB_ERR_NONE;
+ if (ctx.ret)
+ break;
+ }
+
+ return ctx.ret;
+}
+
+char *
+grub_partition_get_name (const grub_partition_t partition)
+{
+ char *out = 0, *ptr;
+ grub_size_t needlen = 0;
+ grub_partition_t part;
+ if (!partition)
+ return grub_strdup ("");
+ for (part = partition; part; part = part->parent)
+ /* Even on 64-bit machines this buffer is enough to hold
+ longest number. */
+ needlen += grub_strlen (part->partmap->name) + 1 + 27;
+ out = grub_malloc (needlen + 1);
+ if (!out)
+ return NULL;
+
+ ptr = out + needlen;
+ *ptr = 0;
+ for (part = partition; part; part = part->parent)
+ {
+ char buf[27];
+ grub_size_t len;
+ grub_snprintf (buf, sizeof (buf), "%d", part->number + 1);
+ len = grub_strlen (buf);
+ ptr -= len;
+ grub_memcpy (ptr, buf, len);
+ len = grub_strlen (part->partmap->name);
+ ptr -= len;
+ grub_memcpy (ptr, part->partmap->name, len);
+ *--ptr = ',';
+ }
+ grub_memmove (out, ptr + 1, out + needlen - ptr);
+ return out;
+}
diff --git a/grub-core/kern/powerpc/cache.S b/grub-core/kern/powerpc/cache.S
new file mode 100644
index 0000000..d85e68d
--- /dev/null
+++ b/grub-core/kern/powerpc/cache.S
@@ -0,0 +1,26 @@
+/* cache.S - Flush the processor cache for a specific region. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2007,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ .text
+
+ .align 2
+ .globl grub_arch_sync_caches
+grub_arch_sync_caches:
+#include "cache_flush.S"
+ blr
diff --git a/grub-core/kern/powerpc/cache_flush.S b/grub-core/kern/powerpc/cache_flush.S
new file mode 100644
index 0000000..1410f78
--- /dev/null
+++ b/grub-core/kern/powerpc/cache_flush.S
@@ -0,0 +1,43 @@
+/* cache.S - Flush the processor cache for a specific region. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2007,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#undef CACHE_LINE_BYTES
+#define CACHE_LINE_BYTES 32
+
+ /* `address' may not be CACHE_LINE_BYTES-aligned. */
+ andi. 6, 3, CACHE_LINE_BYTES - 1 /* Find the misalignment. */
+ add 4, 4, 6 /* Adjust `size' to compensate. */
+
+ /* Force the dcache lines to memory. */
+ li 5, 0
+1: dcbst 5, 3
+ addi 5, 5, CACHE_LINE_BYTES
+ cmpw 5, 4
+ blt 1b
+ sync /* Force all dcbsts to complete. */
+
+ /* Invalidate the icache lines. */
+ li 5, 0
+1: icbi 5, 3
+ addi 5, 5, CACHE_LINE_BYTES
+ cmpw 5, 4
+ blt 1b
+ sync /* Force all icbis to complete. */
+ isync /* Discard partially executed instructions that were
+ loaded from the invalid icache. */
diff --git a/grub-core/kern/powerpc/compiler-rt.S b/grub-core/kern/powerpc/compiler-rt.S
new file mode 100644
index 0000000..b3b912d
--- /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/powerpc/dl.c b/grub-core/kern/powerpc/dl.c
new file mode 100644
index 0000000..cdd61b3
--- /dev/null
+++ b/grub-core/kern/powerpc/dl.c
@@ -0,0 +1,169 @@
+/* dl.c - arch-dependent part of loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/i18n.h>
+
+/* Check if EHDR is a valid ELF header. */
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ Elf_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+ if (e->e_ident[EI_CLASS] != ELFCLASS32
+ || e->e_ident[EI_DATA] != ELFDATA2MSB
+ || e->e_machine != EM_PPC)
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
+
+/* For low-endian reverse lis and addr_high as well as ori and addr_low. */
+struct trampoline
+{
+ grub_uint32_t lis;
+ grub_uint32_t ori;
+ grub_uint32_t mtctr;
+ grub_uint32_t bctr;
+};
+
+static const struct trampoline trampoline_template =
+ {
+ 0x3d800000,
+ 0x618c0000,
+ 0x7d8903a6,
+ 0x4e800420,
+ };
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+grub_err_t
+grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
+ grub_size_t *got)
+{
+ const Elf_Ehdr *e = ehdr;
+ const Elf_Shdr *s;
+ unsigned i;
+
+ *tramp = 0;
+ *got = 0;
+
+ for (i = 0, s = (const Elf_Shdr *) ((const char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (const Elf_Shdr *) ((const char *) s + e->e_shentsize))
+ if (s->sh_type == SHT_RELA)
+ {
+ const Elf_Rela *rel, *max;
+
+ for (rel = (const Elf_Rela *) ((const char *) e + s->sh_offset),
+ max = rel + s->sh_size / s->sh_entsize;
+ rel < max;
+ rel++)
+ if (ELF_R_TYPE (rel->r_info) == GRUB_ELF_R_PPC_REL24
+ || ELF_R_TYPE (rel->r_info) == GRUB_ELF_R_PPC_PLTREL24)
+ (*tramp)++;
+
+ }
+
+ *tramp *= sizeof (struct trampoline);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Relocate symbols. */
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ Elf_Rela *rel, *max;
+
+ for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
+ max = (Elf_Rela *) ((char *) rel + s->sh_size);
+ rel < max;
+ rel = (Elf_Rela *) ((char *) rel + s->sh_entsize))
+ {
+ Elf_Word *addr;
+ Elf_Sym *sym;
+ grub_uint32_t value;
+
+ if (seg->size < rel->r_offset)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
+ sym = (Elf_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel->r_info));
+
+ /* On the PPC the value does not have an explicit
+ addend, add it. */
+ value = sym->st_value + rel->r_addend;
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case GRUB_ELF_R_PPC_ADDR16_LO:
+ *(Elf_Half *) addr = value;
+ break;
+
+ case GRUB_ELF_R_PPC_PLTREL24:
+ case GRUB_ELF_R_PPC_REL24:
+ {
+ Elf_Sword delta = value - (Elf_Word) addr;
+
+ if (delta << 6 >> 6 != delta)
+ {
+ struct trampoline *tptr = mod->trampptr;
+ grub_memcpy (tptr, &trampoline_template,
+ sizeof (*tptr));
+ delta = (grub_uint8_t *) tptr - (grub_uint8_t *) addr;
+ tptr->lis |= (((value) >> 16) & 0xffff);
+ tptr->ori |= ((value) & 0xffff);
+ mod->trampptr = tptr + 1;
+ }
+
+ if (delta << 6 >> 6 != delta)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "relocation overflow");
+ *addr = (*addr & 0xfc000003) | (delta & 0x3fffffc);
+ break;
+ }
+
+ case GRUB_ELF_R_PPC_ADDR16_HA:
+ *(Elf_Half *) addr = (value + 0x8000) >> 16;
+ break;
+
+ case GRUB_ELF_R_PPC_ADDR32:
+ *addr = value;
+ break;
+
+ case GRUB_ELF_R_PPC_REL32:
+ *addr = value - (Elf_Word) addr;
+ break;
+
+ default:
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%x is not implemented yet"),
+ ELF_R_TYPE (rel->r_info));
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/powerpc/ieee1275/startup.S b/grub-core/kern/powerpc/ieee1275/startup.S
new file mode 100644
index 0000000..21c884b
--- /dev/null
+++ b/grub-core/kern/powerpc/ieee1275/startup.S
@@ -0,0 +1,67 @@
+/* startup.S - Startup code for the PowerPC. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/offsets.h>
+
+.extern __bss_start
+.extern _end
+
+ .text
+ .align 2
+ .globl start, _start
+start:
+_start:
+ li 2, 0
+ li 13, 0
+
+ /* Stage1 won't zero BSS for us. In other cases, why not do it again? */
+ lis 6, (__bss_start - 4)@h
+ ori 6, 6, (__bss_start - 4)@l
+
+2: stb 2, 4(6)
+ addi 6, 6, 1
+ andi. 7, 6, 3
+ cmpi 0, 1, 7, 0
+ bne 2b
+
+ lis 7, (_end - 4)@h
+ ori 7, 7, (_end - 4)@l
+ subf 7, 6, 7
+ subi 8, 7, 1
+ andi. 8, 8, 3
+ addi 8, 8, 1
+ sub 7, 7, 8
+
+ srwi 7, 7, 2 /* We store 4 bytes at a time. */
+ mtctr 7
+2: stwu 2, 4(6) /* We know r2 is already 0 from above. */
+ bdnz 2b
+
+ mtctr 8
+2: stb 2, 4(6) /* We know r2 is already 0 from above. */
+ addi 6, 6, 1
+ bdnz 2b
+
+ /* Store r5 in grub_ieee1275_entry_fn. */
+ lis 9, grub_ieee1275_entry_fn@ha
+ stw 5, grub_ieee1275_entry_fn@l(9)
+
+ bl grub_main
+1: b 1b
diff --git a/grub-core/kern/rescue_parser.c b/grub-core/kern/rescue_parser.c
new file mode 100644
index 0000000..6338366
--- /dev/null
+++ b/grub-core/kern/rescue_parser.c
@@ -0,0 +1,84 @@
+/* rescue_parser.c - rescue mode parser */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/parser.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+grub_err_t
+grub_rescue_parse_line (char *line,
+ grub_reader_getline_t getline, void *getline_data)
+{
+ char *name;
+ int n;
+ grub_command_t cmd;
+ char **args;
+
+ if (grub_parser_split_cmdline (line, getline, getline_data, &n, &args)
+ || n < 0)
+ return grub_errno;
+
+ if (n == 0)
+ return GRUB_ERR_NONE;
+
+ /* In case of an assignment set the environment accordingly
+ instead of calling a function. */
+ if (n == 1)
+ {
+ char *val = grub_strchr (args[0], '=');
+
+ if (val)
+ {
+ val[0] = 0;
+ grub_env_set (args[0], val + 1);
+ val[0] = '=';
+ goto quit;
+ }
+ }
+
+ /* Get the command name. */
+ name = args[0];
+
+ /* If nothing is specified, restart. */
+ if (*name == '\0')
+ goto quit;
+
+ cmd = grub_command_find (name);
+ if (cmd)
+ {
+ (cmd->func) (cmd, n - 1, &args[1]);
+ }
+ else
+ {
+ grub_printf_ (N_("Unknown command `%s'.\n"), name);
+ if (grub_command_find ("help"))
+ grub_printf ("Try `help' for usage\n");
+ }
+
+ quit:
+ /* Arguments are returned in single memory chunk separated by zeroes */
+ grub_free (args[0]);
+ grub_free (args);
+
+ return grub_errno;
+}
diff --git a/grub-core/kern/rescue_reader.c b/grub-core/kern/rescue_reader.c
new file mode 100644
index 0000000..dcd7d44
--- /dev/null
+++ b/grub-core/kern/rescue_reader.c
@@ -0,0 +1,98 @@
+/* rescue_reader.c - rescue mode reader */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/reader.h>
+#include <grub/parser.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/mm.h>
+
+#define GRUB_RESCUE_BUF_SIZE 256
+
+static char linebuf[GRUB_RESCUE_BUF_SIZE];
+
+/* Prompt to input a command and read the line. */
+static grub_err_t
+grub_rescue_read_line (char **line, int cont,
+ void *data __attribute__ ((unused)))
+{
+ int c;
+ int pos = 0;
+ char str[4];
+
+ grub_printf ((cont) ? "> " : "grub rescue> ");
+ grub_memset (linebuf, 0, GRUB_RESCUE_BUF_SIZE);
+
+ while ((c = grub_getkey ()) != '\n' && c != '\r')
+ {
+ if (grub_isprint (c))
+ {
+ if (pos < GRUB_RESCUE_BUF_SIZE - 1)
+ {
+ str[0] = c;
+ str[1] = 0;
+ linebuf[pos++] = c;
+ grub_xputs (str);
+ }
+ }
+ else if (c == '\b')
+ {
+ if (pos > 0)
+ {
+ str[0] = c;
+ str[1] = ' ';
+ str[2] = c;
+ str[3] = 0;
+ linebuf[--pos] = 0;
+ grub_xputs (str);
+ }
+ }
+ grub_refresh ();
+ }
+
+ grub_xputs ("\n");
+ grub_refresh ();
+
+ *line = grub_strdup (linebuf);
+
+ return 0;
+}
+
+void __attribute__ ((noreturn))
+grub_rescue_run (void)
+{
+ grub_printf ("Entering rescue mode...\n");
+
+ while (1)
+ {
+ char *line;
+
+ /* Print an error, if any. */
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+
+ grub_rescue_read_line (&line, 0, NULL);
+ if (! line || line[0] == '\0')
+ continue;
+
+ grub_rescue_parse_line (line, grub_rescue_read_line, NULL);
+ grub_free (line);
+ }
+}
diff --git a/grub-core/kern/riscv/cache.c b/grub-core/kern/riscv/cache.c
new file mode 100644
index 0000000..47777a0
--- /dev/null
+++ b/grub-core/kern/riscv/cache.c
@@ -0,0 +1,63 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/cache.h>
+#include <grub/misc.h>
+
+static grub_int64_t dlinesz;
+static grub_int64_t ilinesz;
+
+/* Prototypes for asm functions. */
+void grub_arch_clean_dcache_range (grub_addr_t beg, grub_addr_t end,
+ grub_size_t line_size);
+void grub_arch_invalidate_icache_range (grub_addr_t beg, grub_addr_t end,
+ grub_size_t line_size);
+
+static void
+probe_caches (void)
+{
+ /* TODO */
+ dlinesz = 32;
+ ilinesz = 32;
+}
+
+void
+grub_arch_sync_caches (void *address, grub_size_t len)
+{
+ grub_size_t start, end, max_align;
+
+ if (dlinesz == 0)
+ probe_caches();
+ if (dlinesz == 0)
+ grub_fatal ("Unknown cache line size!");
+
+ max_align = dlinesz > ilinesz ? dlinesz : ilinesz;
+
+ start = ALIGN_DOWN ((grub_size_t) address, max_align);
+ end = ALIGN_UP ((grub_size_t) address + len, max_align);
+
+ grub_arch_clean_dcache_range (start, end, dlinesz);
+ grub_arch_invalidate_icache_range (start, end, ilinesz);
+}
+
+void
+grub_arch_sync_dma_caches (volatile void *address __attribute__((unused)),
+ grub_size_t len __attribute__((unused)))
+{
+ /* DMA incoherent devices not supported yet */
+}
diff --git a/grub-core/kern/riscv/cache_flush.S b/grub-core/kern/riscv/cache_flush.S
new file mode 100644
index 0000000..41de6e4
--- /dev/null
+++ b/grub-core/kern/riscv/cache_flush.S
@@ -0,0 +1,44 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+
+ .file "cache_flush.S"
+ .text
+
+/*
+ * Simple cache maintenance functions
+ */
+
+/*
+ * a0 - *beg (inclusive)
+ * a1 - *end (exclusive)
+ * a2 - line size
+*/
+FUNCTION(grub_arch_clean_dcache_range)
+ /* TODO */
+ ret
+
+/*
+ * a0 - *beg (inclusive)
+ * a1 - *end (exclusive)
+ * a2 - line size
+ */
+FUNCTION(grub_arch_invalidate_icache_range)
+ fence.i
+ ret
diff --git a/grub-core/kern/riscv/dl.c b/grub-core/kern/riscv/dl.c
new file mode 100644
index 0000000..f26b12a
--- /dev/null
+++ b/grub-core/kern/riscv/dl.c
@@ -0,0 +1,345 @@
+/* dl.c - arch-dependent part of loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+
+/*
+ * Instructions and instruction encoding are documented in the RISC-V
+ * specification. This file is based on version 2.2:
+ *
+ * https://github.com/riscv/riscv-isa-manual/blob/master/release/riscv-spec-v2.2.pdf
+ */
+#define LDR 0x58000050
+#define BR 0xd61f0200
+
+/*
+ * Check if EHDR is a valid ELF header.
+ */
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ Elf_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+ if (e->e_ident[EI_DATA] != ELFDATA2LSB || e->e_machine != EM_RISCV)
+ return grub_error (GRUB_ERR_BAD_OS,
+ N_("invalid arch-dependent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+/* Relocate symbols. */
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ Elf_Rel *rel, *max;
+
+ for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
+ max = (Elf_Rel *) ((char *) rel + s->sh_size);
+ rel < max;
+ rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
+ {
+ Elf_Sym *sym;
+ void *place;
+ grub_size_t sym_addr;
+
+ if (rel->r_offset >= seg->size)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ sym = (Elf_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel->r_info));
+
+ sym_addr = sym->st_value;
+ if (s->sh_type == SHT_RELA)
+ sym_addr += ((Elf_Rela *) rel)->r_addend;
+
+ place = (void *) ((grub_addr_t) seg->addr + rel->r_offset);
+
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case R_RISCV_32:
+ {
+ grub_uint32_t *abs_place = place;
+
+ grub_dprintf ("dl", " reloc_abs32 %p => 0x%016llx\n",
+ place, (unsigned long long) sym_addr);
+
+ *abs_place = (grub_uint32_t) sym_addr;
+ }
+ break;
+ case R_RISCV_64:
+ {
+ grub_size_t *abs_place = place;
+
+ grub_dprintf ("dl", " reloc_abs64 %p => 0x%016llx\n",
+ place, (unsigned long long) sym_addr);
+
+ *abs_place = (grub_size_t) sym_addr;
+ }
+ break;
+
+ case R_RISCV_ADD8:
+ {
+ grub_uint8_t *abs_place = place;
+
+ *abs_place += (grub_uint8_t) sym_addr;
+ }
+ break;
+ case R_RISCV_ADD16:
+ {
+ grub_uint16_t *abs_place = place;
+
+ *abs_place += (grub_uint16_t) sym_addr;
+ }
+ break;
+ case R_RISCV_ADD32:
+ {
+ grub_uint32_t *abs_place = place;
+
+ *abs_place += (grub_uint32_t) sym_addr;
+ }
+ break;
+ case R_RISCV_ADD64:
+ {
+ grub_size_t *abs_place = place;
+
+ *abs_place += (grub_size_t) sym_addr;
+ }
+ break;
+
+ case R_RISCV_SUB8:
+ {
+ grub_uint8_t *abs_place = place;
+
+ *abs_place -= (grub_uint8_t) sym_addr;
+ }
+ break;
+ case R_RISCV_SUB16:
+ {
+ grub_uint16_t *abs_place = place;
+
+ *abs_place -= (grub_uint16_t) sym_addr;
+ }
+ break;
+ case R_RISCV_SUB32:
+ {
+ grub_uint32_t *abs_place = place;
+
+ *abs_place -= (grub_uint32_t) sym_addr;
+ }
+ break;
+ case R_RISCV_SUB64:
+ {
+ grub_size_t *abs_place = place;
+
+ *abs_place -= (grub_size_t) sym_addr;
+ }
+ break;
+
+ case R_RISCV_BRANCH:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_uint32_t imm12 = (off & 0x1000) << (31 - 12);
+ grub_uint32_t imm11 = (off & 0x800) >> (11 - 7);
+ grub_uint32_t imm10_5 = (off & 0x7e0) << (30 - 10);
+ grub_uint32_t imm4_1 = (off & 0x1e) << (11 - 4);
+ *abs_place = (*abs_place & 0x1fff07f)
+ | imm12 | imm11 | imm10_5 | imm4_1;
+ }
+ break;
+
+ case R_RISCV_JAL:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_uint32_t imm20 = (off & 0x100000) << (31 - 20);
+ grub_uint32_t imm19_12 = (off & 0xff000);
+ grub_uint32_t imm11 = (off & 0x800) << (20 - 11);
+ grub_uint32_t imm10_1 = (off & 0x7fe) << (30 - 10);
+ *abs_place = (*abs_place & 0xfff)
+ | imm20 | imm19_12 | imm11 | imm10_1;
+ }
+ break;
+
+ case R_RISCV_CALL:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_uint32_t hi20, lo12;
+
+ if (off != (grub_int32_t) off)
+ return grub_error (GRUB_ERR_BAD_MODULE, "relocation overflow");
+
+ hi20 = (off + 0x800) & 0xfffff000;
+ lo12 = (off - hi20) & 0xfff;
+ abs_place[0] = (abs_place[0] & 0xfff) | hi20;
+ abs_place[1] = (abs_place[1] & 0xfffff) | (lo12 << 20);
+ }
+ break;
+
+ case R_RISCV_RVC_BRANCH:
+ {
+ grub_uint16_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_uint16_t imm8 = (off & 0x100) << (12 - 8);
+ grub_uint16_t imm7_6 = (off & 0xc0) >> (6 - 5);
+ grub_uint16_t imm5 = (off & 0x20) >> (5 - 2);
+ grub_uint16_t imm4_3 = (off & 0x18) << (12 - 5);
+ grub_uint16_t imm2_1 = (off & 0x6) << (12 - 10);
+ *abs_place = (*abs_place & 0xe383)
+ | imm8 | imm7_6 | imm5 | imm4_3 | imm2_1;
+ }
+ break;
+
+ case R_RISCV_RVC_JUMP:
+ {
+ grub_uint16_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_uint16_t imm11 = (off & 0x800) << (12 - 11);
+ grub_uint16_t imm10 = (off & 0x400) >> (10 - 8);
+ grub_uint16_t imm9_8 = (off & 0x300) << (12 - 11);
+ grub_uint16_t imm7 = (off & 0x80) >> (7 - 6);
+ grub_uint16_t imm6 = (off & 0x40) << (12 - 11);
+ grub_uint16_t imm5 = (off & 0x20) >> (5 - 2);
+ grub_uint16_t imm4 = (off & 0x10) << (12 - 5);
+ grub_uint16_t imm3_1 = (off & 0xe) << (12 - 10);
+ *abs_place = ((*abs_place & 0xe003)
+ | imm11 | imm10 | imm9_8 | imm7 | imm6
+ | imm5 | imm4 | imm3_1);
+ }
+ break;
+
+ case R_RISCV_PCREL_HI20:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_int32_t hi20;
+
+ if (off != (grub_int32_t)off)
+ return grub_error (GRUB_ERR_BAD_MODULE, "relocation overflow");
+
+ hi20 = (off + 0x800) & 0xfffff000;
+ *abs_place = (*abs_place & 0xfff) | hi20;
+ }
+ break;
+
+ case R_RISCV_PCREL_LO12_I:
+ case R_RISCV_PCREL_LO12_S:
+ {
+ grub_uint32_t *t32 = place;
+ Elf_Rela *rel2;
+ /* Search backwards for matching HI20 reloc. */
+ for (rel2 = (Elf_Rela *) ((char *) rel - s->sh_entsize);
+ (unsigned long)rel2 >= ((unsigned long)ehdr + s->sh_offset);
+ rel2 = (Elf_Rela *) ((char *) rel2 - s->sh_entsize))
+ {
+ Elf_Addr rel2_info;
+ Elf_Addr rel2_offset;
+ Elf_Addr rel2_sym_addr;
+ Elf_Addr rel2_loc;
+ grub_ssize_t rel2_off;
+ grub_ssize_t off;
+ Elf_Sym *sym2;
+
+ rel2_offset = rel2->r_offset;
+ rel2_info = rel2->r_info;
+ rel2_loc = (grub_addr_t) seg->addr + rel2_offset;
+
+ if (ELF_R_TYPE (rel2_info) == R_RISCV_PCREL_HI20
+ && rel2_loc == sym_addr)
+ {
+ sym2 = (Elf_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel2->r_info));
+ rel2_sym_addr = sym2->st_value;
+ if (s->sh_type == SHT_RELA)
+ rel2_sym_addr += ((Elf_Rela *) rel2)->r_addend;
+
+ rel2_off = rel2_sym_addr - rel2_loc;
+ off = rel2_off - ((rel2_off + 0x800) & 0xfffff000);
+
+ if (ELF_R_TYPE (rel->r_info) == R_RISCV_PCREL_LO12_I)
+ *t32 = (*t32 & 0xfffff) | (off & 0xfff) << 20;
+ else
+ {
+ grub_uint32_t imm11_5 = (off & 0xfe0) << (31 - 11);
+ grub_uint32_t imm4_0 = (off & 0x1f) << (11 - 4);
+ *t32 = (*t32 & 0x1fff07f) | imm11_5 | imm4_0;
+ }
+ break;
+ }
+ }
+ if ((unsigned long)rel2 < ((unsigned long)ehdr + s->sh_offset))
+ return grub_error (GRUB_ERR_BAD_MODULE, "cannot find matching HI20 relocation");
+ }
+ break;
+
+ case R_RISCV_HI20:
+ {
+ grub_uint32_t *abs_place = place;
+ *abs_place = (*abs_place & 0xfff) |
+ (((grub_int32_t) sym_addr + 0x800) & 0xfffff000);
+ }
+ break;
+
+ case R_RISCV_LO12_I:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_int32_t lo12 = (grub_int32_t) sym_addr -
+ (((grub_int32_t) sym_addr + 0x800) & 0xfffff000);
+ *abs_place = (*abs_place & 0xfffff) | ((lo12 & 0xfff) << 20);
+ }
+ break;
+
+ case R_RISCV_LO12_S:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_int32_t lo12 = (grub_int32_t) sym_addr -
+ (((grub_int32_t) sym_addr + 0x800) & 0xfffff000);
+ grub_uint32_t imm11_5 = (lo12 & 0xfe0) << (31 - 11);
+ grub_uint32_t imm4_0 = (lo12 & 0x1f) << (11 - 4);
+ *abs_place = (*abs_place & 0x1fff07f) | imm11_5 | imm4_0;
+ }
+ break;
+
+ case R_RISCV_RELAX:
+ break;
+ default:
+ {
+ char rel_info[17]; /* log16(2^64) = 16, plus NUL. */
+
+ grub_snprintf (rel_info, sizeof (rel_info) - 1, "%" PRIxGRUB_UINT64_T,
+ (grub_uint64_t) ELF_R_TYPE (rel->r_info));
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%s is not implemented yet"), rel_info);
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/riscv/efi/init.c b/grub-core/kern/riscv/efi/init.c
new file mode 100644
index 0000000..38795fe
--- /dev/null
+++ b/grub-core/kern/riscv/efi/init.c
@@ -0,0 +1,79 @@
+/* init.c - initialize a riscv-based EFI system */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/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;
+
+#if __riscv_xlen == 64
+ asm volatile ("rdcycle %0" : "=r" (tmr));
+#else
+ grub_uint32_t lo, hi, tmp;
+ asm volatile (
+ "1:\n"
+ "rdcycleh %0\n"
+ "rdcycle %1\n"
+ "rdcycleh %2\n"
+ "bne %0, %2, 1b"
+ : "=&r" (hi), "=&r" (lo), "=&r" (tmp));
+ tmr = ((grub_uint64_t)hi << 32) | lo;
+#endif
+
+ return tmr / timer_frequency_in_khz;
+}
+
+void
+grub_machine_init (void)
+{
+ grub_uint64_t time_before, time_after;
+
+ grub_efi_init ();
+
+ /* Calculate timer frequency */
+ timer_frequency_in_khz = 1;
+ time_before = grub_efi_get_time_ms();
+ grub_efi_stall(1000);
+ time_after = grub_efi_get_time_ms();
+ timer_frequency_in_khz = time_after - time_before;
+
+ 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 ();
+
+ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY))
+ grub_efi_memory_fini ();
+}
diff --git a/grub-core/kern/riscv/efi/startup.S b/grub-core/kern/riscv/efi/startup.S
new file mode 100644
index 0000000..f2a7b2b
--- /dev/null
+++ b/grub-core/kern/riscv/efi/startup.S
@@ -0,0 +1,48 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+
+#if __riscv_xlen == 64
+#define sl sd
+#define ll ld
+#else
+#define sl sw
+#define ll lw
+#endif
+
+
+ .file "startup.S"
+ .text
+FUNCTION(_start)
+ /*
+ * EFI_SYSTEM_TABLE and EFI_HANDLE are passed in a1/a0.
+ */
+
+ ll a2, efi_image_handle_val
+ sl a0, 0(a2)
+ ll a2, efi_system_table_val
+ sl a1, 0(a2)
+ ll a2, grub_main_val
+ jr a2
+grub_main_val:
+ .quad EXT_C(grub_main)
+efi_system_table_val:
+ .quad EXT_C(grub_efi_system_table)
+efi_image_handle_val:
+ .quad EXT_C(grub_efi_image_handle)
diff --git a/grub-core/kern/sparc64/cache.S b/grub-core/kern/sparc64/cache.S
new file mode 100644
index 0000000..1a16add
--- /dev/null
+++ b/grub-core/kern/sparc64/cache.S
@@ -0,0 +1,41 @@
+/* cache.S - Flush the processor cache for a specific region. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+
+ .file "cache.S"
+
+ .text
+
+/*
+ * void grub_arch_sync_caches (void *address, grub_size_t len)
+ */
+FUNCTION(grub_arch_sync_caches)
+ brz,pn %o1, 2f
+ add %o0, %o1, %o1
+ add %o1, 7, %o1
+ andn %o1, 7, %o1
+ andn %o0, 7, %o0
+ sub %o1, %o0, %o1
+1: subcc %o1, 8, %o1
+ bne,pt %icc, 1b
+ flush %o0 + %o1
+2: retl
+ nop
+
diff --git a/grub-core/kern/sparc64/dl.c b/grub-core/kern/sparc64/dl.c
new file mode 100644
index 0000000..f3d9601
--- /dev/null
+++ b/grub-core/kern/sparc64/dl.c
@@ -0,0 +1,191 @@
+/* dl.c - arch-dependent part of loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/i18n.h>
+
+/* Check if EHDR is a valid ELF header. */
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ Elf_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+ if (e->e_ident[EI_CLASS] != ELFCLASS64
+ || e->e_ident[EI_DATA] != ELFDATA2MSB
+ || e->e_machine != EM_SPARCV9)
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+struct trampoline
+{
+ grub_uint8_t code[0x28];
+ grub_uint64_t addr;
+};
+
+static const grub_uint8_t trampoline_code[0x28] =
+{
+ /* 0: */ 0x82, 0x10, 0x00, 0x0f, /* mov %o7, %g1 */
+ /* 4: */ 0x40, 0x00, 0x00, 0x02, /* call 0xc */
+ /* 8: */ 0x01, 0x00, 0x00, 0x00, /* nop */
+ /* c: */ 0x9e, 0x1b, 0xc0, 0x01, /* xor %o7, %g1, %o7 */
+ /* 10: */ 0x82, 0x18, 0x40, 0x0f, /* xor %g1, %o7, %g1 */
+ /* 14: */ 0x9e, 0x1b, 0xc0, 0x01, /* xor %o7, %g1, %o7 */
+ /* 18: */ 0xc2, 0x58, 0x60, 0x24, /* ldx [ %g1 + 0x24 ], %g1 */
+ /* 1c: */ 0x81, 0xc0, 0x40, 0x00, /* jmp %g1 */
+ /* 20: */ 0x01, 0x00, 0x00, 0x00, /* nop */
+ /* 24: */ 0x01, 0x00, 0x00, 0x00, /* nop */
+};
+
+grub_err_t
+grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
+ grub_size_t *got)
+{
+ const Elf_Ehdr *e = ehdr;
+ const Elf_Shdr *s;
+ unsigned i;
+
+ *tramp = 0;
+ *got = 0;
+
+ for (i = 0, s = (const Elf_Shdr *) ((grub_addr_t) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (const Elf_Shdr *) ((grub_addr_t) s + e->e_shentsize))
+ if (s->sh_type == SHT_REL || s->sh_type == SHT_RELA)
+ {
+ 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 = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_entsize))
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case R_SPARC_WDISP30:
+ {
+ *tramp += sizeof (struct trampoline);
+ break;
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/* Relocate symbols. */
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ Elf_Rela *rel, *max;
+
+ for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
+ max = (Elf_Rela *) ((char *) rel + s->sh_size);
+ rel < max;
+ rel = (Elf_Rela *) ((char *) rel + s->sh_entsize))
+ {
+ Elf_Word *addr;
+ Elf_Sym *sym;
+ Elf_Addr value;
+
+ if (seg->size < rel->r_offset)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
+ sym = (Elf_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel->r_info));
+
+ value = sym->st_value + rel->r_addend;
+ switch (ELF_R_TYPE (rel->r_info) & 0xff)
+ {
+ case R_SPARC_32: /* 3 V-word32 */
+ if (value & 0xFFFFFFFF00000000)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "address out of 32 bits range");
+ *addr = value;
+ break;
+ case R_SPARC_WDISP30: /* 7 V-disp30 */
+ if (((value - (Elf_Addr) addr) & 0xFFFFFFFF00000000) &&
+ (((value - (Elf_Addr) addr) & 0xFFFFFFFF00000000)
+ != 0xFFFFFFFF00000000))
+ {
+ struct trampoline *tp = mod->trampptr;
+ mod->trampptr = tp + 1;
+ grub_memcpy (tp->code, trampoline_code, sizeof (tp->code));
+ tp->addr = value;
+ value = (Elf_Addr) tp;
+ }
+
+ if (((value - (Elf_Addr) addr) & 0xFFFFFFFF00000000) &&
+ (((value - (Elf_Addr) addr) & 0xFFFFFFFF00000000)
+ != 0xFFFFFFFF00000000))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "displacement out of 30 bits range");
+ *addr = (*addr & 0xC0000000) |
+ (((grub_int32_t) ((value - (Elf_Addr) addr) >> 2)) &
+ 0x3FFFFFFF);
+ break;
+ case R_SPARC_HH22: /* 9 V-imm22 */
+ *addr = (*addr & 0xFFC00000) | ((value >> 42) & 0x3FFFFF);
+ break;
+ case R_SPARC_HM10: /* 12 T-simm13 */
+ *addr = (*addr & 0xFFFFFC00) | ((value >> 32) & 0x3FF);
+ break;
+ case R_SPARC_HI22: /* 9 V-imm22 */
+ if (value >> 32)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "address out of 32 bits range");
+ /* Fallthrough. */
+ case R_SPARC_LM22:
+ *addr = (*addr & 0xFFC00000) | ((value >> 10) & 0x3FFFFF);
+ break;
+ case R_SPARC_LO10: /* 12 T-simm13 */
+ *addr = (*addr & 0xFFFFFC00) | (value & 0x3FF);
+ break;
+ case R_SPARC_64: /* 32 V-xwords64 */
+ *(Elf_Xword *) addr = value;
+ break;
+ case R_SPARC_OLO10:
+ *addr = (*addr & ~0x1fff)
+ | (((value & 0x3ff) +
+ (ELF_R_TYPE (rel->r_info) >> 8))
+ & 0x1fff);
+ break;
+ default:
+ {
+ char rel_info[17]; /* log16(2^64) = 16, plus NUL. */
+
+ grub_snprintf (rel_info, sizeof (rel_info) - 1, "%" PRIxGRUB_UINT64_T,
+ ELF_R_TYPE (rel->r_info));
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%s is not implemented yet"), rel_info);
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/sparc64/ieee1275/crt0.S b/grub-core/kern/sparc64/ieee1275/crt0.S
new file mode 100644
index 0000000..03b916f
--- /dev/null
+++ b/grub-core/kern/sparc64/ieee1275/crt0.S
@@ -0,0 +1,104 @@
+/* crt0.S - Startup code for the Sparc64. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <grub/symbol.h>
+#include <grub/machine/kernel.h>
+#include <grub/offsets.h>
+
+ .text
+ .align 4
+ .globl _start
+_start:
+ ba codestart
+ mov %o4, %o0
+
+ .org GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
+
+VARIABLE(grub_total_module_size)
+ .word 0
+
+codestart:
+ /* Copy the modules past the end of the kernel image.
+ * They are currently sitting in the BSS.
+ */
+ sethi %hi(__bss_start + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o2
+ or %o2, %lo(__bss_start + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o2
+ srl %o2, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o2
+ sll %o2, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o2
+ sethi %hi(_end + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o3
+ or %o3, %lo(_end + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o3
+ srl %o3, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o3
+ sll %o3, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o3
+ sethi %hi(grub_total_module_size), %o4
+ lduw [%o4 + %lo(grub_total_module_size)], %o4
+
+ add %o2, %o4, %o2
+ add %o3, %o4, %o3
+
+ /* Save ieee1275 stack for future use by booter. */
+ mov %o6, %o1
+ /* Our future stack. */
+ sethi %hi(GRUB_KERNEL_MACHINE_STACK_SIZE), %o5
+ or %o5, %lo(GRUB_KERNEL_MACHINE_STACK_SIZE), %o5
+ add %o3, %o5, %o6
+ and %o6, ~0xff, %o6
+ sub %o6, 2047, %o6
+
+ sub %o2, 4, %o2
+ sub %o3, 4, %o3
+1: lduw [%o2], %o5
+ stw %o5, [%o3]
+ subcc %o4, 4, %o4
+ sub %o2, 4, %o2
+ bne,pt %icc, 1b
+ sub %o3, 4, %o3
+
+ /* Now it's safe to clear out the BSS. */
+ sethi %hi(__bss_start), %o2
+ or %o2, %lo(__bss_start), %o2
+1: stb %g0, [%o2]
+ add %o2, 1, %o2
+ and %o2, 7, %o3
+ brnz %o3, 1b
+ nop
+
+ sethi %hi(_end - 1), %o3
+ or %o3, %lo(_end - 1), %o3
+ srl %o3, 3, %o3
+ sll %o3, 3, %o3
+1: stx %g0, [%o2]
+ add %o2, 8, %o2
+ cmp %o2, %o3
+ blt,pt %xcc, 1b
+ nop
+
+ sethi %hi(_end), %o3
+ or %o3, %lo(_end), %o3
+1: stb %g0, [%o2]
+ add %o2, 1, %o2
+ cmp %o2, %o3
+ blt,pt %xcc, 1b
+ nop
+
+ sethi %hi(grub_ieee1275_original_stack), %o2
+ stx %o1, [%o2 + %lo(grub_ieee1275_original_stack)]
+ sethi %hi(grub_ieee1275_entry_fn), %o2
+ call grub_main
+ stx %o0, [%o2 + %lo(grub_ieee1275_entry_fn)]
+1: ba,a 1b
+ nop
diff --git a/grub-core/kern/sparc64/ieee1275/ieee1275.c b/grub-core/kern/sparc64/ieee1275/ieee1275.c
new file mode 100644
index 0000000..5a59aaf
--- /dev/null
+++ b/grub-core/kern/sparc64/ieee1275/ieee1275.c
@@ -0,0 +1,147 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/types.h>
+
+/* Sun specific ieee1275 interfaces used by GRUB. */
+
+int
+grub_ieee1275_claim_vaddr (grub_addr_t vaddr, grub_size_t size)
+{
+ struct claim_vaddr_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t align;
+ grub_ieee1275_cell_t size;
+ grub_ieee1275_cell_t virt;
+ grub_ieee1275_cell_t catch_result;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 5, 2);
+ args.method = (grub_ieee1275_cell_t) "claim";
+ args.ihandle = grub_ieee1275_mmu;
+ args.align = 0;
+ args.size = size;
+ args.virt = vaddr;
+ args.catch_result = (grub_ieee1275_cell_t) -1;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ return args.catch_result;
+}
+
+int
+grub_ieee1275_alloc_physmem (grub_addr_t *paddr, grub_size_t size,
+ grub_uint32_t align)
+{
+ grub_uint32_t memory_ihandle;
+ struct alloc_physmem_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t align;
+ grub_ieee1275_cell_t size;
+ grub_ieee1275_cell_t catch_result;
+ grub_ieee1275_cell_t phys_high;
+ grub_ieee1275_cell_t phys_low;
+ }
+ args;
+ grub_ssize_t actual = 0;
+
+ grub_ieee1275_get_property (grub_ieee1275_chosen, "memory",
+ &memory_ihandle, sizeof (memory_ihandle),
+ &actual);
+ if (actual != sizeof (memory_ihandle))
+ return -1;
+
+ if (!align)
+ align = 1;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 3);
+ args.method = (grub_ieee1275_cell_t) "claim";
+ args.ihandle = memory_ihandle;
+ args.align = (align ? align : 1);
+ args.size = size;
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+
+ *paddr = args.phys_low;
+
+ return args.catch_result;
+}
+
+grub_uint64_t
+grub_ieee1275_num_blocks (grub_ieee1275_ihandle_t ihandle)
+{
+ struct nblocks_args_ieee1275
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t catch_result;
+ grub_ieee1275_cell_t blocks;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2);
+ args.method = (grub_ieee1275_cell_t) "#blocks";
+ args.ihandle = ihandle;
+ args.catch_result = 1;
+
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result != 0))
+ return -1;
+
+ /*
+ * If the number of blocks exceeds the range of an unsigned number,
+ * return 0 to alert the caller to try the #blocks64 command.
+ */
+ if (args.blocks >= 0xffffffffULL)
+ return 0;
+
+ return args.blocks;
+}
+
+grub_uint64_t
+grub_ieee1275_num_blocks64 (grub_ieee1275_ihandle_t ihandle)
+{
+ struct nblocks_args_ieee1275
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t catch_result;
+ grub_ieee1275_cell_t hi_blocks;
+ grub_ieee1275_cell_t lo_blocks;
+ }
+ args;
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
+ args.method = (grub_ieee1275_cell_t) "#blocks64";
+ args.ihandle = ihandle;
+ args.catch_result = 1;
+
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result != 0))
+ return -1;
+
+ return ((args.hi_blocks << 32) | (args.lo_blocks));
+}
diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c
new file mode 100644
index 0000000..14d5964
--- /dev/null
+++ b/grub-core/kern/term.c
@@ -0,0 +1,169 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/term.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/time.h>
+
+struct grub_term_output *grub_term_outputs_disabled;
+struct grub_term_input *grub_term_inputs_disabled;
+struct grub_term_output *grub_term_outputs;
+struct grub_term_input *grub_term_inputs;
+
+/* Current color state. */
+grub_uint8_t grub_term_normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR;
+grub_uint8_t grub_term_highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR;
+
+void (*grub_term_poll_usb) (int wait_for_completion) = NULL;
+void (*grub_net_poll_cards_idle) (void) = NULL;
+
+/* Put a Unicode character. */
+static void
+grub_putcode_dumb (grub_uint32_t code,
+ struct grub_term_output *term)
+{
+ struct grub_unicode_glyph c =
+ {
+ .base = code,
+ .variant = 0,
+ .attributes = 0,
+ .ncomb = 0,
+ .estimated_width = 1
+ };
+
+ if (code == '\t' && term->getxy)
+ {
+ int n;
+
+ n = GRUB_TERM_TAB_WIDTH - ((term->getxy (term).x)
+ % GRUB_TERM_TAB_WIDTH);
+ while (n--)
+ grub_putcode_dumb (' ', term);
+
+ return;
+ }
+
+ (term->putchar) (term, &c);
+ if (code == '\n')
+ grub_putcode_dumb ('\r', term);
+}
+
+static void
+grub_xputs_dumb (const char *str)
+{
+ for (; *str; str++)
+ {
+ grub_term_output_t term;
+ grub_uint32_t code = *str;
+ if (code > 0x7f)
+ code = '?';
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ grub_putcode_dumb (code, term);
+ }
+}
+
+void (*grub_xputs) (const char *str) = grub_xputs_dumb;
+
+int
+grub_getkey_noblock (void)
+{
+ grub_term_input_t term;
+
+ if (grub_term_poll_usb)
+ grub_term_poll_usb (0);
+
+ if (grub_net_poll_cards_idle)
+ grub_net_poll_cards_idle ();
+
+ FOR_ACTIVE_TERM_INPUTS(term)
+ {
+ int key = term->getkey (term);
+ if (key != GRUB_TERM_NO_KEY)
+ return key;
+ }
+
+ return GRUB_TERM_NO_KEY;
+}
+
+int
+grub_getkey (void)
+{
+ int ret;
+
+ grub_refresh ();
+
+ while (1)
+ {
+ ret = grub_getkey_noblock ();
+ if (ret != GRUB_TERM_NO_KEY)
+ return ret;
+ grub_cpu_idle ();
+ }
+}
+
+int
+grub_getkeystatus (void)
+{
+ int status = 0;
+ grub_term_input_t term;
+
+ if (grub_term_poll_usb)
+ grub_term_poll_usb (0);
+
+ FOR_ACTIVE_TERM_INPUTS(term)
+ {
+ if (term->getkeystatus)
+ status |= term->getkeystatus (term);
+ }
+
+ return status;
+}
+
+int
+grub_key_is_interrupt (int key)
+{
+ /*
+ * ESC sometimes is the BIOS setup hotkey and may be hard to discover, also
+ * check F4, which was chosen because is not used as a hotkey to enter the
+ * BIOS setup by any vendor.
+ */
+ if (key == GRUB_TERM_ESC || key == GRUB_TERM_KEY_F4)
+ return 1;
+
+ /*
+ * Pressing keys at the right time during boot is hard to time, also allow
+ * interrupting sleeps / the menu countdown by keeping shift pressed.
+ */
+ if (grub_getkeystatus() & (GRUB_TERM_STATUS_LSHIFT | GRUB_TERM_STATUS_RSHIFT))
+ return 1;
+
+ return 0;
+}
+
+void
+grub_refresh (void)
+{
+ struct grub_term_output *term;
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ grub_term_refresh (term);
+}
diff --git a/grub-core/kern/time.c b/grub-core/kern/time.c
new file mode 100644
index 0000000..6521ec6
--- /dev/null
+++ b/grub-core/kern/time.c
@@ -0,0 +1,37 @@
+/* time.c - kernel time functions */
+/*
+ * 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/time.h>
+
+typedef grub_uint64_t (*get_time_ms_func_t) (void);
+
+/* Function pointer to the implementation in use. */
+static get_time_ms_func_t get_time_ms_func;
+
+grub_uint64_t
+grub_get_time_ms (void)
+{
+ return get_time_ms_func ();
+}
+
+void
+grub_install_get_time_ms (get_time_ms_func_t func)
+{
+ get_time_ms_func = func;
+}
diff --git a/grub-core/kern/uboot/hw.c b/grub-core/kern/uboot/hw.c
new file mode 100644
index 0000000..272b83b
--- /dev/null
+++ b/grub-core/kern/uboot/hw.c
@@ -0,0 +1,112 @@
+/* hw.c - U-Boot hardware discovery */
+/*
+ * 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/kernel.h>
+#include <grub/memory.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/offsets.h>
+#include <grub/machine/kernel.h>
+#include <grub/uboot/disk.h>
+#include <grub/uboot/uboot.h>
+#include <grub/uboot/api_public.h>
+
+grub_addr_t start_of_ram;
+
+/*
+ * grub_uboot_probe_memory():
+ * Queries U-Boot for available memory regions.
+ *
+ * Sets up heap near the image in memory and sets up "start_of_ram".
+ */
+void
+grub_uboot_mm_init (void)
+{
+ struct sys_info *si = grub_uboot_get_sys_info ();
+
+ grub_mm_init_region ((void *) grub_modules_get_end (),
+ GRUB_KERNEL_MACHINE_HEAP_SIZE);
+
+ if (si && (si->mr_no != 0))
+ {
+ int i;
+ start_of_ram = GRUB_UINT_MAX;
+
+ for (i = 0; i < si->mr_no; i++)
+ if ((si->mr[i].flags & MR_ATTR_MASK) == MR_ATTR_DRAM)
+ if (si->mr[i].start < start_of_ram)
+ start_of_ram = si->mr[i].start;
+ }
+}
+
+/*
+ * grub_uboot_probe_hardware():
+ */
+grub_err_t
+grub_uboot_probe_hardware (void)
+{
+ int devcount, i;
+
+ devcount = grub_uboot_dev_enum ();
+ grub_dprintf ("init", "%d devices found\n", devcount);
+
+ for (i = 0; i < devcount; i++)
+ {
+ struct device_info *devinfo = grub_uboot_dev_get (i);
+
+ grub_dprintf ("init", "device handle: %d\n", i);
+ grub_dprintf ("init", " cookie\t= 0x%08x\n",
+ (grub_uint32_t) devinfo->cookie);
+
+ if (devinfo->type & DEV_TYP_STOR)
+ {
+ grub_dprintf ("init", " type\t\t= DISK\n");
+ grub_ubootdisk_register (devinfo);
+ }
+ else if (devinfo->type & DEV_TYP_NET)
+ {
+ /* Dealt with in ubootnet module. */
+ grub_dprintf ("init", " type\t\t= NET (not supported yet)\n");
+ }
+ else
+ {
+ grub_dprintf ("init", "%s: unknown device type", __FUNCTION__);
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ int i;
+ struct sys_info *si = grub_uboot_get_sys_info ();
+
+ if (!si || (si->mr_no < 1))
+ return GRUB_ERR_BUG;
+
+ /* Iterate and call `hook'. */
+ for (i = 0; i < si->mr_no; i++)
+ if ((si->mr[i].flags & MR_ATTR_MASK) == MR_ATTR_DRAM)
+ hook (si->mr[i].start, si->mr[i].size, GRUB_MEMORY_AVAILABLE,
+ hook_data);
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c
new file mode 100644
index 0000000..3e33864
--- /dev/null
+++ b/grub-core/kern/uboot/init.c
@@ -0,0 +1,172 @@
+/* init.c - generic U-Boot initialization and finalization */
+/*
+ * 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/offsets.h>
+#include <grub/term.h>
+#include <grub/time.h>
+#include <grub/machine/kernel.h>
+#include <grub/uboot/console.h>
+#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[];
+extern grub_size_t grub_total_module_size;
+static unsigned long timer_start;
+
+void
+grub_exit (void)
+{
+ grub_uboot_return (0);
+}
+
+static grub_uint64_t
+uboot_timer_ms (void)
+{
+ static grub_uint32_t last = 0, high = 0;
+ grub_uint32_t cur = grub_uboot_get_timer (timer_start);
+ if (cur < last)
+ high++;
+ last = cur;
+ 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)
+{
+ int ver;
+
+ /* First of all - establish connection with U-Boot */
+ ver = grub_uboot_api_init ();
+ if (!ver)
+ {
+ /* Don't even have a console to log errors to... */
+ grub_exit ();
+ }
+ else if (ver > API_SIG_VERSION)
+ {
+ /* Try to print an error message */
+ grub_uboot_puts ("invalid U-Boot API version\n");
+ }
+
+ /* Initialize the console so that GRUB can display messages. */
+ grub_console_init_early ();
+
+ /* 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);
+ grub_dprintf ("init", "grub_modules_get_end(): %p\n",
+ (void *) grub_modules_get_end ());
+
+ /* Initialise full terminfo support */
+ grub_console_init_lately ();
+
+ /* Enumerate uboot devices */
+ grub_uboot_probe_hardware ();
+
+ /* Initialise timer */
+#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 ();
+}
+
+
+void
+grub_machine_fini (int flags __attribute__ ((unused)))
+{
+}
+
+/*
+ * grub_machine_get_bootlocation():
+ * Called from kern/main.c, which expects a device name (minus parentheses)
+ * and a filesystem path back, if any are known.
+ * Any returned values must be pointers to dynamically allocated strings.
+ */
+void
+grub_machine_get_bootlocation (char **device, char **path)
+{
+ char *tmp;
+
+ tmp = grub_uboot_env_get ("grub_bootdev");
+ if (tmp)
+ {
+ *device = grub_strdup (tmp);
+ if (*device == NULL)
+ return;
+ }
+ else
+ *device = NULL;
+
+ tmp = grub_uboot_env_get ("grub_bootpath");
+ if (tmp)
+ {
+ *path = grub_strdup (tmp);
+ if (*path == NULL)
+ return;
+ }
+ else
+ *path = NULL;
+}
+
+void
+grub_uboot_fini (void)
+{
+ grub_ubootdisk_fini ();
+ grub_console_fini ();
+}
diff --git a/grub-core/kern/uboot/uboot.c b/grub-core/kern/uboot/uboot.c
new file mode 100644
index 0000000..aac8f9a
--- /dev/null
+++ b/grub-core/kern/uboot/uboot.c
@@ -0,0 +1,307 @@
+/*
+ * 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/misc.h>
+#include <grub/mm.h>
+#include <grub/uboot/api_public.h>
+#include <grub/uboot/uboot.h>
+
+/*
+ * The main syscall entry point is not reentrant, only one call is
+ * serviced until finished.
+ *
+ * int syscall(int call, int *retval, ...)
+ * e.g. syscall(1, int *, u_int32_t, u_int32_t, u_int32_t, u_int32_t);
+ *
+ * call: syscall number
+ *
+ * retval: points to the return value placeholder, this is the place the
+ * syscall puts its return value, if NULL the caller does not
+ * expect a return value
+ *
+ * ... syscall arguments (variable number)
+ *
+ * returns: 0 if the call not found, 1 if serviced
+ */
+
+extern int grub_uboot_syscall (int, int *, ...);
+
+static struct sys_info uboot_sys_info;
+static struct mem_region uboot_mem_info[5];
+static struct device_info * devices;
+static int num_devices;
+
+
+/*
+ * All functions below are wrappers around the grub_uboot_syscall() function
+ */
+
+int
+grub_uboot_getc (void)
+{
+ int c;
+ if (!grub_uboot_syscall (API_GETC, NULL, &c))
+ return -1;
+
+ return c;
+}
+
+int
+grub_uboot_tstc (void)
+{
+ int c;
+ if (!grub_uboot_syscall (API_TSTC, NULL, &c))
+ return -1;
+
+ return c;
+}
+
+void
+grub_uboot_putc (int c)
+{
+ grub_uboot_syscall (API_PUTC, NULL, &c);
+}
+
+void
+grub_uboot_puts (const char *s)
+{
+ grub_uboot_syscall (API_PUTS, NULL, s);
+}
+
+void
+grub_uboot_reset (void)
+{
+ grub_uboot_syscall (API_RESET, NULL, 0);
+}
+
+struct sys_info *
+grub_uboot_get_sys_info (void)
+{
+ int retval;
+
+ grub_memset (&uboot_sys_info, 0, sizeof (uboot_sys_info));
+ grub_memset (&uboot_mem_info, 0, sizeof (uboot_mem_info));
+ uboot_sys_info.mr = uboot_mem_info;
+ uboot_sys_info.mr_no = sizeof (uboot_mem_info) / sizeof (struct mem_region);
+
+ if (grub_uboot_syscall (API_GET_SYS_INFO, &retval, &uboot_sys_info))
+ if (retval == 0)
+ return &uboot_sys_info;
+
+ return NULL;
+}
+
+void
+grub_uboot_udelay (grub_uint32_t usec)
+{
+ grub_uboot_syscall (API_UDELAY, NULL, &usec);
+}
+
+grub_uint32_t
+grub_uboot_get_timer (grub_uint32_t base)
+{
+ grub_uint32_t current;
+
+ if (!grub_uboot_syscall (API_GET_TIMER, NULL, &current, &base))
+ return 0;
+
+ return current;
+}
+
+int
+grub_uboot_dev_enum (void)
+{
+ struct device_info * enum_devices;
+ int num_enum_devices, max_devices;
+
+ if (num_devices)
+ return num_devices;
+
+ max_devices = 2;
+ enum_devices = grub_calloc (max_devices, sizeof(struct device_info));
+ if (!enum_devices)
+ return 0;
+
+ /*
+ * The API_DEV_ENUM call starts a fresh enumeration when passed a
+ * struct device_info with a NULL cookie, and then depends on having
+ * the previously enumerated device cookie "seeded" into the target
+ * structure.
+ */
+
+ enum_devices[0].cookie = NULL;
+ num_enum_devices = 0;
+
+ if (grub_uboot_syscall (API_DEV_ENUM, NULL,
+ &enum_devices[num_enum_devices]) == 0)
+ goto error;
+
+ num_enum_devices++;
+
+ while (enum_devices[num_enum_devices - 1].cookie != NULL)
+ {
+ if (num_enum_devices == max_devices)
+ {
+ struct device_info *tmp;
+ int new_max;
+ new_max = max_devices * 2;
+ tmp = grub_realloc (enum_devices,
+ sizeof (struct device_info) * new_max);
+ if (!tmp)
+ {
+ /* Failed to realloc, so return what we have */
+ break;
+ }
+ enum_devices = tmp;
+ max_devices = new_max;
+ }
+
+ enum_devices[num_enum_devices].cookie =
+ enum_devices[num_enum_devices - 1].cookie;
+ if (grub_uboot_syscall (API_DEV_ENUM, NULL,
+ &enum_devices[num_enum_devices]) == 0)
+ goto error;
+
+ if (enum_devices[num_enum_devices].cookie == NULL)
+ break;
+
+ num_enum_devices++;
+ }
+
+ devices = enum_devices;
+ return num_devices = num_enum_devices;
+
+ error:
+ grub_free (enum_devices);
+ return 0;
+}
+
+#define VALID_DEV(x) (((x) < num_devices) && ((x) >= 0))
+#define OPEN_DEV(x) ((x->state == DEV_STA_OPEN))
+
+struct device_info *
+grub_uboot_dev_get (int index)
+{
+ if (VALID_DEV (index))
+ return &devices[index];
+
+ return NULL;
+}
+
+
+int
+grub_uboot_dev_open (struct device_info *dev)
+{
+ int retval;
+
+ if (!grub_uboot_syscall (API_DEV_OPEN, &retval, dev))
+ return -1;
+
+ return retval;
+}
+
+int
+grub_uboot_dev_close (struct device_info *dev)
+{
+ int retval;
+
+ if (!grub_uboot_syscall (API_DEV_CLOSE, &retval, dev))
+ return -1;
+
+ return retval;
+}
+
+
+int
+grub_uboot_dev_read (struct device_info *dev, void *buf, grub_size_t blocks,
+ grub_uint32_t start, grub_size_t * real_blocks)
+{
+ int retval;
+
+ if (!OPEN_DEV (dev))
+ return -1;
+
+ if (!grub_uboot_syscall (API_DEV_READ, &retval, dev, buf,
+ &blocks, &start, real_blocks))
+ return -1;
+
+ return retval;
+}
+
+int
+grub_uboot_dev_write (struct device_info *dev, const void *buf,
+ grub_size_t blocks, grub_uint32_t start)
+{
+ int retval;
+
+ if (!OPEN_DEV (dev))
+ return -1;
+
+ if (!grub_uboot_syscall (API_DEV_WRITE, &retval, dev, buf,
+ &blocks, &start))
+ return -1;
+
+ return retval;
+}
+
+int
+grub_uboot_dev_recv (struct device_info *dev, void *buf,
+ int size, int *real_size)
+{
+ int retval;
+
+ if (!OPEN_DEV (dev))
+ return -1;
+
+ if (!grub_uboot_syscall (API_DEV_READ, &retval, dev, buf, &size, real_size))
+ return -1;
+
+ return retval;
+
+}
+
+int
+grub_uboot_dev_send (struct device_info *dev, void *buf, int size)
+{
+ int retval;
+
+ if (!OPEN_DEV (dev))
+ return -1;
+
+ if (!grub_uboot_syscall (API_DEV_WRITE, &retval, dev, buf, &size))
+ return -1;
+
+ return retval;
+}
+
+char *
+grub_uboot_env_get (const char *name)
+{
+ char *value;
+
+ if (!grub_uboot_syscall (API_ENV_GET, NULL, name, &value))
+ return NULL;
+
+ return value;
+}
+
+void
+grub_uboot_env_set (const char *name, const char *value)
+{
+ grub_uboot_syscall (API_ENV_SET, NULL, name, value);
+}
diff --git a/grub-core/kern/verifiers.c b/grub-core/kern/verifiers.c
new file mode 100644
index 0000000..75d7994
--- /dev/null
+++ b/grub-core/kern/verifiers.c
@@ -0,0 +1,228 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2017 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Verifiers helper.
+ */
+
+#include <grub/file.h>
+#include <grub/verify.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_file_verifier *grub_file_verifiers;
+
+struct grub_verified
+{
+ grub_file_t file;
+ void *buf;
+};
+typedef struct grub_verified *grub_verified_t;
+
+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_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_verified_t verified = file->data;
+
+ grub_file_close (verified->file);
+ verified_free (verified);
+ file->data = 0;
+
+ /* Device and name are freed by parent. */
+ file->device = 0;
+ file->name = 0;
+
+ return grub_errno;
+}
+
+struct grub_fs verified_fs =
+{
+ .name = "verified_read",
+ .fs_read = verified_read,
+ .fs_close = verified_close
+};
+
+static grub_file_t
+grub_verifiers_open (grub_file_t io, enum grub_file_type type)
+{
+ grub_verified_t verified = NULL;
+ struct grub_file_verifier *ver;
+ void *context;
+ grub_file_t ret = 0;
+ grub_err_t err;
+ int defer = 0;
+
+ grub_dprintf ("verify", "file: %s type: %d\n", io->name, type);
+
+ if ((type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_SIGNATURE
+ || (type & GRUB_FILE_TYPE_MASK) == GRUB_FILE_TYPE_VERIFY_SIGNATURE
+ || (type & GRUB_FILE_TYPE_SKIP_SIGNATURE))
+ return io;
+
+ 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;
+
+ FOR_LIST_ELEMENTS(ver, grub_file_verifiers)
+ {
+ enum grub_verify_flags flags = 0;
+ err = ver->init (io, type, &context, &flags);
+ if (err)
+ goto fail_noclose;
+ if (flags & GRUB_VERIFY_FLAGS_DEFER_AUTH)
+ {
+ defer = 1;
+ continue;
+ }
+ if (!(flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION))
+ break;
+ }
+
+ if (!ver)
+ {
+ if (defer)
+ {
+ grub_error (GRUB_ERR_ACCESS_DENIED,
+ N_("verification requested but nobody cares: %s"), io->name);
+ goto fail_noclose;
+ }
+
+ /* No verifiers wanted to verify. Just return underlying file. */
+ return io;
+ }
+
+ ret = grub_malloc (sizeof (*ret));
+ if (!ret)
+ {
+ goto fail;
+ }
+ *ret = *io;
+
+ ret->fs = &verified_fs;
+ ret->not_easily_seekable = 0;
+ if (ret->size >> (sizeof (grub_size_t) * GRUB_CHAR_BIT - 1))
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("big file signature isn't implemented yet"));
+ goto fail;
+ }
+ verified = grub_malloc (sizeof (*verified));
+ if (!verified)
+ {
+ goto fail;
+ }
+ verified->buf = grub_malloc (ret->size);
+ if (!verified->buf)
+ {
+ goto fail;
+ }
+ 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"),
+ io->name);
+ goto fail;
+ }
+
+ err = ver->write (context, verified->buf, ret->size);
+ if (err)
+ goto fail;
+
+ err = ver->fini ? ver->fini (context) : GRUB_ERR_NONE;
+ if (err)
+ goto fail;
+
+ if (ver->close)
+ ver->close (context);
+
+ FOR_LIST_ELEMENTS_NEXT(ver, grub_file_verifiers)
+ {
+ enum grub_verify_flags flags = 0;
+ err = ver->init (io, type, &context, &flags);
+ if (err)
+ goto fail_noclose;
+ if (flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION ||
+ /* Verification done earlier. So, we are happy here. */
+ flags & GRUB_VERIFY_FLAGS_DEFER_AUTH)
+ continue;
+ err = ver->write (context, verified->buf, ret->size);
+ if (err)
+ goto fail;
+
+ err = ver->fini ? ver->fini (context) : GRUB_ERR_NONE;
+ if (err)
+ goto fail;
+
+ if (ver->close)
+ ver->close (context);
+ }
+
+ verified->file = io;
+ ret->data = verified;
+ return ret;
+
+ fail:
+ if (ver->close)
+ ver->close (context);
+ fail_noclose:
+ verified_free (verified);
+ grub_free (ret);
+ return NULL;
+}
+
+grub_err_t
+grub_verify_string (char *str, enum grub_verify_string_type type)
+{
+ struct grub_file_verifier *ver;
+
+ grub_dprintf ("verify", "string: %s, type: %d\n", str, type);
+
+ FOR_LIST_ELEMENTS(ver, grub_file_verifiers)
+ {
+ grub_err_t err;
+ err = ver->verify_string ? ver->verify_string (str, type) : GRUB_ERR_NONE;
+ if (err)
+ return err;
+ }
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_verifiers_init (void)
+{
+ grub_file_filter_register (GRUB_FILE_FILTER_VERIFY, grub_verifiers_open);
+}
diff --git a/grub-core/kern/vga_init.c b/grub-core/kern/vga_init.c
new file mode 100644
index 0000000..3fe2f16
--- /dev/null
+++ b/grub-core/kern/vga_init.c
@@ -0,0 +1,128 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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 __mips__
+#include <grub/pci.h>
+#include <grub/mm.h>
+#endif
+#include <grub/machine/kernel.h>
+#include <grub/misc.h>
+#include <grub/vga.h>
+
+static struct {grub_uint8_t r, g, b, a; } colors[] =
+ {
+ // {R, G, B, A}
+ {0x00, 0x00, 0x00, 0xFF}, // 0 = black
+ {0x00, 0x00, 0xA8, 0xFF}, // 1 = blue
+ {0x00, 0xA8, 0x00, 0xFF}, // 2 = green
+ {0x00, 0xA8, 0xA8, 0xFF}, // 3 = cyan
+ {0xA8, 0x00, 0x00, 0xFF}, // 4 = red
+ {0xA8, 0x00, 0xA8, 0xFF}, // 5 = magenta
+ {0xA8, 0x54, 0x00, 0xFF}, // 6 = brown
+ {0xA8, 0xA8, 0xA8, 0xFF}, // 7 = light gray
+
+ {0x54, 0x54, 0x54, 0xFF}, // 8 = dark gray
+ {0x54, 0x54, 0xFE, 0xFF}, // 9 = bright blue
+ {0x54, 0xFE, 0x54, 0xFF}, // 10 = bright green
+ {0x54, 0xFE, 0xFE, 0xFF}, // 11 = bright cyan
+ {0xFE, 0x54, 0x54, 0xFF}, // 12 = bright red
+ {0xFE, 0x54, 0xFE, 0xFF}, // 13 = bright magenta
+ {0xFE, 0xFE, 0x54, 0xFF}, // 14 = yellow
+ {0xFE, 0xFE, 0xFE, 0xFF} // 15 = white
+ };
+
+#include <ascii.h>
+
+#ifdef __mips__
+#define VGA_ADDR 0xb00a0000
+#else
+#define VGA_ADDR 0xa0000
+#endif
+
+static void
+load_font (void)
+{
+ unsigned i;
+
+ grub_vga_gr_write (0 << 2, GRUB_VGA_GR_GR6);
+
+ grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_NORMAL, GRUB_VGA_SR_MEMORY_MODE);
+ grub_vga_sr_write (1 << GRUB_VGA_TEXT_FONT_PLANE,
+ GRUB_VGA_SR_MAP_MASK_REGISTER);
+
+ grub_vga_gr_write (0, GRUB_VGA_GR_DATA_ROTATE);
+ grub_vga_gr_write (0, GRUB_VGA_GR_MODE);
+ grub_vga_gr_write (0xff, GRUB_VGA_GR_BITMASK);
+
+ for (i = 0; i < 128; i++)
+ grub_memcpy ((void *) (VGA_ADDR + 32 * i), ascii_bitmaps + 16 * i, 16);
+}
+
+static void
+load_palette (void)
+{
+ unsigned i;
+ for (i = 0; i < 16; i++)
+ grub_vga_write_arx (i, i);
+
+ for (i = 0; i < ARRAY_SIZE (colors); i++)
+ grub_vga_palette_write (i, colors[i].r, colors[i].g, colors[i].b);
+}
+
+void
+grub_qemu_init_cirrus (void)
+{
+ grub_outb (GRUB_VGA_IO_MISC_COLOR,
+ GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_MISC_WRITE);
+
+ load_font ();
+
+ grub_vga_gr_write (GRUB_VGA_GR_GR6_MMAP_CGA, GRUB_VGA_GR_GR6);
+ grub_vga_gr_write (GRUB_VGA_GR_MODE_ODD_EVEN, GRUB_VGA_GR_MODE);
+
+ grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_NORMAL, GRUB_VGA_SR_MEMORY_MODE);
+
+ grub_vga_sr_write ((1 << GRUB_VGA_TEXT_TEXT_PLANE)
+ | (1 << GRUB_VGA_TEXT_ATTR_PLANE),
+ GRUB_VGA_SR_MAP_MASK_REGISTER);
+
+ grub_vga_cr_write (15, GRUB_VGA_CR_CELL_HEIGHT);
+ grub_vga_cr_write (79, GRUB_VGA_CR_HORIZ_END);
+ grub_vga_cr_write (40, GRUB_VGA_CR_PITCH);
+
+ int vert = 25 * 16;
+ grub_vga_cr_write (vert & 0xff, GRUB_VGA_CR_VDISPLAY_END);
+ grub_vga_cr_write (((vert >> GRUB_VGA_CR_OVERFLOW_HEIGHT1_SHIFT)
+ & GRUB_VGA_CR_OVERFLOW_HEIGHT1_MASK)
+ | ((vert >> GRUB_VGA_CR_OVERFLOW_HEIGHT2_SHIFT)
+ & GRUB_VGA_CR_OVERFLOW_HEIGHT2_MASK),
+ GRUB_VGA_CR_OVERFLOW);
+
+ load_palette ();
+
+ grub_vga_write_arx (GRUB_VGA_ARX_MODE_TEXT, GRUB_VGA_ARX_MODE);
+ grub_vga_write_arx (0, GRUB_VGA_ARX_COLOR_SELECT);
+
+ grub_vga_sr_write (GRUB_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK,
+ GRUB_VGA_SR_CLOCKING_MODE);
+
+ grub_vga_cr_write (14, GRUB_VGA_CR_CURSOR_START);
+ grub_vga_cr_write (15, GRUB_VGA_CR_CURSOR_END);
+
+ grub_outb (0x20, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_ARX);
+}
diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c
new file mode 100644
index 0000000..e5a8bdc
--- /dev/null
+++ b/grub-core/kern/x86_64/dl.c
@@ -0,0 +1,121 @@
+/* dl-x86_64.c - arch-dependent part of loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/i18n.h>
+
+/* Check if EHDR is a valid ELF header. */
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ Elf64_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+ if (e->e_ident[EI_CLASS] != ELFCLASS64
+ || e->e_ident[EI_DATA] != ELFDATA2LSB
+ || e->e_machine != EM_X86_64)
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
+
+/* Relocate symbols. */
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ Elf64_Rela *rel, *max;
+
+ for (rel = (Elf64_Rela *) ((char *) ehdr + s->sh_offset),
+ max = (Elf64_Rela *) ((char *) rel + s->sh_size);
+ rel < max;
+ rel = (Elf64_Rela *) ((char *) rel + s->sh_entsize))
+ {
+ Elf64_Word *addr32;
+ Elf64_Xword *addr64;
+ Elf64_Sym *sym;
+
+ if (seg->size < rel->r_offset)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ addr32 = (Elf64_Word *) ((char *) seg->addr + rel->r_offset);
+ addr64 = (Elf64_Xword *) addr32;
+ sym = (Elf64_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel->r_info));
+
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case R_X86_64_64:
+ *addr64 += rel->r_addend + sym->st_value;
+ break;
+
+ case R_X86_64_PC32:
+ case R_X86_64_PLT32:
+ {
+ grub_int64_t value;
+ value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value -
+ (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;
+ }
+ break;
+
+ case R_X86_64_PC64:
+ {
+ *addr64 += rel->r_addend + sym->st_value -
+ (Elf64_Xword) (grub_addr_t) seg->addr - rel->r_offset;
+ }
+ break;
+
+ case R_X86_64_32:
+ {
+ grub_uint64_t value = *addr32 + rel->r_addend + sym->st_value;
+ if (value != (grub_uint32_t) value)
+ return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
+ *addr32 = value;
+ }
+ break;
+ case R_X86_64_32S:
+ {
+ grub_int64_t value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value;
+ if (value != (grub_int32_t) value)
+ return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
+ *addr32 = value;
+ }
+ break;
+
+ default:
+ {
+ char rel_info[17]; /* log16(2^64) = 16, plus NUL. */
+
+ grub_snprintf (rel_info, sizeof (rel_info) - 1, "%" PRIxGRUB_UINT64_T,
+ ELF_R_TYPE (rel->r_info));
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%s is not implemented yet"), rel_info);
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/kern/x86_64/efi/callwrap.S b/grub-core/kern/x86_64/efi/callwrap.S
new file mode 100644
index 0000000..1337fd9
--- /dev/null
+++ b/grub-core/kern/x86_64/efi/callwrap.S
@@ -0,0 +1,129 @@
+/* callwrap.S - wrapper for x86_64 efi calls */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/symbol.h>
+
+/*
+ * x86_64 uses registry to pass parameters. Unfortunately, gcc and efi use
+ * different call conversion, so we need to do some conversion.
+ *
+ * gcc:
+ * %rdi, %rsi, %rdx, %rcx, %r8, %r9, 8(%rsp), 16(%rsp), ...
+ *
+ * efi:
+ * %rcx, %rdx, %r8, %r9, 32(%rsp), 40(%rsp), 48(%rsp), ...
+ *
+ */
+
+ .file "callwrap.S"
+ .text
+
+FUNCTION(efi_wrap_0)
+ subq $40, %rsp
+ call *%rdi
+ addq $40, %rsp
+ ret
+
+FUNCTION(efi_wrap_1)
+ subq $40, %rsp
+ mov %rsi, %rcx
+ call *%rdi
+ addq $40, %rsp
+ ret
+
+FUNCTION(efi_wrap_2)
+ subq $40, %rsp
+ mov %rsi, %rcx
+ call *%rdi
+ addq $40, %rsp
+ ret
+
+FUNCTION(efi_wrap_3)
+ subq $40, %rsp
+ mov %rcx, %r8
+ mov %rsi, %rcx
+ call *%rdi
+ addq $40, %rsp
+ ret
+
+FUNCTION(efi_wrap_4)
+ subq $40, %rsp
+ mov %r8, %r9
+ mov %rcx, %r8
+ mov %rsi, %rcx
+ call *%rdi
+ addq $40, %rsp
+ ret
+
+FUNCTION(efi_wrap_5)
+ subq $40, %rsp
+ mov %r9, 32(%rsp)
+ mov %r8, %r9
+ mov %rcx, %r8
+ mov %rsi, %rcx
+ call *%rdi
+ addq $40, %rsp
+ ret
+
+FUNCTION(efi_wrap_6)
+ subq $56, %rsp
+ mov 56+8(%rsp), %rax
+ mov %rax, 40(%rsp)
+ mov %r9, 32(%rsp)
+ mov %r8, %r9
+ mov %rcx, %r8
+ mov %rsi, %rcx
+ call *%rdi
+ addq $56, %rsp
+ ret
+
+FUNCTION(efi_wrap_7)
+ subq $88, %rsp
+ mov 88+16(%rsp), %rax
+ mov %rax, 48(%rsp)
+ mov 88+8(%rsp), %rax
+ mov %rax, 40(%rsp)
+ mov %r9, 32(%rsp)
+ mov %r8, %r9
+ mov %rcx, %r8
+ mov %rsi, %rcx
+ call *%rdi
+ addq $88, %rsp
+ ret
+
+FUNCTION(efi_wrap_10)
+ subq $88, %rsp
+ mov 88+40(%rsp), %rax
+ mov %rax, 72(%rsp)
+ mov 88+32(%rsp), %rax
+ mov %rax, 64(%rsp)
+ mov 88+24(%rsp), %rax
+ mov %rax, 56(%rsp)
+ mov 88+16(%rsp), %rax
+ mov %rax, 48(%rsp)
+ mov 88+8(%rsp), %rax
+ mov %rax, 40(%rsp)
+ mov %r9, 32(%rsp)
+ mov %r8, %r9
+ mov %rcx, %r8
+ mov %rsi, %rcx
+ call *%rdi
+ addq $88, %rsp
+ ret
diff --git a/grub-core/kern/x86_64/efi/startup.S b/grub-core/kern/x86_64/efi/startup.S
new file mode 100644
index 0000000..9357e5c
--- /dev/null
+++ b/grub-core/kern/x86_64/efi/startup.S
@@ -0,0 +1,35 @@
+/* startup.S - bootstrap GRUB itself */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/symbol.h>
+
+ .file "startup.S"
+ .text
+ .globl start, _start
+ .code64
+
+start:
+_start:
+ movq %rcx, EXT_C(grub_efi_image_handle)(%rip)
+ movq %rdx, EXT_C(grub_efi_system_table)(%rip)
+
+ andq $~0xf, %rsp
+ call EXT_C(grub_main)
+ /* Doesn't return. */
diff --git a/grub-core/kern/x86_64/xen/hypercall.S b/grub-core/kern/x86_64/xen/hypercall.S
new file mode 100644
index 0000000..9b04db6
--- /dev/null
+++ b/grub-core/kern/x86_64/xen/hypercall.S
@@ -0,0 +1,53 @@
+/* hypercall.S - wrappers for Xen hypercalls */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/symbol.h>
+#include <grub/xen.h>
+
+FUNCTION(grub_xen_sched_op)
+ movq $__HYPERVISOR_sched_op, %rax
+ syscall
+ ret
+
+FUNCTION(grub_xen_event_channel_op)
+ movq $__HYPERVISOR_event_channel_op, %rax
+ syscall
+ ret
+
+FUNCTION(grub_xen_update_va_mapping)
+ movq $__HYPERVISOR_update_va_mapping, %rax
+ syscall
+ ret
+
+FUNCTION(grub_xen_mmuext_op)
+ movq %rcx, %r10
+ movq $__HYPERVISOR_mmuext_op, %rax
+ syscall
+ ret
+
+FUNCTION(grub_xen_grant_table_op)
+ movq $__HYPERVISOR_grant_table_op, %rax
+ syscall
+ ret
+
+FUNCTION(grub_xen_mmu_update)
+ movq %rcx, %r10
+ movq $__HYPERVISOR_mmu_update, %rax
+ syscall
+ ret
diff --git a/grub-core/kern/x86_64/xen/startup.S b/grub-core/kern/x86_64/xen/startup.S
new file mode 100644
index 0000000..21a139f
--- /dev/null
+++ b/grub-core/kern/x86_64/xen/startup.S
@@ -0,0 +1,39 @@
+/* startup.S - bootstrap GRUB itself */
+/*
+ * 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 <config.h>
+#include <grub/symbol.h>
+
+ .file "startup.S"
+ .text
+ .globl start, _start
+ .code64
+
+start:
+_start:
+ leaq LOCAL(stack_end), %rsp
+ movq %rsi, EXT_C(grub_xen_start_page_addr)(%rip)
+
+ andq $~0xf, %rsp
+ call EXT_C(grub_main)
+ /* Doesn't return. */
+
+ .bss
+ .space (1 << 22)
+LOCAL(stack_end):
diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c
new file mode 100644
index 0000000..782ca72
--- /dev/null
+++ b/grub-core/kern/xen/init.c
@@ -0,0 +1,601 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/xen.h>
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/mm.h>
+#include <grub/kernel.h>
+#include <grub/offsets.h>
+#include <grub/memory.h>
+#include <grub/i386/tsc.h>
+#include <grub/term.h>
+#include <grub/loader.h>
+
+grub_addr_t grub_modbase;
+struct start_info *grub_xen_start_page_addr;
+volatile struct xencons_interface *grub_xen_xcons;
+volatile struct shared_info *grub_xen_shared_info;
+volatile struct xenstore_domain_interface *grub_xen_xenstore;
+volatile grant_entry_v1_t *grub_xen_grant_table;
+static const grub_size_t total_grants =
+ GRUB_XEN_PAGE_SIZE / sizeof (grub_xen_grant_table[0]);
+grub_size_t grub_xen_n_allocated_shared_pages;
+
+static grub_xen_mfn_t
+grub_xen_ptr2mfn (void *ptr)
+{
+#ifdef GRUB_MACHINE_XEN
+ grub_xen_mfn_t *mfn_list =
+ (grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list;
+ return mfn_list[(grub_addr_t) ptr >> GRUB_XEN_LOG_PAGE_SIZE];
+#else
+ return (grub_addr_t) ptr >> GRUB_XEN_LOG_PAGE_SIZE;
+#endif
+}
+
+void *
+grub_xen_alloc_shared_page (domid_t dom, grub_xen_grant_t * grnum)
+{
+ void *ret;
+ grub_xen_mfn_t mfn;
+ volatile grant_entry_v1_t *entry;
+
+ /* Avoid 0. */
+ for (entry = grub_xen_grant_table;
+ entry < grub_xen_grant_table + total_grants; entry++)
+ if (!entry->flags)
+ break;
+
+ if (entry == grub_xen_grant_table + total_grants)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of grant entries");
+ return NULL;
+ }
+ ret = grub_memalign (GRUB_XEN_PAGE_SIZE, GRUB_XEN_PAGE_SIZE);
+ if (!ret)
+ return NULL;
+ mfn = grub_xen_ptr2mfn (ret);
+ entry->frame = mfn;
+ entry->domid = dom;
+ mb ();
+ entry->flags = GTF_permit_access;
+ mb ();
+ *grnum = entry - grub_xen_grant_table;
+ grub_xen_n_allocated_shared_pages++;
+ return ret;
+}
+
+void
+grub_xen_free_shared_page (void *ptr)
+{
+ grub_xen_mfn_t mfn;
+ volatile grant_entry_v1_t *entry;
+
+ mfn = grub_xen_ptr2mfn (ptr);
+ for (entry = grub_xen_grant_table + 1;
+ entry < grub_xen_grant_table + total_grants; entry++)
+ if (entry->flags && entry->frame == mfn)
+ {
+ mb ();
+ entry->flags = 0;
+ mb ();
+ entry->frame = 0;
+ mb ();
+ }
+ grub_xen_n_allocated_shared_pages--;
+}
+
+void
+grub_machine_get_bootlocation (char **device __attribute__ ((unused)),
+ char **path __attribute__ ((unused)))
+{
+}
+
+void
+grub_xen_store_send (const void *buf_, grub_size_t len)
+{
+ const grub_uint8_t *buf = buf_;
+ struct evtchn_send send;
+ int event_sent = 0;
+ while (len)
+ {
+ grub_size_t avail, inbuf;
+ grub_size_t prod, cons;
+ mb ();
+ prod = grub_xen_xenstore->req_prod;
+ cons = grub_xen_xenstore->req_cons;
+ if (prod >= cons + sizeof (grub_xen_xenstore->req))
+ {
+ if (!event_sent)
+ {
+ send.port = grub_xen_start_page_addr->store_evtchn;
+ grub_xen_event_channel_op (EVTCHNOP_send, &send);
+ event_sent = 1;
+ }
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ continue;
+ }
+ event_sent = 0;
+ avail = cons + sizeof (grub_xen_xenstore->req) - prod;
+ inbuf = (~prod & (sizeof (grub_xen_xenstore->req) - 1)) + 1;
+ if (avail > inbuf)
+ avail = inbuf;
+ if (avail > len)
+ avail = len;
+ grub_memcpy ((void *) &grub_xen_xenstore->req[prod & (sizeof (grub_xen_xenstore->req) - 1)],
+ buf, avail);
+ buf += avail;
+ len -= avail;
+ mb ();
+ grub_xen_xenstore->req_prod += avail;
+ mb ();
+ if (!event_sent)
+ {
+ send.port = grub_xen_start_page_addr->store_evtchn;
+ grub_xen_event_channel_op (EVTCHNOP_send, &send);
+ event_sent = 1;
+ }
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ }
+}
+
+void
+grub_xen_store_recv (void *buf_, grub_size_t len)
+{
+ grub_uint8_t *buf = buf_;
+ struct evtchn_send send;
+ int event_sent = 0;
+ while (len)
+ {
+ grub_size_t avail, inbuf;
+ grub_size_t prod, cons;
+ mb ();
+ prod = grub_xen_xenstore->rsp_prod;
+ cons = grub_xen_xenstore->rsp_cons;
+ if (prod <= cons)
+ {
+ if (!event_sent)
+ {
+ send.port = grub_xen_start_page_addr->store_evtchn;
+ grub_xen_event_channel_op (EVTCHNOP_send, &send);
+ event_sent = 1;
+ }
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ continue;
+ }
+ event_sent = 0;
+ avail = prod - cons;
+ inbuf = (~cons & (sizeof (grub_xen_xenstore->req) - 1)) + 1;
+ if (avail > inbuf)
+ avail = inbuf;
+ if (avail > len)
+ avail = len;
+ grub_memcpy (buf,
+ (void *) &grub_xen_xenstore->rsp[cons & (sizeof (grub_xen_xenstore->rsp) - 1)],
+ avail);
+ buf += avail;
+ len -= avail;
+ mb ();
+ grub_xen_xenstore->rsp_cons += avail;
+ mb ();
+ if (!event_sent)
+ {
+ send.port = grub_xen_start_page_addr->store_evtchn;
+ grub_xen_event_channel_op(EVTCHNOP_send, &send);
+ event_sent = 1;
+ }
+ grub_xen_sched_op(SCHEDOP_yield, 0);
+ }
+}
+
+void *
+grub_xenstore_get_file (const char *dir, grub_size_t *len)
+{
+ struct xsd_sockmsg msg;
+ char *buf;
+ grub_size_t dirlen = grub_strlen (dir) + 1;
+
+ if (len)
+ *len = 0;
+
+ grub_memset (&msg, 0, sizeof (msg));
+ msg.type = XS_READ;
+ msg.len = dirlen;
+ grub_xen_store_send (&msg, sizeof (msg));
+ grub_xen_store_send (dir, dirlen);
+ grub_xen_store_recv (&msg, sizeof (msg));
+ buf = grub_malloc (msg.len + 1);
+ if (!buf)
+ return NULL;
+ grub_dprintf ("xen", "msg type = %d, len = %d\n", msg.type, msg.len);
+ grub_xen_store_recv (buf, msg.len);
+ buf[msg.len] = '\0';
+ if (msg.type == XS_ERROR)
+ {
+ grub_error (GRUB_ERR_IO, "couldn't read xenstorage `%s': %s", dir, buf);
+ grub_free (buf);
+ return NULL;
+ }
+ if (len)
+ *len = msg.len;
+ return buf;
+}
+
+grub_err_t
+grub_xenstore_write_file (const char *dir, const void *buf, grub_size_t len)
+{
+ struct xsd_sockmsg msg;
+ grub_size_t dirlen = grub_strlen (dir) + 1;
+ char *resp;
+
+ grub_memset (&msg, 0, sizeof (msg));
+ msg.type = XS_WRITE;
+ msg.len = dirlen + len;
+ grub_xen_store_send (&msg, sizeof (msg));
+ grub_xen_store_send (dir, dirlen);
+ grub_xen_store_send (buf, len);
+ grub_xen_store_recv (&msg, sizeof (msg));
+ resp = grub_malloc (msg.len + 1);
+ if (!resp)
+ return grub_errno;
+ grub_dprintf ("xen", "msg type = %d, len = %d\n", msg.type, msg.len);
+ grub_xen_store_recv (resp, msg.len);
+ resp[msg.len] = '\0';
+ if (msg.type == XS_ERROR)
+ {
+ grub_dprintf ("xen", "error = %s\n", resp);
+ grub_error (GRUB_ERR_IO, "couldn't read xenstorage `%s': %s",
+ dir, resp);
+ grub_free (resp);
+ return grub_errno;
+ }
+ grub_free (resp);
+ return GRUB_ERR_NONE;
+}
+
+/* FIXME: error handling. */
+grub_err_t
+grub_xenstore_dir (const char *dir,
+ int (*hook) (const char *dir, void *hook_data),
+ void *hook_data)
+{
+ struct xsd_sockmsg msg;
+ char *buf;
+ char *ptr;
+ grub_size_t dirlen = grub_strlen (dir) + 1;
+
+ grub_memset (&msg, 0, sizeof (msg));
+ msg.type = XS_DIRECTORY;
+ msg.len = dirlen;
+ grub_xen_store_send (&msg, sizeof (msg));
+ grub_xen_store_send (dir, dirlen);
+ grub_xen_store_recv (&msg, sizeof (msg));
+ buf = grub_malloc (msg.len + 1);
+ if (!buf)
+ return grub_errno;
+ grub_dprintf ("xen", "msg type = %d, len = %d\n", msg.type, msg.len);
+ grub_xen_store_recv (buf, msg.len);
+ buf[msg.len] = '\0';
+ if (msg.type == XS_ERROR)
+ {
+ grub_err_t err;
+ err = grub_error (GRUB_ERR_IO, "couldn't read xenstorage `%s': %s",
+ dir, buf);
+ grub_free (buf);
+ return err;
+ }
+ for (ptr = buf; ptr < buf + msg.len; ptr += grub_strlen (ptr) + 1)
+ if (hook (ptr, hook_data))
+ break;
+ grub_free (buf);
+ return grub_errno;
+}
+
+unsigned long gntframe = 0;
+
+static void
+grub_xen_setup_gnttab (void)
+{
+ struct gnttab_set_version gnttab_setver;
+ struct gnttab_setup_table gnttab_setup;
+
+ grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver));
+
+ gnttab_setver.version = 1;
+ grub_xen_grant_table_op (GNTTABOP_set_version, &gnttab_setver, 1);
+
+ grub_memset (&gnttab_setup, 0, sizeof (gnttab_setup));
+ gnttab_setup.dom = DOMID_SELF;
+ gnttab_setup.nr_frames = 1;
+ gnttab_setup.frame_list.p = &gntframe;
+
+ grub_xen_grant_table_op (GNTTABOP_setup_table, &gnttab_setup, 1);
+}
+
+#ifdef GRUB_MACHINE_XEN
+static grub_uint8_t window[GRUB_XEN_PAGE_SIZE]
+ __attribute__ ((aligned (GRUB_XEN_PAGE_SIZE)));
+
+#ifdef __x86_64__
+#define NUMBER_OF_LEVELS 4
+#else
+#define NUMBER_OF_LEVELS 3
+#endif
+
+#define LOG_POINTERS_PER_PAGE 9
+#define POINTERS_PER_PAGE (1 << LOG_POINTERS_PER_PAGE)
+
+#define MAX_N_UNUSABLE_PAGES 4
+
+static int
+grub_xen_is_page_usable (grub_xen_mfn_t mfn)
+{
+ if (mfn == grub_xen_start_page_addr->console.domU.mfn)
+ return 0;
+ if (mfn == grub_xen_start_page_addr->shared_info)
+ return 0;
+ if (mfn == grub_xen_start_page_addr->store_mfn)
+ return 0;
+ if (mfn == gntframe)
+ return 0;
+ return 1;
+}
+
+static grub_uint64_t
+page2offset (grub_uint64_t page)
+{
+ return page << 12;
+}
+
+#if defined (__x86_64__) && defined (__code_model_large__)
+#define MAX_TOTAL_PAGES (1LL << (64 - 12))
+#elif defined (__x86_64__)
+#define MAX_TOTAL_PAGES (1LL << (31 - 12))
+#else
+#define MAX_TOTAL_PAGES (1LL << (32 - 12))
+#endif
+
+static void
+map_all_pages (void)
+{
+ grub_uint64_t total_pages = grub_xen_start_page_addr->nr_pages;
+ grub_uint64_t i, j;
+ grub_xen_mfn_t *mfn_list =
+ (grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list;
+ grub_uint64_t *pg = (grub_uint64_t *) window;
+ grub_uint64_t oldpgstart, oldpgend;
+ grub_size_t n_unusable_pages = 0;
+ struct mmu_update m2p_updates[2 * MAX_N_UNUSABLE_PAGES];
+
+ if (total_pages > MAX_TOTAL_PAGES - 4)
+ total_pages = MAX_TOTAL_PAGES - 4;
+
+ for (j = 0; j < total_pages - n_unusable_pages; j++)
+ while (!grub_xen_is_page_usable (mfn_list[j]))
+ {
+ grub_xen_mfn_t t;
+ if (n_unusable_pages >= MAX_N_UNUSABLE_PAGES)
+ {
+ struct sched_shutdown arg;
+ arg.reason = SHUTDOWN_crash;
+ grub_xen_sched_op (SCHEDOP_shutdown, &arg);
+ while (1);
+ }
+ t = mfn_list[j];
+ mfn_list[j] = mfn_list[total_pages - n_unusable_pages - 1];
+ mfn_list[total_pages - n_unusable_pages - 1] = t;
+
+ m2p_updates[2 * n_unusable_pages].ptr
+ = page2offset (mfn_list[j]) | MMU_MACHPHYS_UPDATE;
+ m2p_updates[2 * n_unusable_pages].val = j;
+ m2p_updates[2 * n_unusable_pages + 1].ptr
+ = page2offset (mfn_list[total_pages - n_unusable_pages - 1])
+ | MMU_MACHPHYS_UPDATE;
+ m2p_updates[2 * n_unusable_pages + 1].val = total_pages
+ - n_unusable_pages - 1;
+
+ n_unusable_pages++;
+ }
+
+ grub_xen_mmu_update (m2p_updates, 2 * n_unusable_pages, NULL, DOMID_SELF);
+
+ total_pages += 4;
+
+ grub_uint64_t lx[NUMBER_OF_LEVELS], nlx;
+ grub_uint64_t paging_start = total_pages - 4 - n_unusable_pages, curpage;
+
+ for (nlx = total_pages, i = 0; i < (unsigned) NUMBER_OF_LEVELS; i++)
+ {
+ nlx = (nlx + POINTERS_PER_PAGE - 1) >> LOG_POINTERS_PER_PAGE;
+ /* PAE wants all 4 root directories present. */
+#ifdef __i386__
+ if (i == 1)
+ nlx = 4;
+#endif
+ lx[i] = nlx;
+ paging_start -= nlx;
+ }
+
+ oldpgstart = grub_xen_start_page_addr->pt_base >> 12;
+ oldpgend = oldpgstart + grub_xen_start_page_addr->nr_pt_frames;
+
+ curpage = paging_start;
+
+ int l;
+
+ for (l = NUMBER_OF_LEVELS - 1; l >= 1; l--)
+ {
+ for (i = 0; i < lx[l]; i++)
+ {
+ grub_xen_update_va_mapping (&window,
+ page2offset (mfn_list[curpage + i]) | 7,
+ UVMF_INVLPG);
+ grub_memset (&window, 0, sizeof (window));
+
+ for (j = i * POINTERS_PER_PAGE;
+ j < (i + 1) * POINTERS_PER_PAGE && j < lx[l - 1]; j++)
+ pg[j - i * POINTERS_PER_PAGE] =
+ page2offset (mfn_list[curpage + lx[l] + j])
+#ifdef __x86_64__
+ | 4
+#endif
+ | 3;
+ }
+ curpage += lx[l];
+ }
+
+ for (i = 0; i < lx[0]; i++)
+ {
+ grub_xen_update_va_mapping (&window,
+ page2offset (mfn_list[curpage + i]) | 7,
+ UVMF_INVLPG);
+ grub_memset (&window, 0, sizeof (window));
+
+ for (j = i * POINTERS_PER_PAGE;
+ j < (i + 1) * POINTERS_PER_PAGE && j < total_pages; j++)
+ if (j < paging_start && !(j >= oldpgstart && j < oldpgend))
+ pg[j - i * POINTERS_PER_PAGE] = page2offset (mfn_list[j]) | 0x7;
+ else if (j < grub_xen_start_page_addr->nr_pages)
+ pg[j - i * POINTERS_PER_PAGE] = page2offset (mfn_list[j]) | 5;
+ else if (j == grub_xen_start_page_addr->nr_pages)
+ {
+ pg[j - i * POINTERS_PER_PAGE] =
+ page2offset (grub_xen_start_page_addr->console.domU.mfn) | 7;
+ grub_xen_xcons = (void *) (grub_addr_t) page2offset (j);
+ }
+ else if (j == grub_xen_start_page_addr->nr_pages + 1)
+ {
+ pg[j - i * POINTERS_PER_PAGE] =
+ grub_xen_start_page_addr->shared_info | 7;
+ grub_xen_shared_info = (void *) (grub_addr_t) page2offset (j);
+ }
+ else if (j == grub_xen_start_page_addr->nr_pages + 2)
+ {
+ pg[j - i * POINTERS_PER_PAGE] =
+ page2offset (grub_xen_start_page_addr->store_mfn) | 7;
+ grub_xen_xenstore = (void *) (grub_addr_t) page2offset (j);
+ }
+ else if (j == grub_xen_start_page_addr->nr_pages + 3)
+ {
+ pg[j - i * POINTERS_PER_PAGE] = page2offset (gntframe) | 7;
+ grub_xen_grant_table = (void *) (grub_addr_t) page2offset (j);
+ }
+ }
+
+ grub_xen_update_va_mapping (&window, 0, UVMF_INVLPG);
+
+ mmuext_op_t op[3];
+
+ op[0].cmd = MMUEXT_PIN_L1_TABLE + (NUMBER_OF_LEVELS - 1);
+ op[0].arg1.mfn = mfn_list[paging_start];
+ op[1].cmd = MMUEXT_NEW_BASEPTR;
+ op[1].arg1.mfn = mfn_list[paging_start];
+ op[2].cmd = MMUEXT_UNPIN_TABLE;
+ op[2].arg1.mfn = mfn_list[oldpgstart];
+
+ grub_xen_mmuext_op (op, 3, NULL, DOMID_SELF);
+
+ for (i = oldpgstart; i < oldpgend; i++)
+ grub_xen_update_va_mapping ((void *) (grub_addr_t) page2offset (i),
+ page2offset (mfn_list[i]) | 7, UVMF_INVLPG);
+ void *new_start_page, *new_mfn_list;
+ new_start_page = (void *) (grub_addr_t) page2offset (paging_start - 1);
+ grub_memcpy (new_start_page, grub_xen_start_page_addr, 4096);
+ grub_xen_start_page_addr = new_start_page;
+ new_mfn_list = (void *) (grub_addr_t)
+ page2offset (paging_start - 1
+ - ((grub_xen_start_page_addr->nr_pages
+ * sizeof (grub_uint64_t) + 4095) / 4096));
+ grub_memcpy (new_mfn_list, mfn_list, grub_xen_start_page_addr->nr_pages
+ * sizeof (grub_uint64_t));
+ grub_xen_start_page_addr->pt_base = page2offset (paging_start);
+ grub_xen_start_page_addr->mfn_list = (grub_addr_t) new_mfn_list;
+
+ grub_addr_t heap_start = grub_modules_get_end ();
+ grub_addr_t heap_end = (grub_addr_t) new_mfn_list;
+
+ grub_mm_init_region ((void *) heap_start, heap_end - heap_start);
+}
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ grub_uint64_t total_pages = grub_xen_start_page_addr->nr_pages;
+ grub_uint64_t usable_pages = grub_xen_start_page_addr->pt_base >> 12;
+ if (hook (0, page2offset (usable_pages), GRUB_MEMORY_AVAILABLE, hook_data))
+ return GRUB_ERR_NONE;
+
+ hook (page2offset (usable_pages), page2offset (total_pages - usable_pages),
+ GRUB_MEMORY_RESERVED, hook_data);
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+extern char _end[];
+
+void
+grub_machine_init (void)
+{
+#ifdef GRUB_MACHINE_XEN
+#ifdef __i386__
+ grub_xen_vm_assist (VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3);
+#endif
+#endif
+
+ grub_modbase = ALIGN_UP ((grub_addr_t) _end
+ + GRUB_KERNEL_MACHINE_MOD_GAP,
+ GRUB_KERNEL_MACHINE_MOD_ALIGN);
+
+#ifdef GRUB_MACHINE_XEN_PVH
+ grub_xen_setup_pvh ();
+#endif
+
+ grub_xen_setup_gnttab ();
+
+#ifdef GRUB_MACHINE_XEN
+ map_all_pages ();
+#endif
+
+ grub_console_init ();
+
+ grub_tsc_init ();
+
+ grub_xendisk_init ();
+
+ grub_boot_init ();
+}
+
+void
+grub_exit (void)
+{
+ struct sched_shutdown arg;
+
+ arg.reason = SHUTDOWN_poweroff;
+ grub_xen_sched_op (SCHEDOP_shutdown, &arg);
+ while (1);
+}
+
+void
+grub_machine_fini (int flags __attribute__ ((unused)))
+{
+ grub_xendisk_fini ();
+ grub_boot_fini ();
+}
diff --git a/grub-core/lib/LzFind.c b/grub-core/lib/LzFind.c
new file mode 100644
index 0000000..dcb20d9
--- /dev/null
+++ b/grub-core/lib/LzFind.c
@@ -0,0 +1,777 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (c) 1999-2008 Igor Pavlov
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
+ * to adapt it to GRUB's requirement.
+ *
+ * See <http://www.7-zip.org>, for more information about LZMA.
+ */
+
+
+#include <config.h>
+
+#include <string.h>
+
+#include <grub/lib/LzFind.h>
+#include <grub/lib/LzHash.h>
+
+#define kEmptyHashValue 0
+#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
+#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
+#define kNormalizeMask (~(kNormalizeStepMin - 1))
+#define kMaxHistorySize ((UInt32)3 << 30)
+
+#define kStartMaxLen 3
+
+static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
+{
+ if (!p->directInput)
+ {
+ alloc->Free(alloc, p->bufferBase);
+ p->bufferBase = 0;
+ }
+}
+
+/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */
+
+static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
+{
+ UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
+ if (p->directInput)
+ {
+ p->blockSize = blockSize;
+ return 1;
+ }
+ if (p->bufferBase == 0 || p->blockSize != blockSize)
+ {
+ LzInWindow_Free(p, alloc);
+ p->blockSize = blockSize;
+ p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize);
+ }
+ return (p->bufferBase != 0);
+}
+
+Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
+static Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 curindex) { return p->buffer[curindex]; }
+
+static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
+
+void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
+{
+ p->posLimit -= subValue;
+ p->pos -= subValue;
+ p->streamPos -= subValue;
+}
+
+static void MatchFinder_ReadBlock(CMatchFinder *p)
+{
+ if (p->streamEndWasReached || p->result != SZ_OK)
+ return;
+ for (;;)
+ {
+ Byte *dest = p->buffer + (p->streamPos - p->pos);
+ size_t size = (p->bufferBase + p->blockSize - dest);
+ if (size == 0)
+ return;
+ p->result = p->stream->Read(p->stream, dest, &size);
+ if (p->result != SZ_OK)
+ return;
+ if (size == 0)
+ {
+ p->streamEndWasReached = 1;
+ return;
+ }
+ p->streamPos += (UInt32)size;
+ if (p->streamPos - p->pos > p->keepSizeAfter)
+ return;
+ }
+}
+
+void MatchFinder_MoveBlock(CMatchFinder *p)
+{
+ memmove(p->bufferBase,
+ p->buffer - p->keepSizeBefore,
+ (size_t)(p->streamPos - p->pos + p->keepSizeBefore));
+ p->buffer = p->bufferBase + p->keepSizeBefore;
+}
+
+int MatchFinder_NeedMove(CMatchFinder *p)
+{
+ /* if (p->streamEndWasReached) return 0; */
+ return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
+}
+
+void MatchFinder_ReadIfRequired(CMatchFinder *p)
+{
+ if (p->streamEndWasReached)
+ return;
+ if (p->keepSizeAfter >= p->streamPos - p->pos)
+ MatchFinder_ReadBlock(p);
+}
+
+static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
+{
+ if (MatchFinder_NeedMove(p))
+ MatchFinder_MoveBlock(p);
+ MatchFinder_ReadBlock(p);
+}
+
+static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
+{
+ p->cutValue = 32;
+ p->btMode = 1;
+ p->numHashBytes = 4;
+ /* p->skipModeBits = 0; */
+ p->directInput = 0;
+ p->bigHash = 0;
+}
+
+#define kCrcPoly 0xEDB88320
+
+void MatchFinder_Construct(CMatchFinder *p)
+{
+ UInt32 i;
+ p->bufferBase = 0;
+ p->directInput = 0;
+ p->hash = 0;
+ MatchFinder_SetDefaultSettings(p);
+
+ for (i = 0; i < 256; i++)
+ {
+ UInt32 r = i;
+ int j;
+ for (j = 0; j < 8; j++)
+ r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
+ p->crc[i] = r;
+ }
+}
+
+static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->hash);
+ p->hash = 0;
+}
+
+void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc)
+{
+ MatchFinder_FreeThisClassMemory(p, alloc);
+ LzInWindow_Free(p, alloc);
+}
+
+static CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc)
+{
+ size_t sizeInBytes = (size_t)num * sizeof(CLzRef);
+ if (sizeInBytes / sizeof(CLzRef) != num)
+ return 0;
+ return (CLzRef *)alloc->Alloc(alloc, sizeInBytes);
+}
+
+int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
+ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
+ ISzAlloc *alloc)
+{
+ UInt32 sizeReserv;
+ if (historySize > kMaxHistorySize)
+ {
+ MatchFinder_Free(p, alloc);
+ return 0;
+ }
+ sizeReserv = historySize >> 1;
+ if (historySize > ((UInt32)2 << 30))
+ sizeReserv = historySize >> 2;
+ sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);
+
+ p->keepSizeBefore = historySize + keepAddBufferBefore + 1;
+ p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;
+ /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */
+ if (LzInWindow_Create(p, sizeReserv, alloc))
+ {
+ UInt32 newCyclicBufferSize = (historySize /* >> p->skipModeBits */) + 1;
+ UInt32 hs;
+ p->matchMaxLen = matchMaxLen;
+ {
+ p->fixedHashSize = 0;
+ if (p->numHashBytes == 2)
+ hs = (1 << 16) - 1;
+ else
+ {
+ hs = historySize - 1;
+ hs |= (hs >> 1);
+ hs |= (hs >> 2);
+ hs |= (hs >> 4);
+ hs |= (hs >> 8);
+ hs >>= 1;
+ /* hs >>= p->skipModeBits; */
+ hs |= 0xFFFF; /* don't change it! It's required for Deflate */
+ if (hs > (1 << 24))
+ {
+ if (p->numHashBytes == 3)
+ hs = (1 << 24) - 1;
+ else
+ hs >>= 1;
+ }
+ }
+ p->hashMask = hs;
+ hs++;
+ if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size;
+ if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size;
+ if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size;
+ hs += p->fixedHashSize;
+ }
+
+ {
+ UInt32 prevSize = p->hashSizeSum + p->numSons;
+ UInt32 newSize;
+ p->historySize = historySize;
+ p->hashSizeSum = hs;
+ p->cyclicBufferSize = newCyclicBufferSize;
+ p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize);
+ newSize = p->hashSizeSum + p->numSons;
+ if (p->hash != 0 && prevSize == newSize)
+ return 1;
+ MatchFinder_FreeThisClassMemory(p, alloc);
+ p->hash = AllocRefs(newSize, alloc);
+ if (p->hash != 0)
+ {
+ p->son = p->hash + p->hashSizeSum;
+ return 1;
+ }
+ }
+ }
+ MatchFinder_Free(p, alloc);
+ return 0;
+}
+
+static void MatchFinder_SetLimits(CMatchFinder *p)
+{
+ UInt32 limit = kMaxValForNormalize - p->pos;
+ UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
+ if (limit2 < limit)
+ limit = limit2;
+ limit2 = p->streamPos - p->pos;
+ if (limit2 <= p->keepSizeAfter)
+ {
+ if (limit2 > 0)
+ limit2 = 1;
+ }
+ else
+ limit2 -= p->keepSizeAfter;
+ if (limit2 < limit)
+ limit = limit2;
+ {
+ UInt32 lenLimit = p->streamPos - p->pos;
+ if (lenLimit > p->matchMaxLen)
+ lenLimit = p->matchMaxLen;
+ p->lenLimit = lenLimit;
+ }
+ p->posLimit = p->pos + limit;
+}
+
+void MatchFinder_Init(CMatchFinder *p)
+{
+ UInt32 i;
+ for(i = 0; i < p->hashSizeSum; i++)
+ p->hash[i] = kEmptyHashValue;
+ p->cyclicBufferPos = 0;
+ p->buffer = p->bufferBase;
+ p->pos = p->streamPos = p->cyclicBufferSize;
+ p->result = SZ_OK;
+ p->streamEndWasReached = 0;
+ MatchFinder_ReadBlock(p);
+ MatchFinder_SetLimits(p);
+}
+
+static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
+{
+ return (p->pos - p->historySize - 1) & kNormalizeMask;
+}
+
+void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
+{
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ UInt32 value = items[i];
+ if (value <= subValue)
+ value = kEmptyHashValue;
+ else
+ value -= subValue;
+ items[i] = value;
+ }
+}
+
+static void MatchFinder_Normalize(CMatchFinder *p)
+{
+ UInt32 subValue = MatchFinder_GetSubValue(p);
+ MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons);
+ MatchFinder_ReduceOffsets(p, subValue);
+}
+
+static void MatchFinder_CheckLimits(CMatchFinder *p)
+{
+ if (p->pos == kMaxValForNormalize)
+ MatchFinder_Normalize(p);
+ if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos)
+ MatchFinder_CheckAndMoveAndRead(p);
+ if (p->cyclicBufferPos == p->cyclicBufferSize)
+ p->cyclicBufferPos = 0;
+ MatchFinder_SetLimits(p);
+}
+
+static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
+ UInt32 *distances, UInt32 maxLen)
+{
+ son[_cyclicBufferPos] = curMatch;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ return distances;
+ {
+ const Byte *pb = cur - delta;
+ curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
+ if (pb[maxLen] == cur[maxLen] && *pb == *cur)
+ {
+ UInt32 len = 0;
+ while(++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ if (maxLen < len)
+ {
+ *distances++ = maxLen = len;
+ *distances++ = delta - 1;
+ if (len == lenLimit)
+ return distances;
+ }
+ }
+ }
+ }
+}
+
+UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
+ UInt32 *distances, UInt32 maxLen)
+{
+ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
+ CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
+ UInt32 len0 = 0, len1 = 0;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ {
+ *ptr0 = *ptr1 = kEmptyHashValue;
+ return distances;
+ }
+ {
+ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
+ const Byte *pb = cur - delta;
+ UInt32 len = (len0 < len1 ? len0 : len1);
+ if (pb[len] == cur[len])
+ {
+ if (++len != lenLimit && pb[len] == cur[len])
+ while(++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ if (maxLen < len)
+ {
+ *distances++ = maxLen = len;
+ *distances++ = delta - 1;
+ if (len == lenLimit)
+ {
+ *ptr1 = pair[0];
+ *ptr0 = pair[1];
+ return distances;
+ }
+ }
+ }
+ if (pb[len] < cur[len])
+ {
+ *ptr1 = curMatch;
+ ptr1 = pair + 1;
+ curMatch = *ptr1;
+ len1 = len;
+ }
+ else
+ {
+ *ptr0 = curMatch;
+ ptr0 = pair;
+ curMatch = *ptr0;
+ len0 = len;
+ }
+ }
+ }
+}
+
+static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
+{
+ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
+ CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
+ UInt32 len0 = 0, len1 = 0;
+ for (;;)
+ {
+ UInt32 delta = pos - curMatch;
+ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
+ {
+ *ptr0 = *ptr1 = kEmptyHashValue;
+ return;
+ }
+ {
+ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
+ const Byte *pb = cur - delta;
+ UInt32 len = (len0 < len1 ? len0 : len1);
+ if (pb[len] == cur[len])
+ {
+ while(++len != lenLimit)
+ if (pb[len] != cur[len])
+ break;
+ {
+ if (len == lenLimit)
+ {
+ *ptr1 = pair[0];
+ *ptr0 = pair[1];
+ return;
+ }
+ }
+ }
+ if (pb[len] < cur[len])
+ {
+ *ptr1 = curMatch;
+ ptr1 = pair + 1;
+ curMatch = *ptr1;
+ len1 = len;
+ }
+ else
+ {
+ *ptr0 = curMatch;
+ ptr0 = pair;
+ curMatch = *ptr0;
+ len0 = len;
+ }
+ }
+ }
+}
+
+#define MOVE_POS \
+ ++p->cyclicBufferPos; \
+ p->buffer++; \
+ if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
+
+#define MOVE_POS_RET MOVE_POS return offset;
+
+static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
+
+#define GET_MATCHES_HEADER2(minLen, ret_op) \
+ UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
+ lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
+ cur = p->buffer;
+
+#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
+#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue)
+
+#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
+
+#define GET_MATCHES_FOOTER(offset, maxLen) \
+ offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \
+ distances + offset, maxLen) - distances); MOVE_POS_RET;
+
+#define SKIP_FOOTER \
+ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
+
+static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 offset;
+ GET_MATCHES_HEADER(2)
+ HASH2_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ offset = 0;
+ GET_MATCHES_FOOTER(offset, 1)
+}
+
+UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 offset;
+ GET_MATCHES_HEADER(3)
+ HASH_ZIP_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ offset = 0;
+ GET_MATCHES_FOOTER(offset, 2)
+}
+
+static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 hash2Value, delta2, maxLen, offset;
+ GET_MATCHES_HEADER(3)
+
+ HASH3_CALC;
+
+ delta2 = p->pos - p->hash[hash2Value];
+ curMatch = p->hash[kFix3HashSize + hashValue];
+
+ p->hash[hash2Value] =
+ p->hash[kFix3HashSize + hashValue] = p->pos;
+
+
+ maxLen = 2;
+ offset = 0;
+ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
+ {
+ for (; maxLen != lenLimit; maxLen++)
+ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
+ break;
+ distances[0] = maxLen;
+ distances[1] = delta2 - 1;
+ offset = 2;
+ if (maxLen == lenLimit)
+ {
+ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
+ MOVE_POS_RET;
+ }
+ }
+ GET_MATCHES_FOOTER(offset, maxLen)
+}
+
+static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
+ GET_MATCHES_HEADER(4)
+
+ HASH4_CALC;
+
+ delta2 = p->pos - p->hash[ hash2Value];
+ delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
+ curMatch = p->hash[kFix4HashSize + hashValue];
+
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] =
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+
+ maxLen = 1;
+ offset = 0;
+ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
+ {
+ distances[0] = maxLen = 2;
+ distances[1] = delta2 - 1;
+ offset = 2;
+ }
+ if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
+ {
+ maxLen = 3;
+ distances[offset + 1] = delta3 - 1;
+ offset += 2;
+ delta2 = delta3;
+ }
+ if (offset != 0)
+ {
+ for (; maxLen != lenLimit; maxLen++)
+ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
+ break;
+ distances[offset - 2] = maxLen;
+ if (maxLen == lenLimit)
+ {
+ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
+ MOVE_POS_RET;
+ }
+ }
+ if (maxLen < 3)
+ maxLen = 3;
+ GET_MATCHES_FOOTER(offset, maxLen)
+}
+
+static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
+ GET_MATCHES_HEADER(4)
+
+ HASH4_CALC;
+
+ delta2 = p->pos - p->hash[ hash2Value];
+ delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
+ curMatch = p->hash[kFix4HashSize + hashValue];
+
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] =
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+
+ maxLen = 1;
+ offset = 0;
+ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
+ {
+ distances[0] = maxLen = 2;
+ distances[1] = delta2 - 1;
+ offset = 2;
+ }
+ if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
+ {
+ maxLen = 3;
+ distances[offset + 1] = delta3 - 1;
+ offset += 2;
+ delta2 = delta3;
+ }
+ if (offset != 0)
+ {
+ for (; maxLen != lenLimit; maxLen++)
+ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
+ break;
+ distances[offset - 2] = maxLen;
+ if (maxLen == lenLimit)
+ {
+ p->son[p->cyclicBufferPos] = curMatch;
+ MOVE_POS_RET;
+ }
+ }
+ if (maxLen < 3)
+ maxLen = 3;
+ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
+ distances + offset, maxLen) - (distances));
+ MOVE_POS_RET
+}
+
+UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+{
+ UInt32 offset;
+ GET_MATCHES_HEADER(3)
+ HASH_ZIP_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
+ distances, 2) - (distances));
+ MOVE_POS_RET
+}
+
+static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ SKIP_HEADER(2)
+ HASH2_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ SKIP_HEADER(3)
+ HASH_ZIP_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ UInt32 hash2Value;
+ SKIP_HEADER(3)
+ HASH3_CALC;
+ curMatch = p->hash[kFix3HashSize + hashValue];
+ p->hash[hash2Value] =
+ p->hash[kFix3HashSize + hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ UInt32 hash2Value, hash3Value;
+ SKIP_HEADER(4)
+ HASH4_CALC;
+ curMatch = p->hash[kFix4HashSize + hashValue];
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] = p->pos;
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+ SKIP_FOOTER
+ }
+ while (--num != 0);
+}
+
+static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ UInt32 hash2Value, hash3Value;
+ SKIP_HEADER(4)
+ HASH4_CALC;
+ curMatch = p->hash[kFix4HashSize + hashValue];
+ p->hash[ hash2Value] =
+ p->hash[kFix3HashSize + hash3Value] =
+ p->hash[kFix4HashSize + hashValue] = p->pos;
+ p->son[p->cyclicBufferPos] = curMatch;
+ MOVE_POS
+ }
+ while (--num != 0);
+}
+
+void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+{
+ do
+ {
+ SKIP_HEADER(3)
+ HASH_ZIP_CALC;
+ curMatch = p->hash[hashValue];
+ p->hash[hashValue] = p->pos;
+ p->son[p->cyclicBufferPos] = curMatch;
+ MOVE_POS
+ }
+ while (--num != 0);
+}
+
+void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
+{
+ vTable->Init = (Mf_Init_Func)MatchFinder_Init;
+ vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
+ vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
+ vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
+ if (!p->btMode)
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
+ }
+ else if (p->numHashBytes == 2)
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
+ }
+ else if (p->numHashBytes == 3)
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
+ }
+ else
+ {
+ vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
+ vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
+ }
+}
diff --git a/grub-core/lib/LzmaDec.c b/grub-core/lib/LzmaDec.c
new file mode 100644
index 0000000..952edb3
--- /dev/null
+++ b/grub-core/lib/LzmaDec.c
@@ -0,0 +1,1037 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (c) 1999-2008 Igor Pavlov
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
+ * to adapt it to GRUB's requirement.
+ *
+ * See <http://www.7-zip.org>, for more information about LZMA.
+ */
+
+#include <grub/lib/LzmaDec.h>
+
+#pragma GCC diagnostic ignored "-Wshadow"
+#include <grub/misc.h>
+#define memcpy grub_memcpy
+
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
+
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
+
+#define RC_INIT_SIZE 5
+
+#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
+
+#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
+#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
+#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
+#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
+ { UPDATE_0(p); i = (i + i); A0; } else \
+ { UPDATE_1(p); i = (i + i) + 1; A1; }
+#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;)
+
+#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); }
+#define TREE_DECODE(probs, limit, i) \
+ { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
+
+/* #define _LZMA_SIZE_OPT */
+
+#ifdef _LZMA_SIZE_OPT
+#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i)
+#else
+#define TREE_6_DECODE(probs, i) \
+ { i = 1; \
+ TREE_GET_BIT(probs, i); \
+ TREE_GET_BIT(probs, i); \
+ TREE_GET_BIT(probs, i); \
+ TREE_GET_BIT(probs, i); \
+ TREE_GET_BIT(probs, i); \
+ TREE_GET_BIT(probs, i); \
+ i -= 0x40; }
+#endif
+
+#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
+
+#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
+#define UPDATE_0_CHECK range = bound;
+#define UPDATE_1_CHECK range -= bound; code -= bound;
+#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
+ { UPDATE_0_CHECK; i = (i + i); A0; } else \
+ { UPDATE_1_CHECK; i = (i + i) + 1; A1; }
+#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)
+#define TREE_DECODE_CHECK(probs, limit, i) \
+ { i = 1; do { GET_BIT_CHECK(probs + i, i) } while(i < limit); i -= limit; }
+
+
+#define kNumPosBitsMax 4
+#define kNumPosStatesMax (1 << kNumPosBitsMax)
+
+#define kLenNumLowBits 3
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
+#define kLenNumMidBits 3
+#define kLenNumMidSymbols (1 << kLenNumMidBits)
+#define kLenNumHighBits 8
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
+
+#define LenChoice 0
+#define LenChoice2 (LenChoice + 1)
+#define LenLow (LenChoice2 + 1)
+#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
+#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
+#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
+
+
+#define kNumStates 12
+#define kNumLitStates 7
+
+#define kStartPosModelIndex 4
+#define kEndPosModelIndex 14
+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
+
+#define kNumPosSlotBits 6
+#define kNumLenToPosStates 4
+
+#define kNumAlignBits 4
+#define kAlignTableSize (1 << kNumAlignBits)
+
+#define kMatchMinLen 2
+#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
+
+#define IsMatch 0
+#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
+#define IsRepG0 (IsRep + kNumStates)
+#define IsRepG1 (IsRepG0 + kNumStates)
+#define IsRepG2 (IsRepG1 + kNumStates)
+#define IsRep0Long (IsRepG2 + kNumStates)
+#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
+#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
+#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
+#define LenCoder (Align + kAlignTableSize)
+#define RepLenCoder (LenCoder + kNumLenProbs)
+#define Literal (RepLenCoder + kNumLenProbs)
+
+#define LZMA_BASE_SIZE 1846
+#define LZMA_LIT_SIZE 768
+
+#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
+
+#if Literal != LZMA_BASE_SIZE
+StopCompilingDueBUG
+#endif
+
+/*
+#define LZMA_STREAM_WAS_FINISHED_ID (-1)
+#define LZMA_SPEC_LEN_OFFSET (-3)
+*/
+
+Byte kLiteralNextStates[kNumStates * 2] =
+{
+ 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5,
+ 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10
+};
+
+#define LZMA_DIC_MIN (1 << 12)
+
+/* First LZMA-symbol is always decoded.
+And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization
+Out:
+ Result:
+ 0 - OK
+ 1 - Error
+ p->remainLen:
+ < kMatchSpecLenStart : normal remain
+ = kMatchSpecLenStart : finished
+ = kMatchSpecLenStart + 1 : Flush marker
+ = kMatchSpecLenStart + 2 : State Init Marker
+*/
+
+static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
+{
+ CLzmaProb *probs = p->probs;
+
+ unsigned state = p->state;
+ UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
+ unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
+ unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1;
+ unsigned lc = p->prop.lc;
+
+ Byte *dic = p->dic;
+ SizeT dicBufSize = p->dicBufSize;
+ SizeT dicPos = p->dicPos;
+
+ UInt32 processedPos = p->processedPos;
+ UInt32 checkDicSize = p->checkDicSize;
+ unsigned len = 0;
+
+ const Byte *buf = p->buf;
+ UInt32 range = p->range;
+ UInt32 code = p->code;
+
+ do
+ {
+ CLzmaProb *prob;
+ UInt32 bound;
+ unsigned ttt;
+ unsigned posState = processedPos & pbMask;
+
+ prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
+ IF_BIT_0(prob)
+ {
+ unsigned symbol;
+ UPDATE_0(prob);
+ prob = probs + Literal;
+ if (checkDicSize != 0 || processedPos != 0)
+ prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) +
+ (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));
+
+ if (state < kNumLitStates)
+ {
+ symbol = 1;
+ do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
+ }
+ else
+ {
+ unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
+ unsigned offs = 0x100;
+ symbol = 1;
+ do
+ {
+ unsigned bit;
+ CLzmaProb *probLit;
+ matchByte <<= 1;
+ bit = (matchByte & offs);
+ probLit = prob + offs + bit + symbol;
+ GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
+ }
+ while (symbol < 0x100);
+ }
+ dic[dicPos++] = (Byte)symbol;
+ processedPos++;
+
+ state = kLiteralNextStates[state];
+ /* if (state < 4) state = 0; else if (state < 10) state -= 3; else state -= 6; */
+ continue;
+ }
+ else
+ {
+ UPDATE_1(prob);
+ prob = probs + IsRep + state;
+ IF_BIT_0(prob)
+ {
+ UPDATE_0(prob);
+ state += kNumStates;
+ prob = probs + LenCoder;
+ }
+ else
+ {
+ UPDATE_1(prob);
+ if (checkDicSize == 0 && processedPos == 0)
+ return SZ_ERROR_DATA;
+ prob = probs + IsRepG0 + state;
+ IF_BIT_0(prob)
+ {
+ UPDATE_0(prob);
+ prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
+ IF_BIT_0(prob)
+ {
+ UPDATE_0(prob);
+ dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
+ dicPos++;
+ processedPos++;
+ state = state < kNumLitStates ? 9 : 11;
+ continue;
+ }
+ UPDATE_1(prob);
+ }
+ else
+ {
+ UInt32 distance;
+ UPDATE_1(prob);
+ prob = probs + IsRepG1 + state;
+ IF_BIT_0(prob)
+ {
+ UPDATE_0(prob);
+ distance = rep1;
+ }
+ else
+ {
+ UPDATE_1(prob);
+ prob = probs + IsRepG2 + state;
+ IF_BIT_0(prob)
+ {
+ UPDATE_0(prob);
+ distance = rep2;
+ }
+ else
+ {
+ UPDATE_1(prob);
+ distance = rep3;
+ rep3 = rep2;
+ }
+ rep2 = rep1;
+ }
+ rep1 = rep0;
+ rep0 = distance;
+ }
+ state = state < kNumLitStates ? 8 : 11;
+ prob = probs + RepLenCoder;
+ }
+ {
+ unsigned limit, offset;
+ CLzmaProb *probLen = prob + LenChoice;
+ IF_BIT_0(probLen)
+ {
+ UPDATE_0(probLen);
+ probLen = prob + LenLow + (posState << kLenNumLowBits);
+ offset = 0;
+ limit = (1 << kLenNumLowBits);
+ }
+ else
+ {
+ UPDATE_1(probLen);
+ probLen = prob + LenChoice2;
+ IF_BIT_0(probLen)
+ {
+ UPDATE_0(probLen);
+ probLen = prob + LenMid + (posState << kLenNumMidBits);
+ offset = kLenNumLowSymbols;
+ limit = (1 << kLenNumMidBits);
+ }
+ else
+ {
+ UPDATE_1(probLen);
+ probLen = prob + LenHigh;
+ offset = kLenNumLowSymbols + kLenNumMidSymbols;
+ limit = (1 << kLenNumHighBits);
+ }
+ }
+ TREE_DECODE(probLen, limit, len);
+ len += offset;
+ }
+
+ if (state >= kNumStates)
+ {
+ UInt32 distance;
+ prob = probs + PosSlot +
+ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
+ TREE_6_DECODE(prob, distance);
+ if (distance >= kStartPosModelIndex)
+ {
+ unsigned posSlot = (unsigned)distance;
+ int numDirectBits = (int)(((distance >> 1) - 1));
+ distance = (2 | (distance & 1));
+ if (posSlot < kEndPosModelIndex)
+ {
+ distance <<= numDirectBits;
+ prob = probs + SpecPos + distance - posSlot - 1;
+ {
+ UInt32 mask = 1;
+ unsigned i = 1;
+ do
+ {
+ GET_BIT2(prob + i, i, ; , distance |= mask);
+ mask <<= 1;
+ }
+ while(--numDirectBits != 0);
+ }
+ }
+ else
+ {
+ numDirectBits -= kNumAlignBits;
+ do
+ {
+ NORMALIZE
+ range >>= 1;
+
+ {
+ UInt32 t;
+ code -= range;
+ t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
+ distance = (distance << 1) + (t + 1);
+ code += range & t;
+ }
+ /*
+ distance <<= 1;
+ if (code >= range)
+ {
+ code -= range;
+ distance |= 1;
+ }
+ */
+ }
+ while (--numDirectBits != 0);
+ prob = probs + Align;
+ distance <<= kNumAlignBits;
+ {
+ unsigned i = 1;
+ GET_BIT2(prob + i, i, ; , distance |= 1);
+ GET_BIT2(prob + i, i, ; , distance |= 2);
+ GET_BIT2(prob + i, i, ; , distance |= 4);
+ GET_BIT2(prob + i, i, ; , distance |= 8);
+ }
+ if (distance == (UInt32)0xFFFFFFFF)
+ {
+ len += kMatchSpecLenStart;
+ state -= kNumStates;
+ break;
+ }
+ }
+ }
+ rep3 = rep2;
+ rep2 = rep1;
+ rep1 = rep0;
+ rep0 = distance + 1;
+ if (checkDicSize == 0)
+ {
+ if (distance >= processedPos)
+ return SZ_ERROR_DATA;
+ }
+ else if (distance >= checkDicSize)
+ return SZ_ERROR_DATA;
+ state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
+ /* state = kLiteralNextStates[state]; */
+ }
+
+ len += kMatchMinLen;
+
+ {
+ SizeT rem = limit - dicPos;
+ unsigned curLen = ((rem < len) ? (unsigned)rem : len);
+ SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0);
+
+ processedPos += curLen;
+
+ len -= curLen;
+ if (pos + curLen <= dicBufSize)
+ {
+ Byte *dest = dic + dicPos;
+ ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
+ const Byte *lim = dest + curLen;
+ dicPos += curLen;
+ do
+ *(dest) = (Byte)*(dest + src);
+ while (++dest != lim);
+ }
+ else
+ {
+ do
+ {
+ dic[dicPos++] = dic[pos];
+ if (++pos == dicBufSize)
+ pos = 0;
+ }
+ while (--curLen != 0);
+ }
+ }
+ }
+ }
+ while (dicPos < limit && buf < bufLimit);
+ NORMALIZE;
+ p->buf = buf;
+ p->range = range;
+ p->code = code;
+ p->remainLen = len;
+ p->dicPos = dicPos;
+ p->processedPos = processedPos;
+ p->reps[0] = rep0;
+ p->reps[1] = rep1;
+ p->reps[2] = rep2;
+ p->reps[3] = rep3;
+ p->state = state;
+
+ return SZ_OK;
+}
+
+static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
+{
+ if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)
+ {
+ Byte *dic = p->dic;
+ SizeT dicPos = p->dicPos;
+ SizeT dicBufSize = p->dicBufSize;
+ unsigned len = p->remainLen;
+ UInt32 rep0 = p->reps[0];
+ if (limit - dicPos < len)
+ len = (unsigned)(limit - dicPos);
+
+ if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
+ p->checkDicSize = p->prop.dicSize;
+
+ p->processedPos += len;
+ p->remainLen -= len;
+ while (len-- != 0)
+ {
+ dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
+ dicPos++;
+ }
+ p->dicPos = dicPos;
+ }
+}
+
+/* LzmaDec_DecodeReal2 decodes LZMA-symbols and sets p->needFlush and p->needInit, if required. */
+
+static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
+{
+ do
+ {
+ SizeT limit2 = limit;
+ if (p->checkDicSize == 0)
+ {
+ UInt32 rem = p->prop.dicSize - p->processedPos;
+ if (limit - p->dicPos > rem)
+ limit2 = p->dicPos + rem;
+ }
+ RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit));
+ if (p->processedPos >= p->prop.dicSize)
+ p->checkDicSize = p->prop.dicSize;
+ LzmaDec_WriteRem(p, limit);
+ }
+ while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
+
+ if (p->remainLen > kMatchSpecLenStart)
+ {
+ p->remainLen = kMatchSpecLenStart;
+ }
+ return 0;
+}
+
+typedef enum
+{
+ DUMMY_ERROR, /* unexpected end of input stream */
+ DUMMY_LIT,
+ DUMMY_MATCH,
+ DUMMY_REP
+} ELzmaDummy;
+
+static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)
+{
+ UInt32 range = p->range;
+ UInt32 code = p->code;
+ const Byte *bufLimit = buf + inSize;
+ CLzmaProb *probs = p->probs;
+ unsigned state = p->state;
+ ELzmaDummy res;
+
+ {
+ CLzmaProb *prob;
+ UInt32 bound;
+ unsigned ttt;
+ unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1);
+
+ prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK
+
+ /* if (bufLimit - buf >= 7) return DUMMY_LIT; */
+
+ prob = probs + Literal;
+ if (p->checkDicSize != 0 || p->processedPos != 0)
+ prob += (LZMA_LIT_SIZE *
+ ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
+ (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
+
+ if (state < kNumLitStates)
+ {
+ unsigned symbol = 1;
+ do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100);
+ }
+ else
+ {
+ unsigned matchByte = p->dic[p->dicPos - p->reps[0] +
+ ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)];
+ unsigned offs = 0x100;
+ unsigned symbol = 1;
+ do
+ {
+ unsigned bit;
+ CLzmaProb *probLit;
+ matchByte <<= 1;
+ bit = (matchByte & offs);
+ probLit = prob + offs + bit + symbol;
+ GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)
+ }
+ while (symbol < 0x100);
+ }
+ res = DUMMY_LIT;
+ }
+ else
+ {
+ unsigned len;
+ UPDATE_1_CHECK;
+
+ prob = probs + IsRep + state;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK;
+ state = 0;
+ prob = probs + LenCoder;
+ res = DUMMY_MATCH;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ res = DUMMY_REP;
+ prob = probs + IsRepG0 + state;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK;
+ prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK;
+ NORMALIZE_CHECK;
+ return DUMMY_REP;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ }
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ prob = probs + IsRepG1 + state;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ prob = probs + IsRepG2 + state;
+ IF_BIT_0_CHECK(prob)
+ {
+ UPDATE_0_CHECK;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ }
+ }
+ }
+ state = kNumStates;
+ prob = probs + RepLenCoder;
+ }
+ {
+ unsigned limit, offset;
+ CLzmaProb *probLen = prob + LenChoice;
+ IF_BIT_0_CHECK(probLen)
+ {
+ UPDATE_0_CHECK;
+ probLen = prob + LenLow + (posState << kLenNumLowBits);
+ offset = 0;
+ limit = 1 << kLenNumLowBits;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ probLen = prob + LenChoice2;
+ IF_BIT_0_CHECK(probLen)
+ {
+ UPDATE_0_CHECK;
+ probLen = prob + LenMid + (posState << kLenNumMidBits);
+ offset = kLenNumLowSymbols;
+ limit = 1 << kLenNumMidBits;
+ }
+ else
+ {
+ UPDATE_1_CHECK;
+ probLen = prob + LenHigh;
+ offset = kLenNumLowSymbols + kLenNumMidSymbols;
+ limit = 1 << kLenNumHighBits;
+ }
+ }
+ TREE_DECODE_CHECK(probLen, limit, len);
+ len += offset;
+ }
+
+ if (state < 4)
+ {
+ unsigned posSlot;
+ prob = probs + PosSlot +
+ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
+ kNumPosSlotBits);
+ TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);
+ if (posSlot >= kStartPosModelIndex)
+ {
+ int numDirectBits = ((posSlot >> 1) - 1);
+
+ /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */
+
+ if (posSlot < kEndPosModelIndex)
+ {
+ prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1;
+ }
+ else
+ {
+ numDirectBits -= kNumAlignBits;
+ do
+ {
+ NORMALIZE_CHECK
+ range >>= 1;
+ code -= range & (((code - range) >> 31) - 1);
+ /* if (code >= range) code -= range; */
+ }
+ while (--numDirectBits != 0);
+ prob = probs + Align;
+ numDirectBits = kNumAlignBits;
+ }
+ {
+ unsigned i = 1;
+ do
+ {
+ GET_BIT_CHECK(prob + i, i);
+ }
+ while(--numDirectBits != 0);
+ }
+ }
+ }
+ }
+ }
+ NORMALIZE_CHECK;
+ return res;
+}
+
+
+static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
+{
+ p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]);
+ p->range = 0xFFFFFFFF;
+ p->needFlush = 0;
+}
+
+static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
+{
+ p->needFlush = 1;
+ p->remainLen = 0;
+ p->tempBufSize = 0;
+
+ if (initDic)
+ {
+ p->processedPos = 0;
+ p->checkDicSize = 0;
+ p->needInitState = 1;
+ }
+ if (initState)
+ p->needInitState = 1;
+}
+
+void LzmaDec_Init(CLzmaDec *p)
+{
+ p->dicPos = 0;
+ LzmaDec_InitDicAndState(p, True, True);
+}
+
+static void LzmaDec_InitStateReal(CLzmaDec *p)
+{
+ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp));
+ UInt32 i;
+ CLzmaProb *probs = p->probs;
+ for (i = 0; i < numProbs; i++)
+ probs[i] = kBitModelTotal >> 1;
+ p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;
+ p->state = 0;
+ p->needInitState = 0;
+}
+
+SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
+ ELzmaFinishMode finishMode, ELzmaStatus *status)
+{
+ SizeT inSize = *srcLen;
+ (*srcLen) = 0;
+ LzmaDec_WriteRem(p, dicLimit);
+
+ *status = LZMA_STATUS_NOT_SPECIFIED;
+
+ while (p->remainLen != kMatchSpecLenStart)
+ {
+ int checkEndMarkNow;
+
+ if (p->needFlush != 0)
+ {
+ for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)
+ p->tempBuf[p->tempBufSize++] = *src++;
+ if (p->tempBufSize < RC_INIT_SIZE)
+ {
+ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+ return SZ_OK;
+ }
+ if (p->tempBuf[0] != 0)
+ return SZ_ERROR_DATA;
+
+ LzmaDec_InitRc(p, p->tempBuf);
+ p->tempBufSize = 0;
+ }
+
+ checkEndMarkNow = 0;
+ if (p->dicPos >= dicLimit)
+ {
+ if (p->remainLen == 0 && p->code == 0)
+ {
+ *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK;
+ return SZ_OK;
+ }
+ if (finishMode == LZMA_FINISH_ANY)
+ {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_OK;
+ }
+ if (p->remainLen != 0)
+ {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_ERROR_DATA;
+ }
+ checkEndMarkNow = 1;
+ }
+
+ if (p->needInitState)
+ LzmaDec_InitStateReal(p);
+
+ if (p->tempBufSize == 0)
+ {
+ SizeT processed;
+ const Byte *bufLimit;
+ if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
+ {
+ int dummyRes = LzmaDec_TryDummy(p, src, inSize);
+ if (dummyRes == DUMMY_ERROR)
+ {
+ memcpy(p->tempBuf, src, inSize);
+ p->tempBufSize = (unsigned)inSize;
+ (*srcLen) += inSize;
+ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+ return SZ_OK;
+ }
+ if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
+ {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_ERROR_DATA;
+ }
+ bufLimit = src;
+ }
+ else
+ bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;
+ p->buf = src;
+ if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)
+ return SZ_ERROR_DATA;
+ processed = p->buf - src;
+ (*srcLen) += processed;
+ src += processed;
+ inSize -= processed;
+ }
+ else
+ {
+ unsigned rem = p->tempBufSize, lookAhead = 0;
+ while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize)
+ p->tempBuf[rem++] = src[lookAhead++];
+ p->tempBufSize = rem;
+ if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
+ {
+ int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);
+ if (dummyRes == DUMMY_ERROR)
+ {
+ (*srcLen) += lookAhead;
+ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+ return SZ_OK;
+ }
+ if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
+ {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_ERROR_DATA;
+ }
+ }
+ p->buf = p->tempBuf;
+ if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0)
+ return SZ_ERROR_DATA;
+ lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf));
+ (*srcLen) += lookAhead;
+ src += lookAhead;
+ inSize -= lookAhead;
+ p->tempBufSize = 0;
+ }
+ }
+ if (p->code == 0)
+ *status = LZMA_STATUS_FINISHED_WITH_MARK;
+ return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
+}
+
+SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
+{
+ SizeT outSize = *destLen;
+ SizeT inSize = *srcLen;
+ *srcLen = *destLen = 0;
+ for (;;)
+ {
+ SizeT inSizeCur = inSize, outSizeCur, dicPos;
+ ELzmaFinishMode curFinishMode;
+ SRes res;
+ if (p->dicPos == p->dicBufSize)
+ p->dicPos = 0;
+ dicPos = p->dicPos;
+ if (outSize > p->dicBufSize - dicPos)
+ {
+ outSizeCur = p->dicBufSize;
+ curFinishMode = LZMA_FINISH_ANY;
+ }
+ else
+ {
+ outSizeCur = dicPos + outSize;
+ curFinishMode = finishMode;
+ }
+
+ res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
+ src += inSizeCur;
+ inSize -= inSizeCur;
+ *srcLen += inSizeCur;
+ outSizeCur = p->dicPos - dicPos;
+ memcpy(dest, p->dic + dicPos, outSizeCur);
+ dest += outSizeCur;
+ outSize -= outSizeCur;
+ *destLen += outSizeCur;
+ if (res != 0)
+ return res;
+ if (outSizeCur == 0 || outSize == 0)
+ return SZ_OK;
+ }
+}
+
+void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->probs);
+ p->probs = 0;
+}
+
+static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->dic);
+ p->dic = 0;
+}
+
+void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
+{
+ LzmaDec_FreeProbs(p, alloc);
+ LzmaDec_FreeDict(p, alloc);
+}
+
+SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
+{
+ UInt32 dicSize;
+ Byte d;
+
+ if (size < LZMA_PROPS_SIZE)
+ return SZ_ERROR_UNSUPPORTED;
+ else
+ dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
+
+ if (dicSize < LZMA_DIC_MIN)
+ dicSize = LZMA_DIC_MIN;
+ p->dicSize = dicSize;
+
+ d = data[0];
+ if (d >= (9 * 5 * 5))
+ return SZ_ERROR_UNSUPPORTED;
+
+ p->lc = d % 9;
+ d /= 9;
+ p->pb = d / 5;
+ p->lp = d % 5;
+
+ return SZ_OK;
+}
+
+static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
+{
+ UInt32 numProbs = LzmaProps_GetNumProbs(propNew);
+ if (p->probs == 0 || numProbs != p->numProbs)
+ {
+ LzmaDec_FreeProbs(p, alloc);
+ p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb));
+ p->numProbs = numProbs;
+ if (p->probs == 0)
+ return SZ_ERROR_MEM;
+ }
+ return SZ_OK;
+}
+
+SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+{
+ CLzmaProps propNew;
+ RINOK(LzmaProps_Decode(&propNew, props, propsSize));
+ RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+ p->prop = propNew;
+ return SZ_OK;
+}
+
+SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+{
+ CLzmaProps propNew;
+ SizeT dicBufSize;
+ RINOK(LzmaProps_Decode(&propNew, props, propsSize));
+ RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+ dicBufSize = propNew.dicSize;
+ if (p->dic == 0 || dicBufSize != p->dicBufSize)
+ {
+ LzmaDec_FreeDict(p, alloc);
+ p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
+ if (p->dic == 0)
+ {
+ LzmaDec_FreeProbs(p, alloc);
+ return SZ_ERROR_MEM;
+ }
+ }
+ p->dicBufSize = dicBufSize;
+ p->prop = propNew;
+ return SZ_OK;
+}
+
+SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+ ELzmaStatus *status, ISzAlloc *alloc)
+{
+ CLzmaDec p;
+ SRes res;
+ SizeT inSize = *srcLen;
+ SizeT outSize = *destLen;
+ *srcLen = *destLen = 0;
+ if (inSize < RC_INIT_SIZE)
+ return SZ_ERROR_INPUT_EOF;
+
+ LzmaDec_Construct(&p);
+ res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc);
+ if (res != 0)
+ return res;
+ p.dic = dest;
+ p.dicBufSize = outSize;
+
+ LzmaDec_Init(&p);
+
+ *srcLen = inSize;
+ res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
+
+ if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
+ res = SZ_ERROR_INPUT_EOF;
+
+ (*destLen) = p.dicPos;
+ LzmaDec_FreeProbs(&p, alloc);
+ return res;
+}
diff --git a/grub-core/lib/LzmaEnc.c b/grub-core/lib/LzmaEnc.c
new file mode 100644
index 0000000..52b3315
--- /dev/null
+++ b/grub-core/lib/LzmaEnc.c
@@ -0,0 +1,2250 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (c) 1999-2008 Igor Pavlov
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
+ * to adapt it to GRUB's requirement.
+ *
+ * See <http://www.7-zip.org>, for more information about LZMA.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include <grub/lib/LzmaEnc.h>
+
+#include <grub/lib/LzFind.h>
+#ifdef COMPRESS_MF_MT
+#include <grub/lib/LzFindMt.h>
+#endif
+
+/* #define SHOW_STAT */
+/* #define SHOW_STAT2 */
+
+#ifdef SHOW_STAT
+static int ttt = 0;
+#endif
+
+#define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1)
+
+#define kBlockSize (9 << 10)
+#define kUnpackBlockSize (1 << 18)
+#define kMatchArraySize (1 << 21)
+#define kMatchRecordMaxSize ((LZMA_MATCH_LEN_MAX * 2 + 3) * LZMA_MATCH_LEN_MAX)
+
+#define kNumMaxDirectBits (31)
+
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
+
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
+#define kProbInitValue (kBitModelTotal >> 1)
+
+#define kNumMoveReducingBits 4
+#define kNumBitPriceShiftBits 4
+#define kBitPrice (1 << kNumBitPriceShiftBits)
+
+void LzmaEncProps_Init(CLzmaEncProps *p)
+{
+ p->level = 5;
+ p->dictSize = p->mc = 0;
+ p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1;
+ p->writeEndMark = 0;
+}
+
+void LzmaEncProps_Normalize(CLzmaEncProps *p)
+{
+ int level = p->level;
+ if (level < 0) level = 5;
+ p->level = level;
+ if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26)));
+ if (p->lc < 0) p->lc = 3;
+ if (p->lp < 0) p->lp = 0;
+ if (p->pb < 0) p->pb = 2;
+ if (p->algo < 0) p->algo = (level < 5 ? 0 : 1);
+ if (p->fb < 0) p->fb = (level < 7 ? 32 : 64);
+ if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1);
+ if (p->numHashBytes < 0) p->numHashBytes = 4;
+ if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1);
+ if (p->numThreads < 0) p->numThreads = ((p->btMode && p->algo) ? 2 : 1);
+}
+
+UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
+{
+ CLzmaEncProps props = *props2;
+ LzmaEncProps_Normalize(&props);
+ return props.dictSize;
+}
+
+/* #define LZMA_LOG_BSR */
+/* Define it for Intel's CPU */
+
+
+#ifdef LZMA_LOG_BSR
+
+#define kDicLogSizeMaxCompress 30
+
+#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
+
+UInt32 GetPosSlot1(UInt32 pos)
+{
+ UInt32 res;
+ BSR2_RET(pos, res);
+ return res;
+}
+#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }
+#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); }
+
+#else
+
+#define kNumLogBits (9 + (int)sizeof(size_t) / 2)
+#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
+
+static void LzmaEnc_FastPosInit(Byte *g_FastPos)
+{
+ int c = 2, slotFast;
+ g_FastPos[0] = 0;
+ g_FastPos[1] = 1;
+
+ for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++)
+ {
+ UInt32 k = (1 << ((slotFast >> 1) - 1));
+ UInt32 j;
+ for (j = 0; j < k; j++, c++)
+ g_FastPos[c] = (Byte)slotFast;
+ }
+}
+
+#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
+ (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \
+ res = p->g_FastPos[pos >> i] + (i * 2); }
+/*
+#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \
+ p->g_FastPos[pos >> 6] + 12 : \
+ p->g_FastPos[pos >> (6 + kNumLogBits - 1)] + (6 + (kNumLogBits - 1)) * 2; }
+*/
+
+#define GetPosSlot1(pos) p->g_FastPos[pos]
+#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }
+#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos]; else BSR2_RET(pos, res); }
+
+#endif
+
+
+#define LZMA_NUM_REPS 4
+
+typedef unsigned CState;
+
+typedef struct _COptimal
+{
+ UInt32 price;
+
+ CState state;
+ int prev1IsChar;
+ int prev2;
+
+ UInt32 posPrev2;
+ UInt32 backPrev2;
+
+ UInt32 posPrev;
+ UInt32 backPrev;
+ UInt32 backs[LZMA_NUM_REPS];
+} COptimal;
+
+#define kNumOpts (1 << 12)
+
+#define kNumLenToPosStates 4
+#define kNumPosSlotBits 6
+#define kDicLogSizeMin 0
+#define kDicLogSizeMax 32
+#define kDistTableSizeMax (kDicLogSizeMax * 2)
+
+
+#define kNumAlignBits 4
+#define kAlignTableSize (1 << kNumAlignBits)
+#define kAlignMask (kAlignTableSize - 1)
+
+#define kStartPosModelIndex 4
+#define kEndPosModelIndex 14
+#define kNumPosModels (kEndPosModelIndex - kStartPosModelIndex)
+
+#define kNumFullDistances (1 << (kEndPosModelIndex / 2))
+
+#ifdef _LZMA_PROB32
+#define CLzmaProb UInt32
+#else
+#define CLzmaProb UInt16
+#endif
+
+#define LZMA_PB_MAX 4
+#define LZMA_LC_MAX 8
+#define LZMA_LP_MAX 4
+
+#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX)
+
+
+#define kLenNumLowBits 3
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
+#define kLenNumMidBits 3
+#define kLenNumMidSymbols (1 << kLenNumMidBits)
+#define kLenNumHighBits 8
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
+
+#define kLenNumSymbolsTotal (kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
+
+#define LZMA_MATCH_LEN_MIN 2
+#define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1)
+
+#define kNumStates 12
+
+typedef struct
+{
+ CLzmaProb choice;
+ CLzmaProb choice2;
+ CLzmaProb low[LZMA_NUM_PB_STATES_MAX << kLenNumLowBits];
+ CLzmaProb mid[LZMA_NUM_PB_STATES_MAX << kLenNumMidBits];
+ CLzmaProb high[kLenNumHighSymbols];
+} CLenEnc;
+
+typedef struct
+{
+ CLenEnc p;
+ UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];
+ UInt32 tableSize;
+ UInt32 counters[LZMA_NUM_PB_STATES_MAX];
+} CLenPriceEnc;
+
+typedef struct _CRangeEnc
+{
+ UInt32 range;
+ Byte cache;
+ UInt64 low;
+ UInt64 cacheSize;
+ Byte *buf;
+ Byte *bufLim;
+ Byte *bufBase;
+ ISeqOutStream *outStream;
+ UInt64 processed;
+ SRes res;
+} CRangeEnc;
+
+typedef struct _CSeqInStreamBuf
+{
+ ISeqInStream funcTable;
+ const Byte *data;
+ SizeT rem;
+} CSeqInStreamBuf;
+
+static SRes MyRead(void *pp, void *data, size_t *size)
+{
+ size_t curSize = *size;
+ CSeqInStreamBuf *p = (CSeqInStreamBuf *)pp;
+ if (p->rem < curSize)
+ curSize = p->rem;
+ memcpy(data, p->data, curSize);
+ p->rem -= curSize;
+ p->data += curSize;
+ *size = curSize;
+ return SZ_OK;
+}
+
+typedef struct
+{
+ CLzmaProb *litProbs;
+
+ CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX];
+ CLzmaProb isRep[kNumStates];
+ CLzmaProb isRepG0[kNumStates];
+ CLzmaProb isRepG1[kNumStates];
+ CLzmaProb isRepG2[kNumStates];
+ CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];
+
+ CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
+ CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
+ CLzmaProb posAlignEncoder[1 << kNumAlignBits];
+
+ CLenPriceEnc lenEnc;
+ CLenPriceEnc repLenEnc;
+
+ UInt32 reps[LZMA_NUM_REPS];
+ UInt32 state;
+} CSaveState;
+
+typedef struct _CLzmaEnc
+{
+ IMatchFinder matchFinder;
+ void *matchFinderObj;
+
+ #ifdef COMPRESS_MF_MT
+ Bool mtMode;
+ CMatchFinderMt matchFinderMt;
+ #endif
+
+ CMatchFinder matchFinderBase;
+
+ #ifdef COMPRESS_MF_MT
+ Byte pad[128];
+ #endif
+
+ UInt32 optimumEndIndex;
+ UInt32 optimumCurrentIndex;
+
+ Bool longestMatchWasFound;
+ UInt32 longestMatchLength;
+ UInt32 numDistancePairs;
+
+ COptimal opt[kNumOpts];
+
+ #ifndef LZMA_LOG_BSR
+ Byte g_FastPos[1 << kNumLogBits];
+ #endif
+
+ UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
+ UInt32 matchDistances[LZMA_MATCH_LEN_MAX * 2 + 2 + 1];
+ UInt32 numFastBytes;
+ UInt32 additionalOffset;
+ UInt32 reps[LZMA_NUM_REPS];
+ UInt32 state;
+
+ UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
+ UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances];
+ UInt32 alignPrices[kAlignTableSize];
+ UInt32 alignPriceCount;
+
+ UInt32 distTableSize;
+
+ unsigned lc, lp, pb;
+ unsigned lpMask, pbMask;
+
+ CLzmaProb *litProbs;
+
+ CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX];
+ CLzmaProb isRep[kNumStates];
+ CLzmaProb isRepG0[kNumStates];
+ CLzmaProb isRepG1[kNumStates];
+ CLzmaProb isRepG2[kNumStates];
+ CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];
+
+ CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
+ CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
+ CLzmaProb posAlignEncoder[1 << kNumAlignBits];
+
+ CLenPriceEnc lenEnc;
+ CLenPriceEnc repLenEnc;
+
+ unsigned lclp;
+
+ Bool fastMode;
+
+ CRangeEnc rc;
+
+ Bool writeEndMark;
+ UInt64 nowPos64;
+ UInt32 matchPriceCount;
+ Bool finished;
+ Bool multiThread;
+
+ SRes result;
+ UInt32 dictSize;
+ UInt32 matchFinderCycles;
+
+ ISeqInStream *inStream;
+ CSeqInStreamBuf seqBufInStream;
+
+ CSaveState saveState;
+} CLzmaEnc;
+
+SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ CLzmaEncProps props = *props2;
+ LzmaEncProps_Normalize(&props);
+
+ if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX ||
+ props.dictSize > (1U << kDicLogSizeMaxCompress) || props.dictSize > (1 << 30))
+ return SZ_ERROR_PARAM;
+ p->dictSize = props.dictSize;
+ p->matchFinderCycles = props.mc;
+ {
+ unsigned fb = props.fb;
+ if (fb < 5)
+ fb = 5;
+ if (fb > LZMA_MATCH_LEN_MAX)
+ fb = LZMA_MATCH_LEN_MAX;
+ p->numFastBytes = fb;
+ }
+ p->lc = props.lc;
+ p->lp = props.lp;
+ p->pb = props.pb;
+ p->fastMode = (props.algo == 0);
+ p->matchFinderBase.btMode = props.btMode;
+ {
+ UInt32 numHashBytes = 4;
+ if (props.btMode)
+ {
+ if (props.numHashBytes < 2)
+ numHashBytes = 2;
+ else if (props.numHashBytes < 4)
+ numHashBytes = props.numHashBytes;
+ }
+ p->matchFinderBase.numHashBytes = numHashBytes;
+ }
+
+ p->matchFinderBase.cutValue = props.mc;
+
+ p->writeEndMark = props.writeEndMark;
+
+ #ifdef COMPRESS_MF_MT
+ /*
+ if (newMultiThread != _multiThread)
+ {
+ ReleaseMatchFinder();
+ _multiThread = newMultiThread;
+ }
+ */
+ p->multiThread = (props.numThreads > 1);
+ #endif
+
+ return SZ_OK;
+}
+
+static const int kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5};
+static const int kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};
+static const int kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};
+static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};
+
+/*
+ void UpdateChar() { Index = kLiteralNextStates[Index]; }
+ void UpdateMatch() { Index = kMatchNextStates[Index]; }
+ void UpdateRep() { Index = kRepNextStates[Index]; }
+ void UpdateShortRep() { Index = kShortRepNextStates[Index]; }
+*/
+
+#define IsCharState(s) ((s) < 7)
+
+
+#define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1)
+
+#define kInfinityPrice (1 << 30)
+
+static void RangeEnc_Construct(CRangeEnc *p)
+{
+ p->outStream = 0;
+ p->bufBase = 0;
+}
+
+#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize)
+
+#define RC_BUF_SIZE (1 << 16)
+static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)
+{
+ if (p->bufBase == 0)
+ {
+ p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE);
+ if (p->bufBase == 0)
+ return 0;
+ p->bufLim = p->bufBase + RC_BUF_SIZE;
+ }
+ return 1;
+}
+
+static void RangeEnc_Free(CRangeEnc *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->bufBase);
+ p->bufBase = 0;
+}
+
+static void RangeEnc_Init(CRangeEnc *p)
+{
+ /* Stream.Init(); */
+ p->low = 0;
+ p->range = 0xFFFFFFFF;
+ p->cacheSize = 1;
+ p->cache = 0;
+
+ p->buf = p->bufBase;
+
+ p->processed = 0;
+ p->res = SZ_OK;
+}
+
+static void RangeEnc_FlushStream(CRangeEnc *p)
+{
+ size_t num;
+ if (p->res != SZ_OK)
+ return;
+ num = p->buf - p->bufBase;
+ if (num != p->outStream->Write(p->outStream, p->bufBase, num))
+ p->res = SZ_ERROR_WRITE;
+ p->processed += num;
+ p->buf = p->bufBase;
+}
+
+static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p)
+{
+ if ((UInt32)p->low < (UInt32)0xFF000000 || (int)(p->low >> 32) != 0)
+ {
+ Byte temp = p->cache;
+ do
+ {
+ Byte *buf = p->buf;
+ *buf++ = (Byte)(temp + (Byte)(p->low >> 32));
+ p->buf = buf;
+ if (buf == p->bufLim)
+ RangeEnc_FlushStream(p);
+ temp = 0xFF;
+ }
+ while (--p->cacheSize != 0);
+ p->cache = (Byte)((UInt32)p->low >> 24);
+ }
+ p->cacheSize++;
+ p->low = (UInt32)p->low << 8;
+}
+
+static void RangeEnc_FlushData(CRangeEnc *p)
+{
+ int i;
+ for (i = 0; i < 5; i++)
+ RangeEnc_ShiftLow(p);
+}
+
+static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits)
+{
+ do
+ {
+ p->range >>= 1;
+ p->low += p->range & (0 - ((value >> --numBits) & 1));
+ if (p->range < kTopValue)
+ {
+ p->range <<= 8;
+ RangeEnc_ShiftLow(p);
+ }
+ }
+ while (numBits != 0);
+}
+
+static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol)
+{
+ UInt32 ttt = *prob;
+ UInt32 newBound = (p->range >> kNumBitModelTotalBits) * ttt;
+ if (symbol == 0)
+ {
+ p->range = newBound;
+ ttt += (kBitModelTotal - ttt) >> kNumMoveBits;
+ }
+ else
+ {
+ p->low += newBound;
+ p->range -= newBound;
+ ttt -= ttt >> kNumMoveBits;
+ }
+ *prob = (CLzmaProb)ttt;
+ if (p->range < kTopValue)
+ {
+ p->range <<= 8;
+ RangeEnc_ShiftLow(p);
+ }
+}
+
+static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol)
+{
+ symbol |= 0x100;
+ do
+ {
+ RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1);
+ symbol <<= 1;
+ }
+ while (symbol < 0x10000);
+}
+
+static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte)
+{
+ UInt32 offs = 0x100;
+ symbol |= 0x100;
+ do
+ {
+ matchByte <<= 1;
+ RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1);
+ symbol <<= 1;
+ offs &= ~(matchByte ^ symbol);
+ }
+ while (symbol < 0x10000);
+}
+
+static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
+{
+ UInt32 i;
+ for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
+ {
+ const int kCyclesBits = kNumBitPriceShiftBits;
+ UInt32 w = i;
+ UInt32 bitCount = 0;
+ int j;
+ for (j = 0; j < kCyclesBits; j++)
+ {
+ w = w * w;
+ bitCount <<= 1;
+ while (w >= ((UInt32)1 << 16))
+ {
+ w >>= 1;
+ bitCount++;
+ }
+ }
+ ProbPrices[i >> kNumMoveReducingBits] = ((kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount);
+ }
+}
+
+
+#define GET_PRICE(prob, symbol) \
+ p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];
+
+#define GET_PRICEa(prob, symbol) \
+ ProbPrices[((prob) ^ ((-((int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];
+
+#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits]
+#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]
+
+#define GET_PRICE_0a(prob) ProbPrices[(prob) >> kNumMoveReducingBits]
+#define GET_PRICE_1a(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]
+
+static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *ProbPrices)
+{
+ UInt32 price = 0;
+ symbol |= 0x100;
+ do
+ {
+ price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1);
+ symbol <<= 1;
+ }
+ while (symbol < 0x10000);
+ return price;
+};
+
+static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, UInt32 *ProbPrices)
+{
+ UInt32 price = 0;
+ UInt32 offs = 0x100;
+ symbol |= 0x100;
+ do
+ {
+ matchByte <<= 1;
+ price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1);
+ symbol <<= 1;
+ offs &= ~(matchByte ^ symbol);
+ }
+ while (symbol < 0x10000);
+ return price;
+};
+
+
+static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
+{
+ UInt32 m = 1;
+ int i;
+ for (i = numBitLevels; i != 0 ;)
+ {
+ UInt32 bit;
+ i--;
+ bit = (symbol >> i) & 1;
+ RangeEnc_EncodeBit(rc, probs + m, bit);
+ m = (m << 1) | bit;
+ }
+};
+
+static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
+{
+ UInt32 m = 1;
+ int i;
+ for (i = 0; i < numBitLevels; i++)
+ {
+ UInt32 bit = symbol & 1;
+ RangeEnc_EncodeBit(rc, probs + m, bit);
+ m = (m << 1) | bit;
+ symbol >>= 1;
+ }
+}
+
+static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices)
+{
+ UInt32 price = 0;
+ symbol |= (1 << numBitLevels);
+ while (symbol != 1)
+ {
+ price += GET_PRICEa(probs[symbol >> 1], symbol & 1);
+ symbol >>= 1;
+ }
+ return price;
+}
+
+static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices)
+{
+ UInt32 price = 0;
+ UInt32 m = 1;
+ int i;
+ for (i = numBitLevels; i != 0; i--)
+ {
+ UInt32 bit = symbol & 1;
+ symbol >>= 1;
+ price += GET_PRICEa(probs[m], bit);
+ m = (m << 1) | bit;
+ }
+ return price;
+}
+
+
+static void LenEnc_Init(CLenEnc *p)
+{
+ unsigned i;
+ p->choice = p->choice2 = kProbInitValue;
+ for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumLowBits); i++)
+ p->low[i] = kProbInitValue;
+ for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumMidBits); i++)
+ p->mid[i] = kProbInitValue;
+ for (i = 0; i < kLenNumHighSymbols; i++)
+ p->high[i] = kProbInitValue;
+}
+
+static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState)
+{
+ if (symbol < kLenNumLowSymbols)
+ {
+ RangeEnc_EncodeBit(rc, &p->choice, 0);
+ RcTree_Encode(rc, p->low + (posState << kLenNumLowBits), kLenNumLowBits, symbol);
+ }
+ else
+ {
+ RangeEnc_EncodeBit(rc, &p->choice, 1);
+ if (symbol < kLenNumLowSymbols + kLenNumMidSymbols)
+ {
+ RangeEnc_EncodeBit(rc, &p->choice2, 0);
+ RcTree_Encode(rc, p->mid + (posState << kLenNumMidBits), kLenNumMidBits, symbol - kLenNumLowSymbols);
+ }
+ else
+ {
+ RangeEnc_EncodeBit(rc, &p->choice2, 1);
+ RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSymbols - kLenNumMidSymbols);
+ }
+ }
+}
+
+static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UInt32 *prices, UInt32 *ProbPrices)
+{
+ UInt32 a0 = GET_PRICE_0a(p->choice);
+ UInt32 a1 = GET_PRICE_1a(p->choice);
+ UInt32 b0 = a1 + GET_PRICE_0a(p->choice2);
+ UInt32 b1 = a1 + GET_PRICE_1a(p->choice2);
+ UInt32 i = 0;
+ for (i = 0; i < kLenNumLowSymbols; i++)
+ {
+ if (i >= numSymbols)
+ return;
+ prices[i] = a0 + RcTree_GetPrice(p->low + (posState << kLenNumLowBits), kLenNumLowBits, i, ProbPrices);
+ }
+ for (; i < kLenNumLowSymbols + kLenNumMidSymbols; i++)
+ {
+ if (i >= numSymbols)
+ return;
+ prices[i] = b0 + RcTree_GetPrice(p->mid + (posState << kLenNumMidBits), kLenNumMidBits, i - kLenNumLowSymbols, ProbPrices);
+ }
+ for (; i < numSymbols; i++)
+ prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices);
+}
+
+static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, UInt32 posState, UInt32 *ProbPrices)
+{
+ LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices);
+ p->counters[posState] = p->tableSize;
+}
+
+static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, UInt32 *ProbPrices)
+{
+ UInt32 posState;
+ for (posState = 0; posState < numPosStates; posState++)
+ LenPriceEnc_UpdateTable(p, posState, ProbPrices);
+}
+
+static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, UInt32 *ProbPrices)
+{
+ LenEnc_Encode(&p->p, rc, symbol, posState);
+ if (updatePrice)
+ if (--p->counters[posState] == 0)
+ LenPriceEnc_UpdateTable(p, posState, ProbPrices);
+}
+
+
+
+
+static void MovePos(CLzmaEnc *p, UInt32 num)
+{
+ #ifdef SHOW_STAT
+ ttt += num;
+ printf("\n MovePos %d", num);
+ #endif
+ if (num != 0)
+ {
+ p->additionalOffset += num;
+ p->matchFinder.Skip(p->matchFinderObj, num);
+ }
+}
+
+static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
+{
+ UInt32 lenRes = 0, numDistancePairs;
+ numDistancePairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matchDistances);
+ #ifdef SHOW_STAT
+ printf("\n i = %d numPairs = %d ", ttt, numDistancePairs / 2);
+ if (ttt >= 61994)
+ ttt = ttt;
+
+ ttt++;
+ {
+ UInt32 i;
+ for (i = 0; i < numDistancePairs; i += 2)
+ printf("%2d %6d | ", p->matchDistances[i], p->matchDistances[i + 1]);
+ }
+ #endif
+ if (numDistancePairs > 0)
+ {
+ lenRes = p->matchDistances[numDistancePairs - 2];
+ if (lenRes == p->numFastBytes)
+ {
+ UInt32 numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) + 1;
+ const Byte *pby = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+ UInt32 distance = p->matchDistances[numDistancePairs - 1] + 1;
+ if (numAvail > LZMA_MATCH_LEN_MAX)
+ numAvail = LZMA_MATCH_LEN_MAX;
+
+ {
+ const Byte *pby2 = pby - distance;
+ for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++);
+ }
+ }
+ }
+ p->additionalOffset++;
+ *numDistancePairsRes = numDistancePairs;
+ return lenRes;
+}
+
+
+#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False;
+#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False;
+#define IsShortRep(p) ((p)->backPrev == 0)
+
+static UInt32 GetRepLen1Price(CLzmaEnc *p, UInt32 state, UInt32 posState)
+{
+ return
+ GET_PRICE_0(p->isRepG0[state]) +
+ GET_PRICE_0(p->isRep0Long[state][posState]);
+}
+
+static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32 posState)
+{
+ UInt32 price;
+ if (repIndex == 0)
+ {
+ price = GET_PRICE_0(p->isRepG0[state]);
+ price += GET_PRICE_1(p->isRep0Long[state][posState]);
+ }
+ else
+ {
+ price = GET_PRICE_1(p->isRepG0[state]);
+ if (repIndex == 1)
+ price += GET_PRICE_0(p->isRepG1[state]);
+ else
+ {
+ price += GET_PRICE_1(p->isRepG1[state]);
+ price += GET_PRICE(p->isRepG2[state], repIndex - 2);
+ }
+ }
+ return price;
+}
+
+static UInt32 GetRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 len, UInt32 state, UInt32 posState)
+{
+ return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] +
+ GetPureRepPrice(p, repIndex, state, posState);
+}
+
+static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
+{
+ UInt32 posMem = p->opt[cur].posPrev;
+ UInt32 backMem = p->opt[cur].backPrev;
+ p->optimumEndIndex = cur;
+ do
+ {
+ if (p->opt[cur].prev1IsChar)
+ {
+ MakeAsChar(&p->opt[posMem])
+ p->opt[posMem].posPrev = posMem - 1;
+ if (p->opt[cur].prev2)
+ {
+ p->opt[posMem - 1].prev1IsChar = False;
+ p->opt[posMem - 1].posPrev = p->opt[cur].posPrev2;
+ p->opt[posMem - 1].backPrev = p->opt[cur].backPrev2;
+ }
+ }
+ {
+ UInt32 posPrev = posMem;
+ UInt32 backCur = backMem;
+
+ backMem = p->opt[posPrev].backPrev;
+ posMem = p->opt[posPrev].posPrev;
+
+ p->opt[posPrev].backPrev = backCur;
+ p->opt[posPrev].posPrev = cur;
+ cur = posPrev;
+ }
+ }
+ while (cur != 0);
+ *backRes = p->opt[0].backPrev;
+ p->optimumCurrentIndex = p->opt[0].posPrev;
+ return p->optimumCurrentIndex;
+}
+
+#define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * 0x300)
+
+#pragma GCC diagnostic ignored "-Wshadow"
+
+static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
+{
+ UInt32 numAvailableBytes, lenMain, numDistancePairs;
+ const Byte *data;
+ UInt32 reps[LZMA_NUM_REPS];
+ UInt32 repLens[LZMA_NUM_REPS];
+ UInt32 repMaxIndex, i;
+ UInt32 *matchDistances;
+ Byte currentByte, matchByte;
+ UInt32 posState;
+ UInt32 matchPrice, repMatchPrice;
+ UInt32 lenEnd;
+ UInt32 len;
+ UInt32 normalMatchPrice;
+ UInt32 cur;
+ if (p->optimumEndIndex != p->optimumCurrentIndex)
+ {
+ const COptimal *opt = &p->opt[p->optimumCurrentIndex];
+ UInt32 lenRes = opt->posPrev - p->optimumCurrentIndex;
+ *backRes = opt->backPrev;
+ p->optimumCurrentIndex = opt->posPrev;
+ return lenRes;
+ }
+ p->optimumCurrentIndex = p->optimumEndIndex = 0;
+
+ numAvailableBytes = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
+
+ if (!p->longestMatchWasFound)
+ {
+ lenMain = ReadMatchDistances(p, &numDistancePairs);
+ }
+ else
+ {
+ lenMain = p->longestMatchLength;
+ numDistancePairs = p->numDistancePairs;
+ p->longestMatchWasFound = False;
+ }
+
+ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+ if (numAvailableBytes < 2)
+ {
+ *backRes = (UInt32)(-1);
+ return 1;
+ }
+ if (numAvailableBytes > LZMA_MATCH_LEN_MAX)
+ numAvailableBytes = LZMA_MATCH_LEN_MAX;
+
+ repMaxIndex = 0;
+ for (i = 0; i < LZMA_NUM_REPS; i++)
+ {
+ UInt32 lenTest;
+ const Byte *data2;
+ reps[i] = p->reps[i];
+ data2 = data - (reps[i] + 1);
+ if (data[0] != data2[0] || data[1] != data2[1])
+ {
+ repLens[i] = 0;
+ continue;
+ }
+ for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data2[lenTest]; lenTest++);
+ repLens[i] = lenTest;
+ if (lenTest > repLens[repMaxIndex])
+ repMaxIndex = i;
+ }
+ if (repLens[repMaxIndex] >= p->numFastBytes)
+ {
+ UInt32 lenRes;
+ *backRes = repMaxIndex;
+ lenRes = repLens[repMaxIndex];
+ MovePos(p, lenRes - 1);
+ return lenRes;
+ }
+
+ matchDistances = p->matchDistances;
+ if (lenMain >= p->numFastBytes)
+ {
+ *backRes = matchDistances[numDistancePairs - 1] + LZMA_NUM_REPS;
+ MovePos(p, lenMain - 1);
+ return lenMain;
+ }
+ currentByte = *data;
+ matchByte = *(data - (reps[0] + 1));
+
+ if (lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2)
+ {
+ *backRes = (UInt32)-1;
+ return 1;
+ }
+
+ p->opt[0].state = (CState)p->state;
+
+ posState = (position & p->pbMask);
+
+ {
+ const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));
+ p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) +
+ (!IsCharState(p->state) ?
+ LitEnc_GetPriceMatched(probs, currentByte, matchByte, p->ProbPrices) :
+ LitEnc_GetPrice(probs, currentByte, p->ProbPrices));
+ }
+
+ MakeAsChar(&p->opt[1]);
+
+ matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]);
+ repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]);
+
+ if (matchByte == currentByte)
+ {
+ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState);
+ if (shortRepPrice < p->opt[1].price)
+ {
+ p->opt[1].price = shortRepPrice;
+ MakeAsShortRep(&p->opt[1]);
+ }
+ }
+ lenEnd = ((lenMain >= repLens[repMaxIndex]) ? lenMain : repLens[repMaxIndex]);
+
+ if (lenEnd < 2)
+ {
+ *backRes = p->opt[1].backPrev;
+ return 1;
+ }
+
+ p->opt[1].posPrev = 0;
+ for (i = 0; i < LZMA_NUM_REPS; i++)
+ p->opt[0].backs[i] = reps[i];
+
+ len = lenEnd;
+ do
+ p->opt[len--].price = kInfinityPrice;
+ while (len >= 2);
+
+ for (i = 0; i < LZMA_NUM_REPS; i++)
+ {
+ UInt32 repLen = repLens[i];
+ UInt32 price;
+ if (repLen < 2)
+ continue;
+ price = repMatchPrice + GetPureRepPrice(p, i, p->state, posState);
+ do
+ {
+ UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2];
+ COptimal *opt = &p->opt[repLen];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = 0;
+ opt->backPrev = i;
+ opt->prev1IsChar = False;
+ }
+ }
+ while (--repLen >= 2);
+ }
+
+ normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]);
+
+ len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);
+ if (len <= lenMain)
+ {
+ UInt32 offs = 0;
+ while (len > matchDistances[offs])
+ offs += 2;
+ for (; ; len++)
+ {
+ COptimal *opt;
+ UInt32 distance = matchDistances[offs + 1];
+
+ UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN];
+ UInt32 lenToPosState = GetLenToPosState(len);
+ if (distance < kNumFullDistances)
+ curAndLenPrice += p->distancesPrices[lenToPosState][distance];
+ else
+ {
+ UInt32 slot;
+ GetPosSlot2(distance, slot);
+ curAndLenPrice += p->alignPrices[distance & kAlignMask] + p->posSlotPrices[lenToPosState][slot];
+ }
+ opt = &p->opt[len];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = 0;
+ opt->backPrev = distance + LZMA_NUM_REPS;
+ opt->prev1IsChar = False;
+ }
+ if (len == matchDistances[offs])
+ {
+ offs += 2;
+ if (offs == numDistancePairs)
+ break;
+ }
+ }
+ }
+
+ cur = 0;
+
+ #ifdef SHOW_STAT2
+ if (position >= 0)
+ {
+ unsigned i;
+ printf("\n pos = %4X", position);
+ for (i = cur; i <= lenEnd; i++)
+ printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price);
+ }
+ #endif
+
+ for (;;)
+ {
+ UInt32 numAvailableBytesFull, newLen, numDistancePairs;
+ COptimal *curOpt;
+ UInt32 posPrev;
+ UInt32 state;
+ UInt32 curPrice;
+ Bool nextIsChar;
+ const Byte *data;
+ Byte currentByte, matchByte;
+ UInt32 posState;
+ UInt32 curAnd1Price;
+ COptimal *nextOpt;
+ UInt32 matchPrice, repMatchPrice;
+ UInt32 numAvailableBytes;
+ UInt32 startLen;
+
+ cur++;
+ if (cur == lenEnd)
+ return Backward(p, backRes, cur);
+
+ numAvailableBytesFull = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
+ newLen = ReadMatchDistances(p, &numDistancePairs);
+ if (newLen >= p->numFastBytes)
+ {
+ p->numDistancePairs = numDistancePairs;
+ p->longestMatchLength = newLen;
+ p->longestMatchWasFound = True;
+ return Backward(p, backRes, cur);
+ }
+ position++;
+ curOpt = &p->opt[cur];
+ posPrev = curOpt->posPrev;
+ if (curOpt->prev1IsChar)
+ {
+ posPrev--;
+ if (curOpt->prev2)
+ {
+ state = p->opt[curOpt->posPrev2].state;
+ if (curOpt->backPrev2 < LZMA_NUM_REPS)
+ state = kRepNextStates[state];
+ else
+ state = kMatchNextStates[state];
+ }
+ else
+ state = p->opt[posPrev].state;
+ state = kLiteralNextStates[state];
+ }
+ else
+ state = p->opt[posPrev].state;
+ if (posPrev == cur - 1)
+ {
+ if (IsShortRep(curOpt))
+ state = kShortRepNextStates[state];
+ else
+ state = kLiteralNextStates[state];
+ }
+ else
+ {
+ UInt32 pos;
+ const COptimal *prevOpt;
+ if (curOpt->prev1IsChar && curOpt->prev2)
+ {
+ posPrev = curOpt->posPrev2;
+ pos = curOpt->backPrev2;
+ state = kRepNextStates[state];
+ }
+ else
+ {
+ pos = curOpt->backPrev;
+ if (pos < LZMA_NUM_REPS)
+ state = kRepNextStates[state];
+ else
+ state = kMatchNextStates[state];
+ }
+ prevOpt = &p->opt[posPrev];
+ if (pos < LZMA_NUM_REPS)
+ {
+ UInt32 i;
+ reps[0] = prevOpt->backs[pos];
+ for (i = 1; i < pos + 1; i++)
+ reps[i] = prevOpt->backs[i - 1];
+ for (; i < LZMA_NUM_REPS; i++)
+ reps[i] = prevOpt->backs[i];
+ }
+ else
+ {
+ UInt32 i;
+ reps[0] = (pos - LZMA_NUM_REPS);
+ for (i = 1; i < LZMA_NUM_REPS; i++)
+ reps[i] = prevOpt->backs[i - 1];
+ }
+ }
+ curOpt->state = (CState)state;
+
+ curOpt->backs[0] = reps[0];
+ curOpt->backs[1] = reps[1];
+ curOpt->backs[2] = reps[2];
+ curOpt->backs[3] = reps[3];
+
+ curPrice = curOpt->price;
+ nextIsChar = False;
+ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+ currentByte = *data;
+ matchByte = *(data - (reps[0] + 1));
+
+ posState = (position & p->pbMask);
+
+ curAnd1Price = curPrice + GET_PRICE_0(p->isMatch[state][posState]);
+ {
+ const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));
+ curAnd1Price +=
+ (!IsCharState(state) ?
+ LitEnc_GetPriceMatched(probs, currentByte, matchByte, p->ProbPrices) :
+ LitEnc_GetPrice(probs, currentByte, p->ProbPrices));
+ }
+
+ nextOpt = &p->opt[cur + 1];
+
+ if (curAnd1Price < nextOpt->price)
+ {
+ nextOpt->price = curAnd1Price;
+ nextOpt->posPrev = cur;
+ MakeAsChar(nextOpt);
+ nextIsChar = True;
+ }
+
+ matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]);
+ repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]);
+
+ if (matchByte == currentByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0))
+ {
+ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState);
+ if (shortRepPrice <= nextOpt->price)
+ {
+ nextOpt->price = shortRepPrice;
+ nextOpt->posPrev = cur;
+ MakeAsShortRep(nextOpt);
+ nextIsChar = True;
+ }
+ }
+
+ {
+ UInt32 temp = kNumOpts - 1 - cur;
+ if (temp < numAvailableBytesFull)
+ numAvailableBytesFull = temp;
+ }
+ numAvailableBytes = numAvailableBytesFull;
+
+ if (numAvailableBytes < 2)
+ continue;
+ if (numAvailableBytes > p->numFastBytes)
+ numAvailableBytes = p->numFastBytes;
+ if (!nextIsChar && matchByte != currentByte) /* speed optimization */
+ {
+ /* try Literal + rep0 */
+ UInt32 temp;
+ UInt32 lenTest2;
+ const Byte *data2 = data - (reps[0] + 1);
+ UInt32 limit = p->numFastBytes + 1;
+ if (limit > numAvailableBytesFull)
+ limit = numAvailableBytesFull;
+
+ for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++);
+ lenTest2 = temp - 1;
+ if (lenTest2 >= 2)
+ {
+ UInt32 state2 = kLiteralNextStates[state];
+ UInt32 posStateNext = (position + 1) & p->pbMask;
+ UInt32 nextRepMatchPrice = curAnd1Price +
+ GET_PRICE_1(p->isMatch[state2][posStateNext]) +
+ GET_PRICE_1(p->isRep[state2]);
+ /* for (; lenTest2 >= 2; lenTest2--) */
+ {
+ UInt32 curAndLenPrice;
+ COptimal *opt;
+ UInt32 offset = cur + 1 + lenTest2;
+ while (lenEnd < offset)
+ p->opt[++lenEnd].price = kInfinityPrice;
+ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
+ opt = &p->opt[offset];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = cur + 1;
+ opt->backPrev = 0;
+ opt->prev1IsChar = True;
+ opt->prev2 = False;
+ }
+ }
+ }
+ }
+
+ startLen = 2; /* speed optimization */
+ {
+ UInt32 repIndex;
+ for (repIndex = 0; repIndex < LZMA_NUM_REPS; repIndex++)
+ {
+ UInt32 lenTest;
+ UInt32 lenTestTemp;
+ UInt32 price;
+ const Byte *data2 = data - (reps[repIndex] + 1);
+ if (data[0] != data2[0] || data[1] != data2[1])
+ continue;
+ for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data2[lenTest]; lenTest++);
+ while (lenEnd < cur + lenTest)
+ p->opt[++lenEnd].price = kInfinityPrice;
+ lenTestTemp = lenTest;
+ price = repMatchPrice + GetPureRepPrice(p, repIndex, state, posState);
+ do
+ {
+ UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2];
+ COptimal *opt = &p->opt[cur + lenTest];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = cur;
+ opt->backPrev = repIndex;
+ opt->prev1IsChar = False;
+ }
+ }
+ while (--lenTest >= 2);
+ lenTest = lenTestTemp;
+
+ if (repIndex == 0)
+ startLen = lenTest + 1;
+
+ /* if (_maxMode) */
+ {
+ UInt32 lenTest2 = lenTest + 1;
+ UInt32 limit = lenTest2 + p->numFastBytes;
+ UInt32 nextRepMatchPrice;
+ if (limit > numAvailableBytesFull)
+ limit = numAvailableBytesFull;
+ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
+ lenTest2 -= lenTest + 1;
+ if (lenTest2 >= 2)
+ {
+ UInt32 state2 = kRepNextStates[state];
+ UInt32 posStateNext = (position + lenTest) & p->pbMask;
+ UInt32 curAndLenCharPrice =
+ price + p->repLenEnc.prices[posState][lenTest - 2] +
+ GET_PRICE_0(p->isMatch[state2][posStateNext]) +
+ LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),
+ data[lenTest], data2[lenTest], p->ProbPrices);
+ state2 = kLiteralNextStates[state2];
+ posStateNext = (position + lenTest + 1) & p->pbMask;
+ nextRepMatchPrice = curAndLenCharPrice +
+ GET_PRICE_1(p->isMatch[state2][posStateNext]) +
+ GET_PRICE_1(p->isRep[state2]);
+
+ /* for (; lenTest2 >= 2; lenTest2--) */
+ {
+ UInt32 curAndLenPrice;
+ COptimal *opt;
+ UInt32 offset = cur + lenTest + 1 + lenTest2;
+ while (lenEnd < offset)
+ p->opt[++lenEnd].price = kInfinityPrice;
+ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
+ opt = &p->opt[offset];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = cur + lenTest + 1;
+ opt->backPrev = 0;
+ opt->prev1IsChar = True;
+ opt->prev2 = True;
+ opt->posPrev2 = cur;
+ opt->backPrev2 = repIndex;
+ }
+ }
+ }
+ }
+ }
+ }
+ /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */
+ if (newLen > numAvailableBytes)
+ {
+ newLen = numAvailableBytes;
+ for (numDistancePairs = 0; newLen > matchDistances[numDistancePairs]; numDistancePairs += 2);
+ matchDistances[numDistancePairs] = newLen;
+ numDistancePairs += 2;
+ }
+ if (newLen >= startLen)
+ {
+ UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]);
+ UInt32 offs, curBack, posSlot;
+ UInt32 lenTest;
+ while (lenEnd < cur + newLen)
+ p->opt[++lenEnd].price = kInfinityPrice;
+
+ offs = 0;
+ while (startLen > matchDistances[offs])
+ offs += 2;
+ curBack = matchDistances[offs + 1];
+ GetPosSlot2(curBack, posSlot);
+ for (lenTest = /*2*/ startLen; ; lenTest++)
+ {
+ UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];
+ UInt32 lenToPosState = GetLenToPosState(lenTest);
+ COptimal *opt;
+ if (curBack < kNumFullDistances)
+ curAndLenPrice += p->distancesPrices[lenToPosState][curBack];
+ else
+ curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask];
+
+ opt = &p->opt[cur + lenTest];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = cur;
+ opt->backPrev = curBack + LZMA_NUM_REPS;
+ opt->prev1IsChar = False;
+ }
+
+ if (/*_maxMode && */lenTest == matchDistances[offs])
+ {
+ /* Try Match + Literal + Rep0 */
+ const Byte *data2 = data - (curBack + 1);
+ UInt32 lenTest2 = lenTest + 1;
+ UInt32 limit = lenTest2 + p->numFastBytes;
+ UInt32 nextRepMatchPrice;
+ if (limit > numAvailableBytesFull)
+ limit = numAvailableBytesFull;
+ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
+ lenTest2 -= lenTest + 1;
+ if (lenTest2 >= 2)
+ {
+ UInt32 state2 = kMatchNextStates[state];
+ UInt32 posStateNext = (position + lenTest) & p->pbMask;
+ UInt32 curAndLenCharPrice = curAndLenPrice +
+ GET_PRICE_0(p->isMatch[state2][posStateNext]) +
+ LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),
+ data[lenTest], data2[lenTest], p->ProbPrices);
+ state2 = kLiteralNextStates[state2];
+ posStateNext = (posStateNext + 1) & p->pbMask;
+ nextRepMatchPrice = curAndLenCharPrice +
+ GET_PRICE_1(p->isMatch[state2][posStateNext]) +
+ GET_PRICE_1(p->isRep[state2]);
+
+ /* for (; lenTest2 >= 2; lenTest2--) */
+ {
+ UInt32 offset = cur + lenTest + 1 + lenTest2;
+ UInt32 curAndLenPrice;
+ COptimal *opt;
+ while (lenEnd < offset)
+ p->opt[++lenEnd].price = kInfinityPrice;
+ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
+ opt = &p->opt[offset];
+ if (curAndLenPrice < opt->price)
+ {
+ opt->price = curAndLenPrice;
+ opt->posPrev = cur + lenTest + 1;
+ opt->backPrev = 0;
+ opt->prev1IsChar = True;
+ opt->prev2 = True;
+ opt->posPrev2 = cur;
+ opt->backPrev2 = curBack + LZMA_NUM_REPS;
+ }
+ }
+ }
+ offs += 2;
+ if (offs == numDistancePairs)
+ break;
+ curBack = matchDistances[offs + 1];
+ if (curBack >= kNumFullDistances)
+ GetPosSlot2(curBack, posSlot);
+ }
+ }
+ }
+ }
+}
+
+#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist))
+
+static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
+{
+ UInt32 numAvailableBytes = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
+ UInt32 lenMain, numDistancePairs;
+ const Byte *data;
+ UInt32 repLens[LZMA_NUM_REPS];
+ UInt32 repMaxIndex, i;
+ UInt32 *matchDistances;
+ UInt32 backMain;
+
+ if (!p->longestMatchWasFound)
+ {
+ lenMain = ReadMatchDistances(p, &numDistancePairs);
+ }
+ else
+ {
+ lenMain = p->longestMatchLength;
+ numDistancePairs = p->numDistancePairs;
+ p->longestMatchWasFound = False;
+ }
+
+ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+ if (numAvailableBytes > LZMA_MATCH_LEN_MAX)
+ numAvailableBytes = LZMA_MATCH_LEN_MAX;
+ if (numAvailableBytes < 2)
+ {
+ *backRes = (UInt32)(-1);
+ return 1;
+ }
+
+ repMaxIndex = 0;
+
+ for (i = 0; i < LZMA_NUM_REPS; i++)
+ {
+ const Byte *data2 = data - (p->reps[i] + 1);
+ UInt32 len;
+ if (data[0] != data2[0] || data[1] != data2[1])
+ {
+ repLens[i] = 0;
+ continue;
+ }
+ for (len = 2; len < numAvailableBytes && data[len] == data2[len]; len++);
+ if (len >= p->numFastBytes)
+ {
+ *backRes = i;
+ MovePos(p, len - 1);
+ return len;
+ }
+ repLens[i] = len;
+ if (len > repLens[repMaxIndex])
+ repMaxIndex = i;
+ }
+ matchDistances = p->matchDistances;
+ if (lenMain >= p->numFastBytes)
+ {
+ *backRes = matchDistances[numDistancePairs - 1] + LZMA_NUM_REPS;
+ MovePos(p, lenMain - 1);
+ return lenMain;
+ }
+
+ backMain = 0; /* for GCC */
+ if (lenMain >= 2)
+ {
+ backMain = matchDistances[numDistancePairs - 1];
+ while (numDistancePairs > 2 && lenMain == matchDistances[numDistancePairs - 4] + 1)
+ {
+ if (!ChangePair(matchDistances[numDistancePairs - 3], backMain))
+ break;
+ numDistancePairs -= 2;
+ lenMain = matchDistances[numDistancePairs - 2];
+ backMain = matchDistances[numDistancePairs - 1];
+ }
+ if (lenMain == 2 && backMain >= 0x80)
+ lenMain = 1;
+ }
+
+ if (repLens[repMaxIndex] >= 2)
+ {
+ if (repLens[repMaxIndex] + 1 >= lenMain ||
+ (repLens[repMaxIndex] + 2 >= lenMain && (backMain > (1 << 9))) ||
+ (repLens[repMaxIndex] + 3 >= lenMain && (backMain > (1 << 15))))
+ {
+ UInt32 lenRes;
+ *backRes = repMaxIndex;
+ lenRes = repLens[repMaxIndex];
+ MovePos(p, lenRes - 1);
+ return lenRes;
+ }
+ }
+
+ if (lenMain >= 2 && numAvailableBytes > 2)
+ {
+ UInt32 i;
+ numAvailableBytes = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
+ p->longestMatchLength = ReadMatchDistances(p, &p->numDistancePairs);
+ if (p->longestMatchLength >= 2)
+ {
+ UInt32 newDistance = matchDistances[p->numDistancePairs - 1];
+ if ((p->longestMatchLength >= lenMain && newDistance < backMain) ||
+ (p->longestMatchLength == lenMain + 1 && !ChangePair(backMain, newDistance)) ||
+ (p->longestMatchLength > lenMain + 1) ||
+ (p->longestMatchLength + 1 >= lenMain && lenMain >= 3 && ChangePair(newDistance, backMain)))
+ {
+ p->longestMatchWasFound = True;
+ *backRes = (UInt32)(-1);
+ return 1;
+ }
+ }
+ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+ for (i = 0; i < LZMA_NUM_REPS; i++)
+ {
+ UInt32 len;
+ const Byte *data2 = data - (p->reps[i] + 1);
+ if (data[1] != data2[1] || data[2] != data2[2])
+ {
+ repLens[i] = 0;
+ continue;
+ }
+ for (len = 2; len < numAvailableBytes && data[len] == data2[len]; len++);
+ if (len + 1 >= lenMain)
+ {
+ p->longestMatchWasFound = True;
+ *backRes = (UInt32)(-1);
+ return 1;
+ }
+ }
+ *backRes = backMain + LZMA_NUM_REPS;
+ MovePos(p, lenMain - 2);
+ return lenMain;
+ }
+ *backRes = (UInt32)(-1);
+ return 1;
+}
+
+static void WriteEndMarker(CLzmaEnc *p, UInt32 posState)
+{
+ UInt32 len;
+ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
+ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
+ p->state = kMatchNextStates[p->state];
+ len = LZMA_MATCH_LEN_MIN;
+ LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
+ RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, (1 << kNumPosSlotBits) - 1);
+ RangeEnc_EncodeDirectBits(&p->rc, (((UInt32)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits);
+ RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);
+}
+
+static SRes CheckErrors(CLzmaEnc *p)
+{
+ if (p->result != SZ_OK)
+ return p->result;
+ if (p->rc.res != SZ_OK)
+ p->result = SZ_ERROR_WRITE;
+ if (p->matchFinderBase.result != SZ_OK)
+ p->result = SZ_ERROR_READ;
+ if (p->result != SZ_OK)
+ p->finished = True;
+ return p->result;
+}
+
+static SRes Flush(CLzmaEnc *p, UInt32 nowPos)
+{
+ /* ReleaseMFStream(); */
+ p->finished = True;
+ if (p->writeEndMark)
+ WriteEndMarker(p, nowPos & p->pbMask);
+ RangeEnc_FlushData(&p->rc);
+ RangeEnc_FlushStream(&p->rc);
+ return CheckErrors(p);
+}
+
+static void FillAlignPrices(CLzmaEnc *p)
+{
+ UInt32 i;
+ for (i = 0; i < kAlignTableSize; i++)
+ p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices);
+ p->alignPriceCount = 0;
+}
+
+static void FillDistancesPrices(CLzmaEnc *p)
+{
+ UInt32 tempPrices[kNumFullDistances];
+ UInt32 i, lenToPosState;
+ for (i = kStartPosModelIndex; i < kNumFullDistances; i++)
+ {
+ UInt32 posSlot = GetPosSlot1(i);
+ UInt32 footerBits = ((posSlot >> 1) - 1);
+ UInt32 base = ((2 | (posSlot & 1)) << footerBits);
+ tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base - posSlot - 1, footerBits, i - base, p->ProbPrices);
+ }
+
+ for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
+ {
+ UInt32 posSlot;
+ const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState];
+ UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState];
+ for (posSlot = 0; posSlot < p->distTableSize; posSlot++)
+ posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices);
+ for (posSlot = kEndPosModelIndex; posSlot < p->distTableSize; posSlot++)
+ posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits);
+
+ {
+ UInt32 *distancesPrices = p->distancesPrices[lenToPosState];
+ UInt32 i;
+ for (i = 0; i < kStartPosModelIndex; i++)
+ distancesPrices[i] = posSlotPrices[i];
+ for (; i < kNumFullDistances; i++)
+ distancesPrices[i] = posSlotPrices[GetPosSlot1(i)] + tempPrices[i];
+ }
+ }
+ p->matchPriceCount = 0;
+}
+
+static void LzmaEnc_Construct(CLzmaEnc *p)
+{
+ RangeEnc_Construct(&p->rc);
+ MatchFinder_Construct(&p->matchFinderBase);
+ #ifdef COMPRESS_MF_MT
+ MatchFinderMt_Construct(&p->matchFinderMt);
+ p->matchFinderMt.MatchFinder = &p->matchFinderBase;
+ #endif
+
+ {
+ CLzmaEncProps props;
+ LzmaEncProps_Init(&props);
+ LzmaEnc_SetProps(p, &props);
+ }
+
+ #ifndef LZMA_LOG_BSR
+ LzmaEnc_FastPosInit(p->g_FastPos);
+ #endif
+
+ LzmaEnc_InitPriceTables(p->ProbPrices);
+ p->litProbs = 0;
+ p->saveState.litProbs = 0;
+}
+
+CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)
+{
+ void *p;
+ p = alloc->Alloc(alloc, sizeof(CLzmaEnc));
+ if (p != 0)
+ LzmaEnc_Construct((CLzmaEnc *)p);
+ return p;
+}
+
+static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
+{
+ alloc->Free(alloc, p->litProbs);
+ alloc->Free(alloc, p->saveState.litProbs);
+ p->litProbs = 0;
+ p->saveState.litProbs = 0;
+}
+
+static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ #ifdef COMPRESS_MF_MT
+ MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
+ #endif
+ MatchFinder_Free(&p->matchFinderBase, allocBig);
+ LzmaEnc_FreeLits(p, alloc);
+ RangeEnc_Free(&p->rc, alloc);
+}
+
+void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig);
+ alloc->Free(alloc, p);
+}
+
+static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize)
+{
+ UInt32 nowPos32, startPos32;
+ if (p->inStream != 0)
+ {
+ p->matchFinderBase.stream = p->inStream;
+ p->matchFinder.Init(p->matchFinderObj);
+ p->inStream = 0;
+ }
+
+ if (p->finished)
+ return p->result;
+ RINOK(CheckErrors(p));
+
+ nowPos32 = (UInt32)p->nowPos64;
+ startPos32 = nowPos32;
+
+ if (p->nowPos64 == 0)
+ {
+ UInt32 numDistancePairs;
+ Byte curByte;
+ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)
+ return Flush(p, nowPos32);
+ ReadMatchDistances(p, &numDistancePairs);
+ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][0], 0);
+ p->state = kLiteralNextStates[p->state];
+ curByte = p->matchFinder.GetIndexByte(p->matchFinderObj, 0 - p->additionalOffset);
+ LitEnc_Encode(&p->rc, p->litProbs, curByte);
+ p->additionalOffset--;
+ nowPos32++;
+ }
+
+ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0)
+ for (;;)
+ {
+ UInt32 pos, len, posState;
+
+ if (p->fastMode)
+ len = GetOptimumFast(p, &pos);
+ else
+ len = GetOptimum(p, nowPos32, &pos);
+
+ #ifdef SHOW_STAT2
+ printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos);
+ #endif
+
+ posState = nowPos32 & p->pbMask;
+ if (len == 1 && pos == 0xFFFFFFFF)
+ {
+ Byte curByte;
+ CLzmaProb *probs;
+ const Byte *data;
+
+ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 0);
+ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
+ curByte = *data;
+ probs = LIT_PROBS(nowPos32, *(data - 1));
+ if (IsCharState(p->state))
+ LitEnc_Encode(&p->rc, probs, curByte);
+ else
+ LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0] - 1));
+ p->state = kLiteralNextStates[p->state];
+ }
+ else
+ {
+ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
+ if (pos < LZMA_NUM_REPS)
+ {
+ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 1);
+ if (pos == 0)
+ {
+ RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 0);
+ RangeEnc_EncodeBit(&p->rc, &p->isRep0Long[p->state][posState], ((len == 1) ? 0 : 1));
+ }
+ else
+ {
+ UInt32 distance = p->reps[pos];
+ RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 1);
+ if (pos == 1)
+ RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 0);
+ else
+ {
+ RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 1);
+ RangeEnc_EncodeBit(&p->rc, &p->isRepG2[p->state], pos - 2);
+ if (pos == 3)
+ p->reps[3] = p->reps[2];
+ p->reps[2] = p->reps[1];
+ }
+ p->reps[1] = p->reps[0];
+ p->reps[0] = distance;
+ }
+ if (len == 1)
+ p->state = kShortRepNextStates[p->state];
+ else
+ {
+ LenEnc_Encode2(&p->repLenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
+ p->state = kRepNextStates[p->state];
+ }
+ }
+ else
+ {
+ UInt32 posSlot, lenToPosState;
+ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
+ p->state = kMatchNextStates[p->state];
+ LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
+ pos -= LZMA_NUM_REPS;
+ GetPosSlot(pos, posSlot);
+ lenToPosState = GetLenToPosState(len);
+ if (lenToPosState >= kNumLenToPosStates)
+ {
+ p->result = SZ_ERROR_DATA;
+ return CheckErrors(p);
+ }
+ RcTree_Encode(&p->rc, p->posSlotEncoder[lenToPosState], kNumPosSlotBits, posSlot);
+
+ if (posSlot >= kStartPosModelIndex)
+ {
+ UInt32 footerBits = ((posSlot >> 1) - 1);
+ UInt32 base = ((2 | (posSlot & 1)) << footerBits);
+ UInt32 posReduced = pos - base;
+
+ if (posSlot < kEndPosModelIndex)
+ RcTree_ReverseEncode(&p->rc, p->posEncoders + base - posSlot - 1, footerBits, posReduced);
+ else
+ {
+ RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
+ RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask);
+ p->alignPriceCount++;
+ }
+ }
+ p->reps[3] = p->reps[2];
+ p->reps[2] = p->reps[1];
+ p->reps[1] = p->reps[0];
+ p->reps[0] = pos;
+ p->matchPriceCount++;
+ }
+ }
+ p->additionalOffset -= len;
+ nowPos32 += len;
+ if (p->additionalOffset == 0)
+ {
+ UInt32 processed;
+ if (!p->fastMode)
+ {
+ if (p->matchPriceCount >= (1 << 7))
+ FillDistancesPrices(p);
+ if (p->alignPriceCount >= kAlignTableSize)
+ FillAlignPrices(p);
+ }
+ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)
+ break;
+ processed = nowPos32 - startPos32;
+ if (useLimits)
+ {
+ if (processed + kNumOpts + 300 >= maxUnpackSize ||
+ RangeEnc_GetProcessed(&p->rc) + kNumOpts * 2 >= maxPackSize)
+ break;
+ }
+ else if (processed >= (1 << 15))
+ {
+ p->nowPos64 += nowPos32 - startPos32;
+ return CheckErrors(p);
+ }
+ }
+ }
+ p->nowPos64 += nowPos32 - startPos32;
+ return Flush(p, nowPos32);
+}
+
+#define kBigHashDicLimit ((UInt32)1 << 24)
+
+static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ UInt32 beforeSize = kNumOpts;
+#ifdef COMPRESS_MF_MT
+ Bool btMode;
+#endif
+ if (!RangeEnc_Alloc(&p->rc, alloc))
+ return SZ_ERROR_MEM;
+#ifdef COMPRESS_MF_MT
+ btMode = (p->matchFinderBase.btMode != 0);
+ p->mtMode = (p->multiThread && !p->fastMode && btMode);
+#endif
+
+ {
+ unsigned lclp = p->lc + p->lp;
+ if (p->litProbs == 0 || p->saveState.litProbs == 0 || p->lclp != lclp)
+ {
+ LzmaEnc_FreeLits(p, alloc);
+ p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb));
+ p->saveState.litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb));
+ if (p->litProbs == 0 || p->saveState.litProbs == 0)
+ {
+ LzmaEnc_FreeLits(p, alloc);
+ return SZ_ERROR_MEM;
+ }
+ p->lclp = lclp;
+ }
+ }
+
+ p->matchFinderBase.bigHash = (p->dictSize > kBigHashDicLimit);
+
+ if (beforeSize + p->dictSize < keepWindowSize)
+ beforeSize = keepWindowSize - p->dictSize;
+
+ #ifdef COMPRESS_MF_MT
+ if (p->mtMode)
+ {
+ RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig));
+ p->matchFinderObj = &p->matchFinderMt;
+ MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder);
+ }
+ else
+ #endif
+ {
+ if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig))
+ return SZ_ERROR_MEM;
+ p->matchFinderObj = &p->matchFinderBase;
+ MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder);
+ }
+ return SZ_OK;
+}
+
+static void LzmaEnc_Init(CLzmaEnc *p)
+{
+ UInt32 i;
+ p->state = 0;
+ for(i = 0 ; i < LZMA_NUM_REPS; i++)
+ p->reps[i] = 0;
+
+ RangeEnc_Init(&p->rc);
+
+
+ for (i = 0; i < kNumStates; i++)
+ {
+ UInt32 j;
+ for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++)
+ {
+ p->isMatch[i][j] = kProbInitValue;
+ p->isRep0Long[i][j] = kProbInitValue;
+ }
+ p->isRep[i] = kProbInitValue;
+ p->isRepG0[i] = kProbInitValue;
+ p->isRepG1[i] = kProbInitValue;
+ p->isRepG2[i] = kProbInitValue;
+ }
+
+ {
+ UInt32 num = 0x300 << (p->lp + p->lc);
+ for (i = 0; i < num; i++)
+ p->litProbs[i] = kProbInitValue;
+ }
+
+ {
+ for (i = 0; i < kNumLenToPosStates; i++)
+ {
+ CLzmaProb *probs = p->posSlotEncoder[i];
+ UInt32 j;
+ for (j = 0; j < (1 << kNumPosSlotBits); j++)
+ probs[j] = kProbInitValue;
+ }
+ }
+ {
+ for(i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
+ p->posEncoders[i] = kProbInitValue;
+ }
+
+ LenEnc_Init(&p->lenEnc.p);
+ LenEnc_Init(&p->repLenEnc.p);
+
+ for (i = 0; i < (1 << kNumAlignBits); i++)
+ p->posAlignEncoder[i] = kProbInitValue;
+
+ p->longestMatchWasFound = False;
+ p->optimumEndIndex = 0;
+ p->optimumCurrentIndex = 0;
+ p->additionalOffset = 0;
+
+ p->pbMask = (1 << p->pb) - 1;
+ p->lpMask = (1 << p->lp) - 1;
+}
+
+static void LzmaEnc_InitPrices(CLzmaEnc *p)
+{
+ if (!p->fastMode)
+ {
+ FillDistancesPrices(p);
+ FillAlignPrices(p);
+ }
+
+ p->lenEnc.tableSize =
+ p->repLenEnc.tableSize =
+ p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN;
+ LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, p->ProbPrices);
+ LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices);
+}
+
+static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ UInt32 i;
+ for (i = 0; i < (UInt32)kDicLogSizeMaxCompress; i++)
+ if (p->dictSize <= ((UInt32)1 << i))
+ break;
+ p->distTableSize = i * 2;
+
+ p->finished = False;
+ p->result = SZ_OK;
+ RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig));
+ LzmaEnc_Init(p);
+ LzmaEnc_InitPrices(p);
+ p->nowPos64 = 0;
+ return SZ_OK;
+}
+
+static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqInStream *inStream, ISeqOutStream *outStream,
+ ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ p->inStream = inStream;
+ p->rc.outStream = outStream;
+ return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);
+}
+
+static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)
+{
+ p->seqBufInStream.funcTable.Read = MyRead;
+ p->seqBufInStream.data = src;
+ p->seqBufInStream.rem = srcLen;
+}
+
+static void LzmaEnc_Finish(CLzmaEncHandle pp)
+{
+ #ifdef COMPRESS_MF_MT
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ if (p->mtMode)
+ MatchFinderMt_ReleaseStream(&p->matchFinderMt);
+ #else
+ (void)pp;
+ #endif
+}
+
+typedef struct _CSeqOutStreamBuf
+{
+ ISeqOutStream funcTable;
+ Byte *data;
+ SizeT rem;
+ Bool overflow;
+} CSeqOutStreamBuf;
+
+static size_t MyWrite(void *pp, const void *data, size_t size)
+{
+ CSeqOutStreamBuf *p = (CSeqOutStreamBuf *)pp;
+ if (p->rem < size)
+ {
+ size = p->rem;
+ p->overflow = True;
+ }
+ memcpy(p->data, data, size);
+ p->rem -= size;
+ p->data += size;
+ return size;
+}
+
+SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
+ ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ SRes res = SZ_OK;
+
+ #ifdef COMPRESS_MF_MT
+ Byte allocaDummy[0x300];
+ int i = 0;
+ for (i = 0; i < 16; i++)
+ allocaDummy[i] = (Byte)i;
+ #endif
+
+ RINOK(LzmaEnc_Prepare(pp, inStream, outStream, alloc, allocBig));
+
+ for (;;)
+ {
+ res = LzmaEnc_CodeOneBlock(pp, False, 0, 0);
+ if (res != SZ_OK || p->finished != 0)
+ break;
+ if (progress != 0)
+ {
+ res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc));
+ if (res != SZ_OK)
+ {
+ res = SZ_ERROR_PROGRESS;
+ break;
+ }
+ }
+ }
+ LzmaEnc_Finish(pp);
+ return res;
+}
+
+SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
+{
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+ int i;
+ UInt32 dictSize = p->dictSize;
+ if (*size < LZMA_PROPS_SIZE)
+ return SZ_ERROR_PARAM;
+ *size = LZMA_PROPS_SIZE;
+ props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc);
+
+ for (i = 11; i <= 30; i++)
+ {
+ if (dictSize <= ((UInt32)2 << i))
+ {
+ dictSize = (2 << i);
+ break;
+ }
+ if (dictSize <= ((UInt32)3 << i))
+ {
+ dictSize = (3 << i);
+ break;
+ }
+ }
+
+ for (i = 0; i < 4; i++)
+ props[1 + i] = (Byte)(dictSize >> (8 * i));
+ return SZ_OK;
+}
+
+SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+ int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ SRes res;
+ CLzmaEnc *p = (CLzmaEnc *)pp;
+
+ CSeqOutStreamBuf outStream;
+
+ LzmaEnc_SetInputBuf(p, src, srcLen);
+
+ outStream.funcTable.Write = MyWrite;
+ outStream.data = dest;
+ outStream.rem = *destLen;
+ outStream.overflow = False;
+
+ p->writeEndMark = writeEndMark;
+ res = LzmaEnc_Encode(pp, &outStream.funcTable, &p->seqBufInStream.funcTable,
+ progress, alloc, allocBig);
+
+ *destLen -= outStream.rem;
+ if (outStream.overflow)
+ return SZ_ERROR_OUTPUT_EOF;
+ return res;
+}
+
+SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+ const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
+ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
+{
+ CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
+ SRes res;
+ if (p == 0)
+ return SZ_ERROR_MEM;
+
+ res = LzmaEnc_SetProps(p, props);
+ if (res == SZ_OK)
+ {
+ res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize);
+ if (res == SZ_OK)
+ res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen,
+ writeEndMark, progress, alloc, allocBig);
+ }
+
+ LzmaEnc_Destroy(p, alloc, allocBig);
+ return res;
+}
diff --git a/grub-core/lib/adler32.c b/grub-core/lib/adler32.c
new file mode 100644
index 0000000..43b68af
--- /dev/null
+++ b/grub-core/lib/adler32.c
@@ -0,0 +1,102 @@
+/*
+ * 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/dl.h>
+#include <grub/crypto.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct adler32_context
+{
+ grub_uint16_t a, b;
+ grub_uint32_t c;
+};
+
+static void
+adler32_init (void *context)
+{
+ struct adler32_context *ctx = context;
+
+ ctx->a = 1;
+ ctx->b = 0;
+}
+
+#define MOD 65521
+
+static grub_uint16_t
+mod_add (grub_uint16_t a, grub_uint16_t b)
+{
+ if ((grub_uint32_t) a + (grub_uint32_t) b >= MOD)
+ return a + b - MOD;
+ return a + b;
+}
+
+static void
+adler32_write (void *context, const void *inbuf, grub_size_t inlen)
+{
+ struct adler32_context *ctx = context;
+ const grub_uint8_t *ptr = inbuf;
+
+ while (inlen)
+ {
+ ctx->a = mod_add (ctx->a, *ptr);
+ ctx->b = mod_add (ctx->a, ctx->b);
+ inlen--;
+ ptr++;
+ }
+}
+
+static void
+adler32_final (void *context __attribute__ ((unused)))
+{
+}
+
+static grub_uint8_t *
+adler32_read (void *context)
+{
+ struct adler32_context *ctx = context;
+ if (ctx->a > MOD)
+ ctx->a -= MOD;
+ if (ctx->b > MOD)
+ ctx->b -= MOD;
+ ctx->c = grub_cpu_to_be32 (ctx->a | (ctx->b << 16));
+ return (grub_uint8_t *) &ctx->c;
+}
+
+static gcry_md_spec_t spec_adler32 =
+ {
+ "ADLER32", 0, 0, 0, 4,
+ adler32_init, adler32_write, adler32_final, adler32_read,
+ sizeof (struct adler32_context),
+#ifdef GRUB_UTIL
+ .modname = "adler32",
+#endif
+ .blocksize = 64
+ };
+
+
+GRUB_MOD_INIT(adler32)
+{
+ grub_md_register (&spec_adler32);
+}
+
+GRUB_MOD_FINI(adler32)
+{
+ grub_md_unregister (&spec_adler32);
+}
diff --git a/grub-core/lib/arc/datetime.c b/grub-core/lib/arc/datetime.c
new file mode 100644
index 0000000..b8d910e
--- /dev/null
+++ b/grub-core/lib/arc/datetime.c
@@ -0,0 +1,48 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/datetime.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/arc/arc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+grub_err_t
+grub_get_datetime (struct grub_datetime *datetime)
+{
+ struct grub_arc_timeinfo *dt;
+ grub_memset (datetime, 0, sizeof (*datetime));
+
+ dt = GRUB_ARC_FIRMWARE_VECTOR->gettime ();
+
+ datetime->year = dt->y;
+ datetime->month = dt->m;
+ datetime->day = dt->d;
+ datetime->hour = dt->h;
+ datetime->minute = dt->min;
+ datetime->second = dt->s;
+
+ return 0;
+}
+
+grub_err_t
+grub_set_datetime (struct grub_datetime *datetime __attribute__ ((unused)))
+{
+ return grub_error (GRUB_ERR_IO, "setting time isn't supported");
+}
diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c
new file mode 100644
index 0000000..ade82d5
--- /dev/null
+++ b/grub-core/lib/arg.c
@@ -0,0 +1,492 @@
+/* arg.c - argument parser */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/term.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/safemath.h>
+
+/* Built-in parser for default options. */
+static const struct grub_arg_option help_options[] =
+ {
+ {"help", 0, 0,
+ N_("Display this help and exit."), 0, ARG_TYPE_NONE},
+ {"usage", 0, 0,
+ N_("Display the usage of this command and exit."), 0, ARG_TYPE_NONE},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+/* Helper for find_short. */
+static const struct grub_arg_option *
+fnd_short (const struct grub_arg_option *opt, char c)
+{
+ while (opt->doc)
+ {
+ if (opt->shortarg == c)
+ return opt;
+ opt++;
+ }
+ return 0;
+}
+
+static const struct grub_arg_option *
+find_short (const struct grub_arg_option *options, char c)
+{
+ const struct grub_arg_option *found = 0;
+
+ if (options)
+ found = fnd_short (options, c);
+
+ if (! found)
+ {
+ switch (c)
+ {
+ case 'h':
+ found = help_options;
+ break;
+
+ case 'u':
+ found = (help_options + 1);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return found;
+}
+
+/* Helper for find_long. */
+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 opt;
+ opt++;
+ }
+ return 0;
+}
+
+static const struct grub_arg_option *
+find_long (const struct grub_arg_option *options, const char *s, int len)
+{
+ const struct grub_arg_option *found = 0;
+
+ if (options)
+ found = fnd_long (options, s, len);
+
+ if (! found)
+ found = fnd_long (help_options, s, len);
+
+ return found;
+}
+
+static void
+show_usage (grub_extcmd_t cmd)
+{
+ grub_printf ("%s %s %s\n", _("Usage:"), cmd->cmd->name, _(cmd->cmd->summary));
+}
+
+static void
+showargs (const struct grub_arg_option *opt,
+ int h_is_used, int u_is_used)
+{
+ for (; opt->doc; opt++)
+ {
+ int spacing = 20;
+
+ if (opt->shortarg && grub_isgraph (opt->shortarg))
+ grub_printf ("-%c%c ", opt->shortarg, opt->longarg ? ',':' ');
+ else if (opt == help_options && ! h_is_used)
+ grub_printf ("-h, ");
+ else if (opt == help_options + 1 && ! u_is_used)
+ grub_printf ("-u, ");
+ else
+ grub_printf (" ");
+
+ if (opt->longarg)
+ {
+ grub_printf ("--%s", opt->longarg);
+ spacing -= grub_strlen (opt->longarg) + 2;
+
+ if (opt->arg)
+ {
+ grub_printf ("=%s", opt->arg);
+ spacing -= grub_strlen (opt->arg) + 1;
+ }
+ }
+
+ if (spacing <= 0)
+ spacing = 3;
+
+ while (spacing--)
+ grub_xputs (" ");
+
+ grub_printf ("%s\n", _(opt->doc));
+ }
+}
+
+void
+grub_arg_show_help (grub_extcmd_t cmd)
+{
+ int h_is_used = 0;
+ int u_is_used = 0;
+ const struct grub_arg_option *opt;
+
+ show_usage (cmd);
+ grub_printf ("%s\n\n", _(cmd->cmd->description));
+
+ for (opt = cmd->options; opt && opt->doc; opt++)
+ switch (opt->shortarg)
+ {
+ case 'h':
+ h_is_used = 1;
+ break;
+
+ case 'u':
+ u_is_used = 1;
+ break;
+ }
+
+ if (cmd->options)
+ showargs (cmd->options, h_is_used, u_is_used);
+ showargs (help_options, h_is_used, u_is_used);
+#if 0
+ grub_printf ("\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT);
+#endif
+}
+
+
+static int
+parse_option (grub_extcmd_t cmd, const struct grub_arg_option *opt,
+ char *arg, struct grub_arg_list *usr)
+{
+ if (opt == help_options)
+ {
+ grub_arg_show_help (cmd);
+ return -1;
+ }
+
+ if (opt == help_options + 1)
+ {
+ show_usage (cmd);
+ return -1;
+ }
+ {
+ int found = opt - cmd->options;
+
+ if (opt->flags & GRUB_ARG_OPTION_REPEATABLE)
+ {
+ usr[found].args[usr[found].set++] = arg;
+ usr[found].args[usr[found].set] = NULL;
+ }
+ else
+ {
+ usr[found].set = 1;
+ usr[found].arg = arg;
+ }
+ }
+
+ return 0;
+}
+
+static inline grub_err_t
+add_arg (char ***argl, int *num, char *s)
+{
+ char **p = *argl;
+ grub_size_t sz;
+
+ if (grub_add (++(*num), 1, &sz) ||
+ grub_mul (sz, sizeof (char *), &sz))
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+
+ *argl = grub_realloc (*argl, sz);
+ if (! *argl)
+ {
+ grub_free (p);
+ return grub_errno;
+ }
+ (*argl)[(*num) - 1] = s;
+ (*argl)[(*num)] = NULL;
+ return 0;
+}
+
+
+int
+grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
+ struct grub_arg_list *usr, char ***args, int *argnum)
+{
+ int curarg;
+ int arglen;
+ char **argl = 0;
+ int num = 0;
+
+ for (curarg = 0; curarg < argc; curarg++)
+ {
+ char *arg = argv[curarg];
+ const struct grub_arg_option *opt;
+ char *option = 0;
+
+ /* No option is used. */
+ if ((num && (cmd->cmd->flags & GRUB_COMMAND_OPTIONS_AT_START))
+ || arg[0] != '-' || grub_strlen (arg) == 1)
+ {
+ if (add_arg (&argl, &num, arg) != 0)
+ goto fail;
+
+ continue;
+ }
+
+ /* One or more short options. */
+ if (arg[1] != '-')
+ {
+ char *curshort;
+
+ if (cmd->cmd->flags & GRUB_COMMAND_ACCEPT_DASH)
+ {
+ for (curshort = arg + 1; *curshort; curshort++)
+ if (!find_short (cmd->options, *curshort))
+ break;
+
+ if (*curshort)
+ {
+ if (add_arg (&argl, &num, arg) != 0)
+ goto fail;
+ continue;
+ }
+ }
+
+ curshort = arg + 1;
+
+ while (1)
+ {
+ opt = find_short (cmd->options, *curshort);
+
+ if (! opt)
+ {
+ char tmp[3] = { '-', *curshort, 0 };
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unknown argument `%s'"), tmp);
+ goto fail;
+ }
+
+ curshort++;
+
+ /* Parse all arguments here except the last one because
+ it can have an argument value. */
+ if (*curshort)
+ {
+ /*
+ * Only permit further short opts if this one doesn't
+ * require a value.
+ */
+ if (opt->type != ARG_TYPE_NONE &&
+ !(opt->flags & GRUB_ARG_OPTION_OPTIONAL))
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("missing mandatory option for `%s'"),
+ opt->longarg);
+ goto fail;
+ }
+
+ if (parse_option (cmd, opt, 0, usr) || grub_errno)
+ goto fail;
+ }
+ else
+ {
+ if (opt->type != ARG_TYPE_NONE)
+ {
+ if (curarg + 1 < argc)
+ {
+ char *nextarg = argv[curarg + 1];
+ if (!(opt->flags & GRUB_ARG_OPTION_OPTIONAL)
+ || (grub_strlen (nextarg) < 2 || nextarg[0] != '-'))
+ option = argv[++curarg];
+ }
+ }
+ break;
+ }
+ }
+
+ }
+ else /* The argument starts with "--". */
+ {
+ /* If the argument "--" is used just pass the other
+ arguments. */
+ if (grub_strlen (arg) == 2)
+ {
+ for (curarg++; curarg < argc; curarg++)
+ if (add_arg (&argl, &num, argv[curarg]) != 0)
+ goto fail;
+ break;
+ }
+
+ option = grub_strchr (arg, '=');
+ if (option)
+ {
+ arglen = option - arg - 2;
+ option++;
+ }
+ else
+ arglen = grub_strlen (arg) - 2;
+
+ opt = find_long (cmd->options, arg + 2, arglen);
+
+ if (!option && argv[curarg + 1] && argv[curarg + 1][0] != '-'
+ && opt && opt->type != ARG_TYPE_NONE)
+ option = argv[++curarg];
+
+ if (!opt && (cmd->cmd->flags & GRUB_COMMAND_ACCEPT_DASH))
+ {
+ if (add_arg (&argl, &num, arg) != 0)
+ goto fail;
+ continue;
+ }
+
+ if (! opt)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"), arg);
+ goto fail;
+ }
+ }
+
+ if (! (opt->type == ARG_TYPE_NONE
+ || (! option && (opt->flags & GRUB_ARG_OPTION_OPTIONAL))))
+ {
+ if (! option)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("missing mandatory option for `%s'"), opt->longarg);
+ goto fail;
+ }
+
+ switch (opt->type)
+ {
+ case ARG_TYPE_NONE:
+ /* This will never happen. */
+ break;
+
+ case ARG_TYPE_STRING:
+ /* No need to do anything. */
+ break;
+
+ case ARG_TYPE_INT:
+ {
+ const char * tail;
+
+ grub_strtoull (option, &tail, 0);
+ if (tail == 0 || tail == option || *tail != '\0' || grub_errno)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("the argument `%s' requires an integer"),
+ arg);
+
+ goto fail;
+ }
+ break;
+ }
+
+ case ARG_TYPE_DEVICE:
+ case ARG_TYPE_DIR:
+ case ARG_TYPE_FILE:
+ case ARG_TYPE_PATHNAME:
+ /* XXX: Not implemented. */
+ break;
+ }
+ if (parse_option (cmd, opt, option, usr) || grub_errno)
+ goto fail;
+ }
+ else
+ {
+ if (option)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("a value was assigned to the argument `%s' while it "
+ "doesn't require an argument"), arg);
+ goto fail;
+ }
+
+ if (parse_option (cmd, opt, 0, usr) || grub_errno)
+ goto fail;
+ }
+ }
+
+ *args = argl;
+ *argnum = num;
+ return 1;
+
+ fail:
+ return 0;
+}
+
+struct grub_arg_list*
+grub_arg_list_alloc(grub_extcmd_t extcmd, int argc,
+ char **argv __attribute__((unused)))
+{
+ int i;
+ char **args;
+ grub_size_t argcnt;
+ struct grub_arg_list *list;
+ const struct grub_arg_option *options;
+ grub_size_t sz0, sz1;
+
+ options = extcmd->options;
+ if (! options)
+ return 0;
+
+ argcnt = 0;
+ for (i = 0; options[i].doc; i++)
+ {
+ if (options[i].flags & GRUB_ARG_OPTION_REPEATABLE)
+ argcnt += ((grub_size_t) argc + 1) / 2 + 1; /* max possible for any option */
+ }
+
+ if (grub_mul (sizeof (*list), i, &sz0) ||
+ grub_mul (sizeof (char *), argcnt, &sz1) ||
+ grub_add (sz0, sz1, &sz0))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+ return 0;
+ }
+
+ list = grub_zalloc (sz0);
+ if (! list)
+ return 0;
+
+ args = (char**) (list + i);
+ for (i = 0; options[i].doc; i++)
+ {
+ list[i].set = 0;
+ list[i].arg = 0;
+
+ if (options[i].flags & GRUB_ARG_OPTION_REPEATABLE)
+ {
+ list[i].args = args;
+ args += (grub_size_t) argc / 2 + 1;
+ }
+ }
+ return list;
+}
diff --git a/grub-core/lib/arm/setjmp.S b/grub-core/lib/arm/setjmp.S
new file mode 100644
index 0000000..a5373d3
--- /dev/null
+++ b/grub-core/lib/arm/setjmp.S
@@ -0,0 +1,53 @@
+/*
+ * 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/symbol.h>
+#include <grub/dl.h>
+
+ .file "setjmp.S"
+
+GRUB_MOD_LICENSE "GPLv3+"
+
+ .syntax unified
+#if !defined (__thumb2__)
+ .arm
+#else
+ .thumb
+#endif
+
+ .text
+
+/*
+ * int grub_setjmp (grub_jmp_buf env)
+ */
+FUNCTION(grub_setjmp)
+ mov r12, sp
+ stm r0, { r4-r12, lr }
+ mov r0, #0
+ bx lr
+
+/*
+ * int grub_longjmp (grub_jmp_buf env, int val)
+ */
+FUNCTION(grub_longjmp)
+ ldm r0, { r4-r12, lr }
+ mov sp, r12
+ movs r0, r1
+ it eq
+ moveq r0, #1
+ bx lr
diff --git a/grub-core/lib/arm64/setjmp.S b/grub-core/lib/arm64/setjmp.S
new file mode 100644
index 0000000..ffcabf6
--- /dev/null
+++ b/grub-core/lib/arm64/setjmp.S
@@ -0,0 +1,56 @@
+/*
+ * 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/symbol.h>
+#include <grub/dl.h>
+
+ .file "setjmp.S"
+GRUB_MOD_LICENSE "GPLv3+"
+ .text
+
+/*
+ * int grub_setjmp (grub_jmp_buf env)
+ */
+FUNCTION(grub_setjmp)
+ stp x19, x20, [x0], #16
+ stp x21, x22, [x0], #16
+ stp x23, x24, [x0], #16
+ stp x25, x26, [x0], #16
+ stp x27, x28, [x0], #16
+ stp x29, x30, [x0], #16
+ mov x1, sp
+ str x1, [x0]
+ mov x0, #0
+ ret
+
+/*
+ * int grub_longjmp (grub_jmp_buf env, int val)
+ */
+FUNCTION(grub_longjmp)
+ ldp x19, x20, [x0], #16
+ ldp x21, x22, [x0], #16
+ ldp x23, x24, [x0], #16
+ ldp x25, x26, [x0], #16
+ ldp x27, x28, [x0], #16
+ 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/backtrace.c b/grub-core/lib/backtrace.c
new file mode 100644
index 0000000..825a880
--- /dev/null
+++ b/grub-core/lib/backtrace.c
@@ -0,0 +1,70 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+#include <grub/backtrace.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+void
+grub_backtrace_print_address (void *addr)
+{
+ grub_dl_t mod;
+
+ FOR_DL_MODULES (mod)
+ {
+ grub_dl_segment_t segment;
+ for (segment = mod->segment; segment; segment = segment->next)
+ if (segment->addr <= addr && (grub_uint8_t *) segment->addr
+ + segment->size > (grub_uint8_t *) addr)
+ {
+ grub_printf ("%s.%x+%" PRIxGRUB_SIZE, mod->name, segment->section,
+ (grub_size_t) ((grub_uint8_t *) addr - (grub_uint8_t *) segment->addr));
+ return;
+ }
+ }
+
+ grub_printf ("%p", addr);
+}
+
+static grub_err_t
+grub_cmd_backtrace (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_backtrace ();
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(backtrace)
+{
+ cmd = grub_register_command ("backtrace", grub_cmd_backtrace,
+ 0, N_("Print backtrace."));
+}
+
+GRUB_MOD_FINI(backtrace)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c
new file mode 100644
index 0000000..ed0b149
--- /dev/null
+++ b/grub-core/lib/cmdline.c
@@ -0,0 +1,109 @@
+/* cmdline.c - linux command line handling */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/lib/cmdline.h>
+#include <grub/misc.h>
+
+static unsigned int check_arg (char *c, int *has_space)
+{
+ int space = 0;
+ unsigned int size = 0;
+
+ while (*c)
+ {
+ if (*c == '\\' || *c == '\'' || *c == '"')
+ size++;
+ else if (*c == ' ')
+ space = 1;
+
+ size++;
+ c++;
+ }
+
+ if (space)
+ size += 2;
+
+ if (has_space)
+ *has_space = space;
+
+ return size;
+}
+
+unsigned int grub_loader_cmdline_size (int argc, char *argv[])
+{
+ int i;
+ unsigned int size = 0;
+
+ for (i = 0; i < argc; i++)
+ {
+ size += check_arg (argv[i], 0);
+ size++; /* Separator space or NULL. */
+ }
+
+ if (size == 0)
+ size = 1;
+
+ return size;
+}
+
+grub_err_t
+grub_create_loader_cmdline (int argc, char *argv[], char *buf,
+ grub_size_t size, enum grub_verify_string_type type)
+{
+ int i, space;
+ unsigned int arg_size;
+ char *c, *orig_buf = buf;
+
+ for (i = 0; i < argc; i++)
+ {
+ c = argv[i];
+ arg_size = check_arg(argv[i], &space);
+ arg_size++; /* Separator space or NULL. */
+
+ if (size < arg_size)
+ break;
+
+ size -= arg_size;
+
+ if (space)
+ *buf++ = '"';
+
+ while (*c)
+ {
+ if (*c == '\\' || *c == '\'' || *c == '"')
+ *buf++ = '\\';
+
+ *buf++ = *c;
+ c++;
+ }
+
+ if (space)
+ *buf++ = '"';
+
+ *buf++ = ' ';
+ }
+
+ /* Replace last space with null. */
+ if (i)
+ buf--;
+
+ *buf = 0;
+
+ return grub_verify_string (orig_buf, type);
+}
diff --git a/grub-core/lib/cmos_datetime.c b/grub-core/lib/cmos_datetime.c
new file mode 100644
index 0000000..86cd911
--- /dev/null
+++ b/grub-core/lib/cmos_datetime.c
@@ -0,0 +1,194 @@
+/* kern/cmos_datetime.c - CMOS datetime function.
+ *
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/datetime.h>
+#include <grub/cmos.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#if !defined (__powerpc__) && !defined (__sparc__)
+#define grub_get_datetime_cmos grub_get_datetime
+#define grub_set_datetime_cmos grub_set_datetime
+#endif
+
+grub_err_t
+grub_get_datetime_cmos (struct grub_datetime *datetime)
+{
+ int is_bcd, is_12hour;
+ grub_uint8_t value, flag;
+ grub_err_t err;
+
+ err = grub_cmos_read (GRUB_CMOS_INDEX_STATUS_B, &flag);
+ if (err)
+ return err;
+
+ is_bcd = ! (flag & GRUB_CMOS_STATUS_B_BINARY);
+
+ err = grub_cmos_read (GRUB_CMOS_INDEX_YEAR, &value);
+ if (err)
+ return err;
+ if (is_bcd)
+ value = grub_bcd_to_num (value);
+
+ datetime->year = value;
+ datetime->year += (value < 80) ? 2000 : 1900;
+
+ err = grub_cmos_read (GRUB_CMOS_INDEX_MONTH, &value);
+ if (err)
+ return err;
+ if (is_bcd)
+ value = grub_bcd_to_num (value);
+
+ datetime->month = value;
+
+ err = grub_cmos_read (GRUB_CMOS_INDEX_DAY_OF_MONTH, &value);
+ if (err)
+ return err;
+ if (is_bcd)
+ value = grub_bcd_to_num (value);
+
+ datetime->day = value;
+
+ is_12hour = ! (flag & GRUB_CMOS_STATUS_B_24HOUR);
+
+ err = grub_cmos_read (GRUB_CMOS_INDEX_HOUR, &value);
+ if (err)
+ return err;
+ if (is_12hour)
+ {
+ is_12hour = (value & 0x80);
+
+ value &= 0x7F;
+ value--;
+ }
+
+ if (is_bcd)
+ value = grub_bcd_to_num (value);
+
+ if (is_12hour)
+ value += 12;
+
+ datetime->hour = value;
+
+ err = grub_cmos_read (GRUB_CMOS_INDEX_MINUTE, &value);
+ if (err)
+ return err;
+
+ if (is_bcd)
+ value = grub_bcd_to_num (value);
+
+ datetime->minute = value;
+
+ err = grub_cmos_read (GRUB_CMOS_INDEX_SECOND, &value);
+ if (err)
+ return err;
+ if (is_bcd)
+ value = grub_bcd_to_num (value);
+
+ datetime->second = value;
+
+ return 0;
+}
+
+grub_err_t
+grub_set_datetime_cmos (struct grub_datetime *datetime)
+{
+ int is_bcd, is_12hour;
+ grub_uint8_t value, flag;
+ grub_err_t err;
+
+ err = grub_cmos_read (GRUB_CMOS_INDEX_STATUS_B, &flag);
+ if (err)
+ return err;
+
+ is_bcd = ! (flag & GRUB_CMOS_STATUS_B_BINARY);
+
+ value = ((datetime->year >= 2000) ? datetime->year - 2000 :
+ datetime->year - 1900);
+
+ if (is_bcd)
+ value = grub_num_to_bcd (value);
+
+ err = grub_cmos_write (GRUB_CMOS_INDEX_YEAR, value);
+ if (err)
+ return err;
+
+ value = datetime->month;
+
+ if (is_bcd)
+ value = grub_num_to_bcd (value);
+
+ err = grub_cmos_write (GRUB_CMOS_INDEX_MONTH, value);
+ if (err)
+ return err;
+
+ value = datetime->day;
+
+ if (is_bcd)
+ value = grub_num_to_bcd (value);
+
+ err = grub_cmos_write (GRUB_CMOS_INDEX_DAY_OF_MONTH, value);
+ if (err)
+ return err;
+
+ value = datetime->hour;
+
+ is_12hour = (! (flag & GRUB_CMOS_STATUS_B_24HOUR));
+
+ if (is_12hour)
+ {
+ value++;
+
+ if (value > 12)
+ value -= 12;
+ else
+ is_12hour = 0;
+ }
+
+ if (is_bcd)
+ value = grub_num_to_bcd (value);
+
+ if (is_12hour)
+ value |= 0x80;
+
+ err = grub_cmos_write (GRUB_CMOS_INDEX_HOUR, value);
+ if (err)
+ return err;
+
+ value = datetime->minute;
+
+ if (is_bcd)
+ value = grub_num_to_bcd (value);
+
+ err = grub_cmos_write (GRUB_CMOS_INDEX_MINUTE, value);
+ if (err)
+ return err;
+
+ value = datetime->second;
+
+ if (is_bcd)
+ value = grub_num_to_bcd (value);
+
+ err = grub_cmos_write (GRUB_CMOS_INDEX_SECOND, value);
+ if (err)
+ return err;
+
+ return 0;
+}
diff --git a/grub-core/lib/crc.c b/grub-core/lib/crc.c
new file mode 100644
index 0000000..bf97cc6
--- /dev/null
+++ b/grub-core/lib/crc.c
@@ -0,0 +1,76 @@
+/* crc.c - crc function */
+/*
+ * 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/lib/crc.h>
+
+static grub_uint32_t crc32c_table [256];
+
+/* Helper for init_crc32c_table. */
+static grub_uint32_t
+reflect (grub_uint32_t ref, int len)
+{
+ grub_uint32_t result = 0;
+ int i;
+
+ for (i = 1; i <= len; i++)
+ {
+ if (ref & 1)
+ result |= 1 << (len - i);
+ ref >>= 1;
+ }
+
+ return result;
+}
+
+static void
+init_crc32c_table (void)
+{
+ grub_uint32_t polynomial = 0x1edc6f41;
+ int i, j;
+
+ for(i = 0; i < 256; i++)
+ {
+ crc32c_table[i] = reflect(i, 8) << 24;
+ for (j = 0; j < 8; j++)
+ crc32c_table[i] = (crc32c_table[i] << 1) ^
+ (crc32c_table[i] & (1 << 31) ? polynomial : 0);
+ crc32c_table[i] = reflect(crc32c_table[i], 32);
+ }
+}
+
+grub_uint32_t
+grub_getcrc32c (grub_uint32_t crc, const void *buf, int size)
+{
+ int i;
+ const grub_uint8_t *data = buf;
+
+ if (! crc32c_table[1])
+ init_crc32c_table ();
+
+ crc^= 0xffffffff;
+
+ for (i = 0; i < size; i++)
+ {
+ crc = (crc >> 8) ^ crc32c_table[(crc & 0xFF) ^ *data];
+ data++;
+ }
+
+ return crc ^ 0xffffffff;
+}
diff --git a/grub-core/lib/crc64.c b/grub-core/lib/crc64.c
new file mode 100644
index 0000000..4960f3f
--- /dev/null
+++ b/grub-core/lib/crc64.c
@@ -0,0 +1,114 @@
+/* crc64.c - crc64 function */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/dl.h>
+#include <grub/crypto.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_uint64_t crc64_table [256];
+
+/* Helper for init_crc64_table. */
+static grub_uint64_t
+reflect (grub_uint64_t ref, int len)
+{
+ grub_uint64_t result = 0;
+ int i;
+
+ for (i = 1; i <= len; i++)
+ {
+ if (ref & 1)
+ result |= 1ULL << (len - i);
+ ref >>= 1;
+ }
+
+ return result;
+}
+
+static void
+init_crc64_table (void)
+{
+ grub_uint64_t polynomial = 0x42f0e1eba9ea3693ULL;
+ int i, j;
+
+ for(i = 0; i < 256; i++)
+ {
+ crc64_table[i] = reflect(i, 8) << 56;
+ for (j = 0; j < 8; j++)
+ {
+ crc64_table[i] = (crc64_table[i] << 1) ^
+ (crc64_table[i] & (1ULL << 63) ? polynomial : 0);
+ }
+ crc64_table[i] = reflect(crc64_table[i], 64);
+ }
+}
+
+static void
+crc64_init (void *context)
+{
+ if (! crc64_table[1])
+ init_crc64_table ();
+ *(grub_uint64_t *) context = 0;
+}
+
+static void
+crc64_write (void *context, const void *buf, grub_size_t size)
+{
+ unsigned i;
+ const grub_uint8_t *data = buf;
+ grub_uint64_t crc = ~grub_le_to_cpu64 (*(grub_uint64_t *) context);
+
+ for (i = 0; i < size; i++)
+ {
+ crc = (crc >> 8) ^ crc64_table[(crc & 0xFF) ^ *data];
+ data++;
+ }
+
+ *(grub_uint64_t *) context = grub_cpu_to_le64 (~crc);
+}
+
+static grub_uint8_t *
+crc64_read (void *context)
+{
+ return context;
+}
+
+static void
+crc64_final (void *context __attribute__ ((unused)))
+{
+}
+
+gcry_md_spec_t _gcry_digest_spec_crc64 =
+ {
+ "CRC64", 0, 0, 0, 8,
+ crc64_init, crc64_write, crc64_final, crc64_read,
+ sizeof (grub_uint64_t),
+ .blocksize = 64
+ };
+
+GRUB_MOD_INIT(crc64)
+{
+ grub_md_register (&_gcry_digest_spec_crc64);
+}
+
+GRUB_MOD_FINI(crc64)
+{
+ grub_md_unregister (&_gcry_digest_spec_crc64);
+}
diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c
new file mode 100644
index 0000000..ca334d5
--- /dev/null
+++ b/grub-core/lib/crypto.c
@@ -0,0 +1,493 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
+ * 2007, 2008, 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/crypto.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+#include <grub/env.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_crypto_hmac_handle
+{
+ const struct gcry_md_spec *md;
+ void *ctx;
+ void *opad;
+};
+
+static gcry_cipher_spec_t *grub_ciphers = NULL;
+static gcry_md_spec_t *grub_digests = NULL;
+
+void (*grub_crypto_autoload_hook) (const char *name) = NULL;
+
+/* Based on libgcrypt-1.4.4/src/misc.c. */
+void
+grub_burn_stack (grub_size_t size)
+{
+ char buf[64];
+
+ grub_memset (buf, 0, sizeof (buf));
+ if (size > sizeof (buf))
+ grub_burn_stack (size - sizeof (buf));
+}
+
+void
+_gcry_burn_stack (int size)
+{
+ grub_burn_stack (size);
+}
+
+void __attribute__ ((noreturn))
+_gcry_assert_failed (const char *expr, const char *file, int line,
+ const char *func)
+
+{
+ grub_fatal ("assertion %s at %s:%d (%s) failed\n", expr, file, line, func);
+}
+
+
+void _gcry_log_error (const char *fmt, ...)
+{
+ va_list args;
+ const char *debug = grub_env_get ("debug");
+
+ if (! debug)
+ return;
+
+ if (grub_strword (debug, "all") || grub_strword (debug, "gcrypt"))
+ {
+ grub_printf ("gcrypt error: ");
+ va_start (args, fmt);
+ grub_vprintf (fmt, args);
+ va_end (args);
+ grub_refresh ();
+ }
+}
+
+void
+grub_cipher_register (gcry_cipher_spec_t *cipher)
+{
+ cipher->next = grub_ciphers;
+ grub_ciphers = cipher;
+}
+
+void
+grub_cipher_unregister (gcry_cipher_spec_t *cipher)
+{
+ gcry_cipher_spec_t **ciph;
+ for (ciph = &grub_ciphers; *ciph; ciph = &((*ciph)->next))
+ if (*ciph == cipher)
+ {
+ *ciph = (*ciph)->next;
+ break;
+ }
+}
+
+void
+grub_md_register (gcry_md_spec_t *digest)
+{
+ digest->next = grub_digests;
+ grub_digests = digest;
+}
+
+void
+grub_md_unregister (gcry_md_spec_t *cipher)
+{
+ gcry_md_spec_t **ciph;
+ for (ciph = &grub_digests; *ciph; ciph = &((*ciph)->next))
+ if (*ciph == cipher)
+ {
+ *ciph = (*ciph)->next;
+ break;
+ }
+}
+
+void
+grub_crypto_hash (const gcry_md_spec_t *hash, void *out, const void *in,
+ grub_size_t inlen)
+{
+ GRUB_PROPERLY_ALIGNED_ARRAY (ctx, GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+
+ if (hash->contextsize > sizeof (ctx))
+ grub_fatal ("Too large md context");
+ hash->init (&ctx);
+ hash->write (&ctx, in, inlen);
+ hash->final (&ctx);
+ grub_memcpy (out, hash->read (&ctx), hash->mdlen);
+}
+
+const gcry_md_spec_t *
+grub_crypto_lookup_md_by_name (const char *name)
+{
+ const gcry_md_spec_t *md;
+ int first = 1;
+ while (1)
+ {
+ for (md = grub_digests; md; md = md->next)
+ if (grub_strcasecmp (name, md->name) == 0)
+ return md;
+ if (grub_crypto_autoload_hook && first)
+ grub_crypto_autoload_hook (name);
+ else
+ return NULL;
+ first = 0;
+ }
+}
+
+const gcry_cipher_spec_t *
+grub_crypto_lookup_cipher_by_name (const char *name)
+{
+ const gcry_cipher_spec_t *ciph;
+ int first = 1;
+ while (1)
+ {
+ for (ciph = grub_ciphers; ciph; ciph = ciph->next)
+ {
+ const char **alias;
+ if (grub_strcasecmp (name, ciph->name) == 0)
+ return ciph;
+ if (!ciph->aliases)
+ continue;
+ for (alias = ciph->aliases; *alias; alias++)
+ if (grub_strcasecmp (name, *alias) == 0)
+ return ciph;
+ }
+ if (grub_crypto_autoload_hook && first)
+ grub_crypto_autoload_hook (name);
+ else
+ return NULL;
+ first = 0;
+ }
+}
+
+
+grub_crypto_cipher_handle_t
+grub_crypto_cipher_open (const struct gcry_cipher_spec *cipher)
+{
+ grub_crypto_cipher_handle_t ret;
+ ret = grub_malloc (sizeof (*ret) + cipher->contextsize);
+ if (!ret)
+ return NULL;
+ ret->cipher = cipher;
+ return ret;
+}
+
+gcry_err_code_t
+grub_crypto_cipher_set_key (grub_crypto_cipher_handle_t cipher,
+ const unsigned char *key,
+ unsigned keylen)
+{
+ return cipher->cipher->setkey (cipher->ctx, key, keylen);
+}
+
+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, *end;
+ grub_uint8_t *outptr;
+ grub_size_t blocksize;
+ if (!cipher->cipher->decrypt)
+ return GPG_ERR_NOT_SUPPORTED;
+ blocksize = cipher->cipher->blocksize;
+ if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
+ || ((size & (blocksize - 1)) != 0))
+ return GPG_ERR_INV_ARG;
+ end = (const grub_uint8_t *) in + size;
+ for (inptr = in, outptr = out; inptr < end;
+ inptr += blocksize, outptr += blocksize)
+ cipher->cipher->decrypt (cipher->ctx, outptr, inptr);
+ return GPG_ERR_NO_ERROR;
+}
+
+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, *end;
+ grub_uint8_t *outptr;
+ grub_size_t blocksize;
+ if (!cipher->cipher->encrypt)
+ return GPG_ERR_NOT_SUPPORTED;
+ blocksize = cipher->cipher->blocksize;
+ if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
+ || ((size & (blocksize - 1)) != 0))
+ return GPG_ERR_INV_ARG;
+ end = (const grub_uint8_t *) in + size;
+ for (inptr = in, outptr = out; inptr < end;
+ 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, const void *in, grub_size_t size,
+ void *iv_in)
+{
+ grub_uint8_t *outptr;
+ const grub_uint8_t *inptr, *end;
+ void *iv;
+ grub_size_t blocksize;
+ if (!cipher->cipher->encrypt)
+ return GPG_ERR_NOT_SUPPORTED;
+ blocksize = cipher->cipher->blocksize;
+ if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
+ || ((size & (blocksize - 1)) != 0))
+ return GPG_ERR_INV_ARG;
+ end = (const grub_uint8_t *) in + size;
+ iv = iv_in;
+ for (inptr = in, outptr = out; inptr < end;
+ inptr += blocksize, outptr += blocksize)
+ {
+ grub_crypto_xor (outptr, inptr, iv, blocksize);
+ cipher->cipher->encrypt (cipher->ctx, outptr, outptr);
+ iv = outptr;
+ }
+ grub_memcpy (iv_in, iv, blocksize);
+ return GPG_ERR_NO_ERROR;
+}
+
+gcry_err_code_t
+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, *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;
+ 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 = (const grub_uint8_t *) in + size;
+ for (inptr = in, outptr = out; inptr < end;
+ inptr += blocksize, outptr += blocksize)
+ {
+ grub_memcpy (ivt, inptr, blocksize);
+ cipher->cipher->decrypt (cipher->ctx, outptr, inptr);
+ grub_crypto_xor (outptr, outptr, iv, blocksize);
+ grub_memcpy (iv, ivt, blocksize);
+ }
+ return GPG_ERR_NO_ERROR;
+}
+
+/* Based on gcry/cipher/md.c. */
+struct grub_crypto_hmac_handle *
+grub_crypto_hmac_init (const struct gcry_md_spec *md,
+ const void *key, grub_size_t keylen)
+{
+ grub_uint8_t *helpkey = NULL;
+ grub_uint8_t *ipad = NULL, *opad = NULL;
+ void *ctx = NULL;
+ struct grub_crypto_hmac_handle *ret = NULL;
+ unsigned i;
+
+ if (md->mdlen > md->blocksize)
+ return NULL;
+
+ ctx = grub_malloc (md->contextsize);
+ if (!ctx)
+ goto err;
+
+ if ( keylen > md->blocksize )
+ {
+ helpkey = grub_malloc (md->mdlen);
+ if (!helpkey)
+ goto err;
+ grub_crypto_hash (md, helpkey, key, keylen);
+
+ key = helpkey;
+ keylen = md->mdlen;
+ }
+
+ ipad = grub_zalloc (md->blocksize);
+ if (!ipad)
+ goto err;
+
+ opad = grub_zalloc (md->blocksize);
+ if (!opad)
+ goto err;
+
+ grub_memcpy ( ipad, key, keylen );
+ grub_memcpy ( opad, key, keylen );
+ for (i=0; i < md->blocksize; i++ )
+ {
+ ipad[i] ^= 0x36;
+ opad[i] ^= 0x5c;
+ }
+ grub_free (helpkey);
+ helpkey = NULL;
+
+ md->init (ctx);
+
+ md->write (ctx, ipad, md->blocksize); /* inner pad */
+ grub_memset (ipad, 0, md->blocksize);
+ grub_free (ipad);
+ ipad = NULL;
+
+ ret = grub_malloc (sizeof (*ret));
+ if (!ret)
+ goto err;
+
+ ret->md = md;
+ ret->ctx = ctx;
+ ret->opad = opad;
+
+ return ret;
+
+ err:
+ grub_free (helpkey);
+ grub_free (ctx);
+ grub_free (ipad);
+ grub_free (opad);
+ return NULL;
+}
+
+void
+grub_crypto_hmac_write (struct grub_crypto_hmac_handle *hnd,
+ const void *data,
+ grub_size_t datalen)
+{
+ hnd->md->write (hnd->ctx, data, datalen);
+}
+
+gcry_err_code_t
+grub_crypto_hmac_fini (struct grub_crypto_hmac_handle *hnd, void *out)
+{
+ grub_uint8_t *p;
+ grub_uint8_t *ctx2;
+
+ ctx2 = grub_malloc (hnd->md->contextsize);
+ if (!ctx2)
+ return GPG_ERR_OUT_OF_MEMORY;
+
+ hnd->md->final (hnd->ctx);
+ hnd->md->read (hnd->ctx);
+ p = hnd->md->read (hnd->ctx);
+
+ hnd->md->init (ctx2);
+ hnd->md->write (ctx2, hnd->opad, hnd->md->blocksize);
+ hnd->md->write (ctx2, p, hnd->md->mdlen);
+ hnd->md->final (ctx2);
+ grub_memset (hnd->opad, 0, hnd->md->blocksize);
+ grub_free (hnd->opad);
+ grub_memset (hnd->ctx, 0, hnd->md->contextsize);
+ grub_free (hnd->ctx);
+
+ grub_memcpy (out, hnd->md->read (ctx2), hnd->md->mdlen);
+ grub_memset (ctx2, 0, hnd->md->contextsize);
+ grub_free (ctx2);
+
+ grub_memset (hnd, 0, sizeof (*hnd));
+ grub_free (hnd);
+
+ return GPG_ERR_NO_ERROR;
+}
+
+gcry_err_code_t
+grub_crypto_hmac_buffer (const struct gcry_md_spec *md,
+ const void *key, grub_size_t keylen,
+ const void *data, grub_size_t datalen, void *out)
+{
+ struct grub_crypto_hmac_handle *hnd;
+
+ hnd = grub_crypto_hmac_init (md, key, keylen);
+ if (!hnd)
+ return GPG_ERR_OUT_OF_MEMORY;
+
+ grub_crypto_hmac_write (hnd, data, datalen);
+ return grub_crypto_hmac_fini (hnd, out);
+}
+
+
+grub_err_t
+grub_crypto_gcry_error (gcry_err_code_t in)
+{
+ if (in == GPG_ERR_NO_ERROR)
+ return GRUB_ERR_NONE;
+ return GRUB_ACCESS_DENIED;
+}
+
+int
+grub_crypto_memcmp (const void *a, const void *b, grub_size_t n)
+{
+ register grub_size_t counter = 0;
+ const grub_uint8_t *pa, *pb;
+
+ for (pa = a, pb = b; n; pa++, pb++, n--)
+ {
+ if (*pa != *pb)
+ counter++;
+ }
+
+ return !!counter;
+}
+
+#ifndef GRUB_UTIL
+
+int
+grub_password_get (char buf[], unsigned buf_size)
+{
+ unsigned cur_len = 0;
+ int key;
+
+ while (1)
+ {
+ key = grub_getkey ();
+ if (key == '\n' || key == '\r')
+ break;
+
+ if (key == GRUB_TERM_ESC)
+ {
+ cur_len = 0;
+ break;
+ }
+
+ if (key == '\b')
+ {
+ if (cur_len)
+ cur_len--;
+ continue;
+ }
+
+ if (!grub_isprint (key))
+ continue;
+
+ if (cur_len + 2 < buf_size)
+ buf[cur_len++] = key;
+ }
+
+ grub_memset (buf + cur_len, 0, buf_size - cur_len);
+
+ grub_xputs ("\n");
+ grub_refresh ();
+
+ return (key != GRUB_TERM_ESC);
+}
+#endif
+
diff --git a/grub-core/lib/datetime.c b/grub-core/lib/datetime.c
new file mode 100644
index 0000000..9120128
--- /dev/null
+++ b/grub-core/lib/datetime.c
@@ -0,0 +1,117 @@
+/* datetime.c - Module for common datetime function. */
+/*
+ * 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/datetime.h>
+#include <grub/i18n.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+
+static const char *const grub_weekday_names[] =
+{
+ N_("Sunday"),
+ N_("Monday"),
+ N_("Tuesday"),
+ N_("Wednesday"),
+ N_("Thursday"),
+ N_("Friday"),
+ N_("Saturday"),
+};
+
+int
+grub_get_weekday (struct grub_datetime *datetime)
+{
+ unsigned a, y, m;
+
+ if (datetime->month <= 2)
+ a = 1;
+ else
+ a = 0;
+ y = datetime->year - a;
+ m = datetime->month + 12 * a - 2;
+
+ return (datetime->day + y + y / 4 - y / 100 + y / 400 + (31 * m / 12)) % 7;
+}
+
+const char *
+grub_get_weekday_name (struct grub_datetime *datetime)
+{
+ return _ (grub_weekday_names[grub_get_weekday (datetime)]);
+}
+
+#define SECPERMIN 60
+#define SECPERHOUR (60*SECPERMIN)
+#define SECPERDAY (24*SECPERHOUR)
+#define DAYSPERYEAR 365
+#define DAYSPER4YEARS (4*DAYSPERYEAR+1)
+
+
+void
+grub_unixtime2datetime (grub_int64_t nix, struct grub_datetime *datetime)
+{
+ int i;
+ grub_uint8_t months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+ /* In the period of validity of unixtime all years divisible by 4
+ are bissextile*/
+ /* Convenience: let's have 3 consecutive non-bissextile years
+ at the beginning of the counting date. So count from 1901. */
+ int days_epoch;
+ /* Number of days since 1st Januar, 1901. */
+ unsigned days;
+ /* Seconds into current day. */
+ unsigned secs_in_day;
+
+ /* Transform C divisions and modulos to mathematical ones */
+ if (nix < 0)
+ /*
+ * The result of division here shouldn't be larger than GRUB_INT_MAX.
+ * So, it's safe to store the result back in an int.
+ */
+ days_epoch = -(grub_divmod64 (((grub_int64_t) (SECPERDAY) - nix - 1), SECPERDAY, NULL));
+ else
+ days_epoch = grub_divmod64 (nix, SECPERDAY, NULL);
+
+ secs_in_day = nix - days_epoch * SECPERDAY;
+ days = days_epoch + 69 * DAYSPERYEAR + 17;
+
+ datetime->year = 1901 + 4 * (days / DAYSPER4YEARS);
+ days %= DAYSPER4YEARS;
+ /* On 31st December of bissextile years 365 days from the beginning
+ of the year elapsed but year isn't finished yet */
+ if (days / DAYSPERYEAR == 4)
+ {
+ datetime->year += 3;
+ days -= 3*DAYSPERYEAR;
+ }
+ else
+ {
+ datetime->year += days / DAYSPERYEAR;
+ days %= DAYSPERYEAR;
+ }
+ for (i = 0; i < 12
+ && days >= (i==1 && datetime->year % 4 == 0
+ ? 29 : months[i]); i++)
+ days -= (i==1 && datetime->year % 4 == 0
+ ? 29 : months[i]);
+ datetime->month = i + 1;
+ datetime->day = 1 + days;
+ datetime->hour = (secs_in_day / SECPERHOUR);
+ secs_in_day %= SECPERHOUR;
+ datetime->minute = secs_in_day / SECPERMIN;
+ datetime->second = secs_in_day % SECPERMIN;
+}
diff --git a/grub-core/lib/disk.c b/grub-core/lib/disk.c
new file mode 100644
index 0000000..b4eb064
--- /dev/null
+++ b/grub-core/lib/disk.c
@@ -0,0 +1,161 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/disk.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/partition.h>
+#include <grub/misc.h>
+#include <grub/time.h>
+#include <grub/file.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#include "../kern/disk_common.c"
+
+static void
+grub_disk_cache_invalidate (unsigned long dev_id, unsigned long disk_id,
+ grub_disk_addr_t sector)
+{
+ unsigned cache_index;
+ struct grub_disk_cache *cache;
+
+ 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;
+
+ if (cache->dev_id == dev_id && cache->disk_id == disk_id
+ && cache->sector == sector && cache->data)
+ {
+ cache->lock = 1;
+ grub_free (cache->data);
+ cache->data = 0;
+ cache->lock = 0;
+ }
+}
+
+grub_err_t
+grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector,
+ grub_off_t offset, grub_size_t size, const void *buf)
+{
+ unsigned real_offset;
+ grub_disk_addr_t aligned_sector;
+
+ grub_dprintf ("disk", "Writing `%s'...\n", disk->name);
+
+ if (grub_disk_adjust_range (disk, &sector, &offset, size) != GRUB_ERR_NONE)
+ return -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;
+
+ while (size)
+ {
+ if (real_offset != 0 || (size < (1U << disk->log_sector_size)
+ && size != 0))
+ {
+ char *tmp_buf;
+ grub_size_t len;
+ grub_partition_t part;
+
+ 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, (1U << disk->log_sector_size), tmp_buf)
+ != GRUB_ERR_NONE)
+ {
+ disk->partition = part;
+ grub_free (tmp_buf);
+ goto finish;
+ }
+ disk->partition = part;
+
+ len = (1U << disk->log_sector_size) - real_offset;
+ if (len > size)
+ len = size;
+
+ grub_memcpy (tmp_buf + real_offset, buf, len);
+
+ grub_disk_cache_invalidate (disk->dev->id, disk->id, sector);
+
+ if ((disk->dev->disk_write) (disk, transform_sector (disk, sector),
+ 1, tmp_buf) != GRUB_ERR_NONE)
+ {
+ grub_free (tmp_buf);
+ goto finish;
+ }
+
+ grub_free (tmp_buf);
+
+ sector += (1U << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
+ buf = (const char *) buf + len;
+ size -= len;
+ real_offset = 0;
+ }
+ else
+ {
+ grub_size_t len;
+ grub_size_t n;
+
+ len = size & ~((1ULL << disk->log_sector_size) - 1);
+ n = size >> disk->log_sector_size;
+
+ if (n > (disk->max_agglomerate
+ << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS
+ - disk->log_sector_size)))
+ n = (disk->max_agglomerate
+ << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS
+ - disk->log_sector_size));
+
+ if ((disk->dev->disk_write) (disk, transform_sector (disk, sector),
+ n, buf) != GRUB_ERR_NONE)
+ goto finish;
+
+ while (n--)
+ {
+ grub_disk_cache_invalidate (disk->dev->id, disk->id, sector);
+ sector += (1U << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
+ }
+
+ buf = (const char *) buf + len;
+ size -= len;
+ }
+ }
+
+ finish:
+
+ return grub_errno;
+}
+
+GRUB_MOD_INIT(disk)
+{
+ grub_disk_write_weak = grub_disk_write;
+}
+
+GRUB_MOD_FINI(disk)
+{
+ grub_disk_write_weak = NULL;
+}
diff --git a/grub-core/lib/division.c b/grub-core/lib/division.c
new file mode 100644
index 0000000..35606fe
--- /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/dummy/datetime.c b/grub-core/lib/dummy/datetime.c
new file mode 100644
index 0000000..cf693fc
--- /dev/null
+++ b/grub-core/lib/dummy/datetime.c
@@ -0,0 +1,40 @@
+/*
+ * 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/types.h>
+#include <grub/symbol.h>
+#include <grub/datetime.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* No simple platform-independent RTC access exists in U-Boot. */
+
+grub_err_t
+grub_get_datetime (struct grub_datetime *datetime __attribute__ ((unused)))
+{
+ return grub_error (GRUB_ERR_INVALID_COMMAND,
+ "can\'t get datetime on this machine");
+}
+
+grub_err_t
+grub_set_datetime (struct grub_datetime * datetime __attribute__ ((unused)))
+{
+ return grub_error (GRUB_ERR_INVALID_COMMAND,
+ "can\'t set datetime on this machine");
+}
diff --git a/grub-core/lib/dummy/halt.c b/grub-core/lib/dummy/halt.c
new file mode 100644
index 0000000..378d50f
--- /dev/null
+++ b/grub-core/lib/dummy/halt.c
@@ -0,0 +1,32 @@
+/*
+ * 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/misc.h>
+#include <grub/mm.h>
+#include <grub/kernel.h>
+#include <grub/loader.h>
+
+void
+grub_halt (void)
+{
+ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN);
+
+ /* Just stop here */
+
+ while (1);
+}
diff --git a/grub-core/lib/dummy/reboot.c b/grub-core/lib/dummy/reboot.c
new file mode 100644
index 0000000..b8cbed8
--- /dev/null
+++ b/grub-core/lib/dummy/reboot.c
@@ -0,0 +1,32 @@
+/*
+ * 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/misc.h>
+#include <grub/mm.h>
+#include <grub/kernel.h>
+#include <grub/loader.h>
+
+void
+grub_reboot (void)
+{
+ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN);
+
+ /* Just stop here */
+
+ while (1);
+}
diff --git a/grub-core/lib/efi/datetime.c b/grub-core/lib/efi/datetime.c
new file mode 100644
index 0000000..0fd1b5f
--- /dev/null
+++ b/grub-core/lib/efi/datetime.c
@@ -0,0 +1,82 @@
+/* kern/efi/datetime.c - efi datetime function.
+ *
+ * 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/symbol.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/datetime.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+grub_err_t
+grub_get_datetime (struct grub_datetime *datetime)
+{
+ grub_efi_status_t status;
+ struct grub_efi_time efi_time;
+
+ status = efi_call_2 (grub_efi_system_table->runtime_services->get_time,
+ &efi_time, 0);
+
+ if (status)
+ return grub_error (GRUB_ERR_INVALID_COMMAND,
+ "can\'t get datetime using efi");
+ else
+ {
+ datetime->year = efi_time.year;
+ datetime->month = efi_time.month;
+ datetime->day = efi_time.day;
+ datetime->hour = efi_time.hour;
+ datetime->minute = efi_time.minute;
+ datetime->second = efi_time.second;
+ }
+
+ return 0;
+}
+
+grub_err_t
+grub_set_datetime (struct grub_datetime *datetime)
+{
+ grub_efi_status_t status;
+ struct grub_efi_time efi_time;
+
+ status = efi_call_2 (grub_efi_system_table->runtime_services->get_time,
+ &efi_time, 0);
+
+ if (status)
+ return grub_error (GRUB_ERR_INVALID_COMMAND,
+ "can\'t get datetime using efi");
+
+ efi_time.year = datetime->year;
+ efi_time.month = datetime->month;
+ efi_time.day = datetime->day;
+ efi_time.hour = datetime->hour;
+ efi_time.minute = datetime->minute;
+ efi_time.second = datetime->second;
+
+ status = efi_call_1 (grub_efi_system_table->runtime_services->set_time,
+ &efi_time);
+
+ if (status)
+ return grub_error (GRUB_ERR_INVALID_COMMAND,
+ "can\'t set datetime using efi");
+
+ return 0;
+}
diff --git a/grub-core/lib/efi/halt.c b/grub-core/lib/efi/halt.c
new file mode 100644
index 0000000..29d4136
--- /dev/null
+++ b/grub-core/lib/efi/halt.c
@@ -0,0 +1,41 @@
+/* efi.c - generic EFI support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/kernel.h>
+#include <grub/acpi.h>
+#include <grub/loader.h>
+
+void
+grub_halt (void)
+{
+ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN |
+ GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY);
+#if !defined(__ia64__) && !defined(__arm__) && !defined(__aarch64__) && \
+ !defined(__riscv)
+ grub_acpi_halt ();
+#endif
+ efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
+ GRUB_EFI_RESET_SHUTDOWN, GRUB_EFI_SUCCESS, 0, NULL);
+
+ while (1);
+}
diff --git a/grub-core/lib/efi/relocator.c b/grub-core/lib/efi/relocator.c
new file mode 100644
index 0000000..319b69e
--- /dev/null
+++ b/grub-core/lib/efi/relocator.c
@@ -0,0 +1,119 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/relocator.h>
+#include <grub/relocator_private.h>
+#include <grub/memory.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/api.h>
+#include <grub/term.h>
+
+#define NEXT_MEMORY_DESCRIPTOR(desc, size) \
+ ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
+
+unsigned
+grub_relocator_firmware_get_max_events (void)
+{
+ grub_efi_uintn_t mmapsize = 0, descriptor_size = 0;
+ grub_efi_uint32_t descriptor_version = 0;
+ grub_efi_uintn_t key;
+ grub_efi_get_memory_map (&mmapsize, NULL, &key, &descriptor_size,
+ &descriptor_version);
+ /* Since grub_relocator_firmware_fill_events uses malloc
+ we need some reserve. Hence +10. */
+ return 2 * (mmapsize / descriptor_size + 10);
+}
+
+unsigned
+grub_relocator_firmware_fill_events (struct grub_relocator_mmap_event *events)
+{
+ grub_efi_uintn_t mmapsize = 0, desc_size = 0;
+ grub_efi_uint32_t descriptor_version = 0;
+ grub_efi_memory_descriptor_t *descs = NULL;
+ grub_efi_uintn_t key;
+ int counter = 0;
+ grub_efi_memory_descriptor_t *desc;
+
+ grub_efi_get_memory_map (&mmapsize, NULL, &key, &desc_size,
+ &descriptor_version);
+ descs = grub_malloc (mmapsize);
+ if (!descs)
+ return 0;
+
+ grub_efi_get_memory_map (&mmapsize, descs, &key, &desc_size,
+ &descriptor_version);
+
+ for (desc = descs;
+ (char *) desc < ((char *) descs + mmapsize);
+ desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
+ {
+ grub_uint64_t start = desc->physical_start;
+ grub_uint64_t end = desc->physical_start + (desc->num_pages << 12);
+
+ /* post-4G addresses are never supported on 32-bit EFI.
+ Moreover it has been reported that some 64-bit EFI contrary to the
+ spec don't map post-4G pages. So if you enable post-4G allocations,
+ map pages manually or check that they are mapped.
+ */
+ if (end >= 0x100000000ULL)
+ end = 0x100000000ULL;
+ if (end <= start)
+ continue;
+ if (desc->type != GRUB_EFI_CONVENTIONAL_MEMORY)
+ continue;
+ events[counter].type = REG_FIRMWARE_START;
+ events[counter].pos = start;
+ counter++;
+ events[counter].type = REG_FIRMWARE_END;
+ events[counter].pos = end;
+ counter++;
+ }
+
+ return counter;
+}
+
+int
+grub_relocator_firmware_alloc_region (grub_addr_t start, grub_size_t size)
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_physical_address_t address = start;
+ grub_efi_status_t status;
+
+ if (grub_efi_is_finished)
+ return 1;
+#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF
+ grub_dprintf ("relocator", "EFI alloc: %llx, %llx\n",
+ (unsigned long long) start, (unsigned long long) size);
+#endif
+ b = grub_efi_system_table->boot_services;
+ status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ADDRESS,
+ GRUB_EFI_LOADER_DATA, size >> 12, &address);
+ return (status == GRUB_EFI_SUCCESS);
+}
+
+void
+grub_relocator_firmware_free_region (grub_addr_t start, grub_size_t size)
+{
+ grub_efi_boot_services_t *b;
+
+ if (grub_efi_is_finished)
+ return;
+
+ b = grub_efi_system_table->boot_services;
+ efi_call_2 (b->free_pages, start, size >> 12);
+}
diff --git a/grub-core/lib/emu/halt.c b/grub-core/lib/emu/halt.c
new file mode 100644
index 0000000..620935b
--- /dev/null
+++ b/grub-core/lib/emu/halt.c
@@ -0,0 +1,25 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+
+void
+grub_halt (void)
+{
+ grub_reboot ();
+}
diff --git a/grub-core/lib/envblk.c b/grub-core/lib/envblk.c
new file mode 100644
index 0000000..2e4e78b
--- /dev/null
+++ b/grub-core/lib/envblk.c
@@ -0,0 +1,297 @@
+/* envblk.c - Common functions for environment block. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/lib/envblk.h>
+
+grub_envblk_t
+grub_envblk_open (char *buf, grub_size_t size)
+{
+ grub_envblk_t envblk;
+
+ if (size < sizeof (GRUB_ENVBLK_SIGNATURE)
+ || grub_memcmp (buf, GRUB_ENVBLK_SIGNATURE,
+ sizeof (GRUB_ENVBLK_SIGNATURE) - 1))
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid environment block");
+ return 0;
+ }
+
+ envblk = grub_malloc (sizeof (*envblk));
+ if (envblk)
+ {
+ envblk->buf = buf;
+ envblk->size = size;
+ }
+
+ return envblk;
+}
+
+void
+grub_envblk_close (grub_envblk_t envblk)
+{
+ grub_free (envblk->buf);
+ grub_free (envblk);
+}
+
+static int
+escaped_value_len (const char *value)
+{
+ int n = 0;
+ char *p;
+
+ for (p = (char *) value; *p; p++)
+ {
+ if (*p == '\\' || *p == '\n')
+ n += 2;
+ else
+ n++;
+ }
+
+ return n;
+}
+
+static char *
+find_next_line (char *p, const char *pend)
+{
+ while (p < pend)
+ {
+ if (*p == '\\')
+ p += 2;
+ else if (*p == '\n')
+ break;
+ else
+ p++;
+ }
+
+ return p + 1;
+}
+
+int
+grub_envblk_set (grub_envblk_t envblk, const char *name, const char *value)
+{
+ char *p, *pend;
+ char *space;
+ int found = 0;
+ int nl;
+ int vl;
+ int i;
+
+ nl = grub_strlen (name);
+ vl = escaped_value_len (value);
+ p = envblk->buf + sizeof (GRUB_ENVBLK_SIGNATURE) - 1;
+ pend = envblk->buf + envblk->size;
+
+ /* First, look at free space. */
+ for (space = pend - 1; *space == '#'; space--)
+ ;
+
+ if (*space != '\n')
+ /* Broken. */
+ return 0;
+
+ space++;
+
+ while (p + nl + 1 < space)
+ {
+ if (grub_memcmp (p, name, nl) == 0 && p[nl] == '=')
+ {
+ int len;
+
+ /* Found the same name. */
+ p += nl + 1;
+
+ /* Check the length of the current value. */
+ len = 0;
+ while (p + len < pend && p[len] != '\n')
+ {
+ if (p[len] == '\\')
+ len += 2;
+ else
+ len++;
+ }
+
+ if (p + len >= pend)
+ /* Broken. */
+ return 0;
+
+ if (pend - space < vl - len)
+ /* No space. */
+ return 0;
+
+ if (vl < len)
+ {
+ /* Move the following characters backward, and fill the new
+ space with harmless characters. */
+ grub_memmove (p + vl, p + len, pend - (p + len));
+ grub_memset (space - (len - vl), '#', len - vl);
+ }
+ else
+ /* Move the following characters forward. */
+ grub_memmove (p + vl, p + len, pend - (p + vl));
+
+ found = 1;
+ break;
+ }
+
+ p = find_next_line (p, pend);
+ }
+
+ if (! found)
+ {
+ /* Append a new variable. */
+
+ if (pend - space < nl + 1 + vl + 1)
+ /* No space. */
+ return 0;
+
+ grub_memcpy (space, name, nl);
+ p = space + nl;
+ *p++ = '=';
+ }
+
+ /* Write the value. */
+ for (i = 0; value[i]; i++)
+ {
+ if (value[i] == '\\' || value[i] == '\n')
+ *p++ = '\\';
+
+ *p++ = value[i];
+ }
+
+ *p = '\n';
+ return 1;
+}
+
+void
+grub_envblk_delete (grub_envblk_t envblk, const char *name)
+{
+ char *p, *pend;
+ int nl;
+
+ nl = grub_strlen (name);
+ p = envblk->buf + sizeof (GRUB_ENVBLK_SIGNATURE) - 1;
+ pend = envblk->buf + envblk->size;
+
+ while (p + nl + 1 < pend)
+ {
+ if (grub_memcmp (p, name, nl) == 0 && p[nl] == '=')
+ {
+ /* Found. */
+ int len = nl + 1;
+
+ while (p + len < pend)
+ {
+ if (p[len] == '\n')
+ break;
+ else if (p[len] == '\\')
+ len += 2;
+ else
+ len++;
+ }
+
+ if (p + len >= pend)
+ /* Broken. */
+ return;
+
+ len++;
+ grub_memmove (p, p + len, pend - (p + len));
+ grub_memset (pend - len, '#', len);
+ break;
+ }
+
+ p = find_next_line (p, pend);
+ }
+}
+
+void
+grub_envblk_iterate (grub_envblk_t envblk,
+ void *hook_data,
+ int hook (const char *name, const char *value, void *hook_data))
+{
+ char *p, *pend;
+
+ p = envblk->buf + sizeof (GRUB_ENVBLK_SIGNATURE) - 1;
+ pend = envblk->buf + envblk->size;
+
+ while (p < pend)
+ {
+ if (*p != '#')
+ {
+ char *name;
+ char *value;
+ char *name_start, *name_end, *value_start;
+ char *q;
+ int ret;
+
+ name_start = p;
+ while (p < pend && *p != '=')
+ p++;
+ if (p == pend)
+ /* Broken. */
+ return;
+ name_end = p;
+
+ p++;
+ value_start = p;
+ while (p < pend)
+ {
+ if (*p == '\n')
+ break;
+ else if (*p == '\\')
+ p += 2;
+ else
+ p++;
+ }
+
+ if (p >= pend)
+ /* Broken. */
+ return;
+
+ name = grub_malloc (p - name_start + 1);
+ if (! name)
+ /* out of memory. */
+ return;
+
+ value = name + (value_start - name_start);
+
+ grub_memcpy (name, name_start, name_end - name_start);
+ name[name_end - name_start] = '\0';
+
+ for (p = value_start, q = value; *p != '\n'; ++p)
+ {
+ if (*p == '\\')
+ *q++ = *++p;
+ else
+ *q++ = *p;
+ }
+ *q = '\0';
+
+ ret = hook (name, value, hook_data);
+ grub_free (name);
+ if (ret)
+ return;
+ }
+
+ p = find_next_line (p, pend);
+ }
+}
diff --git a/grub-core/lib/fake_module.c b/grub-core/lib/fake_module.c
new file mode 100644
index 0000000..3646ced
--- /dev/null
+++ b/grub-core/lib/fake_module.c
@@ -0,0 +1,4 @@
+/* This file is intentionally empty: it's used to generate modules with no code or data. (purely dependency modules) */
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c
new file mode 100644
index 0000000..0d371c5
--- /dev/null
+++ b/grub-core/lib/fdt.c
@@ -0,0 +1,531 @@
+/*
+ * 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/fdt.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define FDT_SUPPORTED_VERSION 17
+
+#define FDT_BEGIN_NODE 0x00000001
+#define FDT_END_NODE 0x00000002
+#define FDT_PROP 0x00000003
+#define FDT_NOP 0x00000004
+#define FDT_END 0x00000009
+
+#define struct_end(fdt) \
+ ((grub_addr_t) fdt + grub_fdt_get_off_dt_struct(fdt) \
+ + grub_fdt_get_size_dt_struct(fdt))
+
+/* Size needed by a node entry: 2 tokens (FDT_BEGIN_NODE and FDT_END_NODE), plus
+ the NULL-terminated string containing the name, plus padding if needed. */
+#define node_entry_size(node_name) \
+ (2 * sizeof(grub_uint32_t) \
+ + ALIGN_UP (grub_strlen (name) + 1, sizeof(grub_uint32_t)))
+
+#define SKIP_NODE_NAME(name, token, end) \
+ name = (char *) ((token) + 1); \
+ while (name < (char *) end) \
+ { \
+ if (!*name++) \
+ break; \
+ } \
+ token = (grub_uint32_t *) ALIGN_UP((grub_addr_t) (name), sizeof(*token))
+
+
+static grub_uint32_t *get_next_node (const void *fdt, char *node_name)
+{
+ grub_uint32_t *end = (void *) struct_end (fdt);
+ grub_uint32_t *token;
+
+ if (node_name >= (char *) end)
+ return NULL;
+ while (*node_name++)
+ {
+ if (node_name >= (char *) end)
+ return NULL;
+ }
+ token = (grub_uint32_t *) ALIGN_UP ((grub_addr_t) node_name, 4);
+ while (token < end)
+ {
+ switch (grub_be_to_cpu32(*token))
+ {
+ case FDT_BEGIN_NODE:
+ token = get_next_node (fdt, (char *) (token + 1));
+ if (!token)
+ return NULL;
+ break;
+ case FDT_END_NODE:
+ token++;
+ if (token >= end)
+ return NULL;
+ return token;
+ case FDT_PROP:
+ /* Skip property token and following data (len, nameoff and property
+ value). */
+ token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1)))
+ / sizeof(*token);
+ break;
+ case FDT_NOP:
+ token++;
+ break;
+ default:
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+static int get_mem_rsvmap_size (const void *fdt)
+{
+ int size = 0;
+ grub_unaligned_uint64_t *ptr = (void *) ((grub_addr_t) fdt
+ + grub_fdt_get_off_mem_rsvmap (fdt));
+
+ do
+ {
+ size += 2 * sizeof(*ptr);
+ if (!ptr[0].val && !ptr[1].val)
+ return size;
+ ptr += 2;
+ } while ((grub_addr_t) ptr <= (grub_addr_t) fdt + grub_fdt_get_totalsize (fdt)
+ - 2 * sizeof(grub_uint64_t));
+ return -1;
+}
+
+static grub_uint32_t get_free_space (void *fdt)
+{
+ int mem_rsvmap_size = get_mem_rsvmap_size (fdt);
+
+ if (mem_rsvmap_size < 0)
+ /* invalid memory reservation block */
+ return 0;
+ return (grub_fdt_get_totalsize (fdt) - sizeof(grub_fdt_header_t)
+ - mem_rsvmap_size - grub_fdt_get_size_dt_strings (fdt)
+ - grub_fdt_get_size_dt_struct (fdt));
+}
+
+static int add_subnode (void *fdt, int parentoffset, const char *name)
+{
+ grub_uint32_t *token = (void *) ((grub_addr_t) fdt
+ + grub_fdt_get_off_dt_struct(fdt)
+ + parentoffset);
+ grub_uint32_t *end = (void *) struct_end (fdt);
+ unsigned int entry_size = node_entry_size (name);
+ unsigned int struct_size = grub_fdt_get_size_dt_struct(fdt);
+ char *node_name;
+
+ SKIP_NODE_NAME(node_name, token, end);
+
+ /* Insert the new subnode just after the properties of the parent node (if
+ any).*/
+ while (1)
+ {
+ if (token >= end)
+ return -1;
+ switch (grub_be_to_cpu32(*token))
+ {
+ case FDT_PROP:
+ /* Skip len, nameoff and property value. */
+ token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1)))
+ / sizeof(*token);
+ break;
+ case FDT_BEGIN_NODE:
+ case FDT_END_NODE:
+ goto insert;
+ case FDT_NOP:
+ token++;
+ break;
+ default:
+ /* invalid token */
+ return -1;
+ }
+ }
+insert:
+ grub_memmove (token + entry_size / sizeof(*token), token,
+ (grub_addr_t) end - (grub_addr_t) token);
+ *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_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));
+}
+
+/* Rearrange FDT blocks in the canonical order: first the memory reservation
+ block (just after the FDT header), then the structure block and finally the
+ strings block. No free space is left between the first and the second block,
+ while the space between the second and the third block is given by the
+ clearance argument. */
+static int rearrange_blocks (void *fdt, unsigned int clearance)
+{
+ grub_uint32_t off_mem_rsvmap = ALIGN_UP(sizeof(grub_fdt_header_t), 8);
+ grub_uint32_t off_dt_struct = off_mem_rsvmap + get_mem_rsvmap_size (fdt);
+ grub_uint32_t off_dt_strings = off_dt_struct
+ + grub_fdt_get_size_dt_struct (fdt)
+ + clearance;
+ grub_uint8_t *fdt_ptr = fdt;
+ grub_uint8_t *tmp_fdt;
+
+ if ((grub_fdt_get_off_mem_rsvmap (fdt) == off_mem_rsvmap)
+ && (grub_fdt_get_off_dt_struct (fdt) == off_dt_struct))
+ {
+ /* No need to allocate memory for a temporary FDT, just move the strings
+ block if needed. */
+ if (grub_fdt_get_off_dt_strings (fdt) != off_dt_strings)
+ {
+ grub_memmove(fdt_ptr + off_dt_strings,
+ fdt_ptr + grub_fdt_get_off_dt_strings (fdt),
+ grub_fdt_get_size_dt_strings (fdt));
+ grub_fdt_set_off_dt_strings (fdt, off_dt_strings);
+ }
+ return 0;
+ }
+ tmp_fdt = grub_malloc (grub_fdt_get_totalsize (fdt));
+ if (!tmp_fdt)
+ return -1;
+ grub_memcpy (tmp_fdt + off_mem_rsvmap,
+ fdt_ptr + grub_fdt_get_off_mem_rsvmap (fdt),
+ get_mem_rsvmap_size (fdt));
+ grub_fdt_set_off_mem_rsvmap (fdt, off_mem_rsvmap);
+ grub_memcpy (tmp_fdt + off_dt_struct,
+ fdt_ptr + grub_fdt_get_off_dt_struct (fdt),
+ grub_fdt_get_size_dt_struct (fdt));
+ grub_fdt_set_off_dt_struct (fdt, off_dt_struct);
+ grub_memcpy (tmp_fdt + off_dt_strings,
+ fdt_ptr + grub_fdt_get_off_dt_strings (fdt),
+ grub_fdt_get_size_dt_strings (fdt));
+ grub_fdt_set_off_dt_strings (fdt, off_dt_strings);
+
+ /* Copy reordered blocks back to fdt. */
+ grub_memcpy (fdt_ptr + off_mem_rsvmap, tmp_fdt + off_mem_rsvmap,
+ grub_fdt_get_totalsize (fdt) - off_mem_rsvmap);
+
+ grub_free(tmp_fdt);
+ return 0;
+}
+
+static grub_uint32_t *find_prop (const void *fdt, unsigned int nodeoffset,
+ const char *name)
+{
+ grub_uint32_t *prop = (void *) ((grub_addr_t) fdt
+ + grub_fdt_get_off_dt_struct (fdt)
+ + nodeoffset);
+ grub_uint32_t *end = (void *) struct_end(fdt);
+ grub_uint32_t nameoff;
+ char *node_name;
+
+ SKIP_NODE_NAME(node_name, prop, end);
+ while (prop < end - 2)
+ {
+ if (grub_be_to_cpu32(*prop) == FDT_PROP)
+ {
+ nameoff = grub_be_to_cpu32(*(prop + 2));
+ if ((nameoff + grub_strlen (name) < grub_fdt_get_size_dt_strings (fdt))
+ && !grub_strcmp (name, (char *) fdt +
+ grub_fdt_get_off_dt_strings (fdt) + nameoff))
+ {
+ if (prop + grub_fdt_prop_entry_size(grub_be_to_cpu32(*(prop + 1)))
+ / sizeof (*prop) >= end)
+ return NULL;
+ return prop;
+ }
+ prop += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(prop + 1))) / sizeof (*prop);
+ }
+ else if (grub_be_to_cpu32(*prop) == FDT_NOP)
+ prop++;
+ else
+ return NULL;
+ }
+ return NULL;
+}
+
+/* Check the FDT header for consistency and adjust the totalsize field to match
+ 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_nosize (const void *fdt)
+{
+ if (((grub_addr_t) fdt & 0x3) || (grub_fdt_get_magic (fdt) != FDT_MAGIC)
+ || (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)
+ || (grub_fdt_get_size_dt_struct (fdt) & 0x00000003)
+ || (grub_fdt_get_off_dt_struct (fdt) + grub_fdt_get_size_dt_struct (fdt)
+ > grub_fdt_get_totalsize (fdt))
+ || (grub_fdt_get_off_dt_strings (fdt) + grub_fdt_get_size_dt_strings (fdt)
+ > grub_fdt_get_totalsize (fdt))
+ || (grub_fdt_get_off_mem_rsvmap (fdt) & 0x00000007)
+ || (grub_fdt_get_off_mem_rsvmap (fdt)
+ > grub_fdt_get_totalsize (fdt) - 2 * sizeof(grub_uint64_t)))
+ return -1;
+ return 0;
+}
+
+int grub_fdt_check_header (const 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;
+}
+
+static const grub_uint32_t *
+advance_token (const void *fdt, const grub_uint32_t *token, const grub_uint32_t *end, int skip_current)
+{
+ for (; token < end; skip_current = 0)
+ {
+ switch (grub_be_to_cpu32 (*token))
+ {
+ case FDT_BEGIN_NODE:
+ if (skip_current)
+ {
+ token = get_next_node (fdt, (char *) (token + 1));
+ continue;
+ }
+ char *ptr;
+ for (ptr = (char *) (token + 1); *ptr && ptr < (char *) end; ptr++)
+ ;
+ if (ptr >= (char *) end)
+ return 0;
+ return token;
+ case FDT_PROP:
+ /* Skip property token and following data (len, nameoff and property
+ value). */
+ if (token >= end - 1)
+ return 0;
+ token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1)))
+ / sizeof(*token);
+ break;
+ case FDT_NOP:
+ token++;
+ break;
+ default:
+ return 0;
+ }
+ }
+ return 0;
+}
+
+int grub_fdt_next_node (const void *fdt, unsigned int currentoffset)
+{
+ const grub_uint32_t *token = (const grub_uint32_t *) fdt + (currentoffset + grub_fdt_get_off_dt_struct (fdt)) / 4;
+ token = advance_token (fdt, token, (const void *) struct_end (fdt), 1);
+ if (!token)
+ return -1;
+ return (int) ((grub_addr_t) token - (grub_addr_t) fdt
+ - grub_fdt_get_off_dt_struct (fdt));
+}
+
+int grub_fdt_first_node (const void *fdt, unsigned int parentoffset)
+{
+ const grub_uint32_t *token, *end;
+ char *node_name;
+
+ if (parentoffset & 0x3)
+ return -1;
+ token = (const void *) ((grub_addr_t) fdt + grub_fdt_get_off_dt_struct(fdt)
+ + parentoffset);
+ end = (const void *) struct_end (fdt);
+ if ((token >= end) || (grub_be_to_cpu32(*token) != FDT_BEGIN_NODE))
+ return -1;
+ SKIP_NODE_NAME(node_name, token, end);
+ token = advance_token (fdt, token, end, 0);
+ if (!token)
+ return -1;
+ return (int) ((grub_addr_t) token - (grub_addr_t) fdt
+ - grub_fdt_get_off_dt_struct (fdt));
+}
+
+/* Find a direct sub-node of a given parent node. */
+int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset,
+ const char *name)
+{
+ const grub_uint32_t *token, *end;
+ const char *node_name;
+ int skip_current = 0;
+
+ if (parentoffset & 0x3)
+ return -1;
+ token = (const void *) ((grub_addr_t) fdt + grub_fdt_get_off_dt_struct(fdt)
+ + parentoffset);
+ end = (const void *) struct_end (fdt);
+ if ((token >= end) || (grub_be_to_cpu32(*token) != FDT_BEGIN_NODE))
+ return -1;
+ SKIP_NODE_NAME(node_name, token, end);
+ while (1) {
+ token = advance_token (fdt, token, end, skip_current);
+ if (!token)
+ return -1;
+ skip_current = 1;
+ node_name = (const char *) token + 4;
+ if (grub_strcmp (node_name, name) == 0)
+ return (int) ((grub_addr_t) token - (grub_addr_t) fdt
+ - grub_fdt_get_off_dt_struct (fdt));
+ }
+}
+
+const char *
+grub_fdt_get_nodename (const void *fdt, unsigned int nodeoffset)
+{
+ return (const char *) fdt + grub_fdt_get_off_dt_struct(fdt) + nodeoffset + 4;
+}
+
+int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset,
+ const char *name)
+{
+ unsigned int entry_size = node_entry_size(name);
+
+ if ((parentoffset & 0x3) || (get_free_space (fdt) < entry_size))
+ return -1;
+
+ /* The new node entry will increase the size of the structure block: rearrange
+ blocks such that there is sufficient free space between the structure and
+ the strings block, then add the new node entry. */
+ if (rearrange_blocks (fdt, entry_size) < 0)
+ return -1;
+ return add_subnode (fdt, parentoffset, name);
+}
+
+const void *
+grub_fdt_get_prop (const void *fdt, unsigned int nodeoffset, const char *name,
+ grub_uint32_t *len)
+{
+ grub_uint32_t *prop;
+ if ((nodeoffset >= grub_fdt_get_size_dt_struct (fdt)) || (nodeoffset & 0x3)
+ || (grub_be_to_cpu32(*(grub_uint32_t *) ((grub_addr_t) fdt
+ + grub_fdt_get_off_dt_struct (fdt) + nodeoffset))
+ != FDT_BEGIN_NODE))
+ return 0;
+ prop = find_prop (fdt, nodeoffset, name);
+ if (!prop)
+ return 0;
+ if (len)
+ *len = grub_be_to_cpu32 (*(prop + 1));
+ return prop + 3;
+}
+
+int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
+ const void *val, grub_uint32_t len)
+{
+ grub_uint32_t *prop;
+ int prop_name_present = 0;
+ grub_uint32_t nameoff = 0;
+
+ if ((nodeoffset >= grub_fdt_get_size_dt_struct (fdt)) || (nodeoffset & 0x3)
+ || (grub_be_to_cpu32(*(grub_uint32_t *) ((grub_addr_t) fdt
+ + grub_fdt_get_off_dt_struct (fdt) + nodeoffset))
+ != FDT_BEGIN_NODE))
+ return -1;
+ prop = find_prop (fdt, nodeoffset, name);
+ if (prop)
+ {
+ grub_uint32_t prop_len = ALIGN_UP(grub_be_to_cpu32 (*(prop + 1)),
+ sizeof(grub_uint32_t));
+ grub_uint32_t i;
+
+ prop_name_present = 1;
+ for (i = 0; i < prop_len / sizeof(grub_uint32_t); i++)
+ *(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
+ for the current value: a new entry needs to be created, so save the
+ 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_compile_time (FDT_NOP);
+ prop = NULL;
+ }
+ }
+ if (!prop || !prop_name_present) {
+ unsigned int needed_space = 0;
+
+ if (!prop)
+ needed_space = grub_fdt_prop_entry_size(len);
+ if (!prop_name_present)
+ needed_space += grub_strlen (name) + 1;
+ if (needed_space > get_free_space (fdt))
+ return -1;
+ if (rearrange_blocks (fdt, !prop ? grub_fdt_prop_entry_size(len) : 0) < 0)
+ return -1;
+ }
+ if (!prop_name_present) {
+ /* Append the property name at the end of the strings block. */
+ nameoff = grub_fdt_get_size_dt_strings (fdt);
+ grub_strcpy ((char *) fdt + grub_fdt_get_off_dt_strings (fdt) + nameoff,
+ name);
+ grub_fdt_set_size_dt_strings (fdt, grub_fdt_get_size_dt_strings (fdt)
+ + grub_strlen (name) + 1);
+ }
+ if (!prop) {
+ char *node_name = (char *) ((grub_addr_t) fdt
+ + grub_fdt_get_off_dt_struct (fdt) + nodeoffset
+ + sizeof(grub_uint32_t));
+
+ prop = (void *) (node_name + ALIGN_UP(grub_strlen(node_name) + 1, 4));
+ grub_memmove (prop + grub_fdt_prop_entry_size(len) / sizeof(*prop), prop,
+ struct_end(fdt) - (grub_addr_t) prop);
+ grub_fdt_set_size_dt_struct (fdt, grub_fdt_get_size_dt_struct (fdt)
+ + grub_fdt_prop_entry_size(len));
+ *prop = grub_cpu_to_be32_compile_time (FDT_PROP);
+ *(prop + 2) = grub_cpu_to_be32 (nameoff);
+ }
+ *(prop + 1) = grub_cpu_to_be32 (len);
+
+ /* Insert padding bytes at the end of the value; if they are not needed, they
+ will be overwritten by the following memcpy. */
+ *(prop + grub_fdt_prop_entry_size(len) / sizeof(grub_uint32_t) - 1) = 0;
+
+ 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/getline.c b/grub-core/lib/getline.c
new file mode 100644
index 0000000..edb8e9f
--- /dev/null
+++ b/grub-core/lib/getline.c
@@ -0,0 +1,92 @@
+/* main.c - the normal mode main routine */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2005,2006,2007,2008,2009,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/kernel.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+#include <grub/env.h>
+#include <grub/parser.h>
+#include <grub/reader.h>
+#include <grub/menu_viewer.h>
+#include <grub/auth.h>
+#include <grub/i18n.h>
+#include <grub/charset.h>
+#include <grub/script_sh.h>
+
+/* Read a line from the file FILE. */
+char *
+grub_file_getline (grub_file_t file)
+{
+ char c;
+ grub_size_t pos = 0;
+ char *cmdline;
+ int have_newline = 0;
+ grub_size_t max_len = 64;
+
+ /* Initially locate some space. */
+ cmdline = grub_malloc (max_len);
+ if (! cmdline)
+ return 0;
+
+ while (1)
+ {
+ if (grub_file_read (file, &c, 1) != 1)
+ break;
+
+ /* Skip all carriage returns. */
+ if (c == '\r')
+ continue;
+
+
+ if (pos + 1 >= max_len)
+ {
+ char *old_cmdline = cmdline;
+ max_len = max_len * 2;
+ cmdline = grub_realloc (cmdline, max_len);
+ if (! cmdline)
+ {
+ grub_free (old_cmdline);
+ return 0;
+ }
+ }
+
+ if (c == '\n')
+ {
+ have_newline = 1;
+ break;
+ }
+
+ cmdline[pos++] = c;
+ }
+
+ cmdline[pos] = '\0';
+
+ /* If the buffer is empty, don't return anything at all. */
+ if (pos == 0 && !have_newline)
+ {
+ grub_free (cmdline);
+ cmdline = 0;
+ }
+
+ return cmdline;
+}
diff --git a/grub-core/lib/gnulib-patches/fix-base64.patch b/grub-core/lib/gnulib-patches/fix-base64.patch
new file mode 100644
index 0000000..985db12
--- /dev/null
+++ b/grub-core/lib/gnulib-patches/fix-base64.patch
@@ -0,0 +1,21 @@
+diff --git a/lib/base64.h b/lib/base64.h
+index 9cd0183b8..185a2afa1 100644
+--- a/lib/base64.h
++++ b/lib/base64.h
+@@ -21,8 +21,14 @@
+ /* Get size_t. */
+ # include <stddef.h>
+
+-/* Get bool. */
+-# include <stdbool.h>
++#ifndef GRUB_POSIX_BOOL_DEFINED
++typedef enum { false = 0, true = 1 } bool;
++#define GRUB_POSIX_BOOL_DEFINED 1
++#endif
++
++#ifndef _GL_ATTRIBUTE_CONST
++# define _GL_ATTRIBUTE_CONST /* empty */
++#endif
+
+ # ifdef __cplusplus
+ extern "C" {
diff --git a/grub-core/lib/gnulib-patches/fix-null-deref.patch b/grub-core/lib/gnulib-patches/fix-null-deref.patch
new file mode 100644
index 0000000..8fafa15
--- /dev/null
+++ b/grub-core/lib/gnulib-patches/fix-null-deref.patch
@@ -0,0 +1,13 @@
+diff --git a/lib/argp-parse.c b/lib/argp-parse.c
+index 6dec57310..900adad54 100644
+--- a/lib/argp-parse.c
++++ b/lib/argp-parse.c
+@@ -940,7 +940,7 @@ weak_alias (__argp_parse, argp_parse)
+ void *
+ __argp_input (const struct argp *argp, const struct argp_state *state)
+ {
+- if (state)
++ if (state && state->pstate)
+ {
+ struct group *group;
+ struct parser *parser = state->pstate;
diff --git a/grub-core/lib/gnulib-patches/fix-null-state-deref.patch b/grub-core/lib/gnulib-patches/fix-null-state-deref.patch
new file mode 100644
index 0000000..813ec09
--- /dev/null
+++ b/grub-core/lib/gnulib-patches/fix-null-state-deref.patch
@@ -0,0 +1,12 @@
+--- a/lib/argp-help.c 2020-10-28 14:32:19.189215988 +0000
++++ b/lib/argp-help.c 2020-10-28 14:38:21.204673940 +0000
+@@ -145,7 +145,8 @@
+ if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin)
+ {
+ __argp_failure (state, 0, 0,
+- dgettext (state->root_argp->argp_domain,
++ dgettext (state == NULL ? NULL
++ : state->root_argp->argp_domain,
+ "\
+ ARGP_HELP_FMT: %s value is less than or equal to %s"),
+ "rmargin", up->name);
diff --git a/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch b/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch
new file mode 100644
index 0000000..02e0631
--- /dev/null
+++ b/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch
@@ -0,0 +1,15 @@
+--- a/lib/regcomp.c 2020-11-24 17:06:08.159223858 +0000
++++ b/lib/regcomp.c 2020-11-24 17:06:15.630253923 +0000
+@@ -3808,11 +3808,7 @@
+ create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
+ re_token_type_t type)
+ {
+- re_token_t t;
+-#if defined GCC_LINT || defined lint
+- memset (&t, 0, sizeof t);
+-#endif
+- t.type = type;
++ re_token_t t = { .type = type };
+ return create_token_tree (dfa, left, right, &t);
+ }
+
diff --git a/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch b/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch
new file mode 100644
index 0000000..db6dac9
--- /dev/null
+++ b/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch
@@ -0,0 +1,12 @@
+--- a/lib/regexec.c 2020-10-21 14:25:35.310195912 +0000
++++ b/lib/regexec.c 2020-11-05 10:55:09.621542984 +0000
+@@ -1692,6 +1692,9 @@
+ {
+ Idx top = mctx->state_log_top;
+
++ if (mctx->state_log == NULL)
++ return REG_NOERROR;
++
+ if ((next_state_log_idx >= mctx->input.bufs_len
+ && mctx->input.bufs_len < mctx->input.len)
+ || (next_state_log_idx >= mctx->input.valid_len
diff --git a/grub-core/lib/gnulib-patches/fix-uninit-structure.patch b/grub-core/lib/gnulib-patches/fix-uninit-structure.patch
new file mode 100644
index 0000000..7b4d9f6
--- /dev/null
+++ b/grub-core/lib/gnulib-patches/fix-uninit-structure.patch
@@ -0,0 +1,11 @@
+--- a/lib/regcomp.c 2020-10-22 13:49:06.770168928 +0000
++++ b/lib/regcomp.c 2020-10-22 13:50:37.026528298 +0000
+@@ -3662,7 +3662,7 @@
+ Idx alloc = 0;
+ #endif /* not RE_ENABLE_I18N */
+ reg_errcode_t ret;
+- re_token_t br_token;
++ re_token_t br_token = {0};
+ bin_tree_t *tree;
+
+ sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
diff --git a/grub-core/lib/gnulib-patches/fix-unused-value.patch b/grub-core/lib/gnulib-patches/fix-unused-value.patch
new file mode 100644
index 0000000..ba51f1b
--- /dev/null
+++ b/grub-core/lib/gnulib-patches/fix-unused-value.patch
@@ -0,0 +1,14 @@
+--- a/lib/regexec.c 2020-10-21 14:25:35.310195912 +0000
++++ b/lib/regexec.c 2020-10-21 14:32:07.961765604 +0000
+@@ -828,7 +828,11 @@
+ break;
+ if (__glibc_unlikely (err != REG_NOMATCH))
+ goto free_return;
++#ifdef DEBUG
++ /* Only used for assertion below when DEBUG is set, otherwise
++ it will be over-written when we loop around. */
+ match_last = -1;
++#endif
+ }
+ else
+ break; /* We found a match. */
diff --git a/grub-core/lib/gnulib-patches/fix-width.patch b/grub-core/lib/gnulib-patches/fix-width.patch
new file mode 100644
index 0000000..0a208ad
--- /dev/null
+++ b/grub-core/lib/gnulib-patches/fix-width.patch
@@ -0,0 +1,217 @@
+diff --git a/lib/argp-fmtstream.c b/lib/argp-fmtstream.c
+index ba6a407f7..d0685b3d4 100644
+--- a/lib/argp-fmtstream.c
++++ b/lib/argp-fmtstream.c
+@@ -28,9 +28,11 @@
+ #include <errno.h>
+ #include <stdarg.h>
+ #include <ctype.h>
++#include <wchar.h>
+
+ #include "argp-fmtstream.h"
+ #include "argp-namefrob.h"
++#include "mbswidth.h"
+
+ #ifndef ARGP_FMTSTREAM_USE_LINEWRAP
+
+@@ -115,6 +117,51 @@ weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
+ #endif
+ #endif
+
++
++/* Return the pointer to the first character that doesn't fit in l columns. */
++static inline const ptrdiff_t
++add_width (const char *ptr, const char *end, size_t l)
++{
++ mbstate_t ps;
++ const char *ptr0 = ptr;
++
++ memset (&ps, 0, sizeof (ps));
++
++ while (ptr < end)
++ {
++ wchar_t wc;
++ size_t s, k;
++
++ s = mbrtowc (&wc, ptr, end - ptr, &ps);
++ if (s == (size_t) -1)
++ break;
++ if (s == (size_t) -2)
++ {
++ if (1 >= l)
++ break;
++ l--;
++ ptr++;
++ continue;
++ }
++
++ if (wc == '\e' && ptr + 3 < end
++ && ptr[1] == '[' && (ptr[2] == '0' || ptr[2] == '1')
++ && ptr[3] == 'm')
++ {
++ ptr += 4;
++ continue;
++ }
++
++ k = wcwidth (wc);
++
++ if (k >= l)
++ break;
++ l -= k;
++ ptr += s;
++ }
++ return ptr - ptr0;
++}
++
+ /* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
+ end of its buffer. This code is mostly from glibc stdio/linewrap.c. */
+ void
+@@ -168,13 +215,15 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
+ if (!nl)
+ {
+ /* The buffer ends in a partial line. */
++ size_t display_width = mbsnwidth (buf, fs->p - buf,
++ MBSW_STOP_AT_NUL);
+
+- if (fs->point_col + len < fs->rmargin)
++ if (fs->point_col + display_width < fs->rmargin)
+ {
+ /* The remaining buffer text is a partial line and fits
+ within the maximum line width. Advance point for the
+ characters to be written and stop scanning. */
+- fs->point_col += len;
++ fs->point_col += display_width;
+ break;
+ }
+ else
+@@ -182,14 +231,18 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
+ the end of the buffer. */
+ nl = fs->p;
+ }
+- else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
+- {
+- /* The buffer contains a full line that fits within the maximum
+- line width. Reset point and scan the next line. */
+- fs->point_col = 0;
+- buf = nl + 1;
+- continue;
+- }
++ else
++ {
++ size_t display_width = mbsnwidth (buf, nl - buf, MBSW_STOP_AT_NUL);
++ if (display_width < (ssize_t) fs->rmargin)
++ {
++ /* The buffer contains a full line that fits within the maximum
++ line width. Reset point and scan the next line. */
++ fs->point_col = 0;
++ buf = nl + 1;
++ continue;
++ }
++ }
+
+ /* This line is too long. */
+ r = fs->rmargin - 1;
+@@ -225,7 +278,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
+ char *p, *nextline;
+ int i;
+
+- p = buf + (r + 1 - fs->point_col);
++ p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col));
+ while (p >= buf && !isblank ((unsigned char) *p))
+ --p;
+ nextline = p + 1; /* This will begin the next line. */
+@@ -243,7 +296,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
+ {
+ /* A single word that is greater than the maximum line width.
+ Oh well. Put it on an overlong line by itself. */
+- p = buf + (r + 1 - fs->point_col);
++ p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col));
+ /* Find the end of the long word. */
+ if (p < nl)
+ do
+@@ -277,7 +330,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
+ && fs->p > nextline)
+ {
+ /* The margin needs more blanks than we removed. */
+- if (fs->end - fs->p > fs->wmargin + 1)
++ if (mbsnwidth (fs->p, fs->end - fs->p, MBSW_STOP_AT_NUL)
++ > fs->wmargin + 1)
+ /* Make some space for them. */
+ {
+ size_t mv = fs->p - nextline;
+diff --git a/lib/argp-help.c b/lib/argp-help.c
+index e5375a0f0..5d8f451ec 100644
+--- a/lib/argp-help.c
++++ b/lib/argp-help.c
+@@ -51,6 +51,7 @@
+ #include "argp.h"
+ #include "argp-fmtstream.h"
+ #include "argp-namefrob.h"
++#include "mbswidth.h"
+
+ #ifndef SIZE_MAX
+ # define SIZE_MAX ((size_t) -1)
+@@ -1432,7 +1433,7 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
+
+ /* Manually do line wrapping so that it (probably) won't get wrapped at
+ any embedded spaces. */
+- space (stream, 1 + nl - cp);
++ space (stream, 1 + mbsnwidth (cp, nl - cp, MBSW_STOP_AT_NUL));
+
+ __argp_fmtstream_write (stream, cp, nl - cp);
+ }
+diff --git a/lib/mbswidth.c b/lib/mbswidth.c
+index 408a15e34..b3fb7f83a 100644
+--- a/lib/mbswidth.c
++++ b/lib/mbswidth.c
+@@ -38,6 +38,14 @@
+ /* Get INT_MAX. */
+ #include <limits.h>
+
++#ifndef FALLTHROUGH
++# if __GNUC__ < 7
++# define FALLTHROUGH ((void) 0)
++# else
++# define FALLTHROUGH __attribute__ ((__fallthrough__))
++# endif
++#endif
++
+ /* Returns the number of columns needed to represent the multibyte
+ character string pointed to by STRING. If a non-printable character
+ occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned.
+@@ -90,6 +98,10 @@ mbsnwidth (const char *string, size_t nbytes, int flags)
+ p++;
+ width++;
+ break;
++ case '\0':
++ if (flags & MBSW_STOP_AT_NUL)
++ return width;
++ FALLTHROUGH;
+ default:
+ /* If we have a multibyte sequence, scan it up to its end. */
+ {
+@@ -168,6 +180,9 @@ mbsnwidth (const char *string, size_t nbytes, int flags)
+ {
+ unsigned char c = (unsigned char) *p++;
+
++ if (c == 0 && (flags & MBSW_STOP_AT_NUL))
++ return width;
++
+ if (isprint (c))
+ {
+ if (width == INT_MAX)
+diff --git a/lib/mbswidth.h b/lib/mbswidth.h
+index 2b5c53c37..45a123e63 100644
+--- a/lib/mbswidth.h
++++ b/lib/mbswidth.h
+@@ -45,6 +45,10 @@ extern "C" {
+ control characters and 1 otherwise. */
+ #define MBSW_REJECT_UNPRINTABLE 2
+
++/* If this bit is set \0 is treated as the end of string.
++ Otherwise it's treated as a normal one column width character. */
++#define MBSW_STOP_AT_NUL 4
++
+
+ /* Returns the number of screen columns needed for STRING. */
+ #define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */
diff --git a/grub-core/lib/gnulib-patches/no-abort.patch b/grub-core/lib/gnulib-patches/no-abort.patch
new file mode 100644
index 0000000..e469c47
--- /dev/null
+++ b/grub-core/lib/gnulib-patches/no-abort.patch
@@ -0,0 +1,26 @@
+diff --git a/lib/regcomp.c b/lib/regcomp.c
+index cc85f35ac..de45ebb5c 100644
+--- a/lib/regcomp.c
++++ b/lib/regcomp.c
+@@ -528,9 +528,9 @@ regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
+ to this routine. If we are given anything else, or if other regex
+ code generates an invalid error code, then the program has a bug.
+ Dump core so we can fix it. */
+- abort ();
+-
+- msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
++ msg = gettext ("unknown regexp error");
++ else
++ msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
+
+ msg_size = strlen (msg) + 1; /* Includes the null. */
+
+@@ -1136,7 +1136,7 @@ optimize_utf8 (re_dfa_t *dfa)
+ }
+ break;
+ default:
+- abort ();
++ break;
+ }
+
+ if (mb_chars || has_period)
diff --git a/grub-core/lib/gnulib/Makefile.am b/grub-core/lib/gnulib/Makefile.am
new file mode 100644
index 0000000..4c0b646
--- /dev/null
+++ b/grub-core/lib/gnulib/Makefile.am
@@ -0,0 +1,2221 @@
+## DO NOT EDIT! GENERATED AUTOMATICALLY!
+## Process this file with automake to produce Makefile.in.
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
+#
+# 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 of the License, 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file. If not, see <https://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License,
+# this file may be distributed as part of a program that
+# contains a configuration script generated by Autoconf, under
+# the same distribution terms as the rest of that program.
+#
+# Generated by gnulib-tool.
+# Reproduce by:
+# gnulib-tool --import --local-dir=gl \
+# --lib=libgnu \
+# --source-base=grub-core/lib/gnulib \
+# --m4-base=m4 \
+# --doc-base=doc \
+# --tests-base=tests \
+# --aux-dir=build-aux \
+# --no-conditional-dependencies \
+# --no-libtool \
+# --macro-prefix=gl \
+# --no-vc-files \
+# argp \
+# base64 \
+# error \
+# fnmatch \
+# getdelim \
+# getline \
+# gettext-h \
+# gitlog-to-changelog \
+# mbswidth \
+# progname \
+# realloc-gnu \
+# regex \
+# save-cwd
+
+AUTOMAKE_OPTIONS = 1.11 gnits subdir-objects
+
+SUBDIRS =
+noinst_HEADERS =
+noinst_LIBRARIES =
+noinst_LTLIBRARIES =
+EXTRA_DIST =
+BUILT_SOURCES =
+SUFFIXES =
+MOSTLYCLEANFILES = core *.stackdump
+MOSTLYCLEANDIRS =
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+# No GNU Make output.
+
+AM_CPPFLAGS =
+AM_CFLAGS =
+
+noinst_LIBRARIES += libgnu.a
+
+libgnu_a_SOURCES =
+libgnu_a_LIBADD = $(gl_LIBOBJS)
+libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
+EXTRA_libgnu_a_SOURCES =
+
+## begin gnulib module absolute-header
+
+# Use this preprocessor expression to decide whether #include_next works.
+# Do not rely on a 'configure'-time test for this, since the expression
+# might appear in an installed header, which is used by some other compiler.
+HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER)
+
+## end gnulib module absolute-header
+
+## begin gnulib module alloca
+
+
+libgnu_a_LIBADD += @ALLOCA@
+libgnu_a_DEPENDENCIES += @ALLOCA@
+EXTRA_DIST += alloca.c
+
+EXTRA_libgnu_a_SOURCES += alloca.c
+
+## end gnulib module alloca
+
+## begin gnulib module alloca-opt
+
+BUILT_SOURCES += $(ALLOCA_H)
+
+# We need the following in order to create <alloca.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_ALLOCA_H
+alloca.h: alloca.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/alloca.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+else
+alloca.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += alloca.h alloca.h-t
+
+EXTRA_DIST += alloca.in.h
+
+## end gnulib module alloca-opt
+
+## begin gnulib module argp
+
+libgnu_a_SOURCES += argp.h argp-ba.c argp-eexst.c argp-fmtstream.c argp-fmtstream.h argp-fs-xinl.c argp-help.c argp-namefrob.h argp-parse.c argp-pin.c argp-pv.c argp-pvh.c argp-xinl.c
+
+## end gnulib module argp
+
+## begin gnulib module assure
+
+
+EXTRA_DIST += assure.h
+
+## end gnulib module assure
+
+## begin gnulib module at-internal
+
+
+EXTRA_DIST += openat-priv.h openat-proc.c
+
+EXTRA_libgnu_a_SOURCES += openat-proc.c
+
+## end gnulib module at-internal
+
+## begin gnulib module base64
+
+libgnu_a_SOURCES += base64.h base64.c
+
+## end gnulib module base64
+
+## begin gnulib module btowc
+
+
+EXTRA_DIST += btowc.c
+
+EXTRA_libgnu_a_SOURCES += btowc.c
+
+## end gnulib module btowc
+
+## begin gnulib module chdir-long
+
+
+EXTRA_DIST += chdir-long.c chdir-long.h
+
+EXTRA_libgnu_a_SOURCES += chdir-long.c
+
+## end gnulib module chdir-long
+
+## begin gnulib module cloexec
+
+libgnu_a_SOURCES += cloexec.c
+
+EXTRA_DIST += cloexec.h
+
+## end gnulib module cloexec
+
+## begin gnulib module close
+
+
+EXTRA_DIST += close.c
+
+EXTRA_libgnu_a_SOURCES += close.c
+
+## end gnulib module close
+
+## begin gnulib module dirent
+
+BUILT_SOURCES += dirent.h
+
+# We need the following in order to create <dirent.h> when the system
+# doesn't have one that works with the given compiler.
+dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_DIRENT_H''@|$(HAVE_DIRENT_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \
+ -e 's/@''GNULIB_OPENDIR''@/$(GNULIB_OPENDIR)/g' \
+ -e 's/@''GNULIB_READDIR''@/$(GNULIB_READDIR)/g' \
+ -e 's/@''GNULIB_REWINDDIR''@/$(GNULIB_REWINDDIR)/g' \
+ -e 's/@''GNULIB_CLOSEDIR''@/$(GNULIB_CLOSEDIR)/g' \
+ -e 's/@''GNULIB_DIRFD''@/$(GNULIB_DIRFD)/g' \
+ -e 's/@''GNULIB_FDOPENDIR''@/$(GNULIB_FDOPENDIR)/g' \
+ -e 's/@''GNULIB_SCANDIR''@/$(GNULIB_SCANDIR)/g' \
+ -e 's/@''GNULIB_ALPHASORT''@/$(GNULIB_ALPHASORT)/g' \
+ -e 's/@''HAVE_OPENDIR''@/$(HAVE_OPENDIR)/g' \
+ -e 's/@''HAVE_READDIR''@/$(HAVE_READDIR)/g' \
+ -e 's/@''HAVE_REWINDDIR''@/$(HAVE_REWINDDIR)/g' \
+ -e 's/@''HAVE_CLOSEDIR''@/$(HAVE_CLOSEDIR)/g' \
+ -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \
+ -e 's|@''HAVE_DECL_FDOPENDIR''@|$(HAVE_DECL_FDOPENDIR)|g' \
+ -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \
+ -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \
+ -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \
+ -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \
+ -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \
+ -e 's|@''REPLACE_DIRFD''@|$(REPLACE_DIRFD)|g' \
+ -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/dirent.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += dirent.h dirent.h-t
+
+EXTRA_DIST += dirent.in.h
+
+## end gnulib module dirent
+
+## begin gnulib module dirfd
+
+
+EXTRA_DIST += dirfd.c
+
+EXTRA_libgnu_a_SOURCES += dirfd.c
+
+## end gnulib module dirfd
+
+## begin gnulib module dirname-lgpl
+
+libgnu_a_SOURCES += dirname-lgpl.c basename-lgpl.c stripslash.c
+
+EXTRA_DIST += dirname.h
+
+## end gnulib module dirname-lgpl
+
+## begin gnulib module dosname
+
+
+EXTRA_DIST += dosname.h
+
+## end gnulib module dosname
+
+## begin gnulib module dup2
+
+
+EXTRA_DIST += dup2.c
+
+EXTRA_libgnu_a_SOURCES += dup2.c
+
+## end gnulib module dup2
+
+## begin gnulib module errno
+
+BUILT_SOURCES += $(ERRNO_H)
+
+# We need the following in order to create <errno.h> when the system
+# doesn't have one that is POSIX compliant.
+if GL_GENERATE_ERRNO_H
+errno.h: errno.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
+ -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
+ -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
+ -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \
+ -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
+ -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
+ -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
+ < $(srcdir)/errno.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+errno.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += errno.h errno.h-t
+
+EXTRA_DIST += errno.in.h
+
+## end gnulib module errno
+
+## begin gnulib module error
+
+
+EXTRA_DIST += error.c error.h
+
+EXTRA_libgnu_a_SOURCES += error.c
+
+## end gnulib module error
+
+## begin gnulib module exitfail
+
+libgnu_a_SOURCES += exitfail.c
+
+EXTRA_DIST += exitfail.h
+
+## end gnulib module exitfail
+
+## begin gnulib module fchdir
+
+
+EXTRA_DIST += fchdir.c
+
+EXTRA_libgnu_a_SOURCES += fchdir.c
+
+## end gnulib module fchdir
+
+## begin gnulib module fcntl
+
+
+EXTRA_DIST += fcntl.c
+
+EXTRA_libgnu_a_SOURCES += fcntl.c
+
+## end gnulib module fcntl
+
+## begin gnulib module fcntl-h
+
+BUILT_SOURCES += fcntl.h
+
+# We need the following in order to create <fcntl.h> when the system
+# doesn't have one that works with the given compiler.
+fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
+ -e 's/@''GNULIB_FCNTL''@/$(GNULIB_FCNTL)/g' \
+ -e 's/@''GNULIB_NONBLOCKING''@/$(GNULIB_NONBLOCKING)/g' \
+ -e 's/@''GNULIB_OPEN''@/$(GNULIB_OPEN)/g' \
+ -e 's/@''GNULIB_OPENAT''@/$(GNULIB_OPENAT)/g' \
+ -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
+ -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
+ -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
+ -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
+ -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/fcntl.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += fcntl.h fcntl.h-t
+
+EXTRA_DIST += fcntl.in.h
+
+## end gnulib module fcntl-h
+
+## begin gnulib module fd-hook
+
+libgnu_a_SOURCES += fd-hook.c
+
+EXTRA_DIST += fd-hook.h
+
+## end gnulib module fd-hook
+
+## begin gnulib module fd-safer-flag
+
+libgnu_a_SOURCES += fd-safer-flag.c dup-safer-flag.c
+
+## end gnulib module fd-safer-flag
+
+## begin gnulib module filename
+
+
+EXTRA_DIST += filename.h
+
+## end gnulib module filename
+
+## begin gnulib module filenamecat-lgpl
+
+libgnu_a_SOURCES += filenamecat-lgpl.c
+
+EXTRA_DIST += filenamecat.h
+
+## end gnulib module filenamecat-lgpl
+
+## begin gnulib module flexmember
+
+
+EXTRA_DIST += flexmember.h
+
+## end gnulib module flexmember
+
+## begin gnulib module float
+
+BUILT_SOURCES += $(FLOAT_H)
+
+# We need the following in order to create <float.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_FLOAT_H
+float.h: float.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
+ -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \
+ < $(srcdir)/float.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+float.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += float.h float.h-t
+
+EXTRA_DIST += float.c float.in.h itold.c
+
+EXTRA_libgnu_a_SOURCES += float.c itold.c
+
+## end gnulib module float
+
+## begin gnulib module fnmatch
+
+
+EXTRA_DIST += fnmatch.c fnmatch_loop.c
+
+EXTRA_libgnu_a_SOURCES += fnmatch.c fnmatch_loop.c
+
+## end gnulib module fnmatch
+
+## begin gnulib module fnmatch-h
+
+BUILT_SOURCES += $(FNMATCH_H)
+
+# We need the following in order to create <fnmatch.h>.
+if GL_GENERATE_FNMATCH_H
+fnmatch.h: fnmatch.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_FNMATCH_H''@|$(HAVE_FNMATCH_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_FNMATCH_H''@|$(NEXT_FNMATCH_H)|g' \
+ -e 's/@''GNULIB_FNMATCH''@/$(GNULIB_FNMATCH)/g' \
+ -e 's|@''HAVE_FNMATCH''@|$(HAVE_FNMATCH)|g' \
+ -e 's|@''REPLACE_FNMATCH''@|$(REPLACE_FNMATCH)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/fnmatch.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+fnmatch.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
+
+EXTRA_DIST += fnmatch.in.h
+
+## end gnulib module fnmatch-h
+
+## begin gnulib module fstat
+
+
+EXTRA_DIST += fstat.c stat-w32.c stat-w32.h
+
+EXTRA_libgnu_a_SOURCES += fstat.c stat-w32.c
+
+## end gnulib module fstat
+
+## begin gnulib module getcwd-lgpl
+
+
+EXTRA_DIST += getcwd-lgpl.c
+
+EXTRA_libgnu_a_SOURCES += getcwd-lgpl.c
+
+## end gnulib module getcwd-lgpl
+
+## begin gnulib module getdelim
+
+
+EXTRA_DIST += getdelim.c
+
+EXTRA_libgnu_a_SOURCES += getdelim.c
+
+## end gnulib module getdelim
+
+## begin gnulib module getdtablesize
+
+
+EXTRA_DIST += getdtablesize.c
+
+EXTRA_libgnu_a_SOURCES += getdtablesize.c
+
+## end gnulib module getdtablesize
+
+## begin gnulib module getline
+
+
+EXTRA_DIST += getline.c
+
+EXTRA_libgnu_a_SOURCES += getline.c
+
+## end gnulib module getline
+
+## begin gnulib module getopt-posix
+
+BUILT_SOURCES += $(GETOPT_H) $(GETOPT_CDEFS_H)
+
+# We need the following in order to create <getopt.h> when the system
+# doesn't have one that works with the given compiler.
+getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ < $(srcdir)/getopt.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+
+getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
+ < $(srcdir)/getopt-cdefs.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+
+MOSTLYCLEANFILES += getopt.h getopt.h-t getopt-cdefs.h getopt-cdefs.h-t
+
+EXTRA_DIST += getopt-cdefs.in.h getopt-core.h getopt-ext.h getopt-pfx-core.h getopt-pfx-ext.h getopt.c getopt.in.h getopt1.c getopt_int.h
+
+EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c
+
+## end gnulib module getopt-posix
+
+## begin gnulib module getprogname
+
+libgnu_a_SOURCES += getprogname.h getprogname.c
+
+## end gnulib module getprogname
+
+## begin gnulib module gettext-h
+
+libgnu_a_SOURCES += gettext.h
+
+## end gnulib module gettext-h
+
+## begin gnulib module gitlog-to-changelog
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/gitlog-to-changelog
+
+## end gnulib module gitlog-to-changelog
+
+## begin gnulib module hard-locale
+
+libgnu_a_SOURCES += hard-locale.c
+
+EXTRA_DIST += hard-locale.h
+
+## end gnulib module hard-locale
+
+## begin gnulib module havelib
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
+
+## end gnulib module havelib
+
+## begin gnulib module intprops
+
+
+EXTRA_DIST += intprops.h
+
+## end gnulib module intprops
+
+## begin gnulib module langinfo
+
+BUILT_SOURCES += langinfo.h
+
+# We need the following in order to create an empty placeholder for
+# <langinfo.h> when the system doesn't have one.
+langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
+ -e 's/@''GNULIB_NL_LANGINFO''@/$(GNULIB_NL_LANGINFO)/g' \
+ -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
+ -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
+ -e 's|@''HAVE_LANGINFO_ALTMON''@|$(HAVE_LANGINFO_ALTMON)|g' \
+ -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
+ -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
+ -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
+ -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/langinfo.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += langinfo.h langinfo.h-t
+
+EXTRA_DIST += langinfo.in.h
+
+## end gnulib module langinfo
+
+## begin gnulib module libc-config
+
+
+EXTRA_DIST += cdefs.h libc-config.h
+
+## end gnulib module libc-config
+
+## begin gnulib module limits-h
+
+BUILT_SOURCES += $(LIMITS_H)
+
+# We need the following in order to create <limits.h> when the system
+# doesn't have one that is compatible with GNU.
+if GL_GENERATE_LIMITS_H
+limits.h: limits.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \
+ < $(srcdir)/limits.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+limits.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += limits.h limits.h-t
+
+EXTRA_DIST += limits.in.h
+
+## end gnulib module limits-h
+
+## begin gnulib module localcharset
+
+libgnu_a_SOURCES += localcharset.c
+
+EXTRA_DIST += localcharset.h
+
+## end gnulib module localcharset
+
+## begin gnulib module locale
+
+BUILT_SOURCES += locale.h
+
+# We need the following in order to create <locale.h> when the system
+# doesn't have one that provides all definitions.
+locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
+ -e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/g' \
+ -e 's/@''GNULIB_SETLOCALE''@/$(GNULIB_SETLOCALE)/g' \
+ -e 's/@''GNULIB_DUPLOCALE''@/$(GNULIB_DUPLOCALE)/g' \
+ -e 's/@''GNULIB_LOCALENAME''@/$(GNULIB_LOCALENAME)/g' \
+ -e 's|@''HAVE_NEWLOCALE''@|$(HAVE_NEWLOCALE)|g' \
+ -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
+ -e 's|@''HAVE_FREELOCALE''@|$(HAVE_FREELOCALE)|g' \
+ -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
+ -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \
+ -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \
+ -e 's|@''REPLACE_NEWLOCALE''@|$(REPLACE_NEWLOCALE)|g' \
+ -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
+ -e 's|@''REPLACE_FREELOCALE''@|$(REPLACE_FREELOCALE)|g' \
+ -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/locale.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += locale.h locale.h-t
+
+EXTRA_DIST += locale.in.h
+
+## end gnulib module locale
+
+## begin gnulib module localeconv
+
+
+EXTRA_DIST += localeconv.c
+
+EXTRA_libgnu_a_SOURCES += localeconv.c
+
+## end gnulib module localeconv
+
+## begin gnulib module lock
+
+libgnu_a_SOURCES += glthread/lock.h glthread/lock.c
+
+## end gnulib module lock
+
+## begin gnulib module malloc-gnu
+
+
+EXTRA_DIST += malloc.c
+
+EXTRA_libgnu_a_SOURCES += malloc.c
+
+## end gnulib module malloc-gnu
+
+## begin gnulib module malloc-posix
+
+
+EXTRA_DIST += malloc.c
+
+EXTRA_libgnu_a_SOURCES += malloc.c
+
+## end gnulib module malloc-posix
+
+## begin gnulib module malloca
+
+libgnu_a_SOURCES += malloca.c
+
+EXTRA_DIST += malloca.h
+
+## end gnulib module malloca
+
+## begin gnulib module mbrtowc
+
+
+EXTRA_DIST += mbrtowc.c
+
+EXTRA_libgnu_a_SOURCES += mbrtowc.c
+
+## end gnulib module mbrtowc
+
+## begin gnulib module mbsinit
+
+
+EXTRA_DIST += mbsinit.c
+
+EXTRA_libgnu_a_SOURCES += mbsinit.c
+
+## end gnulib module mbsinit
+
+## begin gnulib module mbsrtowcs
+
+
+EXTRA_DIST += mbsrtowcs-impl.h mbsrtowcs-state.c mbsrtowcs.c
+
+EXTRA_libgnu_a_SOURCES += mbsrtowcs-state.c mbsrtowcs.c
+
+## end gnulib module mbsrtowcs
+
+## begin gnulib module mbswidth
+
+libgnu_a_SOURCES += mbswidth.h mbswidth.c
+
+## end gnulib module mbswidth
+
+## begin gnulib module mbtowc
+
+
+EXTRA_DIST += mbtowc-impl.h mbtowc.c
+
+EXTRA_libgnu_a_SOURCES += mbtowc.c
+
+## end gnulib module mbtowc
+
+## begin gnulib module memchr
+
+
+EXTRA_DIST += memchr.c memchr.valgrind
+
+EXTRA_libgnu_a_SOURCES += memchr.c
+
+## end gnulib module memchr
+
+## begin gnulib module mempcpy
+
+
+EXTRA_DIST += mempcpy.c
+
+EXTRA_libgnu_a_SOURCES += mempcpy.c
+
+## end gnulib module mempcpy
+
+## begin gnulib module memrchr
+
+
+EXTRA_DIST += memrchr.c
+
+EXTRA_libgnu_a_SOURCES += memrchr.c
+
+## end gnulib module memrchr
+
+## begin gnulib module msvc-inval
+
+
+EXTRA_DIST += msvc-inval.c msvc-inval.h
+
+EXTRA_libgnu_a_SOURCES += msvc-inval.c
+
+## end gnulib module msvc-inval
+
+## begin gnulib module msvc-nothrow
+
+
+EXTRA_DIST += msvc-nothrow.c msvc-nothrow.h
+
+EXTRA_libgnu_a_SOURCES += msvc-nothrow.c
+
+## end gnulib module msvc-nothrow
+
+## begin gnulib module nl_langinfo
+
+
+EXTRA_DIST += nl_langinfo.c
+
+EXTRA_libgnu_a_SOURCES += nl_langinfo.c
+
+## end gnulib module nl_langinfo
+
+## begin gnulib module open
+
+
+EXTRA_DIST += open.c
+
+EXTRA_libgnu_a_SOURCES += open.c
+
+## end gnulib module open
+
+## begin gnulib module openat
+
+
+EXTRA_DIST += openat.c
+
+EXTRA_libgnu_a_SOURCES += openat.c
+
+## end gnulib module openat
+
+## begin gnulib module openat-die
+
+libgnu_a_SOURCES += openat-die.c
+
+## end gnulib module openat-die
+
+## begin gnulib module openat-h
+
+
+EXTRA_DIST += openat.h
+
+## end gnulib module openat-h
+
+## begin gnulib module pathmax
+
+
+EXTRA_DIST += pathmax.h
+
+## end gnulib module pathmax
+
+## begin gnulib module progname
+
+libgnu_a_SOURCES += progname.h progname.c
+
+## end gnulib module progname
+
+## begin gnulib module rawmemchr
+
+
+EXTRA_DIST += rawmemchr.c rawmemchr.valgrind
+
+EXTRA_libgnu_a_SOURCES += rawmemchr.c
+
+## end gnulib module rawmemchr
+
+## begin gnulib module realloc-gnu
+
+
+EXTRA_DIST += realloc.c
+
+EXTRA_libgnu_a_SOURCES += realloc.c
+
+## end gnulib module realloc-gnu
+
+## begin gnulib module realloc-posix
+
+
+EXTRA_DIST += realloc.c
+
+EXTRA_libgnu_a_SOURCES += realloc.c
+
+## end gnulib module realloc-posix
+
+## begin gnulib module regex
+
+
+EXTRA_DIST += regcomp.c regex.c regex.h regex_internal.c regex_internal.h regexec.c
+
+EXTRA_libgnu_a_SOURCES += regcomp.c regex.c regex_internal.c regexec.c
+
+## end gnulib module regex
+
+## begin gnulib module save-cwd
+
+libgnu_a_SOURCES += save-cwd.c
+
+EXTRA_DIST += save-cwd.h
+
+## end gnulib module save-cwd
+
+## begin gnulib module size_max
+
+libgnu_a_SOURCES += size_max.h
+
+## end gnulib module size_max
+
+## begin gnulib module sleep
+
+
+EXTRA_DIST += sleep.c
+
+EXTRA_libgnu_a_SOURCES += sleep.c
+
+## end gnulib module sleep
+
+## begin gnulib module snippet/_Noreturn
+
+# Because this Makefile snippet defines a variable used by other
+# gnulib Makefile snippets, it must be present in all makefiles that
+# need it. This is ensured by the applicability 'all' defined above.
+
+_NORETURN_H=$(srcdir)/_Noreturn.h
+
+EXTRA_DIST += _Noreturn.h
+
+## end gnulib module snippet/_Noreturn
+
+## begin gnulib module snippet/arg-nonnull
+
+# Because this Makefile snippet defines a variable used by other
+# gnulib Makefile snippets, it must be present in all makefiles that
+# need it. This is ensured by the applicability 'all' defined above.
+
+ARG_NONNULL_H=$(srcdir)/arg-nonnull.h
+
+EXTRA_DIST += arg-nonnull.h
+
+## end gnulib module snippet/arg-nonnull
+
+## begin gnulib module snippet/c++defs
+
+# Because this Makefile snippet defines a variable used by other
+# gnulib Makefile snippets, it must be present in all makefiles that
+# need it. This is ensured by the applicability 'all' defined above.
+
+CXXDEFS_H=$(srcdir)/c++defs.h
+
+EXTRA_DIST += c++defs.h
+
+## end gnulib module snippet/c++defs
+
+## begin gnulib module snippet/warn-on-use
+
+# Because this Makefile snippet defines a variable used by other
+# gnulib Makefile snippets, it must be present in all makefiles that
+# need it. This is ensured by the applicability 'all' defined above.
+
+WARN_ON_USE_H=$(srcdir)/warn-on-use.h
+
+EXTRA_DIST += warn-on-use.h
+
+## end gnulib module snippet/warn-on-use
+
+## begin gnulib module stat
+
+
+EXTRA_DIST += stat-w32.c stat-w32.h stat.c
+
+EXTRA_libgnu_a_SOURCES += stat-w32.c stat.c
+
+## end gnulib module stat
+
+## begin gnulib module stat-time
+
+libgnu_a_SOURCES += stat-time.c
+
+EXTRA_DIST += stat-time.h
+
+## end gnulib module stat-time
+
+## begin gnulib module stdalign
+
+BUILT_SOURCES += $(STDALIGN_H)
+
+# We need the following in order to create <stdalign.h> when the system
+# doesn't have one that works.
+if GL_GENERATE_STDALIGN_H
+stdalign.h: stdalign.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/stdalign.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+stdalign.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += stdalign.h stdalign.h-t
+
+EXTRA_DIST += stdalign.in.h
+
+## end gnulib module stdalign
+
+## begin gnulib module stdbool
+
+BUILT_SOURCES += $(STDBOOL_H)
+
+# We need the following in order to create <stdbool.h> when the system
+# doesn't have one that works.
+if GL_GENERATE_STDBOOL_H
+stdbool.h: stdbool.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+stdbool.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += stdbool.h stdbool.h-t
+
+EXTRA_DIST += stdbool.in.h
+
+## end gnulib module stdbool
+
+## begin gnulib module stddef
+
+BUILT_SOURCES += $(STDDEF_H)
+
+# We need the following in order to create <stddef.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_STDDEF_H
+stddef.h: stddef.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
+ -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
+ -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
+ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
+ < $(srcdir)/stddef.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+stddef.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += stddef.h stddef.h-t
+
+EXTRA_DIST += stddef.in.h
+
+## end gnulib module stddef
+
+## begin gnulib module stdint
+
+BUILT_SOURCES += $(STDINT_H)
+
+# We need the following in order to create <stdint.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_STDINT_H
+stdint.h: stdint.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
+ -e 's/@''HAVE_C99_STDINT_H''@/$(HAVE_C99_STDINT_H)/g' \
+ -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
+ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
+ -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
+ -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
+ -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
+ -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
+ -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
+ -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
+ -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
+ -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
+ -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
+ -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
+ -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
+ -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
+ -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
+ -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
+ -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
+ -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
+ -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
+ -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
+ -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
+ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
+ < $(srcdir)/stdint.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+stdint.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += stdint.h stdint.h-t
+
+EXTRA_DIST += stdint.in.h
+
+## end gnulib module stdint
+
+## begin gnulib module stdio
+
+BUILT_SOURCES += stdio.h
+
+# We need the following in order to create <stdio.h> when the system
+# doesn't have one that works with the given compiler.
+stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
+ -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \
+ -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \
+ -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \
+ -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \
+ -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \
+ -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \
+ -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \
+ -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \
+ -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \
+ -e 's/@''GNULIB_FPUTC''@/$(GNULIB_FPUTC)/g' \
+ -e 's/@''GNULIB_FPUTS''@/$(GNULIB_FPUTS)/g' \
+ -e 's/@''GNULIB_FREAD''@/$(GNULIB_FREAD)/g' \
+ -e 's/@''GNULIB_FREOPEN''@/$(GNULIB_FREOPEN)/g' \
+ -e 's/@''GNULIB_FSCANF''@/$(GNULIB_FSCANF)/g' \
+ -e 's/@''GNULIB_FSEEK''@/$(GNULIB_FSEEK)/g' \
+ -e 's/@''GNULIB_FSEEKO''@/$(GNULIB_FSEEKO)/g' \
+ -e 's/@''GNULIB_FTELL''@/$(GNULIB_FTELL)/g' \
+ -e 's/@''GNULIB_FTELLO''@/$(GNULIB_FTELLO)/g' \
+ -e 's/@''GNULIB_FWRITE''@/$(GNULIB_FWRITE)/g' \
+ -e 's/@''GNULIB_GETC''@/$(GNULIB_GETC)/g' \
+ -e 's/@''GNULIB_GETCHAR''@/$(GNULIB_GETCHAR)/g' \
+ -e 's/@''GNULIB_GETDELIM''@/$(GNULIB_GETDELIM)/g' \
+ -e 's/@''GNULIB_GETLINE''@/$(GNULIB_GETLINE)/g' \
+ -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \
+ -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \
+ -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \
+ -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \
+ -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \
+ -e 's/@''GNULIB_PRINTF_POSIX''@/$(GNULIB_PRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_PUTC''@/$(GNULIB_PUTC)/g' \
+ -e 's/@''GNULIB_PUTCHAR''@/$(GNULIB_PUTCHAR)/g' \
+ -e 's/@''GNULIB_PUTS''@/$(GNULIB_PUTS)/g' \
+ -e 's/@''GNULIB_REMOVE''@/$(GNULIB_REMOVE)/g' \
+ -e 's/@''GNULIB_RENAME''@/$(GNULIB_RENAME)/g' \
+ -e 's/@''GNULIB_RENAMEAT''@/$(GNULIB_RENAMEAT)/g' \
+ -e 's/@''GNULIB_SCANF''@/$(GNULIB_SCANF)/g' \
+ -e 's/@''GNULIB_SNPRINTF''@/$(GNULIB_SNPRINTF)/g' \
+ -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GNULIB_SPRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GNULIB_STDIO_H_NONBLOCKING)/g' \
+ -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GNULIB_STDIO_H_SIGPIPE)/g' \
+ -e 's/@''GNULIB_TMPFILE''@/$(GNULIB_TMPFILE)/g' \
+ -e 's/@''GNULIB_VASPRINTF''@/$(GNULIB_VASPRINTF)/g' \
+ -e 's/@''GNULIB_VDPRINTF''@/$(GNULIB_VDPRINTF)/g' \
+ -e 's/@''GNULIB_VFPRINTF''@/$(GNULIB_VFPRINTF)/g' \
+ -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GNULIB_VFPRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_VFSCANF''@/$(GNULIB_VFSCANF)/g' \
+ -e 's/@''GNULIB_VSCANF''@/$(GNULIB_VSCANF)/g' \
+ -e 's/@''GNULIB_VPRINTF''@/$(GNULIB_VPRINTF)/g' \
+ -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GNULIB_VPRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_VSNPRINTF''@/$(GNULIB_VSNPRINTF)/g' \
+ -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GNULIB_VSPRINTF_POSIX)/g' \
+ < $(srcdir)/stdio.in.h | \
+ sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
+ -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \
+ -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \
+ -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
+ -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
+ -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
+ -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
+ -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
+ -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
+ -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
+ -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
+ -e 's|@''HAVE_PCLOSE''@|$(HAVE_PCLOSE)|g' \
+ -e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|g' \
+ -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
+ -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
+ -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
+ -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \
+ -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
+ -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \
+ -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
+ -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
+ -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
+ -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
+ -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
+ -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \
+ -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
+ -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \
+ -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
+ -e 's|@''REPLACE_GETDELIM''@|$(REPLACE_GETDELIM)|g' \
+ -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \
+ -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \
+ -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \
+ -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \
+ -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
+ -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \
+ -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \
+ -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \
+ -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
+ -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
+ -e 's|@''REPLACE_STDIO_READ_FUNCS''@|$(REPLACE_STDIO_READ_FUNCS)|g' \
+ -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
+ -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \
+ -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
+ -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \
+ -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
+ -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
+ -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
+ -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
+ -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += stdio.h stdio.h-t
+
+EXTRA_DIST += stdio.in.h
+
+## end gnulib module stdio
+
+## begin gnulib module stdlib
+
+BUILT_SOURCES += stdlib.h
+
+# We need the following in order to create <stdlib.h> when the system
+# doesn't have one that works with the given compiler.
+stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
+ $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
+ -e 's/@''GNULIB__EXIT''@/$(GNULIB__EXIT)/g' \
+ -e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \
+ -e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \
+ -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \
+ -e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \
+ -e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \
+ -e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \
+ -e 's/@''GNULIB_MALLOC_POSIX''@/$(GNULIB_MALLOC_POSIX)/g' \
+ -e 's/@''GNULIB_MBTOWC''@/$(GNULIB_MBTOWC)/g' \
+ -e 's/@''GNULIB_MKDTEMP''@/$(GNULIB_MKDTEMP)/g' \
+ -e 's/@''GNULIB_MKOSTEMP''@/$(GNULIB_MKOSTEMP)/g' \
+ -e 's/@''GNULIB_MKOSTEMPS''@/$(GNULIB_MKOSTEMPS)/g' \
+ -e 's/@''GNULIB_MKSTEMP''@/$(GNULIB_MKSTEMP)/g' \
+ -e 's/@''GNULIB_MKSTEMPS''@/$(GNULIB_MKSTEMPS)/g' \
+ -e 's/@''GNULIB_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \
+ -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \
+ -e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \
+ -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \
+ -e 's/@''GNULIB_QSORT_R''@/$(GNULIB_QSORT_R)/g' \
+ -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \
+ -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \
+ -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
+ -e 's/@''GNULIB_REALLOCARRAY''@/$(GNULIB_REALLOCARRAY)/g' \
+ -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \
+ -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \
+ -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \
+ -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \
+ -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \
+ -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \
+ -e 's/@''GNULIB_STRTOULL''@/$(GNULIB_STRTOULL)/g' \
+ -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GNULIB_SYSTEM_POSIX)/g' \
+ -e 's/@''GNULIB_UNLOCKPT''@/$(GNULIB_UNLOCKPT)/g' \
+ -e 's/@''GNULIB_UNSETENV''@/$(GNULIB_UNSETENV)/g' \
+ -e 's/@''GNULIB_WCTOMB''@/$(GNULIB_WCTOMB)/g' \
+ < $(srcdir)/stdlib.in.h | \
+ sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
+ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
+ -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
+ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
+ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
+ -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
+ -e 's|@''HAVE_DECL_INITSTATE''@|$(HAVE_DECL_INITSTATE)|g' \
+ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
+ -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
+ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
+ -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
+ -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
+ -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \
+ -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
+ -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
+ -e 's|@''HAVE_QSORT_R''@|$(HAVE_QSORT_R)|g' \
+ -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \
+ -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
+ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
+ -e 's|@''HAVE_REALLOCARRAY''@|$(HAVE_REALLOCARRAY)|g' \
+ -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
+ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
+ -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
+ -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
+ -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \
+ -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
+ -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
+ -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
+ -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
+ -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
+ -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
+ -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
+ -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
+ -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
+ -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
+ -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
+ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
+ -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
+ -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
+ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
+ -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
+ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
+ -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
+ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
+ -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
+ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
+ -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
+ -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _Noreturn/r $(_NORETURN_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += stdlib.h stdlib.h-t
+
+EXTRA_DIST += stdlib.in.h
+
+## end gnulib module stdlib
+
+## begin gnulib module strcase
+
+
+EXTRA_DIST += strcasecmp.c strncasecmp.c
+
+EXTRA_libgnu_a_SOURCES += strcasecmp.c strncasecmp.c
+
+## end gnulib module strcase
+
+## begin gnulib module strchrnul
+
+
+EXTRA_DIST += strchrnul.c strchrnul.valgrind
+
+EXTRA_libgnu_a_SOURCES += strchrnul.c
+
+## end gnulib module strchrnul
+
+## begin gnulib module strdup-posix
+
+
+EXTRA_DIST += strdup.c
+
+EXTRA_libgnu_a_SOURCES += strdup.c
+
+## end gnulib module strdup-posix
+
+## begin gnulib module streq
+
+
+EXTRA_DIST += streq.h
+
+## end gnulib module streq
+
+## begin gnulib module strerror
+
+
+EXTRA_DIST += strerror.c
+
+EXTRA_libgnu_a_SOURCES += strerror.c
+
+## end gnulib module strerror
+
+## begin gnulib module strerror-override
+
+
+EXTRA_DIST += strerror-override.c strerror-override.h
+
+EXTRA_libgnu_a_SOURCES += strerror-override.c
+
+## end gnulib module strerror-override
+
+## begin gnulib module string
+
+BUILT_SOURCES += string.h
+
+# We need the following in order to create <string.h> when the system
+# doesn't have one that works with the given compiler.
+string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
+ -e 's/@''GNULIB_EXPLICIT_BZERO''@/$(GNULIB_EXPLICIT_BZERO)/g' \
+ -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \
+ -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \
+ -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \
+ -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \
+ -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \
+ -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \
+ -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \
+ -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \
+ -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \
+ -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \
+ -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \
+ -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \
+ -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \
+ -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \
+ -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \
+ -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \
+ -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \
+ -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \
+ -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \
+ -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \
+ -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \
+ -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \
+ -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \
+ -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \
+ -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \
+ -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \
+ -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \
+ -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \
+ -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \
+ -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \
+ -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \
+ -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \
+ -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \
+ -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \
+ -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \
+ -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
+ -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \
+ < $(srcdir)/string.in.h | \
+ sed -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \
+ -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
+ -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
+ -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
+ -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
+ -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
+ -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
+ -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
+ -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
+ -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
+ -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
+ -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
+ -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
+ -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
+ -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
+ -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
+ -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
+ -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
+ -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
+ -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
+ -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
+ -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
+ -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
+ -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
+ -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
+ -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
+ -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
+ -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
+ -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
+ -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
+ -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
+ -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
+ -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
+ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
+ -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
+ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
+ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
+ < $(srcdir)/string.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += string.h string.h-t
+
+EXTRA_DIST += string.in.h
+
+## end gnulib module string
+
+## begin gnulib module strings
+
+BUILT_SOURCES += strings.h
+
+# We need the following in order to create <strings.h> when the system
+# doesn't have one that works with the given compiler.
+strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
+ -e 's/@''GNULIB_FFS''@/$(GNULIB_FFS)/g' \
+ -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \
+ -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
+ -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/strings.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += strings.h strings.h-t
+
+EXTRA_DIST += strings.in.h
+
+## end gnulib module strings
+
+## begin gnulib module strndup
+
+
+EXTRA_DIST += strndup.c
+
+EXTRA_libgnu_a_SOURCES += strndup.c
+
+## end gnulib module strndup
+
+## begin gnulib module strnlen
+
+
+EXTRA_DIST += strnlen.c
+
+EXTRA_libgnu_a_SOURCES += strnlen.c
+
+## end gnulib module strnlen
+
+## begin gnulib module strnlen1
+
+libgnu_a_SOURCES += strnlen1.h strnlen1.c
+
+## end gnulib module strnlen1
+
+## begin gnulib module sys_stat
+
+BUILT_SOURCES += sys/stat.h
+
+# We need the following in order to create <sys/stat.h> when the system
+# has one that is incomplete.
+sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_at)$(MKDIR_P) sys
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
+ -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
+ -e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \
+ -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
+ -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \
+ -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
+ -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \
+ -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \
+ -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \
+ -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \
+ -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \
+ -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \
+ -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \
+ -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \
+ -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \
+ -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \
+ -e 's/@''GNULIB_OVERRIDES_STRUCT_STAT''@/$(GNULIB_OVERRIDES_STRUCT_STAT)/g' \
+ -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
+ -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
+ -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
+ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
+ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
+ -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
+ -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
+ -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
+ -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
+ -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
+ -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
+ -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
+ -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
+ -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
+ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
+ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
+ -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
+ -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
+ -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
+ -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/sys_stat.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_stat.in.h
+
+## end gnulib module sys_stat
+
+## begin gnulib module sys_types
+
+BUILT_SOURCES += sys/types.h
+
+# We need the following in order to create <sys/types.h> when the system
+# doesn't have one that works with the given compiler.
+sys/types.h: sys_types.in.h $(top_builddir)/config.status
+ $(AM_V_at)$(MKDIR_P) sys
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
+ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
+ -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \
+ < $(srcdir)/sys_types.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += sys/types.h sys/types.h-t
+
+EXTRA_DIST += sys_types.in.h
+
+## end gnulib module sys_types
+
+## begin gnulib module sysexits
+
+BUILT_SOURCES += $(SYSEXITS_H)
+
+# We need the following in order to create <sysexits.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_SYSEXITS_H
+sysexits.h: sysexits.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_SYSEXITS_H''@|$(HAVE_SYSEXITS_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_SYSEXITS_H''@|$(NEXT_SYSEXITS_H)|g' \
+ < $(srcdir)/sysexits.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+else
+sysexits.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += sysexits.h sysexits.h-t
+
+EXTRA_DIST += sysexits.in.h
+
+## end gnulib module sysexits
+
+## begin gnulib module threadlib
+
+libgnu_a_SOURCES += glthread/threadlib.c
+
+EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
+
+## end gnulib module threadlib
+
+## begin gnulib module time
+
+BUILT_SOURCES += time.h
+
+# We need the following in order to create <time.h> when the system
+# doesn't have one that works with the given compiler.
+time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
+ -e 's/@''GNULIB_CTIME''@/$(GNULIB_CTIME)/g' \
+ -e 's/@''GNULIB_LOCALTIME''@/$(GNULIB_LOCALTIME)/g' \
+ -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \
+ -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \
+ -e 's/@''GNULIB_STRFTIME''@/$(GNULIB_STRFTIME)/g' \
+ -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
+ -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
+ -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
+ -e 's/@''GNULIB_TIME_RZ''@/$(GNULIB_TIME_RZ)/g' \
+ -e 's/@''GNULIB_TZSET''@/$(GNULIB_TZSET)/g' \
+ -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
+ -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
+ -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
+ -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
+ -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
+ -e 's|@''HAVE_TZSET''@|$(HAVE_TZSET)|g' \
+ -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
+ -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
+ -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
+ -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
+ -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
+ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
+ -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \
+ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+ -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \
+ -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/time.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += time.h time.h-t
+
+EXTRA_DIST += time.in.h
+
+## end gnulib module time
+
+## begin gnulib module unistd
+
+BUILT_SOURCES += unistd.h
+libgnu_a_SOURCES += unistd.c
+
+# We need the following in order to create an empty placeholder for
+# <unistd.h> when the system doesn't have one.
+unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
+ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
+ -e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \
+ -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \
+ -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \
+ -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \
+ -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \
+ -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \
+ -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \
+ -e 's/@''GNULIB_EUIDACCESS''@/$(GNULIB_EUIDACCESS)/g' \
+ -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \
+ -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \
+ -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \
+ -e 's/@''GNULIB_FDATASYNC''@/$(GNULIB_FDATASYNC)/g' \
+ -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \
+ -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \
+ -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \
+ -e 's/@''GNULIB_GETDOMAINNAME''@/$(GNULIB_GETDOMAINNAME)/g' \
+ -e 's/@''GNULIB_GETDTABLESIZE''@/$(GNULIB_GETDTABLESIZE)/g' \
+ -e 's/@''GNULIB_GETGROUPS''@/$(GNULIB_GETGROUPS)/g' \
+ -e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \
+ -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \
+ -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \
+ -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \
+ -e 's/@''GNULIB_GETPASS''@/$(GNULIB_GETPASS)/g' \
+ -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \
+ -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \
+ -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \
+ -e 's/@''GNULIB_LCHOWN''@/$(GNULIB_LCHOWN)/g' \
+ -e 's/@''GNULIB_LINK''@/$(GNULIB_LINK)/g' \
+ -e 's/@''GNULIB_LINKAT''@/$(GNULIB_LINKAT)/g' \
+ -e 's/@''GNULIB_LSEEK''@/$(GNULIB_LSEEK)/g' \
+ -e 's/@''GNULIB_PIPE''@/$(GNULIB_PIPE)/g' \
+ -e 's/@''GNULIB_PIPE2''@/$(GNULIB_PIPE2)/g' \
+ -e 's/@''GNULIB_PREAD''@/$(GNULIB_PREAD)/g' \
+ -e 's/@''GNULIB_PWRITE''@/$(GNULIB_PWRITE)/g' \
+ -e 's/@''GNULIB_READ''@/$(GNULIB_READ)/g' \
+ -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \
+ -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \
+ -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \
+ -e 's/@''GNULIB_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/g' \
+ -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \
+ -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \
+ -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \
+ -e 's/@''GNULIB_TRUNCATE''@/$(GNULIB_TRUNCATE)/g' \
+ -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \
+ -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \
+ -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \
+ -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' \
+ -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \
+ -e 's/@''GNULIB_UNLINKAT''@/$(GNULIB_UNLINKAT)/g' \
+ -e 's/@''GNULIB_USLEEP''@/$(GNULIB_USLEEP)/g' \
+ -e 's/@''GNULIB_WRITE''@/$(GNULIB_WRITE)/g' \
+ < $(srcdir)/unistd.in.h | \
+ sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
+ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
+ -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
+ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
+ -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
+ -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \
+ -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
+ -e 's|@''HAVE_FDATASYNC''@|$(HAVE_FDATASYNC)|g' \
+ -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
+ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
+ -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
+ -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
+ -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
+ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
+ -e 's|@''HAVE_GETPASS''@|$(HAVE_GETPASS)|g' \
+ -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \
+ -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
+ -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
+ -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
+ -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \
+ -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
+ -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
+ -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \
+ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
+ -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
+ -e 's|@''HAVE_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|g' \
+ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
+ -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
+ -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
+ -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
+ -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
+ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
+ -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
+ -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \
+ -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
+ -e 's|@''HAVE_DECL_GETLOGIN''@|$(HAVE_DECL_GETLOGIN)|g' \
+ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
+ -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
+ -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
+ -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \
+ -e 's|@''HAVE_DECL_TRUNCATE''@|$(HAVE_DECL_TRUNCATE)|g' \
+ -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \
+ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
+ -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
+ | \
+ sed -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
+ -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
+ -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
+ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
+ -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \
+ -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
+ -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
+ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
+ -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
+ -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \
+ -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
+ -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
+ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
+ -e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \
+ -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
+ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
+ -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
+ -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
+ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
+ -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
+ -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
+ -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
+ -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
+ -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \
+ -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
+ -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
+ -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
+ -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
+ -e 's|@''REPLACE_TRUNCATE''@|$(REPLACE_TRUNCATE)|g' \
+ -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
+ -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
+ -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
+ -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
+ -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
+ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
+ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += unistd.h unistd.h-t
+
+EXTRA_DIST += unistd.in.h
+
+## end gnulib module unistd
+
+## begin gnulib module unistd-safer
+
+libgnu_a_SOURCES += dup-safer.c fd-safer.c pipe-safer.c
+
+EXTRA_DIST += unistd--.h unistd-safer.h
+
+## end gnulib module unistd-safer
+
+## begin gnulib module unitypes
+
+BUILT_SOURCES += $(LIBUNISTRING_UNITYPES_H)
+
+unitypes.h: unitypes.in.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/unitypes.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+MOSTLYCLEANFILES += unitypes.h unitypes.h-t
+
+EXTRA_DIST += unitypes.in.h
+
+## end gnulib module unitypes
+
+## begin gnulib module uniwidth/base
+
+BUILT_SOURCES += $(LIBUNISTRING_UNIWIDTH_H)
+
+uniwidth.h: uniwidth.in.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/uniwidth.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+MOSTLYCLEANFILES += uniwidth.h uniwidth.h-t
+
+EXTRA_DIST += localcharset.h uniwidth.in.h
+
+## end gnulib module uniwidth/base
+
+## begin gnulib module uniwidth/width
+
+if LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH
+libgnu_a_SOURCES += uniwidth/width.c
+endif
+
+EXTRA_DIST += uniwidth/cjk.h
+
+## end gnulib module uniwidth/width
+
+## begin gnulib module vasnprintf
+
+
+EXTRA_DIST += asnprintf.c float+.h printf-args.c printf-args.h printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h
+
+EXTRA_libgnu_a_SOURCES += asnprintf.c printf-args.c printf-parse.c vasnprintf.c
+
+## end gnulib module vasnprintf
+
+## begin gnulib module verify
+
+
+EXTRA_DIST += verify.h
+
+## end gnulib module verify
+
+## begin gnulib module vsnprintf
+
+
+EXTRA_DIST += vsnprintf.c
+
+EXTRA_libgnu_a_SOURCES += vsnprintf.c
+
+## end gnulib module vsnprintf
+
+## begin gnulib module wchar
+
+BUILT_SOURCES += wchar.h
+
+# We need the following in order to create <wchar.h> when the system
+# version does not work standalone.
+wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
+ -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
+ -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
+ -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
+ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
+ -e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \
+ -e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \
+ -e 's/@''GNULIB_MBSINIT''@/$(GNULIB_MBSINIT)/g' \
+ -e 's/@''GNULIB_MBRTOWC''@/$(GNULIB_MBRTOWC)/g' \
+ -e 's/@''GNULIB_MBRLEN''@/$(GNULIB_MBRLEN)/g' \
+ -e 's/@''GNULIB_MBSRTOWCS''@/$(GNULIB_MBSRTOWCS)/g' \
+ -e 's/@''GNULIB_MBSNRTOWCS''@/$(GNULIB_MBSNRTOWCS)/g' \
+ -e 's/@''GNULIB_WCRTOMB''@/$(GNULIB_WCRTOMB)/g' \
+ -e 's/@''GNULIB_WCSRTOMBS''@/$(GNULIB_WCSRTOMBS)/g' \
+ -e 's/@''GNULIB_WCSNRTOMBS''@/$(GNULIB_WCSNRTOMBS)/g' \
+ -e 's/@''GNULIB_WCWIDTH''@/$(GNULIB_WCWIDTH)/g' \
+ -e 's/@''GNULIB_WMEMCHR''@/$(GNULIB_WMEMCHR)/g' \
+ -e 's/@''GNULIB_WMEMCMP''@/$(GNULIB_WMEMCMP)/g' \
+ -e 's/@''GNULIB_WMEMCPY''@/$(GNULIB_WMEMCPY)/g' \
+ -e 's/@''GNULIB_WMEMMOVE''@/$(GNULIB_WMEMMOVE)/g' \
+ -e 's/@''GNULIB_WMEMSET''@/$(GNULIB_WMEMSET)/g' \
+ -e 's/@''GNULIB_WCSLEN''@/$(GNULIB_WCSLEN)/g' \
+ -e 's/@''GNULIB_WCSNLEN''@/$(GNULIB_WCSNLEN)/g' \
+ -e 's/@''GNULIB_WCSCPY''@/$(GNULIB_WCSCPY)/g' \
+ -e 's/@''GNULIB_WCPCPY''@/$(GNULIB_WCPCPY)/g' \
+ -e 's/@''GNULIB_WCSNCPY''@/$(GNULIB_WCSNCPY)/g' \
+ -e 's/@''GNULIB_WCPNCPY''@/$(GNULIB_WCPNCPY)/g' \
+ -e 's/@''GNULIB_WCSCAT''@/$(GNULIB_WCSCAT)/g' \
+ -e 's/@''GNULIB_WCSNCAT''@/$(GNULIB_WCSNCAT)/g' \
+ -e 's/@''GNULIB_WCSCMP''@/$(GNULIB_WCSCMP)/g' \
+ -e 's/@''GNULIB_WCSNCMP''@/$(GNULIB_WCSNCMP)/g' \
+ -e 's/@''GNULIB_WCSCASECMP''@/$(GNULIB_WCSCASECMP)/g' \
+ -e 's/@''GNULIB_WCSNCASECMP''@/$(GNULIB_WCSNCASECMP)/g' \
+ -e 's/@''GNULIB_WCSCOLL''@/$(GNULIB_WCSCOLL)/g' \
+ -e 's/@''GNULIB_WCSXFRM''@/$(GNULIB_WCSXFRM)/g' \
+ -e 's/@''GNULIB_WCSDUP''@/$(GNULIB_WCSDUP)/g' \
+ -e 's/@''GNULIB_WCSCHR''@/$(GNULIB_WCSCHR)/g' \
+ -e 's/@''GNULIB_WCSRCHR''@/$(GNULIB_WCSRCHR)/g' \
+ -e 's/@''GNULIB_WCSCSPN''@/$(GNULIB_WCSCSPN)/g' \
+ -e 's/@''GNULIB_WCSSPN''@/$(GNULIB_WCSSPN)/g' \
+ -e 's/@''GNULIB_WCSPBRK''@/$(GNULIB_WCSPBRK)/g' \
+ -e 's/@''GNULIB_WCSSTR''@/$(GNULIB_WCSSTR)/g' \
+ -e 's/@''GNULIB_WCSTOK''@/$(GNULIB_WCSTOK)/g' \
+ -e 's/@''GNULIB_WCSWIDTH''@/$(GNULIB_WCSWIDTH)/g' \
+ -e 's/@''GNULIB_WCSFTIME''@/$(GNULIB_WCSFTIME)/g' \
+ < $(srcdir)/wchar.in.h | \
+ sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \
+ -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \
+ -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \
+ -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \
+ -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \
+ -e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \
+ -e 's|@''HAVE_MBSNRTOWCS''@|$(HAVE_MBSNRTOWCS)|g' \
+ -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \
+ -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \
+ -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \
+ -e 's|@''HAVE_WMEMCHR''@|$(HAVE_WMEMCHR)|g' \
+ -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \
+ -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \
+ -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \
+ -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \
+ -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \
+ -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \
+ -e 's|@''HAVE_WCSCPY''@|$(HAVE_WCSCPY)|g' \
+ -e 's|@''HAVE_WCPCPY''@|$(HAVE_WCPCPY)|g' \
+ -e 's|@''HAVE_WCSNCPY''@|$(HAVE_WCSNCPY)|g' \
+ -e 's|@''HAVE_WCPNCPY''@|$(HAVE_WCPNCPY)|g' \
+ -e 's|@''HAVE_WCSCAT''@|$(HAVE_WCSCAT)|g' \
+ -e 's|@''HAVE_WCSNCAT''@|$(HAVE_WCSNCAT)|g' \
+ -e 's|@''HAVE_WCSCMP''@|$(HAVE_WCSCMP)|g' \
+ -e 's|@''HAVE_WCSNCMP''@|$(HAVE_WCSNCMP)|g' \
+ -e 's|@''HAVE_WCSCASECMP''@|$(HAVE_WCSCASECMP)|g' \
+ -e 's|@''HAVE_WCSNCASECMP''@|$(HAVE_WCSNCASECMP)|g' \
+ -e 's|@''HAVE_WCSCOLL''@|$(HAVE_WCSCOLL)|g' \
+ -e 's|@''HAVE_WCSXFRM''@|$(HAVE_WCSXFRM)|g' \
+ -e 's|@''HAVE_WCSDUP''@|$(HAVE_WCSDUP)|g' \
+ -e 's|@''HAVE_WCSCHR''@|$(HAVE_WCSCHR)|g' \
+ -e 's|@''HAVE_WCSRCHR''@|$(HAVE_WCSRCHR)|g' \
+ -e 's|@''HAVE_WCSCSPN''@|$(HAVE_WCSCSPN)|g' \
+ -e 's|@''HAVE_WCSSPN''@|$(HAVE_WCSSPN)|g' \
+ -e 's|@''HAVE_WCSPBRK''@|$(HAVE_WCSPBRK)|g' \
+ -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \
+ -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \
+ -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \
+ -e 's|@''HAVE_WCSFTIME''@|$(HAVE_WCSFTIME)|g' \
+ -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
+ -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
+ | \
+ sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
+ -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
+ -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
+ -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \
+ -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \
+ -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \
+ -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \
+ -e 's|@''REPLACE_MBSNRTOWCS''@|$(REPLACE_MBSNRTOWCS)|g' \
+ -e 's|@''REPLACE_WCRTOMB''@|$(REPLACE_WCRTOMB)|g' \
+ -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
+ -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
+ -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
+ -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
+ -e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += wchar.h wchar.h-t
+
+EXTRA_DIST += wchar.in.h
+
+## end gnulib module wchar
+
+## begin gnulib module wcrtomb
+
+
+EXTRA_DIST += wcrtomb.c
+
+EXTRA_libgnu_a_SOURCES += wcrtomb.c
+
+## end gnulib module wcrtomb
+
+## begin gnulib module wctype-h
+
+BUILT_SOURCES += wctype.h
+libgnu_a_SOURCES += wctype-h.c
+
+# We need the following in order to create <wctype.h> when the system
+# doesn't have one that works with the given compiler.
+wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
+ -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
+ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
+ -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \
+ -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \
+ -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \
+ -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \
+ -e 's/@''GNULIB_TOWCTRANS''@/$(GNULIB_TOWCTRANS)/g' \
+ -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \
+ -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
+ -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \
+ -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \
+ -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
+ -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \
+ -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
+ -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/wctype.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += wctype.h wctype.h-t
+
+EXTRA_DIST += wctype.in.h
+
+## end gnulib module wctype-h
+
+## begin gnulib module wcwidth
+
+
+EXTRA_DIST += wcwidth.c
+
+EXTRA_libgnu_a_SOURCES += wcwidth.c
+
+## end gnulib module wcwidth
+
+## begin gnulib module xalloc-oversized
+
+
+EXTRA_DIST += xalloc-oversized.h
+
+## end gnulib module xalloc-oversized
+
+## begin gnulib module xsize
+
+libgnu_a_SOURCES += xsize.h xsize.c
+
+## end gnulib module xsize
+
+
+mostlyclean-local: mostlyclean-generic
+ @for dir in '' $(MOSTLYCLEANDIRS); do \
+ if test -n "$$dir" && test -d $$dir; then \
+ echo "rmdir $$dir"; rmdir $$dir; \
+ fi; \
+ done; \
+ :
diff --git a/grub-core/lib/gnulib/Makefile.in b/grub-core/lib/gnulib/Makefile.in
new file mode 100644
index 0000000..839c259
--- /dev/null
+++ b/grub-core/lib/gnulib/Makefile.in
@@ -0,0 +1,3071 @@
+# Makefile.in generated by automake 1.15 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
+#
+# 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 of the License, 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file. If not, see <https://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License,
+# this file may be distributed as part of a program that
+# contains a configuration script generated by Autoconf, under
+# the same distribution terms as the rest of that program.
+#
+# Generated by gnulib-tool.
+# Reproduce by:
+# gnulib-tool --import --local-dir=gl \
+# --lib=libgnu \
+# --source-base=grub-core/lib/gnulib \
+# --m4-base=m4 \
+# --doc-base=doc \
+# --tests-base=tests \
+# --aux-dir=build-aux \
+# --no-conditional-dependencies \
+# --no-libtool \
+# --macro-prefix=gl \
+# --no-vc-files \
+# argp \
+# base64 \
+# error \
+# fnmatch \
+# getdelim \
+# getline \
+# gettext-h \
+# gitlog-to-changelog \
+# mbswidth \
+# progname \
+# realloc-gnu \
+# regex \
+# save-cwd
+
+
+
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+@LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_TRUE@am__append_1 = uniwidth/width.c
+subdir = grub-core/lib/gnulib
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
+ $(top_srcdir)/m4/__inline.m4 \
+ $(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/alloca.m4 \
+ $(top_srcdir)/m4/argp.m4 $(top_srcdir)/m4/base64.m4 \
+ $(top_srcdir)/m4/btowc.m4 $(top_srcdir)/m4/builtin-expect.m4 \
+ $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/close.m4 \
+ $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/dirent_h.m4 \
+ $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \
+ $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \
+ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/errno_h.m4 \
+ $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/exponentd.m4 \
+ $(top_srcdir)/m4/extensions.m4 \
+ $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fchdir.m4 \
+ $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl.m4 \
+ $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/filenamecat.m4 \
+ $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \
+ $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fnmatch_h.m4 \
+ $(top_srcdir)/m4/fstat.m4 $(top_srcdir)/m4/getcwd.m4 \
+ $(top_srcdir)/m4/getdelim.m4 $(top_srcdir)/m4/getdtablesize.m4 \
+ $(top_srcdir)/m4/getline.m4 $(top_srcdir)/m4/getopt.m4 \
+ $(top_srcdir)/m4/getprogname.m4 $(top_srcdir)/m4/gettext.m4 \
+ $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/gnulib-common.m4 \
+ $(top_srcdir)/m4/gnulib-comp.m4 \
+ $(top_srcdir)/m4/host-cpu-c-abi.m4 $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/include_next.m4 \
+ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax_t.m4 \
+ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/langinfo_h.m4 \
+ $(top_srcdir)/m4/largefile.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libunistring-base.m4 \
+ $(top_srcdir)/m4/limits-h.m4 $(top_srcdir)/m4/localcharset.m4 \
+ $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \
+ $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/locale_h.m4 \
+ $(top_srcdir)/m4/localeconv.m4 $(top_srcdir)/m4/lock.m4 \
+ $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/lstat.m4 \
+ $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \
+ $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \
+ $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \
+ $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/mbtowc.m4 \
+ $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/mempcpy.m4 \
+ $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/mmap-anon.m4 \
+ $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/msvc-inval.m4 \
+ $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \
+ $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \
+ $(top_srcdir)/m4/open-cloexec.m4 $(top_srcdir)/m4/open.m4 \
+ $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/printf.m4 \
+ $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/m4/pthread_rwlock_rdlock.m4 \
+ $(top_srcdir)/m4/rawmemchr.m4 $(top_srcdir)/m4/realloc.m4 \
+ $(top_srcdir)/m4/regex.m4 $(top_srcdir)/m4/save-cwd.m4 \
+ $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/sleep.m4 \
+ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/stat-time.m4 \
+ $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdalign.m4 \
+ $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \
+ $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \
+ $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \
+ $(top_srcdir)/m4/strcase.m4 $(top_srcdir)/m4/strchrnul.m4 \
+ $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \
+ $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strings_h.m4 \
+ $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \
+ $(top_srcdir)/m4/sys_socket_h.m4 \
+ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_types_h.m4 \
+ $(top_srcdir)/m4/sysexits.m4 $(top_srcdir)/m4/threadlib.m4 \
+ $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/unistd-safer.m4 \
+ $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/vasnprintf.m4 \
+ $(top_srcdir)/m4/vsnprintf.m4 $(top_srcdir)/m4/warn-on-use.m4 \
+ $(top_srcdir)/m4/wchar_h.m4 $(top_srcdir)/m4/wchar_t.m4 \
+ $(top_srcdir)/m4/wcrtomb.m4 $(top_srcdir)/m4/wctype_h.m4 \
+ $(top_srcdir)/m4/wcwidth.m4 $(top_srcdir)/m4/wint_t.m4 \
+ $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config-util.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AM_V_AR = $(am__v_AR_@AM_V@)
+am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
+am__v_AR_0 = @echo " AR " $@;
+am__v_AR_1 =
+libgnu_a_AR = $(AR) $(ARFLAGS)
+am__DEPENDENCIES_1 =
+am__libgnu_a_SOURCES_DIST = argp.h argp-ba.c argp-eexst.c \
+ argp-fmtstream.c argp-fmtstream.h argp-fs-xinl.c argp-help.c \
+ argp-namefrob.h argp-parse.c argp-pin.c argp-pv.c argp-pvh.c \
+ argp-xinl.c base64.h base64.c cloexec.c dirname-lgpl.c \
+ basename-lgpl.c stripslash.c exitfail.c fd-hook.c \
+ fd-safer-flag.c dup-safer-flag.c filenamecat-lgpl.c \
+ getprogname.h getprogname.c gettext.h hard-locale.c \
+ localcharset.c glthread/lock.h glthread/lock.c malloca.c \
+ mbswidth.h mbswidth.c openat-die.c progname.h progname.c \
+ save-cwd.c size_max.h stat-time.c strnlen1.h strnlen1.c \
+ glthread/threadlib.c unistd.c dup-safer.c fd-safer.c \
+ pipe-safer.c uniwidth/width.c wctype-h.c xsize.h xsize.c
+am__dirstamp = $(am__leading_dot)dirstamp
+@LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_TRUE@am__objects_1 = uniwidth/width.$(OBJEXT)
+am_libgnu_a_OBJECTS = argp-ba.$(OBJEXT) argp-eexst.$(OBJEXT) \
+ argp-fmtstream.$(OBJEXT) argp-fs-xinl.$(OBJEXT) \
+ argp-help.$(OBJEXT) argp-parse.$(OBJEXT) argp-pin.$(OBJEXT) \
+ argp-pv.$(OBJEXT) argp-pvh.$(OBJEXT) argp-xinl.$(OBJEXT) \
+ base64.$(OBJEXT) cloexec.$(OBJEXT) dirname-lgpl.$(OBJEXT) \
+ basename-lgpl.$(OBJEXT) stripslash.$(OBJEXT) \
+ exitfail.$(OBJEXT) fd-hook.$(OBJEXT) fd-safer-flag.$(OBJEXT) \
+ dup-safer-flag.$(OBJEXT) filenamecat-lgpl.$(OBJEXT) \
+ getprogname.$(OBJEXT) hard-locale.$(OBJEXT) \
+ localcharset.$(OBJEXT) glthread/lock.$(OBJEXT) \
+ malloca.$(OBJEXT) mbswidth.$(OBJEXT) openat-die.$(OBJEXT) \
+ progname.$(OBJEXT) save-cwd.$(OBJEXT) stat-time.$(OBJEXT) \
+ strnlen1.$(OBJEXT) glthread/threadlib.$(OBJEXT) \
+ unistd.$(OBJEXT) dup-safer.$(OBJEXT) fd-safer.$(OBJEXT) \
+ pipe-safer.$(OBJEXT) $(am__objects_1) wctype-h.$(OBJEXT) \
+ xsize.$(OBJEXT)
+libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS)
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(libgnu_a_SOURCES) $(EXTRA_libgnu_a_SOURCES)
+DIST_SOURCES = $(am__libgnu_a_SOURCES_DIST) $(EXTRA_libgnu_a_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+ ctags-recursive dvi-recursive html-recursive info-recursive \
+ install-data-recursive install-dvi-recursive \
+ install-exec-recursive install-html-recursive \
+ install-info-recursive install-pdf-recursive \
+ install-ps-recursive install-recursive installcheck-recursive \
+ installdirs-recursive pdf-recursive ps-recursive \
+ tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+HEADERS = $(noinst_HEADERS)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+ $(RECURSIVE_TARGETS) \
+ $(RECURSIVE_CLEAN_TARGETS) \
+ $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+ distdir
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in \
+ $(top_srcdir)/build-aux/depcomp alloca.c
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARFLAGS = @ARFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+BOOT_TIME_STATS = @BOOT_TIME_STATS@
+BSS_START_SYMBOL = @BSS_START_SYMBOL@
+BUILD_CC = @BUILD_CC@
+BUILD_CFLAGS = @BUILD_CFLAGS@
+BUILD_CPPFLAGS = @BUILD_CPPFLAGS@
+BUILD_EXEEXT = @BUILD_EXEEXT@
+BUILD_FREETYPE_CFLAGS = @BUILD_FREETYPE_CFLAGS@
+BUILD_FREETYPE_LIBS = @BUILD_FREETYPE_LIBS@
+BUILD_LDFLAGS = @BUILD_LDFLAGS@
+BUILD_LIBM = @BUILD_LIBM@
+BUILD_SHEBANG = @BUILD_SHEBANG@
+BUILD_SIZEOF_LONG = @BUILD_SIZEOF_LONG@
+BUILD_SIZEOF_VOID_P = @BUILD_SIZEOF_VOID_P@
+BUILD_WORDS_BIGENDIAN = @BUILD_WORDS_BIGENDIAN@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISK_CACHE_STATS = @DISK_CACHE_STATS@
+DJVU_FONT_SOURCE = @DJVU_FONT_SOURCE@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EFIEMU64_LINK_FORMAT = @EFIEMU64_LINK_FORMAT@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+END_SYMBOL = @END_SYMBOL@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+FONT_SOURCE = @FONT_SOURCE@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GETOPT_CDEFS_H = @GETOPT_CDEFS_H@
+GETOPT_H = @GETOPT_H@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GLIBC21 = @GLIBC21@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GNULIB_ALPHASORT = @GNULIB_ALPHASORT@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHDIR = @GNULIB_CHDIR@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_CLOSEDIR = @GNULIB_CLOSEDIR@
+GNULIB_CTIME = @GNULIB_CTIME@
+GNULIB_DIRFD = @GNULIB_DIRFD@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP = @GNULIB_DUP@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_EXPLICIT_BZERO = @GNULIB_EXPLICIT_BZERO@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FDATASYNC = @GNULIB_FDATASYNC@
+GNULIB_FDOPEN = @GNULIB_FDOPEN@
+GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FFS = @GNULIB_FFS@
+GNULIB_FFSL = @GNULIB_FFSL@
+GNULIB_FFSLL = @GNULIB_FFSLL@
+GNULIB_FGETC = @GNULIB_FGETC@
+GNULIB_FGETS = @GNULIB_FGETS@
+GNULIB_FNMATCH = @GNULIB_FNMATCH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREAD = @GNULIB_FREAD@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSCANF = @GNULIB_FSCANF@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTAT = @GNULIB_FSTAT@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETC = @GNULIB_GETC@
+GNULIB_GETCHAR = @GNULIB_GETCHAR@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETPASS = @GNULIB_GETPASS@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETTIMEOFDAY = @GNULIB_GETTIMEOFDAY@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GL_UNISTD_H_GETOPT = @GNULIB_GL_UNISTD_H_GETOPT@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_GROUP_MEMBER = @GNULIB_GROUP_MEMBER@
+GNULIB_ISATTY = @GNULIB_ISATTY@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LOCALECONV = @GNULIB_LOCALECONV@
+GNULIB_LOCALENAME = @GNULIB_LOCALENAME@
+GNULIB_LOCALTIME = @GNULIB_LOCALTIME@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_NONBLOCKING = @GNULIB_NONBLOCKING@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_OPENDIR = @GNULIB_OPENDIR@
+GNULIB_OVERRIDES_STRUCT_STAT = @GNULIB_OVERRIDES_STRUCT_STAT@
+GNULIB_OVERRIDES_WINT_T = @GNULIB_OVERRIDES_WINT_T@
+GNULIB_PCLOSE = @GNULIB_PCLOSE@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PTSNAME_R = @GNULIB_PTSNAME_R@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_QSORT_R = @GNULIB_QSORT_R@
+GNULIB_RANDOM = @GNULIB_RANDOM@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READ = @GNULIB_READ@
+GNULIB_READDIR = @GNULIB_READDIR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOCARRAY = @GNULIB_REALLOCARRAY@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_REWINDDIR = @GNULIB_REWINDDIR@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SCANDIR = @GNULIB_SCANDIR@
+GNULIB_SCANF = @GNULIB_SCANF@
+GNULIB_SECURE_GETENV = @GNULIB_SECURE_GETENV@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETHOSTNAME = @GNULIB_SETHOSTNAME@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_NONBLOCKING = @GNULIB_STDIO_H_NONBLOCKING@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRFTIME = @GNULIB_STRFTIME@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TIME_RZ = @GNULIB_TIME_RZ@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TRUNCATE = @GNULIB_TRUNCATE@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_TZSET = @GNULIB_TZSET@
+GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VFSCANF = @GNULIB_VFSCANF@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSCANF = @GNULIB_VSCANF@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSFTIME = @GNULIB_WCSFTIME@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+GRUB_BOOT_MACHINE_LINK_ADDR = @GRUB_BOOT_MACHINE_LINK_ADDR@
+GRUB_PLATFORM = @GRUB_PLATFORM@
+GRUB_TARGET_CPU = @GRUB_TARGET_CPU@
+HAVE_ALPHASORT = @HAVE_ALPHASORT@
+HAVE_ASM_USCORE = @HAVE_ASM_USCORE@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_C99_STDINT_H = @HAVE_C99_STDINT_H@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_CLOSEDIR = @HAVE_CLOSEDIR@
+HAVE_CRTDEFS_H = @HAVE_CRTDEFS_H@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DECL_DIRFD = @HAVE_DECL_DIRFD@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FDATASYNC = @HAVE_DECL_FDATASYNC@
+HAVE_DECL_FDOPENDIR = @HAVE_DECL_FDOPENDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN = @HAVE_DECL_GETLOGIN@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_INITSTATE = @HAVE_DECL_INITSTATE@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@
+HAVE_DECL_SETSTATE = @HAVE_DECL_SETSTATE@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNCASECMP = @HAVE_DECL_STRNCASECMP@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TRUNCATE = @HAVE_DECL_TRUNCATE@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DIRENT_H = @HAVE_DIRENT_H@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_EXPLICIT_BZERO = @HAVE_EXPLICIT_BZERO@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FDATASYNC = @HAVE_FDATASYNC@
+HAVE_FDOPENDIR = @HAVE_FDOPENDIR@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FFS = @HAVE_FFS@
+HAVE_FFSL = @HAVE_FFSL@
+HAVE_FFSLL = @HAVE_FFSLL@
+HAVE_FNMATCH = @HAVE_FNMATCH@
+HAVE_FNMATCH_H = @HAVE_FNMATCH_H@
+HAVE_FONT_SOURCE = @HAVE_FONT_SOURCE@
+HAVE_FREELOCALE = @HAVE_FREELOCALE@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETPASS = @HAVE_GETPASS@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_GROUP_MEMBER = @HAVE_GROUP_MEMBER@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_ALTMON = @HAVE_LANGINFO_ALTMON@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_MSVC_INVALID_PARAMETER_HANDLER = @HAVE_MSVC_INVALID_PARAMETER_HANDLER@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NEWLOCALE = @HAVE_NEWLOCALE@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OPENDIR = @HAVE_OPENDIR@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PCLOSE = @HAVE_PCLOSE@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_POPEN = @HAVE_POPEN@
+HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PTSNAME_R = @HAVE_PTSNAME_R@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_QSORT_R = @HAVE_QSORT_R@
+HAVE_RANDOM = @HAVE_RANDOM@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READDIR = @HAVE_READDIR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALLOCARRAY = @HAVE_REALLOCARRAY@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_REWINDDIR = @HAVE_REWINDDIR@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SCANDIR = @HAVE_SCANDIR@
+HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASECMP = @HAVE_STRCASECMP@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRINGS_H = @HAVE_STRINGS_H@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYSEXITS_H = @HAVE_SYSEXITS_H@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_CDEFS_H = @HAVE_SYS_CDEFS_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@
+HAVE_TZSET = @HAVE_TZSET@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSFTIME = @HAVE_WCSFTIME@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+HELP2MAN = @HELP2MAN@
+HOST_CC = @HOST_CC@
+HOST_CCASFLAGS = @HOST_CCASFLAGS@
+HOST_CFLAGS = @HOST_CFLAGS@
+HOST_CPPFLAGS = @HOST_CPPFLAGS@
+HOST_LDFLAGS = @HOST_LDFLAGS@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDEVMAPPER = @LIBDEVMAPPER@
+LIBGEOM = @LIBGEOM@
+LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
+LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBLZMA = @LIBLZMA@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBNVPAIR = @LIBNVPAIR@
+LIBOBJS = @LIBOBJS@
+LIBPCIACCESS = @LIBPCIACCESS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBSDL = @LIBSDL@
+LIBTHREAD = @LIBTHREAD@
+LIBUNISTRING_UNITYPES_H = @LIBUNISTRING_UNITYPES_H@
+LIBUNISTRING_UNIWIDTH_H = @LIBUNISTRING_UNIWIDTH_H@
+LIBUTIL = @LIBUTIL@
+LIBZFS = @LIBZFS@
+LIMITS_H = @LIMITS_H@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_FNMATCH_H = @NEXT_AS_FIRST_DIRECTIVE_FNMATCH_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRINGS_H = @NEXT_AS_FIRST_DIRECTIVE_STRINGS_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYSEXITS_H = @NEXT_AS_FIRST_DIRECTIVE_SYSEXITS_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_DIRENT_H = @NEXT_DIRENT_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_FNMATCH_H = @NEXT_FNMATCH_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LIMITS_H = @NEXT_LIMITS_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRINGS_H = @NEXT_STRINGS_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYSEXITS_H = @NEXT_SYSEXITS_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POSUB = @POSUB@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
+REPLACE_CTIME = @REPLACE_CTIME@
+REPLACE_DIRFD = @REPLACE_DIRFD@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FACCESSAT = @REPLACE_FACCESSAT@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FDOPEN = @REPLACE_FDOPEN@
+REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FNMATCH = @REPLACE_FNMATCH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREELOCALE = @REPLACE_FREELOCALE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FTRUNCATE = @REPLACE_FTRUNCATE@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETDTABLESIZE = @REPLACE_GETDTABLESIZE@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_GETPASS = @REPLACE_GETPASS@
+REPLACE_GMTIME = @REPLACE_GMTIME@
+REPLACE_ISATTY = @REPLACE_ISATTY@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_ITOLD = @REPLACE_ITOLD@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALECONV = @REPLACE_LOCALECONV@
+REPLACE_LOCALTIME = @REPLACE_LOCALTIME@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NEWLOCALE = @REPLACE_NEWLOCALE@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_OPENDIR = @REPLACE_OPENDIR@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PTSNAME = @REPLACE_PTSNAME@
+REPLACE_PTSNAME_R = @REPLACE_PTSNAME_R@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_QSORT_R = @REPLACE_QSORT_R@
+REPLACE_RANDOM_R = @REPLACE_RANDOM_R@
+REPLACE_READ = @REPLACE_READ@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_READLINKAT = @REPLACE_READLINKAT@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_READ_FUNCS = @REPLACE_STDIO_READ_FUNCS@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRFTIME = @REPLACE_STRFTIME@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_STRUCT_LCONV = @REPLACE_STRUCT_LCONV@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TOWLOWER = @REPLACE_TOWLOWER@
+REPLACE_TRUNCATE = @REPLACE_TRUNCATE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_TZSET = @REPLACE_TZSET@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSFTIME = @REPLACE_WCSFTIME@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDALIGN_H = @STDALIGN_H@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYSEXITS_H = @SYSEXITS_H@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TARGET_APPLE_LINKER = @TARGET_APPLE_LINKER@
+TARGET_CC = @TARGET_CC@
+TARGET_CCAS = @TARGET_CCAS@
+TARGET_CCASFLAGS = @TARGET_CCASFLAGS@
+TARGET_CC_VERSION = @TARGET_CC_VERSION@
+TARGET_CFLAGS = @TARGET_CFLAGS@
+TARGET_CPP = @TARGET_CPP@
+TARGET_CPPFLAGS = @TARGET_CPPFLAGS@
+TARGET_DECOMPRESSOR_LINK_ADDR = @TARGET_DECOMPRESSOR_LINK_ADDR@
+TARGET_IMG_BASE_LDOPT = @TARGET_IMG_BASE_LDOPT@
+TARGET_IMG_CFLAGS = @TARGET_IMG_CFLAGS@
+TARGET_IMG_LDFLAGS = @TARGET_IMG_LDFLAGS@
+TARGET_LDFLAGS = @TARGET_LDFLAGS@
+TARGET_LDFLAGS_OLDMAGIC = @TARGET_LDFLAGS_OLDMAGIC@
+TARGET_LINK_ADDR = @TARGET_LINK_ADDR@
+TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
+TARGET_NM = @TARGET_NM@
+TARGET_NMFLAGS_DEFINED_ONLY = @TARGET_NMFLAGS_DEFINED_ONLY@
+TARGET_NMFLAGS_MINUS_P = @TARGET_NMFLAGS_MINUS_P@
+TARGET_OBJ2ELF = @TARGET_OBJ2ELF@
+TARGET_OBJCONV = @TARGET_OBJCONV@
+TARGET_OBJCOPY = @TARGET_OBJCOPY@
+TARGET_RANLIB = @TARGET_RANLIB@
+TARGET_STRIP = @TARGET_STRIP@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@
+WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@
+WINDOWS_STAT_INODES = @WINDOWS_STAT_INODES@
+WINDOWS_STAT_TIMESPEC = @WINDOWS_STAT_TIMESPEC@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_TARGET_CC = @ac_ct_TARGET_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bootdirname = @bootdirname@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+enable_efiemu = @enable_efiemu@
+enable_grub_emu_pci = @enable_grub_emu_pci@
+enable_grub_emu_sdl = @enable_grub_emu_sdl@
+enable_grub_mkfont = @enable_grub_mkfont@
+enable_grub_mount = @enable_grub_mount@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+grub_bios_setup = @grub_bios_setup@
+grub_editenv = @grub_editenv@
+grub_file = @grub_file@
+grub_glue_efi = @grub_glue_efi@
+grub_install = @grub_install@
+grub_mkconfig = @grub_mkconfig@
+grub_mkfont = @grub_mkfont@
+grub_mkimage = @grub_mkimage@
+grub_mklayout = @grub_mklayout@
+grub_mkpasswd_pbkdf2 = @grub_mkpasswd_pbkdf2@
+grub_mkrelpath = @grub_mkrelpath@
+grub_mkrescue = @grub_mkrescue@
+grub_probe = @grub_probe@
+grub_reboot = @grub_reboot@
+grub_render_label = @grub_render_label@
+grub_script_check = @grub_script_check@
+grub_set_default = @grub_set_default@
+grub_sparc64_setup = @grub_sparc64_setup@
+grubdirname = @grubdirname@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_kernel = @host_kernel@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+platform = @platform@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = 1.11 gnits subdir-objects
+SUBDIRS =
+noinst_HEADERS =
+noinst_LIBRARIES = libgnu.a
+noinst_LTLIBRARIES =
+EXTRA_DIST = alloca.c alloca.in.h assure.h openat-priv.h openat-proc.c \
+ btowc.c chdir-long.c chdir-long.h cloexec.h close.c \
+ dirent.in.h dirfd.c dirname.h dosname.h dup2.c errno.in.h \
+ error.c error.h exitfail.h fchdir.c fcntl.c fcntl.in.h \
+ fd-hook.h filename.h filenamecat.h flexmember.h float.c \
+ float.in.h itold.c fnmatch.c fnmatch_loop.c fnmatch.in.h \
+ fstat.c stat-w32.c stat-w32.h getcwd-lgpl.c getdelim.c \
+ getdtablesize.c getline.c getopt-cdefs.in.h getopt-core.h \
+ getopt-ext.h getopt-pfx-core.h getopt-pfx-ext.h getopt.c \
+ getopt.in.h getopt1.c getopt_int.h \
+ $(top_srcdir)/build-aux/gitlog-to-changelog hard-locale.h \
+ $(top_srcdir)/build-aux/config.rpath intprops.h langinfo.in.h \
+ cdefs.h libc-config.h limits.in.h localcharset.h locale.in.h \
+ localeconv.c malloc.c malloc.c malloca.h mbrtowc.c mbsinit.c \
+ mbsrtowcs-impl.h mbsrtowcs-state.c mbsrtowcs.c mbtowc-impl.h \
+ mbtowc.c memchr.c memchr.valgrind mempcpy.c memrchr.c \
+ msvc-inval.c msvc-inval.h msvc-nothrow.c msvc-nothrow.h \
+ nl_langinfo.c open.c openat.c openat.h pathmax.h rawmemchr.c \
+ rawmemchr.valgrind realloc.c realloc.c regcomp.c regex.c \
+ regex.h regex_internal.c regex_internal.h regexec.c save-cwd.h \
+ sleep.c _Noreturn.h arg-nonnull.h c++defs.h warn-on-use.h \
+ stat-w32.c stat-w32.h stat.c stat-time.h stdalign.in.h \
+ stdbool.in.h stddef.in.h stdint.in.h stdio.in.h stdlib.in.h \
+ strcasecmp.c strncasecmp.c strchrnul.c strchrnul.valgrind \
+ strdup.c streq.h strerror.c strerror-override.c \
+ strerror-override.h string.in.h strings.in.h strndup.c \
+ strnlen.c sys_stat.in.h sys_types.in.h sysexits.in.h \
+ $(top_srcdir)/build-aux/config.rpath time.in.h unistd.in.h \
+ unistd--.h unistd-safer.h unitypes.in.h localcharset.h \
+ uniwidth.in.h uniwidth/cjk.h asnprintf.c float+.h \
+ printf-args.c printf-args.h printf-parse.c printf-parse.h \
+ vasnprintf.c vasnprintf.h verify.h vsnprintf.c wchar.in.h \
+ wcrtomb.c wctype.in.h wcwidth.c xalloc-oversized.h
+BUILT_SOURCES = $(ALLOCA_H) dirent.h $(ERRNO_H) fcntl.h $(FLOAT_H) \
+ $(FNMATCH_H) $(GETOPT_H) $(GETOPT_CDEFS_H) langinfo.h \
+ $(LIMITS_H) locale.h $(STDALIGN_H) $(STDBOOL_H) $(STDDEF_H) \
+ $(STDINT_H) stdio.h stdlib.h string.h strings.h sys/stat.h \
+ sys/types.h $(SYSEXITS_H) time.h unistd.h \
+ $(LIBUNISTRING_UNITYPES_H) $(LIBUNISTRING_UNIWIDTH_H) wchar.h \
+ wctype.h
+SUFFIXES =
+MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t dirent.h \
+ dirent.h-t errno.h errno.h-t fcntl.h fcntl.h-t float.h \
+ float.h-t fnmatch.h fnmatch.h-t getopt.h getopt.h-t \
+ getopt-cdefs.h getopt-cdefs.h-t langinfo.h langinfo.h-t \
+ limits.h limits.h-t locale.h locale.h-t stdalign.h \
+ stdalign.h-t stdbool.h stdbool.h-t stddef.h stddef.h-t \
+ stdint.h stdint.h-t stdio.h stdio.h-t stdlib.h stdlib.h-t \
+ string.h string.h-t strings.h strings.h-t sys/stat.h \
+ sys/stat.h-t sys/types.h sys/types.h-t sysexits.h sysexits.h-t \
+ time.h time.h-t unistd.h unistd.h-t unitypes.h unitypes.h-t \
+ uniwidth.h uniwidth.h-t wchar.h wchar.h-t wctype.h wctype.h-t
+MOSTLYCLEANDIRS = sys
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+# No GNU Make output.
+AM_CPPFLAGS =
+AM_CFLAGS =
+libgnu_a_SOURCES = argp.h argp-ba.c argp-eexst.c argp-fmtstream.c \
+ argp-fmtstream.h argp-fs-xinl.c argp-help.c argp-namefrob.h \
+ argp-parse.c argp-pin.c argp-pv.c argp-pvh.c argp-xinl.c \
+ base64.h base64.c cloexec.c dirname-lgpl.c basename-lgpl.c \
+ stripslash.c exitfail.c fd-hook.c fd-safer-flag.c \
+ dup-safer-flag.c filenamecat-lgpl.c getprogname.h \
+ getprogname.c gettext.h hard-locale.c localcharset.c \
+ glthread/lock.h glthread/lock.c malloca.c mbswidth.h \
+ mbswidth.c openat-die.c progname.h progname.c save-cwd.c \
+ size_max.h stat-time.c strnlen1.h strnlen1.c \
+ glthread/threadlib.c unistd.c dup-safer.c fd-safer.c \
+ pipe-safer.c $(am__append_1) wctype-h.c xsize.h xsize.c
+libgnu_a_LIBADD = $(gl_LIBOBJS) @ALLOCA@
+libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) @ALLOCA@
+EXTRA_libgnu_a_SOURCES = alloca.c openat-proc.c btowc.c chdir-long.c \
+ close.c dirfd.c dup2.c error.c fchdir.c fcntl.c float.c \
+ itold.c fnmatch.c fnmatch_loop.c fstat.c stat-w32.c \
+ getcwd-lgpl.c getdelim.c getdtablesize.c getline.c getopt.c \
+ getopt1.c localeconv.c malloc.c malloc.c mbrtowc.c mbsinit.c \
+ mbsrtowcs-state.c mbsrtowcs.c mbtowc.c memchr.c mempcpy.c \
+ memrchr.c msvc-inval.c msvc-nothrow.c nl_langinfo.c open.c \
+ openat.c rawmemchr.c realloc.c realloc.c regcomp.c regex.c \
+ regex_internal.c regexec.c sleep.c stat-w32.c stat.c \
+ strcasecmp.c strncasecmp.c strchrnul.c strdup.c strerror.c \
+ strerror-override.c strndup.c strnlen.c asnprintf.c \
+ printf-args.c printf-parse.c vasnprintf.c vsnprintf.c \
+ wcrtomb.c wcwidth.c
+
+# Use this preprocessor expression to decide whether #include_next works.
+# Do not rely on a 'configure'-time test for this, since the expression
+# might appear in an installed header, which is used by some other compiler.
+HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER)
+
+# Because this Makefile snippet defines a variable used by other
+# gnulib Makefile snippets, it must be present in all makefiles that
+# need it. This is ensured by the applicability 'all' defined above.
+_NORETURN_H = $(srcdir)/_Noreturn.h
+
+# Because this Makefile snippet defines a variable used by other
+# gnulib Makefile snippets, it must be present in all makefiles that
+# need it. This is ensured by the applicability 'all' defined above.
+ARG_NONNULL_H = $(srcdir)/arg-nonnull.h
+
+# Because this Makefile snippet defines a variable used by other
+# gnulib Makefile snippets, it must be present in all makefiles that
+# need it. This is ensured by the applicability 'all' defined above.
+CXXDEFS_H = $(srcdir)/c++defs.h
+
+# Because this Makefile snippet defines a variable used by other
+# gnulib Makefile snippets, it must be present in all makefiles that
+# need it. This is ensured by the applicability 'all' defined above.
+WARN_ON_USE_H = $(srcdir)/warn-on-use.h
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnits grub-core/lib/gnulib/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnits grub-core/lib/gnulib/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+glthread/$(am__dirstamp):
+ @$(MKDIR_P) glthread
+ @: > glthread/$(am__dirstamp)
+glthread/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) glthread/$(DEPDIR)
+ @: > glthread/$(DEPDIR)/$(am__dirstamp)
+glthread/lock.$(OBJEXT): glthread/$(am__dirstamp) \
+ glthread/$(DEPDIR)/$(am__dirstamp)
+glthread/threadlib.$(OBJEXT): glthread/$(am__dirstamp) \
+ glthread/$(DEPDIR)/$(am__dirstamp)
+uniwidth/$(am__dirstamp):
+ @$(MKDIR_P) uniwidth
+ @: > uniwidth/$(am__dirstamp)
+uniwidth/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) uniwidth/$(DEPDIR)
+ @: > uniwidth/$(DEPDIR)/$(am__dirstamp)
+uniwidth/width.$(OBJEXT): uniwidth/$(am__dirstamp) \
+ uniwidth/$(DEPDIR)/$(am__dirstamp)
+
+libgnu.a: $(libgnu_a_OBJECTS) $(libgnu_a_DEPENDENCIES) $(EXTRA_libgnu_a_DEPENDENCIES)
+ $(AM_V_at)-rm -f libgnu.a
+ $(AM_V_AR)$(libgnu_a_AR) libgnu.a $(libgnu_a_OBJECTS) $(libgnu_a_LIBADD)
+ $(AM_V_at)$(RANLIB) libgnu.a
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+ -rm -f glthread/*.$(OBJEXT)
+ -rm -f uniwidth/*.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/alloca.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloca.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-ba.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-eexst.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-fmtstream.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-fs-xinl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-help.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-parse.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-pin.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-pv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-pvh.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argp-xinl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asnprintf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename-lgpl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btowc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chdir-long.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cloexec.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/close.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirfd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirname-lgpl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup-safer-flag.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup-safer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exitfail.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchdir.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcntl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-hook.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-safer-flag.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-safer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filenamecat-lgpl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/float.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch_loop.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getcwd-lgpl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdelim.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdtablesize.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getline.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getprogname.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hard-locale.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/itold.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localcharset.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localeconv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloca.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbrtowc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsinit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsrtowcs-state.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsrtowcs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbswidth.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbtowc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memchr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mempcpy.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memrchr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msvc-inval.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msvc-nothrow.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nl_langinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-die.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-proc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pipe-safer.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf-args.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf-parse.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/progname.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rawmemchr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/realloc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regcomp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex_internal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regexec.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/save-cwd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sleep.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat-time.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat-w32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strcasecmp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strchrnul.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strdup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror-override.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stripslash.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strncasecmp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strndup.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unistd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vasnprintf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vsnprintf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcrtomb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctype-h.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcwidth.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xsize.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/lock.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/threadlib.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@uniwidth/$(DEPDIR)/width.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+# (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+ @fail=; \
+ if $(am__make_keepgoing); then \
+ failcom='fail=yes'; \
+ else \
+ failcom='exit 1'; \
+ fi; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ $(am__make_dryrun) \
+ || test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-recursive
+all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS)
+installdirs: installdirs-recursive
+installdirs-am:
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+ -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -rm -f glthread/$(DEPDIR)/$(am__dirstamp)
+ -rm -f glthread/$(am__dirstamp)
+ -rm -f uniwidth/$(DEPDIR)/$(am__dirstamp)
+ -rm -f uniwidth/$(am__dirstamp)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-recursive
+
+clean-am: clean-generic clean-noinstLIBRARIES clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -rf $(DEPDIR) ./$(DEPDIR) glthread/$(DEPDIR) uniwidth/$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -rf $(DEPDIR) ./$(DEPDIR) glthread/$(DEPDIR) uniwidth/$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-local
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(am__recursive_targets) all check install install-am \
+ install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
+ check-am clean clean-generic clean-noinstLIBRARIES \
+ clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \
+ distclean-compile distclean-generic distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs installdirs-am \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-local pdf \
+ pdf-am ps ps-am tags tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# We need the following in order to create <alloca.h> when the system
+# doesn't have one that works with the given compiler.
+@GL_GENERATE_ALLOCA_H_TRUE@alloca.h: alloca.in.h $(top_builddir)/config.status
+@GL_GENERATE_ALLOCA_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_ALLOCA_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+@GL_GENERATE_ALLOCA_H_TRUE@ cat $(srcdir)/alloca.in.h; \
+@GL_GENERATE_ALLOCA_H_TRUE@ } > $@-t && \
+@GL_GENERATE_ALLOCA_H_TRUE@ mv -f $@-t $@
+@GL_GENERATE_ALLOCA_H_FALSE@alloca.h: $(top_builddir)/config.status
+@GL_GENERATE_ALLOCA_H_FALSE@ rm -f $@
+
+# We need the following in order to create <dirent.h> when the system
+# doesn't have one that works with the given compiler.
+dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_DIRENT_H''@|$(HAVE_DIRENT_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \
+ -e 's/@''GNULIB_OPENDIR''@/$(GNULIB_OPENDIR)/g' \
+ -e 's/@''GNULIB_READDIR''@/$(GNULIB_READDIR)/g' \
+ -e 's/@''GNULIB_REWINDDIR''@/$(GNULIB_REWINDDIR)/g' \
+ -e 's/@''GNULIB_CLOSEDIR''@/$(GNULIB_CLOSEDIR)/g' \
+ -e 's/@''GNULIB_DIRFD''@/$(GNULIB_DIRFD)/g' \
+ -e 's/@''GNULIB_FDOPENDIR''@/$(GNULIB_FDOPENDIR)/g' \
+ -e 's/@''GNULIB_SCANDIR''@/$(GNULIB_SCANDIR)/g' \
+ -e 's/@''GNULIB_ALPHASORT''@/$(GNULIB_ALPHASORT)/g' \
+ -e 's/@''HAVE_OPENDIR''@/$(HAVE_OPENDIR)/g' \
+ -e 's/@''HAVE_READDIR''@/$(HAVE_READDIR)/g' \
+ -e 's/@''HAVE_REWINDDIR''@/$(HAVE_REWINDDIR)/g' \
+ -e 's/@''HAVE_CLOSEDIR''@/$(HAVE_CLOSEDIR)/g' \
+ -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \
+ -e 's|@''HAVE_DECL_FDOPENDIR''@|$(HAVE_DECL_FDOPENDIR)|g' \
+ -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \
+ -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \
+ -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \
+ -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \
+ -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \
+ -e 's|@''REPLACE_DIRFD''@|$(REPLACE_DIRFD)|g' \
+ -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/dirent.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <errno.h> when the system
+# doesn't have one that is POSIX compliant.
+@GL_GENERATE_ERRNO_H_TRUE@errno.h: errno.in.h $(top_builddir)/config.status
+@GL_GENERATE_ERRNO_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_ERRNO_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+@GL_GENERATE_ERRNO_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
+@GL_GENERATE_ERRNO_H_TRUE@ < $(srcdir)/errno.in.h; \
+@GL_GENERATE_ERRNO_H_TRUE@ } > $@-t && \
+@GL_GENERATE_ERRNO_H_TRUE@ mv $@-t $@
+@GL_GENERATE_ERRNO_H_FALSE@errno.h: $(top_builddir)/config.status
+@GL_GENERATE_ERRNO_H_FALSE@ rm -f $@
+
+# We need the following in order to create <fcntl.h> when the system
+# doesn't have one that works with the given compiler.
+fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
+ -e 's/@''GNULIB_FCNTL''@/$(GNULIB_FCNTL)/g' \
+ -e 's/@''GNULIB_NONBLOCKING''@/$(GNULIB_NONBLOCKING)/g' \
+ -e 's/@''GNULIB_OPEN''@/$(GNULIB_OPEN)/g' \
+ -e 's/@''GNULIB_OPENAT''@/$(GNULIB_OPENAT)/g' \
+ -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
+ -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
+ -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
+ -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
+ -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/fcntl.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <float.h> when the system
+# doesn't have one that works with the given compiler.
+@GL_GENERATE_FLOAT_H_TRUE@float.h: float.in.h $(top_builddir)/config.status
+@GL_GENERATE_FLOAT_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_FLOAT_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+@GL_GENERATE_FLOAT_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+@GL_GENERATE_FLOAT_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+@GL_GENERATE_FLOAT_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+@GL_GENERATE_FLOAT_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+@GL_GENERATE_FLOAT_H_TRUE@ -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
+@GL_GENERATE_FLOAT_H_TRUE@ -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \
+@GL_GENERATE_FLOAT_H_TRUE@ < $(srcdir)/float.in.h; \
+@GL_GENERATE_FLOAT_H_TRUE@ } > $@-t && \
+@GL_GENERATE_FLOAT_H_TRUE@ mv $@-t $@
+@GL_GENERATE_FLOAT_H_FALSE@float.h: $(top_builddir)/config.status
+@GL_GENERATE_FLOAT_H_FALSE@ rm -f $@
+
+# We need the following in order to create <fnmatch.h>.
+@GL_GENERATE_FNMATCH_H_TRUE@fnmatch.h: fnmatch.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+@GL_GENERATE_FNMATCH_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_FNMATCH_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+@GL_GENERATE_FNMATCH_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e 's|@''HAVE_FNMATCH_H''@|$(HAVE_FNMATCH_H)|g' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e 's|@''NEXT_FNMATCH_H''@|$(NEXT_FNMATCH_H)|g' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e 's/@''GNULIB_FNMATCH''@/$(GNULIB_FNMATCH)/g' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e 's|@''HAVE_FNMATCH''@|$(HAVE_FNMATCH)|g' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e 's|@''REPLACE_FNMATCH''@|$(REPLACE_FNMATCH)|g' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+@GL_GENERATE_FNMATCH_H_TRUE@ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+@GL_GENERATE_FNMATCH_H_TRUE@ < $(srcdir)/fnmatch.in.h; \
+@GL_GENERATE_FNMATCH_H_TRUE@ } > $@-t && \
+@GL_GENERATE_FNMATCH_H_TRUE@ mv $@-t $@
+@GL_GENERATE_FNMATCH_H_FALSE@fnmatch.h: $(top_builddir)/config.status
+@GL_GENERATE_FNMATCH_H_FALSE@ rm -f $@
+
+# We need the following in order to create <getopt.h> when the system
+# doesn't have one that works with the given compiler.
+getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ < $(srcdir)/getopt.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+
+getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
+ < $(srcdir)/getopt-cdefs.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+
+# We need the following in order to create an empty placeholder for
+# <langinfo.h> when the system doesn't have one.
+langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
+ -e 's/@''GNULIB_NL_LANGINFO''@/$(GNULIB_NL_LANGINFO)/g' \
+ -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
+ -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
+ -e 's|@''HAVE_LANGINFO_ALTMON''@|$(HAVE_LANGINFO_ALTMON)|g' \
+ -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
+ -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
+ -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
+ -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/langinfo.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <limits.h> when the system
+# doesn't have one that is compatible with GNU.
+@GL_GENERATE_LIMITS_H_TRUE@limits.h: limits.in.h $(top_builddir)/config.status
+@GL_GENERATE_LIMITS_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_LIMITS_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+@GL_GENERATE_LIMITS_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+@GL_GENERATE_LIMITS_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+@GL_GENERATE_LIMITS_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+@GL_GENERATE_LIMITS_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+@GL_GENERATE_LIMITS_H_TRUE@ -e 's|@''NEXT_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \
+@GL_GENERATE_LIMITS_H_TRUE@ < $(srcdir)/limits.in.h; \
+@GL_GENERATE_LIMITS_H_TRUE@ } > $@-t && \
+@GL_GENERATE_LIMITS_H_TRUE@ mv $@-t $@
+@GL_GENERATE_LIMITS_H_FALSE@limits.h: $(top_builddir)/config.status
+@GL_GENERATE_LIMITS_H_FALSE@ rm -f $@
+
+# We need the following in order to create <locale.h> when the system
+# doesn't have one that provides all definitions.
+locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
+ -e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/g' \
+ -e 's/@''GNULIB_SETLOCALE''@/$(GNULIB_SETLOCALE)/g' \
+ -e 's/@''GNULIB_DUPLOCALE''@/$(GNULIB_DUPLOCALE)/g' \
+ -e 's/@''GNULIB_LOCALENAME''@/$(GNULIB_LOCALENAME)/g' \
+ -e 's|@''HAVE_NEWLOCALE''@|$(HAVE_NEWLOCALE)|g' \
+ -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
+ -e 's|@''HAVE_FREELOCALE''@|$(HAVE_FREELOCALE)|g' \
+ -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
+ -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \
+ -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \
+ -e 's|@''REPLACE_NEWLOCALE''@|$(REPLACE_NEWLOCALE)|g' \
+ -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
+ -e 's|@''REPLACE_FREELOCALE''@|$(REPLACE_FREELOCALE)|g' \
+ -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/locale.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <stdalign.h> when the system
+# doesn't have one that works.
+@GL_GENERATE_STDALIGN_H_TRUE@stdalign.h: stdalign.in.h $(top_builddir)/config.status
+@GL_GENERATE_STDALIGN_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_STDALIGN_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+@GL_GENERATE_STDALIGN_H_TRUE@ cat $(srcdir)/stdalign.in.h; \
+@GL_GENERATE_STDALIGN_H_TRUE@ } > $@-t && \
+@GL_GENERATE_STDALIGN_H_TRUE@ mv $@-t $@
+@GL_GENERATE_STDALIGN_H_FALSE@stdalign.h: $(top_builddir)/config.status
+@GL_GENERATE_STDALIGN_H_FALSE@ rm -f $@
+
+# We need the following in order to create <stdbool.h> when the system
+# doesn't have one that works.
+@GL_GENERATE_STDBOOL_H_TRUE@stdbool.h: stdbool.in.h $(top_builddir)/config.status
+@GL_GENERATE_STDBOOL_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_STDBOOL_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+@GL_GENERATE_STDBOOL_H_TRUE@ sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
+@GL_GENERATE_STDBOOL_H_TRUE@ } > $@-t && \
+@GL_GENERATE_STDBOOL_H_TRUE@ mv $@-t $@
+@GL_GENERATE_STDBOOL_H_FALSE@stdbool.h: $(top_builddir)/config.status
+@GL_GENERATE_STDBOOL_H_FALSE@ rm -f $@
+
+# We need the following in order to create <stddef.h> when the system
+# doesn't have one that works with the given compiler.
+@GL_GENERATE_STDDEF_H_TRUE@stddef.h: stddef.in.h $(top_builddir)/config.status
+@GL_GENERATE_STDDEF_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_STDDEF_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+@GL_GENERATE_STDDEF_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
+@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
+@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
+@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
+@GL_GENERATE_STDDEF_H_TRUE@ < $(srcdir)/stddef.in.h; \
+@GL_GENERATE_STDDEF_H_TRUE@ } > $@-t && \
+@GL_GENERATE_STDDEF_H_TRUE@ mv $@-t $@
+@GL_GENERATE_STDDEF_H_FALSE@stddef.h: $(top_builddir)/config.status
+@GL_GENERATE_STDDEF_H_FALSE@ rm -f $@
+
+# We need the following in order to create <stdint.h> when the system
+# doesn't have one that works with the given compiler.
+@GL_GENERATE_STDINT_H_TRUE@stdint.h: stdint.in.h $(top_builddir)/config.status
+@GL_GENERATE_STDINT_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_STDINT_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+@GL_GENERATE_STDINT_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_C99_STDINT_H''@/$(HAVE_C99_STDINT_H)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
+@GL_GENERATE_STDINT_H_TRUE@ < $(srcdir)/stdint.in.h; \
+@GL_GENERATE_STDINT_H_TRUE@ } > $@-t && \
+@GL_GENERATE_STDINT_H_TRUE@ mv $@-t $@
+@GL_GENERATE_STDINT_H_FALSE@stdint.h: $(top_builddir)/config.status
+@GL_GENERATE_STDINT_H_FALSE@ rm -f $@
+
+# We need the following in order to create <stdio.h> when the system
+# doesn't have one that works with the given compiler.
+stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
+ -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \
+ -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \
+ -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \
+ -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \
+ -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \
+ -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \
+ -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \
+ -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \
+ -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \
+ -e 's/@''GNULIB_FPUTC''@/$(GNULIB_FPUTC)/g' \
+ -e 's/@''GNULIB_FPUTS''@/$(GNULIB_FPUTS)/g' \
+ -e 's/@''GNULIB_FREAD''@/$(GNULIB_FREAD)/g' \
+ -e 's/@''GNULIB_FREOPEN''@/$(GNULIB_FREOPEN)/g' \
+ -e 's/@''GNULIB_FSCANF''@/$(GNULIB_FSCANF)/g' \
+ -e 's/@''GNULIB_FSEEK''@/$(GNULIB_FSEEK)/g' \
+ -e 's/@''GNULIB_FSEEKO''@/$(GNULIB_FSEEKO)/g' \
+ -e 's/@''GNULIB_FTELL''@/$(GNULIB_FTELL)/g' \
+ -e 's/@''GNULIB_FTELLO''@/$(GNULIB_FTELLO)/g' \
+ -e 's/@''GNULIB_FWRITE''@/$(GNULIB_FWRITE)/g' \
+ -e 's/@''GNULIB_GETC''@/$(GNULIB_GETC)/g' \
+ -e 's/@''GNULIB_GETCHAR''@/$(GNULIB_GETCHAR)/g' \
+ -e 's/@''GNULIB_GETDELIM''@/$(GNULIB_GETDELIM)/g' \
+ -e 's/@''GNULIB_GETLINE''@/$(GNULIB_GETLINE)/g' \
+ -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \
+ -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \
+ -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \
+ -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \
+ -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \
+ -e 's/@''GNULIB_PRINTF_POSIX''@/$(GNULIB_PRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_PUTC''@/$(GNULIB_PUTC)/g' \
+ -e 's/@''GNULIB_PUTCHAR''@/$(GNULIB_PUTCHAR)/g' \
+ -e 's/@''GNULIB_PUTS''@/$(GNULIB_PUTS)/g' \
+ -e 's/@''GNULIB_REMOVE''@/$(GNULIB_REMOVE)/g' \
+ -e 's/@''GNULIB_RENAME''@/$(GNULIB_RENAME)/g' \
+ -e 's/@''GNULIB_RENAMEAT''@/$(GNULIB_RENAMEAT)/g' \
+ -e 's/@''GNULIB_SCANF''@/$(GNULIB_SCANF)/g' \
+ -e 's/@''GNULIB_SNPRINTF''@/$(GNULIB_SNPRINTF)/g' \
+ -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GNULIB_SPRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GNULIB_STDIO_H_NONBLOCKING)/g' \
+ -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GNULIB_STDIO_H_SIGPIPE)/g' \
+ -e 's/@''GNULIB_TMPFILE''@/$(GNULIB_TMPFILE)/g' \
+ -e 's/@''GNULIB_VASPRINTF''@/$(GNULIB_VASPRINTF)/g' \
+ -e 's/@''GNULIB_VDPRINTF''@/$(GNULIB_VDPRINTF)/g' \
+ -e 's/@''GNULIB_VFPRINTF''@/$(GNULIB_VFPRINTF)/g' \
+ -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GNULIB_VFPRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_VFSCANF''@/$(GNULIB_VFSCANF)/g' \
+ -e 's/@''GNULIB_VSCANF''@/$(GNULIB_VSCANF)/g' \
+ -e 's/@''GNULIB_VPRINTF''@/$(GNULIB_VPRINTF)/g' \
+ -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GNULIB_VPRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_VSNPRINTF''@/$(GNULIB_VSNPRINTF)/g' \
+ -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GNULIB_VSPRINTF_POSIX)/g' \
+ < $(srcdir)/stdio.in.h | \
+ sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
+ -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \
+ -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \
+ -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
+ -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
+ -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
+ -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
+ -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
+ -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
+ -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
+ -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
+ -e 's|@''HAVE_PCLOSE''@|$(HAVE_PCLOSE)|g' \
+ -e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|g' \
+ -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
+ -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
+ -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
+ -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \
+ -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
+ -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \
+ -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
+ -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
+ -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
+ -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
+ -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
+ -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \
+ -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
+ -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \
+ -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
+ -e 's|@''REPLACE_GETDELIM''@|$(REPLACE_GETDELIM)|g' \
+ -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \
+ -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \
+ -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \
+ -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \
+ -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
+ -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \
+ -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \
+ -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \
+ -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
+ -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
+ -e 's|@''REPLACE_STDIO_READ_FUNCS''@|$(REPLACE_STDIO_READ_FUNCS)|g' \
+ -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
+ -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \
+ -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
+ -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \
+ -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
+ -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
+ -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
+ -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
+ -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <stdlib.h> when the system
+# doesn't have one that works with the given compiler.
+stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
+ $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
+ -e 's/@''GNULIB__EXIT''@/$(GNULIB__EXIT)/g' \
+ -e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \
+ -e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \
+ -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \
+ -e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \
+ -e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \
+ -e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \
+ -e 's/@''GNULIB_MALLOC_POSIX''@/$(GNULIB_MALLOC_POSIX)/g' \
+ -e 's/@''GNULIB_MBTOWC''@/$(GNULIB_MBTOWC)/g' \
+ -e 's/@''GNULIB_MKDTEMP''@/$(GNULIB_MKDTEMP)/g' \
+ -e 's/@''GNULIB_MKOSTEMP''@/$(GNULIB_MKOSTEMP)/g' \
+ -e 's/@''GNULIB_MKOSTEMPS''@/$(GNULIB_MKOSTEMPS)/g' \
+ -e 's/@''GNULIB_MKSTEMP''@/$(GNULIB_MKSTEMP)/g' \
+ -e 's/@''GNULIB_MKSTEMPS''@/$(GNULIB_MKSTEMPS)/g' \
+ -e 's/@''GNULIB_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \
+ -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \
+ -e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \
+ -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \
+ -e 's/@''GNULIB_QSORT_R''@/$(GNULIB_QSORT_R)/g' \
+ -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \
+ -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \
+ -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
+ -e 's/@''GNULIB_REALLOCARRAY''@/$(GNULIB_REALLOCARRAY)/g' \
+ -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \
+ -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \
+ -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \
+ -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \
+ -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \
+ -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \
+ -e 's/@''GNULIB_STRTOULL''@/$(GNULIB_STRTOULL)/g' \
+ -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GNULIB_SYSTEM_POSIX)/g' \
+ -e 's/@''GNULIB_UNLOCKPT''@/$(GNULIB_UNLOCKPT)/g' \
+ -e 's/@''GNULIB_UNSETENV''@/$(GNULIB_UNSETENV)/g' \
+ -e 's/@''GNULIB_WCTOMB''@/$(GNULIB_WCTOMB)/g' \
+ < $(srcdir)/stdlib.in.h | \
+ sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
+ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
+ -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
+ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
+ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
+ -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
+ -e 's|@''HAVE_DECL_INITSTATE''@|$(HAVE_DECL_INITSTATE)|g' \
+ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
+ -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
+ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
+ -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
+ -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
+ -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \
+ -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
+ -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
+ -e 's|@''HAVE_QSORT_R''@|$(HAVE_QSORT_R)|g' \
+ -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \
+ -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
+ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
+ -e 's|@''HAVE_REALLOCARRAY''@|$(HAVE_REALLOCARRAY)|g' \
+ -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
+ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
+ -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
+ -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
+ -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \
+ -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
+ -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
+ -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
+ -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
+ -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
+ -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
+ -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
+ -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
+ -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
+ -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
+ -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
+ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
+ -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
+ -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
+ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
+ -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
+ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
+ -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
+ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
+ -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
+ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
+ -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
+ -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _Noreturn/r $(_NORETURN_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <string.h> when the system
+# doesn't have one that works with the given compiler.
+string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
+ -e 's/@''GNULIB_EXPLICIT_BZERO''@/$(GNULIB_EXPLICIT_BZERO)/g' \
+ -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \
+ -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \
+ -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \
+ -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \
+ -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \
+ -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \
+ -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \
+ -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \
+ -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \
+ -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \
+ -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \
+ -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \
+ -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \
+ -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \
+ -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \
+ -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \
+ -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \
+ -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \
+ -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \
+ -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \
+ -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \
+ -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \
+ -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \
+ -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \
+ -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \
+ -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \
+ -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \
+ -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \
+ -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \
+ -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \
+ -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \
+ -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \
+ -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \
+ -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \
+ -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \
+ -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
+ -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \
+ < $(srcdir)/string.in.h | \
+ sed -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \
+ -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
+ -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
+ -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
+ -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
+ -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
+ -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
+ -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
+ -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
+ -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
+ -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
+ -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
+ -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
+ -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
+ -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
+ -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
+ -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
+ -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
+ -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
+ -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
+ -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
+ -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
+ -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
+ -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
+ -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
+ -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
+ -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
+ -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
+ -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
+ -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
+ -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
+ -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
+ -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
+ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
+ -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
+ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
+ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
+ < $(srcdir)/string.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <strings.h> when the system
+# doesn't have one that works with the given compiler.
+strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
+ -e 's/@''GNULIB_FFS''@/$(GNULIB_FFS)/g' \
+ -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \
+ -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
+ -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/strings.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <sys/stat.h> when the system
+# has one that is incomplete.
+sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_at)$(MKDIR_P) sys
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
+ -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
+ -e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \
+ -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
+ -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \
+ -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
+ -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \
+ -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \
+ -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \
+ -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \
+ -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \
+ -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \
+ -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \
+ -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \
+ -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \
+ -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \
+ -e 's/@''GNULIB_OVERRIDES_STRUCT_STAT''@/$(GNULIB_OVERRIDES_STRUCT_STAT)/g' \
+ -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
+ -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
+ -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
+ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
+ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
+ -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
+ -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
+ -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
+ -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
+ -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
+ -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
+ -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
+ -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
+ -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
+ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
+ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
+ -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
+ -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
+ -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
+ -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/sys_stat.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <sys/types.h> when the system
+# doesn't have one that works with the given compiler.
+sys/types.h: sys_types.in.h $(top_builddir)/config.status
+ $(AM_V_at)$(MKDIR_P) sys
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
+ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
+ -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \
+ < $(srcdir)/sys_types.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <sysexits.h> when the system
+# doesn't have one that works with the given compiler.
+@GL_GENERATE_SYSEXITS_H_TRUE@sysexits.h: sysexits.in.h $(top_builddir)/config.status
+@GL_GENERATE_SYSEXITS_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
+@GL_GENERATE_SYSEXITS_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+@GL_GENERATE_SYSEXITS_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+@GL_GENERATE_SYSEXITS_H_TRUE@ -e 's|@''HAVE_SYSEXITS_H''@|$(HAVE_SYSEXITS_H)|g' \
+@GL_GENERATE_SYSEXITS_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+@GL_GENERATE_SYSEXITS_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+@GL_GENERATE_SYSEXITS_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+@GL_GENERATE_SYSEXITS_H_TRUE@ -e 's|@''NEXT_SYSEXITS_H''@|$(NEXT_SYSEXITS_H)|g' \
+@GL_GENERATE_SYSEXITS_H_TRUE@ < $(srcdir)/sysexits.in.h; \
+@GL_GENERATE_SYSEXITS_H_TRUE@ } > $@-t && \
+@GL_GENERATE_SYSEXITS_H_TRUE@ mv -f $@-t $@
+@GL_GENERATE_SYSEXITS_H_FALSE@sysexits.h: $(top_builddir)/config.status
+@GL_GENERATE_SYSEXITS_H_FALSE@ rm -f $@
+
+# We need the following in order to create <time.h> when the system
+# doesn't have one that works with the given compiler.
+time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
+ -e 's/@''GNULIB_CTIME''@/$(GNULIB_CTIME)/g' \
+ -e 's/@''GNULIB_LOCALTIME''@/$(GNULIB_LOCALTIME)/g' \
+ -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \
+ -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \
+ -e 's/@''GNULIB_STRFTIME''@/$(GNULIB_STRFTIME)/g' \
+ -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
+ -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
+ -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
+ -e 's/@''GNULIB_TIME_RZ''@/$(GNULIB_TIME_RZ)/g' \
+ -e 's/@''GNULIB_TZSET''@/$(GNULIB_TZSET)/g' \
+ -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
+ -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
+ -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
+ -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
+ -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
+ -e 's|@''HAVE_TZSET''@|$(HAVE_TZSET)|g' \
+ -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
+ -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
+ -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
+ -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
+ -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
+ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
+ -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \
+ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+ -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \
+ -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/time.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create an empty placeholder for
+# <unistd.h> when the system doesn't have one.
+unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
+ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
+ -e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \
+ -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \
+ -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \
+ -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \
+ -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \
+ -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \
+ -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \
+ -e 's/@''GNULIB_EUIDACCESS''@/$(GNULIB_EUIDACCESS)/g' \
+ -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \
+ -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \
+ -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \
+ -e 's/@''GNULIB_FDATASYNC''@/$(GNULIB_FDATASYNC)/g' \
+ -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \
+ -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \
+ -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \
+ -e 's/@''GNULIB_GETDOMAINNAME''@/$(GNULIB_GETDOMAINNAME)/g' \
+ -e 's/@''GNULIB_GETDTABLESIZE''@/$(GNULIB_GETDTABLESIZE)/g' \
+ -e 's/@''GNULIB_GETGROUPS''@/$(GNULIB_GETGROUPS)/g' \
+ -e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \
+ -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \
+ -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \
+ -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \
+ -e 's/@''GNULIB_GETPASS''@/$(GNULIB_GETPASS)/g' \
+ -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \
+ -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \
+ -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \
+ -e 's/@''GNULIB_LCHOWN''@/$(GNULIB_LCHOWN)/g' \
+ -e 's/@''GNULIB_LINK''@/$(GNULIB_LINK)/g' \
+ -e 's/@''GNULIB_LINKAT''@/$(GNULIB_LINKAT)/g' \
+ -e 's/@''GNULIB_LSEEK''@/$(GNULIB_LSEEK)/g' \
+ -e 's/@''GNULIB_PIPE''@/$(GNULIB_PIPE)/g' \
+ -e 's/@''GNULIB_PIPE2''@/$(GNULIB_PIPE2)/g' \
+ -e 's/@''GNULIB_PREAD''@/$(GNULIB_PREAD)/g' \
+ -e 's/@''GNULIB_PWRITE''@/$(GNULIB_PWRITE)/g' \
+ -e 's/@''GNULIB_READ''@/$(GNULIB_READ)/g' \
+ -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \
+ -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \
+ -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \
+ -e 's/@''GNULIB_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/g' \
+ -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \
+ -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \
+ -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \
+ -e 's/@''GNULIB_TRUNCATE''@/$(GNULIB_TRUNCATE)/g' \
+ -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \
+ -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \
+ -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \
+ -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' \
+ -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \
+ -e 's/@''GNULIB_UNLINKAT''@/$(GNULIB_UNLINKAT)/g' \
+ -e 's/@''GNULIB_USLEEP''@/$(GNULIB_USLEEP)/g' \
+ -e 's/@''GNULIB_WRITE''@/$(GNULIB_WRITE)/g' \
+ < $(srcdir)/unistd.in.h | \
+ sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
+ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
+ -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
+ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
+ -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
+ -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \
+ -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
+ -e 's|@''HAVE_FDATASYNC''@|$(HAVE_FDATASYNC)|g' \
+ -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
+ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
+ -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
+ -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
+ -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
+ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
+ -e 's|@''HAVE_GETPASS''@|$(HAVE_GETPASS)|g' \
+ -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \
+ -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
+ -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
+ -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
+ -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \
+ -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
+ -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
+ -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \
+ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
+ -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
+ -e 's|@''HAVE_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|g' \
+ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
+ -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
+ -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
+ -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
+ -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
+ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
+ -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
+ -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \
+ -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
+ -e 's|@''HAVE_DECL_GETLOGIN''@|$(HAVE_DECL_GETLOGIN)|g' \
+ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
+ -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
+ -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
+ -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \
+ -e 's|@''HAVE_DECL_TRUNCATE''@|$(HAVE_DECL_TRUNCATE)|g' \
+ -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \
+ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
+ -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
+ | \
+ sed -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
+ -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
+ -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
+ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
+ -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \
+ -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
+ -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
+ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
+ -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
+ -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \
+ -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
+ -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
+ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
+ -e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \
+ -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
+ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
+ -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
+ -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
+ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
+ -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
+ -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
+ -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
+ -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
+ -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \
+ -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
+ -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
+ -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
+ -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
+ -e 's|@''REPLACE_TRUNCATE''@|$(REPLACE_TRUNCATE)|g' \
+ -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
+ -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
+ -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
+ -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
+ -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
+ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
+ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
+ } > $@-t && \
+ mv $@-t $@
+
+unitypes.h: unitypes.in.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/unitypes.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+
+uniwidth.h: uniwidth.in.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/uniwidth.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+
+# We need the following in order to create <wchar.h> when the system
+# version does not work standalone.
+wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
+ -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
+ -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
+ -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
+ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
+ -e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \
+ -e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \
+ -e 's/@''GNULIB_MBSINIT''@/$(GNULIB_MBSINIT)/g' \
+ -e 's/@''GNULIB_MBRTOWC''@/$(GNULIB_MBRTOWC)/g' \
+ -e 's/@''GNULIB_MBRLEN''@/$(GNULIB_MBRLEN)/g' \
+ -e 's/@''GNULIB_MBSRTOWCS''@/$(GNULIB_MBSRTOWCS)/g' \
+ -e 's/@''GNULIB_MBSNRTOWCS''@/$(GNULIB_MBSNRTOWCS)/g' \
+ -e 's/@''GNULIB_WCRTOMB''@/$(GNULIB_WCRTOMB)/g' \
+ -e 's/@''GNULIB_WCSRTOMBS''@/$(GNULIB_WCSRTOMBS)/g' \
+ -e 's/@''GNULIB_WCSNRTOMBS''@/$(GNULIB_WCSNRTOMBS)/g' \
+ -e 's/@''GNULIB_WCWIDTH''@/$(GNULIB_WCWIDTH)/g' \
+ -e 's/@''GNULIB_WMEMCHR''@/$(GNULIB_WMEMCHR)/g' \
+ -e 's/@''GNULIB_WMEMCMP''@/$(GNULIB_WMEMCMP)/g' \
+ -e 's/@''GNULIB_WMEMCPY''@/$(GNULIB_WMEMCPY)/g' \
+ -e 's/@''GNULIB_WMEMMOVE''@/$(GNULIB_WMEMMOVE)/g' \
+ -e 's/@''GNULIB_WMEMSET''@/$(GNULIB_WMEMSET)/g' \
+ -e 's/@''GNULIB_WCSLEN''@/$(GNULIB_WCSLEN)/g' \
+ -e 's/@''GNULIB_WCSNLEN''@/$(GNULIB_WCSNLEN)/g' \
+ -e 's/@''GNULIB_WCSCPY''@/$(GNULIB_WCSCPY)/g' \
+ -e 's/@''GNULIB_WCPCPY''@/$(GNULIB_WCPCPY)/g' \
+ -e 's/@''GNULIB_WCSNCPY''@/$(GNULIB_WCSNCPY)/g' \
+ -e 's/@''GNULIB_WCPNCPY''@/$(GNULIB_WCPNCPY)/g' \
+ -e 's/@''GNULIB_WCSCAT''@/$(GNULIB_WCSCAT)/g' \
+ -e 's/@''GNULIB_WCSNCAT''@/$(GNULIB_WCSNCAT)/g' \
+ -e 's/@''GNULIB_WCSCMP''@/$(GNULIB_WCSCMP)/g' \
+ -e 's/@''GNULIB_WCSNCMP''@/$(GNULIB_WCSNCMP)/g' \
+ -e 's/@''GNULIB_WCSCASECMP''@/$(GNULIB_WCSCASECMP)/g' \
+ -e 's/@''GNULIB_WCSNCASECMP''@/$(GNULIB_WCSNCASECMP)/g' \
+ -e 's/@''GNULIB_WCSCOLL''@/$(GNULIB_WCSCOLL)/g' \
+ -e 's/@''GNULIB_WCSXFRM''@/$(GNULIB_WCSXFRM)/g' \
+ -e 's/@''GNULIB_WCSDUP''@/$(GNULIB_WCSDUP)/g' \
+ -e 's/@''GNULIB_WCSCHR''@/$(GNULIB_WCSCHR)/g' \
+ -e 's/@''GNULIB_WCSRCHR''@/$(GNULIB_WCSRCHR)/g' \
+ -e 's/@''GNULIB_WCSCSPN''@/$(GNULIB_WCSCSPN)/g' \
+ -e 's/@''GNULIB_WCSSPN''@/$(GNULIB_WCSSPN)/g' \
+ -e 's/@''GNULIB_WCSPBRK''@/$(GNULIB_WCSPBRK)/g' \
+ -e 's/@''GNULIB_WCSSTR''@/$(GNULIB_WCSSTR)/g' \
+ -e 's/@''GNULIB_WCSTOK''@/$(GNULIB_WCSTOK)/g' \
+ -e 's/@''GNULIB_WCSWIDTH''@/$(GNULIB_WCSWIDTH)/g' \
+ -e 's/@''GNULIB_WCSFTIME''@/$(GNULIB_WCSFTIME)/g' \
+ < $(srcdir)/wchar.in.h | \
+ sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \
+ -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \
+ -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \
+ -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \
+ -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \
+ -e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \
+ -e 's|@''HAVE_MBSNRTOWCS''@|$(HAVE_MBSNRTOWCS)|g' \
+ -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \
+ -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \
+ -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \
+ -e 's|@''HAVE_WMEMCHR''@|$(HAVE_WMEMCHR)|g' \
+ -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \
+ -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \
+ -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \
+ -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \
+ -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \
+ -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \
+ -e 's|@''HAVE_WCSCPY''@|$(HAVE_WCSCPY)|g' \
+ -e 's|@''HAVE_WCPCPY''@|$(HAVE_WCPCPY)|g' \
+ -e 's|@''HAVE_WCSNCPY''@|$(HAVE_WCSNCPY)|g' \
+ -e 's|@''HAVE_WCPNCPY''@|$(HAVE_WCPNCPY)|g' \
+ -e 's|@''HAVE_WCSCAT''@|$(HAVE_WCSCAT)|g' \
+ -e 's|@''HAVE_WCSNCAT''@|$(HAVE_WCSNCAT)|g' \
+ -e 's|@''HAVE_WCSCMP''@|$(HAVE_WCSCMP)|g' \
+ -e 's|@''HAVE_WCSNCMP''@|$(HAVE_WCSNCMP)|g' \
+ -e 's|@''HAVE_WCSCASECMP''@|$(HAVE_WCSCASECMP)|g' \
+ -e 's|@''HAVE_WCSNCASECMP''@|$(HAVE_WCSNCASECMP)|g' \
+ -e 's|@''HAVE_WCSCOLL''@|$(HAVE_WCSCOLL)|g' \
+ -e 's|@''HAVE_WCSXFRM''@|$(HAVE_WCSXFRM)|g' \
+ -e 's|@''HAVE_WCSDUP''@|$(HAVE_WCSDUP)|g' \
+ -e 's|@''HAVE_WCSCHR''@|$(HAVE_WCSCHR)|g' \
+ -e 's|@''HAVE_WCSRCHR''@|$(HAVE_WCSRCHR)|g' \
+ -e 's|@''HAVE_WCSCSPN''@|$(HAVE_WCSCSPN)|g' \
+ -e 's|@''HAVE_WCSSPN''@|$(HAVE_WCSSPN)|g' \
+ -e 's|@''HAVE_WCSPBRK''@|$(HAVE_WCSPBRK)|g' \
+ -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \
+ -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \
+ -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \
+ -e 's|@''HAVE_WCSFTIME''@|$(HAVE_WCSFTIME)|g' \
+ -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
+ -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
+ | \
+ sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
+ -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
+ -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
+ -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \
+ -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \
+ -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \
+ -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \
+ -e 's|@''REPLACE_MBSNRTOWCS''@|$(REPLACE_MBSNRTOWCS)|g' \
+ -e 's|@''REPLACE_WCRTOMB''@|$(REPLACE_WCRTOMB)|g' \
+ -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
+ -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
+ -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
+ -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
+ -e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
+ } > $@-t && \
+ mv $@-t $@
+
+# We need the following in order to create <wctype.h> when the system
+# doesn't have one that works with the given compiler.
+wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
+ -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
+ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
+ -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \
+ -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \
+ -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \
+ -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \
+ -e 's/@''GNULIB_TOWCTRANS''@/$(GNULIB_TOWCTRANS)/g' \
+ -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \
+ -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
+ -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \
+ -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \
+ -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
+ -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \
+ -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
+ -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/wctype.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
+mostlyclean-local: mostlyclean-generic
+ @for dir in '' $(MOSTLYCLEANDIRS); do \
+ if test -n "$$dir" && test -d $$dir; then \
+ echo "rmdir $$dir"; rmdir $$dir; \
+ fi; \
+ done; \
+ :
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/grub-core/lib/gnulib/_Noreturn.h b/grub-core/lib/gnulib/_Noreturn.h
new file mode 100644
index 0000000..94fdfaf
--- /dev/null
+++ b/grub-core/lib/gnulib/_Noreturn.h
@@ -0,0 +1,14 @@
+#ifndef _Noreturn
+# if 201103 <= (defined __cplusplus ? __cplusplus : 0)
+# define _Noreturn [[noreturn]]
+# elif (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
+ || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))
+ /* _Noreturn works as-is. */
+# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
+# define _Noreturn __attribute__ ((__noreturn__))
+# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
+# define _Noreturn __declspec (noreturn)
+# else
+# define _Noreturn
+# endif
+#endif
diff --git a/grub-core/lib/gnulib/alloca.c b/grub-core/lib/gnulib/alloca.c
new file mode 100644
index 0000000..ee0f018
--- /dev/null
+++ b/grub-core/lib/gnulib/alloca.c
@@ -0,0 +1,478 @@
+/* alloca.c -- allocate automatically reclaimed memory
+ (Mostly) portable public-domain implementation -- D A Gwyn
+
+ This implementation of the PWB library alloca function,
+ which is used to allocate space off the run-time stack so
+ that it is automatically reclaimed upon procedure exit,
+ was inspired by discussions with J. Q. Johnson of Cornell.
+ J.Otto Tennant <jot@cray.com> contributed the Cray support.
+
+ There are some preprocessor constants that can
+ be defined when compiling for your specific system, for
+ improved efficiency; however, the defaults should be okay.
+
+ The general concept of this implementation is to keep
+ track of all alloca-allocated blocks, and reclaim any
+ that are found to be deeper in the stack than the current
+ invocation. This heuristic does not reclaim storage as
+ soon as it becomes invalid, but it will do so eventually.
+
+ As a special case, alloca(0) reclaims storage without
+ allocating any. It is a good idea to use alloca(0) in
+ your main control loop, etc. to force garbage collection. */
+
+#include <config.h>
+
+#include <alloca.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#ifdef emacs
+# include "lisp.h"
+# include "blockinput.h"
+# ifdef EMACS_FREE
+# undef free
+# define free EMACS_FREE
+# endif
+#else
+# define memory_full() abort ()
+#endif
+
+/* If compiling with GCC 2, this file's not needed. */
+#if !defined (__GNUC__) || __GNUC__ < 2
+
+/* If someone has defined alloca as a macro,
+ there must be some other way alloca is supposed to work. */
+# ifndef alloca
+
+# ifdef emacs
+# ifdef static
+/* actually, only want this if static is defined as ""
+ -- this is for usg, in which emacs must undefine static
+ in order to make unexec workable
+ */
+# ifndef STACK_DIRECTION
+you
+lose
+-- must know STACK_DIRECTION at compile-time
+/* Using #error here is not wise since this file should work for
+ old and obscure compilers. */
+# endif /* STACK_DIRECTION undefined */
+# endif /* static */
+# endif /* emacs */
+
+/* If your stack is a linked list of frames, you have to
+ provide an "address metric" ADDRESS_FUNCTION macro. */
+
+# if defined (CRAY) && defined (CRAY_STACKSEG_END)
+long i00afunc ();
+# define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
+# else
+# define ADDRESS_FUNCTION(arg) &(arg)
+# endif
+
+/* Define STACK_DIRECTION if you know the direction of stack
+ growth for your system; otherwise it will be automatically
+ deduced at run-time.
+
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+
+# ifndef STACK_DIRECTION
+# define STACK_DIRECTION 0 /* Direction unknown. */
+# endif
+
+# if STACK_DIRECTION != 0
+
+# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
+
+# else /* STACK_DIRECTION == 0; need run-time code. */
+
+static int stack_dir; /* 1 or -1 once known. */
+# define STACK_DIR stack_dir
+
+static int
+find_stack_direction (int *addr, int depth)
+{
+ int dir, dummy = 0;
+ if (! addr)
+ addr = &dummy;
+ *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
+ dir = depth ? find_stack_direction (addr, depth - 1) : 0;
+ return dir + dummy;
+}
+
+# endif /* STACK_DIRECTION == 0 */
+
+/* An "alloca header" is used to:
+ (a) chain together all alloca'ed blocks;
+ (b) keep track of stack depth.
+
+ It is very important that sizeof(header) agree with malloc
+ alignment chunk size. The following default should work okay. */
+
+# ifndef ALIGN_SIZE
+# define ALIGN_SIZE sizeof(double)
+# endif
+
+typedef union hdr
+{
+ char align[ALIGN_SIZE]; /* To force sizeof(header). */
+ struct
+ {
+ union hdr *next; /* For chaining headers. */
+ char *deep; /* For stack depth measure. */
+ } h;
+} header;
+
+static header *last_alloca_header = NULL; /* -> last alloca header. */
+
+/* Return a pointer to at least SIZE bytes of storage,
+ which will be automatically reclaimed upon exit from
+ the procedure that called alloca. Originally, this space
+ was supposed to be taken from the current stack frame of the
+ caller, but that method cannot be made to work for some
+ implementations of C, for example under Gould's UTX/32. */
+
+void *
+alloca (size_t size)
+{
+ auto char probe; /* Probes stack depth: */
+ register char *depth = ADDRESS_FUNCTION (probe);
+
+# if STACK_DIRECTION == 0
+ if (STACK_DIR == 0) /* Unknown growth direction. */
+ STACK_DIR = find_stack_direction (NULL, (size & 1) + 20);
+# endif
+
+ /* Reclaim garbage, defined as all alloca'd storage that
+ was allocated from deeper in the stack than currently. */
+
+ {
+ register header *hp; /* Traverses linked list. */
+
+# ifdef emacs
+ BLOCK_INPUT;
+# endif
+
+ for (hp = last_alloca_header; hp != NULL;)
+ if ((STACK_DIR > 0 && hp->h.deep > depth)
+ || (STACK_DIR < 0 && hp->h.deep < depth))
+ {
+ register header *np = hp->h.next;
+
+ free (hp); /* Collect garbage. */
+
+ hp = np; /* -> next header. */
+ }
+ else
+ break; /* Rest are not deeper. */
+
+ last_alloca_header = hp; /* -> last valid storage. */
+
+# ifdef emacs
+ UNBLOCK_INPUT;
+# endif
+ }
+
+ if (size == 0)
+ return NULL; /* No allocation required. */
+
+ /* Allocate combined header + user data storage. */
+
+ {
+ /* Address of header. */
+ register header *new;
+
+ size_t combined_size = sizeof (header) + size;
+ if (combined_size < sizeof (header))
+ memory_full ();
+
+ new = malloc (combined_size);
+
+ if (! new)
+ memory_full ();
+
+ new->h.next = last_alloca_header;
+ new->h.deep = depth;
+
+ last_alloca_header = new;
+
+ /* User storage begins just after header. */
+
+ return (void *) (new + 1);
+ }
+}
+
+# if defined (CRAY) && defined (CRAY_STACKSEG_END)
+
+# ifdef DEBUG_I00AFUNC
+# include <stdio.h>
+# endif
+
+# ifndef CRAY_STACK
+# define CRAY_STACK
+# ifndef CRAY2
+/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
+struct stack_control_header
+ {
+ long shgrow:32; /* Number of times stack has grown. */
+ long shaseg:32; /* Size of increments to stack. */
+ long shhwm:32; /* High water mark of stack. */
+ long shsize:32; /* Current size of stack (all segments). */
+ };
+
+/* The stack segment linkage control information occurs at
+ the high-address end of a stack segment. (The stack
+ grows from low addresses to high addresses.) The initial
+ part of the stack segment linkage control information is
+ 0200 (octal) words. This provides for register storage
+ for the routine which overflows the stack. */
+
+struct stack_segment_linkage
+ {
+ long ss[0200]; /* 0200 overflow words. */
+ long sssize:32; /* Number of words in this segment. */
+ long ssbase:32; /* Offset to stack base. */
+ long:32;
+ long sspseg:32; /* Offset to linkage control of previous
+ segment of stack. */
+ long:32;
+ long sstcpt:32; /* Pointer to task common address block. */
+ long sscsnm; /* Private control structure number for
+ microtasking. */
+ long ssusr1; /* Reserved for user. */
+ long ssusr2; /* Reserved for user. */
+ long sstpid; /* Process ID for pid based multi-tasking. */
+ long ssgvup; /* Pointer to multitasking thread giveup. */
+ long sscray[7]; /* Reserved for Cray Research. */
+ long ssa0;
+ long ssa1;
+ long ssa2;
+ long ssa3;
+ long ssa4;
+ long ssa5;
+ long ssa6;
+ long ssa7;
+ long sss0;
+ long sss1;
+ long sss2;
+ long sss3;
+ long sss4;
+ long sss5;
+ long sss6;
+ long sss7;
+ };
+
+# else /* CRAY2 */
+/* The following structure defines the vector of words
+ returned by the STKSTAT library routine. */
+struct stk_stat
+ {
+ long now; /* Current total stack size. */
+ long maxc; /* Amount of contiguous space which would
+ be required to satisfy the maximum
+ stack demand to date. */
+ long high_water; /* Stack high-water mark. */
+ long overflows; /* Number of stack overflow ($STKOFEN) calls. */
+ long hits; /* Number of internal buffer hits. */
+ long extends; /* Number of block extensions. */
+ long stko_mallocs; /* Block allocations by $STKOFEN. */
+ long underflows; /* Number of stack underflow calls ($STKRETN). */
+ long stko_free; /* Number of deallocations by $STKRETN. */
+ long stkm_free; /* Number of deallocations by $STKMRET. */
+ long segments; /* Current number of stack segments. */
+ long maxs; /* Maximum number of stack segments so far. */
+ long pad_size; /* Stack pad size. */
+ long current_address; /* Current stack segment address. */
+ long current_size; /* Current stack segment size. This
+ number is actually corrupted by STKSTAT to
+ include the fifteen word trailer area. */
+ long initial_address; /* Address of initial segment. */
+ long initial_size; /* Size of initial segment. */
+ };
+
+/* The following structure describes the data structure which trails
+ any stack segment. I think that the description in 'asdef' is
+ out of date. I only describe the parts that I am sure about. */
+
+struct stk_trailer
+ {
+ long this_address; /* Address of this block. */
+ long this_size; /* Size of this block (does not include
+ this trailer). */
+ long unknown2;
+ long unknown3;
+ long link; /* Address of trailer block of previous
+ segment. */
+ long unknown5;
+ long unknown6;
+ long unknown7;
+ long unknown8;
+ long unknown9;
+ long unknown10;
+ long unknown11;
+ long unknown12;
+ long unknown13;
+ long unknown14;
+ };
+
+# endif /* CRAY2 */
+# endif /* not CRAY_STACK */
+
+# ifdef CRAY2
+/* Determine a "stack measure" for an arbitrary ADDRESS.
+ I doubt that "lint" will like this much. */
+
+static long
+i00afunc (long *address)
+{
+ struct stk_stat status;
+ struct stk_trailer *trailer;
+ long *block, size;
+ long result = 0;
+
+ /* We want to iterate through all of the segments. The first
+ step is to get the stack status structure. We could do this
+ more quickly and more directly, perhaps, by referencing the
+ $LM00 common block, but I know that this works. */
+
+ STKSTAT (&status);
+
+ /* Set up the iteration. */
+
+ trailer = (struct stk_trailer *) (status.current_address
+ + status.current_size
+ - 15);
+
+ /* There must be at least one stack segment. Therefore it is
+ a fatal error if "trailer" is null. */
+
+ if (trailer == 0)
+ abort ();
+
+ /* Discard segments that do not contain our argument address. */
+
+ while (trailer != 0)
+ {
+ block = (long *) trailer->this_address;
+ size = trailer->this_size;
+ if (block == 0 || size == 0)
+ abort ();
+ trailer = (struct stk_trailer *) trailer->link;
+ if ((block <= address) && (address < (block + size)))
+ break;
+ }
+
+ /* Set the result to the offset in this segment and add the sizes
+ of all predecessor segments. */
+
+ result = address - block;
+
+ if (trailer == 0)
+ {
+ return result;
+ }
+
+ do
+ {
+ if (trailer->this_size <= 0)
+ abort ();
+ result += trailer->this_size;
+ trailer = (struct stk_trailer *) trailer->link;
+ }
+ while (trailer != 0);
+
+ /* We are done. Note that if you present a bogus address (one
+ not in any segment), you will get a different number back, formed
+ from subtracting the address of the first block. This is probably
+ not what you want. */
+
+ return (result);
+}
+
+# else /* not CRAY2 */
+/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
+ Determine the number of the cell within the stack,
+ given the address of the cell. The purpose of this
+ routine is to linearize, in some sense, stack addresses
+ for alloca. */
+
+static long
+i00afunc (long address)
+{
+ long stkl = 0;
+
+ long size, pseg, this_segment, stack;
+ long result = 0;
+
+ struct stack_segment_linkage *ssptr;
+
+ /* Register B67 contains the address of the end of the
+ current stack segment. If you (as a subprogram) store
+ your registers on the stack and find that you are past
+ the contents of B67, you have overflowed the segment.
+
+ B67 also points to the stack segment linkage control
+ area, which is what we are really interested in. */
+
+ stkl = CRAY_STACKSEG_END ();
+ ssptr = (struct stack_segment_linkage *) stkl;
+
+ /* If one subtracts 'size' from the end of the segment,
+ one has the address of the first word of the segment.
+
+ If this is not the first segment, 'pseg' will be
+ nonzero. */
+
+ pseg = ssptr->sspseg;
+ size = ssptr->sssize;
+
+ this_segment = stkl - size;
+
+ /* It is possible that calling this routine itself caused
+ a stack overflow. Discard stack segments which do not
+ contain the target address. */
+
+ while (!(this_segment <= address && address <= stkl))
+ {
+# ifdef DEBUG_I00AFUNC
+ fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
+# endif
+ if (pseg == 0)
+ break;
+ stkl = stkl - pseg;
+ ssptr = (struct stack_segment_linkage *) stkl;
+ size = ssptr->sssize;
+ pseg = ssptr->sspseg;
+ this_segment = stkl - size;
+ }
+
+ result = address - this_segment;
+
+ /* If you subtract pseg from the current end of the stack,
+ you get the address of the previous stack segment's end.
+ This seems a little convoluted to me, but I'll bet you save
+ a cycle somewhere. */
+
+ while (pseg != 0)
+ {
+# ifdef DEBUG_I00AFUNC
+ fprintf (stderr, "%011o %011o\n", pseg, size);
+# endif
+ stkl = stkl - pseg;
+ ssptr = (struct stack_segment_linkage *) stkl;
+ size = ssptr->sssize;
+ pseg = ssptr->sspseg;
+ result += size;
+ }
+ return (result);
+}
+
+# endif /* not CRAY2 */
+# endif /* CRAY */
+
+# endif /* no alloca */
+#endif /* not GCC 2 */
diff --git a/grub-core/lib/gnulib/alloca.in.h b/grub-core/lib/gnulib/alloca.in.h
new file mode 100644
index 0000000..ec81e11
--- /dev/null
+++ b/grub-core/lib/gnulib/alloca.in.h
@@ -0,0 +1,65 @@
+/* Memory allocation on the stack.
+
+ Copyright (C) 1995, 1999, 2001-2004, 2006-2019 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, 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
+ <https://www.gnu.org/licenses/>.
+ */
+
+/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
+ means there is a real alloca function. */
+#ifndef _GL_ALLOCA_H
+#define _GL_ALLOCA_H
+
+/* alloca (N) returns a pointer to N bytes of memory
+ allocated on the stack, which will last until the function returns.
+ Use of alloca should be avoided:
+ - inside arguments of function calls - undefined behaviour,
+ - in inline functions - the allocation may actually last until the
+ calling function returns,
+ - for huge N (say, N >= 65536) - you never know how large (or small)
+ the stack is, and when the stack cannot fulfill the memory allocation
+ request, the program just crashes.
+ */
+
+#ifndef alloca
+# ifdef __GNUC__
+# define alloca __builtin_alloca
+# elif defined _AIX
+# define alloca __alloca
+# elif defined _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
+# elif defined __DECC && defined __VMS
+# define alloca __ALLOCA
+# elif defined __TANDEM && defined _TNS_E_TARGET
+# ifdef __cplusplus
+extern "C"
+# endif
+void *_alloca (unsigned short);
+# pragma intrinsic (_alloca)
+# define alloca _alloca
+# elif defined __MVS__
+# include <stdlib.h>
+# else
+# include <stddef.h>
+# ifdef __cplusplus
+extern "C"
+# endif
+void *alloca (size_t);
+# endif
+#endif
+
+#endif /* _GL_ALLOCA_H */
diff --git a/grub-core/lib/gnulib/arg-nonnull.h b/grub-core/lib/gnulib/arg-nonnull.h
new file mode 100644
index 0000000..ad8c26c
--- /dev/null
+++ b/grub-core/lib/gnulib/arg-nonnull.h
@@ -0,0 +1,26 @@
+/* A C macro for declaring that specific arguments must not be NULL.
+ Copyright (C) 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
+ that the values passed as arguments n, ..., m must be non-NULL pointers.
+ n = 1 stands for the first argument, n = 2 for the second argument etc. */
+#ifndef _GL_ARG_NONNULL
+# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
+# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
+# else
+# define _GL_ARG_NONNULL(params)
+# endif
+#endif
diff --git a/grub-core/lib/gnulib/argp-ba.c b/grub-core/lib/gnulib/argp-ba.c
new file mode 100644
index 0000000..fcf60c8
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-ba.c
@@ -0,0 +1,34 @@
+/* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
+ Copyright (C) 1996-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+/* If set by the user program, it should point to string that is the
+ bug-reporting address for the program. It will be printed by argp_help if
+ the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
+ messages), embedded in a sentence that says something like "Report bugs to
+ ADDR." */
+const char *argp_program_bug_address
+/* This variable should be zero-initialized. On most systems, putting it into
+ BSS is sufficient. Not so on Mac OS X 10.3 and 10.4, see
+ <https://lists.gnu.org/r/bug-gnulib/2009-01/msg00329.html>
+ <https://lists.gnu.org/r/bug-gnulib/2009-08/msg00096.html>. */
+#if defined __ELF__
+ /* On ELF systems, variables in BSS behave well. */
+#else
+ = (const char *) 0
+#endif
+ ;
diff --git a/grub-core/lib/gnulib/argp-eexst.c b/grub-core/lib/gnulib/argp-eexst.c
new file mode 100644
index 0000000..06b025d
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-eexst.c
@@ -0,0 +1,30 @@
+/* Default definition for ARGP_ERR_EXIT_STATUS
+ Copyright (C) 1997, 2009-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sysexits.h>
+
+#include "argp.h"
+
+/* The exit status that argp will use when exiting due to a parsing error.
+ If not defined or set by the user program, this defaults to EX_USAGE from
+ <sysexits.h>. */
+error_t argp_err_exit_status = EX_USAGE;
diff --git a/grub-core/lib/gnulib/argp-fmtstream.c b/grub-core/lib/gnulib/argp-fmtstream.c
new file mode 100644
index 0000000..d0685b3
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-fmtstream.c
@@ -0,0 +1,488 @@
+/* Word-wrapping and line-truncating streams
+ Copyright (C) 1997-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+/* This package emulates glibc 'line_wrap_stream' semantics for systems that
+ don't have that. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <wchar.h>
+
+#include "argp-fmtstream.h"
+#include "argp-namefrob.h"
+#include "mbswidth.h"
+
+#ifndef ARGP_FMTSTREAM_USE_LINEWRAP
+
+#ifndef isblank
+#define isblank(ch) ((ch)==' ' || (ch)=='\t')
+#endif
+
+#ifdef _LIBC
+# include <wchar.h>
+# include <libio/libioP.h>
+# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
+#endif
+
+#define INIT_BUF_SIZE 200
+#define PRINTF_SIZE_GUESS 150
+
+/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
+ written on it with LMARGIN spaces and limits them to RMARGIN columns
+ total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
+ replacing the whitespace before them with a newline and WMARGIN spaces.
+ Otherwise, chars beyond RMARGIN are simply dropped until a newline.
+ Returns NULL if there was an error. */
+argp_fmtstream_t
+__argp_make_fmtstream (FILE *stream,
+ size_t lmargin, size_t rmargin, ssize_t wmargin)
+{
+ argp_fmtstream_t fs;
+
+ fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
+ if (fs != NULL)
+ {
+ fs->stream = stream;
+
+ fs->lmargin = lmargin;
+ fs->rmargin = rmargin;
+ fs->wmargin = wmargin;
+ fs->point_col = 0;
+ fs->point_offs = 0;
+
+ fs->buf = (char *) malloc (INIT_BUF_SIZE);
+ if (! fs->buf)
+ {
+ free (fs);
+ fs = 0;
+ }
+ else
+ {
+ fs->p = fs->buf;
+ fs->end = fs->buf + INIT_BUF_SIZE;
+ }
+ }
+
+ return fs;
+}
+#if 0
+/* Not exported. */
+#ifdef weak_alias
+weak_alias (__argp_make_fmtstream, argp_make_fmtstream)
+#endif
+#endif
+
+/* Flush FS to its stream, and free it (but don't close the stream). */
+void
+__argp_fmtstream_free (argp_fmtstream_t fs)
+{
+ __argp_fmtstream_update (fs);
+ if (fs->p > fs->buf)
+ {
+#ifdef _LIBC
+ __fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
+#else
+ fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
+#endif
+ }
+ free (fs->buf);
+ free (fs);
+}
+#if 0
+/* Not exported. */
+#ifdef weak_alias
+weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
+#endif
+#endif
+
+
+/* Return the pointer to the first character that doesn't fit in l columns. */
+static inline const ptrdiff_t
+add_width (const char *ptr, const char *end, size_t l)
+{
+ mbstate_t ps;
+ const char *ptr0 = ptr;
+
+ memset (&ps, 0, sizeof (ps));
+
+ while (ptr < end)
+ {
+ wchar_t wc;
+ size_t s, k;
+
+ s = mbrtowc (&wc, ptr, end - ptr, &ps);
+ if (s == (size_t) -1)
+ break;
+ if (s == (size_t) -2)
+ {
+ if (1 >= l)
+ break;
+ l--;
+ ptr++;
+ continue;
+ }
+
+ if (wc == '\e' && ptr + 3 < end
+ && ptr[1] == '[' && (ptr[2] == '0' || ptr[2] == '1')
+ && ptr[3] == 'm')
+ {
+ ptr += 4;
+ continue;
+ }
+
+ k = wcwidth (wc);
+
+ if (k >= l)
+ break;
+ l -= k;
+ ptr += s;
+ }
+ return ptr - ptr0;
+}
+
+/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
+ end of its buffer. This code is mostly from glibc stdio/linewrap.c. */
+void
+__argp_fmtstream_update (argp_fmtstream_t fs)
+{
+ char *buf, *nl;
+ size_t len;
+
+ /* Scan the buffer for newlines. */
+ buf = fs->buf + fs->point_offs;
+ while (buf < fs->p)
+ {
+ size_t r;
+
+ if (fs->point_col == 0 && fs->lmargin != 0)
+ {
+ /* We are starting a new line. Print spaces to the left margin. */
+ const size_t pad = fs->lmargin;
+ if (fs->p + pad < fs->end)
+ {
+ /* We can fit in them in the buffer by moving the
+ buffer text up and filling in the beginning. */
+ memmove (buf + pad, buf, fs->p - buf);
+ fs->p += pad; /* Compensate for bigger buffer. */
+ memset (buf, ' ', pad); /* Fill in the spaces. */
+ buf += pad; /* Don't bother searching them. */
+ }
+ else
+ {
+ /* No buffer space for spaces. Must flush. */
+ size_t i;
+ for (i = 0; i < pad; i++)
+ {
+#ifdef _LIBC
+ if (_IO_fwide (fs->stream, 0) > 0)
+ putwc_unlocked (L' ', fs->stream);
+ else
+#endif
+ putc_unlocked (' ', fs->stream);
+ }
+ }
+ fs->point_col = pad;
+ }
+
+ len = fs->p - buf;
+ nl = memchr (buf, '\n', len);
+
+ if (fs->point_col < 0)
+ fs->point_col = 0;
+
+ if (!nl)
+ {
+ /* The buffer ends in a partial line. */
+ size_t display_width = mbsnwidth (buf, fs->p - buf,
+ MBSW_STOP_AT_NUL);
+
+ if (fs->point_col + display_width < fs->rmargin)
+ {
+ /* The remaining buffer text is a partial line and fits
+ within the maximum line width. Advance point for the
+ characters to be written and stop scanning. */
+ fs->point_col += display_width;
+ break;
+ }
+ else
+ /* Set the end-of-line pointer for the code below to
+ the end of the buffer. */
+ nl = fs->p;
+ }
+ else
+ {
+ size_t display_width = mbsnwidth (buf, nl - buf, MBSW_STOP_AT_NUL);
+ if (display_width < (ssize_t) fs->rmargin)
+ {
+ /* The buffer contains a full line that fits within the maximum
+ line width. Reset point and scan the next line. */
+ fs->point_col = 0;
+ buf = nl + 1;
+ continue;
+ }
+ }
+
+ /* This line is too long. */
+ r = fs->rmargin - 1;
+
+ if (fs->wmargin < 0)
+ {
+ /* Truncate the line by overwriting the excess with the
+ newline and anything after it in the buffer. */
+ if (nl < fs->p)
+ {
+ memmove (buf + (r - fs->point_col), nl, fs->p - nl);
+ fs->p -= buf + (r - fs->point_col) - nl;
+ /* Reset point for the next line and start scanning it. */
+ fs->point_col = 0;
+ buf += r + 1; /* Skip full line plus \n. */
+ }
+ else
+ {
+ /* The buffer ends with a partial line that is beyond the
+ maximum line width. Advance point for the characters
+ written, and discard those past the max from the buffer. */
+ fs->point_col += len;
+ fs->p -= fs->point_col - r;
+ break;
+ }
+ }
+ else
+ {
+ /* Do word wrap. Go to the column just past the maximum line
+ width and scan back for the beginning of the word there.
+ Then insert a line break. */
+
+ char *p, *nextline;
+ int i;
+
+ p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col));
+ while (p >= buf && !isblank ((unsigned char) *p))
+ --p;
+ nextline = p + 1; /* This will begin the next line. */
+
+ if (nextline > buf)
+ {
+ /* Swallow separating blanks. */
+ if (p >= buf)
+ do
+ --p;
+ while (p >= buf && isblank ((unsigned char) *p));
+ nl = p + 1; /* The newline will replace the first blank. */
+ }
+ else
+ {
+ /* A single word that is greater than the maximum line width.
+ Oh well. Put it on an overlong line by itself. */
+ p = buf + add_width (buf, fs->p, (r + 1 - fs->point_col));
+ /* Find the end of the long word. */
+ if (p < nl)
+ do
+ ++p;
+ while (p < nl && !isblank ((unsigned char) *p));
+ if (p == nl)
+ {
+ /* It already ends a line. No fussing required. */
+ fs->point_col = 0;
+ buf = nl + 1;
+ continue;
+ }
+ /* We will move the newline to replace the first blank. */
+ nl = p;
+ /* Swallow separating blanks. */
+ do
+ ++p;
+ while (isblank ((unsigned char) *p));
+ /* The next line will start here. */
+ nextline = p;
+ }
+
+ /* Note: There are a bunch of tests below for
+ NEXTLINE == BUF + LEN + 1; this case is where NL happens to fall
+ at the end of the buffer, and NEXTLINE is in fact empty (and so
+ we need not be careful to maintain its contents). */
+
+ if ((nextline == buf + len + 1
+ ? fs->end - nl < fs->wmargin + 1
+ : nextline - (nl + 1) < fs->wmargin)
+ && fs->p > nextline)
+ {
+ /* The margin needs more blanks than we removed. */
+ if (mbsnwidth (fs->p, fs->end - fs->p, MBSW_STOP_AT_NUL)
+ > fs->wmargin + 1)
+ /* Make some space for them. */
+ {
+ size_t mv = fs->p - nextline;
+ memmove (nl + 1 + fs->wmargin, nextline, mv);
+ nextline = nl + 1 + fs->wmargin;
+ len = nextline + mv - buf;
+ *nl++ = '\n';
+ }
+ else
+ /* Output the first line so we can use the space. */
+ {
+#ifdef _LIBC
+ __fxprintf (fs->stream, "%.*s\n",
+ (int) (nl - fs->buf), fs->buf);
+#else
+ if (nl > fs->buf)
+ fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
+ putc_unlocked ('\n', fs->stream);
+#endif
+
+ len += buf - fs->buf;
+ nl = buf = fs->buf;
+ }
+ }
+ else
+ /* We can fit the newline and blanks in before
+ the next word. */
+ *nl++ = '\n';
+
+ if (nextline - nl >= fs->wmargin
+ || (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin))
+ /* Add blanks up to the wrap margin column. */
+ for (i = 0; i < fs->wmargin; ++i)
+ *nl++ = ' ';
+ else
+ for (i = 0; i < fs->wmargin; ++i)
+#ifdef _LIBC
+ if (_IO_fwide (fs->stream, 0) > 0)
+ putwc_unlocked (L' ', fs->stream);
+ else
+#endif
+ putc_unlocked (' ', fs->stream);
+
+ /* Copy the tail of the original buffer into the current buffer
+ position. */
+ if (nl < nextline)
+ memmove (nl, nextline, buf + len - nextline);
+ len -= nextline - buf;
+
+ /* Continue the scan on the remaining lines in the buffer. */
+ buf = nl;
+
+ /* Restore bufp to include all the remaining text. */
+ fs->p = nl + len;
+
+ /* Reset the counter of what has been output this line. If wmargin
+ is 0, we want to avoid the lmargin getting added, so we set
+ point_col to a magic value of -1 in that case. */
+ fs->point_col = fs->wmargin ? fs->wmargin : -1;
+ }
+ }
+
+ /* Remember that we've scanned as far as the end of the buffer. */
+ fs->point_offs = fs->p - fs->buf;
+}
+
+/* Ensure that FS has space for AMOUNT more bytes in its buffer, either by
+ growing the buffer, or by flushing it. True is returned iff we succeed. */
+int
+__argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
+{
+ if ((size_t) (fs->end - fs->p) < amount)
+ {
+ ssize_t wrote;
+
+ /* Flush FS's buffer. */
+ __argp_fmtstream_update (fs);
+
+#ifdef _LIBC
+ __fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
+ wrote = fs->p - fs->buf;
+#else
+ wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
+#endif
+ if (wrote == fs->p - fs->buf)
+ {
+ fs->p = fs->buf;
+ fs->point_offs = 0;
+ }
+ else
+ {
+ fs->p -= wrote;
+ fs->point_offs -= wrote;
+ memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf);
+ return 0;
+ }
+
+ if ((size_t) (fs->end - fs->buf) < amount)
+ /* Gotta grow the buffer. */
+ {
+ size_t old_size = fs->end - fs->buf;
+ size_t new_size = old_size + amount;
+ char *new_buf;
+
+ if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size)))
+ {
+ __set_errno (ENOMEM);
+ return 0;
+ }
+
+ fs->buf = new_buf;
+ fs->end = new_buf + new_size;
+ fs->p = fs->buf;
+ }
+ }
+
+ return 1;
+}
+
+ssize_t
+__argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
+{
+ int out;
+ size_t avail;
+ size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */
+
+ do
+ {
+ va_list args;
+
+ if (! __argp_fmtstream_ensure (fs, size_guess))
+ return -1;
+
+ va_start (args, fmt);
+ avail = fs->end - fs->p;
+ out = __vsnprintf (fs->p, avail, fmt, args);
+ va_end (args);
+ if ((size_t) out >= avail)
+ size_guess = out + 1;
+ }
+ while ((size_t) out >= avail);
+
+ fs->p += out;
+
+ return out;
+}
+#if 0
+/* Not exported. */
+#ifdef weak_alias
+weak_alias (__argp_fmtstream_printf, argp_fmtstream_printf)
+#endif
+#endif
+
+#endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */
diff --git a/grub-core/lib/gnulib/argp-fmtstream.h b/grub-core/lib/gnulib/argp-fmtstream.h
new file mode 100644
index 0000000..0cc8852
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-fmtstream.h
@@ -0,0 +1,310 @@
+/* Word-wrapping and line-truncating streams.
+ Copyright (C) 1997-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+/* This package emulates glibc 'line_wrap_stream' semantics for systems that
+ don't have that. If the system does have it, it is just a wrapper for
+ that. This header file is only used internally while compiling argp, and
+ shouldn't be installed. */
+
+#ifndef _ARGP_FMTSTREAM_H
+#define _ARGP_FMTSTREAM_H
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The __-protected variants of the attributes 'format' and 'printf' are
+ accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+ We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
+ gnulib and libintl do '#define printf __printf__' when they override
+ the 'printf' function. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
+#endif
+
+#if defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)
+/* line_wrap_stream is available, so use that. */
+#define ARGP_FMTSTREAM_USE_LINEWRAP
+#endif
+
+#ifdef ARGP_FMTSTREAM_USE_LINEWRAP
+/* Just be a simple wrapper for line_wrap_stream; the semantics are
+ *slightly* different, as line_wrap_stream doesn't actually make a new
+ object, it just modifies the given stream (reversibly) to do
+ line-wrapping. Since we control who uses this code, it doesn't matter. */
+
+#include <linewrap.h>
+
+typedef FILE *argp_fmtstream_t;
+
+#define argp_make_fmtstream line_wrap_stream
+#define __argp_make_fmtstream line_wrap_stream
+#define argp_fmtstream_free line_unwrap_stream
+#define __argp_fmtstream_free line_unwrap_stream
+
+#define __argp_fmtstream_putc(fs,ch) putc(ch,fs)
+#define argp_fmtstream_putc(fs,ch) putc(ch,fs)
+#define __argp_fmtstream_puts(fs,str) fputs(str,fs)
+#define argp_fmtstream_puts(fs,str) fputs(str,fs)
+#define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
+#define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
+#define __argp_fmtstream_printf fprintf
+#define argp_fmtstream_printf fprintf
+
+#define __argp_fmtstream_lmargin line_wrap_lmargin
+#define argp_fmtstream_lmargin line_wrap_lmargin
+#define __argp_fmtstream_set_lmargin line_wrap_set_lmargin
+#define argp_fmtstream_set_lmargin line_wrap_set_lmargin
+#define __argp_fmtstream_rmargin line_wrap_rmargin
+#define argp_fmtstream_rmargin line_wrap_rmargin
+#define __argp_fmtstream_set_rmargin line_wrap_set_rmargin
+#define argp_fmtstream_set_rmargin line_wrap_set_rmargin
+#define __argp_fmtstream_wmargin line_wrap_wmargin
+#define argp_fmtstream_wmargin line_wrap_wmargin
+#define __argp_fmtstream_set_wmargin line_wrap_set_wmargin
+#define argp_fmtstream_set_wmargin line_wrap_set_wmargin
+#define __argp_fmtstream_point line_wrap_point
+#define argp_fmtstream_point line_wrap_point
+
+#else /* !ARGP_FMTSTREAM_USE_LINEWRAP */
+/* Guess we have to define our own version. */
+
+
+struct argp_fmtstream
+{
+ FILE *stream; /* The stream we're outputting to. */
+
+ size_t lmargin, rmargin; /* Left and right margins. */
+ ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */
+
+ /* Point in buffer to which we've processed for wrapping, but not output. */
+ size_t point_offs;
+ /* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin. */
+ ssize_t point_col;
+
+ char *buf; /* Output buffer. */
+ char *p; /* Current end of text in BUF. */
+ char *end; /* Absolute end of BUF. */
+};
+
+typedef struct argp_fmtstream *argp_fmtstream_t;
+
+/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
+ written on it with LMARGIN spaces and limits them to RMARGIN columns
+ total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
+ replacing the whitespace before them with a newline and WMARGIN spaces.
+ Otherwise, chars beyond RMARGIN are simply dropped until a newline.
+ Returns NULL if there was an error. */
+extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream,
+ size_t __lmargin,
+ size_t __rmargin,
+ ssize_t __wmargin);
+extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream,
+ size_t __lmargin,
+ size_t __rmargin,
+ ssize_t __wmargin);
+
+/* Flush __FS to its stream, and free it (but don't close the stream). */
+extern void __argp_fmtstream_free (argp_fmtstream_t __fs);
+extern void argp_fmtstream_free (argp_fmtstream_t __fs);
+
+extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
+ const char *__fmt, ...)
+ _GL_ATTRIBUTE_FORMAT ((printf, 2, 3));
+extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
+ const char *__fmt, ...)
+ _GL_ATTRIBUTE_FORMAT ((printf, 2, 3));
+
+#if _LIBC
+extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
+extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
+
+extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str);
+extern int argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str);
+
+extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs,
+ const char *__str, size_t __len);
+extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
+ const char *__str, size_t __len);
+#endif
+
+/* Access macros for various bits of state. */
+#define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin)
+#define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin)
+#define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin)
+#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
+#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
+#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
+
+#if _LIBC
+/* Set __FS's left margin to LMARGIN and return the old value. */
+extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
+ size_t __lmargin);
+extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
+ size_t __lmargin);
+
+/* Set __FS's right margin to __RMARGIN and return the old value. */
+extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
+ size_t __rmargin);
+extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
+ size_t __rmargin);
+
+/* Set __FS's wrap margin to __WMARGIN and return the old value. */
+extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
+ size_t __wmargin);
+extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
+ size_t __wmargin);
+
+/* Return the column number of the current output point in __FS. */
+extern size_t argp_fmtstream_point (argp_fmtstream_t __fs);
+extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs);
+#endif
+
+/* Internal routines. */
+extern void _argp_fmtstream_update (argp_fmtstream_t __fs);
+extern void __argp_fmtstream_update (argp_fmtstream_t __fs);
+extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
+extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
+
+#if !_LIBC || defined __OPTIMIZE__
+/* Inline versions of above routines. */
+
+#if !_LIBC
+#define __argp_fmtstream_putc argp_fmtstream_putc
+#define __argp_fmtstream_puts argp_fmtstream_puts
+#define __argp_fmtstream_write argp_fmtstream_write
+#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
+#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
+#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
+#define __argp_fmtstream_point argp_fmtstream_point
+#define __argp_fmtstream_update _argp_fmtstream_update
+#define __argp_fmtstream_ensure _argp_fmtstream_ensure
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef ARGP_FS_EI
+# define ARGP_FS_EI _GL_INLINE
+#endif
+#endif
+
+#ifndef ARGP_FS_EI
+#define ARGP_FS_EI extern inline
+#endif
+
+ARGP_FS_EI size_t
+__argp_fmtstream_write (argp_fmtstream_t __fs, const char *__str, size_t __len)
+{
+ if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len))
+ {
+ memcpy (__fs->p, __str, __len);
+ __fs->p += __len;
+ return __len;
+ }
+ else
+ return 0;
+}
+
+ARGP_FS_EI int
+__argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str)
+{
+ size_t __len = strlen (__str);
+ if (__len)
+ {
+ size_t __wrote = __argp_fmtstream_write (__fs, __str, __len);
+ return __wrote == __len ? 0 : -1;
+ }
+ else
+ return 0;
+}
+
+ARGP_FS_EI int
+__argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
+{
+ if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1))
+ return *__fs->p++ = __ch;
+ else
+ return EOF;
+}
+
+/* Set __FS's left margin to __LMARGIN and return the old value. */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->lmargin;
+ __fs->lmargin = __lmargin;
+ return __old;
+}
+
+/* Set __FS's right margin to __RMARGIN and return the old value. */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->rmargin;
+ __fs->rmargin = __rmargin;
+ return __old;
+}
+
+/* Set FS's wrap margin to __WMARGIN and return the old value. */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->wmargin;
+ __fs->wmargin = __wmargin;
+ return __old;
+}
+
+/* Return the column number of the current output point in __FS. */
+ARGP_FS_EI size_t
+__argp_fmtstream_point (argp_fmtstream_t __fs)
+{
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ return __fs->point_col >= 0 ? __fs->point_col : 0;
+}
+
+#if !_LIBC
+#undef __argp_fmtstream_putc
+#undef __argp_fmtstream_puts
+#undef __argp_fmtstream_write
+#undef __argp_fmtstream_set_lmargin
+#undef __argp_fmtstream_set_rmargin
+#undef __argp_fmtstream_set_wmargin
+#undef __argp_fmtstream_point
+#undef __argp_fmtstream_update
+#undef __argp_fmtstream_ensure
+_GL_INLINE_HEADER_END
+#endif
+
+#endif /* !_LIBC || __OPTIMIZE__ */
+
+#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */
+
+#endif /* argp-fmtstream.h */
diff --git a/grub-core/lib/gnulib/argp-fs-xinl.c b/grub-core/lib/gnulib/argp-fs-xinl.c
new file mode 100644
index 0000000..a2e843c
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-fs-xinl.c
@@ -0,0 +1,46 @@
+/* Real definitions for extern inline functions in argp-fmtstream.h
+ Copyright (C) 1997-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef _LIBC
+# define ARGP_FS_EI
+#else
+# define ARGP_FS_EI _GL_EXTERN_INLINE
+#endif
+#undef __OPTIMIZE__
+#define __OPTIMIZE__ 1
+#include "argp-fmtstream.h"
+
+#if 0
+/* Not exported. */
+/* Add weak aliases. */
+#if _LIBC - 0 && !defined (ARGP_FMTSTREAM_USE_LINEWRAP) && defined (weak_alias)
+
+weak_alias (__argp_fmtstream_putc, argp_fmtstream_putc)
+weak_alias (__argp_fmtstream_puts, argp_fmtstream_puts)
+weak_alias (__argp_fmtstream_write, argp_fmtstream_write)
+weak_alias (__argp_fmtstream_set_lmargin, argp_fmtstream_set_lmargin)
+weak_alias (__argp_fmtstream_set_rmargin, argp_fmtstream_set_rmargin)
+weak_alias (__argp_fmtstream_set_wmargin, argp_fmtstream_set_wmargin)
+weak_alias (__argp_fmtstream_point, argp_fmtstream_point)
+
+#endif
+#endif
diff --git a/grub-core/lib/gnulib/argp-help.c b/grub-core/lib/gnulib/argp-help.c
new file mode 100644
index 0000000..c75568c
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-help.c
@@ -0,0 +1,1912 @@
+/* Hierarchical argument parsing help output
+ Copyright (C) 1995-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <alloca.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <limits.h>
+#ifdef _LIBC
+# include <../libio/libioP.h>
+# include <wchar.h>
+#endif
+
+#ifdef _LIBC
+# include <libintl.h>
+# undef dgettext
+# define dgettext(domain, msgid) \
+ __dcgettext (domain, msgid, LC_MESSAGES)
+#else
+# include "gettext.h"
+#endif
+
+#include "argp.h"
+#include "argp-fmtstream.h"
+#include "argp-namefrob.h"
+#include "mbswidth.h"
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+/* User-selectable (using an environment variable) formatting parameters.
+
+ These may be specified in an environment variable called 'ARGP_HELP_FMT',
+ with a contents like: VAR1=VAL1,VAR2=VAL2,BOOLVAR2,no-BOOLVAR2
+ Where VALn must be a positive integer. The list of variables is in the
+ UPARAM_NAMES vector, below. */
+
+/* Default parameters. */
+#define DUP_ARGS 0 /* True if option argument can be duplicated. */
+#define DUP_ARGS_NOTE 1 /* True to print a note about duplicate args. */
+#define SHORT_OPT_COL 2 /* column in which short options start */
+#define LONG_OPT_COL 6 /* column in which long options start */
+#define DOC_OPT_COL 2 /* column in which doc options start */
+#define OPT_DOC_COL 29 /* column in which option text starts */
+#define HEADER_COL 1 /* column in which group headers are printed */
+#define USAGE_INDENT 12 /* indentation of wrapped usage lines */
+#define RMARGIN 79 /* right margin used for wrapping */
+
+/* User-selectable (using an environment variable) formatting parameters.
+ They must all be of type 'int' for the parsing code to work. */
+struct uparams
+{
+ /* If true, arguments for an option are shown with both short and long
+ options, even when a given option has both, e.g. '-x ARG, --longx=ARG'.
+ If false, then if an option has both, the argument is only shown with
+ the long one, e.g., '-x, --longx=ARG', and a message indicating that
+ this really means both is printed below the options. */
+ int dup_args;
+
+ /* This is true if when DUP_ARGS is false, and some duplicate arguments have
+ been suppressed, an explanatory message should be printed. */
+ int dup_args_note;
+
+ /* Various output columns. */
+ int short_opt_col; /* column in which short options start */
+ int long_opt_col; /* column in which long options start */
+ int doc_opt_col; /* column in which doc options start */
+ int opt_doc_col; /* column in which option text starts */
+ int header_col; /* column in which group headers are printed */
+ int usage_indent; /* indentation of wrapped usage lines */
+ int rmargin; /* right margin used for wrapping */
+
+ int valid; /* True when the values in here are valid. */
+};
+
+/* This is a global variable, as user options are only ever read once. */
+static struct uparams uparams = {
+ DUP_ARGS, DUP_ARGS_NOTE,
+ SHORT_OPT_COL, LONG_OPT_COL, DOC_OPT_COL, OPT_DOC_COL, HEADER_COL,
+ USAGE_INDENT, RMARGIN
+};
+
+/* A particular uparam, and what the user name is. */
+struct uparam_name
+{
+ const char name[14]; /* User name. */
+ bool is_bool; /* Whether it's 'boolean'. */
+ unsigned char uparams_offs; /* Location of the (int) field in UPARAMS. */
+};
+
+/* The name-field mappings we know about. */
+static const struct uparam_name uparam_names[] =
+{
+ { "dup-args", true, offsetof (struct uparams, dup_args) },
+ { "dup-args-note", true, offsetof (struct uparams, dup_args_note) },
+ { "short-opt-col", false, offsetof (struct uparams, short_opt_col) },
+ { "long-opt-col", false, offsetof (struct uparams, long_opt_col) },
+ { "doc-opt-col", false, offsetof (struct uparams, doc_opt_col) },
+ { "opt-doc-col", false, offsetof (struct uparams, opt_doc_col) },
+ { "header-col", false, offsetof (struct uparams, header_col) },
+ { "usage-indent", false, offsetof (struct uparams, usage_indent) },
+ { "rmargin", false, offsetof (struct uparams, rmargin) }
+};
+#define nuparam_names (sizeof (uparam_names) / sizeof (uparam_names[0]))
+
+static void
+validate_uparams (const struct argp_state *state, struct uparams *upptr)
+{
+ const struct uparam_name *up;
+
+ for (up = uparam_names; up < uparam_names + nuparam_names; up++)
+ {
+ if (up->is_bool
+ || up->uparams_offs == offsetof (struct uparams, rmargin))
+ continue;
+ if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin)
+ {
+ __argp_failure (state, 0, 0,
+ dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain,
+ "\
+ARGP_HELP_FMT: %s value is less than or equal to %s"),
+ "rmargin", up->name);
+ return;
+ }
+ }
+ uparams = *upptr;
+ uparams.valid = 1;
+}
+
+/* Read user options from the environment, and fill in UPARAMS appropriately. */
+static void
+fill_in_uparams (const struct argp_state *state)
+{
+ const char *var = getenv ("ARGP_HELP_FMT");
+ struct uparams new_params = uparams;
+
+#define SKIPWS(p) do { while (isspace ((unsigned char) *p)) p++; } while (0);
+
+ if (var)
+ {
+ /* Parse var. */
+ while (*var)
+ {
+ SKIPWS (var);
+
+ if (isalpha ((unsigned char) *var))
+ {
+ size_t var_len;
+ const struct uparam_name *un;
+ int unspec = 0, val = 0;
+ const char *arg = var;
+
+ while (isalnum ((unsigned char) *arg) || *arg == '-' || *arg == '_')
+ arg++;
+ var_len = arg - var;
+
+ SKIPWS (arg);
+
+ if (*arg == '\0' || *arg == ',')
+ unspec = 1;
+ else if (*arg == '=')
+ {
+ arg++;
+ SKIPWS (arg);
+ }
+
+ if (unspec)
+ {
+ if (var[0] == 'n' && var[1] == 'o' && var[2] == '-')
+ {
+ val = 0;
+ var += 3;
+ var_len -= 3;
+ }
+ else
+ val = 1;
+ }
+ else if (isdigit ((unsigned char) *arg))
+ {
+ val = atoi (arg);
+ while (isdigit ((unsigned char) *arg))
+ arg++;
+ SKIPWS (arg);
+ }
+
+ for (un = uparam_names;
+ un < uparam_names + nuparam_names;
+ un++)
+ if (strlen (un->name) == var_len
+ && strncmp (var, un->name, var_len) == 0)
+ {
+ if (unspec && !un->is_bool)
+ __argp_failure (state, 0, 0,
+ dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain,
+ "\
+%.*s: ARGP_HELP_FMT parameter requires a value"),
+ (int) var_len, var);
+ else
+ *(int *)((char *)&new_params + un->uparams_offs) = val;
+ break;
+ }
+ if (un == uparam_names + nuparam_names)
+ __argp_failure (state, 0, 0,
+ dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain, "\
+%.*s: Unknown ARGP_HELP_FMT parameter"),
+ (int) var_len, var);
+
+ var = arg;
+ if (*var == ',')
+ var++;
+ }
+ else if (*var)
+ {
+ __argp_failure (state, 0, 0,
+ dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain,
+ "Garbage in ARGP_HELP_FMT: %s"), var);
+ break;
+ }
+ }
+ validate_uparams (state, &new_params);
+ }
+}
+
+/* Returns true if OPT hasn't been marked invisible. Visibility only affects
+ whether OPT is displayed or used in sorting, not option shadowing. */
+#define ovisible(opt) (! ((opt)->flags & OPTION_HIDDEN))
+
+/* Returns true if OPT is an alias for an earlier option. */
+#define oalias(opt) ((opt)->flags & OPTION_ALIAS)
+
+/* Returns true if OPT is a documentation-only entry. */
+#define odoc(opt) ((opt)->flags & OPTION_DOC)
+
+/* Returns true if OPT should not be translated */
+#define onotrans(opt) ((opt)->flags & OPTION_NO_TRANS)
+
+/* Returns true if OPT is the end-of-list marker for a list of options. */
+#define oend(opt) __option_is_end (opt)
+
+/* Returns true if OPT has a short option. */
+#define oshort(opt) __option_is_short (opt)
+
+/*
+ The help format for a particular option is like:
+
+ -xARG, -yARG, --long1=ARG, --long2=ARG Documentation...
+
+ Where ARG will be omitted if there's no argument, for this option, or
+ will be surrounded by "[" and "]" appropriately if the argument is
+ optional. The documentation string is word-wrapped appropriately, and if
+ the list of options is long enough, it will be started on a separate line.
+ If there are no short options for a given option, the first long option is
+ indented slightly in a way that's supposed to make most long options appear
+ to be in a separate column.
+
+ For example, the following output (from ps):
+
+ -p PID, --pid=PID List the process PID
+ --pgrp=PGRP List processes in the process group PGRP
+ -P, -x, --no-parent Include processes without parents
+ -Q, --all-fields Don't elide unusable fields (normally if there's
+ some reason ps can't print a field for any
+ process, it's removed from the output entirely)
+ -r, --reverse, --gratuitously-long-reverse-option
+ Reverse the order of any sort
+ --session[=SID] Add the processes from the session SID (which
+ defaults to the sid of the current process)
+
+ Here are some more options:
+ -f ZOT, --foonly=ZOT Glork a foonly
+ -z, --zaza Snit a zar
+
+ -?, --help Give this help list
+ --usage Give a short usage message
+ -V, --version Print program version
+
+ The struct argp_option array for the above could look like:
+
+ {
+ {"pid", 'p', "PID", 0, "List the process PID"},
+ {"pgrp", OPT_PGRP, "PGRP", 0, "List processes in the process group PGRP"},
+ {"no-parent", 'P', 0, 0, "Include processes without parents"},
+ {0, 'x', 0, OPTION_ALIAS},
+ {"all-fields",'Q', 0, 0, "Don't elide unusable fields (normally"
+ " if there's some reason ps can't"
+ " print a field for any process, it's"
+ " removed from the output entirely)" },
+ {"reverse", 'r', 0, 0, "Reverse the order of any sort"},
+ {"gratuitously-long-reverse-option", 0, 0, OPTION_ALIAS},
+ {"session", OPT_SESS, "SID", OPTION_ARG_OPTIONAL,
+ "Add the processes from the session"
+ " SID (which defaults to the sid of"
+ " the current process)" },
+
+ {0,0,0,0, "Here are some more options:"},
+ {"foonly", 'f', "ZOT", 0, "Glork a foonly"},
+ {"zaza", 'z', 0, 0, "Snit a zar"},
+
+ {0}
+ }
+
+ Note that the last three options are automatically supplied by argp_parse,
+ unless you tell it not to with ARGP_NO_HELP.
+
+*/
+
+/* Returns true if CH occurs between BEG and END. */
+static int
+find_char (char ch, char *beg, char *end)
+{
+ while (beg < end)
+ if (*beg == ch)
+ return 1;
+ else
+ beg++;
+ return 0;
+}
+
+struct hol_cluster; /* fwd decl */
+
+struct hol_entry
+{
+ /* First option. */
+ const struct argp_option *opt;
+ /* Number of options (including aliases). */
+ unsigned num;
+
+ /* A pointers into the HOL's short_options field, to the first short option
+ letter for this entry. The order of the characters following this point
+ corresponds to the order of options pointed to by OPT, and there are at
+ most NUM. A short option recorded in an option following OPT is only
+ valid if it occurs in the right place in SHORT_OPTIONS (otherwise it's
+ probably been shadowed by some other entry). */
+ char *short_options;
+
+ /* Entries are sorted by their group first, in the order:
+ 1, 2, ..., n, 0, -m, ..., -2, -1
+ and then alphabetically within each group. The default is 0. */
+ int group;
+
+ /* The cluster of options this entry belongs to, or 0 if none. */
+ struct hol_cluster *cluster;
+
+ /* The argp from which this option came. */
+ const struct argp *argp;
+
+ /* Position in the array */
+ unsigned ord;
+};
+
+/* A cluster of entries to reflect the argp tree structure. */
+struct hol_cluster
+{
+ /* A descriptive header printed before options in this cluster. */
+ const char *header;
+
+ /* Used to order clusters within the same group with the same parent,
+ according to the order in which they occurred in the parent argp's child
+ list. */
+ int index;
+
+ /* How to sort this cluster with respect to options and other clusters at the
+ same depth (clusters always follow options in the same group). */
+ int group;
+
+ /* The cluster to which this cluster belongs, or 0 if it's at the base
+ level. */
+ struct hol_cluster *parent;
+
+ /* The argp from which this cluster is (eventually) derived. */
+ const struct argp *argp;
+
+ /* The distance this cluster is from the root. */
+ int depth;
+
+ /* Clusters in a given hol are kept in a linked list, to make freeing them
+ possible. */
+ struct hol_cluster *next;
+};
+
+/* A list of options for help. */
+struct hol
+{
+ /* An array of hol_entry's. */
+ struct hol_entry *entries;
+ /* The number of entries in this hol. If this field is zero, the others
+ are undefined. */
+ unsigned num_entries;
+
+ /* A string containing all short options in this HOL. Each entry contains
+ pointers into this string, so the order can't be messed with blindly. */
+ char *short_options;
+
+ /* Clusters of entries in this hol. */
+ struct hol_cluster *clusters;
+};
+
+/* Create a struct hol from the options in ARGP. CLUSTER is the
+ hol_cluster in which these entries occur, or 0, if at the root. */
+static struct hol *
+make_hol (const struct argp *argp, struct hol_cluster *cluster)
+{
+ char *so;
+ const struct argp_option *o;
+ const struct argp_option *opts = argp->options;
+ struct hol_entry *entry;
+ unsigned num_short_options = 0;
+ struct hol *hol = malloc (sizeof (struct hol));
+
+ assert (hol);
+
+ hol->num_entries = 0;
+ hol->clusters = 0;
+
+ if (opts)
+ {
+ int cur_group = 0;
+
+ /* The first option must not be an alias. */
+ assert (! oalias (opts));
+
+ /* Calculate the space needed. */
+ for (o = opts; ! oend (o); o++)
+ {
+ if (! oalias (o))
+ hol->num_entries++;
+ if (oshort (o))
+ num_short_options++; /* This is an upper bound. */
+ }
+
+ hol->entries = malloc (sizeof (struct hol_entry) * hol->num_entries);
+ hol->short_options = malloc (num_short_options + 1);
+
+ assert (hol->entries && hol->short_options);
+ if (SIZE_MAX <= UINT_MAX)
+ assert (hol->num_entries <= SIZE_MAX / sizeof (struct hol_entry));
+
+ /* Fill in the entries. */
+ so = hol->short_options;
+ for (o = opts, entry = hol->entries; ! oend (o); entry++)
+ {
+ entry->opt = o;
+ entry->num = 0;
+ entry->short_options = so;
+ entry->group = cur_group =
+ o->group
+ ? o->group
+ : ((!o->name && !o->key)
+ ? cur_group + 1
+ : cur_group);
+ entry->cluster = cluster;
+ entry->argp = argp;
+
+ do
+ {
+ entry->num++;
+ if (oshort (o) && ! find_char (o->key, hol->short_options, so))
+ /* O has a valid short option which hasn't already been used.*/
+ *so++ = o->key;
+ o++;
+ }
+ while (! oend (o) && oalias (o));
+ }
+ *so = '\0'; /* null terminated so we can find the length */
+ }
+
+ return hol;
+}
+
+/* Add a new cluster to HOL, with the given GROUP and HEADER (taken from the
+ associated argp child list entry), INDEX, and PARENT, and return a pointer
+ to it. ARGP is the argp that this cluster results from. */
+static struct hol_cluster *
+hol_add_cluster (struct hol *hol, int group, const char *header, int index,
+ struct hol_cluster *parent, const struct argp *argp)
+{
+ struct hol_cluster *cl = malloc (sizeof (struct hol_cluster));
+ if (cl)
+ {
+ cl->group = group;
+ cl->header = header;
+
+ cl->index = index;
+ cl->parent = parent;
+ cl->argp = argp;
+ cl->depth = parent ? parent->depth + 1 : 0;
+
+ cl->next = hol->clusters;
+ hol->clusters = cl;
+ }
+ return cl;
+}
+
+/* Free HOL and any resources it uses. */
+static void
+hol_free (struct hol *hol)
+{
+ struct hol_cluster *cl = hol->clusters;
+
+ while (cl)
+ {
+ struct hol_cluster *next = cl->next;
+ free (cl);
+ cl = next;
+ }
+
+ if (hol->num_entries > 0)
+ {
+ free (hol->entries);
+ free (hol->short_options);
+ }
+
+ free (hol);
+}
+
+static int
+hol_entry_short_iterate (const struct hol_entry *entry,
+ int (*func)(const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie),
+ const char *domain, void *cookie)
+{
+ unsigned nopts;
+ int val = 0;
+ const struct argp_option *opt, *real = entry->opt;
+ char *so = entry->short_options;
+
+ for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--)
+ if (oshort (opt) && *so == opt->key)
+ {
+ if (!oalias (opt))
+ real = opt;
+ if (ovisible (opt))
+ val = (*func)(opt, real, domain, cookie);
+ so++;
+ }
+
+ return val;
+}
+
+static inline int
+#if __GNUC__ >= 3
+__attribute__ ((always_inline))
+#endif
+hol_entry_long_iterate (const struct hol_entry *entry,
+ int (*func)(const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie),
+ const char *domain, void *cookie)
+{
+ unsigned nopts;
+ int val = 0;
+ const struct argp_option *opt, *real = entry->opt;
+
+ for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--)
+ if (opt->name)
+ {
+ if (!oalias (opt))
+ real = opt;
+ if (ovisible (opt))
+ val = (*func)(opt, real, domain, cookie);
+ }
+
+ return val;
+}
+
+/* Iterator that returns true for the first short option. */
+static int
+until_short (const struct argp_option *opt, const struct argp_option *real,
+ const char *domain, void *cookie)
+{
+ return oshort (opt) ? opt->key : 0;
+}
+
+/* Returns the first valid short option in ENTRY, or 0 if there is none. */
+static char
+hol_entry_first_short (const struct hol_entry *entry)
+{
+ return hol_entry_short_iterate (entry, until_short,
+ entry->argp->argp_domain, 0);
+}
+
+/* Returns the first valid long option in ENTRY, or 0 if there is none. */
+static const char *
+hol_entry_first_long (const struct hol_entry *entry)
+{
+ const struct argp_option *opt;
+ unsigned num;
+ for (opt = entry->opt, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ return opt->name;
+ return 0;
+}
+
+/* Returns the entry in HOL with the long option name NAME, or 0 if there is
+ none. */
+static struct hol_entry *
+hol_find_entry (struct hol *hol, const char *name)
+{
+ struct hol_entry *entry = hol->entries;
+ unsigned num_entries = hol->num_entries;
+
+ while (num_entries-- > 0)
+ {
+ const struct argp_option *opt = entry->opt;
+ unsigned num_opts = entry->num;
+
+ while (num_opts-- > 0)
+ if (opt->name && ovisible (opt) && strcmp (opt->name, name) == 0)
+ return entry;
+ else
+ opt++;
+
+ entry++;
+ }
+
+ return 0;
+}
+
+/* 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)
+{
+ struct hol_entry *entry = hol_find_entry (hol, name);
+ if (entry)
+ entry->group = group;
+}
+
+/* Order by group: 0, 1, 2, ..., n, -m, ..., -2, -1.
+ EQ is what to return if GROUP1 and GROUP2 are the same. */
+static int
+group_cmp (int group1, int group2, int eq)
+{
+ if (group1 == group2)
+ return eq;
+ else if ((group1 < 0 && group2 < 0) || (group1 >= 0 && group2 >= 0))
+ return group1 - group2;
+ else
+ return group2 - group1;
+}
+
+/* Compare clusters CL1 & CL2 by the order that they should appear in
+ output. */
+static int
+hol_cluster_cmp (const struct hol_cluster *cl1, const struct hol_cluster *cl2)
+{
+ /* If one cluster is deeper than the other, use its ancestor at the same
+ level, so that finding the common ancestor is straightforward. */
+ while (cl1->depth > cl2->depth)
+ cl1 = cl1->parent;
+ while (cl2->depth > cl1->depth)
+ cl2 = cl2->parent;
+
+ /* Now reduce both clusters to their ancestors at the point where both have
+ a common parent; these can be directly compared. */
+ while (cl1->parent != cl2->parent)
+ cl1 = cl1->parent, cl2 = cl2->parent;
+
+ return group_cmp (cl1->group, cl2->group, cl2->index - cl1->index);
+}
+
+/* Return the ancestor of CL that's just below the root (i.e., has a parent
+ of 0). */
+static struct hol_cluster *
+hol_cluster_base (struct hol_cluster *cl)
+{
+ while (cl->parent)
+ cl = cl->parent;
+ return cl;
+}
+
+/* Return true if CL1 is a child of CL2. */
+static int
+hol_cluster_is_child (const struct hol_cluster *cl1,
+ const struct hol_cluster *cl2)
+{
+ while (cl1 && cl1 != cl2)
+ cl1 = cl1->parent;
+ return cl1 == cl2;
+}
+
+/* Given the name of an OPTION_DOC option, modifies NAME to start at the tail
+ that should be used for comparisons, and returns true iff it should be
+ treated as a non-option. */
+static int
+canon_doc_option (const char **name)
+{
+ int non_opt;
+ /* Skip initial whitespace. */
+ while (isspace (**name))
+ (*name)++;
+ /* Decide whether this looks like an option (leading '-') or not. */
+ non_opt = (**name != '-');
+ /* Skip until part of name used for sorting. */
+ while (**name && !isalnum (**name))
+ (*name)++;
+ return non_opt;
+}
+
+#define HOL_ENTRY_PTRCMP(a,b) ((a)->ord < (b)->ord ? -1 : 1)
+
+/* Order ENTRY1 & ENTRY2 by the order which they should appear in a help
+ listing. */
+static int
+hol_entry_cmp (const struct hol_entry *entry1,
+ const struct hol_entry *entry2)
+{
+ /* The group numbers by which the entries should be ordered; if either is
+ in a cluster, then this is just the group within the cluster. */
+ int group1 = entry1->group, group2 = entry2->group;
+
+ if (entry1->cluster != entry2->cluster)
+ {
+ /* The entries are not within the same cluster, so we can't compare them
+ directly, we have to use the appropriate clustering level too. */
+ if (! entry1->cluster)
+ /* ENTRY1 is at the 'base level', not in a cluster, so we have to
+ compare it's group number with that of the base cluster in which
+ ENTRY2 resides. Note that if they're in the same group, the
+ clustered option always comes last. */
+ return group_cmp (group1, hol_cluster_base (entry2->cluster)->group, -1);
+ else if (! entry2->cluster)
+ /* Likewise, but ENTRY2's not in a cluster. */
+ return group_cmp (hol_cluster_base (entry1->cluster)->group, group2, 1);
+ else
+ /* Both entries are in clusters, we can just compare the clusters. */
+ return hol_cluster_cmp (entry1->cluster, entry2->cluster);
+ }
+ else if (group1 == group2)
+ /* The entries are both in the same cluster and group, so compare them
+ alphabetically. */
+ {
+ int short1 = hol_entry_first_short (entry1);
+ int short2 = hol_entry_first_short (entry2);
+ int doc1 = odoc (entry1->opt);
+ int doc2 = odoc (entry2->opt);
+ const char *long1 = hol_entry_first_long (entry1);
+ const char *long2 = hol_entry_first_long (entry2);
+
+ if (doc1)
+ doc1 = long1 != NULL && canon_doc_option (&long1);
+ if (doc2)
+ doc2 = long2 != NULL && canon_doc_option (&long2);
+
+ if (doc1 != doc2)
+ /* 'documentation' options always follow normal options (or
+ documentation options that *look* like normal options). */
+ return doc1 - doc2;
+ else if (!short1 && !short2 && long1 && long2)
+ /* Only long options. */
+ return __strcasecmp (long1, long2);
+ else
+ /* Compare short/short, long/short, short/long, using the first
+ character of long options. Entries without *any* valid
+ options (such as options with OPTION_HIDDEN set) will be put
+ first, but as they're not displayed, it doesn't matter where
+ they are. */
+ {
+ char first1 = short1 ? short1 : long1 ? *long1 : 0;
+ char first2 = short2 ? short2 : long2 ? *long2 : 0;
+#ifdef _tolower
+ int lower_cmp = _tolower (first1) - _tolower (first2);
+#else
+ int lower_cmp = tolower (first1) - tolower (first2);
+#endif
+ /* Compare ignoring case, except when the options are both the
+ same letter, in which case lower-case always comes first. */
+ return lower_cmp ? lower_cmp : first2 - first1;
+ }
+ }
+ else
+ /* Within the same cluster, but not the same group, so just compare
+ groups. */
+ return group_cmp (group1, group2, 0);
+}
+
+/* Version of hol_entry_cmp with correct signature for qsort. */
+static int
+hol_entry_qcmp (const void *entry1_v, const void *entry2_v)
+{
+ return hol_entry_cmp (entry1_v, entry2_v);
+}
+
+/* Sort HOL by group and alphabetically by option name (with short options
+ taking precedence over long). Since the sorting is for display purposes
+ only, the shadowing of options isn't effected. */
+static void
+hol_sort (struct hol *hol)
+{
+ if (hol->num_entries > 0)
+ {
+ unsigned i;
+ struct hol_entry *e;
+ for (i = 0, e = hol->entries; i < hol->num_entries; i++, e++)
+ e->ord = i;
+ qsort (hol->entries, hol->num_entries, sizeof (struct hol_entry),
+ hol_entry_qcmp);
+ }
+}
+
+/* Append MORE to HOL, destroying MORE in the process. Options in HOL shadow
+ any in MORE with the same name. */
+static void
+hol_append (struct hol *hol, struct hol *more)
+{
+ struct hol_cluster **cl_end = &hol->clusters;
+
+ /* Steal MORE's cluster list, and add it to the end of HOL's. */
+ while (*cl_end)
+ cl_end = &(*cl_end)->next;
+ *cl_end = more->clusters;
+ more->clusters = 0;
+
+ /* Merge entries. */
+ if (more->num_entries > 0)
+ {
+ if (hol->num_entries == 0)
+ {
+ hol->num_entries = more->num_entries;
+ hol->entries = more->entries;
+ hol->short_options = more->short_options;
+ more->num_entries = 0; /* Mark MORE's fields as invalid. */
+ }
+ else
+ /* Append the entries in MORE to those in HOL, taking care to only add
+ non-shadowed SHORT_OPTIONS values. */
+ {
+ unsigned left;
+ char *so, *more_so;
+ struct hol_entry *e;
+ unsigned num_entries = hol->num_entries + more->num_entries;
+ struct hol_entry *entries =
+ malloc (num_entries * sizeof (struct hol_entry));
+ unsigned hol_so_len = strlen (hol->short_options);
+ char *short_options =
+ malloc (hol_so_len + strlen (more->short_options) + 1);
+
+ assert (entries && short_options);
+ if (SIZE_MAX <= UINT_MAX)
+ assert (num_entries <= SIZE_MAX / sizeof (struct hol_entry));
+
+ __mempcpy (__mempcpy (entries, hol->entries,
+ hol->num_entries * sizeof (struct hol_entry)),
+ more->entries,
+ more->num_entries * sizeof (struct hol_entry));
+
+ __mempcpy (short_options, hol->short_options, hol_so_len);
+
+ /* Fix up the short options pointers from HOL. */
+ for (e = entries, left = hol->num_entries; left > 0; e++, left--)
+ e->short_options
+ = short_options + (e->short_options - hol->short_options);
+
+ /* Now add the short options from MORE, fixing up its entries
+ too. */
+ so = short_options + hol_so_len;
+ more_so = more->short_options;
+ for (left = more->num_entries; left > 0; e++, left--)
+ {
+ int opts_left;
+ const struct argp_option *opt;
+
+ e->short_options = so;
+
+ for (opts_left = e->num, opt = e->opt; opts_left; opt++, opts_left--)
+ {
+ int ch = *more_so;
+ if (oshort (opt) && ch == opt->key)
+ /* The next short option in MORE_SO, CH, is from OPT. */
+ {
+ if (! find_char (ch, short_options,
+ short_options + hol_so_len))
+ /* The short option CH isn't shadowed by HOL's options,
+ so add it to the sum. */
+ *so++ = ch;
+ more_so++;
+ }
+ }
+ }
+
+ *so = '\0';
+
+ free (hol->entries);
+ free (hol->short_options);
+
+ hol->entries = entries;
+ hol->num_entries = num_entries;
+ hol->short_options = short_options;
+ }
+ }
+
+ hol_free (more);
+}
+
+/* Inserts enough spaces to make sure STREAM is at column COL. */
+static void
+indent_to (argp_fmtstream_t stream, unsigned col)
+{
+ int needed = col - __argp_fmtstream_point (stream);
+ while (needed-- > 0)
+ __argp_fmtstream_putc (stream, ' ');
+}
+
+/* Output to STREAM either a space, or a newline if there isn't room for at
+ least ENSURE characters before the right margin. */
+static void
+space (argp_fmtstream_t stream, size_t ensure)
+{
+ if (__argp_fmtstream_point (stream) + ensure
+ >= __argp_fmtstream_rmargin (stream))
+ __argp_fmtstream_putc (stream, '\n');
+ else
+ __argp_fmtstream_putc (stream, ' ');
+}
+
+/* If the option REAL has an argument, we print it in using the printf
+ format REQ_FMT or OPT_FMT depending on whether it's a required or
+ optional argument. */
+static void
+arg (const struct argp_option *real, const char *req_fmt, const char *opt_fmt,
+ const char *domain, argp_fmtstream_t stream)
+{
+ if (real->arg)
+ {
+ if (real->flags & OPTION_ARG_OPTIONAL)
+ __argp_fmtstream_printf (stream, opt_fmt,
+ dgettext (domain, real->arg));
+ else
+ __argp_fmtstream_printf (stream, req_fmt,
+ dgettext (domain, real->arg));
+ }
+}
+
+/* Helper functions for hol_entry_help. */
+
+/* State used during the execution of hol_help. */
+struct hol_help_state
+{
+ /* PREV_ENTRY should contain the previous entry printed, or 0. */
+ struct hol_entry *prev_entry;
+
+ /* If an entry is in a different group from the previous one, and SEP_GROUPS
+ is true, then a blank line will be printed before any output. */
+ int sep_groups;
+
+ /* True if a duplicate option argument was suppressed (only ever set if
+ UPARAMS.dup_args is false). */
+ int suppressed_dup_arg;
+};
+
+/* Some state used while printing a help entry (used to communicate with
+ helper functions). See the doc for hol_entry_help for more info, as most
+ of the fields are copied from its arguments. */
+struct pentry_state
+{
+ const struct hol_entry *entry;
+ argp_fmtstream_t stream;
+ struct hol_help_state *hhstate;
+
+ /* True if nothing's been printed so far. */
+ int first;
+
+ /* If non-zero, the state that was used to print this help. */
+ const struct argp_state *state;
+};
+
+/* If a user doc filter should be applied to DOC, do so. */
+static const char *
+filter_doc (const char *doc, int key, const struct argp *argp,
+ const struct argp_state *state)
+{
+ if (argp && argp->help_filter)
+ /* We must apply a user filter to this output. */
+ {
+ void *input = __argp_input (argp, state);
+ return (*argp->help_filter) (key, doc, input);
+ }
+ else
+ /* No filter. */
+ return doc;
+}
+
+/* Prints STR as a header line, with the margin lines set appropriately, and
+ notes the fact that groups should be separated with a blank line. ARGP is
+ the argp that should dictate any user doc filtering to take place. Note
+ that the previous wrap margin isn't restored, but the left margin is reset
+ to 0. */
+static void
+print_header (const char *str, const struct argp *argp,
+ struct pentry_state *pest)
+{
+ const char *tstr = dgettext (argp->argp_domain, str);
+ const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_HEADER, argp, pest->state);
+
+ if (fstr)
+ {
+ if (*fstr)
+ {
+ if (pest->hhstate->prev_entry)
+ /* Precede with a blank line. */
+ __argp_fmtstream_putc (pest->stream, '\n');
+ indent_to (pest->stream, uparams.header_col);
+ __argp_fmtstream_set_lmargin (pest->stream, uparams.header_col);
+ __argp_fmtstream_set_wmargin (pest->stream, uparams.header_col);
+ __argp_fmtstream_puts (pest->stream, fstr);
+ __argp_fmtstream_set_lmargin (pest->stream, 0);
+ __argp_fmtstream_putc (pest->stream, '\n');
+ }
+
+ pest->hhstate->sep_groups = 1; /* Separate subsequent groups. */
+ }
+
+ if (fstr != tstr)
+ free ((char *) fstr);
+}
+
+/* Inserts a comma if this isn't the first item on the line, and then makes
+ sure we're at least to column COL. If this *is* the first item on a line,
+ prints any pending whitespace/headers that should precede this line. Also
+ clears FIRST. */
+static void
+comma (unsigned col, struct pentry_state *pest)
+{
+ if (pest->first)
+ {
+ const struct hol_entry *pe = pest->hhstate->prev_entry;
+ const struct hol_cluster *cl = pest->entry->cluster;
+
+ if (pest->hhstate->sep_groups && pe && pest->entry->group != pe->group)
+ __argp_fmtstream_putc (pest->stream, '\n');
+
+ if (cl && cl->header && *cl->header
+ && (!pe
+ || (pe->cluster != cl
+ && !hol_cluster_is_child (pe->cluster, cl))))
+ /* If we're changing clusters, then this must be the start of the
+ ENTRY's cluster unless that is an ancestor of the previous one
+ (in which case we had just popped into a sub-cluster for a bit).
+ If so, then print the cluster's header line. */
+ {
+ int old_wm = __argp_fmtstream_wmargin (pest->stream);
+ print_header (cl->header, cl->argp, pest);
+ __argp_fmtstream_set_wmargin (pest->stream, old_wm);
+ }
+
+ pest->first = 0;
+ }
+ else
+ __argp_fmtstream_puts (pest->stream, ", ");
+
+ indent_to (pest->stream, col);
+}
+
+/* Print help for ENTRY to STREAM. */
+static void
+hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
+ argp_fmtstream_t stream, struct hol_help_state *hhstate)
+{
+ unsigned num;
+ const struct argp_option *real = entry->opt, *opt;
+ char *so = entry->short_options;
+ int have_long_opt = 0; /* We have any long options. */
+ /* Saved margins. */
+ int old_lm = __argp_fmtstream_set_lmargin (stream, 0);
+ int old_wm = __argp_fmtstream_wmargin (stream);
+ /* PEST is a state block holding some of our variables that we'd like to
+ share with helper functions. */
+ struct pentry_state pest = { entry, stream, hhstate, 1, state };
+
+ if (! odoc (real))
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ {
+ have_long_opt = 1;
+ break;
+ }
+
+ /* First emit short options. */
+ __argp_fmtstream_set_wmargin (stream, uparams.short_opt_col); /* For truly bizarre cases. */
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (oshort (opt) && opt->key == *so)
+ /* OPT has a valid (non shadowed) short option. */
+ {
+ if (ovisible (opt))
+ {
+ comma (uparams.short_opt_col, &pest);
+ __argp_fmtstream_putc (stream, '-');
+ __argp_fmtstream_putc (stream, *so);
+ if (!have_long_opt || uparams.dup_args)
+ arg (real, " %s", "[%s]",
+ state == NULL ? NULL : state->root_argp->argp_domain,
+ stream);
+ else if (real->arg)
+ hhstate->suppressed_dup_arg = 1;
+ }
+ so++;
+ }
+
+ /* Now, long options. */
+ if (odoc (real))
+ /* A "documentation" option. */
+ {
+ __argp_fmtstream_set_wmargin (stream, uparams.doc_opt_col);
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ {
+ comma (uparams.doc_opt_col, &pest);
+ /* Calling dgettext here isn't quite right, since sorting will
+ have been done on the original; but documentation options
+ should be pretty rare anyway... */
+ __argp_fmtstream_puts (stream,
+ dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain,
+ opt->name));
+ }
+ }
+ else
+ /* A real long option. */
+ {
+ __argp_fmtstream_set_wmargin (stream, uparams.long_opt_col);
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ {
+ comma (uparams.long_opt_col, &pest);
+ __argp_fmtstream_printf (stream, "--%s", opt->name);
+ arg (real, "=%s", "[=%s]",
+ state == NULL ? NULL : state->root_argp->argp_domain, stream);
+ }
+ }
+
+ /* Next, documentation strings. */
+ __argp_fmtstream_set_lmargin (stream, 0);
+
+ if (pest.first)
+ {
+ /* Didn't print any switches, what's up? */
+ if (!oshort (real) && !real->name)
+ /* This is a group header, print it nicely. */
+ print_header (real->doc, entry->argp, &pest);
+ else
+ /* Just a totally shadowed option or null header; print nothing. */
+ goto cleanup; /* Just return, after cleaning up. */
+ }
+ else
+ {
+ const char *tstr = real->doc ? dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain,
+ real->doc) : 0;
+ const char *fstr = filter_doc (tstr, real->key, entry->argp, state);
+ if (fstr && *fstr)
+ {
+ unsigned int col = __argp_fmtstream_point (stream);
+
+ __argp_fmtstream_set_lmargin (stream, uparams.opt_doc_col);
+ __argp_fmtstream_set_wmargin (stream, uparams.opt_doc_col);
+
+ if (col > (unsigned int) (uparams.opt_doc_col + 3))
+ __argp_fmtstream_putc (stream, '\n');
+ else if (col >= (unsigned int) uparams.opt_doc_col)
+ __argp_fmtstream_puts (stream, " ");
+ else
+ indent_to (stream, uparams.opt_doc_col);
+
+ __argp_fmtstream_puts (stream, fstr);
+ }
+ if (fstr && fstr != tstr)
+ free ((char *) fstr);
+
+ /* Reset the left margin. */
+ __argp_fmtstream_set_lmargin (stream, 0);
+ __argp_fmtstream_putc (stream, '\n');
+ }
+
+ hhstate->prev_entry = entry;
+
+cleanup:
+ __argp_fmtstream_set_lmargin (stream, old_lm);
+ __argp_fmtstream_set_wmargin (stream, old_wm);
+}
+
+/* Output a long help message about the options in HOL to STREAM. */
+static void
+hol_help (struct hol *hol, const struct argp_state *state,
+ argp_fmtstream_t stream)
+{
+ unsigned num;
+ struct hol_entry *entry;
+ struct hol_help_state hhstate = { 0, 0, 0 };
+
+ for (entry = hol->entries, num = hol->num_entries; num > 0; entry++, num--)
+ hol_entry_help (entry, state, stream, &hhstate);
+
+ if (hhstate.suppressed_dup_arg && uparams.dup_args_note)
+ {
+ const char *tstr = dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain, "\
+Mandatory or optional arguments to long options are also mandatory or \
+optional for any corresponding short options.");
+ const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_DUP_ARGS_NOTE,
+ state ? state->root_argp : 0, state);
+ if (fstr && *fstr)
+ {
+ __argp_fmtstream_putc (stream, '\n');
+ __argp_fmtstream_puts (stream, fstr);
+ __argp_fmtstream_putc (stream, '\n');
+ }
+ if (fstr && fstr != tstr)
+ free ((char *) fstr);
+ }
+}
+
+/* Helper functions for hol_usage. */
+
+/* If OPT is a short option without an arg, append its key to the string
+ pointer pointer to by COOKIE, and advance the pointer. */
+static int
+add_argless_short_opt (const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie)
+{
+ char **snao_end = cookie;
+ if (!(opt->arg || real->arg)
+ && !((opt->flags | real->flags) & OPTION_NO_USAGE))
+ *(*snao_end)++ = opt->key;
+ return 0;
+}
+
+/* If OPT is a short option with an arg, output a usage entry for it to the
+ stream pointed at by COOKIE. */
+static int
+usage_argful_short_opt (const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie)
+{
+ argp_fmtstream_t stream = cookie;
+ const char *arg = opt->arg;
+ int flags = opt->flags | real->flags;
+
+ if (! arg)
+ arg = real->arg;
+
+ if (arg && !(flags & OPTION_NO_USAGE))
+ {
+ arg = dgettext (domain, arg);
+
+ if (flags & OPTION_ARG_OPTIONAL)
+ __argp_fmtstream_printf (stream, " [-%c[%s]]", opt->key, arg);
+ else
+ {
+ /* Manually do line wrapping so that it (probably) won't
+ get wrapped at the embedded space. */
+ space (stream, 6 + strlen (arg));
+ __argp_fmtstream_printf (stream, "[-%c %s]", opt->key, arg);
+ }
+ }
+
+ return 0;
+}
+
+/* Output a usage entry for the long option opt to the stream pointed at by
+ COOKIE. */
+static int
+usage_long_opt (const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie)
+{
+ argp_fmtstream_t stream = cookie;
+ const char *arg = opt->arg;
+ int flags = opt->flags | real->flags;
+
+ if (! arg)
+ arg = real->arg;
+
+ if (! (flags & OPTION_NO_USAGE))
+ {
+ if (arg)
+ {
+ arg = dgettext (domain, arg);
+ if (flags & OPTION_ARG_OPTIONAL)
+ __argp_fmtstream_printf (stream, " [--%s[=%s]]", opt->name, arg);
+ else
+ __argp_fmtstream_printf (stream, " [--%s=%s]", opt->name, arg);
+ }
+ else
+ __argp_fmtstream_printf (stream, " [--%s]", opt->name);
+ }
+
+ return 0;
+}
+
+/* Print a short usage description for the arguments in HOL to STREAM. */
+static void
+hol_usage (struct hol *hol, argp_fmtstream_t stream)
+{
+ if (hol->num_entries > 0)
+ {
+ unsigned nentries;
+ struct hol_entry *entry;
+ char *short_no_arg_opts = alloca (strlen (hol->short_options) + 1);
+ char *snao_end = short_no_arg_opts;
+
+ /* First we put a list of short options without arguments. */
+ for (entry = hol->entries, nentries = hol->num_entries
+ ; nentries > 0
+ ; entry++, nentries--)
+ hol_entry_short_iterate (entry, add_argless_short_opt,
+ entry->argp->argp_domain, &snao_end);
+ if (snao_end > short_no_arg_opts)
+ {
+ *snao_end++ = 0;
+ __argp_fmtstream_printf (stream, " [-%s]", short_no_arg_opts);
+ }
+
+ /* Now a list of short options *with* arguments. */
+ for (entry = hol->entries, nentries = hol->num_entries
+ ; nentries > 0
+ ; entry++, nentries--)
+ hol_entry_short_iterate (entry, usage_argful_short_opt,
+ entry->argp->argp_domain, stream);
+
+ /* Finally, a list of long options (whew!). */
+ for (entry = hol->entries, nentries = hol->num_entries
+ ; nentries > 0
+ ; entry++, nentries--)
+ hol_entry_long_iterate (entry, usage_long_opt,
+ entry->argp->argp_domain, stream);
+ }
+}
+
+/* Make a HOL containing all levels of options in ARGP. CLUSTER is the
+ cluster in which ARGP's entries should be clustered, or 0. */
+static struct hol *
+argp_hol (const struct argp *argp, struct hol_cluster *cluster)
+{
+ const struct argp_child *child = argp->children;
+ struct hol *hol = make_hol (argp, cluster);
+ if (child)
+ while (child->argp)
+ {
+ struct hol_cluster *child_cluster =
+ ((child->group || child->header)
+ /* Put CHILD->argp within its own cluster. */
+ ? hol_add_cluster (hol, child->group, child->header,
+ child - argp->children, cluster, argp)
+ /* Just merge it into the parent's cluster. */
+ : cluster);
+ hol_append (hol, argp_hol (child->argp, child_cluster)) ;
+ child++;
+ }
+ return hol;
+}
+
+/* Calculate how many different levels with alternative args strings exist in
+ ARGP. */
+static size_t
+argp_args_levels (const struct argp *argp)
+{
+ size_t levels = 0;
+ const struct argp_child *child = argp->children;
+
+ if (argp->args_doc && strchr (argp->args_doc, '\n'))
+ levels++;
+
+ if (child)
+ while (child->argp)
+ levels += argp_args_levels ((child++)->argp);
+
+ return levels;
+}
+
+/* Print all the non-option args documented in ARGP to STREAM. Any output is
+ preceded by a space. LEVELS is a pointer to a byte vector the length
+ returned by argp_args_levels; it should be initialized to zero, and
+ updated by this routine for the next call if ADVANCE is true. True is
+ returned as long as there are more patterns to output. */
+static int
+argp_args_usage (const struct argp *argp, const struct argp_state *state,
+ char **levels, int advance, argp_fmtstream_t stream)
+{
+ char *our_level = *levels;
+ int multiple = 0;
+ const struct argp_child *child = argp->children;
+ const char *tdoc = dgettext (argp->argp_domain, argp->args_doc), *nl = 0;
+ const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC, argp, state);
+
+ if (fdoc)
+ {
+ const char *cp = fdoc;
+ nl = __strchrnul (cp, '\n');
+ if (*nl != '\0')
+ /* This is a 'multi-level' args doc; advance to the correct position
+ as determined by our state in LEVELS, and update LEVELS. */
+ {
+ int i;
+ multiple = 1;
+ for (i = 0; i < *our_level; i++)
+ cp = nl + 1, nl = __strchrnul (cp, '\n');
+ (*levels)++;
+ }
+
+ /* Manually do line wrapping so that it (probably) won't get wrapped at
+ any embedded spaces. */
+ space (stream, 1 + mbsnwidth (cp, nl - cp, MBSW_STOP_AT_NUL));
+
+ __argp_fmtstream_write (stream, cp, nl - cp);
+ }
+ if (fdoc && fdoc != tdoc)
+ free ((char *)fdoc); /* Free user's modified doc string. */
+
+ if (child)
+ while (child->argp)
+ advance = !argp_args_usage ((child++)->argp, state, levels, advance, stream);
+
+ if (advance && multiple)
+ {
+ /* Need to increment our level. */
+ if (*nl)
+ /* There's more we can do here. */
+ {
+ (*our_level)++;
+ advance = 0; /* Our parent shouldn't advance also. */
+ }
+ else if (*our_level > 0)
+ /* We had multiple levels, but used them up; reset to zero. */
+ *our_level = 0;
+ }
+
+ return !advance;
+}
+
+/* Print the documentation for ARGP to STREAM; if POST is false, then
+ everything preceding a '\v' character in the documentation strings (or
+ the whole string, for those with none) is printed, otherwise, everything
+ following the '\v' character (nothing for strings without). Each separate
+ bit of documentation is separated a blank line, and if PRE_BLANK is true,
+ then the first is as well. If FIRST_ONLY is true, only the first
+ occurrence is output. Returns true if anything was output. */
+static int
+argp_doc (const struct argp *argp, const struct argp_state *state,
+ int post, int pre_blank, int first_only,
+ argp_fmtstream_t stream)
+{
+ const char *text;
+ const char *inp_text;
+ void *input = 0;
+ int anything = 0;
+ size_t inp_text_limit = 0;
+ const char *doc = dgettext (argp->argp_domain, argp->doc);
+ const struct argp_child *child = argp->children;
+
+ if (doc)
+ {
+ char *vt = strchr (doc, '\v');
+ inp_text = post ? (vt ? vt + 1 : 0) : doc;
+ inp_text_limit = (!post && vt) ? (vt - doc) : 0;
+ }
+ else
+ inp_text = 0;
+
+ if (argp->help_filter)
+ /* We have to filter the doc strings. */
+ {
+ if (inp_text_limit)
+ /* Copy INP_TEXT so that it's nul-terminated. */
+ inp_text = __strndup (inp_text, inp_text_limit);
+ input = __argp_input (argp, state);
+ text =
+ (*argp->help_filter) (post
+ ? ARGP_KEY_HELP_POST_DOC
+ : ARGP_KEY_HELP_PRE_DOC,
+ inp_text, input);
+ }
+ else
+ text = (const char *) inp_text;
+
+ if (text)
+ {
+ if (pre_blank)
+ __argp_fmtstream_putc (stream, '\n');
+
+ if (text == inp_text && inp_text_limit)
+ __argp_fmtstream_write (stream, inp_text, inp_text_limit);
+ else
+ __argp_fmtstream_puts (stream, text);
+
+ if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream))
+ __argp_fmtstream_putc (stream, '\n');
+
+ anything = 1;
+ }
+
+ if (text && text != inp_text)
+ free ((char *) text); /* Free TEXT returned from the help filter. */
+ if (inp_text && inp_text_limit && argp->help_filter)
+ free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */
+
+ if (post && argp->help_filter)
+ /* Now see if we have to output a ARGP_KEY_HELP_EXTRA text. */
+ {
+ text = (*argp->help_filter) (ARGP_KEY_HELP_EXTRA, 0, input);
+ if (text)
+ {
+ if (anything || pre_blank)
+ __argp_fmtstream_putc (stream, '\n');
+ __argp_fmtstream_puts (stream, text);
+ free ((char *) text);
+ if (__argp_fmtstream_point (stream)
+ > __argp_fmtstream_lmargin (stream))
+ __argp_fmtstream_putc (stream, '\n');
+ anything = 1;
+ }
+ }
+
+ if (child)
+ while (child->argp && !(first_only && anything))
+ anything |=
+ argp_doc ((child++)->argp, state,
+ post, anything || pre_blank, first_only,
+ stream);
+
+ return anything;
+}
+
+/* Output a usage message for ARGP to STREAM. If called from
+ argp_state_help, STATE is the relevent parsing state. FLAGS are from the
+ set ARGP_HELP_*. NAME is what to use wherever a 'program name' is
+ needed. */
+static void
+_help (const struct argp *argp, const struct argp_state *state, FILE *stream,
+ unsigned flags, char *name)
+{
+ int anything = 0; /* Whether we've output anything. */
+ struct hol *hol = 0;
+ argp_fmtstream_t fs;
+
+ if (! stream)
+ return;
+
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ __flockfile (stream);
+#endif
+
+ if (! uparams.valid)
+ fill_in_uparams (state);
+
+ fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0);
+ if (! fs)
+ {
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ __funlockfile (stream);
+#endif
+ return;
+ }
+
+ if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG))
+ {
+ hol = argp_hol (argp, 0);
+
+ /* If present, these options always come last. */
+ hol_set_group (hol, "help", -1);
+ hol_set_group (hol, "version", -1);
+
+ hol_sort (hol);
+ }
+
+ if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE))
+ /* Print a short "Usage:" message. */
+ {
+ int first_pattern = 1, more_patterns;
+ size_t num_pattern_levels = argp_args_levels (argp);
+ char *pattern_levels = alloca (num_pattern_levels);
+
+ memset (pattern_levels, 0, num_pattern_levels);
+
+ do
+ {
+ int old_lm;
+ int old_wm = __argp_fmtstream_set_wmargin (fs, uparams.usage_indent);
+ char *levels = pattern_levels;
+
+ if (first_pattern)
+ __argp_fmtstream_printf (fs, "%s %s",
+ dgettext (argp->argp_domain, "Usage:"),
+ name);
+ else
+ __argp_fmtstream_printf (fs, "%s %s",
+ dgettext (argp->argp_domain, " or: "),
+ name);
+
+ /* We set the lmargin as well as the wmargin, because hol_usage
+ manually wraps options with newline to avoid annoying breaks. */
+ old_lm = __argp_fmtstream_set_lmargin (fs, uparams.usage_indent);
+
+ if (flags & ARGP_HELP_SHORT_USAGE)
+ /* Just show where the options go. */
+ {
+ if (hol->num_entries > 0)
+ __argp_fmtstream_puts (fs, dgettext (argp->argp_domain,
+ " [OPTION...]"));
+ }
+ else
+ /* Actually print the options. */
+ {
+ hol_usage (hol, fs);
+ flags |= ARGP_HELP_SHORT_USAGE; /* But only do so once. */
+ }
+
+ more_patterns = argp_args_usage (argp, state, &levels, 1, fs);
+
+ __argp_fmtstream_set_wmargin (fs, old_wm);
+ __argp_fmtstream_set_lmargin (fs, old_lm);
+
+ __argp_fmtstream_putc (fs, '\n');
+ anything = 1;
+
+ first_pattern = 0;
+ }
+ while (more_patterns);
+ }
+
+ if (flags & ARGP_HELP_PRE_DOC)
+ anything |= argp_doc (argp, state, 0, 0, 1, fs);
+
+ if (flags & ARGP_HELP_SEE)
+ {
+ __argp_fmtstream_printf (fs, dgettext (argp->argp_domain, "\
+Try '%s --help' or '%s --usage' for more information.\n"),
+ name, name);
+ anything = 1;
+ }
+
+ if (flags & ARGP_HELP_LONG)
+ /* Print a long, detailed help message. */
+ {
+ /* Print info about all the options. */
+ if (hol->num_entries > 0)
+ {
+ if (anything)
+ __argp_fmtstream_putc (fs, '\n');
+ hol_help (hol, state, fs);
+ anything = 1;
+ }
+ }
+
+ if (flags & ARGP_HELP_POST_DOC)
+ /* Print any documentation strings at the end. */
+ anything |= argp_doc (argp, state, 1, anything, 0, fs);
+
+ if ((flags & ARGP_HELP_BUG_ADDR) && argp_program_bug_address)
+ {
+ if (anything)
+ __argp_fmtstream_putc (fs, '\n');
+ __argp_fmtstream_printf (fs, dgettext (argp->argp_domain,
+ "Report bugs to %s.\n"),
+ argp_program_bug_address);
+ anything = 1;
+ }
+
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ __funlockfile (stream);
+#endif
+
+ if (hol)
+ hol_free (hol);
+
+ __argp_fmtstream_free (fs);
+}
+
+/* Output a usage message for ARGP to STREAM. FLAGS are from the set
+ ARGP_HELP_*. NAME is what to use wherever a 'program name' is needed. */
+void __argp_help (const struct argp *argp, FILE *stream,
+ unsigned flags, char *name)
+{
+ _help (argp, 0, stream, flags, name);
+}
+#ifdef weak_alias
+weak_alias (__argp_help, argp_help)
+#endif
+
+#if ! (defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME)
+char *
+__argp_short_program_name (void)
+{
+# if HAVE_DECL_PROGRAM_INVOCATION_NAME
+ char *name = strrchr (program_invocation_name, '/');
+ return name ? name + 1 : program_invocation_name;
+# else
+ /* FIXME: What now? Miles suggests that it is better to use NULL,
+ but currently the value is passed on directly to fputs_unlocked,
+ so that requires more changes. */
+# if __GNUC__
+# warning No reasonable value to return
+# endif /* __GNUC__ */
+ return "";
+# endif
+}
+#endif
+
+/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
+ from the set ARGP_HELP_*. */
+void
+__argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags)
+{
+ if ((!state || ! (state->flags & ARGP_NO_ERRS)) && stream)
+ {
+ if (state && (state->flags & ARGP_LONG_ONLY))
+ flags |= ARGP_HELP_LONG_ONLY;
+
+ _help (state ? state->root_argp : 0, state, stream, flags,
+ state ? state->name : __argp_short_program_name ());
+
+ if (!state || ! (state->flags & ARGP_NO_EXIT))
+ {
+ if (flags & ARGP_HELP_EXIT_ERR)
+ exit (argp_err_exit_status);
+ if (flags & ARGP_HELP_EXIT_OK)
+ exit (0);
+ }
+ }
+}
+#ifdef weak_alias
+weak_alias (__argp_state_help, argp_state_help)
+#endif
+
+/* If appropriate, print the printf string FMT and following args, preceded
+ by the program name and ':', to stderr, and followed by a "Try ... --help"
+ message, then exit (1). */
+void
+__argp_error (const struct argp_state *state, const char *fmt, ...)
+{
+ if (!state || !(state->flags & ARGP_NO_ERRS))
+ {
+ FILE *stream = state ? state->err_stream : stderr;
+
+ if (stream)
+ {
+ va_list ap;
+
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ __flockfile (stream);
+#endif
+
+ va_start (ap, fmt);
+
+#ifdef _LIBC
+ char *buf;
+
+ if (_IO_vasprintf (&buf, fmt, ap) < 0)
+ buf = NULL;
+
+ __fxprintf (stream, "%s: %s\n",
+ state ? state->name : __argp_short_program_name (), buf);
+
+ free (buf);
+#else
+ fputs_unlocked (state ? state->name : __argp_short_program_name (),
+ stream);
+ putc_unlocked (':', stream);
+ putc_unlocked (' ', stream);
+
+ vfprintf (stream, fmt, ap);
+
+ putc_unlocked ('\n', stream);
+#endif
+
+ __argp_state_help (state, stream, ARGP_HELP_STD_ERR);
+
+ va_end (ap);
+
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ __funlockfile (stream);
+#endif
+ }
+ }
+}
+#ifdef weak_alias
+weak_alias (__argp_error, argp_error)
+#endif
+
+/* Similar to the standard gnu error-reporting function error(), but will
+ respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
+ to STATE->err_stream. This is useful for argument parsing code that is
+ shared between program startup (when exiting is desired) and runtime
+ option parsing (when typically an error code is returned instead). The
+ difference between this function and argp_error is that the latter is for
+ *parsing errors*, and the former is for other problems that occur during
+ parsing but don't reflect a (syntactic) problem with the input. */
+void
+__argp_failure (const struct argp_state *state, int status, int errnum,
+ const char *fmt, ...)
+{
+ if (!state || !(state->flags & ARGP_NO_ERRS))
+ {
+ FILE *stream = state ? state->err_stream : stderr;
+
+ if (stream)
+ {
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ __flockfile (stream);
+#endif
+
+#ifdef _LIBC
+ __fxprintf (stream, "%s",
+ state ? state->name : __argp_short_program_name ());
+#else
+ fputs_unlocked (state ? state->name : __argp_short_program_name (),
+ stream);
+#endif
+
+ if (fmt)
+ {
+ va_list ap;
+
+ va_start (ap, fmt);
+#ifdef _LIBC
+ char *buf;
+
+ if (_IO_vasprintf (&buf, fmt, ap) < 0)
+ buf = NULL;
+
+ __fxprintf (stream, ": %s", buf);
+
+ free (buf);
+#else
+ putc_unlocked (':', stream);
+ putc_unlocked (' ', stream);
+
+ vfprintf (stream, fmt, ap);
+#endif
+
+ va_end (ap);
+ }
+
+ if (errnum)
+ {
+ char buf[200];
+
+#ifdef _LIBC
+ __fxprintf (stream, ": %s",
+ __strerror_r (errnum, buf, sizeof (buf)));
+#else
+ char const *s = NULL;
+ putc_unlocked (':', stream);
+ putc_unlocked (' ', stream);
+# if GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R
+# if !GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P
+ s = __strerror_r (errnum, buf, sizeof buf);
+# else
+ if (__strerror_r (errnum, buf, sizeof buf) == 0)
+ s = buf;
+# endif
+# endif
+ if (! s && ! (s = strerror (errnum)))
+ s = dgettext (state->root_argp->argp_domain,
+ "Unknown system error");
+ fputs_unlocked (s, stream);
+#endif
+ }
+
+#if _LIBC
+ if (_IO_fwide (stream, 0) > 0)
+ putwc_unlocked (L'\n', stream);
+ else
+#endif
+ putc_unlocked ('\n', stream);
+
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ __funlockfile (stream);
+#endif
+
+ if (status && (!state || !(state->flags & ARGP_NO_EXIT)))
+ exit (status);
+ }
+ }
+}
+#ifdef weak_alias
+weak_alias (__argp_failure, argp_failure)
+#endif
diff --git a/grub-core/lib/gnulib/argp-namefrob.h b/grub-core/lib/gnulib/argp-namefrob.h
new file mode 100644
index 0000000..2fb9ac4
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-namefrob.h
@@ -0,0 +1,157 @@
+/* Name frobnication for compiling argp outside of glibc
+ Copyright (C) 1997-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#if !_LIBC
+/* This code is written for inclusion in gnu-libc, and uses names in the
+ namespace reserved for libc. If we're not compiling in libc, define those
+ names to be the normal ones instead. */
+
+/* argp-parse functions */
+#undef __argp_parse
+#define __argp_parse argp_parse
+#undef __option_is_end
+#define __option_is_end _option_is_end
+#undef __option_is_short
+#define __option_is_short _option_is_short
+#undef __argp_input
+#define __argp_input _argp_input
+
+/* argp-help functions */
+#undef __argp_help
+#define __argp_help argp_help
+#undef __argp_error
+#define __argp_error argp_error
+#undef __argp_failure
+#define __argp_failure argp_failure
+#undef __argp_state_help
+#define __argp_state_help argp_state_help
+#undef __argp_usage
+#define __argp_usage argp_usage
+
+/* argp-fmtstream functions */
+#undef __argp_make_fmtstream
+#define __argp_make_fmtstream argp_make_fmtstream
+#undef __argp_fmtstream_free
+#define __argp_fmtstream_free argp_fmtstream_free
+#undef __argp_fmtstream_putc
+#define __argp_fmtstream_putc argp_fmtstream_putc
+#undef __argp_fmtstream_puts
+#define __argp_fmtstream_puts argp_fmtstream_puts
+#undef __argp_fmtstream_write
+#define __argp_fmtstream_write argp_fmtstream_write
+#undef __argp_fmtstream_printf
+#define __argp_fmtstream_printf argp_fmtstream_printf
+#undef __argp_fmtstream_set_lmargin
+#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
+#undef __argp_fmtstream_set_rmargin
+#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
+#undef __argp_fmtstream_set_wmargin
+#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
+#undef __argp_fmtstream_point
+#define __argp_fmtstream_point argp_fmtstream_point
+#undef __argp_fmtstream_update
+#define __argp_fmtstream_update _argp_fmtstream_update
+#undef __argp_fmtstream_ensure
+#define __argp_fmtstream_ensure _argp_fmtstream_ensure
+#undef __argp_fmtstream_lmargin
+#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
+#undef __argp_fmtstream_rmargin
+#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
+#undef __argp_fmtstream_wmargin
+#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
+
+/* normal libc functions we call */
+#undef __flockfile
+#define __flockfile flockfile
+#undef __funlockfile
+#define __funlockfile funlockfile
+#undef __mempcpy
+#define __mempcpy mempcpy
+#undef __sleep
+#define __sleep sleep
+#undef __strcasecmp
+#define __strcasecmp strcasecmp
+#undef __strchrnul
+#define __strchrnul strchrnul
+#undef __strerror_r
+#define __strerror_r strerror_r
+#undef __strndup
+#define __strndup strndup
+#undef __vsnprintf
+#define __vsnprintf vsnprintf
+
+#if defined(HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED
+# define clearerr_unlocked(x) clearerr (x)
+#endif
+#if defined(HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED
+# define feof_unlocked(x) feof (x)
+#endif
+#if defined(HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED
+# define ferror_unlocked(x) ferror (x)
+#endif
+#if defined(HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED
+# define fflush_unlocked(x) fflush (x)
+#endif
+#if defined(HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED
+# define fgets_unlocked(x,y,z) fgets (x,y,z)
+#endif
+#if defined(HAVE_DECL_FPUTC_UNLOCKED) && !HAVE_DECL_FPUTC_UNLOCKED
+# define fputc_unlocked(x,y) fputc (x,y)
+#endif
+#if defined(HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
+# define fputs_unlocked(x,y) fputs (x,y)
+#endif
+#if defined(HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED
+# define fread_unlocked(w,x,y,z) fread (w,x,y,z)
+#endif
+#if defined(HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED
+# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
+#endif
+#if defined(HAVE_DECL_GETC_UNLOCKED) && !HAVE_DECL_GETC_UNLOCKED
+# define getc_unlocked(x) getc (x)
+#endif
+#if defined(HAVE_DECL_GETCHAR_UNLOCKED) && !HAVE_DECL_GETCHAR_UNLOCKED
+# define getchar_unlocked() getchar ()
+#endif
+#if defined(HAVE_DECL_PUTC_UNLOCKED) && !HAVE_DECL_PUTC_UNLOCKED
+# define putc_unlocked(x,y) putc (x,y)
+#endif
+#if defined(HAVE_DECL_PUTCHAR_UNLOCKED) && !HAVE_DECL_PUTCHAR_UNLOCKED
+# define putchar_unlocked(x) putchar (x)
+#endif
+
+#endif /* !_LIBC */
+
+#ifndef __set_errno
+#define __set_errno(e) (errno = (e))
+#endif
+
+#if defined GNULIB_ARGP_DISABLE_DIRNAME
+# define __argp_base_name(arg) arg
+#elif defined GNULIB_ARGP_EXTERN_BASENAME
+extern char *__argp_base_name (const char *arg);
+#else
+# include "dirname.h"
+# define __argp_base_name last_component
+#endif
+
+#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+# define __argp_short_program_name() (program_invocation_short_name)
+#else
+extern char *__argp_short_program_name (void);
+#endif
diff --git a/grub-core/lib/gnulib/argp-parse.c b/grub-core/lib/gnulib/argp-parse.c
new file mode 100644
index 0000000..900adad
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-parse.c
@@ -0,0 +1,957 @@
+/* Hierarchical argument parsing, layered over getopt
+ Copyright (C) 1995-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <alloca.h>
+#include <stdalign.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <getopt.h>
+#include <getopt_int.h>
+
+#ifdef _LIBC
+# include <libintl.h>
+# undef dgettext
+# define dgettext(domain, msgid) \
+ __dcgettext (domain, msgid, LC_MESSAGES)
+#else
+# include "gettext.h"
+#endif
+#define N_(msgid) msgid
+
+#include "argp.h"
+#include "argp-namefrob.h"
+
+#define alignto(n, d) ((((n) + (d) - 1) / (d)) * (d))
+
+/* Getopt return values. */
+#define KEY_END (-1) /* The end of the options. */
+#define KEY_ARG 1 /* A non-option argument. */
+#define KEY_ERR '?' /* An error parsing the options. */
+
+/* The meta-argument used to prevent any further arguments being interpreted
+ as options. */
+#define QUOTE "--"
+
+/* The number of bits we steal in a long-option value for our own use. */
+#define GROUP_BITS CHAR_BIT
+
+/* The number of bits available for the user value. */
+#define USER_BITS ((sizeof ((struct option *)0)->val * CHAR_BIT) - GROUP_BITS)
+#define USER_MASK ((1 << USER_BITS) - 1)
+
+/* EZ alias for ARGP_ERR_UNKNOWN. */
+#define EBADKEY ARGP_ERR_UNKNOWN
+
+/* Default options. */
+
+/* When argp is given the --HANG switch, _ARGP_HANG is set and argp will sleep
+ for one second intervals, decrementing _ARGP_HANG until it's zero. Thus
+ you can force the program to continue by attaching a debugger and setting
+ it to 0 yourself. */
+static volatile int _argp_hang;
+
+#define OPT_PROGNAME -2
+#define OPT_USAGE -3
+#define OPT_HANG -4
+
+static const struct argp_option argp_default_options[] =
+{
+ {"help", '?', 0, 0, N_("give this help list"), -1},
+ {"usage", OPT_USAGE, 0, 0, N_("give a short usage message"), 0},
+ {"program-name",OPT_PROGNAME, N_("NAME"), OPTION_HIDDEN,
+ N_("set the program name"), 0},
+ {"HANG", OPT_HANG, N_("SECS"), OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
+ N_("hang for SECS seconds (default 3600)"), 0},
+ {NULL, 0, 0, 0, NULL, 0}
+};
+
+static error_t
+argp_default_parser (int key, char *arg, struct argp_state *state)
+{
+ switch (key)
+ {
+ case '?':
+ __argp_state_help (state, state->out_stream, ARGP_HELP_STD_HELP);
+ break;
+ case OPT_USAGE:
+ __argp_state_help (state, state->out_stream,
+ ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
+ break;
+
+ case OPT_PROGNAME: /* Set the program name. */
+#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_NAME
+ program_invocation_name = arg;
+#endif
+ /* [Note that some systems only have PROGRAM_INVOCATION_SHORT_NAME (aka
+ __PROGNAME), in which case, PROGRAM_INVOCATION_NAME is just defined
+ to be that, so we have to be a bit careful here.] */
+
+ /* Update what we use for messages. */
+ state->name = __argp_base_name (arg);
+
+#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+ program_invocation_short_name = state->name;
+#endif
+
+ if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS))
+ == ARGP_PARSE_ARGV0)
+ /* Update what getopt uses too. */
+ state->argv[0] = arg;
+
+ break;
+
+ case OPT_HANG:
+ _argp_hang = atoi (arg ? arg : "3600");
+ while (_argp_hang-- > 0)
+ __sleep (1);
+ break;
+
+ default:
+ return EBADKEY;
+ }
+ return 0;
+}
+
+static const struct argp argp_default_argp =
+ {argp_default_options, &argp_default_parser, NULL, NULL, NULL, NULL, "libc"};
+
+
+static const struct argp_option argp_version_options[] =
+{
+ {"version", 'V', 0, 0, N_("print program version"), -1},
+ {NULL, 0, 0, 0, NULL, 0}
+};
+
+static error_t
+argp_version_parser (int key, char *arg, struct argp_state *state)
+{
+ switch (key)
+ {
+ case 'V':
+ if (argp_program_version_hook)
+ (*argp_program_version_hook) (state->out_stream, state);
+ else if (argp_program_version)
+ fprintf (state->out_stream, "%s\n", argp_program_version);
+ else
+ __argp_error (state, "%s",
+ dgettext (state->root_argp->argp_domain,
+ "(PROGRAM ERROR) No version known!?"));
+ if (! (state->flags & ARGP_NO_EXIT))
+ exit (0);
+ break;
+ default:
+ return EBADKEY;
+ }
+ return 0;
+}
+
+static const struct argp argp_version_argp =
+ {argp_version_options, &argp_version_parser, NULL, NULL, NULL, NULL, "libc"};
+
+/* Returns the offset into the getopt long options array LONG_OPTIONS of a
+ long option with called NAME, or -1 if none is found. Passing NULL as
+ NAME will return the number of options. */
+static int
+find_long_option (struct option *long_options, const char *name)
+{
+ struct option *l = long_options;
+ while (l->name != NULL)
+ if (name != NULL && strcmp (l->name, name) == 0)
+ return l - long_options;
+ else
+ l++;
+ if (name == NULL)
+ return l - long_options;
+ else
+ return -1;
+}
+
+
+/* The state of a "group" during parsing. Each group corresponds to a
+ particular argp structure from the tree of such descending from the top
+ level argp passed to argp_parse. */
+struct group
+{
+ /* This group's parsing function. */
+ argp_parser_t parser;
+
+ /* Which argp this group is from. */
+ const struct argp *argp;
+
+ /* Points to the point in SHORT_OPTS corresponding to the end of the short
+ options for this group. We use it to determine from which group a
+ particular short options is from. */
+ char *short_end;
+
+ /* The number of non-option args successfully handled by this parser. */
+ unsigned args_processed;
+
+ /* This group's parser's parent's group. */
+ struct group *parent;
+ unsigned parent_index; /* And the our position in the parent. */
+
+ /* These fields are swapped into and out of the state structure when
+ calling this group's parser. */
+ void *input, **child_inputs;
+ void *hook;
+};
+
+/* Call GROUP's parser with KEY and ARG, swapping any group-specific info
+ from STATE before calling, and back into state afterwards. If GROUP has
+ no parser, EBADKEY is returned. */
+static error_t
+group_parse (struct group *group, struct argp_state *state, int key, char *arg)
+{
+ if (group->parser)
+ {
+ error_t err;
+ state->hook = group->hook;
+ state->input = group->input;
+ state->child_inputs = group->child_inputs;
+ state->arg_num = group->args_processed;
+ err = (*group->parser)(key, arg, state);
+ group->hook = state->hook;
+ return err;
+ }
+ else
+ return EBADKEY;
+}
+
+struct parser
+{
+ const struct argp *argp;
+
+ /* SHORT_OPTS is the getopt short options string for the union of all the
+ groups of options. */
+ char *short_opts;
+ /* LONG_OPTS is the array of getop long option structures for the union of
+ all the groups of options. */
+ struct option *long_opts;
+ /* OPT_DATA is the getopt data used for the re-entrant getopt. */
+ struct _getopt_data opt_data;
+
+ /* States of the various parsing groups. */
+ struct group *groups;
+ /* The end of the GROUPS array. */
+ struct group *egroup;
+ /* A vector containing storage for the CHILD_INPUTS field in all groups. */
+ void **child_inputs;
+
+ /* True if we think using getopt is still useful; if false, then
+ remaining arguments are just passed verbatim with ARGP_KEY_ARG. This is
+ cleared whenever getopt returns KEY_END, but may be set again if the user
+ moves the next argument pointer backwards. */
+ int try_getopt;
+
+ /* State block supplied to parsing routines. */
+ struct argp_state state;
+
+ /* Memory used by this parser. */
+ void *storage;
+};
+
+/* The next usable entries in the various parser tables being filled in by
+ convert_options. */
+struct parser_convert_state
+{
+ struct parser *parser;
+ char *short_end;
+ struct option *long_end;
+ void **child_inputs_end;
+};
+
+/* Converts all options in ARGP (which is put in GROUP) and ancestors
+ into getopt options stored in SHORT_OPTS and LONG_OPTS; SHORT_END and
+ CVT->LONG_END are the points at which new options are added. Returns the
+ next unused group entry. CVT holds state used during the conversion. */
+static struct group *
+convert_options (const struct argp *argp,
+ struct group *parent, unsigned parent_index,
+ struct group *group, struct parser_convert_state *cvt)
+{
+ /* REAL is the most recent non-alias value of OPT. */
+ const struct argp_option *real = argp->options;
+ const struct argp_child *children = argp->children;
+
+ if (real || argp->parser)
+ {
+ const struct argp_option *opt;
+
+ if (real)
+ for (opt = real; !__option_is_end (opt); opt++)
+ {
+ if (! (opt->flags & OPTION_ALIAS))
+ /* OPT isn't an alias, so we can use values from it. */
+ real = opt;
+
+ if (! (real->flags & OPTION_DOC))
+ /* A real option (not just documentation). */
+ {
+ if (__option_is_short (opt))
+ /* OPT can be used as a short option. */
+ {
+ *cvt->short_end++ = opt->key;
+ if (real->arg)
+ {
+ *cvt->short_end++ = ':';
+ if (real->flags & OPTION_ARG_OPTIONAL)
+ *cvt->short_end++ = ':';
+ }
+ *cvt->short_end = '\0'; /* keep 0 terminated */
+ }
+
+ if (opt->name
+ && find_long_option (cvt->parser->long_opts, opt->name) < 0)
+ /* OPT can be used as a long option. */
+ {
+ cvt->long_end->name = opt->name;
+ cvt->long_end->has_arg =
+ (real->arg
+ ? (real->flags & OPTION_ARG_OPTIONAL
+ ? optional_argument
+ : required_argument)
+ : no_argument);
+ cvt->long_end->flag = 0;
+ /* we add a disambiguating code to all the user's
+ values (which is removed before we actually call
+ the function to parse the value); this means that
+ the user loses use of the high 8 bits in all his
+ values (the sign of the lower bits is preserved
+ however)... */
+ cvt->long_end->val =
+ ((opt->key ? opt->key : real->key) & USER_MASK)
+ + (((group - cvt->parser->groups) + 1) << USER_BITS);
+
+ /* Keep the LONG_OPTS list terminated. */
+ (++cvt->long_end)->name = NULL;
+ }
+ }
+ }
+
+ group->parser = argp->parser;
+ group->argp = argp;
+ group->short_end = cvt->short_end;
+ group->args_processed = 0;
+ group->parent = parent;
+ group->parent_index = parent_index;
+ group->input = 0;
+ group->hook = 0;
+ group->child_inputs = 0;
+
+ if (children)
+ /* Assign GROUP's CHILD_INPUTS field some space from
+ CVT->child_inputs_end.*/
+ {
+ unsigned num_children = 0;
+ while (children[num_children].argp)
+ num_children++;
+ group->child_inputs = cvt->child_inputs_end;
+ cvt->child_inputs_end += num_children;
+ }
+
+ parent = group++;
+ }
+ else
+ parent = 0;
+
+ if (children)
+ {
+ unsigned index = 0;
+ while (children->argp)
+ group =
+ convert_options (children++->argp, parent, index++, group, cvt);
+ }
+
+ return group;
+}
+
+/* Find the merged set of getopt options, with keys appropriately prefixed. */
+static void
+parser_convert (struct parser *parser, const struct argp *argp, int flags)
+{
+ struct parser_convert_state cvt;
+
+ cvt.parser = parser;
+ cvt.short_end = parser->short_opts;
+ cvt.long_end = parser->long_opts;
+ cvt.child_inputs_end = parser->child_inputs;
+
+ if (flags & ARGP_IN_ORDER)
+ *cvt.short_end++ = '-';
+ else if (flags & ARGP_NO_ARGS)
+ *cvt.short_end++ = '+';
+ *cvt.short_end = '\0';
+
+ cvt.long_end->name = NULL;
+
+ parser->argp = argp;
+
+ if (argp)
+ parser->egroup = convert_options (argp, 0, 0, parser->groups, &cvt);
+ else
+ parser->egroup = parser->groups; /* No parsers at all! */
+}
+
+/* Lengths of various parser fields which we will allocated. */
+struct parser_sizes
+{
+ size_t short_len; /* Getopt short options string. */
+ size_t long_len; /* Getopt long options vector. */
+ size_t num_groups; /* Group structures we allocate. */
+ size_t num_child_inputs; /* Child input slots. */
+};
+
+/* For ARGP, increments the NUM_GROUPS field in SZS by the total number of
+ argp structures descended from it, and the SHORT_LEN & LONG_LEN fields by
+ the maximum lengths of the resulting merged getopt short options string and
+ long-options array, respectively. */
+static void
+calc_sizes (const struct argp *argp, struct parser_sizes *szs)
+{
+ const struct argp_child *child = argp->children;
+ const struct argp_option *opt = argp->options;
+
+ if (opt || argp->parser)
+ {
+ szs->num_groups++;
+ if (opt)
+ {
+ int num_opts = 0;
+ while (!__option_is_end (opt++))
+ num_opts++;
+ szs->short_len += num_opts * 3; /* opt + up to 2 ':'s */
+ szs->long_len += num_opts;
+ }
+ }
+
+ if (child)
+ while (child->argp)
+ {
+ calc_sizes ((child++)->argp, szs);
+ szs->num_child_inputs++;
+ }
+}
+
+/* Initializes PARSER to parse ARGP in a manner described by FLAGS. */
+static error_t
+parser_init (struct parser *parser, const struct argp *argp,
+ int argc, char **argv, int flags, void *input)
+{
+ error_t err = 0;
+ struct group *group;
+ struct parser_sizes szs;
+ struct _getopt_data opt_data = _GETOPT_DATA_INITIALIZER;
+ char *storage;
+ size_t glen, gsum;
+ size_t clen, csum;
+ size_t llen, lsum;
+ size_t slen, ssum;
+
+ szs.short_len = (flags & ARGP_NO_ARGS) ? 0 : 1;
+ szs.long_len = 0;
+ szs.num_groups = 0;
+ szs.num_child_inputs = 0;
+
+ if (argp)
+ calc_sizes (argp, &szs);
+
+ /* Lengths of the various bits of storage used by PARSER. */
+ glen = (szs.num_groups + 1) * sizeof (struct group);
+ clen = szs.num_child_inputs * sizeof (void *);
+ llen = (szs.long_len + 1) * sizeof (struct option);
+ slen = szs.short_len + 1;
+
+ /* Sums of previous lengths, properly aligned. There's no need to
+ align gsum, since struct group is aligned at least as strictly as
+ void * (since it contains a void * member). And there's no need
+ to align lsum, since struct option is aligned at least as
+ strictly as char. */
+ gsum = glen;
+ csum = alignto (gsum + clen, alignof (struct option));
+ lsum = csum + llen;
+ ssum = lsum + slen;
+
+ parser->storage = malloc (ssum);
+ if (! parser->storage)
+ return ENOMEM;
+
+ storage = parser->storage;
+ parser->groups = parser->storage;
+ parser->child_inputs = (void **) (storage + gsum);
+ parser->long_opts = (struct option *) (storage + csum);
+ parser->short_opts = storage + lsum;
+ parser->opt_data = opt_data;
+
+ memset (parser->child_inputs, 0, clen);
+ parser_convert (parser, argp, flags);
+
+ memset (&parser->state, 0, sizeof (struct argp_state));
+ parser->state.root_argp = parser->argp;
+ parser->state.argc = argc;
+ parser->state.argv = argv;
+ parser->state.flags = flags;
+ parser->state.err_stream = stderr;
+ parser->state.out_stream = stdout;
+ parser->state.next = 0; /* Tell getopt to initialize. */
+ parser->state.pstate = parser;
+
+ parser->try_getopt = 1;
+
+ /* Call each parser for the first time, giving it a chance to propagate
+ values to child parsers. */
+ if (parser->groups < parser->egroup)
+ parser->groups->input = input;
+ for (group = parser->groups;
+ group < parser->egroup && (!err || err == EBADKEY);
+ group++)
+ {
+ if (group->parent)
+ /* If a child parser, get the initial input value from the parent. */
+ group->input = group->parent->child_inputs[group->parent_index];
+
+ if (!group->parser
+ && group->argp->children && group->argp->children->argp)
+ /* For the special case where no parsing function is supplied for an
+ argp, propagate its input to its first child, if any (this just
+ makes very simple wrapper argps more convenient). */
+ group->child_inputs[0] = group->input;
+
+ err = group_parse (group, &parser->state, ARGP_KEY_INIT, 0);
+ }
+ if (err == EBADKEY)
+ err = 0; /* Some parser didn't understand. */
+
+ if (err)
+ return err;
+
+ if (parser->state.flags & ARGP_NO_ERRS)
+ {
+ parser->opt_data.opterr = 0;
+ if (parser->state.flags & ARGP_PARSE_ARGV0)
+ /* getopt always skips ARGV[0], so we have to fake it out. As long
+ as OPTERR is 0, then it shouldn't actually try to access it. */
+ parser->state.argv--, parser->state.argc++;
+ }
+ else
+ parser->opt_data.opterr = 1; /* Print error messages. */
+
+ if (parser->state.argv == argv && argv[0])
+ /* There's an argv[0]; use it for messages. */
+ parser->state.name = __argp_base_name (argv[0]);
+ else
+ parser->state.name = __argp_short_program_name ();
+
+ return 0;
+}
+
+/* Free any storage consumed by PARSER (but not PARSER itself). */
+static error_t
+parser_finalize (struct parser *parser,
+ error_t err, int arg_ebadkey, int *end_index)
+{
+ struct group *group;
+
+ if (err == EBADKEY && arg_ebadkey)
+ /* Suppress errors generated by unparsed arguments. */
+ err = 0;
+
+ if (! err)
+ {
+ if (parser->state.next == parser->state.argc)
+ /* We successfully parsed all arguments! Call all the parsers again,
+ just a few more times... */
+ {
+ for (group = parser->groups;
+ group < parser->egroup && (!err || err==EBADKEY);
+ group++)
+ if (group->args_processed == 0)
+ err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
+ for (group = parser->egroup - 1;
+ group >= parser->groups && (!err || err==EBADKEY);
+ group--)
+ err = group_parse (group, &parser->state, ARGP_KEY_END, 0);
+
+ if (err == EBADKEY)
+ err = 0; /* Some parser didn't understand. */
+
+ /* Tell the user that all arguments are parsed. */
+ if (end_index)
+ *end_index = parser->state.next;
+ }
+ else if (end_index)
+ /* Return any remaining arguments to the user. */
+ *end_index = parser->state.next;
+ else
+ /* No way to return the remaining arguments, they must be bogus. */
+ {
+ if (!(parser->state.flags & ARGP_NO_ERRS)
+ && parser->state.err_stream)
+ fprintf (parser->state.err_stream,
+ dgettext (parser->argp->argp_domain,
+ "%s: Too many arguments\n"),
+ parser->state.name);
+ err = EBADKEY;
+ }
+ }
+
+ /* Okay, we're all done, with either an error or success; call the parsers
+ to indicate which one. */
+
+ if (err)
+ {
+ /* Maybe print an error message. */
+ if (err == EBADKEY)
+ /* An appropriate message describing what the error was should have
+ been printed earlier. */
+ __argp_state_help (&parser->state, parser->state.err_stream,
+ ARGP_HELP_STD_ERR);
+
+ /* Since we didn't exit, give each parser an error indication. */
+ for (group = parser->groups; group < parser->egroup; group++)
+ group_parse (group, &parser->state, ARGP_KEY_ERROR, 0);
+ }
+ else
+ /* Notify parsers of success, and propagate back values from parsers. */
+ {
+ /* We pass over the groups in reverse order so that child groups are
+ given a chance to do there processing before passing back a value to
+ the parent. */
+ for (group = parser->egroup - 1
+ ; group >= parser->groups && (!err || err == EBADKEY)
+ ; group--)
+ err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, 0);
+ if (err == EBADKEY)
+ err = 0; /* Some parser didn't understand. */
+ }
+
+ /* Call parsers once more, to do any final cleanup. Errors are ignored. */
+ for (group = parser->egroup - 1; group >= parser->groups; group--)
+ group_parse (group, &parser->state, ARGP_KEY_FINI, 0);
+
+ if (err == EBADKEY)
+ err = EINVAL;
+
+ free (parser->storage);
+
+ return err;
+}
+
+/* Call the user parsers to parse the non-option argument VAL, at the current
+ position, returning any error. The state NEXT pointer is assumed to have
+ been adjusted (by getopt) to point after this argument; this function will
+ adjust it correctly to reflect however many args actually end up being
+ consumed. */
+static error_t
+parser_parse_arg (struct parser *parser, char *val)
+{
+ /* Save the starting value of NEXT, first adjusting it so that the arg
+ we're parsing is again the front of the arg vector. */
+ int index = --parser->state.next;
+ error_t err = EBADKEY;
+ struct group *group;
+ int key = 0; /* Which of ARGP_KEY_ARG[S] we used. */
+
+ /* Try to parse the argument in each parser. */
+ for (group = parser->groups
+ ; group < parser->egroup && err == EBADKEY
+ ; group++)
+ {
+ parser->state.next++; /* For ARGP_KEY_ARG, consume the arg. */
+ key = ARGP_KEY_ARG;
+ err = group_parse (group, &parser->state, key, val);
+
+ if (err == EBADKEY)
+ /* This parser doesn't like ARGP_KEY_ARG; try ARGP_KEY_ARGS instead. */
+ {
+ parser->state.next--; /* For ARGP_KEY_ARGS, put back the arg. */
+ key = ARGP_KEY_ARGS;
+ err = group_parse (group, &parser->state, key, 0);
+ }
+ }
+
+ if (! err)
+ {
+ if (key == ARGP_KEY_ARGS)
+ /* The default for ARGP_KEY_ARGS is to assume that if NEXT isn't
+ changed by the user, *all* arguments should be considered
+ consumed. */
+ parser->state.next = parser->state.argc;
+
+ if (parser->state.next > index)
+ /* Remember that we successfully processed a non-option
+ argument -- but only if the user hasn't gotten tricky and set
+ the clock back. */
+ (--group)->args_processed += (parser->state.next - index);
+ else
+ /* The user wants to reparse some args, give getopt another try. */
+ parser->try_getopt = 1;
+ }
+
+ return err;
+}
+
+/* Call the user parsers to parse the option OPT, with argument VAL, at the
+ current position, returning any error. */
+static error_t
+parser_parse_opt (struct parser *parser, int opt, char *val)
+{
+ /* The group key encoded in the high bits; 0 for short opts or
+ group_number + 1 for long opts. */
+ int group_key = opt >> USER_BITS;
+ error_t err = EBADKEY;
+
+ if (group_key == 0)
+ /* A short option. By comparing OPT's position in SHORT_OPTS to the
+ various starting positions in each group's SHORT_END field, we can
+ determine which group OPT came from. */
+ {
+ struct group *group;
+ char *short_index = strchr (parser->short_opts, opt);
+
+ if (short_index)
+ for (group = parser->groups; group < parser->egroup; group++)
+ if (group->short_end > short_index)
+ {
+ err = group_parse (group, &parser->state, opt,
+ parser->opt_data.optarg);
+ break;
+ }
+ }
+ else
+ /* A long option. Preserve the sign in the user key, without
+ invoking undefined behavior. Assume two's complement. */
+ {
+ int user_key =
+ ((opt & (1 << (USER_BITS - 1))) ? ~USER_MASK : 0) | (opt & USER_MASK);
+ err =
+ group_parse (&parser->groups[group_key - 1], &parser->state,
+ user_key, parser->opt_data.optarg);
+ }
+
+ if (err == EBADKEY)
+ /* At least currently, an option not recognized is an error in the
+ parser, because we pre-compute which parser is supposed to deal
+ with each option. */
+ {
+ static const char bad_key_err[] =
+ N_("(PROGRAM ERROR) Option should have been recognized!?");
+ if (group_key == 0)
+ __argp_error (&parser->state, "-%c: %s", opt,
+ dgettext (parser->argp->argp_domain, bad_key_err));
+ else
+ {
+ struct option *long_opt = parser->long_opts;
+ while (long_opt->val != opt && long_opt->name)
+ long_opt++;
+ __argp_error (&parser->state, "--%s: %s",
+ long_opt->name ? long_opt->name : "???",
+ dgettext (parser->argp->argp_domain, bad_key_err));
+ }
+ }
+
+ return err;
+}
+
+/* Parse the next argument in PARSER (as indicated by PARSER->state.next).
+ Any error from the parsers is returned, and *ARGP_EBADKEY indicates
+ whether a value of EBADKEY is due to an unrecognized argument (which is
+ generally not fatal). */
+static error_t
+parser_parse_next (struct parser *parser, int *arg_ebadkey)
+{
+ int opt;
+ error_t err = 0;
+
+ if (parser->state.quoted && parser->state.next < parser->state.quoted)
+ /* The next argument pointer has been moved to before the quoted
+ region, so pretend we never saw the quoting "--", and give getopt
+ another chance. If the user hasn't removed it, getopt will just
+ process it again. */
+ parser->state.quoted = 0;
+
+ if (parser->try_getopt && !parser->state.quoted)
+ /* Give getopt a chance to parse this. */
+ {
+ /* Put it back in OPTIND for getopt. */
+ parser->opt_data.optind = parser->state.next;
+ /* Distinguish KEY_ERR from a real option. */
+ parser->opt_data.optopt = KEY_END;
+ if (parser->state.flags & ARGP_LONG_ONLY)
+ opt = _getopt_long_only_r (parser->state.argc, parser->state.argv,
+ parser->short_opts, parser->long_opts, 0,
+ &parser->opt_data);
+ else
+ opt = _getopt_long_r (parser->state.argc, parser->state.argv,
+ parser->short_opts, parser->long_opts, 0,
+ &parser->opt_data);
+ /* And see what getopt did. */
+ parser->state.next = parser->opt_data.optind;
+
+ if (opt == KEY_END)
+ /* Getopt says there are no more options, so stop using
+ getopt; we'll continue if necessary on our own. */
+ {
+ parser->try_getopt = 0;
+ if (parser->state.next > 1
+ && strcmp (parser->state.argv[parser->state.next - 1], QUOTE)
+ == 0)
+ /* Not only is this the end of the options, but it's a
+ "quoted" region, which may have args that *look* like
+ options, so we definitely shouldn't try to use getopt past
+ here, whatever happens. */
+ parser->state.quoted = parser->state.next;
+ }
+ else if (opt == KEY_ERR && parser->opt_data.optopt != KEY_END)
+ /* KEY_ERR can have the same value as a valid user short
+ option, but in the case of a real error, getopt sets OPTOPT
+ to the offending character, which can never be KEY_END. */
+ {
+ *arg_ebadkey = 0;
+ return EBADKEY;
+ }
+ }
+ else
+ opt = KEY_END;
+
+ if (opt == KEY_END)
+ {
+ /* We're past what getopt considers the options. */
+ if (parser->state.next >= parser->state.argc
+ || (parser->state.flags & ARGP_NO_ARGS))
+ /* Indicate that we're done. */
+ {
+ *arg_ebadkey = 1;
+ return EBADKEY;
+ }
+ else
+ /* A non-option arg; simulate what getopt might have done. */
+ {
+ opt = KEY_ARG;
+ parser->opt_data.optarg = parser->state.argv[parser->state.next++];
+ }
+ }
+
+ if (opt == KEY_ARG)
+ /* A non-option argument; try each parser in turn. */
+ err = parser_parse_arg (parser, parser->opt_data.optarg);
+ else
+ err = parser_parse_opt (parser, opt, parser->opt_data.optarg);
+
+ if (err == EBADKEY)
+ *arg_ebadkey = (opt == KEY_END || opt == KEY_ARG);
+
+ return err;
+}
+
+/* Parse the options strings in ARGC & ARGV according to the argp in ARGP.
+ FLAGS is one of the ARGP_ flags above. If END_INDEX is non-NULL, the
+ index in ARGV of the first unparsed option is returned in it. If an
+ unknown option is present, EINVAL is returned; if some parser routine
+ returned a non-zero value, it is returned; otherwise 0 is returned. */
+error_t
+__argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
+ int *end_index, void *input)
+{
+ error_t err;
+ struct parser parser;
+
+ /* If true, then err == EBADKEY is a result of a non-option argument failing
+ to be parsed (which in some cases isn't actually an error). */
+ int arg_ebadkey = 0;
+
+#ifndef _LIBC
+ if (!(flags & ARGP_PARSE_ARGV0))
+ {
+#if HAVE_DECL_PROGRAM_INVOCATION_NAME
+ if (!program_invocation_name)
+ program_invocation_name = argv[0];
+#endif
+#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+ if (!program_invocation_short_name)
+ program_invocation_short_name = __argp_base_name (argv[0]);
+#endif
+ }
+#endif
+
+ if (! (flags & ARGP_NO_HELP))
+ /* Add our own options. */
+ {
+ struct argp_child *child = alloca (4 * sizeof (struct argp_child));
+ struct argp *top_argp = alloca (sizeof (struct argp));
+
+ /* TOP_ARGP has no options, it just serves to group the user & default
+ argps. */
+ memset (top_argp, 0, sizeof (*top_argp));
+ top_argp->children = child;
+
+ memset (child, 0, 4 * sizeof (struct argp_child));
+
+ if (argp)
+ (child++)->argp = argp;
+ (child++)->argp = &argp_default_argp;
+ if (argp_program_version || argp_program_version_hook)
+ (child++)->argp = &argp_version_argp;
+ child->argp = 0;
+
+ argp = top_argp;
+ }
+
+ /* Construct a parser for these arguments. */
+ err = parser_init (&parser, argp, argc, argv, flags, input);
+
+ if (! err)
+ /* Parse! */
+ {
+ while (! err)
+ err = parser_parse_next (&parser, &arg_ebadkey);
+ err = parser_finalize (&parser, err, arg_ebadkey, end_index);
+ }
+
+ return err;
+}
+#ifdef weak_alias
+weak_alias (__argp_parse, argp_parse)
+#endif
+
+/* Return the input field for ARGP in the parser corresponding to STATE; used
+ by the help routines. */
+void *
+__argp_input (const struct argp *argp, const struct argp_state *state)
+{
+ if (state && state->pstate)
+ {
+ struct group *group;
+ struct parser *parser = state->pstate;
+
+ for (group = parser->groups; group < parser->egroup; group++)
+ if (group->argp == argp)
+ return group->input;
+ }
+
+ return 0;
+}
+#ifdef weak_alias
+weak_alias (__argp_input, _argp_input)
+#endif
diff --git a/grub-core/lib/gnulib/argp-pin.c b/grub-core/lib/gnulib/argp-pin.c
new file mode 100644
index 0000000..ece7423
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-pin.c
@@ -0,0 +1,33 @@
+/* Full and short program names for argp module
+ Copyright (C) 2005, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
+char *program_invocation_short_name = 0;
+#endif
+#ifndef HAVE_PROGRAM_INVOCATION_NAME
+char *program_invocation_name = 0;
+#endif
+
+#if (defined HAVE_PROGRAM_INVOCATION_SHORT_NAME \
+ && defined HAVE_PROGRAM_INVOCATION_NAME)
+/* This declaration is solely to ensure that after preprocessing
+ this file is never empty. */
+typedef int dummy;
+#endif
diff --git a/grub-core/lib/gnulib/argp-pv.c b/grub-core/lib/gnulib/argp-pv.c
new file mode 100644
index 0000000..f76b365
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-pv.c
@@ -0,0 +1,33 @@
+/* Default definition for ARGP_PROGRAM_VERSION.
+ Copyright (C) 1996-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+/* If set by the user program to a non-zero value, then a default option
+ --version is added (unless the ARGP_NO_HELP flag is used), which will
+ print this string followed by a newline and exit (unless the
+ ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
+const char *argp_program_version
+/* This variable should be zero-initialized. On most systems, putting it into
+ BSS is sufficient. Not so on Mac OS X 10.3 and 10.4, see
+ <https://lists.gnu.org/r/bug-gnulib/2009-01/msg00329.html>
+ <https://lists.gnu.org/r/bug-gnulib/2009-08/msg00096.html>. */
+#if defined __ELF__
+ /* On ELF systems, variables in BSS behave well. */
+#else
+ = (const char *) 0
+#endif
+ ;
diff --git a/grub-core/lib/gnulib/argp-pvh.c b/grub-core/lib/gnulib/argp-pvh.c
new file mode 100644
index 0000000..be73e33
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-pvh.c
@@ -0,0 +1,30 @@
+/* Default definition for ARGP_PROGRAM_VERSION_HOOK.
+ Copyright (C) 1996-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "argp.h"
+
+/* If set by the user program to a non-zero value, then a default option
+ --version is added (unless the ARGP_NO_HELP flag is used), which calls
+ this function with a stream to print the version to and a pointer to the
+ current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
+ used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
+void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) = NULL;
diff --git a/grub-core/lib/gnulib/argp-xinl.c b/grub-core/lib/gnulib/argp-xinl.c
new file mode 100644
index 0000000..ebc032f
--- /dev/null
+++ b/grub-core/lib/gnulib/argp-xinl.c
@@ -0,0 +1,46 @@
+/* Real definitions for extern inline functions in argp.h
+ Copyright (C) 1997-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined _LIBC || defined HAVE_FEATURES_H
+# include <features.h>
+#endif
+
+#ifndef __USE_EXTERN_INLINES
+# define __USE_EXTERN_INLINES 1
+#endif
+#ifdef _LIBC
+# define ARGP_EI
+#else
+# define ARGP_EI _GL_EXTERN_INLINE
+#endif
+#undef __OPTIMIZE__
+#define __OPTIMIZE__ 1
+#include "argp.h"
+
+/* Add weak aliases. */
+#if _LIBC - 0 && defined (weak_alias)
+
+weak_alias (__argp_usage, argp_usage)
+weak_alias (__option_is_short, _option_is_short)
+weak_alias (__option_is_end, _option_is_end)
+
+#endif
diff --git a/grub-core/lib/gnulib/argp.h b/grub-core/lib/gnulib/argp.h
new file mode 100644
index 0000000..317ac03
--- /dev/null
+++ b/grub-core/lib/gnulib/argp.h
@@ -0,0 +1,631 @@
+/* Hierarchical argument parsing, layered over getopt.
+ Copyright (C) 1995-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARGP_H
+#define _ARGP_H
+
+#include <stdio.h>
+#include <ctype.h>
+#include <getopt.h>
+#include <limits.h>
+
+#define __need_error_t
+#include <errno.h>
+
+#ifndef __THROW
+# define __THROW
+#endif
+#ifndef __NTH
+# define __NTH(fct) fct __THROW
+#endif
+
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The __-protected variants of the attributes 'format' and 'printf' are
+ accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+ We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
+ gnulib and libintl do '#define printf __printf__' when they override
+ the 'printf' function. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
+#endif
+
+/* GCC 2.95 and later have "__restrict"; C99 compilers have
+ "restrict", and "configure" may have defined "restrict".
+ Other compilers use __restrict, __restrict__, and _Restrict, and
+ 'configure' might #define 'restrict' to those words. */
+#ifndef __restrict
+# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
+# if 199901L <= __STDC_VERSION__
+# define __restrict restrict
+# else
+# define __restrict
+# endif
+# endif
+#endif
+
+#ifndef __error_t_defined
+typedef int error_t;
+# define __error_t_defined
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A description of a particular option. A pointer to an array of
+ these is passed in the OPTIONS field of an argp structure. Each option
+ entry can correspond to one long option and/or one short option; more
+ names for the same option can be added by following an entry in an option
+ array with options having the OPTION_ALIAS flag set. */
+struct argp_option
+{
+ /* The long option name. For more than one name for the same option, you
+ can use following options with the OPTION_ALIAS flag set. */
+ const char *name;
+
+ /* What key is returned for this option. If > 0 and printable, then it's
+ also accepted as a short option. */
+ int key;
+
+ /* If non-NULL, this is the name of the argument associated with this
+ option, which is required unless the OPTION_ARG_OPTIONAL flag is set. */
+ const char *arg;
+
+ /* OPTION_ flags. */
+ int flags;
+
+ /* The doc string for this option. If both NAME and KEY are 0, This string
+ will be printed outdented from the normal option column, making it
+ useful as a group header (it will be the first thing printed in its
+ group); in this usage, it's conventional to end the string with a ':'.
+
+ Write the initial value as N_("TEXT") if you want xgettext to collect
+ it into a POT file. */
+ const char *doc;
+
+ /* The group this option is in. In a long help message, options are sorted
+ alphabetically within each group, and the groups presented in the order
+ 0, 1, 2, ..., n, -m, ..., -2, -1. Every entry in an options array with
+ if this field 0 will inherit the group number of the previous entry, or
+ zero if it's the first one, unless its a group header (NAME and KEY both
+ 0), in which case, the previous entry + 1 is the default. Automagic
+ options such as --help are put into group -1. */
+ int group;
+};
+
+/* The argument associated with this option is optional. */
+#define OPTION_ARG_OPTIONAL 0x1
+
+/* This option isn't displayed in any help messages. */
+#define OPTION_HIDDEN 0x2
+
+/* This option is an alias for the closest previous non-alias option. This
+ means that it will be displayed in the same help entry, and will inherit
+ fields other than NAME and KEY from the aliased option. */
+#define OPTION_ALIAS 0x4
+
+/* This option isn't actually an option (and so should be ignored by the
+ actual option parser), but rather an arbitrary piece of documentation that
+ should be displayed in much the same manner as the options. If this flag
+ is set, then the option NAME field is displayed unmodified (e.g., no '--'
+ prefix is added) at the left-margin (where a *short* option would normally
+ be displayed), and the documentation string in the normal place. The NAME
+ field will be translated using gettext, unless OPTION_NO_TRANS is set (see
+ below). For purposes of sorting, any leading whitespace and punctuation is
+ ignored, except that if the first non-whitespace character is not '-', this
+ entry is displayed after all options (and OPTION_DOC entries with a leading
+ '-') in the same group. */
+#define OPTION_DOC 0x8
+
+/* This option shouldn't be included in "long" usage messages (but is still
+ included in help messages). This is mainly intended for options that are
+ completely documented in an argp's ARGS_DOC field, in which case including
+ the option in the generic usage list would be redundant. For instance,
+ if ARGS_DOC is "FOO BAR\n-x BLAH", and the '-x' option's purpose is to
+ distinguish these two cases, -x should probably be marked
+ OPTION_NO_USAGE. */
+#define OPTION_NO_USAGE 0x10
+
+/* Valid only in conjunction with OPTION_DOC. This option disables translation
+ of option name. */
+#define OPTION_NO_TRANS 0x20
+
+struct argp; /* fwd declare this type */
+struct argp_state; /* " */
+struct argp_child; /* " */
+
+/* The type of a pointer to an argp parsing function. */
+typedef error_t (*argp_parser_t) (int __key, char *__arg,
+ struct argp_state *__state);
+
+/* What to return for unrecognized keys. For special ARGP_KEY_ keys, such
+ returns will simply be ignored. For user keys, this error will be turned
+ into EINVAL (if the call to argp_parse is such that errors are propagated
+ back to the user instead of exiting); returning EINVAL itself would result
+ in an immediate stop to parsing in *all* cases. */
+#define ARGP_ERR_UNKNOWN E2BIG /* Hurd should never need E2BIG. XXX */
+
+/* Special values for the KEY argument to an argument parsing function.
+ ARGP_ERR_UNKNOWN should be returned if they aren't understood.
+
+ The sequence of keys to a parsing function is either (where each
+ uppercased word should be prefixed by 'ARGP_KEY_' and opt is a user key):
+
+ INIT opt... NO_ARGS END SUCCESS -- No non-option arguments at all
+ or INIT (opt | ARG)... END SUCCESS -- All non-option args parsed
+ or INIT (opt | ARG)... SUCCESS -- Some non-option arg unrecognized
+
+ The third case is where every parser returned ARGP_KEY_UNKNOWN for an
+ argument, in which case parsing stops at that argument (returning the
+ unparsed arguments to the caller of argp_parse if requested, or stopping
+ with an error message if not).
+
+ If an error occurs (either detected by argp, or because the parsing
+ function returned an error value), then the parser is called with
+ ARGP_KEY_ERROR, and no further calls are made. */
+
+/* This is not an option at all, but rather a command line argument. If a
+ parser receiving this key returns success, the fact is recorded, and the
+ ARGP_KEY_NO_ARGS case won't be used. HOWEVER, if while processing the
+ argument, a parser function decrements the NEXT field of the state it's
+ passed, the option won't be considered processed; this is to allow you to
+ actually modify the argument (perhaps into an option), and have it
+ processed again. */
+#define ARGP_KEY_ARG 0
+/* There are remaining arguments not parsed by any parser, which may be found
+ starting at (STATE->argv + STATE->next). If success is returned, but
+ STATE->next left untouched, it's assumed that all arguments were consume,
+ otherwise, the parser should adjust STATE->next to reflect any arguments
+ consumed. */
+#define ARGP_KEY_ARGS 0x1000006
+/* There are no more command line arguments at all. */
+#define ARGP_KEY_END 0x1000001
+/* Because it's common to want to do some special processing if there aren't
+ any non-option args, user parsers are called with this key if they didn't
+ successfully process any non-option arguments. Called just before
+ ARGP_KEY_END (where more general validity checks on previously parsed
+ arguments can take place). */
+#define ARGP_KEY_NO_ARGS 0x1000002
+/* Passed in before any parsing is done. Afterwards, the values of each
+ element of the CHILD_INPUT field, if any, in the state structure is
+ copied to each child's state to be the initial value of the INPUT field. */
+#define ARGP_KEY_INIT 0x1000003
+/* Use after all other keys, including SUCCESS & END. */
+#define ARGP_KEY_FINI 0x1000007
+/* Passed in when parsing has successfully been completed (even if there are
+ still arguments remaining). */
+#define ARGP_KEY_SUCCESS 0x1000004
+/* Passed in if an error occurs. */
+#define ARGP_KEY_ERROR 0x1000005
+
+/* An argp structure contains a set of options declarations, a function to
+ deal with parsing one, documentation string, a possible vector of child
+ argp's, and perhaps a function to filter help output. When actually
+ parsing options, getopt is called with the union of all the argp
+ structures chained together through their CHILD pointers, with conflicts
+ being resolved in favor of the first occurrence in the chain. */
+struct argp
+{
+ /* An array of argp_option structures, terminated by an entry with both
+ NAME and KEY having a value of 0. */
+ const struct argp_option *options;
+
+ /* What to do with an option from this structure. KEY is the key
+ associated with the option, and ARG is any associated argument (NULL if
+ none was supplied). If KEY isn't understood, ARGP_ERR_UNKNOWN should be
+ returned. If a non-zero, non-ARGP_ERR_UNKNOWN value is returned, then
+ parsing is stopped immediately, and that value is returned from
+ argp_parse(). For special (non-user-supplied) values of KEY, see the
+ ARGP_KEY_ definitions below. */
+ argp_parser_t parser;
+
+ /* A string describing what other arguments are wanted by this program. It
+ is only used by argp_usage to print the "Usage:" message. If it
+ contains newlines, the strings separated by them are considered
+ alternative usage patterns, and printed on separate lines (lines after
+ the first are prefix by " or: " instead of "Usage:"). */
+ const char *args_doc;
+
+ /* If non-NULL, a string containing extra text to be printed before and
+ after the options in a long help message (separated by a vertical tab
+ '\v' character).
+ Write the initial value as N_("BEFORE-TEXT") "\v" N_("AFTER-TEXT") if
+ you want xgettext to collect the two pieces of text into a POT file. */
+ const char *doc;
+
+ /* A vector of argp_children structures, terminated by a member with a 0
+ argp field, pointing to child argps should be parsed with this one. Any
+ conflicts are resolved in favor of this argp, or early argps in the
+ CHILDREN list. This field is useful if you use libraries that supply
+ their own argp structure, which you want to use in conjunction with your
+ own. */
+ const struct argp_child *children;
+
+ /* If non-zero, this should be a function to filter the output of help
+ messages. KEY is either a key from an option, in which case TEXT is
+ that option's help text, or a special key from the ARGP_KEY_HELP_
+ defines, below, describing which other help text TEXT is. The function
+ should return either TEXT, if it should be used as-is, a replacement
+ string, which should be malloced, and will be freed by argp, or NULL,
+ meaning "print nothing". The value for TEXT is *after* any translation
+ has been done, so if any of the replacement text also needs translation,
+ that should be done by the filter function. INPUT is either the input
+ supplied to argp_parse, or NULL, if argp_help was called directly. */
+ char *(*help_filter) (int __key, const char *__text, void *__input);
+
+ /* If non-zero the strings used in the argp library are translated using
+ the domain described by this string. Otherwise the currently installed
+ default domain is used. */
+ const char *argp_domain;
+};
+
+/* Possible KEY arguments to a help filter function. */
+#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceding options. */
+#define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */
+#define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */
+#define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation;
+ TEXT is NULL for this key. */
+/* Explanatory note emitted when duplicate option arguments have been
+ suppressed. */
+#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005
+#define ARGP_KEY_HELP_ARGS_DOC 0x2000006 /* Argument doc string. */
+
+/* When an argp has a non-zero CHILDREN field, it should point to a vector of
+ argp_child structures, each of which describes a subsidiary argp. */
+struct argp_child
+{
+ /* The child parser. */
+ const struct argp *argp;
+
+ /* Flags for this child. */
+ int flags;
+
+ /* If non-zero, an optional header to be printed in help output before the
+ child options. As a side-effect, a non-zero value forces the child
+ options to be grouped together; to achieve this effect without actually
+ printing a header string, use a value of "". */
+ const char *header;
+
+ /* Where to group the child options relative to the other ("consolidated")
+ options in the parent argp; the values are the same as the GROUP field
+ in argp_option structs, but all child-groupings follow parent options at
+ a particular group level. If both this field and HEADER are zero, then
+ they aren't grouped at all, but rather merged with the parent options
+ (merging the child's grouping levels with the parents). */
+ int group;
+};
+
+/* Parsing state. This is provided to parsing functions called by argp,
+ which may examine and, as noted, modify fields. */
+struct argp_state
+{
+ /* The top level ARGP being parsed. */
+ const struct argp *root_argp;
+
+ /* The argument vector being parsed. May be modified. */
+ int argc;
+ char **argv;
+
+ /* The index in ARGV of the next arg that to be parsed. May be modified. */
+ int next;
+
+ /* The flags supplied to argp_parse. May be modified. */
+ unsigned flags;
+
+ /* While calling a parsing function with a key of ARGP_KEY_ARG, this is the
+ number of the current arg, starting at zero, and incremented after each
+ such call returns. At all other times, this is the number of such
+ arguments that have been processed. */
+ unsigned arg_num;
+
+ /* If non-zero, the index in ARGV of the first argument following a special
+ '--' argument (which prevents anything following being interpreted as an
+ option). Only set once argument parsing has proceeded past this point. */
+ int quoted;
+
+ /* An arbitrary pointer passed in from the user. */
+ void *input;
+ /* Values to pass to child parsers. This vector will be the same length as
+ the number of children for the current parser. */
+ void **child_inputs;
+
+ /* For the parser's use. Initialized to 0. */
+ void *hook;
+
+ /* The name used when printing messages. This is initialized to ARGV[0],
+ or PROGRAM_INVOCATION_NAME if that is unavailable. */
+ char *name;
+
+ /* Streams used when argp prints something. */
+ FILE *err_stream; /* For errors; initialized to stderr. */
+ FILE *out_stream; /* For information; initialized to stdout. */
+
+ void *pstate; /* Private, for use by argp. */
+};
+
+/* Flags for argp_parse (note that the defaults are those that are
+ convenient for program command line parsing): */
+
+/* Don't ignore the first element of ARGV. Normally (and always unless
+ ARGP_NO_ERRS is set) the first element of the argument vector is
+ skipped for option parsing purposes, as it corresponds to the program name
+ in a command line. */
+#define ARGP_PARSE_ARGV0 0x01
+
+/* Don't print error messages for unknown options to stderr; unless this flag
+ is set, ARGP_PARSE_ARGV0 is ignored, as ARGV[0] is used as the program
+ name in the error messages. This flag implies ARGP_NO_EXIT (on the
+ assumption that silent exiting upon errors is bad behaviour). */
+#define ARGP_NO_ERRS 0x02
+
+/* Don't parse any non-option args. Normally non-option args are parsed by
+ calling the parse functions with a key of ARGP_KEY_ARG, and the actual arg
+ as the value. Since it's impossible to know which parse function wants to
+ handle it, each one is called in turn, until one returns 0 or an error
+ other than ARGP_ERR_UNKNOWN; if an argument is handled by no one, the
+ argp_parse returns prematurely (but with a return value of 0). If all
+ args have been parsed without error, all parsing functions are called one
+ last time with a key of ARGP_KEY_END. This flag needn't normally be set,
+ as the normal behavior is to stop parsing as soon as some argument can't
+ be handled. */
+#define ARGP_NO_ARGS 0x04
+
+/* Parse options and arguments in the same order they occur on the command
+ line -- normally they're rearranged so that all options come first. */
+#define ARGP_IN_ORDER 0x08
+
+/* Don't provide the standard long option --help, which causes usage and
+ option help information to be output to stdout, and exit (0) called. */
+#define ARGP_NO_HELP 0x10
+
+/* Don't exit on errors (they may still result in error messages). */
+#define ARGP_NO_EXIT 0x20
+
+/* Use the gnu getopt "long-only" rules for parsing arguments. */
+#define ARGP_LONG_ONLY 0x40
+
+/* Turns off any message-printing/exiting options. */
+#define ARGP_SILENT (ARGP_NO_EXIT | ARGP_NO_ERRS | ARGP_NO_HELP)
+
+/* Parse the options strings in ARGC & ARGV according to the options in ARGP.
+ FLAGS is one of the ARGP_ flags above. If ARG_INDEX is non-NULL, the
+ index in ARGV of the first unparsed option is returned in it. If an
+ unknown option is present, ARGP_ERR_UNKNOWN is returned; if some parser
+ routine returned a non-zero value, it is returned; otherwise 0 is
+ returned. This function may also call exit unless the ARGP_NO_HELP flag
+ is set. INPUT is a pointer to a value to be passed in to the parser. */
+extern error_t argp_parse (const struct argp *__restrict __argp,
+ int /*argc*/, char **__restrict /*argv*/,
+ unsigned __flags, int *__restrict __arg_index,
+ void *__restrict __input);
+extern error_t __argp_parse (const struct argp *__restrict __argp,
+ int /*argc*/, char **__restrict /*argv*/,
+ unsigned __flags, int *__restrict __arg_index,
+ void *__restrict __input);
+
+/* Global variables. */
+
+/* GNULIB makes sure both program_invocation_name and
+ program_invocation_short_name are available */
+#ifdef GNULIB_PROGRAM_INVOCATION_NAME
+extern char *program_invocation_name;
+# undef HAVE_DECL_PROGRAM_INVOCATION_NAME
+# define HAVE_DECL_PROGRAM_INVOCATION_NAME 1
+#endif
+
+#ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME
+extern char *program_invocation_short_name;
+# undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+# define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1
+#endif
+
+/* If defined or set by the user program to a non-zero value, then a default
+ option --version is added (unless the ARGP_NO_HELP flag is used), which
+ will print this string followed by a newline and exit (unless the
+ ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
+extern const char *argp_program_version;
+
+/* If defined or set by the user program to a non-zero value, then a default
+ option --version is added (unless the ARGP_NO_HELP flag is used), which
+ calls this function with a stream to print the version to and a pointer to
+ the current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
+ used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
+extern void (*argp_program_version_hook) (FILE *__restrict __stream,
+ struct argp_state *__restrict
+ __state);
+
+/* If defined or set by the user program, it should point to string that is
+ the bug-reporting address for the program. It will be printed by
+ argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various
+ standard help messages), embedded in a sentence that says something like
+ "Report bugs to ADDR." */
+extern const char *argp_program_bug_address;
+
+/* The exit status that argp will use when exiting due to a parsing error.
+ If not defined or set by the user program, this defaults to EX_USAGE from
+ <sysexits.h>. */
+extern error_t argp_err_exit_status;
+
+/* Flags for argp_help. */
+#define ARGP_HELP_USAGE 0x01 /* a Usage: message. */
+#define ARGP_HELP_SHORT_USAGE 0x02 /* " but don't actually print options. */
+#define ARGP_HELP_SEE 0x04 /* a "Try ... for more help" message. */
+#define ARGP_HELP_LONG 0x08 /* a long help message. */
+#define ARGP_HELP_PRE_DOC 0x10 /* doc string preceding long help. */
+#define ARGP_HELP_POST_DOC 0x20 /* doc string following long help. */
+#define ARGP_HELP_DOC (ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC)
+#define ARGP_HELP_BUG_ADDR 0x40 /* bug report address */
+#define ARGP_HELP_LONG_ONLY 0x80 /* modify output appropriately to
+ reflect ARGP_LONG_ONLY mode. */
+
+/* These ARGP_HELP flags are only understood by argp_state_help. */
+#define ARGP_HELP_EXIT_ERR 0x100 /* Call exit(1) instead of returning. */
+#define ARGP_HELP_EXIT_OK 0x200 /* Call exit(0) instead of returning. */
+
+/* The standard thing to do after a program command line parsing error, if an
+ error message has already been printed. */
+#define ARGP_HELP_STD_ERR \
+ (ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
+/* The standard thing to do after a program command line parsing error, if no
+ more specific error message has been printed. */
+#define ARGP_HELP_STD_USAGE \
+ (ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
+/* The standard thing to do in response to a --help option. */
+#define ARGP_HELP_STD_HELP \
+ (ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_EXIT_OK \
+ | ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR)
+
+/* Output a usage message for ARGP to STREAM. FLAGS are from the set
+ ARGP_HELP_*. */
+extern void argp_help (const struct argp *__restrict __argp,
+ FILE *__restrict __stream,
+ unsigned __flags, char *__restrict __name);
+extern void __argp_help (const struct argp *__restrict __argp,
+ FILE *__restrict __stream, unsigned __flags,
+ char *__name);
+
+/* The following routines are intended to be called from within an argp
+ parsing routine (thus taking an argp_state structure as the first
+ argument). They may or may not print an error message and exit, depending
+ on the flags in STATE -- in any case, the caller should be prepared for
+ them *not* to exit, and should return an appropriate error after calling
+ them. [argp_usage & argp_error should probably be called argp_state_...,
+ but they're used often enough that they should be short] */
+
+/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
+ from the set ARGP_HELP_*. */
+extern void argp_state_help (const struct argp_state *__restrict __state,
+ FILE *__restrict __stream,
+ unsigned int __flags);
+extern void __argp_state_help (const struct argp_state *__restrict __state,
+ FILE *__restrict __stream,
+ unsigned int __flags);
+
+#if _LIBC
+/* Possibly output the standard usage message for ARGP to stderr and exit. */
+extern void argp_usage (const struct argp_state *__state);
+extern void __argp_usage (const struct argp_state *__state);
+#endif
+
+/* If appropriate, print the printf string FMT and following args, preceded
+ by the program name and ':', to stderr, and followed by a "Try ... --help"
+ message, then exit (1). */
+extern void argp_error (const struct argp_state *__restrict __state,
+ const char *__restrict __fmt, ...)
+ _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3));
+extern void __argp_error (const struct argp_state *__restrict __state,
+ const char *__restrict __fmt, ...)
+ _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3));
+
+/* Similar to the standard gnu error-reporting function error(), but will
+ respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
+ to STATE->err_stream. This is useful for argument parsing code that is
+ shared between program startup (when exiting is desired) and runtime
+ option parsing (when typically an error code is returned instead). The
+ difference between this function and argp_error is that the latter is for
+ *parsing errors*, and the former is for other problems that occur during
+ parsing but don't reflect a (syntactic) problem with the input. */
+extern void argp_failure (const struct argp_state *__restrict __state,
+ int __status, int __errnum,
+ const char *__restrict __fmt, ...)
+ _GL_ATTRIBUTE_FORMAT ((__printf__, 4, 5));
+extern void __argp_failure (const struct argp_state *__restrict __state,
+ int __status, int __errnum,
+ const char *__restrict __fmt, ...)
+ _GL_ATTRIBUTE_FORMAT ((__printf__, 4, 5));
+
+#if _LIBC
+/* Returns true if the option OPT is a valid short option. */
+extern int _option_is_short (const struct argp_option *__opt) __THROW;
+extern int __option_is_short (const struct argp_option *__opt) __THROW;
+
+/* Returns true if the option OPT is in fact the last (unused) entry in an
+ options array. */
+extern int _option_is_end (const struct argp_option *__opt) __THROW;
+extern int __option_is_end (const struct argp_option *__opt) __THROW;
+#endif
+
+/* Return the input field for ARGP in the parser corresponding to STATE; used
+ by the help routines. */
+extern void *_argp_input (const struct argp *__restrict __argp,
+ const struct argp_state *__restrict __state)
+ __THROW;
+extern void *__argp_input (const struct argp *__restrict __argp,
+ const struct argp_state *__restrict __state)
+ __THROW;
+
+#if !_LIBC || defined __USE_EXTERN_INLINES
+
+# if !_LIBC
+# define __argp_usage argp_usage
+# define __argp_state_help argp_state_help
+# define __option_is_short _option_is_short
+# define __option_is_end _option_is_end
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+# ifndef ARGP_EI
+# define ARGP_EI _GL_INLINE
+# endif
+# endif
+
+# ifndef ARGP_EI
+# define ARGP_EI __extern_inline
+# endif
+
+ARGP_EI void
+__argp_usage (const struct argp_state *__state)
+{
+ __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
+}
+
+ARGP_EI int
+__NTH (__option_is_short (const struct argp_option *__opt))
+{
+ if (__opt->flags & OPTION_DOC)
+ return 0;
+ else
+ {
+ int __key = __opt->key;
+ return __key > 0 && __key <= UCHAR_MAX && isprint (__key);
+ }
+}
+
+ARGP_EI int
+__NTH (__option_is_end (const struct argp_option *__opt))
+{
+ return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
+}
+
+# if !_LIBC
+# undef __argp_usage
+# undef __argp_state_help
+# undef __option_is_short
+# undef __option_is_end
+_GL_INLINE_HEADER_END
+# endif
+#endif /* Use extern inlines. */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* argp.h */
diff --git a/grub-core/lib/gnulib/asnprintf.c b/grub-core/lib/gnulib/asnprintf.c
new file mode 100644
index 0000000..d2a8c09
--- /dev/null
+++ b/grub-core/lib/gnulib/asnprintf.c
@@ -0,0 +1,34 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "vasnprintf.h"
+
+#include <stdarg.h>
+
+char *
+asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ char *result;
+
+ va_start (args, format);
+ result = vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return result;
+}
diff --git a/grub-core/lib/gnulib/assure.h b/grub-core/lib/gnulib/assure.h
new file mode 100644
index 0000000..c21b6a6
--- /dev/null
+++ b/grub-core/lib/gnulib/assure.h
@@ -0,0 +1,37 @@
+/* Run-time assert-like macros.
+
+ Copyright (C) 2014-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#ifndef _GL_ASSURE_H
+#define _GL_ASSURE_H
+
+#include <assert.h>
+
+/* Check E's value at runtime, and report an error and abort if not.
+ However, do nothing if NDEBUG is defined.
+
+ Unlike standard 'assert', this macro always compiles E even when NDEBUG
+ is defined, so as to catch typos and avoid some GCC warnings. */
+
+#ifdef NDEBUG
+# define assure(E) ((void) (0 && (E)))
+#else
+# define assure(E) assert (E)
+#endif
+
+#endif
diff --git a/grub-core/lib/gnulib/base64.c b/grub-core/lib/gnulib/base64.c
new file mode 100644
index 0000000..84a4e82
--- /dev/null
+++ b/grub-core/lib/gnulib/base64.c
@@ -0,0 +1,605 @@
+/* base64.c -- Encode binary data using printable characters.
+ Copyright (C) 1999-2001, 2004-2006, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Simon Josefsson. Partially adapted from GNU MailUtils
+ * (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
+ * from Paul Eggert, Bruno Haible, and Stepan Kasal.
+ *
+ * See also RFC 4648 <https://www.ietf.org/rfc/rfc4648.txt>.
+ *
+ * Be careful with error checking. Here is how you would typically
+ * use these functions:
+ *
+ * bool ok = base64_decode_alloc (in, inlen, &out, &outlen);
+ * if (!ok)
+ * FAIL: input was not valid base64
+ * if (out == NULL)
+ * FAIL: memory allocation error
+ * OK: data in OUT/OUTLEN
+ *
+ * size_t outlen = base64_encode_alloc (in, inlen, &out);
+ * if (out == NULL && outlen == 0 && inlen != 0)
+ * FAIL: input too long
+ * if (out == NULL)
+ * FAIL: memory allocation error
+ * OK: data in OUT/OUTLEN.
+ *
+ */
+
+#include <config.h>
+
+/* Get prototype. */
+#include "base64.h"
+
+/* Get malloc. */
+#include <stdlib.h>
+
+/* Get UCHAR_MAX. */
+#include <limits.h>
+
+#include <string.h>
+
+/* C89 compliant way to cast 'char' to 'unsigned char'. */
+static unsigned char
+to_uchar (char ch)
+{
+ return ch;
+}
+
+static const char b64c[64] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+/* Base64 encode IN array of size INLEN into OUT array. OUT needs
+ to be of length >= BASE64_LENGTH(INLEN), and INLEN needs to be
+ a multiple of 3. */
+static void
+base64_encode_fast (const char *restrict in, size_t inlen, char *restrict out)
+{
+ while (inlen)
+ {
+ *out++ = b64c[to_uchar (in[0]) >> 2];
+ *out++ = b64c[((to_uchar (in[0]) << 4) + (to_uchar (in[1]) >> 4)) & 0x3f];
+ *out++ = b64c[((to_uchar (in[1]) << 2) + (to_uchar (in[2]) >> 6)) & 0x3f];
+ *out++ = b64c[to_uchar (in[2]) & 0x3f];
+
+ inlen -= 3;
+ in += 3;
+ }
+}
+
+/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN.
+ If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as
+ possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero
+ terminate the output buffer. */
+void
+base64_encode (const char *restrict in, size_t inlen,
+ char *restrict out, size_t outlen)
+{
+ /* Note this outlen constraint can be enforced at compile time.
+ I.E. that the output buffer is exactly large enough to hold
+ the encoded inlen bytes. The inlen constraints (of corresponding
+ to outlen, and being a multiple of 3) can change at runtime
+ at the end of input. However the common case when reading
+ large inputs is to have both constraints satisfied, so we depend
+ on both in base_encode_fast(). */
+ if (outlen % 4 == 0 && inlen == outlen / 4 * 3)
+ {
+ base64_encode_fast (in, inlen, out);
+ return;
+ }
+
+ while (inlen && outlen)
+ {
+ *out++ = b64c[to_uchar (in[0]) >> 2];
+ if (!--outlen)
+ break;
+ *out++ = b64c[((to_uchar (in[0]) << 4)
+ + (--inlen ? to_uchar (in[1]) >> 4 : 0))
+ & 0x3f];
+ if (!--outlen)
+ break;
+ *out++ =
+ (inlen
+ ? b64c[((to_uchar (in[1]) << 2)
+ + (--inlen ? to_uchar (in[2]) >> 6 : 0))
+ & 0x3f]
+ : '=');
+ if (!--outlen)
+ break;
+ *out++ = inlen ? b64c[to_uchar (in[2]) & 0x3f] : '=';
+ if (!--outlen)
+ break;
+ if (inlen)
+ inlen--;
+ if (inlen)
+ in += 3;
+ }
+
+ if (outlen)
+ *out = '\0';
+}
+
+/* Allocate a buffer and store zero terminated base64 encoded data
+ from array IN of size INLEN, returning BASE64_LENGTH(INLEN), i.e.,
+ the length of the encoded data, excluding the terminating zero. On
+ return, the OUT variable will hold a pointer to newly allocated
+ memory that must be deallocated by the caller. If output string
+ length would overflow, 0 is returned and OUT is set to NULL. If
+ memory allocation failed, OUT is set to NULL, and the return value
+ indicates length of the requested memory block, i.e.,
+ BASE64_LENGTH(inlen) + 1. */
+size_t
+base64_encode_alloc (const char *in, size_t inlen, char **out)
+{
+ size_t outlen = 1 + BASE64_LENGTH (inlen);
+
+ /* Check for overflow in outlen computation.
+ *
+ * If there is no overflow, outlen >= inlen.
+ *
+ * If the operation (inlen + 2) overflows then it yields at most +1, so
+ * outlen is 0.
+ *
+ * If the multiplication overflows, we lose at least half of the
+ * correct value, so the result is < ((inlen + 2) / 3) * 2, which is
+ * less than (inlen + 2) * 0.66667, which is less than inlen as soon as
+ * (inlen > 4).
+ */
+ if (inlen > outlen)
+ {
+ *out = NULL;
+ return 0;
+ }
+
+ *out = malloc (outlen);
+ if (!*out)
+ return outlen;
+
+ base64_encode (in, inlen, *out, outlen);
+
+ return outlen - 1;
+}
+
+/* With this approach this file works independent of the charset used
+ (think EBCDIC). However, it does assume that the characters in the
+ Base64 alphabet (A-Za-z0-9+/) are encoded in 0..255. POSIX
+ 1003.1-2001 require that char and unsigned char are 8-bit
+ quantities, though, taking care of that problem. But this may be a
+ potential problem on non-POSIX C99 platforms.
+
+ IBM C V6 for AIX mishandles "#define B64(x) ...'x'...", so use "_"
+ as the formal parameter rather than "x". */
+#define B64(_) \
+ ((_) == 'A' ? 0 \
+ : (_) == 'B' ? 1 \
+ : (_) == 'C' ? 2 \
+ : (_) == 'D' ? 3 \
+ : (_) == 'E' ? 4 \
+ : (_) == 'F' ? 5 \
+ : (_) == 'G' ? 6 \
+ : (_) == 'H' ? 7 \
+ : (_) == 'I' ? 8 \
+ : (_) == 'J' ? 9 \
+ : (_) == 'K' ? 10 \
+ : (_) == 'L' ? 11 \
+ : (_) == 'M' ? 12 \
+ : (_) == 'N' ? 13 \
+ : (_) == 'O' ? 14 \
+ : (_) == 'P' ? 15 \
+ : (_) == 'Q' ? 16 \
+ : (_) == 'R' ? 17 \
+ : (_) == 'S' ? 18 \
+ : (_) == 'T' ? 19 \
+ : (_) == 'U' ? 20 \
+ : (_) == 'V' ? 21 \
+ : (_) == 'W' ? 22 \
+ : (_) == 'X' ? 23 \
+ : (_) == 'Y' ? 24 \
+ : (_) == 'Z' ? 25 \
+ : (_) == 'a' ? 26 \
+ : (_) == 'b' ? 27 \
+ : (_) == 'c' ? 28 \
+ : (_) == 'd' ? 29 \
+ : (_) == 'e' ? 30 \
+ : (_) == 'f' ? 31 \
+ : (_) == 'g' ? 32 \
+ : (_) == 'h' ? 33 \
+ : (_) == 'i' ? 34 \
+ : (_) == 'j' ? 35 \
+ : (_) == 'k' ? 36 \
+ : (_) == 'l' ? 37 \
+ : (_) == 'm' ? 38 \
+ : (_) == 'n' ? 39 \
+ : (_) == 'o' ? 40 \
+ : (_) == 'p' ? 41 \
+ : (_) == 'q' ? 42 \
+ : (_) == 'r' ? 43 \
+ : (_) == 's' ? 44 \
+ : (_) == 't' ? 45 \
+ : (_) == 'u' ? 46 \
+ : (_) == 'v' ? 47 \
+ : (_) == 'w' ? 48 \
+ : (_) == 'x' ? 49 \
+ : (_) == 'y' ? 50 \
+ : (_) == 'z' ? 51 \
+ : (_) == '0' ? 52 \
+ : (_) == '1' ? 53 \
+ : (_) == '2' ? 54 \
+ : (_) == '3' ? 55 \
+ : (_) == '4' ? 56 \
+ : (_) == '5' ? 57 \
+ : (_) == '6' ? 58 \
+ : (_) == '7' ? 59 \
+ : (_) == '8' ? 60 \
+ : (_) == '9' ? 61 \
+ : (_) == '+' ? 62 \
+ : (_) == '/' ? 63 \
+ : -1)
+
+static const signed char b64[0x100] = {
+ B64 (0), B64 (1), B64 (2), B64 (3),
+ B64 (4), B64 (5), B64 (6), B64 (7),
+ B64 (8), B64 (9), B64 (10), B64 (11),
+ B64 (12), B64 (13), B64 (14), B64 (15),
+ B64 (16), B64 (17), B64 (18), B64 (19),
+ B64 (20), B64 (21), B64 (22), B64 (23),
+ B64 (24), B64 (25), B64 (26), B64 (27),
+ B64 (28), B64 (29), B64 (30), B64 (31),
+ B64 (32), B64 (33), B64 (34), B64 (35),
+ B64 (36), B64 (37), B64 (38), B64 (39),
+ B64 (40), B64 (41), B64 (42), B64 (43),
+ B64 (44), B64 (45), B64 (46), B64 (47),
+ B64 (48), B64 (49), B64 (50), B64 (51),
+ B64 (52), B64 (53), B64 (54), B64 (55),
+ B64 (56), B64 (57), B64 (58), B64 (59),
+ B64 (60), B64 (61), B64 (62), B64 (63),
+ B64 (64), B64 (65), B64 (66), B64 (67),
+ B64 (68), B64 (69), B64 (70), B64 (71),
+ B64 (72), B64 (73), B64 (74), B64 (75),
+ B64 (76), B64 (77), B64 (78), B64 (79),
+ B64 (80), B64 (81), B64 (82), B64 (83),
+ B64 (84), B64 (85), B64 (86), B64 (87),
+ B64 (88), B64 (89), B64 (90), B64 (91),
+ B64 (92), B64 (93), B64 (94), B64 (95),
+ B64 (96), B64 (97), B64 (98), B64 (99),
+ B64 (100), B64 (101), B64 (102), B64 (103),
+ B64 (104), B64 (105), B64 (106), B64 (107),
+ B64 (108), B64 (109), B64 (110), B64 (111),
+ B64 (112), B64 (113), B64 (114), B64 (115),
+ B64 (116), B64 (117), B64 (118), B64 (119),
+ B64 (120), B64 (121), B64 (122), B64 (123),
+ B64 (124), B64 (125), B64 (126), B64 (127),
+ B64 (128), B64 (129), B64 (130), B64 (131),
+ B64 (132), B64 (133), B64 (134), B64 (135),
+ B64 (136), B64 (137), B64 (138), B64 (139),
+ B64 (140), B64 (141), B64 (142), B64 (143),
+ B64 (144), B64 (145), B64 (146), B64 (147),
+ B64 (148), B64 (149), B64 (150), B64 (151),
+ B64 (152), B64 (153), B64 (154), B64 (155),
+ B64 (156), B64 (157), B64 (158), B64 (159),
+ B64 (160), B64 (161), B64 (162), B64 (163),
+ B64 (164), B64 (165), B64 (166), B64 (167),
+ B64 (168), B64 (169), B64 (170), B64 (171),
+ B64 (172), B64 (173), B64 (174), B64 (175),
+ B64 (176), B64 (177), B64 (178), B64 (179),
+ B64 (180), B64 (181), B64 (182), B64 (183),
+ B64 (184), B64 (185), B64 (186), B64 (187),
+ B64 (188), B64 (189), B64 (190), B64 (191),
+ B64 (192), B64 (193), B64 (194), B64 (195),
+ B64 (196), B64 (197), B64 (198), B64 (199),
+ B64 (200), B64 (201), B64 (202), B64 (203),
+ B64 (204), B64 (205), B64 (206), B64 (207),
+ B64 (208), B64 (209), B64 (210), B64 (211),
+ B64 (212), B64 (213), B64 (214), B64 (215),
+ B64 (216), B64 (217), B64 (218), B64 (219),
+ B64 (220), B64 (221), B64 (222), B64 (223),
+ B64 (224), B64 (225), B64 (226), B64 (227),
+ B64 (228), B64 (229), B64 (230), B64 (231),
+ B64 (232), B64 (233), B64 (234), B64 (235),
+ B64 (236), B64 (237), B64 (238), B64 (239),
+ B64 (240), B64 (241), B64 (242), B64 (243),
+ B64 (244), B64 (245), B64 (246), B64 (247),
+ B64 (248), B64 (249), B64 (250), B64 (251),
+ B64 (252), B64 (253), B64 (254), B64 (255)
+};
+
+#if UCHAR_MAX == 255
+# define uchar_in_range(c) true
+#else
+# define uchar_in_range(c) ((c) <= 255)
+#endif
+
+/* Return true if CH is a character from the Base64 alphabet, and
+ false otherwise. Note that '=' is padding and not considered to be
+ part of the alphabet. */
+bool
+isbase64 (char ch)
+{
+ return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)];
+}
+
+/* Initialize decode-context buffer, CTX. */
+void
+base64_decode_ctx_init (struct base64_decode_context *ctx)
+{
+ ctx->i = 0;
+}
+
+/* If CTX->i is 0 or 4, there are four or more bytes in [*IN..IN_END), and
+ none of those four is a newline, then return *IN. Otherwise, copy up to
+ 4 - CTX->i non-newline bytes from that range into CTX->buf, starting at
+ index CTX->i and setting CTX->i to reflect the number of bytes copied,
+ and return CTX->buf. In either case, advance *IN to point to the byte
+ after the last one processed, and set *N_NON_NEWLINE to the number of
+ verified non-newline bytes accessible through the returned pointer. */
+static char *
+get_4 (struct base64_decode_context *ctx,
+ char const *restrict *in, char const *restrict in_end,
+ size_t *n_non_newline)
+{
+ if (ctx->i == 4)
+ ctx->i = 0;
+
+ if (ctx->i == 0)
+ {
+ char const *t = *in;
+ if (4 <= in_end - *in && memchr (t, '\n', 4) == NULL)
+ {
+ /* This is the common case: no newline. */
+ *in += 4;
+ *n_non_newline = 4;
+ return (char *) t;
+ }
+ }
+
+ {
+ /* Copy non-newline bytes into BUF. */
+ char const *p = *in;
+ while (p < in_end)
+ {
+ char c = *p++;
+ if (c != '\n')
+ {
+ ctx->buf[ctx->i++] = c;
+ if (ctx->i == 4)
+ break;
+ }
+ }
+
+ *in = p;
+ *n_non_newline = ctx->i;
+ return ctx->buf;
+ }
+}
+
+#define return_false \
+ do \
+ { \
+ *outp = out; \
+ return false; \
+ } \
+ while (false)
+
+/* Decode up to four bytes of base64-encoded data, IN, of length INLEN
+ into the output buffer, *OUT, of size *OUTLEN bytes. Return true if
+ decoding is successful, false otherwise. If *OUTLEN is too small,
+ as many bytes as possible are written to *OUT. On return, advance
+ *OUT to point to the byte after the last one written, and decrement
+ *OUTLEN to reflect the number of bytes remaining in *OUT. */
+static bool
+decode_4 (char const *restrict in, size_t inlen,
+ char *restrict *outp, size_t *outleft)
+{
+ char *out = *outp;
+ if (inlen < 2)
+ return false;
+
+ if (!isbase64 (in[0]) || !isbase64 (in[1]))
+ return false;
+
+ if (*outleft)
+ {
+ *out++ = ((b64[to_uchar (in[0])] << 2)
+ | (b64[to_uchar (in[1])] >> 4));
+ --*outleft;
+ }
+
+ if (inlen == 2)
+ return_false;
+
+ if (in[2] == '=')
+ {
+ if (inlen != 4)
+ return_false;
+
+ if (in[3] != '=')
+ return_false;
+ }
+ else
+ {
+ if (!isbase64 (in[2]))
+ return_false;
+
+ if (*outleft)
+ {
+ *out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0)
+ | (b64[to_uchar (in[2])] >> 2));
+ --*outleft;
+ }
+
+ if (inlen == 3)
+ return_false;
+
+ if (in[3] == '=')
+ {
+ if (inlen != 4)
+ return_false;
+ }
+ else
+ {
+ if (!isbase64 (in[3]))
+ return_false;
+
+ if (*outleft)
+ {
+ *out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0)
+ | b64[to_uchar (in[3])]);
+ --*outleft;
+ }
+ }
+ }
+
+ *outp = out;
+ return true;
+}
+
+/* Decode base64-encoded input array IN of length INLEN to output array
+ OUT that can hold *OUTLEN bytes. The input data may be interspersed
+ with newlines. Return true if decoding was successful, i.e. if the
+ input was valid base64 data, false otherwise. If *OUTLEN is too
+ small, as many bytes as possible will be written to OUT. On return,
+ *OUTLEN holds the length of decoded bytes in OUT. Note that as soon
+ as any non-alphabet, non-newline character is encountered, decoding
+ is stopped and false is returned. If INLEN is zero, then process
+ only whatever data is stored in CTX.
+
+ Initially, CTX must have been initialized via base64_decode_ctx_init.
+ Subsequent calls to this function must reuse whatever state is recorded
+ in that buffer. It is necessary for when a quadruple of base64 input
+ bytes spans two input buffers.
+
+ If CTX is NULL then newlines are treated as garbage and the input
+ buffer is processed as a unit. */
+
+bool
+base64_decode_ctx (struct base64_decode_context *ctx,
+ const char *restrict in, size_t inlen,
+ char *restrict out, size_t *outlen)
+{
+ size_t outleft = *outlen;
+ bool ignore_newlines = ctx != NULL;
+ bool flush_ctx = false;
+ unsigned int ctx_i = 0;
+
+ if (ignore_newlines)
+ {
+ ctx_i = ctx->i;
+ flush_ctx = inlen == 0;
+ }
+
+
+ while (true)
+ {
+ size_t outleft_save = outleft;
+ if (ctx_i == 0 && !flush_ctx)
+ {
+ while (true)
+ {
+ /* Save a copy of outleft, in case we need to re-parse this
+ block of four bytes. */
+ outleft_save = outleft;
+ if (!decode_4 (in, inlen, &out, &outleft))
+ break;
+
+ in += 4;
+ inlen -= 4;
+ }
+ }
+
+ if (inlen == 0 && !flush_ctx)
+ break;
+
+ /* Handle the common case of 72-byte wrapped lines.
+ This also handles any other multiple-of-4-byte wrapping. */
+ if (inlen && *in == '\n' && ignore_newlines)
+ {
+ ++in;
+ --inlen;
+ continue;
+ }
+
+ /* Restore OUT and OUTLEFT. */
+ out -= outleft_save - outleft;
+ outleft = outleft_save;
+
+ {
+ char const *in_end = in + inlen;
+ char const *non_nl;
+
+ if (ignore_newlines)
+ non_nl = get_4 (ctx, &in, in_end, &inlen);
+ else
+ non_nl = in; /* Might have nl in this case. */
+
+ /* If the input is empty or consists solely of newlines (0 non-newlines),
+ then we're done. Likewise if there are fewer than 4 bytes when not
+ flushing context and not treating newlines as garbage. */
+ if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines))
+ {
+ inlen = 0;
+ break;
+ }
+ if (!decode_4 (non_nl, inlen, &out, &outleft))
+ break;
+
+ inlen = in_end - in;
+ }
+ }
+
+ *outlen -= outleft;
+
+ return inlen == 0;
+}
+
+/* Allocate an output buffer in *OUT, and decode the base64 encoded
+ data stored in IN of size INLEN to the *OUT buffer. On return, the
+ size of the decoded data is stored in *OUTLEN. OUTLEN may be NULL,
+ if the caller is not interested in the decoded length. *OUT may be
+ NULL to indicate an out of memory error, in which case *OUTLEN
+ contains the size of the memory block needed. The function returns
+ true on successful decoding and memory allocation errors. (Use the
+ *OUT and *OUTLEN parameters to differentiate between successful
+ decoding and memory error.) The function returns false if the
+ input was invalid, in which case *OUT is NULL and *OUTLEN is
+ undefined. */
+bool
+base64_decode_alloc_ctx (struct base64_decode_context *ctx,
+ const char *in, size_t inlen, char **out,
+ size_t *outlen)
+{
+ /* This may allocate a few bytes too many, depending on input,
+ but it's not worth the extra CPU time to compute the exact size.
+ The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the
+ input ends with "=" and minus another 1 if the input ends with "==".
+ Dividing before multiplying avoids the possibility of overflow. */
+ size_t needlen = 3 * (inlen / 4) + 3;
+
+ *out = malloc (needlen);
+ if (!*out)
+ return true;
+
+ if (!base64_decode_ctx (ctx, in, inlen, *out, &needlen))
+ {
+ free (*out);
+ *out = NULL;
+ return false;
+ }
+
+ if (outlen)
+ *outlen = needlen;
+
+ return true;
+}
diff --git a/grub-core/lib/gnulib/base64.h b/grub-core/lib/gnulib/base64.h
new file mode 100644
index 0000000..392978f
--- /dev/null
+++ b/grub-core/lib/gnulib/base64.h
@@ -0,0 +1,74 @@
+/* base64.h -- Encode binary data using printable characters.
+ Copyright (C) 2004-2006, 2009-2019 Free Software Foundation, Inc.
+ Written by Simon Josefsson.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef BASE64_H
+# define BASE64_H
+
+/* Get size_t. */
+# include <stddef.h>
+
+#ifndef GRUB_POSIX_BOOL_DEFINED
+typedef enum { false = 0, true = 1 } bool;
+#define GRUB_POSIX_BOOL_DEFINED 1
+#endif
+
+#ifndef _GL_ATTRIBUTE_CONST
+# define _GL_ATTRIBUTE_CONST /* empty */
+#endif
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* This uses that the expression (n+(k-1))/k means the smallest
+ integer >= n/k, i.e., the ceiling of n/k. */
+# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
+
+struct base64_decode_context
+{
+ unsigned int i;
+ char buf[4];
+};
+
+extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST;
+
+extern void base64_encode (const char *restrict in, size_t inlen,
+ char *restrict out, size_t outlen);
+
+extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out);
+
+extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
+
+extern bool base64_decode_ctx (struct base64_decode_context *ctx,
+ const char *restrict in, size_t inlen,
+ char *restrict out, size_t *outlen);
+
+extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
+ const char *in, size_t inlen,
+ char **out, size_t *outlen);
+
+#define base64_decode(in, inlen, out, outlen) \
+ base64_decode_ctx (NULL, in, inlen, out, outlen)
+
+#define base64_decode_alloc(in, inlen, out, outlen) \
+ base64_decode_alloc_ctx (NULL, in, inlen, out, outlen)
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif /* BASE64_H */
diff --git a/grub-core/lib/gnulib/basename-lgpl.c b/grub-core/lib/gnulib/basename-lgpl.c
new file mode 100644
index 0000000..0ae04ee
--- /dev/null
+++ b/grub-core/lib/gnulib/basename-lgpl.c
@@ -0,0 +1,75 @@
+/* basename.c -- return the last element in a file name
+
+ Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "dirname.h"
+
+#include <string.h>
+
+/* Return the address of the last file name component of NAME. If
+ NAME has no relative file name components because it is a file
+ system root, return the empty string. */
+
+char *
+last_component (char const *name)
+{
+ char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
+ char const *p;
+ bool saw_slash = false;
+
+ while (ISSLASH (*base))
+ base++;
+
+ for (p = base; *p; p++)
+ {
+ if (ISSLASH (*p))
+ saw_slash = true;
+ else if (saw_slash)
+ {
+ base = p;
+ saw_slash = false;
+ }
+ }
+
+ return (char *) base;
+}
+
+/* Return the length of the basename NAME. Typically NAME is the
+ value returned by base_name or last_component. Act like strlen
+ (NAME), except omit all trailing slashes. */
+
+size_t
+base_len (char const *name)
+{
+ size_t len;
+ size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
+
+ for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
+ continue;
+
+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1
+ && ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
+ return 2;
+
+ if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
+ && len == prefix_len && ISSLASH (name[prefix_len]))
+ return prefix_len + 1;
+
+ return len;
+}
diff --git a/grub-core/lib/gnulib/btowc.c b/grub-core/lib/gnulib/btowc.c
new file mode 100644
index 0000000..9e2496d
--- /dev/null
+++ b/grub-core/lib/gnulib/btowc.c
@@ -0,0 +1,39 @@
+/* Convert unibyte character to wide character.
+ Copyright (C) 2008, 2010-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <wchar.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+wint_t
+btowc (int c)
+{
+ if (c != EOF)
+ {
+ char buf[1];
+ wchar_t wc;
+
+ buf[0] = c;
+ if (mbtowc (&wc, buf, 1) >= 0)
+ return wc;
+ }
+ return WEOF;
+}
diff --git a/grub-core/lib/gnulib/c++defs.h b/grub-core/lib/gnulib/c++defs.h
new file mode 100644
index 0000000..87d0716
--- /dev/null
+++ b/grub-core/lib/gnulib/c++defs.h
@@ -0,0 +1,316 @@
+/* C++ compatible function declaration macros.
+ Copyright (C) 2010-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_CXXDEFS_H
+#define _GL_CXXDEFS_H
+
+/* Begin/end the GNULIB_NAMESPACE namespace. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
+# define _GL_END_NAMESPACE }
+#else
+# define _GL_BEGIN_NAMESPACE
+# define _GL_END_NAMESPACE
+#endif
+
+/* The three most frequent use cases of these macros are:
+
+ * For providing a substitute for a function that is missing on some
+ platforms, but is declared and works fine on the platforms on which
+ it exists:
+
+ #if @GNULIB_FOO@
+ # if !@HAVE_FOO@
+ _GL_FUNCDECL_SYS (foo, ...);
+ # endif
+ _GL_CXXALIAS_SYS (foo, ...);
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+
+ * For providing a replacement for a function that exists on all platforms,
+ but is broken/insufficient and needs to be replaced on some platforms:
+
+ #if @GNULIB_FOO@
+ # if @REPLACE_FOO@
+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+ # undef foo
+ # define foo rpl_foo
+ # endif
+ _GL_FUNCDECL_RPL (foo, ...);
+ _GL_CXXALIAS_RPL (foo, ...);
+ # else
+ _GL_CXXALIAS_SYS (foo, ...);
+ # endif
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+
+ * For providing a replacement for a function that exists on some platforms
+ but is broken/insufficient and needs to be replaced on some of them and
+ is additionally either missing or undeclared on some other platforms:
+
+ #if @GNULIB_FOO@
+ # if @REPLACE_FOO@
+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+ # undef foo
+ # define foo rpl_foo
+ # endif
+ _GL_FUNCDECL_RPL (foo, ...);
+ _GL_CXXALIAS_RPL (foo, ...);
+ # else
+ # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
+ _GL_FUNCDECL_SYS (foo, ...);
+ # endif
+ _GL_CXXALIAS_SYS (foo, ...);
+ # endif
+ _GL_CXXALIASWARN (foo);
+ #elif defined GNULIB_POSIXCHECK
+ ...
+ #endif
+*/
+
+/* _GL_EXTERN_C declaration;
+ performs the declaration with C linkage. */
+#if defined __cplusplus
+# define _GL_EXTERN_C extern "C"
+#else
+# define _GL_EXTERN_C extern
+#endif
+
+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
+ declares a replacement function, named rpl_func, with the given prototype,
+ consisting of return type, parameters, and attributes.
+ Example:
+ _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
+ _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
+ _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C rettype rpl_func parameters_and_attributes
+
+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
+ declares the system function, named func, with the given prototype,
+ consisting of return type, parameters, and attributes.
+ Example:
+ _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
+ _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C rettype func parameters_and_attributes
+
+/* _GL_CXXALIAS_RPL (func, rettype, parameters);
+ declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
+ Example:
+ _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
+
+ Wrapping rpl_func in an object with an inline conversion operator
+ avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
+#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::rpl_func; \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
+ is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
+ except that the C function rpl_func may have a slightly different
+ declaration. A cast is used to silence the "invalid conversion" error
+ that would otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>(::rpl_func); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS (func, rettype, parameters);
+ declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to the system provided function func, if GNULIB_NAMESPACE
+ is defined.
+ Example:
+ _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
+
+ Wrapping func in an object with an inline conversion operator
+ avoids a reference to func unless GNULIB_NAMESPACE::func is
+ actually used in the program. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return ::func; \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
+ is like _GL_CXXALIAS_SYS (func, rettype, parameters);
+ except that the C function func may have a slightly different declaration.
+ A cast is used to silence the "invalid conversion" error that would
+ otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>(::func); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
+ is like _GL_CXXALIAS_SYS (func, rettype, parameters);
+ except that the C function is picked among a set of overloaded functions,
+ namely the one with rettype2 and parameters2. Two consecutive casts
+ are used to silence the "cannot find a match" and "invalid conversion"
+ errors that would otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+ /* The outer cast must be a reinterpret_cast.
+ The inner cast: When the function is defined as a set of overloaded
+ functions, it works as a static_cast<>, choosing the designated variant.
+ When the function is defined as a single variant, it works as a
+ reinterpret_cast<>. The parenthesized cast syntax works both ways. */
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ static const struct _gl_ ## func ## _wrapper \
+ { \
+ typedef rettype (*type) parameters; \
+ \
+ inline operator type () const \
+ { \
+ return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
+ } \
+ } func = {}; \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN (func);
+ causes a warning to be emitted when ::func is used but not when
+ GNULIB_NAMESPACE::func is used. func must be defined without overloaded
+ variants. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN(func) \
+ _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN_1(func,namespace) \
+ _GL_CXXALIASWARN_2 (func, namespace)
+/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+ we enable the warning only when not optimizing. */
+# if !__OPTIMIZE__
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ _GL_WARN_ON_USE (func, \
+ "The symbol ::" #func " refers to the system function. " \
+ "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ extern __typeof__ (func) func
+# else
+# define _GL_CXXALIASWARN_2(func,namespace) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
+#else
+# define _GL_CXXALIASWARN(func) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
+ causes a warning to be emitted when the given overloaded variant of ::func
+ is used but not when GNULIB_NAMESPACE::func is used. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+ _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
+ GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
+ _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
+/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+ we enable the warning only when not optimizing. */
+# if !__OPTIMIZE__
+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
+ "The symbol ::" #func " refers to the system function. " \
+ "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ extern __typeof__ (func) func
+# else
+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
+#else
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+#endif /* _GL_CXXDEFS_H */
diff --git a/grub-core/lib/gnulib/cdefs.h b/grub-core/lib/gnulib/cdefs.h
new file mode 100644
index 0000000..f7a1064
--- /dev/null
+++ b/grub-core/lib/gnulib/cdefs.h
@@ -0,0 +1,514 @@
+/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_CDEFS_H
+#define _SYS_CDEFS_H 1
+
+/* We are almost always included from features.h. */
+#ifndef _FEATURES_H
+# include <features.h>
+#endif
+
+/* The GNU libc does not support any K&R compilers or the traditional mode
+ of ISO C compilers anymore. Check for some of the combinations not
+ anymore supported. */
+#if defined __GNUC__ && !defined __STDC__
+# error "You need a ISO C conforming compiler to use the glibc headers"
+#endif
+
+/* Some user header file might have defined this before. */
+#undef __P
+#undef __PMT
+
+#ifdef __GNUC__
+
+/* All functions, except those with callbacks or those that
+ synchronize memory, are leaf functions. */
+# if __GNUC_PREREQ (4, 6) && !defined _LIBC
+# define __LEAF , __leaf__
+# define __LEAF_ATTR __attribute__ ((__leaf__))
+# else
+# define __LEAF
+# define __LEAF_ATTR
+# endif
+
+/* GCC can always grok prototypes. For C++ programs we add throw()
+ to help it optimize the function calls. But this works only with
+ gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
+ as non-throwing using a function attribute since programs can use
+ the -fexceptions options for C code as well. */
+# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
+# define __THROW __attribute__ ((__nothrow__ __LEAF))
+# define __THROWNL __attribute__ ((__nothrow__))
+# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
+# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
+# else
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# define __THROW throw ()
+# define __THROWNL throw ()
+# define __NTH(fct) __LEAF_ATTR fct throw ()
+# define __NTHNL(fct) fct throw ()
+# else
+# define __THROW
+# define __THROWNL
+# define __NTH(fct) fct
+# define __NTHNL(fct) fct
+# endif
+# endif
+
+#else /* Not GCC. */
+
+# if (defined __cplusplus \
+ || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
+# define __inline inline
+# else
+# define __inline /* No inline functions. */
+# endif
+
+# define __THROW
+# define __THROWNL
+# define __NTH(fct) fct
+
+#endif /* GCC. */
+
+/* Compilers that are not clang may object to
+ #if defined __clang__ && __has_extension(...)
+ even though they do not need to evaluate the right-hand side of the &&. */
+#if defined __clang__ && defined __has_extension
+# define __glibc_clang_has_extension(ext) __has_extension (ext)
+#else
+# define __glibc_clang_has_extension(ext) 0
+#endif
+
+/* These two macros are not used in glibc anymore. They are kept here
+ only because some other projects expect the macros to be defined. */
+#define __P(args) args
+#define __PMT(args) args
+
+/* For these things, GCC behaves the ANSI way normally,
+ and the non-ANSI way under -traditional. */
+
+#define __CONCAT(x,y) x ## y
+#define __STRING(x) #x
+
+/* This is not a typedef so `const __ptr_t' does the right thing. */
+#define __ptr_t void *
+
+
+/* C++ needs to know that types and declarations are C, not C++. */
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS
+# define __END_DECLS
+#endif
+
+
+/* Fortify support. */
+#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
+#define __bos0(ptr) __builtin_object_size (ptr, 0)
+
+#if __GNUC_PREREQ (4,3)
+# define __warndecl(name, msg) \
+ extern void name (void) __attribute__((__warning__ (msg)))
+# define __warnattr(msg) __attribute__((__warning__ (msg)))
+# define __errordecl(name, msg) \
+ extern void name (void) __attribute__((__error__ (msg)))
+#else
+# define __warndecl(name, msg) extern void name (void)
+# define __warnattr(msg)
+# define __errordecl(name, msg) extern void name (void)
+#endif
+
+/* Support for flexible arrays.
+ Headers that should use flexible arrays only if they're "real"
+ (e.g. only if they won't affect sizeof()) should test
+ #if __glibc_c99_flexarr_available. */
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
+# define __flexarr []
+# define __glibc_c99_flexarr_available 1
+#elif __GNUC_PREREQ (2,97)
+/* GCC 2.97 supports C99 flexible array members as an extension,
+ even when in C89 mode or compiling C++ (any version). */
+# define __flexarr []
+# define __glibc_c99_flexarr_available 1
+#elif defined __GNUC__
+/* Pre-2.97 GCC did not support C99 flexible arrays but did have
+ an equivalent extension with slightly different notation. */
+# define __flexarr [0]
+# define __glibc_c99_flexarr_available 1
+#else
+/* Some other non-C99 compiler. Approximate with [1]. */
+# define __flexarr [1]
+# define __glibc_c99_flexarr_available 0
+#endif
+
+
+/* __asm__ ("xyz") is used throughout the headers to rename functions
+ at the assembly language level. This is wrapped by the __REDIRECT
+ macro, in order to support compilers that can do this some other
+ way. When compilers don't support asm-names at all, we have to do
+ preprocessor tricks instead (which don't have exactly the right
+ semantics, but it's the best we can do).
+
+ Example:
+ int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
+
+#if defined __GNUC__ && __GNUC__ >= 2
+
+# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
+# ifdef __cplusplus
+# define __REDIRECT_NTH(name, proto, alias) \
+ name proto __THROW __asm__ (__ASMNAME (#alias))
+# define __REDIRECT_NTHNL(name, proto, alias) \
+ name proto __THROWNL __asm__ (__ASMNAME (#alias))
+# else
+# define __REDIRECT_NTH(name, proto, alias) \
+ name proto __asm__ (__ASMNAME (#alias)) __THROW
+# define __REDIRECT_NTHNL(name, proto, alias) \
+ name proto __asm__ (__ASMNAME (#alias)) __THROWNL
+# endif
+# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
+
+/*
+#elif __SOME_OTHER_COMPILER__
+
+# define __REDIRECT(name, proto, alias) name proto; \
+ _Pragma("let " #name " = " #alias)
+*/
+#endif
+
+/* GCC has various useful declarations that can be made with the
+ `__attribute__' syntax. All of the ways we use this do fine if
+ they are omitted for compilers that don't understand it. */
+#if !defined __GNUC__ || __GNUC__ < 2
+# define __attribute__(xyz) /* Ignore */
+#endif
+
+/* At some point during the gcc 2.96 development the `malloc' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (2,96)
+# define __attribute_malloc__ __attribute__ ((__malloc__))
+#else
+# define __attribute_malloc__ /* Ignore */
+#endif
+
+/* Tell the compiler which arguments to an allocation function
+ indicate the size of the allocation. */
+#if __GNUC_PREREQ (4, 3)
+# define __attribute_alloc_size__(params) \
+ __attribute__ ((__alloc_size__ params))
+#else
+# define __attribute_alloc_size__(params) /* Ignore. */
+#endif
+
+/* At some point during the gcc 2.96 development the `pure' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (2,96)
+# define __attribute_pure__ __attribute__ ((__pure__))
+#else
+# define __attribute_pure__ /* Ignore */
+#endif
+
+/* This declaration tells the compiler that the value is constant. */
+#if __GNUC_PREREQ (2,5)
+# define __attribute_const__ __attribute__ ((__const__))
+#else
+# define __attribute_const__ /* Ignore */
+#endif
+
+/* At some point during the gcc 3.1 development the `used' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (3,1)
+# define __attribute_used__ __attribute__ ((__used__))
+# define __attribute_noinline__ __attribute__ ((__noinline__))
+#else
+# define __attribute_used__ __attribute__ ((__unused__))
+# define __attribute_noinline__ /* Ignore */
+#endif
+
+/* Since version 3.2, gcc allows marking deprecated functions. */
+#if __GNUC_PREREQ (3,2)
+# define __attribute_deprecated__ __attribute__ ((__deprecated__))
+#else
+# define __attribute_deprecated__ /* Ignore */
+#endif
+
+/* Since version 4.5, gcc also allows one to specify the message printed
+ when a deprecated function is used. clang claims to be gcc 4.2, but
+ may also support this feature. */
+#if __GNUC_PREREQ (4,5) || \
+ __glibc_clang_has_extension (__attribute_deprecated_with_message__)
+# define __attribute_deprecated_msg__(msg) \
+ __attribute__ ((__deprecated__ (msg)))
+#else
+# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
+#endif
+
+/* At some point during the gcc 2.8 development the `format_arg' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings.
+ If several `format_arg' attributes are given for the same function, in
+ gcc-3.0 and older, all but the last one are ignored. In newer gccs,
+ all designated arguments are considered. */
+#if __GNUC_PREREQ (2,8)
+# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
+#else
+# define __attribute_format_arg__(x) /* Ignore */
+#endif
+
+/* At some point during the gcc 2.97 development the `strfmon' format
+ attribute for functions was introduced. We don't want to use it
+ unconditionally (although this would be possible) since it
+ generates warnings. */
+#if __GNUC_PREREQ (2,97)
+# define __attribute_format_strfmon__(a,b) \
+ __attribute__ ((__format__ (__strfmon__, a, b)))
+#else
+# define __attribute_format_strfmon__(a,b) /* Ignore */
+#endif
+
+/* The nonnull function attribute marks pointer parameters that
+ must not be NULL. Do not define __nonnull if it is already defined,
+ for portability when this file is used in Gnulib. */
+#ifndef __nonnull
+# if __GNUC_PREREQ (3,3)
+# define __nonnull(params) __attribute__ ((__nonnull__ params))
+# else
+# define __nonnull(params)
+# endif
+#endif
+
+/* If fortification mode, we warn about unused results of certain
+ function calls which can lead to problems. */
+#if __GNUC_PREREQ (3,4)
+# define __attribute_warn_unused_result__ \
+ __attribute__ ((__warn_unused_result__))
+# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
+# define __wur __attribute_warn_unused_result__
+# endif
+#else
+# define __attribute_warn_unused_result__ /* empty */
+#endif
+#ifndef __wur
+# define __wur /* Ignore */
+#endif
+
+/* Forces a function to be always inlined. */
+#if __GNUC_PREREQ (3,2)
+/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
+ it conflicts with this definition. Therefore undefine it first to
+ allow either header to be included first. */
+# undef __always_inline
+# define __always_inline __inline __attribute__ ((__always_inline__))
+#else
+# undef __always_inline
+# define __always_inline __inline
+#endif
+
+/* Associate error messages with the source location of the call site rather
+ than with the source location inside the function. */
+#if __GNUC_PREREQ (4,3)
+# define __attribute_artificial__ __attribute__ ((__artificial__))
+#else
+# define __attribute_artificial__ /* Ignore */
+#endif
+
+/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
+ inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__
+ or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
+ older than 4.3 may define these macros and still not guarantee GNU inlining
+ semantics.
+
+ clang++ identifies itself as gcc-4.2, but has support for GNU inlining
+ semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and
+ __GNUC_GNU_INLINE__ macro definitions. */
+#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
+ || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
+ || defined __GNUC_GNU_INLINE__)))
+# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
+# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
+# define __extern_always_inline \
+ extern __always_inline __attribute__ ((__gnu_inline__))
+# else
+# define __extern_inline extern __inline
+# define __extern_always_inline extern __always_inline
+# endif
+#endif
+
+#ifdef __extern_always_inline
+# define __fortify_function __extern_always_inline __attribute_artificial__
+#endif
+
+/* GCC 4.3 and above allow passing all anonymous arguments of an
+ __extern_always_inline function to some other vararg function. */
+#if __GNUC_PREREQ (4,3)
+# define __va_arg_pack() __builtin_va_arg_pack ()
+# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
+#endif
+
+/* It is possible to compile containing GCC extensions even if GCC is
+ run in pedantic mode if the uses are carefully marked using the
+ `__extension__' keyword. But this is not generally available before
+ version 2.8. */
+#if !__GNUC_PREREQ (2,8)
+# define __extension__ /* Ignore */
+#endif
+
+/* __restrict is known in EGCS 1.2 and above. */
+#if !__GNUC_PREREQ (2,92)
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __restrict restrict
+# else
+# define __restrict /* Ignore */
+# endif
+#endif
+
+/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
+ array_name[restrict]
+ GCC 3.1 supports this. */
+#if __GNUC_PREREQ (3,1) && !defined __GNUG__
+# define __restrict_arr __restrict
+#else
+# ifdef __GNUC__
+# define __restrict_arr /* Not supported in old GCC. */
+# else
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __restrict_arr restrict
+# else
+/* Some other non-C99 compiler. */
+# define __restrict_arr /* Not supported. */
+# endif
+# endif
+#endif
+
+#if __GNUC__ >= 3
+# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
+# define __glibc_likely(cond) __builtin_expect ((cond), 1)
+#else
+# define __glibc_unlikely(cond) (cond)
+# define __glibc_likely(cond) (cond)
+#endif
+
+#ifdef __has_attribute
+# define __glibc_has_attribute(attr) __has_attribute (attr)
+#else
+# define __glibc_has_attribute(attr) 0
+#endif
+
+#if (!defined _Noreturn \
+ && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
+ && !__GNUC_PREREQ (4,7))
+# if __GNUC_PREREQ (2,8)
+# define _Noreturn __attribute__ ((__noreturn__))
+# else
+# define _Noreturn
+# endif
+#endif
+
+#if __GNUC_PREREQ (8, 0)
+/* Describes a char array whose address can safely be passed as the first
+ argument to strncpy and strncat, as the char array is not necessarily
+ a NUL-terminated string. */
+# define __attribute_nonstring__ __attribute__ ((__nonstring__))
+#else
+# define __attribute_nonstring__
+#endif
+
+#if (!defined _Static_assert && !defined __cplusplus \
+ && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
+ && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))
+# define _Static_assert(expr, diagnostic) \
+ extern int (*__Static_assert_function (void)) \
+ [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
+#endif
+
+/* The #ifndef lets Gnulib avoid including these on non-glibc
+ platforms, where the includes typically do not exist. */
+#ifndef __WORDSIZE
+# include <bits/wordsize.h>
+# include <bits/long-double.h>
+#endif
+
+#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+# define __LDBL_COMPAT 1
+# ifdef __REDIRECT
+# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
+# define __LDBL_REDIR(name, proto) \
+ __LDBL_REDIR1 (name, proto, __nldbl_##name)
+# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
+# define __LDBL_REDIR_NTH(name, proto) \
+ __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+# define __LDBL_REDIR1_DECL(name, alias) \
+ extern __typeof (name) name __asm (__ASMNAME (#alias));
+# define __LDBL_REDIR_DECL(name) \
+ extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
+# define __REDIRECT_LDBL(name, proto, alias) \
+ __LDBL_REDIR1 (name, proto, __nldbl_##alias)
+# define __REDIRECT_NTH_LDBL(name, proto, alias) \
+ __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
+# endif
+#endif
+#if !defined __LDBL_COMPAT || !defined __REDIRECT
+# define __LDBL_REDIR1(name, proto, alias) name proto
+# define __LDBL_REDIR(name, proto) name proto
+# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
+# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
+# define __LDBL_REDIR_DECL(name)
+# ifdef __REDIRECT
+# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
+# define __REDIRECT_NTH_LDBL(name, proto, alias) \
+ __REDIRECT_NTH (name, proto, alias)
+# endif
+#endif
+
+/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
+ intended for use in preprocessor macros.
+
+ Note: MESSAGE must be a _single_ string; concatenation of string
+ literals is not supported. */
+#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
+# define __glibc_macro_warning1(message) _Pragma (#message)
+# define __glibc_macro_warning(message) \
+ __glibc_macro_warning1 (GCC warning message)
+#else
+# define __glibc_macro_warning(msg)
+#endif
+
+/* Generic selection (ISO C11) is a C-only feature, available in GCC
+ since version 4.9. Previous versions do not provide generic
+ selection, even though they might set __STDC_VERSION__ to 201112L,
+ when in -std=c11 mode. Thus, we must check for !defined __GNUC__
+ when testing __STDC_VERSION__ for generic selection support.
+ On the other hand, Clang also defines __GNUC__, so a clang-specific
+ check is required to enable the use of generic selection. */
+#if !defined __cplusplus \
+ && (__GNUC_PREREQ (4, 9) \
+ || __glibc_clang_has_extension (c_generic_selections) \
+ || (!defined __GNUC__ && defined __STDC_VERSION__ \
+ && __STDC_VERSION__ >= 201112L))
+# define __HAVE_GENERIC_SELECTION 1
+#else
+# define __HAVE_GENERIC_SELECTION 0
+#endif
+
+#endif /* sys/cdefs.h */
diff --git a/grub-core/lib/gnulib/chdir-long.c b/grub-core/lib/gnulib/chdir-long.c
new file mode 100644
index 0000000..febdf59
--- /dev/null
+++ b/grub-core/lib/gnulib/chdir-long.c
@@ -0,0 +1,264 @@
+/* provide a chdir function that tries not to fail due to ENAMETOOLONG
+ Copyright (C) 2004-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering */
+
+#include <config.h>
+
+#include "chdir-long.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "assure.h"
+
+#ifndef PATH_MAX
+# error "compile this file only if your system defines PATH_MAX"
+#endif
+
+/* The results of openat() in this file are not leaked to any
+ single-threaded code that could use stdio.
+ FIXME - if the kernel ever adds support for multi-thread safety for
+ avoiding standard fds, then we should use openat_safer. */
+
+struct cd_buf
+{
+ int fd;
+};
+
+static void
+cdb_init (struct cd_buf *cdb)
+{
+ cdb->fd = AT_FDCWD;
+}
+
+static int
+cdb_fchdir (struct cd_buf const *cdb)
+{
+ return fchdir (cdb->fd);
+}
+
+static void
+cdb_free (struct cd_buf const *cdb)
+{
+ if (0 <= cdb->fd)
+ {
+ bool close_fail = close (cdb->fd);
+ assure (! close_fail);
+ }
+}
+
+/* Given a file descriptor of an open directory (or AT_FDCWD), CDB->fd,
+ try to open the CDB->fd-relative directory, DIR. If the open succeeds,
+ update CDB->fd with the resulting descriptor, close the incoming file
+ descriptor, and return zero. Upon failure, return -1 and set errno. */
+static int
+cdb_advance_fd (struct cd_buf *cdb, char const *dir)
+{
+ int new_fd = openat (cdb->fd, dir,
+ O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK);
+ if (new_fd < 0)
+ return -1;
+
+ cdb_free (cdb);
+ cdb->fd = new_fd;
+
+ return 0;
+}
+
+/* Return a pointer to the first non-slash in S. */
+static char * _GL_ATTRIBUTE_PURE
+find_non_slash (char const *s)
+{
+ size_t n_slash = strspn (s, "/");
+ return (char *) s + n_slash;
+}
+
+/* This is a function much like chdir, but without the PATH_MAX limitation
+ on the length of the directory name. A significant difference is that
+ it must be able to modify (albeit only temporarily) the directory
+ name. It handles an arbitrarily long directory name by operating
+ on manageable portions of the name. On systems without the openat
+ syscall, this means changing the working directory to more and more
+ "distant" points along the long directory name and then restoring
+ the working directory. If any of those attempts to save or restore
+ the working directory fails, this function exits nonzero.
+
+ Note that this function may still fail with errno == ENAMETOOLONG, but
+ only if the specified directory name contains a component that is long
+ enough to provoke such a failure all by itself (e.g. if the component
+ has length PATH_MAX or greater on systems that define PATH_MAX). */
+
+int
+chdir_long (char *dir)
+{
+ int e = chdir (dir);
+ if (e == 0 || errno != ENAMETOOLONG)
+ return e;
+
+ {
+ size_t len = strlen (dir);
+ char *dir_end = dir + len;
+ struct cd_buf cdb;
+ size_t n_leading_slash;
+
+ cdb_init (&cdb);
+
+ /* If DIR is the empty string, then the chdir above
+ must have failed and set errno to ENOENT. */
+ assure (0 < len);
+ assure (PATH_MAX <= len);
+
+ /* Count leading slashes. */
+ n_leading_slash = strspn (dir, "/");
+
+ /* Handle any leading slashes as well as any name that matches
+ the regular expression, m!^//hostname[/]*! . Handling this
+ prefix separately usually results in a single additional
+ cdb_advance_fd call, but it's worthwhile, since it makes the
+ code in the following loop cleaner. */
+ if (n_leading_slash == 2)
+ {
+ int err;
+ /* Find next slash.
+ We already know that dir[2] is neither a slash nor '\0'. */
+ char *slash = memchr (dir + 3, '/', dir_end - (dir + 3));
+ if (slash == NULL)
+ {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ *slash = '\0';
+ err = cdb_advance_fd (&cdb, dir);
+ *slash = '/';
+ if (err != 0)
+ goto Fail;
+ dir = find_non_slash (slash + 1);
+ }
+ else if (n_leading_slash)
+ {
+ if (cdb_advance_fd (&cdb, "/") != 0)
+ goto Fail;
+ dir += n_leading_slash;
+ }
+
+ assure (*dir != '/');
+ assure (dir <= dir_end);
+
+ while (PATH_MAX <= dir_end - dir)
+ {
+ int err;
+ /* Find a slash that is PATH_MAX or fewer bytes away from dir.
+ I.e. see if there is a slash that will give us a name of
+ length PATH_MAX-1 or less. */
+ char *slash = memrchr (dir, '/', PATH_MAX);
+ if (slash == NULL)
+ {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+
+ *slash = '\0';
+ assure (slash - dir < PATH_MAX);
+ err = cdb_advance_fd (&cdb, dir);
+ *slash = '/';
+ if (err != 0)
+ goto Fail;
+
+ dir = find_non_slash (slash + 1);
+ }
+
+ if (dir < dir_end)
+ {
+ if (cdb_advance_fd (&cdb, dir) != 0)
+ goto Fail;
+ }
+
+ if (cdb_fchdir (&cdb) != 0)
+ goto Fail;
+
+ cdb_free (&cdb);
+ return 0;
+
+ Fail:
+ {
+ int saved_errno = errno;
+ cdb_free (&cdb);
+ errno = saved_errno;
+ return -1;
+ }
+ }
+}
+
+#if TEST_CHDIR
+
+# include "closeout.h"
+# include "error.h"
+
+int
+main (int argc, char *argv[])
+{
+ char *line = NULL;
+ size_t n = 0;
+ int len;
+
+ atexit (close_stdout);
+
+ len = getline (&line, &n, stdin);
+ if (len < 0)
+ {
+ int saved_errno = errno;
+ if (feof (stdin))
+ exit (0);
+
+ error (EXIT_FAILURE, saved_errno,
+ "reading standard input");
+ }
+ else if (len == 0)
+ exit (0);
+
+ if (line[len-1] == '\n')
+ line[len-1] = '\0';
+
+ if (chdir_long (line) != 0)
+ error (EXIT_FAILURE, errno,
+ "chdir_long failed: %s", line);
+
+ if (argc <= 1)
+ {
+ /* Using 'pwd' here makes sense only if it is a robust implementation,
+ like the one in coreutils after the 2004-04-19 changes. */
+ char const *cmd = "pwd";
+ execlp (cmd, (char *) NULL);
+ error (EXIT_FAILURE, errno, "%s", cmd);
+ }
+
+ fclose (stdin);
+ fclose (stderr);
+
+ exit (EXIT_SUCCESS);
+}
+#endif
+
+/*
+Local Variables:
+compile-command: "gcc -DTEST_CHDIR=1 -g -O -W -Wall chdir-long.c libcoreutils.a"
+End:
+*/
diff --git a/grub-core/lib/gnulib/chdir-long.h b/grub-core/lib/gnulib/chdir-long.h
new file mode 100644
index 0000000..43259d1
--- /dev/null
+++ b/grub-core/lib/gnulib/chdir-long.h
@@ -0,0 +1,30 @@
+/* provide a chdir function that tries not to fail due to ENAMETOOLONG
+ Copyright (C) 2004-2005, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering. */
+
+#include <unistd.h>
+#include <limits.h>
+
+#include "pathmax.h"
+
+/* On systems without PATH_MAX, presume that chdir accepts
+ arbitrarily long directory names. */
+#ifndef PATH_MAX
+# define chdir_long(Dir) chdir (Dir)
+#else
+int chdir_long (char *dir);
+#endif
diff --git a/grub-core/lib/gnulib/cloexec.c b/grub-core/lib/gnulib/cloexec.c
new file mode 100644
index 0000000..db42576
--- /dev/null
+++ b/grub-core/lib/gnulib/cloexec.c
@@ -0,0 +1,83 @@
+/* cloexec.c - set or clear the close-on-exec descriptor flag
+
+ Copyright (C) 1991, 2004-2006, 2009-2019 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 <https://www.gnu.org/licenses/>.
+
+ The code is taken from glibc/manual/llio.texi */
+
+#include <config.h>
+
+#include "cloexec.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
+ or clear the flag if VALUE is false.
+ Return 0 on success, or -1 on error with 'errno' set.
+
+ Note that on MingW, this function does NOT protect DESC from being
+ inherited into spawned children. Instead, either use dup_cloexec
+ followed by closing the original DESC, or use interfaces such as
+ open or pipe2 that accept flags like O_CLOEXEC to create DESC
+ non-inheritable in the first place. */
+
+int
+set_cloexec_flag (int desc, bool value)
+{
+#ifdef F_SETFD
+
+ int flags = fcntl (desc, F_GETFD, 0);
+
+ if (0 <= flags)
+ {
+ int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
+
+ if (flags == newflags
+ || fcntl (desc, F_SETFD, newflags) != -1)
+ return 0;
+ }
+
+ return -1;
+
+#else /* !F_SETFD */
+
+ /* Use dup2 to reject invalid file descriptors; the cloexec flag
+ will be unaffected. */
+ if (desc < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (dup2 (desc, desc) < 0)
+ /* errno is EBADF here. */
+ return -1;
+
+ /* There is nothing we can do on this kind of platform. Punt. */
+ return 0;
+#endif /* !F_SETFD */
+}
+
+
+/* Duplicates a file handle FD, while marking the copy to be closed
+ prior to exec or spawn. Returns -1 and sets errno if FD could not
+ be duplicated. */
+
+int
+dup_cloexec (int fd)
+{
+ return fcntl (fd, F_DUPFD_CLOEXEC, 0);
+}
diff --git a/grub-core/lib/gnulib/cloexec.h b/grub-core/lib/gnulib/cloexec.h
new file mode 100644
index 0000000..06ad945
--- /dev/null
+++ b/grub-core/lib/gnulib/cloexec.h
@@ -0,0 +1,38 @@
+/* cloexec.c - set or clear the close-on-exec descriptor flag
+
+ Copyright (C) 2004, 2009-2019 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 <https://www.gnu.org/licenses/>.
+
+*/
+
+#include <stdbool.h>
+
+/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
+ or clear the flag if VALUE is false.
+ Return 0 on success, or -1 on error with 'errno' set.
+
+ Note that on MingW, this function does NOT protect DESC from being
+ inherited into spawned children. Instead, either use dup_cloexec
+ followed by closing the original DESC, or use interfaces such as
+ open or pipe2 that accept flags like O_CLOEXEC to create DESC
+ non-inheritable in the first place. */
+
+int set_cloexec_flag (int desc, bool value);
+
+/* Duplicates a file handle FD, while marking the copy to be closed
+ prior to exec or spawn. Returns -1 and sets errno if FD could not
+ be duplicated. */
+
+int dup_cloexec (int fd);
diff --git a/grub-core/lib/gnulib/close.c b/grub-core/lib/gnulib/close.c
new file mode 100644
index 0000000..40ce845
--- /dev/null
+++ b/grub-core/lib/gnulib/close.c
@@ -0,0 +1,71 @@
+/* close replacement.
+ Copyright (C) 2008-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+#include <errno.h>
+
+#include "fd-hook.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
+
+#undef close
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+static int
+close_nothrow (int fd)
+{
+ int result;
+
+ TRY_MSVC_INVAL
+ {
+ result = close (fd);
+ }
+ CATCH_MSVC_INVAL
+ {
+ result = -1;
+ errno = EBADF;
+ }
+ DONE_MSVC_INVAL;
+
+ return result;
+}
+#else
+# define close_nothrow close
+#endif
+
+/* Override close() to call into other gnulib modules. */
+
+int
+rpl_close (int fd)
+{
+#if WINDOWS_SOCKETS
+ int retval = execute_all_close_hooks (close_nothrow, fd);
+#else
+ int retval = close_nothrow (fd);
+#endif
+
+#if REPLACE_FCHDIR
+ if (retval >= 0)
+ _gl_unregister_fd (fd);
+#endif
+
+ return retval;
+}
diff --git a/grub-core/lib/gnulib/dirent.in.h b/grub-core/lib/gnulib/dirent.in.h
new file mode 100644
index 0000000..a3c8eb3
--- /dev/null
+++ b/grub-core/lib/gnulib/dirent.in.h
@@ -0,0 +1,267 @@
+/* A GNU-like <dirent.h>.
+ Copyright (C) 2006-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_DIRENT_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_DIRENT_H@
+# @INCLUDE_NEXT@ @NEXT_DIRENT_H@
+#endif
+
+#ifndef _@GUARD_PREFIX@_DIRENT_H
+#define _@GUARD_PREFIX@_DIRENT_H
+
+/* Get ino_t. Needed on some systems, including glibc 2.8. */
+#include <sys/types.h>
+
+#if !@HAVE_DIRENT_H@
+/* Define types DIR and 'struct dirent'. */
+# if !GNULIB_defined_struct_dirent
+struct dirent
+{
+ char d_type;
+ char d_name[1];
+};
+/* Possible values for 'd_type'. */
+# define DT_UNKNOWN 0
+# define DT_FIFO 1 /* FIFO */
+# define DT_CHR 2 /* character device */
+# define DT_DIR 4 /* directory */
+# define DT_BLK 6 /* block device */
+# define DT_REG 8 /* regular file */
+# define DT_LNK 10 /* symbolic link */
+# define DT_SOCK 12 /* socket */
+# define DT_WHT 14 /* whiteout */
+typedef struct gl_directory DIR;
+# define GNULIB_defined_struct_dirent 1
+# endif
+#endif
+
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The attribute __pure__ was added in gcc 2.96. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+#else
+# define _GL_ATTRIBUTE_PURE /* empty */
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+
+/* Declare overridden functions. */
+
+#if @GNULIB_OPENDIR@
+# if @REPLACE_OPENDIR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef opendir
+# define opendir rpl_opendir
+# define GNULIB_defined_opendir 1
+# endif
+_GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
+# else
+# if !@HAVE_OPENDIR@
+_GL_FUNCDECL_SYS (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name));
+# endif
+_GL_CXXALIASWARN (opendir);
+#elif defined GNULIB_POSIXCHECK
+# undef opendir
+# if HAVE_RAW_DECL_OPENDIR
+_GL_WARN_ON_USE (opendir, "opendir is not portable - "
+ "use gnulib module opendir for portability");
+# endif
+#endif
+
+#if @GNULIB_READDIR@
+# if !@HAVE_READDIR@
+_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp));
+_GL_CXXALIASWARN (readdir);
+#elif defined GNULIB_POSIXCHECK
+# undef readdir
+# if HAVE_RAW_DECL_READDIR
+_GL_WARN_ON_USE (readdir, "readdir is not portable - "
+ "use gnulib module readdir for portability");
+# endif
+#endif
+
+#if @GNULIB_REWINDDIR@
+# if !@HAVE_REWINDDIR@
+_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp));
+_GL_CXXALIASWARN (rewinddir);
+#elif defined GNULIB_POSIXCHECK
+# undef rewinddir
+# if HAVE_RAW_DECL_REWINDDIR
+_GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
+ "use gnulib module rewinddir for portability");
+# endif
+#endif
+
+#if @GNULIB_CLOSEDIR@
+# if @REPLACE_CLOSEDIR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef closedir
+# define closedir rpl_closedir
+# define GNULIB_defined_closedir 1
+# endif
+_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
+# else
+# if !@HAVE_CLOSEDIR@
+_GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (closedir, int, (DIR *dirp));
+# endif
+_GL_CXXALIASWARN (closedir);
+#elif defined GNULIB_POSIXCHECK
+# undef closedir
+# if HAVE_RAW_DECL_CLOSEDIR
+_GL_WARN_ON_USE (closedir, "closedir is not portable - "
+ "use gnulib module closedir for portability");
+# endif
+#endif
+
+#if @GNULIB_DIRFD@
+/* Return the file descriptor associated with the given directory stream,
+ or -1 if none exists. */
+# if @REPLACE_DIRFD@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef dirfd
+# define dirfd rpl_dirfd
+# endif
+_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (dirfd, int, (DIR *));
+
+# ifdef __KLIBC__
+/* Gnulib internal hooks needed to maintain the dirfd metadata. */
+_GL_EXTERN_C int _gl_register_dirp_fd (int fd, DIR *dirp)
+ _GL_ARG_NONNULL ((2));
+_GL_EXTERN_C void _gl_unregister_dirp_fd (int fd);
+# endif
+# else
+# if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
+ /* dirfd is defined as a macro and not as a function.
+ Turn it into a function and get rid of the macro. */
+static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
+# undef dirfd
+# endif
+# if !(@HAVE_DECL_DIRFD@ || defined dirfd)
+_GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (dirfd, int, (DIR *));
+# endif
+_GL_CXXALIASWARN (dirfd);
+#elif defined GNULIB_POSIXCHECK
+# undef dirfd
+# if HAVE_RAW_DECL_DIRFD
+_GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
+ "use gnulib module dirfd for portability");
+# endif
+#endif
+
+#if @GNULIB_FDOPENDIR@
+/* Open a directory stream visiting the given directory file
+ descriptor. Return NULL and set errno if fd is not visiting a
+ directory. On success, this function consumes fd (it will be
+ implicitly closed either by this function or by a subsequent
+ closedir). */
+# if @REPLACE_FDOPENDIR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fdopendir
+# define fdopendir rpl_fdopendir
+# endif
+_GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd));
+_GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
+# else
+# if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@
+_GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd));
+# endif
+_GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
+# endif
+_GL_CXXALIASWARN (fdopendir);
+#elif defined GNULIB_POSIXCHECK
+# undef fdopendir
+# if HAVE_RAW_DECL_FDOPENDIR
+_GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
+ "use gnulib module fdopendir for portability");
+# endif
+#endif
+
+#if @GNULIB_SCANDIR@
+/* Scan the directory DIR, calling FILTER on each directory entry.
+ Entries for which FILTER returns nonzero are individually malloc'd,
+ sorted using qsort with CMP, and collected in a malloc'd array in
+ *NAMELIST. Returns the number of entries selected, or -1 on error. */
+# if !@HAVE_SCANDIR@
+_GL_FUNCDECL_SYS (scandir, int,
+ (const char *dir, struct dirent ***namelist,
+ int (*filter) (const struct dirent *),
+ int (*cmp) (const struct dirent **, const struct dirent **))
+ _GL_ARG_NONNULL ((1, 2, 4)));
+# endif
+/* Need to cast, because on glibc systems, the fourth parameter is
+ int (*cmp) (const void *, const void *). */
+_GL_CXXALIAS_SYS_CAST (scandir, int,
+ (const char *dir, struct dirent ***namelist,
+ int (*filter) (const struct dirent *),
+ int (*cmp) (const struct dirent **, const struct dirent **)));
+_GL_CXXALIASWARN (scandir);
+#elif defined GNULIB_POSIXCHECK
+# undef scandir
+# if HAVE_RAW_DECL_SCANDIR
+_GL_WARN_ON_USE (scandir, "scandir is unportable - "
+ "use gnulib module scandir for portability");
+# endif
+#endif
+
+#if @GNULIB_ALPHASORT@
+/* Compare two 'struct dirent' entries alphabetically. */
+# if !@HAVE_ALPHASORT@
+_GL_FUNCDECL_SYS (alphasort, int,
+ (const struct dirent **, const struct dirent **)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+/* Need to cast, because on glibc systems, the parameters are
+ (const void *, const void *). */
+_GL_CXXALIAS_SYS_CAST (alphasort, int,
+ (const struct dirent **, const struct dirent **));
+_GL_CXXALIASWARN (alphasort);
+#elif defined GNULIB_POSIXCHECK
+# undef alphasort
+# if HAVE_RAW_DECL_ALPHASORT
+_GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
+ "use gnulib module alphasort for portability");
+# endif
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_DIRENT_H */
+#endif /* _@GUARD_PREFIX@_DIRENT_H */
diff --git a/grub-core/lib/gnulib/dirfd.c b/grub-core/lib/gnulib/dirfd.c
new file mode 100644
index 0000000..bc858fd
--- /dev/null
+++ b/grub-core/lib/gnulib/dirfd.c
@@ -0,0 +1,98 @@
+/* dirfd.c -- return the file descriptor associated with an open DIR*
+
+ Copyright (C) 2001, 2006, 2008-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering. */
+
+#include <config.h>
+
+#include <dirent.h>
+#include <errno.h>
+
+#ifdef __KLIBC__
+# include <stdlib.h>
+# include <io.h>
+
+static struct dirp_fd_list
+{
+ DIR *dirp;
+ int fd;
+ struct dirp_fd_list *next;
+} *dirp_fd_start = NULL;
+
+/* Register fd associated with dirp to dirp_fd_list. */
+int
+_gl_register_dirp_fd (int fd, DIR *dirp)
+{
+ struct dirp_fd_list *new_dirp_fd = malloc (sizeof *new_dirp_fd);
+ if (!new_dirp_fd)
+ return -1;
+
+ new_dirp_fd->dirp = dirp;
+ new_dirp_fd->fd = fd;
+ new_dirp_fd->next = dirp_fd_start;
+
+ dirp_fd_start = new_dirp_fd;
+
+ return 0;
+}
+
+/* Unregister fd from dirp_fd_list with closing it */
+void
+_gl_unregister_dirp_fd (int fd)
+{
+ struct dirp_fd_list *dirp_fd;
+ struct dirp_fd_list *dirp_fd_prev;
+
+ for (dirp_fd_prev = NULL, dirp_fd = dirp_fd_start; dirp_fd;
+ dirp_fd_prev = dirp_fd, dirp_fd = dirp_fd->next)
+ {
+ if (dirp_fd->fd == fd)
+ {
+ if (dirp_fd_prev)
+ dirp_fd_prev->next = dirp_fd->next;
+ else /* dirp_fd == dirp_fd_start */
+ dirp_fd_start = dirp_fd_start->next;
+
+ close (fd);
+ free (dirp_fd);
+ break;
+ }
+ }
+}
+#endif
+
+int
+dirfd (DIR *dir_p)
+{
+ int fd = DIR_TO_FD (dir_p);
+ if (fd == -1)
+#ifndef __KLIBC__
+ errno = ENOTSUP;
+#else
+ {
+ struct dirp_fd_list *dirp_fd;
+
+ for (dirp_fd = dirp_fd_start; dirp_fd; dirp_fd = dirp_fd->next)
+ if (dirp_fd->dirp == dir_p)
+ return dirp_fd->fd;
+
+ errno = EINVAL;
+ }
+#endif
+
+ return fd;
+}
diff --git a/grub-core/lib/gnulib/dirname-lgpl.c b/grub-core/lib/gnulib/dirname-lgpl.c
new file mode 100644
index 0000000..7cf89d8
--- /dev/null
+++ b/grub-core/lib/gnulib/dirname-lgpl.c
@@ -0,0 +1,86 @@
+/* dirname.c -- return all but the last element in a file name
+
+ Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "dirname.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+/* Return the length of the prefix of FILE that will be used by
+ dir_name. If FILE is in the working directory, this returns zero
+ even though 'dir_name (FILE)' will return ".". Works properly even
+ if there are trailing slashes (by effectively ignoring them). */
+
+size_t
+dir_len (char const *file)
+{
+ size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
+ size_t length;
+
+ /* Advance prefix_length beyond important leading slashes. */
+ prefix_length += (prefix_length != 0
+ ? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+ && ISSLASH (file[prefix_length]))
+ : (ISSLASH (file[0])
+ ? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
+ && ISSLASH (file[1]) && ! ISSLASH (file[2])
+ ? 2 : 1))
+ : 0));
+
+ /* Strip the basename and any redundant slashes before it. */
+ for (length = last_component (file) - file;
+ prefix_length < length; length--)
+ if (! ISSLASH (file[length - 1]))
+ break;
+ return length;
+}
+
+
+/* In general, we can't use the builtin 'dirname' function if available,
+ since it has different meanings in different environments.
+ In some environments the builtin 'dirname' modifies its argument.
+
+ Return the leading directories part of FILE, allocated with malloc.
+ Works properly even if there are trailing slashes (by effectively
+ ignoring them). Return NULL on failure.
+
+ If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
+ lstat (base_name (FILE)); } will access the same file. Likewise,
+ if the sequence { chdir (dir_name (FILE));
+ rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
+ to "foo" in the same directory FILE was in. */
+
+char *
+mdir_name (char const *file)
+{
+ size_t length = dir_len (file);
+ bool append_dot = (length == 0
+ || (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+ && length == FILE_SYSTEM_PREFIX_LEN (file)
+ && file[2] != '\0' && ! ISSLASH (file[2])));
+ char *dir = malloc (length + append_dot + 1);
+ if (!dir)
+ return NULL;
+ memcpy (dir, file, length);
+ if (append_dot)
+ dir[length++] = '.';
+ dir[length] = '\0';
+ return dir;
+}
diff --git a/grub-core/lib/gnulib/dirname.h b/grub-core/lib/gnulib/dirname.h
new file mode 100644
index 0000000..5791659
--- /dev/null
+++ b/grub-core/lib/gnulib/dirname.h
@@ -0,0 +1,54 @@
+/* Take file names apart into directory and base names.
+
+ Copyright (C) 1998, 2001, 2003-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef DIRNAME_H_
+# define DIRNAME_H_ 1
+
+# include <stdbool.h>
+# include <stddef.h>
+# include "dosname.h"
+
+# ifndef DIRECTORY_SEPARATOR
+# define DIRECTORY_SEPARATOR '/'
+# endif
+
+# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
+# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
+# endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+# if GNULIB_DIRNAME
+char *base_name (char const *file) _GL_ATTRIBUTE_MALLOC;
+char *dir_name (char const *file);
+# endif
+
+char *mdir_name (char const *file);
+size_t base_len (char const *file) _GL_ATTRIBUTE_PURE;
+size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
+char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
+
+bool strip_trailing_slashes (char *file);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* not DIRNAME_H_ */
diff --git a/grub-core/lib/gnulib/dosname.h b/grub-core/lib/gnulib/dosname.h
new file mode 100644
index 0000000..c0ab684
--- /dev/null
+++ b/grub-core/lib/gnulib/dosname.h
@@ -0,0 +1,52 @@
+/* File names on MS-DOS/Windows systems.
+
+ Copyright (C) 2000-2001, 2004-2006, 2009-2019 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 <https://www.gnu.org/licenses/>.
+
+ From Paul Eggert and Jim Meyering. */
+
+#ifndef _DOSNAME_H
+#define _DOSNAME_H
+
+#if (defined _WIN32 || defined __CYGWIN__ \
+ || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__)
+ /* This internal macro assumes ASCII, but all hosts that support drive
+ letters use ASCII. */
+# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
+ <= 'z' - 'a')
+# define FILE_SYSTEM_PREFIX_LEN(Filename) \
+ (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
+# ifndef __CYGWIN__
+# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
+# endif
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+#else
+# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
+# define ISSLASH(C) ((C) == '/')
+#endif
+
+#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
+#endif
+
+#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
+# else
+# define IS_ABSOLUTE_FILE_NAME(F) \
+ (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
+#endif
+#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
+
+#endif /* DOSNAME_H_ */
diff --git a/grub-core/lib/gnulib/dup-safer-flag.c b/grub-core/lib/gnulib/dup-safer-flag.c
new file mode 100644
index 0000000..485f741
--- /dev/null
+++ b/grub-core/lib/gnulib/dup-safer-flag.c
@@ -0,0 +1,38 @@
+/* Duplicate a file descriptor result, avoiding clobbering
+ STD{IN,OUT,ERR}_FILENO, with specific flags.
+
+ Copyright (C) 2001, 2004-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert and Eric Blake. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistd-safer.h"
+
+#include <fcntl.h>
+#include <unistd.h>
+
+/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or
+ STDERR_FILENO. If FLAG contains O_CLOEXEC, behave like
+ fcntl(F_DUPFD_CLOEXEC) rather than fcntl(F_DUPFD). */
+
+int
+dup_safer_flag (int fd, int flag)
+{
+ return fcntl (fd, (flag & O_CLOEXEC) ? F_DUPFD_CLOEXEC : F_DUPFD,
+ STDERR_FILENO + 1);
+}
diff --git a/grub-core/lib/gnulib/dup-safer.c b/grub-core/lib/gnulib/dup-safer.c
new file mode 100644
index 0000000..c0c5f2a
--- /dev/null
+++ b/grub-core/lib/gnulib/dup-safer.c
@@ -0,0 +1,34 @@
+/* Invoke dup, but avoid some glitches.
+
+ Copyright (C) 2001, 2004-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#include <config.h>
+
+#include "unistd-safer.h"
+
+#include <fcntl.h>
+#include <unistd.h>
+
+/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or
+ STDERR_FILENO. */
+
+int
+dup_safer (int fd)
+{
+ return fcntl (fd, F_DUPFD, STDERR_FILENO + 1);
+}
diff --git a/grub-core/lib/gnulib/dup2.c b/grub-core/lib/gnulib/dup2.c
new file mode 100644
index 0000000..d3aafa4
--- /dev/null
+++ b/grub-core/lib/gnulib/dup2.c
@@ -0,0 +1,235 @@
+/* Duplicate an open file descriptor to a specified file descriptor.
+
+ Copyright (C) 1999, 2004-2007, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* written by Paul Eggert */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+#include <errno.h>
+#include <fcntl.h>
+
+#if HAVE_DUP2
+
+# undef dup2
+
+# if defined _WIN32 && ! defined __CYGWIN__
+
+/* Get declarations of the native Windows API functions. */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
+
+/* Get _get_osfhandle. */
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+static int
+dup2_nothrow (int fd, int desired_fd)
+{
+ int result;
+
+ TRY_MSVC_INVAL
+ {
+ result = dup2 (fd, desired_fd);
+ }
+ CATCH_MSVC_INVAL
+ {
+ errno = EBADF;
+ result = -1;
+ }
+ DONE_MSVC_INVAL;
+
+ return result;
+}
+# else
+# define dup2_nothrow dup2
+# endif
+
+static int
+ms_windows_dup2 (int fd, int desired_fd)
+{
+ int result;
+
+ /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open,
+ dup2 (fd, fd) returns 0, but all further attempts to use fd in
+ future dup2 calls will hang. */
+ if (fd == desired_fd)
+ {
+ if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ return fd;
+ }
+
+ /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
+ https://bugs.winehq.org/show_bug.cgi?id=21289 */
+ if (desired_fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ result = dup2_nothrow (fd, desired_fd);
+
+ if (result == 0)
+ result = desired_fd;
+
+ return result;
+}
+
+# define dup2 ms_windows_dup2
+
+# elif defined __KLIBC__
+
+# include <InnoTekLIBC/backend.h>
+
+static int
+klibc_dup2dirfd (int fd, int desired_fd)
+{
+ int tempfd;
+ int dupfd;
+
+ tempfd = open ("NUL", O_RDONLY);
+ if (tempfd == -1)
+ return -1;
+
+ if (tempfd == desired_fd)
+ {
+ close (tempfd);
+
+ char path[_MAX_PATH];
+ if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
+ return -1;
+
+ return open(path, O_RDONLY);
+ }
+
+ dupfd = klibc_dup2dirfd (fd, desired_fd);
+
+ close (tempfd);
+
+ return dupfd;
+}
+
+static int
+klibc_dup2 (int fd, int desired_fd)
+{
+ int dupfd;
+ struct stat sbuf;
+
+ dupfd = dup2 (fd, desired_fd);
+ if (dupfd == -1 && errno == ENOTSUP \
+ && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
+ {
+ close (desired_fd);
+
+ return klibc_dup2dirfd (fd, desired_fd);
+ }
+
+ return dupfd;
+}
+
+# define dup2 klibc_dup2
+# endif
+
+int
+rpl_dup2 (int fd, int desired_fd)
+{
+ int result;
+
+# ifdef F_GETFL
+ /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
+ On Cygwin 1.5.x, dup2 (1, 1) returns 0.
+ On Cygwin 1.7.17, dup2 (1, -1) dumps core.
+ On Cygwin 1.7.25, dup2 (1, 256) can dump core.
+ On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */
+# if HAVE_SETDTABLESIZE
+ setdtablesize (desired_fd + 1);
+# endif
+ if (desired_fd < 0)
+ fd = desired_fd;
+ if (fd == desired_fd)
+ return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
+# endif
+
+ result = dup2 (fd, desired_fd);
+
+ /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */
+ if (result == -1 && errno == EMFILE)
+ errno = EBADF;
+# if REPLACE_FCHDIR
+ if (fd != desired_fd && result != -1)
+ result = _gl_register_dup (fd, result);
+# endif
+ return result;
+}
+
+#else /* !HAVE_DUP2 */
+
+/* On older platforms, dup2 did not exist. */
+
+# ifndef F_DUPFD
+static int
+dupfd (int fd, int desired_fd)
+{
+ int duplicated_fd = dup (fd);
+ if (duplicated_fd < 0 || duplicated_fd == desired_fd)
+ return duplicated_fd;
+ else
+ {
+ int r = dupfd (fd, desired_fd);
+ int e = errno;
+ close (duplicated_fd);
+ errno = e;
+ return r;
+ }
+}
+# endif
+
+int
+dup2 (int fd, int desired_fd)
+{
+ int result = fcntl (fd, F_GETFL) < 0 ? -1 : fd;
+ if (result == -1 || fd == desired_fd)
+ return result;
+ close (desired_fd);
+# ifdef F_DUPFD
+ result = fcntl (fd, F_DUPFD, desired_fd);
+# if REPLACE_FCHDIR
+ if (0 <= result)
+ result = _gl_register_dup (fd, result);
+# endif
+# else
+ result = dupfd (fd, desired_fd);
+# endif
+ if (result == -1 && (errno == EMFILE || errno == EINVAL))
+ errno = EBADF;
+ return result;
+}
+#endif /* !HAVE_DUP2 */
diff --git a/grub-core/lib/gnulib/errno.in.h b/grub-core/lib/gnulib/errno.in.h
new file mode 100644
index 0000000..3bd27f1
--- /dev/null
+++ b/grub-core/lib/gnulib/errno.in.h
@@ -0,0 +1,279 @@
+/* A POSIX-like <errno.h>.
+
+ Copyright (C) 2008-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_ERRNO_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_ERRNO_H@
+
+#ifndef _@GUARD_PREFIX@_ERRNO_H
+#define _@GUARD_PREFIX@_ERRNO_H
+
+
+/* On native Windows platforms, many macros are not defined. */
+# if defined _WIN32 && ! defined __CYGWIN__
+
+/* These are the same values as defined by MSVC 10, for interoperability. */
+
+# ifndef ENOMSG
+# define ENOMSG 122
+# define GNULIB_defined_ENOMSG 1
+# endif
+
+# ifndef EIDRM
+# define EIDRM 111
+# define GNULIB_defined_EIDRM 1
+# endif
+
+# ifndef ENOLINK
+# define ENOLINK 121
+# define GNULIB_defined_ENOLINK 1
+# endif
+
+# ifndef EPROTO
+# define EPROTO 134
+# define GNULIB_defined_EPROTO 1
+# endif
+
+# ifndef EBADMSG
+# define EBADMSG 104
+# define GNULIB_defined_EBADMSG 1
+# endif
+
+# ifndef EOVERFLOW
+# define EOVERFLOW 132
+# define GNULIB_defined_EOVERFLOW 1
+# endif
+
+# ifndef ENOTSUP
+# define ENOTSUP 129
+# define GNULIB_defined_ENOTSUP 1
+# endif
+
+# ifndef ENETRESET
+# define ENETRESET 117
+# define GNULIB_defined_ENETRESET 1
+# endif
+
+# ifndef ECONNABORTED
+# define ECONNABORTED 106
+# define GNULIB_defined_ECONNABORTED 1
+# endif
+
+# ifndef ECANCELED
+# define ECANCELED 105
+# define GNULIB_defined_ECANCELED 1
+# endif
+
+# ifndef EOWNERDEAD
+# define EOWNERDEAD 133
+# define GNULIB_defined_EOWNERDEAD 1
+# endif
+
+# ifndef ENOTRECOVERABLE
+# define ENOTRECOVERABLE 127
+# define GNULIB_defined_ENOTRECOVERABLE 1
+# endif
+
+# ifndef EINPROGRESS
+# define EINPROGRESS 112
+# define EALREADY 103
+# define ENOTSOCK 128
+# define EDESTADDRREQ 109
+# define EMSGSIZE 115
+# define EPROTOTYPE 136
+# define ENOPROTOOPT 123
+# define EPROTONOSUPPORT 135
+# define EOPNOTSUPP 130
+# define EAFNOSUPPORT 102
+# define EADDRINUSE 100
+# define EADDRNOTAVAIL 101
+# define ENETDOWN 116
+# define ENETUNREACH 118
+# define ECONNRESET 108
+# define ENOBUFS 119
+# define EISCONN 113
+# define ENOTCONN 126
+# define ETIMEDOUT 138
+# define ECONNREFUSED 107
+# define ELOOP 114
+# define EHOSTUNREACH 110
+# define EWOULDBLOCK 140
+# define GNULIB_defined_ESOCK 1
+# endif
+
+# ifndef ETXTBSY
+# define ETXTBSY 139
+# define ENODATA 120 /* not required by POSIX */
+# define ENOSR 124 /* not required by POSIX */
+# define ENOSTR 125 /* not required by POSIX */
+# define ETIME 137 /* not required by POSIX */
+# define EOTHER 131 /* not required by POSIX */
+# define GNULIB_defined_ESTREAMS 1
+# endif
+
+/* These are intentionally the same values as the WSA* error numbers, defined
+ in <winsock2.h>. */
+# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */
+# define EPFNOSUPPORT 10046 /* not required by POSIX */
+# define ESHUTDOWN 10058 /* not required by POSIX */
+# define ETOOMANYREFS 10059 /* not required by POSIX */
+# define EHOSTDOWN 10064 /* not required by POSIX */
+# define EPROCLIM 10067 /* not required by POSIX */
+# define EUSERS 10068 /* not required by POSIX */
+# define EDQUOT 10069
+# define ESTALE 10070
+# define EREMOTE 10071 /* not required by POSIX */
+# define GNULIB_defined_EWINSOCK 1
+
+# endif
+
+
+/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros
+ EMULTIHOP, ENOLINK, EOVERFLOW are not defined. */
+# if @EMULTIHOP_HIDDEN@
+# define EMULTIHOP @EMULTIHOP_VALUE@
+# define GNULIB_defined_EMULTIHOP 1
+# endif
+# if @ENOLINK_HIDDEN@
+# define ENOLINK @ENOLINK_VALUE@
+# define GNULIB_defined_ENOLINK 1
+# endif
+# if @EOVERFLOW_HIDDEN@
+# define EOVERFLOW @EOVERFLOW_VALUE@
+# define GNULIB_defined_EOVERFLOW 1
+# endif
+
+
+/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
+ EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
+ Likewise, on NonStop Kernel, EDQUOT is not defined.
+ Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151,
+ HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.
+
+ Note: When one of these systems defines some of these macros some day,
+ binaries will have to be recompiled so that they recognizes the new
+ errno values from the system. */
+
+# ifndef ENOMSG
+# define ENOMSG 2000
+# define GNULIB_defined_ENOMSG 1
+# endif
+
+# ifndef EIDRM
+# define EIDRM 2001
+# define GNULIB_defined_EIDRM 1
+# endif
+
+# ifndef ENOLINK
+# define ENOLINK 2002
+# define GNULIB_defined_ENOLINK 1
+# endif
+
+# ifndef EPROTO
+# define EPROTO 2003
+# define GNULIB_defined_EPROTO 1
+# endif
+
+# ifndef EMULTIHOP
+# define EMULTIHOP 2004
+# define GNULIB_defined_EMULTIHOP 1
+# endif
+
+# ifndef EBADMSG
+# define EBADMSG 2005
+# define GNULIB_defined_EBADMSG 1
+# endif
+
+# ifndef EOVERFLOW
+# define EOVERFLOW 2006
+# define GNULIB_defined_EOVERFLOW 1
+# endif
+
+# ifndef ENOTSUP
+# define ENOTSUP 2007
+# define GNULIB_defined_ENOTSUP 1
+# endif
+
+# ifndef ENETRESET
+# define ENETRESET 2011
+# define GNULIB_defined_ENETRESET 1
+# endif
+
+# ifndef ECONNABORTED
+# define ECONNABORTED 2012
+# define GNULIB_defined_ECONNABORTED 1
+# endif
+
+# ifndef ESTALE
+# define ESTALE 2009
+# define GNULIB_defined_ESTALE 1
+# endif
+
+# ifndef EDQUOT
+# define EDQUOT 2010
+# define GNULIB_defined_EDQUOT 1
+# endif
+
+# ifndef ECANCELED
+# define ECANCELED 2008
+# define GNULIB_defined_ECANCELED 1
+# endif
+
+/* On many platforms, the macros EOWNERDEAD and ENOTRECOVERABLE are not
+ defined. */
+
+# ifndef EOWNERDEAD
+# if defined __sun
+ /* Use the same values as defined for Solaris >= 8, for
+ interoperability. */
+# define EOWNERDEAD 58
+# define ENOTRECOVERABLE 59
+# elif defined _WIN32 && ! defined __CYGWIN__
+ /* We have a conflict here: pthreads-win32 defines these values
+ differently than MSVC 10. It's hairy to decide which one to use. */
+# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
+ /* Use the same values as defined by pthreads-win32, for
+ interoperability. */
+# define EOWNERDEAD 43
+# define ENOTRECOVERABLE 44
+# else
+ /* Use the same values as defined by MSVC 10, for
+ interoperability. */
+# define EOWNERDEAD 133
+# define ENOTRECOVERABLE 127
+# endif
+# else
+# define EOWNERDEAD 2013
+# define ENOTRECOVERABLE 2014
+# endif
+# define GNULIB_defined_EOWNERDEAD 1
+# define GNULIB_defined_ENOTRECOVERABLE 1
+# endif
+
+# ifndef EILSEQ
+# define EILSEQ 2015
+# define GNULIB_defined_EILSEQ 1
+# endif
+
+#endif /* _@GUARD_PREFIX@_ERRNO_H */
+#endif /* _@GUARD_PREFIX@_ERRNO_H */
diff --git a/grub-core/lib/gnulib/error.c b/grub-core/lib/gnulib/error.c
new file mode 100644
index 0000000..7e532f0
--- /dev/null
+++ b/grub-core/lib/gnulib/error.c
@@ -0,0 +1,411 @@
+/* Error handler for noninteractive utilities
+ Copyright (C) 1990-1998, 2000-2007, 2009-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
+
+#if !_LIBC
+# include <config.h>
+#endif
+
+#include "error.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if !_LIBC && ENABLE_NLS
+# include "gettext.h"
+# define _(msgid) gettext (msgid)
+#endif
+
+#ifdef _LIBC
+# include <libintl.h>
+# include <stdbool.h>
+# include <stdint.h>
+# include <wchar.h>
+# define mbsrtowcs __mbsrtowcs
+# define USE_UNLOCKED_IO 0
+# define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b)
+# define _GL_ARG_NONNULL(a)
+#else
+# include "getprogname.h"
+#endif
+
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+#endif
+
+#ifndef _
+# define _(String) String
+#endif
+
+/* If NULL, error will flush stdout, then print on stderr the program
+ name, a colon and a space. Otherwise, error will call this
+ function without parameters instead. */
+void (*error_print_progname) (void);
+
+/* This variable is incremented each time 'error' is called. */
+unsigned int error_message_count;
+
+#ifdef _LIBC
+/* In the GNU C library, there is a predefined variable for this. */
+
+# define program_name program_invocation_name
+# include <errno.h>
+# include <limits.h>
+# include <libio/libioP.h>
+
+/* In GNU libc we want do not want to use the common name 'error' directly.
+ Instead make it a weak alias. */
+extern void __error (int status, int errnum, const char *message, ...)
+ __attribute__ ((__format__ (__printf__, 3, 4)));
+extern void __error_at_line (int status, int errnum, const char *file_name,
+ unsigned int line_number, const char *message,
+ ...)
+ __attribute__ ((__format__ (__printf__, 5, 6)));
+# define error __error
+# define error_at_line __error_at_line
+
+# include <libio/iolibio.h>
+# define fflush(s) _IO_fflush (s)
+# undef putc
+# define putc(c, fp) _IO_putc (c, fp)
+
+# include <bits/libc-lock.h>
+
+#else /* not _LIBC */
+
+# include <fcntl.h>
+# include <unistd.h>
+
+# if defined _WIN32 && ! defined __CYGWIN__
+/* Get declarations of the native Windows API functions. */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+/* Get _get_osfhandle. */
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
+# endif
+
+/* The gnulib override of fcntl is not needed in this file. */
+# undef fcntl
+
+# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R)
+# ifndef HAVE_DECL_STRERROR_R
+"this configure-time declaration test was not run"
+# endif
+# if STRERROR_R_CHAR_P
+char *strerror_r (int errnum, char *buf, size_t buflen);
+# else
+int strerror_r (int errnum, char *buf, size_t buflen);
+# endif
+# endif
+
+#define program_name getprogname ()
+
+# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r
+# define __strerror_r strerror_r
+# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
+#endif /* not _LIBC */
+
+#if !_LIBC
+/* Return non-zero if FD is open. */
+static int
+is_open (int fd)
+{
+# if defined _WIN32 && ! defined __CYGWIN__
+ /* On native Windows: The initial state of unassigned standard file
+ descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
+ There is no fcntl, and the gnulib replacement fcntl does not support
+ F_GETFL. */
+ return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
+# else
+# ifndef F_GETFL
+# error Please port fcntl to your platform
+# endif
+ return 0 <= fcntl (fd, F_GETFL);
+# endif
+}
+#endif
+
+static void
+flush_stdout (void)
+{
+#if !_LIBC
+ int stdout_fd;
+
+# if GNULIB_FREOPEN_SAFER
+ /* Use of gnulib's freopen-safer module normally ensures that
+ fileno (stdout) == 1
+ whenever stdout is open. */
+ stdout_fd = STDOUT_FILENO;
+# else
+ /* POSIX states that fileno (stdout) after fclose is unspecified. But in
+ practice it is not a problem, because stdout is statically allocated and
+ the fd of a FILE stream is stored as a field in its allocated memory. */
+ stdout_fd = fileno (stdout);
+# endif
+ /* POSIX states that fflush (stdout) after fclose is unspecified; it
+ is safe in glibc, but not on all other platforms. fflush (NULL)
+ is always defined, but too draconian. */
+ if (0 <= stdout_fd && is_open (stdout_fd))
+#endif
+ fflush (stdout);
+}
+
+static void
+print_errno_message (int errnum)
+{
+ char const *s;
+
+#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R
+ char errbuf[1024];
+# if _LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P)
+ s = __strerror_r (errnum, errbuf, sizeof errbuf);
+# else
+ if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
+ s = errbuf;
+ else
+ s = 0;
+# endif
+#else
+ s = strerror (errnum);
+#endif
+
+#if !_LIBC
+ if (! s)
+ s = _("Unknown system error");
+#endif
+
+#if _LIBC
+ __fxprintf (NULL, ": %s", s);
+#else
+ fprintf (stderr, ": %s", s);
+#endif
+}
+
+static void _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3))
+error_tail (int status, int errnum, const char *message, va_list args)
+{
+#if _LIBC
+ if (_IO_fwide (stderr, 0) > 0)
+ {
+ size_t len = strlen (message) + 1;
+ wchar_t *wmessage = NULL;
+ mbstate_t st;
+ size_t res;
+ const char *tmp;
+ bool use_malloc = false;
+
+ while (1)
+ {
+ if (__libc_use_alloca (len * sizeof (wchar_t)))
+ wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
+ else
+ {
+ if (!use_malloc)
+ wmessage = NULL;
+
+ wchar_t *p = (wchar_t *) realloc (wmessage,
+ len * sizeof (wchar_t));
+ if (p == NULL)
+ {
+ free (wmessage);
+ fputws_unlocked (L"out of memory\n", stderr);
+ return;
+ }
+ wmessage = p;
+ use_malloc = true;
+ }
+
+ memset (&st, '\0', sizeof (st));
+ tmp = message;
+
+ res = mbsrtowcs (wmessage, &tmp, len, &st);
+ if (res != len)
+ break;
+
+ if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0))
+ {
+ /* This really should not happen if everything is fine. */
+ res = (size_t) -1;
+ break;
+ }
+
+ len *= 2;
+ }
+
+ if (res == (size_t) -1)
+ {
+ /* The string cannot be converted. */
+ if (use_malloc)
+ {
+ free (wmessage);
+ use_malloc = false;
+ }
+ wmessage = (wchar_t *) L"???";
+ }
+
+ __vfwprintf (stderr, wmessage, args);
+
+ if (use_malloc)
+ free (wmessage);
+ }
+ else
+#endif
+ vfprintf (stderr, message, args);
+
+ ++error_message_count;
+ if (errnum)
+ print_errno_message (errnum);
+#if _LIBC
+ __fxprintf (NULL, "\n");
+#else
+ putc ('\n', stderr);
+#endif
+ fflush (stderr);
+ if (status)
+ exit (status);
+}
+
+
+/* Print the program name and error message MESSAGE, which is a printf-style
+ format string with optional args.
+ If ERRNUM is nonzero, print its corresponding system error message.
+ Exit with status STATUS if it is nonzero. */
+void
+error (int status, int errnum, const char *message, ...)
+{
+ va_list args;
+
+#if defined _LIBC && defined __libc_ptf_call
+ /* We do not want this call to be cut short by a thread
+ cancellation. Therefore disable cancellation for now. */
+ int state = PTHREAD_CANCEL_ENABLE;
+ __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
+ 0);
+#endif
+
+ flush_stdout ();
+#ifdef _LIBC
+ _IO_flockfile (stderr);
+#endif
+ if (error_print_progname)
+ (*error_print_progname) ();
+ else
+ {
+#if _LIBC
+ __fxprintf (NULL, "%s: ", program_name);
+#else
+ fprintf (stderr, "%s: ", program_name);
+#endif
+ }
+
+ va_start (args, message);
+ error_tail (status, errnum, message, args);
+ va_end (args);
+
+#ifdef _LIBC
+ _IO_funlockfile (stderr);
+# ifdef __libc_ptf_call
+ __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
+# endif
+#endif
+}
+
+/* Sometimes we want to have at most one error per line. This
+ variable controls whether this mode is selected or not. */
+int error_one_per_line;
+
+void
+error_at_line (int status, int errnum, const char *file_name,
+ unsigned int line_number, const char *message, ...)
+{
+ va_list args;
+
+ if (error_one_per_line)
+ {
+ static const char *old_file_name;
+ static unsigned int old_line_number;
+
+ if (old_line_number == line_number
+ && (file_name == old_file_name
+ || (old_file_name != NULL
+ && file_name != NULL
+ && strcmp (old_file_name, file_name) == 0)))
+
+ /* Simply return and print nothing. */
+ return;
+
+ old_file_name = file_name;
+ old_line_number = line_number;
+ }
+
+#if defined _LIBC && defined __libc_ptf_call
+ /* We do not want this call to be cut short by a thread
+ cancellation. Therefore disable cancellation for now. */
+ int state = PTHREAD_CANCEL_ENABLE;
+ __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
+ 0);
+#endif
+
+ flush_stdout ();
+#ifdef _LIBC
+ _IO_flockfile (stderr);
+#endif
+ if (error_print_progname)
+ (*error_print_progname) ();
+ else
+ {
+#if _LIBC
+ __fxprintf (NULL, "%s:", program_name);
+#else
+ fprintf (stderr, "%s:", program_name);
+#endif
+ }
+
+#if _LIBC
+ __fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ",
+ file_name, line_number);
+#else
+ fprintf (stderr, file_name != NULL ? "%s:%u: " : " ",
+ file_name, line_number);
+#endif
+
+ va_start (args, message);
+ error_tail (status, errnum, message, args);
+ va_end (args);
+
+#ifdef _LIBC
+ _IO_funlockfile (stderr);
+# ifdef __libc_ptf_call
+ __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
+# endif
+#endif
+}
+
+#ifdef _LIBC
+/* Make the weak alias. */
+# undef error
+# undef error_at_line
+weak_alias (__error, error)
+weak_alias (__error_at_line, error_at_line)
+#endif
diff --git a/grub-core/lib/gnulib/error.h b/grub-core/lib/gnulib/error.h
new file mode 100644
index 0000000..3759f8a
--- /dev/null
+++ b/grub-core/lib/gnulib/error.h
@@ -0,0 +1,75 @@
+/* Declaration for error-reporting function
+ Copyright (C) 1995-1997, 2003, 2006, 2008-2019 Free Software Foundation,
+ Inc.
+ This file is part of the GNU C Library.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _ERROR_H
+#define _ERROR_H 1
+
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The __-protected variants of the attributes 'format' and 'printf' are
+ accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+ We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
+ gnulib and libintl do '#define printf __printf__' when they override
+ the 'printf' function. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
+#endif
+
+/* On mingw, the flavor of printf depends on whether the extensions module
+ * is in use; the check for <stdio.h> determines the witness macro. */
+#ifndef _GL_ATTRIBUTE_SPEC_PRINTF
+# if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
+# define _GL_ATTRIBUTE_SPEC_PRINTF __gnu_printf__
+# else
+# define _GL_ATTRIBUTE_SPEC_PRINTF __printf__
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Print a message with 'fprintf (stderr, FORMAT, ...)';
+ if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
+ If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */
+
+extern void error (int __status, int __errnum, const char *__format, ...)
+ _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 3, 4));
+
+extern void error_at_line (int __status, int __errnum, const char *__fname,
+ unsigned int __lineno, const char *__format, ...)
+ _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 5, 6));
+
+/* If NULL, error will flush stdout, then print on stderr the program
+ name, a colon and a space. Otherwise, error will call this
+ function without parameters instead. */
+extern void (*error_print_progname) (void);
+
+/* This variable is incremented each time 'error' is called. */
+extern unsigned int error_message_count;
+
+/* Sometimes we want to have at most one error per line. This
+ variable controls whether this mode is selected or not. */
+extern int error_one_per_line;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* error.h */
diff --git a/grub-core/lib/gnulib/exitfail.c b/grub-core/lib/gnulib/exitfail.c
new file mode 100644
index 0000000..69b3513
--- /dev/null
+++ b/grub-core/lib/gnulib/exitfail.c
@@ -0,0 +1,24 @@
+/* Failure exit status
+
+ Copyright (C) 2002-2003, 2005-2007, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "exitfail.h"
+
+#include <stdlib.h>
+
+int volatile exit_failure = EXIT_FAILURE;
diff --git a/grub-core/lib/gnulib/exitfail.h b/grub-core/lib/gnulib/exitfail.h
new file mode 100644
index 0000000..480ad1a
--- /dev/null
+++ b/grub-core/lib/gnulib/exitfail.h
@@ -0,0 +1,18 @@
+/* Failure exit status
+
+ Copyright (C) 2002, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+extern int volatile exit_failure;
diff --git a/grub-core/lib/gnulib/fchdir.c b/grub-core/lib/gnulib/fchdir.c
new file mode 100644
index 0000000..38ab802
--- /dev/null
+++ b/grub-core/lib/gnulib/fchdir.c
@@ -0,0 +1,208 @@
+/* fchdir replacement.
+ Copyright (C) 2006-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "assure.h"
+#include "dosname.h"
+#include "filenamecat.h"
+
+#ifndef REPLACE_OPEN_DIRECTORY
+# define REPLACE_OPEN_DIRECTORY 0
+#endif
+
+/* This replacement assumes that a directory is not renamed while opened
+ through a file descriptor.
+
+ FIXME: On mingw, this would be possible to enforce if we were to
+ also open a HANDLE to each directory currently visited by a file
+ descriptor, since mingw refuses to rename any in-use file system
+ object. */
+
+/* Array of file descriptors opened. If REPLACE_OPEN_DIRECTORY or if it points
+ to a directory, it stores info about this directory. */
+typedef struct
+{
+ char *name; /* Absolute name of the directory, or NULL. */
+ /* FIXME - add a DIR* member to make dirfd possible on mingw? */
+} dir_info_t;
+static dir_info_t *dirs;
+static size_t dirs_allocated;
+
+/* Try to ensure dirs has enough room for a slot at index fd; free any
+ contents already in that slot. Return false and set errno to
+ ENOMEM on allocation failure. */
+static bool
+ensure_dirs_slot (size_t fd)
+{
+ if (fd < dirs_allocated)
+ free (dirs[fd].name);
+ else
+ {
+ size_t new_allocated;
+ dir_info_t *new_dirs;
+
+ new_allocated = 2 * dirs_allocated + 1;
+ if (new_allocated <= fd)
+ new_allocated = fd + 1;
+ new_dirs =
+ (dirs != NULL
+ ? (dir_info_t *) realloc (dirs, new_allocated * sizeof *dirs)
+ : (dir_info_t *) malloc (new_allocated * sizeof *dirs));
+ if (new_dirs == NULL)
+ return false;
+ memset (new_dirs + dirs_allocated, 0,
+ (new_allocated - dirs_allocated) * sizeof *dirs);
+ dirs = new_dirs;
+ dirs_allocated = new_allocated;
+ }
+ return true;
+}
+
+/* Return an absolute name of DIR in malloc'd storage. */
+static char *
+get_name (char const *dir)
+{
+ char *cwd;
+ char *result;
+ int saved_errno;
+
+ if (IS_ABSOLUTE_FILE_NAME (dir))
+ return strdup (dir);
+
+ /* We often encounter "."; treat it as a special case. */
+ cwd = getcwd (NULL, 0);
+ if (!cwd || (dir[0] == '.' && dir[1] == '\0'))
+ return cwd;
+
+ result = mfile_name_concat (cwd, dir, NULL);
+ saved_errno = errno;
+ free (cwd);
+ errno = saved_errno;
+ return result;
+}
+
+/* Hook into the gnulib replacements for open() and close() to keep track
+ of the open file descriptors. */
+
+/* Close FD, cleaning up any fd to name mapping if fd was visiting a
+ directory. */
+void
+_gl_unregister_fd (int fd)
+{
+ if (fd >= 0 && fd < dirs_allocated)
+ {
+ free (dirs[fd].name);
+ dirs[fd].name = NULL;
+ }
+}
+
+/* Mark FD as visiting FILENAME. FD must be non-negative, and refer
+ to an open file descriptor. If REPLACE_OPEN_DIRECTORY is non-zero,
+ this should only be called if FD is visiting a directory. Close FD
+ and return -1 if there is insufficient memory to track the
+ directory name; otherwise return FD. */
+int
+_gl_register_fd (int fd, const char *filename)
+{
+ struct stat statbuf;
+
+ assure (0 <= fd);
+ if (REPLACE_OPEN_DIRECTORY
+ || (fstat (fd, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)))
+ {
+ if (!ensure_dirs_slot (fd)
+ || (dirs[fd].name = get_name (filename)) == NULL)
+ {
+ int saved_errno = errno;
+ close (fd);
+ errno = saved_errno;
+ return -1;
+ }
+ }
+ return fd;
+}
+
+/* Mark NEWFD as a duplicate of OLDFD; useful from dup, dup2, dup3,
+ and fcntl. Both arguments must be valid and distinct file
+ descriptors. Close NEWFD and return -1 if OLDFD is tracking a
+ directory, but there is insufficient memory to track the same
+ directory in NEWFD; otherwise return NEWFD. */
+int
+_gl_register_dup (int oldfd, int newfd)
+{
+ assure (0 <= oldfd && 0 <= newfd && oldfd != newfd);
+ if (oldfd < dirs_allocated && dirs[oldfd].name)
+ {
+ /* Duplicated a directory; must ensure newfd is allocated. */
+ if (!ensure_dirs_slot (newfd)
+ || (dirs[newfd].name = strdup (dirs[oldfd].name)) == NULL)
+ {
+ int saved_errno = errno;
+ close (newfd);
+ errno = saved_errno;
+ newfd = -1;
+ }
+ }
+ else if (newfd < dirs_allocated)
+ {
+ /* Duplicated a non-directory; ensure newfd is cleared. */
+ free (dirs[newfd].name);
+ dirs[newfd].name = NULL;
+ }
+ return newfd;
+}
+
+/* If FD is currently visiting a directory, then return the name of
+ that directory. Otherwise, return NULL and set errno. */
+const char *
+_gl_directory_name (int fd)
+{
+ if (0 <= fd && fd < dirs_allocated && dirs[fd].name != NULL)
+ return dirs[fd].name;
+ /* At this point, fd is either invalid, or open but not a directory.
+ If dup2 fails, errno is correctly EBADF. */
+ if (0 <= fd)
+ {
+ if (dup2 (fd, fd) == fd)
+ errno = ENOTDIR;
+ }
+ else
+ errno = EBADF;
+ return NULL;
+}
+
+
+/* Implement fchdir() in terms of chdir(). */
+
+int
+fchdir (int fd)
+{
+ const char *name = _gl_directory_name (fd);
+ return name ? chdir (name) : -1;
+}
diff --git a/grub-core/lib/gnulib/fcntl.c b/grub-core/lib/gnulib/fcntl.c
new file mode 100644
index 0000000..f602fad
--- /dev/null
+++ b/grub-core/lib/gnulib/fcntl.c
@@ -0,0 +1,626 @@
+/* Provide file descriptor control.
+
+ Copyright (C) 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Eric Blake <ebb9@byu.net>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <fcntl.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <unistd.h>
+
+#ifdef __KLIBC__
+# define INCL_DOS
+# include <os2.h>
+#endif
+
+#if defined _WIN32 && ! defined __CYGWIN__
+/* Get declarations of the native Windows API functions. */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+/* Get _get_osfhandle. */
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
+
+/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
+# define OPEN_MAX_MAX 0x10000
+
+/* Duplicate OLDFD into the first available slot of at least NEWFD,
+ which must be positive, with FLAGS determining whether the duplicate
+ will be inheritable. */
+static int
+dupfd (int oldfd, int newfd, int flags)
+{
+ /* Mingw has no way to create an arbitrary fd. Iterate until all
+ file descriptors less than newfd are filled up. */
+ HANDLE curr_process = GetCurrentProcess ();
+ HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
+ unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
+ unsigned int fds_to_close_bound = 0;
+ int result;
+ BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
+ int mode;
+
+ if (newfd < 0 || getdtablesize () <= newfd)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ if (old_handle == INVALID_HANDLE_VALUE
+ || (mode = setmode (oldfd, O_BINARY)) == -1)
+ {
+ /* oldfd is not open, or is an unassigned standard file
+ descriptor. */
+ errno = EBADF;
+ return -1;
+ }
+ setmode (oldfd, mode);
+ flags |= mode;
+
+ for (;;)
+ {
+ HANDLE new_handle;
+ int duplicated_fd;
+ unsigned int index;
+
+ if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
+ old_handle, /* SourceHandle */
+ curr_process, /* TargetProcessHandle */
+ (PHANDLE) &new_handle, /* TargetHandle */
+ (DWORD) 0, /* DesiredAccess */
+ inherit, /* InheritHandle */
+ DUPLICATE_SAME_ACCESS)) /* Options */
+ {
+ switch (GetLastError ())
+ {
+ case ERROR_TOO_MANY_OPEN_FILES:
+ errno = EMFILE;
+ break;
+ case ERROR_INVALID_HANDLE:
+ case ERROR_INVALID_TARGET_HANDLE:
+ case ERROR_DIRECT_ACCESS_HANDLE:
+ errno = EBADF;
+ break;
+ case ERROR_INVALID_PARAMETER:
+ case ERROR_INVALID_FUNCTION:
+ case ERROR_INVALID_ACCESS:
+ errno = EINVAL;
+ break;
+ default:
+ errno = EACCES;
+ break;
+ }
+ result = -1;
+ break;
+ }
+ duplicated_fd = _open_osfhandle ((intptr_t) new_handle, flags);
+ if (duplicated_fd < 0)
+ {
+ CloseHandle (new_handle);
+ result = -1;
+ break;
+ }
+ if (newfd <= duplicated_fd)
+ {
+ result = duplicated_fd;
+ break;
+ }
+
+ /* Set the bit duplicated_fd in fds_to_close[]. */
+ index = (unsigned int) duplicated_fd / CHAR_BIT;
+ if (fds_to_close_bound <= index)
+ {
+ if (sizeof fds_to_close <= index)
+ /* Need to increase OPEN_MAX_MAX. */
+ abort ();
+ memset (fds_to_close + fds_to_close_bound, '\0',
+ index + 1 - fds_to_close_bound);
+ fds_to_close_bound = index + 1;
+ }
+ fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
+ }
+
+ /* Close the previous fds that turned out to be too small. */
+ {
+ int saved_errno = errno;
+ unsigned int duplicated_fd;
+
+ for (duplicated_fd = 0;
+ duplicated_fd < fds_to_close_bound * CHAR_BIT;
+ duplicated_fd++)
+ if ((fds_to_close[duplicated_fd / CHAR_BIT]
+ >> (duplicated_fd % CHAR_BIT))
+ & 1)
+ close (duplicated_fd);
+
+ errno = saved_errno;
+ }
+
+# if REPLACE_FCHDIR
+ if (0 <= result)
+ result = _gl_register_dup (oldfd, result);
+# endif
+ return result;
+}
+#endif /* W32 */
+
+/* Forward declarations, because we '#undef fcntl' in the middle of this
+ compilation unit. */
+/* Our implementation of fcntl (fd, F_DUPFD, target). */
+static int rpl_fcntl_DUPFD (int fd, int target);
+/* Our implementation of fcntl (fd, F_DUPFD_CLOEXEC, target). */
+static int rpl_fcntl_DUPFD_CLOEXEC (int fd, int target);
+#ifdef __KLIBC__
+/* Adds support for fcntl on directories. */
+static int klibc_fcntl (int fd, int action, /* arg */...);
+#endif
+
+
+/* Perform the specified ACTION on the file descriptor FD, possibly
+ using the argument ARG further described below. This replacement
+ handles the following actions, and forwards all others on to the
+ native fcntl. An unrecognized ACTION returns -1 with errno set to
+ EINVAL.
+
+ F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
+ If successful, return the duplicate, which will be inheritable;
+ otherwise return -1 and set errno.
+
+ F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
+ target fd. If successful, return the duplicate, which will not be
+ inheritable; otherwise return -1 and set errno.
+
+ F_GETFD - ARG need not be present. If successful, return a
+ non-negative value containing the descriptor flags of FD (only
+ FD_CLOEXEC is portable, but other flags may be present); otherwise
+ return -1 and set errno. */
+
+int
+fcntl (int fd, int action, /* arg */...)
+#undef fcntl
+#ifdef __KLIBC__
+# define fcntl klibc_fcntl
+#endif
+{
+ va_list arg;
+ int result = -1;
+ va_start (arg, action);
+ switch (action)
+ {
+ case F_DUPFD:
+ {
+ int target = va_arg (arg, int);
+ result = rpl_fcntl_DUPFD (fd, target);
+ break;
+ }
+
+ case F_DUPFD_CLOEXEC:
+ {
+ int target = va_arg (arg, int);
+ result = rpl_fcntl_DUPFD_CLOEXEC (fd, target);
+ break;
+ }
+
+#if !HAVE_FCNTL
+ case F_GETFD:
+ {
+# if defined _WIN32 && ! defined __CYGWIN__
+ HANDLE handle = (HANDLE) _get_osfhandle (fd);
+ DWORD flags;
+ if (handle == INVALID_HANDLE_VALUE
+ || GetHandleInformation (handle, &flags) == 0)
+ errno = EBADF;
+ else
+ result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
+# else /* !W32 */
+ /* Use dup2 to reject invalid file descriptors. No way to
+ access this information, so punt. */
+ if (0 <= dup2 (fd, fd))
+ result = 0;
+# endif /* !W32 */
+ break;
+ } /* F_GETFD */
+#endif /* !HAVE_FCNTL */
+
+ /* Implementing F_SETFD on mingw is not trivial - there is no
+ API for changing the O_NOINHERIT bit on an fd, and merely
+ changing the HANDLE_FLAG_INHERIT bit on the underlying handle
+ can lead to odd state. It may be possible by duplicating the
+ handle, using _open_osfhandle with the right flags, then
+ using dup2 to move the duplicate onto the original, but that
+ is not supported for now. */
+
+ default:
+ {
+#if HAVE_FCNTL
+ switch (action)
+ {
+ #ifdef F_BARRIERFSYNC /* macOS */
+ case F_BARRIERFSYNC:
+ #endif
+ #ifdef F_CHKCLEAN /* macOS */
+ case F_CHKCLEAN:
+ #endif
+ #ifdef F_CLOSEM /* NetBSD, HP-UX */
+ case F_CLOSEM:
+ #endif
+ #ifdef F_FLUSH_DATA /* macOS */
+ case F_FLUSH_DATA:
+ #endif
+ #ifdef F_FREEZE_FS /* macOS */
+ case F_FREEZE_FS:
+ #endif
+ #ifdef F_FULLFSYNC /* macOS */
+ case F_FULLFSYNC:
+ #endif
+ #ifdef F_GETCONFINED /* macOS */
+ case F_GETCONFINED:
+ #endif
+ #ifdef F_GETDEFAULTPROTLEVEL /* macOS */
+ case F_GETDEFAULTPROTLEVEL:
+ #endif
+ #ifdef F_GETFD /* POSIX */
+ case F_GETFD:
+ #endif
+ #ifdef F_GETFL /* POSIX */
+ case F_GETFL:
+ #endif
+ #ifdef F_GETLEASE /* Linux */
+ case F_GETLEASE:
+ #endif
+ #ifdef F_GETNOSIGPIPE /* macOS */
+ case F_GETNOSIGPIPE:
+ #endif
+ #ifdef F_GETOWN /* POSIX */
+ case F_GETOWN:
+ #endif
+ #ifdef F_GETPIPE_SZ /* Linux */
+ case F_GETPIPE_SZ:
+ #endif
+ #ifdef F_GETPROTECTIONCLASS /* macOS */
+ case F_GETPROTECTIONCLASS:
+ #endif
+ #ifdef F_GETPROTECTIONLEVEL /* macOS */
+ case F_GETPROTECTIONLEVEL:
+ #endif
+ #ifdef F_GET_SEALS /* Linux */
+ case F_GET_SEALS:
+ #endif
+ #ifdef F_GETSIG /* Linux */
+ case F_GETSIG:
+ #endif
+ #ifdef F_MAXFD /* NetBSD */
+ case F_MAXFD:
+ #endif
+ #ifdef F_RECYCLE /* macOS */
+ case F_RECYCLE:
+ #endif
+ #ifdef F_SETFIFOENH /* HP-UX */
+ case F_SETFIFOENH:
+ #endif
+ #ifdef F_THAW_FS /* macOS */
+ case F_THAW_FS:
+ #endif
+ /* These actions take no argument. */
+ result = fcntl (fd, action);
+ break;
+
+ #ifdef F_ADD_SEALS /* Linux */
+ case F_ADD_SEALS:
+ #endif
+ #ifdef F_BADFD /* Solaris */
+ case F_BADFD:
+ #endif
+ #ifdef F_CHECK_OPENEVT /* macOS */
+ case F_CHECK_OPENEVT:
+ #endif
+ #ifdef F_DUP2FD /* FreeBSD, AIX, Solaris */
+ case F_DUP2FD:
+ #endif
+ #ifdef F_DUP2FD_CLOEXEC /* FreeBSD, Solaris */
+ case F_DUP2FD_CLOEXEC:
+ #endif
+ #ifdef F_DUP2FD_CLOFORK /* Solaris */
+ case F_DUP2FD_CLOFORK:
+ #endif
+ #ifdef F_DUPFD /* POSIX */
+ case F_DUPFD:
+ #endif
+ #ifdef F_DUPFD_CLOEXEC /* POSIX */
+ case F_DUPFD_CLOEXEC:
+ #endif
+ #ifdef F_DUPFD_CLOFORK /* Solaris */
+ case F_DUPFD_CLOFORK:
+ #endif
+ #ifdef F_GETXFL /* Solaris */
+ case F_GETXFL:
+ #endif
+ #ifdef F_GLOBAL_NOCACHE /* macOS */
+ case F_GLOBAL_NOCACHE:
+ #endif
+ #ifdef F_MAKECOMPRESSED /* macOS */
+ case F_MAKECOMPRESSED:
+ #endif
+ #ifdef F_MOVEDATAEXTENTS /* macOS */
+ case F_MOVEDATAEXTENTS:
+ #endif
+ #ifdef F_NOCACHE /* macOS */
+ case F_NOCACHE:
+ #endif
+ #ifdef F_NODIRECT /* macOS */
+ case F_NODIRECT:
+ #endif
+ #ifdef F_NOTIFY /* Linux */
+ case F_NOTIFY:
+ #endif
+ #ifdef F_OPLKACK /* IRIX */
+ case F_OPLKACK:
+ #endif
+ #ifdef F_OPLKREG /* IRIX */
+ case F_OPLKREG:
+ #endif
+ #ifdef F_RDAHEAD /* macOS */
+ case F_RDAHEAD:
+ #endif
+ #ifdef F_SETBACKINGSTORE /* macOS */
+ case F_SETBACKINGSTORE:
+ #endif
+ #ifdef F_SETCONFINED /* macOS */
+ case F_SETCONFINED:
+ #endif
+ #ifdef F_SETFD /* POSIX */
+ case F_SETFD:
+ #endif
+ #ifdef F_SETFL /* POSIX */
+ case F_SETFL:
+ #endif
+ #ifdef F_SETLEASE /* Linux */
+ case F_SETLEASE:
+ #endif
+ #ifdef F_SETNOSIGPIPE /* macOS */
+ case F_SETNOSIGPIPE:
+ #endif
+ #ifdef F_SETOWN /* POSIX */
+ case F_SETOWN:
+ #endif
+ #ifdef F_SETPIPE_SZ /* Linux */
+ case F_SETPIPE_SZ:
+ #endif
+ #ifdef F_SETPROTECTIONCLASS /* macOS */
+ case F_SETPROTECTIONCLASS:
+ #endif
+ #ifdef F_SETSIG /* Linux */
+ case F_SETSIG:
+ #endif
+ #ifdef F_SINGLE_WRITER /* macOS */
+ case F_SINGLE_WRITER:
+ #endif
+ /* These actions take an 'int' argument. */
+ {
+ int x = va_arg (arg, int);
+ result = fcntl (fd, action, x);
+ }
+ break;
+
+ default:
+ /* Other actions take a pointer argument. */
+ {
+ void *p = va_arg (arg, void *);
+ result = fcntl (fd, action, p);
+ }
+ break;
+ }
+#else
+ errno = EINVAL;
+#endif
+ break;
+ }
+ }
+ va_end (arg);
+ return result;
+}
+
+static int
+rpl_fcntl_DUPFD (int fd, int target)
+{
+ int result;
+#if !HAVE_FCNTL
+ result = dupfd (fd, target, 0);
+#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
+ /* Detect invalid target; needed for cygwin 1.5.x. */
+ if (target < 0 || getdtablesize () <= target)
+ {
+ result = -1;
+ errno = EINVAL;
+ }
+ else
+ {
+ /* Haiku alpha 2 loses fd flags on original. */
+ int flags = fcntl (fd, F_GETFD);
+ if (flags < 0)
+ result = -1;
+ else
+ {
+ result = fcntl (fd, F_DUPFD, target);
+ if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
+ {
+ int saved_errno = errno;
+ close (result);
+ result = -1;
+ errno = saved_errno;
+ }
+# if REPLACE_FCHDIR
+ if (0 <= result)
+ result = _gl_register_dup (fd, result);
+# endif
+ }
+ }
+#else
+ result = fcntl (fd, F_DUPFD, target);
+#endif
+ return result;
+}
+
+static int
+rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
+{
+ int result;
+#if !HAVE_FCNTL
+ result = dupfd (fd, target, O_CLOEXEC);
+#else /* HAVE_FCNTL */
+# if defined __HAIKU__
+ /* On Haiku, the system fcntl (fd, F_DUPFD_CLOEXEC, target) sets
+ the FD_CLOEXEC flag on fd, not on target. Therefore avoid the
+ system fcntl in this case. */
+# define have_dupfd_cloexec -1
+# else
+ /* Try the system call first, if the headers claim it exists
+ (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
+ may be running with a glibc that has the macro but with an
+ older kernel that does not support it. Cache the
+ information on whether the system call really works, but
+ avoid caching failure if the corresponding F_DUPFD fails
+ for any reason. 0 = unknown, 1 = yes, -1 = no. */
+ static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
+ if (0 <= have_dupfd_cloexec)
+ {
+ result = fcntl (fd, F_DUPFD_CLOEXEC, target);
+ if (0 <= result || errno != EINVAL)
+ {
+ have_dupfd_cloexec = 1;
+# if REPLACE_FCHDIR
+ if (0 <= result)
+ result = _gl_register_dup (fd, result);
+# endif
+ }
+ else
+ {
+ result = rpl_fcntl_DUPFD (fd, target);
+ if (result >= 0)
+ have_dupfd_cloexec = -1;
+ }
+ }
+ else
+# endif
+ result = rpl_fcntl_DUPFD (fd, target);
+ if (0 <= result && have_dupfd_cloexec == -1)
+ {
+ int flags = fcntl (result, F_GETFD);
+ if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
+ {
+ int saved_errno = errno;
+ close (result);
+ errno = saved_errno;
+ result = -1;
+ }
+ }
+#endif /* HAVE_FCNTL */
+ return result;
+}
+
+#undef fcntl
+
+#ifdef __KLIBC__
+
+static int
+klibc_fcntl (int fd, int action, /* arg */...);
+{
+ va_list arg_ptr;
+ int arg;
+ struct stat sbuf;
+ int result;
+
+ va_start (arg_ptr, action);
+ arg = va_arg (arg_ptr, int);
+ result = fcntl (fd, action, arg);
+ /* EPERM for F_DUPFD, ENOTSUP for others */
+ if (result == -1 && (errno == EPERM || errno == ENOTSUP)
+ && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
+ {
+ ULONG ulMode;
+
+ switch (action)
+ {
+ case F_DUPFD:
+ /* Find available fd */
+ while (fcntl (arg, F_GETFL) != -1 || errno != EBADF)
+ arg++;
+
+ result = dup2 (fd, arg);
+ break;
+
+ /* Using underlying APIs is right ? */
+ case F_GETFD:
+ if (DosQueryFHState (fd, &ulMode))
+ break;
+
+ result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0;
+ break;
+
+ case F_SETFD:
+ if (arg & ~FD_CLOEXEC)
+ break;
+
+ if (DosQueryFHState (fd, &ulMode))
+ break;
+
+ if (arg & FD_CLOEXEC)
+ ulMode |= OPEN_FLAGS_NOINHERIT;
+ else
+ ulMode &= ~OPEN_FLAGS_NOINHERIT;
+
+ /* Filter supported flags. */
+ ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR
+ | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT);
+
+ if (DosSetFHState (fd, ulMode))
+ break;
+
+ result = 0;
+ break;
+
+ case F_GETFL:
+ result = 0;
+ break;
+
+ case F_SETFL:
+ if (arg != 0)
+ break;
+
+ result = 0;
+ break;
+
+ default:
+ errno = EINVAL;
+ break;
+ }
+ }
+
+ va_end (arg_ptr);
+
+ return result;
+}
+
+#endif
diff --git a/grub-core/lib/gnulib/fcntl.in.h b/grub-core/lib/gnulib/fcntl.in.h
new file mode 100644
index 0000000..eb70dc6
--- /dev/null
+++ b/grub-core/lib/gnulib/fcntl.in.h
@@ -0,0 +1,366 @@
+/* Like <fcntl.h>, but with non-working flags defined to 0.
+
+ Copyright (C) 2006-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* written by Paul Eggert */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_system_fcntl_h
+/* Special invocation convention. */
+
+/* Needed before <sys/stat.h>.
+ May also define off_t to a 64-bit type on native Windows. */
+#include <sys/types.h>
+/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
+ <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
+ But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
+ extern "C" { ... } block, which leads to errors in C++ mode with the
+ overridden <sys/stat.h> from gnulib. These errors are known to be gone
+ with g++ version >= 4.3. */
+#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
+# include <sys/stat.h>
+#endif
+#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_FCNTL_H
+
+/* Needed before <sys/stat.h>.
+ May also define off_t to a 64-bit type on native Windows. */
+#include <sys/types.h>
+/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
+ <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
+ But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
+ extern "C" { ... } block, which leads to errors in C++ mode with the
+ overridden <sys/stat.h> from gnulib. These errors are known to be gone
+ with g++ version >= 4.3. */
+#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
+# include <sys/stat.h>
+#endif
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
+
+#ifndef _@GUARD_PREFIX@_FCNTL_H
+#define _@GUARD_PREFIX@_FCNTL_H
+
+#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
+# include <unistd.h>
+#endif
+
+/* Native Windows platforms declare open(), creat() in <io.h>. */
+#if (@GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
+ && (defined _WIN32 && ! defined __CYGWIN__)
+# include <io.h>
+#endif
+
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+
+/* Declare overridden functions. */
+
+#if @GNULIB_FCNTL@
+# if @REPLACE_FCNTL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fcntl
+# define fcntl rpl_fcntl
+# endif
+_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
+_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
+# else
+# if !@HAVE_FCNTL@
+_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
+# endif
+_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
+# endif
+_GL_CXXALIASWARN (fcntl);
+#elif defined GNULIB_POSIXCHECK
+# undef fcntl
+# if HAVE_RAW_DECL_FCNTL
+_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
+ "use gnulib module fcntl for portability");
+# endif
+#endif
+
+#if @GNULIB_OPEN@
+# if @REPLACE_OPEN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef open
+# define open rpl_open
+# endif
+_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
+# else
+_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
+# endif
+/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
+ default argument. _GL_CXXALIASWARN does not work in this case. */
+# if !defined __hpux
+_GL_CXXALIASWARN (open);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef open
+/* Assume open is always declared. */
+_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
+ "use gnulib module open for portability");
+#endif
+
+#if @GNULIB_OPENAT@
+# if @REPLACE_OPENAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef openat
+# define openat rpl_openat
+# endif
+_GL_FUNCDECL_RPL (openat, int,
+ (int fd, char const *file, int flags, /* mode_t mode */ ...)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (openat, int,
+ (int fd, char const *file, int flags, /* mode_t mode */ ...));
+# else
+# if !@HAVE_OPENAT@
+_GL_FUNCDECL_SYS (openat, int,
+ (int fd, char const *file, int flags, /* mode_t mode */ ...)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (openat, int,
+ (int fd, char const *file, int flags, /* mode_t mode */ ...));
+# endif
+_GL_CXXALIASWARN (openat);
+#elif defined GNULIB_POSIXCHECK
+# undef openat
+# if HAVE_RAW_DECL_OPENAT
+_GL_WARN_ON_USE (openat, "openat is not portable - "
+ "use gnulib module openat for portability");
+# endif
+#endif
+
+
+/* Fix up the FD_* macros, only known to be missing on mingw. */
+
+#ifndef FD_CLOEXEC
+# define FD_CLOEXEC 1
+#endif
+
+/* Fix up the supported F_* macros. Intentionally leave other F_*
+ macros undefined. Only known to be missing on mingw. */
+
+#ifndef F_DUPFD_CLOEXEC
+# define F_DUPFD_CLOEXEC 0x40000000
+/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
+# define GNULIB_defined_F_DUPFD_CLOEXEC 1
+#else
+# define GNULIB_defined_F_DUPFD_CLOEXEC 0
+#endif
+
+#ifndef F_DUPFD
+# define F_DUPFD 1
+#endif
+
+#ifndef F_GETFD
+# define F_GETFD 2
+#endif
+
+/* Fix up the O_* macros. */
+
+/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
+ to values outside 'int' range, so omit these misdefinitions.
+ But avoid namespace pollution on non-AIX systems. */
+#ifdef _AIX
+# include <limits.h>
+# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
+# undef O_CLOEXEC
+# endif
+# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
+# undef O_NOFOLLOW
+# endif
+# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
+# undef O_TTY_INIT
+# endif
+#endif
+
+#if !defined O_DIRECT && defined O_DIRECTIO
+/* Tru64 spells it 'O_DIRECTIO'. */
+# define O_DIRECT O_DIRECTIO
+#endif
+
+#if !defined O_CLOEXEC && defined O_NOINHERIT
+/* Mingw spells it 'O_NOINHERIT'. */
+# define O_CLOEXEC O_NOINHERIT
+#endif
+
+#ifndef O_CLOEXEC
+# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */
+# define GNULIB_defined_O_CLOEXEC 1
+#else
+# define GNULIB_defined_O_CLOEXEC 0
+#endif
+
+#ifndef O_DIRECT
+# define O_DIRECT 0
+#endif
+
+#ifndef O_DIRECTORY
+# define O_DIRECTORY 0
+#endif
+
+#ifndef O_DSYNC
+# define O_DSYNC 0
+#endif
+
+#ifndef O_EXEC
+# define O_EXEC O_RDONLY /* This is often close enough in older systems. */
+#endif
+
+#ifndef O_IGNORE_CTTY
+# define O_IGNORE_CTTY 0
+#endif
+
+#ifndef O_NDELAY
+# define O_NDELAY 0
+#endif
+
+#ifndef O_NOATIME
+# define O_NOATIME 0
+#endif
+
+#ifndef O_NONBLOCK
+# define O_NONBLOCK O_NDELAY
+#endif
+
+/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
+ value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
+ or to 0 as fallback. */
+#if @GNULIB_NONBLOCKING@
+# if O_NONBLOCK
+# define GNULIB_defined_O_NONBLOCK 0
+# else
+# define GNULIB_defined_O_NONBLOCK 1
+# undef O_NONBLOCK
+# define O_NONBLOCK 0x40000000
+# endif
+#endif
+
+#ifndef O_NOCTTY
+# define O_NOCTTY 0
+#endif
+
+#ifndef O_NOFOLLOW
+# define O_NOFOLLOW 0
+#endif
+
+#ifndef O_NOLINK
+# define O_NOLINK 0
+#endif
+
+#ifndef O_NOLINKS
+# define O_NOLINKS 0
+#endif
+
+#ifndef O_NOTRANS
+# define O_NOTRANS 0
+#endif
+
+#ifndef O_RSYNC
+# define O_RSYNC 0
+#endif
+
+#ifndef O_SEARCH
+# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
+#endif
+
+#ifndef O_SYNC
+# define O_SYNC 0
+#endif
+
+#ifndef O_TTY_INIT
+# define O_TTY_INIT 0
+#endif
+
+#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
+# undef O_ACCMODE
+# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
+#endif
+
+/* For systems that distinguish between text and binary I/O.
+ O_BINARY is usually declared in fcntl.h */
+#if !defined O_BINARY && defined _O_BINARY
+ /* For MSC-compatible compilers. */
+# define O_BINARY _O_BINARY
+# define O_TEXT _O_TEXT
+#endif
+
+#if defined __BEOS__ || defined __HAIKU__
+ /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
+# undef O_BINARY
+# undef O_TEXT
+#endif
+
+#ifndef O_BINARY
+# define O_BINARY 0
+# define O_TEXT 0
+#endif
+
+/* Fix up the AT_* macros. */
+
+/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
+ value exceeds INT_MAX, so its use as an int doesn't conform to the
+ C standard, and GCC and Sun C complain in some cases. If the bug
+ is present, undef AT_FDCWD here, so it can be redefined below. */
+#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
+# undef AT_FDCWD
+#endif
+
+/* Use the same bit pattern as Solaris 9, but with the proper
+ signedness. The bit pattern is important, in case this actually is
+ Solaris with the above workaround. */
+#ifndef AT_FDCWD
+# define AT_FDCWD (-3041965)
+#endif
+
+/* Use the same values as Solaris 9. This shouldn't matter, but
+ there's no real reason to differ. */
+#ifndef AT_SYMLINK_NOFOLLOW
+# define AT_SYMLINK_NOFOLLOW 4096
+#endif
+
+#ifndef AT_REMOVEDIR
+# define AT_REMOVEDIR 1
+#endif
+
+/* Solaris 9 lacks these two, so just pick unique values. */
+#ifndef AT_SYMLINK_FOLLOW
+# define AT_SYMLINK_FOLLOW 2
+#endif
+
+#ifndef AT_EACCESS
+# define AT_EACCESS 4
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_FCNTL_H */
+#endif /* _@GUARD_PREFIX@_FCNTL_H */
+#endif
diff --git a/grub-core/lib/gnulib/fd-hook.c b/grub-core/lib/gnulib/fd-hook.c
new file mode 100644
index 0000000..7879119
--- /dev/null
+++ b/grub-core/lib/gnulib/fd-hook.c
@@ -0,0 +1,116 @@
+/* Hook for making file descriptor functions close(), ioctl() extensible.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2009.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "fd-hook.h"
+
+#include <stdlib.h>
+
+/* Currently, this entire code is only needed for the handling of sockets
+ on native Windows platforms. */
+#if WINDOWS_SOCKETS
+
+/* The first and last link in the doubly linked list.
+ Initially the list is empty. */
+static struct fd_hook anchor = { &anchor, &anchor, NULL, NULL };
+
+int
+execute_close_hooks (const struct fd_hook *remaining_list, gl_close_fn primary,
+ int fd)
+{
+ if (remaining_list == &anchor)
+ /* End of list reached. */
+ return primary (fd);
+ else
+ return remaining_list->private_close_fn (remaining_list->private_next,
+ primary, fd);
+}
+
+int
+execute_all_close_hooks (gl_close_fn primary, int fd)
+{
+ return execute_close_hooks (anchor.private_next, primary, fd);
+}
+
+int
+execute_ioctl_hooks (const struct fd_hook *remaining_list, gl_ioctl_fn primary,
+ int fd, int request, void *arg)
+{
+ if (remaining_list == &anchor)
+ /* End of list reached. */
+ return primary (fd, request, arg);
+ else
+ return remaining_list->private_ioctl_fn (remaining_list->private_next,
+ primary, fd, request, arg);
+}
+
+int
+execute_all_ioctl_hooks (gl_ioctl_fn primary,
+ int fd, int request, void *arg)
+{
+ return execute_ioctl_hooks (anchor.private_next, primary, fd, request, arg);
+}
+
+void
+register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook, struct fd_hook *link)
+{
+ if (close_hook == NULL)
+ close_hook = execute_close_hooks;
+ if (ioctl_hook == NULL)
+ ioctl_hook = execute_ioctl_hooks;
+
+ if (link->private_next == NULL && link->private_prev == NULL)
+ {
+ /* Add the link to the doubly linked list. */
+ link->private_next = anchor.private_next;
+ link->private_prev = &anchor;
+ link->private_close_fn = close_hook;
+ link->private_ioctl_fn = ioctl_hook;
+ anchor.private_next->private_prev = link;
+ anchor.private_next = link;
+ }
+ else
+ {
+ /* The link is already in use. */
+ if (link->private_close_fn != close_hook
+ || link->private_ioctl_fn != ioctl_hook)
+ abort ();
+ }
+}
+
+void
+unregister_fd_hook (struct fd_hook *link)
+{
+ struct fd_hook *next = link->private_next;
+ struct fd_hook *prev = link->private_prev;
+
+ if (next != NULL && prev != NULL)
+ {
+ /* The link is in use. Remove it from the doubly linked list. */
+ prev->private_next = next;
+ next->private_prev = prev;
+ /* Clear the link, to mark it unused. */
+ link->private_next = NULL;
+ link->private_prev = NULL;
+ link->private_close_fn = NULL;
+ link->private_ioctl_fn = NULL;
+ }
+}
+
+#endif
diff --git a/grub-core/lib/gnulib/fd-hook.h b/grub-core/lib/gnulib/fd-hook.h
new file mode 100644
index 0000000..bf07f00
--- /dev/null
+++ b/grub-core/lib/gnulib/fd-hook.h
@@ -0,0 +1,119 @@
+/* Hook for making file descriptor functions close(), ioctl() extensible.
+ Copyright (C) 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+
+#ifndef FD_HOOK_H
+#define FD_HOOK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Currently, this entire code is only needed for the handling of sockets
+ on native Windows platforms. */
+#if WINDOWS_SOCKETS
+
+
+/* Type of function that closes FD. */
+typedef int (*gl_close_fn) (int fd);
+
+/* Type of function that applies a control request to FD. */
+typedef int (*gl_ioctl_fn) (int fd, int request, void *arg);
+
+/* An element of the list of file descriptor hooks.
+ In CLOS (Common Lisp Object System) speak, it consists of an "around"
+ method for the close() function and an "around" method for the ioctl()
+ function.
+ The fields of this structure are considered private. */
+struct fd_hook
+{
+ /* Doubly linked list. */
+ struct fd_hook *private_next;
+ struct fd_hook *private_prev;
+ /* Function that treats the types of FD that it knows about and calls
+ execute_close_hooks (REMAINING_LIST, PRIMARY, FD) as a fallback. */
+ int (*private_close_fn) (const struct fd_hook *remaining_list,
+ gl_close_fn primary,
+ int fd);
+ /* Function that treats the types of FD that it knows about and calls
+ execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG) as a
+ fallback. */
+ int (*private_ioctl_fn) (const struct fd_hook *remaining_list,
+ gl_ioctl_fn primary,
+ int fd, int request, void *arg);
+};
+
+/* This type of function closes FD, applying special knowledge for the FD
+ types it knows about, and calls
+ execute_close_hooks (REMAINING_LIST, PRIMARY, FD)
+ for the other FD types.
+ In CLOS speak, REMAINING_LIST is the remaining list of "around" methods,
+ and PRIMARY is the "primary" method for close(). */
+typedef int (*close_hook_fn) (const struct fd_hook *remaining_list,
+ gl_close_fn primary,
+ int fd);
+
+/* Execute the close hooks in REMAINING_LIST, with PRIMARY as "primary" method.
+ Return 0 or -1, like close() would do. */
+extern int execute_close_hooks (const struct fd_hook *remaining_list,
+ gl_close_fn primary,
+ int fd);
+
+/* Execute all close hooks, with PRIMARY as "primary" method.
+ Return 0 or -1, like close() would do. */
+extern int execute_all_close_hooks (gl_close_fn primary, int fd);
+
+/* This type of function applies a control request to FD, applying special
+ knowledge for the FD types it knows about, and calls
+ execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG)
+ for the other FD types.
+ In CLOS speak, REMAINING_LIST is the remaining list of "around" methods,
+ and PRIMARY is the "primary" method for ioctl(). */
+typedef int (*ioctl_hook_fn) (const struct fd_hook *remaining_list,
+ gl_ioctl_fn primary,
+ int fd, int request, void *arg);
+
+/* Execute the ioctl hooks in REMAINING_LIST, with PRIMARY as "primary" method.
+ Return 0 or -1, like ioctl() would do. */
+extern int execute_ioctl_hooks (const struct fd_hook *remaining_list,
+ gl_ioctl_fn primary,
+ int fd, int request, void *arg);
+
+/* Execute all ioctl hooks, with PRIMARY as "primary" method.
+ Return 0 or -1, like ioctl() would do. */
+extern int execute_all_ioctl_hooks (gl_ioctl_fn primary,
+ int fd, int request, void *arg);
+
+/* Add a function pair to the list of file descriptor hooks.
+ CLOSE_HOOK and IOCTL_HOOK may be NULL, indicating no change.
+ The LINK variable points to a piece of memory which is guaranteed to be
+ accessible until the corresponding call to unregister_fd_hook. */
+extern void register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook,
+ struct fd_hook *link);
+
+/* Removes a hook from the list of file descriptor hooks. */
+extern void unregister_fd_hook (struct fd_hook *link);
+
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FD_HOOK_H */
diff --git a/grub-core/lib/gnulib/fd-safer-flag.c b/grub-core/lib/gnulib/fd-safer-flag.c
new file mode 100644
index 0000000..7c026ef
--- /dev/null
+++ b/grub-core/lib/gnulib/fd-safer-flag.c
@@ -0,0 +1,52 @@
+/* Adjust a file descriptor result so that it avoids clobbering
+ STD{IN,OUT,ERR}_FILENO, with specific flags.
+
+ Copyright (C) 2005-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert and Eric Blake. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistd-safer.h"
+
+#include <errno.h>
+#include <unistd.h>
+
+/* Return FD, unless FD would be a copy of standard input, output, or
+ error; in that case, return a duplicate of FD, closing FD. If FLAG
+ contains O_CLOEXEC, the returned FD will have close-on-exec
+ semantics. On failure to duplicate, close FD, set errno, and
+ return -1. Preserve errno if FD is negative, so that the caller
+ can always inspect errno when the returned value is negative.
+
+ This function is usefully wrapped around functions that return file
+ descriptors, e.g., fd_safer_flag (open ("file", O_RDONLY | flag), flag). */
+
+int
+fd_safer_flag (int fd, int flag)
+{
+ if (STDIN_FILENO <= fd && fd <= STDERR_FILENO)
+ {
+ int f = dup_safer_flag (fd, flag);
+ int e = errno;
+ close (fd);
+ errno = e;
+ fd = f;
+ }
+
+ return fd;
+}
diff --git a/grub-core/lib/gnulib/fd-safer.c b/grub-core/lib/gnulib/fd-safer.c
new file mode 100644
index 0000000..b5113e1
--- /dev/null
+++ b/grub-core/lib/gnulib/fd-safer.c
@@ -0,0 +1,49 @@
+/* Return a safer copy of a file descriptor.
+
+ Copyright (C) 2005-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#include <config.h>
+
+#include "unistd-safer.h"
+
+#include <errno.h>
+#include <unistd.h>
+
+/* Return FD, unless FD would be a copy of standard input, output, or
+ error; in that case, return a duplicate of FD, closing FD. On
+ failure to duplicate, close FD, set errno, and return -1. Preserve
+ errno if FD is negative, so that the caller can always inspect
+ errno when the returned value is negative.
+
+ This function is usefully wrapped around functions that return file
+ descriptors, e.g., fd_safer (open ("file", O_RDONLY)). */
+
+int
+fd_safer (int fd)
+{
+ if (STDIN_FILENO <= fd && fd <= STDERR_FILENO)
+ {
+ int f = dup_safer (fd);
+ int e = errno;
+ close (fd);
+ errno = e;
+ fd = f;
+ }
+
+ return fd;
+}
diff --git a/grub-core/lib/gnulib/filename.h b/grub-core/lib/gnulib/filename.h
new file mode 100644
index 0000000..3ba3105
--- /dev/null
+++ b/grub-core/lib/gnulib/filename.h
@@ -0,0 +1,54 @@
+/* Basic filename support macros.
+ Copyright (C) 2001-2004, 2007-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _FILENAME_H
+#define _FILENAME_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Pathname support.
+ ISSLASH(C) tests whether C is a directory separator character.
+ IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not,
+ it may be concatenated to a directory pathname.
+ IS_PATH_WITH_DIR(P) tests whether P contains a directory specification.
+ */
+#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
+ /* Native Windows, Cygwin, OS/2, DOS */
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+# define HAS_DEVICE(P) \
+ ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
+ && (P)[1] == ':')
+# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
+# define IS_PATH_WITH_DIR(P) \
+ (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
+# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
+#else
+ /* Unix */
+# define ISSLASH(C) ((C) == '/')
+# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
+# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
+# define FILE_SYSTEM_PREFIX_LEN(P) 0
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FILENAME_H */
diff --git a/grub-core/lib/gnulib/filenamecat-lgpl.c b/grub-core/lib/gnulib/filenamecat-lgpl.c
new file mode 100644
index 0000000..98b105a
--- /dev/null
+++ b/grub-core/lib/gnulib/filenamecat-lgpl.c
@@ -0,0 +1,87 @@
+/* Concatenate two arbitrary file names.
+
+ Copyright (C) 1996-2007, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering. */
+
+#include <config.h>
+
+/* Specification. */
+#include "filenamecat.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "dirname.h"
+
+#if ! HAVE_MEMPCPY && ! defined mempcpy
+# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
+#endif
+
+/* Concatenate two file name components, DIR and BASE, in
+ newly-allocated storage and return the result.
+ The resulting file name F is such that the commands "ls F" and "(cd
+ DIR; ls ./BASE)" refer to the same file. If necessary, put
+ a separator between DIR and BASE in the result. Typically this
+ separator is "/", but in rare cases it might be ".".
+ In any case, if BASE_IN_RESULT is non-NULL, set
+ *BASE_IN_RESULT to point to the copy of BASE at the end of the
+ returned concatenation.
+
+ Return NULL if malloc fails. */
+
+char *
+mfile_name_concat (char const *dir, char const *base, char **base_in_result)
+{
+ char const *dirbase = last_component (dir);
+ size_t dirbaselen = base_len (dirbase);
+ size_t dirlen = dirbase - dir + dirbaselen;
+ size_t baselen = strlen (base);
+ char sep = '\0';
+ if (dirbaselen)
+ {
+ /* DIR is not a file system root, so separate with / if needed. */
+ if (! ISSLASH (dir[dirlen - 1]) && ! ISSLASH (*base))
+ sep = '/';
+ }
+ else if (ISSLASH (*base))
+ {
+ /* DIR is a file system root and BASE begins with a slash, so
+ separate with ".". For example, if DIR is "/" and BASE is
+ "/foo" then return "/./foo", as "//foo" would be wrong on
+ some POSIX systems. A fancier algorithm could omit "." in
+ some cases but is not worth the trouble. */
+ sep = '.';
+ }
+
+ char *p_concat = malloc (dirlen + (sep != '\0') + baselen + 1);
+ char *p;
+
+ if (p_concat == NULL)
+ return NULL;
+
+ p = mempcpy (p_concat, dir, dirlen);
+ *p = sep;
+ p += sep != '\0';
+
+ if (base_in_result)
+ *base_in_result = p;
+
+ p = mempcpy (p, base, baselen);
+ *p = '\0';
+
+ return p_concat;
+}
diff --git a/grub-core/lib/gnulib/filenamecat.h b/grub-core/lib/gnulib/filenamecat.h
new file mode 100644
index 0000000..67b46b0
--- /dev/null
+++ b/grub-core/lib/gnulib/filenamecat.h
@@ -0,0 +1,27 @@
+/* Concatenate two arbitrary file names.
+
+ Copyright (C) 1996-1997, 2003, 2005, 2007, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering. */
+
+#if GNULIB_FILENAMECAT
+char *file_name_concat (char const *dir, char const *base,
+ char **base_in_result);
+#endif
+
+char *mfile_name_concat (char const *dir, char const *base,
+ char **base_in_result);
diff --git a/grub-core/lib/gnulib/flexmember.h b/grub-core/lib/gnulib/flexmember.h
new file mode 100644
index 0000000..0d65f6d
--- /dev/null
+++ b/grub-core/lib/gnulib/flexmember.h
@@ -0,0 +1,45 @@
+/* Sizes of structs with flexible array members.
+
+ Copyright 2016-2019 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>.
+
+ Written by Paul Eggert. */
+
+#include <stddef.h>
+
+/* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below.
+ On older platforms without _Alignof, use a pessimistic bound that is
+ safe in practice even if FLEXIBLE_ARRAY_MEMBER is 1.
+ On newer platforms, use _Alignof to get a tighter bound. */
+
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
+# define FLEXALIGNOF(type) (sizeof (type) & ~ (sizeof (type) - 1))
+#else
+# define FLEXALIGNOF(type) _Alignof (type)
+#endif
+
+/* Upper bound on the size of a struct of type TYPE with a flexible
+ array member named MEMBER that is followed by N bytes of other data.
+ This is not simply sizeof (TYPE) + N, since it may require
+ alignment on unusually picky C11 platforms, and
+ FLEXIBLE_ARRAY_MEMBER may be 1 on pre-C11 platforms.
+ Yield a value less than N if and only if arithmetic overflow occurs. */
+
+#define FLEXSIZEOF(type, member, n) \
+ ((offsetof (type, member) + FLEXALIGNOF (type) - 1 + (n)) \
+ & ~ (FLEXALIGNOF (type) - 1))
diff --git a/grub-core/lib/gnulib/float+.h b/grub-core/lib/gnulib/float+.h
new file mode 100644
index 0000000..5af861f
--- /dev/null
+++ b/grub-core/lib/gnulib/float+.h
@@ -0,0 +1,147 @@
+/* Supplemental information about the floating-point formats.
+ Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2007.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _FLOATPLUS_H
+#define _FLOATPLUS_H
+
+#include <float.h>
+#include <limits.h>
+
+/* Number of bits in the mantissa of a floating-point number, including the
+ "hidden bit". */
+#if FLT_RADIX == 2
+# define FLT_MANT_BIT FLT_MANT_DIG
+# define DBL_MANT_BIT DBL_MANT_DIG
+# define LDBL_MANT_BIT LDBL_MANT_DIG
+#elif FLT_RADIX == 4
+# define FLT_MANT_BIT (FLT_MANT_DIG * 2)
+# define DBL_MANT_BIT (DBL_MANT_DIG * 2)
+# define LDBL_MANT_BIT (LDBL_MANT_DIG * 2)
+#elif FLT_RADIX == 16
+# define FLT_MANT_BIT (FLT_MANT_DIG * 4)
+# define DBL_MANT_BIT (DBL_MANT_DIG * 4)
+# define LDBL_MANT_BIT (LDBL_MANT_DIG * 4)
+#endif
+
+/* Bit mask that can be used to mask the exponent, as an unsigned number. */
+#define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7)
+#define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
+#define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7)
+
+/* Number of bits used for the exponent of a floating-point number, including
+ the exponent's sign. */
+#define FLT_EXP_BIT \
+ (FLT_EXP_MASK < 0x100 ? 8 : \
+ FLT_EXP_MASK < 0x200 ? 9 : \
+ FLT_EXP_MASK < 0x400 ? 10 : \
+ FLT_EXP_MASK < 0x800 ? 11 : \
+ FLT_EXP_MASK < 0x1000 ? 12 : \
+ FLT_EXP_MASK < 0x2000 ? 13 : \
+ FLT_EXP_MASK < 0x4000 ? 14 : \
+ FLT_EXP_MASK < 0x8000 ? 15 : \
+ FLT_EXP_MASK < 0x10000 ? 16 : \
+ FLT_EXP_MASK < 0x20000 ? 17 : \
+ FLT_EXP_MASK < 0x40000 ? 18 : \
+ FLT_EXP_MASK < 0x80000 ? 19 : \
+ FLT_EXP_MASK < 0x100000 ? 20 : \
+ FLT_EXP_MASK < 0x200000 ? 21 : \
+ FLT_EXP_MASK < 0x400000 ? 22 : \
+ FLT_EXP_MASK < 0x800000 ? 23 : \
+ FLT_EXP_MASK < 0x1000000 ? 24 : \
+ FLT_EXP_MASK < 0x2000000 ? 25 : \
+ FLT_EXP_MASK < 0x4000000 ? 26 : \
+ FLT_EXP_MASK < 0x8000000 ? 27 : \
+ FLT_EXP_MASK < 0x10000000 ? 28 : \
+ FLT_EXP_MASK < 0x20000000 ? 29 : \
+ FLT_EXP_MASK < 0x40000000 ? 30 : \
+ FLT_EXP_MASK <= 0x7fffffff ? 31 : \
+ 32)
+#define DBL_EXP_BIT \
+ (DBL_EXP_MASK < 0x100 ? 8 : \
+ DBL_EXP_MASK < 0x200 ? 9 : \
+ DBL_EXP_MASK < 0x400 ? 10 : \
+ DBL_EXP_MASK < 0x800 ? 11 : \
+ DBL_EXP_MASK < 0x1000 ? 12 : \
+ DBL_EXP_MASK < 0x2000 ? 13 : \
+ DBL_EXP_MASK < 0x4000 ? 14 : \
+ DBL_EXP_MASK < 0x8000 ? 15 : \
+ DBL_EXP_MASK < 0x10000 ? 16 : \
+ DBL_EXP_MASK < 0x20000 ? 17 : \
+ DBL_EXP_MASK < 0x40000 ? 18 : \
+ DBL_EXP_MASK < 0x80000 ? 19 : \
+ DBL_EXP_MASK < 0x100000 ? 20 : \
+ DBL_EXP_MASK < 0x200000 ? 21 : \
+ DBL_EXP_MASK < 0x400000 ? 22 : \
+ DBL_EXP_MASK < 0x800000 ? 23 : \
+ DBL_EXP_MASK < 0x1000000 ? 24 : \
+ DBL_EXP_MASK < 0x2000000 ? 25 : \
+ DBL_EXP_MASK < 0x4000000 ? 26 : \
+ DBL_EXP_MASK < 0x8000000 ? 27 : \
+ DBL_EXP_MASK < 0x10000000 ? 28 : \
+ DBL_EXP_MASK < 0x20000000 ? 29 : \
+ DBL_EXP_MASK < 0x40000000 ? 30 : \
+ DBL_EXP_MASK <= 0x7fffffff ? 31 : \
+ 32)
+#define LDBL_EXP_BIT \
+ (LDBL_EXP_MASK < 0x100 ? 8 : \
+ LDBL_EXP_MASK < 0x200 ? 9 : \
+ LDBL_EXP_MASK < 0x400 ? 10 : \
+ LDBL_EXP_MASK < 0x800 ? 11 : \
+ LDBL_EXP_MASK < 0x1000 ? 12 : \
+ LDBL_EXP_MASK < 0x2000 ? 13 : \
+ LDBL_EXP_MASK < 0x4000 ? 14 : \
+ LDBL_EXP_MASK < 0x8000 ? 15 : \
+ LDBL_EXP_MASK < 0x10000 ? 16 : \
+ LDBL_EXP_MASK < 0x20000 ? 17 : \
+ LDBL_EXP_MASK < 0x40000 ? 18 : \
+ LDBL_EXP_MASK < 0x80000 ? 19 : \
+ LDBL_EXP_MASK < 0x100000 ? 20 : \
+ LDBL_EXP_MASK < 0x200000 ? 21 : \
+ LDBL_EXP_MASK < 0x400000 ? 22 : \
+ LDBL_EXP_MASK < 0x800000 ? 23 : \
+ LDBL_EXP_MASK < 0x1000000 ? 24 : \
+ LDBL_EXP_MASK < 0x2000000 ? 25 : \
+ LDBL_EXP_MASK < 0x4000000 ? 26 : \
+ LDBL_EXP_MASK < 0x8000000 ? 27 : \
+ LDBL_EXP_MASK < 0x10000000 ? 28 : \
+ LDBL_EXP_MASK < 0x20000000 ? 29 : \
+ LDBL_EXP_MASK < 0x40000000 ? 30 : \
+ LDBL_EXP_MASK <= 0x7fffffff ? 31 : \
+ 32)
+
+/* Number of bits used for a floating-point number: the mantissa (not
+ counting the "hidden bit", since it may or may not be explicit), the
+ exponent, and the sign. */
+#define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1)
+#define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1)
+#define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1)
+
+/* Number of bytes used for a floating-point number.
+ This can be smaller than the 'sizeof'. For example, on i386 systems,
+ 'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence
+ LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but
+ sizeof (long double) = 12 or = 16. */
+#define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
+#define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
+#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
+
+/* Verify that SIZEOF_FLT <= sizeof (float) etc. */
+typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1];
+typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1];
+typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1];
+
+#endif /* _FLOATPLUS_H */
diff --git a/grub-core/lib/gnulib/float.c b/grub-core/lib/gnulib/float.c
new file mode 100644
index 0000000..8872deb
--- /dev/null
+++ b/grub-core/lib/gnulib/float.c
@@ -0,0 +1,33 @@
+/* Auxiliary definitions for <float.h>.
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <float.h>
+
+#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
+const union gl_long_double_union gl_LDBL_MAX =
+ { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } };
+#elif defined __i386__
+const union gl_long_double_union gl_LDBL_MAX =
+ { { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } };
+#else
+/* This declaration is solely to ensure that after preprocessing
+ this file is never empty. */
+typedef int dummy;
+#endif
diff --git a/grub-core/lib/gnulib/float.in.h b/grub-core/lib/gnulib/float.in.h
new file mode 100644
index 0000000..ba094a8
--- /dev/null
+++ b/grub-core/lib/gnulib/float.in.h
@@ -0,0 +1,188 @@
+/* A correct <float.h>.
+
+ Copyright (C) 2007-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_FLOAT_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_FLOAT_H@
+
+#ifndef _@GUARD_PREFIX@_FLOAT_H
+#define _@GUARD_PREFIX@_FLOAT_H
+
+/* 'long double' properties. */
+
+#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
+/* Number of mantissa units, in base FLT_RADIX. */
+# undef LDBL_MANT_DIG
+# define LDBL_MANT_DIG 64
+/* Number of decimal digits that is sufficient for representing a number. */
+# undef LDBL_DIG
+# define LDBL_DIG 18
+/* x-1 where x is the smallest representable number > 1. */
+# undef LDBL_EPSILON
+# define LDBL_EPSILON 1.0842021724855044340E-19L
+/* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */
+# undef LDBL_MIN_EXP
+# define LDBL_MIN_EXP (-16381)
+/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */
+# undef LDBL_MAX_EXP
+# define LDBL_MAX_EXP 16384
+/* Minimum positive normalized number. */
+# undef LDBL_MIN
+# define LDBL_MIN 3.3621031431120935063E-4932L
+/* Maximum representable finite number. */
+# undef LDBL_MAX
+# define LDBL_MAX 1.1897314953572317650E+4932L
+/* Minimum e such that 10^e is in the range of normalized numbers. */
+# undef LDBL_MIN_10_EXP
+# define LDBL_MIN_10_EXP (-4931)
+/* Maximum e such that 10^e is in the range of representable finite numbers. */
+# undef LDBL_MAX_10_EXP
+# define LDBL_MAX_10_EXP 4932
+#endif
+
+/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
+ precision in the compiler but 64 bits of precision at runtime. See
+ <https://lists.gnu.org/r/bug-gnulib/2008-07/msg00063.html>. */
+#if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
+/* Number of mantissa units, in base FLT_RADIX. */
+# undef LDBL_MANT_DIG
+# define LDBL_MANT_DIG 64
+/* Number of decimal digits that is sufficient for representing a number. */
+# undef LDBL_DIG
+# define LDBL_DIG 18
+/* x-1 where x is the smallest representable number > 1. */
+# undef LDBL_EPSILON
+# define LDBL_EPSILON 1.084202172485504434007452800869941711426e-19L /* 2^-63 */
+/* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */
+# undef LDBL_MIN_EXP
+# define LDBL_MIN_EXP (-16381)
+/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */
+# undef LDBL_MAX_EXP
+# define LDBL_MAX_EXP 16384
+/* Minimum positive normalized number. */
+# undef LDBL_MIN
+# define LDBL_MIN 3.362103143112093506262677817321752E-4932L /* = 0x1p-16382L */
+/* Maximum representable finite number. */
+# undef LDBL_MAX
+/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
+ But the largest literal that GCC allows us to write is
+ 0x0.fffffffffffff8p16384L = { 0xFFFFF800, 0xFFFFFFFF, 32766 }.
+ So, define it like this through a reference to an external variable
+
+ const unsigned int LDBL_MAX[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 32766 };
+ extern const long double LDBL_MAX;
+
+ Unfortunately, this is not a constant expression. */
+union gl_long_double_union
+ {
+ struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd;
+ long double ld;
+ };
+extern const union gl_long_double_union gl_LDBL_MAX;
+# define LDBL_MAX (gl_LDBL_MAX.ld)
+/* Minimum e such that 10^e is in the range of normalized numbers. */
+# undef LDBL_MIN_10_EXP
+# define LDBL_MIN_10_EXP (-4931)
+/* Maximum e such that 10^e is in the range of representable finite numbers. */
+# undef LDBL_MAX_10_EXP
+# define LDBL_MAX_10_EXP 4932
+#endif
+
+/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are
+ wrong.
+ On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */
+#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__
+# undef LDBL_MIN_EXP
+# define LDBL_MIN_EXP DBL_MIN_EXP
+# undef LDBL_MIN_10_EXP
+# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
+# undef LDBL_MIN
+# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
+#endif
+#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
+# undef LDBL_MAX
+/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }.
+ It is not easy to define:
+ #define LDBL_MAX 1.79769313486231580793728971405302307166e308L
+ is too small, whereas
+ #define LDBL_MAX 1.79769313486231580793728971405302307167e308L
+ is too large. Apparently a bug in GCC decimal-to-binary conversion.
+ Also, I can't get values larger than
+ #define LDBL63 ((long double) (1ULL << 63))
+ #define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
+ #define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
+ #define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
+ #define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL)
+ which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }.
+ So, define it like this through a reference to an external variable
+
+ const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL };
+ extern const long double LDBL_MAX;
+
+ or through a pointer cast
+
+ #define LDBL_MAX \
+ (*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL })
+
+ Unfortunately, this is not a constant expression, and the latter expression
+ does not work well when GCC is optimizing.. */
+union gl_long_double_union
+ {
+ struct { double hi; double lo; } dd;
+ long double ld;
+ };
+extern const union gl_long_double_union gl_LDBL_MAX;
+# define LDBL_MAX (gl_LDBL_MAX.ld)
+#endif
+
+/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong.
+ On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON
+ are wrong. */
+#if defined __sgi && (LDBL_MANT_DIG >= 106)
+# undef LDBL_MANT_DIG
+# define LDBL_MANT_DIG 106
+# if defined __GNUC__
+# undef LDBL_MIN_EXP
+# define LDBL_MIN_EXP DBL_MIN_EXP
+# undef LDBL_MIN_10_EXP
+# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
+# undef LDBL_MIN
+# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
+# undef LDBL_EPSILON
+# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */
+# endif
+#endif
+
+#if @REPLACE_ITOLD@
+/* Pull in a function that fixes the 'int' to 'long double' conversion
+ of glibc 2.7. */
+extern
+# ifdef __cplusplus
+"C"
+# endif
+void _Qp_itoq (long double *, int);
+static void (*_gl_float_fix_itold) (long double *, int) = _Qp_itoq;
+#endif
+
+#endif /* _@GUARD_PREFIX@_FLOAT_H */
+#endif /* _@GUARD_PREFIX@_FLOAT_H */
diff --git a/grub-core/lib/gnulib/fnmatch.c b/grub-core/lib/gnulib/fnmatch.c
new file mode 100644
index 0000000..dbcd290
--- /dev/null
+++ b/grub-core/lib/gnulib/fnmatch.c
@@ -0,0 +1,356 @@
+/* Copyright (C) 1991-1993, 1996-2007, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+/* Enable GNU extensions in fnmatch.h. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <fnmatch.h>
+
+#include <alloca.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define WIDE_CHAR_SUPPORT \
+ (HAVE_WCTYPE_H && HAVE_BTOWC && HAVE_ISWCTYPE \
+ && HAVE_WMEMCHR && (HAVE_WMEMCPY || HAVE_WMEMPCPY))
+
+/* For platform which support the ISO C amendment 1 functionality we
+ support user defined character classes. */
+#if defined _LIBC || WIDE_CHAR_SUPPORT
+# include <wctype.h>
+# include <wchar.h>
+#endif
+
+/* We need some of the locale data (the collation sequence information)
+ but there is no interface to get this information in general. Therefore
+ we support a correct implementation only in glibc. */
+#ifdef _LIBC
+# include "../locale/localeinfo.h"
+# include "../locale/elem-hash.h"
+# include "../locale/coll-lookup.h"
+# include <shlib-compat.h>
+
+# define CONCAT(a,b) __CONCAT(a,b)
+# define mbsrtowcs __mbsrtowcs
+# define fnmatch __fnmatch
+extern int fnmatch (const char *pattern, const char *string, int flags);
+#endif
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+#include "flexmember.h"
+
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
+/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */
+#define NO_LEADING_PERIOD(flags) \
+ ((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD))
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself, and have not detected a bug
+ in the library. This code is part of the GNU C
+ Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand 'configure --with-gnu-libc' and omit the object files,
+ it is simpler to just do this in the source for each such file. */
+
+#if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU
+
+
+# if ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK))
+# define isblank(c) ((c) == ' ' || (c) == '\t')
+# endif
+
+# define STREQ(s1, s2) (strcmp (s1, s2) == 0)
+
+# if defined _LIBC || WIDE_CHAR_SUPPORT
+/* The GNU C library provides support for user-defined character classes
+ and the functions from ISO C amendment 1. */
+# ifdef CHARCLASS_NAME_MAX
+# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
+# else
+/* This shouldn't happen but some implementation might still have this
+ problem. Use a reasonable default value. */
+# define CHAR_CLASS_MAX_LENGTH 256
+# endif
+
+# ifdef _LIBC
+# define IS_CHAR_CLASS(string) __wctype (string)
+# else
+# define IS_CHAR_CLASS(string) wctype (string)
+# endif
+
+# ifdef _LIBC
+# define ISWCTYPE(WC, WT) __iswctype (WC, WT)
+# else
+# define ISWCTYPE(WC, WT) iswctype (WC, WT)
+# endif
+
+# if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC
+/* In this case we are implementing the multibyte character handling. */
+# define HANDLE_MULTIBYTE 1
+# endif
+
+# else
+# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, 'xdigit'. */
+
+# define IS_CHAR_CLASS(string) \
+ (STREQ (string, "alpha") || STREQ (string, "upper") \
+ || STREQ (string, "lower") || STREQ (string, "digit") \
+ || STREQ (string, "alnum") || STREQ (string, "xdigit") \
+ || STREQ (string, "space") || STREQ (string, "print") \
+ || STREQ (string, "punct") || STREQ (string, "graph") \
+ || STREQ (string, "cntrl") || STREQ (string, "blank"))
+# endif
+
+/* Avoid depending on library functions or files
+ whose names are inconsistent. */
+
+/* Global variable. */
+static int posixly_correct;
+
+# ifndef internal_function
+/* Inside GNU libc we mark some function in a special way. In other
+ environments simply ignore the marking. */
+# define internal_function
+# endif
+
+/* Note that this evaluates C many times. */
+# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
+# define CHAR char
+# define UCHAR unsigned char
+# define INT int
+# define FCT internal_fnmatch
+# define EXT ext_match
+# define END end_pattern
+# define L_(CS) CS
+# ifdef _LIBC
+# define BTOWC(C) __btowc (C)
+# else
+# define BTOWC(C) btowc (C)
+# endif
+# define STRLEN(S) strlen (S)
+# define STRCAT(D, S) strcat (D, S)
+# ifdef _LIBC
+# define MEMPCPY(D, S, N) __mempcpy (D, S, N)
+# else
+# if HAVE_MEMPCPY
+# define MEMPCPY(D, S, N) mempcpy (D, S, N)
+# else
+# define MEMPCPY(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
+# endif
+# endif
+# define MEMCHR(S, C, N) memchr (S, C, N)
+# include "fnmatch_loop.c"
+
+
+# if HANDLE_MULTIBYTE
+# define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c))
+# define CHAR wchar_t
+# define UCHAR wint_t
+# define INT wint_t
+# define FCT internal_fnwmatch
+# define EXT ext_wmatch
+# define END end_wpattern
+# define L_(CS) L##CS
+# define BTOWC(C) (C)
+# ifdef _LIBC
+# define STRLEN(S) __wcslen (S)
+# define STRCAT(D, S) __wcscat (D, S)
+# define MEMPCPY(D, S, N) __wmempcpy (D, S, N)
+# else
+# define STRLEN(S) wcslen (S)
+# define STRCAT(D, S) wcscat (D, S)
+# if HAVE_WMEMPCPY
+# define MEMPCPY(D, S, N) wmempcpy (D, S, N)
+# else
+# define MEMPCPY(D, S, N) (wmemcpy (D, S, N) + (N))
+# endif
+# endif
+# define MEMCHR(S, C, N) wmemchr (S, C, N)
+# define WIDE_CHAR_VERSION 1
+
+# undef IS_CHAR_CLASS
+/* We have to convert the wide character string in a multibyte string. But
+ we know that the character class names consist of alphanumeric characters
+ from the portable character set, and since the wide character encoding
+ for a member of the portable character set is the same code point as
+ its single-byte encoding, we can use a simplified method to convert the
+ string to a multibyte character string. */
+static wctype_t
+is_char_class (const wchar_t *wcs)
+{
+ char s[CHAR_CLASS_MAX_LENGTH + 1];
+ char *cp = s;
+
+ do
+ {
+ /* Test for a printable character from the portable character set. */
+# ifdef _LIBC
+ if (*wcs < 0x20 || *wcs > 0x7e
+ || *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60)
+ return (wctype_t) 0;
+# else
+ switch (*wcs)
+ {
+ case L' ': case L'!': case L'"': case L'#': case L'%':
+ case L'&': case L'\'': case L'(': case L')': case L'*':
+ case L'+': case L',': case L'-': case L'.': case L'/':
+ case L'0': case L'1': case L'2': case L'3': case L'4':
+ case L'5': case L'6': case L'7': case L'8': case L'9':
+ case L':': case L';': case L'<': case L'=': case L'>':
+ case L'?':
+ case L'A': case L'B': case L'C': case L'D': case L'E':
+ case L'F': case L'G': case L'H': case L'I': case L'J':
+ case L'K': case L'L': case L'M': case L'N': case L'O':
+ case L'P': case L'Q': case L'R': case L'S': case L'T':
+ case L'U': case L'V': case L'W': case L'X': case L'Y':
+ case L'Z':
+ case L'[': case L'\\': case L']': case L'^': case L'_':
+ case L'a': case L'b': case L'c': case L'd': case L'e':
+ case L'f': case L'g': case L'h': case L'i': case L'j':
+ case L'k': case L'l': case L'm': case L'n': case L'o':
+ case L'p': case L'q': case L'r': case L's': case L't':
+ case L'u': case L'v': case L'w': case L'x': case L'y':
+ case L'z': case L'{': case L'|': case L'}': case L'~':
+ break;
+ default:
+ return (wctype_t) 0;
+ }
+# endif
+
+ /* Avoid overrunning the buffer. */
+ if (cp == s + CHAR_CLASS_MAX_LENGTH)
+ return (wctype_t) 0;
+
+ *cp++ = (char) *wcs++;
+ }
+ while (*wcs != L'\0');
+
+ *cp = '\0';
+
+# ifdef _LIBC
+ return __wctype (s);
+# else
+ return wctype (s);
+# endif
+}
+# define IS_CHAR_CLASS(string) is_char_class (string)
+
+# include "fnmatch_loop.c"
+# endif
+
+
+int
+fnmatch (const char *pattern, const char *string, int flags)
+{
+# if HANDLE_MULTIBYTE
+# define ALLOCA_LIMIT 2000
+ if (__builtin_expect (MB_CUR_MAX, 1) != 1)
+ {
+ mbstate_t ps;
+ size_t patsize;
+ size_t strsize;
+ size_t totsize;
+ wchar_t *wpattern;
+ wchar_t *wstring;
+ int res;
+
+ /* Calculate the size needed to convert the strings to
+ wide characters. */
+ memset (&ps, '\0', sizeof (ps));
+ patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1;
+ if (__builtin_expect (patsize != 0, 1))
+ {
+ assert (mbsinit (&ps));
+ strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
+ if (__builtin_expect (strsize != 0, 1))
+ {
+ assert (mbsinit (&ps));
+ totsize = patsize + strsize;
+ if (__builtin_expect (! (patsize <= totsize
+ && totsize <= SIZE_MAX / sizeof (wchar_t)),
+ 0))
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ /* Allocate room for the wide characters. */
+ if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
+ wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
+ else
+ {
+ wpattern = malloc (totsize * sizeof (wchar_t));
+ if (__builtin_expect (! wpattern, 0))
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ }
+ wstring = wpattern + patsize;
+
+ /* Convert the strings into wide characters. */
+ mbsrtowcs (wpattern, &pattern, patsize, &ps);
+ assert (mbsinit (&ps));
+ mbsrtowcs (wstring, &string, strsize, &ps);
+
+ res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
+ flags & FNM_PERIOD, flags);
+
+ if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
+ free (wpattern);
+ return res;
+ }
+ }
+ }
+
+# endif /* HANDLE_MULTIBYTE */
+
+ return internal_fnmatch (pattern, string, string + strlen (string),
+ flags & FNM_PERIOD, flags);
+}
+
+# ifdef _LIBC
+# undef fnmatch
+versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3);
+# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_3)
+strong_alias (__fnmatch, __fnmatch_old)
+compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0);
+# endif
+libc_hidden_ver (__fnmatch, fnmatch)
+# endif
+
+#endif /* _LIBC or not __GNU_LIBRARY__. */
diff --git a/grub-core/lib/gnulib/fnmatch.in.h b/grub-core/lib/gnulib/fnmatch.in.h
new file mode 100644
index 0000000..2ead782
--- /dev/null
+++ b/grub-core/lib/gnulib/fnmatch.in.h
@@ -0,0 +1,110 @@
+/* Substitute for and wrapper around <fnmatch.h>.
+ Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2019 Free
+ Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_FNMATCH_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_FNMATCH_H@ && !@REPLACE_FNMATCH@
+# @INCLUDE_NEXT@ @NEXT_FNMATCH_H@
+#endif
+
+#ifndef _@GUARD_PREFIX@_FNMATCH_H
+#define _@GUARD_PREFIX@_FNMATCH_H
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+#if !@HAVE_FNMATCH_H@ || @REPLACE_FNMATCH@
+
+/* We #undef these before defining them because some losing systems
+ (HP-UX A.08.07 for example) define these in <unistd.h>. */
+#undef FNM_PATHNAME
+#undef FNM_NOESCAPE
+#undef FNM_PERIOD
+
+/* Bits set in the FLAGS argument to 'fnmatch'. */
+#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match '/'. */
+#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
+#define FNM_PERIOD (1 << 2) /* Leading '.' is matched only explicitly. */
+
+#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
+# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
+# define FNM_LEADING_DIR (1 << 3) /* Ignore '/...' after a match. */
+# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
+# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */
+#endif
+
+/* Value returned by 'fnmatch' if STRING does not match PATTERN. */
+#define FNM_NOMATCH 1
+
+/* This value is returned if the implementation does not support
+ 'fnmatch'. Since this is not the case here it will never be
+ returned but the conformance test suites still require the symbol
+ to be defined. */
+#ifdef _XOPEN_SOURCE
+# define FNM_NOSYS (-1)
+#endif
+
+#endif
+
+
+#if @GNULIB_FNMATCH@
+/* Match NAME against the file name pattern PATTERN,
+ returning zero if it matches, FNM_NOMATCH if not. */
+# if @REPLACE_FNMATCH@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define fnmatch rpl_fnmatch
+# endif
+_GL_FUNCDECL_RPL (fnmatch, int,
+ (const char *pattern, const char *name, int flags)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (fnmatch, int,
+ (const char *pattern, const char *name, int flags));
+# else
+# if !@HAVE_FNMATCH@
+_GL_FUNCDECL_SYS (fnmatch, int,
+ (const char *pattern, const char *name, int flags)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (fnmatch, int,
+ (const char *pattern, const char *name, int flags));
+# endif
+# if !GNULIB_FNMATCH_GNU
+_GL_CXXALIASWARN (fnmatch);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fnmatch
+# if HAVE_RAW_DECL_FNMATCH
+_GL_WARN_ON_USE (fnmatch,
+ "fnmatch does not portably work - "
+ "use gnulib module fnmatch for portability or gnulib module fnmatch-gnu for a glibc compatible implementation");
+# endif
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_FNMATCH_H */
+#endif /* _@GUARD_PREFIX@_FNMATCH_H */
diff --git a/grub-core/lib/gnulib/fnmatch_loop.c b/grub-core/lib/gnulib/fnmatch_loop.c
new file mode 100644
index 0000000..82a7cee
--- /dev/null
+++ b/grub-core/lib/gnulib/fnmatch_loop.c
@@ -0,0 +1,1217 @@
+/* Copyright (C) 1991-1993, 1996-2006, 2009-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Match STRING against the file name pattern PATTERN, returning zero if
+ it matches, nonzero if not. */
+static int EXT (INT opt, const CHAR *pattern, const CHAR *string,
+ const CHAR *string_end, bool no_leading_period, int flags)
+ internal_function;
+static const CHAR *END (const CHAR *patternp) internal_function;
+
+static int
+internal_function
+FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
+ bool no_leading_period, int flags)
+{
+ register const CHAR *p = pattern, *n = string;
+ register UCHAR c;
+#ifdef _LIBC
+# if WIDE_CHAR_VERSION
+ const char *collseq = (const char *)
+ _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQWC);
+# else
+ const UCHAR *collseq = (const UCHAR *)
+ _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQMB);
+# endif
+#endif
+
+ while ((c = *p++) != L_('\0'))
+ {
+ bool new_no_leading_period = false;
+ c = FOLD (c);
+
+ switch (c)
+ {
+ case L_('?'):
+ if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
+ {
+ int res;
+
+ res = EXT (c, p, n, string_end, no_leading_period,
+ flags);
+ if (res != -1)
+ return res;
+ }
+
+ if (n == string_end)
+ return FNM_NOMATCH;
+ else if (*n == L_('/') && (flags & FNM_FILE_NAME))
+ return FNM_NOMATCH;
+ else if (*n == L_('.') && no_leading_period)
+ return FNM_NOMATCH;
+ break;
+
+ case L_('\\'):
+ if (!(flags & FNM_NOESCAPE))
+ {
+ c = *p++;
+ if (c == L_('\0'))
+ /* Trailing \ loses. */
+ return FNM_NOMATCH;
+ c = FOLD (c);
+ }
+ if (n == string_end || FOLD ((UCHAR) *n) != c)
+ return FNM_NOMATCH;
+ break;
+
+ case L_('*'):
+ if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
+ {
+ int res;
+
+ res = EXT (c, p, n, string_end, no_leading_period,
+ flags);
+ if (res != -1)
+ return res;
+ }
+
+ if (n != string_end && *n == L_('.') && no_leading_period)
+ return FNM_NOMATCH;
+
+ for (c = *p++; c == L_('?') || c == L_('*'); c = *p++)
+ {
+ if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0)
+ {
+ const CHAR *endp = END (p);
+ if (endp != p)
+ {
+ /* This is a pattern. Skip over it. */
+ p = endp;
+ continue;
+ }
+ }
+
+ if (c == L_('?'))
+ {
+ /* A ? needs to match one character. */
+ if (n == string_end)
+ /* There isn't another character; no match. */
+ return FNM_NOMATCH;
+ else if (*n == L_('/')
+ && __builtin_expect (flags & FNM_FILE_NAME, 0))
+ /* A slash does not match a wildcard under
+ FNM_FILE_NAME. */
+ return FNM_NOMATCH;
+ else
+ /* One character of the string is consumed in matching
+ this ? wildcard, so *??? won't match if there are
+ less than three characters. */
+ ++n;
+ }
+ }
+
+ if (c == L_('\0'))
+ /* The wildcard(s) is/are the last element of the pattern.
+ If the name is a file name and contains another slash
+ this means it cannot match, unless the FNM_LEADING_DIR
+ flag is set. */
+ {
+ int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH;
+
+ if (flags & FNM_FILE_NAME)
+ {
+ if (flags & FNM_LEADING_DIR)
+ result = 0;
+ else
+ {
+ if (MEMCHR (n, L_('/'), string_end - n) == NULL)
+ result = 0;
+ }
+ }
+
+ return result;
+ }
+ else
+ {
+ const CHAR *endp;
+
+ endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'),
+ string_end - n);
+ if (endp == NULL)
+ endp = string_end;
+
+ if (c == L_('[')
+ || (__builtin_expect (flags & FNM_EXTMATCH, 0) != 0
+ && (c == L_('@') || c == L_('+') || c == L_('!'))
+ && *p == L_('(')))
+ {
+ int flags2 = ((flags & FNM_FILE_NAME)
+ ? flags : (flags & ~FNM_PERIOD));
+ bool no_leading_period2 = no_leading_period;
+
+ for (--p; n < endp; ++n, no_leading_period2 = false)
+ if (FCT (p, n, string_end, no_leading_period2, flags2)
+ == 0)
+ return 0;
+ }
+ else if (c == L_('/') && (flags & FNM_FILE_NAME))
+ {
+ while (n < string_end && *n != L_('/'))
+ ++n;
+ if (n < string_end && *n == L_('/')
+ && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags)
+ == 0))
+ return 0;
+ }
+ else
+ {
+ int flags2 = ((flags & FNM_FILE_NAME)
+ ? flags : (flags & ~FNM_PERIOD));
+ int no_leading_period2 = no_leading_period;
+
+ if (c == L_('\\') && !(flags & FNM_NOESCAPE))
+ c = *p;
+ c = FOLD (c);
+ for (--p; n < endp; ++n, no_leading_period2 = false)
+ if (FOLD ((UCHAR) *n) == c
+ && (FCT (p, n, string_end, no_leading_period2, flags2)
+ == 0))
+ return 0;
+ }
+ }
+
+ /* If we come here no match is possible with the wildcard. */
+ return FNM_NOMATCH;
+
+ case L_('['):
+ {
+ /* Nonzero if the sense of the character class is inverted. */
+ const CHAR *p_init = p;
+ const CHAR *n_init = n;
+ register bool not;
+ CHAR cold;
+ UCHAR fn;
+
+ if (posixly_correct == 0)
+ posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+
+ if (n == string_end)
+ return FNM_NOMATCH;
+
+ if (*n == L_('.') && no_leading_period)
+ return FNM_NOMATCH;
+
+ if (*n == L_('/') && (flags & FNM_FILE_NAME))
+ /* '/' cannot be matched. */
+ return FNM_NOMATCH;
+
+ not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^')));
+ if (not)
+ ++p;
+
+ fn = FOLD ((UCHAR) *n);
+
+ c = *p++;
+ for (;;)
+ {
+ bool is_range = false;
+
+ if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
+ {
+ if (*p == L_('\0'))
+ return FNM_NOMATCH;
+ c = FOLD ((UCHAR) *p);
+ ++p;
+
+ goto normal_bracket;
+ }
+ else if (c == L_('[') && *p == L_(':'))
+ {
+ /* Leave room for the null. */
+ CHAR str[CHAR_CLASS_MAX_LENGTH + 1];
+ size_t c1 = 0;
+#if defined _LIBC || WIDE_CHAR_SUPPORT
+ wctype_t wt;
+#endif
+ const CHAR *startp = p;
+
+ for (;;)
+ {
+ if (c1 == CHAR_CLASS_MAX_LENGTH)
+ /* The name is too long and therefore the pattern
+ is ill-formed. */
+ return FNM_NOMATCH;
+
+ c = *++p;
+ if (c == L_(':') && p[1] == L_(']'))
+ {
+ p += 2;
+ break;
+ }
+ if (c < L_('a') || c >= L_('z'))
+ {
+ /* This cannot possibly be a character class name.
+ Match it as a normal range. */
+ p = startp;
+ c = L_('[');
+ goto normal_bracket;
+ }
+ str[c1++] = c;
+ }
+ str[c1] = L_('\0');
+
+#if defined _LIBC || WIDE_CHAR_SUPPORT
+ wt = IS_CHAR_CLASS (str);
+ if (wt == 0)
+ /* Invalid character class name. */
+ return FNM_NOMATCH;
+
+# if defined _LIBC && ! WIDE_CHAR_VERSION
+ /* The following code is glibc specific but does
+ there a good job in speeding up the code since
+ we can avoid the btowc() call. */
+ if (_ISCTYPE ((UCHAR) *n, wt))
+ goto matched;
+# else
+ if (ISWCTYPE (BTOWC ((UCHAR) *n), wt))
+ goto matched;
+# endif
+#else
+ if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n))
+ || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n))
+ || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n))
+ || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n))
+ || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n))
+ || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n))
+ || (STREQ (str, L_("lower")) && islower ((UCHAR) *n))
+ || (STREQ (str, L_("print")) && isprint ((UCHAR) *n))
+ || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n))
+ || (STREQ (str, L_("space")) && isspace ((UCHAR) *n))
+ || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n))
+ || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n)))
+ goto matched;
+#endif
+ c = *p++;
+ }
+#ifdef _LIBC
+ else if (c == L_('[') && *p == L_('='))
+ {
+ UCHAR str[1];
+ uint32_t nrules =
+ _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ const CHAR *startp = p;
+
+ c = *++p;
+ if (c == L_('\0'))
+ {
+ p = startp;
+ c = L_('[');
+ goto normal_bracket;
+ }
+ str[0] = c;
+
+ c = *++p;
+ if (c != L_('=') || p[1] != L_(']'))
+ {
+ p = startp;
+ c = L_('[');
+ goto normal_bracket;
+ }
+ p += 2;
+
+ if (nrules == 0)
+ {
+ if ((UCHAR) *n == str[0])
+ goto matched;
+ }
+ else
+ {
+ const int32_t *table;
+# if WIDE_CHAR_VERSION
+ const int32_t *weights;
+ const int32_t *extra;
+# else
+ const unsigned char *weights;
+ const unsigned char *extra;
+# endif
+ const int32_t *indirect;
+ int32_t idx;
+ const UCHAR *cp = (const UCHAR *) str;
+
+ /* This #include defines a local function! */
+# if WIDE_CHAR_VERSION
+# include <locale/weightwc.h>
+# else
+# include <locale/weight.h>
+# endif
+
+# if WIDE_CHAR_VERSION
+ table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC);
+ weights = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC);
+ extra = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC);
+ indirect = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC);
+# else
+ table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+ weights = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
+ indirect = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
+# endif
+
+ idx = findidx (&cp);
+ if (idx != 0)
+ {
+ /* We found a table entry. Now see whether the
+ character we are currently at has the same
+ equivalence class value. */
+ int len = weights[idx & 0xffffff];
+ int32_t idx2;
+ const UCHAR *np = (const UCHAR *) n;
+
+ idx2 = findidx (&np);
+ if (idx2 != 0
+ && (idx >> 24) == (idx2 >> 24)
+ && len == weights[idx2 & 0xffffff])
+ {
+ int cnt = 0;
+
+ idx &= 0xffffff;
+ idx2 &= 0xffffff;
+
+ while (cnt < len
+ && (weights[idx + 1 + cnt]
+ == weights[idx2 + 1 + cnt]))
+ ++cnt;
+
+ if (cnt == len)
+ goto matched;
+ }
+ }
+ }
+
+ c = *p++;
+ }
+#endif
+ else if (c == L_('\0'))
+ {
+ /* [ unterminated, treat as normal character. */
+ p = p_init;
+ n = n_init;
+ c = L_('[');
+ goto normal_match;
+ }
+ else
+ {
+#ifdef _LIBC
+ bool is_seqval = false;
+
+ if (c == L_('[') && *p == L_('.'))
+ {
+ uint32_t nrules =
+ _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ const CHAR *startp = p;
+ size_t c1 = 0;
+
+ while (1)
+ {
+ c = *++p;
+ if (c == L_('.') && p[1] == L_(']'))
+ {
+ p += 2;
+ break;
+ }
+ if (c == '\0')
+ return FNM_NOMATCH;
+ ++c1;
+ }
+
+ /* We have to handling the symbols differently in
+ ranges since then the collation sequence is
+ important. */
+ is_range = *p == L_('-') && p[1] != L_('\0');
+
+ if (nrules == 0)
+ {
+ /* There are no names defined in the collation
+ data. Therefore we only accept the trivial
+ names consisting of the character itself. */
+ if (c1 != 1)
+ return FNM_NOMATCH;
+
+ if (!is_range && *n == startp[1])
+ goto matched;
+
+ cold = startp[1];
+ c = *p++;
+ }
+ else
+ {
+ int32_t table_size;
+ const int32_t *symb_table;
+# ifdef WIDE_CHAR_VERSION
+ char str[c1];
+ size_t strcnt;
+# else
+# define str (startp + 1)
+# endif
+ const unsigned char *extra;
+ int32_t idx;
+ int32_t elem;
+ int32_t second;
+ int32_t hash;
+
+# ifdef WIDE_CHAR_VERSION
+ /* We have to convert the name to a single-byte
+ string. This is possible since the names
+ consist of ASCII characters and the internal
+ representation is UCS4. */
+ for (strcnt = 0; strcnt < c1; ++strcnt)
+ str[strcnt] = startp[1 + strcnt];
+# endif
+
+ table_size =
+ _NL_CURRENT_WORD (LC_COLLATE,
+ _NL_COLLATE_SYMB_HASH_SIZEMB);
+ symb_table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_TABLEMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_EXTRAMB);
+
+ /* Locate the character in the hashing table. */
+ hash = elem_hash (str, c1);
+
+ idx = 0;
+ elem = hash % table_size;
+ if (symb_table[2 * elem] != 0)
+ {
+ second = hash % (table_size - 2) + 1;
+
+ do
+ {
+ /* First compare the hashing value. */
+ if (symb_table[2 * elem] == hash
+ && (c1
+ == extra[symb_table[2 * elem + 1]])
+ && memcmp (str,
+ &extra[symb_table[2 * elem
+ + 1]
+ + 1], c1) == 0)
+ {
+ /* Yep, this is the entry. */
+ idx = symb_table[2 * elem + 1];
+ idx += 1 + extra[idx];
+ break;
+ }
+
+ /* Next entry. */
+ elem += second;
+ }
+ while (symb_table[2 * elem] != 0);
+ }
+
+ if (symb_table[2 * elem] != 0)
+ {
+ /* Compare the byte sequence but only if
+ this is not part of a range. */
+# ifdef WIDE_CHAR_VERSION
+ int32_t *wextra;
+
+ idx += 1 + extra[idx];
+ /* Adjust for the alignment. */
+ idx = (idx + 3) & ~3;
+
+ wextra = (int32_t *) &extra[idx + 4];
+# endif
+
+ if (! is_range)
+ {
+# ifdef WIDE_CHAR_VERSION
+ for (c1 = 0;
+ (int32_t) c1 < wextra[idx];
+ ++c1)
+ if (n[c1] != wextra[1 + c1])
+ break;
+
+ if ((int32_t) c1 == wextra[idx])
+ goto matched;
+# else
+ for (c1 = 0; c1 < extra[idx]; ++c1)
+ if (n[c1] != extra[1 + c1])
+ break;
+
+ if (c1 == extra[idx])
+ goto matched;
+# endif
+ }
+
+ /* Get the collation sequence value. */
+ is_seqval = true;
+# ifdef WIDE_CHAR_VERSION
+ cold = wextra[1 + wextra[idx]];
+# else
+ /* Adjust for the alignment. */
+ idx += 1 + extra[idx];
+ idx = (idx + 3) & ~4;
+ cold = *((int32_t *) &extra[idx]);
+# endif
+
+ c = *p++;
+ }
+ else if (c1 == 1)
+ {
+ /* No valid character. Match it as a
+ single byte. */
+ if (!is_range && *n == str[0])
+ goto matched;
+
+ cold = str[0];
+ c = *p++;
+ }
+ else
+ return FNM_NOMATCH;
+ }
+ }
+ else
+# undef str
+#endif
+ {
+ c = FOLD (c);
+ normal_bracket:
+
+ /* We have to handling the symbols differently in
+ ranges since then the collation sequence is
+ important. */
+ is_range = (*p == L_('-') && p[1] != L_('\0')
+ && p[1] != L_(']'));
+
+ if (!is_range && c == fn)
+ goto matched;
+
+#if _LIBC
+ /* This is needed if we goto normal_bracket; from
+ outside of is_seqval's scope. */
+ is_seqval = false;
+#endif
+
+ cold = c;
+ c = *p++;
+ }
+
+ if (c == L_('-') && *p != L_(']'))
+ {
+#if _LIBC
+ /* We have to find the collation sequence
+ value for C. Collation sequence is nothing
+ we can regularly access. The sequence
+ value is defined by the order in which the
+ definitions of the collation values for the
+ various characters appear in the source
+ file. A strange concept, nowhere
+ documented. */
+ uint32_t fcollseq;
+ uint32_t lcollseq;
+ UCHAR cend = *p++;
+
+# ifdef WIDE_CHAR_VERSION
+ /* Search in the 'names' array for the characters. */
+ fcollseq = __collseq_table_lookup (collseq, fn);
+ if (fcollseq == ~((uint32_t) 0))
+ /* XXX We don't know anything about the character
+ we are supposed to match. This means we are
+ failing. */
+ goto range_not_matched;
+
+ if (is_seqval)
+ lcollseq = cold;
+ else
+ lcollseq = __collseq_table_lookup (collseq, cold);
+# else
+ fcollseq = collseq[fn];
+ lcollseq = is_seqval ? cold : collseq[(UCHAR) cold];
+# endif
+
+ is_seqval = false;
+ if (cend == L_('[') && *p == L_('.'))
+ {
+ uint32_t nrules =
+ _NL_CURRENT_WORD (LC_COLLATE,
+ _NL_COLLATE_NRULES);
+ const CHAR *startp = p;
+ size_t c1 = 0;
+
+ while (1)
+ {
+ c = *++p;
+ if (c == L_('.') && p[1] == L_(']'))
+ {
+ p += 2;
+ break;
+ }
+ if (c == '\0')
+ return FNM_NOMATCH;
+ ++c1;
+ }
+
+ if (nrules == 0)
+ {
+ /* There are no names defined in the
+ collation data. Therefore we only
+ accept the trivial names consisting
+ of the character itself. */
+ if (c1 != 1)
+ return FNM_NOMATCH;
+
+ cend = startp[1];
+ }
+ else
+ {
+ int32_t table_size;
+ const int32_t *symb_table;
+# ifdef WIDE_CHAR_VERSION
+ char str[c1];
+ size_t strcnt;
+# else
+# define str (startp + 1)
+# endif
+ const unsigned char *extra;
+ int32_t idx;
+ int32_t elem;
+ int32_t second;
+ int32_t hash;
+
+# ifdef WIDE_CHAR_VERSION
+ /* We have to convert the name to a single-byte
+ string. This is possible since the names
+ consist of ASCII characters and the internal
+ representation is UCS4. */
+ for (strcnt = 0; strcnt < c1; ++strcnt)
+ str[strcnt] = startp[1 + strcnt];
+# endif
+
+ table_size =
+ _NL_CURRENT_WORD (LC_COLLATE,
+ _NL_COLLATE_SYMB_HASH_SIZEMB);
+ symb_table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_TABLEMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_EXTRAMB);
+
+ /* Locate the character in the hashing
+ table. */
+ hash = elem_hash (str, c1);
+
+ idx = 0;
+ elem = hash % table_size;
+ if (symb_table[2 * elem] != 0)
+ {
+ second = hash % (table_size - 2) + 1;
+
+ do
+ {
+ /* First compare the hashing value. */
+ if (symb_table[2 * elem] == hash
+ && (c1
+ == extra[symb_table[2 * elem + 1]])
+ && memcmp (str,
+ &extra[symb_table[2 * elem + 1]
+ + 1], c1) == 0)
+ {
+ /* Yep, this is the entry. */
+ idx = symb_table[2 * elem + 1];
+ idx += 1 + extra[idx];
+ break;
+ }
+
+ /* Next entry. */
+ elem += second;
+ }
+ while (symb_table[2 * elem] != 0);
+ }
+
+ if (symb_table[2 * elem] != 0)
+ {
+ /* Compare the byte sequence but only if
+ this is not part of a range. */
+# ifdef WIDE_CHAR_VERSION
+ int32_t *wextra;
+
+ idx += 1 + extra[idx];
+ /* Adjust for the alignment. */
+ idx = (idx + 3) & ~4;
+
+ wextra = (int32_t *) &extra[idx + 4];
+# endif
+ /* Get the collation sequence value. */
+ is_seqval = true;
+# ifdef WIDE_CHAR_VERSION
+ cend = wextra[1 + wextra[idx]];
+# else
+ /* Adjust for the alignment. */
+ idx += 1 + extra[idx];
+ idx = (idx + 3) & ~4;
+ cend = *((int32_t *) &extra[idx]);
+# endif
+ }
+ else if (symb_table[2 * elem] != 0 && c1 == 1)
+ {
+ cend = str[0];
+ c = *p++;
+ }
+ else
+ return FNM_NOMATCH;
+ }
+# undef str
+ }
+ else
+ {
+ if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
+ cend = *p++;
+ if (cend == L_('\0'))
+ return FNM_NOMATCH;
+ cend = FOLD (cend);
+ }
+
+ /* XXX It is not entirely clear to me how to handle
+ characters which are not mentioned in the
+ collation specification. */
+ if (
+# ifdef WIDE_CHAR_VERSION
+ lcollseq == 0xffffffff ||
+# endif
+ lcollseq <= fcollseq)
+ {
+ /* We have to look at the upper bound. */
+ uint32_t hcollseq;
+
+ if (is_seqval)
+ hcollseq = cend;
+ else
+ {
+# ifdef WIDE_CHAR_VERSION
+ hcollseq =
+ __collseq_table_lookup (collseq, cend);
+ if (hcollseq == ~((uint32_t) 0))
+ {
+ /* Hum, no information about the upper
+ bound. The matching succeeds if the
+ lower bound is matched exactly. */
+ if (lcollseq != fcollseq)
+ goto range_not_matched;
+
+ goto matched;
+ }
+# else
+ hcollseq = collseq[cend];
+# endif
+ }
+
+ if (lcollseq <= hcollseq && fcollseq <= hcollseq)
+ goto matched;
+ }
+# ifdef WIDE_CHAR_VERSION
+ range_not_matched:
+# endif
+#else
+ /* We use a boring value comparison of the character
+ values. This is better than comparing using
+ 'strcoll' since the latter would have surprising
+ and sometimes fatal consequences. */
+ UCHAR cend = *p++;
+
+ if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
+ cend = *p++;
+ if (cend == L_('\0'))
+ return FNM_NOMATCH;
+
+ /* It is a range. */
+ if (cold <= fn && fn <= cend)
+ goto matched;
+#endif
+
+ c = *p++;
+ }
+ }
+
+ if (c == L_(']'))
+ break;
+ }
+
+ if (!not)
+ return FNM_NOMATCH;
+ break;
+
+ matched:
+ /* Skip the rest of the [...] that already matched. */
+ do
+ {
+ ignore_next:
+ c = *p++;
+
+ if (c == L_('\0'))
+ /* [... (unterminated) loses. */
+ return FNM_NOMATCH;
+
+ if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
+ {
+ if (*p == L_('\0'))
+ return FNM_NOMATCH;
+ /* XXX 1003.2d11 is unclear if this is right. */
+ ++p;
+ }
+ else if (c == L_('[') && *p == L_(':'))
+ {
+ int c1 = 0;
+ const CHAR *startp = p;
+
+ while (1)
+ {
+ c = *++p;
+ if (++c1 == CHAR_CLASS_MAX_LENGTH)
+ return FNM_NOMATCH;
+
+ if (*p == L_(':') && p[1] == L_(']'))
+ break;
+
+ if (c < L_('a') || c >= L_('z'))
+ {
+ p = startp;
+ goto ignore_next;
+ }
+ }
+ p += 2;
+ c = *p++;
+ }
+ else if (c == L_('[') && *p == L_('='))
+ {
+ c = *++p;
+ if (c == L_('\0'))
+ return FNM_NOMATCH;
+ c = *++p;
+ if (c != L_('=') || p[1] != L_(']'))
+ return FNM_NOMATCH;
+ p += 2;
+ c = *p++;
+ }
+ else if (c == L_('[') && *p == L_('.'))
+ {
+ ++p;
+ while (1)
+ {
+ c = *++p;
+ if (c == '\0')
+ return FNM_NOMATCH;
+
+ if (*p == L_('.') && p[1] == L_(']'))
+ break;
+ }
+ p += 2;
+ c = *p++;
+ }
+ }
+ while (c != L_(']'));
+ if (not)
+ return FNM_NOMATCH;
+ }
+ break;
+
+ case L_('+'):
+ case L_('@'):
+ case L_('!'):
+ if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
+ {
+ int res;
+
+ res = EXT (c, p, n, string_end, no_leading_period, flags);
+ if (res != -1)
+ return res;
+ }
+ goto normal_match;
+
+ case L_('/'):
+ if (NO_LEADING_PERIOD (flags))
+ {
+ if (n == string_end || c != (UCHAR) *n)
+ return FNM_NOMATCH;
+
+ new_no_leading_period = true;
+ break;
+ }
+ FALLTHROUGH;
+ default:
+ normal_match:
+ if (n == string_end || c != FOLD ((UCHAR) *n))
+ return FNM_NOMATCH;
+ }
+
+ no_leading_period = new_no_leading_period;
+ ++n;
+ }
+
+ if (n == string_end)
+ return 0;
+
+ if ((flags & FNM_LEADING_DIR) && n != string_end && *n == L_('/'))
+ /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
+ return 0;
+
+ return FNM_NOMATCH;
+}
+
+
+static const CHAR *
+internal_function
+END (const CHAR *pattern)
+{
+ const CHAR *p = pattern;
+
+ while (1)
+ if (*++p == L_('\0'))
+ /* This is an invalid pattern. */
+ return pattern;
+ else if (*p == L_('['))
+ {
+ /* Handle brackets special. */
+ if (posixly_correct == 0)
+ posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+
+ /* Skip the not sign. We have to recognize it because of a possibly
+ following ']'. */
+ if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
+ ++p;
+ /* A leading ']' is recognized as such. */
+ if (*p == L_(']'))
+ ++p;
+ /* Skip over all characters of the list. */
+ while (*p != L_(']'))
+ if (*p++ == L_('\0'))
+ /* This is no valid pattern. */
+ return pattern;
+ }
+ else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
+ || *p == L_('!')) && p[1] == L_('('))
+ p = END (p + 1);
+ else if (*p == L_(')'))
+ break;
+
+ return p + 1;
+}
+
+
+static int
+internal_function
+EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
+ bool no_leading_period, int flags)
+{
+ const CHAR *startp;
+ size_t level;
+ struct patternlist
+ {
+ struct patternlist *next;
+ CHAR str[FLEXIBLE_ARRAY_MEMBER];
+ } *list = NULL;
+ struct patternlist **lastp = &list;
+ size_t pattern_len = STRLEN (pattern);
+ const CHAR *p;
+ const CHAR *rs;
+ enum { ALLOCA_LIMIT = 8000 };
+
+ /* Parse the pattern. Store the individual parts in the list. */
+ level = 0;
+ for (startp = p = pattern + 1; ; ++p)
+ if (*p == L_('\0'))
+ /* This is an invalid pattern. */
+ return -1;
+ else if (*p == L_('['))
+ {
+ /* Handle brackets special. */
+ if (posixly_correct == 0)
+ posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+
+ /* Skip the not sign. We have to recognize it because of a possibly
+ following ']'. */
+ if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
+ ++p;
+ /* A leading ']' is recognized as such. */
+ if (*p == L_(']'))
+ ++p;
+ /* Skip over all characters of the list. */
+ while (*p != L_(']'))
+ if (*p++ == L_('\0'))
+ /* This is no valid pattern. */
+ return -1;
+ }
+ else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
+ || *p == L_('!')) && p[1] == L_('('))
+ /* Remember the nesting level. */
+ ++level;
+ else if (*p == L_(')'))
+ {
+ if (level-- == 0)
+ {
+ /* This means we found the end of the pattern. */
+#define NEW_PATTERN \
+ struct patternlist *newp; \
+ size_t plen; \
+ size_t plensize; \
+ size_t newpsize; \
+ \
+ plen = (opt == L_('?') || opt == L_('@') \
+ ? pattern_len \
+ : p - startp + 1UL); \
+ plensize = plen * sizeof (CHAR); \
+ newpsize = FLEXSIZEOF (struct patternlist, str, plensize); \
+ if ((size_t) -1 / sizeof (CHAR) < plen \
+ || newpsize < offsetof (struct patternlist, str) \
+ || ALLOCA_LIMIT <= newpsize) \
+ return -1; \
+ newp = (struct patternlist *) alloca (newpsize); \
+ *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0'); \
+ newp->next = NULL; \
+ *lastp = newp; \
+ lastp = &newp->next
+ NEW_PATTERN;
+ break;
+ }
+ }
+ else if (*p == L_('|'))
+ {
+ if (level == 0)
+ {
+ NEW_PATTERN;
+ startp = p + 1;
+ }
+ }
+ assert (list != NULL);
+ assert (p[-1] == L_(')'));
+#undef NEW_PATTERN
+
+ switch (opt)
+ {
+ case L_('*'):
+ if (FCT (p, string, string_end, no_leading_period, flags) == 0)
+ return 0;
+ FALLTHROUGH;
+ case L_('+'):
+ do
+ {
+ for (rs = string; rs <= string_end; ++rs)
+ /* First match the prefix with the current pattern with the
+ current pattern. */
+ if (FCT (list->str, string, rs, no_leading_period,
+ flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0
+ /* This was successful. Now match the rest with the rest
+ of the pattern. */
+ && (FCT (p, rs, string_end,
+ rs == string
+ ? no_leading_period
+ : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
+ flags & FNM_FILE_NAME
+ ? flags : flags & ~FNM_PERIOD) == 0
+ /* This didn't work. Try the whole pattern. */
+ || (rs != string
+ && FCT (pattern - 1, rs, string_end,
+ rs == string
+ ? no_leading_period
+ : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
+ flags & FNM_FILE_NAME
+ ? flags : flags & ~FNM_PERIOD) == 0)))
+ /* It worked. Signal success. */
+ return 0;
+ }
+ while ((list = list->next) != NULL);
+
+ /* None of the patterns lead to a match. */
+ return FNM_NOMATCH;
+
+ case L_('?'):
+ if (FCT (p, string, string_end, no_leading_period, flags) == 0)
+ return 0;
+ FALLTHROUGH;
+ case L_('@'):
+ do
+ /* I cannot believe it but 'strcat' is actually acceptable
+ here. Match the entire string with the prefix from the
+ pattern list and the rest of the pattern following the
+ pattern list. */
+ if (FCT (STRCAT (list->str, p), string, string_end,
+ no_leading_period,
+ flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
+ /* It worked. Signal success. */
+ return 0;
+ while ((list = list->next) != NULL);
+
+ /* None of the patterns lead to a match. */
+ return FNM_NOMATCH;
+
+ case L_('!'):
+ for (rs = string; rs <= string_end; ++rs)
+ {
+ struct patternlist *runp;
+
+ for (runp = list; runp != NULL; runp = runp->next)
+ if (FCT (runp->str, string, rs, no_leading_period,
+ flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
+ break;
+
+ /* If none of the patterns matched see whether the rest does. */
+ if (runp == NULL
+ && (FCT (p, rs, string_end,
+ rs == string
+ ? no_leading_period
+ : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
+ flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD)
+ == 0))
+ /* This is successful. */
+ return 0;
+ }
+
+ /* None of the patterns together with the rest of the pattern
+ lead to a match. */
+ return FNM_NOMATCH;
+
+ default:
+ assert (! "Invalid extended matching operator");
+ break;
+ }
+
+ return -1;
+}
+
+
+#undef FOLD
+#undef CHAR
+#undef UCHAR
+#undef INT
+#undef FCT
+#undef EXT
+#undef END
+#undef MEMPCPY
+#undef MEMCHR
+#undef STRLEN
+#undef STRCAT
+#undef L_
+#undef BTOWC
diff --git a/grub-core/lib/gnulib/fstat.c b/grub-core/lib/gnulib/fstat.c
new file mode 100644
index 0000000..4f0e618
--- /dev/null
+++ b/grub-core/lib/gnulib/fstat.c
@@ -0,0 +1,90 @@
+/* fstat() replacement.
+ Copyright (C) 2011-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+ the system's <sys/stat.h> here, so that orig_fstat doesn't recurse to
+ rpl_fstat. */
+#define __need_system_sys_stat_h
+#include <config.h>
+
+/* Get the original definition of fstat. It might be defined as a macro. */
+#include <sys/types.h>
+#include <sys/stat.h>
+#undef __need_system_sys_stat_h
+
+#if defined _WIN32 && ! defined __CYGWIN__
+# define WINDOWS_NATIVE
+#endif
+
+#if !defined WINDOWS_NATIVE
+
+static int
+orig_fstat (int fd, struct stat *buf)
+{
+ return fstat (fd, buf);
+}
+
+#endif
+
+/* Specification. */
+/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
+ eliminates this include because of the preliminary #include <sys/stat.h>
+ above. */
+#include "sys/stat.h"
+
+#include "stat-time.h"
+
+#include <errno.h>
+#include <unistd.h>
+#ifdef WINDOWS_NATIVE
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
+# include "stat-w32.h"
+#endif
+
+int
+rpl_fstat (int fd, struct stat *buf)
+{
+#if REPLACE_FCHDIR && REPLACE_OPEN_DIRECTORY
+ /* Handle the case when rpl_open() used a dummy file descriptor to work
+ around an open() that can't normally visit directories. */
+ const char *name = _gl_directory_name (fd);
+ if (name != NULL)
+ return stat (name, buf);
+#endif
+
+#ifdef WINDOWS_NATIVE
+ /* Fill the fields ourselves, because the original fstat function returns
+ values for st_atime, st_mtime, st_ctime that depend on the current time
+ zone. See
+ <https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html> */
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ return _gl_fstat_by_handle (h, NULL, buf);
+#else
+ return stat_time_normalize (orig_fstat (fd, buf), buf);
+#endif
+}
diff --git a/grub-core/lib/gnulib/getcwd-lgpl.c b/grub-core/lib/gnulib/getcwd-lgpl.c
new file mode 100644
index 0000000..b224cfc
--- /dev/null
+++ b/grub-core/lib/gnulib/getcwd-lgpl.c
@@ -0,0 +1,126 @@
+/* Copyright (C) 2011-2019 Free Software Foundation, Inc.
+ This file is part of gnulib.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification */
+#include <unistd.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if GNULIB_GETCWD
+/* Favor GPL getcwd.c if both getcwd and getcwd-lgpl modules are in use. */
+typedef int dummy;
+#else
+
+/* Get the name of the current working directory, and put it in SIZE
+ bytes of BUF. Returns NULL if the directory couldn't be determined
+ (perhaps because the absolute name was longer than PATH_MAX, or
+ because of missing read/search permissions on parent directories)
+ or SIZE was too small. If successful, returns BUF. If BUF is
+ NULL, an array is allocated with 'malloc'; the array is SIZE bytes
+ long, unless SIZE == 0, in which case it is as big as
+ necessary. */
+
+# undef getcwd
+char *
+rpl_getcwd (char *buf, size_t size)
+{
+ char *ptr;
+ char *result;
+
+ /* Handle single size operations. */
+ if (buf)
+ {
+ if (!size)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ return getcwd (buf, size);
+ }
+
+ if (size)
+ {
+ buf = malloc (size);
+ if (!buf)
+ {
+ errno = ENOMEM;
+ return NULL;
+ }
+ result = getcwd (buf, size);
+ if (!result)
+ {
+ int saved_errno = errno;
+ free (buf);
+ errno = saved_errno;
+ }
+ return result;
+ }
+
+ /* Flexible sizing requested. Avoid over-allocation for the common
+ case of a name that fits within a 4k page, minus some space for
+ local variables, to be sure we don't skip over a guard page. */
+ {
+ char tmp[4032];
+ size = sizeof tmp;
+ ptr = getcwd (tmp, size);
+ if (ptr)
+ {
+ result = strdup (ptr);
+ if (!result)
+ errno = ENOMEM;
+ return result;
+ }
+ if (errno != ERANGE)
+ return NULL;
+ }
+
+ /* My what a large directory name we have. */
+ do
+ {
+ size <<= 1;
+ ptr = realloc (buf, size);
+ if (ptr == NULL)
+ {
+ free (buf);
+ errno = ENOMEM;
+ return NULL;
+ }
+ buf = ptr;
+ result = getcwd (buf, size);
+ }
+ while (!result && errno == ERANGE);
+
+ if (!result)
+ {
+ int saved_errno = errno;
+ free (buf);
+ errno = saved_errno;
+ }
+ else
+ {
+ /* Trim to fit, if possible. */
+ result = realloc (buf, strlen (buf) + 1);
+ if (!result)
+ result = buf;
+ }
+ return result;
+}
+
+#endif
diff --git a/grub-core/lib/gnulib/getdelim.c b/grub-core/lib/gnulib/getdelim.c
new file mode 100644
index 0000000..528678c
--- /dev/null
+++ b/grub-core/lib/gnulib/getdelim.c
@@ -0,0 +1,147 @@
+/* getdelim.c --- Implementation of replacement getdelim function.
+ Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Ported from glibc by Simon Josefsson. */
+
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */
+#define _GL_ARG_NONNULL(params)
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <limits.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#ifndef SSIZE_MAX
+# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
+#endif
+
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+# define getc_maybe_unlocked(fp) getc(fp)
+#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
+# undef flockfile
+# undef funlockfile
+# define flockfile(x) ((void) 0)
+# define funlockfile(x) ((void) 0)
+# define getc_maybe_unlocked(fp) getc(fp)
+#else
+# define getc_maybe_unlocked(fp) getc_unlocked(fp)
+#endif
+
+static void
+alloc_failed (void)
+{
+#if defined _WIN32 && ! defined __CYGWIN__
+ /* Avoid errno problem without using the realloc module; see:
+ https://lists.gnu.org/r/bug-gnulib/2016-08/msg00025.html */
+ errno = ENOMEM;
+#endif
+}
+
+/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
+ NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
+ NULL), pointing to *N characters of space. It is realloc'ed as
+ necessary. Returns the number of characters read (not including
+ the null terminator), or -1 on error or EOF. */
+
+ssize_t
+getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
+{
+ ssize_t result;
+ size_t cur_len = 0;
+
+ if (lineptr == NULL || n == NULL || fp == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ flockfile (fp);
+
+ if (*lineptr == NULL || *n == 0)
+ {
+ char *new_lineptr;
+ *n = 120;
+ new_lineptr = (char *) realloc (*lineptr, *n);
+ if (new_lineptr == NULL)
+ {
+ alloc_failed ();
+ result = -1;
+ goto unlock_return;
+ }
+ *lineptr = new_lineptr;
+ }
+
+ for (;;)
+ {
+ int i;
+
+ i = getc_maybe_unlocked (fp);
+ if (i == EOF)
+ {
+ result = -1;
+ break;
+ }
+
+ /* Make enough space for len+1 (for final NUL) bytes. */
+ if (cur_len + 1 >= *n)
+ {
+ size_t needed_max =
+ SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
+ size_t needed = 2 * *n + 1; /* Be generous. */
+ char *new_lineptr;
+
+ if (needed_max < needed)
+ needed = needed_max;
+ if (cur_len + 1 >= needed)
+ {
+ result = -1;
+ errno = EOVERFLOW;
+ goto unlock_return;
+ }
+
+ new_lineptr = (char *) realloc (*lineptr, needed);
+ if (new_lineptr == NULL)
+ {
+ alloc_failed ();
+ result = -1;
+ goto unlock_return;
+ }
+
+ *lineptr = new_lineptr;
+ *n = needed;
+ }
+
+ (*lineptr)[cur_len] = i;
+ cur_len++;
+
+ if (i == delimiter)
+ break;
+ }
+ (*lineptr)[cur_len] = '\0';
+ result = cur_len ? cur_len : result;
+
+ unlock_return:
+ funlockfile (fp); /* doesn't set errno */
+
+ return result;
+}
diff --git a/grub-core/lib/gnulib/getdtablesize.c b/grub-core/lib/gnulib/getdtablesize.c
new file mode 100644
index 0000000..03a9243
--- /dev/null
+++ b/grub-core/lib/gnulib/getdtablesize.c
@@ -0,0 +1,124 @@
+/* getdtablesize() function: Return maximum possible file descriptor value + 1.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+#if defined _WIN32 && ! defined __CYGWIN__
+
+# include <stdio.h>
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+static int
+_setmaxstdio_nothrow (int newmax)
+{
+ int result;
+
+ TRY_MSVC_INVAL
+ {
+ result = _setmaxstdio (newmax);
+ }
+ CATCH_MSVC_INVAL
+ {
+ result = -1;
+ }
+ DONE_MSVC_INVAL;
+
+ return result;
+}
+# else
+# define _setmaxstdio_nothrow _setmaxstdio
+# endif
+
+/* Cache for the previous getdtablesize () result. Safe to cache because
+ Windows also lacks setrlimit. */
+static int dtablesize;
+
+int
+getdtablesize (void)
+{
+ if (dtablesize == 0)
+ {
+ /* We are looking for the number N such that the valid file descriptors
+ are 0..N-1. It can be obtained through a loop as follows:
+ {
+ int fd;
+ for (fd = 3; fd < 65536; fd++)
+ if (dup2 (0, fd) == -1)
+ break;
+ return fd;
+ }
+ On Windows XP, the result is 2048.
+ The drawback of this loop is that it allocates memory for a libc
+ internal array that is never freed.
+
+ The number N can also be obtained as the upper bound for
+ _getmaxstdio (). _getmaxstdio () returns the maximum number of open
+ FILE objects. The sanity check in _setmaxstdio reveals the maximum
+ number of file descriptors. This too allocates memory, but it is
+ freed when we call _setmaxstdio with the original value. */
+ int orig_max_stdio = _getmaxstdio ();
+ unsigned int bound;
+ for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2)
+ ;
+ _setmaxstdio_nothrow (orig_max_stdio);
+ dtablesize = bound;
+ }
+ return dtablesize;
+}
+
+#else
+
+# include <limits.h>
+# include <sys/resource.h>
+
+# ifndef RLIM_SAVED_CUR
+# define RLIM_SAVED_CUR RLIM_INFINITY
+# endif
+# ifndef RLIM_SAVED_MAX
+# define RLIM_SAVED_MAX RLIM_INFINITY
+# endif
+
+# ifdef __CYGWIN__
+ /* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it
+ hits the compile-time constant hard limit of 3200. We might as
+ well just report the hard limit. */
+# define rlim_cur rlim_max
+# endif
+
+int
+getdtablesize (void)
+{
+ struct rlimit lim;
+
+ if (getrlimit (RLIMIT_NOFILE, &lim) == 0
+ && 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX
+ && lim.rlim_cur != RLIM_INFINITY
+ && lim.rlim_cur != RLIM_SAVED_CUR
+ && lim.rlim_cur != RLIM_SAVED_MAX)
+ return lim.rlim_cur;
+
+ return INT_MAX;
+}
+
+#endif
diff --git a/grub-core/lib/gnulib/getline.c b/grub-core/lib/gnulib/getline.c
new file mode 100644
index 0000000..40882fb
--- /dev/null
+++ b/grub-core/lib/gnulib/getline.c
@@ -0,0 +1,27 @@
+/* getline.c --- Implementation of replacement getline function.
+ Copyright (C) 2005-2007, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Simon Josefsson. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+ssize_t
+getline (char **lineptr, size_t *n, FILE *stream)
+{
+ return getdelim (lineptr, n, '\n', stream);
+}
diff --git a/grub-core/lib/gnulib/getopt-cdefs.in.h b/grub-core/lib/gnulib/getopt-cdefs.in.h
new file mode 100644
index 0000000..049145b
--- /dev/null
+++ b/grub-core/lib/gnulib/getopt-cdefs.in.h
@@ -0,0 +1,67 @@
+/* getopt-on-non-glibc compatibility macros.
+ Copyright (C) 1989-2019 Free Software Foundation, Inc.
+ This file is part of gnulib.
+ Unlike most of the getopt implementation, it is NOT shared
+ with the GNU C Library.
+
+ 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 of
+ the License, 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.
+
+ You should have received a copy of the GNU General Public
+ License along with gnulib; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _GETOPT_CDEFS_H
+#define _GETOPT_CDEFS_H 1
+
+/* This header should not be used directly; include getopt.h or
+ unistd.h instead. It does not have a protective #error, because
+ the guard macro for getopt.h in gnulib is not fixed. */
+
+/* getopt-core.h and getopt-ext.h are shared with GNU libc, and expect
+ a number of the internal macros supplied to GNU libc's headers by
+ sys/cdefs.h. Provide fallback definitions for all of them. */
+#if @HAVE_SYS_CDEFS_H@
+# include <sys/cdefs.h>
+#endif
+
+#ifndef __BEGIN_DECLS
+# ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# else
+# define __BEGIN_DECLS /* nothing */
+# endif
+#endif
+#ifndef __END_DECLS
+# ifdef __cplusplus
+# define __END_DECLS }
+# else
+# define __END_DECLS /* nothing */
+# endif
+#endif
+
+#ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_VERSION__
+# define __GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+# else
+# define __GNUC_PREREQ(maj, min) 0
+# endif
+#endif
+
+#ifndef __THROW
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# define __THROW throw ()
+# else
+# define __THROW
+# endif
+#endif
+
+#endif /* _GETOPT_CDEFS_H */
diff --git a/grub-core/lib/gnulib/getopt-core.h b/grub-core/lib/gnulib/getopt-core.h
new file mode 100644
index 0000000..6360ad6
--- /dev/null
+++ b/grub-core/lib/gnulib/getopt-core.h
@@ -0,0 +1,96 @@
+/* Declarations for getopt (basic, portable features only).
+ Copyright (C) 1989-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library and is also part of gnulib.
+ Patches to this file should be submitted to both projects.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _GETOPT_CORE_H
+#define _GETOPT_CORE_H 1
+
+/* This header should not be used directly; include getopt.h or
+ unistd.h instead. Unlike most bits headers, it does not have
+ a protective #error, because the guard macro for getopt.h in
+ gnulib is not fixed. */
+
+__BEGIN_DECLS
+
+/* For communication from 'getopt' to the caller.
+ When 'getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when 'ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to 'getopt'.
+
+ On entry to 'getopt', zero means this is the first call; initialize.
+
+ When 'getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, 'optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message 'getopt' prints
+ for unrecognized options. */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized. */
+
+extern int optopt;
+
+/* Get definitions and prototypes for functions to process the
+ arguments in ARGV (ARGC of them, minus the program name) for
+ options given in OPTS.
+
+ Return the option character from OPTS just read. Return -1 when
+ there are no more options. For unrecognized options, or options
+ missing arguments, 'optopt' is set to the option letter, and '?' is
+ returned.
+
+ The OPTS string is a list of characters which are recognized option
+ letters, optionally followed by colons, specifying that that letter
+ takes an argument, to be placed in 'optarg'.
+
+ If a letter in OPTS is followed by two colons, its argument is
+ optional. This behavior is specific to the GNU 'getopt'.
+
+ The argument '--' causes premature termination of argument
+ scanning, explicitly telling 'getopt' that there are no more
+ options.
+
+ If OPTS begins with '-', then non-option arguments are treated as
+ arguments to the option '\1'. This behavior is specific to the GNU
+ 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
+ the environment, then do not permute arguments.
+
+ For standards compliance, the 'argv' argument has the type
+ char *const *, but this is inaccurate; if argument permutation is
+ enabled, the argv array (not the strings it points to) must be
+ writable. */
+
+extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
+ __THROW _GL_ARG_NONNULL ((2, 3));
+
+__END_DECLS
+
+#endif /* _GETOPT_CORE_H */
diff --git a/grub-core/lib/gnulib/getopt-ext.h b/grub-core/lib/gnulib/getopt-ext.h
new file mode 100644
index 0000000..13cb007
--- /dev/null
+++ b/grub-core/lib/gnulib/getopt-ext.h
@@ -0,0 +1,77 @@
+/* Declarations for getopt (GNU extensions).
+ Copyright (C) 1989-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library and is also part of gnulib.
+ Patches to this file should be submitted to both projects.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _GETOPT_EXT_H
+#define _GETOPT_EXT_H 1
+
+/* This header should not be used directly; include getopt.h instead.
+ Unlike most bits headers, it does not have a protective #error,
+ because the guard macro for getopt.h in gnulib is not fixed. */
+
+__BEGIN_DECLS
+
+/* Describe the long-named options requested by the application.
+ The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+ of 'struct option' terminated by an element containing a name which is
+ zero.
+
+ The field 'has_arg' is:
+ no_argument (or 0) if the option does not take an argument,
+ required_argument (or 1) if the option requires an argument,
+ optional_argument (or 2) if the option takes an optional argument.
+
+ If the field 'flag' is not NULL, it points to a variable that is set
+ to the value given in the field 'val' when the option is found, but
+ left unchanged if the option is not found.
+
+ To have a long-named option do something other than set an 'int' to
+ a compiled-in constant, such as set a value from 'optarg', set the
+ option's 'flag' field to zero and its 'val' field to a nonzero
+ value (the equivalent single-letter option character, if there is
+ one). For long options that have a zero 'flag' field, 'getopt'
+ returns the contents of the 'val' field. */
+
+struct option
+{
+ const char *name;
+ /* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* Names for the values of the 'has_arg' field of 'struct option'. */
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind)
+ __THROW _GL_ARG_NONNULL ((2, 3));
+extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind)
+ __THROW _GL_ARG_NONNULL ((2, 3));
+
+__END_DECLS
+
+#endif /* _GETOPT_EXT_H */
diff --git a/grub-core/lib/gnulib/getopt-pfx-core.h b/grub-core/lib/gnulib/getopt-pfx-core.h
new file mode 100644
index 0000000..8fac269
--- /dev/null
+++ b/grub-core/lib/gnulib/getopt-pfx-core.h
@@ -0,0 +1,59 @@
+/* getopt (basic, portable features) gnulib wrapper header.
+ Copyright (C) 1989-2019 Free Software Foundation, Inc.
+ This file is part of gnulib.
+ Unlike most of the getopt implementation, it is NOT shared
+ with the GNU C Library.
+
+ 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 of
+ the License, 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.
+
+ You should have received a copy of the GNU General Public
+ License along with gnulib; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _GETOPT_PFX_CORE_H
+#define _GETOPT_PFX_CORE_H 1
+
+/* This header should not be used directly; include getopt.h or
+ unistd.h instead. It does not have a protective #error, because
+ the guard macro for getopt.h in gnulib is not fixed. */
+
+/* Standalone applications should #define __GETOPT_PREFIX to an
+ identifier that prefixes the external functions and variables
+ defined in getopt-core.h and getopt-ext.h. Systematically
+ rename identifiers so that they do not collide with the system
+ functions and variables. Renaming avoids problems with some
+ compilers and linkers. */
+#ifdef __GETOPT_PREFIX
+# ifndef __GETOPT_ID
+# define __GETOPT_CONCAT(x, y) x ## y
+# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
+# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
+# endif
+# undef getopt
+# undef optarg
+# undef opterr
+# undef optind
+# undef optopt
+# define getopt __GETOPT_ID (getopt)
+# define optarg __GETOPT_ID (optarg)
+# define opterr __GETOPT_ID (opterr)
+# define optind __GETOPT_ID (optind)
+# define optopt __GETOPT_ID (optopt)
+
+/* The system's getopt.h may have already included getopt-core.h to
+ declare the unprefixed identifiers. Undef _GETOPT_CORE_H so that
+ getopt-core.h declares them with prefixes. */
+# undef _GETOPT_CORE_H
+#endif
+
+#include <getopt-core.h>
+
+#endif /* _GETOPT_PFX_CORE_H */
diff --git a/grub-core/lib/gnulib/getopt-pfx-ext.h b/grub-core/lib/gnulib/getopt-pfx-ext.h
new file mode 100644
index 0000000..0e21aef
--- /dev/null
+++ b/grub-core/lib/gnulib/getopt-pfx-ext.h
@@ -0,0 +1,71 @@
+/* getopt (GNU extensions) gnulib wrapper header.
+ Copyright (C) 1989-2019 Free Software Foundation, Inc.
+ This file is part of gnulib.
+ Unlike most of the getopt implementation, it is NOT shared
+ with the GNU C Library.
+
+ 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 of
+ the License, 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.
+
+ You should have received a copy of the GNU General Public
+ License along with gnulib; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _GETOPT_PFX_EXT_H
+#define _GETOPT_PFX_EXT_H 1
+
+/* This header should not be used directly; include getopt.h instead.
+ It does not have a protective #error, because the guard macro for
+ getopt.h in gnulib is not fixed. */
+
+/* Standalone applications should #define __GETOPT_PREFIX to an
+ identifier that prefixes the external functions and variables
+ defined in getopt-core.h and getopt-ext.h. Systematically
+ rename identifiers so that they do not collide with the system
+ functions and variables. Renaming avoids problems with some
+ compilers and linkers. */
+#ifdef __GETOPT_PREFIX
+# ifndef __GETOPT_ID
+# define __GETOPT_CONCAT(x, y) x ## y
+# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
+# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
+# endif
+# undef getopt_long
+# undef getopt_long_only
+# undef option
+# undef _getopt_internal
+# define getopt_long __GETOPT_ID (getopt_long)
+# define getopt_long_only __GETOPT_ID (getopt_long_only)
+# define option __GETOPT_ID (option)
+# define _getopt_internal __GETOPT_ID (getopt_internal)
+
+/* The system's getopt.h may have already included getopt-ext.h to
+ declare the unprefixed identifiers. Undef _GETOPT_EXT_H so that
+ getopt-ext.h declares them with prefixes. */
+# undef _GETOPT_EXT_H
+#endif
+
+/* Standalone applications get correct prototypes for getopt_long and
+ getopt_long_only; they declare "char **argv". For backward
+ compatibility with old applications, if __GETOPT_PREFIX is not
+ defined, we supply GNU-libc-compatible, but incorrect, prototypes
+ using "char *const *argv". (GNU libc is stuck with the incorrect
+ prototypes, as they are baked into older versions of LSB.) */
+#ifndef __getopt_argv_const
+# if defined __GETOPT_PREFIX
+# define __getopt_argv_const /* empty */
+# else
+# define __getopt_argv_const const
+# endif
+#endif
+
+#include <getopt-ext.h>
+
+#endif /* _GETOPT_PFX_EXT_H */
diff --git a/grub-core/lib/gnulib/getopt.c b/grub-core/lib/gnulib/getopt.c
new file mode 100644
index 0000000..8ee075a
--- /dev/null
+++ b/grub-core/lib/gnulib/getopt.c
@@ -0,0 +1,811 @@
+/* Getopt for GNU.
+ Copyright (C) 1987-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library and is also part of gnulib.
+ Patches to this file should be submitted to both projects.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+#include "getopt.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef _LIBC
+/* When used as part of glibc, error printing must be done differently
+ for standards compliance. getopt is not a cancellation point, so
+ it must not call functions that are, and it is specified by an
+ older standard than stdio locking, so it must not refer to
+ functions in the "user namespace" related to stdio locking.
+ Finally, it must use glibc's internal message translation so that
+ the messages are looked up in the proper text domain. */
+# include <libintl.h>
+# define fprintf __fxprintf_nocancel
+# define flockfile(fp) _IO_flockfile (fp)
+# define funlockfile(fp) _IO_funlockfile (fp)
+#else
+# include "gettext.h"
+# define _(msgid) gettext (msgid)
+/* When used standalone, flockfile and funlockfile might not be
+ available. */
+# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \
+ || (defined _WIN32 && ! defined __CYGWIN__))
+# define flockfile(fp) /* nop */
+# define funlockfile(fp) /* nop */
+# endif
+/* When used standalone, do not attempt to use alloca. */
+# define __libc_use_alloca(size) 0
+# undef alloca
+# define alloca(size) (abort (), (void *)0)
+#endif
+
+/* This implementation of 'getopt' has three modes for handling
+ options interspersed with non-option arguments. It can stop
+ scanning for options at the first non-option argument encountered,
+ as POSIX specifies. It can continue scanning for options after the
+ first non-option argument, but permute 'argv' as it goes so that,
+ after 'getopt' is done, all the options precede all the non-option
+ arguments and 'optind' points to the first non-option argument.
+ Or, it can report non-option arguments as if they were arguments to
+ the option character '\x01'.
+
+ The default behavior of 'getopt_long' is to permute the argument list.
+ When this implementation is used standalone, the default behavior of
+ 'getopt' is to stop at the first non-option argument, but when it is
+ used as part of GNU libc it also permutes the argument list. In both
+ cases, setting the environment variable POSIXLY_CORRECT to any value
+ disables permutation.
+
+ If the first character of the OPTSTRING argument to 'getopt' or
+ 'getopt_long' is '+', both functions will stop at the first
+ non-option argument. If it is '-', both functions will report
+ non-option arguments as arguments to the option character '\x01'. */
+
+#include "getopt_int.h"
+
+/* For communication from 'getopt' to the caller.
+ When 'getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when 'ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to 'getopt'.
+
+ On entry to 'getopt', zero means this is the first call; initialize.
+
+ When 'getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, 'optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+/* 1003.2 says this must be 1 before any call. */
+int optind = 1;
+
+/* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+ This must be initialized on some systems to avoid linking in the
+ system's own getopt implementation. */
+
+int optopt = '?';
+
+/* Keep a global copy of all internal members of getopt_data. */
+
+static struct _getopt_data getopt_data;
+
+/* Exchange two adjacent subsequences of ARGV.
+ One subsequence is elements [first_nonopt,last_nonopt)
+ which contains all the non-options that have been skipped so far.
+ The other is elements [last_nonopt,optind), which contains all
+ the options processed since those non-options were skipped.
+
+ 'first_nonopt' and 'last_nonopt' are relocated so that they describe
+ the new indices of the non-options in ARGV after they are moved. */
+
+static void
+exchange (char **argv, struct _getopt_data *d)
+{
+ int bottom = d->__first_nonopt;
+ int middle = d->__last_nonopt;
+ int top = d->optind;
+ char *tem;
+
+ /* Exchange the shorter segment with the far end of the longer segment.
+ That puts the shorter segment into the right place.
+ It leaves the longer segment in the right place overall,
+ but it consists of two parts that need to be swapped next. */
+
+ while (top > middle && middle > bottom)
+ {
+ if (top - middle > middle - bottom)
+ {
+ /* Bottom segment is the short one. */
+ int len = middle - bottom;
+ int i;
+
+ /* Swap it with the top part of the top segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[top - (middle - bottom) + i];
+ argv[top - (middle - bottom) + i] = tem;
+ }
+ /* Exclude the moved bottom segment from further swapping. */
+ top -= len;
+ }
+ else
+ {
+ /* Top segment is the short one. */
+ int len = top - middle;
+ int i;
+
+ /* Swap it with the bottom part of the bottom segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ }
+ /* Exclude the moved top segment from further swapping. */
+ bottom += len;
+ }
+ }
+
+ /* Update records for the slots the non-options now occupy. */
+
+ d->__first_nonopt += (d->optind - d->__last_nonopt);
+ d->__last_nonopt = d->optind;
+}
+
+/* Process the argument starting with d->__nextchar as a long option.
+ d->optind should *not* have been advanced over this argument.
+
+ If the value returned is -1, it was not actually a long option, the
+ state is unchanged, and the argument should be processed as a set
+ of short options (this can only happen when long_only is true).
+ Otherwise, the option (and its argument, if any) have been consumed
+ and the return value is the value to return from _getopt_internal_r. */
+static int
+process_long_option (int argc, char **argv, const char *optstring,
+ const struct option *longopts, int *longind,
+ int long_only, struct _getopt_data *d,
+ int print_errors, const char *prefix)
+{
+ char *nameend;
+ size_t namelen;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int n_options;
+ int option_index;
+
+ for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
+ /* Do nothing. */ ;
+ namelen = nameend - d->__nextchar;
+
+ /* First look for an exact match, counting the options as a side
+ effect. */
+ for (p = longopts, n_options = 0; p->name; p++, n_options++)
+ if (!strncmp (p->name, d->__nextchar, namelen)
+ && namelen == strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ option_index = n_options;
+ break;
+ }
+
+ if (pfound == NULL)
+ {
+ /* Didn't find an exact match, so look for abbreviations. */
+ unsigned char *ambig_set = NULL;
+ int ambig_malloced = 0;
+ int ambig_fallback = 0;
+ int indfound = -1;
+
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (!strncmp (p->name, d->__nextchar, namelen))
+ {
+ if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else if (long_only
+ || pfound->has_arg != p->has_arg
+ || pfound->flag != p->flag
+ || pfound->val != p->val)
+ {
+ /* Second or later nonexact match found. */
+ if (!ambig_fallback)
+ {
+ if (!print_errors)
+ /* Don't waste effort tracking the ambig set if
+ we're not going to print it anyway. */
+ ambig_fallback = 1;
+ else if (!ambig_set)
+ {
+ if (__libc_use_alloca (n_options))
+ ambig_set = alloca (n_options);
+ else if ((ambig_set = malloc (n_options)) == NULL)
+ /* Fall back to simpler error message. */
+ ambig_fallback = 1;
+ else
+ ambig_malloced = 1;
+
+ if (ambig_set)
+ {
+ memset (ambig_set, 0, n_options);
+ ambig_set[indfound] = 1;
+ }
+ }
+ if (ambig_set)
+ ambig_set[option_index] = 1;
+ }
+ }
+ }
+
+ if (ambig_set || ambig_fallback)
+ {
+ if (print_errors)
+ {
+ if (ambig_fallback)
+ fprintf (stderr, _("%s: option '%s%s' is ambiguous\n"),
+ argv[0], prefix, d->__nextchar);
+ else
+ {
+ flockfile (stderr);
+ fprintf (stderr,
+ _("%s: option '%s%s' is ambiguous; possibilities:"),
+ argv[0], prefix, d->__nextchar);
+
+ for (option_index = 0; option_index < n_options; option_index++)
+ if (ambig_set[option_index])
+ fprintf (stderr, " '%s%s'",
+ prefix, longopts[option_index].name);
+
+ /* This must use 'fprintf' even though it's only
+ printing a single character, so that it goes through
+ __fxprintf_nocancel when compiled as part of glibc. */
+ fprintf (stderr, "\n");
+ funlockfile (stderr);
+ }
+ }
+ if (ambig_malloced)
+ free (ambig_set);
+ d->__nextchar += strlen (d->__nextchar);
+ d->optind++;
+ d->optopt = 0;
+ return '?';
+ }
+
+ option_index = indfound;
+ }
+
+ if (pfound == NULL)
+ {
+ /* Can't find it as a long option. If this is not getopt_long_only,
+ or the option starts with '--' or is not a valid short option,
+ then it's an error. */
+ if (!long_only || argv[d->optind][1] == '-'
+ || strchr (optstring, *d->__nextchar) == NULL)
+ {
+ if (print_errors)
+ fprintf (stderr, _("%s: unrecognized option '%s%s'\n"),
+ argv[0], prefix, d->__nextchar);
+
+ d->__nextchar = NULL;
+ d->optind++;
+ d->optopt = 0;
+ return '?';
+ }
+
+ /* Otherwise interpret it as a short option. */
+ return -1;
+ }
+
+ /* We have found a matching long option. Consume it. */
+ d->optind++;
+ d->__nextchar = NULL;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ d->optarg = nameend + 1;
+ else
+ {
+ if (print_errors)
+ fprintf (stderr,
+ _("%s: option '%s%s' doesn't allow an argument\n"),
+ argv[0], prefix, pfound->name);
+
+ d->optopt = pfound->val;
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (d->optind < argc)
+ d->optarg = argv[d->optind++];
+ else
+ {
+ if (print_errors)
+ fprintf (stderr,
+ _("%s: option '%s%s' requires an argument\n"),
+ argv[0], prefix, pfound->name);
+
+ d->optopt = pfound->val;
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+}
+
+/* Initialize internal data upon the first call to getopt. */
+
+static const char *
+_getopt_initialize (int argc _GL_UNUSED,
+ char **argv _GL_UNUSED, const char *optstring,
+ struct _getopt_data *d, int posixly_correct)
+{
+ /* Start processing options with ARGV-element 1 (since ARGV-element 0
+ is the program name); the sequence of previously skipped
+ non-option ARGV-elements is empty. */
+ if (d->optind == 0)
+ d->optind = 1;
+
+ d->__first_nonopt = d->__last_nonopt = d->optind;
+ d->__nextchar = NULL;
+
+ /* Determine how to handle the ordering of options and nonoptions. */
+ if (optstring[0] == '-')
+ {
+ d->__ordering = RETURN_IN_ORDER;
+ ++optstring;
+ }
+ else if (optstring[0] == '+')
+ {
+ d->__ordering = REQUIRE_ORDER;
+ ++optstring;
+ }
+ else if (posixly_correct || !!getenv ("POSIXLY_CORRECT"))
+ d->__ordering = REQUIRE_ORDER;
+ else
+ d->__ordering = PERMUTE;
+
+ d->__initialized = 1;
+ return optstring;
+}
+
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+ given in OPTSTRING.
+
+ If an element of ARGV starts with '-', and is not exactly "-" or "--",
+ then it is an option element. The characters of this element
+ (aside from the initial '-') are option characters. If 'getopt'
+ is called repeatedly, it returns successively each of the option characters
+ from each of the option elements.
+
+ If 'getopt' finds another option character, it returns that character,
+ updating 'optind' and 'nextchar' so that the next call to 'getopt' can
+ resume the scan with the following option character or ARGV-element.
+
+ If there are no more option characters, 'getopt' returns -1.
+ Then 'optind' is the index in ARGV of the first ARGV-element
+ that is not an option. (The ARGV-elements have been permuted
+ so that those that are not options now come last.)
+
+ OPTSTRING is a string containing the legitimate option characters.
+ If an option character is seen that is not listed in OPTSTRING,
+ return '?' after printing an error message. If you set 'opterr' to
+ zero, the error message is suppressed but we still return '?'.
+
+ If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+ so the following text in the same ARGV-element, or the text of the following
+ ARGV-element, is returned in 'optarg'. Two colons mean an option that
+ wants an optional arg; if there is text in the current ARGV-element,
+ it is returned in 'optarg', otherwise 'optarg' is set to zero.
+
+ If OPTSTRING starts with '-' or '+', it requests different methods of
+ handling the non-option ARGV-elements.
+ See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
+ Long-named options begin with '--' instead of '-'.
+ Their names may be abbreviated as long as the abbreviation is unique
+ or is an exact match for some defined option. If they have an
+ argument, it follows the option name in the same ARGV-element, separated
+ from the option name by a '=', or else the in next ARGV-element.
+ When 'getopt' finds a long-named option, it returns 0 if that option's
+ 'flag' field is nonzero, the value of the option's 'val' field
+ if the 'flag' field is zero.
+
+ The elements of ARGV aren't really const, because we permute them.
+ But we pretend they're const in the prototype to be compatible
+ with other systems.
+
+ LONGOPTS is a vector of 'struct option' terminated by an
+ element containing a name which is zero.
+
+ LONGIND returns the index in LONGOPT of the long-named option found.
+ It is only valid when a long-named option has been found by the most
+ recent call.
+
+ If LONG_ONLY is nonzero, '-' as well as '--' can introduce
+ long-named options. */
+
+int
+_getopt_internal_r (int argc, char **argv, const char *optstring,
+ const struct option *longopts, int *longind,
+ int long_only, struct _getopt_data *d, int posixly_correct)
+{
+ int print_errors = d->opterr;
+
+ if (argc < 1)
+ return -1;
+
+ d->optarg = NULL;
+
+ if (d->optind == 0 || !d->__initialized)
+ optstring = _getopt_initialize (argc, argv, optstring, d, posixly_correct);
+ else if (optstring[0] == '-' || optstring[0] == '+')
+ optstring++;
+
+ if (optstring[0] == ':')
+ print_errors = 0;
+
+ /* Test whether ARGV[optind] points to a non-option argument. */
+#define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
+
+ if (d->__nextchar == NULL || *d->__nextchar == '\0')
+ {
+ /* Advance to the next ARGV-element. */
+
+ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+ moved back by the user (who may also have changed the arguments). */
+ if (d->__last_nonopt > d->optind)
+ d->__last_nonopt = d->optind;
+ if (d->__first_nonopt > d->optind)
+ d->__first_nonopt = d->optind;
+
+ if (d->__ordering == PERMUTE)
+ {
+ /* If we have just processed some options following some non-options,
+ exchange them so that the options come first. */
+
+ if (d->__first_nonopt != d->__last_nonopt
+ && d->__last_nonopt != d->optind)
+ exchange (argv, d);
+ else if (d->__last_nonopt != d->optind)
+ d->__first_nonopt = d->optind;
+
+ /* Skip any additional non-options
+ and extend the range of non-options previously skipped. */
+
+ while (d->optind < argc && NONOPTION_P)
+ d->optind++;
+ d->__last_nonopt = d->optind;
+ }
+
+ /* The special ARGV-element '--' means premature end of options.
+ Skip it like a null option,
+ then exchange with previous non-options as if it were an option,
+ then skip everything else like a non-option. */
+
+ if (d->optind != argc && !strcmp (argv[d->optind], "--"))
+ {
+ d->optind++;
+
+ if (d->__first_nonopt != d->__last_nonopt
+ && d->__last_nonopt != d->optind)
+ exchange (argv, d);
+ else if (d->__first_nonopt == d->__last_nonopt)
+ d->__first_nonopt = d->optind;
+ d->__last_nonopt = argc;
+
+ d->optind = argc;
+ }
+
+ /* If we have done all the ARGV-elements, stop the scan
+ and back over any non-options that we skipped and permuted. */
+
+ if (d->optind == argc)
+ {
+ /* Set the next-arg-index to point at the non-options
+ that we previously skipped, so the caller will digest them. */
+ if (d->__first_nonopt != d->__last_nonopt)
+ d->optind = d->__first_nonopt;
+ return -1;
+ }
+
+ /* If we have come to a non-option and did not permute it,
+ either stop the scan or describe it to the caller and pass it by. */
+
+ if (NONOPTION_P)
+ {
+ if (d->__ordering == REQUIRE_ORDER)
+ return -1;
+ d->optarg = argv[d->optind++];
+ return 1;
+ }
+
+ /* We have found another option-ARGV-element.
+ Check whether it might be a long option. */
+ if (longopts)
+ {
+ if (argv[d->optind][1] == '-')
+ {
+ /* "--foo" is always a long option. The special option
+ "--" was handled above. */
+ d->__nextchar = argv[d->optind] + 2;
+ return process_long_option (argc, argv, optstring, longopts,
+ longind, long_only, d,
+ print_errors, "--");
+ }
+
+ /* If long_only and the ARGV-element has the form "-f",
+ where f is a valid short option, don't consider it an
+ abbreviated form of a long option that starts with f.
+ Otherwise there would be no way to give the -f short
+ option.
+
+ On the other hand, if there's a long option "fubar" and
+ the ARGV-element is "-fu", do consider that an
+ abbreviation of the long option, just like "--fu", and
+ not "-f" with arg "u".
+
+ This distinction seems to be the most useful approach. */
+ if (long_only && (argv[d->optind][2]
+ || !strchr (optstring, argv[d->optind][1])))
+ {
+ int code;
+ d->__nextchar = argv[d->optind] + 1;
+ code = process_long_option (argc, argv, optstring, longopts,
+ longind, long_only, d,
+ print_errors, "-");
+ if (code != -1)
+ return code;
+ }
+ }
+
+ /* It is not a long option. Skip the initial punctuation. */
+ d->__nextchar = argv[d->optind] + 1;
+ }
+
+ /* Look at and handle the next short option-character. */
+
+ {
+ char c = *d->__nextchar++;
+ const char *temp = strchr (optstring, c);
+
+ /* Increment 'optind' when we start to process its last character. */
+ if (*d->__nextchar == '\0')
+ ++d->optind;
+
+ if (temp == NULL || c == ':' || c == ';')
+ {
+ if (print_errors)
+ fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
+ d->optopt = c;
+ return '?';
+ }
+
+ /* Convenience. Treat POSIX -W foo same as long option --foo */
+ if (temp[0] == 'W' && temp[1] == ';' && longopts != NULL)
+ {
+ /* This is an option that requires an argument. */
+ if (*d->__nextchar != '\0')
+ d->optarg = d->__nextchar;
+ else if (d->optind == argc)
+ {
+ if (print_errors)
+ fprintf (stderr,
+ _("%s: option requires an argument -- '%c'\n"),
+ argv[0], c);
+
+ d->optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ return c;
+ }
+ else
+ d->optarg = argv[d->optind];
+
+ d->__nextchar = d->optarg;
+ d->optarg = NULL;
+ return process_long_option (argc, argv, optstring, longopts, longind,
+ 0 /* long_only */, d, print_errors, "-W ");
+ }
+ if (temp[1] == ':')
+ {
+ if (temp[2] == ':')
+ {
+ /* This is an option that accepts an argument optionally. */
+ if (*d->__nextchar != '\0')
+ {
+ d->optarg = d->__nextchar;
+ d->optind++;
+ }
+ else
+ d->optarg = NULL;
+ d->__nextchar = NULL;
+ }
+ else
+ {
+ /* This is an option that requires an argument. */
+ if (*d->__nextchar != '\0')
+ {
+ d->optarg = d->__nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ d->optind++;
+ }
+ else if (d->optind == argc)
+ {
+ if (print_errors)
+ fprintf (stderr,
+ _("%s: option requires an argument -- '%c'\n"),
+ argv[0], c);
+
+ d->optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ }
+ else
+ /* We already incremented 'optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ d->optarg = argv[d->optind++];
+ d->__nextchar = NULL;
+ }
+ }
+ return c;
+ }
+}
+
+int
+_getopt_internal (int argc, char **argv, const char *optstring,
+ const struct option *longopts, int *longind, int long_only,
+ int posixly_correct)
+{
+ int result;
+
+ getopt_data.optind = optind;
+ getopt_data.opterr = opterr;
+
+ result = _getopt_internal_r (argc, argv, optstring, longopts,
+ longind, long_only, &getopt_data,
+ posixly_correct);
+
+ optind = getopt_data.optind;
+ optarg = getopt_data.optarg;
+ optopt = getopt_data.optopt;
+
+ return result;
+}
+
+/* glibc gets a LSB-compliant getopt and a POSIX-complaint __posix_getopt.
+ Standalone applications just get a POSIX-compliant getopt.
+ POSIX and LSB both require these functions to take 'char *const *argv'
+ even though this is incorrect (because of the permutation). */
+#define GETOPT_ENTRY(NAME, POSIXLY_CORRECT) \
+ int \
+ NAME (int argc, char *const *argv, const char *optstring) \
+ { \
+ return _getopt_internal (argc, (char **)argv, optstring, \
+ 0, 0, 0, POSIXLY_CORRECT); \
+ }
+
+#ifdef _LIBC
+GETOPT_ENTRY(getopt, 0)
+GETOPT_ENTRY(__posix_getopt, 1)
+#else
+GETOPT_ENTRY(getopt, 1)
+#endif
+
+
+#ifdef TEST
+
+/* Compile with -DTEST to make an executable for use in testing
+ the above definition of 'getopt'. */
+
+int
+main (int argc, char **argv)
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+
+ c = getopt (argc, argv, "abc:d:0123456789");
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value '%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
diff --git a/grub-core/lib/gnulib/getopt.in.h b/grub-core/lib/gnulib/getopt.in.h
new file mode 100644
index 0000000..c77f34c
--- /dev/null
+++ b/grub-core/lib/gnulib/getopt.in.h
@@ -0,0 +1,61 @@
+/* Declarations for getopt.
+ Copyright (C) 1989-2019 Free Software Foundation, Inc.
+ This file is part of gnulib.
+ Unlike most of the getopt implementation, it is NOT shared
+ with the GNU C Library, which supplies a different version of
+ this file.
+
+ 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 of
+ the License, 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.
+
+ You should have received a copy of the GNU General Public
+ License along with gnulib; if not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_GETOPT_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. We must
+ also inform the replacement unistd.h to not recursively use
+ <getopt.h>; our definitions will be present soon enough. */
+#if @HAVE_GETOPT_H@
+# define _GL_SYSTEM_GETOPT
+# @INCLUDE_NEXT@ @NEXT_GETOPT_H@
+# undef _GL_SYSTEM_GETOPT
+#endif
+
+#define _@GUARD_PREFIX@_GETOPT_H 1
+
+/* Standalone applications should #define __GETOPT_PREFIX to an
+ identifier that prefixes the external functions and variables
+ defined in getopt-core.h and getopt-ext.h. When this happens,
+ include the headers that might declare getopt so that they will not
+ cause confusion if included after this file (if the system had
+ <getopt.h>, we have already included it). */
+#if defined __GETOPT_PREFIX
+# if !@HAVE_GETOPT_H@
+# define __need_system_stdlib_h
+# include <stdlib.h>
+# undef __need_system_stdlib_h
+# include <stdio.h>
+# include <unistd.h>
+# endif
+#endif
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+#include <getopt-cdefs.h>
+#include <getopt-pfx-core.h>
+#include <getopt-pfx-ext.h>
+
+#endif /* _@GUARD_PREFIX@_GETOPT_H */
diff --git a/grub-core/lib/gnulib/getopt1.c b/grub-core/lib/gnulib/getopt1.c
new file mode 100644
index 0000000..883aa6b
--- /dev/null
+++ b/grub-core/lib/gnulib/getopt1.c
@@ -0,0 +1,159 @@
+/* getopt_long and getopt_long_only entry points for GNU getopt.
+ Copyright (C) 1987-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library and is also part of gnulib.
+ Patches to this file should be submitted to both projects.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+#include "getopt.h"
+#include "getopt_int.h"
+
+int
+getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
+ const struct option *long_options, int *opt_index)
+{
+ return _getopt_internal (argc, (char **) argv, options, long_options,
+ opt_index, 0, 0);
+}
+
+int
+_getopt_long_r (int argc, char **argv, const char *options,
+ const struct option *long_options, int *opt_index,
+ struct _getopt_data *d)
+{
+ return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+ 0, d, 0);
+}
+
+/* Like getopt_long, but '-' as well as '--' can indicate a long option.
+ If an option that starts with '-' (not '--') doesn't match a long option,
+ but does match a short option, it is parsed as a short option
+ instead. */
+
+int
+getopt_long_only (int argc, char *__getopt_argv_const *argv,
+ const char *options,
+ const struct option *long_options, int *opt_index)
+{
+ return _getopt_internal (argc, (char **) argv, options, long_options,
+ opt_index, 1, 0);
+}
+
+int
+_getopt_long_only_r (int argc, char **argv, const char *options,
+ const struct option *long_options, int *opt_index,
+ struct _getopt_data *d)
+{
+ return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+ 1, d, 0);
+}
+
+
+#ifdef TEST
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (int argc, char **argv)
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+ int option_index = 0;
+ static const struct option long_options[] =
+ {
+ {"add", 1, 0, 0},
+ {"append", 0, 0, 0},
+ {"delete", 1, 0, 0},
+ {"verbose", 0, 0, 0},
+ {"create", 0, 0, 0},
+ {"file", 1, 0, 0},
+ {0, 0, 0, 0}
+ };
+
+ c = getopt_long (argc, argv, "abc:d:0123456789",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case 0:
+ printf ("option %s", long_options[option_index].name);
+ if (optarg)
+ printf (" with arg %s", optarg);
+ printf ("\n");
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value '%s'\n", optarg);
+ break;
+
+ case 'd':
+ printf ("option d with value '%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
diff --git a/grub-core/lib/gnulib/getopt_int.h b/grub-core/lib/gnulib/getopt_int.h
new file mode 100644
index 0000000..e63706f
--- /dev/null
+++ b/grub-core/lib/gnulib/getopt_int.h
@@ -0,0 +1,118 @@
+/* Internal declarations for getopt.
+ Copyright (C) 1989-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library and is also part of gnulib.
+ Patches to this file should be submitted to both projects.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _GETOPT_INT_H
+#define _GETOPT_INT_H 1
+
+#include <getopt.h>
+
+extern int _getopt_internal (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ int __long_only, int __posixly_correct);
+
+
+/* Reentrant versions which can handle parsing multiple argument
+ vectors at the same time. */
+
+/* Describe how to deal with options that follow non-option ARGV-elements.
+
+ REQUIRE_ORDER means don't recognize them as options; stop option
+ processing when the first non-option is seen. This is what POSIX
+ specifies should happen.
+
+ PERMUTE means permute the contents of ARGV as we scan, so that
+ eventually all the non-options are at the end. This allows options
+ to be given in any order, even with programs that were not written
+ to expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were
+ written to expect options and other ARGV-elements in any order
+ and that care about the ordering of the two. We describe each
+ non-option ARGV-element as if it were the argument of an option
+ with character code 1.
+
+ The special argument '--' forces an end of option-scanning regardless
+ of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
+ '--' can cause 'getopt' to return -1 with 'optind' != ARGC. */
+
+enum __ord
+ {
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+ };
+
+/* Data type for reentrant functions. */
+struct _getopt_data
+{
+ /* These have exactly the same meaning as the corresponding global
+ variables, except that they are used for the reentrant
+ versions of getopt. */
+ int optind;
+ int opterr;
+ int optopt;
+ char *optarg;
+
+ /* Internal members. */
+
+ /* True if the internal members have been initialized. */
+ int __initialized;
+
+ /* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+ char *__nextchar;
+
+ /* See __ord above. */
+ enum __ord __ordering;
+
+ /* Handle permutation of arguments. */
+
+ /* Describe the part of ARGV that contains non-options that have
+ been skipped. 'first_nonopt' is the index in ARGV of the first
+ of them; 'last_nonopt' is the index after the last of them. */
+
+ int __first_nonopt;
+ int __last_nonopt;
+};
+
+/* The initializer is necessary to set OPTIND and OPTERR to their
+ default values and to clear the initialization flag. */
+#define _GETOPT_DATA_INITIALIZER { 1, 1 }
+
+extern int _getopt_internal_r (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ int __long_only, struct _getopt_data *__data,
+ int __posixly_correct);
+
+extern int _getopt_long_r (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ struct _getopt_data *__data);
+
+extern int _getopt_long_only_r (int ___argc, char **___argv,
+ const char *__shortopts,
+ const struct option *__longopts,
+ int *__longind,
+ struct _getopt_data *__data);
+
+#endif /* getopt_int.h */
diff --git a/grub-core/lib/gnulib/getprogname.c b/grub-core/lib/gnulib/getprogname.c
new file mode 100644
index 0000000..96fa759
--- /dev/null
+++ b/grub-core/lib/gnulib/getprogname.c
@@ -0,0 +1,255 @@
+/* Program name management.
+ Copyright (C) 2016-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "getprogname.h"
+
+#include <errno.h> /* get program_invocation_name declaration */
+#include <stdlib.h> /* get __argv declaration */
+
+#ifdef _AIX
+# include <unistd.h>
+# include <procinfo.h>
+# include <string.h>
+#endif
+
+#ifdef __MVS__
+# ifndef _OPEN_SYS
+# define _OPEN_SYS
+# endif
+# include <string.h>
+# include <sys/ps.h>
+#endif
+
+#ifdef __hpux
+# include <unistd.h>
+# include <sys/param.h>
+# include <sys/pstat.h>
+# include <string.h>
+#endif
+
+#ifdef __sgi
+# include <string.h>
+# include <unistd.h>
+# include <stdio.h>
+# include <fcntl.h>
+# include <sys/procfs.h>
+#endif
+
+#include "dirname.h"
+
+#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */
+char const *
+getprogname (void)
+{
+# if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME /* glibc, BeOS */
+ /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
+ return program_invocation_short_name;
+# elif HAVE_DECL_PROGRAM_INVOCATION_NAME /* glibc, BeOS */
+ /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
+ return last_component (program_invocation_name);
+# elif HAVE_GETEXECNAME /* Solaris */
+ /* https://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hrb1/index.html */
+ const char *p = getexecname ();
+ if (!p)
+ p = "?";
+ return last_component (p);
+# elif HAVE_DECL___ARGV /* mingw, MSVC */
+ /* https://msdn.microsoft.com/en-us/library/dn727674.aspx */
+ const char *p = __argv && __argv[0] ? __argv[0] : "?";
+ return last_component (p);
+# elif HAVE_VAR___PROGNAME /* OpenBSD, QNX */
+ /* https://man.openbsd.org/style.9 */
+ /* http://www.qnx.de/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fp%2F__progname.html */
+ /* Be careful to declare this only when we absolutely need it
+ (OpenBSD 5.1), rather than when it's available. Otherwise,
+ its mere declaration makes program_invocation_short_name
+ malfunction (have zero length) with Fedora 25's glibc. */
+ extern char *__progname;
+ const char *p = __progname;
+ return p && p[0] ? p : "?";
+# elif _AIX /* AIX */
+ /* Idea by Bastien ROUCARIÈS,
+ https://lists.gnu.org/r/bug-gnulib/2010-12/msg00095.html
+ Reference: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.basetrf1/getprocs.htm
+ */
+ static char *p;
+ static int first = 1;
+ if (first)
+ {
+ first = 0;
+ pid_t pid = getpid ();
+ struct procentry64 procs;
+ p = (0 < getprocs64 (&procs, sizeof procs, NULL, 0, &pid, 1)
+ ? strdup (procs.pi_comm)
+ : NULL);
+ if (!p)
+ p = "?";
+ }
+ return p;
+# elif defined __hpux
+ static char *p;
+ static int first = 1;
+ if (first)
+ {
+ first = 0;
+ pid_t pid = getpid ();
+ struct pst_status status;
+ if (pstat_getproc (&status, sizeof status, 0, pid) > 0)
+ {
+ char *ucomm = status.pst_ucomm;
+ char *cmd = status.pst_cmd;
+ if (strlen (ucomm) < PST_UCOMMLEN - 1)
+ p = ucomm;
+ else
+ {
+ /* ucomm is truncated to length PST_UCOMMLEN - 1.
+ Look at cmd instead. */
+ char *space = strchr (cmd, ' ');
+ if (space != NULL)
+ *space = '\0';
+ p = strrchr (cmd, '/');
+ if (p != NULL)
+ p++;
+ else
+ p = cmd;
+ if (strlen (p) > PST_UCOMMLEN - 1
+ && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
+ /* p is less truncated than ucomm. */
+ ;
+ else
+ p = ucomm;
+ }
+ p = strdup (p);
+ }
+ else
+ {
+# if !defined __LP64__
+ /* Support for 32-bit programs running in 64-bit HP-UX.
+ The documented way to do this is to use the same source code
+ as above, but in a compilation unit where '#define _PSTAT64 1'
+ is in effect. I prefer a single compilation unit; the struct
+ size and the offsets are not going to change. */
+ char status64[1216];
+ if (__pstat_getproc64 (status64, sizeof status64, 0, pid) > 0)
+ {
+ char *ucomm = status64 + 288;
+ char *cmd = status64 + 168;
+ if (strlen (ucomm) < PST_UCOMMLEN - 1)
+ p = ucomm;
+ else
+ {
+ /* ucomm is truncated to length PST_UCOMMLEN - 1.
+ Look at cmd instead. */
+ char *space = strchr (cmd, ' ');
+ if (space != NULL)
+ *space = '\0';
+ p = strrchr (cmd, '/');
+ if (p != NULL)
+ p++;
+ else
+ p = cmd;
+ if (strlen (p) > PST_UCOMMLEN - 1
+ && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
+ /* p is less truncated than ucomm. */
+ ;
+ else
+ p = ucomm;
+ }
+ p = strdup (p);
+ }
+ else
+# endif
+ p = NULL;
+ }
+ if (!p)
+ p = "?";
+ }
+ return p;
+# elif __MVS__ /* z/OS */
+ /* https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/rtwgetp.htm */
+ static char *p = "?";
+ static int first = 1;
+ if (first)
+ {
+ pid_t pid = getpid ();
+ int token;
+ W_PSPROC buf;
+ first = 0;
+ memset (&buf, 0, sizeof(buf));
+ buf.ps_cmdptr = (char *) malloc (buf.ps_cmdlen = PS_CMDBLEN_LONG);
+ buf.ps_conttyptr = (char *) malloc (buf.ps_conttylen = PS_CONTTYBLEN);
+ buf.ps_pathptr = (char *) malloc (buf.ps_pathlen = PS_PATHBLEN);
+ if (buf.ps_cmdptr && buf.ps_conttyptr && buf.ps_pathptr)
+ {
+ for (token = 0; token >= 0;
+ token = w_getpsent (token, &buf, sizeof(buf)))
+ {
+ if (token > 0 && buf.ps_pid == pid)
+ {
+ char *s = strdup (last_component (buf.ps_pathptr));
+ if (s)
+ p = s;
+ break;
+ }
+ }
+ }
+ free (buf.ps_cmdptr);
+ free (buf.ps_conttyptr);
+ free (buf.ps_pathptr);
+ }
+ return p;
+# elif defined __sgi /* IRIX */
+ char filename[50];
+ int fd;
+
+ sprintf (filename, "/proc/pinfo/%d", (int) getpid ());
+ fd = open (filename, O_RDONLY);
+ if (0 <= fd)
+ {
+ prpsinfo_t buf;
+ int ioctl_ok = 0 <= ioctl (fd, PIOCPSINFO, &buf);
+ close (fd);
+ if (ioctl_ok)
+ {
+ char *name = buf.pr_fname;
+ size_t namesize = sizeof buf.pr_fname;
+ char *namenul = memchr (name, '\0', namesize);
+ size_t namelen = namenul ? namenul - name : namesize;
+ char *namecopy = malloc (namelen + 1);
+ if (namecopy)
+ {
+ namecopy[namelen] = 0;
+ return memcpy (namecopy, name, namelen);
+ }
+ }
+ }
+ return NULL;
+# else
+# error "getprogname module not ported to this OS"
+# endif
+}
+
+#endif
+
+/*
+ * Hey Emacs!
+ * Local Variables:
+ * coding: utf-8
+ * End:
+ */
diff --git a/grub-core/lib/gnulib/getprogname.h b/grub-core/lib/gnulib/getprogname.h
new file mode 100644
index 0000000..1590b38
--- /dev/null
+++ b/grub-core/lib/gnulib/getprogname.h
@@ -0,0 +1,40 @@
+/* Program name management.
+ Copyright (C) 2016-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_GETPROGNAME_H
+#define _GL_GETPROGNAME_H
+
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Return the base name of the executing program.
+ On native Windows this will usually end in ".exe" or ".EXE". */
+#ifndef HAVE_GETPROGNAME
+extern char const *getprogname (void)
+# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
+ _GL_ATTRIBUTE_PURE
+# endif
+ ;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/grub-core/lib/gnulib/gettext.h b/grub-core/lib/gnulib/gettext.h
new file mode 100644
index 0000000..89f53d9
--- /dev/null
+++ b/grub-core/lib/gnulib/gettext.h
@@ -0,0 +1,294 @@
+/* Convenience header for conditional use of GNU <libintl.h>.
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option
+ or through "#define ENABLE NLS 0" before including this file. */
+#if defined ENABLE_NLS && ENABLE_NLS
+
+/* Get declarations of GNU message catalog functions. */
+# include <libintl.h>
+
+/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
+ the gettext() and ngettext() macros. This is an alternative to calling
+ textdomain(), and is useful for libraries. */
+# ifdef DEFAULT_TEXT_DOMAIN
+# undef gettext
+# define gettext(Msgid) \
+ dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+ dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
+# endif
+
+#else
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+ chokes if dcgettext is defined as a macro. So include it now, to make
+ later inclusions of <locale.h> a NOP. We don't include <libintl.h>
+ as well because people using "gettext.h" will not include <libintl.h>,
+ and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+ is OK. */
+#if defined(__sun)
+# include <locale.h>
+#endif
+
+/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
+ <libintl.h>, which chokes if dcgettext is defined as a macro. So include
+ it now, to make later inclusions of <libintl.h> a NOP. */
+#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
+# include <cstdlib>
+# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
+# include <libintl.h>
+# endif
+#endif
+
+/* Disabled NLS.
+ The casts to 'const char *' serve the purpose of producing warnings
+ for invalid uses of the value returned from these functions.
+ On pre-ANSI systems without 'const', the config.h file is supposed to
+ contain "#define const". */
+# undef gettext
+# define gettext(Msgid) ((const char *) (Msgid))
+# undef dgettext
+# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
+# undef dcgettext
+# define dcgettext(Domainname, Msgid, Category) \
+ ((void) (Category), dgettext (Domainname, Msgid))
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+ ((N) == 1 \
+ ? ((void) (Msgid2), (const char *) (Msgid1)) \
+ : ((void) (Msgid1), (const char *) (Msgid2)))
+# undef dngettext
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+ ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
+# undef dcngettext
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+ ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
+# undef textdomain
+# define textdomain(Domainname) ((const char *) (Domainname))
+# undef bindtextdomain
+# define bindtextdomain(Domainname, Dirname) \
+ ((void) (Domainname), (const char *) (Dirname))
+# undef bind_textdomain_codeset
+# define bind_textdomain_codeset(Domainname, Codeset) \
+ ((void) (Domainname), (const char *) (Codeset))
+
+#endif
+
+/* Prefer gnulib's setlocale override over libintl's setlocale override. */
+#ifdef GNULIB_defined_setlocale
+# undef setlocale
+# define setlocale rpl_setlocale
+#endif
+
+/* A pseudo function call that serves as a marker for the automated
+ extraction of messages, but does not call gettext(). The run-time
+ translation is done at a different place in the code.
+ The argument, String, should be a literal string. Concatenated strings
+ and other string expressions won't work.
+ The macro's expansion is not parenthesized, so that it is suitable as
+ initializer for static 'char[]' or 'const char[]' variables. */
+#define gettext_noop(String) String
+
+/* The separator between msgctxt and msgid in a .mo file. */
+#define GETTEXT_CONTEXT_GLUE "\004"
+
+/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
+ MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
+ short and rarely need to change.
+ The letter 'p' stands for 'particular' or 'special'. */
+#ifdef DEFAULT_TEXT_DOMAIN
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#else
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#endif
+#define dpgettext(Domainname, Msgctxt, Msgid) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
+#ifdef DEFAULT_TEXT_DOMAIN
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#else
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#endif
+#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+pgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ int category)
+{
+ const char *translation = dcgettext (domain, msg_ctxt_id, category);
+ if (translation == msg_ctxt_id)
+ return msgid;
+ else
+ return translation;
+}
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+npgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ const char *translation =
+ dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+ if (translation == msg_ctxt_id || translation == msgid_plural)
+ return (n == 1 ? msgid : msgid_plural);
+ else
+ return translation;
+}
+
+/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
+ can be arbitrary expressions. But for string literals these macros are
+ less efficient than those above. */
+
+#include <string.h>
+
+#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
+ /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc)
+ || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )
+# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
+#else
+# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
+#endif
+
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+#include <stdlib.h>
+#endif
+
+#define pgettext_expr(Msgctxt, Msgid) \
+ dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+ dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ int found_translation;
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcgettext (domain, msg_ctxt_id, category);
+ found_translation = (translation != msg_ctxt_id);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (found_translation)
+ return translation;
+ }
+ return msgid;
+}
+
+#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcnpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ int found_translation;
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+ found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (found_translation)
+ return translation;
+ }
+ return (n == 1 ? msgid : msgid_plural);
+}
+
+#endif /* _LIBGETTEXT_H */
diff --git a/grub-core/lib/gnulib/glthread/lock.c b/grub-core/lib/gnulib/glthread/lock.c
new file mode 100644
index 0000000..a4498cb
--- /dev/null
+++ b/grub-core/lib/gnulib/glthread/lock.c
@@ -0,0 +1,1221 @@
+/* Locking in multithreaded situations.
+ Copyright (C) 2005-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005.
+ Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
+ gthr-win32.h. */
+
+#include <config.h>
+
+#include "glthread/lock.h"
+
+/* ========================================================================= */
+
+#if USE_POSIX_THREADS
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1)))
+
+# ifdef PTHREAD_RWLOCK_INITIALIZER
+
+# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
+ /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
+
+int
+glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock)
+{
+ pthread_rwlockattr_t attributes;
+ int err;
+
+ err = pthread_rwlockattr_init (&attributes);
+ if (err != 0)
+ return err;
+ /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that
+ causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not
+ do this; see
+ http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */
+ err = pthread_rwlockattr_setkind_np (&attributes,
+ PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+ if (err == 0)
+ err = pthread_rwlock_init(lock, &attributes);
+ /* pthread_rwlockattr_destroy always returns 0. It cannot influence the
+ return value. */
+ pthread_rwlockattr_destroy (&attributes);
+ return err;
+}
+
+# endif
+# else
+
+int
+glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
+{
+ int err;
+
+ err = pthread_rwlock_init (&lock->rwlock, NULL);
+ if (err != 0)
+ return err;
+ lock->initialized = 1;
+ return 0;
+}
+
+int
+glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
+{
+ if (!lock->initialized)
+ {
+ int err;
+
+ err = pthread_mutex_lock (&lock->guard);
+ if (err != 0)
+ return err;
+ if (!lock->initialized)
+ {
+ err = glthread_rwlock_init_multithreaded (lock);
+ if (err != 0)
+ {
+ pthread_mutex_unlock (&lock->guard);
+ return err;
+ }
+ }
+ err = pthread_mutex_unlock (&lock->guard);
+ if (err != 0)
+ return err;
+ }
+ return pthread_rwlock_rdlock (&lock->rwlock);
+}
+
+int
+glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
+{
+ if (!lock->initialized)
+ {
+ int err;
+
+ err = pthread_mutex_lock (&lock->guard);
+ if (err != 0)
+ return err;
+ if (!lock->initialized)
+ {
+ err = glthread_rwlock_init_multithreaded (lock);
+ if (err != 0)
+ {
+ pthread_mutex_unlock (&lock->guard);
+ return err;
+ }
+ }
+ err = pthread_mutex_unlock (&lock->guard);
+ if (err != 0)
+ return err;
+ }
+ return pthread_rwlock_wrlock (&lock->rwlock);
+}
+
+int
+glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
+{
+ if (!lock->initialized)
+ return EINVAL;
+ return pthread_rwlock_unlock (&lock->rwlock);
+}
+
+int
+glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
+{
+ int err;
+
+ if (!lock->initialized)
+ return EINVAL;
+ err = pthread_rwlock_destroy (&lock->rwlock);
+ if (err != 0)
+ return err;
+ lock->initialized = 0;
+ return 0;
+}
+
+# endif
+
+# else
+
+int
+glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
+{
+ int err;
+
+ err = pthread_mutex_init (&lock->lock, NULL);
+ if (err != 0)
+ return err;
+ err = pthread_cond_init (&lock->waiting_readers, NULL);
+ if (err != 0)
+ return err;
+ err = pthread_cond_init (&lock->waiting_writers, NULL);
+ if (err != 0)
+ return err;
+ lock->waiting_writers_count = 0;
+ lock->runcount = 0;
+ return 0;
+}
+
+int
+glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
+{
+ int err;
+
+ err = pthread_mutex_lock (&lock->lock);
+ if (err != 0)
+ return err;
+ /* Test whether only readers are currently running, and whether the runcount
+ field will not overflow, and whether no writer is waiting. The latter
+ condition is because POSIX recommends that "write locks shall take
+ precedence over read locks", to avoid "writer starvation". */
+ while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
+ {
+ /* This thread has to wait for a while. Enqueue it among the
+ waiting_readers. */
+ err = pthread_cond_wait (&lock->waiting_readers, &lock->lock);
+ if (err != 0)
+ {
+ pthread_mutex_unlock (&lock->lock);
+ return err;
+ }
+ }
+ lock->runcount++;
+ return pthread_mutex_unlock (&lock->lock);
+}
+
+int
+glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
+{
+ int err;
+
+ err = pthread_mutex_lock (&lock->lock);
+ if (err != 0)
+ return err;
+ /* Test whether no readers or writers are currently running. */
+ while (!(lock->runcount == 0))
+ {
+ /* This thread has to wait for a while. Enqueue it among the
+ waiting_writers. */
+ lock->waiting_writers_count++;
+ err = pthread_cond_wait (&lock->waiting_writers, &lock->lock);
+ if (err != 0)
+ {
+ lock->waiting_writers_count--;
+ pthread_mutex_unlock (&lock->lock);
+ return err;
+ }
+ lock->waiting_writers_count--;
+ }
+ lock->runcount--; /* runcount becomes -1 */
+ return pthread_mutex_unlock (&lock->lock);
+}
+
+int
+glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
+{
+ int err;
+
+ err = pthread_mutex_lock (&lock->lock);
+ if (err != 0)
+ return err;
+ if (lock->runcount < 0)
+ {
+ /* Drop a writer lock. */
+ if (!(lock->runcount == -1))
+ {
+ pthread_mutex_unlock (&lock->lock);
+ return EINVAL;
+ }
+ lock->runcount = 0;
+ }
+ else
+ {
+ /* Drop a reader lock. */
+ if (!(lock->runcount > 0))
+ {
+ pthread_mutex_unlock (&lock->lock);
+ return EINVAL;
+ }
+ lock->runcount--;
+ }
+ if (lock->runcount == 0)
+ {
+ /* POSIX recommends that "write locks shall take precedence over read
+ locks", to avoid "writer starvation". */
+ if (lock->waiting_writers_count > 0)
+ {
+ /* Wake up one of the waiting writers. */
+ err = pthread_cond_signal (&lock->waiting_writers);
+ if (err != 0)
+ {
+ pthread_mutex_unlock (&lock->lock);
+ return err;
+ }
+ }
+ else
+ {
+ /* Wake up all waiting readers. */
+ err = pthread_cond_broadcast (&lock->waiting_readers);
+ if (err != 0)
+ {
+ pthread_mutex_unlock (&lock->lock);
+ return err;
+ }
+ }
+ }
+ return pthread_mutex_unlock (&lock->lock);
+}
+
+int
+glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
+{
+ int err;
+
+ err = pthread_mutex_destroy (&lock->lock);
+ if (err != 0)
+ return err;
+ err = pthread_cond_destroy (&lock->waiting_readers);
+ if (err != 0)
+ return err;
+ err = pthread_cond_destroy (&lock->waiting_writers);
+ if (err != 0)
+ return err;
+ return 0;
+}
+
+# endif
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+# if HAVE_PTHREAD_MUTEX_RECURSIVE
+
+# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+
+int
+glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
+{
+ pthread_mutexattr_t attributes;
+ int err;
+
+ err = pthread_mutexattr_init (&attributes);
+ if (err != 0)
+ return err;
+ err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
+ if (err != 0)
+ {
+ pthread_mutexattr_destroy (&attributes);
+ return err;
+ }
+ err = pthread_mutex_init (lock, &attributes);
+ if (err != 0)
+ {
+ pthread_mutexattr_destroy (&attributes);
+ return err;
+ }
+ err = pthread_mutexattr_destroy (&attributes);
+ if (err != 0)
+ return err;
+ return 0;
+}
+
+# else
+
+int
+glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
+{
+ pthread_mutexattr_t attributes;
+ int err;
+
+ err = pthread_mutexattr_init (&attributes);
+ if (err != 0)
+ return err;
+ err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
+ if (err != 0)
+ {
+ pthread_mutexattr_destroy (&attributes);
+ return err;
+ }
+ err = pthread_mutex_init (&lock->recmutex, &attributes);
+ if (err != 0)
+ {
+ pthread_mutexattr_destroy (&attributes);
+ return err;
+ }
+ err = pthread_mutexattr_destroy (&attributes);
+ if (err != 0)
+ return err;
+ lock->initialized = 1;
+ return 0;
+}
+
+int
+glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
+{
+ if (!lock->initialized)
+ {
+ int err;
+
+ err = pthread_mutex_lock (&lock->guard);
+ if (err != 0)
+ return err;
+ if (!lock->initialized)
+ {
+ err = glthread_recursive_lock_init_multithreaded (lock);
+ if (err != 0)
+ {
+ pthread_mutex_unlock (&lock->guard);
+ return err;
+ }
+ }
+ err = pthread_mutex_unlock (&lock->guard);
+ if (err != 0)
+ return err;
+ }
+ return pthread_mutex_lock (&lock->recmutex);
+}
+
+int
+glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
+{
+ if (!lock->initialized)
+ return EINVAL;
+ return pthread_mutex_unlock (&lock->recmutex);
+}
+
+int
+glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
+{
+ int err;
+
+ if (!lock->initialized)
+ return EINVAL;
+ err = pthread_mutex_destroy (&lock->recmutex);
+ if (err != 0)
+ return err;
+ lock->initialized = 0;
+ return 0;
+}
+
+# endif
+
+# else
+
+int
+glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
+{
+ int err;
+
+ err = pthread_mutex_init (&lock->mutex, NULL);
+ if (err != 0)
+ return err;
+ lock->owner = (pthread_t) 0;
+ lock->depth = 0;
+ return 0;
+}
+
+int
+glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
+{
+ pthread_t self = pthread_self ();
+ if (lock->owner != self)
+ {
+ int err;
+
+ err = pthread_mutex_lock (&lock->mutex);
+ if (err != 0)
+ return err;
+ lock->owner = self;
+ }
+ if (++(lock->depth) == 0) /* wraparound? */
+ {
+ lock->depth--;
+ return EAGAIN;
+ }
+ return 0;
+}
+
+int
+glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
+{
+ if (lock->owner != pthread_self ())
+ return EPERM;
+ if (lock->depth == 0)
+ return EINVAL;
+ if (--(lock->depth) == 0)
+ {
+ lock->owner = (pthread_t) 0;
+ return pthread_mutex_unlock (&lock->mutex);
+ }
+ else
+ return 0;
+}
+
+int
+glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
+{
+ if (lock->owner != (pthread_t) 0)
+ return EBUSY;
+ return pthread_mutex_destroy (&lock->mutex);
+}
+
+# endif
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT;
+
+int
+glthread_once_singlethreaded (pthread_once_t *once_control)
+{
+ /* We don't know whether pthread_once_t is an integer type, a floating-point
+ type, a pointer type, or a structure type. */
+ char *firstbyte = (char *)once_control;
+ if (*firstbyte == *(const char *)&fresh_once)
+ {
+ /* First time use of once_control. Invert the first byte. */
+ *firstbyte = ~ *(const char *)&fresh_once;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_PTH_THREADS
+
+/* Use the GNU Pth threads library. */
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+# if !HAVE_PTH_RWLOCK_ACQUIRE_PREFER_WRITER
+
+int
+glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
+{
+ if (!pth_mutex_init (&lock->lock))
+ return errno;
+ if (!pth_cond_init (&lock->waiting_readers))
+ return errno;
+ if (!pth_cond_init (&lock->waiting_writers))
+ return errno;
+ lock->waiting_writers_count = 0;
+ lock->runcount = 0;
+ lock->initialized = 1;
+ return 0;
+}
+
+int
+glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
+{
+ if (!lock->initialized)
+ glthread_rwlock_init_multithreaded (lock);
+ if (!pth_mutex_acquire (&lock->lock, 0, NULL))
+ return errno;
+ /* Test whether only readers are currently running, and whether the runcount
+ field will not overflow, and whether no writer is waiting. The latter
+ condition is because POSIX recommends that "write locks shall take
+ precedence over read locks", to avoid "writer starvation". */
+ while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
+ {
+ /* This thread has to wait for a while. Enqueue it among the
+ waiting_readers. */
+ if (!pth_cond_await (&lock->waiting_readers, &lock->lock, NULL))
+ {
+ int err = errno;
+ pth_mutex_release (&lock->lock);
+ return err;
+ }
+ }
+ lock->runcount++;
+ return (!pth_mutex_release (&lock->lock) ? errno : 0);
+}
+
+int
+glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
+{
+ if (!lock->initialized)
+ glthread_rwlock_init_multithreaded (lock);
+ if (!pth_mutex_acquire (&lock->lock, 0, NULL))
+ return errno;
+ /* Test whether no readers or writers are currently running. */
+ while (!(lock->runcount == 0))
+ {
+ /* This thread has to wait for a while. Enqueue it among the
+ waiting_writers. */
+ lock->waiting_writers_count++;
+ if (!pth_cond_await (&lock->waiting_writers, &lock->lock, NULL))
+ {
+ int err = errno;
+ lock->waiting_writers_count--;
+ pth_mutex_release (&lock->lock);
+ return err;
+ }
+ lock->waiting_writers_count--;
+ }
+ lock->runcount--; /* runcount becomes -1 */
+ return (!pth_mutex_release (&lock->lock) ? errno : 0);
+}
+
+int
+glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
+{
+ int err;
+
+ if (!lock->initialized)
+ return EINVAL;
+ if (!pth_mutex_acquire (&lock->lock, 0, NULL))
+ return errno;
+ if (lock->runcount < 0)
+ {
+ /* Drop a writer lock. */
+ if (!(lock->runcount == -1))
+ {
+ pth_mutex_release (&lock->lock);
+ return EINVAL;
+ }
+ lock->runcount = 0;
+ }
+ else
+ {
+ /* Drop a reader lock. */
+ if (!(lock->runcount > 0))
+ {
+ pth_mutex_release (&lock->lock);
+ return EINVAL;
+ }
+ lock->runcount--;
+ }
+ if (lock->runcount == 0)
+ {
+ /* POSIX recommends that "write locks shall take precedence over read
+ locks", to avoid "writer starvation". */
+ if (lock->waiting_writers_count > 0)
+ {
+ /* Wake up one of the waiting writers. */
+ if (!pth_cond_notify (&lock->waiting_writers, FALSE))
+ {
+ int err = errno;
+ pth_mutex_release (&lock->lock);
+ return err;
+ }
+ }
+ else
+ {
+ /* Wake up all waiting readers. */
+ if (!pth_cond_notify (&lock->waiting_readers, TRUE))
+ {
+ int err = errno;
+ pth_mutex_release (&lock->lock);
+ return err;
+ }
+ }
+ }
+ return (!pth_mutex_release (&lock->lock) ? errno : 0);
+}
+
+int
+glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
+{
+ lock->initialized = 0;
+ return 0;
+}
+
+# endif
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+static void
+glthread_once_call (void *arg)
+{
+ void (**gl_once_temp_addr) (void) = (void (**) (void)) arg;
+ void (*initfunction) (void) = *gl_once_temp_addr;
+ initfunction ();
+}
+
+int
+glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void))
+{
+ void (*temp) (void) = initfunction;
+ return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0);
+}
+
+int
+glthread_once_singlethreaded (pth_once_t *once_control)
+{
+ /* We know that pth_once_t is an integer type. */
+ if (*once_control == PTH_ONCE_INIT)
+ {
+ /* First time use of once_control. Invert the marker. */
+ *once_control = ~ PTH_ONCE_INIT;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_SOLARIS_THREADS
+
+/* Use the old Solaris threads library. */
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+int
+glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
+{
+ int err;
+
+ err = mutex_init (&lock->mutex, USYNC_THREAD, NULL);
+ if (err != 0)
+ return err;
+ lock->owner = (thread_t) 0;
+ lock->depth = 0;
+ return 0;
+}
+
+int
+glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
+{
+ thread_t self = thr_self ();
+ if (lock->owner != self)
+ {
+ int err;
+
+ err = mutex_lock (&lock->mutex);
+ if (err != 0)
+ return err;
+ lock->owner = self;
+ }
+ if (++(lock->depth) == 0) /* wraparound? */
+ {
+ lock->depth--;
+ return EAGAIN;
+ }
+ return 0;
+}
+
+int
+glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
+{
+ if (lock->owner != thr_self ())
+ return EPERM;
+ if (lock->depth == 0)
+ return EINVAL;
+ if (--(lock->depth) == 0)
+ {
+ lock->owner = (thread_t) 0;
+ return mutex_unlock (&lock->mutex);
+ }
+ else
+ return 0;
+}
+
+int
+glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
+{
+ if (lock->owner != (thread_t) 0)
+ return EBUSY;
+ return mutex_destroy (&lock->mutex);
+}
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+int
+glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void))
+{
+ if (!once_control->inited)
+ {
+ int err;
+
+ /* Use the mutex to guarantee that if another thread is already calling
+ the initfunction, this thread waits until it's finished. */
+ err = mutex_lock (&once_control->mutex);
+ if (err != 0)
+ return err;
+ if (!once_control->inited)
+ {
+ once_control->inited = 1;
+ initfunction ();
+ }
+ return mutex_unlock (&once_control->mutex);
+ }
+ else
+ return 0;
+}
+
+int
+glthread_once_singlethreaded (gl_once_t *once_control)
+{
+ /* We know that gl_once_t contains an integer type. */
+ if (!once_control->inited)
+ {
+ /* First time use of once_control. Invert the marker. */
+ once_control->inited = ~ 0;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_WINDOWS_THREADS
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+void
+glthread_lock_init_func (gl_lock_t *lock)
+{
+ InitializeCriticalSection (&lock->lock);
+ lock->guard.done = 1;
+}
+
+int
+glthread_lock_lock_func (gl_lock_t *lock)
+{
+ if (!lock->guard.done)
+ {
+ if (InterlockedIncrement (&lock->guard.started) == 0)
+ /* This thread is the first one to need this lock. Initialize it. */
+ glthread_lock_init (lock);
+ else
+ /* Yield the CPU while waiting for another thread to finish
+ initializing this lock. */
+ while (!lock->guard.done)
+ Sleep (0);
+ }
+ EnterCriticalSection (&lock->lock);
+ return 0;
+}
+
+int
+glthread_lock_unlock_func (gl_lock_t *lock)
+{
+ if (!lock->guard.done)
+ return EINVAL;
+ LeaveCriticalSection (&lock->lock);
+ return 0;
+}
+
+int
+glthread_lock_destroy_func (gl_lock_t *lock)
+{
+ if (!lock->guard.done)
+ return EINVAL;
+ DeleteCriticalSection (&lock->lock);
+ lock->guard.done = 0;
+ return 0;
+}
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+/* In this file, the waitqueues are implemented as circular arrays. */
+#define gl_waitqueue_t gl_carray_waitqueue_t
+
+static void
+gl_waitqueue_init (gl_waitqueue_t *wq)
+{
+ wq->array = NULL;
+ wq->count = 0;
+ wq->alloc = 0;
+ wq->offset = 0;
+}
+
+/* Enqueues the current thread, represented by an event, in a wait queue.
+ Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */
+static HANDLE
+gl_waitqueue_add (gl_waitqueue_t *wq)
+{
+ HANDLE event;
+ unsigned int index;
+
+ if (wq->count == wq->alloc)
+ {
+ unsigned int new_alloc = 2 * wq->alloc + 1;
+ HANDLE *new_array =
+ (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE));
+ if (new_array == NULL)
+ /* No more memory. */
+ return INVALID_HANDLE_VALUE;
+ /* Now is a good opportunity to rotate the array so that its contents
+ starts at offset 0. */
+ if (wq->offset > 0)
+ {
+ unsigned int old_count = wq->count;
+ unsigned int old_alloc = wq->alloc;
+ unsigned int old_offset = wq->offset;
+ unsigned int i;
+ if (old_offset + old_count > old_alloc)
+ {
+ unsigned int limit = old_offset + old_count - old_alloc;
+ for (i = 0; i < limit; i++)
+ new_array[old_alloc + i] = new_array[i];
+ }
+ for (i = 0; i < old_count; i++)
+ new_array[i] = new_array[old_offset + i];
+ wq->offset = 0;
+ }
+ wq->array = new_array;
+ wq->alloc = new_alloc;
+ }
+ /* Whether the created event is a manual-reset one or an auto-reset one,
+ does not matter, since we will wait on it only once. */
+ event = CreateEvent (NULL, TRUE, FALSE, NULL);
+ if (event == INVALID_HANDLE_VALUE)
+ /* No way to allocate an event. */
+ return INVALID_HANDLE_VALUE;
+ index = wq->offset + wq->count;
+ if (index >= wq->alloc)
+ index -= wq->alloc;
+ wq->array[index] = event;
+ wq->count++;
+ return event;
+}
+
+/* Notifies the first thread from a wait queue and dequeues it. */
+static void
+gl_waitqueue_notify_first (gl_waitqueue_t *wq)
+{
+ SetEvent (wq->array[wq->offset + 0]);
+ wq->offset++;
+ wq->count--;
+ if (wq->count == 0 || wq->offset == wq->alloc)
+ wq->offset = 0;
+}
+
+/* Notifies all threads from a wait queue and dequeues them all. */
+static void
+gl_waitqueue_notify_all (gl_waitqueue_t *wq)
+{
+ unsigned int i;
+
+ for (i = 0; i < wq->count; i++)
+ {
+ unsigned int index = wq->offset + i;
+ if (index >= wq->alloc)
+ index -= wq->alloc;
+ SetEvent (wq->array[index]);
+ }
+ wq->count = 0;
+ wq->offset = 0;
+}
+
+void
+glthread_rwlock_init_func (gl_rwlock_t *lock)
+{
+ InitializeCriticalSection (&lock->lock);
+ gl_waitqueue_init (&lock->waiting_readers);
+ gl_waitqueue_init (&lock->waiting_writers);
+ lock->runcount = 0;
+ lock->guard.done = 1;
+}
+
+int
+glthread_rwlock_rdlock_func (gl_rwlock_t *lock)
+{
+ if (!lock->guard.done)
+ {
+ if (InterlockedIncrement (&lock->guard.started) == 0)
+ /* This thread is the first one to need this lock. Initialize it. */
+ glthread_rwlock_init (lock);
+ else
+ /* Yield the CPU while waiting for another thread to finish
+ initializing this lock. */
+ while (!lock->guard.done)
+ Sleep (0);
+ }
+ EnterCriticalSection (&lock->lock);
+ /* Test whether only readers are currently running, and whether the runcount
+ field will not overflow, and whether no writer is waiting. The latter
+ condition is because POSIX recommends that "write locks shall take
+ precedence over read locks", to avoid "writer starvation". */
+ if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0))
+ {
+ /* This thread has to wait for a while. Enqueue it among the
+ waiting_readers. */
+ HANDLE event = gl_waitqueue_add (&lock->waiting_readers);
+ if (event != INVALID_HANDLE_VALUE)
+ {
+ DWORD result;
+ LeaveCriticalSection (&lock->lock);
+ /* Wait until another thread signals this event. */
+ result = WaitForSingleObject (event, INFINITE);
+ if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
+ abort ();
+ CloseHandle (event);
+ /* The thread which signalled the event already did the bookkeeping:
+ removed us from the waiting_readers, incremented lock->runcount. */
+ if (!(lock->runcount > 0))
+ abort ();
+ return 0;
+ }
+ else
+ {
+ /* Allocation failure. Weird. */
+ do
+ {
+ LeaveCriticalSection (&lock->lock);
+ Sleep (1);
+ EnterCriticalSection (&lock->lock);
+ }
+ while (!(lock->runcount + 1 > 0));
+ }
+ }
+ lock->runcount++;
+ LeaveCriticalSection (&lock->lock);
+ return 0;
+}
+
+int
+glthread_rwlock_wrlock_func (gl_rwlock_t *lock)
+{
+ if (!lock->guard.done)
+ {
+ if (InterlockedIncrement (&lock->guard.started) == 0)
+ /* This thread is the first one to need this lock. Initialize it. */
+ glthread_rwlock_init (lock);
+ else
+ /* Yield the CPU while waiting for another thread to finish
+ initializing this lock. */
+ while (!lock->guard.done)
+ Sleep (0);
+ }
+ EnterCriticalSection (&lock->lock);
+ /* Test whether no readers or writers are currently running. */
+ if (!(lock->runcount == 0))
+ {
+ /* This thread has to wait for a while. Enqueue it among the
+ waiting_writers. */
+ HANDLE event = gl_waitqueue_add (&lock->waiting_writers);
+ if (event != INVALID_HANDLE_VALUE)
+ {
+ DWORD result;
+ LeaveCriticalSection (&lock->lock);
+ /* Wait until another thread signals this event. */
+ result = WaitForSingleObject (event, INFINITE);
+ if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
+ abort ();
+ CloseHandle (event);
+ /* The thread which signalled the event already did the bookkeeping:
+ removed us from the waiting_writers, set lock->runcount = -1. */
+ if (!(lock->runcount == -1))
+ abort ();
+ return 0;
+ }
+ else
+ {
+ /* Allocation failure. Weird. */
+ do
+ {
+ LeaveCriticalSection (&lock->lock);
+ Sleep (1);
+ EnterCriticalSection (&lock->lock);
+ }
+ while (!(lock->runcount == 0));
+ }
+ }
+ lock->runcount--; /* runcount becomes -1 */
+ LeaveCriticalSection (&lock->lock);
+ return 0;
+}
+
+int
+glthread_rwlock_unlock_func (gl_rwlock_t *lock)
+{
+ if (!lock->guard.done)
+ return EINVAL;
+ EnterCriticalSection (&lock->lock);
+ if (lock->runcount < 0)
+ {
+ /* Drop a writer lock. */
+ if (!(lock->runcount == -1))
+ abort ();
+ lock->runcount = 0;
+ }
+ else
+ {
+ /* Drop a reader lock. */
+ if (!(lock->runcount > 0))
+ {
+ LeaveCriticalSection (&lock->lock);
+ return EPERM;
+ }
+ lock->runcount--;
+ }
+ if (lock->runcount == 0)
+ {
+ /* POSIX recommends that "write locks shall take precedence over read
+ locks", to avoid "writer starvation". */
+ if (lock->waiting_writers.count > 0)
+ {
+ /* Wake up one of the waiting writers. */
+ lock->runcount--;
+ gl_waitqueue_notify_first (&lock->waiting_writers);
+ }
+ else
+ {
+ /* Wake up all waiting readers. */
+ lock->runcount += lock->waiting_readers.count;
+ gl_waitqueue_notify_all (&lock->waiting_readers);
+ }
+ }
+ LeaveCriticalSection (&lock->lock);
+ return 0;
+}
+
+int
+glthread_rwlock_destroy_func (gl_rwlock_t *lock)
+{
+ if (!lock->guard.done)
+ return EINVAL;
+ if (lock->runcount != 0)
+ return EBUSY;
+ DeleteCriticalSection (&lock->lock);
+ if (lock->waiting_readers.array != NULL)
+ free (lock->waiting_readers.array);
+ if (lock->waiting_writers.array != NULL)
+ free (lock->waiting_writers.array);
+ lock->guard.done = 0;
+ return 0;
+}
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+void
+glthread_recursive_lock_init_func (gl_recursive_lock_t *lock)
+{
+ lock->owner = 0;
+ lock->depth = 0;
+ InitializeCriticalSection (&lock->lock);
+ lock->guard.done = 1;
+}
+
+int
+glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock)
+{
+ if (!lock->guard.done)
+ {
+ if (InterlockedIncrement (&lock->guard.started) == 0)
+ /* This thread is the first one to need this lock. Initialize it. */
+ glthread_recursive_lock_init (lock);
+ else
+ /* Yield the CPU while waiting for another thread to finish
+ initializing this lock. */
+ while (!lock->guard.done)
+ Sleep (0);
+ }
+ {
+ DWORD self = GetCurrentThreadId ();
+ if (lock->owner != self)
+ {
+ EnterCriticalSection (&lock->lock);
+ lock->owner = self;
+ }
+ if (++(lock->depth) == 0) /* wraparound? */
+ {
+ lock->depth--;
+ return EAGAIN;
+ }
+ }
+ return 0;
+}
+
+int
+glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock)
+{
+ if (lock->owner != GetCurrentThreadId ())
+ return EPERM;
+ if (lock->depth == 0)
+ return EINVAL;
+ if (--(lock->depth) == 0)
+ {
+ lock->owner = 0;
+ LeaveCriticalSection (&lock->lock);
+ }
+ return 0;
+}
+
+int
+glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock)
+{
+ if (lock->owner != 0)
+ return EBUSY;
+ DeleteCriticalSection (&lock->lock);
+ lock->guard.done = 0;
+ return 0;
+}
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+void
+glthread_once_func (gl_once_t *once_control, void (*initfunction) (void))
+{
+ if (once_control->inited <= 0)
+ {
+ if (InterlockedIncrement (&once_control->started) == 0)
+ {
+ /* This thread is the first one to come to this once_control. */
+ InitializeCriticalSection (&once_control->lock);
+ EnterCriticalSection (&once_control->lock);
+ once_control->inited = 0;
+ initfunction ();
+ once_control->inited = 1;
+ LeaveCriticalSection (&once_control->lock);
+ }
+ else
+ {
+ /* Undo last operation. */
+ InterlockedDecrement (&once_control->started);
+ /* Some other thread has already started the initialization.
+ Yield the CPU while waiting for the other thread to finish
+ initializing and taking the lock. */
+ while (once_control->inited < 0)
+ Sleep (0);
+ if (once_control->inited <= 0)
+ {
+ /* Take the lock. This blocks until the other thread has
+ finished calling the initfunction. */
+ EnterCriticalSection (&once_control->lock);
+ LeaveCriticalSection (&once_control->lock);
+ if (!(once_control->inited > 0))
+ abort ();
+ }
+ }
+ }
+}
+
+#endif
+
+/* ========================================================================= */
diff --git a/grub-core/lib/gnulib/glthread/lock.h b/grub-core/lib/gnulib/glthread/lock.h
new file mode 100644
index 0000000..636b089
--- /dev/null
+++ b/grub-core/lib/gnulib/glthread/lock.h
@@ -0,0 +1,988 @@
+/* Locking in multithreaded situations.
+ Copyright (C) 2005-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005.
+ Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
+ gthr-win32.h. */
+
+/* This file contains locking primitives for use with a given thread library.
+ It does not contain primitives for creating threads or for other
+ synchronization primitives.
+
+ Normal (non-recursive) locks:
+ Type: gl_lock_t
+ Declaration: gl_lock_define(extern, name)
+ Initializer: gl_lock_define_initialized(, name)
+ Initialization: gl_lock_init (name);
+ Taking the lock: gl_lock_lock (name);
+ Releasing the lock: gl_lock_unlock (name);
+ De-initialization: gl_lock_destroy (name);
+ Equivalent functions with control of error handling:
+ Initialization: err = glthread_lock_init (&name);
+ Taking the lock: err = glthread_lock_lock (&name);
+ Releasing the lock: err = glthread_lock_unlock (&name);
+ De-initialization: err = glthread_lock_destroy (&name);
+
+ Read-Write (non-recursive) locks:
+ Type: gl_rwlock_t
+ Declaration: gl_rwlock_define(extern, name)
+ Initializer: gl_rwlock_define_initialized(, name)
+ Initialization: gl_rwlock_init (name);
+ Taking the lock: gl_rwlock_rdlock (name);
+ gl_rwlock_wrlock (name);
+ Releasing the lock: gl_rwlock_unlock (name);
+ De-initialization: gl_rwlock_destroy (name);
+ Equivalent functions with control of error handling:
+ Initialization: err = glthread_rwlock_init (&name);
+ Taking the lock: err = glthread_rwlock_rdlock (&name);
+ err = glthread_rwlock_wrlock (&name);
+ Releasing the lock: err = glthread_rwlock_unlock (&name);
+ De-initialization: err = glthread_rwlock_destroy (&name);
+
+ Recursive locks:
+ Type: gl_recursive_lock_t
+ Declaration: gl_recursive_lock_define(extern, name)
+ Initializer: gl_recursive_lock_define_initialized(, name)
+ Initialization: gl_recursive_lock_init (name);
+ Taking the lock: gl_recursive_lock_lock (name);
+ Releasing the lock: gl_recursive_lock_unlock (name);
+ De-initialization: gl_recursive_lock_destroy (name);
+ Equivalent functions with control of error handling:
+ Initialization: err = glthread_recursive_lock_init (&name);
+ Taking the lock: err = glthread_recursive_lock_lock (&name);
+ Releasing the lock: err = glthread_recursive_lock_unlock (&name);
+ De-initialization: err = glthread_recursive_lock_destroy (&name);
+
+ Once-only execution:
+ Type: gl_once_t
+ Initializer: gl_once_define(extern, name)
+ Execution: gl_once (name, initfunction);
+ Equivalent functions with control of error handling:
+ Execution: err = glthread_once (&name, initfunction);
+*/
+
+
+#ifndef _LOCK_H
+#define _LOCK_H
+
+#include <errno.h>
+#include <stdlib.h>
+
+/* ========================================================================= */
+
+#if USE_POSIX_THREADS
+
+/* Use the POSIX threads library. */
+
+# include <pthread.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if PTHREAD_IN_USE_DETECTION_HARD
+
+/* The pthread_in_use() detection needs to be done at runtime. */
+# define pthread_in_use() \
+ glthread_in_use ()
+extern int glthread_in_use (void);
+
+# endif
+
+# if USE_POSIX_THREADS_WEAK
+
+/* Use weak references to the POSIX threads library. */
+
+/* Weak references avoid dragging in external libraries if the other parts
+ of the program don't use them. Here we use them, because we don't want
+ every program that uses libintl to depend on libpthread. This assumes
+ that libpthread would not be loaded after libintl; i.e. if libintl is
+ loaded first, by an executable that does not depend on libpthread, and
+ then a module is dynamically loaded that depends on libpthread, libintl
+ will not be multithread-safe. */
+
+/* The way to test at runtime whether libpthread is present is to test
+ whether a function pointer's value, such as &pthread_mutex_init, is
+ non-NULL. However, some versions of GCC have a bug through which, in
+ PIC mode, &foo != NULL always evaluates to true if there is a direct
+ call to foo(...) in the same function. To avoid this, we test the
+ address of a function in libpthread that we don't use. */
+
+# pragma weak pthread_mutex_init
+# pragma weak pthread_mutex_lock
+# pragma weak pthread_mutex_unlock
+# pragma weak pthread_mutex_destroy
+# pragma weak pthread_rwlock_init
+# pragma weak pthread_rwlock_rdlock
+# pragma weak pthread_rwlock_wrlock
+# pragma weak pthread_rwlock_unlock
+# pragma weak pthread_rwlock_destroy
+# pragma weak pthread_once
+# pragma weak pthread_cond_init
+# pragma weak pthread_cond_wait
+# pragma weak pthread_cond_signal
+# pragma weak pthread_cond_broadcast
+# pragma weak pthread_cond_destroy
+# pragma weak pthread_mutexattr_init
+# pragma weak pthread_mutexattr_settype
+# pragma weak pthread_mutexattr_destroy
+# pragma weak pthread_rwlockattr_init
+# if __GNU_LIBRARY__ > 1
+# pragma weak pthread_rwlockattr_setkind_np
+# endif
+# pragma weak pthread_rwlockattr_destroy
+# ifndef pthread_self
+# pragma weak pthread_self
+# endif
+
+# if !PTHREAD_IN_USE_DETECTION_HARD
+ /* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols
+ can be used to determine whether libpthread is in use. These are:
+ pthread_mutexattr_gettype
+ pthread_rwlockattr_destroy
+ pthread_rwlockattr_init
+ */
+# pragma weak pthread_mutexattr_gettype
+# define pthread_in_use() (pthread_mutexattr_gettype != NULL)
+# endif
+
+# else
+
+# if !PTHREAD_IN_USE_DETECTION_HARD
+# define pthread_in_use() 1
+# endif
+
+# endif
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+typedef pthread_mutex_t gl_lock_t;
+# define gl_lock_define(STORAGECLASS, NAME) \
+ STORAGECLASS pthread_mutex_t NAME;
+# define gl_lock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer;
+# define gl_lock_initializer \
+ PTHREAD_MUTEX_INITIALIZER
+# define glthread_lock_init(LOCK) \
+ (pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0)
+# define glthread_lock_lock(LOCK) \
+ (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
+# define glthread_lock_unlock(LOCK) \
+ (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
+# define glthread_lock_destroy(LOCK) \
+ (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1)))
+
+# ifdef PTHREAD_RWLOCK_INITIALIZER
+
+typedef pthread_rwlock_t gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME) \
+ STORAGECLASS pthread_rwlock_t NAME;
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
+# if HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
+# define gl_rwlock_initializer \
+ PTHREAD_RWLOCK_INITIALIZER
+# define glthread_rwlock_init(LOCK) \
+ (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
+# else /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
+# define gl_rwlock_initializer \
+ PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
+# define glthread_rwlock_init(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_init_for_glibc (LOCK) : 0)
+extern int glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock);
+# endif
+# define glthread_rwlock_rdlock(LOCK) \
+ (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0)
+# define glthread_rwlock_wrlock(LOCK) \
+ (pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0)
+# define glthread_rwlock_unlock(LOCK) \
+ (pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0)
+# define glthread_rwlock_destroy(LOCK) \
+ (pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0)
+
+# else
+
+typedef struct
+ {
+ int initialized;
+ pthread_mutex_t guard; /* protects the initialization */
+ pthread_rwlock_t rwlock; /* read-write lock */
+ }
+ gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_rwlock_t NAME;
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
+# define gl_rwlock_initializer \
+ { 0, PTHREAD_MUTEX_INITIALIZER }
+# define glthread_rwlock_init(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
+# define glthread_rwlock_rdlock(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_wrlock(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_unlock(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_destroy(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
+
+# endif
+
+# else
+
+typedef struct
+ {
+ pthread_mutex_t lock; /* protects the remaining fields */
+ pthread_cond_t waiting_readers; /* waiting readers */
+ pthread_cond_t waiting_writers; /* waiting writers */
+ unsigned int waiting_writers_count; /* number of waiting writers */
+ int runcount; /* number of readers running, or -1 when a writer runs */
+ }
+ gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_rwlock_t NAME;
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
+# define gl_rwlock_initializer \
+ { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 }
+# define glthread_rwlock_init(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
+# define glthread_rwlock_rdlock(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_wrlock(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_unlock(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_destroy(LOCK) \
+ (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
+
+# endif
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+# if HAVE_PTHREAD_MUTEX_RECURSIVE
+
+# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+
+typedef pthread_mutex_t gl_recursive_lock_t;
+# define gl_recursive_lock_define(STORAGECLASS, NAME) \
+ STORAGECLASS pthread_mutex_t NAME;
+# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer;
+# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER
+# define gl_recursive_lock_initializer \
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER
+# else
+# define gl_recursive_lock_initializer \
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+# endif
+# define glthread_recursive_lock_init(LOCK) \
+ (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_lock(LOCK) \
+ (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
+# define glthread_recursive_lock_unlock(LOCK) \
+ (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
+# define glthread_recursive_lock_destroy(LOCK) \
+ (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
+extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
+
+# else
+
+typedef struct
+ {
+ pthread_mutex_t recmutex; /* recursive mutex */
+ pthread_mutex_t guard; /* protects the initialization */
+ int initialized;
+ }
+ gl_recursive_lock_t;
+# define gl_recursive_lock_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_recursive_lock_t NAME;
+# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
+# define gl_recursive_lock_initializer \
+ { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 }
+# define glthread_recursive_lock_init(LOCK) \
+ (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_lock(LOCK) \
+ (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_unlock(LOCK) \
+ (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_destroy(LOCK) \
+ (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
+
+# endif
+
+# else
+
+/* Old versions of POSIX threads on Solaris did not have recursive locks.
+ We have to implement them ourselves. */
+
+typedef struct
+ {
+ pthread_mutex_t mutex;
+ pthread_t owner;
+ unsigned long depth;
+ }
+ gl_recursive_lock_t;
+# define gl_recursive_lock_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_recursive_lock_t NAME;
+# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
+# define gl_recursive_lock_initializer \
+ { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 }
+# define glthread_recursive_lock_init(LOCK) \
+ (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_lock(LOCK) \
+ (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_unlock(LOCK) \
+ (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_destroy(LOCK) \
+ (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
+
+# endif
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+typedef pthread_once_t gl_once_t;
+# define gl_once_define(STORAGECLASS, NAME) \
+ STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
+# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
+ (pthread_in_use () \
+ ? pthread_once (ONCE_CONTROL, INITFUNCTION) \
+ : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
+extern int glthread_once_singlethreaded (pthread_once_t *once_control);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_PTH_THREADS
+
+/* Use the GNU Pth threads library. */
+
+# include <pth.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if USE_PTH_THREADS_WEAK
+
+/* Use weak references to the GNU Pth threads library. */
+
+# pragma weak pth_mutex_init
+# pragma weak pth_mutex_acquire
+# pragma weak pth_mutex_release
+# pragma weak pth_rwlock_init
+# pragma weak pth_rwlock_acquire
+# pragma weak pth_rwlock_release
+# pragma weak pth_once
+# pragma weak pth_cond_init
+# pragma weak pth_cond_await
+# pragma weak pth_cond_notify
+
+# pragma weak pth_cancel
+# define pth_in_use() (pth_cancel != NULL)
+
+# else
+
+# define pth_in_use() 1
+
+# endif
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+typedef pth_mutex_t gl_lock_t;
+# define gl_lock_define(STORAGECLASS, NAME) \
+ STORAGECLASS pth_mutex_t NAME;
+# define gl_lock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS pth_mutex_t NAME = gl_lock_initializer;
+# define gl_lock_initializer \
+ PTH_MUTEX_INIT
+# define glthread_lock_init(LOCK) \
+ (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
+# define glthread_lock_lock(LOCK) \
+ (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
+# define glthread_lock_unlock(LOCK) \
+ (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
+# define glthread_lock_destroy(LOCK) \
+ ((void)(LOCK), 0)
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+/* Pth pth_rwlock_acquire always prefers readers. No autoconf test so far. */
+# if HAVE_PTH_RWLOCK_ACQUIRE_PREFER_WRITER
+
+typedef pth_rwlock_t gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME) \
+ STORAGECLASS pth_rwlock_t NAME;
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer;
+# define gl_rwlock_initializer \
+ PTH_RWLOCK_INIT
+# define glthread_rwlock_init(LOCK) \
+ (pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0)
+# define glthread_rwlock_rdlock(LOCK) \
+ (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0)
+# define glthread_rwlock_wrlock(LOCK) \
+ (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0)
+# define glthread_rwlock_unlock(LOCK) \
+ (pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0)
+# define glthread_rwlock_destroy(LOCK) \
+ ((void)(LOCK), 0)
+
+# else
+
+typedef struct
+ {
+ int initialized;
+ pth_mutex_t lock; /* protects the remaining fields */
+ pth_cond_t waiting_readers; /* waiting readers */
+ pth_cond_t waiting_writers; /* waiting writers */
+ unsigned int waiting_writers_count; /* number of waiting writers */
+ int runcount; /* number of readers running, or -1 when a writer runs */
+ }
+ gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_rwlock_t NAME;
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
+# define gl_rwlock_initializer \
+ { 0 }
+# define glthread_rwlock_init(LOCK) \
+ (pth_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
+# define glthread_rwlock_rdlock(LOCK) \
+ (pth_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_wrlock(LOCK) \
+ (pth_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_unlock(LOCK) \
+ (pth_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_destroy(LOCK) \
+ (pth_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
+
+# endif
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+/* In Pth, mutexes are recursive by default. */
+typedef pth_mutex_t gl_recursive_lock_t;
+# define gl_recursive_lock_define(STORAGECLASS, NAME) \
+ STORAGECLASS pth_mutex_t NAME;
+# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer;
+# define gl_recursive_lock_initializer \
+ PTH_MUTEX_INIT
+# define glthread_recursive_lock_init(LOCK) \
+ (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
+# define glthread_recursive_lock_lock(LOCK) \
+ (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
+# define glthread_recursive_lock_unlock(LOCK) \
+ (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
+# define glthread_recursive_lock_destroy(LOCK) \
+ ((void)(LOCK), 0)
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+typedef pth_once_t gl_once_t;
+# define gl_once_define(STORAGECLASS, NAME) \
+ STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT;
+# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
+ (pth_in_use () \
+ ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
+ : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
+extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void));
+extern int glthread_once_singlethreaded (pth_once_t *once_control);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_SOLARIS_THREADS
+
+/* Use the old Solaris threads library. */
+
+# include <thread.h>
+# include <synch.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if USE_SOLARIS_THREADS_WEAK
+
+/* Use weak references to the old Solaris threads library. */
+
+# pragma weak mutex_init
+# pragma weak mutex_lock
+# pragma weak mutex_unlock
+# pragma weak mutex_destroy
+# pragma weak rwlock_init
+# pragma weak rw_rdlock
+# pragma weak rw_wrlock
+# pragma weak rw_unlock
+# pragma weak rwlock_destroy
+# pragma weak thr_self
+
+# pragma weak thr_suspend
+# define thread_in_use() (thr_suspend != NULL)
+
+# else
+
+# define thread_in_use() 1
+
+# endif
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+typedef mutex_t gl_lock_t;
+# define gl_lock_define(STORAGECLASS, NAME) \
+ STORAGECLASS mutex_t NAME;
+# define gl_lock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS mutex_t NAME = gl_lock_initializer;
+# define gl_lock_initializer \
+ DEFAULTMUTEX
+# define glthread_lock_init(LOCK) \
+ (thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0)
+# define glthread_lock_lock(LOCK) \
+ (thread_in_use () ? mutex_lock (LOCK) : 0)
+# define glthread_lock_unlock(LOCK) \
+ (thread_in_use () ? mutex_unlock (LOCK) : 0)
+# define glthread_lock_destroy(LOCK) \
+ (thread_in_use () ? mutex_destroy (LOCK) : 0)
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+typedef rwlock_t gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME) \
+ STORAGECLASS rwlock_t NAME;
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS rwlock_t NAME = gl_rwlock_initializer;
+# define gl_rwlock_initializer \
+ DEFAULTRWLOCK
+# define glthread_rwlock_init(LOCK) \
+ (thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0)
+# define glthread_rwlock_rdlock(LOCK) \
+ (thread_in_use () ? rw_rdlock (LOCK) : 0)
+# define glthread_rwlock_wrlock(LOCK) \
+ (thread_in_use () ? rw_wrlock (LOCK) : 0)
+# define glthread_rwlock_unlock(LOCK) \
+ (thread_in_use () ? rw_unlock (LOCK) : 0)
+# define glthread_rwlock_destroy(LOCK) \
+ (thread_in_use () ? rwlock_destroy (LOCK) : 0)
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+/* Old Solaris threads did not have recursive locks.
+ We have to implement them ourselves. */
+
+typedef struct
+ {
+ mutex_t mutex;
+ thread_t owner;
+ unsigned long depth;
+ }
+ gl_recursive_lock_t;
+# define gl_recursive_lock_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_recursive_lock_t NAME;
+# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
+# define gl_recursive_lock_initializer \
+ { DEFAULTMUTEX, (thread_t) 0, 0 }
+# define glthread_recursive_lock_init(LOCK) \
+ (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_lock(LOCK) \
+ (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_unlock(LOCK) \
+ (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_destroy(LOCK) \
+ (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+typedef struct
+ {
+ volatile int inited;
+ mutex_t mutex;
+ }
+ gl_once_t;
+# define gl_once_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX };
+# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
+ (thread_in_use () \
+ ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
+ : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
+extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void));
+extern int glthread_once_singlethreaded (gl_once_t *once_control);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_WINDOWS_THREADS
+
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include <windows.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* We can use CRITICAL_SECTION directly, rather than the native Windows Event,
+ Mutex, Semaphore types, because
+ - we need only to synchronize inside a single process (address space),
+ not inter-process locking,
+ - we don't need to support trylock operations. (TryEnterCriticalSection
+ does not work on Windows 95/98/ME. Packages that need trylock usually
+ define their own mutex type.) */
+
+/* There is no way to statically initialize a CRITICAL_SECTION. It needs
+ to be done lazily, once only. For this we need spinlocks. */
+
+typedef struct { volatile int done; volatile long started; } gl_spinlock_t;
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+typedef struct
+ {
+ gl_spinlock_t guard; /* protects the initialization */
+ CRITICAL_SECTION lock;
+ }
+ gl_lock_t;
+# define gl_lock_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_lock_t NAME;
+# define gl_lock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS gl_lock_t NAME = gl_lock_initializer;
+# define gl_lock_initializer \
+ { { 0, -1 } }
+# define glthread_lock_init(LOCK) \
+ (glthread_lock_init_func (LOCK), 0)
+# define glthread_lock_lock(LOCK) \
+ glthread_lock_lock_func (LOCK)
+# define glthread_lock_unlock(LOCK) \
+ glthread_lock_unlock_func (LOCK)
+# define glthread_lock_destroy(LOCK) \
+ glthread_lock_destroy_func (LOCK)
+extern void glthread_lock_init_func (gl_lock_t *lock);
+extern int glthread_lock_lock_func (gl_lock_t *lock);
+extern int glthread_lock_unlock_func (gl_lock_t *lock);
+extern int glthread_lock_destroy_func (gl_lock_t *lock);
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+/* It is impossible to implement read-write locks using plain locks, without
+ introducing an extra thread dedicated to managing read-write locks.
+ Therefore here we need to use the low-level Event type. */
+
+typedef struct
+ {
+ HANDLE *array; /* array of waiting threads, each represented by an event */
+ unsigned int count; /* number of waiting threads */
+ unsigned int alloc; /* length of allocated array */
+ unsigned int offset; /* index of first waiting thread in array */
+ }
+ gl_carray_waitqueue_t;
+typedef struct
+ {
+ gl_spinlock_t guard; /* protects the initialization */
+ CRITICAL_SECTION lock; /* protects the remaining fields */
+ gl_carray_waitqueue_t waiting_readers; /* waiting readers */
+ gl_carray_waitqueue_t waiting_writers; /* waiting writers */
+ int runcount; /* number of readers running, or -1 when a writer runs */
+ }
+ gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_rwlock_t NAME;
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
+# define gl_rwlock_initializer \
+ { { 0, -1 } }
+# define glthread_rwlock_init(LOCK) \
+ (glthread_rwlock_init_func (LOCK), 0)
+# define glthread_rwlock_rdlock(LOCK) \
+ glthread_rwlock_rdlock_func (LOCK)
+# define glthread_rwlock_wrlock(LOCK) \
+ glthread_rwlock_wrlock_func (LOCK)
+# define glthread_rwlock_unlock(LOCK) \
+ glthread_rwlock_unlock_func (LOCK)
+# define glthread_rwlock_destroy(LOCK) \
+ glthread_rwlock_destroy_func (LOCK)
+extern void glthread_rwlock_init_func (gl_rwlock_t *lock);
+extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock);
+extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock);
+extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock);
+extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock);
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+/* The native Windows documentation says that CRITICAL_SECTION already
+ implements a recursive lock. But we need not rely on it: It's easy to
+ implement a recursive lock without this assumption. */
+
+typedef struct
+ {
+ gl_spinlock_t guard; /* protects the initialization */
+ DWORD owner;
+ unsigned long depth;
+ CRITICAL_SECTION lock;
+ }
+ gl_recursive_lock_t;
+# define gl_recursive_lock_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_recursive_lock_t NAME;
+# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+ STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
+# define gl_recursive_lock_initializer \
+ { { 0, -1 }, 0, 0 }
+# define glthread_recursive_lock_init(LOCK) \
+ (glthread_recursive_lock_init_func (LOCK), 0)
+# define glthread_recursive_lock_lock(LOCK) \
+ glthread_recursive_lock_lock_func (LOCK)
+# define glthread_recursive_lock_unlock(LOCK) \
+ glthread_recursive_lock_unlock_func (LOCK)
+# define glthread_recursive_lock_destroy(LOCK) \
+ glthread_recursive_lock_destroy_func (LOCK)
+extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock);
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+typedef struct
+ {
+ volatile int inited;
+ volatile long started;
+ CRITICAL_SECTION lock;
+ }
+ gl_once_t;
+# define gl_once_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_once_t NAME = { -1, -1 };
+# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
+ (glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0)
+extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void));
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS)
+
+/* Provide dummy implementation if threads are not supported. */
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+typedef int gl_lock_t;
+# define gl_lock_define(STORAGECLASS, NAME)
+# define gl_lock_define_initialized(STORAGECLASS, NAME)
+# define glthread_lock_init(NAME) 0
+# define glthread_lock_lock(NAME) 0
+# define glthread_lock_unlock(NAME) 0
+# define glthread_lock_destroy(NAME) 0
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+typedef int gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME)
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME)
+# define glthread_rwlock_init(NAME) 0
+# define glthread_rwlock_rdlock(NAME) 0
+# define glthread_rwlock_wrlock(NAME) 0
+# define glthread_rwlock_unlock(NAME) 0
+# define glthread_rwlock_destroy(NAME) 0
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+typedef int gl_recursive_lock_t;
+# define gl_recursive_lock_define(STORAGECLASS, NAME)
+# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME)
+# define glthread_recursive_lock_init(NAME) 0
+# define glthread_recursive_lock_lock(NAME) 0
+# define glthread_recursive_lock_unlock(NAME) 0
+# define glthread_recursive_lock_destroy(NAME) 0
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+typedef int gl_once_t;
+# define gl_once_define(STORAGECLASS, NAME) \
+ STORAGECLASS gl_once_t NAME = 0;
+# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
+ (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0)
+
+#endif
+
+/* ========================================================================= */
+
+/* Macros with built-in error handling. */
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+#define gl_lock_init(NAME) \
+ do \
+ { \
+ if (glthread_lock_init (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+#define gl_lock_lock(NAME) \
+ do \
+ { \
+ if (glthread_lock_lock (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+#define gl_lock_unlock(NAME) \
+ do \
+ { \
+ if (glthread_lock_unlock (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+#define gl_lock_destroy(NAME) \
+ do \
+ { \
+ if (glthread_lock_destroy (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+#define gl_rwlock_init(NAME) \
+ do \
+ { \
+ if (glthread_rwlock_init (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+#define gl_rwlock_rdlock(NAME) \
+ do \
+ { \
+ if (glthread_rwlock_rdlock (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+#define gl_rwlock_wrlock(NAME) \
+ do \
+ { \
+ if (glthread_rwlock_wrlock (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+#define gl_rwlock_unlock(NAME) \
+ do \
+ { \
+ if (glthread_rwlock_unlock (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+#define gl_rwlock_destroy(NAME) \
+ do \
+ { \
+ if (glthread_rwlock_destroy (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+#define gl_recursive_lock_init(NAME) \
+ do \
+ { \
+ if (glthread_recursive_lock_init (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+#define gl_recursive_lock_lock(NAME) \
+ do \
+ { \
+ if (glthread_recursive_lock_lock (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+#define gl_recursive_lock_unlock(NAME) \
+ do \
+ { \
+ if (glthread_recursive_lock_unlock (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+#define gl_recursive_lock_destroy(NAME) \
+ do \
+ { \
+ if (glthread_recursive_lock_destroy (&NAME)) \
+ abort (); \
+ } \
+ while (0)
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+#define gl_once(NAME, INITFUNCTION) \
+ do \
+ { \
+ if (glthread_once (&NAME, INITFUNCTION)) \
+ abort (); \
+ } \
+ while (0)
+
+/* ========================================================================= */
+
+#endif /* _LOCK_H */
diff --git a/grub-core/lib/gnulib/glthread/threadlib.c b/grub-core/lib/gnulib/glthread/threadlib.c
new file mode 100644
index 0000000..a5ebd9b
--- /dev/null
+++ b/grub-core/lib/gnulib/glthread/threadlib.c
@@ -0,0 +1,73 @@
+/* Multithreading primitives.
+ Copyright (C) 2005-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005. */
+
+#include <config.h>
+
+/* ========================================================================= */
+
+#if USE_POSIX_THREADS
+
+/* Use the POSIX threads library. */
+
+# include <pthread.h>
+# include <stdlib.h>
+
+# if PTHREAD_IN_USE_DETECTION_HARD
+
+/* The function to be executed by a dummy thread. */
+static void *
+dummy_thread_func (void *arg)
+{
+ return arg;
+}
+
+int
+glthread_in_use (void)
+{
+ static int tested;
+ static int result; /* 1: linked with -lpthread, 0: only with libc */
+
+ if (!tested)
+ {
+ pthread_t thread;
+
+ if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
+ /* Thread creation failed. */
+ result = 0;
+ else
+ {
+ /* Thread creation works. */
+ void *retval;
+ if (pthread_join (thread, &retval) != 0)
+ abort ();
+ result = 1;
+ }
+ tested = 1;
+ }
+ return result;
+}
+
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+/* This declaration is solely to ensure that after preprocessing
+ this file is never empty. */
+typedef int dummy;
diff --git a/grub-core/lib/gnulib/hard-locale.c b/grub-core/lib/gnulib/hard-locale.c
new file mode 100644
index 0000000..dcfcad6
--- /dev/null
+++ b/grub-core/lib/gnulib/hard-locale.c
@@ -0,0 +1,72 @@
+/* hard-locale.c -- Determine whether a locale is hard.
+
+ Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "hard-locale.h"
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __GLIBC__
+# define GLIBC_VERSION __GLIBC__
+#elif defined __UCLIBC__
+# define GLIBC_VERSION 2
+#else
+# define GLIBC_VERSION 0
+#endif
+
+/* Return true if the current CATEGORY locale is hard, i.e. if you
+ can't get away with assuming traditional C or POSIX behavior. */
+bool
+hard_locale (int category)
+{
+ bool hard = true;
+ char const *p = setlocale (category, NULL);
+
+ if (p)
+ {
+ if (2 <= GLIBC_VERSION)
+ {
+ if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
+ hard = false;
+ }
+ else
+ {
+ char *locale = strdup (p);
+ if (locale)
+ {
+ /* Temporarily set the locale to the "C" and "POSIX" locales
+ to find their names, so that we can determine whether one
+ or the other is the caller's locale. */
+ if (((p = setlocale (category, "C"))
+ && strcmp (p, locale) == 0)
+ || ((p = setlocale (category, "POSIX"))
+ && strcmp (p, locale) == 0))
+ hard = false;
+
+ /* Restore the caller's locale. */
+ setlocale (category, locale);
+ free (locale);
+ }
+ }
+ }
+
+ return hard;
+}
diff --git a/grub-core/lib/gnulib/hard-locale.h b/grub-core/lib/gnulib/hard-locale.h
new file mode 100644
index 0000000..8f1da96
--- /dev/null
+++ b/grub-core/lib/gnulib/hard-locale.h
@@ -0,0 +1,25 @@
+/* Determine whether a locale is hard.
+
+ Copyright (C) 1999, 2003-2004, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef HARD_LOCALE_H_
+# define HARD_LOCALE_H_ 1
+
+# include <stdbool.h>
+
+bool hard_locale (int);
+
+#endif /* HARD_LOCALE_H_ */
diff --git a/grub-core/lib/gnulib/intprops.h b/grub-core/lib/gnulib/intprops.h
new file mode 100644
index 0000000..1a44ae5
--- /dev/null
+++ b/grub-core/lib/gnulib/intprops.h
@@ -0,0 +1,455 @@
+/* intprops.h -- properties of integer types
+
+ Copyright (C) 2001-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#ifndef _GL_INTPROPS_H
+#define _GL_INTPROPS_H
+
+#include <limits.h>
+
+/* Return a value with the common real type of E and V and the value of V.
+ Do not evaluate E. */
+#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
+
+/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
+ <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
+#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v))
+
+/* The extra casts in the following macros work around compiler bugs,
+ e.g., in Cray C 5.0.3.0. */
+
+/* True if the arithmetic type T is an integer type. bool counts as
+ an integer. */
+#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
+
+/* True if the real type T is signed. */
+#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+
+/* Return 1 if the real expression E, after promotion, has a
+ signed or floating type. Do not evaluate E. */
+#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
+
+
+/* Minimum and maximum values for integer types and expressions. */
+
+/* The width in bits of the integer type or expression T.
+ Do not evaluate T.
+ Padding bits are not supported; this is checked at compile-time below. */
+#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
+
+/* The maximum and minimum values for the integer type T. */
+#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
+#define TYPE_MAXIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) -1 \
+ : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
+
+/* The maximum and minimum values for the type of the expression E,
+ after integer promotion. E is not evaluated. */
+#define _GL_INT_MINIMUM(e) \
+ (EXPR_SIGNED (e) \
+ ? ~ _GL_SIGNED_INT_MAXIMUM (e) \
+ : _GL_INT_CONVERT (e, 0))
+#define _GL_INT_MAXIMUM(e) \
+ (EXPR_SIGNED (e) \
+ ? _GL_SIGNED_INT_MAXIMUM (e) \
+ : _GL_INT_NEGATE_CONVERT (e, 1))
+#define _GL_SIGNED_INT_MAXIMUM(e) \
+ (((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH ((e) + 0) - 2)) - 1) * 2 + 1)
+
+/* Work around OpenVMS incompatibility with C99. */
+#if !defined LLONG_MAX && defined __INT64_MAX
+# define LLONG_MAX __INT64_MAX
+# define LLONG_MIN __INT64_MIN
+#endif
+
+/* This include file assumes that signed types are two's complement without
+ padding bits; the above macros have undefined behavior otherwise.
+ If this is a problem for you, please let us know how to fix it for your host.
+ This assumption is tested by the intprops-tests module. */
+
+/* Does the __typeof__ keyword work? This could be done by
+ 'configure', but for now it's easier to do it by hand. */
+#if (2 <= __GNUC__ \
+ || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
+ || (0x5110 <= __SUNPRO_C && !__STDC__))
+# define _GL_HAVE___TYPEOF__ 1
+#else
+# define _GL_HAVE___TYPEOF__ 0
+#endif
+
+/* Return 1 if the integer type or expression T might be signed. Return 0
+ if it is definitely unsigned. This macro does not evaluate its argument,
+ and expands to an integer constant expression. */
+#if _GL_HAVE___TYPEOF__
+# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
+#else
+# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
+#endif
+
+/* Bound on length of the string representing an unsigned integer
+ value representable in B bits. log10 (2.0) < 146/485. The
+ smallest value of B where this bound is not tight is 2621. */
+#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
+
+/* Bound on length of the string representing an integer type or expression T.
+ Subtract 1 for the sign bit if T is signed, and then add 1 more for
+ a minus sign if needed.
+
+ Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is
+ signed, this macro may overestimate the true bound by one byte when
+ applied to unsigned types of size 2, 4, 16, ... bytes. */
+#define INT_STRLEN_BOUND(t) \
+ (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
+ + _GL_SIGNED_TYPE_OR_EXPR (t))
+
+/* Bound on buffer size needed to represent an integer type or expression T,
+ including the terminating null. */
+#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
+
+
+/* Range overflow checks.
+
+ The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
+ operators might not yield numerically correct answers due to
+ arithmetic overflow. They do not rely on undefined or
+ implementation-defined behavior. Their implementations are simple
+ and straightforward, but they are a bit harder to use than the
+ INT_<op>_OVERFLOW macros described below.
+
+ Example usage:
+
+ long int i = ...;
+ long int j = ...;
+ if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX))
+ printf ("multiply would overflow");
+ else
+ printf ("product is %ld", i * j);
+
+ Restrictions on *_RANGE_OVERFLOW macros:
+
+ These macros do not check for all possible numerical problems or
+ undefined or unspecified behavior: they do not check for division
+ by zero, for bad shift counts, or for shifting negative numbers.
+
+ These macros may evaluate their arguments zero or multiple times,
+ so the arguments should not have side effects. The arithmetic
+ arguments (including the MIN and MAX arguments) must be of the same
+ integer type after the usual arithmetic conversions, and the type
+ must have minimum value MIN and maximum MAX. Unsigned types should
+ use a zero MIN of the proper type.
+
+ These macros are tuned for constant MIN and MAX. For commutative
+ operations such as A + B, they are also tuned for constant B. */
+
+/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. */
+#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \
+ ((b) < 0 \
+ ? (a) < (min) - (b) \
+ : (max) - (b) < (a))
+
+/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. */
+#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \
+ ((b) < 0 \
+ ? (max) + (b) < (a) \
+ : (a) < (min) + (b))
+
+/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. */
+#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
+ ((min) < 0 \
+ ? (a) < - (max) \
+ : 0 < (a))
+
+/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. Avoid && and || as they tickle
+ bugs in Sun C 5.11 2010/08/13 and other compilers; see
+ <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */
+#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
+ ((b) < 0 \
+ ? ((a) < 0 \
+ ? (a) < (max) / (b) \
+ : (b) == -1 \
+ ? 0 \
+ : (min) / (b) < (a)) \
+ : (b) == 0 \
+ ? 0 \
+ : ((a) < 0 \
+ ? (a) < (min) / (b) \
+ : (max) / (b) < (a)))
+
+/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. Do not check for division by zero. */
+#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \
+ ((min) < 0 && (b) == -1 && (a) < - (max))
+
+/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. Do not check for division by zero.
+ Mathematically, % should never overflow, but on x86-like hosts
+ INT_MIN % -1 traps, and the C standard permits this, so treat this
+ as an overflow too. */
+#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \
+ INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max)
+
+/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic.
+ See above for restrictions. Here, MIN and MAX are for A only, and B need
+ not be of the same type as the other arguments. The C standard says that
+ behavior is undefined for shifts unless 0 <= B < wordwidth, and that when
+ A is negative then A << B has undefined behavior and A >> B has
+ implementation-defined behavior, but do not check these other
+ restrictions. */
+#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
+ ((a) < 0 \
+ ? (a) < (min) >> (b) \
+ : (max) >> (b) < (a))
+
+/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */
+#if 5 <= __GNUC__ && !defined __ICC
+# define _GL_HAS_BUILTIN_OVERFLOW 1
+#else
+# define _GL_HAS_BUILTIN_OVERFLOW 0
+#endif
+
+/* True if __builtin_add_overflow_p (A, B, C) works. */
+#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
+
+/* The _GL*_OVERFLOW macros have the same restrictions as the
+ *_RANGE_OVERFLOW macros, except that they do not assume that operands
+ (e.g., A and B) have the same type as MIN and MAX. Instead, they assume
+ that the result (e.g., A + B) has that type. */
+#if _GL_HAS_BUILTIN_OVERFLOW_P
+# define _GL_ADD_OVERFLOW(a, b, min, max) \
+ __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
+ __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
+ __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
+#else
+# define _GL_ADD_OVERFLOW(a, b, min, max) \
+ ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
+ : (a) < 0 ? (b) <= (a) + (b) \
+ : (b) < 0 ? (a) <= (a) + (b) \
+ : (a) + (b) < (b))
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
+ ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
+ : (a) < 0 ? 1 \
+ : (b) < 0 ? (a) - (b) <= (a) \
+ : (a) < (b))
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
+ (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
+ || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
+#endif
+#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
+ ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
+ : (a) < 0 ? (b) <= (a) + (b) - 1 \
+ : (b) < 0 && (a) + (b) <= (a))
+#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
+ ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
+ : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
+ : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
+
+/* Return a nonzero value if A is a mathematical multiple of B, where
+ A is unsigned, B is negative, and MAX is the maximum value of A's
+ type. A's type must be the same as (A % B)'s type. Normally (A %
+ -B == 0) suffices, but things get tricky if -B would overflow. */
+#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \
+ (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \
+ ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \
+ ? (a) \
+ : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \
+ : (a) % - (b)) \
+ == 0)
+
+/* Check for integer overflow, and report low order bits of answer.
+
+ The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
+ might not yield numerically correct answers due to arithmetic overflow.
+ The INT_<op>_WRAPV macros also store the low-order bits of the answer.
+ These macros work correctly on all known practical hosts, and do not rely
+ on undefined behavior due to signed arithmetic overflow.
+
+ Example usage, assuming A and B are long int:
+
+ if (INT_MULTIPLY_OVERFLOW (a, b))
+ printf ("result would overflow\n");
+ else
+ printf ("result is %ld (no overflow)\n", a * b);
+
+ Example usage with WRAPV flavor:
+
+ long int result;
+ bool overflow = INT_MULTIPLY_WRAPV (a, b, &result);
+ printf ("result is %ld (%s)\n", result,
+ overflow ? "after overflow" : "no overflow");
+
+ Restrictions on these macros:
+
+ These macros do not check for all possible numerical problems or
+ undefined or unspecified behavior: they do not check for division
+ by zero, for bad shift counts, or for shifting negative numbers.
+
+ These macros may evaluate their arguments zero or multiple times, so the
+ arguments should not have side effects.
+
+ The WRAPV macros are not constant expressions. They support only
+ +, binary -, and *. The result type must be signed.
+
+ These macros are tuned for their last argument being a constant.
+
+ Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
+ A % B, and A << B would overflow, respectively. */
+
+#define INT_ADD_OVERFLOW(a, b) \
+ _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
+#define INT_SUBTRACT_OVERFLOW(a, b) \
+ _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
+#if _GL_HAS_BUILTIN_OVERFLOW_P
+# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
+#else
+# define INT_NEGATE_OVERFLOW(a) \
+ INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#endif
+#define INT_MULTIPLY_OVERFLOW(a, b) \
+ _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
+#define INT_DIVIDE_OVERFLOW(a, b) \
+ _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW)
+#define INT_REMAINDER_OVERFLOW(a, b) \
+ _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW)
+#define INT_LEFT_SHIFT_OVERFLOW(a, b) \
+ INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \
+ _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+
+/* Return 1 if the expression A <op> B would overflow,
+ where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test,
+ assuming MIN and MAX are the minimum and maximum for the result type.
+ Arguments should be free of side effects. */
+#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
+ op_result_overflow (a, b, \
+ _GL_INT_MINIMUM (_GL_INT_CONVERT (a, b)), \
+ _GL_INT_MAXIMUM (_GL_INT_CONVERT (a, b)))
+
+/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
+ Return 1 if the result overflows. See above for restrictions. */
+#define INT_ADD_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW)
+#define INT_SUBTRACT_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, INT_SUBTRACT_OVERFLOW)
+#define INT_MULTIPLY_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW)
+
+/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
+ https://llvm.org/bugs/show_bug.cgi?id=25390
+ For now, assume all versions of GCC-like compilers generate bogus
+ warnings for _Generic. This matters only for older compilers that
+ lack __builtin_add_overflow. */
+#if __GNUC__
+# define _GL__GENERIC_BOGUS 1
+#else
+# define _GL__GENERIC_BOGUS 0
+#endif
+
+/* Store the low-order bits of A <op> B into *R, where OP specifies
+ the operation. BUILTIN is the builtin operation, and OVERFLOW the
+ overflow predicate. Return 1 if the result overflows. See above
+ for restrictions. */
+#if _GL_HAS_BUILTIN_OVERFLOW
+# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
+#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
+# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
+ (_Generic \
+ (*(r), \
+ signed char: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ signed char, SCHAR_MIN, SCHAR_MAX), \
+ short int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ short int, SHRT_MIN, SHRT_MAX), \
+ int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ int, INT_MIN, INT_MAX), \
+ long int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX), \
+ long long int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
+ long long int, LLONG_MIN, LLONG_MAX)))
+#else
+# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
+ (sizeof *(r) == sizeof (signed char) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ signed char, SCHAR_MIN, SCHAR_MAX) \
+ : sizeof *(r) == sizeof (short int) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ short int, SHRT_MIN, SHRT_MAX) \
+ : sizeof *(r) == sizeof (int) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ int, INT_MIN, INT_MAX) \
+ : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
+# ifdef LLONG_MAX
+# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
+ (sizeof *(r) == sizeof (long int) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX) \
+ : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
+ long long int, LLONG_MIN, LLONG_MAX))
+# else
+# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX)
+# endif
+#endif
+
+/* Store the low-order bits of A <op> B into *R, where the operation
+ is given by OP. Use the unsigned type UT for calculation to avoid
+ overflow problems. *R's type is T, with extrema TMIN and TMAX.
+ T must be a signed integer type. Return 1 if the result overflows. */
+#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
+ (sizeof ((a) op (b)) < sizeof (t) \
+ ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
+ : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax))
+#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \
+ ((overflow (a, b) \
+ || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
+ || (tmax) < ((a) op (b))) \
+ ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
+ : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
+
+/* Return the low-order bits of A <op> B, where the operation is given
+ by OP. Use the unsigned type UT for calculation to avoid undefined
+ behavior on signed integer overflow, and convert the result to type T.
+ UT is at least as wide as T and is no narrower than unsigned int,
+ T is two's complement, and there is no padding or trap representations.
+ Assume that converting UT to T yields the low-order bits, as is
+ done in all known two's-complement C compilers. E.g., see:
+ https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
+
+ According to the C standard, converting UT to T yields an
+ implementation-defined result or signal for values outside T's
+ range. However, code that works around this theoretical problem
+ runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
+ https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
+ As the compiler bug is real, don't try to work around the
+ theoretical problem. */
+
+#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
+ ((t) ((ut) (a) op (ut) (b)))
+
+#endif /* _GL_INTPROPS_H */
diff --git a/grub-core/lib/gnulib/itold.c b/grub-core/lib/gnulib/itold.c
new file mode 100644
index 0000000..bca01eb
--- /dev/null
+++ b/grub-core/lib/gnulib/itold.c
@@ -0,0 +1,28 @@
+/* Replacement for 'int' to 'long double' conversion routine.
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <float.h>
+
+void
+_Qp_itoq (long double *result, int a)
+{
+ /* Convert from 'int' to 'double', then from 'double' to 'long double'. */
+ *result = (double) a;
+}
diff --git a/grub-core/lib/gnulib/langinfo.in.h b/grub-core/lib/gnulib/langinfo.in.h
new file mode 100644
index 0000000..6d40635
--- /dev/null
+++ b/grub-core/lib/gnulib/langinfo.in.h
@@ -0,0 +1,222 @@
+/* Substitute for and wrapper around <langinfo.h>.
+ Copyright (C) 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/*
+ * POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
+ * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
+ */
+
+#ifndef _@GUARD_PREFIX@_LANGINFO_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_LANGINFO_H@
+# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@
+#endif
+
+#ifndef _@GUARD_PREFIX@_LANGINFO_H
+#define _@GUARD_PREFIX@_LANGINFO_H
+
+
+#if !@HAVE_LANGINFO_H@
+
+/* A platform that lacks <langinfo.h>. */
+
+/* Assume that it also lacks <nl_types.h> and the nl_item type. */
+# if !GNULIB_defined_nl_item
+typedef int nl_item;
+# define GNULIB_defined_nl_item 1
+# endif
+
+/* nl_langinfo items of the LC_CTYPE category */
+# define CODESET 10000
+/* nl_langinfo items of the LC_NUMERIC category */
+# define RADIXCHAR 10001
+# define DECIMAL_POINT RADIXCHAR
+# define THOUSEP 10002
+# define THOUSANDS_SEP THOUSEP
+# define GROUPING 10114
+/* nl_langinfo items of the LC_TIME category */
+# define D_T_FMT 10003
+# define D_FMT 10004
+# define T_FMT 10005
+# define T_FMT_AMPM 10006
+# define AM_STR 10007
+# define PM_STR 10008
+# define DAY_1 10009
+# define DAY_2 (DAY_1 + 1)
+# define DAY_3 (DAY_1 + 2)
+# define DAY_4 (DAY_1 + 3)
+# define DAY_5 (DAY_1 + 4)
+# define DAY_6 (DAY_1 + 5)
+# define DAY_7 (DAY_1 + 6)
+# define ABDAY_1 10016
+# define ABDAY_2 (ABDAY_1 + 1)
+# define ABDAY_3 (ABDAY_1 + 2)
+# define ABDAY_4 (ABDAY_1 + 3)
+# define ABDAY_5 (ABDAY_1 + 4)
+# define ABDAY_6 (ABDAY_1 + 5)
+# define ABDAY_7 (ABDAY_1 + 6)
+# define MON_1 10023
+# define MON_2 (MON_1 + 1)
+# define MON_3 (MON_1 + 2)
+# define MON_4 (MON_1 + 3)
+# define MON_5 (MON_1 + 4)
+# define MON_6 (MON_1 + 5)
+# define MON_7 (MON_1 + 6)
+# define MON_8 (MON_1 + 7)
+# define MON_9 (MON_1 + 8)
+# define MON_10 (MON_1 + 9)
+# define MON_11 (MON_1 + 10)
+# define MON_12 (MON_1 + 11)
+# define ALTMON_1 10200
+# define ALTMON_2 (ALTMON_1 + 1)
+# define ALTMON_3 (ALTMON_1 + 2)
+# define ALTMON_4 (ALTMON_1 + 3)
+# define ALTMON_5 (ALTMON_1 + 4)
+# define ALTMON_6 (ALTMON_1 + 5)
+# define ALTMON_7 (ALTMON_1 + 6)
+# define ALTMON_8 (ALTMON_1 + 7)
+# define ALTMON_9 (ALTMON_1 + 8)
+# define ALTMON_10 (ALTMON_1 + 9)
+# define ALTMON_11 (ALTMON_1 + 10)
+# define ALTMON_12 (ALTMON_1 + 11)
+# define ABMON_1 10035
+# define ABMON_2 (ABMON_1 + 1)
+# define ABMON_3 (ABMON_1 + 2)
+# define ABMON_4 (ABMON_1 + 3)
+# define ABMON_5 (ABMON_1 + 4)
+# define ABMON_6 (ABMON_1 + 5)
+# define ABMON_7 (ABMON_1 + 6)
+# define ABMON_8 (ABMON_1 + 7)
+# define ABMON_9 (ABMON_1 + 8)
+# define ABMON_10 (ABMON_1 + 9)
+# define ABMON_11 (ABMON_1 + 10)
+# define ABMON_12 (ABMON_1 + 11)
+# define ERA 10047
+# define ERA_D_FMT 10048
+# define ERA_D_T_FMT 10049
+# define ERA_T_FMT 10050
+# define ALT_DIGITS 10051
+/* nl_langinfo items of the LC_MONETARY category */
+# define CRNCYSTR 10052
+# define CURRENCY_SYMBOL CRNCYSTR
+# define INT_CURR_SYMBOL 10100
+# define MON_DECIMAL_POINT 10101
+# define MON_THOUSANDS_SEP 10102
+# define MON_GROUPING 10103
+# define POSITIVE_SIGN 10104
+# define NEGATIVE_SIGN 10105
+# define FRAC_DIGITS 10106
+# define INT_FRAC_DIGITS 10107
+# define P_CS_PRECEDES 10108
+# define N_CS_PRECEDES 10109
+# define P_SEP_BY_SPACE 10110
+# define N_SEP_BY_SPACE 10111
+# define P_SIGN_POSN 10112
+# define N_SIGN_POSN 10113
+/* nl_langinfo items of the LC_MESSAGES category */
+# define YESEXPR 10053
+# define NOEXPR 10054
+
+#else
+
+/* A platform that has <langinfo.h>. */
+
+# if !@HAVE_LANGINFO_CODESET@
+# define CODESET 10000
+# define GNULIB_defined_CODESET 1
+# endif
+
+# if !@HAVE_LANGINFO_T_FMT_AMPM@
+# define T_FMT_AMPM 10006
+# define GNULIB_defined_T_FMT_AMPM 1
+# endif
+
+# if !@HAVE_LANGINFO_ALTMON@
+# define ALTMON_1 10200
+# define ALTMON_2 (ALTMON_1 + 1)
+# define ALTMON_3 (ALTMON_1 + 2)
+# define ALTMON_4 (ALTMON_1 + 3)
+# define ALTMON_5 (ALTMON_1 + 4)
+# define ALTMON_6 (ALTMON_1 + 5)
+# define ALTMON_7 (ALTMON_1 + 6)
+# define ALTMON_8 (ALTMON_1 + 7)
+# define ALTMON_9 (ALTMON_1 + 8)
+# define ALTMON_10 (ALTMON_1 + 9)
+# define ALTMON_11 (ALTMON_1 + 10)
+# define ALTMON_12 (ALTMON_1 + 11)
+# define GNULIB_defined_ALTMON 1
+# endif
+
+# if !@HAVE_LANGINFO_ERA@
+# define ERA 10047
+# define ERA_D_FMT 10048
+# define ERA_D_T_FMT 10049
+# define ERA_T_FMT 10050
+# define ALT_DIGITS 10051
+# define GNULIB_defined_ERA 1
+# endif
+
+# if !@HAVE_LANGINFO_YESEXPR@
+# define YESEXPR 10053
+# define NOEXPR 10054
+# define GNULIB_defined_YESEXPR 1
+# endif
+
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+/* Declare overridden functions. */
+
+
+/* Return a piece of locale dependent information.
+ Note: The difference between nl_langinfo (CODESET) and locale_charset ()
+ is that the latter normalizes the encoding names to GNU conventions. */
+
+#if @GNULIB_NL_LANGINFO@
+# if @REPLACE_NL_LANGINFO@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef nl_langinfo
+# define nl_langinfo rpl_nl_langinfo
+# endif
+_GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item));
+_GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item));
+# else
+# if !@HAVE_NL_LANGINFO@
+_GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item));
+# endif
+_GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item));
+# endif
+_GL_CXXALIASWARN (nl_langinfo);
+#elif defined GNULIB_POSIXCHECK
+# undef nl_langinfo
+# if HAVE_RAW_DECL_NL_LANGINFO
+_GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - "
+ "use gnulib module nl_langinfo for portability");
+# endif
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_LANGINFO_H */
+#endif /* _@GUARD_PREFIX@_LANGINFO_H */
diff --git a/grub-core/lib/gnulib/libc-config.h b/grub-core/lib/gnulib/libc-config.h
new file mode 100644
index 0000000..57c6966
--- /dev/null
+++ b/grub-core/lib/gnulib/libc-config.h
@@ -0,0 +1,174 @@
+/* System definitions for code taken from the GNU C Library
+
+ Copyright 2017-2019 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
+ <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+/* This is intended to be a good-enough substitute for glibc system
+ macros like those defined in <sys/cdefs.h>, so that Gnulib code
+ shared with glibc can do this as the first #include:
+
+ #ifndef _LIBC
+ # include <libc-config.h>
+ #endif
+
+ When compiled as part of glibc this is a no-op; when compiled as
+ part of Gnulib this includes Gnulib's <config.h> and defines macros
+ that glibc library code would normally assume. */
+
+#include <config.h>
+
+/* On glibc this includes <features.h> and <sys/cdefs.h> and #defines
+ _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 it
+ includes <sys/cdefs.h> which defines __nonnull. Elsewhere it
+ is harmless. */
+#include <errno.h>
+
+/* From glibc <errno.h>. */
+#ifndef __set_errno
+# define __set_errno(val) (errno = (val))
+#endif
+
+/* From glibc <features.h>. */
+
+#ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
+# else
+# define __GNUC_PREREQ(maj, min) 0
+# endif
+#endif
+
+#ifndef __glibc_clang_prereq
+# if defined __clang_major__ && defined __clang_minor__
+# define __glibc_clang_prereq(maj, min) \
+ ((maj) < __clang_major__ + ((min) <= __clang_minor__))
+# else
+# define __glibc_clang_prereq(maj, min) 0
+# endif
+#endif
+
+
+/* Prepare to include <cdefs.h>, which is our copy of glibc
+ <sys/cdefs.h>. */
+
+/* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */
+#ifndef _FEATURES_H
+# define _FEATURES_H 1
+#endif
+/* Define __WORDSIZE so that <cdefs.h> does not attempt to include
+ nonexistent files. Make it a syntax error, since Gnulib does not
+ use __WORDSIZE now, and if Gnulib uses it later the syntax error
+ will let us know that __WORDSIZE needs configuring. */
+#ifndef __WORDSIZE
+# define __WORDSIZE %%%
+#endif
+/* Undef the macros unconditionally defined by our copy of glibc
+ <sys/cdefs.h>, so that they do not clash with any system-defined
+ versions. */
+#undef _SYS_CDEFS_H
+#undef __ASMNAME
+#undef __ASMNAME2
+#undef __BEGIN_DECLS
+#undef __CONCAT
+#undef __END_DECLS
+#undef __HAVE_GENERIC_SELECTION
+#undef __LDBL_COMPAT
+#undef __LDBL_REDIR
+#undef __LDBL_REDIR1
+#undef __LDBL_REDIR1_DECL
+#undef __LDBL_REDIR1_NTH
+#undef __LDBL_REDIR_DECL
+#undef __LDBL_REDIR_NTH
+#undef __LEAF
+#undef __LEAF_ATTR
+#undef __NTH
+#undef __NTHNL
+#undef __P
+#undef __PMT
+#undef __REDIRECT
+#undef __REDIRECT_LDBL
+#undef __REDIRECT_NTH
+#undef __REDIRECT_NTHNL
+#undef __REDIRECT_NTH_LDBL
+#undef __STRING
+#undef __THROW
+#undef __THROWNL
+#undef __always_inline
+#undef __attribute__
+#undef __attribute_alloc_size__
+#undef __attribute_artificial__
+#undef __attribute_const__
+#undef __attribute_deprecated__
+#undef __attribute_deprecated_msg__
+#undef __attribute_format_arg__
+#undef __attribute_format_strfmon__
+#undef __attribute_malloc__
+#undef __attribute_noinline__
+#undef __attribute_nonstring__
+#undef __attribute_pure__
+#undef __attribute_used__
+#undef __attribute_warn_unused_result__
+#undef __bos
+#undef __bos0
+#undef __errordecl
+#undef __extension__
+#undef __extern_always_inline
+#undef __extern_inline
+#undef __flexarr
+#undef __fortify_function
+#undef __glibc_c99_flexarr_available
+#undef __glibc_clang_has_extension
+#undef __glibc_likely
+#undef __glibc_macro_warning
+#undef __glibc_macro_warning1
+#undef __glibc_unlikely
+#undef __inline
+#undef __ptr_t
+#undef __restrict
+#undef __restrict_arr
+#undef __va_arg_pack
+#undef __va_arg_pack_len
+#undef __warnattr
+#undef __warndecl
+
+/* Include our copy of glibc <sys/cdefs.h>. */
+#include <cdefs.h>
+
+/* <cdefs.h> __inline is too pessimistic for non-GCC. */
+#undef __inline
+#ifndef HAVE___INLINE
+# if 199901 <= __STDC_VERSION__ || defined inline
+# define __inline inline
+# else
+# define __inline
+# endif
+#endif
+
+
+/* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
+#define attribute_hidden
+#define libc_hidden_proto(name, ...)
+#define libc_hidden_def(name)
+#define libc_hidden_weak(name)
+#define libc_hidden_ver(local, name)
+#define strong_alias(name, aliasname)
+#define weak_alias(name, aliasname)
+
+/* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
+#define SHLIB_COMPAT(lib, introduced, obsoleted) 0
+#define versioned_symbol(lib, local, symbol, version)
diff --git a/grub-core/lib/gnulib/limits.in.h b/grub-core/lib/gnulib/limits.in.h
new file mode 100644
index 0000000..39750b3
--- /dev/null
+++ b/grub-core/lib/gnulib/limits.in.h
@@ -0,0 +1,104 @@
+/* A GNU-like <limits.h>.
+
+ Copyright 2016-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_LIMITS_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_LIMITS_H@
+
+#ifndef _@GUARD_PREFIX@_LIMITS_H
+#define _@GUARD_PREFIX@_LIMITS_H
+
+#ifndef LLONG_MIN
+# if defined LONG_LONG_MIN /* HP-UX 11.31 */
+# define LLONG_MIN LONG_LONG_MIN
+# elif defined LONGLONG_MIN /* IRIX 6.5 */
+# define LLONG_MIN LONGLONG_MIN
+# elif defined __GNUC__
+# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL)
+# endif
+#endif
+#ifndef LLONG_MAX
+# if defined LONG_LONG_MAX /* HP-UX 11.31 */
+# define LLONG_MAX LONG_LONG_MAX
+# elif defined LONGLONG_MAX /* IRIX 6.5 */
+# define LLONG_MAX LONGLONG_MAX
+# elif defined __GNUC__
+# define LLONG_MAX __LONG_LONG_MAX__
+# endif
+#endif
+#ifndef ULLONG_MAX
+# if defined ULONG_LONG_MAX /* HP-UX 11.31 */
+# define ULLONG_MAX ULONG_LONG_MAX
+# elif defined ULONGLONG_MAX /* IRIX 6.5 */
+# define ULLONG_MAX ULONGLONG_MAX
+# elif defined __GNUC__
+# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL)
+# endif
+#endif
+
+/* The number of usable bits in an unsigned or signed integer type
+ with minimum value MIN and maximum value MAX, as an int expression
+ suitable in #if. Cover all known practical hosts. This
+ implementation exploits the fact that MAX is 1 less than a power of
+ 2, and merely counts the number of 1 bits in MAX; "COBn" means
+ "count the number of 1 bits in the low-order n bits"). */
+#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
+#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
+#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
+#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
+#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
+#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
+#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
+
+#ifndef WORD_BIT
+/* Assume 'int' is 32 bits wide. */
+# define WORD_BIT 32
+#endif
+#ifndef LONG_BIT
+/* Assume 'long' is 32 or 64 bits wide. */
+# if LONG_MAX == INT_MAX
+# define LONG_BIT 32
+# else
+# define LONG_BIT 64
+# endif
+#endif
+
+/* Macros specified by ISO/IEC TS 18661-1:2014. */
+
+#if (! defined ULLONG_WIDTH \
+ && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
+# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
+# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
+# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
+# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
+# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
+# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
+# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
+# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
+# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
+# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
+# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
+#endif /* !ULLONG_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
+
+#endif /* _@GUARD_PREFIX@_LIMITS_H */
+#endif /* _@GUARD_PREFIX@_LIMITS_H */
diff --git a/grub-core/lib/gnulib/localcharset.c b/grub-core/lib/gnulib/localcharset.c
new file mode 100644
index 0000000..38e27e6
--- /dev/null
+++ b/grub-core/lib/gnulib/localcharset.c
@@ -0,0 +1,996 @@
+/* Determine a canonical name for the current locale's character encoding.
+
+ Copyright (C) 2000-2006, 2008-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "localcharset.h"
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET
+# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */
+#endif
+
+#if defined _WIN32 && !defined __CYGWIN__
+# define WINDOWS_NATIVE
+# include <locale.h>
+#endif
+
+#if defined __EMX__
+/* Assume EMX program runs on OS/2, even if compiled under DOS. */
+# ifndef OS2
+# define OS2
+# endif
+#endif
+
+#if !defined WINDOWS_NATIVE
+# if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+# else
+# if 0 /* see comment regarding use of setlocale(), below */
+# include <locale.h>
+# endif
+# endif
+# ifdef __CYGWIN__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# endif
+#elif defined WINDOWS_NATIVE
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+#if defined OS2
+# define INCL_DOS
+# include <os2.h>
+#endif
+
+/* For MB_CUR_MAX_L */
+#if defined DARWIN7
+# include <xlocale.h>
+#endif
+
+
+#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
+
+/* On these platforms, we use a mapping from non-canonical encoding name
+ to GNU canonical encoding name. */
+
+/* With glibc-2.1 or newer, we don't need any canonicalization,
+ because glibc has iconv and both glibc and libiconv support all
+ GNU canonical names directly. */
+# if !((defined __GNU_LIBRARY__ && __GLIBC__ >= 2) || defined __UCLIBC__)
+
+struct table_entry
+{
+ const char alias[11+1];
+ const char canonical[11+1];
+};
+
+/* Table of platform-dependent mappings, sorted in ascending order. */
+static const struct table_entry alias_table[] =
+ {
+# if defined __FreeBSD__ /* FreeBSD */
+ /*{ "ARMSCII-8", "ARMSCII-8" },*/
+ { "Big5", "BIG5" },
+ { "C", "ASCII" },
+ /*{ "CP1131", "CP1131" },*/
+ /*{ "CP1251", "CP1251" },*/
+ /*{ "CP866", "CP866" },*/
+ /*{ "GB18030", "GB18030" },*/
+ /*{ "GB2312", "GB2312" },*/
+ /*{ "GBK", "GBK" },*/
+ /*{ "ISCII-DEV", "?" },*/
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-13", "ISO-8859-13" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-9", "ISO-8859-9" },
+ /*{ "KOI8-R", "KOI8-R" },*/
+ /*{ "KOI8-U", "KOI8-U" },*/
+ { "SJIS", "SHIFT_JIS" },
+ { "US-ASCII", "ASCII" },
+ { "eucCN", "GB2312" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" }
+# define alias_table_defined
+# endif
+# if defined __NetBSD__ /* NetBSD */
+ { "646", "ASCII" },
+ /*{ "ARMSCII-8", "ARMSCII-8" },*/
+ /*{ "BIG5", "BIG5" },*/
+ { "Big5-HKSCS", "BIG5-HKSCS" },
+ /*{ "CP1251", "CP1251" },*/
+ /*{ "CP866", "CP866" },*/
+ /*{ "GB18030", "GB18030" },*/
+ /*{ "GB2312", "GB2312" },*/
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-13", "ISO-8859-13" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-4", "ISO-8859-4" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ /*{ "KOI8-R", "KOI8-R" },*/
+ /*{ "KOI8-U", "KOI8-U" },*/
+ /*{ "PT154", "PT154" },*/
+ { "SJIS", "SHIFT_JIS" },
+ { "eucCN", "GB2312" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" },
+ { "eucTW", "EUC-TW" }
+# define alias_table_defined
+# endif
+# if defined __OpenBSD__ /* OpenBSD */
+ { "646", "ASCII" },
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-13", "ISO-8859-13" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-4", "ISO-8859-4" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" }
+# define alias_table_defined
+# endif
+# if defined __APPLE__ && defined __MACH__ /* Mac OS X */
+ /* Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
+ useless:
+ - It returns the empty string when LANG is set to a locale of the
+ form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
+ LC_CTYPE file.
+ - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
+ the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
+ - The documentation says:
+ "... all code that calls BSD system routines should ensure
+ that the const *char parameters of these routines are in UTF-8
+ encoding. All BSD system functions expect their string
+ parameters to be in UTF-8 encoding and nothing else."
+ It also says
+ "An additional caveat is that string parameters for files,
+ paths, and other file-system entities must be in canonical
+ UTF-8. In a canonical UTF-8 Unicode string, all decomposable
+ characters are decomposed ..."
+ but this is not true: You can pass non-decomposed UTF-8 strings
+ to file system functions, and it is the OS which will convert
+ them to decomposed UTF-8 before accessing the file system.
+ - The Apple Terminal application displays UTF-8 by default.
+ - However, other applications are free to use different encodings:
+ - xterm uses ISO-8859-1 by default.
+ - TextEdit uses MacRoman by default.
+ We prefer UTF-8 over decomposed UTF-8-MAC because one should
+ minimize the use of decomposed Unicode. Unfortunately, through the
+ Darwin file system, decomposed UTF-8 strings are leaked into user
+ space nevertheless.
+ Then there are also the locales with encodings other than US-ASCII
+ and UTF-8. These locales can be occasionally useful to users (e.g.
+ when grepping through ISO-8859-1 encoded text files), when all their
+ file names are in US-ASCII.
+ */
+ { "ARMSCII-8", "ARMSCII-8" },
+ { "Big5", "BIG5" },
+ { "Big5HKSCS", "BIG5-HKSCS" },
+ { "CP1131", "CP1131" },
+ { "CP1251", "CP1251" },
+ { "CP866", "CP866" },
+ { "CP949", "CP949" },
+ { "GB18030", "GB18030" },
+ { "GB2312", "GB2312" },
+ { "GBK", "GBK" },
+ /*{ "ISCII-DEV", "?" },*/
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-13", "ISO-8859-13" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-4", "ISO-8859-4" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "KOI8-R", "KOI8-R" },
+ { "KOI8-U", "KOI8-U" },
+ { "PT154", "PT154" },
+ { "SJIS", "SHIFT_JIS" },
+ { "eucCN", "GB2312" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" }
+# define alias_table_defined
+# endif
+# if defined _AIX /* AIX */
+ /*{ "GBK", "GBK" },*/
+ { "IBM-1046", "CP1046" },
+ { "IBM-1124", "CP1124" },
+ { "IBM-1129", "CP1129" },
+ { "IBM-1252", "CP1252" },
+ { "IBM-850", "CP850" },
+ { "IBM-856", "CP856" },
+ { "IBM-921", "ISO-8859-13" },
+ { "IBM-922", "CP922" },
+ { "IBM-932", "CP932" },
+ { "IBM-943", "CP943" },
+ { "IBM-eucCN", "GB2312" },
+ { "IBM-eucJP", "EUC-JP" },
+ { "IBM-eucKR", "EUC-KR" },
+ { "IBM-eucTW", "EUC-TW" },
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-6", "ISO-8859-6" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-8", "ISO-8859-8" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "TIS-620", "TIS-620" },
+ /*{ "UTF-8", "UTF-8" },*/
+ { "big5", "BIG5" }
+# define alias_table_defined
+# endif
+# if defined __hpux /* HP-UX */
+ { "SJIS", "SHIFT_JIS" },
+ { "arabic8", "HP-ARABIC8" },
+ { "big5", "BIG5" },
+ { "cp1251", "CP1251" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" },
+ { "eucTW", "EUC-TW" },
+ { "gb18030", "GB18030" },
+ { "greek8", "HP-GREEK8" },
+ { "hebrew8", "HP-HEBREW8" },
+ { "hkbig5", "BIG5-HKSCS" },
+ { "hp15CN", "GB2312" },
+ { "iso88591", "ISO-8859-1" },
+ { "iso885913", "ISO-8859-13" },
+ { "iso885915", "ISO-8859-15" },
+ { "iso88592", "ISO-8859-2" },
+ { "iso88594", "ISO-8859-4" },
+ { "iso88595", "ISO-8859-5" },
+ { "iso88596", "ISO-8859-6" },
+ { "iso88597", "ISO-8859-7" },
+ { "iso88598", "ISO-8859-8" },
+ { "iso88599", "ISO-8859-9" },
+ { "kana8", "HP-KANA8" },
+ { "koi8r", "KOI8-R" },
+ { "roman8", "HP-ROMAN8" },
+ { "tis620", "TIS-620" },
+ { "turkish8", "HP-TURKISH8" },
+ { "utf8", "UTF-8" }
+# define alias_table_defined
+# endif
+# if defined __sgi /* IRIX */
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "eucCN", "GB2312" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" },
+ { "eucTW", "EUC-TW" }
+# define alias_table_defined
+# endif
+# if defined __osf__ /* OSF/1 */
+ /*{ "GBK", "GBK" },*/
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-4", "ISO-8859-4" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-8", "ISO-8859-8" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "KSC5601", "CP949" },
+ { "SJIS", "SHIFT_JIS" },
+ { "TACTIS", "TIS-620" },
+ /*{ "UTF-8", "UTF-8" },*/
+ { "big5", "BIG5" },
+ { "cp850", "CP850" },
+ { "dechanyu", "DEC-HANYU" },
+ { "dechanzi", "GB2312" },
+ { "deckanji", "DEC-KANJI" },
+ { "deckorean", "EUC-KR" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" },
+ { "eucTW", "EUC-TW" },
+ { "sdeckanji", "EUC-JP" }
+# define alias_table_defined
+# endif
+# if defined __sun /* Solaris */
+ { "5601", "EUC-KR" },
+ { "646", "ASCII" },
+ /*{ "BIG5", "BIG5" },*/
+ { "Big5-HKSCS", "BIG5-HKSCS" },
+ { "GB18030", "GB18030" },
+ /*{ "GBK", "GBK" },*/
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-11", "TIS-620" },
+ { "ISO8859-13", "ISO-8859-13" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-3", "ISO-8859-3" },
+ { "ISO8859-4", "ISO-8859-4" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-6", "ISO-8859-6" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-8", "ISO-8859-8" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "PCK", "SHIFT_JIS" },
+ { "TIS620.2533", "TIS-620" },
+ /*{ "UTF-8", "UTF-8" },*/
+ { "ansi-1251", "CP1251" },
+ { "cns11643", "EUC-TW" },
+ { "eucJP", "EUC-JP" },
+ { "gb2312", "GB2312" },
+ { "koi8-r", "KOI8-R" }
+# define alias_table_defined
+# endif
+# if defined __minix /* Minix */
+ { "646", "ASCII" }
+# define alias_table_defined
+# endif
+# if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Windows */
+ { "CP1361", "JOHAB" },
+ { "CP20127", "ASCII" },
+ { "CP20866", "KOI8-R" },
+ { "CP20936", "GB2312" },
+ { "CP21866", "KOI8-RU" },
+ { "CP28591", "ISO-8859-1" },
+ { "CP28592", "ISO-8859-2" },
+ { "CP28593", "ISO-8859-3" },
+ { "CP28594", "ISO-8859-4" },
+ { "CP28595", "ISO-8859-5" },
+ { "CP28596", "ISO-8859-6" },
+ { "CP28597", "ISO-8859-7" },
+ { "CP28598", "ISO-8859-8" },
+ { "CP28599", "ISO-8859-9" },
+ { "CP28605", "ISO-8859-15" },
+ { "CP38598", "ISO-8859-8" },
+ { "CP51932", "EUC-JP" },
+ { "CP51936", "GB2312" },
+ { "CP51949", "EUC-KR" },
+ { "CP51950", "EUC-TW" },
+ { "CP54936", "GB18030" },
+ { "CP65001", "UTF-8" },
+ { "CP936", "GBK" }
+# define alias_table_defined
+# endif
+# if defined OS2 /* OS/2 */
+ /* The list of encodings is taken from "List of OS/2 Codepages"
+ by Alex Taylor:
+ <http://altsan.org/os2/toolkits/uls/index.html#codepages>.
+ See also "IBM Globalization - Code page identifiers":
+ <https://www-01.ibm.com/software/globalization/cp/cp_cpgid.html>. */
+ { "CP1089", "ISO-8859-6" },
+ { "CP1208", "UTF-8" },
+ { "CP1381", "GB2312" },
+ { "CP1386", "GBK" },
+ { "CP3372", "EUC-JP" },
+ { "CP813", "ISO-8859-7" },
+ { "CP819", "ISO-8859-1" },
+ { "CP878", "KOI8-R" },
+ { "CP912", "ISO-8859-2" },
+ { "CP913", "ISO-8859-3" },
+ { "CP914", "ISO-8859-4" },
+ { "CP915", "ISO-8859-5" },
+ { "CP916", "ISO-8859-8" },
+ { "CP920", "ISO-8859-9" },
+ { "CP921", "ISO-8859-13" },
+ { "CP923", "ISO-8859-15" },
+ { "CP954", "EUC-JP" },
+ { "CP964", "EUC-TW" },
+ { "CP970", "EUC-KR" }
+# define alias_table_defined
+# endif
+# if defined VMS /* OpenVMS */
+ /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
+ "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
+ section 10.7 "Handling Different Character Sets". */
+ { "DECHANYU", "DEC-HANYU" },
+ { "DECHANZI", "GB2312" },
+ { "DECKANJI", "DEC-KANJI" },
+ { "DECKOREAN", "EUC-KR" },
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-8", "ISO-8859-8" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "SDECKANJI", "EUC-JP" },
+ { "SJIS", "SHIFT_JIS" },
+ { "eucJP", "EUC-JP" },
+ { "eucTW", "EUC-TW" }
+# define alias_table_defined
+# endif
+# ifndef alias_table_defined
+ /* Just a dummy entry, to avoid a C syntax error. */
+ { "", "" }
+# endif
+ };
+
+# endif
+
+#else
+
+/* On these platforms, we use a mapping from locale name to GNU canonical
+ encoding name. */
+
+struct table_entry
+{
+ const char locale[17+1];
+ const char canonical[11+1];
+};
+
+/* Table of platform-dependent mappings, sorted in ascending order. */
+static const struct table_entry locale_table[] =
+ {
+# if defined __FreeBSD__ /* FreeBSD 4.2 */
+ { "cs_CZ.ISO_8859-2", "ISO-8859-2" },
+ { "da_DK.DIS_8859-15", "ISO-8859-15" },
+ { "da_DK.ISO_8859-1", "ISO-8859-1" },
+ { "de_AT.DIS_8859-15", "ISO-8859-15" },
+ { "de_AT.ISO_8859-1", "ISO-8859-1" },
+ { "de_CH.DIS_8859-15", "ISO-8859-15" },
+ { "de_CH.ISO_8859-1", "ISO-8859-1" },
+ { "de_DE.DIS_8859-15", "ISO-8859-15" },
+ { "de_DE.ISO_8859-1", "ISO-8859-1" },
+ { "en_AU.DIS_8859-15", "ISO-8859-15" },
+ { "en_AU.ISO_8859-1", "ISO-8859-1" },
+ { "en_CA.DIS_8859-15", "ISO-8859-15" },
+ { "en_CA.ISO_8859-1", "ISO-8859-1" },
+ { "en_GB.DIS_8859-15", "ISO-8859-15" },
+ { "en_GB.ISO_8859-1", "ISO-8859-1" },
+ { "en_US.DIS_8859-15", "ISO-8859-15" },
+ { "en_US.ISO_8859-1", "ISO-8859-1" },
+ { "es_ES.DIS_8859-15", "ISO-8859-15" },
+ { "es_ES.ISO_8859-1", "ISO-8859-1" },
+ { "fi_FI.DIS_8859-15", "ISO-8859-15" },
+ { "fi_FI.ISO_8859-1", "ISO-8859-1" },
+ { "fr_BE.DIS_8859-15", "ISO-8859-15" },
+ { "fr_BE.ISO_8859-1", "ISO-8859-1" },
+ { "fr_CA.DIS_8859-15", "ISO-8859-15" },
+ { "fr_CA.ISO_8859-1", "ISO-8859-1" },
+ { "fr_CH.DIS_8859-15", "ISO-8859-15" },
+ { "fr_CH.ISO_8859-1", "ISO-8859-1" },
+ { "fr_FR.DIS_8859-15", "ISO-8859-15" },
+ { "fr_FR.ISO_8859-1", "ISO-8859-1" },
+ { "hr_HR.ISO_8859-2", "ISO-8859-2" },
+ { "hu_HU.ISO_8859-2", "ISO-8859-2" },
+ { "is_IS.DIS_8859-15", "ISO-8859-15" },
+ { "is_IS.ISO_8859-1", "ISO-8859-1" },
+ { "it_CH.DIS_8859-15", "ISO-8859-15" },
+ { "it_CH.ISO_8859-1", "ISO-8859-1" },
+ { "it_IT.DIS_8859-15", "ISO-8859-15" },
+ { "it_IT.ISO_8859-1", "ISO-8859-1" },
+ { "ja_JP.EUC", "EUC-JP" },
+ { "ja_JP.SJIS", "SHIFT_JIS" },
+ { "ja_JP.Shift_JIS", "SHIFT_JIS" },
+ { "ko_KR.EUC", "EUC-KR" },
+ { "la_LN.ASCII", "ASCII" },
+ { "la_LN.DIS_8859-15", "ISO-8859-15" },
+ { "la_LN.ISO_8859-1", "ISO-8859-1" },
+ { "la_LN.ISO_8859-2", "ISO-8859-2" },
+ { "la_LN.ISO_8859-4", "ISO-8859-4" },
+ { "lt_LN.ASCII", "ASCII" },
+ { "lt_LN.DIS_8859-15", "ISO-8859-15" },
+ { "lt_LN.ISO_8859-1", "ISO-8859-1" },
+ { "lt_LN.ISO_8859-2", "ISO-8859-2" },
+ { "lt_LT.ISO_8859-4", "ISO-8859-4" },
+ { "nl_BE.DIS_8859-15", "ISO-8859-15" },
+ { "nl_BE.ISO_8859-1", "ISO-8859-1" },
+ { "nl_NL.DIS_8859-15", "ISO-8859-15" },
+ { "nl_NL.ISO_8859-1", "ISO-8859-1" },
+ { "no_NO.DIS_8859-15", "ISO-8859-15" },
+ { "no_NO.ISO_8859-1", "ISO-8859-1" },
+ { "pl_PL.ISO_8859-2", "ISO-8859-2" },
+ { "pt_PT.DIS_8859-15", "ISO-8859-15" },
+ { "pt_PT.ISO_8859-1", "ISO-8859-1" },
+ { "ru_RU.CP866", "CP866" },
+ { "ru_RU.ISO_8859-5", "ISO-8859-5" },
+ { "ru_RU.KOI8-R", "KOI8-R" },
+ { "ru_SU.CP866", "CP866" },
+ { "ru_SU.ISO_8859-5", "ISO-8859-5" },
+ { "ru_SU.KOI8-R", "KOI8-R" },
+ { "sl_SI.ISO_8859-2", "ISO-8859-2" },
+ { "sv_SE.DIS_8859-15", "ISO-8859-15" },
+ { "sv_SE.ISO_8859-1", "ISO-8859-1" },
+ { "uk_UA.KOI8-U", "KOI8-U" },
+ { "zh_CN.EUC", "GB2312" },
+ { "zh_TW.BIG5", "BIG5" },
+ { "zh_TW.Big5", "BIG5" }
+# define locale_table_defined
+# endif
+# if defined __DJGPP__ /* DOS / DJGPP 2.03 */
+ /* The encodings given here may not all be correct.
+ If you find that the encoding given for your language and
+ country is not the one your DOS machine actually uses, just
+ correct it in this file, and send a mail to
+ Juan Manuel Guerrero <juan.guerrero@gmx.de>
+ and <bug-gnulib@gnu.org>. */
+ { "C", "ASCII" },
+ { "ar", "CP864" },
+ { "ar_AE", "CP864" },
+ { "ar_DZ", "CP864" },
+ { "ar_EG", "CP864" },
+ { "ar_IQ", "CP864" },
+ { "ar_IR", "CP864" },
+ { "ar_JO", "CP864" },
+ { "ar_KW", "CP864" },
+ { "ar_MA", "CP864" },
+ { "ar_OM", "CP864" },
+ { "ar_QA", "CP864" },
+ { "ar_SA", "CP864" },
+ { "ar_SY", "CP864" },
+ { "be", "CP866" },
+ { "be_BE", "CP866" },
+ { "bg", "CP866" }, /* not CP855 ?? */
+ { "bg_BG", "CP866" }, /* not CP855 ?? */
+ { "ca", "CP850" },
+ { "ca_ES", "CP850" },
+ { "cs", "CP852" },
+ { "cs_CZ", "CP852" },
+ { "da", "CP865" }, /* not CP850 ?? */
+ { "da_DK", "CP865" }, /* not CP850 ?? */
+ { "de", "CP850" },
+ { "de_AT", "CP850" },
+ { "de_CH", "CP850" },
+ { "de_DE", "CP850" },
+ { "el", "CP869" },
+ { "el_GR", "CP869" },
+ { "en", "CP850" },
+ { "en_AU", "CP850" }, /* not CP437 ?? */
+ { "en_CA", "CP850" },
+ { "en_GB", "CP850" },
+ { "en_NZ", "CP437" },
+ { "en_US", "CP437" },
+ { "en_ZA", "CP850" }, /* not CP437 ?? */
+ { "eo", "CP850" },
+ { "eo_EO", "CP850" },
+ { "es", "CP850" },
+ { "es_AR", "CP850" },
+ { "es_BO", "CP850" },
+ { "es_CL", "CP850" },
+ { "es_CO", "CP850" },
+ { "es_CR", "CP850" },
+ { "es_CU", "CP850" },
+ { "es_DO", "CP850" },
+ { "es_EC", "CP850" },
+ { "es_ES", "CP850" },
+ { "es_GT", "CP850" },
+ { "es_HN", "CP850" },
+ { "es_MX", "CP850" },
+ { "es_NI", "CP850" },
+ { "es_PA", "CP850" },
+ { "es_PE", "CP850" },
+ { "es_PY", "CP850" },
+ { "es_SV", "CP850" },
+ { "es_UY", "CP850" },
+ { "es_VE", "CP850" },
+ { "et", "CP850" },
+ { "et_EE", "CP850" },
+ { "eu", "CP850" },
+ { "eu_ES", "CP850" },
+ { "fi", "CP850" },
+ { "fi_FI", "CP850" },
+ { "fr", "CP850" },
+ { "fr_BE", "CP850" },
+ { "fr_CA", "CP850" },
+ { "fr_CH", "CP850" },
+ { "fr_FR", "CP850" },
+ { "ga", "CP850" },
+ { "ga_IE", "CP850" },
+ { "gd", "CP850" },
+ { "gd_GB", "CP850" },
+ { "gl", "CP850" },
+ { "gl_ES", "CP850" },
+ { "he", "CP862" },
+ { "he_IL", "CP862" },
+ { "hr", "CP852" },
+ { "hr_HR", "CP852" },
+ { "hu", "CP852" },
+ { "hu_HU", "CP852" },
+ { "id", "CP850" }, /* not CP437 ?? */
+ { "id_ID", "CP850" }, /* not CP437 ?? */
+ { "is", "CP861" }, /* not CP850 ?? */
+ { "is_IS", "CP861" }, /* not CP850 ?? */
+ { "it", "CP850" },
+ { "it_CH", "CP850" },
+ { "it_IT", "CP850" },
+ { "ja", "CP932" },
+ { "ja_JP", "CP932" },
+ { "kr", "CP949" }, /* not CP934 ?? */
+ { "kr_KR", "CP949" }, /* not CP934 ?? */
+ { "lt", "CP775" },
+ { "lt_LT", "CP775" },
+ { "lv", "CP775" },
+ { "lv_LV", "CP775" },
+ { "mk", "CP866" }, /* not CP855 ?? */
+ { "mk_MK", "CP866" }, /* not CP855 ?? */
+ { "mt", "CP850" },
+ { "mt_MT", "CP850" },
+ { "nb", "CP865" }, /* not CP850 ?? */
+ { "nb_NO", "CP865" }, /* not CP850 ?? */
+ { "nl", "CP850" },
+ { "nl_BE", "CP850" },
+ { "nl_NL", "CP850" },
+ { "nn", "CP865" }, /* not CP850 ?? */
+ { "nn_NO", "CP865" }, /* not CP850 ?? */
+ { "no", "CP865" }, /* not CP850 ?? */
+ { "no_NO", "CP865" }, /* not CP850 ?? */
+ { "pl", "CP852" },
+ { "pl_PL", "CP852" },
+ { "pt", "CP850" },
+ { "pt_BR", "CP850" },
+ { "pt_PT", "CP850" },
+ { "ro", "CP852" },
+ { "ro_RO", "CP852" },
+ { "ru", "CP866" },
+ { "ru_RU", "CP866" },
+ { "sk", "CP852" },
+ { "sk_SK", "CP852" },
+ { "sl", "CP852" },
+ { "sl_SI", "CP852" },
+ { "sq", "CP852" },
+ { "sq_AL", "CP852" },
+ { "sr", "CP852" }, /* CP852 or CP866 or CP855 ?? */
+ { "sr_CS", "CP852" }, /* CP852 or CP866 or CP855 ?? */
+ { "sr_YU", "CP852" }, /* CP852 or CP866 or CP855 ?? */
+ { "sv", "CP850" },
+ { "sv_SE", "CP850" },
+ { "th", "CP874" },
+ { "th_TH", "CP874" },
+ { "tr", "CP857" },
+ { "tr_TR", "CP857" },
+ { "uk", "CP1125" },
+ { "uk_UA", "CP1125" },
+ { "zh_CN", "GBK" },
+ { "zh_TW", "CP950" } /* not CP938 ?? */
+# define locale_table_defined
+# endif
+# ifndef locale_table_defined
+ /* Just a dummy entry, to avoid a C syntax error. */
+ { "", "" }
+# endif
+ };
+
+#endif
+
+
+/* Determine the current locale's character encoding, and canonicalize it
+ into one of the canonical names listed in localcharset.h.
+ The result must not be freed; it is statically allocated.
+ If the canonical name cannot be determined, the result is a non-canonical
+ name. */
+
+#ifdef STATIC
+STATIC
+#endif
+const char *
+locale_charset (void)
+{
+ const char *codeset;
+
+#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
+
+# if HAVE_LANGINFO_CODESET
+
+ /* Most systems support nl_langinfo (CODESET) nowadays. */
+ codeset = nl_langinfo (CODESET);
+
+# ifdef __CYGWIN__
+ /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always
+ returns "US-ASCII". Return the suffix of the locale name from the
+ environment variables (if present) or the codepage as a number. */
+ if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
+ {
+ const char *locale;
+ static char buf[2 + 10 + 1];
+
+ locale = getenv ("LC_ALL");
+ if (locale == NULL || locale[0] == '\0')
+ {
+ locale = getenv ("LC_CTYPE");
+ if (locale == NULL || locale[0] == '\0')
+ locale = getenv ("LANG");
+ }
+ if (locale != NULL && locale[0] != '\0')
+ {
+ /* If the locale name contains an encoding after the dot, return
+ it. */
+ const char *dot = strchr (locale, '.');
+
+ if (dot != NULL)
+ {
+ const char *modifier;
+
+ dot++;
+ /* Look for the possible @... trailer and remove it, if any. */
+ modifier = strchr (dot, '@');
+ if (modifier == NULL)
+ return dot;
+ if (modifier - dot < sizeof (buf))
+ {
+ memcpy (buf, dot, modifier - dot);
+ buf [modifier - dot] = '\0';
+ return buf;
+ }
+ }
+ }
+
+ /* The Windows API has a function returning the locale's codepage as a
+ number: GetACP(). This encoding is used by Cygwin, unless the user
+ has set the environment variable CYGWIN=codepage:oem (which very few
+ people do).
+ Output directed to console windows needs to be converted (to
+ GetOEMCP() if the console is using a raster font, or to
+ GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
+ this conversion transparently (see winsup/cygwin/fhandler_console.cc),
+ converting to GetConsoleOutputCP(). This leads to correct results,
+ except when SetConsoleOutputCP has been called and a raster font is
+ in use. */
+ sprintf (buf, "CP%u", GetACP ());
+ codeset = buf;
+ }
+# endif
+
+ if (codeset == NULL)
+ /* The canonical name cannot be determined. */
+ codeset = "";
+
+# elif defined WINDOWS_NATIVE
+
+ static char buf[2 + 10 + 1];
+
+ /* The Windows API has a function returning the locale's codepage as
+ a number, but the value doesn't change according to what the
+ 'setlocale' call specified. So we use it as a last resort, in
+ case the string returned by 'setlocale' doesn't specify the
+ codepage. */
+ char *current_locale = setlocale (LC_ALL, NULL);
+ char *pdot;
+
+ /* If they set different locales for different categories,
+ 'setlocale' will return a semi-colon separated list of locale
+ values. To make sure we use the correct one, we choose LC_CTYPE. */
+ if (strchr (current_locale, ';'))
+ current_locale = setlocale (LC_CTYPE, NULL);
+
+ pdot = strrchr (current_locale, '.');
+ if (pdot && 2 + strlen (pdot + 1) + 1 <= sizeof (buf))
+ sprintf (buf, "CP%s", pdot + 1);
+ else
+ {
+ /* The Windows API has a function returning the locale's codepage as a
+ number: GetACP().
+ When the output goes to a console window, it needs to be provided in
+ GetOEMCP() encoding if the console is using a raster font, or in
+ GetConsoleOutputCP() encoding if it is using a TrueType font.
+ But in GUI programs and for output sent to files and pipes, GetACP()
+ encoding is the best bet. */
+ sprintf (buf, "CP%u", GetACP ());
+ }
+ codeset = buf;
+
+# elif defined OS2
+
+ const char *locale;
+ static char buf[2 + 10 + 1];
+ ULONG cp[3];
+ ULONG cplen;
+
+ codeset = NULL;
+
+ /* Allow user to override the codeset, as set in the operating system,
+ with standard language environment variables. */
+ locale = getenv ("LC_ALL");
+ if (locale == NULL || locale[0] == '\0')
+ {
+ locale = getenv ("LC_CTYPE");
+ if (locale == NULL || locale[0] == '\0')
+ locale = getenv ("LANG");
+ }
+ if (locale != NULL && locale[0] != '\0')
+ {
+ /* If the locale name contains an encoding after the dot, return it. */
+ const char *dot = strchr (locale, '.');
+
+ if (dot != NULL)
+ {
+ const char *modifier;
+
+ dot++;
+ /* Look for the possible @... trailer and remove it, if any. */
+ modifier = strchr (dot, '@');
+ if (modifier == NULL)
+ return dot;
+ if (modifier - dot < sizeof (buf))
+ {
+ memcpy (buf, dot, modifier - dot);
+ buf [modifier - dot] = '\0';
+ return buf;
+ }
+ }
+
+ /* For the POSIX locale, don't use the system's codepage. */
+ if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)
+ codeset = "";
+ }
+
+ if (codeset == NULL)
+ {
+ /* OS/2 has a function returning the locale's codepage as a number. */
+ if (DosQueryCp (sizeof (cp), cp, &cplen))
+ codeset = "";
+ else
+ {
+ sprintf (buf, "CP%u", cp[0]);
+ codeset = buf;
+ }
+ }
+
+# else
+
+# error "Add code for other platforms here."
+
+# endif
+
+ /* Resolve alias. */
+ {
+# ifdef alias_table_defined
+ /* On some platforms, UTF-8 locales are the most frequently used ones.
+ Speed up the common case and slow down the less common cases by
+ testing for this case first. */
+# if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__
+ if (strcmp (codeset, "UTF-8") == 0)
+ goto done_table_lookup;
+ else
+# endif
+ {
+ const struct table_entry * const table = alias_table;
+ size_t const table_size =
+ sizeof (alias_table) / sizeof (struct table_entry);
+ /* The table is sorted. Perform a binary search. */
+ size_t hi = table_size;
+ size_t lo = 0;
+ while (lo < hi)
+ {
+ /* Invariant:
+ for i < lo, strcmp (table[i].alias, codeset) < 0,
+ for i >= hi, strcmp (table[i].alias, codeset) > 0. */
+ size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
+ int cmp = strcmp (table[mid].alias, codeset);
+ if (cmp < 0)
+ lo = mid + 1;
+ else if (cmp > 0)
+ hi = mid;
+ else
+ {
+ /* Found an i with
+ strcmp (table[i].alias, codeset) == 0. */
+ codeset = table[mid].canonical;
+ goto done_table_lookup;
+ }
+ }
+ }
+ if (0)
+ done_table_lookup: ;
+ else
+# endif
+ {
+ /* Did not find it in the table. */
+ /* On Mac OS X, all modern locales use the UTF-8 encoding.
+ BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
+# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
+ codeset = "UTF-8";
+# else
+ /* Don't return an empty string. GNU libc and GNU libiconv interpret
+ the empty string as denoting "the locale's character encoding",
+ thus GNU libiconv would call this function a second time. */
+ if (codeset[0] == '\0')
+ codeset = "ASCII";
+# endif
+ }
+ }
+
+#else
+
+ /* On old systems which lack it, use setlocale or getenv. */
+ const char *locale = NULL;
+
+ /* But most old systems don't have a complete set of locales. Some
+ (like DJGPP) have only the C locale. Therefore we don't use setlocale
+ here; it would return "C" when it doesn't support the locale name the
+ user has set. */
+# if 0
+ locale = setlocale (LC_CTYPE, NULL);
+# endif
+ if (locale == NULL || locale[0] == '\0')
+ {
+ locale = getenv ("LC_ALL");
+ if (locale == NULL || locale[0] == '\0')
+ {
+ locale = getenv ("LC_CTYPE");
+ if (locale == NULL || locale[0] == '\0')
+ locale = getenv ("LANG");
+ if (locale == NULL)
+ locale = "";
+ }
+ }
+
+ /* Map locale name to canonical encoding name. */
+ {
+# ifdef locale_table_defined
+ const struct table_entry * const table = locale_table;
+ size_t const table_size =
+ sizeof (locale_table) / sizeof (struct table_entry);
+ /* The table is sorted. Perform a binary search. */
+ size_t hi = table_size;
+ size_t lo = 0;
+ while (lo < hi)
+ {
+ /* Invariant:
+ for i < lo, strcmp (table[i].locale, locale) < 0,
+ for i >= hi, strcmp (table[i].locale, locale) > 0. */
+ size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
+ int cmp = strcmp (table[mid].locale, locale);
+ if (cmp < 0)
+ lo = mid + 1;
+ else if (cmp > 0)
+ hi = mid;
+ else
+ {
+ /* Found an i with
+ strcmp (table[i].locale, locale) == 0. */
+ codeset = table[mid].canonical;
+ goto done_table_lookup;
+ }
+ }
+ if (0)
+ done_table_lookup: ;
+ else
+# endif
+ {
+ /* Did not find it in the table. */
+ /* On Mac OS X, all modern locales use the UTF-8 encoding.
+ BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
+# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
+ codeset = "UTF-8";
+# else
+ /* The canonical name cannot be determined. */
+ /* Don't return an empty string. GNU libc and GNU libiconv interpret
+ the empty string as denoting "the locale's character encoding",
+ thus GNU libiconv would call this function a second time. */
+ codeset = "ASCII";
+# endif
+ }
+ }
+
+#endif
+
+#ifdef DARWIN7
+ /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
+ (the default codeset) does not work when MB_CUR_MAX is 1. */
+ if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1)
+ codeset = "ASCII";
+#endif
+
+ return codeset;
+}
diff --git a/grub-core/lib/gnulib/localcharset.h b/grub-core/lib/gnulib/localcharset.h
new file mode 100644
index 0000000..7d0d771
--- /dev/null
+++ b/grub-core/lib/gnulib/localcharset.h
@@ -0,0 +1,134 @@
+/* Determine a canonical name for the current locale's character encoding.
+ Copyright (C) 2000-2003, 2009-2019 Free Software Foundation, Inc.
+ This file is part of the GNU CHARSET Library.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _LOCALCHARSET_H
+#define _LOCALCHARSET_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Determine the current locale's character encoding, and canonicalize it
+ into one of the canonical names listed below.
+ The result must not be freed; it is statically allocated.
+ If the canonical name cannot be determined, the result is a non-canonical
+ name. */
+extern const char * locale_charset (void);
+
+/* About GNU canonical names for character encodings:
+
+ Every canonical name must be supported by GNU libiconv. Support by GNU libc
+ is also desirable.
+
+ The name is case insensitive. Usually an upper case MIME charset name is
+ preferred.
+
+ The current list of these GNU canonical names is:
+
+ name MIME? used by which systems
+ (darwin = Mac OS X, windows = native Windows)
+
+ ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin
+ ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+ ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+ ISO-8859-3 Y glibc solaris cygwin
+ ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin
+ ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+ ISO-8859-6 Y glibc aix hpux solaris cygwin
+ ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+ ISO-8859-8 Y glibc aix hpux osf solaris cygwin
+ ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin
+ ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
+ ISO-8859-14 glibc cygwin
+ ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin
+ KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin
+ KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
+ KOI8-T glibc
+ CP437 dos
+ CP775 dos
+ CP850 aix osf dos
+ CP852 dos
+ CP855 dos
+ CP856 aix
+ CP857 dos
+ CP861 dos
+ CP862 dos
+ CP864 dos
+ CP865 dos
+ CP866 freebsd netbsd openbsd darwin dos
+ CP869 dos
+ CP874 windows dos
+ CP922 aix
+ CP932 aix cygwin windows dos
+ CP943 aix
+ CP949 osf darwin windows dos
+ CP950 windows dos
+ CP1046 aix
+ CP1124 aix
+ CP1125 dos
+ CP1129 aix
+ CP1131 freebsd darwin
+ CP1250 windows
+ CP1251 glibc hpux solaris freebsd netbsd openbsd darwin cygwin windows
+ CP1252 aix windows
+ CP1253 windows
+ CP1254 windows
+ CP1255 glibc windows
+ CP1256 windows
+ CP1257 windows
+ GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin
+ EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
+ EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
+ EUC-TW glibc aix hpux irix osf solaris netbsd
+ BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin
+ BIG5-HKSCS glibc hpux solaris netbsd darwin
+ GBK glibc aix osf solaris freebsd darwin cygwin windows dos
+ GB18030 glibc hpux solaris freebsd netbsd darwin
+ SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
+ JOHAB glibc solaris windows
+ TIS-620 glibc aix hpux osf solaris cygwin
+ VISCII Y glibc
+ TCVN5712-1 glibc
+ ARMSCII-8 glibc freebsd netbsd darwin
+ GEORGIAN-PS glibc cygwin
+ PT154 glibc netbsd cygwin
+ HP-ROMAN8 hpux
+ HP-ARABIC8 hpux
+ HP-GREEK8 hpux
+ HP-HEBREW8 hpux
+ HP-TURKISH8 hpux
+ HP-KANA8 hpux
+ DEC-KANJI osf
+ DEC-HANYU osf
+ UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin
+
+ Note: Names which are not marked as being a MIME name should not be used in
+ Internet protocols for information interchange (mail, news, etc.).
+
+ Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
+ must understand both names and treat them as equivalent.
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _LOCALCHARSET_H */
diff --git a/grub-core/lib/gnulib/locale.in.h b/grub-core/lib/gnulib/locale.in.h
new file mode 100644
index 0000000..5f33ed1
--- /dev/null
+++ b/grub-core/lib/gnulib/locale.in.h
@@ -0,0 +1,272 @@
+/* A POSIX <locale.h>.
+ Copyright (C) 2007-2019 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 <https://www.gnu.org/licenses/>. */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
+ || defined _GL_ALREADY_INCLUDING_LOCALE_H
+
+/* Special invocation convention:
+ - Inside mingw header files,
+ - To handle Solaris header files (through Solaris 10) when combined
+ with gettext's libintl.h. */
+
+#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_LOCALE_H
+
+#define _GL_ALREADY_INCLUDING_LOCALE_H
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
+
+#undef _GL_ALREADY_INCLUDING_LOCALE_H
+
+#ifndef _@GUARD_PREFIX@_LOCALE_H
+#define _@GUARD_PREFIX@_LOCALE_H
+
+/* NetBSD 5.0 mis-defines NULL. */
+#include <stddef.h>
+
+/* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */
+#if @HAVE_XLOCALE_H@
+# include <xlocale.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
+ On systems that don't define it, use the same value as GNU libintl. */
+#if !defined LC_MESSAGES
+# define LC_MESSAGES 1729
+#endif
+
+/* Bionic libc's 'struct lconv' is just a dummy. */
+#if @REPLACE_STRUCT_LCONV@
+# define lconv rpl_lconv
+struct lconv
+{
+ /* All 'char *' are actually 'const char *'. */
+
+ /* Members that depend on the LC_NUMERIC category of the locale. See
+ <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */
+
+ /* Symbol used as decimal point. */
+ char *decimal_point;
+ /* Symbol used to separate groups of digits to the left of the decimal
+ point. */
+ char *thousands_sep;
+ /* Definition of the size of groups of digits to the left of the decimal
+ point. */
+ char *grouping;
+
+ /* Members that depend on the LC_MONETARY category of the locale. See
+ <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */
+
+ /* Symbol used as decimal point. */
+ char *mon_decimal_point;
+ /* Symbol used to separate groups of digits to the left of the decimal
+ point. */
+ char *mon_thousands_sep;
+ /* Definition of the size of groups of digits to the left of the decimal
+ point. */
+ char *mon_grouping;
+ /* Sign used to indicate a value >= 0. */
+ char *positive_sign;
+ /* Sign used to indicate a value < 0. */
+ char *negative_sign;
+
+ /* For formatting local currency. */
+ /* Currency symbol (3 characters) followed by separator (1 character). */
+ char *currency_symbol;
+ /* Number of digits after the decimal point. */
+ char frac_digits;
+ /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
+ comes after the number. */
+ char p_cs_precedes;
+ /* For values >= 0: Position of the sign. */
+ char p_sign_posn;
+ /* For values >= 0: Placement of spaces between currency symbol, sign, and
+ number. */
+ char p_sep_by_space;
+ /* For values < 0: 1 if the currency symbol precedes the number, 0 if it
+ comes after the number. */
+ char n_cs_precedes;
+ /* For values < 0: Position of the sign. */
+ char n_sign_posn;
+ /* For values < 0: Placement of spaces between currency symbol, sign, and
+ number. */
+ char n_sep_by_space;
+
+ /* For formatting international currency. */
+ /* Currency symbol (3 characters) followed by separator (1 character). */
+ char *int_curr_symbol;
+ /* Number of digits after the decimal point. */
+ char int_frac_digits;
+ /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
+ comes after the number. */
+ char int_p_cs_precedes;
+ /* For values >= 0: Position of the sign. */
+ char int_p_sign_posn;
+ /* For values >= 0: Placement of spaces between currency symbol, sign, and
+ number. */
+ char int_p_sep_by_space;
+ /* For values < 0: 1 if the currency symbol precedes the number, 0 if it
+ comes after the number. */
+ char int_n_cs_precedes;
+ /* For values < 0: Position of the sign. */
+ char int_n_sign_posn;
+ /* For values < 0: Placement of spaces between currency symbol, sign, and
+ number. */
+ char int_n_sep_by_space;
+};
+#endif
+
+#if @GNULIB_LOCALECONV@
+# if @REPLACE_LOCALECONV@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef localeconv
+# define localeconv rpl_localeconv
+# endif
+_GL_FUNCDECL_RPL (localeconv, struct lconv *, (void));
+_GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
+# else
+_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
+# endif
+_GL_CXXALIASWARN (localeconv);
+#elif @REPLACE_STRUCT_LCONV@
+# undef localeconv
+# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
+#elif defined GNULIB_POSIXCHECK
+# undef localeconv
+# if HAVE_RAW_DECL_LOCALECONV
+_GL_WARN_ON_USE (localeconv,
+ "localeconv returns too few information on some platforms - "
+ "use gnulib module localeconv for portability");
+# endif
+#endif
+
+#if @GNULIB_SETLOCALE@
+# if @REPLACE_SETLOCALE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef setlocale
+# define setlocale rpl_setlocale
+# define GNULIB_defined_setlocale 1
+# endif
+_GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale));
+_GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
+# else
+_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
+# endif
+_GL_CXXALIASWARN (setlocale);
+#elif defined GNULIB_POSIXCHECK
+# undef setlocale
+# if HAVE_RAW_DECL_SETLOCALE
+_GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
+ "use gnulib module setlocale for portability");
+# endif
+#endif
+
+#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_NEWLOCALE@)
+# if @REPLACE_NEWLOCALE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef newlocale
+# define newlocale rpl_newlocale
+# define GNULIB_defined_newlocale 1
+# endif
+_GL_FUNCDECL_RPL (newlocale, locale_t,
+ (int category_mask, const char *name, locale_t base)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (newlocale, locale_t,
+ (int category_mask, const char *name, locale_t base));
+# else
+# if @HAVE_NEWLOCALE@
+_GL_CXXALIAS_SYS (newlocale, locale_t,
+ (int category_mask, const char *name, locale_t base));
+# endif
+# endif
+# if @HAVE_NEWLOCALE@
+_GL_CXXALIASWARN (newlocale);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef newlocale
+# if HAVE_RAW_DECL_NEWLOCALE
+_GL_WARN_ON_USE (newlocale, "newlocale is not portable");
+# endif
+#endif
+
+#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @HAVE_DUPLOCALE@)
+# if @REPLACE_DUPLOCALE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef duplocale
+# define duplocale rpl_duplocale
+# define GNULIB_defined_duplocale 1
+# endif
+_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
+# else
+# if @HAVE_DUPLOCALE@
+_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
+# endif
+# endif
+# if @HAVE_DUPLOCALE@
+_GL_CXXALIASWARN (duplocale);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef duplocale
+# if HAVE_RAW_DECL_DUPLOCALE
+_GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
+ "use gnulib module duplocale for portability");
+# endif
+#endif
+
+#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_FREELOCALE@)
+# if @REPLACE_FREELOCALE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef freelocale
+# define freelocale rpl_freelocale
+# define GNULIB_defined_freelocale 1
+# endif
+_GL_FUNCDECL_RPL (freelocale, void, (locale_t locale) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (freelocale, void, (locale_t locale));
+# else
+# if @HAVE_FREELOCALE@
+_GL_CXXALIAS_SYS (freelocale, void, (locale_t locale));
+# endif
+# endif
+# if @HAVE_FREELOCALE@
+_GL_CXXALIASWARN (freelocale);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef freelocale
+# if HAVE_RAW_DECL_FREELOCALE
+_GL_WARN_ON_USE (freelocale, "freelocale is not portable");
+# endif
+#endif
+
+#endif /* _@GUARD_PREFIX@_LOCALE_H */
+#endif /* _@GUARD_PREFIX@_LOCALE_H */
+#endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */
diff --git a/grub-core/lib/gnulib/localeconv.c b/grub-core/lib/gnulib/localeconv.c
new file mode 100644
index 0000000..b5a965f
--- /dev/null
+++ b/grub-core/lib/gnulib/localeconv.c
@@ -0,0 +1,103 @@
+/* Query locale dependent information for formatting numbers.
+ Copyright (C) 2012-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <locale.h>
+
+#if HAVE_STRUCT_LCONV_DECIMAL_POINT
+
+/* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_*
+ members. */
+
+struct lconv *
+localeconv (void)
+{
+ static struct lconv result;
+# undef lconv
+# undef localeconv
+ struct lconv *sys_result = localeconv ();
+
+ result.decimal_point = sys_result->decimal_point;
+ result.thousands_sep = sys_result->thousands_sep;
+ result.grouping = sys_result->grouping;
+ result.mon_decimal_point = sys_result->mon_decimal_point;
+ result.mon_thousands_sep = sys_result->mon_thousands_sep;
+ result.mon_grouping = sys_result->mon_grouping;
+ result.positive_sign = sys_result->positive_sign;
+ result.negative_sign = sys_result->negative_sign;
+ result.currency_symbol = sys_result->currency_symbol;
+ result.frac_digits = sys_result->frac_digits;
+ result.p_cs_precedes = sys_result->p_cs_precedes;
+ result.p_sign_posn = sys_result->p_sign_posn;
+ result.p_sep_by_space = sys_result->p_sep_by_space;
+ result.n_cs_precedes = sys_result->n_cs_precedes;
+ result.n_sign_posn = sys_result->n_sign_posn;
+ result.n_sep_by_space = sys_result->n_sep_by_space;
+ result.int_curr_symbol = sys_result->int_curr_symbol;
+ result.int_frac_digits = sys_result->int_frac_digits;
+ result.int_p_cs_precedes = sys_result->p_cs_precedes;
+ result.int_p_sign_posn = sys_result->p_sign_posn;
+ result.int_p_sep_by_space = sys_result->p_sep_by_space;
+ result.int_n_cs_precedes = sys_result->n_cs_precedes;
+ result.int_n_sign_posn = sys_result->n_sign_posn;
+ result.int_n_sep_by_space = sys_result->n_sep_by_space;
+
+ return &result;
+}
+
+#else
+
+/* Override for platforms where 'struct lconv' is a dummy. */
+
+# include <limits.h>
+
+struct lconv *
+localeconv (void)
+{
+ static /*const*/ struct lconv result =
+ {
+ /* decimal_point */ ".",
+ /* thousands_sep */ "",
+ /* grouping */ "",
+ /* mon_decimal_point */ "",
+ /* mon_thousands_sep */ "",
+ /* mon_grouping */ "",
+ /* positive_sign */ "",
+ /* negative_sign */ "",
+ /* currency_symbol */ "",
+ /* frac_digits */ CHAR_MAX,
+ /* p_cs_precedes */ CHAR_MAX,
+ /* p_sign_posn */ CHAR_MAX,
+ /* p_sep_by_space */ CHAR_MAX,
+ /* n_cs_precedes */ CHAR_MAX,
+ /* n_sign_posn */ CHAR_MAX,
+ /* n_sep_by_space */ CHAR_MAX,
+ /* int_curr_symbol */ "",
+ /* int_frac_digits */ CHAR_MAX,
+ /* int_p_cs_precedes */ CHAR_MAX,
+ /* int_p_sign_posn */ CHAR_MAX,
+ /* int_p_sep_by_space */ CHAR_MAX,
+ /* int_n_cs_precedes */ CHAR_MAX,
+ /* int_n_sign_posn */ CHAR_MAX,
+ /* int_n_sep_by_space */ CHAR_MAX
+ };
+
+ return &result;
+}
+
+#endif
diff --git a/grub-core/lib/gnulib/malloc.c b/grub-core/lib/gnulib/malloc.c
new file mode 100644
index 0000000..76e6ff7
--- /dev/null
+++ b/grub-core/lib/gnulib/malloc.c
@@ -0,0 +1,56 @@
+/* malloc() function that is glibc compatible.
+
+ Copyright (C) 1997-1998, 2006-2007, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering and Bruno Haible */
+
+#define _GL_USE_STDLIB_ALLOC 1
+#include <config.h>
+/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
+#ifdef malloc
+# define NEED_MALLOC_GNU 1
+# undef malloc
+/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */
+#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU
+# define NEED_MALLOC_GNU 1
+#endif
+
+#include <stdlib.h>
+
+#include <errno.h>
+
+/* Allocate an N-byte block of memory from the heap.
+ If N is zero, allocate a 1-byte block. */
+
+void *
+rpl_malloc (size_t n)
+{
+ void *result;
+
+#if NEED_MALLOC_GNU
+ if (n == 0)
+ n = 1;
+#endif
+
+ result = malloc (n);
+
+#if !HAVE_MALLOC_POSIX
+ if (result == NULL)
+ errno = ENOMEM;
+#endif
+
+ return result;
+}
diff --git a/grub-core/lib/gnulib/malloca.c b/grub-core/lib/gnulib/malloca.c
new file mode 100644
index 0000000..f60c5fb
--- /dev/null
+++ b/grub-core/lib/gnulib/malloca.c
@@ -0,0 +1,105 @@
+/* Safe automatic memory allocation.
+ Copyright (C) 2003, 2006-2007, 2009-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2003, 2018.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#define _GL_USE_STDLIB_ALLOC 1
+#include <config.h>
+
+/* Specification. */
+#include "malloca.h"
+
+#include "verify.h"
+
+/* The speed critical point in this file is freea() applied to an alloca()
+ result: it must be fast, to match the speed of alloca(). The speed of
+ mmalloca() and freea() in the other case are not critical, because they
+ are only invoked for big memory sizes.
+ Here we use a bit in the address as an indicator, an idea by Ondřej Bílka.
+ malloca() can return three types of pointers:
+ - Pointers ≡ 0 mod 2*sa_alignment_max come from stack allocation.
+ - Pointers ≡ sa_alignment_max mod 2*sa_alignment_max come from heap
+ allocation.
+ - NULL comes from a failed heap allocation. */
+
+/* Type for holding very small pointer differences. */
+typedef unsigned char small_t;
+/* Verify that it is wide enough. */
+verify (2 * sa_alignment_max - 1 <= (small_t) -1);
+
+void *
+mmalloca (size_t n)
+{
+#if HAVE_ALLOCA
+ /* Allocate one more word, used to determine the address to pass to freea(),
+ and room for the alignment ≡ sa_alignment_max mod 2*sa_alignment_max. */
+ size_t nplus = n + sizeof (small_t) + 2 * sa_alignment_max - 1;
+
+ if (nplus >= n)
+ {
+ char *mem = (char *) malloc (nplus);
+
+ if (mem != NULL)
+ {
+ char *p =
+ (char *)((((uintptr_t)mem + sizeof (small_t) + sa_alignment_max - 1)
+ & ~(uintptr_t)(2 * sa_alignment_max - 1))
+ + sa_alignment_max);
+ /* Here p >= mem + sizeof (small_t),
+ and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
+ hence p + n <= mem + nplus.
+ So, the memory range [p, p+n) lies in the allocated memory range
+ [mem, mem + nplus). */
+ ((small_t *) p)[-1] = p - mem;
+ /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */
+ return p;
+ }
+ }
+ /* Out of memory. */
+ return NULL;
+#else
+# if !MALLOC_0_IS_NONNULL
+ if (n == 0)
+ n = 1;
+# endif
+ return malloc (n);
+#endif
+}
+
+#if HAVE_ALLOCA
+void
+freea (void *p)
+{
+ /* Check argument. */
+ if ((uintptr_t) p & (sa_alignment_max - 1))
+ {
+ /* p was not the result of a malloca() call. Invalid argument. */
+ abort ();
+ }
+ /* Determine whether p was a non-NULL pointer returned by mmalloca(). */
+ if ((uintptr_t) p & sa_alignment_max)
+ {
+ void *mem = (char *) p - ((small_t *) p)[-1];
+ free (mem);
+ }
+}
+#endif
+
+/*
+ * Hey Emacs!
+ * Local Variables:
+ * coding: utf-8
+ * End:
+ */
diff --git a/grub-core/lib/gnulib/malloca.h b/grub-core/lib/gnulib/malloca.h
new file mode 100644
index 0000000..d80c316
--- /dev/null
+++ b/grub-core/lib/gnulib/malloca.h
@@ -0,0 +1,127 @@
+/* Safe automatic memory allocation.
+ Copyright (C) 2003-2007, 2009-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2003.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _MALLOCA_H
+#define _MALLOCA_H
+
+#include <alloca.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include "xalloc-oversized.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call
+ alloca(N); otherwise it returns NULL. It either returns N bytes of
+ memory allocated on the stack, that lasts until the function returns,
+ or NULL.
+ Use of safe_alloca should be avoided:
+ - inside arguments of function calls - undefined behaviour,
+ - in inline functions - the allocation may actually last until the
+ calling function returns.
+*/
+#if HAVE_ALLOCA
+/* The OS usually guarantees only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ allocate anything larger than 4096 bytes. Also care for the possibility
+ of a few compiler-allocated temporary stack slots.
+ This must be a macro, not a function. */
+# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL)
+#else
+# define safe_alloca(N) ((void) (N), NULL)
+#endif
+
+/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of
+ memory allocated on the stack, that must be freed using freea() before
+ the function returns. Upon failure, it returns NULL. */
+#if HAVE_ALLOCA
+# define malloca(N) \
+ ((N) < 4032 - (2 * sa_alignment_max - 1) \
+ ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \
+ + (2 * sa_alignment_max - 1)) \
+ & ~(uintptr_t)(2 * sa_alignment_max - 1)) \
+ : mmalloca (N))
+#else
+# define malloca(N) \
+ mmalloca (N)
+#endif
+extern void * mmalloca (size_t n);
+
+/* Free a block of memory allocated through malloca(). */
+#if HAVE_ALLOCA
+extern void freea (void *p);
+#else
+# define freea free
+#endif
+
+/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S).
+ It allocates an array of N objects, each with S bytes of memory,
+ on the stack. S must be positive and N must be nonnegative.
+ The array must be freed using freea() before the function returns. */
+#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s)))
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* ------------------- Auxiliary, non-public definitions ------------------- */
+
+/* Determine the alignment of a type at compile time. */
+#if defined __GNUC__ || defined __IBM__ALIGNOF__
+# define sa_alignof __alignof__
+#elif defined __cplusplus
+ template <class type> struct sa_alignof_helper { char __slot1; type __slot2; };
+# define sa_alignof(type) offsetof (sa_alignof_helper<type>, __slot2)
+#elif defined __hpux
+ /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof
+ values. */
+# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
+#elif defined _AIX
+ /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof
+ values. */
+# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
+#else
+# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
+#endif
+
+enum
+{
+/* The desired alignment of memory allocations is the maximum alignment
+ among all elementary types. */
+ sa_alignment_long = sa_alignof (long),
+ sa_alignment_double = sa_alignof (double),
+#if HAVE_LONG_LONG_INT
+ sa_alignment_longlong = sa_alignof (long long),
+#endif
+ sa_alignment_longdouble = sa_alignof (long double),
+ sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
+#if HAVE_LONG_LONG_INT
+ | (sa_alignment_longlong - 1)
+#endif
+ | (sa_alignment_longdouble - 1)
+ ) + 1
+};
+
+#endif /* _MALLOCA_H */
diff --git a/grub-core/lib/gnulib/mbrtowc.c b/grub-core/lib/gnulib/mbrtowc.c
new file mode 100644
index 0000000..bbe3f7a
--- /dev/null
+++ b/grub-core/lib/gnulib/mbrtowc.c
@@ -0,0 +1,458 @@
+/* Convert multibyte character to wide character.
+ Copyright (C) 1999-2002, 2005-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <wchar.h>
+
+#if C_LOCALE_MAYBE_EILSEQ
+# include "hard-locale.h"
+# include <locale.h>
+#endif
+
+#if GNULIB_defined_mbstate_t
+/* Implement mbrtowc() on top of mbtowc(). */
+
+# include <errno.h>
+# include <stdlib.h>
+
+# include "localcharset.h"
+# include "streq.h"
+# include "verify.h"
+
+# ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+# endif
+
+/* Returns a classification of special values of the encoding of the current
+ locale. */
+typedef enum {
+ enc_other, /* other */
+ enc_utf8, /* UTF-8 */
+ enc_eucjp, /* EUC-JP */
+ enc_94, /* EUC-KR, GB2312, BIG5 */
+ enc_euctw, /* EUC-TW */
+ enc_gb18030, /* GB18030 */
+ enc_sjis /* SJIS */
+} enc_t;
+static inline enc_t
+locale_enc (void)
+{
+ const char *encoding = locale_charset ();
+ if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
+ return enc_utf8;
+ if (STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
+ return enc_eucjp;
+ if (STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+ || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
+ || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
+ return enc_94;
+ if (STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
+ return enc_euctw;
+ if (STREQ_OPT (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
+ return enc_gb18030;
+ if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
+ return enc_sjis;
+ return enc_other;
+}
+
+#if GNULIB_WCHAR_SINGLE
+/* When we know that the locale does not change, provide a speedup by
+ caching the value of locale_enc. */
+static int cached_locale_enc = -1;
+static inline enc_t
+locale_enc_cached (void)
+{
+ if (cached_locale_enc < 0)
+ cached_locale_enc = locale_enc ();
+ return cached_locale_enc;
+}
+#else
+/* By default, don't make assumptions, hence no caching. */
+# define locale_enc_cached locale_enc
+#endif
+
+verify (sizeof (mbstate_t) >= 4);
+
+static char internal_state[4];
+
+size_t
+mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+ char *pstate = (char *)ps;
+
+ if (s == NULL)
+ {
+ pwc = NULL;
+ s = "";
+ n = 1;
+ }
+
+ if (n == 0)
+ return (size_t)(-2);
+
+ /* Here n > 0. */
+
+ if (pstate == NULL)
+ pstate = internal_state;
+
+ {
+ size_t nstate = pstate[0];
+ char buf[4];
+ const char *p;
+ size_t m;
+
+ switch (nstate)
+ {
+ case 0:
+ p = s;
+ m = n;
+ break;
+ case 3:
+ buf[2] = pstate[3];
+ FALLTHROUGH;
+ case 2:
+ buf[1] = pstate[2];
+ FALLTHROUGH;
+ case 1:
+ buf[0] = pstate[1];
+ p = buf;
+ m = nstate;
+ buf[m++] = s[0];
+ if (n >= 2 && m < 4)
+ {
+ buf[m++] = s[1];
+ if (n >= 3 && m < 4)
+ buf[m++] = s[2];
+ }
+ break;
+ default:
+ errno = EINVAL;
+ return (size_t)(-1);
+ }
+
+ /* Here m > 0. */
+
+# if __GLIBC__ || defined __UCLIBC__
+ /* Work around bug <https://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
+ mbtowc (NULL, NULL, 0);
+# endif
+ {
+ int res = mbtowc (pwc, p, m);
+
+ if (res >= 0)
+ {
+ if (pwc != NULL && ((*pwc == 0) != (res == 0)))
+ abort ();
+ if (nstate >= (res > 0 ? res : 1))
+ abort ();
+ res -= nstate;
+ pstate[0] = 0;
+ return res;
+ }
+
+ /* mbtowc does not distinguish between invalid and incomplete multibyte
+ sequences. But mbrtowc needs to make this distinction.
+ There are two possible approaches:
+ - Use iconv() and its return value.
+ - Use built-in knowledge about the possible encodings.
+ Given the low quality of implementation of iconv() on the systems that
+ lack mbrtowc(), we use the second approach.
+ The possible encodings are:
+ - 8-bit encodings,
+ - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
+ - UTF-8.
+ Use specialized code for each. */
+ if (m >= 4 || m >= MB_CUR_MAX)
+ goto invalid;
+ /* Here MB_CUR_MAX > 1 and 0 < m < 4. */
+ switch (locale_enc_cached ())
+ {
+ case enc_utf8: /* UTF-8 */
+ {
+ /* Cf. unistr/u8-mblen.c. */
+ unsigned char c = (unsigned char) p[0];
+
+ if (c >= 0xc2)
+ {
+ if (c < 0xe0)
+ {
+ if (m == 1)
+ goto incomplete;
+ }
+ else if (c < 0xf0)
+ {
+ if (m == 1)
+ goto incomplete;
+ if (m == 2)
+ {
+ unsigned char c2 = (unsigned char) p[1];
+
+ if ((c2 ^ 0x80) < 0x40
+ && (c >= 0xe1 || c2 >= 0xa0)
+ && (c != 0xed || c2 < 0xa0))
+ goto incomplete;
+ }
+ }
+ else if (c <= 0xf4)
+ {
+ if (m == 1)
+ goto incomplete;
+ else /* m == 2 || m == 3 */
+ {
+ unsigned char c2 = (unsigned char) p[1];
+
+ if ((c2 ^ 0x80) < 0x40
+ && (c >= 0xf1 || c2 >= 0x90)
+ && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
+ {
+ if (m == 2)
+ goto incomplete;
+ else /* m == 3 */
+ {
+ unsigned char c3 = (unsigned char) p[2];
+
+ if ((c3 ^ 0x80) < 0x40)
+ goto incomplete;
+ }
+ }
+ }
+ }
+ }
+ goto invalid;
+ }
+
+ /* As a reference for this code, you can use the GNU libiconv
+ implementation. Look for uses of the RET_TOOFEW macro. */
+
+ case enc_eucjp: /* EUC-JP */
+ {
+ if (m == 1)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
+ goto incomplete;
+ }
+ if (m == 2)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if (c == 0x8f)
+ {
+ unsigned char c2 = (unsigned char) p[1];
+
+ if (c2 >= 0xa1 && c2 < 0xff)
+ goto incomplete;
+ }
+ }
+ goto invalid;
+ }
+
+ case enc_94: /* EUC-KR, GB2312, BIG5 */
+ {
+ if (m == 1)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if (c >= 0xa1 && c < 0xff)
+ goto incomplete;
+ }
+ goto invalid;
+ }
+
+ case enc_euctw: /* EUC-TW */
+ {
+ if (m == 1)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
+ goto incomplete;
+ }
+ else /* m == 2 || m == 3 */
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if (c == 0x8e)
+ goto incomplete;
+ }
+ goto invalid;
+ }
+
+ case enc_gb18030: /* GB18030 */
+ {
+ if (m == 1)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
+ goto incomplete;
+ }
+ else /* m == 2 || m == 3 */
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if (c >= 0x90 && c <= 0xe3)
+ {
+ unsigned char c2 = (unsigned char) p[1];
+
+ if (c2 >= 0x30 && c2 <= 0x39)
+ {
+ if (m == 2)
+ goto incomplete;
+ else /* m == 3 */
+ {
+ unsigned char c3 = (unsigned char) p[2];
+
+ if (c3 >= 0x81 && c3 <= 0xfe)
+ goto incomplete;
+ }
+ }
+ }
+ }
+ goto invalid;
+ }
+
+ case enc_sjis: /* SJIS */
+ {
+ if (m == 1)
+ {
+ unsigned char c = (unsigned char) p[0];
+
+ if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
+ || (c >= 0xf0 && c <= 0xf9))
+ goto incomplete;
+ }
+ goto invalid;
+ }
+
+ default:
+ /* An unknown multibyte encoding. */
+ goto incomplete;
+ }
+
+ incomplete:
+ {
+ size_t k = nstate;
+ /* Here 0 <= k < m < 4. */
+ pstate[++k] = s[0];
+ if (k < m)
+ {
+ pstate[++k] = s[1];
+ if (k < m)
+ pstate[++k] = s[2];
+ }
+ if (k != m)
+ abort ();
+ }
+ pstate[0] = m;
+ return (size_t)(-2);
+
+ invalid:
+ errno = EILSEQ;
+ /* The conversion state is undefined, says POSIX. */
+ return (size_t)(-1);
+ }
+ }
+}
+
+#else
+/* Override the system's mbrtowc() function. */
+
+# undef mbrtowc
+
+size_t
+rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+ size_t ret;
+ wchar_t wc;
+
+# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG
+ if (s == NULL)
+ {
+ pwc = NULL;
+ s = "";
+ n = 1;
+ }
+# endif
+
+# if MBRTOWC_EMPTY_INPUT_BUG
+ if (n == 0)
+ return (size_t) -2;
+# endif
+
+ if (! pwc)
+ pwc = &wc;
+
+# if MBRTOWC_RETVAL_BUG
+ {
+ static mbstate_t internal_state;
+
+ /* Override mbrtowc's internal state. We cannot call mbsinit() on the
+ hidden internal state, but we can call it on our variable. */
+ if (ps == NULL)
+ ps = &internal_state;
+
+ if (!mbsinit (ps))
+ {
+ /* Parse the rest of the multibyte character byte for byte. */
+ size_t count = 0;
+ for (; n > 0; s++, n--)
+ {
+ ret = mbrtowc (&wc, s, 1, ps);
+
+ if (ret == (size_t)(-1))
+ return (size_t)(-1);
+ count++;
+ if (ret != (size_t)(-2))
+ {
+ /* The multibyte character has been completed. */
+ *pwc = wc;
+ return (wc == 0 ? 0 : count);
+ }
+ }
+ return (size_t)(-2);
+ }
+ }
+# endif
+
+ ret = mbrtowc (pwc, s, n, ps);
+
+# if MBRTOWC_NUL_RETVAL_BUG
+ if (ret < (size_t) -2 && !*pwc)
+ return 0;
+# endif
+
+# if C_LOCALE_MAYBE_EILSEQ
+ if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE))
+ {
+ unsigned char uc = *s;
+ *pwc = uc;
+ return 1;
+ }
+# endif
+
+ return ret;
+}
+
+#endif
diff --git a/grub-core/lib/gnulib/mbsinit.c b/grub-core/lib/gnulib/mbsinit.c
new file mode 100644
index 0000000..5ecaef7
--- /dev/null
+++ b/grub-core/lib/gnulib/mbsinit.c
@@ -0,0 +1,73 @@
+/* Test for initial conversion state.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <wchar.h>
+
+#include "verify.h"
+
+#if GNULIB_defined_mbstate_t
+
+/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
+ and wcrtomb(), wcsrtombs().
+ We assume that
+ - sizeof (mbstate_t) >= 4,
+ - only stateless encodings are supported (such as UTF-8 and EUC-JP, but
+ not ISO-2022 variants),
+ - for each encoding, the number of bytes for a wide character is <= 4.
+ (This maximum is attained for UTF-8, GB18030, EUC-TW.)
+ We define the meaning of mbstate_t as follows:
+ - In mb -> wc direction, mbstate_t's first byte contains the number of
+ buffered bytes (in the range 0..3), followed by up to 3 buffered bytes.
+ See mbrtowc.c.
+ - In wc -> mb direction, mbstate_t contains no information. In other
+ words, it is always in the initial state. */
+
+verify (sizeof (mbstate_t) >= 4);
+
+int
+mbsinit (const mbstate_t *ps)
+{
+ const char *pstate = (const char *)ps;
+
+ return pstate == NULL || pstate[0] == 0;
+}
+
+#else
+
+int
+mbsinit (const mbstate_t *ps)
+{
+# if defined _WIN32 && !defined __CYGWIN__
+ /* Native Windows. */
+# ifdef __MINGW32__
+ /* On mingw, 'mbstate_t' is defined as 'int'. */
+ return ps == NULL || *ps == 0;
+# else
+ /* MSVC defines 'mbstate_t' as an 8-byte struct; the first 4-bytes matter. */
+ return ps == NULL || *(const unsigned int *)ps == 0;
+# endif
+# else
+ /* Minix, HP-UX 11.00, Solaris 2.6, Interix, ... */
+ /* Maybe this definition works, maybe not... */
+ return ps == NULL || *(const char *)ps == 0;
+# endif
+}
+
+#endif
diff --git a/grub-core/lib/gnulib/mbsrtowcs-impl.h b/grub-core/lib/gnulib/mbsrtowcs-impl.h
new file mode 100644
index 0000000..110d692
--- /dev/null
+++ b/grub-core/lib/gnulib/mbsrtowcs-impl.h
@@ -0,0 +1,122 @@
+/* Convert string to wide string.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+size_t
+mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+{
+ if (ps == NULL)
+ ps = &_gl_mbsrtowcs_state;
+ {
+ const char *src = *srcp;
+
+ if (dest != NULL)
+ {
+ wchar_t *destptr = dest;
+
+ for (; len > 0; destptr++, len--)
+ {
+ size_t src_avail;
+ size_t ret;
+
+ /* An optimized variant of
+ src_avail = strnlen1 (src, MB_LEN_MAX); */
+ if (src[0] == '\0')
+ src_avail = 1;
+ else if (src[1] == '\0')
+ src_avail = 2;
+ else if (src[2] == '\0')
+ src_avail = 3;
+ else if (MB_LEN_MAX <= 4 || src[3] == '\0')
+ src_avail = 4;
+ else
+ src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
+
+ /* Parse the next multibyte character. */
+ ret = mbrtowc (destptr, src, src_avail, ps);
+
+ if (ret == (size_t)(-2))
+ /* Encountered a multibyte character that extends past a '\0' byte
+ or that is longer than MB_LEN_MAX bytes. Cannot happen. */
+ abort ();
+
+ if (ret == (size_t)(-1))
+ goto bad_input;
+ if (ret == 0)
+ {
+ src = NULL;
+ /* Here mbsinit (ps). */
+ break;
+ }
+ src += ret;
+ }
+
+ *srcp = src;
+ return destptr - dest;
+ }
+ else
+ {
+ /* Ignore dest and len, don't store *srcp at the end, and
+ don't clobber *ps. */
+ mbstate_t state = *ps;
+ size_t totalcount = 0;
+
+ for (;; totalcount++)
+ {
+ size_t src_avail;
+ size_t ret;
+
+ /* An optimized variant of
+ src_avail = strnlen1 (src, MB_LEN_MAX); */
+ if (src[0] == '\0')
+ src_avail = 1;
+ else if (src[1] == '\0')
+ src_avail = 2;
+ else if (src[2] == '\0')
+ src_avail = 3;
+ else if (MB_LEN_MAX <= 4 || src[3] == '\0')
+ src_avail = 4;
+ else
+ src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
+
+ /* Parse the next multibyte character. */
+ ret = mbrtowc (NULL, src, src_avail, &state);
+
+ if (ret == (size_t)(-2))
+ /* Encountered a multibyte character that extends past a '\0' byte
+ or that is longer than MB_LEN_MAX bytes. Cannot happen. */
+ abort ();
+
+ if (ret == (size_t)(-1))
+ goto bad_input2;
+ if (ret == 0)
+ {
+ /* Here mbsinit (&state). */
+ break;
+ }
+ src += ret;
+ }
+
+ return totalcount;
+ }
+
+ bad_input:
+ *srcp = src;
+ bad_input2:
+ errno = EILSEQ;
+ return (size_t)(-1);
+ }
+}
diff --git a/grub-core/lib/gnulib/mbsrtowcs-state.c b/grub-core/lib/gnulib/mbsrtowcs-state.c
new file mode 100644
index 0000000..59525e7
--- /dev/null
+++ b/grub-core/lib/gnulib/mbsrtowcs-state.c
@@ -0,0 +1,37 @@
+/* Convert string to wide string.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <wchar.h>
+
+/* Internal state used by the functions mbsrtowcs() and mbsnrtowcs(). */
+mbstate_t _gl_mbsrtowcs_state
+/* The state must initially be in the "initial state"; so, zero-initialize it.
+ On most systems, putting it into BSS is sufficient. Not so on Mac OS X 10.3,
+ see <https://lists.gnu.org/r/bug-gnulib/2009-01/msg00329.html>.
+ When it needs an initializer, use 0 or {0} as initializer? 0 only works
+ when mbstate_t is a scalar type (such as when gnulib defines it, or on
+ AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct
+ or union type, but also for a scalar type (ISO C 99, 6.7.8.(11)). */
+#if defined __ELF__
+ /* On ELF systems, variables in BSS behave well. */
+#else
+ /* Use braces, to be on the safe side. */
+ = { 0 }
+#endif
+ ;
diff --git a/grub-core/lib/gnulib/mbsrtowcs.c b/grub-core/lib/gnulib/mbsrtowcs.c
new file mode 100644
index 0000000..14f241e
--- /dev/null
+++ b/grub-core/lib/gnulib/mbsrtowcs.c
@@ -0,0 +1,32 @@
+/* Convert string to wide string.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <wchar.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#include "strnlen1.h"
+
+
+extern mbstate_t _gl_mbsrtowcs_state;
+
+#include "mbsrtowcs-impl.h"
diff --git a/grub-core/lib/gnulib/mbswidth.c b/grub-core/lib/gnulib/mbswidth.c
new file mode 100644
index 0000000..b3fb7f8
--- /dev/null
+++ b/grub-core/lib/gnulib/mbswidth.c
@@ -0,0 +1,208 @@
+/* Determine the number of screen columns needed for a string.
+ Copyright (C) 2000-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <haible@clisp.cons.org>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "mbswidth.h"
+
+/* Get MB_CUR_MAX. */
+#include <stdlib.h>
+
+#include <string.h>
+
+/* Get isprint(). */
+#include <ctype.h>
+
+/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */
+#include <wchar.h>
+
+/* Get iswcntrl(). */
+#include <wctype.h>
+
+/* Get INT_MAX. */
+#include <limits.h>
+
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
+/* Returns the number of columns needed to represent the multibyte
+ character string pointed to by STRING. If a non-printable character
+ occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned.
+ With flags = MBSW_REJECT_INVALID | MBSW_REJECT_UNPRINTABLE, this is
+ the multibyte analogue of the wcswidth function. */
+int
+mbswidth (const char *string, int flags)
+{
+ return mbsnwidth (string, strlen (string), flags);
+}
+
+/* Returns the number of columns needed to represent the multibyte
+ character string pointed to by STRING of length NBYTES. If a
+ non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is
+ specified, -1 is returned. */
+int
+mbsnwidth (const char *string, size_t nbytes, int flags)
+{
+ const char *p = string;
+ const char *plimit = p + nbytes;
+ int width;
+
+ width = 0;
+ if (MB_CUR_MAX > 1)
+ {
+ while (p < plimit)
+ switch (*p)
+ {
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* These characters are printable ASCII characters. */
+ p++;
+ width++;
+ break;
+ case '\0':
+ if (flags & MBSW_STOP_AT_NUL)
+ return width;
+ FALLTHROUGH;
+ default:
+ /* If we have a multibyte sequence, scan it up to its end. */
+ {
+ mbstate_t mbstate;
+ memset (&mbstate, 0, sizeof mbstate);
+ do
+ {
+ wchar_t wc;
+ size_t bytes;
+ int w;
+
+ bytes = mbrtowc (&wc, p, plimit - p, &mbstate);
+
+ if (bytes == (size_t) -1)
+ /* An invalid multibyte sequence was encountered. */
+ {
+ if (!(flags & MBSW_REJECT_INVALID))
+ {
+ p++;
+ width++;
+ break;
+ }
+ else
+ return -1;
+ }
+
+ if (bytes == (size_t) -2)
+ /* An incomplete multibyte character at the end. */
+ {
+ if (!(flags & MBSW_REJECT_INVALID))
+ {
+ p = plimit;
+ width++;
+ break;
+ }
+ else
+ return -1;
+ }
+
+ if (bytes == 0)
+ /* A null wide character was encountered. */
+ bytes = 1;
+
+ w = wcwidth (wc);
+ if (w >= 0)
+ /* A printable multibyte character. */
+ {
+ if (w > INT_MAX - width)
+ goto overflow;
+ width += w;
+ }
+ else
+ /* An unprintable multibyte character. */
+ if (!(flags & MBSW_REJECT_UNPRINTABLE))
+ {
+ if (!iswcntrl (wc))
+ {
+ if (width == INT_MAX)
+ goto overflow;
+ width++;
+ }
+ }
+ else
+ return -1;
+
+ p += bytes;
+ }
+ while (! mbsinit (&mbstate));
+ }
+ break;
+ }
+ return width;
+ }
+
+ while (p < plimit)
+ {
+ unsigned char c = (unsigned char) *p++;
+
+ if (c == 0 && (flags & MBSW_STOP_AT_NUL))
+ return width;
+
+ if (isprint (c))
+ {
+ if (width == INT_MAX)
+ goto overflow;
+ width++;
+ }
+ else if (!(flags & MBSW_REJECT_UNPRINTABLE))
+ {
+ if (!iscntrl (c))
+ {
+ if (width == INT_MAX)
+ goto overflow;
+ width++;
+ }
+ }
+ else
+ return -1;
+ }
+ return width;
+
+ overflow:
+ return INT_MAX;
+}
diff --git a/grub-core/lib/gnulib/mbswidth.h b/grub-core/lib/gnulib/mbswidth.h
new file mode 100644
index 0000000..45a123e
--- /dev/null
+++ b/grub-core/lib/gnulib/mbswidth.h
@@ -0,0 +1,64 @@
+/* Determine the number of screen columns needed for a string.
+ Copyright (C) 2000-2004, 2007, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <stddef.h>
+
+/* Avoid a clash of our mbswidth() with a function of the same name defined
+ in UnixWare 7.1.1 <wchar.h>. We need this #include before the #define
+ below.
+ However, we don't want to #include <wchar.h> on all platforms because
+ - Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+ <wchar.h>.
+ - BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
+ <wchar.h>. */
+#if HAVE_DECL_MBSWIDTH_IN_WCHAR_H
+# include <wchar.h>
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Optional flags to influence mbswidth/mbsnwidth behavior. */
+
+/* If this bit is set, return -1 upon finding an invalid or incomplete
+ character. Otherwise, assume invalid characters have width 1. */
+#define MBSW_REJECT_INVALID 1
+
+/* If this bit is set, return -1 upon finding a non-printable character.
+ Otherwise, assume unprintable characters have width 0 if they are
+ control characters and 1 otherwise. */
+#define MBSW_REJECT_UNPRINTABLE 2
+
+/* If this bit is set \0 is treated as the end of string.
+ Otherwise it's treated as a normal one column width character. */
+#define MBSW_STOP_AT_NUL 4
+
+
+/* Returns the number of screen columns needed for STRING. */
+#define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */
+extern int mbswidth (const char *string, int flags);
+
+/* Returns the number of screen columns needed for the NBYTES bytes
+ starting at BUF. */
+extern int mbsnwidth (const char *buf, size_t nbytes, int flags);
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/grub-core/lib/gnulib/mbtowc-impl.h b/grub-core/lib/gnulib/mbtowc-impl.h
new file mode 100644
index 0000000..f4ab981
--- /dev/null
+++ b/grub-core/lib/gnulib/mbtowc-impl.h
@@ -0,0 +1,44 @@
+/* Convert multibyte character to wide character.
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+/* We don't need a static internal state, because the encoding is not state
+ dependent, and when mbrtowc returns (size_t)(-2). we throw the result
+ away. */
+
+int
+mbtowc (wchar_t *pwc, const char *s, size_t n)
+{
+ if (s == NULL)
+ return 0;
+ else
+ {
+ mbstate_t state;
+ wchar_t wc;
+ size_t result;
+
+ memset (&state, 0, sizeof (mbstate_t));
+ result = mbrtowc (&wc, s, n, &state);
+ if (result == (size_t)-1 || result == (size_t)-2)
+ {
+ errno = EILSEQ;
+ return -1;
+ }
+ if (pwc != NULL)
+ *pwc = wc;
+ return (wc == 0 ? 0 : result);
+ }
+}
diff --git a/grub-core/lib/gnulib/mbtowc.c b/grub-core/lib/gnulib/mbtowc.c
new file mode 100644
index 0000000..77a8472
--- /dev/null
+++ b/grub-core/lib/gnulib/mbtowc.c
@@ -0,0 +1,26 @@
+/* Convert multibyte character to wide character.
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <errno.h>
+#include <string.h>
+#include <wchar.h>
+
+#include "mbtowc-impl.h"
diff --git a/grub-core/lib/gnulib/memchr.c b/grub-core/lib/gnulib/memchr.c
new file mode 100644
index 0000000..4e0c5f9
--- /dev/null
+++ b/grub-core/lib/gnulib/memchr.c
@@ -0,0 +1,172 @@
+/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2019
+ Free Software Foundation, Inc.
+
+ Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
+ with help from Dan Sahlin (dan@sics.se) and
+ commentary by Jim Blandy (jimb@ai.mit.edu);
+ adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
+ and implemented by Roland McGrath (roland@ai.mit.edu).
+
+NOTE: The canonical source of this file is maintained with the GNU C Library.
+Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+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 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+#include <string.h>
+
+#include <stddef.h>
+
+#if defined _LIBC
+# include <memcopy.h>
+#else
+# define reg_char char
+#endif
+
+#include <limits.h>
+
+#if HAVE_BP_SYM_H || defined _LIBC
+# include <bp-sym.h>
+#else
+# define BP_SYM(sym) sym
+#endif
+
+#undef __memchr
+#ifdef _LIBC
+# undef memchr
+#endif
+
+#ifndef weak_alias
+# define __memchr memchr
+#endif
+
+/* Search no more than N bytes of S for C. */
+void *
+__memchr (void const *s, int c_in, size_t n)
+{
+ /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
+ long instead of a 64-bit uintmax_t tends to give better
+ performance. On 64-bit hardware, unsigned long is generally 64
+ bits already. Change this typedef to experiment with
+ performance. */
+ typedef unsigned long int longword;
+
+ const unsigned char *char_ptr;
+ const longword *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ unsigned reg_char c;
+
+ c = (unsigned char) c_in;
+
+ /* Handle the first few bytes by reading one byte at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = (const unsigned char *) s;
+ n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
+ --n, ++char_ptr)
+ if (*char_ptr == c)
+ return (void *) char_ptr;
+
+ longword_ptr = (const longword *) char_ptr;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to any size longwords. */
+
+ /* Compute auxiliary longword values:
+ repeated_one is a value which has a 1 in every byte.
+ repeated_c has c in every byte. */
+ repeated_one = 0x01010101;
+ repeated_c = c | (c << 8);
+ repeated_c |= repeated_c << 16;
+ if (0xffffffffU < (longword) -1)
+ {
+ repeated_one |= repeated_one << 31 << 1;
+ repeated_c |= repeated_c << 31 << 1;
+ if (8 < sizeof (longword))
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
+ }
+
+ /* Instead of the traditional loop which tests each byte, we will test a
+ longword at a time. The tricky part is testing if *any of the four*
+ bytes in the longword in question are equal to c. We first use an xor
+ with repeated_c. This reduces the task to testing whether *any of the
+ four* bytes in longword1 is zero.
+
+ We compute tmp =
+ ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+ That is, we perform the following operations:
+ 1. Subtract repeated_one.
+ 2. & ~longword1.
+ 3. & a mask consisting of 0x80 in every byte.
+ Consider what happens in each byte:
+ - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
+ and step 3 transforms it into 0x80. A carry can also be propagated
+ to more significant bytes.
+ - If a byte of longword1 is nonzero, let its lowest 1 bit be at
+ position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
+ the byte ends in a single bit of value 0 and k bits of value 1.
+ After step 2, the result is just k bits of value 1: 2^k - 1. After
+ step 3, the result is 0. And no carry is produced.
+ So, if longword1 has only non-zero bytes, tmp is zero.
+ Whereas if longword1 has a zero byte, call j the position of the least
+ significant zero byte. Then the result has a zero at positions 0, ...,
+ j-1 and a 0x80 at position j. We cannot predict the result at the more
+ significant bytes (positions j+1..3), but it does not matter since we
+ already have a non-zero bit at position 8*j+7.
+
+ So, the test whether any byte in longword1 is zero is equivalent to
+ testing whether tmp is nonzero. */
+
+ while (n >= sizeof (longword))
+ {
+ longword longword1 = *longword_ptr ^ repeated_c;
+
+ if ((((longword1 - repeated_one) & ~longword1)
+ & (repeated_one << 7)) != 0)
+ break;
+ longword_ptr++;
+ n -= sizeof (longword);
+ }
+
+ char_ptr = (const unsigned char *) longword_ptr;
+
+ /* At this point, we know that either n < sizeof (longword), or one of the
+ sizeof (longword) bytes starting at char_ptr is == c. On little-endian
+ machines, we could determine the first such byte without any further
+ memory accesses, just by looking at the tmp result from the last loop
+ iteration. But this does not work on big-endian machines. Choose code
+ that works in both cases. */
+
+ for (; n > 0; --n, ++char_ptr)
+ {
+ if (*char_ptr == c)
+ return (void *) char_ptr;
+ }
+
+ return NULL;
+}
+#ifdef weak_alias
+weak_alias (__memchr, BP_SYM (memchr))
+#endif
diff --git a/grub-core/lib/gnulib/memchr.valgrind b/grub-core/lib/gnulib/memchr.valgrind
new file mode 100644
index 0000000..60f247e
--- /dev/null
+++ b/grub-core/lib/gnulib/memchr.valgrind
@@ -0,0 +1,14 @@
+# Suppress a valgrind message about use of uninitialized memory in memchr().
+# POSIX states that when the character is found, memchr must not read extra
+# bytes in an overestimated length (for example, where memchr is used to
+# implement strnlen). However, we use a safe word read to provide a speedup.
+{
+ memchr-value4
+ Memcheck:Value4
+ fun:rpl_memchr
+}
+{
+ memchr-value8
+ Memcheck:Value8
+ fun:rpl_memchr
+}
diff --git a/grub-core/lib/gnulib/mempcpy.c b/grub-core/lib/gnulib/mempcpy.c
new file mode 100644
index 0000000..d0220e1
--- /dev/null
+++ b/grub-core/lib/gnulib/mempcpy.c
@@ -0,0 +1,28 @@
+/* Copy memory area and return pointer after last written byte.
+ Copyright (C) 2003, 2007, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+/* Copy N bytes of SRC to DEST, return pointer to bytes after the
+ last written byte. */
+void *
+mempcpy (void *dest, const void *src, size_t n)
+{
+ return (char *) memcpy (dest, src, n) + n;
+}
diff --git a/grub-core/lib/gnulib/memrchr.c b/grub-core/lib/gnulib/memrchr.c
new file mode 100644
index 0000000..9602283
--- /dev/null
+++ b/grub-core/lib/gnulib/memrchr.c
@@ -0,0 +1,161 @@
+/* memrchr -- find the last occurrence of a byte in a memory block
+
+ Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2019 Free Software
+ Foundation, Inc.
+
+ Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
+ with help from Dan Sahlin (dan@sics.se) and
+ commentary by Jim Blandy (jimb@ai.mit.edu);
+ adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
+ and implemented by Roland McGrath (roland@ai.mit.edu).
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#if defined _LIBC
+# include <memcopy.h>
+#else
+# include <config.h>
+# define reg_char char
+#endif
+
+#include <string.h>
+#include <limits.h>
+
+#undef __memrchr
+#ifdef _LIBC
+# undef memrchr
+#endif
+
+#ifndef weak_alias
+# define __memrchr memrchr
+#endif
+
+/* Search no more than N bytes of S for C. */
+void *
+__memrchr (void const *s, int c_in, size_t n)
+{
+ /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
+ long instead of a 64-bit uintmax_t tends to give better
+ performance. On 64-bit hardware, unsigned long is generally 64
+ bits already. Change this typedef to experiment with
+ performance. */
+ typedef unsigned long int longword;
+
+ const unsigned char *char_ptr;
+ const longword *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ unsigned reg_char c;
+
+ c = (unsigned char) c_in;
+
+ /* Handle the last few bytes by reading one byte at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = (const unsigned char *) s + n;
+ n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
+ --n)
+ if (*--char_ptr == c)
+ return (void *) char_ptr;
+
+ longword_ptr = (const void *) char_ptr;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to any size longwords. */
+
+ /* Compute auxiliary longword values:
+ repeated_one is a value which has a 1 in every byte.
+ repeated_c has c in every byte. */
+ repeated_one = 0x01010101;
+ repeated_c = c | (c << 8);
+ repeated_c |= repeated_c << 16;
+ if (0xffffffffU < (longword) -1)
+ {
+ repeated_one |= repeated_one << 31 << 1;
+ repeated_c |= repeated_c << 31 << 1;
+ if (8 < sizeof (longword))
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
+ }
+
+ /* Instead of the traditional loop which tests each byte, we will test a
+ longword at a time. The tricky part is testing if *any of the four*
+ bytes in the longword in question are equal to c. We first use an xor
+ with repeated_c. This reduces the task to testing whether *any of the
+ four* bytes in longword1 is zero.
+
+ We compute tmp =
+ ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+ That is, we perform the following operations:
+ 1. Subtract repeated_one.
+ 2. & ~longword1.
+ 3. & a mask consisting of 0x80 in every byte.
+ Consider what happens in each byte:
+ - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
+ and step 3 transforms it into 0x80. A carry can also be propagated
+ to more significant bytes.
+ - If a byte of longword1 is nonzero, let its lowest 1 bit be at
+ position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
+ the byte ends in a single bit of value 0 and k bits of value 1.
+ After step 2, the result is just k bits of value 1: 2^k - 1. After
+ step 3, the result is 0. And no carry is produced.
+ So, if longword1 has only non-zero bytes, tmp is zero.
+ Whereas if longword1 has a zero byte, call j the position of the least
+ significant zero byte. Then the result has a zero at positions 0, ...,
+ j-1 and a 0x80 at position j. We cannot predict the result at the more
+ significant bytes (positions j+1..3), but it does not matter since we
+ already have a non-zero bit at position 8*j+7.
+
+ So, the test whether any byte in longword1 is zero is equivalent to
+ testing whether tmp is nonzero. */
+
+ while (n >= sizeof (longword))
+ {
+ longword longword1 = *--longword_ptr ^ repeated_c;
+
+ if ((((longword1 - repeated_one) & ~longword1)
+ & (repeated_one << 7)) != 0)
+ {
+ longword_ptr++;
+ break;
+ }
+ n -= sizeof (longword);
+ }
+
+ char_ptr = (const unsigned char *) longword_ptr;
+
+ /* At this point, we know that either n < sizeof (longword), or one of the
+ sizeof (longword) bytes starting at char_ptr is == c. On little-endian
+ machines, we could determine the first such byte without any further
+ memory accesses, just by looking at the tmp result from the last loop
+ iteration. But this does not work on big-endian machines. Choose code
+ that works in both cases. */
+
+ while (n-- > 0)
+ {
+ if (*--char_ptr == c)
+ return (void *) char_ptr;
+ }
+
+ return NULL;
+}
+#ifdef weak_alias
+weak_alias (__memrchr, memrchr)
+#endif
diff --git a/grub-core/lib/gnulib/msvc-inval.c b/grub-core/lib/gnulib/msvc-inval.c
new file mode 100644
index 0000000..75b5a07
--- /dev/null
+++ b/grub-core/lib/gnulib/msvc-inval.c
@@ -0,0 +1,129 @@
+/* Invalid parameter handler for MSVC runtime libraries.
+ Copyright (C) 2011-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "msvc-inval.h"
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \
+ && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING)
+
+/* Get _invalid_parameter_handler type and _set_invalid_parameter_handler
+ declaration. */
+# include <stdlib.h>
+
+# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
+
+static void __cdecl
+gl_msvc_invalid_parameter_handler (const wchar_t *expression,
+ const wchar_t *function,
+ const wchar_t *file,
+ unsigned int line,
+ uintptr_t dummy)
+{
+}
+
+# else
+
+/* Get declarations of the native Windows API functions. */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+# if defined _MSC_VER
+
+static void __cdecl
+gl_msvc_invalid_parameter_handler (const wchar_t *expression,
+ const wchar_t *function,
+ const wchar_t *file,
+ unsigned int line,
+ uintptr_t dummy)
+{
+ RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL);
+}
+
+# else
+
+/* An index to thread-local storage. */
+static DWORD tls_index;
+static int tls_initialized /* = 0 */;
+
+/* Used as a fallback only. */
+static struct gl_msvc_inval_per_thread not_per_thread;
+
+struct gl_msvc_inval_per_thread *
+gl_msvc_inval_current (void)
+{
+ if (!tls_initialized)
+ {
+ tls_index = TlsAlloc ();
+ tls_initialized = 1;
+ }
+ if (tls_index == TLS_OUT_OF_INDEXES)
+ /* TlsAlloc had failed. */
+ return &not_per_thread;
+ else
+ {
+ struct gl_msvc_inval_per_thread *pointer =
+ (struct gl_msvc_inval_per_thread *) TlsGetValue (tls_index);
+ if (pointer == NULL)
+ {
+ /* First call. Allocate a new 'struct gl_msvc_inval_per_thread'. */
+ pointer =
+ (struct gl_msvc_inval_per_thread *)
+ malloc (sizeof (struct gl_msvc_inval_per_thread));
+ if (pointer == NULL)
+ /* Could not allocate memory. Use the global storage. */
+ pointer = &not_per_thread;
+ TlsSetValue (tls_index, pointer);
+ }
+ return pointer;
+ }
+}
+
+static void __cdecl
+gl_msvc_invalid_parameter_handler (const wchar_t *expression,
+ const wchar_t *function,
+ const wchar_t *file,
+ unsigned int line,
+ uintptr_t dummy)
+{
+ struct gl_msvc_inval_per_thread *current = gl_msvc_inval_current ();
+ if (current->restart_valid)
+ longjmp (current->restart, 1);
+ else
+ /* An invalid parameter notification from outside the gnulib code.
+ Give the caller a chance to intervene. */
+ RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL);
+}
+
+# endif
+
+# endif
+
+static int gl_msvc_inval_initialized /* = 0 */;
+
+void
+gl_msvc_inval_ensure_handler (void)
+{
+ if (gl_msvc_inval_initialized == 0)
+ {
+ _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler);
+ gl_msvc_inval_initialized = 1;
+ }
+}
+
+#endif
diff --git a/grub-core/lib/gnulib/msvc-inval.h b/grub-core/lib/gnulib/msvc-inval.h
new file mode 100644
index 0000000..e31cf65
--- /dev/null
+++ b/grub-core/lib/gnulib/msvc-inval.h
@@ -0,0 +1,222 @@
+/* Invalid parameter handler for MSVC runtime libraries.
+ Copyright (C) 2011-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _MSVC_INVAL_H
+#define _MSVC_INVAL_H
+
+/* With MSVC runtime libraries with the "invalid parameter handler" concept,
+ functions like fprintf(), dup2(), or close() crash when the caller passes
+ an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF)
+ instead.
+ This file defines macros that turn such an invalid parameter notification
+ into a non-local exit. An error code can then be produced at the target
+ of this exit. You can thus write code like
+
+ TRY_MSVC_INVAL
+ {
+ <Code that can trigger an invalid parameter notification
+ but does not do 'return', 'break', 'continue', nor 'goto'.>
+ }
+ CATCH_MSVC_INVAL
+ {
+ <Code that handles an invalid parameter notification
+ but does not do 'return', 'break', 'continue', nor 'goto'.>
+ }
+ DONE_MSVC_INVAL;
+
+ This entire block expands to a single statement.
+
+ The handling of invalid parameters can be done in three ways:
+
+ * The default way, which is reasonable for programs (not libraries):
+ AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [DEFAULT_HANDLING])
+
+ * The way for libraries that make "hairy" calls (like close(-1), or
+ fclose(fp) where fileno(fp) is closed, or simply getdtablesize()):
+ AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [HAIRY_LIBRARY_HANDLING])
+
+ * The way for libraries that make no "hairy" calls:
+ AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [SANE_LIBRARY_HANDLING])
+ */
+
+#define DEFAULT_HANDLING 0
+#define HAIRY_LIBRARY_HANDLING 1
+#define SANE_LIBRARY_HANDLING 2
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \
+ && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING)
+/* A native Windows platform with the "invalid parameter handler" concept,
+ and either DEFAULT_HANDLING or HAIRY_LIBRARY_HANDLING. */
+
+# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
+/* Default handling. */
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* Ensure that the invalid parameter handler in installed that just returns.
+ Because we assume no other part of the program installs a different
+ invalid parameter handler, this solution is multithread-safe. */
+extern void gl_msvc_inval_ensure_handler (void);
+
+# ifdef __cplusplus
+}
+# endif
+
+# define TRY_MSVC_INVAL \
+ do \
+ { \
+ gl_msvc_inval_ensure_handler (); \
+ if (1)
+# define CATCH_MSVC_INVAL \
+ else
+# define DONE_MSVC_INVAL \
+ } \
+ while (0)
+
+# else
+/* Handling for hairy libraries. */
+
+# include <excpt.h>
+
+/* Gnulib can define its own status codes, as described in the page
+ "Raising Software Exceptions" on microsoft.com
+ <https://msdn.microsoft.com/en-us/library/het71c37.aspx>.
+ Our status codes are composed of
+ - 0xE0000000, mandatory for all user-defined status codes,
+ - 0x474E550, a API identifier ("GNU"),
+ - 0, 1, 2, ..., used to distinguish different status codes from the
+ same API. */
+# define STATUS_GNULIB_INVALID_PARAMETER (0xE0000000 + 0x474E550 + 0)
+
+# if defined _MSC_VER
+/* A compiler that supports __try/__except, as described in the page
+ "try-except statement" on microsoft.com
+ <https://msdn.microsoft.com/en-us/library/s58ftw19.aspx>.
+ With __try/__except, we can use the multithread-safe exception handling. */
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* Ensure that the invalid parameter handler in installed that raises a
+ software exception with code STATUS_GNULIB_INVALID_PARAMETER.
+ Because we assume no other part of the program installs a different
+ invalid parameter handler, this solution is multithread-safe. */
+extern void gl_msvc_inval_ensure_handler (void);
+
+# ifdef __cplusplus
+}
+# endif
+
+# define TRY_MSVC_INVAL \
+ do \
+ { \
+ gl_msvc_inval_ensure_handler (); \
+ __try
+# define CATCH_MSVC_INVAL \
+ __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER \
+ ? EXCEPTION_EXECUTE_HANDLER \
+ : EXCEPTION_CONTINUE_SEARCH)
+# define DONE_MSVC_INVAL \
+ } \
+ while (0)
+
+# else
+/* Any compiler.
+ We can only use setjmp/longjmp. */
+
+# include <setjmp.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+struct gl_msvc_inval_per_thread
+{
+ /* The restart that will resume execution at the code between
+ CATCH_MSVC_INVAL and DONE_MSVC_INVAL. It is enabled only between
+ TRY_MSVC_INVAL and CATCH_MSVC_INVAL. */
+ jmp_buf restart;
+
+ /* Tells whether the contents of restart is valid. */
+ int restart_valid;
+};
+
+/* Ensure that the invalid parameter handler in installed that passes
+ control to the gl_msvc_inval_restart if it is valid, or raises a
+ software exception with code STATUS_GNULIB_INVALID_PARAMETER otherwise.
+ Because we assume no other part of the program installs a different
+ invalid parameter handler, this solution is multithread-safe. */
+extern void gl_msvc_inval_ensure_handler (void);
+
+/* Return a pointer to the per-thread data for the current thread. */
+extern struct gl_msvc_inval_per_thread *gl_msvc_inval_current (void);
+
+# ifdef __cplusplus
+}
+# endif
+
+# define TRY_MSVC_INVAL \
+ do \
+ { \
+ struct gl_msvc_inval_per_thread *msvc_inval_current; \
+ gl_msvc_inval_ensure_handler (); \
+ msvc_inval_current = gl_msvc_inval_current (); \
+ /* First, initialize gl_msvc_inval_restart. */ \
+ if (setjmp (msvc_inval_current->restart) == 0) \
+ { \
+ /* Then, mark it as valid. */ \
+ msvc_inval_current->restart_valid = 1;
+# define CATCH_MSVC_INVAL \
+ /* Execution completed. \
+ Mark gl_msvc_inval_restart as invalid. */ \
+ msvc_inval_current->restart_valid = 0; \
+ } \
+ else \
+ { \
+ /* Execution triggered an invalid parameter notification. \
+ Mark gl_msvc_inval_restart as invalid. */ \
+ msvc_inval_current->restart_valid = 0;
+# define DONE_MSVC_INVAL \
+ } \
+ } \
+ while (0)
+
+# endif
+
+# endif
+
+#else
+/* A platform that does not need to the invalid parameter handler,
+ or when SANE_LIBRARY_HANDLING is desired. */
+
+/* The braces here avoid GCC warnings like
+ "warning: suggest explicit braces to avoid ambiguous 'else'". */
+# define TRY_MSVC_INVAL \
+ do \
+ { \
+ if (1)
+# define CATCH_MSVC_INVAL \
+ else
+# define DONE_MSVC_INVAL \
+ } \
+ while (0)
+
+#endif
+
+#endif /* _MSVC_INVAL_H */
diff --git a/grub-core/lib/gnulib/msvc-nothrow.c b/grub-core/lib/gnulib/msvc-nothrow.c
new file mode 100644
index 0000000..49b709c
--- /dev/null
+++ b/grub-core/lib/gnulib/msvc-nothrow.c
@@ -0,0 +1,51 @@
+/* Wrappers that don't throw invalid parameter notifications
+ with MSVC runtime libraries.
+ Copyright (C) 2011-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "msvc-nothrow.h"
+
+/* Get declarations of the native Windows API functions. */
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
+
+#undef _get_osfhandle
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+intptr_t
+_gl_nothrow_get_osfhandle (int fd)
+{
+ intptr_t result;
+
+ TRY_MSVC_INVAL
+ {
+ result = _get_osfhandle (fd);
+ }
+ CATCH_MSVC_INVAL
+ {
+ result = (intptr_t) INVALID_HANDLE_VALUE;
+ }
+ DONE_MSVC_INVAL;
+
+ return result;
+}
+#endif
diff --git a/grub-core/lib/gnulib/msvc-nothrow.h b/grub-core/lib/gnulib/msvc-nothrow.h
new file mode 100644
index 0000000..8d3ca78
--- /dev/null
+++ b/grub-core/lib/gnulib/msvc-nothrow.h
@@ -0,0 +1,43 @@
+/* Wrappers that don't throw invalid parameter notifications
+ with MSVC runtime libraries.
+ Copyright (C) 2011-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _MSVC_NOTHROW_H
+#define _MSVC_NOTHROW_H
+
+/* With MSVC runtime libraries with the "invalid parameter handler" concept,
+ functions like fprintf(), dup2(), or close() crash when the caller passes
+ an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF)
+ instead.
+ This file defines wrappers that turn such an invalid parameter notification
+ into an error code. */
+
+#if defined _WIN32 && ! defined __CYGWIN__
+
+/* Get original declaration of _get_osfhandle. */
+# include <io.h>
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+
+/* Override _get_osfhandle. */
+extern intptr_t _gl_nothrow_get_osfhandle (int fd);
+# define _get_osfhandle _gl_nothrow_get_osfhandle
+
+# endif
+
+#endif
+
+#endif /* _MSVC_NOTHROW_H */
diff --git a/grub-core/lib/gnulib/nl_langinfo.c b/grub-core/lib/gnulib/nl_langinfo.c
new file mode 100644
index 0000000..e8a5595
--- /dev/null
+++ b/grub-core/lib/gnulib/nl_langinfo.c
@@ -0,0 +1,366 @@
+/* nl_langinfo() replacement: query locale dependent information.
+
+ Copyright (C) 2007-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <langinfo.h>
+
+#include <locale.h>
+#include <string.h>
+#if defined _WIN32 && ! defined __CYGWIN__
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include <windows.h>
+# include <stdio.h>
+#endif
+
+#if !REPLACE_NL_LANGINFO || GNULIB_defined_CODESET
+/* Return the codeset of the current locale, if this is easily deducible.
+ Otherwise, return "". */
+static char *
+ctype_codeset (void)
+{
+ static char buf[2 + 10 + 1];
+ char const *locale = setlocale (LC_CTYPE, NULL);
+ char *codeset = buf;
+ size_t codesetlen;
+ codeset[0] = '\0';
+
+ if (locale && locale[0])
+ {
+ /* If the locale name contains an encoding after the dot, return it. */
+ char *dot = strchr (locale, '.');
+
+ if (dot)
+ {
+ /* Look for the possible @... trailer and remove it, if any. */
+ char *codeset_start = dot + 1;
+ char const *modifier = strchr (codeset_start, '@');
+
+ if (! modifier)
+ codeset = codeset_start;
+ else
+ {
+ codesetlen = modifier - codeset_start;
+ if (codesetlen < sizeof buf)
+ {
+ codeset = memcpy (buf, codeset_start, codesetlen);
+ codeset[codesetlen] = '\0';
+ }
+ }
+ }
+ }
+
+# if defined _WIN32 && ! defined __CYGWIN__
+ /* If setlocale is successful, it returns the number of the
+ codepage, as a string. Otherwise, fall back on Windows API
+ GetACP, which returns the locale's codepage as a number (although
+ this doesn't change according to what the 'setlocale' call specified).
+ Either way, prepend "CP" to make it a valid codeset name. */
+ codesetlen = strlen (codeset);
+ if (0 < codesetlen && codesetlen < sizeof buf - 2)
+ memmove (buf + 2, codeset, codesetlen + 1);
+ else
+ sprintf (buf + 2, "%u", GetACP ());
+ codeset = memcpy (buf, "CP", 2);
+# endif
+ return codeset;
+}
+#endif
+
+
+#if REPLACE_NL_LANGINFO
+
+/* Override nl_langinfo with support for added nl_item values. */
+
+# undef nl_langinfo
+
+char *
+rpl_nl_langinfo (nl_item item)
+{
+ switch (item)
+ {
+# if GNULIB_defined_CODESET
+ case CODESET:
+ return ctype_codeset ();
+# endif
+# if GNULIB_defined_T_FMT_AMPM
+ case T_FMT_AMPM:
+ return (char *) "%I:%M:%S %p";
+# endif
+# if GNULIB_defined_ALTMON
+ case ALTMON_1:
+ case ALTMON_2:
+ case ALTMON_3:
+ case ALTMON_4:
+ case ALTMON_5:
+ case ALTMON_6:
+ case ALTMON_7:
+ case ALTMON_8:
+ case ALTMON_9:
+ case ALTMON_10:
+ case ALTMON_11:
+ case ALTMON_12:
+ /* We don't ship the appropriate localizations with gnulib. Therefore,
+ treat ALTMON_i like MON_i. */
+ item = item - ALTMON_1 + MON_1;
+ break;
+# endif
+# if GNULIB_defined_ERA
+ case ERA:
+ /* The format is not standardized. In glibc it is a sequence of strings
+ of the form "direction:offset:start_date:end_date:era_name:era_format"
+ with an empty string at the end. */
+ return (char *) "";
+ case ERA_D_FMT:
+ /* The %Ex conversion in strftime behaves like %x if the locale does not
+ have an alternative time format. */
+ item = D_FMT;
+ break;
+ case ERA_D_T_FMT:
+ /* The %Ec conversion in strftime behaves like %c if the locale does not
+ have an alternative time format. */
+ item = D_T_FMT;
+ break;
+ case ERA_T_FMT:
+ /* The %EX conversion in strftime behaves like %X if the locale does not
+ have an alternative time format. */
+ item = T_FMT;
+ break;
+ case ALT_DIGITS:
+ /* The format is not standardized. In glibc it is a sequence of 10
+ strings, appended in memory. */
+ return (char *) "\0\0\0\0\0\0\0\0\0\0";
+# endif
+# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS
+ case YESEXPR:
+ return (char *) "^[yY]";
+ case NOEXPR:
+ return (char *) "^[nN]";
+# endif
+ default:
+ break;
+ }
+ return nl_langinfo (item);
+}
+
+#else
+
+/* Provide nl_langinfo from scratch, either for native MS-Windows, or
+ for old Unix platforms without locales, such as Linux libc5 or
+ BeOS. */
+
+# include <time.h>
+
+char *
+nl_langinfo (nl_item item)
+{
+ static char nlbuf[100];
+ struct tm tmm = { 0 };
+
+ switch (item)
+ {
+ /* nl_langinfo items of the LC_CTYPE category */
+ case CODESET:
+ {
+ char *codeset = ctype_codeset ();
+ if (*codeset)
+ return codeset;
+ }
+# ifdef __BEOS__
+ return (char *) "UTF-8";
+# else
+ return (char *) "ISO-8859-1";
+# endif
+ /* nl_langinfo items of the LC_NUMERIC category */
+ case RADIXCHAR:
+ return localeconv () ->decimal_point;
+ case THOUSEP:
+ return localeconv () ->thousands_sep;
+# ifdef GROUPING
+ case GROUPING:
+ return localeconv () ->grouping;
+# endif
+ /* nl_langinfo items of the LC_TIME category.
+ TODO: Really use the locale. */
+ case D_T_FMT:
+ case ERA_D_T_FMT:
+ return (char *) "%a %b %e %H:%M:%S %Y";
+ case D_FMT:
+ case ERA_D_FMT:
+ return (char *) "%m/%d/%y";
+ case T_FMT:
+ case ERA_T_FMT:
+ return (char *) "%H:%M:%S";
+ case T_FMT_AMPM:
+ return (char *) "%I:%M:%S %p";
+ case AM_STR:
+ if (!strftime (nlbuf, sizeof nlbuf, "%p", &tmm))
+ return (char *) "AM";
+ return nlbuf;
+ case PM_STR:
+ tmm.tm_hour = 12;
+ if (!strftime (nlbuf, sizeof nlbuf, "%p", &tmm))
+ return (char *) "PM";
+ return nlbuf;
+ case DAY_1:
+ case DAY_2:
+ case DAY_3:
+ case DAY_4:
+ case DAY_5:
+ case DAY_6:
+ case DAY_7:
+ {
+ static char const days[][sizeof "Wednesday"] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
+ "Friday", "Saturday"
+ };
+ tmm.tm_wday = item - DAY_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%A", &tmm))
+ return (char *) days[item - DAY_1];
+ return nlbuf;
+ }
+ case ABDAY_1:
+ case ABDAY_2:
+ case ABDAY_3:
+ case ABDAY_4:
+ case ABDAY_5:
+ case ABDAY_6:
+ case ABDAY_7:
+ {
+ static char const abdays[][sizeof "Sun"] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+ };
+ tmm.tm_wday = item - ABDAY_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%a", &tmm))
+ return (char *) abdays[item - ABDAY_1];
+ return nlbuf;
+ }
+ {
+ static char const months[][sizeof "September"] = {
+ "January", "February", "March", "April", "May", "June", "July",
+ "September", "October", "November", "December"
+ };
+ case MON_1:
+ case MON_2:
+ case MON_3:
+ case MON_4:
+ case MON_5:
+ case MON_6:
+ case MON_7:
+ case MON_8:
+ case MON_9:
+ case MON_10:
+ case MON_11:
+ case MON_12:
+ tmm.tm_mon = item - MON_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%B", &tmm))
+ return (char *) months[item - MON_1];
+ return nlbuf;
+ case ALTMON_1:
+ case ALTMON_2:
+ case ALTMON_3:
+ case ALTMON_4:
+ case ALTMON_5:
+ case ALTMON_6:
+ case ALTMON_7:
+ case ALTMON_8:
+ case ALTMON_9:
+ case ALTMON_10:
+ case ALTMON_11:
+ case ALTMON_12:
+ tmm.tm_mon = item - ALTMON_1;
+ /* The platforms without nl_langinfo() don't support strftime with %OB.
+ We don't even need to try. */
+ #if 0
+ if (!strftime (nlbuf, sizeof nlbuf, "%OB", &tmm))
+ #endif
+ if (!strftime (nlbuf, sizeof nlbuf, "%B", &tmm))
+ return (char *) months[item - ALTMON_1];
+ return nlbuf;
+ }
+ case ABMON_1:
+ case ABMON_2:
+ case ABMON_3:
+ case ABMON_4:
+ case ABMON_5:
+ case ABMON_6:
+ case ABMON_7:
+ case ABMON_8:
+ case ABMON_9:
+ case ABMON_10:
+ case ABMON_11:
+ case ABMON_12:
+ {
+ static char const abmonths[][sizeof "Jan"] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
+ "Sep", "Oct", "Nov", "Dec"
+ };
+ tmm.tm_mon = item - ABMON_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%b", &tmm))
+ return (char *) abmonths[item - ABMON_1];
+ return nlbuf;
+ }
+ case ERA:
+ return (char *) "";
+ case ALT_DIGITS:
+ return (char *) "\0\0\0\0\0\0\0\0\0\0";
+ /* nl_langinfo items of the LC_MONETARY category. */
+ case CRNCYSTR:
+ return localeconv () ->currency_symbol;
+# ifdef INT_CURR_SYMBOL
+ case INT_CURR_SYMBOL:
+ return localeconv () ->int_curr_symbol;
+ case MON_DECIMAL_POINT:
+ return localeconv () ->mon_decimal_point;
+ case MON_THOUSANDS_SEP:
+ return localeconv () ->mon_thousands_sep;
+ case MON_GROUPING:
+ return localeconv () ->mon_grouping;
+ case POSITIVE_SIGN:
+ return localeconv () ->positive_sign;
+ case NEGATIVE_SIGN:
+ return localeconv () ->negative_sign;
+ case FRAC_DIGITS:
+ return & localeconv () ->frac_digits;
+ case INT_FRAC_DIGITS:
+ return & localeconv () ->int_frac_digits;
+ case P_CS_PRECEDES:
+ return & localeconv () ->p_cs_precedes;
+ case N_CS_PRECEDES:
+ return & localeconv () ->n_cs_precedes;
+ case P_SEP_BY_SPACE:
+ return & localeconv () ->p_sep_by_space;
+ case N_SEP_BY_SPACE:
+ return & localeconv () ->n_sep_by_space;
+ case P_SIGN_POSN:
+ return & localeconv () ->p_sign_posn;
+ case N_SIGN_POSN:
+ return & localeconv () ->n_sign_posn;
+# endif
+ /* nl_langinfo items of the LC_MESSAGES category
+ TODO: Really use the locale. */
+ case YESEXPR:
+ return (char *) "^[yY]";
+ case NOEXPR:
+ return (char *) "^[nN]";
+ default:
+ return (char *) "";
+ }
+}
+
+#endif
diff --git a/grub-core/lib/gnulib/open.c b/grub-core/lib/gnulib/open.c
new file mode 100644
index 0000000..6552605
--- /dev/null
+++ b/grub-core/lib/gnulib/open.c
@@ -0,0 +1,208 @@
+/* Open a descriptor to a file.
+ Copyright (C) 2007-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+/* If the user's config.h happens to include <fcntl.h>, let it include only
+ the system's <fcntl.h> here, so that orig_open doesn't recurse to
+ rpl_open. */
+#define __need_system_fcntl_h
+#include <config.h>
+
+/* Get the original definition of open. It might be defined as a macro. */
+#include <fcntl.h>
+#include <sys/types.h>
+#undef __need_system_fcntl_h
+
+static int
+orig_open (const char *filename, int flags, mode_t mode)
+{
+ return open (filename, flags, mode);
+}
+
+/* Specification. */
+/* Write "fcntl.h" here, not <fcntl.h>, otherwise OSF/1 5.1 DTK cc eliminates
+ this include because of the preliminary #include <fcntl.h> above. */
+#include "fcntl.h"
+
+#include "cloexec.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#ifndef REPLACE_OPEN_DIRECTORY
+# define REPLACE_OPEN_DIRECTORY 0
+#endif
+
+int
+open (const char *filename, int flags, ...)
+{
+ /* 0 = unknown, 1 = yes, -1 = no. */
+#if GNULIB_defined_O_CLOEXEC
+ int have_cloexec = -1;
+#else
+ static int have_cloexec;
+#endif
+
+ mode_t mode;
+ int fd;
+
+ mode = 0;
+ if (flags & O_CREAT)
+ {
+ va_list arg;
+ va_start (arg, flags);
+
+ /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
+ creates crashing code when 'mode_t' is smaller than 'int'. */
+ mode = va_arg (arg, PROMOTED_MODE_T);
+
+ va_end (arg);
+ }
+
+#if GNULIB_defined_O_NONBLOCK
+ /* The only known platform that lacks O_NONBLOCK is mingw, but it
+ also lacks named pipes and Unix sockets, which are the only two
+ file types that require non-blocking handling in open().
+ Therefore, it is safe to ignore O_NONBLOCK here. It is handy
+ that mingw also lacks openat(), so that is also covered here. */
+ flags &= ~O_NONBLOCK;
+#endif
+
+#if defined _WIN32 && ! defined __CYGWIN__
+ if (strcmp (filename, "/dev/null") == 0)
+ filename = "NUL";
+#endif
+
+#if OPEN_TRAILING_SLASH_BUG
+ /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR
+ is specified, then fail.
+ Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
+ says that
+ "A pathname that contains at least one non-slash character and that
+ ends with one or more trailing slashes shall be resolved as if a
+ single dot character ( '.' ) were appended to the pathname."
+ and
+ "The special filename dot shall refer to the directory specified by
+ its predecessor."
+ If the named file already exists as a directory, then
+ - if O_CREAT is specified, open() must fail because of the semantics
+ of O_CREAT,
+ - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX
+ <http://www.opengroup.org/susv3/functions/open.html> says that it
+ fails with errno = EISDIR in this case.
+ If the named file does not exist or does not name a directory, then
+ - if O_CREAT is specified, open() must fail since open() cannot create
+ directories,
+ - if O_WRONLY or O_RDWR is specified, open() must fail because the
+ file does not contain a '.' directory. */
+ if (flags & (O_CREAT | O_WRONLY | O_RDWR))
+ {
+ size_t len = strlen (filename);
+ if (len > 0 && filename[len - 1] == '/')
+ {
+ errno = EISDIR;
+ return -1;
+ }
+ }
+#endif
+
+ fd = orig_open (filename,
+ flags & ~(have_cloexec <= 0 ? O_CLOEXEC : 0), mode);
+
+ if (flags & O_CLOEXEC)
+ {
+ if (! have_cloexec)
+ {
+ if (0 <= fd)
+ have_cloexec = 1;
+ else if (errno == EINVAL)
+ {
+ fd = orig_open (filename, flags & ~O_CLOEXEC, mode);
+ have_cloexec = -1;
+ }
+ }
+ if (have_cloexec < 0 && 0 <= fd)
+ set_cloexec_flag (fd, true);
+ }
+
+
+#if REPLACE_FCHDIR
+ /* Implementing fchdir and fdopendir requires the ability to open a
+ directory file descriptor. If open doesn't support that (as on
+ mingw), we use a dummy file that behaves the same as directories
+ on Linux (ie. always reports EOF on attempts to read()), and
+ override fstat() in fchdir.c to hide the fact that we have a
+ dummy. */
+ if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
+ && ((flags & O_ACCMODE) == O_RDONLY
+ || (O_SEARCH != O_RDONLY && (flags & O_ACCMODE) == O_SEARCH)))
+ {
+ struct stat statbuf;
+ if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
+ {
+ /* Maximum recursion depth of 1. */
+ fd = open ("/dev/null", flags, mode);
+ if (0 <= fd)
+ fd = _gl_register_fd (fd, filename);
+ }
+ else
+ errno = EACCES;
+ }
+#endif
+
+#if OPEN_TRAILING_SLASH_BUG
+ /* If the filename ends in a slash and fd does not refer to a directory,
+ then fail.
+ Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
+ says that
+ "A pathname that contains at least one non-slash character and that
+ ends with one or more trailing slashes shall be resolved as if a
+ single dot character ( '.' ) were appended to the pathname."
+ and
+ "The special filename dot shall refer to the directory specified by
+ its predecessor."
+ If the named file without the slash is not a directory, open() must fail
+ with ENOTDIR. */
+ if (fd >= 0)
+ {
+ /* We know len is positive, since open did not fail with ENOENT. */
+ size_t len = strlen (filename);
+ if (filename[len - 1] == '/')
+ {
+ struct stat statbuf;
+
+ if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
+ {
+ close (fd);
+ errno = ENOTDIR;
+ return -1;
+ }
+ }
+ }
+#endif
+
+#if REPLACE_FCHDIR
+ if (!REPLACE_OPEN_DIRECTORY && 0 <= fd)
+ fd = _gl_register_fd (fd, filename);
+#endif
+
+ return fd;
+}
diff --git a/grub-core/lib/gnulib/openat-die.c b/grub-core/lib/gnulib/openat-die.c
new file mode 100644
index 0000000..690c447
--- /dev/null
+++ b/grub-core/lib/gnulib/openat-die.c
@@ -0,0 +1,62 @@
+/* Report a save- or restore-cwd failure in our openat replacement and then exit.
+
+ Copyright (C) 2005-2006, 2008-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "openat.h"
+
+#include <stdlib.h>
+
+#ifndef GNULIB_LIBPOSIX
+# include "error.h"
+#endif
+
+#include "exitfail.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+_Noreturn void
+openat_save_fail (int errnum)
+{
+#ifndef GNULIB_LIBPOSIX
+ error (exit_failure, errnum,
+ _("unable to record current working directory"));
+#endif
+ /* _Noreturn cannot be applied to error, since it returns
+ when its first argument is 0. To help compilers understand that this
+ function does not return, call abort. Also, the abort is a
+ safety feature if exit_failure is 0 (which shouldn't happen). */
+ abort ();
+}
+
+
+/* Exit with an error about failure to restore the working directory
+ during an openat emulation. The caller must ensure that fd 2 is
+ not a just-opened fd, even when openat_safer is not in use. */
+
+_Noreturn void
+openat_restore_fail (int errnum)
+{
+#ifndef GNULIB_LIBPOSIX
+ error (exit_failure, errnum,
+ _("failed to return to initial working directory"));
+#endif
+
+ /* As above. */
+ abort ();
+}
diff --git a/grub-core/lib/gnulib/openat-priv.h b/grub-core/lib/gnulib/openat-priv.h
new file mode 100644
index 0000000..7b90eef
--- /dev/null
+++ b/grub-core/lib/gnulib/openat-priv.h
@@ -0,0 +1,64 @@
+/* Internals for openat-like functions.
+
+ Copyright (C) 2005-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering */
+
+#ifndef _GL_HEADER_OPENAT_PRIV
+#define _GL_HEADER_OPENAT_PRIV
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+/* Maximum number of bytes that it is safe to allocate as a single
+ array on the stack, and that is known as a compile-time constant.
+ The assumption is that we'll touch the array very quickly, or a
+ temporary very near the array, provoking an out-of-memory trap. On
+ some operating systems, there is only one guard page for the stack,
+ and a page size can be as small as 4096 bytes. Subtract 64 in the
+ hope that this will let the compiler touch a nearby temporary and
+ provoke a trap. */
+#define SAFER_ALLOCA_MAX (4096 - 64)
+
+#define SAFER_ALLOCA(m) ((m) < SAFER_ALLOCA_MAX ? (m) : SAFER_ALLOCA_MAX)
+
+#if defined PATH_MAX
+# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (PATH_MAX)
+#elif defined _XOPEN_PATH_MAX
+# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (_XOPEN_PATH_MAX)
+#else
+# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (1024)
+#endif
+
+char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file);
+
+/* Trying to access a BUILD_PROC_NAME file will fail on systems without
+ /proc support, and even on systems *with* ProcFS support. Return
+ nonzero if the failure may be legitimate, e.g., because /proc is not
+ readable, or the particular .../fd/N directory is not present. */
+#define EXPECTED_ERRNO(Errno) \
+ ((Errno) == ENOTDIR || (Errno) == ENOENT \
+ || (Errno) == EPERM || (Errno) == EACCES \
+ || (Errno) == ENOSYS /* Solaris 8 */ \
+ || (Errno) == EOPNOTSUPP /* FreeBSD */)
+
+/* Wrapper function shared among linkat and renameat. */
+int at_func2 (int fd1, char const *file1,
+ int fd2, char const *file2,
+ int (*func) (char const *file1, char const *file2));
+
+#endif /* _GL_HEADER_OPENAT_PRIV */
diff --git a/grub-core/lib/gnulib/openat-proc.c b/grub-core/lib/gnulib/openat-proc.c
new file mode 100644
index 0000000..da76e2b
--- /dev/null
+++ b/grub-core/lib/gnulib/openat-proc.c
@@ -0,0 +1,134 @@
+/* Create /proc/self/fd-related names for subfiles of open directories.
+
+ Copyright (C) 2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#include <config.h>
+
+#include "openat-priv.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef __KLIBC__
+# include <InnoTekLIBC/backend.h>
+#endif
+
+#include "intprops.h"
+
+/* Set BUF to the name of the subfile of the directory identified by
+ FD, where the subfile is named FILE. If successful, return BUF if
+ the result fits in BUF, dynamically allocated memory otherwise.
+ Return NULL (setting errno) on error. */
+char *
+openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file)
+{
+ char *result = buf;
+ int dirlen;
+
+ /* Make sure the caller gets ENOENT when appropriate. */
+ if (!*file)
+ {
+ buf[0] = '\0';
+ return buf;
+ }
+
+#ifndef __KLIBC__
+# define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/"
+ {
+ enum {
+ PROC_SELF_FD_DIR_SIZE_BOUND
+ = (sizeof PROC_SELF_FD_FORMAT - (sizeof "%d" - 1)
+ + INT_STRLEN_BOUND (int))
+ };
+
+ static int proc_status = 0;
+ if (! proc_status)
+ {
+ /* Set PROC_STATUS to a positive value if /proc/self/fd is
+ reliable, and a negative value otherwise. Solaris 10
+ /proc/self/fd mishandles "..", and any file name might expand
+ to ".." after symbolic link expansion, so avoid /proc/self/fd
+ if it mishandles "..". Solaris 10 has openat, but this
+ problem is exhibited on code that built on Solaris 8 and
+ running on Solaris 10. */
+
+ int proc_self_fd = open ("/proc/self/fd",
+ O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK);
+ if (proc_self_fd < 0)
+ proc_status = -1;
+ else
+ {
+ /* Detect whether /proc/self/fd/%i/../fd exists, where %i is the
+ number of a file descriptor open on /proc/self/fd. On Linux,
+ that name resolves to /proc/self/fd, which was opened above.
+ However, on Solaris, it may resolve to /proc/self/fd/fd, which
+ cannot exist, since all names in /proc/self/fd are numeric. */
+ char dotdot_buf[PROC_SELF_FD_DIR_SIZE_BOUND + sizeof "../fd" - 1];
+ sprintf (dotdot_buf, PROC_SELF_FD_FORMAT "../fd", proc_self_fd);
+ proc_status = access (dotdot_buf, F_OK) ? -1 : 1;
+ close (proc_self_fd);
+ }
+ }
+
+ if (proc_status < 0)
+ return NULL;
+ else
+ {
+ size_t bufsize = PROC_SELF_FD_DIR_SIZE_BOUND + strlen (file);
+ if (OPENAT_BUFFER_SIZE < bufsize)
+ {
+ result = malloc (bufsize);
+ if (! result)
+ return NULL;
+ }
+
+ dirlen = sprintf (result, PROC_SELF_FD_FORMAT, fd);
+ }
+ }
+#else
+ /* OS/2 kLIBC provides a function to retrieve a path from a fd. */
+ {
+ char dir[_MAX_PATH];
+ size_t bufsize;
+
+ if (__libc_Back_ioFHToPath (fd, dir, sizeof dir))
+ return NULL;
+
+ dirlen = strlen (dir);
+ bufsize = dirlen + 1 + strlen (file) + 1; /* 1 for '/', 1 for null */
+ if (OPENAT_BUFFER_SIZE < bufsize)
+ {
+ result = malloc (bufsize);
+ if (! result)
+ return NULL;
+ }
+
+ strcpy (result, dir);
+ result[dirlen++] = '/';
+ }
+#endif
+
+ strcpy (result + dirlen, file);
+ return result;
+}
diff --git a/grub-core/lib/gnulib/openat.c b/grub-core/lib/gnulib/openat.c
new file mode 100644
index 0000000..4ab4a31
--- /dev/null
+++ b/grub-core/lib/gnulib/openat.c
@@ -0,0 +1,314 @@
+/* provide a replacement openat function
+ Copyright (C) 2004-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering */
+
+/* If the user's config.h happens to include <fcntl.h>, let it include only
+ the system's <fcntl.h> here, so that orig_openat doesn't recurse to
+ rpl_openat. */
+#define __need_system_fcntl_h
+#include <config.h>
+
+/* Get the original definition of open. It might be defined as a macro. */
+#include <fcntl.h>
+#include <sys/types.h>
+#undef __need_system_fcntl_h
+
+#if HAVE_OPENAT
+static int
+orig_openat (int fd, char const *filename, int flags, mode_t mode)
+{
+ return openat (fd, filename, flags, mode);
+}
+#endif
+
+/* Write "fcntl.h" here, not <fcntl.h>, otherwise OSF/1 5.1 DTK cc eliminates
+ this include because of the preliminary #include <fcntl.h> above. */
+#include "fcntl.h"
+
+#include "openat.h"
+
+#include "cloexec.h"
+
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#if HAVE_OPENAT
+
+/* Like openat, but support O_CLOEXEC and work around Solaris 9 bugs
+ with trailing slash. */
+int
+rpl_openat (int dfd, char const *filename, int flags, ...)
+{
+ /* 0 = unknown, 1 = yes, -1 = no. */
+#if GNULIB_defined_O_CLOEXEC
+ int have_cloexec = -1;
+#else
+ static int have_cloexec;
+#endif
+
+ mode_t mode;
+ int fd;
+
+ mode = 0;
+ if (flags & O_CREAT)
+ {
+ va_list arg;
+ va_start (arg, flags);
+
+ /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
+ creates crashing code when 'mode_t' is smaller than 'int'. */
+ mode = va_arg (arg, PROMOTED_MODE_T);
+
+ va_end (arg);
+ }
+
+# if OPEN_TRAILING_SLASH_BUG
+ /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR
+ is specified, then fail.
+ Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
+ says that
+ "A pathname that contains at least one non-slash character and that
+ ends with one or more trailing slashes shall be resolved as if a
+ single dot character ( '.' ) were appended to the pathname."
+ and
+ "The special filename dot shall refer to the directory specified by
+ its predecessor."
+ If the named file already exists as a directory, then
+ - if O_CREAT is specified, open() must fail because of the semantics
+ of O_CREAT,
+ - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX
+ <http://www.opengroup.org/susv3/functions/open.html> says that it
+ fails with errno = EISDIR in this case.
+ If the named file does not exist or does not name a directory, then
+ - if O_CREAT is specified, open() must fail since open() cannot create
+ directories,
+ - if O_WRONLY or O_RDWR is specified, open() must fail because the
+ file does not contain a '.' directory. */
+ if (flags & (O_CREAT | O_WRONLY | O_RDWR))
+ {
+ size_t len = strlen (filename);
+ if (len > 0 && filename[len - 1] == '/')
+ {
+ errno = EISDIR;
+ return -1;
+ }
+ }
+# endif
+
+ fd = orig_openat (dfd, filename,
+ flags & ~(have_cloexec <= 0 ? O_CLOEXEC : 0), mode);
+
+ if (flags & O_CLOEXEC)
+ {
+ if (! have_cloexec)
+ {
+ if (0 <= fd)
+ have_cloexec = 1;
+ else if (errno == EINVAL)
+ {
+ fd = orig_openat (dfd, filename, flags & ~O_CLOEXEC, mode);
+ have_cloexec = -1;
+ }
+ }
+ if (have_cloexec < 0 && 0 <= fd)
+ set_cloexec_flag (fd, true);
+ }
+
+
+# if OPEN_TRAILING_SLASH_BUG
+ /* If the filename ends in a slash and fd does not refer to a directory,
+ then fail.
+ Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
+ says that
+ "A pathname that contains at least one non-slash character and that
+ ends with one or more trailing slashes shall be resolved as if a
+ single dot character ( '.' ) were appended to the pathname."
+ and
+ "The special filename dot shall refer to the directory specified by
+ its predecessor."
+ If the named file without the slash is not a directory, open() must fail
+ with ENOTDIR. */
+ if (fd >= 0)
+ {
+ /* We know len is positive, since open did not fail with ENOENT. */
+ size_t len = strlen (filename);
+ if (filename[len - 1] == '/')
+ {
+ struct stat statbuf;
+
+ if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
+ {
+ close (fd);
+ errno = ENOTDIR;
+ return -1;
+ }
+ }
+ }
+# endif
+
+ return fd;
+}
+
+#else /* !HAVE_OPENAT */
+
+# include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
+# include "openat-priv.h"
+# include "save-cwd.h"
+
+/* Replacement for Solaris' openat function.
+ <https://www.google.com/search?q=openat+site:docs.oracle.com>
+ First, try to simulate it via open ("/proc/self/fd/FD/FILE").
+ Failing that, simulate it by doing save_cwd/fchdir/open/restore_cwd.
+ If either the save_cwd or the restore_cwd fails (relatively unlikely),
+ then give a diagnostic and exit nonzero.
+ Otherwise, upon failure, set errno and return -1, as openat does.
+ Upon successful completion, return a file descriptor. */
+int
+openat (int fd, char const *file, int flags, ...)
+{
+ mode_t mode = 0;
+
+ if (flags & O_CREAT)
+ {
+ va_list arg;
+ va_start (arg, flags);
+
+ /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
+ creates crashing code when 'mode_t' is smaller than 'int'. */
+ mode = va_arg (arg, PROMOTED_MODE_T);
+
+ va_end (arg);
+ }
+
+ return openat_permissive (fd, file, flags, mode, NULL);
+}
+
+/* Like openat (FD, FILE, FLAGS, MODE), but if CWD_ERRNO is
+ nonnull, set *CWD_ERRNO to an errno value if unable to save
+ or restore the initial working directory. This is needed only
+ the first time remove.c's remove_dir opens a command-line
+ directory argument.
+
+ If a previous attempt to restore the current working directory
+ failed, then we must not even try to access a '.'-relative name.
+ It is the caller's responsibility not to call this function
+ in that case. */
+
+int
+openat_permissive (int fd, char const *file, int flags, mode_t mode,
+ int *cwd_errno)
+{
+ struct saved_cwd saved_cwd;
+ int saved_errno;
+ int err;
+ bool save_ok;
+
+ if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file))
+ return open (file, flags, mode);
+
+ {
+ char buf[OPENAT_BUFFER_SIZE];
+ char *proc_file = openat_proc_name (buf, fd, file);
+ if (proc_file)
+ {
+ int open_result = open (proc_file, flags, mode);
+ int open_errno = errno;
+ if (proc_file != buf)
+ free (proc_file);
+ /* If the syscall succeeds, or if it fails with an unexpected
+ errno value, then return right away. Otherwise, fall through
+ and resort to using save_cwd/restore_cwd. */
+ if (0 <= open_result || ! EXPECTED_ERRNO (open_errno))
+ {
+ errno = open_errno;
+ return open_result;
+ }
+ }
+ }
+
+ save_ok = (save_cwd (&saved_cwd) == 0);
+ if (! save_ok)
+ {
+ if (! cwd_errno)
+ openat_save_fail (errno);
+ *cwd_errno = errno;
+ }
+ if (0 <= fd && fd == saved_cwd.desc)
+ {
+ /* If saving the working directory collides with the user's
+ requested fd, then the user's fd must have been closed to
+ begin with. */
+ free_cwd (&saved_cwd);
+ errno = EBADF;
+ return -1;
+ }
+
+ err = fchdir (fd);
+ saved_errno = errno;
+
+ if (! err)
+ {
+ err = open (file, flags, mode);
+ saved_errno = errno;
+ if (save_ok && restore_cwd (&saved_cwd) != 0)
+ {
+ if (! cwd_errno)
+ {
+ /* Don't write a message to just-created fd 2. */
+ saved_errno = errno;
+ if (err == STDERR_FILENO)
+ close (err);
+ openat_restore_fail (saved_errno);
+ }
+ *cwd_errno = errno;
+ }
+ }
+
+ free_cwd (&saved_cwd);
+ errno = saved_errno;
+ return err;
+}
+
+/* Return true if our openat implementation must resort to
+ using save_cwd and restore_cwd. */
+bool
+openat_needs_fchdir (void)
+{
+ bool needs_fchdir = true;
+ int fd = open ("/", O_SEARCH);
+
+ if (0 <= fd)
+ {
+ char buf[OPENAT_BUFFER_SIZE];
+ char *proc_file = openat_proc_name (buf, fd, ".");
+ if (proc_file)
+ {
+ needs_fchdir = false;
+ if (proc_file != buf)
+ free (proc_file);
+ }
+ close (fd);
+ }
+
+ return needs_fchdir;
+}
+
+#endif /* !HAVE_OPENAT */
diff --git a/grub-core/lib/gnulib/openat.h b/grub-core/lib/gnulib/openat.h
new file mode 100644
index 0000000..f23b371
--- /dev/null
+++ b/grub-core/lib/gnulib/openat.h
@@ -0,0 +1,123 @@
+/* provide a replacement openat function
+ Copyright (C) 2004-2006, 2008-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering */
+
+#ifndef _GL_HEADER_OPENAT
+#define _GL_HEADER_OPENAT
+
+#include <fcntl.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdbool.h>
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+
+#if !HAVE_OPENAT
+
+int openat_permissive (int fd, char const *file, int flags, mode_t mode,
+ int *cwd_errno);
+bool openat_needs_fchdir (void);
+
+#else
+
+# define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \
+ openat (Fd, File, Flags, Mode)
+# define openat_needs_fchdir() false
+
+#endif
+
+_Noreturn void openat_restore_fail (int);
+_Noreturn void openat_save_fail (int);
+
+/* Using these function names makes application code
+ slightly more readable than it would be with
+ fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW). */
+
+#if GNULIB_FCHOWNAT
+
+# ifndef FCHOWNAT_INLINE
+# define FCHOWNAT_INLINE _GL_INLINE
+# endif
+
+FCHOWNAT_INLINE int
+chownat (int fd, char const *file, uid_t owner, gid_t group)
+{
+ return fchownat (fd, file, owner, group, 0);
+}
+
+FCHOWNAT_INLINE int
+lchownat (int fd, char const *file, uid_t owner, gid_t group)
+{
+ return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
+}
+
+#endif
+
+#if GNULIB_FCHMODAT
+
+# ifndef FCHMODAT_INLINE
+# define FCHMODAT_INLINE _GL_INLINE
+# endif
+
+FCHMODAT_INLINE int
+chmodat (int fd, char const *file, mode_t mode)
+{
+ return fchmodat (fd, file, mode, 0);
+}
+
+FCHMODAT_INLINE int
+lchmodat (int fd, char const *file, mode_t mode)
+{
+ return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
+}
+
+#endif
+
+#if GNULIB_STATAT
+
+# ifndef STATAT_INLINE
+# define STATAT_INLINE _GL_INLINE
+# endif
+
+STATAT_INLINE int
+statat (int fd, char const *name, struct stat *st)
+{
+ return fstatat (fd, name, st, 0);
+}
+
+STATAT_INLINE int
+lstatat (int fd, char const *name, struct stat *st)
+{
+ return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
+}
+
+#endif
+
+/* For now, there are no wrappers named laccessat or leuidaccessat,
+ since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
+ since access rights on symlinks are of limited utility. Likewise,
+ wrappers are not provided for accessat or euidaccessat, so as to
+ avoid dragging in -lgen on some platforms. */
+
+_GL_INLINE_HEADER_END
+
+#endif /* _GL_HEADER_OPENAT */
diff --git a/grub-core/lib/gnulib/pathmax.h b/grub-core/lib/gnulib/pathmax.h
new file mode 100644
index 0000000..83b9491
--- /dev/null
+++ b/grub-core/lib/gnulib/pathmax.h
@@ -0,0 +1,83 @@
+/* Define PATH_MAX somehow. Requires sys/types.h.
+ Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _PATHMAX_H
+# define _PATHMAX_H
+
+/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
+ including the terminating NUL byte.
+ <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
+ PATH_MAX is not defined on systems which have no limit on filename length,
+ such as GNU/Hurd.
+
+ This file does *not* define PATH_MAX always. Programs that use this file
+ can handle the GNU/Hurd case in several ways:
+ - Either with a package-wide handling, or with a per-file handling,
+ - Either through a
+ #ifdef PATH_MAX
+ or through a fallback like
+ #ifndef PATH_MAX
+ # define PATH_MAX 8192
+ #endif
+ or through a fallback like
+ #ifndef PATH_MAX
+ # define PATH_MAX pathconf ("/", _PC_PATH_MAX)
+ #endif
+ */
+
+# include <unistd.h>
+
+# include <limits.h>
+
+# ifndef _POSIX_PATH_MAX
+# define _POSIX_PATH_MAX 256
+# endif
+
+/* Don't include sys/param.h if it already has been. */
+# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
+# include <sys/param.h>
+# endif
+
+# if !defined PATH_MAX && defined MAXPATHLEN
+# define PATH_MAX MAXPATHLEN
+# endif
+
+# ifdef __hpux
+/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename,
+ *not* including the terminating NUL byte, and is set to 1023.
+ Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is
+ not defined at all any more. */
+# undef PATH_MAX
+# define PATH_MAX 1024
+# endif
+
+# if defined _WIN32 && ! defined __CYGWIN__
+/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
+ section "Maximum Path Length Limitation",
+ <https://msdn.microsoft.com/en-us/library/aa365247.aspx#maxpath>
+ explains that the maximum size of a filename, including the terminating
+ NUL byte, is 260 = 3 + 256 + 1.
+ This is the same value as
+ - FILENAME_MAX in <stdio.h>,
+ - _MAX_PATH in <stdlib.h>,
+ - MAX_PATH in <windef.h>.
+ Undefine the original value, because mingw's <limits.h> gets it wrong. */
+# undef PATH_MAX
+# define PATH_MAX 260
+# endif
+
+#endif /* _PATHMAX_H */
diff --git a/grub-core/lib/gnulib/pipe-safer.c b/grub-core/lib/gnulib/pipe-safer.c
new file mode 100644
index 0000000..6201739
--- /dev/null
+++ b/grub-core/lib/gnulib/pipe-safer.c
@@ -0,0 +1,56 @@
+/* Invoke pipe, but avoid some glitches.
+ Copyright (C) 2005-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering. */
+
+#include <config.h>
+
+#include "unistd-safer.h"
+
+#include <unistd.h>
+#include <errno.h>
+
+/* Like pipe, but ensure that neither of the file descriptors is
+ STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO. Fail with ENOSYS on
+ platforms that lack pipe. */
+
+int
+pipe_safer (int fd[2])
+{
+#if HAVE_PIPE
+ if (pipe (fd) == 0)
+ {
+ int i;
+ for (i = 0; i < 2; i++)
+ {
+ fd[i] = fd_safer (fd[i]);
+ if (fd[i] < 0)
+ {
+ int e = errno;
+ close (fd[1 - i]);
+ errno = e;
+ return -1;
+ }
+ }
+
+ return 0;
+ }
+#else
+ errno = ENOSYS;
+#endif
+
+ return -1;
+}
diff --git a/grub-core/lib/gnulib/printf-args.c b/grub-core/lib/gnulib/printf-args.c
new file mode 100644
index 0000000..e45cfbe
--- /dev/null
+++ b/grub-core/lib/gnulib/printf-args.c
@@ -0,0 +1,187 @@
+/* Decomposed printf argument list.
+ Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* This file can be parametrized with the following macros:
+ ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
+ PRINTF_FETCHARGS Name of the function to be defined.
+ STATIC Set to 'static' to declare the function static. */
+
+#ifndef PRINTF_FETCHARGS
+# include <config.h>
+#endif
+
+/* Specification. */
+#ifndef PRINTF_FETCHARGS
+# include "printf-args.h"
+#endif
+
+#ifdef STATIC
+STATIC
+#endif
+int
+PRINTF_FETCHARGS (va_list args, arguments *a)
+{
+ size_t i;
+ argument *ap;
+
+ for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
+ switch (ap->type)
+ {
+ case TYPE_SCHAR:
+ ap->a.a_schar = va_arg (args, /*signed char*/ int);
+ break;
+ case TYPE_UCHAR:
+ ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
+ break;
+ case TYPE_SHORT:
+ ap->a.a_short = va_arg (args, /*short*/ int);
+ break;
+ case TYPE_USHORT:
+ ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
+ break;
+ case TYPE_INT:
+ ap->a.a_int = va_arg (args, int);
+ break;
+ case TYPE_UINT:
+ ap->a.a_uint = va_arg (args, unsigned int);
+ break;
+ case TYPE_LONGINT:
+ ap->a.a_longint = va_arg (args, long int);
+ break;
+ case TYPE_ULONGINT:
+ ap->a.a_ulongint = va_arg (args, unsigned long int);
+ break;
+#if HAVE_LONG_LONG_INT
+ case TYPE_LONGLONGINT:
+ ap->a.a_longlongint = va_arg (args, long long int);
+ break;
+ case TYPE_ULONGLONGINT:
+ ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
+ break;
+#endif
+ case TYPE_DOUBLE:
+ ap->a.a_double = va_arg (args, double);
+ break;
+ case TYPE_LONGDOUBLE:
+ ap->a.a_longdouble = va_arg (args, long double);
+ break;
+ case TYPE_CHAR:
+ ap->a.a_char = va_arg (args, int);
+ break;
+#if HAVE_WINT_T
+ case TYPE_WIDE_CHAR:
+ /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
+ default argument promotions", this is not the case in mingw32,
+ where wint_t is 'unsigned short'. */
+ ap->a.a_wide_char =
+ (sizeof (wint_t) < sizeof (int)
+ ? (wint_t) va_arg (args, int)
+ : va_arg (args, wint_t));
+ break;
+#endif
+ case TYPE_STRING:
+ ap->a.a_string = va_arg (args, const char *);
+ /* A null pointer is an invalid argument for "%s", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_string == NULL)
+ ap->a.a_string = "(NULL)";
+ break;
+#if HAVE_WCHAR_T
+ case TYPE_WIDE_STRING:
+ ap->a.a_wide_string = va_arg (args, const wchar_t *);
+ /* A null pointer is an invalid argument for "%ls", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_wide_string == NULL)
+ {
+ static const wchar_t wide_null_string[] =
+ {
+ (wchar_t)'(',
+ (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
+ (wchar_t)')',
+ (wchar_t)0
+ };
+ ap->a.a_wide_string = wide_null_string;
+ }
+ break;
+#endif
+ case TYPE_POINTER:
+ ap->a.a_pointer = va_arg (args, void *);
+ break;
+ case TYPE_COUNT_SCHAR_POINTER:
+ ap->a.a_count_schar_pointer = va_arg (args, signed char *);
+ break;
+ case TYPE_COUNT_SHORT_POINTER:
+ ap->a.a_count_short_pointer = va_arg (args, short *);
+ break;
+ case TYPE_COUNT_INT_POINTER:
+ ap->a.a_count_int_pointer = va_arg (args, int *);
+ break;
+ case TYPE_COUNT_LONGINT_POINTER:
+ ap->a.a_count_longint_pointer = va_arg (args, long int *);
+ break;
+#if HAVE_LONG_LONG_INT
+ case TYPE_COUNT_LONGLONGINT_POINTER:
+ ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
+ break;
+#endif
+#if ENABLE_UNISTDIO
+ /* The unistdio extensions. */
+ case TYPE_U8_STRING:
+ ap->a.a_u8_string = va_arg (args, const uint8_t *);
+ /* A null pointer is an invalid argument for "%U", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_u8_string == NULL)
+ {
+ static const uint8_t u8_null_string[] =
+ { '(', 'N', 'U', 'L', 'L', ')', 0 };
+ ap->a.a_u8_string = u8_null_string;
+ }
+ break;
+ case TYPE_U16_STRING:
+ ap->a.a_u16_string = va_arg (args, const uint16_t *);
+ /* A null pointer is an invalid argument for "%lU", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_u16_string == NULL)
+ {
+ static const uint16_t u16_null_string[] =
+ { '(', 'N', 'U', 'L', 'L', ')', 0 };
+ ap->a.a_u16_string = u16_null_string;
+ }
+ break;
+ case TYPE_U32_STRING:
+ ap->a.a_u32_string = va_arg (args, const uint32_t *);
+ /* A null pointer is an invalid argument for "%llU", but in practice
+ it occurs quite frequently in printf statements that produce
+ debug output. Use a fallback in this case. */
+ if (ap->a.a_u32_string == NULL)
+ {
+ static const uint32_t u32_null_string[] =
+ { '(', 'N', 'U', 'L', 'L', ')', 0 };
+ ap->a.a_u32_string = u32_null_string;
+ }
+ break;
+#endif
+ default:
+ /* Unknown type. */
+ return -1;
+ }
+ return 0;
+}
diff --git a/grub-core/lib/gnulib/printf-args.h b/grub-core/lib/gnulib/printf-args.h
new file mode 100644
index 0000000..866cba0
--- /dev/null
+++ b/grub-core/lib/gnulib/printf-args.h
@@ -0,0 +1,158 @@
+/* Decomposed printf argument list.
+ Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _PRINTF_ARGS_H
+#define _PRINTF_ARGS_H
+
+/* This file can be parametrized with the following macros:
+ ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
+ PRINTF_FETCHARGS Name of the function to be declared.
+ STATIC Set to 'static' to declare the function static. */
+
+/* Default parameters. */
+#ifndef PRINTF_FETCHARGS
+# define PRINTF_FETCHARGS printf_fetchargs
+#endif
+
+/* Get size_t. */
+#include <stddef.h>
+
+/* Get wchar_t. */
+#if HAVE_WCHAR_T
+# include <stddef.h>
+#endif
+
+/* Get wint_t. */
+#if HAVE_WINT_T
+# include <wchar.h>
+#endif
+
+/* Get va_list. */
+#include <stdarg.h>
+
+
+/* Argument types */
+typedef enum
+{
+ TYPE_NONE,
+ TYPE_SCHAR,
+ TYPE_UCHAR,
+ TYPE_SHORT,
+ TYPE_USHORT,
+ TYPE_INT,
+ TYPE_UINT,
+ TYPE_LONGINT,
+ TYPE_ULONGINT,
+#if HAVE_LONG_LONG_INT
+ TYPE_LONGLONGINT,
+ TYPE_ULONGLONGINT,
+#endif
+ TYPE_DOUBLE,
+ TYPE_LONGDOUBLE,
+ TYPE_CHAR,
+#if HAVE_WINT_T
+ TYPE_WIDE_CHAR,
+#endif
+ TYPE_STRING,
+#if HAVE_WCHAR_T
+ TYPE_WIDE_STRING,
+#endif
+ TYPE_POINTER,
+ TYPE_COUNT_SCHAR_POINTER,
+ TYPE_COUNT_SHORT_POINTER,
+ TYPE_COUNT_INT_POINTER,
+ TYPE_COUNT_LONGINT_POINTER
+#if HAVE_LONG_LONG_INT
+, TYPE_COUNT_LONGLONGINT_POINTER
+#endif
+#if ENABLE_UNISTDIO
+ /* The unistdio extensions. */
+, TYPE_U8_STRING
+, TYPE_U16_STRING
+, TYPE_U32_STRING
+#endif
+} arg_type;
+
+/* Polymorphic argument */
+typedef struct
+{
+ arg_type type;
+ union
+ {
+ signed char a_schar;
+ unsigned char a_uchar;
+ short a_short;
+ unsigned short a_ushort;
+ int a_int;
+ unsigned int a_uint;
+ long int a_longint;
+ unsigned long int a_ulongint;
+#if HAVE_LONG_LONG_INT
+ long long int a_longlongint;
+ unsigned long long int a_ulonglongint;
+#endif
+ float a_float;
+ double a_double;
+ long double a_longdouble;
+ int a_char;
+#if HAVE_WINT_T
+ wint_t a_wide_char;
+#endif
+ const char* a_string;
+#if HAVE_WCHAR_T
+ const wchar_t* a_wide_string;
+#endif
+ void* a_pointer;
+ signed char * a_count_schar_pointer;
+ short * a_count_short_pointer;
+ int * a_count_int_pointer;
+ long int * a_count_longint_pointer;
+#if HAVE_LONG_LONG_INT
+ long long int * a_count_longlongint_pointer;
+#endif
+#if ENABLE_UNISTDIO
+ /* The unistdio extensions. */
+ const uint8_t * a_u8_string;
+ const uint16_t * a_u16_string;
+ const uint32_t * a_u32_string;
+#endif
+ }
+ a;
+}
+argument;
+
+/* Number of directly allocated arguments (no malloc() needed). */
+#define N_DIRECT_ALLOC_ARGUMENTS 7
+
+typedef struct
+{
+ size_t count;
+ argument *arg;
+ argument direct_alloc_arg[N_DIRECT_ALLOC_ARGUMENTS];
+}
+arguments;
+
+
+/* Fetch the arguments, putting them into a. */
+#ifdef STATIC
+STATIC
+#else
+extern
+#endif
+int PRINTF_FETCHARGS (va_list args, arguments *a);
+
+#endif /* _PRINTF_ARGS_H */
diff --git a/grub-core/lib/gnulib/printf-parse.c b/grub-core/lib/gnulib/printf-parse.c
new file mode 100644
index 0000000..8596fd5
--- /dev/null
+++ b/grub-core/lib/gnulib/printf-parse.c
@@ -0,0 +1,638 @@
+/* Formatted output to strings.
+ Copyright (C) 1999-2000, 2002-2003, 2006-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* This file can be parametrized with the following macros:
+ CHAR_T The element type of the format string.
+ CHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters
+ in the format string are ASCII.
+ DIRECTIVE Structure denoting a format directive.
+ Depends on CHAR_T.
+ DIRECTIVES Structure denoting the set of format directives of a
+ format string. Depends on CHAR_T.
+ PRINTF_PARSE Function that parses a format string.
+ Depends on CHAR_T.
+ STATIC Set to 'static' to declare the function static.
+ ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. */
+
+#ifndef PRINTF_PARSE
+# include <config.h>
+#endif
+
+/* Specification. */
+#ifndef PRINTF_PARSE
+# include "printf-parse.h"
+#endif
+
+/* Default parameters. */
+#ifndef PRINTF_PARSE
+# define PRINTF_PARSE printf_parse
+# define CHAR_T char
+# define DIRECTIVE char_directive
+# define DIRECTIVES char_directives
+#endif
+
+/* Get size_t, NULL. */
+#include <stddef.h>
+
+/* Get intmax_t. */
+#if defined IN_LIBINTL || defined IN_LIBASPRINTF
+# if HAVE_STDINT_H_WITH_UINTMAX
+# include <stdint.h>
+# endif
+# if HAVE_INTTYPES_H_WITH_UINTMAX
+# include <inttypes.h>
+# endif
+#else
+# include <stdint.h>
+#endif
+
+/* malloc(), realloc(), free(). */
+#include <stdlib.h>
+
+/* memcpy(). */
+#include <string.h>
+
+/* errno. */
+#include <errno.h>
+
+/* Checked size_t computations. */
+#include "xsize.h"
+
+#if CHAR_T_ONLY_ASCII
+/* c_isascii(). */
+# include "c-ctype.h"
+#endif
+
+#ifdef STATIC
+STATIC
+#endif
+int
+PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
+{
+ const CHAR_T *cp = format; /* pointer into format */
+ size_t arg_posn = 0; /* number of regular arguments consumed */
+ size_t d_allocated; /* allocated elements of d->dir */
+ size_t a_allocated; /* allocated elements of a->arg */
+ size_t max_width_length = 0;
+ size_t max_precision_length = 0;
+
+ d->count = 0;
+ d_allocated = N_DIRECT_ALLOC_DIRECTIVES;
+ d->dir = d->direct_alloc_dir;
+
+ a->count = 0;
+ a_allocated = N_DIRECT_ALLOC_ARGUMENTS;
+ a->arg = a->direct_alloc_arg;
+
+#define REGISTER_ARG(_index_,_type_) \
+ { \
+ size_t n = (_index_); \
+ if (n >= a_allocated) \
+ { \
+ size_t memory_size; \
+ argument *memory; \
+ \
+ a_allocated = xtimes (a_allocated, 2); \
+ if (a_allocated <= n) \
+ a_allocated = xsum (n, 1); \
+ memory_size = xtimes (a_allocated, sizeof (argument)); \
+ if (size_overflow_p (memory_size)) \
+ /* Overflow, would lead to out of memory. */ \
+ goto out_of_memory; \
+ memory = (argument *) (a->arg != a->direct_alloc_arg \
+ ? realloc (a->arg, memory_size) \
+ : malloc (memory_size)); \
+ if (memory == NULL) \
+ /* Out of memory. */ \
+ goto out_of_memory; \
+ if (a->arg == a->direct_alloc_arg) \
+ memcpy (memory, a->arg, a->count * sizeof (argument)); \
+ a->arg = memory; \
+ } \
+ while (a->count <= n) \
+ a->arg[a->count++].type = TYPE_NONE; \
+ if (a->arg[n].type == TYPE_NONE) \
+ a->arg[n].type = (_type_); \
+ else if (a->arg[n].type != (_type_)) \
+ /* Ambiguous type for positional argument. */ \
+ goto error; \
+ }
+
+ while (*cp != '\0')
+ {
+ CHAR_T c = *cp++;
+ if (c == '%')
+ {
+ size_t arg_index = ARG_NONE;
+ DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
+
+ /* Initialize the next directive. */
+ dp->dir_start = cp - 1;
+ dp->flags = 0;
+ dp->width_start = NULL;
+ dp->width_end = NULL;
+ dp->width_arg_index = ARG_NONE;
+ dp->precision_start = NULL;
+ dp->precision_end = NULL;
+ dp->precision_arg_index = ARG_NONE;
+ dp->arg_index = ARG_NONE;
+
+ /* Test for positional argument. */
+ if (*cp >= '0' && *cp <= '9')
+ {
+ const CHAR_T *np;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ ;
+ if (*np == '$')
+ {
+ size_t n = 0;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ n = xsum (xtimes (n, 10), *np - '0');
+ if (n == 0)
+ /* Positional argument 0. */
+ goto error;
+ if (size_overflow_p (n))
+ /* n too large, would lead to out of memory later. */
+ goto error;
+ arg_index = n - 1;
+ cp = np + 1;
+ }
+ }
+
+ /* Read the flags. */
+ for (;;)
+ {
+ if (*cp == '\'')
+ {
+ dp->flags |= FLAG_GROUP;
+ cp++;
+ }
+ else if (*cp == '-')
+ {
+ dp->flags |= FLAG_LEFT;
+ cp++;
+ }
+ else if (*cp == '+')
+ {
+ dp->flags |= FLAG_SHOWSIGN;
+ cp++;
+ }
+ else if (*cp == ' ')
+ {
+ dp->flags |= FLAG_SPACE;
+ cp++;
+ }
+ else if (*cp == '#')
+ {
+ dp->flags |= FLAG_ALT;
+ cp++;
+ }
+ else if (*cp == '0')
+ {
+ dp->flags |= FLAG_ZERO;
+ cp++;
+ }
+#if __GLIBC__ >= 2 && !defined __UCLIBC__
+ else if (*cp == 'I')
+ {
+ dp->flags |= FLAG_LOCALIZED;
+ cp++;
+ }
+#endif
+ else
+ break;
+ }
+
+ /* Parse the field width. */
+ if (*cp == '*')
+ {
+ dp->width_start = cp;
+ cp++;
+ dp->width_end = cp;
+ if (max_width_length < 1)
+ max_width_length = 1;
+
+ /* Test for positional argument. */
+ if (*cp >= '0' && *cp <= '9')
+ {
+ const CHAR_T *np;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ ;
+ if (*np == '$')
+ {
+ size_t n = 0;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ n = xsum (xtimes (n, 10), *np - '0');
+ if (n == 0)
+ /* Positional argument 0. */
+ goto error;
+ if (size_overflow_p (n))
+ /* n too large, would lead to out of memory later. */
+ goto error;
+ dp->width_arg_index = n - 1;
+ cp = np + 1;
+ }
+ }
+ if (dp->width_arg_index == ARG_NONE)
+ {
+ dp->width_arg_index = arg_posn++;
+ if (dp->width_arg_index == ARG_NONE)
+ /* arg_posn wrapped around. */
+ goto error;
+ }
+ REGISTER_ARG (dp->width_arg_index, TYPE_INT);
+ }
+ else if (*cp >= '0' && *cp <= '9')
+ {
+ size_t width_length;
+
+ dp->width_start = cp;
+ for (; *cp >= '0' && *cp <= '9'; cp++)
+ ;
+ dp->width_end = cp;
+ width_length = dp->width_end - dp->width_start;
+ if (max_width_length < width_length)
+ max_width_length = width_length;
+ }
+
+ /* Parse the precision. */
+ if (*cp == '.')
+ {
+ cp++;
+ if (*cp == '*')
+ {
+ dp->precision_start = cp - 1;
+ cp++;
+ dp->precision_end = cp;
+ if (max_precision_length < 2)
+ max_precision_length = 2;
+
+ /* Test for positional argument. */
+ if (*cp >= '0' && *cp <= '9')
+ {
+ const CHAR_T *np;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ ;
+ if (*np == '$')
+ {
+ size_t n = 0;
+
+ for (np = cp; *np >= '0' && *np <= '9'; np++)
+ n = xsum (xtimes (n, 10), *np - '0');
+ if (n == 0)
+ /* Positional argument 0. */
+ goto error;
+ if (size_overflow_p (n))
+ /* n too large, would lead to out of memory
+ later. */
+ goto error;
+ dp->precision_arg_index = n - 1;
+ cp = np + 1;
+ }
+ }
+ if (dp->precision_arg_index == ARG_NONE)
+ {
+ dp->precision_arg_index = arg_posn++;
+ if (dp->precision_arg_index == ARG_NONE)
+ /* arg_posn wrapped around. */
+ goto error;
+ }
+ REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
+ }
+ else
+ {
+ size_t precision_length;
+
+ dp->precision_start = cp - 1;
+ for (; *cp >= '0' && *cp <= '9'; cp++)
+ ;
+ dp->precision_end = cp;
+ precision_length = dp->precision_end - dp->precision_start;
+ if (max_precision_length < precision_length)
+ max_precision_length = precision_length;
+ }
+ }
+
+ {
+ arg_type type;
+
+ /* Parse argument type/size specifiers. */
+ {
+ int flags = 0;
+
+ for (;;)
+ {
+ if (*cp == 'h')
+ {
+ flags |= (1 << (flags & 1));
+ cp++;
+ }
+ else if (*cp == 'L')
+ {
+ flags |= 4;
+ cp++;
+ }
+ else if (*cp == 'l')
+ {
+ flags += 8;
+ cp++;
+ }
+ else if (*cp == 'j')
+ {
+ if (sizeof (intmax_t) > sizeof (long))
+ {
+ /* intmax_t = long long */
+ flags += 16;
+ }
+ else if (sizeof (intmax_t) > sizeof (int))
+ {
+ /* intmax_t = long */
+ flags += 8;
+ }
+ cp++;
+ }
+ else if (*cp == 'z' || *cp == 'Z')
+ {
+ /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
+ because the warning facility in gcc-2.95.2 understands
+ only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
+ if (sizeof (size_t) > sizeof (long))
+ {
+ /* size_t = long long */
+ flags += 16;
+ }
+ else if (sizeof (size_t) > sizeof (int))
+ {
+ /* size_t = long */
+ flags += 8;
+ }
+ cp++;
+ }
+ else if (*cp == 't')
+ {
+ if (sizeof (ptrdiff_t) > sizeof (long))
+ {
+ /* ptrdiff_t = long long */
+ flags += 16;
+ }
+ else if (sizeof (ptrdiff_t) > sizeof (int))
+ {
+ /* ptrdiff_t = long */
+ flags += 8;
+ }
+ cp++;
+ }
+#if defined __APPLE__ && defined __MACH__
+ /* On Mac OS X 10.3, PRIdMAX is defined as "qd".
+ We cannot change it to "lld" because PRIdMAX must also
+ be understood by the system's printf routines. */
+ else if (*cp == 'q')
+ {
+ if (64 / 8 > sizeof (long))
+ {
+ /* int64_t = long long */
+ flags += 16;
+ }
+ else
+ {
+ /* int64_t = long */
+ flags += 8;
+ }
+ cp++;
+ }
+#endif
+#if defined _WIN32 && ! defined __CYGWIN__
+ /* On native Windows, PRIdMAX is defined as "I64d".
+ We cannot change it to "lld" because PRIdMAX must also
+ be understood by the system's printf routines. */
+ else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
+ {
+ if (64 / 8 > sizeof (long))
+ {
+ /* __int64 = long long */
+ flags += 16;
+ }
+ else
+ {
+ /* __int64 = long */
+ flags += 8;
+ }
+ cp += 3;
+ }
+#endif
+ else
+ break;
+ }
+
+ /* Read the conversion character. */
+ c = *cp++;
+ switch (c)
+ {
+ case 'd': case 'i':
+#if HAVE_LONG_LONG_INT
+ /* If 'long long' exists and is larger than 'long': */
+ if (flags >= 16 || (flags & 4))
+ type = TYPE_LONGLONGINT;
+ else
+#endif
+ /* If 'long long' exists and is the same as 'long', we parse
+ "lld" into TYPE_LONGINT. */
+ if (flags >= 8)
+ type = TYPE_LONGINT;
+ else if (flags & 2)
+ type = TYPE_SCHAR;
+ else if (flags & 1)
+ type = TYPE_SHORT;
+ else
+ type = TYPE_INT;
+ break;
+ case 'o': case 'u': case 'x': case 'X':
+#if HAVE_LONG_LONG_INT
+ /* If 'long long' exists and is larger than 'long': */
+ if (flags >= 16 || (flags & 4))
+ type = TYPE_ULONGLONGINT;
+ else
+#endif
+ /* If 'unsigned long long' exists and is the same as
+ 'unsigned long', we parse "llu" into TYPE_ULONGINT. */
+ if (flags >= 8)
+ type = TYPE_ULONGINT;
+ else if (flags & 2)
+ type = TYPE_UCHAR;
+ else if (flags & 1)
+ type = TYPE_USHORT;
+ else
+ type = TYPE_UINT;
+ break;
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
+ case 'a': case 'A':
+ if (flags >= 16 || (flags & 4))
+ type = TYPE_LONGDOUBLE;
+ else
+ type = TYPE_DOUBLE;
+ break;
+ case 'c':
+ if (flags >= 8)
+#if HAVE_WINT_T
+ type = TYPE_WIDE_CHAR;
+#else
+ goto error;
+#endif
+ else
+ type = TYPE_CHAR;
+ break;
+#if HAVE_WINT_T
+ case 'C':
+ type = TYPE_WIDE_CHAR;
+ c = 'c';
+ break;
+#endif
+ case 's':
+ if (flags >= 8)
+#if HAVE_WCHAR_T
+ type = TYPE_WIDE_STRING;
+#else
+ goto error;
+#endif
+ else
+ type = TYPE_STRING;
+ break;
+#if HAVE_WCHAR_T
+ case 'S':
+ type = TYPE_WIDE_STRING;
+ c = 's';
+ break;
+#endif
+ case 'p':
+ type = TYPE_POINTER;
+ break;
+ case 'n':
+#if HAVE_LONG_LONG_INT
+ /* If 'long long' exists and is larger than 'long': */
+ if (flags >= 16 || (flags & 4))
+ type = TYPE_COUNT_LONGLONGINT_POINTER;
+ else
+#endif
+ /* If 'long long' exists and is the same as 'long', we parse
+ "lln" into TYPE_COUNT_LONGINT_POINTER. */
+ if (flags >= 8)
+ type = TYPE_COUNT_LONGINT_POINTER;
+ else if (flags & 2)
+ type = TYPE_COUNT_SCHAR_POINTER;
+ else if (flags & 1)
+ type = TYPE_COUNT_SHORT_POINTER;
+ else
+ type = TYPE_COUNT_INT_POINTER;
+ break;
+#if ENABLE_UNISTDIO
+ /* The unistdio extensions. */
+ case 'U':
+ if (flags >= 16)
+ type = TYPE_U32_STRING;
+ else if (flags >= 8)
+ type = TYPE_U16_STRING;
+ else
+ type = TYPE_U8_STRING;
+ break;
+#endif
+ case '%':
+ type = TYPE_NONE;
+ break;
+ default:
+ /* Unknown conversion character. */
+ goto error;
+ }
+ }
+
+ if (type != TYPE_NONE)
+ {
+ dp->arg_index = arg_index;
+ if (dp->arg_index == ARG_NONE)
+ {
+ dp->arg_index = arg_posn++;
+ if (dp->arg_index == ARG_NONE)
+ /* arg_posn wrapped around. */
+ goto error;
+ }
+ REGISTER_ARG (dp->arg_index, type);
+ }
+ dp->conversion = c;
+ dp->dir_end = cp;
+ }
+
+ d->count++;
+ if (d->count >= d_allocated)
+ {
+ size_t memory_size;
+ DIRECTIVE *memory;
+
+ d_allocated = xtimes (d_allocated, 2);
+ memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
+ if (size_overflow_p (memory_size))
+ /* Overflow, would lead to out of memory. */
+ goto out_of_memory;
+ memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir
+ ? realloc (d->dir, memory_size)
+ : malloc (memory_size));
+ if (memory == NULL)
+ /* Out of memory. */
+ goto out_of_memory;
+ if (d->dir == d->direct_alloc_dir)
+ memcpy (memory, d->dir, d->count * sizeof (DIRECTIVE));
+ d->dir = memory;
+ }
+ }
+#if CHAR_T_ONLY_ASCII
+ else if (!c_isascii (c))
+ {
+ /* Non-ASCII character. Not supported. */
+ goto error;
+ }
+#endif
+ }
+ d->dir[d->count].dir_start = cp;
+
+ d->max_width_length = max_width_length;
+ d->max_precision_length = max_precision_length;
+ return 0;
+
+error:
+ if (a->arg != a->direct_alloc_arg)
+ free (a->arg);
+ if (d->dir != d->direct_alloc_dir)
+ free (d->dir);
+ errno = EINVAL;
+ return -1;
+
+out_of_memory:
+ if (a->arg != a->direct_alloc_arg)
+ free (a->arg);
+ if (d->dir != d->direct_alloc_dir)
+ free (d->dir);
+ errno = ENOMEM;
+ return -1;
+}
+
+#undef PRINTF_PARSE
+#undef DIRECTIVES
+#undef DIRECTIVE
+#undef CHAR_T_ONLY_ASCII
+#undef CHAR_T
diff --git a/grub-core/lib/gnulib/printf-parse.h b/grub-core/lib/gnulib/printf-parse.h
new file mode 100644
index 0000000..746bb3f
--- /dev/null
+++ b/grub-core/lib/gnulib/printf-parse.h
@@ -0,0 +1,193 @@
+/* Parse printf format string.
+ Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _PRINTF_PARSE_H
+#define _PRINTF_PARSE_H
+
+/* This file can be parametrized with the following macros:
+ ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
+ STATIC Set to 'static' to declare the function static. */
+
+#if HAVE_FEATURES_H
+# include <features.h> /* for __GLIBC__, __UCLIBC__ */
+#endif
+
+#include "printf-args.h"
+
+
+/* Flags */
+#define FLAG_GROUP 1 /* ' flag */
+#define FLAG_LEFT 2 /* - flag */
+#define FLAG_SHOWSIGN 4 /* + flag */
+#define FLAG_SPACE 8 /* space flag */
+#define FLAG_ALT 16 /* # flag */
+#define FLAG_ZERO 32
+#if __GLIBC__ >= 2 && !defined __UCLIBC__
+# define FLAG_LOCALIZED 64 /* I flag, uses localized digits */
+#endif
+
+/* arg_index value indicating that no argument is consumed. */
+#define ARG_NONE (~(size_t)0)
+
+/* xxx_directive: A parsed directive.
+ xxx_directives: A parsed format string. */
+
+/* Number of directly allocated directives (no malloc() needed). */
+#define N_DIRECT_ALLOC_DIRECTIVES 7
+
+/* A parsed directive. */
+typedef struct
+{
+ const char* dir_start;
+ const char* dir_end;
+ int flags;
+ const char* width_start;
+ const char* width_end;
+ size_t width_arg_index;
+ const char* precision_start;
+ const char* precision_end;
+ size_t precision_arg_index;
+ char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
+ size_t arg_index;
+}
+char_directive;
+
+/* A parsed format string. */
+typedef struct
+{
+ size_t count;
+ char_directive *dir;
+ size_t max_width_length;
+ size_t max_precision_length;
+ char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
+}
+char_directives;
+
+#if ENABLE_UNISTDIO
+
+/* A parsed directive. */
+typedef struct
+{
+ const uint8_t* dir_start;
+ const uint8_t* dir_end;
+ int flags;
+ const uint8_t* width_start;
+ const uint8_t* width_end;
+ size_t width_arg_index;
+ const uint8_t* precision_start;
+ const uint8_t* precision_end;
+ size_t precision_arg_index;
+ uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
+ size_t arg_index;
+}
+u8_directive;
+
+/* A parsed format string. */
+typedef struct
+{
+ size_t count;
+ u8_directive *dir;
+ size_t max_width_length;
+ size_t max_precision_length;
+ u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
+}
+u8_directives;
+
+/* A parsed directive. */
+typedef struct
+{
+ const uint16_t* dir_start;
+ const uint16_t* dir_end;
+ int flags;
+ const uint16_t* width_start;
+ const uint16_t* width_end;
+ size_t width_arg_index;
+ const uint16_t* precision_start;
+ const uint16_t* precision_end;
+ size_t precision_arg_index;
+ uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
+ size_t arg_index;
+}
+u16_directive;
+
+/* A parsed format string. */
+typedef struct
+{
+ size_t count;
+ u16_directive *dir;
+ size_t max_width_length;
+ size_t max_precision_length;
+ u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
+}
+u16_directives;
+
+/* A parsed directive. */
+typedef struct
+{
+ const uint32_t* dir_start;
+ const uint32_t* dir_end;
+ int flags;
+ const uint32_t* width_start;
+ const uint32_t* width_end;
+ size_t width_arg_index;
+ const uint32_t* precision_start;
+ const uint32_t* precision_end;
+ size_t precision_arg_index;
+ uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
+ size_t arg_index;
+}
+u32_directive;
+
+/* A parsed format string. */
+typedef struct
+{
+ size_t count;
+ u32_directive *dir;
+ size_t max_width_length;
+ size_t max_precision_length;
+ u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
+}
+u32_directives;
+
+#endif
+
+
+/* Parses the format string. Fills in the number N of directives, and fills
+ in directives[0], ..., directives[N-1], and sets directives[N].dir_start
+ to the end of the format string. Also fills in the arg_type fields of the
+ arguments and the needed count of arguments. */
+#if ENABLE_UNISTDIO
+extern int
+ ulc_printf_parse (const char *format, char_directives *d, arguments *a);
+extern int
+ u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
+extern int
+ u16_printf_parse (const uint16_t *format, u16_directives *d,
+ arguments *a);
+extern int
+ u32_printf_parse (const uint32_t *format, u32_directives *d,
+ arguments *a);
+#else
+# ifdef STATIC
+STATIC
+# else
+extern
+# endif
+int printf_parse (const char *format, char_directives *d, arguments *a);
+#endif
+
+#endif /* _PRINTF_PARSE_H */
diff --git a/grub-core/lib/gnulib/progname.c b/grub-core/lib/gnulib/progname.c
new file mode 100644
index 0000000..a42b7fa
--- /dev/null
+++ b/grub-core/lib/gnulib/progname.c
@@ -0,0 +1,92 @@
+/* Program name management.
+ Copyright (C) 2001-2003, 2005-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2001.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+
+#include <config.h>
+
+/* Specification. */
+#undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */
+#include "progname.h"
+
+#include <errno.h> /* get program_invocation_name declaration */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* String containing name the program is called with.
+ To be initialized by main(). */
+const char *program_name = NULL;
+
+/* Set program_name, based on argv[0].
+ argv0 must be a string allocated with indefinite extent, and must not be
+ modified after this call. */
+void
+set_program_name (const char *argv0)
+{
+ /* libtool creates a temporary executable whose name is sometimes prefixed
+ with "lt-" (depends on the platform). It also makes argv[0] absolute.
+ But the name of the temporary executable is a detail that should not be
+ visible to the end user and to the test suite.
+ Remove this "<dirname>/.libs/" or "<dirname>/.libs/lt-" prefix here. */
+ const char *slash;
+ const char *base;
+
+ /* Sanity check. POSIX requires the invoking process to pass a non-NULL
+ argv[0]. */
+ if (argv0 == NULL)
+ {
+ /* It's a bug in the invoking program. Help diagnosing it. */
+ fputs ("A NULL argv[0] was passed through an exec system call.\n",
+ stderr);
+ abort ();
+ }
+
+ slash = strrchr (argv0, '/');
+ base = (slash != NULL ? slash + 1 : argv0);
+ if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
+ {
+ argv0 = base;
+ if (strncmp (base, "lt-", 3) == 0)
+ {
+ argv0 = base + 3;
+ /* On glibc systems, remove the "lt-" prefix from the variable
+ program_invocation_short_name. */
+#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+ program_invocation_short_name = (char *) argv0;
+#endif
+ }
+ }
+
+ /* But don't strip off a leading <dirname>/ in general, because when the user
+ runs
+ /some/hidden/place/bin/cp foo foo
+ he should get the error message
+ /some/hidden/place/bin/cp: `foo' and `foo' are the same file
+ not
+ cp: `foo' and `foo' are the same file
+ */
+
+ program_name = argv0;
+
+ /* On glibc systems, the error() function comes from libc and uses the
+ variable program_invocation_name, not program_name. So set this variable
+ as well. */
+#if HAVE_DECL_PROGRAM_INVOCATION_NAME
+ program_invocation_name = (char *) argv0;
+#endif
+}
diff --git a/grub-core/lib/gnulib/progname.h b/grub-core/lib/gnulib/progname.h
new file mode 100644
index 0000000..c726e97
--- /dev/null
+++ b/grub-core/lib/gnulib/progname.h
@@ -0,0 +1,62 @@
+/* Program name management.
+ Copyright (C) 2001-2004, 2006, 2009-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2001.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _PROGNAME_H
+#define _PROGNAME_H
+
+/* Programs using this file should do the following in main():
+ set_program_name (argv[0]);
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* String containing name the program is called with. */
+extern const char *program_name;
+
+/* Set program_name, based on argv[0].
+ argv0 must be a string allocated with indefinite extent, and must not be
+ modified after this call. */
+extern void set_program_name (const char *argv0);
+
+#if ENABLE_RELOCATABLE
+
+/* Set program_name, based on argv[0], and original installation prefix and
+ directory, for relocatability. */
+extern void set_program_name_and_installdir (const char *argv0,
+ const char *orig_installprefix,
+ const char *orig_installdir);
+#undef set_program_name
+#define set_program_name(ARG0) \
+ set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR)
+
+/* Return the full pathname of the current executable, based on the earlier
+ call to set_program_name_and_installdir. Return NULL if unknown. */
+extern char *get_full_program_name (void);
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _PROGNAME_H */
diff --git a/grub-core/lib/gnulib/rawmemchr.c b/grub-core/lib/gnulib/rawmemchr.c
new file mode 100644
index 0000000..7df6151
--- /dev/null
+++ b/grub-core/lib/gnulib/rawmemchr.c
@@ -0,0 +1,136 @@
+/* Searching in a string.
+ Copyright (C) 2008-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+/* Find the first occurrence of C in S. */
+void *
+rawmemchr (const void *s, int c_in)
+{
+ /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
+ long instead of a 64-bit uintmax_t tends to give better
+ performance. On 64-bit hardware, unsigned long is generally 64
+ bits already. Change this typedef to experiment with
+ performance. */
+ typedef unsigned long int longword;
+
+ const unsigned char *char_ptr;
+ const longword *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ unsigned char c;
+
+ c = (unsigned char) c_in;
+
+ /* Handle the first few bytes by reading one byte at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = (const unsigned char *) s;
+ (size_t) char_ptr % sizeof (longword) != 0;
+ ++char_ptr)
+ if (*char_ptr == c)
+ return (void *) char_ptr;
+
+ longword_ptr = (const longword *) char_ptr;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to any size longwords. */
+
+ /* Compute auxiliary longword values:
+ repeated_one is a value which has a 1 in every byte.
+ repeated_c has c in every byte. */
+ repeated_one = 0x01010101;
+ repeated_c = c | (c << 8);
+ repeated_c |= repeated_c << 16;
+ if (0xffffffffU < (longword) -1)
+ {
+ repeated_one |= repeated_one << 31 << 1;
+ repeated_c |= repeated_c << 31 << 1;
+ if (8 < sizeof (longword))
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
+ }
+
+ /* Instead of the traditional loop which tests each byte, we will
+ test a longword at a time. The tricky part is testing if *any of
+ the four* bytes in the longword in question are equal to NUL or
+ c. We first use an xor with repeated_c. This reduces the task
+ to testing whether *any of the four* bytes in longword1 is zero.
+
+ We compute tmp =
+ ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+ That is, we perform the following operations:
+ 1. Subtract repeated_one.
+ 2. & ~longword1.
+ 3. & a mask consisting of 0x80 in every byte.
+ Consider what happens in each byte:
+ - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
+ and step 3 transforms it into 0x80. A carry can also be propagated
+ to more significant bytes.
+ - If a byte of longword1 is nonzero, let its lowest 1 bit be at
+ position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
+ the byte ends in a single bit of value 0 and k bits of value 1.
+ After step 2, the result is just k bits of value 1: 2^k - 1. After
+ step 3, the result is 0. And no carry is produced.
+ So, if longword1 has only non-zero bytes, tmp is zero.
+ Whereas if longword1 has a zero byte, call j the position of the least
+ significant zero byte. Then the result has a zero at positions 0, ...,
+ j-1 and a 0x80 at position j. We cannot predict the result at the more
+ significant bytes (positions j+1..3), but it does not matter since we
+ already have a non-zero bit at position 8*j+7.
+
+ The test whether any byte in longword1 is zero is equivalent
+ to testing whether tmp is nonzero.
+
+ This test can read beyond the end of a string, depending on where
+ C_IN is encountered. However, this is considered safe since the
+ initialization phase ensured that the read will be aligned,
+ therefore, the read will not cross page boundaries and will not
+ cause a fault. */
+
+ while (1)
+ {
+ longword longword1 = *longword_ptr ^ repeated_c;
+
+ if ((((longword1 - repeated_one) & ~longword1)
+ & (repeated_one << 7)) != 0)
+ break;
+ longword_ptr++;
+ }
+
+ char_ptr = (const unsigned char *) longword_ptr;
+
+ /* At this point, we know that one of the sizeof (longword) bytes
+ starting at char_ptr is == c. On little-endian machines, we
+ could determine the first such byte without any further memory
+ accesses, just by looking at the tmp result from the last loop
+ iteration. But this does not work on big-endian machines.
+ Choose code that works in both cases. */
+
+ char_ptr = (unsigned char *) longword_ptr;
+ while (*char_ptr != c)
+ char_ptr++;
+ return (void *) char_ptr;
+}
diff --git a/grub-core/lib/gnulib/rawmemchr.valgrind b/grub-core/lib/gnulib/rawmemchr.valgrind
new file mode 100644
index 0000000..6363923
--- /dev/null
+++ b/grub-core/lib/gnulib/rawmemchr.valgrind
@@ -0,0 +1,12 @@
+# Suppress a valgrind message about use of uninitialized memory in rawmemchr().
+# This use is OK because it provides only a speedup.
+{
+ rawmemchr-value4
+ Memcheck:Value4
+ fun:rawmemchr
+}
+{
+ rawmemchr-value8
+ Memcheck:Value8
+ fun:rawmemchr
+}
diff --git a/grub-core/lib/gnulib/realloc.c b/grub-core/lib/gnulib/realloc.c
new file mode 100644
index 0000000..a81ce3b
--- /dev/null
+++ b/grub-core/lib/gnulib/realloc.c
@@ -0,0 +1,79 @@
+/* realloc() function that is glibc compatible.
+
+ Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering and Bruno Haible */
+
+#define _GL_USE_STDLIB_ALLOC 1
+#include <config.h>
+
+/* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */
+#ifdef realloc
+# define NEED_REALLOC_GNU 1
+/* Whereas the gnulib module 'realloc-gnu' defines HAVE_REALLOC_GNU. */
+#elif GNULIB_REALLOC_GNU && !HAVE_REALLOC_GNU
+# define NEED_REALLOC_GNU 1
+#endif
+
+/* Infer the properties of the system's malloc function.
+ The gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */
+#if GNULIB_MALLOC_GNU && HAVE_MALLOC_GNU
+# define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1
+#endif
+
+#include <stdlib.h>
+
+#include <errno.h>
+
+/* Change the size of an allocated block of memory P to N bytes,
+ with error checking. If N is zero, change it to 1. If P is NULL,
+ use malloc. */
+
+void *
+rpl_realloc (void *p, size_t n)
+{
+ void *result;
+
+#if NEED_REALLOC_GNU
+ if (n == 0)
+ {
+ n = 1;
+
+ /* In theory realloc might fail, so don't rely on it to free. */
+ free (p);
+ p = NULL;
+ }
+#endif
+
+ if (p == NULL)
+ {
+#if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE
+ if (n == 0)
+ n = 1;
+#endif
+ result = malloc (n);
+ }
+ else
+ result = realloc (p, n);
+
+#if !HAVE_REALLOC_POSIX
+ if (result == NULL)
+ errno = ENOMEM;
+#endif
+
+ return result;
+}
diff --git a/grub-core/lib/gnulib/regcomp.c b/grub-core/lib/gnulib/regcomp.c
new file mode 100644
index 0000000..64a4fa7
--- /dev/null
+++ b/grub-core/lib/gnulib/regcomp.c
@@ -0,0 +1,3930 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 2002-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifdef _LIBC
+# include <locale/weight.h>
+#endif
+
+static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
+ size_t length, reg_syntax_t syntax);
+static void re_compile_fastmap_iter (regex_t *bufp,
+ const re_dfastate_t *init_state,
+ char *fastmap);
+static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len);
+#ifdef RE_ENABLE_I18N
+static void free_charset (re_charset_t *cset);
+#endif /* RE_ENABLE_I18N */
+static void free_workarea_compile (regex_t *preg);
+static reg_errcode_t create_initial_state (re_dfa_t *dfa);
+#ifdef RE_ENABLE_I18N
+static void optimize_utf8 (re_dfa_t *dfa);
+#endif
+static reg_errcode_t analyze (regex_t *preg);
+static reg_errcode_t preorder (bin_tree_t *root,
+ reg_errcode_t (fn (void *, bin_tree_t *)),
+ void *extra);
+static reg_errcode_t postorder (bin_tree_t *root,
+ reg_errcode_t (fn (void *, bin_tree_t *)),
+ void *extra);
+static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node);
+static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node);
+static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg,
+ bin_tree_t *node);
+static reg_errcode_t calc_first (void *extra, bin_tree_t *node);
+static reg_errcode_t calc_next (void *extra, bin_tree_t *node);
+static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node);
+static Idx duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint);
+static Idx search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
+ unsigned int constraint);
+static reg_errcode_t calc_eclosure (re_dfa_t *dfa);
+static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa,
+ Idx node, bool root);
+static reg_errcode_t calc_inveclosure (re_dfa_t *dfa);
+static Idx fetch_number (re_string_t *input, re_token_t *token,
+ reg_syntax_t syntax);
+static int peek_token (re_token_t *token, re_string_t *input,
+ reg_syntax_t syntax);
+static bin_tree_t *parse (re_string_t *regexp, regex_t *preg,
+ reg_syntax_t syntax, reg_errcode_t *err);
+static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg,
+ re_token_t *token, reg_syntax_t syntax,
+ Idx nest, reg_errcode_t *err);
+static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg,
+ re_token_t *token, reg_syntax_t syntax,
+ Idx nest, reg_errcode_t *err);
+static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg,
+ re_token_t *token, reg_syntax_t syntax,
+ Idx nest, reg_errcode_t *err);
+static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg,
+ re_token_t *token, reg_syntax_t syntax,
+ Idx nest, reg_errcode_t *err);
+static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp,
+ re_dfa_t *dfa, re_token_t *token,
+ reg_syntax_t syntax, reg_errcode_t *err);
+static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa,
+ re_token_t *token, reg_syntax_t syntax,
+ reg_errcode_t *err);
+static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
+ re_string_t *regexp,
+ re_token_t *token, int token_len,
+ re_dfa_t *dfa,
+ reg_syntax_t syntax,
+ bool accept_hyphen);
+static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
+ re_string_t *regexp,
+ re_token_t *token);
+#ifdef RE_ENABLE_I18N
+static reg_errcode_t build_equiv_class (bitset_t sbcset,
+ re_charset_t *mbcset,
+ Idx *equiv_class_alloc,
+ const unsigned char *name);
+static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
+ bitset_t sbcset,
+ re_charset_t *mbcset,
+ Idx *char_class_alloc,
+ const char *class_name,
+ reg_syntax_t syntax);
+#else /* not RE_ENABLE_I18N */
+static reg_errcode_t build_equiv_class (bitset_t sbcset,
+ const unsigned char *name);
+static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
+ bitset_t sbcset,
+ const char *class_name,
+ reg_syntax_t syntax);
+#endif /* not RE_ENABLE_I18N */
+static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
+ RE_TRANSLATE_TYPE trans,
+ const char *class_name,
+ const char *extra,
+ bool non_match, reg_errcode_t *err);
+static bin_tree_t *create_tree (re_dfa_t *dfa,
+ bin_tree_t *left, bin_tree_t *right,
+ re_token_type_t type);
+static bin_tree_t *create_token_tree (re_dfa_t *dfa,
+ bin_tree_t *left, bin_tree_t *right,
+ const re_token_t *token);
+static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa);
+static void free_token (re_token_t *node);
+static reg_errcode_t free_tree (void *extra, bin_tree_t *node);
+static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node);
+
+/* This table gives an error message for each of the error codes listed
+ in regex.h. Obviously the order here has to be same as there.
+ POSIX doesn't require that we do anything for REG_NOERROR,
+ but why not be nice? */
+
+static const char __re_error_msgid[] =
+ {
+#define REG_NOERROR_IDX 0
+ gettext_noop ("Success") /* REG_NOERROR */
+ "\0"
+#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success")
+ gettext_noop ("No match") /* REG_NOMATCH */
+ "\0"
+#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match")
+ gettext_noop ("Invalid regular expression") /* REG_BADPAT */
+ "\0"
+#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression")
+ gettext_noop ("Invalid collation character") /* REG_ECOLLATE */
+ "\0"
+#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character")
+ gettext_noop ("Invalid character class name") /* REG_ECTYPE */
+ "\0"
+#define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name")
+ gettext_noop ("Trailing backslash") /* REG_EESCAPE */
+ "\0"
+#define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash")
+ gettext_noop ("Invalid back reference") /* REG_ESUBREG */
+ "\0"
+#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference")
+ gettext_noop ("Unmatched [, [^, [:, [., or [=") /* REG_EBRACK */
+ "\0"
+#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [, [^, [:, [., or [=")
+ gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */
+ "\0"
+#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
+ gettext_noop ("Unmatched \\{") /* REG_EBRACE */
+ "\0"
+#define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{")
+ gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */
+ "\0"
+#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}")
+ gettext_noop ("Invalid range end") /* REG_ERANGE */
+ "\0"
+#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end")
+ gettext_noop ("Memory exhausted") /* REG_ESPACE */
+ "\0"
+#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted")
+ gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */
+ "\0"
+#define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression")
+ gettext_noop ("Premature end of regular expression") /* REG_EEND */
+ "\0"
+#define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression")
+ gettext_noop ("Regular expression too big") /* REG_ESIZE */
+ "\0"
+#define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big")
+ gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */
+ };
+
+static const size_t __re_error_msgid_idx[] =
+ {
+ REG_NOERROR_IDX,
+ REG_NOMATCH_IDX,
+ REG_BADPAT_IDX,
+ REG_ECOLLATE_IDX,
+ REG_ECTYPE_IDX,
+ REG_EESCAPE_IDX,
+ REG_ESUBREG_IDX,
+ REG_EBRACK_IDX,
+ REG_EPAREN_IDX,
+ REG_EBRACE_IDX,
+ REG_BADBR_IDX,
+ REG_ERANGE_IDX,
+ REG_ESPACE_IDX,
+ REG_BADRPT_IDX,
+ REG_EEND_IDX,
+ REG_ESIZE_IDX,
+ REG_ERPAREN_IDX
+ };
+
+/* Entry points for GNU code. */
+
+/* re_compile_pattern is the GNU regular expression compiler: it
+ compiles PATTERN (of length LENGTH) and puts the result in BUFP.
+ Returns 0 if the pattern was valid, otherwise an error string.
+
+ Assumes the 'allocated' (and perhaps 'buffer') and 'translate' fields
+ are set in BUFP on entry. */
+
+const char *
+re_compile_pattern (const char *pattern, size_t length,
+ struct re_pattern_buffer *bufp)
+{
+ reg_errcode_t ret;
+
+ /* And GNU code determines whether or not to get register information
+ by passing null for the REGS argument to re_match, etc., not by
+ setting no_sub, unless RE_NO_SUB is set. */
+ bufp->no_sub = !!(re_syntax_options & RE_NO_SUB);
+
+ /* Match anchors at newline. */
+ bufp->newline_anchor = 1;
+
+ ret = re_compile_internal (bufp, pattern, length, re_syntax_options);
+
+ if (!ret)
+ return NULL;
+ return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
+}
+weak_alias (__re_compile_pattern, re_compile_pattern)
+
+/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can
+ also be assigned to arbitrarily: each pattern buffer stores its own
+ syntax, so it can be changed between regex compilations. */
+/* This has no initializer because initialized variables in Emacs
+ become read-only after dumping. */
+reg_syntax_t re_syntax_options;
+
+
+/* Specify the precise syntax of regexps for compilation. This provides
+ for compatibility for various utilities which historically have
+ different, incompatible syntaxes.
+
+ The argument SYNTAX is a bit mask comprised of the various bits
+ defined in regex.h. We return the old syntax. */
+
+reg_syntax_t
+re_set_syntax (reg_syntax_t syntax)
+{
+ reg_syntax_t ret = re_syntax_options;
+
+ re_syntax_options = syntax;
+ return ret;
+}
+weak_alias (__re_set_syntax, re_set_syntax)
+
+int
+re_compile_fastmap (struct re_pattern_buffer *bufp)
+{
+ re_dfa_t *dfa = bufp->buffer;
+ char *fastmap = bufp->fastmap;
+
+ memset (fastmap, '\0', sizeof (char) * SBC_MAX);
+ re_compile_fastmap_iter (bufp, dfa->init_state, fastmap);
+ if (dfa->init_state != dfa->init_state_word)
+ re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap);
+ if (dfa->init_state != dfa->init_state_nl)
+ re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap);
+ if (dfa->init_state != dfa->init_state_begbuf)
+ re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap);
+ bufp->fastmap_accurate = 1;
+ return 0;
+}
+weak_alias (__re_compile_fastmap, re_compile_fastmap)
+
+static inline void
+__attribute__ ((always_inline))
+re_set_fastmap (char *fastmap, bool icase, int ch)
+{
+ fastmap[ch] = 1;
+ if (icase)
+ fastmap[tolower (ch)] = 1;
+}
+
+/* Helper function for re_compile_fastmap.
+ Compile fastmap for the initial_state INIT_STATE. */
+
+static void
+re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
+ char *fastmap)
+{
+ re_dfa_t *dfa = bufp->buffer;
+ Idx node_cnt;
+ bool icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
+ for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
+ {
+ Idx node = init_state->nodes.elems[node_cnt];
+ re_token_type_t type = dfa->nodes[node].type;
+
+ if (type == CHARACTER)
+ {
+ re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
+#ifdef RE_ENABLE_I18N
+ if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+ {
+ unsigned char buf[MB_LEN_MAX];
+ unsigned char *p;
+ wchar_t wc;
+ mbstate_t state;
+
+ p = buf;
+ *p++ = dfa->nodes[node].opr.c;
+ while (++node < dfa->nodes_len
+ && dfa->nodes[node].type == CHARACTER
+ && dfa->nodes[node].mb_partial)
+ *p++ = dfa->nodes[node].opr.c;
+ memset (&state, '\0', sizeof (state));
+ if (__mbrtowc (&wc, (const char *) buf, p - buf,
+ &state) == p - buf
+ && (__wcrtomb ((char *) buf, __towlower (wc), &state)
+ != (size_t) -1))
+ re_set_fastmap (fastmap, false, buf[0]);
+ }
+#endif
+ }
+ else if (type == SIMPLE_BRACKET)
+ {
+ int i, ch;
+ for (i = 0, ch = 0; i < BITSET_WORDS; ++i)
+ {
+ int j;
+ bitset_word_t w = dfa->nodes[node].opr.sbcset[i];
+ for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
+ if (w & ((bitset_word_t) 1 << j))
+ re_set_fastmap (fastmap, icase, ch);
+ }
+ }
+#ifdef RE_ENABLE_I18N
+ else if (type == COMPLEX_BRACKET)
+ {
+ re_charset_t *cset = dfa->nodes[node].opr.mbcset;
+ Idx i;
+
+# ifdef _LIBC
+ /* See if we have to try all bytes which start multiple collation
+ elements.
+ e.g. In da_DK, we want to catch 'a' since "aa" is a valid
+ collation element, and don't catch 'b' since 'b' is
+ the only collation element which starts from 'b' (and
+ it is caught by SIMPLE_BRACKET). */
+ if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0
+ && (cset->ncoll_syms || cset->nranges))
+ {
+ const int32_t *table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+ for (i = 0; i < SBC_MAX; ++i)
+ if (table[i] < 0)
+ re_set_fastmap (fastmap, icase, i);
+ }
+# endif /* _LIBC */
+
+ /* See if we have to start the match at all multibyte characters,
+ i.e. where we would not find an invalid sequence. This only
+ applies to multibyte character sets; for single byte character
+ sets, the SIMPLE_BRACKET again suffices. */
+ if (dfa->mb_cur_max > 1
+ && (cset->nchar_classes || cset->non_match || cset->nranges
+# ifdef _LIBC
+ || cset->nequiv_classes
+# endif /* _LIBC */
+ ))
+ {
+ unsigned char c = 0;
+ do
+ {
+ mbstate_t mbs;
+ memset (&mbs, 0, sizeof (mbs));
+ if (__mbrtowc (NULL, (char *) &c, 1, &mbs) == (size_t) -2)
+ re_set_fastmap (fastmap, false, (int) c);
+ }
+ while (++c != 0);
+ }
+
+ else
+ {
+ /* ... Else catch all bytes which can start the mbchars. */
+ for (i = 0; i < cset->nmbchars; ++i)
+ {
+ char buf[256];
+ mbstate_t state;
+ memset (&state, '\0', sizeof (state));
+ if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
+ re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
+ if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+ {
+ if (__wcrtomb (buf, __towlower (cset->mbchars[i]), &state)
+ != (size_t) -1)
+ re_set_fastmap (fastmap, false, *(unsigned char *) buf);
+ }
+ }
+ }
+ }
+#endif /* RE_ENABLE_I18N */
+ else if (type == OP_PERIOD
+#ifdef RE_ENABLE_I18N
+ || type == OP_UTF8_PERIOD
+#endif /* RE_ENABLE_I18N */
+ || type == END_OF_RE)
+ {
+ memset (fastmap, '\1', sizeof (char) * SBC_MAX);
+ if (type == END_OF_RE)
+ bufp->can_be_null = 1;
+ return;
+ }
+ }
+}
+
+/* Entry point for POSIX code. */
+/* regcomp takes a regular expression as a string and compiles it.
+
+ PREG is a regex_t *. We do not expect any fields to be initialized,
+ since POSIX says we shouldn't. Thus, we set
+
+ 'buffer' to the compiled pattern;
+ 'used' to the length of the compiled pattern;
+ 'syntax' to RE_SYNTAX_POSIX_EXTENDED if the
+ REG_EXTENDED bit in CFLAGS is set; otherwise, to
+ RE_SYNTAX_POSIX_BASIC;
+ 'newline_anchor' to REG_NEWLINE being set in CFLAGS;
+ 'fastmap' to an allocated space for the fastmap;
+ 'fastmap_accurate' to zero;
+ 're_nsub' to the number of subexpressions in PATTERN.
+
+ PATTERN is the address of the pattern string.
+
+ CFLAGS is a series of bits which affect compilation.
+
+ If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we
+ use POSIX basic syntax.
+
+ If REG_NEWLINE is set, then . and [^...] don't match newline.
+ Also, regexec will try a match beginning after every newline.
+
+ If REG_ICASE is set, then we considers upper- and lowercase
+ versions of letters to be equivalent when matching.
+
+ If REG_NOSUB is set, then when PREG is passed to regexec, that
+ routine will report only success or failure, and nothing about the
+ registers.
+
+ It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for
+ the return codes and their meanings.) */
+
+int
+regcomp (regex_t *__restrict preg, const char *__restrict pattern, int cflags)
+{
+ reg_errcode_t ret;
+ reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
+ : RE_SYNTAX_POSIX_BASIC);
+
+ preg->buffer = NULL;
+ preg->allocated = 0;
+ preg->used = 0;
+
+ /* Try to allocate space for the fastmap. */
+ preg->fastmap = re_malloc (char, SBC_MAX);
+ if (__glibc_unlikely (preg->fastmap == NULL))
+ return REG_ESPACE;
+
+ syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
+
+ /* If REG_NEWLINE is set, newlines are treated differently. */
+ if (cflags & REG_NEWLINE)
+ { /* REG_NEWLINE implies neither . nor [^...] match newline. */
+ syntax &= ~RE_DOT_NEWLINE;
+ syntax |= RE_HAT_LISTS_NOT_NEWLINE;
+ /* It also changes the matching behavior. */
+ preg->newline_anchor = 1;
+ }
+ else
+ preg->newline_anchor = 0;
+ preg->no_sub = !!(cflags & REG_NOSUB);
+ preg->translate = NULL;
+
+ ret = re_compile_internal (preg, pattern, strlen (pattern), syntax);
+
+ /* POSIX doesn't distinguish between an unmatched open-group and an
+ unmatched close-group: both are REG_EPAREN. */
+ if (ret == REG_ERPAREN)
+ ret = REG_EPAREN;
+
+ /* We have already checked preg->fastmap != NULL. */
+ if (__glibc_likely (ret == REG_NOERROR))
+ /* Compute the fastmap now, since regexec cannot modify the pattern
+ buffer. This function never fails in this implementation. */
+ (void) re_compile_fastmap (preg);
+ else
+ {
+ /* Some error occurred while compiling the expression. */
+ re_free (preg->fastmap);
+ preg->fastmap = NULL;
+ }
+
+ return (int) ret;
+}
+libc_hidden_def (__regcomp)
+weak_alias (__regcomp, regcomp)
+
+/* Returns a message corresponding to an error code, ERRCODE, returned
+ from either regcomp or regexec. We don't use PREG here. */
+
+size_t
+regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
+ size_t errbuf_size)
+{
+ const char *msg;
+ size_t msg_size;
+ int nerrcodes = sizeof __re_error_msgid_idx / sizeof __re_error_msgid_idx[0];
+
+ if (__glibc_unlikely (errcode < 0 || errcode >= nerrcodes))
+ /* Only error codes returned by the rest of the code should be passed
+ to this routine. If we are given anything else, or if other regex
+ code generates an invalid error code, then the program has a bug.
+ Dump core so we can fix it. */
+ msg = gettext ("unknown regexp error");
+ else
+ msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
+
+ msg_size = strlen (msg) + 1; /* Includes the null. */
+
+ if (__glibc_likely (errbuf_size != 0))
+ {
+ size_t cpy_size = msg_size;
+ if (__glibc_unlikely (msg_size > errbuf_size))
+ {
+ cpy_size = errbuf_size - 1;
+ errbuf[cpy_size] = '\0';
+ }
+ memcpy (errbuf, msg, cpy_size);
+ }
+
+ return msg_size;
+}
+weak_alias (__regerror, regerror)
+
+
+#ifdef RE_ENABLE_I18N
+/* This static array is used for the map to single-byte characters when
+ UTF-8 is used. Otherwise we would allocate memory just to initialize
+ it the same all the time. UTF-8 is the preferred encoding so this is
+ a worthwhile optimization. */
+static const bitset_t utf8_sb_map =
+{
+ /* Set the first 128 bits. */
+# if defined __GNUC__ && !defined __STRICT_ANSI__
+ [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
+# else
+# if 4 * BITSET_WORD_BITS < ASCII_CHARS
+# error "bitset_word_t is narrower than 32 bits"
+# elif 3 * BITSET_WORD_BITS < ASCII_CHARS
+ BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX,
+# elif 2 * BITSET_WORD_BITS < ASCII_CHARS
+ BITSET_WORD_MAX, BITSET_WORD_MAX,
+# elif 1 * BITSET_WORD_BITS < ASCII_CHARS
+ BITSET_WORD_MAX,
+# endif
+ (BITSET_WORD_MAX
+ >> (SBC_MAX % BITSET_WORD_BITS == 0
+ ? 0
+ : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS))
+# endif
+};
+#endif
+
+
+static void
+free_dfa_content (re_dfa_t *dfa)
+{
+ Idx i, j;
+
+ if (dfa->nodes)
+ for (i = 0; i < dfa->nodes_len; ++i)
+ free_token (dfa->nodes + i);
+ re_free (dfa->nexts);
+ for (i = 0; i < dfa->nodes_len; ++i)
+ {
+ if (dfa->eclosures != NULL)
+ re_node_set_free (dfa->eclosures + i);
+ if (dfa->inveclosures != NULL)
+ re_node_set_free (dfa->inveclosures + i);
+ if (dfa->edests != NULL)
+ re_node_set_free (dfa->edests + i);
+ }
+ re_free (dfa->edests);
+ re_free (dfa->eclosures);
+ re_free (dfa->inveclosures);
+ re_free (dfa->nodes);
+
+ if (dfa->state_table)
+ for (i = 0; i <= dfa->state_hash_mask; ++i)
+ {
+ struct re_state_table_entry *entry = dfa->state_table + i;
+ for (j = 0; j < entry->num; ++j)
+ {
+ re_dfastate_t *state = entry->array[j];
+ free_state (state);
+ }
+ re_free (entry->array);
+ }
+ re_free (dfa->state_table);
+#ifdef RE_ENABLE_I18N
+ if (dfa->sb_char != utf8_sb_map)
+ re_free (dfa->sb_char);
+#endif
+ re_free (dfa->subexp_map);
+#ifdef DEBUG
+ re_free (dfa->re_str);
+#endif
+
+ re_free (dfa);
+}
+
+
+/* Free dynamically allocated space used by PREG. */
+
+void
+regfree (regex_t *preg)
+{
+ re_dfa_t *dfa = preg->buffer;
+ if (__glibc_likely (dfa != NULL))
+ {
+ lock_fini (dfa->lock);
+ free_dfa_content (dfa);
+ }
+ preg->buffer = NULL;
+ preg->allocated = 0;
+
+ re_free (preg->fastmap);
+ preg->fastmap = NULL;
+
+ re_free (preg->translate);
+ preg->translate = NULL;
+}
+libc_hidden_def (__regfree)
+weak_alias (__regfree, regfree)
+
+/* Entry points compatible with 4.2 BSD regex library. We don't define
+ them unless specifically requested. */
+
+#if defined _REGEX_RE_COMP || defined _LIBC
+
+/* BSD has one and only one pattern buffer. */
+static struct re_pattern_buffer re_comp_buf;
+
+char *
+# ifdef _LIBC
+/* Make these definitions weak in libc, so POSIX programs can redefine
+ these names if they don't use our functions, and still use
+ regcomp/regexec above without link errors. */
+weak_function
+# endif
+re_comp (const char *s)
+{
+ reg_errcode_t ret;
+ char *fastmap;
+
+ if (!s)
+ {
+ if (!re_comp_buf.buffer)
+ return gettext ("No previous regular expression");
+ return 0;
+ }
+
+ if (re_comp_buf.buffer)
+ {
+ fastmap = re_comp_buf.fastmap;
+ re_comp_buf.fastmap = NULL;
+ __regfree (&re_comp_buf);
+ memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
+ re_comp_buf.fastmap = fastmap;
+ }
+
+ if (re_comp_buf.fastmap == NULL)
+ {
+ re_comp_buf.fastmap = re_malloc (char, SBC_MAX);
+ if (re_comp_buf.fastmap == NULL)
+ return (char *) gettext (__re_error_msgid
+ + __re_error_msgid_idx[(int) REG_ESPACE]);
+ }
+
+ /* Since 're_exec' always passes NULL for the 'regs' argument, we
+ don't need to initialize the pattern buffer fields which affect it. */
+
+ /* Match anchors at newlines. */
+ re_comp_buf.newline_anchor = 1;
+
+ ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options);
+
+ if (!ret)
+ return NULL;
+
+ /* Yes, we're discarding 'const' here if !HAVE_LIBINTL. */
+ return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
+}
+
+#ifdef _LIBC
+libc_freeres_fn (free_mem)
+{
+ __regfree (&re_comp_buf);
+}
+#endif
+
+#endif /* _REGEX_RE_COMP */
+
+/* Internal entry point.
+ Compile the regular expression PATTERN, whose length is LENGTH.
+ SYNTAX indicate regular expression's syntax. */
+
+static reg_errcode_t
+re_compile_internal (regex_t *preg, const char * pattern, size_t length,
+ reg_syntax_t syntax)
+{
+ reg_errcode_t err = REG_NOERROR;
+ re_dfa_t *dfa;
+ re_string_t regexp;
+
+ /* Initialize the pattern buffer. */
+ preg->fastmap_accurate = 0;
+ preg->syntax = syntax;
+ preg->not_bol = preg->not_eol = 0;
+ preg->used = 0;
+ preg->re_nsub = 0;
+ preg->can_be_null = 0;
+ preg->regs_allocated = REGS_UNALLOCATED;
+
+ /* Initialize the dfa. */
+ dfa = preg->buffer;
+ if (__glibc_unlikely (preg->allocated < sizeof (re_dfa_t)))
+ {
+ /* If zero allocated, but buffer is non-null, try to realloc
+ enough space. This loses if buffer's address is bogus, but
+ that is the user's responsibility. If ->buffer is NULL this
+ is a simple allocation. */
+ dfa = re_realloc (preg->buffer, re_dfa_t, 1);
+ if (dfa == NULL)
+ return REG_ESPACE;
+ preg->allocated = sizeof (re_dfa_t);
+ preg->buffer = dfa;
+ }
+ preg->used = sizeof (re_dfa_t);
+
+ err = init_dfa (dfa, length);
+ if (__glibc_unlikely (err == REG_NOERROR && lock_init (dfa->lock) != 0))
+ err = REG_ESPACE;
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+ return err;
+ }
+#ifdef DEBUG
+ /* Note: length+1 will not overflow since it is checked in init_dfa. */
+ dfa->re_str = re_malloc (char, length + 1);
+ strncpy (dfa->re_str, pattern, length + 1);
+#endif
+
+ err = re_string_construct (&regexp, pattern, length, preg->translate,
+ (syntax & RE_ICASE) != 0, dfa);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_compile_internal_free_return:
+ free_workarea_compile (preg);
+ re_string_destruct (&regexp);
+ lock_fini (dfa->lock);
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+ return err;
+ }
+
+ /* Parse the regular expression, and build a structure tree. */
+ preg->re_nsub = 0;
+ dfa->str_tree = parse (&regexp, preg, syntax, &err);
+ if (__glibc_unlikely (dfa->str_tree == NULL))
+ goto re_compile_internal_free_return;
+
+ /* Analyze the tree and create the nfa. */
+ err = analyze (preg);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto re_compile_internal_free_return;
+
+#ifdef RE_ENABLE_I18N
+ /* If possible, do searching in single byte encoding to speed things up. */
+ if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
+ optimize_utf8 (dfa);
+#endif
+
+ /* Then create the initial state of the dfa. */
+ err = create_initial_state (dfa);
+
+ /* Release work areas. */
+ free_workarea_compile (preg);
+ re_string_destruct (&regexp);
+
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ lock_fini (dfa->lock);
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+ }
+
+ return err;
+}
+
+/* Initialize DFA. We use the length of the regular expression PAT_LEN
+ as the initial length of some arrays. */
+
+static reg_errcode_t
+init_dfa (re_dfa_t *dfa, size_t pat_len)
+{
+ __re_size_t table_size;
+#ifndef _LIBC
+ const char *codeset_name;
+#endif
+#ifdef RE_ENABLE_I18N
+ size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t));
+#else
+ size_t max_i18n_object_size = 0;
+#endif
+ size_t max_object_size =
+ MAX (sizeof (struct re_state_table_entry),
+ MAX (sizeof (re_token_t),
+ MAX (sizeof (re_node_set),
+ MAX (sizeof (regmatch_t),
+ max_i18n_object_size))));
+
+ memset (dfa, '\0', sizeof (re_dfa_t));
+
+ /* Force allocation of str_tree_storage the first time. */
+ dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE;
+
+ /* Avoid overflows. The extra "/ 2" is for the table_size doubling
+ calculation below, and for similar doubling calculations
+ elsewhere. And it's <= rather than <, because some of the
+ doubling calculations add 1 afterwards. */
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2
+ <= pat_len))
+ return REG_ESPACE;
+
+ dfa->nodes_alloc = pat_len + 1;
+ dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc);
+
+ /* table_size = 2 ^ ceil(log pat_len) */
+ for (table_size = 1; ; table_size <<= 1)
+ if (table_size > pat_len)
+ break;
+
+ dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
+ dfa->state_hash_mask = table_size - 1;
+
+ dfa->mb_cur_max = MB_CUR_MAX;
+#ifdef _LIBC
+ if (dfa->mb_cur_max == 6
+ && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0)
+ dfa->is_utf8 = 1;
+ dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII)
+ != 0);
+#else
+ codeset_name = nl_langinfo (CODESET);
+ if ((codeset_name[0] == 'U' || codeset_name[0] == 'u')
+ && (codeset_name[1] == 'T' || codeset_name[1] == 't')
+ && (codeset_name[2] == 'F' || codeset_name[2] == 'f')
+ && strcmp (codeset_name + 3 + (codeset_name[3] == '-'), "8") == 0)
+ dfa->is_utf8 = 1;
+
+ /* We check exhaustively in the loop below if this charset is a
+ superset of ASCII. */
+ dfa->map_notascii = 0;
+#endif
+
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ {
+ if (dfa->is_utf8)
+ dfa->sb_char = (re_bitset_ptr_t) utf8_sb_map;
+ else
+ {
+ int i, j, ch;
+
+ dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+ if (__glibc_unlikely (dfa->sb_char == NULL))
+ return REG_ESPACE;
+
+ /* Set the bits corresponding to single byte chars. */
+ for (i = 0, ch = 0; i < BITSET_WORDS; ++i)
+ for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
+ {
+ wint_t wch = __btowc (ch);
+ if (wch != WEOF)
+ dfa->sb_char[i] |= (bitset_word_t) 1 << j;
+# ifndef _LIBC
+ if (isascii (ch) && wch != ch)
+ dfa->map_notascii = 1;
+# endif
+ }
+ }
+ }
+#endif
+
+ if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL))
+ return REG_ESPACE;
+ return REG_NOERROR;
+}
+
+/* Initialize WORD_CHAR table, which indicate which character is
+ "word". In this case "word" means that it is the word construction
+ character used by some operators like "\<", "\>", etc. */
+
+static void
+init_word_char (re_dfa_t *dfa)
+{
+ int i = 0;
+ int j;
+ int ch = 0;
+ dfa->word_ops_used = 1;
+ if (__glibc_likely (dfa->map_notascii == 0))
+ {
+ /* Avoid uint32_t and uint64_t as some non-GCC platforms lack
+ them, an issue when this code is used in Gnulib. */
+ bitset_word_t bits0 = 0x00000000;
+ bitset_word_t bits1 = 0x03ff0000;
+ bitset_word_t bits2 = 0x87fffffe;
+ bitset_word_t bits3 = 0x07fffffe;
+ if (BITSET_WORD_BITS == 64)
+ {
+ /* Pacify gcc -Woverflow on 32-bit platformns. */
+ dfa->word_char[0] = bits1 << 31 << 1 | bits0;
+ dfa->word_char[1] = bits3 << 31 << 1 | bits2;
+ i = 2;
+ }
+ else if (BITSET_WORD_BITS == 32)
+ {
+ dfa->word_char[0] = bits0;
+ dfa->word_char[1] = bits1;
+ dfa->word_char[2] = bits2;
+ dfa->word_char[3] = bits3;
+ i = 4;
+ }
+ else
+ goto general_case;
+ ch = 128;
+
+ if (__glibc_likely (dfa->is_utf8))
+ {
+ memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8);
+ return;
+ }
+ }
+
+ general_case:
+ for (; i < BITSET_WORDS; ++i)
+ for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
+ if (isalnum (ch) || ch == '_')
+ dfa->word_char[i] |= (bitset_word_t) 1 << j;
+}
+
+/* Free the work area which are only used while compiling. */
+
+static void
+free_workarea_compile (regex_t *preg)
+{
+ re_dfa_t *dfa = preg->buffer;
+ bin_tree_storage_t *storage, *next;
+ for (storage = dfa->str_tree_storage; storage; storage = next)
+ {
+ next = storage->next;
+ re_free (storage);
+ }
+ dfa->str_tree_storage = NULL;
+ dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE;
+ dfa->str_tree = NULL;
+ re_free (dfa->org_indices);
+ dfa->org_indices = NULL;
+}
+
+/* Create initial states for all contexts. */
+
+static reg_errcode_t
+create_initial_state (re_dfa_t *dfa)
+{
+ Idx first, i;
+ reg_errcode_t err;
+ re_node_set init_nodes;
+
+ /* Initial states have the epsilon closure of the node which is
+ the first node of the regular expression. */
+ first = dfa->str_tree->first->node_idx;
+ dfa->init_node = first;
+ err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+
+ /* The back-references which are in initial states can epsilon transit,
+ since in this case all of the subexpressions can be null.
+ Then we add epsilon closures of the nodes which are the next nodes of
+ the back-references. */
+ if (dfa->nbackref > 0)
+ for (i = 0; i < init_nodes.nelem; ++i)
+ {
+ Idx node_idx = init_nodes.elems[i];
+ re_token_type_t type = dfa->nodes[node_idx].type;
+
+ Idx clexp_idx;
+ if (type != OP_BACK_REF)
+ continue;
+ for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx)
+ {
+ re_token_t *clexp_node;
+ clexp_node = dfa->nodes + init_nodes.elems[clexp_idx];
+ if (clexp_node->type == OP_CLOSE_SUBEXP
+ && clexp_node->opr.idx == dfa->nodes[node_idx].opr.idx)
+ break;
+ }
+ if (clexp_idx == init_nodes.nelem)
+ continue;
+
+ if (type == OP_BACK_REF)
+ {
+ Idx dest_idx = dfa->edests[node_idx].elems[0];
+ if (!re_node_set_contains (&init_nodes, dest_idx))
+ {
+ reg_errcode_t merge_err
+ = re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx);
+ if (merge_err != REG_NOERROR)
+ return merge_err;
+ i = 0;
+ }
+ }
+ }
+
+ /* It must be the first time to invoke acquire_state. */
+ dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0);
+ /* We don't check ERR here, since the initial state must not be NULL. */
+ if (__glibc_unlikely (dfa->init_state == NULL))
+ return err;
+ if (dfa->init_state->has_constraint)
+ {
+ dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes,
+ CONTEXT_WORD);
+ dfa->init_state_nl = re_acquire_state_context (&err, dfa, &init_nodes,
+ CONTEXT_NEWLINE);
+ dfa->init_state_begbuf = re_acquire_state_context (&err, dfa,
+ &init_nodes,
+ CONTEXT_NEWLINE
+ | CONTEXT_BEGBUF);
+ if (__glibc_unlikely (dfa->init_state_word == NULL
+ || dfa->init_state_nl == NULL
+ || dfa->init_state_begbuf == NULL))
+ return err;
+ }
+ else
+ dfa->init_state_word = dfa->init_state_nl
+ = dfa->init_state_begbuf = dfa->init_state;
+
+ re_node_set_free (&init_nodes);
+ return REG_NOERROR;
+}
+
+#ifdef RE_ENABLE_I18N
+/* If it is possible to do searching in single byte encoding instead of UTF-8
+ to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change
+ DFA nodes where needed. */
+
+static void
+optimize_utf8 (re_dfa_t *dfa)
+{
+ Idx node;
+ int i;
+ bool mb_chars = false;
+ bool has_period = false;
+
+ for (node = 0; node < dfa->nodes_len; ++node)
+ switch (dfa->nodes[node].type)
+ {
+ case CHARACTER:
+ if (dfa->nodes[node].opr.c >= ASCII_CHARS)
+ mb_chars = true;
+ break;
+ case ANCHOR:
+ switch (dfa->nodes[node].opr.ctx_type)
+ {
+ case LINE_FIRST:
+ case LINE_LAST:
+ case BUF_FIRST:
+ case BUF_LAST:
+ break;
+ default:
+ /* Word anchors etc. cannot be handled. It's okay to test
+ opr.ctx_type since constraints (for all DFA nodes) are
+ created by ORing one or more opr.ctx_type values. */
+ return;
+ }
+ break;
+ case OP_PERIOD:
+ has_period = true;
+ break;
+ case OP_BACK_REF:
+ case OP_ALT:
+ case END_OF_RE:
+ case OP_DUP_ASTERISK:
+ case OP_OPEN_SUBEXP:
+ case OP_CLOSE_SUBEXP:
+ break;
+ case COMPLEX_BRACKET:
+ return;
+ case SIMPLE_BRACKET:
+ /* Just double check. */
+ {
+ int rshift = (ASCII_CHARS % BITSET_WORD_BITS == 0
+ ? 0
+ : BITSET_WORD_BITS - ASCII_CHARS % BITSET_WORD_BITS);
+ for (i = ASCII_CHARS / BITSET_WORD_BITS; i < BITSET_WORDS; ++i)
+ {
+ if (dfa->nodes[node].opr.sbcset[i] >> rshift != 0)
+ return;
+ rshift = 0;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (mb_chars || has_period)
+ for (node = 0; node < dfa->nodes_len; ++node)
+ {
+ if (dfa->nodes[node].type == CHARACTER
+ && dfa->nodes[node].opr.c >= ASCII_CHARS)
+ dfa->nodes[node].mb_partial = 0;
+ else if (dfa->nodes[node].type == OP_PERIOD)
+ dfa->nodes[node].type = OP_UTF8_PERIOD;
+ }
+
+ /* The search can be in single byte locale. */
+ dfa->mb_cur_max = 1;
+ dfa->is_utf8 = 0;
+ dfa->has_mb_node = dfa->nbackref > 0 || has_period;
+}
+#endif
+
+/* Analyze the structure tree, and calculate "first", "next", "edest",
+ "eclosure", and "inveclosure". */
+
+static reg_errcode_t
+analyze (regex_t *preg)
+{
+ re_dfa_t *dfa = preg->buffer;
+ reg_errcode_t ret;
+
+ /* Allocate arrays. */
+ dfa->nexts = re_malloc (Idx, dfa->nodes_alloc);
+ dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc);
+ dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc);
+ dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc);
+ if (__glibc_unlikely (dfa->nexts == NULL || dfa->org_indices == NULL
+ || dfa->edests == NULL || dfa->eclosures == NULL))
+ return REG_ESPACE;
+
+ dfa->subexp_map = re_malloc (Idx, preg->re_nsub);
+ if (dfa->subexp_map != NULL)
+ {
+ Idx i;
+ for (i = 0; i < preg->re_nsub; i++)
+ dfa->subexp_map[i] = i;
+ preorder (dfa->str_tree, optimize_subexps, dfa);
+ for (i = 0; i < preg->re_nsub; i++)
+ if (dfa->subexp_map[i] != i)
+ break;
+ if (i == preg->re_nsub)
+ {
+ re_free (dfa->subexp_map);
+ dfa->subexp_map = NULL;
+ }
+ }
+
+ ret = postorder (dfa->str_tree, lower_subexps, preg);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+ ret = postorder (dfa->str_tree, calc_first, dfa);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+ preorder (dfa->str_tree, calc_next, dfa);
+ ret = preorder (dfa->str_tree, link_nfa_nodes, dfa);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+ ret = calc_eclosure (dfa);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+
+ /* We only need this during the prune_impossible_nodes pass in regexec.c;
+ skip it if p_i_n will not run, as calc_inveclosure can be quadratic. */
+ if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match)
+ || dfa->nbackref)
+ {
+ dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
+ if (__glibc_unlikely (dfa->inveclosures == NULL))
+ return REG_ESPACE;
+ ret = calc_inveclosure (dfa);
+ }
+
+ return ret;
+}
+
+/* Our parse trees are very unbalanced, so we cannot use a stack to
+ implement parse tree visits. Instead, we use parent pointers and
+ some hairy code in these two functions. */
+static reg_errcode_t
+postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
+ void *extra)
+{
+ bin_tree_t *node, *prev;
+
+ for (node = root; ; )
+ {
+ /* Descend down the tree, preferably to the left (or to the right
+ if that's the only child). */
+ while (node->left || node->right)
+ if (node->left)
+ node = node->left;
+ else
+ node = node->right;
+
+ do
+ {
+ reg_errcode_t err = fn (extra, node);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ if (node->parent == NULL)
+ return REG_NOERROR;
+ prev = node;
+ node = node->parent;
+ }
+ /* Go up while we have a node that is reached from the right. */
+ while (node->right == prev || node->right == NULL);
+ node = node->right;
+ }
+}
+
+static reg_errcode_t
+preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
+ void *extra)
+{
+ bin_tree_t *node;
+
+ for (node = root; ; )
+ {
+ reg_errcode_t err = fn (extra, node);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+
+ /* Go to the left node, or up and to the right. */
+ if (node->left)
+ node = node->left;
+ else
+ {
+ bin_tree_t *prev = NULL;
+ while (node->right == prev || node->right == NULL)
+ {
+ prev = node;
+ node = node->parent;
+ if (!node)
+ return REG_NOERROR;
+ }
+ node = node->right;
+ }
+ }
+}
+
+/* Optimization pass: if a SUBEXP is entirely contained, strip it and tell
+ re_search_internal to map the inner one's opr.idx to this one's. Adjust
+ backreferences as well. Requires a preorder visit. */
+static reg_errcode_t
+optimize_subexps (void *extra, bin_tree_t *node)
+{
+ re_dfa_t *dfa = (re_dfa_t *) extra;
+
+ if (node->token.type == OP_BACK_REF && dfa->subexp_map)
+ {
+ int idx = node->token.opr.idx;
+ node->token.opr.idx = dfa->subexp_map[idx];
+ dfa->used_bkref_map |= 1 << node->token.opr.idx;
+ }
+
+ else if (node->token.type == SUBEXP
+ && node->left && node->left->token.type == SUBEXP)
+ {
+ Idx other_idx = node->left->token.opr.idx;
+
+ node->left = node->left->left;
+ if (node->left)
+ node->left->parent = node;
+
+ dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx];
+ if (other_idx < BITSET_WORD_BITS)
+ dfa->used_bkref_map &= ~((bitset_word_t) 1 << other_idx);
+ }
+
+ return REG_NOERROR;
+}
+
+/* Lowering pass: Turn each SUBEXP node into the appropriate concatenation
+ of OP_OPEN_SUBEXP, the body of the SUBEXP (if any) and OP_CLOSE_SUBEXP. */
+static reg_errcode_t
+lower_subexps (void *extra, bin_tree_t *node)
+{
+ regex_t *preg = (regex_t *) extra;
+ reg_errcode_t err = REG_NOERROR;
+
+ if (node->left && node->left->token.type == SUBEXP)
+ {
+ node->left = lower_subexp (&err, preg, node->left);
+ if (node->left)
+ node->left->parent = node;
+ }
+ if (node->right && node->right->token.type == SUBEXP)
+ {
+ node->right = lower_subexp (&err, preg, node->right);
+ if (node->right)
+ node->right->parent = node;
+ }
+
+ return err;
+}
+
+static bin_tree_t *
+lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
+{
+ re_dfa_t *dfa = preg->buffer;
+ bin_tree_t *body = node->left;
+ bin_tree_t *op, *cls, *tree1, *tree;
+
+ if (preg->no_sub
+ /* We do not optimize empty subexpressions, because otherwise we may
+ have bad CONCAT nodes with NULL children. This is obviously not
+ very common, so we do not lose much. An example that triggers
+ this case is the sed "script" /\(\)/x. */
+ && node->left != NULL
+ && (node->token.opr.idx >= BITSET_WORD_BITS
+ || !(dfa->used_bkref_map
+ & ((bitset_word_t) 1 << node->token.opr.idx))))
+ return node->left;
+
+ /* Convert the SUBEXP node to the concatenation of an
+ OP_OPEN_SUBEXP, the contents, and an OP_CLOSE_SUBEXP. */
+ op = create_tree (dfa, NULL, NULL, OP_OPEN_SUBEXP);
+ cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP);
+ tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls;
+ tree = create_tree (dfa, op, tree1, CONCAT);
+ if (__glibc_unlikely (tree == NULL || tree1 == NULL
+ || op == NULL || cls == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+
+ op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx;
+ op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp;
+ return tree;
+}
+
+/* Pass 1 in building the NFA: compute FIRST and create unlinked automaton
+ nodes. Requires a postorder visit. */
+static reg_errcode_t
+calc_first (void *extra, bin_tree_t *node)
+{
+ re_dfa_t *dfa = (re_dfa_t *) extra;
+ if (node->token.type == CONCAT)
+ {
+ node->first = node->left->first;
+ node->node_idx = node->left->node_idx;
+ }
+ else
+ {
+ node->first = node;
+ node->node_idx = re_dfa_add_node (dfa, node->token);
+ if (__glibc_unlikely (node->node_idx == -1))
+ return REG_ESPACE;
+ if (node->token.type == ANCHOR)
+ dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
+ }
+ return REG_NOERROR;
+}
+
+/* Pass 2: compute NEXT on the tree. Preorder visit. */
+static reg_errcode_t
+calc_next (void *extra, bin_tree_t *node)
+{
+ switch (node->token.type)
+ {
+ case OP_DUP_ASTERISK:
+ node->left->next = node;
+ break;
+ case CONCAT:
+ node->left->next = node->right->first;
+ node->right->next = node->next;
+ break;
+ default:
+ if (node->left)
+ node->left->next = node->next;
+ if (node->right)
+ node->right->next = node->next;
+ break;
+ }
+ return REG_NOERROR;
+}
+
+/* Pass 3: link all DFA nodes to their NEXT node (any order will do). */
+static reg_errcode_t
+link_nfa_nodes (void *extra, bin_tree_t *node)
+{
+ re_dfa_t *dfa = (re_dfa_t *) extra;
+ Idx idx = node->node_idx;
+ reg_errcode_t err = REG_NOERROR;
+
+ switch (node->token.type)
+ {
+ case CONCAT:
+ break;
+
+ case END_OF_RE:
+ assert (node->next == NULL);
+ break;
+
+ case OP_DUP_ASTERISK:
+ case OP_ALT:
+ {
+ Idx left, right;
+ dfa->has_plural_match = 1;
+ if (node->left != NULL)
+ left = node->left->first->node_idx;
+ else
+ left = node->next->node_idx;
+ if (node->right != NULL)
+ right = node->right->first->node_idx;
+ else
+ right = node->next->node_idx;
+ assert (left > -1);
+ assert (right > -1);
+ err = re_node_set_init_2 (dfa->edests + idx, left, right);
+ }
+ break;
+
+ case ANCHOR:
+ case OP_OPEN_SUBEXP:
+ case OP_CLOSE_SUBEXP:
+ err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx);
+ break;
+
+ case OP_BACK_REF:
+ dfa->nexts[idx] = node->next->node_idx;
+ if (node->token.type == OP_BACK_REF)
+ err = re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]);
+ break;
+
+ default:
+ assert (!IS_EPSILON_NODE (node->token.type));
+ dfa->nexts[idx] = node->next->node_idx;
+ break;
+ }
+
+ return err;
+}
+
+/* Duplicate the epsilon closure of the node ROOT_NODE.
+ Note that duplicated nodes have constraint INIT_CONSTRAINT in addition
+ to their own constraint. */
+
+static reg_errcode_t
+duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
+ Idx root_node, unsigned int init_constraint)
+{
+ Idx org_node, clone_node;
+ bool ok;
+ unsigned int constraint = init_constraint;
+ for (org_node = top_org_node, clone_node = top_clone_node;;)
+ {
+ Idx org_dest, clone_dest;
+ if (dfa->nodes[org_node].type == OP_BACK_REF)
+ {
+ /* If the back reference epsilon-transit, its destination must
+ also have the constraint. Then duplicate the epsilon closure
+ of the destination of the back reference, and store it in
+ edests of the back reference. */
+ org_dest = dfa->nexts[org_node];
+ re_node_set_empty (dfa->edests + clone_node);
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (__glibc_unlikely (clone_dest == -1))
+ return REG_ESPACE;
+ dfa->nexts[clone_node] = dfa->nexts[org_node];
+ ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ }
+ else if (dfa->edests[org_node].nelem == 0)
+ {
+ /* In case of the node can't epsilon-transit, don't duplicate the
+ destination and store the original destination as the
+ destination of the node. */
+ dfa->nexts[clone_node] = dfa->nexts[org_node];
+ break;
+ }
+ else if (dfa->edests[org_node].nelem == 1)
+ {
+ /* In case of the node can epsilon-transit, and it has only one
+ destination. */
+ org_dest = dfa->edests[org_node].elems[0];
+ re_node_set_empty (dfa->edests + clone_node);
+ /* If the node is root_node itself, it means the epsilon closure
+ has a loop. Then tie it to the destination of the root_node. */
+ if (org_node == root_node && clone_node != org_node)
+ {
+ ok = re_node_set_insert (dfa->edests + clone_node, org_dest);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ break;
+ }
+ /* In case the node has another constraint, append it. */
+ constraint |= dfa->nodes[org_node].constraint;
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (__glibc_unlikely (clone_dest == -1))
+ return REG_ESPACE;
+ ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ }
+ else /* dfa->edests[org_node].nelem == 2 */
+ {
+ /* In case of the node can epsilon-transit, and it has two
+ destinations. In the bin_tree_t and DFA, that's '|' and '*'. */
+ org_dest = dfa->edests[org_node].elems[0];
+ re_node_set_empty (dfa->edests + clone_node);
+ /* Search for a duplicated node which satisfies the constraint. */
+ clone_dest = search_duplicated_node (dfa, org_dest, constraint);
+ if (clone_dest == -1)
+ {
+ /* There is no such duplicated node, create a new one. */
+ reg_errcode_t err;
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (__glibc_unlikely (clone_dest == -1))
+ return REG_ESPACE;
+ ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ err = duplicate_node_closure (dfa, org_dest, clone_dest,
+ root_node, constraint);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ else
+ {
+ /* There is a duplicated node which satisfies the constraint,
+ use it to avoid infinite loop. */
+ ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ }
+
+ org_dest = dfa->edests[org_node].elems[1];
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (__glibc_unlikely (clone_dest == -1))
+ return REG_ESPACE;
+ ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ }
+ org_node = org_dest;
+ clone_node = clone_dest;
+ }
+ return REG_NOERROR;
+}
+
+/* Search for a node which is duplicated from the node ORG_NODE, and
+ satisfies the constraint CONSTRAINT. */
+
+static Idx
+search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
+ unsigned int constraint)
+{
+ Idx idx;
+ for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx)
+ {
+ if (org_node == dfa->org_indices[idx]
+ && constraint == dfa->nodes[idx].constraint)
+ return idx; /* Found. */
+ }
+ return -1; /* Not found. */
+}
+
+/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT.
+ Return the index of the new node, or -1 if insufficient storage is
+ available. */
+
+static Idx
+duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint)
+{
+ Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]);
+ if (__glibc_likely (dup_idx != -1))
+ {
+ dfa->nodes[dup_idx].constraint = constraint;
+ dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint;
+ dfa->nodes[dup_idx].duplicated = 1;
+
+ /* Store the index of the original node. */
+ dfa->org_indices[dup_idx] = org_idx;
+ }
+ return dup_idx;
+}
+
+static reg_errcode_t
+calc_inveclosure (re_dfa_t *dfa)
+{
+ Idx src, idx;
+ bool ok;
+ for (idx = 0; idx < dfa->nodes_len; ++idx)
+ re_node_set_init_empty (dfa->inveclosures + idx);
+
+ for (src = 0; src < dfa->nodes_len; ++src)
+ {
+ Idx *elems = dfa->eclosures[src].elems;
+ for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx)
+ {
+ ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ }
+ }
+
+ return REG_NOERROR;
+}
+
+/* Calculate "eclosure" for all the node in DFA. */
+
+static reg_errcode_t
+calc_eclosure (re_dfa_t *dfa)
+{
+ Idx node_idx;
+ bool incomplete;
+#ifdef DEBUG
+ assert (dfa->nodes_len > 0);
+#endif
+ incomplete = false;
+ /* For each nodes, calculate epsilon closure. */
+ for (node_idx = 0; ; ++node_idx)
+ {
+ reg_errcode_t err;
+ re_node_set eclosure_elem;
+ if (node_idx == dfa->nodes_len)
+ {
+ if (!incomplete)
+ break;
+ incomplete = false;
+ node_idx = 0;
+ }
+
+#ifdef DEBUG
+ assert (dfa->eclosures[node_idx].nelem != -1);
+#endif
+
+ /* If we have already calculated, skip it. */
+ if (dfa->eclosures[node_idx].nelem != 0)
+ continue;
+ /* Calculate epsilon closure of 'node_idx'. */
+ err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+
+ if (dfa->eclosures[node_idx].nelem == 0)
+ {
+ incomplete = true;
+ re_node_set_free (&eclosure_elem);
+ }
+ }
+ return REG_NOERROR;
+}
+
+/* Calculate epsilon closure of NODE. */
+
+static reg_errcode_t
+calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
+{
+ reg_errcode_t err;
+ Idx i;
+ re_node_set eclosure;
+ bool ok;
+ bool incomplete = false;
+ err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+
+ /* This indicates that we are calculating this node now.
+ We reference this value to avoid infinite loop. */
+ dfa->eclosures[node].nelem = -1;
+
+ /* If the current node has constraints, duplicate all nodes
+ since they must inherit the constraints. */
+ if (dfa->nodes[node].constraint
+ && dfa->edests[node].nelem
+ && !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
+ {
+ err = duplicate_node_closure (dfa, node, node, node,
+ dfa->nodes[node].constraint);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+
+ /* Expand each epsilon destination nodes. */
+ if (IS_EPSILON_NODE(dfa->nodes[node].type))
+ for (i = 0; i < dfa->edests[node].nelem; ++i)
+ {
+ re_node_set eclosure_elem;
+ Idx edest = dfa->edests[node].elems[i];
+ /* If calculating the epsilon closure of 'edest' is in progress,
+ return intermediate result. */
+ if (dfa->eclosures[edest].nelem == -1)
+ {
+ incomplete = true;
+ continue;
+ }
+ /* If we haven't calculated the epsilon closure of 'edest' yet,
+ calculate now. Otherwise use calculated epsilon closure. */
+ if (dfa->eclosures[edest].nelem == 0)
+ {
+ err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ else
+ eclosure_elem = dfa->eclosures[edest];
+ /* Merge the epsilon closure of 'edest'. */
+ err = re_node_set_merge (&eclosure, &eclosure_elem);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ /* If the epsilon closure of 'edest' is incomplete,
+ the epsilon closure of this node is also incomplete. */
+ if (dfa->eclosures[edest].nelem == 0)
+ {
+ incomplete = true;
+ re_node_set_free (&eclosure_elem);
+ }
+ }
+
+ /* An epsilon closure includes itself. */
+ ok = re_node_set_insert (&eclosure, node);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ if (incomplete && !root)
+ dfa->eclosures[node].nelem = 0;
+ else
+ dfa->eclosures[node] = eclosure;
+ *new_set = eclosure;
+ return REG_NOERROR;
+}
+
+/* Functions for token which are used in the parser. */
+
+/* Fetch a token from INPUT.
+ We must not use this function inside bracket expressions. */
+
+static void
+fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
+{
+ re_string_skip_bytes (input, peek_token (result, input, syntax));
+}
+
+/* Peek a token from INPUT, and return the length of the token.
+ We must not use this function inside bracket expressions. */
+
+static int
+peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
+{
+ unsigned char c;
+
+ if (re_string_eoi (input))
+ {
+ token->type = END_OF_RE;
+ return 0;
+ }
+
+ c = re_string_peek_byte (input, 0);
+ token->opr.c = c;
+
+ token->word_char = 0;
+#ifdef RE_ENABLE_I18N
+ token->mb_partial = 0;
+ if (input->mb_cur_max > 1 &&
+ !re_string_first_byte (input, re_string_cur_idx (input)))
+ {
+ token->type = CHARACTER;
+ token->mb_partial = 1;
+ return 1;
+ }
+#endif
+ if (c == '\\')
+ {
+ unsigned char c2;
+ if (re_string_cur_idx (input) + 1 >= re_string_length (input))
+ {
+ token->type = BACK_SLASH;
+ return 1;
+ }
+
+ c2 = re_string_peek_byte_case (input, 1);
+ token->opr.c = c2;
+ token->type = CHARACTER;
+#ifdef RE_ENABLE_I18N
+ if (input->mb_cur_max > 1)
+ {
+ wint_t wc = re_string_wchar_at (input,
+ re_string_cur_idx (input) + 1);
+ token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
+ }
+ else
+#endif
+ token->word_char = IS_WORD_CHAR (c2) != 0;
+
+ switch (c2)
+ {
+ case '|':
+ if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR))
+ token->type = OP_ALT;
+ break;
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ if (!(syntax & RE_NO_BK_REFS))
+ {
+ token->type = OP_BACK_REF;
+ token->opr.idx = c2 - '1';
+ }
+ break;
+ case '<':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = WORD_FIRST;
+ }
+ break;
+ case '>':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = WORD_LAST;
+ }
+ break;
+ case 'b':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = WORD_DELIM;
+ }
+ break;
+ case 'B':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = NOT_WORD_DELIM;
+ }
+ break;
+ case 'w':
+ if (!(syntax & RE_NO_GNU_OPS))
+ token->type = OP_WORD;
+ break;
+ case 'W':
+ if (!(syntax & RE_NO_GNU_OPS))
+ token->type = OP_NOTWORD;
+ break;
+ case 's':
+ if (!(syntax & RE_NO_GNU_OPS))
+ token->type = OP_SPACE;
+ break;
+ case 'S':
+ if (!(syntax & RE_NO_GNU_OPS))
+ token->type = OP_NOTSPACE;
+ break;
+ case '`':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = BUF_FIRST;
+ }
+ break;
+ case '\'':
+ if (!(syntax & RE_NO_GNU_OPS))
+ {
+ token->type = ANCHOR;
+ token->opr.ctx_type = BUF_LAST;
+ }
+ break;
+ case '(':
+ if (!(syntax & RE_NO_BK_PARENS))
+ token->type = OP_OPEN_SUBEXP;
+ break;
+ case ')':
+ if (!(syntax & RE_NO_BK_PARENS))
+ token->type = OP_CLOSE_SUBEXP;
+ break;
+ case '+':
+ if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
+ token->type = OP_DUP_PLUS;
+ break;
+ case '?':
+ if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
+ token->type = OP_DUP_QUESTION;
+ break;
+ case '{':
+ if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
+ token->type = OP_OPEN_DUP_NUM;
+ break;
+ case '}':
+ if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
+ token->type = OP_CLOSE_DUP_NUM;
+ break;
+ default:
+ break;
+ }
+ return 2;
+ }
+
+ token->type = CHARACTER;
+#ifdef RE_ENABLE_I18N
+ if (input->mb_cur_max > 1)
+ {
+ wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input));
+ token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
+ }
+ else
+#endif
+ token->word_char = IS_WORD_CHAR (token->opr.c);
+
+ switch (c)
+ {
+ case '\n':
+ if (syntax & RE_NEWLINE_ALT)
+ token->type = OP_ALT;
+ break;
+ case '|':
+ if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR))
+ token->type = OP_ALT;
+ break;
+ case '*':
+ token->type = OP_DUP_ASTERISK;
+ break;
+ case '+':
+ if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
+ token->type = OP_DUP_PLUS;
+ break;
+ case '?':
+ if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
+ token->type = OP_DUP_QUESTION;
+ break;
+ case '{':
+ if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+ token->type = OP_OPEN_DUP_NUM;
+ break;
+ case '}':
+ if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+ token->type = OP_CLOSE_DUP_NUM;
+ break;
+ case '(':
+ if (syntax & RE_NO_BK_PARENS)
+ token->type = OP_OPEN_SUBEXP;
+ break;
+ case ')':
+ if (syntax & RE_NO_BK_PARENS)
+ token->type = OP_CLOSE_SUBEXP;
+ break;
+ case '[':
+ token->type = OP_OPEN_BRACKET;
+ break;
+ case '.':
+ token->type = OP_PERIOD;
+ break;
+ case '^':
+ if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) &&
+ re_string_cur_idx (input) != 0)
+ {
+ char prev = re_string_peek_byte (input, -1);
+ if (!(syntax & RE_NEWLINE_ALT) || prev != '\n')
+ break;
+ }
+ token->type = ANCHOR;
+ token->opr.ctx_type = LINE_FIRST;
+ break;
+ case '$':
+ if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) &&
+ re_string_cur_idx (input) + 1 != re_string_length (input))
+ {
+ re_token_t next;
+ re_string_skip_bytes (input, 1);
+ peek_token (&next, input, syntax);
+ re_string_skip_bytes (input, -1);
+ if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP)
+ break;
+ }
+ token->type = ANCHOR;
+ token->opr.ctx_type = LINE_LAST;
+ break;
+ default:
+ break;
+ }
+ return 1;
+}
+
+/* Peek a token from INPUT, and return the length of the token.
+ We must not use this function out of bracket expressions. */
+
+static int
+peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
+{
+ unsigned char c;
+ if (re_string_eoi (input))
+ {
+ token->type = END_OF_RE;
+ return 0;
+ }
+ c = re_string_peek_byte (input, 0);
+ token->opr.c = c;
+
+#ifdef RE_ENABLE_I18N
+ if (input->mb_cur_max > 1 &&
+ !re_string_first_byte (input, re_string_cur_idx (input)))
+ {
+ token->type = CHARACTER;
+ return 1;
+ }
+#endif /* RE_ENABLE_I18N */
+
+ if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
+ && re_string_cur_idx (input) + 1 < re_string_length (input))
+ {
+ /* In this case, '\' escape a character. */
+ unsigned char c2;
+ re_string_skip_bytes (input, 1);
+ c2 = re_string_peek_byte (input, 0);
+ token->opr.c = c2;
+ token->type = CHARACTER;
+ return 1;
+ }
+ if (c == '[') /* '[' is a special char in a bracket exps. */
+ {
+ unsigned char c2;
+ int token_len;
+ if (re_string_cur_idx (input) + 1 < re_string_length (input))
+ c2 = re_string_peek_byte (input, 1);
+ else
+ c2 = 0;
+ token->opr.c = c2;
+ token_len = 2;
+ switch (c2)
+ {
+ case '.':
+ token->type = OP_OPEN_COLL_ELEM;
+ break;
+
+ case '=':
+ token->type = OP_OPEN_EQUIV_CLASS;
+ break;
+
+ case ':':
+ if (syntax & RE_CHAR_CLASSES)
+ {
+ token->type = OP_OPEN_CHAR_CLASS;
+ break;
+ }
+ FALLTHROUGH;
+ default:
+ token->type = CHARACTER;
+ token->opr.c = c;
+ token_len = 1;
+ break;
+ }
+ return token_len;
+ }
+ switch (c)
+ {
+ case '-':
+ token->type = OP_CHARSET_RANGE;
+ break;
+ case ']':
+ token->type = OP_CLOSE_BRACKET;
+ break;
+ case '^':
+ token->type = OP_NON_MATCH_LIST;
+ break;
+ default:
+ token->type = CHARACTER;
+ }
+ return 1;
+}
+
+/* Functions for parser. */
+
+/* Entry point of the parser.
+ Parse the regular expression REGEXP and return the structure tree.
+ If an error occurs, ERR is set by error code, and return NULL.
+ This function build the following tree, from regular expression <reg_exp>:
+ CAT
+ / \
+ / \
+ <reg_exp> EOR
+
+ CAT means concatenation.
+ EOR means end of regular expression. */
+
+static bin_tree_t *
+parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
+ reg_errcode_t *err)
+{
+ re_dfa_t *dfa = preg->buffer;
+ bin_tree_t *tree, *eor, *root;
+ re_token_t current_token;
+ dfa->syntax = syntax;
+ fetch_token (&current_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+ tree = parse_reg_exp (regexp, preg, &current_token, syntax, 0, err);
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
+ return NULL;
+ eor = create_tree (dfa, NULL, NULL, END_OF_RE);
+ if (tree != NULL)
+ root = create_tree (dfa, tree, eor, CONCAT);
+ else
+ root = eor;
+ if (__glibc_unlikely (eor == NULL || root == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ return root;
+}
+
+/* This function build the following tree, from regular expression
+ <branch1>|<branch2>:
+ ALT
+ / \
+ / \
+ <branch1> <branch2>
+
+ ALT means alternative, which represents the operator '|'. */
+
+static bin_tree_t *
+parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
+ reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
+{
+ re_dfa_t *dfa = preg->buffer;
+ bin_tree_t *tree, *branch = NULL;
+ bitset_word_t initial_bkref_map = dfa->completed_bkref_map;
+ tree = parse_branch (regexp, preg, token, syntax, nest, err);
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
+ return NULL;
+
+ while (token->type == OP_ALT)
+ {
+ fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+ if (token->type != OP_ALT && token->type != END_OF_RE
+ && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
+ {
+ bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map;
+ dfa->completed_bkref_map = initial_bkref_map;
+ branch = parse_branch (regexp, preg, token, syntax, nest, err);
+ if (__glibc_unlikely (*err != REG_NOERROR && branch == NULL))
+ {
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
+ return NULL;
+ }
+ dfa->completed_bkref_map |= accumulated_bkref_map;
+ }
+ else
+ branch = NULL;
+ tree = create_tree (dfa, tree, branch, OP_ALT);
+ if (__glibc_unlikely (tree == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ }
+ return tree;
+}
+
+/* This function build the following tree, from regular expression
+ <exp1><exp2>:
+ CAT
+ / \
+ / \
+ <exp1> <exp2>
+
+ CAT means concatenation. */
+
+static bin_tree_t *
+parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
+ reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
+{
+ bin_tree_t *tree, *expr;
+ re_dfa_t *dfa = preg->buffer;
+ tree = parse_expression (regexp, preg, token, syntax, nest, err);
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
+ return NULL;
+
+ while (token->type != OP_ALT && token->type != END_OF_RE
+ && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
+ {
+ expr = parse_expression (regexp, preg, token, syntax, nest, err);
+ if (__glibc_unlikely (*err != REG_NOERROR && expr == NULL))
+ {
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
+ return NULL;
+ }
+ if (tree != NULL && expr != NULL)
+ {
+ bin_tree_t *newtree = create_tree (dfa, tree, expr, CONCAT);
+ if (newtree == NULL)
+ {
+ postorder (expr, free_tree, NULL);
+ postorder (tree, free_tree, NULL);
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ tree = newtree;
+ }
+ else if (tree == NULL)
+ tree = expr;
+ /* Otherwise expr == NULL, we don't need to create new tree. */
+ }
+ return tree;
+}
+
+/* This function build the following tree, from regular expression a*:
+ *
+ |
+ a
+*/
+
+static bin_tree_t *
+parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
+ reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
+{
+ re_dfa_t *dfa = preg->buffer;
+ bin_tree_t *tree;
+ switch (token->type)
+ {
+ case CHARACTER:
+ tree = create_token_tree (dfa, NULL, NULL, token);
+ if (__glibc_unlikely (tree == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ {
+ while (!re_string_eoi (regexp)
+ && !re_string_first_byte (regexp, re_string_cur_idx (regexp)))
+ {
+ bin_tree_t *mbc_remain;
+ fetch_token (token, regexp, syntax);
+ mbc_remain = create_token_tree (dfa, NULL, NULL, token);
+ tree = create_tree (dfa, tree, mbc_remain, CONCAT);
+ if (__glibc_unlikely (mbc_remain == NULL || tree == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ }
+ }
+#endif
+ break;
+
+ case OP_OPEN_SUBEXP:
+ tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
+ return NULL;
+ break;
+
+ case OP_OPEN_BRACKET:
+ tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
+ return NULL;
+ break;
+
+ case OP_BACK_REF:
+ if (!__glibc_likely (dfa->completed_bkref_map & (1 << token->opr.idx)))
+ {
+ *err = REG_ESUBREG;
+ return NULL;
+ }
+ dfa->used_bkref_map |= 1 << token->opr.idx;
+ tree = create_token_tree (dfa, NULL, NULL, token);
+ if (__glibc_unlikely (tree == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ ++dfa->nbackref;
+ dfa->has_mb_node = 1;
+ break;
+
+ case OP_OPEN_DUP_NUM:
+ if (syntax & RE_CONTEXT_INVALID_DUP)
+ {
+ *err = REG_BADRPT;
+ return NULL;
+ }
+ FALLTHROUGH;
+ case OP_DUP_ASTERISK:
+ case OP_DUP_PLUS:
+ case OP_DUP_QUESTION:
+ if (syntax & RE_CONTEXT_INVALID_OPS)
+ {
+ *err = REG_BADRPT;
+ return NULL;
+ }
+ else if (syntax & RE_CONTEXT_INDEP_OPS)
+ {
+ fetch_token (token, regexp, syntax);
+ return parse_expression (regexp, preg, token, syntax, nest, err);
+ }
+ FALLTHROUGH;
+ case OP_CLOSE_SUBEXP:
+ if ((token->type == OP_CLOSE_SUBEXP) &&
+ !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
+ {
+ *err = REG_ERPAREN;
+ return NULL;
+ }
+ FALLTHROUGH;
+ case OP_CLOSE_DUP_NUM:
+ /* We treat it as a normal character. */
+
+ /* Then we can these characters as normal characters. */
+ token->type = CHARACTER;
+ /* mb_partial and word_char bits should be initialized already
+ by peek_token. */
+ tree = create_token_tree (dfa, NULL, NULL, token);
+ if (__glibc_unlikely (tree == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ break;
+
+ case ANCHOR:
+ if ((token->opr.ctx_type
+ & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST))
+ && dfa->word_ops_used == 0)
+ init_word_char (dfa);
+ if (token->opr.ctx_type == WORD_DELIM
+ || token->opr.ctx_type == NOT_WORD_DELIM)
+ {
+ bin_tree_t *tree_first, *tree_last;
+ if (token->opr.ctx_type == WORD_DELIM)
+ {
+ token->opr.ctx_type = WORD_FIRST;
+ tree_first = create_token_tree (dfa, NULL, NULL, token);
+ token->opr.ctx_type = WORD_LAST;
+ }
+ else
+ {
+ token->opr.ctx_type = INSIDE_WORD;
+ tree_first = create_token_tree (dfa, NULL, NULL, token);
+ token->opr.ctx_type = INSIDE_NOTWORD;
+ }
+ tree_last = create_token_tree (dfa, NULL, NULL, token);
+ tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
+ if (__glibc_unlikely (tree_first == NULL || tree_last == NULL
+ || tree == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ }
+ else
+ {
+ tree = create_token_tree (dfa, NULL, NULL, token);
+ if (__glibc_unlikely (tree == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ }
+ /* We must return here, since ANCHORs can't be followed
+ by repetition operators.
+ eg. RE"^*" is invalid or "<ANCHOR(^)><CHAR(*)>",
+ it must not be "<ANCHOR(^)><REPEAT(*)>". */
+ fetch_token (token, regexp, syntax);
+ return tree;
+
+ case OP_PERIOD:
+ tree = create_token_tree (dfa, NULL, NULL, token);
+ if (__glibc_unlikely (tree == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ if (dfa->mb_cur_max > 1)
+ dfa->has_mb_node = 1;
+ break;
+
+ case OP_WORD:
+ case OP_NOTWORD:
+ tree = build_charclass_op (dfa, regexp->trans,
+ "alnum",
+ "_",
+ token->type == OP_NOTWORD, err);
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
+ return NULL;
+ break;
+
+ case OP_SPACE:
+ case OP_NOTSPACE:
+ tree = build_charclass_op (dfa, regexp->trans,
+ "space",
+ "",
+ token->type == OP_NOTSPACE, err);
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
+ return NULL;
+ break;
+
+ case OP_ALT:
+ case END_OF_RE:
+ return NULL;
+
+ case BACK_SLASH:
+ *err = REG_EESCAPE;
+ return NULL;
+
+ default:
+ /* Must not happen? */
+#ifdef DEBUG
+ assert (0);
+#endif
+ return NULL;
+ }
+ fetch_token (token, regexp, syntax);
+
+ while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS
+ || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM)
+ {
+ bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token,
+ syntax, err);
+ if (__glibc_unlikely (*err != REG_NOERROR && dup_tree == NULL))
+ {
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
+ return NULL;
+ }
+ tree = dup_tree;
+ /* In BRE consecutive duplications are not allowed. */
+ if ((syntax & RE_CONTEXT_INVALID_DUP)
+ && (token->type == OP_DUP_ASTERISK
+ || token->type == OP_OPEN_DUP_NUM))
+ {
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
+ *err = REG_BADRPT;
+ return NULL;
+ }
+ }
+
+ return tree;
+}
+
+/* This function build the following tree, from regular expression
+ (<reg_exp>):
+ SUBEXP
+ |
+ <reg_exp>
+*/
+
+static bin_tree_t *
+parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
+ reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
+{
+ re_dfa_t *dfa = preg->buffer;
+ bin_tree_t *tree;
+ size_t cur_nsub;
+ cur_nsub = preg->re_nsub++;
+
+ fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+
+ /* The subexpression may be a null string. */
+ if (token->type == OP_CLOSE_SUBEXP)
+ tree = NULL;
+ else
+ {
+ tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
+ if (__glibc_unlikely (*err == REG_NOERROR
+ && token->type != OP_CLOSE_SUBEXP))
+ {
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
+ *err = REG_EPAREN;
+ }
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ return NULL;
+ }
+
+ if (cur_nsub <= '9' - '1')
+ dfa->completed_bkref_map |= 1 << cur_nsub;
+
+ tree = create_tree (dfa, tree, NULL, SUBEXP);
+ if (__glibc_unlikely (tree == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ tree->token.opr.idx = cur_nsub;
+ return tree;
+}
+
+/* This function parse repetition operators like "*", "+", "{1,3}" etc. */
+
+static bin_tree_t *
+parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
+ re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err)
+{
+ bin_tree_t *tree = NULL, *old_tree = NULL;
+ Idx i, start, end, start_idx = re_string_cur_idx (regexp);
+ re_token_t start_token = *token;
+
+ if (token->type == OP_OPEN_DUP_NUM)
+ {
+ end = 0;
+ start = fetch_number (regexp, token, syntax);
+ if (start == -1)
+ {
+ if (token->type == CHARACTER && token->opr.c == ',')
+ start = 0; /* We treat "{,m}" as "{0,m}". */
+ else
+ {
+ *err = REG_BADBR; /* <re>{} is invalid. */
+ return NULL;
+ }
+ }
+ if (__glibc_likely (start != -2))
+ {
+ /* We treat "{n}" as "{n,n}". */
+ end = ((token->type == OP_CLOSE_DUP_NUM) ? start
+ : ((token->type == CHARACTER && token->opr.c == ',')
+ ? fetch_number (regexp, token, syntax) : -2));
+ }
+ if (__glibc_unlikely (start == -2 || end == -2))
+ {
+ /* Invalid sequence. */
+ if (__glibc_unlikely (!(syntax & RE_INVALID_INTERVAL_ORD)))
+ {
+ if (token->type == END_OF_RE)
+ *err = REG_EBRACE;
+ else
+ *err = REG_BADBR;
+
+ return NULL;
+ }
+
+ /* If the syntax bit is set, rollback. */
+ re_string_set_index (regexp, start_idx);
+ *token = start_token;
+ token->type = CHARACTER;
+ /* mb_partial and word_char bits should be already initialized by
+ peek_token. */
+ return elem;
+ }
+
+ if (__glibc_unlikely ((end != -1 && start > end)
+ || token->type != OP_CLOSE_DUP_NUM))
+ {
+ /* First number greater than second. */
+ *err = REG_BADBR;
+ return NULL;
+ }
+
+ if (__glibc_unlikely (RE_DUP_MAX < (end == -1 ? start : end)))
+ {
+ *err = REG_ESIZE;
+ return NULL;
+ }
+ }
+ else
+ {
+ start = (token->type == OP_DUP_PLUS) ? 1 : 0;
+ end = (token->type == OP_DUP_QUESTION) ? 1 : -1;
+ }
+
+ fetch_token (token, regexp, syntax);
+
+ if (__glibc_unlikely (elem == NULL))
+ return NULL;
+ if (__glibc_unlikely (start == 0 && end == 0))
+ {
+ postorder (elem, free_tree, NULL);
+ return NULL;
+ }
+
+ /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */
+ if (__glibc_unlikely (start > 0))
+ {
+ tree = elem;
+ for (i = 2; i <= start; ++i)
+ {
+ elem = duplicate_tree (elem, dfa);
+ tree = create_tree (dfa, tree, elem, CONCAT);
+ if (__glibc_unlikely (elem == NULL || tree == NULL))
+ goto parse_dup_op_espace;
+ }
+
+ if (start == end)
+ return tree;
+
+ /* Duplicate ELEM before it is marked optional. */
+ elem = duplicate_tree (elem, dfa);
+ if (__glibc_unlikely (elem == NULL))
+ goto parse_dup_op_espace;
+ old_tree = tree;
+ }
+ else
+ old_tree = NULL;
+
+ if (elem->token.type == SUBEXP)
+ {
+ uintptr_t subidx = elem->token.opr.idx;
+ postorder (elem, mark_opt_subexp, (void *) subidx);
+ }
+
+ tree = create_tree (dfa, elem, NULL,
+ (end == -1 ? OP_DUP_ASTERISK : OP_ALT));
+ if (__glibc_unlikely (tree == NULL))
+ goto parse_dup_op_espace;
+
+ /* This loop is actually executed only when end != -1,
+ to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have
+ already created the start+1-th copy. */
+ if (TYPE_SIGNED (Idx) || end != -1)
+ for (i = start + 2; i <= end; ++i)
+ {
+ elem = duplicate_tree (elem, dfa);
+ tree = create_tree (dfa, tree, elem, CONCAT);
+ if (__glibc_unlikely (elem == NULL || tree == NULL))
+ goto parse_dup_op_espace;
+
+ tree = create_tree (dfa, tree, NULL, OP_ALT);
+ if (__glibc_unlikely (tree == NULL))
+ goto parse_dup_op_espace;
+ }
+
+ if (old_tree)
+ tree = create_tree (dfa, old_tree, tree, CONCAT);
+
+ return tree;
+
+ parse_dup_op_espace:
+ *err = REG_ESPACE;
+ return NULL;
+}
+
+/* Size of the names for collating symbol/equivalence_class/character_class.
+ I'm not sure, but maybe enough. */
+#define BRACKET_NAME_BUF_SIZE 32
+
+#ifndef _LIBC
+
+# ifdef RE_ENABLE_I18N
+/* Convert the byte B to the corresponding wide character. In a
+ unibyte locale, treat B as itself. In a multibyte locale, return
+ WEOF if B is an encoding error. */
+static wint_t
+parse_byte (unsigned char b, re_charset_t *mbcset)
+{
+ return mbcset == NULL ? b : __btowc (b);
+}
+# endif
+
+ /* Local function for parse_bracket_exp only used in case of NOT _LIBC.
+ Build the range expression which starts from START_ELEM, and ends
+ at END_ELEM. The result are written to MBCSET and SBCSET.
+ RANGE_ALLOC is the allocated size of mbcset->range_starts, and
+ mbcset->range_ends, is a pointer argument since we may
+ update it. */
+
+static reg_errcode_t
+# ifdef RE_ENABLE_I18N
+build_range_exp (const reg_syntax_t syntax,
+ bitset_t sbcset,
+ re_charset_t *mbcset,
+ Idx *range_alloc,
+ const bracket_elem_t *start_elem,
+ const bracket_elem_t *end_elem)
+# else /* not RE_ENABLE_I18N */
+build_range_exp (const reg_syntax_t syntax,
+ bitset_t sbcset,
+ const bracket_elem_t *start_elem,
+ const bracket_elem_t *end_elem)
+# endif /* not RE_ENABLE_I18N */
+{
+ unsigned int start_ch, end_ch;
+ /* Equivalence Classes and Character Classes can't be a range start/end. */
+ if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
+ || start_elem->type == CHAR_CLASS
+ || end_elem->type == EQUIV_CLASS
+ || end_elem->type == CHAR_CLASS))
+ return REG_ERANGE;
+
+ /* We can handle no multi character collating elements without libc
+ support. */
+ if (__glibc_unlikely ((start_elem->type == COLL_SYM
+ && strlen ((char *) start_elem->opr.name) > 1)
+ || (end_elem->type == COLL_SYM
+ && strlen ((char *) end_elem->opr.name) > 1)))
+ return REG_ECOLLATE;
+
+# ifdef RE_ENABLE_I18N
+ {
+ wchar_t wc;
+ wint_t start_wc;
+ wint_t end_wc;
+
+ start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
+ : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
+ : 0));
+ end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch
+ : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
+ : 0));
+ start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM)
+ ? parse_byte (start_ch, mbcset) : start_elem->opr.wch);
+ end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
+ ? parse_byte (end_ch, mbcset) : end_elem->opr.wch);
+ if (start_wc == WEOF || end_wc == WEOF)
+ return REG_ECOLLATE;
+ else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
+ && start_wc > end_wc))
+ return REG_ERANGE;
+
+ /* Got valid collation sequence values, add them as a new entry.
+ However, for !_LIBC we have no collation elements: if the
+ character set is single byte, the single byte character set
+ that we build below suffices. parse_bracket_exp passes
+ no MBCSET if dfa->mb_cur_max == 1. */
+ if (mbcset)
+ {
+ /* Check the space of the arrays. */
+ if (__glibc_unlikely (*range_alloc == mbcset->nranges))
+ {
+ /* There is not enough space, need realloc. */
+ wchar_t *new_array_start, *new_array_end;
+ Idx new_nranges;
+
+ /* +1 in case of mbcset->nranges is 0. */
+ new_nranges = 2 * mbcset->nranges + 1;
+ /* Use realloc since mbcset->range_starts and mbcset->range_ends
+ are NULL if *range_alloc == 0. */
+ new_array_start = re_realloc (mbcset->range_starts, wchar_t,
+ new_nranges);
+ new_array_end = re_realloc (mbcset->range_ends, wchar_t,
+ new_nranges);
+
+ if (__glibc_unlikely (new_array_start == NULL
+ || new_array_end == NULL))
+ {
+ re_free (new_array_start);
+ re_free (new_array_end);
+ return REG_ESPACE;
+ }
+
+ mbcset->range_starts = new_array_start;
+ mbcset->range_ends = new_array_end;
+ *range_alloc = new_nranges;
+ }
+
+ mbcset->range_starts[mbcset->nranges] = start_wc;
+ mbcset->range_ends[mbcset->nranges++] = end_wc;
+ }
+
+ /* Build the table for single byte characters. */
+ for (wc = 0; wc < SBC_MAX; ++wc)
+ {
+ if (start_wc <= wc && wc <= end_wc)
+ bitset_set (sbcset, wc);
+ }
+ }
+# else /* not RE_ENABLE_I18N */
+ {
+ unsigned int ch;
+ start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch
+ : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
+ : 0));
+ end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch
+ : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
+ : 0));
+ if (start_ch > end_ch)
+ return REG_ERANGE;
+ /* Build the table for single byte characters. */
+ for (ch = 0; ch < SBC_MAX; ++ch)
+ if (start_ch <= ch && ch <= end_ch)
+ bitset_set (sbcset, ch);
+ }
+# endif /* not RE_ENABLE_I18N */
+ return REG_NOERROR;
+}
+#endif /* not _LIBC */
+
+#ifndef _LIBC
+/* Helper function for parse_bracket_exp only used in case of NOT _LIBC..
+ Build the collating element which is represented by NAME.
+ The result are written to MBCSET and SBCSET.
+ COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
+ pointer argument since we may update it. */
+
+static reg_errcode_t
+# ifdef RE_ENABLE_I18N
+build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
+ Idx *coll_sym_alloc, const unsigned char *name)
+# else /* not RE_ENABLE_I18N */
+build_collating_symbol (bitset_t sbcset, const unsigned char *name)
+# endif /* not RE_ENABLE_I18N */
+{
+ size_t name_len = strlen ((const char *) name);
+ if (__glibc_unlikely (name_len != 1))
+ return REG_ECOLLATE;
+ else
+ {
+ bitset_set (sbcset, name[0]);
+ return REG_NOERROR;
+ }
+}
+#endif /* not _LIBC */
+
+/* This function parse bracket expression like "[abc]", "[a-c]",
+ "[[.a-a.]]" etc. */
+
+static bin_tree_t *
+parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
+ reg_syntax_t syntax, reg_errcode_t *err)
+{
+#ifdef _LIBC
+ const unsigned char *collseqmb;
+ const char *collseqwc;
+ uint32_t nrules;
+ int32_t table_size;
+ const int32_t *symb_table;
+ const unsigned char *extra;
+
+ /* Local function for parse_bracket_exp used in _LIBC environment.
+ Seek the collating symbol entry corresponding to NAME.
+ Return the index of the symbol in the SYMB_TABLE,
+ or -1 if not found. */
+
+ auto inline int32_t
+ __attribute__ ((always_inline))
+ seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
+ {
+ int32_t elem;
+
+ for (elem = 0; elem < table_size; elem++)
+ if (symb_table[2 * elem] != 0)
+ {
+ int32_t idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ if (/* Compare the length of the name. */
+ name_len == extra[idx]
+ /* Compare the name. */
+ && memcmp (name, &extra[idx + 1], name_len) == 0)
+ /* Yep, this is the entry. */
+ return elem;
+ }
+ return -1;
+ }
+
+ /* Local function for parse_bracket_exp used in _LIBC environment.
+ Look up the collation sequence value of BR_ELEM.
+ Return the value if succeeded, UINT_MAX otherwise. */
+
+ auto inline unsigned int
+ __attribute__ ((always_inline))
+ lookup_collation_sequence_value (bracket_elem_t *br_elem)
+ {
+ if (br_elem->type == SB_CHAR)
+ {
+ /*
+ if (MB_CUR_MAX == 1)
+ */
+ if (nrules == 0)
+ return collseqmb[br_elem->opr.ch];
+ else
+ {
+ wint_t wc = __btowc (br_elem->opr.ch);
+ return __collseq_table_lookup (collseqwc, wc);
+ }
+ }
+ else if (br_elem->type == MB_CHAR)
+ {
+ if (nrules != 0)
+ return __collseq_table_lookup (collseqwc, br_elem->opr.wch);
+ }
+ else if (br_elem->type == COLL_SYM)
+ {
+ size_t sym_name_len = strlen ((char *) br_elem->opr.name);
+ if (nrules != 0)
+ {
+ int32_t elem, idx;
+ elem = seek_collating_symbol_entry (br_elem->opr.name,
+ sym_name_len);
+ if (elem != -1)
+ {
+ /* We found the entry. */
+ idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ /* Skip the byte sequence of the collating element. */
+ idx += 1 + extra[idx];
+ /* Adjust for the alignment. */
+ idx = (idx + 3) & ~3;
+ /* Skip the multibyte collation sequence value. */
+ idx += sizeof (unsigned int);
+ /* Skip the wide char sequence of the collating element. */
+ idx += sizeof (unsigned int) *
+ (1 + *(unsigned int *) (extra + idx));
+ /* Return the collation sequence value. */
+ return *(unsigned int *) (extra + idx);
+ }
+ else if (sym_name_len == 1)
+ {
+ /* No valid character. Match it as a single byte
+ character. */
+ return collseqmb[br_elem->opr.name[0]];
+ }
+ }
+ else if (sym_name_len == 1)
+ return collseqmb[br_elem->opr.name[0]];
+ }
+ return UINT_MAX;
+ }
+
+ /* Local function for parse_bracket_exp used in _LIBC environment.
+ Build the range expression which starts from START_ELEM, and ends
+ at END_ELEM. The result are written to MBCSET and SBCSET.
+ RANGE_ALLOC is the allocated size of mbcset->range_starts, and
+ mbcset->range_ends, is a pointer argument since we may
+ update it. */
+
+ auto inline reg_errcode_t
+ __attribute__ ((always_inline))
+ build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc,
+ bracket_elem_t *start_elem, bracket_elem_t *end_elem)
+ {
+ unsigned int ch;
+ uint32_t start_collseq;
+ uint32_t end_collseq;
+
+ /* Equivalence Classes and Character Classes can't be a range
+ start/end. */
+ if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
+ || start_elem->type == CHAR_CLASS
+ || end_elem->type == EQUIV_CLASS
+ || end_elem->type == CHAR_CLASS))
+ return REG_ERANGE;
+
+ /* FIXME: Implement rational ranges here, too. */
+ start_collseq = lookup_collation_sequence_value (start_elem);
+ end_collseq = lookup_collation_sequence_value (end_elem);
+ /* Check start/end collation sequence values. */
+ if (__glibc_unlikely (start_collseq == UINT_MAX
+ || end_collseq == UINT_MAX))
+ return REG_ECOLLATE;
+ if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
+ && start_collseq > end_collseq))
+ return REG_ERANGE;
+
+ /* Got valid collation sequence values, add them as a new entry.
+ However, if we have no collation elements, and the character set
+ is single byte, the single byte character set that we
+ build below suffices. */
+ if (nrules > 0 || dfa->mb_cur_max > 1)
+ {
+ /* Check the space of the arrays. */
+ if (__glibc_unlikely (*range_alloc == mbcset->nranges))
+ {
+ /* There is not enough space, need realloc. */
+ uint32_t *new_array_start;
+ uint32_t *new_array_end;
+ Idx new_nranges;
+
+ /* +1 in case of mbcset->nranges is 0. */
+ new_nranges = 2 * mbcset->nranges + 1;
+ new_array_start = re_realloc (mbcset->range_starts, uint32_t,
+ new_nranges);
+ new_array_end = re_realloc (mbcset->range_ends, uint32_t,
+ new_nranges);
+
+ if (__glibc_unlikely (new_array_start == NULL
+ || new_array_end == NULL))
+ return REG_ESPACE;
+
+ mbcset->range_starts = new_array_start;
+ mbcset->range_ends = new_array_end;
+ *range_alloc = new_nranges;
+ }
+
+ mbcset->range_starts[mbcset->nranges] = start_collseq;
+ mbcset->range_ends[mbcset->nranges++] = end_collseq;
+ }
+
+ /* Build the table for single byte characters. */
+ for (ch = 0; ch < SBC_MAX; ch++)
+ {
+ uint32_t ch_collseq;
+ /*
+ if (MB_CUR_MAX == 1)
+ */
+ if (nrules == 0)
+ ch_collseq = collseqmb[ch];
+ else
+ ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
+ if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
+ bitset_set (sbcset, ch);
+ }
+ return REG_NOERROR;
+ }
+
+ /* Local function for parse_bracket_exp used in _LIBC environment.
+ Build the collating element which is represented by NAME.
+ The result are written to MBCSET and SBCSET.
+ COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
+ pointer argument since we may update it. */
+
+ auto inline reg_errcode_t
+ __attribute__ ((always_inline))
+ build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
+ Idx *coll_sym_alloc, const unsigned char *name)
+ {
+ int32_t elem, idx;
+ size_t name_len = strlen ((const char *) name);
+ if (nrules != 0)
+ {
+ elem = seek_collating_symbol_entry (name, name_len);
+ if (elem != -1)
+ {
+ /* We found the entry. */
+ idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ }
+ else if (name_len == 1)
+ {
+ /* No valid character, treat it as a normal
+ character. */
+ bitset_set (sbcset, name[0]);
+ return REG_NOERROR;
+ }
+ else
+ return REG_ECOLLATE;
+
+ /* Got valid collation sequence, add it as a new entry. */
+ /* Check the space of the arrays. */
+ if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms))
+ {
+ /* Not enough, realloc it. */
+ /* +1 in case of mbcset->ncoll_syms is 0. */
+ Idx new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
+ /* Use realloc since mbcset->coll_syms is NULL
+ if *alloc == 0. */
+ int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
+ new_coll_sym_alloc);
+ if (__glibc_unlikely (new_coll_syms == NULL))
+ return REG_ESPACE;
+ mbcset->coll_syms = new_coll_syms;
+ *coll_sym_alloc = new_coll_sym_alloc;
+ }
+ mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
+ return REG_NOERROR;
+ }
+ else
+ {
+ if (__glibc_unlikely (name_len != 1))
+ return REG_ECOLLATE;
+ else
+ {
+ bitset_set (sbcset, name[0]);
+ return REG_NOERROR;
+ }
+ }
+ }
+#endif
+
+ re_token_t br_token;
+ re_bitset_ptr_t sbcset;
+#ifdef RE_ENABLE_I18N
+ re_charset_t *mbcset;
+ Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0;
+ Idx equiv_class_alloc = 0, char_class_alloc = 0;
+#endif /* not RE_ENABLE_I18N */
+ bool non_match = false;
+ bin_tree_t *work_tree;
+ int token_len;
+ bool first_round = true;
+#ifdef _LIBC
+ collseqmb = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
+ nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ if (nrules)
+ {
+ /*
+ if (MB_CUR_MAX > 1)
+ */
+ collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
+ table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
+ symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_TABLEMB);
+ extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_EXTRAMB);
+ }
+#endif
+ sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+#ifdef RE_ENABLE_I18N
+ mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+#endif /* RE_ENABLE_I18N */
+#ifdef RE_ENABLE_I18N
+ if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
+#else
+ if (__glibc_unlikely (sbcset == NULL))
+#endif /* RE_ENABLE_I18N */
+ {
+ re_free (sbcset);
+#ifdef RE_ENABLE_I18N
+ re_free (mbcset);
+#endif
+ *err = REG_ESPACE;
+ return NULL;
+ }
+
+ token_len = peek_token_bracket (token, regexp, syntax);
+ if (__glibc_unlikely (token->type == END_OF_RE))
+ {
+ *err = REG_BADPAT;
+ goto parse_bracket_exp_free_return;
+ }
+ if (token->type == OP_NON_MATCH_LIST)
+ {
+#ifdef RE_ENABLE_I18N
+ mbcset->non_match = 1;
+#endif /* not RE_ENABLE_I18N */
+ non_match = true;
+ if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
+ bitset_set (sbcset, '\n');
+ re_string_skip_bytes (regexp, token_len); /* Skip a token. */
+ token_len = peek_token_bracket (token, regexp, syntax);
+ if (__glibc_unlikely (token->type == END_OF_RE))
+ {
+ *err = REG_BADPAT;
+ goto parse_bracket_exp_free_return;
+ }
+ }
+
+ /* We treat the first ']' as a normal character. */
+ if (token->type == OP_CLOSE_BRACKET)
+ token->type = CHARACTER;
+
+ while (1)
+ {
+ bracket_elem_t start_elem, end_elem;
+ unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE];
+ unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE];
+ reg_errcode_t ret;
+ int token_len2 = 0;
+ bool is_range_exp = false;
+ re_token_t token2;
+
+ start_elem.opr.name = start_name_buf;
+ start_elem.type = COLL_SYM;
+ ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
+ syntax, first_round);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ {
+ *err = ret;
+ goto parse_bracket_exp_free_return;
+ }
+ first_round = false;
+
+ /* Get information about the next token. We need it in any case. */
+ token_len = peek_token_bracket (token, regexp, syntax);
+
+ /* Do not check for ranges if we know they are not allowed. */
+ if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS)
+ {
+ if (__glibc_unlikely (token->type == END_OF_RE))
+ {
+ *err = REG_EBRACK;
+ goto parse_bracket_exp_free_return;
+ }
+ if (token->type == OP_CHARSET_RANGE)
+ {
+ re_string_skip_bytes (regexp, token_len); /* Skip '-'. */
+ token_len2 = peek_token_bracket (&token2, regexp, syntax);
+ if (__glibc_unlikely (token2.type == END_OF_RE))
+ {
+ *err = REG_EBRACK;
+ goto parse_bracket_exp_free_return;
+ }
+ if (token2.type == OP_CLOSE_BRACKET)
+ {
+ /* We treat the last '-' as a normal character. */
+ re_string_skip_bytes (regexp, -token_len);
+ token->type = CHARACTER;
+ }
+ else
+ is_range_exp = true;
+ }
+ }
+
+ if (is_range_exp == true)
+ {
+ end_elem.opr.name = end_name_buf;
+ end_elem.type = COLL_SYM;
+ ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
+ dfa, syntax, true);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ {
+ *err = ret;
+ goto parse_bracket_exp_free_return;
+ }
+
+ token_len = peek_token_bracket (token, regexp, syntax);
+
+#ifdef _LIBC
+ *err = build_range_exp (sbcset, mbcset, &range_alloc,
+ &start_elem, &end_elem);
+#else
+# ifdef RE_ENABLE_I18N
+ *err = build_range_exp (syntax, sbcset,
+ dfa->mb_cur_max > 1 ? mbcset : NULL,
+ &range_alloc, &start_elem, &end_elem);
+# else
+ *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem);
+# endif
+#endif /* RE_ENABLE_I18N */
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ goto parse_bracket_exp_free_return;
+ }
+ else
+ {
+ switch (start_elem.type)
+ {
+ case SB_CHAR:
+ bitset_set (sbcset, start_elem.opr.ch);
+ break;
+#ifdef RE_ENABLE_I18N
+ case MB_CHAR:
+ /* Check whether the array has enough space. */
+ if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars))
+ {
+ wchar_t *new_mbchars;
+ /* Not enough, realloc it. */
+ /* +1 in case of mbcset->nmbchars is 0. */
+ mbchar_alloc = 2 * mbcset->nmbchars + 1;
+ /* Use realloc since array is NULL if *alloc == 0. */
+ new_mbchars = re_realloc (mbcset->mbchars, wchar_t,
+ mbchar_alloc);
+ if (__glibc_unlikely (new_mbchars == NULL))
+ goto parse_bracket_exp_espace;
+ mbcset->mbchars = new_mbchars;
+ }
+ mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch;
+ break;
+#endif /* RE_ENABLE_I18N */
+ case EQUIV_CLASS:
+ *err = build_equiv_class (sbcset,
+#ifdef RE_ENABLE_I18N
+ mbcset, &equiv_class_alloc,
+#endif /* RE_ENABLE_I18N */
+ start_elem.opr.name);
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ goto parse_bracket_exp_free_return;
+ break;
+ case COLL_SYM:
+ *err = build_collating_symbol (sbcset,
+#ifdef RE_ENABLE_I18N
+ mbcset, &coll_sym_alloc,
+#endif /* RE_ENABLE_I18N */
+ start_elem.opr.name);
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ goto parse_bracket_exp_free_return;
+ break;
+ case CHAR_CLASS:
+ *err = build_charclass (regexp->trans, sbcset,
+#ifdef RE_ENABLE_I18N
+ mbcset, &char_class_alloc,
+#endif /* RE_ENABLE_I18N */
+ (const char *) start_elem.opr.name,
+ syntax);
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ goto parse_bracket_exp_free_return;
+ break;
+ default:
+ assert (0);
+ break;
+ }
+ }
+ if (__glibc_unlikely (token->type == END_OF_RE))
+ {
+ *err = REG_EBRACK;
+ goto parse_bracket_exp_free_return;
+ }
+ if (token->type == OP_CLOSE_BRACKET)
+ break;
+ }
+
+ re_string_skip_bytes (regexp, token_len); /* Skip a token. */
+
+ /* If it is non-matching list. */
+ if (non_match)
+ bitset_not (sbcset);
+
+#ifdef RE_ENABLE_I18N
+ /* Ensure only single byte characters are set. */
+ if (dfa->mb_cur_max > 1)
+ bitset_mask (sbcset, dfa->sb_char);
+
+ if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes
+ || mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes
+ || mbcset->non_match)))
+ {
+ bin_tree_t *mbc_tree;
+ int sbc_idx;
+ /* Build a tree for complex bracket. */
+ dfa->has_mb_node = 1;
+ br_token.type = COMPLEX_BRACKET;
+ br_token.opr.mbcset = mbcset;
+ mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+ if (__glibc_unlikely (mbc_tree == NULL))
+ goto parse_bracket_exp_espace;
+ for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx)
+ if (sbcset[sbc_idx])
+ break;
+ /* If there are no bits set in sbcset, there is no point
+ of having both SIMPLE_BRACKET and COMPLEX_BRACKET. */
+ if (sbc_idx < BITSET_WORDS)
+ {
+ /* Build a tree for simple bracket. */
+ br_token.type = SIMPLE_BRACKET;
+ br_token.opr.sbcset = sbcset;
+ work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+ if (__glibc_unlikely (work_tree == NULL))
+ goto parse_bracket_exp_espace;
+
+ /* Then join them by ALT node. */
+ work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT);
+ if (__glibc_unlikely (work_tree == NULL))
+ goto parse_bracket_exp_espace;
+ }
+ else
+ {
+ re_free (sbcset);
+ work_tree = mbc_tree;
+ }
+ }
+ else
+#endif /* not RE_ENABLE_I18N */
+ {
+#ifdef RE_ENABLE_I18N
+ free_charset (mbcset);
+#endif
+ /* Build a tree for simple bracket. */
+ br_token.type = SIMPLE_BRACKET;
+ br_token.opr.sbcset = sbcset;
+ work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+ if (__glibc_unlikely (work_tree == NULL))
+ goto parse_bracket_exp_espace;
+ }
+ return work_tree;
+
+ parse_bracket_exp_espace:
+ *err = REG_ESPACE;
+ parse_bracket_exp_free_return:
+ re_free (sbcset);
+#ifdef RE_ENABLE_I18N
+ free_charset (mbcset);
+#endif /* RE_ENABLE_I18N */
+ return NULL;
+}
+
+/* Parse an element in the bracket expression. */
+
+static reg_errcode_t
+parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
+ re_token_t *token, int token_len, re_dfa_t *dfa,
+ reg_syntax_t syntax, bool accept_hyphen)
+{
+#ifdef RE_ENABLE_I18N
+ int cur_char_size;
+ cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp));
+ if (cur_char_size > 1)
+ {
+ elem->type = MB_CHAR;
+ elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp));
+ re_string_skip_bytes (regexp, cur_char_size);
+ return REG_NOERROR;
+ }
+#endif /* RE_ENABLE_I18N */
+ re_string_skip_bytes (regexp, token_len); /* Skip a token. */
+ if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
+ || token->type == OP_OPEN_EQUIV_CLASS)
+ return parse_bracket_symbol (elem, regexp, token);
+ if (__glibc_unlikely (token->type == OP_CHARSET_RANGE) && !accept_hyphen)
+ {
+ /* A '-' must only appear as anything but a range indicator before
+ the closing bracket. Everything else is an error. */
+ re_token_t token2;
+ (void) peek_token_bracket (&token2, regexp, syntax);
+ if (token2.type != OP_CLOSE_BRACKET)
+ /* The actual error value is not standardized since this whole
+ case is undefined. But ERANGE makes good sense. */
+ return REG_ERANGE;
+ }
+ elem->type = SB_CHAR;
+ elem->opr.ch = token->opr.c;
+ return REG_NOERROR;
+}
+
+/* Parse a bracket symbol in the bracket expression. Bracket symbols are
+ such as [:<character_class>:], [.<collating_element>.], and
+ [=<equivalent_class>=]. */
+
+static reg_errcode_t
+parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
+ re_token_t *token)
+{
+ unsigned char ch, delim = token->opr.c;
+ int i = 0;
+ if (re_string_eoi(regexp))
+ return REG_EBRACK;
+ for (;; ++i)
+ {
+ if (i >= BRACKET_NAME_BUF_SIZE)
+ return REG_EBRACK;
+ if (token->type == OP_OPEN_CHAR_CLASS)
+ ch = re_string_fetch_byte_case (regexp);
+ else
+ ch = re_string_fetch_byte (regexp);
+ if (re_string_eoi(regexp))
+ return REG_EBRACK;
+ if (ch == delim && re_string_peek_byte (regexp, 0) == ']')
+ break;
+ elem->opr.name[i] = ch;
+ }
+ re_string_skip_bytes (regexp, 1);
+ elem->opr.name[i] = '\0';
+ switch (token->type)
+ {
+ case OP_OPEN_COLL_ELEM:
+ elem->type = COLL_SYM;
+ break;
+ case OP_OPEN_EQUIV_CLASS:
+ elem->type = EQUIV_CLASS;
+ break;
+ case OP_OPEN_CHAR_CLASS:
+ elem->type = CHAR_CLASS;
+ break;
+ default:
+ break;
+ }
+ return REG_NOERROR;
+}
+
+ /* Helper function for parse_bracket_exp.
+ Build the equivalence class which is represented by NAME.
+ The result are written to MBCSET and SBCSET.
+ EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes,
+ is a pointer argument since we may update it. */
+
+static reg_errcode_t
+#ifdef RE_ENABLE_I18N
+build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
+ Idx *equiv_class_alloc, const unsigned char *name)
+#else /* not RE_ENABLE_I18N */
+build_equiv_class (bitset_t sbcset, const unsigned char *name)
+#endif /* not RE_ENABLE_I18N */
+{
+#ifdef _LIBC
+ uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ if (nrules != 0)
+ {
+ const int32_t *table, *indirect;
+ const unsigned char *weights, *extra, *cp;
+ unsigned char char_buf[2];
+ int32_t idx1, idx2;
+ unsigned int ch;
+ size_t len;
+ /* Calculate the index for equivalence class. */
+ cp = name;
+ table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+ weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_WEIGHTMB);
+ extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_EXTRAMB);
+ indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_INDIRECTMB);
+ idx1 = findidx (table, indirect, extra, &cp, -1);
+ if (__glibc_unlikely (idx1 == 0 || *cp != '\0'))
+ /* This isn't a valid character. */
+ return REG_ECOLLATE;
+
+ /* Build single byte matching table for this equivalence class. */
+ len = weights[idx1 & 0xffffff];
+ for (ch = 0; ch < SBC_MAX; ++ch)
+ {
+ char_buf[0] = ch;
+ cp = char_buf;
+ idx2 = findidx (table, indirect, extra, &cp, 1);
+/*
+ idx2 = table[ch];
+*/
+ if (idx2 == 0)
+ /* This isn't a valid character. */
+ continue;
+ /* Compare only if the length matches and the collation rule
+ index is the same. */
+ if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24)
+ && memcmp (weights + (idx1 & 0xffffff) + 1,
+ weights + (idx2 & 0xffffff) + 1, len) == 0)
+ bitset_set (sbcset, ch);
+ }
+ /* Check whether the array has enough space. */
+ if (__glibc_unlikely (*equiv_class_alloc == mbcset->nequiv_classes))
+ {
+ /* Not enough, realloc it. */
+ /* +1 in case of mbcset->nequiv_classes is 0. */
+ Idx new_equiv_class_alloc = 2 * mbcset->nequiv_classes + 1;
+ /* Use realloc since the array is NULL if *alloc == 0. */
+ int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes,
+ int32_t,
+ new_equiv_class_alloc);
+ if (__glibc_unlikely (new_equiv_classes == NULL))
+ return REG_ESPACE;
+ mbcset->equiv_classes = new_equiv_classes;
+ *equiv_class_alloc = new_equiv_class_alloc;
+ }
+ mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1;
+ }
+ else
+#endif /* _LIBC */
+ {
+ if (__glibc_unlikely (strlen ((const char *) name) != 1))
+ return REG_ECOLLATE;
+ bitset_set (sbcset, *name);
+ }
+ return REG_NOERROR;
+}
+
+ /* Helper function for parse_bracket_exp.
+ Build the character class which is represented by NAME.
+ The result are written to MBCSET and SBCSET.
+ CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes,
+ is a pointer argument since we may update it. */
+
+static reg_errcode_t
+#ifdef RE_ENABLE_I18N
+build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+ re_charset_t *mbcset, Idx *char_class_alloc,
+ const char *class_name, reg_syntax_t syntax)
+#else /* not RE_ENABLE_I18N */
+build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+ const char *class_name, reg_syntax_t syntax)
+#endif /* not RE_ENABLE_I18N */
+{
+ int i;
+ const char *name = class_name;
+
+ /* In case of REG_ICASE "upper" and "lower" match the both of
+ upper and lower cases. */
+ if ((syntax & RE_ICASE)
+ && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
+ name = "alpha";
+
+#ifdef RE_ENABLE_I18N
+ /* Check the space of the arrays. */
+ if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes))
+ {
+ /* Not enough, realloc it. */
+ /* +1 in case of mbcset->nchar_classes is 0. */
+ Idx new_char_class_alloc = 2 * mbcset->nchar_classes + 1;
+ /* Use realloc since array is NULL if *alloc == 0. */
+ wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t,
+ new_char_class_alloc);
+ if (__glibc_unlikely (new_char_classes == NULL))
+ return REG_ESPACE;
+ mbcset->char_classes = new_char_classes;
+ *char_class_alloc = new_char_class_alloc;
+ }
+ mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name);
+#endif /* RE_ENABLE_I18N */
+
+#define BUILD_CHARCLASS_LOOP(ctype_func) \
+ do { \
+ if (__glibc_unlikely (trans != NULL)) \
+ { \
+ for (i = 0; i < SBC_MAX; ++i) \
+ if (ctype_func (i)) \
+ bitset_set (sbcset, trans[i]); \
+ } \
+ else \
+ { \
+ for (i = 0; i < SBC_MAX; ++i) \
+ if (ctype_func (i)) \
+ bitset_set (sbcset, i); \
+ } \
+ } while (0)
+
+ if (strcmp (name, "alnum") == 0)
+ BUILD_CHARCLASS_LOOP (isalnum);
+ else if (strcmp (name, "cntrl") == 0)
+ BUILD_CHARCLASS_LOOP (iscntrl);
+ else if (strcmp (name, "lower") == 0)
+ BUILD_CHARCLASS_LOOP (islower);
+ else if (strcmp (name, "space") == 0)
+ BUILD_CHARCLASS_LOOP (isspace);
+ else if (strcmp (name, "alpha") == 0)
+ BUILD_CHARCLASS_LOOP (isalpha);
+ else if (strcmp (name, "digit") == 0)
+ BUILD_CHARCLASS_LOOP (isdigit);
+ else if (strcmp (name, "print") == 0)
+ BUILD_CHARCLASS_LOOP (isprint);
+ else if (strcmp (name, "upper") == 0)
+ BUILD_CHARCLASS_LOOP (isupper);
+ else if (strcmp (name, "blank") == 0)
+ BUILD_CHARCLASS_LOOP (isblank);
+ else if (strcmp (name, "graph") == 0)
+ BUILD_CHARCLASS_LOOP (isgraph);
+ else if (strcmp (name, "punct") == 0)
+ BUILD_CHARCLASS_LOOP (ispunct);
+ else if (strcmp (name, "xdigit") == 0)
+ BUILD_CHARCLASS_LOOP (isxdigit);
+ else
+ return REG_ECTYPE;
+
+ return REG_NOERROR;
+}
+
+static bin_tree_t *
+build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
+ const char *class_name,
+ const char *extra, bool non_match,
+ reg_errcode_t *err)
+{
+ re_bitset_ptr_t sbcset;
+#ifdef RE_ENABLE_I18N
+ re_charset_t *mbcset;
+ Idx alloc = 0;
+#endif /* not RE_ENABLE_I18N */
+ reg_errcode_t ret;
+ re_token_t br_token = {0};
+ bin_tree_t *tree;
+
+ sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+ if (__glibc_unlikely (sbcset == NULL))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+#ifdef RE_ENABLE_I18N
+ mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+ if (__glibc_unlikely (mbcset == NULL))
+ {
+ re_free (sbcset);
+ *err = REG_ESPACE;
+ return NULL;
+ }
+ mbcset->non_match = non_match;
+#endif /* RE_ENABLE_I18N */
+
+ /* We don't care the syntax in this case. */
+ ret = build_charclass (trans, sbcset,
+#ifdef RE_ENABLE_I18N
+ mbcset, &alloc,
+#endif /* RE_ENABLE_I18N */
+ class_name, 0);
+
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ {
+ re_free (sbcset);
+#ifdef RE_ENABLE_I18N
+ free_charset (mbcset);
+#endif /* RE_ENABLE_I18N */
+ *err = ret;
+ return NULL;
+ }
+ /* \w match '_' also. */
+ for (; *extra; extra++)
+ bitset_set (sbcset, *extra);
+
+ /* If it is non-matching list. */
+ if (non_match)
+ bitset_not (sbcset);
+
+#ifdef RE_ENABLE_I18N
+ /* Ensure only single byte characters are set. */
+ if (dfa->mb_cur_max > 1)
+ bitset_mask (sbcset, dfa->sb_char);
+#endif
+
+ /* Build a tree for simple bracket. */
+#if defined GCC_LINT || defined lint
+ memset (&br_token, 0, sizeof br_token);
+#endif
+ br_token.type = SIMPLE_BRACKET;
+ br_token.opr.sbcset = sbcset;
+ tree = create_token_tree (dfa, NULL, NULL, &br_token);
+ if (__glibc_unlikely (tree == NULL))
+ goto build_word_op_espace;
+
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ {
+ bin_tree_t *mbc_tree;
+ /* Build a tree for complex bracket. */
+ br_token.type = COMPLEX_BRACKET;
+ br_token.opr.mbcset = mbcset;
+ dfa->has_mb_node = 1;
+ mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+ if (__glibc_unlikely (mbc_tree == NULL))
+ goto build_word_op_espace;
+ /* Then join them by ALT node. */
+ tree = create_tree (dfa, tree, mbc_tree, OP_ALT);
+ if (__glibc_likely (mbc_tree != NULL))
+ return tree;
+ }
+ else
+ {
+ free_charset (mbcset);
+ return tree;
+ }
+#else /* not RE_ENABLE_I18N */
+ return tree;
+#endif /* not RE_ENABLE_I18N */
+
+ build_word_op_espace:
+ re_free (sbcset);
+#ifdef RE_ENABLE_I18N
+ free_charset (mbcset);
+#endif /* RE_ENABLE_I18N */
+ *err = REG_ESPACE;
+ return NULL;
+}
+
+/* This is intended for the expressions like "a{1,3}".
+ Fetch a number from 'input', and return the number.
+ Return -1 if the number field is empty like "{,1}".
+ Return RE_DUP_MAX + 1 if the number field is too large.
+ Return -2 if an error occurred. */
+
+static Idx
+fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
+{
+ Idx num = -1;
+ unsigned char c;
+ while (1)
+ {
+ fetch_token (token, input, syntax);
+ c = token->opr.c;
+ if (__glibc_unlikely (token->type == END_OF_RE))
+ return -2;
+ if (token->type == OP_CLOSE_DUP_NUM || c == ',')
+ break;
+ num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2)
+ ? -2
+ : num == -1
+ ? c - '0'
+ : MIN (RE_DUP_MAX + 1, num * 10 + c - '0'));
+ }
+ return num;
+}
+
+#ifdef RE_ENABLE_I18N
+static void
+free_charset (re_charset_t *cset)
+{
+ re_free (cset->mbchars);
+# ifdef _LIBC
+ re_free (cset->coll_syms);
+ re_free (cset->equiv_classes);
+# endif
+ re_free (cset->range_starts);
+ re_free (cset->range_ends);
+ re_free (cset->char_classes);
+ re_free (cset);
+}
+#endif /* RE_ENABLE_I18N */
+
+/* Functions for binary tree operation. */
+
+/* Create a tree node. */
+
+static bin_tree_t *
+create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
+ re_token_type_t type)
+{
+ re_token_t t = { .type = type };
+ return create_token_tree (dfa, left, right, &t);
+}
+
+static bin_tree_t *
+create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
+ const re_token_t *token)
+{
+ bin_tree_t *tree;
+ if (__glibc_unlikely (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE))
+ {
+ bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1);
+
+ if (storage == NULL)
+ return NULL;
+ storage->next = dfa->str_tree_storage;
+ dfa->str_tree_storage = storage;
+ dfa->str_tree_storage_idx = 0;
+ }
+ tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++];
+
+ tree->parent = NULL;
+ tree->left = left;
+ tree->right = right;
+ tree->token = *token;
+ tree->token.duplicated = 0;
+ tree->token.opt_subexp = 0;
+ tree->first = NULL;
+ tree->next = NULL;
+ tree->node_idx = -1;
+
+ if (left != NULL)
+ left->parent = tree;
+ if (right != NULL)
+ right->parent = tree;
+ return tree;
+}
+
+/* Mark the tree SRC as an optional subexpression.
+ To be called from preorder or postorder. */
+
+static reg_errcode_t
+mark_opt_subexp (void *extra, bin_tree_t *node)
+{
+ Idx idx = (uintptr_t) extra;
+ if (node->token.type == SUBEXP && node->token.opr.idx == idx)
+ node->token.opt_subexp = 1;
+
+ return REG_NOERROR;
+}
+
+/* Free the allocated memory inside NODE. */
+
+static void
+free_token (re_token_t *node)
+{
+#ifdef RE_ENABLE_I18N
+ if (node->type == COMPLEX_BRACKET && node->duplicated == 0)
+ free_charset (node->opr.mbcset);
+ else
+#endif /* RE_ENABLE_I18N */
+ if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
+ re_free (node->opr.sbcset);
+}
+
+/* Worker function for tree walking. Free the allocated memory inside NODE
+ and its children. */
+
+static reg_errcode_t
+free_tree (void *extra, bin_tree_t *node)
+{
+ free_token (&node->token);
+ return REG_NOERROR;
+}
+
+
+/* Duplicate the node SRC, and return new node. This is a preorder
+ visit similar to the one implemented by the generic visitor, but
+ we need more infrastructure to maintain two parallel trees --- so,
+ it's easier to duplicate. */
+
+static bin_tree_t *
+duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa)
+{
+ const bin_tree_t *node;
+ bin_tree_t *dup_root;
+ bin_tree_t **p_new = &dup_root, *dup_node = root->parent;
+
+ for (node = root; ; )
+ {
+ /* Create a new tree and link it back to the current parent. */
+ *p_new = create_token_tree (dfa, NULL, NULL, &node->token);
+ if (*p_new == NULL)
+ return NULL;
+ (*p_new)->parent = dup_node;
+ (*p_new)->token.duplicated = 1;
+ dup_node = *p_new;
+
+ /* Go to the left node, or up and to the right. */
+ if (node->left)
+ {
+ node = node->left;
+ p_new = &dup_node->left;
+ }
+ else
+ {
+ const bin_tree_t *prev = NULL;
+ while (node->right == prev || node->right == NULL)
+ {
+ prev = node;
+ node = node->parent;
+ dup_node = dup_node->parent;
+ if (!node)
+ return dup_root;
+ }
+ node = node->right;
+ p_new = &dup_node->right;
+ }
+ }
+}
diff --git a/grub-core/lib/gnulib/regex.c b/grub-core/lib/gnulib/regex.c
new file mode 100644
index 0000000..eab7a48
--- /dev/null
+++ b/grub-core/lib/gnulib/regex.c
@@ -0,0 +1,81 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 2002-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _LIBC
+# include <libc-config.h>
+
+# if __GNUC_PREREQ (4, 6)
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
+# endif
+# if __GNUC_PREREQ (4, 3)
+# pragma GCC diagnostic ignored "-Wold-style-definition"
+# pragma GCC diagnostic ignored "-Wtype-limits"
+# endif
+#endif
+
+/* Make sure no one compiles this code with a C++ compiler. */
+#if defined __cplusplus && defined _LIBC
+# error "This is C code, use a C compiler"
+#endif
+
+#ifdef _LIBC
+/* We have to keep the namespace clean. */
+# define regfree(preg) __regfree (preg)
+# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
+# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
+# define regerror(errcode, preg, errbuf, errbuf_size) \
+ __regerror(errcode, preg, errbuf, errbuf_size)
+# define re_set_registers(bu, re, nu, st, en) \
+ __re_set_registers (bu, re, nu, st, en)
+# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
+ __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
+# define re_match(bufp, string, size, pos, regs) \
+ __re_match (bufp, string, size, pos, regs)
+# define re_search(bufp, string, size, startpos, range, regs) \
+ __re_search (bufp, string, size, startpos, range, regs)
+# define re_compile_pattern(pattern, length, bufp) \
+ __re_compile_pattern (pattern, length, bufp)
+# define re_set_syntax(syntax) __re_set_syntax (syntax)
+# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
+ __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
+# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
+
+# include "../locale/localeinfo.h"
+#endif
+
+/* On some systems, limits.h sets RE_DUP_MAX to a lower value than
+ GNU regex allows. Include it before <regex.h>, which correctly
+ #undefs RE_DUP_MAX and sets it to the right value. */
+#include <limits.h>
+
+#include <regex.h>
+#include "regex_internal.h"
+
+#include "regex_internal.c"
+#include "regcomp.c"
+#include "regexec.c"
+
+/* Binary backward compatibility. */
+#if _LIBC
+# include <shlib-compat.h>
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
+link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
+int re_max_failures = 2000;
+# endif
+#endif
diff --git a/grub-core/lib/gnulib/regex.h b/grub-core/lib/gnulib/regex.h
new file mode 100644
index 0000000..77ac1a5
--- /dev/null
+++ b/grub-core/lib/gnulib/regex.h
@@ -0,0 +1,658 @@
+/* Definitions for data structures and routines for the regular
+ expression library.
+ Copyright (C) 1985, 1989-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _REGEX_H
+#define _REGEX_H 1
+
+#include <sys/types.h>
+
+/* Allow the use in C++ code. */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Define __USE_GNU to declare GNU extensions that violate the
+ POSIX name space rules. */
+#ifdef _GNU_SOURCE
+# define __USE_GNU 1
+#endif
+
+#ifdef _REGEX_LARGE_OFFSETS
+
+/* Use types and values that are wide enough to represent signed and
+ unsigned byte offsets in memory. This currently works only when
+ the regex code is used outside of the GNU C library; it is not yet
+ supported within glibc itself, and glibc users should not define
+ _REGEX_LARGE_OFFSETS. */
+
+/* The type of object sizes. */
+typedef size_t __re_size_t;
+
+/* The type of object sizes, in places where the traditional code
+ uses unsigned long int. */
+typedef size_t __re_long_size_t;
+
+#else
+
+/* The traditional GNU regex implementation mishandles strings longer
+ than INT_MAX. */
+typedef unsigned int __re_size_t;
+typedef unsigned long int __re_long_size_t;
+
+#endif
+
+/* The following two types have to be signed and unsigned integer type
+ wide enough to hold a value of a pointer. For most ANSI compilers
+ ptrdiff_t and size_t should be likely OK. Still size of these two
+ types is 2 for Microsoft C. Ugh... */
+typedef long int s_reg_t;
+typedef unsigned long int active_reg_t;
+
+/* The following bits are used to determine the regexp syntax we
+ recognize. The set/not-set meanings are chosen so that Emacs syntax
+ remains the value 0. The bits are given in alphabetical order, and
+ the definitions shifted by one from the previous bit; thus, when we
+ add or remove a bit, only one other definition need change. */
+typedef unsigned long int reg_syntax_t;
+
+#ifdef __USE_GNU
+/* If this bit is not set, then \ inside a bracket expression is literal.
+ If set, then such a \ quotes the following character. */
+# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
+
+/* If this bit is not set, then + and ? are operators, and \+ and \? are
+ literals.
+ If set, then \+ and \? are operators and + and ? are literals. */
+# define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
+
+/* If this bit is set, then character classes are supported. They are:
+ [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
+ [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
+ If not set, then character classes are not supported. */
+# define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
+
+/* If this bit is set, then ^ and $ are always anchors (outside bracket
+ expressions, of course).
+ If this bit is not set, then it depends:
+ ^ is an anchor if it is at the beginning of a regular
+ expression or after an open-group or an alternation operator;
+ $ is an anchor if it is at the end of a regular expression, or
+ before a close-group or an alternation operator.
+
+ This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
+ POSIX draft 11.2 says that * etc. in leading positions is undefined.
+ We already implemented a previous draft which made those constructs
+ invalid, though, so we haven't changed the code back. */
+# define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
+
+/* If this bit is set, then special characters are always special
+ regardless of where they are in the pattern.
+ If this bit is not set, then special characters are special only in
+ some contexts; otherwise they are ordinary. Specifically,
+ * + ? and intervals are only special when not after the beginning,
+ open-group, or alternation operator. */
+# define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
+
+/* If this bit is set, then *, +, ?, and { cannot be first in an re or
+ immediately after an alternation or begin-group operator. */
+# define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
+
+/* If this bit is set, then . matches newline.
+ If not set, then it doesn't. */
+# define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
+
+/* If this bit is set, then . doesn't match NUL.
+ If not set, then it does. */
+# define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
+
+/* If this bit is set, nonmatching lists [^...] do not match newline.
+ If not set, they do. */
+# define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
+
+/* If this bit is set, either \{...\} or {...} defines an
+ interval, depending on RE_NO_BK_BRACES.
+ If not set, \{, \}, {, and } are literals. */
+# define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
+
+/* If this bit is set, +, ? and | aren't recognized as operators.
+ If not set, they are. */
+# define RE_LIMITED_OPS (RE_INTERVALS << 1)
+
+/* If this bit is set, newline is an alternation operator.
+ If not set, newline is literal. */
+# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
+
+/* If this bit is set, then '{...}' defines an interval, and \{ and \}
+ are literals.
+ If not set, then '\{...\}' defines an interval. */
+# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
+
+/* If this bit is set, (...) defines a group, and \( and \) are literals.
+ If not set, \(...\) defines a group, and ( and ) are literals. */
+# define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
+
+/* If this bit is set, then \<digit> matches <digit>.
+ If not set, then \<digit> is a back-reference. */
+# define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
+
+/* If this bit is set, then | is an alternation operator, and \| is literal.
+ If not set, then \| is an alternation operator, and | is literal. */
+# define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
+
+/* If this bit is set, then an ending range point collating higher
+ than the starting range point, as in [z-a], is invalid.
+ If not set, then when ending range point collates higher than the
+ starting range point, the range is ignored. */
+# define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
+
+/* If this bit is set, then an unmatched ) is ordinary.
+ If not set, then an unmatched ) is invalid. */
+# define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
+
+/* If this bit is set, succeed as soon as we match the whole pattern,
+ without further backtracking. */
+# define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
+
+/* If this bit is set, do not process the GNU regex operators.
+ If not set, then the GNU regex operators are recognized. */
+# define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
+
+/* If this bit is set, turn on internal regex debugging.
+ If not set, and debugging was on, turn it off.
+ This only works if regex.c is compiled -DDEBUG.
+ We define this bit always, so that all that's needed to turn on
+ debugging is to recompile regex.c; the calling code can always have
+ this bit set, and it won't affect anything in the normal case. */
+# define RE_DEBUG (RE_NO_GNU_OPS << 1)
+
+/* If this bit is set, a syntactically invalid interval is treated as
+ a string of ordinary characters. For example, the ERE 'a{1' is
+ treated as 'a\{1'. */
+# define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
+
+/* If this bit is set, then ignore case when matching.
+ If not set, then case is significant. */
+# define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
+
+/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
+ for ^, because it is difficult to scan the regex backwards to find
+ whether ^ should be special. */
+# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
+
+/* If this bit is set, then \{ cannot be first in a regex or
+ immediately after an alternation, open-group or \} operator. */
+# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
+
+/* If this bit is set, then no_sub will be set to 1 during
+ re_compile_pattern. */
+# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
+#endif
+
+/* This global variable defines the particular regexp syntax to use (for
+ some interfaces). When a regexp is compiled, the syntax used is
+ stored in the pattern buffer, so changing this does not affect
+ already-compiled regexps. */
+extern reg_syntax_t re_syntax_options;
+
+#ifdef __USE_GNU
+/* Define combinations of the above bits for the standard possibilities.
+ (The [[[ comments delimit what gets put into the Texinfo file, so
+ don't delete them!) */
+/* [[[begin syntaxes]]] */
+# define RE_SYNTAX_EMACS 0
+
+# define RE_SYNTAX_AWK \
+ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
+ | RE_NO_BK_PARENS | RE_NO_BK_REFS \
+ | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
+ | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CHAR_CLASSES \
+ | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
+
+# define RE_SYNTAX_GNU_AWK \
+ ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
+ | RE_INVALID_INTERVAL_ORD) \
+ & ~(RE_DOT_NOT_NULL | RE_CONTEXT_INDEP_OPS \
+ | RE_CONTEXT_INVALID_OPS ))
+
+# define RE_SYNTAX_POSIX_AWK \
+ (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
+ | RE_INTERVALS | RE_NO_GNU_OPS \
+ | RE_INVALID_INTERVAL_ORD)
+
+# define RE_SYNTAX_GREP \
+ ((RE_SYNTAX_POSIX_BASIC | RE_NEWLINE_ALT) \
+ & ~(RE_CONTEXT_INVALID_DUP | RE_DOT_NOT_NULL))
+
+# define RE_SYNTAX_EGREP \
+ ((RE_SYNTAX_POSIX_EXTENDED | RE_INVALID_INTERVAL_ORD | RE_NEWLINE_ALT) \
+ & ~(RE_CONTEXT_INVALID_OPS | RE_DOT_NOT_NULL))
+
+/* POSIX grep -E behavior is no longer incompatible with GNU. */
+# define RE_SYNTAX_POSIX_EGREP \
+ RE_SYNTAX_EGREP
+
+/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
+# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
+
+# define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
+
+/* Syntax bits common to both basic and extended POSIX regex syntax. */
+# define _RE_SYNTAX_POSIX_COMMON \
+ (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
+ | RE_INTERVALS | RE_NO_EMPTY_RANGES)
+
+# define RE_SYNTAX_POSIX_BASIC \
+ (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP)
+
+/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
+ RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
+ isn't minimal, since other operators, such as \`, aren't disabled. */
+# define RE_SYNTAX_POSIX_MINIMAL_BASIC \
+ (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
+
+# define RE_SYNTAX_POSIX_EXTENDED \
+ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
+ | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
+ | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
+
+/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
+ removed and RE_NO_BK_REFS is added. */
+# define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
+ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
+ | RE_NO_BK_PARENS | RE_NO_BK_REFS \
+ | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
+/* [[[end syntaxes]]] */
+
+/* Maximum number of duplicates an interval can allow. POSIX-conforming
+ systems might define this in <limits.h>, but we want our
+ value, so remove any previous define. */
+# ifdef _REGEX_INCLUDE_LIMITS_H
+# include <limits.h>
+# endif
+# ifdef RE_DUP_MAX
+# undef RE_DUP_MAX
+# endif
+
+/* RE_DUP_MAX is 2**15 - 1 because an earlier implementation stored
+ the counter as a 2-byte signed integer. This is no longer true, so
+ RE_DUP_MAX could be increased to (INT_MAX / 10 - 1), or to
+ ((SIZE_MAX - 9) / 10) if _REGEX_LARGE_OFFSETS is defined.
+ However, there would be a huge performance problem if someone
+ actually used a pattern like a\{214748363\}, so RE_DUP_MAX retains
+ its historical value. */
+# define RE_DUP_MAX (0x7fff)
+#endif
+
+
+/* POSIX 'cflags' bits (i.e., information for 'regcomp'). */
+
+/* If this bit is set, then use extended regular expression syntax.
+ If not set, then use basic regular expression syntax. */
+#define REG_EXTENDED 1
+
+/* If this bit is set, then ignore case when matching.
+ If not set, then case is significant. */
+#define REG_ICASE (1 << 1)
+
+/* If this bit is set, then anchors do not match at newline
+ characters in the string.
+ If not set, then anchors do match at newlines. */
+#define REG_NEWLINE (1 << 2)
+
+/* If this bit is set, then report only success or fail in regexec.
+ If not set, then returns differ between not matching and errors. */
+#define REG_NOSUB (1 << 3)
+
+
+/* POSIX 'eflags' bits (i.e., information for regexec). */
+
+/* If this bit is set, then the beginning-of-line operator doesn't match
+ the beginning of the string (presumably because it's not the
+ beginning of a line).
+ If not set, then the beginning-of-line operator does match the
+ beginning of the string. */
+#define REG_NOTBOL 1
+
+/* Like REG_NOTBOL, except for the end-of-line. */
+#define REG_NOTEOL (1 << 1)
+
+/* Use PMATCH[0] to delimit the start and end of the search in the
+ buffer. */
+#define REG_STARTEND (1 << 2)
+
+
+/* If any error codes are removed, changed, or added, update the
+ '__re_error_msgid' table in regcomp.c. */
+
+typedef enum
+{
+ _REG_ENOSYS = -1, /* This will never happen for this implementation. */
+ _REG_NOERROR = 0, /* Success. */
+ _REG_NOMATCH, /* Didn't find a match (for regexec). */
+
+ /* POSIX regcomp return error codes. (In the order listed in the
+ standard.) */
+ _REG_BADPAT, /* Invalid pattern. */
+ _REG_ECOLLATE, /* Invalid collating element. */
+ _REG_ECTYPE, /* Invalid character class name. */
+ _REG_EESCAPE, /* Trailing backslash. */
+ _REG_ESUBREG, /* Invalid back reference. */
+ _REG_EBRACK, /* Unmatched left bracket. */
+ _REG_EPAREN, /* Parenthesis imbalance. */
+ _REG_EBRACE, /* Unmatched \{. */
+ _REG_BADBR, /* Invalid contents of \{\}. */
+ _REG_ERANGE, /* Invalid range end. */
+ _REG_ESPACE, /* Ran out of memory. */
+ _REG_BADRPT, /* No preceding re for repetition op. */
+
+ /* Error codes we've added. */
+ _REG_EEND, /* Premature end. */
+ _REG_ESIZE, /* Too large (e.g., repeat count too large). */
+ _REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
+} reg_errcode_t;
+
+#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K
+# define REG_ENOSYS _REG_ENOSYS
+#endif
+#define REG_NOERROR _REG_NOERROR
+#define REG_NOMATCH _REG_NOMATCH
+#define REG_BADPAT _REG_BADPAT
+#define REG_ECOLLATE _REG_ECOLLATE
+#define REG_ECTYPE _REG_ECTYPE
+#define REG_EESCAPE _REG_EESCAPE
+#define REG_ESUBREG _REG_ESUBREG
+#define REG_EBRACK _REG_EBRACK
+#define REG_EPAREN _REG_EPAREN
+#define REG_EBRACE _REG_EBRACE
+#define REG_BADBR _REG_BADBR
+#define REG_ERANGE _REG_ERANGE
+#define REG_ESPACE _REG_ESPACE
+#define REG_BADRPT _REG_BADRPT
+#define REG_EEND _REG_EEND
+#define REG_ESIZE _REG_ESIZE
+#define REG_ERPAREN _REG_ERPAREN
+
+/* This data structure represents a compiled pattern. Before calling
+ the pattern compiler, the fields 'buffer', 'allocated', 'fastmap',
+ and 'translate' can be set. After the pattern has been compiled,
+ the fields 're_nsub', 'not_bol' and 'not_eol' are available. All
+ other fields are private to the regex routines. */
+
+#ifndef RE_TRANSLATE_TYPE
+# define __RE_TRANSLATE_TYPE unsigned char *
+# ifdef __USE_GNU
+# define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE
+# endif
+#endif
+
+#ifdef __USE_GNU
+# define __REPB_PREFIX(name) name
+#else
+# define __REPB_PREFIX(name) __##name
+#endif
+
+struct re_pattern_buffer
+{
+ /* Space that holds the compiled pattern. The type
+ 'struct re_dfa_t' is private and is not declared here. */
+ struct re_dfa_t *__REPB_PREFIX(buffer);
+
+ /* Number of bytes to which 'buffer' points. */
+ __re_long_size_t __REPB_PREFIX(allocated);
+
+ /* Number of bytes actually used in 'buffer'. */
+ __re_long_size_t __REPB_PREFIX(used);
+
+ /* Syntax setting with which the pattern was compiled. */
+ reg_syntax_t __REPB_PREFIX(syntax);
+
+ /* Pointer to a fastmap, if any, otherwise zero. re_search uses the
+ fastmap, if there is one, to skip over impossible starting points
+ for matches. */
+ char *__REPB_PREFIX(fastmap);
+
+ /* Either a translate table to apply to all characters before
+ comparing them, or zero for no translation. The translation is
+ applied to a pattern when it is compiled and to a string when it
+ is matched. */
+ __RE_TRANSLATE_TYPE __REPB_PREFIX(translate);
+
+ /* Number of subexpressions found by the compiler. */
+ size_t re_nsub;
+
+ /* Zero if this pattern cannot match the empty string, one else.
+ Well, in truth it's used only in 're_search_2', to see whether or
+ not we should use the fastmap, so we don't set this absolutely
+ perfectly; see 're_compile_fastmap' (the "duplicate" case). */
+ unsigned __REPB_PREFIX(can_be_null) : 1;
+
+ /* If REGS_UNALLOCATED, allocate space in the 'regs' structure
+ for 'max (RE_NREGS, re_nsub + 1)' groups.
+ If REGS_REALLOCATE, reallocate space if necessary.
+ If REGS_FIXED, use what's there. */
+#ifdef __USE_GNU
+# define REGS_UNALLOCATED 0
+# define REGS_REALLOCATE 1
+# define REGS_FIXED 2
+#endif
+ unsigned __REPB_PREFIX(regs_allocated) : 2;
+
+ /* Set to zero when 're_compile_pattern' compiles a pattern; set to
+ one by 're_compile_fastmap' if it updates the fastmap. */
+ unsigned __REPB_PREFIX(fastmap_accurate) : 1;
+
+ /* If set, 're_match_2' does not return information about
+ subexpressions. */
+ unsigned __REPB_PREFIX(no_sub) : 1;
+
+ /* If set, a beginning-of-line anchor doesn't match at the beginning
+ of the string. */
+ unsigned __REPB_PREFIX(not_bol) : 1;
+
+ /* Similarly for an end-of-line anchor. */
+ unsigned __REPB_PREFIX(not_eol) : 1;
+
+ /* If true, an anchor at a newline matches. */
+ unsigned __REPB_PREFIX(newline_anchor) : 1;
+};
+
+typedef struct re_pattern_buffer regex_t;
+
+/* Type for byte offsets within the string. POSIX mandates this. */
+#ifdef _REGEX_LARGE_OFFSETS
+/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as
+ ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t
+ is wider than ssize_t, so ssize_t is safe. ptrdiff_t is not
+ visible here, so use ssize_t. */
+typedef ssize_t regoff_t;
+#else
+/* The traditional GNU regex implementation mishandles strings longer
+ than INT_MAX. */
+typedef int regoff_t;
+#endif
+
+
+#ifdef __USE_GNU
+/* This is the structure we store register match data in. See
+ regex.texinfo for a full description of what registers match. */
+struct re_registers
+{
+ __re_size_t num_regs;
+ regoff_t *start;
+ regoff_t *end;
+};
+
+
+/* If 'regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
+ 're_match_2' returns information about at least this many registers
+ the first time a 'regs' structure is passed. */
+# ifndef RE_NREGS
+# define RE_NREGS 30
+# endif
+#endif
+
+
+/* POSIX specification for registers. Aside from the different names than
+ 're_registers', POSIX uses an array of structures, instead of a
+ structure of arrays. */
+typedef struct
+{
+ regoff_t rm_so; /* Byte offset from string's start to substring's start. */
+ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
+} regmatch_t;
+
+/* Declarations for routines. */
+
+#ifdef __USE_GNU
+/* Sets the current default syntax to SYNTAX, and return the old syntax.
+ You can also simply assign to the 're_syntax_options' variable. */
+extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
+
+/* Compile the regular expression PATTERN, with length LENGTH
+ and syntax given by the global 're_syntax_options', into the buffer
+ BUFFER. Return NULL if successful, and an error string if not.
+
+ To free the allocated storage, you must call 'regfree' on BUFFER.
+ Note that the translate table must either have been initialized by
+ 'regcomp', with a malloc'ed value, or set to NULL before calling
+ 'regfree'. */
+extern const char *re_compile_pattern (const char *__pattern, size_t __length,
+ struct re_pattern_buffer *__buffer);
+
+
+/* Compile a fastmap for the compiled pattern in BUFFER; used to
+ accelerate searches. Return 0 if successful and -2 if was an
+ internal error. */
+extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
+
+
+/* Search in the string STRING (with length LENGTH) for the pattern
+ compiled into BUFFER. Start searching at position START, for RANGE
+ characters. Return the starting position of the match, -1 for no
+ match, or -2 for an internal error. Also return register
+ information in REGS (if REGS and BUFFER->no_sub are nonzero). */
+extern regoff_t re_search (struct re_pattern_buffer *__buffer,
+ const char *__String, regoff_t __length,
+ regoff_t __start, regoff_t __range,
+ struct re_registers *__regs);
+
+
+/* Like 're_search', but search in the concatenation of STRING1 and
+ STRING2. Also, stop searching at index START + STOP. */
+extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer,
+ const char *__string1, regoff_t __length1,
+ const char *__string2, regoff_t __length2,
+ regoff_t __start, regoff_t __range,
+ struct re_registers *__regs,
+ regoff_t __stop);
+
+
+/* Like 're_search', but return how many characters in STRING the regexp
+ in BUFFER matched, starting at position START. */
+extern regoff_t re_match (struct re_pattern_buffer *__buffer,
+ const char *__String, regoff_t __length,
+ regoff_t __start, struct re_registers *__regs);
+
+
+/* Relates to 're_match' as 're_search_2' relates to 're_search'. */
+extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer,
+ const char *__string1, regoff_t __length1,
+ const char *__string2, regoff_t __length2,
+ regoff_t __start, struct re_registers *__regs,
+ regoff_t __stop);
+
+
+/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
+ ENDS. Subsequent matches using BUFFER and REGS will use this memory
+ for recording register information. STARTS and ENDS must be
+ allocated with malloc, and must each be at least 'NUM_REGS * sizeof
+ (regoff_t)' bytes long.
+
+ If NUM_REGS == 0, then subsequent matches should allocate their own
+ register data.
+
+ Unless this function is called, the first search or match using
+ BUFFER will allocate its own register data, without
+ freeing the old data. */
+extern void re_set_registers (struct re_pattern_buffer *__buffer,
+ struct re_registers *__regs,
+ __re_size_t __num_regs,
+ regoff_t *__starts, regoff_t *__ends);
+#endif /* Use GNU */
+
+#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_MISC)
+# ifndef _CRAY
+/* 4.2 bsd compatibility. */
+extern char *re_comp (const char *);
+extern int re_exec (const char *);
+# endif
+#endif
+
+/* For plain 'restrict', use glibc's __restrict if defined.
+ Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have
+ "restrict", and "configure" may have defined "restrict".
+ Other compilers use __restrict, __restrict__, and _Restrict, and
+ 'configure' might #define 'restrict' to those words, so pick a
+ different name. */
+#ifndef _Restrict_
+# if defined __restrict || 2 < __GNUC__ + (95 <= __GNUC_MINOR__)
+# define _Restrict_ __restrict
+# elif 199901L <= __STDC_VERSION__ || defined restrict
+# define _Restrict_ restrict
+# else
+# define _Restrict_
+# endif
+#endif
+/* For [restrict], use glibc's __restrict_arr if available.
+ Otherwise, GCC 3.1 (not in C++ mode) and C99 support [restrict]. */
+#ifndef _Restrict_arr_
+# ifdef __restrict_arr
+# define _Restrict_arr_ __restrict_arr
+# elif ((199901L <= __STDC_VERSION__ || 3 < __GNUC__ + (1 <= __GNUC_MINOR__)) \
+ && !defined __GNUG__)
+# define _Restrict_arr_ _Restrict_
+# else
+# define _Restrict_arr_
+# endif
+#endif
+
+/* POSIX compatibility. */
+extern int regcomp (regex_t *_Restrict_ __preg,
+ const char *_Restrict_ __pattern,
+ int __cflags);
+
+extern int regexec (const regex_t *_Restrict_ __preg,
+ const char *_Restrict_ __String, size_t __nmatch,
+ regmatch_t __pmatch[_Restrict_arr_],
+ int __eflags);
+
+extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
+ char *_Restrict_ __errbuf, size_t __errbuf_size);
+
+extern void regfree (regex_t *__preg);
+
+
+#ifdef __cplusplus
+}
+#endif /* C++ */
+
+#endif /* regex.h */
diff --git a/grub-core/lib/gnulib/regex_internal.c b/grub-core/lib/gnulib/regex_internal.c
new file mode 100644
index 0000000..b592f06
--- /dev/null
+++ b/grub-core/lib/gnulib/regex_internal.c
@@ -0,0 +1,1746 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 2002-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+static void re_string_construct_common (const char *str, Idx len,
+ re_string_t *pstr,
+ RE_TRANSLATE_TYPE trans, bool icase,
+ const re_dfa_t *dfa);
+static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
+ const re_node_set *nodes,
+ re_hashval_t hash);
+static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
+ const re_node_set *nodes,
+ unsigned int context,
+ re_hashval_t hash);
+static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
+ Idx new_buf_len);
+#ifdef RE_ENABLE_I18N
+static void build_wcs_buffer (re_string_t *pstr);
+static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr);
+#endif /* RE_ENABLE_I18N */
+static void build_upper_buffer (re_string_t *pstr);
+static void re_string_translate_buffer (re_string_t *pstr);
+static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
+ int eflags) __attribute__ ((pure));
+
+/* Functions for string operation. */
+
+/* This function allocate the buffers. It is necessary to call
+ re_string_reconstruct before using the object. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
+ RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
+{
+ reg_errcode_t ret;
+ Idx init_buf_len;
+
+ /* Ensure at least one character fits into the buffers. */
+ if (init_len < dfa->mb_cur_max)
+ init_len = dfa->mb_cur_max;
+ init_buf_len = (len + 1 < init_len) ? len + 1: init_len;
+ re_string_construct_common (str, len, pstr, trans, icase, dfa);
+
+ ret = re_string_realloc_buffers (pstr, init_buf_len);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+
+ pstr->word_char = dfa->word_char;
+ pstr->word_ops_used = dfa->word_ops_used;
+ pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
+ pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len;
+ pstr->valid_raw_len = pstr->valid_len;
+ return REG_NOERROR;
+}
+
+/* This function allocate the buffers, and initialize them. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_string_construct (re_string_t *pstr, const char *str, Idx len,
+ RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
+{
+ reg_errcode_t ret;
+ memset (pstr, '\0', sizeof (re_string_t));
+ re_string_construct_common (str, len, pstr, trans, icase, dfa);
+
+ if (len > 0)
+ {
+ ret = re_string_realloc_buffers (pstr, len + 1);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+ }
+ pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
+
+ if (icase)
+ {
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ {
+ while (1)
+ {
+ ret = build_wcs_upper_buffer (pstr);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+ if (pstr->valid_raw_len >= len)
+ break;
+ if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max)
+ break;
+ ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+ }
+ }
+ else
+#endif /* RE_ENABLE_I18N */
+ build_upper_buffer (pstr);
+ }
+ else
+ {
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ build_wcs_buffer (pstr);
+ else
+#endif /* RE_ENABLE_I18N */
+ {
+ if (trans != NULL)
+ re_string_translate_buffer (pstr);
+ else
+ {
+ pstr->valid_len = pstr->bufs_len;
+ pstr->valid_raw_len = pstr->bufs_len;
+ }
+ }
+ }
+
+ return REG_NOERROR;
+}
+
+/* Helper functions for re_string_allocate, and re_string_construct. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
+{
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ {
+ wint_t *new_wcs;
+
+ /* Avoid overflow in realloc. */
+ const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx));
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size)
+ < new_buf_len))
+ return REG_ESPACE;
+
+ new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
+ if (__glibc_unlikely (new_wcs == NULL))
+ return REG_ESPACE;
+ pstr->wcs = new_wcs;
+ if (pstr->offsets != NULL)
+ {
+ Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len);
+ if (__glibc_unlikely (new_offsets == NULL))
+ return REG_ESPACE;
+ pstr->offsets = new_offsets;
+ }
+ }
+#endif /* RE_ENABLE_I18N */
+ if (pstr->mbs_allocated)
+ {
+ unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
+ new_buf_len);
+ if (__glibc_unlikely (new_mbs == NULL))
+ return REG_ESPACE;
+ pstr->mbs = new_mbs;
+ }
+ pstr->bufs_len = new_buf_len;
+ return REG_NOERROR;
+}
+
+
+static void
+re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
+ RE_TRANSLATE_TYPE trans, bool icase,
+ const re_dfa_t *dfa)
+{
+ pstr->raw_mbs = (const unsigned char *) str;
+ pstr->len = len;
+ pstr->raw_len = len;
+ pstr->trans = trans;
+ pstr->icase = icase;
+ pstr->mbs_allocated = (trans != NULL || icase);
+ pstr->mb_cur_max = dfa->mb_cur_max;
+ pstr->is_utf8 = dfa->is_utf8;
+ pstr->map_notascii = dfa->map_notascii;
+ pstr->stop = pstr->len;
+ pstr->raw_stop = pstr->stop;
+}
+
+#ifdef RE_ENABLE_I18N
+
+/* Build wide character buffer PSTR->WCS.
+ If the byte sequence of the string are:
+ <mb1>(0), <mb1>(1), <mb2>(0), <mb2>(1), <sb3>
+ Then wide character buffer will be:
+ <wc1> , WEOF , <wc2> , WEOF , <wc3>
+ We use WEOF for padding, they indicate that the position isn't
+ a first byte of a multibyte character.
+
+ Note that this function assumes PSTR->VALID_LEN elements are already
+ built and starts from PSTR->VALID_LEN. */
+
+static void
+build_wcs_buffer (re_string_t *pstr)
+{
+#ifdef _LIBC
+ unsigned char buf[MB_LEN_MAX];
+ assert (MB_LEN_MAX >= pstr->mb_cur_max);
+#else
+ unsigned char buf[64];
+#endif
+ mbstate_t prev_st;
+ Idx byte_idx, end_idx, remain_len;
+ size_t mbclen;
+
+ /* Build the buffers from pstr->valid_len to either pstr->len or
+ pstr->bufs_len. */
+ end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+ for (byte_idx = pstr->valid_len; byte_idx < end_idx;)
+ {
+ wchar_t wc;
+ const char *p;
+
+ remain_len = end_idx - byte_idx;
+ prev_st = pstr->cur_state;
+ /* Apply the translation if we need. */
+ if (__glibc_unlikely (pstr->trans != NULL))
+ {
+ int i, ch;
+
+ for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
+ {
+ ch = pstr->raw_mbs [pstr->raw_mbs_idx + byte_idx + i];
+ buf[i] = pstr->mbs[byte_idx + i] = pstr->trans[ch];
+ }
+ p = (const char *) buf;
+ }
+ else
+ p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
+ mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
+ if (__glibc_unlikely (mbclen == (size_t) -1 || mbclen == 0
+ || (mbclen == (size_t) -2
+ && pstr->bufs_len >= pstr->len)))
+ {
+ /* We treat these cases as a singlebyte character. */
+ mbclen = 1;
+ wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
+ if (__glibc_unlikely (pstr->trans != NULL))
+ wc = pstr->trans[wc];
+ pstr->cur_state = prev_st;
+ }
+ else if (__glibc_unlikely (mbclen == (size_t) -2))
+ {
+ /* The buffer doesn't have enough space, finish to build. */
+ pstr->cur_state = prev_st;
+ break;
+ }
+
+ /* Write wide character and padding. */
+ pstr->wcs[byte_idx++] = wc;
+ /* Write paddings. */
+ for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
+ pstr->wcs[byte_idx++] = WEOF;
+ }
+ pstr->valid_len = byte_idx;
+ pstr->valid_raw_len = byte_idx;
+}
+
+/* Build wide character buffer PSTR->WCS like build_wcs_buffer,
+ but for REG_ICASE. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+build_wcs_upper_buffer (re_string_t *pstr)
+{
+ mbstate_t prev_st;
+ Idx src_idx, byte_idx, end_idx, remain_len;
+ size_t mbclen;
+#ifdef _LIBC
+ char buf[MB_LEN_MAX];
+ assert (MB_LEN_MAX >= pstr->mb_cur_max);
+#else
+ char buf[64];
+#endif
+
+ byte_idx = pstr->valid_len;
+ end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+
+ /* The following optimization assumes that ASCII characters can be
+ mapped to wide characters with a simple cast. */
+ if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed)
+ {
+ while (byte_idx < end_idx)
+ {
+ wchar_t wc;
+
+ if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx])
+ && mbsinit (&pstr->cur_state))
+ {
+ /* In case of a singlebyte character. */
+ pstr->mbs[byte_idx]
+ = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
+ /* The next step uses the assumption that wchar_t is encoded
+ ASCII-safe: all ASCII values can be converted like this. */
+ pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx];
+ ++byte_idx;
+ continue;
+ }
+
+ remain_len = end_idx - byte_idx;
+ prev_st = pstr->cur_state;
+ mbclen = __mbrtowc (&wc,
+ ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
+ + byte_idx), remain_len, &pstr->cur_state);
+ if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2))
+ {
+ wchar_t wcu = __towupper (wc);
+ if (wcu != wc)
+ {
+ size_t mbcdlen;
+
+ mbcdlen = __wcrtomb (buf, wcu, &prev_st);
+ if (__glibc_likely (mbclen == mbcdlen))
+ memcpy (pstr->mbs + byte_idx, buf, mbclen);
+ else
+ {
+ src_idx = byte_idx;
+ goto offsets_needed;
+ }
+ }
+ else
+ memcpy (pstr->mbs + byte_idx,
+ pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen);
+ pstr->wcs[byte_idx++] = wcu;
+ /* Write paddings. */
+ for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
+ pstr->wcs[byte_idx++] = WEOF;
+ }
+ else if (mbclen == (size_t) -1 || mbclen == 0
+ || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len))
+ {
+ /* It is an invalid character, an incomplete character
+ at the end of the string, or '\0'. Just use the byte. */
+ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
+ pstr->mbs[byte_idx] = ch;
+ /* And also cast it to wide char. */
+ pstr->wcs[byte_idx++] = (wchar_t) ch;
+ if (__glibc_unlikely (mbclen == (size_t) -1))
+ pstr->cur_state = prev_st;
+ }
+ else
+ {
+ /* The buffer doesn't have enough space, finish to build. */
+ pstr->cur_state = prev_st;
+ break;
+ }
+ }
+ pstr->valid_len = byte_idx;
+ pstr->valid_raw_len = byte_idx;
+ return REG_NOERROR;
+ }
+ else
+ for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;)
+ {
+ wchar_t wc;
+ const char *p;
+ offsets_needed:
+ remain_len = end_idx - byte_idx;
+ prev_st = pstr->cur_state;
+ if (__glibc_unlikely (pstr->trans != NULL))
+ {
+ int i, ch;
+
+ for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
+ {
+ ch = pstr->raw_mbs [pstr->raw_mbs_idx + src_idx + i];
+ buf[i] = pstr->trans[ch];
+ }
+ p = (const char *) buf;
+ }
+ else
+ p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
+ mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
+ if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2))
+ {
+ wchar_t wcu = __towupper (wc);
+ if (wcu != wc)
+ {
+ size_t mbcdlen;
+
+ mbcdlen = __wcrtomb ((char *) buf, wcu, &prev_st);
+ if (__glibc_likely (mbclen == mbcdlen))
+ memcpy (pstr->mbs + byte_idx, buf, mbclen);
+ else if (mbcdlen != (size_t) -1)
+ {
+ size_t i;
+
+ if (byte_idx + mbcdlen > pstr->bufs_len)
+ {
+ pstr->cur_state = prev_st;
+ break;
+ }
+
+ if (pstr->offsets == NULL)
+ {
+ pstr->offsets = re_malloc (Idx, pstr->bufs_len);
+
+ if (pstr->offsets == NULL)
+ return REG_ESPACE;
+ }
+ if (!pstr->offsets_needed)
+ {
+ for (i = 0; i < (size_t) byte_idx; ++i)
+ pstr->offsets[i] = i;
+ pstr->offsets_needed = 1;
+ }
+
+ memcpy (pstr->mbs + byte_idx, buf, mbcdlen);
+ pstr->wcs[byte_idx] = wcu;
+ pstr->offsets[byte_idx] = src_idx;
+ for (i = 1; i < mbcdlen; ++i)
+ {
+ pstr->offsets[byte_idx + i]
+ = src_idx + (i < mbclen ? i : mbclen - 1);
+ pstr->wcs[byte_idx + i] = WEOF;
+ }
+ pstr->len += mbcdlen - mbclen;
+ if (pstr->raw_stop > src_idx)
+ pstr->stop += mbcdlen - mbclen;
+ end_idx = (pstr->bufs_len > pstr->len)
+ ? pstr->len : pstr->bufs_len;
+ byte_idx += mbcdlen;
+ src_idx += mbclen;
+ continue;
+ }
+ else
+ memcpy (pstr->mbs + byte_idx, p, mbclen);
+ }
+ else
+ memcpy (pstr->mbs + byte_idx, p, mbclen);
+
+ if (__glibc_unlikely (pstr->offsets_needed != 0))
+ {
+ size_t i;
+ for (i = 0; i < mbclen; ++i)
+ pstr->offsets[byte_idx + i] = src_idx + i;
+ }
+ src_idx += mbclen;
+
+ pstr->wcs[byte_idx++] = wcu;
+ /* Write paddings. */
+ for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
+ pstr->wcs[byte_idx++] = WEOF;
+ }
+ else if (mbclen == (size_t) -1 || mbclen == 0
+ || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len))
+ {
+ /* It is an invalid character or '\0'. Just use the byte. */
+ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];
+
+ if (__glibc_unlikely (pstr->trans != NULL))
+ ch = pstr->trans [ch];
+ pstr->mbs[byte_idx] = ch;
+
+ if (__glibc_unlikely (pstr->offsets_needed != 0))
+ pstr->offsets[byte_idx] = src_idx;
+ ++src_idx;
+
+ /* And also cast it to wide char. */
+ pstr->wcs[byte_idx++] = (wchar_t) ch;
+ if (__glibc_unlikely (mbclen == (size_t) -1))
+ pstr->cur_state = prev_st;
+ }
+ else
+ {
+ /* The buffer doesn't have enough space, finish to build. */
+ pstr->cur_state = prev_st;
+ break;
+ }
+ }
+ pstr->valid_len = byte_idx;
+ pstr->valid_raw_len = src_idx;
+ return REG_NOERROR;
+}
+
+/* Skip characters until the index becomes greater than NEW_RAW_IDX.
+ Return the index. */
+
+static Idx
+re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
+{
+ mbstate_t prev_st;
+ Idx rawbuf_idx;
+ size_t mbclen;
+ wint_t wc = WEOF;
+
+ /* Skip the characters which are not necessary to check. */
+ for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len;
+ rawbuf_idx < new_raw_idx;)
+ {
+ wchar_t wc2;
+ Idx remain_len = pstr->raw_len - rawbuf_idx;
+ prev_st = pstr->cur_state;
+ mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
+ remain_len, &pstr->cur_state);
+ if (__glibc_unlikely (mbclen == (size_t) -2 || mbclen == (size_t) -1
+ || mbclen == 0))
+ {
+ /* We treat these cases as a single byte character. */
+ if (mbclen == 0 || remain_len == 0)
+ wc = L'\0';
+ else
+ wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx);
+ mbclen = 1;
+ pstr->cur_state = prev_st;
+ }
+ else
+ wc = wc2;
+ /* Then proceed the next character. */
+ rawbuf_idx += mbclen;
+ }
+ *last_wc = wc;
+ return rawbuf_idx;
+}
+#endif /* RE_ENABLE_I18N */
+
+/* Build the buffer PSTR->MBS, and apply the translation if we need.
+ This function is used in case of REG_ICASE. */
+
+static void
+build_upper_buffer (re_string_t *pstr)
+{
+ Idx char_idx, end_idx;
+ end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+
+ for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
+ {
+ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
+ if (__glibc_unlikely (pstr->trans != NULL))
+ ch = pstr->trans[ch];
+ pstr->mbs[char_idx] = toupper (ch);
+ }
+ pstr->valid_len = char_idx;
+ pstr->valid_raw_len = char_idx;
+}
+
+/* Apply TRANS to the buffer in PSTR. */
+
+static void
+re_string_translate_buffer (re_string_t *pstr)
+{
+ Idx buf_idx, end_idx;
+ end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+
+ for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx)
+ {
+ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx];
+ pstr->mbs[buf_idx] = pstr->trans[ch];
+ }
+
+ pstr->valid_len = buf_idx;
+ pstr->valid_raw_len = buf_idx;
+}
+
+/* This function re-construct the buffers.
+ Concretely, convert to wide character in case of pstr->mb_cur_max > 1,
+ convert to upper case in case of REG_ICASE, apply translation. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
+{
+ Idx offset;
+
+ if (__glibc_unlikely (pstr->raw_mbs_idx <= idx))
+ offset = idx - pstr->raw_mbs_idx;
+ else
+ {
+ /* Reset buffer. */
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
+#endif /* RE_ENABLE_I18N */
+ pstr->len = pstr->raw_len;
+ pstr->stop = pstr->raw_stop;
+ pstr->valid_len = 0;
+ pstr->raw_mbs_idx = 0;
+ pstr->valid_raw_len = 0;
+ pstr->offsets_needed = 0;
+ pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
+ : CONTEXT_NEWLINE | CONTEXT_BEGBUF);
+ if (!pstr->mbs_allocated)
+ pstr->mbs = (unsigned char *) pstr->raw_mbs;
+ offset = idx;
+ }
+
+ if (__glibc_likely (offset != 0))
+ {
+ /* Should the already checked characters be kept? */
+ if (__glibc_likely (offset < pstr->valid_raw_len))
+ {
+ /* Yes, move them to the front of the buffer. */
+#ifdef RE_ENABLE_I18N
+ if (__glibc_unlikely (pstr->offsets_needed))
+ {
+ Idx low = 0, high = pstr->valid_len, mid;
+ do
+ {
+ mid = (high + low) / 2;
+ if (pstr->offsets[mid] > offset)
+ high = mid;
+ else if (pstr->offsets[mid] < offset)
+ low = mid + 1;
+ else
+ break;
+ }
+ while (low < high);
+ if (pstr->offsets[mid] < offset)
+ ++mid;
+ pstr->tip_context = re_string_context_at (pstr, mid - 1,
+ eflags);
+ /* This can be quite complicated, so handle specially
+ only the common and easy case where the character with
+ different length representation of lower and upper
+ case is present at or after offset. */
+ if (pstr->valid_len > offset
+ && mid == offset && pstr->offsets[mid] == offset)
+ {
+ memmove (pstr->wcs, pstr->wcs + offset,
+ (pstr->valid_len - offset) * sizeof (wint_t));
+ memmove (pstr->mbs, pstr->mbs + offset, pstr->valid_len - offset);
+ pstr->valid_len -= offset;
+ pstr->valid_raw_len -= offset;
+ for (low = 0; low < pstr->valid_len; low++)
+ pstr->offsets[low] = pstr->offsets[low + offset] - offset;
+ }
+ else
+ {
+ /* Otherwise, just find out how long the partial multibyte
+ character at offset is and fill it with WEOF/255. */
+ pstr->len = pstr->raw_len - idx + offset;
+ pstr->stop = pstr->raw_stop - idx + offset;
+ pstr->offsets_needed = 0;
+ while (mid > 0 && pstr->offsets[mid - 1] == offset)
+ --mid;
+ while (mid < pstr->valid_len)
+ if (pstr->wcs[mid] != WEOF)
+ break;
+ else
+ ++mid;
+ if (mid == pstr->valid_len)
+ pstr->valid_len = 0;
+ else
+ {
+ pstr->valid_len = pstr->offsets[mid] - offset;
+ if (pstr->valid_len)
+ {
+ for (low = 0; low < pstr->valid_len; ++low)
+ pstr->wcs[low] = WEOF;
+ memset (pstr->mbs, 255, pstr->valid_len);
+ }
+ }
+ pstr->valid_raw_len = pstr->valid_len;
+ }
+ }
+ else
+#endif
+ {
+ pstr->tip_context = re_string_context_at (pstr, offset - 1,
+ eflags);
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ memmove (pstr->wcs, pstr->wcs + offset,
+ (pstr->valid_len - offset) * sizeof (wint_t));
+#endif /* RE_ENABLE_I18N */
+ if (__glibc_unlikely (pstr->mbs_allocated))
+ memmove (pstr->mbs, pstr->mbs + offset,
+ pstr->valid_len - offset);
+ pstr->valid_len -= offset;
+ pstr->valid_raw_len -= offset;
+#if defined DEBUG && DEBUG
+ assert (pstr->valid_len > 0);
+#endif
+ }
+ }
+ else
+ {
+#ifdef RE_ENABLE_I18N
+ /* No, skip all characters until IDX. */
+ Idx prev_valid_len = pstr->valid_len;
+
+ if (__glibc_unlikely (pstr->offsets_needed))
+ {
+ pstr->len = pstr->raw_len - idx + offset;
+ pstr->stop = pstr->raw_stop - idx + offset;
+ pstr->offsets_needed = 0;
+ }
+#endif
+ pstr->valid_len = 0;
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ {
+ Idx wcs_idx;
+ wint_t wc = WEOF;
+
+ if (pstr->is_utf8)
+ {
+ const unsigned char *raw, *p, *end;
+
+ /* Special case UTF-8. Multi-byte chars start with any
+ byte other than 0x80 - 0xbf. */
+ raw = pstr->raw_mbs + pstr->raw_mbs_idx;
+ end = raw + (offset - pstr->mb_cur_max);
+ if (end < pstr->raw_mbs)
+ end = pstr->raw_mbs;
+ p = raw + offset - 1;
+#ifdef _LIBC
+ /* We know the wchar_t encoding is UCS4, so for the simple
+ case, ASCII characters, skip the conversion step. */
+ if (isascii (*p) && __glibc_likely (pstr->trans == NULL))
+ {
+ memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
+ /* pstr->valid_len = 0; */
+ wc = (wchar_t) *p;
+ }
+ else
+#endif
+ for (; p >= end; --p)
+ if ((*p & 0xc0) != 0x80)
+ {
+ mbstate_t cur_state;
+ wchar_t wc2;
+ Idx mlen = raw + pstr->len - p;
+ unsigned char buf[6];
+ size_t mbclen;
+
+ const unsigned char *pp = p;
+ if (__glibc_unlikely (pstr->trans != NULL))
+ {
+ int i = mlen < 6 ? mlen : 6;
+ while (--i >= 0)
+ buf[i] = pstr->trans[p[i]];
+ pp = buf;
+ }
+ /* XXX Don't use mbrtowc, we know which conversion
+ to use (UTF-8 -> UCS4). */
+ memset (&cur_state, 0, sizeof (cur_state));
+ mbclen = __mbrtowc (&wc2, (const char *) pp, mlen,
+ &cur_state);
+ if (raw + offset - p <= mbclen
+ && mbclen < (size_t) -2)
+ {
+ memset (&pstr->cur_state, '\0',
+ sizeof (mbstate_t));
+ pstr->valid_len = mbclen - (raw + offset - p);
+ wc = wc2;
+ }
+ break;
+ }
+ }
+
+ if (wc == WEOF)
+ pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx;
+ if (wc == WEOF)
+ pstr->tip_context
+ = re_string_context_at (pstr, prev_valid_len - 1, eflags);
+ else
+ pstr->tip_context = ((__glibc_unlikely (pstr->word_ops_used != 0)
+ && IS_WIDE_WORD_CHAR (wc))
+ ? CONTEXT_WORD
+ : ((IS_WIDE_NEWLINE (wc)
+ && pstr->newline_anchor)
+ ? CONTEXT_NEWLINE : 0));
+ if (__glibc_unlikely (pstr->valid_len))
+ {
+ for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
+ pstr->wcs[wcs_idx] = WEOF;
+ if (pstr->mbs_allocated)
+ memset (pstr->mbs, 255, pstr->valid_len);
+ }
+ pstr->valid_raw_len = pstr->valid_len;
+ }
+ else
+#endif /* RE_ENABLE_I18N */
+ {
+ int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
+ pstr->valid_raw_len = 0;
+ if (pstr->trans)
+ c = pstr->trans[c];
+ pstr->tip_context = (bitset_contain (pstr->word_char, c)
+ ? CONTEXT_WORD
+ : ((IS_NEWLINE (c) && pstr->newline_anchor)
+ ? CONTEXT_NEWLINE : 0));
+ }
+ }
+ if (!__glibc_unlikely (pstr->mbs_allocated))
+ pstr->mbs += offset;
+ }
+ pstr->raw_mbs_idx = idx;
+ pstr->len -= offset;
+ pstr->stop -= offset;
+
+ /* Then build the buffers. */
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ {
+ if (pstr->icase)
+ {
+ reg_errcode_t ret = build_wcs_upper_buffer (pstr);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+ }
+ else
+ build_wcs_buffer (pstr);
+ }
+ else
+#endif /* RE_ENABLE_I18N */
+ if (__glibc_unlikely (pstr->mbs_allocated))
+ {
+ if (pstr->icase)
+ build_upper_buffer (pstr);
+ else if (pstr->trans != NULL)
+ re_string_translate_buffer (pstr);
+ }
+ else
+ pstr->valid_len = pstr->len;
+
+ pstr->cur_idx = 0;
+ return REG_NOERROR;
+}
+
+static unsigned char
+__attribute__ ((pure))
+re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
+{
+ int ch;
+ Idx off;
+
+ /* Handle the common (easiest) cases first. */
+ if (__glibc_likely (!pstr->mbs_allocated))
+ return re_string_peek_byte (pstr, idx);
+
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1
+ && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx))
+ return re_string_peek_byte (pstr, idx);
+#endif
+
+ off = pstr->cur_idx + idx;
+#ifdef RE_ENABLE_I18N
+ if (pstr->offsets_needed)
+ off = pstr->offsets[off];
+#endif
+
+ ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
+
+#ifdef RE_ENABLE_I18N
+ /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I
+ this function returns CAPITAL LETTER I instead of first byte of
+ DOTLESS SMALL LETTER I. The latter would confuse the parser,
+ since peek_byte_case doesn't advance cur_idx in any way. */
+ if (pstr->offsets_needed && !isascii (ch))
+ return re_string_peek_byte (pstr, idx);
+#endif
+
+ return ch;
+}
+
+static unsigned char
+re_string_fetch_byte_case (re_string_t *pstr)
+{
+ if (__glibc_likely (!pstr->mbs_allocated))
+ return re_string_fetch_byte (pstr);
+
+#ifdef RE_ENABLE_I18N
+ if (pstr->offsets_needed)
+ {
+ Idx off;
+ int ch;
+
+ /* For tr_TR.UTF-8 [[:islower:]] there is
+ [[: CAPITAL LETTER I WITH DOT lower:]] in mbs. Skip
+ in that case the whole multi-byte character and return
+ the original letter. On the other side, with
+ [[: DOTLESS SMALL LETTER I return [[:I, as doing
+ anything else would complicate things too much. */
+
+ if (!re_string_first_byte (pstr, pstr->cur_idx))
+ return re_string_fetch_byte (pstr);
+
+ off = pstr->offsets[pstr->cur_idx];
+ ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
+
+ if (! isascii (ch))
+ return re_string_fetch_byte (pstr);
+
+ re_string_skip_bytes (pstr,
+ re_string_char_size_at (pstr, pstr->cur_idx));
+ return ch;
+ }
+#endif
+
+ return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++];
+}
+
+static void
+re_string_destruct (re_string_t *pstr)
+{
+#ifdef RE_ENABLE_I18N
+ re_free (pstr->wcs);
+ re_free (pstr->offsets);
+#endif /* RE_ENABLE_I18N */
+ if (pstr->mbs_allocated)
+ re_free (pstr->mbs);
+}
+
+/* Return the context at IDX in INPUT. */
+
+static unsigned int
+re_string_context_at (const re_string_t *input, Idx idx, int eflags)
+{
+ int c;
+ if (__glibc_unlikely (idx < 0))
+ /* In this case, we use the value stored in input->tip_context,
+ since we can't know the character in input->mbs[-1] here. */
+ return input->tip_context;
+ if (__glibc_unlikely (idx == input->len))
+ return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
+ : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
+#ifdef RE_ENABLE_I18N
+ if (input->mb_cur_max > 1)
+ {
+ wint_t wc;
+ Idx wc_idx = idx;
+ while(input->wcs[wc_idx] == WEOF)
+ {
+#if defined DEBUG && DEBUG
+ /* It must not happen. */
+ assert (wc_idx >= 0);
+#endif
+ --wc_idx;
+ if (wc_idx < 0)
+ return input->tip_context;
+ }
+ wc = input->wcs[wc_idx];
+ if (__glibc_unlikely (input->word_ops_used != 0)
+ && IS_WIDE_WORD_CHAR (wc))
+ return CONTEXT_WORD;
+ return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
+ ? CONTEXT_NEWLINE : 0);
+ }
+ else
+#endif
+ {
+ c = re_string_byte_at (input, idx);
+ if (bitset_contain (input->word_char, c))
+ return CONTEXT_WORD;
+ return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0;
+ }
+}
+
+/* Functions for set operation. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_node_set_alloc (re_node_set *set, Idx size)
+{
+ set->alloc = size;
+ set->nelem = 0;
+ set->elems = re_malloc (Idx, size);
+ if (__glibc_unlikely (set->elems == NULL)
+ && (MALLOC_0_IS_NONNULL || size != 0))
+ return REG_ESPACE;
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_node_set_init_1 (re_node_set *set, Idx elem)
+{
+ set->alloc = 1;
+ set->nelem = 1;
+ set->elems = re_malloc (Idx, 1);
+ if (__glibc_unlikely (set->elems == NULL))
+ {
+ set->alloc = set->nelem = 0;
+ return REG_ESPACE;
+ }
+ set->elems[0] = elem;
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
+{
+ set->alloc = 2;
+ set->elems = re_malloc (Idx, 2);
+ if (__glibc_unlikely (set->elems == NULL))
+ return REG_ESPACE;
+ if (elem1 == elem2)
+ {
+ set->nelem = 1;
+ set->elems[0] = elem1;
+ }
+ else
+ {
+ set->nelem = 2;
+ if (elem1 < elem2)
+ {
+ set->elems[0] = elem1;
+ set->elems[1] = elem2;
+ }
+ else
+ {
+ set->elems[0] = elem2;
+ set->elems[1] = elem1;
+ }
+ }
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
+{
+ dest->nelem = src->nelem;
+ if (src->nelem > 0)
+ {
+ dest->alloc = dest->nelem;
+ dest->elems = re_malloc (Idx, dest->alloc);
+ if (__glibc_unlikely (dest->elems == NULL))
+ {
+ dest->alloc = dest->nelem = 0;
+ return REG_ESPACE;
+ }
+ memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx));
+ }
+ else
+ re_node_set_init_empty (dest);
+ return REG_NOERROR;
+}
+
+/* Calculate the intersection of the sets SRC1 and SRC2. And merge it to
+ DEST. Return value indicate the error code or REG_NOERROR if succeeded.
+ Note: We assume dest->elems is NULL, when dest->alloc is 0. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
+ const re_node_set *src2)
+{
+ Idx i1, i2, is, id, delta, sbase;
+ if (src1->nelem == 0 || src2->nelem == 0)
+ return REG_NOERROR;
+
+ /* We need dest->nelem + 2 * elems_in_intersection; this is a
+ conservative estimate. */
+ if (src1->nelem + src2->nelem + dest->nelem > dest->alloc)
+ {
+ Idx new_alloc = src1->nelem + src2->nelem + dest->alloc;
+ Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc);
+ if (__glibc_unlikely (new_elems == NULL))
+ return REG_ESPACE;
+ dest->elems = new_elems;
+ dest->alloc = new_alloc;
+ }
+
+ /* Find the items in the intersection of SRC1 and SRC2, and copy
+ into the top of DEST those that are not already in DEST itself. */
+ sbase = dest->nelem + src1->nelem + src2->nelem;
+ i1 = src1->nelem - 1;
+ i2 = src2->nelem - 1;
+ id = dest->nelem - 1;
+ for (;;)
+ {
+ if (src1->elems[i1] == src2->elems[i2])
+ {
+ /* Try to find the item in DEST. Maybe we could binary search? */
+ while (id >= 0 && dest->elems[id] > src1->elems[i1])
+ --id;
+
+ if (id < 0 || dest->elems[id] != src1->elems[i1])
+ dest->elems[--sbase] = src1->elems[i1];
+
+ if (--i1 < 0 || --i2 < 0)
+ break;
+ }
+
+ /* Lower the highest of the two items. */
+ else if (src1->elems[i1] < src2->elems[i2])
+ {
+ if (--i2 < 0)
+ break;
+ }
+ else
+ {
+ if (--i1 < 0)
+ break;
+ }
+ }
+
+ id = dest->nelem - 1;
+ is = dest->nelem + src1->nelem + src2->nelem - 1;
+ delta = is - sbase + 1;
+
+ /* Now copy. When DELTA becomes zero, the remaining
+ DEST elements are already in place; this is more or
+ less the same loop that is in re_node_set_merge. */
+ dest->nelem += delta;
+ if (delta > 0 && id >= 0)
+ for (;;)
+ {
+ if (dest->elems[is] > dest->elems[id])
+ {
+ /* Copy from the top. */
+ dest->elems[id + delta--] = dest->elems[is--];
+ if (delta == 0)
+ break;
+ }
+ else
+ {
+ /* Slide from the bottom. */
+ dest->elems[id + delta] = dest->elems[id];
+ if (--id < 0)
+ break;
+ }
+ }
+
+ /* Copy remaining SRC elements. */
+ memcpy (dest->elems, dest->elems + sbase, delta * sizeof (Idx));
+
+ return REG_NOERROR;
+}
+
+/* Calculate the union set of the sets SRC1 and SRC2. And store it to
+ DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
+ const re_node_set *src2)
+{
+ Idx i1, i2, id;
+ if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
+ {
+ dest->alloc = src1->nelem + src2->nelem;
+ dest->elems = re_malloc (Idx, dest->alloc);
+ if (__glibc_unlikely (dest->elems == NULL))
+ return REG_ESPACE;
+ }
+ else
+ {
+ if (src1 != NULL && src1->nelem > 0)
+ return re_node_set_init_copy (dest, src1);
+ else if (src2 != NULL && src2->nelem > 0)
+ return re_node_set_init_copy (dest, src2);
+ else
+ re_node_set_init_empty (dest);
+ return REG_NOERROR;
+ }
+ for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;)
+ {
+ if (src1->elems[i1] > src2->elems[i2])
+ {
+ dest->elems[id++] = src2->elems[i2++];
+ continue;
+ }
+ if (src1->elems[i1] == src2->elems[i2])
+ ++i2;
+ dest->elems[id++] = src1->elems[i1++];
+ }
+ if (i1 < src1->nelem)
+ {
+ memcpy (dest->elems + id, src1->elems + i1,
+ (src1->nelem - i1) * sizeof (Idx));
+ id += src1->nelem - i1;
+ }
+ else if (i2 < src2->nelem)
+ {
+ memcpy (dest->elems + id, src2->elems + i2,
+ (src2->nelem - i2) * sizeof (Idx));
+ id += src2->nelem - i2;
+ }
+ dest->nelem = id;
+ return REG_NOERROR;
+}
+
+/* Calculate the union set of the sets DEST and SRC. And store it to
+ DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_node_set_merge (re_node_set *dest, const re_node_set *src)
+{
+ Idx is, id, sbase, delta;
+ if (src == NULL || src->nelem == 0)
+ return REG_NOERROR;
+ if (dest->alloc < 2 * src->nelem + dest->nelem)
+ {
+ Idx new_alloc = 2 * (src->nelem + dest->alloc);
+ Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc);
+ if (__glibc_unlikely (new_buffer == NULL))
+ return REG_ESPACE;
+ dest->elems = new_buffer;
+ dest->alloc = new_alloc;
+ }
+
+ if (__glibc_unlikely (dest->nelem == 0))
+ {
+ dest->nelem = src->nelem;
+ memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx));
+ return REG_NOERROR;
+ }
+
+ /* Copy into the top of DEST the items of SRC that are not
+ found in DEST. Maybe we could binary search in DEST? */
+ for (sbase = dest->nelem + 2 * src->nelem,
+ is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; )
+ {
+ if (dest->elems[id] == src->elems[is])
+ is--, id--;
+ else if (dest->elems[id] < src->elems[is])
+ dest->elems[--sbase] = src->elems[is--];
+ else /* if (dest->elems[id] > src->elems[is]) */
+ --id;
+ }
+
+ if (is >= 0)
+ {
+ /* If DEST is exhausted, the remaining items of SRC must be unique. */
+ sbase -= is + 1;
+ memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (Idx));
+ }
+
+ id = dest->nelem - 1;
+ is = dest->nelem + 2 * src->nelem - 1;
+ delta = is - sbase + 1;
+ if (delta == 0)
+ return REG_NOERROR;
+
+ /* Now copy. When DELTA becomes zero, the remaining
+ DEST elements are already in place. */
+ dest->nelem += delta;
+ for (;;)
+ {
+ if (dest->elems[is] > dest->elems[id])
+ {
+ /* Copy from the top. */
+ dest->elems[id + delta--] = dest->elems[is--];
+ if (delta == 0)
+ break;
+ }
+ else
+ {
+ /* Slide from the bottom. */
+ dest->elems[id + delta] = dest->elems[id];
+ if (--id < 0)
+ {
+ /* Copy remaining SRC elements. */
+ memcpy (dest->elems, dest->elems + sbase,
+ delta * sizeof (Idx));
+ break;
+ }
+ }
+ }
+
+ return REG_NOERROR;
+}
+
+/* Insert the new element ELEM to the re_node_set* SET.
+ SET should not already have ELEM.
+ Return true if successful. */
+
+static bool
+__attribute_warn_unused_result__
+re_node_set_insert (re_node_set *set, Idx elem)
+{
+ Idx idx;
+ /* In case the set is empty. */
+ if (set->alloc == 0)
+ return __glibc_likely (re_node_set_init_1 (set, elem) == REG_NOERROR);
+
+ if (__glibc_unlikely (set->nelem) == 0)
+ {
+ /* We already guaranteed above that set->alloc != 0. */
+ set->elems[0] = elem;
+ ++set->nelem;
+ return true;
+ }
+
+ /* Realloc if we need. */
+ if (set->alloc == set->nelem)
+ {
+ Idx *new_elems;
+ set->alloc = set->alloc * 2;
+ new_elems = re_realloc (set->elems, Idx, set->alloc);
+ if (__glibc_unlikely (new_elems == NULL))
+ return false;
+ set->elems = new_elems;
+ }
+
+ /* Move the elements which follows the new element. Test the
+ first element separately to skip a check in the inner loop. */
+ if (elem < set->elems[0])
+ {
+ idx = 0;
+ for (idx = set->nelem; idx > 0; idx--)
+ set->elems[idx] = set->elems[idx - 1];
+ }
+ else
+ {
+ for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
+ set->elems[idx] = set->elems[idx - 1];
+ }
+
+ /* Insert the new element. */
+ set->elems[idx] = elem;
+ ++set->nelem;
+ return true;
+}
+
+/* Insert the new element ELEM to the re_node_set* SET.
+ SET should not already have any element greater than or equal to ELEM.
+ Return true if successful. */
+
+static bool
+__attribute_warn_unused_result__
+re_node_set_insert_last (re_node_set *set, Idx elem)
+{
+ /* Realloc if we need. */
+ if (set->alloc == set->nelem)
+ {
+ Idx *new_elems;
+ set->alloc = (set->alloc + 1) * 2;
+ new_elems = re_realloc (set->elems, Idx, set->alloc);
+ if (__glibc_unlikely (new_elems == NULL))
+ return false;
+ set->elems = new_elems;
+ }
+
+ /* Insert the new element. */
+ set->elems[set->nelem++] = elem;
+ return true;
+}
+
+/* Compare two node sets SET1 and SET2.
+ Return true if SET1 and SET2 are equivalent. */
+
+static bool
+__attribute__ ((pure))
+re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
+{
+ Idx i;
+ if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
+ return false;
+ for (i = set1->nelem ; --i >= 0 ; )
+ if (set1->elems[i] != set2->elems[i])
+ return false;
+ return true;
+}
+
+/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
+
+static Idx
+__attribute__ ((pure))
+re_node_set_contains (const re_node_set *set, Idx elem)
+{
+ __re_size_t idx, right, mid;
+ if (set->nelem <= 0)
+ return 0;
+
+ /* Binary search the element. */
+ idx = 0;
+ right = set->nelem - 1;
+ while (idx < right)
+ {
+ mid = (idx + right) / 2;
+ if (set->elems[mid] < elem)
+ idx = mid + 1;
+ else
+ right = mid;
+ }
+ return set->elems[idx] == elem ? idx + 1 : 0;
+}
+
+static void
+re_node_set_remove_at (re_node_set *set, Idx idx)
+{
+ if (idx < 0 || idx >= set->nelem)
+ return;
+ --set->nelem;
+ for (; idx < set->nelem; idx++)
+ set->elems[idx] = set->elems[idx + 1];
+}
+
+
+/* Add the token TOKEN to dfa->nodes, and return the index of the token.
+ Or return -1 if an error occurred. */
+
+static Idx
+re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
+{
+ if (__glibc_unlikely (dfa->nodes_len >= dfa->nodes_alloc))
+ {
+ size_t new_nodes_alloc = dfa->nodes_alloc * 2;
+ Idx *new_nexts, *new_indices;
+ re_node_set *new_edests, *new_eclosures;
+ re_token_t *new_nodes;
+
+ /* Avoid overflows in realloc. */
+ const size_t max_object_size = MAX (sizeof (re_token_t),
+ MAX (sizeof (re_node_set),
+ sizeof (Idx)));
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size)
+ < new_nodes_alloc))
+ return -1;
+
+ new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
+ if (__glibc_unlikely (new_nodes == NULL))
+ return -1;
+ dfa->nodes = new_nodes;
+ new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc);
+ new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc);
+ new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
+ new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
+ if (__glibc_unlikely (new_nexts == NULL || new_indices == NULL
+ || new_edests == NULL || new_eclosures == NULL))
+ {
+ re_free (new_nexts);
+ re_free (new_indices);
+ re_free (new_edests);
+ re_free (new_eclosures);
+ return -1;
+ }
+ dfa->nexts = new_nexts;
+ dfa->org_indices = new_indices;
+ dfa->edests = new_edests;
+ dfa->eclosures = new_eclosures;
+ dfa->nodes_alloc = new_nodes_alloc;
+ }
+ dfa->nodes[dfa->nodes_len] = token;
+ dfa->nodes[dfa->nodes_len].constraint = 0;
+#ifdef RE_ENABLE_I18N
+ dfa->nodes[dfa->nodes_len].accept_mb =
+ ((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
+ || token.type == COMPLEX_BRACKET);
+#endif
+ dfa->nexts[dfa->nodes_len] = -1;
+ re_node_set_init_empty (dfa->edests + dfa->nodes_len);
+ re_node_set_init_empty (dfa->eclosures + dfa->nodes_len);
+ return dfa->nodes_len++;
+}
+
+static re_hashval_t
+calc_state_hash (const re_node_set *nodes, unsigned int context)
+{
+ re_hashval_t hash = nodes->nelem + context;
+ Idx i;
+ for (i = 0 ; i < nodes->nelem ; i++)
+ hash += nodes->elems[i];
+ return hash;
+}
+
+/* Search for the state whose node_set is equivalent to NODES.
+ Return the pointer to the state, if we found it in the DFA.
+ Otherwise create the new one and return it. In case of an error
+ return NULL and set the error code in ERR.
+ Note: - We assume NULL as the invalid state, then it is possible that
+ return value is NULL and ERR is REG_NOERROR.
+ - We never return non-NULL value in case of any errors, it is for
+ optimization. */
+
+static re_dfastate_t *
+__attribute_warn_unused_result__
+re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
+ const re_node_set *nodes)
+{
+ re_hashval_t hash;
+ re_dfastate_t *new_state;
+ struct re_state_table_entry *spot;
+ Idx i;
+#if defined GCC_LINT || defined lint
+ /* Suppress bogus uninitialized-variable warnings. */
+ *err = REG_NOERROR;
+#endif
+ if (__glibc_unlikely (nodes->nelem == 0))
+ {
+ *err = REG_NOERROR;
+ return NULL;
+ }
+ hash = calc_state_hash (nodes, 0);
+ spot = dfa->state_table + (hash & dfa->state_hash_mask);
+
+ for (i = 0 ; i < spot->num ; i++)
+ {
+ re_dfastate_t *state = spot->array[i];
+ if (hash != state->hash)
+ continue;
+ if (re_node_set_compare (&state->nodes, nodes))
+ return state;
+ }
+
+ /* There are no appropriate state in the dfa, create the new one. */
+ new_state = create_ci_newstate (dfa, nodes, hash);
+ if (__glibc_unlikely (new_state == NULL))
+ *err = REG_ESPACE;
+
+ return new_state;
+}
+
+/* Search for the state whose node_set is equivalent to NODES and
+ whose context is equivalent to CONTEXT.
+ Return the pointer to the state, if we found it in the DFA.
+ Otherwise create the new one and return it. In case of an error
+ return NULL and set the error code in ERR.
+ Note: - We assume NULL as the invalid state, then it is possible that
+ return value is NULL and ERR is REG_NOERROR.
+ - We never return non-NULL value in case of any errors, it is for
+ optimization. */
+
+static re_dfastate_t *
+__attribute_warn_unused_result__
+re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
+ const re_node_set *nodes, unsigned int context)
+{
+ re_hashval_t hash;
+ re_dfastate_t *new_state;
+ struct re_state_table_entry *spot;
+ Idx i;
+#if defined GCC_LINT || defined lint
+ /* Suppress bogus uninitialized-variable warnings. */
+ *err = REG_NOERROR;
+#endif
+ if (nodes->nelem == 0)
+ {
+ *err = REG_NOERROR;
+ return NULL;
+ }
+ hash = calc_state_hash (nodes, context);
+ spot = dfa->state_table + (hash & dfa->state_hash_mask);
+
+ for (i = 0 ; i < spot->num ; i++)
+ {
+ re_dfastate_t *state = spot->array[i];
+ if (state->hash == hash
+ && state->context == context
+ && re_node_set_compare (state->entrance_nodes, nodes))
+ return state;
+ }
+ /* There are no appropriate state in 'dfa', create the new one. */
+ new_state = create_cd_newstate (dfa, nodes, context, hash);
+ if (__glibc_unlikely (new_state == NULL))
+ *err = REG_ESPACE;
+
+ return new_state;
+}
+
+/* Finish initialization of the new state NEWSTATE, and using its hash value
+ HASH put in the appropriate bucket of DFA's state table. Return value
+ indicates the error code if failed. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
+ re_hashval_t hash)
+{
+ struct re_state_table_entry *spot;
+ reg_errcode_t err;
+ Idx i;
+
+ newstate->hash = hash;
+ err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return REG_ESPACE;
+ for (i = 0; i < newstate->nodes.nelem; i++)
+ {
+ Idx elem = newstate->nodes.elems[i];
+ if (!IS_EPSILON_NODE (dfa->nodes[elem].type))
+ if (! re_node_set_insert_last (&newstate->non_eps_nodes, elem))
+ return REG_ESPACE;
+ }
+
+ spot = dfa->state_table + (hash & dfa->state_hash_mask);
+ if (__glibc_unlikely (spot->alloc <= spot->num))
+ {
+ Idx new_alloc = 2 * spot->num + 2;
+ re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *,
+ new_alloc);
+ if (__glibc_unlikely (new_array == NULL))
+ return REG_ESPACE;
+ spot->array = new_array;
+ spot->alloc = new_alloc;
+ }
+ spot->array[spot->num++] = newstate;
+ return REG_NOERROR;
+}
+
+static void
+free_state (re_dfastate_t *state)
+{
+ re_node_set_free (&state->non_eps_nodes);
+ re_node_set_free (&state->inveclosure);
+ if (state->entrance_nodes != &state->nodes)
+ {
+ re_node_set_free (state->entrance_nodes);
+ re_free (state->entrance_nodes);
+ }
+ re_node_set_free (&state->nodes);
+ re_free (state->word_trtable);
+ re_free (state->trtable);
+ re_free (state);
+}
+
+/* Create the new state which is independent of contexts.
+ Return the new state if succeeded, otherwise return NULL. */
+
+static re_dfastate_t *
+__attribute_warn_unused_result__
+create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
+ re_hashval_t hash)
+{
+ Idx i;
+ reg_errcode_t err;
+ re_dfastate_t *newstate;
+
+ newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+ if (__glibc_unlikely (newstate == NULL))
+ return NULL;
+ err = re_node_set_init_copy (&newstate->nodes, nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_free (newstate);
+ return NULL;
+ }
+
+ newstate->entrance_nodes = &newstate->nodes;
+ for (i = 0 ; i < nodes->nelem ; i++)
+ {
+ re_token_t *node = dfa->nodes + nodes->elems[i];
+ re_token_type_t type = node->type;
+ if (type == CHARACTER && !node->constraint)
+ continue;
+#ifdef RE_ENABLE_I18N
+ newstate->accept_mb |= node->accept_mb;
+#endif /* RE_ENABLE_I18N */
+
+ /* If the state has the halt node, the state is a halt state. */
+ if (type == END_OF_RE)
+ newstate->halt = 1;
+ else if (type == OP_BACK_REF)
+ newstate->has_backref = 1;
+ else if (type == ANCHOR || node->constraint)
+ newstate->has_constraint = 1;
+ }
+ err = register_state (dfa, newstate, hash);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ free_state (newstate);
+ newstate = NULL;
+ }
+ return newstate;
+}
+
+/* Create the new state which is depend on the context CONTEXT.
+ Return the new state if succeeded, otherwise return NULL. */
+
+static re_dfastate_t *
+__attribute_warn_unused_result__
+create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
+ unsigned int context, re_hashval_t hash)
+{
+ Idx i, nctx_nodes = 0;
+ reg_errcode_t err;
+ re_dfastate_t *newstate;
+
+ newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+ if (__glibc_unlikely (newstate == NULL))
+ return NULL;
+ err = re_node_set_init_copy (&newstate->nodes, nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_free (newstate);
+ return NULL;
+ }
+
+ newstate->context = context;
+ newstate->entrance_nodes = &newstate->nodes;
+
+ for (i = 0 ; i < nodes->nelem ; i++)
+ {
+ re_token_t *node = dfa->nodes + nodes->elems[i];
+ re_token_type_t type = node->type;
+ unsigned int constraint = node->constraint;
+
+ if (type == CHARACTER && !constraint)
+ continue;
+#ifdef RE_ENABLE_I18N
+ newstate->accept_mb |= node->accept_mb;
+#endif /* RE_ENABLE_I18N */
+
+ /* If the state has the halt node, the state is a halt state. */
+ if (type == END_OF_RE)
+ newstate->halt = 1;
+ else if (type == OP_BACK_REF)
+ newstate->has_backref = 1;
+
+ if (constraint)
+ {
+ if (newstate->entrance_nodes == &newstate->nodes)
+ {
+ newstate->entrance_nodes = re_malloc (re_node_set, 1);
+ if (__glibc_unlikely (newstate->entrance_nodes == NULL))
+ {
+ free_state (newstate);
+ return NULL;
+ }
+ if (re_node_set_init_copy (newstate->entrance_nodes, nodes)
+ != REG_NOERROR)
+ return NULL;
+ nctx_nodes = 0;
+ newstate->has_constraint = 1;
+ }
+
+ if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
+ {
+ re_node_set_remove_at (&newstate->nodes, i - nctx_nodes);
+ ++nctx_nodes;
+ }
+ }
+ }
+ err = register_state (dfa, newstate, hash);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ free_state (newstate);
+ newstate = NULL;
+ }
+ return newstate;
+}
diff --git a/grub-core/lib/gnulib/regex_internal.h b/grub-core/lib/gnulib/regex_internal.h
new file mode 100644
index 0000000..a3aedda
--- /dev/null
+++ b/grub-core/lib/gnulib/regex_internal.h
@@ -0,0 +1,874 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 2002-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _REGEX_INTERNAL_H
+#define _REGEX_INTERNAL_H 1
+
+#include <assert.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <langinfo.h>
+#include <locale.h>
+#include <wchar.h>
+#include <wctype.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <intprops.h>
+
+#ifdef _LIBC
+# include <libc-lock.h>
+# define lock_define(name) __libc_lock_define (, name)
+# define lock_init(lock) (__libc_lock_init (lock), 0)
+# define lock_fini(lock) ((void) 0)
+# define lock_lock(lock) __libc_lock_lock (lock)
+# define lock_unlock(lock) __libc_lock_unlock (lock)
+#elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO
+# include "glthread/lock.h"
+ /* Use gl_lock_define if empty macro arguments are known to work.
+ Otherwise, fall back on less-portable substitutes. */
+# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \
+ || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__))
+# define lock_define(name) gl_lock_define (, name)
+# elif USE_POSIX_THREADS
+# define lock_define(name) pthread_mutex_t name;
+# elif USE_PTH_THREADS
+# define lock_define(name) pth_mutex_t name;
+# elif USE_SOLARIS_THREADS
+# define lock_define(name) mutex_t name;
+# elif USE_WINDOWS_THREADS
+# define lock_define(name) gl_lock_t name;
+# else
+# define lock_define(name)
+# endif
+# define lock_init(lock) glthread_lock_init (&(lock))
+# define lock_fini(lock) glthread_lock_destroy (&(lock))
+# define lock_lock(lock) glthread_lock_lock (&(lock))
+# define lock_unlock(lock) glthread_lock_unlock (&(lock))
+#elif defined GNULIB_PTHREAD && !defined USE_UNLOCKED_IO
+# include <pthread.h>
+# define lock_define(name) pthread_mutex_t name;
+# define lock_init(lock) pthread_mutex_init (&(lock), 0)
+# define lock_fini(lock) pthread_mutex_destroy (&(lock))
+# define lock_lock(lock) pthread_mutex_lock (&(lock))
+# define lock_unlock(lock) pthread_mutex_unlock (&(lock))
+#else
+# define lock_define(name)
+# define lock_init(lock) 0
+# define lock_fini(lock) ((void) 0)
+ /* The 'dfa' avoids an "unused variable 'dfa'" warning from GCC. */
+# define lock_lock(lock) ((void) dfa)
+# define lock_unlock(lock) ((void) 0)
+#endif
+
+/* In case that the system doesn't have isblank(). */
+#if !defined _LIBC && ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK))
+# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
+#endif
+
+#ifdef _LIBC
+# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
+# define _RE_DEFINE_LOCALE_FUNCTIONS 1
+# include <locale/localeinfo.h>
+# include <locale/coll-lookup.h>
+# endif
+#endif
+
+/* This is for other GNU distributions with internationalized messages. */
+#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
+# include <libintl.h>
+# ifdef _LIBC
+# undef gettext
+# define gettext(msgid) \
+ __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
+# endif
+#else
+# undef gettext
+# define gettext(msgid) (msgid)
+#endif
+
+#ifndef gettext_noop
+/* This define is so xgettext can find the internationalizable
+ strings. */
+# define gettext_noop(String) String
+#endif
+
+#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE) || _LIBC
+# define RE_ENABLE_I18N
+#endif
+
+/* Number of ASCII characters. */
+#define ASCII_CHARS 0x80
+
+/* Number of single byte characters. */
+#define SBC_MAX (UCHAR_MAX + 1)
+
+#define COLL_ELEM_LEN_MAX 8
+
+/* The character which represents newline. */
+#define NEWLINE_CHAR '\n'
+#define WIDE_NEWLINE_CHAR L'\n'
+
+/* Rename to standard API for using out of glibc. */
+#ifndef _LIBC
+# undef __wctype
+# undef __iswalnum
+# undef __iswctype
+# undef __towlower
+# undef __towupper
+# define __wctype wctype
+# define __iswalnum iswalnum
+# define __iswctype iswctype
+# define __towlower towlower
+# define __towupper towupper
+# define __btowc btowc
+# define __mbrtowc mbrtowc
+# define __wcrtomb wcrtomb
+# define __regfree regfree
+#endif /* not _LIBC */
+
+#ifndef SSIZE_MAX
+# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
+#endif
+
+/* The type of indexes into strings. This is signed, not size_t,
+ since the API requires indexes to fit in regoff_t anyway, and using
+ signed integers makes the code a bit smaller and presumably faster.
+ The traditional GNU regex implementation uses int for indexes.
+ The POSIX-compatible implementation uses a possibly-wider type.
+ The name 'Idx' is three letters to minimize the hassle of
+ reindenting a lot of regex code that formerly used 'int'. */
+typedef regoff_t Idx;
+#ifdef _REGEX_LARGE_OFFSETS
+# define IDX_MAX SSIZE_MAX
+#else
+# define IDX_MAX INT_MAX
+#endif
+
+/* A hash value, suitable for computing hash tables. */
+typedef __re_size_t re_hashval_t;
+
+/* An integer used to represent a set of bits. It must be unsigned,
+ and must be at least as wide as unsigned int. */
+typedef unsigned long int bitset_word_t;
+/* All bits set in a bitset_word_t. */
+#define BITSET_WORD_MAX ULONG_MAX
+
+/* Number of bits in a bitset_word_t. For portability to hosts with
+ padding bits, do not use '(sizeof (bitset_word_t) * CHAR_BIT)';
+ instead, deduce it directly from BITSET_WORD_MAX. Avoid
+ greater-than-32-bit integers and unconditional shifts by more than
+ 31 bits, as they're not portable. */
+#if BITSET_WORD_MAX == 0xffffffffUL
+# define BITSET_WORD_BITS 32
+#elif BITSET_WORD_MAX >> 31 >> 4 == 1
+# define BITSET_WORD_BITS 36
+#elif BITSET_WORD_MAX >> 31 >> 16 == 1
+# define BITSET_WORD_BITS 48
+#elif BITSET_WORD_MAX >> 31 >> 28 == 1
+# define BITSET_WORD_BITS 60
+#elif BITSET_WORD_MAX >> 31 >> 31 >> 1 == 1
+# define BITSET_WORD_BITS 64
+#elif BITSET_WORD_MAX >> 31 >> 31 >> 9 == 1
+# define BITSET_WORD_BITS 72
+#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 3 == 1
+# define BITSET_WORD_BITS 128
+#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 == 1
+# define BITSET_WORD_BITS 256
+#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 > 1
+# define BITSET_WORD_BITS 257 /* any value > SBC_MAX will do here */
+# if BITSET_WORD_BITS <= SBC_MAX
+# error "Invalid SBC_MAX"
+# endif
+#else
+# error "Add case for new bitset_word_t size"
+#endif
+
+/* Number of bitset_word_t values in a bitset_t. */
+#define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
+
+typedef bitset_word_t bitset_t[BITSET_WORDS];
+typedef bitset_word_t *re_bitset_ptr_t;
+typedef const bitset_word_t *re_const_bitset_ptr_t;
+
+#define PREV_WORD_CONSTRAINT 0x0001
+#define PREV_NOTWORD_CONSTRAINT 0x0002
+#define NEXT_WORD_CONSTRAINT 0x0004
+#define NEXT_NOTWORD_CONSTRAINT 0x0008
+#define PREV_NEWLINE_CONSTRAINT 0x0010
+#define NEXT_NEWLINE_CONSTRAINT 0x0020
+#define PREV_BEGBUF_CONSTRAINT 0x0040
+#define NEXT_ENDBUF_CONSTRAINT 0x0080
+#define WORD_DELIM_CONSTRAINT 0x0100
+#define NOT_WORD_DELIM_CONSTRAINT 0x0200
+
+typedef enum
+{
+ INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
+ WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
+ WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
+ INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
+ LINE_FIRST = PREV_NEWLINE_CONSTRAINT,
+ LINE_LAST = NEXT_NEWLINE_CONSTRAINT,
+ BUF_FIRST = PREV_BEGBUF_CONSTRAINT,
+ BUF_LAST = NEXT_ENDBUF_CONSTRAINT,
+ WORD_DELIM = WORD_DELIM_CONSTRAINT,
+ NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT
+} re_context_type;
+
+typedef struct
+{
+ Idx alloc;
+ Idx nelem;
+ Idx *elems;
+} re_node_set;
+
+typedef enum
+{
+ NON_TYPE = 0,
+
+ /* Node type, These are used by token, node, tree. */
+ CHARACTER = 1,
+ END_OF_RE = 2,
+ SIMPLE_BRACKET = 3,
+ OP_BACK_REF = 4,
+ OP_PERIOD = 5,
+#ifdef RE_ENABLE_I18N
+ COMPLEX_BRACKET = 6,
+ OP_UTF8_PERIOD = 7,
+#endif /* RE_ENABLE_I18N */
+
+ /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
+ when the debugger shows values of this enum type. */
+#define EPSILON_BIT 8
+ OP_OPEN_SUBEXP = EPSILON_BIT | 0,
+ OP_CLOSE_SUBEXP = EPSILON_BIT | 1,
+ OP_ALT = EPSILON_BIT | 2,
+ OP_DUP_ASTERISK = EPSILON_BIT | 3,
+ ANCHOR = EPSILON_BIT | 4,
+
+ /* Tree type, these are used only by tree. */
+ CONCAT = 16,
+ SUBEXP = 17,
+
+ /* Token type, these are used only by token. */
+ OP_DUP_PLUS = 18,
+ OP_DUP_QUESTION,
+ OP_OPEN_BRACKET,
+ OP_CLOSE_BRACKET,
+ OP_CHARSET_RANGE,
+ OP_OPEN_DUP_NUM,
+ OP_CLOSE_DUP_NUM,
+ OP_NON_MATCH_LIST,
+ OP_OPEN_COLL_ELEM,
+ OP_CLOSE_COLL_ELEM,
+ OP_OPEN_EQUIV_CLASS,
+ OP_CLOSE_EQUIV_CLASS,
+ OP_OPEN_CHAR_CLASS,
+ OP_CLOSE_CHAR_CLASS,
+ OP_WORD,
+ OP_NOTWORD,
+ OP_SPACE,
+ OP_NOTSPACE,
+ BACK_SLASH
+
+} re_token_type_t;
+
+#ifdef RE_ENABLE_I18N
+typedef struct
+{
+ /* Multibyte characters. */
+ wchar_t *mbchars;
+
+ /* Collating symbols. */
+# ifdef _LIBC
+ int32_t *coll_syms;
+# endif
+
+ /* Equivalence classes. */
+# ifdef _LIBC
+ int32_t *equiv_classes;
+# endif
+
+ /* Range expressions. */
+# ifdef _LIBC
+ uint32_t *range_starts;
+ uint32_t *range_ends;
+# else /* not _LIBC */
+ wchar_t *range_starts;
+ wchar_t *range_ends;
+# endif /* not _LIBC */
+
+ /* Character classes. */
+ wctype_t *char_classes;
+
+ /* If this character set is the non-matching list. */
+ unsigned int non_match : 1;
+
+ /* # of multibyte characters. */
+ Idx nmbchars;
+
+ /* # of collating symbols. */
+ Idx ncoll_syms;
+
+ /* # of equivalence classes. */
+ Idx nequiv_classes;
+
+ /* # of range expressions. */
+ Idx nranges;
+
+ /* # of character classes. */
+ Idx nchar_classes;
+} re_charset_t;
+#endif /* RE_ENABLE_I18N */
+
+typedef struct
+{
+ union
+ {
+ unsigned char c; /* for CHARACTER */
+ re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */
+#ifdef RE_ENABLE_I18N
+ re_charset_t *mbcset; /* for COMPLEX_BRACKET */
+#endif /* RE_ENABLE_I18N */
+ Idx idx; /* for BACK_REF */
+ re_context_type ctx_type; /* for ANCHOR */
+ } opr;
+#if __GNUC__ >= 2 && !defined __STRICT_ANSI__
+ re_token_type_t type : 8;
+#else
+ re_token_type_t type;
+#endif
+ unsigned int constraint : 10; /* context constraint */
+ unsigned int duplicated : 1;
+ unsigned int opt_subexp : 1;
+#ifdef RE_ENABLE_I18N
+ unsigned int accept_mb : 1;
+ /* These 2 bits can be moved into the union if needed (e.g. if running out
+ of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */
+ unsigned int mb_partial : 1;
+#endif
+ unsigned int word_char : 1;
+} re_token_t;
+
+#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT)
+
+struct re_string_t
+{
+ /* Indicate the raw buffer which is the original string passed as an
+ argument of regexec(), re_search(), etc.. */
+ const unsigned char *raw_mbs;
+ /* Store the multibyte string. In case of "case insensitive mode" like
+ REG_ICASE, upper cases of the string are stored, otherwise MBS points
+ the same address that RAW_MBS points. */
+ unsigned char *mbs;
+#ifdef RE_ENABLE_I18N
+ /* Store the wide character string which is corresponding to MBS. */
+ wint_t *wcs;
+ Idx *offsets;
+ mbstate_t cur_state;
+#endif
+ /* Index in RAW_MBS. Each character mbs[i] corresponds to
+ raw_mbs[raw_mbs_idx + i]. */
+ Idx raw_mbs_idx;
+ /* The length of the valid characters in the buffers. */
+ Idx valid_len;
+ /* The corresponding number of bytes in raw_mbs array. */
+ Idx valid_raw_len;
+ /* The length of the buffers MBS and WCS. */
+ Idx bufs_len;
+ /* The index in MBS, which is updated by re_string_fetch_byte. */
+ Idx cur_idx;
+ /* length of RAW_MBS array. */
+ Idx raw_len;
+ /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */
+ Idx len;
+ /* End of the buffer may be shorter than its length in the cases such
+ as re_match_2, re_search_2. Then, we use STOP for end of the buffer
+ instead of LEN. */
+ Idx raw_stop;
+ /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */
+ Idx stop;
+
+ /* The context of mbs[0]. We store the context independently, since
+ the context of mbs[0] may be different from raw_mbs[0], which is
+ the beginning of the input string. */
+ unsigned int tip_context;
+ /* The translation passed as a part of an argument of re_compile_pattern. */
+ RE_TRANSLATE_TYPE trans;
+ /* Copy of re_dfa_t's word_char. */
+ re_const_bitset_ptr_t word_char;
+ /* true if REG_ICASE. */
+ unsigned char icase;
+ unsigned char is_utf8;
+ unsigned char map_notascii;
+ unsigned char mbs_allocated;
+ unsigned char offsets_needed;
+ unsigned char newline_anchor;
+ unsigned char word_ops_used;
+ int mb_cur_max;
+};
+typedef struct re_string_t re_string_t;
+
+
+struct re_dfa_t;
+typedef struct re_dfa_t re_dfa_t;
+
+#ifndef _LIBC
+# define IS_IN(libc) false
+#endif
+
+#define re_string_peek_byte(pstr, offset) \
+ ((pstr)->mbs[(pstr)->cur_idx + offset])
+#define re_string_fetch_byte(pstr) \
+ ((pstr)->mbs[(pstr)->cur_idx++])
+#define re_string_first_byte(pstr, idx) \
+ ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF)
+#define re_string_is_single_byte_char(pstr, idx) \
+ ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \
+ || (pstr)->wcs[(idx) + 1] != WEOF))
+#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx)
+#define re_string_cur_idx(pstr) ((pstr)->cur_idx)
+#define re_string_get_buffer(pstr) ((pstr)->mbs)
+#define re_string_length(pstr) ((pstr)->len)
+#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx])
+#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
+#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
+
+#if defined _LIBC || HAVE_ALLOCA
+# include <alloca.h>
+#endif
+
+#ifndef _LIBC
+# if HAVE_ALLOCA
+/* The OS usually guarantees only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ allocate anything larger than 4096 bytes. Also care for the possibility
+ of a few compiler-allocated temporary stack slots. */
+# define __libc_use_alloca(n) ((n) < 4032)
+# else
+/* alloca is implemented with malloc, so just use malloc. */
+# define __libc_use_alloca(n) 0
+# undef alloca
+# define alloca(n) malloc (n)
+# endif
+#endif
+
+#ifdef _LIBC
+# define MALLOC_0_IS_NONNULL 1
+#elif !defined MALLOC_0_IS_NONNULL
+# define MALLOC_0_IS_NONNULL 0
+#endif
+
+#ifndef MAX
+# define MAX(a,b) ((a) < (b) ? (b) : (a))
+#endif
+#ifndef MIN
+# define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
+#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
+#define re_free(p) free (p)
+
+struct bin_tree_t
+{
+ struct bin_tree_t *parent;
+ struct bin_tree_t *left;
+ struct bin_tree_t *right;
+ struct bin_tree_t *first;
+ struct bin_tree_t *next;
+
+ re_token_t token;
+
+ /* 'node_idx' is the index in dfa->nodes, if 'type' == 0.
+ Otherwise 'type' indicate the type of this node. */
+ Idx node_idx;
+};
+typedef struct bin_tree_t bin_tree_t;
+
+#define BIN_TREE_STORAGE_SIZE \
+ ((1024 - sizeof (void *)) / sizeof (bin_tree_t))
+
+struct bin_tree_storage_t
+{
+ struct bin_tree_storage_t *next;
+ bin_tree_t data[BIN_TREE_STORAGE_SIZE];
+};
+typedef struct bin_tree_storage_t bin_tree_storage_t;
+
+#define CONTEXT_WORD 1
+#define CONTEXT_NEWLINE (CONTEXT_WORD << 1)
+#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1)
+#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1)
+
+#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD)
+#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE)
+#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF)
+#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF)
+#define IS_ORDINARY_CONTEXT(c) ((c) == 0)
+
+#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_')
+#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR)
+#define IS_WIDE_WORD_CHAR(ch) (__iswalnum (ch) || (ch) == L'_')
+#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
+
+#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
+ ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
+ || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
+ || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\
+ || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context)))
+
+#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \
+ ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
+ || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
+ || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \
+ || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context)))
+
+struct re_dfastate_t
+{
+ re_hashval_t hash;
+ re_node_set nodes;
+ re_node_set non_eps_nodes;
+ re_node_set inveclosure;
+ re_node_set *entrance_nodes;
+ struct re_dfastate_t **trtable, **word_trtable;
+ unsigned int context : 4;
+ unsigned int halt : 1;
+ /* If this state can accept "multi byte".
+ Note that we refer to multibyte characters, and multi character
+ collating elements as "multi byte". */
+ unsigned int accept_mb : 1;
+ /* If this state has backreference node(s). */
+ unsigned int has_backref : 1;
+ unsigned int has_constraint : 1;
+};
+typedef struct re_dfastate_t re_dfastate_t;
+
+struct re_state_table_entry
+{
+ Idx num;
+ Idx alloc;
+ re_dfastate_t **array;
+};
+
+/* Array type used in re_sub_match_last_t and re_sub_match_top_t. */
+
+typedef struct
+{
+ Idx next_idx;
+ Idx alloc;
+ re_dfastate_t **array;
+} state_array_t;
+
+/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */
+
+typedef struct
+{
+ Idx node;
+ Idx str_idx; /* The position NODE match at. */
+ state_array_t path;
+} re_sub_match_last_t;
+
+/* Store information about the node NODE whose type is OP_OPEN_SUBEXP.
+ And information about the node, whose type is OP_CLOSE_SUBEXP,
+ corresponding to NODE is stored in LASTS. */
+
+typedef struct
+{
+ Idx str_idx;
+ Idx node;
+ state_array_t *path;
+ Idx alasts; /* Allocation size of LASTS. */
+ Idx nlasts; /* The number of LASTS. */
+ re_sub_match_last_t **lasts;
+} re_sub_match_top_t;
+
+struct re_backref_cache_entry
+{
+ Idx node;
+ Idx str_idx;
+ Idx subexp_from;
+ Idx subexp_to;
+ char more;
+ char unused;
+ unsigned short int eps_reachable_subexps_map;
+};
+
+typedef struct
+{
+ /* The string object corresponding to the input string. */
+ re_string_t input;
+#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
+ const re_dfa_t *const dfa;
+#else
+ const re_dfa_t *dfa;
+#endif
+ /* EFLAGS of the argument of regexec. */
+ int eflags;
+ /* Where the matching ends. */
+ Idx match_last;
+ Idx last_node;
+ /* The state log used by the matcher. */
+ re_dfastate_t **state_log;
+ Idx state_log_top;
+ /* Back reference cache. */
+ Idx nbkref_ents;
+ Idx abkref_ents;
+ struct re_backref_cache_entry *bkref_ents;
+ int max_mb_elem_len;
+ Idx nsub_tops;
+ Idx asub_tops;
+ re_sub_match_top_t **sub_tops;
+} re_match_context_t;
+
+typedef struct
+{
+ re_dfastate_t **sifted_states;
+ re_dfastate_t **limited_states;
+ Idx last_node;
+ Idx last_str_idx;
+ re_node_set limits;
+} re_sift_context_t;
+
+struct re_fail_stack_ent_t
+{
+ Idx idx;
+ Idx node;
+ regmatch_t *regs;
+ re_node_set eps_via_nodes;
+};
+
+struct re_fail_stack_t
+{
+ Idx num;
+ Idx alloc;
+ struct re_fail_stack_ent_t *stack;
+};
+
+struct re_dfa_t
+{
+ re_token_t *nodes;
+ size_t nodes_alloc;
+ size_t nodes_len;
+ Idx *nexts;
+ Idx *org_indices;
+ re_node_set *edests;
+ re_node_set *eclosures;
+ re_node_set *inveclosures;
+ struct re_state_table_entry *state_table;
+ re_dfastate_t *init_state;
+ re_dfastate_t *init_state_word;
+ re_dfastate_t *init_state_nl;
+ re_dfastate_t *init_state_begbuf;
+ bin_tree_t *str_tree;
+ bin_tree_storage_t *str_tree_storage;
+ re_bitset_ptr_t sb_char;
+ int str_tree_storage_idx;
+
+ /* number of subexpressions 're_nsub' is in regex_t. */
+ re_hashval_t state_hash_mask;
+ Idx init_node;
+ Idx nbackref; /* The number of backreference in this dfa. */
+
+ /* Bitmap expressing which backreference is used. */
+ bitset_word_t used_bkref_map;
+ bitset_word_t completed_bkref_map;
+
+ unsigned int has_plural_match : 1;
+ /* If this dfa has "multibyte node", which is a backreference or
+ a node which can accept multibyte character or multi character
+ collating element. */
+ unsigned int has_mb_node : 1;
+ unsigned int is_utf8 : 1;
+ unsigned int map_notascii : 1;
+ unsigned int word_ops_used : 1;
+ int mb_cur_max;
+ bitset_t word_char;
+ reg_syntax_t syntax;
+ Idx *subexp_map;
+#ifdef DEBUG
+ char* re_str;
+#endif
+ lock_define (lock)
+};
+
+#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
+#define re_node_set_remove(set,id) \
+ (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1))
+#define re_node_set_empty(p) ((p)->nelem = 0)
+#define re_node_set_free(set) re_free ((set)->elems)
+
+
+typedef enum
+{
+ SB_CHAR,
+ MB_CHAR,
+ EQUIV_CLASS,
+ COLL_SYM,
+ CHAR_CLASS
+} bracket_elem_type;
+
+typedef struct
+{
+ bracket_elem_type type;
+ union
+ {
+ unsigned char ch;
+ unsigned char *name;
+ wchar_t wch;
+ } opr;
+} bracket_elem_t;
+
+
+/* Functions for bitset_t operation. */
+
+static inline void
+bitset_set (bitset_t set, Idx i)
+{
+ set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS;
+}
+
+static inline void
+bitset_clear (bitset_t set, Idx i)
+{
+ set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS);
+}
+
+static inline bool
+bitset_contain (const bitset_t set, Idx i)
+{
+ return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1;
+}
+
+static inline void
+bitset_empty (bitset_t set)
+{
+ memset (set, '\0', sizeof (bitset_t));
+}
+
+static inline void
+bitset_set_all (bitset_t set)
+{
+ memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS));
+ if (SBC_MAX % BITSET_WORD_BITS != 0)
+ set[BITSET_WORDS - 1] =
+ ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1;
+}
+
+static inline void
+bitset_copy (bitset_t dest, const bitset_t src)
+{
+ memcpy (dest, src, sizeof (bitset_t));
+}
+
+static inline void
+bitset_not (bitset_t set)
+{
+ int bitset_i;
+ for (bitset_i = 0; bitset_i < SBC_MAX / BITSET_WORD_BITS; ++bitset_i)
+ set[bitset_i] = ~set[bitset_i];
+ if (SBC_MAX % BITSET_WORD_BITS != 0)
+ set[BITSET_WORDS - 1] =
+ ((((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1)
+ & ~set[BITSET_WORDS - 1]);
+}
+
+static inline void
+bitset_merge (bitset_t dest, const bitset_t src)
+{
+ int bitset_i;
+ for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
+ dest[bitset_i] |= src[bitset_i];
+}
+
+static inline void
+bitset_mask (bitset_t dest, const bitset_t src)
+{
+ int bitset_i;
+ for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
+ dest[bitset_i] &= src[bitset_i];
+}
+
+#ifdef RE_ENABLE_I18N
+/* Functions for re_string. */
+static int
+__attribute__ ((pure, unused))
+re_string_char_size_at (const re_string_t *pstr, Idx idx)
+{
+ int byte_idx;
+ if (pstr->mb_cur_max == 1)
+ return 1;
+ for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx)
+ if (pstr->wcs[idx + byte_idx] != WEOF)
+ break;
+ return byte_idx;
+}
+
+static wint_t
+__attribute__ ((pure, unused))
+re_string_wchar_at (const re_string_t *pstr, Idx idx)
+{
+ if (pstr->mb_cur_max == 1)
+ return (wint_t) pstr->mbs[idx];
+ return (wint_t) pstr->wcs[idx];
+}
+
+# ifdef _LIBC
+# include <locale/weight.h>
+# endif
+
+static int
+__attribute__ ((pure, unused))
+re_string_elem_size_at (const re_string_t *pstr, Idx idx)
+{
+# ifdef _LIBC
+ const unsigned char *p, *extra;
+ const int32_t *table, *indirect;
+ uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+
+ if (nrules != 0)
+ {
+ table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
+ indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_INDIRECTMB);
+ p = pstr->mbs + idx;
+ findidx (table, indirect, extra, &p, pstr->len - idx);
+ return p - pstr->mbs - idx;
+ }
+ else
+# endif /* _LIBC */
+ return 1;
+}
+#endif /* RE_ENABLE_I18N */
+
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
+#endif /* _REGEX_INTERNAL_H */
diff --git a/grub-core/lib/gnulib/regexec.c b/grub-core/lib/gnulib/regexec.c
new file mode 100644
index 0000000..be787f0
--- /dev/null
+++ b/grub-core/lib/gnulib/regexec.c
@@ -0,0 +1,4341 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 2002-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
+ Idx n);
+static void match_ctx_clean (re_match_context_t *mctx);
+static void match_ctx_free (re_match_context_t *cache);
+static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node,
+ Idx str_idx, Idx from, Idx to);
+static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx);
+static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node,
+ Idx str_idx);
+static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop,
+ Idx node, Idx str_idx);
+static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
+ re_dfastate_t **limited_sts, Idx last_node,
+ Idx last_str_idx);
+static reg_errcode_t re_search_internal (const regex_t *preg,
+ const char *string, Idx length,
+ Idx start, Idx last_start, Idx stop,
+ size_t nmatch, regmatch_t pmatch[],
+ int eflags);
+static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp,
+ const char *string1, Idx length1,
+ const char *string2, Idx length2,
+ Idx start, regoff_t range,
+ struct re_registers *regs,
+ Idx stop, bool ret_len);
+static regoff_t re_search_stub (struct re_pattern_buffer *bufp,
+ const char *string, Idx length, Idx start,
+ regoff_t range, Idx stop,
+ struct re_registers *regs,
+ bool ret_len);
+static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
+ Idx nregs, int regs_allocated);
+static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx);
+static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match,
+ Idx *p_match_first);
+static Idx check_halt_state_context (const re_match_context_t *mctx,
+ const re_dfastate_t *state, Idx idx);
+static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
+ regmatch_t *prev_idx_match, Idx cur_node,
+ Idx cur_idx, Idx nmatch);
+static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs,
+ Idx str_idx, Idx dest_node, Idx nregs,
+ regmatch_t *regs,
+ re_node_set *eps_via_nodes);
+static reg_errcode_t set_regs (const regex_t *preg,
+ const re_match_context_t *mctx,
+ size_t nmatch, regmatch_t *pmatch,
+ bool fl_backtrack);
+static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs);
+
+#ifdef RE_ENABLE_I18N
+static int sift_states_iter_mb (const re_match_context_t *mctx,
+ re_sift_context_t *sctx,
+ Idx node_idx, Idx str_idx, Idx max_str_idx);
+#endif /* RE_ENABLE_I18N */
+static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
+ re_sift_context_t *sctx);
+static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
+ re_sift_context_t *sctx, Idx str_idx,
+ re_node_set *cur_dest);
+static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx,
+ re_sift_context_t *sctx,
+ Idx str_idx,
+ re_node_set *dest_nodes);
+static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa,
+ re_node_set *dest_nodes,
+ const re_node_set *candidates);
+static bool check_dst_limits (const re_match_context_t *mctx,
+ const re_node_set *limits,
+ Idx dst_node, Idx dst_idx, Idx src_node,
+ Idx src_idx);
+static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx,
+ int boundaries, Idx subexp_idx,
+ Idx from_node, Idx bkref_idx);
+static int check_dst_limits_calc_pos (const re_match_context_t *mctx,
+ Idx limit, Idx subexp_idx,
+ Idx node, Idx str_idx,
+ Idx bkref_idx);
+static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa,
+ re_node_set *dest_nodes,
+ const re_node_set *candidates,
+ re_node_set *limits,
+ struct re_backref_cache_entry *bkref_ents,
+ Idx str_idx);
+static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx,
+ re_sift_context_t *sctx,
+ Idx str_idx, const re_node_set *candidates);
+static reg_errcode_t merge_state_array (const re_dfa_t *dfa,
+ re_dfastate_t **dst,
+ re_dfastate_t **src, Idx num);
+static re_dfastate_t *find_recover_state (reg_errcode_t *err,
+ re_match_context_t *mctx);
+static re_dfastate_t *transit_state (reg_errcode_t *err,
+ re_match_context_t *mctx,
+ re_dfastate_t *state);
+static re_dfastate_t *merge_state_with_log (reg_errcode_t *err,
+ re_match_context_t *mctx,
+ re_dfastate_t *next_state);
+static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx,
+ re_node_set *cur_nodes,
+ Idx str_idx);
+#if 0
+static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
+ re_match_context_t *mctx,
+ re_dfastate_t *pstate);
+#endif
+#ifdef RE_ENABLE_I18N
+static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
+ re_dfastate_t *pstate);
+#endif /* RE_ENABLE_I18N */
+static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
+ const re_node_set *nodes);
+static reg_errcode_t get_subexp (re_match_context_t *mctx,
+ Idx bkref_node, Idx bkref_str_idx);
+static reg_errcode_t get_subexp_sub (re_match_context_t *mctx,
+ const re_sub_match_top_t *sub_top,
+ re_sub_match_last_t *sub_last,
+ Idx bkref_node, Idx bkref_str);
+static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
+ Idx subexp_idx, int type);
+static reg_errcode_t check_arrival (re_match_context_t *mctx,
+ state_array_t *path, Idx top_node,
+ Idx top_str, Idx last_node, Idx last_str,
+ int type);
+static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx,
+ Idx str_idx,
+ re_node_set *cur_nodes,
+ re_node_set *next_nodes);
+static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa,
+ re_node_set *cur_nodes,
+ Idx ex_subexp, int type);
+static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa,
+ re_node_set *dst_nodes,
+ Idx target, Idx ex_subexp,
+ int type);
+static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
+ re_node_set *cur_nodes, Idx cur_str,
+ Idx subexp_num, int type);
+static bool build_trtable (const re_dfa_t *dfa, re_dfastate_t *state);
+#ifdef RE_ENABLE_I18N
+static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
+ const re_string_t *input, Idx idx);
+# ifdef _LIBC
+static unsigned int find_collation_sequence_value (const unsigned char *mbs,
+ size_t name_len);
+# endif /* _LIBC */
+#endif /* RE_ENABLE_I18N */
+static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
+ const re_dfastate_t *state,
+ re_node_set *states_node,
+ bitset_t *states_ch);
+static bool check_node_accept (const re_match_context_t *mctx,
+ const re_token_t *node, Idx idx);
+static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len);
+
+/* Entry point for POSIX code. */
+
+/* regexec searches for a given pattern, specified by PREG, in the
+ string STRING.
+
+ If NMATCH is zero or REG_NOSUB was set in the cflags argument to
+ 'regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at
+ least NMATCH elements, and we set them to the offsets of the
+ corresponding matched substrings.
+
+ EFLAGS specifies "execution flags" which affect matching: if
+ REG_NOTBOL is set, then ^ does not match at the beginning of the
+ string; if REG_NOTEOL is set, then $ does not match at the end.
+
+ We return 0 if we find a match and REG_NOMATCH if not. */
+
+int
+regexec (const regex_t *__restrict preg, const char *__restrict string,
+ size_t nmatch, regmatch_t pmatch[], int eflags)
+{
+ reg_errcode_t err;
+ Idx start, length;
+ re_dfa_t *dfa = preg->buffer;
+
+ if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
+ return REG_BADPAT;
+
+ if (eflags & REG_STARTEND)
+ {
+ start = pmatch[0].rm_so;
+ length = pmatch[0].rm_eo;
+ }
+ else
+ {
+ start = 0;
+ length = strlen (string);
+ }
+
+ lock_lock (dfa->lock);
+ if (preg->no_sub)
+ err = re_search_internal (preg, string, length, start, length,
+ length, 0, NULL, eflags);
+ else
+ err = re_search_internal (preg, string, length, start, length,
+ length, nmatch, pmatch, eflags);
+ lock_unlock (dfa->lock);
+ return err != REG_NOERROR;
+}
+
+#ifdef _LIBC
+libc_hidden_def (__regexec)
+
+# include <shlib-compat.h>
+versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4);
+
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
+__typeof__ (__regexec) __compat_regexec;
+
+int
+attribute_compat_text_section
+__compat_regexec (const regex_t *__restrict preg,
+ const char *__restrict string, size_t nmatch,
+ regmatch_t pmatch[], int eflags)
+{
+ return regexec (preg, string, nmatch, pmatch,
+ eflags & (REG_NOTBOL | REG_NOTEOL));
+}
+compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
+# endif
+#endif
+
+/* Entry points for GNU code. */
+
+/* re_match, re_search, re_match_2, re_search_2
+
+ The former two functions operate on STRING with length LENGTH,
+ while the later two operate on concatenation of STRING1 and STRING2
+ with lengths LENGTH1 and LENGTH2, respectively.
+
+ re_match() matches the compiled pattern in BUFP against the string,
+ starting at index START.
+
+ re_search() first tries matching at index START, then it tries to match
+ starting from index START + 1, and so on. The last start position tried
+ is START + RANGE. (Thus RANGE = 0 forces re_search to operate the same
+ way as re_match().)
+
+ The parameter STOP of re_{match,search}_2 specifies that no match exceeding
+ the first STOP characters of the concatenation of the strings should be
+ concerned.
+
+ If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match
+ and all groups is stored in REGS. (For the "_2" variants, the offsets are
+ computed relative to the concatenation, not relative to the individual
+ strings.)
+
+ On success, re_match* functions return the length of the match, re_search*
+ return the position of the start of the match. Return value -1 means no
+ match was found and -2 indicates an internal error. */
+
+regoff_t
+re_match (struct re_pattern_buffer *bufp, const char *string, Idx length,
+ Idx start, struct re_registers *regs)
+{
+ return re_search_stub (bufp, string, length, start, 0, length, regs, true);
+}
+#ifdef _LIBC
+weak_alias (__re_match, re_match)
+#endif
+
+regoff_t
+re_search (struct re_pattern_buffer *bufp, const char *string, Idx length,
+ Idx start, regoff_t range, struct re_registers *regs)
+{
+ return re_search_stub (bufp, string, length, start, range, length, regs,
+ false);
+}
+#ifdef _LIBC
+weak_alias (__re_search, re_search)
+#endif
+
+regoff_t
+re_match_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1,
+ const char *string2, Idx length2, Idx start,
+ struct re_registers *regs, Idx stop)
+{
+ return re_search_2_stub (bufp, string1, length1, string2, length2,
+ start, 0, regs, stop, true);
+}
+#ifdef _LIBC
+weak_alias (__re_match_2, re_match_2)
+#endif
+
+regoff_t
+re_search_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1,
+ const char *string2, Idx length2, Idx start, regoff_t range,
+ struct re_registers *regs, Idx stop)
+{
+ return re_search_2_stub (bufp, string1, length1, string2, length2,
+ start, range, regs, stop, false);
+}
+#ifdef _LIBC
+weak_alias (__re_search_2, re_search_2)
+#endif
+
+static regoff_t
+re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
+ Idx length1, const char *string2, Idx length2, Idx start,
+ regoff_t range, struct re_registers *regs,
+ Idx stop, bool ret_len)
+{
+ const char *str;
+ regoff_t rval;
+ Idx len;
+ char *s = NULL;
+
+ if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0
+ || INT_ADD_WRAPV (length1, length2, &len))))
+ return -2;
+
+ /* Concatenate the strings. */
+ if (length2 > 0)
+ if (length1 > 0)
+ {
+ s = re_malloc (char, len);
+
+ if (__glibc_unlikely (s == NULL))
+ return -2;
+#ifdef _LIBC
+ memcpy (__mempcpy (s, string1, length1), string2, length2);
+#else
+ memcpy (s, string1, length1);
+ memcpy (s + length1, string2, length2);
+#endif
+ str = s;
+ }
+ else
+ str = string2;
+ else
+ str = string1;
+
+ rval = re_search_stub (bufp, str, len, start, range, stop, regs,
+ ret_len);
+ re_free (s);
+ return rval;
+}
+
+/* The parameters have the same meaning as those of re_search.
+ Additional parameters:
+ If RET_LEN is true the length of the match is returned (re_match style);
+ otherwise the position of the match is returned. */
+
+static regoff_t
+re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
+ Idx start, regoff_t range, Idx stop, struct re_registers *regs,
+ bool ret_len)
+{
+ reg_errcode_t result;
+ regmatch_t *pmatch;
+ Idx nregs;
+ regoff_t rval;
+ int eflags = 0;
+ re_dfa_t *dfa = bufp->buffer;
+ Idx last_start = start + range;
+
+ /* Check for out-of-range. */
+ if (__glibc_unlikely (start < 0 || start > length))
+ return -1;
+ if (__glibc_unlikely (length < last_start
+ || (0 <= range && last_start < start)))
+ last_start = length;
+ else if (__glibc_unlikely (last_start < 0
+ || (range < 0 && start <= last_start)))
+ last_start = 0;
+
+ lock_lock (dfa->lock);
+
+ eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
+ eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
+
+ /* Compile fastmap if we haven't yet. */
+ if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate)
+ re_compile_fastmap (bufp);
+
+ if (__glibc_unlikely (bufp->no_sub))
+ regs = NULL;
+
+ /* We need at least 1 register. */
+ if (regs == NULL)
+ nregs = 1;
+ else if (__glibc_unlikely (bufp->regs_allocated == REGS_FIXED
+ && regs->num_regs <= bufp->re_nsub))
+ {
+ nregs = regs->num_regs;
+ if (__glibc_unlikely (nregs < 1))
+ {
+ /* Nothing can be copied to regs. */
+ regs = NULL;
+ nregs = 1;
+ }
+ }
+ else
+ nregs = bufp->re_nsub + 1;
+ pmatch = re_malloc (regmatch_t, nregs);
+ if (__glibc_unlikely (pmatch == NULL))
+ {
+ rval = -2;
+ goto out;
+ }
+
+ result = re_search_internal (bufp, string, length, start, last_start, stop,
+ nregs, pmatch, eflags);
+
+ rval = 0;
+
+ /* I hope we needn't fill their regs with -1's when no match was found. */
+ if (result != REG_NOERROR)
+ rval = result == REG_NOMATCH ? -1 : -2;
+ else if (regs != NULL)
+ {
+ /* If caller wants register contents data back, copy them. */
+ bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
+ bufp->regs_allocated);
+ if (__glibc_unlikely (bufp->regs_allocated == REGS_UNALLOCATED))
+ rval = -2;
+ }
+
+ if (__glibc_likely (rval == 0))
+ {
+ if (ret_len)
+ {
+ assert (pmatch[0].rm_so == start);
+ rval = pmatch[0].rm_eo - start;
+ }
+ else
+ rval = pmatch[0].rm_so;
+ }
+ re_free (pmatch);
+ out:
+ lock_unlock (dfa->lock);
+ return rval;
+}
+
+static unsigned
+re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
+ int regs_allocated)
+{
+ int rval = REGS_REALLOCATE;
+ Idx i;
+ Idx need_regs = nregs + 1;
+ /* We need one extra element beyond 'num_regs' for the '-1' marker GNU code
+ uses. */
+
+ /* Have the register data arrays been allocated? */
+ if (regs_allocated == REGS_UNALLOCATED)
+ { /* No. So allocate them with malloc. */
+ regs->start = re_malloc (regoff_t, need_regs);
+ if (__glibc_unlikely (regs->start == NULL))
+ return REGS_UNALLOCATED;
+ regs->end = re_malloc (regoff_t, need_regs);
+ if (__glibc_unlikely (regs->end == NULL))
+ {
+ re_free (regs->start);
+ return REGS_UNALLOCATED;
+ }
+ regs->num_regs = need_regs;
+ }
+ else if (regs_allocated == REGS_REALLOCATE)
+ { /* Yes. If we need more elements than were already
+ allocated, reallocate them. If we need fewer, just
+ leave it alone. */
+ if (__glibc_unlikely (need_regs > regs->num_regs))
+ {
+ regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
+ regoff_t *new_end;
+ if (__glibc_unlikely (new_start == NULL))
+ return REGS_UNALLOCATED;
+ new_end = re_realloc (regs->end, regoff_t, need_regs);
+ if (__glibc_unlikely (new_end == NULL))
+ {
+ re_free (new_start);
+ return REGS_UNALLOCATED;
+ }
+ regs->start = new_start;
+ regs->end = new_end;
+ regs->num_regs = need_regs;
+ }
+ }
+ else
+ {
+ assert (regs_allocated == REGS_FIXED);
+ /* This function may not be called with REGS_FIXED and nregs too big. */
+ assert (regs->num_regs >= nregs);
+ rval = REGS_FIXED;
+ }
+
+ /* Copy the regs. */
+ for (i = 0; i < nregs; ++i)
+ {
+ regs->start[i] = pmatch[i].rm_so;
+ regs->end[i] = pmatch[i].rm_eo;
+ }
+ for ( ; i < regs->num_regs; ++i)
+ regs->start[i] = regs->end[i] = -1;
+
+ return rval;
+}
+
+/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
+ ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use
+ this memory for recording register information. STARTS and ENDS
+ must be allocated using the malloc library routine, and must each
+ be at least NUM_REGS * sizeof (regoff_t) bytes long.
+
+ If NUM_REGS == 0, then subsequent matches should allocate their own
+ register data.
+
+ Unless this function is called, the first search or match using
+ PATTERN_BUFFER will allocate its own register data, without
+ freeing the old data. */
+
+void
+re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs,
+ __re_size_t num_regs, regoff_t *starts, regoff_t *ends)
+{
+ if (num_regs)
+ {
+ bufp->regs_allocated = REGS_REALLOCATE;
+ regs->num_regs = num_regs;
+ regs->start = starts;
+ regs->end = ends;
+ }
+ else
+ {
+ bufp->regs_allocated = REGS_UNALLOCATED;
+ regs->num_regs = 0;
+ regs->start = regs->end = NULL;
+ }
+}
+#ifdef _LIBC
+weak_alias (__re_set_registers, re_set_registers)
+#endif
+
+/* Entry points compatible with 4.2 BSD regex library. We don't define
+ them unless specifically requested. */
+
+#if defined _REGEX_RE_COMP || defined _LIBC
+int
+# ifdef _LIBC
+weak_function
+# endif
+re_exec (const char *s)
+{
+ return 0 == regexec (&re_comp_buf, s, 0, NULL, 0);
+}
+#endif /* _REGEX_RE_COMP */
+
+/* Internal entry point. */
+
+/* Searches for a compiled pattern PREG in the string STRING, whose
+ length is LENGTH. NMATCH, PMATCH, and EFLAGS have the same
+ meaning as with regexec. LAST_START is START + RANGE, where
+ START and RANGE have the same meaning as with re_search.
+ Return REG_NOERROR if we find a match, and REG_NOMATCH if not,
+ otherwise return the error code.
+ Note: We assume front end functions already check ranges.
+ (0 <= LAST_START && LAST_START <= LENGTH) */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+re_search_internal (const regex_t *preg, const char *string, Idx length,
+ Idx start, Idx last_start, Idx stop, size_t nmatch,
+ regmatch_t pmatch[], int eflags)
+{
+ reg_errcode_t err;
+ const re_dfa_t *dfa = preg->buffer;
+ Idx left_lim, right_lim;
+ int incr;
+ bool fl_longest_match;
+ int match_kind;
+ Idx match_first;
+ Idx match_last = -1;
+ Idx extra_nmatch;
+ bool sb;
+ int ch;
+#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
+ re_match_context_t mctx = { .dfa = dfa };
+#else
+ re_match_context_t mctx;
+#endif
+ char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate
+ && start != last_start && !preg->can_be_null)
+ ? preg->fastmap : NULL);
+ RE_TRANSLATE_TYPE t = preg->translate;
+
+#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
+ memset (&mctx, '\0', sizeof (re_match_context_t));
+ mctx.dfa = dfa;
+#endif
+
+ extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0;
+ nmatch -= extra_nmatch;
+
+ /* Check if the DFA haven't been compiled. */
+ if (__glibc_unlikely (preg->used == 0 || dfa->init_state == NULL
+ || dfa->init_state_word == NULL
+ || dfa->init_state_nl == NULL
+ || dfa->init_state_begbuf == NULL))
+ return REG_NOMATCH;
+
+#ifdef DEBUG
+ /* We assume front-end functions already check them. */
+ assert (0 <= last_start && last_start <= length);
+#endif
+
+ /* If initial states with non-begbuf contexts have no elements,
+ the regex must be anchored. If preg->newline_anchor is set,
+ we'll never use init_state_nl, so do not check it. */
+ if (dfa->init_state->nodes.nelem == 0
+ && dfa->init_state_word->nodes.nelem == 0
+ && (dfa->init_state_nl->nodes.nelem == 0
+ || !preg->newline_anchor))
+ {
+ if (start != 0 && last_start != 0)
+ return REG_NOMATCH;
+ start = last_start = 0;
+ }
+
+ /* We must check the longest matching, if nmatch > 0. */
+ fl_longest_match = (nmatch != 0 || dfa->nbackref);
+
+ err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
+ preg->translate, (preg->syntax & RE_ICASE) != 0,
+ dfa);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+ mctx.input.stop = stop;
+ mctx.input.raw_stop = stop;
+ mctx.input.newline_anchor = preg->newline_anchor;
+
+ err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+
+ /* We will log all the DFA states through which the dfa pass,
+ if nmatch > 1, or this dfa has "multibyte node", which is a
+ back-reference or a node which can accept multibyte character or
+ multi character collating element. */
+ if (nmatch > 1 || dfa->has_mb_node)
+ {
+ /* Avoid overflow. */
+ if (__glibc_unlikely ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
+ <= mctx.input.bufs_len)))
+ {
+ err = REG_ESPACE;
+ goto free_return;
+ }
+
+ mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
+ if (__glibc_unlikely (mctx.state_log == NULL))
+ {
+ err = REG_ESPACE;
+ goto free_return;
+ }
+ }
+ else
+ mctx.state_log = NULL;
+
+ match_first = start;
+ mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
+ : CONTEXT_NEWLINE | CONTEXT_BEGBUF;
+
+ /* Check incrementally whether the input string matches. */
+ incr = (last_start < start) ? -1 : 1;
+ left_lim = (last_start < start) ? last_start : start;
+ right_lim = (last_start < start) ? start : last_start;
+ sb = dfa->mb_cur_max == 1;
+ match_kind =
+ (fastmap
+ ? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0)
+ | (start <= last_start ? 2 : 0)
+ | (t != NULL ? 1 : 0))
+ : 8);
+
+ for (;; match_first += incr)
+ {
+ err = REG_NOMATCH;
+ if (match_first < left_lim || right_lim < match_first)
+ goto free_return;
+
+ /* Advance as rapidly as possible through the string, until we
+ find a plausible place to start matching. This may be done
+ with varying efficiency, so there are various possibilities:
+ only the most common of them are specialized, in order to
+ save on code size. We use a switch statement for speed. */
+ switch (match_kind)
+ {
+ case 8:
+ /* No fastmap. */
+ break;
+
+ case 7:
+ /* Fastmap with single-byte translation, match forward. */
+ while (__glibc_likely (match_first < right_lim)
+ && !fastmap[t[(unsigned char) string[match_first]]])
+ ++match_first;
+ goto forward_match_found_start_or_reached_end;
+
+ case 6:
+ /* Fastmap without translation, match forward. */
+ while (__glibc_likely (match_first < right_lim)
+ && !fastmap[(unsigned char) string[match_first]])
+ ++match_first;
+
+ forward_match_found_start_or_reached_end:
+ if (__glibc_unlikely (match_first == right_lim))
+ {
+ ch = match_first >= length
+ ? 0 : (unsigned char) string[match_first];
+ if (!fastmap[t ? t[ch] : ch])
+ goto free_return;
+ }
+ break;
+
+ case 4:
+ case 5:
+ /* Fastmap without multi-byte translation, match backwards. */
+ while (match_first >= left_lim)
+ {
+ ch = match_first >= length
+ ? 0 : (unsigned char) string[match_first];
+ if (fastmap[t ? t[ch] : ch])
+ break;
+ --match_first;
+ }
+ if (match_first < left_lim)
+ goto free_return;
+ break;
+
+ default:
+ /* In this case, we can't determine easily the current byte,
+ since it might be a component byte of a multibyte
+ character. Then we use the constructed buffer instead. */
+ for (;;)
+ {
+ /* If MATCH_FIRST is out of the valid range, reconstruct the
+ buffers. */
+ __re_size_t offset = match_first - mctx.input.raw_mbs_idx;
+ if (__glibc_unlikely (offset
+ >= (__re_size_t) mctx.input.valid_raw_len))
+ {
+ err = re_string_reconstruct (&mctx.input, match_first,
+ eflags);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+
+ offset = match_first - mctx.input.raw_mbs_idx;
+ }
+ /* If MATCH_FIRST is out of the buffer, leave it as '\0'.
+ Note that MATCH_FIRST must not be smaller than 0. */
+ ch = (match_first >= length
+ ? 0 : re_string_byte_at (&mctx.input, offset));
+ if (fastmap[ch])
+ break;
+ match_first += incr;
+ if (match_first < left_lim || match_first > right_lim)
+ {
+ err = REG_NOMATCH;
+ goto free_return;
+ }
+ }
+ break;
+ }
+
+ /* Reconstruct the buffers so that the matcher can assume that
+ the matching starts from the beginning of the buffer. */
+ err = re_string_reconstruct (&mctx.input, match_first, eflags);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+
+#ifdef RE_ENABLE_I18N
+ /* Don't consider this char as a possible match start if it part,
+ yet isn't the head, of a multibyte character. */
+ if (!sb && !re_string_first_byte (&mctx.input, 0))
+ continue;
+#endif
+
+ /* It seems to be appropriate one, then use the matcher. */
+ /* We assume that the matching starts from 0. */
+ mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
+ match_last = check_matching (&mctx, fl_longest_match,
+ start <= last_start ? &match_first : NULL);
+ if (match_last != -1)
+ {
+ if (__glibc_unlikely (match_last == -2))
+ {
+ err = REG_ESPACE;
+ goto free_return;
+ }
+ else
+ {
+ mctx.match_last = match_last;
+ if ((!preg->no_sub && nmatch > 1) || dfa->nbackref)
+ {
+ re_dfastate_t *pstate = mctx.state_log[match_last];
+ mctx.last_node = check_halt_state_context (&mctx, pstate,
+ match_last);
+ }
+ if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match)
+ || dfa->nbackref)
+ {
+ err = prune_impossible_nodes (&mctx);
+ if (err == REG_NOERROR)
+ break;
+ if (__glibc_unlikely (err != REG_NOMATCH))
+ goto free_return;
+#ifdef DEBUG
+ /* Only used for assertion below when DEBUG is set, otherwise
+ it will be over-written when we loop around. */
+ match_last = -1;
+#endif
+ }
+ else
+ break; /* We found a match. */
+ }
+ }
+
+ match_ctx_clean (&mctx);
+ }
+
+#ifdef DEBUG
+ assert (match_last != -1);
+ assert (err == REG_NOERROR);
+#endif
+
+ /* Set pmatch[] if we need. */
+ if (nmatch > 0)
+ {
+ Idx reg_idx;
+
+ /* Initialize registers. */
+ for (reg_idx = 1; reg_idx < nmatch; ++reg_idx)
+ pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1;
+
+ /* Set the points where matching start/end. */
+ pmatch[0].rm_so = 0;
+ pmatch[0].rm_eo = mctx.match_last;
+ /* FIXME: This function should fail if mctx.match_last exceeds
+ the maximum possible regoff_t value. We need a new error
+ code REG_OVERFLOW. */
+
+ if (!preg->no_sub && nmatch > 1)
+ {
+ err = set_regs (preg, &mctx, nmatch, pmatch,
+ dfa->has_plural_match && dfa->nbackref > 0);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+ }
+
+ /* At last, add the offset to each register, since we slid
+ the buffers so that we could assume that the matching starts
+ from 0. */
+ for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
+ if (pmatch[reg_idx].rm_so != -1)
+ {
+#ifdef RE_ENABLE_I18N
+ if (__glibc_unlikely (mctx.input.offsets_needed != 0))
+ {
+ pmatch[reg_idx].rm_so =
+ (pmatch[reg_idx].rm_so == mctx.input.valid_len
+ ? mctx.input.valid_raw_len
+ : mctx.input.offsets[pmatch[reg_idx].rm_so]);
+ pmatch[reg_idx].rm_eo =
+ (pmatch[reg_idx].rm_eo == mctx.input.valid_len
+ ? mctx.input.valid_raw_len
+ : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
+ }
+#else
+ assert (mctx.input.offsets_needed == 0);
+#endif
+ pmatch[reg_idx].rm_so += match_first;
+ pmatch[reg_idx].rm_eo += match_first;
+ }
+ for (reg_idx = 0; reg_idx < extra_nmatch; ++reg_idx)
+ {
+ pmatch[nmatch + reg_idx].rm_so = -1;
+ pmatch[nmatch + reg_idx].rm_eo = -1;
+ }
+
+ if (dfa->subexp_map)
+ for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++)
+ if (dfa->subexp_map[reg_idx] != reg_idx)
+ {
+ pmatch[reg_idx + 1].rm_so
+ = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so;
+ pmatch[reg_idx + 1].rm_eo
+ = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo;
+ }
+ }
+
+ free_return:
+ re_free (mctx.state_log);
+ if (dfa->nbackref)
+ match_ctx_free (&mctx);
+ re_string_destruct (&mctx.input);
+ return err;
+}
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+prune_impossible_nodes (re_match_context_t *mctx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ Idx halt_node, match_last;
+ reg_errcode_t ret;
+ re_dfastate_t **sifted_states;
+ re_dfastate_t **lim_states = NULL;
+ re_sift_context_t sctx;
+#ifdef DEBUG
+ assert (mctx->state_log != NULL);
+#endif
+ match_last = mctx->match_last;
+ halt_node = mctx->last_node;
+
+ /* Avoid overflow. */
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
+ <= match_last))
+ return REG_ESPACE;
+
+ sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
+ if (__glibc_unlikely (sifted_states == NULL))
+ {
+ ret = REG_ESPACE;
+ goto free_return;
+ }
+ if (dfa->nbackref)
+ {
+ lim_states = re_malloc (re_dfastate_t *, match_last + 1);
+ if (__glibc_unlikely (lim_states == NULL))
+ {
+ ret = REG_ESPACE;
+ goto free_return;
+ }
+ while (1)
+ {
+ memset (lim_states, '\0',
+ sizeof (re_dfastate_t *) * (match_last + 1));
+ sift_ctx_init (&sctx, sifted_states, lim_states, halt_node,
+ match_last);
+ ret = sift_states_backward (mctx, &sctx);
+ re_node_set_free (&sctx.limits);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ goto free_return;
+ if (sifted_states[0] != NULL || lim_states[0] != NULL)
+ break;
+ do
+ {
+ --match_last;
+ if (match_last < 0)
+ {
+ ret = REG_NOMATCH;
+ goto free_return;
+ }
+ } while (mctx->state_log[match_last] == NULL
+ || !mctx->state_log[match_last]->halt);
+ halt_node = check_halt_state_context (mctx,
+ mctx->state_log[match_last],
+ match_last);
+ }
+ ret = merge_state_array (dfa, sifted_states, lim_states,
+ match_last + 1);
+ re_free (lim_states);
+ lim_states = NULL;
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ goto free_return;
+ }
+ else
+ {
+ sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last);
+ ret = sift_states_backward (mctx, &sctx);
+ re_node_set_free (&sctx.limits);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ goto free_return;
+ if (sifted_states[0] == NULL)
+ {
+ ret = REG_NOMATCH;
+ goto free_return;
+ }
+ }
+ re_free (mctx->state_log);
+ mctx->state_log = sifted_states;
+ sifted_states = NULL;
+ mctx->last_node = halt_node;
+ mctx->match_last = match_last;
+ ret = REG_NOERROR;
+ free_return:
+ re_free (sifted_states);
+ re_free (lim_states);
+ return ret;
+}
+
+/* Acquire an initial state and return it.
+ We must select appropriate initial state depending on the context,
+ since initial states may have constraints like "\<", "^", etc.. */
+
+static inline re_dfastate_t *
+__attribute__ ((always_inline))
+acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
+ Idx idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ if (dfa->init_state->has_constraint)
+ {
+ unsigned int context;
+ context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags);
+ if (IS_WORD_CONTEXT (context))
+ return dfa->init_state_word;
+ else if (IS_ORDINARY_CONTEXT (context))
+ return dfa->init_state;
+ else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context))
+ return dfa->init_state_begbuf;
+ else if (IS_NEWLINE_CONTEXT (context))
+ return dfa->init_state_nl;
+ else if (IS_BEGBUF_CONTEXT (context))
+ {
+ /* It is relatively rare case, then calculate on demand. */
+ return re_acquire_state_context (err, dfa,
+ dfa->init_state->entrance_nodes,
+ context);
+ }
+ else
+ /* Must not happen? */
+ return dfa->init_state;
+ }
+ else
+ return dfa->init_state;
+}
+
+/* Check whether the regular expression match input string INPUT or not,
+ and return the index where the matching end. Return -1 if
+ there is no match, and return -2 in case of an error.
+ FL_LONGEST_MATCH means we want the POSIX longest matching.
+ If P_MATCH_FIRST is not NULL, and the match fails, it is set to the
+ next place where we may want to try matching.
+ Note that the matcher assumes that the matching starts from the current
+ index of the buffer. */
+
+static Idx
+__attribute_warn_unused_result__
+check_matching (re_match_context_t *mctx, bool fl_longest_match,
+ Idx *p_match_first)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err;
+ Idx match = 0;
+ Idx match_last = -1;
+ Idx cur_str_idx = re_string_cur_idx (&mctx->input);
+ re_dfastate_t *cur_state;
+ bool at_init_state = p_match_first != NULL;
+ Idx next_start_idx = cur_str_idx;
+
+ err = REG_NOERROR;
+ cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
+ /* An initial state must not be NULL (invalid). */
+ if (__glibc_unlikely (cur_state == NULL))
+ {
+ assert (err == REG_ESPACE);
+ return -2;
+ }
+
+ if (mctx->state_log != NULL)
+ {
+ mctx->state_log[cur_str_idx] = cur_state;
+
+ /* Check OP_OPEN_SUBEXP in the initial state in case that we use them
+ later. E.g. Processing back references. */
+ if (__glibc_unlikely (dfa->nbackref))
+ {
+ at_init_state = false;
+ err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+
+ if (cur_state->has_backref)
+ {
+ err = transit_state_bkref (mctx, &cur_state->nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ }
+ }
+
+ /* If the RE accepts NULL string. */
+ if (__glibc_unlikely (cur_state->halt))
+ {
+ if (!cur_state->has_constraint
+ || check_halt_state_context (mctx, cur_state, cur_str_idx))
+ {
+ if (!fl_longest_match)
+ return cur_str_idx;
+ else
+ {
+ match_last = cur_str_idx;
+ match = 1;
+ }
+ }
+ }
+
+ while (!re_string_eoi (&mctx->input))
+ {
+ re_dfastate_t *old_state = cur_state;
+ Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1;
+
+ if ((__glibc_unlikely (next_char_idx >= mctx->input.bufs_len)
+ && mctx->input.bufs_len < mctx->input.len)
+ || (__glibc_unlikely (next_char_idx >= mctx->input.valid_len)
+ && mctx->input.valid_len < mctx->input.len))
+ {
+ err = extend_buffers (mctx, next_char_idx + 1);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ assert (err == REG_ESPACE);
+ return -2;
+ }
+ }
+
+ cur_state = transit_state (&err, mctx, cur_state);
+ if (mctx->state_log != NULL)
+ cur_state = merge_state_with_log (&err, mctx, cur_state);
+
+ if (cur_state == NULL)
+ {
+ /* Reached the invalid state or an error. Try to recover a valid
+ state using the state log, if available and if we have not
+ already found a valid (even if not the longest) match. */
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return -2;
+
+ if (mctx->state_log == NULL
+ || (match && !fl_longest_match)
+ || (cur_state = find_recover_state (&err, mctx)) == NULL)
+ break;
+ }
+
+ if (__glibc_unlikely (at_init_state))
+ {
+ if (old_state == cur_state)
+ next_start_idx = next_char_idx;
+ else
+ at_init_state = false;
+ }
+
+ if (cur_state->halt)
+ {
+ /* Reached a halt state.
+ Check the halt state can satisfy the current context. */
+ if (!cur_state->has_constraint
+ || check_halt_state_context (mctx, cur_state,
+ re_string_cur_idx (&mctx->input)))
+ {
+ /* We found an appropriate halt state. */
+ match_last = re_string_cur_idx (&mctx->input);
+ match = 1;
+
+ /* We found a match, do not modify match_first below. */
+ p_match_first = NULL;
+ if (!fl_longest_match)
+ break;
+ }
+ }
+ }
+
+ if (p_match_first)
+ *p_match_first += next_start_idx;
+
+ return match_last;
+}
+
+/* Check NODE match the current context. */
+
+static bool
+check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context)
+{
+ re_token_type_t type = dfa->nodes[node].type;
+ unsigned int constraint = dfa->nodes[node].constraint;
+ if (type != END_OF_RE)
+ return false;
+ if (!constraint)
+ return true;
+ if (NOT_SATISFY_NEXT_CONSTRAINT (constraint, context))
+ return false;
+ return true;
+}
+
+/* Check the halt state STATE match the current context.
+ Return 0 if not match, if the node, STATE has, is a halt node and
+ match the context, return the node. */
+
+static Idx
+check_halt_state_context (const re_match_context_t *mctx,
+ const re_dfastate_t *state, Idx idx)
+{
+ Idx i;
+ unsigned int context;
+#ifdef DEBUG
+ assert (state->halt);
+#endif
+ context = re_string_context_at (&mctx->input, idx, mctx->eflags);
+ for (i = 0; i < state->nodes.nelem; ++i)
+ if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context))
+ return state->nodes.elems[i];
+ return 0;
+}
+
+/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA
+ corresponding to the DFA).
+ Return the destination node, and update EPS_VIA_NODES;
+ return -1 in case of errors. */
+
+static Idx
+proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
+ Idx *pidx, Idx node, re_node_set *eps_via_nodes,
+ struct re_fail_stack_t *fs)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ Idx i;
+ bool ok;
+ if (IS_EPSILON_NODE (dfa->nodes[node].type))
+ {
+ re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
+ re_node_set *edests = &dfa->edests[node];
+ Idx dest_node;
+ ok = re_node_set_insert (eps_via_nodes, node);
+ if (__glibc_unlikely (! ok))
+ return -2;
+ /* Pick up a valid destination, or return -1 if none
+ is found. */
+ for (dest_node = -1, i = 0; i < edests->nelem; ++i)
+ {
+ Idx candidate = edests->elems[i];
+ if (!re_node_set_contains (cur_nodes, candidate))
+ continue;
+ if (dest_node == -1)
+ dest_node = candidate;
+
+ else
+ {
+ /* In order to avoid infinite loop like "(a*)*", return the second
+ epsilon-transition if the first was already considered. */
+ if (re_node_set_contains (eps_via_nodes, dest_node))
+ return candidate;
+
+ /* Otherwise, push the second epsilon-transition on the fail stack. */
+ else if (fs != NULL
+ && push_fail_stack (fs, *pidx, candidate, nregs, regs,
+ eps_via_nodes))
+ return -2;
+
+ /* We know we are going to exit. */
+ break;
+ }
+ }
+ return dest_node;
+ }
+ else
+ {
+ Idx naccepted = 0;
+ re_token_type_t type = dfa->nodes[node].type;
+
+#ifdef RE_ENABLE_I18N
+ if (dfa->nodes[node].accept_mb)
+ naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx);
+ else
+#endif /* RE_ENABLE_I18N */
+ if (type == OP_BACK_REF)
+ {
+ Idx subexp_idx = dfa->nodes[node].opr.idx + 1;
+ naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
+ if (fs != NULL)
+ {
+ if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1)
+ return -1;
+ else if (naccepted)
+ {
+ char *buf = (char *) re_string_get_buffer (&mctx->input);
+ if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
+ naccepted) != 0)
+ return -1;
+ }
+ }
+
+ if (naccepted == 0)
+ {
+ Idx dest_node;
+ ok = re_node_set_insert (eps_via_nodes, node);
+ if (__glibc_unlikely (! ok))
+ return -2;
+ dest_node = dfa->edests[node].elems[0];
+ if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
+ dest_node))
+ return dest_node;
+ }
+ }
+
+ if (naccepted != 0
+ || check_node_accept (mctx, dfa->nodes + node, *pidx))
+ {
+ Idx dest_node = dfa->nexts[node];
+ *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted;
+ if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL
+ || !re_node_set_contains (&mctx->state_log[*pidx]->nodes,
+ dest_node)))
+ return -1;
+ re_node_set_empty (eps_via_nodes);
+ return dest_node;
+ }
+ }
+ return -1;
+}
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
+ Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes)
+{
+ reg_errcode_t err;
+ Idx num = fs->num++;
+ if (fs->num == fs->alloc)
+ {
+ struct re_fail_stack_ent_t *new_array;
+ new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t,
+ fs->alloc * 2);
+ if (new_array == NULL)
+ return REG_ESPACE;
+ fs->alloc *= 2;
+ fs->stack = new_array;
+ }
+ fs->stack[num].idx = str_idx;
+ fs->stack[num].node = dest_node;
+ fs->stack[num].regs = re_malloc (regmatch_t, nregs);
+ if (fs->stack[num].regs == NULL)
+ return REG_ESPACE;
+ memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs);
+ err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes);
+ return err;
+}
+
+static Idx
+pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs,
+ regmatch_t *regs, re_node_set *eps_via_nodes)
+{
+ Idx num = --fs->num;
+ assert (num >= 0);
+ *pidx = fs->stack[num].idx;
+ memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs);
+ re_node_set_free (eps_via_nodes);
+ re_free (fs->stack[num].regs);
+ *eps_via_nodes = fs->stack[num].eps_via_nodes;
+ return fs->stack[num].node;
+}
+
+/* Set the positions where the subexpressions are starts/ends to registers
+ PMATCH.
+ Note: We assume that pmatch[0] is already set, and
+ pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
+ regmatch_t *pmatch, bool fl_backtrack)
+{
+ const re_dfa_t *dfa = preg->buffer;
+ Idx idx, cur_node;
+ re_node_set eps_via_nodes;
+ struct re_fail_stack_t *fs;
+ struct re_fail_stack_t fs_body = { 0, 2, NULL };
+ regmatch_t *prev_idx_match;
+ bool prev_idx_match_malloced = false;
+
+#ifdef DEBUG
+ assert (nmatch > 1);
+ assert (mctx->state_log != NULL);
+#endif
+ if (fl_backtrack)
+ {
+ fs = &fs_body;
+ fs->stack = re_malloc (struct re_fail_stack_ent_t, fs->alloc);
+ if (fs->stack == NULL)
+ return REG_ESPACE;
+ }
+ else
+ fs = NULL;
+
+ cur_node = dfa->init_node;
+ re_node_set_init_empty (&eps_via_nodes);
+
+ if (__libc_use_alloca (nmatch * sizeof (regmatch_t)))
+ prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t));
+ else
+ {
+ prev_idx_match = re_malloc (regmatch_t, nmatch);
+ if (prev_idx_match == NULL)
+ {
+ free_fail_stack_return (fs);
+ return REG_ESPACE;
+ }
+ prev_idx_match_malloced = true;
+ }
+ memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
+
+ for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
+ {
+ update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch);
+
+ if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
+ {
+ Idx reg_idx;
+ if (fs)
+ {
+ for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
+ if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1)
+ break;
+ if (reg_idx == nmatch)
+ {
+ re_node_set_free (&eps_via_nodes);
+ if (prev_idx_match_malloced)
+ re_free (prev_idx_match);
+ return free_fail_stack_return (fs);
+ }
+ cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
+ &eps_via_nodes);
+ }
+ else
+ {
+ re_node_set_free (&eps_via_nodes);
+ if (prev_idx_match_malloced)
+ re_free (prev_idx_match);
+ return REG_NOERROR;
+ }
+ }
+
+ /* Proceed to next node. */
+ cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node,
+ &eps_via_nodes, fs);
+
+ if (__glibc_unlikely (cur_node < 0))
+ {
+ if (__glibc_unlikely (cur_node == -2))
+ {
+ re_node_set_free (&eps_via_nodes);
+ if (prev_idx_match_malloced)
+ re_free (prev_idx_match);
+ free_fail_stack_return (fs);
+ return REG_ESPACE;
+ }
+ if (fs)
+ cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
+ &eps_via_nodes);
+ else
+ {
+ re_node_set_free (&eps_via_nodes);
+ if (prev_idx_match_malloced)
+ re_free (prev_idx_match);
+ return REG_NOMATCH;
+ }
+ }
+ }
+ re_node_set_free (&eps_via_nodes);
+ if (prev_idx_match_malloced)
+ re_free (prev_idx_match);
+ return free_fail_stack_return (fs);
+}
+
+static reg_errcode_t
+free_fail_stack_return (struct re_fail_stack_t *fs)
+{
+ if (fs)
+ {
+ Idx fs_idx;
+ for (fs_idx = 0; fs_idx < fs->num; ++fs_idx)
+ {
+ re_node_set_free (&fs->stack[fs_idx].eps_via_nodes);
+ re_free (fs->stack[fs_idx].regs);
+ }
+ re_free (fs->stack);
+ }
+ return REG_NOERROR;
+}
+
+static void
+update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
+ regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch)
+{
+ int type = dfa->nodes[cur_node].type;
+ if (type == OP_OPEN_SUBEXP)
+ {
+ Idx reg_num = dfa->nodes[cur_node].opr.idx + 1;
+
+ /* We are at the first node of this sub expression. */
+ if (reg_num < nmatch)
+ {
+ pmatch[reg_num].rm_so = cur_idx;
+ pmatch[reg_num].rm_eo = -1;
+ }
+ }
+ else if (type == OP_CLOSE_SUBEXP)
+ {
+ Idx reg_num = dfa->nodes[cur_node].opr.idx + 1;
+ if (reg_num < nmatch)
+ {
+ /* We are at the last node of this sub expression. */
+ if (pmatch[reg_num].rm_so < cur_idx)
+ {
+ pmatch[reg_num].rm_eo = cur_idx;
+ /* This is a non-empty match or we are not inside an optional
+ subexpression. Accept this right away. */
+ memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
+ }
+ else
+ {
+ if (dfa->nodes[cur_node].opt_subexp
+ && prev_idx_match[reg_num].rm_so != -1)
+ /* We transited through an empty match for an optional
+ subexpression, like (a?)*, and this is not the subexp's
+ first match. Copy back the old content of the registers
+ so that matches of an inner subexpression are undone as
+ well, like in ((a?))*. */
+ memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch);
+ else
+ /* We completed a subexpression, but it may be part of
+ an optional one, so do not update PREV_IDX_MATCH. */
+ pmatch[reg_num].rm_eo = cur_idx;
+ }
+ }
+ }
+}
+
+/* This function checks the STATE_LOG from the SCTX->last_str_idx to 0
+ and sift the nodes in each states according to the following rules.
+ Updated state_log will be wrote to STATE_LOG.
+
+ Rules: We throw away the Node 'a' in the STATE_LOG[STR_IDX] if...
+ 1. When STR_IDX == MATCH_LAST(the last index in the state_log):
+ If 'a' isn't the LAST_NODE and 'a' can't epsilon transit to
+ the LAST_NODE, we throw away the node 'a'.
+ 2. When 0 <= STR_IDX < MATCH_LAST and 'a' accepts
+ string 's' and transit to 'b':
+ i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw
+ away the node 'a'.
+ ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is
+ thrown away, we throw away the node 'a'.
+ 3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b':
+ i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the
+ node 'a'.
+ ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away,
+ we throw away the node 'a'. */
+
+#define STATE_NODE_CONTAINS(state,node) \
+ ((state) != NULL && re_node_set_contains (&(state)->nodes, node))
+
+static reg_errcode_t
+sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
+{
+ reg_errcode_t err;
+ int null_cnt = 0;
+ Idx str_idx = sctx->last_str_idx;
+ re_node_set cur_dest;
+
+#ifdef DEBUG
+ assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
+#endif
+
+ /* Build sifted state_log[str_idx]. It has the nodes which can epsilon
+ transit to the last_node and the last_node itself. */
+ err = re_node_set_init_1 (&cur_dest, sctx->last_node);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+
+ /* Then check each states in the state_log. */
+ while (str_idx > 0)
+ {
+ /* Update counters. */
+ null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0;
+ if (null_cnt > mctx->max_mb_elem_len)
+ {
+ memset (sctx->sifted_states, '\0',
+ sizeof (re_dfastate_t *) * str_idx);
+ re_node_set_free (&cur_dest);
+ return REG_NOERROR;
+ }
+ re_node_set_empty (&cur_dest);
+ --str_idx;
+
+ if (mctx->state_log[str_idx])
+ {
+ err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+ }
+
+ /* Add all the nodes which satisfy the following conditions:
+ - It can epsilon transit to a node in CUR_DEST.
+ - It is in CUR_SRC.
+ And update state_log. */
+ err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+ }
+ err = REG_NOERROR;
+ free_return:
+ re_node_set_free (&cur_dest);
+ return err;
+}
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
+ Idx str_idx, re_node_set *cur_dest)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes;
+ Idx i;
+
+ /* Then build the next sifted state.
+ We build the next sifted state on 'cur_dest', and update
+ 'sifted_states[str_idx]' with 'cur_dest'.
+ Note:
+ 'cur_dest' is the sifted state from 'state_log[str_idx + 1]'.
+ 'cur_src' points the node_set of the old 'state_log[str_idx]'
+ (with the epsilon nodes pre-filtered out). */
+ for (i = 0; i < cur_src->nelem; i++)
+ {
+ Idx prev_node = cur_src->elems[i];
+ int naccepted = 0;
+ bool ok;
+
+#ifdef DEBUG
+ re_token_type_t type = dfa->nodes[prev_node].type;
+ assert (!IS_EPSILON_NODE (type));
+#endif
+#ifdef RE_ENABLE_I18N
+ /* If the node may accept "multi byte". */
+ if (dfa->nodes[prev_node].accept_mb)
+ naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
+ str_idx, sctx->last_str_idx);
+#endif /* RE_ENABLE_I18N */
+
+ /* We don't check backreferences here.
+ See update_cur_sifted_state(). */
+ if (!naccepted
+ && check_node_accept (mctx, dfa->nodes + prev_node, str_idx)
+ && STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1],
+ dfa->nexts[prev_node]))
+ naccepted = 1;
+
+ if (naccepted == 0)
+ continue;
+
+ if (sctx->limits.nelem)
+ {
+ Idx to_idx = str_idx + naccepted;
+ if (check_dst_limits (mctx, &sctx->limits,
+ dfa->nexts[prev_node], to_idx,
+ prev_node, str_idx))
+ continue;
+ }
+ ok = re_node_set_insert (cur_dest, prev_node);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ }
+
+ return REG_NOERROR;
+}
+
+/* Helper functions. */
+
+static reg_errcode_t
+clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
+{
+ Idx top = mctx->state_log_top;
+
+ if (mctx->state_log == NULL)
+ return REG_NOERROR;
+
+ if ((next_state_log_idx >= mctx->input.bufs_len
+ && mctx->input.bufs_len < mctx->input.len)
+ || (next_state_log_idx >= mctx->input.valid_len
+ && mctx->input.valid_len < mctx->input.len))
+ {
+ reg_errcode_t err;
+ err = extend_buffers (mctx, next_state_log_idx + 1);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+
+ if (top < next_state_log_idx)
+ {
+ memset (mctx->state_log + top + 1, '\0',
+ sizeof (re_dfastate_t *) * (next_state_log_idx - top));
+ mctx->state_log_top = next_state_log_idx;
+ }
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
+ re_dfastate_t **src, Idx num)
+{
+ Idx st_idx;
+ reg_errcode_t err;
+ for (st_idx = 0; st_idx < num; ++st_idx)
+ {
+ if (dst[st_idx] == NULL)
+ dst[st_idx] = src[st_idx];
+ else if (src[st_idx] != NULL)
+ {
+ re_node_set merged_set;
+ err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes,
+ &src[st_idx]->nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ dst[st_idx] = re_acquire_state (&err, dfa, &merged_set);
+ re_node_set_free (&merged_set);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ }
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+update_cur_sifted_state (const re_match_context_t *mctx,
+ re_sift_context_t *sctx, Idx str_idx,
+ re_node_set *dest_nodes)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err = REG_NOERROR;
+ const re_node_set *candidates;
+ candidates = ((mctx->state_log[str_idx] == NULL) ? NULL
+ : &mctx->state_log[str_idx]->nodes);
+
+ if (dest_nodes->nelem == 0)
+ sctx->sifted_states[str_idx] = NULL;
+ else
+ {
+ if (candidates)
+ {
+ /* At first, add the nodes which can epsilon transit to a node in
+ DEST_NODE. */
+ err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+
+ /* Then, check the limitations in the current sift_context. */
+ if (sctx->limits.nelem)
+ {
+ err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits,
+ mctx->bkref_ents, str_idx);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ }
+
+ sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+
+ if (candidates && mctx->state_log[str_idx]->has_backref)
+ {
+ err = sift_states_bkref (mctx, sctx, str_idx, candidates);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
+ const re_node_set *candidates)
+{
+ reg_errcode_t err = REG_NOERROR;
+ Idx i;
+
+ re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+
+ if (!state->inveclosure.alloc)
+ {
+ err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return REG_ESPACE;
+ for (i = 0; i < dest_nodes->nelem; i++)
+ {
+ err = re_node_set_merge (&state->inveclosure,
+ dfa->inveclosures + dest_nodes->elems[i]);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return REG_ESPACE;
+ }
+ }
+ return re_node_set_add_intersect (dest_nodes, candidates,
+ &state->inveclosure);
+}
+
+static reg_errcode_t
+sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
+ const re_node_set *candidates)
+{
+ Idx ecl_idx;
+ reg_errcode_t err;
+ re_node_set *inv_eclosure = dfa->inveclosures + node;
+ re_node_set except_nodes;
+ re_node_set_init_empty (&except_nodes);
+ for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
+ {
+ Idx cur_node = inv_eclosure->elems[ecl_idx];
+ if (cur_node == node)
+ continue;
+ if (IS_EPSILON_NODE (dfa->nodes[cur_node].type))
+ {
+ Idx edst1 = dfa->edests[cur_node].elems[0];
+ Idx edst2 = ((dfa->edests[cur_node].nelem > 1)
+ ? dfa->edests[cur_node].elems[1] : -1);
+ if ((!re_node_set_contains (inv_eclosure, edst1)
+ && re_node_set_contains (dest_nodes, edst1))
+ || (edst2 > 0
+ && !re_node_set_contains (inv_eclosure, edst2)
+ && re_node_set_contains (dest_nodes, edst2)))
+ {
+ err = re_node_set_add_intersect (&except_nodes, candidates,
+ dfa->inveclosures + cur_node);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&except_nodes);
+ return err;
+ }
+ }
+ }
+ }
+ for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
+ {
+ Idx cur_node = inv_eclosure->elems[ecl_idx];
+ if (!re_node_set_contains (&except_nodes, cur_node))
+ {
+ Idx idx = re_node_set_contains (dest_nodes, cur_node) - 1;
+ re_node_set_remove_at (dest_nodes, idx);
+ }
+ }
+ re_node_set_free (&except_nodes);
+ return REG_NOERROR;
+}
+
+static bool
+check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
+ Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ Idx lim_idx, src_pos, dst_pos;
+
+ Idx dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx);
+ Idx src_bkref_idx = search_cur_bkref_entry (mctx, src_idx);
+ for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
+ {
+ Idx subexp_idx;
+ struct re_backref_cache_entry *ent;
+ ent = mctx->bkref_ents + limits->elems[lim_idx];
+ subexp_idx = dfa->nodes[ent->node].opr.idx;
+
+ dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
+ subexp_idx, dst_node, dst_idx,
+ dst_bkref_idx);
+ src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
+ subexp_idx, src_node, src_idx,
+ src_bkref_idx);
+
+ /* In case of:
+ <src> <dst> ( <subexp> )
+ ( <subexp> ) <src> <dst>
+ ( <subexp1> <src> <subexp2> <dst> <subexp3> ) */
+ if (src_pos == dst_pos)
+ continue; /* This is unrelated limitation. */
+ else
+ return true;
+ }
+ return false;
+}
+
+static int
+check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
+ Idx subexp_idx, Idx from_node, Idx bkref_idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ const re_node_set *eclosures = dfa->eclosures + from_node;
+ Idx node_idx;
+
+ /* Else, we are on the boundary: examine the nodes on the epsilon
+ closure. */
+ for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx)
+ {
+ Idx node = eclosures->elems[node_idx];
+ switch (dfa->nodes[node].type)
+ {
+ case OP_BACK_REF:
+ if (bkref_idx != -1)
+ {
+ struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
+ do
+ {
+ Idx dst;
+ int cpos;
+
+ if (ent->node != node)
+ continue;
+
+ if (subexp_idx < BITSET_WORD_BITS
+ && !(ent->eps_reachable_subexps_map
+ & ((bitset_word_t) 1 << subexp_idx)))
+ continue;
+
+ /* Recurse trying to reach the OP_OPEN_SUBEXP and
+ OP_CLOSE_SUBEXP cases below. But, if the
+ destination node is the same node as the source
+ node, don't recurse because it would cause an
+ infinite loop: a regex that exhibits this behavior
+ is ()\1*\1* */
+ dst = dfa->edests[node].elems[0];
+ if (dst == from_node)
+ {
+ if (boundaries & 1)
+ return -1;
+ else /* if (boundaries & 2) */
+ return 0;
+ }
+
+ cpos =
+ check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
+ dst, bkref_idx);
+ if (cpos == -1 /* && (boundaries & 1) */)
+ return -1;
+ if (cpos == 0 && (boundaries & 2))
+ return 0;
+
+ if (subexp_idx < BITSET_WORD_BITS)
+ ent->eps_reachable_subexps_map
+ &= ~((bitset_word_t) 1 << subexp_idx);
+ }
+ while (ent++->more);
+ }
+ break;
+
+ case OP_OPEN_SUBEXP:
+ if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx)
+ return -1;
+ break;
+
+ case OP_CLOSE_SUBEXP:
+ if ((boundaries & 2) && subexp_idx == dfa->nodes[node].opr.idx)
+ return 0;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return (boundaries & 2) ? 1 : 0;
+}
+
+static int
+check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
+ Idx subexp_idx, Idx from_node, Idx str_idx,
+ Idx bkref_idx)
+{
+ struct re_backref_cache_entry *lim = mctx->bkref_ents + limit;
+ int boundaries;
+
+ /* If we are outside the range of the subexpression, return -1 or 1. */
+ if (str_idx < lim->subexp_from)
+ return -1;
+
+ if (lim->subexp_to < str_idx)
+ return 1;
+
+ /* If we are within the subexpression, return 0. */
+ boundaries = (str_idx == lim->subexp_from);
+ boundaries |= (str_idx == lim->subexp_to) << 1;
+ if (boundaries == 0)
+ return 0;
+
+ /* Else, examine epsilon closure. */
+ return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
+ from_node, bkref_idx);
+}
+
+/* Check the limitations of sub expressions LIMITS, and remove the nodes
+ which are against limitations from DEST_NODES. */
+
+static reg_errcode_t
+check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
+ const re_node_set *candidates, re_node_set *limits,
+ struct re_backref_cache_entry *bkref_ents, Idx str_idx)
+{
+ reg_errcode_t err;
+ Idx node_idx, lim_idx;
+
+ for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
+ {
+ Idx subexp_idx;
+ struct re_backref_cache_entry *ent;
+ ent = bkref_ents + limits->elems[lim_idx];
+
+ if (str_idx <= ent->subexp_from || ent->str_idx < str_idx)
+ continue; /* This is unrelated limitation. */
+
+ subexp_idx = dfa->nodes[ent->node].opr.idx;
+ if (ent->subexp_to == str_idx)
+ {
+ Idx ops_node = -1;
+ Idx cls_node = -1;
+ for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
+ {
+ Idx node = dest_nodes->elems[node_idx];
+ re_token_type_t type = dfa->nodes[node].type;
+ if (type == OP_OPEN_SUBEXP
+ && subexp_idx == dfa->nodes[node].opr.idx)
+ ops_node = node;
+ else if (type == OP_CLOSE_SUBEXP
+ && subexp_idx == dfa->nodes[node].opr.idx)
+ cls_node = node;
+ }
+
+ /* Check the limitation of the open subexpression. */
+ /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */
+ if (ops_node >= 0)
+ {
+ err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
+ candidates);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+
+ /* Check the limitation of the close subexpression. */
+ if (cls_node >= 0)
+ for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
+ {
+ Idx node = dest_nodes->elems[node_idx];
+ if (!re_node_set_contains (dfa->inveclosures + node,
+ cls_node)
+ && !re_node_set_contains (dfa->eclosures + node,
+ cls_node))
+ {
+ /* It is against this limitation.
+ Remove it form the current sifted state. */
+ err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
+ candidates);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ --node_idx;
+ }
+ }
+ }
+ else /* (ent->subexp_to != str_idx) */
+ {
+ for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
+ {
+ Idx node = dest_nodes->elems[node_idx];
+ re_token_type_t type = dfa->nodes[node].type;
+ if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP)
+ {
+ if (subexp_idx != dfa->nodes[node].opr.idx)
+ continue;
+ /* It is against this limitation.
+ Remove it form the current sifted state. */
+ err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
+ candidates);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ }
+ }
+ }
+ return REG_NOERROR;
+}
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
+ Idx str_idx, const re_node_set *candidates)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err;
+ Idx node_idx, node;
+ re_sift_context_t local_sctx;
+ Idx first_idx = search_cur_bkref_entry (mctx, str_idx);
+
+ if (first_idx == -1)
+ return REG_NOERROR;
+
+ local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */
+
+ for (node_idx = 0; node_idx < candidates->nelem; ++node_idx)
+ {
+ Idx enabled_idx;
+ re_token_type_t type;
+ struct re_backref_cache_entry *entry;
+ node = candidates->elems[node_idx];
+ type = dfa->nodes[node].type;
+ /* Avoid infinite loop for the REs like "()\1+". */
+ if (node == sctx->last_node && str_idx == sctx->last_str_idx)
+ continue;
+ if (type != OP_BACK_REF)
+ continue;
+
+ entry = mctx->bkref_ents + first_idx;
+ enabled_idx = first_idx;
+ do
+ {
+ Idx subexp_len;
+ Idx to_idx;
+ Idx dst_node;
+ bool ok;
+ re_dfastate_t *cur_state;
+
+ if (entry->node != node)
+ continue;
+ subexp_len = entry->subexp_to - entry->subexp_from;
+ to_idx = str_idx + subexp_len;
+ dst_node = (subexp_len ? dfa->nexts[node]
+ : dfa->edests[node].elems[0]);
+
+ if (to_idx > sctx->last_str_idx
+ || sctx->sifted_states[to_idx] == NULL
+ || !STATE_NODE_CONTAINS (sctx->sifted_states[to_idx], dst_node)
+ || check_dst_limits (mctx, &sctx->limits, node,
+ str_idx, dst_node, to_idx))
+ continue;
+
+ if (local_sctx.sifted_states == NULL)
+ {
+ local_sctx = *sctx;
+ err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+ }
+ local_sctx.last_node = node;
+ local_sctx.last_str_idx = str_idx;
+ ok = re_node_set_insert (&local_sctx.limits, enabled_idx);
+ if (__glibc_unlikely (! ok))
+ {
+ err = REG_ESPACE;
+ goto free_return;
+ }
+ cur_state = local_sctx.sifted_states[str_idx];
+ err = sift_states_backward (mctx, &local_sctx);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+ if (sctx->limited_states != NULL)
+ {
+ err = merge_state_array (dfa, sctx->limited_states,
+ local_sctx.sifted_states,
+ str_idx + 1);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+ }
+ local_sctx.sifted_states[str_idx] = cur_state;
+ re_node_set_remove (&local_sctx.limits, enabled_idx);
+
+ /* mctx->bkref_ents may have changed, reload the pointer. */
+ entry = mctx->bkref_ents + enabled_idx;
+ }
+ while (enabled_idx++, entry++->more);
+ }
+ err = REG_NOERROR;
+ free_return:
+ if (local_sctx.sifted_states != NULL)
+ {
+ re_node_set_free (&local_sctx.limits);
+ }
+
+ return err;
+}
+
+
+#ifdef RE_ENABLE_I18N
+static int
+sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
+ Idx node_idx, Idx str_idx, Idx max_str_idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ int naccepted;
+ /* Check the node can accept "multi byte". */
+ naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx);
+ if (naccepted > 0 && str_idx + naccepted <= max_str_idx &&
+ !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
+ dfa->nexts[node_idx]))
+ /* The node can't accept the "multi byte", or the
+ destination was already thrown away, then the node
+ could't accept the current input "multi byte". */
+ naccepted = 0;
+ /* Otherwise, it is sure that the node could accept
+ 'naccepted' bytes input. */
+ return naccepted;
+}
+#endif /* RE_ENABLE_I18N */
+
+
+/* Functions for state transition. */
+
+/* Return the next state to which the current state STATE will transit by
+ accepting the current input byte, and update STATE_LOG if necessary.
+ If STATE can accept a multibyte char/collating element/back reference
+ update the destination of STATE_LOG. */
+
+static re_dfastate_t *
+__attribute_warn_unused_result__
+transit_state (reg_errcode_t *err, re_match_context_t *mctx,
+ re_dfastate_t *state)
+{
+ re_dfastate_t **trtable;
+ unsigned char ch;
+
+#ifdef RE_ENABLE_I18N
+ /* If the current state can accept multibyte. */
+ if (__glibc_unlikely (state->accept_mb))
+ {
+ *err = transit_state_mb (mctx, state);
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ return NULL;
+ }
+#endif /* RE_ENABLE_I18N */
+
+ /* Then decide the next state with the single byte. */
+#if 0
+ if (0)
+ /* don't use transition table */
+ return transit_state_sb (err, mctx, state);
+#endif
+
+ /* Use transition table */
+ ch = re_string_fetch_byte (&mctx->input);
+ for (;;)
+ {
+ trtable = state->trtable;
+ if (__glibc_likely (trtable != NULL))
+ return trtable[ch];
+
+ trtable = state->word_trtable;
+ if (__glibc_likely (trtable != NULL))
+ {
+ unsigned int context;
+ context
+ = re_string_context_at (&mctx->input,
+ re_string_cur_idx (&mctx->input) - 1,
+ mctx->eflags);
+ if (IS_WORD_CONTEXT (context))
+ return trtable[ch + SBC_MAX];
+ else
+ return trtable[ch];
+ }
+
+ if (!build_trtable (mctx->dfa, state))
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
+
+ /* Retry, we now have a transition table. */
+ }
+}
+
+/* Update the state_log if we need */
+static re_dfastate_t *
+merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
+ re_dfastate_t *next_state)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ Idx cur_idx = re_string_cur_idx (&mctx->input);
+
+ if (cur_idx > mctx->state_log_top)
+ {
+ mctx->state_log[cur_idx] = next_state;
+ mctx->state_log_top = cur_idx;
+ }
+ else if (mctx->state_log[cur_idx] == 0)
+ {
+ mctx->state_log[cur_idx] = next_state;
+ }
+ else
+ {
+ re_dfastate_t *pstate;
+ unsigned int context;
+ re_node_set next_nodes, *log_nodes, *table_nodes = NULL;
+ /* If (state_log[cur_idx] != 0), it implies that cur_idx is
+ the destination of a multibyte char/collating element/
+ back reference. Then the next state is the union set of
+ these destinations and the results of the transition table. */
+ pstate = mctx->state_log[cur_idx];
+ log_nodes = pstate->entrance_nodes;
+ if (next_state != NULL)
+ {
+ table_nodes = next_state->entrance_nodes;
+ *err = re_node_set_init_union (&next_nodes, table_nodes,
+ log_nodes);
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ return NULL;
+ }
+ else
+ next_nodes = *log_nodes;
+ /* Note: We already add the nodes of the initial state,
+ then we don't need to add them here. */
+
+ context = re_string_context_at (&mctx->input,
+ re_string_cur_idx (&mctx->input) - 1,
+ mctx->eflags);
+ next_state = mctx->state_log[cur_idx]
+ = re_acquire_state_context (err, dfa, &next_nodes, context);
+ /* We don't need to check errors here, since the return value of
+ this function is next_state and ERR is already set. */
+
+ if (table_nodes != NULL)
+ re_node_set_free (&next_nodes);
+ }
+
+ if (__glibc_unlikely (dfa->nbackref) && next_state != NULL)
+ {
+ /* Check OP_OPEN_SUBEXP in the current state in case that we use them
+ later. We must check them here, since the back references in the
+ next state might use them. */
+ *err = check_subexp_matching_top (mctx, &next_state->nodes,
+ cur_idx);
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ return NULL;
+
+ /* If the next state has back references. */
+ if (next_state->has_backref)
+ {
+ *err = transit_state_bkref (mctx, &next_state->nodes);
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ return NULL;
+ next_state = mctx->state_log[cur_idx];
+ }
+ }
+
+ return next_state;
+}
+
+/* Skip bytes in the input that correspond to part of a
+ multi-byte match, then look in the log for a state
+ from which to restart matching. */
+static re_dfastate_t *
+find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
+{
+ re_dfastate_t *cur_state;
+ do
+ {
+ Idx max = mctx->state_log_top;
+ Idx cur_str_idx = re_string_cur_idx (&mctx->input);
+
+ do
+ {
+ if (++cur_str_idx > max)
+ return NULL;
+ re_string_skip_bytes (&mctx->input, 1);
+ }
+ while (mctx->state_log[cur_str_idx] == NULL);
+
+ cur_state = merge_state_with_log (err, mctx, NULL);
+ }
+ while (*err == REG_NOERROR && cur_state == NULL);
+ return cur_state;
+}
+
+/* Helper functions for transit_state. */
+
+/* From the node set CUR_NODES, pick up the nodes whose types are
+ OP_OPEN_SUBEXP and which have corresponding back references in the regular
+ expression. And register them to use them later for evaluating the
+ corresponding back references. */
+
+static reg_errcode_t
+check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
+ Idx str_idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ Idx node_idx;
+ reg_errcode_t err;
+
+ /* TODO: This isn't efficient.
+ Because there might be more than one nodes whose types are
+ OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all
+ nodes.
+ E.g. RE: (a){2} */
+ for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx)
+ {
+ Idx node = cur_nodes->elems[node_idx];
+ if (dfa->nodes[node].type == OP_OPEN_SUBEXP
+ && dfa->nodes[node].opr.idx < BITSET_WORD_BITS
+ && (dfa->used_bkref_map
+ & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx)))
+ {
+ err = match_ctx_add_subtop (mctx, node, str_idx);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ }
+ return REG_NOERROR;
+}
+
+#if 0
+/* Return the next state to which the current state STATE will transit by
+ accepting the current input byte. */
+
+static re_dfastate_t *
+transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
+ re_dfastate_t *state)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ re_node_set next_nodes;
+ re_dfastate_t *next_state;
+ Idx node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input);
+ unsigned int context;
+
+ *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1);
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ return NULL;
+ for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt)
+ {
+ Idx cur_node = state->nodes.elems[node_cnt];
+ if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx))
+ {
+ *err = re_node_set_merge (&next_nodes,
+ dfa->eclosures + dfa->nexts[cur_node]);
+ if (__glibc_unlikely (*err != REG_NOERROR))
+ {
+ re_node_set_free (&next_nodes);
+ return NULL;
+ }
+ }
+ }
+ context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags);
+ next_state = re_acquire_state_context (err, dfa, &next_nodes, context);
+ /* We don't need to check errors here, since the return value of
+ this function is next_state and ERR is already set. */
+
+ re_node_set_free (&next_nodes);
+ re_string_skip_bytes (&mctx->input, 1);
+ return next_state;
+}
+#endif
+
+#ifdef RE_ENABLE_I18N
+static reg_errcode_t
+transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err;
+ Idx i;
+
+ for (i = 0; i < pstate->nodes.nelem; ++i)
+ {
+ re_node_set dest_nodes, *new_nodes;
+ Idx cur_node_idx = pstate->nodes.elems[i];
+ int naccepted;
+ Idx dest_idx;
+ unsigned int context;
+ re_dfastate_t *dest_state;
+
+ if (!dfa->nodes[cur_node_idx].accept_mb)
+ continue;
+
+ if (dfa->nodes[cur_node_idx].constraint)
+ {
+ context = re_string_context_at (&mctx->input,
+ re_string_cur_idx (&mctx->input),
+ mctx->eflags);
+ if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint,
+ context))
+ continue;
+ }
+
+ /* How many bytes the node can accept? */
+ naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input,
+ re_string_cur_idx (&mctx->input));
+ if (naccepted == 0)
+ continue;
+
+ /* The node can accepts 'naccepted' bytes. */
+ dest_idx = re_string_cur_idx (&mctx->input) + naccepted;
+ mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
+ : mctx->max_mb_elem_len);
+ err = clean_state_log_if_needed (mctx, dest_idx);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+#ifdef DEBUG
+ assert (dfa->nexts[cur_node_idx] != -1);
+#endif
+ new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx];
+
+ dest_state = mctx->state_log[dest_idx];
+ if (dest_state == NULL)
+ dest_nodes = *new_nodes;
+ else
+ {
+ err = re_node_set_init_union (&dest_nodes,
+ dest_state->entrance_nodes, new_nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ context = re_string_context_at (&mctx->input, dest_idx - 1,
+ mctx->eflags);
+ mctx->state_log[dest_idx]
+ = re_acquire_state_context (&err, dfa, &dest_nodes, context);
+ if (dest_state != NULL)
+ re_node_set_free (&dest_nodes);
+ if (__glibc_unlikely (mctx->state_log[dest_idx] == NULL
+ && err != REG_NOERROR))
+ return err;
+ }
+ return REG_NOERROR;
+}
+#endif /* RE_ENABLE_I18N */
+
+static reg_errcode_t
+transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err;
+ Idx i;
+ Idx cur_str_idx = re_string_cur_idx (&mctx->input);
+
+ for (i = 0; i < nodes->nelem; ++i)
+ {
+ Idx dest_str_idx, prev_nelem, bkc_idx;
+ Idx node_idx = nodes->elems[i];
+ unsigned int context;
+ const re_token_t *node = dfa->nodes + node_idx;
+ re_node_set *new_dest_nodes;
+
+ /* Check whether 'node' is a backreference or not. */
+ if (node->type != OP_BACK_REF)
+ continue;
+
+ if (node->constraint)
+ {
+ context = re_string_context_at (&mctx->input, cur_str_idx,
+ mctx->eflags);
+ if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
+ continue;
+ }
+
+ /* 'node' is a backreference.
+ Check the substring which the substring matched. */
+ bkc_idx = mctx->nbkref_ents;
+ err = get_subexp (mctx, node_idx, cur_str_idx);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+
+ /* And add the epsilon closures (which is 'new_dest_nodes') of
+ the backreference to appropriate state_log. */
+#ifdef DEBUG
+ assert (dfa->nexts[node_idx] != -1);
+#endif
+ for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
+ {
+ Idx subexp_len;
+ re_dfastate_t *dest_state;
+ struct re_backref_cache_entry *bkref_ent;
+ bkref_ent = mctx->bkref_ents + bkc_idx;
+ if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx)
+ continue;
+ subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from;
+ new_dest_nodes = (subexp_len == 0
+ ? dfa->eclosures + dfa->edests[node_idx].elems[0]
+ : dfa->eclosures + dfa->nexts[node_idx]);
+ dest_str_idx = (cur_str_idx + bkref_ent->subexp_to
+ - bkref_ent->subexp_from);
+ context = re_string_context_at (&mctx->input, dest_str_idx - 1,
+ mctx->eflags);
+ dest_state = mctx->state_log[dest_str_idx];
+ prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0
+ : mctx->state_log[cur_str_idx]->nodes.nelem);
+ /* Add 'new_dest_node' to state_log. */
+ if (dest_state == NULL)
+ {
+ mctx->state_log[dest_str_idx]
+ = re_acquire_state_context (&err, dfa, new_dest_nodes,
+ context);
+ if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
+ && err != REG_NOERROR))
+ goto free_return;
+ }
+ else
+ {
+ re_node_set dest_nodes;
+ err = re_node_set_init_union (&dest_nodes,
+ dest_state->entrance_nodes,
+ new_dest_nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&dest_nodes);
+ goto free_return;
+ }
+ mctx->state_log[dest_str_idx]
+ = re_acquire_state_context (&err, dfa, &dest_nodes, context);
+ re_node_set_free (&dest_nodes);
+ if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
+ && err != REG_NOERROR))
+ goto free_return;
+ }
+ /* We need to check recursively if the backreference can epsilon
+ transit. */
+ if (subexp_len == 0
+ && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem)
+ {
+ err = check_subexp_matching_top (mctx, new_dest_nodes,
+ cur_str_idx);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+ err = transit_state_bkref (mctx, new_dest_nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto free_return;
+ }
+ }
+ }
+ err = REG_NOERROR;
+ free_return:
+ return err;
+}
+
+/* Enumerate all the candidates which the backreference BKREF_NODE can match
+ at BKREF_STR_IDX, and register them by match_ctx_add_entry().
+ Note that we might collect inappropriate candidates here.
+ However, the cost of checking them strictly here is too high, then we
+ delay these checking for prune_impossible_nodes(). */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ Idx subexp_num, sub_top_idx;
+ const char *buf = (const char *) re_string_get_buffer (&mctx->input);
+ /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */
+ Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx);
+ if (cache_idx != -1)
+ {
+ const struct re_backref_cache_entry *entry
+ = mctx->bkref_ents + cache_idx;
+ do
+ if (entry->node == bkref_node)
+ return REG_NOERROR; /* We already checked it. */
+ while (entry++->more);
+ }
+
+ subexp_num = dfa->nodes[bkref_node].opr.idx;
+
+ /* For each sub expression */
+ for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx)
+ {
+ reg_errcode_t err;
+ re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx];
+ re_sub_match_last_t *sub_last;
+ Idx sub_last_idx, sl_str, bkref_str_off;
+
+ if (dfa->nodes[sub_top->node].opr.idx != subexp_num)
+ continue; /* It isn't related. */
+
+ sl_str = sub_top->str_idx;
+ bkref_str_off = bkref_str_idx;
+ /* At first, check the last node of sub expressions we already
+ evaluated. */
+ for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx)
+ {
+ regoff_t sl_str_diff;
+ sub_last = sub_top->lasts[sub_last_idx];
+ sl_str_diff = sub_last->str_idx - sl_str;
+ /* The matched string by the sub expression match with the substring
+ at the back reference? */
+ if (sl_str_diff > 0)
+ {
+ if (__glibc_unlikely (bkref_str_off + sl_str_diff
+ > mctx->input.valid_len))
+ {
+ /* Not enough chars for a successful match. */
+ if (bkref_str_off + sl_str_diff > mctx->input.len)
+ break;
+
+ err = clean_state_log_if_needed (mctx,
+ bkref_str_off
+ + sl_str_diff);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ buf = (const char *) re_string_get_buffer (&mctx->input);
+ }
+ if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0)
+ /* We don't need to search this sub expression any more. */
+ break;
+ }
+ bkref_str_off += sl_str_diff;
+ sl_str += sl_str_diff;
+ err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
+ bkref_str_idx);
+
+ /* Reload buf, since the preceding call might have reallocated
+ the buffer. */
+ buf = (const char *) re_string_get_buffer (&mctx->input);
+
+ if (err == REG_NOMATCH)
+ continue;
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+
+ if (sub_last_idx < sub_top->nlasts)
+ continue;
+ if (sub_last_idx > 0)
+ ++sl_str;
+ /* Then, search for the other last nodes of the sub expression. */
+ for (; sl_str <= bkref_str_idx; ++sl_str)
+ {
+ Idx cls_node;
+ regoff_t sl_str_off;
+ const re_node_set *nodes;
+ sl_str_off = sl_str - sub_top->str_idx;
+ /* The matched string by the sub expression match with the substring
+ at the back reference? */
+ if (sl_str_off > 0)
+ {
+ if (__glibc_unlikely (bkref_str_off >= mctx->input.valid_len))
+ {
+ /* If we are at the end of the input, we cannot match. */
+ if (bkref_str_off >= mctx->input.len)
+ break;
+
+ err = extend_buffers (mctx, bkref_str_off + 1);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+
+ buf = (const char *) re_string_get_buffer (&mctx->input);
+ }
+ if (buf [bkref_str_off++] != buf[sl_str - 1])
+ break; /* We don't need to search this sub expression
+ any more. */
+ }
+ if (mctx->state_log[sl_str] == NULL)
+ continue;
+ /* Does this state have a ')' of the sub expression? */
+ nodes = &mctx->state_log[sl_str]->nodes;
+ cls_node = find_subexp_node (dfa, nodes, subexp_num,
+ OP_CLOSE_SUBEXP);
+ if (cls_node == -1)
+ continue; /* No. */
+ if (sub_top->path == NULL)
+ {
+ sub_top->path = calloc (sizeof (state_array_t),
+ sl_str - sub_top->str_idx + 1);
+ if (sub_top->path == NULL)
+ return REG_ESPACE;
+ }
+ /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node
+ in the current context? */
+ err = check_arrival (mctx, sub_top->path, sub_top->node,
+ sub_top->str_idx, cls_node, sl_str,
+ OP_CLOSE_SUBEXP);
+ if (err == REG_NOMATCH)
+ continue;
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);
+ if (__glibc_unlikely (sub_last == NULL))
+ return REG_ESPACE;
+ err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
+ bkref_str_idx);
+ buf = (const char *) re_string_get_buffer (&mctx->input);
+ if (err == REG_NOMATCH)
+ continue;
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ }
+ return REG_NOERROR;
+}
+
+/* Helper functions for get_subexp(). */
+
+/* Check SUB_LAST can arrive to the back reference BKREF_NODE at BKREF_STR.
+ If it can arrive, register the sub expression expressed with SUB_TOP
+ and SUB_LAST. */
+
+static reg_errcode_t
+get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
+ re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str)
+{
+ reg_errcode_t err;
+ Idx to_idx;
+ /* Can the subexpression arrive the back reference? */
+ err = check_arrival (mctx, &sub_last->path, sub_last->node,
+ sub_last->str_idx, bkref_node, bkref_str,
+ OP_OPEN_SUBEXP);
+ if (err != REG_NOERROR)
+ return err;
+ err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
+ sub_last->str_idx);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx;
+ return clean_state_log_if_needed (mctx, to_idx);
+}
+
+/* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX.
+ Search '(' if FL_OPEN, or search ')' otherwise.
+ TODO: This function isn't efficient...
+ Because there might be more than one nodes whose types are
+ OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all
+ nodes.
+ E.g. RE: (a){2} */
+
+static Idx
+find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
+ Idx subexp_idx, int type)
+{
+ Idx cls_idx;
+ for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx)
+ {
+ Idx cls_node = nodes->elems[cls_idx];
+ const re_token_t *node = dfa->nodes + cls_node;
+ if (node->type == type
+ && node->opr.idx == subexp_idx)
+ return cls_node;
+ }
+ return -1;
+}
+
+/* Check whether the node TOP_NODE at TOP_STR can arrive to the node
+ LAST_NODE at LAST_STR. We record the path onto PATH since it will be
+ heavily reused.
+ Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
+ Idx top_str, Idx last_node, Idx last_str, int type)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err = REG_NOERROR;
+ Idx subexp_num, backup_cur_idx, str_idx, null_cnt;
+ re_dfastate_t *cur_state = NULL;
+ re_node_set *cur_nodes, next_nodes;
+ re_dfastate_t **backup_state_log;
+ unsigned int context;
+
+ subexp_num = dfa->nodes[top_node].opr.idx;
+ /* Extend the buffer if we need. */
+ if (__glibc_unlikely (path->alloc < last_str + mctx->max_mb_elem_len + 1))
+ {
+ re_dfastate_t **new_array;
+ Idx old_alloc = path->alloc;
+ Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1;
+ Idx new_alloc;
+ if (__glibc_unlikely (IDX_MAX - old_alloc < incr_alloc))
+ return REG_ESPACE;
+ new_alloc = old_alloc + incr_alloc;
+ if (__glibc_unlikely (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc))
+ return REG_ESPACE;
+ new_array = re_realloc (path->array, re_dfastate_t *, new_alloc);
+ if (__glibc_unlikely (new_array == NULL))
+ return REG_ESPACE;
+ path->array = new_array;
+ path->alloc = new_alloc;
+ memset (new_array + old_alloc, '\0',
+ sizeof (re_dfastate_t *) * (path->alloc - old_alloc));
+ }
+
+ str_idx = path->next_idx ? path->next_idx : top_str;
+
+ /* Temporary modify MCTX. */
+ backup_state_log = mctx->state_log;
+ backup_cur_idx = mctx->input.cur_idx;
+ mctx->state_log = path->array;
+ mctx->input.cur_idx = str_idx;
+
+ /* Setup initial node set. */
+ context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
+ if (str_idx == top_str)
+ {
+ err = re_node_set_init_1 (&next_nodes, top_node);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ }
+ else
+ {
+ cur_state = mctx->state_log[str_idx];
+ if (cur_state && cur_state->has_backref)
+ {
+ err = re_node_set_init_copy (&next_nodes, &cur_state->nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ else
+ re_node_set_init_empty (&next_nodes);
+ }
+ if (str_idx == top_str || (cur_state && cur_state->has_backref))
+ {
+ if (next_nodes.nelem)
+ {
+ err = expand_bkref_cache (mctx, &next_nodes, str_idx,
+ subexp_num, type);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ }
+ cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
+ if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ mctx->state_log[str_idx] = cur_state;
+ }
+
+ for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;)
+ {
+ re_node_set_empty (&next_nodes);
+ if (mctx->state_log[str_idx + 1])
+ {
+ err = re_node_set_merge (&next_nodes,
+ &mctx->state_log[str_idx + 1]->nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ }
+ if (cur_state)
+ {
+ err = check_arrival_add_next_nodes (mctx, str_idx,
+ &cur_state->non_eps_nodes,
+ &next_nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ }
+ ++str_idx;
+ if (next_nodes.nelem)
+ {
+ err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ err = expand_bkref_cache (mctx, &next_nodes, str_idx,
+ subexp_num, type);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ }
+ context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
+ cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
+ if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
+ {
+ re_node_set_free (&next_nodes);
+ return err;
+ }
+ mctx->state_log[str_idx] = cur_state;
+ null_cnt = cur_state == NULL ? null_cnt + 1 : 0;
+ }
+ re_node_set_free (&next_nodes);
+ cur_nodes = (mctx->state_log[last_str] == NULL ? NULL
+ : &mctx->state_log[last_str]->nodes);
+ path->next_idx = str_idx;
+
+ /* Fix MCTX. */
+ mctx->state_log = backup_state_log;
+ mctx->input.cur_idx = backup_cur_idx;
+
+ /* Then check the current node set has the node LAST_NODE. */
+ if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node))
+ return REG_NOERROR;
+
+ return REG_NOMATCH;
+}
+
+/* Helper functions for check_arrival. */
+
+/* Calculate the destination nodes of CUR_NODES at STR_IDX, and append them
+ to NEXT_NODES.
+ TODO: This function is similar to the functions transit_state*(),
+ however this function has many additional works.
+ Can't we unify them? */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
+ re_node_set *cur_nodes, re_node_set *next_nodes)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ bool ok;
+ Idx cur_idx;
+#ifdef RE_ENABLE_I18N
+ reg_errcode_t err = REG_NOERROR;
+#endif
+ re_node_set union_set;
+ re_node_set_init_empty (&union_set);
+ for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
+ {
+ int naccepted = 0;
+ Idx cur_node = cur_nodes->elems[cur_idx];
+#ifdef DEBUG
+ re_token_type_t type = dfa->nodes[cur_node].type;
+ assert (!IS_EPSILON_NODE (type));
+#endif
+#ifdef RE_ENABLE_I18N
+ /* If the node may accept "multi byte". */
+ if (dfa->nodes[cur_node].accept_mb)
+ {
+ naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input,
+ str_idx);
+ if (naccepted > 1)
+ {
+ re_dfastate_t *dest_state;
+ Idx next_node = dfa->nexts[cur_node];
+ Idx next_idx = str_idx + naccepted;
+ dest_state = mctx->state_log[next_idx];
+ re_node_set_empty (&union_set);
+ if (dest_state)
+ {
+ err = re_node_set_merge (&union_set, &dest_state->nodes);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&union_set);
+ return err;
+ }
+ }
+ ok = re_node_set_insert (&union_set, next_node);
+ if (__glibc_unlikely (! ok))
+ {
+ re_node_set_free (&union_set);
+ return REG_ESPACE;
+ }
+ mctx->state_log[next_idx] = re_acquire_state (&err, dfa,
+ &union_set);
+ if (__glibc_unlikely (mctx->state_log[next_idx] == NULL
+ && err != REG_NOERROR))
+ {
+ re_node_set_free (&union_set);
+ return err;
+ }
+ }
+ }
+#endif /* RE_ENABLE_I18N */
+ if (naccepted
+ || check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
+ {
+ ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]);
+ if (__glibc_unlikely (! ok))
+ {
+ re_node_set_free (&union_set);
+ return REG_ESPACE;
+ }
+ }
+ }
+ re_node_set_free (&union_set);
+ return REG_NOERROR;
+}
+
+/* For all the nodes in CUR_NODES, add the epsilon closures of them to
+ CUR_NODES, however exclude the nodes which are:
+ - inside the sub expression whose number is EX_SUBEXP, if FL_OPEN.
+ - out of the sub expression whose number is EX_SUBEXP, if !FL_OPEN.
+*/
+
+static reg_errcode_t
+check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
+ Idx ex_subexp, int type)
+{
+ reg_errcode_t err;
+ Idx idx, outside_node;
+ re_node_set new_nodes;
+#ifdef DEBUG
+ assert (cur_nodes->nelem);
+#endif
+ err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ /* Create a new node set NEW_NODES with the nodes which are epsilon
+ closures of the node in CUR_NODES. */
+
+ for (idx = 0; idx < cur_nodes->nelem; ++idx)
+ {
+ Idx cur_node = cur_nodes->elems[idx];
+ const re_node_set *eclosure = dfa->eclosures + cur_node;
+ outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type);
+ if (outside_node == -1)
+ {
+ /* There are no problematic nodes, just merge them. */
+ err = re_node_set_merge (&new_nodes, eclosure);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&new_nodes);
+ return err;
+ }
+ }
+ else
+ {
+ /* There are problematic nodes, re-calculate incrementally. */
+ err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node,
+ ex_subexp, type);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ {
+ re_node_set_free (&new_nodes);
+ return err;
+ }
+ }
+ }
+ re_node_set_free (cur_nodes);
+ *cur_nodes = new_nodes;
+ return REG_NOERROR;
+}
+
+/* Helper function for check_arrival_expand_ecl.
+ Check incrementally the epsilon closure of TARGET, and if it isn't
+ problematic append it to DST_NODES. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
+ Idx target, Idx ex_subexp, int type)
+{
+ Idx cur_node;
+ for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);)
+ {
+ bool ok;
+
+ if (dfa->nodes[cur_node].type == type
+ && dfa->nodes[cur_node].opr.idx == ex_subexp)
+ {
+ if (type == OP_CLOSE_SUBEXP)
+ {
+ ok = re_node_set_insert (dst_nodes, cur_node);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ }
+ break;
+ }
+ ok = re_node_set_insert (dst_nodes, cur_node);
+ if (__glibc_unlikely (! ok))
+ return REG_ESPACE;
+ if (dfa->edests[cur_node].nelem == 0)
+ break;
+ if (dfa->edests[cur_node].nelem == 2)
+ {
+ reg_errcode_t err;
+ err = check_arrival_expand_ecl_sub (dfa, dst_nodes,
+ dfa->edests[cur_node].elems[1],
+ ex_subexp, type);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ cur_node = dfa->edests[cur_node].elems[0];
+ }
+ return REG_NOERROR;
+}
+
+
+/* For all the back references in the current state, calculate the
+ destination of the back references by the appropriate entry
+ in MCTX->BKREF_ENTS. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
+ Idx cur_str, Idx subexp_num, int type)
+{
+ const re_dfa_t *const dfa = mctx->dfa;
+ reg_errcode_t err;
+ Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str);
+ struct re_backref_cache_entry *ent;
+
+ if (cache_idx_start == -1)
+ return REG_NOERROR;
+
+ restart:
+ ent = mctx->bkref_ents + cache_idx_start;
+ do
+ {
+ Idx to_idx, next_node;
+
+ /* Is this entry ENT is appropriate? */
+ if (!re_node_set_contains (cur_nodes, ent->node))
+ continue; /* No. */
+
+ to_idx = cur_str + ent->subexp_to - ent->subexp_from;
+ /* Calculate the destination of the back reference, and append it
+ to MCTX->STATE_LOG. */
+ if (to_idx == cur_str)
+ {
+ /* The backreference did epsilon transit, we must re-check all the
+ node in the current state. */
+ re_node_set new_dests;
+ reg_errcode_t err2, err3;
+ next_node = dfa->edests[ent->node].elems[0];
+ if (re_node_set_contains (cur_nodes, next_node))
+ continue;
+ err = re_node_set_init_1 (&new_dests, next_node);
+ err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type);
+ err3 = re_node_set_merge (cur_nodes, &new_dests);
+ re_node_set_free (&new_dests);
+ if (__glibc_unlikely (err != REG_NOERROR || err2 != REG_NOERROR
+ || err3 != REG_NOERROR))
+ {
+ err = (err != REG_NOERROR ? err
+ : (err2 != REG_NOERROR ? err2 : err3));
+ return err;
+ }
+ /* TODO: It is still inefficient... */
+ goto restart;
+ }
+ else
+ {
+ re_node_set union_set;
+ next_node = dfa->nexts[ent->node];
+ if (mctx->state_log[to_idx])
+ {
+ bool ok;
+ if (re_node_set_contains (&mctx->state_log[to_idx]->nodes,
+ next_node))
+ continue;
+ err = re_node_set_init_copy (&union_set,
+ &mctx->state_log[to_idx]->nodes);
+ ok = re_node_set_insert (&union_set, next_node);
+ if (__glibc_unlikely (err != REG_NOERROR || ! ok))
+ {
+ re_node_set_free (&union_set);
+ err = err != REG_NOERROR ? err : REG_ESPACE;
+ return err;
+ }
+ }
+ else
+ {
+ err = re_node_set_init_1 (&union_set, next_node);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ return err;
+ }
+ mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
+ re_node_set_free (&union_set);
+ if (__glibc_unlikely (mctx->state_log[to_idx] == NULL
+ && err != REG_NOERROR))
+ return err;
+ }
+ }
+ while (ent++->more);
+ return REG_NOERROR;
+}
+
+/* Build transition table for the state.
+ Return true if successful. */
+
+static bool
+build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
+{
+ reg_errcode_t err;
+ Idx i, j;
+ int ch;
+ bool need_word_trtable = false;
+ bitset_word_t elem, mask;
+ bool dests_node_malloced = false;
+ bool dest_states_malloced = false;
+ Idx ndests; /* Number of the destination states from 'state'. */
+ re_dfastate_t **trtable;
+ re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl;
+ re_node_set follows, *dests_node;
+ bitset_t *dests_ch;
+ bitset_t acceptable;
+
+ struct dests_alloc
+ {
+ re_node_set dests_node[SBC_MAX];
+ bitset_t dests_ch[SBC_MAX];
+ } *dests_alloc;
+
+ /* We build DFA states which corresponds to the destination nodes
+ from 'state'. 'dests_node[i]' represents the nodes which i-th
+ destination state contains, and 'dests_ch[i]' represents the
+ characters which i-th destination state accepts. */
+ if (__libc_use_alloca (sizeof (struct dests_alloc)))
+ dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc));
+ else
+ {
+ dests_alloc = re_malloc (struct dests_alloc, 1);
+ if (__glibc_unlikely (dests_alloc == NULL))
+ return false;
+ dests_node_malloced = true;
+ }
+ dests_node = dests_alloc->dests_node;
+ dests_ch = dests_alloc->dests_ch;
+
+ /* Initialize transition table. */
+ state->word_trtable = state->trtable = NULL;
+
+ /* At first, group all nodes belonging to 'state' into several
+ destinations. */
+ ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
+ if (__glibc_unlikely (ndests <= 0))
+ {
+ if (dests_node_malloced)
+ re_free (dests_alloc);
+ /* Return false in case of an error, true otherwise. */
+ if (ndests == 0)
+ {
+ state->trtable = (re_dfastate_t **)
+ calloc (sizeof (re_dfastate_t *), SBC_MAX);
+ if (__glibc_unlikely (state->trtable == NULL))
+ return false;
+ return true;
+ }
+ return false;
+ }
+
+ err = re_node_set_alloc (&follows, ndests + 1);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto out_free;
+
+ /* Avoid arithmetic overflow in size calculation. */
+ size_t ndests_max
+ = ((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX)
+ / (3 * sizeof (re_dfastate_t *)));
+ if (__glibc_unlikely (ndests_max < ndests))
+ goto out_free;
+
+ if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX
+ + ndests * 3 * sizeof (re_dfastate_t *)))
+ dest_states = (re_dfastate_t **)
+ alloca (ndests * 3 * sizeof (re_dfastate_t *));
+ else
+ {
+ dest_states = re_malloc (re_dfastate_t *, ndests * 3);
+ if (__glibc_unlikely (dest_states == NULL))
+ {
+out_free:
+ if (dest_states_malloced)
+ re_free (dest_states);
+ re_node_set_free (&follows);
+ for (i = 0; i < ndests; ++i)
+ re_node_set_free (dests_node + i);
+ if (dests_node_malloced)
+ re_free (dests_alloc);
+ return false;
+ }
+ dest_states_malloced = true;
+ }
+ dest_states_word = dest_states + ndests;
+ dest_states_nl = dest_states_word + ndests;
+ bitset_empty (acceptable);
+
+ /* Then build the states for all destinations. */
+ for (i = 0; i < ndests; ++i)
+ {
+ Idx next_node;
+ re_node_set_empty (&follows);
+ /* Merge the follows of this destination states. */
+ for (j = 0; j < dests_node[i].nelem; ++j)
+ {
+ next_node = dfa->nexts[dests_node[i].elems[j]];
+ if (next_node != -1)
+ {
+ err = re_node_set_merge (&follows, dfa->eclosures + next_node);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto out_free;
+ }
+ }
+ dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0);
+ if (__glibc_unlikely (dest_states[i] == NULL && err != REG_NOERROR))
+ goto out_free;
+ /* If the new state has context constraint,
+ build appropriate states for these contexts. */
+ if (dest_states[i]->has_constraint)
+ {
+ dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows,
+ CONTEXT_WORD);
+ if (__glibc_unlikely (dest_states_word[i] == NULL
+ && err != REG_NOERROR))
+ goto out_free;
+
+ if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1)
+ need_word_trtable = true;
+
+ dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,
+ CONTEXT_NEWLINE);
+ if (__glibc_unlikely (dest_states_nl[i] == NULL && err != REG_NOERROR))
+ goto out_free;
+ }
+ else
+ {
+ dest_states_word[i] = dest_states[i];
+ dest_states_nl[i] = dest_states[i];
+ }
+ bitset_merge (acceptable, dests_ch[i]);
+ }
+
+ if (!__glibc_unlikely (need_word_trtable))
+ {
+ /* We don't care about whether the following character is a word
+ character, or we are in a single-byte character set so we can
+ discern by looking at the character code: allocate a
+ 256-entry transition table. */
+ trtable = state->trtable =
+ (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
+ if (__glibc_unlikely (trtable == NULL))
+ goto out_free;
+
+ /* For all characters ch...: */
+ for (i = 0; i < BITSET_WORDS; ++i)
+ for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
+ elem;
+ mask <<= 1, elem >>= 1, ++ch)
+ if (__glibc_unlikely (elem & 1))
+ {
+ /* There must be exactly one destination which accepts
+ character ch. See group_nodes_into_DFAstates. */
+ for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
+ ;
+
+ /* j-th destination accepts the word character ch. */
+ if (dfa->word_char[i] & mask)
+ trtable[ch] = dest_states_word[j];
+ else
+ trtable[ch] = dest_states[j];
+ }
+ }
+ else
+ {
+ /* We care about whether the following character is a word
+ character, and we are in a multi-byte character set: discern
+ by looking at the character code: build two 256-entry
+ transition tables, one starting at trtable[0] and one
+ starting at trtable[SBC_MAX]. */
+ trtable = state->word_trtable =
+ (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
+ if (__glibc_unlikely (trtable == NULL))
+ goto out_free;
+
+ /* For all characters ch...: */
+ for (i = 0; i < BITSET_WORDS; ++i)
+ for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
+ elem;
+ mask <<= 1, elem >>= 1, ++ch)
+ if (__glibc_unlikely (elem & 1))
+ {
+ /* There must be exactly one destination which accepts
+ character ch. See group_nodes_into_DFAstates. */
+ for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
+ ;
+
+ /* j-th destination accepts the word character ch. */
+ trtable[ch] = dest_states[j];
+ trtable[ch + SBC_MAX] = dest_states_word[j];
+ }
+ }
+
+ /* new line */
+ if (bitset_contain (acceptable, NEWLINE_CHAR))
+ {
+ /* The current state accepts newline character. */
+ for (j = 0; j < ndests; ++j)
+ if (bitset_contain (dests_ch[j], NEWLINE_CHAR))
+ {
+ /* k-th destination accepts newline character. */
+ trtable[NEWLINE_CHAR] = dest_states_nl[j];
+ if (need_word_trtable)
+ trtable[NEWLINE_CHAR + SBC_MAX] = dest_states_nl[j];
+ /* There must be only one destination which accepts
+ newline. See group_nodes_into_DFAstates. */
+ break;
+ }
+ }
+
+ if (dest_states_malloced)
+ re_free (dest_states);
+
+ re_node_set_free (&follows);
+ for (i = 0; i < ndests; ++i)
+ re_node_set_free (dests_node + i);
+
+ if (dests_node_malloced)
+ re_free (dests_alloc);
+
+ return true;
+}
+
+/* Group all nodes belonging to STATE into several destinations.
+ Then for all destinations, set the nodes belonging to the destination
+ to DESTS_NODE[i] and set the characters accepted by the destination
+ to DEST_CH[i]. This function return the number of destinations. */
+
+static Idx
+group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
+ re_node_set *dests_node, bitset_t *dests_ch)
+{
+ reg_errcode_t err;
+ bool ok;
+ Idx i, j, k;
+ Idx ndests; /* Number of the destinations from 'state'. */
+ bitset_t accepts; /* Characters a node can accept. */
+ const re_node_set *cur_nodes = &state->nodes;
+ bitset_empty (accepts);
+ ndests = 0;
+
+ /* For all the nodes belonging to 'state', */
+ for (i = 0; i < cur_nodes->nelem; ++i)
+ {
+ re_token_t *node = &dfa->nodes[cur_nodes->elems[i]];
+ re_token_type_t type = node->type;
+ unsigned int constraint = node->constraint;
+
+ /* Enumerate all single byte character this node can accept. */
+ if (type == CHARACTER)
+ bitset_set (accepts, node->opr.c);
+ else if (type == SIMPLE_BRACKET)
+ {
+ bitset_merge (accepts, node->opr.sbcset);
+ }
+ else if (type == OP_PERIOD)
+ {
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ bitset_merge (accepts, dfa->sb_char);
+ else
+#endif
+ bitset_set_all (accepts);
+ if (!(dfa->syntax & RE_DOT_NEWLINE))
+ bitset_clear (accepts, '\n');
+ if (dfa->syntax & RE_DOT_NOT_NULL)
+ bitset_clear (accepts, '\0');
+ }
+#ifdef RE_ENABLE_I18N
+ else if (type == OP_UTF8_PERIOD)
+ {
+ if (ASCII_CHARS % BITSET_WORD_BITS == 0)
+ memset (accepts, -1, ASCII_CHARS / CHAR_BIT);
+ else
+ bitset_merge (accepts, utf8_sb_map);
+ if (!(dfa->syntax & RE_DOT_NEWLINE))
+ bitset_clear (accepts, '\n');
+ if (dfa->syntax & RE_DOT_NOT_NULL)
+ bitset_clear (accepts, '\0');
+ }
+#endif
+ else
+ continue;
+
+ /* Check the 'accepts' and sift the characters which are not
+ match it the context. */
+ if (constraint)
+ {
+ if (constraint & NEXT_NEWLINE_CONSTRAINT)
+ {
+ bool accepts_newline = bitset_contain (accepts, NEWLINE_CHAR);
+ bitset_empty (accepts);
+ if (accepts_newline)
+ bitset_set (accepts, NEWLINE_CHAR);
+ else
+ continue;
+ }
+ if (constraint & NEXT_ENDBUF_CONSTRAINT)
+ {
+ bitset_empty (accepts);
+ continue;
+ }
+
+ if (constraint & NEXT_WORD_CONSTRAINT)
+ {
+ bitset_word_t any_set = 0;
+ if (type == CHARACTER && !node->word_char)
+ {
+ bitset_empty (accepts);
+ continue;
+ }
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ for (j = 0; j < BITSET_WORDS; ++j)
+ any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
+ else
+#endif
+ for (j = 0; j < BITSET_WORDS; ++j)
+ any_set |= (accepts[j] &= dfa->word_char[j]);
+ if (!any_set)
+ continue;
+ }
+ if (constraint & NEXT_NOTWORD_CONSTRAINT)
+ {
+ bitset_word_t any_set = 0;
+ if (type == CHARACTER && node->word_char)
+ {
+ bitset_empty (accepts);
+ continue;
+ }
+#ifdef RE_ENABLE_I18N
+ if (dfa->mb_cur_max > 1)
+ for (j = 0; j < BITSET_WORDS; ++j)
+ any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j]));
+ else
+#endif
+ for (j = 0; j < BITSET_WORDS; ++j)
+ any_set |= (accepts[j] &= ~dfa->word_char[j]);
+ if (!any_set)
+ continue;
+ }
+ }
+
+ /* Then divide 'accepts' into DFA states, or create a new
+ state. Above, we make sure that accepts is not empty. */
+ for (j = 0; j < ndests; ++j)
+ {
+ bitset_t intersec; /* Intersection sets, see below. */
+ bitset_t remains;
+ /* Flags, see below. */
+ bitset_word_t has_intersec, not_subset, not_consumed;
+
+ /* Optimization, skip if this state doesn't accept the character. */
+ if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c))
+ continue;
+
+ /* Enumerate the intersection set of this state and 'accepts'. */
+ has_intersec = 0;
+ for (k = 0; k < BITSET_WORDS; ++k)
+ has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k];
+ /* And skip if the intersection set is empty. */
+ if (!has_intersec)
+ continue;
+
+ /* Then check if this state is a subset of 'accepts'. */
+ not_subset = not_consumed = 0;
+ for (k = 0; k < BITSET_WORDS; ++k)
+ {
+ not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k];
+ not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k];
+ }
+
+ /* If this state isn't a subset of 'accepts', create a
+ new group state, which has the 'remains'. */
+ if (not_subset)
+ {
+ bitset_copy (dests_ch[ndests], remains);
+ bitset_copy (dests_ch[j], intersec);
+ err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto error_return;
+ ++ndests;
+ }
+
+ /* Put the position in the current group. */
+ ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]);
+ if (__glibc_unlikely (! ok))
+ goto error_return;
+
+ /* If all characters are consumed, go to next node. */
+ if (!not_consumed)
+ break;
+ }
+ /* Some characters remain, create a new group. */
+ if (j == ndests)
+ {
+ bitset_copy (dests_ch[ndests], accepts);
+ err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
+ if (__glibc_unlikely (err != REG_NOERROR))
+ goto error_return;
+ ++ndests;
+ bitset_empty (accepts);
+ }
+ }
+ return ndests;
+ error_return:
+ for (j = 0; j < ndests; ++j)
+ re_node_set_free (dests_node + j);
+ return -1;
+}
+
+#ifdef RE_ENABLE_I18N
+/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts.
+ Return the number of the bytes the node accepts.
+ STR_IDX is the current index of the input string.
+
+ This function handles the nodes which can accept one character, or
+ one collating element like '.', '[a-z]', opposite to the other nodes
+ can only accept one byte. */
+
+# ifdef _LIBC
+# include <locale/weight.h>
+# endif
+
+static int
+check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
+ const re_string_t *input, Idx str_idx)
+{
+ const re_token_t *node = dfa->nodes + node_idx;
+ int char_len, elem_len;
+ Idx i;
+
+ if (__glibc_unlikely (node->type == OP_UTF8_PERIOD))
+ {
+ unsigned char c = re_string_byte_at (input, str_idx), d;
+ if (__glibc_likely (c < 0xc2))
+ return 0;
+
+ if (str_idx + 2 > input->len)
+ return 0;
+
+ d = re_string_byte_at (input, str_idx + 1);
+ if (c < 0xe0)
+ return (d < 0x80 || d > 0xbf) ? 0 : 2;
+ else if (c < 0xf0)
+ {
+ char_len = 3;
+ if (c == 0xe0 && d < 0xa0)
+ return 0;
+ }
+ else if (c < 0xf8)
+ {
+ char_len = 4;
+ if (c == 0xf0 && d < 0x90)
+ return 0;
+ }
+ else if (c < 0xfc)
+ {
+ char_len = 5;
+ if (c == 0xf8 && d < 0x88)
+ return 0;
+ }
+ else if (c < 0xfe)
+ {
+ char_len = 6;
+ if (c == 0xfc && d < 0x84)
+ return 0;
+ }
+ else
+ return 0;
+
+ if (str_idx + char_len > input->len)
+ return 0;
+
+ for (i = 1; i < char_len; ++i)
+ {
+ d = re_string_byte_at (input, str_idx + i);
+ if (d < 0x80 || d > 0xbf)
+ return 0;
+ }
+ return char_len;
+ }
+
+ char_len = re_string_char_size_at (input, str_idx);
+ if (node->type == OP_PERIOD)
+ {
+ if (char_len <= 1)
+ return 0;
+ /* FIXME: I don't think this if is needed, as both '\n'
+ and '\0' are char_len == 1. */
+ /* '.' accepts any one character except the following two cases. */
+ if ((!(dfa->syntax & RE_DOT_NEWLINE) &&
+ re_string_byte_at (input, str_idx) == '\n') ||
+ ((dfa->syntax & RE_DOT_NOT_NULL) &&
+ re_string_byte_at (input, str_idx) == '\0'))
+ return 0;
+ return char_len;
+ }
+
+ elem_len = re_string_elem_size_at (input, str_idx);
+ if ((elem_len <= 1 && char_len <= 1) || char_len == 0)
+ return 0;
+
+ if (node->type == COMPLEX_BRACKET)
+ {
+ const re_charset_t *cset = node->opr.mbcset;
+# ifdef _LIBC
+ const unsigned char *pin
+ = ((const unsigned char *) re_string_get_buffer (input) + str_idx);
+ Idx j;
+ uint32_t nrules;
+# endif /* _LIBC */
+ int match_len = 0;
+ wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars)
+ ? re_string_wchar_at (input, str_idx) : 0);
+
+ /* match with multibyte character? */
+ for (i = 0; i < cset->nmbchars; ++i)
+ if (wc == cset->mbchars[i])
+ {
+ match_len = char_len;
+ goto check_node_accept_bytes_match;
+ }
+ /* match with character_class? */
+ for (i = 0; i < cset->nchar_classes; ++i)
+ {
+ wctype_t wt = cset->char_classes[i];
+ if (__iswctype (wc, wt))
+ {
+ match_len = char_len;
+ goto check_node_accept_bytes_match;
+ }
+ }
+
+# ifdef _LIBC
+ nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ if (nrules != 0)
+ {
+ unsigned int in_collseq = 0;
+ const int32_t *table, *indirect;
+ const unsigned char *weights, *extra;
+ const char *collseqwc;
+
+ /* match with collating_symbol? */
+ if (cset->ncoll_syms)
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+ for (i = 0; i < cset->ncoll_syms; ++i)
+ {
+ const unsigned char *coll_sym = extra + cset->coll_syms[i];
+ /* Compare the length of input collating element and
+ the length of current collating element. */
+ if (*coll_sym != elem_len)
+ continue;
+ /* Compare each bytes. */
+ for (j = 0; j < *coll_sym; j++)
+ if (pin[j] != coll_sym[1 + j])
+ break;
+ if (j == *coll_sym)
+ {
+ /* Match if every bytes is equal. */
+ match_len = j;
+ goto check_node_accept_bytes_match;
+ }
+ }
+
+ if (cset->nranges)
+ {
+ if (elem_len <= char_len)
+ {
+ collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
+ in_collseq = __collseq_table_lookup (collseqwc, wc);
+ }
+ else
+ in_collseq = find_collation_sequence_value (pin, elem_len);
+ }
+ /* match with range expression? */
+ /* FIXME: Implement rational ranges here, too. */
+ for (i = 0; i < cset->nranges; ++i)
+ if (cset->range_starts[i] <= in_collseq
+ && in_collseq <= cset->range_ends[i])
+ {
+ match_len = elem_len;
+ goto check_node_accept_bytes_match;
+ }
+
+ /* match with equivalence_class? */
+ if (cset->nequiv_classes)
+ {
+ const unsigned char *cp = pin;
+ table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+ weights = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
+ indirect = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
+ int32_t idx = findidx (table, indirect, extra, &cp, elem_len);
+ int32_t rule = idx >> 24;
+ idx &= 0xffffff;
+ if (idx > 0)
+ {
+ size_t weight_len = weights[idx];
+ for (i = 0; i < cset->nequiv_classes; ++i)
+ {
+ int32_t equiv_class_idx = cset->equiv_classes[i];
+ int32_t equiv_class_rule = equiv_class_idx >> 24;
+ equiv_class_idx &= 0xffffff;
+ if (weights[equiv_class_idx] == weight_len
+ && equiv_class_rule == rule
+ && memcmp (weights + idx + 1,
+ weights + equiv_class_idx + 1,
+ weight_len) == 0)
+ {
+ match_len = elem_len;
+ goto check_node_accept_bytes_match;
+ }
+ }
+ }
+ }
+ }
+ else
+# endif /* _LIBC */
+ {
+ /* match with range expression? */
+ for (i = 0; i < cset->nranges; ++i)
+ {
+ if (cset->range_starts[i] <= wc && wc <= cset->range_ends[i])
+ {
+ match_len = char_len;
+ goto check_node_accept_bytes_match;
+ }
+ }
+ }
+ check_node_accept_bytes_match:
+ if (!cset->non_match)
+ return match_len;
+ else
+ {
+ if (match_len > 0)
+ return 0;
+ else
+ return (elem_len > char_len) ? elem_len : char_len;
+ }
+ }
+ return 0;
+}
+
+# ifdef _LIBC
+static unsigned int
+find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
+{
+ uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ if (nrules == 0)
+ {
+ if (mbs_len == 1)
+ {
+ /* No valid character. Match it as a single byte character. */
+ const unsigned char *collseq = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
+ return collseq[mbs[0]];
+ }
+ return UINT_MAX;
+ }
+ else
+ {
+ int32_t idx;
+ const unsigned char *extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+ int32_t extrasize = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra;
+
+ for (idx = 0; idx < extrasize;)
+ {
+ int mbs_cnt;
+ bool found = false;
+ int32_t elem_mbs_len;
+ /* Skip the name of collating element name. */
+ idx = idx + extra[idx] + 1;
+ elem_mbs_len = extra[idx++];
+ if (mbs_len == elem_mbs_len)
+ {
+ for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt)
+ if (extra[idx + mbs_cnt] != mbs[mbs_cnt])
+ break;
+ if (mbs_cnt == elem_mbs_len)
+ /* Found the entry. */
+ found = true;
+ }
+ /* Skip the byte sequence of the collating element. */
+ idx += elem_mbs_len;
+ /* Adjust for the alignment. */
+ idx = (idx + 3) & ~3;
+ /* Skip the collation sequence value. */
+ idx += sizeof (uint32_t);
+ /* Skip the wide char sequence of the collating element. */
+ idx = idx + sizeof (uint32_t) * (*(int32_t *) (extra + idx) + 1);
+ /* If we found the entry, return the sequence value. */
+ if (found)
+ return *(uint32_t *) (extra + idx);
+ /* Skip the collation sequence value. */
+ idx += sizeof (uint32_t);
+ }
+ return UINT_MAX;
+ }
+}
+# endif /* _LIBC */
+#endif /* RE_ENABLE_I18N */
+
+/* Check whether the node accepts the byte which is IDX-th
+ byte of the INPUT. */
+
+static bool
+check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
+ Idx idx)
+{
+ unsigned char ch;
+ ch = re_string_byte_at (&mctx->input, idx);
+ switch (node->type)
+ {
+ case CHARACTER:
+ if (node->opr.c != ch)
+ return false;
+ break;
+
+ case SIMPLE_BRACKET:
+ if (!bitset_contain (node->opr.sbcset, ch))
+ return false;
+ break;
+
+#ifdef RE_ENABLE_I18N
+ case OP_UTF8_PERIOD:
+ if (ch >= ASCII_CHARS)
+ return false;
+ FALLTHROUGH;
+#endif
+ case OP_PERIOD:
+ if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
+ || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
+ return false;
+ break;
+
+ default:
+ return false;
+ }
+
+ if (node->constraint)
+ {
+ /* The node has constraints. Check whether the current context
+ satisfies the constraints. */
+ unsigned int context = re_string_context_at (&mctx->input, idx,
+ mctx->eflags);
+ if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
+ return false;
+ }
+
+ return true;
+}
+
+/* Extend the buffers, if the buffers have run out. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+extend_buffers (re_match_context_t *mctx, int min_len)
+{
+ reg_errcode_t ret;
+ re_string_t *pstr = &mctx->input;
+
+ /* Avoid overflow. */
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2
+ <= pstr->bufs_len))
+ return REG_ESPACE;
+
+ /* Double the lengths of the buffers, but allocate at least MIN_LEN. */
+ ret = re_string_realloc_buffers (pstr,
+ MAX (min_len,
+ MIN (pstr->len, pstr->bufs_len * 2)));
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+
+ if (mctx->state_log != NULL)
+ {
+ /* And double the length of state_log. */
+ /* XXX We have no indication of the size of this buffer. If this
+ allocation fail we have no indication that the state_log array
+ does not have the right size. */
+ re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *,
+ pstr->bufs_len + 1);
+ if (__glibc_unlikely (new_array == NULL))
+ return REG_ESPACE;
+ mctx->state_log = new_array;
+ }
+
+ /* Then reconstruct the buffers. */
+ if (pstr->icase)
+ {
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ {
+ ret = build_wcs_upper_buffer (pstr);
+ if (__glibc_unlikely (ret != REG_NOERROR))
+ return ret;
+ }
+ else
+#endif /* RE_ENABLE_I18N */
+ build_upper_buffer (pstr);
+ }
+ else
+ {
+#ifdef RE_ENABLE_I18N
+ if (pstr->mb_cur_max > 1)
+ build_wcs_buffer (pstr);
+ else
+#endif /* RE_ENABLE_I18N */
+ {
+ if (pstr->trans != NULL)
+ re_string_translate_buffer (pstr);
+ }
+ }
+ return REG_NOERROR;
+}
+
+
+/* Functions for matching context. */
+
+/* Initialize MCTX. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
+{
+ mctx->eflags = eflags;
+ mctx->match_last = -1;
+ if (n > 0)
+ {
+ /* Avoid overflow. */
+ size_t max_object_size =
+ MAX (sizeof (struct re_backref_cache_entry),
+ sizeof (re_sub_match_top_t *));
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n))
+ return REG_ESPACE;
+
+ mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
+ mctx->sub_tops = re_malloc (re_sub_match_top_t *, n);
+ if (__glibc_unlikely (mctx->bkref_ents == NULL || mctx->sub_tops == NULL))
+ return REG_ESPACE;
+ }
+ /* Already zero-ed by the caller.
+ else
+ mctx->bkref_ents = NULL;
+ mctx->nbkref_ents = 0;
+ mctx->nsub_tops = 0; */
+ mctx->abkref_ents = n;
+ mctx->max_mb_elem_len = 1;
+ mctx->asub_tops = n;
+ return REG_NOERROR;
+}
+
+/* Clean the entries which depend on the current input in MCTX.
+ This function must be invoked when the matcher changes the start index
+ of the input, or changes the input string. */
+
+static void
+match_ctx_clean (re_match_context_t *mctx)
+{
+ Idx st_idx;
+ for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx)
+ {
+ Idx sl_idx;
+ re_sub_match_top_t *top = mctx->sub_tops[st_idx];
+ for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx)
+ {
+ re_sub_match_last_t *last = top->lasts[sl_idx];
+ re_free (last->path.array);
+ re_free (last);
+ }
+ re_free (top->lasts);
+ if (top->path)
+ {
+ re_free (top->path->array);
+ re_free (top->path);
+ }
+ re_free (top);
+ }
+
+ mctx->nsub_tops = 0;
+ mctx->nbkref_ents = 0;
+}
+
+/* Free all the memory associated with MCTX. */
+
+static void
+match_ctx_free (re_match_context_t *mctx)
+{
+ /* First, free all the memory associated with MCTX->SUB_TOPS. */
+ match_ctx_clean (mctx);
+ re_free (mctx->sub_tops);
+ re_free (mctx->bkref_ents);
+}
+
+/* Add a new backreference entry to MCTX.
+ Note that we assume that caller never call this function with duplicate
+ entry, and call with STR_IDX which isn't smaller than any existing entry.
+*/
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
+ Idx to)
+{
+ if (mctx->nbkref_ents >= mctx->abkref_ents)
+ {
+ struct re_backref_cache_entry* new_entry;
+ new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry,
+ mctx->abkref_ents * 2);
+ if (__glibc_unlikely (new_entry == NULL))
+ {
+ re_free (mctx->bkref_ents);
+ return REG_ESPACE;
+ }
+ mctx->bkref_ents = new_entry;
+ memset (mctx->bkref_ents + mctx->nbkref_ents, '\0',
+ sizeof (struct re_backref_cache_entry) * mctx->abkref_ents);
+ mctx->abkref_ents *= 2;
+ }
+ if (mctx->nbkref_ents > 0
+ && mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx)
+ mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1;
+
+ mctx->bkref_ents[mctx->nbkref_ents].node = node;
+ mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx;
+ mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from;
+ mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to;
+
+ /* This is a cache that saves negative results of check_dst_limits_calc_pos.
+ If bit N is clear, means that this entry won't epsilon-transition to
+ an OP_OPEN_SUBEXP or OP_CLOSE_SUBEXP for the N+1-th subexpression. If
+ it is set, check_dst_limits_calc_pos_1 will recurse and try to find one
+ such node.
+
+ A backreference does not epsilon-transition unless it is empty, so set
+ to all zeros if FROM != TO. */
+ mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map
+ = (from == to ? -1 : 0);
+
+ mctx->bkref_ents[mctx->nbkref_ents++].more = 0;
+ if (mctx->max_mb_elem_len < to - from)
+ mctx->max_mb_elem_len = to - from;
+ return REG_NOERROR;
+}
+
+/* Return the first entry with the same str_idx, or -1 if none is
+ found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */
+
+static Idx
+search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
+{
+ Idx left, right, mid, last;
+ last = right = mctx->nbkref_ents;
+ for (left = 0; left < right;)
+ {
+ mid = (left + right) / 2;
+ if (mctx->bkref_ents[mid].str_idx < str_idx)
+ left = mid + 1;
+ else
+ right = mid;
+ }
+ if (left < last && mctx->bkref_ents[left].str_idx == str_idx)
+ return left;
+ else
+ return -1;
+}
+
+/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches
+ at STR_IDX. */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
+{
+#ifdef DEBUG
+ assert (mctx->sub_tops != NULL);
+ assert (mctx->asub_tops > 0);
+#endif
+ if (__glibc_unlikely (mctx->nsub_tops == mctx->asub_tops))
+ {
+ Idx new_asub_tops = mctx->asub_tops * 2;
+ re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops,
+ re_sub_match_top_t *,
+ new_asub_tops);
+ if (__glibc_unlikely (new_array == NULL))
+ return REG_ESPACE;
+ mctx->sub_tops = new_array;
+ mctx->asub_tops = new_asub_tops;
+ }
+ mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t));
+ if (__glibc_unlikely (mctx->sub_tops[mctx->nsub_tops] == NULL))
+ return REG_ESPACE;
+ mctx->sub_tops[mctx->nsub_tops]->node = node;
+ mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;
+ return REG_NOERROR;
+}
+
+/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches
+ at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */
+
+static re_sub_match_last_t *
+match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
+{
+ re_sub_match_last_t *new_entry;
+ if (__glibc_unlikely (subtop->nlasts == subtop->alasts))
+ {
+ Idx new_alasts = 2 * subtop->alasts + 1;
+ re_sub_match_last_t **new_array = re_realloc (subtop->lasts,
+ re_sub_match_last_t *,
+ new_alasts);
+ if (__glibc_unlikely (new_array == NULL))
+ return NULL;
+ subtop->lasts = new_array;
+ subtop->alasts = new_alasts;
+ }
+ new_entry = calloc (1, sizeof (re_sub_match_last_t));
+ if (__glibc_likely (new_entry != NULL))
+ {
+ subtop->lasts[subtop->nlasts] = new_entry;
+ new_entry->node = node;
+ new_entry->str_idx = str_idx;
+ ++subtop->nlasts;
+ }
+ return new_entry;
+}
+
+static void
+sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
+ re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx)
+{
+ sctx->sifted_states = sifted_sts;
+ sctx->limited_states = limited_sts;
+ sctx->last_node = last_node;
+ sctx->last_str_idx = last_str_idx;
+ re_node_set_init_empty (&sctx->limits);
+}
diff --git a/grub-core/lib/gnulib/save-cwd.c b/grub-core/lib/gnulib/save-cwd.c
new file mode 100644
index 0000000..a67d95d
--- /dev/null
+++ b/grub-core/lib/gnulib/save-cwd.c
@@ -0,0 +1,97 @@
+/* save-cwd.c -- Save and restore current working directory.
+
+ Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering. */
+
+#include <config.h>
+
+#include "save-cwd.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "chdir-long.h"
+#include "unistd--.h"
+
+#if GNULIB_FCNTL_SAFER
+# include "fcntl--.h"
+#else
+# define GNULIB_FCNTL_SAFER 0
+#endif
+
+/* Record the location of the current working directory in CWD so that
+ the program may change to other directories and later use restore_cwd
+ to return to the recorded location. This function may allocate
+ space using malloc (via getcwd) or leave a file descriptor open;
+ use free_cwd to perform the necessary free or close. Upon failure,
+ no memory is allocated, any locally opened file descriptors are
+ closed; return non-zero -- in that case, free_cwd need not be
+ called, but doing so is ok. Otherwise, return zero.
+
+ The _raison d'etre_ for this interface is that the working directory
+ is sometimes inaccessible, and getcwd is not robust or as efficient.
+ So, we prefer to use the open/fchdir approach, but fall back on
+ getcwd if necessary. This module works for most cases with just
+ the getcwd-lgpl module, but to be truly robust, use the getcwd module.
+
+ Some systems lack fchdir altogether: e.g., OS/2, pre-2001 Cygwin,
+ SCO Xenix. Also, SunOS 4 and Irix 5.3 provide the function, yet it
+ doesn't work for partitions on which auditing is enabled. If
+ you're still using an obsolete system with these problems, please
+ send email to the maintainer of this code. */
+
+int
+save_cwd (struct saved_cwd *cwd)
+{
+ cwd->name = NULL;
+
+ cwd->desc = open (".", O_SEARCH | O_CLOEXEC);
+ if (!GNULIB_FCNTL_SAFER)
+ cwd->desc = fd_safer_flag (cwd->desc, O_CLOEXEC);
+ if (cwd->desc < 0)
+ {
+ cwd->name = getcwd (NULL, 0);
+ return cwd->name ? 0 : -1;
+ }
+
+ return 0;
+}
+
+/* Change to recorded location, CWD, in directory hierarchy.
+ Upon failure, return -1 (errno is set by chdir or fchdir).
+ Upon success, return zero. */
+
+int
+restore_cwd (const struct saved_cwd *cwd)
+{
+ if (0 <= cwd->desc)
+ return fchdir (cwd->desc);
+ else
+ return chdir_long (cwd->name);
+}
+
+void
+free_cwd (struct saved_cwd *cwd)
+{
+ if (cwd->desc >= 0)
+ close (cwd->desc);
+ free (cwd->name);
+}
diff --git a/grub-core/lib/gnulib/save-cwd.h b/grub-core/lib/gnulib/save-cwd.h
new file mode 100644
index 0000000..6a78070
--- /dev/null
+++ b/grub-core/lib/gnulib/save-cwd.h
@@ -0,0 +1,34 @@
+/* Save and restore current working directory.
+
+ Copyright (C) 1995, 1997-1998, 2003, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering. */
+
+#ifndef SAVE_CWD_H
+# define SAVE_CWD_H 1
+
+struct saved_cwd
+ {
+ int desc;
+ char *name;
+ };
+
+int save_cwd (struct saved_cwd *cwd);
+int restore_cwd (const struct saved_cwd *cwd);
+void free_cwd (struct saved_cwd *cwd);
+
+#endif /* SAVE_CWD_H */
diff --git a/grub-core/lib/gnulib/size_max.h b/grub-core/lib/gnulib/size_max.h
new file mode 100644
index 0000000..e265fb9
--- /dev/null
+++ b/grub-core/lib/gnulib/size_max.h
@@ -0,0 +1,30 @@
+/* size_max.h -- declare SIZE_MAX through system headers
+ Copyright (C) 2005-2006, 2009-2019 Free Software Foundation, Inc.
+ Written by Simon Josefsson.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef GNULIB_SIZE_MAX_H
+#define GNULIB_SIZE_MAX_H
+
+/* Get SIZE_MAX declaration on systems like Solaris 7/8/9. */
+# include <limits.h>
+/* Get SIZE_MAX declaration on systems like glibc 2. */
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
+/* On systems where these include files don't define it, SIZE_MAX is defined
+ in config.h. */
+
+#endif /* GNULIB_SIZE_MAX_H */
diff --git a/grub-core/lib/gnulib/sleep.c b/grub-core/lib/gnulib/sleep.c
new file mode 100644
index 0000000..c5218e5
--- /dev/null
+++ b/grub-core/lib/gnulib/sleep.c
@@ -0,0 +1,76 @@
+/* Pausing execution of the current thread.
+ Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2007.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+#include <limits.h>
+
+#include "verify.h"
+
+#if defined _WIN32 && ! defined __CYGWIN__
+
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include <windows.h>
+
+unsigned int
+sleep (unsigned int seconds)
+{
+ unsigned int remaining;
+
+ /* Sleep for 1 second many times, because
+ 1. Sleep is not interruptible by Ctrl-C,
+ 2. we want to avoid arithmetic overflow while multiplying with 1000. */
+ for (remaining = seconds; remaining > 0; remaining--)
+ Sleep (1000);
+
+ return remaining;
+}
+
+#elif HAVE_SLEEP
+
+# undef sleep
+
+/* Guarantee unlimited sleep and a reasonable return value. Cygwin
+ 1.5.x rejects attempts to sleep more than 49.7 days (2**32
+ milliseconds), but uses uninitialized memory which results in a
+ garbage answer. Similarly, Linux 2.6.9 with glibc 2.3.4 has a too
+ small return value when asked to sleep more than 24.85 days. */
+unsigned int
+rpl_sleep (unsigned int seconds)
+{
+ /* This requires int larger than 16 bits. */
+ verify (UINT_MAX / 24 / 24 / 60 / 60);
+ const unsigned int limit = 24 * 24 * 60 * 60;
+ while (limit < seconds)
+ {
+ unsigned int result;
+ seconds -= limit;
+ result = sleep (limit);
+ if (result)
+ return seconds + result;
+ }
+ return sleep (seconds);
+}
+
+#else /* !HAVE_SLEEP */
+
+ #error "Please port gnulib sleep.c to your platform, possibly using usleep() or select(), then report this to bug-gnulib."
+
+#endif
diff --git a/grub-core/lib/gnulib/stat-time.c b/grub-core/lib/gnulib/stat-time.c
new file mode 100644
index 0000000..81b83dd
--- /dev/null
+++ b/grub-core/lib/gnulib/stat-time.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE
+#include "stat-time.h"
diff --git a/grub-core/lib/gnulib/stat-time.h b/grub-core/lib/gnulib/stat-time.h
new file mode 100644
index 0000000..d4f1f96
--- /dev/null
+++ b/grub-core/lib/gnulib/stat-time.h
@@ -0,0 +1,252 @@
+/* stat-related time functions.
+
+ Copyright (C) 2005, 2007, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#ifndef STAT_TIME_H
+#define STAT_TIME_H 1
+
+#include "intprops.h"
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <time.h>
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_STAT_TIME_INLINE
+# define _GL_STAT_TIME_INLINE _GL_INLINE
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type
+ struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST,
+ ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST,
+ if available. ST_XTIM can be st_atim, st_ctim, st_mtim, or st_birthtim
+ for access, status change, data modification, or birth (creation)
+ time respectively.
+
+ These macros are private to stat-time.h. */
+#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
+# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
+# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim)
+# else
+# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec)
+# endif
+#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
+# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec)
+#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC
+# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec)
+#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC
+# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec)
+#endif
+
+/* Return the nanosecond component of *ST's access time. */
+_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
+get_stat_atime_ns (struct stat const *st)
+{
+# if defined STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_atim).tv_nsec;
+# elif defined STAT_TIMESPEC_NS
+ return STAT_TIMESPEC_NS (st, st_atim);
+# else
+ return 0;
+# endif
+}
+
+/* Return the nanosecond component of *ST's status change time. */
+_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
+get_stat_ctime_ns (struct stat const *st)
+{
+# if defined STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_ctim).tv_nsec;
+# elif defined STAT_TIMESPEC_NS
+ return STAT_TIMESPEC_NS (st, st_ctim);
+# else
+ return 0;
+# endif
+}
+
+/* Return the nanosecond component of *ST's data modification time. */
+_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
+get_stat_mtime_ns (struct stat const *st)
+{
+# if defined STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_mtim).tv_nsec;
+# elif defined STAT_TIMESPEC_NS
+ return STAT_TIMESPEC_NS (st, st_mtim);
+# else
+ return 0;
+# endif
+}
+
+/* Return the nanosecond component of *ST's birth time. */
+_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
+get_stat_birthtime_ns (struct stat const *st _GL_UNUSED)
+{
+# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
+ return STAT_TIMESPEC (st, st_birthtim).tv_nsec;
+# elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
+ return STAT_TIMESPEC_NS (st, st_birthtim);
+# else
+ return 0;
+# endif
+}
+
+/* Return *ST's access time. */
+_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
+get_stat_atime (struct stat const *st)
+{
+#ifdef STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_atim);
+#else
+ struct timespec t;
+ t.tv_sec = st->st_atime;
+ t.tv_nsec = get_stat_atime_ns (st);
+ return t;
+#endif
+}
+
+/* Return *ST's status change time. */
+_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
+get_stat_ctime (struct stat const *st)
+{
+#ifdef STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_ctim);
+#else
+ struct timespec t;
+ t.tv_sec = st->st_ctime;
+ t.tv_nsec = get_stat_ctime_ns (st);
+ return t;
+#endif
+}
+
+/* Return *ST's data modification time. */
+_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
+get_stat_mtime (struct stat const *st)
+{
+#ifdef STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_mtim);
+#else
+ struct timespec t;
+ t.tv_sec = st->st_mtime;
+ t.tv_nsec = get_stat_mtime_ns (st);
+ return t;
+#endif
+}
+
+/* Return *ST's birth time, if available; otherwise return a value
+ with tv_sec and tv_nsec both equal to -1. */
+_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
+get_stat_birthtime (struct stat const *st _GL_UNUSED)
+{
+ struct timespec t;
+
+#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
+ || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
+ t = STAT_TIMESPEC (st, st_birthtim);
+#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
+ t.tv_sec = st->st_birthtime;
+ t.tv_nsec = st->st_birthtimensec;
+#elif defined _WIN32 && ! defined __CYGWIN__
+ /* Native Windows platforms (but not Cygwin) put the "file creation
+ time" in st_ctime (!). See
+ <https://msdn.microsoft.com/en-us/library/14h5k7ff(VS.80).aspx>. */
+# if _GL_WINDOWS_STAT_TIMESPEC
+ t = st->st_ctim;
+# else
+ t.tv_sec = st->st_ctime;
+ t.tv_nsec = 0;
+# endif
+#else
+ /* Birth time is not supported. */
+ t.tv_sec = -1;
+ t.tv_nsec = -1;
+#endif
+
+#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
+ || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \
+ || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC)
+ /* FreeBSD and NetBSD sometimes signal the absence of knowledge by
+ using zero. Attempt to work around this problem. Alas, this can
+ report failure even for valid timestamps. Also, NetBSD
+ sometimes returns junk in the birth time fields; work around this
+ bug if it is detected. */
+ if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000))
+ {
+ t.tv_sec = -1;
+ t.tv_nsec = -1;
+ }
+#endif
+
+ return t;
+}
+
+/* If a stat-like function returned RESULT, normalize the timestamps
+ in *ST, in case this platform suffers from the Solaris 11 bug where
+ tv_nsec might be negative. Return the adjusted RESULT, setting
+ errno to EOVERFLOW if normalization overflowed. This function
+ is intended to be private to this .h file. */
+_GL_STAT_TIME_INLINE int
+stat_time_normalize (int result, struct stat *st _GL_UNUSED)
+{
+#if defined __sun && defined STAT_TIMESPEC
+ if (result == 0)
+ {
+ long int timespec_hz = 1000000000;
+ short int const ts_off[] = { offsetof (struct stat, st_atim),
+ offsetof (struct stat, st_mtim),
+ offsetof (struct stat, st_ctim) };
+ int i;
+ for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++)
+ {
+ struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]);
+ long int q = ts->tv_nsec / timespec_hz;
+ long int r = ts->tv_nsec % timespec_hz;
+ if (r < 0)
+ {
+ r += timespec_hz;
+ q--;
+ }
+ ts->tv_nsec = r;
+ /* Overflow is possible, as Solaris 11 stat can yield
+ tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000.
+ INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */
+ if (INT_ADD_WRAPV (q, ts->tv_sec, &ts->tv_sec))
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
+ }
+ }
+#endif
+ return result;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+_GL_INLINE_HEADER_END
+
+#endif
diff --git a/grub-core/lib/gnulib/stat-w32.c b/grub-core/lib/gnulib/stat-w32.c
new file mode 100644
index 0000000..ffa9942
--- /dev/null
+++ b/grub-core/lib/gnulib/stat-w32.c
@@ -0,0 +1,425 @@
+/* Core of implementation of fstat and stat for native Windows.
+ Copyright (C) 2017-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible. */
+
+#include <config.h>
+
+#if defined _WIN32 && ! defined __CYGWIN__
+
+/* Ensure that <windows.h> defines FILE_ID_INFO. */
+#undef _WIN32_WINNT
+#define _WIN32_WINNT _WIN32_WINNT_WIN8
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <limits.h>
+#include <string.h>
+#include <unistd.h>
+#include <windows.h>
+
+/* Specification. */
+#include "stat-w32.h"
+
+#include "pathmax.h"
+#include "verify.h"
+
+/* Avoid warnings from gcc -Wcast-function-type. */
+#define GetProcAddress \
+ (void *) GetProcAddress
+
+#if _GL_WINDOWS_STAT_INODES == 2
+/* GetFileInformationByHandleEx was introduced only in Windows Vista. */
+typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile,
+ FILE_INFO_BY_HANDLE_CLASS fiClass,
+ LPVOID lpBuffer,
+ DWORD dwBufferSize);
+static GetFileInformationByHandleExFuncType GetFileInformationByHandleExFunc = NULL;
+#endif
+/* GetFinalPathNameByHandle was introduced only in Windows Vista. */
+typedef DWORD (WINAPI * GetFinalPathNameByHandleFuncType) (HANDLE hFile,
+ LPTSTR lpFilePath,
+ DWORD lenFilePath,
+ DWORD dwFlags);
+static GetFinalPathNameByHandleFuncType GetFinalPathNameByHandleFunc = NULL;
+static BOOL initialized = FALSE;
+
+static void
+initialize (void)
+{
+ HMODULE kernel32 = LoadLibrary ("kernel32.dll");
+ if (kernel32 != NULL)
+ {
+#if _GL_WINDOWS_STAT_INODES == 2
+ GetFileInformationByHandleExFunc =
+ (GetFileInformationByHandleExFuncType) GetProcAddress (kernel32, "GetFileInformationByHandleEx");
+#endif
+ GetFinalPathNameByHandleFunc =
+ (GetFinalPathNameByHandleFuncType) GetProcAddress (kernel32, "GetFinalPathNameByHandleA");
+ }
+ initialized = TRUE;
+}
+
+/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */
+#if _GL_WINDOWS_STAT_TIMESPEC
+struct timespec
+_gl_convert_FILETIME_to_timespec (const FILETIME *ft)
+{
+ struct timespec result;
+ /* FILETIME: <https://msdn.microsoft.com/en-us/library/ms724284.aspx> */
+ unsigned long long since_1601 =
+ ((unsigned long long) ft->dwHighDateTime << 32)
+ | (unsigned long long) ft->dwLowDateTime;
+ if (since_1601 == 0)
+ {
+ result.tv_sec = 0;
+ result.tv_nsec = 0;
+ }
+ else
+ {
+ /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89
+ leap years, in total 134774 days. */
+ unsigned long long since_1970 =
+ since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000;
+ result.tv_sec = since_1970 / (unsigned long long) 10000000;
+ result.tv_nsec = (unsigned long) (since_1970 % (unsigned long long) 10000000) * 100;
+ }
+ return result;
+}
+#else
+time_t
+_gl_convert_FILETIME_to_POSIX (const FILETIME *ft)
+{
+ /* FILETIME: <https://msdn.microsoft.com/en-us/library/ms724284.aspx> */
+ unsigned long long since_1601 =
+ ((unsigned long long) ft->dwHighDateTime << 32)
+ | (unsigned long long) ft->dwLowDateTime;
+ if (since_1601 == 0)
+ return 0;
+ else
+ {
+ /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89
+ leap years, in total 134774 days. */
+ unsigned long long since_1970 =
+ since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000;
+ return since_1970 / (unsigned long long) 10000000;
+ }
+}
+#endif
+
+/* Fill *BUF with information about the file designated by H.
+ PATH is the file name, if known, otherwise NULL.
+ Return 0 if successful, or -1 with errno set upon failure. */
+int
+_gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf)
+{
+ /* GetFileType
+ <https://msdn.microsoft.com/en-us/library/aa364960.aspx> */
+ DWORD type = GetFileType (h);
+ if (type == FILE_TYPE_DISK)
+ {
+ if (!initialized)
+ initialize ();
+
+ /* st_mode can be determined through
+ GetFileAttributesEx
+ <https://msdn.microsoft.com/en-us/library/aa364946.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa365739.aspx>
+ or through
+ GetFileInformationByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364952.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363788.aspx>
+ or through
+ GetFileInformationByHandleEx with argument FileBasicInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364217.aspx>
+ The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
+ BY_HANDLE_FILE_INFORMATION info;
+ if (! GetFileInformationByHandle (h, &info))
+ goto failed;
+
+ /* Test for error conditions before starting to fill *buf. */
+ if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0)
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+#if _GL_WINDOWS_STAT_INODES
+ /* st_ino can be determined through
+ GetFileInformationByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364952.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363788.aspx>
+ as 64 bits, or through
+ GetFileInformationByHandleEx with argument FileIdInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/hh802691.aspx>
+ as 128 bits.
+ The latter requires -D_WIN32_WINNT=_WIN32_WINNT_WIN8 or higher. */
+ /* Experiments show that GetFileInformationByHandleEx does not provide
+ much more information than GetFileInformationByHandle:
+ * The dwVolumeSerialNumber from GetFileInformationByHandle is equal
+ to the low 32 bits of the 64-bit VolumeSerialNumber from
+ GetFileInformationByHandleEx, and is apparently sufficient for
+ identifying the device.
+ * The nFileIndex from GetFileInformationByHandle is equal to the low
+ 64 bits of the 128-bit FileId from GetFileInformationByHandleEx,
+ and the high 64 bits of this 128-bit FileId are zero.
+ * On a FAT file system, GetFileInformationByHandleEx fails with error
+ ERROR_INVALID_PARAMETER, whereas GetFileInformationByHandle
+ succeeds.
+ * On a CIFS/SMB file system, GetFileInformationByHandleEx fails with
+ error ERROR_INVALID_LEVEL, whereas GetFileInformationByHandle
+ succeeds. */
+# if _GL_WINDOWS_STAT_INODES == 2
+ if (GetFileInformationByHandleExFunc != NULL)
+ {
+ FILE_ID_INFO id;
+ if (GetFileInformationByHandleExFunc (h, FileIdInfo, &id, sizeof (id)))
+ {
+ buf->st_dev = id.VolumeSerialNumber;
+ verify (sizeof (ino_t) == sizeof (id.FileId));
+ memcpy (&buf->st_ino, &id.FileId, sizeof (ino_t));
+ goto ino_done;
+ }
+ else
+ {
+ switch (GetLastError ())
+ {
+ case ERROR_INVALID_PARAMETER: /* older Windows version, or FAT */
+ case ERROR_INVALID_LEVEL: /* CIFS/SMB file system */
+ goto fallback;
+ default:
+ goto failed;
+ }
+ }
+ }
+ fallback: ;
+ /* Fallback for older Windows versions. */
+ buf->st_dev = info.dwVolumeSerialNumber;
+ buf->st_ino._gl_ino[0] = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow;
+ buf->st_ino._gl_ino[1] = 0;
+ ino_done: ;
+# else /* _GL_WINDOWS_STAT_INODES == 1 */
+ buf->st_dev = info.dwVolumeSerialNumber;
+ buf->st_ino = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow;
+# endif
+#else
+ /* st_ino is not wide enough for identifying a file on a device.
+ Without st_ino, st_dev is pointless. */
+ buf->st_dev = 0;
+ buf->st_ino = 0;
+#endif
+
+ /* st_mode. */
+ unsigned int mode =
+ /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */
+ ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG)
+ | S_IREAD_UGO
+ | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO);
+ if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ /* Determine whether the file is executable by looking at the file
+ name suffix.
+ If the file name is already known, use it. Otherwise, for
+ non-empty files, it can be determined through
+ GetFinalPathNameByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364962.aspx>
+ or through
+ GetFileInformationByHandleEx with argument FileNameInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364388.aspx>
+ Both require -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
+ if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
+ {
+ char fpath[PATH_MAX];
+ if (path != NULL
+ || (GetFinalPathNameByHandleFunc != NULL
+ && GetFinalPathNameByHandleFunc (h, fpath, sizeof (fpath), VOLUME_NAME_NONE)
+ < sizeof (fpath)
+ && (path = fpath, 1)))
+ {
+ const char *last_dot = NULL;
+ const char *p;
+ for (p = path; *p != '\0'; p++)
+ if (*p == '.')
+ last_dot = p;
+ if (last_dot != NULL)
+ {
+ const char *suffix = last_dot + 1;
+ if (_stricmp (suffix, "exe") == 0
+ || _stricmp (suffix, "bat") == 0
+ || _stricmp (suffix, "cmd") == 0
+ || _stricmp (suffix, "com") == 0)
+ mode |= S_IEXEC_UGO;
+ }
+ }
+ else
+ /* Cannot determine file name. Pretend that it is executable. */
+ mode |= S_IEXEC_UGO;
+ }
+ }
+ buf->st_mode = mode;
+
+ /* st_nlink can be determined through
+ GetFileInformationByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364952.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363788.aspx>
+ or through
+ GetFileInformationByHandleEx with argument FileStandardInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364401.aspx>
+ The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
+ buf->st_nlink = (info.nNumberOfLinks > SHRT_MAX ? SHRT_MAX : info.nNumberOfLinks);
+
+ /* There's no easy way to map the Windows SID concept to an integer. */
+ buf->st_uid = 0;
+ buf->st_gid = 0;
+
+ /* st_rdev is irrelevant for normal files and directories. */
+ buf->st_rdev = 0;
+
+ /* st_size can be determined through
+ GetFileSizeEx
+ <https://msdn.microsoft.com/en-us/library/aa364957.aspx>
+ or through
+ GetFileAttributesEx
+ <https://msdn.microsoft.com/en-us/library/aa364946.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa365739.aspx>
+ or through
+ GetFileInformationByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364952.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363788.aspx>
+ or through
+ GetFileInformationByHandleEx with argument FileStandardInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364401.aspx>
+ The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
+ if (sizeof (buf->st_size) <= 4)
+ /* Range check already done above. */
+ buf->st_size = info.nFileSizeLow;
+ else
+ buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow;
+
+ /* st_atime, st_mtime, st_ctime can be determined through
+ GetFileTime
+ <https://msdn.microsoft.com/en-us/library/ms724320.aspx>
+ or through
+ GetFileAttributesEx
+ <https://msdn.microsoft.com/en-us/library/aa364946.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa365739.aspx>
+ or through
+ GetFileInformationByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364952.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363788.aspx>
+ or through
+ GetFileInformationByHandleEx with argument FileBasicInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364217.aspx>
+ The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
+#if _GL_WINDOWS_STAT_TIMESPEC
+ buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime);
+ buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime);
+ buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime);
+#else
+ buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime);
+ buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime);
+ buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime);
+#endif
+
+ return 0;
+ }
+ else if (type == FILE_TYPE_CHAR || type == FILE_TYPE_PIPE)
+ {
+ buf->st_dev = 0;
+#if _GL_WINDOWS_STAT_INODES == 2
+ buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0;
+#else
+ buf->st_ino = 0;
+#endif
+ buf->st_mode = (type == FILE_TYPE_PIPE ? _S_IFIFO : _S_IFCHR);
+ buf->st_nlink = 1;
+ buf->st_uid = 0;
+ buf->st_gid = 0;
+ buf->st_rdev = 0;
+ if (type == FILE_TYPE_PIPE)
+ {
+ /* PeekNamedPipe
+ <https://msdn.microsoft.com/en-us/library/aa365779.aspx> */
+ DWORD bytes_available;
+ if (PeekNamedPipe (h, NULL, 0, NULL, &bytes_available, NULL))
+ buf->st_size = bytes_available;
+ else
+ buf->st_size = 0;
+ }
+ else
+ buf->st_size = 0;
+#if _GL_WINDOWS_STAT_TIMESPEC
+ buf->st_atim.tv_sec = 0; buf->st_atim.tv_nsec = 0;
+ buf->st_mtim.tv_sec = 0; buf->st_mtim.tv_nsec = 0;
+ buf->st_ctim.tv_sec = 0; buf->st_ctim.tv_nsec = 0;
+#else
+ buf->st_atime = 0;
+ buf->st_mtime = 0;
+ buf->st_ctime = 0;
+#endif
+ return 0;
+ }
+ else
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ failed:
+ {
+ DWORD error = GetLastError ();
+ #if 0
+ fprintf (stderr, "_gl_fstat_by_handle error 0x%x\n", (unsigned int) error);
+ #endif
+ switch (error)
+ {
+ case ERROR_ACCESS_DENIED:
+ case ERROR_SHARING_VIOLATION:
+ errno = EACCES;
+ break;
+
+ case ERROR_OUTOFMEMORY:
+ errno = ENOMEM;
+ break;
+
+ case ERROR_WRITE_FAULT:
+ case ERROR_READ_FAULT:
+ case ERROR_GEN_FAILURE:
+ errno = EIO;
+ break;
+
+ default:
+ errno = EINVAL;
+ break;
+ }
+ return -1;
+ }
+}
+
+#else
+
+/* This declaration is solely to ensure that after preprocessing
+ this file is never empty. */
+typedef int dummy;
+
+#endif
diff --git a/grub-core/lib/gnulib/stat-w32.h b/grub-core/lib/gnulib/stat-w32.h
new file mode 100644
index 0000000..6b961d7
--- /dev/null
+++ b/grub-core/lib/gnulib/stat-w32.h
@@ -0,0 +1,37 @@
+/* Core of implementation of fstat and stat for native Windows.
+ Copyright (C) 2017-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _STAT_W32_H
+#define _STAT_W32_H 1
+
+/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */
+#if _GL_WINDOWS_STAT_TIMESPEC
+extern struct timespec _gl_convert_FILETIME_to_timespec (const FILETIME *ft);
+#else
+extern time_t _gl_convert_FILETIME_to_POSIX (const FILETIME *ft);
+#endif
+
+/* Fill *BUF with information about the file designated by H.
+ PATH is the file name, if known, otherwise NULL.
+ Return 0 if successful, or -1 with errno set upon failure. */
+extern int _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf);
+
+/* Bitmasks for st_mode. */
+#define S_IREAD_UGO (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6))
+#define S_IWRITE_UGO (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
+#define S_IEXEC_UGO (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6))
+
+#endif /* _STAT_W32_H */
diff --git a/grub-core/lib/gnulib/stat.c b/grub-core/lib/gnulib/stat.c
new file mode 100644
index 0000000..74f4795
--- /dev/null
+++ b/grub-core/lib/gnulib/stat.c
@@ -0,0 +1,429 @@
+/* Work around platform bugs in stat.
+ Copyright (C) 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Eric Blake and Bruno Haible. */
+
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+ the system's <sys/stat.h> here, so that orig_stat doesn't recurse to
+ rpl_stat. */
+#define __need_system_sys_stat_h
+#include <config.h>
+
+/* Get the original definition of stat. It might be defined as a macro. */
+#include <sys/types.h>
+#include <sys/stat.h>
+#undef __need_system_sys_stat_h
+
+#if defined _WIN32 && ! defined __CYGWIN__
+# define WINDOWS_NATIVE
+#endif
+
+#if !defined WINDOWS_NATIVE
+
+static int
+orig_stat (const char *filename, struct stat *buf)
+{
+ return stat (filename, buf);
+}
+
+#endif
+
+/* Specification. */
+/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
+ eliminates this include because of the preliminary #include <sys/stat.h>
+ above. */
+#include "sys/stat.h"
+
+#include "stat-time.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <string.h>
+#include "filename.h"
+#include "malloca.h"
+#include "verify.h"
+
+#ifdef WINDOWS_NATIVE
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# include "stat-w32.h"
+#endif
+
+#ifdef WINDOWS_NATIVE
+/* Return TRUE if the given file name denotes an UNC root. */
+static BOOL
+is_unc_root (const char *rname)
+{
+ /* Test whether it has the syntax '\\server\share'. */
+ if (ISSLASH (rname[0]) && ISSLASH (rname[1]))
+ {
+ /* It starts with two slashes. Find the next slash. */
+ const char *p = rname + 2;
+ const char *q = p;
+ while (*q != '\0' && !ISSLASH (*q))
+ q++;
+ if (q > p && *q != '\0')
+ {
+ /* Found the next slash at q. */
+ q++;
+ const char *r = q;
+ while (*r != '\0' && !ISSLASH (*r))
+ r++;
+ if (r > q && *r == '\0')
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+#endif
+
+/* Store information about NAME into ST. Work around bugs with
+ trailing slashes. Mingw has other bugs (such as st_ino always
+ being 0 on success) which this wrapper does not work around. But
+ at least this implementation provides the ability to emulate fchdir
+ correctly. */
+
+int
+rpl_stat (char const *name, struct stat *buf)
+{
+#ifdef WINDOWS_NATIVE
+ /* Fill the fields ourselves, because the original stat function returns
+ values for st_atime, st_mtime, st_ctime that depend on the current time
+ zone. See
+ <https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html> */
+ /* XXX Should we convert to wchar_t* and prepend '\\?\', in order to work
+ around length limitations
+ <https://msdn.microsoft.com/en-us/library/aa365247.aspx> ? */
+
+ /* POSIX <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>
+ specifies: "More than two leading <slash> characters shall be treated as
+ a single <slash> character." */
+ if (ISSLASH (name[0]) && ISSLASH (name[1]) && ISSLASH (name[2]))
+ {
+ name += 2;
+ while (ISSLASH (name[1]))
+ name++;
+ }
+
+ size_t len = strlen (name);
+ size_t drive_prefix_len = (HAS_DEVICE (name) ? 2 : 0);
+
+ /* Remove trailing slashes (except the very first one, at position
+ drive_prefix_len), but remember their presence. */
+ size_t rlen;
+ bool check_dir = false;
+
+ rlen = len;
+ while (rlen > drive_prefix_len && ISSLASH (name[rlen-1]))
+ {
+ check_dir = true;
+ if (rlen == drive_prefix_len + 1)
+ break;
+ rlen--;
+ }
+
+ /* Handle '' and 'C:'. */
+ if (!check_dir && rlen == drive_prefix_len)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ /* Handle '\\'. */
+ if (rlen == 1 && ISSLASH (name[0]) && len >= 2)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ const char *rname;
+ char *malloca_rname;
+ if (rlen == len)
+ {
+ rname = name;
+ malloca_rname = NULL;
+ }
+ else
+ {
+ malloca_rname = malloca (rlen + 1);
+ if (malloca_rname == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ memcpy (malloca_rname, name, rlen);
+ malloca_rname[rlen] = '\0';
+ rname = malloca_rname;
+ }
+
+ /* There are two ways to get at the requested information:
+ - by scanning the parent directory and examining the relevant
+ directory entry,
+ - by opening the file directly.
+ The first approach fails for root directories (e.g. 'C:\') and
+ UNC root directories (e.g. '\\server\share').
+ The second approach fails for some system files (e.g. 'C:\pagefile.sys'
+ and 'C:\hiberfil.sys'): ERROR_SHARING_VIOLATION.
+ The second approach gives more information (in particular, correct
+ st_dev, st_ino, st_nlink fields).
+ So we use the second approach and, as a fallback except for root and
+ UNC root directories, also the first approach. */
+ {
+ int ret;
+
+ {
+ /* Approach based on the file. */
+
+ /* Open a handle to the file.
+ CreateFile
+ <https://msdn.microsoft.com/en-us/library/aa363858.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363874.aspx> */
+ HANDLE h =
+ CreateFile (rname,
+ FILE_READ_ATTRIBUTES,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ OPEN_EXISTING,
+ /* FILE_FLAG_POSIX_SEMANTICS (treat file names that differ only
+ in case as different) makes sense only when applied to *all*
+ filesystem operations. */
+ FILE_FLAG_BACKUP_SEMANTICS /* | FILE_FLAG_POSIX_SEMANTICS */,
+ NULL);
+ if (h != INVALID_HANDLE_VALUE)
+ {
+ ret = _gl_fstat_by_handle (h, rname, buf);
+ CloseHandle (h);
+ goto done;
+ }
+ }
+
+ /* Test for root and UNC root directories. */
+ if ((rlen == drive_prefix_len + 1 && ISSLASH (rname[drive_prefix_len]))
+ || is_unc_root (rname))
+ goto failed;
+
+ /* Fallback. */
+ {
+ /* Approach based on the directory entry. */
+
+ if (strchr (rname, '?') != NULL || strchr (rname, '*') != NULL)
+ {
+ /* Other Windows API functions would fail with error
+ ERROR_INVALID_NAME. */
+ if (malloca_rname != NULL)
+ freea (malloca_rname);
+ errno = ENOENT;
+ return -1;
+ }
+
+ /* Get the details about the directory entry. This can be done through
+ FindFirstFile
+ <https://msdn.microsoft.com/en-us/library/aa364418.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa365740.aspx>
+ or through
+ FindFirstFileEx with argument FindExInfoBasic
+ <https://msdn.microsoft.com/en-us/library/aa364419.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364415.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa365740.aspx> */
+ WIN32_FIND_DATA info;
+ HANDLE h = FindFirstFile (rname, &info);
+ if (h == INVALID_HANDLE_VALUE)
+ goto failed;
+
+ /* Test for error conditions before starting to fill *buf. */
+ if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0)
+ {
+ FindClose (h);
+ if (malloca_rname != NULL)
+ freea (malloca_rname);
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+# if _GL_WINDOWS_STAT_INODES
+ buf->st_dev = 0;
+# if _GL_WINDOWS_STAT_INODES == 2
+ buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0;
+# else /* _GL_WINDOWS_STAT_INODES == 1 */
+ buf->st_ino = 0;
+# endif
+# else
+ /* st_ino is not wide enough for identifying a file on a device.
+ Without st_ino, st_dev is pointless. */
+ buf->st_dev = 0;
+ buf->st_ino = 0;
+# endif
+
+ /* st_mode. */
+ unsigned int mode =
+ /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */
+ ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG)
+ | S_IREAD_UGO
+ | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO);
+ if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ /* Determine whether the file is executable by looking at the file
+ name suffix. */
+ if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
+ {
+ const char *last_dot = NULL;
+ const char *p;
+ for (p = info.cFileName; *p != '\0'; p++)
+ if (*p == '.')
+ last_dot = p;
+ if (last_dot != NULL)
+ {
+ const char *suffix = last_dot + 1;
+ if (_stricmp (suffix, "exe") == 0
+ || _stricmp (suffix, "bat") == 0
+ || _stricmp (suffix, "cmd") == 0
+ || _stricmp (suffix, "com") == 0)
+ mode |= S_IEXEC_UGO;
+ }
+ }
+ }
+ buf->st_mode = mode;
+
+ /* st_nlink. Ignore hard links here. */
+ buf->st_nlink = 1;
+
+ /* There's no easy way to map the Windows SID concept to an integer. */
+ buf->st_uid = 0;
+ buf->st_gid = 0;
+
+ /* st_rdev is irrelevant for normal files and directories. */
+ buf->st_rdev = 0;
+
+ /* st_size. */
+ if (sizeof (buf->st_size) <= 4)
+ /* Range check already done above. */
+ buf->st_size = info.nFileSizeLow;
+ else
+ buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow;
+
+ /* st_atime, st_mtime, st_ctime. */
+# if _GL_WINDOWS_STAT_TIMESPEC
+ buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime);
+ buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime);
+ buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime);
+# else
+ buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime);
+ buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime);
+ buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime);
+# endif
+
+ FindClose (h);
+
+ ret = 0;
+ }
+
+ done:
+ if (ret >= 0 && check_dir && !S_ISDIR (buf->st_mode))
+ {
+ errno = ENOTDIR;
+ ret = -1;
+ }
+ if (malloca_rname != NULL)
+ {
+ int saved_errno = errno;
+ freea (malloca_rname);
+ errno = saved_errno;
+ }
+ return ret;
+ }
+
+ failed:
+ {
+ DWORD error = GetLastError ();
+ #if 0
+ fprintf (stderr, "rpl_stat error 0x%x\n", (unsigned int) error);
+ #endif
+
+ if (malloca_rname != NULL)
+ freea (malloca_rname);
+
+ switch (error)
+ {
+ /* Some of these errors probably cannot happen with the specific flags
+ that we pass to CreateFile. But who knows... */
+ case ERROR_FILE_NOT_FOUND: /* The last component of rname does not exist. */
+ case ERROR_PATH_NOT_FOUND: /* Some directory component in rname does not exist. */
+ case ERROR_BAD_PATHNAME: /* rname is such as '\\server'. */
+ case ERROR_BAD_NET_NAME: /* rname is such as '\\server\nonexistentshare'. */
+ case ERROR_INVALID_NAME: /* rname contains wildcards, misplaced colon, etc. */
+ case ERROR_DIRECTORY:
+ errno = ENOENT;
+ break;
+
+ case ERROR_ACCESS_DENIED: /* rname is such as 'C:\System Volume Information\foo'. */
+ case ERROR_SHARING_VIOLATION: /* rname is such as 'C:\pagefile.sys' (second approach only). */
+ /* XXX map to EACCESS or EPERM? */
+ errno = EACCES;
+ break;
+
+ case ERROR_OUTOFMEMORY:
+ errno = ENOMEM;
+ break;
+
+ case ERROR_WRITE_PROTECT:
+ errno = EROFS;
+ break;
+
+ case ERROR_WRITE_FAULT:
+ case ERROR_READ_FAULT:
+ case ERROR_GEN_FAILURE:
+ errno = EIO;
+ break;
+
+ case ERROR_BUFFER_OVERFLOW:
+ case ERROR_FILENAME_EXCED_RANGE:
+ errno = ENAMETOOLONG;
+ break;
+
+ case ERROR_DELETE_PENDING: /* XXX map to EACCESS or EPERM? */
+ errno = EPERM;
+ break;
+
+ default:
+ errno = EINVAL;
+ break;
+ }
+
+ return -1;
+ }
+#else
+ int result = orig_stat (name, buf);
+ if (result == 0)
+ {
+# if REPLACE_FUNC_STAT_FILE
+ /* Solaris 9 mistakenly succeeds when given a non-directory with a
+ trailing slash. */
+ if (!S_ISDIR (buf->st_mode))
+ {
+ size_t len = strlen (name);
+ if (ISSLASH (name[len - 1]))
+ {
+ errno = ENOTDIR;
+ return -1;
+ }
+ }
+# endif /* REPLACE_FUNC_STAT_FILE */
+ result = stat_time_normalize (result, buf);
+ }
+ return result;
+#endif
+}
diff --git a/grub-core/lib/gnulib/stdalign.in.h b/grub-core/lib/gnulib/stdalign.in.h
new file mode 100644
index 0000000..d988d7c
--- /dev/null
+++ b/grub-core/lib/gnulib/stdalign.in.h
@@ -0,0 +1,121 @@
+/* A substitute for ISO C11 <stdalign.h>.
+
+ Copyright 2011-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert and Bruno Haible. */
+
+#ifndef _GL_STDALIGN_H
+#define _GL_STDALIGN_H
+
+/* ISO C11 <stdalign.h> for platforms that lack it.
+
+ References:
+ ISO C11 (latest free draft
+ <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
+ sections 6.5.3.4, 6.7.5, 7.15.
+ C++11 (latest free draft
+ <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
+ section 18.10. */
+
+/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment
+ requirement of a structure member (i.e., slot or field) that is of
+ type TYPE, as an integer constant expression.
+
+ This differs from GCC's __alignof__ operator, which can yield a
+ better-performing alignment for an object of that type. For
+ example, on x86 with GCC, __alignof__ (double) and __alignof__
+ (long long) are 8, whereas alignof (double) and alignof (long long)
+ are 4 unless the option '-malign-double' is used.
+
+ The result cannot be used as a value for an 'enum' constant, if you
+ want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.
+
+ Include <stddef.h> for offsetof. */
+#include <stddef.h>
+
+/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
+ standard headers, defines conflicting implementations of _Alignas
+ and _Alignof that are no better than ours; override them. */
+#undef _Alignas
+#undef _Alignof
+
+/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
+ <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
+#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
+ || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9)))
+# ifdef __cplusplus
+# if 201103 <= __cplusplus
+# define _Alignof(type) alignof (type)
+# else
+ template <class __t> struct __alignof_helper { char __a; __t __b; };
+# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
+# endif
+# else
+# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
+# endif
+#endif
+#if ! (defined __cplusplus && 201103 <= __cplusplus)
+# define alignof _Alignof
+#endif
+#define __alignof_is_defined 1
+
+/* alignas (A), also known as _Alignas (A), aligns a variable or type
+ to the alignment A, where A is an integer constant expression. For
+ example:
+
+ int alignas (8) foo;
+ struct s { int a; int alignas (8) bar; };
+
+ aligns the address of FOO and the offset of BAR to be multiples of 8.
+
+ A should be a power of two that is at least the type's alignment
+ and at most the implementation's alignment limit. This limit is
+ 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable
+ to MSVC through at least version 10.0, A should be an integer
+ constant, as MSVC does not support expressions such as 1 << 3.
+ To be portable to Sun C 5.11, do not align auto variables to
+ anything stricter than their default alignment.
+
+ The following C11 requirements are not supported here:
+
+ - If A is zero, alignas has no effect.
+ - alignas can be used multiple times; the strictest one wins.
+ - alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
+
+ */
+
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
+# if defined __cplusplus && 201103 <= __cplusplus
+# define _Alignas(a) alignas (a)
+# elif ((defined __APPLE__ && defined __MACH__ \
+ ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
+ : __GNUC__) \
+ || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
+ || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)
+# define _Alignas(a) __attribute__ ((__aligned__ (a)))
+# elif 1300 <= _MSC_VER
+# define _Alignas(a) __declspec (align (a))
+# endif
+#endif
+#if ((defined _Alignas && ! (defined __cplusplus && 201103 <= __cplusplus)) \
+ || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
+# define alignas _Alignas
+#endif
+#if defined alignas || (defined __cplusplus && 201103 <= __cplusplus)
+# define __alignas_is_defined 1
+#endif
+
+#endif /* _GL_STDALIGN_H */
diff --git a/grub-core/lib/gnulib/stdbool.in.h b/grub-core/lib/gnulib/stdbool.in.h
new file mode 100644
index 0000000..8158b00
--- /dev/null
+++ b/grub-core/lib/gnulib/stdbool.in.h
@@ -0,0 +1,132 @@
+/* Copyright (C) 2001-2003, 2006-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_STDBOOL_H
+#define _GL_STDBOOL_H
+
+/* ISO C 99 <stdbool.h> for platforms that lack it. */
+
+/* Usage suggestions:
+
+ Programs that use <stdbool.h> should be aware of some limitations
+ and standards compliance issues.
+
+ Standards compliance:
+
+ - <stdbool.h> must be #included before 'bool', 'false', 'true'
+ can be used.
+
+ - You cannot assume that sizeof (bool) == 1.
+
+ - Programs should not undefine the macros bool, true, and false,
+ as C99 lists that as an "obsolescent feature".
+
+ Limitations of this substitute, when used in a C89 environment:
+
+ - <stdbool.h> must be #included before the '_Bool' type can be used.
+
+ - You cannot assume that _Bool is a typedef; it might be a macro.
+
+ - Bit-fields of type 'bool' are not supported. Portable code
+ should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
+
+ - In C99, casts and automatic conversions to '_Bool' or 'bool' are
+ performed in such a way that every nonzero value gets converted
+ to 'true', and zero gets converted to 'false'. This doesn't work
+ with this substitute. With this substitute, only the values 0 and 1
+ give the expected result when converted to _Bool' or 'bool'.
+
+ - C99 allows the use of (_Bool)0.0 in constant expressions, but
+ this substitute cannot always provide this property.
+
+ Also, it is suggested that programs use 'bool' rather than '_Bool';
+ this isn't required, but 'bool' is more common. */
+
+
+/* 7.16. Boolean type and values */
+
+/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
+ definitions below, but temporarily we have to #undef them. */
+#if defined __BEOS__ && !defined __HAIKU__
+# include <OS.h> /* defines bool but not _Bool */
+# undef false
+# undef true
+#endif
+
+#ifdef __cplusplus
+# define _Bool bool
+# define bool bool
+#else
+# if defined __BEOS__ && !defined __HAIKU__
+ /* A compiler known to have 'bool'. */
+ /* If the compiler already has both 'bool' and '_Bool', we can assume they
+ are the same types. */
+# if !@HAVE__BOOL@
+typedef bool _Bool;
+# endif
+# else
+# if !defined __GNUC__
+ /* If @HAVE__BOOL@:
+ Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
+ the built-in _Bool type is used. See
+ https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html
+ https://lists.gnu.org/r/bug-coreutils/2005-10/msg00086.html
+ Similar bugs are likely with other compilers as well; this file
+ wouldn't be used if <stdbool.h> was working.
+ So we override the _Bool type.
+ If !@HAVE__BOOL@:
+ Need to define _Bool ourselves. As 'signed char' or as an enum type?
+ Use of a typedef, with SunPRO C, leads to a stupid
+ "warning: _Bool is a keyword in ISO C99".
+ Use of an enum type, with IRIX cc, leads to a stupid
+ "warning(1185): enumerated type mixed with another type".
+ Even the existence of an enum type, without a typedef,
+ "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
+ The only benefit of the enum, debuggability, is not important
+ with these compilers. So use 'signed char' and no enum. */
+# define _Bool signed char
+# else
+ /* With this compiler, trust the _Bool type if the compiler has it. */
+# if !@HAVE__BOOL@
+ /* For the sake of symbolic names in gdb, define true and false as
+ enum constants, not only as macros.
+ It is tempting to write
+ typedef enum { false = 0, true = 1 } _Bool;
+ so that gdb prints values of type 'bool' symbolically. But then
+ values of type '_Bool' might promote to 'int' or 'unsigned int'
+ (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
+ (see ISO C 99 6.3.1.1.(2)). So add a negative value to the
+ enum; this ensures that '_Bool' promotes to 'int'. */
+typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
+# endif
+# endif
+# endif
+# define bool _Bool
+#endif
+
+/* The other macros must be usable in preprocessor directives. */
+#ifdef __cplusplus
+# define false false
+# define true true
+#else
+# define false 0
+# define true 1
+#endif
+
+#define __bool_true_false_are_defined 1
+
+#endif /* _GL_STDBOOL_H */
diff --git a/grub-core/lib/gnulib/stddef.in.h b/grub-core/lib/gnulib/stddef.in.h
new file mode 100644
index 0000000..5aad121
--- /dev/null
+++ b/grub-core/lib/gnulib/stddef.in.h
@@ -0,0 +1,114 @@
+/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
+
+ Copyright (C) 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Eric Blake. */
+
+/*
+ * POSIX 2008 <stddef.h> for platforms that have issues.
+ * <http://www.opengroup.org/susv3xbd/stddef.h.html>
+ */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_wchar_t || defined __need_size_t \
+ || defined __need_ptrdiff_t || defined __need_NULL \
+ || defined __need_wint_t
+/* Special invocation convention inside gcc header files. In
+ particular, gcc provides a version of <stddef.h> that blindly
+ redefines NULL even when __need_wint_t was defined, even though
+ wint_t is not normally provided by <stddef.h>. Hence, we must
+ remember if special invocation has ever been used to obtain wint_t,
+ in which case we need to clean up NULL yet again. */
+
+# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T)
+# ifdef __need_wint_t
+# define _GL_STDDEF_WINT_T
+# endif
+# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
+# endif
+
+#else
+/* Normal invocation convention. */
+
+# ifndef _@GUARD_PREFIX@_STDDEF_H
+
+/* The include_next requires a split double-inclusion guard. */
+
+# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
+
+/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
+# if (@REPLACE_NULL@ \
+ && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T))
+# undef NULL
+# ifdef __cplusplus
+ /* ISO C++ says that the macro NULL must expand to an integer constant
+ expression, hence '((void *) 0)' is not allowed in C++. */
+# if __GNUG__ >= 3
+ /* GNU C++ has a __null macro that behaves like an integer ('int' or
+ 'long') but has the same size as a pointer. Use that, to avoid
+ warnings. */
+# define NULL __null
+# else
+# define NULL 0L
+# endif
+# else
+# define NULL ((void *) 0)
+# endif
+# endif
+
+# ifndef _@GUARD_PREFIX@_STDDEF_H
+# define _@GUARD_PREFIX@_STDDEF_H
+
+/* Some platforms lack wchar_t. */
+#if !@HAVE_WCHAR_T@
+# define wchar_t int
+#endif
+
+/* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is
+ a hack in case the configure-time test was done with g++ even though
+ we are currently compiling with gcc. */
+#if ! (@HAVE_MAX_ALIGN_T@ || defined _GCC_MAX_ALIGN_T)
+# if !GNULIB_defined_max_align_t
+/* On the x86, the maximum storage alignment of double, long, etc. is 4,
+ but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
+ and the C11 standard allows this. Work around this problem by
+ using __alignof__ (which returns 8 for double) rather than _Alignof
+ (which returns 4), and align each union member accordingly. */
+# ifdef __GNUC__
+# define _GL_STDDEF_ALIGNAS(type) \
+ __attribute__ ((__aligned__ (__alignof__ (type))))
+# else
+# define _GL_STDDEF_ALIGNAS(type) /* */
+# endif
+typedef union
+{
+ char *__p _GL_STDDEF_ALIGNAS (char *);
+ double __d _GL_STDDEF_ALIGNAS (double);
+ long double __ld _GL_STDDEF_ALIGNAS (long double);
+ long int __i _GL_STDDEF_ALIGNAS (long int);
+} rpl_max_align_t;
+# define max_align_t rpl_max_align_t
+# define GNULIB_defined_max_align_t 1
+# endif
+#endif
+
+# endif /* _@GUARD_PREFIX@_STDDEF_H */
+# endif /* _@GUARD_PREFIX@_STDDEF_H */
+#endif /* __need_XXX */
diff --git a/grub-core/lib/gnulib/stdint.in.h b/grub-core/lib/gnulib/stdint.in.h
new file mode 100644
index 0000000..21dd8d2
--- /dev/null
+++ b/grub-core/lib/gnulib/stdint.in.h
@@ -0,0 +1,726 @@
+/* Copyright (C) 2001-2002, 2004-2019 Free Software Foundation, Inc.
+ Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
+ This file is part of gnulib.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+/*
+ * ISO C 99 <stdint.h> for platforms that lack it.
+ * <http://www.opengroup.org/susv3xbd/stdint.h.html>
+ */
+
+#ifndef _@GUARD_PREFIX@_STDINT_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* When including a system file that in turn includes <inttypes.h>,
+ use the system <inttypes.h>, not our substitute. This avoids
+ problems with (for example) VMS, whose <sys/bitypes.h> includes
+ <inttypes.h>. */
+#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+
+/* On Android (Bionic libc), <sys/types.h> includes this file before
+ having defined 'time_t'. Therefore in this case avoid including
+ other system header files; just include the system's <stdint.h>.
+ Ideally we should test __BIONIC__ here, but it is only defined after
+ <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */
+#if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H
+# @INCLUDE_NEXT@ @NEXT_STDINT_H@
+#else
+
+/* Get those types that are already defined in other system include
+ files, so that we can "#define int8_t signed char" below without
+ worrying about a later system include file containing a "typedef
+ signed char int8_t;" that will get messed up by our macro. Our
+ macros should all be consistent with the system versions, except
+ for the "fast" types and macros, which we recommend against using
+ in public interfaces due to compiler differences. */
+
+#if @HAVE_STDINT_H@
+# if defined __sgi && ! defined __c99
+ /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
+ with "This header file is to be used only for c99 mode compilations"
+ diagnostics. */
+# define __STDINT_H__
+# endif
+
+ /* Some pre-C++11 <stdint.h> implementations need this. */
+# ifdef __cplusplus
+# ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+# endif
+# ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS 1
+# endif
+# endif
+
+ /* Other systems may have an incomplete or buggy <stdint.h>.
+ Include it before <inttypes.h>, since any "#include <stdint.h>"
+ in <inttypes.h> would reinclude us, skipping our contents because
+ _@GUARD_PREFIX@_STDINT_H is defined.
+ The include_next requires a split double-inclusion guard. */
+# @INCLUDE_NEXT@ @NEXT_STDINT_H@
+#endif
+
+#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
+#define _@GUARD_PREFIX@_STDINT_H
+
+/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
+ LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */
+#include <limits.h>
+
+/* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides
+ wint_t. */
+#if @GNULIB_OVERRIDES_WINT_T@
+# undef WINT_MIN
+# undef WINT_MAX
+# define WINT_MIN 0x0U
+# define WINT_MAX 0xffffffffU
+#endif
+
+#if ! @HAVE_C99_STDINT_H@
+
+/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
+ IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
+ AIX 5.2 <sys/types.h> isn't needed and causes troubles.
+ Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
+ relies on the system <stdint.h> definitions, so include
+ <sys/types.h> after @NEXT_STDINT_H@. */
+# if @HAVE_SYS_TYPES_H@ && ! defined _AIX
+# include <sys/types.h>
+# endif
+
+# if @HAVE_INTTYPES_H@
+ /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
+ int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
+ <inttypes.h> also defines intptr_t and uintptr_t. */
+# include <inttypes.h>
+# elif @HAVE_SYS_INTTYPES_H@
+ /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
+ the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
+# include <sys/inttypes.h>
+# endif
+
+# if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
+ /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
+ int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
+ included by <sys/types.h>. */
+# include <sys/bitypes.h>
+# endif
+
+# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+
+/* Minimum and maximum values for an integer type under the usual assumption.
+ Return an unspecified value if BITS == 0, adding a check to pacify
+ picky compilers. */
+
+/* These are separate macros, because if you try to merge these macros into
+ a single one, HP-UX cc rejects the resulting expression in constant
+ expressions. */
+# define _STDINT_UNSIGNED_MIN(bits, zero) \
+ (zero)
+# define _STDINT_SIGNED_MIN(bits, zero) \
+ (~ _STDINT_MAX (1, bits, zero))
+
+# define _STDINT_MAX(signed, bits, zero) \
+ (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
+
+#if !GNULIB_defined_stdint_types
+
+/* 7.18.1.1. Exact-width integer types */
+
+/* Here we assume a standard architecture where the hardware integer
+ types have 8, 16, 32, optionally 64 bits. */
+
+# undef int8_t
+# undef uint8_t
+typedef signed char gl_int8_t;
+typedef unsigned char gl_uint8_t;
+# define int8_t gl_int8_t
+# define uint8_t gl_uint8_t
+
+# undef int16_t
+# undef uint16_t
+typedef short int gl_int16_t;
+typedef unsigned short int gl_uint16_t;
+# define int16_t gl_int16_t
+# define uint16_t gl_uint16_t
+
+# undef int32_t
+# undef uint32_t
+typedef int gl_int32_t;
+typedef unsigned int gl_uint32_t;
+# define int32_t gl_int32_t
+# define uint32_t gl_uint32_t
+
+/* If the system defines INT64_MAX, assume int64_t works. That way,
+ if the underlying platform defines int64_t to be a 64-bit long long
+ int, the code below won't mistakenly define it to be a 64-bit long
+ int, which would mess up C++ name mangling. We must use #ifdef
+ rather than #if, to avoid an error with HP-UX 10.20 cc. */
+
+# ifdef INT64_MAX
+# define GL_INT64_T
+# else
+/* Do not undefine int64_t if gnulib is not being used with 64-bit
+ types, since otherwise it breaks platforms like Tandem/NSK. */
+# if LONG_MAX >> 31 >> 31 == 1
+# undef int64_t
+typedef long int gl_int64_t;
+# define int64_t gl_int64_t
+# define GL_INT64_T
+# elif defined _MSC_VER
+# undef int64_t
+typedef __int64 gl_int64_t;
+# define int64_t gl_int64_t
+# define GL_INT64_T
+# elif @HAVE_LONG_LONG_INT@
+# undef int64_t
+typedef long long int gl_int64_t;
+# define int64_t gl_int64_t
+# define GL_INT64_T
+# endif
+# endif
+
+# ifdef UINT64_MAX
+# define GL_UINT64_T
+# else
+# if ULONG_MAX >> 31 >> 31 >> 1 == 1
+# undef uint64_t
+typedef unsigned long int gl_uint64_t;
+# define uint64_t gl_uint64_t
+# define GL_UINT64_T
+# elif defined _MSC_VER
+# undef uint64_t
+typedef unsigned __int64 gl_uint64_t;
+# define uint64_t gl_uint64_t
+# define GL_UINT64_T
+# elif @HAVE_UNSIGNED_LONG_LONG_INT@
+# undef uint64_t
+typedef unsigned long long int gl_uint64_t;
+# define uint64_t gl_uint64_t
+# define GL_UINT64_T
+# endif
+# endif
+
+/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
+# define _UINT8_T
+# define _UINT32_T
+# define _UINT64_T
+
+
+/* 7.18.1.2. Minimum-width integer types */
+
+/* Here we assume a standard architecture where the hardware integer
+ types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
+ are the same as the corresponding N_t types. */
+
+# undef int_least8_t
+# undef uint_least8_t
+# undef int_least16_t
+# undef uint_least16_t
+# undef int_least32_t
+# undef uint_least32_t
+# undef int_least64_t
+# undef uint_least64_t
+# define int_least8_t int8_t
+# define uint_least8_t uint8_t
+# define int_least16_t int16_t
+# define uint_least16_t uint16_t
+# define int_least32_t int32_t
+# define uint_least32_t uint32_t
+# ifdef GL_INT64_T
+# define int_least64_t int64_t
+# endif
+# ifdef GL_UINT64_T
+# define uint_least64_t uint64_t
+# endif
+
+/* 7.18.1.3. Fastest minimum-width integer types */
+
+/* Note: Other <stdint.h> substitutes may define these types differently.
+ It is not recommended to use these types in public header files. */
+
+/* Here we assume a standard architecture where the hardware integer
+ types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
+ are taken from the same list of types. The following code normally
+ uses types consistent with glibc, as that lessens the chance of
+ incompatibility with older GNU hosts. */
+
+# undef int_fast8_t
+# undef uint_fast8_t
+# undef int_fast16_t
+# undef uint_fast16_t
+# undef int_fast32_t
+# undef uint_fast32_t
+# undef int_fast64_t
+# undef uint_fast64_t
+typedef signed char gl_int_fast8_t;
+typedef unsigned char gl_uint_fast8_t;
+
+# ifdef __sun
+/* Define types compatible with SunOS 5.10, so that code compiled under
+ earlier SunOS versions works with code compiled under SunOS 5.10. */
+typedef int gl_int_fast32_t;
+typedef unsigned int gl_uint_fast32_t;
+# else
+typedef long int gl_int_fast32_t;
+typedef unsigned long int gl_uint_fast32_t;
+# endif
+typedef gl_int_fast32_t gl_int_fast16_t;
+typedef gl_uint_fast32_t gl_uint_fast16_t;
+
+# define int_fast8_t gl_int_fast8_t
+# define uint_fast8_t gl_uint_fast8_t
+# define int_fast16_t gl_int_fast16_t
+# define uint_fast16_t gl_uint_fast16_t
+# define int_fast32_t gl_int_fast32_t
+# define uint_fast32_t gl_uint_fast32_t
+# ifdef GL_INT64_T
+# define int_fast64_t int64_t
+# endif
+# ifdef GL_UINT64_T
+# define uint_fast64_t uint64_t
+# endif
+
+/* 7.18.1.4. Integer types capable of holding object pointers */
+
+/* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own
+ definitions of intptr_t and uintptr_t (which use int and unsigned)
+ to avoid clashes with declarations of system functions like sbrk. */
+# ifndef _INTPTR_T_DECLARED
+# undef intptr_t
+# undef uintptr_t
+typedef long int gl_intptr_t;
+typedef unsigned long int gl_uintptr_t;
+# define intptr_t gl_intptr_t
+# define uintptr_t gl_uintptr_t
+# endif
+
+/* 7.18.1.5. Greatest-width integer types */
+
+/* Note: These types are compiler dependent. It may be unwise to use them in
+ public header files. */
+
+/* If the system defines INTMAX_MAX, assume that intmax_t works, and
+ similarly for UINTMAX_MAX and uintmax_t. This avoids problems with
+ assuming one type where another is used by the system. */
+
+# ifndef INTMAX_MAX
+# undef INTMAX_C
+# undef intmax_t
+# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+typedef long long int gl_intmax_t;
+# define intmax_t gl_intmax_t
+# elif defined GL_INT64_T
+# define intmax_t int64_t
+# else
+typedef long int gl_intmax_t;
+# define intmax_t gl_intmax_t
+# endif
+# endif
+
+# ifndef UINTMAX_MAX
+# undef UINTMAX_C
+# undef uintmax_t
+# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+typedef unsigned long long int gl_uintmax_t;
+# define uintmax_t gl_uintmax_t
+# elif defined GL_UINT64_T
+# define uintmax_t uint64_t
+# else
+typedef unsigned long int gl_uintmax_t;
+# define uintmax_t gl_uintmax_t
+# endif
+# endif
+
+/* Verify that intmax_t and uintmax_t have the same size. Too much code
+ breaks if this is not the case. If this check fails, the reason is likely
+ to be found in the autoconf macros. */
+typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
+ ? 1 : -1];
+
+# define GNULIB_defined_stdint_types 1
+# endif /* !GNULIB_defined_stdint_types */
+
+/* 7.18.2. Limits of specified-width integer types */
+
+/* 7.18.2.1. Limits of exact-width integer types */
+
+/* Here we assume a standard architecture where the hardware integer
+ types have 8, 16, 32, optionally 64 bits. */
+
+# undef INT8_MIN
+# undef INT8_MAX
+# undef UINT8_MAX
+# define INT8_MIN (~ INT8_MAX)
+# define INT8_MAX 127
+# define UINT8_MAX 255
+
+# undef INT16_MIN
+# undef INT16_MAX
+# undef UINT16_MAX
+# define INT16_MIN (~ INT16_MAX)
+# define INT16_MAX 32767
+# define UINT16_MAX 65535
+
+# undef INT32_MIN
+# undef INT32_MAX
+# undef UINT32_MAX
+# define INT32_MIN (~ INT32_MAX)
+# define INT32_MAX 2147483647
+# define UINT32_MAX 4294967295U
+
+# if defined GL_INT64_T && ! defined INT64_MAX
+/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
+ evaluates the latter incorrectly in preprocessor expressions. */
+# define INT64_MIN (- INTMAX_C (1) << 63)
+# define INT64_MAX INTMAX_C (9223372036854775807)
+# endif
+
+# if defined GL_UINT64_T && ! defined UINT64_MAX
+# define UINT64_MAX UINTMAX_C (18446744073709551615)
+# endif
+
+/* 7.18.2.2. Limits of minimum-width integer types */
+
+/* Here we assume a standard architecture where the hardware integer
+ types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
+ are the same as the corresponding N_t types. */
+
+# undef INT_LEAST8_MIN
+# undef INT_LEAST8_MAX
+# undef UINT_LEAST8_MAX
+# define INT_LEAST8_MIN INT8_MIN
+# define INT_LEAST8_MAX INT8_MAX
+# define UINT_LEAST8_MAX UINT8_MAX
+
+# undef INT_LEAST16_MIN
+# undef INT_LEAST16_MAX
+# undef UINT_LEAST16_MAX
+# define INT_LEAST16_MIN INT16_MIN
+# define INT_LEAST16_MAX INT16_MAX
+# define UINT_LEAST16_MAX UINT16_MAX
+
+# undef INT_LEAST32_MIN
+# undef INT_LEAST32_MAX
+# undef UINT_LEAST32_MAX
+# define INT_LEAST32_MIN INT32_MIN
+# define INT_LEAST32_MAX INT32_MAX
+# define UINT_LEAST32_MAX UINT32_MAX
+
+# undef INT_LEAST64_MIN
+# undef INT_LEAST64_MAX
+# ifdef GL_INT64_T
+# define INT_LEAST64_MIN INT64_MIN
+# define INT_LEAST64_MAX INT64_MAX
+# endif
+
+# undef UINT_LEAST64_MAX
+# ifdef GL_UINT64_T
+# define UINT_LEAST64_MAX UINT64_MAX
+# endif
+
+/* 7.18.2.3. Limits of fastest minimum-width integer types */
+
+/* Here we assume a standard architecture where the hardware integer
+ types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
+ are taken from the same list of types. */
+
+# undef INT_FAST8_MIN
+# undef INT_FAST8_MAX
+# undef UINT_FAST8_MAX
+# define INT_FAST8_MIN SCHAR_MIN
+# define INT_FAST8_MAX SCHAR_MAX
+# define UINT_FAST8_MAX UCHAR_MAX
+
+# undef INT_FAST16_MIN
+# undef INT_FAST16_MAX
+# undef UINT_FAST16_MAX
+# define INT_FAST16_MIN INT_FAST32_MIN
+# define INT_FAST16_MAX INT_FAST32_MAX
+# define UINT_FAST16_MAX UINT_FAST32_MAX
+
+# undef INT_FAST32_MIN
+# undef INT_FAST32_MAX
+# undef UINT_FAST32_MAX
+# ifdef __sun
+# define INT_FAST32_MIN INT_MIN
+# define INT_FAST32_MAX INT_MAX
+# define UINT_FAST32_MAX UINT_MAX
+# else
+# define INT_FAST32_MIN LONG_MIN
+# define INT_FAST32_MAX LONG_MAX
+# define UINT_FAST32_MAX ULONG_MAX
+# endif
+
+# undef INT_FAST64_MIN
+# undef INT_FAST64_MAX
+# ifdef GL_INT64_T
+# define INT_FAST64_MIN INT64_MIN
+# define INT_FAST64_MAX INT64_MAX
+# endif
+
+# undef UINT_FAST64_MAX
+# ifdef GL_UINT64_T
+# define UINT_FAST64_MAX UINT64_MAX
+# endif
+
+/* 7.18.2.4. Limits of integer types capable of holding object pointers */
+
+# undef INTPTR_MIN
+# undef INTPTR_MAX
+# undef UINTPTR_MAX
+# define INTPTR_MIN LONG_MIN
+# define INTPTR_MAX LONG_MAX
+# define UINTPTR_MAX ULONG_MAX
+
+/* 7.18.2.5. Limits of greatest-width integer types */
+
+# ifndef INTMAX_MAX
+# undef INTMAX_MIN
+# ifdef INT64_MAX
+# define INTMAX_MIN INT64_MIN
+# define INTMAX_MAX INT64_MAX
+# else
+# define INTMAX_MIN INT32_MIN
+# define INTMAX_MAX INT32_MAX
+# endif
+# endif
+
+# ifndef UINTMAX_MAX
+# ifdef UINT64_MAX
+# define UINTMAX_MAX UINT64_MAX
+# else
+# define UINTMAX_MAX UINT32_MAX
+# endif
+# endif
+
+/* 7.18.3. Limits of other integer types */
+
+/* ptrdiff_t limits */
+# undef PTRDIFF_MIN
+# undef PTRDIFF_MAX
+# if @APPLE_UNIVERSAL_BUILD@
+# ifdef _LP64
+# define PTRDIFF_MIN _STDINT_SIGNED_MIN (64, 0l)
+# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l)
+# else
+# define PTRDIFF_MIN _STDINT_SIGNED_MIN (32, 0)
+# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
+# endif
+# else
+# define PTRDIFF_MIN \
+ _STDINT_SIGNED_MIN (@BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
+# define PTRDIFF_MAX \
+ _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
+# endif
+
+/* sig_atomic_t limits */
+# undef SIG_ATOMIC_MIN
+# undef SIG_ATOMIC_MAX
+# if @HAVE_SIGNED_SIG_ATOMIC_T@
+# define SIG_ATOMIC_MIN \
+ _STDINT_SIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@)
+# else
+# define SIG_ATOMIC_MIN \
+ _STDINT_UNSIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@)
+# endif
+# define SIG_ATOMIC_MAX \
+ _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
+ 0@SIG_ATOMIC_T_SUFFIX@)
+
+
+/* size_t limit */
+# undef SIZE_MAX
+# if @APPLE_UNIVERSAL_BUILD@
+# ifdef _LP64
+# define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
+# else
+# define SIZE_MAX _STDINT_MAX (0, 32, 0ul)
+# endif
+# else
+# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
+# endif
+
+/* wchar_t limits */
+/* Get WCHAR_MIN, WCHAR_MAX.
+ This include is not on the top, above, because on OSF/1 4.0 we have a
+ sequence of nested includes
+ <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
+ <stdint.h> and assumes its types are already defined. */
+# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
+ /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+ included before <wchar.h>. */
+# include <stddef.h>
+# include <stdio.h>
+# include <time.h>
+# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
+# include <wchar.h>
+# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
+# endif
+# undef WCHAR_MIN
+# undef WCHAR_MAX
+# if @HAVE_SIGNED_WCHAR_T@
+# define WCHAR_MIN \
+ _STDINT_SIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
+# else
+# define WCHAR_MIN \
+ _STDINT_UNSIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
+# endif
+# define WCHAR_MAX \
+ _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
+
+/* wint_t limits */
+# undef WINT_MIN
+# undef WINT_MAX
+# if @HAVE_SIGNED_WINT_T@
+# define WINT_MIN \
+ _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
+# else
+# define WINT_MIN \
+ _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
+# endif
+# define WINT_MAX \
+ _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
+
+/* 7.18.4. Macros for integer constants */
+
+/* 7.18.4.1. Macros for minimum-width integer constants */
+/* According to ISO C 99 Technical Corrigendum 1 */
+
+/* Here we assume a standard architecture where the hardware integer
+ types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */
+
+# undef INT8_C
+# undef UINT8_C
+# define INT8_C(x) x
+# define UINT8_C(x) x
+
+# undef INT16_C
+# undef UINT16_C
+# define INT16_C(x) x
+# define UINT16_C(x) x
+
+# undef INT32_C
+# undef UINT32_C
+# define INT32_C(x) x
+# define UINT32_C(x) x ## U
+
+# undef INT64_C
+# undef UINT64_C
+# if LONG_MAX >> 31 >> 31 == 1
+# define INT64_C(x) x##L
+# elif defined _MSC_VER
+# define INT64_C(x) x##i64
+# elif @HAVE_LONG_LONG_INT@
+# define INT64_C(x) x##LL
+# endif
+# if ULONG_MAX >> 31 >> 31 >> 1 == 1
+# define UINT64_C(x) x##UL
+# elif defined _MSC_VER
+# define UINT64_C(x) x##ui64
+# elif @HAVE_UNSIGNED_LONG_LONG_INT@
+# define UINT64_C(x) x##ULL
+# endif
+
+/* 7.18.4.2. Macros for greatest-width integer constants */
+
+# ifndef INTMAX_C
+# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+# define INTMAX_C(x) x##LL
+# elif defined GL_INT64_T
+# define INTMAX_C(x) INT64_C(x)
+# else
+# define INTMAX_C(x) x##L
+# endif
+# endif
+
+# ifndef UINTMAX_C
+# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+# define UINTMAX_C(x) x##ULL
+# elif defined GL_UINT64_T
+# define UINTMAX_C(x) UINT64_C(x)
+# else
+# define UINTMAX_C(x) x##UL
+# endif
+# endif
+
+#endif /* !@HAVE_C99_STDINT_H@ */
+
+/* Macros specified by ISO/IEC TS 18661-1:2014. */
+
+#if (!defined UINTMAX_WIDTH \
+ && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
+# ifdef INT8_MAX
+# define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX)
+# endif
+# ifdef UINT8_MAX
+# define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX)
+# endif
+# ifdef INT16_MAX
+# define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX)
+# endif
+# ifdef UINT16_MAX
+# define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX)
+# endif
+# ifdef INT32_MAX
+# define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX)
+# endif
+# ifdef UINT32_MAX
+# define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX)
+# endif
+# ifdef INT64_MAX
+# define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX)
+# endif
+# ifdef UINT64_MAX
+# define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX)
+# endif
+# define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX)
+# define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX)
+# define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX)
+# define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX)
+# define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX)
+# define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX)
+# define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX)
+# define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX)
+# define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX)
+# define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX)
+# define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX)
+# define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX)
+# define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX)
+# define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX)
+# define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX)
+# define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX)
+# define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX)
+# define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX)
+# define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX)
+# define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX)
+# define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX)
+# define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX)
+# define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX)
+# ifdef WINT_MAX
+# define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX)
+# endif
+# ifdef SIG_ATOMIC_MAX
+# define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX)
+# endif
+#endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
+
+#endif /* _@GUARD_PREFIX@_STDINT_H */
+#endif /* !(defined __ANDROID__ && ...) */
+#endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */
diff --git a/grub-core/lib/gnulib/stdio.in.h b/grub-core/lib/gnulib/stdio.in.h
new file mode 100644
index 0000000..acf29c4
--- /dev/null
+++ b/grub-core/lib/gnulib/stdio.in.h
@@ -0,0 +1,1377 @@
+/* A GNU-like <stdio.h>.
+
+ Copyright (C) 2004, 2007-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
+/* Special invocation convention:
+ - Inside glibc header files.
+ - On OSF/1 5.1 we have a sequence of nested includes
+ <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
+ <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
+ In this situation, the functions are not yet declared, therefore we cannot
+ provide the C++ aliases. */
+
+#@INCLUDE_NEXT@ @NEXT_STDIO_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_STDIO_H
+
+#define _GL_ALREADY_INCLUDING_STDIO_H
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_STDIO_H@
+
+#undef _GL_ALREADY_INCLUDING_STDIO_H
+
+#ifndef _@GUARD_PREFIX@_STDIO_H
+#define _@GUARD_PREFIX@_STDIO_H
+
+/* Get va_list. Needed on many systems, including glibc 2.8. */
+#include <stdarg.h>
+
+#include <stddef.h>
+
+/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
+ and eglibc 2.11.2.
+ May also define off_t to a 64-bit type on native Windows. */
+#include <sys/types.h>
+
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The __-protected variants of the attributes 'format' and 'printf' are
+ accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+ We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
+ gnulib and libintl do '#define printf __printf__' when they override
+ the 'printf' function. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
+#endif
+
+/* _GL_ATTRIBUTE_FORMAT_PRINTF
+ indicates to GCC that the function takes a format string and arguments,
+ where the format string directives are the ones standardized by ISO C99
+ and POSIX. */
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
+#else
+# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
+#endif
+
+/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF,
+ except that it indicates to GCC that the supported format string directives
+ are the ones of the system printf(), rather than the ones standardized by
+ ISO C99 and POSIX. */
+#if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
+# define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT_PRINTF (formatstring_parameter, first_argument)
+#else
+# define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
+#endif
+
+/* _GL_ATTRIBUTE_FORMAT_SCANF
+ indicates to GCC that the function takes a format string and arguments,
+ where the format string directives are the ones standardized by ISO C99
+ and POSIX. */
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
+#else
+# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
+#endif
+
+/* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
+ except that it indicates to GCC that the supported format string directives
+ are the ones of the system scanf(), rather than the ones standardized by
+ ISO C99 and POSIX. */
+#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
+
+/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
+/* But in any case avoid namespace pollution on glibc systems. */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
+ && ! defined __GLIBC__
+# include <unistd.h>
+#endif
+
+/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include
+ it before we #define perror rpl_perror. */
+/* But in any case avoid namespace pollution on glibc systems. */
+#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
+ && (defined _WIN32 && ! defined __CYGWIN__) \
+ && ! defined __GLIBC__
+# include <stdlib.h>
+#endif
+
+/* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include
+ it before we #define remove rpl_remove. */
+/* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include
+ it before we #define rename rpl_rename. */
+/* But in any case avoid namespace pollution on glibc systems. */
+#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
+ && (defined _WIN32 && ! defined __CYGWIN__) \
+ && ! defined __GLIBC__
+# include <io.h>
+#endif
+
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+/* Macros for stringification. */
+#define _GL_STDIO_STRINGIZE(token) #token
+#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
+
+/* When also using extern inline, suppress the use of static inline in
+ standard headers of problematic Apple configurations, as Libc at
+ least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
+ <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
+ Perhaps Apple will fix this some day. */
+#if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
+ && defined __GNUC__ && defined __STDC__)
+# undef putc_unlocked
+#endif
+
+#if @GNULIB_DPRINTF@
+# if @REPLACE_DPRINTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define dprintf rpl_dprintf
+# endif
+_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...));
+# else
+# if !@HAVE_DPRINTF@
+_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (dprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef dprintf
+# if HAVE_RAW_DECL_DPRINTF
+_GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
+ "use gnulib module dprintf for portability");
+# endif
+#endif
+
+#if @GNULIB_FCLOSE@
+/* Close STREAM and its underlying file descriptor. */
+# if @REPLACE_FCLOSE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define fclose rpl_fclose
+# endif
+_GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
+# endif
+_GL_CXXALIASWARN (fclose);
+#elif defined GNULIB_POSIXCHECK
+# undef fclose
+/* Assume fclose is always declared. */
+_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
+ "use gnulib module fclose for portable POSIX compliance");
+#endif
+
+#if @GNULIB_FDOPEN@
+# if @REPLACE_FDOPEN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fdopen
+# define fdopen rpl_fdopen
+# endif
+_GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
+# else
+_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
+# endif
+_GL_CXXALIASWARN (fdopen);
+#elif defined GNULIB_POSIXCHECK
+# undef fdopen
+/* Assume fdopen is always declared. */
+_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
+ "use gnulib module fdopen for portability");
+#endif
+
+#if @GNULIB_FFLUSH@
+/* Flush all pending data on STREAM according to POSIX rules. Both
+ output and seekable input streams are supported.
+ Note! LOSS OF DATA can occur if fflush is applied on an input stream
+ that is _not_seekable_ or on an update stream that is _not_seekable_
+ and in which the most recent operation was input. Seekability can
+ be tested with lseek(fileno(fp),0,SEEK_CUR). */
+# if @REPLACE_FFLUSH@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define fflush rpl_fflush
+# endif
+_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
+_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
+# else
+_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
+# endif
+_GL_CXXALIASWARN (fflush);
+#elif defined GNULIB_POSIXCHECK
+# undef fflush
+/* Assume fflush is always declared. */
+_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
+ "use gnulib module fflush for portable POSIX compliance");
+#endif
+
+#if @GNULIB_FGETC@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fgetc
+# define fgetc rpl_fgetc
+# endif
+_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
+# endif
+_GL_CXXALIASWARN (fgetc);
+#endif
+
+#if @GNULIB_FGETS@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fgets
+# define fgets rpl_fgets
+# endif
+_GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream)
+ _GL_ARG_NONNULL ((1, 3)));
+_GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream));
+# endif
+_GL_CXXALIASWARN (fgets);
+#endif
+
+#if @GNULIB_FOPEN@
+# if @REPLACE_FOPEN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fopen
+# define fopen rpl_fopen
+# endif
+_GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode));
+# else
+_GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode));
+# endif
+_GL_CXXALIASWARN (fopen);
+#elif defined GNULIB_POSIXCHECK
+# undef fopen
+/* Assume fopen is always declared. */
+_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
+ "use gnulib module fopen for portability");
+#endif
+
+#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
+# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
+ || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define fprintf rpl_fprintf
+# endif
+# define GNULIB_overrides_fprintf 1
+# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
+_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+# else
+_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
+# else
+_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (fprintf);
+#endif
+#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
+# if !GNULIB_overrides_fprintf
+# undef fprintf
+# endif
+/* Assume fprintf is always declared. */
+_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
+ "use gnulib module fprintf-posix for portable "
+ "POSIX compliance");
+#endif
+
+#if @GNULIB_FPURGE@
+/* Discard all pending buffered I/O data on STREAM.
+ STREAM must not be wide-character oriented.
+ When discarding pending output, the file position is set back to where it
+ was before the write calls. When discarding pending input, the file
+ position is advanced to match the end of the previously read input.
+ Return 0 if successful. Upon error, return -1 and set errno. */
+# if @REPLACE_FPURGE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define fpurge rpl_fpurge
+# endif
+_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
+# else
+# if !@HAVE_DECL_FPURGE@
+_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
+# endif
+_GL_CXXALIASWARN (fpurge);
+#elif defined GNULIB_POSIXCHECK
+# undef fpurge
+# if HAVE_RAW_DECL_FPURGE
+_GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
+ "use gnulib module fpurge for portability");
+# endif
+#endif
+
+#if @GNULIB_FPUTC@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fputc
+# define fputc rpl_fputc
+# endif
+_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
+# endif
+_GL_CXXALIASWARN (fputc);
+#endif
+
+#if @GNULIB_FPUTS@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fputs
+# define fputs rpl_fputs
+# endif
+_GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
+# endif
+_GL_CXXALIASWARN (fputs);
+#endif
+
+#if @GNULIB_FREAD@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fread
+# define fread rpl_fread
+# endif
+_GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)
+ _GL_ARG_NONNULL ((4)));
+_GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
+# endif
+_GL_CXXALIASWARN (fread);
+#endif
+
+#if @GNULIB_FREOPEN@
+# if @REPLACE_FREOPEN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef freopen
+# define freopen rpl_freopen
+# endif
+_GL_FUNCDECL_RPL (freopen, FILE *,
+ (const char *filename, const char *mode, FILE *stream)
+ _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (freopen, FILE *,
+ (const char *filename, const char *mode, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (freopen, FILE *,
+ (const char *filename, const char *mode, FILE *stream));
+# endif
+_GL_CXXALIASWARN (freopen);
+#elif defined GNULIB_POSIXCHECK
+# undef freopen
+/* Assume freopen is always declared. */
+_GL_WARN_ON_USE (freopen,
+ "freopen on native Windows platforms is not POSIX compliant - "
+ "use gnulib module freopen for portability");
+#endif
+
+#if @GNULIB_FSCANF@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fscanf
+# define fscanf rpl_fscanf
+# endif
+_GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...));
+# else
+_GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (fscanf);
+#endif
+
+
+/* Set up the following warnings, based on which modules are in use.
+ GNU Coding Standards discourage the use of fseek, since it imposes
+ an arbitrary limitation on some 32-bit hosts. Remember that the
+ fseek module depends on the fseeko module, so we only have three
+ cases to consider:
+
+ 1. The developer is not using either module. Issue a warning under
+ GNULIB_POSIXCHECK for both functions, to remind them that both
+ functions have bugs on some systems. _GL_NO_LARGE_FILES has no
+ impact on this warning.
+
+ 2. The developer is using both modules. They may be unaware of the
+ arbitrary limitations of fseek, so issue a warning under
+ GNULIB_POSIXCHECK. On the other hand, they may be using both
+ modules intentionally, so the developer can define
+ _GL_NO_LARGE_FILES in the compilation units where the use of fseek
+ is safe, to silence the warning.
+
+ 3. The developer is using the fseeko module, but not fseek. Gnulib
+ guarantees that fseek will still work around platform bugs in that
+ case, but we presume that the developer is aware of the pitfalls of
+ fseek and was trying to avoid it, so issue a warning even when
+ GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be
+ defined to silence the warning in particular compilation units.
+ In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
+ fseek gets defined as a macro, it is recommended that the developer
+ uses the fseek module, even if he is not calling the fseek function.
+
+ Most gnulib clients that perform stream operations should fall into
+ category 3. */
+
+#if @GNULIB_FSEEK@
+# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
+# define _GL_FSEEK_WARN /* Category 2, above. */
+# undef fseek
+# endif
+# if @REPLACE_FSEEK@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fseek
+# define fseek rpl_fseek
+# endif
+_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
+# else
+_GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
+# endif
+_GL_CXXALIASWARN (fseek);
+#endif
+
+#if @GNULIB_FSEEKO@
+# if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
+# define _GL_FSEEK_WARN /* Category 3, above. */
+# undef fseek
+# endif
+# if @REPLACE_FSEEKO@
+/* Provide an fseeko function that is aware of a preceding fflush(), and which
+ detects pipes. */
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fseeko
+# define fseeko rpl_fseeko
+# endif
+_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
+# else
+# if ! @HAVE_DECL_FSEEKO@
+_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
+# endif
+_GL_CXXALIASWARN (fseeko);
+#elif defined GNULIB_POSIXCHECK
+# define _GL_FSEEK_WARN /* Category 1, above. */
+# undef fseek
+# undef fseeko
+# if HAVE_RAW_DECL_FSEEKO
+_GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
+ "use gnulib module fseeko for portability");
+# endif
+#endif
+
+#ifdef _GL_FSEEK_WARN
+# undef _GL_FSEEK_WARN
+/* Here, either fseek is undefined (but C89 guarantees that it is
+ declared), or it is defined as rpl_fseek (declared above). */
+_GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
+ "on 32-bit platforms - "
+ "use fseeko function for handling of large files");
+#endif
+
+
+/* ftell, ftello. See the comments on fseek/fseeko. */
+
+#if @GNULIB_FTELL@
+# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
+# define _GL_FTELL_WARN /* Category 2, above. */
+# undef ftell
+# endif
+# if @REPLACE_FTELL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ftell
+# define ftell rpl_ftell
+# endif
+_GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
+# else
+_GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
+# endif
+_GL_CXXALIASWARN (ftell);
+#endif
+
+#if @GNULIB_FTELLO@
+# if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
+# define _GL_FTELL_WARN /* Category 3, above. */
+# undef ftell
+# endif
+# if @REPLACE_FTELLO@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ftello
+# define ftello rpl_ftello
+# endif
+_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
+# else
+# if ! @HAVE_DECL_FTELLO@
+_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
+# endif
+_GL_CXXALIASWARN (ftello);
+#elif defined GNULIB_POSIXCHECK
+# define _GL_FTELL_WARN /* Category 1, above. */
+# undef ftell
+# undef ftello
+# if HAVE_RAW_DECL_FTELLO
+_GL_WARN_ON_USE (ftello, "ftello is unportable - "
+ "use gnulib module ftello for portability");
+# endif
+#endif
+
+#ifdef _GL_FTELL_WARN
+# undef _GL_FTELL_WARN
+/* Here, either ftell is undefined (but C89 guarantees that it is
+ declared), or it is defined as rpl_ftell (declared above). */
+_GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
+ "on 32-bit platforms - "
+ "use ftello function for handling of large files");
+#endif
+
+
+#if @GNULIB_FWRITE@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fwrite
+# define fwrite rpl_fwrite
+# endif
+_GL_FUNCDECL_RPL (fwrite, size_t,
+ (const void *ptr, size_t s, size_t n, FILE *stream)
+ _GL_ARG_NONNULL ((1, 4)));
+_GL_CXXALIAS_RPL (fwrite, size_t,
+ (const void *ptr, size_t s, size_t n, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fwrite, size_t,
+ (const void *ptr, size_t s, size_t n, FILE *stream));
+
+/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
+ <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
+ which sometimes causes an unwanted diagnostic for fwrite calls.
+ This affects only function declaration attributes under certain
+ versions of gcc and clang, and is not needed for C++. */
+# if (0 < __USE_FORTIFY_LEVEL \
+ && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
+ && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
+ && !defined __cplusplus)
+# undef fwrite
+# undef fwrite_unlocked
+extern size_t __REDIRECT (rpl_fwrite,
+ (const void *__restrict, size_t, size_t,
+ FILE *__restrict),
+ fwrite);
+extern size_t __REDIRECT (rpl_fwrite_unlocked,
+ (const void *__restrict, size_t, size_t,
+ FILE *__restrict),
+ fwrite_unlocked);
+# define fwrite rpl_fwrite
+# define fwrite_unlocked rpl_fwrite_unlocked
+# endif
+# endif
+_GL_CXXALIASWARN (fwrite);
+#endif
+
+#if @GNULIB_GETC@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getc
+# define getc rpl_fgetc
+# endif
+_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
+# else
+_GL_CXXALIAS_SYS (getc, int, (FILE *stream));
+# endif
+_GL_CXXALIASWARN (getc);
+#endif
+
+#if @GNULIB_GETCHAR@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getchar
+# define getchar rpl_getchar
+# endif
+_GL_FUNCDECL_RPL (getchar, int, (void));
+_GL_CXXALIAS_RPL (getchar, int, (void));
+# else
+_GL_CXXALIAS_SYS (getchar, int, (void));
+# endif
+_GL_CXXALIASWARN (getchar);
+#endif
+
+#if @GNULIB_GETDELIM@
+/* Read input, up to (and including) the next occurrence of DELIMITER, from
+ STREAM, store it in *LINEPTR (and NUL-terminate it).
+ *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
+ bytes of space. It is realloc'd as necessary.
+ Return the number of bytes read and stored at *LINEPTR (not including the
+ NUL terminator), or -1 on error or EOF. */
+# if @REPLACE_GETDELIM@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getdelim
+# define getdelim rpl_getdelim
+# endif
+_GL_FUNCDECL_RPL (getdelim, ssize_t,
+ (char **lineptr, size_t *linesize, int delimiter,
+ FILE *stream)
+ _GL_ARG_NONNULL ((1, 2, 4)));
+_GL_CXXALIAS_RPL (getdelim, ssize_t,
+ (char **lineptr, size_t *linesize, int delimiter,
+ FILE *stream));
+# else
+# if !@HAVE_DECL_GETDELIM@
+_GL_FUNCDECL_SYS (getdelim, ssize_t,
+ (char **lineptr, size_t *linesize, int delimiter,
+ FILE *stream)
+ _GL_ARG_NONNULL ((1, 2, 4)));
+# endif
+_GL_CXXALIAS_SYS (getdelim, ssize_t,
+ (char **lineptr, size_t *linesize, int delimiter,
+ FILE *stream));
+# endif
+_GL_CXXALIASWARN (getdelim);
+#elif defined GNULIB_POSIXCHECK
+# undef getdelim
+# if HAVE_RAW_DECL_GETDELIM
+_GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
+ "use gnulib module getdelim for portability");
+# endif
+#endif
+
+#if @GNULIB_GETLINE@
+/* Read a line, up to (and including) the next newline, from STREAM, store it
+ in *LINEPTR (and NUL-terminate it).
+ *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
+ bytes of space. It is realloc'd as necessary.
+ Return the number of bytes read and stored at *LINEPTR (not including the
+ NUL terminator), or -1 on error or EOF. */
+# if @REPLACE_GETLINE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getline
+# define getline rpl_getline
+# endif
+_GL_FUNCDECL_RPL (getline, ssize_t,
+ (char **lineptr, size_t *linesize, FILE *stream)
+ _GL_ARG_NONNULL ((1, 2, 3)));
+_GL_CXXALIAS_RPL (getline, ssize_t,
+ (char **lineptr, size_t *linesize, FILE *stream));
+# else
+# if !@HAVE_DECL_GETLINE@
+_GL_FUNCDECL_SYS (getline, ssize_t,
+ (char **lineptr, size_t *linesize, FILE *stream)
+ _GL_ARG_NONNULL ((1, 2, 3)));
+# endif
+_GL_CXXALIAS_SYS (getline, ssize_t,
+ (char **lineptr, size_t *linesize, FILE *stream));
+# endif
+# if @HAVE_DECL_GETLINE@
+_GL_CXXALIASWARN (getline);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getline
+# if HAVE_RAW_DECL_GETLINE
+_GL_WARN_ON_USE (getline, "getline is unportable - "
+ "use gnulib module getline for portability");
+# endif
+#endif
+
+/* It is very rare that the developer ever has full control of stdin,
+ so any use of gets warrants an unconditional warning; besides, C11
+ removed it. */
+#undef gets
+#if HAVE_RAW_DECL_GETS && !defined __cplusplus
+_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+#endif
+
+#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
+struct obstack;
+/* Grow an obstack with formatted output. Return the number of
+ bytes added to OBS. No trailing nul byte is added, and the
+ object should be closed with obstack_finish before use. Upon
+ memory allocation error, call obstack_alloc_failed_handler. Upon
+ other error, return -1. */
+# if @REPLACE_OBSTACK_PRINTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define obstack_printf rpl_obstack_printf
+# endif
+_GL_FUNCDECL_RPL (obstack_printf, int,
+ (struct obstack *obs, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (obstack_printf, int,
+ (struct obstack *obs, const char *format, ...));
+# else
+# if !@HAVE_DECL_OBSTACK_PRINTF@
+_GL_FUNCDECL_SYS (obstack_printf, int,
+ (struct obstack *obs, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (obstack_printf, int,
+ (struct obstack *obs, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (obstack_printf);
+# if @REPLACE_OBSTACK_PRINTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define obstack_vprintf rpl_obstack_vprintf
+# endif
+_GL_FUNCDECL_RPL (obstack_vprintf, int,
+ (struct obstack *obs, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (obstack_vprintf, int,
+ (struct obstack *obs, const char *format, va_list args));
+# else
+# if !@HAVE_DECL_OBSTACK_PRINTF@
+_GL_FUNCDECL_SYS (obstack_vprintf, int,
+ (struct obstack *obs, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (obstack_vprintf, int,
+ (struct obstack *obs, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (obstack_vprintf);
+#endif
+
+#if @GNULIB_PCLOSE@
+# if !@HAVE_PCLOSE@
+_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
+_GL_CXXALIASWARN (pclose);
+#elif defined GNULIB_POSIXCHECK
+# undef pclose
+# if HAVE_RAW_DECL_PCLOSE
+_GL_WARN_ON_USE (pclose, "pclose is unportable - "
+ "use gnulib module pclose for more portability");
+# endif
+#endif
+
+#if @GNULIB_PERROR@
+/* Print a message to standard error, describing the value of ERRNO,
+ (if STRING is not NULL and not empty) prefixed with STRING and ": ",
+ and terminated with a newline. */
+# if @REPLACE_PERROR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define perror rpl_perror
+# endif
+_GL_FUNCDECL_RPL (perror, void, (const char *string));
+_GL_CXXALIAS_RPL (perror, void, (const char *string));
+# else
+_GL_CXXALIAS_SYS (perror, void, (const char *string));
+# endif
+_GL_CXXALIASWARN (perror);
+#elif defined GNULIB_POSIXCHECK
+# undef perror
+/* Assume perror is always declared. */
+_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
+ "use gnulib module perror for portability");
+#endif
+
+#if @GNULIB_POPEN@
+# if @REPLACE_POPEN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef popen
+# define popen rpl_popen
+# endif
+_GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
+# else
+# if !@HAVE_POPEN@
+_GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
+# endif
+_GL_CXXALIASWARN (popen);
+#elif defined GNULIB_POSIXCHECK
+# undef popen
+# if HAVE_RAW_DECL_POPEN
+_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
+ "use gnulib module popen or pipe for more portability");
+# endif
+#endif
+
+#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
+# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
+ || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
+# if defined __GNUC__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+/* Don't break __attribute__((format(printf,M,N))). */
+# define printf __printf__
+# endif
+# if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
+_GL_FUNCDECL_RPL_1 (__printf__, int,
+ (const char *format, ...)
+ __asm__ (@ASM_SYMBOL_PREFIX@
+ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
+ _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
+ _GL_ARG_NONNULL ((1)));
+# else
+_GL_FUNCDECL_RPL_1 (__printf__, int,
+ (const char *format, ...)
+ __asm__ (@ASM_SYMBOL_PREFIX@
+ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
+ _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
+# else
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define printf rpl_printf
+# endif
+_GL_FUNCDECL_RPL (printf, int,
+ (const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
+# endif
+# define GNULIB_overrides_printf 1
+# else
+_GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
+# endif
+_GL_CXXALIASWARN (printf);
+#endif
+#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
+# if !GNULIB_overrides_printf
+# undef printf
+# endif
+/* Assume printf is always declared. */
+_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
+ "use gnulib module printf-posix for portable "
+ "POSIX compliance");
+#endif
+
+#if @GNULIB_PUTC@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef putc
+# define putc rpl_fputc
+# endif
+_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
+# endif
+_GL_CXXALIASWARN (putc);
+#endif
+
+#if @GNULIB_PUTCHAR@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef putchar
+# define putchar rpl_putchar
+# endif
+_GL_FUNCDECL_RPL (putchar, int, (int c));
+_GL_CXXALIAS_RPL (putchar, int, (int c));
+# else
+_GL_CXXALIAS_SYS (putchar, int, (int c));
+# endif
+_GL_CXXALIASWARN (putchar);
+#endif
+
+#if @GNULIB_PUTS@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef puts
+# define puts rpl_puts
+# endif
+_GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (puts, int, (const char *string));
+# else
+_GL_CXXALIAS_SYS (puts, int, (const char *string));
+# endif
+_GL_CXXALIASWARN (puts);
+#endif
+
+#if @GNULIB_REMOVE@
+# if @REPLACE_REMOVE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef remove
+# define remove rpl_remove
+# endif
+_GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (remove, int, (const char *name));
+# else
+_GL_CXXALIAS_SYS (remove, int, (const char *name));
+# endif
+_GL_CXXALIASWARN (remove);
+#elif defined GNULIB_POSIXCHECK
+# undef remove
+/* Assume remove is always declared. */
+_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
+ "use gnulib module remove for more portability");
+#endif
+
+#if @GNULIB_RENAME@
+# if @REPLACE_RENAME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef rename
+# define rename rpl_rename
+# endif
+_GL_FUNCDECL_RPL (rename, int,
+ (const char *old_filename, const char *new_filename)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (rename, int,
+ (const char *old_filename, const char *new_filename));
+# else
+_GL_CXXALIAS_SYS (rename, int,
+ (const char *old_filename, const char *new_filename));
+# endif
+_GL_CXXALIASWARN (rename);
+#elif defined GNULIB_POSIXCHECK
+# undef rename
+/* Assume rename is always declared. */
+_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
+ "use gnulib module rename for more portability");
+#endif
+
+#if @GNULIB_RENAMEAT@
+# if @REPLACE_RENAMEAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef renameat
+# define renameat rpl_renameat
+# endif
+_GL_FUNCDECL_RPL (renameat, int,
+ (int fd1, char const *file1, int fd2, char const *file2)
+ _GL_ARG_NONNULL ((2, 4)));
+_GL_CXXALIAS_RPL (renameat, int,
+ (int fd1, char const *file1, int fd2, char const *file2));
+# else
+# if !@HAVE_RENAMEAT@
+_GL_FUNCDECL_SYS (renameat, int,
+ (int fd1, char const *file1, int fd2, char const *file2)
+ _GL_ARG_NONNULL ((2, 4)));
+# endif
+_GL_CXXALIAS_SYS (renameat, int,
+ (int fd1, char const *file1, int fd2, char const *file2));
+# endif
+_GL_CXXALIASWARN (renameat);
+#elif defined GNULIB_POSIXCHECK
+# undef renameat
+# if HAVE_RAW_DECL_RENAMEAT
+_GL_WARN_ON_USE (renameat, "renameat is not portable - "
+ "use gnulib module renameat for portability");
+# endif
+#endif
+
+#if @GNULIB_SCANF@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if defined __GNUC__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef scanf
+/* Don't break __attribute__((format(scanf,M,N))). */
+# define scanf __scanf__
+# endif
+_GL_FUNCDECL_RPL_1 (__scanf__, int,
+ (const char *format, ...)
+ __asm__ (@ASM_SYMBOL_PREFIX@
+ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
+ _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...));
+# else
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef scanf
+# define scanf rpl_scanf
+# endif
+_GL_FUNCDECL_RPL (scanf, int, (const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (scanf, int, (const char *format, ...));
+# endif
+# else
+_GL_CXXALIAS_SYS (scanf, int, (const char *format, ...));
+# endif
+_GL_CXXALIASWARN (scanf);
+#endif
+
+#if @GNULIB_SNPRINTF@
+# if @REPLACE_SNPRINTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define snprintf rpl_snprintf
+# endif
+_GL_FUNCDECL_RPL (snprintf, int,
+ (char *str, size_t size, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
+ _GL_ARG_NONNULL ((3)));
+_GL_CXXALIAS_RPL (snprintf, int,
+ (char *str, size_t size, const char *format, ...));
+# else
+# if !@HAVE_DECL_SNPRINTF@
+_GL_FUNCDECL_SYS (snprintf, int,
+ (char *str, size_t size, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
+ _GL_ARG_NONNULL ((3)));
+# endif
+_GL_CXXALIAS_SYS (snprintf, int,
+ (char *str, size_t size, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (snprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef snprintf
+# if HAVE_RAW_DECL_SNPRINTF
+_GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
+ "use gnulib module snprintf for portability");
+# endif
+#endif
+
+/* Some people would argue that all sprintf uses should be warned about
+ (for example, OpenBSD issues a link warning for it),
+ since it can cause security holes due to buffer overruns.
+ However, we believe that sprintf can be used safely, and is more
+ efficient than snprintf in those safe cases; and as proof of our
+ belief, we use sprintf in several gnulib modules. So this header
+ intentionally avoids adding a warning to sprintf except when
+ GNULIB_POSIXCHECK is defined. */
+
+#if @GNULIB_SPRINTF_POSIX@
+# if @REPLACE_SPRINTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define sprintf rpl_sprintf
+# endif
+_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
+# else
+_GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (sprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef sprintf
+/* Assume sprintf is always declared. */
+_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
+ "use gnulib module sprintf-posix for portable "
+ "POSIX compliance");
+#endif
+
+#if @GNULIB_TMPFILE@
+# if @REPLACE_TMPFILE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define tmpfile rpl_tmpfile
+# endif
+_GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
+_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
+# else
+_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
+# endif
+_GL_CXXALIASWARN (tmpfile);
+#elif defined GNULIB_POSIXCHECK
+# undef tmpfile
+# if HAVE_RAW_DECL_TMPFILE
+_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
+ "use gnulib module tmpfile for portability");
+# endif
+#endif
+
+#if @GNULIB_VASPRINTF@
+/* Write formatted output to a string dynamically allocated with malloc().
+ If the memory allocation succeeds, store the address of the string in
+ *RESULT and return the number of resulting bytes, excluding the trailing
+ NUL. Upon memory allocation error, or some other error, return -1. */
+# if @REPLACE_VASPRINTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define asprintf rpl_asprintf
+# endif
+_GL_FUNCDECL_RPL (asprintf, int,
+ (char **result, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (asprintf, int,
+ (char **result, const char *format, ...));
+# else
+# if !@HAVE_VASPRINTF@
+_GL_FUNCDECL_SYS (asprintf, int,
+ (char **result, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (asprintf, int,
+ (char **result, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (asprintf);
+# if @REPLACE_VASPRINTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define vasprintf rpl_vasprintf
+# endif
+_GL_FUNCDECL_RPL (vasprintf, int,
+ (char **result, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (vasprintf, int,
+ (char **result, const char *format, va_list args));
+# else
+# if !@HAVE_VASPRINTF@
+_GL_FUNCDECL_SYS (vasprintf, int,
+ (char **result, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (vasprintf, int,
+ (char **result, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vasprintf);
+#endif
+
+#if @GNULIB_VDPRINTF@
+# if @REPLACE_VDPRINTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define vdprintf rpl_vdprintf
+# endif
+_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
+# else
+# if !@HAVE_VDPRINTF@
+_GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+ _GL_ARG_NONNULL ((2)));
+# endif
+/* Need to cast, because on Solaris, the third parameter will likely be
+ __va_list args. */
+_GL_CXXALIAS_SYS_CAST (vdprintf, int,
+ (int fd, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vdprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef vdprintf
+# if HAVE_RAW_DECL_VDPRINTF
+_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
+ "use gnulib module vdprintf for portability");
+# endif
+#endif
+
+#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
+# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
+ || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define vfprintf rpl_vfprintf
+# endif
+# define GNULIB_overrides_vfprintf 1
+# if @GNULIB_VFPRINTF_POSIX@
+_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+# else
+_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
+# else
+/* Need to cast, because on Solaris, the third parameter is
+ __va_list args
+ and GCC's fixincludes did not change this to __gnuc_va_list. */
+_GL_CXXALIAS_SYS_CAST (vfprintf, int,
+ (FILE *fp, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vfprintf);
+#endif
+#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
+# if !GNULIB_overrides_vfprintf
+# undef vfprintf
+# endif
+/* Assume vfprintf is always declared. */
+_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
+ "use gnulib module vfprintf-posix for portable "
+ "POSIX compliance");
+#endif
+
+#if @GNULIB_VFSCANF@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef vfscanf
+# define vfscanf rpl_vfscanf
+# endif
+_GL_FUNCDECL_RPL (vfscanf, int,
+ (FILE *stream, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (vfscanf, int,
+ (FILE *stream, const char *format, va_list args));
+# else
+_GL_CXXALIAS_SYS (vfscanf, int,
+ (FILE *stream, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vfscanf);
+#endif
+
+#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
+# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
+ || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define vprintf rpl_vprintf
+# endif
+# define GNULIB_overrides_vprintf 1
+# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
+_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
+ _GL_ARG_NONNULL ((1)));
+# else
+_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
+# else
+/* Need to cast, because on Solaris, the second parameter is
+ __va_list args
+ and GCC's fixincludes did not change this to __gnuc_va_list. */
+_GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vprintf);
+#endif
+#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
+# if !GNULIB_overrides_vprintf
+# undef vprintf
+# endif
+/* Assume vprintf is always declared. */
+_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
+ "use gnulib module vprintf-posix for portable "
+ "POSIX compliance");
+#endif
+
+#if @GNULIB_VSCANF@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef vscanf
+# define vscanf rpl_vscanf
+# endif
+_GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args));
+# else
+_GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vscanf);
+#endif
+
+#if @GNULIB_VSNPRINTF@
+# if @REPLACE_VSNPRINTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define vsnprintf rpl_vsnprintf
+# endif
+_GL_FUNCDECL_RPL (vsnprintf, int,
+ (char *str, size_t size, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
+ _GL_ARG_NONNULL ((3)));
+_GL_CXXALIAS_RPL (vsnprintf, int,
+ (char *str, size_t size, const char *format, va_list args));
+# else
+# if !@HAVE_DECL_VSNPRINTF@
+_GL_FUNCDECL_SYS (vsnprintf, int,
+ (char *str, size_t size, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
+ _GL_ARG_NONNULL ((3)));
+# endif
+_GL_CXXALIAS_SYS (vsnprintf, int,
+ (char *str, size_t size, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vsnprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef vsnprintf
+# if HAVE_RAW_DECL_VSNPRINTF
+_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
+ "use gnulib module vsnprintf for portability");
+# endif
+#endif
+
+#if @GNULIB_VSPRINTF_POSIX@
+# if @REPLACE_VSPRINTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define vsprintf rpl_vsprintf
+# endif
+_GL_FUNCDECL_RPL (vsprintf, int,
+ (char *str, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (vsprintf, int,
+ (char *str, const char *format, va_list args));
+# else
+/* Need to cast, because on Solaris, the third parameter is
+ __va_list args
+ and GCC's fixincludes did not change this to __gnuc_va_list. */
+_GL_CXXALIAS_SYS_CAST (vsprintf, int,
+ (char *str, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vsprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef vsprintf
+/* Assume vsprintf is always declared. */
+_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
+ "use gnulib module vsprintf-posix for portable "
+ "POSIX compliance");
+#endif
+
+#endif /* _@GUARD_PREFIX@_STDIO_H */
+#endif /* _@GUARD_PREFIX@_STDIO_H */
+#endif
diff --git a/grub-core/lib/gnulib/stdlib.in.h b/grub-core/lib/gnulib/stdlib.in.h
new file mode 100644
index 0000000..d80d7ec
--- /dev/null
+++ b/grub-core/lib/gnulib/stdlib.in.h
@@ -0,0 +1,1013 @@
+/* A GNU-like <stdlib.h>.
+
+ Copyright (C) 1995, 2001-2004, 2006-2019 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 <https://www.gnu.org/licenses/>. */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc
+/* Special invocation conventions inside some gnulib header files,
+ and inside some glibc header files, respectively. */
+
+#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_STDLIB_H
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
+
+#ifndef _@GUARD_PREFIX@_STDLIB_H
+#define _@GUARD_PREFIX@_STDLIB_H
+
+/* NetBSD 5.0 mis-defines NULL. */
+#include <stddef.h>
+
+/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
+#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
+# include <sys/wait.h>
+#endif
+
+/* Solaris declares getloadavg() in <sys/loadavg.h>. */
+#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
+/* OpenIndiana has a bug: <sys/time.h> must be included before
+ <sys/loadavg.h>. */
+# include <sys/time.h>
+# include <sys/loadavg.h>
+#endif
+
+/* Native Windows platforms declare mktemp() in <io.h>. */
+#if 0 && (defined _WIN32 && ! defined __CYGWIN__)
+# include <io.h>
+#endif
+
+#if @GNULIB_RANDOM_R@
+
+/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
+ from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
+ 'struct random_data'. */
+# if @HAVE_RANDOM_H@
+# include <random.h>
+# endif
+
+# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
+# include <stdint.h>
+# endif
+
+# if !@HAVE_STRUCT_RANDOM_DATA@
+/* Define 'struct random_data'.
+ But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
+# if !GNULIB_defined_struct_random_data
+struct random_data
+{
+ int32_t *fptr; /* Front pointer. */
+ int32_t *rptr; /* Rear pointer. */
+ int32_t *state; /* Array of state values. */
+ int rand_type; /* Type of random number generator. */
+ int rand_deg; /* Degree of random number generator. */
+ int rand_sep; /* Distance between front and rear. */
+ int32_t *end_ptr; /* Pointer behind state table. */
+};
+# define GNULIB_defined_struct_random_data 1
+# endif
+# endif
+#endif
+
+#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_MKOSTEMP@ || @GNULIB_MKOSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !(defined _WIN32 && ! defined __CYGWIN__)
+/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
+/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
+/* On Mac OS X 10.13, only <unistd.h> declares mkostemp and mkostemps. */
+/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
+/* But avoid namespace pollution on glibc systems and native Windows. */
+# include <unistd.h>
+#endif
+
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The attribute __pure__ was added in gcc 2.96. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+#else
+# define _GL_ATTRIBUTE_PURE /* empty */
+#endif
+
+/* The definition of _Noreturn is copied here. */
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+
+/* Some systems do not define EXIT_*, despite otherwise supporting C89. */
+#ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+#endif
+/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
+ with proper operation of xargs. */
+#ifndef EXIT_FAILURE
+# define EXIT_FAILURE 1
+#elif EXIT_FAILURE != 1
+# undef EXIT_FAILURE
+# define EXIT_FAILURE 1
+#endif
+
+
+#if @GNULIB__EXIT@
+/* Terminate the current process with the given return code, without running
+ the 'atexit' handlers. */
+# if !@HAVE__EXIT@
+_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
+# endif
+_GL_CXXALIAS_SYS (_Exit, void, (int status));
+_GL_CXXALIASWARN (_Exit);
+#elif defined GNULIB_POSIXCHECK
+# undef _Exit
+# if HAVE_RAW_DECL__EXIT
+_GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
+ "use gnulib module _Exit for portability");
+# endif
+#endif
+
+
+#if @GNULIB_ATOLL@
+/* Parse a signed decimal integer.
+ Returns the value of the integer. Errors are not detected. */
+# if !@HAVE_ATOLL@
+_GL_FUNCDECL_SYS (atoll, long long, (const char *string)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
+_GL_CXXALIASWARN (atoll);
+#elif defined GNULIB_POSIXCHECK
+# undef atoll
+# if HAVE_RAW_DECL_ATOLL
+_GL_WARN_ON_USE (atoll, "atoll is unportable - "
+ "use gnulib module atoll for portability");
+# endif
+#endif
+
+#if @GNULIB_CALLOC_POSIX@
+# if @REPLACE_CALLOC@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef calloc
+# define calloc rpl_calloc
+# endif
+_GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
+_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
+# else
+_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
+# endif
+_GL_CXXALIASWARN (calloc);
+#elif defined GNULIB_POSIXCHECK
+# undef calloc
+/* Assume calloc is always declared. */
+_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
+ "use gnulib module calloc-posix for portability");
+#endif
+
+#if @GNULIB_CANONICALIZE_FILE_NAME@
+# if @REPLACE_CANONICALIZE_FILE_NAME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define canonicalize_file_name rpl_canonicalize_file_name
+# endif
+_GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
+# else
+# if !@HAVE_CANONICALIZE_FILE_NAME@
+_GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
+# endif
+_GL_CXXALIASWARN (canonicalize_file_name);
+#elif defined GNULIB_POSIXCHECK
+# undef canonicalize_file_name
+# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
+_GL_WARN_ON_USE (canonicalize_file_name,
+ "canonicalize_file_name is unportable - "
+ "use gnulib module canonicalize-lgpl for portability");
+# endif
+#endif
+
+#if @GNULIB_GETLOADAVG@
+/* Store max(NELEM,3) load average numbers in LOADAVG[].
+ The three numbers are the load average of the last 1 minute, the last 5
+ minutes, and the last 15 minutes, respectively.
+ LOADAVG is an array of NELEM numbers. */
+# if !@HAVE_DECL_GETLOADAVG@
+_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
+_GL_CXXALIASWARN (getloadavg);
+#elif defined GNULIB_POSIXCHECK
+# undef getloadavg
+# if HAVE_RAW_DECL_GETLOADAVG
+_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
+ "use gnulib module getloadavg for portability");
+# endif
+#endif
+
+#if @GNULIB_GETSUBOPT@
+/* Assuming *OPTIONP is a comma separated list of elements of the form
+ "token" or "token=value", getsubopt parses the first of these elements.
+ If the first element refers to a "token" that is member of the given
+ NULL-terminated array of tokens:
+ - It replaces the comma with a NUL byte, updates *OPTIONP to point past
+ the first option and the comma, sets *VALUEP to the value of the
+ element (or NULL if it doesn't contain an "=" sign),
+ - It returns the index of the "token" in the given array of tokens.
+ Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
+ For more details see the POSIX:2001 specification.
+ http://www.opengroup.org/susv3xsh/getsubopt.html */
+# if !@HAVE_GETSUBOPT@
+_GL_FUNCDECL_SYS (getsubopt, int,
+ (char **optionp, char *const *tokens, char **valuep)
+ _GL_ARG_NONNULL ((1, 2, 3)));
+# endif
+_GL_CXXALIAS_SYS (getsubopt, int,
+ (char **optionp, char *const *tokens, char **valuep));
+_GL_CXXALIASWARN (getsubopt);
+#elif defined GNULIB_POSIXCHECK
+# undef getsubopt
+# if HAVE_RAW_DECL_GETSUBOPT
+_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
+ "use gnulib module getsubopt for portability");
+# endif
+#endif
+
+#if @GNULIB_GRANTPT@
+/* Change the ownership and access permission of the slave side of the
+ pseudo-terminal whose master side is specified by FD. */
+# if !@HAVE_GRANTPT@
+_GL_FUNCDECL_SYS (grantpt, int, (int fd));
+# endif
+_GL_CXXALIAS_SYS (grantpt, int, (int fd));
+_GL_CXXALIASWARN (grantpt);
+#elif defined GNULIB_POSIXCHECK
+# undef grantpt
+# if HAVE_RAW_DECL_GRANTPT
+_GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
+ "use gnulib module grantpt for portability");
+# endif
+#endif
+
+/* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
+ rely on GNU or POSIX semantics for malloc and realloc (for example,
+ by never specifying a zero size), so it does not need malloc or
+ realloc to be redefined. */
+#if @GNULIB_MALLOC_POSIX@
+# if @REPLACE_MALLOC@
+# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
+ || _GL_USE_STDLIB_ALLOC)
+# undef malloc
+# define malloc rpl_malloc
+# endif
+_GL_FUNCDECL_RPL (malloc, void *, (size_t size));
+_GL_CXXALIAS_RPL (malloc, void *, (size_t size));
+# else
+_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
+# endif
+_GL_CXXALIASWARN (malloc);
+#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
+# undef malloc
+/* Assume malloc is always declared. */
+_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
+ "use gnulib module malloc-posix for portability");
+#endif
+
+/* Convert a multibyte character to a wide character. */
+#if @GNULIB_MBTOWC@
+# if @REPLACE_MBTOWC@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef mbtowc
+# define mbtowc rpl_mbtowc
+# endif
+_GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
+_GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
+# else
+_GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
+# endif
+_GL_CXXALIASWARN (mbtowc);
+#endif
+
+#if @GNULIB_MKDTEMP@
+/* Create a unique temporary directory from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the directory name unique.
+ Returns TEMPLATE, or a null pointer if it cannot get a unique name.
+ The directory is created mode 700. */
+# if !@HAVE_MKDTEMP@
+_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
+_GL_CXXALIASWARN (mkdtemp);
+#elif defined GNULIB_POSIXCHECK
+# undef mkdtemp
+# if HAVE_RAW_DECL_MKDTEMP
+_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
+ "use gnulib module mkdtemp for portability");
+# endif
+#endif
+
+#if @GNULIB_MKOSTEMP@
+/* Create a unique temporary file from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the file name unique.
+ The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+ and O_TEXT, O_BINARY (defined in "binary-io.h").
+ The file is then created, with the specified flags, ensuring it didn't exist
+ before.
+ The file is created read-write (mask at least 0600 & ~umask), but it may be
+ world-readable and world-writable (mask 0666 & ~umask), depending on the
+ implementation.
+ Returns the open file descriptor if successful, otherwise -1 and errno
+ set. */
+# if !@HAVE_MKOSTEMP@
+_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
+_GL_CXXALIASWARN (mkostemp);
+#elif defined GNULIB_POSIXCHECK
+# undef mkostemp
+# if HAVE_RAW_DECL_MKOSTEMP
+_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
+ "use gnulib module mkostemp for portability");
+# endif
+#endif
+
+#if @GNULIB_MKOSTEMPS@
+/* Create a unique temporary file from TEMPLATE.
+ The last six characters of TEMPLATE before a suffix of length
+ SUFFIXLEN must be "XXXXXX";
+ they are replaced with a string that makes the file name unique.
+ The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+ and O_TEXT, O_BINARY (defined in "binary-io.h").
+ The file is then created, with the specified flags, ensuring it didn't exist
+ before.
+ The file is created read-write (mask at least 0600 & ~umask), but it may be
+ world-readable and world-writable (mask 0666 & ~umask), depending on the
+ implementation.
+ Returns the open file descriptor if successful, otherwise -1 and errno
+ set. */
+# if !@HAVE_MKOSTEMPS@
+_GL_FUNCDECL_SYS (mkostemps, int,
+ (char * /*template*/, int /*suffixlen*/, int /*flags*/)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (mkostemps, int,
+ (char * /*template*/, int /*suffixlen*/, int /*flags*/));
+_GL_CXXALIASWARN (mkostemps);
+#elif defined GNULIB_POSIXCHECK
+# undef mkostemps
+# if HAVE_RAW_DECL_MKOSTEMPS
+_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
+ "use gnulib module mkostemps for portability");
+# endif
+#endif
+
+#if @GNULIB_MKSTEMP@
+/* Create a unique temporary file from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the file name unique.
+ The file is then created, ensuring it didn't exist before.
+ The file is created read-write (mask at least 0600 & ~umask), but it may be
+ world-readable and world-writable (mask 0666 & ~umask), depending on the
+ implementation.
+ Returns the open file descriptor if successful, otherwise -1 and errno
+ set. */
+# if @REPLACE_MKSTEMP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mkstemp rpl_mkstemp
+# endif
+_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
+# else
+# if ! @HAVE_MKSTEMP@
+_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
+# endif
+_GL_CXXALIASWARN (mkstemp);
+#elif defined GNULIB_POSIXCHECK
+# undef mkstemp
+# if HAVE_RAW_DECL_MKSTEMP
+_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
+ "use gnulib module mkstemp for portability");
+# endif
+#endif
+
+#if @GNULIB_MKSTEMPS@
+/* Create a unique temporary file from TEMPLATE.
+ The last six characters of TEMPLATE prior to a suffix of length
+ SUFFIXLEN must be "XXXXXX";
+ they are replaced with a string that makes the file name unique.
+ The file is then created, ensuring it didn't exist before.
+ The file is created read-write (mask at least 0600 & ~umask), but it may be
+ world-readable and world-writable (mask 0666 & ~umask), depending on the
+ implementation.
+ Returns the open file descriptor if successful, otherwise -1 and errno
+ set. */
+# if !@HAVE_MKSTEMPS@
+_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
+_GL_CXXALIASWARN (mkstemps);
+#elif defined GNULIB_POSIXCHECK
+# undef mkstemps
+# if HAVE_RAW_DECL_MKSTEMPS
+_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
+ "use gnulib module mkstemps for portability");
+# endif
+#endif
+
+#if @GNULIB_POSIX_OPENPT@
+/* Return an FD open to the master side of a pseudo-terminal. Flags should
+ include O_RDWR, and may also include O_NOCTTY. */
+# if !@HAVE_POSIX_OPENPT@
+_GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
+# endif
+_GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
+_GL_CXXALIASWARN (posix_openpt);
+#elif defined GNULIB_POSIXCHECK
+# undef posix_openpt
+# if HAVE_RAW_DECL_POSIX_OPENPT
+_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
+ "use gnulib module posix_openpt for portability");
+# endif
+#endif
+
+#if @GNULIB_PTSNAME@
+/* Return the pathname of the pseudo-terminal slave associated with
+ the master FD is open on, or NULL on errors. */
+# if @REPLACE_PTSNAME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ptsname
+# define ptsname rpl_ptsname
+# endif
+_GL_FUNCDECL_RPL (ptsname, char *, (int fd));
+_GL_CXXALIAS_RPL (ptsname, char *, (int fd));
+# else
+# if !@HAVE_PTSNAME@
+_GL_FUNCDECL_SYS (ptsname, char *, (int fd));
+# endif
+_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
+# endif
+_GL_CXXALIASWARN (ptsname);
+#elif defined GNULIB_POSIXCHECK
+# undef ptsname
+# if HAVE_RAW_DECL_PTSNAME
+_GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
+ "use gnulib module ptsname for portability");
+# endif
+#endif
+
+#if @GNULIB_PTSNAME_R@
+/* Set the pathname of the pseudo-terminal slave associated with
+ the master FD is open on and return 0, or set errno and return
+ non-zero on errors. */
+# if @REPLACE_PTSNAME_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ptsname_r
+# define ptsname_r rpl_ptsname_r
+# endif
+_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
+_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
+# else
+# if !@HAVE_PTSNAME_R@
+_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
+# endif
+_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
+# endif
+_GL_CXXALIASWARN (ptsname_r);
+#elif defined GNULIB_POSIXCHECK
+# undef ptsname_r
+# if HAVE_RAW_DECL_PTSNAME_R
+_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
+ "use gnulib module ptsname_r for portability");
+# endif
+#endif
+
+#if @GNULIB_PUTENV@
+# if @REPLACE_PUTENV@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef putenv
+# define putenv rpl_putenv
+# endif
+_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (putenv, int, (char *string));
+# else
+_GL_CXXALIAS_SYS (putenv, int, (char *string));
+# endif
+_GL_CXXALIASWARN (putenv);
+#endif
+
+#if @GNULIB_QSORT_R@
+/* Sort an array of NMEMB elements, starting at address BASE, each element
+ occupying SIZE bytes, in ascending order according to the comparison
+ function COMPARE. */
+# if @REPLACE_QSORT_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef qsort_r
+# define qsort_r rpl_qsort_r
+# endif
+_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
+ int (*compare) (void const *, void const *,
+ void *),
+ void *arg) _GL_ARG_NONNULL ((1, 4)));
+_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
+ int (*compare) (void const *, void const *,
+ void *),
+ void *arg));
+# else
+# if !@HAVE_QSORT_R@
+_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
+ int (*compare) (void const *, void const *,
+ void *),
+ void *arg) _GL_ARG_NONNULL ((1, 4)));
+# endif
+_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
+ int (*compare) (void const *, void const *,
+ void *),
+ void *arg));
+# endif
+_GL_CXXALIASWARN (qsort_r);
+#elif defined GNULIB_POSIXCHECK
+# undef qsort_r
+# if HAVE_RAW_DECL_QSORT_R
+_GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
+ "use gnulib module qsort_r for portability");
+# endif
+#endif
+
+
+#if @GNULIB_RANDOM_R@
+# if !@HAVE_RANDOM_R@
+# ifndef RAND_MAX
+# define RAND_MAX 2147483647
+# endif
+# endif
+#endif
+
+
+#if @GNULIB_RANDOM@
+# if !@HAVE_RANDOM@
+_GL_FUNCDECL_SYS (random, long, (void));
+# endif
+_GL_CXXALIAS_SYS (random, long, (void));
+_GL_CXXALIASWARN (random);
+#elif defined GNULIB_POSIXCHECK
+# undef random
+# if HAVE_RAW_DECL_RANDOM
+_GL_WARN_ON_USE (random, "random is unportable - "
+ "use gnulib module random for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM@
+# if !@HAVE_RANDOM@
+_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
+# endif
+_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
+_GL_CXXALIASWARN (srandom);
+#elif defined GNULIB_POSIXCHECK
+# undef srandom
+# if HAVE_RAW_DECL_SRANDOM
+_GL_WARN_ON_USE (srandom, "srandom is unportable - "
+ "use gnulib module random for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM@
+# if !@HAVE_RANDOM@ || !@HAVE_DECL_INITSTATE@
+_GL_FUNCDECL_SYS (initstate, char *,
+ (unsigned int seed, char *buf, size_t buf_size)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (initstate, char *,
+ (unsigned int seed, char *buf, size_t buf_size));
+_GL_CXXALIASWARN (initstate);
+#elif defined GNULIB_POSIXCHECK
+# undef initstate
+# if HAVE_RAW_DECL_INITSTATE_R
+_GL_WARN_ON_USE (initstate, "initstate is unportable - "
+ "use gnulib module random for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM@
+# if !@HAVE_RANDOM@ || !@HAVE_DECL_SETSTATE@
+_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
+_GL_CXXALIASWARN (setstate);
+#elif defined GNULIB_POSIXCHECK
+# undef setstate
+# if HAVE_RAW_DECL_SETSTATE_R
+_GL_WARN_ON_USE (setstate, "setstate is unportable - "
+ "use gnulib module random for portability");
+# endif
+#endif
+
+
+#if @GNULIB_RANDOM_R@
+# if @REPLACE_RANDOM_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef random_r
+# define random_r rpl_random_r
+# endif
+_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
+# else
+# if !@HAVE_RANDOM_R@
+_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
+# endif
+_GL_CXXALIASWARN (random_r);
+#elif defined GNULIB_POSIXCHECK
+# undef random_r
+# if HAVE_RAW_DECL_RANDOM_R
+_GL_WARN_ON_USE (random_r, "random_r is unportable - "
+ "use gnulib module random_r for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM_R@
+# if @REPLACE_RANDOM_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef srandom_r
+# define srandom_r rpl_srandom_r
+# endif
+_GL_FUNCDECL_RPL (srandom_r, int,
+ (unsigned int seed, struct random_data *rand_state)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (srandom_r, int,
+ (unsigned int seed, struct random_data *rand_state));
+# else
+# if !@HAVE_RANDOM_R@
+_GL_FUNCDECL_SYS (srandom_r, int,
+ (unsigned int seed, struct random_data *rand_state)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (srandom_r, int,
+ (unsigned int seed, struct random_data *rand_state));
+# endif
+_GL_CXXALIASWARN (srandom_r);
+#elif defined GNULIB_POSIXCHECK
+# undef srandom_r
+# if HAVE_RAW_DECL_SRANDOM_R
+_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
+ "use gnulib module random_r for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM_R@
+# if @REPLACE_RANDOM_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef initstate_r
+# define initstate_r rpl_initstate_r
+# endif
+_GL_FUNCDECL_RPL (initstate_r, int,
+ (unsigned int seed, char *buf, size_t buf_size,
+ struct random_data *rand_state)
+ _GL_ARG_NONNULL ((2, 4)));
+_GL_CXXALIAS_RPL (initstate_r, int,
+ (unsigned int seed, char *buf, size_t buf_size,
+ struct random_data *rand_state));
+# else
+# if !@HAVE_RANDOM_R@
+_GL_FUNCDECL_SYS (initstate_r, int,
+ (unsigned int seed, char *buf, size_t buf_size,
+ struct random_data *rand_state)
+ _GL_ARG_NONNULL ((2, 4)));
+# endif
+_GL_CXXALIAS_SYS (initstate_r, int,
+ (unsigned int seed, char *buf, size_t buf_size,
+ struct random_data *rand_state));
+# endif
+_GL_CXXALIASWARN (initstate_r);
+#elif defined GNULIB_POSIXCHECK
+# undef initstate_r
+# if HAVE_RAW_DECL_INITSTATE_R
+_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
+ "use gnulib module random_r for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM_R@
+# if @REPLACE_RANDOM_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef setstate_r
+# define setstate_r rpl_setstate_r
+# endif
+_GL_FUNCDECL_RPL (setstate_r, int,
+ (char *arg_state, struct random_data *rand_state)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (setstate_r, int,
+ (char *arg_state, struct random_data *rand_state));
+# else
+# if !@HAVE_RANDOM_R@
+_GL_FUNCDECL_SYS (setstate_r, int,
+ (char *arg_state, struct random_data *rand_state)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (setstate_r, int,
+ (char *arg_state, struct random_data *rand_state));
+# endif
+_GL_CXXALIASWARN (setstate_r);
+#elif defined GNULIB_POSIXCHECK
+# undef setstate_r
+# if HAVE_RAW_DECL_SETSTATE_R
+_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
+ "use gnulib module random_r for portability");
+# endif
+#endif
+
+
+#if @GNULIB_REALLOC_POSIX@
+# if @REPLACE_REALLOC@
+# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
+ || _GL_USE_STDLIB_ALLOC)
+# undef realloc
+# define realloc rpl_realloc
+# endif
+_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
+_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
+# else
+_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
+# endif
+_GL_CXXALIASWARN (realloc);
+#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
+# undef realloc
+/* Assume realloc is always declared. */
+_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
+ "use gnulib module realloc-posix for portability");
+#endif
+
+
+#if @GNULIB_REALLOCARRAY@
+# if ! @HAVE_REALLOCARRAY@
+_GL_FUNCDECL_SYS (reallocarray, void *,
+ (void *ptr, size_t nmemb, size_t size));
+# endif
+_GL_CXXALIAS_SYS (reallocarray, void *,
+ (void *ptr, size_t nmemb, size_t size));
+_GL_CXXALIASWARN (reallocarray);
+#elif defined GNULIB_POSIXCHECK
+# undef reallocarray
+# if HAVE_RAW_DECL_REALLOCARRAY
+_GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
+ "use gnulib module reallocarray for portability");
+# endif
+#endif
+
+#if @GNULIB_REALPATH@
+# if @REPLACE_REALPATH@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define realpath rpl_realpath
+# endif
+_GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
+# else
+# if !@HAVE_REALPATH@
+_GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
+# endif
+_GL_CXXALIASWARN (realpath);
+#elif defined GNULIB_POSIXCHECK
+# undef realpath
+# if HAVE_RAW_DECL_REALPATH
+_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
+ "canonicalize or canonicalize-lgpl for portability");
+# endif
+#endif
+
+#if @GNULIB_RPMATCH@
+/* Test a user response to a question.
+ Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
+# if !@HAVE_RPMATCH@
+_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
+_GL_CXXALIASWARN (rpmatch);
+#elif defined GNULIB_POSIXCHECK
+# undef rpmatch
+# if HAVE_RAW_DECL_RPMATCH
+_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
+ "use gnulib module rpmatch for portability");
+# endif
+#endif
+
+#if @GNULIB_SECURE_GETENV@
+/* Look up NAME in the environment, returning 0 in insecure situations. */
+# if !@HAVE_SECURE_GETENV@
+_GL_FUNCDECL_SYS (secure_getenv, char *,
+ (char const *name) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
+_GL_CXXALIASWARN (secure_getenv);
+#elif defined GNULIB_POSIXCHECK
+# undef secure_getenv
+# if HAVE_RAW_DECL_SECURE_GETENV
+_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
+ "use gnulib module secure_getenv for portability");
+# endif
+#endif
+
+#if @GNULIB_SETENV@
+/* Set NAME to VALUE in the environment.
+ If REPLACE is nonzero, overwrite an existing value. */
+# if @REPLACE_SETENV@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef setenv
+# define setenv rpl_setenv
+# endif
+_GL_FUNCDECL_RPL (setenv, int,
+ (const char *name, const char *value, int replace)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (setenv, int,
+ (const char *name, const char *value, int replace));
+# else
+# if !@HAVE_DECL_SETENV@
+_GL_FUNCDECL_SYS (setenv, int,
+ (const char *name, const char *value, int replace)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (setenv, int,
+ (const char *name, const char *value, int replace));
+# endif
+# if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
+_GL_CXXALIASWARN (setenv);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef setenv
+# if HAVE_RAW_DECL_SETENV
+_GL_WARN_ON_USE (setenv, "setenv is unportable - "
+ "use gnulib module setenv for portability");
+# endif
+#endif
+
+#if @GNULIB_STRTOD@
+ /* Parse a double from STRING, updating ENDP if appropriate. */
+# if @REPLACE_STRTOD@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strtod rpl_strtod
+# endif
+_GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
+# else
+# if !@HAVE_STRTOD@
+_GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
+# endif
+_GL_CXXALIASWARN (strtod);
+#elif defined GNULIB_POSIXCHECK
+# undef strtod
+# if HAVE_RAW_DECL_STRTOD
+_GL_WARN_ON_USE (strtod, "strtod is unportable - "
+ "use gnulib module strtod for portability");
+# endif
+#endif
+
+#if @GNULIB_STRTOLL@
+/* Parse a signed integer whose textual representation starts at STRING.
+ The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
+ it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
+ "0x").
+ If ENDPTR is not NULL, the address of the first byte after the integer is
+ stored in *ENDPTR.
+ Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
+ to ERANGE. */
+# if !@HAVE_STRTOLL@
+_GL_FUNCDECL_SYS (strtoll, long long,
+ (const char *string, char **endptr, int base)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strtoll, long long,
+ (const char *string, char **endptr, int base));
+_GL_CXXALIASWARN (strtoll);
+#elif defined GNULIB_POSIXCHECK
+# undef strtoll
+# if HAVE_RAW_DECL_STRTOLL
+_GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
+ "use gnulib module strtoll for portability");
+# endif
+#endif
+
+#if @GNULIB_STRTOULL@
+/* Parse an unsigned integer whose textual representation starts at STRING.
+ The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
+ it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
+ "0x").
+ If ENDPTR is not NULL, the address of the first byte after the integer is
+ stored in *ENDPTR.
+ Upon overflow, the return value is ULLONG_MAX, and errno is set to
+ ERANGE. */
+# if !@HAVE_STRTOULL@
+_GL_FUNCDECL_SYS (strtoull, unsigned long long,
+ (const char *string, char **endptr, int base)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strtoull, unsigned long long,
+ (const char *string, char **endptr, int base));
+_GL_CXXALIASWARN (strtoull);
+#elif defined GNULIB_POSIXCHECK
+# undef strtoull
+# if HAVE_RAW_DECL_STRTOULL
+_GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
+ "use gnulib module strtoull for portability");
+# endif
+#endif
+
+#if @GNULIB_UNLOCKPT@
+/* Unlock the slave side of the pseudo-terminal whose master side is specified
+ by FD, so that it can be opened. */
+# if !@HAVE_UNLOCKPT@
+_GL_FUNCDECL_SYS (unlockpt, int, (int fd));
+# endif
+_GL_CXXALIAS_SYS (unlockpt, int, (int fd));
+_GL_CXXALIASWARN (unlockpt);
+#elif defined GNULIB_POSIXCHECK
+# undef unlockpt
+# if HAVE_RAW_DECL_UNLOCKPT
+_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
+ "use gnulib module unlockpt for portability");
+# endif
+#endif
+
+#if @GNULIB_UNSETENV@
+/* Remove the variable NAME from the environment. */
+# if @REPLACE_UNSETENV@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef unsetenv
+# define unsetenv rpl_unsetenv
+# endif
+_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
+# else
+# if !@HAVE_DECL_UNSETENV@
+_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
+# endif
+# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
+_GL_CXXALIASWARN (unsetenv);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef unsetenv
+# if HAVE_RAW_DECL_UNSETENV
+_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
+ "use gnulib module unsetenv for portability");
+# endif
+#endif
+
+/* Convert a wide character to a multibyte character. */
+#if @GNULIB_WCTOMB@
+# if @REPLACE_WCTOMB@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wctomb
+# define wctomb rpl_wctomb
+# endif
+_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
+_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
+# else
+_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
+# endif
+_GL_CXXALIASWARN (wctomb);
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_STDLIB_H */
+#endif /* _@GUARD_PREFIX@_STDLIB_H */
+#endif
diff --git a/grub-core/lib/gnulib/strcasecmp.c b/grub-core/lib/gnulib/strcasecmp.c
new file mode 100644
index 0000000..6cd0e1e
--- /dev/null
+++ b/grub-core/lib/gnulib/strcasecmp.c
@@ -0,0 +1,62 @@
+/* Case-insensitive string comparison function.
+ Copyright (C) 1998-1999, 2005-2007, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+#include <ctype.h>
+#include <limits.h>
+
+#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
+
+/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
+ greater than zero if S1 is lexicographically less than, equal to or greater
+ than S2.
+ Note: This function does not work with multibyte strings! */
+
+int
+strcasecmp (const char *s1, const char *s2)
+{
+ const unsigned char *p1 = (const unsigned char *) s1;
+ const unsigned char *p2 = (const unsigned char *) s2;
+ unsigned char c1, c2;
+
+ if (p1 == p2)
+ return 0;
+
+ do
+ {
+ c1 = TOLOWER (*p1);
+ c2 = TOLOWER (*p2);
+
+ if (c1 == '\0')
+ break;
+
+ ++p1;
+ ++p2;
+ }
+ while (c1 == c2);
+
+ if (UCHAR_MAX <= INT_MAX)
+ return c1 - c2;
+ else
+ /* On machines where 'char' and 'int' are types of the same size, the
+ difference of two 'unsigned char' values - including the sign bit -
+ doesn't fit in an 'int'. */
+ return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
+}
diff --git a/grub-core/lib/gnulib/strchrnul.c b/grub-core/lib/gnulib/strchrnul.c
new file mode 100644
index 0000000..0f5dd81
--- /dev/null
+++ b/grub-core/lib/gnulib/strchrnul.c
@@ -0,0 +1,142 @@
+/* Searching in a string.
+ Copyright (C) 2003, 2007-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+/* Find the first occurrence of C in S or the final NUL byte. */
+char *
+strchrnul (const char *s, int c_in)
+{
+ /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
+ long instead of a 64-bit uintmax_t tends to give better
+ performance. On 64-bit hardware, unsigned long is generally 64
+ bits already. Change this typedef to experiment with
+ performance. */
+ typedef unsigned long int longword;
+
+ const unsigned char *char_ptr;
+ const longword *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ unsigned char c;
+
+ c = (unsigned char) c_in;
+ if (!c)
+ return rawmemchr (s, 0);
+
+ /* Handle the first few bytes by reading one byte at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = (const unsigned char *) s;
+ (size_t) char_ptr % sizeof (longword) != 0;
+ ++char_ptr)
+ if (!*char_ptr || *char_ptr == c)
+ return (char *) char_ptr;
+
+ longword_ptr = (const longword *) char_ptr;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to any size longwords. */
+
+ /* Compute auxiliary longword values:
+ repeated_one is a value which has a 1 in every byte.
+ repeated_c has c in every byte. */
+ repeated_one = 0x01010101;
+ repeated_c = c | (c << 8);
+ repeated_c |= repeated_c << 16;
+ if (0xffffffffU < (longword) -1)
+ {
+ repeated_one |= repeated_one << 31 << 1;
+ repeated_c |= repeated_c << 31 << 1;
+ if (8 < sizeof (longword))
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
+ }
+
+ /* Instead of the traditional loop which tests each byte, we will
+ test a longword at a time. The tricky part is testing if *any of
+ the four* bytes in the longword in question are equal to NUL or
+ c. We first use an xor with repeated_c. This reduces the task
+ to testing whether *any of the four* bytes in longword1 or
+ longword2 is zero.
+
+ Let's consider longword1. We compute tmp =
+ ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+ That is, we perform the following operations:
+ 1. Subtract repeated_one.
+ 2. & ~longword1.
+ 3. & a mask consisting of 0x80 in every byte.
+ Consider what happens in each byte:
+ - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
+ and step 3 transforms it into 0x80. A carry can also be propagated
+ to more significant bytes.
+ - If a byte of longword1 is nonzero, let its lowest 1 bit be at
+ position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
+ the byte ends in a single bit of value 0 and k bits of value 1.
+ After step 2, the result is just k bits of value 1: 2^k - 1. After
+ step 3, the result is 0. And no carry is produced.
+ So, if longword1 has only non-zero bytes, tmp is zero.
+ Whereas if longword1 has a zero byte, call j the position of the least
+ significant zero byte. Then the result has a zero at positions 0, ...,
+ j-1 and a 0x80 at position j. We cannot predict the result at the more
+ significant bytes (positions j+1..3), but it does not matter since we
+ already have a non-zero bit at position 8*j+7.
+
+ The test whether any byte in longword1 or longword2 is zero is equivalent
+ to testing whether tmp1 is nonzero or tmp2 is nonzero. We can combine
+ this into a single test, whether (tmp1 | tmp2) is nonzero.
+
+ This test can read more than one byte beyond the end of a string,
+ depending on where the terminating NUL is encountered. However,
+ this is considered safe since the initialization phase ensured
+ that the read will be aligned, therefore, the read will not cross
+ page boundaries and will not cause a fault. */
+
+ while (1)
+ {
+ longword longword1 = *longword_ptr ^ repeated_c;
+ longword longword2 = *longword_ptr;
+
+ if (((((longword1 - repeated_one) & ~longword1)
+ | ((longword2 - repeated_one) & ~longword2))
+ & (repeated_one << 7)) != 0)
+ break;
+ longword_ptr++;
+ }
+
+ char_ptr = (const unsigned char *) longword_ptr;
+
+ /* At this point, we know that one of the sizeof (longword) bytes
+ starting at char_ptr is == 0 or == c. On little-endian machines,
+ we could determine the first such byte without any further memory
+ accesses, just by looking at the tmp result from the last loop
+ iteration. But this does not work on big-endian machines.
+ Choose code that works in both cases. */
+
+ char_ptr = (unsigned char *) longword_ptr;
+ while (*char_ptr && (*char_ptr != c))
+ char_ptr++;
+ return (char *) char_ptr;
+}
diff --git a/grub-core/lib/gnulib/strchrnul.valgrind b/grub-core/lib/gnulib/strchrnul.valgrind
new file mode 100644
index 0000000..b14fa13
--- /dev/null
+++ b/grub-core/lib/gnulib/strchrnul.valgrind
@@ -0,0 +1,12 @@
+# Suppress a valgrind message about use of uninitialized memory in strchrnul().
+# This use is OK because it provides only a speedup.
+{
+ strchrnul-value4
+ Memcheck:Value4
+ fun:strchrnul
+}
+{
+ strchrnul-value8
+ Memcheck:Value8
+ fun:strchrnul
+}
diff --git a/grub-core/lib/gnulib/strdup.c b/grub-core/lib/gnulib/strdup.c
new file mode 100644
index 0000000..717cf65
--- /dev/null
+++ b/grub-core/lib/gnulib/strdup.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2019 Free Software
+ Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+/* Get specification. */
+#include <string.h>
+
+#include <stdlib.h>
+
+#undef __strdup
+#ifdef _LIBC
+# undef strdup
+#endif
+
+#ifndef weak_alias
+# define __strdup strdup
+#endif
+
+/* Duplicate S, returning an identical malloc'd string. */
+char *
+__strdup (const char *s)
+{
+ size_t len = strlen (s) + 1;
+ void *new = malloc (len);
+
+ if (new == NULL)
+ return NULL;
+
+ return (char *) memcpy (new, s, len);
+}
+#ifdef libc_hidden_def
+libc_hidden_def (__strdup)
+#endif
+#ifdef weak_alias
+weak_alias (__strdup, strdup)
+#endif
diff --git a/grub-core/lib/gnulib/streq.h b/grub-core/lib/gnulib/streq.h
new file mode 100644
index 0000000..326537b
--- /dev/null
+++ b/grub-core/lib/gnulib/streq.h
@@ -0,0 +1,176 @@
+/* Optimized string comparison.
+ Copyright (C) 2001-2002, 2007, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>. */
+
+#ifndef _GL_STREQ_H
+#define _GL_STREQ_H
+
+#include <string.h>
+
+/* STREQ_OPT allows to optimize string comparison with a small literal string.
+ STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+ is semantically equivalent to
+ strcmp (s, "EUC-KR") == 0
+ just faster. */
+
+/* Help GCC to generate good code for string comparisons with
+ immediate strings. */
+#if defined (__GNUC__) && defined (__OPTIMIZE__)
+
+static inline int
+streq9 (const char *s1, const char *s2)
+{
+ return strcmp (s1 + 9, s2 + 9) == 0;
+}
+
+static inline int
+streq8 (const char *s1, const char *s2, char s28)
+{
+ if (s1[8] == s28)
+ {
+ if (s28 == 0)
+ return 1;
+ else
+ return streq9 (s1, s2);
+ }
+ else
+ return 0;
+}
+
+static inline int
+streq7 (const char *s1, const char *s2, char s27, char s28)
+{
+ if (s1[7] == s27)
+ {
+ if (s27 == 0)
+ return 1;
+ else
+ return streq8 (s1, s2, s28);
+ }
+ else
+ return 0;
+}
+
+static inline int
+streq6 (const char *s1, const char *s2, char s26, char s27, char s28)
+{
+ if (s1[6] == s26)
+ {
+ if (s26 == 0)
+ return 1;
+ else
+ return streq7 (s1, s2, s27, s28);
+ }
+ else
+ return 0;
+}
+
+static inline int
+streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28)
+{
+ if (s1[5] == s25)
+ {
+ if (s25 == 0)
+ return 1;
+ else
+ return streq6 (s1, s2, s26, s27, s28);
+ }
+ else
+ return 0;
+}
+
+static inline int
+streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28)
+{
+ if (s1[4] == s24)
+ {
+ if (s24 == 0)
+ return 1;
+ else
+ return streq5 (s1, s2, s25, s26, s27, s28);
+ }
+ else
+ return 0;
+}
+
+static inline int
+streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+ if (s1[3] == s23)
+ {
+ if (s23 == 0)
+ return 1;
+ else
+ return streq4 (s1, s2, s24, s25, s26, s27, s28);
+ }
+ else
+ return 0;
+}
+
+static inline int
+streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+ if (s1[2] == s22)
+ {
+ if (s22 == 0)
+ return 1;
+ else
+ return streq3 (s1, s2, s23, s24, s25, s26, s27, s28);
+ }
+ else
+ return 0;
+}
+
+static inline int
+streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+ if (s1[1] == s21)
+ {
+ if (s21 == 0)
+ return 1;
+ else
+ return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28);
+ }
+ else
+ return 0;
+}
+
+static inline int
+streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+ if (s1[0] == s20)
+ {
+ if (s20 == 0)
+ return 1;
+ else
+ return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28);
+ }
+ else
+ return 0;
+}
+
+#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
+ streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28)
+
+#else
+
+#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
+ (strcmp (s1, s2) == 0)
+
+#endif
+
+#endif /* _GL_STREQ_H */
diff --git a/grub-core/lib/gnulib/strerror-override.c b/grub-core/lib/gnulib/strerror-override.c
new file mode 100644
index 0000000..558a010
--- /dev/null
+++ b/grub-core/lib/gnulib/strerror-override.c
@@ -0,0 +1,302 @@
+/* strerror-override.c --- POSIX compatible system error routine
+
+ Copyright (C) 2010-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2010. */
+
+#include <config.h>
+
+#include "strerror-override.h"
+
+#include <errno.h>
+
+#if GNULIB_defined_EWINSOCK /* native Windows platforms */
+# if HAVE_WINSOCK2_H
+# include <winsock2.h>
+# endif
+#endif
+
+/* If ERRNUM maps to an errno value defined by gnulib, return a string
+ describing the error. Otherwise return NULL. */
+const char *
+strerror_override (int errnum)
+{
+ /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
+ switch (errnum)
+ {
+#if REPLACE_STRERROR_0
+ case 0:
+ return "Success";
+#endif
+
+#if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
+ case EINPROGRESS:
+ return "Operation now in progress";
+ case EALREADY:
+ return "Operation already in progress";
+ case ENOTSOCK:
+ return "Socket operation on non-socket";
+ case EDESTADDRREQ:
+ return "Destination address required";
+ case EMSGSIZE:
+ return "Message too long";
+ case EPROTOTYPE:
+ return "Protocol wrong type for socket";
+ case ENOPROTOOPT:
+ return "Protocol not available";
+ case EPROTONOSUPPORT:
+ return "Protocol not supported";
+ case EOPNOTSUPP:
+ return "Operation not supported";
+ case EAFNOSUPPORT:
+ return "Address family not supported by protocol";
+ case EADDRINUSE:
+ return "Address already in use";
+ case EADDRNOTAVAIL:
+ return "Cannot assign requested address";
+ case ENETDOWN:
+ return "Network is down";
+ case ENETUNREACH:
+ return "Network is unreachable";
+ case ECONNRESET:
+ return "Connection reset by peer";
+ case ENOBUFS:
+ return "No buffer space available";
+ case EISCONN:
+ return "Transport endpoint is already connected";
+ case ENOTCONN:
+ return "Transport endpoint is not connected";
+ case ETIMEDOUT:
+ return "Connection timed out";
+ case ECONNREFUSED:
+ return "Connection refused";
+ case ELOOP:
+ return "Too many levels of symbolic links";
+ case EHOSTUNREACH:
+ return "No route to host";
+ case EWOULDBLOCK:
+ return "Operation would block";
+#endif
+#if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
+ case ETXTBSY:
+ return "Text file busy";
+ case ENODATA:
+ return "No data available";
+ case ENOSR:
+ return "Out of streams resources";
+ case ENOSTR:
+ return "Device not a stream";
+ case ETIME:
+ return "Timer expired";
+ case EOTHER:
+ return "Other error";
+#endif
+#if GNULIB_defined_EWINSOCK /* native Windows platforms */
+ case ESOCKTNOSUPPORT:
+ return "Socket type not supported";
+ case EPFNOSUPPORT:
+ return "Protocol family not supported";
+ case ESHUTDOWN:
+ return "Cannot send after transport endpoint shutdown";
+ case ETOOMANYREFS:
+ return "Too many references: cannot splice";
+ case EHOSTDOWN:
+ return "Host is down";
+ case EPROCLIM:
+ return "Too many processes";
+ case EUSERS:
+ return "Too many users";
+ case EDQUOT:
+ return "Disk quota exceeded";
+ case ESTALE:
+ return "Stale NFS file handle";
+ case EREMOTE:
+ return "Object is remote";
+# if HAVE_WINSOCK2_H
+ /* WSA_INVALID_HANDLE maps to EBADF */
+ /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
+ /* WSA_INVALID_PARAMETER maps to EINVAL */
+ case WSA_OPERATION_ABORTED:
+ return "Overlapped operation aborted";
+ case WSA_IO_INCOMPLETE:
+ return "Overlapped I/O event object not in signaled state";
+ case WSA_IO_PENDING:
+ return "Overlapped operations will complete later";
+ /* WSAEINTR maps to EINTR */
+ /* WSAEBADF maps to EBADF */
+ /* WSAEACCES maps to EACCES */
+ /* WSAEFAULT maps to EFAULT */
+ /* WSAEINVAL maps to EINVAL */
+ /* WSAEMFILE maps to EMFILE */
+ /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
+ /* WSAEINPROGRESS maps to EINPROGRESS */
+ /* WSAEALREADY maps to EALREADY */
+ /* WSAENOTSOCK maps to ENOTSOCK */
+ /* WSAEDESTADDRREQ maps to EDESTADDRREQ */
+ /* WSAEMSGSIZE maps to EMSGSIZE */
+ /* WSAEPROTOTYPE maps to EPROTOTYPE */
+ /* WSAENOPROTOOPT maps to ENOPROTOOPT */
+ /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */
+ /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
+ /* WSAEOPNOTSUPP maps to EOPNOTSUPP */
+ /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
+ /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */
+ /* WSAEADDRINUSE maps to EADDRINUSE */
+ /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */
+ /* WSAENETDOWN maps to ENETDOWN */
+ /* WSAENETUNREACH maps to ENETUNREACH */
+ /* WSAENETRESET maps to ENETRESET */
+ /* WSAECONNABORTED maps to ECONNABORTED */
+ /* WSAECONNRESET maps to ECONNRESET */
+ /* WSAENOBUFS maps to ENOBUFS */
+ /* WSAEISCONN maps to EISCONN */
+ /* WSAENOTCONN maps to ENOTCONN */
+ /* WSAESHUTDOWN is ESHUTDOWN */
+ /* WSAETOOMANYREFS is ETOOMANYREFS */
+ /* WSAETIMEDOUT maps to ETIMEDOUT */
+ /* WSAECONNREFUSED maps to ECONNREFUSED */
+ /* WSAELOOP maps to ELOOP */
+ /* WSAENAMETOOLONG maps to ENAMETOOLONG */
+ /* WSAEHOSTDOWN is EHOSTDOWN */
+ /* WSAEHOSTUNREACH maps to EHOSTUNREACH */
+ /* WSAENOTEMPTY maps to ENOTEMPTY */
+ /* WSAEPROCLIM is EPROCLIM */
+ /* WSAEUSERS is EUSERS */
+ /* WSAEDQUOT is EDQUOT */
+ /* WSAESTALE is ESTALE */
+ /* WSAEREMOTE is EREMOTE */
+ case WSASYSNOTREADY:
+ return "Network subsystem is unavailable";
+ case WSAVERNOTSUPPORTED:
+ return "Winsock.dll version out of range";
+ case WSANOTINITIALISED:
+ return "Successful WSAStartup not yet performed";
+ case WSAEDISCON:
+ return "Graceful shutdown in progress";
+ case WSAENOMORE: case WSA_E_NO_MORE:
+ return "No more results";
+ case WSAECANCELLED: case WSA_E_CANCELLED:
+ return "Call was canceled";
+ case WSAEINVALIDPROCTABLE:
+ return "Procedure call table is invalid";
+ case WSAEINVALIDPROVIDER:
+ return "Service provider is invalid";
+ case WSAEPROVIDERFAILEDINIT:
+ return "Service provider failed to initialize";
+ case WSASYSCALLFAILURE:
+ return "System call failure";
+ case WSASERVICE_NOT_FOUND:
+ return "Service not found";
+ case WSATYPE_NOT_FOUND:
+ return "Class type not found";
+ case WSAEREFUSED:
+ return "Database query was refused";
+ case WSAHOST_NOT_FOUND:
+ return "Host not found";
+ case WSATRY_AGAIN:
+ return "Nonauthoritative host not found";
+ case WSANO_RECOVERY:
+ return "Nonrecoverable error";
+ case WSANO_DATA:
+ return "Valid name, no data record of requested type";
+ /* WSA_QOS_* omitted */
+# endif
+#endif
+
+#if GNULIB_defined_ENOMSG
+ case ENOMSG:
+ return "No message of desired type";
+#endif
+
+#if GNULIB_defined_EIDRM
+ case EIDRM:
+ return "Identifier removed";
+#endif
+
+#if GNULIB_defined_ENOLINK
+ case ENOLINK:
+ return "Link has been severed";
+#endif
+
+#if GNULIB_defined_EPROTO
+ case EPROTO:
+ return "Protocol error";
+#endif
+
+#if GNULIB_defined_EMULTIHOP
+ case EMULTIHOP:
+ return "Multihop attempted";
+#endif
+
+#if GNULIB_defined_EBADMSG
+ case EBADMSG:
+ return "Bad message";
+#endif
+
+#if GNULIB_defined_EOVERFLOW
+ case EOVERFLOW:
+ return "Value too large for defined data type";
+#endif
+
+#if GNULIB_defined_ENOTSUP
+ case ENOTSUP:
+ return "Not supported";
+#endif
+
+#if GNULIB_defined_ENETRESET
+ case ENETRESET:
+ return "Network dropped connection on reset";
+#endif
+
+#if GNULIB_defined_ECONNABORTED
+ case ECONNABORTED:
+ return "Software caused connection abort";
+#endif
+
+#if GNULIB_defined_ESTALE
+ case ESTALE:
+ return "Stale NFS file handle";
+#endif
+
+#if GNULIB_defined_EDQUOT
+ case EDQUOT:
+ return "Disk quota exceeded";
+#endif
+
+#if GNULIB_defined_ECANCELED
+ case ECANCELED:
+ return "Operation canceled";
+#endif
+
+#if GNULIB_defined_EOWNERDEAD
+ case EOWNERDEAD:
+ return "Owner died";
+#endif
+
+#if GNULIB_defined_ENOTRECOVERABLE
+ case ENOTRECOVERABLE:
+ return "State not recoverable";
+#endif
+
+#if GNULIB_defined_EILSEQ
+ case EILSEQ:
+ return "Invalid or incomplete multibyte or wide character";
+#endif
+
+ default:
+ return NULL;
+ }
+}
diff --git a/grub-core/lib/gnulib/strerror-override.h b/grub-core/lib/gnulib/strerror-override.h
new file mode 100644
index 0000000..255febc
--- /dev/null
+++ b/grub-core/lib/gnulib/strerror-override.h
@@ -0,0 +1,56 @@
+/* strerror-override.h --- POSIX compatible system error routine
+
+ Copyright (C) 2010-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_STRERROR_OVERRIDE_H
+# define _GL_STRERROR_OVERRIDE_H
+
+# include <errno.h>
+# include <stddef.h>
+
+/* Reasonable buffer size that should never trigger ERANGE; if this
+ proves too small, we intentionally abort(), to remind us to fix
+ this value. */
+# define STACKBUF_LEN 256
+
+/* If ERRNUM maps to an errno value defined by gnulib, return a string
+ describing the error. Otherwise return NULL. */
+# if REPLACE_STRERROR_0 \
+ || GNULIB_defined_ESOCK \
+ || GNULIB_defined_ESTREAMS \
+ || GNULIB_defined_EWINSOCK \
+ || GNULIB_defined_ENOMSG \
+ || GNULIB_defined_EIDRM \
+ || GNULIB_defined_ENOLINK \
+ || GNULIB_defined_EPROTO \
+ || GNULIB_defined_EMULTIHOP \
+ || GNULIB_defined_EBADMSG \
+ || GNULIB_defined_EOVERFLOW \
+ || GNULIB_defined_ENOTSUP \
+ || GNULIB_defined_ENETRESET \
+ || GNULIB_defined_ECONNABORTED \
+ || GNULIB_defined_ESTALE \
+ || GNULIB_defined_EDQUOT \
+ || GNULIB_defined_ECANCELED \
+ || GNULIB_defined_EOWNERDEAD \
+ || GNULIB_defined_ENOTRECOVERABLE \
+ || GNULIB_defined_EILSEQ
+extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST;
+# else
+# define strerror_override(ignored) NULL
+# endif
+
+#endif /* _GL_STRERROR_OVERRIDE_H */
diff --git a/grub-core/lib/gnulib/strerror.c b/grub-core/lib/gnulib/strerror.c
new file mode 100644
index 0000000..f5900fd
--- /dev/null
+++ b/grub-core/lib/gnulib/strerror.c
@@ -0,0 +1,71 @@
+/* strerror.c --- POSIX compatible system error routine
+
+ Copyright (C) 2007-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "intprops.h"
+#include "strerror-override.h"
+#include "verify.h"
+
+/* Use the system functions, not the gnulib overrides in this file. */
+#undef sprintf
+
+char *
+strerror (int n)
+#undef strerror
+{
+ static char buf[STACKBUF_LEN];
+ size_t len;
+
+ /* Cast away const, due to the historical signature of strerror;
+ callers should not be modifying the string. */
+ const char *msg = strerror_override (n);
+ if (msg)
+ return (char *) msg;
+
+ msg = strerror (n);
+
+ /* Our strerror_r implementation might use the system's strerror
+ buffer, so all other clients of strerror have to see the error
+ copied into a buffer that we manage. This is not thread-safe,
+ even if the system strerror is, but portable programs shouldn't
+ be using strerror if they care about thread-safety. */
+ if (!msg || !*msg)
+ {
+ static char const fmt[] = "Unknown error %d";
+ verify (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n));
+ sprintf (buf, fmt, n);
+ errno = EINVAL;
+ return buf;
+ }
+
+ /* Fix STACKBUF_LEN if this ever aborts. */
+ len = strlen (msg);
+ if (sizeof buf <= len)
+ abort ();
+
+ memcpy (buf, msg, len + 1);
+ return buf;
+}
diff --git a/grub-core/lib/gnulib/string.in.h b/grub-core/lib/gnulib/string.in.h
new file mode 100644
index 0000000..4a9292f
--- /dev/null
+++ b/grub-core/lib/gnulib/string.in.h
@@ -0,0 +1,1063 @@
+/* A GNU-like <string.h>.
+
+ Copyright (C) 1995-1996, 2001-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined _GL_ALREADY_INCLUDING_STRING_H
+/* Special invocation convention:
+ - On OS X/NetBSD we have a sequence of nested includes
+ <string.h> -> <strings.h> -> "string.h"
+ In this situation system _chk variants due to -D_FORTIFY_SOURCE
+ might be used after any replacements defined here. */
+
+#@INCLUDE_NEXT@ @NEXT_STRING_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_STRING_H
+
+#define _GL_ALREADY_INCLUDING_STRING_H
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_STRING_H@
+
+#undef _GL_ALREADY_INCLUDING_STRING_H
+
+#ifndef _@GUARD_PREFIX@_STRING_H
+#define _@GUARD_PREFIX@_STRING_H
+
+/* NetBSD 5.0 mis-defines NULL. */
+#include <stddef.h>
+
+/* MirBSD defines mbslen as a macro. */
+#if @GNULIB_MBSLEN@ && defined __MirBSD__
+# include <wchar.h>
+#endif
+
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The attribute __pure__ was added in gcc 2.96. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+#else
+# define _GL_ATTRIBUTE_PURE /* empty */
+#endif
+
+/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
+/* But in any case avoid namespace pollution on glibc systems. */
+#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
+ && ! defined __GLIBC__
+# include <unistd.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+
+/* Clear a block of memory. The compiler will not delete a call to
+ this function, even if the block is dead after the call. */
+#if @GNULIB_EXPLICIT_BZERO@
+# if ! @HAVE_EXPLICIT_BZERO@
+_GL_FUNCDECL_SYS (explicit_bzero, void,
+ (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
+_GL_CXXALIASWARN (explicit_bzero);
+#elif defined GNULIB_POSIXCHECK
+# undef explicit_bzero
+# if HAVE_RAW_DECL_EXPLICIT_BZERO
+_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
+ "use gnulib module explicit_bzero for portability");
+# endif
+#endif
+
+/* Find the index of the least-significant set bit. */
+#if @GNULIB_FFSL@
+# if !@HAVE_FFSL@
+_GL_FUNCDECL_SYS (ffsl, int, (long int i));
+# endif
+_GL_CXXALIAS_SYS (ffsl, int, (long int i));
+_GL_CXXALIASWARN (ffsl);
+#elif defined GNULIB_POSIXCHECK
+# undef ffsl
+# if HAVE_RAW_DECL_FFSL
+_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
+# endif
+#endif
+
+
+/* Find the index of the least-significant set bit. */
+#if @GNULIB_FFSLL@
+# if !@HAVE_FFSLL@
+_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
+# endif
+_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
+_GL_CXXALIASWARN (ffsll);
+#elif defined GNULIB_POSIXCHECK
+# undef ffsll
+# if HAVE_RAW_DECL_FFSLL
+_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
+# endif
+#endif
+
+
+/* Return the first instance of C within N bytes of S, or NULL. */
+#if @GNULIB_MEMCHR@
+# if @REPLACE_MEMCHR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define memchr rpl_memchr
+# endif
+_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
+# else
+# if ! @HAVE_MEMCHR@
+_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C" { const void * std::memchr (const void *, int, size_t); }
+ extern "C++" { void * std::memchr (void *, int, size_t); } */
+_GL_CXXALIAS_SYS_CAST2 (memchr,
+ void *, (void const *__s, int __c, size_t __n),
+ void const *, (void const *__s, int __c, size_t __n));
+# endif
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
+_GL_CXXALIASWARN1 (memchr, void const *,
+ (void const *__s, int __c, size_t __n));
+# else
+_GL_CXXALIASWARN (memchr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef memchr
+/* Assume memchr is always declared. */
+_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
+ "use gnulib module memchr for portability" );
+#endif
+
+/* Return the first occurrence of NEEDLE in HAYSTACK. */
+#if @GNULIB_MEMMEM@
+# if @REPLACE_MEMMEM@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define memmem rpl_memmem
+# endif
+_GL_FUNCDECL_RPL (memmem, void *,
+ (void const *__haystack, size_t __haystack_len,
+ void const *__needle, size_t __needle_len)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 3)));
+_GL_CXXALIAS_RPL (memmem, void *,
+ (void const *__haystack, size_t __haystack_len,
+ void const *__needle, size_t __needle_len));
+# else
+# if ! @HAVE_DECL_MEMMEM@
+_GL_FUNCDECL_SYS (memmem, void *,
+ (void const *__haystack, size_t __haystack_len,
+ void const *__needle, size_t __needle_len)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 3)));
+# endif
+_GL_CXXALIAS_SYS (memmem, void *,
+ (void const *__haystack, size_t __haystack_len,
+ void const *__needle, size_t __needle_len));
+# endif
+_GL_CXXALIASWARN (memmem);
+#elif defined GNULIB_POSIXCHECK
+# undef memmem
+# if HAVE_RAW_DECL_MEMMEM
+_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
+ "use gnulib module memmem-simple for portability, "
+ "and module memmem for speed" );
+# endif
+#endif
+
+/* Copy N bytes of SRC to DEST, return pointer to bytes after the
+ last written byte. */
+#if @GNULIB_MEMPCPY@
+# if ! @HAVE_MEMPCPY@
+_GL_FUNCDECL_SYS (mempcpy, void *,
+ (void *restrict __dest, void const *restrict __src,
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (mempcpy, void *,
+ (void *restrict __dest, void const *restrict __src,
+ size_t __n));
+_GL_CXXALIASWARN (mempcpy);
+#elif defined GNULIB_POSIXCHECK
+# undef mempcpy
+# if HAVE_RAW_DECL_MEMPCPY
+_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
+ "use gnulib module mempcpy for portability");
+# endif
+#endif
+
+/* Search backwards through a block for a byte (specified as an int). */
+#if @GNULIB_MEMRCHR@
+# if ! @HAVE_DECL_MEMRCHR@
+_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" { const void * std::memrchr (const void *, int, size_t); }
+ extern "C++" { void * std::memrchr (void *, int, size_t); } */
+_GL_CXXALIAS_SYS_CAST2 (memrchr,
+ void *, (void const *, int, size_t),
+ void const *, (void const *, int, size_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
+_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
+# else
+_GL_CXXALIASWARN (memrchr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef memrchr
+# if HAVE_RAW_DECL_MEMRCHR
+_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
+ "use gnulib module memrchr for portability");
+# endif
+#endif
+
+/* Find the first occurrence of C in S. More efficient than
+ memchr(S,C,N), at the expense of undefined behavior if C does not
+ occur within N bytes. */
+#if @GNULIB_RAWMEMCHR@
+# if ! @HAVE_RAWMEMCHR@
+_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" { const void * std::rawmemchr (const void *, int); }
+ extern "C++" { void * std::rawmemchr (void *, int); } */
+_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
+ void *, (void const *__s, int __c_in),
+ void const *, (void const *__s, int __c_in));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
+_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
+# else
+_GL_CXXALIASWARN (rawmemchr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef rawmemchr
+# if HAVE_RAW_DECL_RAWMEMCHR
+_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
+ "use gnulib module rawmemchr for portability");
+# endif
+#endif
+
+/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
+#if @GNULIB_STPCPY@
+# if ! @HAVE_STPCPY@
+_GL_FUNCDECL_SYS (stpcpy, char *,
+ (char *restrict __dst, char const *restrict __src)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (stpcpy, char *,
+ (char *restrict __dst, char const *restrict __src));
+_GL_CXXALIASWARN (stpcpy);
+#elif defined GNULIB_POSIXCHECK
+# undef stpcpy
+# if HAVE_RAW_DECL_STPCPY
+_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
+ "use gnulib module stpcpy for portability");
+# endif
+#endif
+
+/* Copy no more than N bytes of SRC to DST, returning a pointer past the
+ last non-NUL byte written into DST. */
+#if @GNULIB_STPNCPY@
+# if @REPLACE_STPNCPY@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef stpncpy
+# define stpncpy rpl_stpncpy
+# endif
+_GL_FUNCDECL_RPL (stpncpy, char *,
+ (char *restrict __dst, char const *restrict __src,
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (stpncpy, char *,
+ (char *restrict __dst, char const *restrict __src,
+ size_t __n));
+# else
+# if ! @HAVE_STPNCPY@
+_GL_FUNCDECL_SYS (stpncpy, char *,
+ (char *restrict __dst, char const *restrict __src,
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (stpncpy, char *,
+ (char *restrict __dst, char const *restrict __src,
+ size_t __n));
+# endif
+_GL_CXXALIASWARN (stpncpy);
+#elif defined GNULIB_POSIXCHECK
+# undef stpncpy
+# if HAVE_RAW_DECL_STPNCPY
+_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
+ "use gnulib module stpncpy for portability");
+# endif
+#endif
+
+#if defined GNULIB_POSIXCHECK
+/* strchr() does not work with multibyte strings if the locale encoding is
+ GB18030 and the character to be searched is a digit. */
+# undef strchr
+/* Assume strchr is always declared. */
+_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
+ "in some multibyte locales - "
+ "use mbschr if you care about internationalization");
+#endif
+
+/* Find the first occurrence of C in S or the final NUL byte. */
+#if @GNULIB_STRCHRNUL@
+# if @REPLACE_STRCHRNUL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strchrnul rpl_strchrnul
+# endif
+_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strchrnul, char *,
+ (const char *str, int ch));
+# else
+# if ! @HAVE_STRCHRNUL@
+_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" { const char * std::strchrnul (const char *, int); }
+ extern "C++" { char * std::strchrnul (char *, int); } */
+_GL_CXXALIAS_SYS_CAST2 (strchrnul,
+ char *, (char const *__s, int __c_in),
+ char const *, (char const *__s, int __c_in));
+# endif
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
+_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
+# else
+_GL_CXXALIASWARN (strchrnul);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strchrnul
+# if HAVE_RAW_DECL_STRCHRNUL
+_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
+ "use gnulib module strchrnul for portability");
+# endif
+#endif
+
+/* Duplicate S, returning an identical malloc'd string. */
+#if @GNULIB_STRDUP@
+# if @REPLACE_STRDUP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strdup
+# define strdup rpl_strdup
+# endif
+_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
+# else
+# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
+ /* strdup exists as a function and as a macro. Get rid of the macro. */
+# undef strdup
+# endif
+# if !(@HAVE_DECL_STRDUP@ || defined strdup)
+_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
+# endif
+_GL_CXXALIASWARN (strdup);
+#elif defined GNULIB_POSIXCHECK
+# undef strdup
+# if HAVE_RAW_DECL_STRDUP
+_GL_WARN_ON_USE (strdup, "strdup is unportable - "
+ "use gnulib module strdup for portability");
+# endif
+#endif
+
+/* Append no more than N characters from SRC onto DEST. */
+#if @GNULIB_STRNCAT@
+# if @REPLACE_STRNCAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strncat
+# define strncat rpl_strncat
+# endif
+_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
+# else
+_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
+# endif
+_GL_CXXALIASWARN (strncat);
+#elif defined GNULIB_POSIXCHECK
+# undef strncat
+# if HAVE_RAW_DECL_STRNCAT
+_GL_WARN_ON_USE (strncat, "strncat is unportable - "
+ "use gnulib module strncat for portability");
+# endif
+#endif
+
+/* Return a newly allocated copy of at most N bytes of STRING. */
+#if @GNULIB_STRNDUP@
+# if @REPLACE_STRNDUP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strndup
+# define strndup rpl_strndup
+# endif
+_GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
+# else
+# if ! @HAVE_DECL_STRNDUP@
+_GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
+# endif
+_GL_CXXALIASWARN (strndup);
+#elif defined GNULIB_POSIXCHECK
+# undef strndup
+# if HAVE_RAW_DECL_STRNDUP
+_GL_WARN_ON_USE (strndup, "strndup is unportable - "
+ "use gnulib module strndup for portability");
+# endif
+#endif
+
+/* Find the length (number of bytes) of STRING, but scan at most
+ MAXLEN bytes. If no '\0' terminator is found in that many bytes,
+ return MAXLEN. */
+#if @GNULIB_STRNLEN@
+# if @REPLACE_STRNLEN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strnlen
+# define strnlen rpl_strnlen
+# endif
+_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
+# else
+# if ! @HAVE_DECL_STRNLEN@
+_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
+# endif
+_GL_CXXALIASWARN (strnlen);
+#elif defined GNULIB_POSIXCHECK
+# undef strnlen
+# if HAVE_RAW_DECL_STRNLEN
+_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
+ "use gnulib module strnlen for portability");
+# endif
+#endif
+
+#if defined GNULIB_POSIXCHECK
+/* strcspn() assumes the second argument is a list of single-byte characters.
+ Even in this simple case, it does not work with multibyte strings if the
+ locale encoding is GB18030 and one of the characters to be searched is a
+ digit. */
+# undef strcspn
+/* Assume strcspn is always declared. */
+_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
+ "in multibyte locales - "
+ "use mbscspn if you care about internationalization");
+#endif
+
+/* Find the first occurrence in S of any character in ACCEPT. */
+#if @GNULIB_STRPBRK@
+# if ! @HAVE_STRPBRK@
+_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C" { const char * strpbrk (const char *, const char *); }
+ extern "C++" { char * strpbrk (char *, const char *); } */
+_GL_CXXALIAS_SYS_CAST2 (strpbrk,
+ char *, (char const *__s, char const *__accept),
+ const char *, (char const *__s, char const *__accept));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
+_GL_CXXALIASWARN1 (strpbrk, char const *,
+ (char const *__s, char const *__accept));
+# else
+_GL_CXXALIASWARN (strpbrk);
+# endif
+# if defined GNULIB_POSIXCHECK
+/* strpbrk() assumes the second argument is a list of single-byte characters.
+ Even in this simple case, it does not work with multibyte strings if the
+ locale encoding is GB18030 and one of the characters to be searched is a
+ digit. */
+# undef strpbrk
+_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
+ "in multibyte locales - "
+ "use mbspbrk if you care about internationalization");
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strpbrk
+# if HAVE_RAW_DECL_STRPBRK
+_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
+ "use gnulib module strpbrk for portability");
+# endif
+#endif
+
+#if defined GNULIB_POSIXCHECK
+/* strspn() assumes the second argument is a list of single-byte characters.
+ Even in this simple case, it cannot work with multibyte strings. */
+# undef strspn
+/* Assume strspn is always declared. */
+_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
+ "in multibyte locales - "
+ "use mbsspn if you care about internationalization");
+#endif
+
+#if defined GNULIB_POSIXCHECK
+/* strrchr() does not work with multibyte strings if the locale encoding is
+ GB18030 and the character to be searched is a digit. */
+# undef strrchr
+/* Assume strrchr is always declared. */
+_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
+ "in some multibyte locales - "
+ "use mbsrchr if you care about internationalization");
+#endif
+
+/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
+ If one is found, overwrite it with a NUL, and advance *STRINGP
+ to point to the next char after it. Otherwise, set *STRINGP to NULL.
+ If *STRINGP was already NULL, nothing happens.
+ Return the old value of *STRINGP.
+
+ This is a variant of strtok() that is multithread-safe and supports
+ empty fields.
+
+ Caveat: It modifies the original string.
+ Caveat: These functions cannot be used on constant strings.
+ Caveat: The identity of the delimiting character is lost.
+ Caveat: It doesn't work with multibyte strings unless all of the delimiter
+ characters are ASCII characters < 0x30.
+
+ See also strtok_r(). */
+#if @GNULIB_STRSEP@
+# if ! @HAVE_STRSEP@
+_GL_FUNCDECL_SYS (strsep, char *,
+ (char **restrict __stringp, char const *restrict __delim)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (strsep, char *,
+ (char **restrict __stringp, char const *restrict __delim));
+_GL_CXXALIASWARN (strsep);
+# if defined GNULIB_POSIXCHECK
+# undef strsep
+_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
+ "in multibyte locales - "
+ "use mbssep if you care about internationalization");
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strsep
+# if HAVE_RAW_DECL_STRSEP
+_GL_WARN_ON_USE (strsep, "strsep is unportable - "
+ "use gnulib module strsep for portability");
+# endif
+#endif
+
+#if @GNULIB_STRSTR@
+# if @REPLACE_STRSTR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strstr rpl_strstr
+# endif
+_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
+# else
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" { const char * strstr (const char *, const char *); }
+ extern "C++" { char * strstr (char *, const char *); } */
+_GL_CXXALIAS_SYS_CAST2 (strstr,
+ char *, (const char *haystack, const char *needle),
+ const char *, (const char *haystack, const char *needle));
+# endif
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
+_GL_CXXALIASWARN1 (strstr, const char *,
+ (const char *haystack, const char *needle));
+# else
+_GL_CXXALIASWARN (strstr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+/* strstr() does not work with multibyte strings if the locale encoding is
+ different from UTF-8:
+ POSIX says that it operates on "strings", and "string" in POSIX is defined
+ as a sequence of bytes, not of characters. */
+# undef strstr
+/* Assume strstr is always declared. */
+_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
+ "work correctly on character strings in most "
+ "multibyte locales - "
+ "use mbsstr if you care about internationalization, "
+ "or use strstr if you care about speed");
+#endif
+
+/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
+ comparison. */
+#if @GNULIB_STRCASESTR@
+# if @REPLACE_STRCASESTR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strcasestr rpl_strcasestr
+# endif
+_GL_FUNCDECL_RPL (strcasestr, char *,
+ (const char *haystack, const char *needle)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (strcasestr, char *,
+ (const char *haystack, const char *needle));
+# else
+# if ! @HAVE_STRCASESTR@
+_GL_FUNCDECL_SYS (strcasestr, char *,
+ (const char *haystack, const char *needle)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" { const char * strcasestr (const char *, const char *); }
+ extern "C++" { char * strcasestr (char *, const char *); } */
+_GL_CXXALIAS_SYS_CAST2 (strcasestr,
+ char *, (const char *haystack, const char *needle),
+ const char *, (const char *haystack, const char *needle));
+# endif
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
+_GL_CXXALIASWARN1 (strcasestr, const char *,
+ (const char *haystack, const char *needle));
+# else
+_GL_CXXALIASWARN (strcasestr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+/* strcasestr() does not work with multibyte strings:
+ It is a glibc extension, and glibc implements it only for unibyte
+ locales. */
+# undef strcasestr
+# if HAVE_RAW_DECL_STRCASESTR
+_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
+ "strings in multibyte locales - "
+ "use mbscasestr if you care about "
+ "internationalization, or use c-strcasestr if you want "
+ "a locale independent function");
+# endif
+#endif
+
+/* Parse S into tokens separated by characters in DELIM.
+ If S is NULL, the saved pointer in SAVE_PTR is used as
+ the next starting point. For example:
+ char s[] = "-abc-=-def";
+ char *sp;
+ x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
+ x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
+ x = strtok_r(NULL, "=", &sp); // x = NULL
+ // s = "abc\0-def\0"
+
+ This is a variant of strtok() that is multithread-safe.
+
+ For the POSIX documentation for this function, see:
+ http://www.opengroup.org/susv3xsh/strtok.html
+
+ Caveat: It modifies the original string.
+ Caveat: These functions cannot be used on constant strings.
+ Caveat: The identity of the delimiting character is lost.
+ Caveat: It doesn't work with multibyte strings unless all of the delimiter
+ characters are ASCII characters < 0x30.
+
+ See also strsep(). */
+#if @GNULIB_STRTOK_R@
+# if @REPLACE_STRTOK_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strtok_r
+# define strtok_r rpl_strtok_r
+# endif
+_GL_FUNCDECL_RPL (strtok_r, char *,
+ (char *restrict s, char const *restrict delim,
+ char **restrict save_ptr)
+ _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (strtok_r, char *,
+ (char *restrict s, char const *restrict delim,
+ char **restrict save_ptr));
+# else
+# if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
+# undef strtok_r
+# endif
+# if ! @HAVE_DECL_STRTOK_R@
+_GL_FUNCDECL_SYS (strtok_r, char *,
+ (char *restrict s, char const *restrict delim,
+ char **restrict save_ptr)
+ _GL_ARG_NONNULL ((2, 3)));
+# endif
+_GL_CXXALIAS_SYS (strtok_r, char *,
+ (char *restrict s, char const *restrict delim,
+ char **restrict save_ptr));
+# endif
+_GL_CXXALIASWARN (strtok_r);
+# if defined GNULIB_POSIXCHECK
+_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
+ "strings in multibyte locales - "
+ "use mbstok_r if you care about internationalization");
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strtok_r
+# if HAVE_RAW_DECL_STRTOK_R
+_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
+ "use gnulib module strtok_r for portability");
+# endif
+#endif
+
+
+/* The following functions are not specified by POSIX. They are gnulib
+ extensions. */
+
+#if @GNULIB_MBSLEN@
+/* Return the number of multibyte characters in the character string STRING.
+ This considers multibyte characters, unlike strlen, which counts bytes. */
+# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
+# undef mbslen
+# endif
+# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mbslen rpl_mbslen
+# endif
+_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
+# else
+_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
+# endif
+_GL_CXXALIASWARN (mbslen);
+#endif
+
+#if @GNULIB_MBSNLEN@
+/* Return the number of multibyte characters in the character string starting
+ at STRING and ending at STRING + LEN. */
+_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1));
+#endif
+
+#if @GNULIB_MBSCHR@
+/* Locate the first single-byte character C in the character string STRING,
+ and return a pointer to it. Return NULL if C is not found in STRING.
+ Unlike strchr(), this function works correctly in multibyte locales with
+ encodings such as GB18030. */
+# if defined __hpux
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
+# endif
+_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
+# else
+_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
+# endif
+_GL_CXXALIASWARN (mbschr);
+#endif
+
+#if @GNULIB_MBSRCHR@
+/* Locate the last single-byte character C in the character string STRING,
+ and return a pointer to it. Return NULL if C is not found in STRING.
+ Unlike strrchr(), this function works correctly in multibyte locales with
+ encodings such as GB18030. */
+# if defined __hpux || defined __INTERIX
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mbsrchr rpl_mbsrchr /* avoid collision with system function */
+# endif
+_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
+# else
+_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
+# endif
+_GL_CXXALIASWARN (mbsrchr);
+#endif
+
+#if @GNULIB_MBSSTR@
+/* Find the first occurrence of the character string NEEDLE in the character
+ string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
+ Unlike strstr(), this function works correctly in multibyte locales with
+ encodings different from UTF-8. */
+_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSCASECMP@
+/* Compare the character strings S1 and S2, ignoring case, returning less than,
+ equal to or greater than zero if S1 is lexicographically less than, equal to
+ or greater than S2.
+ Note: This function may, in multibyte locales, return 0 for strings of
+ different lengths!
+ Unlike strcasecmp(), this function works correctly in multibyte locales. */
+_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSNCASECMP@
+/* Compare the initial segment of the character string S1 consisting of at most
+ N characters with the initial segment of the character string S2 consisting
+ of at most N characters, ignoring case, returning less than, equal to or
+ greater than zero if the initial segment of S1 is lexicographically less
+ than, equal to or greater than the initial segment of S2.
+ Note: This function may, in multibyte locales, return 0 for initial segments
+ of different lengths!
+ Unlike strncasecmp(), this function works correctly in multibyte locales.
+ But beware that N is not a byte count but a character count! */
+_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSPCASECMP@
+/* Compare the initial segment of the character string STRING consisting of
+ at most mbslen (PREFIX) characters with the character string PREFIX,
+ ignoring case. If the two match, return a pointer to the first byte
+ after this prefix in STRING. Otherwise, return NULL.
+ Note: This function may, in multibyte locales, return non-NULL if STRING
+ is of smaller length than PREFIX!
+ Unlike strncasecmp(), this function works correctly in multibyte
+ locales. */
+_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSCASESTR@
+/* Find the first occurrence of the character string NEEDLE in the character
+ string HAYSTACK, using case-insensitive comparison.
+ Note: This function may, in multibyte locales, return success even if
+ strlen (haystack) < strlen (needle) !
+ Unlike strcasestr(), this function works correctly in multibyte locales. */
+_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSCSPN@
+/* Find the first occurrence in the character string STRING of any character
+ in the character string ACCEPT. Return the number of bytes from the
+ beginning of the string to this occurrence, or to the end of the string
+ if none exists.
+ Unlike strcspn(), this function works correctly in multibyte locales. */
+_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSPBRK@
+/* Find the first occurrence in the character string STRING of any character
+ in the character string ACCEPT. Return the pointer to it, or NULL if none
+ exists.
+ Unlike strpbrk(), this function works correctly in multibyte locales. */
+# if defined __hpux
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
+# endif
+_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
+# else
+_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
+# endif
+_GL_CXXALIASWARN (mbspbrk);
+#endif
+
+#if @GNULIB_MBSSPN@
+/* Find the first occurrence in the character string STRING of any character
+ not in the character string REJECT. Return the number of bytes from the
+ beginning of the string to this occurrence, or to the end of the string
+ if none exists.
+ Unlike strspn(), this function works correctly in multibyte locales. */
+_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSSEP@
+/* Search the next delimiter (multibyte character listed in the character
+ string DELIM) starting at the character string *STRINGP.
+ If one is found, overwrite it with a NUL, and advance *STRINGP to point
+ to the next multibyte character after it. Otherwise, set *STRINGP to NULL.
+ If *STRINGP was already NULL, nothing happens.
+ Return the old value of *STRINGP.
+
+ This is a variant of mbstok_r() that supports empty fields.
+
+ Caveat: It modifies the original string.
+ Caveat: These functions cannot be used on constant strings.
+ Caveat: The identity of the delimiting character is lost.
+
+ See also mbstok_r(). */
+_GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSTOK_R@
+/* Parse the character string STRING into tokens separated by characters in
+ the character string DELIM.
+ If STRING is NULL, the saved pointer in SAVE_PTR is used as
+ the next starting point. For example:
+ char s[] = "-abc-=-def";
+ char *sp;
+ x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
+ x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
+ x = mbstok_r(NULL, "=", &sp); // x = NULL
+ // s = "abc\0-def\0"
+
+ Caveat: It modifies the original string.
+ Caveat: These functions cannot be used on constant strings.
+ Caveat: The identity of the delimiting character is lost.
+
+ See also mbssep(). */
+_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
+ _GL_ARG_NONNULL ((2, 3));
+#endif
+
+/* Map any int, typically from errno, into an error message. */
+#if @GNULIB_STRERROR@
+# if @REPLACE_STRERROR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strerror
+# define strerror rpl_strerror
+# endif
+_GL_FUNCDECL_RPL (strerror, char *, (int));
+_GL_CXXALIAS_RPL (strerror, char *, (int));
+# else
+_GL_CXXALIAS_SYS (strerror, char *, (int));
+# endif
+_GL_CXXALIASWARN (strerror);
+#elif defined GNULIB_POSIXCHECK
+# undef strerror
+/* Assume strerror is always declared. */
+_GL_WARN_ON_USE (strerror, "strerror is unportable - "
+ "use gnulib module strerror to guarantee non-NULL result");
+#endif
+
+/* Map any int, typically from errno, into an error message. Multithread-safe.
+ Uses the POSIX declaration, not the glibc declaration. */
+#if @GNULIB_STRERROR_R@
+# if @REPLACE_STRERROR_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strerror_r
+# define strerror_r rpl_strerror_r
+# endif
+_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
+# else
+# if !@HAVE_DECL_STRERROR_R@
+_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
+# endif
+# if @HAVE_DECL_STRERROR_R@
+_GL_CXXALIASWARN (strerror_r);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strerror_r
+# if HAVE_RAW_DECL_STRERROR_R
+_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
+ "use gnulib module strerror_r-posix for portability");
+# endif
+#endif
+
+#if @GNULIB_STRSIGNAL@
+# if @REPLACE_STRSIGNAL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strsignal rpl_strsignal
+# endif
+_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
+_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
+# else
+# if ! @HAVE_DECL_STRSIGNAL@
+_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
+# endif
+/* Need to cast, because on Cygwin 1.5.x systems, the return type is
+ 'const char *'. */
+_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
+# endif
+_GL_CXXALIASWARN (strsignal);
+#elif defined GNULIB_POSIXCHECK
+# undef strsignal
+# if HAVE_RAW_DECL_STRSIGNAL
+_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
+ "use gnulib module strsignal for portability");
+# endif
+#endif
+
+#if @GNULIB_STRVERSCMP@
+# if !@HAVE_STRVERSCMP@
+_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
+_GL_CXXALIASWARN (strverscmp);
+#elif defined GNULIB_POSIXCHECK
+# undef strverscmp
+# if HAVE_RAW_DECL_STRVERSCMP
+_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
+ "use gnulib module strverscmp for portability");
+# endif
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_STRING_H */
+#endif /* _@GUARD_PREFIX@_STRING_H */
+#endif
diff --git a/grub-core/lib/gnulib/strings.in.h b/grub-core/lib/gnulib/strings.in.h
new file mode 100644
index 0000000..21b1a85
--- /dev/null
+++ b/grub-core/lib/gnulib/strings.in.h
@@ -0,0 +1,122 @@
+/* A substitute <strings.h>.
+
+ Copyright (C) 2007-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_STRINGS_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* Minix 3.1.8 has a bug: <sys/types.h> must be included before <strings.h>.
+ But avoid namespace pollution on glibc systems. */
+#if defined __minix && !defined __GLIBC__
+# include <sys/types.h>
+#endif
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_STRINGS_H@
+# @INCLUDE_NEXT@ @NEXT_STRINGS_H@
+#endif
+
+#ifndef _@GUARD_PREFIX@_STRINGS_H
+#define _@GUARD_PREFIX@_STRINGS_H
+
+#if ! @HAVE_DECL_STRNCASECMP@
+/* Get size_t. */
+# include <stddef.h>
+#endif
+
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ /* Find the index of the least-significant set bit. */
+#if @GNULIB_FFS@
+# if !@HAVE_FFS@
+_GL_FUNCDECL_SYS (ffs, int, (int i));
+# endif
+_GL_CXXALIAS_SYS (ffs, int, (int i));
+_GL_CXXALIASWARN (ffs);
+#elif defined GNULIB_POSIXCHECK
+# undef ffs
+# if HAVE_RAW_DECL_FFS
+_GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
+# endif
+#endif
+
+/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
+ greater than zero if S1 is lexicographically less than, equal to or greater
+ than S2.
+ Note: This function does not work in multibyte locales. */
+#if ! @HAVE_STRCASECMP@
+extern int strcasecmp (char const *s1, char const *s2)
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+#if defined GNULIB_POSIXCHECK
+/* strcasecmp() does not work with multibyte strings:
+ POSIX says that it operates on "strings", and "string" in POSIX is defined
+ as a sequence of bytes, not of characters. */
+# undef strcasecmp
+# if HAVE_RAW_DECL_STRCASECMP
+_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
+ "strings in multibyte locales - "
+ "use mbscasecmp if you care about "
+ "internationalization, or use c_strcasecmp , "
+ "gnulib module c-strcase) if you want a locale "
+ "independent function");
+# endif
+#endif
+
+/* Compare no more than N bytes of strings S1 and S2, ignoring case,
+ returning less than, equal to or greater than zero if S1 is
+ lexicographically less than, equal to or greater than S2.
+ Note: This function cannot work correctly in multibyte locales. */
+#if ! @HAVE_DECL_STRNCASECMP@
+extern int strncasecmp (char const *s1, char const *s2, size_t n)
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+#if defined GNULIB_POSIXCHECK
+/* strncasecmp() does not work with multibyte strings:
+ POSIX says that it operates on "strings", and "string" in POSIX is defined
+ as a sequence of bytes, not of characters. */
+# undef strncasecmp
+# if HAVE_RAW_DECL_STRNCASECMP
+_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
+ "strings in multibyte locales - "
+ "use mbsncasecmp or mbspcasecmp if you care about "
+ "internationalization, or use c_strncasecmp , "
+ "gnulib module c-strcase) if you want a locale "
+ "independent function");
+# endif
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _@GUARD_PREFIX@_STRING_H */
+#endif /* _@GUARD_PREFIX@_STRING_H */
diff --git a/grub-core/lib/gnulib/stripslash.c b/grub-core/lib/gnulib/stripslash.c
new file mode 100644
index 0000000..dfc15b4
--- /dev/null
+++ b/grub-core/lib/gnulib/stripslash.c
@@ -0,0 +1,45 @@
+/* stripslash.c -- remove redundant trailing slashes from a file name
+
+ Copyright (C) 1990, 2001, 2003-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "dirname.h"
+
+/* Remove trailing slashes from FILE. Return true if a trailing slash
+ was removed. This is useful when using file name completion from a
+ shell that adds a "/" after directory names (such as tcsh and
+ bash), because on symlinks to directories, several system calls
+ have different semantics according to whether a trailing slash is
+ present. */
+
+bool
+strip_trailing_slashes (char *file)
+{
+ char *base = last_component (file);
+ char *base_lim;
+ bool had_slash;
+
+ /* last_component returns "" for file system roots, but we need to turn
+ "///" into "/". */
+ if (! *base)
+ base = file;
+ base_lim = base + base_len (base);
+ had_slash = (*base_lim != '\0');
+ *base_lim = '\0';
+ return had_slash;
+}
diff --git a/grub-core/lib/gnulib/strncasecmp.c b/grub-core/lib/gnulib/strncasecmp.c
new file mode 100644
index 0000000..034011c
--- /dev/null
+++ b/grub-core/lib/gnulib/strncasecmp.c
@@ -0,0 +1,62 @@
+/* strncasecmp.c -- case insensitive string comparator
+ Copyright (C) 1998-1999, 2005-2007, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <string.h>
+
+#include <ctype.h>
+#include <limits.h>
+
+#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
+
+/* Compare no more than N bytes of strings S1 and S2, ignoring case,
+ returning less than, equal to or greater than zero if S1 is
+ lexicographically less than, equal to or greater than S2.
+ Note: This function cannot work correctly in multibyte locales. */
+
+int
+strncasecmp (const char *s1, const char *s2, size_t n)
+{
+ register const unsigned char *p1 = (const unsigned char *) s1;
+ register const unsigned char *p2 = (const unsigned char *) s2;
+ unsigned char c1, c2;
+
+ if (p1 == p2 || n == 0)
+ return 0;
+
+ do
+ {
+ c1 = TOLOWER (*p1);
+ c2 = TOLOWER (*p2);
+
+ if (--n == 0 || c1 == '\0')
+ break;
+
+ ++p1;
+ ++p2;
+ }
+ while (c1 == c2);
+
+ if (UCHAR_MAX <= INT_MAX)
+ return c1 - c2;
+ else
+ /* On machines where 'char' and 'int' are types of the same size, the
+ difference of two 'unsigned char' values - including the sign bit -
+ doesn't fit in an 'int'. */
+ return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
+}
diff --git a/grub-core/lib/gnulib/strndup.c b/grub-core/lib/gnulib/strndup.c
new file mode 100644
index 0000000..5b74828
--- /dev/null
+++ b/grub-core/lib/gnulib/strndup.c
@@ -0,0 +1,36 @@
+/* A replacement function, for systems that lack strndup.
+
+ Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <stdlib.h>
+
+char *
+strndup (char const *s, size_t n)
+{
+ size_t len = strnlen (s, n);
+ char *new = malloc (len + 1);
+
+ if (new == NULL)
+ return NULL;
+
+ new[len] = '\0';
+ return memcpy (new, s, len);
+}
diff --git a/grub-core/lib/gnulib/strnlen.c b/grub-core/lib/gnulib/strnlen.c
new file mode 100644
index 0000000..9fb6635
--- /dev/null
+++ b/grub-core/lib/gnulib/strnlen.c
@@ -0,0 +1,30 @@
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ Copyright (C) 2005-2007, 2009-2019 Free Software Foundation, Inc.
+ Written by Simon Josefsson.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <string.h>
+
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ If no '\0' terminator is found in that many characters, return MAXLEN. */
+
+size_t
+strnlen (const char *string, size_t maxlen)
+{
+ const char *end = memchr (string, '\0', maxlen);
+ return end ? (size_t) (end - string) : maxlen;
+}
diff --git a/grub-core/lib/gnulib/strnlen1.c b/grub-core/lib/gnulib/strnlen1.c
new file mode 100644
index 0000000..666a557
--- /dev/null
+++ b/grub-core/lib/gnulib/strnlen1.c
@@ -0,0 +1,35 @@
+/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
+ Copyright (C) 2005-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "strnlen1.h"
+
+#include <string.h>
+
+/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
+ If no '\0' terminator is found in that many characters, return MAXLEN. */
+/* This is the same as strnlen (string, maxlen - 1) + 1. */
+size_t
+strnlen1 (const char *string, size_t maxlen)
+{
+ const char *end = (const char *) memchr (string, '\0', maxlen);
+ if (end != NULL)
+ return end - string + 1;
+ else
+ return maxlen;
+}
diff --git a/grub-core/lib/gnulib/strnlen1.h b/grub-core/lib/gnulib/strnlen1.h
new file mode 100644
index 0000000..5d95244
--- /dev/null
+++ b/grub-core/lib/gnulib/strnlen1.h
@@ -0,0 +1,40 @@
+/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
+ Copyright (C) 2005, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _STRNLEN1_H
+#define _STRNLEN1_H
+
+#include <stddef.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
+ If no '\0' terminator is found in that many characters, return MAXLEN. */
+/* This is the same as strnlen (string, maxlen - 1) + 1. */
+extern size_t strnlen1 (const char *string, size_t maxlen)
+ _GL_ATTRIBUTE_PURE;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _STRNLEN1_H */
diff --git a/grub-core/lib/gnulib/sys_stat.in.h b/grub-core/lib/gnulib/sys_stat.in.h
new file mode 100644
index 0000000..58fa93f
--- /dev/null
+++ b/grub-core/lib/gnulib/sys_stat.in.h
@@ -0,0 +1,816 @@
+/* Provide a more complete sys/stat.h header file.
+ Copyright (C) 2005-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
+
+/* This file is supposed to be used on platforms where <sys/stat.h> is
+ incomplete. It is intended to provide definitions and prototypes
+ needed by an application. Start with what the system provides. */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_system_sys_stat_h
+/* Special invocation convention. */
+
+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_SYS_STAT_H
+
+/* Get nlink_t.
+ May also define off_t to a 64-bit type on native Windows. */
+#include <sys/types.h>
+
+/* Get struct timespec. */
+#include <time.h>
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
+
+#ifndef _@GUARD_PREFIX@_SYS_STAT_H
+#define _@GUARD_PREFIX@_SYS_STAT_H
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
+ headers that may declare mkdir(). Native Windows platforms declare mkdir
+ in <io.h> and/or <direct.h>, not in <unistd.h>. */
+#if defined _WIN32 && ! defined __CYGWIN__
+# include <io.h> /* mingw32, mingw64 */
+# include <direct.h> /* mingw64, MSVC 9 */
+#endif
+
+/* Native Windows platforms declare umask() in <io.h>. */
+#if 0 && (defined _WIN32 && ! defined __CYGWIN__)
+# include <io.h>
+#endif
+
+/* Large File Support on native Windows. */
+#if @WINDOWS_64_BIT_ST_SIZE@
+# define stat _stati64
+#endif
+
+/* Optionally, override 'struct stat' on native Windows. */
+#if @GNULIB_OVERRIDES_STRUCT_STAT@
+
+# undef stat
+# if @GNULIB_STAT@
+# define stat rpl_stat
+# else
+ /* Provoke a clear link error if stat() is used as a function and
+ module 'stat' is not in use. */
+# define stat stat_used_without_requesting_gnulib_module_stat
+# endif
+
+# if !GNULIB_defined_struct_stat
+struct stat
+{
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+# if 0
+ uid_t st_uid;
+# else /* uid_t is not defined by default on native Windows. */
+ short st_uid;
+# endif
+# if 0
+ gid_t st_gid;
+# else /* gid_t is not defined by default on native Windows. */
+ short st_gid;
+# endif
+ dev_t st_rdev;
+ off_t st_size;
+# if 0
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
+# endif
+
+# if @WINDOWS_STAT_TIMESPEC@
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+# else
+ time_t st_atime;
+ time_t st_mtime;
+ time_t st_ctime;
+# endif
+};
+# if @WINDOWS_STAT_TIMESPEC@
+# define st_atime st_atim.tv_sec
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+ /* Indicator, for gnulib internal purposes. */
+# define _GL_WINDOWS_STAT_TIMESPEC 1
+# endif
+# define GNULIB_defined_struct_stat 1
+# endif
+
+/* Other possible values of st_mode. */
+# if 0
+# define _S_IFBLK 0x6000
+# endif
+# if 0
+# define _S_IFLNK 0xA000
+# endif
+# if 0
+# define _S_IFSOCK 0xC000
+# endif
+
+#endif
+
+#ifndef S_IFIFO
+# ifdef _S_IFIFO
+# define S_IFIFO _S_IFIFO
+# endif
+#endif
+
+#ifndef S_IFMT
+# define S_IFMT 0170000
+#endif
+
+#if STAT_MACROS_BROKEN
+# undef S_ISBLK
+# undef S_ISCHR
+# undef S_ISDIR
+# undef S_ISFIFO
+# undef S_ISLNK
+# undef S_ISNAM
+# undef S_ISMPB
+# undef S_ISMPC
+# undef S_ISNWK
+# undef S_ISREG
+# undef S_ISSOCK
+#endif
+
+#ifndef S_ISBLK
+# ifdef S_IFBLK
+# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+# else
+# define S_ISBLK(m) 0
+# endif
+#endif
+
+#ifndef S_ISCHR
+# ifdef S_IFCHR
+# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+# else
+# define S_ISCHR(m) 0
+# endif
+#endif
+
+#ifndef S_ISDIR
+# ifdef S_IFDIR
+# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+# else
+# define S_ISDIR(m) 0
+# endif
+#endif
+
+#ifndef S_ISDOOR /* Solaris 2.5 and up */
+# define S_ISDOOR(m) 0
+#endif
+
+#ifndef S_ISFIFO
+# ifdef S_IFIFO
+# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+# else
+# define S_ISFIFO(m) 0
+# endif
+#endif
+
+#ifndef S_ISLNK
+# ifdef S_IFLNK
+# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+# else
+# define S_ISLNK(m) 0
+# endif
+#endif
+
+#ifndef S_ISMPB /* V7 */
+# ifdef S_IFMPB
+# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
+# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
+# else
+# define S_ISMPB(m) 0
+# define S_ISMPC(m) 0
+# endif
+#endif
+
+#ifndef S_ISMPX /* AIX */
+# define S_ISMPX(m) 0
+#endif
+
+#ifndef S_ISNAM /* Xenix */
+# ifdef S_IFNAM
+# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
+# else
+# define S_ISNAM(m) 0
+# endif
+#endif
+
+#ifndef S_ISNWK /* HP/UX */
+# ifdef S_IFNWK
+# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
+# else
+# define S_ISNWK(m) 0
+# endif
+#endif
+
+#ifndef S_ISPORT /* Solaris 10 and up */
+# define S_ISPORT(m) 0
+#endif
+
+#ifndef S_ISREG
+# ifdef S_IFREG
+# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+# else
+# define S_ISREG(m) 0
+# endif
+#endif
+
+#ifndef S_ISSOCK
+# ifdef S_IFSOCK
+# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+# else
+# define S_ISSOCK(m) 0
+# endif
+#endif
+
+
+#ifndef S_TYPEISMQ
+# define S_TYPEISMQ(p) 0
+#endif
+
+#ifndef S_TYPEISTMO
+# define S_TYPEISTMO(p) 0
+#endif
+
+
+#ifndef S_TYPEISSEM
+# ifdef S_INSEM
+# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
+# else
+# define S_TYPEISSEM(p) 0
+# endif
+#endif
+
+#ifndef S_TYPEISSHM
+# ifdef S_INSHD
+# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
+# else
+# define S_TYPEISSHM(p) 0
+# endif
+#endif
+
+/* high performance ("contiguous data") */
+#ifndef S_ISCTG
+# define S_ISCTG(p) 0
+#endif
+
+/* Cray DMF (data migration facility): off line, with data */
+#ifndef S_ISOFD
+# define S_ISOFD(p) 0
+#endif
+
+/* Cray DMF (data migration facility): off line, with no data */
+#ifndef S_ISOFL
+# define S_ISOFL(p) 0
+#endif
+
+/* 4.4BSD whiteout */
+#ifndef S_ISWHT
+# define S_ISWHT(m) 0
+#endif
+
+/* If any of the following are undefined,
+ define them to their de facto standard values. */
+#if !S_ISUID
+# define S_ISUID 04000
+#endif
+#if !S_ISGID
+# define S_ISGID 02000
+#endif
+
+/* S_ISVTX is a common extension to POSIX. */
+#ifndef S_ISVTX
+# define S_ISVTX 01000
+#endif
+
+#if !S_IRUSR && S_IREAD
+# define S_IRUSR S_IREAD
+#endif
+#if !S_IRUSR
+# define S_IRUSR 00400
+#endif
+#if !S_IRGRP
+# define S_IRGRP (S_IRUSR >> 3)
+#endif
+#if !S_IROTH
+# define S_IROTH (S_IRUSR >> 6)
+#endif
+
+#if !S_IWUSR && S_IWRITE
+# define S_IWUSR S_IWRITE
+#endif
+#if !S_IWUSR
+# define S_IWUSR 00200
+#endif
+#if !S_IWGRP
+# define S_IWGRP (S_IWUSR >> 3)
+#endif
+#if !S_IWOTH
+# define S_IWOTH (S_IWUSR >> 6)
+#endif
+
+#if !S_IXUSR && S_IEXEC
+# define S_IXUSR S_IEXEC
+#endif
+#if !S_IXUSR
+# define S_IXUSR 00100
+#endif
+#if !S_IXGRP
+# define S_IXGRP (S_IXUSR >> 3)
+#endif
+#if !S_IXOTH
+# define S_IXOTH (S_IXUSR >> 6)
+#endif
+
+#if !S_IRWXU
+# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
+#endif
+#if !S_IRWXG
+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
+#endif
+#if !S_IRWXO
+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
+#endif
+
+/* S_IXUGO is a common extension to POSIX. */
+#if !S_IXUGO
+# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
+#endif
+
+#ifndef S_IRWXUGO
+# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
+#endif
+
+/* Macros for futimens and utimensat. */
+#ifndef UTIME_NOW
+# define UTIME_NOW (-1)
+# define UTIME_OMIT (-2)
+#endif
+
+
+#if @GNULIB_FCHMODAT@
+# if !@HAVE_FCHMODAT@
+_GL_FUNCDECL_SYS (fchmodat, int,
+ (int fd, char const *file, mode_t mode, int flag)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (fchmodat, int,
+ (int fd, char const *file, mode_t mode, int flag));
+_GL_CXXALIASWARN (fchmodat);
+#elif defined GNULIB_POSIXCHECK
+# undef fchmodat
+# if HAVE_RAW_DECL_FCHMODAT
+_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
+ "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FSTAT@
+# if @REPLACE_FSTAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fstat
+# define fstat rpl_fstat
+# endif
+_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
+# else
+_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
+# endif
+_GL_CXXALIASWARN (fstat);
+#elif @GNULIB_OVERRIDES_STRUCT_STAT@
+# undef fstat
+# define fstat fstat_used_without_requesting_gnulib_module_fstat
+#elif @WINDOWS_64_BIT_ST_SIZE@
+/* Above, we define stat to _stati64. */
+# define fstat _fstati64
+#elif defined GNULIB_POSIXCHECK
+# undef fstat
+# if HAVE_RAW_DECL_FSTAT
+_GL_WARN_ON_USE (fstat, "fstat has portability problems - "
+ "use gnulib module fstat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FSTATAT@
+# if @REPLACE_FSTATAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fstatat
+# define fstatat rpl_fstatat
+# endif
+_GL_FUNCDECL_RPL (fstatat, int,
+ (int fd, char const *name, struct stat *st, int flags)
+ _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (fstatat, int,
+ (int fd, char const *name, struct stat *st, int flags));
+# else
+# if !@HAVE_FSTATAT@
+_GL_FUNCDECL_SYS (fstatat, int,
+ (int fd, char const *name, struct stat *st, int flags)
+ _GL_ARG_NONNULL ((2, 3)));
+# endif
+_GL_CXXALIAS_SYS (fstatat, int,
+ (int fd, char const *name, struct stat *st, int flags));
+# endif
+_GL_CXXALIASWARN (fstatat);
+#elif @GNULIB_OVERRIDES_STRUCT_STAT@
+# undef fstatat
+# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
+#elif defined GNULIB_POSIXCHECK
+# undef fstatat
+# if HAVE_RAW_DECL_FSTATAT
+_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
+ "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FUTIMENS@
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
+ implementation relies on futimesat, which on Solaris 10 makes an invocation
+ to futimens that is meant to invoke the libc's futimens(), not gnulib's
+ futimens(). */
+# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef futimens
+# define futimens rpl_futimens
+# endif
+_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
+_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
+# else
+# if !@HAVE_FUTIMENS@
+_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
+# endif
+_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
+# endif
+# if @HAVE_FUTIMENS@
+_GL_CXXALIASWARN (futimens);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef futimens
+# if HAVE_RAW_DECL_FUTIMENS
+_GL_WARN_ON_USE (futimens, "futimens is not portable - "
+ "use gnulib module futimens for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LCHMOD@
+/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
+ denotes a symbolic link. */
+# if !@HAVE_LCHMOD@
+/* The lchmod replacement follows symbolic links. Callers should take
+ this into account; lchmod should be applied only to arguments that
+ are known to not be symbolic links. On hosts that lack lchmod,
+ this can lead to race conditions between the check and the
+ invocation of lchmod, but we know of no workarounds that are
+ reliable in general. You might try requesting support for lchmod
+ from your operating system supplier. */
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define lchmod chmod
+# endif
+/* Need to cast, because on mingw, the second parameter of chmod is
+ int mode. */
+_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
+ (const char *filename, mode_t mode));
+# else
+# if 0 /* assume already declared */
+_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
+# endif
+# if @HAVE_LCHMOD@
+_GL_CXXALIASWARN (lchmod);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef lchmod
+# if HAVE_RAW_DECL_LCHMOD
+_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
+ "use gnulib module lchmod for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LSTAT@
+# if ! @HAVE_LSTAT@
+/* mingw does not support symlinks, therefore it does not have lstat. But
+ without links, stat does just fine. */
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define lstat stat
+# endif
+_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
+# elif @REPLACE_LSTAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef lstat
+# define lstat rpl_lstat
+# endif
+_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
+# else
+_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
+# endif
+# if @HAVE_LSTAT@
+_GL_CXXALIASWARN (lstat);
+# endif
+#elif @GNULIB_OVERRIDES_STRUCT_STAT@
+# undef lstat
+# define lstat lstat_used_without_requesting_gnulib_module_lstat
+#elif defined GNULIB_POSIXCHECK
+# undef lstat
+# if HAVE_RAW_DECL_LSTAT
+_GL_WARN_ON_USE (lstat, "lstat is unportable - "
+ "use gnulib module lstat for portability");
+# endif
+#endif
+
+
+#if @REPLACE_MKDIR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef mkdir
+# define mkdir rpl_mkdir
+# endif
+_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
+#else
+/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
+ Additionally, it declares _mkdir (and depending on compile flags, an
+ alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
+ which are included above. */
+# if defined _WIN32 && ! defined __CYGWIN__
+
+# if !GNULIB_defined_rpl_mkdir
+static int
+rpl_mkdir (char const *name, mode_t mode)
+{
+ return _mkdir (name);
+}
+# define GNULIB_defined_rpl_mkdir 1
+# endif
+
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mkdir rpl_mkdir
+# endif
+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
+# else
+_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
+# endif
+#endif
+_GL_CXXALIASWARN (mkdir);
+
+
+#if @GNULIB_MKDIRAT@
+# if !@HAVE_MKDIRAT@
+_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
+_GL_CXXALIASWARN (mkdirat);
+#elif defined GNULIB_POSIXCHECK
+# undef mkdirat
+# if HAVE_RAW_DECL_MKDIRAT
+_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
+ "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKFIFO@
+# if @REPLACE_MKFIFO@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef mkfifo
+# define mkfifo rpl_mkfifo
+# endif
+_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
+# else
+# if !@HAVE_MKFIFO@
+_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
+# endif
+_GL_CXXALIASWARN (mkfifo);
+#elif defined GNULIB_POSIXCHECK
+# undef mkfifo
+# if HAVE_RAW_DECL_MKFIFO
+_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
+ "use gnulib module mkfifo for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKFIFOAT@
+# if !@HAVE_MKFIFOAT@
+_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
+_GL_CXXALIASWARN (mkfifoat);
+#elif defined GNULIB_POSIXCHECK
+# undef mkfifoat
+# if HAVE_RAW_DECL_MKFIFOAT
+_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
+ "use gnulib module mkfifoat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKNOD@
+# if @REPLACE_MKNOD@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef mknod
+# define mknod rpl_mknod
+# endif
+_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
+# else
+# if !@HAVE_MKNOD@
+_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
+ _GL_ARG_NONNULL ((1)));
+# endif
+/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
+_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
+# endif
+_GL_CXXALIASWARN (mknod);
+#elif defined GNULIB_POSIXCHECK
+# undef mknod
+# if HAVE_RAW_DECL_MKNOD
+_GL_WARN_ON_USE (mknod, "mknod is not portable - "
+ "use gnulib module mknod for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKNODAT@
+# if !@HAVE_MKNODAT@
+_GL_FUNCDECL_SYS (mknodat, int,
+ (int fd, char const *file, mode_t mode, dev_t dev)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mknodat, int,
+ (int fd, char const *file, mode_t mode, dev_t dev));
+_GL_CXXALIASWARN (mknodat);
+#elif defined GNULIB_POSIXCHECK
+# undef mknodat
+# if HAVE_RAW_DECL_MKNODAT
+_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
+ "use gnulib module mkfifoat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_STAT@
+# if @REPLACE_STAT@
+# if !@GNULIB_OVERRIDES_STRUCT_STAT@
+ /* We can't use the object-like #define stat rpl_stat, because of
+ struct stat. This means that rpl_stat will not be used if the user
+ does (stat)(a,b). Oh well. */
+# if defined _AIX && defined stat && defined _LARGE_FILES
+ /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
+ so we have to replace stat64() instead of stat(). */
+# undef stat64
+# define stat64(name, st) rpl_stat (name, st)
+# elif @WINDOWS_64_BIT_ST_SIZE@
+ /* Above, we define stat to _stati64. */
+# if defined __MINGW32__ && defined _stati64
+# ifndef _USE_32BIT_TIME_T
+ /* The system headers define _stati64 to _stat64. */
+# undef _stat64
+# define _stat64(name, st) rpl_stat (name, st)
+# endif
+# elif defined _MSC_VER && defined _stati64
+# ifdef _USE_32BIT_TIME_T
+ /* The system headers define _stati64 to _stat32i64. */
+# undef _stat32i64
+# define _stat32i64(name, st) rpl_stat (name, st)
+# else
+ /* The system headers define _stati64 to _stat64. */
+# undef _stat64
+# define _stat64(name, st) rpl_stat (name, st)
+# endif
+# else
+# undef _stati64
+# define _stati64(name, st) rpl_stat (name, st)
+# endif
+# elif defined __MINGW32__ && defined stat
+# ifdef _USE_32BIT_TIME_T
+ /* The system headers define stat to _stat32i64. */
+# undef _stat32i64
+# define _stat32i64(name, st) rpl_stat (name, st)
+# else
+ /* The system headers define stat to _stat64. */
+# undef _stat64
+# define _stat64(name, st) rpl_stat (name, st)
+# endif
+# elif defined _MSC_VER && defined stat
+# ifdef _USE_32BIT_TIME_T
+ /* The system headers define stat to _stat32. */
+# undef _stat32
+# define _stat32(name, st) rpl_stat (name, st)
+# else
+ /* The system headers define stat to _stat64i32. */
+# undef _stat64i32
+# define _stat64i32(name, st) rpl_stat (name, st)
+# endif
+# else /* !(_AIX || __MINGW32__ || _MSC_VER) */
+# undef stat
+# define stat(name, st) rpl_stat (name, st)
+# endif /* !_LARGE_FILES */
+# endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
+_GL_EXTERN_C int stat (const char *name, struct stat *buf)
+ _GL_ARG_NONNULL ((1, 2));
+# endif
+#elif @GNULIB_OVERRIDES_STRUCT_STAT@
+/* see above:
+ #define stat stat_used_without_requesting_gnulib_module_stat
+ */
+#elif defined GNULIB_POSIXCHECK
+# undef stat
+# if HAVE_RAW_DECL_STAT
+_GL_WARN_ON_USE (stat, "stat is unportable - "
+ "use gnulib module stat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_UTIMENSAT@
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
+ implementation relies on futimesat, which on Solaris 10 makes an invocation
+ to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
+ utimensat(). */
+# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef utimensat
+# define utimensat rpl_utimensat
+# endif
+_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
+ struct timespec const times[2], int flag)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
+ struct timespec const times[2], int flag));
+# else
+# if !@HAVE_UTIMENSAT@
+_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
+ struct timespec const times[2], int flag)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
+ struct timespec const times[2], int flag));
+# endif
+# if @HAVE_UTIMENSAT@
+_GL_CXXALIASWARN (utimensat);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef utimensat
+# if HAVE_RAW_DECL_UTIMENSAT
+_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
+ "use gnulib module utimensat for portability");
+# endif
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
+#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
+#endif
diff --git a/grub-core/lib/gnulib/sys_types.in.h b/grub-core/lib/gnulib/sys_types.in.h
new file mode 100644
index 0000000..237e206
--- /dev/null
+++ b/grub-core/lib/gnulib/sys_types.in.h
@@ -0,0 +1,106 @@
+/* Provide a more complete sys/types.h.
+
+ Copyright (C) 2011-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined _WIN32 && !defined __CYGWIN__ \
+ && (defined __need_off_t || defined __need___off64_t \
+ || defined __need_ssize_t || defined __need_time_t)
+
+/* Special invocation convention inside mingw header files. */
+
+#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
+
+/* The include_next requires a split double-inclusion guard. */
+# define _GL_INCLUDING_SYS_TYPES_H
+#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
+# undef _GL_INCLUDING_SYS_TYPES_H
+
+#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
+#define _@GUARD_PREFIX@_SYS_TYPES_H
+
+/* Override off_t if Large File Support is requested on native Windows. */
+#if @WINDOWS_64_BIT_OFF_T@
+/* Same as int64_t in <stdint.h>. */
+# if defined _MSC_VER
+# define off_t __int64
+# else
+# define off_t long long int
+# endif
+/* Indicator, for gnulib internal purposes. */
+# define _GL_WINDOWS_64_BIT_OFF_T 1
+#endif
+
+/* Override dev_t and ino_t if distinguishable inodes support is requested
+ on native Windows. */
+#if @WINDOWS_STAT_INODES@
+
+# if @WINDOWS_STAT_INODES@ == 2
+/* Experimental, not useful in Windows 10. */
+
+/* Define dev_t to a 64-bit type. */
+# if !defined GNULIB_defined_dev_t
+typedef unsigned long long int rpl_dev_t;
+# undef dev_t
+# define dev_t rpl_dev_t
+# define GNULIB_defined_dev_t 1
+# endif
+
+/* Define ino_t to a 128-bit type. */
+# if !defined GNULIB_defined_ino_t
+/* MSVC does not have a 128-bit integer type.
+ GCC has a 128-bit integer type __int128, but only on 64-bit targets. */
+typedef struct { unsigned long long int _gl_ino[2]; } rpl_ino_t;
+# undef ino_t
+# define ino_t rpl_ino_t
+# define GNULIB_defined_ino_t 1
+# endif
+
+# else /* @WINDOWS_STAT_INODES@ == 1 */
+
+/* Define ino_t to a 64-bit type. */
+# if !defined GNULIB_defined_ino_t
+typedef unsigned long long int rpl_ino_t;
+# undef ino_t
+# define ino_t rpl_ino_t
+# define GNULIB_defined_ino_t 1
+# endif
+
+# endif
+
+/* Indicator, for gnulib internal purposes. */
+# define _GL_WINDOWS_STAT_INODES @WINDOWS_STAT_INODES@
+
+#endif
+
+/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */
+/* But avoid namespace pollution on glibc systems. */
+#if (defined _WIN32 && ! defined __CYGWIN__) && ! defined __GLIBC__
+# include <stddef.h>
+#endif
+
+#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
+#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
+#endif /* __need_XXX */
diff --git a/grub-core/lib/gnulib/sysexits.in.h b/grub-core/lib/gnulib/sysexits.in.h
new file mode 100644
index 0000000..7043a0a
--- /dev/null
+++ b/grub-core/lib/gnulib/sysexits.in.h
@@ -0,0 +1,72 @@
+/* exit() exit codes for some BSD system programs.
+ Copyright (C) 2003, 2006-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Simon Josefsson based on sysexits(3) man page */
+
+#ifndef _@GUARD_PREFIX@_SYSEXITS_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if @HAVE_SYSEXITS_H@
+
+/* IRIX 6.5 has an <unistd.h> that defines a macro EX_OK with a nonzero
+ value. Override it. See
+ <https://lists.gnu.org/r/bug-gnulib/2007-03/msg00361.html> */
+# ifdef __sgi
+# include <unistd.h>
+# undef EX_OK
+# endif
+
+/* The include_next requires a split double-inclusion guard. */
+# @INCLUDE_NEXT@ @NEXT_SYSEXITS_H@
+
+/* HP-UX 11 <sysexits.h> ends at EX_NOPERM. */
+# ifndef EX_CONFIG
+# define EX_CONFIG 78
+# endif
+
+#endif
+
+#ifndef _@GUARD_PREFIX@_SYSEXITS_H
+#define _@GUARD_PREFIX@_SYSEXITS_H
+
+#if !@HAVE_SYSEXITS_H@
+
+# define EX_OK 0 /* same value as EXIT_SUCCESS */
+
+# define EX_USAGE 64
+# define EX_DATAERR 65
+# define EX_NOINPUT 66
+# define EX_NOUSER 67
+# define EX_NOHOST 68
+# define EX_UNAVAILABLE 69
+# define EX_SOFTWARE 70
+# define EX_OSERR 71
+# define EX_OSFILE 72
+# define EX_CANTCREAT 73
+# define EX_IOERR 74
+# define EX_TEMPFAIL 75
+# define EX_PROTOCOL 76
+# define EX_NOPERM 77
+# define EX_CONFIG 78
+
+#endif
+
+#endif /* _@GUARD_PREFIX@_SYSEXITS_H */
+#endif /* _@GUARD_PREFIX@_SYSEXITS_H */
diff --git a/grub-core/lib/gnulib/time.in.h b/grub-core/lib/gnulib/time.in.h
new file mode 100644
index 0000000..dd3b212
--- /dev/null
+++ b/grub-core/lib/gnulib/time.in.h
@@ -0,0 +1,350 @@
+/* A more-standard <time.h>.
+
+ Copyright (C) 2007-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* Don't get in the way of glibc when it includes time.h merely to
+ declare a few standard symbols, rather than to declare all the
+ symbols. (However, skip this for MinGW as it treats __need_time_t
+ incompatibly.) Also, Solaris 8 <time.h> eventually includes itself
+ recursively; if that is happening, just include the system <time.h>
+ without adding our own declarations. */
+#if (((defined __need_time_t || defined __need_clock_t \
+ || defined __need_timespec) \
+ && !defined __MINGW32__) \
+ || defined _@GUARD_PREFIX@_TIME_H)
+
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
+
+#else
+
+# define _@GUARD_PREFIX@_TIME_H
+
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
+
+/* NetBSD 5.0 mis-defines NULL. */
+# include <stddef.h>
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+/* Some systems don't define struct timespec (e.g., AIX 4.1).
+ Or they define it with the wrong member names or define it in <sys/time.h>
+ (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it,
+ but the pthreads-win32 library defines it in <pthread.h>. */
+# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
+# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+# include <sys/time.h>
+# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+# include <pthread.h>
+# elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
+# include <unistd.h>
+# else
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if !GNULIB_defined_struct_timespec
+# undef timespec
+# define timespec rpl_timespec
+struct timespec
+{
+ time_t tv_sec;
+ long int tv_nsec;
+};
+# define GNULIB_defined_struct_timespec 1
+# endif
+
+# ifdef __cplusplus
+}
+# endif
+
+# endif
+# endif
+
+# if !GNULIB_defined_struct_time_t_must_be_integral
+/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
+ time_t to be an integer type, even though C99 permits floating
+ point. We don't know of any implementation that uses floating
+ point, and it is much easier to write code that doesn't have to
+ worry about that corner case, so we force the issue. */
+struct __time_t_must_be_integral {
+ unsigned int __floating_time_t_unsupported : (time_t) 1;
+};
+# define GNULIB_defined_struct_time_t_must_be_integral 1
+# endif
+
+/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
+ return -1 and store the remaining time into RMTP. See
+ <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
+# if @GNULIB_NANOSLEEP@
+# if @REPLACE_NANOSLEEP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define nanosleep rpl_nanosleep
+# endif
+_GL_FUNCDECL_RPL (nanosleep, int,
+ (struct timespec const *__rqtp, struct timespec *__rmtp)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (nanosleep, int,
+ (struct timespec const *__rqtp, struct timespec *__rmtp));
+# else
+# if ! @HAVE_NANOSLEEP@
+_GL_FUNCDECL_SYS (nanosleep, int,
+ (struct timespec const *__rqtp, struct timespec *__rmtp)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (nanosleep, int,
+ (struct timespec const *__rqtp, struct timespec *__rmtp));
+# endif
+_GL_CXXALIASWARN (nanosleep);
+# endif
+
+/* Initialize time conversion information. */
+# if @GNULIB_TZSET@
+# if @REPLACE_TZSET@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef tzset
+# define tzset rpl_tzset
+# endif
+_GL_FUNCDECL_RPL (tzset, void, (void));
+_GL_CXXALIAS_RPL (tzset, void, (void));
+# else
+# if ! @HAVE_TZSET@
+_GL_FUNCDECL_SYS (tzset, void, (void));
+# endif
+_GL_CXXALIAS_SYS (tzset, void, (void));
+# endif
+_GL_CXXALIASWARN (tzset);
+# endif
+
+/* Return the 'time_t' representation of TP and normalize TP. */
+# if @GNULIB_MKTIME@
+# if @REPLACE_MKTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define mktime rpl_mktime
+# endif
+_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
+# else
+_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
+# endif
+_GL_CXXALIASWARN (mktime);
+# endif
+
+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
+ <http://www.opengroup.org/susv3xsh/localtime_r.html> and
+ <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
+# if @GNULIB_TIME_R@
+# if @REPLACE_LOCALTIME_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef localtime_r
+# define localtime_r rpl_localtime_r
+# endif
+_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result));
+# else
+# if ! @HAVE_DECL_LOCALTIME_R@
+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result));
+# endif
+# if @HAVE_DECL_LOCALTIME_R@
+_GL_CXXALIASWARN (localtime_r);
+# endif
+# if @REPLACE_LOCALTIME_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef gmtime_r
+# define gmtime_r rpl_gmtime_r
+# endif
+_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result));
+# else
+# if ! @HAVE_DECL_LOCALTIME_R@
+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result));
+# endif
+# if @HAVE_DECL_LOCALTIME_R@
+_GL_CXXALIASWARN (gmtime_r);
+# endif
+# endif
+
+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
+ <http://www.opengroup.org/susv3xsh/localtime.html> and
+ <http://www.opengroup.org/susv3xsh/gmtime.html>. */
+# if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@
+# if @REPLACE_LOCALTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef localtime
+# define localtime rpl_localtime
+# endif
+_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
+# else
+_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
+# endif
+_GL_CXXALIASWARN (localtime);
+# endif
+
+# if 0 || @REPLACE_GMTIME@
+# if @REPLACE_GMTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef gmtime
+# define gmtime rpl_gmtime
+# endif
+_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
+# else
+_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
+# endif
+_GL_CXXALIASWARN (gmtime);
+# endif
+
+/* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
+ the resulting broken-down time into TM. See
+ <http://www.opengroup.org/susv3xsh/strptime.html>. */
+# if @GNULIB_STRPTIME@
+# if ! @HAVE_STRPTIME@
+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
+ char const *restrict __format,
+ struct tm *restrict __tm)
+ _GL_ARG_NONNULL ((1, 2, 3)));
+# endif
+_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
+ char const *restrict __format,
+ struct tm *restrict __tm));
+_GL_CXXALIASWARN (strptime);
+# endif
+
+/* Convert *TP to a date and time string. See
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>. */
+# if @GNULIB_CTIME@
+# if @REPLACE_CTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define ctime rpl_ctime
+# endif
+_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
+# else
+_GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
+# endif
+_GL_CXXALIASWARN (ctime);
+# endif
+
+/* Convert *TP to a date and time string. See
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>. */
+# if @GNULIB_STRFTIME@
+# if @REPLACE_STRFTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strftime rpl_strftime
+# endif
+_GL_FUNCDECL_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
+ const char *__fmt, const struct tm *__tp)
+ _GL_ARG_NONNULL ((1, 3, 4)));
+_GL_CXXALIAS_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
+ const char *__fmt, const struct tm *__tp));
+# else
+_GL_CXXALIAS_SYS (strftime, size_t, (char *__buf, size_t __bufsize,
+ const char *__fmt, const struct tm *__tp));
+# endif
+_GL_CXXALIASWARN (strftime);
+# endif
+
+# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
+typedef struct tm_zone *timezone_t;
+_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
+_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
+_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
+_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
+_GL_FUNCDECL_SYS (localtime_rz, struct tm *,
+ (timezone_t __tz, time_t const *restrict __timer,
+ struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_SYS (localtime_rz, struct tm *,
+ (timezone_t __tz, time_t const *restrict __timer,
+ struct tm *restrict __result));
+_GL_FUNCDECL_SYS (mktime_z, time_t,
+ (timezone_t __tz, struct tm *restrict __result)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_SYS (mktime_z, time_t,
+ (timezone_t __tz, struct tm *restrict __result));
+# endif
+
+/* Convert TM to a time_t value, assuming UTC. */
+# if @GNULIB_TIMEGM@
+# if @REPLACE_TIMEGM@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef timegm
+# define timegm rpl_timegm
+# endif
+_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
+# else
+# if ! @HAVE_TIMEGM@
+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
+# endif
+_GL_CXXALIASWARN (timegm);
+# endif
+
+/* Encourage applications to avoid unsafe functions that can overrun
+ buffers when given outlandish struct tm values. Portable
+ applications should use strftime (or even sprintf) instead. */
+# if defined GNULIB_POSIXCHECK
+# undef asctime
+_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
+ "better use strftime (or even sprintf) instead");
+# endif
+# if defined GNULIB_POSIXCHECK
+# undef asctime_r
+_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
+ "better use strftime (or even sprintf) instead");
+# endif
+# if defined GNULIB_POSIXCHECK
+# undef ctime
+_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
+ "better use strftime (or even sprintf) instead");
+# endif
+# if defined GNULIB_POSIXCHECK
+# undef ctime_r
+_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
+ "better use strftime (or even sprintf) instead");
+# endif
+
+#endif
diff --git a/grub-core/lib/gnulib/unistd--.h b/grub-core/lib/gnulib/unistd--.h
new file mode 100644
index 0000000..1268854
--- /dev/null
+++ b/grub-core/lib/gnulib/unistd--.h
@@ -0,0 +1,32 @@
+/* Like unistd.h, but redefine some names to avoid glitches.
+
+ Copyright (C) 2005, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#include <unistd.h>
+#include "unistd-safer.h"
+
+#undef dup
+#define dup dup_safer
+
+#undef pipe
+#define pipe pipe_safer
+
+#if GNULIB_PIPE2_SAFER
+# undef pipe2
+# define pipe2 pipe2_safer
+#endif
diff --git a/grub-core/lib/gnulib/unistd-safer.h b/grub-core/lib/gnulib/unistd-safer.h
new file mode 100644
index 0000000..8eebffc
--- /dev/null
+++ b/grub-core/lib/gnulib/unistd-safer.h
@@ -0,0 +1,31 @@
+/* Invoke unistd-like functions, but avoid some glitches.
+
+ Copyright (C) 2001, 2003, 2005, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert and Eric Blake. */
+
+int dup_safer (int);
+int fd_safer (int);
+int pipe_safer (int[2]);
+
+#if GNULIB_FD_SAFER_FLAG
+int dup_safer_flag (int, int);
+int fd_safer_flag (int, int);
+#endif
+
+#if GNULIB_PIPE2_SAFER
+int pipe2_safer (int[2], int);
+#endif
diff --git a/grub-core/lib/gnulib/unistd.c b/grub-core/lib/gnulib/unistd.c
new file mode 100644
index 0000000..72bad1c
--- /dev/null
+++ b/grub-core/lib/gnulib/unistd.c
@@ -0,0 +1,4 @@
+#include <config.h>
+#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE
+#include "unistd.h"
+typedef int dummy;
diff --git a/grub-core/lib/gnulib/unistd.in.h b/grub-core/lib/gnulib/unistd.in.h
new file mode 100644
index 0000000..a10ca28
--- /dev/null
+++ b/grub-core/lib/gnulib/unistd.in.h
@@ -0,0 +1,1668 @@
+/* Substitute for and wrapper around <unistd.h>.
+ Copyright (C) 2003-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_UNISTD_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#ifdef _GL_INCLUDING_UNISTD_H
+/* Special invocation convention:
+ - On Mac OS X 10.3.9 we have a sequence of nested includes
+ <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
+ In this situation, the functions are not yet declared, therefore we cannot
+ provide the C++ aliases. */
+
+#@INCLUDE_NEXT@ @NEXT_UNISTD_H@
+
+#else
+/* Normal invocation convention. */
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_UNISTD_H@
+# define _GL_INCLUDING_UNISTD_H
+# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
+# undef _GL_INCLUDING_UNISTD_H
+#endif
+
+/* Get all possible declarations of gethostname(). */
+#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
+ && !defined _GL_INCLUDING_WINSOCK2_H
+# define _GL_INCLUDING_WINSOCK2_H
+# include <winsock2.h>
+# undef _GL_INCLUDING_WINSOCK2_H
+#endif
+
+#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
+#define _@GUARD_PREFIX@_UNISTD_H
+
+/* NetBSD 5.0 mis-defines NULL. Also get size_t. */
+#include <stddef.h>
+
+/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
+/* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
+ it before we #define unlink rpl_unlink. */
+/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
+/* But avoid namespace pollution on glibc systems. */
+#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
+ || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
+ && (defined _WIN32 && ! defined __CYGWIN__)) \
+ || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
+ && defined __CYGWIN__)) \
+ && ! defined __GLIBC__
+# include <stdio.h>
+#endif
+
+/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
+/* But avoid namespace pollution on glibc systems. */
+#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
+ && ! defined __GLIBC__
+# include <fcntl.h>
+#endif
+
+/* mingw fails to declare _exit in <unistd.h>. */
+/* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
+ <unistd.h>. */
+/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
+/* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
+ included here. */
+/* But avoid namespace pollution on glibc systems. */
+#if !defined __GLIBC__ && !defined __osf__
+# define __need_system_stdlib_h
+# include <stdlib.h>
+# undef __need_system_stdlib_h
+#endif
+
+/* Native Windows platforms declare chdir, getcwd, rmdir in
+ <io.h> and/or <direct.h>, not in <unistd.h>.
+ They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
+ lseek(), read(), unlink(), write() in <io.h>. */
+#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
+ || defined GNULIB_POSIXCHECK) \
+ && (defined _WIN32 && ! defined __CYGWIN__))
+# include <io.h> /* mingw32, mingw64 */
+# include <direct.h> /* mingw64, MSVC 9 */
+#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
+ || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
+ || defined GNULIB_POSIXCHECK) \
+ && (defined _WIN32 && ! defined __CYGWIN__)
+# include <io.h>
+#endif
+
+/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
+ NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
+/* But avoid namespace pollution on glibc systems. */
+#if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
+ || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
+ && !defined __GLIBC__
+# include <netdb.h>
+#endif
+
+/* MSVC defines off_t in <sys/types.h>.
+ May also define off_t to a 64-bit type on native Windows. */
+#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
+/* Get off_t. */
+# include <sys/types.h>
+#endif
+
+#if (@GNULIB_READ@ || @GNULIB_WRITE@ \
+ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
+ || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
+/* Get ssize_t. */
+# include <sys/types.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+
+/* Get getopt(), optarg, optind, opterr, optopt. */
+#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
+# include <getopt-cdefs.h>
+# include <getopt-pfx-core.h>
+#endif
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_UNISTD_INLINE
+# define _GL_UNISTD_INLINE _GL_INLINE
+#endif
+
+/* Hide some function declarations from <winsock2.h>. */
+
+#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
+# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef socket
+# define socket socket_used_without_including_sys_socket_h
+# undef connect
+# define connect connect_used_without_including_sys_socket_h
+# undef accept
+# define accept accept_used_without_including_sys_socket_h
+# undef bind
+# define bind bind_used_without_including_sys_socket_h
+# undef getpeername
+# define getpeername getpeername_used_without_including_sys_socket_h
+# undef getsockname
+# define getsockname getsockname_used_without_including_sys_socket_h
+# undef getsockopt
+# define getsockopt getsockopt_used_without_including_sys_socket_h
+# undef listen
+# define listen listen_used_without_including_sys_socket_h
+# undef recv
+# define recv recv_used_without_including_sys_socket_h
+# undef send
+# define send send_used_without_including_sys_socket_h
+# undef recvfrom
+# define recvfrom recvfrom_used_without_including_sys_socket_h
+# undef sendto
+# define sendto sendto_used_without_including_sys_socket_h
+# undef setsockopt
+# define setsockopt setsockopt_used_without_including_sys_socket_h
+# undef shutdown
+# define shutdown shutdown_used_without_including_sys_socket_h
+# else
+ _GL_WARN_ON_USE (socket,
+ "socket() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (connect,
+ "connect() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (accept,
+ "accept() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (bind,
+ "bind() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (getpeername,
+ "getpeername() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (getsockname,
+ "getsockname() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (getsockopt,
+ "getsockopt() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (listen,
+ "listen() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (recv,
+ "recv() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (send,
+ "send() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (recvfrom,
+ "recvfrom() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (sendto,
+ "sendto() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (setsockopt,
+ "setsockopt() used without including <sys/socket.h>");
+ _GL_WARN_ON_USE (shutdown,
+ "shutdown() used without including <sys/socket.h>");
+# endif
+# endif
+# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef select
+# define select select_used_without_including_sys_select_h
+# else
+ _GL_WARN_ON_USE (select,
+ "select() used without including <sys/select.h>");
+# endif
+# endif
+#endif
+
+
+/* OS/2 EMX lacks these macros. */
+#ifndef STDIN_FILENO
+# define STDIN_FILENO 0
+#endif
+#ifndef STDOUT_FILENO
+# define STDOUT_FILENO 1
+#endif
+#ifndef STDERR_FILENO
+# define STDERR_FILENO 2
+#endif
+
+/* Ensure *_OK macros exist. */
+#ifndef F_OK
+# define F_OK 0
+# define X_OK 1
+# define W_OK 2
+# define R_OK 4
+#endif
+
+
+/* Declare overridden functions. */
+
+
+#if defined GNULIB_POSIXCHECK
+/* The access() function is a security risk. */
+_GL_WARN_ON_USE (access, "the access function is a security risk - "
+ "use the gnulib module faccessat instead");
+#endif
+
+
+#if @GNULIB_CHDIR@
+_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIASWARN (chdir);
+#elif defined GNULIB_POSIXCHECK
+# undef chdir
+# if HAVE_RAW_DECL_CHDIR
+_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
+ "use gnulib module chdir for portability");
+# endif
+#endif
+
+
+#if @GNULIB_CHOWN@
+/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
+ to GID (if GID is not -1). Follow symbolic links.
+ Return 0 if successful, otherwise -1 and errno set.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
+# if @REPLACE_CHOWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef chown
+# define chown rpl_chown
+# endif
+_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
+# else
+# if !@HAVE_CHOWN@
+_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
+# endif
+_GL_CXXALIASWARN (chown);
+#elif defined GNULIB_POSIXCHECK
+# undef chown
+# if HAVE_RAW_DECL_CHOWN
+_GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
+ "doesn't treat a uid or gid of -1 on some systems - "
+ "use gnulib module chown for portability");
+# endif
+#endif
+
+
+#if @GNULIB_CLOSE@
+# if @REPLACE_CLOSE@
+/* Automatically included by modules that need a replacement for close. */
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef close
+# define close rpl_close
+# endif
+_GL_FUNCDECL_RPL (close, int, (int fd));
+_GL_CXXALIAS_RPL (close, int, (int fd));
+# else
+_GL_CXXALIAS_SYS (close, int, (int fd));
+# endif
+_GL_CXXALIASWARN (close);
+#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+# undef close
+# define close close_used_without_requesting_gnulib_module_close
+#elif defined GNULIB_POSIXCHECK
+# undef close
+/* Assume close is always declared. */
+_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
+ "use gnulib module close for portability");
+#endif
+
+
+#if @GNULIB_DUP@
+# if @REPLACE_DUP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define dup rpl_dup
+# endif
+_GL_FUNCDECL_RPL (dup, int, (int oldfd));
+_GL_CXXALIAS_RPL (dup, int, (int oldfd));
+# else
+_GL_CXXALIAS_SYS (dup, int, (int oldfd));
+# endif
+_GL_CXXALIASWARN (dup);
+#elif defined GNULIB_POSIXCHECK
+# undef dup
+# if HAVE_RAW_DECL_DUP
+_GL_WARN_ON_USE (dup, "dup is unportable - "
+ "use gnulib module dup for portability");
+# endif
+#endif
+
+
+#if @GNULIB_DUP2@
+/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
+ NEWFD = OLDFD, otherwise close NEWFD first if it is open.
+ Return newfd if successful, otherwise -1 and errno set.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
+# if @REPLACE_DUP2@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define dup2 rpl_dup2
+# endif
+_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
+_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
+# else
+# if !@HAVE_DUP2@
+_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
+# endif
+_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
+# endif
+_GL_CXXALIASWARN (dup2);
+#elif defined GNULIB_POSIXCHECK
+# undef dup2
+# if HAVE_RAW_DECL_DUP2
+_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
+ "use gnulib module dup2 for portability");
+# endif
+#endif
+
+
+#if @GNULIB_DUP3@
+/* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
+ specified flags.
+ The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+ and O_TEXT, O_BINARY (defined in "binary-io.h").
+ Close NEWFD first if it is open.
+ Return newfd if successful, otherwise -1 and errno set.
+ See the Linux man page at
+ <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
+# if @HAVE_DUP3@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define dup3 rpl_dup3
+# endif
+_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
+_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
+# else
+_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
+_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
+# endif
+_GL_CXXALIASWARN (dup3);
+#elif defined GNULIB_POSIXCHECK
+# undef dup3
+# if HAVE_RAW_DECL_DUP3
+_GL_WARN_ON_USE (dup3, "dup3 is unportable - "
+ "use gnulib module dup3 for portability");
+# endif
+#endif
+
+
+#if @GNULIB_ENVIRON@
+# if defined __CYGWIN__ && !defined __i386__
+/* The 'environ' variable is defined in a DLL. Therefore its declaration needs
+ the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
+ This leads to a link error on 64-bit Cygwin when the option
+ -Wl,--disable-auto-import is in use. */
+_GL_EXTERN_C __declspec(dllimport) char **environ;
+# endif
+# if !@HAVE_DECL_ENVIRON@
+/* Set of environment variables and values. An array of strings of the form
+ "VARIABLE=VALUE", terminated with a NULL. */
+# if defined __APPLE__ && defined __MACH__
+# include <TargetConditionals.h>
+# if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
+# define _GL_USE_CRT_EXTERNS
+# endif
+# endif
+# ifdef _GL_USE_CRT_EXTERNS
+# include <crt_externs.h>
+# define environ (*_NSGetEnviron ())
+# else
+# ifdef __cplusplus
+extern "C" {
+# endif
+extern char **environ;
+# ifdef __cplusplus
+}
+# endif
+# endif
+# endif
+#elif defined GNULIB_POSIXCHECK
+# if HAVE_RAW_DECL_ENVIRON
+_GL_UNISTD_INLINE char ***
+_GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
+ "use gnulib module environ for portability")
+rpl_environ (void)
+{
+ return &environ;
+}
+# undef environ
+# define environ (*rpl_environ ())
+# endif
+#endif
+
+
+#if @GNULIB_EUIDACCESS@
+/* Like access(), except that it uses the effective user id and group id of
+ the current process. */
+# if !@HAVE_EUIDACCESS@
+_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
+_GL_CXXALIASWARN (euidaccess);
+# if defined GNULIB_POSIXCHECK
+/* Like access(), this function is a security risk. */
+_GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
+ "use the gnulib module faccessat instead");
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef euidaccess
+# if HAVE_RAW_DECL_EUIDACCESS
+_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
+ "use gnulib module euidaccess for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FACCESSAT@
+# if @REPLACE_FACCESSAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef faccessat
+# define faccessat rpl_faccessat
+# endif
+_GL_FUNCDECL_RPL (faccessat, int,
+ (int fd, char const *name, int mode, int flag)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (faccessat, int,
+ (int fd, char const *name, int mode, int flag));
+# else
+# if !@HAVE_FACCESSAT@
+_GL_FUNCDECL_SYS (faccessat, int,
+ (int fd, char const *file, int mode, int flag)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (faccessat, int,
+ (int fd, char const *file, int mode, int flag));
+# endif
+_GL_CXXALIASWARN (faccessat);
+#elif defined GNULIB_POSIXCHECK
+# undef faccessat
+# if HAVE_RAW_DECL_FACCESSAT
+_GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
+ "use gnulib module faccessat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FCHDIR@
+/* Change the process' current working directory to the directory on which
+ the given file descriptor is open.
+ Return 0 if successful, otherwise -1 and errno set.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
+# if ! @HAVE_FCHDIR@
+_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
+
+/* Gnulib internal hooks needed to maintain the fchdir metadata. */
+_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
+ _GL_ARG_NONNULL ((2));
+_GL_EXTERN_C void _gl_unregister_fd (int fd);
+_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
+_GL_EXTERN_C const char *_gl_directory_name (int fd);
+
+# else
+# if !@HAVE_DECL_FCHDIR@
+_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
+# endif
+# endif
+_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
+_GL_CXXALIASWARN (fchdir);
+#elif defined GNULIB_POSIXCHECK
+# undef fchdir
+# if HAVE_RAW_DECL_FCHDIR
+_GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
+ "use gnulib module fchdir for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FCHOWNAT@
+# if @REPLACE_FCHOWNAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fchownat
+# define fchownat rpl_fchownat
+# endif
+_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
+ uid_t owner, gid_t group, int flag)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
+ uid_t owner, gid_t group, int flag));
+# else
+# if !@HAVE_FCHOWNAT@
+_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
+ uid_t owner, gid_t group, int flag)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
+ uid_t owner, gid_t group, int flag));
+# endif
+_GL_CXXALIASWARN (fchownat);
+#elif defined GNULIB_POSIXCHECK
+# undef fchownat
+# if HAVE_RAW_DECL_FCHOWNAT
+_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
+ "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FDATASYNC@
+/* Synchronize changes to a file.
+ Return 0 if successful, otherwise -1 and errno set.
+ See POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
+# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
+_GL_FUNCDECL_SYS (fdatasync, int, (int fd));
+# endif
+_GL_CXXALIAS_SYS (fdatasync, int, (int fd));
+_GL_CXXALIASWARN (fdatasync);
+#elif defined GNULIB_POSIXCHECK
+# undef fdatasync
+# if HAVE_RAW_DECL_FDATASYNC
+_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
+ "use gnulib module fdatasync for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FSYNC@
+/* Synchronize changes, including metadata, to a file.
+ Return 0 if successful, otherwise -1 and errno set.
+ See POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
+# if !@HAVE_FSYNC@
+_GL_FUNCDECL_SYS (fsync, int, (int fd));
+# endif
+_GL_CXXALIAS_SYS (fsync, int, (int fd));
+_GL_CXXALIASWARN (fsync);
+#elif defined GNULIB_POSIXCHECK
+# undef fsync
+# if HAVE_RAW_DECL_FSYNC
+_GL_WARN_ON_USE (fsync, "fsync is unportable - "
+ "use gnulib module fsync for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FTRUNCATE@
+/* Change the size of the file to which FD is opened to become equal to LENGTH.
+ Return 0 if successful, otherwise -1 and errno set.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
+# if @REPLACE_FTRUNCATE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ftruncate
+# define ftruncate rpl_ftruncate
+# endif
+_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
+_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
+# else
+# if !@HAVE_FTRUNCATE@
+_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
+# endif
+_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
+# endif
+_GL_CXXALIASWARN (ftruncate);
+#elif defined GNULIB_POSIXCHECK
+# undef ftruncate
+# if HAVE_RAW_DECL_FTRUNCATE
+_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
+ "use gnulib module ftruncate for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETCWD@
+/* Get the name of the current working directory, and put it in SIZE bytes
+ of BUF.
+ Return BUF if successful, or NULL if the directory couldn't be determined
+ or SIZE was too small.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
+ Additionally, the gnulib module 'getcwd' guarantees the following GNU
+ extension: If BUF is NULL, an array is allocated with 'malloc'; the array
+ is SIZE bytes long, unless SIZE == 0, in which case it is as big as
+ necessary. */
+# if @REPLACE_GETCWD@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define getcwd rpl_getcwd
+# endif
+_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
+_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
+# else
+/* Need to cast, because on mingw, the second parameter is
+ int size. */
+_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
+# endif
+_GL_CXXALIASWARN (getcwd);
+#elif defined GNULIB_POSIXCHECK
+# undef getcwd
+# if HAVE_RAW_DECL_GETCWD
+_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
+ "use gnulib module getcwd for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETDOMAINNAME@
+/* Return the NIS domain name of the machine.
+ WARNING! The NIS domain name is unrelated to the fully qualified host name
+ of the machine. It is also unrelated to email addresses.
+ WARNING! The NIS domain name is usually the empty string or "(none)" when
+ not using NIS.
+
+ Put up to LEN bytes of the NIS domain name into NAME.
+ Null terminate it if the name is shorter than LEN.
+ If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
+ Return 0 if successful, otherwise set errno and return -1. */
+# if @REPLACE_GETDOMAINNAME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getdomainname
+# define getdomainname rpl_getdomainname
+# endif
+_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
+# else
+# if !@HAVE_DECL_GETDOMAINNAME@
+_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
+# endif
+_GL_CXXALIASWARN (getdomainname);
+#elif defined GNULIB_POSIXCHECK
+# undef getdomainname
+# if HAVE_RAW_DECL_GETDOMAINNAME
+_GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
+ "use gnulib module getdomainname for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETDTABLESIZE@
+/* Return the maximum number of file descriptors in the current process.
+ In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
+# if @REPLACE_GETDTABLESIZE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getdtablesize
+# define getdtablesize rpl_getdtablesize
+# endif
+_GL_FUNCDECL_RPL (getdtablesize, int, (void));
+_GL_CXXALIAS_RPL (getdtablesize, int, (void));
+# else
+# if !@HAVE_GETDTABLESIZE@
+_GL_FUNCDECL_SYS (getdtablesize, int, (void));
+# endif
+_GL_CXXALIAS_SYS (getdtablesize, int, (void));
+# endif
+_GL_CXXALIASWARN (getdtablesize);
+#elif defined GNULIB_POSIXCHECK
+# undef getdtablesize
+# if HAVE_RAW_DECL_GETDTABLESIZE
+_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
+ "use gnulib module getdtablesize for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETGROUPS@
+/* Return the supplemental groups that the current process belongs to.
+ It is unspecified whether the effective group id is in the list.
+ If N is 0, return the group count; otherwise, N describes how many
+ entries are available in GROUPS. Return -1 and set errno if N is
+ not 0 and not large enough. Fails with ENOSYS on some systems. */
+# if @REPLACE_GETGROUPS@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getgroups
+# define getgroups rpl_getgroups
+# endif
+_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
+_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
+# else
+# if !@HAVE_GETGROUPS@
+_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
+# endif
+_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
+# endif
+_GL_CXXALIASWARN (getgroups);
+#elif defined GNULIB_POSIXCHECK
+# undef getgroups
+# if HAVE_RAW_DECL_GETGROUPS
+_GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
+ "use gnulib module getgroups for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETHOSTNAME@
+/* Return the standard host name of the machine.
+ WARNING! The host name may or may not be fully qualified.
+
+ Put up to LEN bytes of the host name into NAME.
+ Null terminate it if the name is shorter than LEN.
+ If the host name is longer than LEN, set errno = EINVAL and return -1.
+ Return 0 if successful, otherwise set errno and return -1. */
+# if @UNISTD_H_HAVE_WINSOCK2_H@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef gethostname
+# define gethostname rpl_gethostname
+# endif
+_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
+# else
+# if !@HAVE_GETHOSTNAME@
+_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
+ _GL_ARG_NONNULL ((1)));
+# endif
+/* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
+ parameter is
+ int len. */
+_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
+# endif
+_GL_CXXALIASWARN (gethostname);
+#elif @UNISTD_H_HAVE_WINSOCK2_H@
+# undef gethostname
+# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
+#elif defined GNULIB_POSIXCHECK
+# undef gethostname
+# if HAVE_RAW_DECL_GETHOSTNAME
+_GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
+ "use gnulib module gethostname for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETLOGIN@
+/* Returns the user's login name, or NULL if it cannot be found. Upon error,
+ returns NULL with errno set.
+
+ See <http://www.opengroup.org/susv3xsh/getlogin.html>.
+
+ Most programs don't need to use this function, because the information is
+ available through environment variables:
+ ${LOGNAME-$USER} on Unix platforms,
+ $USERNAME on native Windows platforms.
+ */
+# if !@HAVE_DECL_GETLOGIN@
+_GL_FUNCDECL_SYS (getlogin, char *, (void));
+# endif
+_GL_CXXALIAS_SYS (getlogin, char *, (void));
+_GL_CXXALIASWARN (getlogin);
+#elif defined GNULIB_POSIXCHECK
+# undef getlogin
+# if HAVE_RAW_DECL_GETLOGIN
+_GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
+ "use gnulib module getlogin for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETLOGIN_R@
+/* Copies the user's login name to NAME.
+ The array pointed to by NAME has room for SIZE bytes.
+
+ Returns 0 if successful. Upon error, an error number is returned, or -1 in
+ the case that the login name cannot be found but no specific error is
+ provided (this case is hopefully rare but is left open by the POSIX spec).
+
+ See <http://www.opengroup.org/susv3xsh/getlogin.html>.
+
+ Most programs don't need to use this function, because the information is
+ available through environment variables:
+ ${LOGNAME-$USER} on Unix platforms,
+ $USERNAME on native Windows platforms.
+ */
+# if @REPLACE_GETLOGIN_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define getlogin_r rpl_getlogin_r
+# endif
+_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
+# else
+# if !@HAVE_DECL_GETLOGIN_R@
+_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
+ _GL_ARG_NONNULL ((1)));
+# endif
+/* Need to cast, because on Solaris 10 systems, the second argument is
+ int size. */
+_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
+# endif
+_GL_CXXALIASWARN (getlogin_r);
+#elif defined GNULIB_POSIXCHECK
+# undef getlogin_r
+# if HAVE_RAW_DECL_GETLOGIN_R
+_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
+ "use gnulib module getlogin_r for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETPAGESIZE@
+# if @REPLACE_GETPAGESIZE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define getpagesize rpl_getpagesize
+# endif
+_GL_FUNCDECL_RPL (getpagesize, int, (void));
+_GL_CXXALIAS_RPL (getpagesize, int, (void));
+# else
+# if !@HAVE_GETPAGESIZE@
+# if !defined getpagesize
+/* This is for POSIX systems. */
+# if !defined _gl_getpagesize && defined _SC_PAGESIZE
+# if ! (defined __VMS && __VMS_VER < 70000000)
+# define _gl_getpagesize() sysconf (_SC_PAGESIZE)
+# endif
+# endif
+/* This is for older VMS. */
+# if !defined _gl_getpagesize && defined __VMS
+# ifdef __ALPHA
+# define _gl_getpagesize() 8192
+# else
+# define _gl_getpagesize() 512
+# endif
+# endif
+/* This is for BeOS. */
+# if !defined _gl_getpagesize && @HAVE_OS_H@
+# include <OS.h>
+# if defined B_PAGE_SIZE
+# define _gl_getpagesize() B_PAGE_SIZE
+# endif
+# endif
+/* This is for AmigaOS4.0. */
+# if !defined _gl_getpagesize && defined __amigaos4__
+# define _gl_getpagesize() 2048
+# endif
+/* This is for older Unix systems. */
+# if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
+# include <sys/param.h>
+# ifdef EXEC_PAGESIZE
+# define _gl_getpagesize() EXEC_PAGESIZE
+# else
+# ifdef NBPG
+# ifndef CLSIZE
+# define CLSIZE 1
+# endif
+# define _gl_getpagesize() (NBPG * CLSIZE)
+# else
+# ifdef NBPC
+# define _gl_getpagesize() NBPC
+# endif
+# endif
+# endif
+# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define getpagesize() _gl_getpagesize ()
+# else
+# if !GNULIB_defined_getpagesize_function
+_GL_UNISTD_INLINE int
+getpagesize ()
+{
+ return _gl_getpagesize ();
+}
+# define GNULIB_defined_getpagesize_function 1
+# endif
+# endif
+# endif
+# endif
+/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
+_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
+# endif
+# if @HAVE_DECL_GETPAGESIZE@
+_GL_CXXALIASWARN (getpagesize);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getpagesize
+# if HAVE_RAW_DECL_GETPAGESIZE
+_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
+ "use gnulib module getpagesize for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETPASS@
+/* Function getpass() from module 'getpass':
+ Read a password from /dev/tty or stdin.
+ Function getpass() from module 'getpass-gnu':
+ Read a password of arbitrary length from /dev/tty or stdin. */
+# if @REPLACE_GETPASS@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getpass
+# define getpass rpl_getpass
+# endif
+_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
+# else
+# if !@HAVE_GETPASS@
+_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
+# endif
+_GL_CXXALIASWARN (getpass);
+#elif defined GNULIB_POSIXCHECK
+# undef getpass
+# if HAVE_RAW_DECL_GETPASS
+_GL_WARN_ON_USE (getpass, "getpass is unportable - "
+ "use gnulib module getpass or getpass-gnu for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETUSERSHELL@
+/* Return the next valid login shell on the system, or NULL when the end of
+ the list has been reached. */
+# if !@HAVE_DECL_GETUSERSHELL@
+_GL_FUNCDECL_SYS (getusershell, char *, (void));
+# endif
+_GL_CXXALIAS_SYS (getusershell, char *, (void));
+_GL_CXXALIASWARN (getusershell);
+#elif defined GNULIB_POSIXCHECK
+# undef getusershell
+# if HAVE_RAW_DECL_GETUSERSHELL
+_GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
+ "use gnulib module getusershell for portability");
+# endif
+#endif
+
+#if @GNULIB_GETUSERSHELL@
+/* Rewind to pointer that is advanced at each getusershell() call. */
+# if !@HAVE_DECL_GETUSERSHELL@
+_GL_FUNCDECL_SYS (setusershell, void, (void));
+# endif
+_GL_CXXALIAS_SYS (setusershell, void, (void));
+_GL_CXXALIASWARN (setusershell);
+#elif defined GNULIB_POSIXCHECK
+# undef setusershell
+# if HAVE_RAW_DECL_SETUSERSHELL
+_GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
+ "use gnulib module getusershell for portability");
+# endif
+#endif
+
+#if @GNULIB_GETUSERSHELL@
+/* Free the pointer that is advanced at each getusershell() call and
+ associated resources. */
+# if !@HAVE_DECL_GETUSERSHELL@
+_GL_FUNCDECL_SYS (endusershell, void, (void));
+# endif
+_GL_CXXALIAS_SYS (endusershell, void, (void));
+_GL_CXXALIASWARN (endusershell);
+#elif defined GNULIB_POSIXCHECK
+# undef endusershell
+# if HAVE_RAW_DECL_ENDUSERSHELL
+_GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
+ "use gnulib module getusershell for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GROUP_MEMBER@
+/* Determine whether group id is in calling user's group list. */
+# if !@HAVE_GROUP_MEMBER@
+_GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
+# endif
+_GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
+_GL_CXXALIASWARN (group_member);
+#elif defined GNULIB_POSIXCHECK
+# undef group_member
+# if HAVE_RAW_DECL_GROUP_MEMBER
+_GL_WARN_ON_USE (group_member, "group_member is unportable - "
+ "use gnulib module group-member for portability");
+# endif
+#endif
+
+
+#if @GNULIB_ISATTY@
+# if @REPLACE_ISATTY@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef isatty
+# define isatty rpl_isatty
+# endif
+_GL_FUNCDECL_RPL (isatty, int, (int fd));
+_GL_CXXALIAS_RPL (isatty, int, (int fd));
+# else
+_GL_CXXALIAS_SYS (isatty, int, (int fd));
+# endif
+_GL_CXXALIASWARN (isatty);
+#elif defined GNULIB_POSIXCHECK
+# undef isatty
+# if HAVE_RAW_DECL_ISATTY
+_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
+ "use gnulib module isatty for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LCHOWN@
+/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
+ to GID (if GID is not -1). Do not follow symbolic links.
+ Return 0 if successful, otherwise -1 and errno set.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
+# if @REPLACE_LCHOWN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef lchown
+# define lchown rpl_lchown
+# endif
+_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
+# else
+# if !@HAVE_LCHOWN@
+_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
+# endif
+_GL_CXXALIASWARN (lchown);
+#elif defined GNULIB_POSIXCHECK
+# undef lchown
+# if HAVE_RAW_DECL_LCHOWN
+_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
+ "use gnulib module lchown for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LINK@
+/* Create a new hard link for an existing file.
+ Return 0 if successful, otherwise -1 and errno set.
+ See POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
+# if @REPLACE_LINK@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define link rpl_link
+# endif
+_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
+# else
+# if !@HAVE_LINK@
+_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
+# endif
+_GL_CXXALIASWARN (link);
+#elif defined GNULIB_POSIXCHECK
+# undef link
+# if HAVE_RAW_DECL_LINK
+_GL_WARN_ON_USE (link, "link is unportable - "
+ "use gnulib module link for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LINKAT@
+/* Create a new hard link for an existing file, relative to two
+ directories. FLAG controls whether symlinks are followed.
+ Return 0 if successful, otherwise -1 and errno set. */
+# if @REPLACE_LINKAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef linkat
+# define linkat rpl_linkat
+# endif
+_GL_FUNCDECL_RPL (linkat, int,
+ (int fd1, const char *path1, int fd2, const char *path2,
+ int flag)
+ _GL_ARG_NONNULL ((2, 4)));
+_GL_CXXALIAS_RPL (linkat, int,
+ (int fd1, const char *path1, int fd2, const char *path2,
+ int flag));
+# else
+# if !@HAVE_LINKAT@
+_GL_FUNCDECL_SYS (linkat, int,
+ (int fd1, const char *path1, int fd2, const char *path2,
+ int flag)
+ _GL_ARG_NONNULL ((2, 4)));
+# endif
+_GL_CXXALIAS_SYS (linkat, int,
+ (int fd1, const char *path1, int fd2, const char *path2,
+ int flag));
+# endif
+_GL_CXXALIASWARN (linkat);
+#elif defined GNULIB_POSIXCHECK
+# undef linkat
+# if HAVE_RAW_DECL_LINKAT
+_GL_WARN_ON_USE (linkat, "linkat is unportable - "
+ "use gnulib module linkat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LSEEK@
+/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
+ Return the new offset if successful, otherwise -1 and errno set.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
+# if @REPLACE_LSEEK@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define lseek rpl_lseek
+# endif
+_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
+_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
+# else
+_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
+# endif
+_GL_CXXALIASWARN (lseek);
+#elif defined GNULIB_POSIXCHECK
+# undef lseek
+# if HAVE_RAW_DECL_LSEEK
+_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
+ "systems - use gnulib module lseek for portability");
+# endif
+#endif
+
+
+#if @GNULIB_PIPE@
+/* Create a pipe, defaulting to O_BINARY mode.
+ Store the read-end as fd[0] and the write-end as fd[1].
+ Return 0 upon success, or -1 with errno set upon failure. */
+# if !@HAVE_PIPE@
+_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
+_GL_CXXALIASWARN (pipe);
+#elif defined GNULIB_POSIXCHECK
+# undef pipe
+# if HAVE_RAW_DECL_PIPE
+_GL_WARN_ON_USE (pipe, "pipe is unportable - "
+ "use gnulib module pipe-posix for portability");
+# endif
+#endif
+
+
+#if @GNULIB_PIPE2@
+/* Create a pipe, applying the given flags when opening the read-end of the
+ pipe and the write-end of the pipe.
+ The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+ and O_TEXT, O_BINARY (defined in "binary-io.h").
+ Store the read-end as fd[0] and the write-end as fd[1].
+ Return 0 upon success, or -1 with errno set upon failure.
+ See also the Linux man page at
+ <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
+# if @HAVE_PIPE2@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define pipe2 rpl_pipe2
+# endif
+_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
+# else
+_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
+# endif
+_GL_CXXALIASWARN (pipe2);
+#elif defined GNULIB_POSIXCHECK
+# undef pipe2
+# if HAVE_RAW_DECL_PIPE2
+_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
+ "use gnulib module pipe2 for portability");
+# endif
+#endif
+
+
+#if @GNULIB_PREAD@
+/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
+ Return the number of bytes placed into BUF if successful, otherwise
+ set errno and return -1. 0 indicates EOF.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
+# if @REPLACE_PREAD@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef pread
+# define pread rpl_pread
+# endif
+_GL_FUNCDECL_RPL (pread, ssize_t,
+ (int fd, void *buf, size_t bufsize, off_t offset)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (pread, ssize_t,
+ (int fd, void *buf, size_t bufsize, off_t offset));
+# else
+# if !@HAVE_PREAD@
+_GL_FUNCDECL_SYS (pread, ssize_t,
+ (int fd, void *buf, size_t bufsize, off_t offset)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (pread, ssize_t,
+ (int fd, void *buf, size_t bufsize, off_t offset));
+# endif
+_GL_CXXALIASWARN (pread);
+#elif defined GNULIB_POSIXCHECK
+# undef pread
+# if HAVE_RAW_DECL_PREAD
+_GL_WARN_ON_USE (pread, "pread is unportable - "
+ "use gnulib module pread for portability");
+# endif
+#endif
+
+
+#if @GNULIB_PWRITE@
+/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
+ Return the number of bytes written if successful, otherwise
+ set errno and return -1. 0 indicates nothing written. See the
+ POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
+# if @REPLACE_PWRITE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef pwrite
+# define pwrite rpl_pwrite
+# endif
+_GL_FUNCDECL_RPL (pwrite, ssize_t,
+ (int fd, const void *buf, size_t bufsize, off_t offset)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (pwrite, ssize_t,
+ (int fd, const void *buf, size_t bufsize, off_t offset));
+# else
+# if !@HAVE_PWRITE@
+_GL_FUNCDECL_SYS (pwrite, ssize_t,
+ (int fd, const void *buf, size_t bufsize, off_t offset)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (pwrite, ssize_t,
+ (int fd, const void *buf, size_t bufsize, off_t offset));
+# endif
+_GL_CXXALIASWARN (pwrite);
+#elif defined GNULIB_POSIXCHECK
+# undef pwrite
+# if HAVE_RAW_DECL_PWRITE
+_GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
+ "use gnulib module pwrite for portability");
+# endif
+#endif
+
+
+#if @GNULIB_READ@
+/* Read up to COUNT bytes from file descriptor FD into the buffer starting
+ at BUF. See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
+# if @REPLACE_READ@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef read
+# define read rpl_read
+# endif
+_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
+# else
+/* Need to cast, because on mingw, the third parameter is
+ unsigned int count
+ and the return type is 'int'. */
+_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
+# endif
+_GL_CXXALIASWARN (read);
+#endif
+
+
+#if @GNULIB_READLINK@
+/* Read the contents of the symbolic link FILE and place the first BUFSIZE
+ bytes of it into BUF. Return the number of bytes placed into BUF if
+ successful, otherwise -1 and errno set.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
+# if @REPLACE_READLINK@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define readlink rpl_readlink
+# endif
+_GL_FUNCDECL_RPL (readlink, ssize_t,
+ (const char *file, char *buf, size_t bufsize)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (readlink, ssize_t,
+ (const char *file, char *buf, size_t bufsize));
+# else
+# if !@HAVE_READLINK@
+_GL_FUNCDECL_SYS (readlink, ssize_t,
+ (const char *file, char *buf, size_t bufsize)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (readlink, ssize_t,
+ (const char *file, char *buf, size_t bufsize));
+# endif
+_GL_CXXALIASWARN (readlink);
+#elif defined GNULIB_POSIXCHECK
+# undef readlink
+# if HAVE_RAW_DECL_READLINK
+_GL_WARN_ON_USE (readlink, "readlink is unportable - "
+ "use gnulib module readlink for portability");
+# endif
+#endif
+
+
+#if @GNULIB_READLINKAT@
+# if @REPLACE_READLINKAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define readlinkat rpl_readlinkat
+# endif
+_GL_FUNCDECL_RPL (readlinkat, ssize_t,
+ (int fd, char const *file, char *buf, size_t len)
+ _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (readlinkat, ssize_t,
+ (int fd, char const *file, char *buf, size_t len));
+# else
+# if !@HAVE_READLINKAT@
+_GL_FUNCDECL_SYS (readlinkat, ssize_t,
+ (int fd, char const *file, char *buf, size_t len)
+ _GL_ARG_NONNULL ((2, 3)));
+# endif
+_GL_CXXALIAS_SYS (readlinkat, ssize_t,
+ (int fd, char const *file, char *buf, size_t len));
+# endif
+_GL_CXXALIASWARN (readlinkat);
+#elif defined GNULIB_POSIXCHECK
+# undef readlinkat
+# if HAVE_RAW_DECL_READLINKAT
+_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
+ "use gnulib module readlinkat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_RMDIR@
+/* Remove the directory DIR. */
+# if @REPLACE_RMDIR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define rmdir rpl_rmdir
+# endif
+_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
+# else
+_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
+# endif
+_GL_CXXALIASWARN (rmdir);
+#elif defined GNULIB_POSIXCHECK
+# undef rmdir
+# if HAVE_RAW_DECL_RMDIR
+_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
+ "use gnulib module rmdir for portability");
+# endif
+#endif
+
+
+#if @GNULIB_SETHOSTNAME@
+/* Set the host name of the machine.
+ The host name may or may not be fully qualified.
+
+ Put LEN bytes of NAME into the host name.
+ Return 0 if successful, otherwise, set errno and return -1.
+
+ Platforms with no ability to set the hostname return -1 and set
+ errno = ENOSYS. */
+# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
+_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
+ _GL_ARG_NONNULL ((1)));
+# endif
+/* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
+ and FreeBSD 6.4 the second parameter is int. On Solaris 11
+ 2011-10, the first parameter is not const. */
+_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
+_GL_CXXALIASWARN (sethostname);
+#elif defined GNULIB_POSIXCHECK
+# undef sethostname
+# if HAVE_RAW_DECL_SETHOSTNAME
+_GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
+ "use gnulib module sethostname for portability");
+# endif
+#endif
+
+
+#if @GNULIB_SLEEP@
+/* Pause the execution of the current thread for N seconds.
+ Returns the number of seconds left to sleep.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
+# if @REPLACE_SLEEP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef sleep
+# define sleep rpl_sleep
+# endif
+_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
+_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
+# else
+# if !@HAVE_SLEEP@
+_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
+# endif
+_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
+# endif
+_GL_CXXALIASWARN (sleep);
+#elif defined GNULIB_POSIXCHECK
+# undef sleep
+# if HAVE_RAW_DECL_SLEEP
+_GL_WARN_ON_USE (sleep, "sleep is unportable - "
+ "use gnulib module sleep for portability");
+# endif
+#endif
+
+
+#if @GNULIB_SYMLINK@
+# if @REPLACE_SYMLINK@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef symlink
+# define symlink rpl_symlink
+# endif
+_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
+# else
+# if !@HAVE_SYMLINK@
+_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
+# endif
+_GL_CXXALIASWARN (symlink);
+#elif defined GNULIB_POSIXCHECK
+# undef symlink
+# if HAVE_RAW_DECL_SYMLINK
+_GL_WARN_ON_USE (symlink, "symlink is not portable - "
+ "use gnulib module symlink for portability");
+# endif
+#endif
+
+
+#if @GNULIB_SYMLINKAT@
+# if @REPLACE_SYMLINKAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef symlinkat
+# define symlinkat rpl_symlinkat
+# endif
+_GL_FUNCDECL_RPL (symlinkat, int,
+ (char const *contents, int fd, char const *file)
+ _GL_ARG_NONNULL ((1, 3)));
+_GL_CXXALIAS_RPL (symlinkat, int,
+ (char const *contents, int fd, char const *file));
+# else
+# if !@HAVE_SYMLINKAT@
+_GL_FUNCDECL_SYS (symlinkat, int,
+ (char const *contents, int fd, char const *file)
+ _GL_ARG_NONNULL ((1, 3)));
+# endif
+_GL_CXXALIAS_SYS (symlinkat, int,
+ (char const *contents, int fd, char const *file));
+# endif
+_GL_CXXALIASWARN (symlinkat);
+#elif defined GNULIB_POSIXCHECK
+# undef symlinkat
+# if HAVE_RAW_DECL_SYMLINKAT
+_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
+ "use gnulib module symlinkat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_TRUNCATE@
+/* Change the size of the file designated by FILENAME to become equal to LENGTH.
+ Return 0 if successful, otherwise -1 and errno set.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
+# if @REPLACE_TRUNCATE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef truncate
+# define truncate rpl_truncate
+# endif
+_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
+# else
+# if !@HAVE_DECL_TRUNCATE@
+_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
+# endif
+_GL_CXXALIASWARN (truncate);
+#elif defined GNULIB_POSIXCHECK
+# undef truncate
+# if HAVE_RAW_DECL_TRUNCATE
+_GL_WARN_ON_USE (truncate, "truncate is unportable - "
+ "use gnulib module truncate for portability");
+# endif
+#endif
+
+
+#if @GNULIB_TTYNAME_R@
+/* Store at most BUFLEN characters of the pathname of the terminal FD is
+ open on in BUF. Return 0 on success, otherwise an error number. */
+# if @REPLACE_TTYNAME_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ttyname_r
+# define ttyname_r rpl_ttyname_r
+# endif
+_GL_FUNCDECL_RPL (ttyname_r, int,
+ (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (ttyname_r, int,
+ (int fd, char *buf, size_t buflen));
+# else
+# if !@HAVE_DECL_TTYNAME_R@
+_GL_FUNCDECL_SYS (ttyname_r, int,
+ (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (ttyname_r, int,
+ (int fd, char *buf, size_t buflen));
+# endif
+_GL_CXXALIASWARN (ttyname_r);
+#elif defined GNULIB_POSIXCHECK
+# undef ttyname_r
+# if HAVE_RAW_DECL_TTYNAME_R
+_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
+ "use gnulib module ttyname_r for portability");
+# endif
+#endif
+
+
+#if @GNULIB_UNLINK@
+# if @REPLACE_UNLINK@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef unlink
+# define unlink rpl_unlink
+# endif
+_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (unlink, int, (char const *file));
+# else
+_GL_CXXALIAS_SYS (unlink, int, (char const *file));
+# endif
+_GL_CXXALIASWARN (unlink);
+#elif defined GNULIB_POSIXCHECK
+# undef unlink
+# if HAVE_RAW_DECL_UNLINK
+_GL_WARN_ON_USE (unlink, "unlink is not portable - "
+ "use gnulib module unlink for portability");
+# endif
+#endif
+
+
+#if @GNULIB_UNLINKAT@
+# if @REPLACE_UNLINKAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef unlinkat
+# define unlinkat rpl_unlinkat
+# endif
+_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
+# else
+# if !@HAVE_UNLINKAT@
+_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
+# endif
+_GL_CXXALIASWARN (unlinkat);
+#elif defined GNULIB_POSIXCHECK
+# undef unlinkat
+# if HAVE_RAW_DECL_UNLINKAT
+_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
+ "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_USLEEP@
+/* Pause the execution of the current thread for N microseconds.
+ Returns 0 on completion, or -1 on range error.
+ See the POSIX:2001 specification
+ <http://www.opengroup.org/susv3xsh/usleep.html>. */
+# if @REPLACE_USLEEP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef usleep
+# define usleep rpl_usleep
+# endif
+_GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
+_GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
+# else
+# if !@HAVE_USLEEP@
+_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
+# endif
+_GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
+# endif
+_GL_CXXALIASWARN (usleep);
+#elif defined GNULIB_POSIXCHECK
+# undef usleep
+# if HAVE_RAW_DECL_USLEEP
+_GL_WARN_ON_USE (usleep, "usleep is unportable - "
+ "use gnulib module usleep for portability");
+# endif
+#endif
+
+
+#if @GNULIB_WRITE@
+/* Write up to COUNT bytes starting at BUF to file descriptor FD.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
+# if @REPLACE_WRITE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef write
+# define write rpl_write
+# endif
+_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
+# else
+/* Need to cast, because on mingw, the third parameter is
+ unsigned int count
+ and the return type is 'int'. */
+_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
+# endif
+_GL_CXXALIASWARN (write);
+#endif
+
+_GL_INLINE_HEADER_END
+
+#endif /* _@GUARD_PREFIX@_UNISTD_H */
+#endif /* _GL_INCLUDING_UNISTD_H */
+#endif /* _@GUARD_PREFIX@_UNISTD_H */
diff --git a/grub-core/lib/gnulib/unitypes.in.h b/grub-core/lib/gnulib/unitypes.in.h
new file mode 100644
index 0000000..631654b
--- /dev/null
+++ b/grub-core/lib/gnulib/unitypes.in.h
@@ -0,0 +1,46 @@
+/* Elementary types and macros for the GNU UniString library.
+ Copyright (C) 2002, 2005-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _UNITYPES_H
+#define _UNITYPES_H
+
+/* Get uint8_t, uint16_t, uint32_t. */
+#include <stdint.h>
+
+/* Type representing a Unicode character. */
+typedef uint32_t ucs4_t;
+
+/* Attribute of a function whose result depends only on the arguments
+ (not pointers!) and which has no side effects. */
+#ifndef _UC_ATTRIBUTE_CONST
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
+# define _UC_ATTRIBUTE_CONST __attribute__ ((__const__))
+# else
+# define _UC_ATTRIBUTE_CONST
+# endif
+#endif
+
+/* Attribute of a function whose result depends only on the arguments
+ (possibly pointers) and global memory, and which has no side effects. */
+#ifndef _UC_ATTRIBUTE_PURE
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define _UC_ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+# define _UC_ATTRIBUTE_PURE
+# endif
+#endif
+
+#endif /* _UNITYPES_H */
diff --git a/grub-core/lib/gnulib/uniwidth.in.h b/grub-core/lib/gnulib/uniwidth.in.h
new file mode 100644
index 0000000..80c5eea
--- /dev/null
+++ b/grub-core/lib/gnulib/uniwidth.in.h
@@ -0,0 +1,72 @@
+/* Display width functions.
+ Copyright (C) 2001-2002, 2005, 2007, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _UNIWIDTH_H
+#define _UNIWIDTH_H
+
+#include "unitypes.h"
+
+/* Get size_t. */
+#include <stddef.h>
+
+/* Get locale_charset() declaration. */
+#include "localcharset.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Display width. */
+
+/* These functions are locale dependent. The encoding argument identifies
+ the encoding (e.g. "ISO-8859-2" for Polish). */
+
+/* Determine number of column positions required for UC. */
+extern int
+ uc_width (ucs4_t uc, const char *encoding)
+ _UC_ATTRIBUTE_PURE;
+
+/* Determine number of column positions required for first N units
+ (or fewer if S ends before this) in S. */
+extern int
+ u8_width (const uint8_t *s, size_t n, const char *encoding)
+ _UC_ATTRIBUTE_PURE;
+extern int
+ u16_width (const uint16_t *s, size_t n, const char *encoding)
+ _UC_ATTRIBUTE_PURE;
+extern int
+ u32_width (const uint32_t *s, size_t n, const char *encoding)
+ _UC_ATTRIBUTE_PURE;
+
+/* Determine number of column positions required for S. */
+extern int
+ u8_strwidth (const uint8_t *s, const char *encoding)
+ _UC_ATTRIBUTE_PURE;
+extern int
+ u16_strwidth (const uint16_t *s, const char *encoding)
+ _UC_ATTRIBUTE_PURE;
+extern int
+ u32_strwidth (const uint32_t *s, const char *encoding)
+ _UC_ATTRIBUTE_PURE;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _UNIWIDTH_H */
diff --git a/grub-core/lib/gnulib/uniwidth/cjk.h b/grub-core/lib/gnulib/uniwidth/cjk.h
new file mode 100644
index 0000000..9870422
--- /dev/null
+++ b/grub-core/lib/gnulib/uniwidth/cjk.h
@@ -0,0 +1,37 @@
+/* Test for CJK encoding.
+ Copyright (C) 2001-2002, 2005-2007, 2009-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2002.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include "streq.h"
+
+static int
+is_cjk_encoding (const char *encoding)
+{
+ if (0
+ /* Legacy Japanese encodings */
+ || STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)
+ /* Legacy Chinese encodings */
+ || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
+ || STREQ_OPT (encoding, "GBK", 'G', 'B', 'K', 0, 0, 0, 0, 0, 0)
+ || STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)
+ || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)
+ /* Legacy Korean encodings */
+ || STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+ || STREQ_OPT (encoding, "CP949", 'C', 'P', '9', '4', '9', 0, 0, 0, 0)
+ || STREQ_OPT (encoding, "JOHAB", 'J', 'O', 'H', 'A', 'B', 0, 0, 0, 0))
+ return 1;
+ return 0;
+}
diff --git a/grub-core/lib/gnulib/uniwidth/width.c b/grub-core/lib/gnulib/uniwidth/width.c
new file mode 100644
index 0000000..a7f59b1
--- /dev/null
+++ b/grub-core/lib/gnulib/uniwidth/width.c
@@ -0,0 +1,468 @@
+/* Determine display width of Unicode character.
+ Copyright (C) 2001-2002, 2006-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2002.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "uniwidth.h"
+
+#include "cjk.h"
+
+/*
+ * Non-spacing attribute table.
+ * Consists of:
+ * - Non-spacing characters; generated from PropList.txt or
+ * "grep '^[^;]*;[^;]*;[^;]*;[^;]*;NSM;' UnicodeData.txt"
+ * - Format control characters; generated from
+ * "grep '^[^;]*;[^;]*;Cf;' UnicodeData.txt"
+ * - Zero width characters; generated from
+ * "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt"
+ */
+static const unsigned char nonspacing_table_data[38*64] = {
+ /* 0x0000-0x01ff */
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0000-0x003f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x0040-0x007f */
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x20, 0x00, 0x00, /* 0x0080-0x00bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00c0-0x00ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0100-0x013f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0140-0x017f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0180-0x01bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x01c0-0x01ff */
+ /* 0x0200-0x03ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0200-0x023f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0240-0x027f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0280-0x02bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x02c0-0x02ff */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x0300-0x033f */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, /* 0x0340-0x037f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0380-0x03bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x03c0-0x03ff */
+ /* 0x0400-0x05ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0400-0x043f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0440-0x047f */
+ 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0480-0x04bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04c0-0x04ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0500-0x053f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0540-0x057f */
+ 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xbf, /* 0x0580-0x05bf */
+ 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x05c0-0x05ff */
+ /* 0x0600-0x07ff */
+ 0x3f, 0x00, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, /* 0x0600-0x063f */
+ 0x00, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x01, 0x00, /* 0x0640-0x067f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0680-0x06bf */
+ 0x00, 0x00, 0xc0, 0xbf, 0x9f, 0x3d, 0x00, 0x00, /* 0x06c0-0x06ff */
+ 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x0700-0x073f */
+ 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0740-0x077f */
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, 0x00, /* 0x0780-0x07bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x07c0-0x07ff */
+ /* 0x0800-0x09ff */
+ 0x00, 0x00, 0xc0, 0xfb, 0xef, 0x3e, 0x00, 0x00, /* 0x0800-0x083f */
+ 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, /* 0x0840-0x087f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0880-0x08bf */
+ 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x08c0-0x08ff */
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, /* 0x0900-0x093f */
+ 0xfe, 0x21, 0xfe, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0940-0x097f */
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0980-0x09bf */
+ 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x09c0-0x09ff */
+ /* 0x0a00-0x0bff */
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a00-0x0a3f */
+ 0x86, 0x39, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, /* 0x0a40-0x0a7f */
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a80-0x0abf */
+ 0xbe, 0x21, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0ac0-0x0aff */
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, /* 0x0b00-0x0b3f */
+ 0x1e, 0x20, 0x40, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0b40-0x0b7f */
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0b80-0x0bbf */
+ 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0bc0-0x0bff */
+ /* 0x0c00-0x0dff */
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, /* 0x0c00-0x0c3f */
+ 0xc1, 0x3d, 0x60, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0c40-0x0c7f */
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0c80-0x0cbf */
+ 0x00, 0x30, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0cc0-0x0cff */
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d00-0x0d3f */
+ 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0d40-0x0d7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d80-0x0dbf */
+ 0x00, 0x04, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0dc0-0x0dff */
+ /* 0x0e00-0x0fff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x07, /* 0x0e00-0x0e3f */
+ 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0e40-0x0e7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x1b, /* 0x0e80-0x0ebf */
+ 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0ec0-0x0eff */
+ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xa0, 0x02, /* 0x0f00-0x0f3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, /* 0x0f40-0x0f7f */
+ 0xdf, 0xe0, 0xff, 0xfe, 0xff, 0xff, 0xff, 0x1f, /* 0x0f80-0x0fbf */
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0fc0-0x0fff */
+ /* 0x1000-0x11ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfd, 0x66, /* 0x1000-0x103f */
+ 0x00, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x1e, 0x00, /* 0x1040-0x107f */
+ 0x64, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x1080-0x10bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c0-0x10ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1100-0x113f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1140-0x117f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1180-0x11bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11c0-0x11ff */
+ /* 0x1200-0x13ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1200-0x123f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1240-0x127f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1280-0x12bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x12c0-0x12ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1300-0x133f */
+ 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, /* 0x1340-0x137f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1380-0x13bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13c0-0x13ff */
+ /* 0x1600-0x17ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1600-0x163f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1640-0x167f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1680-0x16bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16c0-0x16ff */
+ 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, /* 0x1700-0x173f */
+ 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, /* 0x1740-0x177f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x3f, /* 0x1780-0x17bf */
+ 0x40, 0xfe, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x17c0-0x17ff */
+ /* 0x1800-0x19ff */
+ 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1800-0x183f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1840-0x187f */
+ 0x60, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x1880-0x18bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18c0-0x18ff */
+ 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x04, 0x0e, /* 0x1900-0x193f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1940-0x197f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1980-0x19bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x19c0-0x19ff */
+ /* 0x1a00-0x1bff */
+ 0x00, 0x00, 0x80, 0x09, 0x00, 0x00, 0x00, 0x00, /* 0x1a00-0x1a3f */
+ 0x00, 0x00, 0x40, 0x7f, 0xe5, 0x1f, 0xf8, 0x9f, /* 0x1a40-0x1a7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, /* 0x1a80-0x1abf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ac0-0x1aff */
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x17, /* 0x1b00-0x1b3f */
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x1b40-0x1b7f */
+ 0x03, 0x00, 0x00, 0x00, 0x3c, 0x3b, 0x00, 0x00, /* 0x1b80-0x1bbf */
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0xa3, 0x03, 0x00, /* 0x1bc0-0x1bff */
+ /* 0x1c00-0x1dff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xcf, 0x00, /* 0x1c00-0x1c3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c40-0x1c7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c80-0x1cbf */
+ 0x00, 0x00, 0xf7, 0xff, 0xfd, 0x21, 0x10, 0x03, /* 0x1cc0-0x1cff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d00-0x1d3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d40-0x1d7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d80-0x1dbf */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf8, /* 0x1dc0-0x1dff */
+ /* 0x2000-0x21ff */
+ 0x00, 0xf8, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, /* 0x2000-0x203f */
+ 0x00, 0x00, 0x00, 0x00, 0xdf, 0xff, 0x00, 0x00, /* 0x2040-0x207f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2080-0x20bf */
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, /* 0x20c0-0x20ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2100-0x213f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2140-0x217f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2180-0x21bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x21c0-0x21ff */
+ /* 0x2c00-0x2dff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c00-0x2c3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c40-0x2c7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c80-0x2cbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, /* 0x2cc0-0x2cff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d00-0x2d3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x2d40-0x2d7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d80-0x2dbf */
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x2dc0-0x2dff */
+ /* 0x3000-0x31ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x3000-0x303f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3040-0x307f */
+ 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, /* 0x3080-0x30bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30c0-0x30ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3100-0x313f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3140-0x317f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3180-0x31bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x31c0-0x31ff */
+ /* 0xa600-0xa7ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa600-0xa63f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf7, 0x3f, /* 0xa640-0xa67f */
+ 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, /* 0xa680-0xa6bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, /* 0xa6c0-0xa6ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa700-0xa73f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa740-0xa77f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa780-0xa7bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa7c0-0xa7ff */
+ /* 0xa800-0xa9ff */
+ 0x44, 0x08, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0xa800-0xa83f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa840-0xa87f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa880-0xa8bf */
+ 0x30, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, /* 0xa8c0-0xa8ff */
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, /* 0xa900-0xa93f */
+ 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa940-0xa97f */
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x13, /* 0xa980-0xa9bf */
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, /* 0xa9c0-0xa9ff */
+ /* 0xaa00-0xabff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x66, 0x00, /* 0xaa00-0xaa3f */
+ 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0xaa40-0xaa7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0xc1, /* 0xaa80-0xaabf */
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x30, 0x40, 0x00, /* 0xaac0-0xaaff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab00-0xab3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab40-0xab7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab80-0xabbf */
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x00, 0x00, /* 0xabc0-0xabff */
+ /* 0xfa00-0xfbff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa00-0xfa3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa40-0xfa7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa80-0xfabf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfac0-0xfaff */
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, /* 0xfb00-0xfb3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb40-0xfb7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb80-0xfbbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfbc0-0xfbff */
+ /* 0xfe00-0xffff */
+ 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, /* 0xfe00-0xfe3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe40-0xfe7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe80-0xfebf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0xfec0-0xfeff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff00-0xff3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff40-0xff7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff80-0xffbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, /* 0xffc0-0xffff */
+ /* 0x10000-0x101ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10000-0x1003f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10040-0x1007f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10080-0x100bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x100c0-0x100ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10100-0x1013f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10140-0x1017f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10180-0x101bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, /* 0x101c0-0x101ff */
+ /* 0x10200-0x103ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10200-0x1023f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10240-0x1027f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10280-0x102bf */
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, /* 0x102c0-0x102ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10300-0x1033f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, /* 0x10340-0x1037f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10380-0x103bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x103c0-0x103ff */
+ /* 0x10a00-0x10bff */
+ 0x6e, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, /* 0x10a00-0x10a3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a40-0x10a7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a80-0x10abf */
+ 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0x10ac0-0x10aff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b00-0x10b3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b40-0x10b7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b80-0x10bbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10bc0-0x10bff */
+ /* 0x11000-0x111ff */
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11000-0x1103f */
+ 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x11040-0x1107f */
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x26, /* 0x11080-0x110bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x110c0-0x110ff */
+ 0x07, 0x00, 0x00, 0x00, 0x80, 0xef, 0x1f, 0x00, /* 0x11100-0x1113f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, /* 0x11140-0x1117f */
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x7f, /* 0x11180-0x111bf */
+ 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x111c0-0x111ff */
+ /* 0x11200-0x113ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xd3, 0x40, /* 0x11200-0x1123f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11240-0x1127f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11280-0x112bf */
+ 0x00, 0x00, 0x00, 0x80, 0xf8, 0x07, 0x00, 0x00, /* 0x112c0-0x112ff */
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x11300-0x1133f */
+ 0x01, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x1f, 0x00, /* 0x11340-0x1137f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11380-0x113bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x113c0-0x113ff */
+ /* 0x11400-0x115ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11400-0x1143f */
+ 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11440-0x1147f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x85, /* 0x11480-0x114bf */
+ 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x114c0-0x114ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11500-0x1153f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11540-0x1157f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xb0, /* 0x11580-0x115bf */
+ 0x01, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, /* 0x115c0-0x115ff */
+ /* 0x11600-0x117ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xa7, /* 0x11600-0x1163f */
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11640-0x1167f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0xbf, 0x00, /* 0x11680-0x116bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x116c0-0x116ff */
+ 0x00, 0x00, 0x00, 0xe0, 0xbc, 0x0f, 0x00, 0x00, /* 0x11700-0x1173f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11740-0x1177f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11780-0x117bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x117c0-0x117ff */
+ /* 0x11c00-0x11dff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x3f, /* 0x11c00-0x11c3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11c40-0x11c7f */
+ 0x00, 0x00, 0xfc, 0xff, 0xff, 0xfc, 0x6d, 0x00, /* 0x11c80-0x11cbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11cc0-0x11cff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11d00-0x11d3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11d40-0x11d7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11d80-0x11dbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11dc0-0x11dff */
+ /* 0x16a00-0x16bff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a00-0x16a3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a40-0x16a7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a80-0x16abf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, /* 0x16ac0-0x16aff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, /* 0x16b00-0x16b3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16b40-0x16b7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16b80-0x16bbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16bc0-0x16bff */
+ /* 0x16e00-0x16fff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e00-0x16e3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e40-0x16e7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e80-0x16ebf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16ec0-0x16eff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f00-0x16f3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f40-0x16f7f */
+ 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f80-0x16fbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16fc0-0x16fff */
+ /* 0x1bc00-0x1bdff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc00-0x1bc3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc40-0x1bc7f */
+ 0x00, 0x00, 0x00, 0x60, 0x0f, 0x00, 0x00, 0x00, /* 0x1bc80-0x1bcbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bcc0-0x1bcff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd00-0x1bd3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd40-0x1bd7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd80-0x1bdbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bdc0-0x1bdff */
+ /* 0x1d000-0x1d1ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d000-0x1d03f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d040-0x1d07f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d080-0x1d0bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d0c0-0x1d0ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d100-0x1d13f */
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xf8, 0xff, /* 0x1d140-0x1d17f */
+ 0xe7, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x1d180-0x1d1bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d1c0-0x1d1ff */
+ /* 0x1d200-0x1d3ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d200-0x1d23f */
+ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d240-0x1d27f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d280-0x1d2bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d2c0-0x1d2ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d300-0x1d33f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d340-0x1d37f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d380-0x1d3bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d3c0-0x1d3ff */
+ /* 0x1da00-0x1dbff */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf8, /* 0x1da00-0x1da3f */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x20, 0x00, /* 0x1da40-0x1da7f */
+ 0x10, 0x00, 0x00, 0xf8, 0xfe, 0xff, 0x00, 0x00, /* 0x1da80-0x1dabf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1dac0-0x1daff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db00-0x1db3f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db40-0x1db7f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db80-0x1dbbf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1dbc0-0x1dbff */
+ /* 0x1e000-0x1e1ff */
+ 0x7f, 0xff, 0xff, 0xf9, 0xdb, 0x07, 0x00, 0x00, /* 0x1e000-0x1e03f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e040-0x1e07f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e080-0x1e0bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e0c0-0x1e0ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e100-0x1e13f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e140-0x1e17f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e180-0x1e1bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e1c0-0x1e1ff */
+ /* 0x1e800-0x1e9ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e800-0x1e83f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e840-0x1e87f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e880-0x1e8bf */
+ 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e8c0-0x1e8ff */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e900-0x1e93f */
+ 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e940-0x1e97f */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e980-0x1e9bf */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 0x1e9c0-0x1e9ff */
+};
+static const signed char nonspacing_table_ind[248] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, /* 0x0000-0x0fff */
+ 8, 9, -1, 10, 11, 12, 13, -1, /* 0x1000-0x1fff */
+ 14, -1, -1, -1, -1, -1, 15, -1, /* 0x2000-0x2fff */
+ 16, -1, -1, -1, -1, -1, -1, -1, /* 0x3000-0x3fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x4000-0x4fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x5000-0x5fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x6000-0x6fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x7000-0x7fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x8000-0x8fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x9000-0x9fff */
+ -1, -1, -1, 17, 18, 19, -1, -1, /* 0xa000-0xafff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb000-0xbfff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc000-0xcfff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd000-0xdfff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe000-0xefff */
+ -1, -1, -1, -1, -1, 20, -1, 21, /* 0xf000-0xffff */
+ 22, 23, -1, -1, -1, 24, -1, -1, /* 0x10000-0x10fff */
+ 25, 26, 27, 28, -1, -1, 29, -1, /* 0x11000-0x11fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x12000-0x12fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x13000-0x13fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x14000-0x14fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x15000-0x15fff */
+ -1, -1, -1, -1, -1, 30, -1, 31, /* 0x16000-0x16fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x17000-0x17fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x18000-0x18fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x19000-0x19fff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1a000-0x1afff */
+ -1, -1, -1, -1, -1, -1, 32, -1, /* 0x1b000-0x1bfff */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1c000-0x1cfff */
+ 33, 34, -1, -1, -1, 35, -1, -1, /* 0x1d000-0x1dfff */
+ 36, -1, -1, -1, 37, -1, -1, -1 /* 0x1e000-0x1efff */
+};
+
+/* Determine number of column positions required for UC. */
+int
+uc_width (ucs4_t uc, const char *encoding)
+{
+ /* Test for non-spacing or control character. */
+ if ((uc >> 9) < 248)
+ {
+ int ind = nonspacing_table_ind[uc >> 9];
+ if (ind >= 0)
+ if ((nonspacing_table_data[64*ind + ((uc >> 3) & 63)] >> (uc & 7)) & 1)
+ {
+ if (uc > 0 && uc < 0xa0)
+ return -1;
+ else
+ return 0;
+ }
+ }
+ else if ((uc >> 9) == (0xe0000 >> 9))
+ {
+ if (uc >= 0xe0100)
+ {
+ if (uc <= 0xe01ef)
+ return 0;
+ }
+ else
+ {
+ if (uc >= 0xe0020 ? uc <= 0xe007f : uc == 0xe0001)
+ return 0;
+ }
+ }
+ /* Test for double-width character.
+ * Generated from "grep '^[^;]\{4,5\};[WF]' EastAsianWidth.txt"
+ * and "grep '^[^;]\{4,5\};[^WF]' EastAsianWidth.txt"
+ */
+ if (uc >= 0x1100
+ && ((uc < 0x1160) /* Hangul Jamo */
+ || (uc >= 0x2329 && uc < 0x232b) /* Angle Brackets */
+ || (uc >= 0x2e80 && uc < 0xa4d0 /* CJK ... Yi */
+ && !(uc == 0x303f) && !(uc >= 0x4dc0 && uc < 0x4e00))
+ || (uc >= 0xac00 && uc < 0xd7a4) /* Hangul Syllables */
+ || (uc >= 0xf900 && uc < 0xfb00) /* CJK Compatibility Ideographs */
+ || (uc >= 0xfe10 && uc < 0xfe20) /* Presentation Forms for Vertical */
+ || (uc >= 0xfe30 && uc < 0xfe70) /* CJK Compatibility Forms */
+ || (uc >= 0xff00 && uc < 0xff61) /* Fullwidth Forms */
+ || (uc >= 0xffe0 && uc < 0xffe7) /* Fullwidth Signs */
+ || (uc >= 0x20000 && uc <= 0x2ffff) /* Supplementary Ideographic Plane */
+ || (uc >= 0x30000 && uc <= 0x3ffff) /* Tertiary Ideographic Plane */
+ ) )
+ return 2;
+ /* In ancient CJK encodings, Cyrillic and most other characters are
+ double-width as well. */
+ if (uc >= 0x00A1 && uc < 0xFF61 && uc != 0x20A9
+ && is_cjk_encoding (encoding))
+ return 2;
+ return 1;
+}
diff --git a/grub-core/lib/gnulib/vasnprintf.c b/grub-core/lib/gnulib/vasnprintf.c
new file mode 100644
index 0000000..c475903
--- /dev/null
+++ b/grub-core/lib/gnulib/vasnprintf.c
@@ -0,0 +1,5621 @@
+/* vsprintf with automatic memory allocation.
+ Copyright (C) 1999, 2002-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* This file can be parametrized with the following macros:
+ VASNPRINTF The name of the function being defined.
+ FCHAR_T The element type of the format string.
+ DCHAR_T The element type of the destination (result) string.
+ FCHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters
+ in the format string are ASCII. MUST be set if
+ FCHAR_T and DCHAR_T are not the same type.
+ DIRECTIVE Structure denoting a format directive.
+ Depends on FCHAR_T.
+ DIRECTIVES Structure denoting the set of format directives of a
+ format string. Depends on FCHAR_T.
+ PRINTF_PARSE Function that parses a format string.
+ Depends on FCHAR_T.
+ DCHAR_CPY memcpy like function for DCHAR_T[] arrays.
+ DCHAR_SET memset like function for DCHAR_T[] arrays.
+ DCHAR_MBSNLEN mbsnlen like function for DCHAR_T[] arrays.
+ SNPRINTF The system's snprintf (or similar) function.
+ This may be either snprintf or swprintf.
+ TCHAR_T The element type of the argument and result string
+ of the said SNPRINTF function. This may be either
+ char or wchar_t. The code exploits that
+ sizeof (TCHAR_T) | sizeof (DCHAR_T) and
+ alignof (TCHAR_T) <= alignof (DCHAR_T).
+ DCHAR_IS_TCHAR Set to 1 if DCHAR_T and TCHAR_T are the same type.
+ DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[].
+ DCHAR_IS_UINT8_T Set to 1 if DCHAR_T is uint8_t.
+ DCHAR_IS_UINT16_T Set to 1 if DCHAR_T is uint16_t.
+ DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#ifndef VASNPRINTF
+# include <config.h>
+#endif
+#ifndef IN_LIBINTL
+# include <alloca.h>
+#endif
+
+/* Specification. */
+#ifndef VASNPRINTF
+# if WIDE_CHAR_VERSION
+# include "vasnwprintf.h"
+# else
+# include "vasnprintf.h"
+# endif
+#endif
+
+#include <locale.h> /* localeconv() */
+#include <stdio.h> /* snprintf(), sprintf() */
+#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
+#include <string.h> /* memcpy(), strlen() */
+#include <errno.h> /* errno */
+#include <limits.h> /* CHAR_BIT */
+#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
+#if HAVE_NL_LANGINFO
+# include <langinfo.h>
+#endif
+#ifndef VASNPRINTF
+# if WIDE_CHAR_VERSION
+# include "wprintf-parse.h"
+# else
+# include "printf-parse.h"
+# endif
+#endif
+
+/* Checked size_t computations. */
+#include "xsize.h"
+
+#include "verify.h"
+
+#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
+# include <math.h>
+# include "float+.h"
+#endif
+
+#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
+# include <math.h>
+# include "isnand-nolibm.h"
+#endif
+
+#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL
+# include <math.h>
+# include "isnanl-nolibm.h"
+# include "fpucw.h"
+#endif
+
+#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
+# include <math.h>
+# include "isnand-nolibm.h"
+# include "printf-frexp.h"
+#endif
+
+#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
+# include <math.h>
+# include "isnanl-nolibm.h"
+# include "printf-frexpl.h"
+# include "fpucw.h"
+#endif
+
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
+/* Default parameters. */
+#ifndef VASNPRINTF
+# if WIDE_CHAR_VERSION
+# define VASNPRINTF vasnwprintf
+# define FCHAR_T wchar_t
+# define DCHAR_T wchar_t
+# define TCHAR_T wchar_t
+# define DCHAR_IS_TCHAR 1
+# define DIRECTIVE wchar_t_directive
+# define DIRECTIVES wchar_t_directives
+# define PRINTF_PARSE wprintf_parse
+# define DCHAR_CPY wmemcpy
+# define DCHAR_SET wmemset
+# else
+# define VASNPRINTF vasnprintf
+# define FCHAR_T char
+# define DCHAR_T char
+# define TCHAR_T char
+# define DCHAR_IS_TCHAR 1
+# define DIRECTIVE char_directive
+# define DIRECTIVES char_directives
+# define PRINTF_PARSE printf_parse
+# define DCHAR_CPY memcpy
+# define DCHAR_SET memset
+# endif
+#endif
+#if WIDE_CHAR_VERSION
+ /* TCHAR_T is wchar_t. */
+# define USE_SNPRINTF 1
+# if HAVE_DECL__SNWPRINTF
+ /* On Windows, the function swprintf() has a different signature than
+ on Unix; we use the function _snwprintf() or - on mingw - snwprintf()
+ instead. The mingw function snwprintf() has fewer bugs than the
+ MSVCRT function _snwprintf(), so prefer that. */
+# if defined __MINGW32__
+# define SNPRINTF snwprintf
+# else
+# define SNPRINTF _snwprintf
+# define USE_MSVC__SNPRINTF 1
+# endif
+# else
+ /* Unix. */
+# define SNPRINTF swprintf
+# endif
+#else
+ /* TCHAR_T is char. */
+ /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'.
+ But don't use it on BeOS, since BeOS snprintf produces no output if the
+ size argument is >= 0x3000000.
+ Also don't use it on Linux libc5, since there snprintf with size = 1
+ writes any output without bounds, like sprintf. */
+# if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ && !(__GNU_LIBRARY__ == 1)
+# define USE_SNPRINTF 1
+# else
+# define USE_SNPRINTF 0
+# endif
+# if HAVE_DECL__SNPRINTF
+ /* Windows. The mingw function snprintf() has fewer bugs than the MSVCRT
+ function _snprintf(), so prefer that. */
+# if defined __MINGW32__
+# define SNPRINTF snprintf
+ /* Here we need to call the native snprintf, not rpl_snprintf. */
+# undef snprintf
+# else
+ /* MSVC versions < 14 did not have snprintf, only _snprintf. */
+# define SNPRINTF _snprintf
+# define USE_MSVC__SNPRINTF 1
+# endif
+# else
+ /* Unix. */
+# define SNPRINTF snprintf
+ /* Here we need to call the native snprintf, not rpl_snprintf. */
+# undef snprintf
+# endif
+#endif
+/* Here we need to call the native sprintf, not rpl_sprintf. */
+#undef sprintf
+
+/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized"
+ warnings in this file. Use -Dlint to suppress them. */
+#if defined GCC_LINT || defined lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
+
+/* Avoid some warnings from "gcc -Wshadow".
+ This file doesn't use the exp() and remainder() functions. */
+#undef exp
+#define exp expo
+#undef remainder
+#define remainder rem
+
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && !WIDE_CHAR_VERSION
+# if (HAVE_STRNLEN && !defined _AIX)
+# define local_strnlen strnlen
+# else
+# ifndef local_strnlen_defined
+# define local_strnlen_defined 1
+static size_t
+local_strnlen (const char *string, size_t maxlen)
+{
+ const char *end = memchr (string, '\0', maxlen);
+ return end ? (size_t) (end - string) : maxlen;
+}
+# endif
+# endif
+#endif
+
+#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T
+# if HAVE_WCSLEN
+# define local_wcslen wcslen
+# else
+ /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
+ a dependency towards this library, here is a local substitute.
+ Define this substitute only once, even if this file is included
+ twice in the same compilation unit. */
+# ifndef local_wcslen_defined
+# define local_wcslen_defined 1
+static size_t
+local_wcslen (const wchar_t *s)
+{
+ const wchar_t *ptr;
+
+ for (ptr = s; *ptr != (wchar_t) 0; ptr++)
+ ;
+ return ptr - s;
+}
+# endif
+# endif
+#endif
+
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && HAVE_WCHAR_T && WIDE_CHAR_VERSION
+# if HAVE_WCSNLEN
+# define local_wcsnlen wcsnlen
+# else
+# ifndef local_wcsnlen_defined
+# define local_wcsnlen_defined 1
+static size_t
+local_wcsnlen (const wchar_t *s, size_t maxlen)
+{
+ const wchar_t *ptr;
+
+ for (ptr = s; maxlen > 0 && *ptr != (wchar_t) 0; ptr++, maxlen--)
+ ;
+ return ptr - s;
+}
+# endif
+# endif
+#endif
+
+#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
+/* Determine the decimal-point character according to the current locale. */
+# ifndef decimal_point_char_defined
+# define decimal_point_char_defined 1
+static char
+decimal_point_char (void)
+{
+ const char *point;
+ /* Determine it in a multithread-safe way. We know nl_langinfo is
+ multithread-safe on glibc systems and Mac OS X systems, but is not required
+ to be multithread-safe by POSIX. sprintf(), however, is multithread-safe.
+ localeconv() is rarely multithread-safe. */
+# if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined __APPLE__ && defined __MACH__))
+ point = nl_langinfo (RADIXCHAR);
+# elif 1
+ char pointbuf[5];
+ sprintf (pointbuf, "%#.0f", 1.0);
+ point = &pointbuf[1];
+# else
+ point = localeconv () -> decimal_point;
+# endif
+ /* The decimal point is always a single byte: either '.' or ','. */
+ return (point[0] != '\0' ? point[0] : '.');
+}
+# endif
+#endif
+
+#if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE && !defined IN_LIBINTL
+
+/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */
+static int
+is_infinite_or_zero (double x)
+{
+ return isnand (x) || x + x == x;
+}
+
+#endif
+
+#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL
+
+/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */
+static int
+is_infinite_or_zerol (long double x)
+{
+ return isnanl (x) || x + x == x;
+}
+
+#endif
+
+#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
+
+/* Converting 'long double' to decimal without rare rounding bugs requires
+ real bignums. We use the naming conventions of GNU gmp, but vastly simpler
+ (and slower) algorithms. */
+
+typedef unsigned int mp_limb_t;
+# define GMP_LIMB_BITS 32
+verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS);
+
+typedef unsigned long long mp_twolimb_t;
+# define GMP_TWOLIMB_BITS 64
+verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS);
+
+/* Representation of a bignum >= 0. */
+typedef struct
+{
+ size_t nlimbs;
+ mp_limb_t *limbs; /* Bits in little-endian order, allocated with malloc(). */
+} mpn_t;
+
+/* Compute the product of two bignums >= 0.
+ Return the allocated memory in case of success, NULL in case of memory
+ allocation failure. */
+static void *
+multiply (mpn_t src1, mpn_t src2, mpn_t *dest)
+{
+ const mp_limb_t *p1;
+ const mp_limb_t *p2;
+ size_t len1;
+ size_t len2;
+
+ if (src1.nlimbs <= src2.nlimbs)
+ {
+ len1 = src1.nlimbs;
+ p1 = src1.limbs;
+ len2 = src2.nlimbs;
+ p2 = src2.limbs;
+ }
+ else
+ {
+ len1 = src2.nlimbs;
+ p1 = src2.limbs;
+ len2 = src1.nlimbs;
+ p2 = src1.limbs;
+ }
+ /* Now 0 <= len1 <= len2. */
+ if (len1 == 0)
+ {
+ /* src1 or src2 is zero. */
+ dest->nlimbs = 0;
+ dest->limbs = (mp_limb_t *) malloc (1);
+ }
+ else
+ {
+ /* Here 1 <= len1 <= len2. */
+ size_t dlen;
+ mp_limb_t *dp;
+ size_t k, i, j;
+
+ dlen = len1 + len2;
+ dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t));
+ if (dp == NULL)
+ return NULL;
+ for (k = len2; k > 0; )
+ dp[--k] = 0;
+ for (i = 0; i < len1; i++)
+ {
+ mp_limb_t digit1 = p1[i];
+ mp_twolimb_t carry = 0;
+ for (j = 0; j < len2; j++)
+ {
+ mp_limb_t digit2 = p2[j];
+ carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
+ carry += dp[i + j];
+ dp[i + j] = (mp_limb_t) carry;
+ carry = carry >> GMP_LIMB_BITS;
+ }
+ dp[i + len2] = (mp_limb_t) carry;
+ }
+ /* Normalise. */
+ while (dlen > 0 && dp[dlen - 1] == 0)
+ dlen--;
+ dest->nlimbs = dlen;
+ dest->limbs = dp;
+ }
+ return dest->limbs;
+}
+
+/* Compute the quotient of a bignum a >= 0 and a bignum b > 0.
+ a is written as a = q * b + r with 0 <= r < b. q is the quotient, r
+ the remainder.
+ Finally, round-to-even is performed: If r > b/2 or if r = b/2 and q is odd,
+ q is incremented.
+ Return the allocated memory in case of success, NULL in case of memory
+ allocation failure. */
+static void *
+divide (mpn_t a, mpn_t b, mpn_t *q)
+{
+ /* Algorithm:
+ First normalise a and b: a=[a[m-1],...,a[0]], b=[b[n-1],...,b[0]]
+ with m>=0 and n>0 (in base beta = 2^GMP_LIMB_BITS).
+ If m<n, then q:=0 and r:=a.
+ If m>=n=1, perform a single-precision division:
+ r:=0, j:=m,
+ while j>0 do
+ {Here (q[m-1]*beta^(m-1)+...+q[j]*beta^j) * b[0] + r*beta^j =
+ = a[m-1]*beta^(m-1)+...+a[j]*beta^j und 0<=r<b[0]<beta}
+ j:=j-1, r:=r*beta+a[j], q[j]:=floor(r/b[0]), r:=r-b[0]*q[j].
+ Normalise [q[m-1],...,q[0]], yields q.
+ If m>=n>1, perform a multiple-precision division:
+ We have a/b < beta^(m-n+1).
+ s:=intDsize-1-(highest bit in b[n-1]), 0<=s<intDsize.
+ Shift a and b left by s bits, copying them. r:=a.
+ r=[r[m],...,r[0]], b=[b[n-1],...,b[0]] with b[n-1]>=beta/2.
+ For j=m-n,...,0: {Here 0 <= r < b*beta^(j+1).}
+ Compute q* :
+ q* := floor((r[j+n]*beta+r[j+n-1])/b[n-1]).
+ In case of overflow (q* >= beta) set q* := beta-1.
+ Compute c2 := ((r[j+n]*beta+r[j+n-1]) - q* * b[n-1])*beta + r[j+n-2]
+ and c3 := b[n-2] * q*.
+ {We have 0 <= c2 < 2*beta^2, even 0 <= c2 < beta^2 if no overflow
+ occurred. Furthermore 0 <= c3 < beta^2.
+ If there was overflow and
+ r[j+n]*beta+r[j+n-1] - q* * b[n-1] >= beta, i.e. c2 >= beta^2,
+ the next test can be skipped.}
+ While c3 > c2, {Here 0 <= c2 < c3 < beta^2}
+ Put q* := q* - 1, c2 := c2 + b[n-1]*beta, c3 := c3 - b[n-2].
+ If q* > 0:
+ Put r := r - b * q* * beta^j. In detail:
+ [r[n+j],...,r[j]] := [r[n+j],...,r[j]] - q* * [b[n-1],...,b[0]].
+ hence: u:=0, for i:=0 to n-1 do
+ u := u + q* * b[i],
+ r[j+i]:=r[j+i]-(u mod beta) (+ beta, if carry),
+ u:=u div beta (+ 1, if carry in subtraction)
+ r[n+j]:=r[n+j]-u.
+ {Since always u = (q* * [b[i-1],...,b[0]] div beta^i) + 1
+ < q* + 1 <= beta,
+ the carry u does not overflow.}
+ If a negative carry occurs, put q* := q* - 1
+ and [r[n+j],...,r[j]] := [r[n+j],...,r[j]] + [0,b[n-1],...,b[0]].
+ Set q[j] := q*.
+ Normalise [q[m-n],..,q[0]]; this yields the quotient q.
+ Shift [r[n-1],...,r[0]] right by s bits and normalise; this yields the
+ rest r.
+ The room for q[j] can be allocated at the memory location of r[n+j].
+ Finally, round-to-even:
+ Shift r left by 1 bit.
+ If r > b or if r = b and q[0] is odd, q := q+1.
+ */
+ const mp_limb_t *a_ptr = a.limbs;
+ size_t a_len = a.nlimbs;
+ const mp_limb_t *b_ptr = b.limbs;
+ size_t b_len = b.nlimbs;
+ mp_limb_t *roomptr;
+ mp_limb_t *tmp_roomptr = NULL;
+ mp_limb_t *q_ptr;
+ size_t q_len;
+ mp_limb_t *r_ptr;
+ size_t r_len;
+
+ /* Allocate room for a_len+2 digits.
+ (Need a_len+1 digits for the real division and 1 more digit for the
+ final rounding of q.) */
+ roomptr = (mp_limb_t *) malloc ((a_len + 2) * sizeof (mp_limb_t));
+ if (roomptr == NULL)
+ return NULL;
+
+ /* Normalise a. */
+ while (a_len > 0 && a_ptr[a_len - 1] == 0)
+ a_len--;
+
+ /* Normalise b. */
+ for (;;)
+ {
+ if (b_len == 0)
+ /* Division by zero. */
+ abort ();
+ if (b_ptr[b_len - 1] == 0)
+ b_len--;
+ else
+ break;
+ }
+
+ /* Here m = a_len >= 0 and n = b_len > 0. */
+
+ if (a_len < b_len)
+ {
+ /* m<n: trivial case. q=0, r := copy of a. */
+ r_ptr = roomptr;
+ r_len = a_len;
+ memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
+ q_ptr = roomptr + a_len;
+ q_len = 0;
+ }
+ else if (b_len == 1)
+ {
+ /* n=1: single precision division.
+ beta^(m-1) <= a < beta^m ==> beta^(m-2) <= a/b < beta^m */
+ r_ptr = roomptr;
+ q_ptr = roomptr + 1;
+ {
+ mp_limb_t den = b_ptr[0];
+ mp_limb_t remainder = 0;
+ const mp_limb_t *sourceptr = a_ptr + a_len;
+ mp_limb_t *destptr = q_ptr + a_len;
+ size_t count;
+ for (count = a_len; count > 0; count--)
+ {
+ mp_twolimb_t num =
+ ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr;
+ *--destptr = num / den;
+ remainder = num % den;
+ }
+ /* Normalise and store r. */
+ if (remainder > 0)
+ {
+ r_ptr[0] = remainder;
+ r_len = 1;
+ }
+ else
+ r_len = 0;
+ /* Normalise q. */
+ q_len = a_len;
+ if (q_ptr[q_len - 1] == 0)
+ q_len--;
+ }
+ }
+ else
+ {
+ /* n>1: multiple precision division.
+ beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==>
+ beta^(m-n-1) <= a/b < beta^(m-n+1). */
+ /* Determine s. */
+ size_t s;
+ {
+ mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
+ /* Determine s = GMP_LIMB_BITS - integer_length (msd).
+ Code copied from gnulib's integer_length.c. */
+# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ s = __builtin_clz (msd);
+# else
+# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
+ if (GMP_LIMB_BITS <= DBL_MANT_BIT)
+ {
+ /* Use 'double' operations.
+ Assumes an IEEE 754 'double' implementation. */
+# define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
+# define DBL_EXP_BIAS (DBL_EXP_MASK / 2 - 1)
+# define NWORDS \
+ ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
+ union { double value; unsigned int word[NWORDS]; } m;
+
+ /* Use a single integer to floating-point conversion. */
+ m.value = msd;
+
+ s = GMP_LIMB_BITS
+ - (((m.word[DBL_EXPBIT0_WORD] >> DBL_EXPBIT0_BIT) & DBL_EXP_MASK)
+ - DBL_EXP_BIAS);
+ }
+ else
+# undef NWORDS
+# endif
+ {
+ s = 31;
+ if (msd >= 0x10000)
+ {
+ msd = msd >> 16;
+ s -= 16;
+ }
+ if (msd >= 0x100)
+ {
+ msd = msd >> 8;
+ s -= 8;
+ }
+ if (msd >= 0x10)
+ {
+ msd = msd >> 4;
+ s -= 4;
+ }
+ if (msd >= 0x4)
+ {
+ msd = msd >> 2;
+ s -= 2;
+ }
+ if (msd >= 0x2)
+ {
+ msd = msd >> 1;
+ s -= 1;
+ }
+ }
+# endif
+ }
+ /* 0 <= s < GMP_LIMB_BITS.
+ Copy b, shifting it left by s bits. */
+ if (s > 0)
+ {
+ tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t));
+ if (tmp_roomptr == NULL)
+ {
+ free (roomptr);
+ return NULL;
+ }
+ {
+ const mp_limb_t *sourceptr = b_ptr;
+ mp_limb_t *destptr = tmp_roomptr;
+ mp_twolimb_t accu = 0;
+ size_t count;
+ for (count = b_len; count > 0; count--)
+ {
+ accu += (mp_twolimb_t) *sourceptr++ << s;
+ *destptr++ = (mp_limb_t) accu;
+ accu = accu >> GMP_LIMB_BITS;
+ }
+ /* accu must be zero, since that was how s was determined. */
+ if (accu != 0)
+ abort ();
+ }
+ b_ptr = tmp_roomptr;
+ }
+ /* Copy a, shifting it left by s bits, yields r.
+ Memory layout:
+ At the beginning: r = roomptr[0..a_len],
+ at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */
+ r_ptr = roomptr;
+ if (s == 0)
+ {
+ memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
+ r_ptr[a_len] = 0;
+ }
+ else
+ {
+ const mp_limb_t *sourceptr = a_ptr;
+ mp_limb_t *destptr = r_ptr;
+ mp_twolimb_t accu = 0;
+ size_t count;
+ for (count = a_len; count > 0; count--)
+ {
+ accu += (mp_twolimb_t) *sourceptr++ << s;
+ *destptr++ = (mp_limb_t) accu;
+ accu = accu >> GMP_LIMB_BITS;
+ }
+ *destptr++ = (mp_limb_t) accu;
+ }
+ q_ptr = roomptr + b_len;
+ q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */
+ {
+ size_t j = a_len - b_len; /* m-n */
+ mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */
+ mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */
+ mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */
+ ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd;
+ /* Division loop, traversed m-n+1 times.
+ j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */
+ for (;;)
+ {
+ mp_limb_t q_star;
+ mp_limb_t c1;
+ if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */
+ {
+ /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */
+ mp_twolimb_t num =
+ ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS)
+ | r_ptr[j + b_len - 1];
+ q_star = num / b_msd;
+ c1 = num % b_msd;
+ }
+ else
+ {
+ /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */
+ q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */
+ /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta
+ <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta
+ <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta)
+ {<= beta !}.
+ If yes, jump directly to the subtraction loop.
+ (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta
+ <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */
+ if (r_ptr[j + b_len] > b_msd
+ || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd)
+ /* r[j+n] >= b[n-1]+1 or
+ r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a
+ carry. */
+ goto subtract;
+ }
+ /* q_star = q*,
+ c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, <beta). */
+ {
+ mp_twolimb_t c2 = /* c1*beta+r[j+n-2] */
+ ((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2];
+ mp_twolimb_t c3 = /* b[n-2] * q* */
+ (mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star;
+ /* While c2 < c3, increase c2 and decrease c3.
+ Consider c3-c2. While it is > 0, decrease it by
+ b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2
+ this can happen only twice. */
+ if (c3 > c2)
+ {
+ q_star = q_star - 1; /* q* := q* - 1 */
+ if (c3 - c2 > b_msdd)
+ q_star = q_star - 1; /* q* := q* - 1 */
+ }
+ }
+ if (q_star > 0)
+ subtract:
+ {
+ /* Subtract r := r - b * q* * beta^j. */
+ mp_limb_t cr;
+ {
+ const mp_limb_t *sourceptr = b_ptr;
+ mp_limb_t *destptr = r_ptr + j;
+ mp_twolimb_t carry = 0;
+ size_t count;
+ for (count = b_len; count > 0; count--)
+ {
+ /* Here 0 <= carry <= q*. */
+ carry =
+ carry
+ + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++
+ + (mp_limb_t) ~(*destptr);
+ /* Here 0 <= carry <= beta*q* + beta-1. */
+ *destptr++ = ~(mp_limb_t) carry;
+ carry = carry >> GMP_LIMB_BITS; /* <= q* */
+ }
+ cr = (mp_limb_t) carry;
+ }
+ /* Subtract cr from r_ptr[j + b_len], then forget about
+ r_ptr[j + b_len]. */
+ if (cr > r_ptr[j + b_len])
+ {
+ /* Subtraction gave a carry. */
+ q_star = q_star - 1; /* q* := q* - 1 */
+ /* Add b back. */
+ {
+ const mp_limb_t *sourceptr = b_ptr;
+ mp_limb_t *destptr = r_ptr + j;
+ mp_limb_t carry = 0;
+ size_t count;
+ for (count = b_len; count > 0; count--)
+ {
+ mp_limb_t source1 = *sourceptr++;
+ mp_limb_t source2 = *destptr;
+ *destptr++ = source1 + source2 + carry;
+ carry =
+ (carry
+ ? source1 >= (mp_limb_t) ~source2
+ : source1 > (mp_limb_t) ~source2);
+ }
+ }
+ /* Forget about the carry and about r[j+n]. */
+ }
+ }
+ /* q* is determined. Store it as q[j]. */
+ q_ptr[j] = q_star;
+ if (j == 0)
+ break;
+ j--;
+ }
+ }
+ r_len = b_len;
+ /* Normalise q. */
+ if (q_ptr[q_len - 1] == 0)
+ q_len--;
+# if 0 /* Not needed here, since we need r only to compare it with b/2, and
+ b is shifted left by s bits. */
+ /* Shift r right by s bits. */
+ if (s > 0)
+ {
+ mp_limb_t ptr = r_ptr + r_len;
+ mp_twolimb_t accu = 0;
+ size_t count;
+ for (count = r_len; count > 0; count--)
+ {
+ accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
+ accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
+ *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS);
+ }
+ }
+# endif
+ /* Normalise r. */
+ while (r_len > 0 && r_ptr[r_len - 1] == 0)
+ r_len--;
+ }
+ /* Compare r << 1 with b. */
+ if (r_len > b_len)
+ goto increment_q;
+ {
+ size_t i;
+ for (i = b_len;;)
+ {
+ mp_limb_t r_i =
+ (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
+ | (i < r_len ? r_ptr[i] << 1 : 0);
+ mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
+ if (r_i > b_i)
+ goto increment_q;
+ if (r_i < b_i)
+ goto keep_q;
+ if (i == 0)
+ break;
+ i--;
+ }
+ }
+ if (q_len > 0 && ((q_ptr[0] & 1) != 0))
+ /* q is odd. */
+ increment_q:
+ {
+ size_t i;
+ for (i = 0; i < q_len; i++)
+ if (++(q_ptr[i]) != 0)
+ goto keep_q;
+ q_ptr[q_len++] = 1;
+ }
+ keep_q:
+ if (tmp_roomptr != NULL)
+ free (tmp_roomptr);
+ q->limbs = q_ptr;
+ q->nlimbs = q_len;
+ return roomptr;
+}
+
+/* Convert a bignum a >= 0, multiplied with 10^extra_zeroes, to decimal
+ representation.
+ Destroys the contents of a.
+ Return the allocated memory - containing the decimal digits in low-to-high
+ order, terminated with a NUL character - in case of success, NULL in case
+ of memory allocation failure. */
+static char *
+convert_to_decimal (mpn_t a, size_t extra_zeroes)
+{
+ mp_limb_t *a_ptr = a.limbs;
+ size_t a_len = a.nlimbs;
+ /* 0.03345 is slightly larger than log(2)/(9*log(10)). */
+ size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1);
+ /* We need extra_zeroes bytes for zeroes, followed by c_len bytes for the
+ digits of a, followed by 1 byte for the terminating NUL. */
+ char *c_ptr = (char *) malloc (xsum (xsum (extra_zeroes, c_len), 1));
+ if (c_ptr != NULL)
+ {
+ char *d_ptr = c_ptr;
+ for (; extra_zeroes > 0; extra_zeroes--)
+ *d_ptr++ = '0';
+ while (a_len > 0)
+ {
+ /* Divide a by 10^9, in-place. */
+ mp_limb_t remainder = 0;
+ mp_limb_t *ptr = a_ptr + a_len;
+ size_t count;
+ for (count = a_len; count > 0; count--)
+ {
+ mp_twolimb_t num =
+ ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;
+ *ptr = num / 1000000000;
+ remainder = num % 1000000000;
+ }
+ /* Store the remainder as 9 decimal digits. */
+ for (count = 9; count > 0; count--)
+ {
+ *d_ptr++ = '0' + (remainder % 10);
+ remainder = remainder / 10;
+ }
+ /* Normalize a. */
+ if (a_ptr[a_len - 1] == 0)
+ a_len--;
+ }
+ /* Remove leading zeroes. */
+ while (d_ptr > c_ptr && d_ptr[-1] == '0')
+ d_ptr--;
+ /* But keep at least one zero. */
+ if (d_ptr == c_ptr)
+ *d_ptr++ = '0';
+ /* Terminate the string. */
+ *d_ptr = '\0';
+ }
+ return c_ptr;
+}
+
+# if NEED_PRINTF_LONG_DOUBLE
+
+/* Assuming x is finite and >= 0:
+ write x as x = 2^e * m, where m is a bignum.
+ Return the allocated memory in case of success, NULL in case of memory
+ allocation failure. */
+static void *
+decode_long_double (long double x, int *ep, mpn_t *mp)
+{
+ mpn_t m;
+ int exp;
+ long double y;
+ size_t i;
+
+ /* Allocate memory for result. */
+ m.nlimbs = (LDBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS;
+ m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t));
+ if (m.limbs == NULL)
+ return NULL;
+ /* Split into exponential part and mantissa. */
+ y = frexpl (x, &exp);
+ if (!(y >= 0.0L && y < 1.0L))
+ abort ();
+ /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * 2^LDBL_MANT_BIT), and the
+ latter is an integer. */
+ /* Convert the mantissa (y * 2^LDBL_MANT_BIT) to a sequence of limbs.
+ I'm not sure whether it's safe to cast a 'long double' value between
+ 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only
+ 'long double' values between 0 and 2^16 (to 'unsigned int' or 'int',
+ doesn't matter). */
+# if (LDBL_MANT_BIT % GMP_LIMB_BITS) != 0
+# if (LDBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2
+ {
+ mp_limb_t hi, lo;
+ y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % (GMP_LIMB_BITS / 2));
+ hi = (int) y;
+ y -= hi;
+ if (!(y >= 0.0L && y < 1.0L))
+ abort ();
+ y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+ lo = (int) y;
+ y -= lo;
+ if (!(y >= 0.0L && y < 1.0L))
+ abort ();
+ m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
+ }
+# else
+ {
+ mp_limb_t d;
+ y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % GMP_LIMB_BITS);
+ d = (int) y;
+ y -= d;
+ if (!(y >= 0.0L && y < 1.0L))
+ abort ();
+ m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d;
+ }
+# endif
+# endif
+ for (i = LDBL_MANT_BIT / GMP_LIMB_BITS; i > 0; )
+ {
+ mp_limb_t hi, lo;
+ y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+ hi = (int) y;
+ y -= hi;
+ if (!(y >= 0.0L && y < 1.0L))
+ abort ();
+ y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+ lo = (int) y;
+ y -= lo;
+ if (!(y >= 0.0L && y < 1.0L))
+ abort ();
+ m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
+ }
+# if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess
+ precision. */
+ if (!(y == 0.0L))
+ abort ();
+# endif
+ /* Normalise. */
+ while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0)
+ m.nlimbs--;
+ *mp = m;
+ *ep = exp - LDBL_MANT_BIT;
+ return m.limbs;
+}
+
+# endif
+
+# if NEED_PRINTF_DOUBLE
+
+/* Assuming x is finite and >= 0:
+ write x as x = 2^e * m, where m is a bignum.
+ Return the allocated memory in case of success, NULL in case of memory
+ allocation failure. */
+static void *
+decode_double (double x, int *ep, mpn_t *mp)
+{
+ mpn_t m;
+ int exp;
+ double y;
+ size_t i;
+
+ /* Allocate memory for result. */
+ m.nlimbs = (DBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS;
+ m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t));
+ if (m.limbs == NULL)
+ return NULL;
+ /* Split into exponential part and mantissa. */
+ y = frexp (x, &exp);
+ if (!(y >= 0.0 && y < 1.0))
+ abort ();
+ /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * 2^DBL_MANT_BIT), and the
+ latter is an integer. */
+ /* Convert the mantissa (y * 2^DBL_MANT_BIT) to a sequence of limbs.
+ I'm not sure whether it's safe to cast a 'double' value between
+ 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only
+ 'double' values between 0 and 2^16 (to 'unsigned int' or 'int',
+ doesn't matter). */
+# if (DBL_MANT_BIT % GMP_LIMB_BITS) != 0
+# if (DBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2
+ {
+ mp_limb_t hi, lo;
+ y *= (mp_limb_t) 1 << (DBL_MANT_BIT % (GMP_LIMB_BITS / 2));
+ hi = (int) y;
+ y -= hi;
+ if (!(y >= 0.0 && y < 1.0))
+ abort ();
+ y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+ lo = (int) y;
+ y -= lo;
+ if (!(y >= 0.0 && y < 1.0))
+ abort ();
+ m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
+ }
+# else
+ {
+ mp_limb_t d;
+ y *= (mp_limb_t) 1 << (DBL_MANT_BIT % GMP_LIMB_BITS);
+ d = (int) y;
+ y -= d;
+ if (!(y >= 0.0 && y < 1.0))
+ abort ();
+ m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d;
+ }
+# endif
+# endif
+ for (i = DBL_MANT_BIT / GMP_LIMB_BITS; i > 0; )
+ {
+ mp_limb_t hi, lo;
+ y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+ hi = (int) y;
+ y -= hi;
+ if (!(y >= 0.0 && y < 1.0))
+ abort ();
+ y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+ lo = (int) y;
+ y -= lo;
+ if (!(y >= 0.0 && y < 1.0))
+ abort ();
+ m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
+ }
+ if (!(y == 0.0))
+ abort ();
+ /* Normalise. */
+ while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0)
+ m.nlimbs--;
+ *mp = m;
+ *ep = exp - DBL_MANT_BIT;
+ return m.limbs;
+}
+
+# endif
+
+/* Assuming x = 2^e * m is finite and >= 0, and n is an integer:
+ Returns the decimal representation of round (x * 10^n).
+ Return the allocated memory - containing the decimal digits in low-to-high
+ order, terminated with a NUL character - in case of success, NULL in case
+ of memory allocation failure. */
+static char *
+scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
+{
+ int s;
+ size_t extra_zeroes;
+ unsigned int abs_n;
+ unsigned int abs_s;
+ mp_limb_t *pow5_ptr;
+ size_t pow5_len;
+ unsigned int s_limbs;
+ unsigned int s_bits;
+ mpn_t pow5;
+ mpn_t z;
+ void *z_memory;
+ char *digits;
+
+ if (memory == NULL)
+ return NULL;
+ /* x = 2^e * m, hence
+ y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m)
+ = round (2^s * 5^n * m). */
+ s = e + n;
+ extra_zeroes = 0;
+ /* Factor out a common power of 10 if possible. */
+ if (s > 0 && n > 0)
+ {
+ extra_zeroes = (s < n ? s : n);
+ s -= extra_zeroes;
+ n -= extra_zeroes;
+ }
+ /* Here y = round (2^s * 5^n * m) * 10^extra_zeroes.
+ Before converting to decimal, we need to compute
+ z = round (2^s * 5^n * m). */
+ /* Compute 5^|n|, possibly shifted by |s| bits if n and s have the same
+ sign. 2.322 is slightly larger than log(5)/log(2). */
+ abs_n = (n >= 0 ? n : -n);
+ abs_s = (s >= 0 ? s : -s);
+ pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1
+ + abs_s / GMP_LIMB_BITS + 1)
+ * sizeof (mp_limb_t));
+ if (pow5_ptr == NULL)
+ {
+ free (memory);
+ return NULL;
+ }
+ /* Initialize with 1. */
+ pow5_ptr[0] = 1;
+ pow5_len = 1;
+ /* Multiply with 5^|n|. */
+ if (abs_n > 0)
+ {
+ static mp_limb_t const small_pow5[13 + 1] =
+ {
+ 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
+ 48828125, 244140625, 1220703125
+ };
+ unsigned int n13;
+ for (n13 = 0; n13 <= abs_n; n13 += 13)
+ {
+ mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13];
+ size_t j;
+ mp_twolimb_t carry = 0;
+ for (j = 0; j < pow5_len; j++)
+ {
+ mp_limb_t digit2 = pow5_ptr[j];
+ carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
+ pow5_ptr[j] = (mp_limb_t) carry;
+ carry = carry >> GMP_LIMB_BITS;
+ }
+ if (carry > 0)
+ pow5_ptr[pow5_len++] = (mp_limb_t) carry;
+ }
+ }
+ s_limbs = abs_s / GMP_LIMB_BITS;
+ s_bits = abs_s % GMP_LIMB_BITS;
+ if (n >= 0 ? s >= 0 : s <= 0)
+ {
+ /* Multiply with 2^|s|. */
+ if (s_bits > 0)
+ {
+ mp_limb_t *ptr = pow5_ptr;
+ mp_twolimb_t accu = 0;
+ size_t count;
+ for (count = pow5_len; count > 0; count--)
+ {
+ accu += (mp_twolimb_t) *ptr << s_bits;
+ *ptr++ = (mp_limb_t) accu;
+ accu = accu >> GMP_LIMB_BITS;
+ }
+ if (accu > 0)
+ {
+ *ptr = (mp_limb_t) accu;
+ pow5_len++;
+ }
+ }
+ if (s_limbs > 0)
+ {
+ size_t count;
+ for (count = pow5_len; count > 0;)
+ {
+ count--;
+ pow5_ptr[s_limbs + count] = pow5_ptr[count];
+ }
+ for (count = s_limbs; count > 0;)
+ {
+ count--;
+ pow5_ptr[count] = 0;
+ }
+ pow5_len += s_limbs;
+ }
+ pow5.limbs = pow5_ptr;
+ pow5.nlimbs = pow5_len;
+ if (n >= 0)
+ {
+ /* Multiply m with pow5. No division needed. */
+ z_memory = multiply (m, pow5, &z);
+ }
+ else
+ {
+ /* Divide m by pow5 and round. */
+ z_memory = divide (m, pow5, &z);
+ }
+ }
+ else
+ {
+ pow5.limbs = pow5_ptr;
+ pow5.nlimbs = pow5_len;
+ if (n >= 0)
+ {
+ /* n >= 0, s < 0.
+ Multiply m with pow5, then divide by 2^|s|. */
+ mpn_t numerator;
+ mpn_t denominator;
+ void *tmp_memory;
+ tmp_memory = multiply (m, pow5, &numerator);
+ if (tmp_memory == NULL)
+ {
+ free (pow5_ptr);
+ free (memory);
+ return NULL;
+ }
+ /* Construct 2^|s|. */
+ {
+ mp_limb_t *ptr = pow5_ptr + pow5_len;
+ size_t i;
+ for (i = 0; i < s_limbs; i++)
+ ptr[i] = 0;
+ ptr[s_limbs] = (mp_limb_t) 1 << s_bits;
+ denominator.limbs = ptr;
+ denominator.nlimbs = s_limbs + 1;
+ }
+ z_memory = divide (numerator, denominator, &z);
+ free (tmp_memory);
+ }
+ else
+ {
+ /* n < 0, s > 0.
+ Multiply m with 2^s, then divide by pow5. */
+ mpn_t numerator;
+ mp_limb_t *num_ptr;
+ num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1)
+ * sizeof (mp_limb_t));
+ if (num_ptr == NULL)
+ {
+ free (pow5_ptr);
+ free (memory);
+ return NULL;
+ }
+ {
+ mp_limb_t *destptr = num_ptr;
+ {
+ size_t i;
+ for (i = 0; i < s_limbs; i++)
+ *destptr++ = 0;
+ }
+ if (s_bits > 0)
+ {
+ const mp_limb_t *sourceptr = m.limbs;
+ mp_twolimb_t accu = 0;
+ size_t count;
+ for (count = m.nlimbs; count > 0; count--)
+ {
+ accu += (mp_twolimb_t) *sourceptr++ << s_bits;
+ *destptr++ = (mp_limb_t) accu;
+ accu = accu >> GMP_LIMB_BITS;
+ }
+ if (accu > 0)
+ *destptr++ = (mp_limb_t) accu;
+ }
+ else
+ {
+ const mp_limb_t *sourceptr = m.limbs;
+ size_t count;
+ for (count = m.nlimbs; count > 0; count--)
+ *destptr++ = *sourceptr++;
+ }
+ numerator.limbs = num_ptr;
+ numerator.nlimbs = destptr - num_ptr;
+ }
+ z_memory = divide (numerator, pow5, &z);
+ free (num_ptr);
+ }
+ }
+ free (pow5_ptr);
+ free (memory);
+
+ /* Here y = round (x * 10^n) = z * 10^extra_zeroes. */
+
+ if (z_memory == NULL)
+ return NULL;
+ digits = convert_to_decimal (z, extra_zeroes);
+ free (z_memory);
+ return digits;
+}
+
+# if NEED_PRINTF_LONG_DOUBLE
+
+/* Assuming x is finite and >= 0, and n is an integer:
+ Returns the decimal representation of round (x * 10^n).
+ Return the allocated memory - containing the decimal digits in low-to-high
+ order, terminated with a NUL character - in case of success, NULL in case
+ of memory allocation failure. */
+static char *
+scale10_round_decimal_long_double (long double x, int n)
+{
+ int e IF_LINT(= 0);
+ mpn_t m;
+ void *memory = decode_long_double (x, &e, &m);
+ return scale10_round_decimal_decoded (e, m, memory, n);
+}
+
+# endif
+
+# if NEED_PRINTF_DOUBLE
+
+/* Assuming x is finite and >= 0, and n is an integer:
+ Returns the decimal representation of round (x * 10^n).
+ Return the allocated memory - containing the decimal digits in low-to-high
+ order, terminated with a NUL character - in case of success, NULL in case
+ of memory allocation failure. */
+static char *
+scale10_round_decimal_double (double x, int n)
+{
+ int e IF_LINT(= 0);
+ mpn_t m;
+ void *memory = decode_double (x, &e, &m);
+ return scale10_round_decimal_decoded (e, m, memory, n);
+}
+
+# endif
+
+# if NEED_PRINTF_LONG_DOUBLE
+
+/* Assuming x is finite and > 0:
+ Return an approximation for n with 10^n <= x < 10^(n+1).
+ The approximation is usually the right n, but may be off by 1 sometimes. */
+static int
+floorlog10l (long double x)
+{
+ int exp;
+ long double y;
+ double z;
+ double l;
+
+ /* Split into exponential part and mantissa. */
+ y = frexpl (x, &exp);
+ if (!(y >= 0.0L && y < 1.0L))
+ abort ();
+ if (y == 0.0L)
+ return INT_MIN;
+ if (y < 0.5L)
+ {
+ while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
+ {
+ y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
+ exp -= GMP_LIMB_BITS;
+ }
+ if (y < (1.0L / (1 << 16)))
+ {
+ y *= 1.0L * (1 << 16);
+ exp -= 16;
+ }
+ if (y < (1.0L / (1 << 8)))
+ {
+ y *= 1.0L * (1 << 8);
+ exp -= 8;
+ }
+ if (y < (1.0L / (1 << 4)))
+ {
+ y *= 1.0L * (1 << 4);
+ exp -= 4;
+ }
+ if (y < (1.0L / (1 << 2)))
+ {
+ y *= 1.0L * (1 << 2);
+ exp -= 2;
+ }
+ if (y < (1.0L / (1 << 1)))
+ {
+ y *= 1.0L * (1 << 1);
+ exp -= 1;
+ }
+ }
+ if (!(y >= 0.5L && y < 1.0L))
+ abort ();
+ /* Compute an approximation for l = log2(x) = exp + log2(y). */
+ l = exp;
+ z = y;
+ if (z < 0.70710678118654752444)
+ {
+ z *= 1.4142135623730950488;
+ l -= 0.5;
+ }
+ if (z < 0.8408964152537145431)
+ {
+ z *= 1.1892071150027210667;
+ l -= 0.25;
+ }
+ if (z < 0.91700404320467123175)
+ {
+ z *= 1.0905077326652576592;
+ l -= 0.125;
+ }
+ if (z < 0.9576032806985736469)
+ {
+ z *= 1.0442737824274138403;
+ l -= 0.0625;
+ }
+ /* Now 0.95 <= z <= 1.01. */
+ z = 1 - z;
+ /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...)
+ Four terms are enough to get an approximation with error < 10^-7. */
+ l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25)));
+ /* Finally multiply with log(2)/log(10), yields an approximation for
+ log10(x). */
+ l *= 0.30102999566398119523;
+ /* Round down to the next integer. */
+ return (int) l + (l < 0 ? -1 : 0);
+}
+
+# endif
+
+# if NEED_PRINTF_DOUBLE
+
+/* Assuming x is finite and > 0:
+ Return an approximation for n with 10^n <= x < 10^(n+1).
+ The approximation is usually the right n, but may be off by 1 sometimes. */
+static int
+floorlog10 (double x)
+{
+ int exp;
+ double y;
+ double z;
+ double l;
+
+ /* Split into exponential part and mantissa. */
+ y = frexp (x, &exp);
+ if (!(y >= 0.0 && y < 1.0))
+ abort ();
+ if (y == 0.0)
+ return INT_MIN;
+ if (y < 0.5)
+ {
+ while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
+ {
+ y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
+ exp -= GMP_LIMB_BITS;
+ }
+ if (y < (1.0 / (1 << 16)))
+ {
+ y *= 1.0 * (1 << 16);
+ exp -= 16;
+ }
+ if (y < (1.0 / (1 << 8)))
+ {
+ y *= 1.0 * (1 << 8);
+ exp -= 8;
+ }
+ if (y < (1.0 / (1 << 4)))
+ {
+ y *= 1.0 * (1 << 4);
+ exp -= 4;
+ }
+ if (y < (1.0 / (1 << 2)))
+ {
+ y *= 1.0 * (1 << 2);
+ exp -= 2;
+ }
+ if (y < (1.0 / (1 << 1)))
+ {
+ y *= 1.0 * (1 << 1);
+ exp -= 1;
+ }
+ }
+ if (!(y >= 0.5 && y < 1.0))
+ abort ();
+ /* Compute an approximation for l = log2(x) = exp + log2(y). */
+ l = exp;
+ z = y;
+ if (z < 0.70710678118654752444)
+ {
+ z *= 1.4142135623730950488;
+ l -= 0.5;
+ }
+ if (z < 0.8408964152537145431)
+ {
+ z *= 1.1892071150027210667;
+ l -= 0.25;
+ }
+ if (z < 0.91700404320467123175)
+ {
+ z *= 1.0905077326652576592;
+ l -= 0.125;
+ }
+ if (z < 0.9576032806985736469)
+ {
+ z *= 1.0442737824274138403;
+ l -= 0.0625;
+ }
+ /* Now 0.95 <= z <= 1.01. */
+ z = 1 - z;
+ /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...)
+ Four terms are enough to get an approximation with error < 10^-7. */
+ l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25)));
+ /* Finally multiply with log(2)/log(10), yields an approximation for
+ log10(x). */
+ l *= 0.30102999566398119523;
+ /* Round down to the next integer. */
+ return (int) l + (l < 0 ? -1 : 0);
+}
+
+# endif
+
+/* Tests whether a string of digits consists of exactly PRECISION zeroes and
+ a single '1' digit. */
+static int
+is_borderline (const char *digits, size_t precision)
+{
+ for (; precision > 0; precision--, digits++)
+ if (*digits != '0')
+ return 0;
+ if (*digits != '1')
+ return 0;
+ digits++;
+ return *digits == '\0';
+}
+
+#endif
+
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
+
+/* Use a different function name, to make it possible that the 'wchar_t'
+ parametrization and the 'char' parametrization get compiled in the same
+ translation unit. */
+# if WIDE_CHAR_VERSION
+# define MAX_ROOM_NEEDED wmax_room_needed
+# else
+# define MAX_ROOM_NEEDED max_room_needed
+# endif
+
+/* Returns the number of TCHAR_T units needed as temporary space for the result
+ of sprintf or SNPRINTF of a single conversion directive. */
+static size_t
+MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
+ arg_type type, int flags, size_t width, int has_precision,
+ size_t precision, int pad_ourselves)
+{
+ size_t tmp_length;
+
+ switch (conversion)
+ {
+ case 'd': case 'i': case 'u':
+# if HAVE_LONG_LONG_INT
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+# endif
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Multiply by 2, as an estimate for FLAG_GROUP. */
+ tmp_length = xsum (tmp_length, tmp_length);
+ /* Add 1, to account for a leading sign. */
+ tmp_length = xsum (tmp_length, 1);
+ break;
+
+ case 'o':
+# if HAVE_LONG_LONG_INT
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+# endif
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Add 1, to account for a leading sign. */
+ tmp_length = xsum (tmp_length, 1);
+ break;
+
+ case 'x': case 'X':
+# if HAVE_LONG_LONG_INT
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+# endif
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Add 2, to account for a leading sign or alternate form. */
+ tmp_length = xsum (tmp_length, 2);
+ break;
+
+ case 'f': case 'F':
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) (LDBL_MAX_EXP
+ * 0.30103 /* binary -> decimal */
+ * 2 /* estimate for FLAG_GROUP */
+ )
+ + 1 /* turn floor into ceil */
+ + 10; /* sign, decimal point etc. */
+ else
+ tmp_length =
+ (unsigned int) (DBL_MAX_EXP
+ * 0.30103 /* binary -> decimal */
+ * 2 /* estimate for FLAG_GROUP */
+ )
+ + 1 /* turn floor into ceil */
+ + 10; /* sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, precision);
+ break;
+
+ case 'e': case 'E': case 'g': case 'G':
+ tmp_length =
+ 12; /* sign, decimal point, exponent etc. */
+ tmp_length = xsum (tmp_length, precision);
+ break;
+
+ case 'a': case 'A':
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) (LDBL_DIG
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (DBL_DIG
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Account for sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, 12);
+ break;
+
+ case 'c':
+# if HAVE_WINT_T && !WIDE_CHAR_VERSION
+ if (type == TYPE_WIDE_CHAR)
+ tmp_length = MB_CUR_MAX;
+ else
+# endif
+ tmp_length = 1;
+ break;
+
+ case 's':
+# if HAVE_WCHAR_T
+ if (type == TYPE_WIDE_STRING)
+ {
+# if WIDE_CHAR_VERSION
+ /* ISO C says about %ls in fwprintf:
+ "If the precision is not specified or is greater than the size
+ of the array, the array shall contain a null wide character."
+ So if there is a precision, we must not use wcslen. */
+ const wchar_t *arg = ap->arg[arg_index].a.a_wide_string;
+
+ if (has_precision)
+ tmp_length = local_wcsnlen (arg, precision);
+ else
+ tmp_length = local_wcslen (arg);
+# else
+ /* ISO C says about %ls in fprintf:
+ "If a precision is specified, no more than that many bytes are
+ written (including shift sequences, if any), and the array
+ shall contain a null wide character if, to equal the multibyte
+ character sequence length given by the precision, the function
+ would need to access a wide character one past the end of the
+ array."
+ So if there is a precision, we must not use wcslen. */
+ /* This case has already been handled separately in VASNPRINTF. */
+ abort ();
+# endif
+ }
+ else
+# endif
+ {
+# if WIDE_CHAR_VERSION
+ /* ISO C says about %s in fwprintf:
+ "If the precision is not specified or is greater than the size
+ of the converted array, the converted array shall contain a
+ null wide character."
+ So if there is a precision, we must not use strlen. */
+ /* This case has already been handled separately in VASNPRINTF. */
+ abort ();
+# else
+ /* ISO C says about %s in fprintf:
+ "If the precision is not specified or greater than the size of
+ the array, the array shall contain a null character."
+ So if there is a precision, we must not use strlen. */
+ const char *arg = ap->arg[arg_index].a.a_string;
+
+ if (has_precision)
+ tmp_length = local_strnlen (arg, precision);
+ else
+ tmp_length = strlen (arg);
+# endif
+ }
+ break;
+
+ case 'p':
+ tmp_length =
+ (unsigned int) (sizeof (void *) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1 /* turn floor into ceil */
+ + 2; /* account for leading 0x */
+ break;
+
+ default:
+ abort ();
+ }
+
+ if (!pad_ourselves)
+ {
+# if ENABLE_UNISTDIO
+ /* Padding considers the number of characters, therefore the number of
+ elements after padding may be
+ > max (tmp_length, width)
+ but is certainly
+ <= tmp_length + width. */
+ tmp_length = xsum (tmp_length, width);
+# else
+ /* Padding considers the number of elements, says POSIX. */
+ if (tmp_length < width)
+ tmp_length = width;
+# endif
+ }
+
+ tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+
+ return tmp_length;
+}
+
+#endif
+
+DCHAR_T *
+VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
+ const FCHAR_T *format, va_list args)
+{
+ DIRECTIVES d;
+ arguments a;
+
+ if (PRINTF_PARSE (format, &d, &a) < 0)
+ /* errno is already set. */
+ return NULL;
+
+#define CLEANUP() \
+ if (d.dir != d.direct_alloc_dir) \
+ free (d.dir); \
+ if (a.arg != a.direct_alloc_arg) \
+ free (a.arg);
+
+ if (PRINTF_FETCHARGS (args, &a) < 0)
+ {
+ CLEANUP ();
+ errno = EINVAL;
+ return NULL;
+ }
+
+ {
+ size_t buf_neededlength;
+ TCHAR_T *buf;
+ TCHAR_T *buf_malloced;
+ const FCHAR_T *cp;
+ size_t i;
+ DIRECTIVE *dp;
+ /* Output string accumulator. */
+ DCHAR_T *result;
+ size_t allocated;
+ size_t length;
+
+ /* Allocate a small buffer that will hold a directive passed to
+ sprintf or snprintf. */
+ buf_neededlength =
+ xsum4 (7, d.max_width_length, d.max_precision_length, 6);
+#if HAVE_ALLOCA
+ if (buf_neededlength < 4000 / sizeof (TCHAR_T))
+ {
+ buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T));
+ buf_malloced = NULL;
+ }
+ else
+#endif
+ {
+ size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T));
+ if (size_overflow_p (buf_memsize))
+ goto out_of_memory_1;
+ buf = (TCHAR_T *) malloc (buf_memsize);
+ if (buf == NULL)
+ goto out_of_memory_1;
+ buf_malloced = buf;
+ }
+
+ if (resultbuf != NULL)
+ {
+ result = resultbuf;
+ allocated = *lengthp;
+ }
+ else
+ {
+ result = NULL;
+ allocated = 0;
+ }
+ length = 0;
+ /* Invariants:
+ result is either == resultbuf or == NULL or malloc-allocated.
+ If length > 0, then result != NULL. */
+
+ /* Ensures that allocated >= needed. Aborts through a jump to
+ out_of_memory if needed is SIZE_MAX or otherwise too big. */
+#define ENSURE_ALLOCATION(needed) \
+ if ((needed) > allocated) \
+ { \
+ size_t memory_size; \
+ DCHAR_T *memory; \
+ \
+ allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \
+ if ((needed) > allocated) \
+ allocated = (needed); \
+ memory_size = xtimes (allocated, sizeof (DCHAR_T)); \
+ if (size_overflow_p (memory_size)) \
+ goto out_of_memory; \
+ if (result == resultbuf || result == NULL) \
+ memory = (DCHAR_T *) malloc (memory_size); \
+ else \
+ memory = (DCHAR_T *) realloc (result, memory_size); \
+ if (memory == NULL) \
+ goto out_of_memory; \
+ if (result == resultbuf && length > 0) \
+ DCHAR_CPY (memory, result, length); \
+ result = memory; \
+ }
+
+ for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
+ {
+ if (cp != dp->dir_start)
+ {
+ size_t n = dp->dir_start - cp;
+ size_t augmented_length = xsum (length, n);
+
+ ENSURE_ALLOCATION (augmented_length);
+ /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we
+ need that the format string contains only ASCII characters
+ if FCHAR_T and DCHAR_T are not the same type. */
+ if (sizeof (FCHAR_T) == sizeof (DCHAR_T))
+ {
+ DCHAR_CPY (result + length, (const DCHAR_T *) cp, n);
+ length = augmented_length;
+ }
+ else
+ {
+ do
+ result[length++] = *cp++;
+ while (--n > 0);
+ }
+ }
+ if (i == d.count)
+ break;
+
+ /* Execute a single directive. */
+ if (dp->conversion == '%')
+ {
+ size_t augmented_length;
+
+ if (!(dp->arg_index == ARG_NONE))
+ abort ();
+ augmented_length = xsum (length, 1);
+ ENSURE_ALLOCATION (augmented_length);
+ result[length] = '%';
+ length = augmented_length;
+ }
+ else
+ {
+ if (!(dp->arg_index != ARG_NONE))
+ abort ();
+
+ if (dp->conversion == 'n')
+ {
+ switch (a.arg[dp->arg_index].type)
+ {
+ case TYPE_COUNT_SCHAR_POINTER:
+ *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
+ break;
+ case TYPE_COUNT_SHORT_POINTER:
+ *a.arg[dp->arg_index].a.a_count_short_pointer = length;
+ break;
+ case TYPE_COUNT_INT_POINTER:
+ *a.arg[dp->arg_index].a.a_count_int_pointer = length;
+ break;
+ case TYPE_COUNT_LONGINT_POINTER:
+ *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
+ break;
+#if HAVE_LONG_LONG_INT
+ case TYPE_COUNT_LONGLONGINT_POINTER:
+ *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
+ break;
+#endif
+ default:
+ abort ();
+ }
+ }
+#if ENABLE_UNISTDIO
+ /* The unistdio extensions. */
+ else if (dp->conversion == 'U')
+ {
+ arg_type type = a.arg[dp->arg_index].type;
+ int flags = dp->flags;
+ int has_width;
+ size_t width;
+ int has_precision;
+ size_t precision;
+
+ has_width = 0;
+ width = 0;
+ if (dp->width_start != dp->width_end)
+ {
+ if (dp->width_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->width_arg_index].a.a_int;
+ width = arg;
+ if (arg < 0)
+ {
+ /* "A negative field width is taken as a '-' flag
+ followed by a positive field width." */
+ flags |= FLAG_LEFT;
+ width = -width;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->width_start;
+
+ do
+ width = xsum (xtimes (width, 10), *digitp++ - '0');
+ while (digitp != dp->width_end);
+ }
+ has_width = 1;
+ }
+
+ has_precision = 0;
+ precision = 0;
+ if (dp->precision_start != dp->precision_end)
+ {
+ if (dp->precision_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->precision_arg_index].a.a_int;
+ /* "A negative precision is taken as if the precision
+ were omitted." */
+ if (arg >= 0)
+ {
+ precision = arg;
+ has_precision = 1;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->precision_start + 1;
+
+ precision = 0;
+ while (digitp != dp->precision_end)
+ precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+ has_precision = 1;
+ }
+ }
+
+ switch (type)
+ {
+ case TYPE_U8_STRING:
+ {
+ const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string;
+ const uint8_t *arg_end;
+ size_t characters;
+
+ if (has_precision)
+ {
+ /* Use only PRECISION characters, from the left. */
+ arg_end = arg;
+ characters = 0;
+ for (; precision > 0; precision--)
+ {
+ int count = u8_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else if (has_width)
+ {
+ /* Use the entire string, and count the number of
+ characters. */
+ arg_end = arg;
+ characters = 0;
+ for (;;)
+ {
+ int count = u8_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else
+ {
+ /* Use the entire string. */
+ arg_end = arg + u8_strlen (arg);
+ /* The number of characters doesn't matter. */
+ characters = 0;
+ }
+
+ if (characters < width && !(dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+
+# if DCHAR_IS_UINT8_T
+ {
+ size_t n = arg_end - arg;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_CPY (result + length, arg, n);
+ length += n;
+ }
+# else
+ { /* Convert. */
+ DCHAR_T *converted = result + length;
+ size_t converted_len = allocated - length;
+# if DCHAR_IS_TCHAR
+ /* Convert from UTF-8 to locale encoding. */
+ converted =
+ u8_conv_to_encoding (locale_charset (),
+ iconveh_question_mark,
+ arg, arg_end - arg, NULL,
+ converted, &converted_len);
+# else
+ /* Convert from UTF-8 to UTF-16/UTF-32. */
+ converted =
+ U8_TO_DCHAR (arg, arg_end - arg,
+ converted, &converted_len);
+# endif
+ if (converted == NULL)
+ {
+ int saved_errno = errno;
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = saved_errno;
+ return NULL;
+ }
+ if (converted != result + length)
+ {
+ ENSURE_ALLOCATION (xsum (length, converted_len));
+ DCHAR_CPY (result + length, converted, converted_len);
+ free (converted);
+ }
+ length += converted_len;
+ }
+# endif
+
+ if (characters < width && (dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+ }
+ break;
+
+ case TYPE_U16_STRING:
+ {
+ const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string;
+ const uint16_t *arg_end;
+ size_t characters;
+
+ if (has_precision)
+ {
+ /* Use only PRECISION characters, from the left. */
+ arg_end = arg;
+ characters = 0;
+ for (; precision > 0; precision--)
+ {
+ int count = u16_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else if (has_width)
+ {
+ /* Use the entire string, and count the number of
+ characters. */
+ arg_end = arg;
+ characters = 0;
+ for (;;)
+ {
+ int count = u16_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else
+ {
+ /* Use the entire string. */
+ arg_end = arg + u16_strlen (arg);
+ /* The number of characters doesn't matter. */
+ characters = 0;
+ }
+
+ if (characters < width && !(dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+
+# if DCHAR_IS_UINT16_T
+ {
+ size_t n = arg_end - arg;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_CPY (result + length, arg, n);
+ length += n;
+ }
+# else
+ { /* Convert. */
+ DCHAR_T *converted = result + length;
+ size_t converted_len = allocated - length;
+# if DCHAR_IS_TCHAR
+ /* Convert from UTF-16 to locale encoding. */
+ converted =
+ u16_conv_to_encoding (locale_charset (),
+ iconveh_question_mark,
+ arg, arg_end - arg, NULL,
+ converted, &converted_len);
+# else
+ /* Convert from UTF-16 to UTF-8/UTF-32. */
+ converted =
+ U16_TO_DCHAR (arg, arg_end - arg,
+ converted, &converted_len);
+# endif
+ if (converted == NULL)
+ {
+ int saved_errno = errno;
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = saved_errno;
+ return NULL;
+ }
+ if (converted != result + length)
+ {
+ ENSURE_ALLOCATION (xsum (length, converted_len));
+ DCHAR_CPY (result + length, converted, converted_len);
+ free (converted);
+ }
+ length += converted_len;
+ }
+# endif
+
+ if (characters < width && (dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+ }
+ break;
+
+ case TYPE_U32_STRING:
+ {
+ const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string;
+ const uint32_t *arg_end;
+ size_t characters;
+
+ if (has_precision)
+ {
+ /* Use only PRECISION characters, from the left. */
+ arg_end = arg;
+ characters = 0;
+ for (; precision > 0; precision--)
+ {
+ int count = u32_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else if (has_width)
+ {
+ /* Use the entire string, and count the number of
+ characters. */
+ arg_end = arg;
+ characters = 0;
+ for (;;)
+ {
+ int count = u32_strmblen (arg_end);
+ if (count == 0)
+ break;
+ if (count < 0)
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else
+ {
+ /* Use the entire string. */
+ arg_end = arg + u32_strlen (arg);
+ /* The number of characters doesn't matter. */
+ characters = 0;
+ }
+
+ if (characters < width && !(dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+
+# if DCHAR_IS_UINT32_T
+ {
+ size_t n = arg_end - arg;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_CPY (result + length, arg, n);
+ length += n;
+ }
+# else
+ { /* Convert. */
+ DCHAR_T *converted = result + length;
+ size_t converted_len = allocated - length;
+# if DCHAR_IS_TCHAR
+ /* Convert from UTF-32 to locale encoding. */
+ converted =
+ u32_conv_to_encoding (locale_charset (),
+ iconveh_question_mark,
+ arg, arg_end - arg, NULL,
+ converted, &converted_len);
+# else
+ /* Convert from UTF-32 to UTF-8/UTF-16. */
+ converted =
+ U32_TO_DCHAR (arg, arg_end - arg,
+ converted, &converted_len);
+# endif
+ if (converted == NULL)
+ {
+ int saved_errno = errno;
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = saved_errno;
+ return NULL;
+ }
+ if (converted != result + length)
+ {
+ ENSURE_ALLOCATION (xsum (length, converted_len));
+ DCHAR_CPY (result + length, converted, converted_len);
+ free (converted);
+ }
+ length += converted_len;
+ }
+# endif
+
+ if (characters < width && (dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+#endif
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
+ else if (dp->conversion == 's'
+# if WIDE_CHAR_VERSION
+ && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
+# else
+ && a.arg[dp->arg_index].type == TYPE_WIDE_STRING
+# endif
+ )
+ {
+ /* The normal handling of the 's' directive below requires
+ allocating a temporary buffer. The determination of its
+ length (tmp_length), in the case when a precision is
+ specified, below requires a conversion between a char[]
+ string and a wchar_t[] wide string. It could be done, but
+ we have no guarantee that the implementation of sprintf will
+ use the exactly same algorithm. Without this guarantee, it
+ is possible to have buffer overrun bugs. In order to avoid
+ such bugs, we implement the entire processing of the 's'
+ directive ourselves. */
+ int flags = dp->flags;
+ int has_width;
+ size_t width;
+ int has_precision;
+ size_t precision;
+
+ has_width = 0;
+ width = 0;
+ if (dp->width_start != dp->width_end)
+ {
+ if (dp->width_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->width_arg_index].a.a_int;
+ width = arg;
+ if (arg < 0)
+ {
+ /* "A negative field width is taken as a '-' flag
+ followed by a positive field width." */
+ flags |= FLAG_LEFT;
+ width = -width;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->width_start;
+
+ do
+ width = xsum (xtimes (width, 10), *digitp++ - '0');
+ while (digitp != dp->width_end);
+ }
+ has_width = 1;
+ }
+
+ has_precision = 0;
+ precision = 6;
+ if (dp->precision_start != dp->precision_end)
+ {
+ if (dp->precision_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->precision_arg_index].a.a_int;
+ /* "A negative precision is taken as if the precision
+ were omitted." */
+ if (arg >= 0)
+ {
+ precision = arg;
+ has_precision = 1;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->precision_start + 1;
+
+ precision = 0;
+ while (digitp != dp->precision_end)
+ precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+ has_precision = 1;
+ }
+ }
+
+# if WIDE_CHAR_VERSION
+ /* %s in vasnwprintf. See the specification of fwprintf. */
+ {
+ const char *arg = a.arg[dp->arg_index].a.a_string;
+ const char *arg_end;
+ size_t characters;
+
+ if (has_precision)
+ {
+ /* Use only as many bytes as needed to produce PRECISION
+ wide characters, from the left. */
+# if HAVE_MBRTOWC
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
+# endif
+ arg_end = arg;
+ characters = 0;
+ for (; precision > 0; precision--)
+ {
+ int count;
+# if HAVE_MBRTOWC
+ count = mbrlen (arg_end, MB_CUR_MAX, &state);
+# else
+ count = mblen (arg_end, MB_CUR_MAX);
+# endif
+ if (count == 0)
+ /* Found the terminating NUL. */
+ break;
+ if (count < 0)
+ {
+ /* Invalid or incomplete multibyte character. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else if (has_width)
+ {
+ /* Use the entire string, and count the number of wide
+ characters. */
+# if HAVE_MBRTOWC
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
+# endif
+ arg_end = arg;
+ characters = 0;
+ for (;;)
+ {
+ int count;
+# if HAVE_MBRTOWC
+ count = mbrlen (arg_end, MB_CUR_MAX, &state);
+# else
+ count = mblen (arg_end, MB_CUR_MAX);
+# endif
+ if (count == 0)
+ /* Found the terminating NUL. */
+ break;
+ if (count < 0)
+ {
+ /* Invalid or incomplete multibyte character. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end += count;
+ characters++;
+ }
+ }
+ else
+ {
+ /* Use the entire string. */
+ arg_end = arg + strlen (arg);
+ /* The number of characters doesn't matter. */
+ characters = 0;
+ }
+
+ if (characters < width && !(dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+
+ if (has_precision || has_width)
+ {
+ /* We know the number of wide characters in advance. */
+ size_t remaining;
+# if HAVE_MBRTOWC
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
+# endif
+ ENSURE_ALLOCATION (xsum (length, characters));
+ for (remaining = characters; remaining > 0; remaining--)
+ {
+ wchar_t wc;
+ int count;
+# if HAVE_MBRTOWC
+ count = mbrtowc (&wc, arg, arg_end - arg, &state);
+# else
+ count = mbtowc (&wc, arg, arg_end - arg);
+# endif
+ if (count <= 0)
+ /* mbrtowc not consistent with mbrlen, or mbtowc
+ not consistent with mblen. */
+ abort ();
+ result[length++] = wc;
+ arg += count;
+ }
+ if (!(arg == arg_end))
+ abort ();
+ }
+ else
+ {
+# if HAVE_MBRTOWC
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
+# endif
+ while (arg < arg_end)
+ {
+ wchar_t wc;
+ int count;
+# if HAVE_MBRTOWC
+ count = mbrtowc (&wc, arg, arg_end - arg, &state);
+# else
+ count = mbtowc (&wc, arg, arg_end - arg);
+# endif
+ if (count <= 0)
+ /* mbrtowc not consistent with mbrlen, or mbtowc
+ not consistent with mblen. */
+ abort ();
+ ENSURE_ALLOCATION (xsum (length, 1));
+ result[length++] = wc;
+ arg += count;
+ }
+ }
+
+ if (characters < width && (dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - characters;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+ }
+# else
+ /* %ls in vasnprintf. See the specification of fprintf. */
+ {
+ const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
+ const wchar_t *arg_end;
+ size_t characters;
+# if !DCHAR_IS_TCHAR
+ /* This code assumes that TCHAR_T is 'char'. */
+ verify (sizeof (TCHAR_T) == 1);
+ TCHAR_T *tmpsrc;
+ DCHAR_T *tmpdst;
+ size_t tmpdst_len;
+# endif
+ size_t w;
+
+ if (has_precision)
+ {
+ /* Use only as many wide characters as needed to produce
+ at most PRECISION bytes, from the left. */
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
+# endif
+ arg_end = arg;
+ characters = 0;
+ while (precision > 0)
+ {
+ char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
+ int count;
+
+ if (*arg_end == 0)
+ /* Found the terminating null wide character. */
+ break;
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ count = wcrtomb (cbuf, *arg_end, &state);
+# else
+ count = wctomb (cbuf, *arg_end);
+# endif
+ if (count < 0)
+ {
+ /* Cannot convert. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ if (precision < (unsigned int) count)
+ break;
+ arg_end++;
+ characters += count;
+ precision -= count;
+ }
+ }
+# if DCHAR_IS_TCHAR
+ else if (has_width)
+# else
+ else
+# endif
+ {
+ /* Use the entire string, and count the number of
+ bytes. */
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
+# endif
+ arg_end = arg;
+ characters = 0;
+ for (;;)
+ {
+ char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
+ int count;
+
+ if (*arg_end == 0)
+ /* Found the terminating null wide character. */
+ break;
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ count = wcrtomb (cbuf, *arg_end, &state);
+# else
+ count = wctomb (cbuf, *arg_end);
+# endif
+ if (count < 0)
+ {
+ /* Cannot convert. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ arg_end++;
+ characters += count;
+ }
+ }
+# if DCHAR_IS_TCHAR
+ else
+ {
+ /* Use the entire string. */
+ arg_end = arg + local_wcslen (arg);
+ /* The number of bytes doesn't matter. */
+ characters = 0;
+ }
+# endif
+
+# if !DCHAR_IS_TCHAR
+ /* Convert the string into a piece of temporary memory. */
+ tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T));
+ if (tmpsrc == NULL)
+ goto out_of_memory;
+ {
+ TCHAR_T *tmpptr = tmpsrc;
+ size_t remaining;
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
+# endif
+ for (remaining = characters; remaining > 0; )
+ {
+ char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
+ int count;
+
+ if (*arg == 0)
+ abort ();
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ count = wcrtomb (cbuf, *arg, &state);
+# else
+ count = wctomb (cbuf, *arg);
+# endif
+ if (count <= 0)
+ /* Inconsistency. */
+ abort ();
+ memcpy (tmpptr, cbuf, count);
+ tmpptr += count;
+ arg++;
+ remaining -= count;
+ }
+ if (!(arg == arg_end))
+ abort ();
+ }
+
+ /* Convert from TCHAR_T[] to DCHAR_T[]. */
+ tmpdst =
+ DCHAR_CONV_FROM_ENCODING (locale_charset (),
+ iconveh_question_mark,
+ tmpsrc, characters,
+ NULL,
+ NULL, &tmpdst_len);
+ if (tmpdst == NULL)
+ {
+ int saved_errno = errno;
+ free (tmpsrc);
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = saved_errno;
+ return NULL;
+ }
+ free (tmpsrc);
+# endif
+
+ if (has_width)
+ {
+# if ENABLE_UNISTDIO
+ /* Outside POSIX, it's preferable to compare the width
+ against the number of _characters_ of the converted
+ value. */
+ w = DCHAR_MBSNLEN (result + length, characters);
+# else
+ /* The width is compared against the number of _bytes_
+ of the converted value, says POSIX. */
+ w = characters;
+# endif
+ }
+ else
+ /* w doesn't matter. */
+ w = 0;
+
+ if (w < width && !(dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - w;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+
+# if DCHAR_IS_TCHAR
+ if (has_precision || has_width)
+ {
+ /* We know the number of bytes in advance. */
+ size_t remaining;
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
+# endif
+ ENSURE_ALLOCATION (xsum (length, characters));
+ for (remaining = characters; remaining > 0; )
+ {
+ char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
+ int count;
+
+ if (*arg == 0)
+ abort ();
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ count = wcrtomb (cbuf, *arg, &state);
+# else
+ count = wctomb (cbuf, *arg);
+# endif
+ if (count <= 0)
+ /* Inconsistency. */
+ abort ();
+ memcpy (result + length, cbuf, count);
+ length += count;
+ arg++;
+ remaining -= count;
+ }
+ if (!(arg == arg_end))
+ abort ();
+ }
+ else
+ {
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
+# endif
+ while (arg < arg_end)
+ {
+ char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
+ int count;
+
+ if (*arg == 0)
+ abort ();
+# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+ count = wcrtomb (cbuf, *arg, &state);
+# else
+ count = wctomb (cbuf, *arg);
+# endif
+ if (count <= 0)
+ {
+ /* Cannot convert. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
+ ENSURE_ALLOCATION (xsum (length, count));
+ memcpy (result + length, cbuf, count);
+ length += count;
+ arg++;
+ }
+ }
+# else
+ ENSURE_ALLOCATION (xsum (length, tmpdst_len));
+ DCHAR_CPY (result + length, tmpdst, tmpdst_len);
+ free (tmpdst);
+ length += tmpdst_len;
+# endif
+
+ if (w < width && (dp->flags & FLAG_LEFT))
+ {
+ size_t n = width - w;
+ ENSURE_ALLOCATION (xsum (length, n));
+ DCHAR_SET (result + length, ' ', n);
+ length += n;
+ }
+ }
+# endif
+ }
+#endif
+#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
+ else if ((dp->conversion == 'a' || dp->conversion == 'A')
+# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE))
+ && (0
+# if NEED_PRINTF_DOUBLE
+ || a.arg[dp->arg_index].type == TYPE_DOUBLE
+# endif
+# if NEED_PRINTF_LONG_DOUBLE
+ || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
+# endif
+ )
+# endif
+ )
+ {
+ arg_type type = a.arg[dp->arg_index].type;
+ int flags = dp->flags;
+ size_t width;
+ int has_precision;
+ size_t precision;
+ size_t tmp_length;
+ size_t count;
+ DCHAR_T tmpbuf[700];
+ DCHAR_T *tmp;
+ DCHAR_T *pad_ptr;
+ DCHAR_T *p;
+
+ width = 0;
+ if (dp->width_start != dp->width_end)
+ {
+ if (dp->width_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->width_arg_index].a.a_int;
+ width = arg;
+ if (arg < 0)
+ {
+ /* "A negative field width is taken as a '-' flag
+ followed by a positive field width." */
+ flags |= FLAG_LEFT;
+ width = -width;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->width_start;
+
+ do
+ width = xsum (xtimes (width, 10), *digitp++ - '0');
+ while (digitp != dp->width_end);
+ }
+ }
+
+ has_precision = 0;
+ precision = 0;
+ if (dp->precision_start != dp->precision_end)
+ {
+ if (dp->precision_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->precision_arg_index].a.a_int;
+ /* "A negative precision is taken as if the precision
+ were omitted." */
+ if (arg >= 0)
+ {
+ precision = arg;
+ has_precision = 1;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->precision_start + 1;
+
+ precision = 0;
+ while (digitp != dp->precision_end)
+ precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+ has_precision = 1;
+ }
+ }
+
+ /* Allocate a temporary buffer of sufficient size. */
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) ((LDBL_DIG + 1)
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) ((DBL_DIG + 1)
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Account for sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, 12);
+
+ if (tmp_length < width)
+ tmp_length = width;
+
+ tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+
+ if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
+ tmp = tmpbuf;
+ else
+ {
+ size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
+
+ if (size_overflow_p (tmp_memsize))
+ /* Overflow, would lead to out of memory. */
+ goto out_of_memory;
+ tmp = (DCHAR_T *) malloc (tmp_memsize);
+ if (tmp == NULL)
+ /* Out of memory. */
+ goto out_of_memory;
+ }
+
+ pad_ptr = NULL;
+ p = tmp;
+ if (type == TYPE_LONGDOUBLE)
+ {
+# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE
+ long double arg = a.arg[dp->arg_index].a.a_longdouble;
+
+ if (isnanl (arg))
+ {
+ if (dp->conversion == 'A')
+ {
+ *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+ }
+ else
+ {
+ *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+ }
+ }
+ else
+ {
+ int sign = 0;
+ DECL_LONG_DOUBLE_ROUNDING
+
+ BEGIN_LONG_DOUBLE_ROUNDING ();
+
+ if (signbit (arg)) /* arg < 0.0L or negative zero */
+ {
+ sign = -1;
+ arg = -arg;
+ }
+
+ if (sign < 0)
+ *p++ = '-';
+ else if (flags & FLAG_SHOWSIGN)
+ *p++ = '+';
+ else if (flags & FLAG_SPACE)
+ *p++ = ' ';
+
+ if (arg > 0.0L && arg + arg == arg)
+ {
+ if (dp->conversion == 'A')
+ {
+ *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+ }
+ else
+ {
+ *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+ }
+ }
+ else
+ {
+ int exponent;
+ long double mantissa;
+
+ if (arg > 0.0L)
+ mantissa = printf_frexpl (arg, &exponent);
+ else
+ {
+ exponent = 0;
+ mantissa = 0.0L;
+ }
+
+ if (has_precision
+ && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1)
+ {
+ /* Round the mantissa. */
+ long double tail = mantissa;
+ size_t q;
+
+ for (q = precision; ; q--)
+ {
+ int digit = (int) tail;
+ tail -= digit;
+ if (q == 0)
+ {
+ if (digit & 1 ? tail >= 0.5L : tail > 0.5L)
+ tail = 1 - tail;
+ else
+ tail = - tail;
+ break;
+ }
+ tail *= 16.0L;
+ }
+ if (tail != 0.0L)
+ for (q = precision; q > 0; q--)
+ tail *= 0.0625L;
+ mantissa += tail;
+ }
+
+ *p++ = '0';
+ *p++ = dp->conversion - 'A' + 'X';
+ pad_ptr = p;
+ {
+ int digit;
+
+ digit = (int) mantissa;
+ mantissa -= digit;
+ *p++ = '0' + digit;
+ if ((flags & FLAG_ALT)
+ || mantissa > 0.0L || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ /* This loop terminates because we assume
+ that FLT_RADIX is a power of 2. */
+ while (mantissa > 0.0L)
+ {
+ mantissa *= 16.0L;
+ digit = (int) mantissa;
+ mantissa -= digit;
+ *p++ = digit
+ + (digit < 10
+ ? '0'
+ : dp->conversion - 10);
+ if (precision > 0)
+ precision--;
+ }
+ while (precision > 0)
+ {
+ *p++ = '0';
+ precision--;
+ }
+ }
+ }
+ *p++ = dp->conversion - 'A' + 'P';
+# if WIDE_CHAR_VERSION
+ {
+ static const wchar_t decimal_format[] =
+ { '%', '+', 'd', '\0' };
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
+# else
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, "%+d", exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, "%+d", exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
+# endif
+ }
+
+ END_LONG_DOUBLE_ROUNDING ();
+ }
+# else
+ abort ();
+# endif
+ }
+ else
+ {
+# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE
+ double arg = a.arg[dp->arg_index].a.a_double;
+
+ if (isnand (arg))
+ {
+ if (dp->conversion == 'A')
+ {
+ *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+ }
+ else
+ {
+ *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+ }
+ }
+ else
+ {
+ int sign = 0;
+
+ if (signbit (arg)) /* arg < 0.0 or negative zero */
+ {
+ sign = -1;
+ arg = -arg;
+ }
+
+ if (sign < 0)
+ *p++ = '-';
+ else if (flags & FLAG_SHOWSIGN)
+ *p++ = '+';
+ else if (flags & FLAG_SPACE)
+ *p++ = ' ';
+
+ if (arg > 0.0 && arg + arg == arg)
+ {
+ if (dp->conversion == 'A')
+ {
+ *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+ }
+ else
+ {
+ *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+ }
+ }
+ else
+ {
+ int exponent;
+ double mantissa;
+
+ if (arg > 0.0)
+ mantissa = printf_frexp (arg, &exponent);
+ else
+ {
+ exponent = 0;
+ mantissa = 0.0;
+ }
+
+ if (has_precision
+ && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1)
+ {
+ /* Round the mantissa. */
+ double tail = mantissa;
+ size_t q;
+
+ for (q = precision; ; q--)
+ {
+ int digit = (int) tail;
+ tail -= digit;
+ if (q == 0)
+ {
+ if (digit & 1 ? tail >= 0.5 : tail > 0.5)
+ tail = 1 - tail;
+ else
+ tail = - tail;
+ break;
+ }
+ tail *= 16.0;
+ }
+ if (tail != 0.0)
+ for (q = precision; q > 0; q--)
+ tail *= 0.0625;
+ mantissa += tail;
+ }
+
+ *p++ = '0';
+ *p++ = dp->conversion - 'A' + 'X';
+ pad_ptr = p;
+ {
+ int digit;
+
+ digit = (int) mantissa;
+ mantissa -= digit;
+ *p++ = '0' + digit;
+ if ((flags & FLAG_ALT)
+ || mantissa > 0.0 || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ /* This loop terminates because we assume
+ that FLT_RADIX is a power of 2. */
+ while (mantissa > 0.0)
+ {
+ mantissa *= 16.0;
+ digit = (int) mantissa;
+ mantissa -= digit;
+ *p++ = digit
+ + (digit < 10
+ ? '0'
+ : dp->conversion - 10);
+ if (precision > 0)
+ precision--;
+ }
+ while (precision > 0)
+ {
+ *p++ = '0';
+ precision--;
+ }
+ }
+ }
+ *p++ = dp->conversion - 'A' + 'P';
+# if WIDE_CHAR_VERSION
+ {
+ static const wchar_t decimal_format[] =
+ { '%', '+', 'd', '\0' };
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
+# else
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, "%+d", exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, "%+d", exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
+# endif
+ }
+ }
+# else
+ abort ();
+# endif
+ }
+
+ /* The generated string now extends from tmp to p, with the
+ zero padding insertion point being at pad_ptr. */
+ count = p - tmp;
+
+ if (count < width)
+ {
+ size_t pad = width - count;
+ DCHAR_T *end = p + pad;
+
+ if (flags & FLAG_LEFT)
+ {
+ /* Pad with spaces on the right. */
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+ else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
+ {
+ /* Pad with zeroes. */
+ DCHAR_T *q = end;
+
+ while (p > pad_ptr)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = '0';
+ }
+ else
+ {
+ /* Pad with spaces on the left. */
+ DCHAR_T *q = end;
+
+ while (p > tmp)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+
+ p = end;
+ }
+
+ count = p - tmp;
+
+ if (count >= tmp_length)
+ /* tmp_length was incorrectly calculated - fix the
+ code above! */
+ abort ();
+
+ /* Make room for the result. */
+ if (count >= allocated - length)
+ {
+ size_t n = xsum (length, count);
+
+ ENSURE_ALLOCATION (n);
+ }
+
+ /* Append the result. */
+ memcpy (result + length, tmp, count * sizeof (DCHAR_T));
+ if (tmp != tmpbuf)
+ free (tmp);
+ length += count;
+ }
+#endif
+#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
+ else if ((dp->conversion == 'f' || dp->conversion == 'F'
+ || dp->conversion == 'e' || dp->conversion == 'E'
+ || dp->conversion == 'g' || dp->conversion == 'G'
+ || dp->conversion == 'a' || dp->conversion == 'A')
+ && (0
+# if NEED_PRINTF_DOUBLE
+ || a.arg[dp->arg_index].type == TYPE_DOUBLE
+# elif NEED_PRINTF_INFINITE_DOUBLE
+ || (a.arg[dp->arg_index].type == TYPE_DOUBLE
+ /* The systems (mingw) which produce wrong output
+ for Inf, -Inf, and NaN also do so for -0.0.
+ Therefore we treat this case here as well. */
+ && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double))
+# endif
+# if NEED_PRINTF_LONG_DOUBLE
+ || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
+# elif NEED_PRINTF_INFINITE_LONG_DOUBLE
+ || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
+ /* Some systems produce wrong output for Inf,
+ -Inf, and NaN. Some systems in this category
+ (IRIX 5.3) also do so for -0.0. Therefore we
+ treat this case here as well. */
+ && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble))
+# endif
+ ))
+ {
+# if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE)
+ arg_type type = a.arg[dp->arg_index].type;
+# endif
+ int flags = dp->flags;
+ size_t width;
+ size_t count;
+ int has_precision;
+ size_t precision;
+ size_t tmp_length;
+ DCHAR_T tmpbuf[700];
+ DCHAR_T *tmp;
+ DCHAR_T *pad_ptr;
+ DCHAR_T *p;
+
+ width = 0;
+ if (dp->width_start != dp->width_end)
+ {
+ if (dp->width_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->width_arg_index].a.a_int;
+ width = arg;
+ if (arg < 0)
+ {
+ /* "A negative field width is taken as a '-' flag
+ followed by a positive field width." */
+ flags |= FLAG_LEFT;
+ width = -width;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->width_start;
+
+ do
+ width = xsum (xtimes (width, 10), *digitp++ - '0');
+ while (digitp != dp->width_end);
+ }
+ }
+
+ has_precision = 0;
+ precision = 0;
+ if (dp->precision_start != dp->precision_end)
+ {
+ if (dp->precision_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->precision_arg_index].a.a_int;
+ /* "A negative precision is taken as if the precision
+ were omitted." */
+ if (arg >= 0)
+ {
+ precision = arg;
+ has_precision = 1;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->precision_start + 1;
+
+ precision = 0;
+ while (digitp != dp->precision_end)
+ precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+ has_precision = 1;
+ }
+ }
+
+ /* POSIX specifies the default precision to be 6 for %f, %F,
+ %e, %E, but not for %g, %G. Implementations appear to use
+ the same default precision also for %g, %G. But for %a, %A,
+ the default precision is 0. */
+ if (!has_precision)
+ if (!(dp->conversion == 'a' || dp->conversion == 'A'))
+ precision = 6;
+
+ /* Allocate a temporary buffer of sufficient size. */
+# if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE
+ tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1);
+# elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE
+ tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0);
+# elif NEED_PRINTF_LONG_DOUBLE
+ tmp_length = LDBL_DIG + 1;
+# elif NEED_PRINTF_DOUBLE
+ tmp_length = DBL_DIG + 1;
+# else
+ tmp_length = 0;
+# endif
+ if (tmp_length < precision)
+ tmp_length = precision;
+# if NEED_PRINTF_LONG_DOUBLE
+# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
+ if (type == TYPE_LONGDOUBLE)
+# endif
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ long double arg = a.arg[dp->arg_index].a.a_longdouble;
+ if (!(isnanl (arg) || arg + arg == arg))
+ {
+ /* arg is finite and nonzero. */
+ int exponent = floorlog10l (arg < 0 ? -arg : arg);
+ if (exponent >= 0 && tmp_length < exponent + precision)
+ tmp_length = exponent + precision;
+ }
+ }
+# endif
+# if NEED_PRINTF_DOUBLE
+# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
+ if (type == TYPE_DOUBLE)
+# endif
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ double arg = a.arg[dp->arg_index].a.a_double;
+ if (!(isnand (arg) || arg + arg == arg))
+ {
+ /* arg is finite and nonzero. */
+ int exponent = floorlog10 (arg < 0 ? -arg : arg);
+ if (exponent >= 0 && tmp_length < exponent + precision)
+ tmp_length = exponent + precision;
+ }
+ }
+# endif
+ /* Account for sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, 12);
+
+ if (tmp_length < width)
+ tmp_length = width;
+
+ tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+
+ if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
+ tmp = tmpbuf;
+ else
+ {
+ size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
+
+ if (size_overflow_p (tmp_memsize))
+ /* Overflow, would lead to out of memory. */
+ goto out_of_memory;
+ tmp = (DCHAR_T *) malloc (tmp_memsize);
+ if (tmp == NULL)
+ /* Out of memory. */
+ goto out_of_memory;
+ }
+
+ pad_ptr = NULL;
+ p = tmp;
+
+# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
+# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
+ if (type == TYPE_LONGDOUBLE)
+# endif
+ {
+ long double arg = a.arg[dp->arg_index].a.a_longdouble;
+
+ if (isnanl (arg))
+ {
+ if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+ {
+ *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+ }
+ else
+ {
+ *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+ }
+ }
+ else
+ {
+ int sign = 0;
+ DECL_LONG_DOUBLE_ROUNDING
+
+ BEGIN_LONG_DOUBLE_ROUNDING ();
+
+ if (signbit (arg)) /* arg < 0.0L or negative zero */
+ {
+ sign = -1;
+ arg = -arg;
+ }
+
+ if (sign < 0)
+ *p++ = '-';
+ else if (flags & FLAG_SHOWSIGN)
+ *p++ = '+';
+ else if (flags & FLAG_SPACE)
+ *p++ = ' ';
+
+ if (arg > 0.0L && arg + arg == arg)
+ {
+ if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+ {
+ *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+ }
+ else
+ {
+ *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+ }
+ }
+ else
+ {
+# if NEED_PRINTF_LONG_DOUBLE
+ pad_ptr = p;
+
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ char *digits;
+ size_t ndigits;
+
+ digits =
+ scale10_round_decimal_long_double (arg, precision);
+ if (digits == NULL)
+ {
+ END_LONG_DOUBLE_ROUNDING ();
+ goto out_of_memory;
+ }
+ ndigits = strlen (digits);
+
+ if (ndigits > precision)
+ do
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ while (ndigits > precision);
+ else
+ *p++ = '0';
+ /* Here ndigits <= precision. */
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > ndigits; precision--)
+ *p++ = '0';
+ while (ndigits > 0)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+
+ free (digits);
+ }
+ else if (dp->conversion == 'e' || dp->conversion == 'E')
+ {
+ int exponent;
+
+ if (arg == 0.0L)
+ {
+ exponent = 0;
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ }
+ else
+ {
+ /* arg > 0.0L. */
+ int adjusted;
+ char *digits;
+ size_t ndigits;
+
+ exponent = floorlog10l (arg);
+ adjusted = 0;
+ for (;;)
+ {
+ digits =
+ scale10_round_decimal_long_double (arg,
+ (int)precision - exponent);
+ if (digits == NULL)
+ {
+ END_LONG_DOUBLE_ROUNDING ();
+ goto out_of_memory;
+ }
+ ndigits = strlen (digits);
+
+ if (ndigits == precision + 1)
+ break;
+ if (ndigits < precision
+ || ndigits > precision + 2)
+ /* The exponent was not guessed
+ precisely enough. */
+ abort ();
+ if (adjusted)
+ /* None of two values of exponent is
+ the right one. Prevent an endless
+ loop. */
+ abort ();
+ free (digits);
+ if (ndigits == precision)
+ exponent -= 1;
+ else
+ exponent += 1;
+ adjusted = 1;
+ }
+ /* Here ndigits = precision+1. */
+ if (is_borderline (digits, precision))
+ {
+ /* Maybe the exponent guess was too high
+ and a smaller exponent can be reached
+ by turning a 10...0 into 9...9x. */
+ char *digits2 =
+ scale10_round_decimal_long_double (arg,
+ (int)precision - exponent + 1);
+ if (digits2 == NULL)
+ {
+ free (digits);
+ END_LONG_DOUBLE_ROUNDING ();
+ goto out_of_memory;
+ }
+ if (strlen (digits2) == precision + 1)
+ {
+ free (digits);
+ digits = digits2;
+ exponent -= 1;
+ }
+ else
+ free (digits2);
+ }
+ /* Here ndigits = precision+1. */
+
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > 0)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+
+ free (digits);
+ }
+
+ *p++ = dp->conversion; /* 'e' or 'E' */
+# if WIDE_CHAR_VERSION
+ {
+ static const wchar_t decimal_format[] =
+ { '%', '+', '.', '2', 'd', '\0' };
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
+# else
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, "%+.2d", exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, "%+.2d", exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
+# endif
+ }
+ else if (dp->conversion == 'g' || dp->conversion == 'G')
+ {
+ if (precision == 0)
+ precision = 1;
+ /* precision >= 1. */
+
+ if (arg == 0.0L)
+ /* The exponent is 0, >= -4, < precision.
+ Use fixed-point notation. */
+ {
+ size_t ndigits = precision;
+ /* Number of trailing zeroes that have to be
+ dropped. */
+ size_t nzeroes =
+ (flags & FLAG_ALT ? 0 : precision - 1);
+
+ --ndigits;
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = '0';
+ }
+ }
+ }
+ else
+ {
+ /* arg > 0.0L. */
+ int exponent;
+ int adjusted;
+ char *digits;
+ size_t ndigits;
+ size_t nzeroes;
+
+ exponent = floorlog10l (arg);
+ adjusted = 0;
+ for (;;)
+ {
+ digits =
+ scale10_round_decimal_long_double (arg,
+ (int)(precision - 1) - exponent);
+ if (digits == NULL)
+ {
+ END_LONG_DOUBLE_ROUNDING ();
+ goto out_of_memory;
+ }
+ ndigits = strlen (digits);
+
+ if (ndigits == precision)
+ break;
+ if (ndigits < precision - 1
+ || ndigits > precision + 1)
+ /* The exponent was not guessed
+ precisely enough. */
+ abort ();
+ if (adjusted)
+ /* None of two values of exponent is
+ the right one. Prevent an endless
+ loop. */
+ abort ();
+ free (digits);
+ if (ndigits < precision)
+ exponent -= 1;
+ else
+ exponent += 1;
+ adjusted = 1;
+ }
+ /* Here ndigits = precision. */
+ if (is_borderline (digits, precision - 1))
+ {
+ /* Maybe the exponent guess was too high
+ and a smaller exponent can be reached
+ by turning a 10...0 into 9...9x. */
+ char *digits2 =
+ scale10_round_decimal_long_double (arg,
+ (int)(precision - 1) - exponent + 1);
+ if (digits2 == NULL)
+ {
+ free (digits);
+ END_LONG_DOUBLE_ROUNDING ();
+ goto out_of_memory;
+ }
+ if (strlen (digits2) == precision)
+ {
+ free (digits);
+ digits = digits2;
+ exponent -= 1;
+ }
+ else
+ free (digits2);
+ }
+ /* Here ndigits = precision. */
+
+ /* Determine the number of trailing zeroes
+ that have to be dropped. */
+ nzeroes = 0;
+ if ((flags & FLAG_ALT) == 0)
+ while (nzeroes < ndigits
+ && digits[nzeroes] == '0')
+ nzeroes++;
+
+ /* The exponent is now determined. */
+ if (exponent >= -4
+ && exponent < (long)precision)
+ {
+ /* Fixed-point notation:
+ max(exponent,0)+1 digits, then the
+ decimal point, then the remaining
+ digits without trailing zeroes. */
+ if (exponent >= 0)
+ {
+ size_t ecount = exponent + 1;
+ /* Note: count <= precision = ndigits. */
+ for (; ecount > 0; ecount--)
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ }
+ else
+ {
+ size_t ecount = -exponent - 1;
+ *p++ = '0';
+ *p++ = decimal_point_char ();
+ for (; ecount > 0; ecount--)
+ *p++ = '0';
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ }
+ else
+ {
+ /* Exponential notation. */
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
+# if WIDE_CHAR_VERSION
+ {
+ static const wchar_t decimal_format[] =
+ { '%', '+', '.', '2', 'd', '\0' };
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
+# else
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, "%+.2d", exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, "%+.2d", exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
+# endif
+ }
+
+ free (digits);
+ }
+ }
+ else
+ abort ();
+# else
+ /* arg is finite. */
+ if (!(arg == 0.0L))
+ abort ();
+
+ pad_ptr = p;
+
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ }
+ else if (dp->conversion == 'e' || dp->conversion == 'E')
+ {
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ *p++ = dp->conversion; /* 'e' or 'E' */
+ *p++ = '+';
+ *p++ = '0';
+ *p++ = '0';
+ }
+ else if (dp->conversion == 'g' || dp->conversion == 'G')
+ {
+ *p++ = '0';
+ if (flags & FLAG_ALT)
+ {
+ size_t ndigits =
+ (precision > 0 ? precision - 1 : 0);
+ *p++ = decimal_point_char ();
+ for (; ndigits > 0; --ndigits)
+ *p++ = '0';
+ }
+ }
+ else if (dp->conversion == 'a' || dp->conversion == 'A')
+ {
+ *p++ = '0';
+ *p++ = dp->conversion - 'A' + 'X';
+ pad_ptr = p;
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ *p++ = dp->conversion - 'A' + 'P';
+ *p++ = '+';
+ *p++ = '0';
+ }
+ else
+ abort ();
+# endif
+ }
+
+ END_LONG_DOUBLE_ROUNDING ();
+ }
+ }
+# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
+ else
+# endif
+# endif
+# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
+ {
+ double arg = a.arg[dp->arg_index].a.a_double;
+
+ if (isnand (arg))
+ {
+ if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+ {
+ *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+ }
+ else
+ {
+ *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+ }
+ }
+ else
+ {
+ int sign = 0;
+
+ if (signbit (arg)) /* arg < 0.0 or negative zero */
+ {
+ sign = -1;
+ arg = -arg;
+ }
+
+ if (sign < 0)
+ *p++ = '-';
+ else if (flags & FLAG_SHOWSIGN)
+ *p++ = '+';
+ else if (flags & FLAG_SPACE)
+ *p++ = ' ';
+
+ if (arg > 0.0 && arg + arg == arg)
+ {
+ if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+ {
+ *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+ }
+ else
+ {
+ *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+ }
+ }
+ else
+ {
+# if NEED_PRINTF_DOUBLE
+ pad_ptr = p;
+
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ char *digits;
+ size_t ndigits;
+
+ digits =
+ scale10_round_decimal_double (arg, precision);
+ if (digits == NULL)
+ goto out_of_memory;
+ ndigits = strlen (digits);
+
+ if (ndigits > precision)
+ do
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ while (ndigits > precision);
+ else
+ *p++ = '0';
+ /* Here ndigits <= precision. */
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > ndigits; precision--)
+ *p++ = '0';
+ while (ndigits > 0)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+
+ free (digits);
+ }
+ else if (dp->conversion == 'e' || dp->conversion == 'E')
+ {
+ int exponent;
+
+ if (arg == 0.0)
+ {
+ exponent = 0;
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ }
+ else
+ {
+ /* arg > 0.0. */
+ int adjusted;
+ char *digits;
+ size_t ndigits;
+
+ exponent = floorlog10 (arg);
+ adjusted = 0;
+ for (;;)
+ {
+ digits =
+ scale10_round_decimal_double (arg,
+ (int)precision - exponent);
+ if (digits == NULL)
+ goto out_of_memory;
+ ndigits = strlen (digits);
+
+ if (ndigits == precision + 1)
+ break;
+ if (ndigits < precision
+ || ndigits > precision + 2)
+ /* The exponent was not guessed
+ precisely enough. */
+ abort ();
+ if (adjusted)
+ /* None of two values of exponent is
+ the right one. Prevent an endless
+ loop. */
+ abort ();
+ free (digits);
+ if (ndigits == precision)
+ exponent -= 1;
+ else
+ exponent += 1;
+ adjusted = 1;
+ }
+ /* Here ndigits = precision+1. */
+ if (is_borderline (digits, precision))
+ {
+ /* Maybe the exponent guess was too high
+ and a smaller exponent can be reached
+ by turning a 10...0 into 9...9x. */
+ char *digits2 =
+ scale10_round_decimal_double (arg,
+ (int)precision - exponent + 1);
+ if (digits2 == NULL)
+ {
+ free (digits);
+ goto out_of_memory;
+ }
+ if (strlen (digits2) == precision + 1)
+ {
+ free (digits);
+ digits = digits2;
+ exponent -= 1;
+ }
+ else
+ free (digits2);
+ }
+ /* Here ndigits = precision+1. */
+
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > 0)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+
+ free (digits);
+ }
+
+ *p++ = dp->conversion; /* 'e' or 'E' */
+# if WIDE_CHAR_VERSION
+ {
+ static const wchar_t decimal_format[] =
+ /* Produce the same number of exponent digits
+ as the native printf implementation. */
+# if defined _WIN32 && ! defined __CYGWIN__
+ { '%', '+', '.', '3', 'd', '\0' };
+# else
+ { '%', '+', '.', '2', 'd', '\0' };
+# endif
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
+# else
+ {
+ static const char decimal_format[] =
+ /* Produce the same number of exponent digits
+ as the native printf implementation. */
+# if defined _WIN32 && ! defined __CYGWIN__
+ "%+.3d";
+# else
+ "%+.2d";
+# endif
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, decimal_format, exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, decimal_format, exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
+ }
+# endif
+ }
+ else if (dp->conversion == 'g' || dp->conversion == 'G')
+ {
+ if (precision == 0)
+ precision = 1;
+ /* precision >= 1. */
+
+ if (arg == 0.0)
+ /* The exponent is 0, >= -4, < precision.
+ Use fixed-point notation. */
+ {
+ size_t ndigits = precision;
+ /* Number of trailing zeroes that have to be
+ dropped. */
+ size_t nzeroes =
+ (flags & FLAG_ALT ? 0 : precision - 1);
+
+ --ndigits;
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = '0';
+ }
+ }
+ }
+ else
+ {
+ /* arg > 0.0. */
+ int exponent;
+ int adjusted;
+ char *digits;
+ size_t ndigits;
+ size_t nzeroes;
+
+ exponent = floorlog10 (arg);
+ adjusted = 0;
+ for (;;)
+ {
+ digits =
+ scale10_round_decimal_double (arg,
+ (int)(precision - 1) - exponent);
+ if (digits == NULL)
+ goto out_of_memory;
+ ndigits = strlen (digits);
+
+ if (ndigits == precision)
+ break;
+ if (ndigits < precision - 1
+ || ndigits > precision + 1)
+ /* The exponent was not guessed
+ precisely enough. */
+ abort ();
+ if (adjusted)
+ /* None of two values of exponent is
+ the right one. Prevent an endless
+ loop. */
+ abort ();
+ free (digits);
+ if (ndigits < precision)
+ exponent -= 1;
+ else
+ exponent += 1;
+ adjusted = 1;
+ }
+ /* Here ndigits = precision. */
+ if (is_borderline (digits, precision - 1))
+ {
+ /* Maybe the exponent guess was too high
+ and a smaller exponent can be reached
+ by turning a 10...0 into 9...9x. */
+ char *digits2 =
+ scale10_round_decimal_double (arg,
+ (int)(precision - 1) - exponent + 1);
+ if (digits2 == NULL)
+ {
+ free (digits);
+ goto out_of_memory;
+ }
+ if (strlen (digits2) == precision)
+ {
+ free (digits);
+ digits = digits2;
+ exponent -= 1;
+ }
+ else
+ free (digits2);
+ }
+ /* Here ndigits = precision. */
+
+ /* Determine the number of trailing zeroes
+ that have to be dropped. */
+ nzeroes = 0;
+ if ((flags & FLAG_ALT) == 0)
+ while (nzeroes < ndigits
+ && digits[nzeroes] == '0')
+ nzeroes++;
+
+ /* The exponent is now determined. */
+ if (exponent >= -4
+ && exponent < (long)precision)
+ {
+ /* Fixed-point notation:
+ max(exponent,0)+1 digits, then the
+ decimal point, then the remaining
+ digits without trailing zeroes. */
+ if (exponent >= 0)
+ {
+ size_t ecount = exponent + 1;
+ /* Note: ecount <= precision = ndigits. */
+ for (; ecount > 0; ecount--)
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ }
+ else
+ {
+ size_t ecount = -exponent - 1;
+ *p++ = '0';
+ *p++ = decimal_point_char ();
+ for (; ecount > 0; ecount--)
+ *p++ = '0';
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ }
+ else
+ {
+ /* Exponential notation. */
+ *p++ = digits[--ndigits];
+ if ((flags & FLAG_ALT) || ndigits > nzeroes)
+ {
+ *p++ = decimal_point_char ();
+ while (ndigits > nzeroes)
+ {
+ --ndigits;
+ *p++ = digits[ndigits];
+ }
+ }
+ *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
+# if WIDE_CHAR_VERSION
+ {
+ static const wchar_t decimal_format[] =
+ /* Produce the same number of exponent digits
+ as the native printf implementation. */
+# if defined _WIN32 && ! defined __CYGWIN__
+ { '%', '+', '.', '3', 'd', '\0' };
+# else
+ { '%', '+', '.', '2', 'd', '\0' };
+# endif
+ SNPRINTF (p, 6 + 1, decimal_format, exponent);
+ }
+ while (*p != '\0')
+ p++;
+# else
+ {
+ static const char decimal_format[] =
+ /* Produce the same number of exponent digits
+ as the native printf implementation. */
+# if defined _WIN32 && ! defined __CYGWIN__
+ "%+.3d";
+# else
+ "%+.2d";
+# endif
+ if (sizeof (DCHAR_T) == 1)
+ {
+ sprintf ((char *) p, decimal_format, exponent);
+ while (*p != '\0')
+ p++;
+ }
+ else
+ {
+ char expbuf[6 + 1];
+ const char *ep;
+ sprintf (expbuf, decimal_format, exponent);
+ for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+ p++;
+ }
+ }
+# endif
+ }
+
+ free (digits);
+ }
+ }
+ else
+ abort ();
+# else
+ /* arg is finite. */
+ if (!(arg == 0.0))
+ abort ();
+
+ pad_ptr = p;
+
+ if (dp->conversion == 'f' || dp->conversion == 'F')
+ {
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ }
+ else if (dp->conversion == 'e' || dp->conversion == 'E')
+ {
+ *p++ = '0';
+ if ((flags & FLAG_ALT) || precision > 0)
+ {
+ *p++ = decimal_point_char ();
+ for (; precision > 0; precision--)
+ *p++ = '0';
+ }
+ *p++ = dp->conversion; /* 'e' or 'E' */
+ *p++ = '+';
+ /* Produce the same number of exponent digits as
+ the native printf implementation. */
+# if defined _WIN32 && ! defined __CYGWIN__
+ *p++ = '0';
+# endif
+ *p++ = '0';
+ *p++ = '0';
+ }
+ else if (dp->conversion == 'g' || dp->conversion == 'G')
+ {
+ *p++ = '0';
+ if (flags & FLAG_ALT)
+ {
+ size_t ndigits =
+ (precision > 0 ? precision - 1 : 0);
+ *p++ = decimal_point_char ();
+ for (; ndigits > 0; --ndigits)
+ *p++ = '0';
+ }
+ }
+ else
+ abort ();
+# endif
+ }
+ }
+ }
+# endif
+
+ /* The generated string now extends from tmp to p, with the
+ zero padding insertion point being at pad_ptr. */
+ count = p - tmp;
+
+ if (count < width)
+ {
+ size_t pad = width - count;
+ DCHAR_T *end = p + pad;
+
+ if (flags & FLAG_LEFT)
+ {
+ /* Pad with spaces on the right. */
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+ else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
+ {
+ /* Pad with zeroes. */
+ DCHAR_T *q = end;
+
+ while (p > pad_ptr)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = '0';
+ }
+ else
+ {
+ /* Pad with spaces on the left. */
+ DCHAR_T *q = end;
+
+ while (p > tmp)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+
+ p = end;
+ }
+
+ count = p - tmp;
+
+ if (count >= tmp_length)
+ /* tmp_length was incorrectly calculated - fix the
+ code above! */
+ abort ();
+
+ /* Make room for the result. */
+ if (count >= allocated - length)
+ {
+ size_t n = xsum (length, count);
+
+ ENSURE_ALLOCATION (n);
+ }
+
+ /* Append the result. */
+ memcpy (result + length, tmp, count * sizeof (DCHAR_T));
+ if (tmp != tmpbuf)
+ free (tmp);
+ length += count;
+ }
+#endif
+ else
+ {
+ arg_type type = a.arg[dp->arg_index].type;
+ int flags = dp->flags;
+#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+ int has_width;
+#endif
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+ size_t width;
+#endif
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
+ int has_precision;
+ size_t precision;
+#endif
+#if NEED_PRINTF_UNBOUNDED_PRECISION
+ int prec_ourselves;
+#else
+# define prec_ourselves 0
+#endif
+#if NEED_PRINTF_FLAG_LEFTADJUST
+# define pad_ourselves 1
+#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+ int pad_ourselves;
+#else
+# define pad_ourselves 0
+#endif
+ TCHAR_T *fbp;
+ unsigned int prefix_count;
+ int prefixes[2] IF_LINT (= { 0 });
+ int orig_errno;
+#if !USE_SNPRINTF
+ size_t tmp_length;
+ TCHAR_T tmpbuf[700];
+ TCHAR_T *tmp;
+#endif
+
+#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+ has_width = 0;
+#endif
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+ width = 0;
+ if (dp->width_start != dp->width_end)
+ {
+ if (dp->width_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->width_arg_index].a.a_int;
+ width = arg;
+ if (arg < 0)
+ {
+ /* "A negative field width is taken as a '-' flag
+ followed by a positive field width." */
+ flags |= FLAG_LEFT;
+ width = -width;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->width_start;
+
+ do
+ width = xsum (xtimes (width, 10), *digitp++ - '0');
+ while (digitp != dp->width_end);
+ }
+#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+ has_width = 1;
+#endif
+ }
+#endif
+
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
+ has_precision = 0;
+ precision = 6;
+ if (dp->precision_start != dp->precision_end)
+ {
+ if (dp->precision_arg_index != ARG_NONE)
+ {
+ int arg;
+
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ arg = a.arg[dp->precision_arg_index].a.a_int;
+ /* "A negative precision is taken as if the precision
+ were omitted." */
+ if (arg >= 0)
+ {
+ precision = arg;
+ has_precision = 1;
+ }
+ }
+ else
+ {
+ const FCHAR_T *digitp = dp->precision_start + 1;
+
+ precision = 0;
+ while (digitp != dp->precision_end)
+ precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+ has_precision = 1;
+ }
+ }
+#endif
+
+ /* Decide whether to handle the precision ourselves. */
+#if NEED_PRINTF_UNBOUNDED_PRECISION
+ switch (dp->conversion)
+ {
+ case 'd': case 'i': case 'u':
+ case 'o':
+ case 'x': case 'X': case 'p':
+ prec_ourselves = has_precision && (precision > 0);
+ break;
+ default:
+ prec_ourselves = 0;
+ break;
+ }
+#endif
+
+ /* Decide whether to perform the padding ourselves. */
+#if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION)
+ switch (dp->conversion)
+ {
+# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
+ /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need
+ to perform the padding after this conversion. Functions
+ with unistdio extensions perform the padding based on
+ character count rather than element count. */
+ case 'c': case 's':
+# endif
+# if NEED_PRINTF_FLAG_ZERO
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
+ case 'a': case 'A':
+# endif
+ pad_ourselves = 1;
+ break;
+ default:
+ pad_ourselves = prec_ourselves;
+ break;
+ }
+#endif
+
+#if !USE_SNPRINTF
+ /* Allocate a temporary buffer of sufficient size for calling
+ sprintf. */
+ tmp_length =
+ MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type,
+ flags, width, has_precision, precision,
+ pad_ourselves);
+
+ if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T))
+ tmp = tmpbuf;
+ else
+ {
+ size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T));
+
+ if (size_overflow_p (tmp_memsize))
+ /* Overflow, would lead to out of memory. */
+ goto out_of_memory;
+ tmp = (TCHAR_T *) malloc (tmp_memsize);
+ if (tmp == NULL)
+ /* Out of memory. */
+ goto out_of_memory;
+ }
+#endif
+
+ /* Construct the format string for calling snprintf or
+ sprintf. */
+ fbp = buf;
+ *fbp++ = '%';
+#if NEED_PRINTF_FLAG_GROUPING
+ /* The underlying implementation doesn't support the ' flag.
+ Produce no grouping characters in this case; this is
+ acceptable because the grouping is locale dependent. */
+#else
+ if (flags & FLAG_GROUP)
+ *fbp++ = '\'';
+#endif
+ if (flags & FLAG_LEFT)
+ *fbp++ = '-';
+ if (flags & FLAG_SHOWSIGN)
+ *fbp++ = '+';
+ if (flags & FLAG_SPACE)
+ *fbp++ = ' ';
+ if (flags & FLAG_ALT)
+ *fbp++ = '#';
+#if __GLIBC__ >= 2 && !defined __UCLIBC__
+ if (flags & FLAG_LOCALIZED)
+ *fbp++ = 'I';
+#endif
+ if (!pad_ourselves)
+ {
+ if (flags & FLAG_ZERO)
+ *fbp++ = '0';
+ if (dp->width_start != dp->width_end)
+ {
+ size_t n = dp->width_end - dp->width_start;
+ /* The width specification is known to consist only
+ of standard ASCII characters. */
+ if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
+ {
+ memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T));
+ fbp += n;
+ }
+ else
+ {
+ const FCHAR_T *mp = dp->width_start;
+ do
+ *fbp++ = *mp++;
+ while (--n > 0);
+ }
+ }
+ }
+ if (!prec_ourselves)
+ {
+ if (dp->precision_start != dp->precision_end)
+ {
+ size_t n = dp->precision_end - dp->precision_start;
+ /* The precision specification is known to consist only
+ of standard ASCII characters. */
+ if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
+ {
+ memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T));
+ fbp += n;
+ }
+ else
+ {
+ const FCHAR_T *mp = dp->precision_start;
+ do
+ *fbp++ = *mp++;
+ while (--n > 0);
+ }
+ }
+ }
+
+ switch (type)
+ {
+#if HAVE_LONG_LONG_INT
+ case TYPE_LONGLONGINT:
+ case TYPE_ULONGLONGINT:
+# if defined _WIN32 && ! defined __CYGWIN__
+ *fbp++ = 'I';
+ *fbp++ = '6';
+ *fbp++ = '4';
+ break;
+# else
+ *fbp++ = 'l';
+# endif
+#endif
+ FALLTHROUGH;
+ case TYPE_LONGINT:
+ case TYPE_ULONGINT:
+#if HAVE_WINT_T
+ case TYPE_WIDE_CHAR:
+#endif
+#if HAVE_WCHAR_T
+ case TYPE_WIDE_STRING:
+#endif
+ *fbp++ = 'l';
+ break;
+ case TYPE_LONGDOUBLE:
+ *fbp++ = 'L';
+ break;
+ default:
+ break;
+ }
+#if NEED_PRINTF_DIRECTIVE_F
+ if (dp->conversion == 'F')
+ *fbp = 'f';
+ else
+#endif
+ *fbp = dp->conversion;
+#if USE_SNPRINTF
+# if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \
+ && !defined __UCLIBC__) \
+ || (defined __APPLE__ && defined __MACH__) \
+ || (defined _WIN32 && ! defined __CYGWIN__))
+ fbp[1] = '%';
+ fbp[2] = 'n';
+ fbp[3] = '\0';
+# else
+ /* On glibc2 systems from glibc >= 2.3 - probably also older
+ ones - we know that snprintf's return value conforms to
+ ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and
+ gl_SNPRINTF_TRUNCATION_C99 pass.
+ Therefore we can avoid using %n in this situation.
+ On glibc2 systems from 2004-10-18 or newer, the use of %n
+ in format strings in writable memory may crash the program
+ (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
+ in this situation. */
+ /* On Mac OS X 10.3 or newer, we know that snprintf's return
+ value conforms to ISO C 99: the tests gl_SNPRINTF_RETVAL_C99
+ and gl_SNPRINTF_TRUNCATION_C99 pass.
+ Therefore we can avoid using %n in this situation.
+ On Mac OS X 10.13 or newer, the use of %n in format strings
+ in writable memory by default crashes the program, so we
+ should avoid it in this situation. */
+ /* On native Windows systems (such as mingw), we can avoid using
+ %n because:
+ - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
+ snprintf does not write more than the specified number
+ of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes
+ '4', '5', '6' into buf, not '4', '5', '\0'.)
+ - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf
+ allows us to recognize the case of an insufficient
+ buffer size: it returns -1 in this case.
+ On native Windows systems (such as mingw) where the OS is
+ Windows Vista, the use of %n in format strings by default
+ crashes the program. See
+ <https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
+ <https://msdn.microsoft.com/en-us/library/ms175782.aspx>
+ So we should avoid %n in this situation. */
+ fbp[1] = '\0';
+# endif
+#else
+ fbp[1] = '\0';
+#endif
+
+ /* Construct the arguments for calling snprintf or sprintf. */
+ prefix_count = 0;
+ if (!pad_ourselves && dp->width_arg_index != ARG_NONE)
+ {
+ if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+ abort ();
+ prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
+ }
+ if (!prec_ourselves && dp->precision_arg_index != ARG_NONE)
+ {
+ if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+ abort ();
+ prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int;
+ }
+
+#if USE_SNPRINTF
+ /* The SNPRINTF result is appended after result[0..length].
+ The latter is an array of DCHAR_T; SNPRINTF appends an
+ array of TCHAR_T to it. This is possible because
+ sizeof (TCHAR_T) divides sizeof (DCHAR_T) and
+ alignof (TCHAR_T) <= alignof (DCHAR_T). */
+# define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T))
+ /* Ensure that maxlen below will be >= 2. Needed on BeOS,
+ where an snprintf() with maxlen==1 acts like sprintf(). */
+ ENSURE_ALLOCATION (xsum (length,
+ (2 + TCHARS_PER_DCHAR - 1)
+ / TCHARS_PER_DCHAR));
+ /* Prepare checking whether snprintf returns the count
+ via %n. */
+ *(TCHAR_T *) (result + length) = '\0';
+#endif
+
+ orig_errno = errno;
+
+ for (;;)
+ {
+ int count = -1;
+
+#if USE_SNPRINTF
+ int retcount = 0;
+ size_t maxlen = allocated - length;
+ /* SNPRINTF can fail if its second argument is
+ > INT_MAX. */
+ if (maxlen > INT_MAX / TCHARS_PER_DCHAR)
+ maxlen = INT_MAX / TCHARS_PER_DCHAR;
+ maxlen = maxlen * TCHARS_PER_DCHAR;
+# define SNPRINTF_BUF(arg) \
+ switch (prefix_count) \
+ { \
+ case 0: \
+ retcount = SNPRINTF ((TCHAR_T *) (result + length), \
+ maxlen, buf, \
+ arg, &count); \
+ break; \
+ case 1: \
+ retcount = SNPRINTF ((TCHAR_T *) (result + length), \
+ maxlen, buf, \
+ prefixes[0], arg, &count); \
+ break; \
+ case 2: \
+ retcount = SNPRINTF ((TCHAR_T *) (result + length), \
+ maxlen, buf, \
+ prefixes[0], prefixes[1], arg, \
+ &count); \
+ break; \
+ default: \
+ abort (); \
+ }
+#else
+# define SNPRINTF_BUF(arg) \
+ switch (prefix_count) \
+ { \
+ case 0: \
+ count = sprintf (tmp, buf, arg); \
+ break; \
+ case 1: \
+ count = sprintf (tmp, buf, prefixes[0], arg); \
+ break; \
+ case 2: \
+ count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
+ arg); \
+ break; \
+ default: \
+ abort (); \
+ }
+#endif
+
+ errno = 0;
+ switch (type)
+ {
+ case TYPE_SCHAR:
+ {
+ int arg = a.arg[dp->arg_index].a.a_schar;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_UCHAR:
+ {
+ unsigned int arg = a.arg[dp->arg_index].a.a_uchar;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_SHORT:
+ {
+ int arg = a.arg[dp->arg_index].a.a_short;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_USHORT:
+ {
+ unsigned int arg = a.arg[dp->arg_index].a.a_ushort;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_INT:
+ {
+ int arg = a.arg[dp->arg_index].a.a_int;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_UINT:
+ {
+ unsigned int arg = a.arg[dp->arg_index].a.a_uint;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_LONGINT:
+ {
+ long int arg = a.arg[dp->arg_index].a.a_longint;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_ULONGINT:
+ {
+ unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+#if HAVE_LONG_LONG_INT
+ case TYPE_LONGLONGINT:
+ {
+ long long int arg = a.arg[dp->arg_index].a.a_longlongint;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_ULONGLONGINT:
+ {
+ unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+#endif
+ case TYPE_DOUBLE:
+ {
+ double arg = a.arg[dp->arg_index].a.a_double;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_LONGDOUBLE:
+ {
+ long double arg = a.arg[dp->arg_index].a.a_longdouble;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ case TYPE_CHAR:
+ {
+ int arg = a.arg[dp->arg_index].a.a_char;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+#if HAVE_WINT_T
+ case TYPE_WIDE_CHAR:
+ {
+ wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+#endif
+ case TYPE_STRING:
+ {
+ const char *arg = a.arg[dp->arg_index].a.a_string;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+#if HAVE_WCHAR_T
+ case TYPE_WIDE_STRING:
+ {
+ const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+#endif
+ case TYPE_POINTER:
+ {
+ void *arg = a.arg[dp->arg_index].a.a_pointer;
+ SNPRINTF_BUF (arg);
+ }
+ break;
+ default:
+ abort ();
+ }
+
+#if USE_SNPRINTF
+ /* Portability: Not all implementations of snprintf()
+ are ISO C 99 compliant. Determine the number of
+ bytes that snprintf() has produced or would have
+ produced. */
+ if (count >= 0)
+ {
+ /* Verify that snprintf() has NUL-terminated its
+ result. */
+ if ((unsigned int) count < maxlen
+ && ((TCHAR_T *) (result + length)) [count] != '\0')
+ abort ();
+ /* Portability hack. */
+ if (retcount > count)
+ count = retcount;
+ }
+ else
+ {
+ /* snprintf() doesn't understand the '%n'
+ directive. */
+ if (fbp[1] != '\0')
+ {
+ /* Don't use the '%n' directive; instead, look
+ at the snprintf() return value. */
+ fbp[1] = '\0';
+ continue;
+ }
+ else
+ {
+ /* Look at the snprintf() return value. */
+ if (retcount < 0)
+ {
+# if !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
+ /* HP-UX 10.20 snprintf() is doubly deficient:
+ It doesn't understand the '%n' directive,
+ *and* it returns -1 (rather than the length
+ that would have been required) when the
+ buffer is too small.
+ But a failure at this point can also come
+ from other reasons than a too small buffer,
+ such as an invalid wide string argument to
+ the %ls directive, or possibly an invalid
+ floating-point argument. */
+ size_t tmp_length =
+ MAX_ROOM_NEEDED (&a, dp->arg_index,
+ dp->conversion, type, flags,
+ width,
+ has_precision,
+ precision, pad_ourselves);
+
+ if (maxlen < tmp_length)
+ {
+ /* Make more room. But try to do through
+ this reallocation only once. */
+ size_t bigger_need =
+ xsum (length,
+ xsum (tmp_length,
+ TCHARS_PER_DCHAR - 1)
+ / TCHARS_PER_DCHAR);
+ /* And always grow proportionally.
+ (There may be several arguments, each
+ needing a little more room than the
+ previous one.) */
+ size_t bigger_need2 =
+ xsum (xtimes (allocated, 2), 12);
+ if (bigger_need < bigger_need2)
+ bigger_need = bigger_need2;
+ ENSURE_ALLOCATION (bigger_need);
+ continue;
+ }
+# endif
+ }
+ else
+ count = retcount;
+ }
+ }
+#endif
+
+ /* Attempt to handle failure. */
+ if (count < 0)
+ {
+ /* SNPRINTF or sprintf failed. Save and use the errno
+ that it has set, if any. */
+ int saved_errno = errno;
+ if (saved_errno == 0)
+ {
+ if (dp->conversion == 'c' || dp->conversion == 's')
+ saved_errno = EILSEQ;
+ else
+ saved_errno = EINVAL;
+ }
+
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+
+ errno = saved_errno;
+ return NULL;
+ }
+
+#if USE_SNPRINTF
+ /* Handle overflow of the allocated buffer.
+ If such an overflow occurs, a C99 compliant snprintf()
+ returns a count >= maxlen. However, a non-compliant
+ snprintf() function returns only count = maxlen - 1. To
+ cover both cases, test whether count >= maxlen - 1. */
+ if ((unsigned int) count + 1 >= maxlen)
+ {
+ /* If maxlen already has attained its allowed maximum,
+ allocating more memory will not increase maxlen.
+ Instead of looping, bail out. */
+ if (maxlen == INT_MAX / TCHARS_PER_DCHAR)
+ goto overflow;
+ else
+ {
+ /* Need at least (count + 1) * sizeof (TCHAR_T)
+ bytes. (The +1 is for the trailing NUL.)
+ But ask for (count + 2) * sizeof (TCHAR_T)
+ bytes, so that in the next round, we likely get
+ maxlen > (unsigned int) count + 1
+ and so we don't get here again.
+ And allocate proportionally, to avoid looping
+ eternally if snprintf() reports a too small
+ count. */
+ size_t n =
+ xmax (xsum (length,
+ ((unsigned int) count + 2
+ + TCHARS_PER_DCHAR - 1)
+ / TCHARS_PER_DCHAR),
+ xtimes (allocated, 2));
+
+ ENSURE_ALLOCATION (n);
+ continue;
+ }
+ }
+#endif
+
+#if NEED_PRINTF_UNBOUNDED_PRECISION
+ if (prec_ourselves)
+ {
+ /* Handle the precision. */
+ TCHAR_T *prec_ptr =
+# if USE_SNPRINTF
+ (TCHAR_T *) (result + length);
+# else
+ tmp;
+# endif
+ size_t prefix_count;
+ size_t move;
+
+ prefix_count = 0;
+ /* Put the additional zeroes after the sign. */
+ if (count >= 1
+ && (*prec_ptr == '-' || *prec_ptr == '+'
+ || *prec_ptr == ' '))
+ prefix_count = 1;
+ /* Put the additional zeroes after the 0x prefix if
+ (flags & FLAG_ALT) || (dp->conversion == 'p'). */
+ else if (count >= 2
+ && prec_ptr[0] == '0'
+ && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X'))
+ prefix_count = 2;
+
+ move = count - prefix_count;
+ if (precision > move)
+ {
+ /* Insert zeroes. */
+ size_t insert = precision - move;
+ TCHAR_T *prec_end;
+
+# if USE_SNPRINTF
+ size_t n =
+ xsum (length,
+ (count + insert + TCHARS_PER_DCHAR - 1)
+ / TCHARS_PER_DCHAR);
+ length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
+ ENSURE_ALLOCATION (n);
+ length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
+ prec_ptr = (TCHAR_T *) (result + length);
+# endif
+
+ prec_end = prec_ptr + count;
+ prec_ptr += prefix_count;
+
+ while (prec_end > prec_ptr)
+ {
+ prec_end--;
+ prec_end[insert] = prec_end[0];
+ }
+
+ prec_end += insert;
+ do
+ *--prec_end = '0';
+ while (prec_end > prec_ptr);
+
+ count += insert;
+ }
+ }
+#endif
+
+#if !USE_SNPRINTF
+ if (count >= tmp_length)
+ /* tmp_length was incorrectly calculated - fix the
+ code above! */
+ abort ();
+#endif
+
+#if !DCHAR_IS_TCHAR
+ /* Convert from TCHAR_T[] to DCHAR_T[]. */
+ if (dp->conversion == 'c' || dp->conversion == 's')
+ {
+ /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING
+ TYPE_WIDE_STRING.
+ The result string is not certainly ASCII. */
+ const TCHAR_T *tmpsrc;
+ DCHAR_T *tmpdst;
+ size_t tmpdst_len;
+ /* This code assumes that TCHAR_T is 'char'. */
+ verify (sizeof (TCHAR_T) == 1);
+# if USE_SNPRINTF
+ tmpsrc = (TCHAR_T *) (result + length);
+# else
+ tmpsrc = tmp;
+# endif
+ tmpdst =
+ DCHAR_CONV_FROM_ENCODING (locale_charset (),
+ iconveh_question_mark,
+ tmpsrc, count,
+ NULL,
+ NULL, &tmpdst_len);
+ if (tmpdst == NULL)
+ {
+ int saved_errno = errno;
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = saved_errno;
+ return NULL;
+ }
+ ENSURE_ALLOCATION (xsum (length, tmpdst_len));
+ DCHAR_CPY (result + length, tmpdst, tmpdst_len);
+ free (tmpdst);
+ count = tmpdst_len;
+ }
+ else
+ {
+ /* The result string is ASCII.
+ Simple 1:1 conversion. */
+# if USE_SNPRINTF
+ /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a
+ no-op conversion, in-place on the array starting
+ at (result + length). */
+ if (sizeof (DCHAR_T) != sizeof (TCHAR_T))
+# endif
+ {
+ const TCHAR_T *tmpsrc;
+ DCHAR_T *tmpdst;
+ size_t n;
+
+# if USE_SNPRINTF
+ if (result == resultbuf)
+ {
+ tmpsrc = (TCHAR_T *) (result + length);
+ /* ENSURE_ALLOCATION will not move tmpsrc
+ (because it's part of resultbuf). */
+ ENSURE_ALLOCATION (xsum (length, count));
+ }
+ else
+ {
+ /* ENSURE_ALLOCATION will move the array
+ (because it uses realloc(). */
+ ENSURE_ALLOCATION (xsum (length, count));
+ tmpsrc = (TCHAR_T *) (result + length);
+ }
+# else
+ tmpsrc = tmp;
+ ENSURE_ALLOCATION (xsum (length, count));
+# endif
+ tmpdst = result + length;
+ /* Copy backwards, because of overlapping. */
+ tmpsrc += count;
+ tmpdst += count;
+ for (n = count; n > 0; n--)
+ *--tmpdst = *--tmpsrc;
+ }
+ }
+#endif
+
+#if DCHAR_IS_TCHAR && !USE_SNPRINTF
+ /* Make room for the result. */
+ if (count > allocated - length)
+ {
+ /* Need at least count elements. But allocate
+ proportionally. */
+ size_t n =
+ xmax (xsum (length, count), xtimes (allocated, 2));
+
+ ENSURE_ALLOCATION (n);
+ }
+#endif
+
+ /* Here count <= allocated - length. */
+
+ /* Perform padding. */
+#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+ if (pad_ourselves && has_width)
+ {
+ size_t w;
+# if ENABLE_UNISTDIO
+ /* Outside POSIX, it's preferable to compare the width
+ against the number of _characters_ of the converted
+ value. */
+ w = DCHAR_MBSNLEN (result + length, count);
+# else
+ /* The width is compared against the number of _bytes_
+ of the converted value, says POSIX. */
+ w = count;
+# endif
+ if (w < width)
+ {
+ size_t pad = width - w;
+
+ /* Make room for the result. */
+ if (xsum (count, pad) > allocated - length)
+ {
+ /* Need at least count + pad elements. But
+ allocate proportionally. */
+ size_t n =
+ xmax (xsum3 (length, count, pad),
+ xtimes (allocated, 2));
+
+# if USE_SNPRINTF
+ length += count;
+ ENSURE_ALLOCATION (n);
+ length -= count;
+# else
+ ENSURE_ALLOCATION (n);
+# endif
+ }
+ /* Here count + pad <= allocated - length. */
+
+ {
+# if !DCHAR_IS_TCHAR || USE_SNPRINTF
+ DCHAR_T * const rp = result + length;
+# else
+ DCHAR_T * const rp = tmp;
+# endif
+ DCHAR_T *p = rp + count;
+ DCHAR_T *end = p + pad;
+ DCHAR_T *pad_ptr;
+# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
+ if (dp->conversion == 'c'
+ || dp->conversion == 's')
+ /* No zero-padding for string directives. */
+ pad_ptr = NULL;
+ else
+# endif
+ {
+ pad_ptr = (*rp == '-' ? rp + 1 : rp);
+ /* No zero-padding of "inf" and "nan". */
+ if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z')
+ || (*pad_ptr >= 'a' && *pad_ptr <= 'z'))
+ pad_ptr = NULL;
+ }
+ /* The generated string now extends from rp to p,
+ with the zero padding insertion point being at
+ pad_ptr. */
+
+ count = count + pad; /* = end - rp */
+
+ if (flags & FLAG_LEFT)
+ {
+ /* Pad with spaces on the right. */
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+ else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
+ {
+ /* Pad with zeroes. */
+ DCHAR_T *q = end;
+
+ while (p > pad_ptr)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = '0';
+ }
+ else
+ {
+ /* Pad with spaces on the left. */
+ DCHAR_T *q = end;
+
+ while (p > rp)
+ *--q = *--p;
+ for (; pad > 0; pad--)
+ *p++ = ' ';
+ }
+ }
+ }
+ }
+#endif
+
+ /* Here still count <= allocated - length. */
+
+#if !DCHAR_IS_TCHAR || USE_SNPRINTF
+ /* The snprintf() result did fit. */
+#else
+ /* Append the sprintf() result. */
+ memcpy (result + length, tmp, count * sizeof (DCHAR_T));
+#endif
+#if !USE_SNPRINTF
+ if (tmp != tmpbuf)
+ free (tmp);
+#endif
+
+#if NEED_PRINTF_DIRECTIVE_F
+ if (dp->conversion == 'F')
+ {
+ /* Convert the %f result to upper case for %F. */
+ DCHAR_T *rp = result + length;
+ size_t rc;
+ for (rc = count; rc > 0; rc--, rp++)
+ if (*rp >= 'a' && *rp <= 'z')
+ *rp = *rp - 'a' + 'A';
+ }
+#endif
+
+ length += count;
+ break;
+ }
+ errno = orig_errno;
+#undef pad_ourselves
+#undef prec_ourselves
+ }
+ }
+ }
+
+ /* Add the final NUL. */
+ ENSURE_ALLOCATION (xsum (length, 1));
+ result[length] = '\0';
+
+ if (result != resultbuf && length + 1 < allocated)
+ {
+ /* Shrink the allocated memory if possible. */
+ DCHAR_T *memory;
+
+ memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T));
+ if (memory != NULL)
+ result = memory;
+ }
+
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ *lengthp = length;
+ /* Note that we can produce a big string of a length > INT_MAX. POSIX
+ says that snprintf() fails with errno = EOVERFLOW in this case, but
+ that's only because snprintf() returns an 'int'. This function does
+ not have this limitation. */
+ return result;
+
+#if USE_SNPRINTF
+ overflow:
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EOVERFLOW;
+ return NULL;
+#endif
+
+ out_of_memory:
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ out_of_memory_1:
+ CLEANUP ();
+ errno = ENOMEM;
+ return NULL;
+ }
+}
+
+#undef MAX_ROOM_NEEDED
+#undef TCHARS_PER_DCHAR
+#undef SNPRINTF
+#undef USE_SNPRINTF
+#undef DCHAR_SET
+#undef DCHAR_CPY
+#undef PRINTF_PARSE
+#undef DIRECTIVES
+#undef DIRECTIVE
+#undef DCHAR_IS_TCHAR
+#undef TCHAR_T
+#undef DCHAR_T
+#undef FCHAR_T
+#undef VASNPRINTF
diff --git a/grub-core/lib/gnulib/vasnprintf.h b/grub-core/lib/gnulib/vasnprintf.h
new file mode 100644
index 0000000..5b192b2
--- /dev/null
+++ b/grub-core/lib/gnulib/vasnprintf.h
@@ -0,0 +1,79 @@
+/* vsprintf with automatic memory allocation.
+ Copyright (C) 2002-2004, 2007-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _VASNPRINTF_H
+#define _VASNPRINTF_H
+
+/* Get va_list. */
+#include <stdarg.h>
+
+/* Get size_t. */
+#include <stddef.h>
+
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The __-protected variants of the attributes 'format' and 'printf' are
+ accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+ We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
+ gnulib and libintl do '#define printf __printf__' when they override
+ the 'printf' function. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Write formatted output to a string dynamically allocated with malloc().
+ You can pass a preallocated buffer for the result in RESULTBUF and its
+ size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
+ If successful, return the address of the string (this may be = RESULTBUF
+ if no dynamic memory allocation was necessary) and set *LENGTHP to the
+ number of resulting bytes, excluding the trailing NUL. Upon error, set
+ errno and return NULL.
+
+ When dynamic memory allocation occurs, the preallocated buffer is left
+ alone (with possibly modified contents). This makes it possible to use
+ a statically allocated or stack-allocated buffer, like this:
+
+ char buf[100];
+ size_t len = sizeof (buf);
+ char *output = vasnprintf (buf, &len, format, args);
+ if (output == NULL)
+ ... error handling ...;
+ else
+ {
+ ... use the output string ...;
+ if (output != buf)
+ free (output);
+ }
+ */
+#if REPLACE_VASNPRINTF
+# define asnprintf rpl_asnprintf
+# define vasnprintf rpl_vasnprintf
+#endif
+extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
+extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 0));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VASNPRINTF_H */
diff --git a/grub-core/lib/gnulib/verify.h b/grub-core/lib/gnulib/verify.h
new file mode 100644
index 0000000..b2e5f64
--- /dev/null
+++ b/grub-core/lib/gnulib/verify.h
@@ -0,0 +1,285 @@
+/* Compile-time assert-like macros.
+
+ Copyright (C) 2005-2006, 2009-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
+
+#ifndef _GL_VERIFY_H
+#define _GL_VERIFY_H
+
+
+/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11.
+ This is supported by GCC 4.6.0 and later, in C mode, and its use
+ here generates easier-to-read diagnostics when verify (R) fails.
+
+ Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11.
+ This will likely be supported by future GCC versions, in C++ mode.
+
+ Use this only with GCC. If we were willing to slow 'configure'
+ down we could also use it with other compilers, but since this
+ affects only the quality of diagnostics, why bother? */
+#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \
+ && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \
+ && !defined __cplusplus)
+# define _GL_HAVE__STATIC_ASSERT 1
+#endif
+/* The condition (99 < __GNUC__) is temporary, until we know about the
+ first G++ release that supports static_assert. */
+#if (99 < __GNUC__) && defined __cplusplus
+# define _GL_HAVE_STATIC_ASSERT 1
+#endif
+
+/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
+ system headers, defines a conflicting _Static_assert that is no
+ better than ours; override it. */
+#ifndef _GL_HAVE_STATIC_ASSERT
+# include <stddef.h>
+# undef _Static_assert
+#endif
+
+/* Each of these macros verifies that its argument R is nonzero. To
+ be portable, R should be an integer constant expression. Unlike
+ assert (R), there is no run-time overhead.
+
+ If _Static_assert works, verify (R) uses it directly. Similarly,
+ _GL_VERIFY_TRUE works by packaging a _Static_assert inside a struct
+ that is an operand of sizeof.
+
+ The code below uses several ideas for C++ compilers, and for C
+ compilers that do not support _Static_assert:
+
+ * The first step is ((R) ? 1 : -1). Given an expression R, of
+ integral or boolean or floating-point type, this yields an
+ expression of integral type, whose value is later verified to be
+ constant and nonnegative.
+
+ * Next this expression W is wrapped in a type
+ struct _gl_verify_type {
+ unsigned int _gl_verify_error_if_negative: W;
+ }.
+ If W is negative, this yields a compile-time error. No compiler can
+ deal with a bit-field of negative size.
+
+ One might think that an array size check would have the same
+ effect, that is, that the type struct { unsigned int dummy[W]; }
+ would work as well. However, inside a function, some compilers
+ (such as C++ compilers and GNU C) allow local parameters and
+ variables inside array size expressions. With these compilers,
+ an array size check would not properly diagnose this misuse of
+ the verify macro:
+
+ void function (int n) { verify (n < 0); }
+
+ * For the verify macro, the struct _gl_verify_type will need to
+ somehow be embedded into a declaration. To be portable, this
+ declaration must declare an object, a constant, a function, or a
+ typedef name. If the declared entity uses the type directly,
+ such as in
+
+ struct dummy {...};
+ typedef struct {...} dummy;
+ extern struct {...} *dummy;
+ extern void dummy (struct {...} *);
+ extern struct {...} *dummy (void);
+
+ two uses of the verify macro would yield colliding declarations
+ if the entity names are not disambiguated. A workaround is to
+ attach the current line number to the entity name:
+
+ #define _GL_CONCAT0(x, y) x##y
+ #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
+ extern struct {...} * _GL_CONCAT (dummy, __LINE__);
+
+ But this has the problem that two invocations of verify from
+ within the same macro would collide, since the __LINE__ value
+ would be the same for both invocations. (The GCC __COUNTER__
+ macro solves this problem, but is not portable.)
+
+ A solution is to use the sizeof operator. It yields a number,
+ getting rid of the identity of the type. Declarations like
+
+ extern int dummy [sizeof (struct {...})];
+ extern void dummy (int [sizeof (struct {...})]);
+ extern int (*dummy (void)) [sizeof (struct {...})];
+
+ can be repeated.
+
+ * Should the implementation use a named struct or an unnamed struct?
+ Which of the following alternatives can be used?
+
+ extern int dummy [sizeof (struct {...})];
+ extern int dummy [sizeof (struct _gl_verify_type {...})];
+ extern void dummy (int [sizeof (struct {...})]);
+ extern void dummy (int [sizeof (struct _gl_verify_type {...})]);
+ extern int (*dummy (void)) [sizeof (struct {...})];
+ extern int (*dummy (void)) [sizeof (struct _gl_verify_type {...})];
+
+ In the second and sixth case, the struct type is exported to the
+ outer scope; two such declarations therefore collide. GCC warns
+ about the first, third, and fourth cases. So the only remaining
+ possibility is the fifth case:
+
+ extern int (*dummy (void)) [sizeof (struct {...})];
+
+ * GCC warns about duplicate declarations of the dummy function if
+ -Wredundant-decls is used. GCC 4.3 and later have a builtin
+ __COUNTER__ macro that can let us generate unique identifiers for
+ each dummy function, to suppress this warning.
+
+ * This implementation exploits the fact that older versions of GCC,
+ which do not support _Static_assert, also do not warn about the
+ last declaration mentioned above.
+
+ * GCC warns if -Wnested-externs is enabled and verify() is used
+ within a function body; but inside a function, you can always
+ arrange to use verify_expr() instead.
+
+ * In C++, any struct definition inside sizeof is invalid.
+ Use a template type to work around the problem. */
+
+/* Concatenate two preprocessor tokens. */
+#define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
+#define _GL_CONCAT0(x, y) x##y
+
+/* _GL_COUNTER is an integer, preferably one that changes each time we
+ use it. Use __COUNTER__ if it works, falling back on __LINE__
+ otherwise. __LINE__ isn't perfect, but it's better than a
+ constant. */
+#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
+# define _GL_COUNTER __COUNTER__
+#else
+# define _GL_COUNTER __LINE__
+#endif
+
+/* Generate a symbol with the given prefix, making it unique if
+ possible. */
+#define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
+
+/* Verify requirement R at compile-time, as an integer constant expression
+ that returns 1. If R is false, fail at compile-time, preferably
+ with a diagnostic that includes the string-literal DIAGNOSTIC. */
+
+#define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \
+ (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
+
+#ifdef __cplusplus
+# if !GNULIB_defined_struct__gl_verify_type
+template <int w>
+ struct _gl_verify_type {
+ unsigned int _gl_verify_error_if_negative: w;
+ };
+# define GNULIB_defined_struct__gl_verify_type 1
+# endif
+# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+ _gl_verify_type<(R) ? 1 : -1>
+#elif defined _GL_HAVE__STATIC_ASSERT
+# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+ struct { \
+ _Static_assert (R, DIAGNOSTIC); \
+ int _gl_dummy; \
+ }
+#else
+# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+ struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
+#endif
+
+/* Verify requirement R at compile-time, as a declaration without a
+ trailing ';'. If R is false, fail at compile-time, preferably
+ with a diagnostic that includes the string-literal DIAGNOSTIC.
+
+ Unfortunately, unlike C11, this implementation must appear as an
+ ordinary declaration, and cannot appear inside struct { ... }. */
+
+#ifdef _GL_HAVE__STATIC_ASSERT
+# define _GL_VERIFY _Static_assert
+#else
+# define _GL_VERIFY(R, DIAGNOSTIC) \
+ extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
+ [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
+#endif
+
+/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
+#ifdef _GL_STATIC_ASSERT_H
+# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert
+# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
+# endif
+# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
+# define static_assert _Static_assert /* C11 requires this #define. */
+# endif
+#endif
+
+/* @assert.h omit start@ */
+
+/* Each of these macros verifies that its argument R is nonzero. To
+ be portable, R should be an integer constant expression. Unlike
+ assert (R), there is no run-time overhead.
+
+ There are two macros, since no single macro can be used in all
+ contexts in C. verify_true (R) is for scalar contexts, including
+ integer constant expression contexts. verify (R) is for declaration
+ contexts, e.g., the top level. */
+
+/* Verify requirement R at compile-time, as an integer constant expression.
+ Return 1. This is equivalent to verify_expr (R, 1).
+
+ verify_true is obsolescent; please use verify_expr instead. */
+
+#define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
+
+/* Verify requirement R at compile-time. Return the value of the
+ expression E. */
+
+#define verify_expr(R, E) \
+ (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
+
+/* Verify requirement R at compile-time, as a declaration without a
+ trailing ';'. */
+
+#ifdef __GNUC__
+# define verify(R) _GL_VERIFY (R, "verify (" #R ")")
+#else
+/* PGI barfs if R is long. Play it safe. */
+# define verify(R) _GL_VERIFY (R, "verify (...)")
+#endif
+
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+
+/* Assume that R always holds. This lets the compiler optimize
+ accordingly. R should not have side-effects; it may or may not be
+ evaluated. Behavior is undefined if R is false. */
+
+#if (__has_builtin (__builtin_unreachable) \
+ || 4 < __GNUC__ + (5 <= __GNUC_MINOR__))
+# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
+#elif 1200 <= _MSC_VER
+# define assume(R) __assume (R)
+#elif ((defined GCC_LINT || defined lint) \
+ && (__has_builtin (__builtin_trap) \
+ || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))))
+ /* Doing it this way helps various packages when configured with
+ --enable-gcc-warnings, which compiles with -Dlint. It's nicer
+ when 'assume' silences warnings even with older GCCs. */
+# define assume(R) ((R) ? (void) 0 : __builtin_trap ())
+#else
+ /* Some tools grok NOTREACHED, e.g., Oracle Studio 12.6. */
+# define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0)
+#endif
+
+/* @assert.h omit end@ */
+
+#endif
diff --git a/grub-core/lib/gnulib/vsnprintf.c b/grub-core/lib/gnulib/vsnprintf.c
new file mode 100644
index 0000000..6a209f7
--- /dev/null
+++ b/grub-core/lib/gnulib/vsnprintf.c
@@ -0,0 +1,70 @@
+/* Formatted output to strings.
+ Copyright (C) 2004, 2006-2019 Free Software Foundation, Inc.
+ Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
+
+ 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include <stdio.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vasnprintf.h"
+
+/* Print formatted output to string STR. Similar to vsprintf, but
+ additional length SIZE limit how much is written into STR. Returns
+ string length of formatted string (which may be larger than SIZE).
+ STR may be NULL, in which case nothing will be written. On error,
+ return a negative value. */
+int
+vsnprintf (char *str, size_t size, const char *format, va_list args)
+{
+ char *output;
+ size_t len;
+ size_t lenbuf = size;
+
+ output = vasnprintf (str, &lenbuf, format, args);
+ len = lenbuf;
+
+ if (!output)
+ return -1;
+
+ if (output != str)
+ {
+ if (size)
+ {
+ size_t pruned_len = (len < size ? len : size - 1);
+ memcpy (str, output, pruned_len);
+ str[pruned_len] = '\0';
+ }
+
+ free (output);
+ }
+
+ if (len > INT_MAX)
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ return len;
+}
diff --git a/grub-core/lib/gnulib/warn-on-use.h b/grub-core/lib/gnulib/warn-on-use.h
new file mode 100644
index 0000000..7d11a15
--- /dev/null
+++ b/grub-core/lib/gnulib/warn-on-use.h
@@ -0,0 +1,131 @@
+/* A C macro for emitting warnings if a function is used.
+ Copyright (C) 2010-2019 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 <https://www.gnu.org/licenses/>. */
+
+/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
+ for FUNCTION which will then trigger a compiler warning containing
+ the text of "literal string" anywhere that function is called, if
+ supported by the compiler. If the compiler does not support this
+ feature, the macro expands to an unused extern declaration.
+
+ _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
+ attribute used in _GL_WARN_ON_USE. If the compiler does not support
+ this feature, it expands to empty.
+
+ These macros are useful for marking a function as a potential
+ portability trap, with the intent that "literal string" include
+ instructions on the replacement function that should be used
+ instead.
+ _GL_WARN_ON_USE is for functions with 'extern' linkage.
+ _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
+ linkage.
+
+ However, one of the reasons that a function is a portability trap is
+ if it has the wrong signature. Declaring FUNCTION with a different
+ signature in C is a compilation error, so this macro must use the
+ same type as any existing declaration so that programs that avoid
+ the problematic FUNCTION do not fail to compile merely because they
+ included a header that poisoned the function. But this implies that
+ _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
+ have a declaration. Use of this macro implies that there must not
+ be any other macro hiding the declaration of FUNCTION; but
+ undefining FUNCTION first is part of the poisoning process anyway
+ (although for symbols that are provided only via a macro, the result
+ is a compilation error rather than a warning containing
+ "literal string"). Also note that in C++, it is only safe to use if
+ FUNCTION has no overloads.
+
+ For an example, it is possible to poison 'getline' by:
+ - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
+ [getline]) in configure.ac, which potentially defines
+ HAVE_RAW_DECL_GETLINE
+ - adding this code to a header that wraps the system <stdio.h>:
+ #undef getline
+ #if HAVE_RAW_DECL_GETLINE
+ _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
+ "not universally present; use the gnulib module getline");
+ #endif
+
+ It is not possible to directly poison global variables. But it is
+ possible to write a wrapper accessor function, and poison that
+ (less common usage, like &environ, will cause a compilation error
+ rather than issue the nice warning, but the end result of informing
+ the developer about their portability problem is still achieved):
+ #if HAVE_RAW_DECL_ENVIRON
+ static char ***
+ rpl_environ (void) { return &environ; }
+ _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
+ # undef environ
+ # define environ (*rpl_environ ())
+ #endif
+ or better (avoiding contradictory use of 'static' and 'extern'):
+ #if HAVE_RAW_DECL_ENVIRON
+ static char ***
+ _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
+ rpl_environ (void) { return &environ; }
+ # undef environ
+ # define environ (*rpl_environ ())
+ #endif
+ */
+#ifndef _GL_WARN_ON_USE
+
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+/* A compiler attribute is available in gcc versions 4.3.0 and later. */
+# define _GL_WARN_ON_USE(function, message) \
+extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
+# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
+ __attribute__ ((__warning__ (message)))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE(function, message) \
+extern __typeof__ (function) function
+# define _GL_WARN_ON_USE_ATTRIBUTE(message)
+# else /* Unsupported. */
+# define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C int _gl_warn_on_use
+# define _GL_WARN_ON_USE_ATTRIBUTE(message)
+# endif
+#endif
+
+/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
+ is like _GL_WARN_ON_USE (function, "string"), except that the function is
+ declared with the given prototype, consisting of return type, parameters,
+ and attributes.
+ This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
+ not work in this case. */
+#ifndef _GL_WARN_ON_USE_CXX
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+extern rettype function parameters_and_attributes \
+ __attribute__ ((__warning__ (msg)))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+extern rettype function parameters_and_attributes
+# else /* Unsupported. */
+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+_GL_WARN_EXTERN_C int _gl_warn_on_use
+# endif
+#endif
+
+/* _GL_WARN_EXTERN_C declaration;
+ performs the declaration with C linkage. */
+#ifndef _GL_WARN_EXTERN_C
+# if defined __cplusplus
+# define _GL_WARN_EXTERN_C extern "C"
+# else
+# define _GL_WARN_EXTERN_C extern
+# endif
+#endif
diff --git a/grub-core/lib/gnulib/wchar.in.h b/grub-core/lib/gnulib/wchar.in.h
new file mode 100644
index 0000000..17d5691
--- /dev/null
+++ b/grub-core/lib/gnulib/wchar.in.h
@@ -0,0 +1,1072 @@
+/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
+
+ Copyright (C) 2007-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Eric Blake. */
+
+/*
+ * ISO C 99 <wchar.h> for platforms that have issues.
+ * <http://www.opengroup.org/susv3xbd/wchar.h.html>
+ *
+ * For now, this just ensures proper prerequisite inclusion order and
+ * the declaration of wcwidth().
+ */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if (((defined __need_mbstate_t || defined __need_wint_t) \
+ && !defined __MINGW32__) \
+ || (defined __hpux \
+ && ((defined _INTTYPES_INCLUDED && !defined strtoimax) \
+ || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
+ || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
+ || defined _GL_ALREADY_INCLUDING_WCHAR_H)
+/* Special invocation convention:
+ - Inside glibc and uClibc header files, but not MinGW.
+ - On HP-UX 11.00 we have a sequence of nested includes
+ <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
+ once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
+ and once directly. In both situations 'wint_t' is not yet defined,
+ therefore we cannot provide the function overrides; instead include only
+ the system's <wchar.h>.
+ - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
+ <wchar.h> is actually processed, and that doesn't include 'mbstate_t'.
+ - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
+ the latter includes <wchar.h>. But here, we have no way to detect whether
+ <wctype.h> is completely included or is still being included. */
+
+#@INCLUDE_NEXT@ @NEXT_WCHAR_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_WCHAR_H
+
+#define _GL_ALREADY_INCLUDING_WCHAR_H
+
+#if @HAVE_FEATURES_H@
+# include <features.h> /* for __GLIBC__ */
+#endif
+
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+ <wchar.h>.
+ BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+ included before <wchar.h>.
+ In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
+ by <stddef.h>.
+ But avoid namespace pollution on glibc systems. */
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
+# include <stddef.h>
+#endif
+#ifndef __GLIBC__
+# include <stdio.h>
+# include <time.h>
+#endif
+
+/* Include the original <wchar.h> if it exists.
+ Some builds of uClibc lack it. */
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_WCHAR_H@
+# @INCLUDE_NEXT@ @NEXT_WCHAR_H@
+#endif
+
+#undef _GL_ALREADY_INCLUDING_WCHAR_H
+
+#ifndef _@GUARD_PREFIX@_WCHAR_H
+#define _@GUARD_PREFIX@_WCHAR_H
+
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+ The attribute __pure__ was added in gcc 2.96. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+#else
+# define _GL_ATTRIBUTE_PURE /* empty */
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+
+/* Define wint_t and WEOF. (Also done in wctype.in.h.) */
+#if !@HAVE_WINT_T@ && !defined wint_t
+# define wint_t int
+# ifndef WEOF
+# define WEOF -1
+# endif
+#else
+/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
+ <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
+ wint_t must be "unchanged by default argument promotions". Override it. */
+# if @GNULIB_OVERRIDES_WINT_T@
+# if !GNULIB_defined_wint_t
+# if @HAVE_CRTDEFS_H@
+# include <crtdefs.h>
+# else
+# include <stddef.h>
+# endif
+typedef unsigned int rpl_wint_t;
+# undef wint_t
+# define wint_t rpl_wint_t
+# define GNULIB_defined_wint_t 1
+# endif
+# endif
+# ifndef WEOF
+# define WEOF ((wint_t) -1)
+# endif
+#endif
+
+
+/* Override mbstate_t if it is too small.
+ On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
+ implementing mbrtowc for encodings like UTF-8. */
+#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
+# if !GNULIB_defined_mbstate_t
+typedef int rpl_mbstate_t;
+# undef mbstate_t
+# define mbstate_t rpl_mbstate_t
+# define GNULIB_defined_mbstate_t 1
+# endif
+#endif
+
+
+/* Convert a single-byte character to a wide character. */
+#if @GNULIB_BTOWC@
+# if @REPLACE_BTOWC@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef btowc
+# define btowc rpl_btowc
+# endif
+_GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
+_GL_CXXALIAS_RPL (btowc, wint_t, (int c));
+# else
+# if !@HAVE_BTOWC@
+_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (btowc, wint_t, (int c));
+# endif
+_GL_CXXALIASWARN (btowc);
+#elif defined GNULIB_POSIXCHECK
+# undef btowc
+# if HAVE_RAW_DECL_BTOWC
+_GL_WARN_ON_USE (btowc, "btowc is unportable - "
+ "use gnulib module btowc for portability");
+# endif
+#endif
+
+
+/* Convert a wide character to a single-byte character. */
+#if @GNULIB_WCTOB@
+# if @REPLACE_WCTOB@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wctob
+# define wctob rpl_wctob
+# endif
+_GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
+_GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
+# else
+# if !defined wctob && !@HAVE_DECL_WCTOB@
+/* wctob is provided by gnulib, or wctob exists but is not declared. */
+_GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
+# endif
+_GL_CXXALIASWARN (wctob);
+#elif defined GNULIB_POSIXCHECK
+# undef wctob
+# if HAVE_RAW_DECL_WCTOB
+_GL_WARN_ON_USE (wctob, "wctob is unportable - "
+ "use gnulib module wctob for portability");
+# endif
+#endif
+
+
+/* Test whether *PS is in the initial state. */
+#if @GNULIB_MBSINIT@
+# if @REPLACE_MBSINIT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef mbsinit
+# define mbsinit rpl_mbsinit
+# endif
+_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
+# else
+# if !@HAVE_MBSINIT@
+_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
+# endif
+_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (mbsinit);
+#elif defined GNULIB_POSIXCHECK
+# undef mbsinit
+# if HAVE_RAW_DECL_MBSINIT
+_GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
+ "use gnulib module mbsinit for portability");
+# endif
+#endif
+
+
+/* Convert a multibyte character to a wide character. */
+#if @GNULIB_MBRTOWC@
+# if @REPLACE_MBRTOWC@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef mbrtowc
+# define mbrtowc rpl_mbrtowc
+# endif
+_GL_FUNCDECL_RPL (mbrtowc, size_t,
+ (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbrtowc, size_t,
+ (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+# else
+# if !@HAVE_MBRTOWC@
+_GL_FUNCDECL_SYS (mbrtowc, size_t,
+ (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+# endif
+_GL_CXXALIAS_SYS (mbrtowc, size_t,
+ (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (mbrtowc);
+#elif defined GNULIB_POSIXCHECK
+# undef mbrtowc
+# if HAVE_RAW_DECL_MBRTOWC
+_GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
+ "use gnulib module mbrtowc for portability");
+# endif
+#endif
+
+
+/* Recognize a multibyte character. */
+#if @GNULIB_MBRLEN@
+# if @REPLACE_MBRLEN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef mbrlen
+# define mbrlen rpl_mbrlen
+# endif
+_GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+# else
+# if !@HAVE_MBRLEN@
+_GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+# endif
+_GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (mbrlen);
+#elif defined GNULIB_POSIXCHECK
+# undef mbrlen
+# if HAVE_RAW_DECL_MBRLEN
+_GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
+ "use gnulib module mbrlen for portability");
+# endif
+#endif
+
+
+/* Convert a string to a wide string. */
+#if @GNULIB_MBSRTOWCS@
+# if @REPLACE_MBSRTOWCS@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef mbsrtowcs
+# define mbsrtowcs rpl_mbsrtowcs
+# endif
+_GL_FUNCDECL_RPL (mbsrtowcs, size_t,
+ (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (mbsrtowcs, size_t,
+ (wchar_t *dest, const char **srcp, size_t len,
+ mbstate_t *ps));
+# else
+# if !@HAVE_MBSRTOWCS@
+_GL_FUNCDECL_SYS (mbsrtowcs, size_t,
+ (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mbsrtowcs, size_t,
+ (wchar_t *dest, const char **srcp, size_t len,
+ mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (mbsrtowcs);
+#elif defined GNULIB_POSIXCHECK
+# undef mbsrtowcs
+# if HAVE_RAW_DECL_MBSRTOWCS
+_GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
+ "use gnulib module mbsrtowcs for portability");
+# endif
+#endif
+
+
+/* Convert a string to a wide string. */
+#if @GNULIB_MBSNRTOWCS@
+# if @REPLACE_MBSNRTOWCS@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef mbsnrtowcs
+# define mbsnrtowcs rpl_mbsnrtowcs
+# endif
+_GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
+ (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+ mbstate_t *ps)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
+ (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+ mbstate_t *ps));
+# else
+# if !@HAVE_MBSNRTOWCS@
+_GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
+ (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+ mbstate_t *ps)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
+ (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+ mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (mbsnrtowcs);
+#elif defined GNULIB_POSIXCHECK
+# undef mbsnrtowcs
+# if HAVE_RAW_DECL_MBSNRTOWCS
+_GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
+ "use gnulib module mbsnrtowcs for portability");
+# endif
+#endif
+
+
+/* Convert a wide character to a multibyte character. */
+#if @GNULIB_WCRTOMB@
+# if @REPLACE_WCRTOMB@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcrtomb
+# define wcrtomb rpl_wcrtomb
+# endif
+_GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+_GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+# else
+# if !@HAVE_WCRTOMB@
+_GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+# endif
+_GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (wcrtomb);
+#elif defined GNULIB_POSIXCHECK
+# undef wcrtomb
+# if HAVE_RAW_DECL_WCRTOMB
+_GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
+ "use gnulib module wcrtomb for portability");
+# endif
+#endif
+
+
+/* Convert a wide string to a string. */
+#if @GNULIB_WCSRTOMBS@
+# if @REPLACE_WCSRTOMBS@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcsrtombs
+# define wcsrtombs rpl_wcsrtombs
+# endif
+_GL_FUNCDECL_RPL (wcsrtombs, size_t,
+ (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (wcsrtombs, size_t,
+ (char *dest, const wchar_t **srcp, size_t len,
+ mbstate_t *ps));
+# else
+# if !@HAVE_WCSRTOMBS@
+_GL_FUNCDECL_SYS (wcsrtombs, size_t,
+ (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (wcsrtombs, size_t,
+ (char *dest, const wchar_t **srcp, size_t len,
+ mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (wcsrtombs);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsrtombs
+# if HAVE_RAW_DECL_WCSRTOMBS
+_GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
+ "use gnulib module wcsrtombs for portability");
+# endif
+#endif
+
+
+/* Convert a wide string to a string. */
+#if @GNULIB_WCSNRTOMBS@
+# if @REPLACE_WCSNRTOMBS@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcsnrtombs
+# define wcsnrtombs rpl_wcsnrtombs
+# endif
+_GL_FUNCDECL_RPL (wcsnrtombs, size_t,
+ (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+ mbstate_t *ps)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (wcsnrtombs, size_t,
+ (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+ mbstate_t *ps));
+# else
+# if !@HAVE_WCSNRTOMBS@
+_GL_FUNCDECL_SYS (wcsnrtombs, size_t,
+ (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+ mbstate_t *ps)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (wcsnrtombs, size_t,
+ (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+ mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (wcsnrtombs);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsnrtombs
+# if HAVE_RAW_DECL_WCSNRTOMBS
+_GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
+ "use gnulib module wcsnrtombs for portability");
+# endif
+#endif
+
+
+/* Return the number of screen columns needed for WC. */
+#if @GNULIB_WCWIDTH@
+# if @REPLACE_WCWIDTH@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcwidth
+# define wcwidth rpl_wcwidth
+# endif
+_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
+_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
+# else
+# if !@HAVE_DECL_WCWIDTH@
+/* wcwidth exists but is not declared. */
+_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
+# endif
+_GL_CXXALIASWARN (wcwidth);
+#elif defined GNULIB_POSIXCHECK
+# undef wcwidth
+# if HAVE_RAW_DECL_WCWIDTH
+_GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
+ "use gnulib module wcwidth for portability");
+# endif
+#endif
+
+
+/* Search N wide characters of S for C. */
+#if @GNULIB_WMEMCHR@
+# if !@HAVE_WMEMCHR@
+_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n)
+ _GL_ATTRIBUTE_PURE);
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
+ wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wmemchr,
+ wchar_t *, (const wchar_t *, wchar_t, size_t),
+ const wchar_t *, (const wchar_t *, wchar_t, size_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
+_GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
+ (const wchar_t *s, wchar_t c, size_t n));
+# else
+_GL_CXXALIASWARN (wmemchr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef wmemchr
+# if HAVE_RAW_DECL_WMEMCHR
+_GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
+ "use gnulib module wmemchr for portability");
+# endif
+#endif
+
+
+/* Compare N wide characters of S1 and S2. */
+#if @GNULIB_WMEMCMP@
+# if !@HAVE_WMEMCMP@
+_GL_FUNCDECL_SYS (wmemcmp, int,
+ (const wchar_t *s1, const wchar_t *s2, size_t n)
+ _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wmemcmp, int,
+ (const wchar_t *s1, const wchar_t *s2, size_t n));
+_GL_CXXALIASWARN (wmemcmp);
+#elif defined GNULIB_POSIXCHECK
+# undef wmemcmp
+# if HAVE_RAW_DECL_WMEMCMP
+_GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
+ "use gnulib module wmemcmp for portability");
+# endif
+#endif
+
+
+/* Copy N wide characters of SRC to DEST. */
+#if @GNULIB_WMEMCPY@
+# if !@HAVE_WMEMCPY@
+_GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
+ (wchar_t *dest, const wchar_t *src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
+ (wchar_t *dest, const wchar_t *src, size_t n));
+_GL_CXXALIASWARN (wmemcpy);
+#elif defined GNULIB_POSIXCHECK
+# undef wmemcpy
+# if HAVE_RAW_DECL_WMEMCPY
+_GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
+ "use gnulib module wmemcpy for portability");
+# endif
+#endif
+
+
+/* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
+ overlapping memory areas. */
+#if @GNULIB_WMEMMOVE@
+# if !@HAVE_WMEMMOVE@
+_GL_FUNCDECL_SYS (wmemmove, wchar_t *,
+ (wchar_t *dest, const wchar_t *src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wmemmove, wchar_t *,
+ (wchar_t *dest, const wchar_t *src, size_t n));
+_GL_CXXALIASWARN (wmemmove);
+#elif defined GNULIB_POSIXCHECK
+# undef wmemmove
+# if HAVE_RAW_DECL_WMEMMOVE
+_GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
+ "use gnulib module wmemmove for portability");
+# endif
+#endif
+
+
+/* Set N wide characters of S to C. */
+#if @GNULIB_WMEMSET@
+# if !@HAVE_WMEMSET@
+_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
+_GL_CXXALIASWARN (wmemset);
+#elif defined GNULIB_POSIXCHECK
+# undef wmemset
+# if HAVE_RAW_DECL_WMEMSET
+_GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
+ "use gnulib module wmemset for portability");
+# endif
+#endif
+
+
+/* Return the number of wide characters in S. */
+#if @GNULIB_WCSLEN@
+# if !@HAVE_WCSLEN@
+_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
+_GL_CXXALIASWARN (wcslen);
+#elif defined GNULIB_POSIXCHECK
+# undef wcslen
+# if HAVE_RAW_DECL_WCSLEN
+_GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
+ "use gnulib module wcslen for portability");
+# endif
+#endif
+
+
+/* Return the number of wide characters in S, but at most MAXLEN. */
+#if @GNULIB_WCSNLEN@
+# if !@HAVE_WCSNLEN@
+_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)
+ _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
+_GL_CXXALIASWARN (wcsnlen);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsnlen
+# if HAVE_RAW_DECL_WCSNLEN
+_GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
+ "use gnulib module wcsnlen for portability");
+# endif
+#endif
+
+
+/* Copy SRC to DEST. */
+#if @GNULIB_WCSCPY@
+# if !@HAVE_WCSCPY@
+_GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
+# endif
+_GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
+_GL_CXXALIASWARN (wcscpy);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscpy
+# if HAVE_RAW_DECL_WCSCPY
+_GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
+ "use gnulib module wcscpy for portability");
+# endif
+#endif
+
+
+/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
+#if @GNULIB_WCPCPY@
+# if !@HAVE_WCPCPY@
+_GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
+# endif
+_GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
+_GL_CXXALIASWARN (wcpcpy);
+#elif defined GNULIB_POSIXCHECK
+# undef wcpcpy
+# if HAVE_RAW_DECL_WCPCPY
+_GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
+ "use gnulib module wcpcpy for portability");
+# endif
+#endif
+
+
+/* Copy no more than N wide characters of SRC to DEST. */
+#if @GNULIB_WCSNCPY@
+# if !@HAVE_WCSNCPY@
+_GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
+ (wchar_t *dest, const wchar_t *src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
+ (wchar_t *dest, const wchar_t *src, size_t n));
+_GL_CXXALIASWARN (wcsncpy);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsncpy
+# if HAVE_RAW_DECL_WCSNCPY
+_GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
+ "use gnulib module wcsncpy for portability");
+# endif
+#endif
+
+
+/* Copy no more than N characters of SRC to DEST, returning the address of
+ the last character written into DEST. */
+#if @GNULIB_WCPNCPY@
+# if !@HAVE_WCPNCPY@
+_GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
+ (wchar_t *dest, const wchar_t *src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
+ (wchar_t *dest, const wchar_t *src, size_t n));
+_GL_CXXALIASWARN (wcpncpy);
+#elif defined GNULIB_POSIXCHECK
+# undef wcpncpy
+# if HAVE_RAW_DECL_WCPNCPY
+_GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
+ "use gnulib module wcpncpy for portability");
+# endif
+#endif
+
+
+/* Append SRC onto DEST. */
+#if @GNULIB_WCSCAT@
+# if !@HAVE_WCSCAT@
+_GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
+# endif
+_GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
+_GL_CXXALIASWARN (wcscat);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscat
+# if HAVE_RAW_DECL_WCSCAT
+_GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
+ "use gnulib module wcscat for portability");
+# endif
+#endif
+
+
+/* Append no more than N wide characters of SRC onto DEST. */
+#if @GNULIB_WCSNCAT@
+# if !@HAVE_WCSNCAT@
+_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
+ (wchar_t *dest, const wchar_t *src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
+ (wchar_t *dest, const wchar_t *src, size_t n));
+_GL_CXXALIASWARN (wcsncat);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsncat
+# if HAVE_RAW_DECL_WCSNCAT
+_GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
+ "use gnulib module wcsncat for portability");
+# endif
+#endif
+
+
+/* Compare S1 and S2. */
+#if @GNULIB_WCSCMP@
+# if !@HAVE_WCSCMP@
+_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
+ _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
+_GL_CXXALIASWARN (wcscmp);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscmp
+# if HAVE_RAW_DECL_WCSCMP
+_GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
+ "use gnulib module wcscmp for portability");
+# endif
+#endif
+
+
+/* Compare no more than N wide characters of S1 and S2. */
+#if @GNULIB_WCSNCMP@
+# if !@HAVE_WCSNCMP@
+_GL_FUNCDECL_SYS (wcsncmp, int,
+ (const wchar_t *s1, const wchar_t *s2, size_t n)
+ _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wcsncmp, int,
+ (const wchar_t *s1, const wchar_t *s2, size_t n));
+_GL_CXXALIASWARN (wcsncmp);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsncmp
+# if HAVE_RAW_DECL_WCSNCMP
+_GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
+ "use gnulib module wcsncmp for portability");
+# endif
+#endif
+
+
+/* Compare S1 and S2, ignoring case. */
+#if @GNULIB_WCSCASECMP@
+# if !@HAVE_WCSCASECMP@
+_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)
+ _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
+_GL_CXXALIASWARN (wcscasecmp);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscasecmp
+# if HAVE_RAW_DECL_WCSCASECMP
+_GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
+ "use gnulib module wcscasecmp for portability");
+# endif
+#endif
+
+
+/* Compare no more than N chars of S1 and S2, ignoring case. */
+#if @GNULIB_WCSNCASECMP@
+# if !@HAVE_WCSNCASECMP@
+_GL_FUNCDECL_SYS (wcsncasecmp, int,
+ (const wchar_t *s1, const wchar_t *s2, size_t n)
+ _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wcsncasecmp, int,
+ (const wchar_t *s1, const wchar_t *s2, size_t n));
+_GL_CXXALIASWARN (wcsncasecmp);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsncasecmp
+# if HAVE_RAW_DECL_WCSNCASECMP
+_GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
+ "use gnulib module wcsncasecmp for portability");
+# endif
+#endif
+
+
+/* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
+ category of the current locale. */
+#if @GNULIB_WCSCOLL@
+# if !@HAVE_WCSCOLL@
+_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
+# endif
+_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
+_GL_CXXALIASWARN (wcscoll);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscoll
+# if HAVE_RAW_DECL_WCSCOLL
+_GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
+ "use gnulib module wcscoll for portability");
+# endif
+#endif
+
+
+/* Transform S2 into array pointed to by S1 such that if wcscmp is applied
+ to two transformed strings the result is the as applying 'wcscoll' to the
+ original strings. */
+#if @GNULIB_WCSXFRM@
+# if !@HAVE_WCSXFRM@
+_GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
+_GL_CXXALIASWARN (wcsxfrm);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsxfrm
+# if HAVE_RAW_DECL_WCSXFRM
+_GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
+ "use gnulib module wcsxfrm for portability");
+# endif
+#endif
+
+
+/* Duplicate S, returning an identical malloc'd string. */
+#if @GNULIB_WCSDUP@
+# if !@HAVE_WCSDUP@
+_GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s));
+# endif
+_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
+_GL_CXXALIASWARN (wcsdup);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsdup
+# if HAVE_RAW_DECL_WCSDUP
+_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
+ "use gnulib module wcsdup for portability");
+# endif
+#endif
+
+
+/* Find the first occurrence of WC in WCS. */
+#if @GNULIB_WCSCHR@
+# if !@HAVE_WCSCHR@
+_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
+ _GL_ATTRIBUTE_PURE);
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcschr (const wchar_t *, wchar_t);
+ wchar_t * std::wcschr (wchar_t *, wchar_t);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcschr,
+ wchar_t *, (const wchar_t *, wchar_t),
+ const wchar_t *, (const wchar_t *, wchar_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
+_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
+# else
+_GL_CXXALIASWARN (wcschr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef wcschr
+# if HAVE_RAW_DECL_WCSCHR
+_GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
+ "use gnulib module wcschr for portability");
+# endif
+#endif
+
+
+/* Find the last occurrence of WC in WCS. */
+#if @GNULIB_WCSRCHR@
+# if !@HAVE_WCSRCHR@
+_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
+ _GL_ATTRIBUTE_PURE);
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
+ wchar_t * std::wcsrchr (wchar_t *, wchar_t);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcsrchr,
+ wchar_t *, (const wchar_t *, wchar_t),
+ const wchar_t *, (const wchar_t *, wchar_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
+_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
+# else
+_GL_CXXALIASWARN (wcsrchr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef wcsrchr
+# if HAVE_RAW_DECL_WCSRCHR
+_GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
+ "use gnulib module wcsrchr for portability");
+# endif
+#endif
+
+
+/* Return the length of the initial segmet of WCS which consists entirely
+ of wide characters not in REJECT. */
+#if @GNULIB_WCSCSPN@
+# if !@HAVE_WCSCSPN@
+_GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)
+ _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
+_GL_CXXALIASWARN (wcscspn);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscspn
+# if HAVE_RAW_DECL_WCSCSPN
+_GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
+ "use gnulib module wcscspn for portability");
+# endif
+#endif
+
+
+/* Return the length of the initial segmet of WCS which consists entirely
+ of wide characters in ACCEPT. */
+#if @GNULIB_WCSSPN@
+# if !@HAVE_WCSSPN@
+_GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)
+ _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
+_GL_CXXALIASWARN (wcsspn);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsspn
+# if HAVE_RAW_DECL_WCSSPN
+_GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
+ "use gnulib module wcsspn for portability");
+# endif
+#endif
+
+
+/* Find the first occurrence in WCS of any character in ACCEPT. */
+#if @GNULIB_WCSPBRK@
+# if !@HAVE_WCSPBRK@
+_GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
+ (const wchar_t *wcs, const wchar_t *accept)
+ _GL_ATTRIBUTE_PURE);
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
+ wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcspbrk,
+ wchar_t *, (const wchar_t *, const wchar_t *),
+ const wchar_t *, (const wchar_t *, const wchar_t *));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
+ (wchar_t *wcs, const wchar_t *accept));
+_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
+ (const wchar_t *wcs, const wchar_t *accept));
+# else
+_GL_CXXALIASWARN (wcspbrk);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef wcspbrk
+# if HAVE_RAW_DECL_WCSPBRK
+_GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
+ "use gnulib module wcspbrk for portability");
+# endif
+#endif
+
+
+/* Find the first occurrence of NEEDLE in HAYSTACK. */
+#if @GNULIB_WCSSTR@
+# if !@HAVE_WCSSTR@
+_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
+ (const wchar_t *haystack, const wchar_t *needle)
+ _GL_ATTRIBUTE_PURE);
+# endif
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
+ wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcsstr,
+ wchar_t *, (const wchar_t *, const wchar_t *),
+ const wchar_t *, (const wchar_t *, const wchar_t *));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
+ (wchar_t *haystack, const wchar_t *needle));
+_GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
+ (const wchar_t *haystack, const wchar_t *needle));
+# else
+_GL_CXXALIASWARN (wcsstr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef wcsstr
+# if HAVE_RAW_DECL_WCSSTR
+_GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
+ "use gnulib module wcsstr for portability");
+# endif
+#endif
+
+
+/* Divide WCS into tokens separated by characters in DELIM. */
+#if @GNULIB_WCSTOK@
+# if !@HAVE_WCSTOK@
+_GL_FUNCDECL_SYS (wcstok, wchar_t *,
+ (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
+# endif
+_GL_CXXALIAS_SYS (wcstok, wchar_t *,
+ (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
+_GL_CXXALIASWARN (wcstok);
+#elif defined GNULIB_POSIXCHECK
+# undef wcstok
+# if HAVE_RAW_DECL_WCSTOK
+_GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
+ "use gnulib module wcstok for portability");
+# endif
+#endif
+
+
+/* Determine number of column positions required for first N wide
+ characters (or fewer if S ends before this) in S. */
+#if @GNULIB_WCSWIDTH@
+# if @REPLACE_WCSWIDTH@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcswidth
+# define wcswidth rpl_wcswidth
+# endif
+_GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n)
+ _GL_ATTRIBUTE_PURE);
+_GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
+# else
+# if !@HAVE_WCSWIDTH@
+_GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n)
+ _GL_ATTRIBUTE_PURE);
+# endif
+_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
+# endif
+_GL_CXXALIASWARN (wcswidth);
+#elif defined GNULIB_POSIXCHECK
+# undef wcswidth
+# if HAVE_RAW_DECL_WCSWIDTH
+_GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
+ "use gnulib module wcswidth for portability");
+# endif
+#endif
+
+
+/* Convert *TP to a date and time wide string. See
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
+#if @GNULIB_WCSFTIME@
+# if @REPLACE_WCSFTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcsftime
+# define wcsftime rpl_wcsftime
+# endif
+_GL_FUNCDECL_RPL (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize,
+ const wchar_t *__fmt, const struct tm *__tp)
+ _GL_ARG_NONNULL ((1, 3, 4)));
+_GL_CXXALIAS_RPL (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize,
+ const wchar_t *__fmt, const struct tm *__tp));
+# else
+# if !@HAVE_WCSFTIME@
+_GL_FUNCDECL_SYS (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize,
+ const wchar_t *__fmt, const struct tm *__tp)
+ _GL_ARG_NONNULL ((1, 3, 4)));
+# endif
+_GL_CXXALIAS_SYS (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize,
+ const wchar_t *__fmt, const struct tm *__tp));
+# endif
+_GL_CXXALIASWARN (wcsftime);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsftime
+# if HAVE_RAW_DECL_WCSFTIME
+_GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
+ "use gnulib module wcsftime for portability");
+# endif
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_WCHAR_H */
+#endif /* _@GUARD_PREFIX@_WCHAR_H */
+#endif
diff --git a/grub-core/lib/gnulib/wcrtomb.c b/grub-core/lib/gnulib/wcrtomb.c
new file mode 100644
index 0000000..9fc40cf
--- /dev/null
+++ b/grub-core/lib/gnulib/wcrtomb.c
@@ -0,0 +1,53 @@
+/* Convert wide character to multibyte character.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <wchar.h>
+
+#include <errno.h>
+#include <stdlib.h>
+
+
+size_t
+wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
+{
+ /* This implementation of wcrtomb on top of wctomb() supports only
+ stateless encodings. ps must be in the initial state. */
+ if (ps != NULL && !mbsinit (ps))
+ {
+ errno = EINVAL;
+ return (size_t)(-1);
+ }
+
+ if (s == NULL)
+ /* We know the NUL wide character corresponds to the NUL character. */
+ return 1;
+ else
+ {
+ int ret = wctomb (s, wc);
+
+ if (ret >= 0)
+ return ret;
+ else
+ {
+ errno = EILSEQ;
+ return (size_t)(-1);
+ }
+ }
+}
diff --git a/grub-core/lib/gnulib/wctype-h.c b/grub-core/lib/gnulib/wctype-h.c
new file mode 100644
index 0000000..bb5f847
--- /dev/null
+++ b/grub-core/lib/gnulib/wctype-h.c
@@ -0,0 +1,4 @@
+/* Normally this would be wctype.c, but that name's already taken. */
+#include <config.h>
+#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE
+#include "wctype.h"
diff --git a/grub-core/lib/gnulib/wctype.in.h b/grub-core/lib/gnulib/wctype.in.h
new file mode 100644
index 0000000..0a7471f
--- /dev/null
+++ b/grub-core/lib/gnulib/wctype.in.h
@@ -0,0 +1,533 @@
+/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
+
+ Copyright (C) 2006-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible and Paul Eggert. */
+
+/*
+ * ISO C 99 <wctype.h> for platforms that lack it.
+ * <http://www.opengroup.org/susv3xbd/wctype.h.html>
+ *
+ * iswctype, towctrans, towlower, towupper, wctrans, wctype,
+ * wctrans_t, and wctype_t are not yet implemented.
+ */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if (defined __MINGW32__ && defined __CTYPE_H_SOURCED__)
+
+/* Special invocation convention:
+ - With MinGW 3.22, when <ctype.h> includes <wctype.h>, only some part of
+ <wctype.h> is being processed, which doesn't include the idempotency
+ guard. */
+
+#@INCLUDE_NEXT@ @NEXT_WCTYPE_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_WCTYPE_H
+
+#if @HAVE_WINT_T@
+/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
+ Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+ <wchar.h>.
+ BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+ included before <wchar.h>. */
+# include <stddef.h>
+# include <stdio.h>
+# include <time.h>
+# include <wchar.h>
+#endif
+
+/* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and
+ isw* functions in <ctype.h>, <wchar.h> as well as in <wctype.h>. Include
+ <ctype.h>, <wchar.h> in advance to avoid rpl_ prefix being added to the
+ declarations. */
+#if defined _WIN32 && ! defined __CYGWIN__
+# include <ctype.h>
+# include <wchar.h>
+#endif
+
+/* Include the original <wctype.h> if it exists.
+ BeOS 5 has the functions but no <wctype.h>. */
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_WCTYPE_H@
+# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
+#endif
+
+#ifndef _@GUARD_PREFIX@_WCTYPE_H
+#define _@GUARD_PREFIX@_WCTYPE_H
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_WCTYPE_INLINE
+# define _GL_WCTYPE_INLINE _GL_INLINE
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+/* Solaris 2.6 <wctype.h> includes <widec.h> which includes <euc.h> which
+ #defines a number of identifiers in the application namespace. Revert
+ these #defines. */
+#ifdef __sun
+# undef multibyte
+# undef eucw1
+# undef eucw2
+# undef eucw3
+# undef scrw1
+# undef scrw2
+# undef scrw3
+#endif
+
+/* Define wint_t and WEOF. (Also done in wchar.in.h.) */
+#if !@HAVE_WINT_T@ && !defined wint_t
+# define wint_t int
+# ifndef WEOF
+# define WEOF -1
+# endif
+#else
+/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
+ <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
+ wint_t must be "unchanged by default argument promotions". Override it. */
+# if @GNULIB_OVERRIDES_WINT_T@
+# if !GNULIB_defined_wint_t
+# if @HAVE_CRTDEFS_H@
+# include <crtdefs.h>
+# else
+# include <stddef.h>
+# endif
+typedef unsigned int rpl_wint_t;
+# undef wint_t
+# define wint_t rpl_wint_t
+# define GNULIB_defined_wint_t 1
+# endif
+# endif
+# ifndef WEOF
+# define WEOF ((wint_t) -1)
+# endif
+#endif
+
+
+#if !GNULIB_defined_wctype_functions
+
+/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
+ Linux libc5 has <wctype.h> and the functions but they are broken.
+ Assume all 11 functions (all isw* except iswblank) are implemented the
+ same way, or not at all. */
+# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
+
+/* IRIX 5.3 has macros but no functions, its isw* macros refer to an
+ undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
+ refer to system functions like _iswctype that are not in the
+ standard C library. Rather than try to get ancient buggy
+ implementations like this to work, just disable them. */
+# undef iswalnum
+# undef iswalpha
+# undef iswblank
+# undef iswcntrl
+# undef iswdigit
+# undef iswgraph
+# undef iswlower
+# undef iswprint
+# undef iswpunct
+# undef iswspace
+# undef iswupper
+# undef iswxdigit
+# undef towlower
+# undef towupper
+
+/* Linux libc5 has <wctype.h> and the functions but they are broken. */
+# if @REPLACE_ISWCNTRL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define iswalnum rpl_iswalnum
+# define iswalpha rpl_iswalpha
+# define iswblank rpl_iswblank
+# define iswcntrl rpl_iswcntrl
+# define iswdigit rpl_iswdigit
+# define iswgraph rpl_iswgraph
+# define iswlower rpl_iswlower
+# define iswprint rpl_iswprint
+# define iswpunct rpl_iswpunct
+# define iswspace rpl_iswspace
+# define iswupper rpl_iswupper
+# define iswxdigit rpl_iswxdigit
+# endif
+# endif
+# if @REPLACE_TOWLOWER@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define towlower rpl_towlower
+# define towupper rpl_towupper
+# endif
+# endif
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswalnum
+# else
+iswalnum
+# endif
+ (wint_t wc)
+{
+ return ((wc >= '0' && wc <= '9')
+ || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswalpha
+# else
+iswalpha
+# endif
+ (wint_t wc)
+{
+ return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswblank
+# else
+iswblank
+# endif
+ (wint_t wc)
+{
+ return wc == ' ' || wc == '\t';
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswcntrl
+# else
+iswcntrl
+# endif
+ (wint_t wc)
+{
+ return (wc & ~0x1f) == 0 || wc == 0x7f;
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswdigit
+# else
+iswdigit
+# endif
+ (wint_t wc)
+{
+ return wc >= '0' && wc <= '9';
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswgraph
+# else
+iswgraph
+# endif
+ (wint_t wc)
+{
+ return wc >= '!' && wc <= '~';
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswlower
+# else
+iswlower
+# endif
+ (wint_t wc)
+{
+ return wc >= 'a' && wc <= 'z';
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswprint
+# else
+iswprint
+# endif
+ (wint_t wc)
+{
+ return wc >= ' ' && wc <= '~';
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswpunct
+# else
+iswpunct
+# endif
+ (wint_t wc)
+{
+ return (wc >= '!' && wc <= '~'
+ && !((wc >= '0' && wc <= '9')
+ || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswspace
+# else
+iswspace
+# endif
+ (wint_t wc)
+{
+ return (wc == ' ' || wc == '\t'
+ || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswupper
+# else
+iswupper
+# endif
+ (wint_t wc)
+{
+ return wc >= 'A' && wc <= 'Z';
+}
+
+_GL_WCTYPE_INLINE int
+# if @REPLACE_ISWCNTRL@
+rpl_iswxdigit
+# else
+iswxdigit
+# endif
+ (wint_t wc)
+{
+ return ((wc >= '0' && wc <= '9')
+ || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
+}
+
+_GL_WCTYPE_INLINE wint_t
+# if @REPLACE_TOWLOWER@
+rpl_towlower
+# else
+towlower
+# endif
+ (wint_t wc)
+{
+ return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
+}
+
+_GL_WCTYPE_INLINE wint_t
+# if @REPLACE_TOWLOWER@
+rpl_towupper
+# else
+towupper
+# endif
+ (wint_t wc)
+{
+ return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
+}
+
+# elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
+/* Only the iswblank function is missing. */
+
+# if @REPLACE_ISWBLANK@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define iswblank rpl_iswblank
+# endif
+_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
+# else
+_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
+# endif
+
+# endif
+
+# if defined __MINGW32__
+
+/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
+ The functions towlower and towupper are implemented in the MSVCRT library
+ to take a wchar_t argument and return a wchar_t result. mingw declares
+ these functions to take a wint_t argument and return a wint_t result.
+ This means that:
+ 1. When the user passes an argument outside the range 0x0000..0xFFFF, the
+ function will look only at the lower 16 bits. This is allowed according
+ to POSIX.
+ 2. The return value is returned in the lower 16 bits of the result register.
+ The upper 16 bits are random: whatever happened to be in that part of the
+ result register. We need to fix this by adding a zero-extend from
+ wchar_t to wint_t after the call. */
+
+_GL_WCTYPE_INLINE wint_t
+rpl_towlower (wint_t wc)
+{
+ return (wint_t) (wchar_t) towlower (wc);
+}
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define towlower rpl_towlower
+# endif
+
+_GL_WCTYPE_INLINE wint_t
+rpl_towupper (wint_t wc)
+{
+ return (wint_t) (wchar_t) towupper (wc);
+}
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define towupper rpl_towupper
+# endif
+
+# endif /* __MINGW32__ */
+
+# define GNULIB_defined_wctype_functions 1
+#endif
+
+#if @REPLACE_ISWCNTRL@
+_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
+#else
+_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
+#endif
+_GL_CXXALIASWARN (iswalnum);
+_GL_CXXALIASWARN (iswalpha);
+_GL_CXXALIASWARN (iswcntrl);
+_GL_CXXALIASWARN (iswdigit);
+_GL_CXXALIASWARN (iswgraph);
+_GL_CXXALIASWARN (iswlower);
+_GL_CXXALIASWARN (iswprint);
+_GL_CXXALIASWARN (iswpunct);
+_GL_CXXALIASWARN (iswspace);
+_GL_CXXALIASWARN (iswupper);
+_GL_CXXALIASWARN (iswxdigit);
+
+#if @GNULIB_ISWBLANK@
+# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
+_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
+# else
+_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
+# endif
+_GL_CXXALIASWARN (iswblank);
+#endif
+
+#if !@HAVE_WCTYPE_T@
+# if !GNULIB_defined_wctype_t
+typedef void * wctype_t;
+# define GNULIB_defined_wctype_t 1
+# endif
+#endif
+
+/* Get a descriptor for a wide character property. */
+#if @GNULIB_WCTYPE@
+# if !@HAVE_WCTYPE_T@
+_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
+# endif
+_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
+_GL_CXXALIASWARN (wctype);
+#elif defined GNULIB_POSIXCHECK
+# undef wctype
+# if HAVE_RAW_DECL_WCTYPE
+_GL_WARN_ON_USE (wctype, "wctype is unportable - "
+ "use gnulib module wctype for portability");
+# endif
+#endif
+
+/* Test whether a wide character has a given property.
+ The argument WC must be either a wchar_t value or WEOF.
+ The argument DESC must have been returned by the wctype() function. */
+#if @GNULIB_ISWCTYPE@
+# if !@HAVE_WCTYPE_T@
+_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
+# endif
+_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
+_GL_CXXALIASWARN (iswctype);
+#elif defined GNULIB_POSIXCHECK
+# undef iswctype
+# if HAVE_RAW_DECL_ISWCTYPE
+_GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
+ "use gnulib module iswctype for portability");
+# endif
+#endif
+
+#if @REPLACE_TOWLOWER@ || defined __MINGW32__
+_GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
+_GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
+#else
+_GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
+_GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
+#endif
+_GL_CXXALIASWARN (towlower);
+_GL_CXXALIASWARN (towupper);
+
+#if !@HAVE_WCTRANS_T@
+# if !GNULIB_defined_wctrans_t
+typedef void * wctrans_t;
+# define GNULIB_defined_wctrans_t 1
+# endif
+#endif
+
+/* Get a descriptor for a wide character case conversion. */
+#if @GNULIB_WCTRANS@
+# if !@HAVE_WCTRANS_T@
+_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
+# endif
+_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
+_GL_CXXALIASWARN (wctrans);
+#elif defined GNULIB_POSIXCHECK
+# undef wctrans
+# if HAVE_RAW_DECL_WCTRANS
+_GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
+ "use gnulib module wctrans for portability");
+# endif
+#endif
+
+/* Perform a given case conversion on a wide character.
+ The argument WC must be either a wchar_t value or WEOF.
+ The argument DESC must have been returned by the wctrans() function. */
+#if @GNULIB_TOWCTRANS@
+# if !@HAVE_WCTRANS_T@
+_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
+# endif
+_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
+_GL_CXXALIASWARN (towctrans);
+#elif defined GNULIB_POSIXCHECK
+# undef towctrans
+# if HAVE_RAW_DECL_TOWCTRANS
+_GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
+ "use gnulib module towctrans for portability");
+# endif
+#endif
+
+_GL_INLINE_HEADER_END
+
+#endif /* _@GUARD_PREFIX@_WCTYPE_H */
+#endif /* _@GUARD_PREFIX@_WCTYPE_H */
+#endif
diff --git a/grub-core/lib/gnulib/wcwidth.c b/grub-core/lib/gnulib/wcwidth.c
new file mode 100644
index 0000000..1f081cc
--- /dev/null
+++ b/grub-core/lib/gnulib/wcwidth.c
@@ -0,0 +1,73 @@
+/* Determine the number of screen columns needed for a character.
+ Copyright (C) 2006-2007, 2010-2019 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <wchar.h>
+
+/* Get iswprint. */
+#include <wctype.h>
+
+#include "localcharset.h"
+#include "streq.h"
+#include "uniwidth.h"
+
+/* Returns 1 if the current locale is an UTF-8 locale, 0 otherwise. */
+static inline int
+is_locale_utf8 (void)
+{
+ const char *encoding = locale_charset ();
+ return STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0);
+}
+
+#if GNULIB_WCHAR_SINGLE
+/* When we know that the locale does not change, provide a speedup by
+ caching the value of is_locale_utf8. */
+static int cached_is_locale_utf8 = -1;
+static inline int
+is_locale_utf8_cached (void)
+{
+ if (cached_is_locale_utf8 < 0)
+ cached_is_locale_utf8 = is_locale_utf8 ();
+ return cached_is_locale_utf8;
+}
+#else
+/* By default, don't make assumptions, hence no caching. */
+# define is_locale_utf8_cached is_locale_utf8
+#endif
+
+int
+wcwidth (wchar_t wc)
+#undef wcwidth
+{
+ /* In UTF-8 locales, use a Unicode aware width function. */
+ if (is_locale_utf8_cached ())
+ {
+ /* We assume that in a UTF-8 locale, a wide character is the same as a
+ Unicode character. */
+ return uc_width (wc, "UTF-8");
+ }
+ else
+ {
+ /* Otherwise, fall back to the system's wcwidth function. */
+#if HAVE_WCWIDTH
+ return wcwidth (wc);
+#else
+ return wc == 0 ? 0 : iswprint (wc) ? 1 : -1;
+#endif
+ }
+}
diff --git a/grub-core/lib/gnulib/xalloc-oversized.h b/grub-core/lib/gnulib/xalloc-oversized.h
new file mode 100644
index 0000000..e3068c8
--- /dev/null
+++ b/grub-core/lib/gnulib/xalloc-oversized.h
@@ -0,0 +1,60 @@
+/* xalloc-oversized.h -- memory allocation size checking
+
+ Copyright (C) 1990-2000, 2003-2004, 2006-2019 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef XALLOC_OVERSIZED_H_
+#define XALLOC_OVERSIZED_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+/* True if N * S would overflow in a size_t calculation,
+ or would generate a value larger than PTRDIFF_MAX.
+ This expands to a constant expression if N and S are both constants.
+ By gnulib convention, SIZE_MAX represents overflow in size
+ calculations, so the conservative size_t-based dividend to use here
+ is SIZE_MAX - 1. */
+#define __xalloc_oversized(n, s) \
+ ((size_t) (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) < (n))
+
+#if PTRDIFF_MAX < SIZE_MAX
+typedef ptrdiff_t __xalloc_count_type;
+#else
+typedef size_t __xalloc_count_type;
+#endif
+
+/* Return 1 if an array of N objects, each of size S, cannot exist
+ reliably due to size or ptrdiff_t arithmetic overflow. S must be
+ positive and N must be nonnegative. This is a macro, not a
+ function, so that it works correctly even when SIZE_MAX < N. */
+
+#if 7 <= __GNUC__
+# define xalloc_oversized(n, s) \
+ __builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1)
+#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__
+# define xalloc_oversized(n, s) \
+ (__builtin_constant_p (n) && __builtin_constant_p (s) \
+ ? __xalloc_oversized (n, s) \
+ : ({ __xalloc_count_type __xalloc_count; \
+ __builtin_mul_overflow (n, s, &__xalloc_count); }))
+
+/* Other compilers use integer division; this may be slower but is
+ more portable. */
+#else
+# define xalloc_oversized(n, s) __xalloc_oversized (n, s)
+#endif
+
+#endif /* !XALLOC_OVERSIZED_H_ */
diff --git a/grub-core/lib/gnulib/xsize.c b/grub-core/lib/gnulib/xsize.c
new file mode 100644
index 0000000..4b4914c
--- /dev/null
+++ b/grub-core/lib/gnulib/xsize.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define XSIZE_INLINE _GL_EXTERN_INLINE
+#include "xsize.h"
diff --git a/grub-core/lib/gnulib/xsize.h b/grub-core/lib/gnulib/xsize.h
new file mode 100644
index 0000000..ecfd478
--- /dev/null
+++ b/grub-core/lib/gnulib/xsize.h
@@ -0,0 +1,117 @@
+/* xsize.h -- Checked size_t computations.
+
+ Copyright (C) 2003, 2008-2019 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, 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _XSIZE_H
+#define _XSIZE_H
+
+/* Get size_t. */
+#include <stddef.h>
+
+/* Get SIZE_MAX. */
+#include <limits.h>
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef XSIZE_INLINE
+# define XSIZE_INLINE _GL_INLINE
+#endif
+
+/* The size of memory objects is often computed through expressions of
+ type size_t. Example:
+ void* p = malloc (header_size + n * element_size).
+ These computations can lead to overflow. When this happens, malloc()
+ returns a piece of memory that is way too small, and the program then
+ crashes while attempting to fill the memory.
+ To avoid this, the functions and macros in this file check for overflow.
+ The convention is that SIZE_MAX represents overflow.
+ malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc
+ implementation that uses mmap --, it's recommended to use size_overflow_p()
+ or size_in_bounds_p() before invoking malloc().
+ The example thus becomes:
+ size_t size = xsum (header_size, xtimes (n, element_size));
+ void *p = (size_in_bounds_p (size) ? malloc (size) : NULL);
+*/
+
+/* Convert an arbitrary value >= 0 to type size_t. */
+#define xcast_size_t(N) \
+ ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
+
+/* Sum of two sizes, with overflow check. */
+XSIZE_INLINE size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum (size_t size1, size_t size2)
+{
+ size_t sum = size1 + size2;
+ return (sum >= size1 ? sum : SIZE_MAX);
+}
+
+/* Sum of three sizes, with overflow check. */
+XSIZE_INLINE size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum3 (size_t size1, size_t size2, size_t size3)
+{
+ return xsum (xsum (size1, size2), size3);
+}
+
+/* Sum of four sizes, with overflow check. */
+XSIZE_INLINE size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
+{
+ return xsum (xsum (xsum (size1, size2), size3), size4);
+}
+
+/* Maximum of two sizes, with overflow check. */
+XSIZE_INLINE size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xmax (size_t size1, size_t size2)
+{
+ /* No explicit check is needed here, because for any n:
+ max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX. */
+ return (size1 >= size2 ? size1 : size2);
+}
+
+/* Multiplication of a count with an element size, with overflow check.
+ The count must be >= 0 and the element size must be > 0.
+ This is a macro, not a function, so that it works correctly even
+ when N is of a wider type and N > SIZE_MAX. */
+#define xtimes(N, ELSIZE) \
+ ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
+
+/* Check for overflow. */
+#define size_overflow_p(SIZE) \
+ ((SIZE) == SIZE_MAX)
+/* Check against overflow. */
+#define size_in_bounds_p(SIZE) \
+ ((SIZE) != SIZE_MAX)
+
+_GL_INLINE_HEADER_END
+
+#endif /* _XSIZE_H */
diff --git a/grub-core/lib/hexdump.c b/grub-core/lib/hexdump.c
new file mode 100644
index 0000000..317635a
--- /dev/null
+++ b/grub-core/lib/hexdump.c
@@ -0,0 +1,85 @@
+/* hexdump.c - hexdump function */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/lib/hexdump.h>
+
+void
+hexdump (unsigned long bse, char *buf, int len)
+{
+ int pos;
+ char line[80];
+
+ while (len > 0)
+ {
+ int cnt, i;
+
+ pos = grub_snprintf (line, sizeof (line), "%08lx ", bse);
+ cnt = 16;
+ if (cnt > len)
+ cnt = len;
+
+ for (i = 0; i < cnt; i++)
+ {
+ pos += grub_snprintf (&line[pos], sizeof (line) - pos,
+ "%02x ", (unsigned char) buf[i]);
+ if ((i & 7) == 7)
+ line[pos++] = ' ';
+ }
+
+ for (; i < 16; i++)
+ {
+ pos += grub_snprintf (&line[pos], sizeof (line) - pos, " ");
+ if ((i & 7) == 7)
+ line[pos++] = ' ';
+ }
+
+ line[pos++] = '|';
+
+ for (i = 0; i < cnt; i++)
+ line[pos++] = ((buf[i] >= 32) && (buf[i] < 127)) ? buf[i] : '.';
+
+ line[pos++] = '|';
+
+ line[pos] = 0;
+
+ grub_printf ("%s\n", line);
+
+ /* Print only first and last line if more than 3 lines are identical. */
+ if (len >= 4 * 16
+ && ! grub_memcmp (buf, buf + 1 * 16, 16)
+ && ! grub_memcmp (buf, buf + 2 * 16, 16)
+ && ! grub_memcmp (buf, buf + 3 * 16, 16))
+ {
+ grub_printf ("*\n");
+ do
+ {
+ bse += 16;
+ buf += 16;
+ len -= 16;
+ }
+ while (len >= 3 * 16 && ! grub_memcmp (buf, buf + 2 * 16, 16));
+ }
+
+ bse += 16;
+ buf += 16;
+ len -= cnt;
+ }
+}
diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c
new file mode 100644
index 0000000..c3e03c7
--- /dev/null
+++ b/grub-core/lib/i386/backtrace.c
@@ -0,0 +1,66 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+#include <grub/backtrace.h>
+
+#define MAX_STACK_FRAME 102400
+
+void
+grub_backtrace_pointer (void *ebp)
+{
+ void *ptr, *nptr;
+ unsigned i;
+
+ ptr = ebp;
+ while (1)
+ {
+ grub_printf ("%p: ", ptr);
+ grub_backtrace_print_address (((void **) ptr)[1]);
+ grub_printf (" (");
+ for (i = 0; i < 2; i++)
+ grub_printf ("%p,", ((void **)ptr) [i + 2]);
+ grub_printf ("%p)\n", ((void **)ptr) [i + 2]);
+ nptr = *(void **)ptr;
+ if (nptr < ptr || (void **) nptr - (void **) ptr > MAX_STACK_FRAME
+ || nptr == ptr)
+ {
+ grub_printf ("Invalid stack frame at %p (%p)\n", ptr, nptr);
+ break;
+ }
+ ptr = nptr;
+ }
+}
+
+void
+grub_backtrace (void)
+{
+#ifdef __x86_64__
+ asm volatile ("movq %%rbp, %%rdi\n"
+ "callq *%%rax": :"a"(grub_backtrace_pointer));
+#else
+ asm volatile ("movl %%ebp, %%eax\n"
+ "calll *%%ecx": :"c"(grub_backtrace_pointer));
+#endif
+}
+
diff --git a/grub-core/lib/i386/halt.c b/grub-core/lib/i386/halt.c
new file mode 100644
index 0000000..2364fe4
--- /dev/null
+++ b/grub-core/lib/i386/halt.c
@@ -0,0 +1,82 @@
+/*
+ * 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/cpu/io.h>
+#include <grub/misc.h>
+#include <grub/acpi.h>
+#include <grub/i18n.h>
+#include <grub/pci.h>
+#include <grub/mm.h>
+
+const char bochs_shutdown[] = "Shutdown";
+
+/*
+ * This call is special... it never returns... in fact it should simply
+ * hang at this point!
+ */
+static inline void __attribute__ ((noreturn))
+stop (void)
+{
+ asm volatile ("cli");
+ while (1)
+ {
+ asm volatile ("hlt");
+ }
+}
+
+static int
+grub_shutdown_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ /* QEMU. */
+ if (pciid == 0x71138086)
+ {
+ grub_pci_address_t addr;
+ addr = grub_pci_make_address (dev, 0x40);
+ grub_pci_write (addr, 0x7001);
+ addr = grub_pci_make_address (dev, 0x80);
+ grub_pci_write (addr, grub_pci_read (addr) | 1);
+ grub_outw (0x2000, 0x7004);
+ }
+ return 0;
+}
+
+void
+grub_halt (void)
+{
+ unsigned int i;
+
+#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT)
+ grub_acpi_halt ();
+#endif
+
+ /* Disable interrupts. */
+ asm volatile ("cli");
+
+ /* Bochs, QEMU, etc. Removed in newer QEMU releases. */
+ for (i = 0; i < sizeof (bochs_shutdown) - 1; i++)
+ grub_outb (bochs_shutdown[i], 0x8900);
+
+ grub_pci_iterate (grub_shutdown_pci_iter, NULL);
+
+ grub_puts_ (N_("GRUB doesn't know how to halt this machine yet!"));
+
+ /* In order to return we'd have to check what the previous status of IF
+ flag was. But user most likely doesn't want to return anyway ... */
+ stop ();
+}
diff --git a/grub-core/lib/i386/pc/biosnum.c b/grub-core/lib/i386/pc/biosnum.c
new file mode 100644
index 0000000..0f0e743
--- /dev/null
+++ b/grub-core/lib/i386/pc/biosnum.c
@@ -0,0 +1,47 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/disk.h>
+#include <grub/machine/biosnum.h>
+
+static int
+grub_get_root_biosnumber_default (void)
+{
+ const char *biosnum;
+ int ret = -1;
+ grub_device_t dev;
+
+ biosnum = grub_env_get ("biosnum");
+
+ if (biosnum)
+ return grub_strtoul (biosnum, 0, 0);
+
+ dev = grub_device_open (0);
+ if (dev && dev->disk && dev->disk->dev
+ && dev->disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID)
+ ret = (int) dev->disk->id;
+
+ if (dev)
+ grub_device_close (dev);
+
+ return ret;
+}
+
+int (*grub_get_root_biosnumber) (void) = grub_get_root_biosnumber_default;
diff --git a/grub-core/lib/i386/pc/vesa_modes_table.c b/grub-core/lib/i386/pc/vesa_modes_table.c
new file mode 100644
index 0000000..6dc4b7d
--- /dev/null
+++ b/grub-core/lib/i386/pc/vesa_modes_table.c
@@ -0,0 +1,127 @@
+
+#include <grub/i386/pc/vesa_modes_table.h>
+
+/* This is the reverse of the table in [linux]/Documentation/fb/vesafb.txt
+ plus a few more modes based on the table in
+ http://en.wikipedia.org/wiki/VESA_BIOS_Extensions */
+struct grub_vesa_mode_table_entry
+grub_vesa_mode_table[GRUB_VESA_MODE_TABLE_END
+ - GRUB_VESA_MODE_TABLE_START + 1] =
+ {
+ { 640, 400, 8 }, /* 0x300 */
+ { 640, 480, 8 }, /* 0x301 */
+ { 800, 600, 4 }, /* 0x302 */
+ { 800, 600, 8 }, /* 0x303 */
+ { 1024, 768, 4 }, /* 0x304 */
+ { 1024, 768, 8 }, /* 0x305 */
+ { 1280, 1024, 4 }, /* 0x306 */
+ { 1280, 1024, 8 }, /* 0x307 */
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 320, 200, 15 }, /* 0x30d */
+ { 320, 200, 16 }, /* 0x30e */
+ { 320, 200, 24 }, /* 0x30f */
+ { 640, 480, 15 }, /* 0x310 */
+ { 640, 480, 16 }, /* 0x311 */
+ { 640, 480, 24 }, /* 0x312 */
+ { 800, 600, 15 }, /* 0x313 */
+ { 800, 600, 16 }, /* 0x314 */
+ { 800, 600, 24 }, /* 0x315 */
+ { 1024, 768, 15 }, /* 0x316 */
+ { 1024, 768, 16 }, /* 0x317 */
+ { 1024, 768, 24 }, /* 0x318 */
+ { 1280, 1024, 15 }, /* 0x319 */
+ { 1280, 1024, 16 }, /* 0x31a */
+ { 1280, 1024, 24 }, /* 0x31b */
+ { 1600, 1200, 8 }, /* 0x31c */
+ { 1600, 1200, 15 }, /* 0x31d */
+ { 1600, 1200, 16 }, /* 0x31e */
+ { 1600, 1200, 24 }, /* 0x31f */
+ { 0, 0, 0 },
+ { 640, 400, 15 }, /* 0x321 */
+ { 640, 400, 16 }, /* 0x322 */
+ { 640, 400, 24 }, /* 0x323 */
+ { 640, 400, 32 }, /* 0x324 */
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 640, 480, 32 }, /* 0x329 */
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 896, 672, 8 }, /* 0x32f */
+ { 896, 672, 15 }, /* 0x330 */
+ { 896, 672, 16 }, /* 0x331 */
+ { 896, 672, 24 }, /* 0x332 */
+ { 896, 672, 32 }, /* 0x333 */
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 1600, 1200, 32 }, /* 0x342 */
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 1440, 900, 8 }, /* 0x360 */
+ { 1440, 900, 15 }, /* 0x361 */
+ { 1440, 900, 16 }, /* 0x362 */
+ { 1440, 900, 24 }, /* 0x363 */
+ { 1440, 900, 32 }, /* 0x364 */
+ { 1152, 720, 8 }, /* 0x365 */
+ { 1152, 720, 15 }, /* 0x366 */
+ { 1152, 720, 16 }, /* 0x367 */
+ { 1152, 720, 24 }, /* 0x368 */
+ { 1152, 720, 32 }, /* 0x369 */
+ { 1024, 640, 8 }, /* 0x36a */
+ { 1024, 640, 15 }, /* 0x36b */
+ { 1024, 640, 16 }, /* 0x36c */
+ { 1024, 640, 24 }, /* 0x36d */
+ { 1024, 640, 32 }, /* 0x36e */
+ { 800, 500, 8 }, /* 0x36f */
+ { 800, 500, 15 }, /* 0x370 */
+ { 800, 500, 16 }, /* 0x371 */
+ { 800, 500, 24 }, /* 0x372 */
+ { 800, 500, 32 }, /* 0x373 */
+ };
diff --git a/grub-core/lib/i386/random.c b/grub-core/lib/i386/random.c
new file mode 100644
index 0000000..cd83d2f
--- /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/reboot.c b/grub-core/lib/i386/reboot.c
new file mode 100644
index 0000000..dce0b56
--- /dev/null
+++ b/grub-core/lib/i386/reboot.c
@@ -0,0 +1,64 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_MACHINE_EFI
+
+#include <grub/relocator.h>
+#include <grub/cpu/relocator.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/cpu/reboot.h>
+#include <grub/i386/floppy.h>
+
+void
+grub_reboot (void)
+{
+ struct grub_relocator *relocator = NULL;
+ grub_relocator_chunk_t ch;
+ grub_err_t err;
+ void *buf;
+ struct grub_relocator16_state state;
+ grub_uint16_t segment;
+
+ relocator = grub_relocator_new ();
+ if (!relocator)
+ while (1);
+ err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x1000, 0x1000,
+ grub_reboot_end - grub_reboot_start,
+ 16, GRUB_RELOCATOR_PREFERENCE_NONE,
+ 0);
+ if (err)
+ while (1);
+ buf = get_virtual_current_address (ch);
+ grub_memcpy (buf, grub_reboot_start, grub_reboot_end - grub_reboot_start);
+
+ segment = ((grub_addr_t) get_physical_target_address (ch)) >> 4;
+ state.gs = state.fs = state.es = state.ds = state.ss = segment;
+ state.sp = 0;
+ state.cs = segment;
+ state.ip = 0;
+ state.a20 = 0;
+
+ grub_stop_floppy ();
+
+ err = grub_relocator16_boot (relocator, state);
+
+ while (1);
+}
+
+#endif /* GRUB_MACHINE_EFI */
diff --git a/grub-core/lib/i386/reboot_trampoline.S b/grub-core/lib/i386/reboot_trampoline.S
new file mode 100644
index 0000000..c088cd0
--- /dev/null
+++ b/grub-core/lib/i386/reboot_trampoline.S
@@ -0,0 +1,34 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/symbol.h>
+#include <grub/i386/reboot.h>
+
+ .p2align 4
+
+VARIABLE(grub_reboot_start)
+ .code16
+
+ /* set 0x472 to 0x0000 for cold boot (0x1234 for warm boot) */
+ movw $0x0472, %di
+ xorw %ax, %ax
+ movw %ax, (%di)
+ ljmp $0xf000, $0xfff0
+
+ .code32
+VARIABLE(grub_reboot_end)
diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c
new file mode 100644
index 0000000..34cbe83
--- /dev/null
+++ b/grub-core/lib/i386/relocator.c
@@ -0,0 +1,210 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/term.h>
+
+#include <grub/i386/relocator.h>
+#include <grub/relocator_private.h>
+#include <grub/i386/relocator_private.h>
+#include <grub/i386/pc/int.h>
+
+extern grub_uint8_t grub_relocator16_start;
+extern grub_uint8_t grub_relocator16_end;
+extern grub_uint16_t grub_relocator16_cs;
+extern grub_uint16_t grub_relocator16_ip;
+extern grub_uint16_t grub_relocator16_ds;
+extern grub_uint16_t grub_relocator16_es;
+extern grub_uint16_t grub_relocator16_fs;
+extern grub_uint16_t grub_relocator16_gs;
+extern grub_uint16_t grub_relocator16_ss;
+extern grub_uint16_t grub_relocator16_sp;
+extern grub_uint32_t grub_relocator16_edx;
+extern grub_uint32_t grub_relocator16_ebx;
+extern grub_uint32_t grub_relocator16_esi;
+extern grub_uint32_t grub_relocator16_ebp;
+
+extern grub_uint16_t grub_relocator16_keep_a20_enabled;
+
+extern grub_uint8_t grub_relocator32_start;
+extern grub_uint8_t grub_relocator32_end;
+extern grub_uint32_t grub_relocator32_eax;
+extern grub_uint32_t grub_relocator32_ebx;
+extern grub_uint32_t grub_relocator32_ecx;
+extern grub_uint32_t grub_relocator32_edx;
+extern grub_uint32_t grub_relocator32_eip;
+extern grub_uint32_t grub_relocator32_esp;
+extern grub_uint32_t grub_relocator32_ebp;
+extern grub_uint32_t grub_relocator32_esi;
+extern grub_uint32_t grub_relocator32_edi;
+
+extern grub_uint8_t grub_relocator64_start;
+extern grub_uint8_t grub_relocator64_end;
+extern grub_uint64_t grub_relocator64_rax;
+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_rsp;
+extern grub_uint64_t grub_relocator64_rsi;
+extern grub_addr_t grub_relocator64_cr3;
+extern struct grub_i386_idt grub_relocator16_idt;
+
+#define RELOCATOR_SIZEOF(x) (&grub_relocator##x##_end - &grub_relocator##x##_start)
+
+grub_err_t
+grub_relocator32_boot (struct grub_relocator *rel,
+ struct grub_relocator32_state state,
+ int avoid_efi_bootservices)
+{
+ grub_err_t err;
+ void *relst;
+ grub_relocator_chunk_t ch;
+
+ /* 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_safe (rel, &ch, 0x1000, 0x9a000,
+ RELOCATOR_SIZEOF (32), 16,
+ GRUB_RELOCATOR_PREFERENCE_LOW,
+ avoid_efi_bootservices);
+ if (err)
+ return err;
+
+ grub_relocator32_eax = state.eax;
+ grub_relocator32_ebx = state.ebx;
+ grub_relocator32_ecx = state.ecx;
+ grub_relocator32_edx = state.edx;
+ grub_relocator32_eip = state.eip;
+ grub_relocator32_esp = state.esp;
+ grub_relocator32_ebp = state.ebp;
+ grub_relocator32_esi = state.esi;
+ grub_relocator32_edi = state.edi;
+
+ grub_memmove (get_virtual_current_address (ch), &grub_relocator32_start,
+ RELOCATOR_SIZEOF (32));
+
+ err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
+ &relst, NULL);
+ if (err)
+ return err;
+
+ asm volatile ("cli");
+ ((void (*) (void)) relst) ();
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_relocator16_boot (struct grub_relocator *rel,
+ struct grub_relocator16_state state)
+{
+ grub_err_t err;
+ void *relst;
+ grub_relocator_chunk_t ch;
+
+ /* Put it higher than the byte it checks for A20 check. */
+ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, 0x8010, 0xa0000,
+ RELOCATOR_SIZEOF (16) +
+ GRUB_RELOCATOR16_STACK_SIZE, 16,
+ GRUB_RELOCATOR_PREFERENCE_NONE, 0);
+ if (err)
+ return err;
+
+ grub_relocator16_cs = state.cs;
+ grub_relocator16_ip = state.ip;
+
+ grub_relocator16_ds = state.ds;
+ grub_relocator16_es = state.es;
+ grub_relocator16_fs = state.fs;
+ grub_relocator16_gs = state.gs;
+
+ grub_relocator16_ss = state.ss;
+ grub_relocator16_sp = state.sp;
+
+ grub_relocator16_ebp = state.ebp;
+ grub_relocator16_ebx = state.ebx;
+ grub_relocator16_edx = state.edx;
+ grub_relocator16_esi = state.esi;
+#ifdef GRUB_MACHINE_PCBIOS
+ grub_relocator16_idt = *grub_realidt;
+#else
+ grub_relocator16_idt.base = 0;
+ grub_relocator16_idt.limit = 0;
+#endif
+
+ grub_relocator16_keep_a20_enabled = state.a20;
+
+ grub_memmove (get_virtual_current_address (ch), &grub_relocator16_start,
+ RELOCATOR_SIZEOF (16));
+
+ err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
+ &relst, NULL);
+ if (err)
+ return err;
+
+ asm volatile ("cli");
+ ((void (*) (void)) relst) ();
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_relocator64_boot (struct grub_relocator *rel,
+ struct grub_relocator64_state state,
+ grub_addr_t min_addr, grub_addr_t max_addr)
+{
+ grub_err_t err;
+ void *relst;
+ grub_relocator_chunk_t ch;
+
+ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, min_addr, max_addr,
+ RELOCATOR_SIZEOF (64), 16,
+ GRUB_RELOCATOR_PREFERENCE_NONE, 0);
+ if (err)
+ return err;
+
+ grub_relocator64_rax = state.rax;
+ grub_relocator64_rbx = state.rbx;
+ grub_relocator64_rcx = state.rcx;
+ grub_relocator64_rdx = state.rdx;
+ grub_relocator64_rip = state.rip;
+ grub_relocator64_rsp = state.rsp;
+ grub_relocator64_rsi = state.rsi;
+ grub_relocator64_cr3 = state.cr3;
+
+ grub_memmove (get_virtual_current_address (ch), &grub_relocator64_start,
+ RELOCATOR_SIZEOF (64));
+
+ err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
+ &relst, NULL);
+ if (err)
+ return err;
+
+ asm volatile ("cli");
+ ((void (*) (void)) relst) ();
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/lib/i386/relocator16.S b/grub-core/lib/i386/relocator16.S
new file mode 100644
index 0000000..e923811
--- /dev/null
+++ b/grub-core/lib/i386/relocator16.S
@@ -0,0 +1,341 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* The code segment of the protected mode. */
+#define CODE_SEGMENT 0x08
+
+/* The data segment of the protected mode. */
+#define DATA_SEGMENT 0x10
+
+#define PSEUDO_REAL_CSEG 0x18
+
+#define PSEUDO_REAL_DSEG 0x20
+
+#include <grub/i386/relocator_private.h>
+
+#include "relocator_common.S"
+
+ .p2align 4 /* force 16-byte alignment */
+
+VARIABLE(grub_relocator16_start)
+ PREAMBLE
+
+#ifdef __APPLE__
+ LOCAL(cs_base_bytes12_offset) = LOCAL (cs_base_bytes12) - LOCAL (base)
+ LOCAL(cs_base_byte3_offset) = LOCAL (cs_base_byte3) - LOCAL (base)
+ LOCAL(ds_base_bytes12_offset) = LOCAL (ds_base_bytes12) - LOCAL (base)
+ LOCAL(ds_base_byte3_offset) = LOCAL (ds_base_byte3) - LOCAL (base)
+ movl %esi, %eax
+ movw %ax, (LOCAL(cs_base_bytes12_offset)) (RSI, 1)
+ movw %ax, (LOCAL(ds_base_bytes12_offset)) (RSI, 1)
+ shrl $16, %eax
+ movb %al, (LOCAL (cs_base_byte3_offset)) (RSI, 1)
+ movb %al, (LOCAL (ds_base_byte3_offset)) (RSI, 1)
+#else
+ movl %esi, %eax
+ movw %ax, (LOCAL (cs_base_bytes12) - LOCAL (base)) (RSI, 1)
+ movw %ax, (LOCAL (ds_base_bytes12) - LOCAL (base)) (RSI, 1)
+ shrl $16, %eax
+ movb %al, (LOCAL (cs_base_byte3) - LOCAL (base)) (RSI, 1)
+ movb %al, (LOCAL (ds_base_byte3) - LOCAL (base)) (RSI, 1)
+#endif
+
+ RELOAD_GDT
+ .code32
+ /* Update other registers. */
+ movl $DATA_SEGMENT, %eax
+ movl %eax, %ds
+ movl %eax, %es
+ movl %eax, %fs
+ movl %eax, %gs
+ movl %eax, %ss
+
+ DISABLE_PAGING
+
+#ifdef __x86_64__
+ /* Disable amd64. */
+ movl $GRUB_MEMORY_CPU_AMD64_MSR, %ecx
+ rdmsr
+ andl $(~GRUB_MEMORY_CPU_AMD64_MSR_ON), %eax
+ wrmsr
+#endif
+
+ /* Turn off PAE. */
+ movl %cr4, %eax
+ andl $(~GRUB_MEMORY_CPU_CR4_PAE_ON), %eax
+ movl %eax, %cr4
+
+ /* Update other registers. */
+ movl $PSEUDO_REAL_DSEG, %eax
+ movl %eax, %ds
+ movl %eax, %es
+ movl %eax, %fs
+ movl %eax, %gs
+ movl %eax, %ss
+
+ movl %esi, %eax
+ shrl $4, %eax
+#ifdef __APPLE__
+ LOCAL(segment_offset) = LOCAL (segment) - LOCAL (base)
+ LOCAL(idt_offset) = LOCAL(relocator16_idt) - LOCAL (base)
+ LOCAL(cont2_offset) = LOCAL (cont2) - LOCAL(base)
+ movw %ax, (LOCAL(segment_offset))
+ lidt (LOCAL(idt_offset))
+
+ /* jump to a 16 bit segment */
+ ljmp $PSEUDO_REAL_CSEG, $(LOCAL(cont2_offset))
+#else
+ movw %ax, (LOCAL (segment) - LOCAL (base))
+
+ lidt (EXT_C(grub_relocator16_idt) - LOCAL (base))
+
+ /* jump to a 16 bit segment */
+ ljmp $PSEUDO_REAL_CSEG, $(LOCAL (cont2) - LOCAL(base))
+#endif
+LOCAL(cont2):
+ .code16
+
+ /* clear the PE bit of CR0 */
+ movl %cr0, %eax
+ andl $(~GRUB_MEMORY_CPU_CR0_PE_ON), %eax
+ movl %eax, %cr0
+
+ /* flush prefetch queue, reload %cs */
+ /* ljmp */
+ .byte 0xea
+#ifdef __APPLE__
+ LOCAL(cont3_offset) = LOCAL(cont3) - LOCAL(base)
+ .word LOCAL(cont3_offset)
+#else
+ .word LOCAL(cont3)-LOCAL(base)
+#endif
+LOCAL(segment):
+ .word 0
+
+LOCAL(cont3):
+
+ /* movw imm16, %ax. */
+ .byte 0xb8
+VARIABLE(grub_relocator16_keep_a20_enabled)
+ .word 0
+
+ test %ax, %ax
+ jnz LOCAL(gate_a20_done)
+
+ movw %cs, %ax
+ movw %ax, %ss
+#ifdef __APPLE__
+ LOCAL(relocator16_end_offset) = LOCAL(relocator16_end) - LOCAL(base)
+ leaw LOCAL(relocator16_end_offset), %sp
+#else
+ leaw LOCAL(relocator16_end) - LOCAL(base), %sp
+#endif
+ addw $GRUB_RELOCATOR16_STACK_SIZE, %sp
+
+ /* second, try a BIOS call */
+ movw $0x2400, %ax
+ int $0x15
+
+ call LOCAL(gate_a20_check_state)
+ testb %al, %al
+ jz LOCAL(gate_a20_done)
+
+ /*
+ * In macbook, the keyboard test would hang the machine, so we move
+ * this forward.
+ */
+ /* fourth, try the system control port A */
+ inb $0x92
+ andb $(~0x03), %al
+ outb $0x92
+
+ /* When turning off Gate A20, do not check the state strictly,
+ because a failure is not fatal usually, and Gate A20 is always
+ on some modern machines. */
+ jmp LOCAL(gate_a20_done)
+
+LOCAL(gate_a20_check_state):
+ /* iterate the checking for a while */
+ movw $100, %cx
+1:
+ xorw %ax, %ax
+ movw %ax, %ds
+ decw %ax
+ movw %ax, %es
+ xorw %ax, %ax
+
+ movw $0x8000, %ax
+ /* compare the byte at ADDR with that at 0x100000 + ADDR */
+ movw %ax, %si
+ addw $0x10, %ax
+ movw %ax, %di
+
+ /* save the original byte in DL */
+ movb %ds:(%si), %dl
+ movb %es:(%di), %al
+ /* try to set one less value at ADDR */
+ movb %al, %dh
+ decb %dh
+ movb %dh, %ds:(%si)
+ /* serialize */
+ outb %al, $0x80
+ outb %al, $0x80
+ /* obtain the value at 0x100000 + ADDR in CH */
+ movb %es:(%di), %dh
+ /* this result is 1 if A20 is on or 0 if it is off */
+ subb %dh, %al
+ xorb $1, %al
+ /* restore the original */
+ movb %dl, %ds:(%si)
+
+ testb %al, %al
+ jz LOCAL(gate_a20_done)
+ loop 1b
+2:
+ ret
+
+LOCAL(gate_a20_done):
+ /*
+ * We are in real mode now. Set up the real mode segment registers and
+ * all the other general purpose registers. cs is updated with ljmp.
+ */
+ /* movw imm16, %ax. */
+ .byte 0xb8
+VARIABLE(grub_relocator16_ds)
+ .word 0
+ movw %ax, %ds
+
+ /* movw imm16, %ax. */
+ .byte 0xb8
+VARIABLE(grub_relocator16_es)
+ .word 0
+ movw %ax, %es
+
+ /* movw imm16, %ax. */
+ .byte 0xb8
+VARIABLE(grub_relocator16_fs)
+ .word 0
+ movw %ax, %fs
+
+ /* movw imm16, %ax. */
+ .byte 0xb8
+VARIABLE(grub_relocator16_gs)
+ .word 0
+ movw %ax, %gs
+
+ /* movw imm16, %ax. */
+ .byte 0xb8
+VARIABLE(grub_relocator16_ss)
+ .word 0
+ movw %ax, %ss
+
+ /* movw imm16, %ax. */
+ .byte 0xb8
+VARIABLE(grub_relocator16_sp)
+ .word 0
+ movzwl %ax, %esp
+
+ /* movw imm32, %eax. */
+ .byte 0x66, 0xb8
+VARIABLE(grub_relocator16_esi)
+ .long 0
+ movl %eax, %esi
+
+ /* movw imm32, %edx. */
+ .byte 0x66, 0xba
+VARIABLE(grub_relocator16_edx)
+ .long 0
+
+ /* movw imm32, %ebx. */
+ .byte 0x66, 0xbb
+VARIABLE(grub_relocator16_ebx)
+ .long 0
+
+ /* movl imm32, %ebp. */
+ .byte 0x66, 0xbd
+VARIABLE(grub_relocator16_ebp)
+ .long 0
+
+ /* Cleared direction flag is of no problem with any current
+ payload and makes this implementation easier. */
+ cld
+
+ /* ljmp */
+ .byte 0xea
+VARIABLE(grub_relocator16_ip)
+ .word 0
+VARIABLE(grub_relocator16_cs)
+ .word 0
+
+ .code32
+
+ /* GDT. Copied from loader/i386/linux.c. */
+ .p2align 4
+LOCAL(gdt):
+ .word 0, 0
+ .byte 0, 0, 0, 0
+
+ /* -- code segment --
+ * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
+ * type = 32bit code execute/read, DPL = 0
+ */
+ .word 0xFFFF, 0
+ .byte 0, 0x9A, 0xCF, 0
+
+ /* -- data segment --
+ * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
+ * type = 32 bit data read/write, DPL = 0
+ */
+ .word 0xFFFF, 0
+ .byte 0, 0x92, 0xCF, 0
+
+ /* -- 16 bit real mode CS --
+ * base = filled by code, limit 0x0FFFF (1 B Granularity), present
+ * type = 16 bit code execute/read only/conforming, DPL = 0
+ */
+ .word 0xFFFF
+LOCAL(cs_base_bytes12):
+ .word 0
+LOCAL(cs_base_byte3):
+ .byte 0
+
+ .byte 0x9E, 0, 0
+
+ /* -- 16 bit real mode DS --
+ * base = filled by code, limit 0x0FFFF (1 B Granularity), present
+ * type = 16 bit data read/write, DPL = 0
+ */
+ .word 0xFFFF
+LOCAL(ds_base_bytes12):
+ .word 0
+LOCAL(ds_base_byte3):
+ .byte 0
+
+ .byte 0x92, 0, 0
+
+LOCAL(gdt_end):
+
+#ifdef __APPLE__
+LOCAL(relocator16_idt):
+#endif
+VARIABLE(grub_relocator16_idt)
+ .word 0
+ .long 0
+LOCAL(relocator16_end):
+VARIABLE(grub_relocator16_end)
+ .byte 0
diff --git a/grub-core/lib/i386/relocator32.S b/grub-core/lib/i386/relocator32.S
new file mode 100644
index 0000000..09ce56a
--- /dev/null
+++ b/grub-core/lib/i386/relocator32.S
@@ -0,0 +1,134 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* The code segment of the protected mode. */
+#define CODE_SEGMENT 0x10
+
+/* The data segment of the protected mode. */
+#define DATA_SEGMENT 0x18
+
+#include "relocator_common.S"
+
+ .p2align 4 /* force 16-byte alignment */
+
+VARIABLE(grub_relocator32_start)
+ PREAMBLE
+
+ RELOAD_GDT
+ .code32
+ /* Update other registers. */
+ movl $DATA_SEGMENT, %eax
+ movl %eax, %ds
+ movl %eax, %es
+ movl %eax, %fs
+ movl %eax, %gs
+ movl %eax, %ss
+
+ DISABLE_PAGING
+
+#ifdef __x86_64__
+ /* Disable amd64. */
+ movl $GRUB_MEMORY_CPU_AMD64_MSR, %ecx
+ rdmsr
+ andl $(~GRUB_MEMORY_CPU_AMD64_MSR_ON), %eax
+ wrmsr
+#endif
+
+ /* Turn off PAE. */
+ movl %cr4, %eax
+ andl $(~GRUB_MEMORY_CPU_CR4_PAE_ON), %eax
+ movl %eax, %cr4
+
+ jmp LOCAL(cont2)
+LOCAL(cont2):
+ .code32
+
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator32_esp)
+ .long 0
+
+ movl %eax, %esp
+
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator32_ebp)
+ .long 0
+
+ movl %eax, %ebp
+
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator32_esi)
+ .long 0
+
+ movl %eax, %esi
+
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator32_edi)
+ .long 0
+
+ movl %eax, %edi
+
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator32_eax)
+ .long 0
+
+ /* mov imm32, %ebx */
+ .byte 0xbb
+VARIABLE(grub_relocator32_ebx)
+ .long 0
+
+ /* mov imm32, %ecx */
+ .byte 0xb9
+VARIABLE(grub_relocator32_ecx)
+ .long 0
+
+ /* mov imm32, %edx */
+ .byte 0xba
+VARIABLE(grub_relocator32_edx)
+ .long 0
+
+ /* Cleared direction flag is of no problem with any current
+ payload and makes this implementation easier. */
+ cld
+
+ .byte 0xea
+VARIABLE(grub_relocator32_eip)
+ .long 0
+ .word CODE_SEGMENT
+
+ /* GDT. Copied from loader/i386/linux.c. */
+ .p2align 4
+LOCAL(gdt):
+ /* NULL. */
+ .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+
+ /* Reserved. */
+ .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+
+ /* Code segment. */
+ .byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
+
+ /* Data segment. */
+ .byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
+LOCAL(gdt_end):
+
+VARIABLE(grub_relocator32_end)
diff --git a/grub-core/lib/i386/relocator64.S b/grub-core/lib/i386/relocator64.S
new file mode 100644
index 0000000..00bf315
--- /dev/null
+++ b/grub-core/lib/i386/relocator64.S
@@ -0,0 +1,210 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define CODE32_SEGMENT 0x18
+#define CODE_SEGMENT 0x08
+
+/* The data segment of the protected mode. */
+#define DATA_SEGMENT 0x10
+
+#include "relocator_common.S"
+
+ .p2align 4 /* force 16-byte alignment */
+
+VARIABLE(grub_relocator64_start)
+ PREAMBLE
+#ifndef __x86_64__
+ DISABLE_PAGING
+
+ /* Turn on PAE. */
+ movl %cr4, %eax
+ orl $(GRUB_MEMORY_CPU_CR4_PAE_ON | GRUB_MEMORY_CPU_CR4_PSE_ON), %eax
+ movl %eax, %cr4
+
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator64_cr3)
+ .long 0
+ movl %eax, %cr3
+
+ /* Turn on amd64. */
+ movl $GRUB_MEMORY_CPU_AMD64_MSR, %ecx
+ rdmsr
+ orl $GRUB_MEMORY_CPU_AMD64_MSR_ON, %eax
+ wrmsr
+
+ /* Enable paging. */
+ movl %cr0, %eax
+ orl $GRUB_MEMORY_CPU_CR0_PAGING_ON, %eax
+ movl %eax, %cr0
+
+ RELOAD_GDT
+#else
+ /* mov imm64, %rax */
+ .byte 0x48
+ .byte 0xb8
+VARIABLE(grub_relocator64_cr3)
+ .quad 0
+ movq %rax, %cr3
+#endif
+
+#ifdef __x86_64__
+ .code64
+#endif
+
+ /* mov imm64, %rax */
+ .byte 0x48
+ .byte 0xb8
+VARIABLE(grub_relocator64_rsp)
+ .quad 0
+
+#ifdef __x86_64__
+ movq %rax, %rsp
+#else
+ /* movq %rax, %rsp */
+ .byte 0x48
+ .byte 0x89
+ .byte 0xc4
+#endif
+
+#ifdef GRUB_MACHINE_EFI
+ jmp LOCAL(skip_efi_stack_align)
+
+ /*
+ * Here is grub_relocator64_efi_start() entry point. Most of the
+ * code below is shared between grub_relocator64_efi_start()
+ * and grub_relocator64_start().
+ *
+ * Think twice before changing anything there!!!
+ */
+VARIABLE(grub_relocator64_efi_start)
+ /* Align the stack as UEFI spec requires. */
+#ifdef __x86_64__
+ andq $~15, %rsp
+#else
+ /* andq $~15, %rsp */
+ .byte 0x48
+ .byte 0x83
+ .byte 0xe4
+ .byte 0xf0
+#endif
+
+LOCAL(skip_efi_stack_align):
+#endif
+ /* mov imm64, %rax */
+ .byte 0x48
+ .byte 0xb8
+VARIABLE(grub_relocator64_rsi)
+ .quad 0
+
+#ifdef __x86_64__
+ movq %rax, %rsi
+#else
+ /* movq %rax, %rsi */
+ .byte 0x48
+ .byte 0x89
+ .byte 0xc6
+#endif
+
+ /* mov imm64, %rax */
+ .byte 0x48
+ .byte 0xb8
+VARIABLE(grub_relocator64_rax)
+ .quad 0
+
+ /* mov imm64, %rbx */
+ .byte 0x48
+ .byte 0xbb
+VARIABLE(grub_relocator64_rbx)
+ .quad 0
+
+ /* mov imm64, %rcx */
+ .byte 0x48
+ .byte 0xb9
+VARIABLE(grub_relocator64_rcx)
+ .quad 0
+
+ /* mov imm64, %rdx */
+ .byte 0x48
+ .byte 0xba
+VARIABLE(grub_relocator64_rdx)
+ .quad 0
+
+ /* Cleared direction flag is of no problem with any current
+ payload and makes this implementation easier. */
+ cld
+
+#if defined (__APPLE__) || !defined (__x86_64__)
+ .byte 0xff, 0x25
+ .quad 0
+#else
+ jmp *LOCAL(jump_addr) (%rip)
+#endif
+
+LOCAL(jump_addr):
+VARIABLE(grub_relocator64_rip)
+ .quad 0
+
+#ifdef GRUB_MACHINE_EFI
+ /* Here grub_relocator64_efi_start() ends. Ufff... */
+VARIABLE(grub_relocator64_efi_end)
+#endif
+
+#ifndef __x86_64__
+ .p2align 4
+LOCAL(gdt):
+ /* NULL. */
+ .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+
+ /* 64-bit segment. */
+ .word 0xffff /* Limit xffff. */
+ .word 0x0000 /* Base xxxx0000. */
+ .byte 0x00 /* Base xx00xxxx. */
+ .byte (0x8 /* Type 8. */ | (1 << 4) /* Code. */ \
+ | (0 << 5) /* Ring 0. */ | (1 << 7) /* Present. */)
+ .byte (0xf /* Limit fxxxx. */ | (0 << 4) /* AVL flag. */ \
+ | (1 << 5) /* 64-bit. */ | (0 << 6) \
+ | (1 << 7) /* 4K granular. */)
+ .byte 0x00 /* Base 00xxxxxx. */
+
+ /* Data segment*/
+ .word 0xffff /* Limit xffff. */
+ .word 0x0000 /* Base xxxx0000. */
+ .byte 0x00 /* Base xx00xxxx. */
+ .byte (0x0 /* Type 0. */ | (0 << 4) /* Data. */ \
+ | (0 << 5) /* Ring 0. */ | (1 << 7) /* Present. */)
+ .byte (0xf /* Limit fxxxx. */ | (0 << 4) /* AVL flag. */ \
+ | (0 << 5) /* Data. */ | (0 << 6) \
+ | (1 << 7) /* 4K granular. */)
+ .byte 0x00 /* Base 00xxxxxx. */
+
+ /* Compatibility segment. */
+ .word 0xffff /* Limit xffff. */
+ .word 0x0000 /* Base xxxx0000. */
+ .byte 0x00 /* Base xx00xxxx. */
+ .byte (0x8 /* Type 8. */ | (1 << 4) /* Code. */ \
+ | (0 << 5) /* Ring 0. */ | (1 << 7) /* Present. */)
+ .byte (0xf /* Limit fxxxx. */ | (0 << 4) /* AVL flag. */ \
+ | (0 << 5) /* 32-bit. */ | (1 << 6) /* 32-bit. */ \
+ | (1 << 7) /* 4K granular. */)
+ .byte 0x00 /* Base 00xxxxxx. */
+
+LOCAL(gdt_end):
+#endif
+
+VARIABLE(grub_relocator64_end)
diff --git a/grub-core/lib/i386/relocator_asm.S b/grub-core/lib/i386/relocator_asm.S
new file mode 100644
index 0000000..f273586
--- /dev/null
+++ b/grub-core/lib/i386/relocator_asm.S
@@ -0,0 +1,80 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/i386/memory.h>
+
+ .p2align 2
+
+VARIABLE(grub_relocator_backward_start)
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator_backward_dest)
+ .long 0
+ movl %eax, %edi
+
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator_backward_src)
+ .long 0
+ movl %eax, %esi
+
+ /* mov imm32, %ecx */
+ .byte 0xb9
+VARIABLE(grub_relocator_backward_chunk_size)
+ .long 0
+
+ add %ecx, %esi
+ add %ecx, %edi
+
+
+ /* Backward movsb is implicitly off-by-one. compensate that. */
+ sub $1, %esi
+ sub $1, %edi
+
+ /* Backward copy. */
+ std
+
+ rep
+ movsb
+VARIABLE(grub_relocator_backward_end)
+
+
+VARIABLE(grub_relocator_forward_start)
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator_forward_dest)
+ .long 0
+ movl %eax, %edi
+
+ /* mov imm32, %rax */
+ .byte 0xb8
+VARIABLE(grub_relocator_forward_src)
+ .long 0
+ movl %eax, %esi
+
+ /* mov imm32, %ecx */
+ .byte 0xb9
+VARIABLE(grub_relocator_forward_chunk_size)
+ .long 0
+
+ /* Forward copy. */
+ cld
+ rep
+ movsb
+VARIABLE(grub_relocator_forward_end)
diff --git a/grub-core/lib/i386/relocator_common.S b/grub-core/lib/i386/relocator_common.S
new file mode 100644
index 0000000..1b5210d
--- /dev/null
+++ b/grub-core/lib/i386/relocator_common.S
@@ -0,0 +1,111 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <grub/symbol.h>
+#include <grub/i386/memory.h>
+
+#ifdef __x86_64__
+#define RAX %rax
+#define RSI %rsi
+#else
+#define RAX %eax
+#define RSI %esi
+#endif
+
+ .macro DISABLE_PAGING
+
+ movl %cr0, %eax
+ andl $(~GRUB_MEMORY_CPU_CR0_PAGING_ON), %eax
+ movl %eax, %cr0
+ .endm
+
+ .macro PREAMBLE
+LOCAL(base):
+ /* %rax contains now our new 'base'. */
+ mov RAX, RSI
+
+#if defined (__APPLE__) && defined (__x86_64__)
+ leaq LOCAL(cont0) (%rip), RAX
+#elif defined (__APPLE__)
+ LOCAL(cont0_offset) = LOCAL(cont0) - LOCAL(base)
+ add $LOCAL(cont0_offset), RAX
+#else
+ add $(LOCAL(cont0) - LOCAL(base)), RAX
+#endif
+ jmp *RAX
+LOCAL(cont0):
+ .endm
+
+ .macro RELOAD_GDT
+#ifdef __APPLE__
+ LOCAL(cont1_offset) = LOCAL(cont1) - LOCAL(base)
+ LOCAL(jump_vector_offset) = LOCAL(jump_vector) - LOCAL(base)
+ LOCAL(gdt_offset) = LOCAL(gdt) - LOCAL(base)
+ LOCAL(gdt_addr_offset) = LOCAL(gdt_addr) - LOCAL(base)
+ LOCAL(gdtdesc_offset) = LOCAL(gdtdesc) - LOCAL(base)
+
+ lea LOCAL(cont1_offset) (RSI, 1), RAX
+ movl %eax, LOCAL(jump_vector_offset) (RSI, 1)
+
+ lea LOCAL(gdt_offset) (RSI, 1), RAX
+ mov RAX, (LOCAL(gdt_addr_offset)) (RSI, 1)
+
+ /* Switch to compatibility mode. */
+ lgdt (LOCAL(gdtdesc_offset)) (RSI, 1)
+
+ /* Update %cs. */
+ ljmp *(LOCAL(jump_vector_offset)) (RSI, 1)
+ .p2align 4
+LOCAL(gdtdesc):
+ LOCAL(gdtsize) = LOCAL(gdt_end) - LOCAL(gdt)
+ .word LOCAL(gdtsize)
+#else
+ lea (LOCAL(cont1) - LOCAL(base)) (RSI, 1), RAX
+ movl %eax, (LOCAL(jump_vector) - LOCAL(base)) (RSI, 1)
+
+ lea (LOCAL(gdt) - LOCAL(base)) (RSI, 1), RAX
+ mov RAX, (LOCAL(gdt_addr) - LOCAL(base)) (RSI, 1)
+
+ /* Switch to compatibility mode. */
+ lgdt (LOCAL(gdtdesc) - LOCAL(base)) (RSI, 1)
+
+ /* Update %cs. */
+ ljmp *(LOCAL(jump_vector) - LOCAL(base)) (RSI, 1)
+
+ .p2align 4
+LOCAL(gdtdesc):
+ .word LOCAL(gdt_end) - LOCAL(gdt)
+#endif
+LOCAL(gdt_addr):
+#ifdef __x86_64__
+ /* Filled by the code. */
+ .quad 0
+#else
+ /* Filled by the code. */
+ .long 0
+#endif
+
+ .p2align 4
+LOCAL(jump_vector):
+ /* Jump location. Is filled by the code */
+ .long 0
+ .long CODE_SEGMENT
+
+LOCAL(cont1):
+ .endm
diff --git a/grub-core/lib/i386/relocator_common_c.c b/grub-core/lib/i386/relocator_common_c.c
new file mode 100644
index 0000000..7be609b
--- /dev/null
+++ b/grub-core/lib/i386/relocator_common_c.c
@@ -0,0 +1,109 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009-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/mm.h>
+#include <grub/misc.h>
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/term.h>
+
+#include <grub/relocator.h>
+#include <grub/relocator_private.h>
+
+extern grub_uint8_t grub_relocator_forward_start;
+extern grub_uint8_t grub_relocator_forward_end;
+extern grub_uint8_t grub_relocator_backward_start;
+extern grub_uint8_t grub_relocator_backward_end;
+
+extern void *grub_relocator_backward_dest;
+extern void *grub_relocator_backward_src;
+extern grub_size_t grub_relocator_backward_chunk_size;
+
+extern void *grub_relocator_forward_dest;
+extern void *grub_relocator_forward_src;
+extern grub_size_t grub_relocator_forward_chunk_size;
+
+#define RELOCATOR_SIZEOF(x) (&grub_relocator##x##_end - &grub_relocator##x##_start)
+
+grub_size_t grub_relocator_align = 1;
+grub_size_t grub_relocator_forward_size;
+grub_size_t grub_relocator_backward_size;
+#ifdef __x86_64__
+grub_size_t grub_relocator_jumper_size = 12;
+#else
+grub_size_t grub_relocator_jumper_size = 7;
+#endif
+
+void
+grub_cpu_relocator_init (void)
+{
+ grub_relocator_forward_size = RELOCATOR_SIZEOF (_forward);
+ grub_relocator_backward_size = RELOCATOR_SIZEOF (_backward);
+}
+
+void
+grub_cpu_relocator_jumper (void *rels, grub_addr_t addr)
+{
+ grub_uint8_t *ptr;
+ ptr = rels;
+#ifdef __x86_64__
+ /* movq imm64, %rax (for relocator) */
+ *(grub_uint8_t *) ptr = 0x48;
+ ptr++;
+ *(grub_uint8_t *) ptr = 0xb8;
+ ptr++;
+ *(grub_uint64_t *) ptr = addr;
+ ptr += sizeof (grub_uint64_t);
+#else
+ /* movl imm32, %eax (for relocator) */
+ *(grub_uint8_t *) ptr = 0xb8;
+ ptr++;
+ *(grub_uint32_t *) ptr = addr;
+ ptr += sizeof (grub_uint32_t);
+#endif
+ /* jmp $eax/$rax */
+ *(grub_uint8_t *) ptr = 0xff;
+ ptr++;
+ *(grub_uint8_t *) ptr = 0xe0;
+ ptr++;
+}
+
+void
+grub_cpu_relocator_backward (void *ptr, void *src, void *dest,
+ grub_size_t size)
+{
+ grub_relocator_backward_dest = dest;
+ grub_relocator_backward_src = src;
+ grub_relocator_backward_chunk_size = size;
+
+ grub_memmove (ptr,
+ &grub_relocator_backward_start, RELOCATOR_SIZEOF (_backward));
+}
+
+void
+grub_cpu_relocator_forward (void *ptr, void *src, void *dest,
+ grub_size_t size)
+{
+ grub_relocator_forward_dest = dest;
+ grub_relocator_forward_src = src;
+ grub_relocator_forward_chunk_size = size;
+
+ grub_memmove (ptr,
+ &grub_relocator_forward_start, RELOCATOR_SIZEOF (_forward));
+}
diff --git a/grub-core/lib/i386/setjmp.S b/grub-core/lib/i386/setjmp.S
new file mode 100644
index 0000000..0b0740f
--- /dev/null
+++ b/grub-core/lib/i386/setjmp.S
@@ -0,0 +1,59 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/dl.h>
+
+ .file "setjmp.S"
+
+GRUB_MOD_LICENSE "GPLv3+"
+
+ .text
+
+/*
+ * int grub_setjmp (grub_jmp_buf env)
+ */
+FUNCTION(grub_setjmp)
+ movl %ebx, 0(%eax) /* EBX */
+ movl %esi, 4(%eax) /* ESI */
+ movl %edi, 8(%eax) /* EDI */
+ movl %ebp, 12(%eax) /* EBP */
+ popl %ecx
+ movl %esp, 16(%eax) /* ESP */
+ movl %ecx, 20(%eax) /* EIP */
+ xorl %eax, %eax
+ jmp *%ecx
+
+
+/*
+ * int grub_longjmp (grub_jmp_buf env, int val)
+ */
+FUNCTION(grub_longjmp)
+ movl 0(%eax), %ebx
+ movl 4(%eax), %esi
+ movl 8(%eax), %edi
+ movl 12(%eax), %ebp
+ movl 16(%eax), %esp
+ movl 20(%eax), %ecx
+
+ movl %edx, %eax
+ testl %eax, %eax
+ jnz 1f
+ incl %eax
+1: jmp *%ecx
+
diff --git a/grub-core/lib/i386/xen/relocator.S b/grub-core/lib/i386/xen/relocator.S
new file mode 100644
index 0000000..96e51b5
--- /dev/null
+++ b/grub-core/lib/i386/xen/relocator.S
@@ -0,0 +1,165 @@
+/*
+ * 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/i386/memory.h>
+#include <grub/i386/types.h>
+#include <grub/symbol.h>
+#include <grub/xen.h>
+
+ .p2align 4 /* force 16-byte alignment */
+
+VARIABLE(grub_relocator_xen_remap_start)
+LOCAL(base):
+ /* Remap the remapper to it's new address. */
+ /* mov imm32, %ebx - %ebx: new virtual address of remapper */
+ .byte 0xbb
+VARIABLE(grub_relocator_xen_remapper_virt)
+ .long 0
+
+ /* mov imm32, %ecx - %ecx: low part of page table entry */
+ .byte 0xb9
+VARIABLE(grub_relocator_xen_remapper_map)
+ .long 0
+
+ /* mov imm32, %edx - %edx: high part of page table entry */
+ .byte 0xba
+VARIABLE(grub_relocator_xen_remapper_map_high)
+ .long 0
+
+ movl %ebx, %ebp /* %ebx is clobbered by hypercall */
+
+ movl $UVMF_INVLPG, %esi /* esi: flags (inv. single entry) */
+ movl $__HYPERVISOR_update_va_mapping, %eax
+ int $0x82
+
+ movl %ebp, %ebx
+ addl $(LOCAL(cont) - LOCAL(base)), %ebx
+
+ jmp *%ebx /* Continue with new virtual address */
+
+LOCAL(cont):
+ /* Modify mappings of new page tables to be read-only. */
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator_xen_paging_areas_addr)
+ .long 0
+ movl %eax, %ebx
+1:
+ movl 0(%ebx), %ebp /* Get start pfn of the current area */
+ movl GRUB_TARGET_SIZEOF_LONG(%ebx), %ecx /* Get # of pg tables */
+ testl %ecx, %ecx /* 0 -> last area reached */
+ jz 3f
+ addl $(2 * GRUB_TARGET_SIZEOF_LONG), %ebx
+ movl %ebx, %esp /* Save current area pointer */
+
+2:
+ movl %ecx, %edi
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator_xen_mfn_list)
+ .long 0
+ movl 0(%eax, %ebp, 4), %ecx /* mfn */
+ movl %ebp, %ebx
+ shll $PAGE_SHIFT, %ebx /* virtual address (1:1 mapping) */
+ movl %ecx, %edx
+ shll $PAGE_SHIFT, %ecx /* prepare pte low part */
+ shrl $(32 - PAGE_SHIFT), %edx /* pte high part */
+ orl $(GRUB_PAGE_PRESENT | GRUB_PAGE_USER), %ecx /* pte low */
+ movl $UVMF_INVLPG, %esi
+ movl $__HYPERVISOR_update_va_mapping, %eax
+ int $0x82 /* parameters: eax, ebx, ecx, edx, esi */
+
+ incl %ebp /* next pfn */
+ movl %edi, %ecx
+
+ loop 2b
+
+ mov %esp, %ebx /* restore area poniter */
+ jmp 1b
+
+3:
+ /* Switch page tables: pin new L3 pt, load cr3, unpin old L3. */
+ /* mov imm32, %ebx */
+ .byte 0xbb
+VARIABLE(grub_relocator_xen_mmu_op_addr)
+ .long 0
+ movl $3, %ecx /* 3 mmu ops */
+ movl $0, %edx /* pdone (not used) */
+ movl $DOMID_SELF, %esi
+ movl $__HYPERVISOR_mmuext_op, %eax
+ int $0x82
+
+ /* Continue in virtual kernel mapping. */
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator_xen_remap_continue)
+ .long 0
+
+ jmp *%eax
+
+VARIABLE(grub_relocator_xen_paging_areas)
+ .long 0, 0, 0, 0, 0, 0, 0, 0
+
+VARIABLE(grub_relocator_xen_mmu_op)
+ .space 256
+
+VARIABLE(grub_relocator_xen_remap_end)
+
+
+VARIABLE(grub_relocator_xen_start)
+ /* Unmap old remapper area. */
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator_xen_remapper_virt2)
+ .long 0
+
+ movl %eax, %ebx
+
+ xorl %ecx, %ecx /* Invalid pte */
+ xorl %edx, %edx
+
+ movl $UVMF_INVLPG, %esi
+ movl $__HYPERVISOR_update_va_mapping, %eax
+ int $0x82
+
+ /* Prepare registers for starting kernel. */
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator_xen_stack)
+ .long 0
+
+ movl %eax, %esp
+
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator_xen_start_info)
+ .long 0
+
+ movl %eax, %esi
+
+ cld
+
+ /* mov imm32, %eax */
+ .byte 0xb8
+VARIABLE(grub_relocator_xen_entry_point)
+ .long 0
+
+ /* Now start the new kernel. */
+ jmp *%eax
+
+VARIABLE(grub_relocator_xen_end)
diff --git a/grub-core/lib/ia64/longjmp.S b/grub-core/lib/ia64/longjmp.S
new file mode 100644
index 0000000..38afb22
--- /dev/null
+++ b/grub-core/lib/ia64/longjmp.S
@@ -0,0 +1,162 @@
+/* Copyright (C) 1999, 2000, 2001, 2002, 2008 Free Software Foundation, Inc.
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+ Note that __sigsetjmp() did NOT flush the register stack. Instead,
+ we do it here since __longjmp() is usually much less frequently
+ invoked than __sigsetjmp(). The only difficulty is that __sigsetjmp()
+ didn't (and wouldn't be able to) save ar.rnat either. This is a problem
+ because if we're not careful, we could end up loading random NaT bits.
+ There are two cases:
+
+ (i) ar.bsp < ia64_rse_rnat_addr(jmpbuf.ar_bsp)
+ ar.rnat contains the desired bits---preserve ar.rnat
+ across loadrs and write to ar.bspstore
+
+ (ii) ar.bsp >= ia64_rse_rnat_addr(jmpbuf.ar_bsp)
+ The desired ar.rnat is stored in
+ ia64_rse_rnat_addr(jmpbuf.ar_bsp). Load those
+ bits into ar.rnat after setting ar.bspstore. */
+
+
+
+# define pPos p6 /* is rotate count positive? */
+# define pNeg p7 /* is rotate count negative? */
+
+
+ /* __longjmp(__jmp_buf buf, int val) */
+
+ .text
+
+ .proc EXT_C(grub_longjmp)
+FUNCTION(grub_longjmp)
+ alloc r8=ar.pfs,2,1,0,0
+ mov r27=ar.rsc
+ add r2=0x98,in0 // r2 <- &jmpbuf.orig_jmp_buf_addr
+ ;;
+ ld8 r8=[r2],-16 // r8 <- orig_jmp_buf_addr
+ mov r10=ar.bsp
+ and r11=~0x3,r27 // clear ar.rsc.mode
+ ;;
+ flushrs // flush dirty regs to backing store (must be first in insn grp)
+ ld8 r23=[r2],8 // r23 <- jmpbuf.ar_bsp
+ sub r8=r8,in0 // r8 <- &orig_jmpbuf - &jmpbuf
+ ;;
+ ld8 r25=[r2] // r25 <- jmpbuf.ar_unat
+ extr.u r8=r8,3,6 // r8 <- (&orig_jmpbuf - &jmpbuf)/8 & 0x3f
+ ;;
+ cmp.lt pNeg,pPos=r8,r0
+ mov r2=in0
+ ;;
+(pPos) mov r16=r8
+(pNeg) add r16=64,r8
+(pPos) sub r17=64,r8
+(pNeg) sub r17=r0,r8
+ ;;
+ mov ar.rsc=r11 // put RSE in enforced lazy mode
+ shr.u r8=r25,r16
+ add r3=8,in0 // r3 <- &jmpbuf.r1
+ shl r9=r25,r17
+ ;;
+ or r25=r8,r9
+ ;;
+ mov r26=ar.rnat
+ mov ar.unat=r25 // setup ar.unat (NaT bits for r1, r4-r7, and r12)
+ ;;
+ ld8.fill.nta sp=[r2],16 // r12 (sp)
+ ld8.fill.nta gp=[r3],16 // r1 (gp)
+ dep r11=-1,r23,3,6 // r11 <- ia64_rse_rnat_addr(jmpbuf.ar_bsp)
+ ;;
+ ld8.nta r16=[r2],16 // caller's unat
+ ld8.nta r17=[r3],16 // fpsr
+ ;;
+ ld8.fill.nta r4=[r2],16 // r4
+ ld8.fill.nta r5=[r3],16 // r5 (gp)
+ cmp.geu p8,p0=r10,r11 // p8 <- (ar.bsp >= jmpbuf.ar_bsp)
+ ;;
+ ld8.fill.nta r6=[r2],16 // r6
+ ld8.fill.nta r7=[r3],16 // r7
+ ;;
+ mov ar.unat=r16 // restore caller's unat
+ mov ar.fpsr=r17 // restore fpsr
+ ;;
+ ld8.nta r16=[r2],16 // b0
+ ld8.nta r17=[r3],16 // b1
+ ;;
+(p8) ld8 r26=[r11] // r26 <- *ia64_rse_rnat_addr(jmpbuf.ar_bsp)
+ mov ar.bspstore=r23 // restore ar.bspstore
+ ;;
+ ld8.nta r18=[r2],16 // b2
+ ld8.nta r19=[r3],16 // b3
+ ;;
+ ld8.nta r20=[r2],16 // b4
+ ld8.nta r21=[r3],16 // b5
+ ;;
+ ld8.nta r11=[r2],16 // ar.pfs
+ ld8.nta r22=[r3],56 // ar.lc
+ ;;
+ ld8.nta r24=[r2],32 // pr
+ mov b0=r16
+ ;;
+ ldf.fill.nta f2=[r2],32
+ ldf.fill.nta f3=[r3],32
+ mov b1=r17
+ ;;
+ ldf.fill.nta f4=[r2],32
+ ldf.fill.nta f5=[r3],32
+ mov b2=r18
+ ;;
+ ldf.fill.nta f16=[r2],32
+ ldf.fill.nta f17=[r3],32
+ mov b3=r19
+ ;;
+ ldf.fill.nta f18=[r2],32
+ ldf.fill.nta f19=[r3],32
+ mov b4=r20
+ ;;
+ ldf.fill.nta f20=[r2],32
+ ldf.fill.nta f21=[r3],32
+ mov b5=r21
+ ;;
+ ldf.fill.nta f22=[r2],32
+ ldf.fill.nta f23=[r3],32
+ mov ar.lc=r22
+ ;;
+ ldf.fill.nta f24=[r2],32
+ ldf.fill.nta f25=[r3],32
+ cmp.eq p8,p9=0,in1
+ ;;
+ ldf.fill.nta f26=[r2],32
+ ldf.fill.nta f27=[r3],32
+ mov ar.pfs=r11
+ ;;
+ ldf.fill.nta f28=[r2],32
+ ldf.fill.nta f29=[r3],32
+ ;;
+ ldf.fill.nta f30=[r2]
+ ldf.fill.nta f31=[r3]
+(p8) mov r8=1
+
+ mov ar.rnat=r26 // restore ar.rnat
+ ;;
+ mov ar.rsc=r27 // restore ar.rsc
+(p9) mov r8=in1
+
+ invala // virt. -> phys. regnum mapping may change
+ mov pr=r24,-1
+ br.ret.dptk.few rp
+ .endp EXT_C(grub_longjmp)
diff --git a/grub-core/lib/ia64/setjmp.S b/grub-core/lib/ia64/setjmp.S
new file mode 100644
index 0000000..a0382d8
--- /dev/null
+++ b/grub-core/lib/ia64/setjmp.S
@@ -0,0 +1,177 @@
+/* Copyright (C) 1999, 2000, 2001, 2002, 2008 Free Software Foundation, Inc.
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+ The layout of the jmp_buf is as follows. This is subject to change
+ and user-code should never depend on the particular layout of
+ jmp_buf!
+
+
+ offset: description:
+ ------- ------------
+ 0x000 stack pointer (r12) ; unchangeable (see _JMPBUF_UNWINDS)
+ 0x008 r1 (gp)
+ 0x010 caller's unat
+ 0x018 fpsr
+ 0x020 r4
+ 0x028 r5
+ 0x030 r6
+ 0x038 r7
+ 0x040 rp (b0)
+ 0x048 b1
+ 0x050 b2
+ 0x058 b3
+ 0x060 b4
+ 0x068 b5
+ 0x070 ar.pfs
+ 0x078 ar.lc
+ 0x080 pr
+ 0x088 ar.bsp ; unchangeable (see __longjmp.S)
+ 0x090 ar.unat
+ 0x098 &__jmp_buf ; address of the jmpbuf (needed to locate NaT bits in unat)
+ 0x0a0 f2
+ 0x0b0 f3
+ 0x0c0 f4
+ 0x0d0 f5
+ 0x0e0 f16
+ 0x0f0 f17
+ 0x100 f18
+ 0x110 f19
+ 0x120 f20
+ 0x130 f21
+ 0x130 f22
+ 0x140 f23
+ 0x150 f24
+ 0x160 f25
+ 0x170 f26
+ 0x180 f27
+ 0x190 f28
+ 0x1a0 f29
+ 0x1b0 f30
+ 0x1c0 f31 */
+
+#include <grub/symbol.h>
+#include <grub/dl.h>
+
+ .file "setjmp.S"
+
+GRUB_MOD_LICENSE "GPLv2+"
+
+ /* The following two entry points are the traditional entry points: */
+
+ .text
+
+ .proc EXT_C(grub_setjmp)
+FUNCTION(grub_setjmp)
+ alloc r8=ar.pfs,2,0,0,0
+ mov in1=1
+ br.cond.sptk.many __sigsetjmp
+ .endp EXT_C(grub_setjmp)
+
+ /* __sigsetjmp(__jmp_buf buf, int savemask) */
+
+ .proc __sigsetjmp
+__sigsetjmp:
+ //.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
+ alloc loc1=ar.pfs,2,2,2,0
+ mov r16=ar.unat
+ ;;
+ mov r17=ar.fpsr
+ mov r2=in0
+ add r3=8,in0
+ ;;
+ st8.spill.nta [r2]=sp,16 // r12 (sp)
+ st8.spill.nta [r3]=gp,16 // r1 (gp)
+ ;;
+ st8.nta [r2]=r16,16 // save caller's unat
+ st8.nta [r3]=r17,16 // save fpsr
+ add r8=0xa0,in0
+ ;;
+ st8.spill.nta [r2]=r4,16 // r4
+ st8.spill.nta [r3]=r5,16 // r5
+ add r9=0xb0,in0
+ ;;
+ stf.spill.nta [r8]=f2,32
+ stf.spill.nta [r9]=f3,32
+ mov loc0=rp
+ .body
+ ;;
+ stf.spill.nta [r8]=f4,32
+ stf.spill.nta [r9]=f5,32
+ mov r17=b1
+ ;;
+ stf.spill.nta [r8]=f16,32
+ stf.spill.nta [r9]=f17,32
+ mov r18=b2
+ ;;
+ stf.spill.nta [r8]=f18,32
+ stf.spill.nta [r9]=f19,32
+ mov r19=b3
+ ;;
+ stf.spill.nta [r8]=f20,32
+ stf.spill.nta [r9]=f21,32
+ mov r20=b4
+ ;;
+ stf.spill.nta [r8]=f22,32
+ stf.spill.nta [r9]=f23,32
+ mov r21=b5
+ ;;
+ stf.spill.nta [r8]=f24,32
+ stf.spill.nta [r9]=f25,32
+ mov r22=ar.lc
+ ;;
+ stf.spill.nta [r8]=f26,32
+ stf.spill.nta [r9]=f27,32
+ mov r24=pr
+ ;;
+ stf.spill.nta [r8]=f28,32
+ stf.spill.nta [r9]=f29,32
+ ;;
+ stf.spill.nta [r8]=f30
+ stf.spill.nta [r9]=f31
+
+ st8.spill.nta [r2]=r6,16 // r6
+ st8.spill.nta [r3]=r7,16 // r7
+ ;;
+ mov r23=ar.bsp
+ mov r25=ar.unat
+ mov out0=in0
+
+ st8.nta [r2]=loc0,16 // b0
+ st8.nta [r3]=r17,16 // b1
+ mov out1=in1
+ ;;
+ st8.nta [r2]=r18,16 // b2
+ st8.nta [r3]=r19,16 // b3
+ ;;
+ st8.nta [r2]=r20,16 // b4
+ st8.nta [r3]=r21,16 // b5
+ ;;
+ st8.nta [r2]=loc1,16 // ar.pfs
+ st8.nta [r3]=r22,16 // ar.lc
+ ;;
+ st8.nta [r2]=r24,16 // pr
+ st8.nta [r3]=r23,16 // ar.bsp
+ ;;
+ st8.nta [r2]=r25 // ar.unat
+ st8.nta [r3]=in0 // &__jmp_buf
+ mov r8=0
+ mov rp=loc0
+ mov ar.pfs=loc1
+ br.ret.sptk.many rp
+
+ .endp __sigsetjmp
diff --git a/grub-core/lib/ieee1275/cmos.c b/grub-core/lib/ieee1275/cmos.c
new file mode 100644
index 0000000..328d70a
--- /dev/null
+++ b/grub-core/lib/ieee1275/cmos.c
@@ -0,0 +1,77 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/datetime.h>
+#include <grub/cmos.h>
+#include <grub/dl.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/misc.h>
+
+volatile grub_uint8_t *grub_cmos_port = 0;
+
+/* Helper for grub_cmos_find_port. */
+static int
+grub_cmos_find_port_iter (struct grub_ieee1275_devalias *alias)
+{
+ grub_ieee1275_phandle_t dev;
+ grub_uint32_t addr[2];
+ grub_ssize_t actual;
+ /* Enough to check if it's "m5819" */
+ char compat[100];
+ if (grub_ieee1275_finddevice (alias->path, &dev))
+ return 0;
+ if (grub_ieee1275_get_property (dev, "compatible", compat, sizeof (compat),
+ 0))
+ return 0;
+ if (grub_strcmp (compat, "m5819") != 0)
+ return 0;
+ if (grub_ieee1275_get_integer_property (dev, "address",
+ addr, sizeof (addr), &actual))
+ return 0;
+ if (actual == 4)
+ {
+ grub_cmos_port = (volatile grub_uint8_t *) (grub_addr_t) addr[0];
+ return 1;
+ }
+
+#if GRUB_CPU_SIZEOF_VOID_P == 8
+ if (actual == 8)
+ {
+ grub_cmos_port = (volatile grub_uint8_t *)
+ ((((grub_addr_t) addr[0]) << 32) | addr[1]);
+ return 1;
+ }
+#else
+ if (actual == 8 && addr[0] == 0)
+ {
+ grub_cmos_port = (volatile grub_uint8_t *) addr[1];
+ return 1;
+ }
+#endif
+ return 0;
+}
+
+grub_err_t
+grub_cmos_find_port (void)
+{
+ grub_ieee1275_devices_iterate (grub_cmos_find_port_iter);
+ if (!grub_cmos_port)
+ return grub_error (GRUB_ERR_IO, "no cmos found");
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c
new file mode 100644
index 0000000..b81fba2
--- /dev/null
+++ b/grub-core/lib/ieee1275/datetime.c
@@ -0,0 +1,156 @@
+/* kern/cmos_datetime.c - CMOS datetime function.
+ *
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/datetime.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#if defined (__powerpc__) || defined (__sparc__)
+#include <grub/cmos.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static char *rtc = 0;
+static int no_ieee1275_rtc = 0;
+
+/* Helper for find_rtc. */
+static int
+find_rtc_iter (struct grub_ieee1275_devalias *alias)
+{
+ if (grub_strcmp (alias->type, "rtc") == 0)
+ {
+ grub_dprintf ("datetime", "Found RTC %s\n", alias->path);
+ rtc = grub_strdup (alias->path);
+ return 1;
+ }
+ return 0;
+}
+
+static void
+find_rtc (void)
+{
+ grub_ieee1275_devices_iterate (find_rtc_iter);
+ if (!rtc)
+ no_ieee1275_rtc = 1;
+}
+
+grub_err_t
+grub_get_datetime (struct grub_datetime *datetime)
+{
+ struct get_time_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t device;
+ grub_ieee1275_cell_t catch_result;
+ grub_ieee1275_cell_t year;
+ grub_ieee1275_cell_t month;
+ grub_ieee1275_cell_t day;
+ grub_ieee1275_cell_t hour;
+ grub_ieee1275_cell_t minute;
+ grub_ieee1275_cell_t second;
+ }
+ args;
+ int status;
+ grub_ieee1275_ihandle_t ihandle;
+
+ if (no_ieee1275_rtc)
+ return grub_get_datetime_cmos (datetime);
+ if (!rtc)
+ find_rtc ();
+ if (!rtc)
+ return grub_get_datetime_cmos (datetime);
+
+ status = grub_ieee1275_open (rtc, &ihandle);
+ if (status == -1)
+ return grub_error (GRUB_ERR_IO, "couldn't open RTC");
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 7);
+ args.device = (grub_ieee1275_cell_t) ihandle;
+ args.method = (grub_ieee1275_cell_t) "get-time";
+
+ status = IEEE1275_CALL_ENTRY_FN (&args);
+
+ grub_ieee1275_close (ihandle);
+
+ if (status == -1 || args.catch_result)
+ return grub_error (GRUB_ERR_IO, "get-time failed");
+
+ datetime->year = args.year;
+ datetime->month = args.month;
+ datetime->day = args.day + 1;
+ datetime->hour = args.hour;
+ datetime->minute = args.minute;
+ datetime->second = args.second;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_set_datetime (struct grub_datetime *datetime)
+{
+ struct set_time_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t device;
+ grub_ieee1275_cell_t year;
+ grub_ieee1275_cell_t month;
+ grub_ieee1275_cell_t day;
+ grub_ieee1275_cell_t hour;
+ grub_ieee1275_cell_t minute;
+ grub_ieee1275_cell_t second;
+ grub_ieee1275_cell_t catch_result;
+ }
+ args;
+ int status;
+ grub_ieee1275_ihandle_t ihandle;
+
+ if (no_ieee1275_rtc)
+ return grub_set_datetime_cmos (datetime);
+ if (!rtc)
+ find_rtc ();
+ if (!rtc)
+ return grub_set_datetime_cmos (datetime);
+
+ status = grub_ieee1275_open (rtc, &ihandle);
+ if (status == -1)
+ return grub_error (GRUB_ERR_IO, "couldn't open RTC");
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 8, 1);
+ args.device = (grub_ieee1275_cell_t) ihandle;
+ args.method = (grub_ieee1275_cell_t) "set-time";
+
+ args.year = datetime->year;
+ args.month = datetime->month;
+ args.day = datetime->day - 1;
+ args.hour = datetime->hour;
+ args.minute = datetime->minute;
+ args.second = datetime->second;
+
+ status = IEEE1275_CALL_ENTRY_FN (&args);
+
+ grub_ieee1275_close (ihandle);
+
+ if (status == -1 || args.catch_result)
+ return grub_error (GRUB_ERR_IO, "set-time failed");
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/lib/ieee1275/halt.c b/grub-core/lib/ieee1275/halt.c
new file mode 100644
index 0000000..8fc16d2
--- /dev/null
+++ b/grub-core/lib/ieee1275/halt.c
@@ -0,0 +1,33 @@
+/* openfw.c -- Open firmware support functions. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/misc.h>
+
+void
+grub_halt (void)
+{
+ /* Not standardized. We try three known commands. */
+
+ grub_ieee1275_interpret ("power-off", 0);
+ grub_ieee1275_interpret ("shut-down", 0);
+ grub_ieee1275_interpret ("poweroff", 0);
+
+ while (1);
+}
diff --git a/grub-core/lib/ieee1275/reboot.c b/grub-core/lib/ieee1275/reboot.c
new file mode 100644
index 0000000..91c8779
--- /dev/null
+++ b/grub-core/lib/ieee1275/reboot.c
@@ -0,0 +1,27 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/ieee1275/ieee1275.h>
+#include <grub/misc.h>
+
+void
+grub_reboot (void)
+{
+ grub_ieee1275_interpret ("reset-all", 0);
+ for (;;) ;
+}
diff --git a/grub-core/lib/ieee1275/relocator.c b/grub-core/lib/ieee1275/relocator.c
new file mode 100644
index 0000000..c6dd8fa
--- /dev/null
+++ b/grub-core/lib/ieee1275/relocator.c
@@ -0,0 +1,114 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/relocator.h>
+#include <grub/relocator_private.h>
+#include <grub/memory.h>
+#include <grub/ieee1275/ieee1275.h>
+
+/* Helper for grub_relocator_firmware_get_max_events. */
+static int
+count (grub_uint64_t addr __attribute__ ((unused)),
+ grub_uint64_t len __attribute__ ((unused)),
+ grub_memory_type_t type __attribute__ ((unused)), void *data)
+{
+ int *counter = data;
+
+ (*counter)++;
+ return 0;
+}
+
+unsigned
+grub_relocator_firmware_get_max_events (void)
+{
+ int counter = 0;
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM))
+ return 0;
+ grub_machine_mmap_iterate (count, &counter);
+ return 2 * counter;
+}
+
+/* Context for grub_relocator_firmware_fill_events. */
+struct grub_relocator_firmware_fill_events_ctx
+{
+ struct grub_relocator_mmap_event *events;
+ int counter;
+};
+
+/* Helper for grub_relocator_firmware_fill_events. */
+static int
+grub_relocator_firmware_fill_events_iter (grub_uint64_t addr,
+ grub_uint64_t len,
+ grub_memory_type_t type, void *data)
+{
+ struct grub_relocator_firmware_fill_events_ctx *ctx = data;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM))
+ {
+ if (addr + len <= 0x180000)
+ return 0;
+
+ if (addr < 0x180000)
+ {
+ len = addr + len - 0x180000;
+ addr = 0x180000;
+ }
+ }
+
+ ctx->events[ctx->counter].type = REG_FIRMWARE_START;
+ ctx->events[ctx->counter].pos = addr;
+ ctx->counter++;
+ ctx->events[ctx->counter].type = REG_FIRMWARE_END;
+ ctx->events[ctx->counter].pos = addr + len;
+ ctx->counter++;
+
+ return 0;
+}
+
+unsigned
+grub_relocator_firmware_fill_events (struct grub_relocator_mmap_event *events)
+{
+ struct grub_relocator_firmware_fill_events_ctx ctx = {
+ .events = events,
+ .counter = 0
+ };
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM))
+ return 0;
+ grub_machine_mmap_iterate (grub_relocator_firmware_fill_events_iter, &ctx);
+ return ctx.counter;
+}
+
+int
+grub_relocator_firmware_alloc_region (grub_addr_t start, grub_size_t size)
+{
+ grub_err_t err;
+ err = grub_claimmap (start, size);
+ grub_errno = 0;
+ return (err == 0);
+}
+
+void
+grub_relocator_firmware_free_region (grub_addr_t start, grub_size_t size)
+{
+ grub_ieee1275_release (start, size);
+}
diff --git a/grub-core/lib/json/jsmn.h b/grub-core/lib/json/jsmn.h
new file mode 100644
index 0000000..3178dcc
--- /dev/null
+++ b/grub-core/lib/json/jsmn.h
@@ -0,0 +1,471 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2010 Serge Zaitsev
+ *
+ * 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 JSMN_H
+#define JSMN_H
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef JSMN_STATIC
+#define JSMN_API static
+#else
+#define JSMN_API extern
+#endif
+
+/**
+ * JSON type identifier. Basic types are:
+ * o Object
+ * o Array
+ * o String
+ * o Other primitive: number, boolean (true/false) or null
+ */
+typedef enum {
+ JSMN_UNDEFINED = 0,
+ JSMN_OBJECT = 1,
+ JSMN_ARRAY = 2,
+ JSMN_STRING = 3,
+ JSMN_PRIMITIVE = 4
+} jsmntype_t;
+
+enum jsmnerr {
+ /* Not enough tokens were provided */
+ JSMN_ERROR_NOMEM = -1,
+ /* Invalid character inside JSON string */
+ JSMN_ERROR_INVAL = -2,
+ /* The string is not a full JSON packet, more bytes expected */
+ JSMN_ERROR_PART = -3
+};
+
+/**
+ * JSON token description.
+ * type type (object, array, string etc.)
+ * start start position in JSON data string
+ * end end position in JSON data string
+ */
+typedef struct jsmntok {
+ jsmntype_t type;
+ int start;
+ int end;
+ int size;
+#ifdef JSMN_PARENT_LINKS
+ int parent;
+#endif
+} jsmntok_t;
+
+/**
+ * JSON parser. Contains an array of token blocks available. Also stores
+ * the string being parsed now and current position in that string.
+ */
+typedef struct jsmn_parser {
+ unsigned int pos; /* offset in the JSON string */
+ unsigned int toknext; /* next token to allocate */
+ int toksuper; /* superior token node, e.g. parent object or array */
+} jsmn_parser;
+
+/**
+ * Create JSON parser over an array of tokens
+ */
+JSMN_API void jsmn_init(jsmn_parser *parser);
+
+/**
+ * Run JSON parser. It parses a JSON data string into and array of tokens, each
+ * describing
+ * a single JSON object.
+ */
+JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+ jsmntok_t *tokens, const unsigned int num_tokens);
+
+#ifndef JSMN_HEADER
+/**
+ * Allocates a fresh unused token from the token pool.
+ */
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens,
+ const size_t num_tokens) {
+ jsmntok_t *tok;
+ if (parser->toknext >= num_tokens) {
+ return NULL;
+ }
+ tok = &tokens[parser->toknext++];
+ tok->start = tok->end = -1;
+ tok->size = 0;
+#ifdef JSMN_PARENT_LINKS
+ tok->parent = -1;
+#endif
+ return tok;
+}
+
+/**
+ * Fills token type and boundaries.
+ */
+static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type,
+ const int start, const int end) {
+ token->type = type;
+ token->start = start;
+ token->end = end;
+ token->size = 0;
+}
+
+/**
+ * Fills next available token with JSON primitive.
+ */
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+ const size_t len, jsmntok_t *tokens,
+ const size_t num_tokens) {
+ jsmntok_t *token;
+ int start;
+
+ start = parser->pos;
+
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ switch (js[parser->pos]) {
+#ifndef JSMN_STRICT
+ /* In strict mode primitive must be followed by "," or "}" or "]" */
+ case ':':
+#endif
+ case '\t':
+ case '\r':
+ case '\n':
+ case ' ':
+ case ',':
+ case ']':
+ case '}':
+ goto found;
+ default:
+ /* to quiet a warning from gcc*/
+ break;
+ }
+ if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ }
+#ifdef JSMN_STRICT
+ /* In strict mode primitive must be followed by a comma/object/array */
+ parser->pos = start;
+ return JSMN_ERROR_PART;
+#endif
+
+found:
+ if (tokens == NULL) {
+ parser->pos--;
+ return 0;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL) {
+ parser->pos = start;
+ return JSMN_ERROR_NOMEM;
+ }
+ jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
+#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+#endif
+ parser->pos--;
+ return 0;
+}
+
+/**
+ * Fills next token with JSON string.
+ */
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+ const size_t len, jsmntok_t *tokens,
+ const size_t num_tokens) {
+ jsmntok_t *token;
+
+ int start = parser->pos;
+
+ parser->pos++;
+
+ /* Skip starting quote */
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ char c = js[parser->pos];
+
+ /* Quote: end of string */
+ if (c == '\"') {
+ if (tokens == NULL) {
+ return 0;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL) {
+ parser->pos = start;
+ return JSMN_ERROR_NOMEM;
+ }
+ jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos);
+#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+#endif
+ return 0;
+ }
+
+ /* Backslash: Quoted symbol expected */
+ if (c == '\\' && parser->pos + 1 < len) {
+ int i;
+ parser->pos++;
+ switch (js[parser->pos]) {
+ /* Allowed escaped symbols */
+ case '\"':
+ case '/':
+ case '\\':
+ case 'b':
+ case 'f':
+ case 'r':
+ case 'n':
+ case 't':
+ break;
+ /* Allows escaped symbol \uXXXX */
+ case 'u':
+ parser->pos++;
+ for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0';
+ i++) {
+ /* If it isn't a hex character we have an error */
+ if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+ (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+ (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ parser->pos++;
+ }
+ parser->pos--;
+ break;
+ /* Unexpected symbol */
+ default:
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ }
+ }
+ parser->pos = start;
+ return JSMN_ERROR_PART;
+}
+
+/**
+ * Parse JSON string and fill tokens.
+ */
+JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+ jsmntok_t *tokens, const unsigned int num_tokens) {
+ int r;
+ int i;
+ jsmntok_t *token;
+ int count = parser->toknext;
+
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ char c;
+ jsmntype_t type;
+
+ c = js[parser->pos];
+ switch (c) {
+ case '{':
+ case '[':
+ count++;
+ if (tokens == NULL) {
+ break;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL) {
+ return JSMN_ERROR_NOMEM;
+ }
+ if (parser->toksuper != -1) {
+ jsmntok_t *t = &tokens[parser->toksuper];
+#ifdef JSMN_STRICT
+ /* In strict mode an object or array can't become a key */
+ if (t->type == JSMN_OBJECT) {
+ return JSMN_ERROR_INVAL;
+ }
+#endif
+ t->size++;
+#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+#endif
+ }
+ token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
+ token->start = parser->pos;
+ parser->toksuper = parser->toknext - 1;
+ break;
+ case '}':
+ case ']':
+ if (tokens == NULL) {
+ break;
+ }
+ type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
+#ifdef JSMN_PARENT_LINKS
+ if (parser->toknext < 1) {
+ return JSMN_ERROR_INVAL;
+ }
+ token = &tokens[parser->toknext - 1];
+ for (;;) {
+ if (token->start != -1 && token->end == -1) {
+ if (token->type != type) {
+ return JSMN_ERROR_INVAL;
+ }
+ token->end = parser->pos + 1;
+ parser->toksuper = token->parent;
+ break;
+ }
+ if (token->parent == -1) {
+ if (token->type != type || parser->toksuper == -1) {
+ return JSMN_ERROR_INVAL;
+ }
+ break;
+ }
+ token = &tokens[token->parent];
+ }
+#else
+ for (i = parser->toknext - 1; i >= 0; i--) {
+ token = &tokens[i];
+ if (token->start != -1 && token->end == -1) {
+ if (token->type != type) {
+ return JSMN_ERROR_INVAL;
+ }
+ parser->toksuper = -1;
+ token->end = parser->pos + 1;
+ break;
+ }
+ }
+ /* Error if unmatched closing bracket */
+ if (i == -1) {
+ return JSMN_ERROR_INVAL;
+ }
+ for (; i >= 0; i--) {
+ token = &tokens[i];
+ if (token->start != -1 && token->end == -1) {
+ parser->toksuper = i;
+ break;
+ }
+ }
+#endif
+ break;
+ case '\"':
+ r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
+ if (r < 0) {
+ return r;
+ }
+ count++;
+ if (parser->toksuper != -1 && tokens != NULL) {
+ tokens[parser->toksuper].size++;
+ }
+ break;
+ case '\t':
+ case '\r':
+ case '\n':
+ case ' ':
+ break;
+ case ':':
+ parser->toksuper = parser->toknext - 1;
+ break;
+ case ',':
+ if (tokens != NULL && parser->toksuper != -1 &&
+ tokens[parser->toksuper].type != JSMN_ARRAY &&
+ tokens[parser->toksuper].type != JSMN_OBJECT) {
+#ifdef JSMN_PARENT_LINKS
+ parser->toksuper = tokens[parser->toksuper].parent;
+#else
+ for (i = parser->toknext - 1; i >= 0; i--) {
+ if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
+ if (tokens[i].start != -1 && tokens[i].end == -1) {
+ parser->toksuper = i;
+ break;
+ }
+ }
+ }
+#endif
+ }
+ break;
+#ifdef JSMN_STRICT
+ /* In strict mode primitives are: numbers and booleans */
+ case '-':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case 't':
+ case 'f':
+ case 'n':
+ /* And they must not be keys of the object */
+ if (tokens != NULL && parser->toksuper != -1) {
+ const jsmntok_t *t = &tokens[parser->toksuper];
+ if (t->type == JSMN_OBJECT ||
+ (t->type == JSMN_STRING && t->size != 0)) {
+ return JSMN_ERROR_INVAL;
+ }
+ }
+#else
+ /* In non-strict mode every unquoted value is a primitive */
+ default:
+#endif
+ r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
+ if (r < 0) {
+ return r;
+ }
+ count++;
+ if (parser->toksuper != -1 && tokens != NULL) {
+ tokens[parser->toksuper].size++;
+ }
+ break;
+
+#ifdef JSMN_STRICT
+ /* Unexpected char in strict mode */
+ default:
+ return JSMN_ERROR_INVAL;
+#endif
+ }
+ }
+
+ if (tokens != NULL) {
+ for (i = parser->toknext - 1; i >= 0; i--) {
+ /* Unmatched opened object or array */
+ if (tokens[i].start != -1 && tokens[i].end == -1) {
+ return JSMN_ERROR_PART;
+ }
+ }
+ }
+
+ return count;
+}
+
+/**
+ * Creates a new parser based over a given buffer with an array of tokens
+ * available.
+ */
+JSMN_API void jsmn_init(jsmn_parser *parser) {
+ parser->pos = 0;
+ parser->toknext = 0;
+ parser->toksuper = -1;
+}
+
+#endif /* JSMN_HEADER */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* JSMN_H */
diff --git a/grub-core/lib/json/json.c b/grub-core/lib/json/json.c
new file mode 100644
index 0000000..1c20c75
--- /dev/null
+++ b/grub-core/lib/json/json.c
@@ -0,0 +1,264 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2019 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+
+#define JSMN_STATIC
+#include "jsmn.h"
+#include "json.h"
+
+GRUB_MOD_LICENSE ("GPLv3");
+
+grub_err_t
+grub_json_parse (grub_json_t **out, char *string, grub_size_t string_len)
+{
+ grub_json_t *json = NULL;
+ jsmn_parser parser;
+ grub_err_t ret = GRUB_ERR_NONE;
+ int jsmn_ret;
+
+ if (!string)
+ return GRUB_ERR_BAD_ARGUMENT;
+
+ json = grub_zalloc (sizeof (*json));
+ if (!json)
+ return GRUB_ERR_OUT_OF_MEMORY;
+ json->string = string;
+
+ /*
+ * Parse the string twice: first to determine how many tokens
+ * we need to allocate, second to fill allocated tokens.
+ */
+ jsmn_init (&parser);
+ jsmn_ret = jsmn_parse (&parser, string, string_len, NULL, 0);
+ if (jsmn_ret <= 0)
+ {
+ ret = GRUB_ERR_BAD_ARGUMENT;
+ goto err;
+ }
+
+ json->tokens = grub_calloc (jsmn_ret, sizeof (jsmntok_t));
+ if (!json->tokens)
+ {
+ ret = GRUB_ERR_OUT_OF_MEMORY;
+ goto err;
+ }
+
+ jsmn_init (&parser);
+ jsmn_ret = jsmn_parse (&parser, string, string_len, json->tokens, jsmn_ret);
+ if (jsmn_ret <= 0)
+ {
+ ret = GRUB_ERR_BAD_ARGUMENT;
+ goto err;
+ }
+
+ *out = json;
+
+ err:
+ if (ret)
+ grub_json_free (json);
+
+ return ret;
+}
+
+void
+grub_json_free (grub_json_t *json)
+{
+ if (json)
+ {
+ grub_free (json->tokens);
+ grub_free (json);
+ }
+}
+
+grub_err_t
+grub_json_getsize (grub_size_t *out, const grub_json_t *json)
+{
+ int size;
+
+ size = json->tokens[json->idx].size;
+ if (size < 0)
+ return GRUB_ERR_OUT_OF_RANGE;
+
+ *out = (grub_size_t) size;
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_json_gettype (grub_json_type_t *out, const grub_json_t *json)
+{
+ switch (json->tokens[json->idx].type)
+ {
+ case JSMN_OBJECT:
+ *out = GRUB_JSON_OBJECT;
+ break;
+ case JSMN_ARRAY:
+ *out = GRUB_JSON_ARRAY;
+ break;
+ case JSMN_STRING:
+ *out = GRUB_JSON_STRING;
+ break;
+ case JSMN_PRIMITIVE:
+ *out = GRUB_JSON_PRIMITIVE;
+ break;
+ default:
+ return GRUB_ERR_BAD_ARGUMENT;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_json_getchild (grub_json_t *out, const grub_json_t *parent, grub_size_t n)
+{
+ grub_size_t offset = 1, size;
+ jsmntok_t *p;
+
+ if (grub_json_getsize (&size, parent) || n >= size)
+ return GRUB_ERR_OUT_OF_RANGE;
+
+ /*
+ * Skip the first n children. For each of the children, we need
+ * to skip their own potential children (e.g. if it's an
+ * array), as well. We thus add the children's size to n on
+ * each iteration.
+ */
+ p = &parent->tokens[parent->idx];
+ while (n--)
+ n += p[offset++].size;
+
+ out->string = parent->string;
+ out->tokens = parent->tokens;
+ out->idx = parent->idx + offset;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_json_getvalue (grub_json_t *out, const grub_json_t *parent, const char *key)
+{
+ grub_json_type_t type;
+ grub_size_t i, size;
+
+ if (grub_json_gettype (&type, parent) || type != GRUB_JSON_OBJECT)
+ return GRUB_ERR_BAD_ARGUMENT;
+
+ if (grub_json_getsize (&size, parent))
+ return GRUB_ERR_BAD_ARGUMENT;
+
+ for (i = 0; i < size; i++)
+ {
+ grub_json_t child;
+ const char *s;
+
+ if (grub_json_getchild (&child, parent, i) ||
+ grub_json_getstring (&s, &child, NULL) ||
+ grub_strcmp (s, key) != 0)
+ continue;
+
+ return grub_json_getchild (out, &child, 0);
+ }
+
+ return GRUB_ERR_FILE_NOT_FOUND;
+}
+
+static grub_err_t
+get_value (grub_json_type_t *out_type, const char **out_string, const grub_json_t *parent, const char *key)
+{
+ const grub_json_t *p = parent;
+ grub_json_t child;
+ grub_err_t ret;
+ jsmntok_t *tok;
+
+ if (key)
+ {
+ ret = grub_json_getvalue (&child, parent, key);
+ if (ret)
+ return ret;
+ p = &child;
+ }
+
+ tok = &p->tokens[p->idx];
+ p->string[tok->end] = '\0';
+
+ *out_string = p->string + tok->start;
+
+ return grub_json_gettype (out_type, p);
+}
+
+grub_err_t
+grub_json_getstring (const char **out, const grub_json_t *parent, const char *key)
+{
+ grub_json_type_t type;
+ const char *value;
+ grub_err_t ret;
+
+ ret = get_value (&type, &value, parent, key);
+ if (ret)
+ return ret;
+ if (type != GRUB_JSON_STRING)
+ return GRUB_ERR_BAD_ARGUMENT;
+
+ *out = value;
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_json_getuint64 (grub_uint64_t *out, const grub_json_t *parent, const char *key)
+{
+ grub_json_type_t type;
+ const char *value;
+ const char *end;
+ grub_err_t ret;
+
+ ret = get_value (&type, &value, parent, key);
+ if (ret)
+ return ret;
+ if (type != GRUB_JSON_STRING && type != GRUB_JSON_PRIMITIVE)
+ return GRUB_ERR_BAD_ARGUMENT;
+
+ grub_errno = GRUB_ERR_NONE;
+ *out = grub_strtoul (value, &end, 10);
+ if (grub_errno != GRUB_ERR_NONE || *end)
+ return GRUB_ERR_BAD_NUMBER;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_json_getint64 (grub_int64_t *out, const grub_json_t *parent, const char *key)
+{
+ grub_json_type_t type;
+ const char *value;
+ const char *end;
+ grub_err_t ret;
+
+ ret = get_value (&type, &value, parent, key);
+ if (ret)
+ return ret;
+ if (type != GRUB_JSON_STRING && type != GRUB_JSON_PRIMITIVE)
+ return GRUB_ERR_BAD_ARGUMENT;
+
+ grub_errno = GRUB_ERR_NONE;
+ *out = grub_strtol (value, &end, 10);
+ if (grub_errno != GRUB_ERR_NONE || *end)
+ return GRUB_ERR_BAD_NUMBER;
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/lib/json/json.h b/grub-core/lib/json/json.h
new file mode 100644
index 0000000..4ea2a22
--- /dev/null
+++ b/grub-core/lib/json/json.h
@@ -0,0 +1,128 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2019 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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_JSON_JSON_H
+#define GRUB_JSON_JSON_H 1
+
+#include <grub/types.h>
+
+enum grub_json_type
+{
+ /* Unordered collection of key-value pairs. */
+ GRUB_JSON_OBJECT,
+ /* Ordered list of zero or more values. */
+ GRUB_JSON_ARRAY,
+ /* Zero or more Unicode characters. */
+ GRUB_JSON_STRING,
+ /* Number, boolean or empty value. */
+ GRUB_JSON_PRIMITIVE,
+ /* Invalid token. */
+ GRUB_JSON_UNDEFINED,
+};
+typedef enum grub_json_type grub_json_type_t;
+
+/* Forward-declaration to avoid including jsmn.h. */
+struct jsmntok;
+
+struct grub_json
+{
+ struct jsmntok *tokens;
+ char *string;
+ grub_size_t idx;
+};
+typedef struct grub_json grub_json_t;
+
+/*
+ * Parse a JSON-encoded string. Note that the string passed to
+ * this function will get modified on subsequent calls to
+ * grub_json_get*(). Returns the root object of the parsed JSON
+ * object, which needs to be free'd via grub_json_free(). Callers
+ * must ensure that the string outlives the returned root object,
+ * and that child objects must not be used after the root object
+ * has been free'd.
+ */
+extern grub_err_t EXPORT_FUNC(grub_json_parse) (grub_json_t **out,
+ char *string,
+ grub_size_t string_len);
+
+/*
+ * Free the structure and its contents. The string passed to
+ * grub_json_parse() will not be free'd.
+ */
+extern void EXPORT_FUNC(grub_json_free) (grub_json_t *json);
+
+/*
+ * Get the child count of a valid grub_json_t instance. Children
+ * are present for arrays, objects (dicts) and keys of a dict.
+ */
+extern grub_err_t EXPORT_FUNC(grub_json_getsize) (grub_size_t *out,
+ const grub_json_t *json);
+
+/* Get the type of a valid grub_json_t instance. */
+extern grub_err_t EXPORT_FUNC(grub_json_gettype) (grub_json_type_t *out,
+ const grub_json_t *json);
+
+/*
+ * Get n'th child of a valid object, array or key. Will return an
+ * error if no such child exists. The result does not need to be
+ * free'd.
+ */
+extern grub_err_t EXPORT_FUNC(grub_json_getchild) (grub_json_t *out,
+ const grub_json_t *parent,
+ grub_size_t n);
+
+/*
+ * Get value of key from a valid grub_json_t instance. The result
+ * does not need to be free'd.
+ */
+extern grub_err_t EXPORT_FUNC(grub_json_getvalue) (grub_json_t *out,
+ const grub_json_t *parent,
+ const char *key);
+
+/*
+ * Get the string representation of a valid grub_json_t instance.
+ * If a key is given and parent is a JSON object, this function
+ * will return the string value of a child mapping to the key.
+ * If no key is given, it will return the string value of the
+ * parent itself.
+ */
+extern grub_err_t EXPORT_FUNC(grub_json_getstring) (const char **out,
+ const grub_json_t *parent,
+ const char *key);
+
+/*
+ * Get the uint64 representation of a valid grub_json_t instance.
+ * Returns an error if the value pointed to by `parent` cannot be
+ * converted to an uint64. See grub_json_getstring() for details
+ * on the key parameter.
+ */
+extern grub_err_t EXPORT_FUNC(grub_json_getuint64) (grub_uint64_t *out,
+ const grub_json_t *parent,
+ const char *key);
+
+/*
+ * Get the int64 representation of a valid grub_json_t instance.
+ * Returns an error if the value pointed to by `parent` cannot be
+ * converted to an int64. See grub_json_getstring() for
+ * details on the key parameter.
+ */
+extern grub_err_t EXPORT_FUNC(grub_json_getint64) (grub_int64_t *out,
+ const grub_json_t *parent,
+ const char *key);
+
+#endif
diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c
new file mode 100644
index 0000000..05719ab
--- /dev/null
+++ b/grub-core/lib/legacy_parse.c
@@ -0,0 +1,875 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2010,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/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/legacy_parse.h>
+#include <grub/i386/pc/vesa_modes_table.h>
+#include <grub/i18n.h>
+
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
+struct legacy_command
+{
+ const char *name;
+ const char *map;
+ const char *suffix;
+ unsigned suffixarg;
+ unsigned argc;
+ enum arg_type {
+ TYPE_VERBATIM,
+ TYPE_FORCE_OPTION,
+ TYPE_NOAPM_OPTION,
+ TYPE_TYPE_OR_NOMEM_OPTION,
+ TYPE_OPTION,
+ TYPE_FILE,
+ TYPE_FILE_NO_CONSUME,
+ TYPE_PARTITION,
+ TYPE_BOOL,
+ TYPE_INT,
+ TYPE_REST_VERBATIM,
+ TYPE_VBE_MODE,
+ TYPE_WITH_CONFIGFILE_OPTION
+ } argt[4];
+ enum {
+ FLAG_IGNORE_REST = 0x001,
+ FLAG_FALLBACK_AVAILABLE = 0x004,
+ FLAG_FALLBACK = 0x008,
+ FLAG_COLOR_INVERT = 0x010,
+ FLAG_NO_MENUENTRY = 0x020,
+ FLAG_MENUENTRY_ONLY = 0x040,
+ FLAG_TERMINAL = 0x080,
+ FLAG_TITLE = 0x100,
+ } flags;
+ const char *shortdesc;
+ const char *longdesc;
+};
+
+/* Help texts are kept here mostly for reference. They are never shown. So
+ no need to gettextize.
+ */
+static struct legacy_command legacy_commands[] =
+ {
+ /* FIXME: background unsupported. */
+ {"blocklist", "blocklist '%s'\n", NULL, 0, 1, {TYPE_FILE}, 0, "FILE",
+ "Print the blocklist notation of the file FILE."},
+ {"boot", "boot\n", NULL, 0, 0, {}, 0, 0,
+ "Boot the OS/chain-loader which has been loaded."},
+ {"bootp", "net_bootp; net_ls_addr; echo $\"" N_("Default server is ${net_default_server}") "\"; if [ x%s = x--with-configfile ]; then "
+ "if net_get_dhcp_option configfile_name pxe 150 string; then "
+ "configfile $configfile_name; fi; fi\n", NULL, 0, 1,
+ {TYPE_WITH_CONFIGFILE_OPTION}, FLAG_IGNORE_REST, "[--with-configfile]",
+ "Initialize a network device via BOOTP. If the option `--with-configfile'"
+ " is given, try to load a configuration file specified by the 150 vendor"
+ " tag."},
+ /* FIXME: border unsupported. */
+ {"cat", "cat '%s'\n", NULL, 0, 1, {TYPE_FILE}, 0, "FILE",
+ "Print the contents of the file FILE."},
+ {"chainloader", "chainloader %s '%s'\n", NULL, 0,
+ 2, {TYPE_FORCE_OPTION, TYPE_FILE}, 0, "[--force] FILE",
+ "Load the chain-loader FILE. If --force is specified, then load it"
+ " forcibly, whether the boot loader signature is present or not."},
+ {"clear", "clear\n", NULL, 0, 0, {}, 0, 0,
+ "Clear the screen."},
+ {"cmp", "cmp '%s' '%s'\n", NULL, 0,
+ 2, {TYPE_FILE, TYPE_FILE}, FLAG_IGNORE_REST, "FILE1 FILE2",
+ "Compare the file FILE1 with the FILE2 and inform the different values"
+ " if any."},
+ {"color", "set color_normal='%s'; set color_highlight='%s'\n", NULL, 0,
+ 2, {TYPE_VERBATIM, TYPE_VERBATIM},
+ FLAG_IGNORE_REST | FLAG_FALLBACK_AVAILABLE, "NORMAL [HIGHLIGHT]",
+ "Change the menu colors. The color NORMAL is used for most"
+ " lines in the menu, and the color HIGHLIGHT is used to highlight the"
+ " line where the cursor points. If you omit HIGHLIGHT, then the"
+ " inverted color of NORMAL is used for the highlighted line."
+ " The format of a color is \"FG/BG\". FG and BG are symbolic color names."
+ " A symbolic color name must be one of these: black, blue, green,"
+ " cyan, red, magenta, brown, light-gray, dark-gray, light-blue,"
+ " light-green, light-cyan, light-red, light-magenta, yellow and white."
+ " But only the first eight names can be used for BG. You can prefix"
+ " \"blink-\" to FG if you want a blinking foreground color."},
+ {"color", "set color_normal='%s'; set color_highlight='%s'\n", NULL, 0,
+ 1, {TYPE_VERBATIM},
+ FLAG_IGNORE_REST | FLAG_FALLBACK | FLAG_COLOR_INVERT, NULL, NULL},
+ {"configfile", "legacy_configfile '%s'\n", NULL, 0, 1, {TYPE_FILE},
+ 0, "FILE", "Load FILE as the configuration file."},
+ {"debug",
+ "if [ -z \"$debug\" ]; then set debug=all; else set debug=; fi\n", NULL, 0,
+ 0, {}, 0, 0, "Turn on/off the debug mode."},
+ {"default",
+ "set default='%s'; if [ x\"$default\" = xsaved ]; then load_env; "
+ "set default=\"$saved_entry\"; fi\n", NULL, 0, 1, {TYPE_VERBATIM}, 0,
+ "[NUM | `saved']",
+ "Set the default entry to entry number NUM (if not specified, it is"
+ " 0, the first entry) or the entry number saved by savedefault."},
+ {"dhcp", "net_bootp; net_ls_addr; if [ x%s = x--with-configfile ]; then "
+ "if net_get_dhcp_option configfile_name pxe 150 string; then "
+ "configfile $configfile_name; fi; fi\n", NULL, 0, 1,
+ {TYPE_WITH_CONFIGFILE_OPTION}, FLAG_IGNORE_REST, "[--with-configfile]",
+ "Initialize a network device via BOOTP. If the option `--with-configfile'"
+ " is given, try to load a configuration file specified by the 150 vendor"
+ " tag."},
+ {"displayapm", "lsapm\n", NULL, 0, 0, {}, 0, 0,
+ "Display APM BIOS information."},
+ {"displaymem", "lsmmap\n", NULL, 0, 0, {}, 0, 0,
+ "Display what GRUB thinks the system address space map of the"
+ " machine is, including all regions of physical RAM installed."},
+ /* FIXME: device and efimap unsupported. */
+ /* NOTE: embed unsupported. */
+ {"fallback", "set fallback='%s'\n", NULL, 0,
+ 1, {TYPE_VERBATIM}, 0, "NUM...",
+ "Go into unattended boot mode: if the default boot entry has any"
+ " errors, instead of waiting for the user to do anything, it"
+ " immediately starts over using the NUM entry (same numbering as the"
+ " `default' command). This obviously won't help if the machine"
+ " was rebooted by a kernel that GRUB loaded."},
+ {"find", "search -f '%s'\n", NULL, 0, 1, {TYPE_FILE}, 0, "FILENAME",
+ "Search for the filename FILENAME in all of partitions and print the list of"
+ " the devices which contain the file."},
+ /* FIXME: findiso unsupported. */
+ /* FIXME: foreground unsupported. */
+ /* FIXME: fstest unsupported. */
+ /* NOTE: The obsolete C/H/S geometry isn't shown anymore. */
+ {"geometry", "insmod regexp; ls -l (%s*)\n", NULL, 0, 1, {TYPE_VERBATIM}, 0, "DRIVE",
+ "Print the information for a drive DRIVE. "},
+ {"halt", "halt %s\n", NULL, 0, 1, {TYPE_NOAPM_OPTION}, 0, "[--no-apm]",
+ "Halt your system. If APM is available on it, turn off the power using"
+ " the APM BIOS, unless you specify the option `--no-apm'."},
+ /* FIXME: help unsupported. */ /* NUL_TERMINATE */
+ {"hiddenmenu", NULL,
+ "if sleep -i $timeout; then timeout=0; else timeout=-1; fi\n", 0,
+ 0, {}, 0, "", "Hide the menu."},
+ {"hide", "parttool '%s' hidden+\n", NULL, 0, 1, {TYPE_PARTITION},
+ 0, "PARTITION",
+ "Hide PARTITION by setting the \"hidden\" bit in"
+ " its partition type code."},
+ /* FIXME: ifconfig unsupported. */
+ /* FIXME: impsprobe unsupported. */
+ {"initrd", "legacy_initrd '%s' %s\n", NULL, 0, 2, {TYPE_FILE_NO_CONSUME,
+ TYPE_REST_VERBATIM}, 0,
+ "FILE [ARG ...]",
+ "Load an initial ramdisk FILE for a Linux format boot image and set the"
+ " appropriate parameters in the Linux setup area in memory."},
+ /* NOTE: install unsupported. */
+ /* FIXME: ioprobe unsupported. */
+ /* FIXME: really support --no-mem-option. */
+ {"kernel", "legacy_kernel %s %s '%s' %s\n", NULL, 0,
+ 4, {TYPE_TYPE_OR_NOMEM_OPTION, TYPE_TYPE_OR_NOMEM_OPTION,
+ TYPE_FILE_NO_CONSUME, TYPE_REST_VERBATIM}, 0,
+ "[--no-mem-option] [--type=TYPE] FILE [ARG ...]",
+ "Attempt to load the primary boot image from FILE. The rest of the"
+ " line is passed verbatim as the \"kernel command line\". Any modules"
+ " must be reloaded after using this command. The option --type is used"
+ " to suggest what type of kernel to be loaded. TYPE must be either of"
+ " \"netbsd\", \"freebsd\", \"openbsd\", \"linux\", \"biglinux\" and"
+ " \"multiboot\". The option --no-mem-option tells GRUB not to pass a"
+ " Linux's mem option automatically."},
+ {"lock", "if ! authenticate legacy; then return; fi", NULL, 0, 0, {}, 0,
+ 0, "Break a command execution unless the user is authenticated."},
+ {"makeactive", "parttool \"$root\" boot+\n", NULL, 0, 0, {}, 0, 0,
+ "Set the active partition on the root disk to GRUB's root device."
+ " This command is limited to _primary_ PC partitions on a hard disk."},
+ {"map", "drivemap '%s' '%s'\n", NULL, 0,
+ 2, {TYPE_PARTITION, TYPE_PARTITION},
+ FLAG_IGNORE_REST, "TO_DRIVE FROM_DRIVE",
+ "Map the drive FROM_DRIVE to the drive TO_DRIVE. This is necessary"
+ " when you chain-load some operating systems, such as DOS, if such an"
+ " OS resides at a non-first drive."},
+ /* NOTE: md5crypt unsupported since GRUB has not enough entropy and this
+ hash shouldn't be used anymore. */
+ {"module", "legacy_initrd '%s' %s\n", NULL, 0, 2, {TYPE_FILE_NO_CONSUME,
+ TYPE_REST_VERBATIM}, 0,
+ "FILE [ARG ...]",
+ "Load a boot module FILE for a Multiboot format boot image (no"
+ " interpretation of the file contents is made, so users of this"
+ " command must know what the kernel in question expects). The"
+ " rest of the line is passed as the \"module command line\", like"
+ " the `kernel' command."},
+ {"modulenounzip", "legacy_initrd_nounzip '%s' %s\n", NULL, 0, 2,
+ {TYPE_FILE_NO_CONSUME, TYPE_REST_VERBATIM}, 0,
+ "FILE [ARG ...]",
+ "The same as `module', except that automatic decompression is"
+ " disabled."},
+ {"pager", "set pager=%s; if [ \"$pager\" = 0 ]; then "
+ " echo Internal pager is now off; else "
+ "echo Internal pager is now on; fi\n", NULL, 0,
+ 1, {TYPE_BOOL}, FLAG_FALLBACK_AVAILABLE, "[FLAG]",
+ "Toggle pager mode with no argument. If FLAG is given and its value"
+ " is `on', turn on the mode. If FLAG is `off', turn off the mode."},
+ {"pager",
+ "if [ \"$pager\" = 1 ]; then pager=0; echo Internal pager is now off;"
+ "else pager=1; echo Internal pager is now on; fi\n", NULL, 0, 0, {},
+ FLAG_FALLBACK, NULL, NULL},
+ /* FIXME: partnew unsupported. */
+ {"parttype", "parttool '%s' type=%s\n", NULL, 0,
+ 2, {TYPE_PARTITION, TYPE_INT}, 0,
+ "PART TYPE", "Change the type of the partition PART to TYPE."},
+ {"password", "if [ \"$superusers\" = "" ]; then superusers=legacy; fi;\n"
+ "legacy_password %s '%s'\n",
+ "menuentry \"Superuser menu\" --users \"legacy\" { configfile '%s'; }\n",
+ 2, 3, {TYPE_OPTION, TYPE_VERBATIM, TYPE_FILE},
+ FLAG_IGNORE_REST | FLAG_FALLBACK_AVAILABLE | FLAG_NO_MENUENTRY,
+ "[--md5] PASSWD [FILE]",
+ "If used in the first section of a menu file, disable all"
+ " interactive editing control (menu entry editor and"
+ " command line). If the password PASSWD is entered, it loads the"
+ " FILE as a new config file and restarts the GRUB Stage 2. If you"
+ " omit the argument FILE, then GRUB just unlocks privileged"
+ " instructions. You can also use it in the script section, in"
+ " which case it will ask for the password, before continuing."
+ " The option --md5 tells GRUB that PASSWD is encrypted with"
+ " md5crypt."},
+ {"password", "if [ \"$superusers\" = "" ]; then superusers=legacy; fi;\n"
+ "legacy_password %s '%s'\n", NULL, 0, 2, {TYPE_OPTION, TYPE_VERBATIM},
+ FLAG_IGNORE_REST | FLAG_FALLBACK | FLAG_NO_MENUENTRY, NULL, NULL},
+ {"password", "if legacy_check_password %s '%s'; then configfile '%s'; "
+ "else return; fi\n", NULL, 2, 3, {TYPE_OPTION, TYPE_VERBATIM, TYPE_FILE},
+ FLAG_IGNORE_REST | FLAG_FALLBACK_AVAILABLE | FLAG_MENUENTRY_ONLY,
+ NULL, NULL},
+ {"password", "if ! legacy_check_password %s '%s'; then return fi;\n",
+ NULL, 0, 2, {TYPE_OPTION, TYPE_VERBATIM},
+ FLAG_IGNORE_REST | FLAG_FALLBACK | FLAG_MENUENTRY_ONLY, NULL, NULL},
+ /* NOTE: GRUB2 has a design principle of not eternally waiting for user
+ input. 60 seconds should be enough.
+ */
+ {"pause", "echo %s; if ! sleep -i 60; then return; fi\n", NULL, 0, 1,
+ {TYPE_REST_VERBATIM}, 0,
+ "[MESSAGE ...]", "Print MESSAGE, then wait until a key is pressed."},
+ {"print", "echo %s\n", NULL, 0, 1,
+ {TYPE_REST_VERBATIM}, 0,
+ "[MESSAGE ...]", "Print MESSAGE."},
+ /* FIXME: quit unsupported. */
+ /* FIXME: rarp unsupported. */
+ {"read", "read_dword %s\n", NULL, 0, 1, {TYPE_INT}, 0, "ADDR",
+ "Read a 32-bit value from memory at address ADDR and"
+ " display it in hex format."},
+ {"reboot", "reboot\n", NULL, 0, 0, {}, 0, 0, "Reboot your system."},
+ {"root", "set root='%s'; set legacy_hdbias='%s'\n", NULL, 0,
+ 2, {TYPE_PARTITION, TYPE_INT}, FLAG_FALLBACK_AVAILABLE,
+ "[DEVICE [HDBIAS]]",
+ "Set the current \"root device\" to the device DEVICE, then"
+ " attempt to mount it to get the partition size (for passing the"
+ " partition descriptor in `ES:ESI', used by some chain-loaded"
+ " bootloaders), the BSD drive-type (for booting BSD kernels using"
+ " their native boot format), and correctly determine "
+ " the PC partition where a BSD sub-partition is located. The"
+ " optional HDBIAS parameter is a number to tell a BSD kernel"
+ " how many BIOS drive numbers are on controllers before the current"
+ " one. For example, if there is an IDE disk and a SCSI disk, and your"
+ " FreeBSD root partition is on the SCSI disk, then use a `1' for HDBIAS."},
+ {"root", "echo \"$root\"\n", NULL, 0, 0, {}, FLAG_FALLBACK, NULL, NULL},
+ {"rootnoverify", "set root='%s'; set legacy_hdbias='%s'\n", NULL, 0,
+ 2, {TYPE_PARTITION, TYPE_INT}, 0,
+ "[DEVICE [HDBIAS]]",
+ "Similar to `root', but don't attempt to mount the partition. This"
+ " is useful for when an OS is outside of the area of the disk that"
+ " GRUB can read, but setting the correct root device is still"
+ " desired. Note that the items mentioned in `root' which"
+ " derived from attempting the mount will NOT work correctly."},
+ {"rootnoverify", "echo \"$root\"\n", NULL, 0,
+ 0, {}, FLAG_FALLBACK, NULL, NULL},
+ /* FIXME: support saving NUM and fallback. */
+ {"savedefault", "saved_entry=${chosen}; save_env saved_entry\n", NULL, 0,
+ 0, {}, 0, "[NUM | `fallback']",
+ "Save the current entry as the default boot entry if no argument is"
+ " specified. If a number is specified, this number is saved. If"
+ " `fallback' is used, next fallback entry is saved."},
+ {"serial", "serial %s\n", NULL, 0, 1, {TYPE_REST_VERBATIM}, 0,
+ "[--unit=UNIT] [--port=PORT] [--speed=SPEED] [--word=WORD] "
+ "[--parity=PARITY] [--stop=STOP] [--device=DEV]",
+ "Initialize a serial device. UNIT is a digit that specifies which serial"
+ " device is used (e.g. 0 == COM1). If you need to specify the port number,"
+ " set it by --port. SPEED is the DTE-DTE speed. WORD is the word length,"
+ " PARITY is the type of parity, which is one of `no', `odd' and `even'."
+ " STOP is the length of stop bit(s). The option --device can be used only"
+ " in the grub shell, which specifies the file name of a tty device. The"
+ " default values are COM1, 9600, 8N1."},
+ /* FIXME: shade unsupported. */
+ /* FIXME: silent unsupported. */
+ /* FIXME: splashimage unsupported. */
+ /* FIXME: setkey unsupported. */ /* NUL_TERMINATE */
+ /* NOTE: setup unsupported. */
+ /* FIXME: --no-echo, --no-edit unsupported. */
+ /* NOTE: both terminals are activated so --silent and --timeout
+ are useless. */
+ /* FIXME: graphics unsupported. */
+ {"terminal", NULL, NULL, 0, 0, {}, FLAG_TERMINAL | FLAG_IGNORE_REST,
+ "[--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] "
+ "[--silent] [console] [serial] [hercules] [graphics]",
+ "Select a terminal. When multiple terminals are specified, wait until"
+ " you push any key to continue. If both console and serial are specified,"
+ " the terminal to which you input a key first will be selected. If no"
+ " argument is specified, print current setting. The option --dumb"
+ " specifies that your terminal is dumb, otherwise, vt100-compatibility"
+ " is assumed. If you specify --no-echo, input characters won't be echoed."
+ " If you specify --no-edit, the BASH-like editing feature will be disabled."
+ " If --timeout is present, this command will wait at most for SECS"
+ " seconds. The option --lines specifies the maximum number of lines."
+ " The option --silent is used to suppress messages."},
+ /* FIXME: terminfo unsupported. */ /* NUL_TERMINATE */
+ {"testload", "testload '%s'\n", NULL, 0, 1, {TYPE_FILE}, 0, "FILE",
+ "Read the entire contents of FILE in several different ways and"
+ " compares them, to test the filesystem code. "
+ " If this test succeeds, then a good next"
+ " step is to try loading a kernel."},
+ {"testvbe", "insmod vbe; videotest '%s'\n", NULL, 0, 1, {TYPE_VBE_MODE}, 0,
+ "MODE", "Test the VBE mode MODE. Hit any key to return."},
+ /* FIXME: tftpserver unsupported. */
+ {"timeout", "set timeout=%s\n", NULL, 0, 1, {TYPE_INT}, 0, "SEC",
+ "Set a timeout, in SEC seconds, before automatically booting the"
+ " default entry (normally the first entry defined)."},
+ {"title", NULL, NULL, 0, 0, {}, FLAG_TITLE, "NAME ...",
+ "Start a new boot entry, and set its name to the contents of the"
+ " rest of the line, starting with the first non-space character."},
+ {"unhide", "parttool '%s' hidden-\n", NULL, 0,
+ 1, {TYPE_PARTITION}, 0, "PARTITION",
+ "Unhide PARTITION by clearing the \"hidden\" bit in its"
+ " partition type code."},
+ /* FIXME: uppermem unsupported. */
+ {"uuid", "search --set=root --fs-uuid '%s'\n", NULL, 0, 1, {TYPE_VERBATIM},
+ 0, "UUID", "Find root by UUID"},
+ {"vbeprobe", "insmod vbe; videoinfo '%s'\n", NULL, 0, 1, {TYPE_VBE_MODE},
+ FLAG_FALLBACK_AVAILABLE, "[MODE]",
+ "Probe VBE information. If the mode number MODE is specified, show only"
+ " the information about only the mode."},
+ {"vbeprobe", "insmod vbe; videoinfo\n", NULL, 0, 0, {},
+ FLAG_FALLBACK, NULL, NULL}
+ /* FIXME: verbose unsupported. */
+ /* FIXME: version unsupported. */
+ /* FIXME: viewport unsupported. */
+ };
+
+char *
+grub_legacy_escape (const char *in, grub_size_t len)
+{
+ char *ptr;
+ char *ret;
+ char saved;
+ int overhead = 0;
+
+ for (ptr = (char*)in; ptr < in + len && *ptr; ptr++)
+ if (*ptr == '\'')
+ overhead += 3;
+ ret = grub_malloc (ptr - in + overhead + 1);
+ if (!ret)
+ return NULL;
+
+ ptr = (char*)in;
+ saved = ptr[len];
+ ptr[len] = '\0';
+ grub_strchrsub (ret, ptr, '\'', "'\\''");
+ ptr[len] = saved;
+ return ret;
+}
+
+static char *
+adjust_file (const char *in, grub_size_t len)
+{
+ const char *comma, *ptr, *rest;
+ char *ret, *outptr;
+ int overhead = 0;
+ int part = -1, subpart = -1;
+ if (in[0] != '(')
+ return grub_legacy_escape (in, len);
+ for (ptr = in + 1; ptr < in + len && *ptr && *ptr != ')'
+ && *ptr != ','; ptr++)
+ if (*ptr == '\'' || *ptr == '\\')
+ overhead++;
+ comma = ptr;
+ if (*comma == ')' && comma - in == 3
+ && in[1] == 'n' && in[2] == 'd')
+ {
+ rest = comma + 1;
+ for (ptr = rest; ptr < in + len && *ptr; ptr++)
+ if (*ptr == '\'' || *ptr == '\\')
+ overhead++;
+
+ ret = grub_malloc (ptr - in + overhead + 15);
+ if (!ret)
+ return NULL;
+
+ outptr = grub_stpcpy (ret, "(tftp)");;
+ for (ptr = rest; ptr < in + len; ptr++)
+ {
+ if (*ptr == '\'' || *ptr == '\\')
+ *outptr++ = '\\';
+
+ *outptr++ = *ptr;
+ }
+ *outptr = 0;
+ return ret;
+ }
+ if (*comma != ',')
+ return grub_legacy_escape (in, len);
+ part = grub_strtoull (comma + 1, &rest, 0);
+ if (rest[0] == ',' && rest[1] >= 'a' && rest[1] <= 'z')
+ {
+ subpart = rest[1] - 'a';
+ rest += 2;
+ }
+ for (ptr = rest; ptr < in + len && *ptr; ptr++)
+ if (*ptr == '\'' || *ptr == '\\')
+ overhead++;
+
+ /* 35 is enough for any 2 numbers. */
+ ret = grub_malloc (ptr - in + overhead + 35 + 5);
+ if (!ret)
+ return NULL;
+
+ outptr = ret;
+ for (ptr = in; ptr < in + len && ptr <= comma; ptr++)
+ {
+ if (*ptr == '\'' || *ptr == '\\')
+ *outptr++ = '\\';
+
+ *outptr++ = *ptr;
+ }
+ if (subpart != -1)
+ grub_snprintf (outptr, 35, "%d,%d", part + 1, subpart + 1);
+ else
+ grub_snprintf (outptr, 35, "%d", part + 1);
+ while (*outptr)
+ outptr++;
+ for (ptr = rest; ptr < in + len; ptr++)
+ {
+ if (*ptr == '\'' || *ptr == '\\')
+ *outptr++ = '\\';
+
+ *outptr++ = *ptr;
+ }
+ *outptr = 0;
+ return ret;
+}
+
+static int
+check_option (const char *a, const char *b, grub_size_t len)
+{
+ if (grub_strlen (b) != len)
+ return 0;
+ return grub_strncmp (a, b, len) == 0;
+}
+
+static int
+is_option (enum arg_type opt, const char *curarg, grub_size_t len)
+{
+ switch (opt)
+ {
+ case TYPE_WITH_CONFIGFILE_OPTION:
+ return check_option (curarg, "--with-configfile", len);
+ case TYPE_NOAPM_OPTION:
+ return check_option (curarg, "--no-apm", len);
+ case TYPE_FORCE_OPTION:
+ return check_option (curarg, "--force", len);
+ case TYPE_TYPE_OR_NOMEM_OPTION:
+ return check_option (curarg, "--type=netbsd", len)
+ || check_option (curarg, "--type=freebsd", len)
+ || check_option (curarg, "--type=openbsd", len)
+ || check_option (curarg, "--type=linux", len)
+ || check_option (curarg, "--type=biglinux", len)
+ || check_option (curarg, "--type=multiboot", len)
+ || check_option (curarg, "--no-mem-option", len);
+ case TYPE_OPTION:
+ return (len >= 2 && curarg[0] == '-' && curarg[1] == '-');
+ default:
+ return 0;
+ }
+}
+
+char *
+grub_legacy_parse (const char *buf, char **entryname, char **suffix)
+{
+ const char *ptr;
+ const char *cmdname;
+ unsigned i, cmdnum;
+ char *args[ARRAY_SIZE (legacy_commands[0].argt)];
+
+ *suffix = NULL;
+
+ for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++);
+ if (!*ptr || *ptr == '#')
+ {
+ char *ret;
+ int len = grub_strlen (buf);
+ ret = grub_malloc (len + 2);
+ grub_memcpy (ret, buf, len);
+ if (len && ret[len - 1] == '\n')
+ ret[len] = 0;
+ else
+ {
+ ret[len] = '\n';
+ ret[len + 1] = 0;
+ }
+ return ret;
+ }
+
+ cmdname = ptr;
+ for (ptr = buf; *ptr && !grub_isspace (*ptr) && *ptr != '='; ptr++);
+
+ for (cmdnum = 0; cmdnum < ARRAY_SIZE (legacy_commands); cmdnum++)
+ if (grub_strncmp (legacy_commands[cmdnum].name, cmdname, ptr - cmdname) == 0
+ && legacy_commands[cmdnum].name[ptr - cmdname] == 0
+ && (!(*entryname != NULL && (legacy_commands[cmdnum].flags
+ & FLAG_NO_MENUENTRY)))
+ && (!(*entryname == NULL && (legacy_commands[cmdnum].flags
+ & FLAG_MENUENTRY_ONLY))))
+ break;
+ if (cmdnum == ARRAY_SIZE (legacy_commands))
+ return grub_xasprintf ("# Unsupported legacy command: %s\n", buf);
+
+ for (; grub_isspace (*ptr) || *ptr == '='; ptr++);
+
+ if (legacy_commands[cmdnum].flags & FLAG_TITLE)
+ {
+ const char *ptr2;
+ ptr2 = ptr + grub_strlen (ptr);
+ while (ptr2 > ptr && grub_isspace (*(ptr2 - 1)))
+ ptr2--;
+ *entryname = grub_strndup (ptr, ptr2 - ptr);
+ return NULL;
+ }
+
+ if (legacy_commands[cmdnum].flags & FLAG_TERMINAL)
+ {
+ int dumb = 0, lines = 24;
+#ifdef TODO
+ int no_echo = 0, no_edit = 0;
+#endif
+ int hercules = 0;
+ int console = 0, serial = 0, graphics = 0;
+ /* Big enough for any possible resulting command. */
+ char outbuf[512] = "";
+ char *outptr;
+ while (*ptr)
+ {
+ /* "[--timeout=SECS] [--silent]"
+ " [console] [serial] [hercules]"*/
+ if (grub_memcmp (ptr, "--dumb", sizeof ("--dumb") - 1) == 0)
+ dumb = 1;
+#ifdef TODO
+ if (grub_memcmp (ptr, "--no-echo", sizeof ("--no-echo") - 1) == 0)
+ no_echo = 1;
+
+ if (grub_memcmp (ptr, "--no-edit", sizeof ("--no-edit") - 1) == 0)
+ no_edit = 1;
+#endif
+ if (grub_memcmp (ptr, "--lines=", sizeof ("--lines=") - 1) == 0)
+ {
+ lines = grub_strtoul (ptr + sizeof ("--lines=") - 1, 0, 0);
+ if (grub_errno)
+ {
+ lines = 24;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+
+ if (grub_memcmp (ptr, "console", sizeof ("console") - 1) == 0)
+ console = 1;
+
+ if (grub_memcmp (ptr, "serial", sizeof ("serial") - 1) == 0)
+ serial = 1;
+ if (grub_memcmp (ptr, "hercules", sizeof ("hercules") - 1) == 0)
+ hercules = 1;
+ if (grub_memcmp (ptr, "graphics", sizeof ("graphics") - 1) == 0)
+ graphics = 1;
+ while (*ptr && !grub_isspace (*ptr))
+ ptr++;
+ while (*ptr && grub_isspace (*ptr))
+ ptr++;
+ }
+
+ if (!console && !serial && !hercules && !graphics)
+ return grub_strdup ("terminal_input; terminal_output; terminfo\n");
+
+ outptr = outbuf;
+
+ if (graphics)
+ outptr = grub_stpcpy (outptr, "insmod all_video; ");
+
+ outptr = grub_stpcpy (outptr, "terminal_input ");
+ if (serial)
+ outptr = grub_stpcpy (outptr, "serial ");
+ if (console || hercules || graphics)
+ outptr = grub_stpcpy (outptr, "console ");
+ outptr = grub_stpcpy (outptr, "; terminal_output ");
+ if (serial)
+ outptr = grub_stpcpy (outptr, "serial ");
+ if (console)
+ outptr = grub_stpcpy (outptr, "console ");
+ if (hercules)
+ outptr = grub_stpcpy (outptr, "mda_text ");
+ if (graphics)
+ outptr = grub_stpcpy (outptr, "gfxterm ");
+ outptr = grub_stpcpy (outptr, "; ");
+ *outptr = '\0';
+ if (serial)
+ {
+ grub_snprintf (outptr, outbuf + sizeof (outbuf) - outptr,
+ "terminfo serial -g 80x%d %s; ",
+ lines, dumb ? "dumb" : "vt100");
+ outptr += grub_strlen (outptr);
+ }
+
+ grub_strcpy (outptr, "\n");
+
+ return grub_strdup (outbuf);
+ }
+
+ grub_memset (args, 0, sizeof (args));
+
+ {
+ int hold_arg = 0;
+ const char *curarg = NULL;
+ for (i = 0; i < legacy_commands[cmdnum].argc; i++)
+ {
+ grub_size_t curarglen;
+ if (hold_arg)
+ {
+ ptr = curarg;
+ hold_arg = 0;
+ }
+ for (; grub_isspace (*ptr); ptr++);
+ curarg = ptr;
+ if (!*curarg)
+ break;
+ for (; *ptr && !grub_isspace (*ptr); ptr++);
+ if (i != legacy_commands[cmdnum].argc - 1
+ || (legacy_commands[cmdnum].flags & FLAG_IGNORE_REST))
+ curarglen = ptr - curarg;
+ else
+ {
+ curarglen = grub_strlen (curarg);
+ while (curarglen > 0 && grub_isspace (curarg[curarglen - 1]))
+ curarglen--;
+ }
+ if (*ptr)
+ ptr++;
+ switch (legacy_commands[cmdnum].argt[i])
+ {
+ case TYPE_FILE_NO_CONSUME:
+ hold_arg = 1;
+ /* Fallthrough. */
+ case TYPE_PARTITION:
+ case TYPE_FILE:
+ args[i] = adjust_file (curarg, curarglen);
+ break;
+
+ case TYPE_REST_VERBATIM:
+ {
+ char *outptr, *outptr0;
+ int overhead = 3;
+ ptr = curarg;
+ while (*ptr)
+ {
+ for (; *ptr && grub_isspace (*ptr); ptr++);
+ for (; *ptr && !grub_isspace (*ptr); ptr++)
+ if (*ptr == '\'')
+ overhead += 3;
+ if (*ptr)
+ ptr++;
+ overhead += 3;
+ }
+
+ outptr0 = args[i] = grub_malloc (overhead + (ptr - curarg));
+ if (!outptr0)
+ return NULL;
+ ptr = curarg;
+ outptr = outptr0;
+ while (*ptr)
+ {
+ for (; *ptr && grub_isspace (*ptr); ptr++);
+ if (outptr != outptr0)
+ *outptr++ = ' ';
+ *outptr++ = '\'';
+ for (; *ptr && !grub_isspace (*ptr); ptr++)
+ {
+ if (*ptr == '\'')
+ {
+ *outptr++ = '\'';
+ *outptr++ = '\\';
+ *outptr++ = '\'';
+ *outptr++ = '\'';
+ }
+ else
+ *outptr++ = *ptr;
+ }
+ *outptr++ = '\'';
+ if (*ptr)
+ ptr++;
+ }
+ *outptr++ = 0;
+ }
+ break;
+
+ case TYPE_VERBATIM:
+ args[i] = grub_legacy_escape (curarg, curarglen);
+ break;
+ case TYPE_WITH_CONFIGFILE_OPTION:
+ case TYPE_FORCE_OPTION:
+ case TYPE_NOAPM_OPTION:
+ case TYPE_TYPE_OR_NOMEM_OPTION:
+ case TYPE_OPTION:
+ if (is_option (legacy_commands[cmdnum].argt[i], curarg, curarglen))
+ {
+ args[i] = grub_strndup (curarg, curarglen);
+ break;
+ }
+ args[i] = grub_strdup ("");
+ hold_arg = 1;
+ break;
+ case TYPE_INT:
+ {
+ const char *brk;
+ int base = 10;
+ brk = curarg;
+ if (brk[0] == '0' && brk[1] == 'x')
+ {
+ base = 16;
+ brk += 2;
+ }
+ else if (brk[0] == '0')
+ base = 8;
+ for (; *brk && brk < curarg + curarglen; brk++)
+ {
+ if (base == 8 && (*brk == '8' || *brk == '9'))
+ break;
+ if (grub_isdigit (*brk))
+ continue;
+ if (base != 16)
+ break;
+ if (!(*brk >= 'a' && *brk <= 'f')
+ && !(*brk >= 'A' && *brk <= 'F'))
+ break;
+ }
+ if (brk == curarg)
+ args[i] = grub_strdup ("0");
+ else
+ args[i] = grub_strndup (curarg, brk - curarg);
+ }
+ break;
+ case TYPE_VBE_MODE:
+ {
+ unsigned mod;
+ struct grub_vesa_mode_table_entry *modedesc;
+
+ mod = grub_strtoul (curarg, 0, 0);
+ if (grub_errno)
+ {
+ mod = 0;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ if (mod < GRUB_VESA_MODE_TABLE_START
+ || mod > GRUB_VESA_MODE_TABLE_END)
+ {
+ args[i] = grub_strdup ("auto");
+ break;
+ }
+ modedesc = &grub_vesa_mode_table[mod - GRUB_VESA_MODE_TABLE_START];
+ if (!modedesc->width)
+ {
+ args[i] = grub_strdup ("auto");
+ break;
+ }
+ args[i] = grub_xasprintf ("%ux%ux%u",
+ modedesc->width, modedesc->height,
+ modedesc->depth);
+ break;
+ }
+ case TYPE_BOOL:
+ if (curarglen == 2 && curarg[0] == 'o' && curarg[1] == 'n')
+ args[i] = grub_strdup ("1");
+ else
+ args[i] = grub_strdup ("0");
+ break;
+ }
+ }
+ }
+
+ while (legacy_commands[cmdnum].argc > 0
+ && args[legacy_commands[cmdnum].argc - 1] == NULL
+ && (legacy_commands[cmdnum].flags & FLAG_FALLBACK_AVAILABLE)
+ && args[legacy_commands[cmdnum + 1].argc] == NULL)
+ cmdnum++;
+
+ for (; i < legacy_commands[cmdnum].argc; i++)
+ switch (legacy_commands[cmdnum].argt[i])
+ {
+ case TYPE_FILE_NO_CONSUME:
+ case TYPE_PARTITION:
+ case TYPE_FILE:
+ case TYPE_REST_VERBATIM:
+ case TYPE_VERBATIM:
+ case TYPE_WITH_CONFIGFILE_OPTION:
+ case TYPE_FORCE_OPTION:
+ case TYPE_NOAPM_OPTION:
+ case TYPE_TYPE_OR_NOMEM_OPTION:
+ case TYPE_OPTION:
+ args[i] = grub_strdup ("");
+ break;
+ case TYPE_BOOL:
+ case TYPE_INT:
+ args[i] = grub_strdup ("0");
+ break;
+ case TYPE_VBE_MODE:
+ args[i] = grub_strdup ("auto");
+ break;
+ }
+
+ if (legacy_commands[cmdnum].flags & FLAG_COLOR_INVERT)
+ {
+ char *corig = args[legacy_commands[cmdnum].argc - 1];
+ char *slash = grub_strchr (corig, '/');
+ char *invert;
+ grub_size_t len;
+
+ len = grub_strlen (corig);
+ if (!slash)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid color specification `%s'"),
+ args[0]);
+ return NULL;
+ }
+ invert = grub_malloc (len + 1);
+ if (!invert)
+ return NULL;
+ grub_memcpy (invert, slash + 1, len - (slash - corig) - 1);
+ invert[len - (slash - args[0]) - 1] = '/';
+ grub_memcpy (invert + len - (slash - corig), corig, slash - corig);
+ invert[len] = 0;
+ args[legacy_commands[cmdnum].argc] = invert;
+ }
+
+ if (legacy_commands[cmdnum].suffix)
+ {
+ *suffix = grub_xasprintf (legacy_commands[cmdnum].suffix,
+ args[legacy_commands[cmdnum].suffixarg]);
+ if (*suffix)
+ return NULL;
+ }
+
+ {
+ char *ret = grub_xasprintf (legacy_commands[cmdnum].map, args[0], args[1],
+ args[2], args[3]);
+ grub_free (args[0]);
+ grub_free (args[1]);
+ grub_free (args[2]);
+ grub_free (args[3]);
+ return ret;
+ }
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/ChangeLog b/grub-core/lib/libgcrypt-grub/cipher/ChangeLog
new file mode 100644
index 0000000..a00136b
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/ChangeLog
@@ -0,0 +1,4357 @@
+2021-06-08 Automatic import tool
+
+ Imported ciphers to GRUB
+
+ * Makefile.am: Removed
+ * Manifest: Removed
+ * ac.c: Removed
+ * arcfour.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (elftest): Removed declaration.
+ (selftest): Removed.
+ (GRUB_MOD_INIT(gcry_arcfour)): New function
+
+ Register cipher _gcry_cipher_spec_arcfour
+ (GRUB_MOD_FINI(gcry_arcfour)): New function
+
+ Unregister cipher _gcry_cipher_spec_arcfour
+ * blowfish.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (selftest): Removed.
+ (GRUB_MOD_INIT(gcry_blowfish)): New function
+
+ Register cipher _gcry_cipher_spec_blowfish
+ (GRUB_MOD_FINI(gcry_blowfish)): New function
+
+ Unregister cipher _gcry_cipher_spec_blowfish
+ * camellia-glue.c: Removed including of config.h
+ Removed including of config.h
+ (elftest): Removed declaration.
+ (selftest): Removed.
+ (GRUB_MOD_INIT(gcry_camellia)): New function
+
+ Register cipher _gcry_cipher_spec_camellia128
+ Register cipher _gcry_cipher_spec_camellia192
+ Register cipher _gcry_cipher_spec_camellia256
+ (GRUB_MOD_FINI(gcry_camellia)): New function
+
+ Unregister cipher _gcry_cipher_spec_camellia128
+ Unregister cipher _gcry_cipher_spec_camellia192
+ Unregister cipher _gcry_cipher_spec_camellia256
+ * cast5.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (selftest): Removed.
+ (GRUB_MOD_INIT(gcry_cast5)): New function
+
+ Register cipher _gcry_cipher_spec_cast5
+ (GRUB_MOD_FINI(gcry_cast5)): New function
+
+ Unregister cipher _gcry_cipher_spec_cast5
+ * cipher.c: Removed
+ * crc.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (GRUB_MOD_INIT(gcry_crc)): New function
+
+ Register digest _gcry_digest_spec_crc32
+ Register digest _gcry_digest_spec_crc32_rfc1510
+ Register digest _gcry_digest_spec_crc24_rfc2440
+ (GRUB_MOD_FINI(gcry_crc)): New function
+
+ Unregister MD _gcry_digest_spec_crc32
+ Unregister MD _gcry_digest_spec_crc32_rfc1510
+ Unregister MD _gcry_digest_spec_crc24_rfc2440
+ * des.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of string.h
+ (elftest): Removed declaration.
+ (weak_keys_chksum): Removed.
+ (tripledes_set2keys): Removed.
+ (selftest): Removed.
+ (do_tripledes_set_extra_info): Removed.
+ (selftest_fips): Removed.
+ (run_selftests): Removed.
+ (_gcry_cipher_extraspec_tripledes): Removed.
+ (GRUB_MOD_INIT(gcry_des)): New function
+
+ Register cipher _gcry_cipher_spec_des
+ Register cipher _gcry_cipher_spec_tripledes
+ (GRUB_MOD_FINI(gcry_des)): New function
+
+ Unregister cipher _gcry_cipher_spec_des
+ Unregister cipher _gcry_cipher_spec_tripledes
+ * dsa.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (gen_k): Removed declaration.
+ (test_keys): Removed declaration.
+ (progress_cb): Removed declaration.
+ (progress_cb): Removed declaration.
+ (_gcry_register_pk_dsa_progress): Removed.
+ (progress): Removed.
+ (gen_k): Removed.
+ (test_keys): Removed.
+ (generate): Removed.
+ (generate_fips186): Removed.
+ (sign): Removed.
+ (dsa_generate_ext): Removed.
+ (dsa_generate): Removed.
+ (dsa_sign): Removed.
+ (selftest_sign_1024): Removed.
+ (selftests_dsa): Removed.
+ (run_selftests): Removed.
+ (_gcry_pubkey_extraspec_dsa): Removed.
+ (GRUB_MOD_INIT(gcry_dsa)): New function
+
+ Register pk _gcry_digest_spec_crc24_rfc2440
+ (GRUB_MOD_FINI(gcry_dsa)): New function
+
+ Unregister pk _gcry_digest_spec_crc24_rfc2440
+ * ecc.c: Removed
+ * elgamal.c: Removed
+ * hash-common.c: Removed
+ * hmac-tests.c: Removed
+ * idea.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ Removed including of assert.h
+ (elftest): Removed declaration.
+ (selftest): Removed.
+ (GRUB_MOD_INIT(gcry_idea)): New function
+
+ Register cipher _gcry_cipher_spec_idea
+ (GRUB_MOD_FINI(gcry_idea)): New function
+
+ Unregister cipher _gcry_cipher_spec_idea
+ * kdf.c: Removed
+ * md.c: Removed
+ * md4.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (GRUB_MOD_INIT(gcry_md4)): New function
+
+ Register digest _gcry_digest_spec_md4
+ (GRUB_MOD_FINI(gcry_md4)): New function
+
+ Unregister MD _gcry_digest_spec_md4
+ * md5.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (GRUB_MOD_INIT(gcry_md5)): New function
+
+ Register digest _gcry_digest_spec_md5
+ (GRUB_MOD_FINI(gcry_md5)): New function
+
+ Unregister MD _gcry_digest_spec_md5
+ * primegen.c: Removed
+ * pubkey.c: Removed
+ * rfc2268.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (elftest): Removed declaration.
+ (selftest): Removed.
+ (GRUB_MOD_INIT(gcry_rfc2268)): New function
+
+ Register cipher _gcry_cipher_spec_rfc2268_40
+ (GRUB_MOD_FINI(gcry_rfc2268)): New function
+
+ Unregister cipher _gcry_cipher_spec_rfc2268_40
+ * rijndael.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (elftest): Removed declaration.
+ (_gcry_aes_cfb_enc): Removed.
+ (_gcry_aes_cbc_enc): Removed.
+ (_gcry_aes_ctr_enc): Removed.
+ (_gcry_aes_cfb_dec): Removed.
+ (_gcry_aes_cbc_dec): Removed.
+ (selftest_basic_128): Removed.
+ (selftest_basic_192): Removed.
+ (selftest_basic_256): Removed.
+ (selftest): Removed.
+ (selftest_fips_128_38a): Removed.
+ (selftest_fips_128): Removed.
+ (selftest_fips_192): Removed.
+ (selftest_fips_256): Removed.
+ (run_selftests): Removed.
+ (_gcry_cipher_extraspec_aes): Removed.
+ (_gcry_cipher_extraspec_aes192): Removed.
+ (_gcry_cipher_extraspec_aes256): Removed.
+ (GRUB_MOD_INIT(gcry_rijndael)): New function
+
+ Register cipher _gcry_cipher_spec_aes
+ Register cipher _gcry_cipher_spec_aes192
+ Register cipher _gcry_cipher_spec_aes256
+ (GRUB_MOD_FINI(gcry_rijndael)): New function
+
+ Unregister cipher _gcry_cipher_spec_aes
+ Unregister cipher _gcry_cipher_spec_aes192
+ Unregister cipher _gcry_cipher_spec_aes256
+ * rmd160.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (_gcry_rmd160_mixblock): Removed.
+ (_gcry_rmd160_hash_buffer): Removed.
+ (GRUB_MOD_INIT(gcry_rmd160)): New function
+
+ Register digest _gcry_digest_spec_rmd160
+ (GRUB_MOD_FINI(gcry_rmd160)): New function
+
+ Unregister MD _gcry_digest_spec_rmd160
+ * rsa.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ Removed including of errno.h
+ (test_keys): Removed declaration.
+ (secret): Removed declaration.
+ (test_keys): Removed.
+ (check_exponent): Removed.
+ (generate_std): Removed.
+ (gen_x931_parm_xp): Removed.
+ (gen_x931_parm_xi): Removed.
+ (generate_x931): Removed.
+ (secret): Removed.
+ (rsa_blind): Removed.
+ (rsa_unblind): Removed.
+ (rsa_generate_ext): Removed.
+ (rsa_generate): Removed.
+ (rsa_decrypt): Removed.
+ (rsa_sign): Removed.
+ (compute_keygrip): Removed.
+ (selftest_sign_1024): Removed.
+ (extract_a_from_sexp): Removed.
+ (selftest_encr_1024): Removed.
+ (selftests_rsa): Removed.
+ (run_selftests): Removed.
+ (_gcry_pubkey_extraspec_rsa): Removed.
+ (GRUB_MOD_INIT(gcry_rsa)): New function
+
+ Register pk _gcry_digest_spec_rmd160
+ (GRUB_MOD_FINI(gcry_rsa)): New function
+
+ Unregister pk _gcry_digest_spec_rmd160
+ * seed.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ (elftest): Removed declaration.
+ (selftest): Removed.
+ (GRUB_MOD_INIT(gcry_seed)): New function
+
+ Register cipher _gcry_cipher_spec_seed
+ (GRUB_MOD_FINI(gcry_seed)): New function
+
+ Unregister cipher _gcry_cipher_spec_seed
+ * serpent.c: Removed including of config.h
+ Removed including of string.h
+ Removed including of stdio.h
+ (serpent_test): Removed.
+ (GRUB_MOD_INIT(gcry_serpent)): New function
+
+ Register cipher _gcry_cipher_spec_serpent128
+ Register cipher _gcry_cipher_spec_serpent192
+ Register cipher _gcry_cipher_spec_serpent256
+ (GRUB_MOD_FINI(gcry_serpent)): New function
+
+ Unregister cipher _gcry_cipher_spec_serpent128
+ Unregister cipher _gcry_cipher_spec_serpent192
+ Unregister cipher _gcry_cipher_spec_serpent256
+ * sha1.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ Removed including of stdint.h
+ (_gcry_sha1_hash_buffer): Removed.
+ (selftests_sha1): Removed.
+ (run_selftests): Removed.
+ (_gcry_digest_extraspec_sha1): Removed.
+ (GRUB_MOD_INIT(gcry_sha1)): New function
+
+ Register digest _gcry_digest_spec_sha1
+ (GRUB_MOD_FINI(gcry_sha1)): New function
+
+ Unregister MD _gcry_digest_spec_sha1
+ * sha256.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (selftests_sha224): Removed.
+ (selftests_sha256): Removed.
+ (run_selftests): Removed.
+ (_gcry_digest_extraspec_sha224): Removed.
+ (_gcry_digest_extraspec_sha256): Removed.
+ (GRUB_MOD_INIT(gcry_sha256)): New function
+
+ Register digest _gcry_digest_spec_sha224
+ Register digest _gcry_digest_spec_sha256
+ (GRUB_MOD_FINI(gcry_sha256)): New function
+
+ Unregister MD _gcry_digest_spec_sha224
+ Unregister MD _gcry_digest_spec_sha256
+ * sha512.c: Removed including of config.h
+ Removed including of string.h
+ (selftests_sha384): Removed.
+ (selftests_sha512): Removed.
+ (run_selftests): Removed.
+ (_gcry_digest_extraspec_sha512): Removed.
+ (_gcry_digest_extraspec_sha384): Removed.
+ (GRUB_MOD_INIT(gcry_sha512)): New function
+
+ Register digest _gcry_digest_spec_sha512
+ Register digest _gcry_digest_spec_sha384
+ (GRUB_MOD_FINI(gcry_sha512)): New function
+
+ Unregister MD _gcry_digest_spec_sha512
+ Unregister MD _gcry_digest_spec_sha384
+ * test-getrusage.c: Removed
+ * tiger.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (GRUB_MOD_INIT(gcry_tiger)): New function
+
+ Register digest _gcry_digest_spec_tiger
+ Register digest _gcry_digest_spec_tiger1
+ Register digest _gcry_digest_spec_tiger2
+ (GRUB_MOD_FINI(gcry_tiger)): New function
+
+ Unregister MD _gcry_digest_spec_tiger
+ Unregister MD _gcry_digest_spec_tiger1
+ Unregister MD _gcry_digest_spec_tiger2
+ * twofish.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (elftest): Removed declaration.
+ (selftest): Removed.
+ Removed including of stdio.h
+ Removed including of string.h
+ Removed including of time.h
+ (GRUB_MOD_INIT(gcry_twofish)): New function
+
+ Register cipher _gcry_cipher_spec_twofish
+ Register cipher _gcry_cipher_spec_twofish128
+ (GRUB_MOD_FINI(gcry_twofish)): New function
+
+ Unregister cipher _gcry_cipher_spec_twofish
+ Unregister cipher _gcry_cipher_spec_twofish128
+ * whirlpool.c: Removed including of config.h
+ Removed including of stdio.h
+ Removed including of stdlib.h
+ Removed including of string.h
+ (GRUB_MOD_INIT(gcry_whirlpool)): New function
+
+ Register digest _gcry_digest_spec_whirlpool
+ (GRUB_MOD_FINI(gcry_whirlpool)): New function
+
+ Unregister MD _gcry_digest_spec_whirlpool
+ * crypto.lst: New file.
+ * types.h: New file.
+ * memory.h: New file.
+ * cipher.h: Likewise.
+ * g10lib.h: Likewise.
+
+2010-08-19 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Remove double release of the module.
+ Fixes bug#1263.
+
+2010-06-10 Jeff Johnson <n3npq@mac.com> (wk)
+
+ * ecc.c (ecc_generate_ext): Parse transient-key flag.
+ (generate_key): Add arg TRANSIENT_KEY and use it to set the random
+ level.
+
+2010-04-12 Brad Hards <bradh@frogmouth.net> (wk)
+
+ Spelling fixes.
+
+2010-03-26 Werner Koch <wk@g10code.com>
+
+ * tiger.c (asn): Unfetter the old TIGER from an OID.
+ (TIGER_CONTEXT): Add field VARIANT.
+ (tiger_init): Factor code out to ...
+ (do_init): New.
+ (tiger1_init, tiger2_init): New.
+ (_gcry_digest_spec_tiger1, _gcry_digest_spec_tiger2): New.
+ * md.c (digest_table): Add TIGER1 and TIGER2 variants.
+
+2009-12-11 Werner Koch <wk@g10code.com>
+
+ * sha256.c (Cho, Maj, Sum0, Sum1): Turn macros into inline
+ functions.
+ (transform): Partly unroll to interweave the chain variables
+
+ * sha512.c (ROTR, Ch, Maj, Sum0, Sum1): Turn macros into inline
+ functions.
+ (transform): Partly unroll to interweave the chain variables.
+ Suggested by Christian Grothoff.
+
+2009-12-10 Werner Koch <wk@g10code.com>
+
+ * Makefile.am (o_flag_munging): New.
+ (tiger.o, tiger.lo): Use it.
+
+ * cipher.c (do_ctr_encrypt): Add arg OUTBUFLEN. Check for
+ suitable value. Add check for valid inputlen. Wipe temporary
+ memory.
+ (do_ctr_decrypt): Likewise.
+ (do_cbc_encrypt, do_cbc_decrypt): Add arg OUTBUFLEN. Check for
+ suitable value. Move check for valid inputlen to here; change
+ returned error from INV_ARG to INV_LENGTH.
+ (do_ecb_encrypt, do_ecb_decrypt): Ditto.
+ (do_cfb_encrypt, do_cfb_decrypt): Ditto.
+ (do_ofb_encrypt, do_ofb_decrypt): Ditto.
+ (cipher_encrypt, cipher_encrypt): Adjust for above changes.
+ (gcry_cipher_encrypt, gcry_cipher_decrypt): Simplify.
+
+2009-12-09 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Allow for GCRY_CIPHER_MODE_AESWRAP.
+ (cipher_encrypt, cipher_decrypt): Ditto.
+ (do_aeswrap_encrypt, do_aeswrap_decrypt): New.
+ (struct gcry_cipher_handle): Add field marks.
+ (cipher_setkey, cipher_setiv): Update marks flags.
+ (cipher_reset): Reset marks.
+ (cipher_encrypt, cipher_decrypt): Add new arg OUTBUFLEN.
+ (gcry_cipher_encrypt, gcry_cipher_decrypt): Pass outbuflen to
+ cipher_encrypt. Replace GPG_ERR_TOO_SHORT by
+ GPG_ERR_BUFFER_TOO_SHORT.
+
+2009-08-21 Werner Koch <wk@g10code.com>
+
+ * dsa.c (dsa_generate_ext): Release retfactors array before
+ setting it to NULL. Reported by Daiko Ueno.
+
+2009-07-02 Werner Koch <wk@g10code.com>
+
+ * md.c (md_read): Fix incomplete check for NULL.
+ Reported by Fabian Kail.
+
+2009-03-31 Werner Koch <wk@g10code.com>
+
+ * rsa.c (rsa_check_secret_key): Return GPG_ERR_BAD_SECKEY and not
+ GPG_ERR_PUBKEY_ALGO.
+
+2009-02-16 Werner Koch <wk@g10code.com>
+
+ * rsa.c (generate_x931): Do not initialize TBL with automatic
+ variables.
+ * whirlpool.c, tiger.c, sha256.c, sha1.c, rmd160.c, md5.c
+ * md4.c, crc.c: Remove memory.h. This is garbage from gnupg.
+ Reported by Dan Fandrich.
+
+2009-01-22 Werner Koch <wk@g10code.com>
+
+ * ecc.c (compute_keygrip): Remove superfluous const.
+
+2009-01-06 Werner Koch <wk@g10code.com>
+
+ * rmd160.c (oid_spec_rmd160): Add TeleTrust identifier.
+
+2008-12-10 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate): Add arg DOMAIN and use it if specified.
+ (generate_fips186): Ditto.
+ (dsa_generate_ext): Parse and check the optional "domain"
+ parameter and pass them to the generate functions.
+
+ * rijndael.c (rijndael_names): Add "AES128" and "AES-128".
+ (rijndael192_names): Add "AES-192".
+ (rijndael256_names): Add "AES-256".
+
+2008-12-05 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate): Add arg TRANSIENT_KEY and use it to detrmine
+ the RNG quality needed.
+ (dsa_generate_ext): Parse the transient-key flag und pass it to
+ generate.
+
+2008-11-28 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate_fips186): Add arg DERIVEPARMS and use the seed
+ value if available.
+
+ * primegen.c (_gcry_generate_fips186_2_prime): Fix inner p loop.
+
+2008-11-26 Werner Koch <wk@g10code.com>
+
+ * primegen.c (_gcry_generate_fips186_3_prime): New.
+ * dsa.c (generate_fips186): Add arg USE_FIPS186_2.
+ (dsa_generate_ext): Parse new flag use-fips183-2.
+
+2008-11-25 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate_fips186): New.
+ (dsa_generate_ext): Use new function if derive-parms are given or
+ if in FIPS mode.
+ * primegen.c (_gcry_generate_fips186_2_prime): New.
+
+2008-11-24 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Insert code to output extrainfo.
+ (pubkey_generate): Add arg R_EXTRAINFO and pass it to the extended
+ key generation function.
+ * rsa.c (gen_x931_parm_xp, gen_x931_parm_xi): New.
+ (generate_x931): Generate params if not given.
+ (rsa_generate_ext): Parse use-x931 flag. Return p-q-swapped
+ indicator.
+ * dsa.c (dsa_generate_ext): Put RETFACTORS into R_EXTRAINFO if
+ possible.
+
+ * pubkey.c (gcry_pk_genkey): Remove parsing of almost all
+ parameters and pass the parameter S-expression to pubkey_generate.
+ (pubkey_generate): Simplify by requitring modules to parse the
+ parameters. Remove the special cases for Elgamal and ECC.
+ (sexp_elements_extract_ecc): Add arg EXTRASPEC and use it. Fix
+ small memory leak.
+ (sexp_to_key): Pass EXTRASPEC to sexp_elements_extract_ecc.
+ (pubkey_table) [USE_ELGAMAL]: Add real extraspec.
+ * rsa.c (rsa_generate_ext): Adjust for new calling convention.
+ * dsa.c (dsa_generate_ext): Ditto.
+ * elgamal.c (_gcry_elg_generate): Ditto. Rename to elg_generate_ext.
+ (elg_generate): New.
+ (_gcry_elg_generate_using_x): Remove after merging code with
+ elg_generate_ext.
+ (_gcry_pubkey_extraspec_elg): New.
+ (_gcry_elg_check_secret_key, _gcry_elg_encrypt, _gcry_elg_sign)
+ (_gcry_elg_verify, _gcry_elg_get_nbits): Make static and remove
+ _gcry_ prefix.
+ * ecc.c (_gcry_ecc_generate): Rename to ecc_generate_ext and
+ adjust for new calling convention.
+ (_gcry_ecc_get_param): Rename to ecc_get_param and make static.
+ (_gcry_pubkey_extraspec_ecdsa): Add ecc_generate_ext and
+ ecc_get_param.
+
+2008-11-20 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pubkey_generate): Add arg DERIVEPARMS.
+ (gcry_pk_genkey): Parse derive-parms and pass it to above.
+ * rsa.c (generate_x931): New.
+ (rsa_generate_ext): Add arg DERIVEPARMS and call new function in
+ fips mode or if DERIVEPARMS is given.
+ * primegen.c (_gcry_derive_x931_prime, find_x931_prime): New.
+
+2008-11-19 Werner Koch <wk@g10code.com>
+
+ * rsa.c (rsa_decrypt): Use gcry_create_nonce for blinding.
+ (generate): Rename to generate_std.
+
+2008-11-05 Werner Koch <wk@g10code.com>
+
+ * md.c (md_open): Use a switch to set the Bsize.
+ (prepare_macpads): Fix long key case for SHA384 and SHA512.
+
+ * cipher.c (gcry_cipher_handle): Add field EXTRASPEC.
+ (gcry_cipher_open): Set it.
+ (gcry_cipher_ctl): Add private control code to disable weak key
+ detection and to return the current input block.
+ * des.c (_tripledes_ctx): Add field FLAGS.
+ (do_tripledes_set_extra_info): New.
+ (_gcry_cipher_extraspec_tripledes): Add new function.
+ (do_tripledes_setkey): Disable weak key detection.
+
+2008-10-24 Werner Koch <wk@g10code.com>
+
+ * md.c (digest_table): Allow MD5 in fips mode.
+ (md_register_default): Take special action for MD5.
+ (md_enable, gcry_md_hash_buffer): Ditto.
+
+2008-09-30 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (do_setkey): Properly align "t" and "tk".
+ (prepare_decryption): Properly align "w". Fixes bug #936.
+
+2008-09-18 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Parse domain parameter.
+ (pubkey_generate): Add new arg DOMAIN and remove special case for
+ DSA with qbits.
+ * rsa.c (rsa_generate): Add dummy args QBITS, NAME and DOMAIN and
+ rename to rsa_generate_ext. Change caller.
+ (_gcry_rsa_generate, _gcry_rsa_check_secret_key)
+ (_gcry_rsa_encrypt, _gcry_rsa_decrypt, _gcry_rsa_sign)
+ (_gcry_rsa_verify, _gcry_rsa_get_nbits): Make static and remove
+ _gcry_ prefix.
+ (_gcry_pubkey_spec_rsa, _gcry_pubkey_extraspec_rsa): Adjust names.
+ * dsa.c (dsa_generate_ext): New.
+ (_gcry_dsa_generate): Replace code by a call to dsa_generate.
+ (_gcry_dsa_check_secret_key, _gcry_dsa_sign, _gcry_dsa_verify)
+ (_gcry_dsa_get_nbits): Make static and remove _gcry prefix.
+ (_gcry_dsa_generate2): Remove.
+ (_gcry_pubkey_spec_dsa): Adjust to name changes.
+ (_gcry_pubkey_extraspec_rsa): Add dsa_generate_ext.
+
+2008-09-16 Werner Koch <wk@g10code.com>
+
+ * ecc.c (run_selftests): Add arg EXTENDED.
+
+2008-09-12 Werner Koch <wk@g10code.com>
+
+ * rsa.c (test_keys): Do a bad case signature check.
+ * dsa.c (test_keys): Do a bad case check.
+
+ * cipher.c (_gcry_cipher_selftest): Add arg EXTENDED and pass it
+ to the called tests.
+ * md.c (_gcry_md_selftest): Ditto.
+ * pubkey.c (_gcry_pk_selftest): Ditto.
+ * rijndael.c (run_selftests): Add arg EXTENDED and pass it to the
+ called tests.
+ (selftest_fips_128): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftest_fips_192): Add dummy arg EXTENDED.
+ (selftest_fips_256): Ditto.
+ * hmac-tests.c (_gcry_hmac_selftest): Ditto.
+ (run_selftests): Ditto.
+ (selftests_sha1): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftests_sha224, selftests_sha256): Ditto.
+ (selftests_sha384, selftests_sha512): Ditto.
+ * sha1.c (run_selftests): Add arg EXTENDED and pass it to the
+ called test.
+ (selftests_sha1): Add arg EXTENDED and run only one test
+ non-extended mode.
+ * sha256.c (run_selftests): Add arg EXTENDED and pass it to the
+ called tests.
+ (selftests_sha224): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftests_sha256): Ditto.
+ * sha512.c (run_selftests): Add arg EXTENDED and pass it to the
+ called tests.
+ (selftests_sha384): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftests_sha512): Ditto.
+ * des.c (run_selftests): Add arg EXTENDED and pass it to the
+ called test.
+ (selftest_fips): Add dummy arg EXTENDED.
+ * rsa.c (run_selftests): Add dummy arg EXTENDED.
+
+ * dsa.c (run_selftests): Add dummy arg EXTENDED.
+
+ * rsa.c (extract_a_from_sexp): New.
+ (selftest_encr_1024): Check that the ciphertext does not match the
+ plaintext.
+ (test_keys): Improve tests and return an error status.
+ (generate): Return an error if test_keys fails.
+ * dsa.c (test_keys): Add comments and return an error status.
+ (generate): Return an error if test_keys failed.
+
+2008-09-11 Werner Koch <wk@g10code.com>
+
+ * rsa.c (_gcry_rsa_decrypt): Return an error instead of calling
+ BUG in case of a practically impossible condition.
+ (sample_secret_key, sample_public_key): New.
+ (selftest_sign_1024, selftest_encr_1024): New.
+ (selftests_rsa): Implement tests.
+ * dsa.c (sample_secret_key, sample_public_key): New.
+ (selftest_sign_1024): New.
+ (selftests_dsa): Implement tests.
+
+2008-09-09 Werner Koch <wk@g10code.com>
+
+ * hmac-tests.c (selftests_sha1): Add tests.
+ (selftests_sha224, selftests_sha384, selftests_sha512): Make up tests.
+
+ * hash-common.c, hash-common.h: New.
+ * sha1.c (selftests_sha1): Add 3 tests.
+ * sha256.c (selftests_sha256, selftests_sha224): Ditto.
+ * sha512.c (selftests_sha512, selftests_sha384): Ditto.
+
+2008-08-29 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_get_keygrip): Remove the special case for RSA
+ and check whether a custom computation function has been setup.
+ * rsa.c (compute_keygrip): New.
+ (_gcry_pubkey_extraspec_rsa): Setup this function.
+ * ecc.c (compute_keygrip): New.
+ (_gcry_pubkey_extraspec_ecdsa): Setup this function.
+
+2008-08-28 Werner Koch <wk@g10code.com>
+
+ * cipher.c (cipher_decrypt, cipher_encrypt): Return an error if
+ mode NONE is used.
+ (gcry_cipher_open): Allow mode NONE only with a debug flag set and
+ if not in FIPS mode.
+
+2008-08-26 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pubkey_generate): Add arg KEYGEN_FLAGS.
+ (gcry_pk_genkey): Implement new parameter "transient-key" and
+ pass it as flags to pubkey_generate.
+ (pubkey_generate): Make use of an ext_generate function.
+ * rsa.c (generate): Add new arg transient_key and pass appropriate
+ args to the prime generator.
+ (_gcry_rsa_generate): Factor all code out to ...
+ (rsa_generate): .. new func with extra arg KEYGEN_FLAGS.
+ (_gcry_pubkey_extraspec_ecdsa): Setup rsa_generate.
+ * primegen.c (_gcry_generate_secret_prime)
+ (_gcry_generate_public_prime): Add new arg RANDOM_LEVEL.
+
+2008-08-21 Werner Koch <wk@g10code.com>
+
+ * primegen.c (_gcry_generate_secret_prime)
+ (_gcry_generate_public_prime): Use a constant macro for the random
+ level.
+
+2008-08-19 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_elements_extract_ecc) [!USE_ECC]: Do not allow
+ allow "curve" parameter.
+
+2008-08-15 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (_gcry_pk_selftest): New.
+ * dsa.c (selftests_dsa, run_selftests): New.
+ * rsa.c (selftests_rsa, run_selftests): New.
+ * ecc.c (selftests_ecdsa, run_selftests): New.
+
+ * md.c (_gcry_md_selftest): New.
+ * sha1.c (run_selftests, selftests_sha1): New.
+ * sha256.c (selftests_sha224, selftests_sha256, run_selftests): New.
+ * sha512.c (selftests_sha384, selftests_sha512, run_selftests): New.
+
+ * des.c (selftest): Remove static variable form selftest.
+ (des_setkey): No on-the-fly self test in fips mode.
+ (tripledes_set3keys): Ditto.
+
+ * cipher.c (_gcry_cipher_setkey, _gcry_cipher_setiv):
+
+ * dsa.c (generate): Bail out in fips mode if NBITS is less than 1024.
+ * rsa.c (generate): Return an error code if the the requested size
+ is less than 1024 and we are in fpis mode.
+ (_gcry_rsa_generate): Take care of that error code.
+
+ * ecc.c (generate_curve): In fips mode enable only NIST curves.
+
+ * cipher.c (_gcry_cipher_selftest): New.
+
+ * sha512.c (_gcry_digest_extraspec_sha384)
+ (_gcry_digest_extraspec_sha512): New.
+ * sha256.c (_gcry_digest_extraspec_sha224)
+ (_gcry_digest_extraspec_sha256): New.
+ * sha1.c (_gcry_digest_extraspec_sha1): New.
+ * ecc.c (_gcry_pubkey_extraspec_ecdsa): New.
+ * dsa.c (_gcry_pubkey_extraspec_dsa): New.
+ * rsa.c (_gcry_pubkey_extraspec_rsa): New.
+ * rijndael.c (_gcry_cipher_extraspec_aes)
+ (_gcry_cipher_extraspec_aes192, _gcry_cipher_extraspec_aes256): New.
+ * des.c (_gcry_cipher_extraspec_tripledes): New.
+
+ * cipher.c (gcry_cipher_register): Rename to _gcry_cipher_register.
+ Add arg EXTRASPEC.
+ (dummy_extra_spec): New.
+ (cipher_table_entry): Add extraspec field.
+ * md.c (_gcry_md_register): Rename to _gcry_md_register. Add
+ arg EXTRASPEC.
+ (dummy_extra_spec): New.
+ (digest_table_entry): Add extraspec field.
+ * pubkey.c (gcry_pk_register): Rename to _gcry_pk_register. Add
+ arg EXTRASPEC.
+ (dummy_extra_spec): New.
+ (pubkey_table_entry): Add extraspec field.
+
+ * ac.c: Let most public functions return GPG_ERR_UNSUPPORTED in
+ fips mode.
+
+ * pubkey.c (pubkey_table_entry): Add field FIPS_ALLOWED and mark
+ appropriate algorithms.
+ (dummy_generate, dummy_check_secret_key, dummy_encrypt)
+ (dummy_decrypt, dummy_sign, dummy_verify, dummy_get_nbits): Signal
+ a fips error when used.
+ (gcry_pk_register): In fips mode do not allow to register new
+ algorithms.
+
+ * md.c (digest_table): Add field FIPS_ALLOWED and mark appropriate
+ algorithms.
+ (md_register_default): In fips mode register only fips algorithms.
+ (gcry_md_register): In fips mode do not allow to register new
+ algorithms.
+ (gcry_md_get): Signal a fips error if called.
+ (gcry_md_hash_buffer): Do not allow rmd160 when not in fips mode.
+ (md_start_debug): Disable in fips_mode.
+
+ * md.c (gcry_md_register_default): Rename to ..
+ (md_register_default): .. this.
+ (md_digest): Remove this commented fucntion.
+ * pubkey.c (gcry_pk_register_default): Rename to ..
+ (pk_register_default): .. this.
+
+ * cipher.c (cipher_table_entry): Add field FIPS_ALLOWED.
+ (gcry_cipher_register_default): Register only fips approved
+ algorithms.
+ (gcry_cipher_register): Do not allow to register new ciphers.
+ (cipher_setiv): Signal fips error.
+
+ * cipher (gcry_cipher_register_default): Rename to ..
+ (cipher_register_default): .. this.
+ (REGISTER_DEFAULT_CIPHERS): Adjust for that change.
+
+2008-07-05 Werner Koch <wk@g10code.com>
+
+ * random-daemon.c, random.h, rndhw.c, rndunix.c, rand-internal.h
+ * random.c, rndegd.c, rndlinux.c, rndw32.c: Move to ../cipher.
+ * Makefile.am: Remove random stuff.
+
+2008-06-24 Szakats Istvan <szaki.ms@gmail.com> (wk)
+
+ * ac.c (_gcry_ac_key_destroy, _gcry_ac_key_pair_generate): Relase
+ some more memory.
+
+2008-04-22 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (_gcry_aes_cfb_enc, _gcry_aes_cbc_enc)
+ (_gcry_aes_cfb_dec, _gcry_aes_cbc_dec): Use Padlock if possible.
+
+2008-04-18 Werner Koch <wk@g10code.com>
+
+ * sha1.c (transform_aligned): Remove. That is will obviosuly not
+ work because we need a scratch working area and our internal API
+ does not allow to modify the buffers.
+
+ * rijndael.c: Factor tables out to ..
+ * rijndael-tables.h: .. new.
+
+ * ac.c (ac_data_extract): Make static.
+
+ * camellia.h [HAVE_CONFIG_H]: Include config.h.
+
+ * rndw32.c (registry_poll): Only print the performance data
+ problem warning once. Suggested by Simon Josefsson.
+
+2008-03-19 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open) [USE_AES]: Init bulk encryption only
+ if requested. Suggested by Dirk Stoecker.
+
+2008-03-18 Werner Koch <wk@g10code.com>
+
+ * sha1.c: Include stdint.h.
+ (transform): Add arg NBLOCKS so that we can work on more than one
+ block and avoid updates of the chaining variables. Changed all
+ callers to use 1.
+ (sha1_write): Replace loop around transform.
+ (transform_aligned) [WORDS_BIGENDIAN]: New.
+ (TRANSFORM): New macro to replace all direct calls of transform.
+
+2008-03-17 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (_gcry_aes_cfb_dec): New.
+ (do_encrypt): Factor code out to ..
+ (do_encrypt_aligned): .. New.
+ (_gcry_aes_cfb_enc, _gcry_aes_cfb_dec): Use new function.
+ (do_decrypt): Factor code out to ..
+ (do_decrypt_aligned): .. new.
+ (_gcry_aes_cbc_enc, _gcry_aes_cbc_dec): New.
+ * cipher.c (struct gcry_cipher_handle): Put field IV into new
+ union U_IV to enforce proper alignment. Change all users.
+ (do_cfb_decrypt): Optimize.
+ (do_cbc_encrypt, do_cbc_decrypt): Optimize.
+
+2008-03-15 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (_gcry_aes_cfb_enc): New.
+ * cipher.c (struct gcry_cipher_handle): Add field ALGO and BULK.
+ (gcry_cipher_open): Set ALGO and BULK.
+ (do_cfb_encrypt): Optimize.
+
+2008-02-18 Werner Koch <wk@g10code.com>
+
+ * rsa.c (_gcry_rsa_verify) [IS_DEVELOPMENT_VERSION]: Print
+ intermediate results.
+
+2008-01-08 Werner Koch <wk@g10code.com>
+
+ * random.c (add_randomness): Do not just increment
+ POOL_FILLED_COUNTER but update it by the actual amount of data.
+
+2007-12-13 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_data_to_mpi): Support SHA-224.
+
+2007-12-05 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (USE_PADLOCK): Depend on ENABLE_PADLOCK_SUPPORT.
+ * rndhw.c (USE_PADLOCK): Ditto
+
+ * rsa.c (secret): Fixed condition test for using CRT. Reported by
+ Dean Scarff. Fixes bug#864.
+ (_gcry_rsa_check_secret_key): Return an erro if the optional
+ parameters are missing.
+ * pubkey.c (sexp_elements_extract): Add arg ALGO_NAME. Changed all
+ callers to pass NULL. Add hack to allow for optional RSA
+ parameters.
+ (sexp_to_key): Pass algo name to sexp_elements_extract.
+
+2007-12-03 Werner Koch <wk@g10code.com>
+
+ * random.c (gcry_random_add_bytes): Implement it.
+ * rand-internal.h (RANDOM_ORIGIN_EXTERNAL): New.
+
+2007-11-30 Werner Koch <wk@g10code.com>
+
+ * rndhw.c: New.
+ * rndlinux.c (_gcry_rndlinux_gather_random): Try to read 50%
+ directly from the hwrng.
+ * random.c (do_fast_random_poll): Also run the hw rng fast poll.
+ (_gcry_random_dump_stats): Tell whether the hw rng failed.
+
+2007-11-29 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (USE_PADLOCK): Define new macro used for ia32.
+ (RIJNDAEL_context) [USE_PADLOCK]: Add fields USE_PADLOCK and
+ PADLOCK_KEY.
+ (do_setkey) [USE_PADLOCK]: Enable padlock if available for 128 bit
+ AES.
+ (do_padlock) [USE_PADLOCK]: New.
+ (rijndael_encrypt, rijndael_decrypt) [USE_PADLOCK]: Divert to
+ do_padlock.
+ * cipher.c (cipher_context_alignment_t): New. Use it in this
+ module in place of PROPERLY_ALIGNED_TYPE.
+ (NEED_16BYTE_ALIGNED_CONTEXT): Define macro for ia32.
+ (struct gcry_cipher_handle): Add field HANDLE_OFFSET.
+ (gcry_cipher_open): Take care of increased alignment requirements.
+ (gcry_cipher_close): Ditto.
+
+2007-11-28 Werner Koch <wk@g10code.com>
+
+ * sha256.c (asn224): Fixed wrong template. It happened due to a
+ bug in RFC4880. SHA-224 is not in the stable version of libgcrypt
+ so the consequences are limited to users of this devel version.
+
+2007-10-31 Werner Koch <wk@g10code.com>
+
+ * ac.c (gcry_ac_data_new): Remove due to the visibility wrapper.
+ (gcry_ac_data_destroy, gcry_ac_data_copy, gcry_ac_data_length)
+ (gcry_ac_data_set, gcry_ac_data_get_name, gcry_ac_data_get_index)
+ (gcry_ac_data_to_sexp, gcry_ac_data_from_sexp)
+ (gcry_ac_data_clear, gcry_ac_io_init, gcry_ac_open)
+ (gcry_ac_close, gcry_ac_key_init, gcry_ac_key_pair_generate)
+ (gcry_ac_key_pair_extract, gcry_ac_key_destroy)
+ (gcry_ac_key_pair_destroy, gcry_ac_key_data_get)
+ (gcry_ac_key_test, gcry_ac_key_get_nbits, gcry_ac_key_get_grip)
+ (gcry_ac_data_encrypt, gcry_ac_data_decrypt, gcry_ac_data_sign)
+ (gcry_ac_data_verify, gcry_ac_data_encode, gcry_ac_data_decode)
+ (gcry_ac_mpi_to_os, gcry_ac_mpi_to_os_alloc, gcry_ac_os_to_mpi)
+ (gcry_ac_data_encrypt_scheme, gcry_ac_data_decrypt_scheme)
+ (gcry_ac_data_sign_scheme, gcry_ac_data_verify_scheme)
+ (gcry_ac_io_init_va): Ditto.
+ (gcry_ac_id_to_name, gcry_ac_name_to_id): Remove as these
+ deprecated functions are now implemented by visibility.c.
+
+2007-10-26 Werner Koch <wk@g10code.com>
+
+ * rndw32.c: Disable debug flag.
+
+2007-10-25 Werner Koch <wk@g10code.com>
+
+ * rndw32.c: Updated from current cryptlib snapshot and modified
+ for our use. Removed support from pre NT systems.
+ (slow_gatherer_windows95): Remove.
+ (_gcry_rndw32_gather_random): Require an NT platform.
+ (init_system_rng, read_system_rng, read_mbm_data): New.
+ (slow_gatherer_windowsNT): Rename to ...
+ (slow_gatherer): .. this. Read system RNG and MBM.
+ (registry_poll): New with code factored out from slow_gatherer.
+
+2007-08-23 Werner Koch <wk@g10code.com>
+
+ * random.c (pool_filled_counter): New.
+ (add_randomness): Use it.
+
+2007-08-22 Werner Koch <wk@g10code.com>
+
+ * rndw32.c, rndunix.c: Switched to LGPL.
+
+2007-05-30 Werner Koch <wk@g10code.com>
+
+ * camellia.h, camellia.c: Replace by new LGPL version and adjusted
+ camellia.h.
+
+2007-05-09 Marcus Brinkmann <marcus@g10code.de>
+
+ * ac.c (_gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read):
+ Adjust users of gcry_ac_io_t because union is not anonymous
+ anymore.
+
+2007-05-02 Werner Koch <wk@g10code.com>
+
+ * camellia-glue.c (camellia_setkey, camellia_encrypt)
+ (camellia_decrypt): Recalculated used stack size in called
+ functions.
+ * camellia.h: Redefine external symbols.
+
+2007-05-02 David Shaw <dshaw@jabberwocky.com>
+
+ * Makefile.am, cipher.c: Add Camellia.
+
+ * camellia-glue.c: New. The necessary glue to interface libgcrypt
+ to the stock NTT Camellia distribution.
+
+ * camellia.h, camellia.c: The stock NTT Camellia distribution
+ (GPL).
+
+2007-04-30 David Shaw <dshaw@jabberwocky.com>
+
+ * cipher.c: Use #if instead of #ifdef as configure defines the
+ USE_cipher defines as 0 for disabled.
+
+2007-04-30 Werner Koch <wk@g10code.com>
+
+ * rndegd.c (_gcry_rndegd_set_socket_name): New.
+
+2007-04-30 Marcus Brinkmann <marcus@g10code.de>
+
+ * ecc.c (ec2os): Fix relocation of short numbers.
+
+ * ecc.c (generate_key): Do not allocate D, which will be allocated
+ by GEN_K. Remove G. Fix test if g_x, g_y resp. q_x, q_y are
+ requested.
+ (_gcry_ecc_generate): Release unneeded members of SK.
+ * pubkey.c (sexp_to_key): Release NAME.
+
+2007-04-28 Marcus Brinkmann <marcus@g10code.de>
+
+ * ac.c (gcry_ac_mpi): Remove member NAME_PROVIDED.
+ (ac_data_mpi_copy, _gcry_ac_data_set, _gcry_ac_data_get_name)
+ (_gcry_ac_data_get_index, ac_data_construct): Adjust handling of
+ NAME accordingly.
+
+2007-04-20 Werner Koch <wk@g10code.com>
+
+ * ecc.c (domain_parms): Add standard brainpool curves.
+
+2007-04-18 Werner Koch <wk@g10code.com>
+
+ * ecc.c (generate_curve): Implement alias mechanism.
+
+ * pubkey.c (sexp_elements_extract_ecc): New.
+ (sexp_to_key): Add special case for ecc.
+ (sexp_to_key, sexp_to_sig, sexp_to_enc, gcry_pk_genkey): Replace
+ name_terminated stuff by a call to _gcry_sexp_nth_string.
+ (gcry_pk_get_keygrip): Ditto.
+
+2007-04-16 Werner Koch <wk@g10code.com>
+
+ * ecc.c (_gcry_ecc_generate): Renamed DUMMY to CURVE and use it.
+
+2007-04-13 Marcus Brinkmann <marcus@g10code.de>
+
+ * ac.c (ac_data_construct): Cast const away to suppress compiler
+ warning.
+
+ * ecc.c (ecc_generate): Avoid compiler warning for unused argument
+ DUMMY.
+ (ecc_verify): Avoid compiler warning for unused arguments CMP and
+ OPAQUEV.
+
+2007-04-06 Werner Koch <wk@g10code.com>
+
+ * sha1.c (oid_spec_sha1): Add another oid from X9.62.
+
+2007-03-28 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Do not issue misc-key-info if it is
+ empty.
+ (gcry_pk_genkey): New parameter "curve".
+
+ * ecc.c: Entirely rewritten with only a few traces of the old
+ code left.
+ (_gcry_ecc_generate): New.
+ (generate_key) New arg NAME.
+ (generate_curve): Ditto. Return actual number of NBITS.
+
+2007-03-26 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Increase size of SKEY array and add a
+ runtime bounds check.
+
+2007-03-23 Werner Koch <wk@g10code.com>
+
+ * ecc.c (ecc_ctx_init, ecc_ctx_free, ecc_mod, ecc_mulm): New.
+ (duplicate_point, sum_points, escalar_mult): Don't use a
+ copy of base->p. Replaced all mpi_mulm by ecc_mulm so that we can
+ experiment with different algorithms.
+ (generate_key, check_secret_key, sign, verify): Initialize a
+ computation context for use by ecc_mulm.
+
+2007-03-22 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pubkey_table): Initialize ECC.
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Add ecc.c.
+ * ecc.c: New. Heavily reformatted and changed for use in libgcrypt.
+ (point_init): New.
+ (escalar_mult): Make arg R the first arg to be similar to the mpi
+ functions.
+ (duplicate_point): Ditto
+ (sum_points): Ditto
+ (sign, verify): Remove unneeded copy operations.
+ (sum_points): Removed memory leaks and optimized some compares.
+ (verify): Simplified input check.
+
+2007-03-14 Werner Koch <wk@g10code.com>
+
+ * random.c (MASK_LEVEL): Removed macro as it was used only at one
+ place. Open coded it there.
+ (gcry_randomize, _gcry_update_random_seed_file)
+ (_gcry_fast_random_poll): Factor lock code out to ..
+ (lock_pool, unlock_pool): .. new.
+ (initialize): Look the pool while allocating.
+ (read_random_source, do_fast_random_poll): Moved intialization to ...
+ (initialize): .. here.
+ (_gcry_enable_quick_random_gen): No more need for initialization.
+ (is_initialized): Moved this global flag to ..
+ (initialize): .. here and changed all users to unconditionally call
+ initialize.
+ (add_randomness): Remove initalization here. It simply can't
+ happen.
+
+ * random.c (enum random_origins): Moved to ..
+ * rand-internal.h: .. here.
+ * rndunix.c (_gcry_rndunix_gather_random): Use enum in prototype
+ for ORIGIN and renamed REQUESTOR to ORIGIN.
+ * rndegd.c (_gcry_rndegd_gather_random): Ditto.
+ * rndlinux.c (_gcry_rndlinux_gather_random): Ditto.
+ * rndw32.c (_gcry_rndw32_gather_random): Ditto.
+ (_gcry_rndw32_gather_random_fast): Ditto.
+
+2007-03-13 Werner Koch <wk@g10code.com>
+
+ * random.c (enum random_origins): New.
+ (add_randomness): Renamed arg SOURCE to ORIGIN.
+ (read_random_source): Renamed arg REQUESTOR to ORIGIN.
+ (getfnc_gather_random): Removed static variable because this
+ function is only called one and thus we don't need this
+ optimization.
+ (_gcry_quick_random_gen): Removed and replaced by..
+ (_gcry_enable_quick_random_gen): .. this. It is onlyu used to
+ enable it and it does not make sense to disable it later. Changed
+ the only one caller too.
+ (get_random_bytes): Removed.
+ (gcry_random_bytes, gcry_random_bytes_secure): Implement in terms
+ of gcry_randomize.
+ * random-daemon.c (_gcry_daemon_get_random_bytes): Removed.
+
+2007-02-23 Werner Koch <wk@g10code.com>
+
+ * elgamal.c (generate): Removed unused variable TEMP.
+ (test_keys): New arg NODIE.
+ (generate_using_x, _gcry_elg_generate_using_x): New.
+ * pubkey.c (pubkey_generate): New arg XVALUE and direct call to
+ the new elgamal generate fucntion.
+ (gcry_pk_genkey): Parse the new "xvalue" tag.
+
+2007-02-22 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_data_to_mpi): Handle dynamically allocated
+ algorithms. Suggested by Neil Dunbar. Fixes bug#596.
+
+ * rndw32.c (_gcry_rndw32_gather_random_fast): Make it return void.
+
+ * cipher.c (gcry_cipher_algo_name): Simplified.
+
+ * random.c: Use the daemon only if compiled with USE_RANDOM_DAEMON.
+
+ * Makefile.am (libcipher_la_SOURCES): Build random-daemon support
+ only if requested.
+
+2007-02-21 Werner Koch <wk@g10code.com>
+
+ * random.c (rndpool, keypool): Make unsigned.
+ (mix_pool): Change char* variables to unsigned char*.
+ (gcry_randomize): Make arg BUFFER a void*.
+ (gcry_create_nonce): Ditto.
+
+ * rmd160.c (gcry_rmd160_mixblock): Make BUFFER a void*.
+ (_gcry_rmd160_hash_buffer): Make OUTBUF and BUFFER void*.
+ * sha1.c (_gcry_sha1_hash_buffer): Ditto.
+
+ * cipher.c (gcry_cipher_encrypt, cry_cipher_decrypt): Change
+ buffer args to void*.
+ (gcry_cipher_register): Make ALGORITHM_ID a int *.
+
+ * md.c (md_start_debug): Make SUFFIX a const char*. Use snprintf.
+ (gcry_md_debug): New.
+ (gcry_md_ctl): Changed arg BUFFER from unsigned char*.
+
+ * md.c (md_write): Make INBUF a const void*.
+ (gcry_md_write): Remove needless cast.
+ * crc.c (crc32_write): Make INBUF a const void*
+ (update_crc32, crc24rfc2440_write): Ditto.
+ * sha512.c (sha512_write, transform): Ditto.
+ * sha256.c (sha256_write, transform): Ditto.
+ * rmd160.c (rmd160_write, transform): Ditto.
+ * md5.c (md5_write, transform): Ditto.
+ * md4.c (md4_write, transform): Ditto.
+ * sha1.c (sha1_write, transform): Ditto.
+
+ * tiger.c (tiger_write, transform): Ditto.
+ * whirlpool.c (whirlpool_write, whirlpool_add, transform): Ditto.
+
+ * elgamal.c (elg_names): Change to a const*.
+ * dsa.c (dsa_names): Ditto.
+ * rsa.c (rsa_names): Ditto.
+ * pubkey.c (gcry_pk_lookup_func_name): Make ALIASES a const.
+
+2007-02-20 Werner Koch <wk@g10code.com>
+
+ * rndlinux.c (open_device): Remove unsused arg MINOR.
+
+2007-01-30 Werner Koch <wk@g10code.com>
+
+ * sha256.c (oid_spec_sha256): Add alias from pkcs#1.
+ * sha512.c (oid_spec_sha512): Ditto.
+ (oid_spec_sha384): Ditto.
+
+2006-12-18 Werner Koch <wk@g10code.com>
+
+ * rndlinux.c (set_cloexec_flag): New.
+ (open_device): Set close-on-exit flags. Suggested by Max
+ Kellermann. Fixes Debian#403613.
+
+ * Makefile.am (AM_CPPFLAGS, AM_CFLAGS): Splitted and merged
+ Moritz' changes.
+ (INCLUDES): Removed.
+
+2006-11-30 Werner Koch <wk@g10code.com>
+
+ * serpent.c (byte_swap_32): Remove trailing semicolon.
+
+2006-11-15 Werner Koch <wk@g10code.com>
+
+ * Makefile.am (INCLUDES): Include ../src/
+
+2006-11-03 Werner Koch <wk@g10code.com>
+
+ * random.c [HAVE_GETTIMEOFDAY]: Included sys/time.h and not
+ sys/times.h. Reported by Rafaël Carré.
+
+2006-11-05 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (AM_CFLAGS): Added -I$(top_builddir)/src so that the
+ new gcrypt.h is used, not the one installed in the system.
+
+2006-10-25 Werner Koch <wk@g10code.com>
+
+ * primegen.c (prime_generate_internal): Tweaked use of secure
+ memory and entropy use. Safe unused primes from the pool. Allocate
+ at least a pool of 30.
+ (save_pool_prime, get_pool_prime): New.
+
+2006-10-23 Werner Koch <wk@g10code.com>
+
+ * ac.c (_gcry_ac_data_from_sexp): Reset sexp_tmp for failsafe
+ means. Release sexp_cur if needed. Reported by Dirk Stoecker.
+
+ * pubkey.c (pubkeys_registered_lock): Intialized it. It is not
+ realy needed because this is a mere initialization to 0 anyway.
+ Noted by Victor Stinner.
+
+2006-10-17 Werner Koch <wk@g10code.com>
+
+ * dsa.c (_gcry_dsa_generate2): New.
+ (generate): New arg QBITS. Add sanity checks for reasonable qbits
+ and nbits.
+ * pubkey.c (gcry_pk_genkey): Parse an qbits element.
+ (pubkey_generate): New arg QBITS. Pass it to the DSA generation.
+
+2006-10-05 Werner Koch <wk@g10code.com>
+
+ * md.c (gcry_md_algo_info) <get_asnoid>: Check that the algo is
+ available.
+
+2006-10-04 David Shaw <dshaw@jabberwocky.com> (wk)
+
+ * tiger.c (round): Rename to tiger_round as gcc 4 has a built-in
+ round function that this conflicts with.
+
+2006-09-11 Werner Koch <wk@g10code.com>
+
+ * rndw32.c (slow_gatherer_windowsNT): While adding data use the
+ size of the diskPerformance and not its address. Has been fixed in
+ GnuPG more than a year ago. Noted by Lee Fisher.
+
+2006-08-30 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_data_to_mpi): Need to allow "ripemd160" here as
+ this is the canonical name.
+
+2006-08-29 Hye-Shik Chang <perky@FreeBSD.org> (wk)
+
+ * seed.c: New.
+
+2006-08-03 Werner Koch <wk@g10code.com>
+
+ * random-daemon.c (_gcry_daemon_initialize_basics): Don't
+ initialize the socket. Remove arg SOCKETNAME.
+ (connect_to_socket): Make sure that daemon is set to -1 on error.
+ (call_daemon): Initialize the socket on the first call.
+ (_gcry_daemon_randomize, _gcry_daemon_get_random_bytes)
+ (_gcry_daemon_create_nonce): New arg SOCKETNAME.
+ * random.c (initialize): Call new daemon initializator.
+ (get_random_bytes, gcry_randomize, gcry_create_nonce): Pass socket
+ name to daemon call and reset allow_daemon on failure.
+
+2006-07-26 Werner Koch <wk@g10code.com>
+
+ * rmd160.c (_gcry_rmd160_mixblock): Add cast to transform call.
+
+ * blowfish.c (selftest): Cast string to usnigned char*.
+
+ * primegen.c (prime_generate_internal): Cast unsigned/char*
+ mismatch in calling m_out_of_n.
+ (is_prime): Changed COUNT to unsigned int *.
+
+ * ac.c (_gcry_ac_data_copy): Initialize DATA_MPIS.
+
+ * random.c (gcry_create_nonce): Update the pid after a fork.
+ Reported by Uoti Urpala.
+
+2006-07-04 Marcus Brinkmann <marcus@g10code.de>
+
+ * sha512.c: Fix typo in copyright notice.
+
+2006-06-21 Werner Koch <wk@g10code.com>
+
+ * rsa.c (_gcry_rsa_generate): Replace xcalloc by calloc.
+ * pubkey.c (gcry_pk_encrypt, gcry_pk_sign): Ditto.
+ (sexp_to_key, sexp_to_sig, sexp_to_enc, gcry_pk_encrypt)
+ (gcry_pk_sign, gcry_pk_genkey, gcry_pk_get_keygrip): Ditto.
+ * md.c (md_copy): Ditto.
+
+2006-04-22 Moritz Schulte <moritz@g10code.com>
+
+ * random-daemon.c (_gcry_daemon_initialize_basics): New argument:
+ SOCKETNAME. Passing on to connect_to_socket() if non-NULL.
+ (connect_to_socket, writen, readn, call_daemon): New functions.
+ (_gcry_daemon_randomize, _gcry_daemon_get_random_bytes)
+ (_gcry_daemon_create_nonce): Call call_daemon().
+ (RANDOM_DAEMON_SOCKET): New symbol.
+ (daemon_socket): New static variable.
+
+ * random.h (_gcry_daemon_initialize_basics): New parameter:
+ SOCKETNAME.
+ (_gcry_set_random_daemon_socket): New declaration.
+
+ * random.c (initialize_basics): Pass DAEMON_SOCKET_NAME to
+ _gcry_daemon_initialize_basics.
+ (_gcry_set_random_daemon_socket): New function, setting
+ DAEMON_SOCKET_NAME.
+
+2006-04-01 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (eme_pkcs_v1_5_encode): Use KEY_SIZE directly, no need to
+ call gcry_ac_key_get_nbits.
+ (eme_pkcs_v1_5_decode): Likewise.
+ (ac_es_dencode_prepare_pkcs_v1_5): Fill options_em structure with
+ key_size.
+ (_gcry_ac_data_dump, gcry_ac_data_dump): New functions.
+ (_gcry_ac_data_to_sexp, _gcry_ac_data_from_sexp): More or less
+ rewritten; changed S-Expression format so that it matches the one
+ used in pubkey.c.
+
+2006-03-15 Werner Koch <wk@g10code.com>
+
+ * random-daemon.c: New.
+ * random.c (_gcry_use_random_daemon): New.
+ (get_random_bytes, gcry_randomize, gcry_create_nonce): Try
+ diverting to the daemon functions.
+
+2006-03-14 Werner Koch <wk@g10code.com>
+
+ * random.c (lock_seed_file): New.
+ (read_seed_file, _gcry_update_random_seed_file): Use it.
+
+ * random.c (gcry_create_nonce): Detect a fork and re-seed.
+ (read_pool): Fixed the fork detection; it used to work only for
+ multi-threaded processes.
+
+2006-03-12 Brad Hards <bradh@frogmouth.net> (wk)
+
+ * md.c (md_open): Use new variable macpads_Bsize instead of
+ hardwiring the block size. Changed at all places.
+
+2006-03-10 Brad Hards <bradh@frogmouth.net> (wk, patch 2005-04-22)
+
+ * md.c, sha256.c: Add support for SHA-224.
+ (sha224_init): New.
+
+2006-01-18 Brad Hards <bradh@frogmouth.net> (wk 2006-03-07)
+
+ * cipher.c (cipher_encrypt, cipher_decrypt, do_ofb_encrypt)
+ (do_ofb_decrypt, gcry_cipher_open): Implement Output Feedback Mode.
+
+2005-11-02 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_algo_name): Return "?" instead of NULL for
+ unknown algorithm IDs.
+ * cipher.c (cipher_algo_to_string): Likewise.
+
+2005-11-01 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_algo_info): Don't forget to break after switch
+ case.
+
+2005-09-19 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate): Add preliminary support for 2 and 4 keys.
+ Return an error code if the key size is not supported.
+ (_gcry_dsa_generate): Return an error.
+
+2005-08-22 Werner Koch <wk@g10code.com>
+
+ * primegen.c (check_prime): New arg RM_ROUNDS.
+ (prime_generate_internal): Call it here with 5 rounds as used
+ before.
+ (gcry_prime_check): But here with 64 rounds.
+ (is_prime): Make sure never to use less than 5 rounds.
+
+2005-04-16 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_init): New function.
+
+2005-04-12 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_io_write, _gcry_ac_io_read): Initialize err to
+ make the compiler happy.
+ Always use errno, now that gcry_malloc() is guaranteed to set
+ errno on failure.
+ (_gcry_ac_data_to_sexp): Don't forget to goto out after error in
+ loop.
+ (_gcry_ac_data_to_sexp): Remove unused variable: mpi_list;
+ (_gcry_ac_data_to_sexp): Always deallocate sexp_buffer.
+ (_gcry_ac_data_from_sexp): Don't forget to initialize data_set_new.
+ (_gcry_ac_data_from_sexp): Handle special case, which is
+ necessary, since gcry_sexp_nth() does not distinguish between
+ "element does not exist" and "element is the empty list".
+ (_gcry_ac_io_init_va): Use assert to make sure that mode and type
+ are correct.
+ Use gcry_error_t types where gcry_err_code_t types have been used
+ before.
+
+2005-04-11 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_data_sign_scheme): Don't forget to initialize
+ buffer.
+
+ * whirlpool.c: New file.
+ * md.c (digest_table): Add whirlpool.
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Added: whirlpool.c.
+
+2005-03-30 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_data_from_sexp): Use length of SEXP_CUR, not
+ length of SEXP; do not forget to set SEXP_TMP to NULL after it has
+ been released.
+
+ (struct gcry_ac_mpi): New member: name_provided.
+ (_gcry_ac_data_set): Rename variable `name_final' to `name_cp';
+ remove const qualifier; change code to not cast away const
+ qualifiers; use name_provided member as well.
+ (_gcry_ac_data_set, _gcry_ac_data_get_name): Use name_provided
+ member of named mpi structure.
+
+ (gcry_ac_name_to_id): Do not forget to initialize err.
+ (_gcry_ac_data_get_index): Do not forget to initialize mpi_return;
+ use gcry_free() instead of free(); remove unnecessary cast; rename
+ mpi_return and name_return to mpi_cp and name_cp; adjust code.
+ (ac_data_mpi_copy): Do not cast away const qualifier.
+ (ac_data_values_destroy): Likewise.
+ (ac_data_construct): Likewise.
+
+ (ac_data_mpi_copy): Initialize flags to GCRY_AC_FLAG_DEALLOC.
+ (ac_data_extract): Use GCRY_AC_FLAG_DEALLOC instead of
+ GCRY_AC_FLAG_COPY.
+
+ (_gcry_ac_io_init_va, _gcry_ac_io_init, gcry_ac_io_init)
+ (gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read)
+ (_gcry_ac_io_read_all, _gcry_ac_io_process): New functions.
+ (gry_ac_em_dencode_t): Use gcry_ac_io_t in prototype instead of
+ memroy strings directly; adjust encode/decode functions to use io
+ objects.
+ (emsa_pkcs_v1_5_encode_data_cb): New function ...
+ (emsa_pkcs_v1_5_encode): ... use it here.
+ (ac_data_dencode): Use io objects.
+ (_gcry_ac_data_encode, _gcry_ac_data_decode, gcry_ac_data_encode)
+ (gcry_ac_data_decode): Likewise.
+ (_gcry_ac_data_encrypt_scheme, gcry_ac_data_encrypt_scheme)
+ (_gcry_ac_data_decrypt_scheme, gcry_ac_data_decrypt_scheme)
+ (_gcry_ac_data_sign_scheme, gcry_ac_data_sign_scheme)
+ (_gcry_ac_data_verify_scheme, gcry_ac_data_verify_scheme):
+ Likewise.
+
+2005-03-23 Werner Koch <wk@g10code.com>
+
+ * rndw32.c (_gcry_rndw32_gather_random_fast): While adding data
+ use the size of the object and not the one of its address. Bug
+ reported by Sascha Kiefer.
+
+2005-03-19 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (do_cbc_encrypt): Be careful to not overwrite data,
+ which is to be used later on. This happend, in case CTS is
+ enabled and OUTBUF is equal to INBUF.
+
+2005-02-25 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_get_keygrip): Allow for shadowed-private-key.
+
+2005-02-13 Moritz Schulte <moritz@g10code.com>
+
+ * serpent.c: Updated from 1.2 branch:
+
+ s/u32_t/u32/ and s/byte_t/byte/. Too match what we have always
+ used and are using in all other files too
+ (serpent_test): Moved prototype out of a fucntion.
+
+2005-02-07 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: Major parts rewritten.
+ * pubkey.c (_gcry_pk_get_elements): New function.
+
+2004-12-09 Werner Koch <wk@g10code.com>
+
+ * serpent.c (serpent_setkey): Moved prototype of serpent_test to
+ outer scope.
+
+2004-09-11 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (pubkey_table): Added an alias entry for GCRY_PK_ELG_E.
+
+2004-08-23 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: Do not include <assert.h>.
+ * rndegd.c: Likewise.
+ * sha1.c: Likewise.
+ * rndunix.c: Likewise.
+ * rndlinux.c: Likewise.
+ * rmd160.c: Likewise.
+ * md5.c: Likewise.
+ * md4.c: Likewise.
+ * cipher.c: Likewise.
+ * crc.c: Likewise.
+ * blowfish.c: Likewise.
+
+ * pubkey.c (dummy_generate, dummy_check_secret_key)
+ (dummy_encrypt, dummy_decrypt, dummy_sign, dummy_verify): Return
+ err code GPG_ERR_NOT_IMPLEMENTED instead of aborting through
+ log_bug().
+ (dummy_get_nbits): Return 0 instead of aborting though log_bug().
+
+2004-08-19 Werner Koch <wk@g10code.de>
+
+ * pubkey.c (sexp_data_to_mpi): Changed the zero random byte
+ substituting code to actually do clever things. Thanks to
+ Matthias Urlichs for noting the implementation problem.
+
+2004-08-09 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_sign): Fixed memory leak; fix provided by
+ Modestas Vainius.
+
+2004-07-16 Werner Koch <wk@gnupg.org>
+
+ * rijndael.c (do_encrypt): Fix alignment problem. Bugs found by
+ Matthias Urlichs.
+ (do_decrypt): Ditto.
+ (keySched, keySched2): Use 2 macros along with unions in the key
+ schedule context.
+
+2004-07-14 Moritz Schulte <moritz@g10code.com>
+
+ * rsa.c (_gcry_rsa_decrypt): Don't forget to free "a". Thanks to
+ Nikos Mavroyanopoulos.
+
+2004-05-09 Werner Koch <wk@gnupg.org>
+
+ * random.c (read_pool): Mix the PID in to better protect after a
+ fork.
+
+2004-07-04 Moritz Schulte <moritz@g10code.com>
+
+ * serpent.c: Use "u32_t" instead of "unsigned long", do not
+ declare S-Box variables as "register". Fixes failure on
+ OpenBSD/sparc64, reported by Nikolay Sturm.
+
+2004-05-07 Werner Koch <wk@gnupg.org>
+
+ * random.c (initialize): Factored out some code to ..
+ (initialize_basics): .. new function.
+ (_gcry_random_initialize): Just call initialize_basics unless the
+ new arg FULL is set to TRUE.
+ (_gcry_fast_random_poll): Don't do anything unless the random
+ system has been really initialized.
+
+2004-05-07 Moritz Schulte <moritz@g10code.de>
+
+ * ac.c (gcry_ac_open): Do not dereference NULL pointer. Reported
+ by Umberto Salsi.
+
+2004-02-20 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (check_prime): New args CB_FUNC and CB_ARG; call them
+ at different stages. Pass these arguments through all callers.
+
+2004-02-06 Werner Koch <wk@gnupg.org>
+
+ * des.c: Add a new OID as used by pkcs#12.
+
+ * rfc2268.c: New. Taken from libgcrypt.
+ * cipher.c: Setup the rfc2268 algorithm.
+
+2004-01-25 Moritz Schulte <mo@g10code.com>
+
+ * primegen.c (prime_generate_internal): Do not forget to free
+ `q_factor'; fixed by Brieuc Jeunhomme.
+ (prime_generate_internal): Do not forget to free `prime'.
+
+2004-01-14 Moritz Schulte <mo@g10code.com>
+
+ * ac.c (gcry_ac_data_set): New argument: flags; slightly
+ rewritten.
+ (gcry_ac_data_get_name, gcry_ac_data_get_index): Likewise.
+ (gcry_ac_key_pair_generate): New argument: misc_data; modified
+ order of arguments.
+ (gcry_ac_key_test): New argument: handle.
+ (gcry_ac_key_get_nbits, gcry_ac_key_get_grip): Likewise.
+ Use GCRY_AC_FLAG_NO_BLINDING instead of
+ GCRY_AC_DATA_FLAG_NO_BLINDING.
+ (gcry_ac_mpi): New member: flags.
+ (gcry_ac_data_search, gcry_ac_data_add): Removed functions.
+
+2003-12-22 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (is_prime): Release A2.
+
+2003-12-19 Werner Koch <wk@gnupg.org>
+
+ * md.c: Moved a couple of functions down below the data structure
+ definitions.
+ (struct gcry_md_context): New field ACTUAL_HANDLE_SIZE.
+ (md_open): Set it here.
+ (strcut gcry_md_list): New field ACTUAL_STRUCT_SIZE.
+ (md_enable): Set it here.
+ (md_close): Wipe the context memory.
+ secure memory.
+ * cipher.c (struct gcry_cipher_handle): New field ACTUAL_HANDLE_SIZE.
+ (gcry_cipher_open): Set it here.
+ (gcry_cipher_close): Use it to always wipe out the handle data.
+
+ * ac.c (gcry_ac_open): Make sure HANDLE gets initialized even when
+ the function is not successful.
+ (gcry_ac_close): Allow a NULL handle.
+ (gcry_ac_key_destroy, gcry_ac_key_pair_destroy): Ditto.
+ (gcry_ac_key_get_grip): Return INV_OBJ on error.
+
+ * primegen.c (prime_generate_internal): Fixed error code for
+ failed malloc. Replaced the !err if chain by gotos.
+ (gcry_prime_group_generator): Remove the extra sanity check.
+
+ * md.c: Minor code and comment cleanups.
+
+2003-12-16 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): Doc fix. Thanks to Newton Hammet.
+
+2003-12-11 Werner Koch <wk@gnupg.org>
+
+ * rndunix.c (slow_poll): Don't use #warning but #error.
+
+ * rndegd.c: Changed indentation.
+ (my_make_filename): Removd the var_arg cruft becuase we
+ don't need it here. Changed caller.
+
+ * rndlinux.c: Changed indentation.
+ (open_device): Remove the superfluous stat call and clarify
+ comment.
+
+ * rsa.c: Changed indentation.
+ (secret): Use the standard algorithm if p, q and u are not
+ available.
+ (rsa_blind, rsa_unblind): Renamed from _gcry_rsa_blind,
+ _gcry_rsa_unblind and moved more to the top.
+
+ * md4.c: Changed indentation. Removed unnecessary casts.
+ * md5.c, rmd160.c, sha1.c, tiger.c: Ditto.
+ * rijndael.c, twofish.c: Ditto.
+ * serpent.c: Removed unnecessary casts.
+ * sha256.c, sha512.c: Ditto.
+
+2003-12-09 Werner Koch <wk@gnupg.org>
+
+ * dsa.c: Unified indentation style.
+ * elgamal.c: Ditto.
+ * des.c (des_key_schedule): Code beautifications.
+ * blowfish.c: Changed indentation style.
+ * cast5.c (do_cast_setkey): Ditto.
+
+ * pubkey.c (gcry_pk_encrypt): Replaced the chain of if(!err) tests
+ by straightforward gotos. Other cleanups.
+ (gcry_pk_decrypt): Ditto.
+ (gcry_pk_sign): Ditto.
+ (gcry_pk_verify): Ditto.
+ (gcry_pk_genkey): Ditto. Use strtoul instead of strtol.
+ (gcry_pk_ctl): Use GPG_ERR_INV_ARG to indicate bad arguments.
+
+2003-12-07 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_register_default): Undef the helper macro.
+ (gcry_pk_map_name): Allow NULL for string.
+ (sexp_to_key): Use memcpy and not strncpy. Use gcry_free and not
+ free.
+ (sexp_to_sig): Ditto.
+ (sexp_to_enc): Ditto. Replaced the chain of if(!err) tests by
+ straightforward gotos.
+
+2003-12-05 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Documentation cleanups.
+ (gcry_cipher_mode_from_oid): Allow NULL for STRING.
+
+2003-12-03 Werner Koch <wk@gnupg.org>
+
+ * elgamal.c (sign, do_encrypt, gen_k): Make sure that a small K is
+ only used for encryption.
+
+2003-11-18 Werner Koch <wk@gnupg.org>
+
+ * random.h (rndw32_set_dll_name): Removed unused prototype.
+
+ * Makefile.am (EXTRA_DIST): Added Manifest.
+
+2003-11-11 Werner Koch <wk@gnupg.org>
+
+ * Manifest: New.
+
+2003-11-04 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Use shortcut for SHA1
+ * sha1.c (_gcry_sha1_hash_buffer): New.
+
+ * random.c: Reformatted most functions.
+ (mix_pool): Moved the failsafe_digest from global
+ scope to here.
+ (do_fast_random_poll): Use the generic fucntions even if a fast
+ gathering function has been used.
+ (read_pool): Detect a fork and retry.
+ (gcry_randomize, get_random_bytes): Don't distinguish anymore
+ between weak and strong random.
+ (gcry_create_nonce): New.
+
+2003-10-31 Werner Koch <wk@gnupg.org>
+
+ * rndw32.c (slow_gatherer_windowsNT): Use a plain buffer for the
+ disk performance values and not the W32 API structure.
+
+ * dsa.c (verify): s/exp/ex/ due to shadowing of a builtin.
+ * elgamal.c (verify): Ditto.
+
+ * ac.c (gcry_ac_data_get_index): s/index/idx/
+ (gcry_ac_data_copy_internal): Remove the cast in _gcry_malloc.
+ (gcry_ac_data_add): Must use gcry_realloc instead of realloc.
+ * pubkey.c (sexp_elements_extract): s/index/idx/ as tribute to the
+ forehackers.
+ (gcry_pk_encrypt): Removed shadowed definition of I. Reordered
+ arguments to malloc for clarity.
+ (gcry_pk_sign, gcry_pk_genkey): Ditto.
+ * primegen.c (prime_generate_internal): s/random/randomlevel/.
+
+2003-10-27 Moritz Schulte <mo@g10code.com>
+
+ * pubkey.c (gcry_pk_encrypt): Don't forget to deallocate pkey.
+
+2003-10-27 Werner Koch <wk@gnupg.org>
+
+ * random.c (gcry_random_add_bytes): Return if buflen is zero to
+ avoid gcc warning about unsed parameter.
+ (MASK_LEVEL): Simplified; does now work for signed and unsigned
+ w/o warnings.
+
+ * md.c (md_start_debug): Removed the const from SUFFIX, because
+ this function is called from the control fucntion which does not
+ require const.
+
+ Prefixed all (pubkey,digest,cipher}_spec_* globale variables with
+ _gcry_.
+
+ * ac.c (ac_key_identifiers): Made static.
+
+ * random.c (getfnc_gather_random,getfnc_fast_random_poll): Move
+ prototypes to ..
+ * rand-internal.h: .. here
+ * random.c (getfnc_gather_random): Include rndw32 gatherer.
+ * rndunix.c, rndw32.c, rndegd.c: Include them here.
+ * rndlinux.c (_gcry_rndlinux_gather_random): Prepend the _gcry_
+ prefix. Changed all callers.
+ * rndegd.c (_gcry_rndegd_gather_random): Likewise.
+ (_gcry_rndegd_connect_socket): Likewise.
+ * rndunix.c (_gcry_rndunix_gather_random): Likewise.
+ (waitpid): Made static.
+ * rndw32.c: Removed the old and unused winseed.dll cruft.
+ (_gcry_rndw32_gather_random_fast): Renamed from
+ gather_random_fast.
+ (_gcry_rndw32_gather_random): Renamed from gather_random. Note,
+ that the changes 2003-04-08 somehow got lost.
+
+ * sha512.c (sha512_init, sha384_init): Made static.
+
+ * cipher.c (do_ctr_decrypt): Removed "return" from this void
+ function.
+
+2003-10-24 Moritz Schulte <mo@g10code.com>
+
+ * serpent.c: Fix an issue on big-endian systems.
+
+ * rndw32.c: Removed IS_MODULE -cruft.
+ * rndlinux.c (rndlinux_gather_random): Likewise.
+
+2003-10-10 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): Bail out if NBITS is less than 16.
+ (prime_generate_internal): Initialize prime variable to suppress
+ compiler warning. Check pbits, initialize qbits when passed as
+ zero.
+
+ * primegen.c (prime_generate_internal): New arg
+ ALL_FACTORS. Changed all callers.
+ (gcry_prime_generate): Make the factors arg optional. Request
+ all_factors. Make sure PRIME is set to NULL even on error.
+ (gcry_prime_group_generator): New.
+ (gcry_prime_release_factors): New.
+
+2003-10-06 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): Assert that NBITS is never zero, it
+ would cause a segv.
+
+2003-09-28 Moritz Schulte <mo@g10code.com>
+
+ * ac.c: Include "cipher.h".
+
+2003-09-27 Moritz Schulte <mo@g10code.com>
+
+ * rndegd.c (do_read): Return nread instead of nbytes; thanks to
+ Michael Caerwyn.
+
+2003-09-04 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (_gcry_pk_aliased_algo_name): New.
+ * ac.c (gcry_ac_open): Use it here.
+
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Add serpent.c
+
+2003-09-02 Moritz Schulte <mo@g10code.com>
+
+ * primegen.c (gcry_prime_check, gcry_prime_generate): New
+ functions.
+ (prime_generate_internal): New function, based on
+ _gcry_generate_elg_prime.
+ (_gcry_generate_elg_prime): Rewritten as a wrapper for
+ prime_generate_internal.
+
+2003-08-28 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_encrypt): Don't include the flags list in the
+ return value. This does not make sense and breaks any programs
+ parsing the output strictly (e.g. current gpgsm).
+ (gcry_pk_encrypt): If aliases for the algorithm name exists, take
+ the first one instead of the regular name to adhere to SPKI
+ conventions.
+ (gcry_pk_genkey): Ditto.
+ (gcry_pk_sign): Ditto. Removed unused KEY_ALGO_NAME.
+
+2003-08-19 Moritz Schulte <mo@g10code.com>
+
+ * cipher.c: Add support for Serpent
+ * serpent.c: New file.
+
+2003-08-10 Moritz Schulte <moritz@g10code.com>
+
+ * rsa.c (_gcry_rsa_blind, _gcry_rsa_unblind): Declare static.
+
+2003-08-09 Timo Schulz <twoaday@freakmail.de>
+
+ * random.c (getfnc_gather_random): Don't check NAME_OF_DEV_RANDOM
+ two times, but also the NAME_OF_DEV_URANDOM device.
+
+2003-08-08 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_to_enc): Fixed extraction of S-Expression: do not
+ fail if no `flags' sub S-Expression is found.
+
+2003-07-27 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_lookup_func_oid): Allow for empty OID lists.
+
+2003-07-23 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (gcry_ac_data_construct): New argument: include_flags, only
+ include `flags' S-expression, if include_flags is true. Adjust
+ callers. Thanks for triggering a bug caused by `flags'
+ sub-S-expression where they are not expected to Ralf Schneider.
+
+2003-07-21 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_lookup_func_name): Use new member name
+ `aliases' instead of `sexp_names'.
+
+ * ac.c (gcry_ac_key_data_get): New function.
+
+ * cipher.c (gcry_cipher_lookup_func_name): Fix return value.
+
+2003-07-20 Moritz Schulte <moritz@g10code.com>
+
+ * blowfish.c: Adjusted for new gcry_cipher_spec_t structure.
+ * cast5.c: Likewise.
+ * twofish.c: Likewise.
+ * arcfour.c: Likewise.
+ * rijndael.c (rijndael_oids, rijndael192_oids, rijndael256_oids):
+ New variables, adjust for new gcry_cipher_spec_t structure.
+ * des.c (oids_tripledes): New variable, adjust for new
+ gcry_cipher_spec_t structure.
+
+ * md.c (oid_table): Removed.
+
+ * tiger.c (oid_spec_tiger): New variable.
+ (digest_spec_tiger): Adjusted for new gry_md_spec_t structure.
+
+ * sha512.c (oid_spec_sha512): New variable.
+ (digest_spec_sha512): Adjusted for new gry_md_spec_t structure.
+
+ * sha512.c (oid_spec_sha384): New variable.
+ (digest_spec_sha384): Adjusted for new gry_md_spec_t structure.
+
+ * sha256.c (oid_spec_sha256): New variable.
+ (digest_spec_sha256): Adjusted for new gry_md_spec_t structure.
+
+ * sha1.c (oid_spec_sha1): New variable.
+ (digest_spec_sha1): Adjusted for new gry_md_spec_t structure.
+
+ * rmd160.c (oid_spec_rmd160): New variable.
+ (digest_spec_rnd160): Adjusted for new gry_md_spec_t structure.
+
+ * md5.c (oid_spec_md5): New variable.
+ (digest_spec_md5): Adjusted for new gry_md_spec_t structure.
+
+ * md4.c (oid_spec_md4): New variable.
+ (digest_spec_md4): Adjusted for new gry_md_spec_t structure.
+
+ * crc.c (digest_spec_crc32, digest_spec_crc32_rfc1510,
+ digest_spec_crc32_rfc2440): Adjusted for new gry_md_spec_t
+ structure.
+
+2003-07-19 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (gcry_md_lookup_func_oid): New function.
+ (search_oid): New function, copied from cipher.c.
+ (gcry_md_map_name): Adjust for new search_oid_interface.
+
+ * cipher.c (oid_table): Removed table.
+ (gcry_cipher_lookup_func_oid): New function.
+ (search_oid): Rewritten to use the module functions.
+ (gcry_cipher_map_name): Adjust for new search_oid interface.
+ (gcry_cipher_mode_from_oid): Likewise.
+
+2003-07-18 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Convert ERR to gpg_error_t in
+ gpg_strerror.
+
+2003-07-14 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (gcry_cipher_lookup_func_name): Also check the cipher
+ name aliases, not just the primary name.
+ (gcry_cipher_map_name): Remove kludge for aliasing Rijndael to
+ AES.
+
+ * arcfour.c, blowfish.c, cast5.c, des.c, twofish.c: Adjust cipher
+ specification structures.
+
+ * rijndael.c (rijndael_names, rijndael192_names,
+ rijndael256_names): New variables, use them in the cipher
+ specifications.
+
+ * rmd160test.c: Removed file.
+
+ * ac.c, arcfour.c, blowfish.c, cast5.c, cipher.c, des.c, dsa.c,
+ elgamal.c, md.c, pubkey.c, random.c, rijndael.c, rsa.c, twofish.c:
+ Used gcry_err* wrappers for libgpg symbols.
+
+ * primegen.c (gen_prime): Correct the order arguments to
+ extra_check.
+
+2003-07-12 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: Replaced all public occurences of gpg_error_t with
+ gcry_error_t.
+ * cipher.c: Likewise.
+ * md.c: Likewise.
+ * pubkey.c: Likewise.
+ * random.c: Likewise.
+
+ * cipher.c: Added support for TWOFISH128.
+
+2003-07-08 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (gcry_ac_data_copy_internal): New function, based on
+ gcry_ac_data_copy.
+ (gcry_ac_data_copy): Made public, use gcry_ac_data_copy_internal.
+ (gcry_ac_key_init): Use gcry_ac_data_copy_internal.
+
+2003-07-07 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (gcry_ac_data_set): Only release old MPI value if it is
+ different from the new value. Bug reported by Simon Josefsson
+ <jas@extundo.com>.
+
+ * pubkey.c (gcry_pk_list): New function.
+ * md.c (gcry_md_list): New function.
+
+ * ac.c (gcry_ac_key_pair_generate): Fix calculation of format
+ string size.
+
+2003-07-05 Moritz Schulte <moritz@g10code.com>
+
+ * md.c: Named struct of digest_table `digest_table_entry'.
+ (digest_table_entry): New member: algorithm; filled in.
+ (digest_table_entry): Removed unused member: flags.
+ (gcry_md_register): New argument: algorithm_id, filled in.
+ (gcry_md_register_default): Used algorithm ID from module
+ structure.
+ (gcry_md_map_name): Likewise.
+ (md_enable): Likewise.
+ (md_read): Likewise.
+ (gcry_md_info): Likewise.
+
+ * pubkey.c: Named truct for pubkey_table `pubkey_table_entry'.
+ (pubkey_table_entry): New member: algorithm; filled in.
+ (gcry_pk_register_default): Used algorithm ID from pubkey_table.
+ (gcry_pk_register): New argument: algorithm_id, filled in.
+ (gcry_pk_map_name): Used algorithm ID from module structure.
+ (gcry_pk_decrypt): Likewise.
+ (gcry_pk_encrypt): Likewise.
+ (gcry_pk_verify): Likewise.
+ (gcry_pk_sign): Likewise.
+ (gcry_pk_testkey): Likewise.
+ (gcry_pk_genkey): Likewise.
+ (gcry_pk_get_nbits): Likewise.
+ (sexp_to_key): Removed unused variable: algo.
+ (sexp_to_sig): Likewise.
+
+ * cipher.c: Named struct for cipher_table `cipher_table_entry'.
+ (cipher_table_entry): New member: algorithm; filled in.
+ (gcry_cipher_register_default): Used algorithm ID from
+ cipher_table.
+ (gcry_cipher_register): New argument: algorithm_id, filled in.
+ (gcry_cipher_map_name): Used algorithm ID from module structure.
+
+ * arcfour.c (cipher_spec_arcfour): Removed algorithm ID.
+ * blowfish.c (cipher_spec_blowfish): Likewise.
+ * cast5.c (cipher_spec_cast5): Likewise.
+ * crc.c (digest_spec_crc32): Likewise.
+ * crc.c (digest_spec_crc32_rfc1510): Likewise.
+ * crc.c (digest_spec_crc32_rfc2440): Likewise.
+ * des.c (cipher_spec_des): Likewise.
+ * des.c (cipher_spec_tripledes): Likewise.
+ * dsa.c (pubkey_spec_dsa): Likewise.
+ * elgamal.c (pubkey_spec_elg): Likewise.
+ * md4.c (digest_spec_md4): Likewise.
+ * md5.c (digest_spec_md5): Likewise.
+ * aes.c (cipher_spec_aes): Likewise.
+ * aes.c (cipher_spec_aes192): Likewise.
+ * aes.c (cipher_spec_aes256): Likewise.
+ * rsa.c (pubkey_spec_rsa): Likewise.
+ * sha1.c (digest_spec_sha1): Likewise.
+ * sha256.c (digest_spec_sha256): Likewise.
+ * sha512.c (digest_spec_sha512): Likewise.
+ * tiger.c (digest_spec_tiger): Likewise.
+ * twofish.c (cipher_spec_twofish): Likewise.
+ * twofish.c (cipher_spec_twofish128): Likewise.
+
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Fix list of source
+ files; reported by Simon Josefsson <jas@extundo.com>.
+
+ * pubkey.c: Replaced all occurences of `id' with `algorithm',
+ since `id' is a keyword in obj-c.
+ * md.c: Likewise.
+ * cipher.c: Likewise.
+
+ * crc.c, md4.c, md5.c, rmd160.c, sha1.c, sha256.c, tiger.c:
+ Replaced all occurences of gcry_digest_spec_t with gcry_md_spec_t.
+
+ * dsa.c, rsa.c, elgamal.c: Replaced all occurencens of
+ gcry_pubkey_spec_t with gcry_pk_spec_t.
+
+ * md.c: Replaced all occurences of gcry_digest_spec_t with
+ gcry_md_spec_t.
+ (gcry_digest_register_default): Renamed to ...
+ (gcry_md_register_default): ... this; adjusted callers.
+ (gcry_digest_lookup_func_name): Renamed to ...
+ (gcry_md_lookup_func_name): ... this; adjusted callers.
+ (gcry_digest_lookup_name): Renamed to ...
+ (gcry_md_lookup_name): ... this; adjusted callers.
+ (gcry_digest_register): Renamed to ...
+ (gcry_md_register): ... this.
+ (gcry_digest_unregister): Renamed to ...
+ (gcry_md_unregister): ... this.
+
+ * pubkey.c (gcry_pubkey_register): Renamed to ...
+ (gcry_pk_register): ... this.
+ (gcry_pubkey_unregister): Renamed to ...
+ (gcry_pk_unregister): ... this.
+ Replaced all occurences of gcry_pubkey_spec_t with gcry_pk_spec_t.
+ (gcry_pubkey_register_default): Renamed to ...
+ (gcry_pk_register_default): ... this; adjusted callers.
+ (gcry_pubkey_lookup_func_name): Renamed to ...
+ (gcry_pk_lookup_func_name): ... this; adjusted callers.
+ (gcry_pubkey_lookup_name): Renamed to ...
+ (gcry_pk_lookup_name): ... this; adjusted callers.
+
+ * md.c (gcry_md_hash_buffer): Fix error checking. Thanks to Simon
+ Josefsson <jas@extunde.com>.
+
+2003-07-04 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (gcry_cipher_list): New function.
+
+2003-07-01 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_to_sig): Accept a `flags' S-expression to be more
+ consistent with sexp_to_enc.
+
+2003-06-30 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (libcipher_la_SOURCES): Added: ac.c.
+
+ * pubkey.c (_gcry_pk_module_lookup): New function.
+ (_gcry_pk_module_release): New function.
+
+2003-06-29 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: New file.
+
+2003-06-26 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Trigger BUG correcly with new API.
+
+2003-06-19 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_is_enabled): Fixed.
+
+2003-06-18 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_get_algo_keylen): New.
+ (gcry_cipher_get_algo_blklen): New.
+
+2003-06-18 Moritz Schulte <moritz@g10code.com>
+
+ * arcfour.c, cipher.c, blowfish.c, md.c, cast5.c, pubkey.c, crc.c,
+ des.c, dsa.c, elgamal.c, md4.c, md5.c, random.c, rijndael.c,
+ rmd160.c, rsa.c, sha1.c, sha256.c, sha512.c, tiger.c, twofish.c:
+ Replaced older types GcryDigestSpec, GcryCipherSpec and
+ GcryPubkeySpec with newer types: gcry_digest_spec_t,
+ gcry_cipher_spec_t and gcry_pubkey_spec_t.
+
+ * md.c (gcry_digest_id_new): Removed function.
+ (gcry_digest_register): Removed code for generating a new module
+ ID.
+
+ * pubkey.c (gcry_pubkey_id_new): Removed function.
+ (gcry_pubkey_register): Removed code for generating a new module
+ ID.
+
+ * cipher.c, md.c, pubkey.c: Replace old type GcryModule with newer
+ one: gcry_module_t.
+ (gcry_cipher_id_new): Removed function.
+ (gcry_cipher_register): Removed code for generating a new module
+ ID.
+
+ * cipher.c (gcry_cipher_register): Adjust call to
+ _gcry_module_add.
+ (gcry_cipher_register_default): Likewise.
+ * pubkey.c (gcry_pubkey_register_default): Likewise.
+ (gcry_pubkey_register): Likewise.
+ * md.c (gcry_digest_register_default): Likewise.
+ (gcry_digest_register): Likewise.
+
+ * md.c (gcry_digest_lookup_func_id): Removed function.
+ (gcry_digest_lookup_id): Likewise.
+ (gcry_digest_id_new): Use _gcry_module_lookup_id instead of
+ gcry_digest_lookup_id.
+ (digest_algo_to_string): Likewise.
+ (check_digest_algo): Likewise.
+ (md_enable): Likewise.
+ (md_digest_length): Likewise.
+ (md_asn_oid): Likewise.
+
+ * pubkey.c (gcry_pubkey_lookup_id): Removed function.
+ (gcry_pubkey_lookup_func_id): Likewise.
+ (gcry_pubkey_id_new): Use _gcry_module_lookup_id instead of
+ gcry_pubkey_id_new.
+ (gcry_pk_algo_name): Likewise.
+ (disable_pubkey_algo): Likewise.
+ (check_pubkey_algo): Likewise.
+ (pubkey_get_npkey): Likewise.
+ (pubkey_get_nskey): Likewise.
+ (pubkey_get_nsig): Likewise.
+ (pubkey_get_nenc): Likewise.
+ (pubkey_generate): Likewise.
+ (pubkey_check_secret_key): Likewise.
+ (pubkey_encrypt): Likewise.
+ (pubkey_decrypt): Likewise.
+ (pubkey_sign): Likewise.
+ (pubkey_verify): Likewise.
+ (gcry_pk_algo_info): Likewise.
+
+ * cipher.c (gcry_cipher_lookup_func_id): Removed function.
+ (gcry_cipher_lookup_id): Likewise.
+ (cipher_algo_to_string): use _gcry_module_lookup_id instead of
+ gcry_cipher_lookup_id.
+ (disable_cipher_algo): Likewise.
+ (check_cipher_algo): Likewise.
+ (cipher_get_blocksize): Likewise.
+ (gcry_cipher_open): Likewise.
+ (gcry_cipher_id_new): Likewise.
+
+2003-06-17 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (GCRYPT_MODULES): Set to @GCRYPT_CIPHERS@,
+ @GCRYPT_PUBKEY_CIPHERS@, @GCRYPT_DIGESTS@ and @GCRYPT_RANDOM@.
+ (libcipher_la_DEPENDENCIES): Set to $(GCRYPT_MODULES).
+ (libcipher_la_LIBADD): Likewise.
+ (AM_CFLAGS): Added: @GPG_ERROR_CFLAGS@.
+ (EXTRA_libcipher_la_SOURCES): Added all conditional sources.
+
+ * md.c (md_open): Use _gcry_fast_random_poll instead of
+ fast_random_poll.
+ * cipher.c (gcry_cipher_open): Likewise.
+
+ * random.h (fast_random_poll): Removed macro.
+
+ * blowfish.c, md4.c, md5.c, rmd160.c, sha1.c, sha256.c, sha512.c,
+ tiger.c: Use Autoconf's WORDS_BIGENDIAN instead of our own
+ BIG_ENDIAN_HOST.
+
+2003-06-16 Moritz Schulte <moritz@g10code.com>
+
+ * random.c (getfnc_gather_random): Do not special-case
+ USE_ALL_RANDOM_MODULES, make it the default.
+
+ * dsa.c: Replace last occurences of old type names with newer
+ names (i.e. replace MPI with gcry_mpi_t).
+ * elgamal.c: Likewise.
+ * primegen.c: Likewise.
+ * pubkey.c: Likewise.
+ * rsa.c: Likewise.
+
+2003-06-14 Moritz Schulte <moritz@g10code.com>
+
+ * des.c (des_setkey): Add selftest check.
+ (tripledes_set3keys): Likewise.
+ (do_tripledes_setkey): Remove selftest check.
+ (do_des_setkey): Likewise.
+
+2003-06-11 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (_gcry_md_init): New function.
+ * cipher.c (_gcry_cipher_init): New function.
+ * pubkey.c (_gcry_pk_init): New function.
+
+2003-06-13 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_get_algo): Reverted to old API. This is a
+ convenience function anyway and error checking is not approriate.
+ (gcry_md_is_secure): New.
+ (gcry_md_is_enabled): New.
+
+2003-06-12 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_open): Make sure HANDLE is set to NULL on
+ error.
+
+2003-06-11 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_open): Make sure H receives either NULL or an
+ valid handle.
+ (gcry_md_copy): Swapped arguments so that it is more in lione with
+ md_open and most other API fucntions like memcpy (destination
+ comes first). Make sure HANDLE is set to NULL on error.
+
+ * rijndael.c (do_encrypt): Hack to force correct alignment. It
+ seems not to be not sufficient, though. We should rework this
+ fucntions and remove all these ugly casts. Let the compiler
+ optimize or have an assembler implementation.
+
+2003-06-09 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am: Removed rules serpent, since that is not commited
+ yet.
+
+2003-06-08 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_encrypt): Improve calculation for size of the
+ format string.
+
+2003-06-07 Moritz Schulte <moritz@g10code.com>
+
+ * arcfour.c, bithelp.h, blowfish.c, cast5.c, cipher.c, crc.c,
+ des.c, dsa.c, elgamal.c, md4.c, md5.c, md.c, primegen.c, pubkey.c,
+ rand-internal.h, random.c, random.h, rijndael.c, rmd160.c,
+ rmd160test.c, rmd.h, rndeged.c, rndlinux.c, rndunix.c, rndw32.c,
+ rsa.c, sha1.c, sha256.c, sha512.c, tiger.c, twofish.c: Edited all
+ preprocessor instructions to remove whitespace before the '#'.
+ This is not required by C89, but there are some compilers out
+ there that don't like it. Replaced any occurence of the now
+ deprecated type names with the new ones.
+
+2003-06-04 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_encrypt): Construct an arg_list and use
+ gcry_sexp_build_array instead of gcry_sexp_build.
+ (gcry_pk_sign): Likewise.
+ (gcry_pk_genkey): Likewise.
+
+2003-06-01 Moritz Schulte <moritz@g10code.com>
+
+ * dsa.c (_gcry_dsa_generate): Do not check wether the algorithm ID
+ does indeed belong to DSA.
+ (_gcry_dsa_sign): Likewise.
+ (_gcry_dsa_verify): Likewise.
+ (_gcry_dsa_get_nbits): Likewise.
+
+ * elgamal.c (_gcry_elg_check_secret_key): Do not check wether the
+ algorithm ID does indeed belong to ElGamal.
+ (_gcry_elg_encrypt): Likewise.
+ (_gcry_elg_decrypt): Likewise.
+ (_gcry_elg_sign): Likewise.
+ (_gcry_elg_verify): Likewise.
+ (_gcry_elg_get_nbits): Likewise.
+ (_gcry_elg_generate): Likewise.
+
+ * rsa.c (_gcry_rsa_generate): Do not check wether the algorithm ID
+ does indeed belong to RSA.
+ (_gcry_rsa_encrypt): Likewise.
+ (_gcry_rsa_decrypt): Likewise.
+ (_gcry_rsa_sign): Likewise.
+ (_gcry_rsa_verify): Likewise.
+ (_gcry_rsa_get_nbits): Likewise.
+
+2003-05-30 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (md_get_algo): Return zero in case to algorithm is enabled.
+
+ * md.c (gcry_md_info): Adjusted for new no-errno-API.
+ (md_final): Likewise.
+ (gcry_md_get_algo): Likewise.
+ * pubkey.c (gcry_pk_get_keygrip): Likewise.
+ (gcry_pk_ctl): Likewise.
+ (gcry_pk_algo_info): Likewise.
+ * des.c (selftest): Likewise.
+
+2003-05-29 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (md_enable): Do not forget to release module on error.
+ (gcry_md_open): Adjusted for new no-errno-API.
+ (md_open): Likewise.
+ (md_copy): Likewise.
+ (gcry_md_copy): Likewise.
+ (gcry_md_setkey): Likewise.
+ (gcry_md_algo_info): Likewise.
+
+ * cipher.c (gcry_cipher_open): Adjusted for new no-errno-API and
+ also fixed a locking bug.
+ (gcry_cipher_encrypt): Adjusted for new no-errno-API.
+ (gcry_cipher_decrypt): Likewise.
+ (gcry_cipher_ctl): Likewise.
+ (gcry_cipher_info): Likewise.
+ (gcry_cipher_algo_info): Likewise.
+
+2003-05-28 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (md_enable): Adjusted for libgpg-error.
+ (gcry_md_enable): Likewise.
+ (gcry_digest_register_default): Likewise.
+ (gcry_digest_register): Likewise.
+ (check_digest_algo): Likewise.
+ (prepare_macpads): Likewise.
+ (gcry_md_setkey): Likewise.
+ (gcry_md_ctl): Likewise.
+ (gcry_md_get): Likewise.
+ (gcry_md_algo_info): Likewise.
+ (gcry_md_info): Likewise.
+ * dsa.c (_gcry_dsa_generate): Likewise.
+ (_gcry_dsa_check_secret_key): Likewise.
+ (_gcry_dsa_sign): Likewie.
+ (_gcry_dsa_verify): Likewise.
+ * twofish.c (do_twofish_setkey): Likewise.
+ (twofish_setkey): Likewise.
+ * cipher.c (gcry_cipher_register): Likewise.
+
+2003-05-25 Moritz Schulte <moritz@g10code.com>
+
+ * rijndael.c (do_setkey): Adjusted for libgpg-error.
+ (rijndael_setkey): Likewise.
+ * random.c (gcry_random_add_bytes): Likewise.
+ * elgamal.c (_gcry_elg_generate): Likewise.
+ (_gcry_elg_check_secret_key): Likewise.
+ (_gcry_elg_encrypt): Likewise.
+ (_gcry_elg_decrypt): Likewise.
+ (_gcry_elg_sign): Likewise.
+ (_gcry_elg_verify): Likewise.
+ * rsa.c (_gcry_rsa_generate): Likewise.
+ (_gcry_rsa_check_secret_key): Likewise.
+ (_gcry_rsa_encrypt): Likewise.
+ (_gcry_rsa_decrypt): Likewise.
+ (_gcry_rsa_sign): Likewise.
+ (_gcry_rsa_verify): Likewise.
+ * pubkey.c (dummy_generate, dummy_check_secret_key, dummy_encrypt,
+ dummy_decrypt, dummy_sign, dummy_verify): Likewise.
+ (gcry_pubkey_register): Likewise.
+ (check_pubkey_algo): Likewise.
+ (pubkey_generate): Likewise.
+ (pubkey_check_secret_key): Likewise.
+ (pubkey_encrypt): Likewise.
+ (pubkey_decrypt): Likewise.
+ (pubkey_sign): Likewise.
+ (pubkey_verify): Likewise.
+ (sexp_elements_extract): Likewise.
+ (sexp_to_key): Likewise.
+ (sexp_to_sig): Likewise.
+ (sexp_to_enc): Likewise.
+ (sexp_data_to_mpi): Likewise.
+ (gcry_pk_encrypt): Likewise.
+ (gcry_pk_decrypt): Likewise.
+ (gcry_pk_sign): Likewise.
+ (gcry_pk_verify): Likewise.
+ (gcry_pk_testkey): Likewise.
+ (gcry_pk_genkey): Likewise.
+ (gcry_pk_ctl): Likewise.
+ * cipher.c (dummy_setkey): Likewise.
+ (check_cipher_algo): Likewise.
+ (gcry_cipher_open): Likewise.
+ (cipher_setkey): Likewise.
+ (gcry_cipher_ctl): Likewise.
+ (cipher_encrypt): Likewise.
+ (gcry_cipher_encrypt): Likewise.
+ (cipher_decrypt): Likewise.
+ (gcry_cipher_decrypt): Likewise.
+ (gcry_cipher_info): Likewise.
+ (gcry_cipher_algo_info): Likewise.
+ * cast5.c (cast_setkey): Likewise.
+ (do_cast_setkey): Likewise.
+ * arcfour.c (arcfour_setkey): Likewise.
+ (do_arcfour_setkey): Likewise.
+ * blowfish.c (do_bf_setkey): Likewise.
+ (bf_setkey): Likewise.
+ * des.c (do_des_setkey): Likewise.
+ (do_tripledes_setkey): Likewise.
+
+2003-05-22 Moritz Schulte <moritz@g10code.com>
+
+ * tiger.c: Merged code ussing the U64_C macro from GnuPG.
+
+ * sha512.c: Likewise.
+
+2003-05-17 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Fix type: acquire a lock, instead of
+ releasing it.
+
+2003-05-11 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_testkey): Call REGISTER_DEFAULT_CIPHERS.
+ (gcry_pk_ctl): Likewise.
+
+2003-04-27 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Release sexp after extracted data has
+ been used.
+
+ * md.c (gcry_md_get_algo_dlen): Simplified, simply call
+ md_digest_length to do the job.
+
+ * des.c (do_des_setkey): Check for selftest failure not only
+ during initialization.
+ (do_tripledes_setkey): Include check for selftest failure.
+
+ * pubkey.c (gcry_pubkey_register_default): New macro
+ `pubkey_use_dummy', use it.
+
+ * elgamal.c (elg_names): New variable.
+ (pubkey_spec_elg): Include elg_names.
+
+ * dsa.c (dsa_names): New variable.
+ (pubkey_spec_dsa): Include dsa_names.
+
+ * rsa.c (rsa_names): New variable.
+ (pubkey_spec_rsa): Include rsa_names.
+
+ * pubkey.c (gcry_pubkey_lookup_func_name): Compare name also with
+ the names listed in `sexp_names'.
+
+2003-04-24 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_to_key): New variables: module, pubkey. Adjusted
+ to new module interface.
+ (sexp_to_key): Changend type of argument `retalgo' from `int *' to
+ `GcryModule **'. Adjusted all callers. Removed argument:
+ r_algotblidx.
+ (sexp_to_sig): Changend type of argument `retalgo' from `int *' to
+ `GcryModule **'. Adjusted all callers.
+ (sexp_to_enc): Likewise.
+
+ (pubkey_get_npkey, pubkey_get_nskey, pubkey_get_nsig,
+ pubkey_get_nenc): Use strlen to find out the number.
+
+ * rsa.c: Adjust pubkey_spec_rsa to new internal interface.
+ * dsa.c: Likewise.
+ * elgamal.c: Likewise.
+
+2003-04-17 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_elements_extract): New function.
+ * pubkey.c (sexp_to_key): Removed variable `idx', added `err', use
+ sexp_elements_extract.
+ (sexp_to_sig): Likewise.
+ (sexp_to_enc): Likewise.
+
+ * pubkey.c: Terminate list correctly.
+ * md.c: Include sha512/sha384 in digest_table.
+
+2003-04-16 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am: Include support for sha512.c.
+
+ * sha512.c: New file, merged from GnuPG, with few modifications
+ for libgcrypt.
+
+ * rand-internal.h: Removed declarations for constructor functions.
+
+ * md.c (md_copy): Call _gcry_module_use for incrementing the usage
+ counter of the digest modules.
+
+ * rsa.c: Do not include "rsa.h".
+ * dsa.c: Do not include "dsa.h".
+ * elgamal.c: Do not include "elgamal.h".
+ * des.c: Do not include "des.h".
+ * cast5.c: Do not include "cast5.h".
+ * blowfish.c: Do not include "blowfish.h".
+ * arcfour.c: Do not include "arcfour.h".
+
+ * Makefile.am (libcipher_la_DEPENDENCIES): Removed.
+ (libcipher_la_LIBADD): Removed.
+ Use Automake conditionals for conditional compilation.
+
+2003-04-13 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Call REGISTER_DEFAULT_CIPHERS.
+
+ * md.c (gcry_md_list): New member: module.
+ (md_enable): New variable: module, changed use of module and
+ digest.
+ (md_enable): Initialize member: module.
+ (md_close): Call _gcry_module_release.
+
+ * cipher.c (gcry_cipher_open): New variable: module, changed use of
+ module and cipher.
+ (struct gcry_cipher_handle): New member: module.
+ (gcry_cipher_open): Initialize member: module.
+ (gcry_cipher_close): Call _gcry_module_release.
+
+2003-04-09 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c: Include "ath.h".
+ * md.c: Likewise.
+ * pubkey.c: Likewise.
+
+ * cipher.c (ciphers_registered_lock): New variable.
+ * md.c (digests_registered_lock): New variable.
+ * pubkey.c (pubkeys_registered_lock): New variable.
+
+ * rndlinux.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndlinux_constructor): Removed function.
+
+ * rndegd.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndegd_constructor): Removed function.
+
+ * rndunix.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndunix_constructor): Removed function.
+
+ * rndw32.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndw32_constructor): Removed function.
+
+ * rndegd.c (rndegd_connect_socket): Simplify code for creating the
+ egd socket address.
+ (rndegd_connect_socket): Call log_fatal use instead of
+ g10_log_fatal.
+ (egd_gather_random): Renamed to ...
+ (rndegd_gather_random): ... here.
+
+2003-04-08 Moritz Schulte <moritz@g10code.com>
+
+ * rndlinux.c: Do not include "dynload.h".
+ * rndunix.c: Likewise.
+ * rndw32.c: Likewise.
+
+ * rndegd.c (rndegd_connect_socket): Factored out from ...
+ (egd_gather_random): here; call it.
+ (egd_socket): New variable.
+ (egd_gather_random): Initialize fd with egd_socket, do not declare
+ fd static.
+ (do_read): Merged few changes from GnuPG. FIXME - not finished?
+ Do not include "dynload.h".
+
+ * rndw32.c (gather_random): Renamed to rndw32_gather_random, do
+ not declare static.
+ (gather_random_fast): Renamed to rndw32_gather_random_fast, do not
+ declare static.
+
+ * rndunix.c (gather_random): Renamed to rndunix_gather_random, do
+ not declare static.
+ * rndegd.c (gather_random): Renamed to rndegd_gather_random, do
+ not declare static.
+ * rndlinux.c (gather_random): Renamed to rndlinux_gather_random,
+ do not declare static.
+
+2003-04-07 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (libcipher_la_SOURCES): Removed construct.c.
+ (libcipher_la_SOURCES): Added sha1.c, sha256.c, rmd160.c, md4.c,
+ md5.c, tiger.c and crc.c
+ (EXTRA_PROGRAMS): Removed sha1, sha256, rmd160, md4, md5, tiger
+ and crc. Removed definitions: EXTRA_md4_SOURCES,
+ EXTRA_md5_SOURCES, EXTRA_rmd160_SOURCES, EXTRA_sha1_SOURCES,
+ EXTRA_sha256_SOURCES, EXTRA_tiger_SOURCES and EXTRA_crc_SOURCES,
+ BUILT_SOURCES, DISTCLEANFILES.
+
+ * pubkey.c: Do not include "elgamal.h", "dsa.h" and "rsa.h".
+
+ * Makefile.am (libcipher_la_SOURCES): Removed rsa.h, elgamal.h,
+ dsa.h, des.h, cast5.h, arcfour.h and blowfish.h.
+
+ * rsa.h: Removed file.
+ * elgamal.h: Removed file.
+ * dsa.h: Removed file.
+ * des.h: Removed file.
+ * cast5.h: Removed file.
+ * arcfour.h: Removed file.
+ * blowfish.h: Removed file.
+
+ * Makefile.am (libcipher_la_SOURCES): Removed dynload.c and
+ dynload.h.
+
+ * rsa.c (pubkey_spec_rsa): New variable.
+ * dsa.c (pubkey_spec_rsa): New variable.
+ * elgamal.c (pubkey_spec_elg): New variable.
+
+ * rsa.c (_gcry_rsa_get_info): Removed function.
+ * elgamal.c (_gcry_elg_get_info): Removed function.
+ * dsa.c (_gcry_dsa_get_info): Removed function.
+
+ * tiger.c (tiger_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_tiger_constructor): Removed function.
+
+ * sha1.c (sha1_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_sha1_constructor): Removed function.
+
+ * sha256.c (sha256_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_sha256_constructor): Removed function.
+
+ * rmd160.c (rmd160_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rmd160_constructor): Removed function.
+
+ * md5.c (md5_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_md5_constructor): Removed function.
+
+ * md4.c (md4_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_md4_constructor): Removed function.
+
+ * crc.c (crc_get_info): Removed function.
+
+ * arcfour.c (do_arcfour_setkey): Changed type of context argument
+ to `void *', added local variable for cast, adjusted callers.
+ (arcfour_setkey): Likewise.
+ (encrypt_stream): Likewise.
+ * cast5.c (cast_setkey): Likewise.
+ (encrypt_block): Likewise.
+ * rijndael.c (rijndael_setkey): Likewise.
+ (rijndael_encrypt): Likewise.
+ (rijndael_decrypt): Likewise.
+ * twofish.c (twofish_setkey): Likewise.
+ (twofish_encrypt): Likewise.
+ (twofish_decrypt): Likewise.
+ * des.c (do_des_setkey): Likewise.
+ (do_des_encrypt): Likewise.
+ (do_des_encrypt): Likewise.
+ (do_tripledes_encrypt): Likewise.
+ (do_tripledes_encrypt): Likewise.
+ * blowfish.c (bf_setkey: Likewise.
+ (encrypt_block): Likewise.
+ (decrypt_block): Likewise.
+
+ * arcfour.c (encrypt_stream): Likewise.
+
+ * rijndael.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func) Removed function.
+
+ * twofish.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func) Removed function.
+
+ * cast5.c (CIPHER_ALGO_CAST5): Removed.
+
+ * blowfish.c (FNCCAST_SETKEY, FNCCAST_CRYPT): Removed macros.
+ (CIPHER_ALGO_BLOWFISH): Removed symbol.
+ * cast5.c (FNCCAST_SETKEY, FNCCAST_CRYPT): Likewise.
+ * des.c (selftest_failed): Removed.
+ (initialized): New variable.
+ (do_des_setkey): Run selftest, if not yet done.
+ (FNCCAST_SETKEY, FNCCAST_CRYPT): Removed macros.
+
+ * arcfour.c (_gcry_arcfour_get_info): Removed function.
+ * blowfish.c (_gcry_blowfish_get_info): Removed function.
+ * cast5.c (_gcry_cast5_get_info): Removed function.
+ * des.c (_gcry_des_get_info): Removed function.
+ * rijndael.c (_gcry_rijndael_get_info): Removed function.
+ * twofish.c (_gcry_twofish_get_info): Removed function.
+
+ * arcfour.c (cipher_spec_arcfour): New variable.
+ * twofish.c (cipher_spec_twofish, cipher_spec_twofish128): New
+ variables.
+ * rijndael.c (cipher_spec_aes, cipher_spec_aes192,
+ cipher_spec256): New variables.
+ * des.c (cipher_spec_des, cipher_spec_tripledes): New variables.
+ * cast5.c (cipher_spec_cast5): New variable.
+ * blowfish.c (cipher_spec_blowfish): Likewise.
+
+ * twofish.c: Do not include "dynload.h".
+ * rijndael.c: Likewise.
+ * des.c: Likewise.
+ * cast5.c: Likewise.
+ * blowfish.c: Likewise.
+ * cipher.c: Likewise.
+ * crc.c: Likewise.
+ * md4.c: Likewise.
+ * md5.c: Likewise.
+ * md.c: Likewise.
+ * pubkey.c: Likewise.
+ * rijndael.c: Likewise.
+ * sha1.c: Likewise.
+ * sha256.c: Likewise.
+
+ * arcfour.c: Include "cipher.h".
+ * twofish.c: Likewise.
+ * rijndael.c: Likewise.
+ * des.c: Likewise.
+ * cast5.c: Likewise.
+ * blowfish.c: Likewise.
+
+ * twofish.c (twofish_setkey): Declared argument `key' const.
+ (twofish_encrypt): Declared argument `inbuf' const.
+ (twofish_decrypt): Likewise.
+
+ * rijndael.c (rijndael_setkey): Declared argument `key' const.
+ (rijndael_encrypt): Declared argument `inbuf' const.
+ (rijndael_decrypt): Likewise.
+
+ * des.c (do_des_setkey): Declared argument `key' const.
+ (do_tripledes_setkey): Likewise.
+ (do_des_encrypt): Declared argument `inbuf' const.
+ (do_des_decrypt): Likewise.
+ (do_tripledes_encrypt): Likewise.
+ (do_tripledes_decrypt): Likewise.
+
+ * cast5.c (encrypt_block): Declared argument `inbuf' const.
+ (decrypt_block): Likewise.
+ (cast_setkey): Declared argument `key' const.
+
+ * blowfish.c (do_bf_setkey): Declared argument `key' const.
+ (encrypt_block): Declared argument `inbuf' const.
+ (encrypt_block): Likewise.
+
+
+
+ * cipher.c: Remove CIPHER_ALGO_DUMMY related code.
+ Removed struct cipher_table_s.
+ Changed definition of cipher_table.
+ Removed definition of disabled_algos.
+ (ciphers_registered, default_ciphers_registered): New variables.
+ (REGISTER_DEFAULT_CIPHERS): New macro.
+ (dummy_setkey): Declared argument `key' const.
+ (dummy_encrypt_block): Declared argument `inbuf' const.
+ (dummy_encrypt_block): Likewise.
+ (dummy_encrypt_stream): Likewise.
+ (dummy_encrypt_stream): Likewise.
+ (dummy_setkey): Use `unsigned char' instead of `byte'.
+ (dummy_encrypt_block): Likewise.
+ (dummy_decrypt_block): Likewise.
+ (dummy_encrypt_stream): Likewise.
+ (dummy_decrypt_stream): Likewise.
+ (gcry_cipher_register_default): New function.
+ (gcry_cipher_lookup_func_id): New function.
+ (gcry_cipher_lookup_func_name): New function.
+ (gcry_cipher_lookup_id): New function.
+ (gcry_cipher_lookup_name): New function.
+ (gcry_cipher_id_new): New function.
+ (gcry_cipher_register): New function.
+ (gcry_cipher_unregister): New function.
+ (setup_cipher_table): Removed function.
+ (load_cipher_modules): Removed function.
+ (gcry_cipher_map_name): Adjusted to use new module management.
+ (cipher_algo_to_string): Likewise.
+ (disable_cipher_algo): Likewise.
+ (check_cipher_algo): Likewise.
+ (cipher_get_keylen): Likewise.
+ (cipher_get_blocksize): Likewise.
+ (gcry_cipher_open): Likewise.
+ (struct gcry_cipher_handle): Replaced members algo, algo_index,
+ blocksize, setkey, encrypt, decrypt, stencrypt, stdecrypt with one
+ member: cipher.
+ (gcry_cipher_open): Adjusted code for new handle structure.
+ (cipher_setkey): Likewise.
+ (cipher_setiv): Likewise.
+ (cipher_reset): Likewise.
+ (do_ecb_encrypt): Likewise.
+ (do_ecb_decrypt): Likewise.
+ (do_cbc_encrypt): Likewise.
+ (do_cbc_decrypt): Likewise.
+ (do_cfb_encrypt): Likewise.
+ (do_cfb_decrypt): Likewise.
+ (do_ctr_encrypt): Likewise.
+ (cipher_encrypt): Likewise.
+ (gcry_cipher_encrypt): Likewise.
+ (cipher_decrypt): Likewise.
+ (gcry_cipher_decrypt): Likewise.
+ (cipher_sync): Likewise.
+ (gcry_cipher_ctl): Likewise.
+
+ * pubkey.c: Removed struct pubkey_table_s.
+ Changed definition of pubkey_table.
+ Removed definition of disabled_algos.
+ (pubkeys_registered, default_pubkeys_registered): New variables.
+ (REGISTER_DEFAULT_PUBKEYS): New macro.
+ (setup_pubkey_table): Removed function.
+ (load_pubkey_modules): Removed function.
+ (gcry_pubkey_register_default): New function.
+ (gcry_pubkey_lookup_func_id): New function.
+ (gcry_pubkey_lookup_func_name): New function.
+ (gcry_pubkey_lookup_id): New function.
+ (gcry_pubkey_lookup_name): New function.
+ (gcry_pubkey_id_new): New function.
+ (gcry_pubkey_register): New function.
+ (gcry_pubkey_unregister): New function.
+ (gcry_pk_map_name): Adjusted to use new module management.
+ (gcry_pk_algo_name): Likewise.
+ (disable_pubkey_algo): Likewise.
+ (check_pubkey_algo): Likewise.
+ (pubkey_get_npkey): Likewise.
+ (pubkey_get_nskey): Likewise.
+ (pubkey_get_nsig): Likewise.
+ (pubkey_get_nenc): Likewise.
+ (pubkey_generate): Likewise.
+ (pubkey_check_secret_key): Likewise.
+ (pubkey_encrypt): Likewise.
+ (pubkey_decrypt): Likewise.
+ (pubkey_sign): Likewise.
+ (pubkey_verify): Likewise.
+ (gcry_pk_get_nbits): Likewise.
+ (gcry_pk_algo_info): Likewise.
+
+ * md.c: Removed struct md_digest_list_s.
+ (digest_list): Changed definition.
+ (digests_registered, default_digests_registered): New variables.
+ (REGISTER_DEFAULT_DIGESTS): New macro.
+ (new_list_item): Removed function.
+ (setup_md_table): Removed function.
+ (load_digest_module): Removed function.
+ (gcry_digest_register_default): New function.
+ (gcry_digest_lookup_func_id): New function.
+ (gcry_digest_lookup_func_name): New function.
+ (gcry_digest_lookup_id): New function.
+ (gcry_digest_lookup_name): New function.
+ (gcry_digest_id_new): New function.
+ (gcry_digest_register): New function.
+ (gcry_digest_unregister): New function.
+ (GcryDigestEntry): New type.
+ (struct gcry_md_context): Adjusted type of `list'.
+ (gcry_md_map_name): Adjusted to use new module management.
+ (digest_algo_to_string): Likewise.
+ (check_digest_algo): Likewise.
+ (md_enable): Likewise.
+ (md_digest_length): Likewise.
+ (md_asn_oid): Likewise.
+
+2003-04-07 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c: Replaced PUBKEY_ALGO_DSA with GCRY_PK_DSA,
+ PUBKEY_ALGO_RSA with GCRY_PK_RSA and PUBKEY_ALGO_ELGAMAL with
+ GCRY_PK_ELG.
+
+ * dsa.c: Replaced PUBKEY_ALGO_DSA with GCRY_PK_DSA.
+
+2003-04-01 Moritz Schulte <moritz@g10code.com>
+
+ * des.c: Removed checks for GCRY_CIPHER_3DES and GCRY_CIPHER_DES.
+
+2003-03-31 Moritz Schulte <moritz@g10code.com>
+
+ * tiger.c (tiger_get_info): Do not declare static.
+ * sha256.c (sha256_get_info): Likewise.
+ * sha1.c (sha1_get_info): Likewise.
+ * rmd160.c (rmd160_get_info): Likewise.
+ * md5.c (md5_get_info): Likewise.
+ * md4.c (md4_get_info): Likewise.
+ * crc.c (crc_get_info): Likewise.
+
+ * md.c (load_digest_module): Call setup_md_table during
+ initialization.
+ (new_list_item): Link new element into digest_list.
+
+ * cipher.c (do_ctr_decrypt): Made do_ctr_encrypt act as a wrapper
+ for do_ctr_encrypt, since these functions are identical.
+
+2003-03-30 Simon Josefsson <jas@extundo.com>
+
+ * cipher.c (struct gcry_cipher_handle): Add counter field.
+ (gcry_cipher_open): Add CTR.
+ (cipher_reset): Clear counter field.
+ (do_ctr_encrypt, do_ctr_decrypt): New functions.
+ (cipher_encrypt, cipher_decrypt): Call CTR functions.
+ (gcry_cipher_ctl): Add SET_CTR to set counter.
+
+2003-03-30 Moritz Schulte <moritz@g10code.com>
+
+ * rsa.c (_gcry_rsa_blind): New function.
+ (_gcry_rsa_unblind): New function.
+ (_gcry_rsa_decrypt): Use _gcry_rsa_blind and _gcry_rsa_decrypt.
+
+2003-03-26 Moritz Schulte <moritz@g10code.com>
+
+ * dynload.c (_gcry_enum_gnupgext_pubkeys): Adjust `encrypt' and
+ `decrypt' function arguments.
+ (_gcry_enum_gnupgext_pubkeys): Likewise.
+ * dynload.h: Likewise.
+
+ * pubkey.c (dummy_decrypt): Add argument: int flags.
+ (dummy_encrypt): Likewise.
+
+ * elgamal.c (_gcry_elg_encrypt): Add argument: int flags.
+ (_gcry_elg_decrypt): Likewise.
+
+ * rsa.c (_gcry_rsa_encrypt): Add argument: int flags.
+ (_gcry_rsa_decrypt): Likewise.
+
+ * pubkey.c: Add `flags' argument to members `encrypt' and
+ `decrypt' of struct `pubkey_table_s'.
+
+ * rsa.h: Add `flags' argument to function declarations.
+ * elgamal.h: Likewise.
+
+ * pubkey.c (sexp_data_to_mpi): New variable: int parsed_flags.
+ (sexp_data_to_mpi): Set `parsed_flags'.
+ (sexp_data_to_mpi): New argument: int *flags.
+ (gcry_pk_encrypt): New variable: int flags.
+ (gcry_pk_encrypt): Pass `flags' to pubkey_encrypt.
+ (pubkey_encrypt): New variable: int flags.
+ (pubkey_encrypt): Pass `flags' to pubkey encrypt function.
+ (pubkey_decrypt): Likewise.
+ (pubkey_decrypt): Pass `flags' to pubkey encrypt function.
+ (gcry_pk_encrypt): Include `flags' s-exp in return list.
+ (sexp_to_enc): New argument: int *flags.
+ (gcry_pk_decrypt): New variable: int flags.
+ (gcry_pk_decrypt): Pass `flags' to pubkey_decrypt.
+ (sexp_to_enc): New variable: int parsed_flags.
+ (sexp_to_enc): Set `parsed_flags'.
+
+2003-03-22 Simon Josefsson <jas@extundo.com>
+
+ * cipher.c (gcry_cipher_open, do_cbc_encrypt)
+ (gcry_cipher_encrypt): Support GCRY_CIPHER_CBC_MAC.
+ (gcry_cipher_ctl): Support GCRYCTL_SET_CBC_MAC.
+
+2003-03-19 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): New args EXTRA_CHECK and EXTRA_CHECK_ARG
+ to allow for a user callback. Changed all callers.
+ (_gcry_generate_secret_prime)
+ (_gcry_generate_public_prime): Ditto, pass them to gen_prime.
+ * rsa.c (check_exponent): New.
+ (generate): Use a callback to ensure that a given exponent is
+ actually generated.
+
+2003-03-12 Moritz Schulte <moritz@g10code.com>
+
+ * primegen.c: Initialize `no_of_small_prime_numbers' statically.
+ (gen_prime): Remove calculation of `no_of_small_prime_numbers'.
+
+2003-03-03 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (gcry_md_ctl): Rewritten to use same style like the other
+ functions dispatchers.
+
+2003-03-02 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (struct gcry_cipher_handle): New member: algo_index.
+ (gcry_cipher_open): Allocate memory for two cipher contexts.
+ Initialize algo_index.
+ (cipher_setkey): Duplicate context into reserved memory.
+ (cipher_reset): New function, which resets the context and clear
+ the IV.
+ (gcry_cipher_ctl): Call cipher_reset.
+
+2003-02-23 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c: Remove (bogus) `digitp' macro definition.
+ * md.c: Likewise.
+
+ * blowfish.c (burn_stack): Removed.
+ * arcfour.c (burn_stack): Likewise.
+ * cast5.c (burn_stack): Likewise.
+ * des.c (burn_stack): Likewise.
+ * md4.c (burn_stack): Likewise.
+ * md5.c (burn_stack): Likewise.
+ * random.c (burn_stack): Likewise.
+ * rijndael.c (burn_stack): Likewise.
+ * rmd160.c (burn_stack): Likewise.
+ * sha1.c (burn_stack): Likewise.
+ * sha256.c (burn_stack): Likewise.
+ * tiger.c (burn_stack): Likewise.
+ * twofish.c (burn_stack): Likewise.
+
+ * blowfish.c: Changed all occurences of burn_stack to
+ _gcry_burn_stack.
+ * arcfour.c: Likewise.
+ * cast5.c: Likewise.
+ * des.c: Likewise.
+ * md4.c: Likewise.
+ * md5.c: Likewise.
+ * random.c: Likewise.
+ * rijndael.c: Likewise.
+ * rmd160.c: Likewise.
+ * sha1.c: Likewise.
+ * sha256.c: Likewise.
+ * tiger.c: Likewise.
+ * twofish.c: Likewise.
+
+ * arcfour.c (_gcry_arcfour_get_info): Use GCRY_CIPHER_ARCFOUR
+ instead of hard-coded value `301'.
+
+2003-01-24 Werner Koch <wk@gnupg.org>
+
+ * random.c (_gcry_register_random_progress): New.
+ (_gcry_random_progress): New.
+
+ * rndlinux.c (gather_random): Call the random progress function.
+
+2003-01-23 Werner Koch <wk@gnupg.org>
+
+ * rsa.c (generate): New arg USE_E to request a specific public
+ exponent.
+ (_gcry_rsa_generate): Ditto.
+ * elgamal.c (_gcry_elg_generate): Must add an dummy argument
+ instead of USE_E.
+ * dsa.c (_gcry_dsa_generate): Ditto.
+ * pubkey.c (dummy_generate): Ditto.
+ (pubkey_generate): Add USE_E arg and pass it down.
+ (gcry_pk_genkey): Detect "rsa-use-e" parameter and pass it to generate.
+
+ * pubkey.c (sexp_to_enc): New arg RET_MODERN.
+ (gcry_pk_decrypt): Make use of it to return a real S-expression.
+ Return better error codes.
+ (gcry_pk_verify): Return better error codes.
+
+2003-01-21 Werner Koch <wk@gnupg.org>
+
+ * random.c (gcry_random_add_bytes): Add QUALITY argument, let
+ function return an error code and disable its core for now.
+
+2003-01-21 Timo Schulz <twoaday@freakmail.de>
+
+ * random.c (gcry_random_add_bytes): New. Function to add external
+ random to the pool.
+
+2003-01-20 Simon Josefsson <jas@extundo.com>
+
+ * crc.c: New.
+ * Makefile.am (EXTRA_PROGRAMS, EXTRA_crc_SOURCES): Add crc.c.
+ * md.c (gcry_md_get_algo_dlen): Add values for CRC.
+
+2003-01-20 Werner Koch <wk@gnupg.org>
+
+ * sha256.c: New.
+ * bithelp.h (ror): New.
+ * Makfile.am: Add sha256.c.
+ * md.c (oid_table): Add values for SHA256 et al.
+ (gcry_md_get_algo_dlen): Likewise
+
+2003-01-20 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_get_keygrip): Implemented keygrips for DSA
+ and ElGamal.
+
+2003-01-17 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_encrypt): Reworked so that the output will
+ never contain the plaintext even if the caller did not checked the
+ return value.
+
+ * md.c (gcry_md_get_algo): Changed error code to GCRYERR_GENERAL
+ because we don't have an invalid md algo but no algorithm enabled.
+
+ * pubkey.c (gcry_pk_genkey): Changed error code for bounds check
+ of table parameters to GCRYERR_INTERNAL.
+
+ * md.c (gcry_md_open): Partly reverted Timo's change from
+ 2002-10-10 by removing the check for the algorithm. An algorithm
+ of 0 is allowed and anyway we should not double check it or check
+ it using a different function. Also fixed the flags check.
+
+ * pubkey.c (gcry_pk_encrypt): Make sure that R_CIPH points to NULL
+ on error.
+ (gcry_pk_decrypt): Ditto for R_PLAIN.
+ (gcry_pk_sign): Ditto for R_SIG.
+ (gcry_pk_genkey): Ditto for R_KEY.
+
+2003-01-16 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_write): Changed 2nd argument type to void*.
+ (gcry_md_hash_buffer): Changed type of boths buffers to void*.
+ (gcry_md_setkey): Changed 2nd argument type to void*.
+
+2003-01-15 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (sexp_data_to_mpi): New. This handles pkcs1 padding.
+ (gcry_pk_sign, gcry_pk_verify): Use it here.
+ (gcry_pk_encrypt): And here.
+ (pubkey_verify): Add debug code.
+ (sexp_to_enc): Handle flags in the input and return the pkcs1 flag
+ in a new parameter.
+ (gcry_pk_decrypt): Prepare for future pkcs1 handling.
+
+2002-12-19 Werner Koch <wk@gnupg.org>
+
+ * random.c (_gcry_random_initialize): New.
+
+2002-12-16 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Added a Teletrust specific OID for 3DES.
+
+2002-12-12 Werner Koch <wk@gnupg.org>
+
+ * md.c: Added another oddball OIW OID (sha-1WithRSAEncryption).
+
+2002-11-23 Werner Koch <wk@gnupg.org>
+
+ * md.c (load_digest_module): Enlarged checked_algos bitmap.
+ * md4.c (func_table): Fixed entry for md4.
+ Both by Simon Josephson.
+ (transform): Copy data to get the alignment straight. Tested only
+ on i386.
+
+2002-11-10 Simon Josefsson <jas@extundo.com>
+
+ * cipher.c (gcry_cipher_open): Don't reject CTS flag.
+ (do_cbc_encrypt, do_cbc_decrypt, cipher_encrypt)
+ (gcry_cipher_encrypt, cipher_decrypt)
+ (gcry_cipher_decrypt): Support CTS flag.
+ (gcry_cipher_ctl): Toggle CTS flag.
+
+2002-11-10 Werner Koch <wk@gnupg.org>
+
+ * md4.c: New. By Simon Josefsson.
+ * Makefile.am (EXTRA_PROGRAMS): Add md4.c.
+ * md.c (oid_table,gcry_md_get_algo_dlen): MD4 support.
+
+2002-10-14 Werner Koch <wk@gnupg.org>
+
+ * arcfour.c (do_encrypt_stream): Don't use increment op when
+ assigning to the same variable.
+
+2002-10-10 Timo Schulz <ts@winpt.org>
+
+ * pubkey.c (gcry_pk_genkey): Check boundaries.
+
+ * md.c (gcry_md_open): Check that algo is available and only
+ valid flag values are used.
+ (gcry_md_get_algo): Add error handling.
+
+2002-09-26 Werner Koch <wk@gnupg.org>
+
+ * md.c: Include an OID for TIGER.
+ * tiger.c (tiger_get_info): Use a regular OID.
+
+2002-09-17 Werner Koch <wk@gnupg.org>
+
+ * random.c: Replaced mutex.h by the new ath.h. Changed all calls.
+
+2002-09-16 Werner Koch <wk@gnupg.org>
+
+ * arcfour.c (do_encrypt_stream): Use register modifier and modulo.
+ According to Nikos Mavroyanopoulos this increases perfromace on
+ i386 system noticable. And I always tought gcc is clever enough.
+ * md5.c (transform): Use register modifier.
+ * rmd160.c (transform): Ditto.
+ * sha1.c (transform): Ditto. We hope that there are 6 free registers.
+ * random.c (gcry_randomize): Rewrote to avoid malloc calls.
+
+ * rndlinux.c (gather_random): Replaced remaining fprintfs by log_*.
+ * arcfour.c (do_arcfour_setkey): Ditto.
+ * twofish.c (do_twofish_setkey): Ditto.
+ * rndegd.c (gather_random): Ditto.
+ * rijndael.c (do_setkey): Ditto.
+ * random.c (_gcry_random_dump_stats): Ditto.
+ * primegen.c (_gcry_generate_elg_prime): Ditto.
+ * des.c (_gcry_des_get_info): Ditto.
+ * cast5.c (do_cast_setkey): Ditto.
+ * blowfish.c (do_bf_setkey): Ditto.
+
+2002-08-26 Werner Koch <wk@gnupg.org>
+
+ * des.c (weak_keys): Fixed one entry in the table and compared
+ all entries against the literature.
+ (selftest): Checksum the weak key table.
+
+2002-08-21 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c: Enable keygrip calculation for "openpgp-rsa".
+
+2002-08-17 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (setup_cipher_table): Don't overwrite the DES entry
+ with the entry for DUMMY.
+
+2002-08-14 Werner Koch <wk@gnupg.org>
+
+ * des.c (do_des_setkey,do_des_encrypt, do_des_decrypt): New.
+ (_gcry_des_get_info): Support plain old DES.
+ * cipher.c (setup_cipher_table): Put DES into the table.
+
+2002-07-25 Werner Koch <wk@gnupg.org>
+
+ * rndunix.c (_gcry_rndunix_constructor): Prefixed with _gcry_.
+ Noted by Stephan Austermuehle.
+
+2002-07-08 Timo Schulz <ts@winpt.org>
+
+ * rndw32.c: Replaced the m_ memory functions with the real
+ gcry_ functions. Renamed all g10_ prefixed functions to log_.
+
+2002-06-12 Werner Koch <wk@gnupg.org>
+
+ * rsa.c (generate): Use e = 65537 for now.
+
+2002-06-11 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_get_keygrip): Allow a "protected-private-key".
+
+2002-06-05 Timo Schulz <ts@winpt.org>
+
+ * cipher.c (gcry_cipher_encrypt, gcry_cipher_decrypt):
+ Check that the input size is a multiple of the blocksize.
+
+2002-05-23 Werner Koch <wk@gnupg.org>
+
+ * md.c (oid_table): Add an rsadsi OID for MD5.
+
+2002-05-21 Werner Koch <wk@gnupg.org>
+
+ * primegen.c, elgamal.c, dsa.c (progress): Do not print anything
+ by default. Pass an extra identifying string to the callback and
+ reserved 2 argumenst for current and total counters. Changed the
+ register function prototype.
+
+2002-05-17 Werner Koch <wk@gnupg.org>
+
+ * rndegd.c (rndegd_constructor): Fixed name of register function
+ and prefixed the function name with _gcry_.
+ * rndw32.c (rndw32_constructor): Ditto.
+ * tiger.c (tiger_constructor): Ditto.
+
+ * Makefile.am: Removed all dynamic loading stuff.
+ * dynload.c: Ditto. Now only used for the constructor system.
+
+2002-05-15 Werner Koch <wk@gnupg.org>
+
+ * random.c (gcry_random_bytes,gcry_random_bytes_secure)
+ (gcry_randomize): Make sure we are initialized.
+
+2002-05-14 Werner Koch <wk@gnupg.org>
+
+ Changed license of most files to the LGPL.
+
+2002-05-02 Werner Koch <wk@gnupg.org>
+
+ * random.c (_gcry_fast_random_poll): Initialize the module so the
+ mutex can be used.
+
+ * primegen.c (small_prime_numbers): Moved table from smallprime.c
+ * smallprime.c: File removed.
+
+ * des.c (leftkey_swap, rightkey_swap, working_memcmp): Made static.
+
+ * cipher.c (gcry_cipher_map_name): Map "RIJNDAEL" to "AES".
+ * rijndael.c (rijndael_get_info): We do only support a 128 bit
+ blocksize so it makes sense to change the algorithm strings to
+ AES.
+
+ * tiger.c (tiger_final): Removed superfluous token pasting operators.
+ * md5.c (md5_final): Ditto.
+
+2002-04-30 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Fixed list of copyright years.
+
+2002-03-18 Werner Koch <wk@gnupg.org>
+
+ * random.c (initialize): Initialize the new pool lock mutex.
+ (_gcry_fast_random_poll): Add locking and moved main
+ code out to...
+ (do_fast_random_poll): new function.
+ (read_pool): Use the new function here.
+ (get_random_bytes): Add locking.
+ (_gcry_update_random_seed_file): Ditto.
+
+2002-03-11 Werner Koch <wk@gnupg.org>
+
+ * md.c: Add rsaSignatureWithripemd160 to OID table.
+
+2002-02-20 Werner Koch <wk@gnupg.org>
+
+ * sha1.c: Removed a left over comment note. The code has been
+ rewritten from scratch in 1998. Thanks to Niels Möller for
+ reporting this misleading comment.
+
+2002-02-18 Werner Koch <wk@gnupg.org>
+
+ * rndunix.c (rndunix_constructor): Use the the new prefixed
+ function name. Reported by Jordi Mallach.
+
+2002-02-10 Werner Koch <wk@gnupg.org>
+
+ * random.c (mix_pool): Carry an extra failsafe_digest buffer
+ around to make the function more robust.
+
+2002-02-08 Werner Koch <wk@gnupg.org>
+
+ * random.c (add_randomness): Xor new data into the pool and not
+ just copy it. This avoids any choosen input attacks which are not
+ serious in our setting because an outsider won't be able to mix
+ data in and even then we keep going with a PRNG. Thanks to Stefan
+ Keller for pointing this out.
+
+2002-01-04 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_genkey): Do not release skey - it is static.
+
+ * primegen.c (gen_prime): Of course we should use set_bit
+ and not set_highbit to set the second high bit.
+
+2001-12-18 Werner Koch <wk@gnupg.org>
+
+ * rsa.c (generate): Loop until we find the exact modulus size.
+ Changed the exponent to 41.
+ (rsa_get_info): s/usage/r_usage/ to avoid shadow warnings.
+ * primegen.c (gen_prime): Set 2 high order bits for secret primes.
+
+ * Makefile.am (DISTCLEANFILES): Include construct.c.
+
+2001-12-17 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_get_keygrip): New - experimental.
+
+2001-12-11 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Added OIDs for AES.
+ (gcry_cipher_mode_from_oid): New.
+ (gcry_cipher_map_name): Moved OID search code to ..
+ (search_oid): .. new function.
+
+2001-12-10 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_encrypt): Find the signature algorithm by name
+ and not by number.
+
+ * pubkey.c (gcry_pk_encrypt,gcry_pk_decrypt,gcry_pk_sign)
+ (gcry_pk_verify,gcry_pk_testkey, gcry_pk_genkey)
+ (gcry_pk_get_nbits): Release the arrays. Noted by Nikos
+ Mavroyanopoulos.
+
+2001-12-06 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_map_name): Look also for OIDs prefixed
+ with "oid." or "OID.".
+
+2001-12-05 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (algo_info_table): Fixed entry for openpgp-rsa.
+
+2001-11-24 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c: Added the rsaEncryption OID to the tables.
+ (sexp_to_key): Add an arg to return the index of the algorithm,
+ changed all callers.
+ (gcry_pk_sign): Find the signature algorithm by name and not by
+ number.
+ (gcry_pk_get_nbits): Fixed so that we can now really pass a secret
+ key to get the result.
+
+ * md.c (gcry_md_map_name): Look also for OIDs prefixed with "oid."
+ or "OID." so that an OID string can be used as an S-Exp token.
+
+2001-11-20 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_map_name): Lookup by OID if the the name begins
+ with a digit.
+ (oid_table): New.
+
+2001-11-16 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_info): New operator GCRYCTL_IS_ALGO_ENABLED.
+
+2001-11-07 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Close the handle which was left open
+ for algorithms other than rmd160.
+
+2001-08-08 Werner Koch <wk@gnupg.org>
+
+ * rndw32.c (gather_random): Use toolhelp in addition to the NT
+ gatherer for Windows2000. Suggested by Sami Tolvanen.
+
+ * random.c (read_pool): Fixed length check, this used to be one
+ byte to strict. Made an assert out of it because the caller has
+ already made sure that only poolsize bytes are requested.
+ Reported by Marcus Brinkmann.
+
+2001-08-03 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (cipher_encrypt, cipher_decrypt): Prepare to return
+ errors. We have to change the interface to all ciphers to make
+ this really work but we should do so to prepare for hardware
+ encryption modules.
+ (gcry_cipher_encrypt, gcry_cipher_decrypt): Return the error and
+ set lasterr.
+ (gcry_cipher_ctl): Make sure that errors from setkey are returned.
+
+2001-08-02 Werner Koch <wk@gnupg.org>
+
+ * rndlinux.c (gather_random): casted a size_t arg to int so that
+ the format string is correct. Casting is okay here and avoids
+ translation changes.
+
+ * random.c (fast_random_poll): Do not check the return code of
+ getrusage.
+
+ * rndunix.c: Add a signal.h header to avoid warnings on Solaris 7
+ and 8.
+
+ * tiger.c (print_abc,print_data): Removed.
+
+ * rijndael.c, des.c, blowfish.c, twofish.c, cast5.c, arcfour.c
+ (burn_stack): New. Add wrappers for most functions to be able to
+ call burn_stack after the function invocation. This methods seems
+ to be the most portable way to zeroise the stack used. It does
+ only work on stack frame based machines but it is highly portable
+ and has no side effects. Just setting the automatic variables at
+ the end of a function to zero does not work well because the
+ compiler will optimize them away - marking them as volatile would
+ be bad for performance.
+ * md5.c, sha1.c, rmd160.c, tiger.c (burn_stack): Likewise.
+ * random.c (burn_stack): New.
+ (mix_pool): Use it here to burn the stack of the mixblock function.
+
+ * primegen.c (_gcry_generate_elg_prime): Freed q at 3 places.
+ Thanks to Tommi Komulainen.
+
+ * arcfour.c (arcfour_setkey): Check the minimim keylength against
+ bytes and not bits.
+ (selftest): Must reset the key before decryption.
+
+2001-05-31 Werner Koch <wk@gnupg.org>
+
+ * sha1.c (sha1_init): Made static.
+
+ Changed all g10_ prefixed function names as well as some mpi_
+ function names to cope with the introduced naming changes.
+
+ * md.c (prepare_macpads): Made key const.
+
+2001-05-28 Werner Koch <wk@gnupg.org>
+
+ * rndegd.c (gather_random): Removed the use of tty_printf.
+
+2001-03-29 Werner Koch <wk@gnupg.org>
+
+ * md5.c (md5_final): Fixed calculation of hashed length. Thanks
+ to disastry@saiknes.lv for pointing out that it was horrible wrong
+ for more than 512MB of input.
+ * sha1.c (sha1_final): Ditto.
+ * rmd160.c (rmd160_final): Ditto.
+ * tiger.c (tiger_final): Ditto.
+
+ * blowfish.c (encrypt,do_encrypt): Changed name to do_encrypt to
+ avoid name clashes with an encrypt function in stdlib.h of
+ Dynix/PIX. Thanks to Gene Carter.
+ * elgamal.c (encrypt,do_encrypt): Ditto.
+
+ * twofish.c (gnupgext_enum_func): Use only when when compiled as a
+ module.
+ * rijndael.c (gnupgext_enum_func): Ditto.
+
+ * tiger.c (tiger_get_info): Return "TIGER192" and not just
+ "TIGER". By Edwin Woudt.
+
+ * random.c: Always include time.h - standard requirement. Thanks
+ to James Troup.
+
+ * rndw32.c: Fixes to the macros.
+
+2001-01-11 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (cipher_encrypt,gcry_cipher_encrypt): Use blocksize and
+ not 8.
+
+2000-12-19 Werner Koch <wk@gnupg.org>
+
+ Major change:
+ Removed all GnuPG stuff and renamed this piece of software
+ to gcrypt.
+
+2000-11-14 Werner Koch <wk@gnupg.org>
+
+ * dsa.c (test_keys): Replaced mpi_alloc by gcry_mpi_new and
+ mpi_free by gcry_mpi_release.
+ * elgamal.c (test_keys,generate): Ditto, also for mpi_alloc_secure.
+ * rsa.c (test_keys,generate,rsa_verify): Ditto.
+ * primegen.c (generate_elg_prime): Ditto.
+ (gen_prime): Ditto and removed nlimbs.
+
+ * rsa.c (generate): Allocate 2 more vars in secure memory.
+
+ * Makefile.am (OMIT_DEPENDENCIES): Hack to work around dependency
+ problems.
+
+2000-10-09 Werner Koch <wk@gnupg.org>
+
+ * arcfour.c, arcfour.h: New.
+ * cipher.c (cipher_encrypt, cipher_decrypt): Add stream mode.
+ (setup_cipher_table): Add Arcfour.
+ (gcry_cipher_open): Kludge to allow stream mode.
+
+Wed Oct 4 13:16:18 CEST 2000 Werner Koch <wk@openit.de>
+
+ * sha1.c (transform): Use rol() macro. Actually this is not needed
+ for a newer gcc but there are still aoter compilers.
+
+ * rsa.c (test_keys): Use new random function.
+
+ * md.c (gcry_md_setkey): New function to overcome problems with
+ const conflics.
+ (gcry_md_ctl): Pass set key to the new functions.
+
+ * rijndael.c: New.
+ * cipher.c: Add Rijndael support.
+
+Mon Sep 18 16:35:45 CEST 2000 Werner Koch <wk@openit.de>
+
+ * rndlinux.c (open_device): Loose random device checking.
+ By Nils Ellmenreich.
+
+ * random.c (fast_random_poll): Check ENOSYS for getrusage.
+ * rndunix.c: Add 2 sources for QNX. By Sam Roberts.
+
+ * pubkey.c (gcry_pk_algo_info): Add GCRYCTL_GET_ALGO_USAGE.
+
+ * rsa.c: Changed the comment about the patent.
+ (secret): Speed up by using the CRT. For a 2k keys this
+ is about 3 times faster.
+ (stronger_key_check): New but unused code to check the secret key.
+ * Makefile.am: Included rsa.[ch].
+ * pubkey.c: Enabled RSA support.
+ (pubkey_get_npkey): Removed RSA workaround.
+
+Mon Jul 31 10:04:47 CEST 2000 Werner Koch <wk@openit.de>
+
+ * pubkey.c: Replaced all gcry_sexp_{car,cdr}_{data,mpi} by the new
+ gcry_sexp_nth_{data,mpi} functions.
+
+Tue Jul 25 17:44:15 CEST 2000 Werner Koch <wk@openit.de>
+
+ * pubkey.c (exp_to_key,sexp_to_sig,sexp_to_enc,gcry_pk_encrypt,
+ gcry_pk_decrypt,gcry_pk_sign,gcry_pk_genkey): Changed to work with
+ the new S-Exp interface.
+
+Mon Jul 17 16:35:47 CEST 2000 Werner Koch <wk@>
+
+ * random.c (gather_faked): Replaced make_timestamp by time(2) again.
+
+Fri Jul 14 19:38:23 CEST 2000 Werner Koch <wk@>
+
+ * md.c (gcry_md_ctl): Support GCRYCTL_{START,STOP}_DUMP.
+
+ * Makefile.am: Never compile mingw32 as module.
+
+ * Makefile.am: Tweaked module build and removed libtool
+
+ * Makefile.am: Replaced -O1 by -O. Suggested by Alec Habig.
+
+ * elgamal.c (sign): Removed inactive code.
+
+ * rsa.c, rsa.h: New based on the old module version (only in CVS for now).
+ * pubkey.c (setup_pubkey_table): Added commented support for RSA.
+
+ * rndunix.c (waitpid): New. For UTS 2.1. All by Dave Dykstra.
+ (my_popen): Do the FD_CLOEXEC only if it is available
+ (start_gatherer): Cope with missing _SC_OPEN_MAX
+
+ * rndunix.c: Add some more headers for QNX. By Sam Roberts.
+
+ * rndegd.c (gather_random): Shortcut level 0.
+ * rndunix.c (gather_random): Ditto.
+ * rndw32.c (gather_random): Ditto.
+
+ * rndw32.c: Replaced with code from Cryptlib and commented the old stuff.
+ * rndw32.c: Add some debuging code enabled by an environment variable.
+
+ * random.c (read_seed_file): Binary open for DOSish system
+ (update_random_seed_file): Ditto.
+ * random.c [MINGW32]: Include process.h for getpid.
+ * random.c (fast_random_poll): Add clock_gettime() as fallback for
+ system which support this POSIX.4 fucntion. By Sam Roberts.
+
+ * random.c (read_seed_file): Removed the S_ISLNK test becuase it
+ is already covered by !S_ISREG and is not defined in Unixware.
+ Reported by Dave Dykstra.
+ (update_random_seed_file): Silently ignore update request when pool
+ is not filled.
+
+ * random.c (read_seed_file): New.
+ (set_random_seed_file): New.
+ (read_pool): Try to read the seeding file.
+ (update_random_seed_file): New.
+
+ (read_pool): Do an initial extra seeding when level 2 quality random
+ is requested the first time. This requestes at least POOLSIZE/2 bytes
+ of entropy. Compined with the seeding file this should make normal
+ random bytes cheaper and increase the quality of the random bytes
+ used for key generation.
+
+ * random.c (read_pool): Print a more friendly error message in
+ cases when too much random is requested in one call.
+
+ * random.c (fast_random_poll): Check whether RUSAGE_SELF is defined;
+ this is not the case for some ESIX and Unixware, although they have
+ getrusage().
+
+ * primegen.c (generate_elg_prime): All primes are now generated with
+ the lowest random quality level. Because they are public anyway we
+ don't need stronger random and by this we do not drain the systems
+ entropy so much.
+
+ * primegen.c (register_primegen_progress): New.
+ * dsa.c (register_pk_dsa_progress): New.
+ * elgamal.c (register_pk_elg_progress): New.
+
+ * elgamal.c (wiener_map): New.
+ (gen_k): Use a much smaller k.
+ (generate): Calculate the qbits using the wiener map and
+ choose an x at a size comparable to the one choosen in gen_k
+
+ * rmd160.c (rmd160_get_info): Moved casting to the left side due to a
+ problem with UTS4.3. Suggested by Dave Dykstra.
+ * sha1.c (sha1_get_info): Ditto.
+ * tiger.c (tiger_get_info): Ditto.
+ * md5.c (md5_get_info): Ditto
+ * des.c (des_get_info): Ditto.
+ * blowfish.c (blowfish_get_info): Ditto.
+ * cast5.c (cast5_get_info): Ditto.
+ * twofish.c (twofish_get_info): Ditto.
+
+Fri Mar 24 11:25:45 CET 2000 Werner Koch <wk@openit.de>
+
+ * md.c (md_open): Add hmac arg and allocate space for the pads.
+ (md_finalize): Add HMAC support.
+ (md_copy): Ditto.
+ (md_close): Ditto.
+ (gcry_md_reset): Ditto.
+ (gcry_md_ctl): Ditto.
+ (prepare_macpdas): New.
+
+Mon Mar 13 19:22:46 CET 2000 Werner Koch <wk@openit.de>
+
+ * md.c (gcry_md_hash_buffer): Add support for the other algorithms.
+
+Mon Jan 31 16:37:34 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * genprime.c (generate_elg_prime): Fixed returned factors which never
+ worked for non-DSA keys.
+
+Thu Jan 27 18:00:44 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (sexp_to_key): Fixed mem leaks in case of errors.
+
+Mon Jan 24 22:24:38 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (gcry_pk_decrypt): Implemented.
+ (gcry_pk_encrypt): Implemented.
+ (gcry_pk_testkey): New.
+ (gcry_pk_genkey): New.
+ (pubkey_decrypt): Made static.
+ (pubkey_encrypt): Ditto.
+ (pubkey_check_secret_key): Ditto.
+ (pubkey_generate): Ditto.
+
+Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (pubkey_nbits): Removed and replaced by ...
+ (gcry_pk_get_nbits): this new one.
+
+Wed Dec 8 21:58:32 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * dsa.c: s/mpi_powm/gcry_mpi_powm/g
+ * elgamal.c: Ditto.
+ * primegen.c: Ditto.
+
+ * : Replaced g10_opt_verbose by g10_log_verbosity().
+
+ * Makefile.am (INCLUDES): removed intl, add ../gcrypt
+
+Fri Nov 19 17:15:20 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * dynload.c (cmp_filenames): New to replaced compare_filename() in
+ module.
+ (register_cipher_extension): Removed the tilde expansion stuff.
+ * rndeg.c (my_make_filename): New.
+
+ * : Replaced header util.h by g10lib.h
+
+ * random.c (gather_faked): Replaced make_timestamp by time(2).
+ Disabled wrning printed with tty_printf.
+ * rndlinux.c (gather_random): Always use fprintf instead of tty_xxx;
+ this should be replaced by a callback function.
+
+ * primegen.c (gen_prime): Use gcry_mpi_randomize.
+ (is_prime): Ditto.
+ * elgamal.c (test_keys): Ditto.
+ * dsa.c (test_keys): Ditto.
+
+ * cipher.c (gcry_cipher_close): Die on invalid handle.
+
+Mon Nov 15 21:36:02 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * elgamal.c (gen_k): Use the new random API.
+ (generate): Ditto.
+ * dsa.c (gen_k): Ditto.
+ (generate): Ditto.
+
+Sat Nov 13 17:44:23 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (disable_pubkey_algo): Made static.
+ (gcry_pk_ctl): New.
+
+ * random.c (get_random_bits): Renamed to ...
+ (get_random_bytes): ... this and made static.
+ (gcry_random_bytes): New.
+ (gcry_random_bytes_secure): New.
+ (randomize_buffer): Renamed to ...
+ (gcry_randomize): ...this.
+
+ * md.c (gcry_md_hash_buffer): New.
+
+ * pubkey.c (gcry_pk_algo_info): 4 new commands.
+ (pubkey_get_npkey): Made static.
+ (pubkey_get_nskey): Made static.
+ (pubkey_get_nsig): Made static.
+ (pubkey_get_nenc): Made static.
+
+ * pubkey.c: Removed all G10ERR_xxx.
+ * cipher.c: Changed all GCRYERR_INV_ALGO to GCRYERR_INV_CIPHER_ALGO.
+ * md.c: Changed all GCRYERR_INV_ALGO to GCRYERR_INV_MD_ALGO.
+ * cast5.c (cast_setkey): Changed errocodes to GCRYERR_xxx.
+ * blowfish.c: Ditto.
+ * des.c: Ditto.
+ * twofish.c: Ditto.
+ * dsa.c: Ditto.
+ * elgamal.c: Ditto.
+
+ * g10c.c: Removed
+
+ * cipher.c (gcry_cipher_open): Replaced alloc functions and return NULL
+ if we are out of core.
+ * dynload.c: Replaced all memory allocation functions.
+ * md.c: Ditto.
+ * primegen.c: Ditto.
+ * pubkey.c: Ditto.
+ * random.c: Ditto.
+ * rndw32.c: Ditto.
+ * elgamal.c: Ditto.
+ * dsa.c: Ditto.
+
+Tue Oct 26 14:10:21 CEST 1999 Werner Koch <wk@gnupg.de>
+
+ * elgamal.c (sign): Hugh found strange code here. Replaced by BUG().
+
+ * cipher.c: Merged with gcrypt/symapi.c.
+
+ * pubkey.c (string_to_pubkey_algo): Renamed function to ...
+ (gcry_pk_map_name): ... this.
+ (pubkey_algo_to_string): Renamed function to ...
+ (gcry_pk_algo_name): ... this.
+ (gcry_pk_algo_info): New.
+ * pubkey.c: Merged with gcrypt/pkapi.c.
+
+ * md.c (md_reset): Clear finalized; thanks to Ulf Moeller for
+ fixing this bug.
+
+ * md.c: Merged with gcrypt/mdapi.c
+
+Wed Sep 15 14:39:59 CEST 1999 Michael Roth <mroth@nessie.de>
+
+ * des.c: Various speed improvements: One bit pre rotation
+ trick after initial permutation (Richard Outerbridge).
+ Finished test of SSLeay Tripple-DES patterns.
+
+Wed Sep 15 16:22:17 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndw32.c: New.
+
+Mon Sep 13 10:51:29 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * bithelp.h: New.
+ * rmd160.h, sha1.h, md5.h: Use the rol macro from bithelp.h
+
+Tue Sep 7 16:23:36 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Fixed seds for latest egcc. By Ollivier Robert.
+
+Mon Sep 6 19:59:08 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * des.c (selftest): Add some testpattern
+
+Mon Aug 30 20:38:33 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (do_cbc_encrypt): Fixed serious bug occuring when not using
+ in place encryption. Pointed out by Frank Stajano.
+
+Mon Jul 26 09:34:46 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md5.c (md5_final): Fix for a SCO cpp bug.
+
+Thu Jul 15 10:15:35 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * elgamal.c (elg_check_secret_key,elg_encrypt
+ elg_decrypt,elg_sign,elg_verify): Sanity check on the args.
+ * dsa.c (dsa_check_secret_key,dsa_sign,dsa_verify): Ditto.
+
+ * pubkey.c (disable_pubkey_algo): New.
+ (check_pubkey_algo2): Look at disabled algo table.
+ * cipher.c (disable_cipher_algo): New.
+ (check_cipher_algo): Look at disabled algo table.
+
+Wed Jul 7 13:08:40 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Support for libtool.
+
+Fri Jul 2 11:45:54 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dsa.c (gen_k): Changed algorithm to consume less random bytes
+ * elgamal.c (gen_k): Ditto.
+
+ * random.c (random_dump_stats): New.
+
+Thu Jul 1 12:47:31 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * primegen.c, elgamal.c, dsa.c (progess): New and replaced all
+ fputc with a call to this function.
+
+Sat Jun 26 12:15:59 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndegd.c (do_write): s/ssize_t/int/ due to SunOS 4.1 probs.
+
+ * cipher.c (do_cbc_encrypt, do_cbc_decrypt): New.
+
+ * dynload.c (HAVE_DL_SHL_LOAD): Map hpux API to dlopen (Dave Dykstra).
+ * Makefile.am (install-exec-hook): Removed.
+
+Sun May 23 14:20:22 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (setup_cipher_table): Enable Twofish
+
+ * random.c (fast_random_poll): Disable use of times() for mingw32.
+
+Mon May 17 21:54:43 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (register_internal_cipher_extension): Minor init fix.
+
+Tue May 4 15:47:53 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * primegen.c (gen_prime): Readded the Fermat test. Fixed the bug
+ that we didn't correct for step when passing the prime to the
+ Rabin-Miller test which led to bad performance (Stefan Keller).
+ (check_prime): Add a first Fermat test.
+
+Sun Apr 18 10:11:28 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (cipher_setiv): Add ivlen arg, changed all callers.
+
+ * random.c (randomize_buffer): alway use secure memory because
+ we can't use m_is_secure() on a statically allocated buffer.
+
+ * twofish.c: Replaced some macros by a loop to reduce text size.
+ * Makefile.am (twofish): No more need for sed editing.
+
+Fri Apr 9 12:26:25 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (cipher_open): Reversed the changes for AUTO_CFB.
+
+ * blowfish.c: Dropped the Blowfish 160 mode.
+ * cipher.c (cipher_open): Ditto.
+ (setup_cipher_table): Ditto. And removed support of twofish128
+
+Wed Apr 7 20:51:39 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (get_random_bits): Can now handle requests > POOLSIZE
+
+ * cipher.c (cipher_open): Now uses standard CFB for automode if
+ the blocksize is gt 8 (according to rfc2440).
+
+ * twofish.c: Applied Matthew Skala's patches for 256 bit key.
+
+Tue Apr 6 19:58:12 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (get_random_bits): Can now handle requests > POOLSIZE
+
+ * cipher.c (cipher_open): Now uses standard CFB for automode if
+ the blocksize is gt 8 (according to rfc2440).
+
+Sat Mar 20 11:44:21 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndlinux.c (tty_printf) [IS_MODULE]: Removed.
+
+ * rndegd.c (gather_random): Some fixes.
+
+Wed Mar 17 13:09:03 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndegd.c (do_read): New.
+ (gather_random): Changed the implementation.
+
+Mon Mar 8 20:47:17 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (DLSYM_NEEDS_UNDERSCORE): Renamed.
+
+Fri Feb 26 17:55:41 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md.c: Nearly a total rewrote.
+
+Wed Feb 24 11:07:27 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (context): Fixed alignment
+ * md.c: Ditto.
+
+ * rndegd.c: New
+
+Mon Feb 22 20:04:00 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndegd.c: New.
+
+Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Modules are now figured out by configure
+ * construct.c: New. Generated by configure. Changed all modules
+ to work with that.
+ * sha1.h: Removed.
+ * md5.h: Removed.
+
+ * twofish.c: Changed interface to allow Twofish/256
+
+ * rndunix.c (start_gatherer): Die on SIGPIPE.
+
+Wed Jan 20 18:59:49 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndunix.c (gather_random): Fix to avoid infinite loop.
+
+Sun Jan 17 11:04:33 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * des.c (is_weak_key): Replace system memcmp due to bugs
+ in SunOS's memcmp.
+ (des_get_info): Return error on failed selftest.
+ * twofish.c (twofish_setkey): Return error on failed selftest or
+ invalid keylength.
+ * cast5.c (cast_setkey): Ditto.
+ * blowfish.c (bf_setkey): Return error on failed selftest.
+
+Tue Jan 12 11:17:18 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (random_is_faked): New.
+
+ * tiger.c: Only compile if we have the u64 type
+
+Sat Jan 9 16:02:23 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndunix.c (gather_random): check for setuid.
+
+ * Makefile.am: Add a way to staically link random modules
+
+Thu Jan 7 18:00:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md.c (md_stop_debug): Do a flush first.
+ (md_open): size of buffer now depends on the secure parameter
+
+Sun Jan 3 15:28:44 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndunix.c (start_gatherer): Fixed stupid ==/= bug
+
+1998-12-31 Geoff Keating <geoffk@ozemail.com.au>
+
+ * des.c (is_weak_key): Rewrite loop end condition.
+
+Tue Dec 29 14:41:47 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c: add unistd.h for getpid().
+ (RAND_MAX): Fallback value for Sun.
+
+Wed Dec 23 17:12:24 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md.c (md_copy): Reset debug.
+
+Mon Dec 14 21:18:49 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (read_random_source): Changed the interface to the
+ random gathering function.
+ (gather_faked): Use new interface.
+ * dynload.c (dynload_getfnc_fast_random_poll): Ditto.
+ (dynload_getfnc_gather_random): Ditto.
+ * rndlinux.c (gather_random): Ditto.
+ * rndunix.c (gather_random): Ditto.
+
+Sat Dec 12 18:40:32 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (SYMBOL_VERSION): New to cope with system which needs
+ underscores.
+
+ * rndunix.c: Rewrote large parts
+
+Thu Dec 10 20:15:36 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (load_extension): increased needed verbosity level.
+
+ * random.c (fast_random_poll): Fallback to a default fast random
+ poll function.
+ (read_random_source): Always use the faked entroy gatherer if no
+ gather module is available.
+ * rndlinux.c (fast_poll): Removed.
+ * rndunix.c (fast_poll): Removed.
+
+
+Wed Nov 25 12:33:41 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-*.c: Removed.
+ * rndlinux.c : New.
+ * rndunix.c : New.
+ * random.c : Restructured the interface to the gather modules.
+ (intialize): Call constructor functions
+ (read_radnom_source): Moved to here.
+ * dynload.c (dynload_getfnc_gather_random): New.
+ (dynload_getfnc_fast_random_poll): New.
+ (register_internal_cipher_extension): New.
+ (register_cipher_extension): Support of internal modules.
+
+Sun Nov 8 17:44:36 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-unix.c (read_random_source): Removed the assert.
+
+Mon Oct 19 18:34:30 1998 me,,, (wk@tobold)
+
+ * pubkey.c: Hack to allow us to give some info about RSA keys back.
+
+Thu Oct 15 11:47:57 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dynload.c: Support for DLD
+
+Wed Oct 14 12:13:07 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-unix.c: Now uses names from configure for /dev/random.
+
+1998-10-10 SL Baur <steve@altair.xemacs.org>
+
+ * Makefile.am: fix sed -O substitutions to catch -O6, etc.
+
+Tue Oct 6 10:06:32 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-unix.c (HAVE_GETTIMEOFDAY): Fixed (was ..GETTIMEOFTIME :-)
+ * rand-dummy.c (HAVE_GETTIMEOFDAY): Ditto.
+
+Mon Sep 28 13:23:09 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_digest): New.
+ (md_reset): New.
+
+Wed Sep 23 12:27:02 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c (TIGER_CONTEXT): moved "buf", so that it is 64 bit aligned.
+
+Mon Sep 21 06:22:53 1998 Werner Koch (wk@(none))
+
+ * des.c: Some patches from Michael.
+
+Thu Sep 17 19:00:06 1998 Werner Koch (wk@(none))
+
+ * des.c : New file from Michael Roth <mroth@nessie.de>
+
+Mon Sep 14 11:10:55 1998 Werner Koch (wk@(none))
+
+ * blowfish.c (bf_setkey): Niklas Hernaeus patch to detect weak keys.
+
+Mon Sep 14 09:19:25 1998 Werner Koch (wk@(none))
+
+ * dynload.c (RTLD_NOW): Now defined to 1 if it is undefined.
+
+Mon Sep 7 17:04:33 1998 Werner Koch (wk@(none))
+
+ * Makefile.am: Fixes to allow a different build directory
+
+Thu Aug 6 17:25:38 1998 Werner Koch,mobil,,, (wk@tobold)
+
+ * random.c (get_random_byte): Removed and changed all callers
+ to use get_random_bits()
+
+Mon Jul 27 10:30:22 1998 Werner Koch (wk@(none))
+
+ * cipher.c : Support for other blocksizes
+ (cipher_get_blocksize): New.
+ * twofish.c: New.
+ * Makefile.am: Add twofish module.
+
+Mon Jul 13 21:30:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (read_pool): Simple alloc if secure_alloc is not set.
+ (get_random_bits): Ditto.
+
+Thu Jul 9 13:01:14 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dynload.c (load_extension): Function now nbails out if
+ the program is run setuid.
+
+Wed Jul 8 18:58:23 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (rmd160_hash_buffer): New.
+
+Thu Jul 2 10:50:30 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c (cipher_open): algos >=100 use standard CFB
+
+Thu Jun 25 11:18:25 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * Makefile.am: Support for extensions
+
+Thu Jun 18 12:09:38 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (mix_pool): simpler handling for level 0
+
+Mon Jun 15 14:40:48 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c: Removed from dist, will reappear as dynload module
+
+Sat Jun 13 14:16:57 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * pubkey.c: Major changes to allow extensions. Changed the inteface
+ of all public key ciphers and added the ability to load extensions
+ on demand.
+
+ * misc.c: Removed.
+
+Wed Jun 10 07:52:08 1998 Werner Koch,mobil,,, (wk@tobold)
+
+ * dynload.c: New.
+ * cipher.c: Major changes to allow extensions.
+
+Mon Jun 8 22:43:00 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c: Major internal chnages to support extensions.
+ * blowfish.c (blowfish_get_info): New and made all internal
+ functions static, changed heder.
+ * cast5.c (cast5_get_info): Likewise.
+
+Mon Jun 8 12:27:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c (transform): Fix for big endian
+
+ * cipher.c (do_cfb_decrypt): Big endian fix.
+
+Fri May 22 07:30:39 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_get_oid): Add a new one for TIGER.
+
+Thu May 21 13:24:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c: Add support for a dummy cipher
+
+Thu May 14 15:40:36 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (transform): fixed sigbus - I should better
+ add Christian von Roques's new implemenation of rmd160_write.
+
+Fri May 8 18:07:44 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-internal.h, rand-unix.c, rand-w32.c, rand_dummy.c: New
+ * random.c: Moved system specific functions to rand-****.c
+
+Fri May 8 14:01:17 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (fast_random_poll): add call to gethrtime.
+
+Tue May 5 21:28:55 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * elgamal.c (elg_generate): choosing x was not correct, could
+ yield 6 bytes which are not from the random pool, tsss, tsss..
+
+Tue May 5 14:09:06 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * primegen.c (generate_elg_prime): Add arg mode, changed all
+ callers and implemented mode 1.
+
+Mon Apr 27 14:41:58 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c (cipher_get_keylen): New.
+
+Sun Apr 26 14:44:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c, tiger.h: New.
+
+Wed Apr 8 14:57:11 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * misc.c (check_pubkey_algo2): New.
+
+Tue Apr 7 18:46:49 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c: New
+ * misc.c (check_cipher_algo): Moved to cipher.c
+ * cast5.c: Moved many functions to cipher.c
+ * blowfish.c: Likewise.
+
+Sat Apr 4 19:52:08 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cast5.c: Implemented and tested.
+
+Wed Apr 1 16:38:27 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * elgamal.c (elg_generate): Faster generation of x in some cases.
+
+Thu Mar 19 13:54:48 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * blowfish.c (blowfish_decode_cfb): changed XOR operation
+ (blowfish_encode_cfb): Ditto.
+
+Thu Mar 12 14:04:05 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * sha1.c (transform): Rewrote
+
+ * blowfish.c (encrypt): Unrolled for rounds == 16
+ (decrypt): Ditto.
+
+Tue Mar 10 16:32:08 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (transform): Unrolled the loop.
+
+Tue Mar 10 13:05:14 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (read_pool): Add pool_balance stuff.
+ (get_random_bits): New.
+
+ * elgamal.c (elg_generate): Now uses get_random_bits to generate x.
+
+
+Tue Mar 10 11:33:51 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_digest_length): New.
+
+Tue Mar 10 11:27:41 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dsa.c (dsa_verify): Works.
+
+Mon Mar 9 12:59:08 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dsa.c, dsa.h: Removed some unused code.
+
+Wed Mar 4 10:39:22 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_open): Add call to fast_random_poll.
+ blowfish.c (blowfish_setkey): Ditto.
+
+Tue Mar 3 13:32:54 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (rmd160_mixblock): New.
+ * random.c: Restructured to start with a new RNG implementation.
+ * random.h: New.
+
+Mon Mar 2 19:21:46 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * gost.c, gost.h: Removed because they did only contain trash.
+
+Sun Mar 1 16:42:29 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (fill_buffer): removed error message if n == -1.
+
+Fri Feb 27 16:39:34 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_enable): No init if called twice.
+
+Thu Feb 26 07:57:02 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * primegen.c (generate_elg_prime): Changed the progress printing.
+ (gen_prime): Ditto.
+
+Tue Feb 24 12:28:42 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md5.c, md.5 : Replaced by a modified version of md5.c from
+ GNU textutils 1.22.
+
+Wed Feb 18 14:08:30 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c, md.h : New debugging support
+
+Mon Feb 16 10:08:47 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * misc.c (cipher_algo_to_string): New
+ (pubkey_algo_to_string): New.
+ (digest_algo_to_string): New.
+
+
+ Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+ This file is free software; as a special exception the author gives
+ unlimited permission to copy and/or distribute it, with or without
+ modifications, as long as this notice is preserved.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/grub-core/lib/libgcrypt-grub/cipher/arcfour.c b/grub-core/lib/libgcrypt-grub/cipher/arcfour.c
new file mode 100644
index 0000000..9d82360
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/arcfour.c
@@ -0,0 +1,143 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* arcfour.c - The arcfour stream cipher
+ * Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * For a description of the algorithm, see:
+ * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996.
+ * ISBN 0-471-11709-9. Pages 397 ff.
+ */
+
+
+#include "types.h"
+#include "g10lib.h"
+#include "cipher.h"
+
+
+typedef struct {
+ int idx_i, idx_j;
+ byte sbox[256];
+} ARCFOUR_context;
+
+static void
+do_encrypt_stream( ARCFOUR_context *ctx,
+ byte *outbuf, const byte *inbuf, unsigned int length )
+{
+ register int i = ctx->idx_i;
+ register int j = ctx->idx_j;
+ register byte *sbox = ctx->sbox;
+ register int t;
+
+ while ( length-- )
+ {
+ i++;
+ i = i & 255; /* The and-op seems to be faster than the mod-op. */
+ j += sbox[i];
+ j &= 255;
+ t = sbox[i]; sbox[i] = sbox[j]; sbox[j] = t;
+ *outbuf++ = *inbuf++ ^ sbox[(sbox[i] + sbox[j]) & 255];
+ }
+
+ ctx->idx_i = i;
+ ctx->idx_j = j;
+}
+
+static void
+encrypt_stream (void *context,
+ byte *outbuf, const byte *inbuf, unsigned int length)
+{
+ ARCFOUR_context *ctx = (ARCFOUR_context *) context;
+ do_encrypt_stream (ctx, outbuf, inbuf, length );
+ _gcry_burn_stack (64);
+}
+
+
+static gcry_err_code_t
+do_arcfour_setkey (void *context, const byte *key, unsigned int keylen)
+{
+ static int initialized;
+ static const char* selftest_failed;
+ int i, j;
+ byte karr[256];
+ ARCFOUR_context *ctx = (ARCFOUR_context *) context;
+
+ if (!initialized )
+ {
+ initialized = 1;
+ selftest_failed = selftest();
+ if( selftest_failed )
+ log_error ("ARCFOUR selftest failed (%s)\n", selftest_failed );
+ }
+ if( selftest_failed )
+ return GPG_ERR_SELFTEST_FAILED;
+
+ if( keylen < 40/8 ) /* we want at least 40 bits */
+ return GPG_ERR_INV_KEYLEN;
+
+ ctx->idx_i = ctx->idx_j = 0;
+ for (i=0; i < 256; i++ )
+ ctx->sbox[i] = i;
+ for (i=0; i < 256; i++ )
+ karr[i] = key[i%keylen];
+ for (i=j=0; i < 256; i++ )
+ {
+ int t;
+ j = (j + ctx->sbox[i] + karr[i]) % 256;
+ t = ctx->sbox[i];
+ ctx->sbox[i] = ctx->sbox[j];
+ ctx->sbox[j] = t;
+ }
+ memset( karr, 0, 256 );
+
+ return GPG_ERR_NO_ERROR;
+}
+
+static gcry_err_code_t
+arcfour_setkey ( void *context, const byte *key, unsigned int keylen )
+{
+ ARCFOUR_context *ctx = (ARCFOUR_context *) context;
+ gcry_err_code_t rc = do_arcfour_setkey (ctx, key, keylen );
+ _gcry_burn_stack (300);
+ return rc;
+}
+
+
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_arcfour =
+ {
+ "ARCFOUR", NULL, NULL, 1, 128, sizeof (ARCFOUR_context),
+ arcfour_setkey, NULL, NULL, encrypt_stream, encrypt_stream,
+#ifdef GRUB_UTIL
+ .modname = "gcry_arcfour",
+#endif
+ };
+
+
+GRUB_MOD_INIT(gcry_arcfour)
+{
+ grub_cipher_register (&_gcry_cipher_spec_arcfour);
+}
+
+GRUB_MOD_FINI(gcry_arcfour)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_arcfour);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/bithelp.h b/grub-core/lib/libgcrypt-grub/cipher/bithelp.h
new file mode 100644
index 0000000..e957b4e
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/bithelp.h
@@ -0,0 +1,57 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+/* bithelp.h - Some bit manipulation helpers
+ * Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+#ifndef G10_BITHELP_H
+#define G10_BITHELP_H
+
+
+/****************
+ * Rotate the 32 bit unsigned integer X by N bits left/right
+ */
+#if defined(__GNUC__) && defined(__i386__)
+static inline u32
+rol( u32 x, int n)
+{
+ __asm__("roll %%cl,%0"
+ :"=r" (x)
+ :"0" (x),"c" (n));
+ return x;
+}
+#else
+#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
+#endif
+
+#if defined(__GNUC__) && defined(__i386__)
+static inline u32
+ror(u32 x, int n)
+{
+ __asm__("rorl %%cl,%0"
+ :"=r" (x)
+ :"0" (x),"c" (n));
+ return x;
+}
+#else
+#define ror(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) )
+#endif
+
+
+#endif /*G10_BITHELP_H*/
diff --git a/grub-core/lib/libgcrypt-grub/cipher/blowfish.c b/grub-core/lib/libgcrypt-grub/cipher/blowfish.c
new file mode 100644
index 0000000..612bfce
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/blowfish.c
@@ -0,0 +1,592 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* blowfish.c - Blowfish encryption
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * For a description of the algorithm, see:
+ * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996.
+ * ISBN 0-471-11709-9. Pages 336 ff.
+ */
+
+/* Test values:
+ * key "abcdefghijklmnopqrstuvwxyz";
+ * plain "BLOWFISH"
+ * cipher 32 4E D0 FE F4 13 A2 03
+ *
+ */
+
+#include "types.h"
+#include "g10lib.h"
+#include "cipher.h"
+
+#define BLOWFISH_BLOCKSIZE 8
+#define BLOWFISH_ROUNDS 16
+
+typedef struct {
+ u32 s0[256];
+ u32 s1[256];
+ u32 s2[256];
+ u32 s3[256];
+ u32 p[BLOWFISH_ROUNDS+2];
+} BLOWFISH_context;
+
+static gcry_err_code_t bf_setkey (void *c, const byte *key, unsigned keylen);
+static void encrypt_block (void *bc, byte *outbuf, const byte *inbuf);
+static void decrypt_block (void *bc, byte *outbuf, const byte *inbuf);
+
+
+/* precomputed S boxes */
+static const u32 ks0[256] = {
+ 0xD1310BA6,0x98DFB5AC,0x2FFD72DB,0xD01ADFB7,0xB8E1AFED,0x6A267E96,
+ 0xBA7C9045,0xF12C7F99,0x24A19947,0xB3916CF7,0x0801F2E2,0x858EFC16,
+ 0x636920D8,0x71574E69,0xA458FEA3,0xF4933D7E,0x0D95748F,0x728EB658,
+ 0x718BCD58,0x82154AEE,0x7B54A41D,0xC25A59B5,0x9C30D539,0x2AF26013,
+ 0xC5D1B023,0x286085F0,0xCA417918,0xB8DB38EF,0x8E79DCB0,0x603A180E,
+ 0x6C9E0E8B,0xB01E8A3E,0xD71577C1,0xBD314B27,0x78AF2FDA,0x55605C60,
+ 0xE65525F3,0xAA55AB94,0x57489862,0x63E81440,0x55CA396A,0x2AAB10B6,
+ 0xB4CC5C34,0x1141E8CE,0xA15486AF,0x7C72E993,0xB3EE1411,0x636FBC2A,
+ 0x2BA9C55D,0x741831F6,0xCE5C3E16,0x9B87931E,0xAFD6BA33,0x6C24CF5C,
+ 0x7A325381,0x28958677,0x3B8F4898,0x6B4BB9AF,0xC4BFE81B,0x66282193,
+ 0x61D809CC,0xFB21A991,0x487CAC60,0x5DEC8032,0xEF845D5D,0xE98575B1,
+ 0xDC262302,0xEB651B88,0x23893E81,0xD396ACC5,0x0F6D6FF3,0x83F44239,
+ 0x2E0B4482,0xA4842004,0x69C8F04A,0x9E1F9B5E,0x21C66842,0xF6E96C9A,
+ 0x670C9C61,0xABD388F0,0x6A51A0D2,0xD8542F68,0x960FA728,0xAB5133A3,
+ 0x6EEF0B6C,0x137A3BE4,0xBA3BF050,0x7EFB2A98,0xA1F1651D,0x39AF0176,
+ 0x66CA593E,0x82430E88,0x8CEE8619,0x456F9FB4,0x7D84A5C3,0x3B8B5EBE,
+ 0xE06F75D8,0x85C12073,0x401A449F,0x56C16AA6,0x4ED3AA62,0x363F7706,
+ 0x1BFEDF72,0x429B023D,0x37D0D724,0xD00A1248,0xDB0FEAD3,0x49F1C09B,
+ 0x075372C9,0x80991B7B,0x25D479D8,0xF6E8DEF7,0xE3FE501A,0xB6794C3B,
+ 0x976CE0BD,0x04C006BA,0xC1A94FB6,0x409F60C4,0x5E5C9EC2,0x196A2463,
+ 0x68FB6FAF,0x3E6C53B5,0x1339B2EB,0x3B52EC6F,0x6DFC511F,0x9B30952C,
+ 0xCC814544,0xAF5EBD09,0xBEE3D004,0xDE334AFD,0x660F2807,0x192E4BB3,
+ 0xC0CBA857,0x45C8740F,0xD20B5F39,0xB9D3FBDB,0x5579C0BD,0x1A60320A,
+ 0xD6A100C6,0x402C7279,0x679F25FE,0xFB1FA3CC,0x8EA5E9F8,0xDB3222F8,
+ 0x3C7516DF,0xFD616B15,0x2F501EC8,0xAD0552AB,0x323DB5FA,0xFD238760,
+ 0x53317B48,0x3E00DF82,0x9E5C57BB,0xCA6F8CA0,0x1A87562E,0xDF1769DB,
+ 0xD542A8F6,0x287EFFC3,0xAC6732C6,0x8C4F5573,0x695B27B0,0xBBCA58C8,
+ 0xE1FFA35D,0xB8F011A0,0x10FA3D98,0xFD2183B8,0x4AFCB56C,0x2DD1D35B,
+ 0x9A53E479,0xB6F84565,0xD28E49BC,0x4BFB9790,0xE1DDF2DA,0xA4CB7E33,
+ 0x62FB1341,0xCEE4C6E8,0xEF20CADA,0x36774C01,0xD07E9EFE,0x2BF11FB4,
+ 0x95DBDA4D,0xAE909198,0xEAAD8E71,0x6B93D5A0,0xD08ED1D0,0xAFC725E0,
+ 0x8E3C5B2F,0x8E7594B7,0x8FF6E2FB,0xF2122B64,0x8888B812,0x900DF01C,
+ 0x4FAD5EA0,0x688FC31C,0xD1CFF191,0xB3A8C1AD,0x2F2F2218,0xBE0E1777,
+ 0xEA752DFE,0x8B021FA1,0xE5A0CC0F,0xB56F74E8,0x18ACF3D6,0xCE89E299,
+ 0xB4A84FE0,0xFD13E0B7,0x7CC43B81,0xD2ADA8D9,0x165FA266,0x80957705,
+ 0x93CC7314,0x211A1477,0xE6AD2065,0x77B5FA86,0xC75442F5,0xFB9D35CF,
+ 0xEBCDAF0C,0x7B3E89A0,0xD6411BD3,0xAE1E7E49,0x00250E2D,0x2071B35E,
+ 0x226800BB,0x57B8E0AF,0x2464369B,0xF009B91E,0x5563911D,0x59DFA6AA,
+ 0x78C14389,0xD95A537F,0x207D5BA2,0x02E5B9C5,0x83260376,0x6295CFA9,
+ 0x11C81968,0x4E734A41,0xB3472DCA,0x7B14A94A,0x1B510052,0x9A532915,
+ 0xD60F573F,0xBC9BC6E4,0x2B60A476,0x81E67400,0x08BA6FB5,0x571BE91F,
+ 0xF296EC6B,0x2A0DD915,0xB6636521,0xE7B9F9B6,0xFF34052E,0xC5855664,
+ 0x53B02D5D,0xA99F8FA1,0x08BA4799,0x6E85076A };
+
+static const u32 ks1[256] = {
+ 0x4B7A70E9,0xB5B32944,0xDB75092E,0xC4192623,0xAD6EA6B0,0x49A7DF7D,
+ 0x9CEE60B8,0x8FEDB266,0xECAA8C71,0x699A17FF,0x5664526C,0xC2B19EE1,
+ 0x193602A5,0x75094C29,0xA0591340,0xE4183A3E,0x3F54989A,0x5B429D65,
+ 0x6B8FE4D6,0x99F73FD6,0xA1D29C07,0xEFE830F5,0x4D2D38E6,0xF0255DC1,
+ 0x4CDD2086,0x8470EB26,0x6382E9C6,0x021ECC5E,0x09686B3F,0x3EBAEFC9,
+ 0x3C971814,0x6B6A70A1,0x687F3584,0x52A0E286,0xB79C5305,0xAA500737,
+ 0x3E07841C,0x7FDEAE5C,0x8E7D44EC,0x5716F2B8,0xB03ADA37,0xF0500C0D,
+ 0xF01C1F04,0x0200B3FF,0xAE0CF51A,0x3CB574B2,0x25837A58,0xDC0921BD,
+ 0xD19113F9,0x7CA92FF6,0x94324773,0x22F54701,0x3AE5E581,0x37C2DADC,
+ 0xC8B57634,0x9AF3DDA7,0xA9446146,0x0FD0030E,0xECC8C73E,0xA4751E41,
+ 0xE238CD99,0x3BEA0E2F,0x3280BBA1,0x183EB331,0x4E548B38,0x4F6DB908,
+ 0x6F420D03,0xF60A04BF,0x2CB81290,0x24977C79,0x5679B072,0xBCAF89AF,
+ 0xDE9A771F,0xD9930810,0xB38BAE12,0xDCCF3F2E,0x5512721F,0x2E6B7124,
+ 0x501ADDE6,0x9F84CD87,0x7A584718,0x7408DA17,0xBC9F9ABC,0xE94B7D8C,
+ 0xEC7AEC3A,0xDB851DFA,0x63094366,0xC464C3D2,0xEF1C1847,0x3215D908,
+ 0xDD433B37,0x24C2BA16,0x12A14D43,0x2A65C451,0x50940002,0x133AE4DD,
+ 0x71DFF89E,0x10314E55,0x81AC77D6,0x5F11199B,0x043556F1,0xD7A3C76B,
+ 0x3C11183B,0x5924A509,0xF28FE6ED,0x97F1FBFA,0x9EBABF2C,0x1E153C6E,
+ 0x86E34570,0xEAE96FB1,0x860E5E0A,0x5A3E2AB3,0x771FE71C,0x4E3D06FA,
+ 0x2965DCB9,0x99E71D0F,0x803E89D6,0x5266C825,0x2E4CC978,0x9C10B36A,
+ 0xC6150EBA,0x94E2EA78,0xA5FC3C53,0x1E0A2DF4,0xF2F74EA7,0x361D2B3D,
+ 0x1939260F,0x19C27960,0x5223A708,0xF71312B6,0xEBADFE6E,0xEAC31F66,
+ 0xE3BC4595,0xA67BC883,0xB17F37D1,0x018CFF28,0xC332DDEF,0xBE6C5AA5,
+ 0x65582185,0x68AB9802,0xEECEA50F,0xDB2F953B,0x2AEF7DAD,0x5B6E2F84,
+ 0x1521B628,0x29076170,0xECDD4775,0x619F1510,0x13CCA830,0xEB61BD96,
+ 0x0334FE1E,0xAA0363CF,0xB5735C90,0x4C70A239,0xD59E9E0B,0xCBAADE14,
+ 0xEECC86BC,0x60622CA7,0x9CAB5CAB,0xB2F3846E,0x648B1EAF,0x19BDF0CA,
+ 0xA02369B9,0x655ABB50,0x40685A32,0x3C2AB4B3,0x319EE9D5,0xC021B8F7,
+ 0x9B540B19,0x875FA099,0x95F7997E,0x623D7DA8,0xF837889A,0x97E32D77,
+ 0x11ED935F,0x16681281,0x0E358829,0xC7E61FD6,0x96DEDFA1,0x7858BA99,
+ 0x57F584A5,0x1B227263,0x9B83C3FF,0x1AC24696,0xCDB30AEB,0x532E3054,
+ 0x8FD948E4,0x6DBC3128,0x58EBF2EF,0x34C6FFEA,0xFE28ED61,0xEE7C3C73,
+ 0x5D4A14D9,0xE864B7E3,0x42105D14,0x203E13E0,0x45EEE2B6,0xA3AAABEA,
+ 0xDB6C4F15,0xFACB4FD0,0xC742F442,0xEF6ABBB5,0x654F3B1D,0x41CD2105,
+ 0xD81E799E,0x86854DC7,0xE44B476A,0x3D816250,0xCF62A1F2,0x5B8D2646,
+ 0xFC8883A0,0xC1C7B6A3,0x7F1524C3,0x69CB7492,0x47848A0B,0x5692B285,
+ 0x095BBF00,0xAD19489D,0x1462B174,0x23820E00,0x58428D2A,0x0C55F5EA,
+ 0x1DADF43E,0x233F7061,0x3372F092,0x8D937E41,0xD65FECF1,0x6C223BDB,
+ 0x7CDE3759,0xCBEE7460,0x4085F2A7,0xCE77326E,0xA6078084,0x19F8509E,
+ 0xE8EFD855,0x61D99735,0xA969A7AA,0xC50C06C2,0x5A04ABFC,0x800BCADC,
+ 0x9E447A2E,0xC3453484,0xFDD56705,0x0E1E9EC9,0xDB73DBD3,0x105588CD,
+ 0x675FDA79,0xE3674340,0xC5C43465,0x713E38D8,0x3D28F89E,0xF16DFF20,
+ 0x153E21E7,0x8FB03D4A,0xE6E39F2B,0xDB83ADF7 };
+
+static const u32 ks2[256] = {
+ 0xE93D5A68,0x948140F7,0xF64C261C,0x94692934,0x411520F7,0x7602D4F7,
+ 0xBCF46B2E,0xD4A20068,0xD4082471,0x3320F46A,0x43B7D4B7,0x500061AF,
+ 0x1E39F62E,0x97244546,0x14214F74,0xBF8B8840,0x4D95FC1D,0x96B591AF,
+ 0x70F4DDD3,0x66A02F45,0xBFBC09EC,0x03BD9785,0x7FAC6DD0,0x31CB8504,
+ 0x96EB27B3,0x55FD3941,0xDA2547E6,0xABCA0A9A,0x28507825,0x530429F4,
+ 0x0A2C86DA,0xE9B66DFB,0x68DC1462,0xD7486900,0x680EC0A4,0x27A18DEE,
+ 0x4F3FFEA2,0xE887AD8C,0xB58CE006,0x7AF4D6B6,0xAACE1E7C,0xD3375FEC,
+ 0xCE78A399,0x406B2A42,0x20FE9E35,0xD9F385B9,0xEE39D7AB,0x3B124E8B,
+ 0x1DC9FAF7,0x4B6D1856,0x26A36631,0xEAE397B2,0x3A6EFA74,0xDD5B4332,
+ 0x6841E7F7,0xCA7820FB,0xFB0AF54E,0xD8FEB397,0x454056AC,0xBA489527,
+ 0x55533A3A,0x20838D87,0xFE6BA9B7,0xD096954B,0x55A867BC,0xA1159A58,
+ 0xCCA92963,0x99E1DB33,0xA62A4A56,0x3F3125F9,0x5EF47E1C,0x9029317C,
+ 0xFDF8E802,0x04272F70,0x80BB155C,0x05282CE3,0x95C11548,0xE4C66D22,
+ 0x48C1133F,0xC70F86DC,0x07F9C9EE,0x41041F0F,0x404779A4,0x5D886E17,
+ 0x325F51EB,0xD59BC0D1,0xF2BCC18F,0x41113564,0x257B7834,0x602A9C60,
+ 0xDFF8E8A3,0x1F636C1B,0x0E12B4C2,0x02E1329E,0xAF664FD1,0xCAD18115,
+ 0x6B2395E0,0x333E92E1,0x3B240B62,0xEEBEB922,0x85B2A20E,0xE6BA0D99,
+ 0xDE720C8C,0x2DA2F728,0xD0127845,0x95B794FD,0x647D0862,0xE7CCF5F0,
+ 0x5449A36F,0x877D48FA,0xC39DFD27,0xF33E8D1E,0x0A476341,0x992EFF74,
+ 0x3A6F6EAB,0xF4F8FD37,0xA812DC60,0xA1EBDDF8,0x991BE14C,0xDB6E6B0D,
+ 0xC67B5510,0x6D672C37,0x2765D43B,0xDCD0E804,0xF1290DC7,0xCC00FFA3,
+ 0xB5390F92,0x690FED0B,0x667B9FFB,0xCEDB7D9C,0xA091CF0B,0xD9155EA3,
+ 0xBB132F88,0x515BAD24,0x7B9479BF,0x763BD6EB,0x37392EB3,0xCC115979,
+ 0x8026E297,0xF42E312D,0x6842ADA7,0xC66A2B3B,0x12754CCC,0x782EF11C,
+ 0x6A124237,0xB79251E7,0x06A1BBE6,0x4BFB6350,0x1A6B1018,0x11CAEDFA,
+ 0x3D25BDD8,0xE2E1C3C9,0x44421659,0x0A121386,0xD90CEC6E,0xD5ABEA2A,
+ 0x64AF674E,0xDA86A85F,0xBEBFE988,0x64E4C3FE,0x9DBC8057,0xF0F7C086,
+ 0x60787BF8,0x6003604D,0xD1FD8346,0xF6381FB0,0x7745AE04,0xD736FCCC,
+ 0x83426B33,0xF01EAB71,0xB0804187,0x3C005E5F,0x77A057BE,0xBDE8AE24,
+ 0x55464299,0xBF582E61,0x4E58F48F,0xF2DDFDA2,0xF474EF38,0x8789BDC2,
+ 0x5366F9C3,0xC8B38E74,0xB475F255,0x46FCD9B9,0x7AEB2661,0x8B1DDF84,
+ 0x846A0E79,0x915F95E2,0x466E598E,0x20B45770,0x8CD55591,0xC902DE4C,
+ 0xB90BACE1,0xBB8205D0,0x11A86248,0x7574A99E,0xB77F19B6,0xE0A9DC09,
+ 0x662D09A1,0xC4324633,0xE85A1F02,0x09F0BE8C,0x4A99A025,0x1D6EFE10,
+ 0x1AB93D1D,0x0BA5A4DF,0xA186F20F,0x2868F169,0xDCB7DA83,0x573906FE,
+ 0xA1E2CE9B,0x4FCD7F52,0x50115E01,0xA70683FA,0xA002B5C4,0x0DE6D027,
+ 0x9AF88C27,0x773F8641,0xC3604C06,0x61A806B5,0xF0177A28,0xC0F586E0,
+ 0x006058AA,0x30DC7D62,0x11E69ED7,0x2338EA63,0x53C2DD94,0xC2C21634,
+ 0xBBCBEE56,0x90BCB6DE,0xEBFC7DA1,0xCE591D76,0x6F05E409,0x4B7C0188,
+ 0x39720A3D,0x7C927C24,0x86E3725F,0x724D9DB9,0x1AC15BB4,0xD39EB8FC,
+ 0xED545578,0x08FCA5B5,0xD83D7CD3,0x4DAD0FC4,0x1E50EF5E,0xB161E6F8,
+ 0xA28514D9,0x6C51133C,0x6FD5C7E7,0x56E14EC4,0x362ABFCE,0xDDC6C837,
+ 0xD79A3234,0x92638212,0x670EFA8E,0x406000E0 };
+
+static const u32 ks3[256] = {
+ 0x3A39CE37,0xD3FAF5CF,0xABC27737,0x5AC52D1B,0x5CB0679E,0x4FA33742,
+ 0xD3822740,0x99BC9BBE,0xD5118E9D,0xBF0F7315,0xD62D1C7E,0xC700C47B,
+ 0xB78C1B6B,0x21A19045,0xB26EB1BE,0x6A366EB4,0x5748AB2F,0xBC946E79,
+ 0xC6A376D2,0x6549C2C8,0x530FF8EE,0x468DDE7D,0xD5730A1D,0x4CD04DC6,
+ 0x2939BBDB,0xA9BA4650,0xAC9526E8,0xBE5EE304,0xA1FAD5F0,0x6A2D519A,
+ 0x63EF8CE2,0x9A86EE22,0xC089C2B8,0x43242EF6,0xA51E03AA,0x9CF2D0A4,
+ 0x83C061BA,0x9BE96A4D,0x8FE51550,0xBA645BD6,0x2826A2F9,0xA73A3AE1,
+ 0x4BA99586,0xEF5562E9,0xC72FEFD3,0xF752F7DA,0x3F046F69,0x77FA0A59,
+ 0x80E4A915,0x87B08601,0x9B09E6AD,0x3B3EE593,0xE990FD5A,0x9E34D797,
+ 0x2CF0B7D9,0x022B8B51,0x96D5AC3A,0x017DA67D,0xD1CF3ED6,0x7C7D2D28,
+ 0x1F9F25CF,0xADF2B89B,0x5AD6B472,0x5A88F54C,0xE029AC71,0xE019A5E6,
+ 0x47B0ACFD,0xED93FA9B,0xE8D3C48D,0x283B57CC,0xF8D56629,0x79132E28,
+ 0x785F0191,0xED756055,0xF7960E44,0xE3D35E8C,0x15056DD4,0x88F46DBA,
+ 0x03A16125,0x0564F0BD,0xC3EB9E15,0x3C9057A2,0x97271AEC,0xA93A072A,
+ 0x1B3F6D9B,0x1E6321F5,0xF59C66FB,0x26DCF319,0x7533D928,0xB155FDF5,
+ 0x03563482,0x8ABA3CBB,0x28517711,0xC20AD9F8,0xABCC5167,0xCCAD925F,
+ 0x4DE81751,0x3830DC8E,0x379D5862,0x9320F991,0xEA7A90C2,0xFB3E7BCE,
+ 0x5121CE64,0x774FBE32,0xA8B6E37E,0xC3293D46,0x48DE5369,0x6413E680,
+ 0xA2AE0810,0xDD6DB224,0x69852DFD,0x09072166,0xB39A460A,0x6445C0DD,
+ 0x586CDECF,0x1C20C8AE,0x5BBEF7DD,0x1B588D40,0xCCD2017F,0x6BB4E3BB,
+ 0xDDA26A7E,0x3A59FF45,0x3E350A44,0xBCB4CDD5,0x72EACEA8,0xFA6484BB,
+ 0x8D6612AE,0xBF3C6F47,0xD29BE463,0x542F5D9E,0xAEC2771B,0xF64E6370,
+ 0x740E0D8D,0xE75B1357,0xF8721671,0xAF537D5D,0x4040CB08,0x4EB4E2CC,
+ 0x34D2466A,0x0115AF84,0xE1B00428,0x95983A1D,0x06B89FB4,0xCE6EA048,
+ 0x6F3F3B82,0x3520AB82,0x011A1D4B,0x277227F8,0x611560B1,0xE7933FDC,
+ 0xBB3A792B,0x344525BD,0xA08839E1,0x51CE794B,0x2F32C9B7,0xA01FBAC9,
+ 0xE01CC87E,0xBCC7D1F6,0xCF0111C3,0xA1E8AAC7,0x1A908749,0xD44FBD9A,
+ 0xD0DADECB,0xD50ADA38,0x0339C32A,0xC6913667,0x8DF9317C,0xE0B12B4F,
+ 0xF79E59B7,0x43F5BB3A,0xF2D519FF,0x27D9459C,0xBF97222C,0x15E6FC2A,
+ 0x0F91FC71,0x9B941525,0xFAE59361,0xCEB69CEB,0xC2A86459,0x12BAA8D1,
+ 0xB6C1075E,0xE3056A0C,0x10D25065,0xCB03A442,0xE0EC6E0E,0x1698DB3B,
+ 0x4C98A0BE,0x3278E964,0x9F1F9532,0xE0D392DF,0xD3A0342B,0x8971F21E,
+ 0x1B0A7441,0x4BA3348C,0xC5BE7120,0xC37632D8,0xDF359F8D,0x9B992F2E,
+ 0xE60B6F47,0x0FE3F11D,0xE54CDA54,0x1EDAD891,0xCE6279CF,0xCD3E7E6F,
+ 0x1618B166,0xFD2C1D05,0x848FD2C5,0xF6FB2299,0xF523F357,0xA6327623,
+ 0x93A83531,0x56CCCD02,0xACF08162,0x5A75EBB5,0x6E163697,0x88D273CC,
+ 0xDE966292,0x81B949D0,0x4C50901B,0x71C65614,0xE6C6C7BD,0x327A140A,
+ 0x45E1D006,0xC3F27B9A,0xC9AA53FD,0x62A80F00,0xBB25BFE2,0x35BDD2F6,
+ 0x71126905,0xB2040222,0xB6CBCF7C,0xCD769C2B,0x53113EC0,0x1640E3D3,
+ 0x38ABBD60,0x2547ADF0,0xBA38209C,0xF746CE76,0x77AFA1C5,0x20756060,
+ 0x85CBFE4E,0x8AE88DD8,0x7AAAF9B0,0x4CF9AA7E,0x1948C25C,0x02FB8A8C,
+ 0x01C36AE4,0xD6EBE1F9,0x90D4F869,0xA65CDEA0,0x3F09252D,0xC208E69F,
+ 0xB74E6132,0xCE77E25B,0x578FDFE3,0x3AC372E6 };
+
+static const u32 ps[BLOWFISH_ROUNDS+2] = {
+ 0x243F6A88,0x85A308D3,0x13198A2E,0x03707344,0xA4093822,0x299F31D0,
+ 0x082EFA98,0xEC4E6C89,0x452821E6,0x38D01377,0xBE5466CF,0x34E90C6C,
+ 0xC0AC29B7,0xC97C50DD,0x3F84D5B5,0xB5470917,0x9216D5D9,0x8979FB1B };
+
+
+
+#if BLOWFISH_ROUNDS != 16
+static inline u32
+function_F( BLOWFISH_context *bc, u32 x )
+{
+ u16 a, b, c, d;
+
+#ifdef WORDS_BIGENDIAN
+ a = ((byte*)&x)[0];
+ b = ((byte*)&x)[1];
+ c = ((byte*)&x)[2];
+ d = ((byte*)&x)[3];
+#else
+ a = ((byte*)&x)[3];
+ b = ((byte*)&x)[2];
+ c = ((byte*)&x)[1];
+ d = ((byte*)&x)[0];
+#endif
+
+ return ((bc->s0[a] + bc->s1[b]) ^ bc->s2[c] ) + bc->s3[d];
+}
+#endif
+
+#ifdef WORDS_BIGENDIAN
+#define F(x) ((( s0[((byte*)&x)[0]] + s1[((byte*)&x)[1]]) \
+ ^ s2[((byte*)&x)[2]]) + s3[((byte*)&x)[3]] )
+#else
+#define F(x) ((( s0[((byte*)&x)[3]] + s1[((byte*)&x)[2]]) \
+ ^ s2[((byte*)&x)[1]]) + s3[((byte*)&x)[0]] )
+#endif
+#define R(l,r,i) do { l ^= p[i]; r ^= F(l); } while(0)
+
+
+static void
+do_encrypt ( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
+{
+#if BLOWFISH_ROUNDS == 16
+ u32 xl, xr, *s0, *s1, *s2, *s3, *p;
+
+ xl = *ret_xl;
+ xr = *ret_xr;
+ p = bc->p;
+ s0 = bc->s0;
+ s1 = bc->s1;
+ s2 = bc->s2;
+ s3 = bc->s3;
+
+ R( xl, xr, 0);
+ R( xr, xl, 1);
+ R( xl, xr, 2);
+ R( xr, xl, 3);
+ R( xl, xr, 4);
+ R( xr, xl, 5);
+ R( xl, xr, 6);
+ R( xr, xl, 7);
+ R( xl, xr, 8);
+ R( xr, xl, 9);
+ R( xl, xr, 10);
+ R( xr, xl, 11);
+ R( xl, xr, 12);
+ R( xr, xl, 13);
+ R( xl, xr, 14);
+ R( xr, xl, 15);
+
+ xl ^= p[BLOWFISH_ROUNDS];
+ xr ^= p[BLOWFISH_ROUNDS+1];
+
+ *ret_xl = xr;
+ *ret_xr = xl;
+
+#else
+ u32 xl, xr, temp, *p;
+ int i;
+
+ xl = *ret_xl;
+ xr = *ret_xr;
+ p = bc->p;
+
+ for(i=0; i < BLOWFISH_ROUNDS; i++ )
+ {
+ xl ^= p[i];
+ xr ^= function_F(bc, xl);
+ temp = xl;
+ xl = xr;
+ xr = temp;
+ }
+ temp = xl;
+ xl = xr;
+ xr = temp;
+
+ xr ^= p[BLOWFISH_ROUNDS];
+ xl ^= p[BLOWFISH_ROUNDS+1];
+
+ *ret_xl = xl;
+ *ret_xr = xr;
+#endif
+}
+
+
+static void
+decrypt ( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
+{
+#if BLOWFISH_ROUNDS == 16
+ u32 xl, xr, *s0, *s1, *s2, *s3, *p;
+
+ xl = *ret_xl;
+ xr = *ret_xr;
+ p = bc->p;
+ s0 = bc->s0;
+ s1 = bc->s1;
+ s2 = bc->s2;
+ s3 = bc->s3;
+
+ R( xl, xr, 17);
+ R( xr, xl, 16);
+ R( xl, xr, 15);
+ R( xr, xl, 14);
+ R( xl, xr, 13);
+ R( xr, xl, 12);
+ R( xl, xr, 11);
+ R( xr, xl, 10);
+ R( xl, xr, 9);
+ R( xr, xl, 8);
+ R( xl, xr, 7);
+ R( xr, xl, 6);
+ R( xl, xr, 5);
+ R( xr, xl, 4);
+ R( xl, xr, 3);
+ R( xr, xl, 2);
+
+ xl ^= p[1];
+ xr ^= p[0];
+
+ *ret_xl = xr;
+ *ret_xr = xl;
+
+#else
+ u32 xl, xr, temp, *p;
+ int i;
+
+ xl = *ret_xl;
+ xr = *ret_xr;
+ p = bc->p;
+
+ for (i=BLOWFISH_ROUNDS+1; i > 1; i-- )
+ {
+ xl ^= p[i];
+ xr ^= function_F(bc, xl);
+ temp = xl;
+ xl = xr;
+ xr = temp;
+ }
+
+ temp = xl;
+ xl = xr;
+ xr = temp;
+
+ xr ^= p[1];
+ xl ^= p[0];
+
+ *ret_xl = xl;
+ *ret_xr = xr;
+#endif
+}
+
+#undef F
+#undef R
+
+static void
+do_encrypt_block ( BLOWFISH_context *bc, byte *outbuf, const byte *inbuf )
+{
+ u32 d1, d2;
+
+ d1 = inbuf[0] << 24 | inbuf[1] << 16 | inbuf[2] << 8 | inbuf[3];
+ d2 = inbuf[4] << 24 | inbuf[5] << 16 | inbuf[6] << 8 | inbuf[7];
+ do_encrypt( bc, &d1, &d2 );
+ outbuf[0] = (d1 >> 24) & 0xff;
+ outbuf[1] = (d1 >> 16) & 0xff;
+ outbuf[2] = (d1 >> 8) & 0xff;
+ outbuf[3] = d1 & 0xff;
+ outbuf[4] = (d2 >> 24) & 0xff;
+ outbuf[5] = (d2 >> 16) & 0xff;
+ outbuf[6] = (d2 >> 8) & 0xff;
+ outbuf[7] = d2 & 0xff;
+}
+
+static void
+encrypt_block (void *context, byte *outbuf, const byte *inbuf)
+{
+ BLOWFISH_context *bc = (BLOWFISH_context *) context;
+ do_encrypt_block (bc, outbuf, inbuf);
+ _gcry_burn_stack (64);
+}
+
+
+static void
+do_decrypt_block (BLOWFISH_context *bc, byte *outbuf, const byte *inbuf)
+{
+ u32 d1, d2;
+
+ d1 = inbuf[0] << 24 | inbuf[1] << 16 | inbuf[2] << 8 | inbuf[3];
+ d2 = inbuf[4] << 24 | inbuf[5] << 16 | inbuf[6] << 8 | inbuf[7];
+ decrypt( bc, &d1, &d2 );
+ outbuf[0] = (d1 >> 24) & 0xff;
+ outbuf[1] = (d1 >> 16) & 0xff;
+ outbuf[2] = (d1 >> 8) & 0xff;
+ outbuf[3] = d1 & 0xff;
+ outbuf[4] = (d2 >> 24) & 0xff;
+ outbuf[5] = (d2 >> 16) & 0xff;
+ outbuf[6] = (d2 >> 8) & 0xff;
+ outbuf[7] = d2 & 0xff;
+}
+
+static void
+decrypt_block (void *context, byte *outbuf, const byte *inbuf)
+{
+ BLOWFISH_context *bc = (BLOWFISH_context *) context;
+ do_decrypt_block (bc, outbuf, inbuf);
+ _gcry_burn_stack (64);
+}
+
+
+
+
+
+static gcry_err_code_t
+do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen)
+{
+ int i, j;
+ u32 data, datal, datar;
+ static int initialized;
+ static const char *selftest_failed;
+
+ if( !initialized )
+ {
+ initialized = 1;
+ selftest_failed = selftest();
+ if( selftest_failed )
+ log_error ("%s\n", selftest_failed );
+ }
+ if( selftest_failed )
+ return GPG_ERR_SELFTEST_FAILED;
+
+ for(i=0; i < BLOWFISH_ROUNDS+2; i++ )
+ c->p[i] = ps[i];
+ for(i=0; i < 256; i++ )
+ {
+ c->s0[i] = ks0[i];
+ c->s1[i] = ks1[i];
+ c->s2[i] = ks2[i];
+ c->s3[i] = ks3[i];
+ }
+
+ for(i=j=0; i < BLOWFISH_ROUNDS+2; i++ )
+ {
+#ifdef WORDS_BIGENDIAN
+ ((byte*)&data)[0] = key[j];
+ ((byte*)&data)[1] = key[(j+1)%keylen];
+ ((byte*)&data)[2] = key[(j+2)%keylen];
+ ((byte*)&data)[3] = key[(j+3)%keylen];
+#else
+ ((byte*)&data)[3] = key[j];
+ ((byte*)&data)[2] = key[(j+1)%keylen];
+ ((byte*)&data)[1] = key[(j+2)%keylen];
+ ((byte*)&data)[0] = key[(j+3)%keylen];
+#endif
+ c->p[i] ^= data;
+ j = (j+4) % keylen;
+ }
+
+ datal = datar = 0;
+ for(i=0; i < BLOWFISH_ROUNDS+2; i += 2 )
+ {
+ do_encrypt( c, &datal, &datar );
+ c->p[i] = datal;
+ c->p[i+1] = datar;
+ }
+ for(i=0; i < 256; i += 2 )
+ {
+ do_encrypt( c, &datal, &datar );
+ c->s0[i] = datal;
+ c->s0[i+1] = datar;
+ }
+ for(i=0; i < 256; i += 2 )
+ {
+ do_encrypt( c, &datal, &datar );
+ c->s1[i] = datal;
+ c->s1[i+1] = datar;
+ }
+ for(i=0; i < 256; i += 2 )
+ {
+ do_encrypt( c, &datal, &datar );
+ c->s2[i] = datal;
+ c->s2[i+1] = datar;
+ }
+ for(i=0; i < 256; i += 2 )
+ {
+ do_encrypt( c, &datal, &datar );
+ c->s3[i] = datal;
+ c->s3[i+1] = datar;
+ }
+
+
+ /* Check for weak key. A weak key is a key in which a value in
+ the P-array (here c) occurs more than once per table. */
+ for(i=0; i < 255; i++ )
+ {
+ for( j=i+1; j < 256; j++)
+ {
+ if( (c->s0[i] == c->s0[j]) || (c->s1[i] == c->s1[j]) ||
+ (c->s2[i] == c->s2[j]) || (c->s3[i] == c->s3[j]) )
+ return GPG_ERR_WEAK_KEY;
+ }
+ }
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+static gcry_err_code_t
+bf_setkey (void *context, const byte *key, unsigned keylen)
+{
+ BLOWFISH_context *c = (BLOWFISH_context *) context;
+ gcry_err_code_t rc = do_bf_setkey (c, key, keylen);
+ _gcry_burn_stack (64);
+ return rc;
+}
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_blowfish =
+ {
+ "BLOWFISH", NULL, NULL, BLOWFISH_BLOCKSIZE, 128,
+ sizeof (BLOWFISH_context),
+ bf_setkey, encrypt_block, decrypt_block
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_blowfish",
+#endif
+ };
+
+
+GRUB_MOD_INIT(gcry_blowfish)
+{
+ grub_cipher_register (&_gcry_cipher_spec_blowfish);
+}
+
+GRUB_MOD_FINI(gcry_blowfish)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_blowfish);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/bufhelp.h b/grub-core/lib/libgcrypt-grub/cipher/bufhelp.h
new file mode 100644
index 0000000..89471e6
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/bufhelp.h
@@ -0,0 +1,435 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+/* bufhelp.h - Some buffer manipulation helpers
+ * Copyright (C) 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef GCRYPT_BUFHELP_H
+#define GCRYPT_BUFHELP_H
+
+
+#include "bithelp.h"
+
+
+#undef BUFHELP_FAST_UNALIGNED_ACCESS
+#if defined(HAVE_GCC_ATTRIBUTE_PACKED) && \
+ defined(HAVE_GCC_ATTRIBUTE_ALIGNED) && \
+ (defined(__i386__) || defined(__x86_64__) || \
+ (defined(__arm__) && defined(__ARM_FEATURE_UNALIGNED)) || \
+ defined(__aarch64__))
+/* These architectures are able of unaligned memory accesses and can
+ handle those fast.
+ */
+# define BUFHELP_FAST_UNALIGNED_ACCESS 1
+#endif
+
+
+#ifdef BUFHELP_FAST_UNALIGNED_ACCESS
+/* Define type with one-byte alignment on architectures with fast unaligned
+ memory accesses.
+ */
+typedef struct bufhelp_int_s
+{
+ uintptr_t a;
+} __attribute__((packed, aligned(1))) bufhelp_int_t;
+#else
+/* Define type with default alignment for other architectures (unaligned
+ accessed handled in per byte loops).
+ */
+typedef struct bufhelp_int_s
+{
+ uintptr_t a;
+} bufhelp_int_t;
+#endif
+
+
+/* Optimized function for small buffer copying */
+static inline void
+buf_cpy(void *_dst, const void *_src, size_t len)
+{
+#if __GNUC__ >= 4 && (defined(__x86_64__) || defined(__i386__))
+ /* For AMD64 and i386, memcpy is faster. */
+ memcpy(_dst, _src, len);
+#else
+ byte *dst = _dst;
+ const byte *src = _src;
+ bufhelp_int_t *ldst;
+ const bufhelp_int_t *lsrc;
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1;
+
+ /* Skip fast processing if buffers are unaligned. */
+ if (((uintptr_t)dst | (uintptr_t)src) & longmask)
+ goto do_bytes;
+#endif
+
+ ldst = (bufhelp_int_t *)(void *)dst;
+ lsrc = (const bufhelp_int_t *)(const void *)src;
+
+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t))
+ (ldst++)->a = (lsrc++)->a;
+
+ dst = (byte *)ldst;
+ src = (const byte *)lsrc;
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+do_bytes:
+#endif
+ /* Handle tail. */
+ for (; len; len--)
+ *dst++ = *src++;
+#endif /*__GNUC__ >= 4 && (__x86_64__ || __i386__)*/
+}
+
+
+/* Optimized function for buffer xoring */
+static inline void
+buf_xor(void *_dst, const void *_src1, const void *_src2, size_t len)
+{
+ byte *dst = _dst;
+ const byte *src1 = _src1;
+ const byte *src2 = _src2;
+ bufhelp_int_t *ldst;
+ const bufhelp_int_t *lsrc1, *lsrc2;
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1;
+
+ /* Skip fast processing if buffers are unaligned. */
+ if (((uintptr_t)dst | (uintptr_t)src1 | (uintptr_t)src2) & longmask)
+ goto do_bytes;
+#endif
+
+ ldst = (bufhelp_int_t *)(void *)dst;
+ lsrc1 = (const bufhelp_int_t *)(const void *)src1;
+ lsrc2 = (const bufhelp_int_t *)(const void *)src2;
+
+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t))
+ (ldst++)->a = (lsrc1++)->a ^ (lsrc2++)->a;
+
+ dst = (byte *)ldst;
+ src1 = (const byte *)lsrc1;
+ src2 = (const byte *)lsrc2;
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+do_bytes:
+#endif
+ /* Handle tail. */
+ for (; len; len--)
+ *dst++ = *src1++ ^ *src2++;
+}
+
+
+/* Optimized function for in-place buffer xoring. */
+static inline void
+buf_xor_1(void *_dst, const void *_src, size_t len)
+{
+ byte *dst = _dst;
+ const byte *src = _src;
+ bufhelp_int_t *ldst;
+ const bufhelp_int_t *lsrc;
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1;
+
+ /* Skip fast processing if buffers are unaligned. */
+ if (((uintptr_t)dst | (uintptr_t)src) & longmask)
+ goto do_bytes;
+#endif
+
+ ldst = (bufhelp_int_t *)(void *)dst;
+ lsrc = (const bufhelp_int_t *)(const void *)src;
+
+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t))
+ (ldst++)->a ^= (lsrc++)->a;
+
+ dst = (byte *)ldst;
+ src = (const byte *)lsrc;
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+do_bytes:
+#endif
+ /* Handle tail. */
+ for (; len; len--)
+ *dst++ ^= *src++;
+}
+
+
+/* Optimized function for buffer xoring with two destination buffers. Used
+ mainly by CFB mode encryption. */
+static inline void
+buf_xor_2dst(void *_dst1, void *_dst2, const void *_src, size_t len)
+{
+ byte *dst1 = _dst1;
+ byte *dst2 = _dst2;
+ const byte *src = _src;
+ bufhelp_int_t *ldst1, *ldst2;
+ const bufhelp_int_t *lsrc;
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1;
+
+ /* Skip fast processing if buffers are unaligned. */
+ if (((uintptr_t)src | (uintptr_t)dst1 | (uintptr_t)dst2) & longmask)
+ goto do_bytes;
+#endif
+
+ ldst1 = (bufhelp_int_t *)(void *)dst1;
+ ldst2 = (bufhelp_int_t *)(void *)dst2;
+ lsrc = (const bufhelp_int_t *)(const void *)src;
+
+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t))
+ (ldst1++)->a = ((ldst2++)->a ^= (lsrc++)->a);
+
+ dst1 = (byte *)ldst1;
+ dst2 = (byte *)ldst2;
+ src = (const byte *)lsrc;
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+do_bytes:
+#endif
+ /* Handle tail. */
+ for (; len; len--)
+ *dst1++ = (*dst2++ ^= *src++);
+}
+
+
+/* Optimized function for combined buffer xoring and copying. Used by mainly
+ CBC mode decryption. */
+static inline void
+buf_xor_n_copy_2(void *_dst_xor, const void *_src_xor, void *_srcdst_cpy,
+ const void *_src_cpy, size_t len)
+{
+ byte *dst_xor = _dst_xor;
+ byte *srcdst_cpy = _srcdst_cpy;
+ const byte *src_xor = _src_xor;
+ const byte *src_cpy = _src_cpy;
+ byte temp;
+ bufhelp_int_t *ldst_xor, *lsrcdst_cpy;
+ const bufhelp_int_t *lsrc_cpy, *lsrc_xor;
+ uintptr_t ltemp;
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1;
+
+ /* Skip fast processing if buffers are unaligned. */
+ if (((uintptr_t)src_cpy | (uintptr_t)src_xor | (uintptr_t)dst_xor |
+ (uintptr_t)srcdst_cpy) & longmask)
+ goto do_bytes;
+#endif
+
+ ldst_xor = (bufhelp_int_t *)(void *)dst_xor;
+ lsrc_xor = (const bufhelp_int_t *)(void *)src_xor;
+ lsrcdst_cpy = (bufhelp_int_t *)(void *)srcdst_cpy;
+ lsrc_cpy = (const bufhelp_int_t *)(const void *)src_cpy;
+
+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t))
+ {
+ ltemp = (lsrc_cpy++)->a;
+ (ldst_xor++)->a = (lsrcdst_cpy)->a ^ (lsrc_xor++)->a;
+ (lsrcdst_cpy++)->a = ltemp;
+ }
+
+ dst_xor = (byte *)ldst_xor;
+ src_xor = (const byte *)lsrc_xor;
+ srcdst_cpy = (byte *)lsrcdst_cpy;
+ src_cpy = (const byte *)lsrc_cpy;
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+do_bytes:
+#endif
+ /* Handle tail. */
+ for (; len; len--)
+ {
+ temp = *src_cpy++;
+ *dst_xor++ = *srcdst_cpy ^ *src_xor++;
+ *srcdst_cpy++ = temp;
+ }
+}
+
+
+/* Optimized function for combined buffer xoring and copying. Used by mainly
+ CFB mode decryption. */
+static inline void
+buf_xor_n_copy(void *_dst_xor, void *_srcdst_cpy, const void *_src, size_t len)
+{
+ buf_xor_n_copy_2(_dst_xor, _src, _srcdst_cpy, _src, len);
+}
+
+
+/* Constant-time compare of two buffers. Returns 1 if buffers are equal,
+ and 0 if buffers differ. */
+static inline int
+buf_eq_const(const void *_a, const void *_b, size_t len)
+{
+ const byte *a = _a;
+ const byte *b = _b;
+ size_t diff, i;
+
+ /* Constant-time compare. */
+ for (i = 0, diff = 0; i < len; i++)
+ diff -= !!(a[i] - b[i]);
+
+ return !diff;
+}
+
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+
+/* Functions for loading and storing unaligned u32 values of different
+ endianness. */
+static inline u32 buf_get_be32(const void *_buf)
+{
+ const byte *in = _buf;
+ return ((u32)in[0] << 24) | ((u32)in[1] << 16) | \
+ ((u32)in[2] << 8) | (u32)in[3];
+}
+
+static inline u32 buf_get_le32(const void *_buf)
+{
+ const byte *in = _buf;
+ return ((u32)in[3] << 24) | ((u32)in[2] << 16) | \
+ ((u32)in[1] << 8) | (u32)in[0];
+}
+
+static inline void buf_put_be32(void *_buf, u32 val)
+{
+ byte *out = _buf;
+ out[0] = val >> 24;
+ out[1] = val >> 16;
+ out[2] = val >> 8;
+ out[3] = val;
+}
+
+static inline void buf_put_le32(void *_buf, u32 val)
+{
+ byte *out = _buf;
+ out[3] = val >> 24;
+ out[2] = val >> 16;
+ out[1] = val >> 8;
+ out[0] = val;
+}
+
+
+/* Functions for loading and storing unaligned u64 values of different
+ endianness. */
+static inline u64 buf_get_be64(const void *_buf)
+{
+ const byte *in = _buf;
+ return ((u64)in[0] << 56) | ((u64)in[1] << 48) | \
+ ((u64)in[2] << 40) | ((u64)in[3] << 32) | \
+ ((u64)in[4] << 24) | ((u64)in[5] << 16) | \
+ ((u64)in[6] << 8) | (u64)in[7];
+}
+
+static inline u64 buf_get_le64(const void *_buf)
+{
+ const byte *in = _buf;
+ return ((u64)in[7] << 56) | ((u64)in[6] << 48) | \
+ ((u64)in[5] << 40) | ((u64)in[4] << 32) | \
+ ((u64)in[3] << 24) | ((u64)in[2] << 16) | \
+ ((u64)in[1] << 8) | (u64)in[0];
+}
+
+static inline void buf_put_be64(void *_buf, u64 val)
+{
+ byte *out = _buf;
+ out[0] = val >> 56;
+ out[1] = val >> 48;
+ out[2] = val >> 40;
+ out[3] = val >> 32;
+ out[4] = val >> 24;
+ out[5] = val >> 16;
+ out[6] = val >> 8;
+ out[7] = val;
+}
+
+static inline void buf_put_le64(void *_buf, u64 val)
+{
+ byte *out = _buf;
+ out[7] = val >> 56;
+ out[6] = val >> 48;
+ out[5] = val >> 40;
+ out[4] = val >> 32;
+ out[3] = val >> 24;
+ out[2] = val >> 16;
+ out[1] = val >> 8;
+ out[0] = val;
+}
+
+#else /*BUFHELP_FAST_UNALIGNED_ACCESS*/
+
+typedef struct bufhelp_u32_s
+{
+ u32 a;
+} __attribute__((packed, aligned(1))) bufhelp_u32_t;
+
+/* Functions for loading and storing unaligned u32 values of different
+ endianness. */
+static inline u32 buf_get_be32(const void *_buf)
+{
+ return be_bswap32(((const bufhelp_u32_t *)_buf)->a);
+}
+
+static inline u32 buf_get_le32(const void *_buf)
+{
+ return le_bswap32(((const bufhelp_u32_t *)_buf)->a);
+}
+
+static inline void buf_put_be32(void *_buf, u32 val)
+{
+ bufhelp_u32_t *out = _buf;
+ out->a = be_bswap32(val);
+}
+
+static inline void buf_put_le32(void *_buf, u32 val)
+{
+ bufhelp_u32_t *out = _buf;
+ out->a = le_bswap32(val);
+}
+
+
+typedef struct bufhelp_u64_s
+{
+ u64 a;
+} __attribute__((packed, aligned(1))) bufhelp_u64_t;
+
+/* Functions for loading and storing unaligned u64 values of different
+ endianness. */
+static inline u64 buf_get_be64(const void *_buf)
+{
+ return be_bswap64(((const bufhelp_u64_t *)_buf)->a);
+}
+
+static inline u64 buf_get_le64(const void *_buf)
+{
+ return le_bswap64(((const bufhelp_u64_t *)_buf)->a);
+}
+
+static inline void buf_put_be64(void *_buf, u64 val)
+{
+ bufhelp_u64_t *out = _buf;
+ out->a = be_bswap64(val);
+}
+
+static inline void buf_put_le64(void *_buf, u64 val)
+{
+ bufhelp_u64_t *out = _buf;
+ out->a = le_bswap64(val);
+}
+
+
+#endif /*BUFHELP_FAST_UNALIGNED_ACCESS*/
+
+#endif /*GCRYPT_BUFHELP_H*/
diff --git a/grub-core/lib/libgcrypt-grub/cipher/camellia-glue.c b/grub-core/lib/libgcrypt-grub/cipher/camellia-glue.c
new file mode 100644
index 0000000..f1a9143
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/camellia-glue.c
@@ -0,0 +1,211 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* camellia-glue.c - Glue for the Camellia cipher
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+/* I put all the libgcrypt-specific stuff in this file to keep the
+ camellia.c/camellia.h files exactly as provided by NTT. If they
+ update their code, this should make it easier to bring the changes
+ in. - dshaw
+
+ There is one small change which needs to be done: Include the
+ following code at the top of camellia.h: */
+#if 0
+
+/* To use Camellia with libraries it is often useful to keep the name
+ * space of the library clean. The following macro is thus useful:
+ *
+ * #define CAMELLIA_EXT_SYM_PREFIX foo_
+ *
+ * This prefixes all external symbols with "foo_".
+ */
+#ifdef HAVE_CONFIG_H
+#endif
+#ifdef CAMELLIA_EXT_SYM_PREFIX
+#define CAMELLIA_PREFIX1(x,y) x ## y
+#define CAMELLIA_PREFIX2(x,y) CAMELLIA_PREFIX1(x,y)
+#define CAMELLIA_PREFIX(x) CAMELLIA_PREFIX2(CAMELLIA_EXT_SYM_PREFIX,x)
+#define Camellia_Ekeygen CAMELLIA_PREFIX(Camellia_Ekeygen)
+#define Camellia_EncryptBlock CAMELLIA_PREFIX(Camellia_EncryptBlock)
+#define Camellia_DecryptBlock CAMELLIA_PREFIX(Camellia_DecryptBlock)
+#define camellia_decrypt128 CAMELLIA_PREFIX(camellia_decrypt128)
+#define camellia_decrypt256 CAMELLIA_PREFIX(camellia_decrypt256)
+#define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128)
+#define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256)
+#define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128)
+#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192)
+#define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256)
+#endif /*CAMELLIA_EXT_SYM_PREFIX*/
+
+#endif /* Code sample. */
+
+
+#include "types.h"
+#include "g10lib.h"
+#include "cipher.h"
+#include "camellia.h"
+
+typedef struct
+{
+ int keybitlength;
+ KEY_TABLE_TYPE keytable;
+} CAMELLIA_context;
+
+
+static gcry_err_code_t
+camellia_setkey(void *c, const byte *key, unsigned keylen)
+{
+ CAMELLIA_context *ctx=c;
+ static int initialized=0;
+ static const char *selftest_failed=NULL;
+
+ if(keylen!=16 && keylen!=24 && keylen!=32)
+ return GPG_ERR_INV_KEYLEN;
+
+ if(!initialized)
+ {
+ initialized=1;
+ selftest_failed=selftest();
+ if(selftest_failed)
+ log_error("%s\n",selftest_failed);
+ }
+
+ if(selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ ctx->keybitlength=keylen*8;
+ Camellia_Ekeygen(ctx->keybitlength,key,ctx->keytable);
+ _gcry_burn_stack
+ ((19+34+34)*sizeof(u32)+2*sizeof(void*) /* camellia_setup256 */
+ +(4+32)*sizeof(u32)+2*sizeof(void*) /* camellia_setup192 */
+ +0+sizeof(int)+2*sizeof(void*) /* Camellia_Ekeygen */
+ +3*2*sizeof(void*) /* Function calls. */
+ );
+
+ return 0;
+}
+
+static void
+camellia_encrypt(void *c, byte *outbuf, const byte *inbuf)
+{
+ CAMELLIA_context *ctx=c;
+
+ Camellia_EncryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf);
+ _gcry_burn_stack
+ (sizeof(int)+2*sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE)
+ +4*sizeof(u32)
+ +2*sizeof(u32*)+4*sizeof(u32)
+ +2*2*sizeof(void*) /* Function calls. */
+ );
+}
+
+static void
+camellia_decrypt(void *c, byte *outbuf, const byte *inbuf)
+{
+ CAMELLIA_context *ctx=c;
+
+ Camellia_DecryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf);
+ _gcry_burn_stack
+ (sizeof(int)+2*sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE)
+ +4*sizeof(u32)
+ +2*sizeof(u32*)+4*sizeof(u32)
+ +2*2*sizeof(void*) /* Function calls. */
+ );
+}
+
+
+/* These oids are from
+ <http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications_oid.html>,
+ retrieved May 1, 2007. */
+
+static gcry_cipher_oid_spec_t camellia128_oids[] =
+ {
+ {"1.2.392.200011.61.1.1.1.2", GCRY_CIPHER_MODE_CBC},
+ {"0.3.4401.5.3.1.9.1", GCRY_CIPHER_MODE_ECB},
+ {"0.3.4401.5.3.1.9.3", GCRY_CIPHER_MODE_OFB},
+ {"0.3.4401.5.3.1.9.4", GCRY_CIPHER_MODE_CFB},
+ { NULL }
+ };
+
+static gcry_cipher_oid_spec_t camellia192_oids[] =
+ {
+ {"1.2.392.200011.61.1.1.1.3", GCRY_CIPHER_MODE_CBC},
+ {"0.3.4401.5.3.1.9.21", GCRY_CIPHER_MODE_ECB},
+ {"0.3.4401.5.3.1.9.23", GCRY_CIPHER_MODE_OFB},
+ {"0.3.4401.5.3.1.9.24", GCRY_CIPHER_MODE_CFB},
+ { NULL }
+ };
+
+static gcry_cipher_oid_spec_t camellia256_oids[] =
+ {
+ {"1.2.392.200011.61.1.1.1.4", GCRY_CIPHER_MODE_CBC},
+ {"0.3.4401.5.3.1.9.41", GCRY_CIPHER_MODE_ECB},
+ {"0.3.4401.5.3.1.9.43", GCRY_CIPHER_MODE_OFB},
+ {"0.3.4401.5.3.1.9.44", GCRY_CIPHER_MODE_CFB},
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_camellia128 =
+ {
+ "CAMELLIA128",NULL,camellia128_oids,CAMELLIA_BLOCK_SIZE,128,
+ sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_camellia",
+#endif
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_camellia192 =
+ {
+ "CAMELLIA192",NULL,camellia192_oids,CAMELLIA_BLOCK_SIZE,192,
+ sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_camellia",
+#endif
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_camellia256 =
+ {
+ "CAMELLIA256",NULL,camellia256_oids,CAMELLIA_BLOCK_SIZE,256,
+ sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_camellia",
+#endif
+ };
+
+
+GRUB_MOD_INIT(gcry_camellia)
+{
+ grub_cipher_register (&_gcry_cipher_spec_camellia128);
+ grub_cipher_register (&_gcry_cipher_spec_camellia192);
+ grub_cipher_register (&_gcry_cipher_spec_camellia256);
+}
+
+GRUB_MOD_FINI(gcry_camellia)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_camellia128);
+ grub_cipher_unregister (&_gcry_cipher_spec_camellia192);
+ grub_cipher_unregister (&_gcry_cipher_spec_camellia256);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/camellia.c b/grub-core/lib/libgcrypt-grub/cipher/camellia.c
new file mode 100644
index 0000000..5c85ea8
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/camellia.c
@@ -0,0 +1,1463 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* camellia.h ver 1.2.0
+ *
+ * Copyright (C) 2006,2007
+ * NTT (Nippon Telegraph and Telephone Corporation).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Algorithm Specification
+ * http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html
+ */
+
+
+#include "camellia.h"
+
+/* u32 must be 32bit word */
+typedef unsigned int u32;
+typedef unsigned char u8;
+
+/* key constants */
+
+#define CAMELLIA_SIGMA1L (0xA09E667FL)
+#define CAMELLIA_SIGMA1R (0x3BCC908BL)
+#define CAMELLIA_SIGMA2L (0xB67AE858L)
+#define CAMELLIA_SIGMA2R (0x4CAA73B2L)
+#define CAMELLIA_SIGMA3L (0xC6EF372FL)
+#define CAMELLIA_SIGMA3R (0xE94F82BEL)
+#define CAMELLIA_SIGMA4L (0x54FF53A5L)
+#define CAMELLIA_SIGMA4R (0xF1D36F1CL)
+#define CAMELLIA_SIGMA5L (0x10E527FAL)
+#define CAMELLIA_SIGMA5R (0xDE682D1DL)
+#define CAMELLIA_SIGMA6L (0xB05688C2L)
+#define CAMELLIA_SIGMA6R (0xB3E6C1FDL)
+
+/*
+ * macros
+ */
+
+
+#if defined(_MSC_VER)
+
+# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
+# define GETU32(p) SWAP(*((u32 *)(p)))
+# define PUTU32(ct, st) {*((u32 *)(ct)) = SWAP((st));}
+
+#else /* not MS-VC */
+
+# define GETU32(pt) \
+ (((u32)(pt)[0] << 24) \
+ ^ ((u32)(pt)[1] << 16) \
+ ^ ((u32)(pt)[2] << 8) \
+ ^ ((u32)(pt)[3]))
+
+# define PUTU32(ct, st) { \
+ (ct)[0] = (u8)((st) >> 24); \
+ (ct)[1] = (u8)((st) >> 16); \
+ (ct)[2] = (u8)((st) >> 8); \
+ (ct)[3] = (u8)(st); }
+
+#endif
+
+#define CamelliaSubkeyL(INDEX) (subkey[(INDEX)*2])
+#define CamelliaSubkeyR(INDEX) (subkey[(INDEX)*2 + 1])
+
+/* rotation right shift 1byte */
+#define CAMELLIA_RR8(x) (((x) >> 8) + ((x) << 24))
+/* rotation left shift 1bit */
+#define CAMELLIA_RL1(x) (((x) << 1) + ((x) >> 31))
+/* rotation left shift 1byte */
+#define CAMELLIA_RL8(x) (((x) << 8) + ((x) >> 24))
+
+#define CAMELLIA_ROLDQ(ll, lr, rl, rr, w0, w1, bits) \
+ do { \
+ w0 = ll; \
+ ll = (ll << bits) + (lr >> (32 - bits)); \
+ lr = (lr << bits) + (rl >> (32 - bits)); \
+ rl = (rl << bits) + (rr >> (32 - bits)); \
+ rr = (rr << bits) + (w0 >> (32 - bits)); \
+ } while(0)
+
+#define CAMELLIA_ROLDQo32(ll, lr, rl, rr, w0, w1, bits) \
+ do { \
+ w0 = ll; \
+ w1 = lr; \
+ ll = (lr << (bits - 32)) + (rl >> (64 - bits)); \
+ lr = (rl << (bits - 32)) + (rr >> (64 - bits)); \
+ rl = (rr << (bits - 32)) + (w0 >> (64 - bits)); \
+ rr = (w0 << (bits - 32)) + (w1 >> (64 - bits)); \
+ } while(0)
+
+#define CAMELLIA_SP1110(INDEX) (camellia_sp1110[(INDEX)])
+#define CAMELLIA_SP0222(INDEX) (camellia_sp0222[(INDEX)])
+#define CAMELLIA_SP3033(INDEX) (camellia_sp3033[(INDEX)])
+#define CAMELLIA_SP4404(INDEX) (camellia_sp4404[(INDEX)])
+
+#define CAMELLIA_F(xl, xr, kl, kr, yl, yr, il, ir, t0, t1) \
+ do { \
+ il = xl ^ kl; \
+ ir = xr ^ kr; \
+ t0 = il >> 16; \
+ t1 = ir >> 16; \
+ yl = CAMELLIA_SP1110(ir & 0xff) \
+ ^ CAMELLIA_SP0222((t1 >> 8) & 0xff) \
+ ^ CAMELLIA_SP3033(t1 & 0xff) \
+ ^ CAMELLIA_SP4404((ir >> 8) & 0xff); \
+ yr = CAMELLIA_SP1110((t0 >> 8) & 0xff) \
+ ^ CAMELLIA_SP0222(t0 & 0xff) \
+ ^ CAMELLIA_SP3033((il >> 8) & 0xff) \
+ ^ CAMELLIA_SP4404(il & 0xff); \
+ yl ^= yr; \
+ yr = CAMELLIA_RR8(yr); \
+ yr ^= yl; \
+ } while(0)
+
+
+/*
+ * for speed up
+ *
+ */
+#define CAMELLIA_FLS(ll, lr, rl, rr, kll, klr, krl, krr, t0, t1, t2, t3) \
+ do { \
+ t0 = kll; \
+ t0 &= ll; \
+ lr ^= CAMELLIA_RL1(t0); \
+ t1 = klr; \
+ t1 |= lr; \
+ ll ^= t1; \
+ \
+ t2 = krr; \
+ t2 |= rr; \
+ rl ^= t2; \
+ t3 = krl; \
+ t3 &= rl; \
+ rr ^= CAMELLIA_RL1(t3); \
+ } while(0)
+
+#define CAMELLIA_ROUNDSM(xl, xr, kl, kr, yl, yr, il, ir, t0, t1) \
+ do { \
+ ir = CAMELLIA_SP1110(xr & 0xff) \
+ ^ CAMELLIA_SP0222((xr >> 24) & 0xff) \
+ ^ CAMELLIA_SP3033((xr >> 16) & 0xff) \
+ ^ CAMELLIA_SP4404((xr >> 8) & 0xff); \
+ il = CAMELLIA_SP1110((xl >> 24) & 0xff) \
+ ^ CAMELLIA_SP0222((xl >> 16) & 0xff) \
+ ^ CAMELLIA_SP3033((xl >> 8) & 0xff) \
+ ^ CAMELLIA_SP4404(xl & 0xff); \
+ il ^= kl; \
+ ir ^= kr; \
+ ir ^= il; \
+ il = CAMELLIA_RR8(il); \
+ il ^= ir; \
+ yl ^= ir; \
+ yr ^= il; \
+ } while(0)
+
+
+static const u32 camellia_sp1110[256] = {
+ 0x70707000,0x82828200,0x2c2c2c00,0xececec00,
+ 0xb3b3b300,0x27272700,0xc0c0c000,0xe5e5e500,
+ 0xe4e4e400,0x85858500,0x57575700,0x35353500,
+ 0xeaeaea00,0x0c0c0c00,0xaeaeae00,0x41414100,
+ 0x23232300,0xefefef00,0x6b6b6b00,0x93939300,
+ 0x45454500,0x19191900,0xa5a5a500,0x21212100,
+ 0xededed00,0x0e0e0e00,0x4f4f4f00,0x4e4e4e00,
+ 0x1d1d1d00,0x65656500,0x92929200,0xbdbdbd00,
+ 0x86868600,0xb8b8b800,0xafafaf00,0x8f8f8f00,
+ 0x7c7c7c00,0xebebeb00,0x1f1f1f00,0xcecece00,
+ 0x3e3e3e00,0x30303000,0xdcdcdc00,0x5f5f5f00,
+ 0x5e5e5e00,0xc5c5c500,0x0b0b0b00,0x1a1a1a00,
+ 0xa6a6a600,0xe1e1e100,0x39393900,0xcacaca00,
+ 0xd5d5d500,0x47474700,0x5d5d5d00,0x3d3d3d00,
+ 0xd9d9d900,0x01010100,0x5a5a5a00,0xd6d6d600,
+ 0x51515100,0x56565600,0x6c6c6c00,0x4d4d4d00,
+ 0x8b8b8b00,0x0d0d0d00,0x9a9a9a00,0x66666600,
+ 0xfbfbfb00,0xcccccc00,0xb0b0b000,0x2d2d2d00,
+ 0x74747400,0x12121200,0x2b2b2b00,0x20202000,
+ 0xf0f0f000,0xb1b1b100,0x84848400,0x99999900,
+ 0xdfdfdf00,0x4c4c4c00,0xcbcbcb00,0xc2c2c200,
+ 0x34343400,0x7e7e7e00,0x76767600,0x05050500,
+ 0x6d6d6d00,0xb7b7b700,0xa9a9a900,0x31313100,
+ 0xd1d1d100,0x17171700,0x04040400,0xd7d7d700,
+ 0x14141400,0x58585800,0x3a3a3a00,0x61616100,
+ 0xdedede00,0x1b1b1b00,0x11111100,0x1c1c1c00,
+ 0x32323200,0x0f0f0f00,0x9c9c9c00,0x16161600,
+ 0x53535300,0x18181800,0xf2f2f200,0x22222200,
+ 0xfefefe00,0x44444400,0xcfcfcf00,0xb2b2b200,
+ 0xc3c3c300,0xb5b5b500,0x7a7a7a00,0x91919100,
+ 0x24242400,0x08080800,0xe8e8e800,0xa8a8a800,
+ 0x60606000,0xfcfcfc00,0x69696900,0x50505000,
+ 0xaaaaaa00,0xd0d0d000,0xa0a0a000,0x7d7d7d00,
+ 0xa1a1a100,0x89898900,0x62626200,0x97979700,
+ 0x54545400,0x5b5b5b00,0x1e1e1e00,0x95959500,
+ 0xe0e0e000,0xffffff00,0x64646400,0xd2d2d200,
+ 0x10101000,0xc4c4c400,0x00000000,0x48484800,
+ 0xa3a3a300,0xf7f7f700,0x75757500,0xdbdbdb00,
+ 0x8a8a8a00,0x03030300,0xe6e6e600,0xdadada00,
+ 0x09090900,0x3f3f3f00,0xdddddd00,0x94949400,
+ 0x87878700,0x5c5c5c00,0x83838300,0x02020200,
+ 0xcdcdcd00,0x4a4a4a00,0x90909000,0x33333300,
+ 0x73737300,0x67676700,0xf6f6f600,0xf3f3f300,
+ 0x9d9d9d00,0x7f7f7f00,0xbfbfbf00,0xe2e2e200,
+ 0x52525200,0x9b9b9b00,0xd8d8d800,0x26262600,
+ 0xc8c8c800,0x37373700,0xc6c6c600,0x3b3b3b00,
+ 0x81818100,0x96969600,0x6f6f6f00,0x4b4b4b00,
+ 0x13131300,0xbebebe00,0x63636300,0x2e2e2e00,
+ 0xe9e9e900,0x79797900,0xa7a7a700,0x8c8c8c00,
+ 0x9f9f9f00,0x6e6e6e00,0xbcbcbc00,0x8e8e8e00,
+ 0x29292900,0xf5f5f500,0xf9f9f900,0xb6b6b600,
+ 0x2f2f2f00,0xfdfdfd00,0xb4b4b400,0x59595900,
+ 0x78787800,0x98989800,0x06060600,0x6a6a6a00,
+ 0xe7e7e700,0x46464600,0x71717100,0xbababa00,
+ 0xd4d4d400,0x25252500,0xababab00,0x42424200,
+ 0x88888800,0xa2a2a200,0x8d8d8d00,0xfafafa00,
+ 0x72727200,0x07070700,0xb9b9b900,0x55555500,
+ 0xf8f8f800,0xeeeeee00,0xacacac00,0x0a0a0a00,
+ 0x36363600,0x49494900,0x2a2a2a00,0x68686800,
+ 0x3c3c3c00,0x38383800,0xf1f1f100,0xa4a4a400,
+ 0x40404000,0x28282800,0xd3d3d300,0x7b7b7b00,
+ 0xbbbbbb00,0xc9c9c900,0x43434300,0xc1c1c100,
+ 0x15151500,0xe3e3e300,0xadadad00,0xf4f4f400,
+ 0x77777700,0xc7c7c700,0x80808000,0x9e9e9e00,
+};
+
+static const u32 camellia_sp0222[256] = {
+ 0x00e0e0e0,0x00050505,0x00585858,0x00d9d9d9,
+ 0x00676767,0x004e4e4e,0x00818181,0x00cbcbcb,
+ 0x00c9c9c9,0x000b0b0b,0x00aeaeae,0x006a6a6a,
+ 0x00d5d5d5,0x00181818,0x005d5d5d,0x00828282,
+ 0x00464646,0x00dfdfdf,0x00d6d6d6,0x00272727,
+ 0x008a8a8a,0x00323232,0x004b4b4b,0x00424242,
+ 0x00dbdbdb,0x001c1c1c,0x009e9e9e,0x009c9c9c,
+ 0x003a3a3a,0x00cacaca,0x00252525,0x007b7b7b,
+ 0x000d0d0d,0x00717171,0x005f5f5f,0x001f1f1f,
+ 0x00f8f8f8,0x00d7d7d7,0x003e3e3e,0x009d9d9d,
+ 0x007c7c7c,0x00606060,0x00b9b9b9,0x00bebebe,
+ 0x00bcbcbc,0x008b8b8b,0x00161616,0x00343434,
+ 0x004d4d4d,0x00c3c3c3,0x00727272,0x00959595,
+ 0x00ababab,0x008e8e8e,0x00bababa,0x007a7a7a,
+ 0x00b3b3b3,0x00020202,0x00b4b4b4,0x00adadad,
+ 0x00a2a2a2,0x00acacac,0x00d8d8d8,0x009a9a9a,
+ 0x00171717,0x001a1a1a,0x00353535,0x00cccccc,
+ 0x00f7f7f7,0x00999999,0x00616161,0x005a5a5a,
+ 0x00e8e8e8,0x00242424,0x00565656,0x00404040,
+ 0x00e1e1e1,0x00636363,0x00090909,0x00333333,
+ 0x00bfbfbf,0x00989898,0x00979797,0x00858585,
+ 0x00686868,0x00fcfcfc,0x00ececec,0x000a0a0a,
+ 0x00dadada,0x006f6f6f,0x00535353,0x00626262,
+ 0x00a3a3a3,0x002e2e2e,0x00080808,0x00afafaf,
+ 0x00282828,0x00b0b0b0,0x00747474,0x00c2c2c2,
+ 0x00bdbdbd,0x00363636,0x00222222,0x00383838,
+ 0x00646464,0x001e1e1e,0x00393939,0x002c2c2c,
+ 0x00a6a6a6,0x00303030,0x00e5e5e5,0x00444444,
+ 0x00fdfdfd,0x00888888,0x009f9f9f,0x00656565,
+ 0x00878787,0x006b6b6b,0x00f4f4f4,0x00232323,
+ 0x00484848,0x00101010,0x00d1d1d1,0x00515151,
+ 0x00c0c0c0,0x00f9f9f9,0x00d2d2d2,0x00a0a0a0,
+ 0x00555555,0x00a1a1a1,0x00414141,0x00fafafa,
+ 0x00434343,0x00131313,0x00c4c4c4,0x002f2f2f,
+ 0x00a8a8a8,0x00b6b6b6,0x003c3c3c,0x002b2b2b,
+ 0x00c1c1c1,0x00ffffff,0x00c8c8c8,0x00a5a5a5,
+ 0x00202020,0x00898989,0x00000000,0x00909090,
+ 0x00474747,0x00efefef,0x00eaeaea,0x00b7b7b7,
+ 0x00151515,0x00060606,0x00cdcdcd,0x00b5b5b5,
+ 0x00121212,0x007e7e7e,0x00bbbbbb,0x00292929,
+ 0x000f0f0f,0x00b8b8b8,0x00070707,0x00040404,
+ 0x009b9b9b,0x00949494,0x00212121,0x00666666,
+ 0x00e6e6e6,0x00cecece,0x00ededed,0x00e7e7e7,
+ 0x003b3b3b,0x00fefefe,0x007f7f7f,0x00c5c5c5,
+ 0x00a4a4a4,0x00373737,0x00b1b1b1,0x004c4c4c,
+ 0x00919191,0x006e6e6e,0x008d8d8d,0x00767676,
+ 0x00030303,0x002d2d2d,0x00dedede,0x00969696,
+ 0x00262626,0x007d7d7d,0x00c6c6c6,0x005c5c5c,
+ 0x00d3d3d3,0x00f2f2f2,0x004f4f4f,0x00191919,
+ 0x003f3f3f,0x00dcdcdc,0x00797979,0x001d1d1d,
+ 0x00525252,0x00ebebeb,0x00f3f3f3,0x006d6d6d,
+ 0x005e5e5e,0x00fbfbfb,0x00696969,0x00b2b2b2,
+ 0x00f0f0f0,0x00313131,0x000c0c0c,0x00d4d4d4,
+ 0x00cfcfcf,0x008c8c8c,0x00e2e2e2,0x00757575,
+ 0x00a9a9a9,0x004a4a4a,0x00575757,0x00848484,
+ 0x00111111,0x00454545,0x001b1b1b,0x00f5f5f5,
+ 0x00e4e4e4,0x000e0e0e,0x00737373,0x00aaaaaa,
+ 0x00f1f1f1,0x00dddddd,0x00595959,0x00141414,
+ 0x006c6c6c,0x00929292,0x00545454,0x00d0d0d0,
+ 0x00787878,0x00707070,0x00e3e3e3,0x00494949,
+ 0x00808080,0x00505050,0x00a7a7a7,0x00f6f6f6,
+ 0x00777777,0x00939393,0x00868686,0x00838383,
+ 0x002a2a2a,0x00c7c7c7,0x005b5b5b,0x00e9e9e9,
+ 0x00eeeeee,0x008f8f8f,0x00010101,0x003d3d3d,
+};
+
+static const u32 camellia_sp3033[256] = {
+ 0x38003838,0x41004141,0x16001616,0x76007676,
+ 0xd900d9d9,0x93009393,0x60006060,0xf200f2f2,
+ 0x72007272,0xc200c2c2,0xab00abab,0x9a009a9a,
+ 0x75007575,0x06000606,0x57005757,0xa000a0a0,
+ 0x91009191,0xf700f7f7,0xb500b5b5,0xc900c9c9,
+ 0xa200a2a2,0x8c008c8c,0xd200d2d2,0x90009090,
+ 0xf600f6f6,0x07000707,0xa700a7a7,0x27002727,
+ 0x8e008e8e,0xb200b2b2,0x49004949,0xde00dede,
+ 0x43004343,0x5c005c5c,0xd700d7d7,0xc700c7c7,
+ 0x3e003e3e,0xf500f5f5,0x8f008f8f,0x67006767,
+ 0x1f001f1f,0x18001818,0x6e006e6e,0xaf00afaf,
+ 0x2f002f2f,0xe200e2e2,0x85008585,0x0d000d0d,
+ 0x53005353,0xf000f0f0,0x9c009c9c,0x65006565,
+ 0xea00eaea,0xa300a3a3,0xae00aeae,0x9e009e9e,
+ 0xec00ecec,0x80008080,0x2d002d2d,0x6b006b6b,
+ 0xa800a8a8,0x2b002b2b,0x36003636,0xa600a6a6,
+ 0xc500c5c5,0x86008686,0x4d004d4d,0x33003333,
+ 0xfd00fdfd,0x66006666,0x58005858,0x96009696,
+ 0x3a003a3a,0x09000909,0x95009595,0x10001010,
+ 0x78007878,0xd800d8d8,0x42004242,0xcc00cccc,
+ 0xef00efef,0x26002626,0xe500e5e5,0x61006161,
+ 0x1a001a1a,0x3f003f3f,0x3b003b3b,0x82008282,
+ 0xb600b6b6,0xdb00dbdb,0xd400d4d4,0x98009898,
+ 0xe800e8e8,0x8b008b8b,0x02000202,0xeb00ebeb,
+ 0x0a000a0a,0x2c002c2c,0x1d001d1d,0xb000b0b0,
+ 0x6f006f6f,0x8d008d8d,0x88008888,0x0e000e0e,
+ 0x19001919,0x87008787,0x4e004e4e,0x0b000b0b,
+ 0xa900a9a9,0x0c000c0c,0x79007979,0x11001111,
+ 0x7f007f7f,0x22002222,0xe700e7e7,0x59005959,
+ 0xe100e1e1,0xda00dada,0x3d003d3d,0xc800c8c8,
+ 0x12001212,0x04000404,0x74007474,0x54005454,
+ 0x30003030,0x7e007e7e,0xb400b4b4,0x28002828,
+ 0x55005555,0x68006868,0x50005050,0xbe00bebe,
+ 0xd000d0d0,0xc400c4c4,0x31003131,0xcb00cbcb,
+ 0x2a002a2a,0xad00adad,0x0f000f0f,0xca00caca,
+ 0x70007070,0xff00ffff,0x32003232,0x69006969,
+ 0x08000808,0x62006262,0x00000000,0x24002424,
+ 0xd100d1d1,0xfb00fbfb,0xba00baba,0xed00eded,
+ 0x45004545,0x81008181,0x73007373,0x6d006d6d,
+ 0x84008484,0x9f009f9f,0xee00eeee,0x4a004a4a,
+ 0xc300c3c3,0x2e002e2e,0xc100c1c1,0x01000101,
+ 0xe600e6e6,0x25002525,0x48004848,0x99009999,
+ 0xb900b9b9,0xb300b3b3,0x7b007b7b,0xf900f9f9,
+ 0xce00cece,0xbf00bfbf,0xdf00dfdf,0x71007171,
+ 0x29002929,0xcd00cdcd,0x6c006c6c,0x13001313,
+ 0x64006464,0x9b009b9b,0x63006363,0x9d009d9d,
+ 0xc000c0c0,0x4b004b4b,0xb700b7b7,0xa500a5a5,
+ 0x89008989,0x5f005f5f,0xb100b1b1,0x17001717,
+ 0xf400f4f4,0xbc00bcbc,0xd300d3d3,0x46004646,
+ 0xcf00cfcf,0x37003737,0x5e005e5e,0x47004747,
+ 0x94009494,0xfa00fafa,0xfc00fcfc,0x5b005b5b,
+ 0x97009797,0xfe00fefe,0x5a005a5a,0xac00acac,
+ 0x3c003c3c,0x4c004c4c,0x03000303,0x35003535,
+ 0xf300f3f3,0x23002323,0xb800b8b8,0x5d005d5d,
+ 0x6a006a6a,0x92009292,0xd500d5d5,0x21002121,
+ 0x44004444,0x51005151,0xc600c6c6,0x7d007d7d,
+ 0x39003939,0x83008383,0xdc00dcdc,0xaa00aaaa,
+ 0x7c007c7c,0x77007777,0x56005656,0x05000505,
+ 0x1b001b1b,0xa400a4a4,0x15001515,0x34003434,
+ 0x1e001e1e,0x1c001c1c,0xf800f8f8,0x52005252,
+ 0x20002020,0x14001414,0xe900e9e9,0xbd00bdbd,
+ 0xdd00dddd,0xe400e4e4,0xa100a1a1,0xe000e0e0,
+ 0x8a008a8a,0xf100f1f1,0xd600d6d6,0x7a007a7a,
+ 0xbb00bbbb,0xe300e3e3,0x40004040,0x4f004f4f,
+};
+
+static const u32 camellia_sp4404[256] = {
+ 0x70700070,0x2c2c002c,0xb3b300b3,0xc0c000c0,
+ 0xe4e400e4,0x57570057,0xeaea00ea,0xaeae00ae,
+ 0x23230023,0x6b6b006b,0x45450045,0xa5a500a5,
+ 0xeded00ed,0x4f4f004f,0x1d1d001d,0x92920092,
+ 0x86860086,0xafaf00af,0x7c7c007c,0x1f1f001f,
+ 0x3e3e003e,0xdcdc00dc,0x5e5e005e,0x0b0b000b,
+ 0xa6a600a6,0x39390039,0xd5d500d5,0x5d5d005d,
+ 0xd9d900d9,0x5a5a005a,0x51510051,0x6c6c006c,
+ 0x8b8b008b,0x9a9a009a,0xfbfb00fb,0xb0b000b0,
+ 0x74740074,0x2b2b002b,0xf0f000f0,0x84840084,
+ 0xdfdf00df,0xcbcb00cb,0x34340034,0x76760076,
+ 0x6d6d006d,0xa9a900a9,0xd1d100d1,0x04040004,
+ 0x14140014,0x3a3a003a,0xdede00de,0x11110011,
+ 0x32320032,0x9c9c009c,0x53530053,0xf2f200f2,
+ 0xfefe00fe,0xcfcf00cf,0xc3c300c3,0x7a7a007a,
+ 0x24240024,0xe8e800e8,0x60600060,0x69690069,
+ 0xaaaa00aa,0xa0a000a0,0xa1a100a1,0x62620062,
+ 0x54540054,0x1e1e001e,0xe0e000e0,0x64640064,
+ 0x10100010,0x00000000,0xa3a300a3,0x75750075,
+ 0x8a8a008a,0xe6e600e6,0x09090009,0xdddd00dd,
+ 0x87870087,0x83830083,0xcdcd00cd,0x90900090,
+ 0x73730073,0xf6f600f6,0x9d9d009d,0xbfbf00bf,
+ 0x52520052,0xd8d800d8,0xc8c800c8,0xc6c600c6,
+ 0x81810081,0x6f6f006f,0x13130013,0x63630063,
+ 0xe9e900e9,0xa7a700a7,0x9f9f009f,0xbcbc00bc,
+ 0x29290029,0xf9f900f9,0x2f2f002f,0xb4b400b4,
+ 0x78780078,0x06060006,0xe7e700e7,0x71710071,
+ 0xd4d400d4,0xabab00ab,0x88880088,0x8d8d008d,
+ 0x72720072,0xb9b900b9,0xf8f800f8,0xacac00ac,
+ 0x36360036,0x2a2a002a,0x3c3c003c,0xf1f100f1,
+ 0x40400040,0xd3d300d3,0xbbbb00bb,0x43430043,
+ 0x15150015,0xadad00ad,0x77770077,0x80800080,
+ 0x82820082,0xecec00ec,0x27270027,0xe5e500e5,
+ 0x85850085,0x35350035,0x0c0c000c,0x41410041,
+ 0xefef00ef,0x93930093,0x19190019,0x21210021,
+ 0x0e0e000e,0x4e4e004e,0x65650065,0xbdbd00bd,
+ 0xb8b800b8,0x8f8f008f,0xebeb00eb,0xcece00ce,
+ 0x30300030,0x5f5f005f,0xc5c500c5,0x1a1a001a,
+ 0xe1e100e1,0xcaca00ca,0x47470047,0x3d3d003d,
+ 0x01010001,0xd6d600d6,0x56560056,0x4d4d004d,
+ 0x0d0d000d,0x66660066,0xcccc00cc,0x2d2d002d,
+ 0x12120012,0x20200020,0xb1b100b1,0x99990099,
+ 0x4c4c004c,0xc2c200c2,0x7e7e007e,0x05050005,
+ 0xb7b700b7,0x31310031,0x17170017,0xd7d700d7,
+ 0x58580058,0x61610061,0x1b1b001b,0x1c1c001c,
+ 0x0f0f000f,0x16160016,0x18180018,0x22220022,
+ 0x44440044,0xb2b200b2,0xb5b500b5,0x91910091,
+ 0x08080008,0xa8a800a8,0xfcfc00fc,0x50500050,
+ 0xd0d000d0,0x7d7d007d,0x89890089,0x97970097,
+ 0x5b5b005b,0x95950095,0xffff00ff,0xd2d200d2,
+ 0xc4c400c4,0x48480048,0xf7f700f7,0xdbdb00db,
+ 0x03030003,0xdada00da,0x3f3f003f,0x94940094,
+ 0x5c5c005c,0x02020002,0x4a4a004a,0x33330033,
+ 0x67670067,0xf3f300f3,0x7f7f007f,0xe2e200e2,
+ 0x9b9b009b,0x26260026,0x37370037,0x3b3b003b,
+ 0x96960096,0x4b4b004b,0xbebe00be,0x2e2e002e,
+ 0x79790079,0x8c8c008c,0x6e6e006e,0x8e8e008e,
+ 0xf5f500f5,0xb6b600b6,0xfdfd00fd,0x59590059,
+ 0x98980098,0x6a6a006a,0x46460046,0xbaba00ba,
+ 0x25250025,0x42420042,0xa2a200a2,0xfafa00fa,
+ 0x07070007,0x55550055,0xeeee00ee,0x0a0a000a,
+ 0x49490049,0x68680068,0x38380038,0xa4a400a4,
+ 0x28280028,0x7b7b007b,0xc9c900c9,0xc1c100c1,
+ 0xe3e300e3,0xf4f400f4,0xc7c700c7,0x9e9e009e,
+};
+
+
+/**
+ * Stuff related to the Camellia key schedule
+ */
+#define subl(x) subL[(x)]
+#define subr(x) subR[(x)]
+
+void camellia_setup128(const unsigned char *key, u32 *subkey)
+{
+ u32 kll, klr, krl, krr;
+ u32 il, ir, t0, t1, w0, w1;
+ u32 kw4l, kw4r, dw, tl, tr;
+ u32 subL[26];
+ u32 subR[26];
+
+ /**
+ * k == kll || klr || krl || krr (|| is concatination)
+ */
+ kll = GETU32(key );
+ klr = GETU32(key + 4);
+ krl = GETU32(key + 8);
+ krr = GETU32(key + 12);
+ /**
+ * generate KL dependent subkeys
+ */
+ subl(0) = kll; subr(0) = klr;
+ subl(1) = krl; subr(1) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(4) = kll; subr(4) = klr;
+ subl(5) = krl; subr(5) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30);
+ subl(10) = kll; subr(10) = klr;
+ subl(11) = krl; subr(11) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(13) = krl; subr(13) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+ subl(16) = kll; subr(16) = klr;
+ subl(17) = krl; subr(17) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+ subl(18) = kll; subr(18) = klr;
+ subl(19) = krl; subr(19) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+ subl(22) = kll; subr(22) = klr;
+ subl(23) = krl; subr(23) = krr;
+
+ /* generate KA */
+ kll = subl(0); klr = subr(0);
+ krl = subl(1); krr = subr(1);
+ CAMELLIA_F(kll, klr,
+ CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R,
+ w0, w1, il, ir, t0, t1);
+ krl ^= w0; krr ^= w1;
+ CAMELLIA_F(krl, krr,
+ CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R,
+ kll, klr, il, ir, t0, t1);
+ CAMELLIA_F(kll, klr,
+ CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R,
+ krl, krr, il, ir, t0, t1);
+ krl ^= w0; krr ^= w1;
+ CAMELLIA_F(krl, krr,
+ CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R,
+ w0, w1, il, ir, t0, t1);
+ kll ^= w0; klr ^= w1;
+
+ /* generate KA dependent subkeys */
+ subl(2) = kll; subr(2) = klr;
+ subl(3) = krl; subr(3) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(6) = kll; subr(6) = klr;
+ subl(7) = krl; subr(7) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(8) = kll; subr(8) = klr;
+ subl(9) = krl; subr(9) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(12) = kll; subr(12) = klr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(14) = kll; subr(14) = klr;
+ subl(15) = krl; subr(15) = krr;
+ CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34);
+ subl(20) = kll; subr(20) = klr;
+ subl(21) = krl; subr(21) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+ subl(24) = kll; subr(24) = klr;
+ subl(25) = krl; subr(25) = krr;
+
+
+ /* absorb kw2 to other subkeys */
+ subl(3) ^= subl(1); subr(3) ^= subr(1);
+ subl(5) ^= subl(1); subr(5) ^= subr(1);
+ subl(7) ^= subl(1); subr(7) ^= subr(1);
+ subl(1) ^= subr(1) & ~subr(9);
+ dw = subl(1) & subl(9), subr(1) ^= CAMELLIA_RL1(dw);
+ subl(11) ^= subl(1); subr(11) ^= subr(1);
+ subl(13) ^= subl(1); subr(13) ^= subr(1);
+ subl(15) ^= subl(1); subr(15) ^= subr(1);
+ subl(1) ^= subr(1) & ~subr(17);
+ dw = subl(1) & subl(17), subr(1) ^= CAMELLIA_RL1(dw);
+ subl(19) ^= subl(1); subr(19) ^= subr(1);
+ subl(21) ^= subl(1); subr(21) ^= subr(1);
+ subl(23) ^= subl(1); subr(23) ^= subr(1);
+ subl(24) ^= subl(1); subr(24) ^= subr(1);
+
+ /* absorb kw4 to other subkeys */
+ kw4l = subl(25); kw4r = subr(25);
+ subl(22) ^= kw4l; subr(22) ^= kw4r;
+ subl(20) ^= kw4l; subr(20) ^= kw4r;
+ subl(18) ^= kw4l; subr(18) ^= kw4r;
+ kw4l ^= kw4r & ~subr(16);
+ dw = kw4l & subl(16), kw4r ^= CAMELLIA_RL1(dw);
+ subl(14) ^= kw4l; subr(14) ^= kw4r;
+ subl(12) ^= kw4l; subr(12) ^= kw4r;
+ subl(10) ^= kw4l; subr(10) ^= kw4r;
+ kw4l ^= kw4r & ~subr(8);
+ dw = kw4l & subl(8), kw4r ^= CAMELLIA_RL1(dw);
+ subl(6) ^= kw4l; subr(6) ^= kw4r;
+ subl(4) ^= kw4l; subr(4) ^= kw4r;
+ subl(2) ^= kw4l; subr(2) ^= kw4r;
+ subl(0) ^= kw4l; subr(0) ^= kw4r;
+
+ /* key XOR is end of F-function */
+ CamelliaSubkeyL(0) = subl(0) ^ subl(2);
+ CamelliaSubkeyR(0) = subr(0) ^ subr(2);
+ CamelliaSubkeyL(2) = subl(3);
+ CamelliaSubkeyR(2) = subr(3);
+ CamelliaSubkeyL(3) = subl(2) ^ subl(4);
+ CamelliaSubkeyR(3) = subr(2) ^ subr(4);
+ CamelliaSubkeyL(4) = subl(3) ^ subl(5);
+ CamelliaSubkeyR(4) = subr(3) ^ subr(5);
+ CamelliaSubkeyL(5) = subl(4) ^ subl(6);
+ CamelliaSubkeyR(5) = subr(4) ^ subr(6);
+ CamelliaSubkeyL(6) = subl(5) ^ subl(7);
+ CamelliaSubkeyR(6) = subr(5) ^ subr(7);
+ tl = subl(10) ^ (subr(10) & ~subr(8));
+ dw = tl & subl(8), tr = subr(10) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(7) = subl(6) ^ tl;
+ CamelliaSubkeyR(7) = subr(6) ^ tr;
+ CamelliaSubkeyL(8) = subl(8);
+ CamelliaSubkeyR(8) = subr(8);
+ CamelliaSubkeyL(9) = subl(9);
+ CamelliaSubkeyR(9) = subr(9);
+ tl = subl(7) ^ (subr(7) & ~subr(9));
+ dw = tl & subl(9), tr = subr(7) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(10) = tl ^ subl(11);
+ CamelliaSubkeyR(10) = tr ^ subr(11);
+ CamelliaSubkeyL(11) = subl(10) ^ subl(12);
+ CamelliaSubkeyR(11) = subr(10) ^ subr(12);
+ CamelliaSubkeyL(12) = subl(11) ^ subl(13);
+ CamelliaSubkeyR(12) = subr(11) ^ subr(13);
+ CamelliaSubkeyL(13) = subl(12) ^ subl(14);
+ CamelliaSubkeyR(13) = subr(12) ^ subr(14);
+ CamelliaSubkeyL(14) = subl(13) ^ subl(15);
+ CamelliaSubkeyR(14) = subr(13) ^ subr(15);
+ tl = subl(18) ^ (subr(18) & ~subr(16));
+ dw = tl & subl(16), tr = subr(18) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(15) = subl(14) ^ tl;
+ CamelliaSubkeyR(15) = subr(14) ^ tr;
+ CamelliaSubkeyL(16) = subl(16);
+ CamelliaSubkeyR(16) = subr(16);
+ CamelliaSubkeyL(17) = subl(17);
+ CamelliaSubkeyR(17) = subr(17);
+ tl = subl(15) ^ (subr(15) & ~subr(17));
+ dw = tl & subl(17), tr = subr(15) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(18) = tl ^ subl(19);
+ CamelliaSubkeyR(18) = tr ^ subr(19);
+ CamelliaSubkeyL(19) = subl(18) ^ subl(20);
+ CamelliaSubkeyR(19) = subr(18) ^ subr(20);
+ CamelliaSubkeyL(20) = subl(19) ^ subl(21);
+ CamelliaSubkeyR(20) = subr(19) ^ subr(21);
+ CamelliaSubkeyL(21) = subl(20) ^ subl(22);
+ CamelliaSubkeyR(21) = subr(20) ^ subr(22);
+ CamelliaSubkeyL(22) = subl(21) ^ subl(23);
+ CamelliaSubkeyR(22) = subr(21) ^ subr(23);
+ CamelliaSubkeyL(23) = subl(22);
+ CamelliaSubkeyR(23) = subr(22);
+ CamelliaSubkeyL(24) = subl(24) ^ subl(23);
+ CamelliaSubkeyR(24) = subr(24) ^ subr(23);
+
+ /* apply the inverse of the last half of P-function */
+ dw = CamelliaSubkeyL(2) ^ CamelliaSubkeyR(2), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(2) = CamelliaSubkeyL(2) ^ dw, CamelliaSubkeyL(2) = dw;
+ dw = CamelliaSubkeyL(3) ^ CamelliaSubkeyR(3), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(3) = CamelliaSubkeyL(3) ^ dw, CamelliaSubkeyL(3) = dw;
+ dw = CamelliaSubkeyL(4) ^ CamelliaSubkeyR(4), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(4) = CamelliaSubkeyL(4) ^ dw, CamelliaSubkeyL(4) = dw;
+ dw = CamelliaSubkeyL(5) ^ CamelliaSubkeyR(5), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(5) = CamelliaSubkeyL(5) ^ dw, CamelliaSubkeyL(5) = dw;
+ dw = CamelliaSubkeyL(6) ^ CamelliaSubkeyR(6), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(6) = CamelliaSubkeyL(6) ^ dw, CamelliaSubkeyL(6) = dw;
+ dw = CamelliaSubkeyL(7) ^ CamelliaSubkeyR(7), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(7) = CamelliaSubkeyL(7) ^ dw, CamelliaSubkeyL(7) = dw;
+ dw = CamelliaSubkeyL(10) ^ CamelliaSubkeyR(10), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(10) = CamelliaSubkeyL(10) ^ dw, CamelliaSubkeyL(10) = dw;
+ dw = CamelliaSubkeyL(11) ^ CamelliaSubkeyR(11), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(11) = CamelliaSubkeyL(11) ^ dw, CamelliaSubkeyL(11) = dw;
+ dw = CamelliaSubkeyL(12) ^ CamelliaSubkeyR(12), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(12) = CamelliaSubkeyL(12) ^ dw, CamelliaSubkeyL(12) = dw;
+ dw = CamelliaSubkeyL(13) ^ CamelliaSubkeyR(13), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(13) = CamelliaSubkeyL(13) ^ dw, CamelliaSubkeyL(13) = dw;
+ dw = CamelliaSubkeyL(14) ^ CamelliaSubkeyR(14), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(14) = CamelliaSubkeyL(14) ^ dw, CamelliaSubkeyL(14) = dw;
+ dw = CamelliaSubkeyL(15) ^ CamelliaSubkeyR(15), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(15) = CamelliaSubkeyL(15) ^ dw, CamelliaSubkeyL(15) = dw;
+ dw = CamelliaSubkeyL(18) ^ CamelliaSubkeyR(18), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(18) = CamelliaSubkeyL(18) ^ dw, CamelliaSubkeyL(18) = dw;
+ dw = CamelliaSubkeyL(19) ^ CamelliaSubkeyR(19), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(19) = CamelliaSubkeyL(19) ^ dw, CamelliaSubkeyL(19) = dw;
+ dw = CamelliaSubkeyL(20) ^ CamelliaSubkeyR(20), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(20) = CamelliaSubkeyL(20) ^ dw, CamelliaSubkeyL(20) = dw;
+ dw = CamelliaSubkeyL(21) ^ CamelliaSubkeyR(21), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(21) = CamelliaSubkeyL(21) ^ dw, CamelliaSubkeyL(21) = dw;
+ dw = CamelliaSubkeyL(22) ^ CamelliaSubkeyR(22), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(22) = CamelliaSubkeyL(22) ^ dw, CamelliaSubkeyL(22) = dw;
+ dw = CamelliaSubkeyL(23) ^ CamelliaSubkeyR(23), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(23) = CamelliaSubkeyL(23) ^ dw, CamelliaSubkeyL(23) = dw;
+
+ return;
+}
+
+void camellia_setup256(const unsigned char *key, u32 *subkey)
+{
+ u32 kll,klr,krl,krr; /* left half of key */
+ u32 krll,krlr,krrl,krrr; /* right half of key */
+ u32 il, ir, t0, t1, w0, w1; /* temporary variables */
+ u32 kw4l, kw4r, dw, tl, tr;
+ u32 subL[34];
+ u32 subR[34];
+
+ /**
+ * key = (kll || klr || krl || krr || krll || krlr || krrl || krrr)
+ * (|| is concatination)
+ */
+
+ kll = GETU32(key );
+ klr = GETU32(key + 4);
+ krl = GETU32(key + 8);
+ krr = GETU32(key + 12);
+ krll = GETU32(key + 16);
+ krlr = GETU32(key + 20);
+ krrl = GETU32(key + 24);
+ krrr = GETU32(key + 28);
+
+ /* generate KL dependent subkeys */
+ subl(0) = kll; subr(0) = klr;
+ subl(1) = krl; subr(1) = krr;
+ CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 45);
+ subl(12) = kll; subr(12) = klr;
+ subl(13) = krl; subr(13) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(16) = kll; subr(16) = klr;
+ subl(17) = krl; subr(17) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+ subl(22) = kll; subr(22) = klr;
+ subl(23) = krl; subr(23) = krr;
+ CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34);
+ subl(30) = kll; subr(30) = klr;
+ subl(31) = krl; subr(31) = krr;
+
+ /* generate KR dependent subkeys */
+ CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15);
+ subl(4) = krll; subr(4) = krlr;
+ subl(5) = krrl; subr(5) = krrr;
+ CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15);
+ subl(8) = krll; subr(8) = krlr;
+ subl(9) = krrl; subr(9) = krrr;
+ CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+ subl(18) = krll; subr(18) = krlr;
+ subl(19) = krrl; subr(19) = krrr;
+ CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34);
+ subl(26) = krll; subr(26) = krlr;
+ subl(27) = krrl; subr(27) = krrr;
+ CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34);
+
+ /* generate KA */
+ kll = subl(0) ^ krll; klr = subr(0) ^ krlr;
+ krl = subl(1) ^ krrl; krr = subr(1) ^ krrr;
+ CAMELLIA_F(kll, klr,
+ CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R,
+ w0, w1, il, ir, t0, t1);
+ krl ^= w0; krr ^= w1;
+ CAMELLIA_F(krl, krr,
+ CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R,
+ kll, klr, il, ir, t0, t1);
+ kll ^= krll; klr ^= krlr;
+ CAMELLIA_F(kll, klr,
+ CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R,
+ krl, krr, il, ir, t0, t1);
+ krl ^= w0 ^ krrl; krr ^= w1 ^ krrr;
+ CAMELLIA_F(krl, krr,
+ CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R,
+ w0, w1, il, ir, t0, t1);
+ kll ^= w0; klr ^= w1;
+
+ /* generate KB */
+ krll ^= kll; krlr ^= klr;
+ krrl ^= krl; krrr ^= krr;
+ CAMELLIA_F(krll, krlr,
+ CAMELLIA_SIGMA5L, CAMELLIA_SIGMA5R,
+ w0, w1, il, ir, t0, t1);
+ krrl ^= w0; krrr ^= w1;
+ CAMELLIA_F(krrl, krrr,
+ CAMELLIA_SIGMA6L, CAMELLIA_SIGMA6R,
+ w0, w1, il, ir, t0, t1);
+ krll ^= w0; krlr ^= w1;
+
+ /* generate KA dependent subkeys */
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(6) = kll; subr(6) = klr;
+ subl(7) = krl; subr(7) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30);
+ subl(14) = kll; subr(14) = klr;
+ subl(15) = krl; subr(15) = krr;
+ subl(24) = klr; subr(24) = krl;
+ subl(25) = krr; subr(25) = kll;
+ CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 49);
+ subl(28) = kll; subr(28) = klr;
+ subl(29) = krl; subr(29) = krr;
+
+ /* generate KB dependent subkeys */
+ subl(2) = krll; subr(2) = krlr;
+ subl(3) = krrl; subr(3) = krrr;
+ CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+ subl(10) = krll; subr(10) = krlr;
+ subl(11) = krrl; subr(11) = krrr;
+ CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+ subl(20) = krll; subr(20) = krlr;
+ subl(21) = krrl; subr(21) = krrr;
+ CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 51);
+ subl(32) = krll; subr(32) = krlr;
+ subl(33) = krrl; subr(33) = krrr;
+
+ /* absorb kw2 to other subkeys */
+ subl(3) ^= subl(1); subr(3) ^= subr(1);
+ subl(5) ^= subl(1); subr(5) ^= subr(1);
+ subl(7) ^= subl(1); subr(7) ^= subr(1);
+ subl(1) ^= subr(1) & ~subr(9);
+ dw = subl(1) & subl(9), subr(1) ^= CAMELLIA_RL1(dw);
+ subl(11) ^= subl(1); subr(11) ^= subr(1);
+ subl(13) ^= subl(1); subr(13) ^= subr(1);
+ subl(15) ^= subl(1); subr(15) ^= subr(1);
+ subl(1) ^= subr(1) & ~subr(17);
+ dw = subl(1) & subl(17), subr(1) ^= CAMELLIA_RL1(dw);
+ subl(19) ^= subl(1); subr(19) ^= subr(1);
+ subl(21) ^= subl(1); subr(21) ^= subr(1);
+ subl(23) ^= subl(1); subr(23) ^= subr(1);
+ subl(1) ^= subr(1) & ~subr(25);
+ dw = subl(1) & subl(25), subr(1) ^= CAMELLIA_RL1(dw);
+ subl(27) ^= subl(1); subr(27) ^= subr(1);
+ subl(29) ^= subl(1); subr(29) ^= subr(1);
+ subl(31) ^= subl(1); subr(31) ^= subr(1);
+ subl(32) ^= subl(1); subr(32) ^= subr(1);
+
+ /* absorb kw4 to other subkeys */
+ kw4l = subl(33); kw4r = subr(33);
+ subl(30) ^= kw4l; subr(30) ^= kw4r;
+ subl(28) ^= kw4l; subr(28) ^= kw4r;
+ subl(26) ^= kw4l; subr(26) ^= kw4r;
+ kw4l ^= kw4r & ~subr(24);
+ dw = kw4l & subl(24), kw4r ^= CAMELLIA_RL1(dw);
+ subl(22) ^= kw4l; subr(22) ^= kw4r;
+ subl(20) ^= kw4l; subr(20) ^= kw4r;
+ subl(18) ^= kw4l; subr(18) ^= kw4r;
+ kw4l ^= kw4r & ~subr(16);
+ dw = kw4l & subl(16), kw4r ^= CAMELLIA_RL1(dw);
+ subl(14) ^= kw4l; subr(14) ^= kw4r;
+ subl(12) ^= kw4l; subr(12) ^= kw4r;
+ subl(10) ^= kw4l; subr(10) ^= kw4r;
+ kw4l ^= kw4r & ~subr(8);
+ dw = kw4l & subl(8), kw4r ^= CAMELLIA_RL1(dw);
+ subl(6) ^= kw4l; subr(6) ^= kw4r;
+ subl(4) ^= kw4l; subr(4) ^= kw4r;
+ subl(2) ^= kw4l; subr(2) ^= kw4r;
+ subl(0) ^= kw4l; subr(0) ^= kw4r;
+
+ /* key XOR is end of F-function */
+ CamelliaSubkeyL(0) = subl(0) ^ subl(2);
+ CamelliaSubkeyR(0) = subr(0) ^ subr(2);
+ CamelliaSubkeyL(2) = subl(3);
+ CamelliaSubkeyR(2) = subr(3);
+ CamelliaSubkeyL(3) = subl(2) ^ subl(4);
+ CamelliaSubkeyR(3) = subr(2) ^ subr(4);
+ CamelliaSubkeyL(4) = subl(3) ^ subl(5);
+ CamelliaSubkeyR(4) = subr(3) ^ subr(5);
+ CamelliaSubkeyL(5) = subl(4) ^ subl(6);
+ CamelliaSubkeyR(5) = subr(4) ^ subr(6);
+ CamelliaSubkeyL(6) = subl(5) ^ subl(7);
+ CamelliaSubkeyR(6) = subr(5) ^ subr(7);
+ tl = subl(10) ^ (subr(10) & ~subr(8));
+ dw = tl & subl(8), tr = subr(10) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(7) = subl(6) ^ tl;
+ CamelliaSubkeyR(7) = subr(6) ^ tr;
+ CamelliaSubkeyL(8) = subl(8);
+ CamelliaSubkeyR(8) = subr(8);
+ CamelliaSubkeyL(9) = subl(9);
+ CamelliaSubkeyR(9) = subr(9);
+ tl = subl(7) ^ (subr(7) & ~subr(9));
+ dw = tl & subl(9), tr = subr(7) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(10) = tl ^ subl(11);
+ CamelliaSubkeyR(10) = tr ^ subr(11);
+ CamelliaSubkeyL(11) = subl(10) ^ subl(12);
+ CamelliaSubkeyR(11) = subr(10) ^ subr(12);
+ CamelliaSubkeyL(12) = subl(11) ^ subl(13);
+ CamelliaSubkeyR(12) = subr(11) ^ subr(13);
+ CamelliaSubkeyL(13) = subl(12) ^ subl(14);
+ CamelliaSubkeyR(13) = subr(12) ^ subr(14);
+ CamelliaSubkeyL(14) = subl(13) ^ subl(15);
+ CamelliaSubkeyR(14) = subr(13) ^ subr(15);
+ tl = subl(18) ^ (subr(18) & ~subr(16));
+ dw = tl & subl(16), tr = subr(18) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(15) = subl(14) ^ tl;
+ CamelliaSubkeyR(15) = subr(14) ^ tr;
+ CamelliaSubkeyL(16) = subl(16);
+ CamelliaSubkeyR(16) = subr(16);
+ CamelliaSubkeyL(17) = subl(17);
+ CamelliaSubkeyR(17) = subr(17);
+ tl = subl(15) ^ (subr(15) & ~subr(17));
+ dw = tl & subl(17), tr = subr(15) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(18) = tl ^ subl(19);
+ CamelliaSubkeyR(18) = tr ^ subr(19);
+ CamelliaSubkeyL(19) = subl(18) ^ subl(20);
+ CamelliaSubkeyR(19) = subr(18) ^ subr(20);
+ CamelliaSubkeyL(20) = subl(19) ^ subl(21);
+ CamelliaSubkeyR(20) = subr(19) ^ subr(21);
+ CamelliaSubkeyL(21) = subl(20) ^ subl(22);
+ CamelliaSubkeyR(21) = subr(20) ^ subr(22);
+ CamelliaSubkeyL(22) = subl(21) ^ subl(23);
+ CamelliaSubkeyR(22) = subr(21) ^ subr(23);
+ tl = subl(26) ^ (subr(26) & ~subr(24));
+ dw = tl & subl(24), tr = subr(26) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(23) = subl(22) ^ tl;
+ CamelliaSubkeyR(23) = subr(22) ^ tr;
+ CamelliaSubkeyL(24) = subl(24);
+ CamelliaSubkeyR(24) = subr(24);
+ CamelliaSubkeyL(25) = subl(25);
+ CamelliaSubkeyR(25) = subr(25);
+ tl = subl(23) ^ (subr(23) & ~subr(25));
+ dw = tl & subl(25), tr = subr(23) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(26) = tl ^ subl(27);
+ CamelliaSubkeyR(26) = tr ^ subr(27);
+ CamelliaSubkeyL(27) = subl(26) ^ subl(28);
+ CamelliaSubkeyR(27) = subr(26) ^ subr(28);
+ CamelliaSubkeyL(28) = subl(27) ^ subl(29);
+ CamelliaSubkeyR(28) = subr(27) ^ subr(29);
+ CamelliaSubkeyL(29) = subl(28) ^ subl(30);
+ CamelliaSubkeyR(29) = subr(28) ^ subr(30);
+ CamelliaSubkeyL(30) = subl(29) ^ subl(31);
+ CamelliaSubkeyR(30) = subr(29) ^ subr(31);
+ CamelliaSubkeyL(31) = subl(30);
+ CamelliaSubkeyR(31) = subr(30);
+ CamelliaSubkeyL(32) = subl(32) ^ subl(31);
+ CamelliaSubkeyR(32) = subr(32) ^ subr(31);
+
+ /* apply the inverse of the last half of P-function */
+ dw = CamelliaSubkeyL(2) ^ CamelliaSubkeyR(2), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(2) = CamelliaSubkeyL(2) ^ dw, CamelliaSubkeyL(2) = dw;
+ dw = CamelliaSubkeyL(3) ^ CamelliaSubkeyR(3), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(3) = CamelliaSubkeyL(3) ^ dw, CamelliaSubkeyL(3) = dw;
+ dw = CamelliaSubkeyL(4) ^ CamelliaSubkeyR(4), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(4) = CamelliaSubkeyL(4) ^ dw, CamelliaSubkeyL(4) = dw;
+ dw = CamelliaSubkeyL(5) ^ CamelliaSubkeyR(5), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(5) = CamelliaSubkeyL(5) ^ dw, CamelliaSubkeyL(5) = dw;
+ dw = CamelliaSubkeyL(6) ^ CamelliaSubkeyR(6), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(6) = CamelliaSubkeyL(6) ^ dw, CamelliaSubkeyL(6) = dw;
+ dw = CamelliaSubkeyL(7) ^ CamelliaSubkeyR(7), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(7) = CamelliaSubkeyL(7) ^ dw, CamelliaSubkeyL(7) = dw;
+ dw = CamelliaSubkeyL(10) ^ CamelliaSubkeyR(10), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(10) = CamelliaSubkeyL(10) ^ dw, CamelliaSubkeyL(10) = dw;
+ dw = CamelliaSubkeyL(11) ^ CamelliaSubkeyR(11), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(11) = CamelliaSubkeyL(11) ^ dw, CamelliaSubkeyL(11) = dw;
+ dw = CamelliaSubkeyL(12) ^ CamelliaSubkeyR(12), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(12) = CamelliaSubkeyL(12) ^ dw, CamelliaSubkeyL(12) = dw;
+ dw = CamelliaSubkeyL(13) ^ CamelliaSubkeyR(13), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(13) = CamelliaSubkeyL(13) ^ dw, CamelliaSubkeyL(13) = dw;
+ dw = CamelliaSubkeyL(14) ^ CamelliaSubkeyR(14), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(14) = CamelliaSubkeyL(14) ^ dw, CamelliaSubkeyL(14) = dw;
+ dw = CamelliaSubkeyL(15) ^ CamelliaSubkeyR(15), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(15) = CamelliaSubkeyL(15) ^ dw, CamelliaSubkeyL(15) = dw;
+ dw = CamelliaSubkeyL(18) ^ CamelliaSubkeyR(18), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(18) = CamelliaSubkeyL(18) ^ dw, CamelliaSubkeyL(18) = dw;
+ dw = CamelliaSubkeyL(19) ^ CamelliaSubkeyR(19), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(19) = CamelliaSubkeyL(19) ^ dw, CamelliaSubkeyL(19) = dw;
+ dw = CamelliaSubkeyL(20) ^ CamelliaSubkeyR(20), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(20) = CamelliaSubkeyL(20) ^ dw, CamelliaSubkeyL(20) = dw;
+ dw = CamelliaSubkeyL(21) ^ CamelliaSubkeyR(21), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(21) = CamelliaSubkeyL(21) ^ dw, CamelliaSubkeyL(21) = dw;
+ dw = CamelliaSubkeyL(22) ^ CamelliaSubkeyR(22), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(22) = CamelliaSubkeyL(22) ^ dw, CamelliaSubkeyL(22) = dw;
+ dw = CamelliaSubkeyL(23) ^ CamelliaSubkeyR(23), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(23) = CamelliaSubkeyL(23) ^ dw, CamelliaSubkeyL(23) = dw;
+ dw = CamelliaSubkeyL(26) ^ CamelliaSubkeyR(26), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(26) = CamelliaSubkeyL(26) ^ dw, CamelliaSubkeyL(26) = dw;
+ dw = CamelliaSubkeyL(27) ^ CamelliaSubkeyR(27), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(27) = CamelliaSubkeyL(27) ^ dw, CamelliaSubkeyL(27) = dw;
+ dw = CamelliaSubkeyL(28) ^ CamelliaSubkeyR(28), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(28) = CamelliaSubkeyL(28) ^ dw, CamelliaSubkeyL(28) = dw;
+ dw = CamelliaSubkeyL(29) ^ CamelliaSubkeyR(29), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(29) = CamelliaSubkeyL(29) ^ dw, CamelliaSubkeyL(29) = dw;
+ dw = CamelliaSubkeyL(30) ^ CamelliaSubkeyR(30), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(30) = CamelliaSubkeyL(30) ^ dw, CamelliaSubkeyL(30) = dw;
+ dw = CamelliaSubkeyL(31) ^ CamelliaSubkeyR(31), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(31) = CamelliaSubkeyL(31) ^ dw,CamelliaSubkeyL(31) = dw;
+
+ return;
+}
+
+void camellia_setup192(const unsigned char *key, u32 *subkey)
+{
+ unsigned char kk[32];
+ u32 krll, krlr, krrl,krrr;
+
+ memcpy(kk, key, 24);
+ memcpy((unsigned char *)&krll, key+16,4);
+ memcpy((unsigned char *)&krlr, key+20,4);
+ krrl = ~krll;
+ krrr = ~krlr;
+ memcpy(kk+24, (unsigned char *)&krrl, 4);
+ memcpy(kk+28, (unsigned char *)&krrr, 4);
+ camellia_setup256(kk, subkey);
+ return;
+}
+
+
+/**
+ * Stuff related to camellia encryption/decryption
+ *
+ * "io" must be 4byte aligned and big-endian data.
+ */
+void camellia_encrypt128(const u32 *subkey, u32 *io)
+{
+ u32 il, ir, t0, t1;
+
+ /* pre whitening but absorb kw2*/
+ io[0] ^= CamelliaSubkeyL(0);
+ io[1] ^= CamelliaSubkeyR(0);
+ /* main iteration */
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(2),CamelliaSubkeyR(2),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(3),CamelliaSubkeyR(3),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(4),CamelliaSubkeyR(4),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(5),CamelliaSubkeyR(5),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(6),CamelliaSubkeyR(6),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(7),CamelliaSubkeyR(7),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(8),CamelliaSubkeyR(8),
+ CamelliaSubkeyL(9),CamelliaSubkeyR(9),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(10),CamelliaSubkeyR(10),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(11),CamelliaSubkeyR(11),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(12),CamelliaSubkeyR(12),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(13),CamelliaSubkeyR(13),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(14),CamelliaSubkeyR(14),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(15),CamelliaSubkeyR(15),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(16),CamelliaSubkeyR(16),
+ CamelliaSubkeyL(17),CamelliaSubkeyR(17),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(18),CamelliaSubkeyR(18),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(19),CamelliaSubkeyR(19),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(20),CamelliaSubkeyR(20),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(21),CamelliaSubkeyR(21),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(22),CamelliaSubkeyR(22),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(23),CamelliaSubkeyR(23),
+ io[0],io[1],il,ir,t0,t1);
+
+ /* post whitening but kw4 */
+ io[2] ^= CamelliaSubkeyL(24);
+ io[3] ^= CamelliaSubkeyR(24);
+
+ t0 = io[0];
+ t1 = io[1];
+ io[0] = io[2];
+ io[1] = io[3];
+ io[2] = t0;
+ io[3] = t1;
+
+ return;
+}
+
+void camellia_decrypt128(const u32 *subkey, u32 *io)
+{
+ u32 il,ir,t0,t1; /* temporary valiables */
+
+ /* pre whitening but absorb kw2*/
+ io[0] ^= CamelliaSubkeyL(24);
+ io[1] ^= CamelliaSubkeyR(24);
+
+ /* main iteration */
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(23),CamelliaSubkeyR(23),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(22),CamelliaSubkeyR(22),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(21),CamelliaSubkeyR(21),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(20),CamelliaSubkeyR(20),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(19),CamelliaSubkeyR(19),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(18),CamelliaSubkeyR(18),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(17),CamelliaSubkeyR(17),
+ CamelliaSubkeyL(16),CamelliaSubkeyR(16),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(15),CamelliaSubkeyR(15),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(14),CamelliaSubkeyR(14),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(13),CamelliaSubkeyR(13),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(12),CamelliaSubkeyR(12),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(11),CamelliaSubkeyR(11),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(10),CamelliaSubkeyR(10),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(9),CamelliaSubkeyR(9),
+ CamelliaSubkeyL(8),CamelliaSubkeyR(8),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(7),CamelliaSubkeyR(7),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(6),CamelliaSubkeyR(6),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(5),CamelliaSubkeyR(5),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(4),CamelliaSubkeyR(4),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(3),CamelliaSubkeyR(3),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(2),CamelliaSubkeyR(2),
+ io[0],io[1],il,ir,t0,t1);
+
+ /* post whitening but kw4 */
+ io[2] ^= CamelliaSubkeyL(0);
+ io[3] ^= CamelliaSubkeyR(0);
+
+ t0 = io[0];
+ t1 = io[1];
+ io[0] = io[2];
+ io[1] = io[3];
+ io[2] = t0;
+ io[3] = t1;
+
+ return;
+}
+
+/**
+ * stuff for 192 and 256bit encryption/decryption
+ */
+void camellia_encrypt256(const u32 *subkey, u32 *io)
+{
+ u32 il,ir,t0,t1; /* temporary valiables */
+
+ /* pre whitening but absorb kw2*/
+ io[0] ^= CamelliaSubkeyL(0);
+ io[1] ^= CamelliaSubkeyR(0);
+
+ /* main iteration */
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(2),CamelliaSubkeyR(2),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(3),CamelliaSubkeyR(3),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(4),CamelliaSubkeyR(4),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(5),CamelliaSubkeyR(5),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(6),CamelliaSubkeyR(6),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(7),CamelliaSubkeyR(7),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(8),CamelliaSubkeyR(8),
+ CamelliaSubkeyL(9),CamelliaSubkeyR(9),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(10),CamelliaSubkeyR(10),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(11),CamelliaSubkeyR(11),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(12),CamelliaSubkeyR(12),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(13),CamelliaSubkeyR(13),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(14),CamelliaSubkeyR(14),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(15),CamelliaSubkeyR(15),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(16),CamelliaSubkeyR(16),
+ CamelliaSubkeyL(17),CamelliaSubkeyR(17),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(18),CamelliaSubkeyR(18),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(19),CamelliaSubkeyR(19),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(20),CamelliaSubkeyR(20),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(21),CamelliaSubkeyR(21),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(22),CamelliaSubkeyR(22),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(23),CamelliaSubkeyR(23),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(24),CamelliaSubkeyR(24),
+ CamelliaSubkeyL(25),CamelliaSubkeyR(25),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(26),CamelliaSubkeyR(26),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(27),CamelliaSubkeyR(27),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(28),CamelliaSubkeyR(28),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(29),CamelliaSubkeyR(29),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(30),CamelliaSubkeyR(30),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(31),CamelliaSubkeyR(31),
+ io[0],io[1],il,ir,t0,t1);
+
+ /* post whitening but kw4 */
+ io[2] ^= CamelliaSubkeyL(32);
+ io[3] ^= CamelliaSubkeyR(32);
+
+ t0 = io[0];
+ t1 = io[1];
+ io[0] = io[2];
+ io[1] = io[3];
+ io[2] = t0;
+ io[3] = t1;
+
+ return;
+}
+
+void camellia_decrypt256(const u32 *subkey, u32 *io)
+{
+ u32 il,ir,t0,t1; /* temporary valiables */
+
+ /* pre whitening but absorb kw2*/
+ io[0] ^= CamelliaSubkeyL(32);
+ io[1] ^= CamelliaSubkeyR(32);
+
+ /* main iteration */
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(31),CamelliaSubkeyR(31),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(30),CamelliaSubkeyR(30),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(29),CamelliaSubkeyR(29),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(28),CamelliaSubkeyR(28),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(27),CamelliaSubkeyR(27),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(26),CamelliaSubkeyR(26),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(25),CamelliaSubkeyR(25),
+ CamelliaSubkeyL(24),CamelliaSubkeyR(24),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(23),CamelliaSubkeyR(23),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(22),CamelliaSubkeyR(22),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(21),CamelliaSubkeyR(21),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(20),CamelliaSubkeyR(20),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(19),CamelliaSubkeyR(19),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(18),CamelliaSubkeyR(18),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(17),CamelliaSubkeyR(17),
+ CamelliaSubkeyL(16),CamelliaSubkeyR(16),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(15),CamelliaSubkeyR(15),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(14),CamelliaSubkeyR(14),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(13),CamelliaSubkeyR(13),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(12),CamelliaSubkeyR(12),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(11),CamelliaSubkeyR(11),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(10),CamelliaSubkeyR(10),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(9),CamelliaSubkeyR(9),
+ CamelliaSubkeyL(8),CamelliaSubkeyR(8),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(7),CamelliaSubkeyR(7),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(6),CamelliaSubkeyR(6),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(5),CamelliaSubkeyR(5),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(4),CamelliaSubkeyR(4),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(3),CamelliaSubkeyR(3),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(2),CamelliaSubkeyR(2),
+ io[0],io[1],il,ir,t0,t1);
+
+ /* post whitening but kw4 */
+ io[2] ^= CamelliaSubkeyL(0);
+ io[3] ^= CamelliaSubkeyR(0);
+
+ t0 = io[0];
+ t1 = io[1];
+ io[0] = io[2];
+ io[1] = io[3];
+ io[2] = t0;
+ io[3] = t1;
+
+ return;
+}
+
+/***
+ *
+ * API for compatibility
+ */
+
+void Camellia_Ekeygen(const int keyBitLength,
+ const unsigned char *rawKey,
+ KEY_TABLE_TYPE keyTable)
+{
+ switch(keyBitLength) {
+ case 128:
+ camellia_setup128(rawKey, keyTable);
+ break;
+ case 192:
+ camellia_setup192(rawKey, keyTable);
+ break;
+ case 256:
+ camellia_setup256(rawKey, keyTable);
+ break;
+ default:
+ break;
+ }
+}
+
+
+void Camellia_EncryptBlock(const int keyBitLength,
+ const unsigned char *plaintext,
+ const KEY_TABLE_TYPE keyTable,
+ unsigned char *ciphertext)
+{
+ u32 tmp[4];
+
+ tmp[0] = GETU32(plaintext);
+ tmp[1] = GETU32(plaintext + 4);
+ tmp[2] = GETU32(plaintext + 8);
+ tmp[3] = GETU32(plaintext + 12);
+
+ switch (keyBitLength) {
+ case 128:
+ camellia_encrypt128(keyTable, tmp);
+ break;
+ case 192:
+ /* fall through */
+ case 256:
+ camellia_encrypt256(keyTable, tmp);
+ break;
+ default:
+ break;
+ }
+
+ PUTU32(ciphertext, tmp[0]);
+ PUTU32(ciphertext + 4, tmp[1]);
+ PUTU32(ciphertext + 8, tmp[2]);
+ PUTU32(ciphertext + 12, tmp[3]);
+}
+
+void Camellia_DecryptBlock(const int keyBitLength,
+ const unsigned char *ciphertext,
+ const KEY_TABLE_TYPE keyTable,
+ unsigned char *plaintext)
+{
+ u32 tmp[4];
+
+ tmp[0] = GETU32(ciphertext);
+ tmp[1] = GETU32(ciphertext + 4);
+ tmp[2] = GETU32(ciphertext + 8);
+ tmp[3] = GETU32(ciphertext + 12);
+
+ switch (keyBitLength) {
+ case 128:
+ camellia_decrypt128(keyTable, tmp);
+ break;
+ case 192:
+ /* fall through */
+ case 256:
+ camellia_decrypt256(keyTable, tmp);
+ break;
+ default:
+ break;
+ }
+ PUTU32(plaintext, tmp[0]);
+ PUTU32(plaintext + 4, tmp[1]);
+ PUTU32(plaintext + 8, tmp[2]);
+ PUTU32(plaintext + 12, tmp[3]);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/camellia.h b/grub-core/lib/libgcrypt-grub/cipher/camellia.h
new file mode 100644
index 0000000..2ab2ddd
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/camellia.h
@@ -0,0 +1,94 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+#include <grub/misc.h>
+void camellia_setup128(const unsigned char *key, grub_uint32_t *subkey);
+void camellia_setup192(const unsigned char *key, grub_uint32_t *subkey);
+void camellia_setup256(const unsigned char *key, grub_uint32_t *subkey);
+void camellia_encrypt128(const grub_uint32_t *subkey, grub_uint32_t *io);
+void camellia_encrypt192(const grub_uint32_t *subkey, grub_uint32_t *io);
+void camellia_encrypt256(const grub_uint32_t *subkey, grub_uint32_t *io);
+void camellia_decrypt128(const grub_uint32_t *subkey, grub_uint32_t *io);
+void camellia_decrypt192(const grub_uint32_t *subkey, grub_uint32_t *io);
+void camellia_decrypt256(const grub_uint32_t *subkey, grub_uint32_t *io);
+#define memcpy grub_memcpy
+/* camellia.h ver 1.2.0
+ *
+ * Copyright (C) 2006,2007
+ * NTT (Nippon Telegraph and Telephone Corporation).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef HEADER_CAMELLIA_H
+#define HEADER_CAMELLIA_H
+
+/* To use Camellia with libraries it is often useful to keep the name
+ * space of the library clean. The following macro is thus useful:
+ *
+ * #define CAMELLIA_EXT_SYM_PREFIX foo_
+ *
+ * This prefixes all external symbols with "foo_".
+ */
+#ifdef HAVE_CONFIG_H
+#endif
+#ifdef CAMELLIA_EXT_SYM_PREFIX
+#define CAMELLIA_PREFIX1(x,y) x ## y
+#define CAMELLIA_PREFIX2(x,y) CAMELLIA_PREFIX1(x,y)
+#define CAMELLIA_PREFIX(x) CAMELLIA_PREFIX2(CAMELLIA_EXT_SYM_PREFIX,x)
+#define Camellia_Ekeygen CAMELLIA_PREFIX(Camellia_Ekeygen)
+#define Camellia_EncryptBlock CAMELLIA_PREFIX(Camellia_EncryptBlock)
+#define Camellia_DecryptBlock CAMELLIA_PREFIX(Camellia_DecryptBlock)
+#define camellia_decrypt128 CAMELLIA_PREFIX(camellia_decrypt128)
+#define camellia_decrypt256 CAMELLIA_PREFIX(camellia_decrypt256)
+#define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128)
+#define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256)
+#define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128)
+#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192)
+#define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256)
+#endif /*CAMELLIA_EXT_SYM_PREFIX*/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CAMELLIA_BLOCK_SIZE 16
+#define CAMELLIA_TABLE_BYTE_LEN 272
+#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
+
+typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
+
+
+void Camellia_Ekeygen(const int keyBitLength,
+ const unsigned char *rawKey,
+ KEY_TABLE_TYPE keyTable);
+
+void Camellia_EncryptBlock(const int keyBitLength,
+ const unsigned char *plaintext,
+ const KEY_TABLE_TYPE keyTable,
+ unsigned char *cipherText);
+
+void Camellia_DecryptBlock(const int keyBitLength,
+ const unsigned char *cipherText,
+ const KEY_TABLE_TYPE keyTable,
+ unsigned char *plaintext);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HEADER_CAMELLIA_H */
diff --git a/grub-core/lib/libgcrypt-grub/cipher/cast5.c b/grub-core/lib/libgcrypt-grub/cipher/cast5.c
new file mode 100644
index 0000000..8598fa3
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/cast5.c
@@ -0,0 +1,590 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* cast5.c - CAST5 cipher (RFC2144)
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/* Test vectors:
+ *
+ * 128-bit key = 01 23 45 67 12 34 56 78 23 45 67 89 34 56 78 9A
+ * plaintext = 01 23 45 67 89 AB CD EF
+ * ciphertext = 23 8B 4F E5 84 7E 44 B2
+ *
+ * 80-bit key = 01 23 45 67 12 34 56 78 23 45
+ * = 01 23 45 67 12 34 56 78 23 45 00 00 00 00 00 00
+ * plaintext = 01 23 45 67 89 AB CD EF
+ * ciphertext = EB 6A 71 1A 2C 02 27 1B
+ *
+ * 40-bit key = 01 23 45 67 12
+ * = 01 23 45 67 12 00 00 00 00 00 00 00 00 00 00 00
+ * plaintext = 01 23 45 67 89 AB CD EF
+ * ciphertext = 7A C8 16 D1 6E 9B 30 2E
+ */
+
+#include "g10lib.h"
+#include "types.h"
+#include "cipher.h"
+
+#define CAST5_BLOCKSIZE 8
+
+typedef struct {
+ u32 Km[16];
+ byte Kr[16];
+} CAST5_context;
+
+static gcry_err_code_t cast_setkey (void *c, const byte *key, unsigned keylen);
+static void encrypt_block (void *c, byte *outbuf, const byte *inbuf);
+static void decrypt_block (void *c, byte *outbuf, const byte *inbuf);
+
+
+
+
+static const u32 s1[256] = {
+0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x9c004dd3, 0x6003e540, 0xcf9fc949,
+0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, 0x15c361d2, 0xc2e7661d, 0x22d4ff8e,
+0x28683b6f, 0xc07fd059, 0xff2379c8, 0x775f50e2, 0x43c340d3, 0xdf2f8656, 0x887ca41a, 0xa2d2bd2d,
+0xa1c9e0d6, 0x346c4819, 0x61b76d87, 0x22540f2f, 0x2abe32e1, 0xaa54166b, 0x22568e3a, 0xa2d341d0,
+0x66db40c8, 0xa784392f, 0x004dff2f, 0x2db9d2de, 0x97943fac, 0x4a97c1d8, 0x527644b7, 0xb5f437a7,
+0xb82cbaef, 0xd751d159, 0x6ff7f0ed, 0x5a097a1f, 0x827b68d0, 0x90ecf52e, 0x22b0c054, 0xbc8e5935,
+0x4b6d2f7f, 0x50bb64a2, 0xd2664910, 0xbee5812d, 0xb7332290, 0xe93b159f, 0xb48ee411, 0x4bff345d,
+0xfd45c240, 0xad31973f, 0xc4f6d02e, 0x55fc8165, 0xd5b1caad, 0xa1ac2dae, 0xa2d4b76d, 0xc19b0c50,
+0x882240f2, 0x0c6e4f38, 0xa4e4bfd7, 0x4f5ba272, 0x564c1d2f, 0xc59c5319, 0xb949e354, 0xb04669fe,
+0xb1b6ab8a, 0xc71358dd, 0x6385c545, 0x110f935d, 0x57538ad5, 0x6a390493, 0xe63d37e0, 0x2a54f6b3,
+0x3a787d5f, 0x6276a0b5, 0x19a6fcdf, 0x7a42206a, 0x29f9d4d5, 0xf61b1891, 0xbb72275e, 0xaa508167,
+0x38901091, 0xc6b505eb, 0x84c7cb8c, 0x2ad75a0f, 0x874a1427, 0xa2d1936b, 0x2ad286af, 0xaa56d291,
+0xd7894360, 0x425c750d, 0x93b39e26, 0x187184c9, 0x6c00b32d, 0x73e2bb14, 0xa0bebc3c, 0x54623779,
+0x64459eab, 0x3f328b82, 0x7718cf82, 0x59a2cea6, 0x04ee002e, 0x89fe78e6, 0x3fab0950, 0x325ff6c2,
+0x81383f05, 0x6963c5c8, 0x76cb5ad6, 0xd49974c9, 0xca180dcf, 0x380782d5, 0xc7fa5cf6, 0x8ac31511,
+0x35e79e13, 0x47da91d0, 0xf40f9086, 0xa7e2419e, 0x31366241, 0x051ef495, 0xaa573b04, 0x4a805d8d,
+0x548300d0, 0x00322a3c, 0xbf64cddf, 0xba57a68e, 0x75c6372b, 0x50afd341, 0xa7c13275, 0x915a0bf5,
+0x6b54bfab, 0x2b0b1426, 0xab4cc9d7, 0x449ccd82, 0xf7fbf265, 0xab85c5f3, 0x1b55db94, 0xaad4e324,
+0xcfa4bd3f, 0x2deaa3e2, 0x9e204d02, 0xc8bd25ac, 0xeadf55b3, 0xd5bd9e98, 0xe31231b2, 0x2ad5ad6c,
+0x954329de, 0xadbe4528, 0xd8710f69, 0xaa51c90f, 0xaa786bf6, 0x22513f1e, 0xaa51a79b, 0x2ad344cc,
+0x7b5a41f0, 0xd37cfbad, 0x1b069505, 0x41ece491, 0xb4c332e6, 0x032268d4, 0xc9600acc, 0xce387e6d,
+0xbf6bb16c, 0x6a70fb78, 0x0d03d9c9, 0xd4df39de, 0xe01063da, 0x4736f464, 0x5ad328d8, 0xb347cc96,
+0x75bb0fc3, 0x98511bfb, 0x4ffbcc35, 0xb58bcf6a, 0xe11f0abc, 0xbfc5fe4a, 0xa70aec10, 0xac39570a,
+0x3f04442f, 0x6188b153, 0xe0397a2e, 0x5727cb79, 0x9ceb418f, 0x1cacd68d, 0x2ad37c96, 0x0175cb9d,
+0xc69dff09, 0xc75b65f0, 0xd9db40d8, 0xec0e7779, 0x4744ead4, 0xb11c3274, 0xdd24cb9e, 0x7e1c54bd,
+0xf01144f9, 0xd2240eb1, 0x9675b3fd, 0xa3ac3755, 0xd47c27af, 0x51c85f4d, 0x56907596, 0xa5bb15e6,
+0x580304f0, 0xca042cf1, 0x011a37ea, 0x8dbfaadb, 0x35ba3e4a, 0x3526ffa0, 0xc37b4d09, 0xbc306ed9,
+0x98a52666, 0x5648f725, 0xff5e569d, 0x0ced63d0, 0x7c63b2cf, 0x700b45e1, 0xd5ea50f1, 0x85a92872,
+0xaf1fbda7, 0xd4234870, 0xa7870bf3, 0x2d3b4d79, 0x42e04198, 0x0cd0ede7, 0x26470db8, 0xf881814c,
+0x474d6ad7, 0x7c0c5e5c, 0xd1231959, 0x381b7298, 0xf5d2f4db, 0xab838653, 0x6e2f1e23, 0x83719c9e,
+0xbd91e046, 0x9a56456e, 0xdc39200c, 0x20c8c571, 0x962bda1c, 0xe1e696ff, 0xb141ab08, 0x7cca89b9,
+0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c, 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf
+};
+static const u32 s2[256] = {
+0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, 0xeec5207a, 0x55889c94, 0x72fc0651,
+0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, 0x5f0c0794, 0x18dcdb7d, 0xa1d6eff3,
+0xa0b52f7b, 0x59e83605, 0xee15b094, 0xe9ffd909, 0xdc440086, 0xef944459, 0xba83ccb3, 0xe0c3cdfb,
+0xd1da4181, 0x3b092ab1, 0xf997f1c1, 0xa5e6cf7b, 0x01420ddb, 0xe4e7ef5b, 0x25a1ff41, 0xe180f806,
+0x1fc41080, 0x179bee7a, 0xd37ac6a9, 0xfe5830a4, 0x98de8b7f, 0x77e83f4e, 0x79929269, 0x24fa9f7b,
+0xe113c85b, 0xacc40083, 0xd7503525, 0xf7ea615f, 0x62143154, 0x0d554b63, 0x5d681121, 0xc866c359,
+0x3d63cf73, 0xcee234c0, 0xd4d87e87, 0x5c672b21, 0x071f6181, 0x39f7627f, 0x361e3084, 0xe4eb573b,
+0x602f64a4, 0xd63acd9c, 0x1bbc4635, 0x9e81032d, 0x2701f50c, 0x99847ab4, 0xa0e3df79, 0xba6cf38c,
+0x10843094, 0x2537a95e, 0xf46f6ffe, 0xa1ff3b1f, 0x208cfb6a, 0x8f458c74, 0xd9e0a227, 0x4ec73a34,
+0xfc884f69, 0x3e4de8df, 0xef0e0088, 0x3559648d, 0x8a45388c, 0x1d804366, 0x721d9bfd, 0xa58684bb,
+0xe8256333, 0x844e8212, 0x128d8098, 0xfed33fb4, 0xce280ae1, 0x27e19ba5, 0xd5a6c252, 0xe49754bd,
+0xc5d655dd, 0xeb667064, 0x77840b4d, 0xa1b6a801, 0x84db26a9, 0xe0b56714, 0x21f043b7, 0xe5d05860,
+0x54f03084, 0x066ff472, 0xa31aa153, 0xdadc4755, 0xb5625dbf, 0x68561be6, 0x83ca6b94, 0x2d6ed23b,
+0xeccf01db, 0xa6d3d0ba, 0xb6803d5c, 0xaf77a709, 0x33b4a34c, 0x397bc8d6, 0x5ee22b95, 0x5f0e5304,
+0x81ed6f61, 0x20e74364, 0xb45e1378, 0xde18639b, 0x881ca122, 0xb96726d1, 0x8049a7e8, 0x22b7da7b,
+0x5e552d25, 0x5272d237, 0x79d2951c, 0xc60d894c, 0x488cb402, 0x1ba4fe5b, 0xa4b09f6b, 0x1ca815cf,
+0xa20c3005, 0x8871df63, 0xb9de2fcb, 0x0cc6c9e9, 0x0beeff53, 0xe3214517, 0xb4542835, 0x9f63293c,
+0xee41e729, 0x6e1d2d7c, 0x50045286, 0x1e6685f3, 0xf33401c6, 0x30a22c95, 0x31a70850, 0x60930f13,
+0x73f98417, 0xa1269859, 0xec645c44, 0x52c877a9, 0xcdff33a6, 0xa02b1741, 0x7cbad9a2, 0x2180036f,
+0x50d99c08, 0xcb3f4861, 0xc26bd765, 0x64a3f6ab, 0x80342676, 0x25a75e7b, 0xe4e6d1fc, 0x20c710e6,
+0xcdf0b680, 0x17844d3b, 0x31eef84d, 0x7e0824e4, 0x2ccb49eb, 0x846a3bae, 0x8ff77888, 0xee5d60f6,
+0x7af75673, 0x2fdd5cdb, 0xa11631c1, 0x30f66f43, 0xb3faec54, 0x157fd7fa, 0xef8579cc, 0xd152de58,
+0xdb2ffd5e, 0x8f32ce19, 0x306af97a, 0x02f03ef8, 0x99319ad5, 0xc242fa0f, 0xa7e3ebb0, 0xc68e4906,
+0xb8da230c, 0x80823028, 0xdcdef3c8, 0xd35fb171, 0x088a1bc8, 0xbec0c560, 0x61a3c9e8, 0xbca8f54d,
+0xc72feffa, 0x22822e99, 0x82c570b4, 0xd8d94e89, 0x8b1c34bc, 0x301e16e6, 0x273be979, 0xb0ffeaa6,
+0x61d9b8c6, 0x00b24869, 0xb7ffce3f, 0x08dc283b, 0x43daf65a, 0xf7e19798, 0x7619b72f, 0x8f1c9ba4,
+0xdc8637a0, 0x16a7d3b1, 0x9fc393b7, 0xa7136eeb, 0xc6bcc63e, 0x1a513742, 0xef6828bc, 0x520365d6,
+0x2d6a77ab, 0x3527ed4b, 0x821fd216, 0x095c6e2e, 0xdb92f2fb, 0x5eea29cb, 0x145892f5, 0x91584f7f,
+0x5483697b, 0x2667a8cc, 0x85196048, 0x8c4bacea, 0x833860d4, 0x0d23e0f9, 0x6c387e8a, 0x0ae6d249,
+0xb284600c, 0xd835731d, 0xdcb1c647, 0xac4c56ea, 0x3ebd81b3, 0x230eabb0, 0x6438bc87, 0xf0b5b1fa,
+0x8f5ea2b3, 0xfc184642, 0x0a036b7a, 0x4fb089bd, 0x649da589, 0xa345415e, 0x5c038323, 0x3e5d3bb9,
+0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539, 0x73bfbe70, 0x83877605, 0x4523ecf1
+};
+static const u32 s3[256] = {
+0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, 0x369fe44b, 0x8c1fc644, 0xaececa90,
+0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, 0xf0ad0548, 0xe13c8d83, 0x927010d5,
+0x11107d9f, 0x07647db9, 0xb2e3e4d4, 0x3d4f285e, 0xb9afa820, 0xfade82e0, 0xa067268b, 0x8272792e,
+0x553fb2c0, 0x489ae22b, 0xd4ef9794, 0x125e3fbc, 0x21fffcee, 0x825b1bfd, 0x9255c5ed, 0x1257a240,
+0x4e1a8302, 0xbae07fff, 0x528246e7, 0x8e57140e, 0x3373f7bf, 0x8c9f8188, 0xa6fc4ee8, 0xc982b5a5,
+0xa8c01db7, 0x579fc264, 0x67094f31, 0xf2bd3f5f, 0x40fff7c1, 0x1fb78dfc, 0x8e6bd2c1, 0x437be59b,
+0x99b03dbf, 0xb5dbc64b, 0x638dc0e6, 0x55819d99, 0xa197c81c, 0x4a012d6e, 0xc5884a28, 0xccc36f71,
+0xb843c213, 0x6c0743f1, 0x8309893c, 0x0feddd5f, 0x2f7fe850, 0xd7c07f7e, 0x02507fbf, 0x5afb9a04,
+0xa747d2d0, 0x1651192e, 0xaf70bf3e, 0x58c31380, 0x5f98302e, 0x727cc3c4, 0x0a0fb402, 0x0f7fef82,
+0x8c96fdad, 0x5d2c2aae, 0x8ee99a49, 0x50da88b8, 0x8427f4a0, 0x1eac5790, 0x796fb449, 0x8252dc15,
+0xefbd7d9b, 0xa672597d, 0xada840d8, 0x45f54504, 0xfa5d7403, 0xe83ec305, 0x4f91751a, 0x925669c2,
+0x23efe941, 0xa903f12e, 0x60270df2, 0x0276e4b6, 0x94fd6574, 0x927985b2, 0x8276dbcb, 0x02778176,
+0xf8af918d, 0x4e48f79e, 0x8f616ddf, 0xe29d840e, 0x842f7d83, 0x340ce5c8, 0x96bbb682, 0x93b4b148,
+0xef303cab, 0x984faf28, 0x779faf9b, 0x92dc560d, 0x224d1e20, 0x8437aa88, 0x7d29dc96, 0x2756d3dc,
+0x8b907cee, 0xb51fd240, 0xe7c07ce3, 0xe566b4a1, 0xc3e9615e, 0x3cf8209d, 0x6094d1e3, 0xcd9ca341,
+0x5c76460e, 0x00ea983b, 0xd4d67881, 0xfd47572c, 0xf76cedd9, 0xbda8229c, 0x127dadaa, 0x438a074e,
+0x1f97c090, 0x081bdb8a, 0x93a07ebe, 0xb938ca15, 0x97b03cff, 0x3dc2c0f8, 0x8d1ab2ec, 0x64380e51,
+0x68cc7bfb, 0xd90f2788, 0x12490181, 0x5de5ffd4, 0xdd7ef86a, 0x76a2e214, 0xb9a40368, 0x925d958f,
+0x4b39fffa, 0xba39aee9, 0xa4ffd30b, 0xfaf7933b, 0x6d498623, 0x193cbcfa, 0x27627545, 0x825cf47a,
+0x61bd8ba0, 0xd11e42d1, 0xcead04f4, 0x127ea392, 0x10428db7, 0x8272a972, 0x9270c4a8, 0x127de50b,
+0x285ba1c8, 0x3c62f44f, 0x35c0eaa5, 0xe805d231, 0x428929fb, 0xb4fcdf82, 0x4fb66a53, 0x0e7dc15b,
+0x1f081fab, 0x108618ae, 0xfcfd086d, 0xf9ff2889, 0x694bcc11, 0x236a5cae, 0x12deca4d, 0x2c3f8cc5,
+0xd2d02dfe, 0xf8ef5896, 0xe4cf52da, 0x95155b67, 0x494a488c, 0xb9b6a80c, 0x5c8f82bc, 0x89d36b45,
+0x3a609437, 0xec00c9a9, 0x44715253, 0x0a874b49, 0xd773bc40, 0x7c34671c, 0x02717ef6, 0x4feb5536,
+0xa2d02fff, 0xd2bf60c4, 0xd43f03c0, 0x50b4ef6d, 0x07478cd1, 0x006e1888, 0xa2e53f55, 0xb9e6d4bc,
+0xa2048016, 0x97573833, 0xd7207d67, 0xde0f8f3d, 0x72f87b33, 0xabcc4f33, 0x7688c55d, 0x7b00a6b0,
+0x947b0001, 0x570075d2, 0xf9bb88f8, 0x8942019e, 0x4264a5ff, 0x856302e0, 0x72dbd92b, 0xee971b69,
+0x6ea22fde, 0x5f08ae2b, 0xaf7a616d, 0xe5c98767, 0xcf1febd2, 0x61efc8c2, 0xf1ac2571, 0xcc8239c2,
+0x67214cb8, 0xb1e583d1, 0xb7dc3e62, 0x7f10bdce, 0xf90a5c38, 0x0ff0443d, 0x606e6dc6, 0x60543a49,
+0x5727c148, 0x2be98a1d, 0x8ab41738, 0x20e1be24, 0xaf96da0f, 0x68458425, 0x99833be5, 0x600d457d,
+0x282f9350, 0x8334b362, 0xd91d1120, 0x2b6d8da0, 0x642b1e31, 0x9c305a00, 0x52bce688, 0x1b03588a,
+0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636, 0xa133c501, 0xe9d3531c, 0xee353783
+};
+static const u32 s4[256] = {
+0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, 0x64ad8c57, 0x85510443, 0xfa020ed1,
+0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, 0x6497b7b1, 0xf3641f63, 0x241e4adf,
+0x28147f5f, 0x4fa2b8cd, 0xc9430040, 0x0cc32220, 0xfdd30b30, 0xc0a5374f, 0x1d2d00d9, 0x24147b15,
+0xee4d111a, 0x0fca5167, 0x71ff904c, 0x2d195ffe, 0x1a05645f, 0x0c13fefe, 0x081b08ca, 0x05170121,
+0x80530100, 0xe83e5efe, 0xac9af4f8, 0x7fe72701, 0xd2b8ee5f, 0x06df4261, 0xbb9e9b8a, 0x7293ea25,
+0xce84ffdf, 0xf5718801, 0x3dd64b04, 0xa26f263b, 0x7ed48400, 0x547eebe6, 0x446d4ca0, 0x6cf3d6f5,
+0x2649abdf, 0xaea0c7f5, 0x36338cc1, 0x503f7e93, 0xd3772061, 0x11b638e1, 0x72500e03, 0xf80eb2bb,
+0xabe0502e, 0xec8d77de, 0x57971e81, 0xe14f6746, 0xc9335400, 0x6920318f, 0x081dbb99, 0xffc304a5,
+0x4d351805, 0x7f3d5ce3, 0xa6c866c6, 0x5d5bcca9, 0xdaec6fea, 0x9f926f91, 0x9f46222f, 0x3991467d,
+0xa5bf6d8e, 0x1143c44f, 0x43958302, 0xd0214eeb, 0x022083b8, 0x3fb6180c, 0x18f8931e, 0x281658e6,
+0x26486e3e, 0x8bd78a70, 0x7477e4c1, 0xb506e07c, 0xf32d0a25, 0x79098b02, 0xe4eabb81, 0x28123b23,
+0x69dead38, 0x1574ca16, 0xdf871b62, 0x211c40b7, 0xa51a9ef9, 0x0014377b, 0x041e8ac8, 0x09114003,
+0xbd59e4d2, 0xe3d156d5, 0x4fe876d5, 0x2f91a340, 0x557be8de, 0x00eae4a7, 0x0ce5c2ec, 0x4db4bba6,
+0xe756bdff, 0xdd3369ac, 0xec17b035, 0x06572327, 0x99afc8b0, 0x56c8c391, 0x6b65811c, 0x5e146119,
+0x6e85cb75, 0xbe07c002, 0xc2325577, 0x893ff4ec, 0x5bbfc92d, 0xd0ec3b25, 0xb7801ab7, 0x8d6d3b24,
+0x20c763ef, 0xc366a5fc, 0x9c382880, 0x0ace3205, 0xaac9548a, 0xeca1d7c7, 0x041afa32, 0x1d16625a,
+0x6701902c, 0x9b757a54, 0x31d477f7, 0x9126b031, 0x36cc6fdb, 0xc70b8b46, 0xd9e66a48, 0x56e55a79,
+0x026a4ceb, 0x52437eff, 0x2f8f76b4, 0x0df980a5, 0x8674cde3, 0xedda04eb, 0x17a9be04, 0x2c18f4df,
+0xb7747f9d, 0xab2af7b4, 0xefc34d20, 0x2e096b7c, 0x1741a254, 0xe5b6a035, 0x213d42f6, 0x2c1c7c26,
+0x61c2f50f, 0x6552daf9, 0xd2c231f8, 0x25130f69, 0xd8167fa2, 0x0418f2c8, 0x001a96a6, 0x0d1526ab,
+0x63315c21, 0x5e0a72ec, 0x49bafefd, 0x187908d9, 0x8d0dbd86, 0x311170a7, 0x3e9b640c, 0xcc3e10d7,
+0xd5cad3b6, 0x0caec388, 0xf73001e1, 0x6c728aff, 0x71eae2a1, 0x1f9af36e, 0xcfcbd12f, 0xc1de8417,
+0xac07be6b, 0xcb44a1d8, 0x8b9b0f56, 0x013988c3, 0xb1c52fca, 0xb4be31cd, 0xd8782806, 0x12a3a4e2,
+0x6f7de532, 0x58fd7eb6, 0xd01ee900, 0x24adffc2, 0xf4990fc5, 0x9711aac5, 0x001d7b95, 0x82e5e7d2,
+0x109873f6, 0x00613096, 0xc32d9521, 0xada121ff, 0x29908415, 0x7fbb977f, 0xaf9eb3db, 0x29c9ed2a,
+0x5ce2a465, 0xa730f32c, 0xd0aa3fe8, 0x8a5cc091, 0xd49e2ce7, 0x0ce454a9, 0xd60acd86, 0x015f1919,
+0x77079103, 0xdea03af6, 0x78a8565e, 0xdee356df, 0x21f05cbe, 0x8b75e387, 0xb3c50651, 0xb8a5c3ef,
+0xd8eeb6d2, 0xe523be77, 0xc2154529, 0x2f69efdf, 0xafe67afb, 0xf470c4b2, 0xf3e0eb5b, 0xd6cc9876,
+0x39e4460c, 0x1fda8538, 0x1987832f, 0xca007367, 0xa99144f8, 0x296b299e, 0x492fc295, 0x9266beab,
+0xb5676e69, 0x9bd3ddda, 0xdf7e052f, 0xdb25701c, 0x1b5e51ee, 0xf65324e6, 0x6afce36c, 0x0316cc04,
+0x8644213e, 0xb7dc59d0, 0x7965291f, 0xccd6fd43, 0x41823979, 0x932bcdf6, 0xb657c34d, 0x4edfd282,
+0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0, 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2
+};
+static const u32 s5[256] = {
+0x7ec90c04, 0x2c6e74b9, 0x9b0e66df, 0xa6337911, 0xb86a7fff, 0x1dd358f5, 0x44dd9d44, 0x1731167f,
+0x08fbf1fa, 0xe7f511cc, 0xd2051b00, 0x735aba00, 0x2ab722d8, 0x386381cb, 0xacf6243a, 0x69befd7a,
+0xe6a2e77f, 0xf0c720cd, 0xc4494816, 0xccf5c180, 0x38851640, 0x15b0a848, 0xe68b18cb, 0x4caadeff,
+0x5f480a01, 0x0412b2aa, 0x259814fc, 0x41d0efe2, 0x4e40b48d, 0x248eb6fb, 0x8dba1cfe, 0x41a99b02,
+0x1a550a04, 0xba8f65cb, 0x7251f4e7, 0x95a51725, 0xc106ecd7, 0x97a5980a, 0xc539b9aa, 0x4d79fe6a,
+0xf2f3f763, 0x68af8040, 0xed0c9e56, 0x11b4958b, 0xe1eb5a88, 0x8709e6b0, 0xd7e07156, 0x4e29fea7,
+0x6366e52d, 0x02d1c000, 0xc4ac8e05, 0x9377f571, 0x0c05372a, 0x578535f2, 0x2261be02, 0xd642a0c9,
+0xdf13a280, 0x74b55bd2, 0x682199c0, 0xd421e5ec, 0x53fb3ce8, 0xc8adedb3, 0x28a87fc9, 0x3d959981,
+0x5c1ff900, 0xfe38d399, 0x0c4eff0b, 0x062407ea, 0xaa2f4fb1, 0x4fb96976, 0x90c79505, 0xb0a8a774,
+0xef55a1ff, 0xe59ca2c2, 0xa6b62d27, 0xe66a4263, 0xdf65001f, 0x0ec50966, 0xdfdd55bc, 0x29de0655,
+0x911e739a, 0x17af8975, 0x32c7911c, 0x89f89468, 0x0d01e980, 0x524755f4, 0x03b63cc9, 0x0cc844b2,
+0xbcf3f0aa, 0x87ac36e9, 0xe53a7426, 0x01b3d82b, 0x1a9e7449, 0x64ee2d7e, 0xcddbb1da, 0x01c94910,
+0xb868bf80, 0x0d26f3fd, 0x9342ede7, 0x04a5c284, 0x636737b6, 0x50f5b616, 0xf24766e3, 0x8eca36c1,
+0x136e05db, 0xfef18391, 0xfb887a37, 0xd6e7f7d4, 0xc7fb7dc9, 0x3063fcdf, 0xb6f589de, 0xec2941da,
+0x26e46695, 0xb7566419, 0xf654efc5, 0xd08d58b7, 0x48925401, 0xc1bacb7f, 0xe5ff550f, 0xb6083049,
+0x5bb5d0e8, 0x87d72e5a, 0xab6a6ee1, 0x223a66ce, 0xc62bf3cd, 0x9e0885f9, 0x68cb3e47, 0x086c010f,
+0xa21de820, 0xd18b69de, 0xf3f65777, 0xfa02c3f6, 0x407edac3, 0xcbb3d550, 0x1793084d, 0xb0d70eba,
+0x0ab378d5, 0xd951fb0c, 0xded7da56, 0x4124bbe4, 0x94ca0b56, 0x0f5755d1, 0xe0e1e56e, 0x6184b5be,
+0x580a249f, 0x94f74bc0, 0xe327888e, 0x9f7b5561, 0xc3dc0280, 0x05687715, 0x646c6bd7, 0x44904db3,
+0x66b4f0a3, 0xc0f1648a, 0x697ed5af, 0x49e92ff6, 0x309e374f, 0x2cb6356a, 0x85808573, 0x4991f840,
+0x76f0ae02, 0x083be84d, 0x28421c9a, 0x44489406, 0x736e4cb8, 0xc1092910, 0x8bc95fc6, 0x7d869cf4,
+0x134f616f, 0x2e77118d, 0xb31b2be1, 0xaa90b472, 0x3ca5d717, 0x7d161bba, 0x9cad9010, 0xaf462ba2,
+0x9fe459d2, 0x45d34559, 0xd9f2da13, 0xdbc65487, 0xf3e4f94e, 0x176d486f, 0x097c13ea, 0x631da5c7,
+0x445f7382, 0x175683f4, 0xcdc66a97, 0x70be0288, 0xb3cdcf72, 0x6e5dd2f3, 0x20936079, 0x459b80a5,
+0xbe60e2db, 0xa9c23101, 0xeba5315c, 0x224e42f2, 0x1c5c1572, 0xf6721b2c, 0x1ad2fff3, 0x8c25404e,
+0x324ed72f, 0x4067b7fd, 0x0523138e, 0x5ca3bc78, 0xdc0fd66e, 0x75922283, 0x784d6b17, 0x58ebb16e,
+0x44094f85, 0x3f481d87, 0xfcfeae7b, 0x77b5ff76, 0x8c2302bf, 0xaaf47556, 0x5f46b02a, 0x2b092801,
+0x3d38f5f7, 0x0ca81f36, 0x52af4a8a, 0x66d5e7c0, 0xdf3b0874, 0x95055110, 0x1b5ad7a8, 0xf61ed5ad,
+0x6cf6e479, 0x20758184, 0xd0cefa65, 0x88f7be58, 0x4a046826, 0x0ff6f8f3, 0xa09c7f70, 0x5346aba0,
+0x5ce96c28, 0xe176eda3, 0x6bac307f, 0x376829d2, 0x85360fa9, 0x17e3fe2a, 0x24b79767, 0xf5a96b20,
+0xd6cd2595, 0x68ff1ebf, 0x7555442c, 0xf19f06be, 0xf9e0659a, 0xeeb9491d, 0x34010718, 0xbb30cab8,
+0xe822fe15, 0x88570983, 0x750e6249, 0xda627e55, 0x5e76ffa8, 0xb1534546, 0x6d47de08, 0xefe9e7d4
+};
+static const u32 s6[256] = {
+0xf6fa8f9d, 0x2cac6ce1, 0x4ca34867, 0xe2337f7c, 0x95db08e7, 0x016843b4, 0xeced5cbc, 0x325553ac,
+0xbf9f0960, 0xdfa1e2ed, 0x83f0579d, 0x63ed86b9, 0x1ab6a6b8, 0xde5ebe39, 0xf38ff732, 0x8989b138,
+0x33f14961, 0xc01937bd, 0xf506c6da, 0xe4625e7e, 0xa308ea99, 0x4e23e33c, 0x79cbd7cc, 0x48a14367,
+0xa3149619, 0xfec94bd5, 0xa114174a, 0xeaa01866, 0xa084db2d, 0x09a8486f, 0xa888614a, 0x2900af98,
+0x01665991, 0xe1992863, 0xc8f30c60, 0x2e78ef3c, 0xd0d51932, 0xcf0fec14, 0xf7ca07d2, 0xd0a82072,
+0xfd41197e, 0x9305a6b0, 0xe86be3da, 0x74bed3cd, 0x372da53c, 0x4c7f4448, 0xdab5d440, 0x6dba0ec3,
+0x083919a7, 0x9fbaeed9, 0x49dbcfb0, 0x4e670c53, 0x5c3d9c01, 0x64bdb941, 0x2c0e636a, 0xba7dd9cd,
+0xea6f7388, 0xe70bc762, 0x35f29adb, 0x5c4cdd8d, 0xf0d48d8c, 0xb88153e2, 0x08a19866, 0x1ae2eac8,
+0x284caf89, 0xaa928223, 0x9334be53, 0x3b3a21bf, 0x16434be3, 0x9aea3906, 0xefe8c36e, 0xf890cdd9,
+0x80226dae, 0xc340a4a3, 0xdf7e9c09, 0xa694a807, 0x5b7c5ecc, 0x221db3a6, 0x9a69a02f, 0x68818a54,
+0xceb2296f, 0x53c0843a, 0xfe893655, 0x25bfe68a, 0xb4628abc, 0xcf222ebf, 0x25ac6f48, 0xa9a99387,
+0x53bddb65, 0xe76ffbe7, 0xe967fd78, 0x0ba93563, 0x8e342bc1, 0xe8a11be9, 0x4980740d, 0xc8087dfc,
+0x8de4bf99, 0xa11101a0, 0x7fd37975, 0xda5a26c0, 0xe81f994f, 0x9528cd89, 0xfd339fed, 0xb87834bf,
+0x5f04456d, 0x22258698, 0xc9c4c83b, 0x2dc156be, 0x4f628daa, 0x57f55ec5, 0xe2220abe, 0xd2916ebf,
+0x4ec75b95, 0x24f2c3c0, 0x42d15d99, 0xcd0d7fa0, 0x7b6e27ff, 0xa8dc8af0, 0x7345c106, 0xf41e232f,
+0x35162386, 0xe6ea8926, 0x3333b094, 0x157ec6f2, 0x372b74af, 0x692573e4, 0xe9a9d848, 0xf3160289,
+0x3a62ef1d, 0xa787e238, 0xf3a5f676, 0x74364853, 0x20951063, 0x4576698d, 0xb6fad407, 0x592af950,
+0x36f73523, 0x4cfb6e87, 0x7da4cec0, 0x6c152daa, 0xcb0396a8, 0xc50dfe5d, 0xfcd707ab, 0x0921c42f,
+0x89dff0bb, 0x5fe2be78, 0x448f4f33, 0x754613c9, 0x2b05d08d, 0x48b9d585, 0xdc049441, 0xc8098f9b,
+0x7dede786, 0xc39a3373, 0x42410005, 0x6a091751, 0x0ef3c8a6, 0x890072d6, 0x28207682, 0xa9a9f7be,
+0xbf32679d, 0xd45b5b75, 0xb353fd00, 0xcbb0e358, 0x830f220a, 0x1f8fb214, 0xd372cf08, 0xcc3c4a13,
+0x8cf63166, 0x061c87be, 0x88c98f88, 0x6062e397, 0x47cf8e7a, 0xb6c85283, 0x3cc2acfb, 0x3fc06976,
+0x4e8f0252, 0x64d8314d, 0xda3870e3, 0x1e665459, 0xc10908f0, 0x513021a5, 0x6c5b68b7, 0x822f8aa0,
+0x3007cd3e, 0x74719eef, 0xdc872681, 0x073340d4, 0x7e432fd9, 0x0c5ec241, 0x8809286c, 0xf592d891,
+0x08a930f6, 0x957ef305, 0xb7fbffbd, 0xc266e96f, 0x6fe4ac98, 0xb173ecc0, 0xbc60b42a, 0x953498da,
+0xfba1ae12, 0x2d4bd736, 0x0f25faab, 0xa4f3fceb, 0xe2969123, 0x257f0c3d, 0x9348af49, 0x361400bc,
+0xe8816f4a, 0x3814f200, 0xa3f94043, 0x9c7a54c2, 0xbc704f57, 0xda41e7f9, 0xc25ad33a, 0x54f4a084,
+0xb17f5505, 0x59357cbe, 0xedbd15c8, 0x7f97c5ab, 0xba5ac7b5, 0xb6f6deaf, 0x3a479c3a, 0x5302da25,
+0x653d7e6a, 0x54268d49, 0x51a477ea, 0x5017d55b, 0xd7d25d88, 0x44136c76, 0x0404a8c8, 0xb8e5a121,
+0xb81a928a, 0x60ed5869, 0x97c55b96, 0xeaec991b, 0x29935913, 0x01fdb7f1, 0x088e8dfa, 0x9ab6f6f5,
+0x3b4cbf9f, 0x4a5de3ab, 0xe6051d35, 0xa0e1d855, 0xd36b4cf1, 0xf544edeb, 0xb0e93524, 0xbebb8fbd,
+0xa2d762cf, 0x49c92f54, 0x38b5f331, 0x7128a454, 0x48392905, 0xa65b1db8, 0x851c97bd, 0xd675cf2f
+};
+static const u32 s7[256] = {
+0x85e04019, 0x332bf567, 0x662dbfff, 0xcfc65693, 0x2a8d7f6f, 0xab9bc912, 0xde6008a1, 0x2028da1f,
+0x0227bce7, 0x4d642916, 0x18fac300, 0x50f18b82, 0x2cb2cb11, 0xb232e75c, 0x4b3695f2, 0xb28707de,
+0xa05fbcf6, 0xcd4181e9, 0xe150210c, 0xe24ef1bd, 0xb168c381, 0xfde4e789, 0x5c79b0d8, 0x1e8bfd43,
+0x4d495001, 0x38be4341, 0x913cee1d, 0x92a79c3f, 0x089766be, 0xbaeeadf4, 0x1286becf, 0xb6eacb19,
+0x2660c200, 0x7565bde4, 0x64241f7a, 0x8248dca9, 0xc3b3ad66, 0x28136086, 0x0bd8dfa8, 0x356d1cf2,
+0x107789be, 0xb3b2e9ce, 0x0502aa8f, 0x0bc0351e, 0x166bf52a, 0xeb12ff82, 0xe3486911, 0xd34d7516,
+0x4e7b3aff, 0x5f43671b, 0x9cf6e037, 0x4981ac83, 0x334266ce, 0x8c9341b7, 0xd0d854c0, 0xcb3a6c88,
+0x47bc2829, 0x4725ba37, 0xa66ad22b, 0x7ad61f1e, 0x0c5cbafa, 0x4437f107, 0xb6e79962, 0x42d2d816,
+0x0a961288, 0xe1a5c06e, 0x13749e67, 0x72fc081a, 0xb1d139f7, 0xf9583745, 0xcf19df58, 0xbec3f756,
+0xc06eba30, 0x07211b24, 0x45c28829, 0xc95e317f, 0xbc8ec511, 0x38bc46e9, 0xc6e6fa14, 0xbae8584a,
+0xad4ebc46, 0x468f508b, 0x7829435f, 0xf124183b, 0x821dba9f, 0xaff60ff4, 0xea2c4e6d, 0x16e39264,
+0x92544a8b, 0x009b4fc3, 0xaba68ced, 0x9ac96f78, 0x06a5b79a, 0xb2856e6e, 0x1aec3ca9, 0xbe838688,
+0x0e0804e9, 0x55f1be56, 0xe7e5363b, 0xb3a1f25d, 0xf7debb85, 0x61fe033c, 0x16746233, 0x3c034c28,
+0xda6d0c74, 0x79aac56c, 0x3ce4e1ad, 0x51f0c802, 0x98f8f35a, 0x1626a49f, 0xeed82b29, 0x1d382fe3,
+0x0c4fb99a, 0xbb325778, 0x3ec6d97b, 0x6e77a6a9, 0xcb658b5c, 0xd45230c7, 0x2bd1408b, 0x60c03eb7,
+0xb9068d78, 0xa33754f4, 0xf430c87d, 0xc8a71302, 0xb96d8c32, 0xebd4e7be, 0xbe8b9d2d, 0x7979fb06,
+0xe7225308, 0x8b75cf77, 0x11ef8da4, 0xe083c858, 0x8d6b786f, 0x5a6317a6, 0xfa5cf7a0, 0x5dda0033,
+0xf28ebfb0, 0xf5b9c310, 0xa0eac280, 0x08b9767a, 0xa3d9d2b0, 0x79d34217, 0x021a718d, 0x9ac6336a,
+0x2711fd60, 0x438050e3, 0x069908a8, 0x3d7fedc4, 0x826d2bef, 0x4eeb8476, 0x488dcf25, 0x36c9d566,
+0x28e74e41, 0xc2610aca, 0x3d49a9cf, 0xbae3b9df, 0xb65f8de6, 0x92aeaf64, 0x3ac7d5e6, 0x9ea80509,
+0xf22b017d, 0xa4173f70, 0xdd1e16c3, 0x15e0d7f9, 0x50b1b887, 0x2b9f4fd5, 0x625aba82, 0x6a017962,
+0x2ec01b9c, 0x15488aa9, 0xd716e740, 0x40055a2c, 0x93d29a22, 0xe32dbf9a, 0x058745b9, 0x3453dc1e,
+0xd699296e, 0x496cff6f, 0x1c9f4986, 0xdfe2ed07, 0xb87242d1, 0x19de7eae, 0x053e561a, 0x15ad6f8c,
+0x66626c1c, 0x7154c24c, 0xea082b2a, 0x93eb2939, 0x17dcb0f0, 0x58d4f2ae, 0x9ea294fb, 0x52cf564c,
+0x9883fe66, 0x2ec40581, 0x763953c3, 0x01d6692e, 0xd3a0c108, 0xa1e7160e, 0xe4f2dfa6, 0x693ed285,
+0x74904698, 0x4c2b0edd, 0x4f757656, 0x5d393378, 0xa132234f, 0x3d321c5d, 0xc3f5e194, 0x4b269301,
+0xc79f022f, 0x3c997e7e, 0x5e4f9504, 0x3ffafbbd, 0x76f7ad0e, 0x296693f4, 0x3d1fce6f, 0xc61e45be,
+0xd3b5ab34, 0xf72bf9b7, 0x1b0434c0, 0x4e72b567, 0x5592a33d, 0xb5229301, 0xcfd2a87f, 0x60aeb767,
+0x1814386b, 0x30bcc33d, 0x38a0c07d, 0xfd1606f2, 0xc363519b, 0x589dd390, 0x5479f8e6, 0x1cb8d647,
+0x97fd61a9, 0xea7759f4, 0x2d57539d, 0x569a58cf, 0xe84e63ad, 0x462e1b78, 0x6580f87e, 0xf3817914,
+0x91da55f4, 0x40a230f3, 0xd1988f35, 0xb6e318d2, 0x3ffa50bc, 0x3d40f021, 0xc3c0bdae, 0x4958c24c,
+0x518f36b2, 0x84b1d370, 0x0fedce83, 0x878ddada, 0xf2a279c7, 0x94e01be8, 0x90716f4b, 0x954b8aa3
+};
+static const u32 s8[256] = {
+0xe216300d, 0xbbddfffc, 0xa7ebdabd, 0x35648095, 0x7789f8b7, 0xe6c1121b, 0x0e241600, 0x052ce8b5,
+0x11a9cfb0, 0xe5952f11, 0xece7990a, 0x9386d174, 0x2a42931c, 0x76e38111, 0xb12def3a, 0x37ddddfc,
+0xde9adeb1, 0x0a0cc32c, 0xbe197029, 0x84a00940, 0xbb243a0f, 0xb4d137cf, 0xb44e79f0, 0x049eedfd,
+0x0b15a15d, 0x480d3168, 0x8bbbde5a, 0x669ded42, 0xc7ece831, 0x3f8f95e7, 0x72df191b, 0x7580330d,
+0x94074251, 0x5c7dcdfa, 0xabbe6d63, 0xaa402164, 0xb301d40a, 0x02e7d1ca, 0x53571dae, 0x7a3182a2,
+0x12a8ddec, 0xfdaa335d, 0x176f43e8, 0x71fb46d4, 0x38129022, 0xce949ad4, 0xb84769ad, 0x965bd862,
+0x82f3d055, 0x66fb9767, 0x15b80b4e, 0x1d5b47a0, 0x4cfde06f, 0xc28ec4b8, 0x57e8726e, 0x647a78fc,
+0x99865d44, 0x608bd593, 0x6c200e03, 0x39dc5ff6, 0x5d0b00a3, 0xae63aff2, 0x7e8bd632, 0x70108c0c,
+0xbbd35049, 0x2998df04, 0x980cf42a, 0x9b6df491, 0x9e7edd53, 0x06918548, 0x58cb7e07, 0x3b74ef2e,
+0x522fffb1, 0xd24708cc, 0x1c7e27cd, 0xa4eb215b, 0x3cf1d2e2, 0x19b47a38, 0x424f7618, 0x35856039,
+0x9d17dee7, 0x27eb35e6, 0xc9aff67b, 0x36baf5b8, 0x09c467cd, 0xc18910b1, 0xe11dbf7b, 0x06cd1af8,
+0x7170c608, 0x2d5e3354, 0xd4de495a, 0x64c6d006, 0xbcc0c62c, 0x3dd00db3, 0x708f8f34, 0x77d51b42,
+0x264f620f, 0x24b8d2bf, 0x15c1b79e, 0x46a52564, 0xf8d7e54e, 0x3e378160, 0x7895cda5, 0x859c15a5,
+0xe6459788, 0xc37bc75f, 0xdb07ba0c, 0x0676a3ab, 0x7f229b1e, 0x31842e7b, 0x24259fd7, 0xf8bef472,
+0x835ffcb8, 0x6df4c1f2, 0x96f5b195, 0xfd0af0fc, 0xb0fe134c, 0xe2506d3d, 0x4f9b12ea, 0xf215f225,
+0xa223736f, 0x9fb4c428, 0x25d04979, 0x34c713f8, 0xc4618187, 0xea7a6e98, 0x7cd16efc, 0x1436876c,
+0xf1544107, 0xbedeee14, 0x56e9af27, 0xa04aa441, 0x3cf7c899, 0x92ecbae6, 0xdd67016d, 0x151682eb,
+0xa842eedf, 0xfdba60b4, 0xf1907b75, 0x20e3030f, 0x24d8c29e, 0xe139673b, 0xefa63fb8, 0x71873054,
+0xb6f2cf3b, 0x9f326442, 0xcb15a4cc, 0xb01a4504, 0xf1e47d8d, 0x844a1be5, 0xbae7dfdc, 0x42cbda70,
+0xcd7dae0a, 0x57e85b7a, 0xd53f5af6, 0x20cf4d8c, 0xcea4d428, 0x79d130a4, 0x3486ebfb, 0x33d3cddc,
+0x77853b53, 0x37effcb5, 0xc5068778, 0xe580b3e6, 0x4e68b8f4, 0xc5c8b37e, 0x0d809ea2, 0x398feb7c,
+0x132a4f94, 0x43b7950e, 0x2fee7d1c, 0x223613bd, 0xdd06caa2, 0x37df932b, 0xc4248289, 0xacf3ebc3,
+0x5715f6b7, 0xef3478dd, 0xf267616f, 0xc148cbe4, 0x9052815e, 0x5e410fab, 0xb48a2465, 0x2eda7fa4,
+0xe87b40e4, 0xe98ea084, 0x5889e9e1, 0xefd390fc, 0xdd07d35b, 0xdb485694, 0x38d7e5b2, 0x57720101,
+0x730edebc, 0x5b643113, 0x94917e4f, 0x503c2fba, 0x646f1282, 0x7523d24a, 0xe0779695, 0xf9c17a8f,
+0x7a5b2121, 0xd187b896, 0x29263a4d, 0xba510cdf, 0x81f47c9f, 0xad1163ed, 0xea7b5965, 0x1a00726e,
+0x11403092, 0x00da6d77, 0x4a0cdd61, 0xad1f4603, 0x605bdfb0, 0x9eedc364, 0x22ebe6a8, 0xcee7d28a,
+0xa0e736a0, 0x5564a6b9, 0x10853209, 0xc7eb8f37, 0x2de705ca, 0x8951570f, 0xdf09822b, 0xbd691a6c,
+0xaa12e4f2, 0x87451c0f, 0xe0f6a27a, 0x3ada4819, 0x4cf1764f, 0x0d771c2b, 0x67cdb156, 0x350d8384,
+0x5938fa0f, 0x42399ef3, 0x36997b07, 0x0e84093d, 0x4aa93e61, 0x8360d87b, 0x1fa98b0c, 0x1149382c,
+0xe97625a5, 0x0614d1b7, 0x0e25244b, 0x0c768347, 0x589e8d82, 0x0d2059d1, 0xa466bb1e, 0xf8da0a82,
+0x04f19130, 0xba6e4ec0, 0x99265164, 0x1ee7230d, 0x50b2ad80, 0xeaee6801, 0x8db2a283, 0xea8bf59e
+};
+
+
+#if defined(__GNUC__) && defined(__i386__)
+static inline u32
+rol(int n, u32 x)
+{
+ __asm__("roll %%cl,%0"
+ :"=r" (x)
+ :"0" (x),"c" (n));
+ return x;
+}
+#else
+#define rol(n,x) ( ((x) << (n)) | ((x) >> (32-(n))) )
+#endif
+
+#define F1(D,m,r) ( (I = ((m) + (D))), (I=rol((r),I)), \
+ (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff]) )
+#define F2(D,m,r) ( (I = ((m) ^ (D))), (I=rol((r),I)), \
+ (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff]) )
+#define F3(D,m,r) ( (I = ((m) - (D))), (I=rol((r),I)), \
+ (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]) )
+
+static void
+do_encrypt_block( CAST5_context *c, byte *outbuf, const byte *inbuf )
+{
+ u32 l, r, t;
+ u32 I; /* used by the Fx macros */
+ u32 *Km;
+ byte *Kr;
+
+ Km = c->Km;
+ Kr = c->Kr;
+
+ /* (L0,R0) <-- (m1...m64). (Split the plaintext into left and
+ * right 32-bit halves L0 = m1...m32 and R0 = m33...m64.)
+ */
+ l = inbuf[0] << 24 | inbuf[1] << 16 | inbuf[2] << 8 | inbuf[3];
+ r = inbuf[4] << 24 | inbuf[5] << 16 | inbuf[6] << 8 | inbuf[7];
+
+ /* (16 rounds) for i from 1 to 16, compute Li and Ri as follows:
+ * Li = Ri-1;
+ * Ri = Li-1 ^ f(Ri-1,Kmi,Kri), where f is defined in Section 2.2
+ * Rounds 1, 4, 7, 10, 13, and 16 use f function Type 1.
+ * Rounds 2, 5, 8, 11, and 14 use f function Type 2.
+ * Rounds 3, 6, 9, 12, and 15 use f function Type 3.
+ */
+
+ t = l; l = r; r = t ^ F1(r, Km[ 0], Kr[ 0]);
+ t = l; l = r; r = t ^ F2(r, Km[ 1], Kr[ 1]);
+ t = l; l = r; r = t ^ F3(r, Km[ 2], Kr[ 2]);
+ t = l; l = r; r = t ^ F1(r, Km[ 3], Kr[ 3]);
+ t = l; l = r; r = t ^ F2(r, Km[ 4], Kr[ 4]);
+ t = l; l = r; r = t ^ F3(r, Km[ 5], Kr[ 5]);
+ t = l; l = r; r = t ^ F1(r, Km[ 6], Kr[ 6]);
+ t = l; l = r; r = t ^ F2(r, Km[ 7], Kr[ 7]);
+ t = l; l = r; r = t ^ F3(r, Km[ 8], Kr[ 8]);
+ t = l; l = r; r = t ^ F1(r, Km[ 9], Kr[ 9]);
+ t = l; l = r; r = t ^ F2(r, Km[10], Kr[10]);
+ t = l; l = r; r = t ^ F3(r, Km[11], Kr[11]);
+ t = l; l = r; r = t ^ F1(r, Km[12], Kr[12]);
+ t = l; l = r; r = t ^ F2(r, Km[13], Kr[13]);
+ t = l; l = r; r = t ^ F3(r, Km[14], Kr[14]);
+ t = l; l = r; r = t ^ F1(r, Km[15], Kr[15]);
+
+ /* c1...c64 <-- (R16,L16). (Exchange final blocks L16, R16 and
+ * concatenate to form the ciphertext.) */
+ outbuf[0] = (r >> 24) & 0xff;
+ outbuf[1] = (r >> 16) & 0xff;
+ outbuf[2] = (r >> 8) & 0xff;
+ outbuf[3] = r & 0xff;
+ outbuf[4] = (l >> 24) & 0xff;
+ outbuf[5] = (l >> 16) & 0xff;
+ outbuf[6] = (l >> 8) & 0xff;
+ outbuf[7] = l & 0xff;
+}
+
+static void
+encrypt_block (void *context , byte *outbuf, const byte *inbuf)
+{
+ CAST5_context *c = (CAST5_context *) context;
+ do_encrypt_block (c, outbuf, inbuf);
+ _gcry_burn_stack (20+4*sizeof(void*));
+}
+
+
+static void
+do_decrypt_block (CAST5_context *c, byte *outbuf, const byte *inbuf )
+{
+ u32 l, r, t;
+ u32 I;
+ u32 *Km;
+ byte *Kr;
+
+ Km = c->Km;
+ Kr = c->Kr;
+
+ l = inbuf[0] << 24 | inbuf[1] << 16 | inbuf[2] << 8 | inbuf[3];
+ r = inbuf[4] << 24 | inbuf[5] << 16 | inbuf[6] << 8 | inbuf[7];
+
+ t = l; l = r; r = t ^ F1(r, Km[15], Kr[15]);
+ t = l; l = r; r = t ^ F3(r, Km[14], Kr[14]);
+ t = l; l = r; r = t ^ F2(r, Km[13], Kr[13]);
+ t = l; l = r; r = t ^ F1(r, Km[12], Kr[12]);
+ t = l; l = r; r = t ^ F3(r, Km[11], Kr[11]);
+ t = l; l = r; r = t ^ F2(r, Km[10], Kr[10]);
+ t = l; l = r; r = t ^ F1(r, Km[ 9], Kr[ 9]);
+ t = l; l = r; r = t ^ F3(r, Km[ 8], Kr[ 8]);
+ t = l; l = r; r = t ^ F2(r, Km[ 7], Kr[ 7]);
+ t = l; l = r; r = t ^ F1(r, Km[ 6], Kr[ 6]);
+ t = l; l = r; r = t ^ F3(r, Km[ 5], Kr[ 5]);
+ t = l; l = r; r = t ^ F2(r, Km[ 4], Kr[ 4]);
+ t = l; l = r; r = t ^ F1(r, Km[ 3], Kr[ 3]);
+ t = l; l = r; r = t ^ F3(r, Km[ 2], Kr[ 2]);
+ t = l; l = r; r = t ^ F2(r, Km[ 1], Kr[ 1]);
+ t = l; l = r; r = t ^ F1(r, Km[ 0], Kr[ 0]);
+
+ outbuf[0] = (r >> 24) & 0xff;
+ outbuf[1] = (r >> 16) & 0xff;
+ outbuf[2] = (r >> 8) & 0xff;
+ outbuf[3] = r & 0xff;
+ outbuf[4] = (l >> 24) & 0xff;
+ outbuf[5] = (l >> 16) & 0xff;
+ outbuf[6] = (l >> 8) & 0xff;
+ outbuf[7] = l & 0xff;
+}
+
+static void
+decrypt_block (void *context, byte *outbuf, const byte *inbuf)
+{
+ CAST5_context *c = (CAST5_context *) context;
+ do_decrypt_block (c, outbuf, inbuf);
+ _gcry_burn_stack (20+4*sizeof(void*));
+}
+
+
+
+
+static void
+key_schedule( u32 *x, u32 *z, u32 *k )
+{
+
+#define xi(i) ((x[(i)/4] >> (8*(3-((i)%4)))) & 0xff)
+#define zi(i) ((z[(i)/4] >> (8*(3-((i)%4)))) & 0xff)
+
+ z[0] = x[0] ^ s5[xi(13)]^s6[xi(15)]^s7[xi(12)]^s8[xi(14)]^s7[xi( 8)];
+ z[1] = x[2] ^ s5[zi( 0)]^s6[zi( 2)]^s7[zi( 1)]^s8[zi( 3)]^s8[xi(10)];
+ z[2] = x[3] ^ s5[zi( 7)]^s6[zi( 6)]^s7[zi( 5)]^s8[zi( 4)]^s5[xi( 9)];
+ z[3] = x[1] ^ s5[zi(10)]^s6[zi( 9)]^s7[zi(11)]^s8[zi( 8)]^s6[xi(11)];
+ k[0] = s5[zi( 8)]^s6[zi( 9)]^s7[zi( 7)]^s8[zi( 6)]^s5[zi( 2)];
+ k[1] = s5[zi(10)]^s6[zi(11)]^s7[zi( 5)]^s8[zi( 4)]^s6[zi( 6)];
+ k[2] = s5[zi(12)]^s6[zi(13)]^s7[zi( 3)]^s8[zi( 2)]^s7[zi( 9)];
+ k[3] = s5[zi(14)]^s6[zi(15)]^s7[zi( 1)]^s8[zi( 0)]^s8[zi(12)];
+
+ x[0] = z[2] ^ s5[zi( 5)]^s6[zi( 7)]^s7[zi( 4)]^s8[zi( 6)]^s7[zi( 0)];
+ x[1] = z[0] ^ s5[xi( 0)]^s6[xi( 2)]^s7[xi( 1)]^s8[xi( 3)]^s8[zi( 2)];
+ x[2] = z[1] ^ s5[xi( 7)]^s6[xi( 6)]^s7[xi( 5)]^s8[xi( 4)]^s5[zi( 1)];
+ x[3] = z[3] ^ s5[xi(10)]^s6[xi( 9)]^s7[xi(11)]^s8[xi( 8)]^s6[zi( 3)];
+ k[4] = s5[xi( 3)]^s6[xi( 2)]^s7[xi(12)]^s8[xi(13)]^s5[xi( 8)];
+ k[5] = s5[xi( 1)]^s6[xi( 0)]^s7[xi(14)]^s8[xi(15)]^s6[xi(13)];
+ k[6] = s5[xi( 7)]^s6[xi( 6)]^s7[xi( 8)]^s8[xi( 9)]^s7[xi( 3)];
+ k[7] = s5[xi( 5)]^s6[xi( 4)]^s7[xi(10)]^s8[xi(11)]^s8[xi( 7)];
+
+ z[0] = x[0] ^ s5[xi(13)]^s6[xi(15)]^s7[xi(12)]^s8[xi(14)]^s7[xi( 8)];
+ z[1] = x[2] ^ s5[zi( 0)]^s6[zi( 2)]^s7[zi( 1)]^s8[zi( 3)]^s8[xi(10)];
+ z[2] = x[3] ^ s5[zi( 7)]^s6[zi( 6)]^s7[zi( 5)]^s8[zi( 4)]^s5[xi( 9)];
+ z[3] = x[1] ^ s5[zi(10)]^s6[zi( 9)]^s7[zi(11)]^s8[zi( 8)]^s6[xi(11)];
+ k[8] = s5[zi( 3)]^s6[zi( 2)]^s7[zi(12)]^s8[zi(13)]^s5[zi( 9)];
+ k[9] = s5[zi( 1)]^s6[zi( 0)]^s7[zi(14)]^s8[zi(15)]^s6[zi(12)];
+ k[10]= s5[zi( 7)]^s6[zi( 6)]^s7[zi( 8)]^s8[zi( 9)]^s7[zi( 2)];
+ k[11]= s5[zi( 5)]^s6[zi( 4)]^s7[zi(10)]^s8[zi(11)]^s8[zi( 6)];
+
+ x[0] = z[2] ^ s5[zi( 5)]^s6[zi( 7)]^s7[zi( 4)]^s8[zi( 6)]^s7[zi( 0)];
+ x[1] = z[0] ^ s5[xi( 0)]^s6[xi( 2)]^s7[xi( 1)]^s8[xi( 3)]^s8[zi( 2)];
+ x[2] = z[1] ^ s5[xi( 7)]^s6[xi( 6)]^s7[xi( 5)]^s8[xi( 4)]^s5[zi( 1)];
+ x[3] = z[3] ^ s5[xi(10)]^s6[xi( 9)]^s7[xi(11)]^s8[xi( 8)]^s6[zi( 3)];
+ k[12]= s5[xi( 8)]^s6[xi( 9)]^s7[xi( 7)]^s8[xi( 6)]^s5[xi( 3)];
+ k[13]= s5[xi(10)]^s6[xi(11)]^s7[xi( 5)]^s8[xi( 4)]^s6[xi( 7)];
+ k[14]= s5[xi(12)]^s6[xi(13)]^s7[xi( 3)]^s8[xi( 2)]^s7[xi( 8)];
+ k[15]= s5[xi(14)]^s6[xi(15)]^s7[xi( 1)]^s8[xi( 0)]^s8[xi(13)];
+
+#undef xi
+#undef zi
+}
+
+
+static gcry_err_code_t
+do_cast_setkey( CAST5_context *c, const byte *key, unsigned keylen )
+{
+ static int initialized;
+ static const char* selftest_failed;
+ int i;
+ u32 x[4];
+ u32 z[4];
+ u32 k[16];
+
+ if( !initialized )
+ {
+ initialized = 1;
+ selftest_failed = selftest();
+ if( selftest_failed )
+ log_error ("CAST5 selftest failed (%s).\n", selftest_failed );
+ }
+ if( selftest_failed )
+ return GPG_ERR_SELFTEST_FAILED;
+
+ if( keylen != 16 )
+ return GPG_ERR_INV_KEYLEN;
+
+ x[0] = key[0] << 24 | key[1] << 16 | key[2] << 8 | key[3];
+ x[1] = key[4] << 24 | key[5] << 16 | key[6] << 8 | key[7];
+ x[2] = key[8] << 24 | key[9] << 16 | key[10] << 8 | key[11];
+ x[3] = key[12] << 24 | key[13] << 16 | key[14] << 8 | key[15];
+
+ key_schedule( x, z, k );
+ for(i=0; i < 16; i++ )
+ c->Km[i] = k[i];
+ key_schedule( x, z, k );
+ for(i=0; i < 16; i++ )
+ c->Kr[i] = k[i] & 0x1f;
+
+ memset(&x,0, sizeof x);
+ memset(&z,0, sizeof z);
+ memset(&k,0, sizeof k);
+
+#undef xi
+#undef zi
+ return GPG_ERR_NO_ERROR;
+}
+
+static gcry_err_code_t
+cast_setkey (void *context, const byte *key, unsigned keylen )
+{
+ CAST5_context *c = (CAST5_context *) context;
+ gcry_err_code_t rc = do_cast_setkey (c, key, keylen);
+ _gcry_burn_stack (96+7*sizeof(void*));
+ return rc;
+}
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_cast5 =
+ {
+ "CAST5", NULL, NULL, CAST5_BLOCKSIZE, 128, sizeof (CAST5_context),
+ cast_setkey, encrypt_block, decrypt_block
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_cast5",
+#endif
+ };
+
+
+GRUB_MOD_INIT(gcry_cast5)
+{
+ grub_cipher_register (&_gcry_cipher_spec_cast5);
+}
+
+GRUB_MOD_FINI(gcry_cast5)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_cast5);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/cipher.h b/grub-core/lib/libgcrypt-grub/cipher/cipher.h
new file mode 100644
index 0000000..73c6779
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/cipher.h
@@ -0,0 +1,2 @@
+#include <grub/crypto.h>
+#include <cipher_wrap.h>
diff --git a/grub-core/lib/libgcrypt-grub/cipher/crc.c b/grub-core/lib/libgcrypt-grub/cipher/crc.c
new file mode 100644
index 0000000..a929432
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/crc.c
@@ -0,0 +1,826 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* crc.c - Cyclic redundancy checks.
+ * Copyright (C) 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ */
+
+
+#include "g10lib.h"
+#include "cipher.h"
+
+#include "bithelp.h"
+#include "bufhelp.h"
+
+
+typedef struct
+{
+ u32 CRC;
+ byte buf[4];
+}
+CRC_CONTEXT;
+
+
+/*
+ * Code generated by universal_crc by Danjel McGougan
+ *
+ * CRC parameters used:
+ * bits: 32
+ * poly: 0x04c11db7
+ * init: 0xffffffff
+ * xor: 0xffffffff
+ * reverse: true
+ * non-direct: false
+ *
+ * CRC of the string "123456789" is 0xcbf43926
+ */
+
+static const u32 crc32_table[1024] = {
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
+ 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
+ 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
+ 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+ 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
+ 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
+ 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
+ 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
+ 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
+ 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
+ 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
+ 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
+ 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
+ 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
+ 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+ 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
+ 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
+ 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
+ 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
+ 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
+ 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
+ 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+ 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
+ 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
+ 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
+ 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
+ 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
+ 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
+ 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
+ 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
+ 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
+ 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
+ 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+ 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
+ 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
+ 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
+ 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
+ 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
+ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
+ 0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3,
+ 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7,
+ 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb,
+ 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, 0x87981ccf,
+ 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192,
+ 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496,
+ 0x821b9859, 0x9b00a918, 0xb02dfadb, 0xa936cb9a,
+ 0xe6775d5d, 0xff6c6c1c, 0xd4413fdf, 0xcd5a0e9e,
+ 0x958424a2, 0x8c9f15e3, 0xa7b24620, 0xbea97761,
+ 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265,
+ 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69,
+ 0x39316bae, 0x202a5aef, 0x0b07092c, 0x121c386d,
+ 0xdf4636f3, 0xc65d07b2, 0xed705471, 0xf46b6530,
+ 0xbb2af3f7, 0xa231c2b6, 0x891c9175, 0x9007a034,
+ 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38,
+ 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c,
+ 0xf0794f05, 0xe9627e44, 0xc24f2d87, 0xdb541cc6,
+ 0x94158a01, 0x8d0ebb40, 0xa623e883, 0xbf38d9c2,
+ 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, 0x138d96ce,
+ 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca,
+ 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97,
+ 0xded79850, 0xc7cca911, 0xece1fad2, 0xf5facb93,
+ 0x7262d75c, 0x6b79e61d, 0x4054b5de, 0x594f849f,
+ 0x160e1258, 0x0f152319, 0x243870da, 0x3d23419b,
+ 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864,
+ 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60,
+ 0xad24e1af, 0xb43fd0ee, 0x9f12832d, 0x8609b26c,
+ 0xc94824ab, 0xd05315ea, 0xfb7e4629, 0xe2657768,
+ 0x2f3f79f6, 0x362448b7, 0x1d091b74, 0x04122a35,
+ 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31,
+ 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d,
+ 0x838a36fa, 0x9a9107bb, 0xb1bc5478, 0xa8a76539,
+ 0x3b83984b, 0x2298a90a, 0x09b5fac9, 0x10aecb88,
+ 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, 0x74c20e8c,
+ 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180,
+ 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484,
+ 0x71418a1a, 0x685abb5b, 0x4377e898, 0x5a6cd9d9,
+ 0x152d4f1e, 0x0c367e5f, 0x271b2d9c, 0x3e001cdd,
+ 0xb9980012, 0xa0833153, 0x8bae6290, 0x92b553d1,
+ 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5,
+ 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a,
+ 0xca6b79ed, 0xd37048ac, 0xf85d1b6f, 0xe1462a2e,
+ 0x66de36e1, 0x7fc507a0, 0x54e85463, 0x4df36522,
+ 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, 0x299fa026,
+ 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b,
+ 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f,
+ 0x2c1c24b0, 0x350715f1, 0x1e2a4632, 0x07317773,
+ 0x4870e1b4, 0x516bd0f5, 0x7a468336, 0x635db277,
+ 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, 0xe0d7848d,
+ 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189,
+ 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85,
+ 0x674f9842, 0x7e54a903, 0x5579fac0, 0x4c62cb81,
+ 0x8138c51f, 0x9823f45e, 0xb30ea79d, 0xaa1596dc,
+ 0xe554001b, 0xfc4f315a, 0xd7626299, 0xce7953d8,
+ 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4,
+ 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0,
+ 0x5e7ef3ec, 0x4765c2ad, 0x6c48916e, 0x7553a02f,
+ 0x3a1236e8, 0x230907a9, 0x0824546a, 0x113f652b,
+ 0x96a779e4, 0x8fbc48a5, 0xa4911b66, 0xbd8a2a27,
+ 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23,
+ 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e,
+ 0x70d024b9, 0x69cb15f8, 0x42e6463b, 0x5bfd777a,
+ 0xdc656bb5, 0xc57e5af4, 0xee530937, 0xf7483876,
+ 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, 0x9324fd72,
+ 0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59,
+ 0x0709a8dc, 0x06cbc2eb, 0x048d7cb2, 0x054f1685,
+ 0x0e1351b8, 0x0fd13b8f, 0x0d9785d6, 0x0c55efe1,
+ 0x091af964, 0x08d89353, 0x0a9e2d0a, 0x0b5c473d,
+ 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29,
+ 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5,
+ 0x1235f2c8, 0x13f798ff, 0x11b126a6, 0x10734c91,
+ 0x153c5a14, 0x14fe3023, 0x16b88e7a, 0x177ae44d,
+ 0x384d46e0, 0x398f2cd7, 0x3bc9928e, 0x3a0bf8b9,
+ 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065,
+ 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901,
+ 0x3157bf84, 0x3095d5b3, 0x32d36bea, 0x331101dd,
+ 0x246be590, 0x25a98fa7, 0x27ef31fe, 0x262d5bc9,
+ 0x23624d4c, 0x22a0277b, 0x20e69922, 0x2124f315,
+ 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71,
+ 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad,
+ 0x709a8dc0, 0x7158e7f7, 0x731e59ae, 0x72dc3399,
+ 0x7793251c, 0x76514f2b, 0x7417f172, 0x75d59b45,
+ 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, 0x7ccf6221,
+ 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd,
+ 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9,
+ 0x6bb5866c, 0x6a77ec5b, 0x68315202, 0x69f33835,
+ 0x62af7f08, 0x636d153f, 0x612bab66, 0x60e9c151,
+ 0x65a6d7d4, 0x6464bde3, 0x662203ba, 0x67e0698d,
+ 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579,
+ 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5,
+ 0x46c49a98, 0x4706f0af, 0x45404ef6, 0x448224c1,
+ 0x41cd3244, 0x400f5873, 0x4249e62a, 0x438b8c1d,
+ 0x54f16850, 0x55330267, 0x5775bc3e, 0x56b7d609,
+ 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5,
+ 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1,
+ 0x5deb9134, 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d,
+ 0xe1351b80, 0xe0f771b7, 0xe2b1cfee, 0xe373a5d9,
+ 0xe63cb35c, 0xe7fed96b, 0xe5b86732, 0xe47a0d05,
+ 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461,
+ 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd,
+ 0xfd13b8f0, 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9,
+ 0xfa1a102c, 0xfbd87a1b, 0xf99ec442, 0xf85cae75,
+ 0xf300e948, 0xf2c2837f, 0xf0843d26, 0xf1465711,
+ 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd,
+ 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339,
+ 0xde71f5bc, 0xdfb39f8b, 0xddf521d2, 0xdc374be5,
+ 0xd76b0cd8, 0xd6a966ef, 0xd4efd8b6, 0xd52db281,
+ 0xd062a404, 0xd1a0ce33, 0xd3e6706a, 0xd2241a5d,
+ 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049,
+ 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895,
+ 0xcb4dafa8, 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1,
+ 0xcc440774, 0xcd866d43, 0xcfc0d31a, 0xce02b92d,
+ 0x91af9640, 0x906dfc77, 0x922b422e, 0x93e92819,
+ 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5,
+ 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1,
+ 0x98b56f24, 0x99770513, 0x9b31bb4a, 0x9af3d17d,
+ 0x8d893530, 0x8c4b5f07, 0x8e0de15e, 0x8fcf8b69,
+ 0x8a809dec, 0x8b42f7db, 0x89044982, 0x88c623b5,
+ 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1,
+ 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d,
+ 0xa9e2d0a0, 0xa820ba97, 0xaa6604ce, 0xaba46ef9,
+ 0xaeeb787c, 0xaf29124b, 0xad6fac12, 0xacadc625,
+ 0xa7f18118, 0xa633eb2f, 0xa4755576, 0xa5b73f41,
+ 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d,
+ 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89,
+ 0xb2cddb0c, 0xb30fb13b, 0xb1490f62, 0xb08b6555,
+ 0xbbd72268, 0xba15485f, 0xb853f606, 0xb9919c31,
+ 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, 0xbe9834ed,
+ 0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee,
+ 0x8f629757, 0x37def032, 0x256b5fdc, 0x9dd738b9,
+ 0xc5b428ef, 0x7d084f8a, 0x6fbde064, 0xd7018701,
+ 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, 0x58631056,
+ 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871,
+ 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26,
+ 0x95ad7f70, 0x2d111815, 0x3fa4b7fb, 0x8718d09e,
+ 0x1acfe827, 0xa2738f42, 0xb0c620ac, 0x087a47c9,
+ 0xa032af3e, 0x188ec85b, 0x0a3b67b5, 0xb28700d0,
+ 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787,
+ 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f,
+ 0xeae41086, 0x525877e3, 0x40edd80d, 0xf851bf68,
+ 0xf02bf8a1, 0x48979fc4, 0x5a22302a, 0xe29e574f,
+ 0x7f496ff6, 0xc7f50893, 0xd540a77d, 0x6dfcc018,
+ 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0,
+ 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7,
+ 0x9b14583d, 0x23a83f58, 0x311d90b6, 0x89a1f7d3,
+ 0x1476cf6a, 0xaccaa80f, 0xbe7f07e1, 0x06c36084,
+ 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, 0x4c15df3c,
+ 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b,
+ 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c,
+ 0x446f98f5, 0xfcd3ff90, 0xee66507e, 0x56da371b,
+ 0x0eb9274d, 0xb6054028, 0xa4b0efc6, 0x1c0c88a3,
+ 0x81dbb01a, 0x3967d77f, 0x2bd27891, 0x936e1ff4,
+ 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed,
+ 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba,
+ 0xfe92dfec, 0x462eb889, 0x549b1767, 0xec277002,
+ 0x71f048bb, 0xc94c2fde, 0xdbf98030, 0x6345e755,
+ 0x6b3fa09c, 0xd383c7f9, 0xc1366817, 0x798a0f72,
+ 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825,
+ 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d,
+ 0x21e91f24, 0x99557841, 0x8be0d7af, 0x335cb0ca,
+ 0xed59b63b, 0x55e5d15e, 0x47507eb0, 0xffec19d5,
+ 0x623b216c, 0xda874609, 0xc832e9e7, 0x708e8e82,
+ 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a,
+ 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d,
+ 0xbd40e1a4, 0x05fc86c1, 0x1749292f, 0xaff54e4a,
+ 0x322276f3, 0x8a9e1196, 0x982bbe78, 0x2097d91d,
+ 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, 0x6a4166a5,
+ 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2,
+ 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb,
+ 0xc2098e52, 0x7ab5e937, 0x680046d9, 0xd0bc21bc,
+ 0x88df31ea, 0x3063568f, 0x22d6f961, 0x9a6a9e04,
+ 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, 0x15080953,
+ 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174,
+ 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623,
+ 0xd8c66675, 0x607a0110, 0x72cfaefe, 0xca73c99b,
+ 0x57a4f122, 0xef189647, 0xfdad39a9, 0x45115ecc,
+ 0x764dee06, 0xcef18963, 0xdc44268d, 0x64f841e8,
+ 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf,
+ 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907,
+ 0x3c9b51be, 0x842736db, 0x96929935, 0x2e2efe50,
+ 0x2654b999, 0x9ee8defc, 0x8c5d7112, 0x34e11677,
+ 0xa9362ece, 0x118a49ab, 0x033fe645, 0xbb838120,
+ 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98,
+ 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf,
+ 0xd67f4138, 0x6ec3265d, 0x7c7689b3, 0xc4caeed6,
+ 0x591dd66f, 0xe1a1b10a, 0xf3141ee4, 0x4ba87981,
+ 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, 0x017ec639,
+ 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e,
+ 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949,
+ 0x090481f0, 0xb1b8e695, 0xa30d497b, 0x1bb12e1e,
+ 0x43d23e48, 0xfb6e592d, 0xe9dbf6c3, 0x516791a6,
+ 0xccb0a91f, 0x740cce7a, 0x66b96194, 0xde0506f1
+};
+
+/* CRC32 */
+
+static inline u32
+crc32_next (u32 crc, byte data)
+{
+ return (crc >> 8) ^ crc32_table[(crc & 0xff) ^ data];
+}
+
+/*
+ * Process 4 bytes in one go
+ */
+static inline u32
+crc32_next4 (u32 crc, u32 data)
+{
+ crc ^= data;
+ crc = crc32_table[(crc & 0xff) + 0x300] ^
+ crc32_table[((crc >> 8) & 0xff) + 0x200] ^
+ crc32_table[((crc >> 16) & 0xff) + 0x100] ^
+ crc32_table[(crc >> 24) & 0xff];
+ return crc;
+}
+
+static void
+crc32_init (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ ctx->CRC = 0 ^ 0xffffffffL;
+}
+
+static void
+crc32_write (void *context, const void *inbuf_arg, size_t inlen)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ const byte *inbuf = inbuf_arg;
+ u32 crc;
+
+ if (!inbuf || !inlen)
+ return;
+
+ crc = ctx->CRC;
+
+ while (inlen >= 16)
+ {
+ inlen -= 16;
+ crc = crc32_next4(crc, buf_get_le32(&inbuf[0]));
+ crc = crc32_next4(crc, buf_get_le32(&inbuf[4]));
+ crc = crc32_next4(crc, buf_get_le32(&inbuf[8]));
+ crc = crc32_next4(crc, buf_get_le32(&inbuf[12]));
+ inbuf += 16;
+ }
+
+ while (inlen >= 4)
+ {
+ inlen -= 4;
+ crc = crc32_next4(crc, buf_get_le32(inbuf));
+ inbuf += 4;
+ }
+
+ while (inlen--)
+ {
+ crc = crc32_next(crc, *inbuf++);
+ }
+
+ ctx->CRC = crc;
+}
+
+static byte *
+crc32_read (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ return ctx->buf;
+}
+
+static void
+crc32_final (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ ctx->CRC ^= 0xffffffffL;
+ buf_put_be32 (ctx->buf, ctx->CRC);
+}
+
+/* CRC32 a'la RFC 1510 */
+/* CRC of the string "123456789" is 0x2dfd2d88 */
+
+static void
+crc32rfc1510_init (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ ctx->CRC = 0;
+}
+
+static void
+crc32rfc1510_final (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ buf_put_be32(ctx->buf, ctx->CRC);
+}
+
+/* CRC24 a'la RFC 2440 */
+/*
+ * Code generated by universal_crc by Danjel McGougan
+ *
+ * CRC parameters used:
+ * bits: 24
+ * poly: 0x864cfb
+ * init: 0xb704ce
+ * xor: 0x000000
+ * reverse: false
+ * non-direct: false
+ *
+ * CRC of the string "123456789" is 0x21cf02
+ */
+
+static const u32 crc24_table[1024] =
+{
+ 0x00000000, 0x00fb4c86, 0x000dd58a, 0x00f6990c,
+ 0x00e1e693, 0x001aaa15, 0x00ec3319, 0x00177f9f,
+ 0x003981a1, 0x00c2cd27, 0x0034542b, 0x00cf18ad,
+ 0x00d86732, 0x00232bb4, 0x00d5b2b8, 0x002efe3e,
+ 0x00894ec5, 0x00720243, 0x00849b4f, 0x007fd7c9,
+ 0x0068a856, 0x0093e4d0, 0x00657ddc, 0x009e315a,
+ 0x00b0cf64, 0x004b83e2, 0x00bd1aee, 0x00465668,
+ 0x005129f7, 0x00aa6571, 0x005cfc7d, 0x00a7b0fb,
+ 0x00e9d10c, 0x00129d8a, 0x00e40486, 0x001f4800,
+ 0x0008379f, 0x00f37b19, 0x0005e215, 0x00feae93,
+ 0x00d050ad, 0x002b1c2b, 0x00dd8527, 0x0026c9a1,
+ 0x0031b63e, 0x00cafab8, 0x003c63b4, 0x00c72f32,
+ 0x00609fc9, 0x009bd34f, 0x006d4a43, 0x009606c5,
+ 0x0081795a, 0x007a35dc, 0x008cacd0, 0x0077e056,
+ 0x00591e68, 0x00a252ee, 0x0054cbe2, 0x00af8764,
+ 0x00b8f8fb, 0x0043b47d, 0x00b52d71, 0x004e61f7,
+ 0x00d2a319, 0x0029ef9f, 0x00df7693, 0x00243a15,
+ 0x0033458a, 0x00c8090c, 0x003e9000, 0x00c5dc86,
+ 0x00eb22b8, 0x00106e3e, 0x00e6f732, 0x001dbbb4,
+ 0x000ac42b, 0x00f188ad, 0x000711a1, 0x00fc5d27,
+ 0x005beddc, 0x00a0a15a, 0x00563856, 0x00ad74d0,
+ 0x00ba0b4f, 0x004147c9, 0x00b7dec5, 0x004c9243,
+ 0x00626c7d, 0x009920fb, 0x006fb9f7, 0x0094f571,
+ 0x00838aee, 0x0078c668, 0x008e5f64, 0x007513e2,
+ 0x003b7215, 0x00c03e93, 0x0036a79f, 0x00cdeb19,
+ 0x00da9486, 0x0021d800, 0x00d7410c, 0x002c0d8a,
+ 0x0002f3b4, 0x00f9bf32, 0x000f263e, 0x00f46ab8,
+ 0x00e31527, 0x001859a1, 0x00eec0ad, 0x00158c2b,
+ 0x00b23cd0, 0x00497056, 0x00bfe95a, 0x0044a5dc,
+ 0x0053da43, 0x00a896c5, 0x005e0fc9, 0x00a5434f,
+ 0x008bbd71, 0x0070f1f7, 0x008668fb, 0x007d247d,
+ 0x006a5be2, 0x00911764, 0x00678e68, 0x009cc2ee,
+ 0x00a44733, 0x005f0bb5, 0x00a992b9, 0x0052de3f,
+ 0x0045a1a0, 0x00beed26, 0x0048742a, 0x00b338ac,
+ 0x009dc692, 0x00668a14, 0x00901318, 0x006b5f9e,
+ 0x007c2001, 0x00876c87, 0x0071f58b, 0x008ab90d,
+ 0x002d09f6, 0x00d64570, 0x0020dc7c, 0x00db90fa,
+ 0x00ccef65, 0x0037a3e3, 0x00c13aef, 0x003a7669,
+ 0x00148857, 0x00efc4d1, 0x00195ddd, 0x00e2115b,
+ 0x00f56ec4, 0x000e2242, 0x00f8bb4e, 0x0003f7c8,
+ 0x004d963f, 0x00b6dab9, 0x004043b5, 0x00bb0f33,
+ 0x00ac70ac, 0x00573c2a, 0x00a1a526, 0x005ae9a0,
+ 0x0074179e, 0x008f5b18, 0x0079c214, 0x00828e92,
+ 0x0095f10d, 0x006ebd8b, 0x00982487, 0x00636801,
+ 0x00c4d8fa, 0x003f947c, 0x00c90d70, 0x003241f6,
+ 0x00253e69, 0x00de72ef, 0x0028ebe3, 0x00d3a765,
+ 0x00fd595b, 0x000615dd, 0x00f08cd1, 0x000bc057,
+ 0x001cbfc8, 0x00e7f34e, 0x00116a42, 0x00ea26c4,
+ 0x0076e42a, 0x008da8ac, 0x007b31a0, 0x00807d26,
+ 0x009702b9, 0x006c4e3f, 0x009ad733, 0x00619bb5,
+ 0x004f658b, 0x00b4290d, 0x0042b001, 0x00b9fc87,
+ 0x00ae8318, 0x0055cf9e, 0x00a35692, 0x00581a14,
+ 0x00ffaaef, 0x0004e669, 0x00f27f65, 0x000933e3,
+ 0x001e4c7c, 0x00e500fa, 0x001399f6, 0x00e8d570,
+ 0x00c62b4e, 0x003d67c8, 0x00cbfec4, 0x0030b242,
+ 0x0027cddd, 0x00dc815b, 0x002a1857, 0x00d154d1,
+ 0x009f3526, 0x006479a0, 0x0092e0ac, 0x0069ac2a,
+ 0x007ed3b5, 0x00859f33, 0x0073063f, 0x00884ab9,
+ 0x00a6b487, 0x005df801, 0x00ab610d, 0x00502d8b,
+ 0x00475214, 0x00bc1e92, 0x004a879e, 0x00b1cb18,
+ 0x00167be3, 0x00ed3765, 0x001bae69, 0x00e0e2ef,
+ 0x00f79d70, 0x000cd1f6, 0x00fa48fa, 0x0001047c,
+ 0x002ffa42, 0x00d4b6c4, 0x00222fc8, 0x00d9634e,
+ 0x00ce1cd1, 0x00355057, 0x00c3c95b, 0x003885dd,
+ 0x00000000, 0x00488f66, 0x00901ecd, 0x00d891ab,
+ 0x00db711c, 0x0093fe7a, 0x004b6fd1, 0x0003e0b7,
+ 0x00b6e338, 0x00fe6c5e, 0x0026fdf5, 0x006e7293,
+ 0x006d9224, 0x00251d42, 0x00fd8ce9, 0x00b5038f,
+ 0x006cc771, 0x00244817, 0x00fcd9bc, 0x00b456da,
+ 0x00b7b66d, 0x00ff390b, 0x0027a8a0, 0x006f27c6,
+ 0x00da2449, 0x0092ab2f, 0x004a3a84, 0x0002b5e2,
+ 0x00015555, 0x0049da33, 0x00914b98, 0x00d9c4fe,
+ 0x00d88ee3, 0x00900185, 0x0048902e, 0x00001f48,
+ 0x0003ffff, 0x004b7099, 0x0093e132, 0x00db6e54,
+ 0x006e6ddb, 0x0026e2bd, 0x00fe7316, 0x00b6fc70,
+ 0x00b51cc7, 0x00fd93a1, 0x0025020a, 0x006d8d6c,
+ 0x00b44992, 0x00fcc6f4, 0x0024575f, 0x006cd839,
+ 0x006f388e, 0x0027b7e8, 0x00ff2643, 0x00b7a925,
+ 0x0002aaaa, 0x004a25cc, 0x0092b467, 0x00da3b01,
+ 0x00d9dbb6, 0x009154d0, 0x0049c57b, 0x00014a1d,
+ 0x004b5141, 0x0003de27, 0x00db4f8c, 0x0093c0ea,
+ 0x0090205d, 0x00d8af3b, 0x00003e90, 0x0048b1f6,
+ 0x00fdb279, 0x00b53d1f, 0x006dacb4, 0x002523d2,
+ 0x0026c365, 0x006e4c03, 0x00b6dda8, 0x00fe52ce,
+ 0x00279630, 0x006f1956, 0x00b788fd, 0x00ff079b,
+ 0x00fce72c, 0x00b4684a, 0x006cf9e1, 0x00247687,
+ 0x00917508, 0x00d9fa6e, 0x00016bc5, 0x0049e4a3,
+ 0x004a0414, 0x00028b72, 0x00da1ad9, 0x009295bf,
+ 0x0093dfa2, 0x00db50c4, 0x0003c16f, 0x004b4e09,
+ 0x0048aebe, 0x000021d8, 0x00d8b073, 0x00903f15,
+ 0x00253c9a, 0x006db3fc, 0x00b52257, 0x00fdad31,
+ 0x00fe4d86, 0x00b6c2e0, 0x006e534b, 0x0026dc2d,
+ 0x00ff18d3, 0x00b797b5, 0x006f061e, 0x00278978,
+ 0x002469cf, 0x006ce6a9, 0x00b47702, 0x00fcf864,
+ 0x0049fbeb, 0x0001748d, 0x00d9e526, 0x00916a40,
+ 0x00928af7, 0x00da0591, 0x0002943a, 0x004a1b5c,
+ 0x0096a282, 0x00de2de4, 0x0006bc4f, 0x004e3329,
+ 0x004dd39e, 0x00055cf8, 0x00ddcd53, 0x00954235,
+ 0x002041ba, 0x0068cedc, 0x00b05f77, 0x00f8d011,
+ 0x00fb30a6, 0x00b3bfc0, 0x006b2e6b, 0x0023a10d,
+ 0x00fa65f3, 0x00b2ea95, 0x006a7b3e, 0x0022f458,
+ 0x002114ef, 0x00699b89, 0x00b10a22, 0x00f98544,
+ 0x004c86cb, 0x000409ad, 0x00dc9806, 0x00941760,
+ 0x0097f7d7, 0x00df78b1, 0x0007e91a, 0x004f667c,
+ 0x004e2c61, 0x0006a307, 0x00de32ac, 0x0096bdca,
+ 0x00955d7d, 0x00ddd21b, 0x000543b0, 0x004dccd6,
+ 0x00f8cf59, 0x00b0403f, 0x0068d194, 0x00205ef2,
+ 0x0023be45, 0x006b3123, 0x00b3a088, 0x00fb2fee,
+ 0x0022eb10, 0x006a6476, 0x00b2f5dd, 0x00fa7abb,
+ 0x00f99a0c, 0x00b1156a, 0x006984c1, 0x00210ba7,
+ 0x00940828, 0x00dc874e, 0x000416e5, 0x004c9983,
+ 0x004f7934, 0x0007f652, 0x00df67f9, 0x0097e89f,
+ 0x00ddf3c3, 0x00957ca5, 0x004ded0e, 0x00056268,
+ 0x000682df, 0x004e0db9, 0x00969c12, 0x00de1374,
+ 0x006b10fb, 0x00239f9d, 0x00fb0e36, 0x00b38150,
+ 0x00b061e7, 0x00f8ee81, 0x00207f2a, 0x0068f04c,
+ 0x00b134b2, 0x00f9bbd4, 0x00212a7f, 0x0069a519,
+ 0x006a45ae, 0x0022cac8, 0x00fa5b63, 0x00b2d405,
+ 0x0007d78a, 0x004f58ec, 0x0097c947, 0x00df4621,
+ 0x00dca696, 0x009429f0, 0x004cb85b, 0x0004373d,
+ 0x00057d20, 0x004df246, 0x009563ed, 0x00ddec8b,
+ 0x00de0c3c, 0x0096835a, 0x004e12f1, 0x00069d97,
+ 0x00b39e18, 0x00fb117e, 0x002380d5, 0x006b0fb3,
+ 0x0068ef04, 0x00206062, 0x00f8f1c9, 0x00b07eaf,
+ 0x0069ba51, 0x00213537, 0x00f9a49c, 0x00b12bfa,
+ 0x00b2cb4d, 0x00fa442b, 0x0022d580, 0x006a5ae6,
+ 0x00df5969, 0x0097d60f, 0x004f47a4, 0x0007c8c2,
+ 0x00042875, 0x004ca713, 0x009436b8, 0x00dcb9de,
+ 0x00000000, 0x00d70983, 0x00555f80, 0x00825603,
+ 0x0051f286, 0x0086fb05, 0x0004ad06, 0x00d3a485,
+ 0x0059a88b, 0x008ea108, 0x000cf70b, 0x00dbfe88,
+ 0x00085a0d, 0x00df538e, 0x005d058d, 0x008a0c0e,
+ 0x00491c91, 0x009e1512, 0x001c4311, 0x00cb4a92,
+ 0x0018ee17, 0x00cfe794, 0x004db197, 0x009ab814,
+ 0x0010b41a, 0x00c7bd99, 0x0045eb9a, 0x0092e219,
+ 0x0041469c, 0x00964f1f, 0x0014191c, 0x00c3109f,
+ 0x006974a4, 0x00be7d27, 0x003c2b24, 0x00eb22a7,
+ 0x00388622, 0x00ef8fa1, 0x006dd9a2, 0x00bad021,
+ 0x0030dc2f, 0x00e7d5ac, 0x006583af, 0x00b28a2c,
+ 0x00612ea9, 0x00b6272a, 0x00347129, 0x00e378aa,
+ 0x00206835, 0x00f761b6, 0x007537b5, 0x00a23e36,
+ 0x00719ab3, 0x00a69330, 0x0024c533, 0x00f3ccb0,
+ 0x0079c0be, 0x00aec93d, 0x002c9f3e, 0x00fb96bd,
+ 0x00283238, 0x00ff3bbb, 0x007d6db8, 0x00aa643b,
+ 0x0029a4ce, 0x00fead4d, 0x007cfb4e, 0x00abf2cd,
+ 0x00785648, 0x00af5fcb, 0x002d09c8, 0x00fa004b,
+ 0x00700c45, 0x00a705c6, 0x002553c5, 0x00f25a46,
+ 0x0021fec3, 0x00f6f740, 0x0074a143, 0x00a3a8c0,
+ 0x0060b85f, 0x00b7b1dc, 0x0035e7df, 0x00e2ee5c,
+ 0x00314ad9, 0x00e6435a, 0x00641559, 0x00b31cda,
+ 0x003910d4, 0x00ee1957, 0x006c4f54, 0x00bb46d7,
+ 0x0068e252, 0x00bfebd1, 0x003dbdd2, 0x00eab451,
+ 0x0040d06a, 0x0097d9e9, 0x00158fea, 0x00c28669,
+ 0x001122ec, 0x00c62b6f, 0x00447d6c, 0x009374ef,
+ 0x001978e1, 0x00ce7162, 0x004c2761, 0x009b2ee2,
+ 0x00488a67, 0x009f83e4, 0x001dd5e7, 0x00cadc64,
+ 0x0009ccfb, 0x00dec578, 0x005c937b, 0x008b9af8,
+ 0x00583e7d, 0x008f37fe, 0x000d61fd, 0x00da687e,
+ 0x00506470, 0x00876df3, 0x00053bf0, 0x00d23273,
+ 0x000196f6, 0x00d69f75, 0x0054c976, 0x0083c0f5,
+ 0x00a9041b, 0x007e0d98, 0x00fc5b9b, 0x002b5218,
+ 0x00f8f69d, 0x002fff1e, 0x00ada91d, 0x007aa09e,
+ 0x00f0ac90, 0x0027a513, 0x00a5f310, 0x0072fa93,
+ 0x00a15e16, 0x00765795, 0x00f40196, 0x00230815,
+ 0x00e0188a, 0x00371109, 0x00b5470a, 0x00624e89,
+ 0x00b1ea0c, 0x0066e38f, 0x00e4b58c, 0x0033bc0f,
+ 0x00b9b001, 0x006eb982, 0x00ecef81, 0x003be602,
+ 0x00e84287, 0x003f4b04, 0x00bd1d07, 0x006a1484,
+ 0x00c070bf, 0x0017793c, 0x00952f3f, 0x004226bc,
+ 0x00918239, 0x00468bba, 0x00c4ddb9, 0x0013d43a,
+ 0x0099d834, 0x004ed1b7, 0x00cc87b4, 0x001b8e37,
+ 0x00c82ab2, 0x001f2331, 0x009d7532, 0x004a7cb1,
+ 0x00896c2e, 0x005e65ad, 0x00dc33ae, 0x000b3a2d,
+ 0x00d89ea8, 0x000f972b, 0x008dc128, 0x005ac8ab,
+ 0x00d0c4a5, 0x0007cd26, 0x00859b25, 0x005292a6,
+ 0x00813623, 0x00563fa0, 0x00d469a3, 0x00036020,
+ 0x0080a0d5, 0x0057a956, 0x00d5ff55, 0x0002f6d6,
+ 0x00d15253, 0x00065bd0, 0x00840dd3, 0x00530450,
+ 0x00d9085e, 0x000e01dd, 0x008c57de, 0x005b5e5d,
+ 0x0088fad8, 0x005ff35b, 0x00dda558, 0x000aacdb,
+ 0x00c9bc44, 0x001eb5c7, 0x009ce3c4, 0x004bea47,
+ 0x00984ec2, 0x004f4741, 0x00cd1142, 0x001a18c1,
+ 0x009014cf, 0x00471d4c, 0x00c54b4f, 0x001242cc,
+ 0x00c1e649, 0x0016efca, 0x0094b9c9, 0x0043b04a,
+ 0x00e9d471, 0x003eddf2, 0x00bc8bf1, 0x006b8272,
+ 0x00b826f7, 0x006f2f74, 0x00ed7977, 0x003a70f4,
+ 0x00b07cfa, 0x00677579, 0x00e5237a, 0x00322af9,
+ 0x00e18e7c, 0x003687ff, 0x00b4d1fc, 0x0063d87f,
+ 0x00a0c8e0, 0x0077c163, 0x00f59760, 0x00229ee3,
+ 0x00f13a66, 0x002633e5, 0x00a465e6, 0x00736c65,
+ 0x00f9606b, 0x002e69e8, 0x00ac3feb, 0x007b3668,
+ 0x00a892ed, 0x007f9b6e, 0x00fdcd6d, 0x002ac4ee,
+ 0x00000000, 0x00520936, 0x00a4126c, 0x00f61b5a,
+ 0x004825d8, 0x001a2cee, 0x00ec37b4, 0x00be3e82,
+ 0x006b0636, 0x00390f00, 0x00cf145a, 0x009d1d6c,
+ 0x002323ee, 0x00712ad8, 0x00873182, 0x00d538b4,
+ 0x00d60c6c, 0x0084055a, 0x00721e00, 0x00201736,
+ 0x009e29b4, 0x00cc2082, 0x003a3bd8, 0x006832ee,
+ 0x00bd0a5a, 0x00ef036c, 0x00191836, 0x004b1100,
+ 0x00f52f82, 0x00a726b4, 0x00513dee, 0x000334d8,
+ 0x00ac19d8, 0x00fe10ee, 0x00080bb4, 0x005a0282,
+ 0x00e43c00, 0x00b63536, 0x00402e6c, 0x0012275a,
+ 0x00c71fee, 0x009516d8, 0x00630d82, 0x003104b4,
+ 0x008f3a36, 0x00dd3300, 0x002b285a, 0x0079216c,
+ 0x007a15b4, 0x00281c82, 0x00de07d8, 0x008c0eee,
+ 0x0032306c, 0x0060395a, 0x00962200, 0x00c42b36,
+ 0x00111382, 0x00431ab4, 0x00b501ee, 0x00e708d8,
+ 0x0059365a, 0x000b3f6c, 0x00fd2436, 0x00af2d00,
+ 0x00a37f36, 0x00f17600, 0x00076d5a, 0x0055646c,
+ 0x00eb5aee, 0x00b953d8, 0x004f4882, 0x001d41b4,
+ 0x00c87900, 0x009a7036, 0x006c6b6c, 0x003e625a,
+ 0x00805cd8, 0x00d255ee, 0x00244eb4, 0x00764782,
+ 0x0075735a, 0x00277a6c, 0x00d16136, 0x00836800,
+ 0x003d5682, 0x006f5fb4, 0x009944ee, 0x00cb4dd8,
+ 0x001e756c, 0x004c7c5a, 0x00ba6700, 0x00e86e36,
+ 0x005650b4, 0x00045982, 0x00f242d8, 0x00a04bee,
+ 0x000f66ee, 0x005d6fd8, 0x00ab7482, 0x00f97db4,
+ 0x00474336, 0x00154a00, 0x00e3515a, 0x00b1586c,
+ 0x006460d8, 0x003669ee, 0x00c072b4, 0x00927b82,
+ 0x002c4500, 0x007e4c36, 0x0088576c, 0x00da5e5a,
+ 0x00d96a82, 0x008b63b4, 0x007d78ee, 0x002f71d8,
+ 0x00914f5a, 0x00c3466c, 0x00355d36, 0x00675400,
+ 0x00b26cb4, 0x00e06582, 0x00167ed8, 0x004477ee,
+ 0x00fa496c, 0x00a8405a, 0x005e5b00, 0x000c5236,
+ 0x0046ff6c, 0x0014f65a, 0x00e2ed00, 0x00b0e436,
+ 0x000edab4, 0x005cd382, 0x00aac8d8, 0x00f8c1ee,
+ 0x002df95a, 0x007ff06c, 0x0089eb36, 0x00dbe200,
+ 0x0065dc82, 0x0037d5b4, 0x00c1ceee, 0x0093c7d8,
+ 0x0090f300, 0x00c2fa36, 0x0034e16c, 0x0066e85a,
+ 0x00d8d6d8, 0x008adfee, 0x007cc4b4, 0x002ecd82,
+ 0x00fbf536, 0x00a9fc00, 0x005fe75a, 0x000dee6c,
+ 0x00b3d0ee, 0x00e1d9d8, 0x0017c282, 0x0045cbb4,
+ 0x00eae6b4, 0x00b8ef82, 0x004ef4d8, 0x001cfdee,
+ 0x00a2c36c, 0x00f0ca5a, 0x0006d100, 0x0054d836,
+ 0x0081e082, 0x00d3e9b4, 0x0025f2ee, 0x0077fbd8,
+ 0x00c9c55a, 0x009bcc6c, 0x006dd736, 0x003fde00,
+ 0x003cead8, 0x006ee3ee, 0x0098f8b4, 0x00caf182,
+ 0x0074cf00, 0x0026c636, 0x00d0dd6c, 0x0082d45a,
+ 0x0057ecee, 0x0005e5d8, 0x00f3fe82, 0x00a1f7b4,
+ 0x001fc936, 0x004dc000, 0x00bbdb5a, 0x00e9d26c,
+ 0x00e5805a, 0x00b7896c, 0x00419236, 0x00139b00,
+ 0x00ada582, 0x00ffacb4, 0x0009b7ee, 0x005bbed8,
+ 0x008e866c, 0x00dc8f5a, 0x002a9400, 0x00789d36,
+ 0x00c6a3b4, 0x0094aa82, 0x0062b1d8, 0x0030b8ee,
+ 0x00338c36, 0x00618500, 0x00979e5a, 0x00c5976c,
+ 0x007ba9ee, 0x0029a0d8, 0x00dfbb82, 0x008db2b4,
+ 0x00588a00, 0x000a8336, 0x00fc986c, 0x00ae915a,
+ 0x0010afd8, 0x0042a6ee, 0x00b4bdb4, 0x00e6b482,
+ 0x00499982, 0x001b90b4, 0x00ed8bee, 0x00bf82d8,
+ 0x0001bc5a, 0x0053b56c, 0x00a5ae36, 0x00f7a700,
+ 0x00229fb4, 0x00709682, 0x00868dd8, 0x00d484ee,
+ 0x006aba6c, 0x0038b35a, 0x00cea800, 0x009ca136,
+ 0x009f95ee, 0x00cd9cd8, 0x003b8782, 0x00698eb4,
+ 0x00d7b036, 0x0085b900, 0x0073a25a, 0x0021ab6c,
+ 0x00f493d8, 0x00a69aee, 0x005081b4, 0x00028882,
+ 0x00bcb600, 0x00eebf36, 0x0018a46c, 0x004aad5a
+};
+
+static inline
+u32 crc24_init (void)
+{
+ return 0xce04b7;
+}
+
+static inline
+u32 crc24_next (u32 crc, byte data)
+{
+ return (crc >> 8) ^ crc24_table[(crc & 0xff) ^ data];
+}
+
+/*
+ * Process 4 bytes in one go
+ */
+static inline
+u32 crc24_next4 (u32 crc, u32 data)
+{
+ crc ^= data;
+ crc = crc24_table[(crc & 0xff) + 0x300] ^
+ crc24_table[((crc >> 8) & 0xff) + 0x200] ^
+ crc24_table[((crc >> 16) & 0xff) + 0x100] ^
+ crc24_table[(crc >> 24) & 0xff];
+ return crc;
+}
+
+static inline
+u32 crc24_final (u32 crc)
+{
+ return crc & 0xffffff;
+}
+
+static void
+crc24rfc2440_init (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ ctx->CRC = crc24_init();
+}
+
+static void
+crc24rfc2440_write (void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ u32 crc;
+
+ if (!inbuf || !inlen)
+ return;
+
+ crc = ctx->CRC;
+
+ while (inlen >= 16)
+ {
+ inlen -= 16;
+ crc = crc24_next4(crc, buf_get_le32(&inbuf[0]));
+ crc = crc24_next4(crc, buf_get_le32(&inbuf[4]));
+ crc = crc24_next4(crc, buf_get_le32(&inbuf[8]));
+ crc = crc24_next4(crc, buf_get_le32(&inbuf[12]));
+ inbuf += 16;
+ }
+
+ while (inlen >= 4)
+ {
+ inlen -= 4;
+ crc = crc24_next4(crc, buf_get_le32(inbuf));
+ inbuf += 4;
+ }
+
+ while (inlen--)
+ {
+ crc = crc24_next(crc, *inbuf++);
+ }
+
+ ctx->CRC = crc;
+}
+
+static void
+crc24rfc2440_final (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ ctx->CRC = crc24_final(ctx->CRC);
+ buf_put_le32 (ctx->buf, ctx->CRC);
+}
+
+gcry_md_spec_t _gcry_digest_spec_crc32 =
+ {
+ "CRC32", NULL, 0, NULL, 4,
+ crc32_init, crc32_write, crc32_final, crc32_read,
+ sizeof (CRC_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_crc",
+#endif
+ .blocksize = 64
+ };
+
+gcry_md_spec_t _gcry_digest_spec_crc32_rfc1510 =
+ {
+ "CRC32RFC1510", NULL, 0, NULL, 4,
+ crc32rfc1510_init, crc32_write,
+ crc32rfc1510_final, crc32_read,
+ sizeof (CRC_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_crc",
+#endif
+ .blocksize = 64
+ };
+
+gcry_md_spec_t _gcry_digest_spec_crc24_rfc2440 =
+ {
+ "CRC24RFC2440", NULL, 0, NULL, 3,
+ crc24rfc2440_init, crc24rfc2440_write,
+ crc24rfc2440_final, crc32_read,
+ sizeof (CRC_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_crc",
+#endif
+ .blocksize = 64
+ };
+
+
+GRUB_MOD_INIT(gcry_crc)
+{
+ COMPILE_TIME_ASSERT(sizeof (CRC_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ COMPILE_TIME_ASSERT(sizeof (CRC_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ COMPILE_TIME_ASSERT(sizeof (CRC_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ grub_md_register (&_gcry_digest_spec_crc32);
+ grub_md_register (&_gcry_digest_spec_crc32_rfc1510);
+ grub_md_register (&_gcry_digest_spec_crc24_rfc2440);
+}
+
+GRUB_MOD_FINI(gcry_crc)
+{
+ grub_md_unregister (&_gcry_digest_spec_crc32);
+ grub_md_unregister (&_gcry_digest_spec_crc32_rfc1510);
+ grub_md_unregister (&_gcry_digest_spec_crc24_rfc2440);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/crypto.lst b/grub-core/lib/libgcrypt-grub/cipher/crypto.lst
new file mode 100644
index 0000000..77d9efc
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/crypto.lst
@@ -0,0 +1,45 @@
+RIJNDAEL: gcry_rijndael
+RIJNDAEL192: gcry_rijndael
+RIJNDAEL256: gcry_rijndael
+AES128: gcry_rijndael
+AES-128: gcry_rijndael
+AES-192: gcry_rijndael
+AES-256: gcry_rijndael
+ADLER32: adler32
+CRC64: crc64
+ARCFOUR: gcry_arcfour
+BLOWFISH: gcry_blowfish
+CAMELLIA128: gcry_camellia
+CAMELLIA192: gcry_camellia
+CAMELLIA256: gcry_camellia
+CAST5: gcry_cast5
+CRC32: gcry_crc
+CRC32RFC1510: gcry_crc
+CRC24RFC2440: gcry_crc
+DES: gcry_des
+3DES: gcry_des
+DSA: gcry_dsa
+IDEA: gcry_idea
+MD4: gcry_md4
+MD5: gcry_md5
+RFC2268_40: gcry_rfc2268
+AES: gcry_rijndael
+AES192: gcry_rijndael
+AES256: gcry_rijndael
+RIPEMD160: gcry_rmd160
+RSA: gcry_rsa
+SEED: gcry_seed
+SERPENT128: gcry_serpent
+SERPENT192: gcry_serpent
+SERPENT256: gcry_serpent
+SHA1: gcry_sha1
+SHA224: gcry_sha256
+SHA256: gcry_sha256
+SHA512: gcry_sha512
+SHA384: gcry_sha512
+TIGER192: gcry_tiger
+TIGER: gcry_tiger
+TIGER2: gcry_tiger
+TWOFISH: gcry_twofish
+TWOFISH128: gcry_twofish
+WHIRLPOOL: gcry_whirlpool
diff --git a/grub-core/lib/libgcrypt-grub/cipher/des.c b/grub-core/lib/libgcrypt-grub/cipher/des.c
new file mode 100644
index 0000000..09521e8
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/des.c
@@ -0,0 +1,929 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* des.c - DES and Triple-DES encryption/decryption Algorithm
+ * Copyright (C) 1998, 1999, 2001, 2002, 2003,
+ * 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * For a description of triple encryption, see:
+ * Bruce Schneier: Applied Cryptography. Second Edition.
+ * John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff.
+ * This implementation is according to the definition of DES in FIPS
+ * PUB 46-2 from December 1993.
+ */
+
+
+/*
+ * Written by Michael Roth <mroth@nessie.de>, September 1998
+ */
+
+
+/*
+ * U S A G E
+ * ===========
+ *
+ * For DES or Triple-DES encryption/decryption you must initialize a proper
+ * encryption context with a key.
+ *
+ * A DES key is 64bit wide but only 56bits of the key are used. The remaining
+ * bits are parity bits and they will _not_ checked in this implementation, but
+ * simply ignored.
+ *
+ * For Triple-DES you could use either two 64bit keys or three 64bit keys.
+ * The parity bits will _not_ checked, too.
+ *
+ * After initializing a context with a key you could use this context to
+ * encrypt or decrypt data in 64bit blocks in Electronic Codebook Mode.
+ *
+ * (In the examples below the slashes at the beginning and ending of comments
+ * are omited.)
+ *
+ * DES Example
+ * -----------
+ * unsigned char key[8];
+ * unsigned char plaintext[8];
+ * unsigned char ciphertext[8];
+ * unsigned char recoverd[8];
+ * des_ctx context;
+ *
+ * * Fill 'key' and 'plaintext' with some data *
+ * ....
+ *
+ * * Set up the DES encryption context *
+ * des_setkey(context, key);
+ *
+ * * Encrypt the plaintext *
+ * des_ecb_encrypt(context, plaintext, ciphertext);
+ *
+ * * To recover the orginal plaintext from ciphertext use: *
+ * des_ecb_decrypt(context, ciphertext, recoverd);
+ *
+ *
+ * Triple-DES Example
+ * ------------------
+ * unsigned char key1[8];
+ * unsigned char key2[8];
+ * unsigned char key3[8];
+ * unsigned char plaintext[8];
+ * unsigned char ciphertext[8];
+ * unsigned char recoverd[8];
+ * tripledes_ctx context;
+ *
+ * * If you would like to use two 64bit keys, fill 'key1' and'key2'
+ * then setup the encryption context: *
+ * tripledes_set2keys(context, key1, key2);
+ *
+ * * To use three 64bit keys with Triple-DES use: *
+ * tripledes_set3keys(context, key1, key2, key3);
+ *
+ * * Encrypting plaintext with Triple-DES *
+ * tripledes_ecb_encrypt(context, plaintext, ciphertext);
+ *
+ * * Decrypting ciphertext to recover the plaintext with Triple-DES *
+ * tripledes_ecb_decrypt(context, ciphertext, recoverd);
+ *
+ *
+ * Selftest
+ * --------
+ * char *error_msg;
+ *
+ * * To perform a selftest of this DES/Triple-DES implementation use the
+ * function selftest(). It will return an error string if there are
+ * some problems with this library. *
+ *
+ * if ( (error_msg = selftest()) )
+ * {
+ * fprintf(stderr, "An error in the DES/Triple-DES implementation occurred: %s\n", error_msg);
+ * abort();
+ * }
+ */
+
+
+#include "types.h" /* for byte and u32 typedefs */
+#include "g10lib.h"
+#include "cipher.h"
+
+#if defined(__GNUC__) && defined(__GNU_LIBRARY__)
+#define working_memcmp memcmp
+#else
+/*
+ * According to the SunOS man page, memcmp returns indeterminate sign
+ * depending on whether characters are signed or not.
+ */
+static int
+working_memcmp( const char *a, const char *b, size_t n )
+{
+ for( ; n; n--, a++, b++ )
+ if( *a != *b )
+ return (int)(*(byte*)a) - (int)(*(byte*)b);
+ return 0;
+}
+#endif
+
+/*
+ * Encryption/Decryption context of DES
+ */
+typedef struct _des_ctx
+ {
+ u32 encrypt_subkeys[32];
+ u32 decrypt_subkeys[32];
+ }
+des_ctx[1];
+
+/*
+ * Encryption/Decryption context of Triple-DES
+ */
+typedef struct _tripledes_ctx
+ {
+ u32 encrypt_subkeys[96];
+ u32 decrypt_subkeys[96];
+ struct {
+ int no_weak_key;
+ } flags;
+ }
+tripledes_ctx[1];
+
+static void des_key_schedule (const byte *, u32 *);
+static int des_setkey (struct _des_ctx *, const byte *);
+static int des_ecb_crypt (struct _des_ctx *, const byte *, byte *, int);
+static int tripledes_ecb_crypt (struct _tripledes_ctx *,
+ const byte *, byte *, int);
+static int is_weak_key ( const byte *key );
+
+static int initialized;
+
+
+
+
+/*
+ * The s-box values are permuted according to the 'primitive function P'
+ * and are rotated one bit to the left.
+ */
+static u32 sbox1[64] =
+{
+ 0x01010400, 0x00000000, 0x00010000, 0x01010404, 0x01010004, 0x00010404, 0x00000004, 0x00010000,
+ 0x00000400, 0x01010400, 0x01010404, 0x00000400, 0x01000404, 0x01010004, 0x01000000, 0x00000004,
+ 0x00000404, 0x01000400, 0x01000400, 0x00010400, 0x00010400, 0x01010000, 0x01010000, 0x01000404,
+ 0x00010004, 0x01000004, 0x01000004, 0x00010004, 0x00000000, 0x00000404, 0x00010404, 0x01000000,
+ 0x00010000, 0x01010404, 0x00000004, 0x01010000, 0x01010400, 0x01000000, 0x01000000, 0x00000400,
+ 0x01010004, 0x00010000, 0x00010400, 0x01000004, 0x00000400, 0x00000004, 0x01000404, 0x00010404,
+ 0x01010404, 0x00010004, 0x01010000, 0x01000404, 0x01000004, 0x00000404, 0x00010404, 0x01010400,
+ 0x00000404, 0x01000400, 0x01000400, 0x00000000, 0x00010004, 0x00010400, 0x00000000, 0x01010004
+};
+
+static u32 sbox2[64] =
+{
+ 0x80108020, 0x80008000, 0x00008000, 0x00108020, 0x00100000, 0x00000020, 0x80100020, 0x80008020,
+ 0x80000020, 0x80108020, 0x80108000, 0x80000000, 0x80008000, 0x00100000, 0x00000020, 0x80100020,
+ 0x00108000, 0x00100020, 0x80008020, 0x00000000, 0x80000000, 0x00008000, 0x00108020, 0x80100000,
+ 0x00100020, 0x80000020, 0x00000000, 0x00108000, 0x00008020, 0x80108000, 0x80100000, 0x00008020,
+ 0x00000000, 0x00108020, 0x80100020, 0x00100000, 0x80008020, 0x80100000, 0x80108000, 0x00008000,
+ 0x80100000, 0x80008000, 0x00000020, 0x80108020, 0x00108020, 0x00000020, 0x00008000, 0x80000000,
+ 0x00008020, 0x80108000, 0x00100000, 0x80000020, 0x00100020, 0x80008020, 0x80000020, 0x00100020,
+ 0x00108000, 0x00000000, 0x80008000, 0x00008020, 0x80000000, 0x80100020, 0x80108020, 0x00108000
+};
+
+static u32 sbox3[64] =
+{
+ 0x00000208, 0x08020200, 0x00000000, 0x08020008, 0x08000200, 0x00000000, 0x00020208, 0x08000200,
+ 0x00020008, 0x08000008, 0x08000008, 0x00020000, 0x08020208, 0x00020008, 0x08020000, 0x00000208,
+ 0x08000000, 0x00000008, 0x08020200, 0x00000200, 0x00020200, 0x08020000, 0x08020008, 0x00020208,
+ 0x08000208, 0x00020200, 0x00020000, 0x08000208, 0x00000008, 0x08020208, 0x00000200, 0x08000000,
+ 0x08020200, 0x08000000, 0x00020008, 0x00000208, 0x00020000, 0x08020200, 0x08000200, 0x00000000,
+ 0x00000200, 0x00020008, 0x08020208, 0x08000200, 0x08000008, 0x00000200, 0x00000000, 0x08020008,
+ 0x08000208, 0x00020000, 0x08000000, 0x08020208, 0x00000008, 0x00020208, 0x00020200, 0x08000008,
+ 0x08020000, 0x08000208, 0x00000208, 0x08020000, 0x00020208, 0x00000008, 0x08020008, 0x00020200
+};
+
+static u32 sbox4[64] =
+{
+ 0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802080, 0x00800081, 0x00800001, 0x00002001,
+ 0x00000000, 0x00802000, 0x00802000, 0x00802081, 0x00000081, 0x00000000, 0x00800080, 0x00800001,
+ 0x00000001, 0x00002000, 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002001, 0x00002080,
+ 0x00800081, 0x00000001, 0x00002080, 0x00800080, 0x00002000, 0x00802080, 0x00802081, 0x00000081,
+ 0x00800080, 0x00800001, 0x00802000, 0x00802081, 0x00000081, 0x00000000, 0x00000000, 0x00802000,
+ 0x00002080, 0x00800080, 0x00800081, 0x00000001, 0x00802001, 0x00002081, 0x00002081, 0x00000080,
+ 0x00802081, 0x00000081, 0x00000001, 0x00002000, 0x00800001, 0x00002001, 0x00802080, 0x00800081,
+ 0x00002001, 0x00002080, 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002000, 0x00802080
+};
+
+static u32 sbox5[64] =
+{
+ 0x00000100, 0x02080100, 0x02080000, 0x42000100, 0x00080000, 0x00000100, 0x40000000, 0x02080000,
+ 0x40080100, 0x00080000, 0x02000100, 0x40080100, 0x42000100, 0x42080000, 0x00080100, 0x40000000,
+ 0x02000000, 0x40080000, 0x40080000, 0x00000000, 0x40000100, 0x42080100, 0x42080100, 0x02000100,
+ 0x42080000, 0x40000100, 0x00000000, 0x42000000, 0x02080100, 0x02000000, 0x42000000, 0x00080100,
+ 0x00080000, 0x42000100, 0x00000100, 0x02000000, 0x40000000, 0x02080000, 0x42000100, 0x40080100,
+ 0x02000100, 0x40000000, 0x42080000, 0x02080100, 0x40080100, 0x00000100, 0x02000000, 0x42080000,
+ 0x42080100, 0x00080100, 0x42000000, 0x42080100, 0x02080000, 0x00000000, 0x40080000, 0x42000000,
+ 0x00080100, 0x02000100, 0x40000100, 0x00080000, 0x00000000, 0x40080000, 0x02080100, 0x40000100
+};
+
+static u32 sbox6[64] =
+{
+ 0x20000010, 0x20400000, 0x00004000, 0x20404010, 0x20400000, 0x00000010, 0x20404010, 0x00400000,
+ 0x20004000, 0x00404010, 0x00400000, 0x20000010, 0x00400010, 0x20004000, 0x20000000, 0x00004010,
+ 0x00000000, 0x00400010, 0x20004010, 0x00004000, 0x00404000, 0x20004010, 0x00000010, 0x20400010,
+ 0x20400010, 0x00000000, 0x00404010, 0x20404000, 0x00004010, 0x00404000, 0x20404000, 0x20000000,
+ 0x20004000, 0x00000010, 0x20400010, 0x00404000, 0x20404010, 0x00400000, 0x00004010, 0x20000010,
+ 0x00400000, 0x20004000, 0x20000000, 0x00004010, 0x20000010, 0x20404010, 0x00404000, 0x20400000,
+ 0x00404010, 0x20404000, 0x00000000, 0x20400010, 0x00000010, 0x00004000, 0x20400000, 0x00404010,
+ 0x00004000, 0x00400010, 0x20004010, 0x00000000, 0x20404000, 0x20000000, 0x00400010, 0x20004010
+};
+
+static u32 sbox7[64] =
+{
+ 0x00200000, 0x04200002, 0x04000802, 0x00000000, 0x00000800, 0x04000802, 0x00200802, 0x04200800,
+ 0x04200802, 0x00200000, 0x00000000, 0x04000002, 0x00000002, 0x04000000, 0x04200002, 0x00000802,
+ 0x04000800, 0x00200802, 0x00200002, 0x04000800, 0x04000002, 0x04200000, 0x04200800, 0x00200002,
+ 0x04200000, 0x00000800, 0x00000802, 0x04200802, 0x00200800, 0x00000002, 0x04000000, 0x00200800,
+ 0x04000000, 0x00200800, 0x00200000, 0x04000802, 0x04000802, 0x04200002, 0x04200002, 0x00000002,
+ 0x00200002, 0x04000000, 0x04000800, 0x00200000, 0x04200800, 0x00000802, 0x00200802, 0x04200800,
+ 0x00000802, 0x04000002, 0x04200802, 0x04200000, 0x00200800, 0x00000000, 0x00000002, 0x04200802,
+ 0x00000000, 0x00200802, 0x04200000, 0x00000800, 0x04000002, 0x04000800, 0x00000800, 0x00200002
+};
+
+static u32 sbox8[64] =
+{
+ 0x10001040, 0x00001000, 0x00040000, 0x10041040, 0x10000000, 0x10001040, 0x00000040, 0x10000000,
+ 0x00040040, 0x10040000, 0x10041040, 0x00041000, 0x10041000, 0x00041040, 0x00001000, 0x00000040,
+ 0x10040000, 0x10000040, 0x10001000, 0x00001040, 0x00041000, 0x00040040, 0x10040040, 0x10041000,
+ 0x00001040, 0x00000000, 0x00000000, 0x10040040, 0x10000040, 0x10001000, 0x00041040, 0x00040000,
+ 0x00041040, 0x00040000, 0x10041000, 0x00001000, 0x00000040, 0x10040040, 0x00001000, 0x00041040,
+ 0x10001000, 0x00000040, 0x10000040, 0x10040000, 0x10040040, 0x10000000, 0x00040000, 0x10001040,
+ 0x00000000, 0x10041040, 0x00040040, 0x10000040, 0x10040000, 0x10001000, 0x10001040, 0x00000000,
+ 0x10041040, 0x00041000, 0x00041000, 0x00001040, 0x00001040, 0x00040040, 0x10000000, 0x10041000
+};
+
+
+/*
+ * These two tables are part of the 'permuted choice 1' function.
+ * In this implementation several speed improvements are done.
+ */
+static u32 leftkey_swap[16] =
+{
+ 0x00000000, 0x00000001, 0x00000100, 0x00000101,
+ 0x00010000, 0x00010001, 0x00010100, 0x00010101,
+ 0x01000000, 0x01000001, 0x01000100, 0x01000101,
+ 0x01010000, 0x01010001, 0x01010100, 0x01010101
+};
+
+static u32 rightkey_swap[16] =
+{
+ 0x00000000, 0x01000000, 0x00010000, 0x01010000,
+ 0x00000100, 0x01000100, 0x00010100, 0x01010100,
+ 0x00000001, 0x01000001, 0x00010001, 0x01010001,
+ 0x00000101, 0x01000101, 0x00010101, 0x01010101,
+};
+
+
+
+/*
+ * Numbers of left shifts per round for encryption subkeys.
+ * To calculate the decryption subkeys we just reverse the
+ * ordering of the calculated encryption subkeys. So their
+ * is no need for a decryption rotate tab.
+ */
+static byte encrypt_rotate_tab[16] =
+{
+ 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
+};
+
+
+
+/*
+ * Table with weak DES keys sorted in ascending order.
+ * In DES their are 64 known keys which are weak. They are weak
+ * because they produce only one, two or four different
+ * subkeys in the subkey scheduling process.
+ * The keys in this table have all their parity bits cleared.
+ */
+static byte weak_keys[64][8] =
+{
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /*w*/
+ { 0x00, 0x00, 0x1e, 0x1e, 0x00, 0x00, 0x0e, 0x0e },
+ { 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0xf0 },
+ { 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, 0xfe, 0xfe },
+ { 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x0e }, /*sw*/
+ { 0x00, 0x1e, 0x1e, 0x00, 0x00, 0x0e, 0x0e, 0x00 },
+ { 0x00, 0x1e, 0xe0, 0xfe, 0x00, 0x0e, 0xf0, 0xfe },
+ { 0x00, 0x1e, 0xfe, 0xe0, 0x00, 0x0e, 0xfe, 0xf0 },
+ { 0x00, 0xe0, 0x00, 0xe0, 0x00, 0xf0, 0x00, 0xf0 }, /*sw*/
+ { 0x00, 0xe0, 0x1e, 0xfe, 0x00, 0xf0, 0x0e, 0xfe },
+ { 0x00, 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0xf0, 0x00 },
+ { 0x00, 0xe0, 0xfe, 0x1e, 0x00, 0xf0, 0xfe, 0x0e },
+ { 0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe }, /*sw*/
+ { 0x00, 0xfe, 0x1e, 0xe0, 0x00, 0xfe, 0x0e, 0xf0 },
+ { 0x00, 0xfe, 0xe0, 0x1e, 0x00, 0xfe, 0xf0, 0x0e },
+ { 0x00, 0xfe, 0xfe, 0x00, 0x00, 0xfe, 0xfe, 0x00 },
+ { 0x1e, 0x00, 0x00, 0x1e, 0x0e, 0x00, 0x00, 0x0e },
+ { 0x1e, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x0e, 0x00 }, /*sw*/
+ { 0x1e, 0x00, 0xe0, 0xfe, 0x0e, 0x00, 0xf0, 0xfe },
+ { 0x1e, 0x00, 0xfe, 0xe0, 0x0e, 0x00, 0xfe, 0xf0 },
+ { 0x1e, 0x1e, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00 },
+ { 0x1e, 0x1e, 0x1e, 0x1e, 0x0e, 0x0e, 0x0e, 0x0e }, /*w*/
+ { 0x1e, 0x1e, 0xe0, 0xe0, 0x0e, 0x0e, 0xf0, 0xf0 },
+ { 0x1e, 0x1e, 0xfe, 0xfe, 0x0e, 0x0e, 0xfe, 0xfe },
+ { 0x1e, 0xe0, 0x00, 0xfe, 0x0e, 0xf0, 0x00, 0xfe },
+ { 0x1e, 0xe0, 0x1e, 0xe0, 0x0e, 0xf0, 0x0e, 0xf0 }, /*sw*/
+ { 0x1e, 0xe0, 0xe0, 0x1e, 0x0e, 0xf0, 0xf0, 0x0e },
+ { 0x1e, 0xe0, 0xfe, 0x00, 0x0e, 0xf0, 0xfe, 0x00 },
+ { 0x1e, 0xfe, 0x00, 0xe0, 0x0e, 0xfe, 0x00, 0xf0 },
+ { 0x1e, 0xfe, 0x1e, 0xfe, 0x0e, 0xfe, 0x0e, 0xfe }, /*sw*/
+ { 0x1e, 0xfe, 0xe0, 0x00, 0x0e, 0xfe, 0xf0, 0x00 },
+ { 0x1e, 0xfe, 0xfe, 0x1e, 0x0e, 0xfe, 0xfe, 0x0e },
+ { 0xe0, 0x00, 0x00, 0xe0, 0xf0, 0x00, 0x00, 0xf0 },
+ { 0xe0, 0x00, 0x1e, 0xfe, 0xf0, 0x00, 0x0e, 0xfe },
+ { 0xe0, 0x00, 0xe0, 0x00, 0xf0, 0x00, 0xf0, 0x00 }, /*sw*/
+ { 0xe0, 0x00, 0xfe, 0x1e, 0xf0, 0x00, 0xfe, 0x0e },
+ { 0xe0, 0x1e, 0x00, 0xfe, 0xf0, 0x0e, 0x00, 0xfe },
+ { 0xe0, 0x1e, 0x1e, 0xe0, 0xf0, 0x0e, 0x0e, 0xf0 },
+ { 0xe0, 0x1e, 0xe0, 0x1e, 0xf0, 0x0e, 0xf0, 0x0e }, /*sw*/
+ { 0xe0, 0x1e, 0xfe, 0x00, 0xf0, 0x0e, 0xfe, 0x00 },
+ { 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00 },
+ { 0xe0, 0xe0, 0x1e, 0x1e, 0xf0, 0xf0, 0x0e, 0x0e },
+ { 0xe0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf0 }, /*w*/
+ { 0xe0, 0xe0, 0xfe, 0xfe, 0xf0, 0xf0, 0xfe, 0xfe },
+ { 0xe0, 0xfe, 0x00, 0x1e, 0xf0, 0xfe, 0x00, 0x0e },
+ { 0xe0, 0xfe, 0x1e, 0x00, 0xf0, 0xfe, 0x0e, 0x00 },
+ { 0xe0, 0xfe, 0xe0, 0xfe, 0xf0, 0xfe, 0xf0, 0xfe }, /*sw*/
+ { 0xe0, 0xfe, 0xfe, 0xe0, 0xf0, 0xfe, 0xfe, 0xf0 },
+ { 0xfe, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, 0xfe },
+ { 0xfe, 0x00, 0x1e, 0xe0, 0xfe, 0x00, 0x0e, 0xf0 },
+ { 0xfe, 0x00, 0xe0, 0x1e, 0xfe, 0x00, 0xf0, 0x0e },
+ { 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00 }, /*sw*/
+ { 0xfe, 0x1e, 0x00, 0xe0, 0xfe, 0x0e, 0x00, 0xf0 },
+ { 0xfe, 0x1e, 0x1e, 0xfe, 0xfe, 0x0e, 0x0e, 0xfe },
+ { 0xfe, 0x1e, 0xe0, 0x00, 0xfe, 0x0e, 0xf0, 0x00 },
+ { 0xfe, 0x1e, 0xfe, 0x1e, 0xfe, 0x0e, 0xfe, 0x0e }, /*sw*/
+ { 0xfe, 0xe0, 0x00, 0x1e, 0xfe, 0xf0, 0x00, 0x0e },
+ { 0xfe, 0xe0, 0x1e, 0x00, 0xfe, 0xf0, 0x0e, 0x00 },
+ { 0xfe, 0xe0, 0xe0, 0xfe, 0xfe, 0xf0, 0xf0, 0xfe },
+ { 0xfe, 0xe0, 0xfe, 0xe0, 0xfe, 0xf0, 0xfe, 0xf0 }, /*sw*/
+ { 0xfe, 0xfe, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00 },
+ { 0xfe, 0xfe, 0x1e, 0x1e, 0xfe, 0xfe, 0x0e, 0x0e },
+ { 0xfe, 0xfe, 0xe0, 0xe0, 0xfe, 0xfe, 0xf0, 0xf0 },
+ { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe } /*w*/
+};
+
+
+
+/*
+ * Macro to swap bits across two words.
+ */
+#define DO_PERMUTATION(a, temp, b, offset, mask) \
+ temp = ((a>>offset) ^ b) & mask; \
+ b ^= temp; \
+ a ^= temp<<offset;
+
+
+/*
+ * This performs the 'initial permutation' of the data to be encrypted
+ * or decrypted. Additionally the resulting two words are rotated one bit
+ * to the left.
+ */
+#define INITIAL_PERMUTATION(left, temp, right) \
+ DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f) \
+ DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \
+ DO_PERMUTATION(right, temp, left, 2, 0x33333333) \
+ DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \
+ right = (right << 1) | (right >> 31); \
+ temp = (left ^ right) & 0xaaaaaaaa; \
+ right ^= temp; \
+ left ^= temp; \
+ left = (left << 1) | (left >> 31);
+
+/*
+ * The 'inverse initial permutation'.
+ */
+#define FINAL_PERMUTATION(left, temp, right) \
+ left = (left << 31) | (left >> 1); \
+ temp = (left ^ right) & 0xaaaaaaaa; \
+ left ^= temp; \
+ right ^= temp; \
+ right = (right << 31) | (right >> 1); \
+ DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \
+ DO_PERMUTATION(right, temp, left, 2, 0x33333333) \
+ DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \
+ DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f)
+
+
+/*
+ * A full DES round including 'expansion function', 'sbox substitution'
+ * and 'primitive function P' but without swapping the left and right word.
+ * Please note: The data in 'from' and 'to' is already rotated one bit to
+ * the left, done in the initial permutation.
+ */
+#define DES_ROUND(from, to, work, subkey) \
+ work = from ^ *subkey++; \
+ to ^= sbox8[ work & 0x3f ]; \
+ to ^= sbox6[ (work>>8) & 0x3f ]; \
+ to ^= sbox4[ (work>>16) & 0x3f ]; \
+ to ^= sbox2[ (work>>24) & 0x3f ]; \
+ work = ((from << 28) | (from >> 4)) ^ *subkey++; \
+ to ^= sbox7[ work & 0x3f ]; \
+ to ^= sbox5[ (work>>8) & 0x3f ]; \
+ to ^= sbox3[ (work>>16) & 0x3f ]; \
+ to ^= sbox1[ (work>>24) & 0x3f ];
+
+/*
+ * Macros to convert 8 bytes from/to 32bit words.
+ */
+#define READ_64BIT_DATA(data, left, right) \
+ left = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; \
+ right = (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7];
+
+#define WRITE_64BIT_DATA(data, left, right) \
+ data[0] = (left >> 24) &0xff; data[1] = (left >> 16) &0xff; \
+ data[2] = (left >> 8) &0xff; data[3] = left &0xff; \
+ data[4] = (right >> 24) &0xff; data[5] = (right >> 16) &0xff; \
+ data[6] = (right >> 8) &0xff; data[7] = right &0xff;
+
+/*
+ * Handy macros for encryption and decryption of data
+ */
+#define des_ecb_encrypt(ctx, from, to) des_ecb_crypt(ctx, from, to, 0)
+#define des_ecb_decrypt(ctx, from, to) des_ecb_crypt(ctx, from, to, 1)
+#define tripledes_ecb_encrypt(ctx, from, to) tripledes_ecb_crypt(ctx,from,to,0)
+#define tripledes_ecb_decrypt(ctx, from, to) tripledes_ecb_crypt(ctx,from,to,1)
+
+
+
+
+
+
+/*
+ * des_key_schedule(): Calculate 16 subkeys pairs (even/odd) for
+ * 16 encryption rounds.
+ * To calculate subkeys for decryption the caller
+ * have to reorder the generated subkeys.
+ *
+ * rawkey: 8 Bytes of key data
+ * subkey: Array of at least 32 u32s. Will be filled
+ * with calculated subkeys.
+ *
+ */
+static void
+des_key_schedule (const byte * rawkey, u32 * subkey)
+{
+ u32 left, right, work;
+ int round;
+
+ READ_64BIT_DATA (rawkey, left, right)
+
+ DO_PERMUTATION (right, work, left, 4, 0x0f0f0f0f)
+ DO_PERMUTATION (right, work, left, 0, 0x10101010)
+
+ left = ((leftkey_swap[(left >> 0) & 0xf] << 3)
+ | (leftkey_swap[(left >> 8) & 0xf] << 2)
+ | (leftkey_swap[(left >> 16) & 0xf] << 1)
+ | (leftkey_swap[(left >> 24) & 0xf])
+ | (leftkey_swap[(left >> 5) & 0xf] << 7)
+ | (leftkey_swap[(left >> 13) & 0xf] << 6)
+ | (leftkey_swap[(left >> 21) & 0xf] << 5)
+ | (leftkey_swap[(left >> 29) & 0xf] << 4));
+
+ left &= 0x0fffffff;
+
+ right = ((rightkey_swap[(right >> 1) & 0xf] << 3)
+ | (rightkey_swap[(right >> 9) & 0xf] << 2)
+ | (rightkey_swap[(right >> 17) & 0xf] << 1)
+ | (rightkey_swap[(right >> 25) & 0xf])
+ | (rightkey_swap[(right >> 4) & 0xf] << 7)
+ | (rightkey_swap[(right >> 12) & 0xf] << 6)
+ | (rightkey_swap[(right >> 20) & 0xf] << 5)
+ | (rightkey_swap[(right >> 28) & 0xf] << 4));
+
+ right &= 0x0fffffff;
+
+ for (round = 0; round < 16; ++round)
+ {
+ left = ((left << encrypt_rotate_tab[round])
+ | (left >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff;
+ right = ((right << encrypt_rotate_tab[round])
+ | (right >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff;
+
+ *subkey++ = (((left << 4) & 0x24000000)
+ | ((left << 28) & 0x10000000)
+ | ((left << 14) & 0x08000000)
+ | ((left << 18) & 0x02080000)
+ | ((left << 6) & 0x01000000)
+ | ((left << 9) & 0x00200000)
+ | ((left >> 1) & 0x00100000)
+ | ((left << 10) & 0x00040000)
+ | ((left << 2) & 0x00020000)
+ | ((left >> 10) & 0x00010000)
+ | ((right >> 13) & 0x00002000)
+ | ((right >> 4) & 0x00001000)
+ | ((right << 6) & 0x00000800)
+ | ((right >> 1) & 0x00000400)
+ | ((right >> 14) & 0x00000200)
+ | (right & 0x00000100)
+ | ((right >> 5) & 0x00000020)
+ | ((right >> 10) & 0x00000010)
+ | ((right >> 3) & 0x00000008)
+ | ((right >> 18) & 0x00000004)
+ | ((right >> 26) & 0x00000002)
+ | ((right >> 24) & 0x00000001));
+
+ *subkey++ = (((left << 15) & 0x20000000)
+ | ((left << 17) & 0x10000000)
+ | ((left << 10) & 0x08000000)
+ | ((left << 22) & 0x04000000)
+ | ((left >> 2) & 0x02000000)
+ | ((left << 1) & 0x01000000)
+ | ((left << 16) & 0x00200000)
+ | ((left << 11) & 0x00100000)
+ | ((left << 3) & 0x00080000)
+ | ((left >> 6) & 0x00040000)
+ | ((left << 15) & 0x00020000)
+ | ((left >> 4) & 0x00010000)
+ | ((right >> 2) & 0x00002000)
+ | ((right << 8) & 0x00001000)
+ | ((right >> 14) & 0x00000808)
+ | ((right >> 9) & 0x00000400)
+ | ((right) & 0x00000200)
+ | ((right << 7) & 0x00000100)
+ | ((right >> 7) & 0x00000020)
+ | ((right >> 3) & 0x00000011)
+ | ((right << 2) & 0x00000004)
+ | ((right >> 21) & 0x00000002));
+ }
+}
+
+
+/*
+ * Fill a DES context with subkeys calculated from a 64bit key.
+ * Does not check parity bits, but simply ignore them.
+ * Does not check for weak keys.
+ */
+static int
+des_setkey (struct _des_ctx *ctx, const byte * key)
+{
+ static const char *selftest_failed;
+ int i;
+
+ if (!fips_mode () && !initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+
+ if (selftest_failed)
+ log_error ("%s\n", selftest_failed);
+ }
+ if (selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ des_key_schedule (key, ctx->encrypt_subkeys);
+ _gcry_burn_stack (32);
+
+ for(i=0; i<32; i+=2)
+ {
+ ctx->decrypt_subkeys[i] = ctx->encrypt_subkeys[30-i];
+ ctx->decrypt_subkeys[i+1] = ctx->encrypt_subkeys[31-i];
+ }
+
+ return 0;
+}
+
+
+
+/*
+ * Electronic Codebook Mode DES encryption/decryption of data according
+ * to 'mode'.
+ */
+static int
+des_ecb_crypt (struct _des_ctx *ctx, const byte * from, byte * to, int mode)
+{
+ u32 left, right, work;
+ u32 *keys;
+
+ keys = mode ? ctx->decrypt_subkeys : ctx->encrypt_subkeys;
+
+ READ_64BIT_DATA (from, left, right)
+ INITIAL_PERMUTATION (left, work, right)
+
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+
+ FINAL_PERMUTATION (right, work, left)
+ WRITE_64BIT_DATA (to, right, left)
+
+ return 0;
+}
+
+
+
+/*
+ * Fill a Triple-DES context with subkeys calculated from two 64bit keys.
+ * Does not check the parity bits of the keys, but simply ignore them.
+ * Does not check for weak keys.
+ */
+
+
+
+/*
+ * Fill a Triple-DES context with subkeys calculated from three 64bit keys.
+ * Does not check the parity bits of the keys, but simply ignore them.
+ * Does not check for weak keys.
+ */
+static int
+tripledes_set3keys (struct _tripledes_ctx *ctx,
+ const byte * key1,
+ const byte * key2,
+ const byte * key3)
+{
+ static const char *selftest_failed;
+ int i;
+
+ if (!fips_mode () && !initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+
+ if (selftest_failed)
+ log_error ("%s\n", selftest_failed);
+ }
+ if (selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ des_key_schedule (key1, ctx->encrypt_subkeys);
+ des_key_schedule (key2, &(ctx->decrypt_subkeys[32]));
+ des_key_schedule (key3, &(ctx->encrypt_subkeys[64]));
+ _gcry_burn_stack (32);
+
+ for(i=0; i<32; i+=2)
+ {
+ ctx->decrypt_subkeys[i] = ctx->encrypt_subkeys[94-i];
+ ctx->decrypt_subkeys[i+1] = ctx->encrypt_subkeys[95-i];
+
+ ctx->encrypt_subkeys[i+32] = ctx->decrypt_subkeys[62-i];
+ ctx->encrypt_subkeys[i+33] = ctx->decrypt_subkeys[63-i];
+
+ ctx->decrypt_subkeys[i+64] = ctx->encrypt_subkeys[30-i];
+ ctx->decrypt_subkeys[i+65] = ctx->encrypt_subkeys[31-i];
+ }
+
+ return 0;
+}
+
+
+
+/*
+ * Electronic Codebook Mode Triple-DES encryption/decryption of data
+ * according to 'mode'. Sometimes this mode is named 'EDE' mode
+ * (Encryption-Decryption-Encryption).
+ */
+static int
+tripledes_ecb_crypt (struct _tripledes_ctx *ctx, const byte * from,
+ byte * to, int mode)
+{
+ u32 left, right, work;
+ u32 *keys;
+
+ keys = mode ? ctx->decrypt_subkeys : ctx->encrypt_subkeys;
+
+ READ_64BIT_DATA (from, left, right)
+ INITIAL_PERMUTATION (left, work, right)
+
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+
+ FINAL_PERMUTATION (right, work, left)
+ WRITE_64BIT_DATA (to, right, left)
+
+ return 0;
+}
+
+
+
+
+
+/*
+ * Check whether the 8 byte key is weak.
+ * Does not check the parity bits of the key but simple ignore them.
+ */
+static int
+is_weak_key ( const byte *key )
+{
+ byte work[8];
+ int i, left, right, middle, cmp_result;
+
+ /* clear parity bits */
+ for(i=0; i<8; ++i)
+ work[i] = key[i] & 0xfe;
+
+ /* binary search in the weak key table */
+ left = 0;
+ right = 63;
+ while(left <= right)
+ {
+ middle = (left + right) / 2;
+
+ if ( !(cmp_result=working_memcmp(work, weak_keys[middle], 8)) )
+ return -1;
+
+ if ( cmp_result > 0 )
+ left = middle + 1;
+ else
+ right = middle - 1;
+ }
+
+ return 0;
+}
+
+
+
+/*
+ * Performs a selftest of this DES/Triple-DES implementation.
+ * Returns an string with the error text on failure.
+ * Returns NULL if all is ok.
+ */
+
+
+static gcry_err_code_t
+do_tripledes_setkey ( void *context, const byte *key, unsigned keylen )
+{
+ struct _tripledes_ctx *ctx = (struct _tripledes_ctx *) context;
+
+ if( keylen != 24 )
+ return GPG_ERR_INV_KEYLEN;
+
+ tripledes_set3keys ( ctx, key, key+8, key+16);
+
+ if (ctx->flags.no_weak_key)
+ ; /* Detection has been disabled. */
+ else if (is_weak_key (key) || is_weak_key (key+8) || is_weak_key (key+16))
+ {
+ _gcry_burn_stack (64);
+ return GPG_ERR_WEAK_KEY;
+ }
+ _gcry_burn_stack (64);
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+
+
+static void
+do_tripledes_encrypt( void *context, byte *outbuf, const byte *inbuf )
+{
+ struct _tripledes_ctx *ctx = (struct _tripledes_ctx *) context;
+
+ tripledes_ecb_encrypt ( ctx, inbuf, outbuf );
+ _gcry_burn_stack (32);
+}
+
+static void
+do_tripledes_decrypt( void *context, byte *outbuf, const byte *inbuf )
+{
+ struct _tripledes_ctx *ctx = (struct _tripledes_ctx *) context;
+ tripledes_ecb_decrypt ( ctx, inbuf, outbuf );
+ _gcry_burn_stack (32);
+}
+
+static gcry_err_code_t
+do_des_setkey (void *context, const byte *key, unsigned keylen)
+{
+ struct _des_ctx *ctx = (struct _des_ctx *) context;
+
+ if (keylen != 8)
+ return GPG_ERR_INV_KEYLEN;
+
+ des_setkey (ctx, key);
+
+ if (is_weak_key (key)) {
+ _gcry_burn_stack (64);
+ return GPG_ERR_WEAK_KEY;
+ }
+ _gcry_burn_stack (64);
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+static void
+do_des_encrypt( void *context, byte *outbuf, const byte *inbuf )
+{
+ struct _des_ctx *ctx = (struct _des_ctx *) context;
+
+ des_ecb_encrypt ( ctx, inbuf, outbuf );
+ _gcry_burn_stack (32);
+}
+
+static void
+do_des_decrypt( void *context, byte *outbuf, const byte *inbuf )
+{
+ struct _des_ctx *ctx = (struct _des_ctx *) context;
+
+ des_ecb_decrypt ( ctx, inbuf, outbuf );
+ _gcry_burn_stack (32);
+}
+
+
+
+
+/*
+ Self-test section.
+ */
+
+
+/* Selftest for TripleDES. */
+
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_des =
+ {
+ "DES", NULL, NULL, 8, 64, sizeof (struct _des_ctx),
+ do_des_setkey, do_des_encrypt, do_des_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_des",
+#endif
+ };
+
+static gcry_cipher_oid_spec_t oids_tripledes[] =
+ {
+ { "1.2.840.113549.3.7", GCRY_CIPHER_MODE_CBC },
+ /* Teletrust specific OID for 3DES. */
+ { "1.3.36.3.1.3.2.1", GCRY_CIPHER_MODE_CBC },
+ /* pbeWithSHAAnd3_KeyTripleDES_CBC */
+ { "1.2.840.113549.1.12.1.3", GCRY_CIPHER_MODE_CBC },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_tripledes =
+ {
+ "3DES", NULL, oids_tripledes, 8, 192, sizeof (struct _tripledes_ctx),
+ do_tripledes_setkey, do_tripledes_encrypt, do_tripledes_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_des",
+#endif
+ };
+
+
+
+GRUB_MOD_INIT(gcry_des)
+{
+ grub_cipher_register (&_gcry_cipher_spec_des);
+ grub_cipher_register (&_gcry_cipher_spec_tripledes);
+}
+
+GRUB_MOD_FINI(gcry_des)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_des);
+ grub_cipher_unregister (&_gcry_cipher_spec_tripledes);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/dsa.c b/grub-core/lib/libgcrypt-grub/cipher/dsa.c
new file mode 100644
index 0000000..52079c5
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/dsa.c
@@ -0,0 +1,292 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* dsa.c - DSA signature algorithm
+ * Copyright (C) 1998, 2000, 2001, 2002, 2003,
+ * 2006, 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "g10lib.h"
+#include "mpi.h"
+#include "cipher.h"
+
+typedef struct
+{
+ gcry_mpi_t p; /* prime */
+ gcry_mpi_t q; /* group order */
+ gcry_mpi_t g; /* group generator */
+ gcry_mpi_t y; /* g^x mod p */
+} DSA_public_key;
+
+
+typedef struct
+{
+ gcry_mpi_t p; /* prime */
+ gcry_mpi_t q; /* group order */
+ gcry_mpi_t g; /* group generator */
+ gcry_mpi_t y; /* g^x mod p */
+ gcry_mpi_t x; /* secret exponent */
+} DSA_secret_key;
+
+
+/* A structure used to hold domain parameters. */
+typedef struct
+{
+ gcry_mpi_t p; /* prime */
+ gcry_mpi_t q; /* group order */
+ gcry_mpi_t g; /* group generator */
+} dsa_domain_t;
+
+
+/* A sample 1024 bit DSA key used for the selftests. */
+/* A sample 1024 bit DSA key used for the selftests (public only). */
+
+
+
+
+static int check_secret_key (DSA_secret_key *sk);
+static int verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input,
+ DSA_public_key *pkey);
+
+
+
+
+
+
+
+/*
+ * Generate a random secret exponent k less than q.
+ */
+
+
+/* Check that a freshly generated key actually works. Returns 0 on success. */
+
+
+
+/*
+ Generate a DSA key pair with a key of size NBITS. If transient_key
+ is true the key is generated using the standard RNG and not the
+ very secure one.
+
+ Returns: 2 structures filled with all needed values
+ and an array with the n-1 factors of (p-1)
+ */
+
+
+/* Generate a DSA key pair with a key of size NBITS using the
+ algorithm given in FIPS-186-3. If USE_FIPS186_2 is true,
+ FIPS-186-2 is used and thus the length is restricted to 1024/160.
+ If DERIVEPARMS is not NULL it may contain a seed value. If domain
+ parameters are specified in DOMAIN, DERIVEPARMS may not be given
+ and NBITS and QBITS must match the specified domain parameters. */
+
+
+
+/*
+ Test whether the secret key is valid.
+ Returns: if this is a valid key.
+ */
+static int
+check_secret_key( DSA_secret_key *sk )
+{
+ int rc;
+ gcry_mpi_t y = mpi_alloc( mpi_get_nlimbs(sk->y) );
+
+ gcry_mpi_powm( y, sk->g, sk->x, sk->p );
+ rc = !mpi_cmp( y, sk->y );
+ mpi_free( y );
+ return rc;
+}
+
+
+
+/*
+ Make a DSA signature from HASH and put it into r and s.
+ */
+
+
+/*
+ Returns true if the signature composed from R and S is valid.
+ */
+static int
+verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t hash, DSA_public_key *pkey )
+{
+ int rc;
+ gcry_mpi_t w, u1, u2, v;
+ gcry_mpi_t base[3];
+ gcry_mpi_t ex[3];
+
+ if( !(mpi_cmp_ui( r, 0 ) > 0 && mpi_cmp( r, pkey->q ) < 0) )
+ return 0; /* assertion 0 < r < q failed */
+ if( !(mpi_cmp_ui( s, 0 ) > 0 && mpi_cmp( s, pkey->q ) < 0) )
+ return 0; /* assertion 0 < s < q failed */
+
+ w = mpi_alloc( mpi_get_nlimbs(pkey->q) );
+ u1 = mpi_alloc( mpi_get_nlimbs(pkey->q) );
+ u2 = mpi_alloc( mpi_get_nlimbs(pkey->q) );
+ v = mpi_alloc( mpi_get_nlimbs(pkey->p) );
+
+ /* w = s^(-1) mod q */
+ mpi_invm( w, s, pkey->q );
+
+ /* u1 = (hash * w) mod q */
+ mpi_mulm( u1, hash, w, pkey->q );
+
+ /* u2 = r * w mod q */
+ mpi_mulm( u2, r, w, pkey->q );
+
+ /* v = g^u1 * y^u2 mod p mod q */
+ base[0] = pkey->g; ex[0] = u1;
+ base[1] = pkey->y; ex[1] = u2;
+ base[2] = NULL; ex[2] = NULL;
+ mpi_mulpowm( v, base, ex, pkey->p );
+ mpi_fdiv_r( v, v, pkey->q );
+
+ rc = !mpi_cmp( v, r );
+
+ mpi_free(w);
+ mpi_free(u1);
+ mpi_free(u2);
+ mpi_free(v);
+
+ return rc;
+}
+
+
+/*********************************************
+ ************** interface ******************
+ *********************************************/
+
+#define dsa_generate 0
+
+#define dsa_generate 0
+
+
+static gcry_err_code_t
+dsa_check_secret_key (int algo, gcry_mpi_t *skey)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ DSA_secret_key sk;
+
+ (void)algo;
+
+ if ((! skey[0]) || (! skey[1]) || (! skey[2]) || (! skey[3]) || (! skey[4]))
+ err = GPG_ERR_BAD_MPI;
+ else
+ {
+ sk.p = skey[0];
+ sk.q = skey[1];
+ sk.g = skey[2];
+ sk.y = skey[3];
+ sk.x = skey[4];
+ if (! check_secret_key (&sk))
+ err = GPG_ERR_BAD_SECKEY;
+ }
+
+ return err;
+}
+
+
+#define dsa_sign 0
+static gcry_err_code_t
+dsa_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey,
+ int (*cmp) (void *, gcry_mpi_t), void *opaquev)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ DSA_public_key pk;
+
+ (void)algo;
+ (void)cmp;
+ (void)opaquev;
+
+ if ((! data[0]) || (! data[1]) || (! hash)
+ || (! pkey[0]) || (! pkey[1]) || (! pkey[2]) || (! pkey[3]))
+ err = GPG_ERR_BAD_MPI;
+ else
+ {
+ pk.p = pkey[0];
+ pk.q = pkey[1];
+ pk.g = pkey[2];
+ pk.y = pkey[3];
+ if (! verify (data[0], data[1], hash, &pk))
+ err = GPG_ERR_BAD_SIGNATURE;
+ }
+ return err;
+}
+
+
+static unsigned int
+dsa_get_nbits (int algo, gcry_mpi_t *pkey)
+{
+ (void)algo;
+
+ return mpi_get_nbits (pkey[0]);
+}
+
+
+
+/*
+ Self-test section.
+ */
+
+
+
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+
+
+
+
+static const char *dsa_names[] =
+ {
+ "dsa",
+ "openpgp-dsa",
+ NULL,
+ };
+
+gcry_pk_spec_t _gcry_pubkey_spec_dsa =
+ {
+ "DSA", dsa_names,
+ "pqgy", "pqgyx", "", "rs", "pqgy",
+ GCRY_PK_USAGE_SIGN,
+ dsa_generate,
+ dsa_check_secret_key,
+ NULL,
+ NULL,
+ dsa_sign,
+ dsa_verify,
+ dsa_get_nbits
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_dsa",
+#endif
+ };
+
+
+GRUB_MOD_INIT(gcry_dsa)
+{
+ grub_crypto_pk_dsa = &_gcry_pubkey_spec_dsa;
+}
+
+GRUB_MOD_FINI(gcry_dsa)
+{
+ grub_crypto_pk_dsa = 0;
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/g10lib.h b/grub-core/lib/libgcrypt-grub/cipher/g10lib.h
new file mode 100644
index 0000000..49cc16a
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/g10lib.h
@@ -0,0 +1 @@
+#include <cipher_wrap.h>
diff --git a/grub-core/lib/libgcrypt-grub/cipher/hash-common.h b/grub-core/lib/libgcrypt-grub/cipher/hash-common.h
new file mode 100644
index 0000000..79d3675
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/hash-common.h
@@ -0,0 +1,36 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+/* hash-common.h - Declarations of common code for hash algorithms.
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GCRY_HASH_COMMON_H
+#define GCRY_HASH_COMMON_H
+
+
+const char * _gcry_hash_selftest_check_one
+/**/ (int algo,
+ int datamode, const void *data, size_t datalen,
+ const void *expect, size_t expectlen);
+
+
+
+
+
+#endif /*GCRY_HASH_COMMON_H*/
diff --git a/grub-core/lib/libgcrypt-grub/cipher/idea.c b/grub-core/lib/libgcrypt-grub/cipher/idea.c
new file mode 100644
index 0000000..52a818f
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/idea.c
@@ -0,0 +1,322 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* idea.c - IDEA function
+ * Copyright 1997, 1998, 1999, 2001 Werner Koch (dd9jn)
+ * Copyright 2013 g10 Code GmbH
+ *
+ * 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
+ * WERNER KOCH 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.
+ *
+ * Except as contained in this notice, the name of Werner Koch shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Werner Koch.
+ *
+ * Patents on IDEA have expired:
+ * Europe: EP0482154 on 2011-05-16,
+ * Japan: JP3225440 on 2011-05-16,
+ * U.S.: 5,214,703 on 2012-01-07.
+ */
+
+/*
+ * Please see http://www.noepatents.org/ to learn why software patents
+ * are bad for society and what you can do to fight them.
+ *
+ * The code herein is based on the one from:
+ * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996.
+ * ISBN 0-471-11709-9.
+ */
+
+
+
+#include "types.h" /* for byte and u32 typedefs */
+#include "g10lib.h"
+#include "cipher.h"
+
+
+#define IDEA_KEYSIZE 16
+#define IDEA_BLOCKSIZE 8
+#define IDEA_ROUNDS 8
+#define IDEA_KEYLEN (6*IDEA_ROUNDS+4)
+
+typedef struct {
+ u16 ek[IDEA_KEYLEN];
+ u16 dk[IDEA_KEYLEN];
+ int have_dk;
+} IDEA_context;
+
+
+
+static u16
+mul_inv( u16 x )
+{
+ u16 t0, t1;
+ u16 q, y;
+
+ if( x < 2 )
+ return x;
+ t1 = 0x10001UL / x;
+ y = 0x10001UL % x;
+ if( y == 1 )
+ return (1-t1) & 0xffff;
+
+ t0 = 1;
+ do {
+ q = x / y;
+ x = x % y;
+ t0 += q * t1;
+ if( x == 1 )
+ return t0;
+ q = y / x;
+ y = y % x;
+ t1 += q * t0;
+ } while( y != 1 );
+ return (1-t1) & 0xffff;
+}
+
+
+
+static void
+expand_key( const byte *userkey, u16 *ek )
+{
+ int i,j;
+
+ for(j=0; j < 8; j++ ) {
+ ek[j] = (*userkey << 8) + userkey[1];
+ userkey += 2;
+ }
+ for(i=0; j < IDEA_KEYLEN; j++ ) {
+ i++;
+ ek[i+7] = ek[i&7] << 9 | ek[(i+1)&7] >> 7;
+ ek += i & 8;
+ i &= 7;
+ }
+}
+
+
+static void
+invert_key( u16 *ek, u16 dk[IDEA_KEYLEN] )
+{
+ int i;
+ u16 t1, t2, t3;
+ u16 temp[IDEA_KEYLEN];
+ u16 *p = temp + IDEA_KEYLEN;
+
+ t1 = mul_inv( *ek++ );
+ t2 = -*ek++;
+ t3 = -*ek++;
+ *--p = mul_inv( *ek++ );
+ *--p = t3;
+ *--p = t2;
+ *--p = t1;
+
+ for(i=0; i < IDEA_ROUNDS-1; i++ ) {
+ t1 = *ek++;
+ *--p = *ek++;
+ *--p = t1;
+
+ t1 = mul_inv( *ek++ );
+ t2 = -*ek++;
+ t3 = -*ek++;
+ *--p = mul_inv( *ek++ );
+ *--p = t2;
+ *--p = t3;
+ *--p = t1;
+ }
+ t1 = *ek++;
+ *--p = *ek++;
+ *--p = t1;
+
+ t1 = mul_inv( *ek++ );
+ t2 = -*ek++;
+ t3 = -*ek++;
+ *--p = mul_inv( *ek++ );
+ *--p = t3;
+ *--p = t2;
+ *--p = t1;
+ memcpy(dk, temp, sizeof(temp) );
+ memset(temp, 0, sizeof(temp) ); /* burn temp */
+}
+
+
+static void
+cipher( byte *outbuf, const byte *inbuf, u16 *key )
+{
+ u16 s2, s3;
+ u16 in[4];
+ int r = IDEA_ROUNDS;
+#define x1 (in[0])
+#define x2 (in[1])
+#define x3 (in[2])
+#define x4 (in[3])
+#define MUL(x,y) \
+ do {u16 _t16; u32 _t32; \
+ if( (_t16 = (y)) ) { \
+ if( (x = (x)&0xffff) ) { \
+ _t32 = (u32)x * _t16; \
+ x = _t32 & 0xffff; \
+ _t16 = _t32 >> 16; \
+ x = ((x)-_t16) + (x<_t16?1:0); \
+ } \
+ else { \
+ x = 1 - _t16; \
+ } \
+ } \
+ else { \
+ x = 1 - x; \
+ } \
+ } while(0)
+
+ memcpy (in, inbuf, sizeof in);
+#ifndef WORDS_BIGENDIAN
+ x1 = (x1>>8) | (x1<<8);
+ x2 = (x2>>8) | (x2<<8);
+ x3 = (x3>>8) | (x3<<8);
+ x4 = (x4>>8) | (x4<<8);
+#endif
+ do {
+ MUL(x1, *key++);
+ x2 += *key++;
+ x3 += *key++;
+ MUL(x4, *key++ );
+
+ s3 = x3;
+ x3 ^= x1;
+ MUL(x3, *key++);
+ s2 = x2;
+ x2 ^=x4;
+ x2 += x3;
+ MUL(x2, *key++);
+ x3 += x2;
+
+ x1 ^= x2;
+ x4 ^= x3;
+
+ x2 ^= s3;
+ x3 ^= s2;
+ } while( --r );
+ MUL(x1, *key++);
+ x3 += *key++;
+ x2 += *key++;
+ MUL(x4, *key);
+
+#ifndef WORDS_BIGENDIAN
+ x1 = (x1>>8) | (x1<<8);
+ x2 = (x2>>8) | (x2<<8);
+ x3 = (x3>>8) | (x3<<8);
+ x4 = (x4>>8) | (x4<<8);
+#endif
+ memcpy (outbuf+0, &x1, 2);
+ memcpy (outbuf+2, &x3, 2);
+ memcpy (outbuf+4, &x2, 2);
+ memcpy (outbuf+6, &x4, 2);
+#undef MUL
+#undef x1
+#undef x2
+#undef x3
+#undef x4
+}
+
+
+static int
+do_setkey( IDEA_context *c, const byte *key, unsigned int keylen )
+{
+ static int initialized = 0;
+ static const char *selftest_failed = 0;
+
+ if( !initialized ) {
+ initialized = 1;
+ selftest_failed = selftest();
+ if( selftest_failed )
+ log_error( "%s\n", selftest_failed );
+ }
+ if( selftest_failed )
+ return GPG_ERR_SELFTEST_FAILED;
+
+ assert(keylen == 16);
+ c->have_dk = 0;
+ expand_key( key, c->ek );
+ invert_key( c->ek, c->dk );
+ return 0;
+}
+
+static gcry_err_code_t
+idea_setkey (void *context, const byte *key, unsigned int keylen)
+{
+ IDEA_context *ctx = context;
+ int rc = do_setkey (ctx, key, keylen);
+ _gcry_burn_stack (23+6*sizeof(void*));
+ return rc;
+}
+
+static void
+encrypt_block( IDEA_context *c, byte *outbuf, const byte *inbuf )
+{
+ cipher( outbuf, inbuf, c->ek );
+}
+
+static void
+idea_encrypt (void *context, byte *out, const byte *in)
+{
+ IDEA_context *ctx = context;
+ encrypt_block (ctx, out, in);
+ _gcry_burn_stack (24+3*sizeof (void*));
+}
+
+static void
+decrypt_block( IDEA_context *c, byte *outbuf, const byte *inbuf )
+{
+ if( !c->have_dk ) {
+ c->have_dk = 1;
+ invert_key( c->ek, c->dk );
+ }
+ cipher( outbuf, inbuf, c->dk );
+}
+
+static void
+idea_decrypt (void *context, byte *out, const byte *in)
+{
+ IDEA_context *ctx = context;
+ decrypt_block (ctx, out, in);
+ _gcry_burn_stack (24+3*sizeof (void*));
+}
+
+
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_idea =
+{
+ "IDEA", NULL, NULL, IDEA_BLOCKSIZE, 128,
+ sizeof (IDEA_context),
+ idea_setkey, idea_encrypt, idea_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_idea",
+#endif
+};
+
+
+GRUB_MOD_INIT(gcry_idea)
+{
+ grub_cipher_register (&_gcry_cipher_spec_idea);
+}
+
+GRUB_MOD_FINI(gcry_idea)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_idea);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/init.c b/grub-core/lib/libgcrypt-grub/cipher/init.c
new file mode 100644
index 0000000..a02fe0f
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/init.c
@@ -0,0 +1,91 @@
+#include <grub/crypto.h>
+extern void grub_gcry_arcfour_init (void);
+extern void grub_gcry_arcfour_fini (void);
+extern void grub_gcry_blowfish_init (void);
+extern void grub_gcry_blowfish_fini (void);
+extern void grub_gcry_camellia_init (void);
+extern void grub_gcry_camellia_fini (void);
+extern void grub_gcry_cast5_init (void);
+extern void grub_gcry_cast5_fini (void);
+extern void grub_gcry_crc_init (void);
+extern void grub_gcry_crc_fini (void);
+extern void grub_gcry_des_init (void);
+extern void grub_gcry_des_fini (void);
+extern void grub_gcry_idea_init (void);
+extern void grub_gcry_idea_fini (void);
+extern void grub_gcry_md4_init (void);
+extern void grub_gcry_md4_fini (void);
+extern void grub_gcry_md5_init (void);
+extern void grub_gcry_md5_fini (void);
+extern void grub_gcry_rfc2268_init (void);
+extern void grub_gcry_rfc2268_fini (void);
+extern void grub_gcry_rijndael_init (void);
+extern void grub_gcry_rijndael_fini (void);
+extern void grub_gcry_rmd160_init (void);
+extern void grub_gcry_rmd160_fini (void);
+extern void grub_gcry_seed_init (void);
+extern void grub_gcry_seed_fini (void);
+extern void grub_gcry_serpent_init (void);
+extern void grub_gcry_serpent_fini (void);
+extern void grub_gcry_sha1_init (void);
+extern void grub_gcry_sha1_fini (void);
+extern void grub_gcry_sha256_init (void);
+extern void grub_gcry_sha256_fini (void);
+extern void grub_gcry_sha512_init (void);
+extern void grub_gcry_sha512_fini (void);
+extern void grub_gcry_tiger_init (void);
+extern void grub_gcry_tiger_fini (void);
+extern void grub_gcry_twofish_init (void);
+extern void grub_gcry_twofish_fini (void);
+extern void grub_gcry_whirlpool_init (void);
+extern void grub_gcry_whirlpool_fini (void);
+
+void
+grub_gcry_init_all (void)
+{
+ grub_gcry_arcfour_init ();
+ grub_gcry_blowfish_init ();
+ grub_gcry_camellia_init ();
+ grub_gcry_cast5_init ();
+ grub_gcry_crc_init ();
+ grub_gcry_des_init ();
+ grub_gcry_idea_init ();
+ grub_gcry_md4_init ();
+ grub_gcry_md5_init ();
+ grub_gcry_rfc2268_init ();
+ grub_gcry_rijndael_init ();
+ grub_gcry_rmd160_init ();
+ grub_gcry_seed_init ();
+ grub_gcry_serpent_init ();
+ grub_gcry_sha1_init ();
+ grub_gcry_sha256_init ();
+ grub_gcry_sha512_init ();
+ grub_gcry_tiger_init ();
+ grub_gcry_twofish_init ();
+ grub_gcry_whirlpool_init ();
+}
+
+void
+grub_gcry_fini_all (void)
+{
+ grub_gcry_arcfour_fini ();
+ grub_gcry_blowfish_fini ();
+ grub_gcry_camellia_fini ();
+ grub_gcry_cast5_fini ();
+ grub_gcry_crc_fini ();
+ grub_gcry_des_fini ();
+ grub_gcry_idea_fini ();
+ grub_gcry_md4_fini ();
+ grub_gcry_md5_fini ();
+ grub_gcry_rfc2268_fini ();
+ grub_gcry_rijndael_fini ();
+ grub_gcry_rmd160_fini ();
+ grub_gcry_seed_fini ();
+ grub_gcry_serpent_fini ();
+ grub_gcry_sha1_fini ();
+ grub_gcry_sha256_fini ();
+ grub_gcry_sha512_fini ();
+ grub_gcry_tiger_fini ();
+ grub_gcry_twofish_fini ();
+ grub_gcry_whirlpool_fini ();
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/md4.c b/grub-core/lib/libgcrypt-grub/cipher/md4.c
new file mode 100644
index 0000000..deb291a
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/md4.c
@@ -0,0 +1,344 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* md4.c - MD4 Message-Digest Algorithm
+ * Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Based on md5.c in libgcrypt, but rewritten to compute md4 checksums
+ * using a public domain md4 implementation with the following comments:
+ *
+ * Modified by Wei Dai from Andrew M. Kuchling's md4.c
+ * The original code and all modifications are in the public domain.
+ *
+ * This is the original introductory comment:
+ *
+ * md4.c : MD4 hash algorithm.
+ *
+ * Part of the Python Cryptography Toolkit, version 1.1
+ *
+ * Distribute and use freely; there are no restrictions on further
+ * dissemination and usage except those imposed by the laws of your
+ * country of residence.
+ *
+ */
+
+/* MD4 test suite:
+ * MD4 ("") = 31d6cfe0d16ae931b73c59d7e0c089c0
+ * MD4 ("a") = bde52cb31de33e46245e05fbdbd6fb24
+ * MD4 ("abc") = a448017aaf21d8525fc10ae87aa6729d
+ * MD4 ("message digest") = d9130a8164549fe818874806e1c7014b
+ * MD4 ("abcdefghijklmnopqrstuvwxyz") = d79e1c308aa5bbcdeea8ed63df412da9
+ * MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
+ * 043f8582f241db351ce627e153e7f0e4
+ * MD4 ("123456789012345678901234567890123456789012345678901234567890123456
+ * 78901234567890") = e33b4ddc9c38f2199c3e7b164fcc0536
+ */
+
+
+#include "g10lib.h"
+#include "cipher.h"
+
+#include "bithelp.h"
+
+
+typedef struct {
+ u32 A,B,C,D; /* chaining variables */
+ u32 nblocks;
+ byte buf[64];
+ int count;
+} MD4_CONTEXT;
+
+
+static void
+md4_init( void *context )
+{
+ MD4_CONTEXT *ctx = context;
+
+ ctx->A = 0x67452301;
+ ctx->B = 0xefcdab89;
+ ctx->C = 0x98badcfe;
+ ctx->D = 0x10325476;
+
+ ctx->nblocks = 0;
+ ctx->count = 0;
+}
+
+#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
+#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+
+
+/****************
+ * transform 64 bytes
+ */
+static void
+transform ( MD4_CONTEXT *ctx, const unsigned char *data )
+{
+ u32 in[16];
+ register u32 A = ctx->A;
+ register u32 B = ctx->B;
+ register u32 C = ctx->C;
+ register u32 D = ctx->D;
+
+#ifdef WORDS_BIGENDIAN
+ {
+ int i;
+ byte *p2;
+ const byte *p1;
+ for(i=0, p1=data, p2=(byte*)in; i < 16; i++, p2 += 4 )
+ {
+ p2[3] = *p1++;
+ p2[2] = *p1++;
+ p2[1] = *p1++;
+ p2[0] = *p1++;
+ }
+ }
+#else
+ memcpy (in, data, 64);
+#endif
+
+ /* Round 1. */
+#define function(a,b,c,d,k,s) a=rol(a+F(b,c,d)+in[k],s);
+ function(A,B,C,D, 0, 3);
+ function(D,A,B,C, 1, 7);
+ function(C,D,A,B, 2,11);
+ function(B,C,D,A, 3,19);
+ function(A,B,C,D, 4, 3);
+ function(D,A,B,C, 5, 7);
+ function(C,D,A,B, 6,11);
+ function(B,C,D,A, 7,19);
+ function(A,B,C,D, 8, 3);
+ function(D,A,B,C, 9, 7);
+ function(C,D,A,B,10,11);
+ function(B,C,D,A,11,19);
+ function(A,B,C,D,12, 3);
+ function(D,A,B,C,13, 7);
+ function(C,D,A,B,14,11);
+ function(B,C,D,A,15,19);
+
+#undef function
+
+ /* Round 2. */
+#define function(a,b,c,d,k,s) a=rol(a+G(b,c,d)+in[k]+0x5a827999,s);
+
+ function(A,B,C,D, 0, 3);
+ function(D,A,B,C, 4, 5);
+ function(C,D,A,B, 8, 9);
+ function(B,C,D,A,12,13);
+ function(A,B,C,D, 1, 3);
+ function(D,A,B,C, 5, 5);
+ function(C,D,A,B, 9, 9);
+ function(B,C,D,A,13,13);
+ function(A,B,C,D, 2, 3);
+ function(D,A,B,C, 6, 5);
+ function(C,D,A,B,10, 9);
+ function(B,C,D,A,14,13);
+ function(A,B,C,D, 3, 3);
+ function(D,A,B,C, 7, 5);
+ function(C,D,A,B,11, 9);
+ function(B,C,D,A,15,13);
+
+#undef function
+
+ /* Round 3. */
+#define function(a,b,c,d,k,s) a=rol(a+H(b,c,d)+in[k]+0x6ed9eba1,s);
+
+ function(A,B,C,D, 0, 3);
+ function(D,A,B,C, 8, 9);
+ function(C,D,A,B, 4,11);
+ function(B,C,D,A,12,15);
+ function(A,B,C,D, 2, 3);
+ function(D,A,B,C,10, 9);
+ function(C,D,A,B, 6,11);
+ function(B,C,D,A,14,15);
+ function(A,B,C,D, 1, 3);
+ function(D,A,B,C, 9, 9);
+ function(C,D,A,B, 5,11);
+ function(B,C,D,A,13,15);
+ function(A,B,C,D, 3, 3);
+ function(D,A,B,C,11, 9);
+ function(C,D,A,B, 7,11);
+ function(B,C,D,A,15,15);
+
+
+ /* Put checksum in context given as argument. */
+ ctx->A += A;
+ ctx->B += B;
+ ctx->C += C;
+ ctx->D += D;
+}
+
+
+
+/* The routine updates the message-digest context to
+ * account for the presence of each of the characters inBuf[0..inLen-1]
+ * in the message whose digest is being computed.
+ */
+static void
+md4_write ( void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ MD4_CONTEXT *hd = context;
+
+ if( hd->count == 64 ) /* flush the buffer */
+ {
+ transform( hd, hd->buf );
+ _gcry_burn_stack (80+6*sizeof(void*));
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if( !inbuf )
+ return;
+
+ if( hd->count )
+ {
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+ md4_write( hd, NULL, 0 );
+ if( !inlen )
+ return;
+ }
+ _gcry_burn_stack (80+6*sizeof(void*));
+
+ while( inlen >= 64 )
+ {
+ transform( hd, inbuf );
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 64;
+ inbuf += 64;
+ }
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+
+/* The routine final terminates the message-digest computation and
+ * ends with the desired message digest in mdContext->digest[0...15].
+ * The handle is prepared for a new MD4 cycle.
+ * Returns 16 bytes representing the digest.
+ */
+
+static void
+md4_final( void *context )
+{
+ MD4_CONTEXT *hd = context;
+ u32 t, msb, lsb;
+ byte *p;
+
+ md4_write(hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if( (lsb += hd->count) < t )
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if( hd->count < 56 ) /* enough room */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while( hd->count < 56 )
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else /* need one extra block */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while( hd->count < 64 )
+ hd->buf[hd->count++] = 0;
+ md4_write(hd, NULL, 0); /* flush */;
+ memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = lsb ;
+ hd->buf[57] = lsb >> 8;
+ hd->buf[58] = lsb >> 16;
+ hd->buf[59] = lsb >> 24;
+ hd->buf[60] = msb ;
+ hd->buf[61] = msb >> 8;
+ hd->buf[62] = msb >> 16;
+ hd->buf[63] = msb >> 24;
+ transform( hd, hd->buf );
+ _gcry_burn_stack (80+6*sizeof(void*));
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *p++ = hd->a ; *p++ = hd->a >> 8; \
+ *p++ = hd->a >> 16; *p++ = hd->a >> 24; } while(0)
+#else /* little endian */
+#define X(a) do { *(u32*)p = (*hd).a ; p += 4; } while(0)
+#endif
+ X(A);
+ X(B);
+ X(C);
+ X(D);
+#undef X
+
+}
+
+static byte *
+md4_read (void *context)
+{
+ MD4_CONTEXT *hd = context;
+ return hd->buf;
+}
+
+static byte asn[18] = /* Object ID is 1.2.840.113549.2.4 */
+ { 0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86,0x48,
+ 0x86, 0xf7, 0x0d, 0x02, 0x04, 0x05, 0x00, 0x04, 0x10 };
+
+static gcry_md_oid_spec_t oid_spec_md4[] =
+ {
+ /* iso.member-body.us.rsadsi.digestAlgorithm.md4 */
+ { "1.2.840.113549.2.4" },
+ { NULL },
+ };
+
+gcry_md_spec_t _gcry_digest_spec_md4 =
+ {
+ "MD4", asn, DIM (asn), oid_spec_md4,16,
+ md4_init, md4_write, md4_final, md4_read,
+ sizeof (MD4_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_md4",
+#endif
+ .blocksize = 64
+ };
+
+
+GRUB_MOD_INIT(gcry_md4)
+{
+ COMPILE_TIME_ASSERT(sizeof (MD4_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ grub_md_register (&_gcry_digest_spec_md4);
+}
+
+GRUB_MOD_FINI(gcry_md4)
+{
+ grub_md_unregister (&_gcry_digest_spec_md4);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/md5.c b/grub-core/lib/libgcrypt-grub/cipher/md5.c
new file mode 100644
index 0000000..e5b6acc
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/md5.c
@@ -0,0 +1,372 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* md5.c - MD5 Message-Digest Algorithm
+ * Copyright (C) 1995,1996,1998,1999,2001,2002,
+ * 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * According to the definition of MD5 in RFC 1321 from April 1992.
+ * NOTE: This is *not* the same file as the one from glibc.
+ * Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+ * heavily modified for GnuPG by Werner Koch <wk@gnupg.org>
+ */
+
+/* Test values:
+ * "" D4 1D 8C D9 8F 00 B2 04 E9 80 09 98 EC F8 42 7E
+ * "a" 0C C1 75 B9 C0 F1 B6 A8 31 C3 99 E2 69 77 26 61
+ * "abc 90 01 50 98 3C D2 4F B0 D6 96 3F 7D 28 E1 7F 72
+ * "message digest" F9 6B 69 7D 7C B7 93 8D 52 5A 2F 31 AA F1 61 D0
+ */
+
+
+#include "g10lib.h"
+#include "cipher.h"
+
+#include "bithelp.h"
+
+
+typedef struct {
+ u32 A,B,C,D; /* chaining variables */
+ u32 nblocks;
+ byte buf[64];
+ int count;
+} MD5_CONTEXT;
+
+
+static void
+md5_init( void *context )
+{
+ MD5_CONTEXT *ctx = context;
+
+ ctx->A = 0x67452301;
+ ctx->B = 0xefcdab89;
+ ctx->C = 0x98badcfe;
+ ctx->D = 0x10325476;
+
+ ctx->nblocks = 0;
+ ctx->count = 0;
+}
+
+
+/* These are the four functions used in the four steps of the MD5 algorithm
+ and defined in the RFC 1321. The first function is a little bit optimized
+ (as found in Colin Plumbs public domain implementation). */
+/* #define FF(b, c, d) ((b & c) | (~b & d)) */
+#define FF(b, c, d) (d ^ (b & (c ^ d)))
+#define FG(b, c, d) FF (d, b, c)
+#define FH(b, c, d) (b ^ c ^ d)
+#define FI(b, c, d) (c ^ (b | ~d))
+
+
+/****************
+ * transform n*64 bytes
+ */
+static void
+transform ( MD5_CONTEXT *ctx, const unsigned char *data )
+{
+ u32 correct_words[16];
+ register u32 A = ctx->A;
+ register u32 B = ctx->B;
+ register u32 C = ctx->C;
+ register u32 D = ctx->D;
+ u32 *cwp = correct_words;
+
+#ifdef WORDS_BIGENDIAN
+ {
+ int i;
+ byte *p2;
+ const byte *p1;
+ for(i=0, p1=data, p2=(byte*)correct_words; i < 16; i++, p2 += 4 )
+ {
+ p2[3] = *p1++;
+ p2[2] = *p1++;
+ p2[1] = *p1++;
+ p2[0] = *p1++;
+ }
+ }
+#else
+ memcpy( correct_words, data, 64 );
+#endif
+
+
+#define OP(a, b, c, d, s, T) \
+ do \
+ { \
+ a += FF (b, c, d) + (*cwp++) + T; \
+ a = rol(a, s); \
+ a += b; \
+ } \
+ while (0)
+
+ /* Before we start, one word about the strange constants.
+ They are defined in RFC 1321 as
+
+ T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
+ */
+
+ /* Round 1. */
+ OP (A, B, C, D, 7, 0xd76aa478);
+ OP (D, A, B, C, 12, 0xe8c7b756);
+ OP (C, D, A, B, 17, 0x242070db);
+ OP (B, C, D, A, 22, 0xc1bdceee);
+ OP (A, B, C, D, 7, 0xf57c0faf);
+ OP (D, A, B, C, 12, 0x4787c62a);
+ OP (C, D, A, B, 17, 0xa8304613);
+ OP (B, C, D, A, 22, 0xfd469501);
+ OP (A, B, C, D, 7, 0x698098d8);
+ OP (D, A, B, C, 12, 0x8b44f7af);
+ OP (C, D, A, B, 17, 0xffff5bb1);
+ OP (B, C, D, A, 22, 0x895cd7be);
+ OP (A, B, C, D, 7, 0x6b901122);
+ OP (D, A, B, C, 12, 0xfd987193);
+ OP (C, D, A, B, 17, 0xa679438e);
+ OP (B, C, D, A, 22, 0x49b40821);
+
+#undef OP
+#define OP(f, a, b, c, d, k, s, T) \
+ do \
+ { \
+ a += f (b, c, d) + correct_words[k] + T; \
+ a = rol(a, s); \
+ a += b; \
+ } \
+ while (0)
+
+ /* Round 2. */
+ OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
+ OP (FG, D, A, B, C, 6, 9, 0xc040b340);
+ OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
+ OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
+ OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
+ OP (FG, D, A, B, C, 10, 9, 0x02441453);
+ OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
+ OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
+ OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
+ OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
+ OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
+ OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
+ OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
+ OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
+ OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
+ OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
+
+ /* Round 3. */
+ OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
+ OP (FH, D, A, B, C, 8, 11, 0x8771f681);
+ OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
+ OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
+ OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
+ OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
+ OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
+ OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
+ OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
+ OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
+ OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
+ OP (FH, B, C, D, A, 6, 23, 0x04881d05);
+ OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
+ OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
+ OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
+ OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
+
+ /* Round 4. */
+ OP (FI, A, B, C, D, 0, 6, 0xf4292244);
+ OP (FI, D, A, B, C, 7, 10, 0x432aff97);
+ OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
+ OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
+ OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
+ OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
+ OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
+ OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
+ OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
+ OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
+ OP (FI, C, D, A, B, 6, 15, 0xa3014314);
+ OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
+ OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
+ OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
+ OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
+ OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
+
+ /* Put checksum in context given as argument. */
+ ctx->A += A;
+ ctx->B += B;
+ ctx->C += C;
+ ctx->D += D;
+}
+
+
+
+/* The routine updates the message-digest context to
+ * account for the presence of each of the characters inBuf[0..inLen-1]
+ * in the message whose digest is being computed.
+ */
+static void
+md5_write( void *context, const void *inbuf_arg , size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ MD5_CONTEXT *hd = context;
+
+ if( hd->count == 64 ) /* flush the buffer */
+ {
+ transform( hd, hd->buf );
+ _gcry_burn_stack (80+6*sizeof(void*));
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if( !inbuf )
+ return;
+
+ if( hd->count )
+ {
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+ md5_write( hd, NULL, 0 );
+ if( !inlen )
+ return;
+ }
+ _gcry_burn_stack (80+6*sizeof(void*));
+
+ while( inlen >= 64 )
+ {
+ transform( hd, inbuf );
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 64;
+ inbuf += 64;
+ }
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+
+}
+
+
+
+/* The routine final terminates the message-digest computation and
+ * ends with the desired message digest in mdContext->digest[0...15].
+ * The handle is prepared for a new MD5 cycle.
+ * Returns 16 bytes representing the digest.
+ */
+
+static void
+md5_final( void *context)
+{
+ MD5_CONTEXT *hd = context;
+ u32 t, msb, lsb;
+ byte *p;
+
+ md5_write(hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if( (lsb += hd->count) < t )
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if( hd->count < 56 ) /* enough room */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while( hd->count < 56 )
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else /* need one extra block */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while( hd->count < 64 )
+ hd->buf[hd->count++] = 0;
+ md5_write(hd, NULL, 0); /* flush */;
+ memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = lsb ;
+ hd->buf[57] = lsb >> 8;
+ hd->buf[58] = lsb >> 16;
+ hd->buf[59] = lsb >> 24;
+ hd->buf[60] = msb ;
+ hd->buf[61] = msb >> 8;
+ hd->buf[62] = msb >> 16;
+ hd->buf[63] = msb >> 24;
+ transform( hd, hd->buf );
+ _gcry_burn_stack (80+6*sizeof(void*));
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *p++ = hd->a ; *p++ = hd->a >> 8; \
+ *p++ = hd->a >> 16; *p++ = hd->a >> 24; } while(0)
+#else /* little endian */
+#define X(a) do { *(u32*)p = (*hd).a ; p += 4; } while(0)
+#endif
+ X(A);
+ X(B);
+ X(C);
+ X(D);
+#undef X
+
+}
+
+static byte *
+md5_read( void *context )
+{
+ MD5_CONTEXT *hd = (MD5_CONTEXT *) context;
+ return hd->buf;
+}
+
+static byte asn[18] = /* Object ID is 1.2.840.113549.2.5 */
+ { 0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86,0x48,
+ 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 };
+
+static gcry_md_oid_spec_t oid_spec_md5[] =
+ {
+ /* iso.member-body.us.rsadsi.pkcs.pkcs-1.4 (md5WithRSAEncryption) */
+ { "1.2.840.113549.1.1.4" },
+ /* RSADSI digestAlgorithm MD5 */
+ { "1.2.840.113549.2.5" },
+ { NULL },
+ };
+
+gcry_md_spec_t _gcry_digest_spec_md5 =
+ {
+ "MD5", asn, DIM (asn), oid_spec_md5, 16,
+ md5_init, md5_write, md5_final, md5_read,
+ sizeof (MD5_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_md5",
+#endif
+ .blocksize = 64
+ };
+
+
+GRUB_MOD_INIT(gcry_md5)
+{
+ COMPILE_TIME_ASSERT(sizeof (MD5_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ grub_md_register (&_gcry_digest_spec_md5);
+}
+
+GRUB_MOD_FINI(gcry_md5)
+{
+ grub_md_unregister (&_gcry_digest_spec_md5);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/memory.h b/grub-core/lib/libgcrypt-grub/cipher/memory.h
new file mode 100644
index 0000000..49cc16a
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/memory.h
@@ -0,0 +1 @@
+#include <cipher_wrap.h>
diff --git a/grub-core/lib/libgcrypt-grub/cipher/rfc2268.c b/grub-core/lib/libgcrypt-grub/cipher/rfc2268.c
new file mode 100644
index 0000000..c5c4a4b
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/rfc2268.c
@@ -0,0 +1,285 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* rfc2268.c - The cipher described in rfc2268; aka Ron's Cipher 2.
+ * Copyright (C) 2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/* This implementation was written by Nikos Mavroyanopoulos for GNUTLS
+ * as a Libgcrypt module (gnutls/lib/x509/rc2.c) and later adapted for
+ * direct use by Libgcrypt by Werner Koch. This implementation is
+ * only useful for pkcs#12 decryption.
+ *
+ * The implementation here is based on Peter Gutmann's RRC.2 paper.
+ */
+
+
+#include "g10lib.h"
+#include "types.h"
+#include "cipher.h"
+
+#define RFC2268_BLOCKSIZE 8
+
+typedef struct
+{
+ u16 S[64];
+} RFC2268_context;
+
+static const unsigned char rfc2268_sbox[] = {
+ 217, 120, 249, 196, 25, 221, 181, 237,
+ 40, 233, 253, 121, 74, 160, 216, 157,
+ 198, 126, 55, 131, 43, 118, 83, 142,
+ 98, 76, 100, 136, 68, 139, 251, 162,
+ 23, 154, 89, 245, 135, 179, 79, 19,
+ 97, 69, 109, 141, 9, 129, 125, 50,
+ 189, 143, 64, 235, 134, 183, 123, 11,
+ 240, 149, 33, 34, 92, 107, 78, 130,
+ 84, 214, 101, 147, 206, 96, 178, 28,
+ 115, 86, 192, 20, 167, 140, 241, 220,
+ 18, 117, 202, 31, 59, 190, 228, 209,
+ 66, 61, 212, 48, 163, 60, 182, 38,
+ 111, 191, 14, 218, 70, 105, 7, 87,
+ 39, 242, 29, 155, 188, 148, 67, 3,
+ 248, 17, 199, 246, 144, 239, 62, 231,
+ 6, 195, 213, 47, 200, 102, 30, 215,
+ 8, 232, 234, 222, 128, 82, 238, 247,
+ 132, 170, 114, 172, 53, 77, 106, 42,
+ 150, 26, 210, 113, 90, 21, 73, 116,
+ 75, 159, 208, 94, 4, 24, 164, 236,
+ 194, 224, 65, 110, 15, 81, 203, 204,
+ 36, 145, 175, 80, 161, 244, 112, 57,
+ 153, 124, 58, 133, 35, 184, 180, 122,
+ 252, 2, 54, 91, 37, 85, 151, 49,
+ 45, 93, 250, 152, 227, 138, 146, 174,
+ 5, 223, 41, 16, 103, 108, 186, 201,
+ 211, 0, 230, 207, 225, 158, 168, 44,
+ 99, 22, 1, 63, 88, 226, 137, 169,
+ 13, 56, 52, 27, 171, 51, 255, 176,
+ 187, 72, 12, 95, 185, 177, 205, 46,
+ 197, 243, 219, 71, 229, 165, 156, 119,
+ 10, 166, 32, 104, 254, 127, 193, 173
+};
+
+#define rotl16(x,n) (((x) << ((u16)(n))) | ((x) >> (16 - (u16)(n))))
+#define rotr16(x,n) (((x) >> ((u16)(n))) | ((x) << (16 - (u16)(n))))
+
+
+
+static void
+do_encrypt (void *context, unsigned char *outbuf, const unsigned char *inbuf)
+{
+ RFC2268_context *ctx = context;
+ register int i, j;
+ u16 word0 = 0, word1 = 0, word2 = 0, word3 = 0;
+
+ word0 = (word0 << 8) | inbuf[1];
+ word0 = (word0 << 8) | inbuf[0];
+ word1 = (word1 << 8) | inbuf[3];
+ word1 = (word1 << 8) | inbuf[2];
+ word2 = (word2 << 8) | inbuf[5];
+ word2 = (word2 << 8) | inbuf[4];
+ word3 = (word3 << 8) | inbuf[7];
+ word3 = (word3 << 8) | inbuf[6];
+
+ for (i = 0; i < 16; i++)
+ {
+ j = i * 4;
+ /* For some reason I cannot combine those steps. */
+ word0 += (word1 & ~word3) + (word2 & word3) + ctx->S[j];
+ word0 = rotl16(word0, 1);
+
+ word1 += (word2 & ~word0) + (word3 & word0) + ctx->S[j + 1];
+ word1 = rotl16(word1, 2);
+
+ word2 += (word3 & ~word1) + (word0 & word1) + ctx->S[j + 2];
+ word2 = rotl16(word2, 3);
+
+ word3 += (word0 & ~word2) + (word1 & word2) + ctx->S[j + 3];
+ word3 = rotl16(word3, 5);
+
+ if (i == 4 || i == 10)
+ {
+ word0 += ctx->S[word3 & 63];
+ word1 += ctx->S[word0 & 63];
+ word2 += ctx->S[word1 & 63];
+ word3 += ctx->S[word2 & 63];
+ }
+
+ }
+
+ outbuf[0] = word0 & 255;
+ outbuf[1] = word0 >> 8;
+ outbuf[2] = word1 & 255;
+ outbuf[3] = word1 >> 8;
+ outbuf[4] = word2 & 255;
+ outbuf[5] = word2 >> 8;
+ outbuf[6] = word3 & 255;
+ outbuf[7] = word3 >> 8;
+}
+
+static void
+do_decrypt (void *context, unsigned char *outbuf, const unsigned char *inbuf)
+{
+ RFC2268_context *ctx = context;
+ register int i, j;
+ u16 word0 = 0, word1 = 0, word2 = 0, word3 = 0;
+
+ word0 = (word0 << 8) | inbuf[1];
+ word0 = (word0 << 8) | inbuf[0];
+ word1 = (word1 << 8) | inbuf[3];
+ word1 = (word1 << 8) | inbuf[2];
+ word2 = (word2 << 8) | inbuf[5];
+ word2 = (word2 << 8) | inbuf[4];
+ word3 = (word3 << 8) | inbuf[7];
+ word3 = (word3 << 8) | inbuf[6];
+
+ for (i = 15; i >= 0; i--)
+ {
+ j = i * 4;
+
+ word3 = rotr16(word3, 5);
+ word3 -= (word0 & ~word2) + (word1 & word2) + ctx->S[j + 3];
+
+ word2 = rotr16(word2, 3);
+ word2 -= (word3 & ~word1) + (word0 & word1) + ctx->S[j + 2];
+
+ word1 = rotr16(word1, 2);
+ word1 -= (word2 & ~word0) + (word3 & word0) + ctx->S[j + 1];
+
+ word0 = rotr16(word0, 1);
+ word0 -= (word1 & ~word3) + (word2 & word3) + ctx->S[j];
+
+ if (i == 5 || i == 11)
+ {
+ word3 = word3 - ctx->S[word2 & 63];
+ word2 = word2 - ctx->S[word1 & 63];
+ word1 = word1 - ctx->S[word0 & 63];
+ word0 = word0 - ctx->S[word3 & 63];
+ }
+
+ }
+
+ outbuf[0] = word0 & 255;
+ outbuf[1] = word0 >> 8;
+ outbuf[2] = word1 & 255;
+ outbuf[3] = word1 >> 8;
+ outbuf[4] = word2 & 255;
+ outbuf[5] = word2 >> 8;
+ outbuf[6] = word3 & 255;
+ outbuf[7] = word3 >> 8;
+}
+
+
+static gpg_err_code_t
+setkey_core (void *context, const unsigned char *key, unsigned int keylen, int with_phase2)
+{
+ static int initialized;
+ static const char *selftest_failed;
+ RFC2268_context *ctx = context;
+ unsigned int i;
+ unsigned char *S, x;
+ int len;
+ int bits = keylen * 8;
+
+ if (!initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+ if (selftest_failed)
+ log_error ("RFC2268 selftest failed (%s).\n", selftest_failed);
+ }
+ if (selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ if (keylen < 40 / 8) /* We want at least 40 bits. */
+ return GPG_ERR_INV_KEYLEN;
+
+ S = (unsigned char *) ctx->S;
+
+ for (i = 0; i < keylen; i++)
+ S[i] = key[i];
+
+ for (i = keylen; i < 128; i++)
+ S[i] = rfc2268_sbox[(S[i - keylen] + S[i - 1]) & 255];
+
+ S[0] = rfc2268_sbox[S[0]];
+
+ /* Phase 2 - reduce effective key size to "bits". This was not
+ * discussed in Gutmann's paper. I've copied that from the public
+ * domain code posted in sci.crypt. */
+ if (with_phase2)
+ {
+ len = (bits + 7) >> 3;
+ i = 128 - len;
+ x = rfc2268_sbox[S[i] & (255 >> (7 & -bits))];
+ S[i] = x;
+
+ while (i--)
+ {
+ x = rfc2268_sbox[x ^ S[i + len]];
+ S[i] = x;
+ }
+ }
+
+ /* Make the expanded key, endian independent. */
+ for (i = 0; i < 64; i++)
+ ctx->S[i] = ( (u16) S[i * 2] | (((u16) S[i * 2 + 1]) << 8));
+
+ return 0;
+}
+
+static gpg_err_code_t
+do_setkey (void *context, const unsigned char *key, unsigned int keylen)
+{
+ return setkey_core (context, key, keylen, 1);
+}
+
+
+
+
+static gcry_cipher_oid_spec_t oids_rfc2268_40[] =
+ {
+ /*{ "1.2.840.113549.3.2", GCRY_CIPHER_MODE_CBC },*/
+ /* pbeWithSHAAnd40BitRC2_CBC */
+ { "1.2.840.113549.1.12.1.6", GCRY_CIPHER_MODE_CBC },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_40 = {
+ "RFC2268_40", NULL, oids_rfc2268_40,
+ RFC2268_BLOCKSIZE, 40, sizeof(RFC2268_context),
+ do_setkey, do_encrypt, do_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_rfc2268",
+#endif
+};
+
+
+GRUB_MOD_INIT(gcry_rfc2268)
+{
+ grub_cipher_register (&_gcry_cipher_spec_rfc2268_40);
+}
+
+GRUB_MOD_FINI(gcry_rfc2268)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_rfc2268_40);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/rijndael-tables.h b/grub-core/lib/libgcrypt-grub/cipher/rijndael-tables.h
new file mode 100644
index 0000000..8027db6
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/rijndael-tables.h
@@ -0,0 +1,1689 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+/* rijndael-tables.h - Rijndael (AES) for GnuPG,
+ * Copyright (C) 2000, 2001, 2002, 2003, 2007,
+ * 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* To keep the actual implementation at a readable size we use this
+ include file to define the tables. */
+
+static const unsigned char S[256] =
+ {
+ 99, 124, 119, 123, 242, 107, 111, 197,
+ 48, 1, 103, 43, 254, 215, 171, 118,
+ 202, 130, 201, 125, 250, 89, 71, 240,
+ 173, 212, 162, 175, 156, 164, 114, 192,
+ 183, 253, 147, 38, 54, 63, 247, 204,
+ 52, 165, 229, 241, 113, 216, 49, 21,
+ 4, 199, 35, 195, 24, 150, 5, 154,
+ 7, 18, 128, 226, 235, 39, 178, 117,
+ 9, 131, 44, 26, 27, 110, 90, 160,
+ 82, 59, 214, 179, 41, 227, 47, 132,
+ 83, 209, 0, 237, 32, 252, 177, 91,
+ 106, 203, 190, 57, 74, 76, 88, 207,
+ 208, 239, 170, 251, 67, 77, 51, 133,
+ 69, 249, 2, 127, 80, 60, 159, 168,
+ 81, 163, 64, 143, 146, 157, 56, 245,
+ 188, 182, 218, 33, 16, 255, 243, 210,
+ 205, 12, 19, 236, 95, 151, 68, 23,
+ 196, 167, 126, 61, 100, 93, 25, 115,
+ 96, 129, 79, 220, 34, 42, 144, 136,
+ 70, 238, 184, 20, 222, 94, 11, 219,
+ 224, 50, 58, 10, 73, 6, 36, 92,
+ 194, 211, 172, 98, 145, 149, 228, 121,
+ 231, 200, 55, 109, 141, 213, 78, 169,
+ 108, 86, 244, 234, 101, 122, 174, 8,
+ 186, 120, 37, 46, 28, 166, 180, 198,
+ 232, 221, 116, 31, 75, 189, 139, 138,
+ 112, 62, 181, 102, 72, 3, 246, 14,
+ 97, 53, 87, 185, 134, 193, 29, 158,
+ 225, 248, 152, 17, 105, 217, 142, 148,
+ 155, 30, 135, 233, 206, 85, 40, 223,
+ 140, 161, 137, 13, 191, 230, 66, 104,
+ 65, 153, 45, 15, 176, 84, 187, 22
+ };
+
+
+static const unsigned char T1[256][4] =
+ {
+ { 0xc6,0x63,0x63,0xa5 }, { 0xf8,0x7c,0x7c,0x84 },
+ { 0xee,0x77,0x77,0x99 }, { 0xf6,0x7b,0x7b,0x8d },
+ { 0xff,0xf2,0xf2,0x0d }, { 0xd6,0x6b,0x6b,0xbd },
+ { 0xde,0x6f,0x6f,0xb1 }, { 0x91,0xc5,0xc5,0x54 },
+ { 0x60,0x30,0x30,0x50 }, { 0x02,0x01,0x01,0x03 },
+ { 0xce,0x67,0x67,0xa9 }, { 0x56,0x2b,0x2b,0x7d },
+ { 0xe7,0xfe,0xfe,0x19 }, { 0xb5,0xd7,0xd7,0x62 },
+ { 0x4d,0xab,0xab,0xe6 }, { 0xec,0x76,0x76,0x9a },
+ { 0x8f,0xca,0xca,0x45 }, { 0x1f,0x82,0x82,0x9d },
+ { 0x89,0xc9,0xc9,0x40 }, { 0xfa,0x7d,0x7d,0x87 },
+ { 0xef,0xfa,0xfa,0x15 }, { 0xb2,0x59,0x59,0xeb },
+ { 0x8e,0x47,0x47,0xc9 }, { 0xfb,0xf0,0xf0,0x0b },
+ { 0x41,0xad,0xad,0xec }, { 0xb3,0xd4,0xd4,0x67 },
+ { 0x5f,0xa2,0xa2,0xfd }, { 0x45,0xaf,0xaf,0xea },
+ { 0x23,0x9c,0x9c,0xbf }, { 0x53,0xa4,0xa4,0xf7 },
+ { 0xe4,0x72,0x72,0x96 }, { 0x9b,0xc0,0xc0,0x5b },
+ { 0x75,0xb7,0xb7,0xc2 }, { 0xe1,0xfd,0xfd,0x1c },
+ { 0x3d,0x93,0x93,0xae }, { 0x4c,0x26,0x26,0x6a },
+ { 0x6c,0x36,0x36,0x5a }, { 0x7e,0x3f,0x3f,0x41 },
+ { 0xf5,0xf7,0xf7,0x02 }, { 0x83,0xcc,0xcc,0x4f },
+ { 0x68,0x34,0x34,0x5c }, { 0x51,0xa5,0xa5,0xf4 },
+ { 0xd1,0xe5,0xe5,0x34 }, { 0xf9,0xf1,0xf1,0x08 },
+ { 0xe2,0x71,0x71,0x93 }, { 0xab,0xd8,0xd8,0x73 },
+ { 0x62,0x31,0x31,0x53 }, { 0x2a,0x15,0x15,0x3f },
+ { 0x08,0x04,0x04,0x0c }, { 0x95,0xc7,0xc7,0x52 },
+ { 0x46,0x23,0x23,0x65 }, { 0x9d,0xc3,0xc3,0x5e },
+ { 0x30,0x18,0x18,0x28 }, { 0x37,0x96,0x96,0xa1 },
+ { 0x0a,0x05,0x05,0x0f }, { 0x2f,0x9a,0x9a,0xb5 },
+ { 0x0e,0x07,0x07,0x09 }, { 0x24,0x12,0x12,0x36 },
+ { 0x1b,0x80,0x80,0x9b }, { 0xdf,0xe2,0xe2,0x3d },
+ { 0xcd,0xeb,0xeb,0x26 }, { 0x4e,0x27,0x27,0x69 },
+ { 0x7f,0xb2,0xb2,0xcd }, { 0xea,0x75,0x75,0x9f },
+ { 0x12,0x09,0x09,0x1b }, { 0x1d,0x83,0x83,0x9e },
+ { 0x58,0x2c,0x2c,0x74 }, { 0x34,0x1a,0x1a,0x2e },
+ { 0x36,0x1b,0x1b,0x2d }, { 0xdc,0x6e,0x6e,0xb2 },
+ { 0xb4,0x5a,0x5a,0xee }, { 0x5b,0xa0,0xa0,0xfb },
+ { 0xa4,0x52,0x52,0xf6 }, { 0x76,0x3b,0x3b,0x4d },
+ { 0xb7,0xd6,0xd6,0x61 }, { 0x7d,0xb3,0xb3,0xce },
+ { 0x52,0x29,0x29,0x7b }, { 0xdd,0xe3,0xe3,0x3e },
+ { 0x5e,0x2f,0x2f,0x71 }, { 0x13,0x84,0x84,0x97 },
+ { 0xa6,0x53,0x53,0xf5 }, { 0xb9,0xd1,0xd1,0x68 },
+ { 0x00,0x00,0x00,0x00 }, { 0xc1,0xed,0xed,0x2c },
+ { 0x40,0x20,0x20,0x60 }, { 0xe3,0xfc,0xfc,0x1f },
+ { 0x79,0xb1,0xb1,0xc8 }, { 0xb6,0x5b,0x5b,0xed },
+ { 0xd4,0x6a,0x6a,0xbe }, { 0x8d,0xcb,0xcb,0x46 },
+ { 0x67,0xbe,0xbe,0xd9 }, { 0x72,0x39,0x39,0x4b },
+ { 0x94,0x4a,0x4a,0xde }, { 0x98,0x4c,0x4c,0xd4 },
+ { 0xb0,0x58,0x58,0xe8 }, { 0x85,0xcf,0xcf,0x4a },
+ { 0xbb,0xd0,0xd0,0x6b }, { 0xc5,0xef,0xef,0x2a },
+ { 0x4f,0xaa,0xaa,0xe5 }, { 0xed,0xfb,0xfb,0x16 },
+ { 0x86,0x43,0x43,0xc5 }, { 0x9a,0x4d,0x4d,0xd7 },
+ { 0x66,0x33,0x33,0x55 }, { 0x11,0x85,0x85,0x94 },
+ { 0x8a,0x45,0x45,0xcf }, { 0xe9,0xf9,0xf9,0x10 },
+ { 0x04,0x02,0x02,0x06 }, { 0xfe,0x7f,0x7f,0x81 },
+ { 0xa0,0x50,0x50,0xf0 }, { 0x78,0x3c,0x3c,0x44 },
+ { 0x25,0x9f,0x9f,0xba }, { 0x4b,0xa8,0xa8,0xe3 },
+ { 0xa2,0x51,0x51,0xf3 }, { 0x5d,0xa3,0xa3,0xfe },
+ { 0x80,0x40,0x40,0xc0 }, { 0x05,0x8f,0x8f,0x8a },
+ { 0x3f,0x92,0x92,0xad }, { 0x21,0x9d,0x9d,0xbc },
+ { 0x70,0x38,0x38,0x48 }, { 0xf1,0xf5,0xf5,0x04 },
+ { 0x63,0xbc,0xbc,0xdf }, { 0x77,0xb6,0xb6,0xc1 },
+ { 0xaf,0xda,0xda,0x75 }, { 0x42,0x21,0x21,0x63 },
+ { 0x20,0x10,0x10,0x30 }, { 0xe5,0xff,0xff,0x1a },
+ { 0xfd,0xf3,0xf3,0x0e }, { 0xbf,0xd2,0xd2,0x6d },
+ { 0x81,0xcd,0xcd,0x4c }, { 0x18,0x0c,0x0c,0x14 },
+ { 0x26,0x13,0x13,0x35 }, { 0xc3,0xec,0xec,0x2f },
+ { 0xbe,0x5f,0x5f,0xe1 }, { 0x35,0x97,0x97,0xa2 },
+ { 0x88,0x44,0x44,0xcc }, { 0x2e,0x17,0x17,0x39 },
+ { 0x93,0xc4,0xc4,0x57 }, { 0x55,0xa7,0xa7,0xf2 },
+ { 0xfc,0x7e,0x7e,0x82 }, { 0x7a,0x3d,0x3d,0x47 },
+ { 0xc8,0x64,0x64,0xac }, { 0xba,0x5d,0x5d,0xe7 },
+ { 0x32,0x19,0x19,0x2b }, { 0xe6,0x73,0x73,0x95 },
+ { 0xc0,0x60,0x60,0xa0 }, { 0x19,0x81,0x81,0x98 },
+ { 0x9e,0x4f,0x4f,0xd1 }, { 0xa3,0xdc,0xdc,0x7f },
+ { 0x44,0x22,0x22,0x66 }, { 0x54,0x2a,0x2a,0x7e },
+ { 0x3b,0x90,0x90,0xab }, { 0x0b,0x88,0x88,0x83 },
+ { 0x8c,0x46,0x46,0xca }, { 0xc7,0xee,0xee,0x29 },
+ { 0x6b,0xb8,0xb8,0xd3 }, { 0x28,0x14,0x14,0x3c },
+ { 0xa7,0xde,0xde,0x79 }, { 0xbc,0x5e,0x5e,0xe2 },
+ { 0x16,0x0b,0x0b,0x1d }, { 0xad,0xdb,0xdb,0x76 },
+ { 0xdb,0xe0,0xe0,0x3b }, { 0x64,0x32,0x32,0x56 },
+ { 0x74,0x3a,0x3a,0x4e }, { 0x14,0x0a,0x0a,0x1e },
+ { 0x92,0x49,0x49,0xdb }, { 0x0c,0x06,0x06,0x0a },
+ { 0x48,0x24,0x24,0x6c }, { 0xb8,0x5c,0x5c,0xe4 },
+ { 0x9f,0xc2,0xc2,0x5d }, { 0xbd,0xd3,0xd3,0x6e },
+ { 0x43,0xac,0xac,0xef }, { 0xc4,0x62,0x62,0xa6 },
+ { 0x39,0x91,0x91,0xa8 }, { 0x31,0x95,0x95,0xa4 },
+ { 0xd3,0xe4,0xe4,0x37 }, { 0xf2,0x79,0x79,0x8b },
+ { 0xd5,0xe7,0xe7,0x32 }, { 0x8b,0xc8,0xc8,0x43 },
+ { 0x6e,0x37,0x37,0x59 }, { 0xda,0x6d,0x6d,0xb7 },
+ { 0x01,0x8d,0x8d,0x8c }, { 0xb1,0xd5,0xd5,0x64 },
+ { 0x9c,0x4e,0x4e,0xd2 }, { 0x49,0xa9,0xa9,0xe0 },
+ { 0xd8,0x6c,0x6c,0xb4 }, { 0xac,0x56,0x56,0xfa },
+ { 0xf3,0xf4,0xf4,0x07 }, { 0xcf,0xea,0xea,0x25 },
+ { 0xca,0x65,0x65,0xaf }, { 0xf4,0x7a,0x7a,0x8e },
+ { 0x47,0xae,0xae,0xe9 }, { 0x10,0x08,0x08,0x18 },
+ { 0x6f,0xba,0xba,0xd5 }, { 0xf0,0x78,0x78,0x88 },
+ { 0x4a,0x25,0x25,0x6f }, { 0x5c,0x2e,0x2e,0x72 },
+ { 0x38,0x1c,0x1c,0x24 }, { 0x57,0xa6,0xa6,0xf1 },
+ { 0x73,0xb4,0xb4,0xc7 }, { 0x97,0xc6,0xc6,0x51 },
+ { 0xcb,0xe8,0xe8,0x23 }, { 0xa1,0xdd,0xdd,0x7c },
+ { 0xe8,0x74,0x74,0x9c }, { 0x3e,0x1f,0x1f,0x21 },
+ { 0x96,0x4b,0x4b,0xdd }, { 0x61,0xbd,0xbd,0xdc },
+ { 0x0d,0x8b,0x8b,0x86 }, { 0x0f,0x8a,0x8a,0x85 },
+ { 0xe0,0x70,0x70,0x90 }, { 0x7c,0x3e,0x3e,0x42 },
+ { 0x71,0xb5,0xb5,0xc4 }, { 0xcc,0x66,0x66,0xaa },
+ { 0x90,0x48,0x48,0xd8 }, { 0x06,0x03,0x03,0x05 },
+ { 0xf7,0xf6,0xf6,0x01 }, { 0x1c,0x0e,0x0e,0x12 },
+ { 0xc2,0x61,0x61,0xa3 }, { 0x6a,0x35,0x35,0x5f },
+ { 0xae,0x57,0x57,0xf9 }, { 0x69,0xb9,0xb9,0xd0 },
+ { 0x17,0x86,0x86,0x91 }, { 0x99,0xc1,0xc1,0x58 },
+ { 0x3a,0x1d,0x1d,0x27 }, { 0x27,0x9e,0x9e,0xb9 },
+ { 0xd9,0xe1,0xe1,0x38 }, { 0xeb,0xf8,0xf8,0x13 },
+ { 0x2b,0x98,0x98,0xb3 }, { 0x22,0x11,0x11,0x33 },
+ { 0xd2,0x69,0x69,0xbb }, { 0xa9,0xd9,0xd9,0x70 },
+ { 0x07,0x8e,0x8e,0x89 }, { 0x33,0x94,0x94,0xa7 },
+ { 0x2d,0x9b,0x9b,0xb6 }, { 0x3c,0x1e,0x1e,0x22 },
+ { 0x15,0x87,0x87,0x92 }, { 0xc9,0xe9,0xe9,0x20 },
+ { 0x87,0xce,0xce,0x49 }, { 0xaa,0x55,0x55,0xff },
+ { 0x50,0x28,0x28,0x78 }, { 0xa5,0xdf,0xdf,0x7a },
+ { 0x03,0x8c,0x8c,0x8f }, { 0x59,0xa1,0xa1,0xf8 },
+ { 0x09,0x89,0x89,0x80 }, { 0x1a,0x0d,0x0d,0x17 },
+ { 0x65,0xbf,0xbf,0xda }, { 0xd7,0xe6,0xe6,0x31 },
+ { 0x84,0x42,0x42,0xc6 }, { 0xd0,0x68,0x68,0xb8 },
+ { 0x82,0x41,0x41,0xc3 }, { 0x29,0x99,0x99,0xb0 },
+ { 0x5a,0x2d,0x2d,0x77 }, { 0x1e,0x0f,0x0f,0x11 },
+ { 0x7b,0xb0,0xb0,0xcb }, { 0xa8,0x54,0x54,0xfc },
+ { 0x6d,0xbb,0xbb,0xd6 }, { 0x2c,0x16,0x16,0x3a }
+ };
+
+static const unsigned char T2[256][4] =
+ {
+ { 0xa5,0xc6,0x63,0x63 }, { 0x84,0xf8,0x7c,0x7c },
+ { 0x99,0xee,0x77,0x77 }, { 0x8d,0xf6,0x7b,0x7b },
+ { 0x0d,0xff,0xf2,0xf2 }, { 0xbd,0xd6,0x6b,0x6b },
+ { 0xb1,0xde,0x6f,0x6f }, { 0x54,0x91,0xc5,0xc5 },
+ { 0x50,0x60,0x30,0x30 }, { 0x03,0x02,0x01,0x01 },
+ { 0xa9,0xce,0x67,0x67 }, { 0x7d,0x56,0x2b,0x2b },
+ { 0x19,0xe7,0xfe,0xfe }, { 0x62,0xb5,0xd7,0xd7 },
+ { 0xe6,0x4d,0xab,0xab }, { 0x9a,0xec,0x76,0x76 },
+ { 0x45,0x8f,0xca,0xca }, { 0x9d,0x1f,0x82,0x82 },
+ { 0x40,0x89,0xc9,0xc9 }, { 0x87,0xfa,0x7d,0x7d },
+ { 0x15,0xef,0xfa,0xfa }, { 0xeb,0xb2,0x59,0x59 },
+ { 0xc9,0x8e,0x47,0x47 }, { 0x0b,0xfb,0xf0,0xf0 },
+ { 0xec,0x41,0xad,0xad }, { 0x67,0xb3,0xd4,0xd4 },
+ { 0xfd,0x5f,0xa2,0xa2 }, { 0xea,0x45,0xaf,0xaf },
+ { 0xbf,0x23,0x9c,0x9c }, { 0xf7,0x53,0xa4,0xa4 },
+ { 0x96,0xe4,0x72,0x72 }, { 0x5b,0x9b,0xc0,0xc0 },
+ { 0xc2,0x75,0xb7,0xb7 }, { 0x1c,0xe1,0xfd,0xfd },
+ { 0xae,0x3d,0x93,0x93 }, { 0x6a,0x4c,0x26,0x26 },
+ { 0x5a,0x6c,0x36,0x36 }, { 0x41,0x7e,0x3f,0x3f },
+ { 0x02,0xf5,0xf7,0xf7 }, { 0x4f,0x83,0xcc,0xcc },
+ { 0x5c,0x68,0x34,0x34 }, { 0xf4,0x51,0xa5,0xa5 },
+ { 0x34,0xd1,0xe5,0xe5 }, { 0x08,0xf9,0xf1,0xf1 },
+ { 0x93,0xe2,0x71,0x71 }, { 0x73,0xab,0xd8,0xd8 },
+ { 0x53,0x62,0x31,0x31 }, { 0x3f,0x2a,0x15,0x15 },
+ { 0x0c,0x08,0x04,0x04 }, { 0x52,0x95,0xc7,0xc7 },
+ { 0x65,0x46,0x23,0x23 }, { 0x5e,0x9d,0xc3,0xc3 },
+ { 0x28,0x30,0x18,0x18 }, { 0xa1,0x37,0x96,0x96 },
+ { 0x0f,0x0a,0x05,0x05 }, { 0xb5,0x2f,0x9a,0x9a },
+ { 0x09,0x0e,0x07,0x07 }, { 0x36,0x24,0x12,0x12 },
+ { 0x9b,0x1b,0x80,0x80 }, { 0x3d,0xdf,0xe2,0xe2 },
+ { 0x26,0xcd,0xeb,0xeb }, { 0x69,0x4e,0x27,0x27 },
+ { 0xcd,0x7f,0xb2,0xb2 }, { 0x9f,0xea,0x75,0x75 },
+ { 0x1b,0x12,0x09,0x09 }, { 0x9e,0x1d,0x83,0x83 },
+ { 0x74,0x58,0x2c,0x2c }, { 0x2e,0x34,0x1a,0x1a },
+ { 0x2d,0x36,0x1b,0x1b }, { 0xb2,0xdc,0x6e,0x6e },
+ { 0xee,0xb4,0x5a,0x5a }, { 0xfb,0x5b,0xa0,0xa0 },
+ { 0xf6,0xa4,0x52,0x52 }, { 0x4d,0x76,0x3b,0x3b },
+ { 0x61,0xb7,0xd6,0xd6 }, { 0xce,0x7d,0xb3,0xb3 },
+ { 0x7b,0x52,0x29,0x29 }, { 0x3e,0xdd,0xe3,0xe3 },
+ { 0x71,0x5e,0x2f,0x2f }, { 0x97,0x13,0x84,0x84 },
+ { 0xf5,0xa6,0x53,0x53 }, { 0x68,0xb9,0xd1,0xd1 },
+ { 0x00,0x00,0x00,0x00 }, { 0x2c,0xc1,0xed,0xed },
+ { 0x60,0x40,0x20,0x20 }, { 0x1f,0xe3,0xfc,0xfc },
+ { 0xc8,0x79,0xb1,0xb1 }, { 0xed,0xb6,0x5b,0x5b },
+ { 0xbe,0xd4,0x6a,0x6a }, { 0x46,0x8d,0xcb,0xcb },
+ { 0xd9,0x67,0xbe,0xbe }, { 0x4b,0x72,0x39,0x39 },
+ { 0xde,0x94,0x4a,0x4a }, { 0xd4,0x98,0x4c,0x4c },
+ { 0xe8,0xb0,0x58,0x58 }, { 0x4a,0x85,0xcf,0xcf },
+ { 0x6b,0xbb,0xd0,0xd0 }, { 0x2a,0xc5,0xef,0xef },
+ { 0xe5,0x4f,0xaa,0xaa }, { 0x16,0xed,0xfb,0xfb },
+ { 0xc5,0x86,0x43,0x43 }, { 0xd7,0x9a,0x4d,0x4d },
+ { 0x55,0x66,0x33,0x33 }, { 0x94,0x11,0x85,0x85 },
+ { 0xcf,0x8a,0x45,0x45 }, { 0x10,0xe9,0xf9,0xf9 },
+ { 0x06,0x04,0x02,0x02 }, { 0x81,0xfe,0x7f,0x7f },
+ { 0xf0,0xa0,0x50,0x50 }, { 0x44,0x78,0x3c,0x3c },
+ { 0xba,0x25,0x9f,0x9f }, { 0xe3,0x4b,0xa8,0xa8 },
+ { 0xf3,0xa2,0x51,0x51 }, { 0xfe,0x5d,0xa3,0xa3 },
+ { 0xc0,0x80,0x40,0x40 }, { 0x8a,0x05,0x8f,0x8f },
+ { 0xad,0x3f,0x92,0x92 }, { 0xbc,0x21,0x9d,0x9d },
+ { 0x48,0x70,0x38,0x38 }, { 0x04,0xf1,0xf5,0xf5 },
+ { 0xdf,0x63,0xbc,0xbc }, { 0xc1,0x77,0xb6,0xb6 },
+ { 0x75,0xaf,0xda,0xda }, { 0x63,0x42,0x21,0x21 },
+ { 0x30,0x20,0x10,0x10 }, { 0x1a,0xe5,0xff,0xff },
+ { 0x0e,0xfd,0xf3,0xf3 }, { 0x6d,0xbf,0xd2,0xd2 },
+ { 0x4c,0x81,0xcd,0xcd }, { 0x14,0x18,0x0c,0x0c },
+ { 0x35,0x26,0x13,0x13 }, { 0x2f,0xc3,0xec,0xec },
+ { 0xe1,0xbe,0x5f,0x5f }, { 0xa2,0x35,0x97,0x97 },
+ { 0xcc,0x88,0x44,0x44 }, { 0x39,0x2e,0x17,0x17 },
+ { 0x57,0x93,0xc4,0xc4 }, { 0xf2,0x55,0xa7,0xa7 },
+ { 0x82,0xfc,0x7e,0x7e }, { 0x47,0x7a,0x3d,0x3d },
+ { 0xac,0xc8,0x64,0x64 }, { 0xe7,0xba,0x5d,0x5d },
+ { 0x2b,0x32,0x19,0x19 }, { 0x95,0xe6,0x73,0x73 },
+ { 0xa0,0xc0,0x60,0x60 }, { 0x98,0x19,0x81,0x81 },
+ { 0xd1,0x9e,0x4f,0x4f }, { 0x7f,0xa3,0xdc,0xdc },
+ { 0x66,0x44,0x22,0x22 }, { 0x7e,0x54,0x2a,0x2a },
+ { 0xab,0x3b,0x90,0x90 }, { 0x83,0x0b,0x88,0x88 },
+ { 0xca,0x8c,0x46,0x46 }, { 0x29,0xc7,0xee,0xee },
+ { 0xd3,0x6b,0xb8,0xb8 }, { 0x3c,0x28,0x14,0x14 },
+ { 0x79,0xa7,0xde,0xde }, { 0xe2,0xbc,0x5e,0x5e },
+ { 0x1d,0x16,0x0b,0x0b }, { 0x76,0xad,0xdb,0xdb },
+ { 0x3b,0xdb,0xe0,0xe0 }, { 0x56,0x64,0x32,0x32 },
+ { 0x4e,0x74,0x3a,0x3a }, { 0x1e,0x14,0x0a,0x0a },
+ { 0xdb,0x92,0x49,0x49 }, { 0x0a,0x0c,0x06,0x06 },
+ { 0x6c,0x48,0x24,0x24 }, { 0xe4,0xb8,0x5c,0x5c },
+ { 0x5d,0x9f,0xc2,0xc2 }, { 0x6e,0xbd,0xd3,0xd3 },
+ { 0xef,0x43,0xac,0xac }, { 0xa6,0xc4,0x62,0x62 },
+ { 0xa8,0x39,0x91,0x91 }, { 0xa4,0x31,0x95,0x95 },
+ { 0x37,0xd3,0xe4,0xe4 }, { 0x8b,0xf2,0x79,0x79 },
+ { 0x32,0xd5,0xe7,0xe7 }, { 0x43,0x8b,0xc8,0xc8 },
+ { 0x59,0x6e,0x37,0x37 }, { 0xb7,0xda,0x6d,0x6d },
+ { 0x8c,0x01,0x8d,0x8d }, { 0x64,0xb1,0xd5,0xd5 },
+ { 0xd2,0x9c,0x4e,0x4e }, { 0xe0,0x49,0xa9,0xa9 },
+ { 0xb4,0xd8,0x6c,0x6c }, { 0xfa,0xac,0x56,0x56 },
+ { 0x07,0xf3,0xf4,0xf4 }, { 0x25,0xcf,0xea,0xea },
+ { 0xaf,0xca,0x65,0x65 }, { 0x8e,0xf4,0x7a,0x7a },
+ { 0xe9,0x47,0xae,0xae }, { 0x18,0x10,0x08,0x08 },
+ { 0xd5,0x6f,0xba,0xba }, { 0x88,0xf0,0x78,0x78 },
+ { 0x6f,0x4a,0x25,0x25 }, { 0x72,0x5c,0x2e,0x2e },
+ { 0x24,0x38,0x1c,0x1c }, { 0xf1,0x57,0xa6,0xa6 },
+ { 0xc7,0x73,0xb4,0xb4 }, { 0x51,0x97,0xc6,0xc6 },
+ { 0x23,0xcb,0xe8,0xe8 }, { 0x7c,0xa1,0xdd,0xdd },
+ { 0x9c,0xe8,0x74,0x74 }, { 0x21,0x3e,0x1f,0x1f },
+ { 0xdd,0x96,0x4b,0x4b }, { 0xdc,0x61,0xbd,0xbd },
+ { 0x86,0x0d,0x8b,0x8b }, { 0x85,0x0f,0x8a,0x8a },
+ { 0x90,0xe0,0x70,0x70 }, { 0x42,0x7c,0x3e,0x3e },
+ { 0xc4,0x71,0xb5,0xb5 }, { 0xaa,0xcc,0x66,0x66 },
+ { 0xd8,0x90,0x48,0x48 }, { 0x05,0x06,0x03,0x03 },
+ { 0x01,0xf7,0xf6,0xf6 }, { 0x12,0x1c,0x0e,0x0e },
+ { 0xa3,0xc2,0x61,0x61 }, { 0x5f,0x6a,0x35,0x35 },
+ { 0xf9,0xae,0x57,0x57 }, { 0xd0,0x69,0xb9,0xb9 },
+ { 0x91,0x17,0x86,0x86 }, { 0x58,0x99,0xc1,0xc1 },
+ { 0x27,0x3a,0x1d,0x1d }, { 0xb9,0x27,0x9e,0x9e },
+ { 0x38,0xd9,0xe1,0xe1 }, { 0x13,0xeb,0xf8,0xf8 },
+ { 0xb3,0x2b,0x98,0x98 }, { 0x33,0x22,0x11,0x11 },
+ { 0xbb,0xd2,0x69,0x69 }, { 0x70,0xa9,0xd9,0xd9 },
+ { 0x89,0x07,0x8e,0x8e }, { 0xa7,0x33,0x94,0x94 },
+ { 0xb6,0x2d,0x9b,0x9b }, { 0x22,0x3c,0x1e,0x1e },
+ { 0x92,0x15,0x87,0x87 }, { 0x20,0xc9,0xe9,0xe9 },
+ { 0x49,0x87,0xce,0xce }, { 0xff,0xaa,0x55,0x55 },
+ { 0x78,0x50,0x28,0x28 }, { 0x7a,0xa5,0xdf,0xdf },
+ { 0x8f,0x03,0x8c,0x8c }, { 0xf8,0x59,0xa1,0xa1 },
+ { 0x80,0x09,0x89,0x89 }, { 0x17,0x1a,0x0d,0x0d },
+ { 0xda,0x65,0xbf,0xbf }, { 0x31,0xd7,0xe6,0xe6 },
+ { 0xc6,0x84,0x42,0x42 }, { 0xb8,0xd0,0x68,0x68 },
+ { 0xc3,0x82,0x41,0x41 }, { 0xb0,0x29,0x99,0x99 },
+ { 0x77,0x5a,0x2d,0x2d }, { 0x11,0x1e,0x0f,0x0f },
+ { 0xcb,0x7b,0xb0,0xb0 }, { 0xfc,0xa8,0x54,0x54 },
+ { 0xd6,0x6d,0xbb,0xbb }, { 0x3a,0x2c,0x16,0x16 }
+ };
+
+static const unsigned char T3[256][4] =
+ {
+ { 0x63,0xa5,0xc6,0x63 }, { 0x7c,0x84,0xf8,0x7c },
+ { 0x77,0x99,0xee,0x77 }, { 0x7b,0x8d,0xf6,0x7b },
+ { 0xf2,0x0d,0xff,0xf2 }, { 0x6b,0xbd,0xd6,0x6b },
+ { 0x6f,0xb1,0xde,0x6f }, { 0xc5,0x54,0x91,0xc5 },
+ { 0x30,0x50,0x60,0x30 }, { 0x01,0x03,0x02,0x01 },
+ { 0x67,0xa9,0xce,0x67 }, { 0x2b,0x7d,0x56,0x2b },
+ { 0xfe,0x19,0xe7,0xfe }, { 0xd7,0x62,0xb5,0xd7 },
+ { 0xab,0xe6,0x4d,0xab }, { 0x76,0x9a,0xec,0x76 },
+ { 0xca,0x45,0x8f,0xca }, { 0x82,0x9d,0x1f,0x82 },
+ { 0xc9,0x40,0x89,0xc9 }, { 0x7d,0x87,0xfa,0x7d },
+ { 0xfa,0x15,0xef,0xfa }, { 0x59,0xeb,0xb2,0x59 },
+ { 0x47,0xc9,0x8e,0x47 }, { 0xf0,0x0b,0xfb,0xf0 },
+ { 0xad,0xec,0x41,0xad }, { 0xd4,0x67,0xb3,0xd4 },
+ { 0xa2,0xfd,0x5f,0xa2 }, { 0xaf,0xea,0x45,0xaf },
+ { 0x9c,0xbf,0x23,0x9c }, { 0xa4,0xf7,0x53,0xa4 },
+ { 0x72,0x96,0xe4,0x72 }, { 0xc0,0x5b,0x9b,0xc0 },
+ { 0xb7,0xc2,0x75,0xb7 }, { 0xfd,0x1c,0xe1,0xfd },
+ { 0x93,0xae,0x3d,0x93 }, { 0x26,0x6a,0x4c,0x26 },
+ { 0x36,0x5a,0x6c,0x36 }, { 0x3f,0x41,0x7e,0x3f },
+ { 0xf7,0x02,0xf5,0xf7 }, { 0xcc,0x4f,0x83,0xcc },
+ { 0x34,0x5c,0x68,0x34 }, { 0xa5,0xf4,0x51,0xa5 },
+ { 0xe5,0x34,0xd1,0xe5 }, { 0xf1,0x08,0xf9,0xf1 },
+ { 0x71,0x93,0xe2,0x71 }, { 0xd8,0x73,0xab,0xd8 },
+ { 0x31,0x53,0x62,0x31 }, { 0x15,0x3f,0x2a,0x15 },
+ { 0x04,0x0c,0x08,0x04 }, { 0xc7,0x52,0x95,0xc7 },
+ { 0x23,0x65,0x46,0x23 }, { 0xc3,0x5e,0x9d,0xc3 },
+ { 0x18,0x28,0x30,0x18 }, { 0x96,0xa1,0x37,0x96 },
+ { 0x05,0x0f,0x0a,0x05 }, { 0x9a,0xb5,0x2f,0x9a },
+ { 0x07,0x09,0x0e,0x07 }, { 0x12,0x36,0x24,0x12 },
+ { 0x80,0x9b,0x1b,0x80 }, { 0xe2,0x3d,0xdf,0xe2 },
+ { 0xeb,0x26,0xcd,0xeb }, { 0x27,0x69,0x4e,0x27 },
+ { 0xb2,0xcd,0x7f,0xb2 }, { 0x75,0x9f,0xea,0x75 },
+ { 0x09,0x1b,0x12,0x09 }, { 0x83,0x9e,0x1d,0x83 },
+ { 0x2c,0x74,0x58,0x2c }, { 0x1a,0x2e,0x34,0x1a },
+ { 0x1b,0x2d,0x36,0x1b }, { 0x6e,0xb2,0xdc,0x6e },
+ { 0x5a,0xee,0xb4,0x5a }, { 0xa0,0xfb,0x5b,0xa0 },
+ { 0x52,0xf6,0xa4,0x52 }, { 0x3b,0x4d,0x76,0x3b },
+ { 0xd6,0x61,0xb7,0xd6 }, { 0xb3,0xce,0x7d,0xb3 },
+ { 0x29,0x7b,0x52,0x29 }, { 0xe3,0x3e,0xdd,0xe3 },
+ { 0x2f,0x71,0x5e,0x2f }, { 0x84,0x97,0x13,0x84 },
+ { 0x53,0xf5,0xa6,0x53 }, { 0xd1,0x68,0xb9,0xd1 },
+ { 0x00,0x00,0x00,0x00 }, { 0xed,0x2c,0xc1,0xed },
+ { 0x20,0x60,0x40,0x20 }, { 0xfc,0x1f,0xe3,0xfc },
+ { 0xb1,0xc8,0x79,0xb1 }, { 0x5b,0xed,0xb6,0x5b },
+ { 0x6a,0xbe,0xd4,0x6a }, { 0xcb,0x46,0x8d,0xcb },
+ { 0xbe,0xd9,0x67,0xbe }, { 0x39,0x4b,0x72,0x39 },
+ { 0x4a,0xde,0x94,0x4a }, { 0x4c,0xd4,0x98,0x4c },
+ { 0x58,0xe8,0xb0,0x58 }, { 0xcf,0x4a,0x85,0xcf },
+ { 0xd0,0x6b,0xbb,0xd0 }, { 0xef,0x2a,0xc5,0xef },
+ { 0xaa,0xe5,0x4f,0xaa }, { 0xfb,0x16,0xed,0xfb },
+ { 0x43,0xc5,0x86,0x43 }, { 0x4d,0xd7,0x9a,0x4d },
+ { 0x33,0x55,0x66,0x33 }, { 0x85,0x94,0x11,0x85 },
+ { 0x45,0xcf,0x8a,0x45 }, { 0xf9,0x10,0xe9,0xf9 },
+ { 0x02,0x06,0x04,0x02 }, { 0x7f,0x81,0xfe,0x7f },
+ { 0x50,0xf0,0xa0,0x50 }, { 0x3c,0x44,0x78,0x3c },
+ { 0x9f,0xba,0x25,0x9f }, { 0xa8,0xe3,0x4b,0xa8 },
+ { 0x51,0xf3,0xa2,0x51 }, { 0xa3,0xfe,0x5d,0xa3 },
+ { 0x40,0xc0,0x80,0x40 }, { 0x8f,0x8a,0x05,0x8f },
+ { 0x92,0xad,0x3f,0x92 }, { 0x9d,0xbc,0x21,0x9d },
+ { 0x38,0x48,0x70,0x38 }, { 0xf5,0x04,0xf1,0xf5 },
+ { 0xbc,0xdf,0x63,0xbc }, { 0xb6,0xc1,0x77,0xb6 },
+ { 0xda,0x75,0xaf,0xda }, { 0x21,0x63,0x42,0x21 },
+ { 0x10,0x30,0x20,0x10 }, { 0xff,0x1a,0xe5,0xff },
+ { 0xf3,0x0e,0xfd,0xf3 }, { 0xd2,0x6d,0xbf,0xd2 },
+ { 0xcd,0x4c,0x81,0xcd }, { 0x0c,0x14,0x18,0x0c },
+ { 0x13,0x35,0x26,0x13 }, { 0xec,0x2f,0xc3,0xec },
+ { 0x5f,0xe1,0xbe,0x5f }, { 0x97,0xa2,0x35,0x97 },
+ { 0x44,0xcc,0x88,0x44 }, { 0x17,0x39,0x2e,0x17 },
+ { 0xc4,0x57,0x93,0xc4 }, { 0xa7,0xf2,0x55,0xa7 },
+ { 0x7e,0x82,0xfc,0x7e }, { 0x3d,0x47,0x7a,0x3d },
+ { 0x64,0xac,0xc8,0x64 }, { 0x5d,0xe7,0xba,0x5d },
+ { 0x19,0x2b,0x32,0x19 }, { 0x73,0x95,0xe6,0x73 },
+ { 0x60,0xa0,0xc0,0x60 }, { 0x81,0x98,0x19,0x81 },
+ { 0x4f,0xd1,0x9e,0x4f }, { 0xdc,0x7f,0xa3,0xdc },
+ { 0x22,0x66,0x44,0x22 }, { 0x2a,0x7e,0x54,0x2a },
+ { 0x90,0xab,0x3b,0x90 }, { 0x88,0x83,0x0b,0x88 },
+ { 0x46,0xca,0x8c,0x46 }, { 0xee,0x29,0xc7,0xee },
+ { 0xb8,0xd3,0x6b,0xb8 }, { 0x14,0x3c,0x28,0x14 },
+ { 0xde,0x79,0xa7,0xde }, { 0x5e,0xe2,0xbc,0x5e },
+ { 0x0b,0x1d,0x16,0x0b }, { 0xdb,0x76,0xad,0xdb },
+ { 0xe0,0x3b,0xdb,0xe0 }, { 0x32,0x56,0x64,0x32 },
+ { 0x3a,0x4e,0x74,0x3a }, { 0x0a,0x1e,0x14,0x0a },
+ { 0x49,0xdb,0x92,0x49 }, { 0x06,0x0a,0x0c,0x06 },
+ { 0x24,0x6c,0x48,0x24 }, { 0x5c,0xe4,0xb8,0x5c },
+ { 0xc2,0x5d,0x9f,0xc2 }, { 0xd3,0x6e,0xbd,0xd3 },
+ { 0xac,0xef,0x43,0xac }, { 0x62,0xa6,0xc4,0x62 },
+ { 0x91,0xa8,0x39,0x91 }, { 0x95,0xa4,0x31,0x95 },
+ { 0xe4,0x37,0xd3,0xe4 }, { 0x79,0x8b,0xf2,0x79 },
+ { 0xe7,0x32,0xd5,0xe7 }, { 0xc8,0x43,0x8b,0xc8 },
+ { 0x37,0x59,0x6e,0x37 }, { 0x6d,0xb7,0xda,0x6d },
+ { 0x8d,0x8c,0x01,0x8d }, { 0xd5,0x64,0xb1,0xd5 },
+ { 0x4e,0xd2,0x9c,0x4e }, { 0xa9,0xe0,0x49,0xa9 },
+ { 0x6c,0xb4,0xd8,0x6c }, { 0x56,0xfa,0xac,0x56 },
+ { 0xf4,0x07,0xf3,0xf4 }, { 0xea,0x25,0xcf,0xea },
+ { 0x65,0xaf,0xca,0x65 }, { 0x7a,0x8e,0xf4,0x7a },
+ { 0xae,0xe9,0x47,0xae }, { 0x08,0x18,0x10,0x08 },
+ { 0xba,0xd5,0x6f,0xba }, { 0x78,0x88,0xf0,0x78 },
+ { 0x25,0x6f,0x4a,0x25 }, { 0x2e,0x72,0x5c,0x2e },
+ { 0x1c,0x24,0x38,0x1c }, { 0xa6,0xf1,0x57,0xa6 },
+ { 0xb4,0xc7,0x73,0xb4 }, { 0xc6,0x51,0x97,0xc6 },
+ { 0xe8,0x23,0xcb,0xe8 }, { 0xdd,0x7c,0xa1,0xdd },
+ { 0x74,0x9c,0xe8,0x74 }, { 0x1f,0x21,0x3e,0x1f },
+ { 0x4b,0xdd,0x96,0x4b }, { 0xbd,0xdc,0x61,0xbd },
+ { 0x8b,0x86,0x0d,0x8b }, { 0x8a,0x85,0x0f,0x8a },
+ { 0x70,0x90,0xe0,0x70 }, { 0x3e,0x42,0x7c,0x3e },
+ { 0xb5,0xc4,0x71,0xb5 }, { 0x66,0xaa,0xcc,0x66 },
+ { 0x48,0xd8,0x90,0x48 }, { 0x03,0x05,0x06,0x03 },
+ { 0xf6,0x01,0xf7,0xf6 }, { 0x0e,0x12,0x1c,0x0e },
+ { 0x61,0xa3,0xc2,0x61 }, { 0x35,0x5f,0x6a,0x35 },
+ { 0x57,0xf9,0xae,0x57 }, { 0xb9,0xd0,0x69,0xb9 },
+ { 0x86,0x91,0x17,0x86 }, { 0xc1,0x58,0x99,0xc1 },
+ { 0x1d,0x27,0x3a,0x1d }, { 0x9e,0xb9,0x27,0x9e },
+ { 0xe1,0x38,0xd9,0xe1 }, { 0xf8,0x13,0xeb,0xf8 },
+ { 0x98,0xb3,0x2b,0x98 }, { 0x11,0x33,0x22,0x11 },
+ { 0x69,0xbb,0xd2,0x69 }, { 0xd9,0x70,0xa9,0xd9 },
+ { 0x8e,0x89,0x07,0x8e }, { 0x94,0xa7,0x33,0x94 },
+ { 0x9b,0xb6,0x2d,0x9b }, { 0x1e,0x22,0x3c,0x1e },
+ { 0x87,0x92,0x15,0x87 }, { 0xe9,0x20,0xc9,0xe9 },
+ { 0xce,0x49,0x87,0xce }, { 0x55,0xff,0xaa,0x55 },
+ { 0x28,0x78,0x50,0x28 }, { 0xdf,0x7a,0xa5,0xdf },
+ { 0x8c,0x8f,0x03,0x8c }, { 0xa1,0xf8,0x59,0xa1 },
+ { 0x89,0x80,0x09,0x89 }, { 0x0d,0x17,0x1a,0x0d },
+ { 0xbf,0xda,0x65,0xbf }, { 0xe6,0x31,0xd7,0xe6 },
+ { 0x42,0xc6,0x84,0x42 }, { 0x68,0xb8,0xd0,0x68 },
+ { 0x41,0xc3,0x82,0x41 }, { 0x99,0xb0,0x29,0x99 },
+ { 0x2d,0x77,0x5a,0x2d }, { 0x0f,0x11,0x1e,0x0f },
+ { 0xb0,0xcb,0x7b,0xb0 }, { 0x54,0xfc,0xa8,0x54 },
+ { 0xbb,0xd6,0x6d,0xbb }, { 0x16,0x3a,0x2c,0x16 }
+ };
+
+static const unsigned char T4[256][4] =
+ {
+ { 0x63,0x63,0xa5,0xc6 }, { 0x7c,0x7c,0x84,0xf8 },
+ { 0x77,0x77,0x99,0xee }, { 0x7b,0x7b,0x8d,0xf6 },
+ { 0xf2,0xf2,0x0d,0xff }, { 0x6b,0x6b,0xbd,0xd6 },
+ { 0x6f,0x6f,0xb1,0xde }, { 0xc5,0xc5,0x54,0x91 },
+ { 0x30,0x30,0x50,0x60 }, { 0x01,0x01,0x03,0x02 },
+ { 0x67,0x67,0xa9,0xce }, { 0x2b,0x2b,0x7d,0x56 },
+ { 0xfe,0xfe,0x19,0xe7 }, { 0xd7,0xd7,0x62,0xb5 },
+ { 0xab,0xab,0xe6,0x4d }, { 0x76,0x76,0x9a,0xec },
+ { 0xca,0xca,0x45,0x8f }, { 0x82,0x82,0x9d,0x1f },
+ { 0xc9,0xc9,0x40,0x89 }, { 0x7d,0x7d,0x87,0xfa },
+ { 0xfa,0xfa,0x15,0xef }, { 0x59,0x59,0xeb,0xb2 },
+ { 0x47,0x47,0xc9,0x8e }, { 0xf0,0xf0,0x0b,0xfb },
+ { 0xad,0xad,0xec,0x41 }, { 0xd4,0xd4,0x67,0xb3 },
+ { 0xa2,0xa2,0xfd,0x5f }, { 0xaf,0xaf,0xea,0x45 },
+ { 0x9c,0x9c,0xbf,0x23 }, { 0xa4,0xa4,0xf7,0x53 },
+ { 0x72,0x72,0x96,0xe4 }, { 0xc0,0xc0,0x5b,0x9b },
+ { 0xb7,0xb7,0xc2,0x75 }, { 0xfd,0xfd,0x1c,0xe1 },
+ { 0x93,0x93,0xae,0x3d }, { 0x26,0x26,0x6a,0x4c },
+ { 0x36,0x36,0x5a,0x6c }, { 0x3f,0x3f,0x41,0x7e },
+ { 0xf7,0xf7,0x02,0xf5 }, { 0xcc,0xcc,0x4f,0x83 },
+ { 0x34,0x34,0x5c,0x68 }, { 0xa5,0xa5,0xf4,0x51 },
+ { 0xe5,0xe5,0x34,0xd1 }, { 0xf1,0xf1,0x08,0xf9 },
+ { 0x71,0x71,0x93,0xe2 }, { 0xd8,0xd8,0x73,0xab },
+ { 0x31,0x31,0x53,0x62 }, { 0x15,0x15,0x3f,0x2a },
+ { 0x04,0x04,0x0c,0x08 }, { 0xc7,0xc7,0x52,0x95 },
+ { 0x23,0x23,0x65,0x46 }, { 0xc3,0xc3,0x5e,0x9d },
+ { 0x18,0x18,0x28,0x30 }, { 0x96,0x96,0xa1,0x37 },
+ { 0x05,0x05,0x0f,0x0a }, { 0x9a,0x9a,0xb5,0x2f },
+ { 0x07,0x07,0x09,0x0e }, { 0x12,0x12,0x36,0x24 },
+ { 0x80,0x80,0x9b,0x1b }, { 0xe2,0xe2,0x3d,0xdf },
+ { 0xeb,0xeb,0x26,0xcd }, { 0x27,0x27,0x69,0x4e },
+ { 0xb2,0xb2,0xcd,0x7f }, { 0x75,0x75,0x9f,0xea },
+ { 0x09,0x09,0x1b,0x12 }, { 0x83,0x83,0x9e,0x1d },
+ { 0x2c,0x2c,0x74,0x58 }, { 0x1a,0x1a,0x2e,0x34 },
+ { 0x1b,0x1b,0x2d,0x36 }, { 0x6e,0x6e,0xb2,0xdc },
+ { 0x5a,0x5a,0xee,0xb4 }, { 0xa0,0xa0,0xfb,0x5b },
+ { 0x52,0x52,0xf6,0xa4 }, { 0x3b,0x3b,0x4d,0x76 },
+ { 0xd6,0xd6,0x61,0xb7 }, { 0xb3,0xb3,0xce,0x7d },
+ { 0x29,0x29,0x7b,0x52 }, { 0xe3,0xe3,0x3e,0xdd },
+ { 0x2f,0x2f,0x71,0x5e }, { 0x84,0x84,0x97,0x13 },
+ { 0x53,0x53,0xf5,0xa6 }, { 0xd1,0xd1,0x68,0xb9 },
+ { 0x00,0x00,0x00,0x00 }, { 0xed,0xed,0x2c,0xc1 },
+ { 0x20,0x20,0x60,0x40 }, { 0xfc,0xfc,0x1f,0xe3 },
+ { 0xb1,0xb1,0xc8,0x79 }, { 0x5b,0x5b,0xed,0xb6 },
+ { 0x6a,0x6a,0xbe,0xd4 }, { 0xcb,0xcb,0x46,0x8d },
+ { 0xbe,0xbe,0xd9,0x67 }, { 0x39,0x39,0x4b,0x72 },
+ { 0x4a,0x4a,0xde,0x94 }, { 0x4c,0x4c,0xd4,0x98 },
+ { 0x58,0x58,0xe8,0xb0 }, { 0xcf,0xcf,0x4a,0x85 },
+ { 0xd0,0xd0,0x6b,0xbb }, { 0xef,0xef,0x2a,0xc5 },
+ { 0xaa,0xaa,0xe5,0x4f }, { 0xfb,0xfb,0x16,0xed },
+ { 0x43,0x43,0xc5,0x86 }, { 0x4d,0x4d,0xd7,0x9a },
+ { 0x33,0x33,0x55,0x66 }, { 0x85,0x85,0x94,0x11 },
+ { 0x45,0x45,0xcf,0x8a }, { 0xf9,0xf9,0x10,0xe9 },
+ { 0x02,0x02,0x06,0x04 }, { 0x7f,0x7f,0x81,0xfe },
+ { 0x50,0x50,0xf0,0xa0 }, { 0x3c,0x3c,0x44,0x78 },
+ { 0x9f,0x9f,0xba,0x25 }, { 0xa8,0xa8,0xe3,0x4b },
+ { 0x51,0x51,0xf3,0xa2 }, { 0xa3,0xa3,0xfe,0x5d },
+ { 0x40,0x40,0xc0,0x80 }, { 0x8f,0x8f,0x8a,0x05 },
+ { 0x92,0x92,0xad,0x3f }, { 0x9d,0x9d,0xbc,0x21 },
+ { 0x38,0x38,0x48,0x70 }, { 0xf5,0xf5,0x04,0xf1 },
+ { 0xbc,0xbc,0xdf,0x63 }, { 0xb6,0xb6,0xc1,0x77 },
+ { 0xda,0xda,0x75,0xaf }, { 0x21,0x21,0x63,0x42 },
+ { 0x10,0x10,0x30,0x20 }, { 0xff,0xff,0x1a,0xe5 },
+ { 0xf3,0xf3,0x0e,0xfd }, { 0xd2,0xd2,0x6d,0xbf },
+ { 0xcd,0xcd,0x4c,0x81 }, { 0x0c,0x0c,0x14,0x18 },
+ { 0x13,0x13,0x35,0x26 }, { 0xec,0xec,0x2f,0xc3 },
+ { 0x5f,0x5f,0xe1,0xbe }, { 0x97,0x97,0xa2,0x35 },
+ { 0x44,0x44,0xcc,0x88 }, { 0x17,0x17,0x39,0x2e },
+ { 0xc4,0xc4,0x57,0x93 }, { 0xa7,0xa7,0xf2,0x55 },
+ { 0x7e,0x7e,0x82,0xfc }, { 0x3d,0x3d,0x47,0x7a },
+ { 0x64,0x64,0xac,0xc8 }, { 0x5d,0x5d,0xe7,0xba },
+ { 0x19,0x19,0x2b,0x32 }, { 0x73,0x73,0x95,0xe6 },
+ { 0x60,0x60,0xa0,0xc0 }, { 0x81,0x81,0x98,0x19 },
+ { 0x4f,0x4f,0xd1,0x9e }, { 0xdc,0xdc,0x7f,0xa3 },
+ { 0x22,0x22,0x66,0x44 }, { 0x2a,0x2a,0x7e,0x54 },
+ { 0x90,0x90,0xab,0x3b }, { 0x88,0x88,0x83,0x0b },
+ { 0x46,0x46,0xca,0x8c }, { 0xee,0xee,0x29,0xc7 },
+ { 0xb8,0xb8,0xd3,0x6b }, { 0x14,0x14,0x3c,0x28 },
+ { 0xde,0xde,0x79,0xa7 }, { 0x5e,0x5e,0xe2,0xbc },
+ { 0x0b,0x0b,0x1d,0x16 }, { 0xdb,0xdb,0x76,0xad },
+ { 0xe0,0xe0,0x3b,0xdb }, { 0x32,0x32,0x56,0x64 },
+ { 0x3a,0x3a,0x4e,0x74 }, { 0x0a,0x0a,0x1e,0x14 },
+ { 0x49,0x49,0xdb,0x92 }, { 0x06,0x06,0x0a,0x0c },
+ { 0x24,0x24,0x6c,0x48 }, { 0x5c,0x5c,0xe4,0xb8 },
+ { 0xc2,0xc2,0x5d,0x9f }, { 0xd3,0xd3,0x6e,0xbd },
+ { 0xac,0xac,0xef,0x43 }, { 0x62,0x62,0xa6,0xc4 },
+ { 0x91,0x91,0xa8,0x39 }, { 0x95,0x95,0xa4,0x31 },
+ { 0xe4,0xe4,0x37,0xd3 }, { 0x79,0x79,0x8b,0xf2 },
+ { 0xe7,0xe7,0x32,0xd5 }, { 0xc8,0xc8,0x43,0x8b },
+ { 0x37,0x37,0x59,0x6e }, { 0x6d,0x6d,0xb7,0xda },
+ { 0x8d,0x8d,0x8c,0x01 }, { 0xd5,0xd5,0x64,0xb1 },
+ { 0x4e,0x4e,0xd2,0x9c }, { 0xa9,0xa9,0xe0,0x49 },
+ { 0x6c,0x6c,0xb4,0xd8 }, { 0x56,0x56,0xfa,0xac },
+ { 0xf4,0xf4,0x07,0xf3 }, { 0xea,0xea,0x25,0xcf },
+ { 0x65,0x65,0xaf,0xca }, { 0x7a,0x7a,0x8e,0xf4 },
+ { 0xae,0xae,0xe9,0x47 }, { 0x08,0x08,0x18,0x10 },
+ { 0xba,0xba,0xd5,0x6f }, { 0x78,0x78,0x88,0xf0 },
+ { 0x25,0x25,0x6f,0x4a }, { 0x2e,0x2e,0x72,0x5c },
+ { 0x1c,0x1c,0x24,0x38 }, { 0xa6,0xa6,0xf1,0x57 },
+ { 0xb4,0xb4,0xc7,0x73 }, { 0xc6,0xc6,0x51,0x97 },
+ { 0xe8,0xe8,0x23,0xcb }, { 0xdd,0xdd,0x7c,0xa1 },
+ { 0x74,0x74,0x9c,0xe8 }, { 0x1f,0x1f,0x21,0x3e },
+ { 0x4b,0x4b,0xdd,0x96 }, { 0xbd,0xbd,0xdc,0x61 },
+ { 0x8b,0x8b,0x86,0x0d }, { 0x8a,0x8a,0x85,0x0f },
+ { 0x70,0x70,0x90,0xe0 }, { 0x3e,0x3e,0x42,0x7c },
+ { 0xb5,0xb5,0xc4,0x71 }, { 0x66,0x66,0xaa,0xcc },
+ { 0x48,0x48,0xd8,0x90 }, { 0x03,0x03,0x05,0x06 },
+ { 0xf6,0xf6,0x01,0xf7 }, { 0x0e,0x0e,0x12,0x1c },
+ { 0x61,0x61,0xa3,0xc2 }, { 0x35,0x35,0x5f,0x6a },
+ { 0x57,0x57,0xf9,0xae }, { 0xb9,0xb9,0xd0,0x69 },
+ { 0x86,0x86,0x91,0x17 }, { 0xc1,0xc1,0x58,0x99 },
+ { 0x1d,0x1d,0x27,0x3a }, { 0x9e,0x9e,0xb9,0x27 },
+ { 0xe1,0xe1,0x38,0xd9 }, { 0xf8,0xf8,0x13,0xeb },
+ { 0x98,0x98,0xb3,0x2b }, { 0x11,0x11,0x33,0x22 },
+ { 0x69,0x69,0xbb,0xd2 }, { 0xd9,0xd9,0x70,0xa9 },
+ { 0x8e,0x8e,0x89,0x07 }, { 0x94,0x94,0xa7,0x33 },
+ { 0x9b,0x9b,0xb6,0x2d }, { 0x1e,0x1e,0x22,0x3c },
+ { 0x87,0x87,0x92,0x15 }, { 0xe9,0xe9,0x20,0xc9 },
+ { 0xce,0xce,0x49,0x87 }, { 0x55,0x55,0xff,0xaa },
+ { 0x28,0x28,0x78,0x50 }, { 0xdf,0xdf,0x7a,0xa5 },
+ { 0x8c,0x8c,0x8f,0x03 }, { 0xa1,0xa1,0xf8,0x59 },
+ { 0x89,0x89,0x80,0x09 }, { 0x0d,0x0d,0x17,0x1a },
+ { 0xbf,0xbf,0xda,0x65 }, { 0xe6,0xe6,0x31,0xd7 },
+ { 0x42,0x42,0xc6,0x84 }, { 0x68,0x68,0xb8,0xd0 },
+ { 0x41,0x41,0xc3,0x82 }, { 0x99,0x99,0xb0,0x29 },
+ { 0x2d,0x2d,0x77,0x5a }, { 0x0f,0x0f,0x11,0x1e },
+ { 0xb0,0xb0,0xcb,0x7b }, { 0x54,0x54,0xfc,0xa8 },
+ { 0xbb,0xbb,0xd6,0x6d }, { 0x16,0x16,0x3a,0x2c }
+ };
+
+static const unsigned char T5[256][4] =
+ {
+ { 0x51,0xf4,0xa7,0x50 }, { 0x7e,0x41,0x65,0x53 },
+ { 0x1a,0x17,0xa4,0xc3 }, { 0x3a,0x27,0x5e,0x96 },
+ { 0x3b,0xab,0x6b,0xcb }, { 0x1f,0x9d,0x45,0xf1 },
+ { 0xac,0xfa,0x58,0xab }, { 0x4b,0xe3,0x03,0x93 },
+ { 0x20,0x30,0xfa,0x55 }, { 0xad,0x76,0x6d,0xf6 },
+ { 0x88,0xcc,0x76,0x91 }, { 0xf5,0x02,0x4c,0x25 },
+ { 0x4f,0xe5,0xd7,0xfc }, { 0xc5,0x2a,0xcb,0xd7 },
+ { 0x26,0x35,0x44,0x80 }, { 0xb5,0x62,0xa3,0x8f },
+ { 0xde,0xb1,0x5a,0x49 }, { 0x25,0xba,0x1b,0x67 },
+ { 0x45,0xea,0x0e,0x98 }, { 0x5d,0xfe,0xc0,0xe1 },
+ { 0xc3,0x2f,0x75,0x02 }, { 0x81,0x4c,0xf0,0x12 },
+ { 0x8d,0x46,0x97,0xa3 }, { 0x6b,0xd3,0xf9,0xc6 },
+ { 0x03,0x8f,0x5f,0xe7 }, { 0x15,0x92,0x9c,0x95 },
+ { 0xbf,0x6d,0x7a,0xeb }, { 0x95,0x52,0x59,0xda },
+ { 0xd4,0xbe,0x83,0x2d }, { 0x58,0x74,0x21,0xd3 },
+ { 0x49,0xe0,0x69,0x29 }, { 0x8e,0xc9,0xc8,0x44 },
+ { 0x75,0xc2,0x89,0x6a }, { 0xf4,0x8e,0x79,0x78 },
+ { 0x99,0x58,0x3e,0x6b }, { 0x27,0xb9,0x71,0xdd },
+ { 0xbe,0xe1,0x4f,0xb6 }, { 0xf0,0x88,0xad,0x17 },
+ { 0xc9,0x20,0xac,0x66 }, { 0x7d,0xce,0x3a,0xb4 },
+ { 0x63,0xdf,0x4a,0x18 }, { 0xe5,0x1a,0x31,0x82 },
+ { 0x97,0x51,0x33,0x60 }, { 0x62,0x53,0x7f,0x45 },
+ { 0xb1,0x64,0x77,0xe0 }, { 0xbb,0x6b,0xae,0x84 },
+ { 0xfe,0x81,0xa0,0x1c }, { 0xf9,0x08,0x2b,0x94 },
+ { 0x70,0x48,0x68,0x58 }, { 0x8f,0x45,0xfd,0x19 },
+ { 0x94,0xde,0x6c,0x87 }, { 0x52,0x7b,0xf8,0xb7 },
+ { 0xab,0x73,0xd3,0x23 }, { 0x72,0x4b,0x02,0xe2 },
+ { 0xe3,0x1f,0x8f,0x57 }, { 0x66,0x55,0xab,0x2a },
+ { 0xb2,0xeb,0x28,0x07 }, { 0x2f,0xb5,0xc2,0x03 },
+ { 0x86,0xc5,0x7b,0x9a }, { 0xd3,0x37,0x08,0xa5 },
+ { 0x30,0x28,0x87,0xf2 }, { 0x23,0xbf,0xa5,0xb2 },
+ { 0x02,0x03,0x6a,0xba }, { 0xed,0x16,0x82,0x5c },
+ { 0x8a,0xcf,0x1c,0x2b }, { 0xa7,0x79,0xb4,0x92 },
+ { 0xf3,0x07,0xf2,0xf0 }, { 0x4e,0x69,0xe2,0xa1 },
+ { 0x65,0xda,0xf4,0xcd }, { 0x06,0x05,0xbe,0xd5 },
+ { 0xd1,0x34,0x62,0x1f }, { 0xc4,0xa6,0xfe,0x8a },
+ { 0x34,0x2e,0x53,0x9d }, { 0xa2,0xf3,0x55,0xa0 },
+ { 0x05,0x8a,0xe1,0x32 }, { 0xa4,0xf6,0xeb,0x75 },
+ { 0x0b,0x83,0xec,0x39 }, { 0x40,0x60,0xef,0xaa },
+ { 0x5e,0x71,0x9f,0x06 }, { 0xbd,0x6e,0x10,0x51 },
+ { 0x3e,0x21,0x8a,0xf9 }, { 0x96,0xdd,0x06,0x3d },
+ { 0xdd,0x3e,0x05,0xae }, { 0x4d,0xe6,0xbd,0x46 },
+ { 0x91,0x54,0x8d,0xb5 }, { 0x71,0xc4,0x5d,0x05 },
+ { 0x04,0x06,0xd4,0x6f }, { 0x60,0x50,0x15,0xff },
+ { 0x19,0x98,0xfb,0x24 }, { 0xd6,0xbd,0xe9,0x97 },
+ { 0x89,0x40,0x43,0xcc }, { 0x67,0xd9,0x9e,0x77 },
+ { 0xb0,0xe8,0x42,0xbd }, { 0x07,0x89,0x8b,0x88 },
+ { 0xe7,0x19,0x5b,0x38 }, { 0x79,0xc8,0xee,0xdb },
+ { 0xa1,0x7c,0x0a,0x47 }, { 0x7c,0x42,0x0f,0xe9 },
+ { 0xf8,0x84,0x1e,0xc9 }, { 0x00,0x00,0x00,0x00 },
+ { 0x09,0x80,0x86,0x83 }, { 0x32,0x2b,0xed,0x48 },
+ { 0x1e,0x11,0x70,0xac }, { 0x6c,0x5a,0x72,0x4e },
+ { 0xfd,0x0e,0xff,0xfb }, { 0x0f,0x85,0x38,0x56 },
+ { 0x3d,0xae,0xd5,0x1e }, { 0x36,0x2d,0x39,0x27 },
+ { 0x0a,0x0f,0xd9,0x64 }, { 0x68,0x5c,0xa6,0x21 },
+ { 0x9b,0x5b,0x54,0xd1 }, { 0x24,0x36,0x2e,0x3a },
+ { 0x0c,0x0a,0x67,0xb1 }, { 0x93,0x57,0xe7,0x0f },
+ { 0xb4,0xee,0x96,0xd2 }, { 0x1b,0x9b,0x91,0x9e },
+ { 0x80,0xc0,0xc5,0x4f }, { 0x61,0xdc,0x20,0xa2 },
+ { 0x5a,0x77,0x4b,0x69 }, { 0x1c,0x12,0x1a,0x16 },
+ { 0xe2,0x93,0xba,0x0a }, { 0xc0,0xa0,0x2a,0xe5 },
+ { 0x3c,0x22,0xe0,0x43 }, { 0x12,0x1b,0x17,0x1d },
+ { 0x0e,0x09,0x0d,0x0b }, { 0xf2,0x8b,0xc7,0xad },
+ { 0x2d,0xb6,0xa8,0xb9 }, { 0x14,0x1e,0xa9,0xc8 },
+ { 0x57,0xf1,0x19,0x85 }, { 0xaf,0x75,0x07,0x4c },
+ { 0xee,0x99,0xdd,0xbb }, { 0xa3,0x7f,0x60,0xfd },
+ { 0xf7,0x01,0x26,0x9f }, { 0x5c,0x72,0xf5,0xbc },
+ { 0x44,0x66,0x3b,0xc5 }, { 0x5b,0xfb,0x7e,0x34 },
+ { 0x8b,0x43,0x29,0x76 }, { 0xcb,0x23,0xc6,0xdc },
+ { 0xb6,0xed,0xfc,0x68 }, { 0xb8,0xe4,0xf1,0x63 },
+ { 0xd7,0x31,0xdc,0xca }, { 0x42,0x63,0x85,0x10 },
+ { 0x13,0x97,0x22,0x40 }, { 0x84,0xc6,0x11,0x20 },
+ { 0x85,0x4a,0x24,0x7d }, { 0xd2,0xbb,0x3d,0xf8 },
+ { 0xae,0xf9,0x32,0x11 }, { 0xc7,0x29,0xa1,0x6d },
+ { 0x1d,0x9e,0x2f,0x4b }, { 0xdc,0xb2,0x30,0xf3 },
+ { 0x0d,0x86,0x52,0xec }, { 0x77,0xc1,0xe3,0xd0 },
+ { 0x2b,0xb3,0x16,0x6c }, { 0xa9,0x70,0xb9,0x99 },
+ { 0x11,0x94,0x48,0xfa }, { 0x47,0xe9,0x64,0x22 },
+ { 0xa8,0xfc,0x8c,0xc4 }, { 0xa0,0xf0,0x3f,0x1a },
+ { 0x56,0x7d,0x2c,0xd8 }, { 0x22,0x33,0x90,0xef },
+ { 0x87,0x49,0x4e,0xc7 }, { 0xd9,0x38,0xd1,0xc1 },
+ { 0x8c,0xca,0xa2,0xfe }, { 0x98,0xd4,0x0b,0x36 },
+ { 0xa6,0xf5,0x81,0xcf }, { 0xa5,0x7a,0xde,0x28 },
+ { 0xda,0xb7,0x8e,0x26 }, { 0x3f,0xad,0xbf,0xa4 },
+ { 0x2c,0x3a,0x9d,0xe4 }, { 0x50,0x78,0x92,0x0d },
+ { 0x6a,0x5f,0xcc,0x9b }, { 0x54,0x7e,0x46,0x62 },
+ { 0xf6,0x8d,0x13,0xc2 }, { 0x90,0xd8,0xb8,0xe8 },
+ { 0x2e,0x39,0xf7,0x5e }, { 0x82,0xc3,0xaf,0xf5 },
+ { 0x9f,0x5d,0x80,0xbe }, { 0x69,0xd0,0x93,0x7c },
+ { 0x6f,0xd5,0x2d,0xa9 }, { 0xcf,0x25,0x12,0xb3 },
+ { 0xc8,0xac,0x99,0x3b }, { 0x10,0x18,0x7d,0xa7 },
+ { 0xe8,0x9c,0x63,0x6e }, { 0xdb,0x3b,0xbb,0x7b },
+ { 0xcd,0x26,0x78,0x09 }, { 0x6e,0x59,0x18,0xf4 },
+ { 0xec,0x9a,0xb7,0x01 }, { 0x83,0x4f,0x9a,0xa8 },
+ { 0xe6,0x95,0x6e,0x65 }, { 0xaa,0xff,0xe6,0x7e },
+ { 0x21,0xbc,0xcf,0x08 }, { 0xef,0x15,0xe8,0xe6 },
+ { 0xba,0xe7,0x9b,0xd9 }, { 0x4a,0x6f,0x36,0xce },
+ { 0xea,0x9f,0x09,0xd4 }, { 0x29,0xb0,0x7c,0xd6 },
+ { 0x31,0xa4,0xb2,0xaf }, { 0x2a,0x3f,0x23,0x31 },
+ { 0xc6,0xa5,0x94,0x30 }, { 0x35,0xa2,0x66,0xc0 },
+ { 0x74,0x4e,0xbc,0x37 }, { 0xfc,0x82,0xca,0xa6 },
+ { 0xe0,0x90,0xd0,0xb0 }, { 0x33,0xa7,0xd8,0x15 },
+ { 0xf1,0x04,0x98,0x4a }, { 0x41,0xec,0xda,0xf7 },
+ { 0x7f,0xcd,0x50,0x0e }, { 0x17,0x91,0xf6,0x2f },
+ { 0x76,0x4d,0xd6,0x8d }, { 0x43,0xef,0xb0,0x4d },
+ { 0xcc,0xaa,0x4d,0x54 }, { 0xe4,0x96,0x04,0xdf },
+ { 0x9e,0xd1,0xb5,0xe3 }, { 0x4c,0x6a,0x88,0x1b },
+ { 0xc1,0x2c,0x1f,0xb8 }, { 0x46,0x65,0x51,0x7f },
+ { 0x9d,0x5e,0xea,0x04 }, { 0x01,0x8c,0x35,0x5d },
+ { 0xfa,0x87,0x74,0x73 }, { 0xfb,0x0b,0x41,0x2e },
+ { 0xb3,0x67,0x1d,0x5a }, { 0x92,0xdb,0xd2,0x52 },
+ { 0xe9,0x10,0x56,0x33 }, { 0x6d,0xd6,0x47,0x13 },
+ { 0x9a,0xd7,0x61,0x8c }, { 0x37,0xa1,0x0c,0x7a },
+ { 0x59,0xf8,0x14,0x8e }, { 0xeb,0x13,0x3c,0x89 },
+ { 0xce,0xa9,0x27,0xee }, { 0xb7,0x61,0xc9,0x35 },
+ { 0xe1,0x1c,0xe5,0xed }, { 0x7a,0x47,0xb1,0x3c },
+ { 0x9c,0xd2,0xdf,0x59 }, { 0x55,0xf2,0x73,0x3f },
+ { 0x18,0x14,0xce,0x79 }, { 0x73,0xc7,0x37,0xbf },
+ { 0x53,0xf7,0xcd,0xea }, { 0x5f,0xfd,0xaa,0x5b },
+ { 0xdf,0x3d,0x6f,0x14 }, { 0x78,0x44,0xdb,0x86 },
+ { 0xca,0xaf,0xf3,0x81 }, { 0xb9,0x68,0xc4,0x3e },
+ { 0x38,0x24,0x34,0x2c }, { 0xc2,0xa3,0x40,0x5f },
+ { 0x16,0x1d,0xc3,0x72 }, { 0xbc,0xe2,0x25,0x0c },
+ { 0x28,0x3c,0x49,0x8b }, { 0xff,0x0d,0x95,0x41 },
+ { 0x39,0xa8,0x01,0x71 }, { 0x08,0x0c,0xb3,0xde },
+ { 0xd8,0xb4,0xe4,0x9c }, { 0x64,0x56,0xc1,0x90 },
+ { 0x7b,0xcb,0x84,0x61 }, { 0xd5,0x32,0xb6,0x70 },
+ { 0x48,0x6c,0x5c,0x74 }, { 0xd0,0xb8,0x57,0x42 }
+ };
+
+static const unsigned char T6[256][4] =
+ {
+ { 0x50,0x51,0xf4,0xa7 }, { 0x53,0x7e,0x41,0x65 },
+ { 0xc3,0x1a,0x17,0xa4 }, { 0x96,0x3a,0x27,0x5e },
+ { 0xcb,0x3b,0xab,0x6b }, { 0xf1,0x1f,0x9d,0x45 },
+ { 0xab,0xac,0xfa,0x58 }, { 0x93,0x4b,0xe3,0x03 },
+ { 0x55,0x20,0x30,0xfa }, { 0xf6,0xad,0x76,0x6d },
+ { 0x91,0x88,0xcc,0x76 }, { 0x25,0xf5,0x02,0x4c },
+ { 0xfc,0x4f,0xe5,0xd7 }, { 0xd7,0xc5,0x2a,0xcb },
+ { 0x80,0x26,0x35,0x44 }, { 0x8f,0xb5,0x62,0xa3 },
+ { 0x49,0xde,0xb1,0x5a }, { 0x67,0x25,0xba,0x1b },
+ { 0x98,0x45,0xea,0x0e }, { 0xe1,0x5d,0xfe,0xc0 },
+ { 0x02,0xc3,0x2f,0x75 }, { 0x12,0x81,0x4c,0xf0 },
+ { 0xa3,0x8d,0x46,0x97 }, { 0xc6,0x6b,0xd3,0xf9 },
+ { 0xe7,0x03,0x8f,0x5f }, { 0x95,0x15,0x92,0x9c },
+ { 0xeb,0xbf,0x6d,0x7a }, { 0xda,0x95,0x52,0x59 },
+ { 0x2d,0xd4,0xbe,0x83 }, { 0xd3,0x58,0x74,0x21 },
+ { 0x29,0x49,0xe0,0x69 }, { 0x44,0x8e,0xc9,0xc8 },
+ { 0x6a,0x75,0xc2,0x89 }, { 0x78,0xf4,0x8e,0x79 },
+ { 0x6b,0x99,0x58,0x3e }, { 0xdd,0x27,0xb9,0x71 },
+ { 0xb6,0xbe,0xe1,0x4f }, { 0x17,0xf0,0x88,0xad },
+ { 0x66,0xc9,0x20,0xac }, { 0xb4,0x7d,0xce,0x3a },
+ { 0x18,0x63,0xdf,0x4a }, { 0x82,0xe5,0x1a,0x31 },
+ { 0x60,0x97,0x51,0x33 }, { 0x45,0x62,0x53,0x7f },
+ { 0xe0,0xb1,0x64,0x77 }, { 0x84,0xbb,0x6b,0xae },
+ { 0x1c,0xfe,0x81,0xa0 }, { 0x94,0xf9,0x08,0x2b },
+ { 0x58,0x70,0x48,0x68 }, { 0x19,0x8f,0x45,0xfd },
+ { 0x87,0x94,0xde,0x6c }, { 0xb7,0x52,0x7b,0xf8 },
+ { 0x23,0xab,0x73,0xd3 }, { 0xe2,0x72,0x4b,0x02 },
+ { 0x57,0xe3,0x1f,0x8f }, { 0x2a,0x66,0x55,0xab },
+ { 0x07,0xb2,0xeb,0x28 }, { 0x03,0x2f,0xb5,0xc2 },
+ { 0x9a,0x86,0xc5,0x7b }, { 0xa5,0xd3,0x37,0x08 },
+ { 0xf2,0x30,0x28,0x87 }, { 0xb2,0x23,0xbf,0xa5 },
+ { 0xba,0x02,0x03,0x6a }, { 0x5c,0xed,0x16,0x82 },
+ { 0x2b,0x8a,0xcf,0x1c }, { 0x92,0xa7,0x79,0xb4 },
+ { 0xf0,0xf3,0x07,0xf2 }, { 0xa1,0x4e,0x69,0xe2 },
+ { 0xcd,0x65,0xda,0xf4 }, { 0xd5,0x06,0x05,0xbe },
+ { 0x1f,0xd1,0x34,0x62 }, { 0x8a,0xc4,0xa6,0xfe },
+ { 0x9d,0x34,0x2e,0x53 }, { 0xa0,0xa2,0xf3,0x55 },
+ { 0x32,0x05,0x8a,0xe1 }, { 0x75,0xa4,0xf6,0xeb },
+ { 0x39,0x0b,0x83,0xec }, { 0xaa,0x40,0x60,0xef },
+ { 0x06,0x5e,0x71,0x9f }, { 0x51,0xbd,0x6e,0x10 },
+ { 0xf9,0x3e,0x21,0x8a }, { 0x3d,0x96,0xdd,0x06 },
+ { 0xae,0xdd,0x3e,0x05 }, { 0x46,0x4d,0xe6,0xbd },
+ { 0xb5,0x91,0x54,0x8d }, { 0x05,0x71,0xc4,0x5d },
+ { 0x6f,0x04,0x06,0xd4 }, { 0xff,0x60,0x50,0x15 },
+ { 0x24,0x19,0x98,0xfb }, { 0x97,0xd6,0xbd,0xe9 },
+ { 0xcc,0x89,0x40,0x43 }, { 0x77,0x67,0xd9,0x9e },
+ { 0xbd,0xb0,0xe8,0x42 }, { 0x88,0x07,0x89,0x8b },
+ { 0x38,0xe7,0x19,0x5b }, { 0xdb,0x79,0xc8,0xee },
+ { 0x47,0xa1,0x7c,0x0a }, { 0xe9,0x7c,0x42,0x0f },
+ { 0xc9,0xf8,0x84,0x1e }, { 0x00,0x00,0x00,0x00 },
+ { 0x83,0x09,0x80,0x86 }, { 0x48,0x32,0x2b,0xed },
+ { 0xac,0x1e,0x11,0x70 }, { 0x4e,0x6c,0x5a,0x72 },
+ { 0xfb,0xfd,0x0e,0xff }, { 0x56,0x0f,0x85,0x38 },
+ { 0x1e,0x3d,0xae,0xd5 }, { 0x27,0x36,0x2d,0x39 },
+ { 0x64,0x0a,0x0f,0xd9 }, { 0x21,0x68,0x5c,0xa6 },
+ { 0xd1,0x9b,0x5b,0x54 }, { 0x3a,0x24,0x36,0x2e },
+ { 0xb1,0x0c,0x0a,0x67 }, { 0x0f,0x93,0x57,0xe7 },
+ { 0xd2,0xb4,0xee,0x96 }, { 0x9e,0x1b,0x9b,0x91 },
+ { 0x4f,0x80,0xc0,0xc5 }, { 0xa2,0x61,0xdc,0x20 },
+ { 0x69,0x5a,0x77,0x4b }, { 0x16,0x1c,0x12,0x1a },
+ { 0x0a,0xe2,0x93,0xba }, { 0xe5,0xc0,0xa0,0x2a },
+ { 0x43,0x3c,0x22,0xe0 }, { 0x1d,0x12,0x1b,0x17 },
+ { 0x0b,0x0e,0x09,0x0d }, { 0xad,0xf2,0x8b,0xc7 },
+ { 0xb9,0x2d,0xb6,0xa8 }, { 0xc8,0x14,0x1e,0xa9 },
+ { 0x85,0x57,0xf1,0x19 }, { 0x4c,0xaf,0x75,0x07 },
+ { 0xbb,0xee,0x99,0xdd }, { 0xfd,0xa3,0x7f,0x60 },
+ { 0x9f,0xf7,0x01,0x26 }, { 0xbc,0x5c,0x72,0xf5 },
+ { 0xc5,0x44,0x66,0x3b }, { 0x34,0x5b,0xfb,0x7e },
+ { 0x76,0x8b,0x43,0x29 }, { 0xdc,0xcb,0x23,0xc6 },
+ { 0x68,0xb6,0xed,0xfc }, { 0x63,0xb8,0xe4,0xf1 },
+ { 0xca,0xd7,0x31,0xdc }, { 0x10,0x42,0x63,0x85 },
+ { 0x40,0x13,0x97,0x22 }, { 0x20,0x84,0xc6,0x11 },
+ { 0x7d,0x85,0x4a,0x24 }, { 0xf8,0xd2,0xbb,0x3d },
+ { 0x11,0xae,0xf9,0x32 }, { 0x6d,0xc7,0x29,0xa1 },
+ { 0x4b,0x1d,0x9e,0x2f }, { 0xf3,0xdc,0xb2,0x30 },
+ { 0xec,0x0d,0x86,0x52 }, { 0xd0,0x77,0xc1,0xe3 },
+ { 0x6c,0x2b,0xb3,0x16 }, { 0x99,0xa9,0x70,0xb9 },
+ { 0xfa,0x11,0x94,0x48 }, { 0x22,0x47,0xe9,0x64 },
+ { 0xc4,0xa8,0xfc,0x8c }, { 0x1a,0xa0,0xf0,0x3f },
+ { 0xd8,0x56,0x7d,0x2c }, { 0xef,0x22,0x33,0x90 },
+ { 0xc7,0x87,0x49,0x4e }, { 0xc1,0xd9,0x38,0xd1 },
+ { 0xfe,0x8c,0xca,0xa2 }, { 0x36,0x98,0xd4,0x0b },
+ { 0xcf,0xa6,0xf5,0x81 }, { 0x28,0xa5,0x7a,0xde },
+ { 0x26,0xda,0xb7,0x8e }, { 0xa4,0x3f,0xad,0xbf },
+ { 0xe4,0x2c,0x3a,0x9d }, { 0x0d,0x50,0x78,0x92 },
+ { 0x9b,0x6a,0x5f,0xcc }, { 0x62,0x54,0x7e,0x46 },
+ { 0xc2,0xf6,0x8d,0x13 }, { 0xe8,0x90,0xd8,0xb8 },
+ { 0x5e,0x2e,0x39,0xf7 }, { 0xf5,0x82,0xc3,0xaf },
+ { 0xbe,0x9f,0x5d,0x80 }, { 0x7c,0x69,0xd0,0x93 },
+ { 0xa9,0x6f,0xd5,0x2d }, { 0xb3,0xcf,0x25,0x12 },
+ { 0x3b,0xc8,0xac,0x99 }, { 0xa7,0x10,0x18,0x7d },
+ { 0x6e,0xe8,0x9c,0x63 }, { 0x7b,0xdb,0x3b,0xbb },
+ { 0x09,0xcd,0x26,0x78 }, { 0xf4,0x6e,0x59,0x18 },
+ { 0x01,0xec,0x9a,0xb7 }, { 0xa8,0x83,0x4f,0x9a },
+ { 0x65,0xe6,0x95,0x6e }, { 0x7e,0xaa,0xff,0xe6 },
+ { 0x08,0x21,0xbc,0xcf }, { 0xe6,0xef,0x15,0xe8 },
+ { 0xd9,0xba,0xe7,0x9b }, { 0xce,0x4a,0x6f,0x36 },
+ { 0xd4,0xea,0x9f,0x09 }, { 0xd6,0x29,0xb0,0x7c },
+ { 0xaf,0x31,0xa4,0xb2 }, { 0x31,0x2a,0x3f,0x23 },
+ { 0x30,0xc6,0xa5,0x94 }, { 0xc0,0x35,0xa2,0x66 },
+ { 0x37,0x74,0x4e,0xbc }, { 0xa6,0xfc,0x82,0xca },
+ { 0xb0,0xe0,0x90,0xd0 }, { 0x15,0x33,0xa7,0xd8 },
+ { 0x4a,0xf1,0x04,0x98 }, { 0xf7,0x41,0xec,0xda },
+ { 0x0e,0x7f,0xcd,0x50 }, { 0x2f,0x17,0x91,0xf6 },
+ { 0x8d,0x76,0x4d,0xd6 }, { 0x4d,0x43,0xef,0xb0 },
+ { 0x54,0xcc,0xaa,0x4d }, { 0xdf,0xe4,0x96,0x04 },
+ { 0xe3,0x9e,0xd1,0xb5 }, { 0x1b,0x4c,0x6a,0x88 },
+ { 0xb8,0xc1,0x2c,0x1f }, { 0x7f,0x46,0x65,0x51 },
+ { 0x04,0x9d,0x5e,0xea }, { 0x5d,0x01,0x8c,0x35 },
+ { 0x73,0xfa,0x87,0x74 }, { 0x2e,0xfb,0x0b,0x41 },
+ { 0x5a,0xb3,0x67,0x1d }, { 0x52,0x92,0xdb,0xd2 },
+ { 0x33,0xe9,0x10,0x56 }, { 0x13,0x6d,0xd6,0x47 },
+ { 0x8c,0x9a,0xd7,0x61 }, { 0x7a,0x37,0xa1,0x0c },
+ { 0x8e,0x59,0xf8,0x14 }, { 0x89,0xeb,0x13,0x3c },
+ { 0xee,0xce,0xa9,0x27 }, { 0x35,0xb7,0x61,0xc9 },
+ { 0xed,0xe1,0x1c,0xe5 }, { 0x3c,0x7a,0x47,0xb1 },
+ { 0x59,0x9c,0xd2,0xdf }, { 0x3f,0x55,0xf2,0x73 },
+ { 0x79,0x18,0x14,0xce }, { 0xbf,0x73,0xc7,0x37 },
+ { 0xea,0x53,0xf7,0xcd }, { 0x5b,0x5f,0xfd,0xaa },
+ { 0x14,0xdf,0x3d,0x6f }, { 0x86,0x78,0x44,0xdb },
+ { 0x81,0xca,0xaf,0xf3 }, { 0x3e,0xb9,0x68,0xc4 },
+ { 0x2c,0x38,0x24,0x34 }, { 0x5f,0xc2,0xa3,0x40 },
+ { 0x72,0x16,0x1d,0xc3 }, { 0x0c,0xbc,0xe2,0x25 },
+ { 0x8b,0x28,0x3c,0x49 }, { 0x41,0xff,0x0d,0x95 },
+ { 0x71,0x39,0xa8,0x01 }, { 0xde,0x08,0x0c,0xb3 },
+ { 0x9c,0xd8,0xb4,0xe4 }, { 0x90,0x64,0x56,0xc1 },
+ { 0x61,0x7b,0xcb,0x84 }, { 0x70,0xd5,0x32,0xb6 },
+ { 0x74,0x48,0x6c,0x5c }, { 0x42,0xd0,0xb8,0x57 }
+ };
+
+static const unsigned char T7[256][4] =
+ {
+ { 0xa7,0x50,0x51,0xf4 }, { 0x65,0x53,0x7e,0x41 },
+ { 0xa4,0xc3,0x1a,0x17 }, { 0x5e,0x96,0x3a,0x27 },
+ { 0x6b,0xcb,0x3b,0xab }, { 0x45,0xf1,0x1f,0x9d },
+ { 0x58,0xab,0xac,0xfa }, { 0x03,0x93,0x4b,0xe3 },
+ { 0xfa,0x55,0x20,0x30 }, { 0x6d,0xf6,0xad,0x76 },
+ { 0x76,0x91,0x88,0xcc }, { 0x4c,0x25,0xf5,0x02 },
+ { 0xd7,0xfc,0x4f,0xe5 }, { 0xcb,0xd7,0xc5,0x2a },
+ { 0x44,0x80,0x26,0x35 }, { 0xa3,0x8f,0xb5,0x62 },
+ { 0x5a,0x49,0xde,0xb1 }, { 0x1b,0x67,0x25,0xba },
+ { 0x0e,0x98,0x45,0xea }, { 0xc0,0xe1,0x5d,0xfe },
+ { 0x75,0x02,0xc3,0x2f }, { 0xf0,0x12,0x81,0x4c },
+ { 0x97,0xa3,0x8d,0x46 }, { 0xf9,0xc6,0x6b,0xd3 },
+ { 0x5f,0xe7,0x03,0x8f }, { 0x9c,0x95,0x15,0x92 },
+ { 0x7a,0xeb,0xbf,0x6d }, { 0x59,0xda,0x95,0x52 },
+ { 0x83,0x2d,0xd4,0xbe }, { 0x21,0xd3,0x58,0x74 },
+ { 0x69,0x29,0x49,0xe0 }, { 0xc8,0x44,0x8e,0xc9 },
+ { 0x89,0x6a,0x75,0xc2 }, { 0x79,0x78,0xf4,0x8e },
+ { 0x3e,0x6b,0x99,0x58 }, { 0x71,0xdd,0x27,0xb9 },
+ { 0x4f,0xb6,0xbe,0xe1 }, { 0xad,0x17,0xf0,0x88 },
+ { 0xac,0x66,0xc9,0x20 }, { 0x3a,0xb4,0x7d,0xce },
+ { 0x4a,0x18,0x63,0xdf }, { 0x31,0x82,0xe5,0x1a },
+ { 0x33,0x60,0x97,0x51 }, { 0x7f,0x45,0x62,0x53 },
+ { 0x77,0xe0,0xb1,0x64 }, { 0xae,0x84,0xbb,0x6b },
+ { 0xa0,0x1c,0xfe,0x81 }, { 0x2b,0x94,0xf9,0x08 },
+ { 0x68,0x58,0x70,0x48 }, { 0xfd,0x19,0x8f,0x45 },
+ { 0x6c,0x87,0x94,0xde }, { 0xf8,0xb7,0x52,0x7b },
+ { 0xd3,0x23,0xab,0x73 }, { 0x02,0xe2,0x72,0x4b },
+ { 0x8f,0x57,0xe3,0x1f }, { 0xab,0x2a,0x66,0x55 },
+ { 0x28,0x07,0xb2,0xeb }, { 0xc2,0x03,0x2f,0xb5 },
+ { 0x7b,0x9a,0x86,0xc5 }, { 0x08,0xa5,0xd3,0x37 },
+ { 0x87,0xf2,0x30,0x28 }, { 0xa5,0xb2,0x23,0xbf },
+ { 0x6a,0xba,0x02,0x03 }, { 0x82,0x5c,0xed,0x16 },
+ { 0x1c,0x2b,0x8a,0xcf }, { 0xb4,0x92,0xa7,0x79 },
+ { 0xf2,0xf0,0xf3,0x07 }, { 0xe2,0xa1,0x4e,0x69 },
+ { 0xf4,0xcd,0x65,0xda }, { 0xbe,0xd5,0x06,0x05 },
+ { 0x62,0x1f,0xd1,0x34 }, { 0xfe,0x8a,0xc4,0xa6 },
+ { 0x53,0x9d,0x34,0x2e }, { 0x55,0xa0,0xa2,0xf3 },
+ { 0xe1,0x32,0x05,0x8a }, { 0xeb,0x75,0xa4,0xf6 },
+ { 0xec,0x39,0x0b,0x83 }, { 0xef,0xaa,0x40,0x60 },
+ { 0x9f,0x06,0x5e,0x71 }, { 0x10,0x51,0xbd,0x6e },
+ { 0x8a,0xf9,0x3e,0x21 }, { 0x06,0x3d,0x96,0xdd },
+ { 0x05,0xae,0xdd,0x3e }, { 0xbd,0x46,0x4d,0xe6 },
+ { 0x8d,0xb5,0x91,0x54 }, { 0x5d,0x05,0x71,0xc4 },
+ { 0xd4,0x6f,0x04,0x06 }, { 0x15,0xff,0x60,0x50 },
+ { 0xfb,0x24,0x19,0x98 }, { 0xe9,0x97,0xd6,0xbd },
+ { 0x43,0xcc,0x89,0x40 }, { 0x9e,0x77,0x67,0xd9 },
+ { 0x42,0xbd,0xb0,0xe8 }, { 0x8b,0x88,0x07,0x89 },
+ { 0x5b,0x38,0xe7,0x19 }, { 0xee,0xdb,0x79,0xc8 },
+ { 0x0a,0x47,0xa1,0x7c }, { 0x0f,0xe9,0x7c,0x42 },
+ { 0x1e,0xc9,0xf8,0x84 }, { 0x00,0x00,0x00,0x00 },
+ { 0x86,0x83,0x09,0x80 }, { 0xed,0x48,0x32,0x2b },
+ { 0x70,0xac,0x1e,0x11 }, { 0x72,0x4e,0x6c,0x5a },
+ { 0xff,0xfb,0xfd,0x0e }, { 0x38,0x56,0x0f,0x85 },
+ { 0xd5,0x1e,0x3d,0xae }, { 0x39,0x27,0x36,0x2d },
+ { 0xd9,0x64,0x0a,0x0f }, { 0xa6,0x21,0x68,0x5c },
+ { 0x54,0xd1,0x9b,0x5b }, { 0x2e,0x3a,0x24,0x36 },
+ { 0x67,0xb1,0x0c,0x0a }, { 0xe7,0x0f,0x93,0x57 },
+ { 0x96,0xd2,0xb4,0xee }, { 0x91,0x9e,0x1b,0x9b },
+ { 0xc5,0x4f,0x80,0xc0 }, { 0x20,0xa2,0x61,0xdc },
+ { 0x4b,0x69,0x5a,0x77 }, { 0x1a,0x16,0x1c,0x12 },
+ { 0xba,0x0a,0xe2,0x93 }, { 0x2a,0xe5,0xc0,0xa0 },
+ { 0xe0,0x43,0x3c,0x22 }, { 0x17,0x1d,0x12,0x1b },
+ { 0x0d,0x0b,0x0e,0x09 }, { 0xc7,0xad,0xf2,0x8b },
+ { 0xa8,0xb9,0x2d,0xb6 }, { 0xa9,0xc8,0x14,0x1e },
+ { 0x19,0x85,0x57,0xf1 }, { 0x07,0x4c,0xaf,0x75 },
+ { 0xdd,0xbb,0xee,0x99 }, { 0x60,0xfd,0xa3,0x7f },
+ { 0x26,0x9f,0xf7,0x01 }, { 0xf5,0xbc,0x5c,0x72 },
+ { 0x3b,0xc5,0x44,0x66 }, { 0x7e,0x34,0x5b,0xfb },
+ { 0x29,0x76,0x8b,0x43 }, { 0xc6,0xdc,0xcb,0x23 },
+ { 0xfc,0x68,0xb6,0xed }, { 0xf1,0x63,0xb8,0xe4 },
+ { 0xdc,0xca,0xd7,0x31 }, { 0x85,0x10,0x42,0x63 },
+ { 0x22,0x40,0x13,0x97 }, { 0x11,0x20,0x84,0xc6 },
+ { 0x24,0x7d,0x85,0x4a }, { 0x3d,0xf8,0xd2,0xbb },
+ { 0x32,0x11,0xae,0xf9 }, { 0xa1,0x6d,0xc7,0x29 },
+ { 0x2f,0x4b,0x1d,0x9e }, { 0x30,0xf3,0xdc,0xb2 },
+ { 0x52,0xec,0x0d,0x86 }, { 0xe3,0xd0,0x77,0xc1 },
+ { 0x16,0x6c,0x2b,0xb3 }, { 0xb9,0x99,0xa9,0x70 },
+ { 0x48,0xfa,0x11,0x94 }, { 0x64,0x22,0x47,0xe9 },
+ { 0x8c,0xc4,0xa8,0xfc }, { 0x3f,0x1a,0xa0,0xf0 },
+ { 0x2c,0xd8,0x56,0x7d }, { 0x90,0xef,0x22,0x33 },
+ { 0x4e,0xc7,0x87,0x49 }, { 0xd1,0xc1,0xd9,0x38 },
+ { 0xa2,0xfe,0x8c,0xca }, { 0x0b,0x36,0x98,0xd4 },
+ { 0x81,0xcf,0xa6,0xf5 }, { 0xde,0x28,0xa5,0x7a },
+ { 0x8e,0x26,0xda,0xb7 }, { 0xbf,0xa4,0x3f,0xad },
+ { 0x9d,0xe4,0x2c,0x3a }, { 0x92,0x0d,0x50,0x78 },
+ { 0xcc,0x9b,0x6a,0x5f }, { 0x46,0x62,0x54,0x7e },
+ { 0x13,0xc2,0xf6,0x8d }, { 0xb8,0xe8,0x90,0xd8 },
+ { 0xf7,0x5e,0x2e,0x39 }, { 0xaf,0xf5,0x82,0xc3 },
+ { 0x80,0xbe,0x9f,0x5d }, { 0x93,0x7c,0x69,0xd0 },
+ { 0x2d,0xa9,0x6f,0xd5 }, { 0x12,0xb3,0xcf,0x25 },
+ { 0x99,0x3b,0xc8,0xac }, { 0x7d,0xa7,0x10,0x18 },
+ { 0x63,0x6e,0xe8,0x9c }, { 0xbb,0x7b,0xdb,0x3b },
+ { 0x78,0x09,0xcd,0x26 }, { 0x18,0xf4,0x6e,0x59 },
+ { 0xb7,0x01,0xec,0x9a }, { 0x9a,0xa8,0x83,0x4f },
+ { 0x6e,0x65,0xe6,0x95 }, { 0xe6,0x7e,0xaa,0xff },
+ { 0xcf,0x08,0x21,0xbc }, { 0xe8,0xe6,0xef,0x15 },
+ { 0x9b,0xd9,0xba,0xe7 }, { 0x36,0xce,0x4a,0x6f },
+ { 0x09,0xd4,0xea,0x9f }, { 0x7c,0xd6,0x29,0xb0 },
+ { 0xb2,0xaf,0x31,0xa4 }, { 0x23,0x31,0x2a,0x3f },
+ { 0x94,0x30,0xc6,0xa5 }, { 0x66,0xc0,0x35,0xa2 },
+ { 0xbc,0x37,0x74,0x4e }, { 0xca,0xa6,0xfc,0x82 },
+ { 0xd0,0xb0,0xe0,0x90 }, { 0xd8,0x15,0x33,0xa7 },
+ { 0x98,0x4a,0xf1,0x04 }, { 0xda,0xf7,0x41,0xec },
+ { 0x50,0x0e,0x7f,0xcd }, { 0xf6,0x2f,0x17,0x91 },
+ { 0xd6,0x8d,0x76,0x4d }, { 0xb0,0x4d,0x43,0xef },
+ { 0x4d,0x54,0xcc,0xaa }, { 0x04,0xdf,0xe4,0x96 },
+ { 0xb5,0xe3,0x9e,0xd1 }, { 0x88,0x1b,0x4c,0x6a },
+ { 0x1f,0xb8,0xc1,0x2c }, { 0x51,0x7f,0x46,0x65 },
+ { 0xea,0x04,0x9d,0x5e }, { 0x35,0x5d,0x01,0x8c },
+ { 0x74,0x73,0xfa,0x87 }, { 0x41,0x2e,0xfb,0x0b },
+ { 0x1d,0x5a,0xb3,0x67 }, { 0xd2,0x52,0x92,0xdb },
+ { 0x56,0x33,0xe9,0x10 }, { 0x47,0x13,0x6d,0xd6 },
+ { 0x61,0x8c,0x9a,0xd7 }, { 0x0c,0x7a,0x37,0xa1 },
+ { 0x14,0x8e,0x59,0xf8 }, { 0x3c,0x89,0xeb,0x13 },
+ { 0x27,0xee,0xce,0xa9 }, { 0xc9,0x35,0xb7,0x61 },
+ { 0xe5,0xed,0xe1,0x1c }, { 0xb1,0x3c,0x7a,0x47 },
+ { 0xdf,0x59,0x9c,0xd2 }, { 0x73,0x3f,0x55,0xf2 },
+ { 0xce,0x79,0x18,0x14 }, { 0x37,0xbf,0x73,0xc7 },
+ { 0xcd,0xea,0x53,0xf7 }, { 0xaa,0x5b,0x5f,0xfd },
+ { 0x6f,0x14,0xdf,0x3d }, { 0xdb,0x86,0x78,0x44 },
+ { 0xf3,0x81,0xca,0xaf }, { 0xc4,0x3e,0xb9,0x68 },
+ { 0x34,0x2c,0x38,0x24 }, { 0x40,0x5f,0xc2,0xa3 },
+ { 0xc3,0x72,0x16,0x1d }, { 0x25,0x0c,0xbc,0xe2 },
+ { 0x49,0x8b,0x28,0x3c }, { 0x95,0x41,0xff,0x0d },
+ { 0x01,0x71,0x39,0xa8 }, { 0xb3,0xde,0x08,0x0c },
+ { 0xe4,0x9c,0xd8,0xb4 }, { 0xc1,0x90,0x64,0x56 },
+ { 0x84,0x61,0x7b,0xcb }, { 0xb6,0x70,0xd5,0x32 },
+ { 0x5c,0x74,0x48,0x6c }, { 0x57,0x42,0xd0,0xb8 }
+ };
+
+static const unsigned char T8[256][4] =
+ {
+ { 0xf4,0xa7,0x50,0x51 }, { 0x41,0x65,0x53,0x7e },
+ { 0x17,0xa4,0xc3,0x1a }, { 0x27,0x5e,0x96,0x3a },
+ { 0xab,0x6b,0xcb,0x3b }, { 0x9d,0x45,0xf1,0x1f },
+ { 0xfa,0x58,0xab,0xac }, { 0xe3,0x03,0x93,0x4b },
+ { 0x30,0xfa,0x55,0x20 }, { 0x76,0x6d,0xf6,0xad },
+ { 0xcc,0x76,0x91,0x88 }, { 0x02,0x4c,0x25,0xf5 },
+ { 0xe5,0xd7,0xfc,0x4f }, { 0x2a,0xcb,0xd7,0xc5 },
+ { 0x35,0x44,0x80,0x26 }, { 0x62,0xa3,0x8f,0xb5 },
+ { 0xb1,0x5a,0x49,0xde }, { 0xba,0x1b,0x67,0x25 },
+ { 0xea,0x0e,0x98,0x45 }, { 0xfe,0xc0,0xe1,0x5d },
+ { 0x2f,0x75,0x02,0xc3 }, { 0x4c,0xf0,0x12,0x81 },
+ { 0x46,0x97,0xa3,0x8d }, { 0xd3,0xf9,0xc6,0x6b },
+ { 0x8f,0x5f,0xe7,0x03 }, { 0x92,0x9c,0x95,0x15 },
+ { 0x6d,0x7a,0xeb,0xbf }, { 0x52,0x59,0xda,0x95 },
+ { 0xbe,0x83,0x2d,0xd4 }, { 0x74,0x21,0xd3,0x58 },
+ { 0xe0,0x69,0x29,0x49 }, { 0xc9,0xc8,0x44,0x8e },
+ { 0xc2,0x89,0x6a,0x75 }, { 0x8e,0x79,0x78,0xf4 },
+ { 0x58,0x3e,0x6b,0x99 }, { 0xb9,0x71,0xdd,0x27 },
+ { 0xe1,0x4f,0xb6,0xbe }, { 0x88,0xad,0x17,0xf0 },
+ { 0x20,0xac,0x66,0xc9 }, { 0xce,0x3a,0xb4,0x7d },
+ { 0xdf,0x4a,0x18,0x63 }, { 0x1a,0x31,0x82,0xe5 },
+ { 0x51,0x33,0x60,0x97 }, { 0x53,0x7f,0x45,0x62 },
+ { 0x64,0x77,0xe0,0xb1 }, { 0x6b,0xae,0x84,0xbb },
+ { 0x81,0xa0,0x1c,0xfe }, { 0x08,0x2b,0x94,0xf9 },
+ { 0x48,0x68,0x58,0x70 }, { 0x45,0xfd,0x19,0x8f },
+ { 0xde,0x6c,0x87,0x94 }, { 0x7b,0xf8,0xb7,0x52 },
+ { 0x73,0xd3,0x23,0xab }, { 0x4b,0x02,0xe2,0x72 },
+ { 0x1f,0x8f,0x57,0xe3 }, { 0x55,0xab,0x2a,0x66 },
+ { 0xeb,0x28,0x07,0xb2 }, { 0xb5,0xc2,0x03,0x2f },
+ { 0xc5,0x7b,0x9a,0x86 }, { 0x37,0x08,0xa5,0xd3 },
+ { 0x28,0x87,0xf2,0x30 }, { 0xbf,0xa5,0xb2,0x23 },
+ { 0x03,0x6a,0xba,0x02 }, { 0x16,0x82,0x5c,0xed },
+ { 0xcf,0x1c,0x2b,0x8a }, { 0x79,0xb4,0x92,0xa7 },
+ { 0x07,0xf2,0xf0,0xf3 }, { 0x69,0xe2,0xa1,0x4e },
+ { 0xda,0xf4,0xcd,0x65 }, { 0x05,0xbe,0xd5,0x06 },
+ { 0x34,0x62,0x1f,0xd1 }, { 0xa6,0xfe,0x8a,0xc4 },
+ { 0x2e,0x53,0x9d,0x34 }, { 0xf3,0x55,0xa0,0xa2 },
+ { 0x8a,0xe1,0x32,0x05 }, { 0xf6,0xeb,0x75,0xa4 },
+ { 0x83,0xec,0x39,0x0b }, { 0x60,0xef,0xaa,0x40 },
+ { 0x71,0x9f,0x06,0x5e }, { 0x6e,0x10,0x51,0xbd },
+ { 0x21,0x8a,0xf9,0x3e }, { 0xdd,0x06,0x3d,0x96 },
+ { 0x3e,0x05,0xae,0xdd }, { 0xe6,0xbd,0x46,0x4d },
+ { 0x54,0x8d,0xb5,0x91 }, { 0xc4,0x5d,0x05,0x71 },
+ { 0x06,0xd4,0x6f,0x04 }, { 0x50,0x15,0xff,0x60 },
+ { 0x98,0xfb,0x24,0x19 }, { 0xbd,0xe9,0x97,0xd6 },
+ { 0x40,0x43,0xcc,0x89 }, { 0xd9,0x9e,0x77,0x67 },
+ { 0xe8,0x42,0xbd,0xb0 }, { 0x89,0x8b,0x88,0x07 },
+ { 0x19,0x5b,0x38,0xe7 }, { 0xc8,0xee,0xdb,0x79 },
+ { 0x7c,0x0a,0x47,0xa1 }, { 0x42,0x0f,0xe9,0x7c },
+ { 0x84,0x1e,0xc9,0xf8 }, { 0x00,0x00,0x00,0x00 },
+ { 0x80,0x86,0x83,0x09 }, { 0x2b,0xed,0x48,0x32 },
+ { 0x11,0x70,0xac,0x1e }, { 0x5a,0x72,0x4e,0x6c },
+ { 0x0e,0xff,0xfb,0xfd }, { 0x85,0x38,0x56,0x0f },
+ { 0xae,0xd5,0x1e,0x3d }, { 0x2d,0x39,0x27,0x36 },
+ { 0x0f,0xd9,0x64,0x0a }, { 0x5c,0xa6,0x21,0x68 },
+ { 0x5b,0x54,0xd1,0x9b }, { 0x36,0x2e,0x3a,0x24 },
+ { 0x0a,0x67,0xb1,0x0c }, { 0x57,0xe7,0x0f,0x93 },
+ { 0xee,0x96,0xd2,0xb4 }, { 0x9b,0x91,0x9e,0x1b },
+ { 0xc0,0xc5,0x4f,0x80 }, { 0xdc,0x20,0xa2,0x61 },
+ { 0x77,0x4b,0x69,0x5a }, { 0x12,0x1a,0x16,0x1c },
+ { 0x93,0xba,0x0a,0xe2 }, { 0xa0,0x2a,0xe5,0xc0 },
+ { 0x22,0xe0,0x43,0x3c }, { 0x1b,0x17,0x1d,0x12 },
+ { 0x09,0x0d,0x0b,0x0e }, { 0x8b,0xc7,0xad,0xf2 },
+ { 0xb6,0xa8,0xb9,0x2d }, { 0x1e,0xa9,0xc8,0x14 },
+ { 0xf1,0x19,0x85,0x57 }, { 0x75,0x07,0x4c,0xaf },
+ { 0x99,0xdd,0xbb,0xee }, { 0x7f,0x60,0xfd,0xa3 },
+ { 0x01,0x26,0x9f,0xf7 }, { 0x72,0xf5,0xbc,0x5c },
+ { 0x66,0x3b,0xc5,0x44 }, { 0xfb,0x7e,0x34,0x5b },
+ { 0x43,0x29,0x76,0x8b }, { 0x23,0xc6,0xdc,0xcb },
+ { 0xed,0xfc,0x68,0xb6 }, { 0xe4,0xf1,0x63,0xb8 },
+ { 0x31,0xdc,0xca,0xd7 }, { 0x63,0x85,0x10,0x42 },
+ { 0x97,0x22,0x40,0x13 }, { 0xc6,0x11,0x20,0x84 },
+ { 0x4a,0x24,0x7d,0x85 }, { 0xbb,0x3d,0xf8,0xd2 },
+ { 0xf9,0x32,0x11,0xae }, { 0x29,0xa1,0x6d,0xc7 },
+ { 0x9e,0x2f,0x4b,0x1d }, { 0xb2,0x30,0xf3,0xdc },
+ { 0x86,0x52,0xec,0x0d }, { 0xc1,0xe3,0xd0,0x77 },
+ { 0xb3,0x16,0x6c,0x2b }, { 0x70,0xb9,0x99,0xa9 },
+ { 0x94,0x48,0xfa,0x11 }, { 0xe9,0x64,0x22,0x47 },
+ { 0xfc,0x8c,0xc4,0xa8 }, { 0xf0,0x3f,0x1a,0xa0 },
+ { 0x7d,0x2c,0xd8,0x56 }, { 0x33,0x90,0xef,0x22 },
+ { 0x49,0x4e,0xc7,0x87 }, { 0x38,0xd1,0xc1,0xd9 },
+ { 0xca,0xa2,0xfe,0x8c }, { 0xd4,0x0b,0x36,0x98 },
+ { 0xf5,0x81,0xcf,0xa6 }, { 0x7a,0xde,0x28,0xa5 },
+ { 0xb7,0x8e,0x26,0xda }, { 0xad,0xbf,0xa4,0x3f },
+ { 0x3a,0x9d,0xe4,0x2c }, { 0x78,0x92,0x0d,0x50 },
+ { 0x5f,0xcc,0x9b,0x6a }, { 0x7e,0x46,0x62,0x54 },
+ { 0x8d,0x13,0xc2,0xf6 }, { 0xd8,0xb8,0xe8,0x90 },
+ { 0x39,0xf7,0x5e,0x2e }, { 0xc3,0xaf,0xf5,0x82 },
+ { 0x5d,0x80,0xbe,0x9f }, { 0xd0,0x93,0x7c,0x69 },
+ { 0xd5,0x2d,0xa9,0x6f }, { 0x25,0x12,0xb3,0xcf },
+ { 0xac,0x99,0x3b,0xc8 }, { 0x18,0x7d,0xa7,0x10 },
+ { 0x9c,0x63,0x6e,0xe8 }, { 0x3b,0xbb,0x7b,0xdb },
+ { 0x26,0x78,0x09,0xcd }, { 0x59,0x18,0xf4,0x6e },
+ { 0x9a,0xb7,0x01,0xec }, { 0x4f,0x9a,0xa8,0x83 },
+ { 0x95,0x6e,0x65,0xe6 }, { 0xff,0xe6,0x7e,0xaa },
+ { 0xbc,0xcf,0x08,0x21 }, { 0x15,0xe8,0xe6,0xef },
+ { 0xe7,0x9b,0xd9,0xba }, { 0x6f,0x36,0xce,0x4a },
+ { 0x9f,0x09,0xd4,0xea }, { 0xb0,0x7c,0xd6,0x29 },
+ { 0xa4,0xb2,0xaf,0x31 }, { 0x3f,0x23,0x31,0x2a },
+ { 0xa5,0x94,0x30,0xc6 }, { 0xa2,0x66,0xc0,0x35 },
+ { 0x4e,0xbc,0x37,0x74 }, { 0x82,0xca,0xa6,0xfc },
+ { 0x90,0xd0,0xb0,0xe0 }, { 0xa7,0xd8,0x15,0x33 },
+ { 0x04,0x98,0x4a,0xf1 }, { 0xec,0xda,0xf7,0x41 },
+ { 0xcd,0x50,0x0e,0x7f }, { 0x91,0xf6,0x2f,0x17 },
+ { 0x4d,0xd6,0x8d,0x76 }, { 0xef,0xb0,0x4d,0x43 },
+ { 0xaa,0x4d,0x54,0xcc }, { 0x96,0x04,0xdf,0xe4 },
+ { 0xd1,0xb5,0xe3,0x9e }, { 0x6a,0x88,0x1b,0x4c },
+ { 0x2c,0x1f,0xb8,0xc1 }, { 0x65,0x51,0x7f,0x46 },
+ { 0x5e,0xea,0x04,0x9d }, { 0x8c,0x35,0x5d,0x01 },
+ { 0x87,0x74,0x73,0xfa }, { 0x0b,0x41,0x2e,0xfb },
+ { 0x67,0x1d,0x5a,0xb3 }, { 0xdb,0xd2,0x52,0x92 },
+ { 0x10,0x56,0x33,0xe9 }, { 0xd6,0x47,0x13,0x6d },
+ { 0xd7,0x61,0x8c,0x9a }, { 0xa1,0x0c,0x7a,0x37 },
+ { 0xf8,0x14,0x8e,0x59 }, { 0x13,0x3c,0x89,0xeb },
+ { 0xa9,0x27,0xee,0xce }, { 0x61,0xc9,0x35,0xb7 },
+ { 0x1c,0xe5,0xed,0xe1 }, { 0x47,0xb1,0x3c,0x7a },
+ { 0xd2,0xdf,0x59,0x9c }, { 0xf2,0x73,0x3f,0x55 },
+ { 0x14,0xce,0x79,0x18 }, { 0xc7,0x37,0xbf,0x73 },
+ { 0xf7,0xcd,0xea,0x53 }, { 0xfd,0xaa,0x5b,0x5f },
+ { 0x3d,0x6f,0x14,0xdf }, { 0x44,0xdb,0x86,0x78 },
+ { 0xaf,0xf3,0x81,0xca }, { 0x68,0xc4,0x3e,0xb9 },
+ { 0x24,0x34,0x2c,0x38 }, { 0xa3,0x40,0x5f,0xc2 },
+ { 0x1d,0xc3,0x72,0x16 }, { 0xe2,0x25,0x0c,0xbc },
+ { 0x3c,0x49,0x8b,0x28 }, { 0x0d,0x95,0x41,0xff },
+ { 0xa8,0x01,0x71,0x39 }, { 0x0c,0xb3,0xde,0x08 },
+ { 0xb4,0xe4,0x9c,0xd8 }, { 0x56,0xc1,0x90,0x64 },
+ { 0xcb,0x84,0x61,0x7b }, { 0x32,0xb6,0x70,0xd5 },
+ { 0x6c,0x5c,0x74,0x48 }, { 0xb8,0x57,0x42,0xd0 }
+ };
+
+static const unsigned char S5[256] =
+ {
+ 0x52,0x09,0x6a,0xd5,0x30,0x36,0xa5,0x38,
+ 0xbf,0x40,0xa3,0x9e,0x81,0xf3,0xd7,0xfb,
+ 0x7c,0xe3,0x39,0x82,0x9b,0x2f,0xff,0x87,
+ 0x34,0x8e,0x43,0x44,0xc4,0xde,0xe9,0xcb,
+ 0x54,0x7b,0x94,0x32,0xa6,0xc2,0x23,0x3d,
+ 0xee,0x4c,0x95,0x0b,0x42,0xfa,0xc3,0x4e,
+ 0x08,0x2e,0xa1,0x66,0x28,0xd9,0x24,0xb2,
+ 0x76,0x5b,0xa2,0x49,0x6d,0x8b,0xd1,0x25,
+ 0x72,0xf8,0xf6,0x64,0x86,0x68,0x98,0x16,
+ 0xd4,0xa4,0x5c,0xcc,0x5d,0x65,0xb6,0x92,
+ 0x6c,0x70,0x48,0x50,0xfd,0xed,0xb9,0xda,
+ 0x5e,0x15,0x46,0x57,0xa7,0x8d,0x9d,0x84,
+ 0x90,0xd8,0xab,0x00,0x8c,0xbc,0xd3,0x0a,
+ 0xf7,0xe4,0x58,0x05,0xb8,0xb3,0x45,0x06,
+ 0xd0,0x2c,0x1e,0x8f,0xca,0x3f,0x0f,0x02,
+ 0xc1,0xaf,0xbd,0x03,0x01,0x13,0x8a,0x6b,
+ 0x3a,0x91,0x11,0x41,0x4f,0x67,0xdc,0xea,
+ 0x97,0xf2,0xcf,0xce,0xf0,0xb4,0xe6,0x73,
+ 0x96,0xac,0x74,0x22,0xe7,0xad,0x35,0x85,
+ 0xe2,0xf9,0x37,0xe8,0x1c,0x75,0xdf,0x6e,
+ 0x47,0xf1,0x1a,0x71,0x1d,0x29,0xc5,0x89,
+ 0x6f,0xb7,0x62,0x0e,0xaa,0x18,0xbe,0x1b,
+ 0xfc,0x56,0x3e,0x4b,0xc6,0xd2,0x79,0x20,
+ 0x9a,0xdb,0xc0,0xfe,0x78,0xcd,0x5a,0xf4,
+ 0x1f,0xdd,0xa8,0x33,0x88,0x07,0xc7,0x31,
+ 0xb1,0x12,0x10,0x59,0x27,0x80,0xec,0x5f,
+ 0x60,0x51,0x7f,0xa9,0x19,0xb5,0x4a,0x0d,
+ 0x2d,0xe5,0x7a,0x9f,0x93,0xc9,0x9c,0xef,
+ 0xa0,0xe0,0x3b,0x4d,0xae,0x2a,0xf5,0xb0,
+ 0xc8,0xeb,0xbb,0x3c,0x83,0x53,0x99,0x61,
+ 0x17,0x2b,0x04,0x7e,0xba,0x77,0xd6,0x26,
+ 0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d
+ };
+
+static const unsigned char U1[256][4] =
+ {
+ { 0x00,0x00,0x00,0x00 }, { 0x0e,0x09,0x0d,0x0b },
+ { 0x1c,0x12,0x1a,0x16 }, { 0x12,0x1b,0x17,0x1d },
+ { 0x38,0x24,0x34,0x2c }, { 0x36,0x2d,0x39,0x27 },
+ { 0x24,0x36,0x2e,0x3a }, { 0x2a,0x3f,0x23,0x31 },
+ { 0x70,0x48,0x68,0x58 }, { 0x7e,0x41,0x65,0x53 },
+ { 0x6c,0x5a,0x72,0x4e }, { 0x62,0x53,0x7f,0x45 },
+ { 0x48,0x6c,0x5c,0x74 }, { 0x46,0x65,0x51,0x7f },
+ { 0x54,0x7e,0x46,0x62 }, { 0x5a,0x77,0x4b,0x69 },
+ { 0xe0,0x90,0xd0,0xb0 }, { 0xee,0x99,0xdd,0xbb },
+ { 0xfc,0x82,0xca,0xa6 }, { 0xf2,0x8b,0xc7,0xad },
+ { 0xd8,0xb4,0xe4,0x9c }, { 0xd6,0xbd,0xe9,0x97 },
+ { 0xc4,0xa6,0xfe,0x8a }, { 0xca,0xaf,0xf3,0x81 },
+ { 0x90,0xd8,0xb8,0xe8 }, { 0x9e,0xd1,0xb5,0xe3 },
+ { 0x8c,0xca,0xa2,0xfe }, { 0x82,0xc3,0xaf,0xf5 },
+ { 0xa8,0xfc,0x8c,0xc4 }, { 0xa6,0xf5,0x81,0xcf },
+ { 0xb4,0xee,0x96,0xd2 }, { 0xba,0xe7,0x9b,0xd9 },
+ { 0xdb,0x3b,0xbb,0x7b }, { 0xd5,0x32,0xb6,0x70 },
+ { 0xc7,0x29,0xa1,0x6d }, { 0xc9,0x20,0xac,0x66 },
+ { 0xe3,0x1f,0x8f,0x57 }, { 0xed,0x16,0x82,0x5c },
+ { 0xff,0x0d,0x95,0x41 }, { 0xf1,0x04,0x98,0x4a },
+ { 0xab,0x73,0xd3,0x23 }, { 0xa5,0x7a,0xde,0x28 },
+ { 0xb7,0x61,0xc9,0x35 }, { 0xb9,0x68,0xc4,0x3e },
+ { 0x93,0x57,0xe7,0x0f }, { 0x9d,0x5e,0xea,0x04 },
+ { 0x8f,0x45,0xfd,0x19 }, { 0x81,0x4c,0xf0,0x12 },
+ { 0x3b,0xab,0x6b,0xcb }, { 0x35,0xa2,0x66,0xc0 },
+ { 0x27,0xb9,0x71,0xdd }, { 0x29,0xb0,0x7c,0xd6 },
+ { 0x03,0x8f,0x5f,0xe7 }, { 0x0d,0x86,0x52,0xec },
+ { 0x1f,0x9d,0x45,0xf1 }, { 0x11,0x94,0x48,0xfa },
+ { 0x4b,0xe3,0x03,0x93 }, { 0x45,0xea,0x0e,0x98 },
+ { 0x57,0xf1,0x19,0x85 }, { 0x59,0xf8,0x14,0x8e },
+ { 0x73,0xc7,0x37,0xbf }, { 0x7d,0xce,0x3a,0xb4 },
+ { 0x6f,0xd5,0x2d,0xa9 }, { 0x61,0xdc,0x20,0xa2 },
+ { 0xad,0x76,0x6d,0xf6 }, { 0xa3,0x7f,0x60,0xfd },
+ { 0xb1,0x64,0x77,0xe0 }, { 0xbf,0x6d,0x7a,0xeb },
+ { 0x95,0x52,0x59,0xda }, { 0x9b,0x5b,0x54,0xd1 },
+ { 0x89,0x40,0x43,0xcc }, { 0x87,0x49,0x4e,0xc7 },
+ { 0xdd,0x3e,0x05,0xae }, { 0xd3,0x37,0x08,0xa5 },
+ { 0xc1,0x2c,0x1f,0xb8 }, { 0xcf,0x25,0x12,0xb3 },
+ { 0xe5,0x1a,0x31,0x82 }, { 0xeb,0x13,0x3c,0x89 },
+ { 0xf9,0x08,0x2b,0x94 }, { 0xf7,0x01,0x26,0x9f },
+ { 0x4d,0xe6,0xbd,0x46 }, { 0x43,0xef,0xb0,0x4d },
+ { 0x51,0xf4,0xa7,0x50 }, { 0x5f,0xfd,0xaa,0x5b },
+ { 0x75,0xc2,0x89,0x6a }, { 0x7b,0xcb,0x84,0x61 },
+ { 0x69,0xd0,0x93,0x7c }, { 0x67,0xd9,0x9e,0x77 },
+ { 0x3d,0xae,0xd5,0x1e }, { 0x33,0xa7,0xd8,0x15 },
+ { 0x21,0xbc,0xcf,0x08 }, { 0x2f,0xb5,0xc2,0x03 },
+ { 0x05,0x8a,0xe1,0x32 }, { 0x0b,0x83,0xec,0x39 },
+ { 0x19,0x98,0xfb,0x24 }, { 0x17,0x91,0xf6,0x2f },
+ { 0x76,0x4d,0xd6,0x8d }, { 0x78,0x44,0xdb,0x86 },
+ { 0x6a,0x5f,0xcc,0x9b }, { 0x64,0x56,0xc1,0x90 },
+ { 0x4e,0x69,0xe2,0xa1 }, { 0x40,0x60,0xef,0xaa },
+ { 0x52,0x7b,0xf8,0xb7 }, { 0x5c,0x72,0xf5,0xbc },
+ { 0x06,0x05,0xbe,0xd5 }, { 0x08,0x0c,0xb3,0xde },
+ { 0x1a,0x17,0xa4,0xc3 }, { 0x14,0x1e,0xa9,0xc8 },
+ { 0x3e,0x21,0x8a,0xf9 }, { 0x30,0x28,0x87,0xf2 },
+ { 0x22,0x33,0x90,0xef }, { 0x2c,0x3a,0x9d,0xe4 },
+ { 0x96,0xdd,0x06,0x3d }, { 0x98,0xd4,0x0b,0x36 },
+ { 0x8a,0xcf,0x1c,0x2b }, { 0x84,0xc6,0x11,0x20 },
+ { 0xae,0xf9,0x32,0x11 }, { 0xa0,0xf0,0x3f,0x1a },
+ { 0xb2,0xeb,0x28,0x07 }, { 0xbc,0xe2,0x25,0x0c },
+ { 0xe6,0x95,0x6e,0x65 }, { 0xe8,0x9c,0x63,0x6e },
+ { 0xfa,0x87,0x74,0x73 }, { 0xf4,0x8e,0x79,0x78 },
+ { 0xde,0xb1,0x5a,0x49 }, { 0xd0,0xb8,0x57,0x42 },
+ { 0xc2,0xa3,0x40,0x5f }, { 0xcc,0xaa,0x4d,0x54 },
+ { 0x41,0xec,0xda,0xf7 }, { 0x4f,0xe5,0xd7,0xfc },
+ { 0x5d,0xfe,0xc0,0xe1 }, { 0x53,0xf7,0xcd,0xea },
+ { 0x79,0xc8,0xee,0xdb }, { 0x77,0xc1,0xe3,0xd0 },
+ { 0x65,0xda,0xf4,0xcd }, { 0x6b,0xd3,0xf9,0xc6 },
+ { 0x31,0xa4,0xb2,0xaf }, { 0x3f,0xad,0xbf,0xa4 },
+ { 0x2d,0xb6,0xa8,0xb9 }, { 0x23,0xbf,0xa5,0xb2 },
+ { 0x09,0x80,0x86,0x83 }, { 0x07,0x89,0x8b,0x88 },
+ { 0x15,0x92,0x9c,0x95 }, { 0x1b,0x9b,0x91,0x9e },
+ { 0xa1,0x7c,0x0a,0x47 }, { 0xaf,0x75,0x07,0x4c },
+ { 0xbd,0x6e,0x10,0x51 }, { 0xb3,0x67,0x1d,0x5a },
+ { 0x99,0x58,0x3e,0x6b }, { 0x97,0x51,0x33,0x60 },
+ { 0x85,0x4a,0x24,0x7d }, { 0x8b,0x43,0x29,0x76 },
+ { 0xd1,0x34,0x62,0x1f }, { 0xdf,0x3d,0x6f,0x14 },
+ { 0xcd,0x26,0x78,0x09 }, { 0xc3,0x2f,0x75,0x02 },
+ { 0xe9,0x10,0x56,0x33 }, { 0xe7,0x19,0x5b,0x38 },
+ { 0xf5,0x02,0x4c,0x25 }, { 0xfb,0x0b,0x41,0x2e },
+ { 0x9a,0xd7,0x61,0x8c }, { 0x94,0xde,0x6c,0x87 },
+ { 0x86,0xc5,0x7b,0x9a }, { 0x88,0xcc,0x76,0x91 },
+ { 0xa2,0xf3,0x55,0xa0 }, { 0xac,0xfa,0x58,0xab },
+ { 0xbe,0xe1,0x4f,0xb6 }, { 0xb0,0xe8,0x42,0xbd },
+ { 0xea,0x9f,0x09,0xd4 }, { 0xe4,0x96,0x04,0xdf },
+ { 0xf6,0x8d,0x13,0xc2 }, { 0xf8,0x84,0x1e,0xc9 },
+ { 0xd2,0xbb,0x3d,0xf8 }, { 0xdc,0xb2,0x30,0xf3 },
+ { 0xce,0xa9,0x27,0xee }, { 0xc0,0xa0,0x2a,0xe5 },
+ { 0x7a,0x47,0xb1,0x3c }, { 0x74,0x4e,0xbc,0x37 },
+ { 0x66,0x55,0xab,0x2a }, { 0x68,0x5c,0xa6,0x21 },
+ { 0x42,0x63,0x85,0x10 }, { 0x4c,0x6a,0x88,0x1b },
+ { 0x5e,0x71,0x9f,0x06 }, { 0x50,0x78,0x92,0x0d },
+ { 0x0a,0x0f,0xd9,0x64 }, { 0x04,0x06,0xd4,0x6f },
+ { 0x16,0x1d,0xc3,0x72 }, { 0x18,0x14,0xce,0x79 },
+ { 0x32,0x2b,0xed,0x48 }, { 0x3c,0x22,0xe0,0x43 },
+ { 0x2e,0x39,0xf7,0x5e }, { 0x20,0x30,0xfa,0x55 },
+ { 0xec,0x9a,0xb7,0x01 }, { 0xe2,0x93,0xba,0x0a },
+ { 0xf0,0x88,0xad,0x17 }, { 0xfe,0x81,0xa0,0x1c },
+ { 0xd4,0xbe,0x83,0x2d }, { 0xda,0xb7,0x8e,0x26 },
+ { 0xc8,0xac,0x99,0x3b }, { 0xc6,0xa5,0x94,0x30 },
+ { 0x9c,0xd2,0xdf,0x59 }, { 0x92,0xdb,0xd2,0x52 },
+ { 0x80,0xc0,0xc5,0x4f }, { 0x8e,0xc9,0xc8,0x44 },
+ { 0xa4,0xf6,0xeb,0x75 }, { 0xaa,0xff,0xe6,0x7e },
+ { 0xb8,0xe4,0xf1,0x63 }, { 0xb6,0xed,0xfc,0x68 },
+ { 0x0c,0x0a,0x67,0xb1 }, { 0x02,0x03,0x6a,0xba },
+ { 0x10,0x18,0x7d,0xa7 }, { 0x1e,0x11,0x70,0xac },
+ { 0x34,0x2e,0x53,0x9d }, { 0x3a,0x27,0x5e,0x96 },
+ { 0x28,0x3c,0x49,0x8b }, { 0x26,0x35,0x44,0x80 },
+ { 0x7c,0x42,0x0f,0xe9 }, { 0x72,0x4b,0x02,0xe2 },
+ { 0x60,0x50,0x15,0xff }, { 0x6e,0x59,0x18,0xf4 },
+ { 0x44,0x66,0x3b,0xc5 }, { 0x4a,0x6f,0x36,0xce },
+ { 0x58,0x74,0x21,0xd3 }, { 0x56,0x7d,0x2c,0xd8 },
+ { 0x37,0xa1,0x0c,0x7a }, { 0x39,0xa8,0x01,0x71 },
+ { 0x2b,0xb3,0x16,0x6c }, { 0x25,0xba,0x1b,0x67 },
+ { 0x0f,0x85,0x38,0x56 }, { 0x01,0x8c,0x35,0x5d },
+ { 0x13,0x97,0x22,0x40 }, { 0x1d,0x9e,0x2f,0x4b },
+ { 0x47,0xe9,0x64,0x22 }, { 0x49,0xe0,0x69,0x29 },
+ { 0x5b,0xfb,0x7e,0x34 }, { 0x55,0xf2,0x73,0x3f },
+ { 0x7f,0xcd,0x50,0x0e }, { 0x71,0xc4,0x5d,0x05 },
+ { 0x63,0xdf,0x4a,0x18 }, { 0x6d,0xd6,0x47,0x13 },
+ { 0xd7,0x31,0xdc,0xca }, { 0xd9,0x38,0xd1,0xc1 },
+ { 0xcb,0x23,0xc6,0xdc }, { 0xc5,0x2a,0xcb,0xd7 },
+ { 0xef,0x15,0xe8,0xe6 }, { 0xe1,0x1c,0xe5,0xed },
+ { 0xf3,0x07,0xf2,0xf0 }, { 0xfd,0x0e,0xff,0xfb },
+ { 0xa7,0x79,0xb4,0x92 }, { 0xa9,0x70,0xb9,0x99 },
+ { 0xbb,0x6b,0xae,0x84 }, { 0xb5,0x62,0xa3,0x8f },
+ { 0x9f,0x5d,0x80,0xbe }, { 0x91,0x54,0x8d,0xb5 },
+ { 0x83,0x4f,0x9a,0xa8 }, { 0x8d,0x46,0x97,0xa3 }
+ };
+
+static const unsigned char U2[256][4] =
+ {
+ { 0x00,0x00,0x00,0x00 }, { 0x0b,0x0e,0x09,0x0d },
+ { 0x16,0x1c,0x12,0x1a }, { 0x1d,0x12,0x1b,0x17 },
+ { 0x2c,0x38,0x24,0x34 }, { 0x27,0x36,0x2d,0x39 },
+ { 0x3a,0x24,0x36,0x2e }, { 0x31,0x2a,0x3f,0x23 },
+ { 0x58,0x70,0x48,0x68 }, { 0x53,0x7e,0x41,0x65 },
+ { 0x4e,0x6c,0x5a,0x72 }, { 0x45,0x62,0x53,0x7f },
+ { 0x74,0x48,0x6c,0x5c }, { 0x7f,0x46,0x65,0x51 },
+ { 0x62,0x54,0x7e,0x46 }, { 0x69,0x5a,0x77,0x4b },
+ { 0xb0,0xe0,0x90,0xd0 }, { 0xbb,0xee,0x99,0xdd },
+ { 0xa6,0xfc,0x82,0xca }, { 0xad,0xf2,0x8b,0xc7 },
+ { 0x9c,0xd8,0xb4,0xe4 }, { 0x97,0xd6,0xbd,0xe9 },
+ { 0x8a,0xc4,0xa6,0xfe }, { 0x81,0xca,0xaf,0xf3 },
+ { 0xe8,0x90,0xd8,0xb8 }, { 0xe3,0x9e,0xd1,0xb5 },
+ { 0xfe,0x8c,0xca,0xa2 }, { 0xf5,0x82,0xc3,0xaf },
+ { 0xc4,0xa8,0xfc,0x8c }, { 0xcf,0xa6,0xf5,0x81 },
+ { 0xd2,0xb4,0xee,0x96 }, { 0xd9,0xba,0xe7,0x9b },
+ { 0x7b,0xdb,0x3b,0xbb }, { 0x70,0xd5,0x32,0xb6 },
+ { 0x6d,0xc7,0x29,0xa1 }, { 0x66,0xc9,0x20,0xac },
+ { 0x57,0xe3,0x1f,0x8f }, { 0x5c,0xed,0x16,0x82 },
+ { 0x41,0xff,0x0d,0x95 }, { 0x4a,0xf1,0x04,0x98 },
+ { 0x23,0xab,0x73,0xd3 }, { 0x28,0xa5,0x7a,0xde },
+ { 0x35,0xb7,0x61,0xc9 }, { 0x3e,0xb9,0x68,0xc4 },
+ { 0x0f,0x93,0x57,0xe7 }, { 0x04,0x9d,0x5e,0xea },
+ { 0x19,0x8f,0x45,0xfd }, { 0x12,0x81,0x4c,0xf0 },
+ { 0xcb,0x3b,0xab,0x6b }, { 0xc0,0x35,0xa2,0x66 },
+ { 0xdd,0x27,0xb9,0x71 }, { 0xd6,0x29,0xb0,0x7c },
+ { 0xe7,0x03,0x8f,0x5f }, { 0xec,0x0d,0x86,0x52 },
+ { 0xf1,0x1f,0x9d,0x45 }, { 0xfa,0x11,0x94,0x48 },
+ { 0x93,0x4b,0xe3,0x03 }, { 0x98,0x45,0xea,0x0e },
+ { 0x85,0x57,0xf1,0x19 }, { 0x8e,0x59,0xf8,0x14 },
+ { 0xbf,0x73,0xc7,0x37 }, { 0xb4,0x7d,0xce,0x3a },
+ { 0xa9,0x6f,0xd5,0x2d }, { 0xa2,0x61,0xdc,0x20 },
+ { 0xf6,0xad,0x76,0x6d }, { 0xfd,0xa3,0x7f,0x60 },
+ { 0xe0,0xb1,0x64,0x77 }, { 0xeb,0xbf,0x6d,0x7a },
+ { 0xda,0x95,0x52,0x59 }, { 0xd1,0x9b,0x5b,0x54 },
+ { 0xcc,0x89,0x40,0x43 }, { 0xc7,0x87,0x49,0x4e },
+ { 0xae,0xdd,0x3e,0x05 }, { 0xa5,0xd3,0x37,0x08 },
+ { 0xb8,0xc1,0x2c,0x1f }, { 0xb3,0xcf,0x25,0x12 },
+ { 0x82,0xe5,0x1a,0x31 }, { 0x89,0xeb,0x13,0x3c },
+ { 0x94,0xf9,0x08,0x2b }, { 0x9f,0xf7,0x01,0x26 },
+ { 0x46,0x4d,0xe6,0xbd }, { 0x4d,0x43,0xef,0xb0 },
+ { 0x50,0x51,0xf4,0xa7 }, { 0x5b,0x5f,0xfd,0xaa },
+ { 0x6a,0x75,0xc2,0x89 }, { 0x61,0x7b,0xcb,0x84 },
+ { 0x7c,0x69,0xd0,0x93 }, { 0x77,0x67,0xd9,0x9e },
+ { 0x1e,0x3d,0xae,0xd5 }, { 0x15,0x33,0xa7,0xd8 },
+ { 0x08,0x21,0xbc,0xcf }, { 0x03,0x2f,0xb5,0xc2 },
+ { 0x32,0x05,0x8a,0xe1 }, { 0x39,0x0b,0x83,0xec },
+ { 0x24,0x19,0x98,0xfb }, { 0x2f,0x17,0x91,0xf6 },
+ { 0x8d,0x76,0x4d,0xd6 }, { 0x86,0x78,0x44,0xdb },
+ { 0x9b,0x6a,0x5f,0xcc }, { 0x90,0x64,0x56,0xc1 },
+ { 0xa1,0x4e,0x69,0xe2 }, { 0xaa,0x40,0x60,0xef },
+ { 0xb7,0x52,0x7b,0xf8 }, { 0xbc,0x5c,0x72,0xf5 },
+ { 0xd5,0x06,0x05,0xbe }, { 0xde,0x08,0x0c,0xb3 },
+ { 0xc3,0x1a,0x17,0xa4 }, { 0xc8,0x14,0x1e,0xa9 },
+ { 0xf9,0x3e,0x21,0x8a }, { 0xf2,0x30,0x28,0x87 },
+ { 0xef,0x22,0x33,0x90 }, { 0xe4,0x2c,0x3a,0x9d },
+ { 0x3d,0x96,0xdd,0x06 }, { 0x36,0x98,0xd4,0x0b },
+ { 0x2b,0x8a,0xcf,0x1c }, { 0x20,0x84,0xc6,0x11 },
+ { 0x11,0xae,0xf9,0x32 }, { 0x1a,0xa0,0xf0,0x3f },
+ { 0x07,0xb2,0xeb,0x28 }, { 0x0c,0xbc,0xe2,0x25 },
+ { 0x65,0xe6,0x95,0x6e }, { 0x6e,0xe8,0x9c,0x63 },
+ { 0x73,0xfa,0x87,0x74 }, { 0x78,0xf4,0x8e,0x79 },
+ { 0x49,0xde,0xb1,0x5a }, { 0x42,0xd0,0xb8,0x57 },
+ { 0x5f,0xc2,0xa3,0x40 }, { 0x54,0xcc,0xaa,0x4d },
+ { 0xf7,0x41,0xec,0xda }, { 0xfc,0x4f,0xe5,0xd7 },
+ { 0xe1,0x5d,0xfe,0xc0 }, { 0xea,0x53,0xf7,0xcd },
+ { 0xdb,0x79,0xc8,0xee }, { 0xd0,0x77,0xc1,0xe3 },
+ { 0xcd,0x65,0xda,0xf4 }, { 0xc6,0x6b,0xd3,0xf9 },
+ { 0xaf,0x31,0xa4,0xb2 }, { 0xa4,0x3f,0xad,0xbf },
+ { 0xb9,0x2d,0xb6,0xa8 }, { 0xb2,0x23,0xbf,0xa5 },
+ { 0x83,0x09,0x80,0x86 }, { 0x88,0x07,0x89,0x8b },
+ { 0x95,0x15,0x92,0x9c }, { 0x9e,0x1b,0x9b,0x91 },
+ { 0x47,0xa1,0x7c,0x0a }, { 0x4c,0xaf,0x75,0x07 },
+ { 0x51,0xbd,0x6e,0x10 }, { 0x5a,0xb3,0x67,0x1d },
+ { 0x6b,0x99,0x58,0x3e }, { 0x60,0x97,0x51,0x33 },
+ { 0x7d,0x85,0x4a,0x24 }, { 0x76,0x8b,0x43,0x29 },
+ { 0x1f,0xd1,0x34,0x62 }, { 0x14,0xdf,0x3d,0x6f },
+ { 0x09,0xcd,0x26,0x78 }, { 0x02,0xc3,0x2f,0x75 },
+ { 0x33,0xe9,0x10,0x56 }, { 0x38,0xe7,0x19,0x5b },
+ { 0x25,0xf5,0x02,0x4c }, { 0x2e,0xfb,0x0b,0x41 },
+ { 0x8c,0x9a,0xd7,0x61 }, { 0x87,0x94,0xde,0x6c },
+ { 0x9a,0x86,0xc5,0x7b }, { 0x91,0x88,0xcc,0x76 },
+ { 0xa0,0xa2,0xf3,0x55 }, { 0xab,0xac,0xfa,0x58 },
+ { 0xb6,0xbe,0xe1,0x4f }, { 0xbd,0xb0,0xe8,0x42 },
+ { 0xd4,0xea,0x9f,0x09 }, { 0xdf,0xe4,0x96,0x04 },
+ { 0xc2,0xf6,0x8d,0x13 }, { 0xc9,0xf8,0x84,0x1e },
+ { 0xf8,0xd2,0xbb,0x3d }, { 0xf3,0xdc,0xb2,0x30 },
+ { 0xee,0xce,0xa9,0x27 }, { 0xe5,0xc0,0xa0,0x2a },
+ { 0x3c,0x7a,0x47,0xb1 }, { 0x37,0x74,0x4e,0xbc },
+ { 0x2a,0x66,0x55,0xab }, { 0x21,0x68,0x5c,0xa6 },
+ { 0x10,0x42,0x63,0x85 }, { 0x1b,0x4c,0x6a,0x88 },
+ { 0x06,0x5e,0x71,0x9f }, { 0x0d,0x50,0x78,0x92 },
+ { 0x64,0x0a,0x0f,0xd9 }, { 0x6f,0x04,0x06,0xd4 },
+ { 0x72,0x16,0x1d,0xc3 }, { 0x79,0x18,0x14,0xce },
+ { 0x48,0x32,0x2b,0xed }, { 0x43,0x3c,0x22,0xe0 },
+ { 0x5e,0x2e,0x39,0xf7 }, { 0x55,0x20,0x30,0xfa },
+ { 0x01,0xec,0x9a,0xb7 }, { 0x0a,0xe2,0x93,0xba },
+ { 0x17,0xf0,0x88,0xad }, { 0x1c,0xfe,0x81,0xa0 },
+ { 0x2d,0xd4,0xbe,0x83 }, { 0x26,0xda,0xb7,0x8e },
+ { 0x3b,0xc8,0xac,0x99 }, { 0x30,0xc6,0xa5,0x94 },
+ { 0x59,0x9c,0xd2,0xdf }, { 0x52,0x92,0xdb,0xd2 },
+ { 0x4f,0x80,0xc0,0xc5 }, { 0x44,0x8e,0xc9,0xc8 },
+ { 0x75,0xa4,0xf6,0xeb }, { 0x7e,0xaa,0xff,0xe6 },
+ { 0x63,0xb8,0xe4,0xf1 }, { 0x68,0xb6,0xed,0xfc },
+ { 0xb1,0x0c,0x0a,0x67 }, { 0xba,0x02,0x03,0x6a },
+ { 0xa7,0x10,0x18,0x7d }, { 0xac,0x1e,0x11,0x70 },
+ { 0x9d,0x34,0x2e,0x53 }, { 0x96,0x3a,0x27,0x5e },
+ { 0x8b,0x28,0x3c,0x49 }, { 0x80,0x26,0x35,0x44 },
+ { 0xe9,0x7c,0x42,0x0f }, { 0xe2,0x72,0x4b,0x02 },
+ { 0xff,0x60,0x50,0x15 }, { 0xf4,0x6e,0x59,0x18 },
+ { 0xc5,0x44,0x66,0x3b }, { 0xce,0x4a,0x6f,0x36 },
+ { 0xd3,0x58,0x74,0x21 }, { 0xd8,0x56,0x7d,0x2c },
+ { 0x7a,0x37,0xa1,0x0c }, { 0x71,0x39,0xa8,0x01 },
+ { 0x6c,0x2b,0xb3,0x16 }, { 0x67,0x25,0xba,0x1b },
+ { 0x56,0x0f,0x85,0x38 }, { 0x5d,0x01,0x8c,0x35 },
+ { 0x40,0x13,0x97,0x22 }, { 0x4b,0x1d,0x9e,0x2f },
+ { 0x22,0x47,0xe9,0x64 }, { 0x29,0x49,0xe0,0x69 },
+ { 0x34,0x5b,0xfb,0x7e }, { 0x3f,0x55,0xf2,0x73 },
+ { 0x0e,0x7f,0xcd,0x50 }, { 0x05,0x71,0xc4,0x5d },
+ { 0x18,0x63,0xdf,0x4a }, { 0x13,0x6d,0xd6,0x47 },
+ { 0xca,0xd7,0x31,0xdc }, { 0xc1,0xd9,0x38,0xd1 },
+ { 0xdc,0xcb,0x23,0xc6 }, { 0xd7,0xc5,0x2a,0xcb },
+ { 0xe6,0xef,0x15,0xe8 }, { 0xed,0xe1,0x1c,0xe5 },
+ { 0xf0,0xf3,0x07,0xf2 }, { 0xfb,0xfd,0x0e,0xff },
+ { 0x92,0xa7,0x79,0xb4 }, { 0x99,0xa9,0x70,0xb9 },
+ { 0x84,0xbb,0x6b,0xae }, { 0x8f,0xb5,0x62,0xa3 },
+ { 0xbe,0x9f,0x5d,0x80 }, { 0xb5,0x91,0x54,0x8d },
+ { 0xa8,0x83,0x4f,0x9a }, { 0xa3,0x8d,0x46,0x97 }
+ };
+
+static const unsigned char U3[256][4] =
+ {
+ { 0x00,0x00,0x00,0x00 }, { 0x0d,0x0b,0x0e,0x09 },
+ { 0x1a,0x16,0x1c,0x12 }, { 0x17,0x1d,0x12,0x1b },
+ { 0x34,0x2c,0x38,0x24 }, { 0x39,0x27,0x36,0x2d },
+ { 0x2e,0x3a,0x24,0x36 }, { 0x23,0x31,0x2a,0x3f },
+ { 0x68,0x58,0x70,0x48 }, { 0x65,0x53,0x7e,0x41 },
+ { 0x72,0x4e,0x6c,0x5a }, { 0x7f,0x45,0x62,0x53 },
+ { 0x5c,0x74,0x48,0x6c }, { 0x51,0x7f,0x46,0x65 },
+ { 0x46,0x62,0x54,0x7e }, { 0x4b,0x69,0x5a,0x77 },
+ { 0xd0,0xb0,0xe0,0x90 }, { 0xdd,0xbb,0xee,0x99 },
+ { 0xca,0xa6,0xfc,0x82 }, { 0xc7,0xad,0xf2,0x8b },
+ { 0xe4,0x9c,0xd8,0xb4 }, { 0xe9,0x97,0xd6,0xbd },
+ { 0xfe,0x8a,0xc4,0xa6 }, { 0xf3,0x81,0xca,0xaf },
+ { 0xb8,0xe8,0x90,0xd8 }, { 0xb5,0xe3,0x9e,0xd1 },
+ { 0xa2,0xfe,0x8c,0xca }, { 0xaf,0xf5,0x82,0xc3 },
+ { 0x8c,0xc4,0xa8,0xfc }, { 0x81,0xcf,0xa6,0xf5 },
+ { 0x96,0xd2,0xb4,0xee }, { 0x9b,0xd9,0xba,0xe7 },
+ { 0xbb,0x7b,0xdb,0x3b }, { 0xb6,0x70,0xd5,0x32 },
+ { 0xa1,0x6d,0xc7,0x29 }, { 0xac,0x66,0xc9,0x20 },
+ { 0x8f,0x57,0xe3,0x1f }, { 0x82,0x5c,0xed,0x16 },
+ { 0x95,0x41,0xff,0x0d }, { 0x98,0x4a,0xf1,0x04 },
+ { 0xd3,0x23,0xab,0x73 }, { 0xde,0x28,0xa5,0x7a },
+ { 0xc9,0x35,0xb7,0x61 }, { 0xc4,0x3e,0xb9,0x68 },
+ { 0xe7,0x0f,0x93,0x57 }, { 0xea,0x04,0x9d,0x5e },
+ { 0xfd,0x19,0x8f,0x45 }, { 0xf0,0x12,0x81,0x4c },
+ { 0x6b,0xcb,0x3b,0xab }, { 0x66,0xc0,0x35,0xa2 },
+ { 0x71,0xdd,0x27,0xb9 }, { 0x7c,0xd6,0x29,0xb0 },
+ { 0x5f,0xe7,0x03,0x8f }, { 0x52,0xec,0x0d,0x86 },
+ { 0x45,0xf1,0x1f,0x9d }, { 0x48,0xfa,0x11,0x94 },
+ { 0x03,0x93,0x4b,0xe3 }, { 0x0e,0x98,0x45,0xea },
+ { 0x19,0x85,0x57,0xf1 }, { 0x14,0x8e,0x59,0xf8 },
+ { 0x37,0xbf,0x73,0xc7 }, { 0x3a,0xb4,0x7d,0xce },
+ { 0x2d,0xa9,0x6f,0xd5 }, { 0x20,0xa2,0x61,0xdc },
+ { 0x6d,0xf6,0xad,0x76 }, { 0x60,0xfd,0xa3,0x7f },
+ { 0x77,0xe0,0xb1,0x64 }, { 0x7a,0xeb,0xbf,0x6d },
+ { 0x59,0xda,0x95,0x52 }, { 0x54,0xd1,0x9b,0x5b },
+ { 0x43,0xcc,0x89,0x40 }, { 0x4e,0xc7,0x87,0x49 },
+ { 0x05,0xae,0xdd,0x3e }, { 0x08,0xa5,0xd3,0x37 },
+ { 0x1f,0xb8,0xc1,0x2c }, { 0x12,0xb3,0xcf,0x25 },
+ { 0x31,0x82,0xe5,0x1a }, { 0x3c,0x89,0xeb,0x13 },
+ { 0x2b,0x94,0xf9,0x08 }, { 0x26,0x9f,0xf7,0x01 },
+ { 0xbd,0x46,0x4d,0xe6 }, { 0xb0,0x4d,0x43,0xef },
+ { 0xa7,0x50,0x51,0xf4 }, { 0xaa,0x5b,0x5f,0xfd },
+ { 0x89,0x6a,0x75,0xc2 }, { 0x84,0x61,0x7b,0xcb },
+ { 0x93,0x7c,0x69,0xd0 }, { 0x9e,0x77,0x67,0xd9 },
+ { 0xd5,0x1e,0x3d,0xae }, { 0xd8,0x15,0x33,0xa7 },
+ { 0xcf,0x08,0x21,0xbc }, { 0xc2,0x03,0x2f,0xb5 },
+ { 0xe1,0x32,0x05,0x8a }, { 0xec,0x39,0x0b,0x83 },
+ { 0xfb,0x24,0x19,0x98 }, { 0xf6,0x2f,0x17,0x91 },
+ { 0xd6,0x8d,0x76,0x4d }, { 0xdb,0x86,0x78,0x44 },
+ { 0xcc,0x9b,0x6a,0x5f }, { 0xc1,0x90,0x64,0x56 },
+ { 0xe2,0xa1,0x4e,0x69 }, { 0xef,0xaa,0x40,0x60 },
+ { 0xf8,0xb7,0x52,0x7b }, { 0xf5,0xbc,0x5c,0x72 },
+ { 0xbe,0xd5,0x06,0x05 }, { 0xb3,0xde,0x08,0x0c },
+ { 0xa4,0xc3,0x1a,0x17 }, { 0xa9,0xc8,0x14,0x1e },
+ { 0x8a,0xf9,0x3e,0x21 }, { 0x87,0xf2,0x30,0x28 },
+ { 0x90,0xef,0x22,0x33 }, { 0x9d,0xe4,0x2c,0x3a },
+ { 0x06,0x3d,0x96,0xdd }, { 0x0b,0x36,0x98,0xd4 },
+ { 0x1c,0x2b,0x8a,0xcf }, { 0x11,0x20,0x84,0xc6 },
+ { 0x32,0x11,0xae,0xf9 }, { 0x3f,0x1a,0xa0,0xf0 },
+ { 0x28,0x07,0xb2,0xeb }, { 0x25,0x0c,0xbc,0xe2 },
+ { 0x6e,0x65,0xe6,0x95 }, { 0x63,0x6e,0xe8,0x9c },
+ { 0x74,0x73,0xfa,0x87 }, { 0x79,0x78,0xf4,0x8e },
+ { 0x5a,0x49,0xde,0xb1 }, { 0x57,0x42,0xd0,0xb8 },
+ { 0x40,0x5f,0xc2,0xa3 }, { 0x4d,0x54,0xcc,0xaa },
+ { 0xda,0xf7,0x41,0xec }, { 0xd7,0xfc,0x4f,0xe5 },
+ { 0xc0,0xe1,0x5d,0xfe }, { 0xcd,0xea,0x53,0xf7 },
+ { 0xee,0xdb,0x79,0xc8 }, { 0xe3,0xd0,0x77,0xc1 },
+ { 0xf4,0xcd,0x65,0xda }, { 0xf9,0xc6,0x6b,0xd3 },
+ { 0xb2,0xaf,0x31,0xa4 }, { 0xbf,0xa4,0x3f,0xad },
+ { 0xa8,0xb9,0x2d,0xb6 }, { 0xa5,0xb2,0x23,0xbf },
+ { 0x86,0x83,0x09,0x80 }, { 0x8b,0x88,0x07,0x89 },
+ { 0x9c,0x95,0x15,0x92 }, { 0x91,0x9e,0x1b,0x9b },
+ { 0x0a,0x47,0xa1,0x7c }, { 0x07,0x4c,0xaf,0x75 },
+ { 0x10,0x51,0xbd,0x6e }, { 0x1d,0x5a,0xb3,0x67 },
+ { 0x3e,0x6b,0x99,0x58 }, { 0x33,0x60,0x97,0x51 },
+ { 0x24,0x7d,0x85,0x4a }, { 0x29,0x76,0x8b,0x43 },
+ { 0x62,0x1f,0xd1,0x34 }, { 0x6f,0x14,0xdf,0x3d },
+ { 0x78,0x09,0xcd,0x26 }, { 0x75,0x02,0xc3,0x2f },
+ { 0x56,0x33,0xe9,0x10 }, { 0x5b,0x38,0xe7,0x19 },
+ { 0x4c,0x25,0xf5,0x02 }, { 0x41,0x2e,0xfb,0x0b },
+ { 0x61,0x8c,0x9a,0xd7 }, { 0x6c,0x87,0x94,0xde },
+ { 0x7b,0x9a,0x86,0xc5 }, { 0x76,0x91,0x88,0xcc },
+ { 0x55,0xa0,0xa2,0xf3 }, { 0x58,0xab,0xac,0xfa },
+ { 0x4f,0xb6,0xbe,0xe1 }, { 0x42,0xbd,0xb0,0xe8 },
+ { 0x09,0xd4,0xea,0x9f }, { 0x04,0xdf,0xe4,0x96 },
+ { 0x13,0xc2,0xf6,0x8d }, { 0x1e,0xc9,0xf8,0x84 },
+ { 0x3d,0xf8,0xd2,0xbb }, { 0x30,0xf3,0xdc,0xb2 },
+ { 0x27,0xee,0xce,0xa9 }, { 0x2a,0xe5,0xc0,0xa0 },
+ { 0xb1,0x3c,0x7a,0x47 }, { 0xbc,0x37,0x74,0x4e },
+ { 0xab,0x2a,0x66,0x55 }, { 0xa6,0x21,0x68,0x5c },
+ { 0x85,0x10,0x42,0x63 }, { 0x88,0x1b,0x4c,0x6a },
+ { 0x9f,0x06,0x5e,0x71 }, { 0x92,0x0d,0x50,0x78 },
+ { 0xd9,0x64,0x0a,0x0f }, { 0xd4,0x6f,0x04,0x06 },
+ { 0xc3,0x72,0x16,0x1d }, { 0xce,0x79,0x18,0x14 },
+ { 0xed,0x48,0x32,0x2b }, { 0xe0,0x43,0x3c,0x22 },
+ { 0xf7,0x5e,0x2e,0x39 }, { 0xfa,0x55,0x20,0x30 },
+ { 0xb7,0x01,0xec,0x9a }, { 0xba,0x0a,0xe2,0x93 },
+ { 0xad,0x17,0xf0,0x88 }, { 0xa0,0x1c,0xfe,0x81 },
+ { 0x83,0x2d,0xd4,0xbe }, { 0x8e,0x26,0xda,0xb7 },
+ { 0x99,0x3b,0xc8,0xac }, { 0x94,0x30,0xc6,0xa5 },
+ { 0xdf,0x59,0x9c,0xd2 }, { 0xd2,0x52,0x92,0xdb },
+ { 0xc5,0x4f,0x80,0xc0 }, { 0xc8,0x44,0x8e,0xc9 },
+ { 0xeb,0x75,0xa4,0xf6 }, { 0xe6,0x7e,0xaa,0xff },
+ { 0xf1,0x63,0xb8,0xe4 }, { 0xfc,0x68,0xb6,0xed },
+ { 0x67,0xb1,0x0c,0x0a }, { 0x6a,0xba,0x02,0x03 },
+ { 0x7d,0xa7,0x10,0x18 }, { 0x70,0xac,0x1e,0x11 },
+ { 0x53,0x9d,0x34,0x2e }, { 0x5e,0x96,0x3a,0x27 },
+ { 0x49,0x8b,0x28,0x3c }, { 0x44,0x80,0x26,0x35 },
+ { 0x0f,0xe9,0x7c,0x42 }, { 0x02,0xe2,0x72,0x4b },
+ { 0x15,0xff,0x60,0x50 }, { 0x18,0xf4,0x6e,0x59 },
+ { 0x3b,0xc5,0x44,0x66 }, { 0x36,0xce,0x4a,0x6f },
+ { 0x21,0xd3,0x58,0x74 }, { 0x2c,0xd8,0x56,0x7d },
+ { 0x0c,0x7a,0x37,0xa1 }, { 0x01,0x71,0x39,0xa8 },
+ { 0x16,0x6c,0x2b,0xb3 }, { 0x1b,0x67,0x25,0xba },
+ { 0x38,0x56,0x0f,0x85 }, { 0x35,0x5d,0x01,0x8c },
+ { 0x22,0x40,0x13,0x97 }, { 0x2f,0x4b,0x1d,0x9e },
+ { 0x64,0x22,0x47,0xe9 }, { 0x69,0x29,0x49,0xe0 },
+ { 0x7e,0x34,0x5b,0xfb }, { 0x73,0x3f,0x55,0xf2 },
+ { 0x50,0x0e,0x7f,0xcd }, { 0x5d,0x05,0x71,0xc4 },
+ { 0x4a,0x18,0x63,0xdf }, { 0x47,0x13,0x6d,0xd6 },
+ { 0xdc,0xca,0xd7,0x31 }, { 0xd1,0xc1,0xd9,0x38 },
+ { 0xc6,0xdc,0xcb,0x23 }, { 0xcb,0xd7,0xc5,0x2a },
+ { 0xe8,0xe6,0xef,0x15 }, { 0xe5,0xed,0xe1,0x1c },
+ { 0xf2,0xf0,0xf3,0x07 }, { 0xff,0xfb,0xfd,0x0e },
+ { 0xb4,0x92,0xa7,0x79 }, { 0xb9,0x99,0xa9,0x70 },
+ { 0xae,0x84,0xbb,0x6b }, { 0xa3,0x8f,0xb5,0x62 },
+ { 0x80,0xbe,0x9f,0x5d }, { 0x8d,0xb5,0x91,0x54 },
+ { 0x9a,0xa8,0x83,0x4f }, { 0x97,0xa3,0x8d,0x46 }
+ };
+
+static const unsigned char U4[256][4] =
+ {
+ { 0x00,0x00,0x00,0x00 }, { 0x09,0x0d,0x0b,0x0e },
+ { 0x12,0x1a,0x16,0x1c }, { 0x1b,0x17,0x1d,0x12 },
+ { 0x24,0x34,0x2c,0x38 }, { 0x2d,0x39,0x27,0x36 },
+ { 0x36,0x2e,0x3a,0x24 }, { 0x3f,0x23,0x31,0x2a },
+ { 0x48,0x68,0x58,0x70 }, { 0x41,0x65,0x53,0x7e },
+ { 0x5a,0x72,0x4e,0x6c }, { 0x53,0x7f,0x45,0x62 },
+ { 0x6c,0x5c,0x74,0x48 }, { 0x65,0x51,0x7f,0x46 },
+ { 0x7e,0x46,0x62,0x54 }, { 0x77,0x4b,0x69,0x5a },
+ { 0x90,0xd0,0xb0,0xe0 }, { 0x99,0xdd,0xbb,0xee },
+ { 0x82,0xca,0xa6,0xfc }, { 0x8b,0xc7,0xad,0xf2 },
+ { 0xb4,0xe4,0x9c,0xd8 }, { 0xbd,0xe9,0x97,0xd6 },
+ { 0xa6,0xfe,0x8a,0xc4 }, { 0xaf,0xf3,0x81,0xca },
+ { 0xd8,0xb8,0xe8,0x90 }, { 0xd1,0xb5,0xe3,0x9e },
+ { 0xca,0xa2,0xfe,0x8c }, { 0xc3,0xaf,0xf5,0x82 },
+ { 0xfc,0x8c,0xc4,0xa8 }, { 0xf5,0x81,0xcf,0xa6 },
+ { 0xee,0x96,0xd2,0xb4 }, { 0xe7,0x9b,0xd9,0xba },
+ { 0x3b,0xbb,0x7b,0xdb }, { 0x32,0xb6,0x70,0xd5 },
+ { 0x29,0xa1,0x6d,0xc7 }, { 0x20,0xac,0x66,0xc9 },
+ { 0x1f,0x8f,0x57,0xe3 }, { 0x16,0x82,0x5c,0xed },
+ { 0x0d,0x95,0x41,0xff }, { 0x04,0x98,0x4a,0xf1 },
+ { 0x73,0xd3,0x23,0xab }, { 0x7a,0xde,0x28,0xa5 },
+ { 0x61,0xc9,0x35,0xb7 }, { 0x68,0xc4,0x3e,0xb9 },
+ { 0x57,0xe7,0x0f,0x93 }, { 0x5e,0xea,0x04,0x9d },
+ { 0x45,0xfd,0x19,0x8f }, { 0x4c,0xf0,0x12,0x81 },
+ { 0xab,0x6b,0xcb,0x3b }, { 0xa2,0x66,0xc0,0x35 },
+ { 0xb9,0x71,0xdd,0x27 }, { 0xb0,0x7c,0xd6,0x29 },
+ { 0x8f,0x5f,0xe7,0x03 }, { 0x86,0x52,0xec,0x0d },
+ { 0x9d,0x45,0xf1,0x1f }, { 0x94,0x48,0xfa,0x11 },
+ { 0xe3,0x03,0x93,0x4b }, { 0xea,0x0e,0x98,0x45 },
+ { 0xf1,0x19,0x85,0x57 }, { 0xf8,0x14,0x8e,0x59 },
+ { 0xc7,0x37,0xbf,0x73 }, { 0xce,0x3a,0xb4,0x7d },
+ { 0xd5,0x2d,0xa9,0x6f }, { 0xdc,0x20,0xa2,0x61 },
+ { 0x76,0x6d,0xf6,0xad }, { 0x7f,0x60,0xfd,0xa3 },
+ { 0x64,0x77,0xe0,0xb1 }, { 0x6d,0x7a,0xeb,0xbf },
+ { 0x52,0x59,0xda,0x95 }, { 0x5b,0x54,0xd1,0x9b },
+ { 0x40,0x43,0xcc,0x89 }, { 0x49,0x4e,0xc7,0x87 },
+ { 0x3e,0x05,0xae,0xdd }, { 0x37,0x08,0xa5,0xd3 },
+ { 0x2c,0x1f,0xb8,0xc1 }, { 0x25,0x12,0xb3,0xcf },
+ { 0x1a,0x31,0x82,0xe5 }, { 0x13,0x3c,0x89,0xeb },
+ { 0x08,0x2b,0x94,0xf9 }, { 0x01,0x26,0x9f,0xf7 },
+ { 0xe6,0xbd,0x46,0x4d }, { 0xef,0xb0,0x4d,0x43 },
+ { 0xf4,0xa7,0x50,0x51 }, { 0xfd,0xaa,0x5b,0x5f },
+ { 0xc2,0x89,0x6a,0x75 }, { 0xcb,0x84,0x61,0x7b },
+ { 0xd0,0x93,0x7c,0x69 }, { 0xd9,0x9e,0x77,0x67 },
+ { 0xae,0xd5,0x1e,0x3d }, { 0xa7,0xd8,0x15,0x33 },
+ { 0xbc,0xcf,0x08,0x21 }, { 0xb5,0xc2,0x03,0x2f },
+ { 0x8a,0xe1,0x32,0x05 }, { 0x83,0xec,0x39,0x0b },
+ { 0x98,0xfb,0x24,0x19 }, { 0x91,0xf6,0x2f,0x17 },
+ { 0x4d,0xd6,0x8d,0x76 }, { 0x44,0xdb,0x86,0x78 },
+ { 0x5f,0xcc,0x9b,0x6a }, { 0x56,0xc1,0x90,0x64 },
+ { 0x69,0xe2,0xa1,0x4e }, { 0x60,0xef,0xaa,0x40 },
+ { 0x7b,0xf8,0xb7,0x52 }, { 0x72,0xf5,0xbc,0x5c },
+ { 0x05,0xbe,0xd5,0x06 }, { 0x0c,0xb3,0xde,0x08 },
+ { 0x17,0xa4,0xc3,0x1a }, { 0x1e,0xa9,0xc8,0x14 },
+ { 0x21,0x8a,0xf9,0x3e }, { 0x28,0x87,0xf2,0x30 },
+ { 0x33,0x90,0xef,0x22 }, { 0x3a,0x9d,0xe4,0x2c },
+ { 0xdd,0x06,0x3d,0x96 }, { 0xd4,0x0b,0x36,0x98 },
+ { 0xcf,0x1c,0x2b,0x8a }, { 0xc6,0x11,0x20,0x84 },
+ { 0xf9,0x32,0x11,0xae }, { 0xf0,0x3f,0x1a,0xa0 },
+ { 0xeb,0x28,0x07,0xb2 }, { 0xe2,0x25,0x0c,0xbc },
+ { 0x95,0x6e,0x65,0xe6 }, { 0x9c,0x63,0x6e,0xe8 },
+ { 0x87,0x74,0x73,0xfa }, { 0x8e,0x79,0x78,0xf4 },
+ { 0xb1,0x5a,0x49,0xde }, { 0xb8,0x57,0x42,0xd0 },
+ { 0xa3,0x40,0x5f,0xc2 }, { 0xaa,0x4d,0x54,0xcc },
+ { 0xec,0xda,0xf7,0x41 }, { 0xe5,0xd7,0xfc,0x4f },
+ { 0xfe,0xc0,0xe1,0x5d }, { 0xf7,0xcd,0xea,0x53 },
+ { 0xc8,0xee,0xdb,0x79 }, { 0xc1,0xe3,0xd0,0x77 },
+ { 0xda,0xf4,0xcd,0x65 }, { 0xd3,0xf9,0xc6,0x6b },
+ { 0xa4,0xb2,0xaf,0x31 }, { 0xad,0xbf,0xa4,0x3f },
+ { 0xb6,0xa8,0xb9,0x2d }, { 0xbf,0xa5,0xb2,0x23 },
+ { 0x80,0x86,0x83,0x09 }, { 0x89,0x8b,0x88,0x07 },
+ { 0x92,0x9c,0x95,0x15 }, { 0x9b,0x91,0x9e,0x1b },
+ { 0x7c,0x0a,0x47,0xa1 }, { 0x75,0x07,0x4c,0xaf },
+ { 0x6e,0x10,0x51,0xbd }, { 0x67,0x1d,0x5a,0xb3 },
+ { 0x58,0x3e,0x6b,0x99 }, { 0x51,0x33,0x60,0x97 },
+ { 0x4a,0x24,0x7d,0x85 }, { 0x43,0x29,0x76,0x8b },
+ { 0x34,0x62,0x1f,0xd1 }, { 0x3d,0x6f,0x14,0xdf },
+ { 0x26,0x78,0x09,0xcd }, { 0x2f,0x75,0x02,0xc3 },
+ { 0x10,0x56,0x33,0xe9 }, { 0x19,0x5b,0x38,0xe7 },
+ { 0x02,0x4c,0x25,0xf5 }, { 0x0b,0x41,0x2e,0xfb },
+ { 0xd7,0x61,0x8c,0x9a }, { 0xde,0x6c,0x87,0x94 },
+ { 0xc5,0x7b,0x9a,0x86 }, { 0xcc,0x76,0x91,0x88 },
+ { 0xf3,0x55,0xa0,0xa2 }, { 0xfa,0x58,0xab,0xac },
+ { 0xe1,0x4f,0xb6,0xbe }, { 0xe8,0x42,0xbd,0xb0 },
+ { 0x9f,0x09,0xd4,0xea }, { 0x96,0x04,0xdf,0xe4 },
+ { 0x8d,0x13,0xc2,0xf6 }, { 0x84,0x1e,0xc9,0xf8 },
+ { 0xbb,0x3d,0xf8,0xd2 }, { 0xb2,0x30,0xf3,0xdc },
+ { 0xa9,0x27,0xee,0xce }, { 0xa0,0x2a,0xe5,0xc0 },
+ { 0x47,0xb1,0x3c,0x7a }, { 0x4e,0xbc,0x37,0x74 },
+ { 0x55,0xab,0x2a,0x66 }, { 0x5c,0xa6,0x21,0x68 },
+ { 0x63,0x85,0x10,0x42 }, { 0x6a,0x88,0x1b,0x4c },
+ { 0x71,0x9f,0x06,0x5e }, { 0x78,0x92,0x0d,0x50 },
+ { 0x0f,0xd9,0x64,0x0a }, { 0x06,0xd4,0x6f,0x04 },
+ { 0x1d,0xc3,0x72,0x16 }, { 0x14,0xce,0x79,0x18 },
+ { 0x2b,0xed,0x48,0x32 }, { 0x22,0xe0,0x43,0x3c },
+ { 0x39,0xf7,0x5e,0x2e }, { 0x30,0xfa,0x55,0x20 },
+ { 0x9a,0xb7,0x01,0xec }, { 0x93,0xba,0x0a,0xe2 },
+ { 0x88,0xad,0x17,0xf0 }, { 0x81,0xa0,0x1c,0xfe },
+ { 0xbe,0x83,0x2d,0xd4 }, { 0xb7,0x8e,0x26,0xda },
+ { 0xac,0x99,0x3b,0xc8 }, { 0xa5,0x94,0x30,0xc6 },
+ { 0xd2,0xdf,0x59,0x9c }, { 0xdb,0xd2,0x52,0x92 },
+ { 0xc0,0xc5,0x4f,0x80 }, { 0xc9,0xc8,0x44,0x8e },
+ { 0xf6,0xeb,0x75,0xa4 }, { 0xff,0xe6,0x7e,0xaa },
+ { 0xe4,0xf1,0x63,0xb8 }, { 0xed,0xfc,0x68,0xb6 },
+ { 0x0a,0x67,0xb1,0x0c }, { 0x03,0x6a,0xba,0x02 },
+ { 0x18,0x7d,0xa7,0x10 }, { 0x11,0x70,0xac,0x1e },
+ { 0x2e,0x53,0x9d,0x34 }, { 0x27,0x5e,0x96,0x3a },
+ { 0x3c,0x49,0x8b,0x28 }, { 0x35,0x44,0x80,0x26 },
+ { 0x42,0x0f,0xe9,0x7c }, { 0x4b,0x02,0xe2,0x72 },
+ { 0x50,0x15,0xff,0x60 }, { 0x59,0x18,0xf4,0x6e },
+ { 0x66,0x3b,0xc5,0x44 }, { 0x6f,0x36,0xce,0x4a },
+ { 0x74,0x21,0xd3,0x58 }, { 0x7d,0x2c,0xd8,0x56 },
+ { 0xa1,0x0c,0x7a,0x37 }, { 0xa8,0x01,0x71,0x39 },
+ { 0xb3,0x16,0x6c,0x2b }, { 0xba,0x1b,0x67,0x25 },
+ { 0x85,0x38,0x56,0x0f }, { 0x8c,0x35,0x5d,0x01 },
+ { 0x97,0x22,0x40,0x13 }, { 0x9e,0x2f,0x4b,0x1d },
+ { 0xe9,0x64,0x22,0x47 }, { 0xe0,0x69,0x29,0x49 },
+ { 0xfb,0x7e,0x34,0x5b }, { 0xf2,0x73,0x3f,0x55 },
+ { 0xcd,0x50,0x0e,0x7f }, { 0xc4,0x5d,0x05,0x71 },
+ { 0xdf,0x4a,0x18,0x63 }, { 0xd6,0x47,0x13,0x6d },
+ { 0x31,0xdc,0xca,0xd7 }, { 0x38,0xd1,0xc1,0xd9 },
+ { 0x23,0xc6,0xdc,0xcb }, { 0x2a,0xcb,0xd7,0xc5 },
+ { 0x15,0xe8,0xe6,0xef }, { 0x1c,0xe5,0xed,0xe1 },
+ { 0x07,0xf2,0xf0,0xf3 }, { 0x0e,0xff,0xfb,0xfd },
+ { 0x79,0xb4,0x92,0xa7 }, { 0x70,0xb9,0x99,0xa9 },
+ { 0x6b,0xae,0x84,0xbb }, { 0x62,0xa3,0x8f,0xb5 },
+ { 0x5d,0x80,0xbe,0x9f }, { 0x54,0x8d,0xb5,0x91 },
+ { 0x4f,0x9a,0xa8,0x83 }, { 0x46,0x97,0xa3,0x8d }
+ };
+
+static const u32 rcon[30] =
+ {
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c,
+ 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35,
+ 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91
+ };
diff --git a/grub-core/lib/libgcrypt-grub/cipher/rijndael.c b/grub-core/lib/libgcrypt-grub/cipher/rijndael.c
new file mode 100644
index 0000000..92e4d2c
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/rijndael.c
@@ -0,0 +1,1478 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* Rijndael (AES) for GnuPG
+ * Copyright (C) 2000, 2001, 2002, 2003, 2007,
+ * 2008, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *******************************************************************
+ * The code here is based on the optimized implementation taken from
+ * http://www.esat.kuleuven.ac.be/~rijmen/rijndael/ on Oct 2, 2000,
+ * which carries this notice:
+ *------------------------------------------
+ * rijndael-alg-fst.c v2.3 April '2000
+ *
+ * Optimised ANSI C code
+ *
+ * authors: v1.0: Antoon Bosselaers
+ * v2.0: Vincent Rijmen
+ * v2.3: Paulo Barreto
+ *
+ * This code is placed in the public domain.
+ *------------------------------------------
+ *
+ * The SP800-38a document is available at:
+ * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
+ *
+ */
+
+
+#include "types.h" /* for byte and u32 typedefs */
+#include "g10lib.h"
+#include "cipher.h"
+
+#define MAXKC (256/32)
+#define MAXROUNDS 14
+#define BLOCKSIZE (128/8)
+
+
+/* Helper macro to force alignment to 16 bytes. */
+#ifdef __GNUC__
+# define ATTR_ALIGNED_16 __attribute__ ((aligned (16)))
+#else
+# define ATTR_ALIGNED_16
+#endif
+
+
+/* USE_PADLOCK indicates whether to compile the padlock specific
+ code. */
+#undef USE_PADLOCK
+#ifdef ENABLE_PADLOCK_SUPPORT
+# if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4 && defined (__GNUC__)
+# define USE_PADLOCK 1
+# endif
+#endif /*ENABLE_PADLOCK_SUPPORT*/
+
+/* USE_AESNI inidicates whether to compile with Intel AES-NI code. We
+ need the vector-size attribute which seems to be available since
+ gcc 3. However, to be on the safe side we require at least gcc 4. */
+#undef USE_AESNI
+#ifdef ENABLE_AESNI_SUPPORT
+# if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4 && __GNUC__ >= 4
+# define USE_AESNI 1
+# endif
+#endif /* ENABLE_AESNI_SUPPORT */
+
+#ifdef USE_AESNI
+ typedef int m128i_t __attribute__ ((__vector_size__ (16)));
+#endif /*USE_AESNI*/
+
+/* Define an u32 variant for the sake of gcc 4.4's strict aliasing. */
+#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )
+typedef u32 __attribute__ ((__may_alias__)) u32_a_t;
+#else
+typedef u32 u32_a_t;
+#endif
+
+
+
+/* Our context object. */
+typedef struct
+{
+ /* The first fields are the keyschedule arrays. This is so that
+ they are aligned on a 16 byte boundary if using gcc. This
+ alignment is required for the AES-NI code and a good idea in any
+ case. The alignment is guaranteed due to the way cipher.c
+ allocates the space for the context. The PROPERLY_ALIGNED_TYPE
+ hack is used to force a minimal alignment if not using gcc of if
+ the alignment requirement is higher that 16 bytes. */
+ union
+ {
+ PROPERLY_ALIGNED_TYPE dummy;
+ byte keyschedule[MAXROUNDS+1][4][4];
+#ifdef USE_PADLOCK
+ /* The key as passed to the padlock engine. It is only used if
+ the padlock engine is used (USE_PADLOCK, below). */
+ unsigned char padlock_key[16] __attribute__ ((aligned (16)));
+#endif /*USE_PADLOCK*/
+ } u1;
+ union
+ {
+ PROPERLY_ALIGNED_TYPE dummy;
+ byte keyschedule[MAXROUNDS+1][4][4];
+ } u2;
+ int rounds; /* Key-length-dependent number of rounds. */
+ int decryption_prepared; /* The decryption key schedule is available. */
+#ifdef USE_PADLOCK
+ int use_padlock; /* Padlock shall be used. */
+#endif /*USE_PADLOCK*/
+#ifdef USE_AESNI
+ int use_aesni; /* AES-NI shall be used. */
+#endif /*USE_AESNI*/
+} RIJNDAEL_context ATTR_ALIGNED_16;
+
+/* Macros defining alias for the keyschedules. */
+#define keyschenc u1.keyschedule
+#define keyschdec u2.keyschedule
+#define padlockkey u1.padlock_key
+
+/* Two macros to be called prior and after the use of AESNI
+ instructions. There should be no external function calls between
+ the use of these macros. There purpose is to make sure that the
+ SSE regsiters are cleared and won't reveal any information about
+ the key or the data. */
+#ifdef USE_AESNI
+# define aesni_prepare() do { } while (0)
+# define aesni_cleanup() \
+ do { asm volatile ("pxor %%xmm0, %%xmm0\n\t" \
+ "pxor %%xmm1, %%xmm1\n" :: ); \
+ } while (0)
+# define aesni_cleanup_2_4() \
+ do { asm volatile ("pxor %%xmm2, %%xmm2\n\t" \
+ "pxor %%xmm3, %%xmm3\n" \
+ "pxor %%xmm4, %%xmm4\n":: ); \
+ } while (0)
+#else
+# define aesni_prepare() do { } while (0)
+# define aesni_cleanup() do { } while (0)
+#endif
+
+
+/* All the numbers. */
+#include "rijndael-tables.h"
+
+
+
+/* Function prototypes. */
+#ifdef USE_AESNI
+/* We don't want to inline these functions to help gcc allocate enough
+ registers. */
+static void do_aesni_ctr (const RIJNDAEL_context *ctx, unsigned char *ctr,
+ unsigned char *b, const unsigned char *a)
+ __attribute__ ((__noinline__));
+static void do_aesni_ctr_4 (const RIJNDAEL_context *ctx, unsigned char *ctr,
+ unsigned char *b, const unsigned char *a)
+ __attribute__ ((__noinline__));
+#endif /*USE_AESNI*/
+
+
+
+
+/* Perform the key setup. */
+static gcry_err_code_t
+do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
+{
+ static int initialized = 0;
+ static const char *selftest_failed=0;
+ int rounds;
+ int i,j, r, t, rconpointer = 0;
+ int KC;
+ union
+ {
+ PROPERLY_ALIGNED_TYPE dummy;
+ byte k[MAXKC][4];
+ } k;
+#define k k.k
+ union
+ {
+ PROPERLY_ALIGNED_TYPE dummy;
+ byte tk[MAXKC][4];
+ } tk;
+#define tk tk.tk
+
+ /* The on-the-fly self tests are only run in non-fips mode. In fips
+ mode explicit self-tests are required. Actually the on-the-fly
+ self-tests are not fully thread-safe and it might happen that a
+ failed self-test won't get noticed in another thread.
+
+ FIXME: We might want to have a central registry of succeeded
+ self-tests. */
+ if (!fips_mode () && !initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+ if (selftest_failed)
+ log_error ("%s\n", selftest_failed );
+ }
+ if (selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ ctx->decryption_prepared = 0;
+#ifdef USE_PADLOCK
+ ctx->use_padlock = 0;
+#endif
+#ifdef USE_AESNI
+ ctx->use_aesni = 0;
+#endif
+
+ if( keylen == 128/8 )
+ {
+ rounds = 10;
+ KC = 4;
+
+ if (0)
+ ;
+#ifdef USE_PADLOCK
+ else if ((_gcry_get_hw_features () & HWF_PADLOCK_AES))
+ {
+ ctx->use_padlock = 1;
+ memcpy (ctx->padlockkey, key, keylen);
+ }
+#endif
+#ifdef USE_AESNI
+ else if ((_gcry_get_hw_features () & HWF_INTEL_AESNI))
+ {
+ ctx->use_aesni = 1;
+ }
+#endif
+ }
+ else if ( keylen == 192/8 )
+ {
+ rounds = 12;
+ KC = 6;
+
+ if (0)
+ {
+ ;
+ }
+#ifdef USE_AESNI
+ else if ((_gcry_get_hw_features () & HWF_INTEL_AESNI))
+ {
+ ctx->use_aesni = 1;
+ }
+#endif
+ }
+ else if ( keylen == 256/8 )
+ {
+ rounds = 14;
+ KC = 8;
+
+ if (0)
+ {
+ ;
+ }
+#ifdef USE_AESNI
+ else if ((_gcry_get_hw_features () & HWF_INTEL_AESNI))
+ {
+ ctx->use_aesni = 1;
+ }
+#endif
+ }
+ else
+ return GPG_ERR_INV_KEYLEN;
+
+ ctx->rounds = rounds;
+
+ /* NB: We don't yet support Padlock hardware key generation. */
+
+ if (0)
+ ;
+#ifdef USE_AESNI_is_disabled_here
+ else if (ctx->use_aesni && ctx->rounds == 10)
+ {
+ /* Note: This code works for AES-128 but it is not much better
+ than using the standard key schedule. We disable it for
+ now and don't put any effort into implementing this for
+ AES-192 and AES-256. */
+ asm volatile ("movl %[key], %%esi\n\t"
+ "movdqu (%%esi), %%xmm1\n\t" /* xmm1 := key */
+ "movl %[ksch], %%esi\n\t"
+ "movdqa %%xmm1, (%%esi)\n\t" /* ksch[0] := xmm1 */
+ "aeskeygenassist $0x01, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x10(%%esi)\n\t" /* ksch[1] := xmm1 */
+ "aeskeygenassist $0x02, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x20(%%esi)\n\t" /* ksch[2] := xmm1 */
+ "aeskeygenassist $0x04, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x30(%%esi)\n\t" /* ksch[3] := xmm1 */
+ "aeskeygenassist $0x08, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x40(%%esi)\n\t" /* ksch[4] := xmm1 */
+ "aeskeygenassist $0x10, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x50(%%esi)\n\t" /* ksch[5] := xmm1 */
+ "aeskeygenassist $0x20, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x60(%%esi)\n\t" /* ksch[6] := xmm1 */
+ "aeskeygenassist $0x40, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x70(%%esi)\n\t" /* ksch[7] := xmm1 */
+ "aeskeygenassist $0x80, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x80(%%esi)\n\t" /* ksch[8] := xmm1 */
+ "aeskeygenassist $0x1b, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x90(%%esi)\n\t" /* ksch[9] := xmm1 */
+ "aeskeygenassist $0x36, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0xa0(%%esi)\n\t" /* ksch[10] := xmm1 */
+ "jmp .Lleave%=\n"
+
+ ".Lexpand128_%=:\n\t"
+ "pshufd $0xff, %%xmm2, %%xmm2\n\t"
+ "movdqa %%xmm1, %%xmm3\n\t"
+ "pslldq $4, %%xmm3\n\t"
+ "pxor %%xmm3, %%xmm1\n\t"
+ "pslldq $4, %%xmm3\n\t"
+ "pxor %%xmm3, %%xmm1\n\t"
+ "pslldq $4, %%xmm3\n\t"
+ "pxor %%xmm3, %%xmm2\n\t"
+ "pxor %%xmm2, %%xmm1\n\t"
+ "ret\n"
+
+ ".Lleave%=:\n\t"
+ "pxor %%xmm1, %%xmm1\n\t"
+ "pxor %%xmm2, %%xmm2\n\t"
+ "pxor %%xmm3, %%xmm3\n"
+ :
+ : [key] "g" (key), [ksch] "g" (ctx->keyschenc)
+ : "%esi", "cc", "memory" );
+ }
+#endif /*USE_AESNI*/
+ else
+ {
+#define W (ctx->keyschenc)
+ for (i = 0; i < keylen; i++)
+ {
+ k[i >> 2][i & 3] = key[i];
+ }
+
+ for (j = KC-1; j >= 0; j--)
+ {
+ *((u32_a_t*)tk[j]) = *((u32_a_t*)k[j]);
+ }
+ r = 0;
+ t = 0;
+ /* Copy values into round key array. */
+ for (j = 0; (j < KC) && (r < rounds + 1); )
+ {
+ for (; (j < KC) && (t < 4); j++, t++)
+ {
+ *((u32_a_t*)W[r][t]) = *((u32_a_t*)tk[j]);
+ }
+ if (t == 4)
+ {
+ r++;
+ t = 0;
+ }
+ }
+
+ while (r < rounds + 1)
+ {
+ /* While not enough round key material calculated calculate
+ new values. */
+ tk[0][0] ^= S[tk[KC-1][1]];
+ tk[0][1] ^= S[tk[KC-1][2]];
+ tk[0][2] ^= S[tk[KC-1][3]];
+ tk[0][3] ^= S[tk[KC-1][0]];
+ tk[0][0] ^= rcon[rconpointer++];
+
+ if (KC != 8)
+ {
+ for (j = 1; j < KC; j++)
+ {
+ *((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
+ }
+ }
+ else
+ {
+ for (j = 1; j < KC/2; j++)
+ {
+ *((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]];
+ tk[KC/2][2] ^= S[tk[KC/2 - 1][2]];
+ tk[KC/2][3] ^= S[tk[KC/2 - 1][3]];
+ for (j = KC/2 + 1; j < KC; j++)
+ {
+ *((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
+ }
+ }
+
+ /* Copy values into round key array. */
+ for (j = 0; (j < KC) && (r < rounds + 1); )
+ {
+ for (; (j < KC) && (t < 4); j++, t++)
+ {
+ *((u32_a_t*)W[r][t]) = *((u32_a_t*)tk[j]);
+ }
+ if (t == 4)
+ {
+ r++;
+ t = 0;
+ }
+ }
+ }
+#undef W
+ }
+
+ return 0;
+#undef tk
+#undef k
+}
+
+
+static gcry_err_code_t
+rijndael_setkey (void *context, const byte *key, const unsigned keylen)
+{
+ RIJNDAEL_context *ctx = context;
+
+ int rc = do_setkey (ctx, key, keylen);
+ _gcry_burn_stack ( 100 + 16*sizeof(int));
+ return rc;
+}
+
+
+/* Make a decryption key from an encryption key. */
+static void
+prepare_decryption( RIJNDAEL_context *ctx )
+{
+ int r;
+
+#ifdef USE_AESNI
+ if (ctx->use_aesni)
+ {
+ /* The AES-NI decrypt instructions use the Equivalent Inverse
+ Cipher, thus we can't use the the standard decrypt key
+ preparation. */
+ m128i_t *ekey = (m128i_t*)ctx->keyschenc;
+ m128i_t *dkey = (m128i_t*)ctx->keyschdec;
+ int rr;
+
+ dkey[0] = ekey[ctx->rounds];
+ for (r=1, rr=ctx->rounds-1; r < ctx->rounds; r++, rr--)
+ {
+ asm volatile
+ ("movdqu %[ekey], %%xmm1\n\t"
+ /*"aesimc %%xmm1, %%xmm1\n\t"*/
+ ".byte 0x66, 0x0f, 0x38, 0xdb, 0xc9\n\t"
+ "movdqu %%xmm1, %[dkey]"
+ : [dkey] "=m" (dkey[r])
+ : [ekey] "m" (ekey[rr]) );
+ }
+ dkey[r] = ekey[0];
+ }
+ else
+#endif /*USE_AESNI*/
+ {
+ union
+ {
+ PROPERLY_ALIGNED_TYPE dummy;
+ byte *w;
+ } w;
+#define w w.w
+
+ for (r=0; r < MAXROUNDS+1; r++ )
+ {
+ *((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_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_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_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_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
+ }
+}
+
+
+/* Encrypt one block. A and B need to be aligned on a 4 byte
+ boundary. A and B may be the same. */
+static void
+do_encrypt_aligned (const RIJNDAEL_context *ctx,
+ unsigned char *b, const unsigned char *a)
+{
+#define rk (ctx->keyschenc)
+ int rounds = ctx->rounds;
+ int r;
+ union
+ {
+ u32 tempu32[4]; /* Force correct alignment. */
+ byte temp[4][4];
+ } u;
+
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(a )) ^ *((u32_a_t*)rk[0][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(a+ 4)) ^ *((u32_a_t*)rk[0][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(a+ 8)) ^ *((u32_a_t*)rk[0][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(a+12)) ^ *((u32_a_t*)rk[0][3]);
+ *((u32_a_t*)(b )) = (*((u32_a_t*)T1[u.temp[0][0]])
+ ^ *((u32_a_t*)T2[u.temp[1][1]])
+ ^ *((u32_a_t*)T3[u.temp[2][2]])
+ ^ *((u32_a_t*)T4[u.temp[3][3]]));
+ *((u32_a_t*)(b + 4)) = (*((u32_a_t*)T1[u.temp[1][0]])
+ ^ *((u32_a_t*)T2[u.temp[2][1]])
+ ^ *((u32_a_t*)T3[u.temp[3][2]])
+ ^ *((u32_a_t*)T4[u.temp[0][3]]));
+ *((u32_a_t*)(b + 8)) = (*((u32_a_t*)T1[u.temp[2][0]])
+ ^ *((u32_a_t*)T2[u.temp[3][1]])
+ ^ *((u32_a_t*)T3[u.temp[0][2]])
+ ^ *((u32_a_t*)T4[u.temp[1][3]]));
+ *((u32_a_t*)(b +12)) = (*((u32_a_t*)T1[u.temp[3][0]])
+ ^ *((u32_a_t*)T2[u.temp[0][1]])
+ ^ *((u32_a_t*)T3[u.temp[1][2]])
+ ^ *((u32_a_t*)T4[u.temp[2][3]]));
+
+ for (r = 1; r < rounds-1; r++)
+ {
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(b )) ^ *((u32_a_t*)rk[r][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(b+ 4)) ^ *((u32_a_t*)rk[r][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(b+ 8)) ^ *((u32_a_t*)rk[r][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(b+12)) ^ *((u32_a_t*)rk[r][3]);
+
+ *((u32_a_t*)(b )) = (*((u32_a_t*)T1[u.temp[0][0]])
+ ^ *((u32_a_t*)T2[u.temp[1][1]])
+ ^ *((u32_a_t*)T3[u.temp[2][2]])
+ ^ *((u32_a_t*)T4[u.temp[3][3]]));
+ *((u32_a_t*)(b + 4)) = (*((u32_a_t*)T1[u.temp[1][0]])
+ ^ *((u32_a_t*)T2[u.temp[2][1]])
+ ^ *((u32_a_t*)T3[u.temp[3][2]])
+ ^ *((u32_a_t*)T4[u.temp[0][3]]));
+ *((u32_a_t*)(b + 8)) = (*((u32_a_t*)T1[u.temp[2][0]])
+ ^ *((u32_a_t*)T2[u.temp[3][1]])
+ ^ *((u32_a_t*)T3[u.temp[0][2]])
+ ^ *((u32_a_t*)T4[u.temp[1][3]]));
+ *((u32_a_t*)(b +12)) = (*((u32_a_t*)T1[u.temp[3][0]])
+ ^ *((u32_a_t*)T2[u.temp[0][1]])
+ ^ *((u32_a_t*)T3[u.temp[1][2]])
+ ^ *((u32_a_t*)T4[u.temp[2][3]]));
+ }
+
+ /* Last round is special. */
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(b )) ^ *((u32_a_t*)rk[rounds-1][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(b+ 4)) ^ *((u32_a_t*)rk[rounds-1][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(b+ 8)) ^ *((u32_a_t*)rk[rounds-1][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(b+12)) ^ *((u32_a_t*)rk[rounds-1][3]);
+ b[ 0] = T1[u.temp[0][0]][1];
+ b[ 1] = T1[u.temp[1][1]][1];
+ b[ 2] = T1[u.temp[2][2]][1];
+ b[ 3] = T1[u.temp[3][3]][1];
+ b[ 4] = T1[u.temp[1][0]][1];
+ b[ 5] = T1[u.temp[2][1]][1];
+ b[ 6] = T1[u.temp[3][2]][1];
+ b[ 7] = T1[u.temp[0][3]][1];
+ b[ 8] = T1[u.temp[2][0]][1];
+ b[ 9] = T1[u.temp[3][1]][1];
+ b[10] = T1[u.temp[0][2]][1];
+ b[11] = T1[u.temp[1][3]][1];
+ b[12] = T1[u.temp[3][0]][1];
+ b[13] = T1[u.temp[0][1]][1];
+ b[14] = T1[u.temp[1][2]][1];
+ b[15] = T1[u.temp[2][3]][1];
+ *((u32_a_t*)(b )) ^= *((u32_a_t*)rk[rounds][0]);
+ *((u32_a_t*)(b+ 4)) ^= *((u32_a_t*)rk[rounds][1]);
+ *((u32_a_t*)(b+ 8)) ^= *((u32_a_t*)rk[rounds][2]);
+ *((u32_a_t*)(b+12)) ^= *((u32_a_t*)rk[rounds][3]);
+#undef rk
+}
+
+
+static void
+do_encrypt (const RIJNDAEL_context *ctx,
+ unsigned char *bx, const unsigned char *ax)
+{
+ /* BX and AX are not necessary correctly aligned. Thus we might
+ need to copy them here. We try to align to a 16 bytes. */
+ if (((size_t)ax & 0x0f) || ((size_t)bx & 0x0f))
+ {
+ union
+ {
+ u32 dummy[4];
+ byte a[16] ATTR_ALIGNED_16;
+ } a;
+ union
+ {
+ u32 dummy[4];
+ byte b[16] ATTR_ALIGNED_16;
+ } b;
+
+ memcpy (a.a, ax, 16);
+ do_encrypt_aligned (ctx, b.b, a.a);
+ memcpy (bx, b.b, 16);
+ }
+ else
+ {
+ do_encrypt_aligned (ctx, bx, ax);
+ }
+}
+
+
+/* Encrypt or decrypt one block using the padlock engine. A and B may
+ be the same. */
+#ifdef USE_PADLOCK
+static void
+do_padlock (const RIJNDAEL_context *ctx, int decrypt_flag,
+ unsigned char *bx, const unsigned char *ax)
+{
+ /* BX and AX are not necessary correctly aligned. Thus we need to
+ copy them here. */
+ unsigned char a[16] __attribute__ ((aligned (16)));
+ unsigned char b[16] __attribute__ ((aligned (16)));
+ unsigned int cword[4] __attribute__ ((aligned (16)));
+
+ /* The control word fields are:
+ 127:12 11:10 9 8 7 6 5 4 3:0
+ RESERVED KSIZE CRYPT INTER KEYGN CIPHR ALIGN DGEST ROUND */
+ cword[0] = (ctx->rounds & 15); /* (The mask is just a safeguard.) */
+ cword[1] = 0;
+ cword[2] = 0;
+ cword[3] = 0;
+ if (decrypt_flag)
+ cword[0] |= 0x00000200;
+
+ memcpy (a, ax, 16);
+
+ asm volatile
+ ("pushfl\n\t" /* Force key reload. */
+ "popfl\n\t"
+ "xchg %3, %%ebx\n\t" /* Load key. */
+ "movl $1, %%ecx\n\t" /* Init counter for just one block. */
+ ".byte 0xf3, 0x0f, 0xa7, 0xc8\n\t" /* REP XSTORE ECB. */
+ "xchg %3, %%ebx\n" /* Restore GOT register. */
+ : /* No output */
+ : "S" (a), "D" (b), "d" (cword), "r" (ctx->padlockkey)
+ : "%ecx", "cc", "memory"
+ );
+
+ memcpy (bx, b, 16);
+
+}
+#endif /*USE_PADLOCK*/
+
+
+#ifdef USE_AESNI
+/* Encrypt one block using the Intel AES-NI instructions. A and B may
+ be the same; they need to be properly aligned to 16 bytes.
+
+ Our problem here is that gcc does not allow the "x" constraint for
+ SSE registers in asm unless you compile with -msse. The common
+ wisdom is to use a separate file for SSE instructions and build it
+ separately. This would require a lot of extra build system stuff,
+ similar to what we do in mpi/ for the asm stuff. What we do
+ instead is to use standard registers and a bit more of plain asm
+ which copies the data and key stuff to the SSE registers and later
+ back. If we decide to implement some block modes with parallelized
+ AES instructions, it might indeed be better to use plain asm ala
+ mpi/. */
+static void
+do_aesni_enc_aligned (const RIJNDAEL_context *ctx,
+ unsigned char *b, const unsigned char *a)
+{
+#define aesenc_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xc1\n\t"
+#define aesenclast_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xc1\n\t"
+ /* Note: For now we relax the alignment requirement for A and B: It
+ does not make much difference because in many case we would need
+ to memcpy them to an extra buffer; using the movdqu is much faster
+ that memcpy and movdqa. For CFB we know that the IV is properly
+ aligned but that is a special case. We should better implement
+ CFB direct in asm. */
+ asm volatile ("movdqu %[src], %%xmm0\n\t" /* xmm0 := *a */
+ "movl %[key], %%esi\n\t" /* esi := keyschenc */
+ "movdqa (%%esi), %%xmm1\n\t" /* xmm1 := key[0] */
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 ^= key[0] */
+ "movdqa 0x10(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x20(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x30(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x40(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x50(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x60(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x70(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x80(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x90(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xa0(%%esi), %%xmm1\n\t"
+ "cmp $10, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xb0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xc0(%%esi), %%xmm1\n\t"
+ "cmp $12, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xd0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xe0(%%esi), %%xmm1\n"
+
+ ".Lenclast%=:\n\t"
+ aesenclast_xmm1_xmm0
+ "movdqu %%xmm0, %[dst]\n"
+ : [dst] "=m" (*b)
+ : [src] "m" (*a),
+ [key] "r" (ctx->keyschenc),
+ [rounds] "r" (ctx->rounds)
+ : "%esi", "cc", "memory");
+#undef aesenc_xmm1_xmm0
+#undef aesenclast_xmm1_xmm0
+}
+
+
+static void
+do_aesni_dec_aligned (const RIJNDAEL_context *ctx,
+ unsigned char *b, const unsigned char *a)
+{
+#define aesdec_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xde, 0xc1\n\t"
+#define aesdeclast_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdf, 0xc1\n\t"
+ asm volatile ("movdqu %[src], %%xmm0\n\t" /* xmm0 := *a */
+ "movl %[key], %%esi\n\t"
+ "movdqa (%%esi), %%xmm1\n\t"
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 ^= key[0] */
+ "movdqa 0x10(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x20(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x30(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x40(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x50(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x60(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x70(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x80(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x90(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0xa0(%%esi), %%xmm1\n\t"
+ "cmp $10, %[rounds]\n\t"
+ "jz .Ldeclast%=\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0xb0(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0xc0(%%esi), %%xmm1\n\t"
+ "cmp $12, %[rounds]\n\t"
+ "jz .Ldeclast%=\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0xd0(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0xe0(%%esi), %%xmm1\n"
+
+ ".Ldeclast%=:\n\t"
+ aesdeclast_xmm1_xmm0
+ "movdqu %%xmm0, %[dst]\n"
+ : [dst] "=m" (*b)
+ : [src] "m" (*a),
+ [key] "r" (ctx->keyschdec),
+ [rounds] "r" (ctx->rounds)
+ : "%esi", "cc", "memory");
+#undef aesdec_xmm1_xmm0
+#undef aesdeclast_xmm1_xmm0
+}
+
+
+/* Perform a CFB encryption or decryption round using the
+ initialization vector IV and the input block A. Write the result
+ to the output block B and update IV. IV needs to be 16 byte
+ aligned. */
+static void
+do_aesni_cfb (const RIJNDAEL_context *ctx, int decrypt_flag,
+ unsigned char *iv, unsigned char *b, const unsigned char *a)
+{
+#define aesenc_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xc1\n\t"
+#define aesenclast_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xc1\n\t"
+ asm volatile ("movdqa %[iv], %%xmm0\n\t" /* xmm0 := IV */
+ "movl %[key], %%esi\n\t" /* esi := keyschenc */
+ "movdqa (%%esi), %%xmm1\n\t" /* xmm1 := key[0] */
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 ^= key[0] */
+ "movdqa 0x10(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x20(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x30(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x40(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x50(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x60(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x70(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x80(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x90(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xa0(%%esi), %%xmm1\n\t"
+ "cmp $10, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xb0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xc0(%%esi), %%xmm1\n\t"
+ "cmp $12, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xd0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xe0(%%esi), %%xmm1\n"
+
+ ".Lenclast%=:\n\t"
+ aesenclast_xmm1_xmm0
+ "movdqu %[src], %%xmm1\n\t" /* Save input. */
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 = input ^ IV */
+
+ "cmp $1, %[decrypt]\n\t"
+ "jz .Ldecrypt_%=\n\t"
+ "movdqa %%xmm0, %[iv]\n\t" /* [encrypt] Store IV. */
+ "jmp .Lleave_%=\n"
+ ".Ldecrypt_%=:\n\t"
+ "movdqa %%xmm1, %[iv]\n" /* [decrypt] Store IV. */
+ ".Lleave_%=:\n\t"
+ "movdqu %%xmm0, %[dst]\n" /* Store output. */
+ : [iv] "+m" (*iv), [dst] "=m" (*b)
+ : [src] "m" (*a),
+ [key] "g" (ctx->keyschenc),
+ [rounds] "g" (ctx->rounds),
+ [decrypt] "m" (decrypt_flag)
+ : "%esi", "cc", "memory");
+#undef aesenc_xmm1_xmm0
+#undef aesenclast_xmm1_xmm0
+}
+
+/* Perform a CTR encryption round using the counter CTR and the input
+ block A. Write the result to the output block B and update CTR.
+ CTR needs to be a 16 byte aligned little-endian value. */
+static void
+do_aesni_ctr (const RIJNDAEL_context *ctx,
+ unsigned char *ctr, unsigned char *b, const unsigned char *a)
+{
+#define aesenc_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xc1\n\t"
+#define aesenclast_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xc1\n\t"
+ static unsigned char be_mask[16] __attribute__ ((aligned (16))) =
+ { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
+
+ asm volatile ("movdqa %[ctr], %%xmm0\n\t" /* xmm0, xmm2 := CTR */
+ "movaps %%xmm0, %%xmm2\n\t"
+ "mov $1, %%esi\n\t" /* xmm2++ (big-endian) */
+ "movd %%esi, %%xmm1\n\t"
+ "pshufb %[mask], %%xmm2\n\t"
+ "paddq %%xmm1, %%xmm2\n\t"
+ "pshufb %[mask], %%xmm2\n\t"
+ "movdqa %%xmm2, %[ctr]\n" /* Update CTR. */
+
+ "movl %[key], %%esi\n\t" /* esi := keyschenc */
+ "movdqa (%%esi), %%xmm1\n\t" /* xmm1 := key[0] */
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 ^= key[0] */
+ "movdqa 0x10(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x20(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x30(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x40(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x50(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x60(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x70(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x80(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x90(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xa0(%%esi), %%xmm1\n\t"
+ "cmp $10, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xb0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xc0(%%esi), %%xmm1\n\t"
+ "cmp $12, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xd0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xe0(%%esi), %%xmm1\n"
+
+ ".Lenclast%=:\n\t"
+ aesenclast_xmm1_xmm0
+ "movdqu %[src], %%xmm1\n\t" /* xmm1 := input */
+ "pxor %%xmm1, %%xmm0\n\t" /* EncCTR ^= input */
+ "movdqu %%xmm0, %[dst]" /* Store EncCTR. */
+
+ : [ctr] "+m" (*ctr), [dst] "=m" (*b)
+ : [src] "m" (*a),
+ [key] "g" (ctx->keyschenc),
+ [rounds] "g" (ctx->rounds),
+ [mask] "m" (*be_mask)
+ : "%esi", "cc", "memory");
+#undef aesenc_xmm1_xmm0
+#undef aesenclast_xmm1_xmm0
+}
+
+
+/* Four blocks at a time variant of do_aesni_ctr. */
+static void
+do_aesni_ctr_4 (const RIJNDAEL_context *ctx,
+ unsigned char *ctr, unsigned char *b, const unsigned char *a)
+{
+#define aesenc_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xc1\n\t"
+#define aesenc_xmm1_xmm2 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xd1\n\t"
+#define aesenc_xmm1_xmm3 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xd9\n\t"
+#define aesenc_xmm1_xmm4 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xe1\n\t"
+#define aesenclast_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xc1\n\t"
+#define aesenclast_xmm1_xmm2 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xd1\n\t"
+#define aesenclast_xmm1_xmm3 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xd9\n\t"
+#define aesenclast_xmm1_xmm4 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xe1\n\t"
+
+ static unsigned char be_mask[16] __attribute__ ((aligned (16))) =
+ { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
+
+ /* Register usage:
+ esi keyschedule
+ xmm0 CTR-0
+ xmm1 temp / round key
+ xmm2 CTR-1
+ xmm3 CTR-2
+ xmm4 CTR-3
+ xmm5 temp
+ */
+
+ asm volatile ("movdqa %[ctr], %%xmm0\n\t" /* xmm0, xmm2 := CTR */
+ "movaps %%xmm0, %%xmm2\n\t"
+ "mov $1, %%esi\n\t" /* xmm1 := 1 */
+ "movd %%esi, %%xmm1\n\t"
+ "pshufb %[mask], %%xmm2\n\t" /* xmm2 := le(xmm2) */
+ "paddq %%xmm1, %%xmm2\n\t" /* xmm2++ */
+ "movaps %%xmm2, %%xmm3\n\t" /* xmm3 := xmm2 */
+ "paddq %%xmm1, %%xmm3\n\t" /* xmm3++ */
+ "movaps %%xmm3, %%xmm4\n\t" /* xmm4 := xmm3 */
+ "paddq %%xmm1, %%xmm4\n\t" /* xmm4++ */
+ "movaps %%xmm4, %%xmm5\n\t" /* xmm5 := xmm4 */
+ "paddq %%xmm1, %%xmm5\n\t" /* xmm5++ */
+ "pshufb %[mask], %%xmm2\n\t" /* xmm2 := be(xmm2) */
+ "pshufb %[mask], %%xmm3\n\t" /* xmm3 := be(xmm3) */
+ "pshufb %[mask], %%xmm4\n\t" /* xmm4 := be(xmm4) */
+ "pshufb %[mask], %%xmm5\n\t" /* xmm5 := be(xmm5) */
+ "movdqa %%xmm5, %[ctr]\n" /* Update CTR. */
+
+ "movl %[key], %%esi\n\t" /* esi := keyschenc */
+ "movdqa (%%esi), %%xmm1\n\t" /* xmm1 := key[0] */
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 ^= key[0] */
+ "pxor %%xmm1, %%xmm2\n\t" /* xmm2 ^= key[0] */
+ "pxor %%xmm1, %%xmm3\n\t" /* xmm3 ^= key[0] */
+ "pxor %%xmm1, %%xmm4\n\t" /* xmm4 ^= key[0] */
+ "movdqa 0x10(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x20(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x30(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x40(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x50(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x60(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x70(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x80(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x90(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0xa0(%%esi), %%xmm1\n\t"
+ "cmp $10, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0xb0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0xc0(%%esi), %%xmm1\n\t"
+ "cmp $12, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0xd0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0xe0(%%esi), %%xmm1\n"
+
+ ".Lenclast%=:\n\t"
+ aesenclast_xmm1_xmm0
+ aesenclast_xmm1_xmm2
+ aesenclast_xmm1_xmm3
+ aesenclast_xmm1_xmm4
+
+ "movdqu %[src], %%xmm1\n\t" /* Get block 1. */
+ "pxor %%xmm1, %%xmm0\n\t" /* EncCTR-1 ^= input */
+ "movdqu %%xmm0, %[dst]\n\t" /* Store block 1 */
+
+ "movdqu (16)%[src], %%xmm1\n\t" /* Get block 2. */
+ "pxor %%xmm1, %%xmm2\n\t" /* EncCTR-2 ^= input */
+ "movdqu %%xmm2, (16)%[dst]\n\t" /* Store block 2. */
+
+ "movdqu (32)%[src], %%xmm1\n\t" /* Get block 3. */
+ "pxor %%xmm1, %%xmm3\n\t" /* EncCTR-3 ^= input */
+ "movdqu %%xmm3, (32)%[dst]\n\t" /* Store block 3. */
+
+ "movdqu (48)%[src], %%xmm1\n\t" /* Get block 4. */
+ "pxor %%xmm1, %%xmm4\n\t" /* EncCTR-4 ^= input */
+ "movdqu %%xmm4, (48)%[dst]" /* Store block 4. */
+
+ : [ctr] "+m" (*ctr), [dst] "=m" (*b)
+ : [src] "m" (*a),
+ [key] "g" (ctx->keyschenc),
+ [rounds] "g" (ctx->rounds),
+ [mask] "m" (*be_mask)
+ : "%esi", "cc", "memory");
+#undef aesenc_xmm1_xmm0
+#undef aesenc_xmm1_xmm2
+#undef aesenc_xmm1_xmm3
+#undef aesenc_xmm1_xmm4
+#undef aesenclast_xmm1_xmm0
+#undef aesenclast_xmm1_xmm2
+#undef aesenclast_xmm1_xmm3
+#undef aesenclast_xmm1_xmm4
+}
+
+
+static void
+do_aesni (RIJNDAEL_context *ctx, int decrypt_flag,
+ unsigned char *bx, const unsigned char *ax)
+{
+
+ if (decrypt_flag)
+ {
+ if (!ctx->decryption_prepared )
+ {
+ prepare_decryption ( ctx );
+ ctx->decryption_prepared = 1;
+ }
+ do_aesni_dec_aligned (ctx, bx, ax);
+ }
+ else
+ do_aesni_enc_aligned (ctx, bx, ax);
+}
+#endif /*USE_AESNI*/
+
+
+static void
+rijndael_encrypt (void *context, byte *b, const byte *a)
+{
+ RIJNDAEL_context *ctx = context;
+
+ if (0)
+ ;
+#ifdef USE_PADLOCK
+ else if (ctx->use_padlock)
+ {
+ do_padlock (ctx, 0, b, a);
+ _gcry_burn_stack (48 + 15 /* possible padding for alignment */);
+ }
+#endif /*USE_PADLOCK*/
+#ifdef USE_AESNI
+ else if (ctx->use_aesni)
+ {
+ aesni_prepare ();
+ do_aesni (ctx, 0, b, a);
+ aesni_cleanup ();
+ }
+#endif /*USE_AESNI*/
+ else
+ {
+ do_encrypt (ctx, b, a);
+ _gcry_burn_stack (56 + 2*sizeof(int));
+ }
+}
+
+
+/* Bulk encryption of complete blocks in CFB mode. Caller needs to
+ make sure that IV is aligned on an unsigned long boundary. This
+ function is only intended for the bulk encryption feature of
+ cipher.c. */
+
+
+/* Bulk encryption of complete blocks in CBC mode. Caller needs to
+ make sure that IV is aligned on an unsigned long boundary. This
+ function is only intended for the bulk encryption feature of
+ cipher.c. */
+
+
+/* Bulk encryption of complete blocks in CTR mode. Caller needs to
+ make sure that CTR is aligned on a 16 byte boundary if AESNI; the
+ minimum alignment is for an u32. This function is only intended
+ for the bulk encryption feature of cipher.c. CTR is expected to be
+ of size BLOCKSIZE. */
+
+
+
+/* Decrypt one block. A and B need to be aligned on a 4 byte boundary
+ and the decryption must have been prepared. A and B may be the
+ same. */
+static void
+do_decrypt_aligned (RIJNDAEL_context *ctx,
+ unsigned char *b, const unsigned char *a)
+{
+#define rk (ctx->keyschdec)
+ int rounds = ctx->rounds;
+ int r;
+ union
+ {
+ u32 tempu32[4]; /* Force correct alignment. */
+ byte temp[4][4];
+ } u;
+
+
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(a )) ^ *((u32_a_t*)rk[rounds][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(a+ 4)) ^ *((u32_a_t*)rk[rounds][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(a+ 8)) ^ *((u32_a_t*)rk[rounds][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(a+12)) ^ *((u32_a_t*)rk[rounds][3]);
+
+ *((u32_a_t*)(b )) = (*((u32_a_t*)T5[u.temp[0][0]])
+ ^ *((u32_a_t*)T6[u.temp[3][1]])
+ ^ *((u32_a_t*)T7[u.temp[2][2]])
+ ^ *((u32_a_t*)T8[u.temp[1][3]]));
+ *((u32_a_t*)(b+ 4)) = (*((u32_a_t*)T5[u.temp[1][0]])
+ ^ *((u32_a_t*)T6[u.temp[0][1]])
+ ^ *((u32_a_t*)T7[u.temp[3][2]])
+ ^ *((u32_a_t*)T8[u.temp[2][3]]));
+ *((u32_a_t*)(b+ 8)) = (*((u32_a_t*)T5[u.temp[2][0]])
+ ^ *((u32_a_t*)T6[u.temp[1][1]])
+ ^ *((u32_a_t*)T7[u.temp[0][2]])
+ ^ *((u32_a_t*)T8[u.temp[3][3]]));
+ *((u32_a_t*)(b+12)) = (*((u32_a_t*)T5[u.temp[3][0]])
+ ^ *((u32_a_t*)T6[u.temp[2][1]])
+ ^ *((u32_a_t*)T7[u.temp[1][2]])
+ ^ *((u32_a_t*)T8[u.temp[0][3]]));
+
+ for (r = rounds-1; r > 1; r--)
+ {
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(b )) ^ *((u32_a_t*)rk[r][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(b+ 4)) ^ *((u32_a_t*)rk[r][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(b+ 8)) ^ *((u32_a_t*)rk[r][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(b+12)) ^ *((u32_a_t*)rk[r][3]);
+ *((u32_a_t*)(b )) = (*((u32_a_t*)T5[u.temp[0][0]])
+ ^ *((u32_a_t*)T6[u.temp[3][1]])
+ ^ *((u32_a_t*)T7[u.temp[2][2]])
+ ^ *((u32_a_t*)T8[u.temp[1][3]]));
+ *((u32_a_t*)(b+ 4)) = (*((u32_a_t*)T5[u.temp[1][0]])
+ ^ *((u32_a_t*)T6[u.temp[0][1]])
+ ^ *((u32_a_t*)T7[u.temp[3][2]])
+ ^ *((u32_a_t*)T8[u.temp[2][3]]));
+ *((u32_a_t*)(b+ 8)) = (*((u32_a_t*)T5[u.temp[2][0]])
+ ^ *((u32_a_t*)T6[u.temp[1][1]])
+ ^ *((u32_a_t*)T7[u.temp[0][2]])
+ ^ *((u32_a_t*)T8[u.temp[3][3]]));
+ *((u32_a_t*)(b+12)) = (*((u32_a_t*)T5[u.temp[3][0]])
+ ^ *((u32_a_t*)T6[u.temp[2][1]])
+ ^ *((u32_a_t*)T7[u.temp[1][2]])
+ ^ *((u32_a_t*)T8[u.temp[0][3]]));
+ }
+
+ /* Last round is special. */
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(b )) ^ *((u32_a_t*)rk[1][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(b+ 4)) ^ *((u32_a_t*)rk[1][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(b+ 8)) ^ *((u32_a_t*)rk[1][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(b+12)) ^ *((u32_a_t*)rk[1][3]);
+ b[ 0] = S5[u.temp[0][0]];
+ b[ 1] = S5[u.temp[3][1]];
+ b[ 2] = S5[u.temp[2][2]];
+ b[ 3] = S5[u.temp[1][3]];
+ b[ 4] = S5[u.temp[1][0]];
+ b[ 5] = S5[u.temp[0][1]];
+ b[ 6] = S5[u.temp[3][2]];
+ b[ 7] = S5[u.temp[2][3]];
+ b[ 8] = S5[u.temp[2][0]];
+ b[ 9] = S5[u.temp[1][1]];
+ b[10] = S5[u.temp[0][2]];
+ b[11] = S5[u.temp[3][3]];
+ b[12] = S5[u.temp[3][0]];
+ b[13] = S5[u.temp[2][1]];
+ b[14] = S5[u.temp[1][2]];
+ b[15] = S5[u.temp[0][3]];
+ *((u32_a_t*)(b )) ^= *((u32_a_t*)rk[0][0]);
+ *((u32_a_t*)(b+ 4)) ^= *((u32_a_t*)rk[0][1]);
+ *((u32_a_t*)(b+ 8)) ^= *((u32_a_t*)rk[0][2]);
+ *((u32_a_t*)(b+12)) ^= *((u32_a_t*)rk[0][3]);
+#undef rk
+}
+
+
+/* Decrypt one block. AX and BX may be the same. */
+static void
+do_decrypt (RIJNDAEL_context *ctx, byte *bx, const byte *ax)
+{
+ if ( !ctx->decryption_prepared )
+ {
+ prepare_decryption ( ctx );
+ _gcry_burn_stack (64);
+ ctx->decryption_prepared = 1;
+ }
+
+ /* BX and AX are not necessary correctly aligned. Thus we might
+ need to copy them here. We try to align to a 16 bytes. */
+ if (((size_t)ax & 0x0f) || ((size_t)bx & 0x0f))
+ {
+ union
+ {
+ u32 dummy[4];
+ byte a[16] ATTR_ALIGNED_16;
+ } a;
+ union
+ {
+ u32 dummy[4];
+ byte b[16] ATTR_ALIGNED_16;
+ } b;
+
+ memcpy (a.a, ax, 16);
+ do_decrypt_aligned (ctx, b.b, a.a);
+ memcpy (bx, b.b, 16);
+ }
+ else
+ {
+ do_decrypt_aligned (ctx, bx, ax);
+ }
+}
+
+
+
+
+static void
+rijndael_decrypt (void *context, byte *b, const byte *a)
+{
+ RIJNDAEL_context *ctx = context;
+
+ if (0)
+ ;
+#ifdef USE_PADLOCK
+ else if (ctx->use_padlock)
+ {
+ do_padlock (ctx, 1, b, a);
+ _gcry_burn_stack (48 + 2*sizeof(int) /* FIXME */);
+ }
+#endif /*USE_PADLOCK*/
+#ifdef USE_AESNI
+ else if (ctx->use_aesni)
+ {
+ aesni_prepare ();
+ do_aesni (ctx, 1, b, a);
+ aesni_cleanup ();
+ }
+#endif /*USE_AESNI*/
+ else
+ {
+ do_decrypt (ctx, b, a);
+ _gcry_burn_stack (56+2*sizeof(int));
+ }
+}
+
+
+/* Bulk decryption of complete blocks in CFB mode. Caller needs to
+ make sure that IV is aligned on an unisgned lonhg boundary. This
+ function is only intended for the bulk encryption feature of
+ cipher.c. */
+
+
+/* Bulk decryption of complete blocks in CBC mode. Caller needs to
+ make sure that IV is aligned on an unsigned long boundary. This
+ function is only intended for the bulk encryption feature of
+ cipher.c. */
+
+
+
+
+/* Run the self-tests for AES 128. Returns NULL on success. */
+
+/* Run the self-tests for AES 192. Returns NULL on success. */
+
+
+/* Run the self-tests for AES 256. Returns NULL on success. */
+
+/* Run all the self-tests and return NULL on success. This function
+ is used for the on-the-fly self-tests. */
+
+
+/* SP800-38a.pdf for AES-128. */
+
+
+/* Complete selftest for AES-128 with all modes and driver code. */
+
+/* Complete selftest for AES-192. */
+
+
+/* Complete selftest for AES-256. */
+
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+
+
+
+
+static const char *rijndael_names[] =
+ {
+ "RIJNDAEL",
+ "AES128",
+ "AES-128",
+ NULL
+ };
+
+static gcry_cipher_oid_spec_t rijndael_oids[] =
+ {
+ { "2.16.840.1.101.3.4.1.1", GCRY_CIPHER_MODE_ECB },
+ { "2.16.840.1.101.3.4.1.2", GCRY_CIPHER_MODE_CBC },
+ { "2.16.840.1.101.3.4.1.3", GCRY_CIPHER_MODE_OFB },
+ { "2.16.840.1.101.3.4.1.4", GCRY_CIPHER_MODE_CFB },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_aes =
+ {
+ "AES", rijndael_names, rijndael_oids, 16, 128, sizeof (RIJNDAEL_context),
+ rijndael_setkey, rijndael_encrypt, rijndael_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_rijndael",
+#endif
+ };
+
+static const char *rijndael192_names[] =
+ {
+ "RIJNDAEL192",
+ "AES-192",
+ NULL
+ };
+
+static gcry_cipher_oid_spec_t rijndael192_oids[] =
+ {
+ { "2.16.840.1.101.3.4.1.21", GCRY_CIPHER_MODE_ECB },
+ { "2.16.840.1.101.3.4.1.22", GCRY_CIPHER_MODE_CBC },
+ { "2.16.840.1.101.3.4.1.23", GCRY_CIPHER_MODE_OFB },
+ { "2.16.840.1.101.3.4.1.24", GCRY_CIPHER_MODE_CFB },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_aes192 =
+ {
+ "AES192", rijndael192_names, rijndael192_oids, 16, 192, sizeof (RIJNDAEL_context),
+ rijndael_setkey, rijndael_encrypt, rijndael_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_rijndael",
+#endif
+ };
+
+static const char *rijndael256_names[] =
+ {
+ "RIJNDAEL256",
+ "AES-256",
+ NULL
+ };
+
+static gcry_cipher_oid_spec_t rijndael256_oids[] =
+ {
+ { "2.16.840.1.101.3.4.1.41", GCRY_CIPHER_MODE_ECB },
+ { "2.16.840.1.101.3.4.1.42", GCRY_CIPHER_MODE_CBC },
+ { "2.16.840.1.101.3.4.1.43", GCRY_CIPHER_MODE_OFB },
+ { "2.16.840.1.101.3.4.1.44", GCRY_CIPHER_MODE_CFB },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_aes256 =
+ {
+ "AES256", rijndael256_names, rijndael256_oids, 16, 256,
+ sizeof (RIJNDAEL_context),
+ rijndael_setkey, rijndael_encrypt, rijndael_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_rijndael",
+#endif
+ };
+
+
+
+GRUB_MOD_INIT(gcry_rijndael)
+{
+ grub_cipher_register (&_gcry_cipher_spec_aes);
+ grub_cipher_register (&_gcry_cipher_spec_aes192);
+ grub_cipher_register (&_gcry_cipher_spec_aes256);
+}
+
+GRUB_MOD_FINI(gcry_rijndael)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_aes);
+ grub_cipher_unregister (&_gcry_cipher_spec_aes192);
+ grub_cipher_unregister (&_gcry_cipher_spec_aes256);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/rmd.h b/grub-core/lib/libgcrypt-grub/cipher/rmd.h
new file mode 100644
index 0000000..75bb21f
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/rmd.h
@@ -0,0 +1,39 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+/* rmd.h - RIPE-MD hash functions
+ * Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+#ifndef G10_RMD_H
+#define G10_RMD_H
+
+
+/* We need this here because random.c must have direct access. */
+typedef struct
+{
+ u32 h0,h1,h2,h3,h4;
+ u32 nblocks;
+ byte buf[64];
+ int count;
+} RMD160_CONTEXT;
+
+void _gcry_rmd160_init ( void *context );
+void _gcry_rmd160_mixblock ( RMD160_CONTEXT *hd, void *blockof64byte );
+
+#endif /*G10_RMD_H*/
diff --git a/grub-core/lib/libgcrypt-grub/cipher/rmd160.c b/grub-core/lib/libgcrypt-grub/cipher/rmd160.c
new file mode 100644
index 0000000..620fe98
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/rmd160.c
@@ -0,0 +1,565 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* rmd160.c - RIPE-MD160
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+#include "g10lib.h"
+#include "rmd.h"
+#include "cipher.h" /* Only used for the rmd160_hash_buffer() prototype. */
+
+#include "bithelp.h"
+
+/*********************************
+ * RIPEMD-160 is not patented, see (as of 25.10.97)
+ * http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html
+ * Note that the code uses Little Endian byteorder, which is good for
+ * 386 etc, but we must add some conversion when used on a big endian box.
+ *
+ *
+ * Pseudo-code for RIPEMD-160
+ *
+ * RIPEMD-160 is an iterative hash function that operates on 32-bit words.
+ * The round function takes as input a 5-word chaining variable and a 16-word
+ * message block and maps this to a new chaining variable. All operations are
+ * defined on 32-bit words. Padding is identical to that of MD4.
+ *
+ *
+ * RIPEMD-160: definitions
+ *
+ *
+ * nonlinear functions at bit level: exor, mux, -, mux, -
+ *
+ * f(j, x, y, z) = x XOR y XOR z (0 <= j <= 15)
+ * f(j, x, y, z) = (x AND y) OR (NOT(x) AND z) (16 <= j <= 31)
+ * f(j, x, y, z) = (x OR NOT(y)) XOR z (32 <= j <= 47)
+ * f(j, x, y, z) = (x AND z) OR (y AND NOT(z)) (48 <= j <= 63)
+ * f(j, x, y, z) = x XOR (y OR NOT(z)) (64 <= j <= 79)
+ *
+ *
+ * added constants (hexadecimal)
+ *
+ * K(j) = 0x00000000 (0 <= j <= 15)
+ * K(j) = 0x5A827999 (16 <= j <= 31) int(2**30 x sqrt(2))
+ * K(j) = 0x6ED9EBA1 (32 <= j <= 47) int(2**30 x sqrt(3))
+ * K(j) = 0x8F1BBCDC (48 <= j <= 63) int(2**30 x sqrt(5))
+ * K(j) = 0xA953FD4E (64 <= j <= 79) int(2**30 x sqrt(7))
+ * K'(j) = 0x50A28BE6 (0 <= j <= 15) int(2**30 x cbrt(2))
+ * K'(j) = 0x5C4DD124 (16 <= j <= 31) int(2**30 x cbrt(3))
+ * K'(j) = 0x6D703EF3 (32 <= j <= 47) int(2**30 x cbrt(5))
+ * K'(j) = 0x7A6D76E9 (48 <= j <= 63) int(2**30 x cbrt(7))
+ * K'(j) = 0x00000000 (64 <= j <= 79)
+ *
+ *
+ * selection of message word
+ *
+ * r(j) = j (0 <= j <= 15)
+ * r(16..31) = 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8
+ * r(32..47) = 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12
+ * r(48..63) = 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2
+ * r(64..79) = 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
+ * r0(0..15) = 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12
+ * r0(16..31)= 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2
+ * r0(32..47)= 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13
+ * r0(48..63)= 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14
+ * r0(64..79)= 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
+ *
+ *
+ * amount for rotate left (rol)
+ *
+ * s(0..15) = 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8
+ * s(16..31) = 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12
+ * s(32..47) = 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5
+ * s(48..63) = 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12
+ * s(64..79) = 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
+ * s'(0..15) = 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6
+ * s'(16..31)= 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11
+ * s'(32..47)= 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5
+ * s'(48..63)= 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8
+ * s'(64..79)= 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
+ *
+ *
+ * initial value (hexadecimal)
+ *
+ * h0 = 0x67452301; h1 = 0xEFCDAB89; h2 = 0x98BADCFE; h3 = 0x10325476;
+ * h4 = 0xC3D2E1F0;
+ *
+ *
+ * RIPEMD-160: pseudo-code
+ *
+ * It is assumed that the message after padding consists of t 16-word blocks
+ * that will be denoted with X[i][j], with 0 <= i <= t-1 and 0 <= j <= 15.
+ * The symbol [+] denotes addition modulo 2**32 and rol_s denotes cyclic left
+ * shift (rotate) over s positions.
+ *
+ *
+ * for i := 0 to t-1 {
+ * A := h0; B := h1; C := h2; D = h3; E = h4;
+ * A' := h0; B' := h1; C' := h2; D' = h3; E' = h4;
+ * for j := 0 to 79 {
+ * T := rol_s(j)(A [+] f(j, B, C, D) [+] X[i][r(j)] [+] K(j)) [+] E;
+ * A := E; E := D; D := rol_10(C); C := B; B := T;
+ * T := rol_s'(j)(A' [+] f(79-j, B', C', D') [+] X[i][r'(j)]
+ [+] K'(j)) [+] E';
+ * A' := E'; E' := D'; D' := rol_10(C'); C' := B'; B' := T;
+ * }
+ * T := h1 [+] C [+] D'; h1 := h2 [+] D [+] E'; h2 := h3 [+] E [+] A';
+ * h3 := h4 [+] A [+] B'; h4 := h0 [+] B [+] C'; h0 := T;
+ * }
+ */
+
+/* Some examples:
+ * "" 9c1185a5c5e9fc54612808977ee8f548b2258d31
+ * "a" 0bdc9d2d256b3ee9daae347be6f4dc835a467ffe
+ * "abc" 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc
+ * "message digest" 5d0689ef49d2fae572b881b123a85ffa21595f36
+ * "a...z" f71c27109c692c1b56bbdceb5b9d2865b3708dbc
+ * "abcdbcde...nopq" 12a053384a9c0c88e405a06c27dcf49ada62eb2b
+ * "A...Za...z0...9" b0e20b6e3116640286ed3a87a5713079b21f5189
+ * 8 times "1234567890" 9b752e45573d4b39f4dbd3323cab82bf63326bfb
+ * 1 million times "a" 52783243c1697bdbe16d37f97f68f08325dc1528
+ */
+
+
+void
+_gcry_rmd160_init (void *context)
+{
+ RMD160_CONTEXT *hd = context;
+
+ hd->h0 = 0x67452301;
+ hd->h1 = 0xEFCDAB89;
+ hd->h2 = 0x98BADCFE;
+ hd->h3 = 0x10325476;
+ hd->h4 = 0xC3D2E1F0;
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+
+
+/****************
+ * Transform the message X which consists of 16 32-bit-words
+ */
+static void
+transform ( RMD160_CONTEXT *hd, const unsigned char *data )
+{
+ register u32 a,b,c,d,e;
+ u32 aa,bb,cc,dd,ee,t;
+#ifdef WORDS_BIGENDIAN
+ u32 x[16];
+ {
+ int i;
+ byte *p2;
+ const byte *p1;
+ for (i=0, p1=data, p2=(byte*)x; i < 16; i++, p2 += 4 )
+ {
+ p2[3] = *p1++;
+ p2[2] = *p1++;
+ p2[1] = *p1++;
+ p2[0] = *p1++;
+ }
+ }
+#else
+ /* This version is better because it is always aligned;
+ * The performance penalty on a 586-100 is about 6% which
+ * is acceptable - because the data is more local it might
+ * also be possible that this is faster on some machines.
+ * This function (when compiled with -02 on gcc 2.7.2)
+ * executes on a 586-100 (39.73 bogomips) at about 1900kb/sec;
+ * [measured with a 4MB data and "gpgm --print-md rmd160"] */
+ u32 x[16];
+ memcpy( x, data, 64 );
+#endif
+
+
+#define K0 0x00000000
+#define K1 0x5A827999
+#define K2 0x6ED9EBA1
+#define K3 0x8F1BBCDC
+#define K4 0xA953FD4E
+#define KK0 0x50A28BE6
+#define KK1 0x5C4DD124
+#define KK2 0x6D703EF3
+#define KK3 0x7A6D76E9
+#define KK4 0x00000000
+#define F0(x,y,z) ( (x) ^ (y) ^ (z) )
+#define F1(x,y,z) ( ((x) & (y)) | (~(x) & (z)) )
+#define F2(x,y,z) ( ((x) | ~(y)) ^ (z) )
+#define F3(x,y,z) ( ((x) & (z)) | ((y) & ~(z)) )
+#define F4(x,y,z) ( (x) ^ ((y) | ~(z)) )
+#define R(a,b,c,d,e,f,k,r,s) do { t = a + f(b,c,d) + k + x[r]; \
+ a = rol(t,s) + e; \
+ c = rol(c,10); \
+ } while(0)
+
+ /* left lane */
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+ R( a, b, c, d, e, F0, K0, 0, 11 );
+ R( e, a, b, c, d, F0, K0, 1, 14 );
+ R( d, e, a, b, c, F0, K0, 2, 15 );
+ R( c, d, e, a, b, F0, K0, 3, 12 );
+ R( b, c, d, e, a, F0, K0, 4, 5 );
+ R( a, b, c, d, e, F0, K0, 5, 8 );
+ R( e, a, b, c, d, F0, K0, 6, 7 );
+ R( d, e, a, b, c, F0, K0, 7, 9 );
+ R( c, d, e, a, b, F0, K0, 8, 11 );
+ R( b, c, d, e, a, F0, K0, 9, 13 );
+ R( a, b, c, d, e, F0, K0, 10, 14 );
+ R( e, a, b, c, d, F0, K0, 11, 15 );
+ R( d, e, a, b, c, F0, K0, 12, 6 );
+ R( c, d, e, a, b, F0, K0, 13, 7 );
+ R( b, c, d, e, a, F0, K0, 14, 9 );
+ R( a, b, c, d, e, F0, K0, 15, 8 );
+ R( e, a, b, c, d, F1, K1, 7, 7 );
+ R( d, e, a, b, c, F1, K1, 4, 6 );
+ R( c, d, e, a, b, F1, K1, 13, 8 );
+ R( b, c, d, e, a, F1, K1, 1, 13 );
+ R( a, b, c, d, e, F1, K1, 10, 11 );
+ R( e, a, b, c, d, F1, K1, 6, 9 );
+ R( d, e, a, b, c, F1, K1, 15, 7 );
+ R( c, d, e, a, b, F1, K1, 3, 15 );
+ R( b, c, d, e, a, F1, K1, 12, 7 );
+ R( a, b, c, d, e, F1, K1, 0, 12 );
+ R( e, a, b, c, d, F1, K1, 9, 15 );
+ R( d, e, a, b, c, F1, K1, 5, 9 );
+ R( c, d, e, a, b, F1, K1, 2, 11 );
+ R( b, c, d, e, a, F1, K1, 14, 7 );
+ R( a, b, c, d, e, F1, K1, 11, 13 );
+ R( e, a, b, c, d, F1, K1, 8, 12 );
+ R( d, e, a, b, c, F2, K2, 3, 11 );
+ R( c, d, e, a, b, F2, K2, 10, 13 );
+ R( b, c, d, e, a, F2, K2, 14, 6 );
+ R( a, b, c, d, e, F2, K2, 4, 7 );
+ R( e, a, b, c, d, F2, K2, 9, 14 );
+ R( d, e, a, b, c, F2, K2, 15, 9 );
+ R( c, d, e, a, b, F2, K2, 8, 13 );
+ R( b, c, d, e, a, F2, K2, 1, 15 );
+ R( a, b, c, d, e, F2, K2, 2, 14 );
+ R( e, a, b, c, d, F2, K2, 7, 8 );
+ R( d, e, a, b, c, F2, K2, 0, 13 );
+ R( c, d, e, a, b, F2, K2, 6, 6 );
+ R( b, c, d, e, a, F2, K2, 13, 5 );
+ R( a, b, c, d, e, F2, K2, 11, 12 );
+ R( e, a, b, c, d, F2, K2, 5, 7 );
+ R( d, e, a, b, c, F2, K2, 12, 5 );
+ R( c, d, e, a, b, F3, K3, 1, 11 );
+ R( b, c, d, e, a, F3, K3, 9, 12 );
+ R( a, b, c, d, e, F3, K3, 11, 14 );
+ R( e, a, b, c, d, F3, K3, 10, 15 );
+ R( d, e, a, b, c, F3, K3, 0, 14 );
+ R( c, d, e, a, b, F3, K3, 8, 15 );
+ R( b, c, d, e, a, F3, K3, 12, 9 );
+ R( a, b, c, d, e, F3, K3, 4, 8 );
+ R( e, a, b, c, d, F3, K3, 13, 9 );
+ R( d, e, a, b, c, F3, K3, 3, 14 );
+ R( c, d, e, a, b, F3, K3, 7, 5 );
+ R( b, c, d, e, a, F3, K3, 15, 6 );
+ R( a, b, c, d, e, F3, K3, 14, 8 );
+ R( e, a, b, c, d, F3, K3, 5, 6 );
+ R( d, e, a, b, c, F3, K3, 6, 5 );
+ R( c, d, e, a, b, F3, K3, 2, 12 );
+ R( b, c, d, e, a, F4, K4, 4, 9 );
+ R( a, b, c, d, e, F4, K4, 0, 15 );
+ R( e, a, b, c, d, F4, K4, 5, 5 );
+ R( d, e, a, b, c, F4, K4, 9, 11 );
+ R( c, d, e, a, b, F4, K4, 7, 6 );
+ R( b, c, d, e, a, F4, K4, 12, 8 );
+ R( a, b, c, d, e, F4, K4, 2, 13 );
+ R( e, a, b, c, d, F4, K4, 10, 12 );
+ R( d, e, a, b, c, F4, K4, 14, 5 );
+ R( c, d, e, a, b, F4, K4, 1, 12 );
+ R( b, c, d, e, a, F4, K4, 3, 13 );
+ R( a, b, c, d, e, F4, K4, 8, 14 );
+ R( e, a, b, c, d, F4, K4, 11, 11 );
+ R( d, e, a, b, c, F4, K4, 6, 8 );
+ R( c, d, e, a, b, F4, K4, 15, 5 );
+ R( b, c, d, e, a, F4, K4, 13, 6 );
+
+ aa = a; bb = b; cc = c; dd = d; ee = e;
+
+ /* right lane */
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+ R( a, b, c, d, e, F4, KK0, 5, 8);
+ R( e, a, b, c, d, F4, KK0, 14, 9);
+ R( d, e, a, b, c, F4, KK0, 7, 9);
+ R( c, d, e, a, b, F4, KK0, 0, 11);
+ R( b, c, d, e, a, F4, KK0, 9, 13);
+ R( a, b, c, d, e, F4, KK0, 2, 15);
+ R( e, a, b, c, d, F4, KK0, 11, 15);
+ R( d, e, a, b, c, F4, KK0, 4, 5);
+ R( c, d, e, a, b, F4, KK0, 13, 7);
+ R( b, c, d, e, a, F4, KK0, 6, 7);
+ R( a, b, c, d, e, F4, KK0, 15, 8);
+ R( e, a, b, c, d, F4, KK0, 8, 11);
+ R( d, e, a, b, c, F4, KK0, 1, 14);
+ R( c, d, e, a, b, F4, KK0, 10, 14);
+ R( b, c, d, e, a, F4, KK0, 3, 12);
+ R( a, b, c, d, e, F4, KK0, 12, 6);
+ R( e, a, b, c, d, F3, KK1, 6, 9);
+ R( d, e, a, b, c, F3, KK1, 11, 13);
+ R( c, d, e, a, b, F3, KK1, 3, 15);
+ R( b, c, d, e, a, F3, KK1, 7, 7);
+ R( a, b, c, d, e, F3, KK1, 0, 12);
+ R( e, a, b, c, d, F3, KK1, 13, 8);
+ R( d, e, a, b, c, F3, KK1, 5, 9);
+ R( c, d, e, a, b, F3, KK1, 10, 11);
+ R( b, c, d, e, a, F3, KK1, 14, 7);
+ R( a, b, c, d, e, F3, KK1, 15, 7);
+ R( e, a, b, c, d, F3, KK1, 8, 12);
+ R( d, e, a, b, c, F3, KK1, 12, 7);
+ R( c, d, e, a, b, F3, KK1, 4, 6);
+ R( b, c, d, e, a, F3, KK1, 9, 15);
+ R( a, b, c, d, e, F3, KK1, 1, 13);
+ R( e, a, b, c, d, F3, KK1, 2, 11);
+ R( d, e, a, b, c, F2, KK2, 15, 9);
+ R( c, d, e, a, b, F2, KK2, 5, 7);
+ R( b, c, d, e, a, F2, KK2, 1, 15);
+ R( a, b, c, d, e, F2, KK2, 3, 11);
+ R( e, a, b, c, d, F2, KK2, 7, 8);
+ R( d, e, a, b, c, F2, KK2, 14, 6);
+ R( c, d, e, a, b, F2, KK2, 6, 6);
+ R( b, c, d, e, a, F2, KK2, 9, 14);
+ R( a, b, c, d, e, F2, KK2, 11, 12);
+ R( e, a, b, c, d, F2, KK2, 8, 13);
+ R( d, e, a, b, c, F2, KK2, 12, 5);
+ R( c, d, e, a, b, F2, KK2, 2, 14);
+ R( b, c, d, e, a, F2, KK2, 10, 13);
+ R( a, b, c, d, e, F2, KK2, 0, 13);
+ R( e, a, b, c, d, F2, KK2, 4, 7);
+ R( d, e, a, b, c, F2, KK2, 13, 5);
+ R( c, d, e, a, b, F1, KK3, 8, 15);
+ R( b, c, d, e, a, F1, KK3, 6, 5);
+ R( a, b, c, d, e, F1, KK3, 4, 8);
+ R( e, a, b, c, d, F1, KK3, 1, 11);
+ R( d, e, a, b, c, F1, KK3, 3, 14);
+ R( c, d, e, a, b, F1, KK3, 11, 14);
+ R( b, c, d, e, a, F1, KK3, 15, 6);
+ R( a, b, c, d, e, F1, KK3, 0, 14);
+ R( e, a, b, c, d, F1, KK3, 5, 6);
+ R( d, e, a, b, c, F1, KK3, 12, 9);
+ R( c, d, e, a, b, F1, KK3, 2, 12);
+ R( b, c, d, e, a, F1, KK3, 13, 9);
+ R( a, b, c, d, e, F1, KK3, 9, 12);
+ R( e, a, b, c, d, F1, KK3, 7, 5);
+ R( d, e, a, b, c, F1, KK3, 10, 15);
+ R( c, d, e, a, b, F1, KK3, 14, 8);
+ R( b, c, d, e, a, F0, KK4, 12, 8);
+ R( a, b, c, d, e, F0, KK4, 15, 5);
+ R( e, a, b, c, d, F0, KK4, 10, 12);
+ R( d, e, a, b, c, F0, KK4, 4, 9);
+ R( c, d, e, a, b, F0, KK4, 1, 12);
+ R( b, c, d, e, a, F0, KK4, 5, 5);
+ R( a, b, c, d, e, F0, KK4, 8, 14);
+ R( e, a, b, c, d, F0, KK4, 7, 6);
+ R( d, e, a, b, c, F0, KK4, 6, 8);
+ R( c, d, e, a, b, F0, KK4, 2, 13);
+ R( b, c, d, e, a, F0, KK4, 13, 6);
+ R( a, b, c, d, e, F0, KK4, 14, 5);
+ R( e, a, b, c, d, F0, KK4, 0, 15);
+ R( d, e, a, b, c, F0, KK4, 3, 13);
+ R( c, d, e, a, b, F0, KK4, 9, 11);
+ R( b, c, d, e, a, F0, KK4, 11, 11);
+
+
+ t = hd->h1 + d + cc;
+ hd->h1 = hd->h2 + e + dd;
+ hd->h2 = hd->h3 + a + ee;
+ hd->h3 = hd->h4 + b + aa;
+ hd->h4 = hd->h0 + c + bb;
+ hd->h0 = t;
+}
+
+
+/* Update the message digest with the contents
+ * of INBUF with length INLEN.
+ */
+static void
+rmd160_write ( void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ RMD160_CONTEXT *hd = context;
+
+ if( hd->count == 64 ) /* flush the buffer */
+ {
+ transform( hd, hd->buf );
+ _gcry_burn_stack (108+5*sizeof(void*));
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if( !inbuf )
+ return;
+ if( hd->count )
+ {
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+ rmd160_write( hd, NULL, 0 );
+ if( !inlen )
+ return;
+ }
+
+ while( inlen >= 64 )
+ {
+ transform( hd, inbuf );
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 64;
+ inbuf += 64;
+ }
+ _gcry_burn_stack (108+5*sizeof(void*));
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+/****************
+ * Apply the rmd160 transform function on the buffer which must have
+ * a length 64 bytes. Do not use this function together with the
+ * other functions, use rmd160_init to initialize internal variables.
+ * Returns: 16 bytes in buffer with the mixed contentes of buffer.
+ */
+
+
+/* The routine terminates the computation
+ */
+
+static void
+rmd160_final( void *context )
+{
+ RMD160_CONTEXT *hd = context;
+ u32 t, msb, lsb;
+ byte *p;
+
+ rmd160_write(hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if( (lsb += hd->count) < t )
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if( hd->count < 56 ) /* enough room */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while( hd->count < 56 )
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else /* need one extra block */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while( hd->count < 64 )
+ hd->buf[hd->count++] = 0;
+ rmd160_write(hd, NULL, 0); /* flush */;
+ memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = lsb ;
+ hd->buf[57] = lsb >> 8;
+ hd->buf[58] = lsb >> 16;
+ hd->buf[59] = lsb >> 24;
+ hd->buf[60] = msb ;
+ hd->buf[61] = msb >> 8;
+ hd->buf[62] = msb >> 16;
+ hd->buf[63] = msb >> 24;
+ transform( hd, hd->buf );
+ _gcry_burn_stack (108+5*sizeof(void*));
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *p++ = hd->h##a ; *p++ = hd->h##a >> 8; \
+ *p++ = hd->h##a >> 16; *p++ = hd->h##a >> 24; } while(0)
+#else /* little endian */
+#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
+#endif
+ X(0);
+ X(1);
+ X(2);
+ X(3);
+ X(4);
+#undef X
+}
+
+static byte *
+rmd160_read( void *context )
+{
+ RMD160_CONTEXT *hd = context;
+
+ return hd->buf;
+}
+
+
+
+/****************
+ * Shortcut functions which puts the hash value of the supplied buffer
+ * into outbuf which must have a size of 20 bytes.
+ */
+
+static byte asn[15] = /* Object ID is 1.3.36.3.2.1 */
+ { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x24, 0x03,
+ 0x02, 0x01, 0x05, 0x00, 0x04, 0x14 };
+
+static gcry_md_oid_spec_t oid_spec_rmd160[] =
+ {
+ /* rsaSignatureWithripemd160 */
+ { "1.3.36.3.3.1.2" },
+ /* TeleTrust hash algorithm. */
+ { "1.3.36.3.2.1" },
+ { NULL }
+ };
+
+gcry_md_spec_t _gcry_digest_spec_rmd160 =
+ {
+ "RIPEMD160", asn, DIM (asn), oid_spec_rmd160, 20,
+ _gcry_rmd160_init, rmd160_write, rmd160_final, rmd160_read,
+ sizeof (RMD160_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_rmd160",
+#endif
+ .blocksize = 64
+ };
+
+
+GRUB_MOD_INIT(gcry_rmd160)
+{
+ COMPILE_TIME_ASSERT(sizeof (RMD160_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ grub_md_register (&_gcry_digest_spec_rmd160);
+}
+
+GRUB_MOD_FINI(gcry_rmd160)
+{
+ grub_md_unregister (&_gcry_digest_spec_rmd160);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/rsa.c b/grub-core/lib/libgcrypt-grub/cipher/rsa.c
new file mode 100644
index 0000000..6e0187b
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/rsa.c
@@ -0,0 +1,395 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* rsa.c - RSA implementation
+ * Copyright (C) 1997, 1998, 1999 by Werner Koch (dd9jn)
+ * Copyright (C) 2000, 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This code uses an algorithm protected by U.S. Patent #4,405,829
+ which expired on September 20, 2000. The patent holder placed that
+ patent into the public domain on Sep 6th, 2000.
+*/
+
+
+#include "g10lib.h"
+#include "mpi.h"
+#include "cipher.h"
+
+
+typedef struct
+{
+ gcry_mpi_t n; /* modulus */
+ gcry_mpi_t e; /* exponent */
+} RSA_public_key;
+
+
+typedef struct
+{
+ gcry_mpi_t n; /* public modulus */
+ gcry_mpi_t e; /* public exponent */
+ gcry_mpi_t d; /* exponent */
+ gcry_mpi_t p; /* prime p. */
+ gcry_mpi_t q; /* prime q. */
+ gcry_mpi_t u; /* inverse of p mod q. */
+} RSA_secret_key;
+
+
+/* A sample 1024 bit RSA key used for the selftests. */
+/* A sample 1024 bit RSA key used for the selftests (public only). */
+
+
+
+
+static int check_secret_key (RSA_secret_key *sk);
+static void public (gcry_mpi_t output, gcry_mpi_t input, RSA_public_key *skey);
+
+
+/* Check that a freshly generated key actually works. Returns 0 on success. */
+
+
+/* Callback used by the prime generation to test whether the exponent
+ is suitable. Returns 0 if the test has been passed. */
+
+/****************
+ * Generate a key pair with a key of size NBITS.
+ * USE_E = 0 let Libcgrypt decide what exponent to use.
+ * = 1 request the use of a "secure" exponent; this is required by some
+ * specification to be 65537.
+ * > 2 Use this public exponent. If the given exponent
+ * is not odd one is internally added to it.
+ * TRANSIENT_KEY: If true, generate the primes using the standard RNG.
+ * Returns: 2 structures filled with all needed values
+ */
+
+
+/* Helper for generate_x931. */
+
+
+/* Helper for generate_x931. */
+
+
+
+/* Variant of the standard key generation code using the algorithm
+ from X9.31. Using this algorithm has the advantage that the
+ generation can be made deterministic which is required for CAVS
+ testing. */
+
+
+/****************
+ * Test whether the secret key is valid.
+ * Returns: true if this is a valid key.
+ */
+static int
+check_secret_key( RSA_secret_key *sk )
+{
+ int rc;
+ gcry_mpi_t temp = mpi_alloc( mpi_get_nlimbs(sk->p)*2 );
+
+ mpi_mul(temp, sk->p, sk->q );
+ rc = mpi_cmp( temp, sk->n );
+ mpi_free(temp);
+ return !rc;
+}
+
+
+
+/****************
+ * Public key operation. Encrypt INPUT with PKEY and put result into OUTPUT.
+ *
+ * c = m^e mod n
+ *
+ * Where c is OUTPUT, m is INPUT and e,n are elements of PKEY.
+ */
+static void
+public(gcry_mpi_t output, gcry_mpi_t input, RSA_public_key *pkey )
+{
+ if( output == input ) /* powm doesn't like output and input the same */
+ {
+ gcry_mpi_t x = mpi_alloc( mpi_get_nlimbs(input)*2 );
+ mpi_powm( x, input, pkey->e, pkey->n );
+ mpi_set(output, x);
+ mpi_free(x);
+ }
+ else
+ mpi_powm( output, input, pkey->e, pkey->n );
+}
+
+#if 0
+static void
+stronger_key_check ( RSA_secret_key *skey )
+{
+ gcry_mpi_t t = mpi_alloc_secure ( 0 );
+ gcry_mpi_t t1 = mpi_alloc_secure ( 0 );
+ gcry_mpi_t t2 = mpi_alloc_secure ( 0 );
+ gcry_mpi_t phi = mpi_alloc_secure ( 0 );
+
+ /* check that n == p * q */
+ mpi_mul( t, skey->p, skey->q);
+ if (mpi_cmp( t, skey->n) )
+ log_info ( "RSA Oops: n != p * q\n" );
+
+ /* check that p is less than q */
+ if( mpi_cmp( skey->p, skey->q ) > 0 )
+ {
+ log_info ("RSA Oops: p >= q - fixed\n");
+ _gcry_mpi_swap ( skey->p, skey->q);
+ }
+
+ /* check that e divides neither p-1 nor q-1 */
+ mpi_sub_ui(t, skey->p, 1 );
+ mpi_fdiv_r(t, t, skey->e );
+ if ( !mpi_cmp_ui( t, 0) )
+ log_info ( "RSA Oops: e divides p-1\n" );
+ mpi_sub_ui(t, skey->q, 1 );
+ mpi_fdiv_r(t, t, skey->e );
+ if ( !mpi_cmp_ui( t, 0) )
+ log_info ( "RSA Oops: e divides q-1\n" );
+
+ /* check that d is correct */
+ mpi_sub_ui( t1, skey->p, 1 );
+ mpi_sub_ui( t2, skey->q, 1 );
+ mpi_mul( phi, t1, t2 );
+ gcry_mpi_gcd(t, t1, t2);
+ mpi_fdiv_q(t, phi, t);
+ mpi_invm(t, skey->e, t );
+ if ( mpi_cmp(t, skey->d ) )
+ {
+ log_info ( "RSA Oops: d is wrong - fixed\n");
+ mpi_set (skey->d, t);
+ _gcry_log_mpidump (" fixed d", skey->d);
+ }
+
+ /* check for correctness of u */
+ mpi_invm(t, skey->p, skey->q );
+ if ( mpi_cmp(t, skey->u ) )
+ {
+ log_info ( "RSA Oops: u is wrong - fixed\n");
+ mpi_set (skey->u, t);
+ _gcry_log_mpidump (" fixed u", skey->u);
+ }
+
+ log_info ( "RSA secret key check finished\n");
+
+ mpi_free (t);
+ mpi_free (t1);
+ mpi_free (t2);
+ mpi_free (phi);
+}
+#endif
+
+
+
+/****************
+ * Secret key operation. Encrypt INPUT with SKEY and put result into OUTPUT.
+ *
+ * m = c^d mod n
+ *
+ * Or faster:
+ *
+ * m1 = c ^ (d mod (p-1)) mod p
+ * m2 = c ^ (d mod (q-1)) mod q
+ * h = u * (m2 - m1) mod q
+ * m = m1 + h * p
+ *
+ * Where m is OUTPUT, c is INPUT and d,n,p,q,u are elements of SKEY.
+ */
+
+
+
+/* Perform RSA blinding. */
+
+/* Undo RSA blinding. */
+
+/*********************************************
+ ************** interface ******************
+ *********************************************/
+
+
+
+#define rsa_generate 0
+
+static gcry_err_code_t
+rsa_check_secret_key (int algo, gcry_mpi_t *skey)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ RSA_secret_key sk;
+
+ (void)algo;
+
+ sk.n = skey[0];
+ sk.e = skey[1];
+ sk.d = skey[2];
+ sk.p = skey[3];
+ sk.q = skey[4];
+ sk.u = skey[5];
+
+ if (!sk.p || !sk.q || !sk.u)
+ err = GPG_ERR_NO_OBJ; /* To check the key we need the optional
+ parameters. */
+ else if (!check_secret_key (&sk))
+ err = GPG_ERR_BAD_SECKEY;
+
+ return err;
+}
+
+
+static gcry_err_code_t
+rsa_encrypt (int algo, gcry_mpi_t *resarr, gcry_mpi_t data,
+ gcry_mpi_t *pkey, int flags)
+{
+ RSA_public_key pk;
+
+ (void)algo;
+ (void)flags;
+
+ pk.n = pkey[0];
+ pk.e = pkey[1];
+ resarr[0] = mpi_alloc (mpi_get_nlimbs (pk.n));
+ public (resarr[0], data, &pk);
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+#define rsa_decrypt 0
+
+#define rsa_sign 0
+
+static gcry_err_code_t
+rsa_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey,
+ int (*cmp) (void *opaque, gcry_mpi_t tmp),
+ void *opaquev)
+{
+ RSA_public_key pk;
+ gcry_mpi_t result;
+ gcry_err_code_t rc;
+
+ (void)algo;
+ (void)cmp;
+ (void)opaquev;
+
+ pk.n = pkey[0];
+ pk.e = pkey[1];
+ result = gcry_mpi_new ( 160 );
+ public( result, data[0], &pk );
+#ifdef IS_DEVELOPMENT_VERSION
+ if (DBG_CIPHER)
+ {
+ log_mpidump ("rsa verify result:", result );
+ log_mpidump (" hash:", hash );
+ }
+#endif /*IS_DEVELOPMENT_VERSION*/
+ if (cmp)
+ rc = (*cmp) (opaquev, result);
+ else
+ rc = mpi_cmp (result, hash) ? GPG_ERR_BAD_SIGNATURE : GPG_ERR_NO_ERROR;
+ gcry_mpi_release (result);
+
+ return rc;
+}
+
+
+static unsigned int
+rsa_get_nbits (int algo, gcry_mpi_t *pkey)
+{
+ (void)algo;
+
+ return mpi_get_nbits (pkey[0]);
+}
+
+
+/* Compute a keygrip. MD is the hash context which we are going to
+ update. KEYPARAM is an S-expression with the key parameters, this
+ is usually a public key but may also be a secret key. An example
+ of such an S-expression is:
+
+ (rsa
+ (n #00B...#)
+ (e #010001#))
+
+ PKCS-15 says that for RSA only the modulus should be hashed -
+ however, it is not clear whether this is meant to use the raw bytes
+ (assuming this is an unsigned integer) or whether the DER required
+ 0 should be prefixed. We hash the raw bytes. */
+
+
+
+
+/*
+ Self-test section.
+ */
+
+
+
+
+/* Given an S-expression ENCR_DATA of the form:
+
+ (enc-val
+ (rsa
+ (a a-value)))
+
+ as returned by gcry_pk_decrypt, return the the A-VALUE. On error,
+ return NULL. */
+
+
+
+
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+
+
+
+
+static const char *rsa_names[] =
+ {
+ "rsa",
+ "openpgp-rsa",
+ "oid.1.2.840.113549.1.1.1",
+ NULL,
+ };
+
+gcry_pk_spec_t _gcry_pubkey_spec_rsa =
+ {
+ "RSA", rsa_names,
+ "ne", "nedpqu", "a", "s", "n",
+ GCRY_PK_USAGE_SIGN | GCRY_PK_USAGE_ENCR,
+ rsa_generate,
+ rsa_check_secret_key,
+ rsa_encrypt,
+ rsa_decrypt,
+ rsa_sign,
+ rsa_verify,
+ rsa_get_nbits,
+#ifdef GRUB_UTIL
+ .modname = "gcry_rsa",
+#endif
+ };
+
+
+GRUB_MOD_INIT(gcry_rsa)
+{
+ grub_crypto_pk_rsa = &_gcry_pubkey_spec_rsa;
+}
+
+GRUB_MOD_FINI(gcry_rsa)
+{
+ grub_crypto_pk_rsa = 0;
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/seed.c b/grub-core/lib/libgcrypt-grub/cipher/seed.c
new file mode 100644
index 0000000..087e27b
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/seed.c
@@ -0,0 +1,461 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* SEED for libgcrypt
+ * Copyright (C) 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --
+ * This implementation was provided for libgcrypt in public domain
+ * by Hye-Shik Chang <perky@FreeBSD.org>, July 2006.
+ */
+
+
+#include "types.h" /* for byte and u32 typedefs */
+#include "g10lib.h"
+#include "cipher.h"
+
+#define NUMKC 16
+
+#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
+ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
+#define PUTU32(ct, st) { (ct)[0] = (byte)((st) >> 24); \
+ (ct)[1] = (byte)((st) >> 16); \
+ (ct)[2] = (byte)((st) >> 8); \
+ (ct)[3] = (byte)(st); }
+
+union wordbuf
+{
+ u32 w;
+ byte b[4];
+};
+
+#ifdef WORDS_BIGENDIAN
+#define b0 b[3]
+#define b1 b[2]
+#define b2 b[1]
+#define b3 b[0]
+#else
+#define b0 b[0]
+#define b1 b[1]
+#define b2 b[2]
+#define b3 b[3]
+#endif
+
+
+typedef struct
+{
+ u32 keyschedule[32];
+} SEED_context;
+
+static const u32 SS0[256] = {
+ 0x2989a1a8, 0x05858184, 0x16c6d2d4, 0x13c3d3d0, 0x14445054, 0x1d0d111c,
+ 0x2c8ca0ac, 0x25052124, 0x1d4d515c, 0x03434340, 0x18081018, 0x1e0e121c,
+ 0x11415150, 0x3cccf0fc, 0x0acac2c8, 0x23436360, 0x28082028, 0x04444044,
+ 0x20002020, 0x1d8d919c, 0x20c0e0e0, 0x22c2e2e0, 0x08c8c0c8, 0x17071314,
+ 0x2585a1a4, 0x0f8f838c, 0x03030300, 0x3b4b7378, 0x3b8bb3b8, 0x13031310,
+ 0x12c2d2d0, 0x2ecee2ec, 0x30407070, 0x0c8c808c, 0x3f0f333c, 0x2888a0a8,
+ 0x32023230, 0x1dcdd1dc, 0x36c6f2f4, 0x34447074, 0x2ccce0ec, 0x15859194,
+ 0x0b0b0308, 0x17475354, 0x1c4c505c, 0x1b4b5358, 0x3d8db1bc, 0x01010100,
+ 0x24042024, 0x1c0c101c, 0x33437370, 0x18889098, 0x10001010, 0x0cccc0cc,
+ 0x32c2f2f0, 0x19c9d1d8, 0x2c0c202c, 0x27c7e3e4, 0x32427270, 0x03838380,
+ 0x1b8b9398, 0x11c1d1d0, 0x06868284, 0x09c9c1c8, 0x20406060, 0x10405050,
+ 0x2383a3a0, 0x2bcbe3e8, 0x0d0d010c, 0x3686b2b4, 0x1e8e929c, 0x0f4f434c,
+ 0x3787b3b4, 0x1a4a5258, 0x06c6c2c4, 0x38487078, 0x2686a2a4, 0x12021210,
+ 0x2f8fa3ac, 0x15c5d1d4, 0x21416160, 0x03c3c3c0, 0x3484b0b4, 0x01414140,
+ 0x12425250, 0x3d4d717c, 0x0d8d818c, 0x08080008, 0x1f0f131c, 0x19899198,
+ 0x00000000, 0x19091118, 0x04040004, 0x13435350, 0x37c7f3f4, 0x21c1e1e0,
+ 0x3dcdf1fc, 0x36467274, 0x2f0f232c, 0x27072324, 0x3080b0b0, 0x0b8b8388,
+ 0x0e0e020c, 0x2b8ba3a8, 0x2282a2a0, 0x2e4e626c, 0x13839390, 0x0d4d414c,
+ 0x29496168, 0x3c4c707c, 0x09090108, 0x0a0a0208, 0x3f8fb3bc, 0x2fcfe3ec,
+ 0x33c3f3f0, 0x05c5c1c4, 0x07878384, 0x14041014, 0x3ecef2fc, 0x24446064,
+ 0x1eced2dc, 0x2e0e222c, 0x0b4b4348, 0x1a0a1218, 0x06060204, 0x21012120,
+ 0x2b4b6368, 0x26466264, 0x02020200, 0x35c5f1f4, 0x12829290, 0x0a8a8288,
+ 0x0c0c000c, 0x3383b3b0, 0x3e4e727c, 0x10c0d0d0, 0x3a4a7278, 0x07474344,
+ 0x16869294, 0x25c5e1e4, 0x26062224, 0x00808080, 0x2d8da1ac, 0x1fcfd3dc,
+ 0x2181a1a0, 0x30003030, 0x37073334, 0x2e8ea2ac, 0x36063234, 0x15051114,
+ 0x22022220, 0x38083038, 0x34c4f0f4, 0x2787a3a4, 0x05454144, 0x0c4c404c,
+ 0x01818180, 0x29c9e1e8, 0x04848084, 0x17879394, 0x35053134, 0x0bcbc3c8,
+ 0x0ecec2cc, 0x3c0c303c, 0x31417170, 0x11011110, 0x07c7c3c4, 0x09898188,
+ 0x35457174, 0x3bcbf3f8, 0x1acad2d8, 0x38c8f0f8, 0x14849094, 0x19495158,
+ 0x02828280, 0x04c4c0c4, 0x3fcff3fc, 0x09494148, 0x39093138, 0x27476364,
+ 0x00c0c0c0, 0x0fcfc3cc, 0x17c7d3d4, 0x3888b0b8, 0x0f0f030c, 0x0e8e828c,
+ 0x02424240, 0x23032320, 0x11819190, 0x2c4c606c, 0x1bcbd3d8, 0x2484a0a4,
+ 0x34043034, 0x31c1f1f0, 0x08484048, 0x02c2c2c0, 0x2f4f636c, 0x3d0d313c,
+ 0x2d0d212c, 0x00404040, 0x3e8eb2bc, 0x3e0e323c, 0x3c8cb0bc, 0x01c1c1c0,
+ 0x2a8aa2a8, 0x3a8ab2b8, 0x0e4e424c, 0x15455154, 0x3b0b3338, 0x1cccd0dc,
+ 0x28486068, 0x3f4f737c, 0x1c8c909c, 0x18c8d0d8, 0x0a4a4248, 0x16465254,
+ 0x37477374, 0x2080a0a0, 0x2dcde1ec, 0x06464244, 0x3585b1b4, 0x2b0b2328,
+ 0x25456164, 0x3acaf2f8, 0x23c3e3e0, 0x3989b1b8, 0x3181b1b0, 0x1f8f939c,
+ 0x1e4e525c, 0x39c9f1f8, 0x26c6e2e4, 0x3282b2b0, 0x31013130, 0x2acae2e8,
+ 0x2d4d616c, 0x1f4f535c, 0x24c4e0e4, 0x30c0f0f0, 0x0dcdc1cc, 0x08888088,
+ 0x16061214, 0x3a0a3238, 0x18485058, 0x14c4d0d4, 0x22426260, 0x29092128,
+ 0x07070304, 0x33033330, 0x28c8e0e8, 0x1b0b1318, 0x05050104, 0x39497178,
+ 0x10809090, 0x2a4a6268, 0x2a0a2228, 0x1a8a9298,
+};
+
+static const u32 SS1[256] = {
+ 0x38380830, 0xe828c8e0, 0x2c2d0d21, 0xa42686a2, 0xcc0fcfc3, 0xdc1eced2,
+ 0xb03383b3, 0xb83888b0, 0xac2f8fa3, 0x60204060, 0x54154551, 0xc407c7c3,
+ 0x44044440, 0x6c2f4f63, 0x682b4b63, 0x581b4b53, 0xc003c3c3, 0x60224262,
+ 0x30330333, 0xb43585b1, 0x28290921, 0xa02080a0, 0xe022c2e2, 0xa42787a3,
+ 0xd013c3d3, 0x90118191, 0x10110111, 0x04060602, 0x1c1c0c10, 0xbc3c8cb0,
+ 0x34360632, 0x480b4b43, 0xec2fcfe3, 0x88088880, 0x6c2c4c60, 0xa82888a0,
+ 0x14170713, 0xc404c4c0, 0x14160612, 0xf434c4f0, 0xc002c2c2, 0x44054541,
+ 0xe021c1e1, 0xd416c6d2, 0x3c3f0f33, 0x3c3d0d31, 0x8c0e8e82, 0x98188890,
+ 0x28280820, 0x4c0e4e42, 0xf436c6f2, 0x3c3e0e32, 0xa42585a1, 0xf839c9f1,
+ 0x0c0d0d01, 0xdc1fcfd3, 0xd818c8d0, 0x282b0b23, 0x64264662, 0x783a4a72,
+ 0x24270723, 0x2c2f0f23, 0xf031c1f1, 0x70324272, 0x40024242, 0xd414c4d0,
+ 0x40014141, 0xc000c0c0, 0x70334373, 0x64274763, 0xac2c8ca0, 0x880b8b83,
+ 0xf437c7f3, 0xac2d8da1, 0x80008080, 0x1c1f0f13, 0xc80acac2, 0x2c2c0c20,
+ 0xa82a8aa2, 0x34340430, 0xd012c2d2, 0x080b0b03, 0xec2ecee2, 0xe829c9e1,
+ 0x5c1d4d51, 0x94148490, 0x18180810, 0xf838c8f0, 0x54174753, 0xac2e8ea2,
+ 0x08080800, 0xc405c5c1, 0x10130313, 0xcc0dcdc1, 0x84068682, 0xb83989b1,
+ 0xfc3fcff3, 0x7c3d4d71, 0xc001c1c1, 0x30310131, 0xf435c5f1, 0x880a8a82,
+ 0x682a4a62, 0xb03181b1, 0xd011c1d1, 0x20200020, 0xd417c7d3, 0x00020202,
+ 0x20220222, 0x04040400, 0x68284860, 0x70314171, 0x04070703, 0xd81bcbd3,
+ 0x9c1d8d91, 0x98198991, 0x60214161, 0xbc3e8eb2, 0xe426c6e2, 0x58194951,
+ 0xdc1dcdd1, 0x50114151, 0x90108090, 0xdc1cccd0, 0x981a8a92, 0xa02383a3,
+ 0xa82b8ba3, 0xd010c0d0, 0x80018181, 0x0c0f0f03, 0x44074743, 0x181a0a12,
+ 0xe023c3e3, 0xec2ccce0, 0x8c0d8d81, 0xbc3f8fb3, 0x94168692, 0x783b4b73,
+ 0x5c1c4c50, 0xa02282a2, 0xa02181a1, 0x60234363, 0x20230323, 0x4c0d4d41,
+ 0xc808c8c0, 0x9c1e8e92, 0x9c1c8c90, 0x383a0a32, 0x0c0c0c00, 0x2c2e0e22,
+ 0xb83a8ab2, 0x6c2e4e62, 0x9c1f8f93, 0x581a4a52, 0xf032c2f2, 0x90128292,
+ 0xf033c3f3, 0x48094941, 0x78384870, 0xcc0cccc0, 0x14150511, 0xf83bcbf3,
+ 0x70304070, 0x74354571, 0x7c3f4f73, 0x34350531, 0x10100010, 0x00030303,
+ 0x64244460, 0x6c2d4d61, 0xc406c6c2, 0x74344470, 0xd415c5d1, 0xb43484b0,
+ 0xe82acae2, 0x08090901, 0x74364672, 0x18190911, 0xfc3ecef2, 0x40004040,
+ 0x10120212, 0xe020c0e0, 0xbc3d8db1, 0x04050501, 0xf83acaf2, 0x00010101,
+ 0xf030c0f0, 0x282a0a22, 0x5c1e4e52, 0xa82989a1, 0x54164652, 0x40034343,
+ 0x84058581, 0x14140410, 0x88098981, 0x981b8b93, 0xb03080b0, 0xe425c5e1,
+ 0x48084840, 0x78394971, 0x94178793, 0xfc3cccf0, 0x1c1e0e12, 0x80028282,
+ 0x20210121, 0x8c0c8c80, 0x181b0b13, 0x5c1f4f53, 0x74374773, 0x54144450,
+ 0xb03282b2, 0x1c1d0d11, 0x24250521, 0x4c0f4f43, 0x00000000, 0x44064642,
+ 0xec2dcde1, 0x58184850, 0x50124252, 0xe82bcbe3, 0x7c3e4e72, 0xd81acad2,
+ 0xc809c9c1, 0xfc3dcdf1, 0x30300030, 0x94158591, 0x64254561, 0x3c3c0c30,
+ 0xb43686b2, 0xe424c4e0, 0xb83b8bb3, 0x7c3c4c70, 0x0c0e0e02, 0x50104050,
+ 0x38390931, 0x24260622, 0x30320232, 0x84048480, 0x68294961, 0x90138393,
+ 0x34370733, 0xe427c7e3, 0x24240420, 0xa42484a0, 0xc80bcbc3, 0x50134353,
+ 0x080a0a02, 0x84078783, 0xd819c9d1, 0x4c0c4c40, 0x80038383, 0x8c0f8f83,
+ 0xcc0ecec2, 0x383b0b33, 0x480a4a42, 0xb43787b3,
+};
+
+static const u32 SS2[256] = {
+ 0xa1a82989, 0x81840585, 0xd2d416c6, 0xd3d013c3, 0x50541444, 0x111c1d0d,
+ 0xa0ac2c8c, 0x21242505, 0x515c1d4d, 0x43400343, 0x10181808, 0x121c1e0e,
+ 0x51501141, 0xf0fc3ccc, 0xc2c80aca, 0x63602343, 0x20282808, 0x40440444,
+ 0x20202000, 0x919c1d8d, 0xe0e020c0, 0xe2e022c2, 0xc0c808c8, 0x13141707,
+ 0xa1a42585, 0x838c0f8f, 0x03000303, 0x73783b4b, 0xb3b83b8b, 0x13101303,
+ 0xd2d012c2, 0xe2ec2ece, 0x70703040, 0x808c0c8c, 0x333c3f0f, 0xa0a82888,
+ 0x32303202, 0xd1dc1dcd, 0xf2f436c6, 0x70743444, 0xe0ec2ccc, 0x91941585,
+ 0x03080b0b, 0x53541747, 0x505c1c4c, 0x53581b4b, 0xb1bc3d8d, 0x01000101,
+ 0x20242404, 0x101c1c0c, 0x73703343, 0x90981888, 0x10101000, 0xc0cc0ccc,
+ 0xf2f032c2, 0xd1d819c9, 0x202c2c0c, 0xe3e427c7, 0x72703242, 0x83800383,
+ 0x93981b8b, 0xd1d011c1, 0x82840686, 0xc1c809c9, 0x60602040, 0x50501040,
+ 0xa3a02383, 0xe3e82bcb, 0x010c0d0d, 0xb2b43686, 0x929c1e8e, 0x434c0f4f,
+ 0xb3b43787, 0x52581a4a, 0xc2c406c6, 0x70783848, 0xa2a42686, 0x12101202,
+ 0xa3ac2f8f, 0xd1d415c5, 0x61602141, 0xc3c003c3, 0xb0b43484, 0x41400141,
+ 0x52501242, 0x717c3d4d, 0x818c0d8d, 0x00080808, 0x131c1f0f, 0x91981989,
+ 0x00000000, 0x11181909, 0x00040404, 0x53501343, 0xf3f437c7, 0xe1e021c1,
+ 0xf1fc3dcd, 0x72743646, 0x232c2f0f, 0x23242707, 0xb0b03080, 0x83880b8b,
+ 0x020c0e0e, 0xa3a82b8b, 0xa2a02282, 0x626c2e4e, 0x93901383, 0x414c0d4d,
+ 0x61682949, 0x707c3c4c, 0x01080909, 0x02080a0a, 0xb3bc3f8f, 0xe3ec2fcf,
+ 0xf3f033c3, 0xc1c405c5, 0x83840787, 0x10141404, 0xf2fc3ece, 0x60642444,
+ 0xd2dc1ece, 0x222c2e0e, 0x43480b4b, 0x12181a0a, 0x02040606, 0x21202101,
+ 0x63682b4b, 0x62642646, 0x02000202, 0xf1f435c5, 0x92901282, 0x82880a8a,
+ 0x000c0c0c, 0xb3b03383, 0x727c3e4e, 0xd0d010c0, 0x72783a4a, 0x43440747,
+ 0x92941686, 0xe1e425c5, 0x22242606, 0x80800080, 0xa1ac2d8d, 0xd3dc1fcf,
+ 0xa1a02181, 0x30303000, 0x33343707, 0xa2ac2e8e, 0x32343606, 0x11141505,
+ 0x22202202, 0x30383808, 0xf0f434c4, 0xa3a42787, 0x41440545, 0x404c0c4c,
+ 0x81800181, 0xe1e829c9, 0x80840484, 0x93941787, 0x31343505, 0xc3c80bcb,
+ 0xc2cc0ece, 0x303c3c0c, 0x71703141, 0x11101101, 0xc3c407c7, 0x81880989,
+ 0x71743545, 0xf3f83bcb, 0xd2d81aca, 0xf0f838c8, 0x90941484, 0x51581949,
+ 0x82800282, 0xc0c404c4, 0xf3fc3fcf, 0x41480949, 0x31383909, 0x63642747,
+ 0xc0c000c0, 0xc3cc0fcf, 0xd3d417c7, 0xb0b83888, 0x030c0f0f, 0x828c0e8e,
+ 0x42400242, 0x23202303, 0x91901181, 0x606c2c4c, 0xd3d81bcb, 0xa0a42484,
+ 0x30343404, 0xf1f031c1, 0x40480848, 0xc2c002c2, 0x636c2f4f, 0x313c3d0d,
+ 0x212c2d0d, 0x40400040, 0xb2bc3e8e, 0x323c3e0e, 0xb0bc3c8c, 0xc1c001c1,
+ 0xa2a82a8a, 0xb2b83a8a, 0x424c0e4e, 0x51541545, 0x33383b0b, 0xd0dc1ccc,
+ 0x60682848, 0x737c3f4f, 0x909c1c8c, 0xd0d818c8, 0x42480a4a, 0x52541646,
+ 0x73743747, 0xa0a02080, 0xe1ec2dcd, 0x42440646, 0xb1b43585, 0x23282b0b,
+ 0x61642545, 0xf2f83aca, 0xe3e023c3, 0xb1b83989, 0xb1b03181, 0x939c1f8f,
+ 0x525c1e4e, 0xf1f839c9, 0xe2e426c6, 0xb2b03282, 0x31303101, 0xe2e82aca,
+ 0x616c2d4d, 0x535c1f4f, 0xe0e424c4, 0xf0f030c0, 0xc1cc0dcd, 0x80880888,
+ 0x12141606, 0x32383a0a, 0x50581848, 0xd0d414c4, 0x62602242, 0x21282909,
+ 0x03040707, 0x33303303, 0xe0e828c8, 0x13181b0b, 0x01040505, 0x71783949,
+ 0x90901080, 0x62682a4a, 0x22282a0a, 0x92981a8a,
+};
+
+static const u32 SS3[256] = {
+ 0x08303838, 0xc8e0e828, 0x0d212c2d, 0x86a2a426, 0xcfc3cc0f, 0xced2dc1e,
+ 0x83b3b033, 0x88b0b838, 0x8fa3ac2f, 0x40606020, 0x45515415, 0xc7c3c407,
+ 0x44404404, 0x4f636c2f, 0x4b63682b, 0x4b53581b, 0xc3c3c003, 0x42626022,
+ 0x03333033, 0x85b1b435, 0x09212829, 0x80a0a020, 0xc2e2e022, 0x87a3a427,
+ 0xc3d3d013, 0x81919011, 0x01111011, 0x06020406, 0x0c101c1c, 0x8cb0bc3c,
+ 0x06323436, 0x4b43480b, 0xcfe3ec2f, 0x88808808, 0x4c606c2c, 0x88a0a828,
+ 0x07131417, 0xc4c0c404, 0x06121416, 0xc4f0f434, 0xc2c2c002, 0x45414405,
+ 0xc1e1e021, 0xc6d2d416, 0x0f333c3f, 0x0d313c3d, 0x8e828c0e, 0x88909818,
+ 0x08202828, 0x4e424c0e, 0xc6f2f436, 0x0e323c3e, 0x85a1a425, 0xc9f1f839,
+ 0x0d010c0d, 0xcfd3dc1f, 0xc8d0d818, 0x0b23282b, 0x46626426, 0x4a72783a,
+ 0x07232427, 0x0f232c2f, 0xc1f1f031, 0x42727032, 0x42424002, 0xc4d0d414,
+ 0x41414001, 0xc0c0c000, 0x43737033, 0x47636427, 0x8ca0ac2c, 0x8b83880b,
+ 0xc7f3f437, 0x8da1ac2d, 0x80808000, 0x0f131c1f, 0xcac2c80a, 0x0c202c2c,
+ 0x8aa2a82a, 0x04303434, 0xc2d2d012, 0x0b03080b, 0xcee2ec2e, 0xc9e1e829,
+ 0x4d515c1d, 0x84909414, 0x08101818, 0xc8f0f838, 0x47535417, 0x8ea2ac2e,
+ 0x08000808, 0xc5c1c405, 0x03131013, 0xcdc1cc0d, 0x86828406, 0x89b1b839,
+ 0xcff3fc3f, 0x4d717c3d, 0xc1c1c001, 0x01313031, 0xc5f1f435, 0x8a82880a,
+ 0x4a62682a, 0x81b1b031, 0xc1d1d011, 0x00202020, 0xc7d3d417, 0x02020002,
+ 0x02222022, 0x04000404, 0x48606828, 0x41717031, 0x07030407, 0xcbd3d81b,
+ 0x8d919c1d, 0x89919819, 0x41616021, 0x8eb2bc3e, 0xc6e2e426, 0x49515819,
+ 0xcdd1dc1d, 0x41515011, 0x80909010, 0xccd0dc1c, 0x8a92981a, 0x83a3a023,
+ 0x8ba3a82b, 0xc0d0d010, 0x81818001, 0x0f030c0f, 0x47434407, 0x0a12181a,
+ 0xc3e3e023, 0xcce0ec2c, 0x8d818c0d, 0x8fb3bc3f, 0x86929416, 0x4b73783b,
+ 0x4c505c1c, 0x82a2a022, 0x81a1a021, 0x43636023, 0x03232023, 0x4d414c0d,
+ 0xc8c0c808, 0x8e929c1e, 0x8c909c1c, 0x0a32383a, 0x0c000c0c, 0x0e222c2e,
+ 0x8ab2b83a, 0x4e626c2e, 0x8f939c1f, 0x4a52581a, 0xc2f2f032, 0x82929012,
+ 0xc3f3f033, 0x49414809, 0x48707838, 0xccc0cc0c, 0x05111415, 0xcbf3f83b,
+ 0x40707030, 0x45717435, 0x4f737c3f, 0x05313435, 0x00101010, 0x03030003,
+ 0x44606424, 0x4d616c2d, 0xc6c2c406, 0x44707434, 0xc5d1d415, 0x84b0b434,
+ 0xcae2e82a, 0x09010809, 0x46727436, 0x09111819, 0xcef2fc3e, 0x40404000,
+ 0x02121012, 0xc0e0e020, 0x8db1bc3d, 0x05010405, 0xcaf2f83a, 0x01010001,
+ 0xc0f0f030, 0x0a22282a, 0x4e525c1e, 0x89a1a829, 0x46525416, 0x43434003,
+ 0x85818405, 0x04101414, 0x89818809, 0x8b93981b, 0x80b0b030, 0xc5e1e425,
+ 0x48404808, 0x49717839, 0x87939417, 0xccf0fc3c, 0x0e121c1e, 0x82828002,
+ 0x01212021, 0x8c808c0c, 0x0b13181b, 0x4f535c1f, 0x47737437, 0x44505414,
+ 0x82b2b032, 0x0d111c1d, 0x05212425, 0x4f434c0f, 0x00000000, 0x46424406,
+ 0xcde1ec2d, 0x48505818, 0x42525012, 0xcbe3e82b, 0x4e727c3e, 0xcad2d81a,
+ 0xc9c1c809, 0xcdf1fc3d, 0x00303030, 0x85919415, 0x45616425, 0x0c303c3c,
+ 0x86b2b436, 0xc4e0e424, 0x8bb3b83b, 0x4c707c3c, 0x0e020c0e, 0x40505010,
+ 0x09313839, 0x06222426, 0x02323032, 0x84808404, 0x49616829, 0x83939013,
+ 0x07333437, 0xc7e3e427, 0x04202424, 0x84a0a424, 0xcbc3c80b, 0x43535013,
+ 0x0a02080a, 0x87838407, 0xc9d1d819, 0x4c404c0c, 0x83838003, 0x8f838c0f,
+ 0xcec2cc0e, 0x0b33383b, 0x4a42480a, 0x87b3b437,
+};
+
+static const u32 KC[NUMKC] = {
+ 0x9e3779b9, 0x3c6ef373, 0x78dde6e6, 0xf1bbcdcc,
+ 0xe3779b99, 0xc6ef3733, 0x8dde6e67, 0x1bbcdccf,
+ 0x3779b99e, 0x6ef3733c, 0xdde6e678, 0xbbcdccf1,
+ 0x779b99e3, 0xef3733c6, 0xde6e678d, 0xbcdccf1b,
+};
+
+
+
+/* Perform the key setup.
+ */
+static gcry_err_code_t
+do_setkey (SEED_context *ctx, const byte *key, const unsigned keylen)
+{
+ static int initialized = 0;
+ static const char *selftest_failed=0;
+ u32 x1, x2, x3, x4;
+ union wordbuf t0, t1;
+ u32 *keyout = ctx->keyschedule;
+ int i;
+
+ if (!initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+ if( selftest_failed )
+ log_error ("%s\n", selftest_failed );
+ }
+ if (selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ if (keylen != 16)
+ return GPG_ERR_INV_KEYLEN;
+
+ x1 = GETU32 (key);
+ x2 = GETU32 (key+4);
+ x3 = GETU32 (key+8);
+ x4 = GETU32 (key+12);
+
+ for (i = 0; i < NUMKC; i++)
+ {
+ t0.w = x1 + x3 - KC[i];
+ t1.w = x2 + KC[i] - x4;
+ *(keyout++) = SS0[t0.b0] ^ SS1[t0.b1] ^ SS2[t0.b2] ^ SS3[t0.b3];
+ *(keyout++) = SS0[t1.b0] ^ SS1[t1.b1] ^ SS2[t1.b2] ^ SS3[t1.b3];
+
+ if (i % 2 == 0)
+ {
+ t0.w = x1;
+ x1 = (x1>>8) ^ (x2<<24);
+ x2 = (x2>>8) ^ (t0.w<<24);
+ }
+ else
+ {
+ t0.w = x3;
+ x3 = (x3<<8) ^ (x4>>24);
+ x4 = (x4<<8) ^ (t0.w>>24);
+ }
+ }
+
+ return 0;
+}
+
+static gcry_err_code_t
+seed_setkey (void *context, const byte *key, const unsigned keylen)
+{
+ SEED_context *ctx = context;
+
+ int rc = do_setkey (ctx, key, keylen);
+ _gcry_burn_stack (4*6 + sizeof(void*)*2 + sizeof(int)*2);
+ return rc;
+}
+
+
+
+#define OP(X1, X2, X3, X4, rbase) \
+ t0.w = X3 ^ ctx->keyschedule[rbase]; \
+ t1.w = X4 ^ ctx->keyschedule[rbase+1]; \
+ t1.w ^= t0.w; \
+ t1.w = SS0[t1.b0] ^ SS1[t1.b1] ^ SS2[t1.b2] ^ SS3[t1.b3]; \
+ t0.w += t1.w; \
+ t0.w = SS0[t0.b0] ^ SS1[t0.b1] ^ SS2[t0.b2] ^ SS3[t0.b3]; \
+ t1.w += t0.w; \
+ t1.w = SS0[t1.b0] ^ SS1[t1.b1] ^ SS2[t1.b2] ^ SS3[t1.b3]; \
+ t0.w += t1.w; \
+ X1 ^= t0.w; \
+ X2 ^= t1.w;
+
+/* Encrypt one block. inbuf and outbuf may be the same. */
+static void
+do_encrypt (const SEED_context *ctx, byte *outbuf, const byte *inbuf)
+{
+ u32 x1, x2, x3, x4;
+ union wordbuf t0, t1;
+
+ x1 = GETU32 (inbuf);
+ x2 = GETU32 (inbuf+4);
+ x3 = GETU32 (inbuf+8);
+ x4 = GETU32 (inbuf+12);
+
+ OP (x1, x2, x3, x4, 0);
+ OP (x3, x4, x1, x2, 2);
+ OP (x1, x2, x3, x4, 4);
+ OP (x3, x4, x1, x2, 6);
+ OP (x1, x2, x3, x4, 8);
+ OP (x3, x4, x1, x2, 10);
+ OP (x1, x2, x3, x4, 12);
+ OP (x3, x4, x1, x2, 14);
+ OP (x1, x2, x3, x4, 16);
+ OP (x3, x4, x1, x2, 18);
+ OP (x1, x2, x3, x4, 20);
+ OP (x3, x4, x1, x2, 22);
+ OP (x1, x2, x3, x4, 24);
+ OP (x3, x4, x1, x2, 26);
+ OP (x1, x2, x3, x4, 28);
+ OP (x3, x4, x1, x2, 30);
+
+ PUTU32 (outbuf, x3);
+ PUTU32 (outbuf+4, x4);
+ PUTU32 (outbuf+8, x1);
+ PUTU32 (outbuf+12, x2);
+}
+
+static void
+seed_encrypt (void *context, byte *outbuf, const byte *inbuf)
+{
+ SEED_context *ctx = context;
+
+ do_encrypt (ctx, outbuf, inbuf);
+ _gcry_burn_stack (4*6);
+}
+
+
+
+/* Decrypt one block. inbuf and outbuf may be the same. */
+static void
+do_decrypt (SEED_context *ctx, byte *outbuf, const byte *inbuf)
+{
+ u32 x1, x2, x3, x4;
+ union wordbuf t0, t1;
+
+ x1 = GETU32 (inbuf);
+ x2 = GETU32 (inbuf+4);
+ x3 = GETU32 (inbuf+8);
+ x4 = GETU32 (inbuf+12);
+
+ OP (x1, x2, x3, x4, 30);
+ OP (x3, x4, x1, x2, 28);
+ OP (x1, x2, x3, x4, 26);
+ OP (x3, x4, x1, x2, 24);
+ OP (x1, x2, x3, x4, 22);
+ OP (x3, x4, x1, x2, 20);
+ OP (x1, x2, x3, x4, 18);
+ OP (x3, x4, x1, x2, 16);
+ OP (x1, x2, x3, x4, 14);
+ OP (x3, x4, x1, x2, 12);
+ OP (x1, x2, x3, x4, 10);
+ OP (x3, x4, x1, x2, 8);
+ OP (x1, x2, x3, x4, 6);
+ OP (x3, x4, x1, x2, 4);
+ OP (x1, x2, x3, x4, 2);
+ OP (x3, x4, x1, x2, 0);
+
+ PUTU32 (outbuf, x3);
+ PUTU32 (outbuf+4, x4);
+ PUTU32 (outbuf+8, x1);
+ PUTU32 (outbuf+12, x2);
+}
+
+static void
+seed_decrypt (void *context, byte *outbuf, const byte *inbuf)
+{
+ SEED_context *ctx = context;
+
+ do_decrypt (ctx, outbuf, inbuf);
+ _gcry_burn_stack (4*6);
+}
+
+
+/* Test a single encryption and decryption with each key size. */
+
+
+
+static gcry_cipher_oid_spec_t seed_oids[] =
+ {
+ { "1.2.410.200004.1.3", GCRY_CIPHER_MODE_ECB },
+ { "1.2.410.200004.1.4", GCRY_CIPHER_MODE_CBC },
+ { "1.2.410.200004.1.5", GCRY_CIPHER_MODE_CFB },
+ { "1.2.410.200004.1.6", GCRY_CIPHER_MODE_OFB },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_seed =
+ {
+ "SEED", NULL, seed_oids, 16, 128, sizeof (SEED_context),
+ seed_setkey, seed_encrypt, seed_decrypt,
+#ifdef GRUB_UTIL
+ .modname = "gcry_seed",
+#endif
+ };
+
+
+GRUB_MOD_INIT(gcry_seed)
+{
+ grub_cipher_register (&_gcry_cipher_spec_seed);
+}
+
+GRUB_MOD_FINI(gcry_seed)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_seed);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/serpent.c b/grub-core/lib/libgcrypt-grub/cipher/serpent.c
new file mode 100644
index 0000000..75be7b8
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/serpent.c
@@ -0,0 +1,903 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* serpent.c - Implementation of the Serpent encryption algorithm.
+ * Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+
+
+#include "types.h"
+#include "g10lib.h"
+#include "cipher.h"
+#include "bithelp.h"
+
+/* Number of rounds per Serpent encrypt/decrypt operation. */
+#define ROUNDS 32
+
+/* Magic number, used during generating of the subkeys. */
+#define PHI 0x9E3779B9
+
+/* Serpent works on 128 bit blocks. */
+typedef u32 serpent_block_t[4];
+
+/* Serpent key, provided by the user. If the original key is shorter
+ than 256 bits, it is padded. */
+typedef u32 serpent_key_t[8];
+
+/* The key schedule consists of 33 128 bit subkeys. */
+typedef u32 serpent_subkeys_t[ROUNDS + 1][4];
+
+/* A Serpent context. */
+typedef struct serpent_context
+{
+ serpent_subkeys_t keys; /* Generated subkeys. */
+} serpent_context_t;
+
+
+/* A prototype. */
+static const char *serpent_test (void);
+
+
+#define byte_swap_32(x) \
+ (0 \
+ | (((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
+ | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+
+/* These are the S-Boxes of Serpent. They are copied from Serpents
+ reference implementation (the optimized one, contained in
+ `floppy2') and are therefore:
+
+ Copyright (C) 1998 Ross Anderson, Eli Biham, Lars Knudsen.
+
+ To quote the Serpent homepage
+ (http://www.cl.cam.ac.uk/~rja14/serpent.html):
+
+ "Serpent is now completely in the public domain, and we impose no
+ restrictions on its use. This was announced on the 21st August at
+ the First AES Candidate Conference. The optimised implementations
+ in the submission package are now under the GNU PUBLIC LICENSE
+ (GPL), although some comments in the code still say otherwise. You
+ are welcome to use Serpent for any application." */
+
+#define SBOX0(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t05, t06, t07, t08, t09; \
+ u32 t11, t12, t13, t14, t15, t17, t01; \
+ t01 = b ^ c ; \
+ t02 = a | d ; \
+ t03 = a ^ b ; \
+ z = t02 ^ t01; \
+ t05 = c | z ; \
+ t06 = a ^ d ; \
+ t07 = b | c ; \
+ t08 = d & t05; \
+ t09 = t03 & t07; \
+ y = t09 ^ t08; \
+ t11 = t09 & y ; \
+ t12 = c ^ d ; \
+ t13 = t07 ^ t11; \
+ t14 = b & t06; \
+ t15 = t06 ^ t13; \
+ w = ~ t15; \
+ t17 = w ^ t14; \
+ x = t12 ^ t17; \
+ }
+
+#define SBOX0_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t08, t09, t10; \
+ u32 t12, t13, t14, t15, t17, t18, t01; \
+ t01 = c ^ d ; \
+ t02 = a | b ; \
+ t03 = b | c ; \
+ t04 = c & t01; \
+ t05 = t02 ^ t01; \
+ t06 = a | t04; \
+ y = ~ t05; \
+ t08 = b ^ d ; \
+ t09 = t03 & t08; \
+ t10 = d | y ; \
+ x = t09 ^ t06; \
+ t12 = a | t05; \
+ t13 = x ^ t12; \
+ t14 = t03 ^ t10; \
+ t15 = a ^ c ; \
+ z = t14 ^ t13; \
+ t17 = t05 & t13; \
+ t18 = t14 | t17; \
+ w = t15 ^ t18; \
+ }
+
+#define SBOX1(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t08; \
+ u32 t10, t11, t12, t13, t16, t17, t01; \
+ t01 = a | d ; \
+ t02 = c ^ d ; \
+ t03 = ~ b ; \
+ t04 = a ^ c ; \
+ t05 = a | t03; \
+ t06 = d & t04; \
+ t07 = t01 & t02; \
+ t08 = b | t06; \
+ y = t02 ^ t05; \
+ t10 = t07 ^ t08; \
+ t11 = t01 ^ t10; \
+ t12 = y ^ t11; \
+ t13 = b & d ; \
+ z = ~ t10; \
+ x = t13 ^ t12; \
+ t16 = t10 | x ; \
+ t17 = t05 & t16; \
+ w = c ^ t17; \
+ }
+
+#define SBOX1_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t08; \
+ u32 t09, t10, t11, t14, t15, t17, t01; \
+ t01 = a ^ b ; \
+ t02 = b | d ; \
+ t03 = a & c ; \
+ t04 = c ^ t02; \
+ t05 = a | t04; \
+ t06 = t01 & t05; \
+ t07 = d | t03; \
+ t08 = b ^ t06; \
+ t09 = t07 ^ t06; \
+ t10 = t04 | t03; \
+ t11 = d & t08; \
+ y = ~ t09; \
+ x = t10 ^ t11; \
+ t14 = a | y ; \
+ t15 = t06 ^ x ; \
+ z = t01 ^ t04; \
+ t17 = c ^ t15; \
+ w = t14 ^ t17; \
+ }
+
+#define SBOX2(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t05, t06, t07, t08; \
+ u32 t09, t10, t12, t13, t14, t01; \
+ t01 = a | c ; \
+ t02 = a ^ b ; \
+ t03 = d ^ t01; \
+ w = t02 ^ t03; \
+ t05 = c ^ w ; \
+ t06 = b ^ t05; \
+ t07 = b | t05; \
+ t08 = t01 & t06; \
+ t09 = t03 ^ t07; \
+ t10 = t02 | t09; \
+ x = t10 ^ t08; \
+ t12 = a | d ; \
+ t13 = t09 ^ x ; \
+ t14 = b ^ t13; \
+ z = ~ t09; \
+ y = t12 ^ t14; \
+ }
+
+#define SBOX2_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t06, t07, t08, t09; \
+ u32 t10, t11, t12, t15, t16, t17, t01; \
+ t01 = a ^ d ; \
+ t02 = c ^ d ; \
+ t03 = a & c ; \
+ t04 = b | t02; \
+ w = t01 ^ t04; \
+ t06 = a | c ; \
+ t07 = d | w ; \
+ t08 = ~ d ; \
+ t09 = b & t06; \
+ t10 = t08 | t03; \
+ t11 = b & t07; \
+ t12 = t06 & t02; \
+ z = t09 ^ t10; \
+ x = t12 ^ t11; \
+ t15 = c & z ; \
+ t16 = w ^ x ; \
+ t17 = t10 ^ t15; \
+ y = t16 ^ t17; \
+ }
+
+#define SBOX3(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t08; \
+ u32 t09, t10, t11, t13, t14, t15, t01; \
+ t01 = a ^ c ; \
+ t02 = a | d ; \
+ t03 = a & d ; \
+ t04 = t01 & t02; \
+ t05 = b | t03; \
+ t06 = a & b ; \
+ t07 = d ^ t04; \
+ t08 = c | t06; \
+ t09 = b ^ t07; \
+ t10 = d & t05; \
+ t11 = t02 ^ t10; \
+ z = t08 ^ t09; \
+ t13 = d | z ; \
+ t14 = a | t07; \
+ t15 = b & t13; \
+ y = t08 ^ t11; \
+ w = t14 ^ t15; \
+ x = t05 ^ t04; \
+ }
+
+#define SBOX3_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t09; \
+ u32 t11, t12, t13, t14, t16, t01; \
+ t01 = c | d ; \
+ t02 = a | d ; \
+ t03 = c ^ t02; \
+ t04 = b ^ t02; \
+ t05 = a ^ d ; \
+ t06 = t04 & t03; \
+ t07 = b & t01; \
+ y = t05 ^ t06; \
+ t09 = a ^ t03; \
+ w = t07 ^ t03; \
+ t11 = w | t05; \
+ t12 = t09 & t11; \
+ t13 = a & y ; \
+ t14 = t01 ^ t05; \
+ x = b ^ t12; \
+ t16 = b | t13; \
+ z = t14 ^ t16; \
+ }
+
+#define SBOX4(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t08, t09; \
+ u32 t10, t11, t12, t13, t14, t15, t16, t01; \
+ t01 = a | b ; \
+ t02 = b | c ; \
+ t03 = a ^ t02; \
+ t04 = b ^ d ; \
+ t05 = d | t03; \
+ t06 = d & t01; \
+ z = t03 ^ t06; \
+ t08 = z & t04; \
+ t09 = t04 & t05; \
+ t10 = c ^ t06; \
+ t11 = b & c ; \
+ t12 = t04 ^ t08; \
+ t13 = t11 | t03; \
+ t14 = t10 ^ t09; \
+ t15 = a & t05; \
+ t16 = t11 | t12; \
+ y = t13 ^ t08; \
+ x = t15 ^ t16; \
+ w = ~ t14; \
+ }
+
+#define SBOX4_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t09; \
+ u32 t10, t11, t12, t13, t15, t01; \
+ t01 = b | d ; \
+ t02 = c | d ; \
+ t03 = a & t01; \
+ t04 = b ^ t02; \
+ t05 = c ^ d ; \
+ t06 = ~ t03; \
+ t07 = a & t04; \
+ x = t05 ^ t07; \
+ t09 = x | t06; \
+ t10 = a ^ t07; \
+ t11 = t01 ^ t09; \
+ t12 = d ^ t04; \
+ t13 = c | t10; \
+ z = t03 ^ t12; \
+ t15 = a ^ t04; \
+ y = t11 ^ t13; \
+ w = t15 ^ t09; \
+ }
+
+#define SBOX5(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t07, t08, t09; \
+ u32 t10, t11, t12, t13, t14, t01; \
+ t01 = b ^ d ; \
+ t02 = b | d ; \
+ t03 = a & t01; \
+ t04 = c ^ t02; \
+ t05 = t03 ^ t04; \
+ w = ~ t05; \
+ t07 = a ^ t01; \
+ t08 = d | w ; \
+ t09 = b | t05; \
+ t10 = d ^ t08; \
+ t11 = b | t07; \
+ t12 = t03 | w ; \
+ t13 = t07 | t10; \
+ t14 = t01 ^ t11; \
+ y = t09 ^ t13; \
+ x = t07 ^ t08; \
+ z = t12 ^ t14; \
+ }
+
+#define SBOX5_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t07, t08, t09; \
+ u32 t10, t12, t13, t15, t16, t01; \
+ t01 = a & d ; \
+ t02 = c ^ t01; \
+ t03 = a ^ d ; \
+ t04 = b & t02; \
+ t05 = a & c ; \
+ w = t03 ^ t04; \
+ t07 = a & w ; \
+ t08 = t01 ^ w ; \
+ t09 = b | t05; \
+ t10 = ~ b ; \
+ x = t08 ^ t09; \
+ t12 = t10 | t07; \
+ t13 = w | x ; \
+ z = t02 ^ t12; \
+ t15 = t02 ^ t13; \
+ t16 = b ^ d ; \
+ y = t16 ^ t15; \
+ }
+
+#define SBOX6(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t07, t08, t09, t10; \
+ u32 t11, t12, t13, t15, t17, t18, t01; \
+ t01 = a & d ; \
+ t02 = b ^ c ; \
+ t03 = a ^ d ; \
+ t04 = t01 ^ t02; \
+ t05 = b | c ; \
+ x = ~ t04; \
+ t07 = t03 & t05; \
+ t08 = b & x ; \
+ t09 = a | c ; \
+ t10 = t07 ^ t08; \
+ t11 = b | d ; \
+ t12 = c ^ t11; \
+ t13 = t09 ^ t10; \
+ y = ~ t13; \
+ t15 = x & t03; \
+ z = t12 ^ t07; \
+ t17 = a ^ b ; \
+ t18 = y ^ t15; \
+ w = t17 ^ t18; \
+ }
+
+#define SBOX6_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t08, t09; \
+ u32 t12, t13, t14, t15, t16, t17, t01; \
+ t01 = a ^ c ; \
+ t02 = ~ c ; \
+ t03 = b & t01; \
+ t04 = b | t02; \
+ t05 = d | t03; \
+ t06 = b ^ d ; \
+ t07 = a & t04; \
+ t08 = a | t02; \
+ t09 = t07 ^ t05; \
+ x = t06 ^ t08; \
+ w = ~ t09; \
+ t12 = b & w ; \
+ t13 = t01 & t05; \
+ t14 = t01 ^ t12; \
+ t15 = t07 ^ t13; \
+ t16 = d | t02; \
+ t17 = a ^ x ; \
+ z = t17 ^ t15; \
+ y = t16 ^ t14; \
+ }
+
+#define SBOX7(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t08, t09, t10; \
+ u32 t11, t13, t14, t15, t16, t17, t01; \
+ t01 = a & c ; \
+ t02 = ~ d ; \
+ t03 = a & t02; \
+ t04 = b | t01; \
+ t05 = a & b ; \
+ t06 = c ^ t04; \
+ z = t03 ^ t06; \
+ t08 = c | z ; \
+ t09 = d | t05; \
+ t10 = a ^ t08; \
+ t11 = t04 & z ; \
+ x = t09 ^ t10; \
+ t13 = b ^ x ; \
+ t14 = t01 ^ x ; \
+ t15 = c ^ t05; \
+ t16 = t11 | t13; \
+ t17 = t02 | t14; \
+ w = t15 ^ t17; \
+ y = a ^ t16; \
+ }
+
+#define SBOX7_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t06, t07, t08, t09; \
+ u32 t10, t11, t13, t14, t15, t16, t01; \
+ t01 = a & b ; \
+ t02 = a | b ; \
+ t03 = c | t01; \
+ t04 = d & t02; \
+ z = t03 ^ t04; \
+ t06 = b ^ t04; \
+ t07 = d ^ z ; \
+ t08 = ~ t07; \
+ t09 = t06 | t08; \
+ t10 = b ^ d ; \
+ t11 = a | d ; \
+ x = a ^ t09; \
+ t13 = c ^ t06; \
+ t14 = c & t11; \
+ t15 = d | x ; \
+ t16 = t01 | t10; \
+ w = t13 ^ t15; \
+ y = t14 ^ t16; \
+ }
+
+/* XOR BLOCK1 into BLOCK0. */
+#define BLOCK_XOR(block0, block1) \
+ { \
+ block0[0] ^= block1[0]; \
+ block0[1] ^= block1[1]; \
+ block0[2] ^= block1[2]; \
+ block0[3] ^= block1[3]; \
+ }
+
+/* Copy BLOCK_SRC to BLOCK_DST. */
+#define BLOCK_COPY(block_dst, block_src) \
+ { \
+ block_dst[0] = block_src[0]; \
+ block_dst[1] = block_src[1]; \
+ block_dst[2] = block_src[2]; \
+ block_dst[3] = block_src[3]; \
+ }
+
+/* Apply SBOX number WHICH to to the block found in ARRAY0 at index
+ INDEX, writing the output to the block found in ARRAY1 at index
+ INDEX. */
+#define SBOX(which, array0, array1, index) \
+ SBOX##which (array0[index + 0], array0[index + 1], \
+ array0[index + 2], array0[index + 3], \
+ array1[index + 0], array1[index + 1], \
+ array1[index + 2], array1[index + 3]);
+
+/* Apply inverse SBOX number WHICH to to the block found in ARRAY0 at
+ index INDEX, writing the output to the block found in ARRAY1 at
+ index INDEX. */
+#define SBOX_INVERSE(which, array0, array1, index) \
+ SBOX##which##_INVERSE (array0[index + 0], array0[index + 1], \
+ array0[index + 2], array0[index + 3], \
+ array1[index + 0], array1[index + 1], \
+ array1[index + 2], array1[index + 3]);
+
+/* Apply the linear transformation to BLOCK. */
+#define LINEAR_TRANSFORMATION(block) \
+ { \
+ block[0] = rol (block[0], 13); \
+ block[2] = rol (block[2], 3); \
+ block[1] = block[1] ^ block[0] ^ block[2]; \
+ block[3] = block[3] ^ block[2] ^ (block[0] << 3); \
+ block[1] = rol (block[1], 1); \
+ block[3] = rol (block[3], 7); \
+ block[0] = block[0] ^ block[1] ^ block[3]; \
+ block[2] = block[2] ^ block[3] ^ (block[1] << 7); \
+ block[0] = rol (block[0], 5); \
+ block[2] = rol (block[2], 22); \
+ }
+
+/* Apply the inverse linear transformation to BLOCK. */
+#define LINEAR_TRANSFORMATION_INVERSE(block) \
+ { \
+ block[2] = ror (block[2], 22); \
+ block[0] = ror (block[0] , 5); \
+ block[2] = block[2] ^ block[3] ^ (block[1] << 7); \
+ block[0] = block[0] ^ block[1] ^ block[3]; \
+ block[3] = ror (block[3], 7); \
+ block[1] = ror (block[1], 1); \
+ block[3] = block[3] ^ block[2] ^ (block[0] << 3); \
+ block[1] = block[1] ^ block[0] ^ block[2]; \
+ block[2] = ror (block[2], 3); \
+ block[0] = ror (block[0], 13); \
+ }
+
+/* Apply a Serpent round to BLOCK, using the SBOX number WHICH and the
+ subkeys contained in SUBKEYS. Use BLOCK_TMP as temporary storage.
+ This macro increments `round'. */
+#define ROUND(which, subkeys, block, block_tmp) \
+ { \
+ BLOCK_XOR (block, subkeys[round]); \
+ round++; \
+ SBOX (which, block, block_tmp, 0); \
+ LINEAR_TRANSFORMATION (block_tmp); \
+ BLOCK_COPY (block, block_tmp); \
+ }
+
+/* Apply the last Serpent round to BLOCK, using the SBOX number WHICH
+ and the subkeys contained in SUBKEYS. Use BLOCK_TMP as temporary
+ storage. The result will be stored in BLOCK_TMP. This macro
+ increments `round'. */
+#define ROUND_LAST(which, subkeys, block, block_tmp) \
+ { \
+ BLOCK_XOR (block, subkeys[round]); \
+ round++; \
+ SBOX (which, block, block_tmp, 0); \
+ BLOCK_XOR (block_tmp, subkeys[round]); \
+ round++; \
+ }
+
+/* Apply an inverse Serpent round to BLOCK, using the SBOX number
+ WHICH and the subkeys contained in SUBKEYS. Use BLOCK_TMP as
+ temporary storage. This macro increments `round'. */
+#define ROUND_INVERSE(which, subkey, block, block_tmp) \
+ { \
+ LINEAR_TRANSFORMATION_INVERSE (block); \
+ SBOX_INVERSE (which, block, block_tmp, 0); \
+ BLOCK_XOR (block_tmp, subkey[round]); \
+ round--; \
+ BLOCK_COPY (block, block_tmp); \
+ }
+
+/* Apply the first Serpent round to BLOCK, using the SBOX number WHICH
+ and the subkeys contained in SUBKEYS. Use BLOCK_TMP as temporary
+ storage. The result will be stored in BLOCK_TMP. This macro
+ increments `round'. */
+#define ROUND_FIRST_INVERSE(which, subkeys, block, block_tmp) \
+ { \
+ BLOCK_XOR (block, subkeys[round]); \
+ round--; \
+ SBOX_INVERSE (which, block, block_tmp, 0); \
+ BLOCK_XOR (block_tmp, subkeys[round]); \
+ round--; \
+ }
+
+/* Convert the user provided key KEY of KEY_LENGTH bytes into the
+ internally used format. */
+static void
+serpent_key_prepare (const byte *key, unsigned int key_length,
+ serpent_key_t key_prepared)
+{
+ int i;
+
+ /* Copy key. */
+ memcpy (key_prepared, key, key_length);
+ key_length /= 4;
+#ifdef WORDS_BIGENDIAN
+ for (i = 0; i < key_length; i++)
+ key_prepared[i] = byte_swap_32 (key_prepared[i]);
+#else
+ i = key_length;
+#endif
+ if (i < 8)
+ {
+ /* Key must be padded according to the Serpent
+ specification. */
+ key_prepared[i] = 0x00000001;
+
+ for (i++; i < 8; i++)
+ key_prepared[i] = 0;
+ }
+}
+
+/* Derive the 33 subkeys from KEY and store them in SUBKEYS. */
+static void
+serpent_subkeys_generate (serpent_key_t key, serpent_subkeys_t subkeys)
+{
+ u32 w_real[140]; /* The `prekey'. */
+ u32 k[132];
+ u32 *w = &w_real[8];
+ int i, j;
+
+ /* Initialize with key values. */
+ for (i = 0; i < 8; i++)
+ w[i - 8] = key[i];
+
+ /* Expand to intermediate key using the affine recurrence. */
+ for (i = 0; i < 132; i++)
+ w[i] = rol (w[i - 8] ^ w[i - 5] ^ w[i - 3] ^ w[i - 1] ^ PHI ^ i, 11);
+
+ /* Calculate subkeys via S-Boxes, in bitslice mode. */
+ SBOX (3, w, k, 0);
+ SBOX (2, w, k, 4);
+ SBOX (1, w, k, 8);
+ SBOX (0, w, k, 12);
+ SBOX (7, w, k, 16);
+ SBOX (6, w, k, 20);
+ SBOX (5, w, k, 24);
+ SBOX (4, w, k, 28);
+ SBOX (3, w, k, 32);
+ SBOX (2, w, k, 36);
+ SBOX (1, w, k, 40);
+ SBOX (0, w, k, 44);
+ SBOX (7, w, k, 48);
+ SBOX (6, w, k, 52);
+ SBOX (5, w, k, 56);
+ SBOX (4, w, k, 60);
+ SBOX (3, w, k, 64);
+ SBOX (2, w, k, 68);
+ SBOX (1, w, k, 72);
+ SBOX (0, w, k, 76);
+ SBOX (7, w, k, 80);
+ SBOX (6, w, k, 84);
+ SBOX (5, w, k, 88);
+ SBOX (4, w, k, 92);
+ SBOX (3, w, k, 96);
+ SBOX (2, w, k, 100);
+ SBOX (1, w, k, 104);
+ SBOX (0, w, k, 108);
+ SBOX (7, w, k, 112);
+ SBOX (6, w, k, 116);
+ SBOX (5, w, k, 120);
+ SBOX (4, w, k, 124);
+ SBOX (3, w, k, 128);
+
+ /* Renumber subkeys. */
+ for (i = 0; i < ROUNDS + 1; i++)
+ for (j = 0; j < 4; j++)
+ subkeys[i][j] = k[4 * i + j];
+}
+
+/* Initialize CONTEXT with the key KEY of KEY_LENGTH bits. */
+static void
+serpent_setkey_internal (serpent_context_t *context,
+ const byte *key, unsigned int key_length)
+{
+ serpent_key_t key_prepared;
+
+ serpent_key_prepare (key, key_length, key_prepared);
+ serpent_subkeys_generate (key_prepared, context->keys);
+ _gcry_burn_stack (272 * sizeof (u32));
+}
+
+/* Initialize CTX with the key KEY of KEY_LENGTH bytes. */
+static gcry_err_code_t
+serpent_setkey (void *ctx,
+ const byte *key, unsigned int key_length)
+{
+ serpent_context_t *context = ctx;
+ static const char *serpent_test_ret;
+ static int serpent_init_done;
+ gcry_err_code_t ret = GPG_ERR_NO_ERROR;
+
+ if (! serpent_init_done)
+ {
+ /* Execute a self-test the first time, Serpent is used. */
+ serpent_test_ret = serpent_test ();
+ if (serpent_test_ret)
+ log_error ("Serpent test failure: %s\n", serpent_test_ret);
+ serpent_init_done = 1;
+ }
+
+ if (serpent_test_ret)
+ ret = GPG_ERR_SELFTEST_FAILED;
+ else
+ {
+ serpent_setkey_internal (context, key, key_length);
+ _gcry_burn_stack (sizeof (serpent_key_t));
+ }
+
+ return ret;
+}
+
+static void
+serpent_encrypt_internal (serpent_context_t *context,
+ const byte *input, byte *output)
+{
+ serpent_block_t b, b_next;
+ int round = 0;
+
+ memcpy (b, input, sizeof (b));
+#ifdef WORDS_BIGENDIAN
+ b[0] = byte_swap_32 (b[0]);
+ b[1] = byte_swap_32 (b[1]);
+ b[2] = byte_swap_32 (b[2]);
+ b[3] = byte_swap_32 (b[3]);
+#endif
+
+ ROUND (0, context->keys, b, b_next);
+ ROUND (1, context->keys, b, b_next);
+ ROUND (2, context->keys, b, b_next);
+ ROUND (3, context->keys, b, b_next);
+ ROUND (4, context->keys, b, b_next);
+ ROUND (5, context->keys, b, b_next);
+ ROUND (6, context->keys, b, b_next);
+ ROUND (7, context->keys, b, b_next);
+ ROUND (0, context->keys, b, b_next);
+ ROUND (1, context->keys, b, b_next);
+ ROUND (2, context->keys, b, b_next);
+ ROUND (3, context->keys, b, b_next);
+ ROUND (4, context->keys, b, b_next);
+ ROUND (5, context->keys, b, b_next);
+ ROUND (6, context->keys, b, b_next);
+ ROUND (7, context->keys, b, b_next);
+ ROUND (0, context->keys, b, b_next);
+ ROUND (1, context->keys, b, b_next);
+ ROUND (2, context->keys, b, b_next);
+ ROUND (3, context->keys, b, b_next);
+ ROUND (4, context->keys, b, b_next);
+ ROUND (5, context->keys, b, b_next);
+ ROUND (6, context->keys, b, b_next);
+ ROUND (7, context->keys, b, b_next);
+ ROUND (0, context->keys, b, b_next);
+ ROUND (1, context->keys, b, b_next);
+ ROUND (2, context->keys, b, b_next);
+ ROUND (3, context->keys, b, b_next);
+ ROUND (4, context->keys, b, b_next);
+ ROUND (5, context->keys, b, b_next);
+ ROUND (6, context->keys, b, b_next);
+
+ ROUND_LAST (7, context->keys, b, b_next);
+
+#ifdef WORDS_BIGENDIAN
+ b_next[0] = byte_swap_32 (b_next[0]);
+ b_next[1] = byte_swap_32 (b_next[1]);
+ b_next[2] = byte_swap_32 (b_next[2]);
+ b_next[3] = byte_swap_32 (b_next[3]);
+#endif
+ memcpy (output, b_next, sizeof (b_next));
+}
+
+static void
+serpent_decrypt_internal (serpent_context_t *context,
+ const byte *input, byte *output)
+{
+ serpent_block_t b, b_next;
+ int round = ROUNDS;
+
+ memcpy (b_next, input, sizeof (b));
+#ifdef WORDS_BIGENDIAN
+ b_next[0] = byte_swap_32 (b_next[0]);
+ b_next[1] = byte_swap_32 (b_next[1]);
+ b_next[2] = byte_swap_32 (b_next[2]);
+ b_next[3] = byte_swap_32 (b_next[3]);
+#endif
+
+ ROUND_FIRST_INVERSE (7, context->keys, b_next, b);
+
+ ROUND_INVERSE (6, context->keys, b, b_next);
+ ROUND_INVERSE (5, context->keys, b, b_next);
+ ROUND_INVERSE (4, context->keys, b, b_next);
+ ROUND_INVERSE (3, context->keys, b, b_next);
+ ROUND_INVERSE (2, context->keys, b, b_next);
+ ROUND_INVERSE (1, context->keys, b, b_next);
+ ROUND_INVERSE (0, context->keys, b, b_next);
+ ROUND_INVERSE (7, context->keys, b, b_next);
+ ROUND_INVERSE (6, context->keys, b, b_next);
+ ROUND_INVERSE (5, context->keys, b, b_next);
+ ROUND_INVERSE (4, context->keys, b, b_next);
+ ROUND_INVERSE (3, context->keys, b, b_next);
+ ROUND_INVERSE (2, context->keys, b, b_next);
+ ROUND_INVERSE (1, context->keys, b, b_next);
+ ROUND_INVERSE (0, context->keys, b, b_next);
+ ROUND_INVERSE (7, context->keys, b, b_next);
+ ROUND_INVERSE (6, context->keys, b, b_next);
+ ROUND_INVERSE (5, context->keys, b, b_next);
+ ROUND_INVERSE (4, context->keys, b, b_next);
+ ROUND_INVERSE (3, context->keys, b, b_next);
+ ROUND_INVERSE (2, context->keys, b, b_next);
+ ROUND_INVERSE (1, context->keys, b, b_next);
+ ROUND_INVERSE (0, context->keys, b, b_next);
+ ROUND_INVERSE (7, context->keys, b, b_next);
+ ROUND_INVERSE (6, context->keys, b, b_next);
+ ROUND_INVERSE (5, context->keys, b, b_next);
+ ROUND_INVERSE (4, context->keys, b, b_next);
+ ROUND_INVERSE (3, context->keys, b, b_next);
+ ROUND_INVERSE (2, context->keys, b, b_next);
+ ROUND_INVERSE (1, context->keys, b, b_next);
+ ROUND_INVERSE (0, context->keys, b, b_next);
+
+#ifdef WORDS_BIGENDIAN
+ b_next[0] = byte_swap_32 (b_next[0]);
+ b_next[1] = byte_swap_32 (b_next[1]);
+ b_next[2] = byte_swap_32 (b_next[2]);
+ b_next[3] = byte_swap_32 (b_next[3]);
+#endif
+ memcpy (output, b_next, sizeof (b_next));
+}
+
+static void
+serpent_encrypt (void *ctx, byte *buffer_out, const byte *buffer_in)
+{
+ serpent_context_t *context = ctx;
+
+ serpent_encrypt_internal (context, buffer_in, buffer_out);
+ _gcry_burn_stack (2 * sizeof (serpent_block_t));
+}
+
+static void
+serpent_decrypt (void *ctx, byte *buffer_out, const byte *buffer_in)
+{
+ serpent_context_t *context = ctx;
+
+ serpent_decrypt_internal (context, buffer_in, buffer_out);
+ _gcry_burn_stack (2 * sizeof (serpent_block_t));
+}
+
+
+
+/* Serpent test. */
+
+static const char *serpent_test (void) { return 0; }
+
+
+
+/* "SERPENT" is an alias for "SERPENT128". */
+static const char *cipher_spec_serpent128_aliases[] =
+ {
+ "SERPENT",
+ NULL
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_serpent128 =
+ {
+ "SERPENT128", cipher_spec_serpent128_aliases, NULL, 16, 128,
+ sizeof (serpent_context_t),
+ serpent_setkey, serpent_encrypt, serpent_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_serpent",
+#endif
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_serpent192 =
+ {
+ "SERPENT192", NULL, NULL, 16, 192,
+ sizeof (serpent_context_t),
+ serpent_setkey, serpent_encrypt, serpent_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_serpent",
+#endif
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_serpent256 =
+ {
+ "SERPENT256", NULL, NULL, 16, 256,
+ sizeof (serpent_context_t),
+ serpent_setkey, serpent_encrypt, serpent_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_serpent",
+#endif
+ };
+
+
+GRUB_MOD_INIT(gcry_serpent)
+{
+ grub_cipher_register (&_gcry_cipher_spec_serpent128);
+ grub_cipher_register (&_gcry_cipher_spec_serpent192);
+ grub_cipher_register (&_gcry_cipher_spec_serpent256);
+}
+
+GRUB_MOD_FINI(gcry_serpent)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_serpent128);
+ grub_cipher_unregister (&_gcry_cipher_spec_serpent192);
+ grub_cipher_unregister (&_gcry_cipher_spec_serpent256);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/sha1.c b/grub-core/lib/libgcrypt-grub/cipher/sha1.c
new file mode 100644
index 0000000..581802d
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/sha1.c
@@ -0,0 +1,419 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* sha1.c - SHA1 hash function
+ * Copyright (C) 1998, 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/* Test vectors:
+ *
+ * "abc"
+ * A999 3E36 4706 816A BA3E 2571 7850 C26C 9CD0 D89D
+ *
+ * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ * 8498 3E44 1C3B D26E BAAE 4AA1 F951 29E5 E546 70F1
+ */
+
+
+#ifdef HAVE_STDINT_H
+#endif
+
+#include "g10lib.h"
+#include "bithelp.h"
+#include "cipher.h"
+#include "hash-common.h"
+
+
+/* A macro to test whether P is properly aligned for an u32 type.
+ Note that config.h provides a suitable replacement for uintptr_t if
+ it does not exist in stdint.h. */
+/* #if __GNUC__ >= 2 */
+/* # define U32_ALIGNED_P(p) (!(((uintptr_t)p) % __alignof__ (u32))) */
+/* #else */
+/* # define U32_ALIGNED_P(p) (!(((uintptr_t)p) % sizeof (u32))) */
+/* #endif */
+
+#define TRANSFORM(x,d,n) transform ((x), (d), (n))
+
+
+typedef struct
+{
+ u32 h0,h1,h2,h3,h4;
+ u32 nblocks;
+ unsigned char buf[64];
+ int count;
+} SHA1_CONTEXT;
+
+
+
+static void
+sha1_init (void *context)
+{
+ SHA1_CONTEXT *hd = context;
+
+ hd->h0 = 0x67452301;
+ hd->h1 = 0xefcdab89;
+ hd->h2 = 0x98badcfe;
+ hd->h3 = 0x10325476;
+ hd->h4 = 0xc3d2e1f0;
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+
+/* Round function macros. */
+#define K1 0x5A827999L
+#define K2 0x6ED9EBA1L
+#define K3 0x8F1BBCDCL
+#define K4 0xCA62C1D6L
+#define F1(x,y,z) ( z ^ ( x & ( y ^ z ) ) )
+#define F2(x,y,z) ( x ^ y ^ z )
+#define F3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) )
+#define F4(x,y,z) ( x ^ y ^ z )
+#define M(i) ( tm = x[ i &0x0f] \
+ ^ x[(i-14)&0x0f] \
+ ^ x[(i-8) &0x0f] \
+ ^ x[(i-3) &0x0f], \
+ (x[i&0x0f] = rol(tm, 1)))
+#define R(a,b,c,d,e,f,k,m) do { e += rol( a, 5 ) \
+ + f( b, c, d ) \
+ + k \
+ + m; \
+ b = rol( b, 30 ); \
+ } while(0)
+
+
+/*
+ * Transform NBLOCKS of each 64 bytes (16 32-bit words) at DATA.
+ */
+static void
+transform (SHA1_CONTEXT *hd, const unsigned char *data, size_t nblocks)
+{
+ register u32 a, b, c, d, e; /* Local copies of the chaining variables. */
+ register u32 tm; /* Helper. */
+ u32 x[16]; /* The array we work on. */
+
+ /* Loop over all blocks. */
+ for ( ;nblocks; nblocks--)
+ {
+#ifdef WORDS_BIGENDIAN
+ memcpy (x, data, 64);
+ data += 64;
+#else
+ {
+ int i;
+ unsigned char *p;
+
+ for(i=0, p=(unsigned char*)x; i < 16; i++, p += 4 )
+ {
+ p[3] = *data++;
+ p[2] = *data++;
+ p[1] = *data++;
+ p[0] = *data++;
+ }
+ }
+#endif
+ /* Get the values of the chaining variables. */
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+
+ /* Transform. */
+ R( a, b, c, d, e, F1, K1, x[ 0] );
+ R( e, a, b, c, d, F1, K1, x[ 1] );
+ R( d, e, a, b, c, F1, K1, x[ 2] );
+ R( c, d, e, a, b, F1, K1, x[ 3] );
+ R( b, c, d, e, a, F1, K1, x[ 4] );
+ R( a, b, c, d, e, F1, K1, x[ 5] );
+ R( e, a, b, c, d, F1, K1, x[ 6] );
+ R( d, e, a, b, c, F1, K1, x[ 7] );
+ R( c, d, e, a, b, F1, K1, x[ 8] );
+ R( b, c, d, e, a, F1, K1, x[ 9] );
+ R( a, b, c, d, e, F1, K1, x[10] );
+ R( e, a, b, c, d, F1, K1, x[11] );
+ R( d, e, a, b, c, F1, K1, x[12] );
+ R( c, d, e, a, b, F1, K1, x[13] );
+ R( b, c, d, e, a, F1, K1, x[14] );
+ R( a, b, c, d, e, F1, K1, x[15] );
+ R( e, a, b, c, d, F1, K1, M(16) );
+ R( d, e, a, b, c, F1, K1, M(17) );
+ R( c, d, e, a, b, F1, K1, M(18) );
+ R( b, c, d, e, a, F1, K1, M(19) );
+ R( a, b, c, d, e, F2, K2, M(20) );
+ R( e, a, b, c, d, F2, K2, M(21) );
+ R( d, e, a, b, c, F2, K2, M(22) );
+ R( c, d, e, a, b, F2, K2, M(23) );
+ R( b, c, d, e, a, F2, K2, M(24) );
+ R( a, b, c, d, e, F2, K2, M(25) );
+ R( e, a, b, c, d, F2, K2, M(26) );
+ R( d, e, a, b, c, F2, K2, M(27) );
+ R( c, d, e, a, b, F2, K2, M(28) );
+ R( b, c, d, e, a, F2, K2, M(29) );
+ R( a, b, c, d, e, F2, K2, M(30) );
+ R( e, a, b, c, d, F2, K2, M(31) );
+ R( d, e, a, b, c, F2, K2, M(32) );
+ R( c, d, e, a, b, F2, K2, M(33) );
+ R( b, c, d, e, a, F2, K2, M(34) );
+ R( a, b, c, d, e, F2, K2, M(35) );
+ R( e, a, b, c, d, F2, K2, M(36) );
+ R( d, e, a, b, c, F2, K2, M(37) );
+ R( c, d, e, a, b, F2, K2, M(38) );
+ R( b, c, d, e, a, F2, K2, M(39) );
+ R( a, b, c, d, e, F3, K3, M(40) );
+ R( e, a, b, c, d, F3, K3, M(41) );
+ R( d, e, a, b, c, F3, K3, M(42) );
+ R( c, d, e, a, b, F3, K3, M(43) );
+ R( b, c, d, e, a, F3, K3, M(44) );
+ R( a, b, c, d, e, F3, K3, M(45) );
+ R( e, a, b, c, d, F3, K3, M(46) );
+ R( d, e, a, b, c, F3, K3, M(47) );
+ R( c, d, e, a, b, F3, K3, M(48) );
+ R( b, c, d, e, a, F3, K3, M(49) );
+ R( a, b, c, d, e, F3, K3, M(50) );
+ R( e, a, b, c, d, F3, K3, M(51) );
+ R( d, e, a, b, c, F3, K3, M(52) );
+ R( c, d, e, a, b, F3, K3, M(53) );
+ R( b, c, d, e, a, F3, K3, M(54) );
+ R( a, b, c, d, e, F3, K3, M(55) );
+ R( e, a, b, c, d, F3, K3, M(56) );
+ R( d, e, a, b, c, F3, K3, M(57) );
+ R( c, d, e, a, b, F3, K3, M(58) );
+ R( b, c, d, e, a, F3, K3, M(59) );
+ R( a, b, c, d, e, F4, K4, M(60) );
+ R( e, a, b, c, d, F4, K4, M(61) );
+ R( d, e, a, b, c, F4, K4, M(62) );
+ R( c, d, e, a, b, F4, K4, M(63) );
+ R( b, c, d, e, a, F4, K4, M(64) );
+ R( a, b, c, d, e, F4, K4, M(65) );
+ R( e, a, b, c, d, F4, K4, M(66) );
+ R( d, e, a, b, c, F4, K4, M(67) );
+ R( c, d, e, a, b, F4, K4, M(68) );
+ R( b, c, d, e, a, F4, K4, M(69) );
+ R( a, b, c, d, e, F4, K4, M(70) );
+ R( e, a, b, c, d, F4, K4, M(71) );
+ R( d, e, a, b, c, F4, K4, M(72) );
+ R( c, d, e, a, b, F4, K4, M(73) );
+ R( b, c, d, e, a, F4, K4, M(74) );
+ R( a, b, c, d, e, F4, K4, M(75) );
+ R( e, a, b, c, d, F4, K4, M(76) );
+ R( d, e, a, b, c, F4, K4, M(77) );
+ R( c, d, e, a, b, F4, K4, M(78) );
+ R( b, c, d, e, a, F4, K4, M(79) );
+
+ /* Update the chaining variables. */
+ hd->h0 += a;
+ hd->h1 += b;
+ hd->h2 += c;
+ hd->h3 += d;
+ hd->h4 += e;
+ }
+}
+
+
+/* Update the message digest with the contents
+ * of INBUF with length INLEN.
+ */
+static void
+sha1_write( void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ SHA1_CONTEXT *hd = context;
+ size_t nblocks;
+
+ if (hd->count == 64) /* Flush the buffer. */
+ {
+ TRANSFORM( hd, hd->buf, 1 );
+ _gcry_burn_stack (88+4*sizeof(void*));
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if (!inbuf)
+ return;
+
+ if (hd->count)
+ {
+ for (; inlen && hd->count < 64; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+ sha1_write (hd, NULL, 0);
+ if (!inlen)
+ return;
+ }
+
+ nblocks = inlen / 64;
+ if (nblocks)
+ {
+ TRANSFORM (hd, inbuf, nblocks);
+ hd->count = 0;
+ hd->nblocks += nblocks;
+ inlen -= nblocks * 64;
+ inbuf += nblocks * 64;
+ }
+ _gcry_burn_stack (88+4*sizeof(void*));
+
+ /* Save remaining bytes. */
+ for (; inlen && hd->count < 64; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+/* The routine final terminates the computation and
+ * returns the digest.
+ * The handle is prepared for a new cycle, but adding bytes to the
+ * handle will the destroy the returned buffer.
+ * Returns: 20 bytes representing the digest.
+ */
+
+static void
+sha1_final(void *context)
+{
+ SHA1_CONTEXT *hd = context;
+
+ u32 t, msb, lsb;
+ unsigned char *p;
+
+ sha1_write(hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if( (lsb += hd->count) < t )
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if( hd->count < 56 ) /* enough room */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while( hd->count < 56 )
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else /* need one extra block */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while( hd->count < 64 )
+ hd->buf[hd->count++] = 0;
+ sha1_write(hd, NULL, 0); /* flush */;
+ memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = msb >> 24;
+ hd->buf[57] = msb >> 16;
+ hd->buf[58] = msb >> 8;
+ hd->buf[59] = msb ;
+ hd->buf[60] = lsb >> 24;
+ hd->buf[61] = lsb >> 16;
+ hd->buf[62] = lsb >> 8;
+ hd->buf[63] = lsb ;
+ TRANSFORM( hd, hd->buf, 1 );
+ _gcry_burn_stack (88+4*sizeof(void*));
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
+#else /* little endian */
+#define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \
+ *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0)
+#endif
+ X(0);
+ X(1);
+ X(2);
+ X(3);
+ X(4);
+#undef X
+
+}
+
+static unsigned char *
+sha1_read( void *context )
+{
+ SHA1_CONTEXT *hd = context;
+
+ return hd->buf;
+}
+
+/****************
+ * Shortcut functions which puts the hash value of the supplied buffer
+ * into outbuf which must have a size of 20 bytes.
+ */
+
+
+
+/*
+ Self-test section.
+ */
+
+
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+
+
+
+
+static unsigned char asn[15] = /* Object ID is 1.3.14.3.2.26 */
+ { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03,
+ 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 };
+
+static gcry_md_oid_spec_t oid_spec_sha1[] =
+ {
+ /* iso.member-body.us.rsadsi.pkcs.pkcs-1.5 (sha1WithRSAEncryption) */
+ { "1.2.840.113549.1.1.5" },
+ /* iso.member-body.us.x9-57.x9cm.3 (dsaWithSha1)*/
+ { "1.2.840.10040.4.3" },
+ /* from NIST's OIW (sha1) */
+ { "1.3.14.3.2.26" },
+ /* from NIST OIW (sha-1WithRSAEncryption) */
+ { "1.3.14.3.2.29" },
+ /* iso.member-body.us.ansi-x9-62.signatures.ecdsa-with-sha1 */
+ { "1.2.840.10045.4.1" },
+ { NULL },
+ };
+
+gcry_md_spec_t _gcry_digest_spec_sha1 =
+ {
+ "SHA1", asn, DIM (asn), oid_spec_sha1, 20,
+ sha1_init, sha1_write, sha1_final, sha1_read,
+ sizeof (SHA1_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_sha1",
+#endif
+ .blocksize = 64
+ };
+
+
+GRUB_MOD_INIT(gcry_sha1)
+{
+ COMPILE_TIME_ASSERT(sizeof (SHA1_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ grub_md_register (&_gcry_digest_spec_sha1);
+}
+
+GRUB_MOD_FINI(gcry_sha1)
+{
+ grub_md_unregister (&_gcry_digest_spec_sha1);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/sha256.c b/grub-core/lib/libgcrypt-grub/cipher/sha256.c
new file mode 100644
index 0000000..0c9fd6b
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/sha256.c
@@ -0,0 +1,463 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* sha256.c - SHA256 hash function
+ * Copyright (C) 2003, 2006, 2008, 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/* Test vectors:
+
+ "abc"
+ SHA224: 23097d22 3405d822 8642a477 bda255b3 2aadbce4 bda0b3f7 e36c9da7
+ SHA256: ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad
+
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ SHA224: 75388b16 512776cc 5dba5da1 fd890150 b0c6455c b4f58b19 52522525
+ SHA256: 248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1
+
+ "a" one million times
+ SHA224: 20794655 980c91d8 bbb4c1ea 97618a4b f03f4258 1948b2ee 4ee7ad67
+ SHA256: cdc76e5c 9914fb92 81a1c7e2 84d73e67 f1809a48 a497200e 046d39cc c7112cd0
+
+ */
+
+
+
+#include "g10lib.h"
+#include "bithelp.h"
+#include "cipher.h"
+#include "hash-common.h"
+
+typedef struct {
+ u32 h0,h1,h2,h3,h4,h5,h6,h7;
+ u32 nblocks;
+ byte buf[64];
+ int count;
+} SHA256_CONTEXT;
+
+
+static void
+sha256_init (void *context)
+{
+ SHA256_CONTEXT *hd = context;
+
+ hd->h0 = 0x6a09e667;
+ hd->h1 = 0xbb67ae85;
+ hd->h2 = 0x3c6ef372;
+ hd->h3 = 0xa54ff53a;
+ hd->h4 = 0x510e527f;
+ hd->h5 = 0x9b05688c;
+ hd->h6 = 0x1f83d9ab;
+ hd->h7 = 0x5be0cd19;
+
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+
+static void
+sha224_init (void *context)
+{
+ SHA256_CONTEXT *hd = context;
+
+ hd->h0 = 0xc1059ed8;
+ hd->h1 = 0x367cd507;
+ hd->h2 = 0x3070dd17;
+ hd->h3 = 0xf70e5939;
+ hd->h4 = 0xffc00b31;
+ hd->h5 = 0x68581511;
+ hd->h6 = 0x64f98fa7;
+ hd->h7 = 0xbefa4fa4;
+
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+
+/*
+ Transform the message X which consists of 16 32-bit-words. See FIPS
+ 180-2 for details. */
+#define S0(x) (ror ((x), 7) ^ ror ((x), 18) ^ ((x) >> 3)) /* (4.6) */
+#define S1(x) (ror ((x), 17) ^ ror ((x), 19) ^ ((x) >> 10)) /* (4.7) */
+#define R(a,b,c,d,e,f,g,h,k,w) do \
+ { \
+ t1 = (h) + Sum1((e)) + Cho((e),(f),(g)) + (k) + (w); \
+ t2 = Sum0((a)) + Maj((a),(b),(c)); \
+ h = g; \
+ g = f; \
+ f = e; \
+ e = d + t1; \
+ d = c; \
+ c = b; \
+ b = a; \
+ a = t1 + t2; \
+ } while (0)
+
+/* (4.2) same as SHA-1's F1. */
+static inline u32
+Cho (u32 x, u32 y, u32 z)
+{
+ return (z ^ (x & (y ^ z)));
+}
+
+/* (4.3) same as SHA-1's F3 */
+static inline u32
+Maj (u32 x, u32 y, u32 z)
+{
+ return ((x & y) | (z & (x|y)));
+}
+
+/* (4.4) */
+static inline u32
+Sum0 (u32 x)
+{
+ return (ror (x, 2) ^ ror (x, 13) ^ ror (x, 22));
+}
+
+/* (4.5) */
+static inline u32
+Sum1 (u32 x)
+{
+ return (ror (x, 6) ^ ror (x, 11) ^ ror (x, 25));
+}
+
+
+static void
+transform (SHA256_CONTEXT *hd, const unsigned char *data)
+{
+ static const u32 K[64] = {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+ };
+
+ u32 a,b,c,d,e,f,g,h,t1,t2;
+ u32 x[16];
+ u32 w[64];
+ int i;
+
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+ f = hd->h5;
+ g = hd->h6;
+ h = hd->h7;
+
+#ifdef WORDS_BIGENDIAN
+ memcpy (x, data, 64);
+#else
+ {
+ byte *p2;
+
+ for (i=0, p2=(byte*)x; i < 16; i++, p2 += 4 )
+ {
+ p2[3] = *data++;
+ p2[2] = *data++;
+ p2[1] = *data++;
+ p2[0] = *data++;
+ }
+ }
+#endif
+
+ for (i=0; i < 16; i++)
+ w[i] = x[i];
+ for (; i < 64; i++)
+ w[i] = S1(w[i-2]) + w[i-7] + S0(w[i-15]) + w[i-16];
+
+ for (i=0; i < 64;)
+ {
+#if 0
+ R(a,b,c,d,e,f,g,h,K[i],w[i]);
+ i++;
+#else
+ t1 = h + Sum1 (e) + Cho (e, f, g) + K[i] + w[i];
+ t2 = Sum0 (a) + Maj (a, b, c);
+ d += t1;
+ h = t1 + t2;
+
+ t1 = g + Sum1 (d) + Cho (d, e, f) + K[i+1] + w[i+1];
+ t2 = Sum0 (h) + Maj (h, a, b);
+ c += t1;
+ g = t1 + t2;
+
+ t1 = f + Sum1 (c) + Cho (c, d, e) + K[i+2] + w[i+2];
+ t2 = Sum0 (g) + Maj (g, h, a);
+ b += t1;
+ f = t1 + t2;
+
+ t1 = e + Sum1 (b) + Cho (b, c, d) + K[i+3] + w[i+3];
+ t2 = Sum0 (f) + Maj (f, g, h);
+ a += t1;
+ e = t1 + t2;
+
+ t1 = d + Sum1 (a) + Cho (a, b, c) + K[i+4] + w[i+4];
+ t2 = Sum0 (e) + Maj (e, f, g);
+ h += t1;
+ d = t1 + t2;
+
+ t1 = c + Sum1 (h) + Cho (h, a, b) + K[i+5] + w[i+5];
+ t2 = Sum0 (d) + Maj (d, e, f);
+ g += t1;
+ c = t1 + t2;
+
+ t1 = b + Sum1 (g) + Cho (g, h, a) + K[i+6] + w[i+6];
+ t2 = Sum0 (c) + Maj (c, d, e);
+ f += t1;
+ b = t1 + t2;
+
+ t1 = a + Sum1 (f) + Cho (f, g, h) + K[i+7] + w[i+7];
+ t2 = Sum0 (b) + Maj (b, c, d);
+ e += t1;
+ a = t1 + t2;
+
+ i += 8;
+#endif
+ }
+
+ hd->h0 += a;
+ hd->h1 += b;
+ hd->h2 += c;
+ hd->h3 += d;
+ hd->h4 += e;
+ hd->h5 += f;
+ hd->h6 += g;
+ hd->h7 += h;
+}
+#undef S0
+#undef S1
+#undef R
+
+
+/* Update the message digest with the contents of INBUF with length
+ INLEN. */
+static void
+sha256_write (void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ SHA256_CONTEXT *hd = context;
+
+ if (hd->count == 64)
+ { /* flush the buffer */
+ transform (hd, hd->buf);
+ _gcry_burn_stack (74*4+32);
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if (!inbuf)
+ return;
+ if (hd->count)
+ {
+ for (; inlen && hd->count < 64; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+ sha256_write (hd, NULL, 0);
+ if (!inlen)
+ return;
+ }
+
+ while (inlen >= 64)
+ {
+ transform (hd, inbuf);
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 64;
+ inbuf += 64;
+ }
+ _gcry_burn_stack (74*4+32);
+ for (; inlen && hd->count < 64; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+/*
+ The routine finally terminates the computation and returns the
+ digest. The handle is prepared for a new cycle, but adding bytes
+ to the handle will the destroy the returned buffer. Returns: 32
+ bytes with the message the digest. */
+static void
+sha256_final(void *context)
+{
+ SHA256_CONTEXT *hd = context;
+ u32 t, msb, lsb;
+ byte *p;
+
+ sha256_write (hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if ((lsb += hd->count) < t)
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if (hd->count < 56)
+ { /* enough room */
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while (hd->count < 56)
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else
+ { /* need one extra block */
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while (hd->count < 64)
+ hd->buf[hd->count++] = 0;
+ sha256_write (hd, NULL, 0); /* flush */;
+ memset (hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = msb >> 24;
+ hd->buf[57] = msb >> 16;
+ hd->buf[58] = msb >> 8;
+ hd->buf[59] = msb;
+ hd->buf[60] = lsb >> 24;
+ hd->buf[61] = lsb >> 16;
+ hd->buf[62] = lsb >> 8;
+ hd->buf[63] = lsb;
+ transform (hd, hd->buf);
+ _gcry_burn_stack (74*4+32);
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
+#else /* little endian */
+#define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \
+ *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0)
+#endif
+ X(0);
+ X(1);
+ X(2);
+ X(3);
+ X(4);
+ X(5);
+ X(6);
+ X(7);
+#undef X
+}
+
+static byte *
+sha256_read (void *context)
+{
+ SHA256_CONTEXT *hd = context;
+
+ return hd->buf;
+}
+
+
+
+/*
+ Self-test section.
+ */
+
+
+
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+
+
+
+
+static byte asn224[19] = /* Object ID is 2.16.840.1.101.3.4.2.4 */
+ { 0x30, 0x2D, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48,
+ 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04,
+ 0x1C
+ };
+
+static gcry_md_oid_spec_t oid_spec_sha224[] =
+ {
+ /* From RFC3874, Section 4 */
+ { "2.16.840.1.101.3.4.2.4" },
+ { NULL },
+ };
+
+static byte asn256[19] = /* Object ID is 2.16.840.1.101.3.4.2.1 */
+ { 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
+ 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
+ 0x00, 0x04, 0x20 };
+
+static gcry_md_oid_spec_t oid_spec_sha256[] =
+ {
+ /* According to the OpenPGP draft rfc2440-bis06 */
+ { "2.16.840.1.101.3.4.2.1" },
+ /* PKCS#1 sha256WithRSAEncryption */
+ { "1.2.840.113549.1.1.11" },
+
+ { NULL },
+ };
+
+gcry_md_spec_t _gcry_digest_spec_sha224 =
+ {
+ "SHA224", asn224, DIM (asn224), oid_spec_sha224, 28,
+ sha224_init, sha256_write, sha256_final, sha256_read,
+ sizeof (SHA256_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_sha256",
+#endif
+ .blocksize = 64
+ };
+
+gcry_md_spec_t _gcry_digest_spec_sha256 =
+ {
+ "SHA256", asn256, DIM (asn256), oid_spec_sha256, 32,
+ sha256_init, sha256_write, sha256_final, sha256_read,
+ sizeof (SHA256_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_sha256",
+#endif
+ .blocksize = 64
+ };
+
+
+GRUB_MOD_INIT(gcry_sha256)
+{
+ COMPILE_TIME_ASSERT(sizeof (SHA256_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ COMPILE_TIME_ASSERT(sizeof (SHA256_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ grub_md_register (&_gcry_digest_spec_sha224);
+ grub_md_register (&_gcry_digest_spec_sha256);
+}
+
+GRUB_MOD_FINI(gcry_sha256)
+{
+ grub_md_unregister (&_gcry_digest_spec_sha224);
+ grub_md_unregister (&_gcry_digest_spec_sha256);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/sha512.c b/grub-core/lib/libgcrypt-grub/cipher/sha512.c
new file mode 100644
index 0000000..717551c
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/sha512.c
@@ -0,0 +1,525 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* sha512.c - SHA384 and SHA512 hash functions
+ * Copyright (C) 2003, 2008, 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/* Test vectors from FIPS-180-2:
+ *
+ * "abc"
+ * 384:
+ * CB00753F 45A35E8B B5A03D69 9AC65007 272C32AB 0EDED163
+ * 1A8B605A 43FF5BED 8086072B A1E7CC23 58BAECA1 34C825A7
+ * 512:
+ * DDAF35A1 93617ABA CC417349 AE204131 12E6FA4E 89A97EA2 0A9EEEE6 4B55D39A
+ * 2192992A 274FC1A8 36BA3C23 A3FEEBBD 454D4423 643CE80E 2A9AC94F A54CA49F
+ *
+ * "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
+ * 384:
+ * 09330C33 F71147E8 3D192FC7 82CD1B47 53111B17 3B3B05D2
+ * 2FA08086 E3B0F712 FCC7C71A 557E2DB9 66C3E9FA 91746039
+ * 512:
+ * 8E959B75 DAE313DA 8CF4F728 14FC143F 8F7779C6 EB9F7FA1 7299AEAD B6889018
+ * 501D289E 4900F7E4 331B99DE C4B5433A C7D329EE B6DD2654 5E96E55B 874BE909
+ *
+ * "a" x 1000000
+ * 384:
+ * 9D0E1809 716474CB 086E834E 310A4A1C ED149E9C 00F24852
+ * 7972CEC5 704C2A5B 07B8B3DC 38ECC4EB AE97DDD8 7F3D8985
+ * 512:
+ * E718483D 0CE76964 4E2E42C7 BC15B463 8E1F98B1 3B204428 5632A803 AFA973EB
+ * DE0FF244 877EA60A 4CB0432C E577C31B EB009C5C 2C49AA2E 4EADB217 AD8CC09B
+ */
+
+
+#include "g10lib.h"
+#include "bithelp.h"
+#include "cipher.h"
+#include "hash-common.h"
+
+typedef struct
+{
+ u64 h0, h1, h2, h3, h4, h5, h6, h7;
+ u64 nblocks;
+ byte buf[128];
+ int count;
+} SHA512_CONTEXT;
+
+static void
+sha512_init (void *context)
+{
+ SHA512_CONTEXT *hd = context;
+
+ hd->h0 = U64_C(0x6a09e667f3bcc908);
+ hd->h1 = U64_C(0xbb67ae8584caa73b);
+ hd->h2 = U64_C(0x3c6ef372fe94f82b);
+ hd->h3 = U64_C(0xa54ff53a5f1d36f1);
+ hd->h4 = U64_C(0x510e527fade682d1);
+ hd->h5 = U64_C(0x9b05688c2b3e6c1f);
+ hd->h6 = U64_C(0x1f83d9abfb41bd6b);
+ hd->h7 = U64_C(0x5be0cd19137e2179);
+
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+static void
+sha384_init (void *context)
+{
+ SHA512_CONTEXT *hd = context;
+
+ hd->h0 = U64_C(0xcbbb9d5dc1059ed8);
+ hd->h1 = U64_C(0x629a292a367cd507);
+ hd->h2 = U64_C(0x9159015a3070dd17);
+ hd->h3 = U64_C(0x152fecd8f70e5939);
+ hd->h4 = U64_C(0x67332667ffc00b31);
+ hd->h5 = U64_C(0x8eb44a8768581511);
+ hd->h6 = U64_C(0xdb0c2e0d64f98fa7);
+ hd->h7 = U64_C(0x47b5481dbefa4fa4);
+
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+
+static inline u64
+ROTR (u64 x, u64 n)
+{
+ return ((x >> n) | (x << (64 - n)));
+}
+
+static inline u64
+Ch (u64 x, u64 y, u64 z)
+{
+ return ((x & y) ^ ( ~x & z));
+}
+
+static inline u64
+Maj (u64 x, u64 y, u64 z)
+{
+ return ((x & y) ^ (x & z) ^ (y & z));
+}
+
+static inline u64
+Sum0 (u64 x)
+{
+ return (ROTR (x, 28) ^ ROTR (x, 34) ^ ROTR (x, 39));
+}
+
+static inline u64
+Sum1 (u64 x)
+{
+ return (ROTR (x, 14) ^ ROTR (x, 18) ^ ROTR (x, 41));
+}
+
+/****************
+ * Transform the message W which consists of 16 64-bit-words
+ */
+static void
+transform (SHA512_CONTEXT *hd, const unsigned char *data)
+{
+ u64 a, b, c, d, e, f, g, h;
+ u64 w[80];
+ int t;
+ static const u64 k[] =
+ {
+ U64_C(0x428a2f98d728ae22), U64_C(0x7137449123ef65cd),
+ U64_C(0xb5c0fbcfec4d3b2f), U64_C(0xe9b5dba58189dbbc),
+ U64_C(0x3956c25bf348b538), U64_C(0x59f111f1b605d019),
+ U64_C(0x923f82a4af194f9b), U64_C(0xab1c5ed5da6d8118),
+ U64_C(0xd807aa98a3030242), U64_C(0x12835b0145706fbe),
+ U64_C(0x243185be4ee4b28c), U64_C(0x550c7dc3d5ffb4e2),
+ U64_C(0x72be5d74f27b896f), U64_C(0x80deb1fe3b1696b1),
+ U64_C(0x9bdc06a725c71235), U64_C(0xc19bf174cf692694),
+ U64_C(0xe49b69c19ef14ad2), U64_C(0xefbe4786384f25e3),
+ U64_C(0x0fc19dc68b8cd5b5), U64_C(0x240ca1cc77ac9c65),
+ U64_C(0x2de92c6f592b0275), U64_C(0x4a7484aa6ea6e483),
+ U64_C(0x5cb0a9dcbd41fbd4), U64_C(0x76f988da831153b5),
+ U64_C(0x983e5152ee66dfab), U64_C(0xa831c66d2db43210),
+ U64_C(0xb00327c898fb213f), U64_C(0xbf597fc7beef0ee4),
+ U64_C(0xc6e00bf33da88fc2), U64_C(0xd5a79147930aa725),
+ U64_C(0x06ca6351e003826f), U64_C(0x142929670a0e6e70),
+ U64_C(0x27b70a8546d22ffc), U64_C(0x2e1b21385c26c926),
+ U64_C(0x4d2c6dfc5ac42aed), U64_C(0x53380d139d95b3df),
+ U64_C(0x650a73548baf63de), U64_C(0x766a0abb3c77b2a8),
+ U64_C(0x81c2c92e47edaee6), U64_C(0x92722c851482353b),
+ U64_C(0xa2bfe8a14cf10364), U64_C(0xa81a664bbc423001),
+ U64_C(0xc24b8b70d0f89791), U64_C(0xc76c51a30654be30),
+ U64_C(0xd192e819d6ef5218), U64_C(0xd69906245565a910),
+ U64_C(0xf40e35855771202a), U64_C(0x106aa07032bbd1b8),
+ U64_C(0x19a4c116b8d2d0c8), U64_C(0x1e376c085141ab53),
+ U64_C(0x2748774cdf8eeb99), U64_C(0x34b0bcb5e19b48a8),
+ U64_C(0x391c0cb3c5c95a63), U64_C(0x4ed8aa4ae3418acb),
+ U64_C(0x5b9cca4f7763e373), U64_C(0x682e6ff3d6b2b8a3),
+ U64_C(0x748f82ee5defb2fc), U64_C(0x78a5636f43172f60),
+ U64_C(0x84c87814a1f0ab72), U64_C(0x8cc702081a6439ec),
+ U64_C(0x90befffa23631e28), U64_C(0xa4506cebde82bde9),
+ U64_C(0xbef9a3f7b2c67915), U64_C(0xc67178f2e372532b),
+ U64_C(0xca273eceea26619c), U64_C(0xd186b8c721c0c207),
+ U64_C(0xeada7dd6cde0eb1e), U64_C(0xf57d4f7fee6ed178),
+ U64_C(0x06f067aa72176fba), U64_C(0x0a637dc5a2c898a6),
+ U64_C(0x113f9804bef90dae), U64_C(0x1b710b35131c471b),
+ U64_C(0x28db77f523047d84), U64_C(0x32caab7b40c72493),
+ U64_C(0x3c9ebe0a15c9bebc), U64_C(0x431d67c49c100d4c),
+ U64_C(0x4cc5d4becb3e42b6), U64_C(0x597f299cfc657e2a),
+ U64_C(0x5fcb6fab3ad6faec), U64_C(0x6c44198c4a475817)
+ };
+
+ /* get values from the chaining vars */
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+ f = hd->h5;
+ g = hd->h6;
+ h = hd->h7;
+
+#ifdef WORDS_BIGENDIAN
+ memcpy (w, data, 128);
+#else
+ {
+ int i;
+ byte *p2;
+
+ for (i = 0, p2 = (byte *) w; i < 16; i++, p2 += 8)
+ {
+ p2[7] = *data++;
+ p2[6] = *data++;
+ p2[5] = *data++;
+ p2[4] = *data++;
+ p2[3] = *data++;
+ p2[2] = *data++;
+ p2[1] = *data++;
+ p2[0] = *data++;
+ }
+ }
+#endif
+
+#define S0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7))
+#define S1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6))
+
+ for (t = 16; t < 80; t++)
+ w[t] = S1 (w[t - 2]) + w[t - 7] + S0 (w[t - 15]) + w[t - 16];
+
+
+ for (t = 0; t < 80; )
+ {
+ u64 t1, t2;
+
+ /* Performance on a AMD Athlon(tm) Dual Core Processor 4050e
+ with gcc 4.3.3 using gcry_md_hash_buffer of each 10000 bytes
+ initialized to 0,1,2,3...255,0,... and 1000 iterations:
+
+ Not unrolled with macros: 440ms
+ Unrolled with macros: 350ms
+ Unrolled with inline: 330ms
+ */
+#if 0 /* Not unrolled. */
+ t1 = h + Sum1 (e) + Ch (e, f, g) + k[t] + w[t];
+ t2 = Sum0 (a) + Maj (a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + t1;
+ d = c;
+ c = b;
+ b = a;
+ a = t1 + t2;
+ t++;
+#else /* Unrolled to interweave the chain variables. */
+ t1 = h + Sum1 (e) + Ch (e, f, g) + k[t] + w[t];
+ t2 = Sum0 (a) + Maj (a, b, c);
+ d += t1;
+ h = t1 + t2;
+
+ t1 = g + Sum1 (d) + Ch (d, e, f) + k[t+1] + w[t+1];
+ t2 = Sum0 (h) + Maj (h, a, b);
+ c += t1;
+ g = t1 + t2;
+
+ t1 = f + Sum1 (c) + Ch (c, d, e) + k[t+2] + w[t+2];
+ t2 = Sum0 (g) + Maj (g, h, a);
+ b += t1;
+ f = t1 + t2;
+
+ t1 = e + Sum1 (b) + Ch (b, c, d) + k[t+3] + w[t+3];
+ t2 = Sum0 (f) + Maj (f, g, h);
+ a += t1;
+ e = t1 + t2;
+
+ t1 = d + Sum1 (a) + Ch (a, b, c) + k[t+4] + w[t+4];
+ t2 = Sum0 (e) + Maj (e, f, g);
+ h += t1;
+ d = t1 + t2;
+
+ t1 = c + Sum1 (h) + Ch (h, a, b) + k[t+5] + w[t+5];
+ t2 = Sum0 (d) + Maj (d, e, f);
+ g += t1;
+ c = t1 + t2;
+
+ t1 = b + Sum1 (g) + Ch (g, h, a) + k[t+6] + w[t+6];
+ t2 = Sum0 (c) + Maj (c, d, e);
+ f += t1;
+ b = t1 + t2;
+
+ t1 = a + Sum1 (f) + Ch (f, g, h) + k[t+7] + w[t+7];
+ t2 = Sum0 (b) + Maj (b, c, d);
+ e += t1;
+ a = t1 + t2;
+
+ t += 8;
+#endif
+ }
+
+ /* Update chaining vars. */
+ hd->h0 += a;
+ hd->h1 += b;
+ hd->h2 += c;
+ hd->h3 += d;
+ hd->h4 += e;
+ hd->h5 += f;
+ hd->h6 += g;
+ hd->h7 += h;
+}
+
+
+/* Update the message digest with the contents
+ * of INBUF with length INLEN.
+ */
+static void
+sha512_write (void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ SHA512_CONTEXT *hd = context;
+
+ if (hd->count == 128)
+ { /* flush the buffer */
+ transform (hd, hd->buf);
+ _gcry_burn_stack (768);
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if (!inbuf)
+ return;
+ if (hd->count)
+ {
+ for (; inlen && hd->count < 128; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+ sha512_write (context, NULL, 0);
+ if (!inlen)
+ return;
+ }
+
+ while (inlen >= 128)
+ {
+ transform (hd, inbuf);
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 128;
+ inbuf += 128;
+ }
+ _gcry_burn_stack (768);
+ for (; inlen && hd->count < 128; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+/* The routine final terminates the computation and
+ * returns the digest.
+ * The handle is prepared for a new cycle, but adding bytes to the
+ * handle will the destroy the returned buffer.
+ * Returns: 64 bytes representing the digest. When used for sha384,
+ * we take the leftmost 48 of those bytes.
+ */
+
+static void
+sha512_final (void *context)
+{
+ SHA512_CONTEXT *hd = context;
+ u64 t, msb, lsb;
+ byte *p;
+
+ sha512_write (context, NULL, 0); /* flush */ ;
+
+ t = hd->nblocks;
+ /* multiply by 128 to make a byte count */
+ lsb = t << 7;
+ msb = t >> 57;
+ /* add the count */
+ t = lsb;
+ if ((lsb += hd->count) < t)
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 61;
+
+ if (hd->count < 112)
+ { /* enough room */
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while (hd->count < 112)
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else
+ { /* need one extra block */
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while (hd->count < 128)
+ hd->buf[hd->count++] = 0;
+ sha512_write (context, NULL, 0); /* flush */ ;
+ memset (hd->buf, 0, 112); /* fill next block with zeroes */
+ }
+ /* append the 128 bit count */
+ hd->buf[112] = msb >> 56;
+ hd->buf[113] = msb >> 48;
+ hd->buf[114] = msb >> 40;
+ hd->buf[115] = msb >> 32;
+ hd->buf[116] = msb >> 24;
+ hd->buf[117] = msb >> 16;
+ hd->buf[118] = msb >> 8;
+ hd->buf[119] = msb;
+
+ hd->buf[120] = lsb >> 56;
+ hd->buf[121] = lsb >> 48;
+ hd->buf[122] = lsb >> 40;
+ hd->buf[123] = lsb >> 32;
+ hd->buf[124] = lsb >> 24;
+ hd->buf[125] = lsb >> 16;
+ hd->buf[126] = lsb >> 8;
+ hd->buf[127] = lsb;
+ transform (hd, hd->buf);
+ _gcry_burn_stack (768);
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *(u64*)p = hd->h##a ; p += 8; } while (0)
+#else /* little endian */
+#define X(a) do { *p++ = hd->h##a >> 56; *p++ = hd->h##a >> 48; \
+ *p++ = hd->h##a >> 40; *p++ = hd->h##a >> 32; \
+ *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \
+ *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while (0)
+#endif
+ X (0);
+ X (1);
+ X (2);
+ X (3);
+ X (4);
+ X (5);
+ /* Note that these last two chunks are included even for SHA384.
+ We just ignore them. */
+ X (6);
+ X (7);
+#undef X
+}
+
+static byte *
+sha512_read (void *context)
+{
+ SHA512_CONTEXT *hd = (SHA512_CONTEXT *) context;
+ return hd->buf;
+}
+
+
+
+/*
+ Self-test section.
+ */
+
+
+
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+
+
+
+
+static byte sha512_asn[] = /* Object ID is 2.16.840.1.101.3.4.2.3 */
+ {
+ 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
+ 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
+ 0x00, 0x04, 0x40
+ };
+
+static gcry_md_oid_spec_t oid_spec_sha512[] =
+ {
+ { "2.16.840.1.101.3.4.2.3" },
+
+ /* PKCS#1 sha512WithRSAEncryption */
+ { "1.2.840.113549.1.1.13" },
+
+ { NULL }
+ };
+
+gcry_md_spec_t _gcry_digest_spec_sha512 =
+ {
+ "SHA512", sha512_asn, DIM (sha512_asn), oid_spec_sha512, 64,
+ sha512_init, sha512_write, sha512_final, sha512_read,
+ sizeof (SHA512_CONTEXT),
+#ifdef GRUB_UTIL
+ .modname = "gcry_sha512",
+#endif
+ .blocksize = 128
+ };
+
+static byte sha384_asn[] = /* Object ID is 2.16.840.1.101.3.4.2.2 */
+ {
+ 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
+ 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
+ 0x00, 0x04, 0x30
+ };
+
+static gcry_md_oid_spec_t oid_spec_sha384[] =
+ {
+ { "2.16.840.1.101.3.4.2.2" },
+
+ /* PKCS#1 sha384WithRSAEncryption */
+ { "1.2.840.113549.1.1.12" },
+
+ { NULL },
+ };
+
+gcry_md_spec_t _gcry_digest_spec_sha384 =
+ {
+ "SHA384", sha384_asn, DIM (sha384_asn), oid_spec_sha384, 48,
+ sha384_init, sha512_write, sha512_final, sha512_read,
+ sizeof (SHA512_CONTEXT),
+#ifdef GRUB_UTIL
+ .modname = "gcry_sha512",
+#endif
+ .blocksize = 128
+ };
+
+
+GRUB_MOD_INIT(gcry_sha512)
+{
+ COMPILE_TIME_ASSERT(sizeof (SHA512_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ COMPILE_TIME_ASSERT(sizeof (SHA512_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ grub_md_register (&_gcry_digest_spec_sha512);
+ grub_md_register (&_gcry_digest_spec_sha384);
+}
+
+GRUB_MOD_FINI(gcry_sha512)
+{
+ grub_md_unregister (&_gcry_digest_spec_sha512);
+ grub_md_unregister (&_gcry_digest_spec_sha384);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/tiger.c b/grub-core/lib/libgcrypt-grub/cipher/tiger.c
new file mode 100644
index 0000000..c277293
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/tiger.c
@@ -0,0 +1,944 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* tiger.c - The TIGER hash function
+ * Copyright (C) 1998, 2001, 2002, 2003, 2010 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/* See http://www.cs.technion.ac.il/~biham/Reports/Tiger/ */
+
+
+#include "g10lib.h"
+#include "cipher.h"
+
+/* We really need a 64 bit type for this code. */
+#ifdef HAVE_U64_TYPEDEF
+
+typedef struct
+{
+ u64 a, b, c;
+ byte buf[64];
+ int count;
+ u32 nblocks;
+ int variant; /* 0 = old code, 1 = fixed code, 2 - TIGER2. */
+} TIGER_CONTEXT;
+
+
+/*********************************
+ * Okay, okay, this is not the fastest code - improvements are welcome.
+ *
+ */
+
+/* Some test vectors:
+ * "" 24F0130C63AC9332 16166E76B1BB925F F373DE2D49584E7A
+ * "abc" F258C1E88414AB2A 527AB541FFC5B8BF 935F7B951C132951
+ * "Tiger" 9F00F599072300DD 276ABB38C8EB6DEC 37790C116F9D2BDF
+ * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"
+ * 87FB2A9083851CF7 470D2CF810E6DF9E B586445034A5A386
+ * "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789"
+ * 467DB80863EBCE48 8DF1CD1261655DE9 57896565975F9197
+ * "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham"
+ * 0C410A042968868A 1671DA5A3FD29A72 5EC1E457D3CDB303
+ * "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proc"
+ * "eedings of Fast Software Encryption 3, Cambridge."
+ * EBF591D5AFA655CE 7F22894FF87F54AC 89C811B6B0DA3193
+ * "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proc"
+ * "eedings of Fast Software Encryption 3, Cambridge, 1996."
+ * 3D9AEB03D1BD1A63 57B2774DFD6D5B24 DD68151D503974FC
+ * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEF"
+ * "GHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"
+ * 00B83EB4E53440C5 76AC6AAEE0A74858 25FD15E70A59FFE4
+ */
+
+static u64 sbox1[256] = {
+ U64_C(0x02aab17cf7e90c5e) /* 0 */, U64_C(0xac424b03e243a8ec) /* 1 */,
+ U64_C(0x72cd5be30dd5fcd3) /* 2 */, U64_C(0x6d019b93f6f97f3a) /* 3 */,
+ U64_C(0xcd9978ffd21f9193) /* 4 */, U64_C(0x7573a1c9708029e2) /* 5 */,
+ U64_C(0xb164326b922a83c3) /* 6 */, U64_C(0x46883eee04915870) /* 7 */,
+ U64_C(0xeaace3057103ece6) /* 8 */, U64_C(0xc54169b808a3535c) /* 9 */,
+ U64_C(0x4ce754918ddec47c) /* 10 */, U64_C(0x0aa2f4dfdc0df40c) /* 11 */,
+ U64_C(0x10b76f18a74dbefa) /* 12 */, U64_C(0xc6ccb6235ad1ab6a) /* 13 */,
+ U64_C(0x13726121572fe2ff) /* 14 */, U64_C(0x1a488c6f199d921e) /* 15 */,
+ U64_C(0x4bc9f9f4da0007ca) /* 16 */, U64_C(0x26f5e6f6e85241c7) /* 17 */,
+ U64_C(0x859079dbea5947b6) /* 18 */, U64_C(0x4f1885c5c99e8c92) /* 19 */,
+ U64_C(0xd78e761ea96f864b) /* 20 */, U64_C(0x8e36428c52b5c17d) /* 21 */,
+ U64_C(0x69cf6827373063c1) /* 22 */, U64_C(0xb607c93d9bb4c56e) /* 23 */,
+ U64_C(0x7d820e760e76b5ea) /* 24 */, U64_C(0x645c9cc6f07fdc42) /* 25 */,
+ U64_C(0xbf38a078243342e0) /* 26 */, U64_C(0x5f6b343c9d2e7d04) /* 27 */,
+ U64_C(0xf2c28aeb600b0ec6) /* 28 */, U64_C(0x6c0ed85f7254bcac) /* 29 */,
+ U64_C(0x71592281a4db4fe5) /* 30 */, U64_C(0x1967fa69ce0fed9f) /* 31 */,
+ U64_C(0xfd5293f8b96545db) /* 32 */, U64_C(0xc879e9d7f2a7600b) /* 33 */,
+ U64_C(0x860248920193194e) /* 34 */, U64_C(0xa4f9533b2d9cc0b3) /* 35 */,
+ U64_C(0x9053836c15957613) /* 36 */, U64_C(0xdb6dcf8afc357bf1) /* 37 */,
+ U64_C(0x18beea7a7a370f57) /* 38 */, U64_C(0x037117ca50b99066) /* 39 */,
+ U64_C(0x6ab30a9774424a35) /* 40 */, U64_C(0xf4e92f02e325249b) /* 41 */,
+ U64_C(0x7739db07061ccae1) /* 42 */, U64_C(0xd8f3b49ceca42a05) /* 43 */,
+ U64_C(0xbd56be3f51382f73) /* 44 */, U64_C(0x45faed5843b0bb28) /* 45 */,
+ U64_C(0x1c813d5c11bf1f83) /* 46 */, U64_C(0x8af0e4b6d75fa169) /* 47 */,
+ U64_C(0x33ee18a487ad9999) /* 48 */, U64_C(0x3c26e8eab1c94410) /* 49 */,
+ U64_C(0xb510102bc0a822f9) /* 50 */, U64_C(0x141eef310ce6123b) /* 51 */,
+ U64_C(0xfc65b90059ddb154) /* 52 */, U64_C(0xe0158640c5e0e607) /* 53 */,
+ U64_C(0x884e079826c3a3cf) /* 54 */, U64_C(0x930d0d9523c535fd) /* 55 */,
+ U64_C(0x35638d754e9a2b00) /* 56 */, U64_C(0x4085fccf40469dd5) /* 57 */,
+ U64_C(0xc4b17ad28be23a4c) /* 58 */, U64_C(0xcab2f0fc6a3e6a2e) /* 59 */,
+ U64_C(0x2860971a6b943fcd) /* 60 */, U64_C(0x3dde6ee212e30446) /* 61 */,
+ U64_C(0x6222f32ae01765ae) /* 62 */, U64_C(0x5d550bb5478308fe) /* 63 */,
+ U64_C(0xa9efa98da0eda22a) /* 64 */, U64_C(0xc351a71686c40da7) /* 65 */,
+ U64_C(0x1105586d9c867c84) /* 66 */, U64_C(0xdcffee85fda22853) /* 67 */,
+ U64_C(0xccfbd0262c5eef76) /* 68 */, U64_C(0xbaf294cb8990d201) /* 69 */,
+ U64_C(0xe69464f52afad975) /* 70 */, U64_C(0x94b013afdf133e14) /* 71 */,
+ U64_C(0x06a7d1a32823c958) /* 72 */, U64_C(0x6f95fe5130f61119) /* 73 */,
+ U64_C(0xd92ab34e462c06c0) /* 74 */, U64_C(0xed7bde33887c71d2) /* 75 */,
+ U64_C(0x79746d6e6518393e) /* 76 */, U64_C(0x5ba419385d713329) /* 77 */,
+ U64_C(0x7c1ba6b948a97564) /* 78 */, U64_C(0x31987c197bfdac67) /* 79 */,
+ U64_C(0xde6c23c44b053d02) /* 80 */, U64_C(0x581c49fed002d64d) /* 81 */,
+ U64_C(0xdd474d6338261571) /* 82 */, U64_C(0xaa4546c3e473d062) /* 83 */,
+ U64_C(0x928fce349455f860) /* 84 */, U64_C(0x48161bbacaab94d9) /* 85 */,
+ U64_C(0x63912430770e6f68) /* 86 */, U64_C(0x6ec8a5e602c6641c) /* 87 */,
+ U64_C(0x87282515337ddd2b) /* 88 */, U64_C(0x2cda6b42034b701b) /* 89 */,
+ U64_C(0xb03d37c181cb096d) /* 90 */, U64_C(0xe108438266c71c6f) /* 91 */,
+ U64_C(0x2b3180c7eb51b255) /* 92 */, U64_C(0xdf92b82f96c08bbc) /* 93 */,
+ U64_C(0x5c68c8c0a632f3ba) /* 94 */, U64_C(0x5504cc861c3d0556) /* 95 */,
+ U64_C(0xabbfa4e55fb26b8f) /* 96 */, U64_C(0x41848b0ab3baceb4) /* 97 */,
+ U64_C(0xb334a273aa445d32) /* 98 */, U64_C(0xbca696f0a85ad881) /* 99 */,
+ U64_C(0x24f6ec65b528d56c) /* 100 */, U64_C(0x0ce1512e90f4524a) /* 101 */,
+ U64_C(0x4e9dd79d5506d35a) /* 102 */, U64_C(0x258905fac6ce9779) /* 103 */,
+ U64_C(0x2019295b3e109b33) /* 104 */, U64_C(0xf8a9478b73a054cc) /* 105 */,
+ U64_C(0x2924f2f934417eb0) /* 106 */, U64_C(0x3993357d536d1bc4) /* 107 */,
+ U64_C(0x38a81ac21db6ff8b) /* 108 */, U64_C(0x47c4fbf17d6016bf) /* 109 */,
+ U64_C(0x1e0faadd7667e3f5) /* 110 */, U64_C(0x7abcff62938beb96) /* 111 */,
+ U64_C(0xa78dad948fc179c9) /* 112 */, U64_C(0x8f1f98b72911e50d) /* 113 */,
+ U64_C(0x61e48eae27121a91) /* 114 */, U64_C(0x4d62f7ad31859808) /* 115 */,
+ U64_C(0xeceba345ef5ceaeb) /* 116 */, U64_C(0xf5ceb25ebc9684ce) /* 117 */,
+ U64_C(0xf633e20cb7f76221) /* 118 */, U64_C(0xa32cdf06ab8293e4) /* 119 */,
+ U64_C(0x985a202ca5ee2ca4) /* 120 */, U64_C(0xcf0b8447cc8a8fb1) /* 121 */,
+ U64_C(0x9f765244979859a3) /* 122 */, U64_C(0xa8d516b1a1240017) /* 123 */,
+ U64_C(0x0bd7ba3ebb5dc726) /* 124 */, U64_C(0xe54bca55b86adb39) /* 125 */,
+ U64_C(0x1d7a3afd6c478063) /* 126 */, U64_C(0x519ec608e7669edd) /* 127 */,
+ U64_C(0x0e5715a2d149aa23) /* 128 */, U64_C(0x177d4571848ff194) /* 129 */,
+ U64_C(0xeeb55f3241014c22) /* 130 */, U64_C(0x0f5e5ca13a6e2ec2) /* 131 */,
+ U64_C(0x8029927b75f5c361) /* 132 */, U64_C(0xad139fabc3d6e436) /* 133 */,
+ U64_C(0x0d5df1a94ccf402f) /* 134 */, U64_C(0x3e8bd948bea5dfc8) /* 135 */,
+ U64_C(0xa5a0d357bd3ff77e) /* 136 */, U64_C(0xa2d12e251f74f645) /* 137 */,
+ U64_C(0x66fd9e525e81a082) /* 138 */, U64_C(0x2e0c90ce7f687a49) /* 139 */,
+ U64_C(0xc2e8bcbeba973bc5) /* 140 */, U64_C(0x000001bce509745f) /* 141 */,
+ U64_C(0x423777bbe6dab3d6) /* 142 */, U64_C(0xd1661c7eaef06eb5) /* 143 */,
+ U64_C(0xa1781f354daacfd8) /* 144 */, U64_C(0x2d11284a2b16affc) /* 145 */,
+ U64_C(0xf1fc4f67fa891d1f) /* 146 */, U64_C(0x73ecc25dcb920ada) /* 147 */,
+ U64_C(0xae610c22c2a12651) /* 148 */, U64_C(0x96e0a810d356b78a) /* 149 */,
+ U64_C(0x5a9a381f2fe7870f) /* 150 */, U64_C(0xd5ad62ede94e5530) /* 151 */,
+ U64_C(0xd225e5e8368d1427) /* 152 */, U64_C(0x65977b70c7af4631) /* 153 */,
+ U64_C(0x99f889b2de39d74f) /* 154 */, U64_C(0x233f30bf54e1d143) /* 155 */,
+ U64_C(0x9a9675d3d9a63c97) /* 156 */, U64_C(0x5470554ff334f9a8) /* 157 */,
+ U64_C(0x166acb744a4f5688) /* 158 */, U64_C(0x70c74caab2e4aead) /* 159 */,
+ U64_C(0xf0d091646f294d12) /* 160 */, U64_C(0x57b82a89684031d1) /* 161 */,
+ U64_C(0xefd95a5a61be0b6b) /* 162 */, U64_C(0x2fbd12e969f2f29a) /* 163 */,
+ U64_C(0x9bd37013feff9fe8) /* 164 */, U64_C(0x3f9b0404d6085a06) /* 165 */,
+ U64_C(0x4940c1f3166cfe15) /* 166 */, U64_C(0x09542c4dcdf3defb) /* 167 */,
+ U64_C(0xb4c5218385cd5ce3) /* 168 */, U64_C(0xc935b7dc4462a641) /* 169 */,
+ U64_C(0x3417f8a68ed3b63f) /* 170 */, U64_C(0xb80959295b215b40) /* 171 */,
+ U64_C(0xf99cdaef3b8c8572) /* 172 */, U64_C(0x018c0614f8fcb95d) /* 173 */,
+ U64_C(0x1b14accd1a3acdf3) /* 174 */, U64_C(0x84d471f200bb732d) /* 175 */,
+ U64_C(0xc1a3110e95e8da16) /* 176 */, U64_C(0x430a7220bf1a82b8) /* 177 */,
+ U64_C(0xb77e090d39df210e) /* 178 */, U64_C(0x5ef4bd9f3cd05e9d) /* 179 */,
+ U64_C(0x9d4ff6da7e57a444) /* 180 */, U64_C(0xda1d60e183d4a5f8) /* 181 */,
+ U64_C(0xb287c38417998e47) /* 182 */, U64_C(0xfe3edc121bb31886) /* 183 */,
+ U64_C(0xc7fe3ccc980ccbef) /* 184 */, U64_C(0xe46fb590189bfd03) /* 185 */,
+ U64_C(0x3732fd469a4c57dc) /* 186 */, U64_C(0x7ef700a07cf1ad65) /* 187 */,
+ U64_C(0x59c64468a31d8859) /* 188 */, U64_C(0x762fb0b4d45b61f6) /* 189 */,
+ U64_C(0x155baed099047718) /* 190 */, U64_C(0x68755e4c3d50baa6) /* 191 */,
+ U64_C(0xe9214e7f22d8b4df) /* 192 */, U64_C(0x2addbf532eac95f4) /* 193 */,
+ U64_C(0x32ae3909b4bd0109) /* 194 */, U64_C(0x834df537b08e3450) /* 195 */,
+ U64_C(0xfa209da84220728d) /* 196 */, U64_C(0x9e691d9b9efe23f7) /* 197 */,
+ U64_C(0x0446d288c4ae8d7f) /* 198 */, U64_C(0x7b4cc524e169785b) /* 199 */,
+ U64_C(0x21d87f0135ca1385) /* 200 */, U64_C(0xcebb400f137b8aa5) /* 201 */,
+ U64_C(0x272e2b66580796be) /* 202 */, U64_C(0x3612264125c2b0de) /* 203 */,
+ U64_C(0x057702bdad1efbb2) /* 204 */, U64_C(0xd4babb8eacf84be9) /* 205 */,
+ U64_C(0x91583139641bc67b) /* 206 */, U64_C(0x8bdc2de08036e024) /* 207 */,
+ U64_C(0x603c8156f49f68ed) /* 208 */, U64_C(0xf7d236f7dbef5111) /* 209 */,
+ U64_C(0x9727c4598ad21e80) /* 210 */, U64_C(0xa08a0896670a5fd7) /* 211 */,
+ U64_C(0xcb4a8f4309eba9cb) /* 212 */, U64_C(0x81af564b0f7036a1) /* 213 */,
+ U64_C(0xc0b99aa778199abd) /* 214 */, U64_C(0x959f1ec83fc8e952) /* 215 */,
+ U64_C(0x8c505077794a81b9) /* 216 */, U64_C(0x3acaaf8f056338f0) /* 217 */,
+ U64_C(0x07b43f50627a6778) /* 218 */, U64_C(0x4a44ab49f5eccc77) /* 219 */,
+ U64_C(0x3bc3d6e4b679ee98) /* 220 */, U64_C(0x9cc0d4d1cf14108c) /* 221 */,
+ U64_C(0x4406c00b206bc8a0) /* 222 */, U64_C(0x82a18854c8d72d89) /* 223 */,
+ U64_C(0x67e366b35c3c432c) /* 224 */, U64_C(0xb923dd61102b37f2) /* 225 */,
+ U64_C(0x56ab2779d884271d) /* 226 */, U64_C(0xbe83e1b0ff1525af) /* 227 */,
+ U64_C(0xfb7c65d4217e49a9) /* 228 */, U64_C(0x6bdbe0e76d48e7d4) /* 229 */,
+ U64_C(0x08df828745d9179e) /* 230 */, U64_C(0x22ea6a9add53bd34) /* 231 */,
+ U64_C(0xe36e141c5622200a) /* 232 */, U64_C(0x7f805d1b8cb750ee) /* 233 */,
+ U64_C(0xafe5c7a59f58e837) /* 234 */, U64_C(0xe27f996a4fb1c23c) /* 235 */,
+ U64_C(0xd3867dfb0775f0d0) /* 236 */, U64_C(0xd0e673de6e88891a) /* 237 */,
+ U64_C(0x123aeb9eafb86c25) /* 238 */, U64_C(0x30f1d5d5c145b895) /* 239 */,
+ U64_C(0xbb434a2dee7269e7) /* 240 */, U64_C(0x78cb67ecf931fa38) /* 241 */,
+ U64_C(0xf33b0372323bbf9c) /* 242 */, U64_C(0x52d66336fb279c74) /* 243 */,
+ U64_C(0x505f33ac0afb4eaa) /* 244 */, U64_C(0xe8a5cd99a2cce187) /* 245 */,
+ U64_C(0x534974801e2d30bb) /* 246 */, U64_C(0x8d2d5711d5876d90) /* 247 */,
+ U64_C(0x1f1a412891bc038e) /* 248 */, U64_C(0xd6e2e71d82e56648) /* 249 */,
+ U64_C(0x74036c3a497732b7) /* 250 */, U64_C(0x89b67ed96361f5ab) /* 251 */,
+ U64_C(0xffed95d8f1ea02a2) /* 252 */, U64_C(0xe72b3bd61464d43d) /* 253 */,
+ U64_C(0xa6300f170bdc4820) /* 254 */, U64_C(0xebc18760ed78a77a) /* 255 */
+};
+static u64 sbox2[256] = {
+ U64_C(0xe6a6be5a05a12138) /* 256 */, U64_C(0xb5a122a5b4f87c98) /* 257 */,
+ U64_C(0x563c6089140b6990) /* 258 */, U64_C(0x4c46cb2e391f5dd5) /* 259 */,
+ U64_C(0xd932addbc9b79434) /* 260 */, U64_C(0x08ea70e42015aff5) /* 261 */,
+ U64_C(0xd765a6673e478cf1) /* 262 */, U64_C(0xc4fb757eab278d99) /* 263 */,
+ U64_C(0xdf11c6862d6e0692) /* 264 */, U64_C(0xddeb84f10d7f3b16) /* 265 */,
+ U64_C(0x6f2ef604a665ea04) /* 266 */, U64_C(0x4a8e0f0ff0e0dfb3) /* 267 */,
+ U64_C(0xa5edeef83dbcba51) /* 268 */, U64_C(0xfc4f0a2a0ea4371e) /* 269 */,
+ U64_C(0xe83e1da85cb38429) /* 270 */, U64_C(0xdc8ff882ba1b1ce2) /* 271 */,
+ U64_C(0xcd45505e8353e80d) /* 272 */, U64_C(0x18d19a00d4db0717) /* 273 */,
+ U64_C(0x34a0cfeda5f38101) /* 274 */, U64_C(0x0be77e518887caf2) /* 275 */,
+ U64_C(0x1e341438b3c45136) /* 276 */, U64_C(0xe05797f49089ccf9) /* 277 */,
+ U64_C(0xffd23f9df2591d14) /* 278 */, U64_C(0x543dda228595c5cd) /* 279 */,
+ U64_C(0x661f81fd99052a33) /* 280 */, U64_C(0x8736e641db0f7b76) /* 281 */,
+ U64_C(0x15227725418e5307) /* 282 */, U64_C(0xe25f7f46162eb2fa) /* 283 */,
+ U64_C(0x48a8b2126c13d9fe) /* 284 */, U64_C(0xafdc541792e76eea) /* 285 */,
+ U64_C(0x03d912bfc6d1898f) /* 286 */, U64_C(0x31b1aafa1b83f51b) /* 287 */,
+ U64_C(0xf1ac2796e42ab7d9) /* 288 */, U64_C(0x40a3a7d7fcd2ebac) /* 289 */,
+ U64_C(0x1056136d0afbbcc5) /* 290 */, U64_C(0x7889e1dd9a6d0c85) /* 291 */,
+ U64_C(0xd33525782a7974aa) /* 292 */, U64_C(0xa7e25d09078ac09b) /* 293 */,
+ U64_C(0xbd4138b3eac6edd0) /* 294 */, U64_C(0x920abfbe71eb9e70) /* 295 */,
+ U64_C(0xa2a5d0f54fc2625c) /* 296 */, U64_C(0xc054e36b0b1290a3) /* 297 */,
+ U64_C(0xf6dd59ff62fe932b) /* 298 */, U64_C(0x3537354511a8ac7d) /* 299 */,
+ U64_C(0xca845e9172fadcd4) /* 300 */, U64_C(0x84f82b60329d20dc) /* 301 */,
+ U64_C(0x79c62ce1cd672f18) /* 302 */, U64_C(0x8b09a2add124642c) /* 303 */,
+ U64_C(0xd0c1e96a19d9e726) /* 304 */, U64_C(0x5a786a9b4ba9500c) /* 305 */,
+ U64_C(0x0e020336634c43f3) /* 306 */, U64_C(0xc17b474aeb66d822) /* 307 */,
+ U64_C(0x6a731ae3ec9baac2) /* 308 */, U64_C(0x8226667ae0840258) /* 309 */,
+ U64_C(0x67d4567691caeca5) /* 310 */, U64_C(0x1d94155c4875adb5) /* 311 */,
+ U64_C(0x6d00fd985b813fdf) /* 312 */, U64_C(0x51286efcb774cd06) /* 313 */,
+ U64_C(0x5e8834471fa744af) /* 314 */, U64_C(0xf72ca0aee761ae2e) /* 315 */,
+ U64_C(0xbe40e4cdaee8e09a) /* 316 */, U64_C(0xe9970bbb5118f665) /* 317 */,
+ U64_C(0x726e4beb33df1964) /* 318 */, U64_C(0x703b000729199762) /* 319 */,
+ U64_C(0x4631d816f5ef30a7) /* 320 */, U64_C(0xb880b5b51504a6be) /* 321 */,
+ U64_C(0x641793c37ed84b6c) /* 322 */, U64_C(0x7b21ed77f6e97d96) /* 323 */,
+ U64_C(0x776306312ef96b73) /* 324 */, U64_C(0xae528948e86ff3f4) /* 325 */,
+ U64_C(0x53dbd7f286a3f8f8) /* 326 */, U64_C(0x16cadce74cfc1063) /* 327 */,
+ U64_C(0x005c19bdfa52c6dd) /* 328 */, U64_C(0x68868f5d64d46ad3) /* 329 */,
+ U64_C(0x3a9d512ccf1e186a) /* 330 */, U64_C(0x367e62c2385660ae) /* 331 */,
+ U64_C(0xe359e7ea77dcb1d7) /* 332 */, U64_C(0x526c0773749abe6e) /* 333 */,
+ U64_C(0x735ae5f9d09f734b) /* 334 */, U64_C(0x493fc7cc8a558ba8) /* 335 */,
+ U64_C(0xb0b9c1533041ab45) /* 336 */, U64_C(0x321958ba470a59bd) /* 337 */,
+ U64_C(0x852db00b5f46c393) /* 338 */, U64_C(0x91209b2bd336b0e5) /* 339 */,
+ U64_C(0x6e604f7d659ef19f) /* 340 */, U64_C(0xb99a8ae2782ccb24) /* 341 */,
+ U64_C(0xccf52ab6c814c4c7) /* 342 */, U64_C(0x4727d9afbe11727b) /* 343 */,
+ U64_C(0x7e950d0c0121b34d) /* 344 */, U64_C(0x756f435670ad471f) /* 345 */,
+ U64_C(0xf5add442615a6849) /* 346 */, U64_C(0x4e87e09980b9957a) /* 347 */,
+ U64_C(0x2acfa1df50aee355) /* 348 */, U64_C(0xd898263afd2fd556) /* 349 */,
+ U64_C(0xc8f4924dd80c8fd6) /* 350 */, U64_C(0xcf99ca3d754a173a) /* 351 */,
+ U64_C(0xfe477bacaf91bf3c) /* 352 */, U64_C(0xed5371f6d690c12d) /* 353 */,
+ U64_C(0x831a5c285e687094) /* 354 */, U64_C(0xc5d3c90a3708a0a4) /* 355 */,
+ U64_C(0x0f7f903717d06580) /* 356 */, U64_C(0x19f9bb13b8fdf27f) /* 357 */,
+ U64_C(0xb1bd6f1b4d502843) /* 358 */, U64_C(0x1c761ba38fff4012) /* 359 */,
+ U64_C(0x0d1530c4e2e21f3b) /* 360 */, U64_C(0x8943ce69a7372c8a) /* 361 */,
+ U64_C(0xe5184e11feb5ce66) /* 362 */, U64_C(0x618bdb80bd736621) /* 363 */,
+ U64_C(0x7d29bad68b574d0b) /* 364 */, U64_C(0x81bb613e25e6fe5b) /* 365 */,
+ U64_C(0x071c9c10bc07913f) /* 366 */, U64_C(0xc7beeb7909ac2d97) /* 367 */,
+ U64_C(0xc3e58d353bc5d757) /* 368 */, U64_C(0xeb017892f38f61e8) /* 369 */,
+ U64_C(0xd4effb9c9b1cc21a) /* 370 */, U64_C(0x99727d26f494f7ab) /* 371 */,
+ U64_C(0xa3e063a2956b3e03) /* 372 */, U64_C(0x9d4a8b9a4aa09c30) /* 373 */,
+ U64_C(0x3f6ab7d500090fb4) /* 374 */, U64_C(0x9cc0f2a057268ac0) /* 375 */,
+ U64_C(0x3dee9d2dedbf42d1) /* 376 */, U64_C(0x330f49c87960a972) /* 377 */,
+ U64_C(0xc6b2720287421b41) /* 378 */, U64_C(0x0ac59ec07c00369c) /* 379 */,
+ U64_C(0xef4eac49cb353425) /* 380 */, U64_C(0xf450244eef0129d8) /* 381 */,
+ U64_C(0x8acc46e5caf4deb6) /* 382 */, U64_C(0x2ffeab63989263f7) /* 383 */,
+ U64_C(0x8f7cb9fe5d7a4578) /* 384 */, U64_C(0x5bd8f7644e634635) /* 385 */,
+ U64_C(0x427a7315bf2dc900) /* 386 */, U64_C(0x17d0c4aa2125261c) /* 387 */,
+ U64_C(0x3992486c93518e50) /* 388 */, U64_C(0xb4cbfee0a2d7d4c3) /* 389 */,
+ U64_C(0x7c75d6202c5ddd8d) /* 390 */, U64_C(0xdbc295d8e35b6c61) /* 391 */,
+ U64_C(0x60b369d302032b19) /* 392 */, U64_C(0xce42685fdce44132) /* 393 */,
+ U64_C(0x06f3ddb9ddf65610) /* 394 */, U64_C(0x8ea4d21db5e148f0) /* 395 */,
+ U64_C(0x20b0fce62fcd496f) /* 396 */, U64_C(0x2c1b912358b0ee31) /* 397 */,
+ U64_C(0xb28317b818f5a308) /* 398 */, U64_C(0xa89c1e189ca6d2cf) /* 399 */,
+ U64_C(0x0c6b18576aaadbc8) /* 400 */, U64_C(0xb65deaa91299fae3) /* 401 */,
+ U64_C(0xfb2b794b7f1027e7) /* 402 */, U64_C(0x04e4317f443b5beb) /* 403 */,
+ U64_C(0x4b852d325939d0a6) /* 404 */, U64_C(0xd5ae6beefb207ffc) /* 405 */,
+ U64_C(0x309682b281c7d374) /* 406 */, U64_C(0xbae309a194c3b475) /* 407 */,
+ U64_C(0x8cc3f97b13b49f05) /* 408 */, U64_C(0x98a9422ff8293967) /* 409 */,
+ U64_C(0x244b16b01076ff7c) /* 410 */, U64_C(0xf8bf571c663d67ee) /* 411 */,
+ U64_C(0x1f0d6758eee30da1) /* 412 */, U64_C(0xc9b611d97adeb9b7) /* 413 */,
+ U64_C(0xb7afd5887b6c57a2) /* 414 */, U64_C(0x6290ae846b984fe1) /* 415 */,
+ U64_C(0x94df4cdeacc1a5fd) /* 416 */, U64_C(0x058a5bd1c5483aff) /* 417 */,
+ U64_C(0x63166cc142ba3c37) /* 418 */, U64_C(0x8db8526eb2f76f40) /* 419 */,
+ U64_C(0xe10880036f0d6d4e) /* 420 */, U64_C(0x9e0523c9971d311d) /* 421 */,
+ U64_C(0x45ec2824cc7cd691) /* 422 */, U64_C(0x575b8359e62382c9) /* 423 */,
+ U64_C(0xfa9e400dc4889995) /* 424 */, U64_C(0xd1823ecb45721568) /* 425 */,
+ U64_C(0xdafd983b8206082f) /* 426 */, U64_C(0xaa7d29082386a8cb) /* 427 */,
+ U64_C(0x269fcd4403b87588) /* 428 */, U64_C(0x1b91f5f728bdd1e0) /* 429 */,
+ U64_C(0xe4669f39040201f6) /* 430 */, U64_C(0x7a1d7c218cf04ade) /* 431 */,
+ U64_C(0x65623c29d79ce5ce) /* 432 */, U64_C(0x2368449096c00bb1) /* 433 */,
+ U64_C(0xab9bf1879da503ba) /* 434 */, U64_C(0xbc23ecb1a458058e) /* 435 */,
+ U64_C(0x9a58df01bb401ecc) /* 436 */, U64_C(0xa070e868a85f143d) /* 437 */,
+ U64_C(0x4ff188307df2239e) /* 438 */, U64_C(0x14d565b41a641183) /* 439 */,
+ U64_C(0xee13337452701602) /* 440 */, U64_C(0x950e3dcf3f285e09) /* 441 */,
+ U64_C(0x59930254b9c80953) /* 442 */, U64_C(0x3bf299408930da6d) /* 443 */,
+ U64_C(0xa955943f53691387) /* 444 */, U64_C(0xa15edecaa9cb8784) /* 445 */,
+ U64_C(0x29142127352be9a0) /* 446 */, U64_C(0x76f0371fff4e7afb) /* 447 */,
+ U64_C(0x0239f450274f2228) /* 448 */, U64_C(0xbb073af01d5e868b) /* 449 */,
+ U64_C(0xbfc80571c10e96c1) /* 450 */, U64_C(0xd267088568222e23) /* 451 */,
+ U64_C(0x9671a3d48e80b5b0) /* 452 */, U64_C(0x55b5d38ae193bb81) /* 453 */,
+ U64_C(0x693ae2d0a18b04b8) /* 454 */, U64_C(0x5c48b4ecadd5335f) /* 455 */,
+ U64_C(0xfd743b194916a1ca) /* 456 */, U64_C(0x2577018134be98c4) /* 457 */,
+ U64_C(0xe77987e83c54a4ad) /* 458 */, U64_C(0x28e11014da33e1b9) /* 459 */,
+ U64_C(0x270cc59e226aa213) /* 460 */, U64_C(0x71495f756d1a5f60) /* 461 */,
+ U64_C(0x9be853fb60afef77) /* 462 */, U64_C(0xadc786a7f7443dbf) /* 463 */,
+ U64_C(0x0904456173b29a82) /* 464 */, U64_C(0x58bc7a66c232bd5e) /* 465 */,
+ U64_C(0xf306558c673ac8b2) /* 466 */, U64_C(0x41f639c6b6c9772a) /* 467 */,
+ U64_C(0x216defe99fda35da) /* 468 */, U64_C(0x11640cc71c7be615) /* 469 */,
+ U64_C(0x93c43694565c5527) /* 470 */, U64_C(0xea038e6246777839) /* 471 */,
+ U64_C(0xf9abf3ce5a3e2469) /* 472 */, U64_C(0x741e768d0fd312d2) /* 473 */,
+ U64_C(0x0144b883ced652c6) /* 474 */, U64_C(0xc20b5a5ba33f8552) /* 475 */,
+ U64_C(0x1ae69633c3435a9d) /* 476 */, U64_C(0x97a28ca4088cfdec) /* 477 */,
+ U64_C(0x8824a43c1e96f420) /* 478 */, U64_C(0x37612fa66eeea746) /* 479 */,
+ U64_C(0x6b4cb165f9cf0e5a) /* 480 */, U64_C(0x43aa1c06a0abfb4a) /* 481 */,
+ U64_C(0x7f4dc26ff162796b) /* 482 */, U64_C(0x6cbacc8e54ed9b0f) /* 483 */,
+ U64_C(0xa6b7ffefd2bb253e) /* 484 */, U64_C(0x2e25bc95b0a29d4f) /* 485 */,
+ U64_C(0x86d6a58bdef1388c) /* 486 */, U64_C(0xded74ac576b6f054) /* 487 */,
+ U64_C(0x8030bdbc2b45805d) /* 488 */, U64_C(0x3c81af70e94d9289) /* 489 */,
+ U64_C(0x3eff6dda9e3100db) /* 490 */, U64_C(0xb38dc39fdfcc8847) /* 491 */,
+ U64_C(0x123885528d17b87e) /* 492 */, U64_C(0xf2da0ed240b1b642) /* 493 */,
+ U64_C(0x44cefadcd54bf9a9) /* 494 */, U64_C(0x1312200e433c7ee6) /* 495 */,
+ U64_C(0x9ffcc84f3a78c748) /* 496 */, U64_C(0xf0cd1f72248576bb) /* 497 */,
+ U64_C(0xec6974053638cfe4) /* 498 */, U64_C(0x2ba7b67c0cec4e4c) /* 499 */,
+ U64_C(0xac2f4df3e5ce32ed) /* 500 */, U64_C(0xcb33d14326ea4c11) /* 501 */,
+ U64_C(0xa4e9044cc77e58bc) /* 502 */, U64_C(0x5f513293d934fcef) /* 503 */,
+ U64_C(0x5dc9645506e55444) /* 504 */, U64_C(0x50de418f317de40a) /* 505 */,
+ U64_C(0x388cb31a69dde259) /* 506 */, U64_C(0x2db4a83455820a86) /* 507 */,
+ U64_C(0x9010a91e84711ae9) /* 508 */, U64_C(0x4df7f0b7b1498371) /* 509 */,
+ U64_C(0xd62a2eabc0977179) /* 510 */, U64_C(0x22fac097aa8d5c0e) /* 511 */
+};
+static u64 sbox3[256] = {
+ U64_C(0xf49fcc2ff1daf39b) /* 512 */, U64_C(0x487fd5c66ff29281) /* 513 */,
+ U64_C(0xe8a30667fcdca83f) /* 514 */, U64_C(0x2c9b4be3d2fcce63) /* 515 */,
+ U64_C(0xda3ff74b93fbbbc2) /* 516 */, U64_C(0x2fa165d2fe70ba66) /* 517 */,
+ U64_C(0xa103e279970e93d4) /* 518 */, U64_C(0xbecdec77b0e45e71) /* 519 */,
+ U64_C(0xcfb41e723985e497) /* 520 */, U64_C(0xb70aaa025ef75017) /* 521 */,
+ U64_C(0xd42309f03840b8e0) /* 522 */, U64_C(0x8efc1ad035898579) /* 523 */,
+ U64_C(0x96c6920be2b2abc5) /* 524 */, U64_C(0x66af4163375a9172) /* 525 */,
+ U64_C(0x2174abdcca7127fb) /* 526 */, U64_C(0xb33ccea64a72ff41) /* 527 */,
+ U64_C(0xf04a4933083066a5) /* 528 */, U64_C(0x8d970acdd7289af5) /* 529 */,
+ U64_C(0x8f96e8e031c8c25e) /* 530 */, U64_C(0xf3fec02276875d47) /* 531 */,
+ U64_C(0xec7bf310056190dd) /* 532 */, U64_C(0xf5adb0aebb0f1491) /* 533 */,
+ U64_C(0x9b50f8850fd58892) /* 534 */, U64_C(0x4975488358b74de8) /* 535 */,
+ U64_C(0xa3354ff691531c61) /* 536 */, U64_C(0x0702bbe481d2c6ee) /* 537 */,
+ U64_C(0x89fb24057deded98) /* 538 */, U64_C(0xac3075138596e902) /* 539 */,
+ U64_C(0x1d2d3580172772ed) /* 540 */, U64_C(0xeb738fc28e6bc30d) /* 541 */,
+ U64_C(0x5854ef8f63044326) /* 542 */, U64_C(0x9e5c52325add3bbe) /* 543 */,
+ U64_C(0x90aa53cf325c4623) /* 544 */, U64_C(0xc1d24d51349dd067) /* 545 */,
+ U64_C(0x2051cfeea69ea624) /* 546 */, U64_C(0x13220f0a862e7e4f) /* 547 */,
+ U64_C(0xce39399404e04864) /* 548 */, U64_C(0xd9c42ca47086fcb7) /* 549 */,
+ U64_C(0x685ad2238a03e7cc) /* 550 */, U64_C(0x066484b2ab2ff1db) /* 551 */,
+ U64_C(0xfe9d5d70efbf79ec) /* 552 */, U64_C(0x5b13b9dd9c481854) /* 553 */,
+ U64_C(0x15f0d475ed1509ad) /* 554 */, U64_C(0x0bebcd060ec79851) /* 555 */,
+ U64_C(0xd58c6791183ab7f8) /* 556 */, U64_C(0xd1187c5052f3eee4) /* 557 */,
+ U64_C(0xc95d1192e54e82ff) /* 558 */, U64_C(0x86eea14cb9ac6ca2) /* 559 */,
+ U64_C(0x3485beb153677d5d) /* 560 */, U64_C(0xdd191d781f8c492a) /* 561 */,
+ U64_C(0xf60866baa784ebf9) /* 562 */, U64_C(0x518f643ba2d08c74) /* 563 */,
+ U64_C(0x8852e956e1087c22) /* 564 */, U64_C(0xa768cb8dc410ae8d) /* 565 */,
+ U64_C(0x38047726bfec8e1a) /* 566 */, U64_C(0xa67738b4cd3b45aa) /* 567 */,
+ U64_C(0xad16691cec0dde19) /* 568 */, U64_C(0xc6d4319380462e07) /* 569 */,
+ U64_C(0xc5a5876d0ba61938) /* 570 */, U64_C(0x16b9fa1fa58fd840) /* 571 */,
+ U64_C(0x188ab1173ca74f18) /* 572 */, U64_C(0xabda2f98c99c021f) /* 573 */,
+ U64_C(0x3e0580ab134ae816) /* 574 */, U64_C(0x5f3b05b773645abb) /* 575 */,
+ U64_C(0x2501a2be5575f2f6) /* 576 */, U64_C(0x1b2f74004e7e8ba9) /* 577 */,
+ U64_C(0x1cd7580371e8d953) /* 578 */, U64_C(0x7f6ed89562764e30) /* 579 */,
+ U64_C(0xb15926ff596f003d) /* 580 */, U64_C(0x9f65293da8c5d6b9) /* 581 */,
+ U64_C(0x6ecef04dd690f84c) /* 582 */, U64_C(0x4782275fff33af88) /* 583 */,
+ U64_C(0xe41433083f820801) /* 584 */, U64_C(0xfd0dfe409a1af9b5) /* 585 */,
+ U64_C(0x4325a3342cdb396b) /* 586 */, U64_C(0x8ae77e62b301b252) /* 587 */,
+ U64_C(0xc36f9e9f6655615a) /* 588 */, U64_C(0x85455a2d92d32c09) /* 589 */,
+ U64_C(0xf2c7dea949477485) /* 590 */, U64_C(0x63cfb4c133a39eba) /* 591 */,
+ U64_C(0x83b040cc6ebc5462) /* 592 */, U64_C(0x3b9454c8fdb326b0) /* 593 */,
+ U64_C(0x56f56a9e87ffd78c) /* 594 */, U64_C(0x2dc2940d99f42bc6) /* 595 */,
+ U64_C(0x98f7df096b096e2d) /* 596 */, U64_C(0x19a6e01e3ad852bf) /* 597 */,
+ U64_C(0x42a99ccbdbd4b40b) /* 598 */, U64_C(0xa59998af45e9c559) /* 599 */,
+ U64_C(0x366295e807d93186) /* 600 */, U64_C(0x6b48181bfaa1f773) /* 601 */,
+ U64_C(0x1fec57e2157a0a1d) /* 602 */, U64_C(0x4667446af6201ad5) /* 603 */,
+ U64_C(0xe615ebcacfb0f075) /* 604 */, U64_C(0xb8f31f4f68290778) /* 605 */,
+ U64_C(0x22713ed6ce22d11e) /* 606 */, U64_C(0x3057c1a72ec3c93b) /* 607 */,
+ U64_C(0xcb46acc37c3f1f2f) /* 608 */, U64_C(0xdbb893fd02aaf50e) /* 609 */,
+ U64_C(0x331fd92e600b9fcf) /* 610 */, U64_C(0xa498f96148ea3ad6) /* 611 */,
+ U64_C(0xa8d8426e8b6a83ea) /* 612 */, U64_C(0xa089b274b7735cdc) /* 613 */,
+ U64_C(0x87f6b3731e524a11) /* 614 */, U64_C(0x118808e5cbc96749) /* 615 */,
+ U64_C(0x9906e4c7b19bd394) /* 616 */, U64_C(0xafed7f7e9b24a20c) /* 617 */,
+ U64_C(0x6509eadeeb3644a7) /* 618 */, U64_C(0x6c1ef1d3e8ef0ede) /* 619 */,
+ U64_C(0xb9c97d43e9798fb4) /* 620 */, U64_C(0xa2f2d784740c28a3) /* 621 */,
+ U64_C(0x7b8496476197566f) /* 622 */, U64_C(0x7a5be3e6b65f069d) /* 623 */,
+ U64_C(0xf96330ed78be6f10) /* 624 */, U64_C(0xeee60de77a076a15) /* 625 */,
+ U64_C(0x2b4bee4aa08b9bd0) /* 626 */, U64_C(0x6a56a63ec7b8894e) /* 627 */,
+ U64_C(0x02121359ba34fef4) /* 628 */, U64_C(0x4cbf99f8283703fc) /* 629 */,
+ U64_C(0x398071350caf30c8) /* 630 */, U64_C(0xd0a77a89f017687a) /* 631 */,
+ U64_C(0xf1c1a9eb9e423569) /* 632 */, U64_C(0x8c7976282dee8199) /* 633 */,
+ U64_C(0x5d1737a5dd1f7abd) /* 634 */, U64_C(0x4f53433c09a9fa80) /* 635 */,
+ U64_C(0xfa8b0c53df7ca1d9) /* 636 */, U64_C(0x3fd9dcbc886ccb77) /* 637 */,
+ U64_C(0xc040917ca91b4720) /* 638 */, U64_C(0x7dd00142f9d1dcdf) /* 639 */,
+ U64_C(0x8476fc1d4f387b58) /* 640 */, U64_C(0x23f8e7c5f3316503) /* 641 */,
+ U64_C(0x032a2244e7e37339) /* 642 */, U64_C(0x5c87a5d750f5a74b) /* 643 */,
+ U64_C(0x082b4cc43698992e) /* 644 */, U64_C(0xdf917becb858f63c) /* 645 */,
+ U64_C(0x3270b8fc5bf86dda) /* 646 */, U64_C(0x10ae72bb29b5dd76) /* 647 */,
+ U64_C(0x576ac94e7700362b) /* 648 */, U64_C(0x1ad112dac61efb8f) /* 649 */,
+ U64_C(0x691bc30ec5faa427) /* 650 */, U64_C(0xff246311cc327143) /* 651 */,
+ U64_C(0x3142368e30e53206) /* 652 */, U64_C(0x71380e31e02ca396) /* 653 */,
+ U64_C(0x958d5c960aad76f1) /* 654 */, U64_C(0xf8d6f430c16da536) /* 655 */,
+ U64_C(0xc8ffd13f1be7e1d2) /* 656 */, U64_C(0x7578ae66004ddbe1) /* 657 */,
+ U64_C(0x05833f01067be646) /* 658 */, U64_C(0xbb34b5ad3bfe586d) /* 659 */,
+ U64_C(0x095f34c9a12b97f0) /* 660 */, U64_C(0x247ab64525d60ca8) /* 661 */,
+ U64_C(0xdcdbc6f3017477d1) /* 662 */, U64_C(0x4a2e14d4decad24d) /* 663 */,
+ U64_C(0xbdb5e6d9be0a1eeb) /* 664 */, U64_C(0x2a7e70f7794301ab) /* 665 */,
+ U64_C(0xdef42d8a270540fd) /* 666 */, U64_C(0x01078ec0a34c22c1) /* 667 */,
+ U64_C(0xe5de511af4c16387) /* 668 */, U64_C(0x7ebb3a52bd9a330a) /* 669 */,
+ U64_C(0x77697857aa7d6435) /* 670 */, U64_C(0x004e831603ae4c32) /* 671 */,
+ U64_C(0xe7a21020ad78e312) /* 672 */, U64_C(0x9d41a70c6ab420f2) /* 673 */,
+ U64_C(0x28e06c18ea1141e6) /* 674 */, U64_C(0xd2b28cbd984f6b28) /* 675 */,
+ U64_C(0x26b75f6c446e9d83) /* 676 */, U64_C(0xba47568c4d418d7f) /* 677 */,
+ U64_C(0xd80badbfe6183d8e) /* 678 */, U64_C(0x0e206d7f5f166044) /* 679 */,
+ U64_C(0xe258a43911cbca3e) /* 680 */, U64_C(0x723a1746b21dc0bc) /* 681 */,
+ U64_C(0xc7caa854f5d7cdd3) /* 682 */, U64_C(0x7cac32883d261d9c) /* 683 */,
+ U64_C(0x7690c26423ba942c) /* 684 */, U64_C(0x17e55524478042b8) /* 685 */,
+ U64_C(0xe0be477656a2389f) /* 686 */, U64_C(0x4d289b5e67ab2da0) /* 687 */,
+ U64_C(0x44862b9c8fbbfd31) /* 688 */, U64_C(0xb47cc8049d141365) /* 689 */,
+ U64_C(0x822c1b362b91c793) /* 690 */, U64_C(0x4eb14655fb13dfd8) /* 691 */,
+ U64_C(0x1ecbba0714e2a97b) /* 692 */, U64_C(0x6143459d5cde5f14) /* 693 */,
+ U64_C(0x53a8fbf1d5f0ac89) /* 694 */, U64_C(0x97ea04d81c5e5b00) /* 695 */,
+ U64_C(0x622181a8d4fdb3f3) /* 696 */, U64_C(0xe9bcd341572a1208) /* 697 */,
+ U64_C(0x1411258643cce58a) /* 698 */, U64_C(0x9144c5fea4c6e0a4) /* 699 */,
+ U64_C(0x0d33d06565cf620f) /* 700 */, U64_C(0x54a48d489f219ca1) /* 701 */,
+ U64_C(0xc43e5eac6d63c821) /* 702 */, U64_C(0xa9728b3a72770daf) /* 703 */,
+ U64_C(0xd7934e7b20df87ef) /* 704 */, U64_C(0xe35503b61a3e86e5) /* 705 */,
+ U64_C(0xcae321fbc819d504) /* 706 */, U64_C(0x129a50b3ac60bfa6) /* 707 */,
+ U64_C(0xcd5e68ea7e9fb6c3) /* 708 */, U64_C(0xb01c90199483b1c7) /* 709 */,
+ U64_C(0x3de93cd5c295376c) /* 710 */, U64_C(0xaed52edf2ab9ad13) /* 711 */,
+ U64_C(0x2e60f512c0a07884) /* 712 */, U64_C(0xbc3d86a3e36210c9) /* 713 */,
+ U64_C(0x35269d9b163951ce) /* 714 */, U64_C(0x0c7d6e2ad0cdb5fa) /* 715 */,
+ U64_C(0x59e86297d87f5733) /* 716 */, U64_C(0x298ef221898db0e7) /* 717 */,
+ U64_C(0x55000029d1a5aa7e) /* 718 */, U64_C(0x8bc08ae1b5061b45) /* 719 */,
+ U64_C(0xc2c31c2b6c92703a) /* 720 */, U64_C(0x94cc596baf25ef42) /* 721 */,
+ U64_C(0x0a1d73db22540456) /* 722 */, U64_C(0x04b6a0f9d9c4179a) /* 723 */,
+ U64_C(0xeffdafa2ae3d3c60) /* 724 */, U64_C(0xf7c8075bb49496c4) /* 725 */,
+ U64_C(0x9cc5c7141d1cd4e3) /* 726 */, U64_C(0x78bd1638218e5534) /* 727 */,
+ U64_C(0xb2f11568f850246a) /* 728 */, U64_C(0xedfabcfa9502bc29) /* 729 */,
+ U64_C(0x796ce5f2da23051b) /* 730 */, U64_C(0xaae128b0dc93537c) /* 731 */,
+ U64_C(0x3a493da0ee4b29ae) /* 732 */, U64_C(0xb5df6b2c416895d7) /* 733 */,
+ U64_C(0xfcabbd25122d7f37) /* 734 */, U64_C(0x70810b58105dc4b1) /* 735 */,
+ U64_C(0xe10fdd37f7882a90) /* 736 */, U64_C(0x524dcab5518a3f5c) /* 737 */,
+ U64_C(0x3c9e85878451255b) /* 738 */, U64_C(0x4029828119bd34e2) /* 739 */,
+ U64_C(0x74a05b6f5d3ceccb) /* 740 */, U64_C(0xb610021542e13eca) /* 741 */,
+ U64_C(0x0ff979d12f59e2ac) /* 742 */, U64_C(0x6037da27e4f9cc50) /* 743 */,
+ U64_C(0x5e92975a0df1847d) /* 744 */, U64_C(0xd66de190d3e623fe) /* 745 */,
+ U64_C(0x5032d6b87b568048) /* 746 */, U64_C(0x9a36b7ce8235216e) /* 747 */,
+ U64_C(0x80272a7a24f64b4a) /* 748 */, U64_C(0x93efed8b8c6916f7) /* 749 */,
+ U64_C(0x37ddbff44cce1555) /* 750 */, U64_C(0x4b95db5d4b99bd25) /* 751 */,
+ U64_C(0x92d3fda169812fc0) /* 752 */, U64_C(0xfb1a4a9a90660bb6) /* 753 */,
+ U64_C(0x730c196946a4b9b2) /* 754 */, U64_C(0x81e289aa7f49da68) /* 755 */,
+ U64_C(0x64669a0f83b1a05f) /* 756 */, U64_C(0x27b3ff7d9644f48b) /* 757 */,
+ U64_C(0xcc6b615c8db675b3) /* 758 */, U64_C(0x674f20b9bcebbe95) /* 759 */,
+ U64_C(0x6f31238275655982) /* 760 */, U64_C(0x5ae488713e45cf05) /* 761 */,
+ U64_C(0xbf619f9954c21157) /* 762 */, U64_C(0xeabac46040a8eae9) /* 763 */,
+ U64_C(0x454c6fe9f2c0c1cd) /* 764 */, U64_C(0x419cf6496412691c) /* 765 */,
+ U64_C(0xd3dc3bef265b0f70) /* 766 */, U64_C(0x6d0e60f5c3578a9e) /* 767 */
+};
+static u64 sbox4[256] = {
+ U64_C(0x5b0e608526323c55) /* 768 */, U64_C(0x1a46c1a9fa1b59f5) /* 769 */,
+ U64_C(0xa9e245a17c4c8ffa) /* 770 */, U64_C(0x65ca5159db2955d7) /* 771 */,
+ U64_C(0x05db0a76ce35afc2) /* 772 */, U64_C(0x81eac77ea9113d45) /* 773 */,
+ U64_C(0x528ef88ab6ac0a0d) /* 774 */, U64_C(0xa09ea253597be3ff) /* 775 */,
+ U64_C(0x430ddfb3ac48cd56) /* 776 */, U64_C(0xc4b3a67af45ce46f) /* 777 */,
+ U64_C(0x4ececfd8fbe2d05e) /* 778 */, U64_C(0x3ef56f10b39935f0) /* 779 */,
+ U64_C(0x0b22d6829cd619c6) /* 780 */, U64_C(0x17fd460a74df2069) /* 781 */,
+ U64_C(0x6cf8cc8e8510ed40) /* 782 */, U64_C(0xd6c824bf3a6ecaa7) /* 783 */,
+ U64_C(0x61243d581a817049) /* 784 */, U64_C(0x048bacb6bbc163a2) /* 785 */,
+ U64_C(0xd9a38ac27d44cc32) /* 786 */, U64_C(0x7fddff5baaf410ab) /* 787 */,
+ U64_C(0xad6d495aa804824b) /* 788 */, U64_C(0xe1a6a74f2d8c9f94) /* 789 */,
+ U64_C(0xd4f7851235dee8e3) /* 790 */, U64_C(0xfd4b7f886540d893) /* 791 */,
+ U64_C(0x247c20042aa4bfda) /* 792 */, U64_C(0x096ea1c517d1327c) /* 793 */,
+ U64_C(0xd56966b4361a6685) /* 794 */, U64_C(0x277da5c31221057d) /* 795 */,
+ U64_C(0x94d59893a43acff7) /* 796 */, U64_C(0x64f0c51ccdc02281) /* 797 */,
+ U64_C(0x3d33bcc4ff6189db) /* 798 */, U64_C(0xe005cb184ce66af1) /* 799 */,
+ U64_C(0xff5ccd1d1db99bea) /* 800 */, U64_C(0xb0b854a7fe42980f) /* 801 */,
+ U64_C(0x7bd46a6a718d4b9f) /* 802 */, U64_C(0xd10fa8cc22a5fd8c) /* 803 */,
+ U64_C(0xd31484952be4bd31) /* 804 */, U64_C(0xc7fa975fcb243847) /* 805 */,
+ U64_C(0x4886ed1e5846c407) /* 806 */, U64_C(0x28cddb791eb70b04) /* 807 */,
+ U64_C(0xc2b00be2f573417f) /* 808 */, U64_C(0x5c9590452180f877) /* 809 */,
+ U64_C(0x7a6bddfff370eb00) /* 810 */, U64_C(0xce509e38d6d9d6a4) /* 811 */,
+ U64_C(0xebeb0f00647fa702) /* 812 */, U64_C(0x1dcc06cf76606f06) /* 813 */,
+ U64_C(0xe4d9f28ba286ff0a) /* 814 */, U64_C(0xd85a305dc918c262) /* 815 */,
+ U64_C(0x475b1d8732225f54) /* 816 */, U64_C(0x2d4fb51668ccb5fe) /* 817 */,
+ U64_C(0xa679b9d9d72bba20) /* 818 */, U64_C(0x53841c0d912d43a5) /* 819 */,
+ U64_C(0x3b7eaa48bf12a4e8) /* 820 */, U64_C(0x781e0e47f22f1ddf) /* 821 */,
+ U64_C(0xeff20ce60ab50973) /* 822 */, U64_C(0x20d261d19dffb742) /* 823 */,
+ U64_C(0x16a12b03062a2e39) /* 824 */, U64_C(0x1960eb2239650495) /* 825 */,
+ U64_C(0x251c16fed50eb8b8) /* 826 */, U64_C(0x9ac0c330f826016e) /* 827 */,
+ U64_C(0xed152665953e7671) /* 828 */, U64_C(0x02d63194a6369570) /* 829 */,
+ U64_C(0x5074f08394b1c987) /* 830 */, U64_C(0x70ba598c90b25ce1) /* 831 */,
+ U64_C(0x794a15810b9742f6) /* 832 */, U64_C(0x0d5925e9fcaf8c6c) /* 833 */,
+ U64_C(0x3067716cd868744e) /* 834 */, U64_C(0x910ab077e8d7731b) /* 835 */,
+ U64_C(0x6a61bbdb5ac42f61) /* 836 */, U64_C(0x93513efbf0851567) /* 837 */,
+ U64_C(0xf494724b9e83e9d5) /* 838 */, U64_C(0xe887e1985c09648d) /* 839 */,
+ U64_C(0x34b1d3c675370cfd) /* 840 */, U64_C(0xdc35e433bc0d255d) /* 841 */,
+ U64_C(0xd0aab84234131be0) /* 842 */, U64_C(0x08042a50b48b7eaf) /* 843 */,
+ U64_C(0x9997c4ee44a3ab35) /* 844 */, U64_C(0x829a7b49201799d0) /* 845 */,
+ U64_C(0x263b8307b7c54441) /* 846 */, U64_C(0x752f95f4fd6a6ca6) /* 847 */,
+ U64_C(0x927217402c08c6e5) /* 848 */, U64_C(0x2a8ab754a795d9ee) /* 849 */,
+ U64_C(0xa442f7552f72943d) /* 850 */, U64_C(0x2c31334e19781208) /* 851 */,
+ U64_C(0x4fa98d7ceaee6291) /* 852 */, U64_C(0x55c3862f665db309) /* 853 */,
+ U64_C(0xbd0610175d53b1f3) /* 854 */, U64_C(0x46fe6cb840413f27) /* 855 */,
+ U64_C(0x3fe03792df0cfa59) /* 856 */, U64_C(0xcfe700372eb85e8f) /* 857 */,
+ U64_C(0xa7be29e7adbce118) /* 858 */, U64_C(0xe544ee5cde8431dd) /* 859 */,
+ U64_C(0x8a781b1b41f1873e) /* 860 */, U64_C(0xa5c94c78a0d2f0e7) /* 861 */,
+ U64_C(0x39412e2877b60728) /* 862 */, U64_C(0xa1265ef3afc9a62c) /* 863 */,
+ U64_C(0xbcc2770c6a2506c5) /* 864 */, U64_C(0x3ab66dd5dce1ce12) /* 865 */,
+ U64_C(0xe65499d04a675b37) /* 866 */, U64_C(0x7d8f523481bfd216) /* 867 */,
+ U64_C(0x0f6f64fcec15f389) /* 868 */, U64_C(0x74efbe618b5b13c8) /* 869 */,
+ U64_C(0xacdc82b714273e1d) /* 870 */, U64_C(0xdd40bfe003199d17) /* 871 */,
+ U64_C(0x37e99257e7e061f8) /* 872 */, U64_C(0xfa52626904775aaa) /* 873 */,
+ U64_C(0x8bbbf63a463d56f9) /* 874 */, U64_C(0xf0013f1543a26e64) /* 875 */,
+ U64_C(0xa8307e9f879ec898) /* 876 */, U64_C(0xcc4c27a4150177cc) /* 877 */,
+ U64_C(0x1b432f2cca1d3348) /* 878 */, U64_C(0xde1d1f8f9f6fa013) /* 879 */,
+ U64_C(0x606602a047a7ddd6) /* 880 */, U64_C(0xd237ab64cc1cb2c7) /* 881 */,
+ U64_C(0x9b938e7225fcd1d3) /* 882 */, U64_C(0xec4e03708e0ff476) /* 883 */,
+ U64_C(0xfeb2fbda3d03c12d) /* 884 */, U64_C(0xae0bced2ee43889a) /* 885 */,
+ U64_C(0x22cb8923ebfb4f43) /* 886 */, U64_C(0x69360d013cf7396d) /* 887 */,
+ U64_C(0x855e3602d2d4e022) /* 888 */, U64_C(0x073805bad01f784c) /* 889 */,
+ U64_C(0x33e17a133852f546) /* 890 */, U64_C(0xdf4874058ac7b638) /* 891 */,
+ U64_C(0xba92b29c678aa14a) /* 892 */, U64_C(0x0ce89fc76cfaadcd) /* 893 */,
+ U64_C(0x5f9d4e0908339e34) /* 894 */, U64_C(0xf1afe9291f5923b9) /* 895 */,
+ U64_C(0x6e3480f60f4a265f) /* 896 */, U64_C(0xeebf3a2ab29b841c) /* 897 */,
+ U64_C(0xe21938a88f91b4ad) /* 898 */, U64_C(0x57dfeff845c6d3c3) /* 899 */,
+ U64_C(0x2f006b0bf62caaf2) /* 900 */, U64_C(0x62f479ef6f75ee78) /* 901 */,
+ U64_C(0x11a55ad41c8916a9) /* 902 */, U64_C(0xf229d29084fed453) /* 903 */,
+ U64_C(0x42f1c27b16b000e6) /* 904 */, U64_C(0x2b1f76749823c074) /* 905 */,
+ U64_C(0x4b76eca3c2745360) /* 906 */, U64_C(0x8c98f463b91691bd) /* 907 */,
+ U64_C(0x14bcc93cf1ade66a) /* 908 */, U64_C(0x8885213e6d458397) /* 909 */,
+ U64_C(0x8e177df0274d4711) /* 910 */, U64_C(0xb49b73b5503f2951) /* 911 */,
+ U64_C(0x10168168c3f96b6b) /* 912 */, U64_C(0x0e3d963b63cab0ae) /* 913 */,
+ U64_C(0x8dfc4b5655a1db14) /* 914 */, U64_C(0xf789f1356e14de5c) /* 915 */,
+ U64_C(0x683e68af4e51dac1) /* 916 */, U64_C(0xc9a84f9d8d4b0fd9) /* 917 */,
+ U64_C(0x3691e03f52a0f9d1) /* 918 */, U64_C(0x5ed86e46e1878e80) /* 919 */,
+ U64_C(0x3c711a0e99d07150) /* 920 */, U64_C(0x5a0865b20c4e9310) /* 921 */,
+ U64_C(0x56fbfc1fe4f0682e) /* 922 */, U64_C(0xea8d5de3105edf9b) /* 923 */,
+ U64_C(0x71abfdb12379187a) /* 924 */, U64_C(0x2eb99de1bee77b9c) /* 925 */,
+ U64_C(0x21ecc0ea33cf4523) /* 926 */, U64_C(0x59a4d7521805c7a1) /* 927 */,
+ U64_C(0x3896f5eb56ae7c72) /* 928 */, U64_C(0xaa638f3db18f75dc) /* 929 */,
+ U64_C(0x9f39358dabe9808e) /* 930 */, U64_C(0xb7defa91c00b72ac) /* 931 */,
+ U64_C(0x6b5541fd62492d92) /* 932 */, U64_C(0x6dc6dee8f92e4d5b) /* 933 */,
+ U64_C(0x353f57abc4beea7e) /* 934 */, U64_C(0x735769d6da5690ce) /* 935 */,
+ U64_C(0x0a234aa642391484) /* 936 */, U64_C(0xf6f9508028f80d9d) /* 937 */,
+ U64_C(0xb8e319a27ab3f215) /* 938 */, U64_C(0x31ad9c1151341a4d) /* 939 */,
+ U64_C(0x773c22a57bef5805) /* 940 */, U64_C(0x45c7561a07968633) /* 941 */,
+ U64_C(0xf913da9e249dbe36) /* 942 */, U64_C(0xda652d9b78a64c68) /* 943 */,
+ U64_C(0x4c27a97f3bc334ef) /* 944 */, U64_C(0x76621220e66b17f4) /* 945 */,
+ U64_C(0x967743899acd7d0b) /* 946 */, U64_C(0xf3ee5bcae0ed6782) /* 947 */,
+ U64_C(0x409f753600c879fc) /* 948 */, U64_C(0x06d09a39b5926db6) /* 949 */,
+ U64_C(0x6f83aeb0317ac588) /* 950 */, U64_C(0x01e6ca4a86381f21) /* 951 */,
+ U64_C(0x66ff3462d19f3025) /* 952 */, U64_C(0x72207c24ddfd3bfb) /* 953 */,
+ U64_C(0x4af6b6d3e2ece2eb) /* 954 */, U64_C(0x9c994dbec7ea08de) /* 955 */,
+ U64_C(0x49ace597b09a8bc4) /* 956 */, U64_C(0xb38c4766cf0797ba) /* 957 */,
+ U64_C(0x131b9373c57c2a75) /* 958 */, U64_C(0xb1822cce61931e58) /* 959 */,
+ U64_C(0x9d7555b909ba1c0c) /* 960 */, U64_C(0x127fafdd937d11d2) /* 961 */,
+ U64_C(0x29da3badc66d92e4) /* 962 */, U64_C(0xa2c1d57154c2ecbc) /* 963 */,
+ U64_C(0x58c5134d82f6fe24) /* 964 */, U64_C(0x1c3ae3515b62274f) /* 965 */,
+ U64_C(0xe907c82e01cb8126) /* 966 */, U64_C(0xf8ed091913e37fcb) /* 967 */,
+ U64_C(0x3249d8f9c80046c9) /* 968 */, U64_C(0x80cf9bede388fb63) /* 969 */,
+ U64_C(0x1881539a116cf19e) /* 970 */, U64_C(0x5103f3f76bd52457) /* 971 */,
+ U64_C(0x15b7e6f5ae47f7a8) /* 972 */, U64_C(0xdbd7c6ded47e9ccf) /* 973 */,
+ U64_C(0x44e55c410228bb1a) /* 974 */, U64_C(0xb647d4255edb4e99) /* 975 */,
+ U64_C(0x5d11882bb8aafc30) /* 976 */, U64_C(0xf5098bbb29d3212a) /* 977 */,
+ U64_C(0x8fb5ea14e90296b3) /* 978 */, U64_C(0x677b942157dd025a) /* 979 */,
+ U64_C(0xfb58e7c0a390acb5) /* 980 */, U64_C(0x89d3674c83bd4a01) /* 981 */,
+ U64_C(0x9e2da4df4bf3b93b) /* 982 */, U64_C(0xfcc41e328cab4829) /* 983 */,
+ U64_C(0x03f38c96ba582c52) /* 984 */, U64_C(0xcad1bdbd7fd85db2) /* 985 */,
+ U64_C(0xbbb442c16082ae83) /* 986 */, U64_C(0xb95fe86ba5da9ab0) /* 987 */,
+ U64_C(0xb22e04673771a93f) /* 988 */, U64_C(0x845358c9493152d8) /* 989 */,
+ U64_C(0xbe2a488697b4541e) /* 990 */, U64_C(0x95a2dc2dd38e6966) /* 991 */,
+ U64_C(0xc02c11ac923c852b) /* 992 */, U64_C(0x2388b1990df2a87b) /* 993 */,
+ U64_C(0x7c8008fa1b4f37be) /* 994 */, U64_C(0x1f70d0c84d54e503) /* 995 */,
+ U64_C(0x5490adec7ece57d4) /* 996 */, U64_C(0x002b3c27d9063a3a) /* 997 */,
+ U64_C(0x7eaea3848030a2bf) /* 998 */, U64_C(0xc602326ded2003c0) /* 999 */,
+ U64_C(0x83a7287d69a94086) /* 1000 */, U64_C(0xc57a5fcb30f57a8a) /* 1001 */,
+ U64_C(0xb56844e479ebe779) /* 1002 */, U64_C(0xa373b40f05dcbce9) /* 1003 */,
+ U64_C(0xd71a786e88570ee2) /* 1004 */, U64_C(0x879cbacdbde8f6a0) /* 1005 */,
+ U64_C(0x976ad1bcc164a32f) /* 1006 */, U64_C(0xab21e25e9666d78b) /* 1007 */,
+ U64_C(0x901063aae5e5c33c) /* 1008 */, U64_C(0x9818b34448698d90) /* 1009 */,
+ U64_C(0xe36487ae3e1e8abb) /* 1010 */, U64_C(0xafbdf931893bdcb4) /* 1011 */,
+ U64_C(0x6345a0dc5fbbd519) /* 1012 */, U64_C(0x8628fe269b9465ca) /* 1013 */,
+ U64_C(0x1e5d01603f9c51ec) /* 1014 */, U64_C(0x4de44006a15049b7) /* 1015 */,
+ U64_C(0xbf6c70e5f776cbb1) /* 1016 */, U64_C(0x411218f2ef552bed) /* 1017 */,
+ U64_C(0xcb0c0708705a36a3) /* 1018 */, U64_C(0xe74d14754f986044) /* 1019 */,
+ U64_C(0xcd56d9430ea8280e) /* 1020 */, U64_C(0xc12591d7535f5065) /* 1021 */,
+ U64_C(0xc83223f1720aef96) /* 1022 */, U64_C(0xc3a0396f7363a51f) /* 1023 */
+};
+
+static void
+do_init (void *context, int variant)
+{
+ TIGER_CONTEXT *hd = context;
+
+ hd->a = 0x0123456789abcdefLL;
+ hd->b = 0xfedcba9876543210LL;
+ hd->c = 0xf096a5b4c3b2e187LL;
+ hd->nblocks = 0;
+ hd->count = 0;
+ hd->variant = variant;
+}
+
+static void
+tiger_init (void *context)
+{
+ do_init (context, 0);
+}
+
+static void
+tiger1_init (void *context)
+{
+ do_init (context, 1);
+}
+
+static void
+tiger2_init (void *context)
+{
+ do_init (context, 2);
+}
+
+static void
+tiger_round( u64 *ra, u64 *rb, u64 *rc, u64 x, int mul )
+{
+ u64 a = *ra;
+ u64 b = *rb;
+ u64 c = *rc;
+
+ c ^= x;
+ a -= ( sbox1[ c & 0xff ] ^ sbox2[ (c >> 16) & 0xff ]
+ ^ sbox3[ (c >> 32) & 0xff ] ^ sbox4[ (c >> 48) & 0xff ]);
+ b += ( sbox4[ (c >> 8) & 0xff ] ^ sbox3[ (c >> 24) & 0xff ]
+ ^ sbox2[ (c >> 40) & 0xff ] ^ sbox1[ (c >> 56) & 0xff ]);
+ b *= mul;
+
+ *ra = a;
+ *rb = b;
+ *rc = c;
+}
+
+
+static void
+pass( u64 *ra, u64 *rb, u64 *rc, u64 *x, int mul )
+{
+ u64 a = *ra;
+ u64 b = *rb;
+ u64 c = *rc;
+
+ tiger_round( &a, &b, &c, x[0], mul );
+ tiger_round( &b, &c, &a, x[1], mul );
+ tiger_round( &c, &a, &b, x[2], mul );
+ tiger_round( &a, &b, &c, x[3], mul );
+ tiger_round( &b, &c, &a, x[4], mul );
+ tiger_round( &c, &a, &b, x[5], mul );
+ tiger_round( &a, &b, &c, x[6], mul );
+ tiger_round( &b, &c, &a, x[7], mul );
+
+ *ra = a;
+ *rb = b;
+ *rc = c;
+}
+
+
+static void
+key_schedule( u64 *x )
+{
+ x[0] -= x[7] ^ 0xa5a5a5a5a5a5a5a5LL;
+ x[1] ^= x[0];
+ x[2] += x[1];
+ x[3] -= x[2] ^ ((~x[1]) << 19 );
+ x[4] ^= x[3];
+ x[5] += x[4];
+ x[6] -= x[5] ^ ((~x[4]) >> 23 );
+ x[7] ^= x[6];
+ x[0] += x[7];
+ x[1] -= x[0] ^ ((~x[7]) << 19 );
+ x[2] ^= x[1];
+ x[3] += x[2];
+ x[4] -= x[3] ^ ((~x[2]) >> 23 );
+ x[5] ^= x[4];
+ x[6] += x[5];
+ x[7] -= x[6] ^ 0x0123456789abcdefLL;
+}
+
+
+/****************
+ * Transform the message DATA which consists of 512 bytes (8 words)
+ */
+static void
+transform ( TIGER_CONTEXT *hd, const unsigned char *data )
+{
+ u64 a,b,c,aa,bb,cc;
+ u64 x[8];
+#ifdef WORDS_BIGENDIAN
+#define MKWORD(d,n) \
+ ( ((u64)(d)[8*(n)+7]) << 56 | ((u64)(d)[8*(n)+6]) << 48 \
+ | ((u64)(d)[8*(n)+5]) << 40 | ((u64)(d)[8*(n)+4]) << 32 \
+ | ((u64)(d)[8*(n)+3]) << 24 | ((u64)(d)[8*(n)+2]) << 16 \
+ | ((u64)(d)[8*(n)+1]) << 8 | ((u64)(d)[8*(n) ]) )
+ x[0] = MKWORD(data, 0);
+ x[1] = MKWORD(data, 1);
+ x[2] = MKWORD(data, 2);
+ x[3] = MKWORD(data, 3);
+ x[4] = MKWORD(data, 4);
+ x[5] = MKWORD(data, 5);
+ x[6] = MKWORD(data, 6);
+ x[7] = MKWORD(data, 7);
+#undef MKWORD
+#else
+ memcpy( &x[0], data, 64 );
+#endif
+
+ /* save */
+ a = aa = hd->a;
+ b = bb = hd->b;
+ c = cc = hd->c;
+
+ pass( &a, &b, &c, x, 5);
+ key_schedule( x );
+ pass( &c, &a, &b, x, 7);
+ key_schedule( x );
+ pass( &b, &c, &a, x, 9);
+
+ /* feedforward */
+ a ^= aa;
+ b -= bb;
+ c += cc;
+ /* store */
+ hd->a = a;
+ hd->b = b;
+ hd->c = c;
+}
+
+
+
+/* Update the message digest with the contents
+ * of INBUF with length INLEN.
+ */
+static void
+tiger_write ( void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ TIGER_CONTEXT *hd = context;
+
+ if( hd->count == 64 ) /* flush the buffer */
+ {
+ transform( hd, hd->buf );
+ _gcry_burn_stack (21*8+11*sizeof(void*));
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if( !inbuf )
+ return;
+ if( hd->count )
+ {
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+ tiger_write( hd, NULL, 0 );
+ if( !inlen )
+ return;
+ }
+
+ while( inlen >= 64 )
+ {
+ transform( hd, inbuf );
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 64;
+ inbuf += 64;
+ }
+ _gcry_burn_stack (21*8+11*sizeof(void*));
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+
+/* The routine terminates the computation
+ */
+static void
+tiger_final( void *context )
+{
+ TIGER_CONTEXT *hd = context;
+ u32 t, msb, lsb;
+ byte *p;
+ byte pad = hd->variant == 2? 0x80 : 0x01;
+
+ tiger_write(hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if( (lsb += hd->count) < t )
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if( hd->count < 56 ) /* enough room */
+ {
+ hd->buf[hd->count++] = pad;
+ while( hd->count < 56 )
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else /* need one extra block */
+ {
+ hd->buf[hd->count++] = pad; /* pad character */
+ while( hd->count < 64 )
+ hd->buf[hd->count++] = 0;
+ tiger_write(hd, NULL, 0); /* flush */;
+ memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = lsb ;
+ hd->buf[57] = lsb >> 8;
+ hd->buf[58] = lsb >> 16;
+ hd->buf[59] = lsb >> 24;
+ hd->buf[60] = msb ;
+ hd->buf[61] = msb >> 8;
+ hd->buf[62] = msb >> 16;
+ hd->buf[63] = msb >> 24;
+ transform( hd, hd->buf );
+ _gcry_burn_stack (21*8+11*sizeof(void*));
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *(u64*)p = hd->a ; p += 8; } while(0)
+#else /* little endian */
+#define X(a) do { *p++ = hd->a >> 56; *p++ = hd->a >> 48; \
+ *p++ = hd->a >> 40; *p++ = hd->a >> 32; \
+ *p++ = hd->a >> 24; *p++ = hd->a >> 16; \
+ *p++ = hd->a >> 8; *p++ = hd->a; } while(0)
+#endif
+#define Y(a) do { *p++ = hd->a ; *p++ = hd->a >> 8; \
+ *p++ = hd->a >> 16; *p++ = hd->a >> 24; \
+ *p++ = hd->a >> 32; *p++ = hd->a >> 40; \
+ *p++ = hd->a >> 48; *p++ = hd->a >> 56; } while(0)
+ if (hd->variant == 0)
+ {
+ X(a);
+ X(b);
+ X(c);
+ }
+ else
+ {
+ Y(a);
+ Y(b);
+ Y(c);
+ }
+#undef X
+#undef Y
+}
+
+static byte *
+tiger_read( void *context )
+{
+ TIGER_CONTEXT *hd = context;
+
+ return hd->buf;
+}
+
+
+
+/* This is the old TIGER variant based on the unfixed reference
+ implementation. IT was used in GnupG up to 1.3.2. We don't provide
+ an OID anymore because that would not be correct. */
+gcry_md_spec_t _gcry_digest_spec_tiger =
+ {
+ "TIGER192", NULL, 0, NULL, 24,
+ tiger_init, tiger_write, tiger_final, tiger_read,
+ sizeof (TIGER_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_tiger",
+#endif
+ .blocksize = 64
+ };
+
+
+
+/* This is the fixed TIGER implementation. */
+static byte asn1[19] = /* Object ID is 1.3.6.1.4.1.11591.12.2 */
+ { 0x30, 0x29, 0x30, 0x0d, 0x06, 0x09, 0x2b, 0x06,
+ 0x01, 0x04, 0x01, 0xda, 0x47, 0x0c, 0x02,
+ 0x05, 0x00, 0x04, 0x18 };
+
+static gcry_md_oid_spec_t oid_spec_tiger1[] =
+ {
+ /* GNU.digestAlgorithm TIGER */
+ { "1.3.6.1.4.1.11591.12.2" },
+ { NULL }
+ };
+
+gcry_md_spec_t _gcry_digest_spec_tiger1 =
+ {
+ "TIGER", asn1, DIM (asn1), oid_spec_tiger1, 24,
+ tiger1_init, tiger_write, tiger_final, tiger_read,
+ sizeof (TIGER_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_tiger",
+#endif
+ .blocksize = 64
+ };
+
+
+
+/* This is TIGER2 which usues a changed padding algorithm. */
+gcry_md_spec_t _gcry_digest_spec_tiger2 =
+ {
+ "TIGER2", NULL, 0, NULL, 24,
+ tiger2_init, tiger_write, tiger_final, tiger_read,
+ sizeof (TIGER_CONTEXT)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_tiger",
+#endif
+ .blocksize = 64
+ };
+
+#endif /* HAVE_U64_TYPEDEF */
+
+
+GRUB_MOD_INIT(gcry_tiger)
+{
+ COMPILE_TIME_ASSERT(sizeof (TIGER_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ COMPILE_TIME_ASSERT(sizeof (TIGER_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ COMPILE_TIME_ASSERT(sizeof (TIGER_CONTEXT) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ grub_md_register (&_gcry_digest_spec_tiger);
+ grub_md_register (&_gcry_digest_spec_tiger1);
+ grub_md_register (&_gcry_digest_spec_tiger2);
+}
+
+GRUB_MOD_FINI(gcry_tiger)
+{
+ grub_md_unregister (&_gcry_digest_spec_tiger);
+ grub_md_unregister (&_gcry_digest_spec_tiger1);
+ grub_md_unregister (&_gcry_digest_spec_tiger2);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/twofish.c b/grub-core/lib/libgcrypt-grub/cipher/twofish.c
new file mode 100644
index 0000000..0a65ac1
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/twofish.c
@@ -0,0 +1,1001 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* Twofish for GPG
+ * Copyright (C) 1998, 2002, 2003 Free Software Foundation, Inc.
+ * Written by Matthew Skala <mskala@ansuz.sooke.bc.ca>, July 26, 1998
+ * 256-bit key length added March 20, 1999
+ * Some modifications to reduce the text size by Werner Koch, April, 1998
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ ********************************************************************
+ *
+ * This code is a "clean room" implementation, written from the paper
+ * _Twofish: A 128-Bit Block Cipher_ by Bruce Schneier, John Kelsey,
+ * Doug Whiting, David Wagner, Chris Hall, and Niels Ferguson, available
+ * through http://www.counterpane.com/twofish.html
+ *
+ * For background information on multiplication in finite fields, used for
+ * the matrix operations in the key schedule, see the book _Contemporary
+ * Abstract Algebra_ by Joseph A. Gallian, especially chapter 22 in the
+ * Third Edition.
+ *
+ * Only the 128- and 256-bit key sizes are supported. This code is intended
+ * for GNU C on a 32-bit system, but it should work almost anywhere. Loops
+ * are unrolled, precomputation tables are used, etc., for maximum speed at
+ * some cost in memory consumption. */
+
+
+#include "types.h" /* for byte and u32 typedefs */
+#include "g10lib.h"
+#include "cipher.h"
+
+/* Prototype for the self-test function. */
+
+/* Structure for an expanded Twofish key. s contains the key-dependent
+ * S-boxes composed with the MDS matrix; w contains the eight "whitening"
+ * subkeys, K[0] through K[7]. k holds the remaining, "round" subkeys. Note
+ * that k[i] corresponds to what the Twofish paper calls K[i+8]. */
+typedef struct {
+ u32 s[4][256], w[8], k[32];
+} TWOFISH_context;
+
+/* These two tables are the q0 and q1 permutations, exactly as described in
+ * the Twofish paper. */
+
+static const byte q0[256] = {
+ 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78,
+ 0xE4, 0xDD, 0xD1, 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C,
+ 0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, 0xF2, 0xD0, 0x8B, 0x30,
+ 0x84, 0x54, 0xDF, 0x23, 0x19, 0x5B, 0x3D, 0x59, 0xF3, 0xAE, 0xA2, 0x82,
+ 0x63, 0x01, 0x83, 0x2E, 0xD9, 0x51, 0x9B, 0x7C, 0xA6, 0xEB, 0xA5, 0xBE,
+ 0x16, 0x0C, 0xE3, 0x61, 0xC0, 0x8C, 0x3A, 0xF5, 0x73, 0x2C, 0x25, 0x0B,
+ 0xBB, 0x4E, 0x89, 0x6B, 0x53, 0x6A, 0xB4, 0xF1, 0xE1, 0xE6, 0xBD, 0x45,
+ 0xE2, 0xF4, 0xB6, 0x66, 0xCC, 0x95, 0x03, 0x56, 0xD4, 0x1C, 0x1E, 0xD7,
+ 0xFB, 0xC3, 0x8E, 0xB5, 0xE9, 0xCF, 0xBF, 0xBA, 0xEA, 0x77, 0x39, 0xAF,
+ 0x33, 0xC9, 0x62, 0x71, 0x81, 0x79, 0x09, 0xAD, 0x24, 0xCD, 0xF9, 0xD8,
+ 0xE5, 0xC5, 0xB9, 0x4D, 0x44, 0x08, 0x86, 0xE7, 0xA1, 0x1D, 0xAA, 0xED,
+ 0x06, 0x70, 0xB2, 0xD2, 0x41, 0x7B, 0xA0, 0x11, 0x31, 0xC2, 0x27, 0x90,
+ 0x20, 0xF6, 0x60, 0xFF, 0x96, 0x5C, 0xB1, 0xAB, 0x9E, 0x9C, 0x52, 0x1B,
+ 0x5F, 0x93, 0x0A, 0xEF, 0x91, 0x85, 0x49, 0xEE, 0x2D, 0x4F, 0x8F, 0x3B,
+ 0x47, 0x87, 0x6D, 0x46, 0xD6, 0x3E, 0x69, 0x64, 0x2A, 0xCE, 0xCB, 0x2F,
+ 0xFC, 0x97, 0x05, 0x7A, 0xAC, 0x7F, 0xD5, 0x1A, 0x4B, 0x0E, 0xA7, 0x5A,
+ 0x28, 0x14, 0x3F, 0x29, 0x88, 0x3C, 0x4C, 0x02, 0xB8, 0xDA, 0xB0, 0x17,
+ 0x55, 0x1F, 0x8A, 0x7D, 0x57, 0xC7, 0x8D, 0x74, 0xB7, 0xC4, 0x9F, 0x72,
+ 0x7E, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34, 0x6E, 0x50, 0xDE, 0x68,
+ 0x65, 0xBC, 0xDB, 0xF8, 0xC8, 0xA8, 0x2B, 0x40, 0xDC, 0xFE, 0x32, 0xA4,
+ 0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, 0x6F, 0x9D, 0x36, 0x42,
+ 0x4A, 0x5E, 0xC1, 0xE0
+};
+
+static const byte q1[256] = {
+ 0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B,
+ 0x45, 0x7D, 0xE8, 0x4B, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1,
+ 0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, 0x5E, 0xBA, 0xAE, 0x5B,
+ 0x8A, 0x00, 0xBC, 0x9D, 0x6D, 0xC1, 0xB1, 0x0E, 0x80, 0x5D, 0xD2, 0xD5,
+ 0xA0, 0x84, 0x07, 0x14, 0xB5, 0x90, 0x2C, 0xA3, 0xB2, 0x73, 0x4C, 0x54,
+ 0x92, 0x74, 0x36, 0x51, 0x38, 0xB0, 0xBD, 0x5A, 0xFC, 0x60, 0x62, 0x96,
+ 0x6C, 0x42, 0xF7, 0x10, 0x7C, 0x28, 0x27, 0x8C, 0x13, 0x95, 0x9C, 0xC7,
+ 0x24, 0x46, 0x3B, 0x70, 0xCA, 0xE3, 0x85, 0xCB, 0x11, 0xD0, 0x93, 0xB8,
+ 0xA6, 0x83, 0x20, 0xFF, 0x9F, 0x77, 0xC3, 0xCC, 0x03, 0x6F, 0x08, 0xBF,
+ 0x40, 0xE7, 0x2B, 0xE2, 0x79, 0x0C, 0xAA, 0x82, 0x41, 0x3A, 0xEA, 0xB9,
+ 0xE4, 0x9A, 0xA4, 0x97, 0x7E, 0xDA, 0x7A, 0x17, 0x66, 0x94, 0xA1, 0x1D,
+ 0x3D, 0xF0, 0xDE, 0xB3, 0x0B, 0x72, 0xA7, 0x1C, 0xEF, 0xD1, 0x53, 0x3E,
+ 0x8F, 0x33, 0x26, 0x5F, 0xEC, 0x76, 0x2A, 0x49, 0x81, 0x88, 0xEE, 0x21,
+ 0xC4, 0x1A, 0xEB, 0xD9, 0xC5, 0x39, 0x99, 0xCD, 0xAD, 0x31, 0x8B, 0x01,
+ 0x18, 0x23, 0xDD, 0x1F, 0x4E, 0x2D, 0xF9, 0x48, 0x4F, 0xF2, 0x65, 0x8E,
+ 0x78, 0x5C, 0x58, 0x19, 0x8D, 0xE5, 0x98, 0x57, 0x67, 0x7F, 0x05, 0x64,
+ 0xAF, 0x63, 0xB6, 0xFE, 0xF5, 0xB7, 0x3C, 0xA5, 0xCE, 0xE9, 0x68, 0x44,
+ 0xE0, 0x4D, 0x43, 0x69, 0x29, 0x2E, 0xAC, 0x15, 0x59, 0xA8, 0x0A, 0x9E,
+ 0x6E, 0x47, 0xDF, 0x34, 0x35, 0x6A, 0xCF, 0xDC, 0x22, 0xC9, 0xC0, 0x9B,
+ 0x89, 0xD4, 0xED, 0xAB, 0x12, 0xA2, 0x0D, 0x52, 0xBB, 0x02, 0x2F, 0xA9,
+ 0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, 0x16, 0x25, 0x86, 0x56,
+ 0x55, 0x09, 0xBE, 0x91
+};
+
+/* These MDS tables are actually tables of MDS composed with q0 and q1,
+ * because it is only ever used that way and we can save some time by
+ * precomputing. Of course the main saving comes from precomputing the
+ * GF(2^8) multiplication involved in the MDS matrix multiply; by looking
+ * things up in these tables we reduce the matrix multiply to four lookups
+ * and three XORs. Semi-formally, the definition of these tables is:
+ * mds[0][i] = MDS (q1[i] 0 0 0)^T mds[1][i] = MDS (0 q0[i] 0 0)^T
+ * mds[2][i] = MDS (0 0 q1[i] 0)^T mds[3][i] = MDS (0 0 0 q0[i])^T
+ * where ^T means "transpose", the matrix multiply is performed in GF(2^8)
+ * represented as GF(2)[x]/v(x) where v(x)=x^8+x^6+x^5+x^3+1 as described
+ * by Schneier et al, and I'm casually glossing over the byte/word
+ * conversion issues. */
+
+static const u32 mds[4][256] = {
+ {0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B,
+ 0xE2E22BFB, 0x9E9EFAC8, 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B,
+ 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, 0x3C3C57D6, 0x93938A32,
+ 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1,
+ 0x24243C30, 0x5151E20F, 0xBABAC6F8, 0x4A4AF31B, 0xBFBF4887, 0x0D0D70FA,
+ 0xB0B0B306, 0x7575DE3F, 0xD2D2FD5E, 0x7D7D20BA, 0x666631AE, 0x3A3AA35B,
+ 0x59591C8A, 0x00000000, 0xCDCD93BC, 0x1A1AE09D, 0xAEAE2C6D, 0x7F7FABC1,
+ 0x2B2BC7B1, 0xBEBEB90E, 0xE0E0A080, 0x8A8A105D, 0x3B3B52D2, 0x6464BAD5,
+ 0xD8D888A0, 0xE7E7A584, 0x5F5FE807, 0x1B1B1114, 0x2C2CC2B5, 0xFCFCB490,
+ 0x3131272C, 0x808065A3, 0x73732AB2, 0x0C0C8173, 0x79795F4C, 0x6B6B4154,
+ 0x4B4B0292, 0x53536974, 0x94948F36, 0x83831F51, 0x2A2A3638, 0xC4C49CB0,
+ 0x2222C8BD, 0xD5D5F85A, 0xBDBDC3FC, 0x48487860, 0xFFFFCE62, 0x4C4C0796,
+ 0x4141776C, 0xC7C7E642, 0xEBEB24F7, 0x1C1C1410, 0x5D5D637C, 0x36362228,
+ 0x6767C027, 0xE9E9AF8C, 0x4444F913, 0x1414EA95, 0xF5F5BB9C, 0xCFCF18C7,
+ 0x3F3F2D24, 0xC0C0E346, 0x7272DB3B, 0x54546C70, 0x29294CCA, 0xF0F035E3,
+ 0x0808FE85, 0xC6C617CB, 0xF3F34F11, 0x8C8CE4D0, 0xA4A45993, 0xCACA96B8,
+ 0x68683BA6, 0xB8B84D83, 0x38382820, 0xE5E52EFF, 0xADAD569F, 0x0B0B8477,
+ 0xC8C81DC3, 0x9999FFCC, 0x5858ED03, 0x19199A6F, 0x0E0E0A08, 0x95957EBF,
+ 0x70705040, 0xF7F730E7, 0x6E6ECF2B, 0x1F1F6EE2, 0xB5B53D79, 0x09090F0C,
+ 0x616134AA, 0x57571682, 0x9F9F0B41, 0x9D9D803A, 0x111164EA, 0x2525CDB9,
+ 0xAFAFDDE4, 0x4545089A, 0xDFDF8DA4, 0xA3A35C97, 0xEAEAD57E, 0x353558DA,
+ 0xEDEDD07A, 0x4343FC17, 0xF8F8CB66, 0xFBFBB194, 0x3737D3A1, 0xFAFA401D,
+ 0xC2C2683D, 0xB4B4CCF0, 0x32325DDE, 0x9C9C71B3, 0x5656E70B, 0xE3E3DA72,
+ 0x878760A7, 0x15151B1C, 0xF9F93AEF, 0x6363BFD1, 0x3434A953, 0x9A9A853E,
+ 0xB1B1428F, 0x7C7CD133, 0x88889B26, 0x3D3DA65F, 0xA1A1D7EC, 0xE4E4DF76,
+ 0x8181942A, 0x91910149, 0x0F0FFB81, 0xEEEEAA88, 0x161661EE, 0xD7D77321,
+ 0x9797F5C4, 0xA5A5A81A, 0xFEFE3FEB, 0x6D6DB5D9, 0x7878AEC5, 0xC5C56D39,
+ 0x1D1DE599, 0x7676A4CD, 0x3E3EDCAD, 0xCBCB6731, 0xB6B6478B, 0xEFEF5B01,
+ 0x12121E18, 0x6060C523, 0x6A6AB0DD, 0x4D4DF61F, 0xCECEE94E, 0xDEDE7C2D,
+ 0x55559DF9, 0x7E7E5A48, 0x2121B24F, 0x03037AF2, 0xA0A02665, 0x5E5E198E,
+ 0x5A5A6678, 0x65654B5C, 0x62624E58, 0xFDFD4519, 0x0606F48D, 0x404086E5,
+ 0xF2F2BE98, 0x3333AC57, 0x17179067, 0x05058E7F, 0xE8E85E05, 0x4F4F7D64,
+ 0x89896AAF, 0x10109563, 0x74742FB6, 0x0A0A75FE, 0x5C5C92F5, 0x9B9B74B7,
+ 0x2D2D333C, 0x3030D6A5, 0x2E2E49CE, 0x494989E9, 0x46467268, 0x77775544,
+ 0xA8A8D8E0, 0x9696044D, 0x2828BD43, 0xA9A92969, 0xD9D97929, 0x8686912E,
+ 0xD1D187AC, 0xF4F44A15, 0x8D8D1559, 0xD6D682A8, 0xB9B9BC0A, 0x42420D9E,
+ 0xF6F6C16E, 0x2F2FB847, 0xDDDD06DF, 0x23233934, 0xCCCC6235, 0xF1F1C46A,
+ 0xC1C112CF, 0x8585EBDC, 0x8F8F9E22, 0x7171A1C9, 0x9090F0C0, 0xAAAA539B,
+ 0x0101F189, 0x8B8BE1D4, 0x4E4E8CED, 0x8E8E6FAB, 0xABABA212, 0x6F6F3EA2,
+ 0xE6E6540D, 0xDBDBF252, 0x92927BBB, 0xB7B7B602, 0x6969CA2F, 0x3939D9A9,
+ 0xD3D30CD7, 0xA7A72361, 0xA2A2AD1E, 0xC3C399B4, 0x6C6C4450, 0x07070504,
+ 0x04047FF6, 0x272746C2, 0xACACA716, 0xD0D07625, 0x50501386, 0xDCDCF756,
+ 0x84841A55, 0xE1E15109, 0x7A7A25BE, 0x1313EF91},
+
+ {0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252,
+ 0xA3658080, 0x76DFE4E4, 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A,
+ 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, 0x0D54E6E6, 0xC6432020,
+ 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141,
+ 0x43BD2828, 0x7532BCBC, 0x37D47B7B, 0x269B8888, 0xFA700D0D, 0x13F94444,
+ 0x94B1FBFB, 0x485A7E7E, 0xF27A0303, 0xD0E48C8C, 0x8B47B6B6, 0x303C2424,
+ 0x84A5E7E7, 0x54416B6B, 0xDF06DDDD, 0x23C56060, 0x1945FDFD, 0x5BA33A3A,
+ 0x3D68C2C2, 0x59158D8D, 0xF321ECEC, 0xAE316666, 0xA23E6F6F, 0x82165757,
+ 0x63951010, 0x015BEFEF, 0x834DB8B8, 0x2E918686, 0xD9B56D6D, 0x511F8383,
+ 0x9B53AAAA, 0x7C635D5D, 0xA63B6868, 0xEB3FFEFE, 0xA5D63030, 0xBE257A7A,
+ 0x16A7ACAC, 0x0C0F0909, 0xE335F0F0, 0x6123A7A7, 0xC0F09090, 0x8CAFE9E9,
+ 0x3A809D9D, 0xF5925C5C, 0x73810C0C, 0x2C273131, 0x2576D0D0, 0x0BE75656,
+ 0xBB7B9292, 0x4EE9CECE, 0x89F10101, 0x6B9F1E1E, 0x53A93434, 0x6AC4F1F1,
+ 0xB499C3C3, 0xF1975B5B, 0xE1834747, 0xE66B1818, 0xBDC82222, 0x450E9898,
+ 0xE26E1F1F, 0xF4C9B3B3, 0xB62F7474, 0x66CBF8F8, 0xCCFF9999, 0x95EA1414,
+ 0x03ED5858, 0x56F7DCDC, 0xD4E18B8B, 0x1C1B1515, 0x1EADA2A2, 0xD70CD3D3,
+ 0xFB2BE2E2, 0xC31DC8C8, 0x8E195E5E, 0xB5C22C2C, 0xE9894949, 0xCF12C1C1,
+ 0xBF7E9595, 0xBA207D7D, 0xEA641111, 0x77840B0B, 0x396DC5C5, 0xAF6A8989,
+ 0x33D17C7C, 0xC9A17171, 0x62CEFFFF, 0x7137BBBB, 0x81FB0F0F, 0x793DB5B5,
+ 0x0951E1E1, 0xADDC3E3E, 0x242D3F3F, 0xCDA47676, 0xF99D5555, 0xD8EE8282,
+ 0xE5864040, 0xC5AE7878, 0xB9CD2525, 0x4D049696, 0x44557777, 0x080A0E0E,
+ 0x86135050, 0xE730F7F7, 0xA1D33737, 0x1D40FAFA, 0xAA346161, 0xED8C4E4E,
+ 0x06B3B0B0, 0x706C5454, 0xB22A7373, 0xD2523B3B, 0x410B9F9F, 0x7B8B0202,
+ 0xA088D8D8, 0x114FF3F3, 0x3167CBCB, 0xC2462727, 0x27C06767, 0x90B4FCFC,
+ 0x20283838, 0xF67F0404, 0x60784848, 0xFF2EE5E5, 0x96074C4C, 0x5C4B6565,
+ 0xB1C72B2B, 0xAB6F8E8E, 0x9E0D4242, 0x9CBBF5F5, 0x52F2DBDB, 0x1BF34A4A,
+ 0x5FA63D3D, 0x9359A4A4, 0x0ABCB9B9, 0xEF3AF9F9, 0x91EF1313, 0x85FE0808,
+ 0x49019191, 0xEE611616, 0x2D7CDEDE, 0x4FB22121, 0x8F42B1B1, 0x3BDB7272,
+ 0x47B82F2F, 0x8748BFBF, 0x6D2CAEAE, 0x46E3C0C0, 0xD6573C3C, 0x3E859A9A,
+ 0x6929A9A9, 0x647D4F4F, 0x2A948181, 0xCE492E2E, 0xCB17C6C6, 0x2FCA6969,
+ 0xFCC3BDBD, 0x975CA3A3, 0x055EE8E8, 0x7AD0EDED, 0xAC87D1D1, 0x7F8E0505,
+ 0xD5BA6464, 0x1AA8A5A5, 0x4BB72626, 0x0EB9BEBE, 0xA7608787, 0x5AF8D5D5,
+ 0x28223636, 0x14111B1B, 0x3FDE7575, 0x2979D9D9, 0x88AAEEEE, 0x3C332D2D,
+ 0x4C5F7979, 0x02B6B7B7, 0xB896CACA, 0xDA583535, 0xB09CC4C4, 0x17FC4343,
+ 0x551A8484, 0x1FF64D4D, 0x8A1C5959, 0x7D38B2B2, 0x57AC3333, 0xC718CFCF,
+ 0x8DF40606, 0x74695353, 0xB7749B9B, 0xC4F59797, 0x9F56ADAD, 0x72DAE3E3,
+ 0x7ED5EAEA, 0x154AF4F4, 0x229E8F8F, 0x12A2ABAB, 0x584E6262, 0x07E85F5F,
+ 0x99E51D1D, 0x34392323, 0x6EC1F6F6, 0x50446C6C, 0xDE5D3232, 0x68724646,
+ 0x6526A0A0, 0xBC93CDCD, 0xDB03DADA, 0xF8C6BABA, 0xC8FA9E9E, 0xA882D6D6,
+ 0x2BCF6E6E, 0x40507070, 0xDCEB8585, 0xFE750A0A, 0x328A9393, 0xA48DDFDF,
+ 0xCA4C2929, 0x10141C1C, 0x2173D7D7, 0xF0CCB4B4, 0xD309D4D4, 0x5D108A8A,
+ 0x0FE25151, 0x00000000, 0x6F9A1919, 0x9DE01A1A, 0x368F9494, 0x42E6C7C7,
+ 0x4AECC9C9, 0x5EFDD2D2, 0xC1AB7F7F, 0xE0D8A8A8},
+
+ {0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B,
+ 0xE2FBE22B, 0x9EC89EFA, 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F,
+ 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, 0x3CD63C57, 0x9332938A,
+ 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783,
+ 0x2430243C, 0x510F51E2, 0xBAF8BAC6, 0x4A1B4AF3, 0xBF87BF48, 0x0DFA0D70,
+ 0xB006B0B3, 0x753F75DE, 0xD25ED2FD, 0x7DBA7D20, 0x66AE6631, 0x3A5B3AA3,
+ 0x598A591C, 0x00000000, 0xCDBCCD93, 0x1A9D1AE0, 0xAE6DAE2C, 0x7FC17FAB,
+ 0x2BB12BC7, 0xBE0EBEB9, 0xE080E0A0, 0x8A5D8A10, 0x3BD23B52, 0x64D564BA,
+ 0xD8A0D888, 0xE784E7A5, 0x5F075FE8, 0x1B141B11, 0x2CB52CC2, 0xFC90FCB4,
+ 0x312C3127, 0x80A38065, 0x73B2732A, 0x0C730C81, 0x794C795F, 0x6B546B41,
+ 0x4B924B02, 0x53745369, 0x9436948F, 0x8351831F, 0x2A382A36, 0xC4B0C49C,
+ 0x22BD22C8, 0xD55AD5F8, 0xBDFCBDC3, 0x48604878, 0xFF62FFCE, 0x4C964C07,
+ 0x416C4177, 0xC742C7E6, 0xEBF7EB24, 0x1C101C14, 0x5D7C5D63, 0x36283622,
+ 0x672767C0, 0xE98CE9AF, 0x441344F9, 0x149514EA, 0xF59CF5BB, 0xCFC7CF18,
+ 0x3F243F2D, 0xC046C0E3, 0x723B72DB, 0x5470546C, 0x29CA294C, 0xF0E3F035,
+ 0x088508FE, 0xC6CBC617, 0xF311F34F, 0x8CD08CE4, 0xA493A459, 0xCAB8CA96,
+ 0x68A6683B, 0xB883B84D, 0x38203828, 0xE5FFE52E, 0xAD9FAD56, 0x0B770B84,
+ 0xC8C3C81D, 0x99CC99FF, 0x580358ED, 0x196F199A, 0x0E080E0A, 0x95BF957E,
+ 0x70407050, 0xF7E7F730, 0x6E2B6ECF, 0x1FE21F6E, 0xB579B53D, 0x090C090F,
+ 0x61AA6134, 0x57825716, 0x9F419F0B, 0x9D3A9D80, 0x11EA1164, 0x25B925CD,
+ 0xAFE4AFDD, 0x459A4508, 0xDFA4DF8D, 0xA397A35C, 0xEA7EEAD5, 0x35DA3558,
+ 0xED7AEDD0, 0x431743FC, 0xF866F8CB, 0xFB94FBB1, 0x37A137D3, 0xFA1DFA40,
+ 0xC23DC268, 0xB4F0B4CC, 0x32DE325D, 0x9CB39C71, 0x560B56E7, 0xE372E3DA,
+ 0x87A78760, 0x151C151B, 0xF9EFF93A, 0x63D163BF, 0x345334A9, 0x9A3E9A85,
+ 0xB18FB142, 0x7C337CD1, 0x8826889B, 0x3D5F3DA6, 0xA1ECA1D7, 0xE476E4DF,
+ 0x812A8194, 0x91499101, 0x0F810FFB, 0xEE88EEAA, 0x16EE1661, 0xD721D773,
+ 0x97C497F5, 0xA51AA5A8, 0xFEEBFE3F, 0x6DD96DB5, 0x78C578AE, 0xC539C56D,
+ 0x1D991DE5, 0x76CD76A4, 0x3EAD3EDC, 0xCB31CB67, 0xB68BB647, 0xEF01EF5B,
+ 0x1218121E, 0x602360C5, 0x6ADD6AB0, 0x4D1F4DF6, 0xCE4ECEE9, 0xDE2DDE7C,
+ 0x55F9559D, 0x7E487E5A, 0x214F21B2, 0x03F2037A, 0xA065A026, 0x5E8E5E19,
+ 0x5A785A66, 0x655C654B, 0x6258624E, 0xFD19FD45, 0x068D06F4, 0x40E54086,
+ 0xF298F2BE, 0x335733AC, 0x17671790, 0x057F058E, 0xE805E85E, 0x4F644F7D,
+ 0x89AF896A, 0x10631095, 0x74B6742F, 0x0AFE0A75, 0x5CF55C92, 0x9BB79B74,
+ 0x2D3C2D33, 0x30A530D6, 0x2ECE2E49, 0x49E94989, 0x46684672, 0x77447755,
+ 0xA8E0A8D8, 0x964D9604, 0x284328BD, 0xA969A929, 0xD929D979, 0x862E8691,
+ 0xD1ACD187, 0xF415F44A, 0x8D598D15, 0xD6A8D682, 0xB90AB9BC, 0x429E420D,
+ 0xF66EF6C1, 0x2F472FB8, 0xDDDFDD06, 0x23342339, 0xCC35CC62, 0xF16AF1C4,
+ 0xC1CFC112, 0x85DC85EB, 0x8F228F9E, 0x71C971A1, 0x90C090F0, 0xAA9BAA53,
+ 0x018901F1, 0x8BD48BE1, 0x4EED4E8C, 0x8EAB8E6F, 0xAB12ABA2, 0x6FA26F3E,
+ 0xE60DE654, 0xDB52DBF2, 0x92BB927B, 0xB702B7B6, 0x692F69CA, 0x39A939D9,
+ 0xD3D7D30C, 0xA761A723, 0xA21EA2AD, 0xC3B4C399, 0x6C506C44, 0x07040705,
+ 0x04F6047F, 0x27C22746, 0xAC16ACA7, 0xD025D076, 0x50865013, 0xDC56DCF7,
+ 0x8455841A, 0xE109E151, 0x7ABE7A25, 0x139113EF},
+
+ {0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98,
+ 0x6580A365, 0xDFE476DF, 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866,
+ 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, 0x54E60D54, 0x4320C643,
+ 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77,
+ 0xBD2843BD, 0x32BC7532, 0xD47B37D4, 0x9B88269B, 0x700DFA70, 0xF94413F9,
+ 0xB1FB94B1, 0x5A7E485A, 0x7A03F27A, 0xE48CD0E4, 0x47B68B47, 0x3C24303C,
+ 0xA5E784A5, 0x416B5441, 0x06DDDF06, 0xC56023C5, 0x45FD1945, 0xA33A5BA3,
+ 0x68C23D68, 0x158D5915, 0x21ECF321, 0x3166AE31, 0x3E6FA23E, 0x16578216,
+ 0x95106395, 0x5BEF015B, 0x4DB8834D, 0x91862E91, 0xB56DD9B5, 0x1F83511F,
+ 0x53AA9B53, 0x635D7C63, 0x3B68A63B, 0x3FFEEB3F, 0xD630A5D6, 0x257ABE25,
+ 0xA7AC16A7, 0x0F090C0F, 0x35F0E335, 0x23A76123, 0xF090C0F0, 0xAFE98CAF,
+ 0x809D3A80, 0x925CF592, 0x810C7381, 0x27312C27, 0x76D02576, 0xE7560BE7,
+ 0x7B92BB7B, 0xE9CE4EE9, 0xF10189F1, 0x9F1E6B9F, 0xA93453A9, 0xC4F16AC4,
+ 0x99C3B499, 0x975BF197, 0x8347E183, 0x6B18E66B, 0xC822BDC8, 0x0E98450E,
+ 0x6E1FE26E, 0xC9B3F4C9, 0x2F74B62F, 0xCBF866CB, 0xFF99CCFF, 0xEA1495EA,
+ 0xED5803ED, 0xF7DC56F7, 0xE18BD4E1, 0x1B151C1B, 0xADA21EAD, 0x0CD3D70C,
+ 0x2BE2FB2B, 0x1DC8C31D, 0x195E8E19, 0xC22CB5C2, 0x8949E989, 0x12C1CF12,
+ 0x7E95BF7E, 0x207DBA20, 0x6411EA64, 0x840B7784, 0x6DC5396D, 0x6A89AF6A,
+ 0xD17C33D1, 0xA171C9A1, 0xCEFF62CE, 0x37BB7137, 0xFB0F81FB, 0x3DB5793D,
+ 0x51E10951, 0xDC3EADDC, 0x2D3F242D, 0xA476CDA4, 0x9D55F99D, 0xEE82D8EE,
+ 0x8640E586, 0xAE78C5AE, 0xCD25B9CD, 0x04964D04, 0x55774455, 0x0A0E080A,
+ 0x13508613, 0x30F7E730, 0xD337A1D3, 0x40FA1D40, 0x3461AA34, 0x8C4EED8C,
+ 0xB3B006B3, 0x6C54706C, 0x2A73B22A, 0x523BD252, 0x0B9F410B, 0x8B027B8B,
+ 0x88D8A088, 0x4FF3114F, 0x67CB3167, 0x4627C246, 0xC06727C0, 0xB4FC90B4,
+ 0x28382028, 0x7F04F67F, 0x78486078, 0x2EE5FF2E, 0x074C9607, 0x4B655C4B,
+ 0xC72BB1C7, 0x6F8EAB6F, 0x0D429E0D, 0xBBF59CBB, 0xF2DB52F2, 0xF34A1BF3,
+ 0xA63D5FA6, 0x59A49359, 0xBCB90ABC, 0x3AF9EF3A, 0xEF1391EF, 0xFE0885FE,
+ 0x01914901, 0x6116EE61, 0x7CDE2D7C, 0xB2214FB2, 0x42B18F42, 0xDB723BDB,
+ 0xB82F47B8, 0x48BF8748, 0x2CAE6D2C, 0xE3C046E3, 0x573CD657, 0x859A3E85,
+ 0x29A96929, 0x7D4F647D, 0x94812A94, 0x492ECE49, 0x17C6CB17, 0xCA692FCA,
+ 0xC3BDFCC3, 0x5CA3975C, 0x5EE8055E, 0xD0ED7AD0, 0x87D1AC87, 0x8E057F8E,
+ 0xBA64D5BA, 0xA8A51AA8, 0xB7264BB7, 0xB9BE0EB9, 0x6087A760, 0xF8D55AF8,
+ 0x22362822, 0x111B1411, 0xDE753FDE, 0x79D92979, 0xAAEE88AA, 0x332D3C33,
+ 0x5F794C5F, 0xB6B702B6, 0x96CAB896, 0x5835DA58, 0x9CC4B09C, 0xFC4317FC,
+ 0x1A84551A, 0xF64D1FF6, 0x1C598A1C, 0x38B27D38, 0xAC3357AC, 0x18CFC718,
+ 0xF4068DF4, 0x69537469, 0x749BB774, 0xF597C4F5, 0x56AD9F56, 0xDAE372DA,
+ 0xD5EA7ED5, 0x4AF4154A, 0x9E8F229E, 0xA2AB12A2, 0x4E62584E, 0xE85F07E8,
+ 0xE51D99E5, 0x39233439, 0xC1F66EC1, 0x446C5044, 0x5D32DE5D, 0x72466872,
+ 0x26A06526, 0x93CDBC93, 0x03DADB03, 0xC6BAF8C6, 0xFA9EC8FA, 0x82D6A882,
+ 0xCF6E2BCF, 0x50704050, 0xEB85DCEB, 0x750AFE75, 0x8A93328A, 0x8DDFA48D,
+ 0x4C29CA4C, 0x141C1014, 0x73D72173, 0xCCB4F0CC, 0x09D4D309, 0x108A5D10,
+ 0xE2510FE2, 0x00000000, 0x9A196F9A, 0xE01A9DE0, 0x8F94368F, 0xE6C742E6,
+ 0xECC94AEC, 0xFDD25EFD, 0xAB7FC1AB, 0xD8A8E0D8}
+};
+
+/* The exp_to_poly and poly_to_exp tables are used to perform efficient
+ * operations in GF(2^8) represented as GF(2)[x]/w(x) where
+ * w(x)=x^8+x^6+x^3+x^2+1. We care about doing that because it's part of the
+ * definition of the RS matrix in the key schedule. Elements of that field
+ * are polynomials of degree not greater than 7 and all coefficients 0 or 1,
+ * which can be represented naturally by bytes (just substitute x=2). In that
+ * form, GF(2^8) addition is the same as bitwise XOR, but GF(2^8)
+ * multiplication is inefficient without hardware support. To multiply
+ * faster, I make use of the fact x is a generator for the nonzero elements,
+ * so that every element p of GF(2)[x]/w(x) is either 0 or equal to (x)^n for
+ * some n in 0..254. Note that that caret is exponentiation in GF(2^8),
+ * *not* polynomial notation. So if I want to compute pq where p and q are
+ * in GF(2^8), I can just say:
+ * 1. if p=0 or q=0 then pq=0
+ * 2. otherwise, find m and n such that p=x^m and q=x^n
+ * 3. pq=(x^m)(x^n)=x^(m+n), so add m and n and find pq
+ * The translations in steps 2 and 3 are looked up in the tables
+ * poly_to_exp (for step 2) and exp_to_poly (for step 3). To see this
+ * in action, look at the CALC_S macro. As additional wrinkles, note that
+ * one of my operands is always a constant, so the poly_to_exp lookup on it
+ * is done in advance; I included the original values in the comments so
+ * readers can have some chance of recognizing that this *is* the RS matrix
+ * from the Twofish paper. I've only included the table entries I actually
+ * need; I never do a lookup on a variable input of zero and the biggest
+ * exponents I'll ever see are 254 (variable) and 237 (constant), so they'll
+ * never sum to more than 491. I'm repeating part of the exp_to_poly table
+ * so that I don't have to do mod-255 reduction in the exponent arithmetic.
+ * Since I know my constant operands are never zero, I only have to worry
+ * about zero values in the variable operand, and I do it with a simple
+ * conditional branch. I know conditionals are expensive, but I couldn't
+ * see a non-horrible way of avoiding them, and I did manage to group the
+ * statements so that each if covers four group multiplications. */
+
+static const byte poly_to_exp[255] = {
+ 0x00, 0x01, 0x17, 0x02, 0x2E, 0x18, 0x53, 0x03, 0x6A, 0x2F, 0x93, 0x19,
+ 0x34, 0x54, 0x45, 0x04, 0x5C, 0x6B, 0xB6, 0x30, 0xA6, 0x94, 0x4B, 0x1A,
+ 0x8C, 0x35, 0x81, 0x55, 0xAA, 0x46, 0x0D, 0x05, 0x24, 0x5D, 0x87, 0x6C,
+ 0x9B, 0xB7, 0xC1, 0x31, 0x2B, 0xA7, 0xA3, 0x95, 0x98, 0x4C, 0xCA, 0x1B,
+ 0xE6, 0x8D, 0x73, 0x36, 0xCD, 0x82, 0x12, 0x56, 0x62, 0xAB, 0xF0, 0x47,
+ 0x4F, 0x0E, 0xBD, 0x06, 0xD4, 0x25, 0xD2, 0x5E, 0x27, 0x88, 0x66, 0x6D,
+ 0xD6, 0x9C, 0x79, 0xB8, 0x08, 0xC2, 0xDF, 0x32, 0x68, 0x2C, 0xFD, 0xA8,
+ 0x8A, 0xA4, 0x5A, 0x96, 0x29, 0x99, 0x22, 0x4D, 0x60, 0xCB, 0xE4, 0x1C,
+ 0x7B, 0xE7, 0x3B, 0x8E, 0x9E, 0x74, 0xF4, 0x37, 0xD8, 0xCE, 0xF9, 0x83,
+ 0x6F, 0x13, 0xB2, 0x57, 0xE1, 0x63, 0xDC, 0xAC, 0xC4, 0xF1, 0xAF, 0x48,
+ 0x0A, 0x50, 0x42, 0x0F, 0xBA, 0xBE, 0xC7, 0x07, 0xDE, 0xD5, 0x78, 0x26,
+ 0x65, 0xD3, 0xD1, 0x5F, 0xE3, 0x28, 0x21, 0x89, 0x59, 0x67, 0xFC, 0x6E,
+ 0xB1, 0xD7, 0xF8, 0x9D, 0xF3, 0x7A, 0x3A, 0xB9, 0xC6, 0x09, 0x41, 0xC3,
+ 0xAE, 0xE0, 0xDB, 0x33, 0x44, 0x69, 0x92, 0x2D, 0x52, 0xFE, 0x16, 0xA9,
+ 0x0C, 0x8B, 0x80, 0xA5, 0x4A, 0x5B, 0xB5, 0x97, 0xC9, 0x2A, 0xA2, 0x9A,
+ 0xC0, 0x23, 0x86, 0x4E, 0xBC, 0x61, 0xEF, 0xCC, 0x11, 0xE5, 0x72, 0x1D,
+ 0x3D, 0x7C, 0xEB, 0xE8, 0xE9, 0x3C, 0xEA, 0x8F, 0x7D, 0x9F, 0xEC, 0x75,
+ 0x1E, 0xF5, 0x3E, 0x38, 0xF6, 0xD9, 0x3F, 0xCF, 0x76, 0xFA, 0x1F, 0x84,
+ 0xA0, 0x70, 0xED, 0x14, 0x90, 0xB3, 0x7E, 0x58, 0xFB, 0xE2, 0x20, 0x64,
+ 0xD0, 0xDD, 0x77, 0xAD, 0xDA, 0xC5, 0x40, 0xF2, 0x39, 0xB0, 0xF7, 0x49,
+ 0xB4, 0x0B, 0x7F, 0x51, 0x15, 0x43, 0x91, 0x10, 0x71, 0xBB, 0xEE, 0xBF,
+ 0x85, 0xC8, 0xA1
+};
+
+static const byte exp_to_poly[492] = {
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x4D, 0x9A, 0x79, 0xF2,
+ 0xA9, 0x1F, 0x3E, 0x7C, 0xF8, 0xBD, 0x37, 0x6E, 0xDC, 0xF5, 0xA7, 0x03,
+ 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xCD, 0xD7, 0xE3, 0x8B, 0x5B, 0xB6,
+ 0x21, 0x42, 0x84, 0x45, 0x8A, 0x59, 0xB2, 0x29, 0x52, 0xA4, 0x05, 0x0A,
+ 0x14, 0x28, 0x50, 0xA0, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xED, 0x97, 0x63,
+ 0xC6, 0xC1, 0xCF, 0xD3, 0xEB, 0x9B, 0x7B, 0xF6, 0xA1, 0x0F, 0x1E, 0x3C,
+ 0x78, 0xF0, 0xAD, 0x17, 0x2E, 0x5C, 0xB8, 0x3D, 0x7A, 0xF4, 0xA5, 0x07,
+ 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0x8D, 0x57, 0xAE, 0x11, 0x22, 0x44, 0x88,
+ 0x5D, 0xBA, 0x39, 0x72, 0xE4, 0x85, 0x47, 0x8E, 0x51, 0xA2, 0x09, 0x12,
+ 0x24, 0x48, 0x90, 0x6D, 0xDA, 0xF9, 0xBF, 0x33, 0x66, 0xCC, 0xD5, 0xE7,
+ 0x83, 0x4B, 0x96, 0x61, 0xC2, 0xC9, 0xDF, 0xF3, 0xAB, 0x1B, 0x36, 0x6C,
+ 0xD8, 0xFD, 0xB7, 0x23, 0x46, 0x8C, 0x55, 0xAA, 0x19, 0x32, 0x64, 0xC8,
+ 0xDD, 0xF7, 0xA3, 0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x2D, 0x5A, 0xB4, 0x25,
+ 0x4A, 0x94, 0x65, 0xCA, 0xD9, 0xFF, 0xB3, 0x2B, 0x56, 0xAC, 0x15, 0x2A,
+ 0x54, 0xA8, 0x1D, 0x3A, 0x74, 0xE8, 0x9D, 0x77, 0xEE, 0x91, 0x6F, 0xDE,
+ 0xF1, 0xAF, 0x13, 0x26, 0x4C, 0x98, 0x7D, 0xFA, 0xB9, 0x3F, 0x7E, 0xFC,
+ 0xB5, 0x27, 0x4E, 0x9C, 0x75, 0xEA, 0x99, 0x7F, 0xFE, 0xB1, 0x2F, 0x5E,
+ 0xBC, 0x35, 0x6A, 0xD4, 0xE5, 0x87, 0x43, 0x86, 0x41, 0x82, 0x49, 0x92,
+ 0x69, 0xD2, 0xE9, 0x9F, 0x73, 0xE6, 0x81, 0x4F, 0x9E, 0x71, 0xE2, 0x89,
+ 0x5F, 0xBE, 0x31, 0x62, 0xC4, 0xC5, 0xC7, 0xC3, 0xCB, 0xDB, 0xFB, 0xBB,
+ 0x3B, 0x76, 0xEC, 0x95, 0x67, 0xCE, 0xD1, 0xEF, 0x93, 0x6B, 0xD6, 0xE1,
+ 0x8F, 0x53, 0xA6, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x4D,
+ 0x9A, 0x79, 0xF2, 0xA9, 0x1F, 0x3E, 0x7C, 0xF8, 0xBD, 0x37, 0x6E, 0xDC,
+ 0xF5, 0xA7, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xCD, 0xD7, 0xE3,
+ 0x8B, 0x5B, 0xB6, 0x21, 0x42, 0x84, 0x45, 0x8A, 0x59, 0xB2, 0x29, 0x52,
+ 0xA4, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x0D, 0x1A, 0x34, 0x68, 0xD0,
+ 0xED, 0x97, 0x63, 0xC6, 0xC1, 0xCF, 0xD3, 0xEB, 0x9B, 0x7B, 0xF6, 0xA1,
+ 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0xAD, 0x17, 0x2E, 0x5C, 0xB8, 0x3D, 0x7A,
+ 0xF4, 0xA5, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0x8D, 0x57, 0xAE, 0x11,
+ 0x22, 0x44, 0x88, 0x5D, 0xBA, 0x39, 0x72, 0xE4, 0x85, 0x47, 0x8E, 0x51,
+ 0xA2, 0x09, 0x12, 0x24, 0x48, 0x90, 0x6D, 0xDA, 0xF9, 0xBF, 0x33, 0x66,
+ 0xCC, 0xD5, 0xE7, 0x83, 0x4B, 0x96, 0x61, 0xC2, 0xC9, 0xDF, 0xF3, 0xAB,
+ 0x1B, 0x36, 0x6C, 0xD8, 0xFD, 0xB7, 0x23, 0x46, 0x8C, 0x55, 0xAA, 0x19,
+ 0x32, 0x64, 0xC8, 0xDD, 0xF7, 0xA3, 0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x2D,
+ 0x5A, 0xB4, 0x25, 0x4A, 0x94, 0x65, 0xCA, 0xD9, 0xFF, 0xB3, 0x2B, 0x56,
+ 0xAC, 0x15, 0x2A, 0x54, 0xA8, 0x1D, 0x3A, 0x74, 0xE8, 0x9D, 0x77, 0xEE,
+ 0x91, 0x6F, 0xDE, 0xF1, 0xAF, 0x13, 0x26, 0x4C, 0x98, 0x7D, 0xFA, 0xB9,
+ 0x3F, 0x7E, 0xFC, 0xB5, 0x27, 0x4E, 0x9C, 0x75, 0xEA, 0x99, 0x7F, 0xFE,
+ 0xB1, 0x2F, 0x5E, 0xBC, 0x35, 0x6A, 0xD4, 0xE5, 0x87, 0x43, 0x86, 0x41,
+ 0x82, 0x49, 0x92, 0x69, 0xD2, 0xE9, 0x9F, 0x73, 0xE6, 0x81, 0x4F, 0x9E,
+ 0x71, 0xE2, 0x89, 0x5F, 0xBE, 0x31, 0x62, 0xC4, 0xC5, 0xC7, 0xC3, 0xCB
+};
+
+
+/* The table constants are indices of
+ * S-box entries, preprocessed through q0 and q1. */
+static byte calc_sb_tbl[512] = {
+ 0xA9, 0x75, 0x67, 0xF3, 0xB3, 0xC6, 0xE8, 0xF4,
+ 0x04, 0xDB, 0xFD, 0x7B, 0xA3, 0xFB, 0x76, 0xC8,
+ 0x9A, 0x4A, 0x92, 0xD3, 0x80, 0xE6, 0x78, 0x6B,
+ 0xE4, 0x45, 0xDD, 0x7D, 0xD1, 0xE8, 0x38, 0x4B,
+ 0x0D, 0xD6, 0xC6, 0x32, 0x35, 0xD8, 0x98, 0xFD,
+ 0x18, 0x37, 0xF7, 0x71, 0xEC, 0xF1, 0x6C, 0xE1,
+ 0x43, 0x30, 0x75, 0x0F, 0x37, 0xF8, 0x26, 0x1B,
+ 0xFA, 0x87, 0x13, 0xFA, 0x94, 0x06, 0x48, 0x3F,
+ 0xF2, 0x5E, 0xD0, 0xBA, 0x8B, 0xAE, 0x30, 0x5B,
+ 0x84, 0x8A, 0x54, 0x00, 0xDF, 0xBC, 0x23, 0x9D,
+ 0x19, 0x6D, 0x5B, 0xC1, 0x3D, 0xB1, 0x59, 0x0E,
+ 0xF3, 0x80, 0xAE, 0x5D, 0xA2, 0xD2, 0x82, 0xD5,
+ 0x63, 0xA0, 0x01, 0x84, 0x83, 0x07, 0x2E, 0x14,
+ 0xD9, 0xB5, 0x51, 0x90, 0x9B, 0x2C, 0x7C, 0xA3,
+ 0xA6, 0xB2, 0xEB, 0x73, 0xA5, 0x4C, 0xBE, 0x54,
+ 0x16, 0x92, 0x0C, 0x74, 0xE3, 0x36, 0x61, 0x51,
+ 0xC0, 0x38, 0x8C, 0xB0, 0x3A, 0xBD, 0xF5, 0x5A,
+ 0x73, 0xFC, 0x2C, 0x60, 0x25, 0x62, 0x0B, 0x96,
+ 0xBB, 0x6C, 0x4E, 0x42, 0x89, 0xF7, 0x6B, 0x10,
+ 0x53, 0x7C, 0x6A, 0x28, 0xB4, 0x27, 0xF1, 0x8C,
+ 0xE1, 0x13, 0xE6, 0x95, 0xBD, 0x9C, 0x45, 0xC7,
+ 0xE2, 0x24, 0xF4, 0x46, 0xB6, 0x3B, 0x66, 0x70,
+ 0xCC, 0xCA, 0x95, 0xE3, 0x03, 0x85, 0x56, 0xCB,
+ 0xD4, 0x11, 0x1C, 0xD0, 0x1E, 0x93, 0xD7, 0xB8,
+ 0xFB, 0xA6, 0xC3, 0x83, 0x8E, 0x20, 0xB5, 0xFF,
+ 0xE9, 0x9F, 0xCF, 0x77, 0xBF, 0xC3, 0xBA, 0xCC,
+ 0xEA, 0x03, 0x77, 0x6F, 0x39, 0x08, 0xAF, 0xBF,
+ 0x33, 0x40, 0xC9, 0xE7, 0x62, 0x2B, 0x71, 0xE2,
+ 0x81, 0x79, 0x79, 0x0C, 0x09, 0xAA, 0xAD, 0x82,
+ 0x24, 0x41, 0xCD, 0x3A, 0xF9, 0xEA, 0xD8, 0xB9,
+ 0xE5, 0xE4, 0xC5, 0x9A, 0xB9, 0xA4, 0x4D, 0x97,
+ 0x44, 0x7E, 0x08, 0xDA, 0x86, 0x7A, 0xE7, 0x17,
+ 0xA1, 0x66, 0x1D, 0x94, 0xAA, 0xA1, 0xED, 0x1D,
+ 0x06, 0x3D, 0x70, 0xF0, 0xB2, 0xDE, 0xD2, 0xB3,
+ 0x41, 0x0B, 0x7B, 0x72, 0xA0, 0xA7, 0x11, 0x1C,
+ 0x31, 0xEF, 0xC2, 0xD1, 0x27, 0x53, 0x90, 0x3E,
+ 0x20, 0x8F, 0xF6, 0x33, 0x60, 0x26, 0xFF, 0x5F,
+ 0x96, 0xEC, 0x5C, 0x76, 0xB1, 0x2A, 0xAB, 0x49,
+ 0x9E, 0x81, 0x9C, 0x88, 0x52, 0xEE, 0x1B, 0x21,
+ 0x5F, 0xC4, 0x93, 0x1A, 0x0A, 0xEB, 0xEF, 0xD9,
+ 0x91, 0xC5, 0x85, 0x39, 0x49, 0x99, 0xEE, 0xCD,
+ 0x2D, 0xAD, 0x4F, 0x31, 0x8F, 0x8B, 0x3B, 0x01,
+ 0x47, 0x18, 0x87, 0x23, 0x6D, 0xDD, 0x46, 0x1F,
+ 0xD6, 0x4E, 0x3E, 0x2D, 0x69, 0xF9, 0x64, 0x48,
+ 0x2A, 0x4F, 0xCE, 0xF2, 0xCB, 0x65, 0x2F, 0x8E,
+ 0xFC, 0x78, 0x97, 0x5C, 0x05, 0x58, 0x7A, 0x19,
+ 0xAC, 0x8D, 0x7F, 0xE5, 0xD5, 0x98, 0x1A, 0x57,
+ 0x4B, 0x67, 0x0E, 0x7F, 0xA7, 0x05, 0x5A, 0x64,
+ 0x28, 0xAF, 0x14, 0x63, 0x3F, 0xB6, 0x29, 0xFE,
+ 0x88, 0xF5, 0x3C, 0xB7, 0x4C, 0x3C, 0x02, 0xA5,
+ 0xB8, 0xCE, 0xDA, 0xE9, 0xB0, 0x68, 0x17, 0x44,
+ 0x55, 0xE0, 0x1F, 0x4D, 0x8A, 0x43, 0x7D, 0x69,
+ 0x57, 0x29, 0xC7, 0x2E, 0x8D, 0xAC, 0x74, 0x15,
+ 0xB7, 0x59, 0xC4, 0xA8, 0x9F, 0x0A, 0x72, 0x9E,
+ 0x7E, 0x6E, 0x15, 0x47, 0x22, 0xDF, 0x12, 0x34,
+ 0x58, 0x35, 0x07, 0x6A, 0x99, 0xCF, 0x34, 0xDC,
+ 0x6E, 0x22, 0x50, 0xC9, 0xDE, 0xC0, 0x68, 0x9B,
+ 0x65, 0x89, 0xBC, 0xD4, 0xDB, 0xED, 0xF8, 0xAB,
+ 0xC8, 0x12, 0xA8, 0xA2, 0x2B, 0x0D, 0x40, 0x52,
+ 0xDC, 0xBB, 0xFE, 0x02, 0x32, 0x2F, 0xA4, 0xA9,
+ 0xCA, 0xD7, 0x10, 0x61, 0x21, 0x1E, 0xF0, 0xB4,
+ 0xD3, 0x50, 0x5D, 0x04, 0x0F, 0xF6, 0x00, 0xC2,
+ 0x6F, 0x16, 0x9D, 0x25, 0x36, 0x86, 0x42, 0x56,
+ 0x4A, 0x55, 0x5E, 0x09, 0xC1, 0xBE, 0xE0, 0x91
+};
+/* Macro to perform one column of the RS matrix multiplication. The
+ * parameters a, b, c, and d are the four bytes of output; i is the index
+ * of the key bytes, and w, x, y, and z, are the column of constants from
+ * the RS matrix, preprocessed through the poly_to_exp table. */
+
+#define CALC_S(a, b, c, d, i, w, x, y, z) \
+ if (key[i]) { \
+ tmp = poly_to_exp[key[i] - 1]; \
+ (a) ^= exp_to_poly[tmp + (w)]; \
+ (b) ^= exp_to_poly[tmp + (x)]; \
+ (c) ^= exp_to_poly[tmp + (y)]; \
+ (d) ^= exp_to_poly[tmp + (z)]; \
+ }
+
+/* Macros to calculate the key-dependent S-boxes for a 128-bit key using
+ * the S vector from CALC_S. CALC_SB_2 computes a single entry in all
+ * four S-boxes, where i is the index of the entry to compute, and a and b
+ * are the index numbers preprocessed through the q0 and q1 tables
+ * respectively. CALC_SB is simply a convenience to make the code shorter;
+ * it calls CALC_SB_2 four times with consecutive indices from i to i+3,
+ * using the remaining parameters two by two. */
+
+#define CALC_SB_2(i, a, b) \
+ ctx->s[0][i] = mds[0][q0[(a) ^ sa] ^ se]; \
+ ctx->s[1][i] = mds[1][q0[(b) ^ sb] ^ sf]; \
+ ctx->s[2][i] = mds[2][q1[(a) ^ sc] ^ sg]; \
+ ctx->s[3][i] = mds[3][q1[(b) ^ sd] ^ sh]
+
+#define CALC_SB(i, a, b, c, d, e, f, g, h) \
+ CALC_SB_2 (i, a, b); CALC_SB_2 ((i)+1, c, d); \
+ CALC_SB_2 ((i)+2, e, f); CALC_SB_2 ((i)+3, g, h)
+
+/* Macros exactly like CALC_SB and CALC_SB_2, but for 256-bit keys. */
+
+#define CALC_SB256_2(i, a, b) \
+ ctx->s[0][i] = mds[0][q0[q0[q1[(b) ^ sa] ^ se] ^ si] ^ sm]; \
+ ctx->s[1][i] = mds[1][q0[q1[q1[(a) ^ sb] ^ sf] ^ sj] ^ sn]; \
+ ctx->s[2][i] = mds[2][q1[q0[q0[(a) ^ sc] ^ sg] ^ sk] ^ so]; \
+ ctx->s[3][i] = mds[3][q1[q1[q0[(b) ^ sd] ^ sh] ^ sl] ^ sp];
+
+#define CALC_SB256(i, a, b, c, d, e, f, g, h) \
+ CALC_SB256_2 (i, a, b); CALC_SB256_2 ((i)+1, c, d); \
+ CALC_SB256_2 ((i)+2, e, f); CALC_SB256_2 ((i)+3, g, h)
+
+/* Macros to calculate the whitening and round subkeys. CALC_K_2 computes the
+ * last two stages of the h() function for a given index (either 2i or 2i+1).
+ * a, b, c, and d are the four bytes going into the last two stages. For
+ * 128-bit keys, this is the entire h() function and a and c are the index
+ * preprocessed through q0 and q1 respectively; for longer keys they are the
+ * output of previous stages. j is the index of the first key byte to use.
+ * CALC_K computes a pair of subkeys for 128-bit Twofish, by calling CALC_K_2
+ * twice, doing the Pseudo-Hadamard Transform, and doing the necessary
+ * rotations. Its parameters are: a, the array to write the results into,
+ * j, the index of the first output entry, k and l, the preprocessed indices
+ * for index 2i, and m and n, the preprocessed indices for index 2i+1.
+ * CALC_K256_2 expands CALC_K_2 to handle 256-bit keys, by doing two
+ * additional lookup-and-XOR stages. The parameters a and b are the index
+ * preprocessed through q0 and q1 respectively; j is the index of the first
+ * key byte to use. CALC_K256 is identical to CALC_K but for using the
+ * CALC_K256_2 macro instead of CALC_K_2. */
+
+#define CALC_K_2(a, b, c, d, j) \
+ mds[0][q0[a ^ key[(j) + 8]] ^ key[j]] \
+ ^ mds[1][q0[b ^ key[(j) + 9]] ^ key[(j) + 1]] \
+ ^ mds[2][q1[c ^ key[(j) + 10]] ^ key[(j) + 2]] \
+ ^ mds[3][q1[d ^ key[(j) + 11]] ^ key[(j) + 3]]
+
+#define CALC_K(a, j, k, l, m, n) \
+ x = CALC_K_2 (k, l, k, l, 0); \
+ y = CALC_K_2 (m, n, m, n, 4); \
+ y = (y << 8) + (y >> 24); \
+ x += y; y += x; ctx->a[j] = x; \
+ ctx->a[(j) + 1] = (y << 9) + (y >> 23)
+
+#define CALC_K256_2(a, b, j) \
+ CALC_K_2 (q0[q1[b ^ key[(j) + 24]] ^ key[(j) + 16]], \
+ q1[q1[a ^ key[(j) + 25]] ^ key[(j) + 17]], \
+ q0[q0[a ^ key[(j) + 26]] ^ key[(j) + 18]], \
+ q1[q0[b ^ key[(j) + 27]] ^ key[(j) + 19]], j)
+
+#define CALC_K256(a, j, k, l, m, n) \
+ x = CALC_K256_2 (k, l, 0); \
+ y = CALC_K256_2 (m, n, 4); \
+ y = (y << 8) + (y >> 24); \
+ x += y; y += x; ctx->a[j] = x; \
+ ctx->a[(j) + 1] = (y << 9) + (y >> 23)
+
+
+
+/* Perform the key setup. Note that this works only with 128- and 256-bit
+ * keys, despite the API that looks like it might support other sizes. */
+
+static gcry_err_code_t
+do_twofish_setkey (TWOFISH_context *ctx, const byte *key, const unsigned keylen)
+{
+ int i, j, k;
+
+ /* Temporaries for CALC_K. */
+ u32 x, y;
+
+ /* The S vector used to key the S-boxes, split up into individual bytes.
+ * 128-bit keys use only sa through sh; 256-bit use all of them. */
+ byte sa = 0, sb = 0, sc = 0, sd = 0, se = 0, sf = 0, sg = 0, sh = 0;
+ byte si = 0, sj = 0, sk = 0, sl = 0, sm = 0, sn = 0, so = 0, sp = 0;
+
+ /* Temporary for CALC_S. */
+ byte tmp;
+
+ /* Flags for self-test. */
+ static int initialized = 0;
+ static const char *selftest_failed=0;
+
+ /* Check key length. */
+ if( ( ( keylen - 16 ) | 16 ) != 16 )
+ return GPG_ERR_INV_KEYLEN;
+
+ /* Do self-test if necessary. */
+ if (!initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+ if( selftest_failed )
+ log_error("%s\n", selftest_failed );
+ }
+ if( selftest_failed )
+ return GPG_ERR_SELFTEST_FAILED;
+
+ /* Compute the first two words of the S vector. The magic numbers are
+ * the entries of the RS matrix, preprocessed through poly_to_exp. The
+ * numbers in the comments are the original (polynomial form) matrix
+ * entries. */
+ CALC_S (sa, sb, sc, sd, 0, 0x00, 0x2D, 0x01, 0x2D); /* 01 A4 02 A4 */
+ CALC_S (sa, sb, sc, sd, 1, 0x2D, 0xA4, 0x44, 0x8A); /* A4 56 A1 55 */
+ CALC_S (sa, sb, sc, sd, 2, 0x8A, 0xD5, 0xBF, 0xD1); /* 55 82 FC 87 */
+ CALC_S (sa, sb, sc, sd, 3, 0xD1, 0x7F, 0x3D, 0x99); /* 87 F3 C1 5A */
+ CALC_S (sa, sb, sc, sd, 4, 0x99, 0x46, 0x66, 0x96); /* 5A 1E 47 58 */
+ CALC_S (sa, sb, sc, sd, 5, 0x96, 0x3C, 0x5B, 0xED); /* 58 C6 AE DB */
+ CALC_S (sa, sb, sc, sd, 6, 0xED, 0x37, 0x4F, 0xE0); /* DB 68 3D 9E */
+ CALC_S (sa, sb, sc, sd, 7, 0xE0, 0xD0, 0x8C, 0x17); /* 9E E5 19 03 */
+ CALC_S (se, sf, sg, sh, 8, 0x00, 0x2D, 0x01, 0x2D); /* 01 A4 02 A4 */
+ CALC_S (se, sf, sg, sh, 9, 0x2D, 0xA4, 0x44, 0x8A); /* A4 56 A1 55 */
+ CALC_S (se, sf, sg, sh, 10, 0x8A, 0xD5, 0xBF, 0xD1); /* 55 82 FC 87 */
+ CALC_S (se, sf, sg, sh, 11, 0xD1, 0x7F, 0x3D, 0x99); /* 87 F3 C1 5A */
+ CALC_S (se, sf, sg, sh, 12, 0x99, 0x46, 0x66, 0x96); /* 5A 1E 47 58 */
+ CALC_S (se, sf, sg, sh, 13, 0x96, 0x3C, 0x5B, 0xED); /* 58 C6 AE DB */
+ CALC_S (se, sf, sg, sh, 14, 0xED, 0x37, 0x4F, 0xE0); /* DB 68 3D 9E */
+ CALC_S (se, sf, sg, sh, 15, 0xE0, 0xD0, 0x8C, 0x17); /* 9E E5 19 03 */
+
+ if (keylen == 32) /* 256-bit key */
+ {
+ /* Calculate the remaining two words of the S vector */
+ CALC_S (si, sj, sk, sl, 16, 0x00, 0x2D, 0x01, 0x2D); /* 01 A4 02 A4 */
+ CALC_S (si, sj, sk, sl, 17, 0x2D, 0xA4, 0x44, 0x8A); /* A4 56 A1 55 */
+ CALC_S (si, sj, sk, sl, 18, 0x8A, 0xD5, 0xBF, 0xD1); /* 55 82 FC 87 */
+ CALC_S (si, sj, sk, sl, 19, 0xD1, 0x7F, 0x3D, 0x99); /* 87 F3 C1 5A */
+ CALC_S (si, sj, sk, sl, 20, 0x99, 0x46, 0x66, 0x96); /* 5A 1E 47 58 */
+ CALC_S (si, sj, sk, sl, 21, 0x96, 0x3C, 0x5B, 0xED); /* 58 C6 AE DB */
+ CALC_S (si, sj, sk, sl, 22, 0xED, 0x37, 0x4F, 0xE0); /* DB 68 3D 9E */
+ CALC_S (si, sj, sk, sl, 23, 0xE0, 0xD0, 0x8C, 0x17); /* 9E E5 19 03 */
+ CALC_S (sm, sn, so, sp, 24, 0x00, 0x2D, 0x01, 0x2D); /* 01 A4 02 A4 */
+ CALC_S (sm, sn, so, sp, 25, 0x2D, 0xA4, 0x44, 0x8A); /* A4 56 A1 55 */
+ CALC_S (sm, sn, so, sp, 26, 0x8A, 0xD5, 0xBF, 0xD1); /* 55 82 FC 87 */
+ CALC_S (sm, sn, so, sp, 27, 0xD1, 0x7F, 0x3D, 0x99); /* 87 F3 C1 5A */
+ CALC_S (sm, sn, so, sp, 28, 0x99, 0x46, 0x66, 0x96); /* 5A 1E 47 58 */
+ CALC_S (sm, sn, so, sp, 29, 0x96, 0x3C, 0x5B, 0xED); /* 58 C6 AE DB */
+ CALC_S (sm, sn, so, sp, 30, 0xED, 0x37, 0x4F, 0xE0); /* DB 68 3D 9E */
+ CALC_S (sm, sn, so, sp, 31, 0xE0, 0xD0, 0x8C, 0x17); /* 9E E5 19 03 */
+
+ /* Compute the S-boxes. */
+ for(i=j=0,k=1; i < 256; i++, j += 2, k += 2 )
+ {
+ CALC_SB256_2( i, calc_sb_tbl[j], calc_sb_tbl[k] );
+ }
+
+ /* Calculate whitening and round subkeys. The constants are
+ * indices of subkeys, preprocessed through q0 and q1. */
+ CALC_K256 (w, 0, 0xA9, 0x75, 0x67, 0xF3);
+ CALC_K256 (w, 2, 0xB3, 0xC6, 0xE8, 0xF4);
+ CALC_K256 (w, 4, 0x04, 0xDB, 0xFD, 0x7B);
+ CALC_K256 (w, 6, 0xA3, 0xFB, 0x76, 0xC8);
+ CALC_K256 (k, 0, 0x9A, 0x4A, 0x92, 0xD3);
+ CALC_K256 (k, 2, 0x80, 0xE6, 0x78, 0x6B);
+ CALC_K256 (k, 4, 0xE4, 0x45, 0xDD, 0x7D);
+ CALC_K256 (k, 6, 0xD1, 0xE8, 0x38, 0x4B);
+ CALC_K256 (k, 8, 0x0D, 0xD6, 0xC6, 0x32);
+ CALC_K256 (k, 10, 0x35, 0xD8, 0x98, 0xFD);
+ CALC_K256 (k, 12, 0x18, 0x37, 0xF7, 0x71);
+ CALC_K256 (k, 14, 0xEC, 0xF1, 0x6C, 0xE1);
+ CALC_K256 (k, 16, 0x43, 0x30, 0x75, 0x0F);
+ CALC_K256 (k, 18, 0x37, 0xF8, 0x26, 0x1B);
+ CALC_K256 (k, 20, 0xFA, 0x87, 0x13, 0xFA);
+ CALC_K256 (k, 22, 0x94, 0x06, 0x48, 0x3F);
+ CALC_K256 (k, 24, 0xF2, 0x5E, 0xD0, 0xBA);
+ CALC_K256 (k, 26, 0x8B, 0xAE, 0x30, 0x5B);
+ CALC_K256 (k, 28, 0x84, 0x8A, 0x54, 0x00);
+ CALC_K256 (k, 30, 0xDF, 0xBC, 0x23, 0x9D);
+ }
+ else
+ {
+ /* Compute the S-boxes. */
+ for(i=j=0,k=1; i < 256; i++, j += 2, k += 2 )
+ {
+ CALC_SB_2( i, calc_sb_tbl[j], calc_sb_tbl[k] );
+ }
+
+ /* Calculate whitening and round subkeys. The constants are
+ * indices of subkeys, preprocessed through q0 and q1. */
+ CALC_K (w, 0, 0xA9, 0x75, 0x67, 0xF3);
+ CALC_K (w, 2, 0xB3, 0xC6, 0xE8, 0xF4);
+ CALC_K (w, 4, 0x04, 0xDB, 0xFD, 0x7B);
+ CALC_K (w, 6, 0xA3, 0xFB, 0x76, 0xC8);
+ CALC_K (k, 0, 0x9A, 0x4A, 0x92, 0xD3);
+ CALC_K (k, 2, 0x80, 0xE6, 0x78, 0x6B);
+ CALC_K (k, 4, 0xE4, 0x45, 0xDD, 0x7D);
+ CALC_K (k, 6, 0xD1, 0xE8, 0x38, 0x4B);
+ CALC_K (k, 8, 0x0D, 0xD6, 0xC6, 0x32);
+ CALC_K (k, 10, 0x35, 0xD8, 0x98, 0xFD);
+ CALC_K (k, 12, 0x18, 0x37, 0xF7, 0x71);
+ CALC_K (k, 14, 0xEC, 0xF1, 0x6C, 0xE1);
+ CALC_K (k, 16, 0x43, 0x30, 0x75, 0x0F);
+ CALC_K (k, 18, 0x37, 0xF8, 0x26, 0x1B);
+ CALC_K (k, 20, 0xFA, 0x87, 0x13, 0xFA);
+ CALC_K (k, 22, 0x94, 0x06, 0x48, 0x3F);
+ CALC_K (k, 24, 0xF2, 0x5E, 0xD0, 0xBA);
+ CALC_K (k, 26, 0x8B, 0xAE, 0x30, 0x5B);
+ CALC_K (k, 28, 0x84, 0x8A, 0x54, 0x00);
+ CALC_K (k, 30, 0xDF, 0xBC, 0x23, 0x9D);
+ }
+
+ return 0;
+}
+
+static gcry_err_code_t
+twofish_setkey (void *context, const byte *key, unsigned int keylen)
+{
+ TWOFISH_context *ctx = context;
+ int rc = do_twofish_setkey (ctx, key, keylen);
+ _gcry_burn_stack (23+6*sizeof(void*));
+ return rc;
+}
+
+
+
+/* Macros to compute the g() function in the encryption and decryption
+ * rounds. G1 is the straight g() function; G2 includes the 8-bit
+ * rotation for the high 32-bit word. */
+
+#define G1(a) \
+ (ctx->s[0][(a) & 0xFF]) ^ (ctx->s[1][((a) >> 8) & 0xFF]) \
+ ^ (ctx->s[2][((a) >> 16) & 0xFF]) ^ (ctx->s[3][(a) >> 24])
+
+#define G2(b) \
+ (ctx->s[1][(b) & 0xFF]) ^ (ctx->s[2][((b) >> 8) & 0xFF]) \
+ ^ (ctx->s[3][((b) >> 16) & 0xFF]) ^ (ctx->s[0][(b) >> 24])
+
+/* Encryption and decryption Feistel rounds. Each one calls the two g()
+ * macros, does the PHT, and performs the XOR and the appropriate bit
+ * rotations. The parameters are the round number (used to select subkeys),
+ * and the four 32-bit chunks of the text. */
+
+#define ENCROUND(n, a, b, c, d) \
+ x = G1 (a); y = G2 (b); \
+ x += y; y += x + ctx->k[2 * (n) + 1]; \
+ (c) ^= x + ctx->k[2 * (n)]; \
+ (c) = ((c) >> 1) + ((c) << 31); \
+ (d) = (((d) << 1)+((d) >> 31)) ^ y
+
+#define DECROUND(n, a, b, c, d) \
+ x = G1 (a); y = G2 (b); \
+ x += y; y += x; \
+ (d) ^= y + ctx->k[2 * (n) + 1]; \
+ (d) = ((d) >> 1) + ((d) << 31); \
+ (c) = (((c) << 1)+((c) >> 31)); \
+ (c) ^= (x + ctx->k[2 * (n)])
+
+/* Encryption and decryption cycles; each one is simply two Feistel rounds
+ * with the 32-bit chunks re-ordered to simulate the "swap" */
+
+#define ENCCYCLE(n) \
+ ENCROUND (2 * (n), a, b, c, d); \
+ ENCROUND (2 * (n) + 1, c, d, a, b)
+
+#define DECCYCLE(n) \
+ DECROUND (2 * (n) + 1, c, d, a, b); \
+ DECROUND (2 * (n), a, b, c, d)
+
+/* Macros to convert the input and output bytes into 32-bit words,
+ * and simultaneously perform the whitening step. INPACK packs word
+ * number n into the variable named by x, using whitening subkey number m.
+ * OUTUNPACK unpacks word number n from the variable named by x, using
+ * whitening subkey number m. */
+
+#define INPACK(n, x, m) \
+ x = in[4 * (n)] ^ (in[4 * (n) + 1] << 8) \
+ ^ (in[4 * (n) + 2] << 16) ^ (in[4 * (n) + 3] << 24) ^ ctx->w[m]
+
+#define OUTUNPACK(n, x, m) \
+ x ^= ctx->w[m]; \
+ out[4 * (n)] = x; out[4 * (n) + 1] = x >> 8; \
+ out[4 * (n) + 2] = x >> 16; out[4 * (n) + 3] = x >> 24
+
+/* Encrypt one block. in and out may be the same. */
+
+static void
+do_twofish_encrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
+{
+ /* The four 32-bit chunks of the text. */
+ u32 a, b, c, d;
+
+ /* Temporaries used by the round function. */
+ u32 x, y;
+
+ /* Input whitening and packing. */
+ INPACK (0, a, 0);
+ INPACK (1, b, 1);
+ INPACK (2, c, 2);
+ INPACK (3, d, 3);
+
+ /* Encryption Feistel cycles. */
+ ENCCYCLE (0);
+ ENCCYCLE (1);
+ ENCCYCLE (2);
+ ENCCYCLE (3);
+ ENCCYCLE (4);
+ ENCCYCLE (5);
+ ENCCYCLE (6);
+ ENCCYCLE (7);
+
+ /* Output whitening and unpacking. */
+ OUTUNPACK (0, c, 4);
+ OUTUNPACK (1, d, 5);
+ OUTUNPACK (2, a, 6);
+ OUTUNPACK (3, b, 7);
+}
+
+static void
+twofish_encrypt (void *context, byte *out, const byte *in)
+{
+ TWOFISH_context *ctx = context;
+ do_twofish_encrypt (ctx, out, in);
+ _gcry_burn_stack (24+3*sizeof (void*));
+}
+
+
+/* Decrypt one block. in and out may be the same. */
+
+static void
+do_twofish_decrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
+{
+ /* The four 32-bit chunks of the text. */
+ u32 a, b, c, d;
+
+ /* Temporaries used by the round function. */
+ u32 x, y;
+
+ /* Input whitening and packing. */
+ INPACK (0, c, 4);
+ INPACK (1, d, 5);
+ INPACK (2, a, 6);
+ INPACK (3, b, 7);
+
+ /* Encryption Feistel cycles. */
+ DECCYCLE (7);
+ DECCYCLE (6);
+ DECCYCLE (5);
+ DECCYCLE (4);
+ DECCYCLE (3);
+ DECCYCLE (2);
+ DECCYCLE (1);
+ DECCYCLE (0);
+
+ /* Output whitening and unpacking. */
+ OUTUNPACK (0, a, 0);
+ OUTUNPACK (1, b, 1);
+ OUTUNPACK (2, c, 2);
+ OUTUNPACK (3, d, 3);
+}
+
+static void
+twofish_decrypt (void *context, byte *out, const byte *in)
+{
+ TWOFISH_context *ctx = context;
+
+ do_twofish_decrypt (ctx, out, in);
+ _gcry_burn_stack (24+3*sizeof (void*));
+}
+
+
+/* Test a single encryption and decryption with each key size. */
+
+
+/* More complete test program. This does 1000 encryptions and decryptions
+ * with each of 250 128-bit keys and 2000 encryptions and decryptions with
+ * each of 125 256-bit keys, using a feedback scheme similar to a Feistel
+ * cipher, so as to be sure of testing all the table entries pretty
+ * thoroughly. We keep changing the keys so as to get a more meaningful
+ * performance number, since the key setup is non-trivial for Twofish. */
+
+#ifdef TEST
+
+
+int
+main()
+{
+ TWOFISH_context ctx; /* Expanded key. */
+ int i, j; /* Loop counters. */
+
+ const char *encrypt_msg; /* Message to print regarding encryption test;
+ * the printf is done outside the loop to avoid
+ * stuffing up the timing. */
+ clock_t timer; /* For computing elapsed time. */
+
+ /* Test buffer. */
+ byte buffer[4][16] = {
+ {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF},
+ {0x0F, 0x1E, 0x2D, 0x3C, 0x4B, 0x5A, 0x69, 0x78,
+ 0x87, 0x96, 0xA5, 0xB4, 0xC3, 0xD2 ,0xE1, 0xF0},
+ {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54 ,0x32, 0x10},
+ {0x01, 0x23, 0x45, 0x67, 0x76, 0x54 ,0x32, 0x10,
+ 0x89, 0xAB, 0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98}
+ };
+
+ /* Expected outputs for the million-operation test */
+ static const byte test_encrypt[4][16] = {
+ {0xC8, 0x23, 0xB8, 0xB7, 0x6B, 0xFE, 0x91, 0x13,
+ 0x2F, 0xA7, 0x5E, 0xE6, 0x94, 0x77, 0x6F, 0x6B},
+ {0x90, 0x36, 0xD8, 0x29, 0xD5, 0x96, 0xC2, 0x8E,
+ 0xE4, 0xFF, 0x76, 0xBC, 0xE5, 0x77, 0x88, 0x27},
+ {0xB8, 0x78, 0x69, 0xAF, 0x42, 0x8B, 0x48, 0x64,
+ 0xF7, 0xE9, 0xF3, 0x9C, 0x42, 0x18, 0x7B, 0x73},
+ {0x7A, 0x88, 0xFB, 0xEB, 0x90, 0xA4, 0xB4, 0xA8,
+ 0x43, 0xA3, 0x1D, 0xF1, 0x26, 0xC4, 0x53, 0x57}
+ };
+ static const byte test_decrypt[4][16] = {
+ {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF},
+ {0x0F, 0x1E, 0x2D, 0x3C, 0x4B, 0x5A, 0x69, 0x78,
+ 0x87, 0x96, 0xA5, 0xB4, 0xC3, 0xD2 ,0xE1, 0xF0},
+ {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54 ,0x32, 0x10},
+ {0x01, 0x23, 0x45, 0x67, 0x76, 0x54 ,0x32, 0x10,
+ 0x89, 0xAB, 0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98}
+ };
+
+ /* Start the timer ticking. */
+ timer = clock ();
+
+ /* Encryption test. */
+ for (i = 0; i < 125; i++)
+ {
+ twofish_setkey (&ctx, buffer[0], sizeof (buffer[0]));
+ for (j = 0; j < 1000; j++)
+ twofish_encrypt (&ctx, buffer[2], buffer[2]);
+ twofish_setkey (&ctx, buffer[1], sizeof (buffer[1]));
+ for (j = 0; j < 1000; j++)
+ twofish_encrypt (&ctx, buffer[3], buffer[3]);
+ twofish_setkey (&ctx, buffer[2], sizeof (buffer[2])*2);
+ for (j = 0; j < 1000; j++) {
+ twofish_encrypt (&ctx, buffer[0], buffer[0]);
+ twofish_encrypt (&ctx, buffer[1], buffer[1]);
+ }
+ }
+ encrypt_msg = memcmp (buffer, test_encrypt, sizeof (test_encrypt)) ?
+ "encryption failure!\n" : "encryption OK!\n";
+
+ /* Decryption test. */
+ for (i = 0; i < 125; i++)
+ {
+ twofish_setkey (&ctx, buffer[2], sizeof (buffer[2])*2);
+ for (j = 0; j < 1000; j++) {
+ twofish_decrypt (&ctx, buffer[0], buffer[0]);
+ twofish_decrypt (&ctx, buffer[1], buffer[1]);
+ }
+ twofish_setkey (&ctx, buffer[1], sizeof (buffer[1]));
+ for (j = 0; j < 1000; j++)
+ twofish_decrypt (&ctx, buffer[3], buffer[3]);
+ twofish_setkey (&ctx, buffer[0], sizeof (buffer[0]));
+ for (j = 0; j < 1000; j++)
+ twofish_decrypt (&ctx, buffer[2], buffer[2]);
+ }
+
+ /* Stop the timer, and print results. */
+ timer = clock () - timer;
+ printf (encrypt_msg);
+ printf (memcmp (buffer, test_decrypt, sizeof (test_decrypt)) ?
+ "decryption failure!\n" : "decryption OK!\n");
+ printf ("elapsed time: %.1f s.\n", (float) timer / CLOCKS_PER_SEC);
+
+ return 0;
+}
+
+#endif /* TEST */
+
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_twofish =
+ {
+ "TWOFISH", NULL, NULL, 16, 256, sizeof (TWOFISH_context),
+ twofish_setkey, twofish_encrypt, twofish_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_twofish",
+#endif
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_twofish128 =
+ {
+ "TWOFISH128", NULL, NULL, 16, 128, sizeof (TWOFISH_context),
+ twofish_setkey, twofish_encrypt, twofish_decrypt
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_twofish",
+#endif
+ };
+
+
+GRUB_MOD_INIT(gcry_twofish)
+{
+ grub_cipher_register (&_gcry_cipher_spec_twofish);
+ grub_cipher_register (&_gcry_cipher_spec_twofish128);
+}
+
+GRUB_MOD_FINI(gcry_twofish)
+{
+ grub_cipher_unregister (&_gcry_cipher_spec_twofish);
+ grub_cipher_unregister (&_gcry_cipher_spec_twofish128);
+}
diff --git a/grub-core/lib/libgcrypt-grub/cipher/types.h b/grub-core/lib/libgcrypt-grub/cipher/types.h
new file mode 100644
index 0000000..2ec78b6
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/types.h
@@ -0,0 +1,2 @@
+#include <grub/types.h>
+#include <cipher_wrap.h>
diff --git a/grub-core/lib/libgcrypt-grub/cipher/whirlpool.c b/grub-core/lib/libgcrypt-grub/cipher/whirlpool.c
new file mode 100644
index 0000000..f2a463d
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/cipher/whirlpool.c
@@ -0,0 +1,1422 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+#include <grub/dl.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+/* whirlpool.c - Whirlpool hashing algorithm
+ * Copyright (C) 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ */
+
+/* This is an implementation of the Whirlpool hashing algorithm, which
+ has been developed by Vincent Rijmen and Paulo S. L. M. Barreto;
+ it's homepage is located at:
+ http://planeta.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html.
+
+ The S-Boxes and the structure of the main transformation function,
+ which implements an optimized version of the algorithm, is taken
+ from the reference implementation available from
+ http://planeta.terra.com.br/informatica/paulobarreto/whirlpool.zip. */
+
+
+#include "types.h"
+#include "g10lib.h"
+#include "cipher.h"
+
+#include "bithelp.h"
+
+/* Size of a whirlpool block (in bytes). */
+#define BLOCK_SIZE 64
+
+/* Number of rounds. */
+#define R 10
+
+
+
+/* Types. */
+typedef u64 whirlpool_block_t[BLOCK_SIZE / 8];
+
+typedef struct {
+ whirlpool_block_t hash_state;
+ unsigned char buffer[BLOCK_SIZE];
+ size_t count;
+ unsigned char length[32];
+} whirlpool_context_t;
+
+
+
+/* Macros. */
+
+/* Convert the the buffer BUFFER into a block BLOCK, using I as
+ counter. */
+#define buffer_to_block(buffer, block, i) \
+ for (i = 0; i < 8; i++) \
+ (block)[i] = ((u64) (0 \
+ | (((u64) (buffer)[i * 8 + 0]) << 56) \
+ | (((u64) (buffer)[i * 8 + 1]) << 48) \
+ | (((u64) (buffer)[i * 8 + 2]) << 40) \
+ | (((u64) (buffer)[i * 8 + 3]) << 32) \
+ | (((u64) (buffer)[i * 8 + 4]) << 24) \
+ | (((u64) (buffer)[i * 8 + 5]) << 16) \
+ | (((u64) (buffer)[i * 8 + 6]) << 8) \
+ | (((u64) (buffer)[i * 8 + 7]) << 0)));
+
+/* Convert the block BLOCK into a buffer BUFFER, using I as
+ counter. */
+#define block_to_buffer(buffer, block, i) \
+ for (i = 0; i < 8; i++) \
+ { \
+ (buffer)[i * 8 + 0] = (block[i] >> 56) & 0xFF; \
+ (buffer)[i * 8 + 1] = (block[i] >> 48) & 0xFF; \
+ (buffer)[i * 8 + 2] = (block[i] >> 40) & 0xFF; \
+ (buffer)[i * 8 + 3] = (block[i] >> 32) & 0xFF; \
+ (buffer)[i * 8 + 4] = (block[i] >> 24) & 0xFF; \
+ (buffer)[i * 8 + 5] = (block[i] >> 16) & 0xFF; \
+ (buffer)[i * 8 + 6] = (block[i] >> 8) & 0xFF; \
+ (buffer)[i * 8 + 7] = (block[i] >> 0) & 0xFF; \
+ }
+
+/* Copy the block BLOCK_SRC to BLOCK_DST, using I as counter. */
+#define block_copy(block_dst, block_src, i) \
+ for (i = 0; i < 8; i++) \
+ block_dst[i] = block_src[i];
+
+/* XOR the block BLOCK_SRC into BLOCK_DST, using I as counter. */
+#define block_xor(block_dst, block_src, i) \
+ for (i = 0; i < 8; i++) \
+ block_dst[i] ^= block_src[i];
+
+
+
+/* Round constants. */
+static const u64 rc[R] =
+ {
+ U64_C (0x1823c6e887b8014f),
+ U64_C (0x36a6d2f5796f9152),
+ U64_C (0x60bc9b8ea30c7b35),
+ U64_C (0x1de0d7c22e4bfe57),
+ U64_C (0x157737e59ff04ada),
+ U64_C (0x58c9290ab1a06b85),
+ U64_C (0xbd5d10f4cb3e0567),
+ U64_C (0xe427418ba77d95d8),
+ U64_C (0xfbee7c66dd17479e),
+ U64_C (0xca2dbf07ad5a8333),
+ };
+
+
+
+/* Main lookup boxes. */
+static const u64 C0[256] =
+ {
+ U64_C (0x18186018c07830d8), U64_C (0x23238c2305af4626),
+ U64_C (0xc6c63fc67ef991b8), U64_C (0xe8e887e8136fcdfb),
+ U64_C (0x878726874ca113cb), U64_C (0xb8b8dab8a9626d11),
+ U64_C (0x0101040108050209), U64_C (0x4f4f214f426e9e0d),
+ U64_C (0x3636d836adee6c9b), U64_C (0xa6a6a2a6590451ff),
+ U64_C (0xd2d26fd2debdb90c), U64_C (0xf5f5f3f5fb06f70e),
+ U64_C (0x7979f979ef80f296), U64_C (0x6f6fa16f5fcede30),
+ U64_C (0x91917e91fcef3f6d), U64_C (0x52525552aa07a4f8),
+ U64_C (0x60609d6027fdc047), U64_C (0xbcbccabc89766535),
+ U64_C (0x9b9b569baccd2b37), U64_C (0x8e8e028e048c018a),
+ U64_C (0xa3a3b6a371155bd2), U64_C (0x0c0c300c603c186c),
+ U64_C (0x7b7bf17bff8af684), U64_C (0x3535d435b5e16a80),
+ U64_C (0x1d1d741de8693af5), U64_C (0xe0e0a7e05347ddb3),
+ U64_C (0xd7d77bd7f6acb321), U64_C (0xc2c22fc25eed999c),
+ U64_C (0x2e2eb82e6d965c43), U64_C (0x4b4b314b627a9629),
+ U64_C (0xfefedffea321e15d), U64_C (0x575741578216aed5),
+ U64_C (0x15155415a8412abd), U64_C (0x7777c1779fb6eee8),
+ U64_C (0x3737dc37a5eb6e92), U64_C (0xe5e5b3e57b56d79e),
+ U64_C (0x9f9f469f8cd92313), U64_C (0xf0f0e7f0d317fd23),
+ U64_C (0x4a4a354a6a7f9420), U64_C (0xdada4fda9e95a944),
+ U64_C (0x58587d58fa25b0a2), U64_C (0xc9c903c906ca8fcf),
+ U64_C (0x2929a429558d527c), U64_C (0x0a0a280a5022145a),
+ U64_C (0xb1b1feb1e14f7f50), U64_C (0xa0a0baa0691a5dc9),
+ U64_C (0x6b6bb16b7fdad614), U64_C (0x85852e855cab17d9),
+ U64_C (0xbdbdcebd8173673c), U64_C (0x5d5d695dd234ba8f),
+ U64_C (0x1010401080502090), U64_C (0xf4f4f7f4f303f507),
+ U64_C (0xcbcb0bcb16c08bdd), U64_C (0x3e3ef83eedc67cd3),
+ U64_C (0x0505140528110a2d), U64_C (0x676781671fe6ce78),
+ U64_C (0xe4e4b7e47353d597), U64_C (0x27279c2725bb4e02),
+ U64_C (0x4141194132588273), U64_C (0x8b8b168b2c9d0ba7),
+ U64_C (0xa7a7a6a7510153f6), U64_C (0x7d7de97dcf94fab2),
+ U64_C (0x95956e95dcfb3749), U64_C (0xd8d847d88e9fad56),
+ U64_C (0xfbfbcbfb8b30eb70), U64_C (0xeeee9fee2371c1cd),
+ U64_C (0x7c7ced7cc791f8bb), U64_C (0x6666856617e3cc71),
+ U64_C (0xdddd53dda68ea77b), U64_C (0x17175c17b84b2eaf),
+ U64_C (0x4747014702468e45), U64_C (0x9e9e429e84dc211a),
+ U64_C (0xcaca0fca1ec589d4), U64_C (0x2d2db42d75995a58),
+ U64_C (0xbfbfc6bf9179632e), U64_C (0x07071c07381b0e3f),
+ U64_C (0xadad8ead012347ac), U64_C (0x5a5a755aea2fb4b0),
+ U64_C (0x838336836cb51bef), U64_C (0x3333cc3385ff66b6),
+ U64_C (0x636391633ff2c65c), U64_C (0x02020802100a0412),
+ U64_C (0xaaaa92aa39384993), U64_C (0x7171d971afa8e2de),
+ U64_C (0xc8c807c80ecf8dc6), U64_C (0x19196419c87d32d1),
+ U64_C (0x494939497270923b), U64_C (0xd9d943d9869aaf5f),
+ U64_C (0xf2f2eff2c31df931), U64_C (0xe3e3abe34b48dba8),
+ U64_C (0x5b5b715be22ab6b9), U64_C (0x88881a8834920dbc),
+ U64_C (0x9a9a529aa4c8293e), U64_C (0x262698262dbe4c0b),
+ U64_C (0x3232c8328dfa64bf), U64_C (0xb0b0fab0e94a7d59),
+ U64_C (0xe9e983e91b6acff2), U64_C (0x0f0f3c0f78331e77),
+ U64_C (0xd5d573d5e6a6b733), U64_C (0x80803a8074ba1df4),
+ U64_C (0xbebec2be997c6127), U64_C (0xcdcd13cd26de87eb),
+ U64_C (0x3434d034bde46889), U64_C (0x48483d487a759032),
+ U64_C (0xffffdbffab24e354), U64_C (0x7a7af57af78ff48d),
+ U64_C (0x90907a90f4ea3d64), U64_C (0x5f5f615fc23ebe9d),
+ U64_C (0x202080201da0403d), U64_C (0x6868bd6867d5d00f),
+ U64_C (0x1a1a681ad07234ca), U64_C (0xaeae82ae192c41b7),
+ U64_C (0xb4b4eab4c95e757d), U64_C (0x54544d549a19a8ce),
+ U64_C (0x93937693ece53b7f), U64_C (0x222288220daa442f),
+ U64_C (0x64648d6407e9c863), U64_C (0xf1f1e3f1db12ff2a),
+ U64_C (0x7373d173bfa2e6cc), U64_C (0x12124812905a2482),
+ U64_C (0x40401d403a5d807a), U64_C (0x0808200840281048),
+ U64_C (0xc3c32bc356e89b95), U64_C (0xecec97ec337bc5df),
+ U64_C (0xdbdb4bdb9690ab4d), U64_C (0xa1a1bea1611f5fc0),
+ U64_C (0x8d8d0e8d1c830791), U64_C (0x3d3df43df5c97ac8),
+ U64_C (0x97976697ccf1335b), U64_C (0x0000000000000000),
+ U64_C (0xcfcf1bcf36d483f9), U64_C (0x2b2bac2b4587566e),
+ U64_C (0x7676c57697b3ece1), U64_C (0x8282328264b019e6),
+ U64_C (0xd6d67fd6fea9b128), U64_C (0x1b1b6c1bd87736c3),
+ U64_C (0xb5b5eeb5c15b7774), U64_C (0xafaf86af112943be),
+ U64_C (0x6a6ab56a77dfd41d), U64_C (0x50505d50ba0da0ea),
+ U64_C (0x45450945124c8a57), U64_C (0xf3f3ebf3cb18fb38),
+ U64_C (0x3030c0309df060ad), U64_C (0xefef9bef2b74c3c4),
+ U64_C (0x3f3ffc3fe5c37eda), U64_C (0x55554955921caac7),
+ U64_C (0xa2a2b2a2791059db), U64_C (0xeaea8fea0365c9e9),
+ U64_C (0x656589650fecca6a), U64_C (0xbabad2bab9686903),
+ U64_C (0x2f2fbc2f65935e4a), U64_C (0xc0c027c04ee79d8e),
+ U64_C (0xdede5fdebe81a160), U64_C (0x1c1c701ce06c38fc),
+ U64_C (0xfdfdd3fdbb2ee746), U64_C (0x4d4d294d52649a1f),
+ U64_C (0x92927292e4e03976), U64_C (0x7575c9758fbceafa),
+ U64_C (0x06061806301e0c36), U64_C (0x8a8a128a249809ae),
+ U64_C (0xb2b2f2b2f940794b), U64_C (0xe6e6bfe66359d185),
+ U64_C (0x0e0e380e70361c7e), U64_C (0x1f1f7c1ff8633ee7),
+ U64_C (0x6262956237f7c455), U64_C (0xd4d477d4eea3b53a),
+ U64_C (0xa8a89aa829324d81), U64_C (0x96966296c4f43152),
+ U64_C (0xf9f9c3f99b3aef62), U64_C (0xc5c533c566f697a3),
+ U64_C (0x2525942535b14a10), U64_C (0x59597959f220b2ab),
+ U64_C (0x84842a8454ae15d0), U64_C (0x7272d572b7a7e4c5),
+ U64_C (0x3939e439d5dd72ec), U64_C (0x4c4c2d4c5a619816),
+ U64_C (0x5e5e655eca3bbc94), U64_C (0x7878fd78e785f09f),
+ U64_C (0x3838e038ddd870e5), U64_C (0x8c8c0a8c14860598),
+ U64_C (0xd1d163d1c6b2bf17), U64_C (0xa5a5aea5410b57e4),
+ U64_C (0xe2e2afe2434dd9a1), U64_C (0x616199612ff8c24e),
+ U64_C (0xb3b3f6b3f1457b42), U64_C (0x2121842115a54234),
+ U64_C (0x9c9c4a9c94d62508), U64_C (0x1e1e781ef0663cee),
+ U64_C (0x4343114322528661), U64_C (0xc7c73bc776fc93b1),
+ U64_C (0xfcfcd7fcb32be54f), U64_C (0x0404100420140824),
+ U64_C (0x51515951b208a2e3), U64_C (0x99995e99bcc72f25),
+ U64_C (0x6d6da96d4fc4da22), U64_C (0x0d0d340d68391a65),
+ U64_C (0xfafacffa8335e979), U64_C (0xdfdf5bdfb684a369),
+ U64_C (0x7e7ee57ed79bfca9), U64_C (0x242490243db44819),
+ U64_C (0x3b3bec3bc5d776fe), U64_C (0xabab96ab313d4b9a),
+ U64_C (0xcece1fce3ed181f0), U64_C (0x1111441188552299),
+ U64_C (0x8f8f068f0c890383), U64_C (0x4e4e254e4a6b9c04),
+ U64_C (0xb7b7e6b7d1517366), U64_C (0xebeb8beb0b60cbe0),
+ U64_C (0x3c3cf03cfdcc78c1), U64_C (0x81813e817cbf1ffd),
+ U64_C (0x94946a94d4fe3540), U64_C (0xf7f7fbf7eb0cf31c),
+ U64_C (0xb9b9deb9a1676f18), U64_C (0x13134c13985f268b),
+ U64_C (0x2c2cb02c7d9c5851), U64_C (0xd3d36bd3d6b8bb05),
+ U64_C (0xe7e7bbe76b5cd38c), U64_C (0x6e6ea56e57cbdc39),
+ U64_C (0xc4c437c46ef395aa), U64_C (0x03030c03180f061b),
+ U64_C (0x565645568a13acdc), U64_C (0x44440d441a49885e),
+ U64_C (0x7f7fe17fdf9efea0), U64_C (0xa9a99ea921374f88),
+ U64_C (0x2a2aa82a4d825467), U64_C (0xbbbbd6bbb16d6b0a),
+ U64_C (0xc1c123c146e29f87), U64_C (0x53535153a202a6f1),
+ U64_C (0xdcdc57dcae8ba572), U64_C (0x0b0b2c0b58271653),
+ U64_C (0x9d9d4e9d9cd32701), U64_C (0x6c6cad6c47c1d82b),
+ U64_C (0x3131c43195f562a4), U64_C (0x7474cd7487b9e8f3),
+ U64_C (0xf6f6fff6e309f115), U64_C (0x464605460a438c4c),
+ U64_C (0xacac8aac092645a5), U64_C (0x89891e893c970fb5),
+ U64_C (0x14145014a04428b4), U64_C (0xe1e1a3e15b42dfba),
+ U64_C (0x16165816b04e2ca6), U64_C (0x3a3ae83acdd274f7),
+ U64_C (0x6969b9696fd0d206), U64_C (0x09092409482d1241),
+ U64_C (0x7070dd70a7ade0d7), U64_C (0xb6b6e2b6d954716f),
+ U64_C (0xd0d067d0ceb7bd1e), U64_C (0xeded93ed3b7ec7d6),
+ U64_C (0xcccc17cc2edb85e2), U64_C (0x424215422a578468),
+ U64_C (0x98985a98b4c22d2c), U64_C (0xa4a4aaa4490e55ed),
+ U64_C (0x2828a0285d885075), U64_C (0x5c5c6d5cda31b886),
+ U64_C (0xf8f8c7f8933fed6b), U64_C (0x8686228644a411c2),
+ };
+
+static const u64 C1[256] =
+ {
+ U64_C (0xd818186018c07830), U64_C (0x2623238c2305af46),
+ U64_C (0xb8c6c63fc67ef991), U64_C (0xfbe8e887e8136fcd),
+ U64_C (0xcb878726874ca113), U64_C (0x11b8b8dab8a9626d),
+ U64_C (0x0901010401080502), U64_C (0x0d4f4f214f426e9e),
+ U64_C (0x9b3636d836adee6c), U64_C (0xffa6a6a2a6590451),
+ U64_C (0x0cd2d26fd2debdb9), U64_C (0x0ef5f5f3f5fb06f7),
+ U64_C (0x967979f979ef80f2), U64_C (0x306f6fa16f5fcede),
+ U64_C (0x6d91917e91fcef3f), U64_C (0xf852525552aa07a4),
+ U64_C (0x4760609d6027fdc0), U64_C (0x35bcbccabc897665),
+ U64_C (0x379b9b569baccd2b), U64_C (0x8a8e8e028e048c01),
+ U64_C (0xd2a3a3b6a371155b), U64_C (0x6c0c0c300c603c18),
+ U64_C (0x847b7bf17bff8af6), U64_C (0x803535d435b5e16a),
+ U64_C (0xf51d1d741de8693a), U64_C (0xb3e0e0a7e05347dd),
+ U64_C (0x21d7d77bd7f6acb3), U64_C (0x9cc2c22fc25eed99),
+ U64_C (0x432e2eb82e6d965c), U64_C (0x294b4b314b627a96),
+ U64_C (0x5dfefedffea321e1), U64_C (0xd5575741578216ae),
+ U64_C (0xbd15155415a8412a), U64_C (0xe87777c1779fb6ee),
+ U64_C (0x923737dc37a5eb6e), U64_C (0x9ee5e5b3e57b56d7),
+ U64_C (0x139f9f469f8cd923), U64_C (0x23f0f0e7f0d317fd),
+ U64_C (0x204a4a354a6a7f94), U64_C (0x44dada4fda9e95a9),
+ U64_C (0xa258587d58fa25b0), U64_C (0xcfc9c903c906ca8f),
+ U64_C (0x7c2929a429558d52), U64_C (0x5a0a0a280a502214),
+ U64_C (0x50b1b1feb1e14f7f), U64_C (0xc9a0a0baa0691a5d),
+ U64_C (0x146b6bb16b7fdad6), U64_C (0xd985852e855cab17),
+ U64_C (0x3cbdbdcebd817367), U64_C (0x8f5d5d695dd234ba),
+ U64_C (0x9010104010805020), U64_C (0x07f4f4f7f4f303f5),
+ U64_C (0xddcbcb0bcb16c08b), U64_C (0xd33e3ef83eedc67c),
+ U64_C (0x2d0505140528110a), U64_C (0x78676781671fe6ce),
+ U64_C (0x97e4e4b7e47353d5), U64_C (0x0227279c2725bb4e),
+ U64_C (0x7341411941325882), U64_C (0xa78b8b168b2c9d0b),
+ U64_C (0xf6a7a7a6a7510153), U64_C (0xb27d7de97dcf94fa),
+ U64_C (0x4995956e95dcfb37), U64_C (0x56d8d847d88e9fad),
+ U64_C (0x70fbfbcbfb8b30eb), U64_C (0xcdeeee9fee2371c1),
+ U64_C (0xbb7c7ced7cc791f8), U64_C (0x716666856617e3cc),
+ U64_C (0x7bdddd53dda68ea7), U64_C (0xaf17175c17b84b2e),
+ U64_C (0x454747014702468e), U64_C (0x1a9e9e429e84dc21),
+ U64_C (0xd4caca0fca1ec589), U64_C (0x582d2db42d75995a),
+ U64_C (0x2ebfbfc6bf917963), U64_C (0x3f07071c07381b0e),
+ U64_C (0xacadad8ead012347), U64_C (0xb05a5a755aea2fb4),
+ U64_C (0xef838336836cb51b), U64_C (0xb63333cc3385ff66),
+ U64_C (0x5c636391633ff2c6), U64_C (0x1202020802100a04),
+ U64_C (0x93aaaa92aa393849), U64_C (0xde7171d971afa8e2),
+ U64_C (0xc6c8c807c80ecf8d), U64_C (0xd119196419c87d32),
+ U64_C (0x3b49493949727092), U64_C (0x5fd9d943d9869aaf),
+ U64_C (0x31f2f2eff2c31df9), U64_C (0xa8e3e3abe34b48db),
+ U64_C (0xb95b5b715be22ab6), U64_C (0xbc88881a8834920d),
+ U64_C (0x3e9a9a529aa4c829), U64_C (0x0b262698262dbe4c),
+ U64_C (0xbf3232c8328dfa64), U64_C (0x59b0b0fab0e94a7d),
+ U64_C (0xf2e9e983e91b6acf), U64_C (0x770f0f3c0f78331e),
+ U64_C (0x33d5d573d5e6a6b7), U64_C (0xf480803a8074ba1d),
+ U64_C (0x27bebec2be997c61), U64_C (0xebcdcd13cd26de87),
+ U64_C (0x893434d034bde468), U64_C (0x3248483d487a7590),
+ U64_C (0x54ffffdbffab24e3), U64_C (0x8d7a7af57af78ff4),
+ U64_C (0x6490907a90f4ea3d), U64_C (0x9d5f5f615fc23ebe),
+ U64_C (0x3d202080201da040), U64_C (0x0f6868bd6867d5d0),
+ U64_C (0xca1a1a681ad07234), U64_C (0xb7aeae82ae192c41),
+ U64_C (0x7db4b4eab4c95e75), U64_C (0xce54544d549a19a8),
+ U64_C (0x7f93937693ece53b), U64_C (0x2f222288220daa44),
+ U64_C (0x6364648d6407e9c8), U64_C (0x2af1f1e3f1db12ff),
+ U64_C (0xcc7373d173bfa2e6), U64_C (0x8212124812905a24),
+ U64_C (0x7a40401d403a5d80), U64_C (0x4808082008402810),
+ U64_C (0x95c3c32bc356e89b), U64_C (0xdfecec97ec337bc5),
+ U64_C (0x4ddbdb4bdb9690ab), U64_C (0xc0a1a1bea1611f5f),
+ U64_C (0x918d8d0e8d1c8307), U64_C (0xc83d3df43df5c97a),
+ U64_C (0x5b97976697ccf133), U64_C (0x0000000000000000),
+ U64_C (0xf9cfcf1bcf36d483), U64_C (0x6e2b2bac2b458756),
+ U64_C (0xe17676c57697b3ec), U64_C (0xe68282328264b019),
+ U64_C (0x28d6d67fd6fea9b1), U64_C (0xc31b1b6c1bd87736),
+ U64_C (0x74b5b5eeb5c15b77), U64_C (0xbeafaf86af112943),
+ U64_C (0x1d6a6ab56a77dfd4), U64_C (0xea50505d50ba0da0),
+ U64_C (0x5745450945124c8a), U64_C (0x38f3f3ebf3cb18fb),
+ U64_C (0xad3030c0309df060), U64_C (0xc4efef9bef2b74c3),
+ U64_C (0xda3f3ffc3fe5c37e), U64_C (0xc755554955921caa),
+ U64_C (0xdba2a2b2a2791059), U64_C (0xe9eaea8fea0365c9),
+ U64_C (0x6a656589650fecca), U64_C (0x03babad2bab96869),
+ U64_C (0x4a2f2fbc2f65935e), U64_C (0x8ec0c027c04ee79d),
+ U64_C (0x60dede5fdebe81a1), U64_C (0xfc1c1c701ce06c38),
+ U64_C (0x46fdfdd3fdbb2ee7), U64_C (0x1f4d4d294d52649a),
+ U64_C (0x7692927292e4e039), U64_C (0xfa7575c9758fbcea),
+ U64_C (0x3606061806301e0c), U64_C (0xae8a8a128a249809),
+ U64_C (0x4bb2b2f2b2f94079), U64_C (0x85e6e6bfe66359d1),
+ U64_C (0x7e0e0e380e70361c), U64_C (0xe71f1f7c1ff8633e),
+ U64_C (0x556262956237f7c4), U64_C (0x3ad4d477d4eea3b5),
+ U64_C (0x81a8a89aa829324d), U64_C (0x5296966296c4f431),
+ U64_C (0x62f9f9c3f99b3aef), U64_C (0xa3c5c533c566f697),
+ U64_C (0x102525942535b14a), U64_C (0xab59597959f220b2),
+ U64_C (0xd084842a8454ae15), U64_C (0xc57272d572b7a7e4),
+ U64_C (0xec3939e439d5dd72), U64_C (0x164c4c2d4c5a6198),
+ U64_C (0x945e5e655eca3bbc), U64_C (0x9f7878fd78e785f0),
+ U64_C (0xe53838e038ddd870), U64_C (0x988c8c0a8c148605),
+ U64_C (0x17d1d163d1c6b2bf), U64_C (0xe4a5a5aea5410b57),
+ U64_C (0xa1e2e2afe2434dd9), U64_C (0x4e616199612ff8c2),
+ U64_C (0x42b3b3f6b3f1457b), U64_C (0x342121842115a542),
+ U64_C (0x089c9c4a9c94d625), U64_C (0xee1e1e781ef0663c),
+ U64_C (0x6143431143225286), U64_C (0xb1c7c73bc776fc93),
+ U64_C (0x4ffcfcd7fcb32be5), U64_C (0x2404041004201408),
+ U64_C (0xe351515951b208a2), U64_C (0x2599995e99bcc72f),
+ U64_C (0x226d6da96d4fc4da), U64_C (0x650d0d340d68391a),
+ U64_C (0x79fafacffa8335e9), U64_C (0x69dfdf5bdfb684a3),
+ U64_C (0xa97e7ee57ed79bfc), U64_C (0x19242490243db448),
+ U64_C (0xfe3b3bec3bc5d776), U64_C (0x9aabab96ab313d4b),
+ U64_C (0xf0cece1fce3ed181), U64_C (0x9911114411885522),
+ U64_C (0x838f8f068f0c8903), U64_C (0x044e4e254e4a6b9c),
+ U64_C (0x66b7b7e6b7d15173), U64_C (0xe0ebeb8beb0b60cb),
+ U64_C (0xc13c3cf03cfdcc78), U64_C (0xfd81813e817cbf1f),
+ U64_C (0x4094946a94d4fe35), U64_C (0x1cf7f7fbf7eb0cf3),
+ U64_C (0x18b9b9deb9a1676f), U64_C (0x8b13134c13985f26),
+ U64_C (0x512c2cb02c7d9c58), U64_C (0x05d3d36bd3d6b8bb),
+ U64_C (0x8ce7e7bbe76b5cd3), U64_C (0x396e6ea56e57cbdc),
+ U64_C (0xaac4c437c46ef395), U64_C (0x1b03030c03180f06),
+ U64_C (0xdc565645568a13ac), U64_C (0x5e44440d441a4988),
+ U64_C (0xa07f7fe17fdf9efe), U64_C (0x88a9a99ea921374f),
+ U64_C (0x672a2aa82a4d8254), U64_C (0x0abbbbd6bbb16d6b),
+ U64_C (0x87c1c123c146e29f), U64_C (0xf153535153a202a6),
+ U64_C (0x72dcdc57dcae8ba5), U64_C (0x530b0b2c0b582716),
+ U64_C (0x019d9d4e9d9cd327), U64_C (0x2b6c6cad6c47c1d8),
+ U64_C (0xa43131c43195f562), U64_C (0xf37474cd7487b9e8),
+ U64_C (0x15f6f6fff6e309f1), U64_C (0x4c464605460a438c),
+ U64_C (0xa5acac8aac092645), U64_C (0xb589891e893c970f),
+ U64_C (0xb414145014a04428), U64_C (0xbae1e1a3e15b42df),
+ U64_C (0xa616165816b04e2c), U64_C (0xf73a3ae83acdd274),
+ U64_C (0x066969b9696fd0d2), U64_C (0x4109092409482d12),
+ U64_C (0xd77070dd70a7ade0), U64_C (0x6fb6b6e2b6d95471),
+ U64_C (0x1ed0d067d0ceb7bd), U64_C (0xd6eded93ed3b7ec7),
+ U64_C (0xe2cccc17cc2edb85), U64_C (0x68424215422a5784),
+ U64_C (0x2c98985a98b4c22d), U64_C (0xeda4a4aaa4490e55),
+ U64_C (0x752828a0285d8850), U64_C (0x865c5c6d5cda31b8),
+ U64_C (0x6bf8f8c7f8933fed), U64_C (0xc28686228644a411),
+ };
+
+static const u64 C2[256] =
+ {
+ U64_C (0x30d818186018c078), U64_C (0x462623238c2305af),
+ U64_C (0x91b8c6c63fc67ef9), U64_C (0xcdfbe8e887e8136f),
+ U64_C (0x13cb878726874ca1), U64_C (0x6d11b8b8dab8a962),
+ U64_C (0x0209010104010805), U64_C (0x9e0d4f4f214f426e),
+ U64_C (0x6c9b3636d836adee), U64_C (0x51ffa6a6a2a65904),
+ U64_C (0xb90cd2d26fd2debd), U64_C (0xf70ef5f5f3f5fb06),
+ U64_C (0xf2967979f979ef80), U64_C (0xde306f6fa16f5fce),
+ U64_C (0x3f6d91917e91fcef), U64_C (0xa4f852525552aa07),
+ U64_C (0xc04760609d6027fd), U64_C (0x6535bcbccabc8976),
+ U64_C (0x2b379b9b569baccd), U64_C (0x018a8e8e028e048c),
+ U64_C (0x5bd2a3a3b6a37115), U64_C (0x186c0c0c300c603c),
+ U64_C (0xf6847b7bf17bff8a), U64_C (0x6a803535d435b5e1),
+ U64_C (0x3af51d1d741de869), U64_C (0xddb3e0e0a7e05347),
+ U64_C (0xb321d7d77bd7f6ac), U64_C (0x999cc2c22fc25eed),
+ U64_C (0x5c432e2eb82e6d96), U64_C (0x96294b4b314b627a),
+ U64_C (0xe15dfefedffea321), U64_C (0xaed5575741578216),
+ U64_C (0x2abd15155415a841), U64_C (0xeee87777c1779fb6),
+ U64_C (0x6e923737dc37a5eb), U64_C (0xd79ee5e5b3e57b56),
+ U64_C (0x23139f9f469f8cd9), U64_C (0xfd23f0f0e7f0d317),
+ U64_C (0x94204a4a354a6a7f), U64_C (0xa944dada4fda9e95),
+ U64_C (0xb0a258587d58fa25), U64_C (0x8fcfc9c903c906ca),
+ U64_C (0x527c2929a429558d), U64_C (0x145a0a0a280a5022),
+ U64_C (0x7f50b1b1feb1e14f), U64_C (0x5dc9a0a0baa0691a),
+ U64_C (0xd6146b6bb16b7fda), U64_C (0x17d985852e855cab),
+ U64_C (0x673cbdbdcebd8173), U64_C (0xba8f5d5d695dd234),
+ U64_C (0x2090101040108050), U64_C (0xf507f4f4f7f4f303),
+ U64_C (0x8bddcbcb0bcb16c0), U64_C (0x7cd33e3ef83eedc6),
+ U64_C (0x0a2d050514052811), U64_C (0xce78676781671fe6),
+ U64_C (0xd597e4e4b7e47353), U64_C (0x4e0227279c2725bb),
+ U64_C (0x8273414119413258), U64_C (0x0ba78b8b168b2c9d),
+ U64_C (0x53f6a7a7a6a75101), U64_C (0xfab27d7de97dcf94),
+ U64_C (0x374995956e95dcfb), U64_C (0xad56d8d847d88e9f),
+ U64_C (0xeb70fbfbcbfb8b30), U64_C (0xc1cdeeee9fee2371),
+ U64_C (0xf8bb7c7ced7cc791), U64_C (0xcc716666856617e3),
+ U64_C (0xa77bdddd53dda68e), U64_C (0x2eaf17175c17b84b),
+ U64_C (0x8e45474701470246), U64_C (0x211a9e9e429e84dc),
+ U64_C (0x89d4caca0fca1ec5), U64_C (0x5a582d2db42d7599),
+ U64_C (0x632ebfbfc6bf9179), U64_C (0x0e3f07071c07381b),
+ U64_C (0x47acadad8ead0123), U64_C (0xb4b05a5a755aea2f),
+ U64_C (0x1bef838336836cb5), U64_C (0x66b63333cc3385ff),
+ U64_C (0xc65c636391633ff2), U64_C (0x041202020802100a),
+ U64_C (0x4993aaaa92aa3938), U64_C (0xe2de7171d971afa8),
+ U64_C (0x8dc6c8c807c80ecf), U64_C (0x32d119196419c87d),
+ U64_C (0x923b494939497270), U64_C (0xaf5fd9d943d9869a),
+ U64_C (0xf931f2f2eff2c31d), U64_C (0xdba8e3e3abe34b48),
+ U64_C (0xb6b95b5b715be22a), U64_C (0x0dbc88881a883492),
+ U64_C (0x293e9a9a529aa4c8), U64_C (0x4c0b262698262dbe),
+ U64_C (0x64bf3232c8328dfa), U64_C (0x7d59b0b0fab0e94a),
+ U64_C (0xcff2e9e983e91b6a), U64_C (0x1e770f0f3c0f7833),
+ U64_C (0xb733d5d573d5e6a6), U64_C (0x1df480803a8074ba),
+ U64_C (0x6127bebec2be997c), U64_C (0x87ebcdcd13cd26de),
+ U64_C (0x68893434d034bde4), U64_C (0x903248483d487a75),
+ U64_C (0xe354ffffdbffab24), U64_C (0xf48d7a7af57af78f),
+ U64_C (0x3d6490907a90f4ea), U64_C (0xbe9d5f5f615fc23e),
+ U64_C (0x403d202080201da0), U64_C (0xd00f6868bd6867d5),
+ U64_C (0x34ca1a1a681ad072), U64_C (0x41b7aeae82ae192c),
+ U64_C (0x757db4b4eab4c95e), U64_C (0xa8ce54544d549a19),
+ U64_C (0x3b7f93937693ece5), U64_C (0x442f222288220daa),
+ U64_C (0xc86364648d6407e9), U64_C (0xff2af1f1e3f1db12),
+ U64_C (0xe6cc7373d173bfa2), U64_C (0x248212124812905a),
+ U64_C (0x807a40401d403a5d), U64_C (0x1048080820084028),
+ U64_C (0x9b95c3c32bc356e8), U64_C (0xc5dfecec97ec337b),
+ U64_C (0xab4ddbdb4bdb9690), U64_C (0x5fc0a1a1bea1611f),
+ U64_C (0x07918d8d0e8d1c83), U64_C (0x7ac83d3df43df5c9),
+ U64_C (0x335b97976697ccf1), U64_C (0x0000000000000000),
+ U64_C (0x83f9cfcf1bcf36d4), U64_C (0x566e2b2bac2b4587),
+ U64_C (0xece17676c57697b3), U64_C (0x19e68282328264b0),
+ U64_C (0xb128d6d67fd6fea9), U64_C (0x36c31b1b6c1bd877),
+ U64_C (0x7774b5b5eeb5c15b), U64_C (0x43beafaf86af1129),
+ U64_C (0xd41d6a6ab56a77df), U64_C (0xa0ea50505d50ba0d),
+ U64_C (0x8a5745450945124c), U64_C (0xfb38f3f3ebf3cb18),
+ U64_C (0x60ad3030c0309df0), U64_C (0xc3c4efef9bef2b74),
+ U64_C (0x7eda3f3ffc3fe5c3), U64_C (0xaac755554955921c),
+ U64_C (0x59dba2a2b2a27910), U64_C (0xc9e9eaea8fea0365),
+ U64_C (0xca6a656589650fec), U64_C (0x6903babad2bab968),
+ U64_C (0x5e4a2f2fbc2f6593), U64_C (0x9d8ec0c027c04ee7),
+ U64_C (0xa160dede5fdebe81), U64_C (0x38fc1c1c701ce06c),
+ U64_C (0xe746fdfdd3fdbb2e), U64_C (0x9a1f4d4d294d5264),
+ U64_C (0x397692927292e4e0), U64_C (0xeafa7575c9758fbc),
+ U64_C (0x0c3606061806301e), U64_C (0x09ae8a8a128a2498),
+ U64_C (0x794bb2b2f2b2f940), U64_C (0xd185e6e6bfe66359),
+ U64_C (0x1c7e0e0e380e7036), U64_C (0x3ee71f1f7c1ff863),
+ U64_C (0xc4556262956237f7), U64_C (0xb53ad4d477d4eea3),
+ U64_C (0x4d81a8a89aa82932), U64_C (0x315296966296c4f4),
+ U64_C (0xef62f9f9c3f99b3a), U64_C (0x97a3c5c533c566f6),
+ U64_C (0x4a102525942535b1), U64_C (0xb2ab59597959f220),
+ U64_C (0x15d084842a8454ae), U64_C (0xe4c57272d572b7a7),
+ U64_C (0x72ec3939e439d5dd), U64_C (0x98164c4c2d4c5a61),
+ U64_C (0xbc945e5e655eca3b), U64_C (0xf09f7878fd78e785),
+ U64_C (0x70e53838e038ddd8), U64_C (0x05988c8c0a8c1486),
+ U64_C (0xbf17d1d163d1c6b2), U64_C (0x57e4a5a5aea5410b),
+ U64_C (0xd9a1e2e2afe2434d), U64_C (0xc24e616199612ff8),
+ U64_C (0x7b42b3b3f6b3f145), U64_C (0x42342121842115a5),
+ U64_C (0x25089c9c4a9c94d6), U64_C (0x3cee1e1e781ef066),
+ U64_C (0x8661434311432252), U64_C (0x93b1c7c73bc776fc),
+ U64_C (0xe54ffcfcd7fcb32b), U64_C (0x0824040410042014),
+ U64_C (0xa2e351515951b208), U64_C (0x2f2599995e99bcc7),
+ U64_C (0xda226d6da96d4fc4), U64_C (0x1a650d0d340d6839),
+ U64_C (0xe979fafacffa8335), U64_C (0xa369dfdf5bdfb684),
+ U64_C (0xfca97e7ee57ed79b), U64_C (0x4819242490243db4),
+ U64_C (0x76fe3b3bec3bc5d7), U64_C (0x4b9aabab96ab313d),
+ U64_C (0x81f0cece1fce3ed1), U64_C (0x2299111144118855),
+ U64_C (0x03838f8f068f0c89), U64_C (0x9c044e4e254e4a6b),
+ U64_C (0x7366b7b7e6b7d151), U64_C (0xcbe0ebeb8beb0b60),
+ U64_C (0x78c13c3cf03cfdcc), U64_C (0x1ffd81813e817cbf),
+ U64_C (0x354094946a94d4fe), U64_C (0xf31cf7f7fbf7eb0c),
+ U64_C (0x6f18b9b9deb9a167), U64_C (0x268b13134c13985f),
+ U64_C (0x58512c2cb02c7d9c), U64_C (0xbb05d3d36bd3d6b8),
+ U64_C (0xd38ce7e7bbe76b5c), U64_C (0xdc396e6ea56e57cb),
+ U64_C (0x95aac4c437c46ef3), U64_C (0x061b03030c03180f),
+ U64_C (0xacdc565645568a13), U64_C (0x885e44440d441a49),
+ U64_C (0xfea07f7fe17fdf9e), U64_C (0x4f88a9a99ea92137),
+ U64_C (0x54672a2aa82a4d82), U64_C (0x6b0abbbbd6bbb16d),
+ U64_C (0x9f87c1c123c146e2), U64_C (0xa6f153535153a202),
+ U64_C (0xa572dcdc57dcae8b), U64_C (0x16530b0b2c0b5827),
+ U64_C (0x27019d9d4e9d9cd3), U64_C (0xd82b6c6cad6c47c1),
+ U64_C (0x62a43131c43195f5), U64_C (0xe8f37474cd7487b9),
+ U64_C (0xf115f6f6fff6e309), U64_C (0x8c4c464605460a43),
+ U64_C (0x45a5acac8aac0926), U64_C (0x0fb589891e893c97),
+ U64_C (0x28b414145014a044), U64_C (0xdfbae1e1a3e15b42),
+ U64_C (0x2ca616165816b04e), U64_C (0x74f73a3ae83acdd2),
+ U64_C (0xd2066969b9696fd0), U64_C (0x124109092409482d),
+ U64_C (0xe0d77070dd70a7ad), U64_C (0x716fb6b6e2b6d954),
+ U64_C (0xbd1ed0d067d0ceb7), U64_C (0xc7d6eded93ed3b7e),
+ U64_C (0x85e2cccc17cc2edb), U64_C (0x8468424215422a57),
+ U64_C (0x2d2c98985a98b4c2), U64_C (0x55eda4a4aaa4490e),
+ U64_C (0x50752828a0285d88), U64_C (0xb8865c5c6d5cda31),
+ U64_C (0xed6bf8f8c7f8933f), U64_C (0x11c28686228644a4),
+ };
+
+static const u64 C3[256] =
+ {
+ U64_C (0x7830d818186018c0), U64_C (0xaf462623238c2305),
+ U64_C (0xf991b8c6c63fc67e), U64_C (0x6fcdfbe8e887e813),
+ U64_C (0xa113cb878726874c), U64_C (0x626d11b8b8dab8a9),
+ U64_C (0x0502090101040108), U64_C (0x6e9e0d4f4f214f42),
+ U64_C (0xee6c9b3636d836ad), U64_C (0x0451ffa6a6a2a659),
+ U64_C (0xbdb90cd2d26fd2de), U64_C (0x06f70ef5f5f3f5fb),
+ U64_C (0x80f2967979f979ef), U64_C (0xcede306f6fa16f5f),
+ U64_C (0xef3f6d91917e91fc), U64_C (0x07a4f852525552aa),
+ U64_C (0xfdc04760609d6027), U64_C (0x766535bcbccabc89),
+ U64_C (0xcd2b379b9b569bac), U64_C (0x8c018a8e8e028e04),
+ U64_C (0x155bd2a3a3b6a371), U64_C (0x3c186c0c0c300c60),
+ U64_C (0x8af6847b7bf17bff), U64_C (0xe16a803535d435b5),
+ U64_C (0x693af51d1d741de8), U64_C (0x47ddb3e0e0a7e053),
+ U64_C (0xacb321d7d77bd7f6), U64_C (0xed999cc2c22fc25e),
+ U64_C (0x965c432e2eb82e6d), U64_C (0x7a96294b4b314b62),
+ U64_C (0x21e15dfefedffea3), U64_C (0x16aed55757415782),
+ U64_C (0x412abd15155415a8), U64_C (0xb6eee87777c1779f),
+ U64_C (0xeb6e923737dc37a5), U64_C (0x56d79ee5e5b3e57b),
+ U64_C (0xd923139f9f469f8c), U64_C (0x17fd23f0f0e7f0d3),
+ U64_C (0x7f94204a4a354a6a), U64_C (0x95a944dada4fda9e),
+ U64_C (0x25b0a258587d58fa), U64_C (0xca8fcfc9c903c906),
+ U64_C (0x8d527c2929a42955), U64_C (0x22145a0a0a280a50),
+ U64_C (0x4f7f50b1b1feb1e1), U64_C (0x1a5dc9a0a0baa069),
+ U64_C (0xdad6146b6bb16b7f), U64_C (0xab17d985852e855c),
+ U64_C (0x73673cbdbdcebd81), U64_C (0x34ba8f5d5d695dd2),
+ U64_C (0x5020901010401080), U64_C (0x03f507f4f4f7f4f3),
+ U64_C (0xc08bddcbcb0bcb16), U64_C (0xc67cd33e3ef83eed),
+ U64_C (0x110a2d0505140528), U64_C (0xe6ce78676781671f),
+ U64_C (0x53d597e4e4b7e473), U64_C (0xbb4e0227279c2725),
+ U64_C (0x5882734141194132), U64_C (0x9d0ba78b8b168b2c),
+ U64_C (0x0153f6a7a7a6a751), U64_C (0x94fab27d7de97dcf),
+ U64_C (0xfb374995956e95dc), U64_C (0x9fad56d8d847d88e),
+ U64_C (0x30eb70fbfbcbfb8b), U64_C (0x71c1cdeeee9fee23),
+ U64_C (0x91f8bb7c7ced7cc7), U64_C (0xe3cc716666856617),
+ U64_C (0x8ea77bdddd53dda6), U64_C (0x4b2eaf17175c17b8),
+ U64_C (0x468e454747014702), U64_C (0xdc211a9e9e429e84),
+ U64_C (0xc589d4caca0fca1e), U64_C (0x995a582d2db42d75),
+ U64_C (0x79632ebfbfc6bf91), U64_C (0x1b0e3f07071c0738),
+ U64_C (0x2347acadad8ead01), U64_C (0x2fb4b05a5a755aea),
+ U64_C (0xb51bef838336836c), U64_C (0xff66b63333cc3385),
+ U64_C (0xf2c65c636391633f), U64_C (0x0a04120202080210),
+ U64_C (0x384993aaaa92aa39), U64_C (0xa8e2de7171d971af),
+ U64_C (0xcf8dc6c8c807c80e), U64_C (0x7d32d119196419c8),
+ U64_C (0x70923b4949394972), U64_C (0x9aaf5fd9d943d986),
+ U64_C (0x1df931f2f2eff2c3), U64_C (0x48dba8e3e3abe34b),
+ U64_C (0x2ab6b95b5b715be2), U64_C (0x920dbc88881a8834),
+ U64_C (0xc8293e9a9a529aa4), U64_C (0xbe4c0b262698262d),
+ U64_C (0xfa64bf3232c8328d), U64_C (0x4a7d59b0b0fab0e9),
+ U64_C (0x6acff2e9e983e91b), U64_C (0x331e770f0f3c0f78),
+ U64_C (0xa6b733d5d573d5e6), U64_C (0xba1df480803a8074),
+ U64_C (0x7c6127bebec2be99), U64_C (0xde87ebcdcd13cd26),
+ U64_C (0xe468893434d034bd), U64_C (0x75903248483d487a),
+ U64_C (0x24e354ffffdbffab), U64_C (0x8ff48d7a7af57af7),
+ U64_C (0xea3d6490907a90f4), U64_C (0x3ebe9d5f5f615fc2),
+ U64_C (0xa0403d202080201d), U64_C (0xd5d00f6868bd6867),
+ U64_C (0x7234ca1a1a681ad0), U64_C (0x2c41b7aeae82ae19),
+ U64_C (0x5e757db4b4eab4c9), U64_C (0x19a8ce54544d549a),
+ U64_C (0xe53b7f93937693ec), U64_C (0xaa442f222288220d),
+ U64_C (0xe9c86364648d6407), U64_C (0x12ff2af1f1e3f1db),
+ U64_C (0xa2e6cc7373d173bf), U64_C (0x5a24821212481290),
+ U64_C (0x5d807a40401d403a), U64_C (0x2810480808200840),
+ U64_C (0xe89b95c3c32bc356), U64_C (0x7bc5dfecec97ec33),
+ U64_C (0x90ab4ddbdb4bdb96), U64_C (0x1f5fc0a1a1bea161),
+ U64_C (0x8307918d8d0e8d1c), U64_C (0xc97ac83d3df43df5),
+ U64_C (0xf1335b97976697cc), U64_C (0x0000000000000000),
+ U64_C (0xd483f9cfcf1bcf36), U64_C (0x87566e2b2bac2b45),
+ U64_C (0xb3ece17676c57697), U64_C (0xb019e68282328264),
+ U64_C (0xa9b128d6d67fd6fe), U64_C (0x7736c31b1b6c1bd8),
+ U64_C (0x5b7774b5b5eeb5c1), U64_C (0x2943beafaf86af11),
+ U64_C (0xdfd41d6a6ab56a77), U64_C (0x0da0ea50505d50ba),
+ U64_C (0x4c8a574545094512), U64_C (0x18fb38f3f3ebf3cb),
+ U64_C (0xf060ad3030c0309d), U64_C (0x74c3c4efef9bef2b),
+ U64_C (0xc37eda3f3ffc3fe5), U64_C (0x1caac75555495592),
+ U64_C (0x1059dba2a2b2a279), U64_C (0x65c9e9eaea8fea03),
+ U64_C (0xecca6a656589650f), U64_C (0x686903babad2bab9),
+ U64_C (0x935e4a2f2fbc2f65), U64_C (0xe79d8ec0c027c04e),
+ U64_C (0x81a160dede5fdebe), U64_C (0x6c38fc1c1c701ce0),
+ U64_C (0x2ee746fdfdd3fdbb), U64_C (0x649a1f4d4d294d52),
+ U64_C (0xe0397692927292e4), U64_C (0xbceafa7575c9758f),
+ U64_C (0x1e0c360606180630), U64_C (0x9809ae8a8a128a24),
+ U64_C (0x40794bb2b2f2b2f9), U64_C (0x59d185e6e6bfe663),
+ U64_C (0x361c7e0e0e380e70), U64_C (0x633ee71f1f7c1ff8),
+ U64_C (0xf7c4556262956237), U64_C (0xa3b53ad4d477d4ee),
+ U64_C (0x324d81a8a89aa829), U64_C (0xf4315296966296c4),
+ U64_C (0x3aef62f9f9c3f99b), U64_C (0xf697a3c5c533c566),
+ U64_C (0xb14a102525942535), U64_C (0x20b2ab59597959f2),
+ U64_C (0xae15d084842a8454), U64_C (0xa7e4c57272d572b7),
+ U64_C (0xdd72ec3939e439d5), U64_C (0x6198164c4c2d4c5a),
+ U64_C (0x3bbc945e5e655eca), U64_C (0x85f09f7878fd78e7),
+ U64_C (0xd870e53838e038dd), U64_C (0x8605988c8c0a8c14),
+ U64_C (0xb2bf17d1d163d1c6), U64_C (0x0b57e4a5a5aea541),
+ U64_C (0x4dd9a1e2e2afe243), U64_C (0xf8c24e616199612f),
+ U64_C (0x457b42b3b3f6b3f1), U64_C (0xa542342121842115),
+ U64_C (0xd625089c9c4a9c94), U64_C (0x663cee1e1e781ef0),
+ U64_C (0x5286614343114322), U64_C (0xfc93b1c7c73bc776),
+ U64_C (0x2be54ffcfcd7fcb3), U64_C (0x1408240404100420),
+ U64_C (0x08a2e351515951b2), U64_C (0xc72f2599995e99bc),
+ U64_C (0xc4da226d6da96d4f), U64_C (0x391a650d0d340d68),
+ U64_C (0x35e979fafacffa83), U64_C (0x84a369dfdf5bdfb6),
+ U64_C (0x9bfca97e7ee57ed7), U64_C (0xb44819242490243d),
+ U64_C (0xd776fe3b3bec3bc5), U64_C (0x3d4b9aabab96ab31),
+ U64_C (0xd181f0cece1fce3e), U64_C (0x5522991111441188),
+ U64_C (0x8903838f8f068f0c), U64_C (0x6b9c044e4e254e4a),
+ U64_C (0x517366b7b7e6b7d1), U64_C (0x60cbe0ebeb8beb0b),
+ U64_C (0xcc78c13c3cf03cfd), U64_C (0xbf1ffd81813e817c),
+ U64_C (0xfe354094946a94d4), U64_C (0x0cf31cf7f7fbf7eb),
+ U64_C (0x676f18b9b9deb9a1), U64_C (0x5f268b13134c1398),
+ U64_C (0x9c58512c2cb02c7d), U64_C (0xb8bb05d3d36bd3d6),
+ U64_C (0x5cd38ce7e7bbe76b), U64_C (0xcbdc396e6ea56e57),
+ U64_C (0xf395aac4c437c46e), U64_C (0x0f061b03030c0318),
+ U64_C (0x13acdc565645568a), U64_C (0x49885e44440d441a),
+ U64_C (0x9efea07f7fe17fdf), U64_C (0x374f88a9a99ea921),
+ U64_C (0x8254672a2aa82a4d), U64_C (0x6d6b0abbbbd6bbb1),
+ U64_C (0xe29f87c1c123c146), U64_C (0x02a6f153535153a2),
+ U64_C (0x8ba572dcdc57dcae), U64_C (0x2716530b0b2c0b58),
+ U64_C (0xd327019d9d4e9d9c), U64_C (0xc1d82b6c6cad6c47),
+ U64_C (0xf562a43131c43195), U64_C (0xb9e8f37474cd7487),
+ U64_C (0x09f115f6f6fff6e3), U64_C (0x438c4c464605460a),
+ U64_C (0x2645a5acac8aac09), U64_C (0x970fb589891e893c),
+ U64_C (0x4428b414145014a0), U64_C (0x42dfbae1e1a3e15b),
+ U64_C (0x4e2ca616165816b0), U64_C (0xd274f73a3ae83acd),
+ U64_C (0xd0d2066969b9696f), U64_C (0x2d12410909240948),
+ U64_C (0xade0d77070dd70a7), U64_C (0x54716fb6b6e2b6d9),
+ U64_C (0xb7bd1ed0d067d0ce), U64_C (0x7ec7d6eded93ed3b),
+ U64_C (0xdb85e2cccc17cc2e), U64_C (0x578468424215422a),
+ U64_C (0xc22d2c98985a98b4), U64_C (0x0e55eda4a4aaa449),
+ U64_C (0x8850752828a0285d), U64_C (0x31b8865c5c6d5cda),
+ U64_C (0x3fed6bf8f8c7f893), U64_C (0xa411c28686228644),
+ };
+
+static const u64 C4[256] =
+ {
+ U64_C (0xc07830d818186018), U64_C (0x05af462623238c23),
+ U64_C (0x7ef991b8c6c63fc6), U64_C (0x136fcdfbe8e887e8),
+ U64_C (0x4ca113cb87872687), U64_C (0xa9626d11b8b8dab8),
+ U64_C (0x0805020901010401), U64_C (0x426e9e0d4f4f214f),
+ U64_C (0xadee6c9b3636d836), U64_C (0x590451ffa6a6a2a6),
+ U64_C (0xdebdb90cd2d26fd2), U64_C (0xfb06f70ef5f5f3f5),
+ U64_C (0xef80f2967979f979), U64_C (0x5fcede306f6fa16f),
+ U64_C (0xfcef3f6d91917e91), U64_C (0xaa07a4f852525552),
+ U64_C (0x27fdc04760609d60), U64_C (0x89766535bcbccabc),
+ U64_C (0xaccd2b379b9b569b), U64_C (0x048c018a8e8e028e),
+ U64_C (0x71155bd2a3a3b6a3), U64_C (0x603c186c0c0c300c),
+ U64_C (0xff8af6847b7bf17b), U64_C (0xb5e16a803535d435),
+ U64_C (0xe8693af51d1d741d), U64_C (0x5347ddb3e0e0a7e0),
+ U64_C (0xf6acb321d7d77bd7), U64_C (0x5eed999cc2c22fc2),
+ U64_C (0x6d965c432e2eb82e), U64_C (0x627a96294b4b314b),
+ U64_C (0xa321e15dfefedffe), U64_C (0x8216aed557574157),
+ U64_C (0xa8412abd15155415), U64_C (0x9fb6eee87777c177),
+ U64_C (0xa5eb6e923737dc37), U64_C (0x7b56d79ee5e5b3e5),
+ U64_C (0x8cd923139f9f469f), U64_C (0xd317fd23f0f0e7f0),
+ U64_C (0x6a7f94204a4a354a), U64_C (0x9e95a944dada4fda),
+ U64_C (0xfa25b0a258587d58), U64_C (0x06ca8fcfc9c903c9),
+ U64_C (0x558d527c2929a429), U64_C (0x5022145a0a0a280a),
+ U64_C (0xe14f7f50b1b1feb1), U64_C (0x691a5dc9a0a0baa0),
+ U64_C (0x7fdad6146b6bb16b), U64_C (0x5cab17d985852e85),
+ U64_C (0x8173673cbdbdcebd), U64_C (0xd234ba8f5d5d695d),
+ U64_C (0x8050209010104010), U64_C (0xf303f507f4f4f7f4),
+ U64_C (0x16c08bddcbcb0bcb), U64_C (0xedc67cd33e3ef83e),
+ U64_C (0x28110a2d05051405), U64_C (0x1fe6ce7867678167),
+ U64_C (0x7353d597e4e4b7e4), U64_C (0x25bb4e0227279c27),
+ U64_C (0x3258827341411941), U64_C (0x2c9d0ba78b8b168b),
+ U64_C (0x510153f6a7a7a6a7), U64_C (0xcf94fab27d7de97d),
+ U64_C (0xdcfb374995956e95), U64_C (0x8e9fad56d8d847d8),
+ U64_C (0x8b30eb70fbfbcbfb), U64_C (0x2371c1cdeeee9fee),
+ U64_C (0xc791f8bb7c7ced7c), U64_C (0x17e3cc7166668566),
+ U64_C (0xa68ea77bdddd53dd), U64_C (0xb84b2eaf17175c17),
+ U64_C (0x02468e4547470147), U64_C (0x84dc211a9e9e429e),
+ U64_C (0x1ec589d4caca0fca), U64_C (0x75995a582d2db42d),
+ U64_C (0x9179632ebfbfc6bf), U64_C (0x381b0e3f07071c07),
+ U64_C (0x012347acadad8ead), U64_C (0xea2fb4b05a5a755a),
+ U64_C (0x6cb51bef83833683), U64_C (0x85ff66b63333cc33),
+ U64_C (0x3ff2c65c63639163), U64_C (0x100a041202020802),
+ U64_C (0x39384993aaaa92aa), U64_C (0xafa8e2de7171d971),
+ U64_C (0x0ecf8dc6c8c807c8), U64_C (0xc87d32d119196419),
+ U64_C (0x7270923b49493949), U64_C (0x869aaf5fd9d943d9),
+ U64_C (0xc31df931f2f2eff2), U64_C (0x4b48dba8e3e3abe3),
+ U64_C (0xe22ab6b95b5b715b), U64_C (0x34920dbc88881a88),
+ U64_C (0xa4c8293e9a9a529a), U64_C (0x2dbe4c0b26269826),
+ U64_C (0x8dfa64bf3232c832), U64_C (0xe94a7d59b0b0fab0),
+ U64_C (0x1b6acff2e9e983e9), U64_C (0x78331e770f0f3c0f),
+ U64_C (0xe6a6b733d5d573d5), U64_C (0x74ba1df480803a80),
+ U64_C (0x997c6127bebec2be), U64_C (0x26de87ebcdcd13cd),
+ U64_C (0xbde468893434d034), U64_C (0x7a75903248483d48),
+ U64_C (0xab24e354ffffdbff), U64_C (0xf78ff48d7a7af57a),
+ U64_C (0xf4ea3d6490907a90), U64_C (0xc23ebe9d5f5f615f),
+ U64_C (0x1da0403d20208020), U64_C (0x67d5d00f6868bd68),
+ U64_C (0xd07234ca1a1a681a), U64_C (0x192c41b7aeae82ae),
+ U64_C (0xc95e757db4b4eab4), U64_C (0x9a19a8ce54544d54),
+ U64_C (0xece53b7f93937693), U64_C (0x0daa442f22228822),
+ U64_C (0x07e9c86364648d64), U64_C (0xdb12ff2af1f1e3f1),
+ U64_C (0xbfa2e6cc7373d173), U64_C (0x905a248212124812),
+ U64_C (0x3a5d807a40401d40), U64_C (0x4028104808082008),
+ U64_C (0x56e89b95c3c32bc3), U64_C (0x337bc5dfecec97ec),
+ U64_C (0x9690ab4ddbdb4bdb), U64_C (0x611f5fc0a1a1bea1),
+ U64_C (0x1c8307918d8d0e8d), U64_C (0xf5c97ac83d3df43d),
+ U64_C (0xccf1335b97976697), U64_C (0x0000000000000000),
+ U64_C (0x36d483f9cfcf1bcf), U64_C (0x4587566e2b2bac2b),
+ U64_C (0x97b3ece17676c576), U64_C (0x64b019e682823282),
+ U64_C (0xfea9b128d6d67fd6), U64_C (0xd87736c31b1b6c1b),
+ U64_C (0xc15b7774b5b5eeb5), U64_C (0x112943beafaf86af),
+ U64_C (0x77dfd41d6a6ab56a), U64_C (0xba0da0ea50505d50),
+ U64_C (0x124c8a5745450945), U64_C (0xcb18fb38f3f3ebf3),
+ U64_C (0x9df060ad3030c030), U64_C (0x2b74c3c4efef9bef),
+ U64_C (0xe5c37eda3f3ffc3f), U64_C (0x921caac755554955),
+ U64_C (0x791059dba2a2b2a2), U64_C (0x0365c9e9eaea8fea),
+ U64_C (0x0fecca6a65658965), U64_C (0xb9686903babad2ba),
+ U64_C (0x65935e4a2f2fbc2f), U64_C (0x4ee79d8ec0c027c0),
+ U64_C (0xbe81a160dede5fde), U64_C (0xe06c38fc1c1c701c),
+ U64_C (0xbb2ee746fdfdd3fd), U64_C (0x52649a1f4d4d294d),
+ U64_C (0xe4e0397692927292), U64_C (0x8fbceafa7575c975),
+ U64_C (0x301e0c3606061806), U64_C (0x249809ae8a8a128a),
+ U64_C (0xf940794bb2b2f2b2), U64_C (0x6359d185e6e6bfe6),
+ U64_C (0x70361c7e0e0e380e), U64_C (0xf8633ee71f1f7c1f),
+ U64_C (0x37f7c45562629562), U64_C (0xeea3b53ad4d477d4),
+ U64_C (0x29324d81a8a89aa8), U64_C (0xc4f4315296966296),
+ U64_C (0x9b3aef62f9f9c3f9), U64_C (0x66f697a3c5c533c5),
+ U64_C (0x35b14a1025259425), U64_C (0xf220b2ab59597959),
+ U64_C (0x54ae15d084842a84), U64_C (0xb7a7e4c57272d572),
+ U64_C (0xd5dd72ec3939e439), U64_C (0x5a6198164c4c2d4c),
+ U64_C (0xca3bbc945e5e655e), U64_C (0xe785f09f7878fd78),
+ U64_C (0xddd870e53838e038), U64_C (0x148605988c8c0a8c),
+ U64_C (0xc6b2bf17d1d163d1), U64_C (0x410b57e4a5a5aea5),
+ U64_C (0x434dd9a1e2e2afe2), U64_C (0x2ff8c24e61619961),
+ U64_C (0xf1457b42b3b3f6b3), U64_C (0x15a5423421218421),
+ U64_C (0x94d625089c9c4a9c), U64_C (0xf0663cee1e1e781e),
+ U64_C (0x2252866143431143), U64_C (0x76fc93b1c7c73bc7),
+ U64_C (0xb32be54ffcfcd7fc), U64_C (0x2014082404041004),
+ U64_C (0xb208a2e351515951), U64_C (0xbcc72f2599995e99),
+ U64_C (0x4fc4da226d6da96d), U64_C (0x68391a650d0d340d),
+ U64_C (0x8335e979fafacffa), U64_C (0xb684a369dfdf5bdf),
+ U64_C (0xd79bfca97e7ee57e), U64_C (0x3db4481924249024),
+ U64_C (0xc5d776fe3b3bec3b), U64_C (0x313d4b9aabab96ab),
+ U64_C (0x3ed181f0cece1fce), U64_C (0x8855229911114411),
+ U64_C (0x0c8903838f8f068f), U64_C (0x4a6b9c044e4e254e),
+ U64_C (0xd1517366b7b7e6b7), U64_C (0x0b60cbe0ebeb8beb),
+ U64_C (0xfdcc78c13c3cf03c), U64_C (0x7cbf1ffd81813e81),
+ U64_C (0xd4fe354094946a94), U64_C (0xeb0cf31cf7f7fbf7),
+ U64_C (0xa1676f18b9b9deb9), U64_C (0x985f268b13134c13),
+ U64_C (0x7d9c58512c2cb02c), U64_C (0xd6b8bb05d3d36bd3),
+ U64_C (0x6b5cd38ce7e7bbe7), U64_C (0x57cbdc396e6ea56e),
+ U64_C (0x6ef395aac4c437c4), U64_C (0x180f061b03030c03),
+ U64_C (0x8a13acdc56564556), U64_C (0x1a49885e44440d44),
+ U64_C (0xdf9efea07f7fe17f), U64_C (0x21374f88a9a99ea9),
+ U64_C (0x4d8254672a2aa82a), U64_C (0xb16d6b0abbbbd6bb),
+ U64_C (0x46e29f87c1c123c1), U64_C (0xa202a6f153535153),
+ U64_C (0xae8ba572dcdc57dc), U64_C (0x582716530b0b2c0b),
+ U64_C (0x9cd327019d9d4e9d), U64_C (0x47c1d82b6c6cad6c),
+ U64_C (0x95f562a43131c431), U64_C (0x87b9e8f37474cd74),
+ U64_C (0xe309f115f6f6fff6), U64_C (0x0a438c4c46460546),
+ U64_C (0x092645a5acac8aac), U64_C (0x3c970fb589891e89),
+ U64_C (0xa04428b414145014), U64_C (0x5b42dfbae1e1a3e1),
+ U64_C (0xb04e2ca616165816), U64_C (0xcdd274f73a3ae83a),
+ U64_C (0x6fd0d2066969b969), U64_C (0x482d124109092409),
+ U64_C (0xa7ade0d77070dd70), U64_C (0xd954716fb6b6e2b6),
+ U64_C (0xceb7bd1ed0d067d0), U64_C (0x3b7ec7d6eded93ed),
+ U64_C (0x2edb85e2cccc17cc), U64_C (0x2a57846842421542),
+ U64_C (0xb4c22d2c98985a98), U64_C (0x490e55eda4a4aaa4),
+ U64_C (0x5d8850752828a028), U64_C (0xda31b8865c5c6d5c),
+ U64_C (0x933fed6bf8f8c7f8), U64_C (0x44a411c286862286),
+ };
+
+static const u64 C5[256] =
+ {
+ U64_C (0x18c07830d8181860), U64_C (0x2305af462623238c),
+ U64_C (0xc67ef991b8c6c63f), U64_C (0xe8136fcdfbe8e887),
+ U64_C (0x874ca113cb878726), U64_C (0xb8a9626d11b8b8da),
+ U64_C (0x0108050209010104), U64_C (0x4f426e9e0d4f4f21),
+ U64_C (0x36adee6c9b3636d8), U64_C (0xa6590451ffa6a6a2),
+ U64_C (0xd2debdb90cd2d26f), U64_C (0xf5fb06f70ef5f5f3),
+ U64_C (0x79ef80f2967979f9), U64_C (0x6f5fcede306f6fa1),
+ U64_C (0x91fcef3f6d91917e), U64_C (0x52aa07a4f8525255),
+ U64_C (0x6027fdc04760609d), U64_C (0xbc89766535bcbcca),
+ U64_C (0x9baccd2b379b9b56), U64_C (0x8e048c018a8e8e02),
+ U64_C (0xa371155bd2a3a3b6), U64_C (0x0c603c186c0c0c30),
+ U64_C (0x7bff8af6847b7bf1), U64_C (0x35b5e16a803535d4),
+ U64_C (0x1de8693af51d1d74), U64_C (0xe05347ddb3e0e0a7),
+ U64_C (0xd7f6acb321d7d77b), U64_C (0xc25eed999cc2c22f),
+ U64_C (0x2e6d965c432e2eb8), U64_C (0x4b627a96294b4b31),
+ U64_C (0xfea321e15dfefedf), U64_C (0x578216aed5575741),
+ U64_C (0x15a8412abd151554), U64_C (0x779fb6eee87777c1),
+ U64_C (0x37a5eb6e923737dc), U64_C (0xe57b56d79ee5e5b3),
+ U64_C (0x9f8cd923139f9f46), U64_C (0xf0d317fd23f0f0e7),
+ U64_C (0x4a6a7f94204a4a35), U64_C (0xda9e95a944dada4f),
+ U64_C (0x58fa25b0a258587d), U64_C (0xc906ca8fcfc9c903),
+ U64_C (0x29558d527c2929a4), U64_C (0x0a5022145a0a0a28),
+ U64_C (0xb1e14f7f50b1b1fe), U64_C (0xa0691a5dc9a0a0ba),
+ U64_C (0x6b7fdad6146b6bb1), U64_C (0x855cab17d985852e),
+ U64_C (0xbd8173673cbdbdce), U64_C (0x5dd234ba8f5d5d69),
+ U64_C (0x1080502090101040), U64_C (0xf4f303f507f4f4f7),
+ U64_C (0xcb16c08bddcbcb0b), U64_C (0x3eedc67cd33e3ef8),
+ U64_C (0x0528110a2d050514), U64_C (0x671fe6ce78676781),
+ U64_C (0xe47353d597e4e4b7), U64_C (0x2725bb4e0227279c),
+ U64_C (0x4132588273414119), U64_C (0x8b2c9d0ba78b8b16),
+ U64_C (0xa7510153f6a7a7a6), U64_C (0x7dcf94fab27d7de9),
+ U64_C (0x95dcfb374995956e), U64_C (0xd88e9fad56d8d847),
+ U64_C (0xfb8b30eb70fbfbcb), U64_C (0xee2371c1cdeeee9f),
+ U64_C (0x7cc791f8bb7c7ced), U64_C (0x6617e3cc71666685),
+ U64_C (0xdda68ea77bdddd53), U64_C (0x17b84b2eaf17175c),
+ U64_C (0x4702468e45474701), U64_C (0x9e84dc211a9e9e42),
+ U64_C (0xca1ec589d4caca0f), U64_C (0x2d75995a582d2db4),
+ U64_C (0xbf9179632ebfbfc6), U64_C (0x07381b0e3f07071c),
+ U64_C (0xad012347acadad8e), U64_C (0x5aea2fb4b05a5a75),
+ U64_C (0x836cb51bef838336), U64_C (0x3385ff66b63333cc),
+ U64_C (0x633ff2c65c636391), U64_C (0x02100a0412020208),
+ U64_C (0xaa39384993aaaa92), U64_C (0x71afa8e2de7171d9),
+ U64_C (0xc80ecf8dc6c8c807), U64_C (0x19c87d32d1191964),
+ U64_C (0x497270923b494939), U64_C (0xd9869aaf5fd9d943),
+ U64_C (0xf2c31df931f2f2ef), U64_C (0xe34b48dba8e3e3ab),
+ U64_C (0x5be22ab6b95b5b71), U64_C (0x8834920dbc88881a),
+ U64_C (0x9aa4c8293e9a9a52), U64_C (0x262dbe4c0b262698),
+ U64_C (0x328dfa64bf3232c8), U64_C (0xb0e94a7d59b0b0fa),
+ U64_C (0xe91b6acff2e9e983), U64_C (0x0f78331e770f0f3c),
+ U64_C (0xd5e6a6b733d5d573), U64_C (0x8074ba1df480803a),
+ U64_C (0xbe997c6127bebec2), U64_C (0xcd26de87ebcdcd13),
+ U64_C (0x34bde468893434d0), U64_C (0x487a75903248483d),
+ U64_C (0xffab24e354ffffdb), U64_C (0x7af78ff48d7a7af5),
+ U64_C (0x90f4ea3d6490907a), U64_C (0x5fc23ebe9d5f5f61),
+ U64_C (0x201da0403d202080), U64_C (0x6867d5d00f6868bd),
+ U64_C (0x1ad07234ca1a1a68), U64_C (0xae192c41b7aeae82),
+ U64_C (0xb4c95e757db4b4ea), U64_C (0x549a19a8ce54544d),
+ U64_C (0x93ece53b7f939376), U64_C (0x220daa442f222288),
+ U64_C (0x6407e9c86364648d), U64_C (0xf1db12ff2af1f1e3),
+ U64_C (0x73bfa2e6cc7373d1), U64_C (0x12905a2482121248),
+ U64_C (0x403a5d807a40401d), U64_C (0x0840281048080820),
+ U64_C (0xc356e89b95c3c32b), U64_C (0xec337bc5dfecec97),
+ U64_C (0xdb9690ab4ddbdb4b), U64_C (0xa1611f5fc0a1a1be),
+ U64_C (0x8d1c8307918d8d0e), U64_C (0x3df5c97ac83d3df4),
+ U64_C (0x97ccf1335b979766), U64_C (0x0000000000000000),
+ U64_C (0xcf36d483f9cfcf1b), U64_C (0x2b4587566e2b2bac),
+ U64_C (0x7697b3ece17676c5), U64_C (0x8264b019e6828232),
+ U64_C (0xd6fea9b128d6d67f), U64_C (0x1bd87736c31b1b6c),
+ U64_C (0xb5c15b7774b5b5ee), U64_C (0xaf112943beafaf86),
+ U64_C (0x6a77dfd41d6a6ab5), U64_C (0x50ba0da0ea50505d),
+ U64_C (0x45124c8a57454509), U64_C (0xf3cb18fb38f3f3eb),
+ U64_C (0x309df060ad3030c0), U64_C (0xef2b74c3c4efef9b),
+ U64_C (0x3fe5c37eda3f3ffc), U64_C (0x55921caac7555549),
+ U64_C (0xa2791059dba2a2b2), U64_C (0xea0365c9e9eaea8f),
+ U64_C (0x650fecca6a656589), U64_C (0xbab9686903babad2),
+ U64_C (0x2f65935e4a2f2fbc), U64_C (0xc04ee79d8ec0c027),
+ U64_C (0xdebe81a160dede5f), U64_C (0x1ce06c38fc1c1c70),
+ U64_C (0xfdbb2ee746fdfdd3), U64_C (0x4d52649a1f4d4d29),
+ U64_C (0x92e4e03976929272), U64_C (0x758fbceafa7575c9),
+ U64_C (0x06301e0c36060618), U64_C (0x8a249809ae8a8a12),
+ U64_C (0xb2f940794bb2b2f2), U64_C (0xe66359d185e6e6bf),
+ U64_C (0x0e70361c7e0e0e38), U64_C (0x1ff8633ee71f1f7c),
+ U64_C (0x6237f7c455626295), U64_C (0xd4eea3b53ad4d477),
+ U64_C (0xa829324d81a8a89a), U64_C (0x96c4f43152969662),
+ U64_C (0xf99b3aef62f9f9c3), U64_C (0xc566f697a3c5c533),
+ U64_C (0x2535b14a10252594), U64_C (0x59f220b2ab595979),
+ U64_C (0x8454ae15d084842a), U64_C (0x72b7a7e4c57272d5),
+ U64_C (0x39d5dd72ec3939e4), U64_C (0x4c5a6198164c4c2d),
+ U64_C (0x5eca3bbc945e5e65), U64_C (0x78e785f09f7878fd),
+ U64_C (0x38ddd870e53838e0), U64_C (0x8c148605988c8c0a),
+ U64_C (0xd1c6b2bf17d1d163), U64_C (0xa5410b57e4a5a5ae),
+ U64_C (0xe2434dd9a1e2e2af), U64_C (0x612ff8c24e616199),
+ U64_C (0xb3f1457b42b3b3f6), U64_C (0x2115a54234212184),
+ U64_C (0x9c94d625089c9c4a), U64_C (0x1ef0663cee1e1e78),
+ U64_C (0x4322528661434311), U64_C (0xc776fc93b1c7c73b),
+ U64_C (0xfcb32be54ffcfcd7), U64_C (0x0420140824040410),
+ U64_C (0x51b208a2e3515159), U64_C (0x99bcc72f2599995e),
+ U64_C (0x6d4fc4da226d6da9), U64_C (0x0d68391a650d0d34),
+ U64_C (0xfa8335e979fafacf), U64_C (0xdfb684a369dfdf5b),
+ U64_C (0x7ed79bfca97e7ee5), U64_C (0x243db44819242490),
+ U64_C (0x3bc5d776fe3b3bec), U64_C (0xab313d4b9aabab96),
+ U64_C (0xce3ed181f0cece1f), U64_C (0x1188552299111144),
+ U64_C (0x8f0c8903838f8f06), U64_C (0x4e4a6b9c044e4e25),
+ U64_C (0xb7d1517366b7b7e6), U64_C (0xeb0b60cbe0ebeb8b),
+ U64_C (0x3cfdcc78c13c3cf0), U64_C (0x817cbf1ffd81813e),
+ U64_C (0x94d4fe354094946a), U64_C (0xf7eb0cf31cf7f7fb),
+ U64_C (0xb9a1676f18b9b9de), U64_C (0x13985f268b13134c),
+ U64_C (0x2c7d9c58512c2cb0), U64_C (0xd3d6b8bb05d3d36b),
+ U64_C (0xe76b5cd38ce7e7bb), U64_C (0x6e57cbdc396e6ea5),
+ U64_C (0xc46ef395aac4c437), U64_C (0x03180f061b03030c),
+ U64_C (0x568a13acdc565645), U64_C (0x441a49885e44440d),
+ U64_C (0x7fdf9efea07f7fe1), U64_C (0xa921374f88a9a99e),
+ U64_C (0x2a4d8254672a2aa8), U64_C (0xbbb16d6b0abbbbd6),
+ U64_C (0xc146e29f87c1c123), U64_C (0x53a202a6f1535351),
+ U64_C (0xdcae8ba572dcdc57), U64_C (0x0b582716530b0b2c),
+ U64_C (0x9d9cd327019d9d4e), U64_C (0x6c47c1d82b6c6cad),
+ U64_C (0x3195f562a43131c4), U64_C (0x7487b9e8f37474cd),
+ U64_C (0xf6e309f115f6f6ff), U64_C (0x460a438c4c464605),
+ U64_C (0xac092645a5acac8a), U64_C (0x893c970fb589891e),
+ U64_C (0x14a04428b4141450), U64_C (0xe15b42dfbae1e1a3),
+ U64_C (0x16b04e2ca6161658), U64_C (0x3acdd274f73a3ae8),
+ U64_C (0x696fd0d2066969b9), U64_C (0x09482d1241090924),
+ U64_C (0x70a7ade0d77070dd), U64_C (0xb6d954716fb6b6e2),
+ U64_C (0xd0ceb7bd1ed0d067), U64_C (0xed3b7ec7d6eded93),
+ U64_C (0xcc2edb85e2cccc17), U64_C (0x422a578468424215),
+ U64_C (0x98b4c22d2c98985a), U64_C (0xa4490e55eda4a4aa),
+ U64_C (0x285d8850752828a0), U64_C (0x5cda31b8865c5c6d),
+ U64_C (0xf8933fed6bf8f8c7), U64_C (0x8644a411c2868622),
+ };
+
+static const u64 C6[256] =
+ {
+ U64_C (0x6018c07830d81818), U64_C (0x8c2305af46262323),
+ U64_C (0x3fc67ef991b8c6c6), U64_C (0x87e8136fcdfbe8e8),
+ U64_C (0x26874ca113cb8787), U64_C (0xdab8a9626d11b8b8),
+ U64_C (0x0401080502090101), U64_C (0x214f426e9e0d4f4f),
+ U64_C (0xd836adee6c9b3636), U64_C (0xa2a6590451ffa6a6),
+ U64_C (0x6fd2debdb90cd2d2), U64_C (0xf3f5fb06f70ef5f5),
+ U64_C (0xf979ef80f2967979), U64_C (0xa16f5fcede306f6f),
+ U64_C (0x7e91fcef3f6d9191), U64_C (0x5552aa07a4f85252),
+ U64_C (0x9d6027fdc0476060), U64_C (0xcabc89766535bcbc),
+ U64_C (0x569baccd2b379b9b), U64_C (0x028e048c018a8e8e),
+ U64_C (0xb6a371155bd2a3a3), U64_C (0x300c603c186c0c0c),
+ U64_C (0xf17bff8af6847b7b), U64_C (0xd435b5e16a803535),
+ U64_C (0x741de8693af51d1d), U64_C (0xa7e05347ddb3e0e0),
+ U64_C (0x7bd7f6acb321d7d7), U64_C (0x2fc25eed999cc2c2),
+ U64_C (0xb82e6d965c432e2e), U64_C (0x314b627a96294b4b),
+ U64_C (0xdffea321e15dfefe), U64_C (0x41578216aed55757),
+ U64_C (0x5415a8412abd1515), U64_C (0xc1779fb6eee87777),
+ U64_C (0xdc37a5eb6e923737), U64_C (0xb3e57b56d79ee5e5),
+ U64_C (0x469f8cd923139f9f), U64_C (0xe7f0d317fd23f0f0),
+ U64_C (0x354a6a7f94204a4a), U64_C (0x4fda9e95a944dada),
+ U64_C (0x7d58fa25b0a25858), U64_C (0x03c906ca8fcfc9c9),
+ U64_C (0xa429558d527c2929), U64_C (0x280a5022145a0a0a),
+ U64_C (0xfeb1e14f7f50b1b1), U64_C (0xbaa0691a5dc9a0a0),
+ U64_C (0xb16b7fdad6146b6b), U64_C (0x2e855cab17d98585),
+ U64_C (0xcebd8173673cbdbd), U64_C (0x695dd234ba8f5d5d),
+ U64_C (0x4010805020901010), U64_C (0xf7f4f303f507f4f4),
+ U64_C (0x0bcb16c08bddcbcb), U64_C (0xf83eedc67cd33e3e),
+ U64_C (0x140528110a2d0505), U64_C (0x81671fe6ce786767),
+ U64_C (0xb7e47353d597e4e4), U64_C (0x9c2725bb4e022727),
+ U64_C (0x1941325882734141), U64_C (0x168b2c9d0ba78b8b),
+ U64_C (0xa6a7510153f6a7a7), U64_C (0xe97dcf94fab27d7d),
+ U64_C (0x6e95dcfb37499595), U64_C (0x47d88e9fad56d8d8),
+ U64_C (0xcbfb8b30eb70fbfb), U64_C (0x9fee2371c1cdeeee),
+ U64_C (0xed7cc791f8bb7c7c), U64_C (0x856617e3cc716666),
+ U64_C (0x53dda68ea77bdddd), U64_C (0x5c17b84b2eaf1717),
+ U64_C (0x014702468e454747), U64_C (0x429e84dc211a9e9e),
+ U64_C (0x0fca1ec589d4caca), U64_C (0xb42d75995a582d2d),
+ U64_C (0xc6bf9179632ebfbf), U64_C (0x1c07381b0e3f0707),
+ U64_C (0x8ead012347acadad), U64_C (0x755aea2fb4b05a5a),
+ U64_C (0x36836cb51bef8383), U64_C (0xcc3385ff66b63333),
+ U64_C (0x91633ff2c65c6363), U64_C (0x0802100a04120202),
+ U64_C (0x92aa39384993aaaa), U64_C (0xd971afa8e2de7171),
+ U64_C (0x07c80ecf8dc6c8c8), U64_C (0x6419c87d32d11919),
+ U64_C (0x39497270923b4949), U64_C (0x43d9869aaf5fd9d9),
+ U64_C (0xeff2c31df931f2f2), U64_C (0xabe34b48dba8e3e3),
+ U64_C (0x715be22ab6b95b5b), U64_C (0x1a8834920dbc8888),
+ U64_C (0x529aa4c8293e9a9a), U64_C (0x98262dbe4c0b2626),
+ U64_C (0xc8328dfa64bf3232), U64_C (0xfab0e94a7d59b0b0),
+ U64_C (0x83e91b6acff2e9e9), U64_C (0x3c0f78331e770f0f),
+ U64_C (0x73d5e6a6b733d5d5), U64_C (0x3a8074ba1df48080),
+ U64_C (0xc2be997c6127bebe), U64_C (0x13cd26de87ebcdcd),
+ U64_C (0xd034bde468893434), U64_C (0x3d487a7590324848),
+ U64_C (0xdbffab24e354ffff), U64_C (0xf57af78ff48d7a7a),
+ U64_C (0x7a90f4ea3d649090), U64_C (0x615fc23ebe9d5f5f),
+ U64_C (0x80201da0403d2020), U64_C (0xbd6867d5d00f6868),
+ U64_C (0x681ad07234ca1a1a), U64_C (0x82ae192c41b7aeae),
+ U64_C (0xeab4c95e757db4b4), U64_C (0x4d549a19a8ce5454),
+ U64_C (0x7693ece53b7f9393), U64_C (0x88220daa442f2222),
+ U64_C (0x8d6407e9c8636464), U64_C (0xe3f1db12ff2af1f1),
+ U64_C (0xd173bfa2e6cc7373), U64_C (0x4812905a24821212),
+ U64_C (0x1d403a5d807a4040), U64_C (0x2008402810480808),
+ U64_C (0x2bc356e89b95c3c3), U64_C (0x97ec337bc5dfecec),
+ U64_C (0x4bdb9690ab4ddbdb), U64_C (0xbea1611f5fc0a1a1),
+ U64_C (0x0e8d1c8307918d8d), U64_C (0xf43df5c97ac83d3d),
+ U64_C (0x6697ccf1335b9797), U64_C (0x0000000000000000),
+ U64_C (0x1bcf36d483f9cfcf), U64_C (0xac2b4587566e2b2b),
+ U64_C (0xc57697b3ece17676), U64_C (0x328264b019e68282),
+ U64_C (0x7fd6fea9b128d6d6), U64_C (0x6c1bd87736c31b1b),
+ U64_C (0xeeb5c15b7774b5b5), U64_C (0x86af112943beafaf),
+ U64_C (0xb56a77dfd41d6a6a), U64_C (0x5d50ba0da0ea5050),
+ U64_C (0x0945124c8a574545), U64_C (0xebf3cb18fb38f3f3),
+ U64_C (0xc0309df060ad3030), U64_C (0x9bef2b74c3c4efef),
+ U64_C (0xfc3fe5c37eda3f3f), U64_C (0x4955921caac75555),
+ U64_C (0xb2a2791059dba2a2), U64_C (0x8fea0365c9e9eaea),
+ U64_C (0x89650fecca6a6565), U64_C (0xd2bab9686903baba),
+ U64_C (0xbc2f65935e4a2f2f), U64_C (0x27c04ee79d8ec0c0),
+ U64_C (0x5fdebe81a160dede), U64_C (0x701ce06c38fc1c1c),
+ U64_C (0xd3fdbb2ee746fdfd), U64_C (0x294d52649a1f4d4d),
+ U64_C (0x7292e4e039769292), U64_C (0xc9758fbceafa7575),
+ U64_C (0x1806301e0c360606), U64_C (0x128a249809ae8a8a),
+ U64_C (0xf2b2f940794bb2b2), U64_C (0xbfe66359d185e6e6),
+ U64_C (0x380e70361c7e0e0e), U64_C (0x7c1ff8633ee71f1f),
+ U64_C (0x956237f7c4556262), U64_C (0x77d4eea3b53ad4d4),
+ U64_C (0x9aa829324d81a8a8), U64_C (0x6296c4f431529696),
+ U64_C (0xc3f99b3aef62f9f9), U64_C (0x33c566f697a3c5c5),
+ U64_C (0x942535b14a102525), U64_C (0x7959f220b2ab5959),
+ U64_C (0x2a8454ae15d08484), U64_C (0xd572b7a7e4c57272),
+ U64_C (0xe439d5dd72ec3939), U64_C (0x2d4c5a6198164c4c),
+ U64_C (0x655eca3bbc945e5e), U64_C (0xfd78e785f09f7878),
+ U64_C (0xe038ddd870e53838), U64_C (0x0a8c148605988c8c),
+ U64_C (0x63d1c6b2bf17d1d1), U64_C (0xaea5410b57e4a5a5),
+ U64_C (0xafe2434dd9a1e2e2), U64_C (0x99612ff8c24e6161),
+ U64_C (0xf6b3f1457b42b3b3), U64_C (0x842115a542342121),
+ U64_C (0x4a9c94d625089c9c), U64_C (0x781ef0663cee1e1e),
+ U64_C (0x1143225286614343), U64_C (0x3bc776fc93b1c7c7),
+ U64_C (0xd7fcb32be54ffcfc), U64_C (0x1004201408240404),
+ U64_C (0x5951b208a2e35151), U64_C (0x5e99bcc72f259999),
+ U64_C (0xa96d4fc4da226d6d), U64_C (0x340d68391a650d0d),
+ U64_C (0xcffa8335e979fafa), U64_C (0x5bdfb684a369dfdf),
+ U64_C (0xe57ed79bfca97e7e), U64_C (0x90243db448192424),
+ U64_C (0xec3bc5d776fe3b3b), U64_C (0x96ab313d4b9aabab),
+ U64_C (0x1fce3ed181f0cece), U64_C (0x4411885522991111),
+ U64_C (0x068f0c8903838f8f), U64_C (0x254e4a6b9c044e4e),
+ U64_C (0xe6b7d1517366b7b7), U64_C (0x8beb0b60cbe0ebeb),
+ U64_C (0xf03cfdcc78c13c3c), U64_C (0x3e817cbf1ffd8181),
+ U64_C (0x6a94d4fe35409494), U64_C (0xfbf7eb0cf31cf7f7),
+ U64_C (0xdeb9a1676f18b9b9), U64_C (0x4c13985f268b1313),
+ U64_C (0xb02c7d9c58512c2c), U64_C (0x6bd3d6b8bb05d3d3),
+ U64_C (0xbbe76b5cd38ce7e7), U64_C (0xa56e57cbdc396e6e),
+ U64_C (0x37c46ef395aac4c4), U64_C (0x0c03180f061b0303),
+ U64_C (0x45568a13acdc5656), U64_C (0x0d441a49885e4444),
+ U64_C (0xe17fdf9efea07f7f), U64_C (0x9ea921374f88a9a9),
+ U64_C (0xa82a4d8254672a2a), U64_C (0xd6bbb16d6b0abbbb),
+ U64_C (0x23c146e29f87c1c1), U64_C (0x5153a202a6f15353),
+ U64_C (0x57dcae8ba572dcdc), U64_C (0x2c0b582716530b0b),
+ U64_C (0x4e9d9cd327019d9d), U64_C (0xad6c47c1d82b6c6c),
+ U64_C (0xc43195f562a43131), U64_C (0xcd7487b9e8f37474),
+ U64_C (0xfff6e309f115f6f6), U64_C (0x05460a438c4c4646),
+ U64_C (0x8aac092645a5acac), U64_C (0x1e893c970fb58989),
+ U64_C (0x5014a04428b41414), U64_C (0xa3e15b42dfbae1e1),
+ U64_C (0x5816b04e2ca61616), U64_C (0xe83acdd274f73a3a),
+ U64_C (0xb9696fd0d2066969), U64_C (0x2409482d12410909),
+ U64_C (0xdd70a7ade0d77070), U64_C (0xe2b6d954716fb6b6),
+ U64_C (0x67d0ceb7bd1ed0d0), U64_C (0x93ed3b7ec7d6eded),
+ U64_C (0x17cc2edb85e2cccc), U64_C (0x15422a5784684242),
+ U64_C (0x5a98b4c22d2c9898), U64_C (0xaaa4490e55eda4a4),
+ U64_C (0xa0285d8850752828), U64_C (0x6d5cda31b8865c5c),
+ U64_C (0xc7f8933fed6bf8f8), U64_C (0x228644a411c28686),
+ };
+
+static const u64 C7[256] =
+ {
+ U64_C (0x186018c07830d818), U64_C (0x238c2305af462623),
+ U64_C (0xc63fc67ef991b8c6), U64_C (0xe887e8136fcdfbe8),
+ U64_C (0x8726874ca113cb87), U64_C (0xb8dab8a9626d11b8),
+ U64_C (0x0104010805020901), U64_C (0x4f214f426e9e0d4f),
+ U64_C (0x36d836adee6c9b36), U64_C (0xa6a2a6590451ffa6),
+ U64_C (0xd26fd2debdb90cd2), U64_C (0xf5f3f5fb06f70ef5),
+ U64_C (0x79f979ef80f29679), U64_C (0x6fa16f5fcede306f),
+ U64_C (0x917e91fcef3f6d91), U64_C (0x525552aa07a4f852),
+ U64_C (0x609d6027fdc04760), U64_C (0xbccabc89766535bc),
+ U64_C (0x9b569baccd2b379b), U64_C (0x8e028e048c018a8e),
+ U64_C (0xa3b6a371155bd2a3), U64_C (0x0c300c603c186c0c),
+ U64_C (0x7bf17bff8af6847b), U64_C (0x35d435b5e16a8035),
+ U64_C (0x1d741de8693af51d), U64_C (0xe0a7e05347ddb3e0),
+ U64_C (0xd77bd7f6acb321d7), U64_C (0xc22fc25eed999cc2),
+ U64_C (0x2eb82e6d965c432e), U64_C (0x4b314b627a96294b),
+ U64_C (0xfedffea321e15dfe), U64_C (0x5741578216aed557),
+ U64_C (0x155415a8412abd15), U64_C (0x77c1779fb6eee877),
+ U64_C (0x37dc37a5eb6e9237), U64_C (0xe5b3e57b56d79ee5),
+ U64_C (0x9f469f8cd923139f), U64_C (0xf0e7f0d317fd23f0),
+ U64_C (0x4a354a6a7f94204a), U64_C (0xda4fda9e95a944da),
+ U64_C (0x587d58fa25b0a258), U64_C (0xc903c906ca8fcfc9),
+ U64_C (0x29a429558d527c29), U64_C (0x0a280a5022145a0a),
+ U64_C (0xb1feb1e14f7f50b1), U64_C (0xa0baa0691a5dc9a0),
+ U64_C (0x6bb16b7fdad6146b), U64_C (0x852e855cab17d985),
+ U64_C (0xbdcebd8173673cbd), U64_C (0x5d695dd234ba8f5d),
+ U64_C (0x1040108050209010), U64_C (0xf4f7f4f303f507f4),
+ U64_C (0xcb0bcb16c08bddcb), U64_C (0x3ef83eedc67cd33e),
+ U64_C (0x05140528110a2d05), U64_C (0x6781671fe6ce7867),
+ U64_C (0xe4b7e47353d597e4), U64_C (0x279c2725bb4e0227),
+ U64_C (0x4119413258827341), U64_C (0x8b168b2c9d0ba78b),
+ U64_C (0xa7a6a7510153f6a7), U64_C (0x7de97dcf94fab27d),
+ U64_C (0x956e95dcfb374995), U64_C (0xd847d88e9fad56d8),
+ U64_C (0xfbcbfb8b30eb70fb), U64_C (0xee9fee2371c1cdee),
+ U64_C (0x7ced7cc791f8bb7c), U64_C (0x66856617e3cc7166),
+ U64_C (0xdd53dda68ea77bdd), U64_C (0x175c17b84b2eaf17),
+ U64_C (0x47014702468e4547), U64_C (0x9e429e84dc211a9e),
+ U64_C (0xca0fca1ec589d4ca), U64_C (0x2db42d75995a582d),
+ U64_C (0xbfc6bf9179632ebf), U64_C (0x071c07381b0e3f07),
+ U64_C (0xad8ead012347acad), U64_C (0x5a755aea2fb4b05a),
+ U64_C (0x8336836cb51bef83), U64_C (0x33cc3385ff66b633),
+ U64_C (0x6391633ff2c65c63), U64_C (0x020802100a041202),
+ U64_C (0xaa92aa39384993aa), U64_C (0x71d971afa8e2de71),
+ U64_C (0xc807c80ecf8dc6c8), U64_C (0x196419c87d32d119),
+ U64_C (0x4939497270923b49), U64_C (0xd943d9869aaf5fd9),
+ U64_C (0xf2eff2c31df931f2), U64_C (0xe3abe34b48dba8e3),
+ U64_C (0x5b715be22ab6b95b), U64_C (0x881a8834920dbc88),
+ U64_C (0x9a529aa4c8293e9a), U64_C (0x2698262dbe4c0b26),
+ U64_C (0x32c8328dfa64bf32), U64_C (0xb0fab0e94a7d59b0),
+ U64_C (0xe983e91b6acff2e9), U64_C (0x0f3c0f78331e770f),
+ U64_C (0xd573d5e6a6b733d5), U64_C (0x803a8074ba1df480),
+ U64_C (0xbec2be997c6127be), U64_C (0xcd13cd26de87ebcd),
+ U64_C (0x34d034bde4688934), U64_C (0x483d487a75903248),
+ U64_C (0xffdbffab24e354ff), U64_C (0x7af57af78ff48d7a),
+ U64_C (0x907a90f4ea3d6490), U64_C (0x5f615fc23ebe9d5f),
+ U64_C (0x2080201da0403d20), U64_C (0x68bd6867d5d00f68),
+ U64_C (0x1a681ad07234ca1a), U64_C (0xae82ae192c41b7ae),
+ U64_C (0xb4eab4c95e757db4), U64_C (0x544d549a19a8ce54),
+ U64_C (0x937693ece53b7f93), U64_C (0x2288220daa442f22),
+ U64_C (0x648d6407e9c86364), U64_C (0xf1e3f1db12ff2af1),
+ U64_C (0x73d173bfa2e6cc73), U64_C (0x124812905a248212),
+ U64_C (0x401d403a5d807a40), U64_C (0x0820084028104808),
+ U64_C (0xc32bc356e89b95c3), U64_C (0xec97ec337bc5dfec),
+ U64_C (0xdb4bdb9690ab4ddb), U64_C (0xa1bea1611f5fc0a1),
+ U64_C (0x8d0e8d1c8307918d), U64_C (0x3df43df5c97ac83d),
+ U64_C (0x976697ccf1335b97), U64_C (0x0000000000000000),
+ U64_C (0xcf1bcf36d483f9cf), U64_C (0x2bac2b4587566e2b),
+ U64_C (0x76c57697b3ece176), U64_C (0x82328264b019e682),
+ U64_C (0xd67fd6fea9b128d6), U64_C (0x1b6c1bd87736c31b),
+ U64_C (0xb5eeb5c15b7774b5), U64_C (0xaf86af112943beaf),
+ U64_C (0x6ab56a77dfd41d6a), U64_C (0x505d50ba0da0ea50),
+ U64_C (0x450945124c8a5745), U64_C (0xf3ebf3cb18fb38f3),
+ U64_C (0x30c0309df060ad30), U64_C (0xef9bef2b74c3c4ef),
+ U64_C (0x3ffc3fe5c37eda3f), U64_C (0x554955921caac755),
+ U64_C (0xa2b2a2791059dba2), U64_C (0xea8fea0365c9e9ea),
+ U64_C (0x6589650fecca6a65), U64_C (0xbad2bab9686903ba),
+ U64_C (0x2fbc2f65935e4a2f), U64_C (0xc027c04ee79d8ec0),
+ U64_C (0xde5fdebe81a160de), U64_C (0x1c701ce06c38fc1c),
+ U64_C (0xfdd3fdbb2ee746fd), U64_C (0x4d294d52649a1f4d),
+ U64_C (0x927292e4e0397692), U64_C (0x75c9758fbceafa75),
+ U64_C (0x061806301e0c3606), U64_C (0x8a128a249809ae8a),
+ U64_C (0xb2f2b2f940794bb2), U64_C (0xe6bfe66359d185e6),
+ U64_C (0x0e380e70361c7e0e), U64_C (0x1f7c1ff8633ee71f),
+ U64_C (0x62956237f7c45562), U64_C (0xd477d4eea3b53ad4),
+ U64_C (0xa89aa829324d81a8), U64_C (0x966296c4f4315296),
+ U64_C (0xf9c3f99b3aef62f9), U64_C (0xc533c566f697a3c5),
+ U64_C (0x25942535b14a1025), U64_C (0x597959f220b2ab59),
+ U64_C (0x842a8454ae15d084), U64_C (0x72d572b7a7e4c572),
+ U64_C (0x39e439d5dd72ec39), U64_C (0x4c2d4c5a6198164c),
+ U64_C (0x5e655eca3bbc945e), U64_C (0x78fd78e785f09f78),
+ U64_C (0x38e038ddd870e538), U64_C (0x8c0a8c148605988c),
+ U64_C (0xd163d1c6b2bf17d1), U64_C (0xa5aea5410b57e4a5),
+ U64_C (0xe2afe2434dd9a1e2), U64_C (0x6199612ff8c24e61),
+ U64_C (0xb3f6b3f1457b42b3), U64_C (0x21842115a5423421),
+ U64_C (0x9c4a9c94d625089c), U64_C (0x1e781ef0663cee1e),
+ U64_C (0x4311432252866143), U64_C (0xc73bc776fc93b1c7),
+ U64_C (0xfcd7fcb32be54ffc), U64_C (0x0410042014082404),
+ U64_C (0x515951b208a2e351), U64_C (0x995e99bcc72f2599),
+ U64_C (0x6da96d4fc4da226d), U64_C (0x0d340d68391a650d),
+ U64_C (0xfacffa8335e979fa), U64_C (0xdf5bdfb684a369df),
+ U64_C (0x7ee57ed79bfca97e), U64_C (0x2490243db4481924),
+ U64_C (0x3bec3bc5d776fe3b), U64_C (0xab96ab313d4b9aab),
+ U64_C (0xce1fce3ed181f0ce), U64_C (0x1144118855229911),
+ U64_C (0x8f068f0c8903838f), U64_C (0x4e254e4a6b9c044e),
+ U64_C (0xb7e6b7d1517366b7), U64_C (0xeb8beb0b60cbe0eb),
+ U64_C (0x3cf03cfdcc78c13c), U64_C (0x813e817cbf1ffd81),
+ U64_C (0x946a94d4fe354094), U64_C (0xf7fbf7eb0cf31cf7),
+ U64_C (0xb9deb9a1676f18b9), U64_C (0x134c13985f268b13),
+ U64_C (0x2cb02c7d9c58512c), U64_C (0xd36bd3d6b8bb05d3),
+ U64_C (0xe7bbe76b5cd38ce7), U64_C (0x6ea56e57cbdc396e),
+ U64_C (0xc437c46ef395aac4), U64_C (0x030c03180f061b03),
+ U64_C (0x5645568a13acdc56), U64_C (0x440d441a49885e44),
+ U64_C (0x7fe17fdf9efea07f), U64_C (0xa99ea921374f88a9),
+ U64_C (0x2aa82a4d8254672a), U64_C (0xbbd6bbb16d6b0abb),
+ U64_C (0xc123c146e29f87c1), U64_C (0x535153a202a6f153),
+ U64_C (0xdc57dcae8ba572dc), U64_C (0x0b2c0b582716530b),
+ U64_C (0x9d4e9d9cd327019d), U64_C (0x6cad6c47c1d82b6c),
+ U64_C (0x31c43195f562a431), U64_C (0x74cd7487b9e8f374),
+ U64_C (0xf6fff6e309f115f6), U64_C (0x4605460a438c4c46),
+ U64_C (0xac8aac092645a5ac), U64_C (0x891e893c970fb589),
+ U64_C (0x145014a04428b414), U64_C (0xe1a3e15b42dfbae1),
+ U64_C (0x165816b04e2ca616), U64_C (0x3ae83acdd274f73a),
+ U64_C (0x69b9696fd0d20669), U64_C (0x092409482d124109),
+ U64_C (0x70dd70a7ade0d770), U64_C (0xb6e2b6d954716fb6),
+ U64_C (0xd067d0ceb7bd1ed0), U64_C (0xed93ed3b7ec7d6ed),
+ U64_C (0xcc17cc2edb85e2cc), U64_C (0x4215422a57846842),
+ U64_C (0x985a98b4c22d2c98), U64_C (0xa4aaa4490e55eda4),
+ U64_C (0x28a0285d88507528), U64_C (0x5c6d5cda31b8865c),
+ U64_C (0xf8c7f8933fed6bf8), U64_C (0x86228644a411c286),
+ };
+
+
+
+static void
+whirlpool_init (void *ctx)
+{
+ whirlpool_context_t *context = ctx;
+
+ memset (context, 0, sizeof (*context));
+}
+
+
+/*
+ * Transform block.
+ */
+static void
+whirlpool_transform (whirlpool_context_t *context, const unsigned char *data)
+{
+ whirlpool_block_t data_block;
+ whirlpool_block_t key;
+ whirlpool_block_t state;
+ whirlpool_block_t block;
+ unsigned int r;
+ unsigned int i;
+
+ buffer_to_block (data, data_block, i);
+ block_copy (key, context->hash_state, i);
+ block_copy (state, context->hash_state, i);
+ block_xor (state, data_block, i);
+
+ for (r = 0; r < R; r++)
+ {
+ /* Compute round key K^r. */
+
+ block[0] = (C0[(key[0] >> 56) & 0xFF] ^ C1[(key[7] >> 48) & 0xFF] ^
+ C2[(key[6] >> 40) & 0xFF] ^ C3[(key[5] >> 32) & 0xFF] ^
+ C4[(key[4] >> 24) & 0xFF] ^ C5[(key[3] >> 16) & 0xFF] ^
+ C6[(key[2] >> 8) & 0xFF] ^ C7[(key[1] >> 0) & 0xFF] ^ rc[r]);
+ block[1] = (C0[(key[1] >> 56) & 0xFF] ^ C1[(key[0] >> 48) & 0xFF] ^
+ C2[(key[7] >> 40) & 0xFF] ^ C3[(key[6] >> 32) & 0xFF] ^
+ C4[(key[5] >> 24) & 0xFF] ^ C5[(key[4] >> 16) & 0xFF] ^
+ C6[(key[3] >> 8) & 0xFF] ^ C7[(key[2] >> 0) & 0xFF]);
+ block[2] = (C0[(key[2] >> 56) & 0xFF] ^ C1[(key[1] >> 48) & 0xFF] ^
+ C2[(key[0] >> 40) & 0xFF] ^ C3[(key[7] >> 32) & 0xFF] ^
+ C4[(key[6] >> 24) & 0xFF] ^ C5[(key[5] >> 16) & 0xFF] ^
+ C6[(key[4] >> 8) & 0xFF] ^ C7[(key[3] >> 0) & 0xFF]);
+ block[3] = (C0[(key[3] >> 56) & 0xFF] ^ C1[(key[2] >> 48) & 0xFF] ^
+ C2[(key[1] >> 40) & 0xFF] ^ C3[(key[0] >> 32) & 0xFF] ^
+ C4[(key[7] >> 24) & 0xFF] ^ C5[(key[6] >> 16) & 0xFF] ^
+ C6[(key[5] >> 8) & 0xFF] ^ C7[(key[4] >> 0) & 0xFF]);
+ block[4] = (C0[(key[4] >> 56) & 0xFF] ^ C1[(key[3] >> 48) & 0xFF] ^
+ C2[(key[2] >> 40) & 0xFF] ^ C3[(key[1] >> 32) & 0xFF] ^
+ C4[(key[0] >> 24) & 0xFF] ^ C5[(key[7] >> 16) & 0xFF] ^
+ C6[(key[6] >> 8) & 0xFF] ^ C7[(key[5] >> 0) & 0xFF]);
+ block[5] = (C0[(key[5] >> 56) & 0xFF] ^ C1[(key[4] >> 48) & 0xFF] ^
+ C2[(key[3] >> 40) & 0xFF] ^ C3[(key[2] >> 32) & 0xFF] ^
+ C4[(key[1] >> 24) & 0xFF] ^ C5[(key[0] >> 16) & 0xFF] ^
+ C6[(key[7] >> 8) & 0xFF] ^ C7[(key[6] >> 0) & 0xFF]);
+ block[6] = (C0[(key[6] >> 56) & 0xFF] ^ C1[(key[5] >> 48) & 0xFF] ^
+ C2[(key[4] >> 40) & 0xFF] ^ C3[(key[3] >> 32) & 0xFF] ^
+ C4[(key[2] >> 24) & 0xFF] ^ C5[(key[1] >> 16) & 0xFF] ^
+ C6[(key[0] >> 8) & 0xFF] ^ C7[(key[7] >> 0) & 0xFF]);
+ block[7] = (C0[(key[7] >> 56) & 0xFF] ^ C1[(key[6] >> 48) & 0xFF] ^
+ C2[(key[5] >> 40) & 0xFF] ^ C3[(key[4] >> 32) & 0xFF] ^
+ C4[(key[3] >> 24) & 0xFF] ^ C5[(key[2] >> 16) & 0xFF] ^
+ C6[(key[1] >> 8) & 0xFF] ^ C7[(key[0] >> 0) & 0xFF]);
+ block_copy (key, block, i);
+
+ /* Apply r-th round transformation. */
+
+ block[0] = (C0[(state[0] >> 56) & 0xFF] ^ C1[(state[7] >> 48) & 0xFF] ^
+ C2[(state[6] >> 40) & 0xFF] ^ C3[(state[5] >> 32) & 0xFF] ^
+ C4[(state[4] >> 24) & 0xFF] ^ C5[(state[3] >> 16) & 0xFF] ^
+ C6[(state[2] >> 8) & 0xFF] ^ C7[(state[1] >> 0) & 0xFF] ^ key[0]);
+ block[1] = (C0[(state[1] >> 56) & 0xFF] ^ C1[(state[0] >> 48) & 0xFF] ^
+ C2[(state[7] >> 40) & 0xFF] ^ C3[(state[6] >> 32) & 0xFF] ^
+ C4[(state[5] >> 24) & 0xFF] ^ C5[(state[4] >> 16) & 0xFF] ^
+ C6[(state[3] >> 8) & 0xFF] ^ C7[(state[2] >> 0) & 0xFF] ^ key[1]);
+ block[2] = (C0[(state[2] >> 56) & 0xFF] ^ C1[(state[1] >> 48) & 0xFF] ^
+ C2[(state[0] >> 40) & 0xFF] ^ C3[(state[7] >> 32) & 0xFF] ^
+ C4[(state[6] >> 24) & 0xFF] ^ C5[(state[5] >> 16) & 0xFF] ^
+ C6[(state[4] >> 8) & 0xFF] ^ C7[(state[3] >> 0) & 0xFF] ^ key[2]);
+ block[3] = (C0[(state[3] >> 56) & 0xFF] ^ C1[(state[2] >> 48) & 0xFF] ^
+ C2[(state[1] >> 40) & 0xFF] ^ C3[(state[0] >> 32) & 0xFF] ^
+ C4[(state[7] >> 24) & 0xFF] ^ C5[(state[6] >> 16) & 0xFF] ^
+ C6[(state[5] >> 8) & 0xFF] ^ C7[(state[4] >> 0) & 0xFF] ^ key[3]);
+ block[4] = (C0[(state[4] >> 56) & 0xFF] ^ C1[(state[3] >> 48) & 0xFF] ^
+ C2[(state[2] >> 40) & 0xFF] ^ C3[(state[1] >> 32) & 0xFF] ^
+ C4[(state[0] >> 24) & 0xFF] ^ C5[(state[7] >> 16) & 0xFF] ^
+ C6[(state[6] >> 8) & 0xFF] ^ C7[(state[5] >> 0) & 0xFF] ^ key[4]);
+ block[5] = (C0[(state[5] >> 56) & 0xFF] ^ C1[(state[4] >> 48) & 0xFF] ^
+ C2[(state[3] >> 40) & 0xFF] ^ C3[(state[2] >> 32) & 0xFF] ^
+ C4[(state[1] >> 24) & 0xFF] ^ C5[(state[0] >> 16) & 0xFF] ^
+ C6[(state[7] >> 8) & 0xFF] ^ C7[(state[6] >> 0) & 0xFF] ^ key[5]);
+ block[6] = (C0[(state[6] >> 56) & 0xFF] ^ C1[(state[5] >> 48) & 0xFF] ^
+ C2[(state[4] >> 40) & 0xFF] ^ C3[(state[3] >> 32) & 0xFF] ^
+ C4[(state[2] >> 24) & 0xFF] ^ C5[(state[1] >> 16) & 0xFF] ^
+ C6[(state[0] >> 8) & 0xFF] ^ C7[(state[7] >> 0) & 0xFF] ^ key[6]);
+ block[7] = (C0[(state[7] >> 56) & 0xFF] ^ C1[(state[6] >> 48) & 0xFF] ^
+ C2[(state[5] >> 40) & 0xFF] ^ C3[(state[4] >> 32) & 0xFF] ^
+ C4[(state[3] >> 24) & 0xFF] ^ C5[(state[2] >> 16) & 0xFF] ^
+ C6[(state[1] >> 8) & 0xFF] ^ C7[(state[0] >> 0) & 0xFF] ^ key[7]);
+ block_copy (state, block, i);
+ }
+
+ /* Compression. */
+
+ block_xor (context->hash_state, data_block, i);
+ block_xor (context->hash_state, state, i);
+}
+
+static void
+whirlpool_add (whirlpool_context_t *context,
+ const void *buffer_arg, size_t buffer_n)
+{
+ const unsigned char *buffer = buffer_arg;
+ u64 buffer_size;
+ unsigned int carry;
+ unsigned int i;
+
+ buffer_size = buffer_n;
+
+ if (context->count == BLOCK_SIZE)
+ {
+ /* Flush the buffer. */
+ whirlpool_transform (context, context->buffer);
+ /*_gcry_burn_stack (80+6*sizeof(void*));*/ /* FIXME */
+ context->count = 0;
+ }
+ if (! buffer)
+ return; /* Nothing to add. */
+
+ if (context->count)
+ {
+ while (buffer_n && (context->count < BLOCK_SIZE))
+ {
+ context->buffer[context->count++] = *buffer++;
+ buffer_n--;
+ }
+ whirlpool_add (context, NULL, 0);
+ if (!buffer_n)
+ /* Done. */
+ return;
+ }
+ /*_gcry_burn_stack (80+6*sizeof(void*));*/ /* FIXME */
+
+ while (buffer_n >= BLOCK_SIZE)
+ {
+ whirlpool_transform (context, buffer);
+ context->count = 0;
+ buffer_n -= BLOCK_SIZE;
+ buffer += BLOCK_SIZE;
+ }
+ while (buffer_n && (context->count < BLOCK_SIZE))
+ {
+ context->buffer[context->count++] = *buffer++;
+ buffer_n--;
+ }
+
+ /* Update bit counter. */
+ carry = 0;
+ buffer_size <<= 3;
+ for (i = 1; i <= 32; i++)
+ {
+ if (! (buffer_size || carry))
+ break;
+
+ carry += context->length[32 - i] + (buffer_size & 0xFF);
+ context->length[32 - i] = carry;
+ buffer_size >>= 8;
+ carry >>= 8;
+ }
+ gcry_assert (! (buffer_size || carry));
+}
+
+static void
+whirlpool_write (void *ctx, const void *buffer, size_t buffer_n)
+{
+ whirlpool_context_t *context = ctx;
+
+ whirlpool_add (context, buffer, buffer_n);
+}
+
+static void
+whirlpool_final (void *ctx)
+{
+ whirlpool_context_t *context = ctx;
+ unsigned int i;
+
+ /* Flush. */
+ whirlpool_add (context, NULL, 0);
+
+ /* Pad. */
+ context->buffer[context->count++] = 0x80;
+
+ if (context->count > 32)
+ {
+ /* An extra block is necessary. */
+ while (context->count < 64)
+ context->buffer[context->count++] = 0;
+ whirlpool_add (context, NULL, 0);
+ }
+ while (context->count < 32)
+ context->buffer[context->count++] = 0;
+
+ /* Add length of message. */
+ memcpy (context->buffer + context->count, context->length, 32);
+ context->count += 32;
+ whirlpool_add (context, NULL, 0);
+
+ block_to_buffer (context->buffer, context->hash_state, i);
+}
+
+static byte *
+whirlpool_read (void *ctx)
+{
+ whirlpool_context_t *context = ctx;
+
+ return context->buffer;
+}
+
+gcry_md_spec_t _gcry_digest_spec_whirlpool =
+ {
+ "WHIRLPOOL", NULL, 0, NULL, 64,
+ whirlpool_init, whirlpool_write, whirlpool_final, whirlpool_read,
+ sizeof (whirlpool_context_t)
+ ,
+#ifdef GRUB_UTIL
+ .modname = "gcry_whirlpool",
+#endif
+ .blocksize = 64
+ };
+
+
+GRUB_MOD_INIT(gcry_whirlpool)
+{
+ COMPILE_TIME_ASSERT(sizeof (whirlpool_context_t) <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE);
+ grub_md_register (&_gcry_digest_spec_whirlpool);
+}
+
+GRUB_MOD_FINI(gcry_whirlpool)
+{
+ grub_md_unregister (&_gcry_digest_spec_whirlpool);
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/Manifest b/grub-core/lib/libgcrypt-grub/mpi/generic/Manifest
new file mode 100644
index 0000000..c429fde
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/Manifest
@@ -0,0 +1,29 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-add1.c iQCVAwUAP+Lj2DEAnp832S/7AQKn/AQAwQLWggl6zNQ5EZ+lE+jKV8W3FsogW3/6tp9T5rrSR5JnlWyoHQ9/Pu4knOcLjS6nIfVOiAEifu3nuIysQr9jDSSSJA2LylSUBSXKLKDamPsOCwXOLxiZODslJT3CCGAUtLvXJrWDbTZQrkEuwnLnjQFDzuA7iY9JLrG9kAoXD6Q==WoWm
+mpih-mul1.c iQCVAwUAP+LkCTEAnp832S/7AQKFVQP+MhBNjcY73JtnsHZfnaVZq3TiKwN151cWV51nDc1RnTaMhSIFeuNlj3vNML2W0Gn8n+GnyiWE2XXdQEaik6BL02eekUn9aq7I/rdpnTHuOjQPK1uwjuNl8RuJ9YrERBAxq4oB71f+iwMab8dsMSUlVC+NdeAocRqLLgnR/efkdLc==2Tkb
+mpih-mul2.c iQCVAwUAP+LkMjEAnp832S/7AQLPeAQAqmRzxFe/mDqTdZr/pTXT8RVyB1vKB0Ei2THV05BxmI4OPv39uysfFpLMt/INsX7AGqdOlj4jOZ/qNaFXR1ceMrlSXvo8u/epk6rCXFp82kM7Qs983LjoP//PrMCkYkXwblaVrgUGiBUCbuPMliWTK6qKkxxXtEfqZ7nVbEWdBx8==Kwhl
+mpih-mul3.c iQCVAwUAP+LkVDEAnp832S/7AQL91gP/Qd5iZWxRiN5DdEIVHAedoNvl23NPrT2UUdXvnSK49DpplTxkLiMBj0WqCayG/YIET2NpMRCeLvAZNcSt6lOm0bSZDYo1Hv/N+UoqD3V1McjY16REBv/nnPaMWMZcx7rl5yKTVZiX2PgV6oQOL7Yfrt5ZIOlrHBRs9S2/zcCaVz0==9BQe
+mpih-lshift.c iQCVAwUAP+LlATEAnp832S/7AQIACAQAhMrpx0SRXE/LN1NkjMO9n74nMrvmzYJyru0gw2O4BYrUPvD/LWGju2FZaggKV0IBjmi0cDoCrNeK9EGjKOO1lfgODbX2IZ1LUhr9jDuMj0QRqj6T9YkAFYTNUk4GfpwIf7T6Ybo7c78Jx93PidCJt7d39eMMEalooC7LZ4IU3NM==nZ4k
+mpih-rshift.c iQCVAwUAP+LlIjEAnp832S/7AQKiuAP/eYC2ZScd+taBx/kNzRvGjA0eAXvORMkMLV6Ot+OXVzVUi04eoP2yXdxSNFKwUj12p8GWXkdoMG3aOGBKg2a7bY5Q5RUho3hUWb9UsVYVUfXLf7IOTt/3a6MLh2CmV5dFPWJmSlbCyQRcn6n/fLDeJ3A2bWTS/BhqGfpOXUIU1ws==jCf8
+mpih-sub1.c iQCVAwUAP+LlZzEAnp832S/7AQIEPgP/dLHTDRbPrYJhsLp9SjGstU1M8/IC5XytcDtO3NQeu4mx6vaXjpujtsTvKIbX4QL5IahNntVVKv1xFLEm2yFg7L2ns0uD/mfwGgOhCG1j2o/SaTAWP5KxP7ae5UDcZl2w6NWvEuMj9t32zmziAZjP8W73A37FUspeRDYiL9sQzkI==QQzk
+udiv-w-sdiv.c iQCVAwUAP+Lk0TEAnp832S/7AQICXAQAsxe1SQD4+xZaZTqBC0V9Cyuo0mrdccnRFzthOtm0ARwKFXU2cuLW/ZBOkmeWOVmOFhBp22/I8dEGYnMA3gcfmOMCpNu9i9zk/XHfptdunA1MnOe3GsoWgfHL0rhpAyPhp/X043ICB41NElnnuxADuQQlD4Z1fca5ygYxMr2crJg==EI/6
+mpi-asm-defs.h iQCVAwUAP+LkgDEAnp832S/7AQK0FgQAxJZ7xvXhoZa33GWe23LRb3asrno/loZSyAIXrntqtVH8M3pEsCY0OyW4ry4hX2RnxpuhRCM/PdRNLG3xXyMSVIhkHU8WVRLqzF2LLjEkyU3cAmHnnTQ9aO/XpUWtJGTZ8q2bv7ZsAEi4aPl0p6KhPXcPgM9vQ2XcyOPn3Dl0d6Q==xpjI
+$names$ iQCVAwUAP+LmNDEAnp832S/7AQJa+gP+KQNJpbNOgc+s2UX+Ya2gDaOFcAROImIllhg3ej8EaBF8xxdHmWT1zaKwTwi3moEEleykMR104YAGWyQeMbFYiuPPBW+ohrT6KxRBVJpIA9auOOqqJMyglZyoR3Hv7gduVYUW1h/DebnqiKXKEfzQDFqYuT0ayuteoOR4B5NICbE==nLSh
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/distfiles b/grub-core/lib/libgcrypt-grub/mpi/generic/distfiles
new file mode 100644
index 0000000..9810eef
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/distfiles
@@ -0,0 +1,11 @@
+Manifest
+mpih-add1.c
+mpih-mul1.c
+mpih-mul2.c
+mpih-mul3.c
+mpih-lshift.c
+mpih-rshift.c
+mpih-sub1.c
+udiv-w-sdiv.c
+mpi-asm-defs.h
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/mpi-asm-defs.h b/grub-core/lib/libgcrypt-grub/mpi/generic/mpi-asm-defs.h
new file mode 100644
index 0000000..13424e2
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/mpi-asm-defs.h
@@ -0,0 +1,10 @@
+/* This file defines some basic constants for the MPI machinery. We
+ * need to define the types on a per-CPU basis, so it is done with
+ * this file here. */
+#define BYTES_PER_MPI_LIMB (SIZEOF_UNSIGNED_LONG)
+
+
+
+
+
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-add1.c b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-add1.c
new file mode 100644
index 0000000..4a84df6
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-add1.c
@@ -0,0 +1,65 @@
+/* mpihelp-add_1.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998,
+ * 2000, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+_gcry_mpih_add_n (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_ptr_t s2_ptr, mpi_size_t size)
+{
+ mpi_limb_t x, y, cy;
+ mpi_size_t j;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ the loop becomes faster. */
+ j = -size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ s2_ptr -= j;
+ res_ptr -= j;
+
+ cy = 0;
+ do
+ {
+ y = s2_ptr[j];
+ x = s1_ptr[j];
+ y += cy; /* add previous carry to one addend */
+ cy = y < cy; /* get out carry from that addition */
+ y += x; /* add other addend */
+ cy += y < x; /* get out carry from that add, combine */
+ res_ptr[j] = y;
+ }
+ while ( ++j );
+
+ return cy;
+}
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-lshift.c b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-lshift.c
new file mode 100644
index 0000000..f48c12c
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-lshift.c
@@ -0,0 +1,68 @@
+/* mpi-lshift.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left
+ * and store the USIZE least significant digits of the result at WP.
+ * Return the bits shifted out from the most significant digit.
+ *
+ * Argument constraints:
+ * 1. 0 < CNT < BITS_PER_MP_LIMB
+ * 2. If the result is to be written over the input, WP must be >= UP.
+ */
+
+mpi_limb_t
+_gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
+ unsigned int cnt)
+{
+ mpi_limb_t high_limb, low_limb;
+ unsigned sh_1, sh_2;
+ mpi_size_t i;
+ mpi_limb_t retval;
+
+ sh_1 = cnt;
+ wp += 1;
+ sh_2 = BITS_PER_MPI_LIMB - sh_1;
+ i = usize - 1;
+ low_limb = up[i];
+ retval = low_limb >> sh_2;
+ high_limb = low_limb;
+ while ( --i >= 0 )
+ {
+ low_limb = up[i];
+ wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
+ high_limb = low_limb;
+ }
+ wp[i] = high_limb << sh_1;
+
+ return retval;
+}
+
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul1.c b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul1.c
new file mode 100644
index 0000000..0e8197d
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul1.c
@@ -0,0 +1,62 @@
+/* mpihelp-mul_1.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+_gcry_mpih_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_limb_t s2_limb)
+{
+ mpi_limb_t cy_limb;
+ mpi_size_t j;
+ mpi_limb_t prod_high, prod_low;
+
+ /* The loop counter and index J goes from -S1_SIZE to -1. This way
+ * the loop becomes faster. */
+ j = -s1_size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ res_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+ res_ptr[j] = prod_low;
+ }
+ while( ++j );
+
+ return cy_limb;
+}
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul2.c b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul2.c
new file mode 100644
index 0000000..3b75496
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul2.c
@@ -0,0 +1,68 @@
+/* mpih-mul2.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+mpi_limb_t
+_gcry_mpih_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+ mpi_limb_t cy_limb;
+ mpi_size_t j;
+ mpi_limb_t prod_high, prod_low;
+ mpi_limb_t x;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ * the loop becomes faster. */
+ j = -s1_size;
+ res_ptr -= j;
+ s1_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
+
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+
+ x = res_ptr[j];
+ prod_low = x + prod_low;
+ cy_limb += prod_low < x?1:0;
+ res_ptr[j] = prod_low;
+ }
+ while ( ++j );
+
+ return cy_limb;
+}
+
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul3.c b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul3.c
new file mode 100644
index 0000000..5e84f94
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-mul3.c
@@ -0,0 +1,68 @@
+/* mpih-mul3.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+mpi_limb_t
+_gcry_mpih_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+ mpi_limb_t cy_limb;
+ mpi_size_t j;
+ mpi_limb_t prod_high, prod_low;
+ mpi_limb_t x;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ * the loop becomes faster. */
+ j = -s1_size;
+ res_ptr -= j;
+ s1_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb);
+
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+
+ x = res_ptr[j];
+ prod_low = x - prod_low;
+ cy_limb += prod_low > x?1:0;
+ res_ptr[j] = prod_low;
+ }
+ while( ++j );
+
+ return cy_limb;
+}
+
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-rshift.c b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-rshift.c
new file mode 100644
index 0000000..e40794f
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-rshift.c
@@ -0,0 +1,67 @@
+/* mpih-rshift.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 1999,
+ * 2000, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+
+/* Shift U (pointed to by UP and USIZE limbs long) CNT bits to the right
+ * and store the USIZE least significant limbs of the result at WP.
+ * The bits shifted out to the right are returned.
+ *
+ * Argument constraints:
+ * 1. 0 < CNT < BITS_PER_MP_LIMB
+ * 2. If the result is to be written over the input, WP must be <= UP.
+ */
+
+mpi_limb_t
+_gcry_mpih_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt)
+{
+ mpi_limb_t high_limb, low_limb;
+ unsigned sh_1, sh_2;
+ mpi_size_t i;
+ mpi_limb_t retval;
+
+ sh_1 = cnt;
+ wp -= 1;
+ sh_2 = BITS_PER_MPI_LIMB - sh_1;
+ high_limb = up[0];
+ retval = high_limb << sh_2;
+ low_limb = high_limb;
+ for (i=1; i < usize; i++)
+ {
+ high_limb = up[i];
+ wp[i] = (low_limb >> sh_1) | (high_limb << sh_2);
+ low_limb = high_limb;
+ }
+ wp[i] = low_limb >> sh_1;
+
+ return retval;
+}
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-sub1.c b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-sub1.c
new file mode 100644
index 0000000..e88821b
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/mpih-sub1.c
@@ -0,0 +1,66 @@
+/* mpihelp-add_2.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+_gcry_mpih_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_ptr_t s2_ptr, mpi_size_t size)
+{
+ mpi_limb_t x, y, cy;
+ mpi_size_t j;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ the loop becomes faster. */
+ j = -size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ s2_ptr -= j;
+ res_ptr -= j;
+
+ cy = 0;
+ do
+ {
+ y = s2_ptr[j];
+ x = s1_ptr[j];
+ y += cy; /* add previous carry to subtrahend */
+ cy = y < cy; /* get out carry from that addition */
+ y = x - y; /* main subtract */
+ cy += y > x; /* get out carry from the subtract, combine */
+ res_ptr[j] = y;
+ }
+ while( ++j );
+
+ return cy;
+}
+
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/generic/udiv-w-sdiv.c b/grub-core/lib/libgcrypt-grub/mpi/generic/udiv-w-sdiv.c
new file mode 100644
index 0000000..e80d98b
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/generic/udiv-w-sdiv.c
@@ -0,0 +1,133 @@
+/* mpih-w-sdiv -- implement udiv_qrnnd on machines with only signed
+ * division.
+ * Copyright (C) 1992, 1994, 1996, 1998, 2002 Free Software Foundation, Inc.
+ * Contributed by Peter L. Montgomery.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+#if 0 /* not yet ported to MPI */
+
+mpi_limb_t
+mpihelp_udiv_w_sdiv( mpi_limp_t *rp,
+ mpi_limp_t *a1,
+ mpi_limp_t *a0,
+ mpi_limp_t *d )
+{
+ mp_limb_t q, r;
+ mp_limb_t c0, c1, b1;
+
+ if ((mpi_limb_signed_t) d >= 0)
+ {
+ if (a1 < d - a1 - (a0 >> (BITS_PER_MP_LIMB - 1)))
+ {
+ /* dividend, divisor, and quotient are nonnegative */
+ sdiv_qrnnd (q, r, a1, a0, d);
+ }
+ else
+ {
+ /* Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d */
+ sub_ddmmss (c1, c0, a1, a0, d >> 1, d << (BITS_PER_MP_LIMB - 1));
+ /* Divide (c1*2^32 + c0) by d */
+ sdiv_qrnnd (q, r, c1, c0, d);
+ /* Add 2^31 to quotient */
+ q += (mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1);
+ }
+ }
+ else
+ {
+ b1 = d >> 1; /* d/2, between 2^30 and 2^31 - 1 */
+ c1 = a1 >> 1; /* A/2 */
+ c0 = (a1 << (BITS_PER_MP_LIMB - 1)) + (a0 >> 1);
+
+ if (a1 < b1) /* A < 2^32*b1, so A/2 < 2^31*b1 */
+ {
+ sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
+
+ r = 2*r + (a0 & 1); /* Remainder from A/(2*b1) */
+ if ((d & 1) != 0)
+ {
+ if (r >= q)
+ r = r - q;
+ else if (q - r <= d)
+ {
+ r = r - q + d;
+ q--;
+ }
+ else
+ {
+ r = r - q + 2*d;
+ q -= 2;
+ }
+ }
+ }
+ else if (c1 < b1) /* So 2^31 <= (A/2)/b1 < 2^32 */
+ {
+ c1 = (b1 - 1) - c1;
+ c0 = ~c0; /* logical NOT */
+
+ sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
+
+ q = ~q; /* (A/2)/b1 */
+ r = (b1 - 1) - r;
+
+ r = 2*r + (a0 & 1); /* A/(2*b1) */
+
+ if ((d & 1) != 0)
+ {
+ if (r >= q)
+ r = r - q;
+ else if (q - r <= d)
+ {
+ r = r - q + d;
+ q--;
+ }
+ else
+ {
+ r = r - q + 2*d;
+ q -= 2;
+ }
+ }
+ }
+ else /* Implies c1 = b1 */
+ { /* Hence a1 = d - 1 = 2*b1 - 1 */
+ if (a0 >= -d)
+ {
+ q = -1;
+ r = a0 + d;
+ }
+ else
+ {
+ q = -2;
+ r = a0 + 2*d;
+ }
+ }
+ }
+
+ *rp = r;
+ return q;
+}
+
+#endif
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/longlong.h b/grub-core/lib/libgcrypt-grub/mpi/longlong.h
new file mode 100644
index 0000000..37a9b9a
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/longlong.h
@@ -0,0 +1,1615 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
+ Note: I added some stuff for use with gnupg
+
+Copyright (C) 1991, 1992, 1993, 1994, 1996, 1998,
+ 2000, 2001, 2002, 2003, 2004, 2011 Free Software Foundation, Inc.
+
+This file is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or (at your
+option) any later version.
+
+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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Library General Public License
+along with this file; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/* You have to define the following before including this file:
+
+ UWtype -- An unsigned type, default type for operations (typically a "word")
+ UHWtype -- An unsigned type, at least half the size of UWtype.
+ UDWtype -- An unsigned type, at least twice as large a UWtype
+ W_TYPE_SIZE -- size in bits of UWtype
+
+ SItype, USItype -- Signed and unsigned 32 bit types.
+ DItype, UDItype -- Signed and unsigned 64 bit types.
+
+ On a 32 bit machine UWtype should typically be USItype;
+ on a 64 bit machine, UWtype should typically be UDItype.
+*/
+
+#define __BITS4 (W_TYPE_SIZE / 4)
+#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
+#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
+#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
+
+/* This is used to make sure no undesirable sharing between different libraries
+ that use this file takes place. */
+#ifndef __MPN
+#define __MPN(x) __##x
+#endif
+
+/* Define auxiliary asm macros.
+
+ 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) multiplies two
+ UWtype integers MULTIPLER and MULTIPLICAND, and generates a two UWtype
+ word product in HIGH_PROD and LOW_PROD.
+
+ 2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a
+ UDWtype product. This is just a variant of umul_ppmm.
+
+ 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
+ denominator) divides a UDWtype, composed by the UWtype integers
+ HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
+ in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
+ than DENOMINATOR for correct operation. If, in addition, the most
+ significant bit of DENOMINATOR must be 1, then the pre-processor symbol
+ UDIV_NEEDS_NORMALIZATION is defined to 1.
+
+ 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
+ denominator). Like udiv_qrnnd but the numbers are signed. The quotient
+ is rounded towards 0.
+
+ 5) count_leading_zeros(count, x) counts the number of zero-bits from the
+ msb to the first non-zero bit in the UWtype X. This is the number of
+ steps X needs to be shifted left to set the msb. Undefined for X == 0,
+ unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
+
+ 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts
+ from the least significant end.
+
+ 7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
+ high_addend_2, low_addend_2) adds two UWtype integers, composed by
+ HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2
+ respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow
+ (i.e. carry out) is not stored anywhere, and is lost.
+
+ 8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend,
+ high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
+ composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
+ LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE
+ and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
+ and is lost.
+
+ If any of these macros are left undefined for a particular CPU,
+ C macros are used. */
+
+/* The CPUs come in alphabetical order below.
+
+ Please add support for more CPUs here, or improve the current support
+ for the CPUs below! */
+
+#ifdef __riscos__
+#pragma continue_after_hash_error
+#else /* !__riscos__ */
+#if defined (__GNUC__) && !defined (NO_ASM)
+
+/* We sometimes need to clobber "cc" with gcc2, but that would not be
+ understood by gcc1. Use cpp to avoid major code duplication. */
+#if __GNUC__ < 2
+#define __CLOBBER_CC
+#define __AND_CLOBBER_CC
+#else /* __GNUC__ >= 2 */
+#define __CLOBBER_CC : "cc"
+#define __AND_CLOBBER_CC , "cc"
+#endif /* __GNUC__ < 2 */
+
+
+/***************************************
+ ************** A29K *****************
+ ***************************************/
+#if (defined (__a29k__) || defined (_AM29K)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add %1,%4,%5\n" \
+ "addc %0,%2,%3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%r" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "%r" ((USItype)(al)), \
+ "rI" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub %1,%4,%5\n" \
+ "subc %0,%2,%3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "r" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "r" ((USItype)(al)), \
+ "rI" ((USItype)(bl)))
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("multiplu %0,%1,%2" \
+ : "=r" ((USItype)(xl)) \
+ : "r" (__m0), \
+ "r" (__m1)); \
+ __asm__ ("multmu %0,%1,%2" \
+ : "=r" ((USItype)(xh)) \
+ : "r" (__m0), \
+ "r" (__m1)); \
+ } while (0)
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("dividu %0,%3,%4" \
+ : "=r" ((USItype)(q)), \
+ "=q" ((USItype)(r)) \
+ : "1" ((USItype)(n1)), \
+ "r" ((USItype)(n0)), \
+ "r" ((USItype)(d)))
+#define count_leading_zeros(count, x) \
+ __asm__ ("clz %0,%1" \
+ : "=r" ((USItype)(count)) \
+ : "r" ((USItype)(x)))
+#define COUNT_LEADING_ZEROS_0 32
+#endif /* __a29k__ */
+
+
+#if defined (__alpha) && W_TYPE_SIZE == 64
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ UDItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("umulh %r1,%2,%0" \
+ : "=r" ((UDItype) ph) \
+ : "%rJ" (__m0), \
+ "rI" (__m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define UMUL_TIME 46
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { UDItype __r; \
+ (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
+ (r) = __r; \
+ } while (0)
+extern UDItype __udiv_qrnnd ();
+#define UDIV_TIME 220
+#endif /* LONGLONG_STANDALONE */
+#endif /* __alpha */
+
+/***************************************
+ ************** ARM ******************
+ ***************************************/
+#if defined (__arm__) && W_TYPE_SIZE == 32 && \
+ (!defined (__thumb__) || defined (__thumb2__))
+/* The __ARM_ARCH define is provided by gcc 4.8. Construct it otherwise. */
+#ifndef __ARM_ARCH
+# ifdef __ARM_ARCH_2__
+# define __ARM_ARCH 2
+# elif defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
+# define __ARM_ARCH 3
+# elif defined (__ARM_ARCH_4__) || defined (__ARM_ARCH_4T__)
+# define __ARM_ARCH 4
+# elif defined (__ARM_ARCH_5__) || defined (__ARM_ARCH_5E__) \
+ || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) \
+ || defined(__ARM_ARCH_5TEJ__)
+# define __ARM_ARCH 5
+# elif defined (__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
+ || defined (__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
+ || defined (__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__)
+# define __ARM_ARCH 6
+# elif defined (__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
+ || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
+ || defined(__ARM_ARCH_7EM__)
+# define __ARM_ARCH 7
+# else
+ /* could not detect? */
+# endif
+#endif
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("adds %1, %4, %5\n" \
+ "adc %0, %2, %3" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "%r" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "%r" ((USItype)(al)), \
+ "rI" ((USItype)(bl)) __CLOBBER_CC)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subs %1, %4, %5\n" \
+ "sbc %0, %2, %3" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "r" ((USItype)(al)), \
+ "rI" ((USItype)(bl)) __CLOBBER_CC)
+#if (defined __ARM_ARCH && __ARM_ARCH <= 3)
+#define umul_ppmm(xh, xl, a, b) \
+ __asm__ ("@ Inlined umul_ppmm\n" \
+ "mov %|r0, %2, lsr #16 @ AAAA\n" \
+ "mov %|r2, %3, lsr #16 @ BBBB\n" \
+ "bic %|r1, %2, %|r0, lsl #16 @ aaaa\n" \
+ "bic %0, %3, %|r2, lsl #16 @ bbbb\n" \
+ "mul %1, %|r1, %|r2 @ aaaa * BBBB\n" \
+ "mul %|r2, %|r0, %|r2 @ AAAA * BBBB\n" \
+ "mul %|r1, %0, %|r1 @ aaaa * bbbb\n" \
+ "mul %0, %|r0, %0 @ AAAA * bbbb\n" \
+ "adds %|r0, %1, %0 @ central sum\n" \
+ "addcs %|r2, %|r2, #65536\n" \
+ "adds %1, %|r1, %|r0, lsl #16\n" \
+ "adc %0, %|r2, %|r0, lsr #16" \
+ : "=&r" ((xh)), \
+ "=r" ((xl)) \
+ : "r" ((USItype)(a)), \
+ "r" ((USItype)(b)) \
+ : "r0", "r1", "r2" __AND_CLOBBER_CC)
+#else /* __ARM_ARCH >= 4 */
+#define umul_ppmm(xh, xl, a, b) \
+ __asm__ ("@ Inlined umul_ppmm\n" \
+ "umull %1, %0, %2, %3" \
+ : "=&r" ((xh)), \
+ "=r" ((xl)) \
+ : "r" ((USItype)(a)), \
+ "r" ((USItype)(b)))
+#endif /* __ARM_ARCH >= 4 */
+#define UMUL_TIME 20
+#define UDIV_TIME 100
+#if (defined __ARM_ARCH && __ARM_ARCH >= 5)
+#define count_leading_zeros(count, x) \
+ __asm__ ("clz %0, %1" \
+ : "=r" ((count)) \
+ : "r" ((USItype)(x)))
+#endif /* __ARM_ARCH >= 5 */
+#endif /* __arm__ */
+
+/***************************************
+ ************** CLIPPER **************
+ ***************************************/
+#if defined (__clipper__) && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+ ({union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ __asm__ ("mulwux %2,%0" \
+ : "=r" (__xx.__ll) \
+ : "%0" ((USItype)(u)), \
+ "r" ((USItype)(v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define smul_ppmm(w1, w0, u, v) \
+ ({union {DItype __ll; \
+ struct {SItype __l, __h;} __i; \
+ } __xx; \
+ __asm__ ("mulwx %2,%0" \
+ : "=r" (__xx.__ll) \
+ : "%0" ((SItype)(u)), \
+ "r" ((SItype)(v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define __umulsidi3(u, v) \
+ ({UDItype __w; \
+ __asm__ ("mulwux %2,%0" \
+ : "=r" (__w) \
+ : "%0" ((USItype)(u)), \
+ "r" ((USItype)(v))); \
+ __w; })
+#endif /* __clipper__ */
+
+
+/***************************************
+ ************** GMICRO ***************
+ ***************************************/
+#if defined (__gmicro__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add.w %5,%1\n" \
+ "addx %3,%0" \
+ : "=g" ((USItype)(sh)), \
+ "=&g" ((USItype)(sl)) \
+ : "%0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub.w %5,%1\n" \
+ "subx %3,%0" \
+ : "=g" ((USItype)(sh)), \
+ "=&g" ((USItype)(sl)) \
+ : "0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define umul_ppmm(ph, pl, m0, m1) \
+ __asm__ ("mulx %3,%0,%1" \
+ : "=g" ((USItype)(ph)), \
+ "=r" ((USItype)(pl)) \
+ : "%0" ((USItype)(m0)), \
+ "g" ((USItype)(m1)))
+#define udiv_qrnnd(q, r, nh, nl, d) \
+ __asm__ ("divx %4,%0,%1" \
+ : "=g" ((USItype)(q)), \
+ "=r" ((USItype)(r)) \
+ : "1" ((USItype)(nh)), \
+ "0" ((USItype)(nl)), \
+ "g" ((USItype)(d)))
+#define count_leading_zeros(count, x) \
+ __asm__ ("bsch/1 %1,%0" \
+ : "=g" (count) \
+ : "g" ((USItype)(x)), \
+ "0" ((USItype)0))
+#endif
+
+
+/***************************************
+ ************** HPPA *****************
+ ***************************************/
+#if defined (__hppa) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ (" add %4,%5,%1\n" \
+ " addc %2,%3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%rM" ((USItype)(ah)), \
+ "rM" ((USItype)(bh)), \
+ "%rM" ((USItype)(al)), \
+ "rM" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ (" sub %4,%5,%1\n" \
+ " subb %2,%3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "rM" ((USItype)(ah)), \
+ "rM" ((USItype)(bh)), \
+ "rM" ((USItype)(al)), \
+ "rM" ((USItype)(bl)))
+#if defined (_PA_RISC1_1)
+#define umul_ppmm(wh, wl, u, v) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ __asm__ (" xmpyu %1,%2,%0" \
+ : "=*f" (__xx.__ll) \
+ : "*f" ((USItype)(u)), \
+ "*f" ((USItype)(v))); \
+ (wh) = __xx.__i.__h; \
+ (wl) = __xx.__i.__l; \
+ } while (0)
+#define UMUL_TIME 8
+#define UDIV_TIME 60
+#else
+#define UMUL_TIME 40
+#define UDIV_TIME 80
+#endif
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { USItype __r; \
+ (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
+ (r) = __r; \
+ } while (0)
+extern USItype __udiv_qrnnd ();
+#endif /* LONGLONG_STANDALONE */
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __tmp; \
+ __asm__ ( \
+ " ldi 1,%0 \n" \
+ " extru,= %1,15,16,%%r0 ; Bits 31..16 zero? \n" \
+ " extru,tr %1,15,16,%1 ; No. Shift down, skip add.\n" \
+ " ldo 16(%0),%0 ; Yes. Perform add. \n" \
+ " extru,= %1,23,8,%%r0 ; Bits 15..8 zero? \n" \
+ " extru,tr %1,23,8,%1 ; No. Shift down, skip add.\n" \
+ " ldo 8(%0),%0 ; Yes. Perform add. \n" \
+ " extru,= %1,27,4,%%r0 ; Bits 7..4 zero? \n" \
+ " extru,tr %1,27,4,%1 ; No. Shift down, skip add.\n" \
+ " ldo 4(%0),%0 ; Yes. Perform add. \n" \
+ " extru,= %1,29,2,%%r0 ; Bits 3..2 zero? \n" \
+ " extru,tr %1,29,2,%1 ; No. Shift down, skip add.\n" \
+ " ldo 2(%0),%0 ; Yes. Perform add. \n" \
+ " extru %1,30,1,%1 ; Extract bit 1. \n" \
+ " sub %0,%1,%0 ; Subtract it. " \
+ : "=r" (count), "=r" (__tmp) : "1" (x)); \
+ } while (0)
+#endif /* hppa */
+
+
+/***************************************
+ ************** I370 *****************
+ ***************************************/
+#if (defined (__i370__) || defined (__mvs__)) && W_TYPE_SIZE == 32
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mr %0,%3" \
+ : "=r" (__xx.__i.__h), \
+ "=r" (__xx.__i.__l) \
+ : "%1" (__m0), \
+ "r" (__m1)); \
+ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
+ (xh) += ((((SItype) __m0 >> 31) & __m1) \
+ + (((SItype) __m1 >> 31) & __m0)); \
+ } while (0)
+#define smul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {DItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ __asm__ ("mr %0,%3" \
+ : "=r" (__xx.__i.__h), \
+ "=r" (__xx.__i.__l) \
+ : "%1" (m0), \
+ "r" (m1)); \
+ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
+ } while (0)
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+ do { \
+ union {DItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ __xx.__i.__h = n1; __xx.__i.__l = n0; \
+ __asm__ ("dr %0,%2" \
+ : "=r" (__xx.__ll) \
+ : "0" (__xx.__ll), "r" (d)); \
+ (q) = __xx.__i.__l; (r) = __xx.__i.__h; \
+ } while (0)
+#endif
+
+
+/***************************************
+ ************** I386 *****************
+ ***************************************/
+#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addl %5,%1\n" \
+ "adcl %3,%0" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "%0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "g" ((USItype)(bl)) \
+ __CLOBBER_CC)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subl %5,%1\n" \
+ "sbbl %3,%0" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "g" ((USItype)(bl)) \
+ __CLOBBER_CC)
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("mull %3" \
+ : "=a" ((w0)), \
+ "=d" ((w1)) \
+ : "%0" ((USItype)(u)), \
+ "rm" ((USItype)(v)) \
+ __CLOBBER_CC)
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("divl %4" \
+ : "=a" ((q)), \
+ "=d" ((r)) \
+ : "0" ((USItype)(n0)), \
+ "1" ((USItype)(n1)), \
+ "rm" ((USItype)(d)) \
+ __CLOBBER_CC)
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __cbtmp; \
+ __asm__ ("bsrl %1,%0" \
+ : "=r" (__cbtmp) : "rm" ((USItype)(x)) \
+ __CLOBBER_CC); \
+ (count) = __cbtmp ^ 31; \
+ } while (0)
+#define count_trailing_zeros(count, x) \
+ __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((USItype)(x)) __CLOBBER_CC)
+#ifndef UMUL_TIME
+#define UMUL_TIME 40
+#endif
+#ifndef UDIV_TIME
+#define UDIV_TIME 40
+#endif
+#endif /* 80x86 */
+
+
+/***************************************
+ ************** I860 *****************
+ ***************************************/
+#if defined (__i860__) && W_TYPE_SIZE == 32
+#define rshift_rhlc(r,h,l,c) \
+ __asm__ ("shr %3,r0,r0\n" \
+ "shrd %1,%2,%0" \
+ "=r" (r) : "r" (h), "r" (l), "rn" (c))
+#endif /* i860 */
+
+/***************************************
+ ************** I960 *****************
+ ***************************************/
+#if defined (__i960__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("cmpo 1,0\n" \
+ "addc %5,%4,%1\n" \
+ "addc %3,%2,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%dI" ((USItype)(ah)), \
+ "dI" ((USItype)(bh)), \
+ "%dI" ((USItype)(al)), \
+ "dI" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("cmpo 0,0\n" \
+ "subc %5,%4,%1\n" \
+ "subc %3,%2,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "dI" ((USItype)(ah)), \
+ "dI" ((USItype)(bh)), \
+ "dI" ((USItype)(al)), \
+ "dI" ((USItype)(bl)))
+#define umul_ppmm(w1, w0, u, v) \
+ ({union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ __asm__ ("emul %2,%1,%0" \
+ : "=d" (__xx.__ll) \
+ : "%dI" ((USItype)(u)), \
+ "dI" ((USItype)(v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define __umulsidi3(u, v) \
+ ({UDItype __w; \
+ __asm__ ("emul %2,%1,%0" \
+ : "=d" (__w) \
+ : "%dI" ((USItype)(u)), \
+ "dI" ((USItype)(v))); \
+ __w; })
+#define udiv_qrnnd(q, r, nh, nl, d) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __nn; \
+ __nn.__i.__h = (nh); __nn.__i.__l = (nl); \
+ __asm__ ("ediv %d,%n,%0" \
+ : "=d" (__rq.__ll) \
+ : "dI" (__nn.__ll), \
+ "dI" ((USItype)(d))); \
+ (r) = __rq.__i.__l; (q) = __rq.__i.__h; \
+ } while (0)
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __cbtmp; \
+ __asm__ ("scanbit %1,%0" \
+ : "=r" (__cbtmp) \
+ : "r" ((USItype)(x))); \
+ (count) = __cbtmp ^ 31; \
+ } while (0)
+#define COUNT_LEADING_ZEROS_0 (-32) /* sic */
+#if defined (__i960mx) /* what is the proper symbol to test??? */
+#define rshift_rhlc(r,h,l,c) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __nn; \
+ __nn.__i.__h = (h); __nn.__i.__l = (l); \
+ __asm__ ("shre %2,%1,%0" \
+ : "=d" (r) : "dI" (__nn.__ll), "dI" (c)); \
+ }
+#endif /* i960mx */
+#endif /* i960 */
+
+
+/***************************************
+ ************** 68000 ****************
+ ***************************************/
+#if (defined (__mc68000__) || defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add%.l %5,%1\n" \
+ "addx%.l %3,%0" \
+ : "=d" ((USItype)(sh)), \
+ "=&d" ((USItype)(sl)) \
+ : "%0" ((USItype)(ah)), \
+ "d" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub%.l %5,%1\n" \
+ "subx%.l %3,%0" \
+ : "=d" ((USItype)(sh)), \
+ "=&d" ((USItype)(sl)) \
+ : "0" ((USItype)(ah)), \
+ "d" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("mulu%.l %3,%1:%0" \
+ : "=d" ((USItype)(w0)), \
+ "=d" ((USItype)(w1)) \
+ : "%0" ((USItype)(u)), \
+ "dmi" ((USItype)(v)))
+#define UMUL_TIME 45
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("divu%.l %4,%1:%0" \
+ : "=d" ((USItype)(q)), \
+ "=d" ((USItype)(r)) \
+ : "0" ((USItype)(n0)), \
+ "1" ((USItype)(n1)), \
+ "dmi" ((USItype)(d)))
+#define UDIV_TIME 90
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("divs%.l %4,%1:%0" \
+ : "=d" ((USItype)(q)), \
+ "=d" ((USItype)(r)) \
+ : "0" ((USItype)(n0)), \
+ "1" ((USItype)(n1)), \
+ "dmi" ((USItype)(d)))
+#define count_leading_zeros(count, x) \
+ __asm__ ("bfffo %1{%b2:%b2},%0" \
+ : "=d" ((USItype)(count)) \
+ : "od" ((USItype)(x)), "n" (0))
+#define COUNT_LEADING_ZEROS_0 32
+#else /* not mc68020 */
+#define umul_ppmm(xh, xl, a, b) \
+ do { USItype __umul_tmp1, __umul_tmp2; \
+ __asm__ ("| Inlined umul_ppmm \n" \
+ " move%.l %5,%3 \n" \
+ " move%.l %2,%0 \n" \
+ " move%.w %3,%1 \n" \
+ " swap %3 \n" \
+ " swap %0 \n" \
+ " mulu %2,%1 \n" \
+ " mulu %3,%0 \n" \
+ " mulu %2,%3 \n" \
+ " swap %2 \n" \
+ " mulu %5,%2 \n" \
+ " add%.l %3,%2 \n" \
+ " jcc 1f \n" \
+ " add%.l %#0x10000,%0 \n" \
+ "1: move%.l %2,%3 \n" \
+ " clr%.w %2 \n" \
+ " swap %2 \n" \
+ " swap %3 \n" \
+ " clr%.w %3 \n" \
+ " add%.l %3,%1 \n" \
+ " addx%.l %2,%0 \n" \
+ " | End inlined umul_ppmm" \
+ : "=&d" ((USItype)(xh)), "=&d" ((USItype)(xl)), \
+ "=d" (__umul_tmp1), "=&d" (__umul_tmp2) \
+ : "%2" ((USItype)(a)), "d" ((USItype)(b))); \
+ } while (0)
+#define UMUL_TIME 100
+#define UDIV_TIME 400
+#endif /* not mc68020 */
+#endif /* mc68000 */
+
+
+/***************************************
+ ************** 88000 ****************
+ ***************************************/
+#if defined (__m88000__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addu.co %1,%r4,%r5\n" \
+ "addu.ci %0,%r2,%r3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%rJ" ((USItype)(ah)), \
+ "rJ" ((USItype)(bh)), \
+ "%rJ" ((USItype)(al)), \
+ "rJ" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subu.co %1,%r4,%r5\n" \
+ "subu.ci %0,%r2,%r3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "rJ" ((USItype)(ah)), \
+ "rJ" ((USItype)(bh)), \
+ "rJ" ((USItype)(al)), \
+ "rJ" ((USItype)(bl)))
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __cbtmp; \
+ __asm__ ("ff1 %0,%1" \
+ : "=r" (__cbtmp) \
+ : "r" ((USItype)(x))); \
+ (count) = __cbtmp ^ 31; \
+ } while (0)
+#define COUNT_LEADING_ZEROS_0 63 /* sic */
+#if defined (__m88110__)
+#define umul_ppmm(wh, wl, u, v) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __x; \
+ __asm__ ("mulu.d %0,%1,%2" : "=r" (__x.__ll) : "r" (u), "r" (v)); \
+ (wh) = __x.__i.__h; \
+ (wl) = __x.__i.__l; \
+ } while (0)
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ ({union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __x, __q; \
+ __x.__i.__h = (n1); __x.__i.__l = (n0); \
+ __asm__ ("divu.d %0,%1,%2" \
+ : "=r" (__q.__ll) : "r" (__x.__ll), "r" (d)); \
+ (r) = (n0) - __q.__l * (d); (q) = __q.__l; })
+#define UMUL_TIME 5
+#define UDIV_TIME 25
+#else
+#define UMUL_TIME 17
+#define UDIV_TIME 150
+#endif /* __m88110__ */
+#endif /* __m88000__ */
+
+/***************************************
+ ************** MIPS *****************
+ ***************************************/
+#if defined (__mips__) && W_TYPE_SIZE == 32
+#if defined (__clang__) || (__GNUC__ >= 5) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ UDItype _r; \
+ _r = (UDItype) u * v; \
+ (w1) = _r >> 32; \
+ (w0) = (USItype) _r; \
+ } while (0)
+#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("multu %2,%3" \
+ : "=l" ((USItype)(w0)), \
+ "=h" ((USItype)(w1)) \
+ : "d" ((USItype)(u)), \
+ "d" ((USItype)(v)))
+#else
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("multu %2,%3 \n" \
+ "mflo %0 \n" \
+ "mfhi %1" \
+ : "=d" ((USItype)(w0)), \
+ "=d" ((USItype)(w1)) \
+ : "d" ((USItype)(u)), \
+ "d" ((USItype)(v)))
+#endif
+#define UMUL_TIME 10
+#define UDIV_TIME 100
+#endif /* __mips__ */
+
+/***************************************
+ ************** MIPS/64 **************
+ ***************************************/
+#if (defined (__mips) && __mips >= 3) && W_TYPE_SIZE == 64
+#if (__GNUC__ >= 5) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+typedef unsigned int UTItype __attribute__ ((mode (TI)));
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ UTItype _r; \
+ _r = (UTItype) u * v; \
+ (w1) = _r >> 64; \
+ (w0) = (UDItype) _r; \
+ } while (0)
+#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("dmultu %2,%3" \
+ : "=l" ((UDItype)(w0)), \
+ "=h" ((UDItype)(w1)) \
+ : "d" ((UDItype)(u)), \
+ "d" ((UDItype)(v)))
+#else
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("dmultu %2,%3 \n" \
+ "mflo %0 \n" \
+ "mfhi %1" \
+ : "=d" ((UDItype)(w0)), \
+ "=d" ((UDItype)(w1)) \
+ : "d" ((UDItype)(u)), \
+ "d" ((UDItype)(v)))
+#endif
+#define UMUL_TIME 20
+#define UDIV_TIME 140
+#endif /* __mips__ */
+
+
+/***************************************
+ ************** 32000 ****************
+ ***************************************/
+#if defined (__ns32000__) && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+ ({union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ __asm__ ("meid %2,%0" \
+ : "=g" (__xx.__ll) \
+ : "%0" ((USItype)(u)), \
+ "g" ((USItype)(v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define __umulsidi3(u, v) \
+ ({UDItype __w; \
+ __asm__ ("meid %2,%0" \
+ : "=g" (__w) \
+ : "%0" ((USItype)(u)), \
+ "g" ((USItype)(v))); \
+ __w; })
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ ({union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
+ __asm__ ("deid %2,%0" \
+ : "=g" (__xx.__ll) \
+ : "0" (__xx.__ll), \
+ "g" ((USItype)(d))); \
+ (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
+#define count_trailing_zeros(count,x) \
+ do {
+ __asm__ ("ffsd %2,%0" \
+ : "=r" ((USItype) (count)) \
+ : "0" ((USItype) 0), \
+ "r" ((USItype) (x))); \
+ } while (0)
+#endif /* __ns32000__ */
+
+
+/***************************************
+ ************** PPC ******************
+ ***************************************/
+#if (defined (_ARCH_PPC) || defined (_IBMR2)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "%r" ((USItype)(ah)), \
+ "%r" ((USItype)(al)), \
+ "rI" ((USItype)(bl))); \
+ else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "%r" ((USItype)(ah)), \
+ "%r" ((USItype)(al)), \
+ "rI" ((USItype)(bl))); \
+ else \
+ __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "%r" ((USItype)(ah)), \
+ "r" ((USItype)(bh)), \
+ "%r" ((USItype)(al)), \
+ "rI" ((USItype)(bl))); \
+ } while (0)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (ah) && (ah) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(bh)), \
+ "rI" ((USItype)(al)), \
+ "r" ((USItype)(bl))); \
+ else if (__builtin_constant_p (ah) && (ah) ==~(USItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(bh)), \
+ "rI" ((USItype)(al)), \
+ "r" ((USItype)(bl))); \
+ else if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(ah)), \
+ "rI" ((USItype)(al)), \
+ "r" ((USItype)(bl))); \
+ else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(ah)), \
+ "rI" ((USItype)(al)), \
+ "r" ((USItype)(bl))); \
+ else \
+ __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(ah)), \
+ "r" ((USItype)(bh)), \
+ "rI" ((USItype)(al)), \
+ "r" ((USItype)(bl))); \
+ } while (0)
+#define count_leading_zeros(count, x) \
+ __asm__ ("{cntlz|cntlzw} %0,%1" \
+ : "=r" ((count)) \
+ : "r" ((USItype)(x)))
+#define COUNT_LEADING_ZEROS_0 32
+#if defined (_ARCH_PPC)
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhwu %0,%1,%2" \
+ : "=r" (ph) \
+ : "%r" (__m0), \
+ "r" (__m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define UMUL_TIME 15
+#define smul_ppmm(ph, pl, m0, m1) \
+ do { \
+ SItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhw %0,%1,%2" \
+ : "=r" ((SItype) ph) \
+ : "%r" (__m0), \
+ "r" (__m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define SMUL_TIME 14
+#define UDIV_TIME 120
+#else
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mul %0,%2,%3" \
+ : "=r" ((xh)), \
+ "=q" ((xl)) \
+ : "r" (__m0), \
+ "r" (__m1)); \
+ (xh) += ((((SItype) __m0 >> 31) & __m1) \
+ + (((SItype) __m1 >> 31) & __m0)); \
+ } while (0)
+#define UMUL_TIME 8
+#define smul_ppmm(xh, xl, m0, m1) \
+ __asm__ ("mul %0,%2,%3" \
+ : "=r" ((SItype)(xh)), \
+ "=q" ((SItype)(xl)) \
+ : "r" (m0), \
+ "r" (m1))
+#define SMUL_TIME 4
+#define sdiv_qrnnd(q, r, nh, nl, d) \
+ __asm__ ("div %0,%2,%4" \
+ : "=r" ((SItype)(q)), "=q" ((SItype)(r)) \
+ : "r" ((SItype)(nh)), "1" ((SItype)(nl)), "r" ((SItype)(d)))
+#define UDIV_TIME 100
+#endif
+#endif /* Power architecture variants. */
+
+/* Powerpc 64 bit support taken from gmp-4.1.2. */
+/* We should test _IBMR2 here when we add assembly support for the system
+ vendor compilers. */
+#if 0 /* Not yet enabled because we don't have hardware for a test. */
+#if (defined (_ARCH_PPC) || defined (__powerpc__)) && W_TYPE_SIZE == 64
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+ else \
+ __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
+ : "=r" (sh), "=&r" (sl) \
+ : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
+ } while (0)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (ah) && (ah) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+ else \
+ __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
+ : "=r" (sh), "=&r" (sl) \
+ : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \
+ } while (0)
+#define count_leading_zeros(count, x) \
+ __asm__ ("cntlzd %0,%1" : "=r" (count) : "r" (x))
+#define COUNT_LEADING_ZEROS_0 64
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ UDItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhdu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define UMUL_TIME 15
+#define smul_ppmm(ph, pl, m0, m1) \
+ do { \
+ DItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhd %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define SMUL_TIME 14 /* ??? */
+#define UDIV_TIME 120 /* ??? */
+#endif /* 64-bit PowerPC. */
+#endif /* if 0 */
+
+/***************************************
+ ************** PYR ******************
+ ***************************************/
+#if defined (__pyr__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addw %5,%1 \n" \
+ "addwc %3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subw %5,%1 \n" \
+ "subwb %3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+/* This insn works on Pyramids with AP, XP, or MI CPUs, but not with SP. */
+#define umul_ppmm(w1, w0, u, v) \
+ ({union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ __asm__ ("movw %1,%R0 \n" \
+ "uemul %2,%0" \
+ : "=&r" (__xx.__ll) \
+ : "g" ((USItype) (u)), \
+ "g" ((USItype)(v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#endif /* __pyr__ */
+
+
+/***************************************
+ ************** RT/ROMP **************
+ ***************************************/
+#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("a %1,%5 \n" \
+ "ae %0,%3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%0" ((USItype)(ah)), \
+ "r" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "r" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("s %1,%5\n" \
+ "se %0,%3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "0" ((USItype)(ah)), \
+ "r" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "r" ((USItype)(bl)))
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ( \
+ "s r2,r2 \n" \
+ "mts r10,%2 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "cas %0,r2,r0 \n" \
+ "mfs r10,%1" \
+ : "=r" ((USItype)(ph)), \
+ "=r" ((USItype)(pl)) \
+ : "%r" (__m0), \
+ "r" (__m1) \
+ : "r2"); \
+ (ph) += ((((SItype) __m0 >> 31) & __m1) \
+ + (((SItype) __m1 >> 31) & __m0)); \
+ } while (0)
+#define UMUL_TIME 20
+#define UDIV_TIME 200
+#define count_leading_zeros(count, x) \
+ do { \
+ if ((x) >= 0x10000) \
+ __asm__ ("clz %0,%1" \
+ : "=r" ((USItype)(count)) \
+ : "r" ((USItype)(x) >> 16)); \
+ else \
+ { \
+ __asm__ ("clz %0,%1" \
+ : "=r" ((USItype)(count)) \
+ : "r" ((USItype)(x))); \
+ (count) += 16; \
+ } \
+ } while (0)
+#endif /* RT/ROMP */
+
+
+/***************************************
+ ************** SH2 ******************
+ ***************************************/
+#if (defined (__sh2__) || defined(__sh3__) || defined(__SH4__) ) \
+ && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ( \
+ "dmulu.l %2,%3\n" \
+ "sts macl,%1\n" \
+ "sts mach,%0" \
+ : "=r" ((USItype)(w1)), \
+ "=r" ((USItype)(w0)) \
+ : "r" ((USItype)(u)), \
+ "r" ((USItype)(v)) \
+ : "macl", "mach")
+#define UMUL_TIME 5
+#endif
+
+/***************************************
+ ************** SPARC ****************
+ ***************************************/
+#if defined (__sparc__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addcc %r4,%5,%1\n" \
+ "addx %r2,%3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%rJ" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "%rJ" ((USItype)(al)), \
+ "rI" ((USItype)(bl)) \
+ __CLOBBER_CC)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subcc %r4,%5,%1\n" \
+ "subx %r2,%3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "rJ" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "rJ" ((USItype)(al)), \
+ "rI" ((USItype)(bl)) \
+ __CLOBBER_CC)
+#if defined (__sparc_v8__)
+/* Don't match immediate range because, 1) it is not often useful,
+ 2) the 'I' flag thinks of the range as a 13 bit signed interval,
+ while we want to match a 13 bit interval, sign extended to 32 bits,
+ but INTERPRETED AS UNSIGNED. */
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("umul %2,%3,%1;rd %%y,%0" \
+ : "=r" ((USItype)(w1)), \
+ "=r" ((USItype)(w0)) \
+ : "r" ((USItype)(u)), \
+ "r" ((USItype)(v)))
+#define UMUL_TIME 5
+#ifndef SUPERSPARC /* SuperSPARC's udiv only handles 53 bit dividends */
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { \
+ USItype __q; \
+ __asm__ ("mov %1,%%y;nop;nop;nop;udiv %2,%3,%0" \
+ : "=r" ((USItype)(__q)) \
+ : "r" ((USItype)(n1)), \
+ "r" ((USItype)(n0)), \
+ "r" ((USItype)(d))); \
+ (r) = (n0) - __q * (d); \
+ (q) = __q; \
+ } while (0)
+#define UDIV_TIME 25
+#endif /* SUPERSPARC */
+#else /* ! __sparc_v8__ */
+#if defined (__sparclite__)
+/* This has hardware multiply but not divide. It also has two additional
+ instructions scan (ffs from high bit) and divscc. */
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("umul %2,%3,%1;rd %%y,%0" \
+ : "=r" ((USItype)(w1)), \
+ "=r" ((USItype)(w0)) \
+ : "r" ((USItype)(u)), \
+ "r" ((USItype)(v)))
+#define UMUL_TIME 5
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("! Inlined udiv_qrnnd \n" \
+ " wr %%g0,%2,%%y ! Not a delayed write for sparclite \n" \
+ " tst %%g0 \n" \
+ " divscc %3,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%0 \n" \
+ " rd %%y,%1 \n" \
+ " bl,a 1f \n" \
+ " add %1,%4,%1 \n" \
+ "1: ! End of inline udiv_qrnnd" \
+ : "=r" ((USItype)(q)), \
+ "=r" ((USItype)(r)) \
+ : "r" ((USItype)(n1)), \
+ "r" ((USItype)(n0)), \
+ "rI" ((USItype)(d)) \
+ : "%g1" __AND_CLOBBER_CC)
+#define UDIV_TIME 37
+#define count_leading_zeros(count, x) \
+ __asm__ ("scan %1,0,%0" \
+ : "=r" ((USItype)(x)) \
+ : "r" ((USItype)(count)))
+/* Early sparclites return 63 for an argument of 0, but they warn that future
+ implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0
+ undefined. */
+#endif /* __sparclite__ */
+#endif /* __sparc_v8__ */
+/* Default to sparc v7 versions of umul_ppmm and udiv_qrnnd. */
+#ifndef umul_ppmm
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("! Inlined umul_ppmm \n" \
+ " wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr \n" \
+ " sra %3,31,%%g2 ! Don't move this insn \n" \
+ " and %2,%%g2,%%g2 ! Don't move this insn \n" \
+ " andcc %%g0,0,%%g1 ! Don't move this insn \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,0,%%g1 \n" \
+ " add %%g1,%%g2,%0 \n" \
+ " rd %%y,%1" \
+ : "=r" ((USItype)(w1)), \
+ "=r" ((USItype)(w0)) \
+ : "%rI" ((USItype)(u)), \
+ "r" ((USItype)(v)) \
+ : "%g1", "%g2" __AND_CLOBBER_CC)
+#define UMUL_TIME 39 /* 39 instructions */
+#endif
+#ifndef udiv_qrnnd
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { USItype __r; \
+ (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
+ (r) = __r; \
+ } while (0)
+extern USItype __udiv_qrnnd ();
+#define UDIV_TIME 140
+#endif /* LONGLONG_STANDALONE */
+#endif /* udiv_qrnnd */
+#endif /* __sparc__ */
+
+
+/***************************************
+ ************** VAX ******************
+ ***************************************/
+#if defined (__vax__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addl2 %5,%1\n" \
+ "adwc %3,%0" \
+ : "=g" ((USItype)(sh)), \
+ "=&g" ((USItype)(sl)) \
+ : "%0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subl2 %5,%1\n" \
+ "sbwc %3,%0" \
+ : "=g" ((USItype)(sh)), \
+ "=&g" ((USItype)(sl)) \
+ : "0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("emul %1,%2,$0,%0" \
+ : "=g" (__xx.__ll) \
+ : "g" (__m0), \
+ "g" (__m1)); \
+ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
+ (xh) += ((((SItype) __m0 >> 31) & __m1) \
+ + (((SItype) __m1 >> 31) & __m0)); \
+ } while (0)
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+ do { \
+ union {DItype __ll; \
+ struct {SItype __l, __h;} __i; \
+ } __xx; \
+ __xx.__i.__h = n1; __xx.__i.__l = n0; \
+ __asm__ ("ediv %3,%2,%0,%1" \
+ : "=g" (q), "=g" (r) \
+ : "g" (__xx.__ll), "g" (d)); \
+ } while (0)
+#endif /* __vax__ */
+
+
+/***************************************
+ ************** Z8000 ****************
+ ***************************************/
+#if defined (__z8000__) && W_TYPE_SIZE == 16
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \
+ : "=r" ((unsigned int)(sh)), \
+ "=&r" ((unsigned int)(sl)) \
+ : "%0" ((unsigned int)(ah)), \
+ "r" ((unsigned int)(bh)), \
+ "%1" ((unsigned int)(al)), \
+ "rQR" ((unsigned int)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \
+ : "=r" ((unsigned int)(sh)), \
+ "=&r" ((unsigned int)(sl)) \
+ : "0" ((unsigned int)(ah)), \
+ "r" ((unsigned int)(bh)), \
+ "1" ((unsigned int)(al)), \
+ "rQR" ((unsigned int)(bl)))
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {long int __ll; \
+ struct {unsigned int __h, __l;} __i; \
+ } __xx; \
+ unsigned int __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mult %S0,%H3" \
+ : "=r" (__xx.__i.__h), \
+ "=r" (__xx.__i.__l) \
+ : "%1" (__m0), \
+ "rQR" (__m1)); \
+ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
+ (xh) += ((((signed int) __m0 >> 15) & __m1) \
+ + (((signed int) __m1 >> 15) & __m0)); \
+ } while (0)
+#endif /* __z8000__ */
+
+#endif /* __GNUC__ */
+#endif /* !__riscos__ */
+
+
+/***************************************
+ *********** Generic Versions ********
+ ***************************************/
+#if !defined (umul_ppmm) && defined (__umulsidi3)
+#define umul_ppmm(ph, pl, m0, m1) \
+ { \
+ UDWtype __ll = __umulsidi3 (m0, m1); \
+ ph = (UWtype) (__ll >> W_TYPE_SIZE); \
+ pl = (UWtype) __ll; \
+ }
+#endif
+
+#if !defined (__umulsidi3)
+#define __umulsidi3(u, v) \
+ ({UWtype __hi, __lo; \
+ umul_ppmm (__hi, __lo, u, v); \
+ ((UDWtype) __hi << W_TYPE_SIZE) | __lo; })
+#endif
+
+/* If this machine has no inline assembler, use C macros. */
+
+#if !defined (add_ssaaaa)
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ do { \
+ UWtype __x; \
+ __x = (al) + (bl); \
+ (sh) = (ah) + (bh) + (__x < (al)); \
+ (sl) = __x; \
+ } while (0)
+#endif
+
+#if !defined (sub_ddmmss)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ UWtype __x; \
+ __x = (al) - (bl); \
+ (sh) = (ah) - (bh) - (__x > (al)); \
+ (sl) = __x; \
+ } while (0)
+#endif
+
+#if !defined (umul_ppmm)
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ UWtype __x0, __x1, __x2, __x3; \
+ UHWtype __ul, __vl, __uh, __vh; \
+ UWtype __u = (u), __v = (v); \
+ \
+ __ul = __ll_lowpart (__u); \
+ __uh = __ll_highpart (__u); \
+ __vl = __ll_lowpart (__v); \
+ __vh = __ll_highpart (__v); \
+ \
+ __x0 = (UWtype) __ul * __vl; \
+ __x1 = (UWtype) __ul * __vh; \
+ __x2 = (UWtype) __uh * __vl; \
+ __x3 = (UWtype) __uh * __vh; \
+ \
+ __x1 += __ll_highpart (__x0);/* this can't give carry */ \
+ __x1 += __x2; /* but this indeed can */ \
+ if (__x1 < __x2) /* did we get it? */ \
+ __x3 += __ll_B; /* yes, add it in the proper pos. */ \
+ \
+ (w1) = __x3 + __ll_highpart (__x1); \
+ (w0) = (__ll_lowpart (__x1) << W_TYPE_SIZE/2) + __ll_lowpart (__x0);\
+ } while (0)
+#endif
+
+#if !defined (umul_ppmm)
+#define smul_ppmm(w1, w0, u, v) \
+ do { \
+ UWtype __w1; \
+ UWtype __m0 = (u), __m1 = (v); \
+ umul_ppmm (__w1, w0, __m0, __m1); \
+ (w1) = __w1 - (-(__m0 >> (W_TYPE_SIZE - 1)) & __m1) \
+ - (-(__m1 >> (W_TYPE_SIZE - 1)) & __m0); \
+ } while (0)
+#endif
+
+/* Define this unconditionally, so it can be used for debugging. */
+#define __udiv_qrnnd_c(q, r, n1, n0, d) \
+ do { \
+ UWtype __d1, __d0, __q1, __q0, __r1, __r0, __m; \
+ __d1 = __ll_highpart (d); \
+ __d0 = __ll_lowpart (d); \
+ \
+ __r1 = (n1) % __d1; \
+ __q1 = (n1) / __d1; \
+ __m = (UWtype) __q1 * __d0; \
+ __r1 = __r1 * __ll_B | __ll_highpart (n0); \
+ if (__r1 < __m) \
+ { \
+ __q1--, __r1 += (d); \
+ if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
+ if (__r1 < __m) \
+ __q1--, __r1 += (d); \
+ } \
+ __r1 -= __m; \
+ \
+ __r0 = __r1 % __d1; \
+ __q0 = __r1 / __d1; \
+ __m = (UWtype) __q0 * __d0; \
+ __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
+ if (__r0 < __m) \
+ { \
+ __q0--, __r0 += (d); \
+ if (__r0 >= (d)) \
+ if (__r0 < __m) \
+ __q0--, __r0 += (d); \
+ } \
+ __r0 -= __m; \
+ \
+ (q) = (UWtype) __q1 * __ll_B | __q0; \
+ (r) = __r0; \
+ } while (0)
+
+/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
+ __udiv_w_sdiv (defined in libgcc or elsewhere). */
+#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
+#define udiv_qrnnd(q, r, nh, nl, d) \
+ do { \
+ UWtype __r; \
+ (q) = __MPN(udiv_w_sdiv) (&__r, nh, nl, d); \
+ (r) = __r; \
+ } while (0)
+#endif
+
+/* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */
+#if !defined (udiv_qrnnd)
+#define UDIV_NEEDS_NORMALIZATION 1
+#define udiv_qrnnd __udiv_qrnnd_c
+#endif
+
+#if !defined (count_leading_zeros)
+extern
+#ifdef __STDC__
+const
+#endif
+unsigned char _gcry_clz_tab[];
+#define MPI_INTERNAL_NEED_CLZ_TAB 1
+#define count_leading_zeros(count, x) \
+ do { \
+ UWtype __xr = (x); \
+ UWtype __a; \
+ \
+ if (W_TYPE_SIZE <= 32) \
+ { \
+ __a = __xr < ((UWtype) 1 << 2*__BITS4) \
+ ? (__xr < ((UWtype) 1 << __BITS4) ? 0 : __BITS4) \
+ : (__xr < ((UWtype) 1 << 3*__BITS4) ? 2*__BITS4 : 3*__BITS4);\
+ } \
+ else \
+ { \
+ for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \
+ if (((__xr >> __a) & 0xff) != 0) \
+ break; \
+ } \
+ \
+ (count) = W_TYPE_SIZE - (_gcry_clz_tab[__xr >> __a] + __a); \
+ } while (0)
+/* This version gives a well-defined value for zero. */
+#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
+#endif
+
+#if !defined (count_trailing_zeros)
+/* Define count_trailing_zeros using count_leading_zeros. The latter might be
+ defined in asm, but if it is not, the C version above is good enough. */
+#define count_trailing_zeros(count, x) \
+ do { \
+ UWtype __ctz_x = (x); \
+ UWtype __ctz_c; \
+ count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \
+ (count) = W_TYPE_SIZE - 1 - __ctz_c; \
+ } while (0)
+#endif
+
+#ifndef UDIV_NEEDS_NORMALIZATION
+#define UDIV_NEEDS_NORMALIZATION 0
+#endif
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-add.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-add.c
new file mode 100644
index 0000000..f8f6094
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-add.c
@@ -0,0 +1,237 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-add.c - MPI functions
+ * Copyright (C) 1994, 1996, 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mpi-internal.h"
+
+
+/****************
+ * Add the unsigned integer V to the mpi-integer U and store the
+ * result in W. U and V may be the same.
+ */
+void
+gcry_mpi_add_ui(gcry_mpi_t w, gcry_mpi_t u, unsigned long v )
+{
+ mpi_ptr_t wp, up;
+ mpi_size_t usize, wsize;
+ int usign, wsign;
+
+ usize = u->nlimbs;
+ usign = u->sign;
+ wsign = 0;
+
+ /* If not space for W (and possible carry), increase space. */
+ wsize = usize + 1;
+ if( w->alloced < wsize )
+ mpi_resize(w, wsize);
+
+ /* These must be after realloc (U may be the same as W). */
+ up = u->d;
+ wp = w->d;
+
+ if( !usize ) { /* simple */
+ wp[0] = v;
+ wsize = v? 1:0;
+ }
+ else if( !usign ) { /* mpi is not negative */
+ mpi_limb_t cy;
+ cy = _gcry_mpih_add_1(wp, up, usize, v);
+ wp[usize] = cy;
+ wsize = usize + cy;
+ }
+ else { /* The signs are different. Need exact comparison to determine
+ * which operand to subtract from which. */
+ if( usize == 1 && up[0] < v ) {
+ wp[0] = v - up[0];
+ wsize = 1;
+ }
+ else {
+ _gcry_mpih_sub_1(wp, up, usize, v);
+ /* Size can decrease with at most one limb. */
+ wsize = usize - (wp[usize-1]==0);
+ wsign = 1;
+ }
+ }
+
+ w->nlimbs = wsize;
+ w->sign = wsign;
+}
+
+
+void
+gcry_mpi_add(gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ mpi_ptr_t wp, up, vp;
+ mpi_size_t usize, vsize, wsize;
+ int usign, vsign, wsign;
+
+ if( u->nlimbs < v->nlimbs ) { /* Swap U and V. */
+ usize = v->nlimbs;
+ usign = v->sign;
+ vsize = u->nlimbs;
+ vsign = u->sign;
+ wsize = usize + 1;
+ RESIZE_IF_NEEDED(w, wsize);
+ /* These must be after realloc (u or v may be the same as w). */
+ up = v->d;
+ vp = u->d;
+ }
+ else {
+ usize = u->nlimbs;
+ usign = u->sign;
+ vsize = v->nlimbs;
+ vsign = v->sign;
+ wsize = usize + 1;
+ RESIZE_IF_NEEDED(w, wsize);
+ /* These must be after realloc (u or v may be the same as w). */
+ up = u->d;
+ vp = v->d;
+ }
+ wp = w->d;
+ wsign = 0;
+
+ if( !vsize ) { /* simple */
+ MPN_COPY(wp, up, usize );
+ wsize = usize;
+ wsign = usign;
+ }
+ else if( usign != vsign ) { /* different sign */
+ /* This test is right since USIZE >= VSIZE */
+ if( usize != vsize ) {
+ _gcry_mpih_sub(wp, up, usize, vp, vsize);
+ wsize = usize;
+ MPN_NORMALIZE(wp, wsize);
+ wsign = usign;
+ }
+ else if( _gcry_mpih_cmp(up, vp, usize) < 0 ) {
+ _gcry_mpih_sub_n(wp, vp, up, usize);
+ wsize = usize;
+ MPN_NORMALIZE(wp, wsize);
+ if( !usign )
+ wsign = 1;
+ }
+ else {
+ _gcry_mpih_sub_n(wp, up, vp, usize);
+ wsize = usize;
+ MPN_NORMALIZE(wp, wsize);
+ if( usign )
+ wsign = 1;
+ }
+ }
+ else { /* U and V have same sign. Add them. */
+ mpi_limb_t cy = _gcry_mpih_add(wp, up, usize, vp, vsize);
+ wp[usize] = cy;
+ wsize = usize + cy;
+ if( usign )
+ wsign = 1;
+ }
+
+ w->nlimbs = wsize;
+ w->sign = wsign;
+}
+
+
+/****************
+ * Subtract the unsigned integer V from the mpi-integer U and store the
+ * result in W.
+ */
+void
+gcry_mpi_sub_ui(gcry_mpi_t w, gcry_mpi_t u, unsigned long v )
+{
+ mpi_ptr_t wp, up;
+ mpi_size_t usize, wsize;
+ int usign, wsign;
+
+ usize = u->nlimbs;
+ usign = u->sign;
+ wsign = 0;
+
+ /* If not space for W (and possible carry), increase space. */
+ wsize = usize + 1;
+ if( w->alloced < wsize )
+ mpi_resize(w, wsize);
+
+ /* These must be after realloc (U may be the same as W). */
+ up = u->d;
+ wp = w->d;
+
+ if( !usize ) { /* simple */
+ wp[0] = v;
+ wsize = v? 1:0;
+ wsign = 1;
+ }
+ else if( usign ) { /* mpi and v are negative */
+ mpi_limb_t cy;
+ cy = _gcry_mpih_add_1(wp, up, usize, v);
+ wp[usize] = cy;
+ wsize = usize + cy;
+ }
+ else { /* The signs are different. Need exact comparison to determine
+ * which operand to subtract from which. */
+ if( usize == 1 && up[0] < v ) {
+ wp[0] = v - up[0];
+ wsize = 1;
+ wsign = 1;
+ }
+ else {
+ _gcry_mpih_sub_1(wp, up, usize, v);
+ /* Size can decrease with at most one limb. */
+ wsize = usize - (wp[usize-1]==0);
+ }
+ }
+
+ w->nlimbs = wsize;
+ w->sign = wsign;
+}
+
+void
+gcry_mpi_sub(gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ gcry_mpi_t vv = mpi_copy (v);
+ vv->sign = ! vv->sign;
+ gcry_mpi_add (w, u, vv);
+ mpi_free (vv);
+}
+
+
+void
+gcry_mpi_addm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ gcry_mpi_add(w, u, v);
+ _gcry_mpi_fdiv_r( w, w, m );
+}
+
+void
+gcry_mpi_subm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ gcry_mpi_sub(w, u, v);
+ _gcry_mpi_fdiv_r( w, w, m );
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-asm-defs.h b/grub-core/lib/libgcrypt-grub/mpi/mpi-asm-defs.h
new file mode 100644
index 0000000..13424e2
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-asm-defs.h
@@ -0,0 +1,10 @@
+/* This file defines some basic constants for the MPI machinery. We
+ * need to define the types on a per-CPU basis, so it is done with
+ * this file here. */
+#define BYTES_PER_MPI_LIMB (SIZEOF_UNSIGNED_LONG)
+
+
+
+
+
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-bit.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-bit.c
new file mode 100644
index 0000000..05b9f12
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-bit.c
@@ -0,0 +1,366 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-bit.c - MPI bit level functions
+ * Copyright (C) 1998, 1999, 2001, 2002, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+#ifdef MPI_INTERNAL_NEED_CLZ_TAB
+#ifdef __STDC__
+const
+#endif
+unsigned char
+_gcry_clz_tab[] =
+{
+ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+};
+#endif
+
+
+#define A_LIMB_1 ((mpi_limb_t)1)
+
+
+/****************
+ * Sometimes we have MSL (most significant limbs) which are 0;
+ * this is for some reasons not good, so this function removes them.
+ */
+void
+_gcry_mpi_normalize( gcry_mpi_t a )
+{
+ if( mpi_is_opaque(a) )
+ return;
+
+ for( ; a->nlimbs && !a->d[a->nlimbs-1]; a->nlimbs-- )
+ ;
+}
+
+
+
+/****************
+ * Return the number of bits in A.
+ */
+unsigned int
+gcry_mpi_get_nbits( gcry_mpi_t a )
+{
+ unsigned n;
+
+ if( mpi_is_opaque(a) ) {
+ return a->sign; /* which holds the number of bits */
+ }
+
+ _gcry_mpi_normalize( a );
+ if( a->nlimbs ) {
+ mpi_limb_t alimb = a->d[a->nlimbs-1];
+ if( alimb )
+ count_leading_zeros( n, alimb );
+ else
+ n = BITS_PER_MPI_LIMB;
+ n = BITS_PER_MPI_LIMB - n + (a->nlimbs-1) * BITS_PER_MPI_LIMB;
+ }
+ else
+ n = 0;
+ return n;
+}
+
+
+/****************
+ * Test whether bit N is set.
+ */
+int
+gcry_mpi_test_bit( gcry_mpi_t a, unsigned int n )
+{
+ unsigned int limbno, bitno;
+ mpi_limb_t limb;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if( limbno >= a->nlimbs )
+ return 0; /* too far left: this is a 0 */
+ limb = a->d[limbno];
+ return (limb & (A_LIMB_1 << bitno))? 1: 0;
+}
+
+
+/****************
+ * Set bit N of A.
+ */
+void
+gcry_mpi_set_bit( gcry_mpi_t a, unsigned int n )
+{
+ unsigned int limbno, bitno;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if ( limbno >= a->nlimbs )
+ {
+ mpi_resize (a, limbno+1 );
+ a->nlimbs = limbno+1;
+ }
+ a->d[limbno] |= (A_LIMB_1<<bitno);
+}
+
+/****************
+ * Set bit N of A. and clear all bits above
+ */
+void
+gcry_mpi_set_highbit( gcry_mpi_t a, unsigned int n )
+{
+ unsigned int limbno, bitno;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if ( limbno >= a->nlimbs )
+ {
+ mpi_resize (a, limbno+1 );
+ a->nlimbs = limbno+1;
+ }
+ a->d[limbno] |= (A_LIMB_1<<bitno);
+ for ( bitno++; bitno < BITS_PER_MPI_LIMB; bitno++ )
+ a->d[limbno] &= ~(A_LIMB_1 << bitno);
+ a->nlimbs = limbno+1;
+}
+
+/****************
+ * clear bit N of A and all bits above
+ */
+void
+gcry_mpi_clear_highbit( gcry_mpi_t a, unsigned int n )
+{
+ unsigned int limbno, bitno;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if( limbno >= a->nlimbs )
+ return; /* not allocated, therefore no need to clear bits
+ :-) */
+
+ for( ; bitno < BITS_PER_MPI_LIMB; bitno++ )
+ a->d[limbno] &= ~(A_LIMB_1 << bitno);
+ a->nlimbs = limbno+1;
+}
+
+/****************
+ * Clear bit N of A.
+ */
+void
+gcry_mpi_clear_bit( gcry_mpi_t a, unsigned int n )
+{
+ unsigned int limbno, bitno;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if( limbno >= a->nlimbs )
+ return; /* don't need to clear this bit, it's to far to left */
+ a->d[limbno] &= ~(A_LIMB_1 << bitno);
+}
+
+
+/****************
+ * Shift A by COUNT limbs to the right
+ * This is used only within the MPI library
+ */
+void
+_gcry_mpi_rshift_limbs( gcry_mpi_t a, unsigned int count )
+{
+ mpi_ptr_t ap = a->d;
+ mpi_size_t n = a->nlimbs;
+ unsigned int i;
+
+ if( count >= n ) {
+ a->nlimbs = 0;
+ return;
+ }
+
+ for( i = 0; i < n - count; i++ )
+ ap[i] = ap[i+count];
+ ap[i] = 0;
+ a->nlimbs -= count;
+}
+
+
+/*
+ * Shift A by N bits to the right.
+ */
+void
+gcry_mpi_rshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n )
+{
+ mpi_size_t xsize;
+ unsigned int i;
+ unsigned int nlimbs = (n/BITS_PER_MPI_LIMB);
+ unsigned int nbits = (n%BITS_PER_MPI_LIMB);
+
+ if ( x == a )
+ {
+ /* In-place operation. */
+ if ( nlimbs >= x->nlimbs )
+ {
+ x->nlimbs = 0;
+ return;
+ }
+
+ if (nlimbs)
+ {
+ for (i=0; i < x->nlimbs - nlimbs; i++ )
+ x->d[i] = x->d[i+nlimbs];
+ x->d[i] = 0;
+ x->nlimbs -= nlimbs;
+
+ }
+ if ( x->nlimbs && nbits )
+ _gcry_mpih_rshift ( x->d, x->d, x->nlimbs, nbits );
+ }
+ else if ( nlimbs )
+ {
+ /* Copy and shift by more or equal bits than in a limb. */
+ xsize = a->nlimbs;
+ x->sign = a->sign;
+ RESIZE_IF_NEEDED (x, xsize);
+ x->nlimbs = xsize;
+ for (i=0; i < a->nlimbs; i++ )
+ x->d[i] = a->d[i];
+ x->nlimbs = i;
+
+ if ( nlimbs >= x->nlimbs )
+ {
+ x->nlimbs = 0;
+ return;
+ }
+
+ if (nlimbs)
+ {
+ for (i=0; i < x->nlimbs - nlimbs; i++ )
+ x->d[i] = x->d[i+nlimbs];
+ x->d[i] = 0;
+ x->nlimbs -= nlimbs;
+ }
+
+ if ( x->nlimbs && nbits )
+ _gcry_mpih_rshift ( x->d, x->d, x->nlimbs, nbits );
+ }
+ else
+ {
+ /* Copy and shift by less than bits in a limb. */
+ xsize = a->nlimbs;
+ x->sign = a->sign;
+ RESIZE_IF_NEEDED (x, xsize);
+ x->nlimbs = xsize;
+
+ if ( xsize )
+ {
+ if (nbits )
+ _gcry_mpih_rshift (x->d, a->d, x->nlimbs, nbits );
+ else
+ {
+ /* The rshift helper function is not specified for
+ NBITS==0, thus we do a plain copy here. */
+ for (i=0; i < x->nlimbs; i++ )
+ x->d[i] = a->d[i];
+ }
+ }
+ }
+ MPN_NORMALIZE (x->d, x->nlimbs);
+}
+
+
+/****************
+ * Shift A by COUNT limbs to the left
+ * This is used only within the MPI library
+ */
+void
+_gcry_mpi_lshift_limbs (gcry_mpi_t a, unsigned int count)
+{
+ mpi_ptr_t ap;
+ int n = a->nlimbs;
+ int i;
+
+ if (!count || !n)
+ return;
+
+ RESIZE_IF_NEEDED (a, n+count);
+
+ ap = a->d;
+ for (i = n-1; i >= 0; i--)
+ ap[i+count] = ap[i];
+ for (i=0; i < count; i++ )
+ ap[i] = 0;
+ a->nlimbs += count;
+}
+
+
+/*
+ * Shift A by N bits to the left.
+ */
+void
+gcry_mpi_lshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n )
+{
+ unsigned int nlimbs = (n/BITS_PER_MPI_LIMB);
+ unsigned int nbits = (n%BITS_PER_MPI_LIMB);
+
+ if (x == a && !n)
+ return; /* In-place shift with an amount of zero. */
+
+ if ( x != a )
+ {
+ /* Copy A to X. */
+ unsigned int alimbs = a->nlimbs;
+ int asign = a->sign;
+ mpi_ptr_t xp, ap;
+
+ RESIZE_IF_NEEDED (x, alimbs+nlimbs+1);
+ xp = x->d;
+ ap = a->d;
+ MPN_COPY (xp, ap, alimbs);
+ x->nlimbs = alimbs;
+ x->flags = a->flags;
+ x->sign = asign;
+ }
+
+ if (nlimbs && !nbits)
+ {
+ /* Shift a full number of limbs. */
+ _gcry_mpi_lshift_limbs (x, nlimbs);
+ }
+ else if (n)
+ {
+ /* We use a very dump approach: Shift left by the number of
+ limbs plus one and than fix it up by an rshift. */
+ _gcry_mpi_lshift_limbs (x, nlimbs+1);
+ gcry_mpi_rshift (x, x, BITS_PER_MPI_LIMB - nbits);
+ }
+
+ MPN_NORMALIZE (x->d, x->nlimbs);
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-cmp.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-cmp.c
new file mode 100644
index 0000000..b0ebbc1
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-cmp.c
@@ -0,0 +1,109 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-cmp.c - MPI functions
+ * Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+int
+gcry_mpi_cmp_ui (gcry_mpi_t u, unsigned long v)
+{
+ mpi_limb_t limb = v;
+
+ _gcry_mpi_normalize (u);
+
+ /* Handle the case that U contains no limb. */
+ if (u->nlimbs == 0)
+ return -(limb != 0);
+
+ /* Handle the case that U is negative. */
+ if (u->sign)
+ return -1;
+
+ if (u->nlimbs == 1)
+ {
+ /* Handle the case that U contains exactly one limb. */
+
+ if (u->d[0] > limb)
+ return 1;
+ if (u->d[0] < limb)
+ return -1;
+ return 0;
+ }
+ else
+ /* Handle the case that U contains more than one limb. */
+ return 1;
+}
+
+
+int
+gcry_mpi_cmp (gcry_mpi_t u, gcry_mpi_t v)
+{
+ mpi_size_t usize;
+ mpi_size_t vsize;
+ int cmp;
+
+ if (mpi_is_opaque (u) || mpi_is_opaque (v))
+ {
+ if (mpi_is_opaque (u) && !mpi_is_opaque (v))
+ return -1;
+ if (!mpi_is_opaque (u) && mpi_is_opaque (v))
+ return 1;
+ if (!u->sign && !v->sign)
+ return 0; /* Empty buffers are identical. */
+ if (u->sign < v->sign)
+ return -1;
+ if (u->sign > v->sign)
+ return 1;
+ return memcmp (u->d, v->d, (u->sign+7)/8);
+ }
+ else
+ {
+ _gcry_mpi_normalize (u);
+ _gcry_mpi_normalize (v);
+
+ usize = u->nlimbs;
+ vsize = v->nlimbs;
+
+ /* Compare sign bits. */
+
+ if (!u->sign && v->sign)
+ return 1;
+ if (u->sign && !v->sign)
+ return -1;
+
+ /* U and V are either both positive or both negative. */
+
+ if (usize != vsize && !u->sign && !v->sign)
+ return usize - vsize;
+ if (usize != vsize && u->sign && v->sign)
+ return vsize + usize;
+ if (!usize )
+ return 0;
+ if (!(cmp = _gcry_mpih_cmp (u->d, v->d, usize)))
+ return 0;
+ if ((cmp < 0?1:0) == (u->sign?1:0))
+ return 1;
+ }
+ return -1;
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-div.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-div.c
new file mode 100644
index 0000000..5218caa
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-div.c
@@ -0,0 +1,357 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-div.c - MPI functions
+ * Copyright (C) 1994, 1996, 1998, 2001, 2002,
+ * 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+#include "g10lib.h"
+
+
+void
+_gcry_mpi_fdiv_r( gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor )
+{
+ int divisor_sign = divisor->sign;
+ gcry_mpi_t temp_divisor = NULL;
+
+ /* We need the original value of the divisor after the remainder has been
+ * preliminary calculated. We have to copy it to temporary space if it's
+ * the same variable as REM. */
+ if( rem == divisor ) {
+ temp_divisor = mpi_copy( divisor );
+ divisor = temp_divisor;
+ }
+
+ _gcry_mpi_tdiv_r( rem, dividend, divisor );
+
+ if( ((divisor_sign?1:0) ^ (dividend->sign?1:0)) && rem->nlimbs )
+ gcry_mpi_add( rem, rem, divisor);
+
+ if( temp_divisor )
+ mpi_free(temp_divisor);
+}
+
+
+
+/****************
+ * Division rounding the quotient towards -infinity.
+ * The remainder gets the same sign as the denominator.
+ * rem is optional
+ */
+
+ulong
+_gcry_mpi_fdiv_r_ui( gcry_mpi_t rem, gcry_mpi_t dividend, ulong divisor )
+{
+ mpi_limb_t rlimb;
+
+ rlimb = _gcry_mpih_mod_1( dividend->d, dividend->nlimbs, divisor );
+ if( rlimb && dividend->sign )
+ rlimb = divisor - rlimb;
+
+ if( rem ) {
+ rem->d[0] = rlimb;
+ rem->nlimbs = rlimb? 1:0;
+ }
+ return rlimb;
+}
+
+
+void
+_gcry_mpi_fdiv_q( gcry_mpi_t quot, gcry_mpi_t dividend, gcry_mpi_t divisor )
+{
+ gcry_mpi_t tmp = mpi_alloc( mpi_get_nlimbs(quot) );
+ _gcry_mpi_fdiv_qr( quot, tmp, dividend, divisor);
+ mpi_free(tmp);
+}
+
+void
+_gcry_mpi_fdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor )
+{
+ int divisor_sign = divisor->sign;
+ gcry_mpi_t temp_divisor = NULL;
+
+ if( quot == divisor || rem == divisor ) {
+ temp_divisor = mpi_copy( divisor );
+ divisor = temp_divisor;
+ }
+
+ _gcry_mpi_tdiv_qr( quot, rem, dividend, divisor );
+
+ if( (divisor_sign ^ dividend->sign) && rem->nlimbs ) {
+ gcry_mpi_sub_ui( quot, quot, 1 );
+ gcry_mpi_add( rem, rem, divisor);
+ }
+
+ if( temp_divisor )
+ mpi_free(temp_divisor);
+}
+
+
+/* If den == quot, den needs temporary storage.
+ * If den == rem, den needs temporary storage.
+ * If num == quot, num needs temporary storage.
+ * If den has temporary storage, it can be normalized while being copied,
+ * i.e no extra storage should be allocated.
+ */
+
+void
+_gcry_mpi_tdiv_r( gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t den)
+{
+ _gcry_mpi_tdiv_qr(NULL, rem, num, den );
+}
+
+void
+_gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t den)
+{
+ mpi_ptr_t np, dp;
+ mpi_ptr_t qp, rp;
+ mpi_size_t nsize = num->nlimbs;
+ mpi_size_t dsize = den->nlimbs;
+ mpi_size_t qsize, rsize;
+ mpi_size_t sign_remainder = num->sign;
+ mpi_size_t sign_quotient = num->sign ^ den->sign;
+ unsigned normalization_steps;
+ mpi_limb_t q_limb;
+ mpi_ptr_t marker[5];
+ unsigned int marker_nlimbs[5];
+ int markidx=0;
+
+ /* Ensure space is enough for quotient and remainder.
+ * We need space for an extra limb in the remainder, because it's
+ * up-shifted (normalized) below. */
+ rsize = nsize + 1;
+ mpi_resize( rem, rsize);
+
+ qsize = rsize - dsize; /* qsize cannot be bigger than this. */
+ if( qsize <= 0 ) {
+ if( num != rem ) {
+ rem->nlimbs = num->nlimbs;
+ rem->sign = num->sign;
+ MPN_COPY(rem->d, num->d, nsize);
+ }
+ if( quot ) {
+ /* This needs to follow the assignment to rem, in case the
+ * numerator and quotient are the same. */
+ quot->nlimbs = 0;
+ quot->sign = 0;
+ }
+ return;
+ }
+
+ if( quot )
+ mpi_resize( quot, qsize);
+
+ /* Read pointers here, when reallocation is finished. */
+ np = num->d;
+ dp = den->d;
+ rp = rem->d;
+
+ /* Optimize division by a single-limb divisor. */
+ if( dsize == 1 ) {
+ mpi_limb_t rlimb;
+ if( quot ) {
+ qp = quot->d;
+ rlimb = _gcry_mpih_divmod_1( qp, np, nsize, dp[0] );
+ qsize -= qp[qsize - 1] == 0;
+ quot->nlimbs = qsize;
+ quot->sign = sign_quotient;
+ }
+ else
+ rlimb = _gcry_mpih_mod_1( np, nsize, dp[0] );
+ rp[0] = rlimb;
+ rsize = rlimb != 0?1:0;
+ rem->nlimbs = rsize;
+ rem->sign = sign_remainder;
+ return;
+ }
+
+
+ if( quot ) {
+ qp = quot->d;
+ /* Make sure QP and NP point to different objects. Otherwise the
+ * numerator would be gradually overwritten by the quotient limbs. */
+ if(qp == np) { /* Copy NP object to temporary space. */
+ marker_nlimbs[markidx] = nsize;
+ np = marker[markidx++] = mpi_alloc_limb_space(nsize,
+ mpi_is_secure(quot));
+ MPN_COPY(np, qp, nsize);
+ }
+ }
+ else /* Put quotient at top of remainder. */
+ qp = rp + dsize;
+
+ count_leading_zeros( normalization_steps, dp[dsize - 1] );
+
+ /* Normalize the denominator, i.e. make its most significant bit set by
+ * shifting it NORMALIZATION_STEPS bits to the left. Also shift the
+ * numerator the same number of steps (to keep the quotient the same!).
+ */
+ if( normalization_steps ) {
+ mpi_ptr_t tp;
+ mpi_limb_t nlimb;
+
+ /* Shift up the denominator setting the most significant bit of
+ * the most significant word. Use temporary storage not to clobber
+ * the original contents of the denominator. */
+ marker_nlimbs[markidx] = dsize;
+ tp = marker[markidx++] = mpi_alloc_limb_space(dsize,mpi_is_secure(den));
+ _gcry_mpih_lshift( tp, dp, dsize, normalization_steps );
+ dp = tp;
+
+ /* Shift up the numerator, possibly introducing a new most
+ * significant word. Move the shifted numerator in the remainder
+ * meanwhile. */
+ nlimb = _gcry_mpih_lshift(rp, np, nsize, normalization_steps);
+ if( nlimb ) {
+ rp[nsize] = nlimb;
+ rsize = nsize + 1;
+ }
+ else
+ rsize = nsize;
+ }
+ else {
+ /* The denominator is already normalized, as required. Copy it to
+ * temporary space if it overlaps with the quotient or remainder. */
+ if( dp == rp || (quot && (dp == qp))) {
+ mpi_ptr_t tp;
+
+ marker_nlimbs[markidx] = dsize;
+ tp = marker[markidx++] = mpi_alloc_limb_space(dsize,
+ mpi_is_secure(den));
+ MPN_COPY( tp, dp, dsize );
+ dp = tp;
+ }
+
+ /* Move the numerator to the remainder. */
+ if( rp != np )
+ MPN_COPY(rp, np, nsize);
+
+ rsize = nsize;
+ }
+
+ q_limb = _gcry_mpih_divrem( qp, 0, rp, rsize, dp, dsize );
+
+ if( quot ) {
+ qsize = rsize - dsize;
+ if(q_limb) {
+ qp[qsize] = q_limb;
+ qsize += 1;
+ }
+
+ quot->nlimbs = qsize;
+ quot->sign = sign_quotient;
+ }
+
+ rsize = dsize;
+ MPN_NORMALIZE (rp, rsize);
+
+ if( normalization_steps && rsize ) {
+ _gcry_mpih_rshift(rp, rp, rsize, normalization_steps);
+ rsize -= rp[rsize - 1] == 0?1:0;
+ }
+
+ rem->nlimbs = rsize;
+ rem->sign = sign_remainder;
+ while( markidx )
+ {
+ markidx--;
+ _gcry_mpi_free_limb_space (marker[markidx], marker_nlimbs[markidx]);
+ }
+}
+
+void
+_gcry_mpi_tdiv_q_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned int count )
+{
+ mpi_size_t usize, wsize;
+ mpi_size_t limb_cnt;
+
+ usize = u->nlimbs;
+ limb_cnt = count / BITS_PER_MPI_LIMB;
+ wsize = usize - limb_cnt;
+ if( limb_cnt >= usize )
+ w->nlimbs = 0;
+ else {
+ mpi_ptr_t wp;
+ mpi_ptr_t up;
+
+ RESIZE_IF_NEEDED( w, wsize );
+ wp = w->d;
+ up = u->d;
+
+ count %= BITS_PER_MPI_LIMB;
+ if( count ) {
+ _gcry_mpih_rshift( wp, up + limb_cnt, wsize, count );
+ wsize -= !wp[wsize - 1];
+ }
+ else {
+ MPN_COPY_INCR( wp, up + limb_cnt, wsize);
+ }
+
+ w->nlimbs = wsize;
+ }
+}
+
+/****************
+ * Check whether dividend is divisible by divisor
+ * (note: divisor must fit into a limb)
+ */
+int
+_gcry_mpi_divisible_ui(gcry_mpi_t dividend, ulong divisor )
+{
+ return !_gcry_mpih_mod_1( dividend->d, dividend->nlimbs, divisor );
+}
+
+
+void
+gcry_mpi_div (gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor, int round)
+{
+ if (!round)
+ {
+ if (!rem)
+ {
+ gcry_mpi_t tmp = mpi_alloc (mpi_get_nlimbs(quot));
+ _gcry_mpi_tdiv_qr (quot, tmp, dividend, divisor);
+ mpi_free (tmp);
+ }
+ else
+ _gcry_mpi_tdiv_qr (quot, rem, dividend, divisor);
+ }
+ else if (round < 0)
+ {
+ if (!rem)
+ _gcry_mpi_fdiv_q (quot, dividend, divisor);
+ else if (!quot)
+ _gcry_mpi_fdiv_r (rem, dividend, divisor);
+ else
+ _gcry_mpi_fdiv_qr (quot, rem, dividend, divisor);
+ }
+ else
+ log_bug ("mpi rounding to ceiling not yet implemented\n");
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-gcd.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-gcd.c
new file mode 100644
index 0000000..34bd249
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-gcd.c
@@ -0,0 +1,53 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-gcd.c - MPI functions
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+/****************
+ * Find the greatest common divisor G of A and B.
+ * Return: true if this 1, false in all other cases
+ */
+int
+gcry_mpi_gcd( gcry_mpi_t g, gcry_mpi_t xa, gcry_mpi_t xb )
+{
+ gcry_mpi_t a, b;
+
+ a = mpi_copy(xa);
+ b = mpi_copy(xb);
+
+ /* TAOCP Vol II, 4.5.2, Algorithm A */
+ a->sign = 0;
+ b->sign = 0;
+ while( gcry_mpi_cmp_ui( b, 0 ) ) {
+ _gcry_mpi_fdiv_r( g, a, b ); /* g used as temorary variable */
+ mpi_set(a,b);
+ mpi_set(b,g);
+ }
+ mpi_set(g, a);
+
+ mpi_free(a);
+ mpi_free(b);
+ return !gcry_mpi_cmp_ui( g, 1);
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-inline.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-inline.c
new file mode 100644
index 0000000..4e3e8f3
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-inline.c
@@ -0,0 +1,37 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-inline.c
+ * Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* put the inline functions as real functions into the lib */
+#define G10_MPI_INLINE_DECL
+
+#include "mpi-internal.h"
+
+/* always include the header because it is only
+ * included by mpi-internal if __GCC__ is defined but we
+ * need it here in all cases and the above definition of
+ * of the macro allows us to do so
+ */
+#include "mpi-inline.h"
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-inline.h b/grub-core/lib/libgcrypt-grub/mpi/mpi-inline.h
new file mode 100644
index 0000000..0818d20
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-inline.h
@@ -0,0 +1,163 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-inline.h - Internal to the Multi Precision Integers
+ * Copyright (C) 1994, 1996, 1998, 1999,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#ifndef G10_MPI_INLINE_H
+#define G10_MPI_INLINE_H
+
+/* Starting with gcc 4.3 "extern inline" conforms in c99 mode to the
+ c99 semantics. To keep the useful old semantics we use an
+ attribute. */
+#ifndef G10_MPI_INLINE_DECL
+# ifdef __GNUC_STDC_INLINE__
+# define G10_MPI_INLINE_DECL extern inline __attribute__ ((__gnu_inline__))
+# else
+# define G10_MPI_INLINE_DECL extern __inline__
+# endif
+#endif
+
+G10_MPI_INLINE_DECL mpi_limb_t
+_gcry_mpih_add_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+ mpi_limb_t x;
+
+ x = *s1_ptr++;
+ s2_limb += x;
+ *res_ptr++ = s2_limb;
+ if( s2_limb < x ) { /* sum is less than the left operand: handle carry */
+ while( --s1_size ) {
+ x = *s1_ptr++ + 1; /* add carry */
+ *res_ptr++ = x; /* and store */
+ if( x ) /* not 0 (no overflow): we can stop */
+ goto leave;
+ }
+ return 1; /* return carry (size of s1 to small) */
+ }
+
+ leave:
+ if( res_ptr != s1_ptr ) { /* not the same variable */
+ mpi_size_t i; /* copy the rest */
+ for( i=0; i < s1_size-1; i++ )
+ res_ptr[i] = s1_ptr[i];
+ }
+ return 0; /* no carry */
+}
+
+
+
+G10_MPI_INLINE_DECL mpi_limb_t
+_gcry_mpih_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_ptr_t s2_ptr, mpi_size_t s2_size)
+{
+ mpi_limb_t cy = 0;
+
+ if( s2_size )
+ cy = _gcry_mpih_add_n( res_ptr, s1_ptr, s2_ptr, s2_size );
+
+ if( s1_size - s2_size )
+ cy = _gcry_mpih_add_1( res_ptr + s2_size, s1_ptr + s2_size,
+ s1_size - s2_size, cy);
+ return cy;
+}
+
+
+G10_MPI_INLINE_DECL mpi_limb_t
+_gcry_mpih_sub_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb )
+{
+ mpi_limb_t x;
+
+ x = *s1_ptr++;
+ s2_limb = x - s2_limb;
+ *res_ptr++ = s2_limb;
+ if( s2_limb > x ) {
+ while( --s1_size ) {
+ x = *s1_ptr++;
+ *res_ptr++ = x - 1;
+ if( x )
+ goto leave;
+ }
+ return 1;
+ }
+
+ leave:
+ if( res_ptr != s1_ptr ) {
+ mpi_size_t i;
+ for( i=0; i < s1_size-1; i++ )
+ res_ptr[i] = s1_ptr[i];
+ }
+ return 0;
+}
+
+
+
+G10_MPI_INLINE_DECL mpi_limb_t
+_gcry_mpih_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_ptr_t s2_ptr, mpi_size_t s2_size)
+{
+ mpi_limb_t cy = 0;
+
+ if( s2_size )
+ cy = _gcry_mpih_sub_n(res_ptr, s1_ptr, s2_ptr, s2_size);
+
+ if( s1_size - s2_size )
+ cy = _gcry_mpih_sub_1(res_ptr + s2_size, s1_ptr + s2_size,
+ s1_size - s2_size, cy);
+ return cy;
+}
+
+/****************
+ * Compare OP1_PTR/OP1_SIZE with OP2_PTR/OP2_SIZE.
+ * There are no restrictions on the relative sizes of
+ * the two arguments.
+ * Return 1 if OP1 > OP2, 0 if they are equal, and -1 if OP1 < OP2.
+ */
+G10_MPI_INLINE_DECL int
+_gcry_mpih_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size )
+{
+ mpi_size_t i;
+ mpi_limb_t op1_word, op2_word;
+
+ for( i = size - 1; i >= 0 ; i--) {
+ op1_word = op1_ptr[i];
+ op2_word = op2_ptr[i];
+ if( op1_word != op2_word )
+ goto diff;
+ }
+ return 0;
+
+ diff:
+ /* This can *not* be simplified to
+ * op2_word - op2_word
+ * since that expression might give signed overflow. */
+ return (op1_word > op2_word) ? 1 : -1;
+}
+
+
+#endif /*G10_MPI_INLINE_H*/
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-internal.h b/grub-core/lib/libgcrypt-grub/mpi/mpi-internal.h
new file mode 100644
index 0000000..c9684f2
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-internal.h
@@ -0,0 +1,279 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-internal.h - Internal to the Multi Precision Integers
+ * Copyright (C) 1994, 1996, 1998, 2000, 2002,
+ * 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#ifndef G10_MPI_INTERNAL_H
+#define G10_MPI_INTERNAL_H
+
+#include "mpi-asm-defs.h"
+
+#ifndef BITS_PER_MPI_LIMB
+#if BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_INT
+ typedef unsigned int mpi_limb_t;
+ typedef signed int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_LONG
+ typedef unsigned long int mpi_limb_t;
+ typedef signed long int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_LONG_LONG
+ typedef unsigned long long int mpi_limb_t;
+ typedef signed long long int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_SHORT
+ typedef unsigned short int mpi_limb_t;
+ typedef signed short int mpi_limb_signed_t;
+#else
+#error BYTES_PER_MPI_LIMB does not match any C type
+#endif
+#define BITS_PER_MPI_LIMB (8*BYTES_PER_MPI_LIMB)
+#endif /*BITS_PER_MPI_LIMB*/
+
+#include "mpi.h"
+
+/* If KARATSUBA_THRESHOLD is not already defined, define it to a
+ * value which is good on most machines. */
+
+/* tested 4, 16, 32 and 64, where 16 gave the best performance when
+ * checking a 768 and a 1024 bit ElGamal signature.
+ * (wk 22.12.97) */
+#ifndef KARATSUBA_THRESHOLD
+#define KARATSUBA_THRESHOLD 16
+#endif
+
+/* The code can't handle KARATSUBA_THRESHOLD smaller than 2. */
+#if KARATSUBA_THRESHOLD < 2
+#undef KARATSUBA_THRESHOLD
+#define KARATSUBA_THRESHOLD 2
+#endif
+
+
+typedef mpi_limb_t *mpi_ptr_t; /* pointer to a limb */
+typedef int mpi_size_t; /* (must be a signed type) */
+
+#define ABS(x) (x >= 0 ? x : -x)
+#define MIN(l,o) ((l) < (o) ? (l) : (o))
+#define MAX(h,i) ((h) > (i) ? (h) : (i))
+#define RESIZE_IF_NEEDED(a,b) \
+ do { \
+ if( (a)->alloced < (b) ) \
+ mpi_resize((a), (b)); \
+ } while(0)
+
+/* Copy N limbs from S to D. */
+#define MPN_COPY( d, s, n) \
+ do { \
+ mpi_size_t _i; \
+ for( _i = 0; _i < (n); _i++ ) \
+ (d)[_i] = (s)[_i]; \
+ } while(0)
+
+#define MPN_COPY_INCR( d, s, n) \
+ do { \
+ mpi_size_t _i; \
+ for( _i = 0; _i < (n); _i++ ) \
+ (d)[_i] = (d)[_i]; \
+ } while (0)
+
+#define MPN_COPY_DECR( d, s, n ) \
+ do { \
+ mpi_size_t _i; \
+ for( _i = (n)-1; _i >= 0; _i--) \
+ (d)[_i] = (s)[_i]; \
+ } while(0)
+
+/* Zero N limbs at D */
+#define MPN_ZERO(d, n) \
+ do { \
+ int _i; \
+ for( _i = 0; _i < (n); _i++ ) \
+ (d)[_i] = 0; \
+ } while (0)
+
+#define MPN_NORMALIZE(d, n) \
+ do { \
+ while( (n) > 0 ) { \
+ if( (d)[(n)-1] ) \
+ break; \
+ (n)--; \
+ } \
+ } while(0)
+
+#define MPN_NORMALIZE_NOT_ZERO(d, n) \
+ do { \
+ for(;;) { \
+ if( (d)[(n)-1] ) \
+ break; \
+ (n)--; \
+ } \
+ } while(0)
+
+#define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \
+ do { \
+ if( (size) < KARATSUBA_THRESHOLD ) \
+ mul_n_basecase (prodp, up, vp, size); \
+ else \
+ mul_n (prodp, up, vp, size, tspace); \
+ } while (0);
+
+
+/* Divide the two-limb number in (NH,,NL) by D, with DI being the largest
+ * limb not larger than (2**(2*BITS_PER_MP_LIMB))/D - (2**BITS_PER_MP_LIMB).
+ * If this would yield overflow, DI should be the largest possible number
+ * (i.e., only ones). For correct operation, the most significant bit of D
+ * has to be set. Put the quotient in Q and the remainder in R.
+ */
+#define UDIV_QRNND_PREINV(q, r, nh, nl, d, di) \
+ do { \
+ mpi_limb_t _q, _ql, _r; \
+ mpi_limb_t _xh, _xl; \
+ umul_ppmm (_q, _ql, (nh), (di)); \
+ _q += (nh); /* DI is 2**BITS_PER_MPI_LIMB too small */ \
+ umul_ppmm (_xh, _xl, _q, (d)); \
+ sub_ddmmss (_xh, _r, (nh), (nl), _xh, _xl); \
+ if( _xh ) { \
+ sub_ddmmss (_xh, _r, _xh, _r, 0, (d)); \
+ _q++; \
+ if( _xh) { \
+ sub_ddmmss (_xh, _r, _xh, _r, 0, (d)); \
+ _q++; \
+ } \
+ } \
+ if( _r >= (d) ) { \
+ _r -= (d); \
+ _q++; \
+ } \
+ (r) = _r; \
+ (q) = _q; \
+ } while (0)
+
+
+/*-- mpiutil.c --*/
+#define mpi_alloc_limb_space(n,f) _gcry_mpi_alloc_limb_space((n),(f))
+mpi_ptr_t _gcry_mpi_alloc_limb_space( unsigned nlimbs, int sec );
+void _gcry_mpi_free_limb_space( mpi_ptr_t a, unsigned int nlimbs );
+void _gcry_mpi_assign_limb_space( gcry_mpi_t a, mpi_ptr_t ap, unsigned nlimbs );
+
+/*-- mpi-bit.c --*/
+#define mpi_rshift_limbs(a,n) _gcry_mpi_rshift_limbs ((a), (n))
+#define mpi_lshift_limbs(a,n) _gcry_mpi_lshift_limbs ((a), (n))
+
+void _gcry_mpi_rshift_limbs( gcry_mpi_t a, unsigned int count );
+void _gcry_mpi_lshift_limbs( gcry_mpi_t a, unsigned int count );
+
+
+/*-- mpih-add.c --*/
+mpi_limb_t _gcry_mpih_add_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb );
+mpi_limb_t _gcry_mpih_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_ptr_t s2_ptr, mpi_size_t size);
+mpi_limb_t _gcry_mpih_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_ptr_t s2_ptr, mpi_size_t s2_size);
+
+/*-- mpih-sub.c --*/
+mpi_limb_t _gcry_mpih_sub_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb );
+mpi_limb_t _gcry_mpih_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_ptr_t s2_ptr, mpi_size_t size);
+mpi_limb_t _gcry_mpih_sub(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_ptr_t s2_ptr, mpi_size_t s2_size);
+
+/*-- mpih-cmp.c --*/
+int _gcry_mpih_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size );
+
+/*-- mpih-mul.c --*/
+
+struct karatsuba_ctx {
+ struct karatsuba_ctx *next;
+ mpi_ptr_t tspace;
+ unsigned int tspace_nlimbs;
+ mpi_size_t tspace_size;
+ mpi_ptr_t tp;
+ unsigned int tp_nlimbs;
+ mpi_size_t tp_size;
+};
+
+void _gcry_mpih_release_karatsuba_ctx( struct karatsuba_ctx *ctx );
+
+mpi_limb_t _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb);
+mpi_limb_t _gcry_mpih_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb);
+void _gcry_mpih_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp,
+ mpi_size_t size);
+mpi_limb_t _gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize,
+ mpi_ptr_t vp, mpi_size_t vsize);
+void _gcry_mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size );
+void _gcry_mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size,
+ mpi_ptr_t tspace);
+
+void _gcry_mpih_mul_karatsuba_case( mpi_ptr_t prodp,
+ mpi_ptr_t up, mpi_size_t usize,
+ mpi_ptr_t vp, mpi_size_t vsize,
+ struct karatsuba_ctx *ctx );
+
+
+/*-- mpih-mul_1.c (or xxx/cpu/ *.S) --*/
+mpi_limb_t _gcry_mpih_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb);
+
+/*-- mpih-div.c --*/
+mpi_limb_t _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+ mpi_limb_t divisor_limb);
+mpi_limb_t _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs,
+ mpi_ptr_t np, mpi_size_t nsize,
+ mpi_ptr_t dp, mpi_size_t dsize);
+mpi_limb_t _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr,
+ mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+ mpi_limb_t divisor_limb);
+
+/*-- mpih-shift.c --*/
+mpi_limb_t _gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
+ unsigned cnt);
+mpi_limb_t _gcry_mpih_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
+ unsigned cnt);
+
+
+/* Define stuff for longlong.h. */
+#define W_TYPE_SIZE BITS_PER_MPI_LIMB
+ typedef mpi_limb_t UWtype;
+ typedef unsigned int UHWtype;
+#if defined (__GNUC__)
+ typedef unsigned int UQItype __attribute__ ((mode (QI)));
+ typedef int SItype __attribute__ ((mode (SI)));
+ typedef unsigned int USItype __attribute__ ((mode (SI)));
+ typedef int DItype __attribute__ ((mode (DI)));
+ typedef unsigned int UDItype __attribute__ ((mode (DI)));
+#else
+ typedef unsigned char UQItype;
+ typedef long SItype;
+ typedef unsigned long USItype;
+#endif
+
+#ifdef __GNUC__
+#include "mpi-inline.h"
+#endif
+
+#endif /*G10_MPI_INTERNAL_H*/
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-inv.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-inv.c
new file mode 100644
index 0000000..684384f
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-inv.c
@@ -0,0 +1,269 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-inv.c - MPI functions
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "g10lib.h"
+
+/****************
+ * Calculate the multiplicative inverse X of A mod N
+ * That is: Find the solution x for
+ * 1 = (a*x) mod n
+ */
+int
+gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n )
+{
+#if 0
+ gcry_mpi_t u, v, u1, u2, u3, v1, v2, v3, q, t1, t2, t3;
+ gcry_mpi_t ta, tb, tc;
+
+ u = mpi_copy(a);
+ v = mpi_copy(n);
+ u1 = mpi_alloc_set_ui(1);
+ u2 = mpi_alloc_set_ui(0);
+ u3 = mpi_copy(u);
+ v1 = mpi_alloc_set_ui(0);
+ v2 = mpi_alloc_set_ui(1);
+ v3 = mpi_copy(v);
+ q = mpi_alloc( mpi_get_nlimbs(u)+1 );
+ t1 = mpi_alloc( mpi_get_nlimbs(u)+1 );
+ t2 = mpi_alloc( mpi_get_nlimbs(u)+1 );
+ t3 = mpi_alloc( mpi_get_nlimbs(u)+1 );
+ while( mpi_cmp_ui( v3, 0 ) ) {
+ mpi_fdiv_q( q, u3, v3 );
+ mpi_mul(t1, v1, q); mpi_mul(t2, v2, q); mpi_mul(t3, v3, q);
+ mpi_sub(t1, u1, t1); mpi_sub(t2, u2, t2); mpi_sub(t3, u3, t3);
+ mpi_set(u1, v1); mpi_set(u2, v2); mpi_set(u3, v3);
+ mpi_set(v1, t1); mpi_set(v2, t2); mpi_set(v3, t3);
+ }
+ /* log_debug("result:\n");
+ log_mpidump("q =", q );
+ log_mpidump("u1=", u1);
+ log_mpidump("u2=", u2);
+ log_mpidump("u3=", u3);
+ log_mpidump("v1=", v1);
+ log_mpidump("v2=", v2); */
+ mpi_set(x, u1);
+
+ mpi_free(u1);
+ mpi_free(u2);
+ mpi_free(u3);
+ mpi_free(v1);
+ mpi_free(v2);
+ mpi_free(v3);
+ mpi_free(q);
+ mpi_free(t1);
+ mpi_free(t2);
+ mpi_free(t3);
+ mpi_free(u);
+ mpi_free(v);
+#elif 0
+ /* Extended Euclid's algorithm (See TAOCP Vol II, 4.5.2, Alg X)
+ * modified according to Michael Penk's solution for Exercise 35 */
+
+ /* FIXME: we can simplify this in most cases (see Knuth) */
+ gcry_mpi_t u, v, u1, u2, u3, v1, v2, v3, t1, t2, t3;
+ unsigned k;
+ int sign;
+
+ u = mpi_copy(a);
+ v = mpi_copy(n);
+ for(k=0; !mpi_test_bit(u,0) && !mpi_test_bit(v,0); k++ ) {
+ mpi_rshift(u, u, 1);
+ mpi_rshift(v, v, 1);
+ }
+
+
+ u1 = mpi_alloc_set_ui(1);
+ u2 = mpi_alloc_set_ui(0);
+ u3 = mpi_copy(u);
+ v1 = mpi_copy(v); /* !-- used as const 1 */
+ v2 = mpi_alloc( mpi_get_nlimbs(u) ); mpi_sub( v2, u1, u );
+ v3 = mpi_copy(v);
+ if( mpi_test_bit(u, 0) ) { /* u is odd */
+ t1 = mpi_alloc_set_ui(0);
+ t2 = mpi_alloc_set_ui(1); t2->sign = 1;
+ t3 = mpi_copy(v); t3->sign = !t3->sign;
+ goto Y4;
+ }
+ else {
+ t1 = mpi_alloc_set_ui(1);
+ t2 = mpi_alloc_set_ui(0);
+ t3 = mpi_copy(u);
+ }
+ do {
+ do {
+ if( mpi_test_bit(t1, 0) || mpi_test_bit(t2, 0) ) { /* one is odd */
+ mpi_add(t1, t1, v);
+ mpi_sub(t2, t2, u);
+ }
+ mpi_rshift(t1, t1, 1);
+ mpi_rshift(t2, t2, 1);
+ mpi_rshift(t3, t3, 1);
+ Y4:
+ ;
+ } while( !mpi_test_bit( t3, 0 ) ); /* while t3 is even */
+
+ if( !t3->sign ) {
+ mpi_set(u1, t1);
+ mpi_set(u2, t2);
+ mpi_set(u3, t3);
+ }
+ else {
+ mpi_sub(v1, v, t1);
+ sign = u->sign; u->sign = !u->sign;
+ mpi_sub(v2, u, t2);
+ u->sign = sign;
+ sign = t3->sign; t3->sign = !t3->sign;
+ mpi_set(v3, t3);
+ t3->sign = sign;
+ }
+ mpi_sub(t1, u1, v1);
+ mpi_sub(t2, u2, v2);
+ mpi_sub(t3, u3, v3);
+ if( t1->sign ) {
+ mpi_add(t1, t1, v);
+ mpi_sub(t2, t2, u);
+ }
+ } while( mpi_cmp_ui( t3, 0 ) ); /* while t3 != 0 */
+ /* mpi_lshift( u3, k ); */
+ mpi_set(x, u1);
+
+ mpi_free(u1);
+ mpi_free(u2);
+ mpi_free(u3);
+ mpi_free(v1);
+ mpi_free(v2);
+ mpi_free(v3);
+ mpi_free(t1);
+ mpi_free(t2);
+ mpi_free(t3);
+#else
+ /* Extended Euclid's algorithm (See TAOCP Vol II, 4.5.2, Alg X)
+ * modified according to Michael Penk's solution for Exercise 35
+ * with further enhancement */
+ gcry_mpi_t u, v, u1, u2=NULL, u3, v1, v2=NULL, v3, t1, t2=NULL, t3;
+ unsigned k;
+ int sign;
+ int odd ;
+
+ u = mpi_copy(a);
+ v = mpi_copy(n);
+
+ for(k=0; !mpi_test_bit(u,0) && !mpi_test_bit(v,0); k++ ) {
+ mpi_rshift(u, u, 1);
+ mpi_rshift(v, v, 1);
+ }
+ odd = mpi_test_bit(v,0);
+
+ u1 = mpi_alloc_set_ui(1);
+ if( !odd )
+ u2 = mpi_alloc_set_ui(0);
+ u3 = mpi_copy(u);
+ v1 = mpi_copy(v);
+ if( !odd ) {
+ v2 = mpi_alloc( mpi_get_nlimbs(u) );
+ mpi_sub( v2, u1, u ); /* U is used as const 1 */
+ }
+ v3 = mpi_copy(v);
+ if( mpi_test_bit(u, 0) ) { /* u is odd */
+ t1 = mpi_alloc_set_ui(0);
+ if( !odd ) {
+ t2 = mpi_alloc_set_ui(1); t2->sign = 1;
+ }
+ t3 = mpi_copy(v); t3->sign = !t3->sign;
+ goto Y4;
+ }
+ else {
+ t1 = mpi_alloc_set_ui(1);
+ if( !odd )
+ t2 = mpi_alloc_set_ui(0);
+ t3 = mpi_copy(u);
+ }
+ do {
+ do {
+ if( !odd ) {
+ if( mpi_test_bit(t1, 0) || mpi_test_bit(t2, 0) ) { /* one is odd */
+ mpi_add(t1, t1, v);
+ mpi_sub(t2, t2, u);
+ }
+ mpi_rshift(t1, t1, 1);
+ mpi_rshift(t2, t2, 1);
+ mpi_rshift(t3, t3, 1);
+ }
+ else {
+ if( mpi_test_bit(t1, 0) )
+ mpi_add(t1, t1, v);
+ mpi_rshift(t1, t1, 1);
+ mpi_rshift(t3, t3, 1);
+ }
+ Y4:
+ ;
+ } while( !mpi_test_bit( t3, 0 ) ); /* while t3 is even */
+
+ if( !t3->sign ) {
+ mpi_set(u1, t1);
+ if( !odd )
+ mpi_set(u2, t2);
+ mpi_set(u3, t3);
+ }
+ else {
+ mpi_sub(v1, v, t1);
+ sign = u->sign; u->sign = !u->sign;
+ if( !odd )
+ mpi_sub(v2, u, t2);
+ u->sign = sign;
+ sign = t3->sign; t3->sign = !t3->sign;
+ mpi_set(v3, t3);
+ t3->sign = sign;
+ }
+ mpi_sub(t1, u1, v1);
+ if( !odd )
+ mpi_sub(t2, u2, v2);
+ mpi_sub(t3, u3, v3);
+ if( t1->sign ) {
+ mpi_add(t1, t1, v);
+ if( !odd )
+ mpi_sub(t2, t2, u);
+ }
+ } while( mpi_cmp_ui( t3, 0 ) ); /* while t3 != 0 */
+ /* mpi_lshift( u3, k ); */
+ mpi_set(x, u1);
+
+ mpi_free(u1);
+ mpi_free(v1);
+ mpi_free(t1);
+ if( !odd ) {
+ mpi_free(u2);
+ mpi_free(v2);
+ mpi_free(t2);
+ }
+ mpi_free(u3);
+ mpi_free(v3);
+ mpi_free(t3);
+
+ mpi_free(u);
+ mpi_free(v);
+#endif
+ return 1;
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-mod.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-mod.c
new file mode 100644
index 0000000..6d9a6a3
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-mod.c
@@ -0,0 +1,186 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-mod.c - Modular reduction
+ Copyright (C) 1998, 1999, 2001, 2002, 2003,
+ 2007 Free Software Foundation, Inc.
+
+ This file is part of Libgcrypt.
+
+ Libgcrypt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Libgcrypt is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mpi-internal.h"
+#include "longlong.h"
+#include "g10lib.h"
+
+
+/* Context used with Barrett reduction. */
+struct barrett_ctx_s
+{
+ gcry_mpi_t m; /* The modulus - may not be modified. */
+ int m_copied; /* If true, M needs to be released. */
+ int k;
+ gcry_mpi_t y;
+ gcry_mpi_t r1; /* Helper MPI. */
+ gcry_mpi_t r2; /* Helper MPI. */
+ gcry_mpi_t r3; /* Helper MPI allocated on demand. */
+};
+
+
+
+void
+_gcry_mpi_mod (gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor)
+{
+ _gcry_mpi_fdiv_r (rem, dividend, divisor);
+ rem->sign = 0;
+}
+
+
+/* This function returns a new context for Barrett based operations on
+ the modulus M. This context needs to be released using
+ _gcry_mpi_barrett_free. If COPY is true M will be transferred to
+ the context and the user may change M. If COPY is false, M may not
+ be changed until gcry_mpi_barrett_free has been called. */
+mpi_barrett_t
+_gcry_mpi_barrett_init (gcry_mpi_t m, int copy)
+{
+ mpi_barrett_t ctx;
+ gcry_mpi_t tmp;
+
+ mpi_normalize (m);
+ ctx = gcry_xcalloc (1, sizeof *ctx);
+
+ if (copy)
+ {
+ ctx->m = mpi_copy (m);
+ ctx->m_copied = 1;
+ }
+ else
+ ctx->m = m;
+
+ ctx->k = mpi_get_nlimbs (m);
+ tmp = mpi_alloc (ctx->k + 1);
+
+ /* Barrett precalculation: y = floor(b^(2k) / m). */
+ mpi_set_ui (tmp, 1);
+ mpi_lshift_limbs (tmp, 2 * ctx->k);
+ mpi_fdiv_q (tmp, tmp, m);
+
+ ctx->y = tmp;
+ ctx->r1 = mpi_alloc ( 2 * ctx->k + 1 );
+ ctx->r2 = mpi_alloc ( 2 * ctx->k + 1 );
+
+ return ctx;
+}
+
+void
+_gcry_mpi_barrett_free (mpi_barrett_t ctx)
+{
+ if (ctx)
+ {
+ mpi_free (ctx->y);
+ mpi_free (ctx->r1);
+ mpi_free (ctx->r2);
+ if (ctx->r3)
+ mpi_free (ctx->r3);
+ if (ctx->m_copied)
+ mpi_free (ctx->m);
+ gcry_free (ctx);
+ }
+}
+
+
+/* R = X mod M
+
+ Using Barrett reduction. Before using this function
+ _gcry_mpi_barrett_init must have been called to do the
+ precalculations. CTX is the context created by this precalculation
+ and also conveys M. If the Barret reduction could no be done a
+ starightforward reduction method is used.
+
+ We assume that these conditions are met:
+ Input: x =(x_2k-1 ...x_0)_b
+ m =(m_k-1 ....m_0)_b with m_k-1 != 0
+ Output: r = x mod m
+ */
+void
+_gcry_mpi_mod_barrett (gcry_mpi_t r, gcry_mpi_t x, mpi_barrett_t ctx)
+{
+ gcry_mpi_t m = ctx->m;
+ int k = ctx->k;
+ gcry_mpi_t y = ctx->y;
+ gcry_mpi_t r1 = ctx->r1;
+ gcry_mpi_t r2 = ctx->r2;
+
+ mpi_normalize (x);
+ if (mpi_get_nlimbs (x) > 2*k )
+ {
+ mpi_mod (r, x, m);
+ return;
+ }
+
+ /* 1. q1 = floor( x / b^k-1)
+ * q2 = q1 * y
+ * q3 = floor( q2 / b^k+1 )
+ * Actually, we don't need qx, we can work direct on r2
+ */
+ mpi_set ( r2, x );
+ mpi_rshift_limbs ( r2, k-1 );
+ mpi_mul ( r2, r2, y );
+ mpi_rshift_limbs ( r2, k+1 );
+
+ /* 2. r1 = x mod b^k+1
+ * r2 = q3 * m mod b^k+1
+ * r = r1 - r2
+ * 3. if r < 0 then r = r + b^k+1
+ */
+ mpi_set ( r1, x );
+ if ( r1->nlimbs > k+1 ) /* Quick modulo operation. */
+ r1->nlimbs = k+1;
+ mpi_mul ( r2, r2, m );
+ if ( r2->nlimbs > k+1 ) /* Quick modulo operation. */
+ r2->nlimbs = k+1;
+ mpi_sub ( r, r1, r2 );
+
+ if ( mpi_is_neg( r ) )
+ {
+ if (!ctx->r3)
+ {
+ ctx->r3 = mpi_alloc ( k + 2 );
+ mpi_set_ui (ctx->r3, 1);
+ mpi_lshift_limbs (ctx->r3, k + 1 );
+ }
+ mpi_add ( r, r, ctx->r3 );
+ }
+
+ /* 4. while r >= m do r = r - m */
+ while ( mpi_cmp( r, m ) >= 0 )
+ mpi_sub ( r, r, m );
+
+}
+
+
+void
+_gcry_mpi_mul_barrett (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v,
+ mpi_barrett_t ctx)
+{
+ gcry_mpi_mul (w, u, v);
+ mpi_mod_barrett (w, w, ctx);
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-mpow.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-mpow.c
new file mode 100644
index 0000000..afef433
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-mpow.c
@@ -0,0 +1,225 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-mpow.c - MPI functions
+ * Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mpi-internal.h"
+#include "longlong.h"
+#include "g10lib.h"
+
+
+/* Barrett is slower than the classical way. It can be tweaked by
+ * using partial multiplications
+ */
+/*#define USE_BARRETT*/
+
+
+
+#ifdef USE_BARRETT
+static void barrett_mulm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m, gcry_mpi_t y, int k, gcry_mpi_t r1, gcry_mpi_t r2 );
+static gcry_mpi_t init_barrett( gcry_mpi_t m, int *k, gcry_mpi_t *r1, gcry_mpi_t *r2 );
+static int calc_barrett( gcry_mpi_t r, gcry_mpi_t x, gcry_mpi_t m, gcry_mpi_t y, int k, gcry_mpi_t r1, gcry_mpi_t r2 );
+#else
+#define barrett_mulm( w, u, v, m, y, k, r1, r2 ) gcry_mpi_mulm( (w), (u), (v), (m) )
+#endif
+
+
+static int
+build_index( gcry_mpi_t *exparray, int k, int i, int t )
+{
+ int j, bitno;
+ int idx = 0;
+
+ bitno = t-i;
+ for(j=k-1; j >= 0; j-- ) {
+ idx <<= 1;
+ if( mpi_test_bit( exparray[j], bitno ) )
+ idx |= 1;
+ }
+ /*log_debug("t=%d i=%d idx=%d\n", t, i, idx );*/
+ return idx;
+}
+
+/****************
+ * RES = (BASE[0] ^ EXP[0]) * (BASE[1] ^ EXP[1]) * ... * mod M
+ */
+void
+_gcry_mpi_mulpowm( gcry_mpi_t res, gcry_mpi_t *basearray, gcry_mpi_t *exparray, gcry_mpi_t m)
+{
+ int k; /* number of elements */
+ int t; /* bit size of largest exponent */
+ int i, j, idx;
+ gcry_mpi_t *G; /* table with precomputed values of size 2^k */
+ gcry_mpi_t tmp;
+#ifdef USE_BARRETT
+ gcry_mpi_t barrett_y, barrett_r1, barrett_r2;
+ int barrett_k;
+#endif
+
+ for(k=0; basearray[k]; k++ )
+ ;
+ gcry_assert(k);
+ for(t=0, i=0; (tmp=exparray[i]); i++ ) {
+ /*log_mpidump("exp: ", tmp );*/
+ j = mpi_get_nbits(tmp);
+ if( j > t )
+ t = j;
+ }
+ /*log_mpidump("mod: ", m );*/
+ gcry_assert (i==k);
+ gcry_assert (t);
+ gcry_assert (k < 10);
+
+ G = gcry_xcalloc( (1<<k) , sizeof *G );
+#ifdef USE_BARRETT
+ barrett_y = init_barrett( m, &barrett_k, &barrett_r1, &barrett_r2 );
+#endif
+ /* and calculate */
+ tmp = mpi_alloc( mpi_get_nlimbs(m)+1 );
+ mpi_set_ui( res, 1 );
+ for(i = 1; i <= t; i++ ) {
+ barrett_mulm(tmp, res, res, m, barrett_y, barrett_k,
+ barrett_r1, barrett_r2 );
+ idx = build_index( exparray, k, i, t );
+ gcry_assert (idx >= 0 && idx < (1<<k));
+ if( !G[idx] ) {
+ if( !idx )
+ G[0] = mpi_alloc_set_ui( 1 );
+ else {
+ for(j=0; j < k; j++ ) {
+ if( (idx & (1<<j) ) ) {
+ if( !G[idx] )
+ G[idx] = mpi_copy( basearray[j] );
+ else
+ barrett_mulm( G[idx], G[idx], basearray[j],
+ m, barrett_y, barrett_k, barrett_r1, barrett_r2 );
+ }
+ }
+ if( !G[idx] )
+ G[idx] = mpi_alloc(0);
+ }
+ }
+ barrett_mulm(res, tmp, G[idx], m, barrett_y, barrett_k, barrett_r1, barrett_r2 );
+ }
+
+ /* cleanup */
+ mpi_free(tmp);
+#ifdef USE_BARRETT
+ mpi_free(barrett_y);
+ mpi_free(barrett_r1);
+ mpi_free(barrett_r2);
+#endif
+ for(i=0; i < (1<<k); i++ )
+ mpi_free(G[i]);
+ gcry_free(G);
+}
+
+
+
+#ifdef USE_BARRETT
+static void
+barrett_mulm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m, gcry_mpi_t y, int k, gcry_mpi_t r1, gcry_mpi_t r2 )
+{
+ mpi_mul(w, u, v);
+ if( calc_barrett( w, w, m, y, k, r1, r2 ) )
+ mpi_fdiv_r( w, w, m );
+}
+
+/****************
+ * Barrett precalculation: y = floor(b^(2k) / m)
+ */
+static gcry_mpi_t
+init_barrett( gcry_mpi_t m, int *k, gcry_mpi_t *r1, gcry_mpi_t *r2 )
+{
+ gcry_mpi_t tmp;
+
+ mpi_normalize( m );
+ *k = mpi_get_nlimbs( m );
+ tmp = mpi_alloc( *k + 1 );
+ mpi_set_ui( tmp, 1 );
+ mpi_lshift_limbs( tmp, 2 * *k );
+ mpi_fdiv_q( tmp, tmp, m );
+ *r1 = mpi_alloc( 2* *k + 1 );
+ *r2 = mpi_alloc( 2* *k + 1 );
+ return tmp;
+}
+
+/****************
+ * Barrett reduction: We assume that these conditions are met:
+ * Given x =(x_2k-1 ...x_0)_b
+ * m =(m_k-1 ....m_0)_b with m_k-1 != 0
+ * Output r = x mod m
+ * Before using this function init_barret must be used to calucalte y and k.
+ * Returns: false = no error
+ * true = can't perform barret reduction
+ */
+static int
+calc_barrett( gcry_mpi_t r, gcry_mpi_t x, gcry_mpi_t m, gcry_mpi_t y, int k, gcry_mpi_t r1, gcry_mpi_t r2 )
+{
+ int xx = k > 3 ? k-3:0;
+
+ mpi_normalize( x );
+ if( mpi_get_nlimbs(x) > 2*k )
+ return 1; /* can't do it */
+
+ /* 1. q1 = floor( x / b^k-1)
+ * q2 = q1 * y
+ * q3 = floor( q2 / b^k+1 )
+ * Actually, we don't need qx, we can work direct on r2
+ */
+ mpi_set( r2, x );
+ mpi_rshift_limbs( r2, k-1 );
+ mpi_mul( r2, r2, y );
+ mpi_rshift_limbs( r2, k+1 );
+
+ /* 2. r1 = x mod b^k+1
+ * r2 = q3 * m mod b^k+1
+ * r = r1 - r2
+ * 3. if r < 0 then r = r + b^k+1
+ */
+ mpi_set( r1, x );
+ if( r1->nlimbs > k+1 ) /* quick modulo operation */
+ r1->nlimbs = k+1;
+ mpi_mul( r2, r2, m );
+ if( r2->nlimbs > k+1 ) /* quick modulo operation */
+ r2->nlimbs = k+1;
+ mpi_sub( r, r1, r2 );
+
+ if( mpi_is_neg( r ) ) {
+ gcry_mpi_t tmp;
+
+ tmp = mpi_alloc( k + 2 );
+ mpi_set_ui( tmp, 1 );
+ mpi_lshift_limbs( tmp, k+1 );
+ mpi_add( r, r, tmp );
+ mpi_free(tmp);
+ }
+
+ /* 4. while r >= m do r = r - m */
+ while( mpi_cmp( r, m ) >= 0 )
+ mpi_sub( r, r, m );
+
+ return 0;
+}
+#endif /* USE_BARRETT */
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-mul.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-mul.c
new file mode 100644
index 0000000..d305547
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-mul.c
@@ -0,0 +1,214 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-mul.c - MPI functions
+ * Copyright (C) 1994, 1996, 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+
+void
+gcry_mpi_mul_ui( gcry_mpi_t prod, gcry_mpi_t mult, unsigned long small_mult )
+{
+ mpi_size_t size, prod_size;
+ mpi_ptr_t prod_ptr;
+ mpi_limb_t cy;
+ int sign;
+
+ size = mult->nlimbs;
+ sign = mult->sign;
+
+ if( !size || !small_mult ) {
+ prod->nlimbs = 0;
+ prod->sign = 0;
+ return;
+ }
+
+ prod_size = size + 1;
+ if( prod->alloced < prod_size )
+ mpi_resize( prod, prod_size );
+ prod_ptr = prod->d;
+
+ cy = _gcry_mpih_mul_1( prod_ptr, mult->d, size, (mpi_limb_t)small_mult );
+ if( cy )
+ prod_ptr[size++] = cy;
+ prod->nlimbs = size;
+ prod->sign = sign;
+}
+
+
+void
+gcry_mpi_mul_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt)
+{
+ mpi_size_t usize, wsize, limb_cnt;
+ mpi_ptr_t wp;
+ mpi_limb_t wlimb;
+ int usign, wsign;
+
+ usize = u->nlimbs;
+ usign = u->sign;
+
+ if( !usize ) {
+ w->nlimbs = 0;
+ w->sign = 0;
+ return;
+ }
+
+ limb_cnt = cnt / BITS_PER_MPI_LIMB;
+ wsize = usize + limb_cnt + 1;
+ if( w->alloced < wsize )
+ mpi_resize(w, wsize );
+ wp = w->d;
+ wsize = usize + limb_cnt;
+ wsign = usign;
+
+ cnt %= BITS_PER_MPI_LIMB;
+ if( cnt ) {
+ wlimb = _gcry_mpih_lshift( wp + limb_cnt, u->d, usize, cnt );
+ if( wlimb ) {
+ wp[wsize] = wlimb;
+ wsize++;
+ }
+ }
+ else {
+ MPN_COPY_DECR( wp + limb_cnt, u->d, usize );
+ }
+
+ /* Zero all whole limbs at low end. Do it here and not before calling
+ * mpn_lshift, not to lose for U == W. */
+ MPN_ZERO( wp, limb_cnt );
+
+ w->nlimbs = wsize;
+ w->sign = wsign;
+}
+
+
+void
+gcry_mpi_mul( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ mpi_size_t usize, vsize, wsize;
+ mpi_ptr_t up, vp, wp;
+ mpi_limb_t cy;
+ int usign, vsign, usecure, vsecure, sign_product;
+ int assign_wp=0;
+ mpi_ptr_t tmp_limb=NULL;
+ unsigned int tmp_limb_nlimbs = 0;
+
+ if( u->nlimbs < v->nlimbs ) { /* Swap U and V. */
+ usize = v->nlimbs;
+ usign = v->sign;
+ usecure = mpi_is_secure(v);
+ up = v->d;
+ vsize = u->nlimbs;
+ vsign = u->sign;
+ vsecure = mpi_is_secure(u);
+ vp = u->d;
+ }
+ else {
+ usize = u->nlimbs;
+ usign = u->sign;
+ usecure = mpi_is_secure(u);
+ up = u->d;
+ vsize = v->nlimbs;
+ vsign = v->sign;
+ vsecure = mpi_is_secure(v);
+ vp = v->d;
+ }
+ sign_product = usign ^ vsign;
+ wp = w->d;
+
+ /* Ensure W has space enough to store the result. */
+ wsize = usize + vsize;
+ if ( !mpi_is_secure (w) && (mpi_is_secure (u) || mpi_is_secure (v)) ) {
+ /* w is not allocated in secure space but u or v is. To make sure
+ * that no temporray results are stored in w, we temporary use
+ * a newly allocated limb space for w */
+ wp = mpi_alloc_limb_space( wsize, 1 );
+ assign_wp = 2; /* mark it as 2 so that we can later copy it back to
+ * mormal memory */
+ }
+ else if( w->alloced < wsize ) {
+ if( wp == up || wp == vp ) {
+ wp = mpi_alloc_limb_space( wsize, mpi_is_secure(w) );
+ assign_wp = 1;
+ }
+ else {
+ mpi_resize(w, wsize );
+ wp = w->d;
+ }
+ }
+ else { /* Make U and V not overlap with W. */
+ if( wp == up ) {
+ /* W and U are identical. Allocate temporary space for U. */
+ tmp_limb_nlimbs = usize;
+ up = tmp_limb = mpi_alloc_limb_space( usize, usecure );
+ /* Is V identical too? Keep it identical with U. */
+ if( wp == vp )
+ vp = up;
+ /* Copy to the temporary space. */
+ MPN_COPY( up, wp, usize );
+ }
+ else if( wp == vp ) {
+ /* W and V are identical. Allocate temporary space for V. */
+ tmp_limb_nlimbs = vsize;
+ vp = tmp_limb = mpi_alloc_limb_space( vsize, vsecure );
+ /* Copy to the temporary space. */
+ MPN_COPY( vp, wp, vsize );
+ }
+ }
+
+ if( !vsize )
+ wsize = 0;
+ else {
+ cy = _gcry_mpih_mul( wp, up, usize, vp, vsize );
+ wsize -= cy? 0:1;
+ }
+
+ if( assign_wp ) {
+ if (assign_wp == 2) {
+ /* copy the temp wp from secure memory back to normal memory */
+ mpi_ptr_t tmp_wp = mpi_alloc_limb_space (wsize, 0);
+ MPN_COPY (tmp_wp, wp, wsize);
+ _gcry_mpi_free_limb_space (wp, 0);
+ wp = tmp_wp;
+ }
+ _gcry_mpi_assign_limb_space( w, wp, wsize );
+ }
+ w->nlimbs = wsize;
+ w->sign = sign_product;
+ if( tmp_limb )
+ _gcry_mpi_free_limb_space (tmp_limb, tmp_limb_nlimbs);
+}
+
+
+void
+gcry_mpi_mulm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ gcry_mpi_mul(w, u, v);
+ _gcry_mpi_fdiv_r( w, w, m );
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpi-pow.c b/grub-core/lib/libgcrypt-grub/mpi/mpi-pow.c
new file mode 100644
index 0000000..f6b3f58
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpi-pow.c
@@ -0,0 +1,340 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpi-pow.c - MPI functions for exponentiation
+ * Copyright (C) 1994, 1996, 1998, 2000, 2002
+ * 2003 Free Software Foundation, Inc.
+ * 2013 g10 Code GmbH
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+/****************
+ * RES = BASE ^ EXPO mod MOD
+ */
+void
+gcry_mpi_powm (gcry_mpi_t res,
+ gcry_mpi_t base, gcry_mpi_t expo, gcry_mpi_t mod)
+{
+ /* Pointer to the limbs of the arguments, their size and signs. */
+ mpi_ptr_t rp, ep, mp, bp;
+ mpi_size_t esize, msize, bsize, rsize;
+ int msign, bsign, rsign;
+ /* Flags telling the secure allocation status of the arguments. */
+ int esec, msec, bsec;
+ /* Size of the result including space for temporary values. */
+ mpi_size_t size;
+ /* Helper. */
+ int mod_shift_cnt;
+ int negative_result;
+ mpi_ptr_t mp_marker = NULL;
+ mpi_ptr_t bp_marker = NULL;
+ mpi_ptr_t ep_marker = NULL;
+ mpi_ptr_t xp_marker = NULL;
+ unsigned int mp_nlimbs = 0;
+ unsigned int bp_nlimbs = 0;
+ unsigned int ep_nlimbs = 0;
+ unsigned int xp_nlimbs = 0;
+ mpi_ptr_t tspace = NULL;
+ mpi_size_t tsize = 0;
+
+
+ esize = expo->nlimbs;
+ msize = mod->nlimbs;
+ size = 2 * msize;
+ msign = mod->sign;
+
+ esec = mpi_is_secure(expo);
+ msec = mpi_is_secure(mod);
+ bsec = mpi_is_secure(base);
+
+ rp = res->d;
+ ep = expo->d;
+
+ if (!msize)
+ grub_fatal ("mpi division by zero");
+
+ if (!esize)
+ {
+ /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 depending
+ on if MOD equals 1. */
+ res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1;
+ if (res->nlimbs)
+ {
+ RESIZE_IF_NEEDED (res, 1);
+ rp = res->d;
+ rp[0] = 1;
+ }
+ res->sign = 0;
+ goto leave;
+ }
+
+ /* Normalize MOD (i.e. make its most significant bit set) as
+ required by mpn_divrem. This will make the intermediate values
+ in the calculation slightly larger, but the correct result is
+ obtained after a final reduction using the original MOD value. */
+ mp_nlimbs = msec? msize:0;
+ mp = mp_marker = mpi_alloc_limb_space(msize, msec);
+ count_leading_zeros (mod_shift_cnt, mod->d[msize-1]);
+ if (mod_shift_cnt)
+ _gcry_mpih_lshift (mp, mod->d, msize, mod_shift_cnt);
+ else
+ MPN_COPY( mp, mod->d, msize );
+
+ bsize = base->nlimbs;
+ bsign = base->sign;
+ if (bsize > msize)
+ {
+ /* The base is larger than the module. Reduce it.
+
+ Allocate (BSIZE + 1) with space for remainder and quotient.
+ (The quotient is (bsize - msize + 1) limbs.) */
+ bp_nlimbs = bsec ? (bsize + 1):0;
+ bp = bp_marker = mpi_alloc_limb_space( bsize + 1, bsec );
+ MPN_COPY ( bp, base->d, bsize );
+ /* We don't care about the quotient, store it above the
+ * remainder, at BP + MSIZE. */
+ _gcry_mpih_divrem( bp + msize, 0, bp, bsize, mp, msize );
+ bsize = msize;
+ /* Canonicalize the base, since we are going to multiply with it
+ quite a few times. */
+ MPN_NORMALIZE( bp, bsize );
+ }
+ else
+ bp = base->d;
+
+ if (!bsize)
+ {
+ res->nlimbs = 0;
+ res->sign = 0;
+ goto leave;
+ }
+
+
+ /* Make BASE, EXPO and MOD not overlap with RES. */
+ if ( rp == bp )
+ {
+ /* RES and BASE are identical. Allocate temp. space for BASE. */
+ gcry_assert (!bp_marker);
+ bp_nlimbs = bsec? bsize:0;
+ bp = bp_marker = mpi_alloc_limb_space( bsize, bsec );
+ MPN_COPY(bp, rp, bsize);
+ }
+ if ( rp == ep )
+ {
+ /* RES and EXPO are identical. Allocate temp. space for EXPO. */
+ ep_nlimbs = esec? esize:0;
+ ep = ep_marker = mpi_alloc_limb_space( esize, esec );
+ MPN_COPY(ep, rp, esize);
+ }
+ if ( rp == mp )
+ {
+ /* RES and MOD are identical. Allocate temporary space for MOD.*/
+ gcry_assert (!mp_marker);
+ mp_nlimbs = msec?msize:0;
+ mp = mp_marker = mpi_alloc_limb_space( msize, msec );
+ MPN_COPY(mp, rp, msize);
+ }
+
+ /* Copy base to the result. */
+ if (res->alloced < size)
+ {
+ mpi_resize (res, size);
+ rp = res->d;
+ }
+ MPN_COPY ( rp, bp, bsize );
+ rsize = bsize;
+ rsign = bsign;
+
+ /* Main processing. */
+ {
+ mpi_size_t i;
+ mpi_ptr_t xp;
+ int c;
+ mpi_limb_t e;
+ mpi_limb_t carry_limb;
+ struct karatsuba_ctx karactx;
+
+ xp_nlimbs = msec? (2 * (msize + 1)):0;
+ xp = xp_marker = mpi_alloc_limb_space( 2 * (msize + 1), msec );
+
+ memset( &karactx, 0, sizeof karactx );
+ negative_result = (ep[0] & 1) && base->sign;
+
+ i = esize - 1;
+ e = ep[i];
+ count_leading_zeros (c, e);
+ e = (e << c) << 1; /* Shift the expo bits to the left, lose msb. */
+ c = BITS_PER_MPI_LIMB - 1 - c;
+
+ /* Main loop.
+
+ Make the result be pointed to alternately by XP and RP. This
+ helps us avoid block copying, which would otherwise be
+ necessary with the overlap restrictions of
+ _gcry_mpih_divmod. With 50% probability the result after this
+ loop will be in the area originally pointed by RP (==RES->d),
+ and with 50% probability in the area originally pointed to by XP. */
+ for (;;)
+ {
+ while (c)
+ {
+ mpi_ptr_t tp;
+ mpi_size_t xsize;
+
+ /*mpih_mul_n(xp, rp, rp, rsize);*/
+ if ( rsize < KARATSUBA_THRESHOLD )
+ _gcry_mpih_sqr_n_basecase( xp, rp, rsize );
+ else
+ {
+ if ( !tspace )
+ {
+ tsize = 2 * rsize;
+ tspace = mpi_alloc_limb_space( tsize, 0 );
+ }
+ else if ( tsize < (2*rsize) )
+ {
+ _gcry_mpi_free_limb_space (tspace, 0);
+ tsize = 2 * rsize;
+ tspace = mpi_alloc_limb_space (tsize, 0 );
+ }
+ _gcry_mpih_sqr_n (xp, rp, rsize, tspace);
+ }
+
+ xsize = 2 * rsize;
+ if ( xsize > msize )
+ {
+ _gcry_mpih_divrem(xp + msize, 0, xp, xsize, mp, msize);
+ xsize = msize;
+ }
+
+ tp = rp; rp = xp; xp = tp;
+ rsize = xsize;
+
+ /* To mitigate the Yarom/Falkner flush+reload cache
+ * side-channel attack on the RSA secret exponent, we do
+ * the multiplication regardless of the value of the
+ * high-bit of E. But to avoid this performance penalty
+ * we do it only if the exponent has been stored in secure
+ * memory and we can thus assume it is a secret exponent. */
+ if (esec || (mpi_limb_signed_t)e < 0)
+ {
+ /*mpih_mul( xp, rp, rsize, bp, bsize );*/
+ if( bsize < KARATSUBA_THRESHOLD )
+ _gcry_mpih_mul ( xp, rp, rsize, bp, bsize );
+ else
+ _gcry_mpih_mul_karatsuba_case (xp, rp, rsize, bp, bsize,
+ &karactx);
+
+ xsize = rsize + bsize;
+ if ( xsize > msize )
+ {
+ _gcry_mpih_divrem(xp + msize, 0, xp, xsize, mp, msize);
+ xsize = msize;
+ }
+ }
+ if ( (mpi_limb_signed_t)e < 0 )
+ {
+ tp = rp; rp = xp; xp = tp;
+ rsize = xsize;
+ }
+ e <<= 1;
+ c--;
+ }
+
+ i--;
+ if ( i < 0 )
+ break;
+ e = ep[i];
+ c = BITS_PER_MPI_LIMB;
+ }
+
+ /* We shifted MOD, the modulo reduction argument, left
+ MOD_SHIFT_CNT steps. Adjust the result by reducing it with the
+ original MOD.
+
+ Also make sure the result is put in RES->d (where it already
+ might be, see above). */
+ if ( mod_shift_cnt )
+ {
+ carry_limb = _gcry_mpih_lshift( res->d, rp, rsize, mod_shift_cnt);
+ rp = res->d;
+ if ( carry_limb )
+ {
+ rp[rsize] = carry_limb;
+ rsize++;
+ }
+ }
+ else if (res->d != rp)
+ {
+ MPN_COPY (res->d, rp, rsize);
+ rp = res->d;
+ }
+
+ if ( rsize >= msize )
+ {
+ _gcry_mpih_divrem(rp + msize, 0, rp, rsize, mp, msize);
+ rsize = msize;
+ }
+
+ /* Remove any leading zero words from the result. */
+ if ( mod_shift_cnt )
+ _gcry_mpih_rshift( rp, rp, rsize, mod_shift_cnt);
+ MPN_NORMALIZE (rp, rsize);
+
+ _gcry_mpih_release_karatsuba_ctx (&karactx );
+ }
+
+ /* Fixup for negative results. */
+ if ( negative_result && rsize )
+ {
+ if ( mod_shift_cnt )
+ _gcry_mpih_rshift( mp, mp, msize, mod_shift_cnt);
+ _gcry_mpih_sub( rp, mp, msize, rp, rsize);
+ rsize = msize;
+ rsign = msign;
+ MPN_NORMALIZE(rp, rsize);
+ }
+ gcry_assert (res->d == rp);
+ res->nlimbs = rsize;
+ res->sign = rsign;
+
+ leave:
+ if (mp_marker)
+ _gcry_mpi_free_limb_space( mp_marker, mp_nlimbs );
+ if (bp_marker)
+ _gcry_mpi_free_limb_space( bp_marker, bp_nlimbs );
+ if (ep_marker)
+ _gcry_mpi_free_limb_space( ep_marker, ep_nlimbs );
+ if (xp_marker)
+ _gcry_mpi_free_limb_space( xp_marker, xp_nlimbs );
+ if (tspace)
+ _gcry_mpi_free_limb_space( tspace, 0 );
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpicoder.c b/grub-core/lib/libgcrypt-grub/mpi/mpicoder.c
new file mode 100644
index 0000000..e734dcf
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpicoder.c
@@ -0,0 +1,755 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpicoder.c - Coder for the external representation of MPIs
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+ * 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "mpi-internal.h"
+#include "g10lib.h"
+
+#define MAX_EXTERN_MPI_BITS 16384
+
+/* Helper used to scan PGP style MPIs. Returns NULL on failure. */
+static gcry_mpi_t
+mpi_read_from_buffer (const unsigned char *buffer, unsigned *ret_nread,
+ int secure)
+{
+ int i, j;
+ unsigned int nbits, nbytes, nlimbs, nread=0;
+ mpi_limb_t a;
+ gcry_mpi_t val = MPI_NULL;
+
+ if ( *ret_nread < 2 )
+ goto leave;
+ nbits = buffer[0] << 8 | buffer[1];
+ if ( nbits > MAX_EXTERN_MPI_BITS )
+ {
+/* log_debug ("mpi too large (%u bits)\n", nbits); */
+ goto leave;
+ }
+ buffer += 2;
+ nread = 2;
+
+ nbytes = (nbits+7) / 8;
+ nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
+ val = secure? mpi_alloc_secure (nlimbs) : mpi_alloc (nlimbs);
+ i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
+ i %= BYTES_PER_MPI_LIMB;
+ j= val->nlimbs = nlimbs;
+ val->sign = 0;
+ for ( ; j > 0; j-- )
+ {
+ a = 0;
+ for (; i < BYTES_PER_MPI_LIMB; i++ )
+ {
+ if ( ++nread > *ret_nread )
+ {
+/* log_debug ("mpi larger than buffer"); */
+ mpi_free (val);
+ val = NULL;
+ goto leave;
+ }
+ a <<= 8;
+ a |= *buffer++;
+ }
+ i = 0;
+ val->d[j-1] = a;
+ }
+
+ leave:
+ *ret_nread = nread;
+ return val;
+}
+
+
+/****************
+ * Fill the mpi VAL from the hex string in STR.
+ */
+static int
+mpi_fromstr (gcry_mpi_t val, const char *str)
+{
+ int sign = 0;
+ int prepend_zero = 0;
+ int i, j, c, c1, c2;
+ unsigned int nbits, nbytes, nlimbs;
+ mpi_limb_t a;
+
+ if ( *str == '-' )
+ {
+ sign = 1;
+ str++;
+ }
+
+ /* Skip optional hex prefix. */
+ if ( *str == '0' && str[1] == 'x' )
+ str += 2;
+
+ nbits = 4 * strlen (str);
+ if ((nbits % 8))
+ prepend_zero = 1;
+
+ nbytes = (nbits+7) / 8;
+ nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
+
+ if ( val->alloced < nlimbs )
+ mpi_resize (val, nlimbs);
+
+ i = BYTES_PER_MPI_LIMB - (nbytes % BYTES_PER_MPI_LIMB);
+ i %= BYTES_PER_MPI_LIMB;
+ j = val->nlimbs = nlimbs;
+ val->sign = sign;
+ for (; j > 0; j--)
+ {
+ a = 0;
+ for (; i < BYTES_PER_MPI_LIMB; i++)
+ {
+ if (prepend_zero)
+ {
+ c1 = '0';
+ prepend_zero = 0;
+ }
+ else
+ c1 = *str++;
+
+ if (!c1)
+ {
+ mpi_clear (val);
+ return 1; /* Error. */
+ }
+ c2 = *str++;
+ if (!c2)
+ {
+ mpi_clear (val);
+ return 1; /* Error. */
+ }
+ if ( c1 >= '0' && c1 <= '9' )
+ c = c1 - '0';
+ else if ( c1 >= 'a' && c1 <= 'f' )
+ c = c1 - 'a' + 10;
+ else if ( c1 >= 'A' && c1 <= 'F' )
+ c = c1 - 'A' + 10;
+ else
+ {
+ mpi_clear (val);
+ return 1; /* Error. */
+ }
+ c <<= 4;
+ if ( c2 >= '0' && c2 <= '9' )
+ c |= c2 - '0';
+ else if( c2 >= 'a' && c2 <= 'f' )
+ c |= c2 - 'a' + 10;
+ else if( c2 >= 'A' && c2 <= 'F' )
+ c |= c2 - 'A' + 10;
+ else
+ {
+ mpi_clear(val);
+ return 1; /* Error. */
+ }
+ a <<= 8;
+ a |= c;
+ }
+ i = 0;
+ val->d[j-1] = a;
+ }
+
+ return 0; /* Okay. */
+}
+
+
+/* Dump the value of A in a format suitable for debugging to
+ Libgcrypt's logging stream. Note that one leading space but no
+ trailing space or linefeed will be printed. It is okay to pass
+ NULL for A. */
+void
+gcry_mpi_dump (const gcry_mpi_t a)
+{
+ int i;
+
+ log_printf (" ");
+ if (!a)
+ log_printf ("[MPI_NULL]");
+ else
+ {
+ if (a->sign)
+ log_printf ( "-");
+#if BYTES_PER_MPI_LIMB == 2
+# define X "4"
+#elif BYTES_PER_MPI_LIMB == 4
+# define X "8"
+#elif BYTES_PER_MPI_LIMB == 8
+# define X "16"
+#elif BYTES_PER_MPI_LIMB == 16
+# define X "32"
+#else
+# error please define the format here
+#endif
+ for (i=a->nlimbs; i > 0 ; i-- )
+ {
+ log_printf (i != a->nlimbs? "%0" X "lX":"%lX", (ulong)a->d[i-1]);
+ }
+#undef X
+ if (!a->nlimbs)
+ log_printf ("0");
+ }
+}
+
+/* Convience function used internally. */
+void
+_gcry_log_mpidump (const char *text, gcry_mpi_t a)
+{
+ log_printf ("%s:", text);
+ gcry_mpi_dump (a);
+ log_printf ("\n");
+}
+
+
+/* Return an allocated buffer with the MPI (msb first). NBYTES
+ receives the length of this buffer. Caller must free the return
+ string. This function returns an allocated buffer with NBYTES set
+ to zero if the value of A is zero. If sign is not NULL, it will be
+ set to the sign of the A. On error NULL is returned and ERRNO set
+ appropriately. */
+static unsigned char *
+do_get_buffer (gcry_mpi_t a, unsigned int *nbytes, int *sign, int force_secure)
+{
+ unsigned char *p, *buffer;
+ mpi_limb_t alimb;
+ int i;
+ size_t n;
+
+ if (sign)
+ *sign = a->sign;
+
+ *nbytes = a->nlimbs * BYTES_PER_MPI_LIMB;
+ n = *nbytes? *nbytes:1; /* Allocate at least one byte. */
+ p = buffer = (force_secure || mpi_is_secure(a))? gcry_malloc_secure (n)
+ : gcry_malloc (n);
+ if (!buffer)
+ return NULL;
+
+ for (i=a->nlimbs-1; i >= 0; i--)
+ {
+ alimb = a->d[i];
+#if BYTES_PER_MPI_LIMB == 4
+ *p++ = alimb >> 24;
+ *p++ = alimb >> 16;
+ *p++ = alimb >> 8;
+ *p++ = alimb ;
+#elif BYTES_PER_MPI_LIMB == 8
+ *p++ = alimb >> 56;
+ *p++ = alimb >> 48;
+ *p++ = alimb >> 40;
+ *p++ = alimb >> 32;
+ *p++ = alimb >> 24;
+ *p++ = alimb >> 16;
+ *p++ = alimb >> 8;
+ *p++ = alimb ;
+#else
+# error please implement for this limb size.
+#endif
+ }
+
+ /* This is sub-optimal but we need to do the shift operation because
+ the caller has to free the returned buffer. */
+ for (p=buffer; *nbytes && !*p; p++, --*nbytes)
+ ;
+ if (p != buffer)
+ memmove (buffer,p, *nbytes);
+ return buffer;
+}
+
+
+byte *
+_gcry_mpi_get_buffer (gcry_mpi_t a, unsigned int *nbytes, int *sign)
+{
+ return do_get_buffer (a, nbytes, sign, 0);
+}
+
+byte *
+_gcry_mpi_get_secure_buffer (gcry_mpi_t a, unsigned *nbytes, int *sign)
+{
+ return do_get_buffer (a, nbytes, sign, 1);
+}
+
+
+/*
+ * Use the NBYTES at BUFFER_ARG to update A. Set the sign of a to
+ * SIGN.
+ */
+void
+_gcry_mpi_set_buffer (gcry_mpi_t a, const void *buffer_arg,
+ unsigned int nbytes, int sign)
+{
+ const unsigned char *buffer = (const unsigned char*)buffer_arg;
+ const unsigned char *p;
+ mpi_limb_t alimb;
+ int nlimbs;
+ int i;
+
+ nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
+ RESIZE_IF_NEEDED(a, nlimbs);
+ a->sign = sign;
+
+ for (i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; )
+ {
+#if BYTES_PER_MPI_LIMB == 4
+ alimb = *p-- ;
+ alimb |= *p-- << 8 ;
+ alimb |= *p-- << 16 ;
+ alimb |= *p-- << 24 ;
+#elif BYTES_PER_MPI_LIMB == 8
+ alimb = (mpi_limb_t)*p-- ;
+ alimb |= (mpi_limb_t)*p-- << 8 ;
+ alimb |= (mpi_limb_t)*p-- << 16 ;
+ alimb |= (mpi_limb_t)*p-- << 24 ;
+ alimb |= (mpi_limb_t)*p-- << 32 ;
+ alimb |= (mpi_limb_t)*p-- << 40 ;
+ alimb |= (mpi_limb_t)*p-- << 48 ;
+ alimb |= (mpi_limb_t)*p-- << 56 ;
+#else
+# error please implement for this limb size.
+#endif
+ a->d[i++] = alimb;
+ }
+ if ( p >= buffer )
+ {
+#if BYTES_PER_MPI_LIMB == 4
+ alimb = *p--;
+ if (p >= buffer)
+ alimb |= *p-- << 8;
+ if (p >= buffer)
+ alimb |= *p-- << 16;
+ if (p >= buffer)
+ alimb |= *p-- << 24;
+#elif BYTES_PER_MPI_LIMB == 8
+ alimb = (mpi_limb_t)*p--;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 8;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 16;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 24;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 32;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 40;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 48;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 56;
+#else
+# error please implement for this limb size.
+#endif
+ a->d[i++] = alimb;
+ }
+ a->nlimbs = i;
+ gcry_assert (i == nlimbs);
+}
+
+
+/* Convert the external representation of an integer stored in BUFFER
+ with a length of BUFLEN into a newly create MPI returned in
+ RET_MPI. If NBYTES is not NULL, it will receive the number of
+ bytes actually scanned after a successful operation. */
+gcry_error_t
+gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
+ const void *buffer_arg, size_t buflen, size_t *nscanned)
+{
+ const unsigned char *buffer = (const unsigned char*)buffer_arg;
+ struct gcry_mpi *a = NULL;
+ unsigned int len;
+ int secure = (buffer && gcry_is_secure (buffer));
+
+ if (!buffer)
+ return gcry_error (GPG_ERR_INV_ARG);
+
+ if (format == GCRYMPI_FMT_SSH)
+ len = 0;
+ else
+ len = buflen;
+
+ if (format == GCRYMPI_FMT_STD)
+ {
+ const unsigned char *s = buffer;
+
+ a = secure? mpi_alloc_secure ((len+BYTES_PER_MPI_LIMB-1)
+ /BYTES_PER_MPI_LIMB)
+ : mpi_alloc ((len+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
+ if (len)
+ {
+ a->sign = !!(*s & 0x80);
+ if (a->sign)
+ {
+ /* FIXME: we have to convert from 2compl to magnitude format */
+ mpi_free (a);
+ return gcry_error (GPG_ERR_INTERNAL);
+ }
+ else
+ _gcry_mpi_set_buffer (a, s, len, 0);
+ }
+ if (ret_mpi)
+ {
+ mpi_normalize ( a );
+ *ret_mpi = a;
+ }
+ else
+ mpi_free(a);
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_USG)
+ {
+ a = secure? mpi_alloc_secure ((len+BYTES_PER_MPI_LIMB-1)
+ /BYTES_PER_MPI_LIMB)
+ : mpi_alloc ((len+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
+
+ if (len)
+ _gcry_mpi_set_buffer (a, buffer, len, 0);
+ if (ret_mpi)
+ {
+ mpi_normalize ( a );
+ *ret_mpi = a;
+ }
+ else
+ mpi_free(a);
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_PGP)
+ {
+ a = mpi_read_from_buffer (buffer, &len, secure);
+ if (nscanned)
+ *nscanned = len;
+ if (ret_mpi && a)
+ {
+ mpi_normalize (a);
+ *ret_mpi = a;
+ }
+ else if (a)
+ {
+ mpi_free(a);
+ a = NULL;
+ }
+ return a? 0 : gcry_error (GPG_ERR_INV_OBJ);
+ }
+ else if (format == GCRYMPI_FMT_SSH)
+ {
+ const unsigned char *s = buffer;
+ size_t n;
+
+ /* This test is not strictly necessary and an assert (!len)
+ would be sufficient. We keep this test in case we later
+ allow the BUFLEN argument to act as a sanitiy check. Same
+ below. */
+ if (len && len < 4)
+ return gcry_error (GPG_ERR_TOO_SHORT);
+
+ n = ((size_t)s[0] << 24 | (size_t)s[1] << 16 | (size_t)s[2] << 8 | (size_t)s[3]);
+ s += 4;
+ if (len)
+ len -= 4;
+ if (len && n > len)
+ return gcry_error (GPG_ERR_TOO_LARGE);
+
+ a = secure? mpi_alloc_secure ((n+BYTES_PER_MPI_LIMB-1)
+ /BYTES_PER_MPI_LIMB)
+ : mpi_alloc ((n+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
+ if (n)
+ {
+ a->sign = !!(*s & 0x80);
+ if (a->sign)
+ {
+ /* FIXME: we have to convert from 2compl to magnitude format */
+ mpi_free(a);
+ return gcry_error (GPG_ERR_INTERNAL);
+ }
+ else
+ _gcry_mpi_set_buffer( a, s, n, 0 );
+ }
+ if (nscanned)
+ *nscanned = n+4;
+ if (ret_mpi)
+ {
+ mpi_normalize ( a );
+ *ret_mpi = a;
+ }
+ else
+ mpi_free(a);
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_HEX)
+ {
+ /* We can only handle C strings for now. */
+ if (buflen)
+ return gcry_error (GPG_ERR_INV_ARG);
+
+ a = secure? mpi_alloc_secure (0) : mpi_alloc(0);
+ if (mpi_fromstr (a, (const char *)buffer))
+ {
+ mpi_free (a);
+ return gcry_error (GPG_ERR_INV_OBJ);
+ }
+ if (ret_mpi)
+ {
+ mpi_normalize ( a );
+ *ret_mpi = a;
+ }
+ else
+ mpi_free(a);
+ return 0;
+ }
+ else
+ return gcry_error (GPG_ERR_INV_ARG);
+}
+
+
+/* Convert the big integer A into the external representation
+ described by FORMAT and store it in the provided BUFFER which has
+ been allocated by the user with a size of BUFLEN bytes. NWRITTEN
+ receives the actual length of the external representation unless it
+ has been passed as NULL. BUFFER may be NULL to query the required
+ length. */
+gcry_error_t
+gcry_mpi_print (enum gcry_mpi_format format,
+ unsigned char *buffer, size_t buflen,
+ size_t *nwritten, struct gcry_mpi *a)
+{
+ unsigned int nbits = mpi_get_nbits (a);
+ size_t len;
+ size_t dummy_nwritten;
+
+ if (!nwritten)
+ nwritten = &dummy_nwritten;
+
+ len = buflen;
+ *nwritten = 0;
+ if (format == GCRYMPI_FMT_STD)
+ {
+ unsigned char *tmp;
+ int extra = 0;
+ unsigned int n;
+
+ if (a->sign)
+ return gcry_error (GPG_ERR_INTERNAL); /* Can't handle it yet. */
+
+ tmp = _gcry_mpi_get_buffer (a, &n, NULL);
+ if (!tmp)
+ return gpg_error_from_syserror ();
+ if (n && (*tmp & 0x80))
+ {
+ n++;
+ extra=1;
+ }
+
+ if (buffer && n > len)
+ {
+ /* The provided buffer is too short. */
+ gcry_free (tmp);
+ return gcry_error (GPG_ERR_TOO_SHORT);
+ }
+ if (buffer)
+ {
+ unsigned char *s = buffer;
+
+ if (extra)
+ *s++ = 0;
+ memcpy (s, tmp, n-extra);
+ }
+ gcry_free(tmp);
+ *nwritten = n;
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_USG)
+ {
+ unsigned int n = (nbits + 7)/8;
+
+ /* Note: We ignore the sign for this format. */
+ /* FIXME: for performance reasons we should put this into
+ mpi_aprint because we can then use the buffer directly. */
+ if (buffer && n > len)
+ return gcry_error (GPG_ERR_TOO_SHORT);
+ if (buffer)
+ {
+ unsigned char *tmp;
+
+ tmp = _gcry_mpi_get_buffer (a, &n, NULL);
+ if (!tmp)
+ return gpg_error_from_syserror ();
+ memcpy (buffer, tmp, n);
+ gcry_free (tmp);
+ }
+ *nwritten = n;
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_PGP)
+ {
+ unsigned int n = (nbits + 7)/8;
+
+ /* The PGP format can only handle unsigned integers. */
+ if( a->sign )
+ return gcry_error (GPG_ERR_INV_ARG);
+
+ if (buffer && n+2 > len)
+ return gcry_error (GPG_ERR_TOO_SHORT);
+
+ if (buffer)
+ {
+ unsigned char *tmp;
+ unsigned char *s = buffer;
+
+ s[0] = nbits >> 8;
+ s[1] = nbits;
+
+ tmp = _gcry_mpi_get_buffer (a, &n, NULL);
+ if (!tmp)
+ return gpg_error_from_syserror ();
+ memcpy (s+2, tmp, n);
+ gcry_free (tmp);
+ }
+ *nwritten = n+2;
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_SSH)
+ {
+ unsigned char *tmp;
+ int extra = 0;
+ unsigned int n;
+
+ if (a->sign)
+ return gcry_error (GPG_ERR_INTERNAL); /* Can't handle it yet. */
+
+ tmp = _gcry_mpi_get_buffer (a, &n, NULL);
+ if (!tmp)
+ return gpg_error_from_syserror ();
+ if (n && (*tmp & 0x80))
+ {
+ n++;
+ extra=1;
+ }
+
+ if (buffer && n+4 > len)
+ {
+ gcry_free(tmp);
+ return gcry_error (GPG_ERR_TOO_SHORT);
+ }
+
+ if (buffer)
+ {
+ unsigned char *s = buffer;
+
+ *s++ = n >> 24;
+ *s++ = n >> 16;
+ *s++ = n >> 8;
+ *s++ = n;
+ if (extra)
+ *s++ = 0;
+
+ memcpy (s, tmp, n-extra);
+ }
+ gcry_free (tmp);
+ *nwritten = 4+n;
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_HEX)
+ {
+ unsigned char *tmp;
+ int i;
+ int extra = 0;
+ unsigned int n = 0;
+
+ tmp = _gcry_mpi_get_buffer (a, &n, NULL);
+ if (!tmp)
+ return gpg_error_from_syserror ();
+ if (!n || (*tmp & 0x80))
+ extra = 2;
+
+ if (buffer && 2*n + extra + !!a->sign + 1 > len)
+ {
+ gcry_free(tmp);
+ return gcry_error (GPG_ERR_TOO_SHORT);
+ }
+ if (buffer)
+ {
+ unsigned char *s = buffer;
+
+ if (a->sign)
+ *s++ = '-';
+ if (extra)
+ {
+ *s++ = '0';
+ *s++ = '0';
+ }
+
+ for (i=0; i < n; i++)
+ {
+ unsigned int c = tmp[i];
+
+ *s++ = (c >> 4) < 10? '0'+(c>>4) : 'A'+(c>>4)-10 ;
+ c &= 15;
+ *s++ = c < 10? '0'+c : 'A'+c-10 ;
+ }
+ *s++ = 0;
+ *nwritten = s - buffer;
+ }
+ else
+ {
+ *nwritten = 2*n + extra + !!a->sign + 1;
+ }
+ gcry_free (tmp);
+ return 0;
+ }
+ else
+ return gcry_error (GPG_ERR_INV_ARG);
+}
+
+
+/*
+ * Like gcry_mpi_print but this function allocates the buffer itself.
+ * The caller has to supply the address of a pointer. NWRITTEN may be
+ * NULL.
+ */
+gcry_error_t
+gcry_mpi_aprint (enum gcry_mpi_format format,
+ unsigned char **buffer, size_t *nwritten,
+ struct gcry_mpi *a)
+{
+ size_t n;
+ gcry_error_t rc;
+
+ *buffer = NULL;
+ rc = gcry_mpi_print (format, NULL, 0, &n, a);
+ if (rc)
+ return rc;
+
+ *buffer = mpi_is_secure(a) ? gcry_malloc_secure (n) : gcry_malloc (n);
+ if (!*buffer)
+ return gpg_error_from_syserror ();
+ rc = gcry_mpi_print( format, *buffer, n, &n, a );
+ if (rc)
+ {
+ gcry_free(*buffer);
+ *buffer = NULL;
+ }
+ else if (nwritten)
+ *nwritten = n;
+ return rc;
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpih-add1.c b/grub-core/lib/libgcrypt-grub/mpi/mpih-add1.c
new file mode 100644
index 0000000..4a84df6
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpih-add1.c
@@ -0,0 +1,65 @@
+/* mpihelp-add_1.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998,
+ * 2000, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+_gcry_mpih_add_n (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_ptr_t s2_ptr, mpi_size_t size)
+{
+ mpi_limb_t x, y, cy;
+ mpi_size_t j;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ the loop becomes faster. */
+ j = -size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ s2_ptr -= j;
+ res_ptr -= j;
+
+ cy = 0;
+ do
+ {
+ y = s2_ptr[j];
+ x = s1_ptr[j];
+ y += cy; /* add previous carry to one addend */
+ cy = y < cy; /* get out carry from that addition */
+ y += x; /* add other addend */
+ cy += y < x; /* get out carry from that add, combine */
+ res_ptr[j] = y;
+ }
+ while ( ++j );
+
+ return cy;
+}
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpih-div.c b/grub-core/lib/libgcrypt-grub/mpi/mpih-div.c
new file mode 100644
index 0000000..797c083
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpih-div.c
@@ -0,0 +1,536 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpih-div.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 2000,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+#ifndef UMUL_TIME
+#define UMUL_TIME 1
+#endif
+#ifndef UDIV_TIME
+#define UDIV_TIME UMUL_TIME
+#endif
+
+/* FIXME: We should be using invert_limb (or invert_normalized_limb)
+ * here (not udiv_qrnnd).
+ */
+
+mpi_limb_t
+_gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+ mpi_limb_t divisor_limb)
+{
+ mpi_size_t i;
+ mpi_limb_t n1, n0, r;
+ int dummy;
+
+ /* Botch: Should this be handled at all? Rely on callers? */
+ if( !dividend_size )
+ return 0;
+
+ /* If multiplication is much faster than division, and the
+ * dividend is large, pre-invert the divisor, and use
+ * only multiplications in the inner loop.
+ *
+ * This test should be read:
+ * Does it ever help to use udiv_qrnnd_preinv?
+ * && Does what we save compensate for the inversion overhead?
+ */
+ if( UDIV_TIME > (2 * UMUL_TIME + 6)
+ && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME ) {
+ int normalization_steps;
+
+ count_leading_zeros( normalization_steps, divisor_limb );
+ if( normalization_steps ) {
+ mpi_limb_t divisor_limb_inverted;
+
+ divisor_limb <<= normalization_steps;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ * most significant bit (with weight 2**N) implicit.
+ *
+ * Special case for DIVISOR_LIMB == 100...000.
+ */
+ if( !(divisor_limb << 1) )
+ divisor_limb_inverted = ~(mpi_limb_t)0;
+ else
+ udiv_qrnnd(divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ * if (r == 0
+ * && divisor_limb > ((n1 << normalization_steps)
+ * | (dividend_ptr[dividend_size - 2] >> ...)))
+ * ...one division less...
+ */
+ for( i = dividend_size - 2; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ UDIV_QRNND_PREINV(dummy, r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+ divisor_limb, divisor_limb_inverted);
+ n1 = n0;
+ }
+ UDIV_QRNND_PREINV(dummy, r, r,
+ n1 << normalization_steps,
+ divisor_limb, divisor_limb_inverted);
+ return r >> normalization_steps;
+ }
+ else {
+ mpi_limb_t divisor_limb_inverted;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ * most significant bit (with weight 2**N) implicit.
+ *
+ * Special case for DIVISOR_LIMB == 100...000.
+ */
+ if( !(divisor_limb << 1) )
+ divisor_limb_inverted = ~(mpi_limb_t)0;
+ else
+ udiv_qrnnd(divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if( r >= divisor_limb )
+ r = 0;
+ else
+ i--;
+
+ for( ; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ UDIV_QRNND_PREINV(dummy, r, r,
+ n0, divisor_limb, divisor_limb_inverted);
+ }
+ return r;
+ }
+ }
+ else {
+ if( UDIV_NEEDS_NORMALIZATION ) {
+ int normalization_steps;
+
+ count_leading_zeros(normalization_steps, divisor_limb);
+ if( normalization_steps ) {
+ divisor_limb <<= normalization_steps;
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ * if (r == 0
+ * && divisor_limb > ((n1 << normalization_steps)
+ * | (dividend_ptr[dividend_size - 2] >> ...)))
+ * ...one division less...
+ */
+ for(i = dividend_size - 2; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd (dummy, r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+ divisor_limb);
+ n1 = n0;
+ }
+ udiv_qrnnd (dummy, r, r,
+ n1 << normalization_steps,
+ divisor_limb);
+ return r >> normalization_steps;
+ }
+ }
+ /* No normalization needed, either because udiv_qrnnd doesn't require
+ * it, or because DIVISOR_LIMB is already normalized. */
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if(r >= divisor_limb)
+ r = 0;
+ else
+ i--;
+
+ for(; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd (dummy, r, r, n0, divisor_limb);
+ }
+ return r;
+ }
+}
+
+/* Divide num (NP/NSIZE) by den (DP/DSIZE) and write
+ * the NSIZE-DSIZE least significant quotient limbs at QP
+ * and the DSIZE long remainder at NP. If QEXTRA_LIMBS is
+ * non-zero, generate that many fraction bits and append them after the
+ * other quotient limbs.
+ * Return the most significant limb of the quotient, this is always 0 or 1.
+ *
+ * Preconditions:
+ * 0. NSIZE >= DSIZE.
+ * 1. The most significant bit of the divisor must be set.
+ * 2. QP must either not overlap with the input operands at all, or
+ * QP + DSIZE >= NP must hold true. (This means that it's
+ * possible to put the quotient in the high part of NUM, right after the
+ * remainder in NUM.
+ * 3. NSIZE >= DSIZE, even if QEXTRA_LIMBS is non-zero.
+ */
+
+mpi_limb_t
+_gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs,
+ mpi_ptr_t np, mpi_size_t nsize,
+ mpi_ptr_t dp, mpi_size_t dsize)
+{
+ mpi_limb_t most_significant_q_limb = 0;
+
+ switch(dsize) {
+ case 0:
+ /* We are asked to divide by zero, so go ahead and do it! (To make
+ the compiler not remove this statement, return the value.) */
+ grub_fatal ("mpi division by zero");
+ return 0;
+
+ case 1:
+ {
+ mpi_size_t i;
+ mpi_limb_t n1;
+ mpi_limb_t d;
+
+ d = dp[0];
+ n1 = np[nsize - 1];
+
+ if( n1 >= d ) {
+ n1 -= d;
+ most_significant_q_limb = 1;
+ }
+
+ qp += qextra_limbs;
+ for( i = nsize - 2; i >= 0; i--)
+ udiv_qrnnd( qp[i], n1, n1, np[i], d );
+ qp -= qextra_limbs;
+
+ for( i = qextra_limbs - 1; i >= 0; i-- )
+ udiv_qrnnd (qp[i], n1, n1, 0, d);
+
+ np[0] = n1;
+ }
+ break;
+
+ case 2:
+ {
+ mpi_size_t i;
+ mpi_limb_t n1, n0, n2;
+ mpi_limb_t d1, d0;
+
+ np += nsize - 2;
+ d1 = dp[1];
+ d0 = dp[0];
+ n1 = np[1];
+ n0 = np[0];
+
+ if( n1 >= d1 && (n1 > d1 || n0 >= d0) ) {
+ sub_ddmmss (n1, n0, n1, n0, d1, d0);
+ most_significant_q_limb = 1;
+ }
+
+ for( i = qextra_limbs + nsize - 2 - 1; i >= 0; i-- ) {
+ mpi_limb_t q;
+ mpi_limb_t r;
+
+ if( i >= qextra_limbs )
+ np--;
+ else
+ np[0] = 0;
+
+ if( n1 == d1 ) {
+ /* Q should be either 111..111 or 111..110. Need special
+ * treatment of this rare case as normal division would
+ * give overflow. */
+ q = ~(mpi_limb_t)0;
+
+ r = n0 + d1;
+ if( r < d1 ) { /* Carry in the addition? */
+ add_ssaaaa( n1, n0, r - d0, np[0], 0, d0 );
+ qp[i] = q;
+ continue;
+ }
+ n1 = d0 - (d0 != 0?1:0);
+ n0 = -d0;
+ }
+ else {
+ udiv_qrnnd (q, r, n1, n0, d1);
+ umul_ppmm (n1, n0, d0, q);
+ }
+
+ n2 = np[0];
+ q_test:
+ if( n1 > r || (n1 == r && n0 > n2) ) {
+ /* The estimated Q was too large. */
+ q--;
+ sub_ddmmss (n1, n0, n1, n0, 0, d0);
+ r += d1;
+ if( r >= d1 ) /* If not carry, test Q again. */
+ goto q_test;
+ }
+
+ qp[i] = q;
+ sub_ddmmss (n1, n0, r, n2, n1, n0);
+ }
+ np[1] = n1;
+ np[0] = n0;
+ }
+ break;
+
+ default:
+ {
+ mpi_size_t i;
+ mpi_limb_t dX, d1, n0;
+
+ np += nsize - dsize;
+ dX = dp[dsize - 1];
+ d1 = dp[dsize - 2];
+ n0 = np[dsize - 1];
+
+ if( n0 >= dX ) {
+ if(n0 > dX || _gcry_mpih_cmp(np, dp, dsize - 1) >= 0 ) {
+ _gcry_mpih_sub_n(np, np, dp, dsize);
+ n0 = np[dsize - 1];
+ most_significant_q_limb = 1;
+ }
+ }
+
+ for( i = qextra_limbs + nsize - dsize - 1; i >= 0; i--) {
+ mpi_limb_t q;
+ mpi_limb_t n1, n2;
+ mpi_limb_t cy_limb;
+
+ if( i >= qextra_limbs ) {
+ np--;
+ n2 = np[dsize];
+ }
+ else {
+ n2 = np[dsize - 1];
+ MPN_COPY_DECR (np + 1, np, dsize - 1);
+ np[0] = 0;
+ }
+
+ if( n0 == dX ) {
+ /* This might over-estimate q, but it's probably not worth
+ * the extra code here to find out. */
+ q = ~(mpi_limb_t)0;
+ }
+ else {
+ mpi_limb_t r;
+
+ udiv_qrnnd(q, r, n0, np[dsize - 1], dX);
+ umul_ppmm(n1, n0, d1, q);
+
+ while( n1 > r || (n1 == r && n0 > np[dsize - 2])) {
+ q--;
+ r += dX;
+ if( r < dX ) /* I.e. "carry in previous addition?" */
+ break;
+ n1 -= n0 < d1;
+ n0 -= d1;
+ }
+ }
+
+ /* Possible optimization: We already have (q * n0) and (1 * n1)
+ * after the calculation of q. Taking advantage of that, we
+ * could make this loop make two iterations less. */
+ cy_limb = _gcry_mpih_submul_1(np, dp, dsize, q);
+
+ if( n2 != cy_limb ) {
+ _gcry_mpih_add_n(np, np, dp, dsize);
+ q--;
+ }
+
+ qp[i] = q;
+ n0 = np[dsize - 1];
+ }
+ }
+ }
+
+ return most_significant_q_limb;
+}
+
+
+/****************
+ * Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by DIVISOR_LIMB.
+ * Write DIVIDEND_SIZE limbs of quotient at QUOT_PTR.
+ * Return the single-limb remainder.
+ * There are no constraints on the value of the divisor.
+ *
+ * QUOT_PTR and DIVIDEND_PTR might point to the same limb.
+ */
+
+mpi_limb_t
+_gcry_mpih_divmod_1( mpi_ptr_t quot_ptr,
+ mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+ mpi_limb_t divisor_limb)
+{
+ mpi_size_t i;
+ mpi_limb_t n1, n0, r;
+ int dummy;
+
+ if( !dividend_size )
+ return 0;
+
+ /* If multiplication is much faster than division, and the
+ * dividend is large, pre-invert the divisor, and use
+ * only multiplications in the inner loop.
+ *
+ * This test should be read:
+ * Does it ever help to use udiv_qrnnd_preinv?
+ * && Does what we save compensate for the inversion overhead?
+ */
+ if( UDIV_TIME > (2 * UMUL_TIME + 6)
+ && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME ) {
+ int normalization_steps;
+
+ count_leading_zeros( normalization_steps, divisor_limb );
+ if( normalization_steps ) {
+ mpi_limb_t divisor_limb_inverted;
+
+ divisor_limb <<= normalization_steps;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ * most significant bit (with weight 2**N) implicit.
+ */
+ /* Special case for DIVISOR_LIMB == 100...000. */
+ if( !(divisor_limb << 1) )
+ divisor_limb_inverted = ~(mpi_limb_t)0;
+ else
+ udiv_qrnnd(divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ * if (r == 0
+ * && divisor_limb > ((n1 << normalization_steps)
+ * | (dividend_ptr[dividend_size - 2] >> ...)))
+ * ...one division less...
+ */
+ for( i = dividend_size - 2; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ UDIV_QRNND_PREINV( quot_ptr[i + 1], r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+ divisor_limb, divisor_limb_inverted);
+ n1 = n0;
+ }
+ UDIV_QRNND_PREINV( quot_ptr[0], r, r,
+ n1 << normalization_steps,
+ divisor_limb, divisor_limb_inverted);
+ return r >> normalization_steps;
+ }
+ else {
+ mpi_limb_t divisor_limb_inverted;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ * most significant bit (with weight 2**N) implicit.
+ */
+ /* Special case for DIVISOR_LIMB == 100...000. */
+ if( !(divisor_limb << 1) )
+ divisor_limb_inverted = ~(mpi_limb_t) 0;
+ else
+ udiv_qrnnd(divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if( r >= divisor_limb )
+ r = 0;
+ else
+ quot_ptr[i--] = 0;
+
+ for( ; i >= 0; i-- ) {
+ n0 = dividend_ptr[i];
+ UDIV_QRNND_PREINV( quot_ptr[i], r, r,
+ n0, divisor_limb, divisor_limb_inverted);
+ }
+ return r;
+ }
+ }
+ else {
+ if(UDIV_NEEDS_NORMALIZATION) {
+ int normalization_steps;
+
+ count_leading_zeros (normalization_steps, divisor_limb);
+ if( normalization_steps ) {
+ divisor_limb <<= normalization_steps;
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ * if (r == 0
+ * && divisor_limb > ((n1 << normalization_steps)
+ * | (dividend_ptr[dividend_size - 2] >> ...)))
+ * ...one division less...
+ */
+ for( i = dividend_size - 2; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd (quot_ptr[i + 1], r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+ divisor_limb);
+ n1 = n0;
+ }
+ udiv_qrnnd (quot_ptr[0], r, r,
+ n1 << normalization_steps,
+ divisor_limb);
+ return r >> normalization_steps;
+ }
+ }
+ /* No normalization needed, either because udiv_qrnnd doesn't require
+ * it, or because DIVISOR_LIMB is already normalized. */
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if(r >= divisor_limb)
+ r = 0;
+ else
+ quot_ptr[i--] = 0;
+
+ for(; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd( quot_ptr[i], r, r, n0, divisor_limb );
+ }
+ return r;
+ }
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpih-lshift.c b/grub-core/lib/libgcrypt-grub/mpi/mpih-lshift.c
new file mode 100644
index 0000000..f48c12c
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpih-lshift.c
@@ -0,0 +1,68 @@
+/* mpi-lshift.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left
+ * and store the USIZE least significant digits of the result at WP.
+ * Return the bits shifted out from the most significant digit.
+ *
+ * Argument constraints:
+ * 1. 0 < CNT < BITS_PER_MP_LIMB
+ * 2. If the result is to be written over the input, WP must be >= UP.
+ */
+
+mpi_limb_t
+_gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
+ unsigned int cnt)
+{
+ mpi_limb_t high_limb, low_limb;
+ unsigned sh_1, sh_2;
+ mpi_size_t i;
+ mpi_limb_t retval;
+
+ sh_1 = cnt;
+ wp += 1;
+ sh_2 = BITS_PER_MPI_LIMB - sh_1;
+ i = usize - 1;
+ low_limb = up[i];
+ retval = low_limb >> sh_2;
+ high_limb = low_limb;
+ while ( --i >= 0 )
+ {
+ low_limb = up[i];
+ wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
+ high_limb = low_limb;
+ }
+ wp[i] = high_limb << sh_1;
+
+ return retval;
+}
+
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpih-mul.c b/grub-core/lib/libgcrypt-grub/mpi/mpih-mul.c
new file mode 100644
index 0000000..44b3686
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpih-mul.c
@@ -0,0 +1,530 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpih-mul.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 1999, 2000,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+#include "g10lib.h"
+
+#define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \
+ do { \
+ if( (size) < KARATSUBA_THRESHOLD ) \
+ mul_n_basecase (prodp, up, vp, size); \
+ else \
+ mul_n (prodp, up, vp, size, tspace); \
+ } while (0);
+
+#define MPN_SQR_N_RECURSE(prodp, up, size, tspace) \
+ do { \
+ if ((size) < KARATSUBA_THRESHOLD) \
+ _gcry_mpih_sqr_n_basecase (prodp, up, size); \
+ else \
+ _gcry_mpih_sqr_n (prodp, up, size, tspace); \
+ } while (0);
+
+
+
+
+/* Multiply the natural numbers u (pointed to by UP) and v (pointed to by VP),
+ * both with SIZE limbs, and store the result at PRODP. 2 * SIZE limbs are
+ * always stored. Return the most significant limb.
+ *
+ * Argument constraints:
+ * 1. PRODP != UP and PRODP != VP, i.e. the destination
+ * must be distinct from the multiplier and the multiplicand.
+ *
+ *
+ * Handle simple cases with traditional multiplication.
+ *
+ * This is the most critical code of multiplication. All multiplies rely
+ * on this, both small and huge. Small ones arrive here immediately. Huge
+ * ones arrive here as this is the base case for Karatsuba's recursive
+ * algorithm below.
+ */
+
+static mpi_limb_t
+mul_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up,
+ mpi_ptr_t vp, mpi_size_t size)
+{
+ mpi_size_t i;
+ mpi_limb_t cy;
+ mpi_limb_t v_limb;
+
+ /* Multiply by the first limb in V separately, as the result can be
+ * stored (not added) to PROD. We also avoid a loop for zeroing. */
+ v_limb = vp[0];
+ if( v_limb <= 1 ) {
+ if( v_limb == 1 )
+ MPN_COPY( prodp, up, size );
+ else
+ MPN_ZERO( prodp, size );
+ cy = 0;
+ }
+ else
+ cy = _gcry_mpih_mul_1( prodp, up, size, v_limb );
+
+ prodp[size] = cy;
+ prodp++;
+
+ /* For each iteration in the outer loop, multiply one limb from
+ * U with one limb from V, and add it to PROD. */
+ for( i = 1; i < size; i++ ) {
+ v_limb = vp[i];
+ if( v_limb <= 1 ) {
+ cy = 0;
+ if( v_limb == 1 )
+ cy = _gcry_mpih_add_n(prodp, prodp, up, size);
+ }
+ else
+ cy = _gcry_mpih_addmul_1(prodp, up, size, v_limb);
+
+ prodp[size] = cy;
+ prodp++;
+ }
+
+ return cy;
+}
+
+
+static void
+mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp,
+ mpi_size_t size, mpi_ptr_t tspace )
+{
+ if( size & 1 ) {
+ /* The size is odd, and the code below doesn't handle that.
+ * Multiply the least significant (size - 1) limbs with a recursive
+ * call, and handle the most significant limb of S1 and S2
+ * separately.
+ * A slightly faster way to do this would be to make the Karatsuba
+ * code below behave as if the size were even, and let it check for
+ * odd size in the end. I.e., in essence move this code to the end.
+ * Doing so would save us a recursive call, and potentially make the
+ * stack grow a lot less.
+ */
+ mpi_size_t esize = size - 1; /* even size */
+ mpi_limb_t cy_limb;
+
+ MPN_MUL_N_RECURSE( prodp, up, vp, esize, tspace );
+ cy_limb = _gcry_mpih_addmul_1( prodp + esize, up, esize, vp[esize] );
+ prodp[esize + esize] = cy_limb;
+ cy_limb = _gcry_mpih_addmul_1( prodp + esize, vp, size, up[esize] );
+ prodp[esize + size] = cy_limb;
+ }
+ else {
+ /* Anatolij Alekseevich Karatsuba's divide-and-conquer algorithm.
+ *
+ * Split U in two pieces, U1 and U0, such that
+ * U = U0 + U1*(B**n),
+ * and V in V1 and V0, such that
+ * V = V0 + V1*(B**n).
+ *
+ * UV is then computed recursively using the identity
+ *
+ * 2n n n n
+ * UV = (B + B )U V + B (U -U )(V -V ) + (B + 1)U V
+ * 1 1 1 0 0 1 0 0
+ *
+ * Where B = 2**BITS_PER_MP_LIMB.
+ */
+ mpi_size_t hsize = size >> 1;
+ mpi_limb_t cy;
+ int negflg;
+
+ /* Product H. ________________ ________________
+ * |_____U1 x V1____||____U0 x V0_____|
+ * Put result in upper part of PROD and pass low part of TSPACE
+ * as new TSPACE.
+ */
+ MPN_MUL_N_RECURSE(prodp + size, up + hsize, vp + hsize, hsize, tspace);
+
+ /* Product M. ________________
+ * |_(U1-U0)(V0-V1)_|
+ */
+ if( _gcry_mpih_cmp(up + hsize, up, hsize) >= 0 ) {
+ _gcry_mpih_sub_n(prodp, up + hsize, up, hsize);
+ negflg = 0;
+ }
+ else {
+ _gcry_mpih_sub_n(prodp, up, up + hsize, hsize);
+ negflg = 1;
+ }
+ if( _gcry_mpih_cmp(vp + hsize, vp, hsize) >= 0 ) {
+ _gcry_mpih_sub_n(prodp + hsize, vp + hsize, vp, hsize);
+ negflg ^= 1;
+ }
+ else {
+ _gcry_mpih_sub_n(prodp + hsize, vp, vp + hsize, hsize);
+ /* No change of NEGFLG. */
+ }
+ /* Read temporary operands from low part of PROD.
+ * Put result in low part of TSPACE using upper part of TSPACE
+ * as new TSPACE.
+ */
+ MPN_MUL_N_RECURSE(tspace, prodp, prodp + hsize, hsize, tspace + size);
+
+ /* Add/copy product H. */
+ MPN_COPY (prodp + hsize, prodp + size, hsize);
+ cy = _gcry_mpih_add_n( prodp + size, prodp + size,
+ prodp + size + hsize, hsize);
+
+ /* Add product M (if NEGFLG M is a negative number) */
+ if(negflg)
+ cy -= _gcry_mpih_sub_n(prodp + hsize, prodp + hsize, tspace, size);
+ else
+ cy += _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace, size);
+
+ /* Product L. ________________ ________________
+ * |________________||____U0 x V0_____|
+ * Read temporary operands from low part of PROD.
+ * Put result in low part of TSPACE using upper part of TSPACE
+ * as new TSPACE.
+ */
+ MPN_MUL_N_RECURSE(tspace, up, vp, hsize, tspace + size);
+
+ /* Add/copy Product L (twice) */
+
+ cy += _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace, size);
+ if( cy )
+ _gcry_mpih_add_1(prodp + hsize + size, prodp + hsize + size, hsize, cy);
+
+ MPN_COPY(prodp, tspace, hsize);
+ cy = _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace + hsize, hsize);
+ if( cy )
+ _gcry_mpih_add_1(prodp + size, prodp + size, size, 1);
+ }
+}
+
+
+void
+_gcry_mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size )
+{
+ mpi_size_t i;
+ mpi_limb_t cy_limb;
+ mpi_limb_t v_limb;
+
+ /* Multiply by the first limb in V separately, as the result can be
+ * stored (not added) to PROD. We also avoid a loop for zeroing. */
+ v_limb = up[0];
+ if( v_limb <= 1 ) {
+ if( v_limb == 1 )
+ MPN_COPY( prodp, up, size );
+ else
+ MPN_ZERO(prodp, size);
+ cy_limb = 0;
+ }
+ else
+ cy_limb = _gcry_mpih_mul_1( prodp, up, size, v_limb );
+
+ prodp[size] = cy_limb;
+ prodp++;
+
+ /* For each iteration in the outer loop, multiply one limb from
+ * U with one limb from V, and add it to PROD. */
+ for( i=1; i < size; i++) {
+ v_limb = up[i];
+ if( v_limb <= 1 ) {
+ cy_limb = 0;
+ if( v_limb == 1 )
+ cy_limb = _gcry_mpih_add_n(prodp, prodp, up, size);
+ }
+ else
+ cy_limb = _gcry_mpih_addmul_1(prodp, up, size, v_limb);
+
+ prodp[size] = cy_limb;
+ prodp++;
+ }
+}
+
+
+void
+_gcry_mpih_sqr_n( mpi_ptr_t prodp,
+ mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace)
+{
+ if( size & 1 ) {
+ /* The size is odd, and the code below doesn't handle that.
+ * Multiply the least significant (size - 1) limbs with a recursive
+ * call, and handle the most significant limb of S1 and S2
+ * separately.
+ * A slightly faster way to do this would be to make the Karatsuba
+ * code below behave as if the size were even, and let it check for
+ * odd size in the end. I.e., in essence move this code to the end.
+ * Doing so would save us a recursive call, and potentially make the
+ * stack grow a lot less.
+ */
+ mpi_size_t esize = size - 1; /* even size */
+ mpi_limb_t cy_limb;
+
+ MPN_SQR_N_RECURSE( prodp, up, esize, tspace );
+ cy_limb = _gcry_mpih_addmul_1( prodp + esize, up, esize, up[esize] );
+ prodp[esize + esize] = cy_limb;
+ cy_limb = _gcry_mpih_addmul_1( prodp + esize, up, size, up[esize] );
+
+ prodp[esize + size] = cy_limb;
+ }
+ else {
+ mpi_size_t hsize = size >> 1;
+ mpi_limb_t cy;
+
+ /* Product H. ________________ ________________
+ * |_____U1 x U1____||____U0 x U0_____|
+ * Put result in upper part of PROD and pass low part of TSPACE
+ * as new TSPACE.
+ */
+ MPN_SQR_N_RECURSE(prodp + size, up + hsize, hsize, tspace);
+
+ /* Product M. ________________
+ * |_(U1-U0)(U0-U1)_|
+ */
+ if( _gcry_mpih_cmp( up + hsize, up, hsize) >= 0 )
+ _gcry_mpih_sub_n( prodp, up + hsize, up, hsize);
+ else
+ _gcry_mpih_sub_n (prodp, up, up + hsize, hsize);
+
+ /* Read temporary operands from low part of PROD.
+ * Put result in low part of TSPACE using upper part of TSPACE
+ * as new TSPACE. */
+ MPN_SQR_N_RECURSE(tspace, prodp, hsize, tspace + size);
+
+ /* Add/copy product H */
+ MPN_COPY(prodp + hsize, prodp + size, hsize);
+ cy = _gcry_mpih_add_n(prodp + size, prodp + size,
+ prodp + size + hsize, hsize);
+
+ /* Add product M (if NEGFLG M is a negative number). */
+ cy -= _gcry_mpih_sub_n (prodp + hsize, prodp + hsize, tspace, size);
+
+ /* Product L. ________________ ________________
+ * |________________||____U0 x U0_____|
+ * Read temporary operands from low part of PROD.
+ * Put result in low part of TSPACE using upper part of TSPACE
+ * as new TSPACE. */
+ MPN_SQR_N_RECURSE (tspace, up, hsize, tspace + size);
+
+ /* Add/copy Product L (twice). */
+ cy += _gcry_mpih_add_n (prodp + hsize, prodp + hsize, tspace, size);
+ if( cy )
+ _gcry_mpih_add_1(prodp + hsize + size, prodp + hsize + size,
+ hsize, cy);
+
+ MPN_COPY(prodp, tspace, hsize);
+ cy = _gcry_mpih_add_n (prodp + hsize, prodp + hsize, tspace + hsize, hsize);
+ if( cy )
+ _gcry_mpih_add_1 (prodp + size, prodp + size, size, 1);
+ }
+}
+
+
+/* This should be made into an inline function in gmp.h. */
+void
+_gcry_mpih_mul_n( mpi_ptr_t prodp,
+ mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size)
+{
+ int secure;
+
+ if( up == vp ) {
+ if( size < KARATSUBA_THRESHOLD )
+ _gcry_mpih_sqr_n_basecase( prodp, up, size );
+ else {
+ mpi_ptr_t tspace;
+ secure = gcry_is_secure( up );
+ tspace = mpi_alloc_limb_space( 2 * size, secure );
+ _gcry_mpih_sqr_n( prodp, up, size, tspace );
+ _gcry_mpi_free_limb_space (tspace, 2 * size );
+ }
+ }
+ else {
+ if( size < KARATSUBA_THRESHOLD )
+ mul_n_basecase( prodp, up, vp, size );
+ else {
+ mpi_ptr_t tspace;
+ secure = gcry_is_secure( up ) || gcry_is_secure( vp );
+ tspace = mpi_alloc_limb_space( 2 * size, secure );
+ mul_n (prodp, up, vp, size, tspace);
+ _gcry_mpi_free_limb_space (tspace, 2 * size );
+ }
+ }
+}
+
+
+
+void
+_gcry_mpih_mul_karatsuba_case( mpi_ptr_t prodp,
+ mpi_ptr_t up, mpi_size_t usize,
+ mpi_ptr_t vp, mpi_size_t vsize,
+ struct karatsuba_ctx *ctx )
+{
+ mpi_limb_t cy;
+
+ if( !ctx->tspace || ctx->tspace_size < vsize ) {
+ if( ctx->tspace )
+ _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs );
+ ctx->tspace_nlimbs = 2 * vsize;
+ ctx->tspace = mpi_alloc_limb_space( 2 * vsize,
+ (gcry_is_secure( up )
+ || gcry_is_secure( vp )) );
+ ctx->tspace_size = vsize;
+ }
+
+ MPN_MUL_N_RECURSE( prodp, up, vp, vsize, ctx->tspace );
+
+ prodp += vsize;
+ up += vsize;
+ usize -= vsize;
+ if( usize >= vsize ) {
+ if( !ctx->tp || ctx->tp_size < vsize ) {
+ if( ctx->tp )
+ _gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs );
+ ctx->tp_nlimbs = 2 * vsize;
+ ctx->tp = mpi_alloc_limb_space( 2 * vsize, gcry_is_secure( up )
+ || gcry_is_secure( vp ) );
+ ctx->tp_size = vsize;
+ }
+
+ do {
+ MPN_MUL_N_RECURSE( ctx->tp, up, vp, vsize, ctx->tspace );
+ cy = _gcry_mpih_add_n( prodp, prodp, ctx->tp, vsize );
+ _gcry_mpih_add_1( prodp + vsize, ctx->tp + vsize, vsize, cy );
+ prodp += vsize;
+ up += vsize;
+ usize -= vsize;
+ } while( usize >= vsize );
+ }
+
+ if( usize ) {
+ if( usize < KARATSUBA_THRESHOLD ) {
+ _gcry_mpih_mul( ctx->tspace, vp, vsize, up, usize );
+ }
+ else {
+ if( !ctx->next ) {
+ ctx->next = gcry_xcalloc( 1, sizeof *ctx );
+ }
+ _gcry_mpih_mul_karatsuba_case( ctx->tspace,
+ vp, vsize,
+ up, usize,
+ ctx->next );
+ }
+
+ cy = _gcry_mpih_add_n( prodp, prodp, ctx->tspace, vsize);
+ _gcry_mpih_add_1( prodp + vsize, ctx->tspace + vsize, usize, cy );
+ }
+}
+
+
+void
+_gcry_mpih_release_karatsuba_ctx( struct karatsuba_ctx *ctx )
+{
+ struct karatsuba_ctx *ctx2;
+
+ if( ctx->tp )
+ _gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs );
+ if( ctx->tspace )
+ _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs );
+ for( ctx=ctx->next; ctx; ctx = ctx2 ) {
+ ctx2 = ctx->next;
+ if( ctx->tp )
+ _gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs );
+ if( ctx->tspace )
+ _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs );
+ gcry_free( ctx );
+ }
+}
+
+/* Multiply the natural numbers u (pointed to by UP, with USIZE limbs)
+ * and v (pointed to by VP, with VSIZE limbs), and store the result at
+ * PRODP. USIZE + VSIZE limbs are always stored, but if the input
+ * operands are normalized. Return the most significant limb of the
+ * result.
+ *
+ * NOTE: The space pointed to by PRODP is overwritten before finished
+ * with U and V, so overlap is an error.
+ *
+ * Argument constraints:
+ * 1. USIZE >= VSIZE.
+ * 2. PRODP != UP and PRODP != VP, i.e. the destination
+ * must be distinct from the multiplier and the multiplicand.
+ */
+
+mpi_limb_t
+_gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize,
+ mpi_ptr_t vp, mpi_size_t vsize)
+{
+ mpi_ptr_t prod_endp = prodp + usize + vsize - 1;
+ mpi_limb_t cy;
+ struct karatsuba_ctx ctx;
+
+ if( vsize < KARATSUBA_THRESHOLD ) {
+ mpi_size_t i;
+ mpi_limb_t v_limb;
+
+ if( !vsize )
+ return 0;
+
+ /* Multiply by the first limb in V separately, as the result can be
+ * stored (not added) to PROD. We also avoid a loop for zeroing. */
+ v_limb = vp[0];
+ if( v_limb <= 1 ) {
+ if( v_limb == 1 )
+ MPN_COPY( prodp, up, usize );
+ else
+ MPN_ZERO( prodp, usize );
+ cy = 0;
+ }
+ else
+ cy = _gcry_mpih_mul_1( prodp, up, usize, v_limb );
+
+ prodp[usize] = cy;
+ prodp++;
+
+ /* For each iteration in the outer loop, multiply one limb from
+ * U with one limb from V, and add it to PROD. */
+ for( i = 1; i < vsize; i++ ) {
+ v_limb = vp[i];
+ if( v_limb <= 1 ) {
+ cy = 0;
+ if( v_limb == 1 )
+ cy = _gcry_mpih_add_n(prodp, prodp, up, usize);
+ }
+ else
+ cy = _gcry_mpih_addmul_1(prodp, up, usize, v_limb);
+
+ prodp[usize] = cy;
+ prodp++;
+ }
+
+ return cy;
+ }
+
+ memset( &ctx, 0, sizeof ctx );
+ _gcry_mpih_mul_karatsuba_case( prodp, up, usize, vp, vsize, &ctx );
+ _gcry_mpih_release_karatsuba_ctx( &ctx );
+ return *prod_endp;
+}
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpih-mul1.c b/grub-core/lib/libgcrypt-grub/mpi/mpih-mul1.c
new file mode 100644
index 0000000..0e8197d
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpih-mul1.c
@@ -0,0 +1,62 @@
+/* mpihelp-mul_1.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+_gcry_mpih_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_limb_t s2_limb)
+{
+ mpi_limb_t cy_limb;
+ mpi_size_t j;
+ mpi_limb_t prod_high, prod_low;
+
+ /* The loop counter and index J goes from -S1_SIZE to -1. This way
+ * the loop becomes faster. */
+ j = -s1_size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ res_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+ res_ptr[j] = prod_low;
+ }
+ while( ++j );
+
+ return cy_limb;
+}
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpih-mul2.c b/grub-core/lib/libgcrypt-grub/mpi/mpih-mul2.c
new file mode 100644
index 0000000..3b75496
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpih-mul2.c
@@ -0,0 +1,68 @@
+/* mpih-mul2.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+mpi_limb_t
+_gcry_mpih_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+ mpi_limb_t cy_limb;
+ mpi_size_t j;
+ mpi_limb_t prod_high, prod_low;
+ mpi_limb_t x;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ * the loop becomes faster. */
+ j = -s1_size;
+ res_ptr -= j;
+ s1_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
+
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+
+ x = res_ptr[j];
+ prod_low = x + prod_low;
+ cy_limb += prod_low < x?1:0;
+ res_ptr[j] = prod_low;
+ }
+ while ( ++j );
+
+ return cy_limb;
+}
+
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpih-mul3.c b/grub-core/lib/libgcrypt-grub/mpi/mpih-mul3.c
new file mode 100644
index 0000000..5e84f94
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpih-mul3.c
@@ -0,0 +1,68 @@
+/* mpih-mul3.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+mpi_limb_t
+_gcry_mpih_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+ mpi_limb_t cy_limb;
+ mpi_size_t j;
+ mpi_limb_t prod_high, prod_low;
+ mpi_limb_t x;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ * the loop becomes faster. */
+ j = -s1_size;
+ res_ptr -= j;
+ s1_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb);
+
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+
+ x = res_ptr[j];
+ prod_low = x - prod_low;
+ cy_limb += prod_low > x?1:0;
+ res_ptr[j] = prod_low;
+ }
+ while( ++j );
+
+ return cy_limb;
+}
+
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpih-rshift.c b/grub-core/lib/libgcrypt-grub/mpi/mpih-rshift.c
new file mode 100644
index 0000000..e40794f
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpih-rshift.c
@@ -0,0 +1,67 @@
+/* mpih-rshift.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 1999,
+ * 2000, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+
+/* Shift U (pointed to by UP and USIZE limbs long) CNT bits to the right
+ * and store the USIZE least significant limbs of the result at WP.
+ * The bits shifted out to the right are returned.
+ *
+ * Argument constraints:
+ * 1. 0 < CNT < BITS_PER_MP_LIMB
+ * 2. If the result is to be written over the input, WP must be <= UP.
+ */
+
+mpi_limb_t
+_gcry_mpih_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt)
+{
+ mpi_limb_t high_limb, low_limb;
+ unsigned sh_1, sh_2;
+ mpi_size_t i;
+ mpi_limb_t retval;
+
+ sh_1 = cnt;
+ wp -= 1;
+ sh_2 = BITS_PER_MPI_LIMB - sh_1;
+ high_limb = up[0];
+ retval = high_limb << sh_2;
+ low_limb = high_limb;
+ for (i=1; i < usize; i++)
+ {
+ high_limb = up[i];
+ wp[i] = (low_limb >> sh_1) | (high_limb << sh_2);
+ low_limb = high_limb;
+ }
+ wp[i] = low_limb >> sh_1;
+
+ return retval;
+}
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpih-sub1.c b/grub-core/lib/libgcrypt-grub/mpi/mpih-sub1.c
new file mode 100644
index 0000000..e88821b
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpih-sub1.c
@@ -0,0 +1,66 @@
+/* mpihelp-add_2.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+_gcry_mpih_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_ptr_t s2_ptr, mpi_size_t size)
+{
+ mpi_limb_t x, y, cy;
+ mpi_size_t j;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ the loop becomes faster. */
+ j = -size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ s2_ptr -= j;
+ res_ptr -= j;
+
+ cy = 0;
+ do
+ {
+ y = s2_ptr[j];
+ x = s1_ptr[j];
+ y += cy; /* add previous carry to subtrahend */
+ cy = y < cy; /* get out carry from that addition */
+ y = x - y; /* main subtract */
+ cy += y > x; /* get out carry from the subtract, combine */
+ res_ptr[j] = y;
+ }
+ while( ++j );
+
+ return cy;
+}
+
+
diff --git a/grub-core/lib/libgcrypt-grub/mpi/mpiutil.c b/grub-core/lib/libgcrypt-grub/mpi/mpiutil.c
new file mode 100644
index 0000000..3fec8db
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/mpi/mpiutil.c
@@ -0,0 +1,435 @@
+/* This file was automatically imported with
+ import_gcry.py. Please don't modify it */
+/* mpiutil.ac - Utility functions for MPI
+ * Copyright (C) 1998, 2000, 2001, 2002, 2003,
+ * 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "g10lib.h"
+#include "mpi-internal.h"
+
+
+
+
+/****************
+ * Note: It was a bad idea to use the number of limbs to allocate
+ * because on a alpha the limbs are large but we normally need
+ * integers of n bits - So we should change this to bits (or bytes).
+ *
+ * But mpi_alloc is used in a lot of places :-(. New code
+ * should use mpi_new.
+ */
+gcry_mpi_t
+_gcry_mpi_alloc( unsigned nlimbs )
+{
+ gcry_mpi_t a;
+
+ a = gcry_xmalloc( sizeof *a );
+ a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 0 ) : NULL;
+ a->alloced = nlimbs;
+ a->nlimbs = 0;
+ a->sign = 0;
+ a->flags = 0;
+ return a;
+}
+
+void
+_gcry_mpi_m_check( gcry_mpi_t a )
+{
+ _gcry_check_heap(a);
+ _gcry_check_heap(a->d);
+}
+
+gcry_mpi_t
+_gcry_mpi_alloc_secure( unsigned nlimbs )
+{
+ gcry_mpi_t a;
+
+ a = gcry_xmalloc( sizeof *a );
+ a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 1 ) : NULL;
+ a->alloced = nlimbs;
+ a->flags = 1;
+ a->nlimbs = 0;
+ a->sign = 0;
+ return a;
+}
+
+
+
+mpi_ptr_t
+_gcry_mpi_alloc_limb_space( unsigned int nlimbs, int secure )
+{
+ mpi_ptr_t p;
+ size_t len;
+
+ len = (nlimbs ? nlimbs : 1) * sizeof (mpi_limb_t);
+ p = secure ? gcry_xmalloc_secure (len) : gcry_xmalloc (len);
+ if (! nlimbs)
+ *p = 0;
+
+ return p;
+}
+
+void
+_gcry_mpi_free_limb_space( mpi_ptr_t a, unsigned int nlimbs)
+{
+ if (a)
+ {
+ size_t len = nlimbs * sizeof(mpi_limb_t);
+
+ /* If we have information on the number of allocated limbs, we
+ better wipe that space out. This is a failsafe feature if
+ secure memory has been disabled or was not properly
+ implemented in user provided allocation functions. */
+ if (len)
+ wipememory (a, len);
+ gcry_free(a);
+ }
+}
+
+
+void
+_gcry_mpi_assign_limb_space( gcry_mpi_t a, mpi_ptr_t ap, unsigned int nlimbs )
+{
+ _gcry_mpi_free_limb_space (a->d, a->alloced);
+ a->d = ap;
+ a->alloced = nlimbs;
+}
+
+
+
+/****************
+ * Resize the array of A to NLIMBS. The additional space is cleared
+ * (set to 0).
+ */
+void
+_gcry_mpi_resize (gcry_mpi_t a, unsigned nlimbs)
+{
+ size_t i;
+
+ if (nlimbs <= a->alloced)
+ {
+ /* We only need to clear the new space (this is a nop if the
+ limb space is already of the correct size. */
+ for (i=a->nlimbs; i < a->alloced; i++)
+ a->d[i] = 0;
+ return;
+ }
+
+ /* Actually resize the limb space. */
+ if (a->d)
+ {
+ a->d = gcry_xrealloc (a->d, nlimbs * sizeof (mpi_limb_t));
+ for (i=a->alloced; i < nlimbs; i++)
+ a->d[i] = 0;
+ }
+ else
+ {
+ if (a->flags & 1)
+ /* Secure memory is wanted. */
+ a->d = gcry_xcalloc_secure (nlimbs , sizeof (mpi_limb_t));
+ else
+ /* Standard memory. */
+ a->d = gcry_xcalloc (nlimbs , sizeof (mpi_limb_t));
+ }
+ a->alloced = nlimbs;
+}
+
+void
+_gcry_mpi_clear( gcry_mpi_t a )
+{
+ a->nlimbs = 0;
+ a->flags = 0;
+}
+
+
+void
+_gcry_mpi_free( gcry_mpi_t a )
+{
+ if (!a )
+ return;
+ if ((a->flags & 4))
+ gcry_free( a->d );
+ else
+ {
+ _gcry_mpi_free_limb_space(a->d, a->alloced);
+ }
+ if ((a->flags & ~7))
+ log_bug("invalid flag value in mpi\n");
+ gcry_free(a);
+}
+
+static void
+mpi_set_secure( gcry_mpi_t a )
+{
+ mpi_ptr_t ap, bp;
+
+ if ( (a->flags & 1) )
+ return;
+ a->flags |= 1;
+ ap = a->d;
+ if (!a->nlimbs)
+ {
+ gcry_assert (!ap);
+ return;
+ }
+ bp = mpi_alloc_limb_space (a->nlimbs, 1);
+ MPN_COPY( bp, ap, a->nlimbs );
+ a->d = bp;
+ _gcry_mpi_free_limb_space (ap, a->alloced);
+}
+
+
+gcry_mpi_t
+gcry_mpi_set_opaque( gcry_mpi_t a, void *p, unsigned int nbits )
+{
+ if (!a)
+ a = mpi_alloc(0);
+
+ if( a->flags & 4 )
+ gcry_free( a->d );
+ else
+ _gcry_mpi_free_limb_space (a->d, a->alloced);
+
+ a->d = p;
+ a->alloced = 0;
+ a->nlimbs = 0;
+ a->sign = nbits;
+ a->flags = 4;
+ return a;
+}
+
+
+void *
+gcry_mpi_get_opaque( gcry_mpi_t a, unsigned int *nbits )
+{
+ if( !(a->flags & 4) )
+ log_bug("mpi_get_opaque on normal mpi\n");
+ if( nbits )
+ *nbits = a->sign;
+ return a->d;
+}
+
+
+/****************
+ * Note: This copy function should not interpret the MPI
+ * but copy it transparently.
+ */
+gcry_mpi_t
+gcry_mpi_copy( gcry_mpi_t a )
+{
+ int i;
+ gcry_mpi_t b;
+
+ if( a && (a->flags & 4) ) {
+ void *p = gcry_is_secure(a->d)? gcry_xmalloc_secure( (a->sign+7)/8 )
+ : gcry_xmalloc( (a->sign+7)/8 );
+ memcpy( p, a->d, (a->sign+7)/8 );
+ b = gcry_mpi_set_opaque( NULL, p, a->sign );
+ }
+ else if( a ) {
+ b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
+ : mpi_alloc( a->nlimbs );
+ b->nlimbs = a->nlimbs;
+ b->sign = a->sign;
+ b->flags = a->flags;
+ for(i=0; i < b->nlimbs; i++ )
+ b->d[i] = a->d[i];
+ }
+ else
+ b = NULL;
+ return b;
+}
+
+
+/****************
+ * This function allocates an MPI which is optimized to hold
+ * a value as large as the one given in the argument and allocates it
+ * with the same flags as A.
+ */
+gcry_mpi_t
+_gcry_mpi_alloc_like( gcry_mpi_t a )
+{
+ gcry_mpi_t b;
+
+ if( a && (a->flags & 4) ) {
+ int n = (a->sign+7)/8;
+ void *p = gcry_is_secure(a->d)? gcry_malloc_secure( n )
+ : gcry_malloc( n );
+ memcpy( p, a->d, n );
+ b = gcry_mpi_set_opaque( NULL, p, a->sign );
+ }
+ else if( a ) {
+ b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
+ : mpi_alloc( a->nlimbs );
+ b->nlimbs = 0;
+ b->sign = 0;
+ b->flags = a->flags;
+ }
+ else
+ b = NULL;
+ return b;
+}
+
+
+gcry_mpi_t
+gcry_mpi_set( gcry_mpi_t w, gcry_mpi_t u)
+{
+ mpi_ptr_t wp, up;
+ mpi_size_t usize = u->nlimbs;
+ int usign = u->sign;
+
+ if (!w)
+ w = _gcry_mpi_alloc( mpi_get_nlimbs(u) );
+ RESIZE_IF_NEEDED(w, usize);
+ wp = w->d;
+ up = u->d;
+ MPN_COPY( wp, up, usize );
+ w->nlimbs = usize;
+ w->flags = u->flags;
+ w->sign = usign;
+ return w;
+}
+
+
+gcry_mpi_t
+gcry_mpi_set_ui( gcry_mpi_t w, unsigned long u)
+{
+ if (!w)
+ w = _gcry_mpi_alloc (1);
+ /* FIXME: If U is 0 we have no need to resize and thus possible
+ allocating the the limbs. */
+ RESIZE_IF_NEEDED(w, 1);
+ w->d[0] = u;
+ w->nlimbs = u? 1:0;
+ w->sign = 0;
+ w->flags = 0;
+ return w;
+}
+
+gcry_err_code_t
+_gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ unsigned long x = 0;
+
+ if (w->nlimbs > 1)
+ err = GPG_ERR_TOO_LARGE;
+ else if (w->nlimbs == 1)
+ x = w->d[0];
+ else
+ x = 0;
+
+ if (! err)
+ *u = x;
+
+ return err;
+}
+
+gcry_error_t
+gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ err = _gcry_mpi_get_ui (w, u);
+
+ return gcry_error (err);
+}
+
+gcry_mpi_t
+_gcry_mpi_alloc_set_ui( unsigned long u)
+{
+ gcry_mpi_t w = mpi_alloc(1);
+ w->d[0] = u;
+ w->nlimbs = u? 1:0;
+ w->sign = 0;
+ return w;
+}
+
+void
+gcry_mpi_swap( gcry_mpi_t a, gcry_mpi_t b)
+{
+ struct gcry_mpi tmp;
+
+ tmp = *a; *a = *b; *b = tmp;
+}
+
+
+gcry_mpi_t
+gcry_mpi_new( unsigned int nbits )
+{
+ return _gcry_mpi_alloc ( (nbits+BITS_PER_MPI_LIMB-1)
+ / BITS_PER_MPI_LIMB );
+}
+
+
+gcry_mpi_t
+gcry_mpi_snew( unsigned int nbits )
+{
+ return _gcry_mpi_alloc_secure ( (nbits+BITS_PER_MPI_LIMB-1)
+ / BITS_PER_MPI_LIMB );
+}
+
+void
+gcry_mpi_release( gcry_mpi_t a )
+{
+ _gcry_mpi_free( a );
+}
+
+
+
+void
+gcry_mpi_set_flag( gcry_mpi_t a, enum gcry_mpi_flag flag )
+{
+ switch( flag ) {
+ case GCRYMPI_FLAG_SECURE: mpi_set_secure(a); break;
+ case GCRYMPI_FLAG_OPAQUE:
+ default: log_bug("invalid flag value\n");
+ }
+}
+
+void
+gcry_mpi_clear_flag( gcry_mpi_t a, enum gcry_mpi_flag flag )
+{
+ (void)a; /* Not yet used. */
+
+ switch (flag)
+ {
+ case GCRYMPI_FLAG_SECURE:
+ case GCRYMPI_FLAG_OPAQUE:
+ default: log_bug("invalid flag value\n");
+ }
+}
+
+int
+gcry_mpi_get_flag( gcry_mpi_t a, enum gcry_mpi_flag flag )
+{
+ switch (flag)
+ {
+ case GCRYMPI_FLAG_SECURE: return (a->flags & 1);
+ case GCRYMPI_FLAG_OPAQUE: return (a->flags & 4);
+ default: log_bug("invalid flag value\n");
+ }
+ /*NOTREACHED*/
+ return 0;
+}
diff --git a/grub-core/lib/libgcrypt-grub/src/ath.h b/grub-core/lib/libgcrypt-grub/src/ath.h
new file mode 100644
index 0000000..8769551
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/ath.h
@@ -0,0 +1,147 @@
+/* ath.h - Thread-safeness library.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+ This file is part of Libgcrypt.
+
+ Libgcrypt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Libgcrypt is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Libgcrypt; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#ifndef ATH_H
+#define ATH_H
+
+#include <config.h>
+
+#ifdef _WIN32
+# include <windows.h>
+#else /* !_WIN32 */
+# ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+# else
+# include <sys/time.h>
+# endif
+# include <sys/types.h>
+# ifdef HAVE_SYS_MSG_H
+# include <sys/msg.h> /* (e.g. for zOS) */
+# endif
+# include <sys/socket.h>
+#endif /* !_WIN32 */
+#include <gpg-error.h>
+
+
+
+/* Define _ATH_EXT_SYM_PREFIX if you want to give all external symbols
+ a prefix. */
+#define _ATH_EXT_SYM_PREFIX _gcry_
+
+#ifdef _ATH_EXT_SYM_PREFIX
+#define _ATH_PREFIX1(x,y) x ## y
+#define _ATH_PREFIX2(x,y) _ATH_PREFIX1(x,y)
+#define _ATH_PREFIX(x) _ATH_PREFIX2(_ATH_EXT_SYM_PREFIX,x)
+#define ath_install _ATH_PREFIX(ath_install)
+#define ath_init _ATH_PREFIX(ath_init)
+#define ath_mutex_init _ATH_PREFIX(ath_mutex_init)
+#define ath_mutex_destroy _ATH_PREFIX(ath_mutex_destroy)
+#define ath_mutex_lock _ATH_PREFIX(ath_mutex_lock)
+#define ath_mutex_unlock _ATH_PREFIX(ath_mutex_unlock)
+#define ath_read _ATH_PREFIX(ath_read)
+#define ath_write _ATH_PREFIX(ath_write)
+#define ath_select _ATH_PREFIX(ath_select)
+#define ath_waitpid _ATH_PREFIX(ath_waitpid)
+#define ath_connect _ATH_PREFIX(ath_connect)
+#define ath_accept _ATH_PREFIX(ath_accept)
+#define ath_sendmsg _ATH_PREFIX(ath_sendmsg)
+#define ath_recvmsg _ATH_PREFIX(ath_recvmsg)
+#endif
+
+
+enum ath_thread_option
+ {
+ ATH_THREAD_OPTION_DEFAULT = 0,
+ ATH_THREAD_OPTION_USER = 1,
+ ATH_THREAD_OPTION_PTH = 2,
+ ATH_THREAD_OPTION_PTHREAD = 3
+ };
+
+struct ath_ops
+{
+ /* The OPTION field encodes the thread model and the version number
+ of this structure.
+ Bits 7 - 0 are used for the thread model
+ Bits 15 - 8 are used for the version number.
+ */
+ unsigned int option;
+
+ int (*init) (void);
+ int (*mutex_init) (void **priv);
+ int (*mutex_destroy) (void *priv);
+ int (*mutex_lock) (void *priv);
+ int (*mutex_unlock) (void *priv);
+ ssize_t (*read) (int fd, void *buf, size_t nbytes);
+ ssize_t (*write) (int fd, const void *buf, size_t nbytes);
+#ifdef _WIN32
+ ssize_t (*select) (int nfd, void *rset, void *wset, void *eset,
+ struct timeval *timeout);
+ ssize_t (*waitpid) (pid_t pid, int *status, int options);
+ int (*accept) (int s, void *addr, int *length_ptr);
+ int (*connect) (int s, void *addr, int length);
+ int (*sendmsg) (int s, const void *msg, int flags);
+ int (*recvmsg) (int s, void *msg, int flags);
+#else
+ ssize_t (*select) (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
+ struct timeval *timeout);
+ ssize_t (*waitpid) (pid_t pid, int *status, int options);
+ int (*accept) (int s, struct sockaddr *addr, socklen_t *length_ptr);
+ int (*connect) (int s, struct sockaddr *addr, socklen_t length);
+ int (*sendmsg) (int s, const struct msghdr *msg, int flags);
+ int (*recvmsg) (int s, struct msghdr *msg, int flags);
+#endif
+};
+
+gpg_err_code_t ath_install (struct ath_ops *ath_ops, int check_only);
+int ath_init (void);
+
+
+/* Functions for mutual exclusion. */
+typedef void *ath_mutex_t;
+#define ATH_MUTEX_INITIALIZER 0
+
+int ath_mutex_init (ath_mutex_t *mutex);
+int ath_mutex_destroy (ath_mutex_t *mutex);
+int ath_mutex_lock (ath_mutex_t *mutex);
+int ath_mutex_unlock (ath_mutex_t *mutex);
+
+/* Replacement for the POSIX functions, which can be used to allow
+ other (user-level) threads to run. */
+ssize_t ath_read (int fd, void *buf, size_t nbytes);
+ssize_t ath_write (int fd, const void *buf, size_t nbytes);
+#ifdef _WIN32
+ssize_t ath_select (int nfd, void *rset, void *wset, void *eset,
+ struct timeval *timeout);
+ssize_t ath_waitpid (pid_t pid, int *status, int options);
+int ath_accept (int s, void *addr, int *length_ptr);
+int ath_connect (int s, void *addr, int length);
+int ath_sendmsg (int s, const void *msg, int flags);
+int ath_recvmsg (int s, void *msg, int flags);
+#else
+ssize_t ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
+ struct timeval *timeout);
+ssize_t ath_waitpid (pid_t pid, int *status, int options);
+int ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr);
+int ath_connect (int s, struct sockaddr *addr, socklen_t length);
+int ath_sendmsg (int s, const struct msghdr *msg, int flags);
+int ath_recvmsg (int s, struct msghdr *msg, int flags);
+#endif
+
+#endif /* ATH_H */
diff --git a/grub-core/lib/libgcrypt-grub/src/cipher-proto.h b/grub-core/lib/libgcrypt-grub/src/cipher-proto.h
new file mode 100644
index 0000000..347681f
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/cipher-proto.h
@@ -0,0 +1,124 @@
+/* cipher-proto.h - Internal declarations
+ * Copyright (C) 2008, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This file has been factored out from cipher.h so that it can be
+ used standalone in visibility.c . */
+
+#ifndef G10_CIPHER_PROTO_H
+#define G10_CIPHER_PROTO_H
+
+/* Definition of a function used to report selftest failures.
+ DOMAIN is a string describing the function block:
+ "cipher", "digest", "pubkey or "random",
+ ALGO is the algorithm under test,
+ WHAT is a string describing what has been tested,
+ DESC is a string describing the error. */
+typedef void (*selftest_report_func_t)(const char *domain,
+ int algo,
+ const char *what,
+ const char *errdesc);
+
+/* Definition of the selftest functions. */
+typedef gpg_err_code_t (*selftest_func_t)
+ (int algo, int extended, selftest_report_func_t report);
+
+
+/* An extended type of the generate function. */
+typedef gcry_err_code_t (*pk_ext_generate_t)
+ (int algo,
+ unsigned int nbits,
+ unsigned long evalue,
+ gcry_sexp_t genparms,
+ gcry_mpi_t *skey,
+ gcry_mpi_t **retfactors,
+ gcry_sexp_t *extrainfo);
+
+/* The type used to compute the keygrip. */
+typedef gpg_err_code_t (*pk_comp_keygrip_t)
+ (gcry_md_hd_t md, gcry_sexp_t keyparm);
+
+/* The type used to query ECC curve parameters. */
+typedef gcry_err_code_t (*pk_get_param_t)
+ (const char *name, gcry_mpi_t *pkey);
+
+/* The type used to query an ECC curve name. */
+typedef const char *(*pk_get_curve_t)(gcry_mpi_t *pkey, int iterator,
+ unsigned int *r_nbits);
+
+/* The type used to query ECC curve parameters by name. */
+typedef gcry_sexp_t (*pk_get_curve_param_t)(const char *name);
+
+/* The type used to convey additional information to a cipher. */
+typedef gpg_err_code_t (*cipher_set_extra_info_t)
+ (void *c, int what, const void *buffer, size_t buflen);
+
+
+/* Extra module specification structures. These are used for internal
+ modules which provide more functions than available through the
+ public algorithm register APIs. */
+typedef struct cipher_extra_spec
+{
+ selftest_func_t selftest;
+ cipher_set_extra_info_t set_extra_info;
+} cipher_extra_spec_t;
+
+typedef struct md_extra_spec
+{
+ selftest_func_t selftest;
+} md_extra_spec_t;
+
+typedef struct pk_extra_spec
+{
+ selftest_func_t selftest;
+ pk_ext_generate_t ext_generate;
+ pk_comp_keygrip_t comp_keygrip;
+ pk_get_param_t get_param;
+ pk_get_curve_t get_curve;
+ pk_get_curve_param_t get_curve_param;
+} pk_extra_spec_t;
+
+
+
+/* The private register functions. */
+gcry_error_t _gcry_cipher_register (gcry_cipher_spec_t *cipher,
+ cipher_extra_spec_t *extraspec,
+ int *algorithm_id,
+ gcry_module_t *module);
+gcry_error_t _gcry_md_register (gcry_md_spec_t *cipher,
+ md_extra_spec_t *extraspec,
+ unsigned int *algorithm_id,
+ gcry_module_t *module);
+gcry_error_t _gcry_pk_register (gcry_pk_spec_t *cipher,
+ pk_extra_spec_t *extraspec,
+ unsigned int *algorithm_id,
+ gcry_module_t *module);
+
+/* The selftest functions. */
+gcry_error_t _gcry_cipher_selftest (int algo, int extended,
+ selftest_report_func_t report);
+gcry_error_t _gcry_md_selftest (int algo, int extended,
+ selftest_report_func_t report);
+gcry_error_t _gcry_pk_selftest (int algo, int extended,
+ selftest_report_func_t report);
+gcry_error_t _gcry_hmac_selftest (int algo, int extended,
+ selftest_report_func_t report);
+
+gcry_error_t _gcry_random_selftest (selftest_report_func_t report);
+
+#endif /*G10_CIPHER_PROTO_H*/
diff --git a/grub-core/lib/libgcrypt-grub/src/cipher.h b/grub-core/lib/libgcrypt-grub/src/cipher.h
new file mode 100644
index 0000000..48eeeda
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/cipher.h
@@ -0,0 +1,182 @@
+/* cipher.h
+ * Copyright (C) 1998, 2002, 2003, 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+#ifndef G10_CIPHER_H
+#define G10_CIPHER_H
+
+#include <gcrypt.h>
+
+#define DBG_CIPHER _gcry_get_debug_flag( 1 )
+
+#include "../random/random.h"
+
+#define PUBKEY_FLAG_NO_BLINDING (1 << 0)
+
+enum pk_operation
+ {
+ PUBKEY_OP_ENCRYPT,
+ PUBKEY_OP_DECRYPT,
+ PUBKEY_OP_SIGN,
+ PUBKEY_OP_VERIFY
+ };
+
+enum pk_encoding
+ {
+ PUBKEY_ENC_RAW,
+ PUBKEY_ENC_PKCS1,
+ PUBKEY_ENC_OAEP,
+ PUBKEY_ENC_PSS,
+ PUBKEY_ENC_UNKNOWN
+ };
+
+struct pk_encoding_ctx
+{
+ enum pk_operation op;
+ unsigned int nbits;
+
+ enum pk_encoding encoding;
+ int flags;
+
+ int hash_algo;
+
+ /* for OAEP */
+ unsigned char *label;
+ size_t labellen;
+
+ /* for PSS */
+ size_t saltlen;
+
+ int (* verify_cmp) (void *opaque, gcry_mpi_t tmp);
+ void *verify_arg;
+};
+
+#define CIPHER_INFO_NO_WEAK_KEY 1
+
+#include "cipher-proto.h"
+
+
+/*-- rmd160.c --*/
+void _gcry_rmd160_hash_buffer (void *outbuf,
+ const void *buffer, size_t length);
+/*-- sha1.c --*/
+void _gcry_sha1_hash_buffer (void *outbuf,
+ const void *buffer, size_t length);
+
+/*-- rijndael.c --*/
+void _gcry_aes_cfb_enc (void *context, unsigned char *iv,
+ void *outbuf, const void *inbuf,
+ unsigned int nblocks);
+void _gcry_aes_cfb_dec (void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks);
+void _gcry_aes_cbc_enc (void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks, int cbc_mac);
+void _gcry_aes_cbc_dec (void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks);
+void _gcry_aes_ctr_enc (void *context, unsigned char *ctr,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks);
+
+
+/*-- dsa.c --*/
+void _gcry_register_pk_dsa_progress (gcry_handler_progress_t cbc, void *cb_data);
+
+/*-- elgamal.c --*/
+void _gcry_register_pk_elg_progress (gcry_handler_progress_t cb,
+ void *cb_data);
+
+
+/*-- ecc.c --*/
+void _gcry_register_pk_ecc_progress (gcry_handler_progress_t cbc,
+ void *cb_data);
+
+
+/*-- primegen.c --*/
+void _gcry_register_primegen_progress (gcry_handler_progress_t cb,
+ void *cb_data);
+
+/*-- pubkey.c --*/
+const char * _gcry_pk_aliased_algo_name (int algorithm);
+
+/* Declarations for the cipher specifications. */
+extern gcry_cipher_spec_t _gcry_cipher_spec_blowfish;
+extern gcry_cipher_spec_t _gcry_cipher_spec_des;
+extern gcry_cipher_spec_t _gcry_cipher_spec_tripledes;
+extern gcry_cipher_spec_t _gcry_cipher_spec_arcfour;
+extern gcry_cipher_spec_t _gcry_cipher_spec_cast5;
+extern gcry_cipher_spec_t _gcry_cipher_spec_aes;
+extern gcry_cipher_spec_t _gcry_cipher_spec_aes192;
+extern gcry_cipher_spec_t _gcry_cipher_spec_aes256;
+extern gcry_cipher_spec_t _gcry_cipher_spec_twofish;
+extern gcry_cipher_spec_t _gcry_cipher_spec_twofish128;
+extern gcry_cipher_spec_t _gcry_cipher_spec_serpent128;
+extern gcry_cipher_spec_t _gcry_cipher_spec_serpent192;
+extern gcry_cipher_spec_t _gcry_cipher_spec_serpent256;
+extern gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_40;
+extern gcry_cipher_spec_t _gcry_cipher_spec_seed;
+extern gcry_cipher_spec_t _gcry_cipher_spec_camellia128;
+extern gcry_cipher_spec_t _gcry_cipher_spec_camellia192;
+extern gcry_cipher_spec_t _gcry_cipher_spec_camellia256;
+extern gcry_cipher_spec_t _gcry_cipher_spec_idea;
+
+extern cipher_extra_spec_t _gcry_cipher_extraspec_tripledes;
+extern cipher_extra_spec_t _gcry_cipher_extraspec_aes;
+extern cipher_extra_spec_t _gcry_cipher_extraspec_aes192;
+extern cipher_extra_spec_t _gcry_cipher_extraspec_aes256;
+
+
+/* Declarations for the digest specifications. */
+extern gcry_md_spec_t _gcry_digest_spec_crc32;
+extern gcry_md_spec_t _gcry_digest_spec_crc32_rfc1510;
+extern gcry_md_spec_t _gcry_digest_spec_crc24_rfc2440;
+extern gcry_md_spec_t _gcry_digest_spec_md4;
+extern gcry_md_spec_t _gcry_digest_spec_md5;
+extern gcry_md_spec_t _gcry_digest_spec_rmd160;
+extern gcry_md_spec_t _gcry_digest_spec_sha1;
+extern gcry_md_spec_t _gcry_digest_spec_sha224;
+extern gcry_md_spec_t _gcry_digest_spec_sha256;
+extern gcry_md_spec_t _gcry_digest_spec_sha512;
+extern gcry_md_spec_t _gcry_digest_spec_sha384;
+extern gcry_md_spec_t _gcry_digest_spec_tiger;
+extern gcry_md_spec_t _gcry_digest_spec_tiger1;
+extern gcry_md_spec_t _gcry_digest_spec_tiger2;
+extern gcry_md_spec_t _gcry_digest_spec_whirlpool;
+
+extern md_extra_spec_t _gcry_digest_extraspec_sha1;
+extern md_extra_spec_t _gcry_digest_extraspec_sha224;
+extern md_extra_spec_t _gcry_digest_extraspec_sha256;
+extern md_extra_spec_t _gcry_digest_extraspec_sha384;
+extern md_extra_spec_t _gcry_digest_extraspec_sha512;
+
+/* Declarations for the pubkey cipher specifications. */
+extern gcry_pk_spec_t _gcry_pubkey_spec_rsa;
+extern gcry_pk_spec_t _gcry_pubkey_spec_elg;
+extern gcry_pk_spec_t _gcry_pubkey_spec_dsa;
+extern gcry_pk_spec_t _gcry_pubkey_spec_ecdsa;
+extern gcry_pk_spec_t _gcry_pubkey_spec_ecdh;
+
+extern pk_extra_spec_t _gcry_pubkey_extraspec_rsa;
+extern pk_extra_spec_t _gcry_pubkey_extraspec_dsa;
+extern pk_extra_spec_t _gcry_pubkey_extraspec_elg;
+extern pk_extra_spec_t _gcry_pubkey_extraspec_ecdsa;
+
+
+#endif /*G10_CIPHER_H*/
diff --git a/grub-core/lib/libgcrypt-grub/src/g10lib.h b/grub-core/lib/libgcrypt-grub/src/g10lib.h
new file mode 100644
index 0000000..85a51be
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/g10lib.h
@@ -0,0 +1,302 @@
+/* g10lib.h - Internal definitions for libgcrypt
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
+ * 2007, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This header is to be used inside of libgcrypt in place of gcrypt.h.
+ This way we can better distinguish between internal and external
+ usage of gcrypt.h. */
+
+#ifndef G10LIB_H
+#define G10LIB_H 1
+
+#ifdef _GCRYPT_H
+#error gcrypt.h already included
+#endif
+
+#ifndef _GCRYPT_IN_LIBGCRYPT
+#error something is wrong with config.h
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "visibility.h"
+#include "types.h"
+
+
+
+
+/* Attribute handling macros. */
+
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
+#define JNLIB_GCC_M_FUNCTION 1
+#define JNLIB_GCC_A_NR __attribute__ ((noreturn))
+#define JNLIB_GCC_A_PRINTF( f, a ) __attribute__ ((format (__printf__,f,a)))
+#define JNLIB_GCC_A_NR_PRINTF( f, a ) \
+ __attribute__ ((noreturn, format (__printf__,f,a)))
+#define GCC_ATTR_NORETURN __attribute__ ((__noreturn__))
+#else
+#define JNLIB_GCC_A_NR
+#define JNLIB_GCC_A_PRINTF( f, a )
+#define JNLIB_GCC_A_NR_PRINTF( f, a )
+#define GCC_ATTR_NORETURN
+#endif
+
+#if __GNUC__ >= 3
+/* According to glibc this attribute is available since 2.8 however we
+ better play safe and use it only with gcc 3 or newer. */
+#define GCC_ATTR_FORMAT_ARG(a) __attribute__ ((format_arg (a)))
+#else
+#define GCC_ATTR_FORMAT_ARG(a)
+#endif
+
+
+/* Gettext macros. */
+
+/* Some handy macros */
+#ifndef STR
+#define STR(v) #v
+#endif
+#define STR2(v) STR(v)
+#define DIM(v) (sizeof(v)/sizeof((v)[0]))
+#define DIMof(type,member) DIM(((type *)0)->member)
+
+
+
+/*-- src/global.c -*/
+int _gcry_global_is_operational (void);
+gcry_error_t _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr);
+void _gcry_check_heap (const void *a);
+int _gcry_get_debug_flag (unsigned int mask);
+
+
+/*-- src/misc.c --*/
+
+#if defined(JNLIB_GCC_M_FUNCTION) || __STDC_VERSION__ >= 199901L
+void _gcry_bug (const char *file, int line,
+ const char *func) GCC_ATTR_NORETURN;
+void _gcry_assert_failed (const char *expr, const char *file, int line,
+ const char *func) GCC_ATTR_NORETURN;
+#else
+void _gcry_bug (const char *file, int line);
+void _gcry_assert_failed (const char *expr, const char *file, int line);
+#endif
+
+const char *_gcry_gettext (const char *key) GCC_ATTR_FORMAT_ARG(1);
+void _gcry_fatal_error(int rc, const char *text ) JNLIB_GCC_A_NR;
+void _gcry_log( int level, const char *fmt, ... ) JNLIB_GCC_A_PRINTF(2,3);
+void _gcry_log_bug( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2);
+void _gcry_log_fatal( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2);
+void _gcry_log_error( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
+void _gcry_log_info( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
+int _gcry_log_info_with_dummy_fp (FILE *fp, const char *fmt, ... )
+ JNLIB_GCC_A_PRINTF(2,3);
+void _gcry_log_debug( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
+void _gcry_log_printf ( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
+void _gcry_log_printhex (const char *text, const void *buffer, size_t length);
+
+void _gcry_set_log_verbosity( int level );
+int _gcry_log_verbosity( int level );
+
+#ifdef JNLIB_GCC_M_FUNCTION
+#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
+#define gcry_assert(expr) ((expr)? (void)0 \
+ : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
+#elif __STDC_VERSION__ >= 199901L
+#define BUG() _gcry_bug( __FILE__ , __LINE__, __func__ )
+#define gcry_assert(expr) ((expr)? (void)0 \
+ : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __func__))
+#else
+#define BUG() _gcry_bug( __FILE__ , __LINE__ )
+#define gcry_assert(expr) ((expr)? (void)0 \
+ : _gcry_assert_failed (STR(expr), __FILE__, __LINE__))
+#endif
+
+
+#define log_bug _gcry_log_bug
+#define log_fatal _gcry_log_fatal
+#define log_error _gcry_log_error
+#define log_info _gcry_log_info
+#define log_debug _gcry_log_debug
+#define log_printf _gcry_log_printf
+#define log_printhex _gcry_log_printhex
+
+
+/*-- src/hwfeatures.c --*/
+/* (Do not change these values unless synced with the asm code.) */
+#define HWF_PADLOCK_RNG 1
+#define HWF_PADLOCK_AES 2
+#define HWF_PADLOCK_SHA 4
+#define HWF_PADLOCK_MMUL 8
+
+#define HWF_INTEL_AESNI 256
+
+
+unsigned int _gcry_get_hw_features (void);
+void _gcry_detect_hw_features (unsigned int);
+
+
+/*-- mpi/mpiutil.c --*/
+const char *_gcry_mpi_get_hw_config (void);
+
+
+/*-- cipher/pubkey.c --*/
+
+/* FIXME: shouldn't this go into mpi.h? */
+#ifndef mpi_powm
+#define mpi_powm(w,b,e,m) gcry_mpi_powm( (w), (b), (e), (m) )
+#endif
+
+/*-- primegen.c --*/
+gcry_mpi_t _gcry_generate_secret_prime (unsigned int nbits,
+ gcry_random_level_t random_level,
+ int (*extra_check)(void*, gcry_mpi_t),
+ void *extra_check_arg);
+gcry_mpi_t _gcry_generate_public_prime (unsigned int nbits,
+ gcry_random_level_t random_level,
+ int (*extra_check)(void*, gcry_mpi_t),
+ void *extra_check_arg);
+gcry_mpi_t _gcry_generate_elg_prime (int mode,
+ unsigned int pbits, unsigned int qbits,
+ gcry_mpi_t g, gcry_mpi_t **factors);
+gcry_mpi_t _gcry_derive_x931_prime (const gcry_mpi_t xp,
+ const gcry_mpi_t xp1, const gcry_mpi_t xp2,
+ const gcry_mpi_t e,
+ gcry_mpi_t *r_p1, gcry_mpi_t *r_p2);
+gpg_err_code_t _gcry_generate_fips186_2_prime
+ (unsigned int pbits, unsigned int qbits,
+ const void *seed, size_t seedlen,
+ gcry_mpi_t *r_q, gcry_mpi_t *r_p,
+ int *r_counter,
+ void **r_seed, size_t *r_seedlen);
+gpg_err_code_t _gcry_generate_fips186_3_prime
+ (unsigned int pbits, unsigned int qbits,
+ const void *seed, size_t seedlen,
+ gcry_mpi_t *r_q, gcry_mpi_t *r_p,
+ int *r_counter,
+ void **r_seed, size_t *r_seedlen, int *r_hashalgo);
+
+
+/* Replacements of missing functions (missing-string.c). */
+#ifndef HAVE_STPCPY
+char *stpcpy (char *a, const char *b);
+#endif
+#ifndef HAVE_STRCASECMP
+int strcasecmp (const char *a, const char *b) _GCRY_GCC_ATTR_PURE;
+#endif
+
+
+/* Macros used to rename missing functions. */
+#ifndef HAVE_STRTOUL
+#define strtoul(a,b,c) ((unsigned long)strtol((a),(b),(c)))
+#endif
+#ifndef HAVE_MEMMOVE
+#define memmove(d, s, n) bcopy((s), (d), (n))
+#endif
+#ifndef HAVE_STRICMP
+#define stricmp(a,b) strcasecmp( (a), (b) )
+#endif
+#ifndef HAVE_ATEXIT
+#define atexit(a) (on_exit((a),0))
+#endif
+#ifndef HAVE_RAISE
+#define raise(a) kill(getpid(), (a))
+#endif
+
+
+/* Stack burning. */
+
+void _gcry_burn_stack (int bytes);
+
+
+/* To avoid that a compiler optimizes certain memset calls away, these
+ macros may be used instead. */
+#define wipememory2(_ptr,_set,_len) do { \
+ volatile char *_vptr=(volatile char *)(_ptr); \
+ size_t _vlen=(_len); \
+ while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
+ } while(0)
+#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
+
+
+
+/* Digit predicates. */
+
+#define digitp(p) (*(p) >= '0' && *(p) <= '9')
+#define octdigitp(p) (*(p) >= '0' && *(p) <= '7')
+#define alphap(a) ( (*(a) >= 'A' && *(a) <= 'Z') \
+ || (*(a) >= 'a' && *(a) <= 'z'))
+#define hexdigitp(a) (digitp (a) \
+ || (*(a) >= 'A' && *(a) <= 'F') \
+ || (*(a) >= 'a' && *(a) <= 'f'))
+
+
+/*-- sexp.c --*/
+gcry_error_t _gcry_sexp_vbuild (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, va_list arg_ptr);
+char *_gcry_sexp_nth_string (const gcry_sexp_t list, int number);
+
+
+/*-- fips.c --*/
+
+void _gcry_initialize_fips_mode (int force);
+
+int _gcry_fips_mode (void);
+#define fips_mode() _gcry_fips_mode ()
+
+int _gcry_enforced_fips_mode (void);
+
+void _gcry_set_enforced_fips_mode (void);
+
+void _gcry_inactivate_fips_mode (const char *text);
+int _gcry_is_fips_mode_inactive (void);
+
+
+void _gcry_fips_signal_error (const char *srcfile,
+ int srcline,
+ const char *srcfunc,
+ int is_fatal,
+ const char *description);
+#ifdef JNLIB_GCC_M_FUNCTION
+# define fips_signal_error(a) \
+ _gcry_fips_signal_error (__FILE__, __LINE__, __FUNCTION__, 0, (a))
+# define fips_signal_fatal_error(a) \
+ _gcry_fips_signal_error (__FILE__, __LINE__, __FUNCTION__, 1, (a))
+#else
+# define fips_signal_error(a) \
+ _gcry_fips_signal_error (__FILE__, __LINE__, NULL, 0, (a))
+# define fips_signal_fatal_error(a) \
+ _gcry_fips_signal_error (__FILE__, __LINE__, NULL, 1, (a))
+#endif
+
+int _gcry_fips_is_operational (void);
+#define fips_is_operational() (_gcry_global_is_operational ())
+#define fips_not_operational() (GCRY_GPG_ERR_NOT_OPERATIONAL)
+
+int _gcry_fips_test_operational (void);
+int _gcry_fips_test_error_or_operational (void);
+
+gpg_err_code_t _gcry_fips_run_selftests (int extended);
+
+void _gcry_fips_noreturn (void);
+#define fips_noreturn() (_gcry_fips_noreturn ())
+
+
+
+#endif /* G10LIB_H */
diff --git a/grub-core/lib/libgcrypt-grub/src/gcrypt-module.h b/grub-core/lib/libgcrypt-grub/src/gcrypt-module.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/gcrypt-module.h
diff --git a/grub-core/lib/libgcrypt-grub/src/hmac256.h b/grub-core/lib/libgcrypt-grub/src/hmac256.h
new file mode 100644
index 0000000..df28e72
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/hmac256.h
@@ -0,0 +1,36 @@
+/* hmac256.h - Declarations for _gcry_hmac256
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef HMAC256_H
+#define HMAC256_H
+
+
+struct hmac256_context;
+typedef struct hmac256_context *hmac256_context_t;
+
+hmac256_context_t _gcry_hmac256_new (const void *key, size_t keylen);
+void _gcry_hmac256_update (hmac256_context_t hd, const void *buf, size_t len);
+const void *_gcry_hmac256_finalize (hmac256_context_t hd, size_t *r_dlen);
+void _gcry_hmac256_release (hmac256_context_t hd);
+
+int _gcry_hmac256_file (void *result, size_t resultsize, const char *filename,
+ const void *key, size_t keylen);
+
+
+#endif /*HMAC256_H*/
diff --git a/grub-core/lib/libgcrypt-grub/src/mpi.h b/grub-core/lib/libgcrypt-grub/src/mpi.h
new file mode 100644
index 0000000..5883196
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/mpi.h
@@ -0,0 +1,266 @@
+/* mpi.h - Multi Precision Integers
+ * Copyright (C) 1994, 1996, 1998,
+ * 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#ifndef G10_MPI_H
+#define G10_MPI_H
+
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "types.h"
+#include "../mpi/mpi-asm-defs.h"
+
+#include "g10lib.h"
+
+#ifndef _GCRYPT_IN_LIBGCRYPT
+#error this file should only be used inside libgcrypt
+#endif
+
+#ifndef BITS_PER_MPI_LIMB
+#if BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_INT
+ typedef unsigned int mpi_limb_t;
+ typedef signed int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_LONG
+ typedef unsigned long int mpi_limb_t;
+ typedef signed long int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_LONG_LONG
+ typedef unsigned long long int mpi_limb_t;
+ typedef signed long long int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_SHORT
+ typedef unsigned short int mpi_limb_t;
+ typedef signed short int mpi_limb_signed_t;
+#else
+#error BYTES_PER_MPI_LIMB does not match any C type
+#endif
+#define BITS_PER_MPI_LIMB (8*BYTES_PER_MPI_LIMB)
+#endif /*BITS_PER_MPI_LIMB*/
+
+#define DBG_MPI _gcry_get_debug_flag( 2 );
+
+struct gcry_mpi
+{
+ int alloced; /* Array size (# of allocated limbs). */
+ int nlimbs; /* Number of valid limbs. */
+ int sign; /* Indicates a negative number and is also used
+ for opaque MPIs to store the length. */
+ unsigned int flags; /* Bit 0: Array to be allocated in secure memory space.*/
+ /* Bit 2: the limb is a pointer to some m_alloced data.*/
+ mpi_limb_t *d; /* Array with the limbs */
+};
+
+#define MPI_NULL NULL
+
+#define mpi_get_nlimbs(a) ((a)->nlimbs)
+#define mpi_is_neg(a) ((a)->sign)
+
+/*-- mpiutil.c --*/
+
+#ifdef M_DEBUG
+# define mpi_alloc(n) _gcry_mpi_debug_alloc((n), M_DBGINFO( __LINE__ ) )
+# define mpi_alloc_secure(n) _gcry_mpi_debug_alloc_secure((n), M_DBGINFO( __LINE__ ) )
+# define mpi_free(a) _gcry_mpi_debug_free((a), M_DBGINFO(__LINE__) )
+# define mpi_resize(a,b) _gcry_mpi_debug_resize((a),(b), M_DBGINFO(__LINE__) )
+# define mpi_copy(a) _gcry_mpi_debug_copy((a), M_DBGINFO(__LINE__) )
+ gcry_mpi_t _gcry_mpi_debug_alloc( unsigned nlimbs, const char *info );
+ gcry_mpi_t _gcry_mpi_debug_alloc_secure( unsigned nlimbs, const char *info );
+ void _gcry_mpi_debug_free( gcry_mpi_t a, const char *info );
+ void _gcry_mpi_debug_resize( gcry_mpi_t a, unsigned nlimbs, const char *info );
+ gcry_mpi_t _gcry_mpi_debug_copy( gcry_mpi_t a, const char *info );
+#else
+# define mpi_alloc(n) _gcry_mpi_alloc((n) )
+# define mpi_alloc_secure(n) _gcry_mpi_alloc_secure((n) )
+# define mpi_free(a) _gcry_mpi_free((a) )
+# define mpi_resize(a,b) _gcry_mpi_resize((a),(b))
+# define mpi_copy(a) _gcry_mpi_copy((a))
+ gcry_mpi_t _gcry_mpi_alloc( unsigned nlimbs );
+ gcry_mpi_t _gcry_mpi_alloc_secure( unsigned nlimbs );
+ void _gcry_mpi_free( gcry_mpi_t a );
+ void _gcry_mpi_resize( gcry_mpi_t a, unsigned nlimbs );
+ gcry_mpi_t _gcry_mpi_copy( gcry_mpi_t a );
+#endif
+
+#define gcry_mpi_copy _gcry_mpi_copy
+
+#define mpi_is_opaque(a) ((a) && ((a)->flags&4))
+#define mpi_is_secure(a) ((a) && ((a)->flags&1))
+#define mpi_clear(a) _gcry_mpi_clear ((a))
+#define mpi_alloc_like(a) _gcry_mpi_alloc_like((a))
+#define mpi_set(a,b) gcry_mpi_set ((a),(b))
+#define mpi_set_ui(a,b) gcry_mpi_set_ui ((a),(b))
+#define mpi_get_ui(a,b) _gcry_mpi_get_ui ((a),(b))
+#define mpi_alloc_set_ui(a) _gcry_mpi_alloc_set_ui ((a))
+#define mpi_m_check(a) _gcry_mpi_m_check ((a))
+#define mpi_swap(a,b) _gcry_mpi_swap ((a),(b))
+#define mpi_new(n) _gcry_mpi_new ((n))
+#define mpi_snew(n) _gcry_mpi_snew ((n))
+
+void _gcry_mpi_clear( gcry_mpi_t a );
+gcry_mpi_t _gcry_mpi_alloc_like( gcry_mpi_t a );
+gcry_mpi_t _gcry_mpi_alloc_set_ui( unsigned long u);
+gcry_err_code_t _gcry_mpi_get_ui (gcry_mpi_t w, ulong *u);
+gcry_err_code_t gcry_mpi_get_ui (gcry_mpi_t w, ulong *u);
+void _gcry_mpi_m_check( gcry_mpi_t a );
+void _gcry_mpi_swap( gcry_mpi_t a, gcry_mpi_t b);
+gcry_mpi_t _gcry_mpi_new (unsigned int nbits);
+gcry_mpi_t _gcry_mpi_snew (unsigned int nbits);
+
+/*-- mpicoder.c --*/
+void _gcry_log_mpidump( const char *text, gcry_mpi_t a );
+u32 _gcry_mpi_get_keyid( gcry_mpi_t a, u32 *keyid );
+byte *_gcry_mpi_get_buffer( gcry_mpi_t a, unsigned *nbytes, int *sign );
+byte *_gcry_mpi_get_secure_buffer( gcry_mpi_t a, unsigned *nbytes, int *sign );
+void _gcry_mpi_set_buffer ( gcry_mpi_t a, const void *buffer,
+ unsigned int nbytes, int sign );
+
+#define log_mpidump _gcry_log_mpidump
+
+/*-- mpi-add.c --*/
+#define mpi_add_ui(w,u,v) gcry_mpi_add_ui((w),(u),(v))
+#define mpi_add(w,u,v) gcry_mpi_add ((w),(u),(v))
+#define mpi_addm(w,u,v,m) gcry_mpi_addm ((w),(u),(v),(m))
+#define mpi_sub_ui(w,u,v) gcry_mpi_sub_ui ((w),(u),(v))
+#define mpi_sub(w,u,v) gcry_mpi_sub ((w),(u),(v))
+#define mpi_subm(w,u,v,m) gcry_mpi_subm ((w),(u),(v),(m))
+
+
+/*-- mpi-mul.c --*/
+#define mpi_mul_ui(w,u,v) gcry_mpi_mul_ui ((w),(u),(v))
+#define mpi_mul_2exp(w,u,v) gcry_mpi_mul_2exp ((w),(u),(v))
+#define mpi_mul(w,u,v) gcry_mpi_mul ((w),(u),(v))
+#define mpi_mulm(w,u,v,m) gcry_mpi_mulm ((w),(u),(v),(m))
+
+
+/*-- mpi-div.c --*/
+#define mpi_fdiv_r_ui(a,b,c) _gcry_mpi_fdiv_r_ui((a),(b),(c))
+#define mpi_fdiv_r(a,b,c) _gcry_mpi_fdiv_r((a),(b),(c))
+#define mpi_fdiv_q(a,b,c) _gcry_mpi_fdiv_q((a),(b),(c))
+#define mpi_fdiv_qr(a,b,c,d) _gcry_mpi_fdiv_qr((a),(b),(c),(d))
+#define mpi_tdiv_r(a,b,c) _gcry_mpi_tdiv_r((a),(b),(c))
+#define mpi_tdiv_qr(a,b,c,d) _gcry_mpi_tdiv_qr((a),(b),(c),(d))
+#define mpi_tdiv_q_2exp(a,b,c) _gcry_mpi_tdiv_q_2exp((a),(b),(c))
+#define mpi_divisible_ui(a,b) _gcry_mpi_divisible_ui((a),(b))
+
+ulong _gcry_mpi_fdiv_r_ui( gcry_mpi_t rem, gcry_mpi_t dividend, ulong divisor );
+void _gcry_mpi_fdiv_r( gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor );
+void _gcry_mpi_fdiv_q( gcry_mpi_t quot, gcry_mpi_t dividend, gcry_mpi_t divisor );
+void _gcry_mpi_fdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor );
+void _gcry_mpi_tdiv_r( gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t den);
+void _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t den);
+void _gcry_mpi_tdiv_q_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned count );
+int _gcry_mpi_divisible_ui(gcry_mpi_t dividend, ulong divisor );
+
+
+/*-- mpi-mod.c --*/
+#define mpi_mod(r,a,m) _gcry_mpi_mod ((r), (a), (m))
+#define mpi_barrett_init(m,f) _gcry_mpi_barrett_init ((m),(f))
+#define mpi_barrett_free(c) _gcry_mpi_barrett_free ((c))
+#define mpi_mod_barrett(r,a,c) _gcry_mpi_mod_barrett ((r), (a), (c))
+#define mpi_mul_barrett(r,u,v,c) _gcry_mpi_mul_barrett ((r), (u), (v), (c))
+
+void _gcry_mpi_mod (gcry_mpi_t r, gcry_mpi_t dividend, gcry_mpi_t divisor);
+
+/* Context used with Barrett reduction. */
+struct barrett_ctx_s;
+typedef struct barrett_ctx_s *mpi_barrett_t;
+
+mpi_barrett_t _gcry_mpi_barrett_init (gcry_mpi_t m, int copy);
+void _gcry_mpi_barrett_free (mpi_barrett_t ctx);
+void _gcry_mpi_mod_barrett (gcry_mpi_t r, gcry_mpi_t x, mpi_barrett_t ctx);
+void _gcry_mpi_mul_barrett (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v,
+ mpi_barrett_t ctx);
+
+
+
+/*-- mpi-gcd.c --*/
+
+/*-- mpi-mpow.c --*/
+#define mpi_mulpowm(a,b,c,d) _gcry_mpi_mulpowm ((a),(b),(c),(d))
+void _gcry_mpi_mulpowm( gcry_mpi_t res, gcry_mpi_t *basearray, gcry_mpi_t *exparray, gcry_mpi_t mod);
+
+/*-- mpi-cmp.c --*/
+#define mpi_cmp_ui(a,b) gcry_mpi_cmp_ui ((a),(b))
+#define mpi_cmp(a,b) gcry_mpi_cmp ((a),(b))
+int gcry_mpi_cmp_ui( gcry_mpi_t u, ulong v );
+int gcry_mpi_cmp( gcry_mpi_t u, gcry_mpi_t v );
+
+/*-- mpi-scan.c --*/
+#define mpi_trailing_zeros(a) _gcry_mpi_trailing_zeros ((a))
+int _gcry_mpi_getbyte( gcry_mpi_t a, unsigned idx );
+void _gcry_mpi_putbyte( gcry_mpi_t a, unsigned idx, int value );
+unsigned _gcry_mpi_trailing_zeros( gcry_mpi_t a );
+
+/*-- mpi-bit.c --*/
+#define mpi_normalize(a) _gcry_mpi_normalize ((a))
+#define mpi_get_nbits(a) gcry_mpi_get_nbits ((a))
+#define mpi_test_bit(a,b) gcry_mpi_test_bit ((a),(b))
+#define mpi_set_bit(a,b) gcry_mpi_set_bit ((a),(b))
+#define mpi_set_highbit(a,b) gcry_mpi_set_highbit ((a),(b))
+#define mpi_clear_bit(a,b) gcry_mpi_clear_bit ((a),(b))
+#define mpi_clear_highbit(a,b) gcry_mpi_clear_highbit ((a),(b))
+#define mpi_rshift(a,b,c) gcry_mpi_rshift ((a),(b),(c))
+#define mpi_lshift(a,b,c) gcry_mpi_lshift ((a),(b),(c))
+
+void _gcry_mpi_normalize( gcry_mpi_t a );
+
+/*-- mpi-inv.c --*/
+#define mpi_invm(a,b,c) gcry_mpi_invm ((a),(b),(c))
+
+/*-- ec.c --*/
+
+/* Object to represent a point in projective coordinates. */
+struct mpi_point_s;
+typedef struct mpi_point_s mpi_point_t;
+struct mpi_point_s
+{
+ gcry_mpi_t x;
+ gcry_mpi_t y;
+ gcry_mpi_t z;
+};
+
+/* Context used with elliptic curve functions. */
+struct mpi_ec_ctx_s;
+typedef struct mpi_ec_ctx_s *mpi_ec_t;
+
+void _gcry_mpi_ec_point_init (mpi_point_t *p);
+void _gcry_mpi_ec_point_free (mpi_point_t *p);
+mpi_ec_t _gcry_mpi_ec_init (gcry_mpi_t p, gcry_mpi_t a);
+void _gcry_mpi_ec_free (mpi_ec_t ctx);
+int _gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, mpi_point_t *point,
+ mpi_ec_t ctx);
+void _gcry_mpi_ec_dup_point (mpi_point_t *result,
+ mpi_point_t *point, mpi_ec_t ctx);
+void _gcry_mpi_ec_add_points (mpi_point_t *result,
+ mpi_point_t *p1, mpi_point_t *p2,
+ mpi_ec_t ctx);
+void _gcry_mpi_ec_mul_point (mpi_point_t *result,
+ gcry_mpi_t scalar, mpi_point_t *point,
+ mpi_ec_t ctx);
+
+
+
+#endif /*G10_MPI_H*/
diff --git a/grub-core/lib/libgcrypt-grub/src/secmem.h b/grub-core/lib/libgcrypt-grub/src/secmem.h
new file mode 100644
index 0000000..29e151a
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/secmem.h
@@ -0,0 +1,39 @@
+/* secmem.h - internal definitions for secmem
+ * Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef G10_SECMEM_H
+#define G10_SECMEM_H 1
+
+void _gcry_secmem_init (size_t npool);
+void _gcry_secmem_term (void);
+void *_gcry_secmem_malloc (size_t size) _GCRY_GCC_ATTR_MALLOC;
+void *_gcry_secmem_realloc (void *a, size_t newsize);
+void _gcry_secmem_free (void *a);
+void _gcry_secmem_dump_stats (void);
+void _gcry_secmem_set_flags (unsigned flags);
+unsigned _gcry_secmem_get_flags(void);
+int _gcry_private_is_secure (const void *p);
+
+/* Flags for _gcry_secmem_{set,get}_flags. */
+#define GCRY_SECMEM_FLAG_NO_WARNING (1 << 0)
+#define GCRY_SECMEM_FLAG_SUSPEND_WARNING (1 << 1)
+#define GCRY_SECMEM_FLAG_NOT_LOCKED (1 << 2)
+
+#endif /* G10_SECMEM_H */
diff --git a/grub-core/lib/libgcrypt-grub/src/stdmem.h b/grub-core/lib/libgcrypt-grub/src/stdmem.h
new file mode 100644
index 0000000..b476e7e
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/stdmem.h
@@ -0,0 +1,32 @@
+/* stdmem.h - internal definitions for stdmem
+ * Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef G10_STDMEM_H
+#define G10_STDMEM_H 1
+
+void _gcry_private_enable_m_guard(void);
+
+void *_gcry_private_malloc (size_t n) _GCRY_GCC_ATTR_MALLOC;
+void *_gcry_private_malloc_secure (size_t n) _GCRY_GCC_ATTR_MALLOC;
+void *_gcry_private_realloc (void *a, size_t n);
+void _gcry_private_check_heap (const void *a);
+void _gcry_private_free (void *a);
+
+#endif /* G10_STDMEM_H */
diff --git a/grub-core/lib/libgcrypt-grub/src/types.h b/grub-core/lib/libgcrypt-grub/src/types.h
new file mode 100644
index 0000000..f2c0abf
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/types.h
@@ -0,0 +1,128 @@
+/* types.h - some common typedefs
+ * Copyright (C) 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef GCRYPT_TYPES_H
+#define GCRYPT_TYPES_H
+
+
+/* The AC_CHECK_SIZEOF() in configure fails for some machines.
+ * we provide some fallback values here */
+#if !SIZEOF_UNSIGNED_SHORT
+#undef SIZEOF_UNSIGNED_SHORT
+#define SIZEOF_UNSIGNED_SHORT 2
+#endif
+#if !SIZEOF_UNSIGNED_INT
+#undef SIZEOF_UNSIGNED_INT
+#define SIZEOF_UNSIGNED_INT 4
+#endif
+#if !SIZEOF_UNSIGNED_LONG
+#undef SIZEOF_UNSIGNED_LONG
+#define SIZEOF_UNSIGNED_LONG 4
+#endif
+
+
+#include <sys/types.h>
+
+
+#ifndef HAVE_BYTE_TYPEDEF
+#undef byte /* maybe there is a macro with this name */
+/* Windows typedefs byte in the rpc headers. Avoid warning about
+ double definition. */
+#if !(defined(_WIN32) && defined(cbNDRContext))
+ typedef unsigned char byte;
+#endif
+#define HAVE_BYTE_TYPEDEF
+#endif
+
+#ifndef HAVE_USHORT_TYPEDEF
+#undef ushort /* maybe there is a macro with this name */
+ typedef unsigned short ushort;
+#define HAVE_USHORT_TYPEDEF
+#endif
+
+#ifndef HAVE_ULONG_TYPEDEF
+#undef ulong /* maybe there is a macro with this name */
+ typedef unsigned long ulong;
+#define HAVE_ULONG_TYPEDEF
+#endif
+
+#ifndef HAVE_U16_TYPEDEF
+#undef u16 /* maybe there is a macro with this name */
+#if SIZEOF_UNSIGNED_INT == 2
+ typedef unsigned int u16;
+#elif SIZEOF_UNSIGNED_SHORT == 2
+ typedef unsigned short u16;
+#else
+#error no typedef for u16
+#endif
+#define HAVE_U16_TYPEDEF
+#endif
+
+#ifndef HAVE_U32_TYPEDEF
+#undef u32 /* maybe there is a macro with this name */
+#if SIZEOF_UNSIGNED_INT == 4
+ typedef unsigned int u32;
+#elif SIZEOF_UNSIGNED_LONG == 4
+ typedef unsigned long u32;
+#else
+#error no typedef for u32
+#endif
+#define HAVE_U32_TYPEDEF
+#endif
+
+/****************
+ * Warning: Some systems segfault when this u64 typedef and
+ * the dummy code in cipher/md.c is not available. Examples are
+ * Solaris and IRIX.
+ */
+#ifndef HAVE_U64_TYPEDEF
+#undef u64 /* maybe there is a macro with this name */
+#if SIZEOF_UNSIGNED_INT == 8
+ typedef unsigned int u64;
+#define U64_C(c) (c ## U)
+#define HAVE_U64_TYPEDEF
+#elif SIZEOF_UNSIGNED_LONG == 8
+ typedef unsigned long u64;
+#define U64_C(c) (c ## UL)
+#define HAVE_U64_TYPEDEF
+#elif SIZEOF_UNSIGNED_LONG_LONG == 8
+ typedef unsigned long long u64;
+#define U64_C(c) (c ## ULL)
+#define HAVE_U64_TYPEDEF
+#elif SIZEOF_UINT64_T == 8
+ typedef uint64_t u64;
+#define U64_C(c) (UINT64_C(c))
+#define HAVE_U64_TYPEDEF
+#endif
+#endif
+
+typedef union {
+ int a;
+ short b;
+ char c[1];
+ long d;
+#ifdef HAVE_U64_TYPEDEF
+ u64 e;
+#endif
+
+
+} PROPERLY_ALIGNED_TYPE;
+
+#endif /*GCRYPT_TYPES_H*/
diff --git a/grub-core/lib/libgcrypt-grub/src/visibility.h b/grub-core/lib/libgcrypt-grub/src/visibility.h
new file mode 100644
index 0000000..d1fb018
--- /dev/null
+++ b/grub-core/lib/libgcrypt-grub/src/visibility.h
@@ -0,0 +1 @@
+# include <grub/gcrypt/gcrypt.h>
diff --git a/grub-core/lib/libgcrypt/cipher/ChangeLog b/grub-core/lib/libgcrypt/cipher/ChangeLog
new file mode 100644
index 0000000..1b3694f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/ChangeLog
@@ -0,0 +1,3990 @@
+2010-08-19 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Remove double release of the module.
+ Fixes bug#1263.
+
+2010-06-10 Jeff Johnson <n3npq@mac.com> (wk)
+
+ * ecc.c (ecc_generate_ext): Parse transient-key flag.
+ (generate_key): Add arg TRANSIENT_KEY and use it to set the random
+ level.
+
+2010-04-12 Brad Hards <bradh@frogmouth.net> (wk)
+
+ Spelling fixes.
+
+2010-03-26 Werner Koch <wk@g10code.com>
+
+ * tiger.c (asn): Unfetter the old TIGER from an OID.
+ (TIGER_CONTEXT): Add field VARIANT.
+ (tiger_init): Factor code out to ...
+ (do_init): New.
+ (tiger1_init, tiger2_init): New.
+ (_gcry_digest_spec_tiger1, _gcry_digest_spec_tiger2): New.
+ * md.c (digest_table): Add TIGER1 and TIGER2 variants.
+
+2009-12-11 Werner Koch <wk@g10code.com>
+
+ * sha256.c (Cho, Maj, Sum0, Sum1): Turn macros into inline
+ functions.
+ (transform): Partly unroll to interweave the chain variables
+
+ * sha512.c (ROTR, Ch, Maj, Sum0, Sum1): Turn macros into inline
+ functions.
+ (transform): Partly unroll to interweave the chain variables.
+ Suggested by Christian Grothoff.
+
+2009-12-10 Werner Koch <wk@g10code.com>
+
+ * Makefile.am (o_flag_munging): New.
+ (tiger.o, tiger.lo): Use it.
+
+ * cipher.c (do_ctr_encrypt): Add arg OUTBUFLEN. Check for
+ suitable value. Add check for valid inputlen. Wipe temporary
+ memory.
+ (do_ctr_decrypt): Likewise.
+ (do_cbc_encrypt, do_cbc_decrypt): Add arg OUTBUFLEN. Check for
+ suitable value. Move check for valid inputlen to here; change
+ returned error from INV_ARG to INV_LENGTH.
+ (do_ecb_encrypt, do_ecb_decrypt): Ditto.
+ (do_cfb_encrypt, do_cfb_decrypt): Ditto.
+ (do_ofb_encrypt, do_ofb_decrypt): Ditto.
+ (cipher_encrypt, cipher_encrypt): Adjust for above changes.
+ (gcry_cipher_encrypt, gcry_cipher_decrypt): Simplify.
+
+2009-12-09 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Allow for GCRY_CIPHER_MODE_AESWRAP.
+ (cipher_encrypt, cipher_decrypt): Ditto.
+ (do_aeswrap_encrypt, do_aeswrap_decrypt): New.
+ (struct gcry_cipher_handle): Add field marks.
+ (cipher_setkey, cipher_setiv): Update marks flags.
+ (cipher_reset): Reset marks.
+ (cipher_encrypt, cipher_decrypt): Add new arg OUTBUFLEN.
+ (gcry_cipher_encrypt, gcry_cipher_decrypt): Pass outbuflen to
+ cipher_encrypt. Replace GPG_ERR_TOO_SHORT by
+ GPG_ERR_BUFFER_TOO_SHORT.
+
+2009-08-21 Werner Koch <wk@g10code.com>
+
+ * dsa.c (dsa_generate_ext): Release retfactors array before
+ setting it to NULL. Reported by Daiko Ueno.
+
+2009-07-02 Werner Koch <wk@g10code.com>
+
+ * md.c (md_read): Fix incomplete check for NULL.
+ Reported by Fabian Kail.
+
+2009-03-31 Werner Koch <wk@g10code.com>
+
+ * rsa.c (rsa_check_secret_key): Return GPG_ERR_BAD_SECKEY and not
+ GPG_ERR_PUBKEY_ALGO.
+
+2009-02-16 Werner Koch <wk@g10code.com>
+
+ * rsa.c (generate_x931): Do not initialize TBL with automatic
+ variables.
+ * whirlpool.c, tiger.c, sha256.c, sha1.c, rmd160.c, md5.c
+ * md4.c, crc.c: Remove memory.h. This is garbage from gnupg.
+ Reported by Dan Fandrich.
+
+2009-01-22 Werner Koch <wk@g10code.com>
+
+ * ecc.c (compute_keygrip): Remove superfluous const.
+
+2009-01-06 Werner Koch <wk@g10code.com>
+
+ * rmd160.c (oid_spec_rmd160): Add TeleTrust identifier.
+
+2008-12-10 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate): Add arg DOMAIN and use it if specified.
+ (generate_fips186): Ditto.
+ (dsa_generate_ext): Parse and check the optional "domain"
+ parameter and pass them to the generate functions.
+
+ * rijndael.c (rijndael_names): Add "AES128" and "AES-128".
+ (rijndael192_names): Add "AES-192".
+ (rijndael256_names): Add "AES-256".
+
+2008-12-05 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate): Add arg TRANSIENT_KEY and use it to detrmine
+ the RNG quality needed.
+ (dsa_generate_ext): Parse the transient-key flag und pass it to
+ generate.
+
+2008-11-28 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate_fips186): Add arg DERIVEPARMS and use the seed
+ value if available.
+
+ * primegen.c (_gcry_generate_fips186_2_prime): Fix inner p loop.
+
+2008-11-26 Werner Koch <wk@g10code.com>
+
+ * primegen.c (_gcry_generate_fips186_3_prime): New.
+ * dsa.c (generate_fips186): Add arg USE_FIPS186_2.
+ (dsa_generate_ext): Parse new flag use-fips183-2.
+
+2008-11-25 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate_fips186): New.
+ (dsa_generate_ext): Use new function if derive-parms are given or
+ if in FIPS mode.
+ * primegen.c (_gcry_generate_fips186_2_prime): New.
+
+2008-11-24 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Insert code to output extrainfo.
+ (pubkey_generate): Add arg R_EXTRAINFO and pass it to the extended
+ key generation function.
+ * rsa.c (gen_x931_parm_xp, gen_x931_parm_xi): New.
+ (generate_x931): Generate params if not given.
+ (rsa_generate_ext): Parse use-x931 flag. Return p-q-swapped
+ indicator.
+ * dsa.c (dsa_generate_ext): Put RETFACTORS into R_EXTRAINFO if
+ possible.
+
+ * pubkey.c (gcry_pk_genkey): Remove parsing of almost all
+ parameters and pass the parameter S-expression to pubkey_generate.
+ (pubkey_generate): Simplify by requitring modules to parse the
+ parameters. Remove the special cases for Elgamal and ECC.
+ (sexp_elements_extract_ecc): Add arg EXTRASPEC and use it. Fix
+ small memory leak.
+ (sexp_to_key): Pass EXTRASPEC to sexp_elements_extract_ecc.
+ (pubkey_table) [USE_ELGAMAL]: Add real extraspec.
+ * rsa.c (rsa_generate_ext): Adjust for new calling convention.
+ * dsa.c (dsa_generate_ext): Ditto.
+ * elgamal.c (_gcry_elg_generate): Ditto. Rename to elg_generate_ext.
+ (elg_generate): New.
+ (_gcry_elg_generate_using_x): Remove after merging code with
+ elg_generate_ext.
+ (_gcry_pubkey_extraspec_elg): New.
+ (_gcry_elg_check_secret_key, _gcry_elg_encrypt, _gcry_elg_sign)
+ (_gcry_elg_verify, _gcry_elg_get_nbits): Make static and remove
+ _gcry_ prefix.
+ * ecc.c (_gcry_ecc_generate): Rename to ecc_generate_ext and
+ adjust for new calling convention.
+ (_gcry_ecc_get_param): Rename to ecc_get_param and make static.
+ (_gcry_pubkey_extraspec_ecdsa): Add ecc_generate_ext and
+ ecc_get_param.
+
+2008-11-20 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pubkey_generate): Add arg DERIVEPARMS.
+ (gcry_pk_genkey): Parse derive-parms and pass it to above.
+ * rsa.c (generate_x931): New.
+ (rsa_generate_ext): Add arg DERIVEPARMS and call new function in
+ fips mode or if DERIVEPARMS is given.
+ * primegen.c (_gcry_derive_x931_prime, find_x931_prime): New.
+
+2008-11-19 Werner Koch <wk@g10code.com>
+
+ * rsa.c (rsa_decrypt): Use gcry_create_nonce for blinding.
+ (generate): Rename to generate_std.
+
+2008-11-05 Werner Koch <wk@g10code.com>
+
+ * md.c (md_open): Use a switch to set the Bsize.
+ (prepare_macpads): Fix long key case for SHA384 and SHA512.
+
+ * cipher.c (gcry_cipher_handle): Add field EXTRASPEC.
+ (gcry_cipher_open): Set it.
+ (gcry_cipher_ctl): Add private control code to disable weak key
+ detection and to return the current input block.
+ * des.c (_tripledes_ctx): Add field FLAGS.
+ (do_tripledes_set_extra_info): New.
+ (_gcry_cipher_extraspec_tripledes): Add new function.
+ (do_tripledes_setkey): Disable weak key detection.
+
+2008-10-24 Werner Koch <wk@g10code.com>
+
+ * md.c (digest_table): Allow MD5 in fips mode.
+ (md_register_default): Take special action for MD5.
+ (md_enable, gcry_md_hash_buffer): Ditto.
+
+2008-09-30 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (do_setkey): Properly align "t" and "tk".
+ (prepare_decryption): Properly align "w". Fixes bug #936.
+
+2008-09-18 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Parse domain parameter.
+ (pubkey_generate): Add new arg DOMAIN and remove special case for
+ DSA with qbits.
+ * rsa.c (rsa_generate): Add dummy args QBITS, NAME and DOMAIN and
+ rename to rsa_generate_ext. Change caller.
+ (_gcry_rsa_generate, _gcry_rsa_check_secret_key)
+ (_gcry_rsa_encrypt, _gcry_rsa_decrypt, _gcry_rsa_sign)
+ (_gcry_rsa_verify, _gcry_rsa_get_nbits): Make static and remove
+ _gcry_ prefix.
+ (_gcry_pubkey_spec_rsa, _gcry_pubkey_extraspec_rsa): Adjust names.
+ * dsa.c (dsa_generate_ext): New.
+ (_gcry_dsa_generate): Replace code by a call to dsa_generate.
+ (_gcry_dsa_check_secret_key, _gcry_dsa_sign, _gcry_dsa_verify)
+ (_gcry_dsa_get_nbits): Make static and remove _gcry prefix.
+ (_gcry_dsa_generate2): Remove.
+ (_gcry_pubkey_spec_dsa): Adjust to name changes.
+ (_gcry_pubkey_extraspec_rsa): Add dsa_generate_ext.
+
+2008-09-16 Werner Koch <wk@g10code.com>
+
+ * ecc.c (run_selftests): Add arg EXTENDED.
+
+2008-09-12 Werner Koch <wk@g10code.com>
+
+ * rsa.c (test_keys): Do a bad case signature check.
+ * dsa.c (test_keys): Do a bad case check.
+
+ * cipher.c (_gcry_cipher_selftest): Add arg EXTENDED and pass it
+ to the called tests.
+ * md.c (_gcry_md_selftest): Ditto.
+ * pubkey.c (_gcry_pk_selftest): Ditto.
+ * rijndael.c (run_selftests): Add arg EXTENDED and pass it to the
+ called tests.
+ (selftest_fips_128): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftest_fips_192): Add dummy arg EXTENDED.
+ (selftest_fips_256): Ditto.
+ * hmac-tests.c (_gcry_hmac_selftest): Ditto.
+ (run_selftests): Ditto.
+ (selftests_sha1): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftests_sha224, selftests_sha256): Ditto.
+ (selftests_sha384, selftests_sha512): Ditto.
+ * sha1.c (run_selftests): Add arg EXTENDED and pass it to the
+ called test.
+ (selftests_sha1): Add arg EXTENDED and run only one test
+ non-extended mode.
+ * sha256.c (run_selftests): Add arg EXTENDED and pass it to the
+ called tests.
+ (selftests_sha224): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftests_sha256): Ditto.
+ * sha512.c (run_selftests): Add arg EXTENDED and pass it to the
+ called tests.
+ (selftests_sha384): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftests_sha512): Ditto.
+ * des.c (run_selftests): Add arg EXTENDED and pass it to the
+ called test.
+ (selftest_fips): Add dummy arg EXTENDED.
+ * rsa.c (run_selftests): Add dummy arg EXTENDED.
+
+ * dsa.c (run_selftests): Add dummy arg EXTENDED.
+
+ * rsa.c (extract_a_from_sexp): New.
+ (selftest_encr_1024): Check that the ciphertext does not match the
+ plaintext.
+ (test_keys): Improve tests and return an error status.
+ (generate): Return an error if test_keys fails.
+ * dsa.c (test_keys): Add comments and return an error status.
+ (generate): Return an error if test_keys failed.
+
+2008-09-11 Werner Koch <wk@g10code.com>
+
+ * rsa.c (_gcry_rsa_decrypt): Return an error instead of calling
+ BUG in case of a practically impossible condition.
+ (sample_secret_key, sample_public_key): New.
+ (selftest_sign_1024, selftest_encr_1024): New.
+ (selftests_rsa): Implement tests.
+ * dsa.c (sample_secret_key, sample_public_key): New.
+ (selftest_sign_1024): New.
+ (selftests_dsa): Implement tests.
+
+2008-09-09 Werner Koch <wk@g10code.com>
+
+ * hmac-tests.c (selftests_sha1): Add tests.
+ (selftests_sha224, selftests_sha384, selftests_sha512): Make up tests.
+
+ * hash-common.c, hash-common.h: New.
+ * sha1.c (selftests_sha1): Add 3 tests.
+ * sha256.c (selftests_sha256, selftests_sha224): Ditto.
+ * sha512.c (selftests_sha512, selftests_sha384): Ditto.
+
+2008-08-29 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_get_keygrip): Remove the special case for RSA
+ and check whether a custom computation function has been setup.
+ * rsa.c (compute_keygrip): New.
+ (_gcry_pubkey_extraspec_rsa): Setup this function.
+ * ecc.c (compute_keygrip): New.
+ (_gcry_pubkey_extraspec_ecdsa): Setup this function.
+
+2008-08-28 Werner Koch <wk@g10code.com>
+
+ * cipher.c (cipher_decrypt, cipher_encrypt): Return an error if
+ mode NONE is used.
+ (gcry_cipher_open): Allow mode NONE only with a debug flag set and
+ if not in FIPS mode.
+
+2008-08-26 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pubkey_generate): Add arg KEYGEN_FLAGS.
+ (gcry_pk_genkey): Implement new parameter "transient-key" and
+ pass it as flags to pubkey_generate.
+ (pubkey_generate): Make use of an ext_generate function.
+ * rsa.c (generate): Add new arg transient_key and pass appropriate
+ args to the prime generator.
+ (_gcry_rsa_generate): Factor all code out to ...
+ (rsa_generate): .. new func with extra arg KEYGEN_FLAGS.
+ (_gcry_pubkey_extraspec_ecdsa): Setup rsa_generate.
+ * primegen.c (_gcry_generate_secret_prime)
+ (_gcry_generate_public_prime): Add new arg RANDOM_LEVEL.
+
+2008-08-21 Werner Koch <wk@g10code.com>
+
+ * primegen.c (_gcry_generate_secret_prime)
+ (_gcry_generate_public_prime): Use a constant macro for the random
+ level.
+
+2008-08-19 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_elements_extract_ecc) [!USE_ECC]: Do not allow
+ allow "curve" parameter.
+
+2008-08-15 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (_gcry_pk_selftest): New.
+ * dsa.c (selftests_dsa, run_selftests): New.
+ * rsa.c (selftests_rsa, run_selftests): New.
+ * ecc.c (selftests_ecdsa, run_selftests): New.
+
+ * md.c (_gcry_md_selftest): New.
+ * sha1.c (run_selftests, selftests_sha1): New.
+ * sha256.c (selftests_sha224, selftests_sha256, run_selftests): New.
+ * sha512.c (selftests_sha384, selftests_sha512, run_selftests): New.
+
+ * des.c (selftest): Remove static variable form selftest.
+ (des_setkey): No on-the-fly self test in fips mode.
+ (tripledes_set3keys): Ditto.
+
+ * cipher.c (_gcry_cipher_setkey, _gcry_cipher_setiv):
+
+ * dsa.c (generate): Bail out in fips mode if NBITS is less than 1024.
+ * rsa.c (generate): Return an error code if the the requested size
+ is less than 1024 and we are in fpis mode.
+ (_gcry_rsa_generate): Take care of that error code.
+
+ * ecc.c (generate_curve): In fips mode enable only NIST curves.
+
+ * cipher.c (_gcry_cipher_selftest): New.
+
+ * sha512.c (_gcry_digest_extraspec_sha384)
+ (_gcry_digest_extraspec_sha512): New.
+ * sha256.c (_gcry_digest_extraspec_sha224)
+ (_gcry_digest_extraspec_sha256): New.
+ * sha1.c (_gcry_digest_extraspec_sha1): New.
+ * ecc.c (_gcry_pubkey_extraspec_ecdsa): New.
+ * dsa.c (_gcry_pubkey_extraspec_dsa): New.
+ * rsa.c (_gcry_pubkey_extraspec_rsa): New.
+ * rijndael.c (_gcry_cipher_extraspec_aes)
+ (_gcry_cipher_extraspec_aes192, _gcry_cipher_extraspec_aes256): New.
+ * des.c (_gcry_cipher_extraspec_tripledes): New.
+
+ * cipher.c (gcry_cipher_register): Rename to _gcry_cipher_register.
+ Add arg EXTRASPEC.
+ (dummy_extra_spec): New.
+ (cipher_table_entry): Add extraspec field.
+ * md.c (_gcry_md_register): Rename to _gcry_md_register. Add
+ arg EXTRASPEC.
+ (dummy_extra_spec): New.
+ (digest_table_entry): Add extraspec field.
+ * pubkey.c (gcry_pk_register): Rename to _gcry_pk_register. Add
+ arg EXTRASPEC.
+ (dummy_extra_spec): New.
+ (pubkey_table_entry): Add extraspec field.
+
+ * ac.c: Let most public functions return GPG_ERR_UNSUPPORTED in
+ fips mode.
+
+ * pubkey.c (pubkey_table_entry): Add field FIPS_ALLOWED and mark
+ appropriate algorithms.
+ (dummy_generate, dummy_check_secret_key, dummy_encrypt)
+ (dummy_decrypt, dummy_sign, dummy_verify, dummy_get_nbits): Signal
+ a fips error when used.
+ (gcry_pk_register): In fips mode do not allow to register new
+ algorithms.
+
+ * md.c (digest_table): Add field FIPS_ALLOWED and mark appropriate
+ algorithms.
+ (md_register_default): In fips mode register only fips algorithms.
+ (gcry_md_register): In fips mode do not allow to register new
+ algorithms.
+ (gcry_md_get): Signal a fips error if called.
+ (gcry_md_hash_buffer): Do not allow rmd160 when not in fips mode.
+ (md_start_debug): Disable in fips_mode.
+
+ * md.c (gcry_md_register_default): Rename to ..
+ (md_register_default): .. this.
+ (md_digest): Remove this commented fucntion.
+ * pubkey.c (gcry_pk_register_default): Rename to ..
+ (pk_register_default): .. this.
+
+ * cipher.c (cipher_table_entry): Add field FIPS_ALLOWED.
+ (gcry_cipher_register_default): Register only fips approved
+ algorithms.
+ (gcry_cipher_register): Do not allow to register new ciphers.
+ (cipher_setiv): Signal fips error.
+
+ * cipher (gcry_cipher_register_default): Rename to ..
+ (cipher_register_default): .. this.
+ (REGISTER_DEFAULT_CIPHERS): Adjust for that change.
+
+2008-07-05 Werner Koch <wk@g10code.com>
+
+ * random-daemon.c, random.h, rndhw.c, rndunix.c, rand-internal.h
+ * random.c, rndegd.c, rndlinux.c, rndw32.c: Move to ../cipher.
+ * Makefile.am: Remove random stuff.
+
+2008-06-24 Szakats Istvan <szaki.ms@gmail.com> (wk)
+
+ * ac.c (_gcry_ac_key_destroy, _gcry_ac_key_pair_generate): Relase
+ some more memory.
+
+2008-04-22 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (_gcry_aes_cfb_enc, _gcry_aes_cbc_enc)
+ (_gcry_aes_cfb_dec, _gcry_aes_cbc_dec): Use Padlock if possible.
+
+2008-04-18 Werner Koch <wk@g10code.com>
+
+ * sha1.c (transform_aligned): Remove. That is will obviosuly not
+ work because we need a scratch working area and our internal API
+ does not allow to modify the buffers.
+
+ * rijndael.c: Factor tables out to ..
+ * rijndael-tables.h: .. new.
+
+ * ac.c (ac_data_extract): Make static.
+
+ * camellia.h [HAVE_CONFIG_H]: Include config.h.
+
+ * rndw32.c (registry_poll): Only print the performance data
+ problem warning once. Suggested by Simon Josefsson.
+
+2008-03-19 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open) [USE_AES]: Init bulk encryption only
+ if requested. Suggested by Dirk Stoecker.
+
+2008-03-18 Werner Koch <wk@g10code.com>
+
+ * sha1.c: Include stdint.h.
+ (transform): Add arg NBLOCKS so that we can work on more than one
+ block and avoid updates of the chaining variables. Changed all
+ callers to use 1.
+ (sha1_write): Replace loop around transform.
+ (transform_aligned) [WORDS_BIGENDIAN]: New.
+ (TRANSFORM): New macro to replace all direct calls of transform.
+
+2008-03-17 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (_gcry_aes_cfb_dec): New.
+ (do_encrypt): Factor code out to ..
+ (do_encrypt_aligned): .. New.
+ (_gcry_aes_cfb_enc, _gcry_aes_cfb_dec): Use new function.
+ (do_decrypt): Factor code out to ..
+ (do_decrypt_aligned): .. new.
+ (_gcry_aes_cbc_enc, _gcry_aes_cbc_dec): New.
+ * cipher.c (struct gcry_cipher_handle): Put field IV into new
+ union U_IV to enforce proper alignment. Change all users.
+ (do_cfb_decrypt): Optimize.
+ (do_cbc_encrypt, do_cbc_decrypt): Optimize.
+
+2008-03-15 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (_gcry_aes_cfb_enc): New.
+ * cipher.c (struct gcry_cipher_handle): Add field ALGO and BULK.
+ (gcry_cipher_open): Set ALGO and BULK.
+ (do_cfb_encrypt): Optimize.
+
+2008-02-18 Werner Koch <wk@g10code.com>
+
+ * rsa.c (_gcry_rsa_verify) [IS_DEVELOPMENT_VERSION]: Print
+ intermediate results.
+
+2008-01-08 Werner Koch <wk@g10code.com>
+
+ * random.c (add_randomness): Do not just increment
+ POOL_FILLED_COUNTER but update it by the actual amount of data.
+
+2007-12-13 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_data_to_mpi): Support SHA-224.
+
+2007-12-05 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (USE_PADLOCK): Depend on ENABLE_PADLOCK_SUPPORT.
+ * rndhw.c (USE_PADLOCK): Ditto
+
+ * rsa.c (secret): Fixed condition test for using CRT. Reported by
+ Dean Scarff. Fixes bug#864.
+ (_gcry_rsa_check_secret_key): Return an erro if the optional
+ parameters are missing.
+ * pubkey.c (sexp_elements_extract): Add arg ALGO_NAME. Changed all
+ callers to pass NULL. Add hack to allow for optional RSA
+ parameters.
+ (sexp_to_key): Pass algo name to sexp_elements_extract.
+
+2007-12-03 Werner Koch <wk@g10code.com>
+
+ * random.c (gcry_random_add_bytes): Implement it.
+ * rand-internal.h (RANDOM_ORIGIN_EXTERNAL): New.
+
+2007-11-30 Werner Koch <wk@g10code.com>
+
+ * rndhw.c: New.
+ * rndlinux.c (_gcry_rndlinux_gather_random): Try to read 50%
+ directly from the hwrng.
+ * random.c (do_fast_random_poll): Also run the hw rng fast poll.
+ (_gcry_random_dump_stats): Tell whether the hw rng failed.
+
+2007-11-29 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (USE_PADLOCK): Define new macro used for ia32.
+ (RIJNDAEL_context) [USE_PADLOCK]: Add fields USE_PADLOCK and
+ PADLOCK_KEY.
+ (do_setkey) [USE_PADLOCK]: Enable padlock if available for 128 bit
+ AES.
+ (do_padlock) [USE_PADLOCK]: New.
+ (rijndael_encrypt, rijndael_decrypt) [USE_PADLOCK]: Divert to
+ do_padlock.
+ * cipher.c (cipher_context_alignment_t): New. Use it in this
+ module in place of PROPERLY_ALIGNED_TYPE.
+ (NEED_16BYTE_ALIGNED_CONTEXT): Define macro for ia32.
+ (struct gcry_cipher_handle): Add field HANDLE_OFFSET.
+ (gcry_cipher_open): Take care of increased alignment requirements.
+ (gcry_cipher_close): Ditto.
+
+2007-11-28 Werner Koch <wk@g10code.com>
+
+ * sha256.c (asn224): Fixed wrong template. It happened due to a
+ bug in RFC4880. SHA-224 is not in the stable version of libgcrypt
+ so the consequences are limited to users of this devel version.
+
+2007-10-31 Werner Koch <wk@g10code.com>
+
+ * ac.c (gcry_ac_data_new): Remove due to the visibility wrapper.
+ (gcry_ac_data_destroy, gcry_ac_data_copy, gcry_ac_data_length)
+ (gcry_ac_data_set, gcry_ac_data_get_name, gcry_ac_data_get_index)
+ (gcry_ac_data_to_sexp, gcry_ac_data_from_sexp)
+ (gcry_ac_data_clear, gcry_ac_io_init, gcry_ac_open)
+ (gcry_ac_close, gcry_ac_key_init, gcry_ac_key_pair_generate)
+ (gcry_ac_key_pair_extract, gcry_ac_key_destroy)
+ (gcry_ac_key_pair_destroy, gcry_ac_key_data_get)
+ (gcry_ac_key_test, gcry_ac_key_get_nbits, gcry_ac_key_get_grip)
+ (gcry_ac_data_encrypt, gcry_ac_data_decrypt, gcry_ac_data_sign)
+ (gcry_ac_data_verify, gcry_ac_data_encode, gcry_ac_data_decode)
+ (gcry_ac_mpi_to_os, gcry_ac_mpi_to_os_alloc, gcry_ac_os_to_mpi)
+ (gcry_ac_data_encrypt_scheme, gcry_ac_data_decrypt_scheme)
+ (gcry_ac_data_sign_scheme, gcry_ac_data_verify_scheme)
+ (gcry_ac_io_init_va): Ditto.
+ (gcry_ac_id_to_name, gcry_ac_name_to_id): Remove as these
+ deprecated functions are now implemented by visibility.c.
+
+2007-10-26 Werner Koch <wk@g10code.com>
+
+ * rndw32.c: Disable debug flag.
+
+2007-10-25 Werner Koch <wk@g10code.com>
+
+ * rndw32.c: Updated from current cryptlib snapshot and modified
+ for our use. Removed support from pre NT systems.
+ (slow_gatherer_windows95): Remove.
+ (_gcry_rndw32_gather_random): Require an NT platform.
+ (init_system_rng, read_system_rng, read_mbm_data): New.
+ (slow_gatherer_windowsNT): Rename to ...
+ (slow_gatherer): .. this. Read system RNG and MBM.
+ (registry_poll): New with code factored out from slow_gatherer.
+
+2007-08-23 Werner Koch <wk@g10code.com>
+
+ * random.c (pool_filled_counter): New.
+ (add_randomness): Use it.
+
+2007-08-22 Werner Koch <wk@g10code.com>
+
+ * rndw32.c, rndunix.c: Switched to LGPL.
+
+2007-05-30 Werner Koch <wk@g10code.com>
+
+ * camellia.h, camellia.c: Replace by new LGPL version and adjusted
+ camellia.h.
+
+2007-05-09 Marcus Brinkmann <marcus@g10code.de>
+
+ * ac.c (_gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read):
+ Adjust users of gcry_ac_io_t because union is not anonymous
+ anymore.
+
+2007-05-02 Werner Koch <wk@g10code.com>
+
+ * camellia-glue.c (camellia_setkey, camellia_encrypt)
+ (camellia_decrypt): Recalculated used stack size in called
+ functions.
+ * camellia.h: Redefine external symbols.
+
+2007-05-02 David Shaw <dshaw@jabberwocky.com>
+
+ * Makefile.am, cipher.c: Add Camellia.
+
+ * camellia-glue.c: New. The necessary glue to interface libgcrypt
+ to the stock NTT Camellia distribution.
+
+ * camellia.h, camellia.c: The stock NTT Camellia distribution
+ (GPL).
+
+2007-04-30 David Shaw <dshaw@jabberwocky.com>
+
+ * cipher.c: Use #if instead of #ifdef as configure defines the
+ USE_cipher defines as 0 for disabled.
+
+2007-04-30 Werner Koch <wk@g10code.com>
+
+ * rndegd.c (_gcry_rndegd_set_socket_name): New.
+
+2007-04-30 Marcus Brinkmann <marcus@g10code.de>
+
+ * ecc.c (ec2os): Fix relocation of short numbers.
+
+ * ecc.c (generate_key): Do not allocate D, which will be allocated
+ by GEN_K. Remove G. Fix test if g_x, g_y resp. q_x, q_y are
+ requested.
+ (_gcry_ecc_generate): Release unneeded members of SK.
+ * pubkey.c (sexp_to_key): Release NAME.
+
+2007-04-28 Marcus Brinkmann <marcus@g10code.de>
+
+ * ac.c (gcry_ac_mpi): Remove member NAME_PROVIDED.
+ (ac_data_mpi_copy, _gcry_ac_data_set, _gcry_ac_data_get_name)
+ (_gcry_ac_data_get_index, ac_data_construct): Adjust handling of
+ NAME accordingly.
+
+2007-04-20 Werner Koch <wk@g10code.com>
+
+ * ecc.c (domain_parms): Add standard brainpool curves.
+
+2007-04-18 Werner Koch <wk@g10code.com>
+
+ * ecc.c (generate_curve): Implement alias mechanism.
+
+ * pubkey.c (sexp_elements_extract_ecc): New.
+ (sexp_to_key): Add special case for ecc.
+ (sexp_to_key, sexp_to_sig, sexp_to_enc, gcry_pk_genkey): Replace
+ name_terminated stuff by a call to _gcry_sexp_nth_string.
+ (gcry_pk_get_keygrip): Ditto.
+
+2007-04-16 Werner Koch <wk@g10code.com>
+
+ * ecc.c (_gcry_ecc_generate): Renamed DUMMY to CURVE and use it.
+
+2007-04-13 Marcus Brinkmann <marcus@g10code.de>
+
+ * ac.c (ac_data_construct): Cast const away to suppress compiler
+ warning.
+
+ * ecc.c (ecc_generate): Avoid compiler warning for unused argument
+ DUMMY.
+ (ecc_verify): Avoid compiler warning for unused arguments CMP and
+ OPAQUEV.
+
+2007-04-06 Werner Koch <wk@g10code.com>
+
+ * sha1.c (oid_spec_sha1): Add another oid from X9.62.
+
+2007-03-28 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Do not issue misc-key-info if it is
+ empty.
+ (gcry_pk_genkey): New parameter "curve".
+
+ * ecc.c: Entirely rewritten with only a few traces of the old
+ code left.
+ (_gcry_ecc_generate): New.
+ (generate_key) New arg NAME.
+ (generate_curve): Ditto. Return actual number of NBITS.
+
+2007-03-26 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Increase size of SKEY array and add a
+ runtime bounds check.
+
+2007-03-23 Werner Koch <wk@g10code.com>
+
+ * ecc.c (ecc_ctx_init, ecc_ctx_free, ecc_mod, ecc_mulm): New.
+ (duplicate_point, sum_points, escalar_mult): Don't use a
+ copy of base->p. Replaced all mpi_mulm by ecc_mulm so that we can
+ experiment with different algorithms.
+ (generate_key, check_secret_key, sign, verify): Initialize a
+ computation context for use by ecc_mulm.
+
+2007-03-22 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pubkey_table): Initialize ECC.
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Add ecc.c.
+ * ecc.c: New. Heavily reformatted and changed for use in libgcrypt.
+ (point_init): New.
+ (escalar_mult): Make arg R the first arg to be similar to the mpi
+ functions.
+ (duplicate_point): Ditto
+ (sum_points): Ditto
+ (sign, verify): Remove unneeded copy operations.
+ (sum_points): Removed memory leaks and optimized some compares.
+ (verify): Simplified input check.
+
+2007-03-14 Werner Koch <wk@g10code.com>
+
+ * random.c (MASK_LEVEL): Removed macro as it was used only at one
+ place. Open coded it there.
+ (gcry_randomize, _gcry_update_random_seed_file)
+ (_gcry_fast_random_poll): Factor lock code out to ..
+ (lock_pool, unlock_pool): .. new.
+ (initialize): Look the pool while allocating.
+ (read_random_source, do_fast_random_poll): Moved intialization to ...
+ (initialize): .. here.
+ (_gcry_enable_quick_random_gen): No more need for initialization.
+ (is_initialized): Moved this global flag to ..
+ (initialize): .. here and changed all users to unconditionally call
+ initialize.
+ (add_randomness): Remove initalization here. It simply can't
+ happen.
+
+ * random.c (enum random_origins): Moved to ..
+ * rand-internal.h: .. here.
+ * rndunix.c (_gcry_rndunix_gather_random): Use enum in prototype
+ for ORIGIN and renamed REQUESTOR to ORIGIN.
+ * rndegd.c (_gcry_rndegd_gather_random): Ditto.
+ * rndlinux.c (_gcry_rndlinux_gather_random): Ditto.
+ * rndw32.c (_gcry_rndw32_gather_random): Ditto.
+ (_gcry_rndw32_gather_random_fast): Ditto.
+
+2007-03-13 Werner Koch <wk@g10code.com>
+
+ * random.c (enum random_origins): New.
+ (add_randomness): Renamed arg SOURCE to ORIGIN.
+ (read_random_source): Renamed arg REQUESTOR to ORIGIN.
+ (getfnc_gather_random): Removed static variable because this
+ function is only called one and thus we don't need this
+ optimization.
+ (_gcry_quick_random_gen): Removed and replaced by..
+ (_gcry_enable_quick_random_gen): .. this. It is onlyu used to
+ enable it and it does not make sense to disable it later. Changed
+ the only one caller too.
+ (get_random_bytes): Removed.
+ (gcry_random_bytes, gcry_random_bytes_secure): Implement in terms
+ of gcry_randomize.
+ * random-daemon.c (_gcry_daemon_get_random_bytes): Removed.
+
+2007-02-23 Werner Koch <wk@g10code.com>
+
+ * elgamal.c (generate): Removed unused variable TEMP.
+ (test_keys): New arg NODIE.
+ (generate_using_x, _gcry_elg_generate_using_x): New.
+ * pubkey.c (pubkey_generate): New arg XVALUE and direct call to
+ the new elgamal generate fucntion.
+ (gcry_pk_genkey): Parse the new "xvalue" tag.
+
+2007-02-22 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_data_to_mpi): Handle dynamically allocated
+ algorithms. Suggested by Neil Dunbar. Fixes bug#596.
+
+ * rndw32.c (_gcry_rndw32_gather_random_fast): Make it return void.
+
+ * cipher.c (gcry_cipher_algo_name): Simplified.
+
+ * random.c: Use the daemon only if compiled with USE_RANDOM_DAEMON.
+
+ * Makefile.am (libcipher_la_SOURCES): Build random-daemon support
+ only if requested.
+
+2007-02-21 Werner Koch <wk@g10code.com>
+
+ * random.c (rndpool, keypool): Make unsigned.
+ (mix_pool): Change char* variables to unsigned char*.
+ (gcry_randomize): Make arg BUFFER a void*.
+ (gcry_create_nonce): Ditto.
+
+ * rmd160.c (gcry_rmd160_mixblock): Make BUFFER a void*.
+ (_gcry_rmd160_hash_buffer): Make OUTBUF and BUFFER void*.
+ * sha1.c (_gcry_sha1_hash_buffer): Ditto.
+
+ * cipher.c (gcry_cipher_encrypt, cry_cipher_decrypt): Change
+ buffer args to void*.
+ (gcry_cipher_register): Make ALGORITHM_ID a int *.
+
+ * md.c (md_start_debug): Make SUFFIX a const char*. Use snprintf.
+ (gcry_md_debug): New.
+ (gcry_md_ctl): Changed arg BUFFER from unsigned char*.
+
+ * md.c (md_write): Make INBUF a const void*.
+ (gcry_md_write): Remove needless cast.
+ * crc.c (crc32_write): Make INBUF a const void*
+ (update_crc32, crc24rfc2440_write): Ditto.
+ * sha512.c (sha512_write, transform): Ditto.
+ * sha256.c (sha256_write, transform): Ditto.
+ * rmd160.c (rmd160_write, transform): Ditto.
+ * md5.c (md5_write, transform): Ditto.
+ * md4.c (md4_write, transform): Ditto.
+ * sha1.c (sha1_write, transform): Ditto.
+
+ * tiger.c (tiger_write, transform): Ditto.
+ * whirlpool.c (whirlpool_write, whirlpool_add, transform): Ditto.
+
+ * elgamal.c (elg_names): Change to a const*.
+ * dsa.c (dsa_names): Ditto.
+ * rsa.c (rsa_names): Ditto.
+ * pubkey.c (gcry_pk_lookup_func_name): Make ALIASES a const.
+
+2007-02-20 Werner Koch <wk@g10code.com>
+
+ * rndlinux.c (open_device): Remove unsused arg MINOR.
+
+2007-01-30 Werner Koch <wk@g10code.com>
+
+ * sha256.c (oid_spec_sha256): Add alias from pkcs#1.
+ * sha512.c (oid_spec_sha512): Ditto.
+ (oid_spec_sha384): Ditto.
+
+2006-12-18 Werner Koch <wk@g10code.com>
+
+ * rndlinux.c (set_cloexec_flag): New.
+ (open_device): Set close-on-exit flags. Suggested by Max
+ Kellermann. Fixes Debian#403613.
+
+ * Makefile.am (AM_CPPFLAGS, AM_CFLAGS): Splitted and merged
+ Moritz' changes.
+ (INCLUDES): Removed.
+
+2006-11-30 Werner Koch <wk@g10code.com>
+
+ * serpent.c (byte_swap_32): Remove trailing semicolon.
+
+2006-11-15 Werner Koch <wk@g10code.com>
+
+ * Makefile.am (INCLUDES): Include ../src/
+
+2006-11-03 Werner Koch <wk@g10code.com>
+
+ * random.c [HAVE_GETTIMEOFDAY]: Included sys/time.h and not
+ sys/times.h. Reported by Rafaël Carré.
+
+2006-11-05 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (AM_CFLAGS): Added -I$(top_builddir)/src so that the
+ new gcrypt.h is used, not the one installed in the system.
+
+2006-10-25 Werner Koch <wk@g10code.com>
+
+ * primegen.c (prime_generate_internal): Tweaked use of secure
+ memory and entropy use. Safe unused primes from the pool. Allocate
+ at least a pool of 30.
+ (save_pool_prime, get_pool_prime): New.
+
+2006-10-23 Werner Koch <wk@g10code.com>
+
+ * ac.c (_gcry_ac_data_from_sexp): Reset sexp_tmp for failsafe
+ means. Release sexp_cur if needed. Reported by Dirk Stoecker.
+
+ * pubkey.c (pubkeys_registered_lock): Intialized it. It is not
+ realy needed because this is a mere initialization to 0 anyway.
+ Noted by Victor Stinner.
+
+2006-10-17 Werner Koch <wk@g10code.com>
+
+ * dsa.c (_gcry_dsa_generate2): New.
+ (generate): New arg QBITS. Add sanity checks for reasonable qbits
+ and nbits.
+ * pubkey.c (gcry_pk_genkey): Parse an qbits element.
+ (pubkey_generate): New arg QBITS. Pass it to the DSA generation.
+
+2006-10-05 Werner Koch <wk@g10code.com>
+
+ * md.c (gcry_md_algo_info) <get_asnoid>: Check that the algo is
+ available.
+
+2006-10-04 David Shaw <dshaw@jabberwocky.com> (wk)
+
+ * tiger.c (round): Rename to tiger_round as gcc 4 has a built-in
+ round function that this conflicts with.
+
+2006-09-11 Werner Koch <wk@g10code.com>
+
+ * rndw32.c (slow_gatherer_windowsNT): While adding data use the
+ size of the diskPerformance and not its address. Has been fixed in
+ GnuPG more than a year ago. Noted by Lee Fisher.
+
+2006-08-30 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_data_to_mpi): Need to allow "ripemd160" here as
+ this is the canonical name.
+
+2006-08-29 Hye-Shik Chang <perky@FreeBSD.org> (wk)
+
+ * seed.c: New.
+
+2006-08-03 Werner Koch <wk@g10code.com>
+
+ * random-daemon.c (_gcry_daemon_initialize_basics): Don't
+ initialize the socket. Remove arg SOCKETNAME.
+ (connect_to_socket): Make sure that daemon is set to -1 on error.
+ (call_daemon): Initialize the socket on the first call.
+ (_gcry_daemon_randomize, _gcry_daemon_get_random_bytes)
+ (_gcry_daemon_create_nonce): New arg SOCKETNAME.
+ * random.c (initialize): Call new daemon initializator.
+ (get_random_bytes, gcry_randomize, gcry_create_nonce): Pass socket
+ name to daemon call and reset allow_daemon on failure.
+
+2006-07-26 Werner Koch <wk@g10code.com>
+
+ * rmd160.c (_gcry_rmd160_mixblock): Add cast to transform call.
+
+ * blowfish.c (selftest): Cast string to usnigned char*.
+
+ * primegen.c (prime_generate_internal): Cast unsigned/char*
+ mismatch in calling m_out_of_n.
+ (is_prime): Changed COUNT to unsigned int *.
+
+ * ac.c (_gcry_ac_data_copy): Initialize DATA_MPIS.
+
+ * random.c (gcry_create_nonce): Update the pid after a fork.
+ Reported by Uoti Urpala.
+
+2006-07-04 Marcus Brinkmann <marcus@g10code.de>
+
+ * sha512.c: Fix typo in copyright notice.
+
+2006-06-21 Werner Koch <wk@g10code.com>
+
+ * rsa.c (_gcry_rsa_generate): Replace xcalloc by calloc.
+ * pubkey.c (gcry_pk_encrypt, gcry_pk_sign): Ditto.
+ (sexp_to_key, sexp_to_sig, sexp_to_enc, gcry_pk_encrypt)
+ (gcry_pk_sign, gcry_pk_genkey, gcry_pk_get_keygrip): Ditto.
+ * md.c (md_copy): Ditto.
+
+2006-04-22 Moritz Schulte <moritz@g10code.com>
+
+ * random-daemon.c (_gcry_daemon_initialize_basics): New argument:
+ SOCKETNAME. Passing on to connect_to_socket() if non-NULL.
+ (connect_to_socket, writen, readn, call_daemon): New functions.
+ (_gcry_daemon_randomize, _gcry_daemon_get_random_bytes)
+ (_gcry_daemon_create_nonce): Call call_daemon().
+ (RANDOM_DAEMON_SOCKET): New symbol.
+ (daemon_socket): New static variable.
+
+ * random.h (_gcry_daemon_initialize_basics): New parameter:
+ SOCKETNAME.
+ (_gcry_set_random_daemon_socket): New declaration.
+
+ * random.c (initialize_basics): Pass DAEMON_SOCKET_NAME to
+ _gcry_daemon_initialize_basics.
+ (_gcry_set_random_daemon_socket): New function, setting
+ DAEMON_SOCKET_NAME.
+
+2006-04-01 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (eme_pkcs_v1_5_encode): Use KEY_SIZE directly, no need to
+ call gcry_ac_key_get_nbits.
+ (eme_pkcs_v1_5_decode): Likewise.
+ (ac_es_dencode_prepare_pkcs_v1_5): Fill options_em structure with
+ key_size.
+ (_gcry_ac_data_dump, gcry_ac_data_dump): New functions.
+ (_gcry_ac_data_to_sexp, _gcry_ac_data_from_sexp): More or less
+ rewritten; changed S-Expression format so that it matches the one
+ used in pubkey.c.
+
+2006-03-15 Werner Koch <wk@g10code.com>
+
+ * random-daemon.c: New.
+ * random.c (_gcry_use_random_daemon): New.
+ (get_random_bytes, gcry_randomize, gcry_create_nonce): Try
+ diverting to the daemon functions.
+
+2006-03-14 Werner Koch <wk@g10code.com>
+
+ * random.c (lock_seed_file): New.
+ (read_seed_file, _gcry_update_random_seed_file): Use it.
+
+ * random.c (gcry_create_nonce): Detect a fork and re-seed.
+ (read_pool): Fixed the fork detection; it used to work only for
+ multi-threaded processes.
+
+2006-03-12 Brad Hards <bradh@frogmouth.net> (wk)
+
+ * md.c (md_open): Use new variable macpads_Bsize instead of
+ hardwiring the block size. Changed at all places.
+
+2006-03-10 Brad Hards <bradh@frogmouth.net> (wk, patch 2005-04-22)
+
+ * md.c, sha256.c: Add support for SHA-224.
+ (sha224_init): New.
+
+2006-01-18 Brad Hards <bradh@frogmouth.net> (wk 2006-03-07)
+
+ * cipher.c (cipher_encrypt, cipher_decrypt, do_ofb_encrypt)
+ (do_ofb_decrypt, gcry_cipher_open): Implement Output Feedback Mode.
+
+2005-11-02 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_algo_name): Return "?" instead of NULL for
+ unknown algorithm IDs.
+ * cipher.c (cipher_algo_to_string): Likewise.
+
+2005-11-01 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_algo_info): Don't forget to break after switch
+ case.
+
+2005-09-19 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate): Add preliminary support for 2 and 4 keys.
+ Return an error code if the key size is not supported.
+ (_gcry_dsa_generate): Return an error.
+
+2005-08-22 Werner Koch <wk@g10code.com>
+
+ * primegen.c (check_prime): New arg RM_ROUNDS.
+ (prime_generate_internal): Call it here with 5 rounds as used
+ before.
+ (gcry_prime_check): But here with 64 rounds.
+ (is_prime): Make sure never to use less than 5 rounds.
+
+2005-04-16 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_init): New function.
+
+2005-04-12 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_io_write, _gcry_ac_io_read): Initialize err to
+ make the compiler happy.
+ Always use errno, now that gcry_malloc() is guaranteed to set
+ errno on failure.
+ (_gcry_ac_data_to_sexp): Don't forget to goto out after error in
+ loop.
+ (_gcry_ac_data_to_sexp): Remove unused variable: mpi_list;
+ (_gcry_ac_data_to_sexp): Always deallocate sexp_buffer.
+ (_gcry_ac_data_from_sexp): Don't forget to initialize data_set_new.
+ (_gcry_ac_data_from_sexp): Handle special case, which is
+ necessary, since gcry_sexp_nth() does not distinguish between
+ "element does not exist" and "element is the empty list".
+ (_gcry_ac_io_init_va): Use assert to make sure that mode and type
+ are correct.
+ Use gcry_error_t types where gcry_err_code_t types have been used
+ before.
+
+2005-04-11 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_data_sign_scheme): Don't forget to initialize
+ buffer.
+
+ * whirlpool.c: New file.
+ * md.c (digest_table): Add whirlpool.
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Added: whirlpool.c.
+
+2005-03-30 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_data_from_sexp): Use length of SEXP_CUR, not
+ length of SEXP; do not forget to set SEXP_TMP to NULL after it has
+ been released.
+
+ (struct gcry_ac_mpi): New member: name_provided.
+ (_gcry_ac_data_set): Rename variable `name_final' to `name_cp';
+ remove const qualifier; change code to not cast away const
+ qualifiers; use name_provided member as well.
+ (_gcry_ac_data_set, _gcry_ac_data_get_name): Use name_provided
+ member of named mpi structure.
+
+ (gcry_ac_name_to_id): Do not forget to initialize err.
+ (_gcry_ac_data_get_index): Do not forget to initialize mpi_return;
+ use gcry_free() instead of free(); remove unnecessary cast; rename
+ mpi_return and name_return to mpi_cp and name_cp; adjust code.
+ (ac_data_mpi_copy): Do not cast away const qualifier.
+ (ac_data_values_destroy): Likewise.
+ (ac_data_construct): Likewise.
+
+ (ac_data_mpi_copy): Initialize flags to GCRY_AC_FLAG_DEALLOC.
+ (ac_data_extract): Use GCRY_AC_FLAG_DEALLOC instead of
+ GCRY_AC_FLAG_COPY.
+
+ (_gcry_ac_io_init_va, _gcry_ac_io_init, gcry_ac_io_init)
+ (gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read)
+ (_gcry_ac_io_read_all, _gcry_ac_io_process): New functions.
+ (gry_ac_em_dencode_t): Use gcry_ac_io_t in prototype instead of
+ memroy strings directly; adjust encode/decode functions to use io
+ objects.
+ (emsa_pkcs_v1_5_encode_data_cb): New function ...
+ (emsa_pkcs_v1_5_encode): ... use it here.
+ (ac_data_dencode): Use io objects.
+ (_gcry_ac_data_encode, _gcry_ac_data_decode, gcry_ac_data_encode)
+ (gcry_ac_data_decode): Likewise.
+ (_gcry_ac_data_encrypt_scheme, gcry_ac_data_encrypt_scheme)
+ (_gcry_ac_data_decrypt_scheme, gcry_ac_data_decrypt_scheme)
+ (_gcry_ac_data_sign_scheme, gcry_ac_data_sign_scheme)
+ (_gcry_ac_data_verify_scheme, gcry_ac_data_verify_scheme):
+ Likewise.
+
+2005-03-23 Werner Koch <wk@g10code.com>
+
+ * rndw32.c (_gcry_rndw32_gather_random_fast): While adding data
+ use the size of the object and not the one of its address. Bug
+ reported by Sascha Kiefer.
+
+2005-03-19 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (do_cbc_encrypt): Be careful to not overwrite data,
+ which is to be used later on. This happend, in case CTS is
+ enabled and OUTBUF is equal to INBUF.
+
+2005-02-25 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_get_keygrip): Allow for shadowed-private-key.
+
+2005-02-13 Moritz Schulte <moritz@g10code.com>
+
+ * serpent.c: Updated from 1.2 branch:
+
+ s/u32_t/u32/ and s/byte_t/byte/. Too match what we have always
+ used and are using in all other files too
+ (serpent_test): Moved prototype out of a fucntion.
+
+2005-02-07 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: Major parts rewritten.
+ * pubkey.c (_gcry_pk_get_elements): New function.
+
+2004-12-09 Werner Koch <wk@g10code.com>
+
+ * serpent.c (serpent_setkey): Moved prototype of serpent_test to
+ outer scope.
+
+2004-09-11 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (pubkey_table): Added an alias entry for GCRY_PK_ELG_E.
+
+2004-08-23 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: Do not include <assert.h>.
+ * rndegd.c: Likewise.
+ * sha1.c: Likewise.
+ * rndunix.c: Likewise.
+ * rndlinux.c: Likewise.
+ * rmd160.c: Likewise.
+ * md5.c: Likewise.
+ * md4.c: Likewise.
+ * cipher.c: Likewise.
+ * crc.c: Likewise.
+ * blowfish.c: Likewise.
+
+ * pubkey.c (dummy_generate, dummy_check_secret_key)
+ (dummy_encrypt, dummy_decrypt, dummy_sign, dummy_verify): Return
+ err code GPG_ERR_NOT_IMPLEMENTED instead of aborting through
+ log_bug().
+ (dummy_get_nbits): Return 0 instead of aborting though log_bug().
+
+2004-08-19 Werner Koch <wk@g10code.de>
+
+ * pubkey.c (sexp_data_to_mpi): Changed the zero random byte
+ substituting code to actually do clever things. Thanks to
+ Matthias Urlichs for noting the implementation problem.
+
+2004-08-09 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_sign): Fixed memory leak; fix provided by
+ Modestas Vainius.
+
+2004-07-16 Werner Koch <wk@gnupg.org>
+
+ * rijndael.c (do_encrypt): Fix alignment problem. Bugs found by
+ Matthias Urlichs.
+ (do_decrypt): Ditto.
+ (keySched, keySched2): Use 2 macros along with unions in the key
+ schedule context.
+
+2004-07-14 Moritz Schulte <moritz@g10code.com>
+
+ * rsa.c (_gcry_rsa_decrypt): Don't forget to free "a". Thanks to
+ Nikos Mavroyanopoulos.
+
+2004-05-09 Werner Koch <wk@gnupg.org>
+
+ * random.c (read_pool): Mix the PID in to better protect after a
+ fork.
+
+2004-07-04 Moritz Schulte <moritz@g10code.com>
+
+ * serpent.c: Use "u32_t" instead of "unsigned long", do not
+ declare S-Box variables as "register". Fixes failure on
+ OpenBSD/sparc64, reported by Nikolay Sturm.
+
+2004-05-07 Werner Koch <wk@gnupg.org>
+
+ * random.c (initialize): Factored out some code to ..
+ (initialize_basics): .. new function.
+ (_gcry_random_initialize): Just call initialize_basics unless the
+ new arg FULL is set to TRUE.
+ (_gcry_fast_random_poll): Don't do anything unless the random
+ system has been really initialized.
+
+2004-05-07 Moritz Schulte <moritz@g10code.de>
+
+ * ac.c (gcry_ac_open): Do not dereference NULL pointer. Reported
+ by Umberto Salsi.
+
+2004-02-20 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (check_prime): New args CB_FUNC and CB_ARG; call them
+ at different stages. Pass these arguments through all callers.
+
+2004-02-06 Werner Koch <wk@gnupg.org>
+
+ * des.c: Add a new OID as used by pkcs#12.
+
+ * rfc2268.c: New. Taken from libgcrypt.
+ * cipher.c: Setup the rfc2268 algorithm.
+
+2004-01-25 Moritz Schulte <mo@g10code.com>
+
+ * primegen.c (prime_generate_internal): Do not forget to free
+ `q_factor'; fixed by Brieuc Jeunhomme.
+ (prime_generate_internal): Do not forget to free `prime'.
+
+2004-01-14 Moritz Schulte <mo@g10code.com>
+
+ * ac.c (gcry_ac_data_set): New argument: flags; slightly
+ rewritten.
+ (gcry_ac_data_get_name, gcry_ac_data_get_index): Likewise.
+ (gcry_ac_key_pair_generate): New argument: misc_data; modified
+ order of arguments.
+ (gcry_ac_key_test): New argument: handle.
+ (gcry_ac_key_get_nbits, gcry_ac_key_get_grip): Likewise.
+ Use GCRY_AC_FLAG_NO_BLINDING instead of
+ GCRY_AC_DATA_FLAG_NO_BLINDING.
+ (gcry_ac_mpi): New member: flags.
+ (gcry_ac_data_search, gcry_ac_data_add): Removed functions.
+
+2003-12-22 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (is_prime): Release A2.
+
+2003-12-19 Werner Koch <wk@gnupg.org>
+
+ * md.c: Moved a couple of functions down below the data structure
+ definitions.
+ (struct gcry_md_context): New field ACTUAL_HANDLE_SIZE.
+ (md_open): Set it here.
+ (strcut gcry_md_list): New field ACTUAL_STRUCT_SIZE.
+ (md_enable): Set it here.
+ (md_close): Wipe the context memory.
+ secure memory.
+ * cipher.c (struct gcry_cipher_handle): New field ACTUAL_HANDLE_SIZE.
+ (gcry_cipher_open): Set it here.
+ (gcry_cipher_close): Use it to always wipe out the handle data.
+
+ * ac.c (gcry_ac_open): Make sure HANDLE gets initialized even when
+ the function is not successful.
+ (gcry_ac_close): Allow a NULL handle.
+ (gcry_ac_key_destroy, gcry_ac_key_pair_destroy): Ditto.
+ (gcry_ac_key_get_grip): Return INV_OBJ on error.
+
+ * primegen.c (prime_generate_internal): Fixed error code for
+ failed malloc. Replaced the !err if chain by gotos.
+ (gcry_prime_group_generator): Remove the extra sanity check.
+
+ * md.c: Minor code and comment cleanups.
+
+2003-12-16 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): Doc fix. Thanks to Newton Hammet.
+
+2003-12-11 Werner Koch <wk@gnupg.org>
+
+ * rndunix.c (slow_poll): Don't use #warning but #error.
+
+ * rndegd.c: Changed indentation.
+ (my_make_filename): Removd the var_arg cruft becuase we
+ don't need it here. Changed caller.
+
+ * rndlinux.c: Changed indentation.
+ (open_device): Remove the superfluous stat call and clarify
+ comment.
+
+ * rsa.c: Changed indentation.
+ (secret): Use the standard algorithm if p, q and u are not
+ available.
+ (rsa_blind, rsa_unblind): Renamed from _gcry_rsa_blind,
+ _gcry_rsa_unblind and moved more to the top.
+
+ * md4.c: Changed indentation. Removed unnecessary casts.
+ * md5.c, rmd160.c, sha1.c, tiger.c: Ditto.
+ * rijndael.c, twofish.c: Ditto.
+ * serpent.c: Removed unnecessary casts.
+ * sha256.c, sha512.c: Ditto.
+
+2003-12-09 Werner Koch <wk@gnupg.org>
+
+ * dsa.c: Unified indentation style.
+ * elgamal.c: Ditto.
+ * des.c (des_key_schedule): Code beautifications.
+ * blowfish.c: Changed indentation style.
+ * cast5.c (do_cast_setkey): Ditto.
+
+ * pubkey.c (gcry_pk_encrypt): Replaced the chain of if(!err) tests
+ by straightforward gotos. Other cleanups.
+ (gcry_pk_decrypt): Ditto.
+ (gcry_pk_sign): Ditto.
+ (gcry_pk_verify): Ditto.
+ (gcry_pk_genkey): Ditto. Use strtoul instead of strtol.
+ (gcry_pk_ctl): Use GPG_ERR_INV_ARG to indicate bad arguments.
+
+2003-12-07 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_register_default): Undef the helper macro.
+ (gcry_pk_map_name): Allow NULL for string.
+ (sexp_to_key): Use memcpy and not strncpy. Use gcry_free and not
+ free.
+ (sexp_to_sig): Ditto.
+ (sexp_to_enc): Ditto. Replaced the chain of if(!err) tests by
+ straightforward gotos.
+
+2003-12-05 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Documentation cleanups.
+ (gcry_cipher_mode_from_oid): Allow NULL for STRING.
+
+2003-12-03 Werner Koch <wk@gnupg.org>
+
+ * elgamal.c (sign, do_encrypt, gen_k): Make sure that a small K is
+ only used for encryption.
+
+2003-11-18 Werner Koch <wk@gnupg.org>
+
+ * random.h (rndw32_set_dll_name): Removed unused prototype.
+
+ * Makefile.am (EXTRA_DIST): Added Manifest.
+
+2003-11-11 Werner Koch <wk@gnupg.org>
+
+ * Manifest: New.
+
+2003-11-04 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Use shortcut for SHA1
+ * sha1.c (_gcry_sha1_hash_buffer): New.
+
+ * random.c: Reformatted most functions.
+ (mix_pool): Moved the failsafe_digest from global
+ scope to here.
+ (do_fast_random_poll): Use the generic fucntions even if a fast
+ gathering function has been used.
+ (read_pool): Detect a fork and retry.
+ (gcry_randomize, get_random_bytes): Don't distinguish anymore
+ between weak and strong random.
+ (gcry_create_nonce): New.
+
+2003-10-31 Werner Koch <wk@gnupg.org>
+
+ * rndw32.c (slow_gatherer_windowsNT): Use a plain buffer for the
+ disk performance values and not the W32 API structure.
+
+ * dsa.c (verify): s/exp/ex/ due to shadowing of a builtin.
+ * elgamal.c (verify): Ditto.
+
+ * ac.c (gcry_ac_data_get_index): s/index/idx/
+ (gcry_ac_data_copy_internal): Remove the cast in _gcry_malloc.
+ (gcry_ac_data_add): Must use gcry_realloc instead of realloc.
+ * pubkey.c (sexp_elements_extract): s/index/idx/ as tribute to the
+ forehackers.
+ (gcry_pk_encrypt): Removed shadowed definition of I. Reordered
+ arguments to malloc for clarity.
+ (gcry_pk_sign, gcry_pk_genkey): Ditto.
+ * primegen.c (prime_generate_internal): s/random/randomlevel/.
+
+2003-10-27 Moritz Schulte <mo@g10code.com>
+
+ * pubkey.c (gcry_pk_encrypt): Don't forget to deallocate pkey.
+
+2003-10-27 Werner Koch <wk@gnupg.org>
+
+ * random.c (gcry_random_add_bytes): Return if buflen is zero to
+ avoid gcc warning about unsed parameter.
+ (MASK_LEVEL): Simplified; does now work for signed and unsigned
+ w/o warnings.
+
+ * md.c (md_start_debug): Removed the const from SUFFIX, because
+ this function is called from the control fucntion which does not
+ require const.
+
+ Prefixed all (pubkey,digest,cipher}_spec_* globale variables with
+ _gcry_.
+
+ * ac.c (ac_key_identifiers): Made static.
+
+ * random.c (getfnc_gather_random,getfnc_fast_random_poll): Move
+ prototypes to ..
+ * rand-internal.h: .. here
+ * random.c (getfnc_gather_random): Include rndw32 gatherer.
+ * rndunix.c, rndw32.c, rndegd.c: Include them here.
+ * rndlinux.c (_gcry_rndlinux_gather_random): Prepend the _gcry_
+ prefix. Changed all callers.
+ * rndegd.c (_gcry_rndegd_gather_random): Likewise.
+ (_gcry_rndegd_connect_socket): Likewise.
+ * rndunix.c (_gcry_rndunix_gather_random): Likewise.
+ (waitpid): Made static.
+ * rndw32.c: Removed the old and unused winseed.dll cruft.
+ (_gcry_rndw32_gather_random_fast): Renamed from
+ gather_random_fast.
+ (_gcry_rndw32_gather_random): Renamed from gather_random. Note,
+ that the changes 2003-04-08 somehow got lost.
+
+ * sha512.c (sha512_init, sha384_init): Made static.
+
+ * cipher.c (do_ctr_decrypt): Removed "return" from this void
+ function.
+
+2003-10-24 Moritz Schulte <mo@g10code.com>
+
+ * serpent.c: Fix an issue on big-endian systems.
+
+ * rndw32.c: Removed IS_MODULE -cruft.
+ * rndlinux.c (rndlinux_gather_random): Likewise.
+
+2003-10-10 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): Bail out if NBITS is less than 16.
+ (prime_generate_internal): Initialize prime variable to suppress
+ compiler warning. Check pbits, initialize qbits when passed as
+ zero.
+
+ * primegen.c (prime_generate_internal): New arg
+ ALL_FACTORS. Changed all callers.
+ (gcry_prime_generate): Make the factors arg optional. Request
+ all_factors. Make sure PRIME is set to NULL even on error.
+ (gcry_prime_group_generator): New.
+ (gcry_prime_release_factors): New.
+
+2003-10-06 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): Assert that NBITS is never zero, it
+ would cause a segv.
+
+2003-09-28 Moritz Schulte <mo@g10code.com>
+
+ * ac.c: Include "cipher.h".
+
+2003-09-27 Moritz Schulte <mo@g10code.com>
+
+ * rndegd.c (do_read): Return nread instead of nbytes; thanks to
+ Michael Caerwyn.
+
+2003-09-04 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (_gcry_pk_aliased_algo_name): New.
+ * ac.c (gcry_ac_open): Use it here.
+
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Add serpent.c
+
+2003-09-02 Moritz Schulte <mo@g10code.com>
+
+ * primegen.c (gcry_prime_check, gcry_prime_generate): New
+ functions.
+ (prime_generate_internal): New function, based on
+ _gcry_generate_elg_prime.
+ (_gcry_generate_elg_prime): Rewritten as a wrapper for
+ prime_generate_internal.
+
+2003-08-28 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_encrypt): Don't include the flags list in the
+ return value. This does not make sense and breaks any programs
+ parsing the output strictly (e.g. current gpgsm).
+ (gcry_pk_encrypt): If aliases for the algorithm name exists, take
+ the first one instead of the regular name to adhere to SPKI
+ conventions.
+ (gcry_pk_genkey): Ditto.
+ (gcry_pk_sign): Ditto. Removed unused KEY_ALGO_NAME.
+
+2003-08-19 Moritz Schulte <mo@g10code.com>
+
+ * cipher.c: Add support for Serpent
+ * serpent.c: New file.
+
+2003-08-10 Moritz Schulte <moritz@g10code.com>
+
+ * rsa.c (_gcry_rsa_blind, _gcry_rsa_unblind): Declare static.
+
+2003-08-09 Timo Schulz <twoaday@freakmail.de>
+
+ * random.c (getfnc_gather_random): Don't check NAME_OF_DEV_RANDOM
+ two times, but also the NAME_OF_DEV_URANDOM device.
+
+2003-08-08 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_to_enc): Fixed extraction of S-Expression: do not
+ fail if no `flags' sub S-Expression is found.
+
+2003-07-27 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_lookup_func_oid): Allow for empty OID lists.
+
+2003-07-23 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (gcry_ac_data_construct): New argument: include_flags, only
+ include `flags' S-expression, if include_flags is true. Adjust
+ callers. Thanks for triggering a bug caused by `flags'
+ sub-S-expression where they are not expected to Ralf Schneider.
+
+2003-07-21 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_lookup_func_name): Use new member name
+ `aliases' instead of `sexp_names'.
+
+ * ac.c (gcry_ac_key_data_get): New function.
+
+ * cipher.c (gcry_cipher_lookup_func_name): Fix return value.
+
+2003-07-20 Moritz Schulte <moritz@g10code.com>
+
+ * blowfish.c: Adjusted for new gcry_cipher_spec_t structure.
+ * cast5.c: Likewise.
+ * twofish.c: Likewise.
+ * arcfour.c: Likewise.
+ * rijndael.c (rijndael_oids, rijndael192_oids, rijndael256_oids):
+ New variables, adjust for new gcry_cipher_spec_t structure.
+ * des.c (oids_tripledes): New variable, adjust for new
+ gcry_cipher_spec_t structure.
+
+ * md.c (oid_table): Removed.
+
+ * tiger.c (oid_spec_tiger): New variable.
+ (digest_spec_tiger): Adjusted for new gry_md_spec_t structure.
+
+ * sha512.c (oid_spec_sha512): New variable.
+ (digest_spec_sha512): Adjusted for new gry_md_spec_t structure.
+
+ * sha512.c (oid_spec_sha384): New variable.
+ (digest_spec_sha384): Adjusted for new gry_md_spec_t structure.
+
+ * sha256.c (oid_spec_sha256): New variable.
+ (digest_spec_sha256): Adjusted for new gry_md_spec_t structure.
+
+ * sha1.c (oid_spec_sha1): New variable.
+ (digest_spec_sha1): Adjusted for new gry_md_spec_t structure.
+
+ * rmd160.c (oid_spec_rmd160): New variable.
+ (digest_spec_rnd160): Adjusted for new gry_md_spec_t structure.
+
+ * md5.c (oid_spec_md5): New variable.
+ (digest_spec_md5): Adjusted for new gry_md_spec_t structure.
+
+ * md4.c (oid_spec_md4): New variable.
+ (digest_spec_md4): Adjusted for new gry_md_spec_t structure.
+
+ * crc.c (digest_spec_crc32, digest_spec_crc32_rfc1510,
+ digest_spec_crc32_rfc2440): Adjusted for new gry_md_spec_t
+ structure.
+
+2003-07-19 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (gcry_md_lookup_func_oid): New function.
+ (search_oid): New function, copied from cipher.c.
+ (gcry_md_map_name): Adjust for new search_oid_interface.
+
+ * cipher.c (oid_table): Removed table.
+ (gcry_cipher_lookup_func_oid): New function.
+ (search_oid): Rewritten to use the module functions.
+ (gcry_cipher_map_name): Adjust for new search_oid interface.
+ (gcry_cipher_mode_from_oid): Likewise.
+
+2003-07-18 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Convert ERR to gpg_error_t in
+ gpg_strerror.
+
+2003-07-14 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (gcry_cipher_lookup_func_name): Also check the cipher
+ name aliases, not just the primary name.
+ (gcry_cipher_map_name): Remove kludge for aliasing Rijndael to
+ AES.
+
+ * arcfour.c, blowfish.c, cast5.c, des.c, twofish.c: Adjust cipher
+ specification structures.
+
+ * rijndael.c (rijndael_names, rijndael192_names,
+ rijndael256_names): New variables, use them in the cipher
+ specifications.
+
+ * rmd160test.c: Removed file.
+
+ * ac.c, arcfour.c, blowfish.c, cast5.c, cipher.c, des.c, dsa.c,
+ elgamal.c, md.c, pubkey.c, random.c, rijndael.c, rsa.c, twofish.c:
+ Used gcry_err* wrappers for libgpg symbols.
+
+ * primegen.c (gen_prime): Correct the order arguments to
+ extra_check.
+
+2003-07-12 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: Replaced all public occurences of gpg_error_t with
+ gcry_error_t.
+ * cipher.c: Likewise.
+ * md.c: Likewise.
+ * pubkey.c: Likewise.
+ * random.c: Likewise.
+
+ * cipher.c: Added support for TWOFISH128.
+
+2003-07-08 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (gcry_ac_data_copy_internal): New function, based on
+ gcry_ac_data_copy.
+ (gcry_ac_data_copy): Made public, use gcry_ac_data_copy_internal.
+ (gcry_ac_key_init): Use gcry_ac_data_copy_internal.
+
+2003-07-07 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (gcry_ac_data_set): Only release old MPI value if it is
+ different from the new value. Bug reported by Simon Josefsson
+ <jas@extundo.com>.
+
+ * pubkey.c (gcry_pk_list): New function.
+ * md.c (gcry_md_list): New function.
+
+ * ac.c (gcry_ac_key_pair_generate): Fix calculation of format
+ string size.
+
+2003-07-05 Moritz Schulte <moritz@g10code.com>
+
+ * md.c: Named struct of digest_table `digest_table_entry'.
+ (digest_table_entry): New member: algorithm; filled in.
+ (digest_table_entry): Removed unused member: flags.
+ (gcry_md_register): New argument: algorithm_id, filled in.
+ (gcry_md_register_default): Used algorithm ID from module
+ structure.
+ (gcry_md_map_name): Likewise.
+ (md_enable): Likewise.
+ (md_read): Likewise.
+ (gcry_md_info): Likewise.
+
+ * pubkey.c: Named truct for pubkey_table `pubkey_table_entry'.
+ (pubkey_table_entry): New member: algorithm; filled in.
+ (gcry_pk_register_default): Used algorithm ID from pubkey_table.
+ (gcry_pk_register): New argument: algorithm_id, filled in.
+ (gcry_pk_map_name): Used algorithm ID from module structure.
+ (gcry_pk_decrypt): Likewise.
+ (gcry_pk_encrypt): Likewise.
+ (gcry_pk_verify): Likewise.
+ (gcry_pk_sign): Likewise.
+ (gcry_pk_testkey): Likewise.
+ (gcry_pk_genkey): Likewise.
+ (gcry_pk_get_nbits): Likewise.
+ (sexp_to_key): Removed unused variable: algo.
+ (sexp_to_sig): Likewise.
+
+ * cipher.c: Named struct for cipher_table `cipher_table_entry'.
+ (cipher_table_entry): New member: algorithm; filled in.
+ (gcry_cipher_register_default): Used algorithm ID from
+ cipher_table.
+ (gcry_cipher_register): New argument: algorithm_id, filled in.
+ (gcry_cipher_map_name): Used algorithm ID from module structure.
+
+ * arcfour.c (cipher_spec_arcfour): Removed algorithm ID.
+ * blowfish.c (cipher_spec_blowfish): Likewise.
+ * cast5.c (cipher_spec_cast5): Likewise.
+ * crc.c (digest_spec_crc32): Likewise.
+ * crc.c (digest_spec_crc32_rfc1510): Likewise.
+ * crc.c (digest_spec_crc32_rfc2440): Likewise.
+ * des.c (cipher_spec_des): Likewise.
+ * des.c (cipher_spec_tripledes): Likewise.
+ * dsa.c (pubkey_spec_dsa): Likewise.
+ * elgamal.c (pubkey_spec_elg): Likewise.
+ * md4.c (digest_spec_md4): Likewise.
+ * md5.c (digest_spec_md5): Likewise.
+ * aes.c (cipher_spec_aes): Likewise.
+ * aes.c (cipher_spec_aes192): Likewise.
+ * aes.c (cipher_spec_aes256): Likewise.
+ * rsa.c (pubkey_spec_rsa): Likewise.
+ * sha1.c (digest_spec_sha1): Likewise.
+ * sha256.c (digest_spec_sha256): Likewise.
+ * sha512.c (digest_spec_sha512): Likewise.
+ * tiger.c (digest_spec_tiger): Likewise.
+ * twofish.c (cipher_spec_twofish): Likewise.
+ * twofish.c (cipher_spec_twofish128): Likewise.
+
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Fix list of source
+ files; reported by Simon Josefsson <jas@extundo.com>.
+
+ * pubkey.c: Replaced all occurences of `id' with `algorithm',
+ since `id' is a keyword in obj-c.
+ * md.c: Likewise.
+ * cipher.c: Likewise.
+
+ * crc.c, md4.c, md5.c, rmd160.c, sha1.c, sha256.c, tiger.c:
+ Replaced all occurences of gcry_digest_spec_t with gcry_md_spec_t.
+
+ * dsa.c, rsa.c, elgamal.c: Replaced all occurencens of
+ gcry_pubkey_spec_t with gcry_pk_spec_t.
+
+ * md.c: Replaced all occurences of gcry_digest_spec_t with
+ gcry_md_spec_t.
+ (gcry_digest_register_default): Renamed to ...
+ (gcry_md_register_default): ... this; adjusted callers.
+ (gcry_digest_lookup_func_name): Renamed to ...
+ (gcry_md_lookup_func_name): ... this; adjusted callers.
+ (gcry_digest_lookup_name): Renamed to ...
+ (gcry_md_lookup_name): ... this; adjusted callers.
+ (gcry_digest_register): Renamed to ...
+ (gcry_md_register): ... this.
+ (gcry_digest_unregister): Renamed to ...
+ (gcry_md_unregister): ... this.
+
+ * pubkey.c (gcry_pubkey_register): Renamed to ...
+ (gcry_pk_register): ... this.
+ (gcry_pubkey_unregister): Renamed to ...
+ (gcry_pk_unregister): ... this.
+ Replaced all occurences of gcry_pubkey_spec_t with gcry_pk_spec_t.
+ (gcry_pubkey_register_default): Renamed to ...
+ (gcry_pk_register_default): ... this; adjusted callers.
+ (gcry_pubkey_lookup_func_name): Renamed to ...
+ (gcry_pk_lookup_func_name): ... this; adjusted callers.
+ (gcry_pubkey_lookup_name): Renamed to ...
+ (gcry_pk_lookup_name): ... this; adjusted callers.
+
+ * md.c (gcry_md_hash_buffer): Fix error checking. Thanks to Simon
+ Josefsson <jas@extunde.com>.
+
+2003-07-04 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (gcry_cipher_list): New function.
+
+2003-07-01 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_to_sig): Accept a `flags' S-expression to be more
+ consistent with sexp_to_enc.
+
+2003-06-30 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (libcipher_la_SOURCES): Added: ac.c.
+
+ * pubkey.c (_gcry_pk_module_lookup): New function.
+ (_gcry_pk_module_release): New function.
+
+2003-06-29 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: New file.
+
+2003-06-26 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Trigger BUG correcly with new API.
+
+2003-06-19 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_is_enabled): Fixed.
+
+2003-06-18 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_get_algo_keylen): New.
+ (gcry_cipher_get_algo_blklen): New.
+
+2003-06-18 Moritz Schulte <moritz@g10code.com>
+
+ * arcfour.c, cipher.c, blowfish.c, md.c, cast5.c, pubkey.c, crc.c,
+ des.c, dsa.c, elgamal.c, md4.c, md5.c, random.c, rijndael.c,
+ rmd160.c, rsa.c, sha1.c, sha256.c, sha512.c, tiger.c, twofish.c:
+ Replaced older types GcryDigestSpec, GcryCipherSpec and
+ GcryPubkeySpec with newer types: gcry_digest_spec_t,
+ gcry_cipher_spec_t and gcry_pubkey_spec_t.
+
+ * md.c (gcry_digest_id_new): Removed function.
+ (gcry_digest_register): Removed code for generating a new module
+ ID.
+
+ * pubkey.c (gcry_pubkey_id_new): Removed function.
+ (gcry_pubkey_register): Removed code for generating a new module
+ ID.
+
+ * cipher.c, md.c, pubkey.c: Replace old type GcryModule with newer
+ one: gcry_module_t.
+ (gcry_cipher_id_new): Removed function.
+ (gcry_cipher_register): Removed code for generating a new module
+ ID.
+
+ * cipher.c (gcry_cipher_register): Adjust call to
+ _gcry_module_add.
+ (gcry_cipher_register_default): Likewise.
+ * pubkey.c (gcry_pubkey_register_default): Likewise.
+ (gcry_pubkey_register): Likewise.
+ * md.c (gcry_digest_register_default): Likewise.
+ (gcry_digest_register): Likewise.
+
+ * md.c (gcry_digest_lookup_func_id): Removed function.
+ (gcry_digest_lookup_id): Likewise.
+ (gcry_digest_id_new): Use _gcry_module_lookup_id instead of
+ gcry_digest_lookup_id.
+ (digest_algo_to_string): Likewise.
+ (check_digest_algo): Likewise.
+ (md_enable): Likewise.
+ (md_digest_length): Likewise.
+ (md_asn_oid): Likewise.
+
+ * pubkey.c (gcry_pubkey_lookup_id): Removed function.
+ (gcry_pubkey_lookup_func_id): Likewise.
+ (gcry_pubkey_id_new): Use _gcry_module_lookup_id instead of
+ gcry_pubkey_id_new.
+ (gcry_pk_algo_name): Likewise.
+ (disable_pubkey_algo): Likewise.
+ (check_pubkey_algo): Likewise.
+ (pubkey_get_npkey): Likewise.
+ (pubkey_get_nskey): Likewise.
+ (pubkey_get_nsig): Likewise.
+ (pubkey_get_nenc): Likewise.
+ (pubkey_generate): Likewise.
+ (pubkey_check_secret_key): Likewise.
+ (pubkey_encrypt): Likewise.
+ (pubkey_decrypt): Likewise.
+ (pubkey_sign): Likewise.
+ (pubkey_verify): Likewise.
+ (gcry_pk_algo_info): Likewise.
+
+ * cipher.c (gcry_cipher_lookup_func_id): Removed function.
+ (gcry_cipher_lookup_id): Likewise.
+ (cipher_algo_to_string): use _gcry_module_lookup_id instead of
+ gcry_cipher_lookup_id.
+ (disable_cipher_algo): Likewise.
+ (check_cipher_algo): Likewise.
+ (cipher_get_blocksize): Likewise.
+ (gcry_cipher_open): Likewise.
+ (gcry_cipher_id_new): Likewise.
+
+2003-06-17 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (GCRYPT_MODULES): Set to @GCRYPT_CIPHERS@,
+ @GCRYPT_PUBKEY_CIPHERS@, @GCRYPT_DIGESTS@ and @GCRYPT_RANDOM@.
+ (libcipher_la_DEPENDENCIES): Set to $(GCRYPT_MODULES).
+ (libcipher_la_LIBADD): Likewise.
+ (AM_CFLAGS): Added: @GPG_ERROR_CFLAGS@.
+ (EXTRA_libcipher_la_SOURCES): Added all conditional sources.
+
+ * md.c (md_open): Use _gcry_fast_random_poll instead of
+ fast_random_poll.
+ * cipher.c (gcry_cipher_open): Likewise.
+
+ * random.h (fast_random_poll): Removed macro.
+
+ * blowfish.c, md4.c, md5.c, rmd160.c, sha1.c, sha256.c, sha512.c,
+ tiger.c: Use Autoconf's WORDS_BIGENDIAN instead of our own
+ BIG_ENDIAN_HOST.
+
+2003-06-16 Moritz Schulte <moritz@g10code.com>
+
+ * random.c (getfnc_gather_random): Do not special-case
+ USE_ALL_RANDOM_MODULES, make it the default.
+
+ * dsa.c: Replace last occurences of old type names with newer
+ names (i.e. replace MPI with gcry_mpi_t).
+ * elgamal.c: Likewise.
+ * primegen.c: Likewise.
+ * pubkey.c: Likewise.
+ * rsa.c: Likewise.
+
+2003-06-14 Moritz Schulte <moritz@g10code.com>
+
+ * des.c (des_setkey): Add selftest check.
+ (tripledes_set3keys): Likewise.
+ (do_tripledes_setkey): Remove selftest check.
+ (do_des_setkey): Likewise.
+
+2003-06-11 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (_gcry_md_init): New function.
+ * cipher.c (_gcry_cipher_init): New function.
+ * pubkey.c (_gcry_pk_init): New function.
+
+2003-06-13 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_get_algo): Reverted to old API. This is a
+ convenience function anyway and error checking is not approriate.
+ (gcry_md_is_secure): New.
+ (gcry_md_is_enabled): New.
+
+2003-06-12 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_open): Make sure HANDLE is set to NULL on
+ error.
+
+2003-06-11 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_open): Make sure H receives either NULL or an
+ valid handle.
+ (gcry_md_copy): Swapped arguments so that it is more in lione with
+ md_open and most other API fucntions like memcpy (destination
+ comes first). Make sure HANDLE is set to NULL on error.
+
+ * rijndael.c (do_encrypt): Hack to force correct alignment. It
+ seems not to be not sufficient, though. We should rework this
+ fucntions and remove all these ugly casts. Let the compiler
+ optimize or have an assembler implementation.
+
+2003-06-09 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am: Removed rules serpent, since that is not commited
+ yet.
+
+2003-06-08 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_encrypt): Improve calculation for size of the
+ format string.
+
+2003-06-07 Moritz Schulte <moritz@g10code.com>
+
+ * arcfour.c, bithelp.h, blowfish.c, cast5.c, cipher.c, crc.c,
+ des.c, dsa.c, elgamal.c, md4.c, md5.c, md.c, primegen.c, pubkey.c,
+ rand-internal.h, random.c, random.h, rijndael.c, rmd160.c,
+ rmd160test.c, rmd.h, rndeged.c, rndlinux.c, rndunix.c, rndw32.c,
+ rsa.c, sha1.c, sha256.c, sha512.c, tiger.c, twofish.c: Edited all
+ preprocessor instructions to remove whitespace before the '#'.
+ This is not required by C89, but there are some compilers out
+ there that don't like it. Replaced any occurence of the now
+ deprecated type names with the new ones.
+
+2003-06-04 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_encrypt): Construct an arg_list and use
+ gcry_sexp_build_array instead of gcry_sexp_build.
+ (gcry_pk_sign): Likewise.
+ (gcry_pk_genkey): Likewise.
+
+2003-06-01 Moritz Schulte <moritz@g10code.com>
+
+ * dsa.c (_gcry_dsa_generate): Do not check wether the algorithm ID
+ does indeed belong to DSA.
+ (_gcry_dsa_sign): Likewise.
+ (_gcry_dsa_verify): Likewise.
+ (_gcry_dsa_get_nbits): Likewise.
+
+ * elgamal.c (_gcry_elg_check_secret_key): Do not check wether the
+ algorithm ID does indeed belong to ElGamal.
+ (_gcry_elg_encrypt): Likewise.
+ (_gcry_elg_decrypt): Likewise.
+ (_gcry_elg_sign): Likewise.
+ (_gcry_elg_verify): Likewise.
+ (_gcry_elg_get_nbits): Likewise.
+ (_gcry_elg_generate): Likewise.
+
+ * rsa.c (_gcry_rsa_generate): Do not check wether the algorithm ID
+ does indeed belong to RSA.
+ (_gcry_rsa_encrypt): Likewise.
+ (_gcry_rsa_decrypt): Likewise.
+ (_gcry_rsa_sign): Likewise.
+ (_gcry_rsa_verify): Likewise.
+ (_gcry_rsa_get_nbits): Likewise.
+
+2003-05-30 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (md_get_algo): Return zero in case to algorithm is enabled.
+
+ * md.c (gcry_md_info): Adjusted for new no-errno-API.
+ (md_final): Likewise.
+ (gcry_md_get_algo): Likewise.
+ * pubkey.c (gcry_pk_get_keygrip): Likewise.
+ (gcry_pk_ctl): Likewise.
+ (gcry_pk_algo_info): Likewise.
+ * des.c (selftest): Likewise.
+
+2003-05-29 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (md_enable): Do not forget to release module on error.
+ (gcry_md_open): Adjusted for new no-errno-API.
+ (md_open): Likewise.
+ (md_copy): Likewise.
+ (gcry_md_copy): Likewise.
+ (gcry_md_setkey): Likewise.
+ (gcry_md_algo_info): Likewise.
+
+ * cipher.c (gcry_cipher_open): Adjusted for new no-errno-API and
+ also fixed a locking bug.
+ (gcry_cipher_encrypt): Adjusted for new no-errno-API.
+ (gcry_cipher_decrypt): Likewise.
+ (gcry_cipher_ctl): Likewise.
+ (gcry_cipher_info): Likewise.
+ (gcry_cipher_algo_info): Likewise.
+
+2003-05-28 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (md_enable): Adjusted for libgpg-error.
+ (gcry_md_enable): Likewise.
+ (gcry_digest_register_default): Likewise.
+ (gcry_digest_register): Likewise.
+ (check_digest_algo): Likewise.
+ (prepare_macpads): Likewise.
+ (gcry_md_setkey): Likewise.
+ (gcry_md_ctl): Likewise.
+ (gcry_md_get): Likewise.
+ (gcry_md_algo_info): Likewise.
+ (gcry_md_info): Likewise.
+ * dsa.c (_gcry_dsa_generate): Likewise.
+ (_gcry_dsa_check_secret_key): Likewise.
+ (_gcry_dsa_sign): Likewie.
+ (_gcry_dsa_verify): Likewise.
+ * twofish.c (do_twofish_setkey): Likewise.
+ (twofish_setkey): Likewise.
+ * cipher.c (gcry_cipher_register): Likewise.
+
+2003-05-25 Moritz Schulte <moritz@g10code.com>
+
+ * rijndael.c (do_setkey): Adjusted for libgpg-error.
+ (rijndael_setkey): Likewise.
+ * random.c (gcry_random_add_bytes): Likewise.
+ * elgamal.c (_gcry_elg_generate): Likewise.
+ (_gcry_elg_check_secret_key): Likewise.
+ (_gcry_elg_encrypt): Likewise.
+ (_gcry_elg_decrypt): Likewise.
+ (_gcry_elg_sign): Likewise.
+ (_gcry_elg_verify): Likewise.
+ * rsa.c (_gcry_rsa_generate): Likewise.
+ (_gcry_rsa_check_secret_key): Likewise.
+ (_gcry_rsa_encrypt): Likewise.
+ (_gcry_rsa_decrypt): Likewise.
+ (_gcry_rsa_sign): Likewise.
+ (_gcry_rsa_verify): Likewise.
+ * pubkey.c (dummy_generate, dummy_check_secret_key, dummy_encrypt,
+ dummy_decrypt, dummy_sign, dummy_verify): Likewise.
+ (gcry_pubkey_register): Likewise.
+ (check_pubkey_algo): Likewise.
+ (pubkey_generate): Likewise.
+ (pubkey_check_secret_key): Likewise.
+ (pubkey_encrypt): Likewise.
+ (pubkey_decrypt): Likewise.
+ (pubkey_sign): Likewise.
+ (pubkey_verify): Likewise.
+ (sexp_elements_extract): Likewise.
+ (sexp_to_key): Likewise.
+ (sexp_to_sig): Likewise.
+ (sexp_to_enc): Likewise.
+ (sexp_data_to_mpi): Likewise.
+ (gcry_pk_encrypt): Likewise.
+ (gcry_pk_decrypt): Likewise.
+ (gcry_pk_sign): Likewise.
+ (gcry_pk_verify): Likewise.
+ (gcry_pk_testkey): Likewise.
+ (gcry_pk_genkey): Likewise.
+ (gcry_pk_ctl): Likewise.
+ * cipher.c (dummy_setkey): Likewise.
+ (check_cipher_algo): Likewise.
+ (gcry_cipher_open): Likewise.
+ (cipher_setkey): Likewise.
+ (gcry_cipher_ctl): Likewise.
+ (cipher_encrypt): Likewise.
+ (gcry_cipher_encrypt): Likewise.
+ (cipher_decrypt): Likewise.
+ (gcry_cipher_decrypt): Likewise.
+ (gcry_cipher_info): Likewise.
+ (gcry_cipher_algo_info): Likewise.
+ * cast5.c (cast_setkey): Likewise.
+ (do_cast_setkey): Likewise.
+ * arcfour.c (arcfour_setkey): Likewise.
+ (do_arcfour_setkey): Likewise.
+ * blowfish.c (do_bf_setkey): Likewise.
+ (bf_setkey): Likewise.
+ * des.c (do_des_setkey): Likewise.
+ (do_tripledes_setkey): Likewise.
+
+2003-05-22 Moritz Schulte <moritz@g10code.com>
+
+ * tiger.c: Merged code ussing the U64_C macro from GnuPG.
+
+ * sha512.c: Likewise.
+
+2003-05-17 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Fix type: acquire a lock, instead of
+ releasing it.
+
+2003-05-11 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_testkey): Call REGISTER_DEFAULT_CIPHERS.
+ (gcry_pk_ctl): Likewise.
+
+2003-04-27 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Release sexp after extracted data has
+ been used.
+
+ * md.c (gcry_md_get_algo_dlen): Simplified, simply call
+ md_digest_length to do the job.
+
+ * des.c (do_des_setkey): Check for selftest failure not only
+ during initialization.
+ (do_tripledes_setkey): Include check for selftest failure.
+
+ * pubkey.c (gcry_pubkey_register_default): New macro
+ `pubkey_use_dummy', use it.
+
+ * elgamal.c (elg_names): New variable.
+ (pubkey_spec_elg): Include elg_names.
+
+ * dsa.c (dsa_names): New variable.
+ (pubkey_spec_dsa): Include dsa_names.
+
+ * rsa.c (rsa_names): New variable.
+ (pubkey_spec_rsa): Include rsa_names.
+
+ * pubkey.c (gcry_pubkey_lookup_func_name): Compare name also with
+ the names listed in `sexp_names'.
+
+2003-04-24 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_to_key): New variables: module, pubkey. Adjusted
+ to new module interface.
+ (sexp_to_key): Changend type of argument `retalgo' from `int *' to
+ `GcryModule **'. Adjusted all callers. Removed argument:
+ r_algotblidx.
+ (sexp_to_sig): Changend type of argument `retalgo' from `int *' to
+ `GcryModule **'. Adjusted all callers.
+ (sexp_to_enc): Likewise.
+
+ (pubkey_get_npkey, pubkey_get_nskey, pubkey_get_nsig,
+ pubkey_get_nenc): Use strlen to find out the number.
+
+ * rsa.c: Adjust pubkey_spec_rsa to new internal interface.
+ * dsa.c: Likewise.
+ * elgamal.c: Likewise.
+
+2003-04-17 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_elements_extract): New function.
+ * pubkey.c (sexp_to_key): Removed variable `idx', added `err', use
+ sexp_elements_extract.
+ (sexp_to_sig): Likewise.
+ (sexp_to_enc): Likewise.
+
+ * pubkey.c: Terminate list correctly.
+ * md.c: Include sha512/sha384 in digest_table.
+
+2003-04-16 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am: Include support for sha512.c.
+
+ * sha512.c: New file, merged from GnuPG, with few modifications
+ for libgcrypt.
+
+ * rand-internal.h: Removed declarations for constructor functions.
+
+ * md.c (md_copy): Call _gcry_module_use for incrementing the usage
+ counter of the digest modules.
+
+ * rsa.c: Do not include "rsa.h".
+ * dsa.c: Do not include "dsa.h".
+ * elgamal.c: Do not include "elgamal.h".
+ * des.c: Do not include "des.h".
+ * cast5.c: Do not include "cast5.h".
+ * blowfish.c: Do not include "blowfish.h".
+ * arcfour.c: Do not include "arcfour.h".
+
+ * Makefile.am (libcipher_la_DEPENDENCIES): Removed.
+ (libcipher_la_LIBADD): Removed.
+ Use Automake conditionals for conditional compilation.
+
+2003-04-13 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Call REGISTER_DEFAULT_CIPHERS.
+
+ * md.c (gcry_md_list): New member: module.
+ (md_enable): New variable: module, changed use of module and
+ digest.
+ (md_enable): Initialize member: module.
+ (md_close): Call _gcry_module_release.
+
+ * cipher.c (gcry_cipher_open): New variable: module, changed use of
+ module and cipher.
+ (struct gcry_cipher_handle): New member: module.
+ (gcry_cipher_open): Initialize member: module.
+ (gcry_cipher_close): Call _gcry_module_release.
+
+2003-04-09 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c: Include "ath.h".
+ * md.c: Likewise.
+ * pubkey.c: Likewise.
+
+ * cipher.c (ciphers_registered_lock): New variable.
+ * md.c (digests_registered_lock): New variable.
+ * pubkey.c (pubkeys_registered_lock): New variable.
+
+ * rndlinux.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndlinux_constructor): Removed function.
+
+ * rndegd.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndegd_constructor): Removed function.
+
+ * rndunix.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndunix_constructor): Removed function.
+
+ * rndw32.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndw32_constructor): Removed function.
+
+ * rndegd.c (rndegd_connect_socket): Simplify code for creating the
+ egd socket address.
+ (rndegd_connect_socket): Call log_fatal use instead of
+ g10_log_fatal.
+ (egd_gather_random): Renamed to ...
+ (rndegd_gather_random): ... here.
+
+2003-04-08 Moritz Schulte <moritz@g10code.com>
+
+ * rndlinux.c: Do not include "dynload.h".
+ * rndunix.c: Likewise.
+ * rndw32.c: Likewise.
+
+ * rndegd.c (rndegd_connect_socket): Factored out from ...
+ (egd_gather_random): here; call it.
+ (egd_socket): New variable.
+ (egd_gather_random): Initialize fd with egd_socket, do not declare
+ fd static.
+ (do_read): Merged few changes from GnuPG. FIXME - not finished?
+ Do not include "dynload.h".
+
+ * rndw32.c (gather_random): Renamed to rndw32_gather_random, do
+ not declare static.
+ (gather_random_fast): Renamed to rndw32_gather_random_fast, do not
+ declare static.
+
+ * rndunix.c (gather_random): Renamed to rndunix_gather_random, do
+ not declare static.
+ * rndegd.c (gather_random): Renamed to rndegd_gather_random, do
+ not declare static.
+ * rndlinux.c (gather_random): Renamed to rndlinux_gather_random,
+ do not declare static.
+
+2003-04-07 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (libcipher_la_SOURCES): Removed construct.c.
+ (libcipher_la_SOURCES): Added sha1.c, sha256.c, rmd160.c, md4.c,
+ md5.c, tiger.c and crc.c
+ (EXTRA_PROGRAMS): Removed sha1, sha256, rmd160, md4, md5, tiger
+ and crc. Removed definitions: EXTRA_md4_SOURCES,
+ EXTRA_md5_SOURCES, EXTRA_rmd160_SOURCES, EXTRA_sha1_SOURCES,
+ EXTRA_sha256_SOURCES, EXTRA_tiger_SOURCES and EXTRA_crc_SOURCES,
+ BUILT_SOURCES, DISTCLEANFILES.
+
+ * pubkey.c: Do not include "elgamal.h", "dsa.h" and "rsa.h".
+
+ * Makefile.am (libcipher_la_SOURCES): Removed rsa.h, elgamal.h,
+ dsa.h, des.h, cast5.h, arcfour.h and blowfish.h.
+
+ * rsa.h: Removed file.
+ * elgamal.h: Removed file.
+ * dsa.h: Removed file.
+ * des.h: Removed file.
+ * cast5.h: Removed file.
+ * arcfour.h: Removed file.
+ * blowfish.h: Removed file.
+
+ * Makefile.am (libcipher_la_SOURCES): Removed dynload.c and
+ dynload.h.
+
+ * rsa.c (pubkey_spec_rsa): New variable.
+ * dsa.c (pubkey_spec_rsa): New variable.
+ * elgamal.c (pubkey_spec_elg): New variable.
+
+ * rsa.c (_gcry_rsa_get_info): Removed function.
+ * elgamal.c (_gcry_elg_get_info): Removed function.
+ * dsa.c (_gcry_dsa_get_info): Removed function.
+
+ * tiger.c (tiger_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_tiger_constructor): Removed function.
+
+ * sha1.c (sha1_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_sha1_constructor): Removed function.
+
+ * sha256.c (sha256_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_sha256_constructor): Removed function.
+
+ * rmd160.c (rmd160_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rmd160_constructor): Removed function.
+
+ * md5.c (md5_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_md5_constructor): Removed function.
+
+ * md4.c (md4_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_md4_constructor): Removed function.
+
+ * crc.c (crc_get_info): Removed function.
+
+ * arcfour.c (do_arcfour_setkey): Changed type of context argument
+ to `void *', added local variable for cast, adjusted callers.
+ (arcfour_setkey): Likewise.
+ (encrypt_stream): Likewise.
+ * cast5.c (cast_setkey): Likewise.
+ (encrypt_block): Likewise.
+ * rijndael.c (rijndael_setkey): Likewise.
+ (rijndael_encrypt): Likewise.
+ (rijndael_decrypt): Likewise.
+ * twofish.c (twofish_setkey): Likewise.
+ (twofish_encrypt): Likewise.
+ (twofish_decrypt): Likewise.
+ * des.c (do_des_setkey): Likewise.
+ (do_des_encrypt): Likewise.
+ (do_des_encrypt): Likewise.
+ (do_tripledes_encrypt): Likewise.
+ (do_tripledes_encrypt): Likewise.
+ * blowfish.c (bf_setkey: Likewise.
+ (encrypt_block): Likewise.
+ (decrypt_block): Likewise.
+
+ * arcfour.c (encrypt_stream): Likewise.
+
+ * rijndael.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func) Removed function.
+
+ * twofish.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func) Removed function.
+
+ * cast5.c (CIPHER_ALGO_CAST5): Removed.
+
+ * blowfish.c (FNCCAST_SETKEY, FNCCAST_CRYPT): Removed macros.
+ (CIPHER_ALGO_BLOWFISH): Removed symbol.
+ * cast5.c (FNCCAST_SETKEY, FNCCAST_CRYPT): Likewise.
+ * des.c (selftest_failed): Removed.
+ (initialized): New variable.
+ (do_des_setkey): Run selftest, if not yet done.
+ (FNCCAST_SETKEY, FNCCAST_CRYPT): Removed macros.
+
+ * arcfour.c (_gcry_arcfour_get_info): Removed function.
+ * blowfish.c (_gcry_blowfish_get_info): Removed function.
+ * cast5.c (_gcry_cast5_get_info): Removed function.
+ * des.c (_gcry_des_get_info): Removed function.
+ * rijndael.c (_gcry_rijndael_get_info): Removed function.
+ * twofish.c (_gcry_twofish_get_info): Removed function.
+
+ * arcfour.c (cipher_spec_arcfour): New variable.
+ * twofish.c (cipher_spec_twofish, cipher_spec_twofish128): New
+ variables.
+ * rijndael.c (cipher_spec_aes, cipher_spec_aes192,
+ cipher_spec256): New variables.
+ * des.c (cipher_spec_des, cipher_spec_tripledes): New variables.
+ * cast5.c (cipher_spec_cast5): New variable.
+ * blowfish.c (cipher_spec_blowfish): Likewise.
+
+ * twofish.c: Do not include "dynload.h".
+ * rijndael.c: Likewise.
+ * des.c: Likewise.
+ * cast5.c: Likewise.
+ * blowfish.c: Likewise.
+ * cipher.c: Likewise.
+ * crc.c: Likewise.
+ * md4.c: Likewise.
+ * md5.c: Likewise.
+ * md.c: Likewise.
+ * pubkey.c: Likewise.
+ * rijndael.c: Likewise.
+ * sha1.c: Likewise.
+ * sha256.c: Likewise.
+
+ * arcfour.c: Include "cipher.h".
+ * twofish.c: Likewise.
+ * rijndael.c: Likewise.
+ * des.c: Likewise.
+ * cast5.c: Likewise.
+ * blowfish.c: Likewise.
+
+ * twofish.c (twofish_setkey): Declared argument `key' const.
+ (twofish_encrypt): Declared argument `inbuf' const.
+ (twofish_decrypt): Likewise.
+
+ * rijndael.c (rijndael_setkey): Declared argument `key' const.
+ (rijndael_encrypt): Declared argument `inbuf' const.
+ (rijndael_decrypt): Likewise.
+
+ * des.c (do_des_setkey): Declared argument `key' const.
+ (do_tripledes_setkey): Likewise.
+ (do_des_encrypt): Declared argument `inbuf' const.
+ (do_des_decrypt): Likewise.
+ (do_tripledes_encrypt): Likewise.
+ (do_tripledes_decrypt): Likewise.
+
+ * cast5.c (encrypt_block): Declared argument `inbuf' const.
+ (decrypt_block): Likewise.
+ (cast_setkey): Declared argument `key' const.
+
+ * blowfish.c (do_bf_setkey): Declared argument `key' const.
+ (encrypt_block): Declared argument `inbuf' const.
+ (encrypt_block): Likewise.
+
+
+
+ * cipher.c: Remove CIPHER_ALGO_DUMMY related code.
+ Removed struct cipher_table_s.
+ Changed definition of cipher_table.
+ Removed definition of disabled_algos.
+ (ciphers_registered, default_ciphers_registered): New variables.
+ (REGISTER_DEFAULT_CIPHERS): New macro.
+ (dummy_setkey): Declared argument `key' const.
+ (dummy_encrypt_block): Declared argument `inbuf' const.
+ (dummy_encrypt_block): Likewise.
+ (dummy_encrypt_stream): Likewise.
+ (dummy_encrypt_stream): Likewise.
+ (dummy_setkey): Use `unsigned char' instead of `byte'.
+ (dummy_encrypt_block): Likewise.
+ (dummy_decrypt_block): Likewise.
+ (dummy_encrypt_stream): Likewise.
+ (dummy_decrypt_stream): Likewise.
+ (gcry_cipher_register_default): New function.
+ (gcry_cipher_lookup_func_id): New function.
+ (gcry_cipher_lookup_func_name): New function.
+ (gcry_cipher_lookup_id): New function.
+ (gcry_cipher_lookup_name): New function.
+ (gcry_cipher_id_new): New function.
+ (gcry_cipher_register): New function.
+ (gcry_cipher_unregister): New function.
+ (setup_cipher_table): Removed function.
+ (load_cipher_modules): Removed function.
+ (gcry_cipher_map_name): Adjusted to use new module management.
+ (cipher_algo_to_string): Likewise.
+ (disable_cipher_algo): Likewise.
+ (check_cipher_algo): Likewise.
+ (cipher_get_keylen): Likewise.
+ (cipher_get_blocksize): Likewise.
+ (gcry_cipher_open): Likewise.
+ (struct gcry_cipher_handle): Replaced members algo, algo_index,
+ blocksize, setkey, encrypt, decrypt, stencrypt, stdecrypt with one
+ member: cipher.
+ (gcry_cipher_open): Adjusted code for new handle structure.
+ (cipher_setkey): Likewise.
+ (cipher_setiv): Likewise.
+ (cipher_reset): Likewise.
+ (do_ecb_encrypt): Likewise.
+ (do_ecb_decrypt): Likewise.
+ (do_cbc_encrypt): Likewise.
+ (do_cbc_decrypt): Likewise.
+ (do_cfb_encrypt): Likewise.
+ (do_cfb_decrypt): Likewise.
+ (do_ctr_encrypt): Likewise.
+ (cipher_encrypt): Likewise.
+ (gcry_cipher_encrypt): Likewise.
+ (cipher_decrypt): Likewise.
+ (gcry_cipher_decrypt): Likewise.
+ (cipher_sync): Likewise.
+ (gcry_cipher_ctl): Likewise.
+
+ * pubkey.c: Removed struct pubkey_table_s.
+ Changed definition of pubkey_table.
+ Removed definition of disabled_algos.
+ (pubkeys_registered, default_pubkeys_registered): New variables.
+ (REGISTER_DEFAULT_PUBKEYS): New macro.
+ (setup_pubkey_table): Removed function.
+ (load_pubkey_modules): Removed function.
+ (gcry_pubkey_register_default): New function.
+ (gcry_pubkey_lookup_func_id): New function.
+ (gcry_pubkey_lookup_func_name): New function.
+ (gcry_pubkey_lookup_id): New function.
+ (gcry_pubkey_lookup_name): New function.
+ (gcry_pubkey_id_new): New function.
+ (gcry_pubkey_register): New function.
+ (gcry_pubkey_unregister): New function.
+ (gcry_pk_map_name): Adjusted to use new module management.
+ (gcry_pk_algo_name): Likewise.
+ (disable_pubkey_algo): Likewise.
+ (check_pubkey_algo): Likewise.
+ (pubkey_get_npkey): Likewise.
+ (pubkey_get_nskey): Likewise.
+ (pubkey_get_nsig): Likewise.
+ (pubkey_get_nenc): Likewise.
+ (pubkey_generate): Likewise.
+ (pubkey_check_secret_key): Likewise.
+ (pubkey_encrypt): Likewise.
+ (pubkey_decrypt): Likewise.
+ (pubkey_sign): Likewise.
+ (pubkey_verify): Likewise.
+ (gcry_pk_get_nbits): Likewise.
+ (gcry_pk_algo_info): Likewise.
+
+ * md.c: Removed struct md_digest_list_s.
+ (digest_list): Changed definition.
+ (digests_registered, default_digests_registered): New variables.
+ (REGISTER_DEFAULT_DIGESTS): New macro.
+ (new_list_item): Removed function.
+ (setup_md_table): Removed function.
+ (load_digest_module): Removed function.
+ (gcry_digest_register_default): New function.
+ (gcry_digest_lookup_func_id): New function.
+ (gcry_digest_lookup_func_name): New function.
+ (gcry_digest_lookup_id): New function.
+ (gcry_digest_lookup_name): New function.
+ (gcry_digest_id_new): New function.
+ (gcry_digest_register): New function.
+ (gcry_digest_unregister): New function.
+ (GcryDigestEntry): New type.
+ (struct gcry_md_context): Adjusted type of `list'.
+ (gcry_md_map_name): Adjusted to use new module management.
+ (digest_algo_to_string): Likewise.
+ (check_digest_algo): Likewise.
+ (md_enable): Likewise.
+ (md_digest_length): Likewise.
+ (md_asn_oid): Likewise.
+
+2003-04-07 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c: Replaced PUBKEY_ALGO_DSA with GCRY_PK_DSA,
+ PUBKEY_ALGO_RSA with GCRY_PK_RSA and PUBKEY_ALGO_ELGAMAL with
+ GCRY_PK_ELG.
+
+ * dsa.c: Replaced PUBKEY_ALGO_DSA with GCRY_PK_DSA.
+
+2003-04-01 Moritz Schulte <moritz@g10code.com>
+
+ * des.c: Removed checks for GCRY_CIPHER_3DES and GCRY_CIPHER_DES.
+
+2003-03-31 Moritz Schulte <moritz@g10code.com>
+
+ * tiger.c (tiger_get_info): Do not declare static.
+ * sha256.c (sha256_get_info): Likewise.
+ * sha1.c (sha1_get_info): Likewise.
+ * rmd160.c (rmd160_get_info): Likewise.
+ * md5.c (md5_get_info): Likewise.
+ * md4.c (md4_get_info): Likewise.
+ * crc.c (crc_get_info): Likewise.
+
+ * md.c (load_digest_module): Call setup_md_table during
+ initialization.
+ (new_list_item): Link new element into digest_list.
+
+ * cipher.c (do_ctr_decrypt): Made do_ctr_encrypt act as a wrapper
+ for do_ctr_encrypt, since these functions are identical.
+
+2003-03-30 Simon Josefsson <jas@extundo.com>
+
+ * cipher.c (struct gcry_cipher_handle): Add counter field.
+ (gcry_cipher_open): Add CTR.
+ (cipher_reset): Clear counter field.
+ (do_ctr_encrypt, do_ctr_decrypt): New functions.
+ (cipher_encrypt, cipher_decrypt): Call CTR functions.
+ (gcry_cipher_ctl): Add SET_CTR to set counter.
+
+2003-03-30 Moritz Schulte <moritz@g10code.com>
+
+ * rsa.c (_gcry_rsa_blind): New function.
+ (_gcry_rsa_unblind): New function.
+ (_gcry_rsa_decrypt): Use _gcry_rsa_blind and _gcry_rsa_decrypt.
+
+2003-03-26 Moritz Schulte <moritz@g10code.com>
+
+ * dynload.c (_gcry_enum_gnupgext_pubkeys): Adjust `encrypt' and
+ `decrypt' function arguments.
+ (_gcry_enum_gnupgext_pubkeys): Likewise.
+ * dynload.h: Likewise.
+
+ * pubkey.c (dummy_decrypt): Add argument: int flags.
+ (dummy_encrypt): Likewise.
+
+ * elgamal.c (_gcry_elg_encrypt): Add argument: int flags.
+ (_gcry_elg_decrypt): Likewise.
+
+ * rsa.c (_gcry_rsa_encrypt): Add argument: int flags.
+ (_gcry_rsa_decrypt): Likewise.
+
+ * pubkey.c: Add `flags' argument to members `encrypt' and
+ `decrypt' of struct `pubkey_table_s'.
+
+ * rsa.h: Add `flags' argument to function declarations.
+ * elgamal.h: Likewise.
+
+ * pubkey.c (sexp_data_to_mpi): New variable: int parsed_flags.
+ (sexp_data_to_mpi): Set `parsed_flags'.
+ (sexp_data_to_mpi): New argument: int *flags.
+ (gcry_pk_encrypt): New variable: int flags.
+ (gcry_pk_encrypt): Pass `flags' to pubkey_encrypt.
+ (pubkey_encrypt): New variable: int flags.
+ (pubkey_encrypt): Pass `flags' to pubkey encrypt function.
+ (pubkey_decrypt): Likewise.
+ (pubkey_decrypt): Pass `flags' to pubkey encrypt function.
+ (gcry_pk_encrypt): Include `flags' s-exp in return list.
+ (sexp_to_enc): New argument: int *flags.
+ (gcry_pk_decrypt): New variable: int flags.
+ (gcry_pk_decrypt): Pass `flags' to pubkey_decrypt.
+ (sexp_to_enc): New variable: int parsed_flags.
+ (sexp_to_enc): Set `parsed_flags'.
+
+2003-03-22 Simon Josefsson <jas@extundo.com>
+
+ * cipher.c (gcry_cipher_open, do_cbc_encrypt)
+ (gcry_cipher_encrypt): Support GCRY_CIPHER_CBC_MAC.
+ (gcry_cipher_ctl): Support GCRYCTL_SET_CBC_MAC.
+
+2003-03-19 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): New args EXTRA_CHECK and EXTRA_CHECK_ARG
+ to allow for a user callback. Changed all callers.
+ (_gcry_generate_secret_prime)
+ (_gcry_generate_public_prime): Ditto, pass them to gen_prime.
+ * rsa.c (check_exponent): New.
+ (generate): Use a callback to ensure that a given exponent is
+ actually generated.
+
+2003-03-12 Moritz Schulte <moritz@g10code.com>
+
+ * primegen.c: Initialize `no_of_small_prime_numbers' statically.
+ (gen_prime): Remove calculation of `no_of_small_prime_numbers'.
+
+2003-03-03 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (gcry_md_ctl): Rewritten to use same style like the other
+ functions dispatchers.
+
+2003-03-02 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (struct gcry_cipher_handle): New member: algo_index.
+ (gcry_cipher_open): Allocate memory for two cipher contexts.
+ Initialize algo_index.
+ (cipher_setkey): Duplicate context into reserved memory.
+ (cipher_reset): New function, which resets the context and clear
+ the IV.
+ (gcry_cipher_ctl): Call cipher_reset.
+
+2003-02-23 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c: Remove (bogus) `digitp' macro definition.
+ * md.c: Likewise.
+
+ * blowfish.c (burn_stack): Removed.
+ * arcfour.c (burn_stack): Likewise.
+ * cast5.c (burn_stack): Likewise.
+ * des.c (burn_stack): Likewise.
+ * md4.c (burn_stack): Likewise.
+ * md5.c (burn_stack): Likewise.
+ * random.c (burn_stack): Likewise.
+ * rijndael.c (burn_stack): Likewise.
+ * rmd160.c (burn_stack): Likewise.
+ * sha1.c (burn_stack): Likewise.
+ * sha256.c (burn_stack): Likewise.
+ * tiger.c (burn_stack): Likewise.
+ * twofish.c (burn_stack): Likewise.
+
+ * blowfish.c: Changed all occurences of burn_stack to
+ _gcry_burn_stack.
+ * arcfour.c: Likewise.
+ * cast5.c: Likewise.
+ * des.c: Likewise.
+ * md4.c: Likewise.
+ * md5.c: Likewise.
+ * random.c: Likewise.
+ * rijndael.c: Likewise.
+ * rmd160.c: Likewise.
+ * sha1.c: Likewise.
+ * sha256.c: Likewise.
+ * tiger.c: Likewise.
+ * twofish.c: Likewise.
+
+ * arcfour.c (_gcry_arcfour_get_info): Use GCRY_CIPHER_ARCFOUR
+ instead of hard-coded value `301'.
+
+2003-01-24 Werner Koch <wk@gnupg.org>
+
+ * random.c (_gcry_register_random_progress): New.
+ (_gcry_random_progress): New.
+
+ * rndlinux.c (gather_random): Call the random progress function.
+
+2003-01-23 Werner Koch <wk@gnupg.org>
+
+ * rsa.c (generate): New arg USE_E to request a specific public
+ exponent.
+ (_gcry_rsa_generate): Ditto.
+ * elgamal.c (_gcry_elg_generate): Must add an dummy argument
+ instead of USE_E.
+ * dsa.c (_gcry_dsa_generate): Ditto.
+ * pubkey.c (dummy_generate): Ditto.
+ (pubkey_generate): Add USE_E arg and pass it down.
+ (gcry_pk_genkey): Detect "rsa-use-e" parameter and pass it to generate.
+
+ * pubkey.c (sexp_to_enc): New arg RET_MODERN.
+ (gcry_pk_decrypt): Make use of it to return a real S-expression.
+ Return better error codes.
+ (gcry_pk_verify): Return better error codes.
+
+2003-01-21 Werner Koch <wk@gnupg.org>
+
+ * random.c (gcry_random_add_bytes): Add QUALITY argument, let
+ function return an error code and disable its core for now.
+
+2003-01-21 Timo Schulz <twoaday@freakmail.de>
+
+ * random.c (gcry_random_add_bytes): New. Function to add external
+ random to the pool.
+
+2003-01-20 Simon Josefsson <jas@extundo.com>
+
+ * crc.c: New.
+ * Makefile.am (EXTRA_PROGRAMS, EXTRA_crc_SOURCES): Add crc.c.
+ * md.c (gcry_md_get_algo_dlen): Add values for CRC.
+
+2003-01-20 Werner Koch <wk@gnupg.org>
+
+ * sha256.c: New.
+ * bithelp.h (ror): New.
+ * Makfile.am: Add sha256.c.
+ * md.c (oid_table): Add values for SHA256 et al.
+ (gcry_md_get_algo_dlen): Likewise
+
+2003-01-20 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_get_keygrip): Implemented keygrips for DSA
+ and ElGamal.
+
+2003-01-17 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_encrypt): Reworked so that the output will
+ never contain the plaintext even if the caller did not checked the
+ return value.
+
+ * md.c (gcry_md_get_algo): Changed error code to GCRYERR_GENERAL
+ because we don't have an invalid md algo but no algorithm enabled.
+
+ * pubkey.c (gcry_pk_genkey): Changed error code for bounds check
+ of table parameters to GCRYERR_INTERNAL.
+
+ * md.c (gcry_md_open): Partly reverted Timo's change from
+ 2002-10-10 by removing the check for the algorithm. An algorithm
+ of 0 is allowed and anyway we should not double check it or check
+ it using a different function. Also fixed the flags check.
+
+ * pubkey.c (gcry_pk_encrypt): Make sure that R_CIPH points to NULL
+ on error.
+ (gcry_pk_decrypt): Ditto for R_PLAIN.
+ (gcry_pk_sign): Ditto for R_SIG.
+ (gcry_pk_genkey): Ditto for R_KEY.
+
+2003-01-16 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_write): Changed 2nd argument type to void*.
+ (gcry_md_hash_buffer): Changed type of boths buffers to void*.
+ (gcry_md_setkey): Changed 2nd argument type to void*.
+
+2003-01-15 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (sexp_data_to_mpi): New. This handles pkcs1 padding.
+ (gcry_pk_sign, gcry_pk_verify): Use it here.
+ (gcry_pk_encrypt): And here.
+ (pubkey_verify): Add debug code.
+ (sexp_to_enc): Handle flags in the input and return the pkcs1 flag
+ in a new parameter.
+ (gcry_pk_decrypt): Prepare for future pkcs1 handling.
+
+2002-12-19 Werner Koch <wk@gnupg.org>
+
+ * random.c (_gcry_random_initialize): New.
+
+2002-12-16 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Added a Teletrust specific OID for 3DES.
+
+2002-12-12 Werner Koch <wk@gnupg.org>
+
+ * md.c: Added another oddball OIW OID (sha-1WithRSAEncryption).
+
+2002-11-23 Werner Koch <wk@gnupg.org>
+
+ * md.c (load_digest_module): Enlarged checked_algos bitmap.
+ * md4.c (func_table): Fixed entry for md4.
+ Both by Simon Josephson.
+ (transform): Copy data to get the alignment straight. Tested only
+ on i386.
+
+2002-11-10 Simon Josefsson <jas@extundo.com>
+
+ * cipher.c (gcry_cipher_open): Don't reject CTS flag.
+ (do_cbc_encrypt, do_cbc_decrypt, cipher_encrypt)
+ (gcry_cipher_encrypt, cipher_decrypt)
+ (gcry_cipher_decrypt): Support CTS flag.
+ (gcry_cipher_ctl): Toggle CTS flag.
+
+2002-11-10 Werner Koch <wk@gnupg.org>
+
+ * md4.c: New. By Simon Josefsson.
+ * Makefile.am (EXTRA_PROGRAMS): Add md4.c.
+ * md.c (oid_table,gcry_md_get_algo_dlen): MD4 support.
+
+2002-10-14 Werner Koch <wk@gnupg.org>
+
+ * arcfour.c (do_encrypt_stream): Don't use increment op when
+ assigning to the same variable.
+
+2002-10-10 Timo Schulz <ts@winpt.org>
+
+ * pubkey.c (gcry_pk_genkey): Check boundaries.
+
+ * md.c (gcry_md_open): Check that algo is available and only
+ valid flag values are used.
+ (gcry_md_get_algo): Add error handling.
+
+2002-09-26 Werner Koch <wk@gnupg.org>
+
+ * md.c: Include an OID for TIGER.
+ * tiger.c (tiger_get_info): Use a regular OID.
+
+2002-09-17 Werner Koch <wk@gnupg.org>
+
+ * random.c: Replaced mutex.h by the new ath.h. Changed all calls.
+
+2002-09-16 Werner Koch <wk@gnupg.org>
+
+ * arcfour.c (do_encrypt_stream): Use register modifier and modulo.
+ According to Nikos Mavroyanopoulos this increases perfromace on
+ i386 system noticable. And I always tought gcc is clever enough.
+ * md5.c (transform): Use register modifier.
+ * rmd160.c (transform): Ditto.
+ * sha1.c (transform): Ditto. We hope that there are 6 free registers.
+ * random.c (gcry_randomize): Rewrote to avoid malloc calls.
+
+ * rndlinux.c (gather_random): Replaced remaining fprintfs by log_*.
+ * arcfour.c (do_arcfour_setkey): Ditto.
+ * twofish.c (do_twofish_setkey): Ditto.
+ * rndegd.c (gather_random): Ditto.
+ * rijndael.c (do_setkey): Ditto.
+ * random.c (_gcry_random_dump_stats): Ditto.
+ * primegen.c (_gcry_generate_elg_prime): Ditto.
+ * des.c (_gcry_des_get_info): Ditto.
+ * cast5.c (do_cast_setkey): Ditto.
+ * blowfish.c (do_bf_setkey): Ditto.
+
+2002-08-26 Werner Koch <wk@gnupg.org>
+
+ * des.c (weak_keys): Fixed one entry in the table and compared
+ all entries against the literature.
+ (selftest): Checksum the weak key table.
+
+2002-08-21 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c: Enable keygrip calculation for "openpgp-rsa".
+
+2002-08-17 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (setup_cipher_table): Don't overwrite the DES entry
+ with the entry for DUMMY.
+
+2002-08-14 Werner Koch <wk@gnupg.org>
+
+ * des.c (do_des_setkey,do_des_encrypt, do_des_decrypt): New.
+ (_gcry_des_get_info): Support plain old DES.
+ * cipher.c (setup_cipher_table): Put DES into the table.
+
+2002-07-25 Werner Koch <wk@gnupg.org>
+
+ * rndunix.c (_gcry_rndunix_constructor): Prefixed with _gcry_.
+ Noted by Stephan Austermuehle.
+
+2002-07-08 Timo Schulz <ts@winpt.org>
+
+ * rndw32.c: Replaced the m_ memory functions with the real
+ gcry_ functions. Renamed all g10_ prefixed functions to log_.
+
+2002-06-12 Werner Koch <wk@gnupg.org>
+
+ * rsa.c (generate): Use e = 65537 for now.
+
+2002-06-11 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_get_keygrip): Allow a "protected-private-key".
+
+2002-06-05 Timo Schulz <ts@winpt.org>
+
+ * cipher.c (gcry_cipher_encrypt, gcry_cipher_decrypt):
+ Check that the input size is a multiple of the blocksize.
+
+2002-05-23 Werner Koch <wk@gnupg.org>
+
+ * md.c (oid_table): Add an rsadsi OID for MD5.
+
+2002-05-21 Werner Koch <wk@gnupg.org>
+
+ * primegen.c, elgamal.c, dsa.c (progress): Do not print anything
+ by default. Pass an extra identifying string to the callback and
+ reserved 2 argumenst for current and total counters. Changed the
+ register function prototype.
+
+2002-05-17 Werner Koch <wk@gnupg.org>
+
+ * rndegd.c (rndegd_constructor): Fixed name of register function
+ and prefixed the function name with _gcry_.
+ * rndw32.c (rndw32_constructor): Ditto.
+ * tiger.c (tiger_constructor): Ditto.
+
+ * Makefile.am: Removed all dynamic loading stuff.
+ * dynload.c: Ditto. Now only used for the constructor system.
+
+2002-05-15 Werner Koch <wk@gnupg.org>
+
+ * random.c (gcry_random_bytes,gcry_random_bytes_secure)
+ (gcry_randomize): Make sure we are initialized.
+
+2002-05-14 Werner Koch <wk@gnupg.org>
+
+ Changed license of most files to the LGPL.
+
+2002-05-02 Werner Koch <wk@gnupg.org>
+
+ * random.c (_gcry_fast_random_poll): Initialize the module so the
+ mutex can be used.
+
+ * primegen.c (small_prime_numbers): Moved table from smallprime.c
+ * smallprime.c: File removed.
+
+ * des.c (leftkey_swap, rightkey_swap, working_memcmp): Made static.
+
+ * cipher.c (gcry_cipher_map_name): Map "RIJNDAEL" to "AES".
+ * rijndael.c (rijndael_get_info): We do only support a 128 bit
+ blocksize so it makes sense to change the algorithm strings to
+ AES.
+
+ * tiger.c (tiger_final): Removed superfluous token pasting operators.
+ * md5.c (md5_final): Ditto.
+
+2002-04-30 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Fixed list of copyright years.
+
+2002-03-18 Werner Koch <wk@gnupg.org>
+
+ * random.c (initialize): Initialize the new pool lock mutex.
+ (_gcry_fast_random_poll): Add locking and moved main
+ code out to...
+ (do_fast_random_poll): new function.
+ (read_pool): Use the new function here.
+ (get_random_bytes): Add locking.
+ (_gcry_update_random_seed_file): Ditto.
+
+2002-03-11 Werner Koch <wk@gnupg.org>
+
+ * md.c: Add rsaSignatureWithripemd160 to OID table.
+
+2002-02-20 Werner Koch <wk@gnupg.org>
+
+ * sha1.c: Removed a left over comment note. The code has been
+ rewritten from scratch in 1998. Thanks to Niels Möller for
+ reporting this misleading comment.
+
+2002-02-18 Werner Koch <wk@gnupg.org>
+
+ * rndunix.c (rndunix_constructor): Use the the new prefixed
+ function name. Reported by Jordi Mallach.
+
+2002-02-10 Werner Koch <wk@gnupg.org>
+
+ * random.c (mix_pool): Carry an extra failsafe_digest buffer
+ around to make the function more robust.
+
+2002-02-08 Werner Koch <wk@gnupg.org>
+
+ * random.c (add_randomness): Xor new data into the pool and not
+ just copy it. This avoids any choosen input attacks which are not
+ serious in our setting because an outsider won't be able to mix
+ data in and even then we keep going with a PRNG. Thanks to Stefan
+ Keller for pointing this out.
+
+2002-01-04 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_genkey): Do not release skey - it is static.
+
+ * primegen.c (gen_prime): Of course we should use set_bit
+ and not set_highbit to set the second high bit.
+
+2001-12-18 Werner Koch <wk@gnupg.org>
+
+ * rsa.c (generate): Loop until we find the exact modulus size.
+ Changed the exponent to 41.
+ (rsa_get_info): s/usage/r_usage/ to avoid shadow warnings.
+ * primegen.c (gen_prime): Set 2 high order bits for secret primes.
+
+ * Makefile.am (DISTCLEANFILES): Include construct.c.
+
+2001-12-17 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_get_keygrip): New - experimental.
+
+2001-12-11 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Added OIDs for AES.
+ (gcry_cipher_mode_from_oid): New.
+ (gcry_cipher_map_name): Moved OID search code to ..
+ (search_oid): .. new function.
+
+2001-12-10 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_encrypt): Find the signature algorithm by name
+ and not by number.
+
+ * pubkey.c (gcry_pk_encrypt,gcry_pk_decrypt,gcry_pk_sign)
+ (gcry_pk_verify,gcry_pk_testkey, gcry_pk_genkey)
+ (gcry_pk_get_nbits): Release the arrays. Noted by Nikos
+ Mavroyanopoulos.
+
+2001-12-06 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_map_name): Look also for OIDs prefixed
+ with "oid." or "OID.".
+
+2001-12-05 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (algo_info_table): Fixed entry for openpgp-rsa.
+
+2001-11-24 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c: Added the rsaEncryption OID to the tables.
+ (sexp_to_key): Add an arg to return the index of the algorithm,
+ changed all callers.
+ (gcry_pk_sign): Find the signature algorithm by name and not by
+ number.
+ (gcry_pk_get_nbits): Fixed so that we can now really pass a secret
+ key to get the result.
+
+ * md.c (gcry_md_map_name): Look also for OIDs prefixed with "oid."
+ or "OID." so that an OID string can be used as an S-Exp token.
+
+2001-11-20 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_map_name): Lookup by OID if the the name begins
+ with a digit.
+ (oid_table): New.
+
+2001-11-16 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_info): New operator GCRYCTL_IS_ALGO_ENABLED.
+
+2001-11-07 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Close the handle which was left open
+ for algorithms other than rmd160.
+
+2001-08-08 Werner Koch <wk@gnupg.org>
+
+ * rndw32.c (gather_random): Use toolhelp in addition to the NT
+ gatherer for Windows2000. Suggested by Sami Tolvanen.
+
+ * random.c (read_pool): Fixed length check, this used to be one
+ byte to strict. Made an assert out of it because the caller has
+ already made sure that only poolsize bytes are requested.
+ Reported by Marcus Brinkmann.
+
+2001-08-03 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (cipher_encrypt, cipher_decrypt): Prepare to return
+ errors. We have to change the interface to all ciphers to make
+ this really work but we should do so to prepare for hardware
+ encryption modules.
+ (gcry_cipher_encrypt, gcry_cipher_decrypt): Return the error and
+ set lasterr.
+ (gcry_cipher_ctl): Make sure that errors from setkey are returned.
+
+2001-08-02 Werner Koch <wk@gnupg.org>
+
+ * rndlinux.c (gather_random): casted a size_t arg to int so that
+ the format string is correct. Casting is okay here and avoids
+ translation changes.
+
+ * random.c (fast_random_poll): Do not check the return code of
+ getrusage.
+
+ * rndunix.c: Add a signal.h header to avoid warnings on Solaris 7
+ and 8.
+
+ * tiger.c (print_abc,print_data): Removed.
+
+ * rijndael.c, des.c, blowfish.c, twofish.c, cast5.c, arcfour.c
+ (burn_stack): New. Add wrappers for most functions to be able to
+ call burn_stack after the function invocation. This methods seems
+ to be the most portable way to zeroise the stack used. It does
+ only work on stack frame based machines but it is highly portable
+ and has no side effects. Just setting the automatic variables at
+ the end of a function to zero does not work well because the
+ compiler will optimize them away - marking them as volatile would
+ be bad for performance.
+ * md5.c, sha1.c, rmd160.c, tiger.c (burn_stack): Likewise.
+ * random.c (burn_stack): New.
+ (mix_pool): Use it here to burn the stack of the mixblock function.
+
+ * primegen.c (_gcry_generate_elg_prime): Freed q at 3 places.
+ Thanks to Tommi Komulainen.
+
+ * arcfour.c (arcfour_setkey): Check the minimim keylength against
+ bytes and not bits.
+ (selftest): Must reset the key before decryption.
+
+2001-05-31 Werner Koch <wk@gnupg.org>
+
+ * sha1.c (sha1_init): Made static.
+
+ Changed all g10_ prefixed function names as well as some mpi_
+ function names to cope with the introduced naming changes.
+
+ * md.c (prepare_macpads): Made key const.
+
+2001-05-28 Werner Koch <wk@gnupg.org>
+
+ * rndegd.c (gather_random): Removed the use of tty_printf.
+
+2001-03-29 Werner Koch <wk@gnupg.org>
+
+ * md5.c (md5_final): Fixed calculation of hashed length. Thanks
+ to disastry@saiknes.lv for pointing out that it was horrible wrong
+ for more than 512MB of input.
+ * sha1.c (sha1_final): Ditto.
+ * rmd160.c (rmd160_final): Ditto.
+ * tiger.c (tiger_final): Ditto.
+
+ * blowfish.c (encrypt,do_encrypt): Changed name to do_encrypt to
+ avoid name clashes with an encrypt function in stdlib.h of
+ Dynix/PIX. Thanks to Gene Carter.
+ * elgamal.c (encrypt,do_encrypt): Ditto.
+
+ * twofish.c (gnupgext_enum_func): Use only when when compiled as a
+ module.
+ * rijndael.c (gnupgext_enum_func): Ditto.
+
+ * tiger.c (tiger_get_info): Return "TIGER192" and not just
+ "TIGER". By Edwin Woudt.
+
+ * random.c: Always include time.h - standard requirement. Thanks
+ to James Troup.
+
+ * rndw32.c: Fixes to the macros.
+
+2001-01-11 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (cipher_encrypt,gcry_cipher_encrypt): Use blocksize and
+ not 8.
+
+2000-12-19 Werner Koch <wk@gnupg.org>
+
+ Major change:
+ Removed all GnuPG stuff and renamed this piece of software
+ to gcrypt.
+
+2000-11-14 Werner Koch <wk@gnupg.org>
+
+ * dsa.c (test_keys): Replaced mpi_alloc by gcry_mpi_new and
+ mpi_free by gcry_mpi_release.
+ * elgamal.c (test_keys,generate): Ditto, also for mpi_alloc_secure.
+ * rsa.c (test_keys,generate,rsa_verify): Ditto.
+ * primegen.c (generate_elg_prime): Ditto.
+ (gen_prime): Ditto and removed nlimbs.
+
+ * rsa.c (generate): Allocate 2 more vars in secure memory.
+
+ * Makefile.am (OMIT_DEPENDENCIES): Hack to work around dependency
+ problems.
+
+2000-10-09 Werner Koch <wk@gnupg.org>
+
+ * arcfour.c, arcfour.h: New.
+ * cipher.c (cipher_encrypt, cipher_decrypt): Add stream mode.
+ (setup_cipher_table): Add Arcfour.
+ (gcry_cipher_open): Kludge to allow stream mode.
+
+Wed Oct 4 13:16:18 CEST 2000 Werner Koch <wk@openit.de>
+
+ * sha1.c (transform): Use rol() macro. Actually this is not needed
+ for a newer gcc but there are still aoter compilers.
+
+ * rsa.c (test_keys): Use new random function.
+
+ * md.c (gcry_md_setkey): New function to overcome problems with
+ const conflics.
+ (gcry_md_ctl): Pass set key to the new functions.
+
+ * rijndael.c: New.
+ * cipher.c: Add Rijndael support.
+
+Mon Sep 18 16:35:45 CEST 2000 Werner Koch <wk@openit.de>
+
+ * rndlinux.c (open_device): Loose random device checking.
+ By Nils Ellmenreich.
+
+ * random.c (fast_random_poll): Check ENOSYS for getrusage.
+ * rndunix.c: Add 2 sources for QNX. By Sam Roberts.
+
+ * pubkey.c (gcry_pk_algo_info): Add GCRYCTL_GET_ALGO_USAGE.
+
+ * rsa.c: Changed the comment about the patent.
+ (secret): Speed up by using the CRT. For a 2k keys this
+ is about 3 times faster.
+ (stronger_key_check): New but unused code to check the secret key.
+ * Makefile.am: Included rsa.[ch].
+ * pubkey.c: Enabled RSA support.
+ (pubkey_get_npkey): Removed RSA workaround.
+
+Mon Jul 31 10:04:47 CEST 2000 Werner Koch <wk@openit.de>
+
+ * pubkey.c: Replaced all gcry_sexp_{car,cdr}_{data,mpi} by the new
+ gcry_sexp_nth_{data,mpi} functions.
+
+Tue Jul 25 17:44:15 CEST 2000 Werner Koch <wk@openit.de>
+
+ * pubkey.c (exp_to_key,sexp_to_sig,sexp_to_enc,gcry_pk_encrypt,
+ gcry_pk_decrypt,gcry_pk_sign,gcry_pk_genkey): Changed to work with
+ the new S-Exp interface.
+
+Mon Jul 17 16:35:47 CEST 2000 Werner Koch <wk@>
+
+ * random.c (gather_faked): Replaced make_timestamp by time(2) again.
+
+Fri Jul 14 19:38:23 CEST 2000 Werner Koch <wk@>
+
+ * md.c (gcry_md_ctl): Support GCRYCTL_{START,STOP}_DUMP.
+
+ * Makefile.am: Never compile mingw32 as module.
+
+ * Makefile.am: Tweaked module build and removed libtool
+
+ * Makefile.am: Replaced -O1 by -O. Suggested by Alec Habig.
+
+ * elgamal.c (sign): Removed inactive code.
+
+ * rsa.c, rsa.h: New based on the old module version (only in CVS for now).
+ * pubkey.c (setup_pubkey_table): Added commented support for RSA.
+
+ * rndunix.c (waitpid): New. For UTS 2.1. All by Dave Dykstra.
+ (my_popen): Do the FD_CLOEXEC only if it is available
+ (start_gatherer): Cope with missing _SC_OPEN_MAX
+
+ * rndunix.c: Add some more headers for QNX. By Sam Roberts.
+
+ * rndegd.c (gather_random): Shortcut level 0.
+ * rndunix.c (gather_random): Ditto.
+ * rndw32.c (gather_random): Ditto.
+
+ * rndw32.c: Replaced with code from Cryptlib and commented the old stuff.
+ * rndw32.c: Add some debuging code enabled by an environment variable.
+
+ * random.c (read_seed_file): Binary open for DOSish system
+ (update_random_seed_file): Ditto.
+ * random.c [MINGW32]: Include process.h for getpid.
+ * random.c (fast_random_poll): Add clock_gettime() as fallback for
+ system which support this POSIX.4 fucntion. By Sam Roberts.
+
+ * random.c (read_seed_file): Removed the S_ISLNK test becuase it
+ is already covered by !S_ISREG and is not defined in Unixware.
+ Reported by Dave Dykstra.
+ (update_random_seed_file): Silently ignore update request when pool
+ is not filled.
+
+ * random.c (read_seed_file): New.
+ (set_random_seed_file): New.
+ (read_pool): Try to read the seeding file.
+ (update_random_seed_file): New.
+
+ (read_pool): Do an initial extra seeding when level 2 quality random
+ is requested the first time. This requestes at least POOLSIZE/2 bytes
+ of entropy. Compined with the seeding file this should make normal
+ random bytes cheaper and increase the quality of the random bytes
+ used for key generation.
+
+ * random.c (read_pool): Print a more friendly error message in
+ cases when too much random is requested in one call.
+
+ * random.c (fast_random_poll): Check whether RUSAGE_SELF is defined;
+ this is not the case for some ESIX and Unixware, although they have
+ getrusage().
+
+ * primegen.c (generate_elg_prime): All primes are now generated with
+ the lowest random quality level. Because they are public anyway we
+ don't need stronger random and by this we do not drain the systems
+ entropy so much.
+
+ * primegen.c (register_primegen_progress): New.
+ * dsa.c (register_pk_dsa_progress): New.
+ * elgamal.c (register_pk_elg_progress): New.
+
+ * elgamal.c (wiener_map): New.
+ (gen_k): Use a much smaller k.
+ (generate): Calculate the qbits using the wiener map and
+ choose an x at a size comparable to the one choosen in gen_k
+
+ * rmd160.c (rmd160_get_info): Moved casting to the left side due to a
+ problem with UTS4.3. Suggested by Dave Dykstra.
+ * sha1.c (sha1_get_info): Ditto.
+ * tiger.c (tiger_get_info): Ditto.
+ * md5.c (md5_get_info): Ditto
+ * des.c (des_get_info): Ditto.
+ * blowfish.c (blowfish_get_info): Ditto.
+ * cast5.c (cast5_get_info): Ditto.
+ * twofish.c (twofish_get_info): Ditto.
+
+Fri Mar 24 11:25:45 CET 2000 Werner Koch <wk@openit.de>
+
+ * md.c (md_open): Add hmac arg and allocate space for the pads.
+ (md_finalize): Add HMAC support.
+ (md_copy): Ditto.
+ (md_close): Ditto.
+ (gcry_md_reset): Ditto.
+ (gcry_md_ctl): Ditto.
+ (prepare_macpdas): New.
+
+Mon Mar 13 19:22:46 CET 2000 Werner Koch <wk@openit.de>
+
+ * md.c (gcry_md_hash_buffer): Add support for the other algorithms.
+
+Mon Jan 31 16:37:34 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * genprime.c (generate_elg_prime): Fixed returned factors which never
+ worked for non-DSA keys.
+
+Thu Jan 27 18:00:44 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (sexp_to_key): Fixed mem leaks in case of errors.
+
+Mon Jan 24 22:24:38 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (gcry_pk_decrypt): Implemented.
+ (gcry_pk_encrypt): Implemented.
+ (gcry_pk_testkey): New.
+ (gcry_pk_genkey): New.
+ (pubkey_decrypt): Made static.
+ (pubkey_encrypt): Ditto.
+ (pubkey_check_secret_key): Ditto.
+ (pubkey_generate): Ditto.
+
+Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (pubkey_nbits): Removed and replaced by ...
+ (gcry_pk_get_nbits): this new one.
+
+Wed Dec 8 21:58:32 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * dsa.c: s/mpi_powm/gcry_mpi_powm/g
+ * elgamal.c: Ditto.
+ * primegen.c: Ditto.
+
+ * : Replaced g10_opt_verbose by g10_log_verbosity().
+
+ * Makefile.am (INCLUDES): removed intl, add ../gcrypt
+
+Fri Nov 19 17:15:20 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * dynload.c (cmp_filenames): New to replaced compare_filename() in
+ module.
+ (register_cipher_extension): Removed the tilde expansion stuff.
+ * rndeg.c (my_make_filename): New.
+
+ * : Replaced header util.h by g10lib.h
+
+ * random.c (gather_faked): Replaced make_timestamp by time(2).
+ Disabled wrning printed with tty_printf.
+ * rndlinux.c (gather_random): Always use fprintf instead of tty_xxx;
+ this should be replaced by a callback function.
+
+ * primegen.c (gen_prime): Use gcry_mpi_randomize.
+ (is_prime): Ditto.
+ * elgamal.c (test_keys): Ditto.
+ * dsa.c (test_keys): Ditto.
+
+ * cipher.c (gcry_cipher_close): Die on invalid handle.
+
+Mon Nov 15 21:36:02 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * elgamal.c (gen_k): Use the new random API.
+ (generate): Ditto.
+ * dsa.c (gen_k): Ditto.
+ (generate): Ditto.
+
+Sat Nov 13 17:44:23 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (disable_pubkey_algo): Made static.
+ (gcry_pk_ctl): New.
+
+ * random.c (get_random_bits): Renamed to ...
+ (get_random_bytes): ... this and made static.
+ (gcry_random_bytes): New.
+ (gcry_random_bytes_secure): New.
+ (randomize_buffer): Renamed to ...
+ (gcry_randomize): ...this.
+
+ * md.c (gcry_md_hash_buffer): New.
+
+ * pubkey.c (gcry_pk_algo_info): 4 new commands.
+ (pubkey_get_npkey): Made static.
+ (pubkey_get_nskey): Made static.
+ (pubkey_get_nsig): Made static.
+ (pubkey_get_nenc): Made static.
+
+ * pubkey.c: Removed all G10ERR_xxx.
+ * cipher.c: Changed all GCRYERR_INV_ALGO to GCRYERR_INV_CIPHER_ALGO.
+ * md.c: Changed all GCRYERR_INV_ALGO to GCRYERR_INV_MD_ALGO.
+ * cast5.c (cast_setkey): Changed errocodes to GCRYERR_xxx.
+ * blowfish.c: Ditto.
+ * des.c: Ditto.
+ * twofish.c: Ditto.
+ * dsa.c: Ditto.
+ * elgamal.c: Ditto.
+
+ * g10c.c: Removed
+
+ * cipher.c (gcry_cipher_open): Replaced alloc functions and return NULL
+ if we are out of core.
+ * dynload.c: Replaced all memory allocation functions.
+ * md.c: Ditto.
+ * primegen.c: Ditto.
+ * pubkey.c: Ditto.
+ * random.c: Ditto.
+ * rndw32.c: Ditto.
+ * elgamal.c: Ditto.
+ * dsa.c: Ditto.
+
+Tue Oct 26 14:10:21 CEST 1999 Werner Koch <wk@gnupg.de>
+
+ * elgamal.c (sign): Hugh found strange code here. Replaced by BUG().
+
+ * cipher.c: Merged with gcrypt/symapi.c.
+
+ * pubkey.c (string_to_pubkey_algo): Renamed function to ...
+ (gcry_pk_map_name): ... this.
+ (pubkey_algo_to_string): Renamed function to ...
+ (gcry_pk_algo_name): ... this.
+ (gcry_pk_algo_info): New.
+ * pubkey.c: Merged with gcrypt/pkapi.c.
+
+ * md.c (md_reset): Clear finalized; thanks to Ulf Moeller for
+ fixing this bug.
+
+ * md.c: Merged with gcrypt/mdapi.c
+
+Wed Sep 15 14:39:59 CEST 1999 Michael Roth <mroth@nessie.de>
+
+ * des.c: Various speed improvements: One bit pre rotation
+ trick after initial permutation (Richard Outerbridge).
+ Finished test of SSLeay Tripple-DES patterns.
+
+Wed Sep 15 16:22:17 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndw32.c: New.
+
+Mon Sep 13 10:51:29 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * bithelp.h: New.
+ * rmd160.h, sha1.h, md5.h: Use the rol macro from bithelp.h
+
+Tue Sep 7 16:23:36 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Fixed seds for latest egcc. By Ollivier Robert.
+
+Mon Sep 6 19:59:08 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * des.c (selftest): Add some testpattern
+
+Mon Aug 30 20:38:33 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (do_cbc_encrypt): Fixed serious bug occuring when not using
+ in place encryption. Pointed out by Frank Stajano.
+
+Mon Jul 26 09:34:46 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md5.c (md5_final): Fix for a SCO cpp bug.
+
+Thu Jul 15 10:15:35 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * elgamal.c (elg_check_secret_key,elg_encrypt
+ elg_decrypt,elg_sign,elg_verify): Sanity check on the args.
+ * dsa.c (dsa_check_secret_key,dsa_sign,dsa_verify): Ditto.
+
+ * pubkey.c (disable_pubkey_algo): New.
+ (check_pubkey_algo2): Look at disabled algo table.
+ * cipher.c (disable_cipher_algo): New.
+ (check_cipher_algo): Look at disabled algo table.
+
+Wed Jul 7 13:08:40 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Support for libtool.
+
+Fri Jul 2 11:45:54 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dsa.c (gen_k): Changed algorithm to consume less random bytes
+ * elgamal.c (gen_k): Ditto.
+
+ * random.c (random_dump_stats): New.
+
+Thu Jul 1 12:47:31 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * primegen.c, elgamal.c, dsa.c (progess): New and replaced all
+ fputc with a call to this function.
+
+Sat Jun 26 12:15:59 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndegd.c (do_write): s/ssize_t/int/ due to SunOS 4.1 probs.
+
+ * cipher.c (do_cbc_encrypt, do_cbc_decrypt): New.
+
+ * dynload.c (HAVE_DL_SHL_LOAD): Map hpux API to dlopen (Dave Dykstra).
+ * Makefile.am (install-exec-hook): Removed.
+
+Sun May 23 14:20:22 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (setup_cipher_table): Enable Twofish
+
+ * random.c (fast_random_poll): Disable use of times() for mingw32.
+
+Mon May 17 21:54:43 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (register_internal_cipher_extension): Minor init fix.
+
+Tue May 4 15:47:53 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * primegen.c (gen_prime): Readded the Fermat test. Fixed the bug
+ that we didn't correct for step when passing the prime to the
+ Rabin-Miller test which led to bad performance (Stefan Keller).
+ (check_prime): Add a first Fermat test.
+
+Sun Apr 18 10:11:28 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (cipher_setiv): Add ivlen arg, changed all callers.
+
+ * random.c (randomize_buffer): alway use secure memory because
+ we can't use m_is_secure() on a statically allocated buffer.
+
+ * twofish.c: Replaced some macros by a loop to reduce text size.
+ * Makefile.am (twofish): No more need for sed editing.
+
+Fri Apr 9 12:26:25 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (cipher_open): Reversed the changes for AUTO_CFB.
+
+ * blowfish.c: Dropped the Blowfish 160 mode.
+ * cipher.c (cipher_open): Ditto.
+ (setup_cipher_table): Ditto. And removed support of twofish128
+
+Wed Apr 7 20:51:39 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (get_random_bits): Can now handle requests > POOLSIZE
+
+ * cipher.c (cipher_open): Now uses standard CFB for automode if
+ the blocksize is gt 8 (according to rfc2440).
+
+ * twofish.c: Applied Matthew Skala's patches for 256 bit key.
+
+Tue Apr 6 19:58:12 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (get_random_bits): Can now handle requests > POOLSIZE
+
+ * cipher.c (cipher_open): Now uses standard CFB for automode if
+ the blocksize is gt 8 (according to rfc2440).
+
+Sat Mar 20 11:44:21 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndlinux.c (tty_printf) [IS_MODULE]: Removed.
+
+ * rndegd.c (gather_random): Some fixes.
+
+Wed Mar 17 13:09:03 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndegd.c (do_read): New.
+ (gather_random): Changed the implementation.
+
+Mon Mar 8 20:47:17 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (DLSYM_NEEDS_UNDERSCORE): Renamed.
+
+Fri Feb 26 17:55:41 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md.c: Nearly a total rewrote.
+
+Wed Feb 24 11:07:27 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (context): Fixed alignment
+ * md.c: Ditto.
+
+ * rndegd.c: New
+
+Mon Feb 22 20:04:00 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndegd.c: New.
+
+Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Modules are now figured out by configure
+ * construct.c: New. Generated by configure. Changed all modules
+ to work with that.
+ * sha1.h: Removed.
+ * md5.h: Removed.
+
+ * twofish.c: Changed interface to allow Twofish/256
+
+ * rndunix.c (start_gatherer): Die on SIGPIPE.
+
+Wed Jan 20 18:59:49 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndunix.c (gather_random): Fix to avoid infinite loop.
+
+Sun Jan 17 11:04:33 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * des.c (is_weak_key): Replace system memcmp due to bugs
+ in SunOS's memcmp.
+ (des_get_info): Return error on failed selftest.
+ * twofish.c (twofish_setkey): Return error on failed selftest or
+ invalid keylength.
+ * cast5.c (cast_setkey): Ditto.
+ * blowfish.c (bf_setkey): Return error on failed selftest.
+
+Tue Jan 12 11:17:18 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (random_is_faked): New.
+
+ * tiger.c: Only compile if we have the u64 type
+
+Sat Jan 9 16:02:23 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndunix.c (gather_random): check for setuid.
+
+ * Makefile.am: Add a way to staically link random modules
+
+Thu Jan 7 18:00:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md.c (md_stop_debug): Do a flush first.
+ (md_open): size of buffer now depends on the secure parameter
+
+Sun Jan 3 15:28:44 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndunix.c (start_gatherer): Fixed stupid ==/= bug
+
+1998-12-31 Geoff Keating <geoffk@ozemail.com.au>
+
+ * des.c (is_weak_key): Rewrite loop end condition.
+
+Tue Dec 29 14:41:47 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c: add unistd.h for getpid().
+ (RAND_MAX): Fallback value for Sun.
+
+Wed Dec 23 17:12:24 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md.c (md_copy): Reset debug.
+
+Mon Dec 14 21:18:49 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (read_random_source): Changed the interface to the
+ random gathering function.
+ (gather_faked): Use new interface.
+ * dynload.c (dynload_getfnc_fast_random_poll): Ditto.
+ (dynload_getfnc_gather_random): Ditto.
+ * rndlinux.c (gather_random): Ditto.
+ * rndunix.c (gather_random): Ditto.
+
+Sat Dec 12 18:40:32 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (SYMBOL_VERSION): New to cope with system which needs
+ underscores.
+
+ * rndunix.c: Rewrote large parts
+
+Thu Dec 10 20:15:36 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (load_extension): increased needed verbosity level.
+
+ * random.c (fast_random_poll): Fallback to a default fast random
+ poll function.
+ (read_random_source): Always use the faked entroy gatherer if no
+ gather module is available.
+ * rndlinux.c (fast_poll): Removed.
+ * rndunix.c (fast_poll): Removed.
+
+
+Wed Nov 25 12:33:41 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-*.c: Removed.
+ * rndlinux.c : New.
+ * rndunix.c : New.
+ * random.c : Restructured the interface to the gather modules.
+ (intialize): Call constructor functions
+ (read_radnom_source): Moved to here.
+ * dynload.c (dynload_getfnc_gather_random): New.
+ (dynload_getfnc_fast_random_poll): New.
+ (register_internal_cipher_extension): New.
+ (register_cipher_extension): Support of internal modules.
+
+Sun Nov 8 17:44:36 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-unix.c (read_random_source): Removed the assert.
+
+Mon Oct 19 18:34:30 1998 me,,, (wk@tobold)
+
+ * pubkey.c: Hack to allow us to give some info about RSA keys back.
+
+Thu Oct 15 11:47:57 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dynload.c: Support for DLD
+
+Wed Oct 14 12:13:07 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-unix.c: Now uses names from configure for /dev/random.
+
+1998-10-10 SL Baur <steve@altair.xemacs.org>
+
+ * Makefile.am: fix sed -O substitutions to catch -O6, etc.
+
+Tue Oct 6 10:06:32 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-unix.c (HAVE_GETTIMEOFDAY): Fixed (was ..GETTIMEOFTIME :-)
+ * rand-dummy.c (HAVE_GETTIMEOFDAY): Ditto.
+
+Mon Sep 28 13:23:09 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_digest): New.
+ (md_reset): New.
+
+Wed Sep 23 12:27:02 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c (TIGER_CONTEXT): moved "buf", so that it is 64 bit aligned.
+
+Mon Sep 21 06:22:53 1998 Werner Koch (wk@(none))
+
+ * des.c: Some patches from Michael.
+
+Thu Sep 17 19:00:06 1998 Werner Koch (wk@(none))
+
+ * des.c : New file from Michael Roth <mroth@nessie.de>
+
+Mon Sep 14 11:10:55 1998 Werner Koch (wk@(none))
+
+ * blowfish.c (bf_setkey): Niklas Hernaeus patch to detect weak keys.
+
+Mon Sep 14 09:19:25 1998 Werner Koch (wk@(none))
+
+ * dynload.c (RTLD_NOW): Now defined to 1 if it is undefined.
+
+Mon Sep 7 17:04:33 1998 Werner Koch (wk@(none))
+
+ * Makefile.am: Fixes to allow a different build directory
+
+Thu Aug 6 17:25:38 1998 Werner Koch,mobil,,, (wk@tobold)
+
+ * random.c (get_random_byte): Removed and changed all callers
+ to use get_random_bits()
+
+Mon Jul 27 10:30:22 1998 Werner Koch (wk@(none))
+
+ * cipher.c : Support for other blocksizes
+ (cipher_get_blocksize): New.
+ * twofish.c: New.
+ * Makefile.am: Add twofish module.
+
+Mon Jul 13 21:30:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (read_pool): Simple alloc if secure_alloc is not set.
+ (get_random_bits): Ditto.
+
+Thu Jul 9 13:01:14 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dynload.c (load_extension): Function now nbails out if
+ the program is run setuid.
+
+Wed Jul 8 18:58:23 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (rmd160_hash_buffer): New.
+
+Thu Jul 2 10:50:30 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c (cipher_open): algos >=100 use standard CFB
+
+Thu Jun 25 11:18:25 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * Makefile.am: Support for extensions
+
+Thu Jun 18 12:09:38 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (mix_pool): simpler handling for level 0
+
+Mon Jun 15 14:40:48 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c: Removed from dist, will reappear as dynload module
+
+Sat Jun 13 14:16:57 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * pubkey.c: Major changes to allow extensions. Changed the inteface
+ of all public key ciphers and added the ability to load extensions
+ on demand.
+
+ * misc.c: Removed.
+
+Wed Jun 10 07:52:08 1998 Werner Koch,mobil,,, (wk@tobold)
+
+ * dynload.c: New.
+ * cipher.c: Major changes to allow extensions.
+
+Mon Jun 8 22:43:00 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c: Major internal chnages to support extensions.
+ * blowfish.c (blowfish_get_info): New and made all internal
+ functions static, changed heder.
+ * cast5.c (cast5_get_info): Likewise.
+
+Mon Jun 8 12:27:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c (transform): Fix for big endian
+
+ * cipher.c (do_cfb_decrypt): Big endian fix.
+
+Fri May 22 07:30:39 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_get_oid): Add a new one for TIGER.
+
+Thu May 21 13:24:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c: Add support for a dummy cipher
+
+Thu May 14 15:40:36 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (transform): fixed sigbus - I should better
+ add Christian von Roques's new implemenation of rmd160_write.
+
+Fri May 8 18:07:44 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-internal.h, rand-unix.c, rand-w32.c, rand_dummy.c: New
+ * random.c: Moved system specific functions to rand-****.c
+
+Fri May 8 14:01:17 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (fast_random_poll): add call to gethrtime.
+
+Tue May 5 21:28:55 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * elgamal.c (elg_generate): choosing x was not correct, could
+ yield 6 bytes which are not from the random pool, tsss, tsss..
+
+Tue May 5 14:09:06 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * primegen.c (generate_elg_prime): Add arg mode, changed all
+ callers and implemented mode 1.
+
+Mon Apr 27 14:41:58 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c (cipher_get_keylen): New.
+
+Sun Apr 26 14:44:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c, tiger.h: New.
+
+Wed Apr 8 14:57:11 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * misc.c (check_pubkey_algo2): New.
+
+Tue Apr 7 18:46:49 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c: New
+ * misc.c (check_cipher_algo): Moved to cipher.c
+ * cast5.c: Moved many functions to cipher.c
+ * blowfish.c: Likewise.
+
+Sat Apr 4 19:52:08 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cast5.c: Implemented and tested.
+
+Wed Apr 1 16:38:27 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * elgamal.c (elg_generate): Faster generation of x in some cases.
+
+Thu Mar 19 13:54:48 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * blowfish.c (blowfish_decode_cfb): changed XOR operation
+ (blowfish_encode_cfb): Ditto.
+
+Thu Mar 12 14:04:05 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * sha1.c (transform): Rewrote
+
+ * blowfish.c (encrypt): Unrolled for rounds == 16
+ (decrypt): Ditto.
+
+Tue Mar 10 16:32:08 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (transform): Unrolled the loop.
+
+Tue Mar 10 13:05:14 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (read_pool): Add pool_balance stuff.
+ (get_random_bits): New.
+
+ * elgamal.c (elg_generate): Now uses get_random_bits to generate x.
+
+
+Tue Mar 10 11:33:51 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_digest_length): New.
+
+Tue Mar 10 11:27:41 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dsa.c (dsa_verify): Works.
+
+Mon Mar 9 12:59:08 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dsa.c, dsa.h: Removed some unused code.
+
+Wed Mar 4 10:39:22 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_open): Add call to fast_random_poll.
+ blowfish.c (blowfish_setkey): Ditto.
+
+Tue Mar 3 13:32:54 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (rmd160_mixblock): New.
+ * random.c: Restructured to start with a new RNG implementation.
+ * random.h: New.
+
+Mon Mar 2 19:21:46 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * gost.c, gost.h: Removed because they did only contain trash.
+
+Sun Mar 1 16:42:29 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (fill_buffer): removed error message if n == -1.
+
+Fri Feb 27 16:39:34 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_enable): No init if called twice.
+
+Thu Feb 26 07:57:02 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * primegen.c (generate_elg_prime): Changed the progress printing.
+ (gen_prime): Ditto.
+
+Tue Feb 24 12:28:42 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md5.c, md.5 : Replaced by a modified version of md5.c from
+ GNU textutils 1.22.
+
+Wed Feb 18 14:08:30 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c, md.h : New debugging support
+
+Mon Feb 16 10:08:47 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * misc.c (cipher_algo_to_string): New
+ (pubkey_algo_to_string): New.
+ (digest_algo_to_string): New.
+
+
+ Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+ This file is free software; as a special exception the author gives
+ unlimited permission to copy and/or distribute it, with or without
+ modifications, as long as this notice is preserved.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/grub-core/lib/libgcrypt/cipher/ChangeLog-2011 b/grub-core/lib/libgcrypt/cipher/ChangeLog-2011
new file mode 100644
index 0000000..05516c9
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/ChangeLog-2011
@@ -0,0 +1,4247 @@
+2011-12-01 Werner Koch <wk@g10code.com>
+
+ NB: ChangeLog files are no longer manually maintained. Starting
+ on December 1st, 2011 we put change information only in the GIT
+ commit log, and generate a top-level ChangeLog file from logs at
+ "make dist". See doc/HACKING for details.
+
+2011-06-29 Werner Koch <wk@g10code.com>
+
+ * cipher.c (cipher_get_keylen): Return zero for an invalid algorithm.
+ (cipher_get_blocksize): Ditto.
+
+2011-06-13 Werner Koch <wk@g10code.com>
+
+ * dsa.c (selftest_sign_1024): Use the raw and not the pkcs1 flag.
+
+ * pubkey.c (gcry_pk_sign): Special case output generation for PKCS1.
+ (sexp_data_to_mpi): Parse "random-override" for pkcs1 encryption.
+ (pkcs1_encode_for_encryption): Add args RANDOM_OVERRIDE and
+ RANDOM_OVERRIDE_LEN.
+ (gcry_pk_encrypt): Special case output generation for PKCS1.
+ (sexp_data_to_mpi): Use GCRYMPI_FMT_USG for raw encoding.
+
+2011-06-10 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_sign): Use format specifier '%M' to avoid
+ leading zeroes. Special case output generation for PSS.
+ (gcry_pk_encrypt): Special case output generation for OAEP.
+ (sexp_data_to_mpi): Use GCRYMPI_FMT_USG for PSS verify.
+
+2011-06-09 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (oaep_decode): Make use of octet_string_from_mpi.
+ (sexp_to_enc): Skip "random-override".
+
+ * pubkey.c (oaep_encode, pss_encode): Add args RANDOM_OVERRIDE and
+ RANDOM_OVERRIDE_LEN.
+ (sexp_data_to_mpi): Extract new random-override parameter.
+
+ * pubkey.c (pss_encode, pss_verify): Use VALUE verbatim for MHASH.
+ (octet_string_from_mpi): Add arg SPACE.
+
+2011-06-08 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pss_encode, pss_verify): Restructure and comment code
+ to match rfc-3447. Replace secure allocs by plain allocs and
+ wipememory. Use gcry_md_hash_buffer.
+ (octet_string_from_mpi): New.
+
+2011-06-03 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (oaep_decode): Add more comments and restructure to
+ match the description in RFC-3447.
+ (oaep_encode): Check for mgf1 error. s/dlen/hlen/.
+
+2011-05-31 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (mgf1): Optimize by using gcry_md_reset. Re-implement
+ for easier readability.
+ (oaep_encode): Add more comments and restructure to match the
+ description in RFC-3447.
+
+ * pubkey.c (pkcs1_encode_for_signature, oaep_decode): Change
+ return value from one MPI to a buffer.
+ (gcry_pk_decrypt): Adjust for this change.
+
+2011-05-30 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pkcs1_decode_for_encryption): Change handling of
+ leading zero byte.
+
+2011-05-27 Daiki Ueno <ueno@unixuser.org>
+
+ * pubkey.c (gcry_pk_decrypt): Fix double-free when un-padding
+ invalid data. Thanks to Tom Ritter.
+
+2011-05-24 Daiki Ueno <ueno@unixuser.org>
+
+ * rsa.c (rsa_verify): Use CMP if given, to check the decrypted
+ sig.
+
+ * pubkey.c (sexp_to_enc, sexp_data_to_mpi): Factor out
+ CTX initialization to ...
+ (init_encoding_ctx): .. new.
+ (gcry_pk_verify): Pass verify func and the arg to pubkey_verify.
+ (pss_encode, pss_verify, pss_verify_cmp): New.
+
+2011-05-23 Daiki Ueno <ueno@unixuser.org>
+
+ * pubkey.c (pkcs1_decode_for_encryption, oaep_decode): Fix memleak
+ when gcry_mpi_print fails.
+
+2011-05-18 Daiki Ueno <ueno@unixuser.org>
+
+ * pubkey.c (sexp_data_to_mpi): Factor some code out to ...
+ (pkcs1_encode_for_encryption): .. new,
+ (pkcs1_encode_for_signature): .. new.
+ (pkcs1_decode_for_encryption): New.
+ (gcry_pk_decrypt): Do un-padding for PKCS#1 as well as OAEP.
+ (sexp_to_enc): Abolish "unpad" flag, which is not necessary since
+ we can do un-padding implicitly when "pkcs1" or "oaep" is given.
+
+2011-05-11 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_to_enc, sexp_data_to_mpi): Set LABEL to NULL
+ after free.
+ (sexp_to_enc, sexp_data_to_mpi): Do not allow multiple encoding
+ flags.
+ (oaep_encode, oaep_decode, sexp_to_key, sexp_to_sig)
+ (sexp_to_enc, sexp_data_to_mpi, gcry_pk_encrypt, gcry_pk_sign)
+ (gcry_pk_genkey, _gcry_pk_get_elements): Replace access to ERRNO
+ by gpg_err_code_from_syserror.
+
+2011-05-11 Daiki Ueno <ueno@unixuser.org>
+
+ * pubkey.c (sexp_data_to_mpi): Factor some code out to ...
+ (get_hash_algo): .. new.
+ (mgf1, oaep_encode, oaep_decode): New.
+ (sexp_to_enc): Add arg CTX. Remove arg RET_WANT_PKCS1. Support
+ OAEP.
+ (sexp_data_to_mpi): Add arg CTX. Support OAEP.
+ (gcry_pk_encrypt): Pass a CTX to sexp_data_to_mpi.
+ (gcry_pk_decrypt): Pass a CTX tp sexp_to_enc and replace
+ WANT_PKCS1. Implement unpadding for OAEP.
+ (gcry_pk_sign): Pass NULL for CTX arg of sexp_data_to_mpi.
+ (gcry_pk_verify): Ditto.
+
+2011-04-19 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Replace gpg_err_code_from_errno by
+ gpg_err_code_from_syserror.
+
+2011-04-11 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_get_keygrip): Avoid double free of L2.
+
+ * cipher.c (_gcry_cipher_setctr): Clear unused lastiv info.
+ (gcry_cipher_ctl) <GCRYCTL_SET_CTR>: Implement by calling
+ _gcry_cipher_setctr.
+ (do_ctr_encrypt): Save last counter and reuse it.
+
+ * cipher.c (do_ctr_encrypt): Allow arbitrary length inputs to
+ match the 1.4 behaviour.
+
+2011-04-04 Werner Koch <wk@g10code.com>
+
+ * ecc.c (compute_keygrip): Release L1 while parsing "curve".
+
+ * pubkey.c (gcry_pk_get_keygrip): Always release NAME and L2.
+ Reported by Ben Kibbey.
+
+2011-03-28 Werner Koch <wk@g10code.com>
+
+ * primegen.c (_gcry_generate_elg_prime): Make sure that PRIME is
+ NULL if the called func ever returns an error.
+
+ * pubkey.c (gcry_pk_decrypt): Remove unused var PUBKEY.
+
+2011-03-09 Werner Koch <wk@g10code.com>
+
+ * kdf.c: New.
+
+2011-02-22 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (aesni_cleanup_2_4): New.
+ (aesenc_xmm1_xmm0, do_aesni_ctr_4): New.
+ (_gcry_aes_ctr_enc): New.
+ * cipher.c (struct gcry_cipher_handle): Add CTR_ENC. Move field
+ CTR into an u_ctr union and adjust all users.
+ (gcry_cipher_open): Use _gcry_aes_ctr_enc.
+ (do_ctr_encrypt): Use bulk mode.
+
+2011-02-18 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (u32_a_t): New.
+ (do_encrypt_aligned, do_encrypt_aligned): Use the new type to
+ avoid problems with strict aliasing rules.
+
+2011-02-16 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (do_aesni_cfb) [USE_AESNI]: New.
+ (_gcry_aes_cfb_enc, _gcry_aes_cfb_dec) [USE_AESNI]: Use new fucntion.
+
+2011-02-15 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (do_aesni_enc_aligned, do_aesni_dec_aligned): Use
+ movdqa for the key but keep using movdqu for the data.
+ (do_aesni): Remove alignment detection. Don't burn the stack.
+ (aesni_prepare, aesni_cleanup): New macros.
+ (rijndael_encrypt, _gcry_aes_cfb_enc, _gcry_aes_cbc_enc)
+ (rijndael_decrypt, _gcry_aes_cfb_dec, _gcry_aes_cbc_dec): Use
+ these macros. Don't burn the stack in the USE_AESNI case.
+ (do_setkey): Add disabled code to use aeskeygenassist.
+
+2011-02-14 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (ATTR_ALIGNED_16): New
+ (do_aesni): Do not copy if already aligned.
+ (do_encrypt, do_decrypt): Ditto.
+ (rijndael_decrypt, rijndael_encrypt): Increase stack burning amount.
+
+ * rijndael.c (RIJNDAEL_context): Reorder fields. Change fieldname
+ ROUNDS to rounds. Move padlock_key into u1.
+ (keySched, keySched2): Rename macros to keyscherr and keyschdec
+ and change all users.
+ (padlockkey): New macro. Change all users of padlock_key.
+ * cipher.c (NEED_16BYTE_ALIGNED_CONTEXT): Always define if using gcc.
+ (struct gcry_cipher_handle): Align U_IV to at least 16 byte.
+
+2011-02-13 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (USE_AESNI): New. Define for ia32 and gcc >= 4.
+ (m128i_t) [USE_AESNI]: New.
+ (RIJNDAEL_context) [USE_AESNI]: Add field use_aesni.
+ (do_setkey): Set USE_AESNI for all key lengths.
+ (prepare_decryption) [USE_AESNI]: Use aesimc instn if requested.
+ (do_aesni_enc_aligned, do_aesni_dec_aligned)
+ (do_aesni) [USE_AESNI]: New.
+ (rijndael_encrypt, _gcry_aes_cfb_enc, _gcry_aes_cbc_enc)
+ (rijndael_decrypt, _gcry_aes_cfb_dec)
+ (_gcry_aes_cbc_dec) [USE_AESNI]: Use do_aesni.
+
+2011-02-01 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_get_curve): New.
+ (sexp_to_key): Add arg OVERRIDE_ELEMS.
+ (sexp_elements_extract_ecc): Allow for params only.
+ (gcry_pk_get_param): New.
+ * ecc.c (ecc_get_curve): New.
+ (ecc_get_param_sexp): New.
+
+2011-01-28 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Hack to insert the used curve name.
+
+2011-01-27 Werner Koch <wk@g10code.com>
+
+ * ecc.c (fill_in_curve): Remove.
+ (generate_curve): Rename to ..
+ (fill_in_curve): this. Remove setting of NAME_OID.
+ (ecc_encrypt_raw): Change name of arg DATA to K for better
+ readability. Use ECC_public_key instead of ECC_secret_key.
+ Require a caller to pass a complete pkey array.
+ (ecc_decrypt_raw): Require a caller to pass a complete skey array.
+ (elliptic_curve_t): Add field NAME.
+ (fill_in_curve): Set field.
+ (generate_key): Add arg R_USED_CURVE.
+ (ecc_generate_ext): Return used curve name.
+
+2011-01-13 Andrey Jivsov <openpgp@brainhub.org> (wk)
+
+ * ecc.c (ec2os): Do not free passed parameters X and Y. Adjust
+ callers.
+ (ecc_encrypt_raw, ecc_decrypt_raw): New.
+ (ecdh_names, _gcry_pubkey_spec_ecdh): New.
+ * pubkey.c (pubkey_table): Support ECDH.
+
+2010-08-19 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Remove double release of the module.
+ Fixes bug#1263.
+
+2010-06-10 Jeff Johnson <n3npq@mac.com> (wk)
+
+ * ecc.c (ecc_generate_ext): Parse transient-key flag.
+ (generate_key): Add arg TRANSIENT_KEY and use it to set the random
+ level.
+
+2010-04-12 Brad Hards <bradh@frogmouth.net> (wk)
+
+ Spelling fixes.
+
+2010-03-26 Werner Koch <wk@g10code.com>
+
+ * tiger.c (asn): Unfetter the old TIGER from an OID.
+ (TIGER_CONTEXT): Add field VARIANT.
+ (tiger_init): Factor code out to ...
+ (do_init): New.
+ (tiger1_init, tiger2_init): New.
+ (_gcry_digest_spec_tiger1, _gcry_digest_spec_tiger2): New.
+ * md.c (digest_table): Add TIGER1 and TIGER2 variants.
+
+2009-12-11 Werner Koch <wk@g10code.com>
+
+ * sha256.c (Cho, Maj, Sum0, Sum1): Turn macros into inline
+ functions.
+ (transform): Partly unroll to interweave the chain variables
+
+ * sha512.c (ROTR, Ch, Maj, Sum0, Sum1): Turn macros into inline
+ functions.
+ (transform): Partly unroll to interweave the chain variables.
+ Suggested by Christian Grothoff.
+
+2009-12-10 Werner Koch <wk@g10code.com>
+
+ * Makefile.am (o_flag_munging): New.
+ (tiger.o, tiger.lo): Use it.
+
+ * cipher.c (do_ctr_encrypt): Add arg OUTBUFLEN. Check for
+ suitable value. Add check for valid inputlen. Wipe temporary
+ memory.
+ (do_ctr_decrypt): Likewise.
+ (do_cbc_encrypt, do_cbc_decrypt): Add arg OUTBUFLEN. Check for
+ suitable value. Move check for valid inputlen to here; change
+ returned error from INV_ARG to INV_LENGTH.
+ (do_ecb_encrypt, do_ecb_decrypt): Ditto.
+ (do_cfb_encrypt, do_cfb_decrypt): Ditto.
+ (do_ofb_encrypt, do_ofb_decrypt): Ditto.
+ (cipher_encrypt, cipher_encrypt): Adjust for above changes.
+ (gcry_cipher_encrypt, gcry_cipher_decrypt): Simplify.
+
+2009-12-09 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Allow for GCRY_CIPHER_MODE_AESWRAP.
+ (cipher_encrypt, cipher_decrypt): Ditto.
+ (do_aeswrap_encrypt, do_aeswrap_decrypt): New.
+ (struct gcry_cipher_handle): Add field marks.
+ (cipher_setkey, cipher_setiv): Update marks flags.
+ (cipher_reset): Reset marks.
+ (cipher_encrypt, cipher_decrypt): Add new arg OUTBUFLEN.
+ (gcry_cipher_encrypt, gcry_cipher_decrypt): Pass outbuflen to
+ cipher_encrypt. Replace GPG_ERR_TOO_SHORT by
+ GPG_ERR_BUFFER_TOO_SHORT.
+
+2009-08-21 Werner Koch <wk@g10code.com>
+
+ * dsa.c (dsa_generate_ext): Release retfactors array before
+ setting it to NULL. Reported by Daiko Ueno.
+
+2009-07-02 Werner Koch <wk@g10code.com>
+
+ * md.c (md_read): Fix incomplete check for NULL.
+ Reported by Fabian Kail.
+
+2009-03-31 Werner Koch <wk@g10code.com>
+
+ * rsa.c (rsa_check_secret_key): Return GPG_ERR_BAD_SECKEY and not
+ GPG_ERR_PUBKEY_ALGO.
+
+2009-02-16 Werner Koch <wk@g10code.com>
+
+ * rsa.c (generate_x931): Do not initialize TBL with automatic
+ variables.
+ * whirlpool.c, tiger.c, sha256.c, sha1.c, rmd160.c, md5.c
+ * md4.c, crc.c: Remove memory.h. This is garbage from gnupg.
+ Reported by Dan Fandrich.
+
+2009-01-22 Werner Koch <wk@g10code.com>
+
+ * ecc.c (compute_keygrip): Remove superfluous const.
+
+2009-01-06 Werner Koch <wk@g10code.com>
+
+ * rmd160.c (oid_spec_rmd160): Add TeleTrust identifier.
+
+2008-12-10 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate): Add arg DOMAIN and use it if specified.
+ (generate_fips186): Ditto.
+ (dsa_generate_ext): Parse and check the optional "domain"
+ parameter and pass them to the generate functions.
+
+ * rijndael.c (rijndael_names): Add "AES128" and "AES-128".
+ (rijndael192_names): Add "AES-192".
+ (rijndael256_names): Add "AES-256".
+
+2008-12-05 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate): Add arg TRANSIENT_KEY and use it to detrmine
+ the RNG quality needed.
+ (dsa_generate_ext): Parse the transient-key flag und pass it to
+ generate.
+
+2008-11-28 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate_fips186): Add arg DERIVEPARMS and use the seed
+ value if available.
+
+ * primegen.c (_gcry_generate_fips186_2_prime): Fix inner p loop.
+
+2008-11-26 Werner Koch <wk@g10code.com>
+
+ * primegen.c (_gcry_generate_fips186_3_prime): New.
+ * dsa.c (generate_fips186): Add arg USE_FIPS186_2.
+ (dsa_generate_ext): Parse new flag use-fips183-2.
+
+2008-11-25 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate_fips186): New.
+ (dsa_generate_ext): Use new function if derive-parms are given or
+ if in FIPS mode.
+ * primegen.c (_gcry_generate_fips186_2_prime): New.
+
+2008-11-24 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Insert code to output extrainfo.
+ (pubkey_generate): Add arg R_EXTRAINFO and pass it to the extended
+ key generation function.
+ * rsa.c (gen_x931_parm_xp, gen_x931_parm_xi): New.
+ (generate_x931): Generate params if not given.
+ (rsa_generate_ext): Parse use-x931 flag. Return p-q-swapped
+ indicator.
+ * dsa.c (dsa_generate_ext): Put RETFACTORS into R_EXTRAINFO if
+ possible.
+
+ * pubkey.c (gcry_pk_genkey): Remove parsing of almost all
+ parameters and pass the parameter S-expression to pubkey_generate.
+ (pubkey_generate): Simplify by requitring modules to parse the
+ parameters. Remove the special cases for Elgamal and ECC.
+ (sexp_elements_extract_ecc): Add arg EXTRASPEC and use it. Fix
+ small memory leak.
+ (sexp_to_key): Pass EXTRASPEC to sexp_elements_extract_ecc.
+ (pubkey_table) [USE_ELGAMAL]: Add real extraspec.
+ * rsa.c (rsa_generate_ext): Adjust for new calling convention.
+ * dsa.c (dsa_generate_ext): Ditto.
+ * elgamal.c (_gcry_elg_generate): Ditto. Rename to elg_generate_ext.
+ (elg_generate): New.
+ (_gcry_elg_generate_using_x): Remove after merging code with
+ elg_generate_ext.
+ (_gcry_pubkey_extraspec_elg): New.
+ (_gcry_elg_check_secret_key, _gcry_elg_encrypt, _gcry_elg_sign)
+ (_gcry_elg_verify, _gcry_elg_get_nbits): Make static and remove
+ _gcry_ prefix.
+ * ecc.c (_gcry_ecc_generate): Rename to ecc_generate_ext and
+ adjust for new calling convention.
+ (_gcry_ecc_get_param): Rename to ecc_get_param and make static.
+ (_gcry_pubkey_extraspec_ecdsa): Add ecc_generate_ext and
+ ecc_get_param.
+
+2008-11-20 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pubkey_generate): Add arg DERIVEPARMS.
+ (gcry_pk_genkey): Parse derive-parms and pass it to above.
+ * rsa.c (generate_x931): New.
+ (rsa_generate_ext): Add arg DERIVEPARMS and call new function in
+ fips mode or if DERIVEPARMS is given.
+ * primegen.c (_gcry_derive_x931_prime, find_x931_prime): New.
+
+2008-11-19 Werner Koch <wk@g10code.com>
+
+ * rsa.c (rsa_decrypt): Use gcry_create_nonce for blinding.
+ (generate): Rename to generate_std.
+
+2008-11-05 Werner Koch <wk@g10code.com>
+
+ * md.c (md_open): Use a switch to set the Bsize.
+ (prepare_macpads): Fix long key case for SHA384 and SHA512.
+
+ * cipher.c (gcry_cipher_handle): Add field EXTRASPEC.
+ (gcry_cipher_open): Set it.
+ (gcry_cipher_ctl): Add private control code to disable weak key
+ detection and to return the current input block.
+ * des.c (_tripledes_ctx): Add field FLAGS.
+ (do_tripledes_set_extra_info): New.
+ (_gcry_cipher_extraspec_tripledes): Add new function.
+ (do_tripledes_setkey): Disable weak key detection.
+
+2008-10-24 Werner Koch <wk@g10code.com>
+
+ * md.c (digest_table): Allow MD5 in fips mode.
+ (md_register_default): Take special action for MD5.
+ (md_enable, gcry_md_hash_buffer): Ditto.
+
+2008-09-30 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (do_setkey): Properly align "t" and "tk".
+ (prepare_decryption): Properly align "w". Fixes bug #936.
+
+2008-09-18 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Parse domain parameter.
+ (pubkey_generate): Add new arg DOMAIN and remove special case for
+ DSA with qbits.
+ * rsa.c (rsa_generate): Add dummy args QBITS, NAME and DOMAIN and
+ rename to rsa_generate_ext. Change caller.
+ (_gcry_rsa_generate, _gcry_rsa_check_secret_key)
+ (_gcry_rsa_encrypt, _gcry_rsa_decrypt, _gcry_rsa_sign)
+ (_gcry_rsa_verify, _gcry_rsa_get_nbits): Make static and remove
+ _gcry_ prefix.
+ (_gcry_pubkey_spec_rsa, _gcry_pubkey_extraspec_rsa): Adjust names.
+ * dsa.c (dsa_generate_ext): New.
+ (_gcry_dsa_generate): Replace code by a call to dsa_generate.
+ (_gcry_dsa_check_secret_key, _gcry_dsa_sign, _gcry_dsa_verify)
+ (_gcry_dsa_get_nbits): Make static and remove _gcry prefix.
+ (_gcry_dsa_generate2): Remove.
+ (_gcry_pubkey_spec_dsa): Adjust to name changes.
+ (_gcry_pubkey_extraspec_rsa): Add dsa_generate_ext.
+
+2008-09-16 Werner Koch <wk@g10code.com>
+
+ * ecc.c (run_selftests): Add arg EXTENDED.
+
+2008-09-12 Werner Koch <wk@g10code.com>
+
+ * rsa.c (test_keys): Do a bad case signature check.
+ * dsa.c (test_keys): Do a bad case check.
+
+ * cipher.c (_gcry_cipher_selftest): Add arg EXTENDED and pass it
+ to the called tests.
+ * md.c (_gcry_md_selftest): Ditto.
+ * pubkey.c (_gcry_pk_selftest): Ditto.
+ * rijndael.c (run_selftests): Add arg EXTENDED and pass it to the
+ called tests.
+ (selftest_fips_128): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftest_fips_192): Add dummy arg EXTENDED.
+ (selftest_fips_256): Ditto.
+ * hmac-tests.c (_gcry_hmac_selftest): Ditto.
+ (run_selftests): Ditto.
+ (selftests_sha1): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftests_sha224, selftests_sha256): Ditto.
+ (selftests_sha384, selftests_sha512): Ditto.
+ * sha1.c (run_selftests): Add arg EXTENDED and pass it to the
+ called test.
+ (selftests_sha1): Add arg EXTENDED and run only one test
+ non-extended mode.
+ * sha256.c (run_selftests): Add arg EXTENDED and pass it to the
+ called tests.
+ (selftests_sha224): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftests_sha256): Ditto.
+ * sha512.c (run_selftests): Add arg EXTENDED and pass it to the
+ called tests.
+ (selftests_sha384): Add arg EXTENDED and run only one test
+ non-extended mode.
+ (selftests_sha512): Ditto.
+ * des.c (run_selftests): Add arg EXTENDED and pass it to the
+ called test.
+ (selftest_fips): Add dummy arg EXTENDED.
+ * rsa.c (run_selftests): Add dummy arg EXTENDED.
+
+ * dsa.c (run_selftests): Add dummy arg EXTENDED.
+
+ * rsa.c (extract_a_from_sexp): New.
+ (selftest_encr_1024): Check that the ciphertext does not match the
+ plaintext.
+ (test_keys): Improve tests and return an error status.
+ (generate): Return an error if test_keys fails.
+ * dsa.c (test_keys): Add comments and return an error status.
+ (generate): Return an error if test_keys failed.
+
+2008-09-11 Werner Koch <wk@g10code.com>
+
+ * rsa.c (_gcry_rsa_decrypt): Return an error instead of calling
+ BUG in case of a practically impossible condition.
+ (sample_secret_key, sample_public_key): New.
+ (selftest_sign_1024, selftest_encr_1024): New.
+ (selftests_rsa): Implement tests.
+ * dsa.c (sample_secret_key, sample_public_key): New.
+ (selftest_sign_1024): New.
+ (selftests_dsa): Implement tests.
+
+2008-09-09 Werner Koch <wk@g10code.com>
+
+ * hmac-tests.c (selftests_sha1): Add tests.
+ (selftests_sha224, selftests_sha384, selftests_sha512): Make up tests.
+
+ * hash-common.c, hash-common.h: New.
+ * sha1.c (selftests_sha1): Add 3 tests.
+ * sha256.c (selftests_sha256, selftests_sha224): Ditto.
+ * sha512.c (selftests_sha512, selftests_sha384): Ditto.
+
+2008-08-29 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_get_keygrip): Remove the special case for RSA
+ and check whether a custom computation function has been setup.
+ * rsa.c (compute_keygrip): New.
+ (_gcry_pubkey_extraspec_rsa): Setup this function.
+ * ecc.c (compute_keygrip): New.
+ (_gcry_pubkey_extraspec_ecdsa): Setup this function.
+
+2008-08-28 Werner Koch <wk@g10code.com>
+
+ * cipher.c (cipher_decrypt, cipher_encrypt): Return an error if
+ mode NONE is used.
+ (gcry_cipher_open): Allow mode NONE only with a debug flag set and
+ if not in FIPS mode.
+
+2008-08-26 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pubkey_generate): Add arg KEYGEN_FLAGS.
+ (gcry_pk_genkey): Implement new parameter "transient-key" and
+ pass it as flags to pubkey_generate.
+ (pubkey_generate): Make use of an ext_generate function.
+ * rsa.c (generate): Add new arg transient_key and pass appropriate
+ args to the prime generator.
+ (_gcry_rsa_generate): Factor all code out to ...
+ (rsa_generate): .. new func with extra arg KEYGEN_FLAGS.
+ (_gcry_pubkey_extraspec_ecdsa): Setup rsa_generate.
+ * primegen.c (_gcry_generate_secret_prime)
+ (_gcry_generate_public_prime): Add new arg RANDOM_LEVEL.
+
+2008-08-21 Werner Koch <wk@g10code.com>
+
+ * primegen.c (_gcry_generate_secret_prime)
+ (_gcry_generate_public_prime): Use a constant macro for the random
+ level.
+
+2008-08-19 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_elements_extract_ecc) [!USE_ECC]: Do not allow
+ allow "curve" parameter.
+
+2008-08-15 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (_gcry_pk_selftest): New.
+ * dsa.c (selftests_dsa, run_selftests): New.
+ * rsa.c (selftests_rsa, run_selftests): New.
+ * ecc.c (selftests_ecdsa, run_selftests): New.
+
+ * md.c (_gcry_md_selftest): New.
+ * sha1.c (run_selftests, selftests_sha1): New.
+ * sha256.c (selftests_sha224, selftests_sha256, run_selftests): New.
+ * sha512.c (selftests_sha384, selftests_sha512, run_selftests): New.
+
+ * des.c (selftest): Remove static variable form selftest.
+ (des_setkey): No on-the-fly self test in fips mode.
+ (tripledes_set3keys): Ditto.
+
+ * cipher.c (_gcry_cipher_setkey, _gcry_cipher_setiv):
+
+ * dsa.c (generate): Bail out in fips mode if NBITS is less than 1024.
+ * rsa.c (generate): Return an error code if the the requested size
+ is less than 1024 and we are in fpis mode.
+ (_gcry_rsa_generate): Take care of that error code.
+
+ * ecc.c (generate_curve): In fips mode enable only NIST curves.
+
+ * cipher.c (_gcry_cipher_selftest): New.
+
+ * sha512.c (_gcry_digest_extraspec_sha384)
+ (_gcry_digest_extraspec_sha512): New.
+ * sha256.c (_gcry_digest_extraspec_sha224)
+ (_gcry_digest_extraspec_sha256): New.
+ * sha1.c (_gcry_digest_extraspec_sha1): New.
+ * ecc.c (_gcry_pubkey_extraspec_ecdsa): New.
+ * dsa.c (_gcry_pubkey_extraspec_dsa): New.
+ * rsa.c (_gcry_pubkey_extraspec_rsa): New.
+ * rijndael.c (_gcry_cipher_extraspec_aes)
+ (_gcry_cipher_extraspec_aes192, _gcry_cipher_extraspec_aes256): New.
+ * des.c (_gcry_cipher_extraspec_tripledes): New.
+
+ * cipher.c (gcry_cipher_register): Rename to _gcry_cipher_register.
+ Add arg EXTRASPEC.
+ (dummy_extra_spec): New.
+ (cipher_table_entry): Add extraspec field.
+ * md.c (_gcry_md_register): Rename to _gcry_md_register. Add
+ arg EXTRASPEC.
+ (dummy_extra_spec): New.
+ (digest_table_entry): Add extraspec field.
+ * pubkey.c (gcry_pk_register): Rename to _gcry_pk_register. Add
+ arg EXTRASPEC.
+ (dummy_extra_spec): New.
+ (pubkey_table_entry): Add extraspec field.
+
+ * ac.c: Let most public functions return GPG_ERR_UNSUPPORTED in
+ fips mode.
+
+ * pubkey.c (pubkey_table_entry): Add field FIPS_ALLOWED and mark
+ appropriate algorithms.
+ (dummy_generate, dummy_check_secret_key, dummy_encrypt)
+ (dummy_decrypt, dummy_sign, dummy_verify, dummy_get_nbits): Signal
+ a fips error when used.
+ (gcry_pk_register): In fips mode do not allow to register new
+ algorithms.
+
+ * md.c (digest_table): Add field FIPS_ALLOWED and mark appropriate
+ algorithms.
+ (md_register_default): In fips mode register only fips algorithms.
+ (gcry_md_register): In fips mode do not allow to register new
+ algorithms.
+ (gcry_md_get): Signal a fips error if called.
+ (gcry_md_hash_buffer): Do not allow rmd160 when not in fips mode.
+ (md_start_debug): Disable in fips_mode.
+
+ * md.c (gcry_md_register_default): Rename to ..
+ (md_register_default): .. this.
+ (md_digest): Remove this commented fucntion.
+ * pubkey.c (gcry_pk_register_default): Rename to ..
+ (pk_register_default): .. this.
+
+ * cipher.c (cipher_table_entry): Add field FIPS_ALLOWED.
+ (gcry_cipher_register_default): Register only fips approved
+ algorithms.
+ (gcry_cipher_register): Do not allow to register new ciphers.
+ (cipher_setiv): Signal fips error.
+
+ * cipher (gcry_cipher_register_default): Rename to ..
+ (cipher_register_default): .. this.
+ (REGISTER_DEFAULT_CIPHERS): Adjust for that change.
+
+2008-07-05 Werner Koch <wk@g10code.com>
+
+ * random-daemon.c, random.h, rndhw.c, rndunix.c, rand-internal.h
+ * random.c, rndegd.c, rndlinux.c, rndw32.c: Move to ../cipher.
+ * Makefile.am: Remove random stuff.
+
+2008-06-24 Szakats Istvan <szaki.ms@gmail.com> (wk)
+
+ * ac.c (_gcry_ac_key_destroy, _gcry_ac_key_pair_generate): Relase
+ some more memory.
+
+2008-04-22 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (_gcry_aes_cfb_enc, _gcry_aes_cbc_enc)
+ (_gcry_aes_cfb_dec, _gcry_aes_cbc_dec): Use Padlock if possible.
+
+2008-04-18 Werner Koch <wk@g10code.com>
+
+ * sha1.c (transform_aligned): Remove. That is will obviosuly not
+ work because we need a scratch working area and our internal API
+ does not allow to modify the buffers.
+
+ * rijndael.c: Factor tables out to ..
+ * rijndael-tables.h: .. new.
+
+ * ac.c (ac_data_extract): Make static.
+
+ * camellia.h [HAVE_CONFIG_H]: Include config.h.
+
+ * rndw32.c (registry_poll): Only print the performance data
+ problem warning once. Suggested by Simon Josefsson.
+
+2008-03-19 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open) [USE_AES]: Init bulk encryption only
+ if requested. Suggested by Dirk Stoecker.
+
+2008-03-18 Werner Koch <wk@g10code.com>
+
+ * sha1.c: Include stdint.h.
+ (transform): Add arg NBLOCKS so that we can work on more than one
+ block and avoid updates of the chaining variables. Changed all
+ callers to use 1.
+ (sha1_write): Replace loop around transform.
+ (transform_aligned) [WORDS_BIGENDIAN]: New.
+ (TRANSFORM): New macro to replace all direct calls of transform.
+
+2008-03-17 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (_gcry_aes_cfb_dec): New.
+ (do_encrypt): Factor code out to ..
+ (do_encrypt_aligned): .. New.
+ (_gcry_aes_cfb_enc, _gcry_aes_cfb_dec): Use new function.
+ (do_decrypt): Factor code out to ..
+ (do_decrypt_aligned): .. new.
+ (_gcry_aes_cbc_enc, _gcry_aes_cbc_dec): New.
+ * cipher.c (struct gcry_cipher_handle): Put field IV into new
+ union U_IV to enforce proper alignment. Change all users.
+ (do_cfb_decrypt): Optimize.
+ (do_cbc_encrypt, do_cbc_decrypt): Optimize.
+
+2008-03-15 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (_gcry_aes_cfb_enc): New.
+ * cipher.c (struct gcry_cipher_handle): Add field ALGO and BULK.
+ (gcry_cipher_open): Set ALGO and BULK.
+ (do_cfb_encrypt): Optimize.
+
+2008-02-18 Werner Koch <wk@g10code.com>
+
+ * rsa.c (_gcry_rsa_verify) [IS_DEVELOPMENT_VERSION]: Print
+ intermediate results.
+
+2008-01-08 Werner Koch <wk@g10code.com>
+
+ * random.c (add_randomness): Do not just increment
+ POOL_FILLED_COUNTER but update it by the actual amount of data.
+
+2007-12-13 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_data_to_mpi): Support SHA-224.
+
+2007-12-05 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (USE_PADLOCK): Depend on ENABLE_PADLOCK_SUPPORT.
+ * rndhw.c (USE_PADLOCK): Ditto
+
+ * rsa.c (secret): Fixed condition test for using CRT. Reported by
+ Dean Scarff. Fixes bug#864.
+ (_gcry_rsa_check_secret_key): Return an erro if the optional
+ parameters are missing.
+ * pubkey.c (sexp_elements_extract): Add arg ALGO_NAME. Changed all
+ callers to pass NULL. Add hack to allow for optional RSA
+ parameters.
+ (sexp_to_key): Pass algo name to sexp_elements_extract.
+
+2007-12-03 Werner Koch <wk@g10code.com>
+
+ * random.c (gcry_random_add_bytes): Implement it.
+ * rand-internal.h (RANDOM_ORIGIN_EXTERNAL): New.
+
+2007-11-30 Werner Koch <wk@g10code.com>
+
+ * rndhw.c: New.
+ * rndlinux.c (_gcry_rndlinux_gather_random): Try to read 50%
+ directly from the hwrng.
+ * random.c (do_fast_random_poll): Also run the hw rng fast poll.
+ (_gcry_random_dump_stats): Tell whether the hw rng failed.
+
+2007-11-29 Werner Koch <wk@g10code.com>
+
+ * rijndael.c (USE_PADLOCK): Define new macro used for ia32.
+ (RIJNDAEL_context) [USE_PADLOCK]: Add fields USE_PADLOCK and
+ PADLOCK_KEY.
+ (do_setkey) [USE_PADLOCK]: Enable padlock if available for 128 bit
+ AES.
+ (do_padlock) [USE_PADLOCK]: New.
+ (rijndael_encrypt, rijndael_decrypt) [USE_PADLOCK]: Divert to
+ do_padlock.
+ * cipher.c (cipher_context_alignment_t): New. Use it in this
+ module in place of PROPERLY_ALIGNED_TYPE.
+ (NEED_16BYTE_ALIGNED_CONTEXT): Define macro for ia32.
+ (struct gcry_cipher_handle): Add field HANDLE_OFFSET.
+ (gcry_cipher_open): Take care of increased alignment requirements.
+ (gcry_cipher_close): Ditto.
+
+2007-11-28 Werner Koch <wk@g10code.com>
+
+ * sha256.c (asn224): Fixed wrong template. It happened due to a
+ bug in RFC4880. SHA-224 is not in the stable version of libgcrypt
+ so the consequences are limited to users of this devel version.
+
+2007-10-31 Werner Koch <wk@g10code.com>
+
+ * ac.c (gcry_ac_data_new): Remove due to the visibility wrapper.
+ (gcry_ac_data_destroy, gcry_ac_data_copy, gcry_ac_data_length)
+ (gcry_ac_data_set, gcry_ac_data_get_name, gcry_ac_data_get_index)
+ (gcry_ac_data_to_sexp, gcry_ac_data_from_sexp)
+ (gcry_ac_data_clear, gcry_ac_io_init, gcry_ac_open)
+ (gcry_ac_close, gcry_ac_key_init, gcry_ac_key_pair_generate)
+ (gcry_ac_key_pair_extract, gcry_ac_key_destroy)
+ (gcry_ac_key_pair_destroy, gcry_ac_key_data_get)
+ (gcry_ac_key_test, gcry_ac_key_get_nbits, gcry_ac_key_get_grip)
+ (gcry_ac_data_encrypt, gcry_ac_data_decrypt, gcry_ac_data_sign)
+ (gcry_ac_data_verify, gcry_ac_data_encode, gcry_ac_data_decode)
+ (gcry_ac_mpi_to_os, gcry_ac_mpi_to_os_alloc, gcry_ac_os_to_mpi)
+ (gcry_ac_data_encrypt_scheme, gcry_ac_data_decrypt_scheme)
+ (gcry_ac_data_sign_scheme, gcry_ac_data_verify_scheme)
+ (gcry_ac_io_init_va): Ditto.
+ (gcry_ac_id_to_name, gcry_ac_name_to_id): Remove as these
+ deprecated functions are now implemented by visibility.c.
+
+2007-10-26 Werner Koch <wk@g10code.com>
+
+ * rndw32.c: Disable debug flag.
+
+2007-10-25 Werner Koch <wk@g10code.com>
+
+ * rndw32.c: Updated from current cryptlib snapshot and modified
+ for our use. Removed support from pre NT systems.
+ (slow_gatherer_windows95): Remove.
+ (_gcry_rndw32_gather_random): Require an NT platform.
+ (init_system_rng, read_system_rng, read_mbm_data): New.
+ (slow_gatherer_windowsNT): Rename to ...
+ (slow_gatherer): .. this. Read system RNG and MBM.
+ (registry_poll): New with code factored out from slow_gatherer.
+
+2007-08-23 Werner Koch <wk@g10code.com>
+
+ * random.c (pool_filled_counter): New.
+ (add_randomness): Use it.
+
+2007-08-22 Werner Koch <wk@g10code.com>
+
+ * rndw32.c, rndunix.c: Switched to LGPL.
+
+2007-05-30 Werner Koch <wk@g10code.com>
+
+ * camellia.h, camellia.c: Replace by new LGPL version and adjusted
+ camellia.h.
+
+2007-05-09 Marcus Brinkmann <marcus@g10code.de>
+
+ * ac.c (_gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read):
+ Adjust users of gcry_ac_io_t because union is not anonymous
+ anymore.
+
+2007-05-02 Werner Koch <wk@g10code.com>
+
+ * camellia-glue.c (camellia_setkey, camellia_encrypt)
+ (camellia_decrypt): Recalculated used stack size in called
+ functions.
+ * camellia.h: Redefine external symbols.
+
+2007-05-02 David Shaw <dshaw@jabberwocky.com>
+
+ * Makefile.am, cipher.c: Add Camellia.
+
+ * camellia-glue.c: New. The necessary glue to interface libgcrypt
+ to the stock NTT Camellia distribution.
+
+ * camellia.h, camellia.c: The stock NTT Camellia distribution
+ (GPL).
+
+2007-04-30 David Shaw <dshaw@jabberwocky.com>
+
+ * cipher.c: Use #if instead of #ifdef as configure defines the
+ USE_cipher defines as 0 for disabled.
+
+2007-04-30 Werner Koch <wk@g10code.com>
+
+ * rndegd.c (_gcry_rndegd_set_socket_name): New.
+
+2007-04-30 Marcus Brinkmann <marcus@g10code.de>
+
+ * ecc.c (ec2os): Fix relocation of short numbers.
+
+ * ecc.c (generate_key): Do not allocate D, which will be allocated
+ by GEN_K. Remove G. Fix test if g_x, g_y resp. q_x, q_y are
+ requested.
+ (_gcry_ecc_generate): Release unneeded members of SK.
+ * pubkey.c (sexp_to_key): Release NAME.
+
+2007-04-28 Marcus Brinkmann <marcus@g10code.de>
+
+ * ac.c (gcry_ac_mpi): Remove member NAME_PROVIDED.
+ (ac_data_mpi_copy, _gcry_ac_data_set, _gcry_ac_data_get_name)
+ (_gcry_ac_data_get_index, ac_data_construct): Adjust handling of
+ NAME accordingly.
+
+2007-04-20 Werner Koch <wk@g10code.com>
+
+ * ecc.c (domain_parms): Add standard brainpool curves.
+
+2007-04-18 Werner Koch <wk@g10code.com>
+
+ * ecc.c (generate_curve): Implement alias mechanism.
+
+ * pubkey.c (sexp_elements_extract_ecc): New.
+ (sexp_to_key): Add special case for ecc.
+ (sexp_to_key, sexp_to_sig, sexp_to_enc, gcry_pk_genkey): Replace
+ name_terminated stuff by a call to _gcry_sexp_nth_string.
+ (gcry_pk_get_keygrip): Ditto.
+
+2007-04-16 Werner Koch <wk@g10code.com>
+
+ * ecc.c (_gcry_ecc_generate): Renamed DUMMY to CURVE and use it.
+
+2007-04-13 Marcus Brinkmann <marcus@g10code.de>
+
+ * ac.c (ac_data_construct): Cast const away to suppress compiler
+ warning.
+
+ * ecc.c (ecc_generate): Avoid compiler warning for unused argument
+ DUMMY.
+ (ecc_verify): Avoid compiler warning for unused arguments CMP and
+ OPAQUEV.
+
+2007-04-06 Werner Koch <wk@g10code.com>
+
+ * sha1.c (oid_spec_sha1): Add another oid from X9.62.
+
+2007-03-28 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Do not issue misc-key-info if it is
+ empty.
+ (gcry_pk_genkey): New parameter "curve".
+
+ * ecc.c: Entirely rewritten with only a few traces of the old
+ code left.
+ (_gcry_ecc_generate): New.
+ (generate_key) New arg NAME.
+ (generate_curve): Ditto. Return actual number of NBITS.
+
+2007-03-26 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Increase size of SKEY array and add a
+ runtime bounds check.
+
+2007-03-23 Werner Koch <wk@g10code.com>
+
+ * ecc.c (ecc_ctx_init, ecc_ctx_free, ecc_mod, ecc_mulm): New.
+ (duplicate_point, sum_points, escalar_mult): Don't use a
+ copy of base->p. Replaced all mpi_mulm by ecc_mulm so that we can
+ experiment with different algorithms.
+ (generate_key, check_secret_key, sign, verify): Initialize a
+ computation context for use by ecc_mulm.
+
+2007-03-22 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (pubkey_table): Initialize ECC.
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Add ecc.c.
+ * ecc.c: New. Heavily reformatted and changed for use in libgcrypt.
+ (point_init): New.
+ (escalar_mult): Make arg R the first arg to be similar to the mpi
+ functions.
+ (duplicate_point): Ditto
+ (sum_points): Ditto
+ (sign, verify): Remove unneeded copy operations.
+ (sum_points): Removed memory leaks and optimized some compares.
+ (verify): Simplified input check.
+
+2007-03-14 Werner Koch <wk@g10code.com>
+
+ * random.c (MASK_LEVEL): Removed macro as it was used only at one
+ place. Open coded it there.
+ (gcry_randomize, _gcry_update_random_seed_file)
+ (_gcry_fast_random_poll): Factor lock code out to ..
+ (lock_pool, unlock_pool): .. new.
+ (initialize): Look the pool while allocating.
+ (read_random_source, do_fast_random_poll): Moved intialization to ...
+ (initialize): .. here.
+ (_gcry_enable_quick_random_gen): No more need for initialization.
+ (is_initialized): Moved this global flag to ..
+ (initialize): .. here and changed all users to unconditionally call
+ initialize.
+ (add_randomness): Remove initalization here. It simply can't
+ happen.
+
+ * random.c (enum random_origins): Moved to ..
+ * rand-internal.h: .. here.
+ * rndunix.c (_gcry_rndunix_gather_random): Use enum in prototype
+ for ORIGIN and renamed REQUESTOR to ORIGIN.
+ * rndegd.c (_gcry_rndegd_gather_random): Ditto.
+ * rndlinux.c (_gcry_rndlinux_gather_random): Ditto.
+ * rndw32.c (_gcry_rndw32_gather_random): Ditto.
+ (_gcry_rndw32_gather_random_fast): Ditto.
+
+2007-03-13 Werner Koch <wk@g10code.com>
+
+ * random.c (enum random_origins): New.
+ (add_randomness): Renamed arg SOURCE to ORIGIN.
+ (read_random_source): Renamed arg REQUESTOR to ORIGIN.
+ (getfnc_gather_random): Removed static variable because this
+ function is only called one and thus we don't need this
+ optimization.
+ (_gcry_quick_random_gen): Removed and replaced by..
+ (_gcry_enable_quick_random_gen): .. this. It is onlyu used to
+ enable it and it does not make sense to disable it later. Changed
+ the only one caller too.
+ (get_random_bytes): Removed.
+ (gcry_random_bytes, gcry_random_bytes_secure): Implement in terms
+ of gcry_randomize.
+ * random-daemon.c (_gcry_daemon_get_random_bytes): Removed.
+
+2007-02-23 Werner Koch <wk@g10code.com>
+
+ * elgamal.c (generate): Removed unused variable TEMP.
+ (test_keys): New arg NODIE.
+ (generate_using_x, _gcry_elg_generate_using_x): New.
+ * pubkey.c (pubkey_generate): New arg XVALUE and direct call to
+ the new elgamal generate fucntion.
+ (gcry_pk_genkey): Parse the new "xvalue" tag.
+
+2007-02-22 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_data_to_mpi): Handle dynamically allocated
+ algorithms. Suggested by Neil Dunbar. Fixes bug#596.
+
+ * rndw32.c (_gcry_rndw32_gather_random_fast): Make it return void.
+
+ * cipher.c (gcry_cipher_algo_name): Simplified.
+
+ * random.c: Use the daemon only if compiled with USE_RANDOM_DAEMON.
+
+ * Makefile.am (libcipher_la_SOURCES): Build random-daemon support
+ only if requested.
+
+2007-02-21 Werner Koch <wk@g10code.com>
+
+ * random.c (rndpool, keypool): Make unsigned.
+ (mix_pool): Change char* variables to unsigned char*.
+ (gcry_randomize): Make arg BUFFER a void*.
+ (gcry_create_nonce): Ditto.
+
+ * rmd160.c (gcry_rmd160_mixblock): Make BUFFER a void*.
+ (_gcry_rmd160_hash_buffer): Make OUTBUF and BUFFER void*.
+ * sha1.c (_gcry_sha1_hash_buffer): Ditto.
+
+ * cipher.c (gcry_cipher_encrypt, cry_cipher_decrypt): Change
+ buffer args to void*.
+ (gcry_cipher_register): Make ALGORITHM_ID a int *.
+
+ * md.c (md_start_debug): Make SUFFIX a const char*. Use snprintf.
+ (gcry_md_debug): New.
+ (gcry_md_ctl): Changed arg BUFFER from unsigned char*.
+
+ * md.c (md_write): Make INBUF a const void*.
+ (gcry_md_write): Remove needless cast.
+ * crc.c (crc32_write): Make INBUF a const void*
+ (update_crc32, crc24rfc2440_write): Ditto.
+ * sha512.c (sha512_write, transform): Ditto.
+ * sha256.c (sha256_write, transform): Ditto.
+ * rmd160.c (rmd160_write, transform): Ditto.
+ * md5.c (md5_write, transform): Ditto.
+ * md4.c (md4_write, transform): Ditto.
+ * sha1.c (sha1_write, transform): Ditto.
+
+ * tiger.c (tiger_write, transform): Ditto.
+ * whirlpool.c (whirlpool_write, whirlpool_add, transform): Ditto.
+
+ * elgamal.c (elg_names): Change to a const*.
+ * dsa.c (dsa_names): Ditto.
+ * rsa.c (rsa_names): Ditto.
+ * pubkey.c (gcry_pk_lookup_func_name): Make ALIASES a const.
+
+2007-02-20 Werner Koch <wk@g10code.com>
+
+ * rndlinux.c (open_device): Remove unsused arg MINOR.
+
+2007-01-30 Werner Koch <wk@g10code.com>
+
+ * sha256.c (oid_spec_sha256): Add alias from pkcs#1.
+ * sha512.c (oid_spec_sha512): Ditto.
+ (oid_spec_sha384): Ditto.
+
+2006-12-18 Werner Koch <wk@g10code.com>
+
+ * rndlinux.c (set_cloexec_flag): New.
+ (open_device): Set close-on-exit flags. Suggested by Max
+ Kellermann. Fixes Debian#403613.
+
+ * Makefile.am (AM_CPPFLAGS, AM_CFLAGS): Splitted and merged
+ Moritz' changes.
+ (INCLUDES): Removed.
+
+2006-11-30 Werner Koch <wk@g10code.com>
+
+ * serpent.c (byte_swap_32): Remove trailing semicolon.
+
+2006-11-15 Werner Koch <wk@g10code.com>
+
+ * Makefile.am (INCLUDES): Include ../src/
+
+2006-11-03 Werner Koch <wk@g10code.com>
+
+ * random.c [HAVE_GETTIMEOFDAY]: Included sys/time.h and not
+ sys/times.h. Reported by Rafaël Carré.
+
+2006-11-05 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (AM_CFLAGS): Added -I$(top_builddir)/src so that the
+ new gcrypt.h is used, not the one installed in the system.
+
+2006-10-25 Werner Koch <wk@g10code.com>
+
+ * primegen.c (prime_generate_internal): Tweaked use of secure
+ memory and entropy use. Safe unused primes from the pool. Allocate
+ at least a pool of 30.
+ (save_pool_prime, get_pool_prime): New.
+
+2006-10-23 Werner Koch <wk@g10code.com>
+
+ * ac.c (_gcry_ac_data_from_sexp): Reset sexp_tmp for failsafe
+ means. Release sexp_cur if needed. Reported by Dirk Stoecker.
+
+ * pubkey.c (pubkeys_registered_lock): Intialized it. It is not
+ realy needed because this is a mere initialization to 0 anyway.
+ Noted by Victor Stinner.
+
+2006-10-17 Werner Koch <wk@g10code.com>
+
+ * dsa.c (_gcry_dsa_generate2): New.
+ (generate): New arg QBITS. Add sanity checks for reasonable qbits
+ and nbits.
+ * pubkey.c (gcry_pk_genkey): Parse an qbits element.
+ (pubkey_generate): New arg QBITS. Pass it to the DSA generation.
+
+2006-10-05 Werner Koch <wk@g10code.com>
+
+ * md.c (gcry_md_algo_info) <get_asnoid>: Check that the algo is
+ available.
+
+2006-10-04 David Shaw <dshaw@jabberwocky.com> (wk)
+
+ * tiger.c (round): Rename to tiger_round as gcc 4 has a built-in
+ round function that this conflicts with.
+
+2006-09-11 Werner Koch <wk@g10code.com>
+
+ * rndw32.c (slow_gatherer_windowsNT): While adding data use the
+ size of the diskPerformance and not its address. Has been fixed in
+ GnuPG more than a year ago. Noted by Lee Fisher.
+
+2006-08-30 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (sexp_data_to_mpi): Need to allow "ripemd160" here as
+ this is the canonical name.
+
+2006-08-29 Hye-Shik Chang <perky@FreeBSD.org> (wk)
+
+ * seed.c: New.
+
+2006-08-03 Werner Koch <wk@g10code.com>
+
+ * random-daemon.c (_gcry_daemon_initialize_basics): Don't
+ initialize the socket. Remove arg SOCKETNAME.
+ (connect_to_socket): Make sure that daemon is set to -1 on error.
+ (call_daemon): Initialize the socket on the first call.
+ (_gcry_daemon_randomize, _gcry_daemon_get_random_bytes)
+ (_gcry_daemon_create_nonce): New arg SOCKETNAME.
+ * random.c (initialize): Call new daemon initializator.
+ (get_random_bytes, gcry_randomize, gcry_create_nonce): Pass socket
+ name to daemon call and reset allow_daemon on failure.
+
+2006-07-26 Werner Koch <wk@g10code.com>
+
+ * rmd160.c (_gcry_rmd160_mixblock): Add cast to transform call.
+
+ * blowfish.c (selftest): Cast string to usnigned char*.
+
+ * primegen.c (prime_generate_internal): Cast unsigned/char*
+ mismatch in calling m_out_of_n.
+ (is_prime): Changed COUNT to unsigned int *.
+
+ * ac.c (_gcry_ac_data_copy): Initialize DATA_MPIS.
+
+ * random.c (gcry_create_nonce): Update the pid after a fork.
+ Reported by Uoti Urpala.
+
+2006-07-04 Marcus Brinkmann <marcus@g10code.de>
+
+ * sha512.c: Fix typo in copyright notice.
+
+2006-06-21 Werner Koch <wk@g10code.com>
+
+ * rsa.c (_gcry_rsa_generate): Replace xcalloc by calloc.
+ * pubkey.c (gcry_pk_encrypt, gcry_pk_sign): Ditto.
+ (sexp_to_key, sexp_to_sig, sexp_to_enc, gcry_pk_encrypt)
+ (gcry_pk_sign, gcry_pk_genkey, gcry_pk_get_keygrip): Ditto.
+ * md.c (md_copy): Ditto.
+
+2006-04-22 Moritz Schulte <moritz@g10code.com>
+
+ * random-daemon.c (_gcry_daemon_initialize_basics): New argument:
+ SOCKETNAME. Passing on to connect_to_socket() if non-NULL.
+ (connect_to_socket, writen, readn, call_daemon): New functions.
+ (_gcry_daemon_randomize, _gcry_daemon_get_random_bytes)
+ (_gcry_daemon_create_nonce): Call call_daemon().
+ (RANDOM_DAEMON_SOCKET): New symbol.
+ (daemon_socket): New static variable.
+
+ * random.h (_gcry_daemon_initialize_basics): New parameter:
+ SOCKETNAME.
+ (_gcry_set_random_daemon_socket): New declaration.
+
+ * random.c (initialize_basics): Pass DAEMON_SOCKET_NAME to
+ _gcry_daemon_initialize_basics.
+ (_gcry_set_random_daemon_socket): New function, setting
+ DAEMON_SOCKET_NAME.
+
+2006-04-01 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (eme_pkcs_v1_5_encode): Use KEY_SIZE directly, no need to
+ call gcry_ac_key_get_nbits.
+ (eme_pkcs_v1_5_decode): Likewise.
+ (ac_es_dencode_prepare_pkcs_v1_5): Fill options_em structure with
+ key_size.
+ (_gcry_ac_data_dump, gcry_ac_data_dump): New functions.
+ (_gcry_ac_data_to_sexp, _gcry_ac_data_from_sexp): More or less
+ rewritten; changed S-Expression format so that it matches the one
+ used in pubkey.c.
+
+2006-03-15 Werner Koch <wk@g10code.com>
+
+ * random-daemon.c: New.
+ * random.c (_gcry_use_random_daemon): New.
+ (get_random_bytes, gcry_randomize, gcry_create_nonce): Try
+ diverting to the daemon functions.
+
+2006-03-14 Werner Koch <wk@g10code.com>
+
+ * random.c (lock_seed_file): New.
+ (read_seed_file, _gcry_update_random_seed_file): Use it.
+
+ * random.c (gcry_create_nonce): Detect a fork and re-seed.
+ (read_pool): Fixed the fork detection; it used to work only for
+ multi-threaded processes.
+
+2006-03-12 Brad Hards <bradh@frogmouth.net> (wk)
+
+ * md.c (md_open): Use new variable macpads_Bsize instead of
+ hardwiring the block size. Changed at all places.
+
+2006-03-10 Brad Hards <bradh@frogmouth.net> (wk, patch 2005-04-22)
+
+ * md.c, sha256.c: Add support for SHA-224.
+ (sha224_init): New.
+
+2006-01-18 Brad Hards <bradh@frogmouth.net> (wk 2006-03-07)
+
+ * cipher.c (cipher_encrypt, cipher_decrypt, do_ofb_encrypt)
+ (do_ofb_decrypt, gcry_cipher_open): Implement Output Feedback Mode.
+
+2005-11-02 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_algo_name): Return "?" instead of NULL for
+ unknown algorithm IDs.
+ * cipher.c (cipher_algo_to_string): Likewise.
+
+2005-11-01 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_algo_info): Don't forget to break after switch
+ case.
+
+2005-09-19 Werner Koch <wk@g10code.com>
+
+ * dsa.c (generate): Add preliminary support for 2 and 4 keys.
+ Return an error code if the key size is not supported.
+ (_gcry_dsa_generate): Return an error.
+
+2005-08-22 Werner Koch <wk@g10code.com>
+
+ * primegen.c (check_prime): New arg RM_ROUNDS.
+ (prime_generate_internal): Call it here with 5 rounds as used
+ before.
+ (gcry_prime_check): But here with 64 rounds.
+ (is_prime): Make sure never to use less than 5 rounds.
+
+2005-04-16 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_init): New function.
+
+2005-04-12 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_io_write, _gcry_ac_io_read): Initialize err to
+ make the compiler happy.
+ Always use errno, now that gcry_malloc() is guaranteed to set
+ errno on failure.
+ (_gcry_ac_data_to_sexp): Don't forget to goto out after error in
+ loop.
+ (_gcry_ac_data_to_sexp): Remove unused variable: mpi_list;
+ (_gcry_ac_data_to_sexp): Always deallocate sexp_buffer.
+ (_gcry_ac_data_from_sexp): Don't forget to initialize data_set_new.
+ (_gcry_ac_data_from_sexp): Handle special case, which is
+ necessary, since gcry_sexp_nth() does not distinguish between
+ "element does not exist" and "element is the empty list".
+ (_gcry_ac_io_init_va): Use assert to make sure that mode and type
+ are correct.
+ Use gcry_error_t types where gcry_err_code_t types have been used
+ before.
+
+2005-04-11 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_data_sign_scheme): Don't forget to initialize
+ buffer.
+
+ * whirlpool.c: New file.
+ * md.c (digest_table): Add whirlpool.
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Added: whirlpool.c.
+
+2005-03-30 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (_gcry_ac_data_from_sexp): Use length of SEXP_CUR, not
+ length of SEXP; do not forget to set SEXP_TMP to NULL after it has
+ been released.
+
+ (struct gcry_ac_mpi): New member: name_provided.
+ (_gcry_ac_data_set): Rename variable `name_final' to `name_cp';
+ remove const qualifier; change code to not cast away const
+ qualifiers; use name_provided member as well.
+ (_gcry_ac_data_set, _gcry_ac_data_get_name): Use name_provided
+ member of named mpi structure.
+
+ (gcry_ac_name_to_id): Do not forget to initialize err.
+ (_gcry_ac_data_get_index): Do not forget to initialize mpi_return;
+ use gcry_free() instead of free(); remove unnecessary cast; rename
+ mpi_return and name_return to mpi_cp and name_cp; adjust code.
+ (ac_data_mpi_copy): Do not cast away const qualifier.
+ (ac_data_values_destroy): Likewise.
+ (ac_data_construct): Likewise.
+
+ (ac_data_mpi_copy): Initialize flags to GCRY_AC_FLAG_DEALLOC.
+ (ac_data_extract): Use GCRY_AC_FLAG_DEALLOC instead of
+ GCRY_AC_FLAG_COPY.
+
+ (_gcry_ac_io_init_va, _gcry_ac_io_init, gcry_ac_io_init)
+ (gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read)
+ (_gcry_ac_io_read_all, _gcry_ac_io_process): New functions.
+ (gry_ac_em_dencode_t): Use gcry_ac_io_t in prototype instead of
+ memroy strings directly; adjust encode/decode functions to use io
+ objects.
+ (emsa_pkcs_v1_5_encode_data_cb): New function ...
+ (emsa_pkcs_v1_5_encode): ... use it here.
+ (ac_data_dencode): Use io objects.
+ (_gcry_ac_data_encode, _gcry_ac_data_decode, gcry_ac_data_encode)
+ (gcry_ac_data_decode): Likewise.
+ (_gcry_ac_data_encrypt_scheme, gcry_ac_data_encrypt_scheme)
+ (_gcry_ac_data_decrypt_scheme, gcry_ac_data_decrypt_scheme)
+ (_gcry_ac_data_sign_scheme, gcry_ac_data_sign_scheme)
+ (_gcry_ac_data_verify_scheme, gcry_ac_data_verify_scheme):
+ Likewise.
+
+2005-03-23 Werner Koch <wk@g10code.com>
+
+ * rndw32.c (_gcry_rndw32_gather_random_fast): While adding data
+ use the size of the object and not the one of its address. Bug
+ reported by Sascha Kiefer.
+
+2005-03-19 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (do_cbc_encrypt): Be careful to not overwrite data,
+ which is to be used later on. This happend, in case CTS is
+ enabled and OUTBUF is equal to INBUF.
+
+2005-02-25 Werner Koch <wk@g10code.com>
+
+ * pubkey.c (gcry_pk_get_keygrip): Allow for shadowed-private-key.
+
+2005-02-13 Moritz Schulte <moritz@g10code.com>
+
+ * serpent.c: Updated from 1.2 branch:
+
+ s/u32_t/u32/ and s/byte_t/byte/. Too match what we have always
+ used and are using in all other files too
+ (serpent_test): Moved prototype out of a fucntion.
+
+2005-02-07 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: Major parts rewritten.
+ * pubkey.c (_gcry_pk_get_elements): New function.
+
+2004-12-09 Werner Koch <wk@g10code.com>
+
+ * serpent.c (serpent_setkey): Moved prototype of serpent_test to
+ outer scope.
+
+2004-09-11 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (pubkey_table): Added an alias entry for GCRY_PK_ELG_E.
+
+2004-08-23 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: Do not include <assert.h>.
+ * rndegd.c: Likewise.
+ * sha1.c: Likewise.
+ * rndunix.c: Likewise.
+ * rndlinux.c: Likewise.
+ * rmd160.c: Likewise.
+ * md5.c: Likewise.
+ * md4.c: Likewise.
+ * cipher.c: Likewise.
+ * crc.c: Likewise.
+ * blowfish.c: Likewise.
+
+ * pubkey.c (dummy_generate, dummy_check_secret_key)
+ (dummy_encrypt, dummy_decrypt, dummy_sign, dummy_verify): Return
+ err code GPG_ERR_NOT_IMPLEMENTED instead of aborting through
+ log_bug().
+ (dummy_get_nbits): Return 0 instead of aborting though log_bug().
+
+2004-08-19 Werner Koch <wk@g10code.de>
+
+ * pubkey.c (sexp_data_to_mpi): Changed the zero random byte
+ substituting code to actually do clever things. Thanks to
+ Matthias Urlichs for noting the implementation problem.
+
+2004-08-09 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_sign): Fixed memory leak; fix provided by
+ Modestas Vainius.
+
+2004-07-16 Werner Koch <wk@gnupg.org>
+
+ * rijndael.c (do_encrypt): Fix alignment problem. Bugs found by
+ Matthias Urlichs.
+ (do_decrypt): Ditto.
+ (keySched, keySched2): Use 2 macros along with unions in the key
+ schedule context.
+
+2004-07-14 Moritz Schulte <moritz@g10code.com>
+
+ * rsa.c (_gcry_rsa_decrypt): Don't forget to free "a". Thanks to
+ Nikos Mavroyanopoulos.
+
+2004-05-09 Werner Koch <wk@gnupg.org>
+
+ * random.c (read_pool): Mix the PID in to better protect after a
+ fork.
+
+2004-07-04 Moritz Schulte <moritz@g10code.com>
+
+ * serpent.c: Use "u32_t" instead of "unsigned long", do not
+ declare S-Box variables as "register". Fixes failure on
+ OpenBSD/sparc64, reported by Nikolay Sturm.
+
+2004-05-07 Werner Koch <wk@gnupg.org>
+
+ * random.c (initialize): Factored out some code to ..
+ (initialize_basics): .. new function.
+ (_gcry_random_initialize): Just call initialize_basics unless the
+ new arg FULL is set to TRUE.
+ (_gcry_fast_random_poll): Don't do anything unless the random
+ system has been really initialized.
+
+2004-05-07 Moritz Schulte <moritz@g10code.de>
+
+ * ac.c (gcry_ac_open): Do not dereference NULL pointer. Reported
+ by Umberto Salsi.
+
+2004-02-20 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (check_prime): New args CB_FUNC and CB_ARG; call them
+ at different stages. Pass these arguments through all callers.
+
+2004-02-06 Werner Koch <wk@gnupg.org>
+
+ * des.c: Add a new OID as used by pkcs#12.
+
+ * rfc2268.c: New. Taken from libgcrypt.
+ * cipher.c: Setup the rfc2268 algorithm.
+
+2004-01-25 Moritz Schulte <mo@g10code.com>
+
+ * primegen.c (prime_generate_internal): Do not forget to free
+ `q_factor'; fixed by Brieuc Jeunhomme.
+ (prime_generate_internal): Do not forget to free `prime'.
+
+2004-01-14 Moritz Schulte <mo@g10code.com>
+
+ * ac.c (gcry_ac_data_set): New argument: flags; slightly
+ rewritten.
+ (gcry_ac_data_get_name, gcry_ac_data_get_index): Likewise.
+ (gcry_ac_key_pair_generate): New argument: misc_data; modified
+ order of arguments.
+ (gcry_ac_key_test): New argument: handle.
+ (gcry_ac_key_get_nbits, gcry_ac_key_get_grip): Likewise.
+ Use GCRY_AC_FLAG_NO_BLINDING instead of
+ GCRY_AC_DATA_FLAG_NO_BLINDING.
+ (gcry_ac_mpi): New member: flags.
+ (gcry_ac_data_search, gcry_ac_data_add): Removed functions.
+
+2003-12-22 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (is_prime): Release A2.
+
+2003-12-19 Werner Koch <wk@gnupg.org>
+
+ * md.c: Moved a couple of functions down below the data structure
+ definitions.
+ (struct gcry_md_context): New field ACTUAL_HANDLE_SIZE.
+ (md_open): Set it here.
+ (strcut gcry_md_list): New field ACTUAL_STRUCT_SIZE.
+ (md_enable): Set it here.
+ (md_close): Wipe the context memory.
+ secure memory.
+ * cipher.c (struct gcry_cipher_handle): New field ACTUAL_HANDLE_SIZE.
+ (gcry_cipher_open): Set it here.
+ (gcry_cipher_close): Use it to always wipe out the handle data.
+
+ * ac.c (gcry_ac_open): Make sure HANDLE gets initialized even when
+ the function is not successful.
+ (gcry_ac_close): Allow a NULL handle.
+ (gcry_ac_key_destroy, gcry_ac_key_pair_destroy): Ditto.
+ (gcry_ac_key_get_grip): Return INV_OBJ on error.
+
+ * primegen.c (prime_generate_internal): Fixed error code for
+ failed malloc. Replaced the !err if chain by gotos.
+ (gcry_prime_group_generator): Remove the extra sanity check.
+
+ * md.c: Minor code and comment cleanups.
+
+2003-12-16 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): Doc fix. Thanks to Newton Hammet.
+
+2003-12-11 Werner Koch <wk@gnupg.org>
+
+ * rndunix.c (slow_poll): Don't use #warning but #error.
+
+ * rndegd.c: Changed indentation.
+ (my_make_filename): Removd the var_arg cruft becuase we
+ don't need it here. Changed caller.
+
+ * rndlinux.c: Changed indentation.
+ (open_device): Remove the superfluous stat call and clarify
+ comment.
+
+ * rsa.c: Changed indentation.
+ (secret): Use the standard algorithm if p, q and u are not
+ available.
+ (rsa_blind, rsa_unblind): Renamed from _gcry_rsa_blind,
+ _gcry_rsa_unblind and moved more to the top.
+
+ * md4.c: Changed indentation. Removed unnecessary casts.
+ * md5.c, rmd160.c, sha1.c, tiger.c: Ditto.
+ * rijndael.c, twofish.c: Ditto.
+ * serpent.c: Removed unnecessary casts.
+ * sha256.c, sha512.c: Ditto.
+
+2003-12-09 Werner Koch <wk@gnupg.org>
+
+ * dsa.c: Unified indentation style.
+ * elgamal.c: Ditto.
+ * des.c (des_key_schedule): Code beautifications.
+ * blowfish.c: Changed indentation style.
+ * cast5.c (do_cast_setkey): Ditto.
+
+ * pubkey.c (gcry_pk_encrypt): Replaced the chain of if(!err) tests
+ by straightforward gotos. Other cleanups.
+ (gcry_pk_decrypt): Ditto.
+ (gcry_pk_sign): Ditto.
+ (gcry_pk_verify): Ditto.
+ (gcry_pk_genkey): Ditto. Use strtoul instead of strtol.
+ (gcry_pk_ctl): Use GPG_ERR_INV_ARG to indicate bad arguments.
+
+2003-12-07 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_register_default): Undef the helper macro.
+ (gcry_pk_map_name): Allow NULL for string.
+ (sexp_to_key): Use memcpy and not strncpy. Use gcry_free and not
+ free.
+ (sexp_to_sig): Ditto.
+ (sexp_to_enc): Ditto. Replaced the chain of if(!err) tests by
+ straightforward gotos.
+
+2003-12-05 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Documentation cleanups.
+ (gcry_cipher_mode_from_oid): Allow NULL for STRING.
+
+2003-12-03 Werner Koch <wk@gnupg.org>
+
+ * elgamal.c (sign, do_encrypt, gen_k): Make sure that a small K is
+ only used for encryption.
+
+2003-11-18 Werner Koch <wk@gnupg.org>
+
+ * random.h (rndw32_set_dll_name): Removed unused prototype.
+
+ * Makefile.am (EXTRA_DIST): Added Manifest.
+
+2003-11-11 Werner Koch <wk@gnupg.org>
+
+ * Manifest: New.
+
+2003-11-04 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Use shortcut for SHA1
+ * sha1.c (_gcry_sha1_hash_buffer): New.
+
+ * random.c: Reformatted most functions.
+ (mix_pool): Moved the failsafe_digest from global
+ scope to here.
+ (do_fast_random_poll): Use the generic fucntions even if a fast
+ gathering function has been used.
+ (read_pool): Detect a fork and retry.
+ (gcry_randomize, get_random_bytes): Don't distinguish anymore
+ between weak and strong random.
+ (gcry_create_nonce): New.
+
+2003-10-31 Werner Koch <wk@gnupg.org>
+
+ * rndw32.c (slow_gatherer_windowsNT): Use a plain buffer for the
+ disk performance values and not the W32 API structure.
+
+ * dsa.c (verify): s/exp/ex/ due to shadowing of a builtin.
+ * elgamal.c (verify): Ditto.
+
+ * ac.c (gcry_ac_data_get_index): s/index/idx/
+ (gcry_ac_data_copy_internal): Remove the cast in _gcry_malloc.
+ (gcry_ac_data_add): Must use gcry_realloc instead of realloc.
+ * pubkey.c (sexp_elements_extract): s/index/idx/ as tribute to the
+ forehackers.
+ (gcry_pk_encrypt): Removed shadowed definition of I. Reordered
+ arguments to malloc for clarity.
+ (gcry_pk_sign, gcry_pk_genkey): Ditto.
+ * primegen.c (prime_generate_internal): s/random/randomlevel/.
+
+2003-10-27 Moritz Schulte <mo@g10code.com>
+
+ * pubkey.c (gcry_pk_encrypt): Don't forget to deallocate pkey.
+
+2003-10-27 Werner Koch <wk@gnupg.org>
+
+ * random.c (gcry_random_add_bytes): Return if buflen is zero to
+ avoid gcc warning about unsed parameter.
+ (MASK_LEVEL): Simplified; does now work for signed and unsigned
+ w/o warnings.
+
+ * md.c (md_start_debug): Removed the const from SUFFIX, because
+ this function is called from the control fucntion which does not
+ require const.
+
+ Prefixed all (pubkey,digest,cipher}_spec_* globale variables with
+ _gcry_.
+
+ * ac.c (ac_key_identifiers): Made static.
+
+ * random.c (getfnc_gather_random,getfnc_fast_random_poll): Move
+ prototypes to ..
+ * rand-internal.h: .. here
+ * random.c (getfnc_gather_random): Include rndw32 gatherer.
+ * rndunix.c, rndw32.c, rndegd.c: Include them here.
+ * rndlinux.c (_gcry_rndlinux_gather_random): Prepend the _gcry_
+ prefix. Changed all callers.
+ * rndegd.c (_gcry_rndegd_gather_random): Likewise.
+ (_gcry_rndegd_connect_socket): Likewise.
+ * rndunix.c (_gcry_rndunix_gather_random): Likewise.
+ (waitpid): Made static.
+ * rndw32.c: Removed the old and unused winseed.dll cruft.
+ (_gcry_rndw32_gather_random_fast): Renamed from
+ gather_random_fast.
+ (_gcry_rndw32_gather_random): Renamed from gather_random. Note,
+ that the changes 2003-04-08 somehow got lost.
+
+ * sha512.c (sha512_init, sha384_init): Made static.
+
+ * cipher.c (do_ctr_decrypt): Removed "return" from this void
+ function.
+
+2003-10-24 Moritz Schulte <mo@g10code.com>
+
+ * serpent.c: Fix an issue on big-endian systems.
+
+ * rndw32.c: Removed IS_MODULE -cruft.
+ * rndlinux.c (rndlinux_gather_random): Likewise.
+
+2003-10-10 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): Bail out if NBITS is less than 16.
+ (prime_generate_internal): Initialize prime variable to suppress
+ compiler warning. Check pbits, initialize qbits when passed as
+ zero.
+
+ * primegen.c (prime_generate_internal): New arg
+ ALL_FACTORS. Changed all callers.
+ (gcry_prime_generate): Make the factors arg optional. Request
+ all_factors. Make sure PRIME is set to NULL even on error.
+ (gcry_prime_group_generator): New.
+ (gcry_prime_release_factors): New.
+
+2003-10-06 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): Assert that NBITS is never zero, it
+ would cause a segv.
+
+2003-09-28 Moritz Schulte <mo@g10code.com>
+
+ * ac.c: Include "cipher.h".
+
+2003-09-27 Moritz Schulte <mo@g10code.com>
+
+ * rndegd.c (do_read): Return nread instead of nbytes; thanks to
+ Michael Caerwyn.
+
+2003-09-04 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (_gcry_pk_aliased_algo_name): New.
+ * ac.c (gcry_ac_open): Use it here.
+
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Add serpent.c
+
+2003-09-02 Moritz Schulte <mo@g10code.com>
+
+ * primegen.c (gcry_prime_check, gcry_prime_generate): New
+ functions.
+ (prime_generate_internal): New function, based on
+ _gcry_generate_elg_prime.
+ (_gcry_generate_elg_prime): Rewritten as a wrapper for
+ prime_generate_internal.
+
+2003-08-28 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_encrypt): Don't include the flags list in the
+ return value. This does not make sense and breaks any programs
+ parsing the output strictly (e.g. current gpgsm).
+ (gcry_pk_encrypt): If aliases for the algorithm name exists, take
+ the first one instead of the regular name to adhere to SPKI
+ conventions.
+ (gcry_pk_genkey): Ditto.
+ (gcry_pk_sign): Ditto. Removed unused KEY_ALGO_NAME.
+
+2003-08-19 Moritz Schulte <mo@g10code.com>
+
+ * cipher.c: Add support for Serpent
+ * serpent.c: New file.
+
+2003-08-10 Moritz Schulte <moritz@g10code.com>
+
+ * rsa.c (_gcry_rsa_blind, _gcry_rsa_unblind): Declare static.
+
+2003-08-09 Timo Schulz <twoaday@freakmail.de>
+
+ * random.c (getfnc_gather_random): Don't check NAME_OF_DEV_RANDOM
+ two times, but also the NAME_OF_DEV_URANDOM device.
+
+2003-08-08 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_to_enc): Fixed extraction of S-Expression: do not
+ fail if no `flags' sub S-Expression is found.
+
+2003-07-27 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_lookup_func_oid): Allow for empty OID lists.
+
+2003-07-23 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (gcry_ac_data_construct): New argument: include_flags, only
+ include `flags' S-expression, if include_flags is true. Adjust
+ callers. Thanks for triggering a bug caused by `flags'
+ sub-S-expression where they are not expected to Ralf Schneider.
+
+2003-07-21 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_lookup_func_name): Use new member name
+ `aliases' instead of `sexp_names'.
+
+ * ac.c (gcry_ac_key_data_get): New function.
+
+ * cipher.c (gcry_cipher_lookup_func_name): Fix return value.
+
+2003-07-20 Moritz Schulte <moritz@g10code.com>
+
+ * blowfish.c: Adjusted for new gcry_cipher_spec_t structure.
+ * cast5.c: Likewise.
+ * twofish.c: Likewise.
+ * arcfour.c: Likewise.
+ * rijndael.c (rijndael_oids, rijndael192_oids, rijndael256_oids):
+ New variables, adjust for new gcry_cipher_spec_t structure.
+ * des.c (oids_tripledes): New variable, adjust for new
+ gcry_cipher_spec_t structure.
+
+ * md.c (oid_table): Removed.
+
+ * tiger.c (oid_spec_tiger): New variable.
+ (digest_spec_tiger): Adjusted for new gry_md_spec_t structure.
+
+ * sha512.c (oid_spec_sha512): New variable.
+ (digest_spec_sha512): Adjusted for new gry_md_spec_t structure.
+
+ * sha512.c (oid_spec_sha384): New variable.
+ (digest_spec_sha384): Adjusted for new gry_md_spec_t structure.
+
+ * sha256.c (oid_spec_sha256): New variable.
+ (digest_spec_sha256): Adjusted for new gry_md_spec_t structure.
+
+ * sha1.c (oid_spec_sha1): New variable.
+ (digest_spec_sha1): Adjusted for new gry_md_spec_t structure.
+
+ * rmd160.c (oid_spec_rmd160): New variable.
+ (digest_spec_rnd160): Adjusted for new gry_md_spec_t structure.
+
+ * md5.c (oid_spec_md5): New variable.
+ (digest_spec_md5): Adjusted for new gry_md_spec_t structure.
+
+ * md4.c (oid_spec_md4): New variable.
+ (digest_spec_md4): Adjusted for new gry_md_spec_t structure.
+
+ * crc.c (digest_spec_crc32, digest_spec_crc32_rfc1510,
+ digest_spec_crc32_rfc2440): Adjusted for new gry_md_spec_t
+ structure.
+
+2003-07-19 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (gcry_md_lookup_func_oid): New function.
+ (search_oid): New function, copied from cipher.c.
+ (gcry_md_map_name): Adjust for new search_oid_interface.
+
+ * cipher.c (oid_table): Removed table.
+ (gcry_cipher_lookup_func_oid): New function.
+ (search_oid): Rewritten to use the module functions.
+ (gcry_cipher_map_name): Adjust for new search_oid interface.
+ (gcry_cipher_mode_from_oid): Likewise.
+
+2003-07-18 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Convert ERR to gpg_error_t in
+ gpg_strerror.
+
+2003-07-14 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (gcry_cipher_lookup_func_name): Also check the cipher
+ name aliases, not just the primary name.
+ (gcry_cipher_map_name): Remove kludge for aliasing Rijndael to
+ AES.
+
+ * arcfour.c, blowfish.c, cast5.c, des.c, twofish.c: Adjust cipher
+ specification structures.
+
+ * rijndael.c (rijndael_names, rijndael192_names,
+ rijndael256_names): New variables, use them in the cipher
+ specifications.
+
+ * rmd160test.c: Removed file.
+
+ * ac.c, arcfour.c, blowfish.c, cast5.c, cipher.c, des.c, dsa.c,
+ elgamal.c, md.c, pubkey.c, random.c, rijndael.c, rsa.c, twofish.c:
+ Used gcry_err* wrappers for libgpg symbols.
+
+ * primegen.c (gen_prime): Correct the order arguments to
+ extra_check.
+
+2003-07-12 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: Replaced all public occurences of gpg_error_t with
+ gcry_error_t.
+ * cipher.c: Likewise.
+ * md.c: Likewise.
+ * pubkey.c: Likewise.
+ * random.c: Likewise.
+
+ * cipher.c: Added support for TWOFISH128.
+
+2003-07-08 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (gcry_ac_data_copy_internal): New function, based on
+ gcry_ac_data_copy.
+ (gcry_ac_data_copy): Made public, use gcry_ac_data_copy_internal.
+ (gcry_ac_key_init): Use gcry_ac_data_copy_internal.
+
+2003-07-07 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c (gcry_ac_data_set): Only release old MPI value if it is
+ different from the new value. Bug reported by Simon Josefsson
+ <jas@extundo.com>.
+
+ * pubkey.c (gcry_pk_list): New function.
+ * md.c (gcry_md_list): New function.
+
+ * ac.c (gcry_ac_key_pair_generate): Fix calculation of format
+ string size.
+
+2003-07-05 Moritz Schulte <moritz@g10code.com>
+
+ * md.c: Named struct of digest_table `digest_table_entry'.
+ (digest_table_entry): New member: algorithm; filled in.
+ (digest_table_entry): Removed unused member: flags.
+ (gcry_md_register): New argument: algorithm_id, filled in.
+ (gcry_md_register_default): Used algorithm ID from module
+ structure.
+ (gcry_md_map_name): Likewise.
+ (md_enable): Likewise.
+ (md_read): Likewise.
+ (gcry_md_info): Likewise.
+
+ * pubkey.c: Named truct for pubkey_table `pubkey_table_entry'.
+ (pubkey_table_entry): New member: algorithm; filled in.
+ (gcry_pk_register_default): Used algorithm ID from pubkey_table.
+ (gcry_pk_register): New argument: algorithm_id, filled in.
+ (gcry_pk_map_name): Used algorithm ID from module structure.
+ (gcry_pk_decrypt): Likewise.
+ (gcry_pk_encrypt): Likewise.
+ (gcry_pk_verify): Likewise.
+ (gcry_pk_sign): Likewise.
+ (gcry_pk_testkey): Likewise.
+ (gcry_pk_genkey): Likewise.
+ (gcry_pk_get_nbits): Likewise.
+ (sexp_to_key): Removed unused variable: algo.
+ (sexp_to_sig): Likewise.
+
+ * cipher.c: Named struct for cipher_table `cipher_table_entry'.
+ (cipher_table_entry): New member: algorithm; filled in.
+ (gcry_cipher_register_default): Used algorithm ID from
+ cipher_table.
+ (gcry_cipher_register): New argument: algorithm_id, filled in.
+ (gcry_cipher_map_name): Used algorithm ID from module structure.
+
+ * arcfour.c (cipher_spec_arcfour): Removed algorithm ID.
+ * blowfish.c (cipher_spec_blowfish): Likewise.
+ * cast5.c (cipher_spec_cast5): Likewise.
+ * crc.c (digest_spec_crc32): Likewise.
+ * crc.c (digest_spec_crc32_rfc1510): Likewise.
+ * crc.c (digest_spec_crc32_rfc2440): Likewise.
+ * des.c (cipher_spec_des): Likewise.
+ * des.c (cipher_spec_tripledes): Likewise.
+ * dsa.c (pubkey_spec_dsa): Likewise.
+ * elgamal.c (pubkey_spec_elg): Likewise.
+ * md4.c (digest_spec_md4): Likewise.
+ * md5.c (digest_spec_md5): Likewise.
+ * aes.c (cipher_spec_aes): Likewise.
+ * aes.c (cipher_spec_aes192): Likewise.
+ * aes.c (cipher_spec_aes256): Likewise.
+ * rsa.c (pubkey_spec_rsa): Likewise.
+ * sha1.c (digest_spec_sha1): Likewise.
+ * sha256.c (digest_spec_sha256): Likewise.
+ * sha512.c (digest_spec_sha512): Likewise.
+ * tiger.c (digest_spec_tiger): Likewise.
+ * twofish.c (cipher_spec_twofish): Likewise.
+ * twofish.c (cipher_spec_twofish128): Likewise.
+
+ * Makefile.am (EXTRA_libcipher_la_SOURCES): Fix list of source
+ files; reported by Simon Josefsson <jas@extundo.com>.
+
+ * pubkey.c: Replaced all occurences of `id' with `algorithm',
+ since `id' is a keyword in obj-c.
+ * md.c: Likewise.
+ * cipher.c: Likewise.
+
+ * crc.c, md4.c, md5.c, rmd160.c, sha1.c, sha256.c, tiger.c:
+ Replaced all occurences of gcry_digest_spec_t with gcry_md_spec_t.
+
+ * dsa.c, rsa.c, elgamal.c: Replaced all occurencens of
+ gcry_pubkey_spec_t with gcry_pk_spec_t.
+
+ * md.c: Replaced all occurences of gcry_digest_spec_t with
+ gcry_md_spec_t.
+ (gcry_digest_register_default): Renamed to ...
+ (gcry_md_register_default): ... this; adjusted callers.
+ (gcry_digest_lookup_func_name): Renamed to ...
+ (gcry_md_lookup_func_name): ... this; adjusted callers.
+ (gcry_digest_lookup_name): Renamed to ...
+ (gcry_md_lookup_name): ... this; adjusted callers.
+ (gcry_digest_register): Renamed to ...
+ (gcry_md_register): ... this.
+ (gcry_digest_unregister): Renamed to ...
+ (gcry_md_unregister): ... this.
+
+ * pubkey.c (gcry_pubkey_register): Renamed to ...
+ (gcry_pk_register): ... this.
+ (gcry_pubkey_unregister): Renamed to ...
+ (gcry_pk_unregister): ... this.
+ Replaced all occurences of gcry_pubkey_spec_t with gcry_pk_spec_t.
+ (gcry_pubkey_register_default): Renamed to ...
+ (gcry_pk_register_default): ... this; adjusted callers.
+ (gcry_pubkey_lookup_func_name): Renamed to ...
+ (gcry_pk_lookup_func_name): ... this; adjusted callers.
+ (gcry_pubkey_lookup_name): Renamed to ...
+ (gcry_pk_lookup_name): ... this; adjusted callers.
+
+ * md.c (gcry_md_hash_buffer): Fix error checking. Thanks to Simon
+ Josefsson <jas@extunde.com>.
+
+2003-07-04 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (gcry_cipher_list): New function.
+
+2003-07-01 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_to_sig): Accept a `flags' S-expression to be more
+ consistent with sexp_to_enc.
+
+2003-06-30 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (libcipher_la_SOURCES): Added: ac.c.
+
+ * pubkey.c (_gcry_pk_module_lookup): New function.
+ (_gcry_pk_module_release): New function.
+
+2003-06-29 Moritz Schulte <moritz@g10code.com>
+
+ * ac.c: New file.
+
+2003-06-26 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Trigger BUG correcly with new API.
+
+2003-06-19 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_is_enabled): Fixed.
+
+2003-06-18 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_get_algo_keylen): New.
+ (gcry_cipher_get_algo_blklen): New.
+
+2003-06-18 Moritz Schulte <moritz@g10code.com>
+
+ * arcfour.c, cipher.c, blowfish.c, md.c, cast5.c, pubkey.c, crc.c,
+ des.c, dsa.c, elgamal.c, md4.c, md5.c, random.c, rijndael.c,
+ rmd160.c, rsa.c, sha1.c, sha256.c, sha512.c, tiger.c, twofish.c:
+ Replaced older types GcryDigestSpec, GcryCipherSpec and
+ GcryPubkeySpec with newer types: gcry_digest_spec_t,
+ gcry_cipher_spec_t and gcry_pubkey_spec_t.
+
+ * md.c (gcry_digest_id_new): Removed function.
+ (gcry_digest_register): Removed code for generating a new module
+ ID.
+
+ * pubkey.c (gcry_pubkey_id_new): Removed function.
+ (gcry_pubkey_register): Removed code for generating a new module
+ ID.
+
+ * cipher.c, md.c, pubkey.c: Replace old type GcryModule with newer
+ one: gcry_module_t.
+ (gcry_cipher_id_new): Removed function.
+ (gcry_cipher_register): Removed code for generating a new module
+ ID.
+
+ * cipher.c (gcry_cipher_register): Adjust call to
+ _gcry_module_add.
+ (gcry_cipher_register_default): Likewise.
+ * pubkey.c (gcry_pubkey_register_default): Likewise.
+ (gcry_pubkey_register): Likewise.
+ * md.c (gcry_digest_register_default): Likewise.
+ (gcry_digest_register): Likewise.
+
+ * md.c (gcry_digest_lookup_func_id): Removed function.
+ (gcry_digest_lookup_id): Likewise.
+ (gcry_digest_id_new): Use _gcry_module_lookup_id instead of
+ gcry_digest_lookup_id.
+ (digest_algo_to_string): Likewise.
+ (check_digest_algo): Likewise.
+ (md_enable): Likewise.
+ (md_digest_length): Likewise.
+ (md_asn_oid): Likewise.
+
+ * pubkey.c (gcry_pubkey_lookup_id): Removed function.
+ (gcry_pubkey_lookup_func_id): Likewise.
+ (gcry_pubkey_id_new): Use _gcry_module_lookup_id instead of
+ gcry_pubkey_id_new.
+ (gcry_pk_algo_name): Likewise.
+ (disable_pubkey_algo): Likewise.
+ (check_pubkey_algo): Likewise.
+ (pubkey_get_npkey): Likewise.
+ (pubkey_get_nskey): Likewise.
+ (pubkey_get_nsig): Likewise.
+ (pubkey_get_nenc): Likewise.
+ (pubkey_generate): Likewise.
+ (pubkey_check_secret_key): Likewise.
+ (pubkey_encrypt): Likewise.
+ (pubkey_decrypt): Likewise.
+ (pubkey_sign): Likewise.
+ (pubkey_verify): Likewise.
+ (gcry_pk_algo_info): Likewise.
+
+ * cipher.c (gcry_cipher_lookup_func_id): Removed function.
+ (gcry_cipher_lookup_id): Likewise.
+ (cipher_algo_to_string): use _gcry_module_lookup_id instead of
+ gcry_cipher_lookup_id.
+ (disable_cipher_algo): Likewise.
+ (check_cipher_algo): Likewise.
+ (cipher_get_blocksize): Likewise.
+ (gcry_cipher_open): Likewise.
+ (gcry_cipher_id_new): Likewise.
+
+2003-06-17 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (GCRYPT_MODULES): Set to @GCRYPT_CIPHERS@,
+ @GCRYPT_PUBKEY_CIPHERS@, @GCRYPT_DIGESTS@ and @GCRYPT_RANDOM@.
+ (libcipher_la_DEPENDENCIES): Set to $(GCRYPT_MODULES).
+ (libcipher_la_LIBADD): Likewise.
+ (AM_CFLAGS): Added: @GPG_ERROR_CFLAGS@.
+ (EXTRA_libcipher_la_SOURCES): Added all conditional sources.
+
+ * md.c (md_open): Use _gcry_fast_random_poll instead of
+ fast_random_poll.
+ * cipher.c (gcry_cipher_open): Likewise.
+
+ * random.h (fast_random_poll): Removed macro.
+
+ * blowfish.c, md4.c, md5.c, rmd160.c, sha1.c, sha256.c, sha512.c,
+ tiger.c: Use Autoconf's WORDS_BIGENDIAN instead of our own
+ BIG_ENDIAN_HOST.
+
+2003-06-16 Moritz Schulte <moritz@g10code.com>
+
+ * random.c (getfnc_gather_random): Do not special-case
+ USE_ALL_RANDOM_MODULES, make it the default.
+
+ * dsa.c: Replace last occurences of old type names with newer
+ names (i.e. replace MPI with gcry_mpi_t).
+ * elgamal.c: Likewise.
+ * primegen.c: Likewise.
+ * pubkey.c: Likewise.
+ * rsa.c: Likewise.
+
+2003-06-14 Moritz Schulte <moritz@g10code.com>
+
+ * des.c (des_setkey): Add selftest check.
+ (tripledes_set3keys): Likewise.
+ (do_tripledes_setkey): Remove selftest check.
+ (do_des_setkey): Likewise.
+
+2003-06-11 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (_gcry_md_init): New function.
+ * cipher.c (_gcry_cipher_init): New function.
+ * pubkey.c (_gcry_pk_init): New function.
+
+2003-06-13 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_get_algo): Reverted to old API. This is a
+ convenience function anyway and error checking is not approriate.
+ (gcry_md_is_secure): New.
+ (gcry_md_is_enabled): New.
+
+2003-06-12 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_open): Make sure HANDLE is set to NULL on
+ error.
+
+2003-06-11 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_open): Make sure H receives either NULL or an
+ valid handle.
+ (gcry_md_copy): Swapped arguments so that it is more in lione with
+ md_open and most other API fucntions like memcpy (destination
+ comes first). Make sure HANDLE is set to NULL on error.
+
+ * rijndael.c (do_encrypt): Hack to force correct alignment. It
+ seems not to be not sufficient, though. We should rework this
+ fucntions and remove all these ugly casts. Let the compiler
+ optimize or have an assembler implementation.
+
+2003-06-09 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am: Removed rules serpent, since that is not commited
+ yet.
+
+2003-06-08 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_encrypt): Improve calculation for size of the
+ format string.
+
+2003-06-07 Moritz Schulte <moritz@g10code.com>
+
+ * arcfour.c, bithelp.h, blowfish.c, cast5.c, cipher.c, crc.c,
+ des.c, dsa.c, elgamal.c, md4.c, md5.c, md.c, primegen.c, pubkey.c,
+ rand-internal.h, random.c, random.h, rijndael.c, rmd160.c,
+ rmd160test.c, rmd.h, rndeged.c, rndlinux.c, rndunix.c, rndw32.c,
+ rsa.c, sha1.c, sha256.c, sha512.c, tiger.c, twofish.c: Edited all
+ preprocessor instructions to remove whitespace before the '#'.
+ This is not required by C89, but there are some compilers out
+ there that don't like it. Replaced any occurence of the now
+ deprecated type names with the new ones.
+
+2003-06-04 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_encrypt): Construct an arg_list and use
+ gcry_sexp_build_array instead of gcry_sexp_build.
+ (gcry_pk_sign): Likewise.
+ (gcry_pk_genkey): Likewise.
+
+2003-06-01 Moritz Schulte <moritz@g10code.com>
+
+ * dsa.c (_gcry_dsa_generate): Do not check wether the algorithm ID
+ does indeed belong to DSA.
+ (_gcry_dsa_sign): Likewise.
+ (_gcry_dsa_verify): Likewise.
+ (_gcry_dsa_get_nbits): Likewise.
+
+ * elgamal.c (_gcry_elg_check_secret_key): Do not check wether the
+ algorithm ID does indeed belong to ElGamal.
+ (_gcry_elg_encrypt): Likewise.
+ (_gcry_elg_decrypt): Likewise.
+ (_gcry_elg_sign): Likewise.
+ (_gcry_elg_verify): Likewise.
+ (_gcry_elg_get_nbits): Likewise.
+ (_gcry_elg_generate): Likewise.
+
+ * rsa.c (_gcry_rsa_generate): Do not check wether the algorithm ID
+ does indeed belong to RSA.
+ (_gcry_rsa_encrypt): Likewise.
+ (_gcry_rsa_decrypt): Likewise.
+ (_gcry_rsa_sign): Likewise.
+ (_gcry_rsa_verify): Likewise.
+ (_gcry_rsa_get_nbits): Likewise.
+
+2003-05-30 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (md_get_algo): Return zero in case to algorithm is enabled.
+
+ * md.c (gcry_md_info): Adjusted for new no-errno-API.
+ (md_final): Likewise.
+ (gcry_md_get_algo): Likewise.
+ * pubkey.c (gcry_pk_get_keygrip): Likewise.
+ (gcry_pk_ctl): Likewise.
+ (gcry_pk_algo_info): Likewise.
+ * des.c (selftest): Likewise.
+
+2003-05-29 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (md_enable): Do not forget to release module on error.
+ (gcry_md_open): Adjusted for new no-errno-API.
+ (md_open): Likewise.
+ (md_copy): Likewise.
+ (gcry_md_copy): Likewise.
+ (gcry_md_setkey): Likewise.
+ (gcry_md_algo_info): Likewise.
+
+ * cipher.c (gcry_cipher_open): Adjusted for new no-errno-API and
+ also fixed a locking bug.
+ (gcry_cipher_encrypt): Adjusted for new no-errno-API.
+ (gcry_cipher_decrypt): Likewise.
+ (gcry_cipher_ctl): Likewise.
+ (gcry_cipher_info): Likewise.
+ (gcry_cipher_algo_info): Likewise.
+
+2003-05-28 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (md_enable): Adjusted for libgpg-error.
+ (gcry_md_enable): Likewise.
+ (gcry_digest_register_default): Likewise.
+ (gcry_digest_register): Likewise.
+ (check_digest_algo): Likewise.
+ (prepare_macpads): Likewise.
+ (gcry_md_setkey): Likewise.
+ (gcry_md_ctl): Likewise.
+ (gcry_md_get): Likewise.
+ (gcry_md_algo_info): Likewise.
+ (gcry_md_info): Likewise.
+ * dsa.c (_gcry_dsa_generate): Likewise.
+ (_gcry_dsa_check_secret_key): Likewise.
+ (_gcry_dsa_sign): Likewie.
+ (_gcry_dsa_verify): Likewise.
+ * twofish.c (do_twofish_setkey): Likewise.
+ (twofish_setkey): Likewise.
+ * cipher.c (gcry_cipher_register): Likewise.
+
+2003-05-25 Moritz Schulte <moritz@g10code.com>
+
+ * rijndael.c (do_setkey): Adjusted for libgpg-error.
+ (rijndael_setkey): Likewise.
+ * random.c (gcry_random_add_bytes): Likewise.
+ * elgamal.c (_gcry_elg_generate): Likewise.
+ (_gcry_elg_check_secret_key): Likewise.
+ (_gcry_elg_encrypt): Likewise.
+ (_gcry_elg_decrypt): Likewise.
+ (_gcry_elg_sign): Likewise.
+ (_gcry_elg_verify): Likewise.
+ * rsa.c (_gcry_rsa_generate): Likewise.
+ (_gcry_rsa_check_secret_key): Likewise.
+ (_gcry_rsa_encrypt): Likewise.
+ (_gcry_rsa_decrypt): Likewise.
+ (_gcry_rsa_sign): Likewise.
+ (_gcry_rsa_verify): Likewise.
+ * pubkey.c (dummy_generate, dummy_check_secret_key, dummy_encrypt,
+ dummy_decrypt, dummy_sign, dummy_verify): Likewise.
+ (gcry_pubkey_register): Likewise.
+ (check_pubkey_algo): Likewise.
+ (pubkey_generate): Likewise.
+ (pubkey_check_secret_key): Likewise.
+ (pubkey_encrypt): Likewise.
+ (pubkey_decrypt): Likewise.
+ (pubkey_sign): Likewise.
+ (pubkey_verify): Likewise.
+ (sexp_elements_extract): Likewise.
+ (sexp_to_key): Likewise.
+ (sexp_to_sig): Likewise.
+ (sexp_to_enc): Likewise.
+ (sexp_data_to_mpi): Likewise.
+ (gcry_pk_encrypt): Likewise.
+ (gcry_pk_decrypt): Likewise.
+ (gcry_pk_sign): Likewise.
+ (gcry_pk_verify): Likewise.
+ (gcry_pk_testkey): Likewise.
+ (gcry_pk_genkey): Likewise.
+ (gcry_pk_ctl): Likewise.
+ * cipher.c (dummy_setkey): Likewise.
+ (check_cipher_algo): Likewise.
+ (gcry_cipher_open): Likewise.
+ (cipher_setkey): Likewise.
+ (gcry_cipher_ctl): Likewise.
+ (cipher_encrypt): Likewise.
+ (gcry_cipher_encrypt): Likewise.
+ (cipher_decrypt): Likewise.
+ (gcry_cipher_decrypt): Likewise.
+ (gcry_cipher_info): Likewise.
+ (gcry_cipher_algo_info): Likewise.
+ * cast5.c (cast_setkey): Likewise.
+ (do_cast_setkey): Likewise.
+ * arcfour.c (arcfour_setkey): Likewise.
+ (do_arcfour_setkey): Likewise.
+ * blowfish.c (do_bf_setkey): Likewise.
+ (bf_setkey): Likewise.
+ * des.c (do_des_setkey): Likewise.
+ (do_tripledes_setkey): Likewise.
+
+2003-05-22 Moritz Schulte <moritz@g10code.com>
+
+ * tiger.c: Merged code ussing the U64_C macro from GnuPG.
+
+ * sha512.c: Likewise.
+
+2003-05-17 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Fix type: acquire a lock, instead of
+ releasing it.
+
+2003-05-11 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_testkey): Call REGISTER_DEFAULT_CIPHERS.
+ (gcry_pk_ctl): Likewise.
+
+2003-04-27 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (gcry_pk_genkey): Release sexp after extracted data has
+ been used.
+
+ * md.c (gcry_md_get_algo_dlen): Simplified, simply call
+ md_digest_length to do the job.
+
+ * des.c (do_des_setkey): Check for selftest failure not only
+ during initialization.
+ (do_tripledes_setkey): Include check for selftest failure.
+
+ * pubkey.c (gcry_pubkey_register_default): New macro
+ `pubkey_use_dummy', use it.
+
+ * elgamal.c (elg_names): New variable.
+ (pubkey_spec_elg): Include elg_names.
+
+ * dsa.c (dsa_names): New variable.
+ (pubkey_spec_dsa): Include dsa_names.
+
+ * rsa.c (rsa_names): New variable.
+ (pubkey_spec_rsa): Include rsa_names.
+
+ * pubkey.c (gcry_pubkey_lookup_func_name): Compare name also with
+ the names listed in `sexp_names'.
+
+2003-04-24 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_to_key): New variables: module, pubkey. Adjusted
+ to new module interface.
+ (sexp_to_key): Changend type of argument `retalgo' from `int *' to
+ `GcryModule **'. Adjusted all callers. Removed argument:
+ r_algotblidx.
+ (sexp_to_sig): Changend type of argument `retalgo' from `int *' to
+ `GcryModule **'. Adjusted all callers.
+ (sexp_to_enc): Likewise.
+
+ (pubkey_get_npkey, pubkey_get_nskey, pubkey_get_nsig,
+ pubkey_get_nenc): Use strlen to find out the number.
+
+ * rsa.c: Adjust pubkey_spec_rsa to new internal interface.
+ * dsa.c: Likewise.
+ * elgamal.c: Likewise.
+
+2003-04-17 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c (sexp_elements_extract): New function.
+ * pubkey.c (sexp_to_key): Removed variable `idx', added `err', use
+ sexp_elements_extract.
+ (sexp_to_sig): Likewise.
+ (sexp_to_enc): Likewise.
+
+ * pubkey.c: Terminate list correctly.
+ * md.c: Include sha512/sha384 in digest_table.
+
+2003-04-16 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am: Include support for sha512.c.
+
+ * sha512.c: New file, merged from GnuPG, with few modifications
+ for libgcrypt.
+
+ * rand-internal.h: Removed declarations for constructor functions.
+
+ * md.c (md_copy): Call _gcry_module_use for incrementing the usage
+ counter of the digest modules.
+
+ * rsa.c: Do not include "rsa.h".
+ * dsa.c: Do not include "dsa.h".
+ * elgamal.c: Do not include "elgamal.h".
+ * des.c: Do not include "des.h".
+ * cast5.c: Do not include "cast5.h".
+ * blowfish.c: Do not include "blowfish.h".
+ * arcfour.c: Do not include "arcfour.h".
+
+ * Makefile.am (libcipher_la_DEPENDENCIES): Removed.
+ (libcipher_la_LIBADD): Removed.
+ Use Automake conditionals for conditional compilation.
+
+2003-04-13 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Call REGISTER_DEFAULT_CIPHERS.
+
+ * md.c (gcry_md_list): New member: module.
+ (md_enable): New variable: module, changed use of module and
+ digest.
+ (md_enable): Initialize member: module.
+ (md_close): Call _gcry_module_release.
+
+ * cipher.c (gcry_cipher_open): New variable: module, changed use of
+ module and cipher.
+ (struct gcry_cipher_handle): New member: module.
+ (gcry_cipher_open): Initialize member: module.
+ (gcry_cipher_close): Call _gcry_module_release.
+
+2003-04-09 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c: Include "ath.h".
+ * md.c: Likewise.
+ * pubkey.c: Likewise.
+
+ * cipher.c (ciphers_registered_lock): New variable.
+ * md.c (digests_registered_lock): New variable.
+ * pubkey.c (pubkeys_registered_lock): New variable.
+
+ * rndlinux.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndlinux_constructor): Removed function.
+
+ * rndegd.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndegd_constructor): Removed function.
+
+ * rndunix.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndunix_constructor): Removed function.
+
+ * rndw32.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rndw32_constructor): Removed function.
+
+ * rndegd.c (rndegd_connect_socket): Simplify code for creating the
+ egd socket address.
+ (rndegd_connect_socket): Call log_fatal use instead of
+ g10_log_fatal.
+ (egd_gather_random): Renamed to ...
+ (rndegd_gather_random): ... here.
+
+2003-04-08 Moritz Schulte <moritz@g10code.com>
+
+ * rndlinux.c: Do not include "dynload.h".
+ * rndunix.c: Likewise.
+ * rndw32.c: Likewise.
+
+ * rndegd.c (rndegd_connect_socket): Factored out from ...
+ (egd_gather_random): here; call it.
+ (egd_socket): New variable.
+ (egd_gather_random): Initialize fd with egd_socket, do not declare
+ fd static.
+ (do_read): Merged few changes from GnuPG. FIXME - not finished?
+ Do not include "dynload.h".
+
+ * rndw32.c (gather_random): Renamed to rndw32_gather_random, do
+ not declare static.
+ (gather_random_fast): Renamed to rndw32_gather_random_fast, do not
+ declare static.
+
+ * rndunix.c (gather_random): Renamed to rndunix_gather_random, do
+ not declare static.
+ * rndegd.c (gather_random): Renamed to rndegd_gather_random, do
+ not declare static.
+ * rndlinux.c (gather_random): Renamed to rndlinux_gather_random,
+ do not declare static.
+
+2003-04-07 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (libcipher_la_SOURCES): Removed construct.c.
+ (libcipher_la_SOURCES): Added sha1.c, sha256.c, rmd160.c, md4.c,
+ md5.c, tiger.c and crc.c
+ (EXTRA_PROGRAMS): Removed sha1, sha256, rmd160, md4, md5, tiger
+ and crc. Removed definitions: EXTRA_md4_SOURCES,
+ EXTRA_md5_SOURCES, EXTRA_rmd160_SOURCES, EXTRA_sha1_SOURCES,
+ EXTRA_sha256_SOURCES, EXTRA_tiger_SOURCES and EXTRA_crc_SOURCES,
+ BUILT_SOURCES, DISTCLEANFILES.
+
+ * pubkey.c: Do not include "elgamal.h", "dsa.h" and "rsa.h".
+
+ * Makefile.am (libcipher_la_SOURCES): Removed rsa.h, elgamal.h,
+ dsa.h, des.h, cast5.h, arcfour.h and blowfish.h.
+
+ * rsa.h: Removed file.
+ * elgamal.h: Removed file.
+ * dsa.h: Removed file.
+ * des.h: Removed file.
+ * cast5.h: Removed file.
+ * arcfour.h: Removed file.
+ * blowfish.h: Removed file.
+
+ * Makefile.am (libcipher_la_SOURCES): Removed dynload.c and
+ dynload.h.
+
+ * rsa.c (pubkey_spec_rsa): New variable.
+ * dsa.c (pubkey_spec_rsa): New variable.
+ * elgamal.c (pubkey_spec_elg): New variable.
+
+ * rsa.c (_gcry_rsa_get_info): Removed function.
+ * elgamal.c (_gcry_elg_get_info): Removed function.
+ * dsa.c (_gcry_dsa_get_info): Removed function.
+
+ * tiger.c (tiger_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_tiger_constructor): Removed function.
+
+ * sha1.c (sha1_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_sha1_constructor): Removed function.
+
+ * sha256.c (sha256_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_sha256_constructor): Removed function.
+
+ * rmd160.c (rmd160_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_rmd160_constructor): Removed function.
+
+ * md5.c (md5_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_md5_constructor): Removed function.
+
+ * md4.c (md4_get_info): Removed function.
+ (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func): Removed function.
+ (_gcry_md4_constructor): Removed function.
+
+ * crc.c (crc_get_info): Removed function.
+
+ * arcfour.c (do_arcfour_setkey): Changed type of context argument
+ to `void *', added local variable for cast, adjusted callers.
+ (arcfour_setkey): Likewise.
+ (encrypt_stream): Likewise.
+ * cast5.c (cast_setkey): Likewise.
+ (encrypt_block): Likewise.
+ * rijndael.c (rijndael_setkey): Likewise.
+ (rijndael_encrypt): Likewise.
+ (rijndael_decrypt): Likewise.
+ * twofish.c (twofish_setkey): Likewise.
+ (twofish_encrypt): Likewise.
+ (twofish_decrypt): Likewise.
+ * des.c (do_des_setkey): Likewise.
+ (do_des_encrypt): Likewise.
+ (do_des_encrypt): Likewise.
+ (do_tripledes_encrypt): Likewise.
+ (do_tripledes_encrypt): Likewise.
+ * blowfish.c (bf_setkey: Likewise.
+ (encrypt_block): Likewise.
+ (decrypt_block): Likewise.
+
+ * arcfour.c (encrypt_stream): Likewise.
+
+ * rijndael.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func) Removed function.
+
+ * twofish.c (gnupgext_version, func_table): Removed definitions.
+ (gnupgext_enum_func) Removed function.
+
+ * cast5.c (CIPHER_ALGO_CAST5): Removed.
+
+ * blowfish.c (FNCCAST_SETKEY, FNCCAST_CRYPT): Removed macros.
+ (CIPHER_ALGO_BLOWFISH): Removed symbol.
+ * cast5.c (FNCCAST_SETKEY, FNCCAST_CRYPT): Likewise.
+ * des.c (selftest_failed): Removed.
+ (initialized): New variable.
+ (do_des_setkey): Run selftest, if not yet done.
+ (FNCCAST_SETKEY, FNCCAST_CRYPT): Removed macros.
+
+ * arcfour.c (_gcry_arcfour_get_info): Removed function.
+ * blowfish.c (_gcry_blowfish_get_info): Removed function.
+ * cast5.c (_gcry_cast5_get_info): Removed function.
+ * des.c (_gcry_des_get_info): Removed function.
+ * rijndael.c (_gcry_rijndael_get_info): Removed function.
+ * twofish.c (_gcry_twofish_get_info): Removed function.
+
+ * arcfour.c (cipher_spec_arcfour): New variable.
+ * twofish.c (cipher_spec_twofish, cipher_spec_twofish128): New
+ variables.
+ * rijndael.c (cipher_spec_aes, cipher_spec_aes192,
+ cipher_spec256): New variables.
+ * des.c (cipher_spec_des, cipher_spec_tripledes): New variables.
+ * cast5.c (cipher_spec_cast5): New variable.
+ * blowfish.c (cipher_spec_blowfish): Likewise.
+
+ * twofish.c: Do not include "dynload.h".
+ * rijndael.c: Likewise.
+ * des.c: Likewise.
+ * cast5.c: Likewise.
+ * blowfish.c: Likewise.
+ * cipher.c: Likewise.
+ * crc.c: Likewise.
+ * md4.c: Likewise.
+ * md5.c: Likewise.
+ * md.c: Likewise.
+ * pubkey.c: Likewise.
+ * rijndael.c: Likewise.
+ * sha1.c: Likewise.
+ * sha256.c: Likewise.
+
+ * arcfour.c: Include "cipher.h".
+ * twofish.c: Likewise.
+ * rijndael.c: Likewise.
+ * des.c: Likewise.
+ * cast5.c: Likewise.
+ * blowfish.c: Likewise.
+
+ * twofish.c (twofish_setkey): Declared argument `key' const.
+ (twofish_encrypt): Declared argument `inbuf' const.
+ (twofish_decrypt): Likewise.
+
+ * rijndael.c (rijndael_setkey): Declared argument `key' const.
+ (rijndael_encrypt): Declared argument `inbuf' const.
+ (rijndael_decrypt): Likewise.
+
+ * des.c (do_des_setkey): Declared argument `key' const.
+ (do_tripledes_setkey): Likewise.
+ (do_des_encrypt): Declared argument `inbuf' const.
+ (do_des_decrypt): Likewise.
+ (do_tripledes_encrypt): Likewise.
+ (do_tripledes_decrypt): Likewise.
+
+ * cast5.c (encrypt_block): Declared argument `inbuf' const.
+ (decrypt_block): Likewise.
+ (cast_setkey): Declared argument `key' const.
+
+ * blowfish.c (do_bf_setkey): Declared argument `key' const.
+ (encrypt_block): Declared argument `inbuf' const.
+ (encrypt_block): Likewise.
+
+
+
+ * cipher.c: Remove CIPHER_ALGO_DUMMY related code.
+ Removed struct cipher_table_s.
+ Changed definition of cipher_table.
+ Removed definition of disabled_algos.
+ (ciphers_registered, default_ciphers_registered): New variables.
+ (REGISTER_DEFAULT_CIPHERS): New macro.
+ (dummy_setkey): Declared argument `key' const.
+ (dummy_encrypt_block): Declared argument `inbuf' const.
+ (dummy_encrypt_block): Likewise.
+ (dummy_encrypt_stream): Likewise.
+ (dummy_encrypt_stream): Likewise.
+ (dummy_setkey): Use `unsigned char' instead of `byte'.
+ (dummy_encrypt_block): Likewise.
+ (dummy_decrypt_block): Likewise.
+ (dummy_encrypt_stream): Likewise.
+ (dummy_decrypt_stream): Likewise.
+ (gcry_cipher_register_default): New function.
+ (gcry_cipher_lookup_func_id): New function.
+ (gcry_cipher_lookup_func_name): New function.
+ (gcry_cipher_lookup_id): New function.
+ (gcry_cipher_lookup_name): New function.
+ (gcry_cipher_id_new): New function.
+ (gcry_cipher_register): New function.
+ (gcry_cipher_unregister): New function.
+ (setup_cipher_table): Removed function.
+ (load_cipher_modules): Removed function.
+ (gcry_cipher_map_name): Adjusted to use new module management.
+ (cipher_algo_to_string): Likewise.
+ (disable_cipher_algo): Likewise.
+ (check_cipher_algo): Likewise.
+ (cipher_get_keylen): Likewise.
+ (cipher_get_blocksize): Likewise.
+ (gcry_cipher_open): Likewise.
+ (struct gcry_cipher_handle): Replaced members algo, algo_index,
+ blocksize, setkey, encrypt, decrypt, stencrypt, stdecrypt with one
+ member: cipher.
+ (gcry_cipher_open): Adjusted code for new handle structure.
+ (cipher_setkey): Likewise.
+ (cipher_setiv): Likewise.
+ (cipher_reset): Likewise.
+ (do_ecb_encrypt): Likewise.
+ (do_ecb_decrypt): Likewise.
+ (do_cbc_encrypt): Likewise.
+ (do_cbc_decrypt): Likewise.
+ (do_cfb_encrypt): Likewise.
+ (do_cfb_decrypt): Likewise.
+ (do_ctr_encrypt): Likewise.
+ (cipher_encrypt): Likewise.
+ (gcry_cipher_encrypt): Likewise.
+ (cipher_decrypt): Likewise.
+ (gcry_cipher_decrypt): Likewise.
+ (cipher_sync): Likewise.
+ (gcry_cipher_ctl): Likewise.
+
+ * pubkey.c: Removed struct pubkey_table_s.
+ Changed definition of pubkey_table.
+ Removed definition of disabled_algos.
+ (pubkeys_registered, default_pubkeys_registered): New variables.
+ (REGISTER_DEFAULT_PUBKEYS): New macro.
+ (setup_pubkey_table): Removed function.
+ (load_pubkey_modules): Removed function.
+ (gcry_pubkey_register_default): New function.
+ (gcry_pubkey_lookup_func_id): New function.
+ (gcry_pubkey_lookup_func_name): New function.
+ (gcry_pubkey_lookup_id): New function.
+ (gcry_pubkey_lookup_name): New function.
+ (gcry_pubkey_id_new): New function.
+ (gcry_pubkey_register): New function.
+ (gcry_pubkey_unregister): New function.
+ (gcry_pk_map_name): Adjusted to use new module management.
+ (gcry_pk_algo_name): Likewise.
+ (disable_pubkey_algo): Likewise.
+ (check_pubkey_algo): Likewise.
+ (pubkey_get_npkey): Likewise.
+ (pubkey_get_nskey): Likewise.
+ (pubkey_get_nsig): Likewise.
+ (pubkey_get_nenc): Likewise.
+ (pubkey_generate): Likewise.
+ (pubkey_check_secret_key): Likewise.
+ (pubkey_encrypt): Likewise.
+ (pubkey_decrypt): Likewise.
+ (pubkey_sign): Likewise.
+ (pubkey_verify): Likewise.
+ (gcry_pk_get_nbits): Likewise.
+ (gcry_pk_algo_info): Likewise.
+
+ * md.c: Removed struct md_digest_list_s.
+ (digest_list): Changed definition.
+ (digests_registered, default_digests_registered): New variables.
+ (REGISTER_DEFAULT_DIGESTS): New macro.
+ (new_list_item): Removed function.
+ (setup_md_table): Removed function.
+ (load_digest_module): Removed function.
+ (gcry_digest_register_default): New function.
+ (gcry_digest_lookup_func_id): New function.
+ (gcry_digest_lookup_func_name): New function.
+ (gcry_digest_lookup_id): New function.
+ (gcry_digest_lookup_name): New function.
+ (gcry_digest_id_new): New function.
+ (gcry_digest_register): New function.
+ (gcry_digest_unregister): New function.
+ (GcryDigestEntry): New type.
+ (struct gcry_md_context): Adjusted type of `list'.
+ (gcry_md_map_name): Adjusted to use new module management.
+ (digest_algo_to_string): Likewise.
+ (check_digest_algo): Likewise.
+ (md_enable): Likewise.
+ (md_digest_length): Likewise.
+ (md_asn_oid): Likewise.
+
+2003-04-07 Moritz Schulte <moritz@g10code.com>
+
+ * pubkey.c: Replaced PUBKEY_ALGO_DSA with GCRY_PK_DSA,
+ PUBKEY_ALGO_RSA with GCRY_PK_RSA and PUBKEY_ALGO_ELGAMAL with
+ GCRY_PK_ELG.
+
+ * dsa.c: Replaced PUBKEY_ALGO_DSA with GCRY_PK_DSA.
+
+2003-04-01 Moritz Schulte <moritz@g10code.com>
+
+ * des.c: Removed checks for GCRY_CIPHER_3DES and GCRY_CIPHER_DES.
+
+2003-03-31 Moritz Schulte <moritz@g10code.com>
+
+ * tiger.c (tiger_get_info): Do not declare static.
+ * sha256.c (sha256_get_info): Likewise.
+ * sha1.c (sha1_get_info): Likewise.
+ * rmd160.c (rmd160_get_info): Likewise.
+ * md5.c (md5_get_info): Likewise.
+ * md4.c (md4_get_info): Likewise.
+ * crc.c (crc_get_info): Likewise.
+
+ * md.c (load_digest_module): Call setup_md_table during
+ initialization.
+ (new_list_item): Link new element into digest_list.
+
+ * cipher.c (do_ctr_decrypt): Made do_ctr_encrypt act as a wrapper
+ for do_ctr_encrypt, since these functions are identical.
+
+2003-03-30 Simon Josefsson <jas@extundo.com>
+
+ * cipher.c (struct gcry_cipher_handle): Add counter field.
+ (gcry_cipher_open): Add CTR.
+ (cipher_reset): Clear counter field.
+ (do_ctr_encrypt, do_ctr_decrypt): New functions.
+ (cipher_encrypt, cipher_decrypt): Call CTR functions.
+ (gcry_cipher_ctl): Add SET_CTR to set counter.
+
+2003-03-30 Moritz Schulte <moritz@g10code.com>
+
+ * rsa.c (_gcry_rsa_blind): New function.
+ (_gcry_rsa_unblind): New function.
+ (_gcry_rsa_decrypt): Use _gcry_rsa_blind and _gcry_rsa_decrypt.
+
+2003-03-26 Moritz Schulte <moritz@g10code.com>
+
+ * dynload.c (_gcry_enum_gnupgext_pubkeys): Adjust `encrypt' and
+ `decrypt' function arguments.
+ (_gcry_enum_gnupgext_pubkeys): Likewise.
+ * dynload.h: Likewise.
+
+ * pubkey.c (dummy_decrypt): Add argument: int flags.
+ (dummy_encrypt): Likewise.
+
+ * elgamal.c (_gcry_elg_encrypt): Add argument: int flags.
+ (_gcry_elg_decrypt): Likewise.
+
+ * rsa.c (_gcry_rsa_encrypt): Add argument: int flags.
+ (_gcry_rsa_decrypt): Likewise.
+
+ * pubkey.c: Add `flags' argument to members `encrypt' and
+ `decrypt' of struct `pubkey_table_s'.
+
+ * rsa.h: Add `flags' argument to function declarations.
+ * elgamal.h: Likewise.
+
+ * pubkey.c (sexp_data_to_mpi): New variable: int parsed_flags.
+ (sexp_data_to_mpi): Set `parsed_flags'.
+ (sexp_data_to_mpi): New argument: int *flags.
+ (gcry_pk_encrypt): New variable: int flags.
+ (gcry_pk_encrypt): Pass `flags' to pubkey_encrypt.
+ (pubkey_encrypt): New variable: int flags.
+ (pubkey_encrypt): Pass `flags' to pubkey encrypt function.
+ (pubkey_decrypt): Likewise.
+ (pubkey_decrypt): Pass `flags' to pubkey encrypt function.
+ (gcry_pk_encrypt): Include `flags' s-exp in return list.
+ (sexp_to_enc): New argument: int *flags.
+ (gcry_pk_decrypt): New variable: int flags.
+ (gcry_pk_decrypt): Pass `flags' to pubkey_decrypt.
+ (sexp_to_enc): New variable: int parsed_flags.
+ (sexp_to_enc): Set `parsed_flags'.
+
+2003-03-22 Simon Josefsson <jas@extundo.com>
+
+ * cipher.c (gcry_cipher_open, do_cbc_encrypt)
+ (gcry_cipher_encrypt): Support GCRY_CIPHER_CBC_MAC.
+ (gcry_cipher_ctl): Support GCRYCTL_SET_CBC_MAC.
+
+2003-03-19 Werner Koch <wk@gnupg.org>
+
+ * primegen.c (gen_prime): New args EXTRA_CHECK and EXTRA_CHECK_ARG
+ to allow for a user callback. Changed all callers.
+ (_gcry_generate_secret_prime)
+ (_gcry_generate_public_prime): Ditto, pass them to gen_prime.
+ * rsa.c (check_exponent): New.
+ (generate): Use a callback to ensure that a given exponent is
+ actually generated.
+
+2003-03-12 Moritz Schulte <moritz@g10code.com>
+
+ * primegen.c: Initialize `no_of_small_prime_numbers' statically.
+ (gen_prime): Remove calculation of `no_of_small_prime_numbers'.
+
+2003-03-03 Moritz Schulte <moritz@g10code.com>
+
+ * md.c (gcry_md_ctl): Rewritten to use same style like the other
+ functions dispatchers.
+
+2003-03-02 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c (struct gcry_cipher_handle): New member: algo_index.
+ (gcry_cipher_open): Allocate memory for two cipher contexts.
+ Initialize algo_index.
+ (cipher_setkey): Duplicate context into reserved memory.
+ (cipher_reset): New function, which resets the context and clear
+ the IV.
+ (gcry_cipher_ctl): Call cipher_reset.
+
+2003-02-23 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.c: Remove (bogus) `digitp' macro definition.
+ * md.c: Likewise.
+
+ * blowfish.c (burn_stack): Removed.
+ * arcfour.c (burn_stack): Likewise.
+ * cast5.c (burn_stack): Likewise.
+ * des.c (burn_stack): Likewise.
+ * md4.c (burn_stack): Likewise.
+ * md5.c (burn_stack): Likewise.
+ * random.c (burn_stack): Likewise.
+ * rijndael.c (burn_stack): Likewise.
+ * rmd160.c (burn_stack): Likewise.
+ * sha1.c (burn_stack): Likewise.
+ * sha256.c (burn_stack): Likewise.
+ * tiger.c (burn_stack): Likewise.
+ * twofish.c (burn_stack): Likewise.
+
+ * blowfish.c: Changed all occurences of burn_stack to
+ _gcry_burn_stack.
+ * arcfour.c: Likewise.
+ * cast5.c: Likewise.
+ * des.c: Likewise.
+ * md4.c: Likewise.
+ * md5.c: Likewise.
+ * random.c: Likewise.
+ * rijndael.c: Likewise.
+ * rmd160.c: Likewise.
+ * sha1.c: Likewise.
+ * sha256.c: Likewise.
+ * tiger.c: Likewise.
+ * twofish.c: Likewise.
+
+ * arcfour.c (_gcry_arcfour_get_info): Use GCRY_CIPHER_ARCFOUR
+ instead of hard-coded value `301'.
+
+2003-01-24 Werner Koch <wk@gnupg.org>
+
+ * random.c (_gcry_register_random_progress): New.
+ (_gcry_random_progress): New.
+
+ * rndlinux.c (gather_random): Call the random progress function.
+
+2003-01-23 Werner Koch <wk@gnupg.org>
+
+ * rsa.c (generate): New arg USE_E to request a specific public
+ exponent.
+ (_gcry_rsa_generate): Ditto.
+ * elgamal.c (_gcry_elg_generate): Must add an dummy argument
+ instead of USE_E.
+ * dsa.c (_gcry_dsa_generate): Ditto.
+ * pubkey.c (dummy_generate): Ditto.
+ (pubkey_generate): Add USE_E arg and pass it down.
+ (gcry_pk_genkey): Detect "rsa-use-e" parameter and pass it to generate.
+
+ * pubkey.c (sexp_to_enc): New arg RET_MODERN.
+ (gcry_pk_decrypt): Make use of it to return a real S-expression.
+ Return better error codes.
+ (gcry_pk_verify): Return better error codes.
+
+2003-01-21 Werner Koch <wk@gnupg.org>
+
+ * random.c (gcry_random_add_bytes): Add QUALITY argument, let
+ function return an error code and disable its core for now.
+
+2003-01-21 Timo Schulz <twoaday@freakmail.de>
+
+ * random.c (gcry_random_add_bytes): New. Function to add external
+ random to the pool.
+
+2003-01-20 Simon Josefsson <jas@extundo.com>
+
+ * crc.c: New.
+ * Makefile.am (EXTRA_PROGRAMS, EXTRA_crc_SOURCES): Add crc.c.
+ * md.c (gcry_md_get_algo_dlen): Add values for CRC.
+
+2003-01-20 Werner Koch <wk@gnupg.org>
+
+ * sha256.c: New.
+ * bithelp.h (ror): New.
+ * Makfile.am: Add sha256.c.
+ * md.c (oid_table): Add values for SHA256 et al.
+ (gcry_md_get_algo_dlen): Likewise
+
+2003-01-20 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_get_keygrip): Implemented keygrips for DSA
+ and ElGamal.
+
+2003-01-17 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_encrypt): Reworked so that the output will
+ never contain the plaintext even if the caller did not checked the
+ return value.
+
+ * md.c (gcry_md_get_algo): Changed error code to GCRYERR_GENERAL
+ because we don't have an invalid md algo but no algorithm enabled.
+
+ * pubkey.c (gcry_pk_genkey): Changed error code for bounds check
+ of table parameters to GCRYERR_INTERNAL.
+
+ * md.c (gcry_md_open): Partly reverted Timo's change from
+ 2002-10-10 by removing the check for the algorithm. An algorithm
+ of 0 is allowed and anyway we should not double check it or check
+ it using a different function. Also fixed the flags check.
+
+ * pubkey.c (gcry_pk_encrypt): Make sure that R_CIPH points to NULL
+ on error.
+ (gcry_pk_decrypt): Ditto for R_PLAIN.
+ (gcry_pk_sign): Ditto for R_SIG.
+ (gcry_pk_genkey): Ditto for R_KEY.
+
+2003-01-16 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_write): Changed 2nd argument type to void*.
+ (gcry_md_hash_buffer): Changed type of boths buffers to void*.
+ (gcry_md_setkey): Changed 2nd argument type to void*.
+
+2003-01-15 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (sexp_data_to_mpi): New. This handles pkcs1 padding.
+ (gcry_pk_sign, gcry_pk_verify): Use it here.
+ (gcry_pk_encrypt): And here.
+ (pubkey_verify): Add debug code.
+ (sexp_to_enc): Handle flags in the input and return the pkcs1 flag
+ in a new parameter.
+ (gcry_pk_decrypt): Prepare for future pkcs1 handling.
+
+2002-12-19 Werner Koch <wk@gnupg.org>
+
+ * random.c (_gcry_random_initialize): New.
+
+2002-12-16 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Added a Teletrust specific OID for 3DES.
+
+2002-12-12 Werner Koch <wk@gnupg.org>
+
+ * md.c: Added another oddball OIW OID (sha-1WithRSAEncryption).
+
+2002-11-23 Werner Koch <wk@gnupg.org>
+
+ * md.c (load_digest_module): Enlarged checked_algos bitmap.
+ * md4.c (func_table): Fixed entry for md4.
+ Both by Simon Josephson.
+ (transform): Copy data to get the alignment straight. Tested only
+ on i386.
+
+2002-11-10 Simon Josefsson <jas@extundo.com>
+
+ * cipher.c (gcry_cipher_open): Don't reject CTS flag.
+ (do_cbc_encrypt, do_cbc_decrypt, cipher_encrypt)
+ (gcry_cipher_encrypt, cipher_decrypt)
+ (gcry_cipher_decrypt): Support CTS flag.
+ (gcry_cipher_ctl): Toggle CTS flag.
+
+2002-11-10 Werner Koch <wk@gnupg.org>
+
+ * md4.c: New. By Simon Josefsson.
+ * Makefile.am (EXTRA_PROGRAMS): Add md4.c.
+ * md.c (oid_table,gcry_md_get_algo_dlen): MD4 support.
+
+2002-10-14 Werner Koch <wk@gnupg.org>
+
+ * arcfour.c (do_encrypt_stream): Don't use increment op when
+ assigning to the same variable.
+
+2002-10-10 Timo Schulz <ts@winpt.org>
+
+ * pubkey.c (gcry_pk_genkey): Check boundaries.
+
+ * md.c (gcry_md_open): Check that algo is available and only
+ valid flag values are used.
+ (gcry_md_get_algo): Add error handling.
+
+2002-09-26 Werner Koch <wk@gnupg.org>
+
+ * md.c: Include an OID for TIGER.
+ * tiger.c (tiger_get_info): Use a regular OID.
+
+2002-09-17 Werner Koch <wk@gnupg.org>
+
+ * random.c: Replaced mutex.h by the new ath.h. Changed all calls.
+
+2002-09-16 Werner Koch <wk@gnupg.org>
+
+ * arcfour.c (do_encrypt_stream): Use register modifier and modulo.
+ According to Nikos Mavroyanopoulos this increases perfromace on
+ i386 system noticable. And I always tought gcc is clever enough.
+ * md5.c (transform): Use register modifier.
+ * rmd160.c (transform): Ditto.
+ * sha1.c (transform): Ditto. We hope that there are 6 free registers.
+ * random.c (gcry_randomize): Rewrote to avoid malloc calls.
+
+ * rndlinux.c (gather_random): Replaced remaining fprintfs by log_*.
+ * arcfour.c (do_arcfour_setkey): Ditto.
+ * twofish.c (do_twofish_setkey): Ditto.
+ * rndegd.c (gather_random): Ditto.
+ * rijndael.c (do_setkey): Ditto.
+ * random.c (_gcry_random_dump_stats): Ditto.
+ * primegen.c (_gcry_generate_elg_prime): Ditto.
+ * des.c (_gcry_des_get_info): Ditto.
+ * cast5.c (do_cast_setkey): Ditto.
+ * blowfish.c (do_bf_setkey): Ditto.
+
+2002-08-26 Werner Koch <wk@gnupg.org>
+
+ * des.c (weak_keys): Fixed one entry in the table and compared
+ all entries against the literature.
+ (selftest): Checksum the weak key table.
+
+2002-08-21 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c: Enable keygrip calculation for "openpgp-rsa".
+
+2002-08-17 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (setup_cipher_table): Don't overwrite the DES entry
+ with the entry for DUMMY.
+
+2002-08-14 Werner Koch <wk@gnupg.org>
+
+ * des.c (do_des_setkey,do_des_encrypt, do_des_decrypt): New.
+ (_gcry_des_get_info): Support plain old DES.
+ * cipher.c (setup_cipher_table): Put DES into the table.
+
+2002-07-25 Werner Koch <wk@gnupg.org>
+
+ * rndunix.c (_gcry_rndunix_constructor): Prefixed with _gcry_.
+ Noted by Stephan Austermuehle.
+
+2002-07-08 Timo Schulz <ts@winpt.org>
+
+ * rndw32.c: Replaced the m_ memory functions with the real
+ gcry_ functions. Renamed all g10_ prefixed functions to log_.
+
+2002-06-12 Werner Koch <wk@gnupg.org>
+
+ * rsa.c (generate): Use e = 65537 for now.
+
+2002-06-11 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_get_keygrip): Allow a "protected-private-key".
+
+2002-06-05 Timo Schulz <ts@winpt.org>
+
+ * cipher.c (gcry_cipher_encrypt, gcry_cipher_decrypt):
+ Check that the input size is a multiple of the blocksize.
+
+2002-05-23 Werner Koch <wk@gnupg.org>
+
+ * md.c (oid_table): Add an rsadsi OID for MD5.
+
+2002-05-21 Werner Koch <wk@gnupg.org>
+
+ * primegen.c, elgamal.c, dsa.c (progress): Do not print anything
+ by default. Pass an extra identifying string to the callback and
+ reserved 2 argumenst for current and total counters. Changed the
+ register function prototype.
+
+2002-05-17 Werner Koch <wk@gnupg.org>
+
+ * rndegd.c (rndegd_constructor): Fixed name of register function
+ and prefixed the function name with _gcry_.
+ * rndw32.c (rndw32_constructor): Ditto.
+ * tiger.c (tiger_constructor): Ditto.
+
+ * Makefile.am: Removed all dynamic loading stuff.
+ * dynload.c: Ditto. Now only used for the constructor system.
+
+2002-05-15 Werner Koch <wk@gnupg.org>
+
+ * random.c (gcry_random_bytes,gcry_random_bytes_secure)
+ (gcry_randomize): Make sure we are initialized.
+
+2002-05-14 Werner Koch <wk@gnupg.org>
+
+ Changed license of most files to the LGPL.
+
+2002-05-02 Werner Koch <wk@gnupg.org>
+
+ * random.c (_gcry_fast_random_poll): Initialize the module so the
+ mutex can be used.
+
+ * primegen.c (small_prime_numbers): Moved table from smallprime.c
+ * smallprime.c: File removed.
+
+ * des.c (leftkey_swap, rightkey_swap, working_memcmp): Made static.
+
+ * cipher.c (gcry_cipher_map_name): Map "RIJNDAEL" to "AES".
+ * rijndael.c (rijndael_get_info): We do only support a 128 bit
+ blocksize so it makes sense to change the algorithm strings to
+ AES.
+
+ * tiger.c (tiger_final): Removed superfluous token pasting operators.
+ * md5.c (md5_final): Ditto.
+
+2002-04-30 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Fixed list of copyright years.
+
+2002-03-18 Werner Koch <wk@gnupg.org>
+
+ * random.c (initialize): Initialize the new pool lock mutex.
+ (_gcry_fast_random_poll): Add locking and moved main
+ code out to...
+ (do_fast_random_poll): new function.
+ (read_pool): Use the new function here.
+ (get_random_bytes): Add locking.
+ (_gcry_update_random_seed_file): Ditto.
+
+2002-03-11 Werner Koch <wk@gnupg.org>
+
+ * md.c: Add rsaSignatureWithripemd160 to OID table.
+
+2002-02-20 Werner Koch <wk@gnupg.org>
+
+ * sha1.c: Removed a left over comment note. The code has been
+ rewritten from scratch in 1998. Thanks to Niels Möller for
+ reporting this misleading comment.
+
+2002-02-18 Werner Koch <wk@gnupg.org>
+
+ * rndunix.c (rndunix_constructor): Use the the new prefixed
+ function name. Reported by Jordi Mallach.
+
+2002-02-10 Werner Koch <wk@gnupg.org>
+
+ * random.c (mix_pool): Carry an extra failsafe_digest buffer
+ around to make the function more robust.
+
+2002-02-08 Werner Koch <wk@gnupg.org>
+
+ * random.c (add_randomness): Xor new data into the pool and not
+ just copy it. This avoids any choosen input attacks which are not
+ serious in our setting because an outsider won't be able to mix
+ data in and even then we keep going with a PRNG. Thanks to Stefan
+ Keller for pointing this out.
+
+2002-01-04 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_genkey): Do not release skey - it is static.
+
+ * primegen.c (gen_prime): Of course we should use set_bit
+ and not set_highbit to set the second high bit.
+
+2001-12-18 Werner Koch <wk@gnupg.org>
+
+ * rsa.c (generate): Loop until we find the exact modulus size.
+ Changed the exponent to 41.
+ (rsa_get_info): s/usage/r_usage/ to avoid shadow warnings.
+ * primegen.c (gen_prime): Set 2 high order bits for secret primes.
+
+ * Makefile.am (DISTCLEANFILES): Include construct.c.
+
+2001-12-17 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_get_keygrip): New - experimental.
+
+2001-12-11 Werner Koch <wk@gnupg.org>
+
+ * cipher.c: Added OIDs for AES.
+ (gcry_cipher_mode_from_oid): New.
+ (gcry_cipher_map_name): Moved OID search code to ..
+ (search_oid): .. new function.
+
+2001-12-10 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (gcry_pk_encrypt): Find the signature algorithm by name
+ and not by number.
+
+ * pubkey.c (gcry_pk_encrypt,gcry_pk_decrypt,gcry_pk_sign)
+ (gcry_pk_verify,gcry_pk_testkey, gcry_pk_genkey)
+ (gcry_pk_get_nbits): Release the arrays. Noted by Nikos
+ Mavroyanopoulos.
+
+2001-12-06 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (gcry_cipher_map_name): Look also for OIDs prefixed
+ with "oid." or "OID.".
+
+2001-12-05 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (algo_info_table): Fixed entry for openpgp-rsa.
+
+2001-11-24 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c: Added the rsaEncryption OID to the tables.
+ (sexp_to_key): Add an arg to return the index of the algorithm,
+ changed all callers.
+ (gcry_pk_sign): Find the signature algorithm by name and not by
+ number.
+ (gcry_pk_get_nbits): Fixed so that we can now really pass a secret
+ key to get the result.
+
+ * md.c (gcry_md_map_name): Look also for OIDs prefixed with "oid."
+ or "OID." so that an OID string can be used as an S-Exp token.
+
+2001-11-20 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_map_name): Lookup by OID if the the name begins
+ with a digit.
+ (oid_table): New.
+
+2001-11-16 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_info): New operator GCRYCTL_IS_ALGO_ENABLED.
+
+2001-11-07 Werner Koch <wk@gnupg.org>
+
+ * md.c (gcry_md_hash_buffer): Close the handle which was left open
+ for algorithms other than rmd160.
+
+2001-08-08 Werner Koch <wk@gnupg.org>
+
+ * rndw32.c (gather_random): Use toolhelp in addition to the NT
+ gatherer for Windows2000. Suggested by Sami Tolvanen.
+
+ * random.c (read_pool): Fixed length check, this used to be one
+ byte to strict. Made an assert out of it because the caller has
+ already made sure that only poolsize bytes are requested.
+ Reported by Marcus Brinkmann.
+
+2001-08-03 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (cipher_encrypt, cipher_decrypt): Prepare to return
+ errors. We have to change the interface to all ciphers to make
+ this really work but we should do so to prepare for hardware
+ encryption modules.
+ (gcry_cipher_encrypt, gcry_cipher_decrypt): Return the error and
+ set lasterr.
+ (gcry_cipher_ctl): Make sure that errors from setkey are returned.
+
+2001-08-02 Werner Koch <wk@gnupg.org>
+
+ * rndlinux.c (gather_random): casted a size_t arg to int so that
+ the format string is correct. Casting is okay here and avoids
+ translation changes.
+
+ * random.c (fast_random_poll): Do not check the return code of
+ getrusage.
+
+ * rndunix.c: Add a signal.h header to avoid warnings on Solaris 7
+ and 8.
+
+ * tiger.c (print_abc,print_data): Removed.
+
+ * rijndael.c, des.c, blowfish.c, twofish.c, cast5.c, arcfour.c
+ (burn_stack): New. Add wrappers for most functions to be able to
+ call burn_stack after the function invocation. This methods seems
+ to be the most portable way to zeroise the stack used. It does
+ only work on stack frame based machines but it is highly portable
+ and has no side effects. Just setting the automatic variables at
+ the end of a function to zero does not work well because the
+ compiler will optimize them away - marking them as volatile would
+ be bad for performance.
+ * md5.c, sha1.c, rmd160.c, tiger.c (burn_stack): Likewise.
+ * random.c (burn_stack): New.
+ (mix_pool): Use it here to burn the stack of the mixblock function.
+
+ * primegen.c (_gcry_generate_elg_prime): Freed q at 3 places.
+ Thanks to Tommi Komulainen.
+
+ * arcfour.c (arcfour_setkey): Check the minimim keylength against
+ bytes and not bits.
+ (selftest): Must reset the key before decryption.
+
+2001-05-31 Werner Koch <wk@gnupg.org>
+
+ * sha1.c (sha1_init): Made static.
+
+ Changed all g10_ prefixed function names as well as some mpi_
+ function names to cope with the introduced naming changes.
+
+ * md.c (prepare_macpads): Made key const.
+
+2001-05-28 Werner Koch <wk@gnupg.org>
+
+ * rndegd.c (gather_random): Removed the use of tty_printf.
+
+2001-03-29 Werner Koch <wk@gnupg.org>
+
+ * md5.c (md5_final): Fixed calculation of hashed length. Thanks
+ to disastry@saiknes.lv for pointing out that it was horrible wrong
+ for more than 512MB of input.
+ * sha1.c (sha1_final): Ditto.
+ * rmd160.c (rmd160_final): Ditto.
+ * tiger.c (tiger_final): Ditto.
+
+ * blowfish.c (encrypt,do_encrypt): Changed name to do_encrypt to
+ avoid name clashes with an encrypt function in stdlib.h of
+ Dynix/PIX. Thanks to Gene Carter.
+ * elgamal.c (encrypt,do_encrypt): Ditto.
+
+ * twofish.c (gnupgext_enum_func): Use only when when compiled as a
+ module.
+ * rijndael.c (gnupgext_enum_func): Ditto.
+
+ * tiger.c (tiger_get_info): Return "TIGER192" and not just
+ "TIGER". By Edwin Woudt.
+
+ * random.c: Always include time.h - standard requirement. Thanks
+ to James Troup.
+
+ * rndw32.c: Fixes to the macros.
+
+2001-01-11 Werner Koch <wk@gnupg.org>
+
+ * cipher.c (cipher_encrypt,gcry_cipher_encrypt): Use blocksize and
+ not 8.
+
+2000-12-19 Werner Koch <wk@gnupg.org>
+
+ Major change:
+ Removed all GnuPG stuff and renamed this piece of software
+ to gcrypt.
+
+2000-11-14 Werner Koch <wk@gnupg.org>
+
+ * dsa.c (test_keys): Replaced mpi_alloc by gcry_mpi_new and
+ mpi_free by gcry_mpi_release.
+ * elgamal.c (test_keys,generate): Ditto, also for mpi_alloc_secure.
+ * rsa.c (test_keys,generate,rsa_verify): Ditto.
+ * primegen.c (generate_elg_prime): Ditto.
+ (gen_prime): Ditto and removed nlimbs.
+
+ * rsa.c (generate): Allocate 2 more vars in secure memory.
+
+ * Makefile.am (OMIT_DEPENDENCIES): Hack to work around dependency
+ problems.
+
+2000-10-09 Werner Koch <wk@gnupg.org>
+
+ * arcfour.c, arcfour.h: New.
+ * cipher.c (cipher_encrypt, cipher_decrypt): Add stream mode.
+ (setup_cipher_table): Add Arcfour.
+ (gcry_cipher_open): Kludge to allow stream mode.
+
+Wed Oct 4 13:16:18 CEST 2000 Werner Koch <wk@openit.de>
+
+ * sha1.c (transform): Use rol() macro. Actually this is not needed
+ for a newer gcc but there are still aoter compilers.
+
+ * rsa.c (test_keys): Use new random function.
+
+ * md.c (gcry_md_setkey): New function to overcome problems with
+ const conflics.
+ (gcry_md_ctl): Pass set key to the new functions.
+
+ * rijndael.c: New.
+ * cipher.c: Add Rijndael support.
+
+Mon Sep 18 16:35:45 CEST 2000 Werner Koch <wk@openit.de>
+
+ * rndlinux.c (open_device): Loose random device checking.
+ By Nils Ellmenreich.
+
+ * random.c (fast_random_poll): Check ENOSYS for getrusage.
+ * rndunix.c: Add 2 sources for QNX. By Sam Roberts.
+
+ * pubkey.c (gcry_pk_algo_info): Add GCRYCTL_GET_ALGO_USAGE.
+
+ * rsa.c: Changed the comment about the patent.
+ (secret): Speed up by using the CRT. For a 2k keys this
+ is about 3 times faster.
+ (stronger_key_check): New but unused code to check the secret key.
+ * Makefile.am: Included rsa.[ch].
+ * pubkey.c: Enabled RSA support.
+ (pubkey_get_npkey): Removed RSA workaround.
+
+Mon Jul 31 10:04:47 CEST 2000 Werner Koch <wk@openit.de>
+
+ * pubkey.c: Replaced all gcry_sexp_{car,cdr}_{data,mpi} by the new
+ gcry_sexp_nth_{data,mpi} functions.
+
+Tue Jul 25 17:44:15 CEST 2000 Werner Koch <wk@openit.de>
+
+ * pubkey.c (exp_to_key,sexp_to_sig,sexp_to_enc,gcry_pk_encrypt,
+ gcry_pk_decrypt,gcry_pk_sign,gcry_pk_genkey): Changed to work with
+ the new S-Exp interface.
+
+Mon Jul 17 16:35:47 CEST 2000 Werner Koch <wk@>
+
+ * random.c (gather_faked): Replaced make_timestamp by time(2) again.
+
+Fri Jul 14 19:38:23 CEST 2000 Werner Koch <wk@>
+
+ * md.c (gcry_md_ctl): Support GCRYCTL_{START,STOP}_DUMP.
+
+ * Makefile.am: Never compile mingw32 as module.
+
+ * Makefile.am: Tweaked module build and removed libtool
+
+ * Makefile.am: Replaced -O1 by -O. Suggested by Alec Habig.
+
+ * elgamal.c (sign): Removed inactive code.
+
+ * rsa.c, rsa.h: New based on the old module version (only in CVS for now).
+ * pubkey.c (setup_pubkey_table): Added commented support for RSA.
+
+ * rndunix.c (waitpid): New. For UTS 2.1. All by Dave Dykstra.
+ (my_popen): Do the FD_CLOEXEC only if it is available
+ (start_gatherer): Cope with missing _SC_OPEN_MAX
+
+ * rndunix.c: Add some more headers for QNX. By Sam Roberts.
+
+ * rndegd.c (gather_random): Shortcut level 0.
+ * rndunix.c (gather_random): Ditto.
+ * rndw32.c (gather_random): Ditto.
+
+ * rndw32.c: Replaced with code from Cryptlib and commented the old stuff.
+ * rndw32.c: Add some debuging code enabled by an environment variable.
+
+ * random.c (read_seed_file): Binary open for DOSish system
+ (update_random_seed_file): Ditto.
+ * random.c [MINGW32]: Include process.h for getpid.
+ * random.c (fast_random_poll): Add clock_gettime() as fallback for
+ system which support this POSIX.4 fucntion. By Sam Roberts.
+
+ * random.c (read_seed_file): Removed the S_ISLNK test becuase it
+ is already covered by !S_ISREG and is not defined in Unixware.
+ Reported by Dave Dykstra.
+ (update_random_seed_file): Silently ignore update request when pool
+ is not filled.
+
+ * random.c (read_seed_file): New.
+ (set_random_seed_file): New.
+ (read_pool): Try to read the seeding file.
+ (update_random_seed_file): New.
+
+ (read_pool): Do an initial extra seeding when level 2 quality random
+ is requested the first time. This requestes at least POOLSIZE/2 bytes
+ of entropy. Compined with the seeding file this should make normal
+ random bytes cheaper and increase the quality of the random bytes
+ used for key generation.
+
+ * random.c (read_pool): Print a more friendly error message in
+ cases when too much random is requested in one call.
+
+ * random.c (fast_random_poll): Check whether RUSAGE_SELF is defined;
+ this is not the case for some ESIX and Unixware, although they have
+ getrusage().
+
+ * primegen.c (generate_elg_prime): All primes are now generated with
+ the lowest random quality level. Because they are public anyway we
+ don't need stronger random and by this we do not drain the systems
+ entropy so much.
+
+ * primegen.c (register_primegen_progress): New.
+ * dsa.c (register_pk_dsa_progress): New.
+ * elgamal.c (register_pk_elg_progress): New.
+
+ * elgamal.c (wiener_map): New.
+ (gen_k): Use a much smaller k.
+ (generate): Calculate the qbits using the wiener map and
+ choose an x at a size comparable to the one choosen in gen_k
+
+ * rmd160.c (rmd160_get_info): Moved casting to the left side due to a
+ problem with UTS4.3. Suggested by Dave Dykstra.
+ * sha1.c (sha1_get_info): Ditto.
+ * tiger.c (tiger_get_info): Ditto.
+ * md5.c (md5_get_info): Ditto
+ * des.c (des_get_info): Ditto.
+ * blowfish.c (blowfish_get_info): Ditto.
+ * cast5.c (cast5_get_info): Ditto.
+ * twofish.c (twofish_get_info): Ditto.
+
+Fri Mar 24 11:25:45 CET 2000 Werner Koch <wk@openit.de>
+
+ * md.c (md_open): Add hmac arg and allocate space for the pads.
+ (md_finalize): Add HMAC support.
+ (md_copy): Ditto.
+ (md_close): Ditto.
+ (gcry_md_reset): Ditto.
+ (gcry_md_ctl): Ditto.
+ (prepare_macpdas): New.
+
+Mon Mar 13 19:22:46 CET 2000 Werner Koch <wk@openit.de>
+
+ * md.c (gcry_md_hash_buffer): Add support for the other algorithms.
+
+Mon Jan 31 16:37:34 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * genprime.c (generate_elg_prime): Fixed returned factors which never
+ worked for non-DSA keys.
+
+Thu Jan 27 18:00:44 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (sexp_to_key): Fixed mem leaks in case of errors.
+
+Mon Jan 24 22:24:38 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (gcry_pk_decrypt): Implemented.
+ (gcry_pk_encrypt): Implemented.
+ (gcry_pk_testkey): New.
+ (gcry_pk_genkey): New.
+ (pubkey_decrypt): Made static.
+ (pubkey_encrypt): Ditto.
+ (pubkey_check_secret_key): Ditto.
+ (pubkey_generate): Ditto.
+
+Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (pubkey_nbits): Removed and replaced by ...
+ (gcry_pk_get_nbits): this new one.
+
+Wed Dec 8 21:58:32 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * dsa.c: s/mpi_powm/gcry_mpi_powm/g
+ * elgamal.c: Ditto.
+ * primegen.c: Ditto.
+
+ * : Replaced g10_opt_verbose by g10_log_verbosity().
+
+ * Makefile.am (INCLUDES): removed intl, add ../gcrypt
+
+Fri Nov 19 17:15:20 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * dynload.c (cmp_filenames): New to replaced compare_filename() in
+ module.
+ (register_cipher_extension): Removed the tilde expansion stuff.
+ * rndeg.c (my_make_filename): New.
+
+ * : Replaced header util.h by g10lib.h
+
+ * random.c (gather_faked): Replaced make_timestamp by time(2).
+ Disabled wrning printed with tty_printf.
+ * rndlinux.c (gather_random): Always use fprintf instead of tty_xxx;
+ this should be replaced by a callback function.
+
+ * primegen.c (gen_prime): Use gcry_mpi_randomize.
+ (is_prime): Ditto.
+ * elgamal.c (test_keys): Ditto.
+ * dsa.c (test_keys): Ditto.
+
+ * cipher.c (gcry_cipher_close): Die on invalid handle.
+
+Mon Nov 15 21:36:02 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * elgamal.c (gen_k): Use the new random API.
+ (generate): Ditto.
+ * dsa.c (gen_k): Ditto.
+ (generate): Ditto.
+
+Sat Nov 13 17:44:23 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * pubkey.c (disable_pubkey_algo): Made static.
+ (gcry_pk_ctl): New.
+
+ * random.c (get_random_bits): Renamed to ...
+ (get_random_bytes): ... this and made static.
+ (gcry_random_bytes): New.
+ (gcry_random_bytes_secure): New.
+ (randomize_buffer): Renamed to ...
+ (gcry_randomize): ...this.
+
+ * md.c (gcry_md_hash_buffer): New.
+
+ * pubkey.c (gcry_pk_algo_info): 4 new commands.
+ (pubkey_get_npkey): Made static.
+ (pubkey_get_nskey): Made static.
+ (pubkey_get_nsig): Made static.
+ (pubkey_get_nenc): Made static.
+
+ * pubkey.c: Removed all G10ERR_xxx.
+ * cipher.c: Changed all GCRYERR_INV_ALGO to GCRYERR_INV_CIPHER_ALGO.
+ * md.c: Changed all GCRYERR_INV_ALGO to GCRYERR_INV_MD_ALGO.
+ * cast5.c (cast_setkey): Changed errocodes to GCRYERR_xxx.
+ * blowfish.c: Ditto.
+ * des.c: Ditto.
+ * twofish.c: Ditto.
+ * dsa.c: Ditto.
+ * elgamal.c: Ditto.
+
+ * g10c.c: Removed
+
+ * cipher.c (gcry_cipher_open): Replaced alloc functions and return NULL
+ if we are out of core.
+ * dynload.c: Replaced all memory allocation functions.
+ * md.c: Ditto.
+ * primegen.c: Ditto.
+ * pubkey.c: Ditto.
+ * random.c: Ditto.
+ * rndw32.c: Ditto.
+ * elgamal.c: Ditto.
+ * dsa.c: Ditto.
+
+Tue Oct 26 14:10:21 CEST 1999 Werner Koch <wk@gnupg.de>
+
+ * elgamal.c (sign): Hugh found strange code here. Replaced by BUG().
+
+ * cipher.c: Merged with gcrypt/symapi.c.
+
+ * pubkey.c (string_to_pubkey_algo): Renamed function to ...
+ (gcry_pk_map_name): ... this.
+ (pubkey_algo_to_string): Renamed function to ...
+ (gcry_pk_algo_name): ... this.
+ (gcry_pk_algo_info): New.
+ * pubkey.c: Merged with gcrypt/pkapi.c.
+
+ * md.c (md_reset): Clear finalized; thanks to Ulf Moeller for
+ fixing this bug.
+
+ * md.c: Merged with gcrypt/mdapi.c
+
+Wed Sep 15 14:39:59 CEST 1999 Michael Roth <mroth@nessie.de>
+
+ * des.c: Various speed improvements: One bit pre rotation
+ trick after initial permutation (Richard Outerbridge).
+ Finished test of SSLeay Tripple-DES patterns.
+
+Wed Sep 15 16:22:17 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndw32.c: New.
+
+Mon Sep 13 10:51:29 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * bithelp.h: New.
+ * rmd160.h, sha1.h, md5.h: Use the rol macro from bithelp.h
+
+Tue Sep 7 16:23:36 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Fixed seds for latest egcc. By Ollivier Robert.
+
+Mon Sep 6 19:59:08 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * des.c (selftest): Add some testpattern
+
+Mon Aug 30 20:38:33 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (do_cbc_encrypt): Fixed serious bug occuring when not using
+ in place encryption. Pointed out by Frank Stajano.
+
+Mon Jul 26 09:34:46 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md5.c (md5_final): Fix for a SCO cpp bug.
+
+Thu Jul 15 10:15:35 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * elgamal.c (elg_check_secret_key,elg_encrypt
+ elg_decrypt,elg_sign,elg_verify): Sanity check on the args.
+ * dsa.c (dsa_check_secret_key,dsa_sign,dsa_verify): Ditto.
+
+ * pubkey.c (disable_pubkey_algo): New.
+ (check_pubkey_algo2): Look at disabled algo table.
+ * cipher.c (disable_cipher_algo): New.
+ (check_cipher_algo): Look at disabled algo table.
+
+Wed Jul 7 13:08:40 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Support for libtool.
+
+Fri Jul 2 11:45:54 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dsa.c (gen_k): Changed algorithm to consume less random bytes
+ * elgamal.c (gen_k): Ditto.
+
+ * random.c (random_dump_stats): New.
+
+Thu Jul 1 12:47:31 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * primegen.c, elgamal.c, dsa.c (progess): New and replaced all
+ fputc with a call to this function.
+
+Sat Jun 26 12:15:59 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndegd.c (do_write): s/ssize_t/int/ due to SunOS 4.1 probs.
+
+ * cipher.c (do_cbc_encrypt, do_cbc_decrypt): New.
+
+ * dynload.c (HAVE_DL_SHL_LOAD): Map hpux API to dlopen (Dave Dykstra).
+ * Makefile.am (install-exec-hook): Removed.
+
+Sun May 23 14:20:22 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (setup_cipher_table): Enable Twofish
+
+ * random.c (fast_random_poll): Disable use of times() for mingw32.
+
+Mon May 17 21:54:43 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (register_internal_cipher_extension): Minor init fix.
+
+Tue May 4 15:47:53 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * primegen.c (gen_prime): Readded the Fermat test. Fixed the bug
+ that we didn't correct for step when passing the prime to the
+ Rabin-Miller test which led to bad performance (Stefan Keller).
+ (check_prime): Add a first Fermat test.
+
+Sun Apr 18 10:11:28 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (cipher_setiv): Add ivlen arg, changed all callers.
+
+ * random.c (randomize_buffer): alway use secure memory because
+ we can't use m_is_secure() on a statically allocated buffer.
+
+ * twofish.c: Replaced some macros by a loop to reduce text size.
+ * Makefile.am (twofish): No more need for sed editing.
+
+Fri Apr 9 12:26:25 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (cipher_open): Reversed the changes for AUTO_CFB.
+
+ * blowfish.c: Dropped the Blowfish 160 mode.
+ * cipher.c (cipher_open): Ditto.
+ (setup_cipher_table): Ditto. And removed support of twofish128
+
+Wed Apr 7 20:51:39 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (get_random_bits): Can now handle requests > POOLSIZE
+
+ * cipher.c (cipher_open): Now uses standard CFB for automode if
+ the blocksize is gt 8 (according to rfc2440).
+
+ * twofish.c: Applied Matthew Skala's patches for 256 bit key.
+
+Tue Apr 6 19:58:12 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (get_random_bits): Can now handle requests > POOLSIZE
+
+ * cipher.c (cipher_open): Now uses standard CFB for automode if
+ the blocksize is gt 8 (according to rfc2440).
+
+Sat Mar 20 11:44:21 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndlinux.c (tty_printf) [IS_MODULE]: Removed.
+
+ * rndegd.c (gather_random): Some fixes.
+
+Wed Mar 17 13:09:03 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndegd.c (do_read): New.
+ (gather_random): Changed the implementation.
+
+Mon Mar 8 20:47:17 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (DLSYM_NEEDS_UNDERSCORE): Renamed.
+
+Fri Feb 26 17:55:41 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md.c: Nearly a total rewrote.
+
+Wed Feb 24 11:07:27 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * cipher.c (context): Fixed alignment
+ * md.c: Ditto.
+
+ * rndegd.c: New
+
+Mon Feb 22 20:04:00 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndegd.c: New.
+
+Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Modules are now figured out by configure
+ * construct.c: New. Generated by configure. Changed all modules
+ to work with that.
+ * sha1.h: Removed.
+ * md5.h: Removed.
+
+ * twofish.c: Changed interface to allow Twofish/256
+
+ * rndunix.c (start_gatherer): Die on SIGPIPE.
+
+Wed Jan 20 18:59:49 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndunix.c (gather_random): Fix to avoid infinite loop.
+
+Sun Jan 17 11:04:33 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * des.c (is_weak_key): Replace system memcmp due to bugs
+ in SunOS's memcmp.
+ (des_get_info): Return error on failed selftest.
+ * twofish.c (twofish_setkey): Return error on failed selftest or
+ invalid keylength.
+ * cast5.c (cast_setkey): Ditto.
+ * blowfish.c (bf_setkey): Return error on failed selftest.
+
+Tue Jan 12 11:17:18 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (random_is_faked): New.
+
+ * tiger.c: Only compile if we have the u64 type
+
+Sat Jan 9 16:02:23 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndunix.c (gather_random): check for setuid.
+
+ * Makefile.am: Add a way to staically link random modules
+
+Thu Jan 7 18:00:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md.c (md_stop_debug): Do a flush first.
+ (md_open): size of buffer now depends on the secure parameter
+
+Sun Jan 3 15:28:44 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndunix.c (start_gatherer): Fixed stupid ==/= bug
+
+1998-12-31 Geoff Keating <geoffk@ozemail.com.au>
+
+ * des.c (is_weak_key): Rewrite loop end condition.
+
+Tue Dec 29 14:41:47 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c: add unistd.h for getpid().
+ (RAND_MAX): Fallback value for Sun.
+
+Wed Dec 23 17:12:24 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md.c (md_copy): Reset debug.
+
+Mon Dec 14 21:18:49 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * random.c (read_random_source): Changed the interface to the
+ random gathering function.
+ (gather_faked): Use new interface.
+ * dynload.c (dynload_getfnc_fast_random_poll): Ditto.
+ (dynload_getfnc_gather_random): Ditto.
+ * rndlinux.c (gather_random): Ditto.
+ * rndunix.c (gather_random): Ditto.
+
+Sat Dec 12 18:40:32 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (SYMBOL_VERSION): New to cope with system which needs
+ underscores.
+
+ * rndunix.c: Rewrote large parts
+
+Thu Dec 10 20:15:36 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (load_extension): increased needed verbosity level.
+
+ * random.c (fast_random_poll): Fallback to a default fast random
+ poll function.
+ (read_random_source): Always use the faked entroy gatherer if no
+ gather module is available.
+ * rndlinux.c (fast_poll): Removed.
+ * rndunix.c (fast_poll): Removed.
+
+
+Wed Nov 25 12:33:41 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-*.c: Removed.
+ * rndlinux.c : New.
+ * rndunix.c : New.
+ * random.c : Restructured the interface to the gather modules.
+ (intialize): Call constructor functions
+ (read_radnom_source): Moved to here.
+ * dynload.c (dynload_getfnc_gather_random): New.
+ (dynload_getfnc_fast_random_poll): New.
+ (register_internal_cipher_extension): New.
+ (register_cipher_extension): Support of internal modules.
+
+Sun Nov 8 17:44:36 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-unix.c (read_random_source): Removed the assert.
+
+Mon Oct 19 18:34:30 1998 me,,, (wk@tobold)
+
+ * pubkey.c: Hack to allow us to give some info about RSA keys back.
+
+Thu Oct 15 11:47:57 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dynload.c: Support for DLD
+
+Wed Oct 14 12:13:07 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-unix.c: Now uses names from configure for /dev/random.
+
+1998-10-10 SL Baur <steve@altair.xemacs.org>
+
+ * Makefile.am: fix sed -O substitutions to catch -O6, etc.
+
+Tue Oct 6 10:06:32 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-unix.c (HAVE_GETTIMEOFDAY): Fixed (was ..GETTIMEOFTIME :-)
+ * rand-dummy.c (HAVE_GETTIMEOFDAY): Ditto.
+
+Mon Sep 28 13:23:09 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_digest): New.
+ (md_reset): New.
+
+Wed Sep 23 12:27:02 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c (TIGER_CONTEXT): moved "buf", so that it is 64 bit aligned.
+
+Mon Sep 21 06:22:53 1998 Werner Koch (wk@(none))
+
+ * des.c: Some patches from Michael.
+
+Thu Sep 17 19:00:06 1998 Werner Koch (wk@(none))
+
+ * des.c : New file from Michael Roth <mroth@nessie.de>
+
+Mon Sep 14 11:10:55 1998 Werner Koch (wk@(none))
+
+ * blowfish.c (bf_setkey): Niklas Hernaeus patch to detect weak keys.
+
+Mon Sep 14 09:19:25 1998 Werner Koch (wk@(none))
+
+ * dynload.c (RTLD_NOW): Now defined to 1 if it is undefined.
+
+Mon Sep 7 17:04:33 1998 Werner Koch (wk@(none))
+
+ * Makefile.am: Fixes to allow a different build directory
+
+Thu Aug 6 17:25:38 1998 Werner Koch,mobil,,, (wk@tobold)
+
+ * random.c (get_random_byte): Removed and changed all callers
+ to use get_random_bits()
+
+Mon Jul 27 10:30:22 1998 Werner Koch (wk@(none))
+
+ * cipher.c : Support for other blocksizes
+ (cipher_get_blocksize): New.
+ * twofish.c: New.
+ * Makefile.am: Add twofish module.
+
+Mon Jul 13 21:30:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (read_pool): Simple alloc if secure_alloc is not set.
+ (get_random_bits): Ditto.
+
+Thu Jul 9 13:01:14 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dynload.c (load_extension): Function now nbails out if
+ the program is run setuid.
+
+Wed Jul 8 18:58:23 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (rmd160_hash_buffer): New.
+
+Thu Jul 2 10:50:30 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c (cipher_open): algos >=100 use standard CFB
+
+Thu Jun 25 11:18:25 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * Makefile.am: Support for extensions
+
+Thu Jun 18 12:09:38 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (mix_pool): simpler handling for level 0
+
+Mon Jun 15 14:40:48 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c: Removed from dist, will reappear as dynload module
+
+Sat Jun 13 14:16:57 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * pubkey.c: Major changes to allow extensions. Changed the inteface
+ of all public key ciphers and added the ability to load extensions
+ on demand.
+
+ * misc.c: Removed.
+
+Wed Jun 10 07:52:08 1998 Werner Koch,mobil,,, (wk@tobold)
+
+ * dynload.c: New.
+ * cipher.c: Major changes to allow extensions.
+
+Mon Jun 8 22:43:00 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c: Major internal chnages to support extensions.
+ * blowfish.c (blowfish_get_info): New and made all internal
+ functions static, changed heder.
+ * cast5.c (cast5_get_info): Likewise.
+
+Mon Jun 8 12:27:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c (transform): Fix for big endian
+
+ * cipher.c (do_cfb_decrypt): Big endian fix.
+
+Fri May 22 07:30:39 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_get_oid): Add a new one for TIGER.
+
+Thu May 21 13:24:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c: Add support for a dummy cipher
+
+Thu May 14 15:40:36 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (transform): fixed sigbus - I should better
+ add Christian von Roques's new implemenation of rmd160_write.
+
+Fri May 8 18:07:44 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rand-internal.h, rand-unix.c, rand-w32.c, rand_dummy.c: New
+ * random.c: Moved system specific functions to rand-****.c
+
+Fri May 8 14:01:17 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (fast_random_poll): add call to gethrtime.
+
+Tue May 5 21:28:55 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * elgamal.c (elg_generate): choosing x was not correct, could
+ yield 6 bytes which are not from the random pool, tsss, tsss..
+
+Tue May 5 14:09:06 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * primegen.c (generate_elg_prime): Add arg mode, changed all
+ callers and implemented mode 1.
+
+Mon Apr 27 14:41:58 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c (cipher_get_keylen): New.
+
+Sun Apr 26 14:44:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * tiger.c, tiger.h: New.
+
+Wed Apr 8 14:57:11 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * misc.c (check_pubkey_algo2): New.
+
+Tue Apr 7 18:46:49 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cipher.c: New
+ * misc.c (check_cipher_algo): Moved to cipher.c
+ * cast5.c: Moved many functions to cipher.c
+ * blowfish.c: Likewise.
+
+Sat Apr 4 19:52:08 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * cast5.c: Implemented and tested.
+
+Wed Apr 1 16:38:27 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * elgamal.c (elg_generate): Faster generation of x in some cases.
+
+Thu Mar 19 13:54:48 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * blowfish.c (blowfish_decode_cfb): changed XOR operation
+ (blowfish_encode_cfb): Ditto.
+
+Thu Mar 12 14:04:05 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * sha1.c (transform): Rewrote
+
+ * blowfish.c (encrypt): Unrolled for rounds == 16
+ (decrypt): Ditto.
+
+Tue Mar 10 16:32:08 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (transform): Unrolled the loop.
+
+Tue Mar 10 13:05:14 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (read_pool): Add pool_balance stuff.
+ (get_random_bits): New.
+
+ * elgamal.c (elg_generate): Now uses get_random_bits to generate x.
+
+
+Tue Mar 10 11:33:51 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_digest_length): New.
+
+Tue Mar 10 11:27:41 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dsa.c (dsa_verify): Works.
+
+Mon Mar 9 12:59:08 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * dsa.c, dsa.h: Removed some unused code.
+
+Wed Mar 4 10:39:22 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_open): Add call to fast_random_poll.
+ blowfish.c (blowfish_setkey): Ditto.
+
+Tue Mar 3 13:32:54 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * rmd160.c (rmd160_mixblock): New.
+ * random.c: Restructured to start with a new RNG implementation.
+ * random.h: New.
+
+Mon Mar 2 19:21:46 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * gost.c, gost.h: Removed because they did only contain trash.
+
+Sun Mar 1 16:42:29 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * random.c (fill_buffer): removed error message if n == -1.
+
+Fri Feb 27 16:39:34 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c (md_enable): No init if called twice.
+
+Thu Feb 26 07:57:02 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * primegen.c (generate_elg_prime): Changed the progress printing.
+ (gen_prime): Ditto.
+
+Tue Feb 24 12:28:42 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md5.c, md.5 : Replaced by a modified version of md5.c from
+ GNU textutils 1.22.
+
+Wed Feb 18 14:08:30 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * md.c, md.h : New debugging support
+
+Mon Feb 16 10:08:47 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * misc.c (cipher_algo_to_string): New
+ (pubkey_algo_to_string): New.
+ (digest_algo_to_string): New.
+
+
+ Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+
+ This file is free software; as a special exception the author gives
+ unlimited permission to copy and/or distribute it, with or without
+ modifications, as long as this notice is preserved.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/grub-core/lib/libgcrypt/cipher/Makefile.am b/grub-core/lib/libgcrypt/cipher/Makefile.am
new file mode 100644
index 0000000..76cdc96
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/Makefile.am
@@ -0,0 +1,83 @@
+# Makefile for cipher modules
+# Copyright (C) 1998, 1999, 2000, 2001, 2002,
+# 2003, 2009 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+# Process this file with automake to produce Makefile.in
+
+EXTRA_DIST = Manifest
+
+# Need to include ../src in addition to top_srcdir because gcrypt.h is
+# a built header.
+AM_CPPFLAGS = -I../src -I$(top_srcdir)/src
+AM_CFLAGS = $(GPG_ERROR_CFLAGS)
+
+
+noinst_LTLIBRARIES = libcipher.la
+
+GCRYPT_MODULES = @GCRYPT_CIPHERS@ @GCRYPT_PUBKEY_CIPHERS@ @GCRYPT_DIGESTS@
+
+libcipher_la_DEPENDENCIES = $(GCRYPT_MODULES)
+libcipher_la_LIBADD = $(GCRYPT_MODULES)
+
+libcipher_la_SOURCES = \
+cipher.c pubkey.c ac.c md.c kdf.c \
+hmac-tests.c \
+bithelp.h \
+primegen.c \
+hash-common.c hash-common.h \
+rmd.h
+
+EXTRA_libcipher_la_SOURCES = \
+arcfour.c \
+blowfish.c \
+cast5.c \
+crc.c \
+des.c \
+dsa.c \
+elgamal.c \
+ecc.c \
+idea.c \
+md4.c \
+md5.c \
+rijndael.c rijndael-tables.h \
+rmd160.c \
+rsa.c \
+seed.c \
+serpent.c \
+sha1.c \
+sha256.c \
+sha512.c \
+tiger.c \
+whirlpool.c \
+twofish.c \
+rfc2268.c \
+camellia.c camellia.h camellia-glue.c
+
+if ENABLE_O_FLAG_MUNGING
+o_flag_munging = sed -e 's/-O\([2-9s][2-9s]*\)/-O1/' -e 's/-Ofast/-O1/g'
+else
+o_flag_munging = cat
+endif
+
+
+# We need to lower the optimization for this module.
+tiger.o: $(srcdir)/tiger.c
+ `echo $(COMPILE) -c $(srcdir)/tiger.c | $(o_flag_munging) `
+
+tiger.lo: $(srcdir)/tiger.c
+ `echo $(LTCOMPILE) -c $(srcdir)/tiger.c | $(o_flag_munging) `
diff --git a/grub-core/lib/libgcrypt/cipher/Manifest b/grub-core/lib/libgcrypt/cipher/Manifest
new file mode 100644
index 0000000..0cd64f7
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/Manifest
@@ -0,0 +1,73 @@
+# Manifest - checksums of the cipher directory
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+# Checksums for all source files in this directory. Format is
+# filename, blanks, base-64 part of an OpenPGP detached signature
+# without the header lines. Blank lines and lines beginning with a
+# hash mark are ignored. A tool to process this file is available by
+# cvs -d :pserver:anoncvs@cvs.gnupg.org:/cvs/wk co misc-scripts/manifest-tool
+#
+# The special entry "$names$" holds a signature over all sorted
+# filenames excluding itself.
+
+
+# Algorithm API
+cipher.c iQCVAwUAQDzrVjEAnp832S/7AQIPDgP+OVJ/YNWY5m7c09EBbPAzL/WsGoj6wrBNMmkRlMOqTHeh+OOtjuFHt1f9uhfM2Nzl7sJ5+h4ryZKLEZmQPRMTZTnAqkvGdsrJWJnigUA9QwYdV0ONqC9C63gpuG465gO9TZVOqlQu/FTxSRuTQYUulkaBNG71n8nZEOusBVwV2YA==58xH
+pubkey.c iQCVAwUAP9XQ3jEAnp832S/7AQJ5UgQAyHfEBvPVJ8wTRg8c7ixS2GiVmIgwIo5tvQaiQJTPWASevvYrB+2Z2qa9cATyu50ACjLzbaquGBgPzjJV3dU/qttT1gCqRuN/LCNvXFe5qnIZezejc3RAadFNTw/pOTHq0wxD1Keg66ruei9R36Nba59pEQIWIBXTfubRft2hMYk==E09t
+ac.c iQCVAwUAQDzsOzEAnp832S/7AQJCBQP/WI6EV/dsR4rmha6RVhvkjZo17kQ8z6pIl5J3cXOvqEkIFeD2HYu3HHrWST5l7yXlffhpDkVHkfMih4ruK76q6Fm0dxZ98pO4C/dVtgimlvvcy/wOQjpzsE0fYAe1BYdg81LJ09X33vW5x6C29lunfKROO2tPlV5i8ffeoFvmMF8==j26g
+md.c iQCVAwUAP+NFGjEAnp832S/7AQJs8wP/Qdk0EAKsyr3O1/pmOSN8AG4rPKbd6KDTzvoBPAN4upFwKYY4hWwvy12Q3YU9DmECrzZkRCXHR7mljVQKs6B7CRZJKjFKmOELpcJDtKvu40vTs1bOH4k9iJYZpGgRA83nkQ+ELAcphAbCA+KIpVr2K4mCJAB0FhpC2uOQ50JHAko==BeF6
+primegen.c iQCVAwUAQDzsoDEAnp832S/7AQKYRwP/TqAQBm1rHTnF0HYE05PqXfWlOqa6EosqVpaOcs/OIW6PaqX0xH1UlrukK7jNOjK3xC4o1qNQ1UKzz2dvQaq1bMvNNizeavxAh10SJZc0hIc/ofc83IbjLh8SZVWQ67JxjsUd3DOXmSmhPZ+Pqd7cUIiw8fDoF+I9EZqy3COu1wY==1ebT
+
+# Algorithm implementations
+arcfour.c iQCVAwUAP9XR/TEAnp832S/7AQJcRwP6AlvYEx++fpT4mIYo0xRDqKEQeqMQvbaRhIg2eV74JxItpHa3q5YsYIl+n1yUz5g35JRWWXSWmAZBwO5wLKsHii4kRUhgrKWnSoQZoPpl49L5+N3R58ON3S0ru5lsBiEJEze3xplf2vqwrH9v1QHVD+gU7UTlfNqrIJoOUXN+1O4==Tq+x
+blowfish.c iQCVAwUAP9XTETEAnp832S/7AQJaEgQAgiqqfuO+zQtscgTB0rvOzVymIKjRKjYhFuLjVuc79G4z1RCAffvIn/YM2d7kt+Z/QF7zjcTAOgETCQL1XokpX2zz9HPAMi2tlDY5zsDufTNqj0n4WBL9nM7w6XAvsiwP1B3bqCTv9SjJV4KbxJ58vw1yQE+sqW74R/QIHFvC7mU==wZnX
+cast5.c iQCVAwUAP9XT6DEAnp832S/7AQJ3xgP/ehLjEN3GELGudbqeo91Xd+PqitHrkuBbtRIYX7Udd/fyXLN+h8rMJVyIQX2m+mpxbBxudVU3x8/DNT8B0ZHAwK6qqJmEBLLhEYPgIuF76i9LMrP1KqUPhAwRZ2OppjIIugBQ+rP74aD4eLyd/aKQHNuXML8QGWR6KwQShohXM5I==/BRh
+crc.c iQCVAwUAP7ouejEAnp832S/7AQIgwQQApg5Nm63tH5DQkbN+zPzMO9Ygoj3ukxfFTyTBPYSXYKMiTjEbESegaU40uN8jnz2vprcIQWcgZfzO4+opEJMcI35aPwzEk0vKOp0S/PrBLUY2rJfnDVkX5XgJFZa2Q7LLe826UEBzTVYW924utiCCe8oOaOEWVNpg1mqdknu3M9o==kz5D
+des.c iQCVAwUAQCN2oDEAnp832S/7AQL/jwP6Auoq6nZCDBjpgc9tDzuIRwa9DqyuM3gX94uvgEpUwdHszb2bG43dz03kVmcYxtj1MzXbyCeCZOwox0b2SKmLgxIbrNP6yGbzVdTj6592gDYuf/ZXmc1ZNJ1DDldcPQ0n9fXUipUPwyPaNWo3mSZaNcMKSWWzdK0J6ciG6nk7SWI==9k/t
+dsa.c iQCVAwUAP9XZHDEAnp832S/7AQLBRgP/XrBzTEYx5ccMj1MMb6sg37liEHdIyyy49zjvt6jUqxj4RuwVEN8S6v3u4q/QyJkHAi1E0EkREgENlyHW6PKWhYbcrd0vPIAN15yjnl2yqtrCrJImexUCoqJJewK0E4JOicGbabTil8MZjk+mbhEPnjJBqOkyP1w0i31pEDgE/8M==pC8s
+elgamal.c iQCVAwUAP9XbYzEAnp832S/7AQLXagQA3HrvspZfbTGgmUH0IqLQTJ0exUPxJv5DET2TvoIy62trDmMN6lTAj5P+a7jQ8udcu0w+mR2vXUHcxUpNA2PxLaMwGzNSY4zRDNe9r3SFTDrFm6m4y9Ko2e8XtEA+WF6P/XLpck4Jn7vMEDmVGPwkNd22kXFFE8dBGwG6i5Hk1Mk==oBUs
+md4.c iQCVAwUAP9h50DEAnp832S/7AQJhHgQAzNA/B6MWFDlCtPkIVaW8RpP1Eg0ZNMsy0s7SJkopOCBlu6CwXUOKe+8ppcSxhjYKh4i4uQr/QtfipYlBjzKJGnrafoF/NugXNCOHSTGT11TvK7mCiBuUMVgvZGAlOJImk6eTTfUjRrMfaXM/SWl8bdJ4ZpzdjEyVh89r7I5JrGk==x2UD
+md5.c iQCVAwUAP9h7LzEAnp832S/7AQJUGQP/c0cbf6WZXCzmjufHxiE9FAQBzTsA0WtaNqdFcHl7fhmikGtknlaED8n5a7eYd/C481UQW6Wgq/oZdsvgoPWPhG3fOCy2CFP9cZVXITuMSf0ucyZTFUJNO15fnZ+nDfsUv+JPdv1aSeRinAUtfAcSKfkSyR9BCPZvkx+tgU6cphU==Zv+h
+rijndael.c iQCVAwUAP9h9cTEAnp832S/7AQKF1AP+P2L/tPqDJRDg+/fwbOk8Ts0MNxnvvYEm3gE73TKuLt1S+B2+jkrZcKNvM5VGPnVMJbnS0lmIK04nmedHCOftGTOwhGulZAHHIaKGystT3Jql4iPws/JMgAjE7Fyxh5WZMtB9yEljKBpJ5XNqhrMvvxcHpnyP3+YzIXNwzk34V+c==dJ5k
+rmd160.c iQCVAwUAP9h+bTEAnp832S/7AQK1OgP+PNKF6Nzi6X93easVlksdLqKEsArCAw2QjGWDGyxTnbiJM55qAl9JxR1mn3V+oOL7izLLwTt6EYK9evhzfcxY5N5Mni85RAcsLPsuAfQDEzjI6GUWHtQUKPbM+BaorzfhQjYFSZyvum/dZYJ/WfiwwwhqqIKyVU2ZFSqA38YGC/c==9jdA
+rsa.c iQCVAwUAP9iHIzEAnp832S/7AQKAYwQAuWtnMte54QHN+Hij9t4sGuypXogajOb1vQQwGgS0fKsaBZsuSP2amze4o5diIvsQTsFQ4CzjvqoCVuBDoHM3xkSD8wGDizgvtCamAxkdbF7wmzldKFn8SpJqlVwWQMP6kk1IjXHEuYb4IDWGTbVMhfEu+eOlU8+PSK4IhZqNvt4==/3hp
+serpent.c iQCVAwUAP9h/VzEAnp832S/7AQLyCwP/d1zbmb7l/PriZNa9/Z7mo01XFe5MnAqCfIwhl9GjeaMszcoS37jECNq5nLvrTTFIIJpm3rvBePwiCG4Wwx1I18HCxaP198pcSaR+BLOJ3Aj52EZPrxtqlDKuFr38ZOP5giyUqUYVYGVdrz4kRMNWAZQK53GeJnGhXCnhxojLEgA==ck46
+sha1.c iQCVAwUAP9iATTEAnp832S/7AQKcSwQAwAs/HnNqho3lU1ZUgCPNt5P2/Brm6W21+wWWGKJkSrra/c4NYVKJGDDwlsFE0b9ln1uZt7bHReFkKXK3JnrKTmNVcx/Cy64iCMRNMhaM72Mqy7wWx5yHBAmMBxzFGnNQKbmeY52zeGih5HsNLSibc2pPuOViWo2JPJ5Ci/wIwl8==/wtO
+sha256.c iQCVAwUAP9iAtzEAnp832S/7AQJD2QP/UqvL0hhjG1wEFbGrdkV9tba1sMDXdnnK6X7HdLuRpVAgNiQiFf8JDmntd/dZ2Q71p4Uae2ctqve4WoEijPUZPjACnpuZfx0SEQL0lQBkwxzJp7lz9ujVtwQ2cM/aYexJkXcWgGcloJNLM3JbWPGIJnuYbr/IwJ6RQF9vgj0357o==UWO1
+sha512.c iQCVAwUAP9iBTDEAnp832S/7AQIPBAQA28CJSUQLiW0s2x9u8/OH2eKnxPjA4sZmb50WP7920Lem66P31C3BrOqwfBot4RLhjL+zh/+Uc4s3HPwApZuj9E4BxNMlqLv+Tqk++DAbdaOeYT4jeUt+mlhQQ6mH/RDsy32rZsNsGQ2bUGxazZmfG++PL3JyhawqCy00SUDr/o0==H+0X
+tiger.c iQCVAwUAP9iCfjEAnp832S/7AQKufwP/fryv3MqSOYY+90325DH7X3/CtekxeooN0scGsHX0fxBakWSMecTNrj33KPddLS46gU/S89zIc2N/Bw/7EVIAXVFA3/3Ip+OrFOuIMO4Py1sCdB8o2Y+5ygv8iXLcsXIq1O0av79i9g774V3uaXa2qN9ZnXe0AEhcy8FHJ2i/wro==5XVB
+twofish.c iQCVAwUAP9iD6TEAnp832S/7AQKUnQP/Rq8FaYeHTG7HbZuqAs9pbPitzjDbkdZddmInWR7NmevBkKvhsJALjVooc0KGQfo2lAAmy3Xi/4QQN8VPn51DVjDIgf7x+DQh/9TFJHMccxI9asUgi4+TNnmMqLU1k3N8S2PjyZ1sjeC8B79fKPpwCzj72WkqPkzZw3l2jArr+dU==NdJT
+rfc2268.c iQCVAwUAQCN+3jEAnp832S/7AQLv1gQA1hJh29hAjKi4uLSGxXvJ6cyYmPdmevdKrbLnuHZWtHe4xvCgy/nTdEojEpxgLp/hL/ogasuWRC1W16Wiz9ryxf7YR0uhZWayO/bQNagpfU5MIkJTLuKqqgpwYumCSQfOugXVAqcgEzj+13eeyJaFVrzwrNa67sh84nmbjOjNjvE==0zBq
+
+# Random number related
+random.c iQCVAwUAP7nsITEAnp832S/7AQK4SAQAtvfUgrtGOQ2PlxGMla0qJLPHjJacMwgq0ecusiI79elPdDsFfCCk6dK1Ug2kFbNm22nCGHNcUquqbX7noi7ZVQnmPBQXzyLNZd7GmrawRZfdlRerTUDBpSnR8V8ui/5+YYp627E7kKGC0hPSgqXFql6oBMIfno0LZwFJTjIevRY==L419
+random.h iQCVAwUAP7ovKDEAnp832S/7AQJ3bQQAjnPebnyTC7sphAv2I7uIz+yPgw1ZfbVhLv+OiWDlO9ish+fRyyMpy+HELBOgZjJdgRegqhlZC6qyns5arM/VglYi+PzvdLO3hIqHE/YFfpIFPz8wBrcmlqrYyd3CsGqcYsfjocXNttCBLeSWmoJ09ltKQH8yzJf3oAgN6X1yuc4==eNoU
+rand-internal.h iQCVAwUAP7ouvDEAnp832S/7AQLYnAQAhdI7ERoJVCkV8GiV7MjaUxv1WIL7iZ+jIOvVhv4fNyhCGCGoEtTjkyput/lj7Nsh3FXEqRhypGGrCLf47x/gua5n+BwffogxVyUDqiOyyGhNTPpe3fQcNBvbPCtco8yMK4GJO5G3BqzlPyN+BMeogLymyV6Sm1mvh5LZDyAFbfQ==tZSE
+rndlinux.c iQCVAwUAP9iPYTEAnp832S/7AQL6/AP/ZDrbOkVuB9qJ7sKeX1MImZEsz3mi0xPovJzaBtBU7a0idcUKrWYOvQFWRlLUeq0iCT6+h2l5bniP7q7hepzlKa+VPY9VWaQthqeJm2l5LN6QQ5PyMfBq04QuBncw9BJnCGmEyTLt3RxIXBAPdxmiVxtcRIFUqCBtQvoUXGLvemw==t37k
+rndegd.c iQCVAwUAP9iPRDEAnp832S/7AQImBQP/WHKg+hKXcm1pQvilzML0jZpwK5PAMM4uBnnPJNIXWOYBO6I/Xg9d/tPLg8NlmmtyQCo2Eu0ybDSt+8mu+dWveAys+0LTi0MIqeP9BMzCKz8dnWH6+S8huLXwTF3m0IrqM0JLb6b71GK9SOq6sWQ22yW5vf61hXP8kH9dhIaoMZs==FaHV
+rndunix.c iQCVAwUAP9iQlzEAnp832S/7AQL/KgQA29GnvcD4Xb5qjDMBgW9THEE4+4lfex/6k+Fh0IT61OLJsWVLJ7bJpRntburw4uQm4Tf7CO8vaiDFDYhKKrzXeOF1fmdpcL8hA+fNp9I/MUOc4e9kN9+YJ9wikVa0SZj1OBfhzgcFLd1xOtulkr3ii52HLF9vhrxzkgVwvD10Bi8==2cML
+rndw32.c iQCVAwUAP9iRKDEAnp832S/7AQIuaAQA3AJr3WqnxNDsWCIdvehf8Suotthj+laX8nJsvDfFhXPKcXDpsg0wTTXSnnKgyED53+uYiMDnVRsxeWAyhKwvx1MjjlaSMMjzbH6isWTH8FaWpLgrxEkXoPeNqYf5FXpdUkcUxGX2RkQeuX/cIfiHLNE9CV0usaF2jysjBX2iERY==EEnO
+
+# Helper
+bithelp.h iQCVAwUAP7ouPTEAnp832S/7AQKXggQAqjcgvihIF3WclOgw1JV2rbARw4ISIDRMFqdaNCqBRx6BwEz3UGsEIlz6+iR1sS/reqN61WvtjLb+D0+tujAkGrgQJhFLG85WtG2tB5UVoI3am1fpkwiRm+bR4rv0rGk0BYk81bC7+l4KrK9o5lVp4lCsrorlUKsd48lNmBHyAXM==mDDN
+rmd.h iQCVAwUAP7oumjEAnp832S/7AQJiJQP/V4bJwjZaYndJzV+KRnIDbl1koHuw+ZK5heMYVu8Qk4ylqv//BGyeRa3jZCcfPHI35q6HilCs2VBm8hiBMjHSqY/VPn2ZQ0yg/lt6qEvl7YjsLmyMICvjG+ncszHoq9pRvnF3vTnM18sPIioXLk8fskuM0XOCNBs0ARBAQjY9UGI==olUN
+
+# Configuration
+Makefile.am iQCVAwUAQCN33TEAnp832S/7AQKFJAQAz7BDkC814q+QiuE/jnutJHR5qlgbrm3ikGbQwdRzYUscst4bCCWy3uKL/sIPGLg+JQXtF5FnsQy3s4D9BOYhp72cA9ktYK65hhi4pNm/JQ0lXkZMNfk8Go5lNzKezlWwHvkMwRXR0Fep0wPdyeaKW5BfaW2ABvgep6Bp+hHEbyg==zSyi
+$names$ iQCVAwUAQCN3EDEAnp832S/7AQJXLAP8DvHTpm5DkTF35EmzeKpi9ie59AZcZanD19ir/e/7+PaQxr2riuLHDGwFKTju+dcvvBsqrygXOC378GXVWzIF2OZwS4EdDcJ+pgojo9UpsqpKsJHouY4Ugx5cQialxba462kUn8hcihSBnMyc4LzbJ5WQ4puQuqy544d2x94+2ms==G4Ls
diff --git a/grub-core/lib/libgcrypt/cipher/ac.c b/grub-core/lib/libgcrypt/cipher/ac.c
new file mode 100644
index 0000000..63f6fcd
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/ac.c
@@ -0,0 +1,3301 @@
+/* ac.c - Alternative interface for asymmetric cryptography.
+ Copyright (C) 2003, 2004, 2005, 2006
+ 2007, 2008 Free Software Foundation, Inc.
+
+ This file is part of Libgcrypt.
+
+ Libgcrypt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser general Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Libgcrypt is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stddef.h>
+
+#include "g10lib.h"
+#include "cipher.h"
+#include "mpi.h"
+
+
+
+/* At the moment the ac interface is a wrapper around the pk
+ interface, but this might change somewhen in the future, depending
+ on how many people prefer the ac interface. */
+
+/* Mapping of flag numbers to the according strings as it is expected
+ for S-expressions. */
+static struct number_string
+{
+ int number;
+ const char *string;
+} ac_flags[] =
+ {
+ { GCRY_AC_FLAG_NO_BLINDING, "no-blinding" },
+ };
+
+/* The positions in this list correspond to the values contained in
+ the gcry_ac_key_type_t enumeration list. */
+static const char *ac_key_identifiers[] =
+ {
+ "private-key",
+ "public-key"
+ };
+
+/* These specifications are needed for key-pair generation; the caller
+ is allowed to pass additional, algorithm-specific `specs' to
+ gcry_ac_key_pair_generate. This list is used for decoding the
+ provided values according to the selected algorithm. */
+struct gcry_ac_key_generate_spec
+{
+ int algorithm; /* Algorithm for which this flag is
+ relevant. */
+ const char *name; /* Name of this flag. */
+ size_t offset; /* Offset in the cipher-specific spec
+ structure at which the MPI value
+ associated with this flag is to be
+ found. */
+} ac_key_generate_specs[] =
+ {
+ { GCRY_AC_RSA, "rsa-use-e", offsetof (gcry_ac_key_spec_rsa_t, e) },
+ { 0 }
+ };
+
+/* Handle structure. */
+struct gcry_ac_handle
+{
+ int algorithm; /* Algorithm ID associated with this
+ handle. */
+ const char *algorithm_name; /* Name of the algorithm. */
+ unsigned int flags; /* Flags, not used yet. */
+ gcry_module_t module; /* Reference to the algorithm
+ module. */
+};
+
+/* A named MPI value. */
+typedef struct gcry_ac_mpi
+{
+ char *name; /* Self-maintained copy of name. */
+ gcry_mpi_t mpi; /* MPI value. */
+ unsigned int flags; /* Flags. */
+} gcry_ac_mpi_t;
+
+/* A data set, that is simply a list of named MPI values. */
+struct gcry_ac_data
+{
+ gcry_ac_mpi_t *data; /* List of named values. */
+ unsigned int data_n; /* Number of values in DATA. */
+};
+
+/* A single key. */
+struct gcry_ac_key
+{
+ gcry_ac_data_t data; /* Data in native ac structure. */
+ gcry_ac_key_type_t type; /* Type of the key. */
+};
+
+/* A key pair. */
+struct gcry_ac_key_pair
+{
+ gcry_ac_key_t public;
+ gcry_ac_key_t secret;
+};
+
+
+
+/*
+ * Functions for working with data sets.
+ */
+
+/* Creates a new, empty data set and store it in DATA. */
+gcry_error_t
+_gcry_ac_data_new (gcry_ac_data_t *data)
+{
+ gcry_ac_data_t data_new;
+ gcry_error_t err;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ data_new = gcry_malloc (sizeof (*data_new));
+ if (! data_new)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ data_new->data = NULL;
+ data_new->data_n = 0;
+ *data = data_new;
+ err = 0;
+
+ out:
+
+ return err;
+}
+
+/* Destroys all the entries in DATA, but not DATA itself. */
+static void
+ac_data_values_destroy (gcry_ac_data_t data)
+{
+ unsigned int i;
+
+ for (i = 0; i < data->data_n; i++)
+ if (data->data[i].flags & GCRY_AC_FLAG_DEALLOC)
+ {
+ gcry_mpi_release (data->data[i].mpi);
+ gcry_free (data->data[i].name);
+ }
+}
+
+/* Destroys the data set DATA. */
+void
+_gcry_ac_data_destroy (gcry_ac_data_t data)
+{
+ if (data)
+ {
+ ac_data_values_destroy (data);
+ gcry_free (data->data);
+ gcry_free (data);
+ }
+}
+
+/* This function creates a copy of the array of named MPIs DATA_MPIS,
+ which is of length DATA_MPIS_N; the copy is stored in
+ DATA_MPIS_CP. */
+static gcry_error_t
+ac_data_mpi_copy (gcry_ac_mpi_t *data_mpis, unsigned int data_mpis_n,
+ gcry_ac_mpi_t **data_mpis_cp)
+{
+ gcry_ac_mpi_t *data_mpis_new;
+ gcry_error_t err;
+ unsigned int i;
+ gcry_mpi_t mpi;
+ char *label;
+
+ data_mpis_new = gcry_calloc (data_mpis_n, sizeof (*data_mpis_new));
+ if (! data_mpis_new)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+ memset (data_mpis_new, 0, sizeof (*data_mpis_new) * data_mpis_n);
+
+ err = 0;
+ for (i = 0; i < data_mpis_n; i++)
+ {
+ /* Copy values. */
+
+ label = gcry_strdup (data_mpis[i].name);
+ mpi = gcry_mpi_copy (data_mpis[i].mpi);
+ if (! (label && mpi))
+ {
+ err = gcry_error_from_errno (errno);
+ gcry_mpi_release (mpi);
+ gcry_free (label);
+ break;
+ }
+
+ data_mpis_new[i].flags = GCRY_AC_FLAG_DEALLOC;
+ data_mpis_new[i].name = label;
+ data_mpis_new[i].mpi = mpi;
+ }
+ if (err)
+ goto out;
+
+ *data_mpis_cp = data_mpis_new;
+ err = 0;
+
+ out:
+
+ if (err)
+ if (data_mpis_new)
+ {
+ for (i = 0; i < data_mpis_n; i++)
+ {
+ gcry_mpi_release (data_mpis_new[i].mpi);
+ gcry_free (data_mpis_new[i].name);
+ }
+ gcry_free (data_mpis_new);
+ }
+
+ return err;
+}
+
+/* Create a copy of the data set DATA and store it in DATA_CP. */
+gcry_error_t
+_gcry_ac_data_copy (gcry_ac_data_t *data_cp, gcry_ac_data_t data)
+{
+ gcry_ac_mpi_t *data_mpis = NULL;
+ gcry_ac_data_t data_new;
+ gcry_error_t err;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ /* Allocate data set. */
+ data_new = gcry_malloc (sizeof (*data_new));
+ if (! data_new)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ err = ac_data_mpi_copy (data->data, data->data_n, &data_mpis);
+ if (err)
+ goto out;
+
+ data_new->data_n = data->data_n;
+ data_new->data = data_mpis;
+ *data_cp = data_new;
+
+ out:
+
+ if (err)
+ gcry_free (data_new);
+
+ return err;
+}
+
+/* Returns the number of named MPI values inside of the data set
+ DATA. */
+unsigned int
+_gcry_ac_data_length (gcry_ac_data_t data)
+{
+ return data->data_n;
+}
+
+
+/* Add the value MPI to DATA with the label NAME. If FLAGS contains
+ GCRY_AC_FLAG_COPY, the data set will contain copies of NAME
+ and MPI. If FLAGS contains GCRY_AC_FLAG_DEALLOC or
+ GCRY_AC_FLAG_COPY, the values contained in the data set will
+ be deallocated when they are to be removed from the data set. */
+gcry_error_t
+_gcry_ac_data_set (gcry_ac_data_t data, unsigned int flags,
+ const char *name, gcry_mpi_t mpi)
+{
+ gcry_error_t err;
+ gcry_mpi_t mpi_cp;
+ char *name_cp;
+ unsigned int i;
+
+ name_cp = NULL;
+ mpi_cp = NULL;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ if (flags & ~(GCRY_AC_FLAG_DEALLOC | GCRY_AC_FLAG_COPY))
+ {
+ err = gcry_error (GPG_ERR_INV_ARG);
+ goto out;
+ }
+
+ if (flags & GCRY_AC_FLAG_COPY)
+ {
+ /* Create copies. */
+
+ flags |= GCRY_AC_FLAG_DEALLOC;
+ name_cp = gcry_strdup (name);
+ mpi_cp = gcry_mpi_copy (mpi);
+ if (! (name_cp && mpi_cp))
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+ }
+
+ /* Search for existing entry. */
+ for (i = 0; i < data->data_n; i++)
+ if (! strcmp (name, data->data[i].name))
+ break;
+ if (i < data->data_n)
+ {
+ /* An entry for NAME does already exist. */
+ if (data->data[i].flags & GCRY_AC_FLAG_DEALLOC)
+ {
+ gcry_mpi_release (data->data[i].mpi);
+ gcry_free (data->data[i].name);
+ }
+ }
+ else
+ {
+ /* Create a new entry. */
+
+ gcry_ac_mpi_t *ac_mpis;
+
+ ac_mpis = gcry_realloc (data->data,
+ sizeof (*data->data) * (data->data_n + 1));
+ if (! ac_mpis)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ if (data->data != ac_mpis)
+ data->data = ac_mpis;
+ data->data_n++;
+ }
+
+ data->data[i].name = name_cp ? name_cp : ((char *) name);
+ data->data[i].mpi = mpi_cp ? mpi_cp : mpi;
+ data->data[i].flags = flags;
+ err = 0;
+
+ out:
+
+ if (err)
+ {
+ gcry_mpi_release (mpi_cp);
+ gcry_free (name_cp);
+ }
+
+ return err;
+}
+
+/* Stores the value labelled with NAME found in the data set DATA in
+ MPI. The returned MPI value will be released in case
+ gcry_ac_data_set is used to associate the label NAME with a
+ different MPI value. */
+gcry_error_t
+_gcry_ac_data_get_name (gcry_ac_data_t data, unsigned int flags,
+ const char *name, gcry_mpi_t *mpi)
+{
+ gcry_mpi_t mpi_return;
+ gcry_error_t err;
+ unsigned int i;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ if (flags & ~(GCRY_AC_FLAG_COPY))
+ {
+ err = gcry_error (GPG_ERR_INV_ARG);
+ goto out;
+ }
+
+ for (i = 0; i < data->data_n; i++)
+ if (! strcmp (name, data->data[i].name))
+ break;
+ if (i == data->data_n)
+ {
+ err = gcry_error (GPG_ERR_NOT_FOUND);
+ goto out;
+ }
+
+ if (flags & GCRY_AC_FLAG_COPY)
+ {
+ mpi_return = gcry_mpi_copy (data->data[i].mpi);
+ if (! mpi_return)
+ {
+ err = gcry_error_from_errno (errno); /* FIXME? */
+ goto out;
+ }
+ }
+ else
+ mpi_return = data->data[i].mpi;
+
+ *mpi = mpi_return;
+ err = 0;
+
+ out:
+
+ return err;
+}
+
+/* Stores in NAME and MPI the named MPI value contained in the data
+ set DATA with the index IDX. NAME or MPI may be NULL. The
+ returned MPI value will be released in case gcry_ac_data_set is
+ used to associate the label NAME with a different MPI value. */
+gcry_error_t
+_gcry_ac_data_get_index (gcry_ac_data_t data, unsigned int flags,
+ unsigned int idx,
+ const char **name, gcry_mpi_t *mpi)
+{
+ gcry_error_t err;
+ gcry_mpi_t mpi_cp;
+ char *name_cp;
+
+ name_cp = NULL;
+ mpi_cp = NULL;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ if (flags & ~(GCRY_AC_FLAG_COPY))
+ {
+ err = gcry_error (GPG_ERR_INV_ARG);
+ goto out;
+ }
+
+ if (idx >= data->data_n)
+ {
+ err = gcry_error (GPG_ERR_INV_ARG);
+ goto out;
+ }
+
+ if (flags & GCRY_AC_FLAG_COPY)
+ {
+ /* Return copies to the user. */
+ if (name)
+ {
+ name_cp = gcry_strdup (data->data[idx].name);
+ if (! name_cp)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+ }
+ if (mpi)
+ {
+ mpi_cp = gcry_mpi_copy (data->data[idx].mpi);
+ if (! mpi_cp)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+ }
+ }
+
+ if (name)
+ *name = name_cp ? name_cp : data->data[idx].name;
+ if (mpi)
+ *mpi = mpi_cp ? mpi_cp : data->data[idx].mpi;
+ err = 0;
+
+ out:
+
+ if (err)
+ {
+ gcry_mpi_release (mpi_cp);
+ gcry_free (name_cp);
+ }
+
+ return err;
+}
+
+/* Convert the data set DATA into a new S-Expression, which is to be
+ stored in SEXP, according to the identifiers contained in
+ IDENTIFIERS. */
+gcry_error_t
+_gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp,
+ const char **identifiers)
+{
+ gcry_sexp_t sexp_new;
+ gcry_error_t err;
+ char *sexp_buffer;
+ size_t sexp_buffer_n;
+ size_t identifiers_n;
+ const char *label;
+ gcry_mpi_t mpi;
+ void **arg_list;
+ size_t data_n;
+ unsigned int i;
+
+ sexp_buffer_n = 1;
+ sexp_buffer = NULL;
+ arg_list = NULL;
+ err = 0;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ /* Calculate size of S-expression representation. */
+
+ i = 0;
+ if (identifiers)
+ while (identifiers[i])
+ {
+ /* For each identifier, we add "(<IDENTIFIER>)". */
+ sexp_buffer_n += 1 + strlen (identifiers[i]) + 1;
+ i++;
+ }
+ identifiers_n = i;
+
+ if (! identifiers_n)
+ /* If there are NO identifiers, we still add surrounding braces so
+ that we have a list of named MPI value lists. Otherwise it
+ wouldn't be too much fun to process these lists. */
+ sexp_buffer_n += 2;
+
+ data_n = _gcry_ac_data_length (data);
+ for (i = 0; i < data_n; i++)
+ {
+ err = gcry_ac_data_get_index (data, 0, i, &label, NULL);
+ if (err)
+ break;
+ /* For each MPI we add "(<LABEL> %m)". */
+ sexp_buffer_n += 1 + strlen (label) + 4;
+ }
+ if (err)
+ goto out;
+
+ /* Allocate buffer. */
+
+ sexp_buffer = gcry_malloc (sexp_buffer_n);
+ if (! sexp_buffer)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ /* Fill buffer. */
+
+ *sexp_buffer = 0;
+ sexp_buffer_n = 0;
+
+ /* Add identifiers: (<IDENTIFIER0>(<IDENTIFIER1>...)). */
+ if (identifiers_n)
+ {
+ /* Add nested identifier lists as usual. */
+ for (i = 0; i < identifiers_n; i++)
+ sexp_buffer_n += sprintf (sexp_buffer + sexp_buffer_n, "(%s",
+ identifiers[i]);
+ }
+ else
+ {
+ /* Add special list. */
+ sexp_buffer_n += sprintf (sexp_buffer + sexp_buffer_n, "(");
+ }
+
+ /* Add MPI list. */
+ arg_list = gcry_calloc (data_n + 1, sizeof (*arg_list));
+ if (! arg_list)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+ for (i = 0; i < data_n; i++)
+ {
+ err = gcry_ac_data_get_index (data, 0, i, &label, &mpi);
+ if (err)
+ break;
+ sexp_buffer_n += sprintf (sexp_buffer + sexp_buffer_n,
+ "(%s %%m)", label);
+ arg_list[i] = &data->data[i].mpi;
+ }
+ if (err)
+ goto out;
+
+ if (identifiers_n)
+ {
+ /* Add closing braces for identifier lists as usual. */
+ for (i = 0; i < identifiers_n; i++)
+ sexp_buffer_n += sprintf (sexp_buffer + sexp_buffer_n, ")");
+ }
+ else
+ {
+ /* Add closing braces for special list. */
+ sexp_buffer_n += sprintf (sexp_buffer + sexp_buffer_n, ")");
+ }
+
+ /* Construct. */
+ err = gcry_sexp_build_array (&sexp_new, NULL, sexp_buffer, arg_list);
+ if (err)
+ goto out;
+
+ *sexp = sexp_new;
+
+ out:
+
+ gcry_free (sexp_buffer);
+ gcry_free (arg_list);
+
+ return err;
+}
+
+/* Create a new data set, which is to be stored in DATA_SET, from the
+ S-Expression SEXP, according to the identifiers contained in
+ IDENTIFIERS. */
+gcry_error_t
+_gcry_ac_data_from_sexp (gcry_ac_data_t *data_set, gcry_sexp_t sexp,
+ const char **identifiers)
+{
+ gcry_ac_data_t data_set_new;
+ gcry_error_t err;
+ gcry_sexp_t sexp_cur;
+ gcry_sexp_t sexp_tmp;
+ gcry_mpi_t mpi;
+ char *string;
+ const char *data;
+ size_t data_n;
+ size_t sexp_n;
+ unsigned int i;
+ int skip_name;
+
+ data_set_new = NULL;
+ sexp_cur = sexp;
+ sexp_tmp = NULL;
+ string = NULL;
+ mpi = NULL;
+ err = 0;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ /* Process S-expression/identifiers. */
+
+ if (identifiers)
+ {
+ for (i = 0; identifiers[i]; i++)
+ {
+ /* Next identifier. Extract first data item from
+ SEXP_CUR. */
+ data = gcry_sexp_nth_data (sexp_cur, 0, &data_n);
+
+ if (! ((data_n == strlen (identifiers[i]))
+ && (! strncmp (data, identifiers[i], data_n))))
+ {
+ /* Identifier mismatch -> error. */
+ err = gcry_error (GPG_ERR_INV_SEXP);
+ break;
+ }
+
+ /* Identifier matches. Now we have to distinguish two
+ cases:
+
+ (i) we are at the last identifier:
+ leave loop
+
+ (ii) we are not at the last identifier:
+ extract next element, which is supposed to be a
+ sublist. */
+
+ if (! identifiers[i + 1])
+ /* Last identifier. */
+ break;
+ else
+ {
+ /* Not the last identifier, extract next sublist. */
+
+ sexp_tmp = gcry_sexp_nth (sexp_cur, 1);
+ if (! sexp_tmp)
+ {
+ /* Missing sublist. */
+ err = gcry_error (GPG_ERR_INV_SEXP);
+ break;
+ }
+
+ /* Release old SEXP_CUR, in case it is not equal to the
+ original SEXP. */
+ if (sexp_cur != sexp)
+ gcry_sexp_release (sexp_cur);
+
+ /* Make SEXP_CUR point to the new current sublist. */
+ sexp_cur = sexp_tmp;
+ sexp_tmp = NULL;
+ }
+ }
+ if (err)
+ goto out;
+
+ if (i)
+ {
+ /* We have at least one identifier in the list, this means
+ the the list of named MPI values is prefixed, this means
+ that we need to skip the first item (the list name), when
+ processing the MPI values. */
+ skip_name = 1;
+ }
+ else
+ {
+ /* Since there is no identifiers list, the list of named MPI
+ values is not prefixed with a list name, therefore the
+ offset to use is zero. */
+ skip_name = 0;
+ }
+ }
+ else
+ /* Since there is no identifiers list, the list of named MPI
+ values is not prefixed with a list name, therefore the offset
+ to use is zero. */
+ skip_name = 0;
+
+ /* Create data set from S-expression data. */
+
+ err = gcry_ac_data_new (&data_set_new);
+ if (err)
+ goto out;
+
+ /* Figure out amount of named MPIs in SEXP_CUR. */
+ if (sexp_cur)
+ sexp_n = gcry_sexp_length (sexp_cur) - skip_name;
+ else
+ sexp_n = 0;
+
+ /* Extracte the named MPIs sequentially. */
+ for (i = 0; i < sexp_n; i++)
+ {
+ /* Store next S-Expression pair, which is supposed to consist of
+ a name and an MPI value, in SEXP_TMP. */
+
+ sexp_tmp = gcry_sexp_nth (sexp_cur, i + skip_name);
+ if (! sexp_tmp)
+ {
+ err = gcry_error (GPG_ERR_INV_SEXP);
+ break;
+ }
+
+ /* Extract name from current S-Expression pair. */
+ data = gcry_sexp_nth_data (sexp_tmp, 0, &data_n);
+ string = gcry_malloc (data_n + 1);
+ if (! string)
+ {
+ err = gcry_error_from_errno (errno);
+ break;
+ }
+ memcpy (string, data, data_n);
+ string[data_n] = 0;
+
+ /* Extract MPI value. */
+ mpi = gcry_sexp_nth_mpi (sexp_tmp, 1, 0);
+ if (! mpi)
+ {
+ err = gcry_error (GPG_ERR_INV_SEXP); /* FIXME? */
+ break;
+ }
+
+ /* Store named MPI in data_set_new. */
+ err = gcry_ac_data_set (data_set_new, GCRY_AC_FLAG_DEALLOC, string, mpi);
+ if (err)
+ break;
+
+/* gcry_free (string); */
+ string = NULL;
+/* gcry_mpi_release (mpi); */
+ mpi = NULL;
+
+ gcry_sexp_release (sexp_tmp);
+ sexp_tmp = NULL;
+ }
+ if (err)
+ goto out;
+
+ *data_set = data_set_new;
+
+ out:
+
+ if (sexp_cur != sexp)
+ gcry_sexp_release (sexp_cur);
+ gcry_sexp_release (sexp_tmp);
+ gcry_mpi_release (mpi);
+ gcry_free (string);
+
+ if (err)
+ gcry_ac_data_destroy (data_set_new);
+
+ return err;
+}
+
+
+static void
+_gcry_ac_data_dump (const char *prefix, gcry_ac_data_t data)
+{
+ unsigned char *mpi_buffer;
+ size_t mpi_buffer_n;
+ unsigned int data_n;
+ gcry_error_t err;
+ const char *name;
+ gcry_mpi_t mpi;
+ unsigned int i;
+
+ if (! data)
+ return;
+
+ if (fips_mode ())
+ return;
+
+ mpi_buffer = NULL;
+
+ data_n = _gcry_ac_data_length (data);
+ for (i = 0; i < data_n; i++)
+ {
+ err = gcry_ac_data_get_index (data, 0, i, &name, &mpi);
+ if (err)
+ {
+ log_error ("failed to dump data set");
+ break;
+ }
+
+ err = gcry_mpi_aprint (GCRYMPI_FMT_HEX, &mpi_buffer, &mpi_buffer_n, mpi);
+ if (err)
+ {
+ log_error ("failed to dump data set");
+ break;
+ }
+
+ log_printf ("%s%s%s: %s\n",
+ prefix ? prefix : "",
+ prefix ? ": " : ""
+ , name, mpi_buffer);
+
+ gcry_free (mpi_buffer);
+ mpi_buffer = NULL;
+ }
+
+ gcry_free (mpi_buffer);
+}
+
+/* Dump the named MPI values contained in the data set DATA to
+ Libgcrypt's logging stream. */
+void
+gcry_ac_data_dump (const char *prefix, gcry_ac_data_t data)
+{
+ _gcry_ac_data_dump (prefix, data);
+}
+
+/* Destroys any values contained in the data set DATA. */
+void
+_gcry_ac_data_clear (gcry_ac_data_t data)
+{
+ ac_data_values_destroy (data);
+ gcry_free (data->data);
+ data->data = NULL;
+ data->data_n = 0;
+}
+
+
+
+/*
+ * Implementation of `ac io' objects.
+ */
+
+/* Initialize AC_IO according to MODE, TYPE and the variable list of
+ arguments AP. The list of variable arguments to specify depends on
+ the given TYPE. */
+void
+_gcry_ac_io_init_va (gcry_ac_io_t *ac_io,
+ gcry_ac_io_mode_t mode, gcry_ac_io_type_t type, va_list ap)
+{
+ memset (ac_io, 0, sizeof (*ac_io));
+
+ if (fips_mode ())
+ return;
+
+ gcry_assert ((mode == GCRY_AC_IO_READABLE) || (mode == GCRY_AC_IO_WRITABLE));
+ gcry_assert ((type == GCRY_AC_IO_STRING) || (type == GCRY_AC_IO_STRING));
+
+ ac_io->mode = mode;
+ ac_io->type = type;
+
+ switch (mode)
+ {
+ case GCRY_AC_IO_READABLE:
+ switch (type)
+ {
+ case GCRY_AC_IO_STRING:
+ ac_io->io.readable.string.data = va_arg (ap, unsigned char *);
+ ac_io->io.readable.string.data_n = va_arg (ap, size_t);
+ break;
+
+ case GCRY_AC_IO_CALLBACK:
+ ac_io->io.readable.callback.cb = va_arg (ap, gcry_ac_data_read_cb_t);
+ ac_io->io.readable.callback.opaque = va_arg (ap, void *);
+ break;
+ }
+ break;
+ case GCRY_AC_IO_WRITABLE:
+ switch (type)
+ {
+ case GCRY_AC_IO_STRING:
+ ac_io->io.writable.string.data = va_arg (ap, unsigned char **);
+ ac_io->io.writable.string.data_n = va_arg (ap, size_t *);
+ break;
+
+ case GCRY_AC_IO_CALLBACK:
+ ac_io->io.writable.callback.cb = va_arg (ap, gcry_ac_data_write_cb_t);
+ ac_io->io.writable.callback.opaque = va_arg (ap, void *);
+ break;
+ }
+ break;
+ }
+}
+
+/* Initialize AC_IO according to MODE, TYPE and the variable list of
+ arguments. The list of variable arguments to specify depends on
+ the given TYPE. */
+void
+_gcry_ac_io_init (gcry_ac_io_t *ac_io,
+ gcry_ac_io_mode_t mode, gcry_ac_io_type_t type, ...)
+{
+ va_list ap;
+
+ va_start (ap, type);
+ _gcry_ac_io_init_va (ac_io, mode, type, ap);
+ va_end (ap);
+}
+
+
+/* Write to the IO object AC_IO BUFFER_N bytes from BUFFER. Return
+ zero on success or error code. */
+static gcry_error_t
+_gcry_ac_io_write (gcry_ac_io_t *ac_io, unsigned char *buffer, size_t buffer_n)
+{
+ gcry_error_t err;
+
+ gcry_assert (ac_io->mode == GCRY_AC_IO_WRITABLE);
+ err = 0;
+
+ switch (ac_io->type)
+ {
+ case GCRY_AC_IO_STRING:
+ {
+ unsigned char *p;
+
+ if (*ac_io->io.writable.string.data)
+ {
+ p = gcry_realloc (*ac_io->io.writable.string.data,
+ *ac_io->io.writable.string.data_n + buffer_n);
+ if (! p)
+ err = gcry_error_from_errno (errno);
+ else
+ {
+ if (*ac_io->io.writable.string.data != p)
+ *ac_io->io.writable.string.data = p;
+ memcpy (p + *ac_io->io.writable.string.data_n, buffer, buffer_n);
+ *ac_io->io.writable.string.data_n += buffer_n;
+ }
+ }
+ else
+ {
+ if (gcry_is_secure (buffer))
+ p = gcry_malloc_secure (buffer_n);
+ else
+ p = gcry_malloc (buffer_n);
+ if (! p)
+ err = gcry_error_from_errno (errno);
+ else
+ {
+ memcpy (p, buffer, buffer_n);
+ *ac_io->io.writable.string.data = p;
+ *ac_io->io.writable.string.data_n = buffer_n;
+ }
+ }
+ }
+ break;
+
+ case GCRY_AC_IO_CALLBACK:
+ err = (*ac_io->io.writable.callback.cb) (ac_io->io.writable.callback.opaque,
+ buffer, buffer_n);
+ break;
+ }
+
+ return err;
+}
+
+/* Read *BUFFER_N bytes from the IO object AC_IO into BUFFER; NREAD
+ bytes have already been read from the object; on success, store the
+ amount of bytes read in *BUFFER_N; zero bytes read means EOF.
+ Return zero on success or error code. */
+static gcry_error_t
+_gcry_ac_io_read (gcry_ac_io_t *ac_io,
+ unsigned int nread, unsigned char *buffer, size_t *buffer_n)
+{
+ gcry_error_t err;
+
+ gcry_assert (ac_io->mode == GCRY_AC_IO_READABLE);
+ err = 0;
+
+ switch (ac_io->type)
+ {
+ case GCRY_AC_IO_STRING:
+ {
+ size_t bytes_available;
+ size_t bytes_to_read;
+ size_t bytes_wanted;
+
+ bytes_available = ac_io->io.readable.string.data_n - nread;
+ bytes_wanted = *buffer_n;
+
+ if (bytes_wanted > bytes_available)
+ bytes_to_read = bytes_available;
+ else
+ bytes_to_read = bytes_wanted;
+
+ memcpy (buffer, ac_io->io.readable.string.data + nread, bytes_to_read);
+ *buffer_n = bytes_to_read;
+ err = 0;
+ break;
+ }
+
+ case GCRY_AC_IO_CALLBACK:
+ err = (*ac_io->io.readable.callback.cb)
+ (ac_io->io.readable.callback.opaque, buffer, buffer_n);
+ break;
+ }
+
+ return err;
+}
+
+/* Read all data available from the IO object AC_IO into newly
+ allocated memory, storing an appropriate pointer in *BUFFER and the
+ amount of bytes read in *BUFFER_N. Return zero on success or error
+ code. */
+static gcry_error_t
+_gcry_ac_io_read_all (gcry_ac_io_t *ac_io, unsigned char **buffer, size_t *buffer_n)
+{
+ unsigned char *buffer_new;
+ size_t buffer_new_n;
+ unsigned char buf[BUFSIZ];
+ size_t buf_n;
+ unsigned char *p;
+ gcry_error_t err;
+
+ buffer_new = NULL;
+ buffer_new_n = 0;
+
+ while (1)
+ {
+ buf_n = sizeof (buf);
+ err = _gcry_ac_io_read (ac_io, buffer_new_n, buf, &buf_n);
+ if (err)
+ break;
+
+ if (buf_n)
+ {
+ p = gcry_realloc (buffer_new, buffer_new_n + buf_n);
+ if (! p)
+ {
+ err = gcry_error_from_errno (errno);
+ break;
+ }
+
+ if (buffer_new != p)
+ buffer_new = p;
+
+ memcpy (buffer_new + buffer_new_n, buf, buf_n);
+ buffer_new_n += buf_n;
+ }
+ else
+ break;
+ }
+ if (err)
+ goto out;
+
+ *buffer_n = buffer_new_n;
+ *buffer = buffer_new;
+
+ out:
+
+ if (err)
+ gcry_free (buffer_new);
+
+ return err;
+}
+
+/* Read data chunks from the IO object AC_IO until EOF, feeding them
+ to the callback function CB. Return zero on success or error
+ code. */
+static gcry_error_t
+_gcry_ac_io_process (gcry_ac_io_t *ac_io,
+ gcry_ac_data_write_cb_t cb, void *opaque)
+{
+ unsigned char buffer[BUFSIZ];
+ unsigned int nread;
+ size_t buffer_n;
+ gcry_error_t err;
+
+ nread = 0;
+
+ while (1)
+ {
+ buffer_n = sizeof (buffer);
+ err = _gcry_ac_io_read (ac_io, nread, buffer, &buffer_n);
+ if (err)
+ break;
+ if (buffer_n)
+ {
+ err = (*cb) (opaque, buffer, buffer_n);
+ if (err)
+ break;
+ nread += buffer_n;
+ }
+ else
+ break;
+ }
+
+ return err;
+}
+
+
+
+/*
+ * Functions for converting data between the native ac and the
+ * S-expression structure used by the pk interface.
+ */
+
+/* Extract the S-Expression DATA_SEXP into DATA under the control of
+ TYPE and NAME. This function assumes that S-Expressions are of the
+ following structure:
+
+ (IDENTIFIER [...]
+ (ALGORITHM <list of named MPI values>)) */
+static gcry_error_t
+ac_data_extract (const char *identifier, const char *algorithm,
+ gcry_sexp_t sexp, gcry_ac_data_t *data)
+{
+ gcry_error_t err;
+ gcry_sexp_t value_sexp;
+ gcry_sexp_t data_sexp;
+ size_t data_sexp_n;
+ gcry_mpi_t value_mpi;
+ char *value_name;
+ const char *data_raw;
+ size_t data_raw_n;
+ gcry_ac_data_t data_new;
+ unsigned int i;
+
+ value_sexp = NULL;
+ data_sexp = NULL;
+ value_name = NULL;
+ value_mpi = NULL;
+ data_new = NULL;
+
+ /* Verify that the S-expression contains the correct identifier. */
+ data_raw = gcry_sexp_nth_data (sexp, 0, &data_raw_n);
+ if ((! data_raw) || strncmp (identifier, data_raw, data_raw_n))
+ {
+ err = gcry_error (GPG_ERR_INV_SEXP);
+ goto out;
+ }
+
+ /* Extract inner S-expression. */
+ data_sexp = gcry_sexp_find_token (sexp, algorithm, 0);
+ if (! data_sexp)
+ {
+ err = gcry_error (GPG_ERR_INV_SEXP);
+ goto out;
+ }
+
+ /* Count data elements. */
+ data_sexp_n = gcry_sexp_length (data_sexp);
+ data_sexp_n--;
+
+ /* Allocate new data set. */
+ err = _gcry_ac_data_new (&data_new);
+ if (err)
+ goto out;
+
+ /* Iterate through list of data elements and add them to the data
+ set. */
+ for (i = 0; i < data_sexp_n; i++)
+ {
+ /* Get the S-expression of the named MPI, that contains the name
+ and the MPI value. */
+ value_sexp = gcry_sexp_nth (data_sexp, i + 1);
+ if (! value_sexp)
+ {
+ err = gcry_error (GPG_ERR_INV_SEXP);
+ break;
+ }
+
+ /* Extract the name. */
+ data_raw = gcry_sexp_nth_data (value_sexp, 0, &data_raw_n);
+ if (! data_raw)
+ {
+ err = gcry_error (GPG_ERR_INV_SEXP);
+ break;
+ }
+
+ /* Extract the MPI value. */
+ value_mpi = gcry_sexp_nth_mpi (value_sexp, 1, GCRYMPI_FMT_USG);
+ if (! value_mpi)
+ {
+ err = gcry_error (GPG_ERR_INTERNAL); /* FIXME? */
+ break;
+ }
+
+ /* Duplicate the name. */
+ value_name = gcry_malloc (data_raw_n + 1);
+ if (! value_name)
+ {
+ err = gcry_error_from_errno (errno);
+ break;
+ }
+ strncpy (value_name, data_raw, data_raw_n);
+ value_name[data_raw_n] = 0;
+
+ err = _gcry_ac_data_set (data_new, GCRY_AC_FLAG_DEALLOC, value_name, value_mpi);
+ if (err)
+ break;
+
+ gcry_sexp_release (value_sexp);
+ value_sexp = NULL;
+ value_name = NULL;
+ value_mpi = NULL;
+ }
+ if (err)
+ goto out;
+
+ /* Copy out. */
+ *data = data_new;
+
+ out:
+
+ /* Deallocate resources. */
+ if (err)
+ {
+ _gcry_ac_data_destroy (data_new);
+ gcry_mpi_release (value_mpi);
+ gcry_free (value_name);
+ gcry_sexp_release (value_sexp);
+ }
+ gcry_sexp_release (data_sexp);
+
+ return err;
+}
+
+/* Construct an S-expression from the DATA and store it in
+ DATA_SEXP. The S-expression will be of the following structure:
+
+ (IDENTIFIER [(flags [...])]
+ (ALGORITHM <list of named MPI values>)) */
+static gcry_error_t
+ac_data_construct (const char *identifier, int include_flags,
+ unsigned int flags, const char *algorithm,
+ gcry_ac_data_t data, gcry_sexp_t *sexp)
+{
+ unsigned int data_length;
+ gcry_sexp_t sexp_new;
+ gcry_error_t err;
+ size_t sexp_format_n;
+ char *sexp_format;
+ void **arg_list;
+ unsigned int i;
+
+ arg_list = NULL;
+ sexp_new = NULL;
+ sexp_format = NULL;
+
+ /* We build a list of arguments to pass to
+ gcry_sexp_build_array(). */
+ data_length = _gcry_ac_data_length (data);
+ arg_list = gcry_calloc (data_length, sizeof (*arg_list) * 2);
+ if (! arg_list)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ /* Fill list with MPIs. */
+ for (i = 0; i < data_length; i++)
+ {
+ char **nameaddr = &data->data[i].name;
+
+ arg_list[(i * 2) + 0] = nameaddr;
+ arg_list[(i * 2) + 1] = &data->data[i].mpi;
+ }
+
+ /* Calculate size of format string. */
+ sexp_format_n = (3
+ + (include_flags ? 7 : 0)
+ + (algorithm ? (2 + strlen (algorithm)) : 0)
+ + strlen (identifier));
+
+ for (i = 0; i < data_length; i++)
+ /* Per-element sizes. */
+ sexp_format_n += 6;
+
+ if (include_flags)
+ /* Add flags. */
+ for (i = 0; i < DIM (ac_flags); i++)
+ if (flags & ac_flags[i].number)
+ sexp_format_n += strlen (ac_flags[i].string) + 1;
+
+ /* Done. */
+ sexp_format = gcry_malloc (sexp_format_n);
+ if (! sexp_format)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ /* Construct the format string. */
+
+ *sexp_format = 0;
+ strcat (sexp_format, "(");
+ strcat (sexp_format, identifier);
+ if (include_flags)
+ {
+ strcat (sexp_format, "(flags");
+ for (i = 0; i < DIM (ac_flags); i++)
+ if (flags & ac_flags[i].number)
+ {
+ strcat (sexp_format, " ");
+ strcat (sexp_format, ac_flags[i].string);
+ }
+ strcat (sexp_format, ")");
+ }
+ if (algorithm)
+ {
+ strcat (sexp_format, "(");
+ strcat (sexp_format, algorithm);
+ }
+ for (i = 0; i < data_length; i++)
+ strcat (sexp_format, "(%s%m)");
+ if (algorithm)
+ strcat (sexp_format, ")");
+ strcat (sexp_format, ")");
+
+ /* Create final S-expression. */
+ err = gcry_sexp_build_array (&sexp_new, NULL, sexp_format, arg_list);
+ if (err)
+ goto out;
+
+ *sexp = sexp_new;
+
+ out:
+
+ /* Deallocate resources. */
+ gcry_free (sexp_format);
+ gcry_free (arg_list);
+ if (err)
+ gcry_sexp_release (sexp_new);
+
+ return err;
+}
+
+
+
+/*
+ * Handle management.
+ */
+
+/* Creates a new handle for the algorithm ALGORITHM and stores it in
+ HANDLE. FLAGS is not used yet. */
+gcry_error_t
+_gcry_ac_open (gcry_ac_handle_t *handle,
+ gcry_ac_id_t algorithm, unsigned int flags)
+{
+ gcry_ac_handle_t handle_new;
+ const char *algorithm_name;
+ gcry_module_t module;
+ gcry_error_t err;
+
+ *handle = NULL;
+ module = NULL;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ /* Get name. */
+ algorithm_name = _gcry_pk_aliased_algo_name (algorithm);
+ if (! algorithm_name)
+ {
+ err = gcry_error (GPG_ERR_PUBKEY_ALGO);
+ goto out;
+ }
+
+ /* Acquire reference to the pubkey module. */
+ err = _gcry_pk_module_lookup (algorithm, &module);
+ if (err)
+ goto out;
+
+ /* Allocate. */
+ handle_new = gcry_malloc (sizeof (*handle_new));
+ if (! handle_new)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ /* Done. */
+ handle_new->algorithm = algorithm;
+ handle_new->algorithm_name = algorithm_name;
+ handle_new->flags = flags;
+ handle_new->module = module;
+ *handle = handle_new;
+
+ out:
+
+ /* Deallocate resources. */
+ if (err)
+ _gcry_pk_module_release (module);
+
+ return err;
+}
+
+
+/* Destroys the handle HANDLE. */
+void
+_gcry_ac_close (gcry_ac_handle_t handle)
+{
+ /* Release reference to pubkey module. */
+ if (handle)
+ {
+ _gcry_pk_module_release (handle->module);
+ gcry_free (handle);
+ }
+}
+
+
+
+/*
+ * Key management.
+ */
+
+/* Initialize a key from a given data set. */
+/* FIXME/Damn: the argument HANDLE is not only unnecessary, it is
+ completely WRONG here. */
+gcry_error_t
+_gcry_ac_key_init (gcry_ac_key_t *key, gcry_ac_handle_t handle,
+ gcry_ac_key_type_t type, gcry_ac_data_t data)
+{
+ gcry_ac_data_t data_new;
+ gcry_ac_key_t key_new;
+ gcry_error_t err;
+
+ (void)handle;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ /* Allocate. */
+ key_new = gcry_malloc (sizeof (*key_new));
+ if (! key_new)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ /* Copy data set. */
+ err = _gcry_ac_data_copy (&data_new, data);
+ if (err)
+ goto out;
+
+ /* Done. */
+ key_new->data = data_new;
+ key_new->type = type;
+ *key = key_new;
+
+ out:
+
+ if (err)
+ /* Deallocate resources. */
+ gcry_free (key_new);
+
+ return err;
+}
+
+
+/* Generates a new key pair via the handle HANDLE of NBITS bits and
+ stores it in KEY_PAIR. In case non-standard settings are wanted, a
+ pointer to a structure of type gcry_ac_key_spec_<algorithm>_t,
+ matching the selected algorithm, can be given as KEY_SPEC.
+ MISC_DATA is not used yet. */
+gcry_error_t
+_gcry_ac_key_pair_generate (gcry_ac_handle_t handle, unsigned int nbits,
+ void *key_spec,
+ gcry_ac_key_pair_t *key_pair,
+ gcry_mpi_t **misc_data)
+{
+ gcry_sexp_t genkey_sexp_request;
+ gcry_sexp_t genkey_sexp_reply;
+ gcry_ac_data_t key_data_secret;
+ gcry_ac_data_t key_data_public;
+ gcry_ac_key_pair_t key_pair_new;
+ gcry_ac_key_t key_secret;
+ gcry_ac_key_t key_public;
+ gcry_sexp_t key_sexp;
+ gcry_error_t err;
+ char *genkey_format;
+ size_t genkey_format_n;
+ void **arg_list;
+ size_t arg_list_n;
+ unsigned int i;
+ unsigned int j;
+
+ (void)misc_data;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ key_data_secret = NULL;
+ key_data_public = NULL;
+ key_secret = NULL;
+ key_public = NULL;
+ genkey_format = NULL;
+ arg_list = NULL;
+ genkey_sexp_request = NULL;
+ genkey_sexp_reply = NULL;
+ key_sexp = NULL;
+
+ /* Allocate key pair. */
+ key_pair_new = gcry_malloc (sizeof (struct gcry_ac_key_pair));
+ if (! key_pair_new)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ /* Allocate keys. */
+ key_secret = gcry_malloc (sizeof (*key_secret));
+ if (! key_secret)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+ key_public = gcry_malloc (sizeof (*key_public));
+ if (! key_public)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ /* Calculate size of the format string, that is used for creating
+ the request S-expression. */
+ genkey_format_n = 22;
+
+ /* Respect any relevant algorithm specific commands. */
+ if (key_spec)
+ for (i = 0; i < DIM (ac_key_generate_specs); i++)
+ if (handle->algorithm == ac_key_generate_specs[i].algorithm)
+ genkey_format_n += 6;
+
+ /* Create format string. */
+ genkey_format = gcry_malloc (genkey_format_n);
+ if (! genkey_format)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ /* Fill format string. */
+ *genkey_format = 0;
+ strcat (genkey_format, "(genkey(%s(nbits%d)");
+ if (key_spec)
+ for (i = 0; i < DIM (ac_key_generate_specs); i++)
+ if (handle->algorithm == ac_key_generate_specs[i].algorithm)
+ strcat (genkey_format, "(%s%m)");
+ strcat (genkey_format, "))");
+
+ /* Build list of argument pointers, the algorithm name and the nbits
+ are always needed. */
+ arg_list_n = 2;
+
+ /* Now the algorithm specific arguments. */
+ if (key_spec)
+ for (i = 0; i < DIM (ac_key_generate_specs); i++)
+ if (handle->algorithm == ac_key_generate_specs[i].algorithm)
+ arg_list_n += 2;
+
+ /* Allocate list. */
+ arg_list = gcry_calloc (arg_list_n, sizeof (*arg_list));
+ if (! arg_list)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ arg_list[0] = (void *) &handle->algorithm_name;
+ arg_list[1] = (void *) &nbits;
+ if (key_spec)
+ for (j = 2, i = 0; i < DIM (ac_key_generate_specs); i++)
+ if (handle->algorithm == ac_key_generate_specs[i].algorithm)
+ {
+ /* Add name of this specification flag and the
+ according member of the spec strucuture. */
+ arg_list[j++] = (void *)(&ac_key_generate_specs[i].name);
+ arg_list[j++] = (void *)
+ (((char *) key_spec)
+ + ac_key_generate_specs[i].offset);
+ /* FIXME: above seems to suck. */
+ }
+
+ /* Construct final request S-expression. */
+ err = gcry_sexp_build_array (&genkey_sexp_request,
+ NULL, genkey_format, arg_list);
+ if (err)
+ goto out;
+
+ /* Perform genkey operation. */
+ err = gcry_pk_genkey (&genkey_sexp_reply, genkey_sexp_request);
+ if (err)
+ goto out;
+
+ key_sexp = gcry_sexp_find_token (genkey_sexp_reply, "private-key", 0);
+ if (! key_sexp)
+ {
+ err = gcry_error (GPG_ERR_INTERNAL);
+ goto out;
+ }
+ err = ac_data_extract ("private-key", handle->algorithm_name,
+ key_sexp, &key_data_secret);
+ if (err)
+ goto out;
+
+ gcry_sexp_release (key_sexp);
+ key_sexp = gcry_sexp_find_token (genkey_sexp_reply, "public-key", 0);
+ if (! key_sexp)
+ {
+ err = gcry_error (GPG_ERR_INTERNAL);
+ goto out;
+ }
+ err = ac_data_extract ("public-key", handle->algorithm_name,
+ key_sexp, &key_data_public);
+ if (err)
+ goto out;
+
+ /* Done. */
+
+ key_secret->type = GCRY_AC_KEY_SECRET;
+ key_secret->data = key_data_secret;
+ key_public->type = GCRY_AC_KEY_PUBLIC;
+ key_public->data = key_data_public;
+ key_pair_new->secret = key_secret;
+ key_pair_new->public = key_public;
+ *key_pair = key_pair_new;
+
+ out:
+
+ /* Deallocate resources. */
+
+ gcry_free (genkey_format);
+ gcry_free (arg_list);
+ gcry_sexp_release (genkey_sexp_request);
+ gcry_sexp_release (genkey_sexp_reply);
+ gcry_sexp_release (key_sexp);
+ if (err)
+ {
+ _gcry_ac_data_destroy (key_data_secret);
+ _gcry_ac_data_destroy (key_data_public);
+ gcry_free (key_secret);
+ gcry_free (key_public);
+ gcry_free (key_pair_new);
+ }
+
+ return err;
+}
+
+/* Returns the key of type WHICH out of the key pair KEY_PAIR. */
+gcry_ac_key_t
+_gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair,
+ gcry_ac_key_type_t which)
+{
+ gcry_ac_key_t key;
+
+ if (fips_mode ())
+ return NULL;
+
+ switch (which)
+ {
+ case GCRY_AC_KEY_SECRET:
+ key = key_pair->secret;
+ break;
+
+ case GCRY_AC_KEY_PUBLIC:
+ key = key_pair->public;
+ break;
+
+ default:
+ key = NULL;
+ break;
+ }
+
+ return key;
+}
+
+/* Destroys the key KEY. */
+void
+_gcry_ac_key_destroy (gcry_ac_key_t key)
+{
+ unsigned int i;
+
+ if (key)
+ {
+ if (key->data)
+ {
+ for (i = 0; i < key->data->data_n; i++)
+ {
+ if (key->data->data[i].mpi)
+ gcry_mpi_release (key->data->data[i].mpi);
+ if (key->data->data[i].name)
+ gcry_free (key->data->data[i].name);
+ }
+ gcry_free (key->data->data);
+ gcry_free (key->data);
+ }
+ gcry_free (key);
+ }
+}
+
+/* Destroys the key pair KEY_PAIR. */
+void
+_gcry_ac_key_pair_destroy (gcry_ac_key_pair_t key_pair)
+{
+ if (key_pair)
+ {
+ gcry_ac_key_destroy (key_pair->secret);
+ gcry_ac_key_destroy (key_pair->public);
+ gcry_free (key_pair);
+ }
+}
+
+/* Returns the data set contained in the key KEY. */
+gcry_ac_data_t
+_gcry_ac_key_data_get (gcry_ac_key_t key)
+{
+ if (fips_mode ())
+ return NULL;
+ return key->data;
+}
+
+/* Verifies that the key KEY is sane via HANDLE. */
+gcry_error_t
+_gcry_ac_key_test (gcry_ac_handle_t handle, gcry_ac_key_t key)
+{
+ gcry_sexp_t key_sexp;
+ gcry_error_t err;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ key_sexp = NULL;
+ err = ac_data_construct (ac_key_identifiers[key->type], 0, 0,
+ handle->algorithm_name, key->data, &key_sexp);
+ if (err)
+ goto out;
+
+ err = gcry_pk_testkey (key_sexp);
+
+ out:
+
+ gcry_sexp_release (key_sexp);
+
+ return gcry_error (err);
+}
+
+/* Stores the number of bits of the key KEY in NBITS via HANDLE. */
+gcry_error_t
+_gcry_ac_key_get_nbits (gcry_ac_handle_t handle,
+ gcry_ac_key_t key, unsigned int *nbits)
+{
+ gcry_sexp_t key_sexp;
+ gcry_error_t err;
+ unsigned int n;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ key_sexp = NULL;
+
+ err = ac_data_construct (ac_key_identifiers[key->type],
+ 0, 0, handle->algorithm_name, key->data, &key_sexp);
+ if (err)
+ goto out;
+
+ n = gcry_pk_get_nbits (key_sexp);
+ if (! n)
+ {
+ err = gcry_error (GPG_ERR_PUBKEY_ALGO);
+ goto out;
+ }
+
+ *nbits = n;
+
+ out:
+
+ gcry_sexp_release (key_sexp);
+
+ return err;
+}
+
+/* Writes the 20 byte long key grip of the key KEY to KEY_GRIP via
+ HANDLE. */
+gcry_error_t
+_gcry_ac_key_get_grip (gcry_ac_handle_t handle,
+ gcry_ac_key_t key, unsigned char *key_grip)
+{
+ gcry_sexp_t key_sexp;
+ gcry_error_t err;
+ unsigned char *ret;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ key_sexp = NULL;
+ err = ac_data_construct (ac_key_identifiers[key->type], 0, 0,
+ handle->algorithm_name, key->data, &key_sexp);
+ if (err)
+ goto out;
+
+ ret = gcry_pk_get_keygrip (key_sexp, key_grip);
+ if (! ret)
+ {
+ err = gcry_error (GPG_ERR_INV_OBJ);
+ goto out;
+ }
+
+ err = 0;
+
+ out:
+
+ gcry_sexp_release (key_sexp);
+
+ return err;
+}
+
+
+
+
+/*
+ * Functions performing cryptographic operations.
+ */
+
+/* Encrypts the plain text MPI value DATA_PLAIN with the key public
+ KEY under the control of the flags FLAGS and stores the resulting
+ data set into DATA_ENCRYPTED. */
+gcry_error_t
+_gcry_ac_data_encrypt (gcry_ac_handle_t handle,
+ unsigned int flags,
+ gcry_ac_key_t key,
+ gcry_mpi_t data_plain,
+ gcry_ac_data_t *data_encrypted)
+{
+ gcry_ac_data_t data_encrypted_new;
+ gcry_ac_data_t data_value;
+ gcry_sexp_t sexp_request;
+ gcry_sexp_t sexp_reply;
+ gcry_sexp_t sexp_key;
+ gcry_error_t err;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ data_encrypted_new = NULL;
+ sexp_request = NULL;
+ sexp_reply = NULL;
+ data_value = NULL;
+ sexp_key = NULL;
+
+ if (key->type != GCRY_AC_KEY_PUBLIC)
+ {
+ err = gcry_error (GPG_ERR_WRONG_KEY_USAGE);
+ goto out;
+ }
+
+ err = ac_data_construct (ac_key_identifiers[key->type], 0, 0,
+ handle->algorithm_name, key->data, &sexp_key);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_data_new (&data_value);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_data_set (data_value, 0, "value", data_plain);
+ if (err)
+ goto out;
+
+ err = ac_data_construct ("data", 1, flags, handle->algorithm_name,
+ data_value, &sexp_request);
+ if (err)
+ goto out;
+
+ /* FIXME: error vs. errcode? */
+
+ err = gcry_pk_encrypt (&sexp_reply, sexp_request, sexp_key);
+ if (err)
+ goto out;
+
+ /* Extract data. */
+ err = ac_data_extract ("enc-val", handle->algorithm_name,
+ sexp_reply, &data_encrypted_new);
+ if (err)
+ goto out;
+
+ *data_encrypted = data_encrypted_new;
+
+ out:
+
+ /* Deallocate resources. */
+
+ gcry_sexp_release (sexp_request);
+ gcry_sexp_release (sexp_reply);
+ gcry_sexp_release (sexp_key);
+ _gcry_ac_data_destroy (data_value);
+
+ return err;
+}
+
+/* Decrypts the encrypted data contained in the data set
+ DATA_ENCRYPTED with the secret key KEY under the control of the
+ flags FLAGS and stores the resulting plain text MPI value in
+ DATA_PLAIN. */
+gcry_error_t
+_gcry_ac_data_decrypt (gcry_ac_handle_t handle,
+ unsigned int flags,
+ gcry_ac_key_t key,
+ gcry_mpi_t *data_plain,
+ gcry_ac_data_t data_encrypted)
+{
+ gcry_mpi_t data_decrypted;
+ gcry_sexp_t sexp_request;
+ gcry_sexp_t sexp_reply;
+ gcry_sexp_t sexp_value;
+ gcry_sexp_t sexp_key;
+ gcry_error_t err;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ sexp_request = NULL;
+ sexp_reply = NULL;
+ sexp_value = NULL;
+ sexp_key = NULL;
+
+ if (key->type != GCRY_AC_KEY_SECRET)
+ {
+ err = gcry_error (GPG_ERR_WRONG_KEY_USAGE);
+ goto out;
+ }
+
+ err = ac_data_construct (ac_key_identifiers[key->type], 0, 0,
+ handle->algorithm_name, key->data, &sexp_key);
+ if (err)
+ goto out;
+
+ /* Create S-expression from data. */
+ err = ac_data_construct ("enc-val", 1, flags, handle->algorithm_name,
+ data_encrypted, &sexp_request);
+ if (err)
+ goto out;
+
+ /* Decrypt. */
+ err = gcry_pk_decrypt (&sexp_reply, sexp_request, sexp_key);
+ if (err)
+ goto out;
+
+ /* Extract plain text. */
+ sexp_value = gcry_sexp_find_token (sexp_reply, "value", 0);
+ if (! sexp_value)
+ {
+ /* FIXME? */
+ err = gcry_error (GPG_ERR_GENERAL);
+ goto out;
+ }
+
+ data_decrypted = gcry_sexp_nth_mpi (sexp_value, 1, GCRYMPI_FMT_USG);
+ if (! data_decrypted)
+ {
+ err = gcry_error (GPG_ERR_GENERAL);
+ goto out;
+ }
+
+ *data_plain = data_decrypted;
+
+ out:
+
+ /* Deallocate resources. */
+ gcry_sexp_release (sexp_request);
+ gcry_sexp_release (sexp_reply);
+ gcry_sexp_release (sexp_value);
+ gcry_sexp_release (sexp_key);
+
+ return gcry_error (err);
+
+}
+
+/* Signs the data contained in DATA with the secret key KEY and stores
+ the resulting signature data set in DATA_SIGNATURE. */
+gcry_error_t
+_gcry_ac_data_sign (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ gcry_mpi_t data,
+ gcry_ac_data_t *data_signature)
+{
+ gcry_ac_data_t data_signed;
+ gcry_ac_data_t data_value;
+ gcry_sexp_t sexp_request;
+ gcry_sexp_t sexp_reply;
+ gcry_sexp_t sexp_key;
+ gcry_error_t err;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ data_signed = NULL;
+ data_value = NULL;
+ sexp_request = NULL;
+ sexp_reply = NULL;
+ sexp_key = NULL;
+
+ if (key->type != GCRY_AC_KEY_SECRET)
+ {
+ err = gcry_error (GPG_ERR_WRONG_KEY_USAGE);
+ goto out;
+ }
+
+ err = ac_data_construct (ac_key_identifiers[key->type], 0, 0,
+ handle->algorithm_name, key->data, &sexp_key);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_data_new (&data_value);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_data_set (data_value, 0, "value", data);
+ if (err)
+ goto out;
+
+ /* Create S-expression holding the data. */
+ err = ac_data_construct ("data", 1, 0, NULL, data_value, &sexp_request);
+ if (err)
+ goto out;
+
+ /* Sign. */
+ err = gcry_pk_sign (&sexp_reply, sexp_request, sexp_key);
+ if (err)
+ goto out;
+
+ /* Extract data. */
+ err = ac_data_extract ("sig-val", handle->algorithm_name,
+ sexp_reply, &data_signed);
+ if (err)
+ goto out;
+
+ /* Done. */
+ *data_signature = data_signed;
+
+ out:
+
+ gcry_sexp_release (sexp_request);
+ gcry_sexp_release (sexp_reply);
+ gcry_sexp_release (sexp_key);
+ _gcry_ac_data_destroy (data_value);
+
+ return gcry_error (err);
+}
+
+
+/* Verifies that the signature contained in the data set
+ DATA_SIGNATURE is indeed the result of signing the data contained
+ in DATA with the secret key belonging to the public key KEY. */
+gcry_error_t
+_gcry_ac_data_verify (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ gcry_mpi_t data,
+ gcry_ac_data_t data_signature)
+{
+ gcry_sexp_t sexp_signature;
+ gcry_ac_data_t data_value;
+ gcry_sexp_t sexp_data;
+ gcry_sexp_t sexp_key;
+ gcry_error_t err;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ sexp_signature = NULL;
+ data_value = NULL;
+ sexp_data = NULL;
+ sexp_key = NULL;
+
+ err = ac_data_construct ("public-key", 0, 0,
+ handle->algorithm_name, key->data, &sexp_key);
+ if (err)
+ goto out;
+
+ if (key->type != GCRY_AC_KEY_PUBLIC)
+ {
+ err = gcry_error (GPG_ERR_WRONG_KEY_USAGE);
+ goto out;
+ }
+
+ /* Construct S-expression holding the signature data. */
+ err = ac_data_construct ("sig-val", 1, 0, handle->algorithm_name,
+ data_signature, &sexp_signature);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_data_new (&data_value);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_data_set (data_value, 0, "value", data);
+ if (err)
+ goto out;
+
+ /* Construct S-expression holding the data. */
+ err = ac_data_construct ("data", 1, 0, NULL, data_value, &sexp_data);
+ if (err)
+ goto out;
+
+ /* Verify signature. */
+ err = gcry_pk_verify (sexp_signature, sexp_data, sexp_key);
+
+ out:
+
+ gcry_sexp_release (sexp_signature);
+ gcry_sexp_release (sexp_data);
+ gcry_sexp_release (sexp_key);
+ _gcry_ac_data_destroy (data_value);
+
+ return gcry_error (err);
+}
+
+
+
+
+/*
+ * Implementation of encoding methods (em).
+ */
+
+/* Type for functions that encode or decode (hence the name) a
+ message. */
+typedef gcry_error_t (*gcry_ac_em_dencode_t) (unsigned int flags,
+ void *options,
+ gcry_ac_io_t *ac_io_read,
+ gcry_ac_io_t *ac_io_write);
+
+/* Fill the buffer BUFFER which is BUFFER_N bytes long with non-zero
+ random bytes of random level LEVEL. */
+static void
+em_randomize_nonzero (unsigned char *buffer, size_t buffer_n,
+ gcry_random_level_t level)
+{
+ unsigned char *buffer_rand;
+ unsigned int buffer_rand_n;
+ unsigned int zeros;
+ unsigned int i;
+ unsigned int j;
+
+ for (i = 0; i < buffer_n; i++)
+ buffer[i] = 0;
+
+ do
+ {
+ /* Count zeros. */
+ for (i = zeros = 0; i < buffer_n; i++)
+ if (! buffer[i])
+ zeros++;
+
+ if (zeros)
+ {
+ /* Get random bytes. */
+ buffer_rand_n = zeros + (zeros / 128);
+ buffer_rand = gcry_random_bytes_secure (buffer_rand_n, level);
+
+ /* Substitute zeros with non-zero random bytes. */
+ for (i = j = 0; zeros && (i < buffer_n) && (j < buffer_rand_n); i++)
+ if (! buffer[i])
+ {
+ while ((j < buffer_rand_n) && (! buffer_rand[j]))
+ j++;
+ if (j < buffer_rand_n)
+ {
+ buffer[i] = buffer_rand[j++];
+ zeros--;
+ }
+ else
+ break;
+ }
+ gcry_free (buffer_rand);
+ }
+ }
+ while (zeros);
+}
+
+/* Encode a message according to the Encoding Method for Encryption
+ `PKCS-V1_5' (EME-PKCS-V1_5). */
+static gcry_error_t
+eme_pkcs_v1_5_encode (unsigned int flags, void *opts,
+ gcry_ac_io_t *ac_io_read,
+ gcry_ac_io_t *ac_io_write)
+{
+ gcry_ac_eme_pkcs_v1_5_t *options;
+ gcry_error_t err;
+ unsigned char *buffer;
+ unsigned char *ps;
+ unsigned char *m;
+ size_t m_n;
+ unsigned int ps_n;
+ unsigned int k;
+
+ (void)flags;
+
+ options = opts;
+ buffer = NULL;
+ m = NULL;
+
+ err = _gcry_ac_io_read_all (ac_io_read, &m, &m_n);
+ if (err)
+ goto out;
+
+ /* Figure out key length in bytes. */
+ k = options->key_size / 8;
+
+ if (m_n > k - 11)
+ {
+ /* Key is too short for message. */
+ err = gcry_error (GPG_ERR_TOO_SHORT);
+ goto out;
+ }
+
+ /* According to this encoding method, the first byte of the encoded
+ message is zero. This byte will be lost anyway, when the encoded
+ message is to be converted into an MPI, that's why we skip
+ it. */
+
+ /* Allocate buffer. */
+ buffer = gcry_malloc (k - 1);
+ if (! buffer)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ /* Generate an octet string PS of length k - mLen - 3 consisting
+ of pseudorandomly generated nonzero octets. The length of PS
+ will be at least eight octets. */
+ ps_n = k - m_n - 3;
+ ps = buffer + 1;
+ em_randomize_nonzero (ps, ps_n, GCRY_STRONG_RANDOM);
+
+ /* Concatenate PS, the message M, and other padding to form an
+ encoded message EM of length k octets as:
+
+ EM = 0x00 || 0x02 || PS || 0x00 || M. */
+
+ buffer[0] = 0x02;
+ buffer[ps_n + 1] = 0x00;
+ memcpy (buffer + ps_n + 2, m, m_n);
+
+ err = _gcry_ac_io_write (ac_io_write, buffer, k - 1);
+
+ out:
+
+ gcry_free (buffer);
+ gcry_free (m);
+
+ return err;
+}
+
+/* Decode a message according to the Encoding Method for Encryption
+ `PKCS-V1_5' (EME-PKCS-V1_5). */
+static gcry_error_t
+eme_pkcs_v1_5_decode (unsigned int flags, void *opts,
+ gcry_ac_io_t *ac_io_read,
+ gcry_ac_io_t *ac_io_write)
+{
+ gcry_ac_eme_pkcs_v1_5_t *options;
+ unsigned char *buffer;
+ unsigned char *em;
+ size_t em_n;
+ gcry_error_t err;
+ unsigned int i;
+ unsigned int k;
+
+ (void)flags;
+
+ options = opts;
+ buffer = NULL;
+ em = NULL;
+
+ err = _gcry_ac_io_read_all (ac_io_read, &em, &em_n);
+ if (err)
+ goto out;
+
+ /* Figure out key size. */
+ k = options->key_size / 8;
+
+ /* Search for zero byte. */
+ for (i = 0; (i < em_n) && em[i]; i++);
+
+ /* According to this encoding method, the first byte of the encoded
+ message should be zero. This byte is lost. */
+
+ if (! ((em_n >= 10)
+ && (em_n == (k - 1))
+ && (em[0] == 0x02)
+ && (i < em_n)
+ && ((i - 1) >= 8)))
+ {
+ err = gcry_error (GPG_ERR_DECRYPT_FAILED);
+ goto out;
+ }
+
+ i++;
+ buffer = gcry_malloc (em_n - i);
+ if (! buffer)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ memcpy (buffer, em + i, em_n - i);
+ err = _gcry_ac_io_write (ac_io_write, buffer, em_n - i);
+
+ out:
+
+ gcry_free (buffer);
+ gcry_free (em);
+
+ return err;
+}
+
+static gcry_error_t
+emsa_pkcs_v1_5_encode_data_cb (void *opaque,
+ unsigned char *buffer, size_t buffer_n)
+{
+ gcry_md_hd_t md_handle;
+
+ md_handle = opaque;
+ gcry_md_write (md_handle, buffer, buffer_n);
+
+ return 0;
+}
+
+
+/* Encode a message according to the Encoding Method for Signatures
+ with Appendix `PKCS-V1_5' (EMSA-PKCS-V1_5). */
+static gcry_error_t
+emsa_pkcs_v1_5_encode (unsigned int flags, void *opts,
+ gcry_ac_io_t *ac_io_read,
+ gcry_ac_io_t *ac_io_write)
+{
+ gcry_ac_emsa_pkcs_v1_5_t *options;
+ gcry_error_t err;
+ gcry_md_hd_t md;
+ unsigned char *t;
+ size_t t_n;
+ unsigned char *h;
+ size_t h_n;
+ unsigned char *ps;
+ size_t ps_n;
+ unsigned char *buffer;
+ size_t buffer_n;
+ unsigned char asn[100]; /* FIXME, always enough? */
+ size_t asn_n;
+ unsigned int i;
+
+ (void)flags;
+
+ options = opts;
+ buffer = NULL;
+ md = NULL;
+ ps = NULL;
+ t = NULL;
+
+ /* Create hashing handle and get the necessary information. */
+ err = gcry_md_open (&md, options->md, 0);
+ if (err)
+ goto out;
+
+ asn_n = DIM (asn);
+ err = gcry_md_algo_info (options->md, GCRYCTL_GET_ASNOID, asn, &asn_n);
+ if (err)
+ goto out;
+
+ h_n = gcry_md_get_algo_dlen (options->md);
+
+ err = _gcry_ac_io_process (ac_io_read, emsa_pkcs_v1_5_encode_data_cb, md);
+ if (err)
+ goto out;
+
+ h = gcry_md_read (md, 0);
+
+ /* Encode the algorithm ID for the hash function and the hash value
+ into an ASN.1 value of type DigestInfo with the Distinguished
+ Encoding Rules (DER), where the type DigestInfo has the syntax:
+
+ DigestInfo ::== SEQUENCE {
+ digestAlgorithm AlgorithmIdentifier,
+ digest OCTET STRING
+ }
+
+ The first field identifies the hash function and the second
+ contains the hash value. Let T be the DER encoding of the
+ DigestInfo value and let tLen be the length in octets of T. */
+
+ t_n = asn_n + h_n;
+ t = gcry_malloc (t_n);
+ if (! t)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ for (i = 0; i < asn_n; i++)
+ t[i] = asn[i];
+ for (i = 0; i < h_n; i++)
+ t[asn_n + i] = h[i];
+
+ /* If emLen < tLen + 11, output "intended encoded message length
+ too short" and stop. */
+ if (options->em_n < t_n + 11)
+ {
+ err = gcry_error (GPG_ERR_TOO_SHORT);
+ goto out;
+ }
+
+ /* Generate an octet string PS consisting of emLen - tLen - 3 octets
+ with hexadecimal value 0xFF. The length of PS will be at least 8
+ octets. */
+ ps_n = options->em_n - t_n - 3;
+ ps = gcry_malloc (ps_n);
+ if (! ps)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+ for (i = 0; i < ps_n; i++)
+ ps[i] = 0xFF;
+
+ /* Concatenate PS, the DER encoding T, and other padding to form the
+ encoded message EM as:
+
+ EM = 0x00 || 0x01 || PS || 0x00 || T. */
+
+ buffer_n = ps_n + t_n + 3;
+ buffer = gcry_malloc (buffer_n);
+ if (! buffer)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ buffer[0] = 0x00;
+ buffer[1] = 0x01;
+ for (i = 0; i < ps_n; i++)
+ buffer[2 + i] = ps[i];
+ buffer[2 + ps_n] = 0x00;
+ for (i = 0; i < t_n; i++)
+ buffer[3 + ps_n + i] = t[i];
+
+ err = _gcry_ac_io_write (ac_io_write, buffer, buffer_n);
+
+ out:
+
+ gcry_md_close (md);
+
+ gcry_free (buffer);
+ gcry_free (ps);
+ gcry_free (t);
+
+ return err;
+}
+
+/* `Actions' for data_dencode(). */
+typedef enum dencode_action
+ {
+ DATA_ENCODE,
+ DATA_DECODE,
+ }
+dencode_action_t;
+
+/* Encode or decode a message according to the the encoding method
+ METHOD; ACTION specifies whether the message that is contained in
+ BUFFER_IN and of length BUFFER_IN_N should be encoded or decoded.
+ The resulting message will be stored in a newly allocated buffer in
+ BUFFER_OUT and BUFFER_OUT_N. */
+static gcry_error_t
+ac_data_dencode (gcry_ac_em_t method, dencode_action_t action,
+ unsigned int flags, void *options,
+ gcry_ac_io_t *ac_io_read,
+ gcry_ac_io_t *ac_io_write)
+{
+ struct
+ {
+ gcry_ac_em_t method;
+ gcry_ac_em_dencode_t encode;
+ gcry_ac_em_dencode_t decode;
+ } methods[] =
+ {
+ { GCRY_AC_EME_PKCS_V1_5,
+ eme_pkcs_v1_5_encode, eme_pkcs_v1_5_decode },
+ { GCRY_AC_EMSA_PKCS_V1_5,
+ emsa_pkcs_v1_5_encode, NULL },
+ };
+ size_t methods_n;
+ gcry_error_t err;
+ unsigned int i;
+
+ methods_n = sizeof (methods) / sizeof (*methods);
+
+ for (i = 0; i < methods_n; i++)
+ if (methods[i].method == method)
+ break;
+ if (i == methods_n)
+ {
+ err = gcry_error (GPG_ERR_NOT_FOUND); /* FIXME? */
+ goto out;
+ }
+
+ err = 0;
+ switch (action)
+ {
+ case DATA_ENCODE:
+ if (methods[i].encode)
+ /* FIXME? */
+ err = (*methods[i].encode) (flags, options, ac_io_read, ac_io_write);
+ break;
+
+ case DATA_DECODE:
+ if (methods[i].decode)
+ /* FIXME? */
+ err = (*methods[i].decode) (flags, options, ac_io_read, ac_io_write);
+ break;
+
+ default:
+ err = gcry_error (GPG_ERR_INV_ARG);
+ break;
+ }
+
+ out:
+
+ return err;
+}
+
+/* Encode a message according to the encoding method METHOD. OPTIONS
+ must be a pointer to a method-specific structure
+ (gcry_ac_em*_t). */
+gcry_error_t
+_gcry_ac_data_encode (gcry_ac_em_t method,
+ unsigned int flags, void *options,
+ gcry_ac_io_t *ac_io_read,
+ gcry_ac_io_t *ac_io_write)
+{
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ return ac_data_dencode (method, DATA_ENCODE, flags, options,
+ ac_io_read, ac_io_write);
+}
+
+/* Dencode a message according to the encoding method METHOD. OPTIONS
+ must be a pointer to a method-specific structure
+ (gcry_ac_em*_t). */
+gcry_error_t
+_gcry_ac_data_decode (gcry_ac_em_t method,
+ unsigned int flags, void *options,
+ gcry_ac_io_t *ac_io_read,
+ gcry_ac_io_t *ac_io_write)
+{
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ return ac_data_dencode (method, DATA_DECODE, flags, options,
+ ac_io_read, ac_io_write);
+}
+
+/* Convert an MPI into an octet string. */
+void
+_gcry_ac_mpi_to_os (gcry_mpi_t mpi, unsigned char *os, size_t os_n)
+{
+ unsigned long digit;
+ gcry_mpi_t base;
+ unsigned int i;
+ unsigned int n;
+ gcry_mpi_t m;
+ gcry_mpi_t d;
+
+ if (fips_mode ())
+ return;
+
+ base = gcry_mpi_new (0);
+ gcry_mpi_set_ui (base, 256);
+
+ n = 0;
+ m = gcry_mpi_copy (mpi);
+ while (gcry_mpi_cmp_ui (m, 0))
+ {
+ n++;
+ gcry_mpi_div (m, NULL, m, base, 0);
+ }
+
+ gcry_mpi_set (m, mpi);
+ d = gcry_mpi_new (0);
+ for (i = 0; (i < n) && (i < os_n); i++)
+ {
+ gcry_mpi_mod (d, m, base);
+ _gcry_mpi_get_ui (d, &digit);
+ gcry_mpi_div (m, NULL, m, base, 0);
+ os[os_n - i - 1] = (digit & 0xFF);
+ }
+
+ for (; i < os_n; i++)
+ os[os_n - i - 1] = 0;
+
+ gcry_mpi_release (base);
+ gcry_mpi_release (d);
+ gcry_mpi_release (m);
+}
+
+/* Convert an MPI into an newly allocated octet string. */
+gcry_error_t
+_gcry_ac_mpi_to_os_alloc (gcry_mpi_t mpi, unsigned char **os, size_t *os_n)
+{
+ unsigned char *buffer;
+ size_t buffer_n;
+ gcry_error_t err;
+ unsigned int nbits;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ nbits = gcry_mpi_get_nbits (mpi);
+ buffer_n = (nbits + 7) / 8;
+ buffer = gcry_malloc (buffer_n);
+ if (! buffer)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ _gcry_ac_mpi_to_os (mpi, buffer, buffer_n);
+ *os = buffer;
+ *os_n = buffer_n;
+ err = 0;
+
+ out:
+
+ return err;
+}
+
+
+/* Convert an octet string into an MPI. */
+void
+_gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n)
+{
+ unsigned int i;
+ gcry_mpi_t xi;
+ gcry_mpi_t x;
+ gcry_mpi_t a;
+
+ if (fips_mode ())
+ return;
+
+ a = gcry_mpi_new (0);
+ gcry_mpi_set_ui (a, 1);
+ x = gcry_mpi_new (0);
+ gcry_mpi_set_ui (x, 0);
+ xi = gcry_mpi_new (0);
+
+ for (i = 0; i < os_n; i++)
+ {
+ gcry_mpi_mul_ui (xi, a, os[os_n - i - 1]);
+ gcry_mpi_add (x, x, xi);
+ gcry_mpi_mul_ui (a, a, 256);
+ }
+
+ gcry_mpi_release (xi);
+ gcry_mpi_release (a);
+
+ gcry_mpi_set (mpi, x);
+ gcry_mpi_release (x); /* FIXME: correct? */
+}
+
+
+
+/*
+ * Implementation of Encryption Schemes (ES) and Signature Schemes
+ * with Appendix (SSA).
+ */
+
+/* Schemes consist of two things: encoding methods and cryptographic
+ primitives.
+
+ Since encoding methods are accessible through a common API with
+ method-specific options passed as an anonymous struct, schemes have
+ to provide functions that construct this method-specific structure;
+ this is what the functions of type `gcry_ac_dencode_prepare_t' are
+ there for. */
+
+typedef gcry_error_t (*gcry_ac_dencode_prepare_t) (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ void *opts,
+ void *opts_em);
+
+/* The `dencode_prepare' function for ES-PKCS-V1_5. */
+static gcry_error_t
+ac_es_dencode_prepare_pkcs_v1_5 (gcry_ac_handle_t handle, gcry_ac_key_t key,
+ void *opts, void *opts_em)
+{
+ gcry_ac_eme_pkcs_v1_5_t *options_em;
+ unsigned int nbits;
+ gcry_error_t err;
+
+ (void)opts;
+
+ err = _gcry_ac_key_get_nbits (handle, key, &nbits);
+ if (err)
+ goto out;
+
+ options_em = opts_em;
+ options_em->key_size = nbits;
+
+ out:
+
+ return err;
+}
+
+/* The `dencode_prepare' function for SSA-PKCS-V1_5. */
+static gcry_error_t
+ac_ssa_dencode_prepare_pkcs_v1_5 (gcry_ac_handle_t handle, gcry_ac_key_t key,
+ void *opts, void *opts_em)
+{
+ gcry_ac_emsa_pkcs_v1_5_t *options_em;
+ gcry_ac_ssa_pkcs_v1_5_t *options;
+ gcry_error_t err;
+ unsigned int k;
+
+ options_em = opts_em;
+ options = opts;
+
+ err = _gcry_ac_key_get_nbits (handle, key, &k);
+ if (err)
+ goto out;
+
+ k = (k + 7) / 8;
+ options_em->md = options->md;
+ options_em->em_n = k;
+
+ out:
+
+ return err;
+}
+
+/* Type holding the information about each supported
+ Encryption/Signature Scheme. */
+typedef struct ac_scheme
+{
+ gcry_ac_scheme_t scheme;
+ gcry_ac_em_t scheme_encoding;
+ gcry_ac_dencode_prepare_t dencode_prepare;
+ size_t options_em_n;
+} ac_scheme_t;
+
+/* List of supported Schemes. */
+static ac_scheme_t ac_schemes[] =
+ {
+ { GCRY_AC_ES_PKCS_V1_5, GCRY_AC_EME_PKCS_V1_5,
+ ac_es_dencode_prepare_pkcs_v1_5,
+ sizeof (gcry_ac_eme_pkcs_v1_5_t) },
+ { GCRY_AC_SSA_PKCS_V1_5, GCRY_AC_EMSA_PKCS_V1_5,
+ ac_ssa_dencode_prepare_pkcs_v1_5,
+ sizeof (gcry_ac_emsa_pkcs_v1_5_t) }
+ };
+
+/* Lookup a scheme by it's ID. */
+static ac_scheme_t *
+ac_scheme_get (gcry_ac_scheme_t scheme)
+{
+ ac_scheme_t *ac_scheme;
+ unsigned int i;
+
+ for (i = 0; i < DIM (ac_schemes); i++)
+ if (scheme == ac_schemes[i].scheme)
+ break;
+ if (i == DIM (ac_schemes))
+ ac_scheme = NULL;
+ else
+ ac_scheme = ac_schemes + i;
+
+ return ac_scheme;
+}
+
+/* Prepares the encoding/decoding by creating an according option
+ structure. */
+static gcry_error_t
+ac_dencode_prepare (gcry_ac_handle_t handle, gcry_ac_key_t key, void *opts,
+ ac_scheme_t scheme, void **opts_em)
+{
+ gcry_error_t err;
+ void *options_em;
+
+ options_em = gcry_malloc (scheme.options_em_n);
+ if (! options_em)
+ {
+ err = gcry_error_from_errno (errno);
+ goto out;
+ }
+
+ err = (*scheme.dencode_prepare) (handle, key, opts, options_em);
+ if (err)
+ goto out;
+
+ *opts_em = options_em;
+
+ out:
+
+ if (err)
+ free (options_em);
+
+ return err;
+}
+
+/* Convert a data set into a single MPI; currently, this is only
+ supported for data sets containing a single MPI. */
+static gcry_error_t
+ac_data_set_to_mpi (gcry_ac_data_t data, gcry_mpi_t *mpi)
+{
+ gcry_error_t err;
+ gcry_mpi_t mpi_new;
+ unsigned int elems;
+
+ elems = _gcry_ac_data_length (data);
+
+ if (elems != 1)
+ {
+ /* FIXME: I guess, we should be more flexible in this respect by
+ allowing the actual encryption/signature schemes to implement
+ this conversion mechanism. */
+ err = gcry_error (GPG_ERR_CONFLICT);
+ goto out;
+ }
+
+ err = _gcry_ac_data_get_index (data, GCRY_AC_FLAG_COPY, 0, NULL, &mpi_new);
+ if (err)
+ goto out;
+
+ *mpi = mpi_new;
+
+ out:
+
+ return err;
+}
+
+/* Encrypts the plain text message contained in M, which is of size
+ M_N, with the public key KEY_PUBLIC according to the Encryption
+ Scheme SCHEME_ID. HANDLE is used for accessing the low-level
+ cryptographic primitives. If OPTS is not NULL, it has to be an
+ anonymous structure specific to the chosen scheme (gcry_ac_es_*_t).
+ The encrypted message will be stored in C and C_N. */
+gcry_error_t
+_gcry_ac_data_encrypt_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme_id,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_cipher)
+{
+ gcry_error_t err;
+ gcry_ac_io_t io_em;
+ unsigned char *em;
+ size_t em_n;
+ gcry_mpi_t mpi_plain;
+ gcry_ac_data_t data_encrypted;
+ gcry_mpi_t mpi_encrypted;
+ unsigned char *buffer;
+ size_t buffer_n;
+ void *opts_em;
+ ac_scheme_t *scheme;
+
+ (void)flags;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ data_encrypted = NULL;
+ mpi_encrypted = NULL;
+ mpi_plain = NULL;
+ opts_em = NULL;
+ buffer = NULL;
+ em = NULL;
+
+ scheme = ac_scheme_get (scheme_id);
+ if (! scheme)
+ {
+ err = gcry_error (GPG_ERR_NO_ENCRYPTION_SCHEME);
+ goto out;
+ }
+
+ if (key->type != GCRY_AC_KEY_PUBLIC)
+ {
+ err = gcry_error (GPG_ERR_WRONG_KEY_USAGE);
+ goto out;
+ }
+
+ err = ac_dencode_prepare (handle, key, opts, *scheme, &opts_em);
+ if (err)
+ goto out;
+
+ _gcry_ac_io_init (&io_em, GCRY_AC_IO_WRITABLE,
+ GCRY_AC_IO_STRING, &em, &em_n);
+
+ err = _gcry_ac_data_encode (scheme->scheme_encoding, 0, opts_em,
+ io_message, &io_em);
+ if (err)
+ goto out;
+
+ mpi_plain = gcry_mpi_snew (0);
+ gcry_ac_os_to_mpi (mpi_plain, em, em_n);
+
+ err = _gcry_ac_data_encrypt (handle, 0, key, mpi_plain, &data_encrypted);
+ if (err)
+ goto out;
+
+ err = ac_data_set_to_mpi (data_encrypted, &mpi_encrypted);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_mpi_to_os_alloc (mpi_encrypted, &buffer, &buffer_n);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_io_write (io_cipher, buffer, buffer_n);
+
+ out:
+
+ gcry_ac_data_destroy (data_encrypted);
+ gcry_mpi_release (mpi_encrypted);
+ gcry_mpi_release (mpi_plain);
+ gcry_free (opts_em);
+ gcry_free (buffer);
+ gcry_free (em);
+
+ return err;
+}
+
+/* Decryptes the cipher message contained in C, which is of size C_N,
+ with the secret key KEY_SECRET according to the Encryption Scheme
+ SCHEME_ID. Handle is used for accessing the low-level
+ cryptographic primitives. If OPTS is not NULL, it has to be an
+ anonymous structure specific to the chosen scheme (gcry_ac_es_*_t).
+ The decrypted message will be stored in M and M_N. */
+gcry_error_t
+_gcry_ac_data_decrypt_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme_id,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_cipher,
+ gcry_ac_io_t *io_message)
+{
+ gcry_ac_io_t io_em;
+ gcry_error_t err;
+ gcry_ac_data_t data_encrypted;
+ unsigned char *em;
+ size_t em_n;
+ gcry_mpi_t mpi_encrypted;
+ gcry_mpi_t mpi_decrypted;
+ void *opts_em;
+ ac_scheme_t *scheme;
+ char *elements_enc;
+ size_t elements_enc_n;
+ unsigned char *c;
+ size_t c_n;
+
+ (void)flags;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ data_encrypted = NULL;
+ mpi_encrypted = NULL;
+ mpi_decrypted = NULL;
+ elements_enc = NULL;
+ opts_em = NULL;
+ em = NULL;
+ c = NULL;
+
+ scheme = ac_scheme_get (scheme_id);
+ if (! scheme)
+ {
+ err = gcry_error (GPG_ERR_NO_ENCRYPTION_SCHEME);
+ goto out;
+ }
+
+ if (key->type != GCRY_AC_KEY_SECRET)
+ {
+ err = gcry_error (GPG_ERR_WRONG_KEY_USAGE);
+ goto out;
+ }
+
+ err = _gcry_ac_io_read_all (io_cipher, &c, &c_n);
+ if (err)
+ goto out;
+
+ mpi_encrypted = gcry_mpi_snew (0);
+ gcry_ac_os_to_mpi (mpi_encrypted, c, c_n);
+
+ err = _gcry_pk_get_elements (handle->algorithm, &elements_enc, NULL);
+ if (err)
+ goto out;
+
+ elements_enc_n = strlen (elements_enc);
+ if (elements_enc_n != 1)
+ {
+ /* FIXME? */
+ err = gcry_error (GPG_ERR_CONFLICT);
+ goto out;
+ }
+
+ err = _gcry_ac_data_new (&data_encrypted);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_data_set (data_encrypted, GCRY_AC_FLAG_COPY | GCRY_AC_FLAG_DEALLOC,
+ elements_enc, mpi_encrypted);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_data_decrypt (handle, 0, key, &mpi_decrypted, data_encrypted);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_mpi_to_os_alloc (mpi_decrypted, &em, &em_n);
+ if (err)
+ goto out;
+
+ err = ac_dencode_prepare (handle, key, opts, *scheme, &opts_em);
+ if (err)
+ goto out;
+
+ _gcry_ac_io_init (&io_em, GCRY_AC_IO_READABLE,
+ GCRY_AC_IO_STRING, em, em_n);
+
+ err = _gcry_ac_data_decode (scheme->scheme_encoding, 0, opts_em,
+ &io_em, io_message);
+ if (err)
+ goto out;
+
+ out:
+
+ _gcry_ac_data_destroy (data_encrypted);
+ gcry_mpi_release (mpi_encrypted);
+ gcry_mpi_release (mpi_decrypted);
+ free (elements_enc);
+ gcry_free (opts_em);
+ gcry_free (em);
+ gcry_free (c);
+
+ return err;
+}
+
+
+/* Signs the message contained in M, which is of size M_N, with the
+ secret key KEY according to the Signature Scheme SCHEME_ID. Handle
+ is used for accessing the low-level cryptographic primitives. If
+ OPTS is not NULL, it has to be an anonymous structure specific to
+ the chosen scheme (gcry_ac_ssa_*_t). The signed message will be
+ stored in S and S_N. */
+gcry_error_t
+_gcry_ac_data_sign_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme_id,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_signature)
+{
+ gcry_ac_io_t io_em;
+ gcry_error_t err;
+ gcry_ac_data_t data_signed;
+ unsigned char *em;
+ size_t em_n;
+ gcry_mpi_t mpi;
+ void *opts_em;
+ unsigned char *buffer;
+ size_t buffer_n;
+ gcry_mpi_t mpi_signed;
+ ac_scheme_t *scheme;
+
+ (void)flags;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ data_signed = NULL;
+ mpi_signed = NULL;
+ opts_em = NULL;
+ buffer = NULL;
+ mpi = NULL;
+ em = NULL;
+
+ if (key->type != GCRY_AC_KEY_SECRET)
+ {
+ err = gcry_error (GPG_ERR_WRONG_KEY_USAGE);
+ goto out;
+ }
+
+ scheme = ac_scheme_get (scheme_id);
+ if (! scheme)
+ {
+ /* FIXME: adjust api of scheme_get in respect to err codes. */
+ err = gcry_error (GPG_ERR_NO_SIGNATURE_SCHEME);
+ goto out;
+ }
+
+ err = ac_dencode_prepare (handle, key, opts, *scheme, &opts_em);
+ if (err)
+ goto out;
+
+ _gcry_ac_io_init (&io_em, GCRY_AC_IO_WRITABLE,
+ GCRY_AC_IO_STRING, &em, &em_n);
+
+ err = _gcry_ac_data_encode (scheme->scheme_encoding, 0, opts_em,
+ io_message, &io_em);
+ if (err)
+ goto out;
+
+ mpi = gcry_mpi_new (0);
+ _gcry_ac_os_to_mpi (mpi, em, em_n);
+
+ err = _gcry_ac_data_sign (handle, key, mpi, &data_signed);
+ if (err)
+ goto out;
+
+ err = ac_data_set_to_mpi (data_signed, &mpi_signed);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_mpi_to_os_alloc (mpi_signed, &buffer, &buffer_n);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_io_write (io_signature, buffer, buffer_n);
+
+ out:
+
+ _gcry_ac_data_destroy (data_signed);
+ gcry_mpi_release (mpi_signed);
+ gcry_mpi_release (mpi);
+ gcry_free (opts_em);
+ gcry_free (buffer);
+ gcry_free (em);
+
+ return err;
+}
+
+/* Verifies that the signature contained in S, which is of length S_N,
+ is indeed the result of signing the message contained in M, which
+ is of size M_N, with the secret key belonging to the public key
+ KEY_PUBLIC. If OPTS is not NULL, it has to be an anonymous
+ structure (gcry_ac_ssa_*_t) specific to the Signature Scheme, whose
+ ID is contained in SCHEME_ID. */
+gcry_error_t
+_gcry_ac_data_verify_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme_id,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_signature)
+{
+ gcry_ac_io_t io_em;
+ gcry_error_t err;
+ gcry_ac_data_t data_signed;
+ unsigned char *em;
+ size_t em_n;
+ void *opts_em;
+ gcry_mpi_t mpi_signature;
+ gcry_mpi_t mpi_data;
+ ac_scheme_t *scheme;
+ char *elements_sig;
+ size_t elements_sig_n;
+ unsigned char *s;
+ size_t s_n;
+
+ (void)flags;
+
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ mpi_signature = NULL;
+ elements_sig = NULL;
+ data_signed = NULL;
+ mpi_data = NULL;
+ opts_em = NULL;
+ em = NULL;
+ s = NULL;
+
+ if (key->type != GCRY_AC_KEY_PUBLIC)
+ {
+ err = gcry_error (GPG_ERR_WRONG_KEY_USAGE);
+ goto out;
+ }
+
+ scheme = ac_scheme_get (scheme_id);
+ if (! scheme)
+ {
+ err = gcry_error (GPG_ERR_NO_SIGNATURE_SCHEME);
+ goto out;
+ }
+
+ err = ac_dencode_prepare (handle, key, opts, *scheme, &opts_em);
+ if (err)
+ goto out;
+
+ _gcry_ac_io_init (&io_em, GCRY_AC_IO_WRITABLE,
+ GCRY_AC_IO_STRING, &em, &em_n);
+
+ err = _gcry_ac_data_encode (scheme->scheme_encoding, 0, opts_em,
+ io_message, &io_em);
+ if (err)
+ goto out;
+
+ mpi_data = gcry_mpi_new (0);
+ _gcry_ac_os_to_mpi (mpi_data, em, em_n);
+
+ err = _gcry_ac_io_read_all (io_signature, &s, &s_n);
+ if (err)
+ goto out;
+
+ mpi_signature = gcry_mpi_new (0);
+ _gcry_ac_os_to_mpi (mpi_signature, s, s_n);
+
+ err = _gcry_pk_get_elements (handle->algorithm, NULL, &elements_sig);
+ if (err)
+ goto out;
+
+ elements_sig_n = strlen (elements_sig);
+ if (elements_sig_n != 1)
+ {
+ /* FIXME? */
+ err = gcry_error (GPG_ERR_CONFLICT);
+ goto out;
+ }
+
+ err = _gcry_ac_data_new (&data_signed);
+ if (err)
+ goto out;
+
+ err = _gcry_ac_data_set (data_signed, GCRY_AC_FLAG_COPY | GCRY_AC_FLAG_DEALLOC,
+ elements_sig, mpi_signature);
+ if (err)
+ goto out;
+
+ gcry_mpi_release (mpi_signature);
+ mpi_signature = NULL;
+
+ err = _gcry_ac_data_verify (handle, key, mpi_data, data_signed);
+
+ out:
+
+ _gcry_ac_data_destroy (data_signed);
+ gcry_mpi_release (mpi_signature);
+ gcry_mpi_release (mpi_data);
+ free (elements_sig);
+ gcry_free (opts_em);
+ gcry_free (em);
+ gcry_free (s);
+
+ return err;
+}
+
+
+/*
+ * General functions.
+ */
+
+gcry_err_code_t
+_gcry_ac_init (void)
+{
+ if (fips_mode ())
+ return GPG_ERR_NOT_SUPPORTED;
+
+ return 0;
+}
diff --git a/grub-core/lib/libgcrypt/cipher/arcfour.c b/grub-core/lib/libgcrypt/cipher/arcfour.c
new file mode 100644
index 0000000..6ef07fb
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/arcfour.c
@@ -0,0 +1,155 @@
+/* arcfour.c - The arcfour stream cipher
+ * Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * For a description of the algorithm, see:
+ * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996.
+ * ISBN 0-471-11709-9. Pages 397 ff.
+ */
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "types.h"
+#include "g10lib.h"
+#include "cipher.h"
+
+static const char *selftest(void);
+
+typedef struct {
+ int idx_i, idx_j;
+ byte sbox[256];
+} ARCFOUR_context;
+
+static void
+do_encrypt_stream( ARCFOUR_context *ctx,
+ byte *outbuf, const byte *inbuf, unsigned int length )
+{
+ register int i = ctx->idx_i;
+ register int j = ctx->idx_j;
+ register byte *sbox = ctx->sbox;
+ register int t;
+
+ while ( length-- )
+ {
+ i++;
+ i = i & 255; /* The and-op seems to be faster than the mod-op. */
+ j += sbox[i];
+ j &= 255;
+ t = sbox[i]; sbox[i] = sbox[j]; sbox[j] = t;
+ *outbuf++ = *inbuf++ ^ sbox[(sbox[i] + sbox[j]) & 255];
+ }
+
+ ctx->idx_i = i;
+ ctx->idx_j = j;
+}
+
+static void
+encrypt_stream (void *context,
+ byte *outbuf, const byte *inbuf, unsigned int length)
+{
+ ARCFOUR_context *ctx = (ARCFOUR_context *) context;
+ do_encrypt_stream (ctx, outbuf, inbuf, length );
+ _gcry_burn_stack (64);
+}
+
+
+static gcry_err_code_t
+do_arcfour_setkey (void *context, const byte *key, unsigned int keylen)
+{
+ static int initialized;
+ static const char* selftest_failed;
+ int i, j;
+ byte karr[256];
+ ARCFOUR_context *ctx = (ARCFOUR_context *) context;
+
+ if (!initialized )
+ {
+ initialized = 1;
+ selftest_failed = selftest();
+ if( selftest_failed )
+ log_error ("ARCFOUR selftest failed (%s)\n", selftest_failed );
+ }
+ if( selftest_failed )
+ return GPG_ERR_SELFTEST_FAILED;
+
+ if( keylen < 40/8 ) /* we want at least 40 bits */
+ return GPG_ERR_INV_KEYLEN;
+
+ ctx->idx_i = ctx->idx_j = 0;
+ for (i=0; i < 256; i++ )
+ ctx->sbox[i] = i;
+ for (i=0; i < 256; i++ )
+ karr[i] = key[i%keylen];
+ for (i=j=0; i < 256; i++ )
+ {
+ int t;
+ j = (j + ctx->sbox[i] + karr[i]) % 256;
+ t = ctx->sbox[i];
+ ctx->sbox[i] = ctx->sbox[j];
+ ctx->sbox[j] = t;
+ }
+ memset( karr, 0, 256 );
+
+ return GPG_ERR_NO_ERROR;
+}
+
+static gcry_err_code_t
+arcfour_setkey ( void *context, const byte *key, unsigned int keylen )
+{
+ ARCFOUR_context *ctx = (ARCFOUR_context *) context;
+ gcry_err_code_t rc = do_arcfour_setkey (ctx, key, keylen );
+ _gcry_burn_stack (300);
+ return rc;
+}
+
+
+static const char*
+selftest(void)
+{
+ ARCFOUR_context ctx;
+ byte scratch[16];
+
+ /* Test vector from Cryptlib labeled there: "from the
+ State/Commerce Department". */
+ static byte key_1[] =
+ { 0x61, 0x8A, 0x63, 0xD2, 0xFB };
+ static byte plaintext_1[] =
+ { 0xDC, 0xEE, 0x4C, 0xF9, 0x2C };
+ static const byte ciphertext_1[] =
+ { 0xF1, 0x38, 0x29, 0xC9, 0xDE };
+
+ arcfour_setkey( &ctx, key_1, sizeof(key_1));
+ encrypt_stream( &ctx, scratch, plaintext_1, sizeof(plaintext_1));
+ if ( memcmp (scratch, ciphertext_1, sizeof (ciphertext_1)))
+ return "Arcfour encryption test 1 failed.";
+ arcfour_setkey( &ctx, key_1, sizeof(key_1));
+ encrypt_stream(&ctx, scratch, scratch, sizeof(plaintext_1)); /* decrypt */
+ if ( memcmp (scratch, plaintext_1, sizeof (plaintext_1)))
+ return "Arcfour decryption test 1 failed.";
+ return NULL;
+}
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_arcfour =
+ {
+ "ARCFOUR", NULL, NULL, 1, 128, sizeof (ARCFOUR_context),
+ arcfour_setkey, NULL, NULL, encrypt_stream, encrypt_stream,
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/bithelp.h b/grub-core/lib/libgcrypt/cipher/bithelp.h
new file mode 100644
index 0000000..1505324
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/bithelp.h
@@ -0,0 +1,54 @@
+/* bithelp.h - Some bit manipulation helpers
+ * Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+#ifndef G10_BITHELP_H
+#define G10_BITHELP_H
+
+
+/****************
+ * Rotate the 32 bit unsigned integer X by N bits left/right
+ */
+#if defined(__GNUC__) && defined(__i386__)
+static inline u32
+rol( u32 x, int n)
+{
+ __asm__("roll %%cl,%0"
+ :"=r" (x)
+ :"0" (x),"c" (n));
+ return x;
+}
+#else
+#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
+#endif
+
+#if defined(__GNUC__) && defined(__i386__)
+static inline u32
+ror(u32 x, int n)
+{
+ __asm__("rorl %%cl,%0"
+ :"=r" (x)
+ :"0" (x),"c" (n));
+ return x;
+}
+#else
+#define ror(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) )
+#endif
+
+
+#endif /*G10_BITHELP_H*/
diff --git a/grub-core/lib/libgcrypt/cipher/blowfish.c b/grub-core/lib/libgcrypt/cipher/blowfish.c
new file mode 100644
index 0000000..b4d2b9c
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/blowfish.c
@@ -0,0 +1,605 @@
+/* blowfish.c - Blowfish encryption
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * For a description of the algorithm, see:
+ * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996.
+ * ISBN 0-471-11709-9. Pages 336 ff.
+ */
+
+/* Test values:
+ * key "abcdefghijklmnopqrstuvwxyz";
+ * plain "BLOWFISH"
+ * cipher 32 4E D0 FE F4 13 A2 03
+ *
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "types.h"
+#include "g10lib.h"
+#include "cipher.h"
+
+#define BLOWFISH_BLOCKSIZE 8
+#define BLOWFISH_ROUNDS 16
+
+typedef struct {
+ u32 s0[256];
+ u32 s1[256];
+ u32 s2[256];
+ u32 s3[256];
+ u32 p[BLOWFISH_ROUNDS+2];
+} BLOWFISH_context;
+
+static gcry_err_code_t bf_setkey (void *c, const byte *key, unsigned keylen);
+static void encrypt_block (void *bc, byte *outbuf, const byte *inbuf);
+static void decrypt_block (void *bc, byte *outbuf, const byte *inbuf);
+
+
+/* precomputed S boxes */
+static const u32 ks0[256] = {
+ 0xD1310BA6,0x98DFB5AC,0x2FFD72DB,0xD01ADFB7,0xB8E1AFED,0x6A267E96,
+ 0xBA7C9045,0xF12C7F99,0x24A19947,0xB3916CF7,0x0801F2E2,0x858EFC16,
+ 0x636920D8,0x71574E69,0xA458FEA3,0xF4933D7E,0x0D95748F,0x728EB658,
+ 0x718BCD58,0x82154AEE,0x7B54A41D,0xC25A59B5,0x9C30D539,0x2AF26013,
+ 0xC5D1B023,0x286085F0,0xCA417918,0xB8DB38EF,0x8E79DCB0,0x603A180E,
+ 0x6C9E0E8B,0xB01E8A3E,0xD71577C1,0xBD314B27,0x78AF2FDA,0x55605C60,
+ 0xE65525F3,0xAA55AB94,0x57489862,0x63E81440,0x55CA396A,0x2AAB10B6,
+ 0xB4CC5C34,0x1141E8CE,0xA15486AF,0x7C72E993,0xB3EE1411,0x636FBC2A,
+ 0x2BA9C55D,0x741831F6,0xCE5C3E16,0x9B87931E,0xAFD6BA33,0x6C24CF5C,
+ 0x7A325381,0x28958677,0x3B8F4898,0x6B4BB9AF,0xC4BFE81B,0x66282193,
+ 0x61D809CC,0xFB21A991,0x487CAC60,0x5DEC8032,0xEF845D5D,0xE98575B1,
+ 0xDC262302,0xEB651B88,0x23893E81,0xD396ACC5,0x0F6D6FF3,0x83F44239,
+ 0x2E0B4482,0xA4842004,0x69C8F04A,0x9E1F9B5E,0x21C66842,0xF6E96C9A,
+ 0x670C9C61,0xABD388F0,0x6A51A0D2,0xD8542F68,0x960FA728,0xAB5133A3,
+ 0x6EEF0B6C,0x137A3BE4,0xBA3BF050,0x7EFB2A98,0xA1F1651D,0x39AF0176,
+ 0x66CA593E,0x82430E88,0x8CEE8619,0x456F9FB4,0x7D84A5C3,0x3B8B5EBE,
+ 0xE06F75D8,0x85C12073,0x401A449F,0x56C16AA6,0x4ED3AA62,0x363F7706,
+ 0x1BFEDF72,0x429B023D,0x37D0D724,0xD00A1248,0xDB0FEAD3,0x49F1C09B,
+ 0x075372C9,0x80991B7B,0x25D479D8,0xF6E8DEF7,0xE3FE501A,0xB6794C3B,
+ 0x976CE0BD,0x04C006BA,0xC1A94FB6,0x409F60C4,0x5E5C9EC2,0x196A2463,
+ 0x68FB6FAF,0x3E6C53B5,0x1339B2EB,0x3B52EC6F,0x6DFC511F,0x9B30952C,
+ 0xCC814544,0xAF5EBD09,0xBEE3D004,0xDE334AFD,0x660F2807,0x192E4BB3,
+ 0xC0CBA857,0x45C8740F,0xD20B5F39,0xB9D3FBDB,0x5579C0BD,0x1A60320A,
+ 0xD6A100C6,0x402C7279,0x679F25FE,0xFB1FA3CC,0x8EA5E9F8,0xDB3222F8,
+ 0x3C7516DF,0xFD616B15,0x2F501EC8,0xAD0552AB,0x323DB5FA,0xFD238760,
+ 0x53317B48,0x3E00DF82,0x9E5C57BB,0xCA6F8CA0,0x1A87562E,0xDF1769DB,
+ 0xD542A8F6,0x287EFFC3,0xAC6732C6,0x8C4F5573,0x695B27B0,0xBBCA58C8,
+ 0xE1FFA35D,0xB8F011A0,0x10FA3D98,0xFD2183B8,0x4AFCB56C,0x2DD1D35B,
+ 0x9A53E479,0xB6F84565,0xD28E49BC,0x4BFB9790,0xE1DDF2DA,0xA4CB7E33,
+ 0x62FB1341,0xCEE4C6E8,0xEF20CADA,0x36774C01,0xD07E9EFE,0x2BF11FB4,
+ 0x95DBDA4D,0xAE909198,0xEAAD8E71,0x6B93D5A0,0xD08ED1D0,0xAFC725E0,
+ 0x8E3C5B2F,0x8E7594B7,0x8FF6E2FB,0xF2122B64,0x8888B812,0x900DF01C,
+ 0x4FAD5EA0,0x688FC31C,0xD1CFF191,0xB3A8C1AD,0x2F2F2218,0xBE0E1777,
+ 0xEA752DFE,0x8B021FA1,0xE5A0CC0F,0xB56F74E8,0x18ACF3D6,0xCE89E299,
+ 0xB4A84FE0,0xFD13E0B7,0x7CC43B81,0xD2ADA8D9,0x165FA266,0x80957705,
+ 0x93CC7314,0x211A1477,0xE6AD2065,0x77B5FA86,0xC75442F5,0xFB9D35CF,
+ 0xEBCDAF0C,0x7B3E89A0,0xD6411BD3,0xAE1E7E49,0x00250E2D,0x2071B35E,
+ 0x226800BB,0x57B8E0AF,0x2464369B,0xF009B91E,0x5563911D,0x59DFA6AA,
+ 0x78C14389,0xD95A537F,0x207D5BA2,0x02E5B9C5,0x83260376,0x6295CFA9,
+ 0x11C81968,0x4E734A41,0xB3472DCA,0x7B14A94A,0x1B510052,0x9A532915,
+ 0xD60F573F,0xBC9BC6E4,0x2B60A476,0x81E67400,0x08BA6FB5,0x571BE91F,
+ 0xF296EC6B,0x2A0DD915,0xB6636521,0xE7B9F9B6,0xFF34052E,0xC5855664,
+ 0x53B02D5D,0xA99F8FA1,0x08BA4799,0x6E85076A };
+
+static const u32 ks1[256] = {
+ 0x4B7A70E9,0xB5B32944,0xDB75092E,0xC4192623,0xAD6EA6B0,0x49A7DF7D,
+ 0x9CEE60B8,0x8FEDB266,0xECAA8C71,0x699A17FF,0x5664526C,0xC2B19EE1,
+ 0x193602A5,0x75094C29,0xA0591340,0xE4183A3E,0x3F54989A,0x5B429D65,
+ 0x6B8FE4D6,0x99F73FD6,0xA1D29C07,0xEFE830F5,0x4D2D38E6,0xF0255DC1,
+ 0x4CDD2086,0x8470EB26,0x6382E9C6,0x021ECC5E,0x09686B3F,0x3EBAEFC9,
+ 0x3C971814,0x6B6A70A1,0x687F3584,0x52A0E286,0xB79C5305,0xAA500737,
+ 0x3E07841C,0x7FDEAE5C,0x8E7D44EC,0x5716F2B8,0xB03ADA37,0xF0500C0D,
+ 0xF01C1F04,0x0200B3FF,0xAE0CF51A,0x3CB574B2,0x25837A58,0xDC0921BD,
+ 0xD19113F9,0x7CA92FF6,0x94324773,0x22F54701,0x3AE5E581,0x37C2DADC,
+ 0xC8B57634,0x9AF3DDA7,0xA9446146,0x0FD0030E,0xECC8C73E,0xA4751E41,
+ 0xE238CD99,0x3BEA0E2F,0x3280BBA1,0x183EB331,0x4E548B38,0x4F6DB908,
+ 0x6F420D03,0xF60A04BF,0x2CB81290,0x24977C79,0x5679B072,0xBCAF89AF,
+ 0xDE9A771F,0xD9930810,0xB38BAE12,0xDCCF3F2E,0x5512721F,0x2E6B7124,
+ 0x501ADDE6,0x9F84CD87,0x7A584718,0x7408DA17,0xBC9F9ABC,0xE94B7D8C,
+ 0xEC7AEC3A,0xDB851DFA,0x63094366,0xC464C3D2,0xEF1C1847,0x3215D908,
+ 0xDD433B37,0x24C2BA16,0x12A14D43,0x2A65C451,0x50940002,0x133AE4DD,
+ 0x71DFF89E,0x10314E55,0x81AC77D6,0x5F11199B,0x043556F1,0xD7A3C76B,
+ 0x3C11183B,0x5924A509,0xF28FE6ED,0x97F1FBFA,0x9EBABF2C,0x1E153C6E,
+ 0x86E34570,0xEAE96FB1,0x860E5E0A,0x5A3E2AB3,0x771FE71C,0x4E3D06FA,
+ 0x2965DCB9,0x99E71D0F,0x803E89D6,0x5266C825,0x2E4CC978,0x9C10B36A,
+ 0xC6150EBA,0x94E2EA78,0xA5FC3C53,0x1E0A2DF4,0xF2F74EA7,0x361D2B3D,
+ 0x1939260F,0x19C27960,0x5223A708,0xF71312B6,0xEBADFE6E,0xEAC31F66,
+ 0xE3BC4595,0xA67BC883,0xB17F37D1,0x018CFF28,0xC332DDEF,0xBE6C5AA5,
+ 0x65582185,0x68AB9802,0xEECEA50F,0xDB2F953B,0x2AEF7DAD,0x5B6E2F84,
+ 0x1521B628,0x29076170,0xECDD4775,0x619F1510,0x13CCA830,0xEB61BD96,
+ 0x0334FE1E,0xAA0363CF,0xB5735C90,0x4C70A239,0xD59E9E0B,0xCBAADE14,
+ 0xEECC86BC,0x60622CA7,0x9CAB5CAB,0xB2F3846E,0x648B1EAF,0x19BDF0CA,
+ 0xA02369B9,0x655ABB50,0x40685A32,0x3C2AB4B3,0x319EE9D5,0xC021B8F7,
+ 0x9B540B19,0x875FA099,0x95F7997E,0x623D7DA8,0xF837889A,0x97E32D77,
+ 0x11ED935F,0x16681281,0x0E358829,0xC7E61FD6,0x96DEDFA1,0x7858BA99,
+ 0x57F584A5,0x1B227263,0x9B83C3FF,0x1AC24696,0xCDB30AEB,0x532E3054,
+ 0x8FD948E4,0x6DBC3128,0x58EBF2EF,0x34C6FFEA,0xFE28ED61,0xEE7C3C73,
+ 0x5D4A14D9,0xE864B7E3,0x42105D14,0x203E13E0,0x45EEE2B6,0xA3AAABEA,
+ 0xDB6C4F15,0xFACB4FD0,0xC742F442,0xEF6ABBB5,0x654F3B1D,0x41CD2105,
+ 0xD81E799E,0x86854DC7,0xE44B476A,0x3D816250,0xCF62A1F2,0x5B8D2646,
+ 0xFC8883A0,0xC1C7B6A3,0x7F1524C3,0x69CB7492,0x47848A0B,0x5692B285,
+ 0x095BBF00,0xAD19489D,0x1462B174,0x23820E00,0x58428D2A,0x0C55F5EA,
+ 0x1DADF43E,0x233F7061,0x3372F092,0x8D937E41,0xD65FECF1,0x6C223BDB,
+ 0x7CDE3759,0xCBEE7460,0x4085F2A7,0xCE77326E,0xA6078084,0x19F8509E,
+ 0xE8EFD855,0x61D99735,0xA969A7AA,0xC50C06C2,0x5A04ABFC,0x800BCADC,
+ 0x9E447A2E,0xC3453484,0xFDD56705,0x0E1E9EC9,0xDB73DBD3,0x105588CD,
+ 0x675FDA79,0xE3674340,0xC5C43465,0x713E38D8,0x3D28F89E,0xF16DFF20,
+ 0x153E21E7,0x8FB03D4A,0xE6E39F2B,0xDB83ADF7 };
+
+static const u32 ks2[256] = {
+ 0xE93D5A68,0x948140F7,0xF64C261C,0x94692934,0x411520F7,0x7602D4F7,
+ 0xBCF46B2E,0xD4A20068,0xD4082471,0x3320F46A,0x43B7D4B7,0x500061AF,
+ 0x1E39F62E,0x97244546,0x14214F74,0xBF8B8840,0x4D95FC1D,0x96B591AF,
+ 0x70F4DDD3,0x66A02F45,0xBFBC09EC,0x03BD9785,0x7FAC6DD0,0x31CB8504,
+ 0x96EB27B3,0x55FD3941,0xDA2547E6,0xABCA0A9A,0x28507825,0x530429F4,
+ 0x0A2C86DA,0xE9B66DFB,0x68DC1462,0xD7486900,0x680EC0A4,0x27A18DEE,
+ 0x4F3FFEA2,0xE887AD8C,0xB58CE006,0x7AF4D6B6,0xAACE1E7C,0xD3375FEC,
+ 0xCE78A399,0x406B2A42,0x20FE9E35,0xD9F385B9,0xEE39D7AB,0x3B124E8B,
+ 0x1DC9FAF7,0x4B6D1856,0x26A36631,0xEAE397B2,0x3A6EFA74,0xDD5B4332,
+ 0x6841E7F7,0xCA7820FB,0xFB0AF54E,0xD8FEB397,0x454056AC,0xBA489527,
+ 0x55533A3A,0x20838D87,0xFE6BA9B7,0xD096954B,0x55A867BC,0xA1159A58,
+ 0xCCA92963,0x99E1DB33,0xA62A4A56,0x3F3125F9,0x5EF47E1C,0x9029317C,
+ 0xFDF8E802,0x04272F70,0x80BB155C,0x05282CE3,0x95C11548,0xE4C66D22,
+ 0x48C1133F,0xC70F86DC,0x07F9C9EE,0x41041F0F,0x404779A4,0x5D886E17,
+ 0x325F51EB,0xD59BC0D1,0xF2BCC18F,0x41113564,0x257B7834,0x602A9C60,
+ 0xDFF8E8A3,0x1F636C1B,0x0E12B4C2,0x02E1329E,0xAF664FD1,0xCAD18115,
+ 0x6B2395E0,0x333E92E1,0x3B240B62,0xEEBEB922,0x85B2A20E,0xE6BA0D99,
+ 0xDE720C8C,0x2DA2F728,0xD0127845,0x95B794FD,0x647D0862,0xE7CCF5F0,
+ 0x5449A36F,0x877D48FA,0xC39DFD27,0xF33E8D1E,0x0A476341,0x992EFF74,
+ 0x3A6F6EAB,0xF4F8FD37,0xA812DC60,0xA1EBDDF8,0x991BE14C,0xDB6E6B0D,
+ 0xC67B5510,0x6D672C37,0x2765D43B,0xDCD0E804,0xF1290DC7,0xCC00FFA3,
+ 0xB5390F92,0x690FED0B,0x667B9FFB,0xCEDB7D9C,0xA091CF0B,0xD9155EA3,
+ 0xBB132F88,0x515BAD24,0x7B9479BF,0x763BD6EB,0x37392EB3,0xCC115979,
+ 0x8026E297,0xF42E312D,0x6842ADA7,0xC66A2B3B,0x12754CCC,0x782EF11C,
+ 0x6A124237,0xB79251E7,0x06A1BBE6,0x4BFB6350,0x1A6B1018,0x11CAEDFA,
+ 0x3D25BDD8,0xE2E1C3C9,0x44421659,0x0A121386,0xD90CEC6E,0xD5ABEA2A,
+ 0x64AF674E,0xDA86A85F,0xBEBFE988,0x64E4C3FE,0x9DBC8057,0xF0F7C086,
+ 0x60787BF8,0x6003604D,0xD1FD8346,0xF6381FB0,0x7745AE04,0xD736FCCC,
+ 0x83426B33,0xF01EAB71,0xB0804187,0x3C005E5F,0x77A057BE,0xBDE8AE24,
+ 0x55464299,0xBF582E61,0x4E58F48F,0xF2DDFDA2,0xF474EF38,0x8789BDC2,
+ 0x5366F9C3,0xC8B38E74,0xB475F255,0x46FCD9B9,0x7AEB2661,0x8B1DDF84,
+ 0x846A0E79,0x915F95E2,0x466E598E,0x20B45770,0x8CD55591,0xC902DE4C,
+ 0xB90BACE1,0xBB8205D0,0x11A86248,0x7574A99E,0xB77F19B6,0xE0A9DC09,
+ 0x662D09A1,0xC4324633,0xE85A1F02,0x09F0BE8C,0x4A99A025,0x1D6EFE10,
+ 0x1AB93D1D,0x0BA5A4DF,0xA186F20F,0x2868F169,0xDCB7DA83,0x573906FE,
+ 0xA1E2CE9B,0x4FCD7F52,0x50115E01,0xA70683FA,0xA002B5C4,0x0DE6D027,
+ 0x9AF88C27,0x773F8641,0xC3604C06,0x61A806B5,0xF0177A28,0xC0F586E0,
+ 0x006058AA,0x30DC7D62,0x11E69ED7,0x2338EA63,0x53C2DD94,0xC2C21634,
+ 0xBBCBEE56,0x90BCB6DE,0xEBFC7DA1,0xCE591D76,0x6F05E409,0x4B7C0188,
+ 0x39720A3D,0x7C927C24,0x86E3725F,0x724D9DB9,0x1AC15BB4,0xD39EB8FC,
+ 0xED545578,0x08FCA5B5,0xD83D7CD3,0x4DAD0FC4,0x1E50EF5E,0xB161E6F8,
+ 0xA28514D9,0x6C51133C,0x6FD5C7E7,0x56E14EC4,0x362ABFCE,0xDDC6C837,
+ 0xD79A3234,0x92638212,0x670EFA8E,0x406000E0 };
+
+static const u32 ks3[256] = {
+ 0x3A39CE37,0xD3FAF5CF,0xABC27737,0x5AC52D1B,0x5CB0679E,0x4FA33742,
+ 0xD3822740,0x99BC9BBE,0xD5118E9D,0xBF0F7315,0xD62D1C7E,0xC700C47B,
+ 0xB78C1B6B,0x21A19045,0xB26EB1BE,0x6A366EB4,0x5748AB2F,0xBC946E79,
+ 0xC6A376D2,0x6549C2C8,0x530FF8EE,0x468DDE7D,0xD5730A1D,0x4CD04DC6,
+ 0x2939BBDB,0xA9BA4650,0xAC9526E8,0xBE5EE304,0xA1FAD5F0,0x6A2D519A,
+ 0x63EF8CE2,0x9A86EE22,0xC089C2B8,0x43242EF6,0xA51E03AA,0x9CF2D0A4,
+ 0x83C061BA,0x9BE96A4D,0x8FE51550,0xBA645BD6,0x2826A2F9,0xA73A3AE1,
+ 0x4BA99586,0xEF5562E9,0xC72FEFD3,0xF752F7DA,0x3F046F69,0x77FA0A59,
+ 0x80E4A915,0x87B08601,0x9B09E6AD,0x3B3EE593,0xE990FD5A,0x9E34D797,
+ 0x2CF0B7D9,0x022B8B51,0x96D5AC3A,0x017DA67D,0xD1CF3ED6,0x7C7D2D28,
+ 0x1F9F25CF,0xADF2B89B,0x5AD6B472,0x5A88F54C,0xE029AC71,0xE019A5E6,
+ 0x47B0ACFD,0xED93FA9B,0xE8D3C48D,0x283B57CC,0xF8D56629,0x79132E28,
+ 0x785F0191,0xED756055,0xF7960E44,0xE3D35E8C,0x15056DD4,0x88F46DBA,
+ 0x03A16125,0x0564F0BD,0xC3EB9E15,0x3C9057A2,0x97271AEC,0xA93A072A,
+ 0x1B3F6D9B,0x1E6321F5,0xF59C66FB,0x26DCF319,0x7533D928,0xB155FDF5,
+ 0x03563482,0x8ABA3CBB,0x28517711,0xC20AD9F8,0xABCC5167,0xCCAD925F,
+ 0x4DE81751,0x3830DC8E,0x379D5862,0x9320F991,0xEA7A90C2,0xFB3E7BCE,
+ 0x5121CE64,0x774FBE32,0xA8B6E37E,0xC3293D46,0x48DE5369,0x6413E680,
+ 0xA2AE0810,0xDD6DB224,0x69852DFD,0x09072166,0xB39A460A,0x6445C0DD,
+ 0x586CDECF,0x1C20C8AE,0x5BBEF7DD,0x1B588D40,0xCCD2017F,0x6BB4E3BB,
+ 0xDDA26A7E,0x3A59FF45,0x3E350A44,0xBCB4CDD5,0x72EACEA8,0xFA6484BB,
+ 0x8D6612AE,0xBF3C6F47,0xD29BE463,0x542F5D9E,0xAEC2771B,0xF64E6370,
+ 0x740E0D8D,0xE75B1357,0xF8721671,0xAF537D5D,0x4040CB08,0x4EB4E2CC,
+ 0x34D2466A,0x0115AF84,0xE1B00428,0x95983A1D,0x06B89FB4,0xCE6EA048,
+ 0x6F3F3B82,0x3520AB82,0x011A1D4B,0x277227F8,0x611560B1,0xE7933FDC,
+ 0xBB3A792B,0x344525BD,0xA08839E1,0x51CE794B,0x2F32C9B7,0xA01FBAC9,
+ 0xE01CC87E,0xBCC7D1F6,0xCF0111C3,0xA1E8AAC7,0x1A908749,0xD44FBD9A,
+ 0xD0DADECB,0xD50ADA38,0x0339C32A,0xC6913667,0x8DF9317C,0xE0B12B4F,
+ 0xF79E59B7,0x43F5BB3A,0xF2D519FF,0x27D9459C,0xBF97222C,0x15E6FC2A,
+ 0x0F91FC71,0x9B941525,0xFAE59361,0xCEB69CEB,0xC2A86459,0x12BAA8D1,
+ 0xB6C1075E,0xE3056A0C,0x10D25065,0xCB03A442,0xE0EC6E0E,0x1698DB3B,
+ 0x4C98A0BE,0x3278E964,0x9F1F9532,0xE0D392DF,0xD3A0342B,0x8971F21E,
+ 0x1B0A7441,0x4BA3348C,0xC5BE7120,0xC37632D8,0xDF359F8D,0x9B992F2E,
+ 0xE60B6F47,0x0FE3F11D,0xE54CDA54,0x1EDAD891,0xCE6279CF,0xCD3E7E6F,
+ 0x1618B166,0xFD2C1D05,0x848FD2C5,0xF6FB2299,0xF523F357,0xA6327623,
+ 0x93A83531,0x56CCCD02,0xACF08162,0x5A75EBB5,0x6E163697,0x88D273CC,
+ 0xDE966292,0x81B949D0,0x4C50901B,0x71C65614,0xE6C6C7BD,0x327A140A,
+ 0x45E1D006,0xC3F27B9A,0xC9AA53FD,0x62A80F00,0xBB25BFE2,0x35BDD2F6,
+ 0x71126905,0xB2040222,0xB6CBCF7C,0xCD769C2B,0x53113EC0,0x1640E3D3,
+ 0x38ABBD60,0x2547ADF0,0xBA38209C,0xF746CE76,0x77AFA1C5,0x20756060,
+ 0x85CBFE4E,0x8AE88DD8,0x7AAAF9B0,0x4CF9AA7E,0x1948C25C,0x02FB8A8C,
+ 0x01C36AE4,0xD6EBE1F9,0x90D4F869,0xA65CDEA0,0x3F09252D,0xC208E69F,
+ 0xB74E6132,0xCE77E25B,0x578FDFE3,0x3AC372E6 };
+
+static const u32 ps[BLOWFISH_ROUNDS+2] = {
+ 0x243F6A88,0x85A308D3,0x13198A2E,0x03707344,0xA4093822,0x299F31D0,
+ 0x082EFA98,0xEC4E6C89,0x452821E6,0x38D01377,0xBE5466CF,0x34E90C6C,
+ 0xC0AC29B7,0xC97C50DD,0x3F84D5B5,0xB5470917,0x9216D5D9,0x8979FB1B };
+
+
+
+#if BLOWFISH_ROUNDS != 16
+static inline u32
+function_F( BLOWFISH_context *bc, u32 x )
+{
+ u16 a, b, c, d;
+
+#ifdef WORDS_BIGENDIAN
+ a = ((byte*)&x)[0];
+ b = ((byte*)&x)[1];
+ c = ((byte*)&x)[2];
+ d = ((byte*)&x)[3];
+#else
+ a = ((byte*)&x)[3];
+ b = ((byte*)&x)[2];
+ c = ((byte*)&x)[1];
+ d = ((byte*)&x)[0];
+#endif
+
+ return ((bc->s0[a] + bc->s1[b]) ^ bc->s2[c] ) + bc->s3[d];
+}
+#endif
+
+#ifdef WORDS_BIGENDIAN
+#define F(x) ((( s0[((byte*)&x)[0]] + s1[((byte*)&x)[1]]) \
+ ^ s2[((byte*)&x)[2]]) + s3[((byte*)&x)[3]] )
+#else
+#define F(x) ((( s0[((byte*)&x)[3]] + s1[((byte*)&x)[2]]) \
+ ^ s2[((byte*)&x)[1]]) + s3[((byte*)&x)[0]] )
+#endif
+#define R(l,r,i) do { l ^= p[i]; r ^= F(l); } while(0)
+
+
+static void
+do_encrypt ( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
+{
+#if BLOWFISH_ROUNDS == 16
+ u32 xl, xr, *s0, *s1, *s2, *s3, *p;
+
+ xl = *ret_xl;
+ xr = *ret_xr;
+ p = bc->p;
+ s0 = bc->s0;
+ s1 = bc->s1;
+ s2 = bc->s2;
+ s3 = bc->s3;
+
+ R( xl, xr, 0);
+ R( xr, xl, 1);
+ R( xl, xr, 2);
+ R( xr, xl, 3);
+ R( xl, xr, 4);
+ R( xr, xl, 5);
+ R( xl, xr, 6);
+ R( xr, xl, 7);
+ R( xl, xr, 8);
+ R( xr, xl, 9);
+ R( xl, xr, 10);
+ R( xr, xl, 11);
+ R( xl, xr, 12);
+ R( xr, xl, 13);
+ R( xl, xr, 14);
+ R( xr, xl, 15);
+
+ xl ^= p[BLOWFISH_ROUNDS];
+ xr ^= p[BLOWFISH_ROUNDS+1];
+
+ *ret_xl = xr;
+ *ret_xr = xl;
+
+#else
+ u32 xl, xr, temp, *p;
+ int i;
+
+ xl = *ret_xl;
+ xr = *ret_xr;
+ p = bc->p;
+
+ for(i=0; i < BLOWFISH_ROUNDS; i++ )
+ {
+ xl ^= p[i];
+ xr ^= function_F(bc, xl);
+ temp = xl;
+ xl = xr;
+ xr = temp;
+ }
+ temp = xl;
+ xl = xr;
+ xr = temp;
+
+ xr ^= p[BLOWFISH_ROUNDS];
+ xl ^= p[BLOWFISH_ROUNDS+1];
+
+ *ret_xl = xl;
+ *ret_xr = xr;
+#endif
+}
+
+
+static void
+decrypt ( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
+{
+#if BLOWFISH_ROUNDS == 16
+ u32 xl, xr, *s0, *s1, *s2, *s3, *p;
+
+ xl = *ret_xl;
+ xr = *ret_xr;
+ p = bc->p;
+ s0 = bc->s0;
+ s1 = bc->s1;
+ s2 = bc->s2;
+ s3 = bc->s3;
+
+ R( xl, xr, 17);
+ R( xr, xl, 16);
+ R( xl, xr, 15);
+ R( xr, xl, 14);
+ R( xl, xr, 13);
+ R( xr, xl, 12);
+ R( xl, xr, 11);
+ R( xr, xl, 10);
+ R( xl, xr, 9);
+ R( xr, xl, 8);
+ R( xl, xr, 7);
+ R( xr, xl, 6);
+ R( xl, xr, 5);
+ R( xr, xl, 4);
+ R( xl, xr, 3);
+ R( xr, xl, 2);
+
+ xl ^= p[1];
+ xr ^= p[0];
+
+ *ret_xl = xr;
+ *ret_xr = xl;
+
+#else
+ u32 xl, xr, temp, *p;
+ int i;
+
+ xl = *ret_xl;
+ xr = *ret_xr;
+ p = bc->p;
+
+ for (i=BLOWFISH_ROUNDS+1; i > 1; i-- )
+ {
+ xl ^= p[i];
+ xr ^= function_F(bc, xl);
+ temp = xl;
+ xl = xr;
+ xr = temp;
+ }
+
+ temp = xl;
+ xl = xr;
+ xr = temp;
+
+ xr ^= p[1];
+ xl ^= p[0];
+
+ *ret_xl = xl;
+ *ret_xr = xr;
+#endif
+}
+
+#undef F
+#undef R
+
+static void
+do_encrypt_block ( BLOWFISH_context *bc, byte *outbuf, const byte *inbuf )
+{
+ u32 d1, d2;
+
+ d1 = inbuf[0] << 24 | inbuf[1] << 16 | inbuf[2] << 8 | inbuf[3];
+ d2 = inbuf[4] << 24 | inbuf[5] << 16 | inbuf[6] << 8 | inbuf[7];
+ do_encrypt( bc, &d1, &d2 );
+ outbuf[0] = (d1 >> 24) & 0xff;
+ outbuf[1] = (d1 >> 16) & 0xff;
+ outbuf[2] = (d1 >> 8) & 0xff;
+ outbuf[3] = d1 & 0xff;
+ outbuf[4] = (d2 >> 24) & 0xff;
+ outbuf[5] = (d2 >> 16) & 0xff;
+ outbuf[6] = (d2 >> 8) & 0xff;
+ outbuf[7] = d2 & 0xff;
+}
+
+static void
+encrypt_block (void *context, byte *outbuf, const byte *inbuf)
+{
+ BLOWFISH_context *bc = (BLOWFISH_context *) context;
+ do_encrypt_block (bc, outbuf, inbuf);
+ _gcry_burn_stack (64);
+}
+
+
+static void
+do_decrypt_block (BLOWFISH_context *bc, byte *outbuf, const byte *inbuf)
+{
+ u32 d1, d2;
+
+ d1 = inbuf[0] << 24 | inbuf[1] << 16 | inbuf[2] << 8 | inbuf[3];
+ d2 = inbuf[4] << 24 | inbuf[5] << 16 | inbuf[6] << 8 | inbuf[7];
+ decrypt( bc, &d1, &d2 );
+ outbuf[0] = (d1 >> 24) & 0xff;
+ outbuf[1] = (d1 >> 16) & 0xff;
+ outbuf[2] = (d1 >> 8) & 0xff;
+ outbuf[3] = d1 & 0xff;
+ outbuf[4] = (d2 >> 24) & 0xff;
+ outbuf[5] = (d2 >> 16) & 0xff;
+ outbuf[6] = (d2 >> 8) & 0xff;
+ outbuf[7] = d2 & 0xff;
+}
+
+static void
+decrypt_block (void *context, byte *outbuf, const byte *inbuf)
+{
+ BLOWFISH_context *bc = (BLOWFISH_context *) context;
+ do_decrypt_block (bc, outbuf, inbuf);
+ _gcry_burn_stack (64);
+}
+
+
+static const char*
+selftest(void)
+{
+ BLOWFISH_context c;
+ byte plain[] = "BLOWFISH";
+ byte buffer[8];
+ byte plain3[] = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 };
+ byte key3[] = { 0x41, 0x79, 0x6E, 0xA0, 0x52, 0x61, 0x6E, 0xE4 };
+ byte cipher3[] = { 0xE1, 0x13, 0xF4, 0x10, 0x2C, 0xFC, 0xCE, 0x43 };
+
+ bf_setkey( (void *) &c,
+ (const unsigned char*)"abcdefghijklmnopqrstuvwxyz", 26 );
+ encrypt_block( (void *) &c, buffer, plain );
+ if( memcmp( buffer, "\x32\x4E\xD0\xFE\xF4\x13\xA2\x03", 8 ) )
+ return "Blowfish selftest failed (1).";
+ decrypt_block( (void *) &c, buffer, buffer );
+ if( memcmp( buffer, plain, 8 ) )
+ return "Blowfish selftest failed (2).";
+
+ bf_setkey( (void *) &c, key3, 8 );
+ encrypt_block( (void *) &c, buffer, plain3 );
+ if( memcmp( buffer, cipher3, 8 ) )
+ return "Blowfish selftest failed (3).";
+ decrypt_block( (void *) &c, buffer, buffer );
+ if( memcmp( buffer, plain3, 8 ) )
+ return "Blowfish selftest failed (4).";
+ return NULL;
+}
+
+
+
+static gcry_err_code_t
+do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen)
+{
+ int i, j;
+ u32 data, datal, datar;
+ static int initialized;
+ static const char *selftest_failed;
+
+ if( !initialized )
+ {
+ initialized = 1;
+ selftest_failed = selftest();
+ if( selftest_failed )
+ log_error ("%s\n", selftest_failed );
+ }
+ if( selftest_failed )
+ return GPG_ERR_SELFTEST_FAILED;
+
+ for(i=0; i < BLOWFISH_ROUNDS+2; i++ )
+ c->p[i] = ps[i];
+ for(i=0; i < 256; i++ )
+ {
+ c->s0[i] = ks0[i];
+ c->s1[i] = ks1[i];
+ c->s2[i] = ks2[i];
+ c->s3[i] = ks3[i];
+ }
+
+ for(i=j=0; i < BLOWFISH_ROUNDS+2; i++ )
+ {
+#ifdef WORDS_BIGENDIAN
+ ((byte*)&data)[0] = key[j];
+ ((byte*)&data)[1] = key[(j+1)%keylen];
+ ((byte*)&data)[2] = key[(j+2)%keylen];
+ ((byte*)&data)[3] = key[(j+3)%keylen];
+#else
+ ((byte*)&data)[3] = key[j];
+ ((byte*)&data)[2] = key[(j+1)%keylen];
+ ((byte*)&data)[1] = key[(j+2)%keylen];
+ ((byte*)&data)[0] = key[(j+3)%keylen];
+#endif
+ c->p[i] ^= data;
+ j = (j+4) % keylen;
+ }
+
+ datal = datar = 0;
+ for(i=0; i < BLOWFISH_ROUNDS+2; i += 2 )
+ {
+ do_encrypt( c, &datal, &datar );
+ c->p[i] = datal;
+ c->p[i+1] = datar;
+ }
+ for(i=0; i < 256; i += 2 )
+ {
+ do_encrypt( c, &datal, &datar );
+ c->s0[i] = datal;
+ c->s0[i+1] = datar;
+ }
+ for(i=0; i < 256; i += 2 )
+ {
+ do_encrypt( c, &datal, &datar );
+ c->s1[i] = datal;
+ c->s1[i+1] = datar;
+ }
+ for(i=0; i < 256; i += 2 )
+ {
+ do_encrypt( c, &datal, &datar );
+ c->s2[i] = datal;
+ c->s2[i+1] = datar;
+ }
+ for(i=0; i < 256; i += 2 )
+ {
+ do_encrypt( c, &datal, &datar );
+ c->s3[i] = datal;
+ c->s3[i+1] = datar;
+ }
+
+
+ /* Check for weak key. A weak key is a key in which a value in
+ the P-array (here c) occurs more than once per table. */
+ for(i=0; i < 255; i++ )
+ {
+ for( j=i+1; j < 256; j++)
+ {
+ if( (c->s0[i] == c->s0[j]) || (c->s1[i] == c->s1[j]) ||
+ (c->s2[i] == c->s2[j]) || (c->s3[i] == c->s3[j]) )
+ return GPG_ERR_WEAK_KEY;
+ }
+ }
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+static gcry_err_code_t
+bf_setkey (void *context, const byte *key, unsigned keylen)
+{
+ BLOWFISH_context *c = (BLOWFISH_context *) context;
+ gcry_err_code_t rc = do_bf_setkey (c, key, keylen);
+ _gcry_burn_stack (64);
+ return rc;
+}
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_blowfish =
+ {
+ "BLOWFISH", NULL, NULL, BLOWFISH_BLOCKSIZE, 128,
+ sizeof (BLOWFISH_context),
+ bf_setkey, encrypt_block, decrypt_block
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/bufhelp.h b/grub-core/lib/libgcrypt/cipher/bufhelp.h
new file mode 100644
index 0000000..df35594
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/bufhelp.h
@@ -0,0 +1,432 @@
+/* bufhelp.h - Some buffer manipulation helpers
+ * Copyright (C) 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef GCRYPT_BUFHELP_H
+#define GCRYPT_BUFHELP_H
+
+
+#include "bithelp.h"
+
+
+#undef BUFHELP_FAST_UNALIGNED_ACCESS
+#if defined(HAVE_GCC_ATTRIBUTE_PACKED) && \
+ defined(HAVE_GCC_ATTRIBUTE_ALIGNED) && \
+ (defined(__i386__) || defined(__x86_64__) || \
+ (defined(__arm__) && defined(__ARM_FEATURE_UNALIGNED)) || \
+ defined(__aarch64__))
+/* These architectures are able of unaligned memory accesses and can
+ handle those fast.
+ */
+# define BUFHELP_FAST_UNALIGNED_ACCESS 1
+#endif
+
+
+#ifdef BUFHELP_FAST_UNALIGNED_ACCESS
+/* Define type with one-byte alignment on architectures with fast unaligned
+ memory accesses.
+ */
+typedef struct bufhelp_int_s
+{
+ uintptr_t a;
+} __attribute__((packed, aligned(1))) bufhelp_int_t;
+#else
+/* Define type with default alignment for other architectures (unaligned
+ accessed handled in per byte loops).
+ */
+typedef struct bufhelp_int_s
+{
+ uintptr_t a;
+} bufhelp_int_t;
+#endif
+
+
+/* Optimized function for small buffer copying */
+static inline void
+buf_cpy(void *_dst, const void *_src, size_t len)
+{
+#if __GNUC__ >= 4 && (defined(__x86_64__) || defined(__i386__))
+ /* For AMD64 and i386, memcpy is faster. */
+ memcpy(_dst, _src, len);
+#else
+ byte *dst = _dst;
+ const byte *src = _src;
+ bufhelp_int_t *ldst;
+ const bufhelp_int_t *lsrc;
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1;
+
+ /* Skip fast processing if buffers are unaligned. */
+ if (((uintptr_t)dst | (uintptr_t)src) & longmask)
+ goto do_bytes;
+#endif
+
+ ldst = (bufhelp_int_t *)(void *)dst;
+ lsrc = (const bufhelp_int_t *)(const void *)src;
+
+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t))
+ (ldst++)->a = (lsrc++)->a;
+
+ dst = (byte *)ldst;
+ src = (const byte *)lsrc;
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+do_bytes:
+#endif
+ /* Handle tail. */
+ for (; len; len--)
+ *dst++ = *src++;
+#endif /*__GNUC__ >= 4 && (__x86_64__ || __i386__)*/
+}
+
+
+/* Optimized function for buffer xoring */
+static inline void
+buf_xor(void *_dst, const void *_src1, const void *_src2, size_t len)
+{
+ byte *dst = _dst;
+ const byte *src1 = _src1;
+ const byte *src2 = _src2;
+ bufhelp_int_t *ldst;
+ const bufhelp_int_t *lsrc1, *lsrc2;
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1;
+
+ /* Skip fast processing if buffers are unaligned. */
+ if (((uintptr_t)dst | (uintptr_t)src1 | (uintptr_t)src2) & longmask)
+ goto do_bytes;
+#endif
+
+ ldst = (bufhelp_int_t *)(void *)dst;
+ lsrc1 = (const bufhelp_int_t *)(const void *)src1;
+ lsrc2 = (const bufhelp_int_t *)(const void *)src2;
+
+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t))
+ (ldst++)->a = (lsrc1++)->a ^ (lsrc2++)->a;
+
+ dst = (byte *)ldst;
+ src1 = (const byte *)lsrc1;
+ src2 = (const byte *)lsrc2;
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+do_bytes:
+#endif
+ /* Handle tail. */
+ for (; len; len--)
+ *dst++ = *src1++ ^ *src2++;
+}
+
+
+/* Optimized function for in-place buffer xoring. */
+static inline void
+buf_xor_1(void *_dst, const void *_src, size_t len)
+{
+ byte *dst = _dst;
+ const byte *src = _src;
+ bufhelp_int_t *ldst;
+ const bufhelp_int_t *lsrc;
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1;
+
+ /* Skip fast processing if buffers are unaligned. */
+ if (((uintptr_t)dst | (uintptr_t)src) & longmask)
+ goto do_bytes;
+#endif
+
+ ldst = (bufhelp_int_t *)(void *)dst;
+ lsrc = (const bufhelp_int_t *)(const void *)src;
+
+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t))
+ (ldst++)->a ^= (lsrc++)->a;
+
+ dst = (byte *)ldst;
+ src = (const byte *)lsrc;
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+do_bytes:
+#endif
+ /* Handle tail. */
+ for (; len; len--)
+ *dst++ ^= *src++;
+}
+
+
+/* Optimized function for buffer xoring with two destination buffers. Used
+ mainly by CFB mode encryption. */
+static inline void
+buf_xor_2dst(void *_dst1, void *_dst2, const void *_src, size_t len)
+{
+ byte *dst1 = _dst1;
+ byte *dst2 = _dst2;
+ const byte *src = _src;
+ bufhelp_int_t *ldst1, *ldst2;
+ const bufhelp_int_t *lsrc;
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1;
+
+ /* Skip fast processing if buffers are unaligned. */
+ if (((uintptr_t)src | (uintptr_t)dst1 | (uintptr_t)dst2) & longmask)
+ goto do_bytes;
+#endif
+
+ ldst1 = (bufhelp_int_t *)(void *)dst1;
+ ldst2 = (bufhelp_int_t *)(void *)dst2;
+ lsrc = (const bufhelp_int_t *)(const void *)src;
+
+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t))
+ (ldst1++)->a = ((ldst2++)->a ^= (lsrc++)->a);
+
+ dst1 = (byte *)ldst1;
+ dst2 = (byte *)ldst2;
+ src = (const byte *)lsrc;
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+do_bytes:
+#endif
+ /* Handle tail. */
+ for (; len; len--)
+ *dst1++ = (*dst2++ ^= *src++);
+}
+
+
+/* Optimized function for combined buffer xoring and copying. Used by mainly
+ CBC mode decryption. */
+static inline void
+buf_xor_n_copy_2(void *_dst_xor, const void *_src_xor, void *_srcdst_cpy,
+ const void *_src_cpy, size_t len)
+{
+ byte *dst_xor = _dst_xor;
+ byte *srcdst_cpy = _srcdst_cpy;
+ const byte *src_xor = _src_xor;
+ const byte *src_cpy = _src_cpy;
+ byte temp;
+ bufhelp_int_t *ldst_xor, *lsrcdst_cpy;
+ const bufhelp_int_t *lsrc_cpy, *lsrc_xor;
+ uintptr_t ltemp;
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1;
+
+ /* Skip fast processing if buffers are unaligned. */
+ if (((uintptr_t)src_cpy | (uintptr_t)src_xor | (uintptr_t)dst_xor |
+ (uintptr_t)srcdst_cpy) & longmask)
+ goto do_bytes;
+#endif
+
+ ldst_xor = (bufhelp_int_t *)(void *)dst_xor;
+ lsrc_xor = (const bufhelp_int_t *)(void *)src_xor;
+ lsrcdst_cpy = (bufhelp_int_t *)(void *)srcdst_cpy;
+ lsrc_cpy = (const bufhelp_int_t *)(const void *)src_cpy;
+
+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t))
+ {
+ ltemp = (lsrc_cpy++)->a;
+ (ldst_xor++)->a = (lsrcdst_cpy)->a ^ (lsrc_xor++)->a;
+ (lsrcdst_cpy++)->a = ltemp;
+ }
+
+ dst_xor = (byte *)ldst_xor;
+ src_xor = (const byte *)lsrc_xor;
+ srcdst_cpy = (byte *)lsrcdst_cpy;
+ src_cpy = (const byte *)lsrc_cpy;
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+do_bytes:
+#endif
+ /* Handle tail. */
+ for (; len; len--)
+ {
+ temp = *src_cpy++;
+ *dst_xor++ = *srcdst_cpy ^ *src_xor++;
+ *srcdst_cpy++ = temp;
+ }
+}
+
+
+/* Optimized function for combined buffer xoring and copying. Used by mainly
+ CFB mode decryption. */
+static inline void
+buf_xor_n_copy(void *_dst_xor, void *_srcdst_cpy, const void *_src, size_t len)
+{
+ buf_xor_n_copy_2(_dst_xor, _src, _srcdst_cpy, _src, len);
+}
+
+
+/* Constant-time compare of two buffers. Returns 1 if buffers are equal,
+ and 0 if buffers differ. */
+static inline int
+buf_eq_const(const void *_a, const void *_b, size_t len)
+{
+ const byte *a = _a;
+ const byte *b = _b;
+ size_t diff, i;
+
+ /* Constant-time compare. */
+ for (i = 0, diff = 0; i < len; i++)
+ diff -= !!(a[i] - b[i]);
+
+ return !diff;
+}
+
+
+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+
+/* Functions for loading and storing unaligned u32 values of different
+ endianness. */
+static inline u32 buf_get_be32(const void *_buf)
+{
+ const byte *in = _buf;
+ return ((u32)in[0] << 24) | ((u32)in[1] << 16) | \
+ ((u32)in[2] << 8) | (u32)in[3];
+}
+
+static inline u32 buf_get_le32(const void *_buf)
+{
+ const byte *in = _buf;
+ return ((u32)in[3] << 24) | ((u32)in[2] << 16) | \
+ ((u32)in[1] << 8) | (u32)in[0];
+}
+
+static inline void buf_put_be32(void *_buf, u32 val)
+{
+ byte *out = _buf;
+ out[0] = val >> 24;
+ out[1] = val >> 16;
+ out[2] = val >> 8;
+ out[3] = val;
+}
+
+static inline void buf_put_le32(void *_buf, u32 val)
+{
+ byte *out = _buf;
+ out[3] = val >> 24;
+ out[2] = val >> 16;
+ out[1] = val >> 8;
+ out[0] = val;
+}
+
+
+/* Functions for loading and storing unaligned u64 values of different
+ endianness. */
+static inline u64 buf_get_be64(const void *_buf)
+{
+ const byte *in = _buf;
+ return ((u64)in[0] << 56) | ((u64)in[1] << 48) | \
+ ((u64)in[2] << 40) | ((u64)in[3] << 32) | \
+ ((u64)in[4] << 24) | ((u64)in[5] << 16) | \
+ ((u64)in[6] << 8) | (u64)in[7];
+}
+
+static inline u64 buf_get_le64(const void *_buf)
+{
+ const byte *in = _buf;
+ return ((u64)in[7] << 56) | ((u64)in[6] << 48) | \
+ ((u64)in[5] << 40) | ((u64)in[4] << 32) | \
+ ((u64)in[3] << 24) | ((u64)in[2] << 16) | \
+ ((u64)in[1] << 8) | (u64)in[0];
+}
+
+static inline void buf_put_be64(void *_buf, u64 val)
+{
+ byte *out = _buf;
+ out[0] = val >> 56;
+ out[1] = val >> 48;
+ out[2] = val >> 40;
+ out[3] = val >> 32;
+ out[4] = val >> 24;
+ out[5] = val >> 16;
+ out[6] = val >> 8;
+ out[7] = val;
+}
+
+static inline void buf_put_le64(void *_buf, u64 val)
+{
+ byte *out = _buf;
+ out[7] = val >> 56;
+ out[6] = val >> 48;
+ out[5] = val >> 40;
+ out[4] = val >> 32;
+ out[3] = val >> 24;
+ out[2] = val >> 16;
+ out[1] = val >> 8;
+ out[0] = val;
+}
+
+#else /*BUFHELP_FAST_UNALIGNED_ACCESS*/
+
+typedef struct bufhelp_u32_s
+{
+ u32 a;
+} __attribute__((packed, aligned(1))) bufhelp_u32_t;
+
+/* Functions for loading and storing unaligned u32 values of different
+ endianness. */
+static inline u32 buf_get_be32(const void *_buf)
+{
+ return be_bswap32(((const bufhelp_u32_t *)_buf)->a);
+}
+
+static inline u32 buf_get_le32(const void *_buf)
+{
+ return le_bswap32(((const bufhelp_u32_t *)_buf)->a);
+}
+
+static inline void buf_put_be32(void *_buf, u32 val)
+{
+ bufhelp_u32_t *out = _buf;
+ out->a = be_bswap32(val);
+}
+
+static inline void buf_put_le32(void *_buf, u32 val)
+{
+ bufhelp_u32_t *out = _buf;
+ out->a = le_bswap32(val);
+}
+
+
+typedef struct bufhelp_u64_s
+{
+ u64 a;
+} __attribute__((packed, aligned(1))) bufhelp_u64_t;
+
+/* Functions for loading and storing unaligned u64 values of different
+ endianness. */
+static inline u64 buf_get_be64(const void *_buf)
+{
+ return be_bswap64(((const bufhelp_u64_t *)_buf)->a);
+}
+
+static inline u64 buf_get_le64(const void *_buf)
+{
+ return le_bswap64(((const bufhelp_u64_t *)_buf)->a);
+}
+
+static inline void buf_put_be64(void *_buf, u64 val)
+{
+ bufhelp_u64_t *out = _buf;
+ out->a = be_bswap64(val);
+}
+
+static inline void buf_put_le64(void *_buf, u64 val)
+{
+ bufhelp_u64_t *out = _buf;
+ out->a = le_bswap64(val);
+}
+
+
+#endif /*BUFHELP_FAST_UNALIGNED_ACCESS*/
+
+#endif /*GCRYPT_BUFHELP_H*/
diff --git a/grub-core/lib/libgcrypt/cipher/camellia-glue.c b/grub-core/lib/libgcrypt/cipher/camellia-glue.c
new file mode 100644
index 0000000..a263621
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/camellia-glue.c
@@ -0,0 +1,253 @@
+/* camellia-glue.c - Glue for the Camellia cipher
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+/* I put all the libgcrypt-specific stuff in this file to keep the
+ camellia.c/camellia.h files exactly as provided by NTT. If they
+ update their code, this should make it easier to bring the changes
+ in. - dshaw
+
+ There is one small change which needs to be done: Include the
+ following code at the top of camellia.h: */
+#if 0
+
+/* To use Camellia with libraries it is often useful to keep the name
+ * space of the library clean. The following macro is thus useful:
+ *
+ * #define CAMELLIA_EXT_SYM_PREFIX foo_
+ *
+ * This prefixes all external symbols with "foo_".
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef CAMELLIA_EXT_SYM_PREFIX
+#define CAMELLIA_PREFIX1(x,y) x ## y
+#define CAMELLIA_PREFIX2(x,y) CAMELLIA_PREFIX1(x,y)
+#define CAMELLIA_PREFIX(x) CAMELLIA_PREFIX2(CAMELLIA_EXT_SYM_PREFIX,x)
+#define Camellia_Ekeygen CAMELLIA_PREFIX(Camellia_Ekeygen)
+#define Camellia_EncryptBlock CAMELLIA_PREFIX(Camellia_EncryptBlock)
+#define Camellia_DecryptBlock CAMELLIA_PREFIX(Camellia_DecryptBlock)
+#define camellia_decrypt128 CAMELLIA_PREFIX(camellia_decrypt128)
+#define camellia_decrypt256 CAMELLIA_PREFIX(camellia_decrypt256)
+#define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128)
+#define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256)
+#define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128)
+#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192)
+#define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256)
+#endif /*CAMELLIA_EXT_SYM_PREFIX*/
+
+#endif /* Code sample. */
+
+
+#include <config.h>
+#include "types.h"
+#include "g10lib.h"
+#include "cipher.h"
+#include "camellia.h"
+
+typedef struct
+{
+ int keybitlength;
+ KEY_TABLE_TYPE keytable;
+} CAMELLIA_context;
+
+static const char *selftest(void);
+
+static gcry_err_code_t
+camellia_setkey(void *c, const byte *key, unsigned keylen)
+{
+ CAMELLIA_context *ctx=c;
+ static int initialized=0;
+ static const char *selftest_failed=NULL;
+
+ if(keylen!=16 && keylen!=24 && keylen!=32)
+ return GPG_ERR_INV_KEYLEN;
+
+ if(!initialized)
+ {
+ initialized=1;
+ selftest_failed=selftest();
+ if(selftest_failed)
+ log_error("%s\n",selftest_failed);
+ }
+
+ if(selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ ctx->keybitlength=keylen*8;
+ Camellia_Ekeygen(ctx->keybitlength,key,ctx->keytable);
+ _gcry_burn_stack
+ ((19+34+34)*sizeof(u32)+2*sizeof(void*) /* camellia_setup256 */
+ +(4+32)*sizeof(u32)+2*sizeof(void*) /* camellia_setup192 */
+ +0+sizeof(int)+2*sizeof(void*) /* Camellia_Ekeygen */
+ +3*2*sizeof(void*) /* Function calls. */
+ );
+
+ return 0;
+}
+
+static void
+camellia_encrypt(void *c, byte *outbuf, const byte *inbuf)
+{
+ CAMELLIA_context *ctx=c;
+
+ Camellia_EncryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf);
+ _gcry_burn_stack
+ (sizeof(int)+2*sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE)
+ +4*sizeof(u32)
+ +2*sizeof(u32*)+4*sizeof(u32)
+ +2*2*sizeof(void*) /* Function calls. */
+ );
+}
+
+static void
+camellia_decrypt(void *c, byte *outbuf, const byte *inbuf)
+{
+ CAMELLIA_context *ctx=c;
+
+ Camellia_DecryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf);
+ _gcry_burn_stack
+ (sizeof(int)+2*sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE)
+ +4*sizeof(u32)
+ +2*sizeof(u32*)+4*sizeof(u32)
+ +2*2*sizeof(void*) /* Function calls. */
+ );
+}
+
+static const char *
+selftest(void)
+{
+ CAMELLIA_context ctx;
+ byte scratch[16];
+
+ /* These test vectors are from RFC-3713 */
+ const byte plaintext[]=
+ {
+ 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
+ 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10
+ };
+ const byte key_128[]=
+ {
+ 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
+ 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10
+ };
+ const byte ciphertext_128[]=
+ {
+ 0x67,0x67,0x31,0x38,0x54,0x96,0x69,0x73,
+ 0x08,0x57,0x06,0x56,0x48,0xea,0xbe,0x43
+ };
+ const byte key_192[]=
+ {
+ 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98,
+ 0x76,0x54,0x32,0x10,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77
+ };
+ const byte ciphertext_192[]=
+ {
+ 0xb4,0x99,0x34,0x01,0xb3,0xe9,0x96,0xf8,
+ 0x4e,0xe5,0xce,0xe7,0xd7,0x9b,0x09,0xb9
+ };
+ const byte key_256[]=
+ {
+ 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,
+ 0x98,0x76,0x54,0x32,0x10,0x00,0x11,0x22,0x33,0x44,0x55,
+ 0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff
+ };
+ const byte ciphertext_256[]=
+ {
+ 0x9a,0xcc,0x23,0x7d,0xff,0x16,0xd7,0x6c,
+ 0x20,0xef,0x7c,0x91,0x9e,0x3a,0x75,0x09
+ };
+
+ camellia_setkey(&ctx,key_128,sizeof(key_128));
+ camellia_encrypt(&ctx,scratch,plaintext);
+ if(memcmp(scratch,ciphertext_128,sizeof(ciphertext_128))!=0)
+ return "CAMELLIA-128 test encryption failed.";
+ camellia_decrypt(&ctx,scratch,scratch);
+ if(memcmp(scratch,plaintext,sizeof(plaintext))!=0)
+ return "CAMELLIA-128 test decryption failed.";
+
+ camellia_setkey(&ctx,key_192,sizeof(key_192));
+ camellia_encrypt(&ctx,scratch,plaintext);
+ if(memcmp(scratch,ciphertext_192,sizeof(ciphertext_192))!=0)
+ return "CAMELLIA-192 test encryption failed.";
+ camellia_decrypt(&ctx,scratch,scratch);
+ if(memcmp(scratch,plaintext,sizeof(plaintext))!=0)
+ return "CAMELLIA-192 test decryption failed.";
+
+ camellia_setkey(&ctx,key_256,sizeof(key_256));
+ camellia_encrypt(&ctx,scratch,plaintext);
+ if(memcmp(scratch,ciphertext_256,sizeof(ciphertext_256))!=0)
+ return "CAMELLIA-256 test encryption failed.";
+ camellia_decrypt(&ctx,scratch,scratch);
+ if(memcmp(scratch,plaintext,sizeof(plaintext))!=0)
+ return "CAMELLIA-256 test decryption failed.";
+
+ return NULL;
+}
+
+/* These oids are from
+ <http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications_oid.html>,
+ retrieved May 1, 2007. */
+
+static gcry_cipher_oid_spec_t camellia128_oids[] =
+ {
+ {"1.2.392.200011.61.1.1.1.2", GCRY_CIPHER_MODE_CBC},
+ {"0.3.4401.5.3.1.9.1", GCRY_CIPHER_MODE_ECB},
+ {"0.3.4401.5.3.1.9.3", GCRY_CIPHER_MODE_OFB},
+ {"0.3.4401.5.3.1.9.4", GCRY_CIPHER_MODE_CFB},
+ { NULL }
+ };
+
+static gcry_cipher_oid_spec_t camellia192_oids[] =
+ {
+ {"1.2.392.200011.61.1.1.1.3", GCRY_CIPHER_MODE_CBC},
+ {"0.3.4401.5.3.1.9.21", GCRY_CIPHER_MODE_ECB},
+ {"0.3.4401.5.3.1.9.23", GCRY_CIPHER_MODE_OFB},
+ {"0.3.4401.5.3.1.9.24", GCRY_CIPHER_MODE_CFB},
+ { NULL }
+ };
+
+static gcry_cipher_oid_spec_t camellia256_oids[] =
+ {
+ {"1.2.392.200011.61.1.1.1.4", GCRY_CIPHER_MODE_CBC},
+ {"0.3.4401.5.3.1.9.41", GCRY_CIPHER_MODE_ECB},
+ {"0.3.4401.5.3.1.9.43", GCRY_CIPHER_MODE_OFB},
+ {"0.3.4401.5.3.1.9.44", GCRY_CIPHER_MODE_CFB},
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_camellia128 =
+ {
+ "CAMELLIA128",NULL,camellia128_oids,CAMELLIA_BLOCK_SIZE,128,
+ sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_camellia192 =
+ {
+ "CAMELLIA192",NULL,camellia192_oids,CAMELLIA_BLOCK_SIZE,192,
+ sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_camellia256 =
+ {
+ "CAMELLIA256",NULL,camellia256_oids,CAMELLIA_BLOCK_SIZE,256,
+ sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/camellia.c b/grub-core/lib/libgcrypt/cipher/camellia.c
new file mode 100644
index 0000000..2e28bce
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/camellia.c
@@ -0,0 +1,1461 @@
+/* camellia.h ver 1.2.0
+ *
+ * Copyright (C) 2006,2007
+ * NTT (Nippon Telegraph and Telephone Corporation).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Algorithm Specification
+ * http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "camellia.h"
+
+/* u32 must be 32bit word */
+typedef unsigned int u32;
+typedef unsigned char u8;
+
+/* key constants */
+
+#define CAMELLIA_SIGMA1L (0xA09E667FL)
+#define CAMELLIA_SIGMA1R (0x3BCC908BL)
+#define CAMELLIA_SIGMA2L (0xB67AE858L)
+#define CAMELLIA_SIGMA2R (0x4CAA73B2L)
+#define CAMELLIA_SIGMA3L (0xC6EF372FL)
+#define CAMELLIA_SIGMA3R (0xE94F82BEL)
+#define CAMELLIA_SIGMA4L (0x54FF53A5L)
+#define CAMELLIA_SIGMA4R (0xF1D36F1CL)
+#define CAMELLIA_SIGMA5L (0x10E527FAL)
+#define CAMELLIA_SIGMA5R (0xDE682D1DL)
+#define CAMELLIA_SIGMA6L (0xB05688C2L)
+#define CAMELLIA_SIGMA6R (0xB3E6C1FDL)
+
+/*
+ * macros
+ */
+
+
+#if defined(_MSC_VER)
+
+# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
+# define GETU32(p) SWAP(*((u32 *)(p)))
+# define PUTU32(ct, st) {*((u32 *)(ct)) = SWAP((st));}
+
+#else /* not MS-VC */
+
+# define GETU32(pt) \
+ (((u32)(pt)[0] << 24) \
+ ^ ((u32)(pt)[1] << 16) \
+ ^ ((u32)(pt)[2] << 8) \
+ ^ ((u32)(pt)[3]))
+
+# define PUTU32(ct, st) { \
+ (ct)[0] = (u8)((st) >> 24); \
+ (ct)[1] = (u8)((st) >> 16); \
+ (ct)[2] = (u8)((st) >> 8); \
+ (ct)[3] = (u8)(st); }
+
+#endif
+
+#define CamelliaSubkeyL(INDEX) (subkey[(INDEX)*2])
+#define CamelliaSubkeyR(INDEX) (subkey[(INDEX)*2 + 1])
+
+/* rotation right shift 1byte */
+#define CAMELLIA_RR8(x) (((x) >> 8) + ((x) << 24))
+/* rotation left shift 1bit */
+#define CAMELLIA_RL1(x) (((x) << 1) + ((x) >> 31))
+/* rotation left shift 1byte */
+#define CAMELLIA_RL8(x) (((x) << 8) + ((x) >> 24))
+
+#define CAMELLIA_ROLDQ(ll, lr, rl, rr, w0, w1, bits) \
+ do { \
+ w0 = ll; \
+ ll = (ll << bits) + (lr >> (32 - bits)); \
+ lr = (lr << bits) + (rl >> (32 - bits)); \
+ rl = (rl << bits) + (rr >> (32 - bits)); \
+ rr = (rr << bits) + (w0 >> (32 - bits)); \
+ } while(0)
+
+#define CAMELLIA_ROLDQo32(ll, lr, rl, rr, w0, w1, bits) \
+ do { \
+ w0 = ll; \
+ w1 = lr; \
+ ll = (lr << (bits - 32)) + (rl >> (64 - bits)); \
+ lr = (rl << (bits - 32)) + (rr >> (64 - bits)); \
+ rl = (rr << (bits - 32)) + (w0 >> (64 - bits)); \
+ rr = (w0 << (bits - 32)) + (w1 >> (64 - bits)); \
+ } while(0)
+
+#define CAMELLIA_SP1110(INDEX) (camellia_sp1110[(INDEX)])
+#define CAMELLIA_SP0222(INDEX) (camellia_sp0222[(INDEX)])
+#define CAMELLIA_SP3033(INDEX) (camellia_sp3033[(INDEX)])
+#define CAMELLIA_SP4404(INDEX) (camellia_sp4404[(INDEX)])
+
+#define CAMELLIA_F(xl, xr, kl, kr, yl, yr, il, ir, t0, t1) \
+ do { \
+ il = xl ^ kl; \
+ ir = xr ^ kr; \
+ t0 = il >> 16; \
+ t1 = ir >> 16; \
+ yl = CAMELLIA_SP1110(ir & 0xff) \
+ ^ CAMELLIA_SP0222((t1 >> 8) & 0xff) \
+ ^ CAMELLIA_SP3033(t1 & 0xff) \
+ ^ CAMELLIA_SP4404((ir >> 8) & 0xff); \
+ yr = CAMELLIA_SP1110((t0 >> 8) & 0xff) \
+ ^ CAMELLIA_SP0222(t0 & 0xff) \
+ ^ CAMELLIA_SP3033((il >> 8) & 0xff) \
+ ^ CAMELLIA_SP4404(il & 0xff); \
+ yl ^= yr; \
+ yr = CAMELLIA_RR8(yr); \
+ yr ^= yl; \
+ } while(0)
+
+
+/*
+ * for speed up
+ *
+ */
+#define CAMELLIA_FLS(ll, lr, rl, rr, kll, klr, krl, krr, t0, t1, t2, t3) \
+ do { \
+ t0 = kll; \
+ t0 &= ll; \
+ lr ^= CAMELLIA_RL1(t0); \
+ t1 = klr; \
+ t1 |= lr; \
+ ll ^= t1; \
+ \
+ t2 = krr; \
+ t2 |= rr; \
+ rl ^= t2; \
+ t3 = krl; \
+ t3 &= rl; \
+ rr ^= CAMELLIA_RL1(t3); \
+ } while(0)
+
+#define CAMELLIA_ROUNDSM(xl, xr, kl, kr, yl, yr, il, ir, t0, t1) \
+ do { \
+ ir = CAMELLIA_SP1110(xr & 0xff) \
+ ^ CAMELLIA_SP0222((xr >> 24) & 0xff) \
+ ^ CAMELLIA_SP3033((xr >> 16) & 0xff) \
+ ^ CAMELLIA_SP4404((xr >> 8) & 0xff); \
+ il = CAMELLIA_SP1110((xl >> 24) & 0xff) \
+ ^ CAMELLIA_SP0222((xl >> 16) & 0xff) \
+ ^ CAMELLIA_SP3033((xl >> 8) & 0xff) \
+ ^ CAMELLIA_SP4404(xl & 0xff); \
+ il ^= kl; \
+ ir ^= kr; \
+ ir ^= il; \
+ il = CAMELLIA_RR8(il); \
+ il ^= ir; \
+ yl ^= ir; \
+ yr ^= il; \
+ } while(0)
+
+
+static const u32 camellia_sp1110[256] = {
+ 0x70707000,0x82828200,0x2c2c2c00,0xececec00,
+ 0xb3b3b300,0x27272700,0xc0c0c000,0xe5e5e500,
+ 0xe4e4e400,0x85858500,0x57575700,0x35353500,
+ 0xeaeaea00,0x0c0c0c00,0xaeaeae00,0x41414100,
+ 0x23232300,0xefefef00,0x6b6b6b00,0x93939300,
+ 0x45454500,0x19191900,0xa5a5a500,0x21212100,
+ 0xededed00,0x0e0e0e00,0x4f4f4f00,0x4e4e4e00,
+ 0x1d1d1d00,0x65656500,0x92929200,0xbdbdbd00,
+ 0x86868600,0xb8b8b800,0xafafaf00,0x8f8f8f00,
+ 0x7c7c7c00,0xebebeb00,0x1f1f1f00,0xcecece00,
+ 0x3e3e3e00,0x30303000,0xdcdcdc00,0x5f5f5f00,
+ 0x5e5e5e00,0xc5c5c500,0x0b0b0b00,0x1a1a1a00,
+ 0xa6a6a600,0xe1e1e100,0x39393900,0xcacaca00,
+ 0xd5d5d500,0x47474700,0x5d5d5d00,0x3d3d3d00,
+ 0xd9d9d900,0x01010100,0x5a5a5a00,0xd6d6d600,
+ 0x51515100,0x56565600,0x6c6c6c00,0x4d4d4d00,
+ 0x8b8b8b00,0x0d0d0d00,0x9a9a9a00,0x66666600,
+ 0xfbfbfb00,0xcccccc00,0xb0b0b000,0x2d2d2d00,
+ 0x74747400,0x12121200,0x2b2b2b00,0x20202000,
+ 0xf0f0f000,0xb1b1b100,0x84848400,0x99999900,
+ 0xdfdfdf00,0x4c4c4c00,0xcbcbcb00,0xc2c2c200,
+ 0x34343400,0x7e7e7e00,0x76767600,0x05050500,
+ 0x6d6d6d00,0xb7b7b700,0xa9a9a900,0x31313100,
+ 0xd1d1d100,0x17171700,0x04040400,0xd7d7d700,
+ 0x14141400,0x58585800,0x3a3a3a00,0x61616100,
+ 0xdedede00,0x1b1b1b00,0x11111100,0x1c1c1c00,
+ 0x32323200,0x0f0f0f00,0x9c9c9c00,0x16161600,
+ 0x53535300,0x18181800,0xf2f2f200,0x22222200,
+ 0xfefefe00,0x44444400,0xcfcfcf00,0xb2b2b200,
+ 0xc3c3c300,0xb5b5b500,0x7a7a7a00,0x91919100,
+ 0x24242400,0x08080800,0xe8e8e800,0xa8a8a800,
+ 0x60606000,0xfcfcfc00,0x69696900,0x50505000,
+ 0xaaaaaa00,0xd0d0d000,0xa0a0a000,0x7d7d7d00,
+ 0xa1a1a100,0x89898900,0x62626200,0x97979700,
+ 0x54545400,0x5b5b5b00,0x1e1e1e00,0x95959500,
+ 0xe0e0e000,0xffffff00,0x64646400,0xd2d2d200,
+ 0x10101000,0xc4c4c400,0x00000000,0x48484800,
+ 0xa3a3a300,0xf7f7f700,0x75757500,0xdbdbdb00,
+ 0x8a8a8a00,0x03030300,0xe6e6e600,0xdadada00,
+ 0x09090900,0x3f3f3f00,0xdddddd00,0x94949400,
+ 0x87878700,0x5c5c5c00,0x83838300,0x02020200,
+ 0xcdcdcd00,0x4a4a4a00,0x90909000,0x33333300,
+ 0x73737300,0x67676700,0xf6f6f600,0xf3f3f300,
+ 0x9d9d9d00,0x7f7f7f00,0xbfbfbf00,0xe2e2e200,
+ 0x52525200,0x9b9b9b00,0xd8d8d800,0x26262600,
+ 0xc8c8c800,0x37373700,0xc6c6c600,0x3b3b3b00,
+ 0x81818100,0x96969600,0x6f6f6f00,0x4b4b4b00,
+ 0x13131300,0xbebebe00,0x63636300,0x2e2e2e00,
+ 0xe9e9e900,0x79797900,0xa7a7a700,0x8c8c8c00,
+ 0x9f9f9f00,0x6e6e6e00,0xbcbcbc00,0x8e8e8e00,
+ 0x29292900,0xf5f5f500,0xf9f9f900,0xb6b6b600,
+ 0x2f2f2f00,0xfdfdfd00,0xb4b4b400,0x59595900,
+ 0x78787800,0x98989800,0x06060600,0x6a6a6a00,
+ 0xe7e7e700,0x46464600,0x71717100,0xbababa00,
+ 0xd4d4d400,0x25252500,0xababab00,0x42424200,
+ 0x88888800,0xa2a2a200,0x8d8d8d00,0xfafafa00,
+ 0x72727200,0x07070700,0xb9b9b900,0x55555500,
+ 0xf8f8f800,0xeeeeee00,0xacacac00,0x0a0a0a00,
+ 0x36363600,0x49494900,0x2a2a2a00,0x68686800,
+ 0x3c3c3c00,0x38383800,0xf1f1f100,0xa4a4a400,
+ 0x40404000,0x28282800,0xd3d3d300,0x7b7b7b00,
+ 0xbbbbbb00,0xc9c9c900,0x43434300,0xc1c1c100,
+ 0x15151500,0xe3e3e300,0xadadad00,0xf4f4f400,
+ 0x77777700,0xc7c7c700,0x80808000,0x9e9e9e00,
+};
+
+static const u32 camellia_sp0222[256] = {
+ 0x00e0e0e0,0x00050505,0x00585858,0x00d9d9d9,
+ 0x00676767,0x004e4e4e,0x00818181,0x00cbcbcb,
+ 0x00c9c9c9,0x000b0b0b,0x00aeaeae,0x006a6a6a,
+ 0x00d5d5d5,0x00181818,0x005d5d5d,0x00828282,
+ 0x00464646,0x00dfdfdf,0x00d6d6d6,0x00272727,
+ 0x008a8a8a,0x00323232,0x004b4b4b,0x00424242,
+ 0x00dbdbdb,0x001c1c1c,0x009e9e9e,0x009c9c9c,
+ 0x003a3a3a,0x00cacaca,0x00252525,0x007b7b7b,
+ 0x000d0d0d,0x00717171,0x005f5f5f,0x001f1f1f,
+ 0x00f8f8f8,0x00d7d7d7,0x003e3e3e,0x009d9d9d,
+ 0x007c7c7c,0x00606060,0x00b9b9b9,0x00bebebe,
+ 0x00bcbcbc,0x008b8b8b,0x00161616,0x00343434,
+ 0x004d4d4d,0x00c3c3c3,0x00727272,0x00959595,
+ 0x00ababab,0x008e8e8e,0x00bababa,0x007a7a7a,
+ 0x00b3b3b3,0x00020202,0x00b4b4b4,0x00adadad,
+ 0x00a2a2a2,0x00acacac,0x00d8d8d8,0x009a9a9a,
+ 0x00171717,0x001a1a1a,0x00353535,0x00cccccc,
+ 0x00f7f7f7,0x00999999,0x00616161,0x005a5a5a,
+ 0x00e8e8e8,0x00242424,0x00565656,0x00404040,
+ 0x00e1e1e1,0x00636363,0x00090909,0x00333333,
+ 0x00bfbfbf,0x00989898,0x00979797,0x00858585,
+ 0x00686868,0x00fcfcfc,0x00ececec,0x000a0a0a,
+ 0x00dadada,0x006f6f6f,0x00535353,0x00626262,
+ 0x00a3a3a3,0x002e2e2e,0x00080808,0x00afafaf,
+ 0x00282828,0x00b0b0b0,0x00747474,0x00c2c2c2,
+ 0x00bdbdbd,0x00363636,0x00222222,0x00383838,
+ 0x00646464,0x001e1e1e,0x00393939,0x002c2c2c,
+ 0x00a6a6a6,0x00303030,0x00e5e5e5,0x00444444,
+ 0x00fdfdfd,0x00888888,0x009f9f9f,0x00656565,
+ 0x00878787,0x006b6b6b,0x00f4f4f4,0x00232323,
+ 0x00484848,0x00101010,0x00d1d1d1,0x00515151,
+ 0x00c0c0c0,0x00f9f9f9,0x00d2d2d2,0x00a0a0a0,
+ 0x00555555,0x00a1a1a1,0x00414141,0x00fafafa,
+ 0x00434343,0x00131313,0x00c4c4c4,0x002f2f2f,
+ 0x00a8a8a8,0x00b6b6b6,0x003c3c3c,0x002b2b2b,
+ 0x00c1c1c1,0x00ffffff,0x00c8c8c8,0x00a5a5a5,
+ 0x00202020,0x00898989,0x00000000,0x00909090,
+ 0x00474747,0x00efefef,0x00eaeaea,0x00b7b7b7,
+ 0x00151515,0x00060606,0x00cdcdcd,0x00b5b5b5,
+ 0x00121212,0x007e7e7e,0x00bbbbbb,0x00292929,
+ 0x000f0f0f,0x00b8b8b8,0x00070707,0x00040404,
+ 0x009b9b9b,0x00949494,0x00212121,0x00666666,
+ 0x00e6e6e6,0x00cecece,0x00ededed,0x00e7e7e7,
+ 0x003b3b3b,0x00fefefe,0x007f7f7f,0x00c5c5c5,
+ 0x00a4a4a4,0x00373737,0x00b1b1b1,0x004c4c4c,
+ 0x00919191,0x006e6e6e,0x008d8d8d,0x00767676,
+ 0x00030303,0x002d2d2d,0x00dedede,0x00969696,
+ 0x00262626,0x007d7d7d,0x00c6c6c6,0x005c5c5c,
+ 0x00d3d3d3,0x00f2f2f2,0x004f4f4f,0x00191919,
+ 0x003f3f3f,0x00dcdcdc,0x00797979,0x001d1d1d,
+ 0x00525252,0x00ebebeb,0x00f3f3f3,0x006d6d6d,
+ 0x005e5e5e,0x00fbfbfb,0x00696969,0x00b2b2b2,
+ 0x00f0f0f0,0x00313131,0x000c0c0c,0x00d4d4d4,
+ 0x00cfcfcf,0x008c8c8c,0x00e2e2e2,0x00757575,
+ 0x00a9a9a9,0x004a4a4a,0x00575757,0x00848484,
+ 0x00111111,0x00454545,0x001b1b1b,0x00f5f5f5,
+ 0x00e4e4e4,0x000e0e0e,0x00737373,0x00aaaaaa,
+ 0x00f1f1f1,0x00dddddd,0x00595959,0x00141414,
+ 0x006c6c6c,0x00929292,0x00545454,0x00d0d0d0,
+ 0x00787878,0x00707070,0x00e3e3e3,0x00494949,
+ 0x00808080,0x00505050,0x00a7a7a7,0x00f6f6f6,
+ 0x00777777,0x00939393,0x00868686,0x00838383,
+ 0x002a2a2a,0x00c7c7c7,0x005b5b5b,0x00e9e9e9,
+ 0x00eeeeee,0x008f8f8f,0x00010101,0x003d3d3d,
+};
+
+static const u32 camellia_sp3033[256] = {
+ 0x38003838,0x41004141,0x16001616,0x76007676,
+ 0xd900d9d9,0x93009393,0x60006060,0xf200f2f2,
+ 0x72007272,0xc200c2c2,0xab00abab,0x9a009a9a,
+ 0x75007575,0x06000606,0x57005757,0xa000a0a0,
+ 0x91009191,0xf700f7f7,0xb500b5b5,0xc900c9c9,
+ 0xa200a2a2,0x8c008c8c,0xd200d2d2,0x90009090,
+ 0xf600f6f6,0x07000707,0xa700a7a7,0x27002727,
+ 0x8e008e8e,0xb200b2b2,0x49004949,0xde00dede,
+ 0x43004343,0x5c005c5c,0xd700d7d7,0xc700c7c7,
+ 0x3e003e3e,0xf500f5f5,0x8f008f8f,0x67006767,
+ 0x1f001f1f,0x18001818,0x6e006e6e,0xaf00afaf,
+ 0x2f002f2f,0xe200e2e2,0x85008585,0x0d000d0d,
+ 0x53005353,0xf000f0f0,0x9c009c9c,0x65006565,
+ 0xea00eaea,0xa300a3a3,0xae00aeae,0x9e009e9e,
+ 0xec00ecec,0x80008080,0x2d002d2d,0x6b006b6b,
+ 0xa800a8a8,0x2b002b2b,0x36003636,0xa600a6a6,
+ 0xc500c5c5,0x86008686,0x4d004d4d,0x33003333,
+ 0xfd00fdfd,0x66006666,0x58005858,0x96009696,
+ 0x3a003a3a,0x09000909,0x95009595,0x10001010,
+ 0x78007878,0xd800d8d8,0x42004242,0xcc00cccc,
+ 0xef00efef,0x26002626,0xe500e5e5,0x61006161,
+ 0x1a001a1a,0x3f003f3f,0x3b003b3b,0x82008282,
+ 0xb600b6b6,0xdb00dbdb,0xd400d4d4,0x98009898,
+ 0xe800e8e8,0x8b008b8b,0x02000202,0xeb00ebeb,
+ 0x0a000a0a,0x2c002c2c,0x1d001d1d,0xb000b0b0,
+ 0x6f006f6f,0x8d008d8d,0x88008888,0x0e000e0e,
+ 0x19001919,0x87008787,0x4e004e4e,0x0b000b0b,
+ 0xa900a9a9,0x0c000c0c,0x79007979,0x11001111,
+ 0x7f007f7f,0x22002222,0xe700e7e7,0x59005959,
+ 0xe100e1e1,0xda00dada,0x3d003d3d,0xc800c8c8,
+ 0x12001212,0x04000404,0x74007474,0x54005454,
+ 0x30003030,0x7e007e7e,0xb400b4b4,0x28002828,
+ 0x55005555,0x68006868,0x50005050,0xbe00bebe,
+ 0xd000d0d0,0xc400c4c4,0x31003131,0xcb00cbcb,
+ 0x2a002a2a,0xad00adad,0x0f000f0f,0xca00caca,
+ 0x70007070,0xff00ffff,0x32003232,0x69006969,
+ 0x08000808,0x62006262,0x00000000,0x24002424,
+ 0xd100d1d1,0xfb00fbfb,0xba00baba,0xed00eded,
+ 0x45004545,0x81008181,0x73007373,0x6d006d6d,
+ 0x84008484,0x9f009f9f,0xee00eeee,0x4a004a4a,
+ 0xc300c3c3,0x2e002e2e,0xc100c1c1,0x01000101,
+ 0xe600e6e6,0x25002525,0x48004848,0x99009999,
+ 0xb900b9b9,0xb300b3b3,0x7b007b7b,0xf900f9f9,
+ 0xce00cece,0xbf00bfbf,0xdf00dfdf,0x71007171,
+ 0x29002929,0xcd00cdcd,0x6c006c6c,0x13001313,
+ 0x64006464,0x9b009b9b,0x63006363,0x9d009d9d,
+ 0xc000c0c0,0x4b004b4b,0xb700b7b7,0xa500a5a5,
+ 0x89008989,0x5f005f5f,0xb100b1b1,0x17001717,
+ 0xf400f4f4,0xbc00bcbc,0xd300d3d3,0x46004646,
+ 0xcf00cfcf,0x37003737,0x5e005e5e,0x47004747,
+ 0x94009494,0xfa00fafa,0xfc00fcfc,0x5b005b5b,
+ 0x97009797,0xfe00fefe,0x5a005a5a,0xac00acac,
+ 0x3c003c3c,0x4c004c4c,0x03000303,0x35003535,
+ 0xf300f3f3,0x23002323,0xb800b8b8,0x5d005d5d,
+ 0x6a006a6a,0x92009292,0xd500d5d5,0x21002121,
+ 0x44004444,0x51005151,0xc600c6c6,0x7d007d7d,
+ 0x39003939,0x83008383,0xdc00dcdc,0xaa00aaaa,
+ 0x7c007c7c,0x77007777,0x56005656,0x05000505,
+ 0x1b001b1b,0xa400a4a4,0x15001515,0x34003434,
+ 0x1e001e1e,0x1c001c1c,0xf800f8f8,0x52005252,
+ 0x20002020,0x14001414,0xe900e9e9,0xbd00bdbd,
+ 0xdd00dddd,0xe400e4e4,0xa100a1a1,0xe000e0e0,
+ 0x8a008a8a,0xf100f1f1,0xd600d6d6,0x7a007a7a,
+ 0xbb00bbbb,0xe300e3e3,0x40004040,0x4f004f4f,
+};
+
+static const u32 camellia_sp4404[256] = {
+ 0x70700070,0x2c2c002c,0xb3b300b3,0xc0c000c0,
+ 0xe4e400e4,0x57570057,0xeaea00ea,0xaeae00ae,
+ 0x23230023,0x6b6b006b,0x45450045,0xa5a500a5,
+ 0xeded00ed,0x4f4f004f,0x1d1d001d,0x92920092,
+ 0x86860086,0xafaf00af,0x7c7c007c,0x1f1f001f,
+ 0x3e3e003e,0xdcdc00dc,0x5e5e005e,0x0b0b000b,
+ 0xa6a600a6,0x39390039,0xd5d500d5,0x5d5d005d,
+ 0xd9d900d9,0x5a5a005a,0x51510051,0x6c6c006c,
+ 0x8b8b008b,0x9a9a009a,0xfbfb00fb,0xb0b000b0,
+ 0x74740074,0x2b2b002b,0xf0f000f0,0x84840084,
+ 0xdfdf00df,0xcbcb00cb,0x34340034,0x76760076,
+ 0x6d6d006d,0xa9a900a9,0xd1d100d1,0x04040004,
+ 0x14140014,0x3a3a003a,0xdede00de,0x11110011,
+ 0x32320032,0x9c9c009c,0x53530053,0xf2f200f2,
+ 0xfefe00fe,0xcfcf00cf,0xc3c300c3,0x7a7a007a,
+ 0x24240024,0xe8e800e8,0x60600060,0x69690069,
+ 0xaaaa00aa,0xa0a000a0,0xa1a100a1,0x62620062,
+ 0x54540054,0x1e1e001e,0xe0e000e0,0x64640064,
+ 0x10100010,0x00000000,0xa3a300a3,0x75750075,
+ 0x8a8a008a,0xe6e600e6,0x09090009,0xdddd00dd,
+ 0x87870087,0x83830083,0xcdcd00cd,0x90900090,
+ 0x73730073,0xf6f600f6,0x9d9d009d,0xbfbf00bf,
+ 0x52520052,0xd8d800d8,0xc8c800c8,0xc6c600c6,
+ 0x81810081,0x6f6f006f,0x13130013,0x63630063,
+ 0xe9e900e9,0xa7a700a7,0x9f9f009f,0xbcbc00bc,
+ 0x29290029,0xf9f900f9,0x2f2f002f,0xb4b400b4,
+ 0x78780078,0x06060006,0xe7e700e7,0x71710071,
+ 0xd4d400d4,0xabab00ab,0x88880088,0x8d8d008d,
+ 0x72720072,0xb9b900b9,0xf8f800f8,0xacac00ac,
+ 0x36360036,0x2a2a002a,0x3c3c003c,0xf1f100f1,
+ 0x40400040,0xd3d300d3,0xbbbb00bb,0x43430043,
+ 0x15150015,0xadad00ad,0x77770077,0x80800080,
+ 0x82820082,0xecec00ec,0x27270027,0xe5e500e5,
+ 0x85850085,0x35350035,0x0c0c000c,0x41410041,
+ 0xefef00ef,0x93930093,0x19190019,0x21210021,
+ 0x0e0e000e,0x4e4e004e,0x65650065,0xbdbd00bd,
+ 0xb8b800b8,0x8f8f008f,0xebeb00eb,0xcece00ce,
+ 0x30300030,0x5f5f005f,0xc5c500c5,0x1a1a001a,
+ 0xe1e100e1,0xcaca00ca,0x47470047,0x3d3d003d,
+ 0x01010001,0xd6d600d6,0x56560056,0x4d4d004d,
+ 0x0d0d000d,0x66660066,0xcccc00cc,0x2d2d002d,
+ 0x12120012,0x20200020,0xb1b100b1,0x99990099,
+ 0x4c4c004c,0xc2c200c2,0x7e7e007e,0x05050005,
+ 0xb7b700b7,0x31310031,0x17170017,0xd7d700d7,
+ 0x58580058,0x61610061,0x1b1b001b,0x1c1c001c,
+ 0x0f0f000f,0x16160016,0x18180018,0x22220022,
+ 0x44440044,0xb2b200b2,0xb5b500b5,0x91910091,
+ 0x08080008,0xa8a800a8,0xfcfc00fc,0x50500050,
+ 0xd0d000d0,0x7d7d007d,0x89890089,0x97970097,
+ 0x5b5b005b,0x95950095,0xffff00ff,0xd2d200d2,
+ 0xc4c400c4,0x48480048,0xf7f700f7,0xdbdb00db,
+ 0x03030003,0xdada00da,0x3f3f003f,0x94940094,
+ 0x5c5c005c,0x02020002,0x4a4a004a,0x33330033,
+ 0x67670067,0xf3f300f3,0x7f7f007f,0xe2e200e2,
+ 0x9b9b009b,0x26260026,0x37370037,0x3b3b003b,
+ 0x96960096,0x4b4b004b,0xbebe00be,0x2e2e002e,
+ 0x79790079,0x8c8c008c,0x6e6e006e,0x8e8e008e,
+ 0xf5f500f5,0xb6b600b6,0xfdfd00fd,0x59590059,
+ 0x98980098,0x6a6a006a,0x46460046,0xbaba00ba,
+ 0x25250025,0x42420042,0xa2a200a2,0xfafa00fa,
+ 0x07070007,0x55550055,0xeeee00ee,0x0a0a000a,
+ 0x49490049,0x68680068,0x38380038,0xa4a400a4,
+ 0x28280028,0x7b7b007b,0xc9c900c9,0xc1c100c1,
+ 0xe3e300e3,0xf4f400f4,0xc7c700c7,0x9e9e009e,
+};
+
+
+/**
+ * Stuff related to the Camellia key schedule
+ */
+#define subl(x) subL[(x)]
+#define subr(x) subR[(x)]
+
+void camellia_setup128(const unsigned char *key, u32 *subkey)
+{
+ u32 kll, klr, krl, krr;
+ u32 il, ir, t0, t1, w0, w1;
+ u32 kw4l, kw4r, dw, tl, tr;
+ u32 subL[26];
+ u32 subR[26];
+
+ /**
+ * k == kll || klr || krl || krr (|| is concatination)
+ */
+ kll = GETU32(key );
+ klr = GETU32(key + 4);
+ krl = GETU32(key + 8);
+ krr = GETU32(key + 12);
+ /**
+ * generate KL dependent subkeys
+ */
+ subl(0) = kll; subr(0) = klr;
+ subl(1) = krl; subr(1) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(4) = kll; subr(4) = klr;
+ subl(5) = krl; subr(5) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30);
+ subl(10) = kll; subr(10) = klr;
+ subl(11) = krl; subr(11) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(13) = krl; subr(13) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+ subl(16) = kll; subr(16) = klr;
+ subl(17) = krl; subr(17) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+ subl(18) = kll; subr(18) = klr;
+ subl(19) = krl; subr(19) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+ subl(22) = kll; subr(22) = klr;
+ subl(23) = krl; subr(23) = krr;
+
+ /* generate KA */
+ kll = subl(0); klr = subr(0);
+ krl = subl(1); krr = subr(1);
+ CAMELLIA_F(kll, klr,
+ CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R,
+ w0, w1, il, ir, t0, t1);
+ krl ^= w0; krr ^= w1;
+ CAMELLIA_F(krl, krr,
+ CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R,
+ kll, klr, il, ir, t0, t1);
+ CAMELLIA_F(kll, klr,
+ CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R,
+ krl, krr, il, ir, t0, t1);
+ krl ^= w0; krr ^= w1;
+ CAMELLIA_F(krl, krr,
+ CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R,
+ w0, w1, il, ir, t0, t1);
+ kll ^= w0; klr ^= w1;
+
+ /* generate KA dependent subkeys */
+ subl(2) = kll; subr(2) = klr;
+ subl(3) = krl; subr(3) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(6) = kll; subr(6) = klr;
+ subl(7) = krl; subr(7) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(8) = kll; subr(8) = klr;
+ subl(9) = krl; subr(9) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(12) = kll; subr(12) = klr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(14) = kll; subr(14) = klr;
+ subl(15) = krl; subr(15) = krr;
+ CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34);
+ subl(20) = kll; subr(20) = klr;
+ subl(21) = krl; subr(21) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+ subl(24) = kll; subr(24) = klr;
+ subl(25) = krl; subr(25) = krr;
+
+
+ /* absorb kw2 to other subkeys */
+ subl(3) ^= subl(1); subr(3) ^= subr(1);
+ subl(5) ^= subl(1); subr(5) ^= subr(1);
+ subl(7) ^= subl(1); subr(7) ^= subr(1);
+ subl(1) ^= subr(1) & ~subr(9);
+ dw = subl(1) & subl(9), subr(1) ^= CAMELLIA_RL1(dw);
+ subl(11) ^= subl(1); subr(11) ^= subr(1);
+ subl(13) ^= subl(1); subr(13) ^= subr(1);
+ subl(15) ^= subl(1); subr(15) ^= subr(1);
+ subl(1) ^= subr(1) & ~subr(17);
+ dw = subl(1) & subl(17), subr(1) ^= CAMELLIA_RL1(dw);
+ subl(19) ^= subl(1); subr(19) ^= subr(1);
+ subl(21) ^= subl(1); subr(21) ^= subr(1);
+ subl(23) ^= subl(1); subr(23) ^= subr(1);
+ subl(24) ^= subl(1); subr(24) ^= subr(1);
+
+ /* absorb kw4 to other subkeys */
+ kw4l = subl(25); kw4r = subr(25);
+ subl(22) ^= kw4l; subr(22) ^= kw4r;
+ subl(20) ^= kw4l; subr(20) ^= kw4r;
+ subl(18) ^= kw4l; subr(18) ^= kw4r;
+ kw4l ^= kw4r & ~subr(16);
+ dw = kw4l & subl(16), kw4r ^= CAMELLIA_RL1(dw);
+ subl(14) ^= kw4l; subr(14) ^= kw4r;
+ subl(12) ^= kw4l; subr(12) ^= kw4r;
+ subl(10) ^= kw4l; subr(10) ^= kw4r;
+ kw4l ^= kw4r & ~subr(8);
+ dw = kw4l & subl(8), kw4r ^= CAMELLIA_RL1(dw);
+ subl(6) ^= kw4l; subr(6) ^= kw4r;
+ subl(4) ^= kw4l; subr(4) ^= kw4r;
+ subl(2) ^= kw4l; subr(2) ^= kw4r;
+ subl(0) ^= kw4l; subr(0) ^= kw4r;
+
+ /* key XOR is end of F-function */
+ CamelliaSubkeyL(0) = subl(0) ^ subl(2);
+ CamelliaSubkeyR(0) = subr(0) ^ subr(2);
+ CamelliaSubkeyL(2) = subl(3);
+ CamelliaSubkeyR(2) = subr(3);
+ CamelliaSubkeyL(3) = subl(2) ^ subl(4);
+ CamelliaSubkeyR(3) = subr(2) ^ subr(4);
+ CamelliaSubkeyL(4) = subl(3) ^ subl(5);
+ CamelliaSubkeyR(4) = subr(3) ^ subr(5);
+ CamelliaSubkeyL(5) = subl(4) ^ subl(6);
+ CamelliaSubkeyR(5) = subr(4) ^ subr(6);
+ CamelliaSubkeyL(6) = subl(5) ^ subl(7);
+ CamelliaSubkeyR(6) = subr(5) ^ subr(7);
+ tl = subl(10) ^ (subr(10) & ~subr(8));
+ dw = tl & subl(8), tr = subr(10) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(7) = subl(6) ^ tl;
+ CamelliaSubkeyR(7) = subr(6) ^ tr;
+ CamelliaSubkeyL(8) = subl(8);
+ CamelliaSubkeyR(8) = subr(8);
+ CamelliaSubkeyL(9) = subl(9);
+ CamelliaSubkeyR(9) = subr(9);
+ tl = subl(7) ^ (subr(7) & ~subr(9));
+ dw = tl & subl(9), tr = subr(7) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(10) = tl ^ subl(11);
+ CamelliaSubkeyR(10) = tr ^ subr(11);
+ CamelliaSubkeyL(11) = subl(10) ^ subl(12);
+ CamelliaSubkeyR(11) = subr(10) ^ subr(12);
+ CamelliaSubkeyL(12) = subl(11) ^ subl(13);
+ CamelliaSubkeyR(12) = subr(11) ^ subr(13);
+ CamelliaSubkeyL(13) = subl(12) ^ subl(14);
+ CamelliaSubkeyR(13) = subr(12) ^ subr(14);
+ CamelliaSubkeyL(14) = subl(13) ^ subl(15);
+ CamelliaSubkeyR(14) = subr(13) ^ subr(15);
+ tl = subl(18) ^ (subr(18) & ~subr(16));
+ dw = tl & subl(16), tr = subr(18) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(15) = subl(14) ^ tl;
+ CamelliaSubkeyR(15) = subr(14) ^ tr;
+ CamelliaSubkeyL(16) = subl(16);
+ CamelliaSubkeyR(16) = subr(16);
+ CamelliaSubkeyL(17) = subl(17);
+ CamelliaSubkeyR(17) = subr(17);
+ tl = subl(15) ^ (subr(15) & ~subr(17));
+ dw = tl & subl(17), tr = subr(15) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(18) = tl ^ subl(19);
+ CamelliaSubkeyR(18) = tr ^ subr(19);
+ CamelliaSubkeyL(19) = subl(18) ^ subl(20);
+ CamelliaSubkeyR(19) = subr(18) ^ subr(20);
+ CamelliaSubkeyL(20) = subl(19) ^ subl(21);
+ CamelliaSubkeyR(20) = subr(19) ^ subr(21);
+ CamelliaSubkeyL(21) = subl(20) ^ subl(22);
+ CamelliaSubkeyR(21) = subr(20) ^ subr(22);
+ CamelliaSubkeyL(22) = subl(21) ^ subl(23);
+ CamelliaSubkeyR(22) = subr(21) ^ subr(23);
+ CamelliaSubkeyL(23) = subl(22);
+ CamelliaSubkeyR(23) = subr(22);
+ CamelliaSubkeyL(24) = subl(24) ^ subl(23);
+ CamelliaSubkeyR(24) = subr(24) ^ subr(23);
+
+ /* apply the inverse of the last half of P-function */
+ dw = CamelliaSubkeyL(2) ^ CamelliaSubkeyR(2), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(2) = CamelliaSubkeyL(2) ^ dw, CamelliaSubkeyL(2) = dw;
+ dw = CamelliaSubkeyL(3) ^ CamelliaSubkeyR(3), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(3) = CamelliaSubkeyL(3) ^ dw, CamelliaSubkeyL(3) = dw;
+ dw = CamelliaSubkeyL(4) ^ CamelliaSubkeyR(4), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(4) = CamelliaSubkeyL(4) ^ dw, CamelliaSubkeyL(4) = dw;
+ dw = CamelliaSubkeyL(5) ^ CamelliaSubkeyR(5), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(5) = CamelliaSubkeyL(5) ^ dw, CamelliaSubkeyL(5) = dw;
+ dw = CamelliaSubkeyL(6) ^ CamelliaSubkeyR(6), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(6) = CamelliaSubkeyL(6) ^ dw, CamelliaSubkeyL(6) = dw;
+ dw = CamelliaSubkeyL(7) ^ CamelliaSubkeyR(7), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(7) = CamelliaSubkeyL(7) ^ dw, CamelliaSubkeyL(7) = dw;
+ dw = CamelliaSubkeyL(10) ^ CamelliaSubkeyR(10), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(10) = CamelliaSubkeyL(10) ^ dw, CamelliaSubkeyL(10) = dw;
+ dw = CamelliaSubkeyL(11) ^ CamelliaSubkeyR(11), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(11) = CamelliaSubkeyL(11) ^ dw, CamelliaSubkeyL(11) = dw;
+ dw = CamelliaSubkeyL(12) ^ CamelliaSubkeyR(12), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(12) = CamelliaSubkeyL(12) ^ dw, CamelliaSubkeyL(12) = dw;
+ dw = CamelliaSubkeyL(13) ^ CamelliaSubkeyR(13), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(13) = CamelliaSubkeyL(13) ^ dw, CamelliaSubkeyL(13) = dw;
+ dw = CamelliaSubkeyL(14) ^ CamelliaSubkeyR(14), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(14) = CamelliaSubkeyL(14) ^ dw, CamelliaSubkeyL(14) = dw;
+ dw = CamelliaSubkeyL(15) ^ CamelliaSubkeyR(15), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(15) = CamelliaSubkeyL(15) ^ dw, CamelliaSubkeyL(15) = dw;
+ dw = CamelliaSubkeyL(18) ^ CamelliaSubkeyR(18), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(18) = CamelliaSubkeyL(18) ^ dw, CamelliaSubkeyL(18) = dw;
+ dw = CamelliaSubkeyL(19) ^ CamelliaSubkeyR(19), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(19) = CamelliaSubkeyL(19) ^ dw, CamelliaSubkeyL(19) = dw;
+ dw = CamelliaSubkeyL(20) ^ CamelliaSubkeyR(20), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(20) = CamelliaSubkeyL(20) ^ dw, CamelliaSubkeyL(20) = dw;
+ dw = CamelliaSubkeyL(21) ^ CamelliaSubkeyR(21), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(21) = CamelliaSubkeyL(21) ^ dw, CamelliaSubkeyL(21) = dw;
+ dw = CamelliaSubkeyL(22) ^ CamelliaSubkeyR(22), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(22) = CamelliaSubkeyL(22) ^ dw, CamelliaSubkeyL(22) = dw;
+ dw = CamelliaSubkeyL(23) ^ CamelliaSubkeyR(23), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(23) = CamelliaSubkeyL(23) ^ dw, CamelliaSubkeyL(23) = dw;
+
+ return;
+}
+
+void camellia_setup256(const unsigned char *key, u32 *subkey)
+{
+ u32 kll,klr,krl,krr; /* left half of key */
+ u32 krll,krlr,krrl,krrr; /* right half of key */
+ u32 il, ir, t0, t1, w0, w1; /* temporary variables */
+ u32 kw4l, kw4r, dw, tl, tr;
+ u32 subL[34];
+ u32 subR[34];
+
+ /**
+ * key = (kll || klr || krl || krr || krll || krlr || krrl || krrr)
+ * (|| is concatination)
+ */
+
+ kll = GETU32(key );
+ klr = GETU32(key + 4);
+ krl = GETU32(key + 8);
+ krr = GETU32(key + 12);
+ krll = GETU32(key + 16);
+ krlr = GETU32(key + 20);
+ krrl = GETU32(key + 24);
+ krrr = GETU32(key + 28);
+
+ /* generate KL dependent subkeys */
+ subl(0) = kll; subr(0) = klr;
+ subl(1) = krl; subr(1) = krr;
+ CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 45);
+ subl(12) = kll; subr(12) = klr;
+ subl(13) = krl; subr(13) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(16) = kll; subr(16) = klr;
+ subl(17) = krl; subr(17) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+ subl(22) = kll; subr(22) = klr;
+ subl(23) = krl; subr(23) = krr;
+ CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34);
+ subl(30) = kll; subr(30) = klr;
+ subl(31) = krl; subr(31) = krr;
+
+ /* generate KR dependent subkeys */
+ CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15);
+ subl(4) = krll; subr(4) = krlr;
+ subl(5) = krrl; subr(5) = krrr;
+ CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15);
+ subl(8) = krll; subr(8) = krlr;
+ subl(9) = krrl; subr(9) = krrr;
+ CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+ subl(18) = krll; subr(18) = krlr;
+ subl(19) = krrl; subr(19) = krrr;
+ CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34);
+ subl(26) = krll; subr(26) = krlr;
+ subl(27) = krrl; subr(27) = krrr;
+ CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34);
+
+ /* generate KA */
+ kll = subl(0) ^ krll; klr = subr(0) ^ krlr;
+ krl = subl(1) ^ krrl; krr = subr(1) ^ krrr;
+ CAMELLIA_F(kll, klr,
+ CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R,
+ w0, w1, il, ir, t0, t1);
+ krl ^= w0; krr ^= w1;
+ CAMELLIA_F(krl, krr,
+ CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R,
+ kll, klr, il, ir, t0, t1);
+ kll ^= krll; klr ^= krlr;
+ CAMELLIA_F(kll, klr,
+ CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R,
+ krl, krr, il, ir, t0, t1);
+ krl ^= w0 ^ krrl; krr ^= w1 ^ krrr;
+ CAMELLIA_F(krl, krr,
+ CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R,
+ w0, w1, il, ir, t0, t1);
+ kll ^= w0; klr ^= w1;
+
+ /* generate KB */
+ krll ^= kll; krlr ^= klr;
+ krrl ^= krl; krrr ^= krr;
+ CAMELLIA_F(krll, krlr,
+ CAMELLIA_SIGMA5L, CAMELLIA_SIGMA5R,
+ w0, w1, il, ir, t0, t1);
+ krrl ^= w0; krrr ^= w1;
+ CAMELLIA_F(krrl, krrr,
+ CAMELLIA_SIGMA6L, CAMELLIA_SIGMA6R,
+ w0, w1, il, ir, t0, t1);
+ krll ^= w0; krlr ^= w1;
+
+ /* generate KA dependent subkeys */
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+ subl(6) = kll; subr(6) = klr;
+ subl(7) = krl; subr(7) = krr;
+ CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30);
+ subl(14) = kll; subr(14) = klr;
+ subl(15) = krl; subr(15) = krr;
+ subl(24) = klr; subr(24) = krl;
+ subl(25) = krr; subr(25) = kll;
+ CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 49);
+ subl(28) = kll; subr(28) = klr;
+ subl(29) = krl; subr(29) = krr;
+
+ /* generate KB dependent subkeys */
+ subl(2) = krll; subr(2) = krlr;
+ subl(3) = krrl; subr(3) = krrr;
+ CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+ subl(10) = krll; subr(10) = krlr;
+ subl(11) = krrl; subr(11) = krrr;
+ CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+ subl(20) = krll; subr(20) = krlr;
+ subl(21) = krrl; subr(21) = krrr;
+ CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 51);
+ subl(32) = krll; subr(32) = krlr;
+ subl(33) = krrl; subr(33) = krrr;
+
+ /* absorb kw2 to other subkeys */
+ subl(3) ^= subl(1); subr(3) ^= subr(1);
+ subl(5) ^= subl(1); subr(5) ^= subr(1);
+ subl(7) ^= subl(1); subr(7) ^= subr(1);
+ subl(1) ^= subr(1) & ~subr(9);
+ dw = subl(1) & subl(9), subr(1) ^= CAMELLIA_RL1(dw);
+ subl(11) ^= subl(1); subr(11) ^= subr(1);
+ subl(13) ^= subl(1); subr(13) ^= subr(1);
+ subl(15) ^= subl(1); subr(15) ^= subr(1);
+ subl(1) ^= subr(1) & ~subr(17);
+ dw = subl(1) & subl(17), subr(1) ^= CAMELLIA_RL1(dw);
+ subl(19) ^= subl(1); subr(19) ^= subr(1);
+ subl(21) ^= subl(1); subr(21) ^= subr(1);
+ subl(23) ^= subl(1); subr(23) ^= subr(1);
+ subl(1) ^= subr(1) & ~subr(25);
+ dw = subl(1) & subl(25), subr(1) ^= CAMELLIA_RL1(dw);
+ subl(27) ^= subl(1); subr(27) ^= subr(1);
+ subl(29) ^= subl(1); subr(29) ^= subr(1);
+ subl(31) ^= subl(1); subr(31) ^= subr(1);
+ subl(32) ^= subl(1); subr(32) ^= subr(1);
+
+ /* absorb kw4 to other subkeys */
+ kw4l = subl(33); kw4r = subr(33);
+ subl(30) ^= kw4l; subr(30) ^= kw4r;
+ subl(28) ^= kw4l; subr(28) ^= kw4r;
+ subl(26) ^= kw4l; subr(26) ^= kw4r;
+ kw4l ^= kw4r & ~subr(24);
+ dw = kw4l & subl(24), kw4r ^= CAMELLIA_RL1(dw);
+ subl(22) ^= kw4l; subr(22) ^= kw4r;
+ subl(20) ^= kw4l; subr(20) ^= kw4r;
+ subl(18) ^= kw4l; subr(18) ^= kw4r;
+ kw4l ^= kw4r & ~subr(16);
+ dw = kw4l & subl(16), kw4r ^= CAMELLIA_RL1(dw);
+ subl(14) ^= kw4l; subr(14) ^= kw4r;
+ subl(12) ^= kw4l; subr(12) ^= kw4r;
+ subl(10) ^= kw4l; subr(10) ^= kw4r;
+ kw4l ^= kw4r & ~subr(8);
+ dw = kw4l & subl(8), kw4r ^= CAMELLIA_RL1(dw);
+ subl(6) ^= kw4l; subr(6) ^= kw4r;
+ subl(4) ^= kw4l; subr(4) ^= kw4r;
+ subl(2) ^= kw4l; subr(2) ^= kw4r;
+ subl(0) ^= kw4l; subr(0) ^= kw4r;
+
+ /* key XOR is end of F-function */
+ CamelliaSubkeyL(0) = subl(0) ^ subl(2);
+ CamelliaSubkeyR(0) = subr(0) ^ subr(2);
+ CamelliaSubkeyL(2) = subl(3);
+ CamelliaSubkeyR(2) = subr(3);
+ CamelliaSubkeyL(3) = subl(2) ^ subl(4);
+ CamelliaSubkeyR(3) = subr(2) ^ subr(4);
+ CamelliaSubkeyL(4) = subl(3) ^ subl(5);
+ CamelliaSubkeyR(4) = subr(3) ^ subr(5);
+ CamelliaSubkeyL(5) = subl(4) ^ subl(6);
+ CamelliaSubkeyR(5) = subr(4) ^ subr(6);
+ CamelliaSubkeyL(6) = subl(5) ^ subl(7);
+ CamelliaSubkeyR(6) = subr(5) ^ subr(7);
+ tl = subl(10) ^ (subr(10) & ~subr(8));
+ dw = tl & subl(8), tr = subr(10) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(7) = subl(6) ^ tl;
+ CamelliaSubkeyR(7) = subr(6) ^ tr;
+ CamelliaSubkeyL(8) = subl(8);
+ CamelliaSubkeyR(8) = subr(8);
+ CamelliaSubkeyL(9) = subl(9);
+ CamelliaSubkeyR(9) = subr(9);
+ tl = subl(7) ^ (subr(7) & ~subr(9));
+ dw = tl & subl(9), tr = subr(7) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(10) = tl ^ subl(11);
+ CamelliaSubkeyR(10) = tr ^ subr(11);
+ CamelliaSubkeyL(11) = subl(10) ^ subl(12);
+ CamelliaSubkeyR(11) = subr(10) ^ subr(12);
+ CamelliaSubkeyL(12) = subl(11) ^ subl(13);
+ CamelliaSubkeyR(12) = subr(11) ^ subr(13);
+ CamelliaSubkeyL(13) = subl(12) ^ subl(14);
+ CamelliaSubkeyR(13) = subr(12) ^ subr(14);
+ CamelliaSubkeyL(14) = subl(13) ^ subl(15);
+ CamelliaSubkeyR(14) = subr(13) ^ subr(15);
+ tl = subl(18) ^ (subr(18) & ~subr(16));
+ dw = tl & subl(16), tr = subr(18) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(15) = subl(14) ^ tl;
+ CamelliaSubkeyR(15) = subr(14) ^ tr;
+ CamelliaSubkeyL(16) = subl(16);
+ CamelliaSubkeyR(16) = subr(16);
+ CamelliaSubkeyL(17) = subl(17);
+ CamelliaSubkeyR(17) = subr(17);
+ tl = subl(15) ^ (subr(15) & ~subr(17));
+ dw = tl & subl(17), tr = subr(15) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(18) = tl ^ subl(19);
+ CamelliaSubkeyR(18) = tr ^ subr(19);
+ CamelliaSubkeyL(19) = subl(18) ^ subl(20);
+ CamelliaSubkeyR(19) = subr(18) ^ subr(20);
+ CamelliaSubkeyL(20) = subl(19) ^ subl(21);
+ CamelliaSubkeyR(20) = subr(19) ^ subr(21);
+ CamelliaSubkeyL(21) = subl(20) ^ subl(22);
+ CamelliaSubkeyR(21) = subr(20) ^ subr(22);
+ CamelliaSubkeyL(22) = subl(21) ^ subl(23);
+ CamelliaSubkeyR(22) = subr(21) ^ subr(23);
+ tl = subl(26) ^ (subr(26) & ~subr(24));
+ dw = tl & subl(24), tr = subr(26) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(23) = subl(22) ^ tl;
+ CamelliaSubkeyR(23) = subr(22) ^ tr;
+ CamelliaSubkeyL(24) = subl(24);
+ CamelliaSubkeyR(24) = subr(24);
+ CamelliaSubkeyL(25) = subl(25);
+ CamelliaSubkeyR(25) = subr(25);
+ tl = subl(23) ^ (subr(23) & ~subr(25));
+ dw = tl & subl(25), tr = subr(23) ^ CAMELLIA_RL1(dw);
+ CamelliaSubkeyL(26) = tl ^ subl(27);
+ CamelliaSubkeyR(26) = tr ^ subr(27);
+ CamelliaSubkeyL(27) = subl(26) ^ subl(28);
+ CamelliaSubkeyR(27) = subr(26) ^ subr(28);
+ CamelliaSubkeyL(28) = subl(27) ^ subl(29);
+ CamelliaSubkeyR(28) = subr(27) ^ subr(29);
+ CamelliaSubkeyL(29) = subl(28) ^ subl(30);
+ CamelliaSubkeyR(29) = subr(28) ^ subr(30);
+ CamelliaSubkeyL(30) = subl(29) ^ subl(31);
+ CamelliaSubkeyR(30) = subr(29) ^ subr(31);
+ CamelliaSubkeyL(31) = subl(30);
+ CamelliaSubkeyR(31) = subr(30);
+ CamelliaSubkeyL(32) = subl(32) ^ subl(31);
+ CamelliaSubkeyR(32) = subr(32) ^ subr(31);
+
+ /* apply the inverse of the last half of P-function */
+ dw = CamelliaSubkeyL(2) ^ CamelliaSubkeyR(2), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(2) = CamelliaSubkeyL(2) ^ dw, CamelliaSubkeyL(2) = dw;
+ dw = CamelliaSubkeyL(3) ^ CamelliaSubkeyR(3), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(3) = CamelliaSubkeyL(3) ^ dw, CamelliaSubkeyL(3) = dw;
+ dw = CamelliaSubkeyL(4) ^ CamelliaSubkeyR(4), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(4) = CamelliaSubkeyL(4) ^ dw, CamelliaSubkeyL(4) = dw;
+ dw = CamelliaSubkeyL(5) ^ CamelliaSubkeyR(5), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(5) = CamelliaSubkeyL(5) ^ dw, CamelliaSubkeyL(5) = dw;
+ dw = CamelliaSubkeyL(6) ^ CamelliaSubkeyR(6), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(6) = CamelliaSubkeyL(6) ^ dw, CamelliaSubkeyL(6) = dw;
+ dw = CamelliaSubkeyL(7) ^ CamelliaSubkeyR(7), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(7) = CamelliaSubkeyL(7) ^ dw, CamelliaSubkeyL(7) = dw;
+ dw = CamelliaSubkeyL(10) ^ CamelliaSubkeyR(10), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(10) = CamelliaSubkeyL(10) ^ dw, CamelliaSubkeyL(10) = dw;
+ dw = CamelliaSubkeyL(11) ^ CamelliaSubkeyR(11), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(11) = CamelliaSubkeyL(11) ^ dw, CamelliaSubkeyL(11) = dw;
+ dw = CamelliaSubkeyL(12) ^ CamelliaSubkeyR(12), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(12) = CamelliaSubkeyL(12) ^ dw, CamelliaSubkeyL(12) = dw;
+ dw = CamelliaSubkeyL(13) ^ CamelliaSubkeyR(13), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(13) = CamelliaSubkeyL(13) ^ dw, CamelliaSubkeyL(13) = dw;
+ dw = CamelliaSubkeyL(14) ^ CamelliaSubkeyR(14), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(14) = CamelliaSubkeyL(14) ^ dw, CamelliaSubkeyL(14) = dw;
+ dw = CamelliaSubkeyL(15) ^ CamelliaSubkeyR(15), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(15) = CamelliaSubkeyL(15) ^ dw, CamelliaSubkeyL(15) = dw;
+ dw = CamelliaSubkeyL(18) ^ CamelliaSubkeyR(18), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(18) = CamelliaSubkeyL(18) ^ dw, CamelliaSubkeyL(18) = dw;
+ dw = CamelliaSubkeyL(19) ^ CamelliaSubkeyR(19), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(19) = CamelliaSubkeyL(19) ^ dw, CamelliaSubkeyL(19) = dw;
+ dw = CamelliaSubkeyL(20) ^ CamelliaSubkeyR(20), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(20) = CamelliaSubkeyL(20) ^ dw, CamelliaSubkeyL(20) = dw;
+ dw = CamelliaSubkeyL(21) ^ CamelliaSubkeyR(21), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(21) = CamelliaSubkeyL(21) ^ dw, CamelliaSubkeyL(21) = dw;
+ dw = CamelliaSubkeyL(22) ^ CamelliaSubkeyR(22), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(22) = CamelliaSubkeyL(22) ^ dw, CamelliaSubkeyL(22) = dw;
+ dw = CamelliaSubkeyL(23) ^ CamelliaSubkeyR(23), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(23) = CamelliaSubkeyL(23) ^ dw, CamelliaSubkeyL(23) = dw;
+ dw = CamelliaSubkeyL(26) ^ CamelliaSubkeyR(26), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(26) = CamelliaSubkeyL(26) ^ dw, CamelliaSubkeyL(26) = dw;
+ dw = CamelliaSubkeyL(27) ^ CamelliaSubkeyR(27), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(27) = CamelliaSubkeyL(27) ^ dw, CamelliaSubkeyL(27) = dw;
+ dw = CamelliaSubkeyL(28) ^ CamelliaSubkeyR(28), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(28) = CamelliaSubkeyL(28) ^ dw, CamelliaSubkeyL(28) = dw;
+ dw = CamelliaSubkeyL(29) ^ CamelliaSubkeyR(29), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(29) = CamelliaSubkeyL(29) ^ dw, CamelliaSubkeyL(29) = dw;
+ dw = CamelliaSubkeyL(30) ^ CamelliaSubkeyR(30), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(30) = CamelliaSubkeyL(30) ^ dw, CamelliaSubkeyL(30) = dw;
+ dw = CamelliaSubkeyL(31) ^ CamelliaSubkeyR(31), dw = CAMELLIA_RL8(dw);
+ CamelliaSubkeyR(31) = CamelliaSubkeyL(31) ^ dw,CamelliaSubkeyL(31) = dw;
+
+ return;
+}
+
+void camellia_setup192(const unsigned char *key, u32 *subkey)
+{
+ unsigned char kk[32];
+ u32 krll, krlr, krrl,krrr;
+
+ memcpy(kk, key, 24);
+ memcpy((unsigned char *)&krll, key+16,4);
+ memcpy((unsigned char *)&krlr, key+20,4);
+ krrl = ~krll;
+ krrr = ~krlr;
+ memcpy(kk+24, (unsigned char *)&krrl, 4);
+ memcpy(kk+28, (unsigned char *)&krrr, 4);
+ camellia_setup256(kk, subkey);
+ return;
+}
+
+
+/**
+ * Stuff related to camellia encryption/decryption
+ *
+ * "io" must be 4byte aligned and big-endian data.
+ */
+void camellia_encrypt128(const u32 *subkey, u32 *io)
+{
+ u32 il, ir, t0, t1;
+
+ /* pre whitening but absorb kw2*/
+ io[0] ^= CamelliaSubkeyL(0);
+ io[1] ^= CamelliaSubkeyR(0);
+ /* main iteration */
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(2),CamelliaSubkeyR(2),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(3),CamelliaSubkeyR(3),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(4),CamelliaSubkeyR(4),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(5),CamelliaSubkeyR(5),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(6),CamelliaSubkeyR(6),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(7),CamelliaSubkeyR(7),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(8),CamelliaSubkeyR(8),
+ CamelliaSubkeyL(9),CamelliaSubkeyR(9),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(10),CamelliaSubkeyR(10),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(11),CamelliaSubkeyR(11),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(12),CamelliaSubkeyR(12),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(13),CamelliaSubkeyR(13),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(14),CamelliaSubkeyR(14),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(15),CamelliaSubkeyR(15),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(16),CamelliaSubkeyR(16),
+ CamelliaSubkeyL(17),CamelliaSubkeyR(17),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(18),CamelliaSubkeyR(18),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(19),CamelliaSubkeyR(19),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(20),CamelliaSubkeyR(20),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(21),CamelliaSubkeyR(21),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(22),CamelliaSubkeyR(22),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(23),CamelliaSubkeyR(23),
+ io[0],io[1],il,ir,t0,t1);
+
+ /* post whitening but kw4 */
+ io[2] ^= CamelliaSubkeyL(24);
+ io[3] ^= CamelliaSubkeyR(24);
+
+ t0 = io[0];
+ t1 = io[1];
+ io[0] = io[2];
+ io[1] = io[3];
+ io[2] = t0;
+ io[3] = t1;
+
+ return;
+}
+
+void camellia_decrypt128(const u32 *subkey, u32 *io)
+{
+ u32 il,ir,t0,t1; /* temporary valiables */
+
+ /* pre whitening but absorb kw2*/
+ io[0] ^= CamelliaSubkeyL(24);
+ io[1] ^= CamelliaSubkeyR(24);
+
+ /* main iteration */
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(23),CamelliaSubkeyR(23),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(22),CamelliaSubkeyR(22),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(21),CamelliaSubkeyR(21),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(20),CamelliaSubkeyR(20),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(19),CamelliaSubkeyR(19),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(18),CamelliaSubkeyR(18),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(17),CamelliaSubkeyR(17),
+ CamelliaSubkeyL(16),CamelliaSubkeyR(16),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(15),CamelliaSubkeyR(15),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(14),CamelliaSubkeyR(14),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(13),CamelliaSubkeyR(13),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(12),CamelliaSubkeyR(12),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(11),CamelliaSubkeyR(11),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(10),CamelliaSubkeyR(10),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(9),CamelliaSubkeyR(9),
+ CamelliaSubkeyL(8),CamelliaSubkeyR(8),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(7),CamelliaSubkeyR(7),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(6),CamelliaSubkeyR(6),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(5),CamelliaSubkeyR(5),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(4),CamelliaSubkeyR(4),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(3),CamelliaSubkeyR(3),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(2),CamelliaSubkeyR(2),
+ io[0],io[1],il,ir,t0,t1);
+
+ /* post whitening but kw4 */
+ io[2] ^= CamelliaSubkeyL(0);
+ io[3] ^= CamelliaSubkeyR(0);
+
+ t0 = io[0];
+ t1 = io[1];
+ io[0] = io[2];
+ io[1] = io[3];
+ io[2] = t0;
+ io[3] = t1;
+
+ return;
+}
+
+/**
+ * stuff for 192 and 256bit encryption/decryption
+ */
+void camellia_encrypt256(const u32 *subkey, u32 *io)
+{
+ u32 il,ir,t0,t1; /* temporary valiables */
+
+ /* pre whitening but absorb kw2*/
+ io[0] ^= CamelliaSubkeyL(0);
+ io[1] ^= CamelliaSubkeyR(0);
+
+ /* main iteration */
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(2),CamelliaSubkeyR(2),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(3),CamelliaSubkeyR(3),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(4),CamelliaSubkeyR(4),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(5),CamelliaSubkeyR(5),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(6),CamelliaSubkeyR(6),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(7),CamelliaSubkeyR(7),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(8),CamelliaSubkeyR(8),
+ CamelliaSubkeyL(9),CamelliaSubkeyR(9),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(10),CamelliaSubkeyR(10),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(11),CamelliaSubkeyR(11),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(12),CamelliaSubkeyR(12),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(13),CamelliaSubkeyR(13),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(14),CamelliaSubkeyR(14),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(15),CamelliaSubkeyR(15),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(16),CamelliaSubkeyR(16),
+ CamelliaSubkeyL(17),CamelliaSubkeyR(17),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(18),CamelliaSubkeyR(18),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(19),CamelliaSubkeyR(19),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(20),CamelliaSubkeyR(20),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(21),CamelliaSubkeyR(21),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(22),CamelliaSubkeyR(22),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(23),CamelliaSubkeyR(23),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(24),CamelliaSubkeyR(24),
+ CamelliaSubkeyL(25),CamelliaSubkeyR(25),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(26),CamelliaSubkeyR(26),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(27),CamelliaSubkeyR(27),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(28),CamelliaSubkeyR(28),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(29),CamelliaSubkeyR(29),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(30),CamelliaSubkeyR(30),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(31),CamelliaSubkeyR(31),
+ io[0],io[1],il,ir,t0,t1);
+
+ /* post whitening but kw4 */
+ io[2] ^= CamelliaSubkeyL(32);
+ io[3] ^= CamelliaSubkeyR(32);
+
+ t0 = io[0];
+ t1 = io[1];
+ io[0] = io[2];
+ io[1] = io[3];
+ io[2] = t0;
+ io[3] = t1;
+
+ return;
+}
+
+void camellia_decrypt256(const u32 *subkey, u32 *io)
+{
+ u32 il,ir,t0,t1; /* temporary valiables */
+
+ /* pre whitening but absorb kw2*/
+ io[0] ^= CamelliaSubkeyL(32);
+ io[1] ^= CamelliaSubkeyR(32);
+
+ /* main iteration */
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(31),CamelliaSubkeyR(31),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(30),CamelliaSubkeyR(30),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(29),CamelliaSubkeyR(29),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(28),CamelliaSubkeyR(28),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(27),CamelliaSubkeyR(27),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(26),CamelliaSubkeyR(26),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(25),CamelliaSubkeyR(25),
+ CamelliaSubkeyL(24),CamelliaSubkeyR(24),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(23),CamelliaSubkeyR(23),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(22),CamelliaSubkeyR(22),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(21),CamelliaSubkeyR(21),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(20),CamelliaSubkeyR(20),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(19),CamelliaSubkeyR(19),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(18),CamelliaSubkeyR(18),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(17),CamelliaSubkeyR(17),
+ CamelliaSubkeyL(16),CamelliaSubkeyR(16),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(15),CamelliaSubkeyR(15),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(14),CamelliaSubkeyR(14),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(13),CamelliaSubkeyR(13),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(12),CamelliaSubkeyR(12),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(11),CamelliaSubkeyR(11),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(10),CamelliaSubkeyR(10),
+ io[0],io[1],il,ir,t0,t1);
+
+ CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+ CamelliaSubkeyL(9),CamelliaSubkeyR(9),
+ CamelliaSubkeyL(8),CamelliaSubkeyR(8),
+ t0,t1,il,ir);
+
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(7),CamelliaSubkeyR(7),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(6),CamelliaSubkeyR(6),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(5),CamelliaSubkeyR(5),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(4),CamelliaSubkeyR(4),
+ io[0],io[1],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[0],io[1],
+ CamelliaSubkeyL(3),CamelliaSubkeyR(3),
+ io[2],io[3],il,ir,t0,t1);
+ CAMELLIA_ROUNDSM(io[2],io[3],
+ CamelliaSubkeyL(2),CamelliaSubkeyR(2),
+ io[0],io[1],il,ir,t0,t1);
+
+ /* post whitening but kw4 */
+ io[2] ^= CamelliaSubkeyL(0);
+ io[3] ^= CamelliaSubkeyR(0);
+
+ t0 = io[0];
+ t1 = io[1];
+ io[0] = io[2];
+ io[1] = io[3];
+ io[2] = t0;
+ io[3] = t1;
+
+ return;
+}
+
+/***
+ *
+ * API for compatibility
+ */
+
+void Camellia_Ekeygen(const int keyBitLength,
+ const unsigned char *rawKey,
+ KEY_TABLE_TYPE keyTable)
+{
+ switch(keyBitLength) {
+ case 128:
+ camellia_setup128(rawKey, keyTable);
+ break;
+ case 192:
+ camellia_setup192(rawKey, keyTable);
+ break;
+ case 256:
+ camellia_setup256(rawKey, keyTable);
+ break;
+ default:
+ break;
+ }
+}
+
+
+void Camellia_EncryptBlock(const int keyBitLength,
+ const unsigned char *plaintext,
+ const KEY_TABLE_TYPE keyTable,
+ unsigned char *ciphertext)
+{
+ u32 tmp[4];
+
+ tmp[0] = GETU32(plaintext);
+ tmp[1] = GETU32(plaintext + 4);
+ tmp[2] = GETU32(plaintext + 8);
+ tmp[3] = GETU32(plaintext + 12);
+
+ switch (keyBitLength) {
+ case 128:
+ camellia_encrypt128(keyTable, tmp);
+ break;
+ case 192:
+ /* fall through */
+ case 256:
+ camellia_encrypt256(keyTable, tmp);
+ break;
+ default:
+ break;
+ }
+
+ PUTU32(ciphertext, tmp[0]);
+ PUTU32(ciphertext + 4, tmp[1]);
+ PUTU32(ciphertext + 8, tmp[2]);
+ PUTU32(ciphertext + 12, tmp[3]);
+}
+
+void Camellia_DecryptBlock(const int keyBitLength,
+ const unsigned char *ciphertext,
+ const KEY_TABLE_TYPE keyTable,
+ unsigned char *plaintext)
+{
+ u32 tmp[4];
+
+ tmp[0] = GETU32(ciphertext);
+ tmp[1] = GETU32(ciphertext + 4);
+ tmp[2] = GETU32(ciphertext + 8);
+ tmp[3] = GETU32(ciphertext + 12);
+
+ switch (keyBitLength) {
+ case 128:
+ camellia_decrypt128(keyTable, tmp);
+ break;
+ case 192:
+ /* fall through */
+ case 256:
+ camellia_decrypt256(keyTable, tmp);
+ break;
+ default:
+ break;
+ }
+ PUTU32(plaintext, tmp[0]);
+ PUTU32(plaintext + 4, tmp[1]);
+ PUTU32(plaintext + 8, tmp[2]);
+ PUTU32(plaintext + 12, tmp[3]);
+}
diff --git a/grub-core/lib/libgcrypt/cipher/camellia.h b/grub-core/lib/libgcrypt/cipher/camellia.h
new file mode 100644
index 0000000..cccf786
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/camellia.h
@@ -0,0 +1,81 @@
+/* camellia.h ver 1.2.0
+ *
+ * Copyright (C) 2006,2007
+ * NTT (Nippon Telegraph and Telephone Corporation).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef HEADER_CAMELLIA_H
+#define HEADER_CAMELLIA_H
+
+/* To use Camellia with libraries it is often useful to keep the name
+ * space of the library clean. The following macro is thus useful:
+ *
+ * #define CAMELLIA_EXT_SYM_PREFIX foo_
+ *
+ * This prefixes all external symbols with "foo_".
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef CAMELLIA_EXT_SYM_PREFIX
+#define CAMELLIA_PREFIX1(x,y) x ## y
+#define CAMELLIA_PREFIX2(x,y) CAMELLIA_PREFIX1(x,y)
+#define CAMELLIA_PREFIX(x) CAMELLIA_PREFIX2(CAMELLIA_EXT_SYM_PREFIX,x)
+#define Camellia_Ekeygen CAMELLIA_PREFIX(Camellia_Ekeygen)
+#define Camellia_EncryptBlock CAMELLIA_PREFIX(Camellia_EncryptBlock)
+#define Camellia_DecryptBlock CAMELLIA_PREFIX(Camellia_DecryptBlock)
+#define camellia_decrypt128 CAMELLIA_PREFIX(camellia_decrypt128)
+#define camellia_decrypt256 CAMELLIA_PREFIX(camellia_decrypt256)
+#define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128)
+#define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256)
+#define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128)
+#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192)
+#define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256)
+#endif /*CAMELLIA_EXT_SYM_PREFIX*/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CAMELLIA_BLOCK_SIZE 16
+#define CAMELLIA_TABLE_BYTE_LEN 272
+#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
+
+typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
+
+
+void Camellia_Ekeygen(const int keyBitLength,
+ const unsigned char *rawKey,
+ KEY_TABLE_TYPE keyTable);
+
+void Camellia_EncryptBlock(const int keyBitLength,
+ const unsigned char *plaintext,
+ const KEY_TABLE_TYPE keyTable,
+ unsigned char *cipherText);
+
+void Camellia_DecryptBlock(const int keyBitLength,
+ const unsigned char *cipherText,
+ const KEY_TABLE_TYPE keyTable,
+ unsigned char *plaintext);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HEADER_CAMELLIA_H */
diff --git a/grub-core/lib/libgcrypt/cipher/cast5.c b/grub-core/lib/libgcrypt/cipher/cast5.c
new file mode 100644
index 0000000..9905f5c
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/cast5.c
@@ -0,0 +1,620 @@
+/* cast5.c - CAST5 cipher (RFC2144)
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/* Test vectors:
+ *
+ * 128-bit key = 01 23 45 67 12 34 56 78 23 45 67 89 34 56 78 9A
+ * plaintext = 01 23 45 67 89 AB CD EF
+ * ciphertext = 23 8B 4F E5 84 7E 44 B2
+ *
+ * 80-bit key = 01 23 45 67 12 34 56 78 23 45
+ * = 01 23 45 67 12 34 56 78 23 45 00 00 00 00 00 00
+ * plaintext = 01 23 45 67 89 AB CD EF
+ * ciphertext = EB 6A 71 1A 2C 02 27 1B
+ *
+ * 40-bit key = 01 23 45 67 12
+ * = 01 23 45 67 12 00 00 00 00 00 00 00 00 00 00 00
+ * plaintext = 01 23 45 67 89 AB CD EF
+ * ciphertext = 7A C8 16 D1 6E 9B 30 2E
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "g10lib.h"
+#include "types.h"
+#include "cipher.h"
+
+#define CAST5_BLOCKSIZE 8
+
+typedef struct {
+ u32 Km[16];
+ byte Kr[16];
+} CAST5_context;
+
+static gcry_err_code_t cast_setkey (void *c, const byte *key, unsigned keylen);
+static void encrypt_block (void *c, byte *outbuf, const byte *inbuf);
+static void decrypt_block (void *c, byte *outbuf, const byte *inbuf);
+
+
+
+
+static const u32 s1[256] = {
+0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x9c004dd3, 0x6003e540, 0xcf9fc949,
+0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, 0x15c361d2, 0xc2e7661d, 0x22d4ff8e,
+0x28683b6f, 0xc07fd059, 0xff2379c8, 0x775f50e2, 0x43c340d3, 0xdf2f8656, 0x887ca41a, 0xa2d2bd2d,
+0xa1c9e0d6, 0x346c4819, 0x61b76d87, 0x22540f2f, 0x2abe32e1, 0xaa54166b, 0x22568e3a, 0xa2d341d0,
+0x66db40c8, 0xa784392f, 0x004dff2f, 0x2db9d2de, 0x97943fac, 0x4a97c1d8, 0x527644b7, 0xb5f437a7,
+0xb82cbaef, 0xd751d159, 0x6ff7f0ed, 0x5a097a1f, 0x827b68d0, 0x90ecf52e, 0x22b0c054, 0xbc8e5935,
+0x4b6d2f7f, 0x50bb64a2, 0xd2664910, 0xbee5812d, 0xb7332290, 0xe93b159f, 0xb48ee411, 0x4bff345d,
+0xfd45c240, 0xad31973f, 0xc4f6d02e, 0x55fc8165, 0xd5b1caad, 0xa1ac2dae, 0xa2d4b76d, 0xc19b0c50,
+0x882240f2, 0x0c6e4f38, 0xa4e4bfd7, 0x4f5ba272, 0x564c1d2f, 0xc59c5319, 0xb949e354, 0xb04669fe,
+0xb1b6ab8a, 0xc71358dd, 0x6385c545, 0x110f935d, 0x57538ad5, 0x6a390493, 0xe63d37e0, 0x2a54f6b3,
+0x3a787d5f, 0x6276a0b5, 0x19a6fcdf, 0x7a42206a, 0x29f9d4d5, 0xf61b1891, 0xbb72275e, 0xaa508167,
+0x38901091, 0xc6b505eb, 0x84c7cb8c, 0x2ad75a0f, 0x874a1427, 0xa2d1936b, 0x2ad286af, 0xaa56d291,
+0xd7894360, 0x425c750d, 0x93b39e26, 0x187184c9, 0x6c00b32d, 0x73e2bb14, 0xa0bebc3c, 0x54623779,
+0x64459eab, 0x3f328b82, 0x7718cf82, 0x59a2cea6, 0x04ee002e, 0x89fe78e6, 0x3fab0950, 0x325ff6c2,
+0x81383f05, 0x6963c5c8, 0x76cb5ad6, 0xd49974c9, 0xca180dcf, 0x380782d5, 0xc7fa5cf6, 0x8ac31511,
+0x35e79e13, 0x47da91d0, 0xf40f9086, 0xa7e2419e, 0x31366241, 0x051ef495, 0xaa573b04, 0x4a805d8d,
+0x548300d0, 0x00322a3c, 0xbf64cddf, 0xba57a68e, 0x75c6372b, 0x50afd341, 0xa7c13275, 0x915a0bf5,
+0x6b54bfab, 0x2b0b1426, 0xab4cc9d7, 0x449ccd82, 0xf7fbf265, 0xab85c5f3, 0x1b55db94, 0xaad4e324,
+0xcfa4bd3f, 0x2deaa3e2, 0x9e204d02, 0xc8bd25ac, 0xeadf55b3, 0xd5bd9e98, 0xe31231b2, 0x2ad5ad6c,
+0x954329de, 0xadbe4528, 0xd8710f69, 0xaa51c90f, 0xaa786bf6, 0x22513f1e, 0xaa51a79b, 0x2ad344cc,
+0x7b5a41f0, 0xd37cfbad, 0x1b069505, 0x41ece491, 0xb4c332e6, 0x032268d4, 0xc9600acc, 0xce387e6d,
+0xbf6bb16c, 0x6a70fb78, 0x0d03d9c9, 0xd4df39de, 0xe01063da, 0x4736f464, 0x5ad328d8, 0xb347cc96,
+0x75bb0fc3, 0x98511bfb, 0x4ffbcc35, 0xb58bcf6a, 0xe11f0abc, 0xbfc5fe4a, 0xa70aec10, 0xac39570a,
+0x3f04442f, 0x6188b153, 0xe0397a2e, 0x5727cb79, 0x9ceb418f, 0x1cacd68d, 0x2ad37c96, 0x0175cb9d,
+0xc69dff09, 0xc75b65f0, 0xd9db40d8, 0xec0e7779, 0x4744ead4, 0xb11c3274, 0xdd24cb9e, 0x7e1c54bd,
+0xf01144f9, 0xd2240eb1, 0x9675b3fd, 0xa3ac3755, 0xd47c27af, 0x51c85f4d, 0x56907596, 0xa5bb15e6,
+0x580304f0, 0xca042cf1, 0x011a37ea, 0x8dbfaadb, 0x35ba3e4a, 0x3526ffa0, 0xc37b4d09, 0xbc306ed9,
+0x98a52666, 0x5648f725, 0xff5e569d, 0x0ced63d0, 0x7c63b2cf, 0x700b45e1, 0xd5ea50f1, 0x85a92872,
+0xaf1fbda7, 0xd4234870, 0xa7870bf3, 0x2d3b4d79, 0x42e04198, 0x0cd0ede7, 0x26470db8, 0xf881814c,
+0x474d6ad7, 0x7c0c5e5c, 0xd1231959, 0x381b7298, 0xf5d2f4db, 0xab838653, 0x6e2f1e23, 0x83719c9e,
+0xbd91e046, 0x9a56456e, 0xdc39200c, 0x20c8c571, 0x962bda1c, 0xe1e696ff, 0xb141ab08, 0x7cca89b9,
+0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c, 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf
+};
+static const u32 s2[256] = {
+0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, 0xeec5207a, 0x55889c94, 0x72fc0651,
+0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, 0x5f0c0794, 0x18dcdb7d, 0xa1d6eff3,
+0xa0b52f7b, 0x59e83605, 0xee15b094, 0xe9ffd909, 0xdc440086, 0xef944459, 0xba83ccb3, 0xe0c3cdfb,
+0xd1da4181, 0x3b092ab1, 0xf997f1c1, 0xa5e6cf7b, 0x01420ddb, 0xe4e7ef5b, 0x25a1ff41, 0xe180f806,
+0x1fc41080, 0x179bee7a, 0xd37ac6a9, 0xfe5830a4, 0x98de8b7f, 0x77e83f4e, 0x79929269, 0x24fa9f7b,
+0xe113c85b, 0xacc40083, 0xd7503525, 0xf7ea615f, 0x62143154, 0x0d554b63, 0x5d681121, 0xc866c359,
+0x3d63cf73, 0xcee234c0, 0xd4d87e87, 0x5c672b21, 0x071f6181, 0x39f7627f, 0x361e3084, 0xe4eb573b,
+0x602f64a4, 0xd63acd9c, 0x1bbc4635, 0x9e81032d, 0x2701f50c, 0x99847ab4, 0xa0e3df79, 0xba6cf38c,
+0x10843094, 0x2537a95e, 0xf46f6ffe, 0xa1ff3b1f, 0x208cfb6a, 0x8f458c74, 0xd9e0a227, 0x4ec73a34,
+0xfc884f69, 0x3e4de8df, 0xef0e0088, 0x3559648d, 0x8a45388c, 0x1d804366, 0x721d9bfd, 0xa58684bb,
+0xe8256333, 0x844e8212, 0x128d8098, 0xfed33fb4, 0xce280ae1, 0x27e19ba5, 0xd5a6c252, 0xe49754bd,
+0xc5d655dd, 0xeb667064, 0x77840b4d, 0xa1b6a801, 0x84db26a9, 0xe0b56714, 0x21f043b7, 0xe5d05860,
+0x54f03084, 0x066ff472, 0xa31aa153, 0xdadc4755, 0xb5625dbf, 0x68561be6, 0x83ca6b94, 0x2d6ed23b,
+0xeccf01db, 0xa6d3d0ba, 0xb6803d5c, 0xaf77a709, 0x33b4a34c, 0x397bc8d6, 0x5ee22b95, 0x5f0e5304,
+0x81ed6f61, 0x20e74364, 0xb45e1378, 0xde18639b, 0x881ca122, 0xb96726d1, 0x8049a7e8, 0x22b7da7b,
+0x5e552d25, 0x5272d237, 0x79d2951c, 0xc60d894c, 0x488cb402, 0x1ba4fe5b, 0xa4b09f6b, 0x1ca815cf,
+0xa20c3005, 0x8871df63, 0xb9de2fcb, 0x0cc6c9e9, 0x0beeff53, 0xe3214517, 0xb4542835, 0x9f63293c,
+0xee41e729, 0x6e1d2d7c, 0x50045286, 0x1e6685f3, 0xf33401c6, 0x30a22c95, 0x31a70850, 0x60930f13,
+0x73f98417, 0xa1269859, 0xec645c44, 0x52c877a9, 0xcdff33a6, 0xa02b1741, 0x7cbad9a2, 0x2180036f,
+0x50d99c08, 0xcb3f4861, 0xc26bd765, 0x64a3f6ab, 0x80342676, 0x25a75e7b, 0xe4e6d1fc, 0x20c710e6,
+0xcdf0b680, 0x17844d3b, 0x31eef84d, 0x7e0824e4, 0x2ccb49eb, 0x846a3bae, 0x8ff77888, 0xee5d60f6,
+0x7af75673, 0x2fdd5cdb, 0xa11631c1, 0x30f66f43, 0xb3faec54, 0x157fd7fa, 0xef8579cc, 0xd152de58,
+0xdb2ffd5e, 0x8f32ce19, 0x306af97a, 0x02f03ef8, 0x99319ad5, 0xc242fa0f, 0xa7e3ebb0, 0xc68e4906,
+0xb8da230c, 0x80823028, 0xdcdef3c8, 0xd35fb171, 0x088a1bc8, 0xbec0c560, 0x61a3c9e8, 0xbca8f54d,
+0xc72feffa, 0x22822e99, 0x82c570b4, 0xd8d94e89, 0x8b1c34bc, 0x301e16e6, 0x273be979, 0xb0ffeaa6,
+0x61d9b8c6, 0x00b24869, 0xb7ffce3f, 0x08dc283b, 0x43daf65a, 0xf7e19798, 0x7619b72f, 0x8f1c9ba4,
+0xdc8637a0, 0x16a7d3b1, 0x9fc393b7, 0xa7136eeb, 0xc6bcc63e, 0x1a513742, 0xef6828bc, 0x520365d6,
+0x2d6a77ab, 0x3527ed4b, 0x821fd216, 0x095c6e2e, 0xdb92f2fb, 0x5eea29cb, 0x145892f5, 0x91584f7f,
+0x5483697b, 0x2667a8cc, 0x85196048, 0x8c4bacea, 0x833860d4, 0x0d23e0f9, 0x6c387e8a, 0x0ae6d249,
+0xb284600c, 0xd835731d, 0xdcb1c647, 0xac4c56ea, 0x3ebd81b3, 0x230eabb0, 0x6438bc87, 0xf0b5b1fa,
+0x8f5ea2b3, 0xfc184642, 0x0a036b7a, 0x4fb089bd, 0x649da589, 0xa345415e, 0x5c038323, 0x3e5d3bb9,
+0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539, 0x73bfbe70, 0x83877605, 0x4523ecf1
+};
+static const u32 s3[256] = {
+0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, 0x369fe44b, 0x8c1fc644, 0xaececa90,
+0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, 0xf0ad0548, 0xe13c8d83, 0x927010d5,
+0x11107d9f, 0x07647db9, 0xb2e3e4d4, 0x3d4f285e, 0xb9afa820, 0xfade82e0, 0xa067268b, 0x8272792e,
+0x553fb2c0, 0x489ae22b, 0xd4ef9794, 0x125e3fbc, 0x21fffcee, 0x825b1bfd, 0x9255c5ed, 0x1257a240,
+0x4e1a8302, 0xbae07fff, 0x528246e7, 0x8e57140e, 0x3373f7bf, 0x8c9f8188, 0xa6fc4ee8, 0xc982b5a5,
+0xa8c01db7, 0x579fc264, 0x67094f31, 0xf2bd3f5f, 0x40fff7c1, 0x1fb78dfc, 0x8e6bd2c1, 0x437be59b,
+0x99b03dbf, 0xb5dbc64b, 0x638dc0e6, 0x55819d99, 0xa197c81c, 0x4a012d6e, 0xc5884a28, 0xccc36f71,
+0xb843c213, 0x6c0743f1, 0x8309893c, 0x0feddd5f, 0x2f7fe850, 0xd7c07f7e, 0x02507fbf, 0x5afb9a04,
+0xa747d2d0, 0x1651192e, 0xaf70bf3e, 0x58c31380, 0x5f98302e, 0x727cc3c4, 0x0a0fb402, 0x0f7fef82,
+0x8c96fdad, 0x5d2c2aae, 0x8ee99a49, 0x50da88b8, 0x8427f4a0, 0x1eac5790, 0x796fb449, 0x8252dc15,
+0xefbd7d9b, 0xa672597d, 0xada840d8, 0x45f54504, 0xfa5d7403, 0xe83ec305, 0x4f91751a, 0x925669c2,
+0x23efe941, 0xa903f12e, 0x60270df2, 0x0276e4b6, 0x94fd6574, 0x927985b2, 0x8276dbcb, 0x02778176,
+0xf8af918d, 0x4e48f79e, 0x8f616ddf, 0xe29d840e, 0x842f7d83, 0x340ce5c8, 0x96bbb682, 0x93b4b148,
+0xef303cab, 0x984faf28, 0x779faf9b, 0x92dc560d, 0x224d1e20, 0x8437aa88, 0x7d29dc96, 0x2756d3dc,
+0x8b907cee, 0xb51fd240, 0xe7c07ce3, 0xe566b4a1, 0xc3e9615e, 0x3cf8209d, 0x6094d1e3, 0xcd9ca341,
+0x5c76460e, 0x00ea983b, 0xd4d67881, 0xfd47572c, 0xf76cedd9, 0xbda8229c, 0x127dadaa, 0x438a074e,
+0x1f97c090, 0x081bdb8a, 0x93a07ebe, 0xb938ca15, 0x97b03cff, 0x3dc2c0f8, 0x8d1ab2ec, 0x64380e51,
+0x68cc7bfb, 0xd90f2788, 0x12490181, 0x5de5ffd4, 0xdd7ef86a, 0x76a2e214, 0xb9a40368, 0x925d958f,
+0x4b39fffa, 0xba39aee9, 0xa4ffd30b, 0xfaf7933b, 0x6d498623, 0x193cbcfa, 0x27627545, 0x825cf47a,
+0x61bd8ba0, 0xd11e42d1, 0xcead04f4, 0x127ea392, 0x10428db7, 0x8272a972, 0x9270c4a8, 0x127de50b,
+0x285ba1c8, 0x3c62f44f, 0x35c0eaa5, 0xe805d231, 0x428929fb, 0xb4fcdf82, 0x4fb66a53, 0x0e7dc15b,
+0x1f081fab, 0x108618ae, 0xfcfd086d, 0xf9ff2889, 0x694bcc11, 0x236a5cae, 0x12deca4d, 0x2c3f8cc5,
+0xd2d02dfe, 0xf8ef5896, 0xe4cf52da, 0x95155b67, 0x494a488c, 0xb9b6a80c, 0x5c8f82bc, 0x89d36b45,
+0x3a609437, 0xec00c9a9, 0x44715253, 0x0a874b49, 0xd773bc40, 0x7c34671c, 0x02717ef6, 0x4feb5536,
+0xa2d02fff, 0xd2bf60c4, 0xd43f03c0, 0x50b4ef6d, 0x07478cd1, 0x006e1888, 0xa2e53f55, 0xb9e6d4bc,
+0xa2048016, 0x97573833, 0xd7207d67, 0xde0f8f3d, 0x72f87b33, 0xabcc4f33, 0x7688c55d, 0x7b00a6b0,
+0x947b0001, 0x570075d2, 0xf9bb88f8, 0x8942019e, 0x4264a5ff, 0x856302e0, 0x72dbd92b, 0xee971b69,
+0x6ea22fde, 0x5f08ae2b, 0xaf7a616d, 0xe5c98767, 0xcf1febd2, 0x61efc8c2, 0xf1ac2571, 0xcc8239c2,
+0x67214cb8, 0xb1e583d1, 0xb7dc3e62, 0x7f10bdce, 0xf90a5c38, 0x0ff0443d, 0x606e6dc6, 0x60543a49,
+0x5727c148, 0x2be98a1d, 0x8ab41738, 0x20e1be24, 0xaf96da0f, 0x68458425, 0x99833be5, 0x600d457d,
+0x282f9350, 0x8334b362, 0xd91d1120, 0x2b6d8da0, 0x642b1e31, 0x9c305a00, 0x52bce688, 0x1b03588a,
+0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636, 0xa133c501, 0xe9d3531c, 0xee353783
+};
+static const u32 s4[256] = {
+0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, 0x64ad8c57, 0x85510443, 0xfa020ed1,
+0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, 0x6497b7b1, 0xf3641f63, 0x241e4adf,
+0x28147f5f, 0x4fa2b8cd, 0xc9430040, 0x0cc32220, 0xfdd30b30, 0xc0a5374f, 0x1d2d00d9, 0x24147b15,
+0xee4d111a, 0x0fca5167, 0x71ff904c, 0x2d195ffe, 0x1a05645f, 0x0c13fefe, 0x081b08ca, 0x05170121,
+0x80530100, 0xe83e5efe, 0xac9af4f8, 0x7fe72701, 0xd2b8ee5f, 0x06df4261, 0xbb9e9b8a, 0x7293ea25,
+0xce84ffdf, 0xf5718801, 0x3dd64b04, 0xa26f263b, 0x7ed48400, 0x547eebe6, 0x446d4ca0, 0x6cf3d6f5,
+0x2649abdf, 0xaea0c7f5, 0x36338cc1, 0x503f7e93, 0xd3772061, 0x11b638e1, 0x72500e03, 0xf80eb2bb,
+0xabe0502e, 0xec8d77de, 0x57971e81, 0xe14f6746, 0xc9335400, 0x6920318f, 0x081dbb99, 0xffc304a5,
+0x4d351805, 0x7f3d5ce3, 0xa6c866c6, 0x5d5bcca9, 0xdaec6fea, 0x9f926f91, 0x9f46222f, 0x3991467d,
+0xa5bf6d8e, 0x1143c44f, 0x43958302, 0xd0214eeb, 0x022083b8, 0x3fb6180c, 0x18f8931e, 0x281658e6,
+0x26486e3e, 0x8bd78a70, 0x7477e4c1, 0xb506e07c, 0xf32d0a25, 0x79098b02, 0xe4eabb81, 0x28123b23,
+0x69dead38, 0x1574ca16, 0xdf871b62, 0x211c40b7, 0xa51a9ef9, 0x0014377b, 0x041e8ac8, 0x09114003,
+0xbd59e4d2, 0xe3d156d5, 0x4fe876d5, 0x2f91a340, 0x557be8de, 0x00eae4a7, 0x0ce5c2ec, 0x4db4bba6,
+0xe756bdff, 0xdd3369ac, 0xec17b035, 0x06572327, 0x99afc8b0, 0x56c8c391, 0x6b65811c, 0x5e146119,
+0x6e85cb75, 0xbe07c002, 0xc2325577, 0x893ff4ec, 0x5bbfc92d, 0xd0ec3b25, 0xb7801ab7, 0x8d6d3b24,
+0x20c763ef, 0xc366a5fc, 0x9c382880, 0x0ace3205, 0xaac9548a, 0xeca1d7c7, 0x041afa32, 0x1d16625a,
+0x6701902c, 0x9b757a54, 0x31d477f7, 0x9126b031, 0x36cc6fdb, 0xc70b8b46, 0xd9e66a48, 0x56e55a79,
+0x026a4ceb, 0x52437eff, 0x2f8f76b4, 0x0df980a5, 0x8674cde3, 0xedda04eb, 0x17a9be04, 0x2c18f4df,
+0xb7747f9d, 0xab2af7b4, 0xefc34d20, 0x2e096b7c, 0x1741a254, 0xe5b6a035, 0x213d42f6, 0x2c1c7c26,
+0x61c2f50f, 0x6552daf9, 0xd2c231f8, 0x25130f69, 0xd8167fa2, 0x0418f2c8, 0x001a96a6, 0x0d1526ab,
+0x63315c21, 0x5e0a72ec, 0x49bafefd, 0x187908d9, 0x8d0dbd86, 0x311170a7, 0x3e9b640c, 0xcc3e10d7,
+0xd5cad3b6, 0x0caec388, 0xf73001e1, 0x6c728aff, 0x71eae2a1, 0x1f9af36e, 0xcfcbd12f, 0xc1de8417,
+0xac07be6b, 0xcb44a1d8, 0x8b9b0f56, 0x013988c3, 0xb1c52fca, 0xb4be31cd, 0xd8782806, 0x12a3a4e2,
+0x6f7de532, 0x58fd7eb6, 0xd01ee900, 0x24adffc2, 0xf4990fc5, 0x9711aac5, 0x001d7b95, 0x82e5e7d2,
+0x109873f6, 0x00613096, 0xc32d9521, 0xada121ff, 0x29908415, 0x7fbb977f, 0xaf9eb3db, 0x29c9ed2a,
+0x5ce2a465, 0xa730f32c, 0xd0aa3fe8, 0x8a5cc091, 0xd49e2ce7, 0x0ce454a9, 0xd60acd86, 0x015f1919,
+0x77079103, 0xdea03af6, 0x78a8565e, 0xdee356df, 0x21f05cbe, 0x8b75e387, 0xb3c50651, 0xb8a5c3ef,
+0xd8eeb6d2, 0xe523be77, 0xc2154529, 0x2f69efdf, 0xafe67afb, 0xf470c4b2, 0xf3e0eb5b, 0xd6cc9876,
+0x39e4460c, 0x1fda8538, 0x1987832f, 0xca007367, 0xa99144f8, 0x296b299e, 0x492fc295, 0x9266beab,
+0xb5676e69, 0x9bd3ddda, 0xdf7e052f, 0xdb25701c, 0x1b5e51ee, 0xf65324e6, 0x6afce36c, 0x0316cc04,
+0x8644213e, 0xb7dc59d0, 0x7965291f, 0xccd6fd43, 0x41823979, 0x932bcdf6, 0xb657c34d, 0x4edfd282,
+0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0, 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2
+};
+static const u32 s5[256] = {
+0x7ec90c04, 0x2c6e74b9, 0x9b0e66df, 0xa6337911, 0xb86a7fff, 0x1dd358f5, 0x44dd9d44, 0x1731167f,
+0x08fbf1fa, 0xe7f511cc, 0xd2051b00, 0x735aba00, 0x2ab722d8, 0x386381cb, 0xacf6243a, 0x69befd7a,
+0xe6a2e77f, 0xf0c720cd, 0xc4494816, 0xccf5c180, 0x38851640, 0x15b0a848, 0xe68b18cb, 0x4caadeff,
+0x5f480a01, 0x0412b2aa, 0x259814fc, 0x41d0efe2, 0x4e40b48d, 0x248eb6fb, 0x8dba1cfe, 0x41a99b02,
+0x1a550a04, 0xba8f65cb, 0x7251f4e7, 0x95a51725, 0xc106ecd7, 0x97a5980a, 0xc539b9aa, 0x4d79fe6a,
+0xf2f3f763, 0x68af8040, 0xed0c9e56, 0x11b4958b, 0xe1eb5a88, 0x8709e6b0, 0xd7e07156, 0x4e29fea7,
+0x6366e52d, 0x02d1c000, 0xc4ac8e05, 0x9377f571, 0x0c05372a, 0x578535f2, 0x2261be02, 0xd642a0c9,
+0xdf13a280, 0x74b55bd2, 0x682199c0, 0xd421e5ec, 0x53fb3ce8, 0xc8adedb3, 0x28a87fc9, 0x3d959981,
+0x5c1ff900, 0xfe38d399, 0x0c4eff0b, 0x062407ea, 0xaa2f4fb1, 0x4fb96976, 0x90c79505, 0xb0a8a774,
+0xef55a1ff, 0xe59ca2c2, 0xa6b62d27, 0xe66a4263, 0xdf65001f, 0x0ec50966, 0xdfdd55bc, 0x29de0655,
+0x911e739a, 0x17af8975, 0x32c7911c, 0x89f89468, 0x0d01e980, 0x524755f4, 0x03b63cc9, 0x0cc844b2,
+0xbcf3f0aa, 0x87ac36e9, 0xe53a7426, 0x01b3d82b, 0x1a9e7449, 0x64ee2d7e, 0xcddbb1da, 0x01c94910,
+0xb868bf80, 0x0d26f3fd, 0x9342ede7, 0x04a5c284, 0x636737b6, 0x50f5b616, 0xf24766e3, 0x8eca36c1,
+0x136e05db, 0xfef18391, 0xfb887a37, 0xd6e7f7d4, 0xc7fb7dc9, 0x3063fcdf, 0xb6f589de, 0xec2941da,
+0x26e46695, 0xb7566419, 0xf654efc5, 0xd08d58b7, 0x48925401, 0xc1bacb7f, 0xe5ff550f, 0xb6083049,
+0x5bb5d0e8, 0x87d72e5a, 0xab6a6ee1, 0x223a66ce, 0xc62bf3cd, 0x9e0885f9, 0x68cb3e47, 0x086c010f,
+0xa21de820, 0xd18b69de, 0xf3f65777, 0xfa02c3f6, 0x407edac3, 0xcbb3d550, 0x1793084d, 0xb0d70eba,
+0x0ab378d5, 0xd951fb0c, 0xded7da56, 0x4124bbe4, 0x94ca0b56, 0x0f5755d1, 0xe0e1e56e, 0x6184b5be,
+0x580a249f, 0x94f74bc0, 0xe327888e, 0x9f7b5561, 0xc3dc0280, 0x05687715, 0x646c6bd7, 0x44904db3,
+0x66b4f0a3, 0xc0f1648a, 0x697ed5af, 0x49e92ff6, 0x309e374f, 0x2cb6356a, 0x85808573, 0x4991f840,
+0x76f0ae02, 0x083be84d, 0x28421c9a, 0x44489406, 0x736e4cb8, 0xc1092910, 0x8bc95fc6, 0x7d869cf4,
+0x134f616f, 0x2e77118d, 0xb31b2be1, 0xaa90b472, 0x3ca5d717, 0x7d161bba, 0x9cad9010, 0xaf462ba2,
+0x9fe459d2, 0x45d34559, 0xd9f2da13, 0xdbc65487, 0xf3e4f94e, 0x176d486f, 0x097c13ea, 0x631da5c7,
+0x445f7382, 0x175683f4, 0xcdc66a97, 0x70be0288, 0xb3cdcf72, 0x6e5dd2f3, 0x20936079, 0x459b80a5,
+0xbe60e2db, 0xa9c23101, 0xeba5315c, 0x224e42f2, 0x1c5c1572, 0xf6721b2c, 0x1ad2fff3, 0x8c25404e,
+0x324ed72f, 0x4067b7fd, 0x0523138e, 0x5ca3bc78, 0xdc0fd66e, 0x75922283, 0x784d6b17, 0x58ebb16e,
+0x44094f85, 0x3f481d87, 0xfcfeae7b, 0x77b5ff76, 0x8c2302bf, 0xaaf47556, 0x5f46b02a, 0x2b092801,
+0x3d38f5f7, 0x0ca81f36, 0x52af4a8a, 0x66d5e7c0, 0xdf3b0874, 0x95055110, 0x1b5ad7a8, 0xf61ed5ad,
+0x6cf6e479, 0x20758184, 0xd0cefa65, 0x88f7be58, 0x4a046826, 0x0ff6f8f3, 0xa09c7f70, 0x5346aba0,
+0x5ce96c28, 0xe176eda3, 0x6bac307f, 0x376829d2, 0x85360fa9, 0x17e3fe2a, 0x24b79767, 0xf5a96b20,
+0xd6cd2595, 0x68ff1ebf, 0x7555442c, 0xf19f06be, 0xf9e0659a, 0xeeb9491d, 0x34010718, 0xbb30cab8,
+0xe822fe15, 0x88570983, 0x750e6249, 0xda627e55, 0x5e76ffa8, 0xb1534546, 0x6d47de08, 0xefe9e7d4
+};
+static const u32 s6[256] = {
+0xf6fa8f9d, 0x2cac6ce1, 0x4ca34867, 0xe2337f7c, 0x95db08e7, 0x016843b4, 0xeced5cbc, 0x325553ac,
+0xbf9f0960, 0xdfa1e2ed, 0x83f0579d, 0x63ed86b9, 0x1ab6a6b8, 0xde5ebe39, 0xf38ff732, 0x8989b138,
+0x33f14961, 0xc01937bd, 0xf506c6da, 0xe4625e7e, 0xa308ea99, 0x4e23e33c, 0x79cbd7cc, 0x48a14367,
+0xa3149619, 0xfec94bd5, 0xa114174a, 0xeaa01866, 0xa084db2d, 0x09a8486f, 0xa888614a, 0x2900af98,
+0x01665991, 0xe1992863, 0xc8f30c60, 0x2e78ef3c, 0xd0d51932, 0xcf0fec14, 0xf7ca07d2, 0xd0a82072,
+0xfd41197e, 0x9305a6b0, 0xe86be3da, 0x74bed3cd, 0x372da53c, 0x4c7f4448, 0xdab5d440, 0x6dba0ec3,
+0x083919a7, 0x9fbaeed9, 0x49dbcfb0, 0x4e670c53, 0x5c3d9c01, 0x64bdb941, 0x2c0e636a, 0xba7dd9cd,
+0xea6f7388, 0xe70bc762, 0x35f29adb, 0x5c4cdd8d, 0xf0d48d8c, 0xb88153e2, 0x08a19866, 0x1ae2eac8,
+0x284caf89, 0xaa928223, 0x9334be53, 0x3b3a21bf, 0x16434be3, 0x9aea3906, 0xefe8c36e, 0xf890cdd9,
+0x80226dae, 0xc340a4a3, 0xdf7e9c09, 0xa694a807, 0x5b7c5ecc, 0x221db3a6, 0x9a69a02f, 0x68818a54,
+0xceb2296f, 0x53c0843a, 0xfe893655, 0x25bfe68a, 0xb4628abc, 0xcf222ebf, 0x25ac6f48, 0xa9a99387,
+0x53bddb65, 0xe76ffbe7, 0xe967fd78, 0x0ba93563, 0x8e342bc1, 0xe8a11be9, 0x4980740d, 0xc8087dfc,
+0x8de4bf99, 0xa11101a0, 0x7fd37975, 0xda5a26c0, 0xe81f994f, 0x9528cd89, 0xfd339fed, 0xb87834bf,
+0x5f04456d, 0x22258698, 0xc9c4c83b, 0x2dc156be, 0x4f628daa, 0x57f55ec5, 0xe2220abe, 0xd2916ebf,
+0x4ec75b95, 0x24f2c3c0, 0x42d15d99, 0xcd0d7fa0, 0x7b6e27ff, 0xa8dc8af0, 0x7345c106, 0xf41e232f,
+0x35162386, 0xe6ea8926, 0x3333b094, 0x157ec6f2, 0x372b74af, 0x692573e4, 0xe9a9d848, 0xf3160289,
+0x3a62ef1d, 0xa787e238, 0xf3a5f676, 0x74364853, 0x20951063, 0x4576698d, 0xb6fad407, 0x592af950,
+0x36f73523, 0x4cfb6e87, 0x7da4cec0, 0x6c152daa, 0xcb0396a8, 0xc50dfe5d, 0xfcd707ab, 0x0921c42f,
+0x89dff0bb, 0x5fe2be78, 0x448f4f33, 0x754613c9, 0x2b05d08d, 0x48b9d585, 0xdc049441, 0xc8098f9b,
+0x7dede786, 0xc39a3373, 0x42410005, 0x6a091751, 0x0ef3c8a6, 0x890072d6, 0x28207682, 0xa9a9f7be,
+0xbf32679d, 0xd45b5b75, 0xb353fd00, 0xcbb0e358, 0x830f220a, 0x1f8fb214, 0xd372cf08, 0xcc3c4a13,
+0x8cf63166, 0x061c87be, 0x88c98f88, 0x6062e397, 0x47cf8e7a, 0xb6c85283, 0x3cc2acfb, 0x3fc06976,
+0x4e8f0252, 0x64d8314d, 0xda3870e3, 0x1e665459, 0xc10908f0, 0x513021a5, 0x6c5b68b7, 0x822f8aa0,
+0x3007cd3e, 0x74719eef, 0xdc872681, 0x073340d4, 0x7e432fd9, 0x0c5ec241, 0x8809286c, 0xf592d891,
+0x08a930f6, 0x957ef305, 0xb7fbffbd, 0xc266e96f, 0x6fe4ac98, 0xb173ecc0, 0xbc60b42a, 0x953498da,
+0xfba1ae12, 0x2d4bd736, 0x0f25faab, 0xa4f3fceb, 0xe2969123, 0x257f0c3d, 0x9348af49, 0x361400bc,
+0xe8816f4a, 0x3814f200, 0xa3f94043, 0x9c7a54c2, 0xbc704f57, 0xda41e7f9, 0xc25ad33a, 0x54f4a084,
+0xb17f5505, 0x59357cbe, 0xedbd15c8, 0x7f97c5ab, 0xba5ac7b5, 0xb6f6deaf, 0x3a479c3a, 0x5302da25,
+0x653d7e6a, 0x54268d49, 0x51a477ea, 0x5017d55b, 0xd7d25d88, 0x44136c76, 0x0404a8c8, 0xb8e5a121,
+0xb81a928a, 0x60ed5869, 0x97c55b96, 0xeaec991b, 0x29935913, 0x01fdb7f1, 0x088e8dfa, 0x9ab6f6f5,
+0x3b4cbf9f, 0x4a5de3ab, 0xe6051d35, 0xa0e1d855, 0xd36b4cf1, 0xf544edeb, 0xb0e93524, 0xbebb8fbd,
+0xa2d762cf, 0x49c92f54, 0x38b5f331, 0x7128a454, 0x48392905, 0xa65b1db8, 0x851c97bd, 0xd675cf2f
+};
+static const u32 s7[256] = {
+0x85e04019, 0x332bf567, 0x662dbfff, 0xcfc65693, 0x2a8d7f6f, 0xab9bc912, 0xde6008a1, 0x2028da1f,
+0x0227bce7, 0x4d642916, 0x18fac300, 0x50f18b82, 0x2cb2cb11, 0xb232e75c, 0x4b3695f2, 0xb28707de,
+0xa05fbcf6, 0xcd4181e9, 0xe150210c, 0xe24ef1bd, 0xb168c381, 0xfde4e789, 0x5c79b0d8, 0x1e8bfd43,
+0x4d495001, 0x38be4341, 0x913cee1d, 0x92a79c3f, 0x089766be, 0xbaeeadf4, 0x1286becf, 0xb6eacb19,
+0x2660c200, 0x7565bde4, 0x64241f7a, 0x8248dca9, 0xc3b3ad66, 0x28136086, 0x0bd8dfa8, 0x356d1cf2,
+0x107789be, 0xb3b2e9ce, 0x0502aa8f, 0x0bc0351e, 0x166bf52a, 0xeb12ff82, 0xe3486911, 0xd34d7516,
+0x4e7b3aff, 0x5f43671b, 0x9cf6e037, 0x4981ac83, 0x334266ce, 0x8c9341b7, 0xd0d854c0, 0xcb3a6c88,
+0x47bc2829, 0x4725ba37, 0xa66ad22b, 0x7ad61f1e, 0x0c5cbafa, 0x4437f107, 0xb6e79962, 0x42d2d816,
+0x0a961288, 0xe1a5c06e, 0x13749e67, 0x72fc081a, 0xb1d139f7, 0xf9583745, 0xcf19df58, 0xbec3f756,
+0xc06eba30, 0x07211b24, 0x45c28829, 0xc95e317f, 0xbc8ec511, 0x38bc46e9, 0xc6e6fa14, 0xbae8584a,
+0xad4ebc46, 0x468f508b, 0x7829435f, 0xf124183b, 0x821dba9f, 0xaff60ff4, 0xea2c4e6d, 0x16e39264,
+0x92544a8b, 0x009b4fc3, 0xaba68ced, 0x9ac96f78, 0x06a5b79a, 0xb2856e6e, 0x1aec3ca9, 0xbe838688,
+0x0e0804e9, 0x55f1be56, 0xe7e5363b, 0xb3a1f25d, 0xf7debb85, 0x61fe033c, 0x16746233, 0x3c034c28,
+0xda6d0c74, 0x79aac56c, 0x3ce4e1ad, 0x51f0c802, 0x98f8f35a, 0x1626a49f, 0xeed82b29, 0x1d382fe3,
+0x0c4fb99a, 0xbb325778, 0x3ec6d97b, 0x6e77a6a9, 0xcb658b5c, 0xd45230c7, 0x2bd1408b, 0x60c03eb7,
+0xb9068d78, 0xa33754f4, 0xf430c87d, 0xc8a71302, 0xb96d8c32, 0xebd4e7be, 0xbe8b9d2d, 0x7979fb06,
+0xe7225308, 0x8b75cf77, 0x11ef8da4, 0xe083c858, 0x8d6b786f, 0x5a6317a6, 0xfa5cf7a0, 0x5dda0033,
+0xf28ebfb0, 0xf5b9c310, 0xa0eac280, 0x08b9767a, 0xa3d9d2b0, 0x79d34217, 0x021a718d, 0x9ac6336a,
+0x2711fd60, 0x438050e3, 0x069908a8, 0x3d7fedc4, 0x826d2bef, 0x4eeb8476, 0x488dcf25, 0x36c9d566,
+0x28e74e41, 0xc2610aca, 0x3d49a9cf, 0xbae3b9df, 0xb65f8de6, 0x92aeaf64, 0x3ac7d5e6, 0x9ea80509,
+0xf22b017d, 0xa4173f70, 0xdd1e16c3, 0x15e0d7f9, 0x50b1b887, 0x2b9f4fd5, 0x625aba82, 0x6a017962,
+0x2ec01b9c, 0x15488aa9, 0xd716e740, 0x40055a2c, 0x93d29a22, 0xe32dbf9a, 0x058745b9, 0x3453dc1e,
+0xd699296e, 0x496cff6f, 0x1c9f4986, 0xdfe2ed07, 0xb87242d1, 0x19de7eae, 0x053e561a, 0x15ad6f8c,
+0x66626c1c, 0x7154c24c, 0xea082b2a, 0x93eb2939, 0x17dcb0f0, 0x58d4f2ae, 0x9ea294fb, 0x52cf564c,
+0x9883fe66, 0x2ec40581, 0x763953c3, 0x01d6692e, 0xd3a0c108, 0xa1e7160e, 0xe4f2dfa6, 0x693ed285,
+0x74904698, 0x4c2b0edd, 0x4f757656, 0x5d393378, 0xa132234f, 0x3d321c5d, 0xc3f5e194, 0x4b269301,
+0xc79f022f, 0x3c997e7e, 0x5e4f9504, 0x3ffafbbd, 0x76f7ad0e, 0x296693f4, 0x3d1fce6f, 0xc61e45be,
+0xd3b5ab34, 0xf72bf9b7, 0x1b0434c0, 0x4e72b567, 0x5592a33d, 0xb5229301, 0xcfd2a87f, 0x60aeb767,
+0x1814386b, 0x30bcc33d, 0x38a0c07d, 0xfd1606f2, 0xc363519b, 0x589dd390, 0x5479f8e6, 0x1cb8d647,
+0x97fd61a9, 0xea7759f4, 0x2d57539d, 0x569a58cf, 0xe84e63ad, 0x462e1b78, 0x6580f87e, 0xf3817914,
+0x91da55f4, 0x40a230f3, 0xd1988f35, 0xb6e318d2, 0x3ffa50bc, 0x3d40f021, 0xc3c0bdae, 0x4958c24c,
+0x518f36b2, 0x84b1d370, 0x0fedce83, 0x878ddada, 0xf2a279c7, 0x94e01be8, 0x90716f4b, 0x954b8aa3
+};
+static const u32 s8[256] = {
+0xe216300d, 0xbbddfffc, 0xa7ebdabd, 0x35648095, 0x7789f8b7, 0xe6c1121b, 0x0e241600, 0x052ce8b5,
+0x11a9cfb0, 0xe5952f11, 0xece7990a, 0x9386d174, 0x2a42931c, 0x76e38111, 0xb12def3a, 0x37ddddfc,
+0xde9adeb1, 0x0a0cc32c, 0xbe197029, 0x84a00940, 0xbb243a0f, 0xb4d137cf, 0xb44e79f0, 0x049eedfd,
+0x0b15a15d, 0x480d3168, 0x8bbbde5a, 0x669ded42, 0xc7ece831, 0x3f8f95e7, 0x72df191b, 0x7580330d,
+0x94074251, 0x5c7dcdfa, 0xabbe6d63, 0xaa402164, 0xb301d40a, 0x02e7d1ca, 0x53571dae, 0x7a3182a2,
+0x12a8ddec, 0xfdaa335d, 0x176f43e8, 0x71fb46d4, 0x38129022, 0xce949ad4, 0xb84769ad, 0x965bd862,
+0x82f3d055, 0x66fb9767, 0x15b80b4e, 0x1d5b47a0, 0x4cfde06f, 0xc28ec4b8, 0x57e8726e, 0x647a78fc,
+0x99865d44, 0x608bd593, 0x6c200e03, 0x39dc5ff6, 0x5d0b00a3, 0xae63aff2, 0x7e8bd632, 0x70108c0c,
+0xbbd35049, 0x2998df04, 0x980cf42a, 0x9b6df491, 0x9e7edd53, 0x06918548, 0x58cb7e07, 0x3b74ef2e,
+0x522fffb1, 0xd24708cc, 0x1c7e27cd, 0xa4eb215b, 0x3cf1d2e2, 0x19b47a38, 0x424f7618, 0x35856039,
+0x9d17dee7, 0x27eb35e6, 0xc9aff67b, 0x36baf5b8, 0x09c467cd, 0xc18910b1, 0xe11dbf7b, 0x06cd1af8,
+0x7170c608, 0x2d5e3354, 0xd4de495a, 0x64c6d006, 0xbcc0c62c, 0x3dd00db3, 0x708f8f34, 0x77d51b42,
+0x264f620f, 0x24b8d2bf, 0x15c1b79e, 0x46a52564, 0xf8d7e54e, 0x3e378160, 0x7895cda5, 0x859c15a5,
+0xe6459788, 0xc37bc75f, 0xdb07ba0c, 0x0676a3ab, 0x7f229b1e, 0x31842e7b, 0x24259fd7, 0xf8bef472,
+0x835ffcb8, 0x6df4c1f2, 0x96f5b195, 0xfd0af0fc, 0xb0fe134c, 0xe2506d3d, 0x4f9b12ea, 0xf215f225,
+0xa223736f, 0x9fb4c428, 0x25d04979, 0x34c713f8, 0xc4618187, 0xea7a6e98, 0x7cd16efc, 0x1436876c,
+0xf1544107, 0xbedeee14, 0x56e9af27, 0xa04aa441, 0x3cf7c899, 0x92ecbae6, 0xdd67016d, 0x151682eb,
+0xa842eedf, 0xfdba60b4, 0xf1907b75, 0x20e3030f, 0x24d8c29e, 0xe139673b, 0xefa63fb8, 0x71873054,
+0xb6f2cf3b, 0x9f326442, 0xcb15a4cc, 0xb01a4504, 0xf1e47d8d, 0x844a1be5, 0xbae7dfdc, 0x42cbda70,
+0xcd7dae0a, 0x57e85b7a, 0xd53f5af6, 0x20cf4d8c, 0xcea4d428, 0x79d130a4, 0x3486ebfb, 0x33d3cddc,
+0x77853b53, 0x37effcb5, 0xc5068778, 0xe580b3e6, 0x4e68b8f4, 0xc5c8b37e, 0x0d809ea2, 0x398feb7c,
+0x132a4f94, 0x43b7950e, 0x2fee7d1c, 0x223613bd, 0xdd06caa2, 0x37df932b, 0xc4248289, 0xacf3ebc3,
+0x5715f6b7, 0xef3478dd, 0xf267616f, 0xc148cbe4, 0x9052815e, 0x5e410fab, 0xb48a2465, 0x2eda7fa4,
+0xe87b40e4, 0xe98ea084, 0x5889e9e1, 0xefd390fc, 0xdd07d35b, 0xdb485694, 0x38d7e5b2, 0x57720101,
+0x730edebc, 0x5b643113, 0x94917e4f, 0x503c2fba, 0x646f1282, 0x7523d24a, 0xe0779695, 0xf9c17a8f,
+0x7a5b2121, 0xd187b896, 0x29263a4d, 0xba510cdf, 0x81f47c9f, 0xad1163ed, 0xea7b5965, 0x1a00726e,
+0x11403092, 0x00da6d77, 0x4a0cdd61, 0xad1f4603, 0x605bdfb0, 0x9eedc364, 0x22ebe6a8, 0xcee7d28a,
+0xa0e736a0, 0x5564a6b9, 0x10853209, 0xc7eb8f37, 0x2de705ca, 0x8951570f, 0xdf09822b, 0xbd691a6c,
+0xaa12e4f2, 0x87451c0f, 0xe0f6a27a, 0x3ada4819, 0x4cf1764f, 0x0d771c2b, 0x67cdb156, 0x350d8384,
+0x5938fa0f, 0x42399ef3, 0x36997b07, 0x0e84093d, 0x4aa93e61, 0x8360d87b, 0x1fa98b0c, 0x1149382c,
+0xe97625a5, 0x0614d1b7, 0x0e25244b, 0x0c768347, 0x589e8d82, 0x0d2059d1, 0xa466bb1e, 0xf8da0a82,
+0x04f19130, 0xba6e4ec0, 0x99265164, 0x1ee7230d, 0x50b2ad80, 0xeaee6801, 0x8db2a283, 0xea8bf59e
+};
+
+
+#if defined(__GNUC__) && defined(__i386__)
+static inline u32
+rol(int n, u32 x)
+{
+ __asm__("roll %%cl,%0"
+ :"=r" (x)
+ :"0" (x),"c" (n));
+ return x;
+}
+#else
+#define rol(n,x) ( ((x) << (n)) | ((x) >> (32-(n))) )
+#endif
+
+#define F1(D,m,r) ( (I = ((m) + (D))), (I=rol((r),I)), \
+ (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff]) )
+#define F2(D,m,r) ( (I = ((m) ^ (D))), (I=rol((r),I)), \
+ (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff]) )
+#define F3(D,m,r) ( (I = ((m) - (D))), (I=rol((r),I)), \
+ (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]) )
+
+static void
+do_encrypt_block( CAST5_context *c, byte *outbuf, const byte *inbuf )
+{
+ u32 l, r, t;
+ u32 I; /* used by the Fx macros */
+ u32 *Km;
+ byte *Kr;
+
+ Km = c->Km;
+ Kr = c->Kr;
+
+ /* (L0,R0) <-- (m1...m64). (Split the plaintext into left and
+ * right 32-bit halves L0 = m1...m32 and R0 = m33...m64.)
+ */
+ l = inbuf[0] << 24 | inbuf[1] << 16 | inbuf[2] << 8 | inbuf[3];
+ r = inbuf[4] << 24 | inbuf[5] << 16 | inbuf[6] << 8 | inbuf[7];
+
+ /* (16 rounds) for i from 1 to 16, compute Li and Ri as follows:
+ * Li = Ri-1;
+ * Ri = Li-1 ^ f(Ri-1,Kmi,Kri), where f is defined in Section 2.2
+ * Rounds 1, 4, 7, 10, 13, and 16 use f function Type 1.
+ * Rounds 2, 5, 8, 11, and 14 use f function Type 2.
+ * Rounds 3, 6, 9, 12, and 15 use f function Type 3.
+ */
+
+ t = l; l = r; r = t ^ F1(r, Km[ 0], Kr[ 0]);
+ t = l; l = r; r = t ^ F2(r, Km[ 1], Kr[ 1]);
+ t = l; l = r; r = t ^ F3(r, Km[ 2], Kr[ 2]);
+ t = l; l = r; r = t ^ F1(r, Km[ 3], Kr[ 3]);
+ t = l; l = r; r = t ^ F2(r, Km[ 4], Kr[ 4]);
+ t = l; l = r; r = t ^ F3(r, Km[ 5], Kr[ 5]);
+ t = l; l = r; r = t ^ F1(r, Km[ 6], Kr[ 6]);
+ t = l; l = r; r = t ^ F2(r, Km[ 7], Kr[ 7]);
+ t = l; l = r; r = t ^ F3(r, Km[ 8], Kr[ 8]);
+ t = l; l = r; r = t ^ F1(r, Km[ 9], Kr[ 9]);
+ t = l; l = r; r = t ^ F2(r, Km[10], Kr[10]);
+ t = l; l = r; r = t ^ F3(r, Km[11], Kr[11]);
+ t = l; l = r; r = t ^ F1(r, Km[12], Kr[12]);
+ t = l; l = r; r = t ^ F2(r, Km[13], Kr[13]);
+ t = l; l = r; r = t ^ F3(r, Km[14], Kr[14]);
+ t = l; l = r; r = t ^ F1(r, Km[15], Kr[15]);
+
+ /* c1...c64 <-- (R16,L16). (Exchange final blocks L16, R16 and
+ * concatenate to form the ciphertext.) */
+ outbuf[0] = (r >> 24) & 0xff;
+ outbuf[1] = (r >> 16) & 0xff;
+ outbuf[2] = (r >> 8) & 0xff;
+ outbuf[3] = r & 0xff;
+ outbuf[4] = (l >> 24) & 0xff;
+ outbuf[5] = (l >> 16) & 0xff;
+ outbuf[6] = (l >> 8) & 0xff;
+ outbuf[7] = l & 0xff;
+}
+
+static void
+encrypt_block (void *context , byte *outbuf, const byte *inbuf)
+{
+ CAST5_context *c = (CAST5_context *) context;
+ do_encrypt_block (c, outbuf, inbuf);
+ _gcry_burn_stack (20+4*sizeof(void*));
+}
+
+
+static void
+do_decrypt_block (CAST5_context *c, byte *outbuf, const byte *inbuf )
+{
+ u32 l, r, t;
+ u32 I;
+ u32 *Km;
+ byte *Kr;
+
+ Km = c->Km;
+ Kr = c->Kr;
+
+ l = inbuf[0] << 24 | inbuf[1] << 16 | inbuf[2] << 8 | inbuf[3];
+ r = inbuf[4] << 24 | inbuf[5] << 16 | inbuf[6] << 8 | inbuf[7];
+
+ t = l; l = r; r = t ^ F1(r, Km[15], Kr[15]);
+ t = l; l = r; r = t ^ F3(r, Km[14], Kr[14]);
+ t = l; l = r; r = t ^ F2(r, Km[13], Kr[13]);
+ t = l; l = r; r = t ^ F1(r, Km[12], Kr[12]);
+ t = l; l = r; r = t ^ F3(r, Km[11], Kr[11]);
+ t = l; l = r; r = t ^ F2(r, Km[10], Kr[10]);
+ t = l; l = r; r = t ^ F1(r, Km[ 9], Kr[ 9]);
+ t = l; l = r; r = t ^ F3(r, Km[ 8], Kr[ 8]);
+ t = l; l = r; r = t ^ F2(r, Km[ 7], Kr[ 7]);
+ t = l; l = r; r = t ^ F1(r, Km[ 6], Kr[ 6]);
+ t = l; l = r; r = t ^ F3(r, Km[ 5], Kr[ 5]);
+ t = l; l = r; r = t ^ F2(r, Km[ 4], Kr[ 4]);
+ t = l; l = r; r = t ^ F1(r, Km[ 3], Kr[ 3]);
+ t = l; l = r; r = t ^ F3(r, Km[ 2], Kr[ 2]);
+ t = l; l = r; r = t ^ F2(r, Km[ 1], Kr[ 1]);
+ t = l; l = r; r = t ^ F1(r, Km[ 0], Kr[ 0]);
+
+ outbuf[0] = (r >> 24) & 0xff;
+ outbuf[1] = (r >> 16) & 0xff;
+ outbuf[2] = (r >> 8) & 0xff;
+ outbuf[3] = r & 0xff;
+ outbuf[4] = (l >> 24) & 0xff;
+ outbuf[5] = (l >> 16) & 0xff;
+ outbuf[6] = (l >> 8) & 0xff;
+ outbuf[7] = l & 0xff;
+}
+
+static void
+decrypt_block (void *context, byte *outbuf, const byte *inbuf)
+{
+ CAST5_context *c = (CAST5_context *) context;
+ do_decrypt_block (c, outbuf, inbuf);
+ _gcry_burn_stack (20+4*sizeof(void*));
+}
+
+
+static const char*
+selftest(void)
+{
+ CAST5_context c;
+ byte key[16] = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
+ 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A };
+ byte plain[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
+ byte cipher[8]= { 0x23, 0x8B, 0x4F, 0xE5, 0x84, 0x7E, 0x44, 0xB2 };
+ byte buffer[8];
+
+ cast_setkey( &c, key, 16 );
+ encrypt_block( &c, buffer, plain );
+ if( memcmp( buffer, cipher, 8 ) )
+ return "1";
+ decrypt_block( &c, buffer, buffer );
+ if( memcmp( buffer, plain, 8 ) )
+ return "2";
+
+#if 0 /* full maintenance test */
+ {
+ int i;
+ byte a0[16] = { 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
+ 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A };
+ byte b0[16] = { 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
+ 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A };
+ byte a1[16] = { 0xEE,0xA9,0xD0,0xA2,0x49,0xFD,0x3B,0xA6,
+ 0xB3,0x43,0x6F,0xB8,0x9D,0x6D,0xCA,0x92 };
+ byte b1[16] = { 0xB2,0xC9,0x5E,0xB0,0x0C,0x31,0xAD,0x71,
+ 0x80,0xAC,0x05,0xB8,0xE8,0x3D,0x69,0x6E };
+
+ for(i=0; i < 1000000; i++ ) {
+ cast_setkey( &c, b0, 16 );
+ encrypt_block( &c, a0, a0 );
+ encrypt_block( &c, a0+8, a0+8 );
+ cast_setkey( &c, a0, 16 );
+ encrypt_block( &c, b0, b0 );
+ encrypt_block( &c, b0+8, b0+8 );
+ }
+ if( memcmp( a0, a1, 16 ) || memcmp( b0, b1, 16 ) )
+ return "3";
+
+ }
+#endif
+ return NULL;
+}
+
+
+static void
+key_schedule( u32 *x, u32 *z, u32 *k )
+{
+
+#define xi(i) ((x[(i)/4] >> (8*(3-((i)%4)))) & 0xff)
+#define zi(i) ((z[(i)/4] >> (8*(3-((i)%4)))) & 0xff)
+
+ z[0] = x[0] ^ s5[xi(13)]^s6[xi(15)]^s7[xi(12)]^s8[xi(14)]^s7[xi( 8)];
+ z[1] = x[2] ^ s5[zi( 0)]^s6[zi( 2)]^s7[zi( 1)]^s8[zi( 3)]^s8[xi(10)];
+ z[2] = x[3] ^ s5[zi( 7)]^s6[zi( 6)]^s7[zi( 5)]^s8[zi( 4)]^s5[xi( 9)];
+ z[3] = x[1] ^ s5[zi(10)]^s6[zi( 9)]^s7[zi(11)]^s8[zi( 8)]^s6[xi(11)];
+ k[0] = s5[zi( 8)]^s6[zi( 9)]^s7[zi( 7)]^s8[zi( 6)]^s5[zi( 2)];
+ k[1] = s5[zi(10)]^s6[zi(11)]^s7[zi( 5)]^s8[zi( 4)]^s6[zi( 6)];
+ k[2] = s5[zi(12)]^s6[zi(13)]^s7[zi( 3)]^s8[zi( 2)]^s7[zi( 9)];
+ k[3] = s5[zi(14)]^s6[zi(15)]^s7[zi( 1)]^s8[zi( 0)]^s8[zi(12)];
+
+ x[0] = z[2] ^ s5[zi( 5)]^s6[zi( 7)]^s7[zi( 4)]^s8[zi( 6)]^s7[zi( 0)];
+ x[1] = z[0] ^ s5[xi( 0)]^s6[xi( 2)]^s7[xi( 1)]^s8[xi( 3)]^s8[zi( 2)];
+ x[2] = z[1] ^ s5[xi( 7)]^s6[xi( 6)]^s7[xi( 5)]^s8[xi( 4)]^s5[zi( 1)];
+ x[3] = z[3] ^ s5[xi(10)]^s6[xi( 9)]^s7[xi(11)]^s8[xi( 8)]^s6[zi( 3)];
+ k[4] = s5[xi( 3)]^s6[xi( 2)]^s7[xi(12)]^s8[xi(13)]^s5[xi( 8)];
+ k[5] = s5[xi( 1)]^s6[xi( 0)]^s7[xi(14)]^s8[xi(15)]^s6[xi(13)];
+ k[6] = s5[xi( 7)]^s6[xi( 6)]^s7[xi( 8)]^s8[xi( 9)]^s7[xi( 3)];
+ k[7] = s5[xi( 5)]^s6[xi( 4)]^s7[xi(10)]^s8[xi(11)]^s8[xi( 7)];
+
+ z[0] = x[0] ^ s5[xi(13)]^s6[xi(15)]^s7[xi(12)]^s8[xi(14)]^s7[xi( 8)];
+ z[1] = x[2] ^ s5[zi( 0)]^s6[zi( 2)]^s7[zi( 1)]^s8[zi( 3)]^s8[xi(10)];
+ z[2] = x[3] ^ s5[zi( 7)]^s6[zi( 6)]^s7[zi( 5)]^s8[zi( 4)]^s5[xi( 9)];
+ z[3] = x[1] ^ s5[zi(10)]^s6[zi( 9)]^s7[zi(11)]^s8[zi( 8)]^s6[xi(11)];
+ k[8] = s5[zi( 3)]^s6[zi( 2)]^s7[zi(12)]^s8[zi(13)]^s5[zi( 9)];
+ k[9] = s5[zi( 1)]^s6[zi( 0)]^s7[zi(14)]^s8[zi(15)]^s6[zi(12)];
+ k[10]= s5[zi( 7)]^s6[zi( 6)]^s7[zi( 8)]^s8[zi( 9)]^s7[zi( 2)];
+ k[11]= s5[zi( 5)]^s6[zi( 4)]^s7[zi(10)]^s8[zi(11)]^s8[zi( 6)];
+
+ x[0] = z[2] ^ s5[zi( 5)]^s6[zi( 7)]^s7[zi( 4)]^s8[zi( 6)]^s7[zi( 0)];
+ x[1] = z[0] ^ s5[xi( 0)]^s6[xi( 2)]^s7[xi( 1)]^s8[xi( 3)]^s8[zi( 2)];
+ x[2] = z[1] ^ s5[xi( 7)]^s6[xi( 6)]^s7[xi( 5)]^s8[xi( 4)]^s5[zi( 1)];
+ x[3] = z[3] ^ s5[xi(10)]^s6[xi( 9)]^s7[xi(11)]^s8[xi( 8)]^s6[zi( 3)];
+ k[12]= s5[xi( 8)]^s6[xi( 9)]^s7[xi( 7)]^s8[xi( 6)]^s5[xi( 3)];
+ k[13]= s5[xi(10)]^s6[xi(11)]^s7[xi( 5)]^s8[xi( 4)]^s6[xi( 7)];
+ k[14]= s5[xi(12)]^s6[xi(13)]^s7[xi( 3)]^s8[xi( 2)]^s7[xi( 8)];
+ k[15]= s5[xi(14)]^s6[xi(15)]^s7[xi( 1)]^s8[xi( 0)]^s8[xi(13)];
+
+#undef xi
+#undef zi
+}
+
+
+static gcry_err_code_t
+do_cast_setkey( CAST5_context *c, const byte *key, unsigned keylen )
+{
+ static int initialized;
+ static const char* selftest_failed;
+ int i;
+ u32 x[4];
+ u32 z[4];
+ u32 k[16];
+
+ if( !initialized )
+ {
+ initialized = 1;
+ selftest_failed = selftest();
+ if( selftest_failed )
+ log_error ("CAST5 selftest failed (%s).\n", selftest_failed );
+ }
+ if( selftest_failed )
+ return GPG_ERR_SELFTEST_FAILED;
+
+ if( keylen != 16 )
+ return GPG_ERR_INV_KEYLEN;
+
+ x[0] = key[0] << 24 | key[1] << 16 | key[2] << 8 | key[3];
+ x[1] = key[4] << 24 | key[5] << 16 | key[6] << 8 | key[7];
+ x[2] = key[8] << 24 | key[9] << 16 | key[10] << 8 | key[11];
+ x[3] = key[12] << 24 | key[13] << 16 | key[14] << 8 | key[15];
+
+ key_schedule( x, z, k );
+ for(i=0; i < 16; i++ )
+ c->Km[i] = k[i];
+ key_schedule( x, z, k );
+ for(i=0; i < 16; i++ )
+ c->Kr[i] = k[i] & 0x1f;
+
+ memset(&x,0, sizeof x);
+ memset(&z,0, sizeof z);
+ memset(&k,0, sizeof k);
+
+#undef xi
+#undef zi
+ return GPG_ERR_NO_ERROR;
+}
+
+static gcry_err_code_t
+cast_setkey (void *context, const byte *key, unsigned keylen )
+{
+ CAST5_context *c = (CAST5_context *) context;
+ gcry_err_code_t rc = do_cast_setkey (c, key, keylen);
+ _gcry_burn_stack (96+7*sizeof(void*));
+ return rc;
+}
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_cast5 =
+ {
+ "CAST5", NULL, NULL, CAST5_BLOCKSIZE, 128, sizeof (CAST5_context),
+ cast_setkey, encrypt_block, decrypt_block
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/cipher.c b/grub-core/lib/libgcrypt/cipher/cipher.c
new file mode 100644
index 0000000..9852d6a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/cipher.c
@@ -0,0 +1,2217 @@
+/* cipher.c - cipher dispatcher
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+ * 2005, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "g10lib.h"
+#include "cipher.h"
+#include "ath.h"
+
+#define MAX_BLOCKSIZE 16
+#define TABLE_SIZE 14
+#define CTX_MAGIC_NORMAL 0x24091964
+#define CTX_MAGIC_SECURE 0x46919042
+
+/* Try to use 16 byte aligned cipher context for better performance.
+ We use the aligned attribute, thus it is only possible to implement
+ this with gcc. */
+#undef NEED_16BYTE_ALIGNED_CONTEXT
+#if defined (__GNUC__)
+# define NEED_16BYTE_ALIGNED_CONTEXT 1
+#endif
+
+/* A dummy extraspec so that we do not need to tests the extraspec
+ field from the module specification against NULL and instead
+ directly test the respective fields of extraspecs. */
+static cipher_extra_spec_t dummy_extra_spec;
+
+/* This is the list of the default ciphers, which are included in
+ libgcrypt. */
+static struct cipher_table_entry
+{
+ gcry_cipher_spec_t *cipher;
+ cipher_extra_spec_t *extraspec;
+ unsigned int algorithm;
+ int fips_allowed;
+} cipher_table[] =
+ {
+#if USE_BLOWFISH
+ { &_gcry_cipher_spec_blowfish,
+ &dummy_extra_spec, GCRY_CIPHER_BLOWFISH },
+#endif
+#if USE_DES
+ { &_gcry_cipher_spec_des,
+ &dummy_extra_spec, GCRY_CIPHER_DES },
+ { &_gcry_cipher_spec_tripledes,
+ &_gcry_cipher_extraspec_tripledes, GCRY_CIPHER_3DES, 1 },
+#endif
+#if USE_ARCFOUR
+ { &_gcry_cipher_spec_arcfour,
+ &dummy_extra_spec, GCRY_CIPHER_ARCFOUR },
+#endif
+#if USE_CAST5
+ { &_gcry_cipher_spec_cast5,
+ &dummy_extra_spec, GCRY_CIPHER_CAST5 },
+#endif
+#if USE_AES
+ { &_gcry_cipher_spec_aes,
+ &_gcry_cipher_extraspec_aes, GCRY_CIPHER_AES, 1 },
+ { &_gcry_cipher_spec_aes192,
+ &_gcry_cipher_extraspec_aes192, GCRY_CIPHER_AES192, 1 },
+ { &_gcry_cipher_spec_aes256,
+ &_gcry_cipher_extraspec_aes256, GCRY_CIPHER_AES256, 1 },
+#endif
+#if USE_TWOFISH
+ { &_gcry_cipher_spec_twofish,
+ &dummy_extra_spec, GCRY_CIPHER_TWOFISH },
+ { &_gcry_cipher_spec_twofish128,
+ &dummy_extra_spec, GCRY_CIPHER_TWOFISH128 },
+#endif
+#if USE_SERPENT
+ { &_gcry_cipher_spec_serpent128,
+ &dummy_extra_spec, GCRY_CIPHER_SERPENT128 },
+ { &_gcry_cipher_spec_serpent192,
+ &dummy_extra_spec, GCRY_CIPHER_SERPENT192 },
+ { &_gcry_cipher_spec_serpent256,
+ &dummy_extra_spec, GCRY_CIPHER_SERPENT256 },
+#endif
+#if USE_RFC2268
+ { &_gcry_cipher_spec_rfc2268_40,
+ &dummy_extra_spec, GCRY_CIPHER_RFC2268_40 },
+#endif
+#if USE_SEED
+ { &_gcry_cipher_spec_seed,
+ &dummy_extra_spec, GCRY_CIPHER_SEED },
+#endif
+#if USE_CAMELLIA
+ { &_gcry_cipher_spec_camellia128,
+ &dummy_extra_spec, GCRY_CIPHER_CAMELLIA128 },
+ { &_gcry_cipher_spec_camellia192,
+ &dummy_extra_spec, GCRY_CIPHER_CAMELLIA192 },
+ { &_gcry_cipher_spec_camellia256,
+ &dummy_extra_spec, GCRY_CIPHER_CAMELLIA256 },
+#endif
+#ifdef USE_IDEA
+ { &_gcry_cipher_spec_idea,
+ &dummy_extra_spec, GCRY_CIPHER_IDEA },
+#endif
+ { NULL }
+ };
+
+/* List of registered ciphers. */
+static gcry_module_t ciphers_registered;
+
+/* This is the lock protecting CIPHERS_REGISTERED. */
+static ath_mutex_t ciphers_registered_lock = ATH_MUTEX_INITIALIZER;
+
+/* Flag to check whether the default ciphers have already been
+ registered. */
+static int default_ciphers_registered;
+
+/* Convenient macro for registering the default ciphers. */
+#define REGISTER_DEFAULT_CIPHERS \
+ do \
+ { \
+ ath_mutex_lock (&ciphers_registered_lock); \
+ if (! default_ciphers_registered) \
+ { \
+ cipher_register_default (); \
+ default_ciphers_registered = 1; \
+ } \
+ ath_mutex_unlock (&ciphers_registered_lock); \
+ } \
+ while (0)
+
+
+/* A VIA processor with the Padlock engine as well as the Intel AES_NI
+ instructions require an alignment of most data on a 16 byte
+ boundary. Because we trick out the compiler while allocating the
+ context, the align attribute as used in rijndael.c does not work on
+ its own. Thus we need to make sure that the entire context
+ structure is a aligned on that boundary. We achieve this by
+ defining a new type and use that instead of our usual alignment
+ type. */
+typedef union
+{
+ PROPERLY_ALIGNED_TYPE foo;
+#ifdef NEED_16BYTE_ALIGNED_CONTEXT
+ char bar[16] __attribute__ ((aligned (16)));
+#endif
+ char c[1];
+} cipher_context_alignment_t;
+
+
+/* The handle structure. */
+struct gcry_cipher_handle
+{
+ int magic;
+ size_t actual_handle_size; /* Allocated size of this handle. */
+ size_t handle_offset; /* Offset to the malloced block. */
+ gcry_cipher_spec_t *cipher;
+ cipher_extra_spec_t *extraspec;
+ gcry_module_t module;
+
+ /* The algorithm id. This is a hack required because the module
+ interface does not easily allow to retrieve this value. */
+ int algo;
+
+ /* A structure with function pointers for bulk operations. Due to
+ limitations of the module system (we don't want to change the
+ API) we need to keep these function pointers here. The cipher
+ open function intializes them and the actual encryption routines
+ use them if they are not NULL. */
+ struct {
+ void (*cfb_enc)(void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks);
+ void (*cfb_dec)(void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks);
+ void (*cbc_enc)(void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks, int cbc_mac);
+ void (*cbc_dec)(void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks);
+ void (*ctr_enc)(void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks);
+ } bulk;
+
+
+ int mode;
+ unsigned int flags;
+
+ struct {
+ unsigned int key:1; /* Set to 1 if a key has been set. */
+ unsigned int iv:1; /* Set to 1 if a IV has been set. */
+ } marks;
+
+ /* The initialization vector. For best performance we make sure
+ that it is properly aligned. In particular some implementations
+ of bulk operations expect an 16 byte aligned IV. */
+ union {
+ cipher_context_alignment_t iv_align;
+ unsigned char iv[MAX_BLOCKSIZE];
+ } u_iv;
+
+ /* The counter for CTR mode. This field is also used by AESWRAP and
+ thus we can't use the U_IV union. */
+ union {
+ cipher_context_alignment_t iv_align;
+ unsigned char ctr[MAX_BLOCKSIZE];
+ } u_ctr;
+
+ /* Space to save an IV or CTR for chaining operations. */
+ unsigned char lastiv[MAX_BLOCKSIZE];
+ int unused; /* Number of unused bytes in LASTIV. */
+
+ /* What follows are two contexts of the cipher in use. The first
+ one needs to be aligned well enough for the cipher operation
+ whereas the second one is a copy created by cipher_setkey and
+ used by cipher_reset. That second copy has no need for proper
+ aligment because it is only accessed by memcpy. */
+ cipher_context_alignment_t context;
+};
+
+
+
+/* These dummy functions are used in case a cipher implementation
+ refuses to provide it's own functions. */
+
+static gcry_err_code_t
+dummy_setkey (void *c, const unsigned char *key, unsigned int keylen)
+{
+ (void)c;
+ (void)key;
+ (void)keylen;
+ return GPG_ERR_NO_ERROR;
+}
+
+static void
+dummy_encrypt_block (void *c,
+ unsigned char *outbuf, const unsigned char *inbuf)
+{
+ (void)c;
+ (void)outbuf;
+ (void)inbuf;
+ BUG();
+}
+
+static void
+dummy_decrypt_block (void *c,
+ unsigned char *outbuf, const unsigned char *inbuf)
+{
+ (void)c;
+ (void)outbuf;
+ (void)inbuf;
+ BUG();
+}
+
+static void
+dummy_encrypt_stream (void *c,
+ unsigned char *outbuf, const unsigned char *inbuf,
+ unsigned int n)
+{
+ (void)c;
+ (void)outbuf;
+ (void)inbuf;
+ (void)n;
+ BUG();
+}
+
+static void
+dummy_decrypt_stream (void *c,
+ unsigned char *outbuf, const unsigned char *inbuf,
+ unsigned int n)
+{
+ (void)c;
+ (void)outbuf;
+ (void)inbuf;
+ (void)n;
+ BUG();
+}
+
+
+/* Internal function. Register all the ciphers included in
+ CIPHER_TABLE. Note, that this function gets only used by the macro
+ REGISTER_DEFAULT_CIPHERS which protects it using a mutex. */
+static void
+cipher_register_default (void)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ int i;
+
+ for (i = 0; !err && cipher_table[i].cipher; i++)
+ {
+ if (! cipher_table[i].cipher->setkey)
+ cipher_table[i].cipher->setkey = dummy_setkey;
+ if (! cipher_table[i].cipher->encrypt)
+ cipher_table[i].cipher->encrypt = dummy_encrypt_block;
+ if (! cipher_table[i].cipher->decrypt)
+ cipher_table[i].cipher->decrypt = dummy_decrypt_block;
+ if (! cipher_table[i].cipher->stencrypt)
+ cipher_table[i].cipher->stencrypt = dummy_encrypt_stream;
+ if (! cipher_table[i].cipher->stdecrypt)
+ cipher_table[i].cipher->stdecrypt = dummy_decrypt_stream;
+
+ if ( fips_mode () && !cipher_table[i].fips_allowed )
+ continue;
+
+ err = _gcry_module_add (&ciphers_registered,
+ cipher_table[i].algorithm,
+ (void *) cipher_table[i].cipher,
+ (void *) cipher_table[i].extraspec,
+ NULL);
+ }
+
+ if (err)
+ BUG ();
+}
+
+/* Internal callback function. Used via _gcry_module_lookup. */
+static int
+gcry_cipher_lookup_func_name (void *spec, void *data)
+{
+ gcry_cipher_spec_t *cipher = (gcry_cipher_spec_t *) spec;
+ char *name = (char *) data;
+ const char **aliases = cipher->aliases;
+ int i, ret = ! stricmp (name, cipher->name);
+
+ if (aliases)
+ for (i = 0; aliases[i] && (! ret); i++)
+ ret = ! stricmp (name, aliases[i]);
+
+ return ret;
+}
+
+/* Internal callback function. Used via _gcry_module_lookup. */
+static int
+gcry_cipher_lookup_func_oid (void *spec, void *data)
+{
+ gcry_cipher_spec_t *cipher = (gcry_cipher_spec_t *) spec;
+ char *oid = (char *) data;
+ gcry_cipher_oid_spec_t *oid_specs = cipher->oids;
+ int ret = 0, i;
+
+ if (oid_specs)
+ for (i = 0; oid_specs[i].oid && (! ret); i++)
+ if (! stricmp (oid, oid_specs[i].oid))
+ ret = 1;
+
+ return ret;
+}
+
+/* Internal function. Lookup a cipher entry by it's name. */
+static gcry_module_t
+gcry_cipher_lookup_name (const char *name)
+{
+ gcry_module_t cipher;
+
+ cipher = _gcry_module_lookup (ciphers_registered, (void *) name,
+ gcry_cipher_lookup_func_name);
+
+ return cipher;
+}
+
+/* Internal function. Lookup a cipher entry by it's oid. */
+static gcry_module_t
+gcry_cipher_lookup_oid (const char *oid)
+{
+ gcry_module_t cipher;
+
+ cipher = _gcry_module_lookup (ciphers_registered, (void *) oid,
+ gcry_cipher_lookup_func_oid);
+
+ return cipher;
+}
+
+/* Register a new cipher module whose specification can be found in
+ CIPHER. On success, a new algorithm ID is stored in ALGORITHM_ID
+ and a pointer representhing this module is stored in MODULE. */
+gcry_error_t
+_gcry_cipher_register (gcry_cipher_spec_t *cipher,
+ cipher_extra_spec_t *extraspec,
+ int *algorithm_id,
+ gcry_module_t *module)
+{
+ gcry_err_code_t err = 0;
+ gcry_module_t mod;
+
+ /* We do not support module loading in fips mode. */
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ ath_mutex_lock (&ciphers_registered_lock);
+ err = _gcry_module_add (&ciphers_registered, 0,
+ (void *)cipher,
+ (void *)(extraspec? extraspec : &dummy_extra_spec),
+ &mod);
+ ath_mutex_unlock (&ciphers_registered_lock);
+
+ if (! err)
+ {
+ *module = mod;
+ *algorithm_id = mod->mod_id;
+ }
+
+ return gcry_error (err);
+}
+
+/* Unregister the cipher identified by MODULE, which must have been
+ registered with gcry_cipher_register. */
+void
+gcry_cipher_unregister (gcry_module_t module)
+{
+ ath_mutex_lock (&ciphers_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&ciphers_registered_lock);
+}
+
+/* Locate the OID in the oid table and return the index or -1 when not
+ found. An opitonal "oid." or "OID." prefix in OID is ignored, the
+ OID is expected to be in standard IETF dotted notation. The
+ internal algorithm number is returned in ALGORITHM unless it
+ ispassed as NULL. A pointer to the specification of the module
+ implementing this algorithm is return in OID_SPEC unless passed as
+ NULL.*/
+static int
+search_oid (const char *oid, int *algorithm, gcry_cipher_oid_spec_t *oid_spec)
+{
+ gcry_module_t module;
+ int ret = 0;
+
+ if (oid && ((! strncmp (oid, "oid.", 4))
+ || (! strncmp (oid, "OID.", 4))))
+ oid += 4;
+
+ module = gcry_cipher_lookup_oid (oid);
+ if (module)
+ {
+ gcry_cipher_spec_t *cipher = module->spec;
+ int i;
+
+ for (i = 0; cipher->oids[i].oid && !ret; i++)
+ if (! stricmp (oid, cipher->oids[i].oid))
+ {
+ if (algorithm)
+ *algorithm = module->mod_id;
+ if (oid_spec)
+ *oid_spec = cipher->oids[i];
+ ret = 1;
+ }
+ _gcry_module_release (module);
+ }
+
+ return ret;
+}
+
+/* Map STRING to the cipher algorithm identifier. Returns the
+ algorithm ID of the cipher for the given name or 0 if the name is
+ not known. It is valid to pass NULL for STRING which results in a
+ return value of 0. */
+int
+gcry_cipher_map_name (const char *string)
+{
+ gcry_module_t cipher;
+ int ret, algorithm = 0;
+
+ if (! string)
+ return 0;
+
+ REGISTER_DEFAULT_CIPHERS;
+
+ /* If the string starts with a digit (optionally prefixed with
+ either "OID." or "oid."), we first look into our table of ASN.1
+ object identifiers to figure out the algorithm */
+
+ ath_mutex_lock (&ciphers_registered_lock);
+
+ ret = search_oid (string, &algorithm, NULL);
+ if (! ret)
+ {
+ cipher = gcry_cipher_lookup_name (string);
+ if (cipher)
+ {
+ algorithm = cipher->mod_id;
+ _gcry_module_release (cipher);
+ }
+ }
+
+ ath_mutex_unlock (&ciphers_registered_lock);
+
+ return algorithm;
+}
+
+
+/* Given a STRING with an OID in dotted decimal notation, this
+ function returns the cipher mode (GCRY_CIPHER_MODE_*) associated
+ with that OID or 0 if no mode is known. Passing NULL for string
+ yields a return value of 0. */
+int
+gcry_cipher_mode_from_oid (const char *string)
+{
+ gcry_cipher_oid_spec_t oid_spec;
+ int ret = 0, mode = 0;
+
+ if (!string)
+ return 0;
+
+ ath_mutex_lock (&ciphers_registered_lock);
+ ret = search_oid (string, NULL, &oid_spec);
+ if (ret)
+ mode = oid_spec.mode;
+ ath_mutex_unlock (&ciphers_registered_lock);
+
+ return mode;
+}
+
+
+/* Map the cipher algorithm whose ID is contained in ALGORITHM to a
+ string representation of the algorithm name. For unknown algorithm
+ IDs this function returns "?". */
+static const char *
+cipher_algo_to_string (int algorithm)
+{
+ gcry_module_t cipher;
+ const char *name;
+
+ REGISTER_DEFAULT_CIPHERS;
+
+ ath_mutex_lock (&ciphers_registered_lock);
+ cipher = _gcry_module_lookup_id (ciphers_registered, algorithm);
+ if (cipher)
+ {
+ name = ((gcry_cipher_spec_t *) cipher->spec)->name;
+ _gcry_module_release (cipher);
+ }
+ else
+ name = "?";
+ ath_mutex_unlock (&ciphers_registered_lock);
+
+ return name;
+}
+
+/* Map the cipher algorithm identifier ALGORITHM to a string
+ representing this algorithm. This string is the default name as
+ used by Libgcrypt. An pointer to an empty string is returned for
+ an unknown algorithm. NULL is never returned. */
+const char *
+gcry_cipher_algo_name (int algorithm)
+{
+ return cipher_algo_to_string (algorithm);
+}
+
+
+/* Flag the cipher algorithm with the identifier ALGORITHM as
+ disabled. There is no error return, the function does nothing for
+ unknown algorithms. Disabled algorithms are vitually not available
+ in Libgcrypt. */
+static void
+disable_cipher_algo (int algorithm)
+{
+ gcry_module_t cipher;
+
+ REGISTER_DEFAULT_CIPHERS;
+
+ ath_mutex_lock (&ciphers_registered_lock);
+ cipher = _gcry_module_lookup_id (ciphers_registered, algorithm);
+ if (cipher)
+ {
+ if (! (cipher->flags & FLAG_MODULE_DISABLED))
+ cipher->flags |= FLAG_MODULE_DISABLED;
+ _gcry_module_release (cipher);
+ }
+ ath_mutex_unlock (&ciphers_registered_lock);
+}
+
+
+/* Return 0 if the cipher algorithm with identifier ALGORITHM is
+ available. Returns a basic error code value if it is not
+ available. */
+static gcry_err_code_t
+check_cipher_algo (int algorithm)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ gcry_module_t cipher;
+
+ REGISTER_DEFAULT_CIPHERS;
+
+ ath_mutex_lock (&ciphers_registered_lock);
+ cipher = _gcry_module_lookup_id (ciphers_registered, algorithm);
+ if (cipher)
+ {
+ if (cipher->flags & FLAG_MODULE_DISABLED)
+ err = GPG_ERR_CIPHER_ALGO;
+ _gcry_module_release (cipher);
+ }
+ else
+ err = GPG_ERR_CIPHER_ALGO;
+ ath_mutex_unlock (&ciphers_registered_lock);
+
+ return err;
+}
+
+
+/* Return the standard length in bits of the key for the cipher
+ algorithm with the identifier ALGORITHM. */
+static unsigned int
+cipher_get_keylen (int algorithm)
+{
+ gcry_module_t cipher;
+ unsigned len = 0;
+
+ REGISTER_DEFAULT_CIPHERS;
+
+ ath_mutex_lock (&ciphers_registered_lock);
+ cipher = _gcry_module_lookup_id (ciphers_registered, algorithm);
+ if (cipher)
+ {
+ len = ((gcry_cipher_spec_t *) cipher->spec)->keylen;
+ if (!len)
+ log_bug ("cipher %d w/o key length\n", algorithm);
+ _gcry_module_release (cipher);
+ }
+ ath_mutex_unlock (&ciphers_registered_lock);
+
+ return len;
+}
+
+/* Return the block length of the cipher algorithm with the identifier
+ ALGORITHM. This function return 0 for an invalid algorithm. */
+static unsigned int
+cipher_get_blocksize (int algorithm)
+{
+ gcry_module_t cipher;
+ unsigned len = 0;
+
+ REGISTER_DEFAULT_CIPHERS;
+
+ ath_mutex_lock (&ciphers_registered_lock);
+ cipher = _gcry_module_lookup_id (ciphers_registered, algorithm);
+ if (cipher)
+ {
+ len = ((gcry_cipher_spec_t *) cipher->spec)->blocksize;
+ if (! len)
+ log_bug ("cipher %d w/o blocksize\n", algorithm);
+ _gcry_module_release (cipher);
+ }
+ ath_mutex_unlock (&ciphers_registered_lock);
+
+ return len;
+}
+
+
+/*
+ Open a cipher handle for use with cipher algorithm ALGORITHM, using
+ the cipher mode MODE (one of the GCRY_CIPHER_MODE_*) and return a
+ handle in HANDLE. Put NULL into HANDLE and return an error code if
+ something goes wrong. FLAGS may be used to modify the
+ operation. The defined flags are:
+
+ GCRY_CIPHER_SECURE: allocate all internal buffers in secure memory.
+ GCRY_CIPHER_ENABLE_SYNC: Enable the sync operation as used in OpenPGP.
+ GCRY_CIPHER_CBC_CTS: Enable CTS mode.
+ GCRY_CIPHER_CBC_MAC: Enable MAC mode.
+
+ Values for these flags may be combined using OR.
+ */
+gcry_error_t
+gcry_cipher_open (gcry_cipher_hd_t *handle,
+ int algo, int mode, unsigned int flags)
+{
+ int secure = (flags & GCRY_CIPHER_SECURE);
+ gcry_cipher_spec_t *cipher = NULL;
+ cipher_extra_spec_t *extraspec = NULL;
+ gcry_module_t module = NULL;
+ gcry_cipher_hd_t h = NULL;
+ gcry_err_code_t err = 0;
+
+ /* If the application missed to call the random poll function, we do
+ it here to ensure that it is used once in a while. */
+ _gcry_fast_random_poll ();
+
+ REGISTER_DEFAULT_CIPHERS;
+
+ /* Fetch the according module and check whether the cipher is marked
+ available for use. */
+ ath_mutex_lock (&ciphers_registered_lock);
+ module = _gcry_module_lookup_id (ciphers_registered, algo);
+ if (module)
+ {
+ /* Found module. */
+
+ if (module->flags & FLAG_MODULE_DISABLED)
+ {
+ /* Not available for use. */
+ err = GPG_ERR_CIPHER_ALGO;
+ }
+ else
+ {
+ cipher = (gcry_cipher_spec_t *) module->spec;
+ extraspec = module->extraspec;
+ }
+ }
+ else
+ err = GPG_ERR_CIPHER_ALGO;
+ ath_mutex_unlock (&ciphers_registered_lock);
+
+ /* check flags */
+ if ((! err)
+ && ((flags & ~(0
+ | GCRY_CIPHER_SECURE
+ | GCRY_CIPHER_ENABLE_SYNC
+ | GCRY_CIPHER_CBC_CTS
+ | GCRY_CIPHER_CBC_MAC))
+ || (flags & GCRY_CIPHER_CBC_CTS & GCRY_CIPHER_CBC_MAC)))
+ err = GPG_ERR_CIPHER_ALGO;
+
+ /* check that a valid mode has been requested */
+ if (! err)
+ switch (mode)
+ {
+ case GCRY_CIPHER_MODE_ECB:
+ case GCRY_CIPHER_MODE_CBC:
+ case GCRY_CIPHER_MODE_CFB:
+ case GCRY_CIPHER_MODE_OFB:
+ case GCRY_CIPHER_MODE_CTR:
+ case GCRY_CIPHER_MODE_AESWRAP:
+ if ((cipher->encrypt == dummy_encrypt_block)
+ || (cipher->decrypt == dummy_decrypt_block))
+ err = GPG_ERR_INV_CIPHER_MODE;
+ break;
+
+ case GCRY_CIPHER_MODE_STREAM:
+ if ((cipher->stencrypt == dummy_encrypt_stream)
+ || (cipher->stdecrypt == dummy_decrypt_stream))
+ err = GPG_ERR_INV_CIPHER_MODE;
+ break;
+
+ case GCRY_CIPHER_MODE_NONE:
+ /* This mode may be used for debugging. It copies the main
+ text verbatim to the ciphertext. We do not allow this in
+ fips mode or if no debug flag has been set. */
+ if (fips_mode () || !_gcry_get_debug_flag (0))
+ err = GPG_ERR_INV_CIPHER_MODE;
+ break;
+
+ default:
+ err = GPG_ERR_INV_CIPHER_MODE;
+ }
+
+ /* Perform selftest here and mark this with a flag in cipher_table?
+ No, we should not do this as it takes too long. Further it does
+ not make sense to exclude algorithms with failing selftests at
+ runtime: If a selftest fails there is something seriously wrong
+ with the system and thus we better die immediately. */
+
+ if (! err)
+ {
+ size_t size = (sizeof (*h)
+ + 2 * cipher->contextsize
+ - sizeof (cipher_context_alignment_t)
+#ifdef NEED_16BYTE_ALIGNED_CONTEXT
+ + 15 /* Space for leading alignment gap. */
+#endif /*NEED_16BYTE_ALIGNED_CONTEXT*/
+ );
+
+ if (secure)
+ h = gcry_calloc_secure (1, size);
+ else
+ h = gcry_calloc (1, size);
+
+ if (! h)
+ err = gpg_err_code_from_syserror ();
+ else
+ {
+ size_t off = 0;
+
+#ifdef NEED_16BYTE_ALIGNED_CONTEXT
+ if ( ((unsigned long)h & 0x0f) )
+ {
+ /* The malloced block is not aligned on a 16 byte
+ boundary. Correct for this. */
+ off = 16 - ((unsigned long)h & 0x0f);
+ h = (void*)((char*)h + off);
+ }
+#endif /*NEED_16BYTE_ALIGNED_CONTEXT*/
+
+ h->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL;
+ h->actual_handle_size = size - off;
+ h->handle_offset = off;
+ h->cipher = cipher;
+ h->extraspec = extraspec;
+ h->module = module;
+ h->algo = algo;
+ h->mode = mode;
+ h->flags = flags;
+
+ /* Setup bulk encryption routines. */
+ switch (algo)
+ {
+#ifdef USE_AES
+ case GCRY_CIPHER_AES128:
+ case GCRY_CIPHER_AES192:
+ case GCRY_CIPHER_AES256:
+ h->bulk.cfb_enc = _gcry_aes_cfb_enc;
+ h->bulk.cfb_dec = _gcry_aes_cfb_dec;
+ h->bulk.cbc_enc = _gcry_aes_cbc_enc;
+ h->bulk.cbc_dec = _gcry_aes_cbc_dec;
+ h->bulk.ctr_enc = _gcry_aes_ctr_enc;
+ break;
+#endif /*USE_AES*/
+
+ default:
+ break;
+ }
+ }
+ }
+
+ /* Done. */
+
+ if (err)
+ {
+ if (module)
+ {
+ /* Release module. */
+ ath_mutex_lock (&ciphers_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&ciphers_registered_lock);
+ }
+ }
+
+ *handle = err ? NULL : h;
+
+ return gcry_error (err);
+}
+
+
+/* Release all resources associated with the cipher handle H. H may be
+ NULL in which case this is a no-operation. */
+void
+gcry_cipher_close (gcry_cipher_hd_t h)
+{
+ size_t off;
+
+ if (!h)
+ return;
+
+ if ((h->magic != CTX_MAGIC_SECURE)
+ && (h->magic != CTX_MAGIC_NORMAL))
+ _gcry_fatal_error(GPG_ERR_INTERNAL,
+ "gcry_cipher_close: already closed/invalid handle");
+ else
+ h->magic = 0;
+
+ /* Release module. */
+ ath_mutex_lock (&ciphers_registered_lock);
+ _gcry_module_release (h->module);
+ ath_mutex_unlock (&ciphers_registered_lock);
+
+ /* We always want to wipe out the memory even when the context has
+ been allocated in secure memory. The user might have disabled
+ secure memory or is using his own implementation which does not
+ do the wiping. To accomplish this we need to keep track of the
+ actual size of this structure because we have no way to known
+ how large the allocated area was when using a standard malloc. */
+ off = h->handle_offset;
+ wipememory (h, h->actual_handle_size);
+
+ gcry_free ((char*)h - off);
+}
+
+
+/* Set the key to be used for the encryption context C to KEY with
+ length KEYLEN. The length should match the required length. */
+static gcry_error_t
+cipher_setkey (gcry_cipher_hd_t c, byte *key, unsigned int keylen)
+{
+ gcry_err_code_t ret;
+
+ ret = (*c->cipher->setkey) (&c->context.c, key, keylen);
+ if (!ret)
+ {
+ /* Duplicate initial context. */
+ memcpy ((void *) ((char *) &c->context.c + c->cipher->contextsize),
+ (void *) &c->context.c,
+ c->cipher->contextsize);
+ c->marks.key = 1;
+ }
+ else
+ c->marks.key = 0;
+
+ return gcry_error (ret);
+}
+
+
+/* Set the IV to be used for the encryption context C to IV with
+ length IVLEN. The length should match the required length. */
+static void
+cipher_setiv( gcry_cipher_hd_t c, const byte *iv, unsigned ivlen )
+{
+ memset (c->u_iv.iv, 0, c->cipher->blocksize);
+ if (iv)
+ {
+ if (ivlen != c->cipher->blocksize)
+ {
+ log_info ("WARNING: cipher_setiv: ivlen=%u blklen=%u\n",
+ ivlen, (unsigned int)c->cipher->blocksize);
+ fips_signal_error ("IV length does not match blocklength");
+ }
+ if (ivlen > c->cipher->blocksize)
+ ivlen = c->cipher->blocksize;
+ memcpy (c->u_iv.iv, iv, ivlen);
+ c->marks.iv = 1;
+ }
+ else
+ c->marks.iv = 0;
+ c->unused = 0;
+}
+
+
+/* Reset the cipher context to the initial context. This is basically
+ the same as an release followed by a new. */
+static void
+cipher_reset (gcry_cipher_hd_t c)
+{
+ memcpy (&c->context.c,
+ (char *) &c->context.c + c->cipher->contextsize,
+ c->cipher->contextsize);
+ memset (&c->marks, 0, sizeof c->marks);
+ memset (c->u_iv.iv, 0, c->cipher->blocksize);
+ memset (c->lastiv, 0, c->cipher->blocksize);
+ memset (c->u_ctr.ctr, 0, c->cipher->blocksize);
+}
+
+
+
+static gcry_err_code_t
+do_ecb_encrypt (gcry_cipher_hd_t c,
+ unsigned char *outbuf, unsigned int outbuflen,
+ const unsigned char *inbuf, unsigned int inbuflen)
+{
+ unsigned int blocksize = c->cipher->blocksize;
+ unsigned int n, nblocks;
+
+ if (outbuflen < inbuflen)
+ return GPG_ERR_BUFFER_TOO_SHORT;
+ if ((inbuflen % blocksize))
+ return GPG_ERR_INV_LENGTH;
+
+ nblocks = inbuflen / c->cipher->blocksize;
+
+ for (n=0; n < nblocks; n++ )
+ {
+ c->cipher->encrypt (&c->context.c, outbuf, (byte*)/*arggg*/inbuf);
+ inbuf += blocksize;
+ outbuf += blocksize;
+ }
+ return 0;
+}
+
+static gcry_err_code_t
+do_ecb_decrypt (gcry_cipher_hd_t c,
+ unsigned char *outbuf, unsigned int outbuflen,
+ const unsigned char *inbuf, unsigned int inbuflen)
+{
+ unsigned int blocksize = c->cipher->blocksize;
+ unsigned int n, nblocks;
+
+ if (outbuflen < inbuflen)
+ return GPG_ERR_BUFFER_TOO_SHORT;
+ if ((inbuflen % blocksize))
+ return GPG_ERR_INV_LENGTH;
+ nblocks = inbuflen / c->cipher->blocksize;
+
+ for (n=0; n < nblocks; n++ )
+ {
+ c->cipher->decrypt (&c->context.c, outbuf, (byte*)/*arggg*/inbuf );
+ inbuf += blocksize;
+ outbuf += blocksize;
+ }
+
+ return 0;
+}
+
+
+static gcry_err_code_t
+do_cbc_encrypt (gcry_cipher_hd_t c,
+ unsigned char *outbuf, unsigned int outbuflen,
+ const unsigned char *inbuf, unsigned int inbuflen)
+{
+ unsigned int n;
+ unsigned char *ivp;
+ int i;
+ size_t blocksize = c->cipher->blocksize;
+ unsigned nblocks = inbuflen / blocksize;
+
+ if (outbuflen < ((c->flags & GCRY_CIPHER_CBC_MAC)? blocksize : inbuflen))
+ return GPG_ERR_BUFFER_TOO_SHORT;
+
+ if ((inbuflen % c->cipher->blocksize)
+ && !(inbuflen > c->cipher->blocksize
+ && (c->flags & GCRY_CIPHER_CBC_CTS)))
+ return GPG_ERR_INV_LENGTH;
+
+ if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
+ {
+ if ((inbuflen % blocksize) == 0)
+ nblocks--;
+ }
+
+ if (c->bulk.cbc_enc)
+ {
+ c->bulk.cbc_enc (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks,
+ (c->flags & GCRY_CIPHER_CBC_MAC));
+ inbuf += nblocks * blocksize;
+ if (!(c->flags & GCRY_CIPHER_CBC_MAC))
+ outbuf += nblocks * blocksize;
+ }
+ else
+ {
+ for (n=0; n < nblocks; n++ )
+ {
+ for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
+ outbuf[i] = inbuf[i] ^ *ivp++;
+ c->cipher->encrypt ( &c->context.c, outbuf, outbuf );
+ memcpy (c->u_iv.iv, outbuf, blocksize );
+ inbuf += blocksize;
+ if (!(c->flags & GCRY_CIPHER_CBC_MAC))
+ outbuf += blocksize;
+ }
+ }
+
+ if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
+ {
+ /* We have to be careful here, since outbuf might be equal to
+ inbuf. */
+ int restbytes;
+ unsigned char b;
+
+ if ((inbuflen % blocksize) == 0)
+ restbytes = blocksize;
+ else
+ restbytes = inbuflen % blocksize;
+
+ outbuf -= blocksize;
+ for (ivp = c->u_iv.iv, i = 0; i < restbytes; i++)
+ {
+ b = inbuf[i];
+ outbuf[blocksize + i] = outbuf[i];
+ outbuf[i] = b ^ *ivp++;
+ }
+ for (; i < blocksize; i++)
+ outbuf[i] = 0 ^ *ivp++;
+
+ c->cipher->encrypt (&c->context.c, outbuf, outbuf);
+ memcpy (c->u_iv.iv, outbuf, blocksize);
+ }
+
+ return 0;
+}
+
+
+static gcry_err_code_t
+do_cbc_decrypt (gcry_cipher_hd_t c,
+ unsigned char *outbuf, unsigned int outbuflen,
+ const unsigned char *inbuf, unsigned int inbuflen)
+{
+ unsigned int n;
+ unsigned char *ivp;
+ int i;
+ size_t blocksize = c->cipher->blocksize;
+ unsigned int nblocks = inbuflen / blocksize;
+
+ if (outbuflen < inbuflen)
+ return GPG_ERR_BUFFER_TOO_SHORT;
+
+ if ((inbuflen % c->cipher->blocksize)
+ && !(inbuflen > c->cipher->blocksize
+ && (c->flags & GCRY_CIPHER_CBC_CTS)))
+ return GPG_ERR_INV_LENGTH;
+
+ if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
+ {
+ nblocks--;
+ if ((inbuflen % blocksize) == 0)
+ nblocks--;
+ memcpy (c->lastiv, c->u_iv.iv, blocksize);
+ }
+
+ if (c->bulk.cbc_dec)
+ {
+ c->bulk.cbc_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
+ inbuf += nblocks * blocksize;
+ outbuf += nblocks * blocksize;
+ }
+ else
+ {
+ for (n=0; n < nblocks; n++ )
+ {
+ /* Because outbuf and inbuf might be the same, we have to
+ * save the original ciphertext block. We use LASTIV for
+ * this here because it is not used otherwise. */
+ memcpy (c->lastiv, inbuf, blocksize);
+ c->cipher->decrypt ( &c->context.c, outbuf, inbuf );
+ for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
+ outbuf[i] ^= *ivp++;
+ memcpy(c->u_iv.iv, c->lastiv, blocksize );
+ inbuf += c->cipher->blocksize;
+ outbuf += c->cipher->blocksize;
+ }
+ }
+
+ if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
+ {
+ int restbytes;
+
+ if ((inbuflen % blocksize) == 0)
+ restbytes = blocksize;
+ else
+ restbytes = inbuflen % blocksize;
+
+ memcpy (c->lastiv, c->u_iv.iv, blocksize ); /* Save Cn-2. */
+ memcpy (c->u_iv.iv, inbuf + blocksize, restbytes ); /* Save Cn. */
+
+ c->cipher->decrypt ( &c->context.c, outbuf, inbuf );
+ for (ivp=c->u_iv.iv,i=0; i < restbytes; i++ )
+ outbuf[i] ^= *ivp++;
+
+ memcpy(outbuf + blocksize, outbuf, restbytes);
+ for(i=restbytes; i < blocksize; i++)
+ c->u_iv.iv[i] = outbuf[i];
+ c->cipher->decrypt (&c->context.c, outbuf, c->u_iv.iv);
+ for(ivp=c->lastiv,i=0; i < blocksize; i++ )
+ outbuf[i] ^= *ivp++;
+ /* c->lastiv is now really lastlastiv, does this matter? */
+ }
+
+ return 0;
+}
+
+
+static gcry_err_code_t
+do_cfb_encrypt (gcry_cipher_hd_t c,
+ unsigned char *outbuf, unsigned int outbuflen,
+ const unsigned char *inbuf, unsigned int inbuflen)
+{
+ unsigned char *ivp;
+ size_t blocksize = c->cipher->blocksize;
+ size_t blocksize_x_2 = blocksize + blocksize;
+
+ if (outbuflen < inbuflen)
+ return GPG_ERR_BUFFER_TOO_SHORT;
+
+ if ( inbuflen <= c->unused )
+ {
+ /* Short enough to be encoded by the remaining XOR mask. */
+ /* XOR the input with the IV and store input into IV. */
+ for (ivp=c->u_iv.iv+c->cipher->blocksize - c->unused;
+ inbuflen;
+ inbuflen--, c->unused-- )
+ *outbuf++ = (*ivp++ ^= *inbuf++);
+ return 0;
+ }
+
+ if ( c->unused )
+ {
+ /* XOR the input with the IV and store input into IV */
+ inbuflen -= c->unused;
+ for(ivp=c->u_iv.iv+blocksize - c->unused; c->unused; c->unused-- )
+ *outbuf++ = (*ivp++ ^= *inbuf++);
+ }
+
+ /* Now we can process complete blocks. We use a loop as long as we
+ have at least 2 blocks and use conditions for the rest. This
+ also allows to use a bulk encryption function if available. */
+ if (inbuflen >= blocksize_x_2 && c->bulk.cfb_enc)
+ {
+ unsigned int nblocks = inbuflen / blocksize;
+ c->bulk.cfb_enc (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
+ outbuf += nblocks * blocksize;
+ inbuf += nblocks * blocksize;
+ inbuflen -= nblocks * blocksize;
+ }
+ else
+ {
+ while ( inbuflen >= blocksize_x_2 )
+ {
+ int i;
+ /* Encrypt the IV. */
+ c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
+ /* XOR the input with the IV and store input into IV. */
+ for(ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
+ *outbuf++ = (*ivp++ ^= *inbuf++);
+ inbuflen -= blocksize;
+ }
+ }
+
+ if ( inbuflen >= blocksize )
+ {
+ int i;
+ /* Save the current IV and then encrypt the IV. */
+ memcpy( c->lastiv, c->u_iv.iv, blocksize );
+ c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
+ /* XOR the input with the IV and store input into IV */
+ for(ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
+ *outbuf++ = (*ivp++ ^= *inbuf++);
+ inbuflen -= blocksize;
+ }
+ if ( inbuflen )
+ {
+ /* Save the current IV and then encrypt the IV. */
+ memcpy( c->lastiv, c->u_iv.iv, blocksize );
+ c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
+ c->unused = blocksize;
+ /* Apply the XOR. */
+ c->unused -= inbuflen;
+ for(ivp=c->u_iv.iv; inbuflen; inbuflen-- )
+ *outbuf++ = (*ivp++ ^= *inbuf++);
+ }
+ return 0;
+}
+
+
+static gcry_err_code_t
+do_cfb_decrypt (gcry_cipher_hd_t c,
+ unsigned char *outbuf, unsigned int outbuflen,
+ const unsigned char *inbuf, unsigned int inbuflen)
+{
+ unsigned char *ivp;
+ unsigned long temp;
+ int i;
+ size_t blocksize = c->cipher->blocksize;
+ size_t blocksize_x_2 = blocksize + blocksize;
+
+ if (outbuflen < inbuflen)
+ return GPG_ERR_BUFFER_TOO_SHORT;
+
+ if (inbuflen <= c->unused)
+ {
+ /* Short enough to be encoded by the remaining XOR mask. */
+ /* XOR the input with the IV and store input into IV. */
+ for (ivp=c->u_iv.iv+blocksize - c->unused;
+ inbuflen;
+ inbuflen--, c->unused--)
+ {
+ temp = *inbuf++;
+ *outbuf++ = *ivp ^ temp;
+ *ivp++ = temp;
+ }
+ return 0;
+ }
+
+ if (c->unused)
+ {
+ /* XOR the input with the IV and store input into IV. */
+ inbuflen -= c->unused;
+ for (ivp=c->u_iv.iv+blocksize - c->unused; c->unused; c->unused-- )
+ {
+ temp = *inbuf++;
+ *outbuf++ = *ivp ^ temp;
+ *ivp++ = temp;
+ }
+ }
+
+ /* Now we can process complete blocks. We use a loop as long as we
+ have at least 2 blocks and use conditions for the rest. This
+ also allows to use a bulk encryption function if available. */
+ if (inbuflen >= blocksize_x_2 && c->bulk.cfb_dec)
+ {
+ unsigned int nblocks = inbuflen / blocksize;
+ c->bulk.cfb_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
+ outbuf += nblocks * blocksize;
+ inbuf += nblocks * blocksize;
+ inbuflen -= nblocks * blocksize;
+ }
+ else
+ {
+ while (inbuflen >= blocksize_x_2 )
+ {
+ /* Encrypt the IV. */
+ c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
+ /* XOR the input with the IV and store input into IV. */
+ for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
+ {
+ temp = *inbuf++;
+ *outbuf++ = *ivp ^ temp;
+ *ivp++ = temp;
+ }
+ inbuflen -= blocksize;
+ }
+ }
+
+ if (inbuflen >= blocksize )
+ {
+ /* Save the current IV and then encrypt the IV. */
+ memcpy ( c->lastiv, c->u_iv.iv, blocksize);
+ c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
+ /* XOR the input with the IV and store input into IV */
+ for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
+ {
+ temp = *inbuf++;
+ *outbuf++ = *ivp ^ temp;
+ *ivp++ = temp;
+ }
+ inbuflen -= blocksize;
+ }
+
+ if (inbuflen)
+ {
+ /* Save the current IV and then encrypt the IV. */
+ memcpy ( c->lastiv, c->u_iv.iv, blocksize );
+ c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
+ c->unused = blocksize;
+ /* Apply the XOR. */
+ c->unused -= inbuflen;
+ for (ivp=c->u_iv.iv; inbuflen; inbuflen-- )
+ {
+ temp = *inbuf++;
+ *outbuf++ = *ivp ^ temp;
+ *ivp++ = temp;
+ }
+ }
+ return 0;
+}
+
+
+static gcry_err_code_t
+do_ofb_encrypt (gcry_cipher_hd_t c,
+ unsigned char *outbuf, unsigned int outbuflen,
+ const unsigned char *inbuf, unsigned int inbuflen)
+{
+ unsigned char *ivp;
+ size_t blocksize = c->cipher->blocksize;
+
+ if (outbuflen < inbuflen)
+ return GPG_ERR_BUFFER_TOO_SHORT;
+
+ if ( inbuflen <= c->unused )
+ {
+ /* Short enough to be encoded by the remaining XOR mask. */
+ /* XOR the input with the IV */
+ for (ivp=c->u_iv.iv+c->cipher->blocksize - c->unused;
+ inbuflen;
+ inbuflen--, c->unused-- )
+ *outbuf++ = (*ivp++ ^ *inbuf++);
+ return 0;
+ }
+
+ if( c->unused )
+ {
+ inbuflen -= c->unused;
+ for(ivp=c->u_iv.iv+blocksize - c->unused; c->unused; c->unused-- )
+ *outbuf++ = (*ivp++ ^ *inbuf++);
+ }
+
+ /* Now we can process complete blocks. */
+ while ( inbuflen >= blocksize )
+ {
+ int i;
+ /* Encrypt the IV (and save the current one). */
+ memcpy( c->lastiv, c->u_iv.iv, blocksize );
+ c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
+
+ for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
+ *outbuf++ = (*ivp++ ^ *inbuf++);
+ inbuflen -= blocksize;
+ }
+ if ( inbuflen )
+ { /* process the remaining bytes */
+ memcpy( c->lastiv, c->u_iv.iv, blocksize );
+ c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
+ c->unused = blocksize;
+ c->unused -= inbuflen;
+ for(ivp=c->u_iv.iv; inbuflen; inbuflen-- )
+ *outbuf++ = (*ivp++ ^ *inbuf++);
+ }
+ return 0;
+}
+
+static gcry_err_code_t
+do_ofb_decrypt (gcry_cipher_hd_t c,
+ unsigned char *outbuf, unsigned int outbuflen,
+ const unsigned char *inbuf, unsigned int inbuflen)
+{
+ unsigned char *ivp;
+ size_t blocksize = c->cipher->blocksize;
+
+ if (outbuflen < inbuflen)
+ return GPG_ERR_BUFFER_TOO_SHORT;
+
+ if( inbuflen <= c->unused )
+ {
+ /* Short enough to be encoded by the remaining XOR mask. */
+ for (ivp=c->u_iv.iv+blocksize - c->unused; inbuflen; inbuflen--,c->unused--)
+ *outbuf++ = *ivp++ ^ *inbuf++;
+ return 0;
+ }
+
+ if ( c->unused )
+ {
+ inbuflen -= c->unused;
+ for (ivp=c->u_iv.iv+blocksize - c->unused; c->unused; c->unused-- )
+ *outbuf++ = *ivp++ ^ *inbuf++;
+ }
+
+ /* Now we can process complete blocks. */
+ while ( inbuflen >= blocksize )
+ {
+ int i;
+ /* Encrypt the IV (and save the current one). */
+ memcpy( c->lastiv, c->u_iv.iv, blocksize );
+ c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
+ for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
+ *outbuf++ = *ivp++ ^ *inbuf++;
+ inbuflen -= blocksize;
+ }
+ if ( inbuflen )
+ { /* Process the remaining bytes. */
+ /* Encrypt the IV (and save the current one). */
+ memcpy( c->lastiv, c->u_iv.iv, blocksize );
+ c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
+ c->unused = blocksize;
+ c->unused -= inbuflen;
+ for (ivp=c->u_iv.iv; inbuflen; inbuflen-- )
+ *outbuf++ = *ivp++ ^ *inbuf++;
+ }
+ return 0;
+}
+
+
+static gcry_err_code_t
+do_ctr_encrypt (gcry_cipher_hd_t c,
+ unsigned char *outbuf, unsigned int outbuflen,
+ const unsigned char *inbuf, unsigned int inbuflen)
+{
+ unsigned int n;
+ int i;
+ unsigned int blocksize = c->cipher->blocksize;
+ unsigned int nblocks;
+
+ if (outbuflen < inbuflen)
+ return GPG_ERR_BUFFER_TOO_SHORT;
+
+ /* First process a left over encrypted counter. */
+ if (c->unused)
+ {
+ gcry_assert (c->unused < blocksize);
+ i = blocksize - c->unused;
+ for (n=0; c->unused && n < inbuflen; c->unused--, n++, i++)
+ {
+ /* XOR input with encrypted counter and store in output. */
+ outbuf[n] = inbuf[n] ^ c->lastiv[i];
+ }
+ inbuf += n;
+ outbuf += n;
+ inbuflen -= n;
+ }
+
+
+ /* Use a bulk method if available. */
+ nblocks = inbuflen / blocksize;
+ if (nblocks && c->bulk.ctr_enc)
+ {
+ c->bulk.ctr_enc (&c->context.c, c->u_ctr.ctr, outbuf, inbuf, nblocks);
+ inbuf += nblocks * blocksize;
+ outbuf += nblocks * blocksize;
+ inbuflen -= nblocks * blocksize;
+ }
+
+ /* If we don't have a bulk method use the standard method. We also
+ use this method for the a remaining partial block. */
+ if (inbuflen)
+ {
+ unsigned char tmp[MAX_BLOCKSIZE];
+
+ for (n=0; n < inbuflen; n++)
+ {
+ if ((n % blocksize) == 0)
+ {
+ c->cipher->encrypt (&c->context.c, tmp, c->u_ctr.ctr);
+
+ for (i = blocksize; i > 0; i--)
+ {
+ c->u_ctr.ctr[i-1]++;
+ if (c->u_ctr.ctr[i-1] != 0)
+ break;
+ }
+ }
+
+ /* XOR input with encrypted counter and store in output. */
+ outbuf[n] = inbuf[n] ^ tmp[n % blocksize];
+ }
+
+ /* Save the unused bytes of the counter. */
+ n %= blocksize;
+ c->unused = (blocksize - n) % blocksize;
+ if (c->unused)
+ memcpy (c->lastiv+n, tmp+n, c->unused);
+
+ wipememory (tmp, sizeof tmp);
+ }
+
+ return 0;
+}
+
+static gcry_err_code_t
+do_ctr_decrypt (gcry_cipher_hd_t c,
+ unsigned char *outbuf, unsigned int outbuflen,
+ const unsigned char *inbuf, unsigned int inbuflen)
+{
+ return do_ctr_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+}
+
+
+/* Perform the AES-Wrap algorithm as specified by RFC3394. We
+ implement this as a mode usable with any cipher algorithm of
+ blocksize 128. */
+static gcry_err_code_t
+do_aeswrap_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
+ const byte *inbuf, unsigned int inbuflen )
+{
+ int j, x;
+ unsigned int n, i;
+ unsigned char *r, *a, *b;
+ unsigned char t[8];
+
+#if MAX_BLOCKSIZE < 8
+#error Invalid block size
+#endif
+ /* We require a cipher with a 128 bit block length. */
+ if (c->cipher->blocksize != 16)
+ return GPG_ERR_INV_LENGTH;
+
+ /* The output buffer must be able to hold the input data plus one
+ additional block. */
+ if (outbuflen < inbuflen + 8)
+ return GPG_ERR_BUFFER_TOO_SHORT;
+ /* Input data must be multiple of 64 bits. */
+ if (inbuflen % 8)
+ return GPG_ERR_INV_ARG;
+
+ n = inbuflen / 8;
+
+ /* We need at least two 64 bit blocks. */
+ if (n < 2)
+ return GPG_ERR_INV_ARG;
+
+ r = outbuf;
+ a = outbuf; /* We store A directly in OUTBUF. */
+ b = c->u_ctr.ctr; /* B is also used to concatenate stuff. */
+
+ /* If an IV has been set we use that IV as the Alternative Initial
+ Value; if it has not been set we use the standard value. */
+ if (c->marks.iv)
+ memcpy (a, c->u_iv.iv, 8);
+ else
+ memset (a, 0xa6, 8);
+
+ /* Copy the inbuf to the outbuf. */
+ memmove (r+8, inbuf, inbuflen);
+
+ memset (t, 0, sizeof t); /* t := 0. */
+
+ for (j = 0; j <= 5; j++)
+ {
+ for (i = 1; i <= n; i++)
+ {
+ /* B := AES_k( A | R[i] ) */
+ memcpy (b, a, 8);
+ memcpy (b+8, r+i*8, 8);
+ c->cipher->encrypt (&c->context.c, b, b);
+ /* t := t + 1 */
+ for (x = 7; x >= 0; x--)
+ {
+ t[x]++;
+ if (t[x])
+ break;
+ }
+ /* A := MSB_64(B) ^ t */
+ for (x=0; x < 8; x++)
+ a[x] = b[x] ^ t[x];
+ /* R[i] := LSB_64(B) */
+ memcpy (r+i*8, b+8, 8);
+ }
+ }
+
+ return 0;
+}
+
+/* Perform the AES-Unwrap algorithm as specified by RFC3394. We
+ implement this as a mode usable with any cipher algorithm of
+ blocksize 128. */
+static gcry_err_code_t
+do_aeswrap_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
+ const byte *inbuf, unsigned int inbuflen)
+{
+ int j, x;
+ unsigned int n, i;
+ unsigned char *r, *a, *b;
+ unsigned char t[8];
+
+#if MAX_BLOCKSIZE < 8
+#error Invalid block size
+#endif
+ /* We require a cipher with a 128 bit block length. */
+ if (c->cipher->blocksize != 16)
+ return GPG_ERR_INV_LENGTH;
+
+ /* The output buffer must be able to hold the input data minus one
+ additional block. Fixme: The caller has more restrictive checks
+ - we may want to fix them for this mode. */
+ if (outbuflen + 8 < inbuflen)
+ return GPG_ERR_BUFFER_TOO_SHORT;
+ /* Input data must be multiple of 64 bits. */
+ if (inbuflen % 8)
+ return GPG_ERR_INV_ARG;
+
+ n = inbuflen / 8;
+
+ /* We need at least three 64 bit blocks. */
+ if (n < 3)
+ return GPG_ERR_INV_ARG;
+
+ r = outbuf;
+ a = c->lastiv; /* We use c->LASTIV as buffer for A. */
+ b = c->u_ctr.ctr; /* B is also used to concatenate stuff. */
+
+ /* Copy the inbuf to the outbuf and save A. */
+ memcpy (a, inbuf, 8);
+ memmove (r, inbuf+8, inbuflen-8);
+ n--; /* Reduce to actual number of data blocks. */
+
+ /* t := 6 * n */
+ i = n * 6; /* The range is valid because: n = inbuflen / 8 - 1. */
+ for (x=0; x < 8 && x < sizeof (i); x++)
+ t[7-x] = i >> (8*x);
+ for (; x < 8; x++)
+ t[7-x] = 0;
+
+ for (j = 5; j >= 0; j--)
+ {
+ for (i = n; i >= 1; i--)
+ {
+ /* B := AES_k^1( (A ^ t)| R[i] ) */
+ for (x = 0; x < 8; x++)
+ b[x] = a[x] ^ t[x];
+ memcpy (b+8, r+(i-1)*8, 8);
+ c->cipher->decrypt (&c->context.c, b, b);
+ /* t := t - 1 */
+ for (x = 7; x >= 0; x--)
+ {
+ t[x]--;
+ if (t[x] != 0xff)
+ break;
+ }
+ /* A := MSB_64(B) */
+ memcpy (a, b, 8);
+ /* R[i] := LSB_64(B) */
+ memcpy (r+(i-1)*8, b+8, 8);
+ }
+ }
+
+ /* If an IV has been set we compare against this Alternative Initial
+ Value; if it has not been set we compare against the standard IV. */
+ if (c->marks.iv)
+ j = memcmp (a, c->u_iv.iv, 8);
+ else
+ {
+ for (j=0, x=0; x < 8; x++)
+ if (a[x] != 0xa6)
+ {
+ j=1;
+ break;
+ }
+ }
+ return j? GPG_ERR_CHECKSUM : 0;
+}
+
+
+/****************
+ * Encrypt INBUF to OUTBUF with the mode selected at open.
+ * inbuf and outbuf may overlap or be the same.
+ * Depending on the mode some constraints apply to INBUFLEN.
+ */
+static gcry_err_code_t
+cipher_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
+ const byte *inbuf, unsigned int inbuflen)
+{
+ gcry_err_code_t rc;
+
+ switch (c->mode)
+ {
+ case GCRY_CIPHER_MODE_ECB:
+ rc = do_ecb_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_CBC:
+ rc = do_cbc_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_CFB:
+ rc = do_cfb_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_OFB:
+ rc = do_ofb_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_CTR:
+ rc = do_ctr_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_AESWRAP:
+ rc = do_aeswrap_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_STREAM:
+ c->cipher->stencrypt (&c->context.c,
+ outbuf, (byte*)/*arggg*/inbuf, inbuflen);
+ rc = 0;
+ break;
+
+ case GCRY_CIPHER_MODE_NONE:
+ if (fips_mode () || !_gcry_get_debug_flag (0))
+ {
+ fips_signal_error ("cipher mode NONE used");
+ rc = GPG_ERR_INV_CIPHER_MODE;
+ }
+ else
+ {
+ if (inbuf != outbuf)
+ memmove (outbuf, inbuf, inbuflen);
+ rc = 0;
+ }
+ break;
+
+ default:
+ log_fatal ("cipher_encrypt: invalid mode %d\n", c->mode );
+ rc = GPG_ERR_INV_CIPHER_MODE;
+ break;
+ }
+
+ return rc;
+}
+
+
+/****************
+ * Encrypt IN and write it to OUT. If IN is NULL, in-place encryption has
+ * been requested.
+ */
+gcry_error_t
+gcry_cipher_encrypt (gcry_cipher_hd_t h, void *out, size_t outsize,
+ const void *in, size_t inlen)
+{
+ gcry_err_code_t err;
+
+ if (!in) /* Caller requested in-place encryption. */
+ err = cipher_encrypt (h, out, outsize, out, outsize);
+ else
+ err = cipher_encrypt (h, out, outsize, in, inlen);
+
+ /* Failsafe: Make sure that the plaintext will never make it into
+ OUT if the encryption returned an error. */
+ if (err && out)
+ memset (out, 0x42, outsize);
+
+ return gcry_error (err);
+}
+
+
+
+/****************
+ * Decrypt INBUF to OUTBUF with the mode selected at open.
+ * inbuf and outbuf may overlap or be the same.
+ * Depending on the mode some some contraints apply to INBUFLEN.
+ */
+static gcry_err_code_t
+cipher_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
+ const byte *inbuf, unsigned int inbuflen)
+{
+ gcry_err_code_t rc;
+
+ switch (c->mode)
+ {
+ case GCRY_CIPHER_MODE_ECB:
+ rc = do_ecb_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_CBC:
+ rc = do_cbc_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_CFB:
+ rc = do_cfb_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_OFB:
+ rc = do_ofb_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_CTR:
+ rc = do_ctr_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_AESWRAP:
+ rc = do_aeswrap_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ break;
+
+ case GCRY_CIPHER_MODE_STREAM:
+ c->cipher->stdecrypt (&c->context.c,
+ outbuf, (byte*)/*arggg*/inbuf, inbuflen);
+ rc = 0;
+ break;
+
+ case GCRY_CIPHER_MODE_NONE:
+ if (fips_mode () || !_gcry_get_debug_flag (0))
+ {
+ fips_signal_error ("cipher mode NONE used");
+ rc = GPG_ERR_INV_CIPHER_MODE;
+ }
+ else
+ {
+ if (inbuf != outbuf)
+ memmove (outbuf, inbuf, inbuflen);
+ rc = 0;
+ }
+ break;
+
+ default:
+ log_fatal ("cipher_decrypt: invalid mode %d\n", c->mode );
+ rc = GPG_ERR_INV_CIPHER_MODE;
+ break;
+ }
+
+ return rc;
+}
+
+
+gcry_error_t
+gcry_cipher_decrypt (gcry_cipher_hd_t h, void *out, size_t outsize,
+ const void *in, size_t inlen)
+{
+ gcry_err_code_t err;
+
+ if (!in) /* Caller requested in-place encryption. */
+ err = cipher_decrypt (h, out, outsize, out, outsize);
+ else
+ err = cipher_decrypt (h, out, outsize, in, inlen);
+
+ return gcry_error (err);
+}
+
+
+
+/****************
+ * Used for PGP's somewhat strange CFB mode. Only works if
+ * the corresponding flag is set.
+ */
+static void
+cipher_sync (gcry_cipher_hd_t c)
+{
+ if ((c->flags & GCRY_CIPHER_ENABLE_SYNC) && c->unused)
+ {
+ memmove (c->u_iv.iv + c->unused,
+ c->u_iv.iv, c->cipher->blocksize - c->unused);
+ memcpy (c->u_iv.iv,
+ c->lastiv + c->cipher->blocksize - c->unused, c->unused);
+ c->unused = 0;
+ }
+}
+
+
+gcry_error_t
+_gcry_cipher_setkey (gcry_cipher_hd_t hd, const void *key, size_t keylen)
+{
+ return cipher_setkey (hd, (void*)key, keylen);
+}
+
+
+gcry_error_t
+_gcry_cipher_setiv (gcry_cipher_hd_t hd, const void *iv, size_t ivlen)
+{
+ cipher_setiv (hd, iv, ivlen);
+ return 0;
+}
+
+/* Set counter for CTR mode. (CTR,CTRLEN) must denote a buffer of
+ block size length, or (NULL,0) to set the CTR to the all-zero
+ block. */
+gpg_error_t
+_gcry_cipher_setctr (gcry_cipher_hd_t hd, const void *ctr, size_t ctrlen)
+{
+ if (ctr && ctrlen == hd->cipher->blocksize)
+ {
+ memcpy (hd->u_ctr.ctr, ctr, hd->cipher->blocksize);
+ hd->unused = 0;
+ }
+ else if (!ctr || !ctrlen)
+ {
+ memset (hd->u_ctr.ctr, 0, hd->cipher->blocksize);
+ hd->unused = 0;
+ }
+ else
+ return gpg_error (GPG_ERR_INV_ARG);
+ return 0;
+}
+
+
+gcry_error_t
+gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen)
+{
+ gcry_err_code_t rc = GPG_ERR_NO_ERROR;
+
+ switch (cmd)
+ {
+ case GCRYCTL_SET_KEY: /* Deprecated; use gcry_cipher_setkey. */
+ rc = cipher_setkey( h, buffer, buflen );
+ break;
+
+ case GCRYCTL_SET_IV: /* Deprecated; use gcry_cipher_setiv. */
+ cipher_setiv( h, buffer, buflen );
+ break;
+
+ case GCRYCTL_RESET:
+ cipher_reset (h);
+ break;
+
+ case GCRYCTL_CFB_SYNC:
+ cipher_sync( h );
+ break;
+
+ case GCRYCTL_SET_CBC_CTS:
+ if (buflen)
+ if (h->flags & GCRY_CIPHER_CBC_MAC)
+ rc = GPG_ERR_INV_FLAG;
+ else
+ h->flags |= GCRY_CIPHER_CBC_CTS;
+ else
+ h->flags &= ~GCRY_CIPHER_CBC_CTS;
+ break;
+
+ case GCRYCTL_SET_CBC_MAC:
+ if (buflen)
+ if (h->flags & GCRY_CIPHER_CBC_CTS)
+ rc = GPG_ERR_INV_FLAG;
+ else
+ h->flags |= GCRY_CIPHER_CBC_MAC;
+ else
+ h->flags &= ~GCRY_CIPHER_CBC_MAC;
+ break;
+
+ case GCRYCTL_DISABLE_ALGO:
+ /* This command expects NULL for H and BUFFER to point to an
+ integer with the algo number. */
+ if( h || !buffer || buflen != sizeof(int) )
+ return gcry_error (GPG_ERR_CIPHER_ALGO);
+ disable_cipher_algo( *(int*)buffer );
+ break;
+
+ case GCRYCTL_SET_CTR: /* Deprecated; use gcry_cipher_setctr. */
+ rc = gpg_err_code (_gcry_cipher_setctr (h, buffer, buflen));
+ break;
+
+ case 61: /* Disable weak key detection (private). */
+ if (h->extraspec->set_extra_info)
+ rc = h->extraspec->set_extra_info
+ (&h->context.c, CIPHER_INFO_NO_WEAK_KEY, NULL, 0);
+ else
+ rc = GPG_ERR_NOT_SUPPORTED;
+ break;
+
+ case 62: /* Return current input vector (private). */
+ /* This is the input block as used in CFB and OFB mode which has
+ initially been set as IV. The returned format is:
+ 1 byte Actual length of the block in bytes.
+ n byte The block.
+ If the provided buffer is too short, an error is returned. */
+ if (buflen < (1 + h->cipher->blocksize))
+ rc = GPG_ERR_TOO_SHORT;
+ else
+ {
+ unsigned char *ivp;
+ unsigned char *dst = buffer;
+ int n = h->unused;
+
+ if (!n)
+ n = h->cipher->blocksize;
+ gcry_assert (n <= h->cipher->blocksize);
+ *dst++ = n;
+ ivp = h->u_iv.iv + h->cipher->blocksize - n;
+ while (n--)
+ *dst++ = *ivp++;
+ }
+ break;
+
+ default:
+ rc = GPG_ERR_INV_OP;
+ }
+
+ return gcry_error (rc);
+}
+
+
+/* Return information about the cipher handle H. CMD is the kind of
+ information requested. BUFFER and NBYTES are reserved for now.
+
+ There are no values for CMD yet defined.
+
+ The function always returns GPG_ERR_INV_OP.
+
+ */
+gcry_error_t
+gcry_cipher_info (gcry_cipher_hd_t h, int cmd, void *buffer, size_t *nbytes)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ (void)h;
+ (void)buffer;
+ (void)nbytes;
+
+ switch (cmd)
+ {
+ default:
+ err = GPG_ERR_INV_OP;
+ }
+
+ return gcry_error (err);
+}
+
+/* Return information about the given cipher algorithm ALGO.
+
+ WHAT select the kind of information returned:
+
+ GCRYCTL_GET_KEYLEN:
+ Return the length of the key. If the algorithm ALGO
+ supports multiple key lengths, the maximum supported key length
+ is returned. The key length is returned as number of octets.
+ BUFFER and NBYTES must be zero.
+
+ GCRYCTL_GET_BLKLEN:
+ Return the blocklength of the algorithm ALGO counted in octets.
+ BUFFER and NBYTES must be zero.
+
+ GCRYCTL_TEST_ALGO:
+ Returns 0 if the specified algorithm ALGO is available for use.
+ BUFFER and NBYTES must be zero.
+
+ Note: Because this function is in most cases used to return an
+ integer value, we can make it easier for the caller to just look at
+ the return value. The caller will in all cases consult the value
+ and thereby detecting whether a error occurred or not (i.e. while
+ checking the block size)
+ */
+gcry_error_t
+gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ unsigned int ui;
+
+ switch (what)
+ {
+ case GCRYCTL_GET_KEYLEN:
+ if (buffer || (! nbytes))
+ err = GPG_ERR_CIPHER_ALGO;
+ else
+ {
+ ui = cipher_get_keylen (algo);
+ if ((ui > 0) && (ui <= 512))
+ *nbytes = (size_t) ui / 8;
+ else
+ /* The only reason for an error is an invalid algo. */
+ err = GPG_ERR_CIPHER_ALGO;
+ }
+ break;
+
+ case GCRYCTL_GET_BLKLEN:
+ if (buffer || (! nbytes))
+ err = GPG_ERR_CIPHER_ALGO;
+ else
+ {
+ ui = cipher_get_blocksize (algo);
+ if ((ui > 0) && (ui < 10000))
+ *nbytes = ui;
+ else
+ /* The only reason is an invalid algo or a strange
+ blocksize. */
+ err = GPG_ERR_CIPHER_ALGO;
+ }
+ break;
+
+ case GCRYCTL_TEST_ALGO:
+ if (buffer || nbytes)
+ err = GPG_ERR_INV_ARG;
+ else
+ err = check_cipher_algo (algo);
+ break;
+
+ default:
+ err = GPG_ERR_INV_OP;
+ }
+
+ return gcry_error (err);
+}
+
+
+/* This function returns length of the key for algorithm ALGO. If the
+ algorithm supports multiple key lengths, the maximum supported key
+ length is returned. On error 0 is returned. The key length is
+ returned as number of octets.
+
+ This is a convenience functions which should be preferred over
+ gcry_cipher_algo_info because it allows for proper type
+ checking. */
+size_t
+gcry_cipher_get_algo_keylen (int algo)
+{
+ size_t n;
+
+ if (gcry_cipher_algo_info (algo, GCRYCTL_GET_KEYLEN, NULL, &n))
+ n = 0;
+ return n;
+}
+
+/* This functions returns the blocklength of the algorithm ALGO
+ counted in octets. On error 0 is returned.
+
+ This is a convenience functions which should be preferred over
+ gcry_cipher_algo_info because it allows for proper type
+ checking. */
+size_t
+gcry_cipher_get_algo_blklen (int algo)
+{
+ size_t n;
+
+ if (gcry_cipher_algo_info( algo, GCRYCTL_GET_BLKLEN, NULL, &n))
+ n = 0;
+ return n;
+}
+
+/* Explicitly initialize this module. */
+gcry_err_code_t
+_gcry_cipher_init (void)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ REGISTER_DEFAULT_CIPHERS;
+
+ return err;
+}
+
+/* Get a list consisting of the IDs of the loaded cipher modules. If
+ LIST is zero, write the number of loaded cipher modules to
+ LIST_LENGTH and return. If LIST is non-zero, the first
+ *LIST_LENGTH algorithm IDs are stored in LIST, which must be of
+ according size. In case there are less cipher modules than
+ *LIST_LENGTH, *LIST_LENGTH is updated to the correct number. */
+gcry_error_t
+gcry_cipher_list (int *list, int *list_length)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ ath_mutex_lock (&ciphers_registered_lock);
+ err = _gcry_module_list (ciphers_registered, list, list_length);
+ ath_mutex_unlock (&ciphers_registered_lock);
+
+ return err;
+}
+
+
+/* Run the selftests for cipher algorithm ALGO with optional reporting
+ function REPORT. */
+gpg_error_t
+_gcry_cipher_selftest (int algo, int extended, selftest_report_func_t report)
+{
+ gcry_module_t module = NULL;
+ cipher_extra_spec_t *extraspec = NULL;
+ gcry_err_code_t ec = 0;
+
+ REGISTER_DEFAULT_CIPHERS;
+
+ ath_mutex_lock (&ciphers_registered_lock);
+ module = _gcry_module_lookup_id (ciphers_registered, algo);
+ if (module && !(module->flags & FLAG_MODULE_DISABLED))
+ extraspec = module->extraspec;
+ ath_mutex_unlock (&ciphers_registered_lock);
+ if (extraspec && extraspec->selftest)
+ ec = extraspec->selftest (algo, extended, report);
+ else
+ {
+ ec = GPG_ERR_CIPHER_ALGO;
+ if (report)
+ report ("cipher", algo, "module",
+ module && !(module->flags & FLAG_MODULE_DISABLED)?
+ "no selftest available" :
+ module? "algorithm disabled" : "algorithm not found");
+ }
+
+ if (module)
+ {
+ ath_mutex_lock (&ciphers_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&ciphers_registered_lock);
+ }
+ return gpg_error (ec);
+}
diff --git a/grub-core/lib/libgcrypt/cipher/crc.c b/grub-core/lib/libgcrypt/cipher/crc.c
new file mode 100644
index 0000000..28454f8
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/crc.c
@@ -0,0 +1,793 @@
+/* crc.c - Cyclic redundancy checks.
+ * Copyright (C) 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "g10lib.h"
+#include "cipher.h"
+
+#include "bithelp.h"
+#include "bufhelp.h"
+
+
+typedef struct
+{
+ u32 CRC;
+ byte buf[4];
+}
+CRC_CONTEXT;
+
+
+/*
+ * Code generated by universal_crc by Danjel McGougan
+ *
+ * CRC parameters used:
+ * bits: 32
+ * poly: 0x04c11db7
+ * init: 0xffffffff
+ * xor: 0xffffffff
+ * reverse: true
+ * non-direct: false
+ *
+ * CRC of the string "123456789" is 0xcbf43926
+ */
+
+static const u32 crc32_table[1024] = {
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
+ 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
+ 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
+ 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+ 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
+ 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
+ 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
+ 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
+ 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
+ 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
+ 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
+ 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
+ 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
+ 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
+ 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+ 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
+ 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
+ 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
+ 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
+ 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
+ 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
+ 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+ 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
+ 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
+ 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
+ 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
+ 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
+ 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
+ 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
+ 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
+ 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
+ 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
+ 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+ 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
+ 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
+ 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
+ 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
+ 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
+ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
+ 0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3,
+ 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7,
+ 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb,
+ 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, 0x87981ccf,
+ 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192,
+ 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496,
+ 0x821b9859, 0x9b00a918, 0xb02dfadb, 0xa936cb9a,
+ 0xe6775d5d, 0xff6c6c1c, 0xd4413fdf, 0xcd5a0e9e,
+ 0x958424a2, 0x8c9f15e3, 0xa7b24620, 0xbea97761,
+ 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265,
+ 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69,
+ 0x39316bae, 0x202a5aef, 0x0b07092c, 0x121c386d,
+ 0xdf4636f3, 0xc65d07b2, 0xed705471, 0xf46b6530,
+ 0xbb2af3f7, 0xa231c2b6, 0x891c9175, 0x9007a034,
+ 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38,
+ 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c,
+ 0xf0794f05, 0xe9627e44, 0xc24f2d87, 0xdb541cc6,
+ 0x94158a01, 0x8d0ebb40, 0xa623e883, 0xbf38d9c2,
+ 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, 0x138d96ce,
+ 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca,
+ 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97,
+ 0xded79850, 0xc7cca911, 0xece1fad2, 0xf5facb93,
+ 0x7262d75c, 0x6b79e61d, 0x4054b5de, 0x594f849f,
+ 0x160e1258, 0x0f152319, 0x243870da, 0x3d23419b,
+ 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864,
+ 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60,
+ 0xad24e1af, 0xb43fd0ee, 0x9f12832d, 0x8609b26c,
+ 0xc94824ab, 0xd05315ea, 0xfb7e4629, 0xe2657768,
+ 0x2f3f79f6, 0x362448b7, 0x1d091b74, 0x04122a35,
+ 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31,
+ 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d,
+ 0x838a36fa, 0x9a9107bb, 0xb1bc5478, 0xa8a76539,
+ 0x3b83984b, 0x2298a90a, 0x09b5fac9, 0x10aecb88,
+ 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, 0x74c20e8c,
+ 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180,
+ 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484,
+ 0x71418a1a, 0x685abb5b, 0x4377e898, 0x5a6cd9d9,
+ 0x152d4f1e, 0x0c367e5f, 0x271b2d9c, 0x3e001cdd,
+ 0xb9980012, 0xa0833153, 0x8bae6290, 0x92b553d1,
+ 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5,
+ 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a,
+ 0xca6b79ed, 0xd37048ac, 0xf85d1b6f, 0xe1462a2e,
+ 0x66de36e1, 0x7fc507a0, 0x54e85463, 0x4df36522,
+ 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, 0x299fa026,
+ 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b,
+ 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f,
+ 0x2c1c24b0, 0x350715f1, 0x1e2a4632, 0x07317773,
+ 0x4870e1b4, 0x516bd0f5, 0x7a468336, 0x635db277,
+ 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, 0xe0d7848d,
+ 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189,
+ 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85,
+ 0x674f9842, 0x7e54a903, 0x5579fac0, 0x4c62cb81,
+ 0x8138c51f, 0x9823f45e, 0xb30ea79d, 0xaa1596dc,
+ 0xe554001b, 0xfc4f315a, 0xd7626299, 0xce7953d8,
+ 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4,
+ 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0,
+ 0x5e7ef3ec, 0x4765c2ad, 0x6c48916e, 0x7553a02f,
+ 0x3a1236e8, 0x230907a9, 0x0824546a, 0x113f652b,
+ 0x96a779e4, 0x8fbc48a5, 0xa4911b66, 0xbd8a2a27,
+ 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23,
+ 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e,
+ 0x70d024b9, 0x69cb15f8, 0x42e6463b, 0x5bfd777a,
+ 0xdc656bb5, 0xc57e5af4, 0xee530937, 0xf7483876,
+ 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, 0x9324fd72,
+ 0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59,
+ 0x0709a8dc, 0x06cbc2eb, 0x048d7cb2, 0x054f1685,
+ 0x0e1351b8, 0x0fd13b8f, 0x0d9785d6, 0x0c55efe1,
+ 0x091af964, 0x08d89353, 0x0a9e2d0a, 0x0b5c473d,
+ 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29,
+ 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5,
+ 0x1235f2c8, 0x13f798ff, 0x11b126a6, 0x10734c91,
+ 0x153c5a14, 0x14fe3023, 0x16b88e7a, 0x177ae44d,
+ 0x384d46e0, 0x398f2cd7, 0x3bc9928e, 0x3a0bf8b9,
+ 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065,
+ 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901,
+ 0x3157bf84, 0x3095d5b3, 0x32d36bea, 0x331101dd,
+ 0x246be590, 0x25a98fa7, 0x27ef31fe, 0x262d5bc9,
+ 0x23624d4c, 0x22a0277b, 0x20e69922, 0x2124f315,
+ 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71,
+ 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad,
+ 0x709a8dc0, 0x7158e7f7, 0x731e59ae, 0x72dc3399,
+ 0x7793251c, 0x76514f2b, 0x7417f172, 0x75d59b45,
+ 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, 0x7ccf6221,
+ 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd,
+ 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9,
+ 0x6bb5866c, 0x6a77ec5b, 0x68315202, 0x69f33835,
+ 0x62af7f08, 0x636d153f, 0x612bab66, 0x60e9c151,
+ 0x65a6d7d4, 0x6464bde3, 0x662203ba, 0x67e0698d,
+ 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579,
+ 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5,
+ 0x46c49a98, 0x4706f0af, 0x45404ef6, 0x448224c1,
+ 0x41cd3244, 0x400f5873, 0x4249e62a, 0x438b8c1d,
+ 0x54f16850, 0x55330267, 0x5775bc3e, 0x56b7d609,
+ 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5,
+ 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1,
+ 0x5deb9134, 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d,
+ 0xe1351b80, 0xe0f771b7, 0xe2b1cfee, 0xe373a5d9,
+ 0xe63cb35c, 0xe7fed96b, 0xe5b86732, 0xe47a0d05,
+ 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461,
+ 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd,
+ 0xfd13b8f0, 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9,
+ 0xfa1a102c, 0xfbd87a1b, 0xf99ec442, 0xf85cae75,
+ 0xf300e948, 0xf2c2837f, 0xf0843d26, 0xf1465711,
+ 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd,
+ 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339,
+ 0xde71f5bc, 0xdfb39f8b, 0xddf521d2, 0xdc374be5,
+ 0xd76b0cd8, 0xd6a966ef, 0xd4efd8b6, 0xd52db281,
+ 0xd062a404, 0xd1a0ce33, 0xd3e6706a, 0xd2241a5d,
+ 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049,
+ 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895,
+ 0xcb4dafa8, 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1,
+ 0xcc440774, 0xcd866d43, 0xcfc0d31a, 0xce02b92d,
+ 0x91af9640, 0x906dfc77, 0x922b422e, 0x93e92819,
+ 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5,
+ 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1,
+ 0x98b56f24, 0x99770513, 0x9b31bb4a, 0x9af3d17d,
+ 0x8d893530, 0x8c4b5f07, 0x8e0de15e, 0x8fcf8b69,
+ 0x8a809dec, 0x8b42f7db, 0x89044982, 0x88c623b5,
+ 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1,
+ 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d,
+ 0xa9e2d0a0, 0xa820ba97, 0xaa6604ce, 0xaba46ef9,
+ 0xaeeb787c, 0xaf29124b, 0xad6fac12, 0xacadc625,
+ 0xa7f18118, 0xa633eb2f, 0xa4755576, 0xa5b73f41,
+ 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d,
+ 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89,
+ 0xb2cddb0c, 0xb30fb13b, 0xb1490f62, 0xb08b6555,
+ 0xbbd72268, 0xba15485f, 0xb853f606, 0xb9919c31,
+ 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, 0xbe9834ed,
+ 0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee,
+ 0x8f629757, 0x37def032, 0x256b5fdc, 0x9dd738b9,
+ 0xc5b428ef, 0x7d084f8a, 0x6fbde064, 0xd7018701,
+ 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, 0x58631056,
+ 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871,
+ 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26,
+ 0x95ad7f70, 0x2d111815, 0x3fa4b7fb, 0x8718d09e,
+ 0x1acfe827, 0xa2738f42, 0xb0c620ac, 0x087a47c9,
+ 0xa032af3e, 0x188ec85b, 0x0a3b67b5, 0xb28700d0,
+ 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787,
+ 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f,
+ 0xeae41086, 0x525877e3, 0x40edd80d, 0xf851bf68,
+ 0xf02bf8a1, 0x48979fc4, 0x5a22302a, 0xe29e574f,
+ 0x7f496ff6, 0xc7f50893, 0xd540a77d, 0x6dfcc018,
+ 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0,
+ 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7,
+ 0x9b14583d, 0x23a83f58, 0x311d90b6, 0x89a1f7d3,
+ 0x1476cf6a, 0xaccaa80f, 0xbe7f07e1, 0x06c36084,
+ 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, 0x4c15df3c,
+ 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b,
+ 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c,
+ 0x446f98f5, 0xfcd3ff90, 0xee66507e, 0x56da371b,
+ 0x0eb9274d, 0xb6054028, 0xa4b0efc6, 0x1c0c88a3,
+ 0x81dbb01a, 0x3967d77f, 0x2bd27891, 0x936e1ff4,
+ 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed,
+ 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba,
+ 0xfe92dfec, 0x462eb889, 0x549b1767, 0xec277002,
+ 0x71f048bb, 0xc94c2fde, 0xdbf98030, 0x6345e755,
+ 0x6b3fa09c, 0xd383c7f9, 0xc1366817, 0x798a0f72,
+ 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825,
+ 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d,
+ 0x21e91f24, 0x99557841, 0x8be0d7af, 0x335cb0ca,
+ 0xed59b63b, 0x55e5d15e, 0x47507eb0, 0xffec19d5,
+ 0x623b216c, 0xda874609, 0xc832e9e7, 0x708e8e82,
+ 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a,
+ 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d,
+ 0xbd40e1a4, 0x05fc86c1, 0x1749292f, 0xaff54e4a,
+ 0x322276f3, 0x8a9e1196, 0x982bbe78, 0x2097d91d,
+ 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, 0x6a4166a5,
+ 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2,
+ 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb,
+ 0xc2098e52, 0x7ab5e937, 0x680046d9, 0xd0bc21bc,
+ 0x88df31ea, 0x3063568f, 0x22d6f961, 0x9a6a9e04,
+ 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, 0x15080953,
+ 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174,
+ 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623,
+ 0xd8c66675, 0x607a0110, 0x72cfaefe, 0xca73c99b,
+ 0x57a4f122, 0xef189647, 0xfdad39a9, 0x45115ecc,
+ 0x764dee06, 0xcef18963, 0xdc44268d, 0x64f841e8,
+ 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf,
+ 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907,
+ 0x3c9b51be, 0x842736db, 0x96929935, 0x2e2efe50,
+ 0x2654b999, 0x9ee8defc, 0x8c5d7112, 0x34e11677,
+ 0xa9362ece, 0x118a49ab, 0x033fe645, 0xbb838120,
+ 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98,
+ 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf,
+ 0xd67f4138, 0x6ec3265d, 0x7c7689b3, 0xc4caeed6,
+ 0x591dd66f, 0xe1a1b10a, 0xf3141ee4, 0x4ba87981,
+ 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, 0x017ec639,
+ 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e,
+ 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949,
+ 0x090481f0, 0xb1b8e695, 0xa30d497b, 0x1bb12e1e,
+ 0x43d23e48, 0xfb6e592d, 0xe9dbf6c3, 0x516791a6,
+ 0xccb0a91f, 0x740cce7a, 0x66b96194, 0xde0506f1
+};
+
+/* CRC32 */
+
+static inline u32
+crc32_next (u32 crc, byte data)
+{
+ return (crc >> 8) ^ crc32_table[(crc & 0xff) ^ data];
+}
+
+/*
+ * Process 4 bytes in one go
+ */
+static inline u32
+crc32_next4 (u32 crc, u32 data)
+{
+ crc ^= data;
+ crc = crc32_table[(crc & 0xff) + 0x300] ^
+ crc32_table[((crc >> 8) & 0xff) + 0x200] ^
+ crc32_table[((crc >> 16) & 0xff) + 0x100] ^
+ crc32_table[(crc >> 24) & 0xff];
+ return crc;
+}
+
+static void
+crc32_init (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ ctx->CRC = 0 ^ 0xffffffffL;
+}
+
+static void
+crc32_write (void *context, const void *inbuf_arg, size_t inlen)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ const byte *inbuf = inbuf_arg;
+ u32 crc;
+
+ if (!inbuf || !inlen)
+ return;
+
+ crc = ctx->CRC;
+
+ while (inlen >= 16)
+ {
+ inlen -= 16;
+ crc = crc32_next4(crc, buf_get_le32(&inbuf[0]));
+ crc = crc32_next4(crc, buf_get_le32(&inbuf[4]));
+ crc = crc32_next4(crc, buf_get_le32(&inbuf[8]));
+ crc = crc32_next4(crc, buf_get_le32(&inbuf[12]));
+ inbuf += 16;
+ }
+
+ while (inlen >= 4)
+ {
+ inlen -= 4;
+ crc = crc32_next4(crc, buf_get_le32(inbuf));
+ inbuf += 4;
+ }
+
+ while (inlen--)
+ {
+ crc = crc32_next(crc, *inbuf++);
+ }
+
+ ctx->CRC = crc;
+}
+
+static byte *
+crc32_read (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ return ctx->buf;
+}
+
+static void
+crc32_final (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ ctx->CRC ^= 0xffffffffL;
+ buf_put_be32 (ctx->buf, ctx->CRC);
+}
+
+/* CRC32 a'la RFC 1510 */
+/* CRC of the string "123456789" is 0x2dfd2d88 */
+
+static void
+crc32rfc1510_init (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ ctx->CRC = 0;
+}
+
+static void
+crc32rfc1510_final (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ buf_put_be32(ctx->buf, ctx->CRC);
+}
+
+/* CRC24 a'la RFC 2440 */
+/*
+ * Code generated by universal_crc by Danjel McGougan
+ *
+ * CRC parameters used:
+ * bits: 24
+ * poly: 0x864cfb
+ * init: 0xb704ce
+ * xor: 0x000000
+ * reverse: false
+ * non-direct: false
+ *
+ * CRC of the string "123456789" is 0x21cf02
+ */
+
+static const u32 crc24_table[1024] =
+{
+ 0x00000000, 0x00fb4c86, 0x000dd58a, 0x00f6990c,
+ 0x00e1e693, 0x001aaa15, 0x00ec3319, 0x00177f9f,
+ 0x003981a1, 0x00c2cd27, 0x0034542b, 0x00cf18ad,
+ 0x00d86732, 0x00232bb4, 0x00d5b2b8, 0x002efe3e,
+ 0x00894ec5, 0x00720243, 0x00849b4f, 0x007fd7c9,
+ 0x0068a856, 0x0093e4d0, 0x00657ddc, 0x009e315a,
+ 0x00b0cf64, 0x004b83e2, 0x00bd1aee, 0x00465668,
+ 0x005129f7, 0x00aa6571, 0x005cfc7d, 0x00a7b0fb,
+ 0x00e9d10c, 0x00129d8a, 0x00e40486, 0x001f4800,
+ 0x0008379f, 0x00f37b19, 0x0005e215, 0x00feae93,
+ 0x00d050ad, 0x002b1c2b, 0x00dd8527, 0x0026c9a1,
+ 0x0031b63e, 0x00cafab8, 0x003c63b4, 0x00c72f32,
+ 0x00609fc9, 0x009bd34f, 0x006d4a43, 0x009606c5,
+ 0x0081795a, 0x007a35dc, 0x008cacd0, 0x0077e056,
+ 0x00591e68, 0x00a252ee, 0x0054cbe2, 0x00af8764,
+ 0x00b8f8fb, 0x0043b47d, 0x00b52d71, 0x004e61f7,
+ 0x00d2a319, 0x0029ef9f, 0x00df7693, 0x00243a15,
+ 0x0033458a, 0x00c8090c, 0x003e9000, 0x00c5dc86,
+ 0x00eb22b8, 0x00106e3e, 0x00e6f732, 0x001dbbb4,
+ 0x000ac42b, 0x00f188ad, 0x000711a1, 0x00fc5d27,
+ 0x005beddc, 0x00a0a15a, 0x00563856, 0x00ad74d0,
+ 0x00ba0b4f, 0x004147c9, 0x00b7dec5, 0x004c9243,
+ 0x00626c7d, 0x009920fb, 0x006fb9f7, 0x0094f571,
+ 0x00838aee, 0x0078c668, 0x008e5f64, 0x007513e2,
+ 0x003b7215, 0x00c03e93, 0x0036a79f, 0x00cdeb19,
+ 0x00da9486, 0x0021d800, 0x00d7410c, 0x002c0d8a,
+ 0x0002f3b4, 0x00f9bf32, 0x000f263e, 0x00f46ab8,
+ 0x00e31527, 0x001859a1, 0x00eec0ad, 0x00158c2b,
+ 0x00b23cd0, 0x00497056, 0x00bfe95a, 0x0044a5dc,
+ 0x0053da43, 0x00a896c5, 0x005e0fc9, 0x00a5434f,
+ 0x008bbd71, 0x0070f1f7, 0x008668fb, 0x007d247d,
+ 0x006a5be2, 0x00911764, 0x00678e68, 0x009cc2ee,
+ 0x00a44733, 0x005f0bb5, 0x00a992b9, 0x0052de3f,
+ 0x0045a1a0, 0x00beed26, 0x0048742a, 0x00b338ac,
+ 0x009dc692, 0x00668a14, 0x00901318, 0x006b5f9e,
+ 0x007c2001, 0x00876c87, 0x0071f58b, 0x008ab90d,
+ 0x002d09f6, 0x00d64570, 0x0020dc7c, 0x00db90fa,
+ 0x00ccef65, 0x0037a3e3, 0x00c13aef, 0x003a7669,
+ 0x00148857, 0x00efc4d1, 0x00195ddd, 0x00e2115b,
+ 0x00f56ec4, 0x000e2242, 0x00f8bb4e, 0x0003f7c8,
+ 0x004d963f, 0x00b6dab9, 0x004043b5, 0x00bb0f33,
+ 0x00ac70ac, 0x00573c2a, 0x00a1a526, 0x005ae9a0,
+ 0x0074179e, 0x008f5b18, 0x0079c214, 0x00828e92,
+ 0x0095f10d, 0x006ebd8b, 0x00982487, 0x00636801,
+ 0x00c4d8fa, 0x003f947c, 0x00c90d70, 0x003241f6,
+ 0x00253e69, 0x00de72ef, 0x0028ebe3, 0x00d3a765,
+ 0x00fd595b, 0x000615dd, 0x00f08cd1, 0x000bc057,
+ 0x001cbfc8, 0x00e7f34e, 0x00116a42, 0x00ea26c4,
+ 0x0076e42a, 0x008da8ac, 0x007b31a0, 0x00807d26,
+ 0x009702b9, 0x006c4e3f, 0x009ad733, 0x00619bb5,
+ 0x004f658b, 0x00b4290d, 0x0042b001, 0x00b9fc87,
+ 0x00ae8318, 0x0055cf9e, 0x00a35692, 0x00581a14,
+ 0x00ffaaef, 0x0004e669, 0x00f27f65, 0x000933e3,
+ 0x001e4c7c, 0x00e500fa, 0x001399f6, 0x00e8d570,
+ 0x00c62b4e, 0x003d67c8, 0x00cbfec4, 0x0030b242,
+ 0x0027cddd, 0x00dc815b, 0x002a1857, 0x00d154d1,
+ 0x009f3526, 0x006479a0, 0x0092e0ac, 0x0069ac2a,
+ 0x007ed3b5, 0x00859f33, 0x0073063f, 0x00884ab9,
+ 0x00a6b487, 0x005df801, 0x00ab610d, 0x00502d8b,
+ 0x00475214, 0x00bc1e92, 0x004a879e, 0x00b1cb18,
+ 0x00167be3, 0x00ed3765, 0x001bae69, 0x00e0e2ef,
+ 0x00f79d70, 0x000cd1f6, 0x00fa48fa, 0x0001047c,
+ 0x002ffa42, 0x00d4b6c4, 0x00222fc8, 0x00d9634e,
+ 0x00ce1cd1, 0x00355057, 0x00c3c95b, 0x003885dd,
+ 0x00000000, 0x00488f66, 0x00901ecd, 0x00d891ab,
+ 0x00db711c, 0x0093fe7a, 0x004b6fd1, 0x0003e0b7,
+ 0x00b6e338, 0x00fe6c5e, 0x0026fdf5, 0x006e7293,
+ 0x006d9224, 0x00251d42, 0x00fd8ce9, 0x00b5038f,
+ 0x006cc771, 0x00244817, 0x00fcd9bc, 0x00b456da,
+ 0x00b7b66d, 0x00ff390b, 0x0027a8a0, 0x006f27c6,
+ 0x00da2449, 0x0092ab2f, 0x004a3a84, 0x0002b5e2,
+ 0x00015555, 0x0049da33, 0x00914b98, 0x00d9c4fe,
+ 0x00d88ee3, 0x00900185, 0x0048902e, 0x00001f48,
+ 0x0003ffff, 0x004b7099, 0x0093e132, 0x00db6e54,
+ 0x006e6ddb, 0x0026e2bd, 0x00fe7316, 0x00b6fc70,
+ 0x00b51cc7, 0x00fd93a1, 0x0025020a, 0x006d8d6c,
+ 0x00b44992, 0x00fcc6f4, 0x0024575f, 0x006cd839,
+ 0x006f388e, 0x0027b7e8, 0x00ff2643, 0x00b7a925,
+ 0x0002aaaa, 0x004a25cc, 0x0092b467, 0x00da3b01,
+ 0x00d9dbb6, 0x009154d0, 0x0049c57b, 0x00014a1d,
+ 0x004b5141, 0x0003de27, 0x00db4f8c, 0x0093c0ea,
+ 0x0090205d, 0x00d8af3b, 0x00003e90, 0x0048b1f6,
+ 0x00fdb279, 0x00b53d1f, 0x006dacb4, 0x002523d2,
+ 0x0026c365, 0x006e4c03, 0x00b6dda8, 0x00fe52ce,
+ 0x00279630, 0x006f1956, 0x00b788fd, 0x00ff079b,
+ 0x00fce72c, 0x00b4684a, 0x006cf9e1, 0x00247687,
+ 0x00917508, 0x00d9fa6e, 0x00016bc5, 0x0049e4a3,
+ 0x004a0414, 0x00028b72, 0x00da1ad9, 0x009295bf,
+ 0x0093dfa2, 0x00db50c4, 0x0003c16f, 0x004b4e09,
+ 0x0048aebe, 0x000021d8, 0x00d8b073, 0x00903f15,
+ 0x00253c9a, 0x006db3fc, 0x00b52257, 0x00fdad31,
+ 0x00fe4d86, 0x00b6c2e0, 0x006e534b, 0x0026dc2d,
+ 0x00ff18d3, 0x00b797b5, 0x006f061e, 0x00278978,
+ 0x002469cf, 0x006ce6a9, 0x00b47702, 0x00fcf864,
+ 0x0049fbeb, 0x0001748d, 0x00d9e526, 0x00916a40,
+ 0x00928af7, 0x00da0591, 0x0002943a, 0x004a1b5c,
+ 0x0096a282, 0x00de2de4, 0x0006bc4f, 0x004e3329,
+ 0x004dd39e, 0x00055cf8, 0x00ddcd53, 0x00954235,
+ 0x002041ba, 0x0068cedc, 0x00b05f77, 0x00f8d011,
+ 0x00fb30a6, 0x00b3bfc0, 0x006b2e6b, 0x0023a10d,
+ 0x00fa65f3, 0x00b2ea95, 0x006a7b3e, 0x0022f458,
+ 0x002114ef, 0x00699b89, 0x00b10a22, 0x00f98544,
+ 0x004c86cb, 0x000409ad, 0x00dc9806, 0x00941760,
+ 0x0097f7d7, 0x00df78b1, 0x0007e91a, 0x004f667c,
+ 0x004e2c61, 0x0006a307, 0x00de32ac, 0x0096bdca,
+ 0x00955d7d, 0x00ddd21b, 0x000543b0, 0x004dccd6,
+ 0x00f8cf59, 0x00b0403f, 0x0068d194, 0x00205ef2,
+ 0x0023be45, 0x006b3123, 0x00b3a088, 0x00fb2fee,
+ 0x0022eb10, 0x006a6476, 0x00b2f5dd, 0x00fa7abb,
+ 0x00f99a0c, 0x00b1156a, 0x006984c1, 0x00210ba7,
+ 0x00940828, 0x00dc874e, 0x000416e5, 0x004c9983,
+ 0x004f7934, 0x0007f652, 0x00df67f9, 0x0097e89f,
+ 0x00ddf3c3, 0x00957ca5, 0x004ded0e, 0x00056268,
+ 0x000682df, 0x004e0db9, 0x00969c12, 0x00de1374,
+ 0x006b10fb, 0x00239f9d, 0x00fb0e36, 0x00b38150,
+ 0x00b061e7, 0x00f8ee81, 0x00207f2a, 0x0068f04c,
+ 0x00b134b2, 0x00f9bbd4, 0x00212a7f, 0x0069a519,
+ 0x006a45ae, 0x0022cac8, 0x00fa5b63, 0x00b2d405,
+ 0x0007d78a, 0x004f58ec, 0x0097c947, 0x00df4621,
+ 0x00dca696, 0x009429f0, 0x004cb85b, 0x0004373d,
+ 0x00057d20, 0x004df246, 0x009563ed, 0x00ddec8b,
+ 0x00de0c3c, 0x0096835a, 0x004e12f1, 0x00069d97,
+ 0x00b39e18, 0x00fb117e, 0x002380d5, 0x006b0fb3,
+ 0x0068ef04, 0x00206062, 0x00f8f1c9, 0x00b07eaf,
+ 0x0069ba51, 0x00213537, 0x00f9a49c, 0x00b12bfa,
+ 0x00b2cb4d, 0x00fa442b, 0x0022d580, 0x006a5ae6,
+ 0x00df5969, 0x0097d60f, 0x004f47a4, 0x0007c8c2,
+ 0x00042875, 0x004ca713, 0x009436b8, 0x00dcb9de,
+ 0x00000000, 0x00d70983, 0x00555f80, 0x00825603,
+ 0x0051f286, 0x0086fb05, 0x0004ad06, 0x00d3a485,
+ 0x0059a88b, 0x008ea108, 0x000cf70b, 0x00dbfe88,
+ 0x00085a0d, 0x00df538e, 0x005d058d, 0x008a0c0e,
+ 0x00491c91, 0x009e1512, 0x001c4311, 0x00cb4a92,
+ 0x0018ee17, 0x00cfe794, 0x004db197, 0x009ab814,
+ 0x0010b41a, 0x00c7bd99, 0x0045eb9a, 0x0092e219,
+ 0x0041469c, 0x00964f1f, 0x0014191c, 0x00c3109f,
+ 0x006974a4, 0x00be7d27, 0x003c2b24, 0x00eb22a7,
+ 0x00388622, 0x00ef8fa1, 0x006dd9a2, 0x00bad021,
+ 0x0030dc2f, 0x00e7d5ac, 0x006583af, 0x00b28a2c,
+ 0x00612ea9, 0x00b6272a, 0x00347129, 0x00e378aa,
+ 0x00206835, 0x00f761b6, 0x007537b5, 0x00a23e36,
+ 0x00719ab3, 0x00a69330, 0x0024c533, 0x00f3ccb0,
+ 0x0079c0be, 0x00aec93d, 0x002c9f3e, 0x00fb96bd,
+ 0x00283238, 0x00ff3bbb, 0x007d6db8, 0x00aa643b,
+ 0x0029a4ce, 0x00fead4d, 0x007cfb4e, 0x00abf2cd,
+ 0x00785648, 0x00af5fcb, 0x002d09c8, 0x00fa004b,
+ 0x00700c45, 0x00a705c6, 0x002553c5, 0x00f25a46,
+ 0x0021fec3, 0x00f6f740, 0x0074a143, 0x00a3a8c0,
+ 0x0060b85f, 0x00b7b1dc, 0x0035e7df, 0x00e2ee5c,
+ 0x00314ad9, 0x00e6435a, 0x00641559, 0x00b31cda,
+ 0x003910d4, 0x00ee1957, 0x006c4f54, 0x00bb46d7,
+ 0x0068e252, 0x00bfebd1, 0x003dbdd2, 0x00eab451,
+ 0x0040d06a, 0x0097d9e9, 0x00158fea, 0x00c28669,
+ 0x001122ec, 0x00c62b6f, 0x00447d6c, 0x009374ef,
+ 0x001978e1, 0x00ce7162, 0x004c2761, 0x009b2ee2,
+ 0x00488a67, 0x009f83e4, 0x001dd5e7, 0x00cadc64,
+ 0x0009ccfb, 0x00dec578, 0x005c937b, 0x008b9af8,
+ 0x00583e7d, 0x008f37fe, 0x000d61fd, 0x00da687e,
+ 0x00506470, 0x00876df3, 0x00053bf0, 0x00d23273,
+ 0x000196f6, 0x00d69f75, 0x0054c976, 0x0083c0f5,
+ 0x00a9041b, 0x007e0d98, 0x00fc5b9b, 0x002b5218,
+ 0x00f8f69d, 0x002fff1e, 0x00ada91d, 0x007aa09e,
+ 0x00f0ac90, 0x0027a513, 0x00a5f310, 0x0072fa93,
+ 0x00a15e16, 0x00765795, 0x00f40196, 0x00230815,
+ 0x00e0188a, 0x00371109, 0x00b5470a, 0x00624e89,
+ 0x00b1ea0c, 0x0066e38f, 0x00e4b58c, 0x0033bc0f,
+ 0x00b9b001, 0x006eb982, 0x00ecef81, 0x003be602,
+ 0x00e84287, 0x003f4b04, 0x00bd1d07, 0x006a1484,
+ 0x00c070bf, 0x0017793c, 0x00952f3f, 0x004226bc,
+ 0x00918239, 0x00468bba, 0x00c4ddb9, 0x0013d43a,
+ 0x0099d834, 0x004ed1b7, 0x00cc87b4, 0x001b8e37,
+ 0x00c82ab2, 0x001f2331, 0x009d7532, 0x004a7cb1,
+ 0x00896c2e, 0x005e65ad, 0x00dc33ae, 0x000b3a2d,
+ 0x00d89ea8, 0x000f972b, 0x008dc128, 0x005ac8ab,
+ 0x00d0c4a5, 0x0007cd26, 0x00859b25, 0x005292a6,
+ 0x00813623, 0x00563fa0, 0x00d469a3, 0x00036020,
+ 0x0080a0d5, 0x0057a956, 0x00d5ff55, 0x0002f6d6,
+ 0x00d15253, 0x00065bd0, 0x00840dd3, 0x00530450,
+ 0x00d9085e, 0x000e01dd, 0x008c57de, 0x005b5e5d,
+ 0x0088fad8, 0x005ff35b, 0x00dda558, 0x000aacdb,
+ 0x00c9bc44, 0x001eb5c7, 0x009ce3c4, 0x004bea47,
+ 0x00984ec2, 0x004f4741, 0x00cd1142, 0x001a18c1,
+ 0x009014cf, 0x00471d4c, 0x00c54b4f, 0x001242cc,
+ 0x00c1e649, 0x0016efca, 0x0094b9c9, 0x0043b04a,
+ 0x00e9d471, 0x003eddf2, 0x00bc8bf1, 0x006b8272,
+ 0x00b826f7, 0x006f2f74, 0x00ed7977, 0x003a70f4,
+ 0x00b07cfa, 0x00677579, 0x00e5237a, 0x00322af9,
+ 0x00e18e7c, 0x003687ff, 0x00b4d1fc, 0x0063d87f,
+ 0x00a0c8e0, 0x0077c163, 0x00f59760, 0x00229ee3,
+ 0x00f13a66, 0x002633e5, 0x00a465e6, 0x00736c65,
+ 0x00f9606b, 0x002e69e8, 0x00ac3feb, 0x007b3668,
+ 0x00a892ed, 0x007f9b6e, 0x00fdcd6d, 0x002ac4ee,
+ 0x00000000, 0x00520936, 0x00a4126c, 0x00f61b5a,
+ 0x004825d8, 0x001a2cee, 0x00ec37b4, 0x00be3e82,
+ 0x006b0636, 0x00390f00, 0x00cf145a, 0x009d1d6c,
+ 0x002323ee, 0x00712ad8, 0x00873182, 0x00d538b4,
+ 0x00d60c6c, 0x0084055a, 0x00721e00, 0x00201736,
+ 0x009e29b4, 0x00cc2082, 0x003a3bd8, 0x006832ee,
+ 0x00bd0a5a, 0x00ef036c, 0x00191836, 0x004b1100,
+ 0x00f52f82, 0x00a726b4, 0x00513dee, 0x000334d8,
+ 0x00ac19d8, 0x00fe10ee, 0x00080bb4, 0x005a0282,
+ 0x00e43c00, 0x00b63536, 0x00402e6c, 0x0012275a,
+ 0x00c71fee, 0x009516d8, 0x00630d82, 0x003104b4,
+ 0x008f3a36, 0x00dd3300, 0x002b285a, 0x0079216c,
+ 0x007a15b4, 0x00281c82, 0x00de07d8, 0x008c0eee,
+ 0x0032306c, 0x0060395a, 0x00962200, 0x00c42b36,
+ 0x00111382, 0x00431ab4, 0x00b501ee, 0x00e708d8,
+ 0x0059365a, 0x000b3f6c, 0x00fd2436, 0x00af2d00,
+ 0x00a37f36, 0x00f17600, 0x00076d5a, 0x0055646c,
+ 0x00eb5aee, 0x00b953d8, 0x004f4882, 0x001d41b4,
+ 0x00c87900, 0x009a7036, 0x006c6b6c, 0x003e625a,
+ 0x00805cd8, 0x00d255ee, 0x00244eb4, 0x00764782,
+ 0x0075735a, 0x00277a6c, 0x00d16136, 0x00836800,
+ 0x003d5682, 0x006f5fb4, 0x009944ee, 0x00cb4dd8,
+ 0x001e756c, 0x004c7c5a, 0x00ba6700, 0x00e86e36,
+ 0x005650b4, 0x00045982, 0x00f242d8, 0x00a04bee,
+ 0x000f66ee, 0x005d6fd8, 0x00ab7482, 0x00f97db4,
+ 0x00474336, 0x00154a00, 0x00e3515a, 0x00b1586c,
+ 0x006460d8, 0x003669ee, 0x00c072b4, 0x00927b82,
+ 0x002c4500, 0x007e4c36, 0x0088576c, 0x00da5e5a,
+ 0x00d96a82, 0x008b63b4, 0x007d78ee, 0x002f71d8,
+ 0x00914f5a, 0x00c3466c, 0x00355d36, 0x00675400,
+ 0x00b26cb4, 0x00e06582, 0x00167ed8, 0x004477ee,
+ 0x00fa496c, 0x00a8405a, 0x005e5b00, 0x000c5236,
+ 0x0046ff6c, 0x0014f65a, 0x00e2ed00, 0x00b0e436,
+ 0x000edab4, 0x005cd382, 0x00aac8d8, 0x00f8c1ee,
+ 0x002df95a, 0x007ff06c, 0x0089eb36, 0x00dbe200,
+ 0x0065dc82, 0x0037d5b4, 0x00c1ceee, 0x0093c7d8,
+ 0x0090f300, 0x00c2fa36, 0x0034e16c, 0x0066e85a,
+ 0x00d8d6d8, 0x008adfee, 0x007cc4b4, 0x002ecd82,
+ 0x00fbf536, 0x00a9fc00, 0x005fe75a, 0x000dee6c,
+ 0x00b3d0ee, 0x00e1d9d8, 0x0017c282, 0x0045cbb4,
+ 0x00eae6b4, 0x00b8ef82, 0x004ef4d8, 0x001cfdee,
+ 0x00a2c36c, 0x00f0ca5a, 0x0006d100, 0x0054d836,
+ 0x0081e082, 0x00d3e9b4, 0x0025f2ee, 0x0077fbd8,
+ 0x00c9c55a, 0x009bcc6c, 0x006dd736, 0x003fde00,
+ 0x003cead8, 0x006ee3ee, 0x0098f8b4, 0x00caf182,
+ 0x0074cf00, 0x0026c636, 0x00d0dd6c, 0x0082d45a,
+ 0x0057ecee, 0x0005e5d8, 0x00f3fe82, 0x00a1f7b4,
+ 0x001fc936, 0x004dc000, 0x00bbdb5a, 0x00e9d26c,
+ 0x00e5805a, 0x00b7896c, 0x00419236, 0x00139b00,
+ 0x00ada582, 0x00ffacb4, 0x0009b7ee, 0x005bbed8,
+ 0x008e866c, 0x00dc8f5a, 0x002a9400, 0x00789d36,
+ 0x00c6a3b4, 0x0094aa82, 0x0062b1d8, 0x0030b8ee,
+ 0x00338c36, 0x00618500, 0x00979e5a, 0x00c5976c,
+ 0x007ba9ee, 0x0029a0d8, 0x00dfbb82, 0x008db2b4,
+ 0x00588a00, 0x000a8336, 0x00fc986c, 0x00ae915a,
+ 0x0010afd8, 0x0042a6ee, 0x00b4bdb4, 0x00e6b482,
+ 0x00499982, 0x001b90b4, 0x00ed8bee, 0x00bf82d8,
+ 0x0001bc5a, 0x0053b56c, 0x00a5ae36, 0x00f7a700,
+ 0x00229fb4, 0x00709682, 0x00868dd8, 0x00d484ee,
+ 0x006aba6c, 0x0038b35a, 0x00cea800, 0x009ca136,
+ 0x009f95ee, 0x00cd9cd8, 0x003b8782, 0x00698eb4,
+ 0x00d7b036, 0x0085b900, 0x0073a25a, 0x0021ab6c,
+ 0x00f493d8, 0x00a69aee, 0x005081b4, 0x00028882,
+ 0x00bcb600, 0x00eebf36, 0x0018a46c, 0x004aad5a
+};
+
+static inline
+u32 crc24_init (void)
+{
+ return 0xce04b7;
+}
+
+static inline
+u32 crc24_next (u32 crc, byte data)
+{
+ return (crc >> 8) ^ crc24_table[(crc & 0xff) ^ data];
+}
+
+/*
+ * Process 4 bytes in one go
+ */
+static inline
+u32 crc24_next4 (u32 crc, u32 data)
+{
+ crc ^= data;
+ crc = crc24_table[(crc & 0xff) + 0x300] ^
+ crc24_table[((crc >> 8) & 0xff) + 0x200] ^
+ crc24_table[((crc >> 16) & 0xff) + 0x100] ^
+ crc24_table[(crc >> 24) & 0xff];
+ return crc;
+}
+
+static inline
+u32 crc24_final (u32 crc)
+{
+ return crc & 0xffffff;
+}
+
+static void
+crc24rfc2440_init (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ ctx->CRC = crc24_init();
+}
+
+static void
+crc24rfc2440_write (void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ u32 crc;
+
+ if (!inbuf || !inlen)
+ return;
+
+ crc = ctx->CRC;
+
+ while (inlen >= 16)
+ {
+ inlen -= 16;
+ crc = crc24_next4(crc, buf_get_le32(&inbuf[0]));
+ crc = crc24_next4(crc, buf_get_le32(&inbuf[4]));
+ crc = crc24_next4(crc, buf_get_le32(&inbuf[8]));
+ crc = crc24_next4(crc, buf_get_le32(&inbuf[12]));
+ inbuf += 16;
+ }
+
+ while (inlen >= 4)
+ {
+ inlen -= 4;
+ crc = crc24_next4(crc, buf_get_le32(inbuf));
+ inbuf += 4;
+ }
+
+ while (inlen--)
+ {
+ crc = crc24_next(crc, *inbuf++);
+ }
+
+ ctx->CRC = crc;
+}
+
+static void
+crc24rfc2440_final (void *context)
+{
+ CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
+ ctx->CRC = crc24_final(ctx->CRC);
+ buf_put_le32 (ctx->buf, ctx->CRC);
+}
+
+gcry_md_spec_t _gcry_digest_spec_crc32 =
+ {
+ "CRC32", NULL, 0, NULL, 4,
+ crc32_init, crc32_write, crc32_final, crc32_read,
+ sizeof (CRC_CONTEXT)
+ };
+
+gcry_md_spec_t _gcry_digest_spec_crc32_rfc1510 =
+ {
+ "CRC32RFC1510", NULL, 0, NULL, 4,
+ crc32rfc1510_init, crc32_write,
+ crc32rfc1510_final, crc32_read,
+ sizeof (CRC_CONTEXT)
+ };
+
+gcry_md_spec_t _gcry_digest_spec_crc24_rfc2440 =
+ {
+ "CRC24RFC2440", NULL, 0, NULL, 3,
+ crc24rfc2440_init, crc24rfc2440_write,
+ crc24rfc2440_final, crc32_read,
+ sizeof (CRC_CONTEXT)
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/des.c b/grub-core/lib/libgcrypt/cipher/des.c
new file mode 100644
index 0000000..96b06ae
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/des.c
@@ -0,0 +1,1196 @@
+/* des.c - DES and Triple-DES encryption/decryption Algorithm
+ * Copyright (C) 1998, 1999, 2001, 2002, 2003,
+ * 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * For a description of triple encryption, see:
+ * Bruce Schneier: Applied Cryptography. Second Edition.
+ * John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff.
+ * This implementation is according to the definition of DES in FIPS
+ * PUB 46-2 from December 1993.
+ */
+
+
+/*
+ * Written by Michael Roth <mroth@nessie.de>, September 1998
+ */
+
+
+/*
+ * U S A G E
+ * ===========
+ *
+ * For DES or Triple-DES encryption/decryption you must initialize a proper
+ * encryption context with a key.
+ *
+ * A DES key is 64bit wide but only 56bits of the key are used. The remaining
+ * bits are parity bits and they will _not_ checked in this implementation, but
+ * simply ignored.
+ *
+ * For Triple-DES you could use either two 64bit keys or three 64bit keys.
+ * The parity bits will _not_ checked, too.
+ *
+ * After initializing a context with a key you could use this context to
+ * encrypt or decrypt data in 64bit blocks in Electronic Codebook Mode.
+ *
+ * (In the examples below the slashes at the beginning and ending of comments
+ * are omited.)
+ *
+ * DES Example
+ * -----------
+ * unsigned char key[8];
+ * unsigned char plaintext[8];
+ * unsigned char ciphertext[8];
+ * unsigned char recoverd[8];
+ * des_ctx context;
+ *
+ * * Fill 'key' and 'plaintext' with some data *
+ * ....
+ *
+ * * Set up the DES encryption context *
+ * des_setkey(context, key);
+ *
+ * * Encrypt the plaintext *
+ * des_ecb_encrypt(context, plaintext, ciphertext);
+ *
+ * * To recover the orginal plaintext from ciphertext use: *
+ * des_ecb_decrypt(context, ciphertext, recoverd);
+ *
+ *
+ * Triple-DES Example
+ * ------------------
+ * unsigned char key1[8];
+ * unsigned char key2[8];
+ * unsigned char key3[8];
+ * unsigned char plaintext[8];
+ * unsigned char ciphertext[8];
+ * unsigned char recoverd[8];
+ * tripledes_ctx context;
+ *
+ * * If you would like to use two 64bit keys, fill 'key1' and'key2'
+ * then setup the encryption context: *
+ * tripledes_set2keys(context, key1, key2);
+ *
+ * * To use three 64bit keys with Triple-DES use: *
+ * tripledes_set3keys(context, key1, key2, key3);
+ *
+ * * Encrypting plaintext with Triple-DES *
+ * tripledes_ecb_encrypt(context, plaintext, ciphertext);
+ *
+ * * Decrypting ciphertext to recover the plaintext with Triple-DES *
+ * tripledes_ecb_decrypt(context, ciphertext, recoverd);
+ *
+ *
+ * Selftest
+ * --------
+ * char *error_msg;
+ *
+ * * To perform a selftest of this DES/Triple-DES implementation use the
+ * function selftest(). It will return an error string if there are
+ * some problems with this library. *
+ *
+ * if ( (error_msg = selftest()) )
+ * {
+ * fprintf(stderr, "An error in the DES/Triple-DES implementation occurred: %s\n", error_msg);
+ * abort();
+ * }
+ */
+
+
+#include <config.h>
+#include <stdio.h>
+#include <string.h> /* memcpy, memcmp */
+#include "types.h" /* for byte and u32 typedefs */
+#include "g10lib.h"
+#include "cipher.h"
+
+#if defined(__GNUC__) && defined(__GNU_LIBRARY__)
+#define working_memcmp memcmp
+#else
+/*
+ * According to the SunOS man page, memcmp returns indeterminate sign
+ * depending on whether characters are signed or not.
+ */
+static int
+working_memcmp( const char *a, const char *b, size_t n )
+{
+ for( ; n; n--, a++, b++ )
+ if( *a != *b )
+ return (int)(*(byte*)a) - (int)(*(byte*)b);
+ return 0;
+}
+#endif
+
+/*
+ * Encryption/Decryption context of DES
+ */
+typedef struct _des_ctx
+ {
+ u32 encrypt_subkeys[32];
+ u32 decrypt_subkeys[32];
+ }
+des_ctx[1];
+
+/*
+ * Encryption/Decryption context of Triple-DES
+ */
+typedef struct _tripledes_ctx
+ {
+ u32 encrypt_subkeys[96];
+ u32 decrypt_subkeys[96];
+ struct {
+ int no_weak_key;
+ } flags;
+ }
+tripledes_ctx[1];
+
+static void des_key_schedule (const byte *, u32 *);
+static int des_setkey (struct _des_ctx *, const byte *);
+static int des_ecb_crypt (struct _des_ctx *, const byte *, byte *, int);
+static int tripledes_set2keys (struct _tripledes_ctx *,
+ const byte *, const byte *);
+static int tripledes_set3keys (struct _tripledes_ctx *,
+ const byte *, const byte *, const byte *);
+static int tripledes_ecb_crypt (struct _tripledes_ctx *,
+ const byte *, byte *, int);
+static int is_weak_key ( const byte *key );
+static const char *selftest (void);
+
+static int initialized;
+
+
+
+
+/*
+ * The s-box values are permuted according to the 'primitive function P'
+ * and are rotated one bit to the left.
+ */
+static u32 sbox1[64] =
+{
+ 0x01010400, 0x00000000, 0x00010000, 0x01010404, 0x01010004, 0x00010404, 0x00000004, 0x00010000,
+ 0x00000400, 0x01010400, 0x01010404, 0x00000400, 0x01000404, 0x01010004, 0x01000000, 0x00000004,
+ 0x00000404, 0x01000400, 0x01000400, 0x00010400, 0x00010400, 0x01010000, 0x01010000, 0x01000404,
+ 0x00010004, 0x01000004, 0x01000004, 0x00010004, 0x00000000, 0x00000404, 0x00010404, 0x01000000,
+ 0x00010000, 0x01010404, 0x00000004, 0x01010000, 0x01010400, 0x01000000, 0x01000000, 0x00000400,
+ 0x01010004, 0x00010000, 0x00010400, 0x01000004, 0x00000400, 0x00000004, 0x01000404, 0x00010404,
+ 0x01010404, 0x00010004, 0x01010000, 0x01000404, 0x01000004, 0x00000404, 0x00010404, 0x01010400,
+ 0x00000404, 0x01000400, 0x01000400, 0x00000000, 0x00010004, 0x00010400, 0x00000000, 0x01010004
+};
+
+static u32 sbox2[64] =
+{
+ 0x80108020, 0x80008000, 0x00008000, 0x00108020, 0x00100000, 0x00000020, 0x80100020, 0x80008020,
+ 0x80000020, 0x80108020, 0x80108000, 0x80000000, 0x80008000, 0x00100000, 0x00000020, 0x80100020,
+ 0x00108000, 0x00100020, 0x80008020, 0x00000000, 0x80000000, 0x00008000, 0x00108020, 0x80100000,
+ 0x00100020, 0x80000020, 0x00000000, 0x00108000, 0x00008020, 0x80108000, 0x80100000, 0x00008020,
+ 0x00000000, 0x00108020, 0x80100020, 0x00100000, 0x80008020, 0x80100000, 0x80108000, 0x00008000,
+ 0x80100000, 0x80008000, 0x00000020, 0x80108020, 0x00108020, 0x00000020, 0x00008000, 0x80000000,
+ 0x00008020, 0x80108000, 0x00100000, 0x80000020, 0x00100020, 0x80008020, 0x80000020, 0x00100020,
+ 0x00108000, 0x00000000, 0x80008000, 0x00008020, 0x80000000, 0x80100020, 0x80108020, 0x00108000
+};
+
+static u32 sbox3[64] =
+{
+ 0x00000208, 0x08020200, 0x00000000, 0x08020008, 0x08000200, 0x00000000, 0x00020208, 0x08000200,
+ 0x00020008, 0x08000008, 0x08000008, 0x00020000, 0x08020208, 0x00020008, 0x08020000, 0x00000208,
+ 0x08000000, 0x00000008, 0x08020200, 0x00000200, 0x00020200, 0x08020000, 0x08020008, 0x00020208,
+ 0x08000208, 0x00020200, 0x00020000, 0x08000208, 0x00000008, 0x08020208, 0x00000200, 0x08000000,
+ 0x08020200, 0x08000000, 0x00020008, 0x00000208, 0x00020000, 0x08020200, 0x08000200, 0x00000000,
+ 0x00000200, 0x00020008, 0x08020208, 0x08000200, 0x08000008, 0x00000200, 0x00000000, 0x08020008,
+ 0x08000208, 0x00020000, 0x08000000, 0x08020208, 0x00000008, 0x00020208, 0x00020200, 0x08000008,
+ 0x08020000, 0x08000208, 0x00000208, 0x08020000, 0x00020208, 0x00000008, 0x08020008, 0x00020200
+};
+
+static u32 sbox4[64] =
+{
+ 0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802080, 0x00800081, 0x00800001, 0x00002001,
+ 0x00000000, 0x00802000, 0x00802000, 0x00802081, 0x00000081, 0x00000000, 0x00800080, 0x00800001,
+ 0x00000001, 0x00002000, 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002001, 0x00002080,
+ 0x00800081, 0x00000001, 0x00002080, 0x00800080, 0x00002000, 0x00802080, 0x00802081, 0x00000081,
+ 0x00800080, 0x00800001, 0x00802000, 0x00802081, 0x00000081, 0x00000000, 0x00000000, 0x00802000,
+ 0x00002080, 0x00800080, 0x00800081, 0x00000001, 0x00802001, 0x00002081, 0x00002081, 0x00000080,
+ 0x00802081, 0x00000081, 0x00000001, 0x00002000, 0x00800001, 0x00002001, 0x00802080, 0x00800081,
+ 0x00002001, 0x00002080, 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002000, 0x00802080
+};
+
+static u32 sbox5[64] =
+{
+ 0x00000100, 0x02080100, 0x02080000, 0x42000100, 0x00080000, 0x00000100, 0x40000000, 0x02080000,
+ 0x40080100, 0x00080000, 0x02000100, 0x40080100, 0x42000100, 0x42080000, 0x00080100, 0x40000000,
+ 0x02000000, 0x40080000, 0x40080000, 0x00000000, 0x40000100, 0x42080100, 0x42080100, 0x02000100,
+ 0x42080000, 0x40000100, 0x00000000, 0x42000000, 0x02080100, 0x02000000, 0x42000000, 0x00080100,
+ 0x00080000, 0x42000100, 0x00000100, 0x02000000, 0x40000000, 0x02080000, 0x42000100, 0x40080100,
+ 0x02000100, 0x40000000, 0x42080000, 0x02080100, 0x40080100, 0x00000100, 0x02000000, 0x42080000,
+ 0x42080100, 0x00080100, 0x42000000, 0x42080100, 0x02080000, 0x00000000, 0x40080000, 0x42000000,
+ 0x00080100, 0x02000100, 0x40000100, 0x00080000, 0x00000000, 0x40080000, 0x02080100, 0x40000100
+};
+
+static u32 sbox6[64] =
+{
+ 0x20000010, 0x20400000, 0x00004000, 0x20404010, 0x20400000, 0x00000010, 0x20404010, 0x00400000,
+ 0x20004000, 0x00404010, 0x00400000, 0x20000010, 0x00400010, 0x20004000, 0x20000000, 0x00004010,
+ 0x00000000, 0x00400010, 0x20004010, 0x00004000, 0x00404000, 0x20004010, 0x00000010, 0x20400010,
+ 0x20400010, 0x00000000, 0x00404010, 0x20404000, 0x00004010, 0x00404000, 0x20404000, 0x20000000,
+ 0x20004000, 0x00000010, 0x20400010, 0x00404000, 0x20404010, 0x00400000, 0x00004010, 0x20000010,
+ 0x00400000, 0x20004000, 0x20000000, 0x00004010, 0x20000010, 0x20404010, 0x00404000, 0x20400000,
+ 0x00404010, 0x20404000, 0x00000000, 0x20400010, 0x00000010, 0x00004000, 0x20400000, 0x00404010,
+ 0x00004000, 0x00400010, 0x20004010, 0x00000000, 0x20404000, 0x20000000, 0x00400010, 0x20004010
+};
+
+static u32 sbox7[64] =
+{
+ 0x00200000, 0x04200002, 0x04000802, 0x00000000, 0x00000800, 0x04000802, 0x00200802, 0x04200800,
+ 0x04200802, 0x00200000, 0x00000000, 0x04000002, 0x00000002, 0x04000000, 0x04200002, 0x00000802,
+ 0x04000800, 0x00200802, 0x00200002, 0x04000800, 0x04000002, 0x04200000, 0x04200800, 0x00200002,
+ 0x04200000, 0x00000800, 0x00000802, 0x04200802, 0x00200800, 0x00000002, 0x04000000, 0x00200800,
+ 0x04000000, 0x00200800, 0x00200000, 0x04000802, 0x04000802, 0x04200002, 0x04200002, 0x00000002,
+ 0x00200002, 0x04000000, 0x04000800, 0x00200000, 0x04200800, 0x00000802, 0x00200802, 0x04200800,
+ 0x00000802, 0x04000002, 0x04200802, 0x04200000, 0x00200800, 0x00000000, 0x00000002, 0x04200802,
+ 0x00000000, 0x00200802, 0x04200000, 0x00000800, 0x04000002, 0x04000800, 0x00000800, 0x00200002
+};
+
+static u32 sbox8[64] =
+{
+ 0x10001040, 0x00001000, 0x00040000, 0x10041040, 0x10000000, 0x10001040, 0x00000040, 0x10000000,
+ 0x00040040, 0x10040000, 0x10041040, 0x00041000, 0x10041000, 0x00041040, 0x00001000, 0x00000040,
+ 0x10040000, 0x10000040, 0x10001000, 0x00001040, 0x00041000, 0x00040040, 0x10040040, 0x10041000,
+ 0x00001040, 0x00000000, 0x00000000, 0x10040040, 0x10000040, 0x10001000, 0x00041040, 0x00040000,
+ 0x00041040, 0x00040000, 0x10041000, 0x00001000, 0x00000040, 0x10040040, 0x00001000, 0x00041040,
+ 0x10001000, 0x00000040, 0x10000040, 0x10040000, 0x10040040, 0x10000000, 0x00040000, 0x10001040,
+ 0x00000000, 0x10041040, 0x00040040, 0x10000040, 0x10040000, 0x10001000, 0x10001040, 0x00000000,
+ 0x10041040, 0x00041000, 0x00041000, 0x00001040, 0x00001040, 0x00040040, 0x10000000, 0x10041000
+};
+
+
+/*
+ * These two tables are part of the 'permuted choice 1' function.
+ * In this implementation several speed improvements are done.
+ */
+static u32 leftkey_swap[16] =
+{
+ 0x00000000, 0x00000001, 0x00000100, 0x00000101,
+ 0x00010000, 0x00010001, 0x00010100, 0x00010101,
+ 0x01000000, 0x01000001, 0x01000100, 0x01000101,
+ 0x01010000, 0x01010001, 0x01010100, 0x01010101
+};
+
+static u32 rightkey_swap[16] =
+{
+ 0x00000000, 0x01000000, 0x00010000, 0x01010000,
+ 0x00000100, 0x01000100, 0x00010100, 0x01010100,
+ 0x00000001, 0x01000001, 0x00010001, 0x01010001,
+ 0x00000101, 0x01000101, 0x00010101, 0x01010101,
+};
+
+
+
+/*
+ * Numbers of left shifts per round for encryption subkeys.
+ * To calculate the decryption subkeys we just reverse the
+ * ordering of the calculated encryption subkeys. So their
+ * is no need for a decryption rotate tab.
+ */
+static byte encrypt_rotate_tab[16] =
+{
+ 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
+};
+
+
+
+/*
+ * Table with weak DES keys sorted in ascending order.
+ * In DES their are 64 known keys which are weak. They are weak
+ * because they produce only one, two or four different
+ * subkeys in the subkey scheduling process.
+ * The keys in this table have all their parity bits cleared.
+ */
+static byte weak_keys[64][8] =
+{
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /*w*/
+ { 0x00, 0x00, 0x1e, 0x1e, 0x00, 0x00, 0x0e, 0x0e },
+ { 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0xf0 },
+ { 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, 0xfe, 0xfe },
+ { 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x0e }, /*sw*/
+ { 0x00, 0x1e, 0x1e, 0x00, 0x00, 0x0e, 0x0e, 0x00 },
+ { 0x00, 0x1e, 0xe0, 0xfe, 0x00, 0x0e, 0xf0, 0xfe },
+ { 0x00, 0x1e, 0xfe, 0xe0, 0x00, 0x0e, 0xfe, 0xf0 },
+ { 0x00, 0xe0, 0x00, 0xe0, 0x00, 0xf0, 0x00, 0xf0 }, /*sw*/
+ { 0x00, 0xe0, 0x1e, 0xfe, 0x00, 0xf0, 0x0e, 0xfe },
+ { 0x00, 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0xf0, 0x00 },
+ { 0x00, 0xe0, 0xfe, 0x1e, 0x00, 0xf0, 0xfe, 0x0e },
+ { 0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe }, /*sw*/
+ { 0x00, 0xfe, 0x1e, 0xe0, 0x00, 0xfe, 0x0e, 0xf0 },
+ { 0x00, 0xfe, 0xe0, 0x1e, 0x00, 0xfe, 0xf0, 0x0e },
+ { 0x00, 0xfe, 0xfe, 0x00, 0x00, 0xfe, 0xfe, 0x00 },
+ { 0x1e, 0x00, 0x00, 0x1e, 0x0e, 0x00, 0x00, 0x0e },
+ { 0x1e, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x0e, 0x00 }, /*sw*/
+ { 0x1e, 0x00, 0xe0, 0xfe, 0x0e, 0x00, 0xf0, 0xfe },
+ { 0x1e, 0x00, 0xfe, 0xe0, 0x0e, 0x00, 0xfe, 0xf0 },
+ { 0x1e, 0x1e, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00 },
+ { 0x1e, 0x1e, 0x1e, 0x1e, 0x0e, 0x0e, 0x0e, 0x0e }, /*w*/
+ { 0x1e, 0x1e, 0xe0, 0xe0, 0x0e, 0x0e, 0xf0, 0xf0 },
+ { 0x1e, 0x1e, 0xfe, 0xfe, 0x0e, 0x0e, 0xfe, 0xfe },
+ { 0x1e, 0xe0, 0x00, 0xfe, 0x0e, 0xf0, 0x00, 0xfe },
+ { 0x1e, 0xe0, 0x1e, 0xe0, 0x0e, 0xf0, 0x0e, 0xf0 }, /*sw*/
+ { 0x1e, 0xe0, 0xe0, 0x1e, 0x0e, 0xf0, 0xf0, 0x0e },
+ { 0x1e, 0xe0, 0xfe, 0x00, 0x0e, 0xf0, 0xfe, 0x00 },
+ { 0x1e, 0xfe, 0x00, 0xe0, 0x0e, 0xfe, 0x00, 0xf0 },
+ { 0x1e, 0xfe, 0x1e, 0xfe, 0x0e, 0xfe, 0x0e, 0xfe }, /*sw*/
+ { 0x1e, 0xfe, 0xe0, 0x00, 0x0e, 0xfe, 0xf0, 0x00 },
+ { 0x1e, 0xfe, 0xfe, 0x1e, 0x0e, 0xfe, 0xfe, 0x0e },
+ { 0xe0, 0x00, 0x00, 0xe0, 0xf0, 0x00, 0x00, 0xf0 },
+ { 0xe0, 0x00, 0x1e, 0xfe, 0xf0, 0x00, 0x0e, 0xfe },
+ { 0xe0, 0x00, 0xe0, 0x00, 0xf0, 0x00, 0xf0, 0x00 }, /*sw*/
+ { 0xe0, 0x00, 0xfe, 0x1e, 0xf0, 0x00, 0xfe, 0x0e },
+ { 0xe0, 0x1e, 0x00, 0xfe, 0xf0, 0x0e, 0x00, 0xfe },
+ { 0xe0, 0x1e, 0x1e, 0xe0, 0xf0, 0x0e, 0x0e, 0xf0 },
+ { 0xe0, 0x1e, 0xe0, 0x1e, 0xf0, 0x0e, 0xf0, 0x0e }, /*sw*/
+ { 0xe0, 0x1e, 0xfe, 0x00, 0xf0, 0x0e, 0xfe, 0x00 },
+ { 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00 },
+ { 0xe0, 0xe0, 0x1e, 0x1e, 0xf0, 0xf0, 0x0e, 0x0e },
+ { 0xe0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf0 }, /*w*/
+ { 0xe0, 0xe0, 0xfe, 0xfe, 0xf0, 0xf0, 0xfe, 0xfe },
+ { 0xe0, 0xfe, 0x00, 0x1e, 0xf0, 0xfe, 0x00, 0x0e },
+ { 0xe0, 0xfe, 0x1e, 0x00, 0xf0, 0xfe, 0x0e, 0x00 },
+ { 0xe0, 0xfe, 0xe0, 0xfe, 0xf0, 0xfe, 0xf0, 0xfe }, /*sw*/
+ { 0xe0, 0xfe, 0xfe, 0xe0, 0xf0, 0xfe, 0xfe, 0xf0 },
+ { 0xfe, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, 0xfe },
+ { 0xfe, 0x00, 0x1e, 0xe0, 0xfe, 0x00, 0x0e, 0xf0 },
+ { 0xfe, 0x00, 0xe0, 0x1e, 0xfe, 0x00, 0xf0, 0x0e },
+ { 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00 }, /*sw*/
+ { 0xfe, 0x1e, 0x00, 0xe0, 0xfe, 0x0e, 0x00, 0xf0 },
+ { 0xfe, 0x1e, 0x1e, 0xfe, 0xfe, 0x0e, 0x0e, 0xfe },
+ { 0xfe, 0x1e, 0xe0, 0x00, 0xfe, 0x0e, 0xf0, 0x00 },
+ { 0xfe, 0x1e, 0xfe, 0x1e, 0xfe, 0x0e, 0xfe, 0x0e }, /*sw*/
+ { 0xfe, 0xe0, 0x00, 0x1e, 0xfe, 0xf0, 0x00, 0x0e },
+ { 0xfe, 0xe0, 0x1e, 0x00, 0xfe, 0xf0, 0x0e, 0x00 },
+ { 0xfe, 0xe0, 0xe0, 0xfe, 0xfe, 0xf0, 0xf0, 0xfe },
+ { 0xfe, 0xe0, 0xfe, 0xe0, 0xfe, 0xf0, 0xfe, 0xf0 }, /*sw*/
+ { 0xfe, 0xfe, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00 },
+ { 0xfe, 0xfe, 0x1e, 0x1e, 0xfe, 0xfe, 0x0e, 0x0e },
+ { 0xfe, 0xfe, 0xe0, 0xe0, 0xfe, 0xfe, 0xf0, 0xf0 },
+ { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe } /*w*/
+};
+static unsigned char weak_keys_chksum[20] = {
+ 0xD0, 0xCF, 0x07, 0x38, 0x93, 0x70, 0x8A, 0x83, 0x7D, 0xD7,
+ 0x8A, 0x36, 0x65, 0x29, 0x6C, 0x1F, 0x7C, 0x3F, 0xD3, 0x41
+};
+
+
+
+/*
+ * Macro to swap bits across two words.
+ */
+#define DO_PERMUTATION(a, temp, b, offset, mask) \
+ temp = ((a>>offset) ^ b) & mask; \
+ b ^= temp; \
+ a ^= temp<<offset;
+
+
+/*
+ * This performs the 'initial permutation' of the data to be encrypted
+ * or decrypted. Additionally the resulting two words are rotated one bit
+ * to the left.
+ */
+#define INITIAL_PERMUTATION(left, temp, right) \
+ DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f) \
+ DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \
+ DO_PERMUTATION(right, temp, left, 2, 0x33333333) \
+ DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \
+ right = (right << 1) | (right >> 31); \
+ temp = (left ^ right) & 0xaaaaaaaa; \
+ right ^= temp; \
+ left ^= temp; \
+ left = (left << 1) | (left >> 31);
+
+/*
+ * The 'inverse initial permutation'.
+ */
+#define FINAL_PERMUTATION(left, temp, right) \
+ left = (left << 31) | (left >> 1); \
+ temp = (left ^ right) & 0xaaaaaaaa; \
+ left ^= temp; \
+ right ^= temp; \
+ right = (right << 31) | (right >> 1); \
+ DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \
+ DO_PERMUTATION(right, temp, left, 2, 0x33333333) \
+ DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \
+ DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f)
+
+
+/*
+ * A full DES round including 'expansion function', 'sbox substitution'
+ * and 'primitive function P' but without swapping the left and right word.
+ * Please note: The data in 'from' and 'to' is already rotated one bit to
+ * the left, done in the initial permutation.
+ */
+#define DES_ROUND(from, to, work, subkey) \
+ work = from ^ *subkey++; \
+ to ^= sbox8[ work & 0x3f ]; \
+ to ^= sbox6[ (work>>8) & 0x3f ]; \
+ to ^= sbox4[ (work>>16) & 0x3f ]; \
+ to ^= sbox2[ (work>>24) & 0x3f ]; \
+ work = ((from << 28) | (from >> 4)) ^ *subkey++; \
+ to ^= sbox7[ work & 0x3f ]; \
+ to ^= sbox5[ (work>>8) & 0x3f ]; \
+ to ^= sbox3[ (work>>16) & 0x3f ]; \
+ to ^= sbox1[ (work>>24) & 0x3f ];
+
+/*
+ * Macros to convert 8 bytes from/to 32bit words.
+ */
+#define READ_64BIT_DATA(data, left, right) \
+ left = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; \
+ right = (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7];
+
+#define WRITE_64BIT_DATA(data, left, right) \
+ data[0] = (left >> 24) &0xff; data[1] = (left >> 16) &0xff; \
+ data[2] = (left >> 8) &0xff; data[3] = left &0xff; \
+ data[4] = (right >> 24) &0xff; data[5] = (right >> 16) &0xff; \
+ data[6] = (right >> 8) &0xff; data[7] = right &0xff;
+
+/*
+ * Handy macros for encryption and decryption of data
+ */
+#define des_ecb_encrypt(ctx, from, to) des_ecb_crypt(ctx, from, to, 0)
+#define des_ecb_decrypt(ctx, from, to) des_ecb_crypt(ctx, from, to, 1)
+#define tripledes_ecb_encrypt(ctx, from, to) tripledes_ecb_crypt(ctx,from,to,0)
+#define tripledes_ecb_decrypt(ctx, from, to) tripledes_ecb_crypt(ctx,from,to,1)
+
+
+
+
+
+
+/*
+ * des_key_schedule(): Calculate 16 subkeys pairs (even/odd) for
+ * 16 encryption rounds.
+ * To calculate subkeys for decryption the caller
+ * have to reorder the generated subkeys.
+ *
+ * rawkey: 8 Bytes of key data
+ * subkey: Array of at least 32 u32s. Will be filled
+ * with calculated subkeys.
+ *
+ */
+static void
+des_key_schedule (const byte * rawkey, u32 * subkey)
+{
+ u32 left, right, work;
+ int round;
+
+ READ_64BIT_DATA (rawkey, left, right)
+
+ DO_PERMUTATION (right, work, left, 4, 0x0f0f0f0f)
+ DO_PERMUTATION (right, work, left, 0, 0x10101010)
+
+ left = ((leftkey_swap[(left >> 0) & 0xf] << 3)
+ | (leftkey_swap[(left >> 8) & 0xf] << 2)
+ | (leftkey_swap[(left >> 16) & 0xf] << 1)
+ | (leftkey_swap[(left >> 24) & 0xf])
+ | (leftkey_swap[(left >> 5) & 0xf] << 7)
+ | (leftkey_swap[(left >> 13) & 0xf] << 6)
+ | (leftkey_swap[(left >> 21) & 0xf] << 5)
+ | (leftkey_swap[(left >> 29) & 0xf] << 4));
+
+ left &= 0x0fffffff;
+
+ right = ((rightkey_swap[(right >> 1) & 0xf] << 3)
+ | (rightkey_swap[(right >> 9) & 0xf] << 2)
+ | (rightkey_swap[(right >> 17) & 0xf] << 1)
+ | (rightkey_swap[(right >> 25) & 0xf])
+ | (rightkey_swap[(right >> 4) & 0xf] << 7)
+ | (rightkey_swap[(right >> 12) & 0xf] << 6)
+ | (rightkey_swap[(right >> 20) & 0xf] << 5)
+ | (rightkey_swap[(right >> 28) & 0xf] << 4));
+
+ right &= 0x0fffffff;
+
+ for (round = 0; round < 16; ++round)
+ {
+ left = ((left << encrypt_rotate_tab[round])
+ | (left >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff;
+ right = ((right << encrypt_rotate_tab[round])
+ | (right >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff;
+
+ *subkey++ = (((left << 4) & 0x24000000)
+ | ((left << 28) & 0x10000000)
+ | ((left << 14) & 0x08000000)
+ | ((left << 18) & 0x02080000)
+ | ((left << 6) & 0x01000000)
+ | ((left << 9) & 0x00200000)
+ | ((left >> 1) & 0x00100000)
+ | ((left << 10) & 0x00040000)
+ | ((left << 2) & 0x00020000)
+ | ((left >> 10) & 0x00010000)
+ | ((right >> 13) & 0x00002000)
+ | ((right >> 4) & 0x00001000)
+ | ((right << 6) & 0x00000800)
+ | ((right >> 1) & 0x00000400)
+ | ((right >> 14) & 0x00000200)
+ | (right & 0x00000100)
+ | ((right >> 5) & 0x00000020)
+ | ((right >> 10) & 0x00000010)
+ | ((right >> 3) & 0x00000008)
+ | ((right >> 18) & 0x00000004)
+ | ((right >> 26) & 0x00000002)
+ | ((right >> 24) & 0x00000001));
+
+ *subkey++ = (((left << 15) & 0x20000000)
+ | ((left << 17) & 0x10000000)
+ | ((left << 10) & 0x08000000)
+ | ((left << 22) & 0x04000000)
+ | ((left >> 2) & 0x02000000)
+ | ((left << 1) & 0x01000000)
+ | ((left << 16) & 0x00200000)
+ | ((left << 11) & 0x00100000)
+ | ((left << 3) & 0x00080000)
+ | ((left >> 6) & 0x00040000)
+ | ((left << 15) & 0x00020000)
+ | ((left >> 4) & 0x00010000)
+ | ((right >> 2) & 0x00002000)
+ | ((right << 8) & 0x00001000)
+ | ((right >> 14) & 0x00000808)
+ | ((right >> 9) & 0x00000400)
+ | ((right) & 0x00000200)
+ | ((right << 7) & 0x00000100)
+ | ((right >> 7) & 0x00000020)
+ | ((right >> 3) & 0x00000011)
+ | ((right << 2) & 0x00000004)
+ | ((right >> 21) & 0x00000002));
+ }
+}
+
+
+/*
+ * Fill a DES context with subkeys calculated from a 64bit key.
+ * Does not check parity bits, but simply ignore them.
+ * Does not check for weak keys.
+ */
+static int
+des_setkey (struct _des_ctx *ctx, const byte * key)
+{
+ static const char *selftest_failed;
+ int i;
+
+ if (!fips_mode () && !initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+
+ if (selftest_failed)
+ log_error ("%s\n", selftest_failed);
+ }
+ if (selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ des_key_schedule (key, ctx->encrypt_subkeys);
+ _gcry_burn_stack (32);
+
+ for(i=0; i<32; i+=2)
+ {
+ ctx->decrypt_subkeys[i] = ctx->encrypt_subkeys[30-i];
+ ctx->decrypt_subkeys[i+1] = ctx->encrypt_subkeys[31-i];
+ }
+
+ return 0;
+}
+
+
+
+/*
+ * Electronic Codebook Mode DES encryption/decryption of data according
+ * to 'mode'.
+ */
+static int
+des_ecb_crypt (struct _des_ctx *ctx, const byte * from, byte * to, int mode)
+{
+ u32 left, right, work;
+ u32 *keys;
+
+ keys = mode ? ctx->decrypt_subkeys : ctx->encrypt_subkeys;
+
+ READ_64BIT_DATA (from, left, right)
+ INITIAL_PERMUTATION (left, work, right)
+
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+
+ FINAL_PERMUTATION (right, work, left)
+ WRITE_64BIT_DATA (to, right, left)
+
+ return 0;
+}
+
+
+
+/*
+ * Fill a Triple-DES context with subkeys calculated from two 64bit keys.
+ * Does not check the parity bits of the keys, but simply ignore them.
+ * Does not check for weak keys.
+ */
+static int
+tripledes_set2keys (struct _tripledes_ctx *ctx,
+ const byte * key1,
+ const byte * key2)
+{
+ int i;
+
+ des_key_schedule (key1, ctx->encrypt_subkeys);
+ des_key_schedule (key2, &(ctx->decrypt_subkeys[32]));
+ _gcry_burn_stack (32);
+
+ for(i=0; i<32; i+=2)
+ {
+ ctx->decrypt_subkeys[i] = ctx->encrypt_subkeys[30-i];
+ ctx->decrypt_subkeys[i+1] = ctx->encrypt_subkeys[31-i];
+
+ ctx->encrypt_subkeys[i+32] = ctx->decrypt_subkeys[62-i];
+ ctx->encrypt_subkeys[i+33] = ctx->decrypt_subkeys[63-i];
+
+ ctx->encrypt_subkeys[i+64] = ctx->encrypt_subkeys[i];
+ ctx->encrypt_subkeys[i+65] = ctx->encrypt_subkeys[i+1];
+
+ ctx->decrypt_subkeys[i+64] = ctx->decrypt_subkeys[i];
+ ctx->decrypt_subkeys[i+65] = ctx->decrypt_subkeys[i+1];
+ }
+
+ return 0;
+}
+
+
+
+/*
+ * Fill a Triple-DES context with subkeys calculated from three 64bit keys.
+ * Does not check the parity bits of the keys, but simply ignore them.
+ * Does not check for weak keys.
+ */
+static int
+tripledes_set3keys (struct _tripledes_ctx *ctx,
+ const byte * key1,
+ const byte * key2,
+ const byte * key3)
+{
+ static const char *selftest_failed;
+ int i;
+
+ if (!fips_mode () && !initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+
+ if (selftest_failed)
+ log_error ("%s\n", selftest_failed);
+ }
+ if (selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ des_key_schedule (key1, ctx->encrypt_subkeys);
+ des_key_schedule (key2, &(ctx->decrypt_subkeys[32]));
+ des_key_schedule (key3, &(ctx->encrypt_subkeys[64]));
+ _gcry_burn_stack (32);
+
+ for(i=0; i<32; i+=2)
+ {
+ ctx->decrypt_subkeys[i] = ctx->encrypt_subkeys[94-i];
+ ctx->decrypt_subkeys[i+1] = ctx->encrypt_subkeys[95-i];
+
+ ctx->encrypt_subkeys[i+32] = ctx->decrypt_subkeys[62-i];
+ ctx->encrypt_subkeys[i+33] = ctx->decrypt_subkeys[63-i];
+
+ ctx->decrypt_subkeys[i+64] = ctx->encrypt_subkeys[30-i];
+ ctx->decrypt_subkeys[i+65] = ctx->encrypt_subkeys[31-i];
+ }
+
+ return 0;
+}
+
+
+
+/*
+ * Electronic Codebook Mode Triple-DES encryption/decryption of data
+ * according to 'mode'. Sometimes this mode is named 'EDE' mode
+ * (Encryption-Decryption-Encryption).
+ */
+static int
+tripledes_ecb_crypt (struct _tripledes_ctx *ctx, const byte * from,
+ byte * to, int mode)
+{
+ u32 left, right, work;
+ u32 *keys;
+
+ keys = mode ? ctx->decrypt_subkeys : ctx->encrypt_subkeys;
+
+ READ_64BIT_DATA (from, left, right)
+ INITIAL_PERMUTATION (left, work, right)
+
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+ DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys)
+
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+ DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+
+ FINAL_PERMUTATION (right, work, left)
+ WRITE_64BIT_DATA (to, right, left)
+
+ return 0;
+}
+
+
+
+
+
+/*
+ * Check whether the 8 byte key is weak.
+ * Does not check the parity bits of the key but simple ignore them.
+ */
+static int
+is_weak_key ( const byte *key )
+{
+ byte work[8];
+ int i, left, right, middle, cmp_result;
+
+ /* clear parity bits */
+ for(i=0; i<8; ++i)
+ work[i] = key[i] & 0xfe;
+
+ /* binary search in the weak key table */
+ left = 0;
+ right = 63;
+ while(left <= right)
+ {
+ middle = (left + right) / 2;
+
+ if ( !(cmp_result=working_memcmp(work, weak_keys[middle], 8)) )
+ return -1;
+
+ if ( cmp_result > 0 )
+ left = middle + 1;
+ else
+ right = middle - 1;
+ }
+
+ return 0;
+}
+
+
+
+/*
+ * Performs a selftest of this DES/Triple-DES implementation.
+ * Returns an string with the error text on failure.
+ * Returns NULL if all is ok.
+ */
+static const char *
+selftest (void)
+{
+ /*
+ * Check if 'u32' is really 32 bits wide. This DES / 3DES implementation
+ * need this.
+ */
+ if (sizeof (u32) != 4)
+ return "Wrong word size for DES configured.";
+
+ /*
+ * DES Maintenance Test
+ */
+ {
+ int i;
+ byte key[8] =
+ {0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55};
+ byte input[8] =
+ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ byte result[8] =
+ {0x24, 0x6e, 0x9d, 0xb9, 0xc5, 0x50, 0x38, 0x1a};
+ byte temp1[8], temp2[8], temp3[8];
+ des_ctx des;
+
+ for (i = 0; i < 64; ++i)
+ {
+ des_setkey (des, key);
+ des_ecb_encrypt (des, input, temp1);
+ des_ecb_encrypt (des, temp1, temp2);
+ des_setkey (des, temp2);
+ des_ecb_decrypt (des, temp1, temp3);
+ memcpy (key, temp3, 8);
+ memcpy (input, temp1, 8);
+ }
+ if (memcmp (temp3, result, 8))
+ return "DES maintenance test failed.";
+ }
+
+
+ /*
+ * Self made Triple-DES test (Does somebody know an official test?)
+ */
+ {
+ int i;
+ byte input[8] =
+ {0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10};
+ byte key1[8] =
+ {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0};
+ byte key2[8] =
+ {0x11, 0x22, 0x33, 0x44, 0xff, 0xaa, 0xcc, 0xdd};
+ byte result[8] =
+ {0x7b, 0x38, 0x3b, 0x23, 0xa2, 0x7d, 0x26, 0xd3};
+
+ tripledes_ctx des3;
+
+ for (i = 0; i < 16; ++i)
+ {
+ tripledes_set2keys (des3, key1, key2);
+ tripledes_ecb_encrypt (des3, input, key1);
+ tripledes_ecb_decrypt (des3, input, key2);
+ tripledes_set3keys (des3, key1, input, key2);
+ tripledes_ecb_encrypt (des3, input, input);
+ }
+ if (memcmp (input, result, 8))
+ return "Triple-DES test failed.";
+ }
+
+ /*
+ * More Triple-DES test. These are testvectors as used by SSLeay,
+ * thanks to Jeroen C. van Gelderen.
+ */
+ {
+ struct { byte key[24]; byte plain[8]; byte cipher[8]; } testdata[] = {
+ { { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 },
+ { 0x95,0xF8,0xA5,0xE5,0xDD,0x31,0xD9,0x00 },
+ { 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }
+ },
+
+ { { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 },
+ { 0x9D,0x64,0x55,0x5A,0x9A,0x10,0xB8,0x52, },
+ { 0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00 }
+ },
+ { { 0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E,
+ 0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E,
+ 0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E },
+ { 0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A },
+ { 0x71,0x78,0x87,0x6E,0x01,0xF1,0x9B,0x2A }
+ },
+ { { 0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6,
+ 0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6,
+ 0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6 },
+ { 0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2 },
+ { 0xAF,0x37,0xFB,0x42,0x1F,0x8C,0x40,0x95 }
+ },
+ { { 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
+ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
+ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF },
+ { 0x73,0x6F,0x6D,0x65,0x64,0x61,0x74,0x61 },
+ { 0x3D,0x12,0x4F,0xE2,0x19,0x8B,0xA3,0x18 }
+ },
+ { { 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
+ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
+ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF },
+ { 0x73,0x6F,0x6D,0x65,0x64,0x61,0x74,0x61 },
+ { 0xFB,0xAB,0xA1,0xFF,0x9D,0x05,0xE9,0xB1 }
+ },
+ { { 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
+ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
+ 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10 },
+ { 0x73,0x6F,0x6D,0x65,0x64,0x61,0x74,0x61 },
+ { 0x18,0xd7,0x48,0xe5,0x63,0x62,0x05,0x72 }
+ },
+ { { 0x03,0x52,0x02,0x07,0x67,0x20,0x82,0x17,
+ 0x86,0x02,0x87,0x66,0x59,0x08,0x21,0x98,
+ 0x64,0x05,0x6A,0xBD,0xFE,0xA9,0x34,0x57 },
+ { 0x73,0x71,0x75,0x69,0x67,0x67,0x6C,0x65 },
+ { 0xc0,0x7d,0x2a,0x0f,0xa5,0x66,0xfa,0x30 }
+ },
+ { { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x80,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02 },
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
+ { 0xe6,0xe6,0xdd,0x5b,0x7e,0x72,0x29,0x74 }
+ },
+ { { 0x10,0x46,0x10,0x34,0x89,0x98,0x80,0x20,
+ 0x91,0x07,0xD0,0x15,0x89,0x19,0x01,0x01,
+ 0x19,0x07,0x92,0x10,0x98,0x1A,0x01,0x01 },
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
+ { 0xe1,0xef,0x62,0xc3,0x32,0xfe,0x82,0x5b }
+ }
+ };
+
+ byte result[8];
+ int i;
+ tripledes_ctx des3;
+
+ for (i=0; i<sizeof(testdata)/sizeof(*testdata); ++i)
+ {
+ tripledes_set3keys (des3, testdata[i].key,
+ testdata[i].key + 8, testdata[i].key + 16);
+
+ tripledes_ecb_encrypt (des3, testdata[i].plain, result);
+ if (memcmp (testdata[i].cipher, result, 8))
+ return "Triple-DES SSLeay test failed on encryption.";
+
+ tripledes_ecb_decrypt (des3, testdata[i].cipher, result);
+ if (memcmp (testdata[i].plain, result, 8))
+ return "Triple-DES SSLeay test failed on decryption.";;
+ }
+ }
+
+ /*
+ * Check the weak key detection. We simply assume that the table
+ * with weak keys is ok and check every key in the table if it is
+ * detected... (This test is a little bit stupid).
+ */
+ {
+ int i;
+ unsigned char *p;
+ gcry_md_hd_t h;
+
+ if (_gcry_md_open (&h, GCRY_MD_SHA1, 0))
+ return "SHA1 not available";
+
+ for (i = 0; i < 64; ++i)
+ _gcry_md_write (h, weak_keys[i], 8);
+ p = _gcry_md_read (h, GCRY_MD_SHA1);
+ i = memcmp (p, weak_keys_chksum, 20);
+ _gcry_md_close (h);
+ if (i)
+ return "weak key table defect";
+
+ for (i = 0; i < 64; ++i)
+ if (!is_weak_key(weak_keys[i]))
+ return "DES weak key detection failed";
+ }
+
+ return 0;
+}
+
+
+static gcry_err_code_t
+do_tripledes_setkey ( void *context, const byte *key, unsigned keylen )
+{
+ struct _tripledes_ctx *ctx = (struct _tripledes_ctx *) context;
+
+ if( keylen != 24 )
+ return GPG_ERR_INV_KEYLEN;
+
+ tripledes_set3keys ( ctx, key, key+8, key+16);
+
+ if (ctx->flags.no_weak_key)
+ ; /* Detection has been disabled. */
+ else if (is_weak_key (key) || is_weak_key (key+8) || is_weak_key (key+16))
+ {
+ _gcry_burn_stack (64);
+ return GPG_ERR_WEAK_KEY;
+ }
+ _gcry_burn_stack (64);
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+static gcry_err_code_t
+do_tripledes_set_extra_info (void *context, int what,
+ const void *buffer, size_t buflen)
+{
+ struct _tripledes_ctx *ctx = (struct _tripledes_ctx *)context;
+ gpg_err_code_t ec = 0;
+
+ (void)buffer;
+ (void)buflen;
+
+ switch (what)
+ {
+ case CIPHER_INFO_NO_WEAK_KEY:
+ ctx->flags.no_weak_key = 1;
+ break;
+
+ default:
+ ec = GPG_ERR_INV_OP;
+ break;
+ }
+ return ec;
+}
+
+
+static void
+do_tripledes_encrypt( void *context, byte *outbuf, const byte *inbuf )
+{
+ struct _tripledes_ctx *ctx = (struct _tripledes_ctx *) context;
+
+ tripledes_ecb_encrypt ( ctx, inbuf, outbuf );
+ _gcry_burn_stack (32);
+}
+
+static void
+do_tripledes_decrypt( void *context, byte *outbuf, const byte *inbuf )
+{
+ struct _tripledes_ctx *ctx = (struct _tripledes_ctx *) context;
+ tripledes_ecb_decrypt ( ctx, inbuf, outbuf );
+ _gcry_burn_stack (32);
+}
+
+static gcry_err_code_t
+do_des_setkey (void *context, const byte *key, unsigned keylen)
+{
+ struct _des_ctx *ctx = (struct _des_ctx *) context;
+
+ if (keylen != 8)
+ return GPG_ERR_INV_KEYLEN;
+
+ des_setkey (ctx, key);
+
+ if (is_weak_key (key)) {
+ _gcry_burn_stack (64);
+ return GPG_ERR_WEAK_KEY;
+ }
+ _gcry_burn_stack (64);
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+static void
+do_des_encrypt( void *context, byte *outbuf, const byte *inbuf )
+{
+ struct _des_ctx *ctx = (struct _des_ctx *) context;
+
+ des_ecb_encrypt ( ctx, inbuf, outbuf );
+ _gcry_burn_stack (32);
+}
+
+static void
+do_des_decrypt( void *context, byte *outbuf, const byte *inbuf )
+{
+ struct _des_ctx *ctx = (struct _des_ctx *) context;
+
+ des_ecb_decrypt ( ctx, inbuf, outbuf );
+ _gcry_burn_stack (32);
+}
+
+
+
+
+/*
+ Self-test section.
+ */
+
+
+/* Selftest for TripleDES. */
+static gpg_err_code_t
+selftest_fips (int extended, selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+
+ (void)extended; /* No extended tests available. */
+
+ what = "low-level";
+ errtxt = selftest ();
+ if (errtxt)
+ goto failed;
+
+ /* The low-level self-tests are quite extensive and thus we can do
+ without high level tests. This is also justified because we have
+ no custom block code implementation for 3des but always use the
+ standard high level block code. */
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("cipher", GCRY_CIPHER_3DES, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+static gpg_err_code_t
+run_selftests (int algo, int extended, selftest_report_func_t report)
+{
+ gpg_err_code_t ec;
+
+ switch (algo)
+ {
+ case GCRY_CIPHER_3DES:
+ ec = selftest_fips (extended, report);
+ break;
+ default:
+ ec = GPG_ERR_CIPHER_ALGO;
+ break;
+
+ }
+ return ec;
+}
+
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_des =
+ {
+ "DES", NULL, NULL, 8, 64, sizeof (struct _des_ctx),
+ do_des_setkey, do_des_encrypt, do_des_decrypt
+ };
+
+static gcry_cipher_oid_spec_t oids_tripledes[] =
+ {
+ { "1.2.840.113549.3.7", GCRY_CIPHER_MODE_CBC },
+ /* Teletrust specific OID for 3DES. */
+ { "1.3.36.3.1.3.2.1", GCRY_CIPHER_MODE_CBC },
+ /* pbeWithSHAAnd3_KeyTripleDES_CBC */
+ { "1.2.840.113549.1.12.1.3", GCRY_CIPHER_MODE_CBC },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_tripledes =
+ {
+ "3DES", NULL, oids_tripledes, 8, 192, sizeof (struct _tripledes_ctx),
+ do_tripledes_setkey, do_tripledes_encrypt, do_tripledes_decrypt
+ };
+
+cipher_extra_spec_t _gcry_cipher_extraspec_tripledes =
+ {
+ run_selftests,
+ do_tripledes_set_extra_info
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/dsa.c b/grub-core/lib/libgcrypt/cipher/dsa.c
new file mode 100644
index 0000000..883a815
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/dsa.c
@@ -0,0 +1,1193 @@
+/* dsa.c - DSA signature algorithm
+ * Copyright (C) 1998, 2000, 2001, 2002, 2003,
+ * 2006, 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "g10lib.h"
+#include "mpi.h"
+#include "cipher.h"
+
+typedef struct
+{
+ gcry_mpi_t p; /* prime */
+ gcry_mpi_t q; /* group order */
+ gcry_mpi_t g; /* group generator */
+ gcry_mpi_t y; /* g^x mod p */
+} DSA_public_key;
+
+
+typedef struct
+{
+ gcry_mpi_t p; /* prime */
+ gcry_mpi_t q; /* group order */
+ gcry_mpi_t g; /* group generator */
+ gcry_mpi_t y; /* g^x mod p */
+ gcry_mpi_t x; /* secret exponent */
+} DSA_secret_key;
+
+
+/* A structure used to hold domain parameters. */
+typedef struct
+{
+ gcry_mpi_t p; /* prime */
+ gcry_mpi_t q; /* group order */
+ gcry_mpi_t g; /* group generator */
+} dsa_domain_t;
+
+
+/* A sample 1024 bit DSA key used for the selftests. */
+static const char sample_secret_key[] =
+"(private-key"
+" (dsa"
+" (p #00AD7C0025BA1A15F775F3F2D673718391D00456978D347B33D7B49E7F32EDAB"
+" 96273899DD8B2BB46CD6ECA263FAF04A28903503D59062A8865D2AE8ADFB5191"
+" CF36FFB562D0E2F5809801A1F675DAE59698A9E01EFE8D7DCFCA084F4C6F5A44"
+" 44D499A06FFAEA5E8EF5E01F2FD20A7B7EF3F6968AFBA1FB8D91F1559D52D8777B#)"
+" (q #00EB7B5751D25EBBB7BD59D920315FD840E19AEBF9#)"
+" (g #1574363387FDFD1DDF38F4FBE135BB20C7EE4772FB94C337AF86EA8E49666503"
+" AE04B6BE81A2F8DD095311E0217ACA698A11E6C5D33CCDAE71498ED35D13991E"
+" B02F09AB40BD8F4C5ED8C75DA779D0AE104BC34C960B002377068AB4B5A1F984"
+" 3FBA91F537F1B7CAC4D8DD6D89B0D863AF7025D549F9C765D2FC07EE208F8D15#)"
+" (y #64B11EF8871BE4AB572AA810D5D3CA11A6CDBC637A8014602C72960DB135BF46"
+" A1816A724C34F87330FC9E187C5D66897A04535CC2AC9164A7150ABFA8179827"
+" 6E45831AB811EEE848EBB24D9F5F2883B6E5DDC4C659DEF944DCFD80BF4D0A20"
+" 42CAA7DC289F0C5A9D155F02D3D551DB741A81695B74D4C8F477F9C7838EB0FB#)"
+" (x #11D54E4ADBD3034160F2CED4B7CD292A4EBF3EC0#)))";
+/* A sample 1024 bit DSA key used for the selftests (public only). */
+static const char sample_public_key[] =
+"(public-key"
+" (dsa"
+" (p #00AD7C0025BA1A15F775F3F2D673718391D00456978D347B33D7B49E7F32EDAB"
+" 96273899DD8B2BB46CD6ECA263FAF04A28903503D59062A8865D2AE8ADFB5191"
+" CF36FFB562D0E2F5809801A1F675DAE59698A9E01EFE8D7DCFCA084F4C6F5A44"
+" 44D499A06FFAEA5E8EF5E01F2FD20A7B7EF3F6968AFBA1FB8D91F1559D52D8777B#)"
+" (q #00EB7B5751D25EBBB7BD59D920315FD840E19AEBF9#)"
+" (g #1574363387FDFD1DDF38F4FBE135BB20C7EE4772FB94C337AF86EA8E49666503"
+" AE04B6BE81A2F8DD095311E0217ACA698A11E6C5D33CCDAE71498ED35D13991E"
+" B02F09AB40BD8F4C5ED8C75DA779D0AE104BC34C960B002377068AB4B5A1F984"
+" 3FBA91F537F1B7CAC4D8DD6D89B0D863AF7025D549F9C765D2FC07EE208F8D15#)"
+" (y #64B11EF8871BE4AB572AA810D5D3CA11A6CDBC637A8014602C72960DB135BF46"
+" A1816A724C34F87330FC9E187C5D66897A04535CC2AC9164A7150ABFA8179827"
+" 6E45831AB811EEE848EBB24D9F5F2883B6E5DDC4C659DEF944DCFD80BF4D0A20"
+" 42CAA7DC289F0C5A9D155F02D3D551DB741A81695B74D4C8F477F9C7838EB0FB#)))";
+
+
+
+
+static gcry_mpi_t gen_k (gcry_mpi_t q);
+static int test_keys (DSA_secret_key *sk, unsigned int qbits);
+static int check_secret_key (DSA_secret_key *sk);
+static gpg_err_code_t generate (DSA_secret_key *sk,
+ unsigned int nbits,
+ unsigned int qbits,
+ int transient_key,
+ dsa_domain_t *domain,
+ gcry_mpi_t **ret_factors);
+static void sign (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input,
+ DSA_secret_key *skey);
+static int verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t input,
+ DSA_public_key *pkey);
+
+static void (*progress_cb) (void *,const char *, int, int, int );
+static void *progress_cb_data;
+
+
+void
+_gcry_register_pk_dsa_progress (void (*cb) (void *, const char *,
+ int, int, int),
+ void *cb_data)
+{
+ progress_cb = cb;
+ progress_cb_data = cb_data;
+}
+
+
+static void
+progress (int c)
+{
+ if (progress_cb)
+ progress_cb (progress_cb_data, "pk_dsa", c, 0, 0);
+}
+
+
+/*
+ * Generate a random secret exponent k less than q.
+ */
+static gcry_mpi_t
+gen_k( gcry_mpi_t q )
+{
+ gcry_mpi_t k = mpi_alloc_secure( mpi_get_nlimbs(q) );
+ unsigned int nbits = mpi_get_nbits(q);
+ unsigned int nbytes = (nbits+7)/8;
+ char *rndbuf = NULL;
+
+ /* To learn why we don't use mpi_mod to get the requested bit size,
+ read the paper: "The Insecurity of the Digital Signature
+ Algorithm with Partially Known Nonces" by Nguyen and Shparlinski.
+ Journal of Cryptology, New York. Vol 15, nr 3 (2003) */
+
+ if ( DBG_CIPHER )
+ log_debug("choosing a random k ");
+ for (;;)
+ {
+ if( DBG_CIPHER )
+ progress('.');
+
+ if ( !rndbuf || nbits < 32 )
+ {
+ gcry_free(rndbuf);
+ rndbuf = gcry_random_bytes_secure( (nbits+7)/8, GCRY_STRONG_RANDOM );
+ }
+ else
+ { /* Change only some of the higher bits. We could improve
+ this by directly requesting more memory at the first call
+ to get_random_bytes() and use these extra bytes here.
+ However the required management code is more complex and
+ thus we better use this simple method. */
+ char *pp = gcry_random_bytes_secure( 4, GCRY_STRONG_RANDOM );
+ memcpy( rndbuf,pp, 4 );
+ gcry_free(pp);
+ }
+ _gcry_mpi_set_buffer( k, rndbuf, nbytes, 0 );
+
+ /* Make sure we have the requested number of bits. This code
+ looks a bit funny but it is easy to understand if you
+ consider that mpi_set_highbit clears all higher bits. We
+ don't have a clear_highbit, thus we first set the high bit
+ and then clear it again. */
+ if ( mpi_test_bit( k, nbits-1 ) )
+ mpi_set_highbit( k, nbits-1 );
+ else
+ {
+ mpi_set_highbit( k, nbits-1 );
+ mpi_clear_bit( k, nbits-1 );
+ }
+
+ if( !(mpi_cmp( k, q ) < 0) ) /* check: k < q */
+ {
+ if( DBG_CIPHER )
+ progress('+');
+ continue; /* no */
+ }
+ if( !(mpi_cmp_ui( k, 0 ) > 0) ) /* check: k > 0 */
+ {
+ if( DBG_CIPHER )
+ progress('-');
+ continue; /* no */
+ }
+ break; /* okay */
+ }
+ gcry_free(rndbuf);
+ if( DBG_CIPHER )
+ progress('\n');
+
+ return k;
+}
+
+
+/* Check that a freshly generated key actually works. Returns 0 on success. */
+static int
+test_keys (DSA_secret_key *sk, unsigned int qbits)
+{
+ int result = -1; /* Default to failure. */
+ DSA_public_key pk;
+ gcry_mpi_t data = gcry_mpi_new (qbits);
+ gcry_mpi_t sig_a = gcry_mpi_new (qbits);
+ gcry_mpi_t sig_b = gcry_mpi_new (qbits);
+
+ /* Put the relevant parameters into a public key structure. */
+ pk.p = sk->p;
+ pk.q = sk->q;
+ pk.g = sk->g;
+ pk.y = sk->y;
+
+ /* Create a random plaintext. */
+ gcry_mpi_randomize (data, qbits, GCRY_WEAK_RANDOM);
+
+ /* Sign DATA using the secret key. */
+ sign (sig_a, sig_b, data, sk);
+
+ /* Verify the signature using the public key. */
+ if ( !verify (sig_a, sig_b, data, &pk) )
+ goto leave; /* Signature does not match. */
+
+ /* Modify the data and check that the signing fails. */
+ gcry_mpi_add_ui (data, data, 1);
+ if ( verify (sig_a, sig_b, data, &pk) )
+ goto leave; /* Signature matches but should not. */
+
+ result = 0; /* The test succeeded. */
+
+ leave:
+ gcry_mpi_release (sig_b);
+ gcry_mpi_release (sig_a);
+ gcry_mpi_release (data);
+ return result;
+}
+
+
+
+/*
+ Generate a DSA key pair with a key of size NBITS. If transient_key
+ is true the key is generated using the standard RNG and not the
+ very secure one.
+
+ Returns: 2 structures filled with all needed values
+ and an array with the n-1 factors of (p-1)
+ */
+static gpg_err_code_t
+generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits,
+ int transient_key, dsa_domain_t *domain, gcry_mpi_t **ret_factors )
+{
+ gcry_mpi_t p; /* the prime */
+ gcry_mpi_t q; /* the 160 bit prime factor */
+ gcry_mpi_t g; /* the generator */
+ gcry_mpi_t y; /* g^x mod p */
+ gcry_mpi_t x; /* the secret exponent */
+ gcry_mpi_t h, e; /* helper */
+ unsigned char *rndbuf;
+ gcry_random_level_t random_level;
+
+ if (qbits)
+ ; /* Caller supplied qbits. Use this value. */
+ else if ( nbits >= 512 && nbits <= 1024 )
+ qbits = 160;
+ else if ( nbits == 2048 )
+ qbits = 224;
+ else if ( nbits == 3072 )
+ qbits = 256;
+ else if ( nbits == 7680 )
+ qbits = 384;
+ else if ( nbits == 15360 )
+ qbits = 512;
+ else
+ return GPG_ERR_INV_VALUE;
+
+ if (qbits < 160 || qbits > 512 || (qbits%8) )
+ return GPG_ERR_INV_VALUE;
+ if (nbits < 2*qbits || nbits > 15360)
+ return GPG_ERR_INV_VALUE;
+
+ if (fips_mode ())
+ {
+ if (nbits < 1024)
+ return GPG_ERR_INV_VALUE;
+ if (transient_key)
+ return GPG_ERR_INV_VALUE;
+ }
+
+ if (domain->p && domain->q && domain->g)
+ {
+ /* Domain parameters are given; use them. */
+ p = mpi_copy (domain->p);
+ q = mpi_copy (domain->q);
+ g = mpi_copy (domain->g);
+ gcry_assert (mpi_get_nbits (p) == nbits);
+ gcry_assert (mpi_get_nbits (q) == qbits);
+ h = mpi_alloc (0);
+ e = NULL;
+ }
+ else
+ {
+ /* Generate new domain parameters. */
+ p = _gcry_generate_elg_prime (1, nbits, qbits, NULL, ret_factors);
+ /* Get q out of factors. */
+ q = mpi_copy ((*ret_factors)[0]);
+ gcry_assert (mpi_get_nbits (q) == qbits);
+
+ /* Find a generator g (h and e are helpers).
+ e = (p-1)/q */
+ e = mpi_alloc (mpi_get_nlimbs (p));
+ mpi_sub_ui (e, p, 1);
+ mpi_fdiv_q (e, e, q);
+ g = mpi_alloc (mpi_get_nlimbs (p));
+ h = mpi_alloc_set_ui (1); /* (We start with 2.) */
+ do
+ {
+ mpi_add_ui (h, h, 1);
+ /* g = h^e mod p */
+ gcry_mpi_powm (g, h, e, p);
+ }
+ while (!mpi_cmp_ui (g, 1)); /* Continue until g != 1. */
+ }
+
+ /* Select a random number X with the property:
+ * 0 < x < q-1
+ * This must be a very good random number because this is the secret
+ * part. The random quality depends on the transient_key flag. */
+ random_level = transient_key ? GCRY_STRONG_RANDOM : GCRY_VERY_STRONG_RANDOM;
+ if (DBG_CIPHER)
+ log_debug("choosing a random x%s", transient_key? " (transient-key)":"");
+ gcry_assert( qbits >= 160 );
+ x = mpi_alloc_secure( mpi_get_nlimbs(q) );
+ mpi_sub_ui( h, q, 1 ); /* put q-1 into h */
+ rndbuf = NULL;
+ do
+ {
+ if( DBG_CIPHER )
+ progress('.');
+ if( !rndbuf )
+ rndbuf = gcry_random_bytes_secure ((qbits+7)/8, random_level);
+ else
+ { /* Change only some of the higher bits (= 2 bytes)*/
+ char *r = gcry_random_bytes_secure (2, random_level);
+ memcpy(rndbuf, r, 2 );
+ gcry_free(r);
+ }
+
+ _gcry_mpi_set_buffer( x, rndbuf, (qbits+7)/8, 0 );
+ mpi_clear_highbit( x, qbits+1 );
+ }
+ while ( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, h )<0 ) );
+ gcry_free(rndbuf);
+ mpi_free( e );
+ mpi_free( h );
+
+ /* y = g^x mod p */
+ y = mpi_alloc( mpi_get_nlimbs(p) );
+ gcry_mpi_powm( y, g, x, p );
+
+ if( DBG_CIPHER )
+ {
+ progress('\n');
+ log_mpidump("dsa p", p );
+ log_mpidump("dsa q", q );
+ log_mpidump("dsa g", g );
+ log_mpidump("dsa y", y );
+ log_mpidump("dsa x", x );
+ }
+
+ /* Copy the stuff to the key structures. */
+ sk->p = p;
+ sk->q = q;
+ sk->g = g;
+ sk->y = y;
+ sk->x = x;
+
+ /* Now we can test our keys (this should never fail!). */
+ if ( test_keys (sk, qbits) )
+ {
+ gcry_mpi_release (sk->p); sk->p = NULL;
+ gcry_mpi_release (sk->q); sk->q = NULL;
+ gcry_mpi_release (sk->g); sk->g = NULL;
+ gcry_mpi_release (sk->y); sk->y = NULL;
+ gcry_mpi_release (sk->x); sk->x = NULL;
+ fips_signal_error ("self-test after key generation failed");
+ return GPG_ERR_SELFTEST_FAILED;
+ }
+ return 0;
+}
+
+
+/* Generate a DSA key pair with a key of size NBITS using the
+ algorithm given in FIPS-186-3. If USE_FIPS186_2 is true,
+ FIPS-186-2 is used and thus the length is restricted to 1024/160.
+ If DERIVEPARMS is not NULL it may contain a seed value. If domain
+ parameters are specified in DOMAIN, DERIVEPARMS may not be given
+ and NBITS and QBITS must match the specified domain parameters. */
+static gpg_err_code_t
+generate_fips186 (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits,
+ gcry_sexp_t deriveparms, int use_fips186_2,
+ dsa_domain_t *domain,
+ int *r_counter, void **r_seed, size_t *r_seedlen,
+ gcry_mpi_t *r_h)
+{
+ gpg_err_code_t ec;
+ struct {
+ gcry_sexp_t sexp;
+ const void *seed;
+ size_t seedlen;
+ } initial_seed = { NULL, NULL, 0 };
+ gcry_mpi_t prime_q = NULL;
+ gcry_mpi_t prime_p = NULL;
+ gcry_mpi_t value_g = NULL; /* The generator. */
+ gcry_mpi_t value_y = NULL; /* g^x mod p */
+ gcry_mpi_t value_x = NULL; /* The secret exponent. */
+ gcry_mpi_t value_h = NULL; /* Helper. */
+ gcry_mpi_t value_e = NULL; /* Helper. */
+
+ /* Preset return values. */
+ *r_counter = 0;
+ *r_seed = NULL;
+ *r_seedlen = 0;
+ *r_h = NULL;
+
+ /* Derive QBITS from NBITS if requested */
+ if (!qbits)
+ {
+ if (nbits == 1024)
+ qbits = 160;
+ else if (nbits == 2048)
+ qbits = 224;
+ else if (nbits == 3072)
+ qbits = 256;
+ }
+
+ /* Check that QBITS and NBITS match the standard. Note that FIPS
+ 186-3 uses N for QBITS and L for NBITS. */
+ if (nbits == 1024 && qbits == 160)
+ ;
+ else if (nbits == 2048 && qbits == 224)
+ ;
+ else if (nbits == 2048 && qbits == 256)
+ ;
+ else if (nbits == 3072 && qbits == 256)
+ ;
+ else
+ return GPG_ERR_INV_VALUE;
+
+ if (domain->p && domain->q && domain->g)
+ {
+ /* Domain parameters are given; use them. */
+ prime_p = mpi_copy (domain->p);
+ prime_q = mpi_copy (domain->q);
+ value_g = mpi_copy (domain->g);
+ gcry_assert (mpi_get_nbits (prime_p) == nbits);
+ gcry_assert (mpi_get_nbits (prime_q) == qbits);
+ gcry_assert (!deriveparms);
+ ec = 0;
+ }
+ else
+ {
+ /* Generate new domain parameters. */
+
+ /* Get an initial seed value. */
+ if (deriveparms)
+ {
+ initial_seed.sexp = gcry_sexp_find_token (deriveparms, "seed", 0);
+ if (initial_seed.sexp)
+ initial_seed.seed = gcry_sexp_nth_data (initial_seed.sexp, 1,
+ &initial_seed.seedlen);
+ }
+
+ /* Fixme: Enable 186-3 after it has been approved and after fixing
+ the generation function. */
+ /* if (use_fips186_2) */
+ (void)use_fips186_2;
+ ec = _gcry_generate_fips186_2_prime (nbits, qbits,
+ initial_seed.seed,
+ initial_seed.seedlen,
+ &prime_q, &prime_p,
+ r_counter,
+ r_seed, r_seedlen);
+ /* else */
+ /* ec = _gcry_generate_fips186_3_prime (nbits, qbits, NULL, 0, */
+ /* &prime_q, &prime_p, */
+ /* r_counter, */
+ /* r_seed, r_seedlen, NULL); */
+ gcry_sexp_release (initial_seed.sexp);
+ if (ec)
+ goto leave;
+
+ /* Find a generator g (h and e are helpers).
+ e = (p-1)/q */
+ value_e = mpi_alloc_like (prime_p);
+ mpi_sub_ui (value_e, prime_p, 1);
+ mpi_fdiv_q (value_e, value_e, prime_q );
+ value_g = mpi_alloc_like (prime_p);
+ value_h = mpi_alloc_set_ui (1);
+ do
+ {
+ mpi_add_ui (value_h, value_h, 1);
+ /* g = h^e mod p */
+ mpi_powm (value_g, value_h, value_e, prime_p);
+ }
+ while (!mpi_cmp_ui (value_g, 1)); /* Continue until g != 1. */
+ }
+
+
+ /* Select a random number x with: 0 < x < q */
+ value_x = gcry_mpi_snew (qbits);
+ do
+ {
+ if( DBG_CIPHER )
+ progress('.');
+ gcry_mpi_randomize (value_x, qbits, GCRY_VERY_STRONG_RANDOM);
+ mpi_clear_highbit (value_x, qbits+1);
+ }
+ while (!(mpi_cmp_ui (value_x, 0) > 0 && mpi_cmp (value_x, prime_q) < 0));
+
+ /* y = g^x mod p */
+ value_y = mpi_alloc_like (prime_p);
+ gcry_mpi_powm (value_y, value_g, value_x, prime_p);
+
+ if (DBG_CIPHER)
+ {
+ progress('\n');
+ log_mpidump("dsa p", prime_p );
+ log_mpidump("dsa q", prime_q );
+ log_mpidump("dsa g", value_g );
+ log_mpidump("dsa y", value_y );
+ log_mpidump("dsa x", value_x );
+ log_mpidump("dsa h", value_h );
+ }
+
+ /* Copy the stuff to the key structures. */
+ sk->p = prime_p; prime_p = NULL;
+ sk->q = prime_q; prime_q = NULL;
+ sk->g = value_g; value_g = NULL;
+ sk->y = value_y; value_y = NULL;
+ sk->x = value_x; value_x = NULL;
+ *r_h = value_h; value_h = NULL;
+
+ leave:
+ gcry_mpi_release (prime_p);
+ gcry_mpi_release (prime_q);
+ gcry_mpi_release (value_g);
+ gcry_mpi_release (value_y);
+ gcry_mpi_release (value_x);
+ gcry_mpi_release (value_h);
+ gcry_mpi_release (value_e);
+
+ /* As a last step test this keys (this should never fail of course). */
+ if (!ec && test_keys (sk, qbits) )
+ {
+ gcry_mpi_release (sk->p); sk->p = NULL;
+ gcry_mpi_release (sk->q); sk->q = NULL;
+ gcry_mpi_release (sk->g); sk->g = NULL;
+ gcry_mpi_release (sk->y); sk->y = NULL;
+ gcry_mpi_release (sk->x); sk->x = NULL;
+ fips_signal_error ("self-test after key generation failed");
+ ec = GPG_ERR_SELFTEST_FAILED;
+ }
+
+ if (ec)
+ {
+ *r_counter = 0;
+ gcry_free (*r_seed); *r_seed = NULL;
+ *r_seedlen = 0;
+ gcry_mpi_release (*r_h); *r_h = NULL;
+ }
+
+ return ec;
+}
+
+
+
+/*
+ Test whether the secret key is valid.
+ Returns: if this is a valid key.
+ */
+static int
+check_secret_key( DSA_secret_key *sk )
+{
+ int rc;
+ gcry_mpi_t y = mpi_alloc( mpi_get_nlimbs(sk->y) );
+
+ gcry_mpi_powm( y, sk->g, sk->x, sk->p );
+ rc = !mpi_cmp( y, sk->y );
+ mpi_free( y );
+ return rc;
+}
+
+
+
+/*
+ Make a DSA signature from HASH and put it into r and s.
+ */
+static void
+sign(gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t hash, DSA_secret_key *skey )
+{
+ gcry_mpi_t k;
+ gcry_mpi_t kinv;
+ gcry_mpi_t tmp;
+
+ /* Select a random k with 0 < k < q */
+ k = gen_k( skey->q );
+
+ /* r = (a^k mod p) mod q */
+ gcry_mpi_powm( r, skey->g, k, skey->p );
+ mpi_fdiv_r( r, r, skey->q );
+
+ /* kinv = k^(-1) mod q */
+ kinv = mpi_alloc( mpi_get_nlimbs(k) );
+ mpi_invm(kinv, k, skey->q );
+
+ /* s = (kinv * ( hash + x * r)) mod q */
+ tmp = mpi_alloc( mpi_get_nlimbs(skey->p) );
+ mpi_mul( tmp, skey->x, r );
+ mpi_add( tmp, tmp, hash );
+ mpi_mulm( s , kinv, tmp, skey->q );
+
+ mpi_free(k);
+ mpi_free(kinv);
+ mpi_free(tmp);
+}
+
+
+/*
+ Returns true if the signature composed from R and S is valid.
+ */
+static int
+verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t hash, DSA_public_key *pkey )
+{
+ int rc;
+ gcry_mpi_t w, u1, u2, v;
+ gcry_mpi_t base[3];
+ gcry_mpi_t ex[3];
+
+ if( !(mpi_cmp_ui( r, 0 ) > 0 && mpi_cmp( r, pkey->q ) < 0) )
+ return 0; /* assertion 0 < r < q failed */
+ if( !(mpi_cmp_ui( s, 0 ) > 0 && mpi_cmp( s, pkey->q ) < 0) )
+ return 0; /* assertion 0 < s < q failed */
+
+ w = mpi_alloc( mpi_get_nlimbs(pkey->q) );
+ u1 = mpi_alloc( mpi_get_nlimbs(pkey->q) );
+ u2 = mpi_alloc( mpi_get_nlimbs(pkey->q) );
+ v = mpi_alloc( mpi_get_nlimbs(pkey->p) );
+
+ /* w = s^(-1) mod q */
+ mpi_invm( w, s, pkey->q );
+
+ /* u1 = (hash * w) mod q */
+ mpi_mulm( u1, hash, w, pkey->q );
+
+ /* u2 = r * w mod q */
+ mpi_mulm( u2, r, w, pkey->q );
+
+ /* v = g^u1 * y^u2 mod p mod q */
+ base[0] = pkey->g; ex[0] = u1;
+ base[1] = pkey->y; ex[1] = u2;
+ base[2] = NULL; ex[2] = NULL;
+ mpi_mulpowm( v, base, ex, pkey->p );
+ mpi_fdiv_r( v, v, pkey->q );
+
+ rc = !mpi_cmp( v, r );
+
+ mpi_free(w);
+ mpi_free(u1);
+ mpi_free(u2);
+ mpi_free(v);
+
+ return rc;
+}
+
+
+/*********************************************
+ ************** interface ******************
+ *********************************************/
+
+static gcry_err_code_t
+dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
+ const gcry_sexp_t genparms,
+ gcry_mpi_t *skey, gcry_mpi_t **retfactors,
+ gcry_sexp_t *r_extrainfo)
+{
+ gpg_err_code_t ec;
+ DSA_secret_key sk;
+ gcry_sexp_t l1;
+ unsigned int qbits = 0;
+ gcry_sexp_t deriveparms = NULL;
+ gcry_sexp_t seedinfo = NULL;
+ int transient_key = 0;
+ int use_fips186_2 = 0;
+ int use_fips186 = 0;
+ dsa_domain_t domain;
+
+ (void)algo; /* No need to check it. */
+ (void)evalue; /* Not required for DSA. */
+
+ memset (&domain, 0, sizeof domain);
+
+ if (genparms)
+ {
+ gcry_sexp_t domainsexp;
+
+ /* Parse the optional qbits element. */
+ l1 = gcry_sexp_find_token (genparms, "qbits", 0);
+ if (l1)
+ {
+ char buf[50];
+ const char *s;
+ size_t n;
+
+ s = gcry_sexp_nth_data (l1, 1, &n);
+ if (!s || n >= DIM (buf) - 1 )
+ {
+ gcry_sexp_release (l1);
+ return GPG_ERR_INV_OBJ; /* No value or value too large. */
+ }
+ memcpy (buf, s, n);
+ buf[n] = 0;
+ qbits = (unsigned int)strtoul (buf, NULL, 0);
+ gcry_sexp_release (l1);
+ }
+
+ /* Parse the optional transient-key flag. */
+ l1 = gcry_sexp_find_token (genparms, "transient-key", 0);
+ if (l1)
+ {
+ transient_key = 1;
+ gcry_sexp_release (l1);
+ }
+
+ /* Get the optional derive parameters. */
+ deriveparms = gcry_sexp_find_token (genparms, "derive-parms", 0);
+
+ /* Parse the optional "use-fips186" flags. */
+ l1 = gcry_sexp_find_token (genparms, "use-fips186", 0);
+ if (l1)
+ {
+ use_fips186 = 1;
+ gcry_sexp_release (l1);
+ }
+ l1 = gcry_sexp_find_token (genparms, "use-fips186-2", 0);
+ if (l1)
+ {
+ use_fips186_2 = 1;
+ gcry_sexp_release (l1);
+ }
+
+ /* Check whether domain parameters are given. */
+ domainsexp = gcry_sexp_find_token (genparms, "domain", 0);
+ if (domainsexp)
+ {
+ /* DERIVEPARMS can't be used together with domain
+ parameters. NBITS abnd QBITS may not be specified
+ because there values are derived from the domain
+ parameters. */
+ if (deriveparms || qbits || nbits)
+ {
+ gcry_sexp_release (domainsexp);
+ gcry_sexp_release (deriveparms);
+ return GPG_ERR_INV_VALUE;
+ }
+
+ /* Put all domain parameters into the domain object. */
+ l1 = gcry_sexp_find_token (domainsexp, "p", 0);
+ domain.p = gcry_sexp_nth_mpi (l1, 1, GCRYMPI_FMT_USG);
+ gcry_sexp_release (l1);
+ l1 = gcry_sexp_find_token (domainsexp, "q", 0);
+ domain.q = gcry_sexp_nth_mpi (l1, 1, GCRYMPI_FMT_USG);
+ gcry_sexp_release (l1);
+ l1 = gcry_sexp_find_token (domainsexp, "g", 0);
+ domain.g = gcry_sexp_nth_mpi (l1, 1, GCRYMPI_FMT_USG);
+ gcry_sexp_release (l1);
+ gcry_sexp_release (domainsexp);
+
+ /* Check that all domain parameters are available. */
+ if (!domain.p || !domain.q || !domain.g)
+ {
+ gcry_mpi_release (domain.p);
+ gcry_mpi_release (domain.q);
+ gcry_mpi_release (domain.g);
+ gcry_sexp_release (deriveparms);
+ return GPG_ERR_MISSING_VALUE;
+ }
+
+ /* Get NBITS and QBITS from the domain parameters. */
+ nbits = mpi_get_nbits (domain.p);
+ qbits = mpi_get_nbits (domain.q);
+ }
+ }
+
+ if (deriveparms || use_fips186 || use_fips186_2 || fips_mode ())
+ {
+ int counter;
+ void *seed;
+ size_t seedlen;
+ gcry_mpi_t h_value;
+
+ ec = generate_fips186 (&sk, nbits, qbits, deriveparms, use_fips186_2,
+ &domain,
+ &counter, &seed, &seedlen, &h_value);
+ gcry_sexp_release (deriveparms);
+ if (!ec && h_value)
+ {
+ /* Format the seed-values unless domain parameters are used
+ for which a H_VALUE of NULL is an indication. */
+ ec = gpg_err_code (gcry_sexp_build
+ (&seedinfo, NULL,
+ "(seed-values(counter %d)(seed %b)(h %m))",
+ counter, (int)seedlen, seed, h_value));
+ if (ec)
+ {
+ gcry_mpi_release (sk.p); sk.p = NULL;
+ gcry_mpi_release (sk.q); sk.q = NULL;
+ gcry_mpi_release (sk.g); sk.g = NULL;
+ gcry_mpi_release (sk.y); sk.y = NULL;
+ gcry_mpi_release (sk.x); sk.x = NULL;
+ }
+ gcry_free (seed);
+ gcry_mpi_release (h_value);
+ }
+ }
+ else
+ {
+ ec = generate (&sk, nbits, qbits, transient_key, &domain, retfactors);
+ }
+
+ gcry_mpi_release (domain.p);
+ gcry_mpi_release (domain.q);
+ gcry_mpi_release (domain.g);
+
+ if (!ec)
+ {
+ skey[0] = sk.p;
+ skey[1] = sk.q;
+ skey[2] = sk.g;
+ skey[3] = sk.y;
+ skey[4] = sk.x;
+
+ if (!r_extrainfo)
+ {
+ /* Old style interface - return the factors - if any - at
+ retfactors. */
+ }
+ else if (!*retfactors && !seedinfo)
+ {
+ /* No factors and no seedinfo, thus there is nothing to return. */
+ *r_extrainfo = NULL;
+ }
+ else
+ {
+ /* Put the factors into extrainfo and set retfactors to NULL
+ to make use of the new interface. Note that the factors
+ are not confidential thus we can store them in standard
+ memory. */
+ int nfactors, i, j;
+ char *p;
+ char *format = NULL;
+ void **arg_list = NULL;
+
+ for (nfactors=0; *retfactors && (*retfactors)[nfactors]; nfactors++)
+ ;
+ /* Allocate space for the format string:
+ "(misc-key-info%S(pm1-factors%m))"
+ with one "%m" for each factor and construct it. */
+ format = gcry_malloc (50 + 2*nfactors);
+ if (!format)
+ ec = gpg_err_code_from_syserror ();
+ else
+ {
+ p = stpcpy (format, "(misc-key-info");
+ if (seedinfo)
+ p = stpcpy (p, "%S");
+ if (nfactors)
+ {
+ p = stpcpy (p, "(pm1-factors");
+ for (i=0; i < nfactors; i++)
+ p = stpcpy (p, "%m");
+ p = stpcpy (p, ")");
+ }
+ p = stpcpy (p, ")");
+
+ /* Allocate space for the list of factors plus one for
+ an S-expression plus an extra NULL entry for safety
+ and fill it with the factors. */
+ arg_list = gcry_calloc (nfactors+1+1, sizeof *arg_list);
+ if (!arg_list)
+ ec = gpg_err_code_from_syserror ();
+ else
+ {
+ i = 0;
+ if (seedinfo)
+ arg_list[i++] = &seedinfo;
+ for (j=0; j < nfactors; j++)
+ arg_list[i++] = (*retfactors) + j;
+ arg_list[i] = NULL;
+
+ ec = gpg_err_code (gcry_sexp_build_array
+ (r_extrainfo, NULL, format, arg_list));
+ }
+ }
+
+ gcry_free (arg_list);
+ gcry_free (format);
+ for (i=0; i < nfactors; i++)
+ {
+ gcry_mpi_release ((*retfactors)[i]);
+ (*retfactors)[i] = NULL;
+ }
+ gcry_free (*retfactors);
+ *retfactors = NULL;
+ if (ec)
+ {
+ for (i=0; i < 5; i++)
+ {
+ gcry_mpi_release (skey[i]);
+ skey[i] = NULL;
+ }
+ }
+ }
+ }
+
+ gcry_sexp_release (seedinfo);
+ return ec;
+}
+
+
+static gcry_err_code_t
+dsa_generate (int algo, unsigned int nbits, unsigned long evalue,
+ gcry_mpi_t *skey, gcry_mpi_t **retfactors)
+{
+ (void)evalue;
+ return dsa_generate_ext (algo, nbits, 0, NULL, skey, retfactors, NULL);
+}
+
+
+
+static gcry_err_code_t
+dsa_check_secret_key (int algo, gcry_mpi_t *skey)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ DSA_secret_key sk;
+
+ (void)algo;
+
+ if ((! skey[0]) || (! skey[1]) || (! skey[2]) || (! skey[3]) || (! skey[4]))
+ err = GPG_ERR_BAD_MPI;
+ else
+ {
+ sk.p = skey[0];
+ sk.q = skey[1];
+ sk.g = skey[2];
+ sk.y = skey[3];
+ sk.x = skey[4];
+ if (! check_secret_key (&sk))
+ err = GPG_ERR_BAD_SECKEY;
+ }
+
+ return err;
+}
+
+
+static gcry_err_code_t
+dsa_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ DSA_secret_key sk;
+
+ (void)algo;
+
+ if ((! data)
+ || (! skey[0]) || (! skey[1]) || (! skey[2])
+ || (! skey[3]) || (! skey[4]))
+ err = GPG_ERR_BAD_MPI;
+ else
+ {
+ sk.p = skey[0];
+ sk.q = skey[1];
+ sk.g = skey[2];
+ sk.y = skey[3];
+ sk.x = skey[4];
+ resarr[0] = mpi_alloc (mpi_get_nlimbs (sk.p));
+ resarr[1] = mpi_alloc (mpi_get_nlimbs (sk.p));
+ sign (resarr[0], resarr[1], data, &sk);
+ }
+ return err;
+}
+
+static gcry_err_code_t
+dsa_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey,
+ int (*cmp) (void *, gcry_mpi_t), void *opaquev)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ DSA_public_key pk;
+
+ (void)algo;
+ (void)cmp;
+ (void)opaquev;
+
+ if ((! data[0]) || (! data[1]) || (! hash)
+ || (! pkey[0]) || (! pkey[1]) || (! pkey[2]) || (! pkey[3]))
+ err = GPG_ERR_BAD_MPI;
+ else
+ {
+ pk.p = pkey[0];
+ pk.q = pkey[1];
+ pk.g = pkey[2];
+ pk.y = pkey[3];
+ if (! verify (data[0], data[1], hash, &pk))
+ err = GPG_ERR_BAD_SIGNATURE;
+ }
+ return err;
+}
+
+
+static unsigned int
+dsa_get_nbits (int algo, gcry_mpi_t *pkey)
+{
+ (void)algo;
+
+ return mpi_get_nbits (pkey[0]);
+}
+
+
+
+/*
+ Self-test section.
+ */
+
+static const char *
+selftest_sign_1024 (gcry_sexp_t pkey, gcry_sexp_t skey)
+{
+ static const char sample_data[] =
+ "(data (flags raw)"
+ " (value #a0b1c2d3e4f500102030405060708090a1b2c3d4#))";
+ static const char sample_data_bad[] =
+ "(data (flags raw)"
+ " (value #a0b1c2d3e4f510102030405060708090a1b2c3d4#))";
+
+ const char *errtxt = NULL;
+ gcry_error_t err;
+ gcry_sexp_t data = NULL;
+ gcry_sexp_t data_bad = NULL;
+ gcry_sexp_t sig = NULL;
+
+ err = gcry_sexp_sscan (&data, NULL,
+ sample_data, strlen (sample_data));
+ if (!err)
+ err = gcry_sexp_sscan (&data_bad, NULL,
+ sample_data_bad, strlen (sample_data_bad));
+ if (err)
+ {
+ errtxt = "converting data failed";
+ goto leave;
+ }
+
+ err = gcry_pk_sign (&sig, data, skey);
+ if (err)
+ {
+ errtxt = "signing failed";
+ goto leave;
+ }
+ err = gcry_pk_verify (sig, data, pkey);
+ if (err)
+ {
+ errtxt = "verify failed";
+ goto leave;
+ }
+ err = gcry_pk_verify (sig, data_bad, pkey);
+ if (gcry_err_code (err) != GPG_ERR_BAD_SIGNATURE)
+ {
+ errtxt = "bad signature not detected";
+ goto leave;
+ }
+
+
+ leave:
+ gcry_sexp_release (sig);
+ gcry_sexp_release (data_bad);
+ gcry_sexp_release (data);
+ return errtxt;
+}
+
+
+static gpg_err_code_t
+selftests_dsa (selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+ gcry_error_t err;
+ gcry_sexp_t skey = NULL;
+ gcry_sexp_t pkey = NULL;
+
+ /* Convert the S-expressions into the internal representation. */
+ what = "convert";
+ err = gcry_sexp_sscan (&skey, NULL,
+ sample_secret_key, strlen (sample_secret_key));
+ if (!err)
+ err = gcry_sexp_sscan (&pkey, NULL,
+ sample_public_key, strlen (sample_public_key));
+ if (err)
+ {
+ errtxt = gcry_strerror (err);
+ goto failed;
+ }
+
+ what = "key consistency";
+ err = gcry_pk_testkey (skey);
+ if (err)
+ {
+ errtxt = gcry_strerror (err);
+ goto failed;
+ }
+
+ what = "sign";
+ errtxt = selftest_sign_1024 (pkey, skey);
+ if (errtxt)
+ goto failed;
+
+ gcry_sexp_release (pkey);
+ gcry_sexp_release (skey);
+ return 0; /* Succeeded. */
+
+ failed:
+ gcry_sexp_release (pkey);
+ gcry_sexp_release (skey);
+ if (report)
+ report ("pubkey", GCRY_PK_DSA, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+static gpg_err_code_t
+run_selftests (int algo, int extended, selftest_report_func_t report)
+{
+ gpg_err_code_t ec;
+
+ (void)extended;
+
+ switch (algo)
+ {
+ case GCRY_PK_DSA:
+ ec = selftests_dsa (report);
+ break;
+ default:
+ ec = GPG_ERR_PUBKEY_ALGO;
+ break;
+
+ }
+ return ec;
+}
+
+
+
+
+static const char *dsa_names[] =
+ {
+ "dsa",
+ "openpgp-dsa",
+ NULL,
+ };
+
+gcry_pk_spec_t _gcry_pubkey_spec_dsa =
+ {
+ "DSA", dsa_names,
+ "pqgy", "pqgyx", "", "rs", "pqgy",
+ GCRY_PK_USAGE_SIGN,
+ dsa_generate,
+ dsa_check_secret_key,
+ NULL,
+ NULL,
+ dsa_sign,
+ dsa_verify,
+ dsa_get_nbits
+ };
+pk_extra_spec_t _gcry_pubkey_extraspec_dsa =
+ {
+ run_selftests,
+ dsa_generate_ext
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/ecc.c b/grub-core/lib/libgcrypt/cipher/ecc.c
new file mode 100644
index 0000000..b8487dc
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/ecc.c
@@ -0,0 +1,1793 @@
+/* ecc.c - Elliptic Curve Cryptography
+ Copyright (C) 2007, 2008, 2010, 2011 Free Software Foundation, Inc.
+
+ This file is part of Libgcrypt.
+
+ Libgcrypt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Libgcrypt is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* This code is originally based on the Patch 0.1.6 for the gnupg
+ 1.4.x branch as retrieved on 2007-03-21 from
+ http://www.calcurco.cat/eccGnuPG/src/gnupg-1.4.6-ecc0.2.0beta1.diff.bz2
+ The original authors are:
+ Written by
+ Sergi Blanch i Torne <d4372211 at alumnes.eup.udl.es>,
+ Ramiro Moreno Chiral <ramiro at eup.udl.es>
+ Maintainers
+ Sergi Blanch i Torne
+ Ramiro Moreno Chiral
+ Mikael Mylnikov (mmr)
+ For use in Libgcrypt the code has been heavily modified and cleaned
+ up. In fact there is not much left of the orginally code except for
+ some variable names and the text book implementaion of the sign and
+ verification algorithms. The arithmetic functions have entirely
+ been rewritten and moved to mpi/ec.c.
+
+ ECDH encrypt and decrypt code written by Andrey Jivsov,
+*/
+
+
+/* TODO:
+
+ - If we support point compression we need to uncompress before
+ computing the keygrip
+
+ - In mpi/ec.c we use mpi_powm for x^2 mod p: Either implement a
+ special case in mpi_powm or check whether mpi_mulm is faster.
+
+ - Decide whether we should hide the mpi_point_t definition.
+*/
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "g10lib.h"
+#include "mpi.h"
+#include "cipher.h"
+
+/* Definition of a curve. */
+typedef struct
+{
+ gcry_mpi_t p; /* Prime specifying the field GF(p). */
+ gcry_mpi_t a; /* First coefficient of the Weierstrass equation. */
+ gcry_mpi_t b; /* Second coefficient of the Weierstrass equation. */
+ mpi_point_t G; /* Base point (generator). */
+ gcry_mpi_t n; /* Order of G. */
+ const char *name; /* Name of curve or NULL. */
+} elliptic_curve_t;
+
+
+typedef struct
+{
+ elliptic_curve_t E;
+ mpi_point_t Q; /* Q = [d]G */
+} ECC_public_key;
+
+typedef struct
+{
+ elliptic_curve_t E;
+ mpi_point_t Q;
+ gcry_mpi_t d;
+} ECC_secret_key;
+
+
+/* This tables defines aliases for curve names. */
+static const struct
+{
+ const char *name; /* Our name. */
+ const char *other; /* Other name. */
+} curve_aliases[] =
+ {
+ { "NIST P-192", "1.2.840.10045.3.1.1" }, /* X9.62 OID */
+ { "NIST P-192", "prime192v1" }, /* X9.62 name. */
+ { "NIST P-192", "secp192r1" }, /* SECP name. */
+
+ { "NIST P-224", "secp224r1" },
+ { "NIST P-224", "1.3.132.0.33" }, /* SECP OID. */
+
+ { "NIST P-256", "1.2.840.10045.3.1.7" }, /* From NIST SP 800-78-1. */
+ { "NIST P-256", "prime256v1" },
+ { "NIST P-256", "secp256r1" },
+
+ { "NIST P-384", "secp384r1" },
+ { "NIST P-384", "1.3.132.0.34" },
+
+ { "NIST P-521", "secp521r1" },
+ { "NIST P-521", "1.3.132.0.35" },
+
+ { "brainpoolP160r1", "1.3.36.3.3.2.8.1.1.1" },
+ { "brainpoolP192r1", "1.3.36.3.3.2.8.1.1.3" },
+ { "brainpoolP224r1", "1.3.36.3.3.2.8.1.1.5" },
+ { "brainpoolP256r1", "1.3.36.3.3.2.8.1.1.7" },
+ { "brainpoolP320r1", "1.3.36.3.3.2.8.1.1.9" },
+ { "brainpoolP384r1", "1.3.36.3.3.2.8.1.1.11"},
+ { "brainpoolP512r1", "1.3.36.3.3.2.8.1.1.13"},
+
+ { NULL, NULL}
+ };
+
+typedef struct {
+ const char *desc; /* Description of the curve. */
+ unsigned int nbits; /* Number of bits. */
+ unsigned int fips:1; /* True if this is a FIPS140-2 approved curve. */
+ const char *p; /* Order of the prime field. */
+ const char *a, *b; /* The coefficients. */
+ const char *n; /* The order of the base point. */
+ const char *g_x, *g_y; /* Base point. */
+} ecc_domain_parms_t;
+
+/* This static table defines all available curves. */
+static const ecc_domain_parms_t domain_parms[] =
+ {
+ {
+ "NIST P-192", 192, 1,
+ "0xfffffffffffffffffffffffffffffffeffffffffffffffff",
+ "0xfffffffffffffffffffffffffffffffefffffffffffffffc",
+ "0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
+ "0xffffffffffffffffffffffff99def836146bc9b1b4d22831",
+
+ "0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
+ "0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
+ },
+ {
+ "NIST P-224", 224, 1,
+ "0xffffffffffffffffffffffffffffffff000000000000000000000001",
+ "0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe",
+ "0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4",
+ "0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d" ,
+
+ "0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
+ "0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"
+ },
+ {
+ "NIST P-256", 256, 1,
+ "0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
+ "0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
+ "0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
+ "0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
+
+ "0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
+ "0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
+ },
+ {
+ "NIST P-384", 384, 1,
+ "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
+ "ffffffff0000000000000000ffffffff",
+ "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
+ "ffffffff0000000000000000fffffffc",
+ "0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875a"
+ "c656398d8a2ed19d2a85c8edd3ec2aef",
+ "0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf"
+ "581a0db248b0a77aecec196accc52973",
+
+ "0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a38"
+ "5502f25dbf55296c3a545e3872760ab7",
+ "0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c0"
+ "0a60b1ce1d7e819d7a431d7c90ea0e5f"
+ },
+ {
+ "NIST P-521", 521, 1,
+ "0x01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
+ "0x01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc",
+ "0x051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef10"
+ "9e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00",
+ "0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ "ffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409",
+
+ "0xc6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3d"
+ "baa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66",
+ "0x11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e6"
+ "62c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"
+ },
+
+ { "brainpoolP160r1", 160, 0,
+ "0xe95e4a5f737059dc60dfc7ad95b3d8139515620f",
+ "0x340e7be2a280eb74e2be61bada745d97e8f7c300",
+ "0x1e589a8595423412134faa2dbdec95c8d8675e58",
+ "0xe95e4a5f737059dc60df5991d45029409e60fc09",
+ "0xbed5af16ea3f6a4f62938c4631eb5af7bdbcdbc3",
+ "0x1667cb477a1a8ec338f94741669c976316da6321"
+ },
+
+ { "brainpoolP192r1", 192, 0,
+ "0xc302f41d932a36cda7a3463093d18db78fce476de1a86297",
+ "0x6a91174076b1e0e19c39c031fe8685c1cae040e5c69a28ef",
+ "0x469a28ef7c28cca3dc721d044f4496bcca7ef4146fbf25c9",
+ "0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1",
+ "0xc0a0647eaab6a48753b033c56cb0f0900a2f5c4853375fd6",
+ "0x14b690866abd5bb88b5f4828c1490002e6773fa2fa299b8f"
+ },
+
+ { "brainpoolP224r1", 224, 0,
+ "0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ff",
+ "0x68a5e62ca9ce6c1c299803a6c1530b514e182ad8b0042a59cad29f43",
+ "0x2580f63ccfe44138870713b1a92369e33e2135d266dbb372386c400b",
+ "0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939f",
+ "0x0d9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d",
+ "0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd"
+ },
+
+ { "brainpoolP256r1", 256, 0,
+ "0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377",
+ "0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9",
+ "0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6",
+ "0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7",
+ "0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262",
+ "0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997"
+ },
+
+ { "brainpoolP320r1", 320, 0,
+ "0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28"
+ "fcd412b1f1b32e27",
+ "0x3ee30b568fbab0f883ccebd46d3f3bb8a2a73513f5eb79da66190eb085ffa9f4"
+ "92f375a97d860eb4",
+ "0x520883949dfdbc42d3ad198640688a6fe13f41349554b49acc31dccd88453981"
+ "6f5eb4ac8fb1f1a6",
+ "0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e9"
+ "8691555b44c59311",
+ "0x43bd7e9afb53d8b85289bcc48ee5bfe6f20137d10a087eb6e7871e2a10a599c7"
+ "10af8d0d39e20611",
+ "0x14fdd05545ec1cc8ab4093247f77275e0743ffed117182eaa9c77877aaac6ac7"
+ "d35245d1692e8ee1"
+ },
+
+ { "brainpoolP384r1", 384, 0,
+ "0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123"
+ "acd3a729901d1a71874700133107ec53",
+ "0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f"
+ "8aa5814a503ad4eb04a8c7dd22ce2826",
+ "0x04a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d5"
+ "7cb4390295dbc9943ab78696fa504c11",
+ "0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7"
+ "cf3ab6af6b7fc3103b883202e9046565",
+ "0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8"
+ "e826e03436d646aaef87b2e247d4af1e",
+ "0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff9912928"
+ "0e4646217791811142820341263c5315"
+ },
+
+ { "brainpoolP512r1", 512, 0,
+ "0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330871"
+ "7d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3",
+ "0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc"
+ "2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94ca",
+ "0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a7"
+ "2bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723",
+ "0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870"
+ "553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069",
+ "0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098e"
+ "ff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822",
+ "0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111"
+ "b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892"
+ },
+
+ { NULL, 0, 0, NULL, NULL, NULL, NULL }
+ };
+
+
+/* Registered progress function and its callback value. */
+static void (*progress_cb) (void *, const char*, int, int, int);
+static void *progress_cb_data;
+
+
+#define point_init(a) _gcry_mpi_ec_point_init ((a))
+#define point_free(a) _gcry_mpi_ec_point_free ((a))
+
+
+
+/* Local prototypes. */
+static gcry_mpi_t gen_k (gcry_mpi_t p, int security_level);
+static void test_keys (ECC_secret_key * sk, unsigned int nbits);
+static int check_secret_key (ECC_secret_key * sk);
+static gpg_err_code_t sign (gcry_mpi_t input, ECC_secret_key *skey,
+ gcry_mpi_t r, gcry_mpi_t s);
+static gpg_err_code_t verify (gcry_mpi_t input, ECC_public_key *pkey,
+ gcry_mpi_t r, gcry_mpi_t s);
+
+
+static gcry_mpi_t gen_y_2 (gcry_mpi_t x, elliptic_curve_t * base);
+
+
+
+
+void
+_gcry_register_pk_ecc_progress (void (*cb) (void *, const char *,
+ int, int, int),
+ void *cb_data)
+{
+ progress_cb = cb;
+ progress_cb_data = cb_data;
+}
+
+/* static void */
+/* progress (int c) */
+/* { */
+/* if (progress_cb) */
+/* progress_cb (progress_cb_data, "pk_ecc", c, 0, 0); */
+/* } */
+
+
+
+
+/* Set the value from S into D. */
+static void
+point_set (mpi_point_t *d, mpi_point_t *s)
+{
+ mpi_set (d->x, s->x);
+ mpi_set (d->y, s->y);
+ mpi_set (d->z, s->z);
+}
+
+
+/*
+ * Release a curve object.
+ */
+static void
+curve_free (elliptic_curve_t *E)
+{
+ mpi_free (E->p); E->p = NULL;
+ mpi_free (E->a); E->a = NULL;
+ mpi_free (E->b); E->b = NULL;
+ point_free (&E->G);
+ mpi_free (E->n); E->n = NULL;
+}
+
+
+/*
+ * Return a copy of a curve object.
+ */
+static elliptic_curve_t
+curve_copy (elliptic_curve_t E)
+{
+ elliptic_curve_t R;
+
+ R.p = mpi_copy (E.p);
+ R.a = mpi_copy (E.a);
+ R.b = mpi_copy (E.b);
+ point_init (&R.G);
+ point_set (&R.G, &E.G);
+ R.n = mpi_copy (E.n);
+
+ return R;
+}
+
+
+/* Helper to scan a hex string. */
+static gcry_mpi_t
+scanval (const char *string)
+{
+ gpg_error_t err;
+ gcry_mpi_t val;
+
+ err = gcry_mpi_scan (&val, GCRYMPI_FMT_HEX, string, 0, NULL);
+ if (err)
+ log_fatal ("scanning ECC parameter failed: %s\n", gpg_strerror (err));
+ return val;
+}
+
+
+
+
+
+/****************
+ * Solve the right side of the equation that defines a curve.
+ */
+static gcry_mpi_t
+gen_y_2 (gcry_mpi_t x, elliptic_curve_t *base)
+{
+ gcry_mpi_t three, x_3, axb, y;
+
+ three = mpi_alloc_set_ui (3);
+ x_3 = mpi_new (0);
+ axb = mpi_new (0);
+ y = mpi_new (0);
+
+ mpi_powm (x_3, x, three, base->p);
+ mpi_mulm (axb, base->a, x, base->p);
+ mpi_addm (axb, axb, base->b, base->p);
+ mpi_addm (y, x_3, axb, base->p);
+
+ mpi_free (x_3);
+ mpi_free (axb);
+ mpi_free (three);
+ return y; /* The quadratic value of the coordinate if it exist. */
+}
+
+
+/* Generate a random secret scalar k with an order of p
+
+ At the beginning this was identical to the code is in elgamal.c.
+ Later imporved by mmr. Further simplified by wk. */
+static gcry_mpi_t
+gen_k (gcry_mpi_t p, int security_level)
+{
+ gcry_mpi_t k;
+ unsigned int nbits;
+
+ nbits = mpi_get_nbits (p);
+ k = mpi_snew (nbits);
+ if (DBG_CIPHER)
+ log_debug ("choosing a random k of %u bits at seclevel %d\n",
+ nbits, security_level);
+
+ gcry_mpi_randomize (k, nbits, security_level);
+
+ mpi_mod (k, k, p); /* k = k mod p */
+
+ return k;
+}
+
+
+/* Generate the crypto system setup. This function takes the NAME of
+ a curve or the desired number of bits and stores at R_CURVE the
+ parameters of the named curve or those of a suitable curve. The
+ chosen number of bits is stored on R_NBITS. */
+static gpg_err_code_t
+fill_in_curve (unsigned int nbits, const char *name,
+ elliptic_curve_t *curve, unsigned int *r_nbits)
+{
+ int idx, aliasno;
+ const char *resname = NULL; /* Set to a found curve name. */
+
+ if (name)
+ {
+ /* First check our native curves. */
+ for (idx = 0; domain_parms[idx].desc; idx++)
+ if (!strcmp (name, domain_parms[idx].desc))
+ {
+ resname = domain_parms[idx].desc;
+ break;
+ }
+ /* If not found consult the alias table. */
+ if (!domain_parms[idx].desc)
+ {
+ for (aliasno = 0; curve_aliases[aliasno].name; aliasno++)
+ if (!strcmp (name, curve_aliases[aliasno].other))
+ break;
+ if (curve_aliases[aliasno].name)
+ {
+ for (idx = 0; domain_parms[idx].desc; idx++)
+ if (!strcmp (curve_aliases[aliasno].name,
+ domain_parms[idx].desc))
+ {
+ resname = domain_parms[idx].desc;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ for (idx = 0; domain_parms[idx].desc; idx++)
+ if (nbits == domain_parms[idx].nbits)
+ break;
+ }
+ if (!domain_parms[idx].desc)
+ return GPG_ERR_INV_VALUE;
+
+ /* In fips mode we only support NIST curves. Note that it is
+ possible to bypass this check by specifying the curve parameters
+ directly. */
+ if (fips_mode () && !domain_parms[idx].fips )
+ return GPG_ERR_NOT_SUPPORTED;
+
+ *r_nbits = domain_parms[idx].nbits;
+ curve->p = scanval (domain_parms[idx].p);
+ curve->a = scanval (domain_parms[idx].a);
+ curve->b = scanval (domain_parms[idx].b);
+ curve->n = scanval (domain_parms[idx].n);
+ curve->G.x = scanval (domain_parms[idx].g_x);
+ curve->G.y = scanval (domain_parms[idx].g_y);
+ curve->G.z = mpi_alloc_set_ui (1);
+ curve->name = resname;
+
+ return 0;
+}
+
+
+/*
+ * First obtain the setup. Over the finite field randomize an scalar
+ * secret value, and calculate the public point.
+ */
+static gpg_err_code_t
+generate_key (ECC_secret_key *sk, unsigned int nbits, const char *name,
+ int transient_key,
+ gcry_mpi_t g_x, gcry_mpi_t g_y,
+ gcry_mpi_t q_x, gcry_mpi_t q_y,
+ const char **r_usedcurve)
+{
+ gpg_err_code_t err;
+ elliptic_curve_t E;
+ gcry_mpi_t d;
+ mpi_point_t Q;
+ mpi_ec_t ctx;
+ gcry_random_level_t random_level;
+
+ *r_usedcurve = NULL;
+
+ err = fill_in_curve (nbits, name, &E, &nbits);
+ if (err)
+ return err;
+
+ if (DBG_CIPHER)
+ {
+ log_mpidump ("ecgen curve p", E.p);
+ log_mpidump ("ecgen curve a", E.a);
+ log_mpidump ("ecgen curve b", E.b);
+ log_mpidump ("ecgen curve n", E.n);
+ log_mpidump ("ecgen curve Gx", E.G.x);
+ log_mpidump ("ecgen curve Gy", E.G.y);
+ log_mpidump ("ecgen curve Gz", E.G.z);
+ if (E.name)
+ log_debug ("ecgen curve used: %s\n", E.name);
+ }
+
+ random_level = transient_key ? GCRY_STRONG_RANDOM : GCRY_VERY_STRONG_RANDOM;
+ d = gen_k (E.n, random_level);
+
+ /* Compute Q. */
+ point_init (&Q);
+ ctx = _gcry_mpi_ec_init (E.p, E.a);
+ _gcry_mpi_ec_mul_point (&Q, d, &E.G, ctx);
+
+ /* Copy the stuff to the key structures. */
+ sk->E.p = mpi_copy (E.p);
+ sk->E.a = mpi_copy (E.a);
+ sk->E.b = mpi_copy (E.b);
+ point_init (&sk->E.G);
+ point_set (&sk->E.G, &E.G);
+ sk->E.n = mpi_copy (E.n);
+ point_init (&sk->Q);
+ point_set (&sk->Q, &Q);
+ sk->d = mpi_copy (d);
+ /* We also return copies of G and Q in affine coordinates if
+ requested. */
+ if (g_x && g_y)
+ {
+ if (_gcry_mpi_ec_get_affine (g_x, g_y, &sk->E.G, ctx))
+ log_fatal ("ecgen: Failed to get affine coordinates\n");
+ }
+ if (q_x && q_y)
+ {
+ if (_gcry_mpi_ec_get_affine (q_x, q_y, &sk->Q, ctx))
+ log_fatal ("ecgen: Failed to get affine coordinates\n");
+ }
+ _gcry_mpi_ec_free (ctx);
+
+ point_free (&Q);
+ mpi_free (d);
+
+ *r_usedcurve = E.name;
+ curve_free (&E);
+
+ /* Now we can test our keys (this should never fail!). */
+ test_keys (sk, nbits - 64);
+
+ return 0;
+}
+
+
+/*
+ * To verify correct skey it use a random information.
+ * First, encrypt and decrypt this dummy value,
+ * test if the information is recuperated.
+ * Second, test with the sign and verify functions.
+ */
+static void
+test_keys (ECC_secret_key *sk, unsigned int nbits)
+{
+ ECC_public_key pk;
+ gcry_mpi_t test = mpi_new (nbits);
+ mpi_point_t R_;
+ gcry_mpi_t c = mpi_new (nbits);
+ gcry_mpi_t out = mpi_new (nbits);
+ gcry_mpi_t r = mpi_new (nbits);
+ gcry_mpi_t s = mpi_new (nbits);
+
+ if (DBG_CIPHER)
+ log_debug ("Testing key.\n");
+
+ point_init (&R_);
+
+ pk.E = curve_copy (sk->E);
+ point_init (&pk.Q);
+ point_set (&pk.Q, &sk->Q);
+
+ gcry_mpi_randomize (test, nbits, GCRY_WEAK_RANDOM);
+
+ if (sign (test, sk, r, s) )
+ log_fatal ("ECDSA operation: sign failed\n");
+
+ if (verify (test, &pk, r, s))
+ {
+ log_fatal ("ECDSA operation: sign, verify failed\n");
+ }
+
+ if (DBG_CIPHER)
+ log_debug ("ECDSA operation: sign, verify ok.\n");
+
+ point_free (&pk.Q);
+ curve_free (&pk.E);
+
+ point_free (&R_);
+ mpi_free (s);
+ mpi_free (r);
+ mpi_free (out);
+ mpi_free (c);
+ mpi_free (test);
+}
+
+
+/*
+ * To check the validity of the value, recalculate the correspondence
+ * between the public value and the secret one.
+ */
+static int
+check_secret_key (ECC_secret_key * sk)
+{
+ int rc = 1;
+ mpi_point_t Q;
+ gcry_mpi_t y_2, y2;
+ mpi_ec_t ctx = NULL;
+
+ point_init (&Q);
+
+ /* ?primarity test of 'p' */
+ /* (...) //!! */
+ /* G in E(F_p) */
+ y_2 = gen_y_2 (sk->E.G.x, &sk->E); /* y^2=x^3+a*x+b */
+ y2 = mpi_alloc (0);
+ mpi_mulm (y2, sk->E.G.y, sk->E.G.y, sk->E.p); /* y^2=y*y */
+ if (mpi_cmp (y_2, y2))
+ {
+ if (DBG_CIPHER)
+ log_debug ("Bad check: Point 'G' does not belong to curve 'E'!\n");
+ goto leave;
+ }
+ /* G != PaI */
+ if (!mpi_cmp_ui (sk->E.G.z, 0))
+ {
+ if (DBG_CIPHER)
+ log_debug ("Bad check: 'G' cannot be Point at Infinity!\n");
+ goto leave;
+ }
+
+ ctx = _gcry_mpi_ec_init (sk->E.p, sk->E.a);
+
+ _gcry_mpi_ec_mul_point (&Q, sk->E.n, &sk->E.G, ctx);
+ if (mpi_cmp_ui (Q.z, 0))
+ {
+ if (DBG_CIPHER)
+ log_debug ("check_secret_key: E is not a curve of order n\n");
+ goto leave;
+ }
+ /* pubkey cannot be PaI */
+ if (!mpi_cmp_ui (sk->Q.z, 0))
+ {
+ if (DBG_CIPHER)
+ log_debug ("Bad check: Q can not be a Point at Infinity!\n");
+ goto leave;
+ }
+ /* pubkey = [d]G over E */
+ _gcry_mpi_ec_mul_point (&Q, sk->d, &sk->E.G, ctx);
+ if ((Q.x == sk->Q.x) && (Q.y == sk->Q.y) && (Q.z == sk->Q.z))
+ {
+ if (DBG_CIPHER)
+ log_debug
+ ("Bad check: There is NO correspondence between 'd' and 'Q'!\n");
+ goto leave;
+ }
+ rc = 0; /* Okay. */
+
+ leave:
+ _gcry_mpi_ec_free (ctx);
+ mpi_free (y2);
+ mpi_free (y_2);
+ point_free (&Q);
+ return rc;
+}
+
+
+/*
+ * Return the signature struct (r,s) from the message hash. The caller
+ * must have allocated R and S.
+ */
+static gpg_err_code_t
+sign (gcry_mpi_t input, ECC_secret_key *skey, gcry_mpi_t r, gcry_mpi_t s)
+{
+ gpg_err_code_t err = 0;
+ gcry_mpi_t k, dr, sum, k_1, x;
+ mpi_point_t I;
+ mpi_ec_t ctx;
+
+ if (DBG_CIPHER)
+ log_mpidump ("ecdsa sign hash ", input );
+
+ k = NULL;
+ dr = mpi_alloc (0);
+ sum = mpi_alloc (0);
+ k_1 = mpi_alloc (0);
+ x = mpi_alloc (0);
+ point_init (&I);
+
+ mpi_set_ui (s, 0);
+ mpi_set_ui (r, 0);
+
+ ctx = _gcry_mpi_ec_init (skey->E.p, skey->E.a);
+
+ while (!mpi_cmp_ui (s, 0)) /* s == 0 */
+ {
+ while (!mpi_cmp_ui (r, 0)) /* r == 0 */
+ {
+ /* Note, that we are guaranteed to enter this loop at least
+ once because r has been intialized to 0. We can't use a
+ do_while because we want to keep the value of R even if S
+ has to be recomputed. */
+ mpi_free (k);
+ k = gen_k (skey->E.n, GCRY_STRONG_RANDOM);
+ _gcry_mpi_ec_mul_point (&I, k, &skey->E.G, ctx);
+ if (_gcry_mpi_ec_get_affine (x, NULL, &I, ctx))
+ {
+ if (DBG_CIPHER)
+ log_debug ("ecc sign: Failed to get affine coordinates\n");
+ err = GPG_ERR_BAD_SIGNATURE;
+ goto leave;
+ }
+ mpi_mod (r, x, skey->E.n); /* r = x mod n */
+ }
+ mpi_mulm (dr, skey->d, r, skey->E.n); /* dr = d*r mod n */
+ mpi_addm (sum, input, dr, skey->E.n); /* sum = hash + (d*r) mod n */
+ mpi_invm (k_1, k, skey->E.n); /* k_1 = k^(-1) mod n */
+ mpi_mulm (s, k_1, sum, skey->E.n); /* s = k^(-1)*(hash+(d*r)) mod n */
+ }
+
+ if (DBG_CIPHER)
+ {
+ log_mpidump ("ecdsa sign result r ", r);
+ log_mpidump ("ecdsa sign result s ", s);
+ }
+
+ leave:
+ _gcry_mpi_ec_free (ctx);
+ point_free (&I);
+ mpi_free (x);
+ mpi_free (k_1);
+ mpi_free (sum);
+ mpi_free (dr);
+ mpi_free (k);
+
+ return err;
+}
+
+
+/*
+ * Check if R and S verifies INPUT.
+ */
+static gpg_err_code_t
+verify (gcry_mpi_t input, ECC_public_key *pkey, gcry_mpi_t r, gcry_mpi_t s)
+{
+ gpg_err_code_t err = 0;
+ gcry_mpi_t h, h1, h2, x, y;
+ mpi_point_t Q, Q1, Q2;
+ mpi_ec_t ctx;
+
+ if( !(mpi_cmp_ui (r, 0) > 0 && mpi_cmp (r, pkey->E.n) < 0) )
+ return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < r < n failed. */
+ if( !(mpi_cmp_ui (s, 0) > 0 && mpi_cmp (s, pkey->E.n) < 0) )
+ return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < s < n failed. */
+
+ h = mpi_alloc (0);
+ h1 = mpi_alloc (0);
+ h2 = mpi_alloc (0);
+ x = mpi_alloc (0);
+ y = mpi_alloc (0);
+ point_init (&Q);
+ point_init (&Q1);
+ point_init (&Q2);
+
+ ctx = _gcry_mpi_ec_init (pkey->E.p, pkey->E.a);
+
+ /* h = s^(-1) (mod n) */
+ mpi_invm (h, s, pkey->E.n);
+/* log_mpidump (" h", h); */
+ /* h1 = hash * s^(-1) (mod n) */
+ mpi_mulm (h1, input, h, pkey->E.n);
+/* log_mpidump (" h1", h1); */
+ /* Q1 = [ hash * s^(-1) ]G */
+ _gcry_mpi_ec_mul_point (&Q1, h1, &pkey->E.G, ctx);
+/* log_mpidump ("Q1.x", Q1.x); */
+/* log_mpidump ("Q1.y", Q1.y); */
+/* log_mpidump ("Q1.z", Q1.z); */
+ /* h2 = r * s^(-1) (mod n) */
+ mpi_mulm (h2, r, h, pkey->E.n);
+/* log_mpidump (" h2", h2); */
+ /* Q2 = [ r * s^(-1) ]Q */
+ _gcry_mpi_ec_mul_point (&Q2, h2, &pkey->Q, ctx);
+/* log_mpidump ("Q2.x", Q2.x); */
+/* log_mpidump ("Q2.y", Q2.y); */
+/* log_mpidump ("Q2.z", Q2.z); */
+ /* Q = ([hash * s^(-1)]G) + ([r * s^(-1)]Q) */
+ _gcry_mpi_ec_add_points (&Q, &Q1, &Q2, ctx);
+/* log_mpidump (" Q.x", Q.x); */
+/* log_mpidump (" Q.y", Q.y); */
+/* log_mpidump (" Q.z", Q.z); */
+
+ if (!mpi_cmp_ui (Q.z, 0))
+ {
+ if (DBG_CIPHER)
+ log_debug ("ecc verify: Rejected\n");
+ err = GPG_ERR_BAD_SIGNATURE;
+ goto leave;
+ }
+ if (_gcry_mpi_ec_get_affine (x, y, &Q, ctx))
+ {
+ if (DBG_CIPHER)
+ log_debug ("ecc verify: Failed to get affine coordinates\n");
+ err = GPG_ERR_BAD_SIGNATURE;
+ goto leave;
+ }
+ mpi_mod (x, x, pkey->E.n); /* x = x mod E_n */
+ if (mpi_cmp (x, r)) /* x != r */
+ {
+ if (DBG_CIPHER)
+ {
+ log_mpidump (" x", x);
+ log_mpidump (" y", y);
+ log_mpidump (" r", r);
+ log_mpidump (" s", s);
+ log_debug ("ecc verify: Not verified\n");
+ }
+ err = GPG_ERR_BAD_SIGNATURE;
+ goto leave;
+ }
+ if (DBG_CIPHER)
+ log_debug ("ecc verify: Accepted\n");
+
+ leave:
+ _gcry_mpi_ec_free (ctx);
+ point_free (&Q2);
+ point_free (&Q1);
+ point_free (&Q);
+ mpi_free (y);
+ mpi_free (x);
+ mpi_free (h2);
+ mpi_free (h1);
+ mpi_free (h);
+ return err;
+}
+
+
+
+/*********************************************
+ ************** interface ******************
+ *********************************************/
+static gcry_mpi_t
+ec2os (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t p)
+{
+ gpg_error_t err;
+ int pbytes = (mpi_get_nbits (p)+7)/8;
+ size_t n;
+ unsigned char *buf, *ptr;
+ gcry_mpi_t result;
+
+ buf = gcry_xmalloc ( 1 + 2*pbytes );
+ *buf = 04; /* Uncompressed point. */
+ ptr = buf+1;
+ err = gcry_mpi_print (GCRYMPI_FMT_USG, ptr, pbytes, &n, x);
+ if (err)
+ log_fatal ("mpi_print failed: %s\n", gpg_strerror (err));
+ if (n < pbytes)
+ {
+ memmove (ptr+(pbytes-n), ptr, n);
+ memset (ptr, 0, (pbytes-n));
+ }
+ ptr += pbytes;
+ err = gcry_mpi_print (GCRYMPI_FMT_USG, ptr, pbytes, &n, y);
+ if (err)
+ log_fatal ("mpi_print failed: %s\n", gpg_strerror (err));
+ if (n < pbytes)
+ {
+ memmove (ptr+(pbytes-n), ptr, n);
+ memset (ptr, 0, (pbytes-n));
+ }
+
+ err = gcry_mpi_scan (&result, GCRYMPI_FMT_USG, buf, 1+2*pbytes, NULL);
+ if (err)
+ log_fatal ("mpi_scan failed: %s\n", gpg_strerror (err));
+ gcry_free (buf);
+
+ return result;
+}
+
+
+/* RESULT must have been initialized and is set on success to the
+ point given by VALUE. */
+static gcry_error_t
+os2ec (mpi_point_t *result, gcry_mpi_t value)
+{
+ gcry_error_t err;
+ size_t n;
+ unsigned char *buf;
+ gcry_mpi_t x, y;
+
+ n = (mpi_get_nbits (value)+7)/8;
+ buf = gcry_xmalloc (n);
+ err = gcry_mpi_print (GCRYMPI_FMT_USG, buf, n, &n, value);
+ if (err)
+ {
+ gcry_free (buf);
+ return err;
+ }
+ if (n < 1)
+ {
+ gcry_free (buf);
+ return GPG_ERR_INV_OBJ;
+ }
+ if (*buf != 4)
+ {
+ gcry_free (buf);
+ return GPG_ERR_NOT_IMPLEMENTED; /* No support for point compression. */
+ }
+ if ( ((n-1)%2) )
+ {
+ gcry_free (buf);
+ return GPG_ERR_INV_OBJ;
+ }
+ n = (n-1)/2;
+ err = gcry_mpi_scan (&x, GCRYMPI_FMT_USG, buf+1, n, NULL);
+ if (err)
+ {
+ gcry_free (buf);
+ return err;
+ }
+ err = gcry_mpi_scan (&y, GCRYMPI_FMT_USG, buf+1+n, n, NULL);
+ gcry_free (buf);
+ if (err)
+ {
+ mpi_free (x);
+ return err;
+ }
+
+ mpi_set (result->x, x);
+ mpi_set (result->y, y);
+ mpi_set_ui (result->z, 1);
+
+ mpi_free (x);
+ mpi_free (y);
+
+ return 0;
+}
+
+
+/* Extended version of ecc_generate. */
+static gcry_err_code_t
+ecc_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
+ const gcry_sexp_t genparms,
+ gcry_mpi_t *skey, gcry_mpi_t **retfactors,
+ gcry_sexp_t *r_extrainfo)
+{
+ gpg_err_code_t ec;
+ ECC_secret_key sk;
+ gcry_mpi_t g_x, g_y, q_x, q_y;
+ char *curve_name = NULL;
+ gcry_sexp_t l1;
+ int transient_key = 0;
+ const char *usedcurve = NULL;
+
+ (void)algo;
+ (void)evalue;
+
+ if (genparms)
+ {
+ /* Parse the optional "curve" parameter. */
+ l1 = gcry_sexp_find_token (genparms, "curve", 0);
+ if (l1)
+ {
+ curve_name = _gcry_sexp_nth_string (l1, 1);
+ gcry_sexp_release (l1);
+ if (!curve_name)
+ return GPG_ERR_INV_OBJ; /* No curve name or value too large. */
+ }
+
+ /* Parse the optional transient-key flag. */
+ l1 = gcry_sexp_find_token (genparms, "transient-key", 0);
+ if (l1)
+ {
+ transient_key = 1;
+ gcry_sexp_release (l1);
+ }
+ }
+
+ /* NBITS is required if no curve name has been given. */
+ if (!nbits && !curve_name)
+ return GPG_ERR_NO_OBJ; /* No NBITS parameter. */
+
+ g_x = mpi_new (0);
+ g_y = mpi_new (0);
+ q_x = mpi_new (0);
+ q_y = mpi_new (0);
+ ec = generate_key (&sk, nbits, curve_name, transient_key, g_x, g_y, q_x, q_y,
+ &usedcurve);
+ gcry_free (curve_name);
+ if (ec)
+ return ec;
+ if (usedcurve) /* Fixme: No error return checking. */
+ gcry_sexp_build (r_extrainfo, NULL, "(curve %s)", usedcurve);
+
+ skey[0] = sk.E.p;
+ skey[1] = sk.E.a;
+ skey[2] = sk.E.b;
+ skey[3] = ec2os (g_x, g_y, sk.E.p);
+ skey[4] = sk.E.n;
+ skey[5] = ec2os (q_x, q_y, sk.E.p);
+ skey[6] = sk.d;
+
+ mpi_free (g_x);
+ mpi_free (g_y);
+ mpi_free (q_x);
+ mpi_free (q_y);
+
+ point_free (&sk.E.G);
+ point_free (&sk.Q);
+
+ /* Make an empty list of factors. */
+ *retfactors = gcry_calloc ( 1, sizeof **retfactors );
+ if (!*retfactors)
+ return gpg_err_code_from_syserror (); /* Fixme: relase mem? */
+
+ if (DBG_CIPHER)
+ {
+ log_mpidump ("ecgen result p", skey[0]);
+ log_mpidump ("ecgen result a", skey[1]);
+ log_mpidump ("ecgen result b", skey[2]);
+ log_mpidump ("ecgen result G", skey[3]);
+ log_mpidump ("ecgen result n", skey[4]);
+ log_mpidump ("ecgen result Q", skey[5]);
+ log_mpidump ("ecgen result d", skey[6]);
+ }
+
+ return 0;
+}
+
+
+static gcry_err_code_t
+ecc_generate (int algo, unsigned int nbits, unsigned long evalue,
+ gcry_mpi_t *skey, gcry_mpi_t **retfactors)
+{
+ (void)evalue;
+ return ecc_generate_ext (algo, nbits, 0, NULL, skey, retfactors, NULL);
+}
+
+
+/* Return the parameters of the curve NAME in an MPI array. */
+static gcry_err_code_t
+ecc_get_param (const char *name, gcry_mpi_t *pkey)
+{
+ gpg_err_code_t err;
+ unsigned int nbits;
+ elliptic_curve_t E;
+ mpi_ec_t ctx;
+ gcry_mpi_t g_x, g_y;
+
+ err = fill_in_curve (0, name, &E, &nbits);
+ if (err)
+ return err;
+
+ g_x = mpi_new (0);
+ g_y = mpi_new (0);
+ ctx = _gcry_mpi_ec_init (E.p, E.a);
+ if (_gcry_mpi_ec_get_affine (g_x, g_y, &E.G, ctx))
+ log_fatal ("ecc get param: Failed to get affine coordinates\n");
+ _gcry_mpi_ec_free (ctx);
+ point_free (&E.G);
+
+ pkey[0] = E.p;
+ pkey[1] = E.a;
+ pkey[2] = E.b;
+ pkey[3] = ec2os (g_x, g_y, E.p);
+ pkey[4] = E.n;
+ pkey[5] = NULL;
+
+ mpi_free (g_x);
+ mpi_free (g_y);
+
+ return 0;
+}
+
+
+/* Return the parameters of the curve NAME as an S-expression. */
+static gcry_sexp_t
+ecc_get_param_sexp (const char *name)
+{
+ gcry_mpi_t pkey[6];
+ gcry_sexp_t result;
+ int i;
+
+ if (ecc_get_param (name, pkey))
+ return NULL;
+
+ if (gcry_sexp_build (&result, NULL,
+ "(public-key(ecc(p%m)(a%m)(b%m)(g%m)(n%m)))",
+ pkey[0], pkey[1], pkey[2], pkey[3], pkey[4]))
+ result = NULL;
+
+ for (i=0; pkey[i]; i++)
+ gcry_mpi_release (pkey[i]);
+
+ return result;
+}
+
+
+/* Return the name matching the parameters in PKEY. */
+static const char *
+ecc_get_curve (gcry_mpi_t *pkey, int iterator, unsigned int *r_nbits)
+{
+ gpg_err_code_t err;
+ elliptic_curve_t E;
+ int idx;
+ gcry_mpi_t tmp;
+ const char *result = NULL;
+
+ if (r_nbits)
+ *r_nbits = 0;
+
+ if (!pkey)
+ {
+ idx = iterator;
+ if (idx >= 0 && idx < DIM (domain_parms))
+ {
+ result = domain_parms[idx].desc;
+ if (r_nbits)
+ *r_nbits = domain_parms[idx].nbits;
+ }
+ return result;
+ }
+
+ if (!pkey[0] || !pkey[1] || !pkey[2] || !pkey[3] || !pkey[4])
+ return NULL;
+
+ E.p = pkey[0];
+ E.a = pkey[1];
+ E.b = pkey[2];
+ point_init (&E.G);
+ err = os2ec (&E.G, pkey[3]);
+ if (err)
+ {
+ point_free (&E.G);
+ return NULL;
+ }
+ E.n = pkey[4];
+
+ for (idx = 0; domain_parms[idx].desc; idx++)
+ {
+ tmp = scanval (domain_parms[idx].p);
+ if (!mpi_cmp (tmp, E.p))
+ {
+ mpi_free (tmp);
+ tmp = scanval (domain_parms[idx].a);
+ if (!mpi_cmp (tmp, E.a))
+ {
+ mpi_free (tmp);
+ tmp = scanval (domain_parms[idx].b);
+ if (!mpi_cmp (tmp, E.b))
+ {
+ mpi_free (tmp);
+ tmp = scanval (domain_parms[idx].n);
+ if (!mpi_cmp (tmp, E.n))
+ {
+ mpi_free (tmp);
+ tmp = scanval (domain_parms[idx].g_x);
+ if (!mpi_cmp (tmp, E.G.x))
+ {
+ mpi_free (tmp);
+ tmp = scanval (domain_parms[idx].g_y);
+ if (!mpi_cmp (tmp, E.G.y))
+ {
+ result = domain_parms[idx].desc;
+ if (r_nbits)
+ *r_nbits = domain_parms[idx].nbits;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ mpi_free (tmp);
+ }
+
+ point_free (&E.G);
+
+ return result;
+}
+
+
+static gcry_err_code_t
+ecc_check_secret_key (int algo, gcry_mpi_t *skey)
+{
+ gpg_err_code_t err;
+ ECC_secret_key sk;
+
+ (void)algo;
+
+ /* FIXME: This check looks a bit fishy: Now long is the array? */
+ if (!skey[0] || !skey[1] || !skey[2] || !skey[3] || !skey[4] || !skey[5]
+ || !skey[6])
+ return GPG_ERR_BAD_MPI;
+
+ sk.E.p = skey[0];
+ sk.E.a = skey[1];
+ sk.E.b = skey[2];
+ point_init (&sk.E.G);
+ err = os2ec (&sk.E.G, skey[3]);
+ if (err)
+ {
+ point_free (&sk.E.G);
+ return err;
+ }
+ sk.E.n = skey[4];
+ point_init (&sk.Q);
+ err = os2ec (&sk.Q, skey[5]);
+ if (err)
+ {
+ point_free (&sk.E.G);
+ point_free (&sk.Q);
+ return err;
+ }
+
+ sk.d = skey[6];
+
+ if (check_secret_key (&sk))
+ {
+ point_free (&sk.E.G);
+ point_free (&sk.Q);
+ return GPG_ERR_BAD_SECKEY;
+ }
+ point_free (&sk.E.G);
+ point_free (&sk.Q);
+ return 0;
+}
+
+
+static gcry_err_code_t
+ecc_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey)
+{
+ gpg_err_code_t err;
+ ECC_secret_key sk;
+
+ (void)algo;
+
+ if (!data || !skey[0] || !skey[1] || !skey[2] || !skey[3] || !skey[4]
+ || !skey[5] || !skey[6] )
+ return GPG_ERR_BAD_MPI;
+
+ sk.E.p = skey[0];
+ sk.E.a = skey[1];
+ sk.E.b = skey[2];
+ point_init (&sk.E.G);
+ err = os2ec (&sk.E.G, skey[3]);
+ if (err)
+ {
+ point_free (&sk.E.G);
+ return err;
+ }
+ sk.E.n = skey[4];
+ point_init (&sk.Q);
+ err = os2ec (&sk.Q, skey[5]);
+ if (err)
+ {
+ point_free (&sk.E.G);
+ point_free (&sk.Q);
+ return err;
+ }
+ sk.d = skey[6];
+
+ resarr[0] = mpi_alloc (mpi_get_nlimbs (sk.E.p));
+ resarr[1] = mpi_alloc (mpi_get_nlimbs (sk.E.p));
+ err = sign (data, &sk, resarr[0], resarr[1]);
+ if (err)
+ {
+ mpi_free (resarr[0]);
+ mpi_free (resarr[1]);
+ resarr[0] = NULL; /* Mark array as released. */
+ }
+ point_free (&sk.E.G);
+ point_free (&sk.Q);
+ return err;
+}
+
+
+static gcry_err_code_t
+ecc_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey,
+ int (*cmp)(void *, gcry_mpi_t), void *opaquev)
+{
+ gpg_err_code_t err;
+ ECC_public_key pk;
+
+ (void)algo;
+ (void)cmp;
+ (void)opaquev;
+
+ if (!data[0] || !data[1] || !hash || !pkey[0] || !pkey[1] || !pkey[2]
+ || !pkey[3] || !pkey[4] || !pkey[5] )
+ return GPG_ERR_BAD_MPI;
+
+ pk.E.p = pkey[0];
+ pk.E.a = pkey[1];
+ pk.E.b = pkey[2];
+ point_init (&pk.E.G);
+ err = os2ec (&pk.E.G, pkey[3]);
+ if (err)
+ {
+ point_free (&pk.E.G);
+ return err;
+ }
+ pk.E.n = pkey[4];
+ point_init (&pk.Q);
+ err = os2ec (&pk.Q, pkey[5]);
+ if (err)
+ {
+ point_free (&pk.E.G);
+ point_free (&pk.Q);
+ return err;
+ }
+
+ err = verify (hash, &pk, data[0], data[1]);
+
+ point_free (&pk.E.G);
+ point_free (&pk.Q);
+ return err;
+}
+
+
+/* ecdh raw is classic 2-round DH protocol published in 1976.
+ *
+ * Overview of ecc_encrypt_raw and ecc_decrypt_raw.
+ *
+ * As with any PK operation, encrypt version uses a public key and
+ * decrypt -- private.
+ *
+ * Symbols used below:
+ * G - field generator point
+ * d - private long-term scalar
+ * dG - public long-term key
+ * k - ephemeral scalar
+ * kG - ephemeral public key
+ * dkG - shared secret
+ *
+ * ecc_encrypt_raw description:
+ * input:
+ * data[0] : private scalar (k)
+ * output:
+ * result[0] : shared point (kdG)
+ * result[1] : generated ephemeral public key (kG)
+ *
+ * ecc_decrypt_raw description:
+ * input:
+ * data[0] : a point kG (ephemeral public key)
+ * output:
+ * result[0] : shared point (kdG)
+ */
+static gcry_err_code_t
+ecc_encrypt_raw (int algo, gcry_mpi_t *resarr, gcry_mpi_t k,
+ gcry_mpi_t *pkey, int flags)
+{
+ ECC_public_key pk;
+ mpi_ec_t ctx;
+ gcry_mpi_t result[2];
+ int err;
+
+ (void)algo;
+ (void)flags;
+
+ if (!k
+ || !pkey[0] || !pkey[1] || !pkey[2] || !pkey[3] || !pkey[4] || !pkey[5])
+ return GPG_ERR_BAD_MPI;
+
+ pk.E.p = pkey[0];
+ pk.E.a = pkey[1];
+ pk.E.b = pkey[2];
+ point_init (&pk.E.G);
+ err = os2ec (&pk.E.G, pkey[3]);
+ if (err)
+ {
+ point_free (&pk.E.G);
+ return err;
+ }
+ pk.E.n = pkey[4];
+ point_init (&pk.Q);
+ err = os2ec (&pk.Q, pkey[5]);
+ if (err)
+ {
+ point_free (&pk.E.G);
+ point_free (&pk.Q);
+ return err;
+ }
+
+ ctx = _gcry_mpi_ec_init (pk.E.p, pk.E.a);
+
+ /* The following is false: assert( mpi_cmp_ui( R.x, 1 )==0 );, so */
+ {
+ mpi_point_t R; /* Result that we return. */
+ gcry_mpi_t x, y;
+
+ x = mpi_new (0);
+ y = mpi_new (0);
+
+ point_init (&R);
+
+ /* R = kQ <=> R = kdG */
+ _gcry_mpi_ec_mul_point (&R, k, &pk.Q, ctx);
+
+ if (_gcry_mpi_ec_get_affine (x, y, &R, ctx))
+ log_fatal ("ecdh: Failed to get affine coordinates for kdG\n");
+
+ result[0] = ec2os (x, y, pk.E.p);
+
+ /* R = kG */
+ _gcry_mpi_ec_mul_point (&R, k, &pk.E.G, ctx);
+
+ if (_gcry_mpi_ec_get_affine (x, y, &R, ctx))
+ log_fatal ("ecdh: Failed to get affine coordinates for kG\n");
+
+ result[1] = ec2os (x, y, pk.E.p);
+
+ mpi_free (x);
+ mpi_free (y);
+
+ point_free (&R);
+ }
+
+ _gcry_mpi_ec_free (ctx);
+ point_free (&pk.E.G);
+ point_free (&pk.Q);
+
+ if (!result[0] || !result[1])
+ {
+ mpi_free (result[0]);
+ mpi_free (result[1]);
+ return GPG_ERR_ENOMEM;
+ }
+
+ /* Success. */
+ resarr[0] = result[0];
+ resarr[1] = result[1];
+
+ return 0;
+}
+
+/* input:
+ * data[0] : a point kG (ephemeral public key)
+ * output:
+ * resaddr[0] : shared point kdG
+ *
+ * see ecc_encrypt_raw for details.
+ */
+static gcry_err_code_t
+ecc_decrypt_raw (int algo, gcry_mpi_t *result, gcry_mpi_t *data,
+ gcry_mpi_t *skey, int flags)
+{
+ ECC_secret_key sk;
+ mpi_point_t R; /* Result that we return. */
+ mpi_point_t kG;
+ mpi_ec_t ctx;
+ gcry_mpi_t r;
+ int err;
+
+ (void)algo;
+ (void)flags;
+
+ *result = NULL;
+
+ if (!data || !data[0]
+ || !skey[0] || !skey[1] || !skey[2] || !skey[3] || !skey[4]
+ || !skey[5] || !skey[6] )
+ return GPG_ERR_BAD_MPI;
+
+ point_init (&kG);
+ err = os2ec (&kG, data[0]);
+ if (err)
+ {
+ point_free (&kG);
+ return err;
+ }
+
+
+ sk.E.p = skey[0];
+ sk.E.a = skey[1];
+ sk.E.b = skey[2];
+ point_init (&sk.E.G);
+ err = os2ec (&sk.E.G, skey[3]);
+ if (err)
+ {
+ point_free (&kG);
+ point_free (&sk.E.G);
+ return err;
+ }
+ sk.E.n = skey[4];
+ point_init (&sk.Q);
+ err = os2ec (&sk.Q, skey[5]);
+ if (err)
+ {
+ point_free (&kG);
+ point_free (&sk.E.G);
+ point_free (&sk.Q);
+ return err;
+ }
+ sk.d = skey[6];
+
+ ctx = _gcry_mpi_ec_init (sk.E.p, sk.E.a);
+
+ /* R = dkG */
+ point_init (&R);
+ _gcry_mpi_ec_mul_point (&R, sk.d, &kG, ctx);
+
+ point_free (&kG);
+
+ /* The following is false: assert( mpi_cmp_ui( R.x, 1 )==0 );, so: */
+ {
+ gcry_mpi_t x, y;
+
+ x = mpi_new (0);
+ y = mpi_new (0);
+
+ if (_gcry_mpi_ec_get_affine (x, y, &R, ctx))
+ log_fatal ("ecdh: Failed to get affine coordinates\n");
+
+ r = ec2os (x, y, sk.E.p);
+ mpi_free (x);
+ mpi_free (y);
+ }
+
+ point_free (&R);
+ _gcry_mpi_ec_free (ctx);
+ point_free (&kG);
+ point_free (&sk.E.G);
+ point_free (&sk.Q);
+
+ if (!r)
+ return GPG_ERR_ENOMEM;
+
+ /* Success. */
+
+ *result = r;
+
+ return 0;
+}
+
+
+static unsigned int
+ecc_get_nbits (int algo, gcry_mpi_t *pkey)
+{
+ (void)algo;
+
+ return mpi_get_nbits (pkey[0]);
+}
+
+
+/* See rsa.c for a description of this function. */
+static gpg_err_code_t
+compute_keygrip (gcry_md_hd_t md, gcry_sexp_t keyparam)
+{
+#define N_COMPONENTS 6
+ static const char names[N_COMPONENTS+1] = "pabgnq";
+ gpg_err_code_t ec = 0;
+ gcry_sexp_t l1;
+ gcry_mpi_t values[N_COMPONENTS];
+ int idx;
+
+ /* Clear the values for easier error cleanup. */
+ for (idx=0; idx < N_COMPONENTS; idx++)
+ values[idx] = NULL;
+
+ /* Fill values with all provided parameters. */
+ for (idx=0; idx < N_COMPONENTS; idx++)
+ {
+ l1 = gcry_sexp_find_token (keyparam, names+idx, 1);
+ if (l1)
+ {
+ values[idx] = gcry_sexp_nth_mpi (l1, 1, GCRYMPI_FMT_USG);
+ gcry_sexp_release (l1);
+ if (!values[idx])
+ {
+ ec = GPG_ERR_INV_OBJ;
+ goto leave;
+ }
+ }
+ }
+
+ /* Check whether a curve parameter is available and use that to fill
+ in missing values. */
+ l1 = gcry_sexp_find_token (keyparam, "curve", 5);
+ if (l1)
+ {
+ char *curve;
+ gcry_mpi_t tmpvalues[N_COMPONENTS];
+
+ for (idx = 0; idx < N_COMPONENTS; idx++)
+ tmpvalues[idx] = NULL;
+
+ curve = _gcry_sexp_nth_string (l1, 1);
+ gcry_sexp_release (l1);
+ if (!curve)
+ {
+ ec = GPG_ERR_INV_OBJ; /* Name missing or out of core. */
+ goto leave;
+ }
+ ec = ecc_get_param (curve, tmpvalues);
+ gcry_free (curve);
+ if (ec)
+ goto leave;
+
+ for (idx = 0; idx < N_COMPONENTS; idx++)
+ {
+ if (!values[idx])
+ values[idx] = tmpvalues[idx];
+ else
+ mpi_free (tmpvalues[idx]);
+ }
+ }
+
+ /* Check that all parameters are known and normalize all MPIs (that
+ should not be required but we use an internal function later and
+ thus we better make 100% sure that they are normalized). */
+ for (idx = 0; idx < N_COMPONENTS; idx++)
+ if (!values[idx])
+ {
+ ec = GPG_ERR_NO_OBJ;
+ goto leave;
+ }
+ else
+ _gcry_mpi_normalize (values[idx]);
+
+ /* Hash them all. */
+ for (idx = 0; idx < N_COMPONENTS; idx++)
+ {
+ char buf[30];
+ unsigned char *rawmpi;
+ unsigned int rawmpilen;
+
+ rawmpi = _gcry_mpi_get_buffer (values[idx], &rawmpilen, NULL);
+ if (!rawmpi)
+ {
+ ec = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ snprintf (buf, sizeof buf, "(1:%c%u:", names[idx], rawmpilen);
+ gcry_md_write (md, buf, strlen (buf));
+ gcry_md_write (md, rawmpi, rawmpilen);
+ gcry_md_write (md, ")", 1);
+ gcry_free (rawmpi);
+ }
+
+ leave:
+ for (idx = 0; idx < N_COMPONENTS; idx++)
+ _gcry_mpi_release (values[idx]);
+
+ return ec;
+#undef N_COMPONENTS
+}
+
+
+
+
+
+/*
+ Self-test section.
+ */
+
+
+static gpg_err_code_t
+selftests_ecdsa (selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+
+ what = "low-level";
+ errtxt = NULL; /*selftest ();*/
+ if (errtxt)
+ goto failed;
+
+ /* FIXME: need more tests. */
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("pubkey", GCRY_PK_ECDSA, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+static gpg_err_code_t
+run_selftests (int algo, int extended, selftest_report_func_t report)
+{
+ gpg_err_code_t ec;
+
+ (void)extended;
+
+ switch (algo)
+ {
+ case GCRY_PK_ECDSA:
+ ec = selftests_ecdsa (report);
+ break;
+ default:
+ ec = GPG_ERR_PUBKEY_ALGO;
+ break;
+
+ }
+ return ec;
+}
+
+
+
+
+static const char *ecdsa_names[] =
+ {
+ "ecdsa",
+ "ecc",
+ NULL,
+ };
+static const char *ecdh_names[] =
+ {
+ "ecdh",
+ "ecc",
+ NULL,
+ };
+
+gcry_pk_spec_t _gcry_pubkey_spec_ecdsa =
+ {
+ "ECDSA", ecdsa_names,
+ "pabgnq", "pabgnqd", "", "rs", "pabgnq",
+ GCRY_PK_USAGE_SIGN,
+ ecc_generate,
+ ecc_check_secret_key,
+ NULL,
+ NULL,
+ ecc_sign,
+ ecc_verify,
+ ecc_get_nbits
+ };
+
+gcry_pk_spec_t _gcry_pubkey_spec_ecdh =
+ {
+ "ECDH", ecdh_names,
+ "pabgnq", "pabgnqd", "se", "", "pabgnq",
+ GCRY_PK_USAGE_ENCR,
+ ecc_generate,
+ ecc_check_secret_key,
+ ecc_encrypt_raw,
+ ecc_decrypt_raw,
+ NULL,
+ NULL,
+ ecc_get_nbits
+ };
+
+
+pk_extra_spec_t _gcry_pubkey_extraspec_ecdsa =
+ {
+ run_selftests,
+ ecc_generate_ext,
+ compute_keygrip,
+ ecc_get_param,
+ ecc_get_curve,
+ ecc_get_param_sexp
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/elgamal.c b/grub-core/lib/libgcrypt/cipher/elgamal.c
new file mode 100644
index 0000000..ce4be85
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/elgamal.c
@@ -0,0 +1,845 @@
+/* Elgamal.c - Elgamal Public Key encryption
+ * Copyright (C) 1998, 2000, 2001, 2002, 2003,
+ * 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * For a description of the algorithm, see:
+ * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996.
+ * ISBN 0-471-11709-9. Pages 476 ff.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "g10lib.h"
+#include "mpi.h"
+#include "cipher.h"
+
+typedef struct
+{
+ gcry_mpi_t p; /* prime */
+ gcry_mpi_t g; /* group generator */
+ gcry_mpi_t y; /* g^x mod p */
+} ELG_public_key;
+
+
+typedef struct
+{
+ gcry_mpi_t p; /* prime */
+ gcry_mpi_t g; /* group generator */
+ gcry_mpi_t y; /* g^x mod p */
+ gcry_mpi_t x; /* secret exponent */
+} ELG_secret_key;
+
+
+static int test_keys (ELG_secret_key *sk, unsigned int nbits, int nodie);
+static gcry_mpi_t gen_k (gcry_mpi_t p, int small_k);
+static void generate (ELG_secret_key *sk, unsigned nbits, gcry_mpi_t **factors);
+static int check_secret_key (ELG_secret_key *sk);
+static void do_encrypt (gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input,
+ ELG_public_key *pkey);
+static void decrypt (gcry_mpi_t output, gcry_mpi_t a, gcry_mpi_t b,
+ ELG_secret_key *skey);
+static void sign (gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input,
+ ELG_secret_key *skey);
+static int verify (gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input,
+ ELG_public_key *pkey);
+
+
+static void (*progress_cb) (void *, const char *, int, int, int);
+static void *progress_cb_data;
+
+void
+_gcry_register_pk_elg_progress (void (*cb) (void *, const char *,
+ int, int, int),
+ void *cb_data)
+{
+ progress_cb = cb;
+ progress_cb_data = cb_data;
+}
+
+
+static void
+progress (int c)
+{
+ if (progress_cb)
+ progress_cb (progress_cb_data, "pk_elg", c, 0, 0);
+}
+
+
+/****************
+ * Michael Wiener's table on subgroup sizes to match field sizes.
+ * (floating around somewhere, probably based on the paper from
+ * Eurocrypt 96, page 332)
+ */
+static unsigned int
+wiener_map( unsigned int n )
+{
+ static struct { unsigned int p_n, q_n; } t[] =
+ { /* p q attack cost */
+ { 512, 119 }, /* 9 x 10^17 */
+ { 768, 145 }, /* 6 x 10^21 */
+ { 1024, 165 }, /* 7 x 10^24 */
+ { 1280, 183 }, /* 3 x 10^27 */
+ { 1536, 198 }, /* 7 x 10^29 */
+ { 1792, 212 }, /* 9 x 10^31 */
+ { 2048, 225 }, /* 8 x 10^33 */
+ { 2304, 237 }, /* 5 x 10^35 */
+ { 2560, 249 }, /* 3 x 10^37 */
+ { 2816, 259 }, /* 1 x 10^39 */
+ { 3072, 269 }, /* 3 x 10^40 */
+ { 3328, 279 }, /* 8 x 10^41 */
+ { 3584, 288 }, /* 2 x 10^43 */
+ { 3840, 296 }, /* 4 x 10^44 */
+ { 4096, 305 }, /* 7 x 10^45 */
+ { 4352, 313 }, /* 1 x 10^47 */
+ { 4608, 320 }, /* 2 x 10^48 */
+ { 4864, 328 }, /* 2 x 10^49 */
+ { 5120, 335 }, /* 3 x 10^50 */
+ { 0, 0 }
+ };
+ int i;
+
+ for(i=0; t[i].p_n; i++ )
+ {
+ if( n <= t[i].p_n )
+ return t[i].q_n;
+ }
+ /* Not in table - use an arbitrary high number. */
+ return n / 8 + 200;
+}
+
+static int
+test_keys ( ELG_secret_key *sk, unsigned int nbits, int nodie )
+{
+ ELG_public_key pk;
+ gcry_mpi_t test = gcry_mpi_new ( 0 );
+ gcry_mpi_t out1_a = gcry_mpi_new ( nbits );
+ gcry_mpi_t out1_b = gcry_mpi_new ( nbits );
+ gcry_mpi_t out2 = gcry_mpi_new ( nbits );
+ int failed = 0;
+
+ pk.p = sk->p;
+ pk.g = sk->g;
+ pk.y = sk->y;
+
+ gcry_mpi_randomize ( test, nbits, GCRY_WEAK_RANDOM );
+
+ do_encrypt ( out1_a, out1_b, test, &pk );
+ decrypt ( out2, out1_a, out1_b, sk );
+ if ( mpi_cmp( test, out2 ) )
+ failed |= 1;
+
+ sign ( out1_a, out1_b, test, sk );
+ if ( !verify( out1_a, out1_b, test, &pk ) )
+ failed |= 2;
+
+ gcry_mpi_release ( test );
+ gcry_mpi_release ( out1_a );
+ gcry_mpi_release ( out1_b );
+ gcry_mpi_release ( out2 );
+
+ if (failed && !nodie)
+ log_fatal ("Elgamal test key for %s %s failed\n",
+ (failed & 1)? "encrypt+decrypt":"",
+ (failed & 2)? "sign+verify":"");
+ if (failed && DBG_CIPHER)
+ log_debug ("Elgamal test key for %s %s failed\n",
+ (failed & 1)? "encrypt+decrypt":"",
+ (failed & 2)? "sign+verify":"");
+
+ return failed;
+}
+
+
+/****************
+ * Generate a random secret exponent k from prime p, so that k is
+ * relatively prime to p-1. With SMALL_K set, k will be selected for
+ * better encryption performance - this must never be used signing!
+ */
+static gcry_mpi_t
+gen_k( gcry_mpi_t p, int small_k )
+{
+ gcry_mpi_t k = mpi_alloc_secure( 0 );
+ gcry_mpi_t temp = mpi_alloc( mpi_get_nlimbs(p) );
+ gcry_mpi_t p_1 = mpi_copy(p);
+ unsigned int orig_nbits = mpi_get_nbits(p);
+ unsigned int nbits, nbytes;
+ char *rndbuf = NULL;
+
+ if (small_k)
+ {
+ /* Using a k much lesser than p is sufficient for encryption and
+ * it greatly improves the encryption performance. We use
+ * Wiener's table and add a large safety margin. */
+ nbits = wiener_map( orig_nbits ) * 3 / 2;
+ if( nbits >= orig_nbits )
+ BUG();
+ }
+ else
+ nbits = orig_nbits;
+
+
+ nbytes = (nbits+7)/8;
+ if( DBG_CIPHER )
+ log_debug("choosing a random k ");
+ mpi_sub_ui( p_1, p, 1);
+ for(;;)
+ {
+ if( !rndbuf || nbits < 32 )
+ {
+ gcry_free(rndbuf);
+ rndbuf = gcry_random_bytes_secure( nbytes, GCRY_STRONG_RANDOM );
+ }
+ else
+ {
+ /* Change only some of the higher bits. We could improve
+ this by directly requesting more memory at the first call
+ to get_random_bytes() and use this the here maybe it is
+ easier to do this directly in random.c Anyway, it is
+ highly inlikely that we will ever reach this code. */
+ char *pp = gcry_random_bytes_secure( 4, GCRY_STRONG_RANDOM );
+ memcpy( rndbuf, pp, 4 );
+ gcry_free(pp);
+ }
+ _gcry_mpi_set_buffer( k, rndbuf, nbytes, 0 );
+
+ for(;;)
+ {
+ if( !(mpi_cmp( k, p_1 ) < 0) ) /* check: k < (p-1) */
+ {
+ if( DBG_CIPHER )
+ progress('+');
+ break; /* no */
+ }
+ if( !(mpi_cmp_ui( k, 0 ) > 0) ) /* check: k > 0 */
+ {
+ if( DBG_CIPHER )
+ progress('-');
+ break; /* no */
+ }
+ if (gcry_mpi_gcd( temp, k, p_1 ))
+ goto found; /* okay, k is relative prime to (p-1) */
+ mpi_add_ui( k, k, 1 );
+ if( DBG_CIPHER )
+ progress('.');
+ }
+ }
+ found:
+ gcry_free(rndbuf);
+ if( DBG_CIPHER )
+ progress('\n');
+ mpi_free(p_1);
+ mpi_free(temp);
+
+ return k;
+}
+
+/****************
+ * Generate a key pair with a key of size NBITS
+ * Returns: 2 structures filled with all needed values
+ * and an array with n-1 factors of (p-1)
+ */
+static void
+generate ( ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t **ret_factors )
+{
+ gcry_mpi_t p; /* the prime */
+ gcry_mpi_t p_min1;
+ gcry_mpi_t g;
+ gcry_mpi_t x; /* the secret exponent */
+ gcry_mpi_t y;
+ unsigned int qbits;
+ unsigned int xbits;
+ byte *rndbuf;
+
+ p_min1 = gcry_mpi_new ( nbits );
+ qbits = wiener_map( nbits );
+ if( qbits & 1 ) /* better have a even one */
+ qbits++;
+ g = mpi_alloc(1);
+ p = _gcry_generate_elg_prime( 0, nbits, qbits, g, ret_factors );
+ mpi_sub_ui(p_min1, p, 1);
+
+
+ /* Select a random number which has these properties:
+ * 0 < x < p-1
+ * This must be a very good random number because this is the
+ * secret part. The prime is public and may be shared anyway,
+ * so a random generator level of 1 is used for the prime.
+ *
+ * I don't see a reason to have a x of about the same size
+ * as the p. It should be sufficient to have one about the size
+ * of q or the later used k plus a large safety margin. Decryption
+ * will be much faster with such an x.
+ */
+ xbits = qbits * 3 / 2;
+ if( xbits >= nbits )
+ BUG();
+ x = gcry_mpi_snew ( xbits );
+ if( DBG_CIPHER )
+ log_debug("choosing a random x of size %u", xbits );
+ rndbuf = NULL;
+ do
+ {
+ if( DBG_CIPHER )
+ progress('.');
+ if( rndbuf )
+ { /* Change only some of the higher bits */
+ if( xbits < 16 ) /* should never happen ... */
+ {
+ gcry_free(rndbuf);
+ rndbuf = gcry_random_bytes_secure( (xbits+7)/8,
+ GCRY_VERY_STRONG_RANDOM );
+ }
+ else
+ {
+ char *r = gcry_random_bytes_secure( 2,
+ GCRY_VERY_STRONG_RANDOM );
+ memcpy(rndbuf, r, 2 );
+ gcry_free(r);
+ }
+ }
+ else
+ {
+ rndbuf = gcry_random_bytes_secure( (xbits+7)/8,
+ GCRY_VERY_STRONG_RANDOM );
+ }
+ _gcry_mpi_set_buffer( x, rndbuf, (xbits+7)/8, 0 );
+ mpi_clear_highbit( x, xbits+1 );
+ }
+ while( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, p_min1 )<0 ) );
+ gcry_free(rndbuf);
+
+ y = gcry_mpi_new (nbits);
+ gcry_mpi_powm( y, g, x, p );
+
+ if( DBG_CIPHER )
+ {
+ progress('\n');
+ log_mpidump("elg p= ", p );
+ log_mpidump("elg g= ", g );
+ log_mpidump("elg y= ", y );
+ log_mpidump("elg x= ", x );
+ }
+
+ /* Copy the stuff to the key structures */
+ sk->p = p;
+ sk->g = g;
+ sk->y = y;
+ sk->x = x;
+
+ gcry_mpi_release ( p_min1 );
+
+ /* Now we can test our keys (this should never fail!) */
+ test_keys ( sk, nbits - 64, 0 );
+}
+
+
+/* Generate a key pair with a key of size NBITS not using a random
+ value for the secret key but the one given as X. This is useful to
+ implement a passphrase based decryption for a public key based
+ encryption. It has appliactions in backup systems.
+
+ Returns: A structure filled with all needed values and an array
+ with n-1 factors of (p-1). */
+static gcry_err_code_t
+generate_using_x (ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t x,
+ gcry_mpi_t **ret_factors )
+{
+ gcry_mpi_t p; /* The prime. */
+ gcry_mpi_t p_min1; /* The prime minus 1. */
+ gcry_mpi_t g; /* The generator. */
+ gcry_mpi_t y; /* g^x mod p. */
+ unsigned int qbits;
+ unsigned int xbits;
+
+ sk->p = NULL;
+ sk->g = NULL;
+ sk->y = NULL;
+ sk->x = NULL;
+
+ /* Do a quick check to see whether X is suitable. */
+ xbits = mpi_get_nbits (x);
+ if ( xbits < 64 || xbits >= nbits )
+ return GPG_ERR_INV_VALUE;
+
+ p_min1 = gcry_mpi_new ( nbits );
+ qbits = wiener_map ( nbits );
+ if ( (qbits & 1) ) /* Better have an even one. */
+ qbits++;
+ g = mpi_alloc (1);
+ p = _gcry_generate_elg_prime ( 0, nbits, qbits, g, ret_factors );
+ mpi_sub_ui (p_min1, p, 1);
+
+ if (DBG_CIPHER)
+ log_debug ("using a supplied x of size %u", xbits );
+ if ( !(mpi_cmp_ui ( x, 0 ) > 0 && mpi_cmp ( x, p_min1 ) <0 ) )
+ {
+ gcry_mpi_release ( p_min1 );
+ gcry_mpi_release ( p );
+ gcry_mpi_release ( g );
+ return GPG_ERR_INV_VALUE;
+ }
+
+ y = gcry_mpi_new (nbits);
+ gcry_mpi_powm ( y, g, x, p );
+
+ if ( DBG_CIPHER )
+ {
+ progress ('\n');
+ log_mpidump ("elg p= ", p );
+ log_mpidump ("elg g= ", g );
+ log_mpidump ("elg y= ", y );
+ log_mpidump ("elg x= ", x );
+ }
+
+ /* Copy the stuff to the key structures */
+ sk->p = p;
+ sk->g = g;
+ sk->y = y;
+ sk->x = gcry_mpi_copy (x);
+
+ gcry_mpi_release ( p_min1 );
+
+ /* Now we can test our keys. */
+ if ( test_keys ( sk, nbits - 64, 1 ) )
+ {
+ gcry_mpi_release ( sk->p ); sk->p = NULL;
+ gcry_mpi_release ( sk->g ); sk->g = NULL;
+ gcry_mpi_release ( sk->y ); sk->y = NULL;
+ gcry_mpi_release ( sk->x ); sk->x = NULL;
+ return GPG_ERR_BAD_SECKEY;
+ }
+
+ return 0;
+}
+
+
+/****************
+ * Test whether the secret key is valid.
+ * Returns: if this is a valid key.
+ */
+static int
+check_secret_key( ELG_secret_key *sk )
+{
+ int rc;
+ gcry_mpi_t y = mpi_alloc( mpi_get_nlimbs(sk->y) );
+
+ gcry_mpi_powm( y, sk->g, sk->x, sk->p );
+ rc = !mpi_cmp( y, sk->y );
+ mpi_free( y );
+ return rc;
+}
+
+
+static void
+do_encrypt(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_public_key *pkey )
+{
+ gcry_mpi_t k;
+
+ /* Note: maybe we should change the interface, so that it
+ * is possible to check that input is < p and return an
+ * error code.
+ */
+
+ k = gen_k( pkey->p, 1 );
+ gcry_mpi_powm( a, pkey->g, k, pkey->p );
+ /* b = (y^k * input) mod p
+ * = ((y^k mod p) * (input mod p)) mod p
+ * and because input is < p
+ * = ((y^k mod p) * input) mod p
+ */
+ gcry_mpi_powm( b, pkey->y, k, pkey->p );
+ gcry_mpi_mulm( b, b, input, pkey->p );
+#if 0
+ if( DBG_CIPHER )
+ {
+ log_mpidump("elg encrypted y= ", pkey->y);
+ log_mpidump("elg encrypted p= ", pkey->p);
+ log_mpidump("elg encrypted k= ", k);
+ log_mpidump("elg encrypted M= ", input);
+ log_mpidump("elg encrypted a= ", a);
+ log_mpidump("elg encrypted b= ", b);
+ }
+#endif
+ mpi_free(k);
+}
+
+
+
+
+static void
+decrypt(gcry_mpi_t output, gcry_mpi_t a, gcry_mpi_t b, ELG_secret_key *skey )
+{
+ gcry_mpi_t t1 = mpi_alloc_secure( mpi_get_nlimbs( skey->p ) );
+
+ /* output = b/(a^x) mod p */
+ gcry_mpi_powm( t1, a, skey->x, skey->p );
+ mpi_invm( t1, t1, skey->p );
+ mpi_mulm( output, b, t1, skey->p );
+#if 0
+ if( DBG_CIPHER )
+ {
+ log_mpidump("elg decrypted x= ", skey->x);
+ log_mpidump("elg decrypted p= ", skey->p);
+ log_mpidump("elg decrypted a= ", a);
+ log_mpidump("elg decrypted b= ", b);
+ log_mpidump("elg decrypted M= ", output);
+ }
+#endif
+ mpi_free(t1);
+}
+
+
+/****************
+ * Make an Elgamal signature out of INPUT
+ */
+
+static void
+sign(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_secret_key *skey )
+{
+ gcry_mpi_t k;
+ gcry_mpi_t t = mpi_alloc( mpi_get_nlimbs(a) );
+ gcry_mpi_t inv = mpi_alloc( mpi_get_nlimbs(a) );
+ gcry_mpi_t p_1 = mpi_copy(skey->p);
+
+ /*
+ * b = (t * inv) mod (p-1)
+ * b = (t * inv(k,(p-1),(p-1)) mod (p-1)
+ * b = (((M-x*a) mod (p-1)) * inv(k,(p-1),(p-1))) mod (p-1)
+ *
+ */
+ mpi_sub_ui(p_1, p_1, 1);
+ k = gen_k( skey->p, 0 /* no small K ! */ );
+ gcry_mpi_powm( a, skey->g, k, skey->p );
+ mpi_mul(t, skey->x, a );
+ mpi_subm(t, input, t, p_1 );
+ mpi_invm(inv, k, p_1 );
+ mpi_mulm(b, t, inv, p_1 );
+
+#if 0
+ if( DBG_CIPHER )
+ {
+ log_mpidump("elg sign p= ", skey->p);
+ log_mpidump("elg sign g= ", skey->g);
+ log_mpidump("elg sign y= ", skey->y);
+ log_mpidump("elg sign x= ", skey->x);
+ log_mpidump("elg sign k= ", k);
+ log_mpidump("elg sign M= ", input);
+ log_mpidump("elg sign a= ", a);
+ log_mpidump("elg sign b= ", b);
+ }
+#endif
+ mpi_free(k);
+ mpi_free(t);
+ mpi_free(inv);
+ mpi_free(p_1);
+}
+
+
+/****************
+ * Returns true if the signature composed of A and B is valid.
+ */
+static int
+verify(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_public_key *pkey )
+{
+ int rc;
+ gcry_mpi_t t1;
+ gcry_mpi_t t2;
+ gcry_mpi_t base[4];
+ gcry_mpi_t ex[4];
+
+ if( !(mpi_cmp_ui( a, 0 ) > 0 && mpi_cmp( a, pkey->p ) < 0) )
+ return 0; /* assertion 0 < a < p failed */
+
+ t1 = mpi_alloc( mpi_get_nlimbs(a) );
+ t2 = mpi_alloc( mpi_get_nlimbs(a) );
+
+#if 0
+ /* t1 = (y^a mod p) * (a^b mod p) mod p */
+ gcry_mpi_powm( t1, pkey->y, a, pkey->p );
+ gcry_mpi_powm( t2, a, b, pkey->p );
+ mpi_mulm( t1, t1, t2, pkey->p );
+
+ /* t2 = g ^ input mod p */
+ gcry_mpi_powm( t2, pkey->g, input, pkey->p );
+
+ rc = !mpi_cmp( t1, t2 );
+#elif 0
+ /* t1 = (y^a mod p) * (a^b mod p) mod p */
+ base[0] = pkey->y; ex[0] = a;
+ base[1] = a; ex[1] = b;
+ base[2] = NULL; ex[2] = NULL;
+ mpi_mulpowm( t1, base, ex, pkey->p );
+
+ /* t2 = g ^ input mod p */
+ gcry_mpi_powm( t2, pkey->g, input, pkey->p );
+
+ rc = !mpi_cmp( t1, t2 );
+#else
+ /* t1 = g ^ - input * y ^ a * a ^ b mod p */
+ mpi_invm(t2, pkey->g, pkey->p );
+ base[0] = t2 ; ex[0] = input;
+ base[1] = pkey->y; ex[1] = a;
+ base[2] = a; ex[2] = b;
+ base[3] = NULL; ex[3] = NULL;
+ mpi_mulpowm( t1, base, ex, pkey->p );
+ rc = !mpi_cmp_ui( t1, 1 );
+
+#endif
+
+ mpi_free(t1);
+ mpi_free(t2);
+ return rc;
+}
+
+/*********************************************
+ ************** interface ******************
+ *********************************************/
+
+static gpg_err_code_t
+elg_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
+ const gcry_sexp_t genparms,
+ gcry_mpi_t *skey, gcry_mpi_t **retfactors,
+ gcry_sexp_t *r_extrainfo)
+{
+ gpg_err_code_t ec;
+ ELG_secret_key sk;
+ gcry_mpi_t xvalue = NULL;
+ gcry_sexp_t l1;
+
+ (void)algo;
+ (void)evalue;
+ (void)r_extrainfo;
+
+ if (genparms)
+ {
+ /* Parse the optional xvalue element. */
+ l1 = gcry_sexp_find_token (genparms, "xvalue", 0);
+ if (l1)
+ {
+ xvalue = gcry_sexp_nth_mpi (l1, 1, 0);
+ gcry_sexp_release (l1);
+ if (!xvalue)
+ return GPG_ERR_BAD_MPI;
+ }
+ }
+
+ if (xvalue)
+ ec = generate_using_x (&sk, nbits, xvalue, retfactors);
+ else
+ {
+ generate (&sk, nbits, retfactors);
+ ec = 0;
+ }
+
+ skey[0] = sk.p;
+ skey[1] = sk.g;
+ skey[2] = sk.y;
+ skey[3] = sk.x;
+
+ return ec;
+}
+
+
+static gcry_err_code_t
+elg_generate (int algo, unsigned int nbits, unsigned long evalue,
+ gcry_mpi_t *skey, gcry_mpi_t **retfactors)
+{
+ ELG_secret_key sk;
+
+ (void)algo;
+ (void)evalue;
+
+ generate (&sk, nbits, retfactors);
+ skey[0] = sk.p;
+ skey[1] = sk.g;
+ skey[2] = sk.y;
+ skey[3] = sk.x;
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+static gcry_err_code_t
+elg_check_secret_key (int algo, gcry_mpi_t *skey)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ ELG_secret_key sk;
+
+ (void)algo;
+
+ if ((! skey[0]) || (! skey[1]) || (! skey[2]) || (! skey[3]))
+ err = GPG_ERR_BAD_MPI;
+ else
+ {
+ sk.p = skey[0];
+ sk.g = skey[1];
+ sk.y = skey[2];
+ sk.x = skey[3];
+
+ if (! check_secret_key (&sk))
+ err = GPG_ERR_BAD_SECKEY;
+ }
+
+ return err;
+}
+
+
+static gcry_err_code_t
+elg_encrypt (int algo, gcry_mpi_t *resarr,
+ gcry_mpi_t data, gcry_mpi_t *pkey, int flags)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ ELG_public_key pk;
+
+ (void)algo;
+ (void)flags;
+
+ if ((! data) || (! pkey[0]) || (! pkey[1]) || (! pkey[2]))
+ err = GPG_ERR_BAD_MPI;
+ else
+ {
+ pk.p = pkey[0];
+ pk.g = pkey[1];
+ pk.y = pkey[2];
+ resarr[0] = mpi_alloc (mpi_get_nlimbs (pk.p));
+ resarr[1] = mpi_alloc (mpi_get_nlimbs (pk.p));
+ do_encrypt (resarr[0], resarr[1], data, &pk);
+ }
+ return err;
+}
+
+
+static gcry_err_code_t
+elg_decrypt (int algo, gcry_mpi_t *result,
+ gcry_mpi_t *data, gcry_mpi_t *skey, int flags)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ ELG_secret_key sk;
+
+ (void)algo;
+ (void)flags;
+
+ if ((! data[0]) || (! data[1])
+ || (! skey[0]) || (! skey[1]) || (! skey[2]) || (! skey[3]))
+ err = GPG_ERR_BAD_MPI;
+ else
+ {
+ sk.p = skey[0];
+ sk.g = skey[1];
+ sk.y = skey[2];
+ sk.x = skey[3];
+ *result = mpi_alloc_secure (mpi_get_nlimbs (sk.p));
+ decrypt (*result, data[0], data[1], &sk);
+ }
+ return err;
+}
+
+
+static gcry_err_code_t
+elg_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ ELG_secret_key sk;
+
+ (void)algo;
+
+ if ((! data)
+ || (! skey[0]) || (! skey[1]) || (! skey[2]) || (! skey[3]))
+ err = GPG_ERR_BAD_MPI;
+ else
+ {
+ sk.p = skey[0];
+ sk.g = skey[1];
+ sk.y = skey[2];
+ sk.x = skey[3];
+ resarr[0] = mpi_alloc (mpi_get_nlimbs (sk.p));
+ resarr[1] = mpi_alloc (mpi_get_nlimbs (sk.p));
+ sign (resarr[0], resarr[1], data, &sk);
+ }
+
+ return err;
+}
+
+
+static gcry_err_code_t
+elg_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey,
+ int (*cmp) (void *, gcry_mpi_t), void *opaquev)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ ELG_public_key pk;
+
+ (void)algo;
+ (void)cmp;
+ (void)opaquev;
+
+ if ((! data[0]) || (! data[1]) || (! hash)
+ || (! pkey[0]) || (! pkey[1]) || (! pkey[2]))
+ err = GPG_ERR_BAD_MPI;
+ else
+ {
+ pk.p = pkey[0];
+ pk.g = pkey[1];
+ pk.y = pkey[2];
+ if (! verify (data[0], data[1], hash, &pk))
+ err = GPG_ERR_BAD_SIGNATURE;
+ }
+
+ return err;
+}
+
+
+static unsigned int
+elg_get_nbits (int algo, gcry_mpi_t *pkey)
+{
+ (void)algo;
+
+ return mpi_get_nbits (pkey[0]);
+}
+
+
+static const char *elg_names[] =
+ {
+ "elg",
+ "openpgp-elg",
+ "openpgp-elg-sig",
+ NULL,
+ };
+
+
+gcry_pk_spec_t _gcry_pubkey_spec_elg =
+ {
+ "ELG", elg_names,
+ "pgy", "pgyx", "ab", "rs", "pgy",
+ GCRY_PK_USAGE_SIGN | GCRY_PK_USAGE_ENCR,
+ elg_generate,
+ elg_check_secret_key,
+ elg_encrypt,
+ elg_decrypt,
+ elg_sign,
+ elg_verify,
+ elg_get_nbits
+ };
+
+pk_extra_spec_t _gcry_pubkey_extraspec_elg =
+ {
+ NULL,
+ elg_generate_ext,
+ NULL
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/hash-common.c b/grub-core/lib/libgcrypt/cipher/hash-common.c
new file mode 100644
index 0000000..8c413bc
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/hash-common.c
@@ -0,0 +1,93 @@
+/* hash-common.c - Common code for hash algorithms
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+#include "g10lib.h"
+#include "hash-common.h"
+
+
+/* Run a selftest for hash algorithm ALGO. If the resulting digest
+ matches EXPECT/EXPECTLEN and everything else is fine as well,
+ return NULL. If an error occurs, return a static text string
+ describing the error.
+
+ DATAMODE controls what will be hashed according to this table:
+
+ 0 - Hash the supplied DATA of DATALEN.
+ 1 - Hash one million times a 'a'. DATA and DATALEN are ignored.
+
+*/
+const char *
+_gcry_hash_selftest_check_one (int algo,
+ int datamode, const void *data, size_t datalen,
+ const void *expect, size_t expectlen)
+{
+ const char *result = NULL;
+ gcry_error_t err = 0;
+ gcry_md_hd_t hd;
+ unsigned char *digest;
+
+ if (_gcry_md_get_algo_dlen (algo) != expectlen)
+ return "digest size does not match expected size";
+
+ err = _gcry_md_open (&hd, algo, 0);
+ if (err)
+ return "gcry_md_open failed";
+
+ switch (datamode)
+ {
+ case 0:
+ _gcry_md_write (hd, data, datalen);
+ break;
+
+ case 1: /* Hash one million times an "a". */
+ {
+ char aaa[1000];
+ int i;
+
+ /* Write in odd size chunks so that we test the buffering. */
+ memset (aaa, 'a', 1000);
+ for (i = 0; i < 1000; i++)
+ _gcry_md_write (hd, aaa, 1000);
+ }
+ break;
+
+ default:
+ result = "invalid DATAMODE";
+ }
+
+ if (!result)
+ {
+ digest = _gcry_md_read (hd, algo);
+
+ if ( memcmp (digest, expect, expectlen) )
+ result = "digest mismatch";
+ }
+
+ _gcry_md_close (hd);
+
+ return result;
+}
diff --git a/grub-core/lib/libgcrypt/cipher/hash-common.h b/grub-core/lib/libgcrypt/cipher/hash-common.h
new file mode 100644
index 0000000..fdebef4
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/hash-common.h
@@ -0,0 +1,33 @@
+/* hash-common.h - Declarations of common code for hash algorithms.
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GCRY_HASH_COMMON_H
+#define GCRY_HASH_COMMON_H
+
+
+const char * _gcry_hash_selftest_check_one
+/**/ (int algo,
+ int datamode, const void *data, size_t datalen,
+ const void *expect, size_t expectlen);
+
+
+
+
+
+#endif /*GCRY_HASH_COMMON_H*/
diff --git a/grub-core/lib/libgcrypt/cipher/hmac-tests.c b/grub-core/lib/libgcrypt/cipher/hmac-tests.c
new file mode 100644
index 0000000..a32ece7
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/hmac-tests.c
@@ -0,0 +1,732 @@
+/* hmac-tests.c - HMAC selftests.
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ Although algorithm self-tests are usually implemented in the module
+ implementing the algorithm, the case for HMAC is different because
+ HMAC is implemnetd on a higher level using a special feature of the
+ gcry_md_ functions. It would be possible to do this also in the
+ digest algorithm modules, but that would blow up the code too much
+ and spread the hmac tests over several modules.
+
+ Thus we implement all HMAC tests in this test module and provide a
+ function to run the tests.
+*/
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+#include "g10lib.h"
+#include "cipher.h"
+#include "hmac256.h"
+
+/* Check one HMAC with digest ALGO using the regualr HAMC
+ API. (DATA,DATALEN) is the data to be MACed, (KEY,KEYLEN) the key
+ and (EXPECT,EXPECTLEN) the expected result. Returns NULL on
+ succdess or a string describing the failure. */
+static const char *
+check_one (int algo,
+ const void *data, size_t datalen,
+ const void *key, size_t keylen,
+ const void *expect, size_t expectlen)
+{
+ gcry_md_hd_t hd;
+ const unsigned char *digest;
+
+/* printf ("HMAC algo %d\n", algo); */
+ if (_gcry_md_get_algo_dlen (algo) != expectlen)
+ return "invalid tests data";
+ if (_gcry_md_open (&hd, algo, GCRY_MD_FLAG_HMAC))
+ return "gcry_md_open failed";
+ if (_gcry_md_setkey (hd, key, keylen))
+ {
+ _gcry_md_close (hd);
+ return "gcry_md_setkey failed";
+ }
+ _gcry_md_write (hd, data, datalen);
+ digest = _gcry_md_read (hd, algo);
+ if (!digest)
+ {
+ _gcry_md_close (hd);
+ return "gcry_md_read failed";
+ }
+ if (memcmp (digest, expect, expectlen))
+ {
+/* int i; */
+
+/* fputs (" {", stdout); */
+/* for (i=0; i < expectlen-1; i++) */
+/* { */
+/* if (i && !(i % 8)) */
+/* fputs ("\n ", stdout); */
+/* printf (" 0x%02x,", digest[i]); */
+/* } */
+/* printf (" 0x%02x } },\n", digest[i]); */
+
+ _gcry_md_close (hd);
+ return "does not match";
+ }
+ _gcry_md_close (hd);
+ return NULL;
+}
+
+
+static gpg_err_code_t
+selftests_sha1 (int extended, selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+ unsigned char key[128];
+ int i, j;
+
+ what = "FIPS-198a, A.1";
+ for (i=0; i < 64; i++)
+ key[i] = i;
+ errtxt = check_one (GCRY_MD_SHA1,
+ "Sample #1", 9,
+ key, 64,
+ "\x4f\x4c\xa3\xd5\xd6\x8b\xa7\xcc\x0a\x12"
+ "\x08\xc9\xc6\x1e\x9c\x5d\xa0\x40\x3c\x0a", 20);
+ if (errtxt)
+ goto failed;
+
+ if (extended)
+ {
+ what = "FIPS-198a, A.2";
+ for (i=0, j=0x30; i < 20; i++)
+ key[i] = j++;
+ errtxt = check_one (GCRY_MD_SHA1,
+ "Sample #2", 9,
+ key, 20,
+ "\x09\x22\xd3\x40\x5f\xaa\x3d\x19\x4f\x82"
+ "\xa4\x58\x30\x73\x7d\x5c\xc6\xc7\x5d\x24", 20);
+ if (errtxt)
+ goto failed;
+
+ what = "FIPS-198a, A.3";
+ for (i=0, j=0x50; i < 100; i++)
+ key[i] = j++;
+ errtxt = check_one (GCRY_MD_SHA1,
+ "Sample #3", 9,
+ key, 100,
+ "\xbc\xf4\x1e\xab\x8b\xb2\xd8\x02\xf3\xd0"
+ "\x5c\xaf\x7c\xb0\x92\xec\xf8\xd1\xa3\xaa", 20 );
+ if (errtxt)
+ goto failed;
+
+ what = "FIPS-198a, A.4";
+ for (i=0, j=0x70; i < 49; i++)
+ key[i] = j++;
+ errtxt = check_one (GCRY_MD_SHA1,
+ "Sample #4", 9,
+ key, 49,
+ "\x9e\xa8\x86\xef\xe2\x68\xdb\xec\xce\x42"
+ "\x0c\x75\x24\xdf\x32\xe0\x75\x1a\x2a\x26", 20 );
+ if (errtxt)
+ goto failed;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("hmac", GCRY_MD_SHA1, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+
+static gpg_err_code_t
+selftests_sha224 (int extended, selftest_report_func_t report)
+{
+ static struct
+ {
+ const char * const desc;
+ const char * const data;
+ const char * const key;
+ const char expect[28];
+ } tv[] =
+ {
+ { "data-28 key-4",
+ "what do ya want for nothing?",
+ "Jefe",
+ { 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf,
+ 0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f,
+ 0x8b, 0xbe, 0xa2, 0xa3, 0x9e, 0x61, 0x48, 0x00,
+ 0x8f, 0xd0, 0x5e, 0x44 } },
+
+ { "data-9 key-20",
+ "Hi There",
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ { 0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19,
+ 0x68, 0x32, 0x10, 0x7c, 0xd4, 0x9d, 0xf3, 0x3f,
+ 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f,
+ 0x53, 0x68, 0x4b, 0x22 } },
+
+ { "data-50 key-20",
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa",
+ { 0x7f, 0xb3, 0xcb, 0x35, 0x88, 0xc6, 0xc1, 0xf6,
+ 0xff, 0xa9, 0x69, 0x4d, 0x7d, 0x6a, 0xd2, 0x64,
+ 0x93, 0x65, 0xb0, 0xc1, 0xf6, 0x5d, 0x69, 0xd1,
+ 0xec, 0x83, 0x33, 0xea } },
+
+ { "data-50 key-26",
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd",
+ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ { 0x6c, 0x11, 0x50, 0x68, 0x74, 0x01, 0x3c, 0xac,
+ 0x6a, 0x2a, 0xbc, 0x1b, 0xb3, 0x82, 0x62, 0x7c,
+ 0xec, 0x6a, 0x90, 0xd8, 0x6e, 0xfc, 0x01, 0x2d,
+ 0xe7, 0xaf, 0xec, 0x5a } },
+
+ { "data-54 key-131",
+ "Test Using Larger Than Block-Size Key - Hash Key First",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ { 0x95, 0xe9, 0xa0, 0xdb, 0x96, 0x20, 0x95, 0xad,
+ 0xae, 0xbe, 0x9b, 0x2d, 0x6f, 0x0d, 0xbc, 0xe2,
+ 0xd4, 0x99, 0xf1, 0x12, 0xf2, 0xd2, 0xb7, 0x27,
+ 0x3f, 0xa6, 0x87, 0x0e } },
+
+ { "data-152 key-131",
+ "This is a test using a larger than block-size key and a larger "
+ "than block-size data. The key needs to be hashed before being "
+ "used by the HMAC algorithm.",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ { 0x3a, 0x85, 0x41, 0x66, 0xac, 0x5d, 0x9f, 0x02,
+ 0x3f, 0x54, 0xd5, 0x17, 0xd0, 0xb3, 0x9d, 0xbd,
+ 0x94, 0x67, 0x70, 0xdb, 0x9c, 0x2b, 0x95, 0xc9,
+ 0xf6, 0xf5, 0x65, 0xd1 } },
+
+ { NULL }
+ };
+ const char *what;
+ const char *errtxt;
+ int tvidx;
+
+ for (tvidx=0; tv[tvidx].desc; tvidx++)
+ {
+ what = tv[tvidx].desc;
+ errtxt = check_one (GCRY_MD_SHA224,
+ tv[tvidx].data, strlen (tv[tvidx].data),
+ tv[tvidx].key, strlen (tv[tvidx].key),
+ tv[tvidx].expect, DIM (tv[tvidx].expect) );
+ if (errtxt)
+ goto failed;
+ if (!extended)
+ break;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("hmac", GCRY_MD_SHA224, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+static gpg_err_code_t
+selftests_sha256 (int extended, selftest_report_func_t report)
+{
+ static struct
+ {
+ const char * const desc;
+ const char * const data;
+ const char * const key;
+ const char expect[32];
+ } tv[] =
+ {
+ { "data-28 key-4",
+ "what do ya want for nothing?",
+ "Jefe",
+ { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
+ 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
+ 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
+ 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 } },
+
+ { "data-9 key-20",
+ "Hi There",
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53,
+ 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b,
+ 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7,
+ 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7 } },
+
+ { "data-50 key-20",
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa",
+ { 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46,
+ 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7,
+ 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22,
+ 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe } },
+
+ { "data-50 key-26",
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd",
+ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ { 0x82, 0x55, 0x8a, 0x38, 0x9a, 0x44, 0x3c, 0x0e,
+ 0xa4, 0xcc, 0x81, 0x98, 0x99, 0xf2, 0x08, 0x3a,
+ 0x85, 0xf0, 0xfa, 0xa3, 0xe5, 0x78, 0xf8, 0x07,
+ 0x7a, 0x2e, 0x3f, 0xf4, 0x67, 0x29, 0x66, 0x5b } },
+
+ { "data-54 key-131",
+ "Test Using Larger Than Block-Size Key - Hash Key First",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ { 0x60, 0xe4, 0x31, 0x59, 0x1e, 0xe0, 0xb6, 0x7f,
+ 0x0d, 0x8a, 0x26, 0xaa, 0xcb, 0xf5, 0xb7, 0x7f,
+ 0x8e, 0x0b, 0xc6, 0x21, 0x37, 0x28, 0xc5, 0x14,
+ 0x05, 0x46, 0x04, 0x0f, 0x0e, 0xe3, 0x7f, 0x54 } },
+
+ { "data-152 key-131",
+ "This is a test using a larger than block-size key and a larger "
+ "than block-size data. The key needs to be hashed before being "
+ "used by the HMAC algorithm.",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ { 0x9b, 0x09, 0xff, 0xa7, 0x1b, 0x94, 0x2f, 0xcb,
+ 0x27, 0x63, 0x5f, 0xbc, 0xd5, 0xb0, 0xe9, 0x44,
+ 0xbf, 0xdc, 0x63, 0x64, 0x4f, 0x07, 0x13, 0x93,
+ 0x8a, 0x7f, 0x51, 0x53, 0x5c, 0x3a, 0x35, 0xe2 } },
+
+ { NULL }
+ };
+ const char *what;
+ const char *errtxt;
+ int tvidx;
+
+ for (tvidx=0; tv[tvidx].desc; tvidx++)
+ {
+ hmac256_context_t hmachd;
+ const unsigned char *digest;
+ size_t dlen;
+
+ what = tv[tvidx].desc;
+ errtxt = check_one (GCRY_MD_SHA256,
+ tv[tvidx].data, strlen (tv[tvidx].data),
+ tv[tvidx].key, strlen (tv[tvidx].key),
+ tv[tvidx].expect, DIM (tv[tvidx].expect) );
+ if (errtxt)
+ goto failed;
+
+ hmachd = _gcry_hmac256_new (tv[tvidx].key, strlen (tv[tvidx].key));
+ if (!hmachd)
+ {
+ errtxt = "_gcry_hmac256_new failed";
+ goto failed;
+ }
+ _gcry_hmac256_update (hmachd, tv[tvidx].data, strlen (tv[tvidx].data));
+ digest = _gcry_hmac256_finalize (hmachd, &dlen);
+ if (!digest)
+ {
+ errtxt = "_gcry_hmac256_finalize failed";
+ _gcry_hmac256_release (hmachd);
+ goto failed;
+ }
+ if (dlen != DIM (tv[tvidx].expect)
+ || memcmp (digest, tv[tvidx].expect, DIM (tv[tvidx].expect)))
+ {
+ errtxt = "does not match in second implementation";
+ _gcry_hmac256_release (hmachd);
+ goto failed;
+ }
+ _gcry_hmac256_release (hmachd);
+
+ if (!extended)
+ break;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("hmac", GCRY_MD_SHA256, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+static gpg_err_code_t
+selftests_sha384 (int extended, selftest_report_func_t report)
+{
+ static struct
+ {
+ const char * const desc;
+ const char * const data;
+ const char * const key;
+ const char expect[48];
+ } tv[] =
+ {
+ { "data-28 key-4",
+ "what do ya want for nothing?",
+ "Jefe",
+ { 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31,
+ 0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b,
+ 0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47,
+ 0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e,
+ 0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7,
+ 0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49 } },
+
+ { "data-9 key-20",
+ "Hi There",
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ { 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62,
+ 0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f,
+ 0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6,
+ 0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c,
+ 0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f,
+ 0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6 } },
+
+ { "data-50 key-20",
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa",
+ { 0x88, 0x06, 0x26, 0x08, 0xd3, 0xe6, 0xad, 0x8a,
+ 0x0a, 0xa2, 0xac, 0xe0, 0x14, 0xc8, 0xa8, 0x6f,
+ 0x0a, 0xa6, 0x35, 0xd9, 0x47, 0xac, 0x9f, 0xeb,
+ 0xe8, 0x3e, 0xf4, 0xe5, 0x59, 0x66, 0x14, 0x4b,
+ 0x2a, 0x5a, 0xb3, 0x9d, 0xc1, 0x38, 0x14, 0xb9,
+ 0x4e, 0x3a, 0xb6, 0xe1, 0x01, 0xa3, 0x4f, 0x27 } },
+
+ { "data-50 key-26",
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd",
+ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ { 0x3e, 0x8a, 0x69, 0xb7, 0x78, 0x3c, 0x25, 0x85,
+ 0x19, 0x33, 0xab, 0x62, 0x90, 0xaf, 0x6c, 0xa7,
+ 0x7a, 0x99, 0x81, 0x48, 0x08, 0x50, 0x00, 0x9c,
+ 0xc5, 0x57, 0x7c, 0x6e, 0x1f, 0x57, 0x3b, 0x4e,
+ 0x68, 0x01, 0xdd, 0x23, 0xc4, 0xa7, 0xd6, 0x79,
+ 0xcc, 0xf8, 0xa3, 0x86, 0xc6, 0x74, 0xcf, 0xfb } },
+
+ { "data-54 key-131",
+ "Test Using Larger Than Block-Size Key - Hash Key First",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ { 0x4e, 0xce, 0x08, 0x44, 0x85, 0x81, 0x3e, 0x90,
+ 0x88, 0xd2, 0xc6, 0x3a, 0x04, 0x1b, 0xc5, 0xb4,
+ 0x4f, 0x9e, 0xf1, 0x01, 0x2a, 0x2b, 0x58, 0x8f,
+ 0x3c, 0xd1, 0x1f, 0x05, 0x03, 0x3a, 0xc4, 0xc6,
+ 0x0c, 0x2e, 0xf6, 0xab, 0x40, 0x30, 0xfe, 0x82,
+ 0x96, 0x24, 0x8d, 0xf1, 0x63, 0xf4, 0x49, 0x52 } },
+
+ { "data-152 key-131",
+ "This is a test using a larger than block-size key and a larger "
+ "than block-size data. The key needs to be hashed before being "
+ "used by the HMAC algorithm.",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ { 0x66, 0x17, 0x17, 0x8e, 0x94, 0x1f, 0x02, 0x0d,
+ 0x35, 0x1e, 0x2f, 0x25, 0x4e, 0x8f, 0xd3, 0x2c,
+ 0x60, 0x24, 0x20, 0xfe, 0xb0, 0xb8, 0xfb, 0x9a,
+ 0xdc, 0xce, 0xbb, 0x82, 0x46, 0x1e, 0x99, 0xc5,
+ 0xa6, 0x78, 0xcc, 0x31, 0xe7, 0x99, 0x17, 0x6d,
+ 0x38, 0x60, 0xe6, 0x11, 0x0c, 0x46, 0x52, 0x3e } },
+
+ { NULL }
+ };
+ const char *what;
+ const char *errtxt;
+ int tvidx;
+
+ for (tvidx=0; tv[tvidx].desc; tvidx++)
+ {
+ what = tv[tvidx].desc;
+ errtxt = check_one (GCRY_MD_SHA384,
+ tv[tvidx].data, strlen (tv[tvidx].data),
+ tv[tvidx].key, strlen (tv[tvidx].key),
+ tv[tvidx].expect, DIM (tv[tvidx].expect) );
+ if (errtxt)
+ goto failed;
+ if (!extended)
+ break;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("hmac", GCRY_MD_SHA384, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+static gpg_err_code_t
+selftests_sha512 (int extended, selftest_report_func_t report)
+{
+ static struct
+ {
+ const char * const desc;
+ const char * const data;
+ const char * const key;
+ const char expect[64];
+ } tv[] =
+ {
+ { "data-28 key-4",
+ "what do ya want for nothing?",
+ "Jefe",
+ { 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2,
+ 0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3,
+ 0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6,
+ 0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54,
+ 0x97, 0x58, 0xbf, 0x75, 0xc0, 0x5a, 0x99, 0x4a,
+ 0x6d, 0x03, 0x4f, 0x65, 0xf8, 0xf0, 0xe6, 0xfd,
+ 0xca, 0xea, 0xb1, 0xa3, 0x4d, 0x4a, 0x6b, 0x4b,
+ 0x63, 0x6e, 0x07, 0x0a, 0x38, 0xbc, 0xe7, 0x37 } },
+
+ { "data-9 key-20",
+ "Hi There",
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ { 0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d,
+ 0x4f, 0xf0, 0xb4, 0x24, 0x1a, 0x1d, 0x6c, 0xb0,
+ 0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78,
+ 0x7a, 0xd0, 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde,
+ 0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, 0x02,
+ 0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4,
+ 0xbe, 0x9d, 0x91, 0x4e, 0xeb, 0x61, 0xf1, 0x70,
+ 0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54 } },
+
+ { "data-50 key-20",
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa",
+ { 0xfa, 0x73, 0xb0, 0x08, 0x9d, 0x56, 0xa2, 0x84,
+ 0xef, 0xb0, 0xf0, 0x75, 0x6c, 0x89, 0x0b, 0xe9,
+ 0xb1, 0xb5, 0xdb, 0xdd, 0x8e, 0xe8, 0x1a, 0x36,
+ 0x55, 0xf8, 0x3e, 0x33, 0xb2, 0x27, 0x9d, 0x39,
+ 0xbf, 0x3e, 0x84, 0x82, 0x79, 0xa7, 0x22, 0xc8,
+ 0x06, 0xb4, 0x85, 0xa4, 0x7e, 0x67, 0xc8, 0x07,
+ 0xb9, 0x46, 0xa3, 0x37, 0xbe, 0xe8, 0x94, 0x26,
+ 0x74, 0x27, 0x88, 0x59, 0xe1, 0x32, 0x92, 0xfb } },
+
+ { "data-50 key-26",
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd",
+ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ { 0xb0, 0xba, 0x46, 0x56, 0x37, 0x45, 0x8c, 0x69,
+ 0x90, 0xe5, 0xa8, 0xc5, 0xf6, 0x1d, 0x4a, 0xf7,
+ 0xe5, 0x76, 0xd9, 0x7f, 0xf9, 0x4b, 0x87, 0x2d,
+ 0xe7, 0x6f, 0x80, 0x50, 0x36, 0x1e, 0xe3, 0xdb,
+ 0xa9, 0x1c, 0xa5, 0xc1, 0x1a, 0xa2, 0x5e, 0xb4,
+ 0xd6, 0x79, 0x27, 0x5c, 0xc5, 0x78, 0x80, 0x63,
+ 0xa5, 0xf1, 0x97, 0x41, 0x12, 0x0c, 0x4f, 0x2d,
+ 0xe2, 0xad, 0xeb, 0xeb, 0x10, 0xa2, 0x98, 0xdd } },
+
+ { "data-54 key-131",
+ "Test Using Larger Than Block-Size Key - Hash Key First",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ { 0x80, 0xb2, 0x42, 0x63, 0xc7, 0xc1, 0xa3, 0xeb,
+ 0xb7, 0x14, 0x93, 0xc1, 0xdd, 0x7b, 0xe8, 0xb4,
+ 0x9b, 0x46, 0xd1, 0xf4, 0x1b, 0x4a, 0xee, 0xc1,
+ 0x12, 0x1b, 0x01, 0x37, 0x83, 0xf8, 0xf3, 0x52,
+ 0x6b, 0x56, 0xd0, 0x37, 0xe0, 0x5f, 0x25, 0x98,
+ 0xbd, 0x0f, 0xd2, 0x21, 0x5d, 0x6a, 0x1e, 0x52,
+ 0x95, 0xe6, 0x4f, 0x73, 0xf6, 0x3f, 0x0a, 0xec,
+ 0x8b, 0x91, 0x5a, 0x98, 0x5d, 0x78, 0x65, 0x98 } },
+
+ { "data-152 key-131",
+ "This is a test using a larger than block-size key and a larger "
+ "than block-size data. The key needs to be hashed before being "
+ "used by the HMAC algorithm.",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ { 0xe3, 0x7b, 0x6a, 0x77, 0x5d, 0xc8, 0x7d, 0xba,
+ 0xa4, 0xdf, 0xa9, 0xf9, 0x6e, 0x5e, 0x3f, 0xfd,
+ 0xde, 0xbd, 0x71, 0xf8, 0x86, 0x72, 0x89, 0x86,
+ 0x5d, 0xf5, 0xa3, 0x2d, 0x20, 0xcd, 0xc9, 0x44,
+ 0xb6, 0x02, 0x2c, 0xac, 0x3c, 0x49, 0x82, 0xb1,
+ 0x0d, 0x5e, 0xeb, 0x55, 0xc3, 0xe4, 0xde, 0x15,
+ 0x13, 0x46, 0x76, 0xfb, 0x6d, 0xe0, 0x44, 0x60,
+ 0x65, 0xc9, 0x74, 0x40, 0xfa, 0x8c, 0x6a, 0x58 } },
+
+ { NULL }
+ };
+ const char *what;
+ const char *errtxt;
+ int tvidx;
+
+ for (tvidx=0; tv[tvidx].desc; tvidx++)
+ {
+ what = tv[tvidx].desc;
+ errtxt = check_one (GCRY_MD_SHA512,
+ tv[tvidx].data, strlen (tv[tvidx].data),
+ tv[tvidx].key, strlen (tv[tvidx].key),
+ tv[tvidx].expect, DIM (tv[tvidx].expect) );
+ if (errtxt)
+ goto failed;
+ if (!extended)
+ break;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("hmac", GCRY_MD_SHA512, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+static gpg_err_code_t
+run_selftests (int algo, int extended, selftest_report_func_t report)
+{
+ gpg_err_code_t ec;
+
+ switch (algo)
+ {
+ case GCRY_MD_SHA1:
+ ec = selftests_sha1 (extended, report);
+ break;
+ case GCRY_MD_SHA224:
+ ec = selftests_sha224 (extended, report);
+ break;
+ case GCRY_MD_SHA256:
+ ec = selftests_sha256 (extended, report);
+ break;
+ case GCRY_MD_SHA384:
+ ec = selftests_sha384 (extended, report);
+ break;
+ case GCRY_MD_SHA512:
+ ec = selftests_sha512 (extended, report);
+ break;
+ default:
+ ec = GPG_ERR_DIGEST_ALGO;
+ break;
+ }
+ return ec;
+}
+
+
+
+
+/* Run the selftests for HMAC with digest algorithm ALGO with optional
+ reporting function REPORT. */
+gpg_error_t
+_gcry_hmac_selftest (int algo, int extended, selftest_report_func_t report)
+{
+ gcry_err_code_t ec = 0;
+
+ if (!gcry_md_test_algo (algo))
+ {
+ ec = run_selftests (algo, extended, report);
+ }
+ else
+ {
+ ec = GPG_ERR_DIGEST_ALGO;
+ if (report)
+ report ("hmac", algo, "module", "algorithm not available");
+ }
+ return gpg_error (ec);
+}
diff --git a/grub-core/lib/libgcrypt/cipher/idea.c b/grub-core/lib/libgcrypt/cipher/idea.c
new file mode 100644
index 0000000..3c5578f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/idea.c
@@ -0,0 +1,378 @@
+/* idea.c - IDEA function
+ * Copyright 1997, 1998, 1999, 2001 Werner Koch (dd9jn)
+ * Copyright 2013 g10 Code GmbH
+ *
+ * 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
+ * WERNER KOCH 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.
+ *
+ * Except as contained in this notice, the name of Werner Koch shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Werner Koch.
+ *
+ * Patents on IDEA have expired:
+ * Europe: EP0482154 on 2011-05-16,
+ * Japan: JP3225440 on 2011-05-16,
+ * U.S.: 5,214,703 on 2012-01-07.
+ */
+
+/*
+ * Please see http://www.noepatents.org/ to learn why software patents
+ * are bad for society and what you can do to fight them.
+ *
+ * The code herein is based on the one from:
+ * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996.
+ * ISBN 0-471-11709-9.
+ */
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "types.h" /* for byte and u32 typedefs */
+#include "g10lib.h"
+#include "cipher.h"
+
+
+#define IDEA_KEYSIZE 16
+#define IDEA_BLOCKSIZE 8
+#define IDEA_ROUNDS 8
+#define IDEA_KEYLEN (6*IDEA_ROUNDS+4)
+
+typedef struct {
+ u16 ek[IDEA_KEYLEN];
+ u16 dk[IDEA_KEYLEN];
+ int have_dk;
+} IDEA_context;
+
+static const char *selftest(void);
+
+
+static u16
+mul_inv( u16 x )
+{
+ u16 t0, t1;
+ u16 q, y;
+
+ if( x < 2 )
+ return x;
+ t1 = 0x10001UL / x;
+ y = 0x10001UL % x;
+ if( y == 1 )
+ return (1-t1) & 0xffff;
+
+ t0 = 1;
+ do {
+ q = x / y;
+ x = x % y;
+ t0 += q * t1;
+ if( x == 1 )
+ return t0;
+ q = y / x;
+ y = y % x;
+ t1 += q * t0;
+ } while( y != 1 );
+ return (1-t1) & 0xffff;
+}
+
+
+
+static void
+expand_key( const byte *userkey, u16 *ek )
+{
+ int i,j;
+
+ for(j=0; j < 8; j++ ) {
+ ek[j] = (*userkey << 8) + userkey[1];
+ userkey += 2;
+ }
+ for(i=0; j < IDEA_KEYLEN; j++ ) {
+ i++;
+ ek[i+7] = ek[i&7] << 9 | ek[(i+1)&7] >> 7;
+ ek += i & 8;
+ i &= 7;
+ }
+}
+
+
+static void
+invert_key( u16 *ek, u16 dk[IDEA_KEYLEN] )
+{
+ int i;
+ u16 t1, t2, t3;
+ u16 temp[IDEA_KEYLEN];
+ u16 *p = temp + IDEA_KEYLEN;
+
+ t1 = mul_inv( *ek++ );
+ t2 = -*ek++;
+ t3 = -*ek++;
+ *--p = mul_inv( *ek++ );
+ *--p = t3;
+ *--p = t2;
+ *--p = t1;
+
+ for(i=0; i < IDEA_ROUNDS-1; i++ ) {
+ t1 = *ek++;
+ *--p = *ek++;
+ *--p = t1;
+
+ t1 = mul_inv( *ek++ );
+ t2 = -*ek++;
+ t3 = -*ek++;
+ *--p = mul_inv( *ek++ );
+ *--p = t2;
+ *--p = t3;
+ *--p = t1;
+ }
+ t1 = *ek++;
+ *--p = *ek++;
+ *--p = t1;
+
+ t1 = mul_inv( *ek++ );
+ t2 = -*ek++;
+ t3 = -*ek++;
+ *--p = mul_inv( *ek++ );
+ *--p = t3;
+ *--p = t2;
+ *--p = t1;
+ memcpy(dk, temp, sizeof(temp) );
+ memset(temp, 0, sizeof(temp) ); /* burn temp */
+}
+
+
+static void
+cipher( byte *outbuf, const byte *inbuf, u16 *key )
+{
+ u16 s2, s3;
+ u16 in[4];
+ int r = IDEA_ROUNDS;
+#define x1 (in[0])
+#define x2 (in[1])
+#define x3 (in[2])
+#define x4 (in[3])
+#define MUL(x,y) \
+ do {u16 _t16; u32 _t32; \
+ if( (_t16 = (y)) ) { \
+ if( (x = (x)&0xffff) ) { \
+ _t32 = (u32)x * _t16; \
+ x = _t32 & 0xffff; \
+ _t16 = _t32 >> 16; \
+ x = ((x)-_t16) + (x<_t16?1:0); \
+ } \
+ else { \
+ x = 1 - _t16; \
+ } \
+ } \
+ else { \
+ x = 1 - x; \
+ } \
+ } while(0)
+
+ memcpy (in, inbuf, sizeof in);
+#ifndef WORDS_BIGENDIAN
+ x1 = (x1>>8) | (x1<<8);
+ x2 = (x2>>8) | (x2<<8);
+ x3 = (x3>>8) | (x3<<8);
+ x4 = (x4>>8) | (x4<<8);
+#endif
+ do {
+ MUL(x1, *key++);
+ x2 += *key++;
+ x3 += *key++;
+ MUL(x4, *key++ );
+
+ s3 = x3;
+ x3 ^= x1;
+ MUL(x3, *key++);
+ s2 = x2;
+ x2 ^=x4;
+ x2 += x3;
+ MUL(x2, *key++);
+ x3 += x2;
+
+ x1 ^= x2;
+ x4 ^= x3;
+
+ x2 ^= s3;
+ x3 ^= s2;
+ } while( --r );
+ MUL(x1, *key++);
+ x3 += *key++;
+ x2 += *key++;
+ MUL(x4, *key);
+
+#ifndef WORDS_BIGENDIAN
+ x1 = (x1>>8) | (x1<<8);
+ x2 = (x2>>8) | (x2<<8);
+ x3 = (x3>>8) | (x3<<8);
+ x4 = (x4>>8) | (x4<<8);
+#endif
+ memcpy (outbuf+0, &x1, 2);
+ memcpy (outbuf+2, &x3, 2);
+ memcpy (outbuf+4, &x2, 2);
+ memcpy (outbuf+6, &x4, 2);
+#undef MUL
+#undef x1
+#undef x2
+#undef x3
+#undef x4
+}
+
+
+static int
+do_setkey( IDEA_context *c, const byte *key, unsigned int keylen )
+{
+ static int initialized = 0;
+ static const char *selftest_failed = 0;
+
+ if( !initialized ) {
+ initialized = 1;
+ selftest_failed = selftest();
+ if( selftest_failed )
+ log_error( "%s\n", selftest_failed );
+ }
+ if( selftest_failed )
+ return GPG_ERR_SELFTEST_FAILED;
+
+ assert(keylen == 16);
+ c->have_dk = 0;
+ expand_key( key, c->ek );
+ invert_key( c->ek, c->dk );
+ return 0;
+}
+
+static gcry_err_code_t
+idea_setkey (void *context, const byte *key, unsigned int keylen)
+{
+ IDEA_context *ctx = context;
+ int rc = do_setkey (ctx, key, keylen);
+ _gcry_burn_stack (23+6*sizeof(void*));
+ return rc;
+}
+
+static void
+encrypt_block( IDEA_context *c, byte *outbuf, const byte *inbuf )
+{
+ cipher( outbuf, inbuf, c->ek );
+}
+
+static void
+idea_encrypt (void *context, byte *out, const byte *in)
+{
+ IDEA_context *ctx = context;
+ encrypt_block (ctx, out, in);
+ _gcry_burn_stack (24+3*sizeof (void*));
+}
+
+static void
+decrypt_block( IDEA_context *c, byte *outbuf, const byte *inbuf )
+{
+ if( !c->have_dk ) {
+ c->have_dk = 1;
+ invert_key( c->ek, c->dk );
+ }
+ cipher( outbuf, inbuf, c->dk );
+}
+
+static void
+idea_decrypt (void *context, byte *out, const byte *in)
+{
+ IDEA_context *ctx = context;
+ decrypt_block (ctx, out, in);
+ _gcry_burn_stack (24+3*sizeof (void*));
+}
+
+
+static const char *
+selftest( void )
+{
+static struct {
+ byte key[16];
+ byte plain[8];
+ byte cipher[8];
+} test_vectors[] = {
+ { { 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 },
+ { 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03 },
+ { 0x11, 0xFB, 0xED, 0x2B, 0x01, 0x98, 0x6D, 0xE5 } },
+ { { 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 },
+ { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 },
+ { 0x54, 0x0E, 0x5F, 0xEA, 0x18, 0xC2, 0xF8, 0xB1 } },
+ { { 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 },
+ { 0x00, 0x19, 0x32, 0x4B, 0x64, 0x7D, 0x96, 0xAF },
+ { 0x9F, 0x0A, 0x0A, 0xB6, 0xE1, 0x0C, 0xED, 0x78 } },
+ { { 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 },
+ { 0xF5, 0x20, 0x2D, 0x5B, 0x9C, 0x67, 0x1B, 0x08 },
+ { 0xCF, 0x18, 0xFD, 0x73, 0x55, 0xE2, 0xC5, 0xC5 } },
+ { { 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 },
+ { 0xFA, 0xE6, 0xD2, 0xBE, 0xAA, 0x96, 0x82, 0x6E },
+ { 0x85, 0xDF, 0x52, 0x00, 0x56, 0x08, 0x19, 0x3D } },
+ { { 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 },
+ { 0x0A, 0x14, 0x1E, 0x28, 0x32, 0x3C, 0x46, 0x50 },
+ { 0x2F, 0x7D, 0xE7, 0x50, 0x21, 0x2F, 0xB7, 0x34 } },
+ { { 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 },
+ { 0x05, 0x0A, 0x0F, 0x14, 0x19, 0x1E, 0x23, 0x28 },
+ { 0x7B, 0x73, 0x14, 0x92, 0x5D, 0xE5, 0x9C, 0x09 } },
+ { { 0x00, 0x05, 0x00, 0x0A, 0x00, 0x0F, 0x00, 0x14,
+ 0x00, 0x19, 0x00, 0x1E, 0x00, 0x23, 0x00, 0x28 },
+ { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 },
+ { 0x3E, 0xC0, 0x47, 0x80, 0xBE, 0xFF, 0x6E, 0x20 } },
+ { { 0x3A, 0x98, 0x4E, 0x20, 0x00, 0x19, 0x5D, 0xB3,
+ 0x2E, 0xE5, 0x01, 0xC8, 0xC4, 0x7C, 0xEA, 0x60 },
+ { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 },
+ { 0x97, 0xBC, 0xD8, 0x20, 0x07, 0x80, 0xDA, 0x86 } },
+ { { 0x00, 0x64, 0x00, 0xC8, 0x01, 0x2C, 0x01, 0x90,
+ 0x01, 0xF4, 0x02, 0x58, 0x02, 0xBC, 0x03, 0x20 },
+ { 0x05, 0x32, 0x0A, 0x64, 0x14, 0xC8, 0x19, 0xFA },
+ { 0x65, 0xBE, 0x87, 0xE7, 0xA2, 0x53, 0x8A, 0xED } },
+ { { 0x9D, 0x40, 0x75, 0xC1, 0x03, 0xBC, 0x32, 0x2A,
+ 0xFB, 0x03, 0xE7, 0xBE, 0x6A, 0xB3, 0x00, 0x06 },
+ { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 },
+ { 0xF5, 0xDB, 0x1A, 0xC4, 0x5E, 0x5E, 0xF9, 0xF9 } }
+};
+ IDEA_context c;
+ byte buffer[8];
+ int i;
+
+ for(i=0; i < DIM(test_vectors); i++ ) {
+ do_setkey( &c, test_vectors[i].key, 16 );
+ encrypt_block( &c, buffer, test_vectors[i].plain );
+ if( memcmp( buffer, test_vectors[i].cipher, 8 ) )
+ return "IDEA test encryption failed.";
+ decrypt_block( &c, buffer, test_vectors[i].cipher );
+ if( memcmp( buffer, test_vectors[i].plain, 8 ) )
+ return "IDEA test decryption failed.";
+ }
+
+ return NULL;
+}
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_idea =
+{
+ "IDEA", NULL, NULL, IDEA_BLOCKSIZE, 128,
+ sizeof (IDEA_context),
+ idea_setkey, idea_encrypt, idea_decrypt
+};
diff --git a/grub-core/lib/libgcrypt/cipher/kdf.c b/grub-core/lib/libgcrypt/cipher/kdf.c
new file mode 100644
index 0000000..46e8550
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/kdf.c
@@ -0,0 +1,278 @@
+/* kdf.c - Key Derivation Functions
+ * Copyright (C) 1998, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "g10lib.h"
+#include "cipher.h"
+#include "ath.h"
+
+
+/* Transform a passphrase into a suitable key of length KEYSIZE and
+ store this key in the caller provided buffer KEYBUFFER. The caller
+ must provide an HASHALGO, a valid ALGO and depending on that algo a
+ SALT of 8 bytes and the number of ITERATIONS. Code taken from
+ gnupg/agent/protect.c:hash_passphrase. */
+gpg_err_code_t
+openpgp_s2k (const void *passphrase, size_t passphraselen,
+ int algo, int hashalgo,
+ const void *salt, size_t saltlen,
+ unsigned long iterations,
+ size_t keysize, void *keybuffer)
+{
+ gpg_err_code_t ec;
+ gcry_md_hd_t md;
+ char *key = keybuffer;
+ int pass, i;
+ int used = 0;
+ int secmode;
+
+ if ((algo == GCRY_KDF_SALTED_S2K || algo == GCRY_KDF_ITERSALTED_S2K)
+ && (!salt || saltlen != 8))
+ return GPG_ERR_INV_VALUE;
+
+ secmode = gcry_is_secure (passphrase) || gcry_is_secure (keybuffer);
+
+ ec = gpg_err_code (gcry_md_open (&md, hashalgo,
+ secmode? GCRY_MD_FLAG_SECURE : 0));
+ if (ec)
+ return ec;
+
+ for (pass=0; used < keysize; pass++)
+ {
+ if (pass)
+ {
+ gcry_md_reset (md);
+ for (i=0; i < pass; i++) /* Preset the hash context. */
+ gcry_md_putc (md, 0);
+ }
+
+ if (algo == GCRY_KDF_SALTED_S2K || algo == GCRY_KDF_ITERSALTED_S2K)
+ {
+ int len2 = passphraselen + 8;
+ unsigned long count = len2;
+
+ if (algo == GCRY_KDF_ITERSALTED_S2K)
+ {
+ count = iterations;
+ if (count < len2)
+ count = len2;
+ }
+
+ while (count > len2)
+ {
+ gcry_md_write (md, salt, saltlen);
+ gcry_md_write (md, passphrase, passphraselen);
+ count -= len2;
+ }
+ if (count < saltlen)
+ gcry_md_write (md, salt, count);
+ else
+ {
+ gcry_md_write (md, salt, saltlen);
+ count -= saltlen;
+ gcry_md_write (md, passphrase, count);
+ }
+ }
+ else
+ gcry_md_write (md, passphrase, passphraselen);
+
+ gcry_md_final (md);
+ i = gcry_md_get_algo_dlen (hashalgo);
+ if (i > keysize - used)
+ i = keysize - used;
+ memcpy (key+used, gcry_md_read (md, hashalgo), i);
+ used += i;
+ }
+ gcry_md_close (md);
+ return 0;
+}
+
+
+/* Transform a passphrase into a suitable key of length KEYSIZE and
+ store this key in the caller provided buffer KEYBUFFER. The caller
+ must provide PRFALGO which indicates the pseudorandom function to
+ use: This shall be the algorithms id of a hash algorithm; it is
+ used in HMAC mode. SALT is a salt of length SALTLEN and ITERATIONS
+ gives the number of iterations. */
+gpg_err_code_t
+pkdf2 (const void *passphrase, size_t passphraselen,
+ int hashalgo,
+ const void *salt, size_t saltlen,
+ unsigned long iterations,
+ size_t keysize, void *keybuffer)
+{
+ gpg_err_code_t ec;
+ gcry_md_hd_t md;
+ int secmode;
+ unsigned int dklen = keysize;
+ char *dk = keybuffer;
+ unsigned int hlen; /* Output length of the digest function. */
+ unsigned int l; /* Rounded up number of blocks. */
+ unsigned int r; /* Number of octets in the last block. */
+ char *sbuf; /* Malloced buffer to concatenate salt and iter
+ as well as space to hold TBUF and UBUF. */
+ char *tbuf; /* Buffer for T; ptr into SBUF, size is HLEN. */
+ char *ubuf; /* Buffer for U; ptr into SBUF, size is HLEN. */
+ unsigned int lidx; /* Current block number. */
+ unsigned long iter; /* Current iteration number. */
+ unsigned int i;
+
+ if (!salt || !saltlen || !iterations || !dklen)
+ return GPG_ERR_INV_VALUE;
+
+ hlen = gcry_md_get_algo_dlen (hashalgo);
+ if (!hlen)
+ return GPG_ERR_DIGEST_ALGO;
+
+ secmode = gcry_is_secure (passphrase) || gcry_is_secure (keybuffer);
+
+ /* We ignore step 1 from pksc5v2.1 which demands a check that dklen
+ is not larger that 0xffffffff * hlen. */
+
+ /* Step 2 */
+ l = ((dklen - 1)/ hlen) + 1;
+ r = dklen - (l - 1) * hlen;
+
+ /* Setup buffers and prepare a hash context. */
+ sbuf = (secmode
+ ? gcry_malloc_secure (saltlen + 4 + hlen + hlen)
+ : gcry_malloc (saltlen + 4 + hlen + hlen));
+ if (!sbuf)
+ return gpg_err_code_from_syserror ();
+ tbuf = sbuf + saltlen + 4;
+ ubuf = tbuf + hlen;
+
+ ec = gpg_err_code (gcry_md_open (&md, hashalgo,
+ (GCRY_MD_FLAG_HMAC
+ | (secmode?GCRY_MD_FLAG_SECURE:0))));
+ if (ec)
+ {
+ gcry_free (sbuf);
+ return ec;
+ }
+
+ /* Step 3 and 4. */
+ memcpy (sbuf, salt, saltlen);
+ for (lidx = 1; lidx <= l; lidx++)
+ {
+ for (iter = 0; iter < iterations; iter++)
+ {
+ ec = gpg_err_code (gcry_md_setkey (md, passphrase, passphraselen));
+ if (ec)
+ {
+ gcry_md_close (md);
+ gcry_free (sbuf);
+ return ec;
+ }
+ if (!iter) /* Compute U_1: */
+ {
+ sbuf[saltlen] = (lidx >> 24);
+ sbuf[saltlen + 1] = (lidx >> 16);
+ sbuf[saltlen + 2] = (lidx >> 8);
+ sbuf[saltlen + 3] = lidx;
+ gcry_md_write (md, sbuf, saltlen + 4);
+ memcpy (ubuf, gcry_md_read (md, 0), hlen);
+ memcpy (tbuf, ubuf, hlen);
+ }
+ else /* Compute U_(2..c): */
+ {
+ gcry_md_write (md, ubuf, hlen);
+ memcpy (ubuf, gcry_md_read (md, 0), hlen);
+ for (i=0; i < hlen; i++)
+ tbuf[i] ^= ubuf[i];
+ }
+ }
+ if (lidx == l) /* Last block. */
+ memcpy (dk, tbuf, r);
+ else
+ {
+ memcpy (dk, tbuf, hlen);
+ dk += hlen;
+ }
+ }
+
+ gcry_md_close (md);
+ gcry_free (sbuf);
+ return 0;
+}
+
+
+/* Derive a key from a passphrase. KEYSIZE gives the requested size
+ of the keys in octets. KEYBUFFER is a caller provided buffer
+ filled on success with the derived key. The input passphrase is
+ taken from (PASSPHRASE,PASSPHRASELEN) which is an arbitrary memory
+ buffer. ALGO specifies the KDF algorithm to use; these are the
+ constants GCRY_KDF_*. SUBALGO specifies an algorithm used
+ internally by the KDF algorithms; this is usually a hash algorithm
+ but certain KDF algorithm may use it differently. {SALT,SALTLEN}
+ is a salt as needed by most KDF algorithms. ITERATIONS is a
+ positive integer parameter to most KDFs. 0 is returned on success,
+ or an error code on failure. */
+gpg_error_t
+gcry_kdf_derive (const void *passphrase, size_t passphraselen,
+ int algo, int subalgo,
+ const void *salt, size_t saltlen,
+ unsigned long iterations,
+ size_t keysize, void *keybuffer)
+{
+ gpg_err_code_t ec;
+
+ if (!passphrase || (!passphraselen && algo != GCRY_KDF_PBKDF2))
+ {
+ ec = GPG_ERR_INV_DATA;
+ goto leave;
+ }
+ if (!keybuffer || !keysize)
+ {
+ ec = GPG_ERR_INV_VALUE;
+ goto leave;
+ }
+
+
+ switch (algo)
+ {
+ case GCRY_KDF_SIMPLE_S2K:
+ case GCRY_KDF_SALTED_S2K:
+ case GCRY_KDF_ITERSALTED_S2K:
+ ec = openpgp_s2k (passphrase, passphraselen, algo, subalgo,
+ salt, saltlen, iterations, keysize, keybuffer);
+ break;
+
+ case GCRY_KDF_PBKDF1:
+ ec = GPG_ERR_UNSUPPORTED_ALGORITHM;
+ break;
+
+ case GCRY_KDF_PBKDF2:
+ ec = pkdf2 (passphrase, passphraselen, subalgo,
+ salt, saltlen, iterations, keysize, keybuffer);
+ break;
+
+ default:
+ ec = GPG_ERR_UNKNOWN_ALGORITHM;
+ break;
+ }
+
+ leave:
+ return gpg_error (ec);
+}
diff --git a/grub-core/lib/libgcrypt/cipher/md.c b/grub-core/lib/libgcrypt/cipher/md.c
new file mode 100644
index 0000000..c3b3a4f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/md.c
@@ -0,0 +1,1383 @@
+/* md.c - message digest dispatcher
+ * Copyright (C) 1998, 1999, 2002, 2003, 2006,
+ * 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "g10lib.h"
+#include "cipher.h"
+#include "ath.h"
+
+#include "rmd.h"
+
+/* A dummy extraspec so that we do not need to tests the extraspec
+ field from the module specification against NULL and instead
+ directly test the respective fields of extraspecs. */
+static md_extra_spec_t dummy_extra_spec;
+
+
+/* This is the list of the digest implementations included in
+ libgcrypt. */
+static struct digest_table_entry
+{
+ gcry_md_spec_t *digest;
+ md_extra_spec_t *extraspec;
+ unsigned int algorithm;
+ int fips_allowed;
+} digest_table[] =
+ {
+#if USE_CRC
+ /* We allow the CRC algorithms even in FIPS mode because they are
+ actually no cryptographic primitives. */
+ { &_gcry_digest_spec_crc32,
+ &dummy_extra_spec, GCRY_MD_CRC32, 1 },
+ { &_gcry_digest_spec_crc32_rfc1510,
+ &dummy_extra_spec, GCRY_MD_CRC32_RFC1510, 1 },
+ { &_gcry_digest_spec_crc24_rfc2440,
+ &dummy_extra_spec, GCRY_MD_CRC24_RFC2440, 1 },
+#endif
+#if USE_MD4
+ { &_gcry_digest_spec_md4,
+ &dummy_extra_spec, GCRY_MD_MD4 },
+#endif
+#if USE_MD5
+ { &_gcry_digest_spec_md5,
+ &dummy_extra_spec, GCRY_MD_MD5, 1 },
+#endif
+#if USE_RMD160
+ { &_gcry_digest_spec_rmd160,
+ &dummy_extra_spec, GCRY_MD_RMD160 },
+#endif
+#if USE_SHA1
+ { &_gcry_digest_spec_sha1,
+ &_gcry_digest_extraspec_sha1, GCRY_MD_SHA1, 1 },
+#endif
+#if USE_SHA256
+ { &_gcry_digest_spec_sha256,
+ &_gcry_digest_extraspec_sha256, GCRY_MD_SHA256, 1 },
+ { &_gcry_digest_spec_sha224,
+ &_gcry_digest_extraspec_sha224, GCRY_MD_SHA224, 1 },
+#endif
+#if USE_SHA512
+ { &_gcry_digest_spec_sha512,
+ &_gcry_digest_extraspec_sha512, GCRY_MD_SHA512, 1 },
+ { &_gcry_digest_spec_sha384,
+ &_gcry_digest_extraspec_sha384, GCRY_MD_SHA384, 1 },
+#endif
+#if USE_TIGER
+ { &_gcry_digest_spec_tiger,
+ &dummy_extra_spec, GCRY_MD_TIGER },
+ { &_gcry_digest_spec_tiger1,
+ &dummy_extra_spec, GCRY_MD_TIGER1 },
+ { &_gcry_digest_spec_tiger2,
+ &dummy_extra_spec, GCRY_MD_TIGER2 },
+#endif
+#if USE_WHIRLPOOL
+ { &_gcry_digest_spec_whirlpool,
+ &dummy_extra_spec, GCRY_MD_WHIRLPOOL },
+#endif
+ { NULL },
+ };
+
+/* List of registered digests. */
+static gcry_module_t digests_registered;
+
+/* This is the lock protecting DIGESTS_REGISTERED. */
+static ath_mutex_t digests_registered_lock = ATH_MUTEX_INITIALIZER;
+
+/* Flag to check whether the default ciphers have already been
+ registered. */
+static int default_digests_registered;
+
+typedef struct gcry_md_list
+{
+ gcry_md_spec_t *digest;
+ gcry_module_t module;
+ struct gcry_md_list *next;
+ size_t actual_struct_size; /* Allocated size of this structure. */
+ PROPERLY_ALIGNED_TYPE context;
+} GcryDigestEntry;
+
+/* this structure is put right after the gcry_md_hd_t buffer, so that
+ * only one memory block is needed. */
+struct gcry_md_context
+{
+ int magic;
+ size_t actual_handle_size; /* Allocated size of this handle. */
+ int secure;
+ FILE *debug;
+ int finalized;
+ GcryDigestEntry *list;
+ byte *macpads;
+ int macpads_Bsize; /* Blocksize as used for the HMAC pads. */
+};
+
+
+#define CTX_MAGIC_NORMAL 0x11071961
+#define CTX_MAGIC_SECURE 0x16917011
+
+/* Convenient macro for registering the default digests. */
+#define REGISTER_DEFAULT_DIGESTS \
+ do \
+ { \
+ ath_mutex_lock (&digests_registered_lock); \
+ if (! default_digests_registered) \
+ { \
+ md_register_default (); \
+ default_digests_registered = 1; \
+ } \
+ ath_mutex_unlock (&digests_registered_lock); \
+ } \
+ while (0)
+
+
+static const char * digest_algo_to_string( int algo );
+static gcry_err_code_t check_digest_algo (int algo);
+static gcry_err_code_t md_open (gcry_md_hd_t *h, int algo,
+ int secure, int hmac);
+static gcry_err_code_t md_enable (gcry_md_hd_t hd, int algo);
+static gcry_err_code_t md_copy (gcry_md_hd_t a, gcry_md_hd_t *b);
+static void md_close (gcry_md_hd_t a);
+static void md_write (gcry_md_hd_t a, const void *inbuf, size_t inlen);
+static void md_final(gcry_md_hd_t a);
+static byte *md_read( gcry_md_hd_t a, int algo );
+static int md_get_algo( gcry_md_hd_t a );
+static int md_digest_length( int algo );
+static const byte *md_asn_oid( int algo, size_t *asnlen, size_t *mdlen );
+static void md_start_debug ( gcry_md_hd_t a, const char *suffix );
+static void md_stop_debug ( gcry_md_hd_t a );
+
+
+
+
+/* Internal function. Register all the ciphers included in
+ CIPHER_TABLE. Returns zero on success or an error code. */
+static void
+md_register_default (void)
+{
+ gcry_err_code_t err = 0;
+ int i;
+
+ for (i = 0; !err && digest_table[i].digest; i++)
+ {
+ if ( fips_mode ())
+ {
+ if (!digest_table[i].fips_allowed)
+ continue;
+ if (digest_table[i].algorithm == GCRY_MD_MD5
+ && _gcry_enforced_fips_mode () )
+ continue; /* Do not register in enforced fips mode. */
+ }
+
+ err = _gcry_module_add (&digests_registered,
+ digest_table[i].algorithm,
+ (void *) digest_table[i].digest,
+ (void *) digest_table[i].extraspec,
+ NULL);
+ }
+
+ if (err)
+ BUG ();
+}
+
+/* Internal callback function. */
+static int
+gcry_md_lookup_func_name (void *spec, void *data)
+{
+ gcry_md_spec_t *digest = (gcry_md_spec_t *) spec;
+ char *name = (char *) data;
+
+ return (! stricmp (digest->name, name));
+}
+
+/* Internal callback function. Used via _gcry_module_lookup. */
+static int
+gcry_md_lookup_func_oid (void *spec, void *data)
+{
+ gcry_md_spec_t *digest = (gcry_md_spec_t *) spec;
+ char *oid = (char *) data;
+ gcry_md_oid_spec_t *oid_specs = digest->oids;
+ int ret = 0, i;
+
+ if (oid_specs)
+ {
+ for (i = 0; oid_specs[i].oidstring && (! ret); i++)
+ if (! stricmp (oid, oid_specs[i].oidstring))
+ ret = 1;
+ }
+
+ return ret;
+}
+
+/* Internal function. Lookup a digest entry by it's name. */
+static gcry_module_t
+gcry_md_lookup_name (const char *name)
+{
+ gcry_module_t digest;
+
+ digest = _gcry_module_lookup (digests_registered, (void *) name,
+ gcry_md_lookup_func_name);
+
+ return digest;
+}
+
+/* Internal function. Lookup a cipher entry by it's oid. */
+static gcry_module_t
+gcry_md_lookup_oid (const char *oid)
+{
+ gcry_module_t digest;
+
+ digest = _gcry_module_lookup (digests_registered, (void *) oid,
+ gcry_md_lookup_func_oid);
+
+ return digest;
+}
+
+/* Register a new digest module whose specification can be found in
+ DIGEST. On success, a new algorithm ID is stored in ALGORITHM_ID
+ and a pointer representhing this module is stored in MODULE. */
+gcry_error_t
+_gcry_md_register (gcry_md_spec_t *digest,
+ md_extra_spec_t *extraspec,
+ unsigned int *algorithm_id,
+ gcry_module_t *module)
+{
+ gcry_err_code_t err = 0;
+ gcry_module_t mod;
+
+ /* We do not support module loading in fips mode. */
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ ath_mutex_lock (&digests_registered_lock);
+ err = _gcry_module_add (&digests_registered, 0,
+ (void *) digest,
+ (void *)(extraspec? extraspec : &dummy_extra_spec),
+ &mod);
+ ath_mutex_unlock (&digests_registered_lock);
+
+ if (! err)
+ {
+ *module = mod;
+ *algorithm_id = mod->mod_id;
+ }
+
+ return gcry_error (err);
+}
+
+/* Unregister the digest identified by ID, which must have been
+ registered with gcry_digest_register. */
+void
+gcry_md_unregister (gcry_module_t module)
+{
+ ath_mutex_lock (&digests_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&digests_registered_lock);
+}
+
+
+static int
+search_oid (const char *oid, int *algorithm, gcry_md_oid_spec_t *oid_spec)
+{
+ gcry_module_t module;
+ int ret = 0;
+
+ if (oid && ((! strncmp (oid, "oid.", 4))
+ || (! strncmp (oid, "OID.", 4))))
+ oid += 4;
+
+ module = gcry_md_lookup_oid (oid);
+ if (module)
+ {
+ gcry_md_spec_t *digest = module->spec;
+ int i;
+
+ for (i = 0; digest->oids[i].oidstring && !ret; i++)
+ if (! stricmp (oid, digest->oids[i].oidstring))
+ {
+ if (algorithm)
+ *algorithm = module->mod_id;
+ if (oid_spec)
+ *oid_spec = digest->oids[i];
+ ret = 1;
+ }
+ _gcry_module_release (module);
+ }
+
+ return ret;
+}
+
+/****************
+ * Map a string to the digest algo
+ */
+int
+gcry_md_map_name (const char *string)
+{
+ gcry_module_t digest;
+ int ret, algorithm = 0;
+
+ if (! string)
+ return 0;
+
+ REGISTER_DEFAULT_DIGESTS;
+
+ /* If the string starts with a digit (optionally prefixed with
+ either "OID." or "oid."), we first look into our table of ASN.1
+ object identifiers to figure out the algorithm */
+
+ ath_mutex_lock (&digests_registered_lock);
+
+ ret = search_oid (string, &algorithm, NULL);
+ if (! ret)
+ {
+ /* Not found, search a matching digest name. */
+ digest = gcry_md_lookup_name (string);
+ if (digest)
+ {
+ algorithm = digest->mod_id;
+ _gcry_module_release (digest);
+ }
+ }
+ ath_mutex_unlock (&digests_registered_lock);
+
+ return algorithm;
+}
+
+
+/****************
+ * Map a digest algo to a string
+ */
+static const char *
+digest_algo_to_string (int algorithm)
+{
+ const char *name = NULL;
+ gcry_module_t digest;
+
+ REGISTER_DEFAULT_DIGESTS;
+
+ ath_mutex_lock (&digests_registered_lock);
+ digest = _gcry_module_lookup_id (digests_registered, algorithm);
+ if (digest)
+ {
+ name = ((gcry_md_spec_t *) digest->spec)->name;
+ _gcry_module_release (digest);
+ }
+ ath_mutex_unlock (&digests_registered_lock);
+
+ return name;
+}
+
+/****************
+ * This function simply returns the name of the algorithm or some constant
+ * string when there is no algo. It will never return NULL.
+ * Use the macro gcry_md_test_algo() to check whether the algorithm
+ * is valid.
+ */
+const char *
+gcry_md_algo_name (int algorithm)
+{
+ const char *s = digest_algo_to_string (algorithm);
+ return s ? s : "?";
+}
+
+
+static gcry_err_code_t
+check_digest_algo (int algorithm)
+{
+ gcry_err_code_t rc = 0;
+ gcry_module_t digest;
+
+ REGISTER_DEFAULT_DIGESTS;
+
+ ath_mutex_lock (&digests_registered_lock);
+ digest = _gcry_module_lookup_id (digests_registered, algorithm);
+ if (digest)
+ _gcry_module_release (digest);
+ else
+ rc = GPG_ERR_DIGEST_ALGO;
+ ath_mutex_unlock (&digests_registered_lock);
+
+ return rc;
+}
+
+
+
+/****************
+ * Open a message digest handle for use with algorithm ALGO.
+ * More algorithms may be added by md_enable(). The initial algorithm
+ * may be 0.
+ */
+static gcry_err_code_t
+md_open (gcry_md_hd_t *h, int algo, int secure, int hmac)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ int bufsize = secure ? 512 : 1024;
+ struct gcry_md_context *ctx;
+ gcry_md_hd_t hd;
+ size_t n;
+
+ /* Allocate a memory area to hold the caller visible buffer with it's
+ * control information and the data required by this module. Set the
+ * context pointer at the beginning to this area.
+ * We have to use this strange scheme because we want to hide the
+ * internal data but have a variable sized buffer.
+ *
+ * +---+------+---........------+-------------+
+ * !ctx! bctl ! buffer ! private !
+ * +---+------+---........------+-------------+
+ * ! ^
+ * !---------------------------!
+ *
+ * We have to make sure that private is well aligned.
+ */
+ n = sizeof (struct gcry_md_handle) + bufsize;
+ n = ((n + sizeof (PROPERLY_ALIGNED_TYPE) - 1)
+ / sizeof (PROPERLY_ALIGNED_TYPE)) * sizeof (PROPERLY_ALIGNED_TYPE);
+
+ /* Allocate and set the Context pointer to the private data */
+ if (secure)
+ hd = gcry_malloc_secure (n + sizeof (struct gcry_md_context));
+ else
+ hd = gcry_malloc (n + sizeof (struct gcry_md_context));
+
+ if (! hd)
+ err = gpg_err_code_from_errno (errno);
+
+ if (! err)
+ {
+ hd->ctx = ctx = (struct gcry_md_context *) ((char *) hd + n);
+ /* Setup the globally visible data (bctl in the diagram).*/
+ hd->bufsize = n - sizeof (struct gcry_md_handle) + 1;
+ hd->bufpos = 0;
+
+ /* Initialize the private data. */
+ memset (hd->ctx, 0, sizeof *hd->ctx);
+ ctx->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL;
+ ctx->actual_handle_size = n + sizeof (struct gcry_md_context);
+ ctx->secure = secure;
+
+ if (hmac)
+ {
+ switch (algo)
+ {
+ case GCRY_MD_SHA384:
+ case GCRY_MD_SHA512:
+ ctx->macpads_Bsize = 128;
+ break;
+ default:
+ ctx->macpads_Bsize = 64;
+ break;
+ }
+ ctx->macpads = gcry_malloc_secure (2*(ctx->macpads_Bsize));
+ if (!ctx->macpads)
+ {
+ err = gpg_err_code_from_errno (errno);
+ md_close (hd);
+ }
+ }
+ }
+
+ if (! err)
+ {
+ /* Hmmm, should we really do that? - yes [-wk] */
+ _gcry_fast_random_poll ();
+
+ if (algo)
+ {
+ err = md_enable (hd, algo);
+ if (err)
+ md_close (hd);
+ }
+ }
+
+ if (! err)
+ *h = hd;
+
+ return err;
+}
+
+/* Create a message digest object for algorithm ALGO. FLAGS may be
+ given as an bitwise OR of the gcry_md_flags values. ALGO may be
+ given as 0 if the algorithms to be used are later set using
+ gcry_md_enable. H is guaranteed to be a valid handle or NULL on
+ error. */
+gcry_error_t
+gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ gcry_md_hd_t hd;
+
+ if ((flags & ~(GCRY_MD_FLAG_SECURE | GCRY_MD_FLAG_HMAC)))
+ err = GPG_ERR_INV_ARG;
+ else
+ {
+ err = md_open (&hd, algo, (flags & GCRY_MD_FLAG_SECURE),
+ (flags & GCRY_MD_FLAG_HMAC));
+ }
+
+ *h = err? NULL : hd;
+ return gcry_error (err);
+}
+
+
+
+static gcry_err_code_t
+md_enable (gcry_md_hd_t hd, int algorithm)
+{
+ struct gcry_md_context *h = hd->ctx;
+ gcry_md_spec_t *digest = NULL;
+ GcryDigestEntry *entry;
+ gcry_module_t module;
+ gcry_err_code_t err = 0;
+
+ for (entry = h->list; entry; entry = entry->next)
+ if (entry->module->mod_id == algorithm)
+ return err; /* already enabled */
+
+ REGISTER_DEFAULT_DIGESTS;
+
+ ath_mutex_lock (&digests_registered_lock);
+ module = _gcry_module_lookup_id (digests_registered, algorithm);
+ ath_mutex_unlock (&digests_registered_lock);
+ if (! module)
+ {
+ log_debug ("md_enable: algorithm %d not available\n", algorithm);
+ err = GPG_ERR_DIGEST_ALGO;
+ }
+ else
+ digest = (gcry_md_spec_t *) module->spec;
+
+
+ if (!err && algorithm == GCRY_MD_MD5 && fips_mode ())
+ {
+ _gcry_inactivate_fips_mode ("MD5 used");
+ if (_gcry_enforced_fips_mode () )
+ {
+ /* We should never get to here because we do not register
+ MD5 in enforced fips mode. But better throw an error. */
+ err = GPG_ERR_DIGEST_ALGO;
+ }
+ }
+
+ if (!err)
+ {
+ size_t size = (sizeof (*entry)
+ + digest->contextsize
+ - sizeof (entry->context));
+
+ /* And allocate a new list entry. */
+ if (h->secure)
+ entry = gcry_malloc_secure (size);
+ else
+ entry = gcry_malloc (size);
+
+ if (! entry)
+ err = gpg_err_code_from_errno (errno);
+ else
+ {
+ entry->digest = digest;
+ entry->module = module;
+ entry->next = h->list;
+ entry->actual_struct_size = size;
+ h->list = entry;
+
+ /* And init this instance. */
+ entry->digest->init (&entry->context.c);
+ }
+ }
+
+ if (err)
+ {
+ if (module)
+ {
+ ath_mutex_lock (&digests_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&digests_registered_lock);
+ }
+ }
+
+ return err;
+}
+
+
+gcry_error_t
+gcry_md_enable (gcry_md_hd_t hd, int algorithm)
+{
+ return gcry_error (md_enable (hd, algorithm));
+}
+
+static gcry_err_code_t
+md_copy (gcry_md_hd_t ahd, gcry_md_hd_t *b_hd)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ struct gcry_md_context *a = ahd->ctx;
+ struct gcry_md_context *b;
+ GcryDigestEntry *ar, *br;
+ gcry_md_hd_t bhd;
+ size_t n;
+
+ if (ahd->bufpos)
+ md_write (ahd, NULL, 0);
+
+ n = (char *) ahd->ctx - (char *) ahd;
+ if (a->secure)
+ bhd = gcry_malloc_secure (n + sizeof (struct gcry_md_context));
+ else
+ bhd = gcry_malloc (n + sizeof (struct gcry_md_context));
+
+ if (! bhd)
+ err = gpg_err_code_from_errno (errno);
+
+ if (! err)
+ {
+ bhd->ctx = b = (struct gcry_md_context *) ((char *) bhd + n);
+ /* No need to copy the buffer due to the write above. */
+ gcry_assert (ahd->bufsize == (n - sizeof (struct gcry_md_handle) + 1));
+ bhd->bufsize = ahd->bufsize;
+ bhd->bufpos = 0;
+ gcry_assert (! ahd->bufpos);
+ memcpy (b, a, sizeof *a);
+ b->list = NULL;
+ b->debug = NULL;
+ if (a->macpads)
+ {
+ b->macpads = gcry_malloc_secure (2*(a->macpads_Bsize));
+ if (! b->macpads)
+ {
+ err = gpg_err_code_from_errno (errno);
+ md_close (bhd);
+ }
+ else
+ memcpy (b->macpads, a->macpads, (2*(a->macpads_Bsize)));
+ }
+ }
+
+ /* Copy the complete list of algorithms. The copied list is
+ reversed, but that doesn't matter. */
+ if (!err)
+ {
+ for (ar = a->list; ar; ar = ar->next)
+ {
+ if (a->secure)
+ br = gcry_malloc_secure (sizeof *br
+ + ar->digest->contextsize
+ - sizeof(ar->context));
+ else
+ br = gcry_malloc (sizeof *br
+ + ar->digest->contextsize
+ - sizeof (ar->context));
+ if (!br)
+ {
+ err = gpg_err_code_from_errno (errno);
+ md_close (bhd);
+ break;
+ }
+
+ memcpy (br, ar, (sizeof (*br) + ar->digest->contextsize
+ - sizeof (ar->context)));
+ br->next = b->list;
+ b->list = br;
+
+ /* Add a reference to the module. */
+ ath_mutex_lock (&digests_registered_lock);
+ _gcry_module_use (br->module);
+ ath_mutex_unlock (&digests_registered_lock);
+ }
+ }
+
+ if (a->debug && !err)
+ md_start_debug (bhd, "unknown");
+
+ if (!err)
+ *b_hd = bhd;
+
+ return err;
+}
+
+gcry_error_t
+gcry_md_copy (gcry_md_hd_t *handle, gcry_md_hd_t hd)
+{
+ gcry_err_code_t err;
+
+ err = md_copy (hd, handle);
+ if (err)
+ *handle = NULL;
+ return gcry_error (err);
+}
+
+/*
+ * Reset all contexts and discard any buffered stuff. This may be used
+ * instead of a md_close(); md_open().
+ */
+void
+gcry_md_reset (gcry_md_hd_t a)
+{
+ GcryDigestEntry *r;
+
+ /* Note: We allow this even in fips non operational mode. */
+
+ a->bufpos = a->ctx->finalized = 0;
+
+ for (r = a->ctx->list; r; r = r->next)
+ {
+ memset (r->context.c, 0, r->digest->contextsize);
+ (*r->digest->init) (&r->context.c);
+ }
+ if (a->ctx->macpads)
+ md_write (a, a->ctx->macpads, a->ctx->macpads_Bsize); /* inner pad */
+}
+
+static void
+md_close (gcry_md_hd_t a)
+{
+ GcryDigestEntry *r, *r2;
+
+ if (! a)
+ return;
+ if (a->ctx->debug)
+ md_stop_debug (a);
+ for (r = a->ctx->list; r; r = r2)
+ {
+ r2 = r->next;
+ ath_mutex_lock (&digests_registered_lock);
+ _gcry_module_release (r->module);
+ ath_mutex_unlock (&digests_registered_lock);
+ wipememory (r, r->actual_struct_size);
+ gcry_free (r);
+ }
+
+ if (a->ctx->macpads)
+ {
+ wipememory (a->ctx->macpads, 2*(a->ctx->macpads_Bsize));
+ gcry_free(a->ctx->macpads);
+ }
+
+ wipememory (a, a->ctx->actual_handle_size);
+ gcry_free(a);
+}
+
+void
+gcry_md_close (gcry_md_hd_t hd)
+{
+ /* Note: We allow this even in fips non operational mode. */
+ md_close (hd);
+}
+
+static void
+md_write (gcry_md_hd_t a, const void *inbuf, size_t inlen)
+{
+ GcryDigestEntry *r;
+
+ if (a->ctx->debug)
+ {
+ if (a->bufpos && fwrite (a->buf, a->bufpos, 1, a->ctx->debug) != 1)
+ BUG();
+ if (inlen && fwrite (inbuf, inlen, 1, a->ctx->debug) != 1)
+ BUG();
+ }
+
+ for (r = a->ctx->list; r; r = r->next)
+ {
+ if (a->bufpos)
+ (*r->digest->write) (&r->context.c, a->buf, a->bufpos);
+ (*r->digest->write) (&r->context.c, inbuf, inlen);
+ }
+ a->bufpos = 0;
+}
+
+void
+gcry_md_write (gcry_md_hd_t hd, const void *inbuf, size_t inlen)
+{
+ md_write (hd, inbuf, inlen);
+}
+
+static void
+md_final (gcry_md_hd_t a)
+{
+ GcryDigestEntry *r;
+
+ if (a->ctx->finalized)
+ return;
+
+ if (a->bufpos)
+ md_write (a, NULL, 0);
+
+ for (r = a->ctx->list; r; r = r->next)
+ (*r->digest->final) (&r->context.c);
+
+ a->ctx->finalized = 1;
+
+ if (a->ctx->macpads)
+ {
+ /* Finish the hmac. */
+ int algo = md_get_algo (a);
+ byte *p = md_read (a, algo);
+ size_t dlen = md_digest_length (algo);
+ gcry_md_hd_t om;
+ gcry_err_code_t err = md_open (&om, algo, a->ctx->secure, 0);
+
+ if (err)
+ _gcry_fatal_error (err, NULL);
+ md_write (om,
+ (a->ctx->macpads)+(a->ctx->macpads_Bsize),
+ a->ctx->macpads_Bsize);
+ md_write (om, p, dlen);
+ md_final (om);
+ /* Replace our digest with the mac (they have the same size). */
+ memcpy (p, md_read (om, algo), dlen);
+ md_close (om);
+ }
+}
+
+static gcry_err_code_t
+prepare_macpads (gcry_md_hd_t hd, const unsigned char *key, size_t keylen)
+{
+ int i;
+ int algo = md_get_algo (hd);
+ unsigned char *helpkey = NULL;
+ unsigned char *ipad, *opad;
+
+ if (!algo)
+ return GPG_ERR_DIGEST_ALGO; /* Might happen if no algo is enabled. */
+
+ if ( keylen > hd->ctx->macpads_Bsize )
+ {
+ helpkey = gcry_malloc_secure (md_digest_length (algo));
+ if (!helpkey)
+ return gpg_err_code_from_errno (errno);
+ gcry_md_hash_buffer (algo, helpkey, key, keylen);
+ key = helpkey;
+ keylen = md_digest_length (algo);
+ gcry_assert ( keylen <= hd->ctx->macpads_Bsize );
+ }
+
+ memset ( hd->ctx->macpads, 0, 2*(hd->ctx->macpads_Bsize) );
+ ipad = hd->ctx->macpads;
+ opad = (hd->ctx->macpads)+(hd->ctx->macpads_Bsize);
+ memcpy ( ipad, key, keylen );
+ memcpy ( opad, key, keylen );
+ for (i=0; i < hd->ctx->macpads_Bsize; i++ )
+ {
+ ipad[i] ^= 0x36;
+ opad[i] ^= 0x5c;
+ }
+ gcry_free (helpkey);
+
+ return GPG_ERR_NO_ERROR;
+}
+
+gcry_error_t
+gcry_md_ctl (gcry_md_hd_t hd, int cmd, void *buffer, size_t buflen)
+{
+ gcry_err_code_t rc = 0;
+
+ switch (cmd)
+ {
+ case GCRYCTL_FINALIZE:
+ md_final (hd);
+ break;
+ case GCRYCTL_SET_KEY:
+ rc = gcry_err_code (gcry_md_setkey (hd, buffer, buflen));
+ break;
+ case GCRYCTL_START_DUMP:
+ md_start_debug (hd, buffer);
+ break;
+ case GCRYCTL_STOP_DUMP:
+ md_stop_debug ( hd );
+ break;
+ default:
+ rc = GPG_ERR_INV_OP;
+ }
+ return gcry_error (rc);
+}
+
+gcry_error_t
+gcry_md_setkey (gcry_md_hd_t hd, const void *key, size_t keylen)
+{
+ gcry_err_code_t rc = GPG_ERR_NO_ERROR;
+
+ if (!hd->ctx->macpads)
+ rc = GPG_ERR_CONFLICT;
+ else
+ {
+ rc = prepare_macpads (hd, key, keylen);
+ if (! rc)
+ gcry_md_reset (hd);
+ }
+
+ return gcry_error (rc);
+}
+
+/* The new debug interface. If SUFFIX is a string it creates an debug
+ file for the context HD. IF suffix is NULL, the file is closed and
+ debugging is stopped. */
+void
+gcry_md_debug (gcry_md_hd_t hd, const char *suffix)
+{
+ if (suffix)
+ md_start_debug (hd, suffix);
+ else
+ md_stop_debug (hd);
+}
+
+
+
+/****************
+ * if ALGO is null get the digest for the used algo (which should be only one)
+ */
+static byte *
+md_read( gcry_md_hd_t a, int algo )
+{
+ GcryDigestEntry *r = a->ctx->list;
+
+ if (! algo)
+ {
+ /* Return the first algorithm */
+ if (r)
+ {
+ if (r->next)
+ log_debug ("more than one algorithm in md_read(0)\n");
+ return r->digest->read (&r->context.c);
+ }
+ }
+ else
+ {
+ for (r = a->ctx->list; r; r = r->next)
+ if (r->module->mod_id == algo)
+ return r->digest->read (&r->context.c);
+ }
+ BUG();
+ return NULL;
+}
+
+/*
+ * Read out the complete digest, this function implictly finalizes
+ * the hash.
+ */
+byte *
+gcry_md_read (gcry_md_hd_t hd, int algo)
+{
+ /* This function is expected to always return a digest, thus we
+ can't return an error which we actually should do in
+ non-operational state. */
+ gcry_md_ctl (hd, GCRYCTL_FINALIZE, NULL, 0);
+ return md_read (hd, algo);
+}
+
+
+/*
+ * Read out an intermediate digest. Not yet functional.
+ */
+gcry_err_code_t
+gcry_md_get (gcry_md_hd_t hd, int algo, byte *buffer, int buflen)
+{
+ (void)hd;
+ (void)algo;
+ (void)buffer;
+ (void)buflen;
+
+ /*md_digest ... */
+ fips_signal_error ("unimplemented function called");
+ return GPG_ERR_INTERNAL;
+}
+
+
+/*
+ * Shortcut function to hash a buffer with a given algo. The only
+ * guaranteed supported algorithms are RIPE-MD160 and SHA-1. The
+ * supplied digest buffer must be large enough to store the resulting
+ * hash. No error is returned, the function will abort on an invalid
+ * algo. DISABLED_ALGOS are ignored here. */
+void
+gcry_md_hash_buffer (int algo, void *digest,
+ const void *buffer, size_t length)
+{
+ if (algo == GCRY_MD_SHA1)
+ _gcry_sha1_hash_buffer (digest, buffer, length);
+ else if (algo == GCRY_MD_RMD160 && !fips_mode () )
+ _gcry_rmd160_hash_buffer (digest, buffer, length);
+ else
+ {
+ /* For the others we do not have a fast function, so we use the
+ normal functions. */
+ gcry_md_hd_t h;
+ gpg_err_code_t err;
+
+ if (algo == GCRY_MD_MD5 && fips_mode ())
+ {
+ _gcry_inactivate_fips_mode ("MD5 used");
+ if (_gcry_enforced_fips_mode () )
+ {
+ /* We should never get to here because we do not register
+ MD5 in enforced fips mode. */
+ _gcry_fips_noreturn ();
+ }
+ }
+
+ err = md_open (&h, algo, 0, 0);
+ if (err)
+ log_bug ("gcry_md_open failed for algo %d: %s",
+ algo, gpg_strerror (gcry_error(err)));
+ md_write (h, (byte *) buffer, length);
+ md_final (h);
+ memcpy (digest, md_read (h, algo), md_digest_length (algo));
+ md_close (h);
+ }
+}
+
+static int
+md_get_algo (gcry_md_hd_t a)
+{
+ GcryDigestEntry *r = a->ctx->list;
+
+ if (r && r->next)
+ {
+ fips_signal_error ("possible usage error");
+ log_error ("WARNING: more than one algorithm in md_get_algo()\n");
+ }
+ return r ? r->module->mod_id : 0;
+}
+
+int
+gcry_md_get_algo (gcry_md_hd_t hd)
+{
+ return md_get_algo (hd);
+}
+
+
+/****************
+ * Return the length of the digest
+ */
+static int
+md_digest_length (int algorithm)
+{
+ gcry_module_t digest;
+ int mdlen = 0;
+
+ REGISTER_DEFAULT_DIGESTS;
+
+ ath_mutex_lock (&digests_registered_lock);
+ digest = _gcry_module_lookup_id (digests_registered, algorithm);
+ if (digest)
+ {
+ mdlen = ((gcry_md_spec_t *) digest->spec)->mdlen;
+ _gcry_module_release (digest);
+ }
+ ath_mutex_unlock (&digests_registered_lock);
+
+ return mdlen;
+}
+
+/****************
+ * Return the length of the digest in bytes.
+ * This function will return 0 in case of errors.
+ */
+unsigned int
+gcry_md_get_algo_dlen (int algorithm)
+{
+ return md_digest_length (algorithm);
+}
+
+
+/* Hmmm: add a mode to enumerate the OIDs
+ * to make g10/sig-check.c more portable */
+static const byte *
+md_asn_oid (int algorithm, size_t *asnlen, size_t *mdlen)
+{
+ const byte *asnoid = NULL;
+ gcry_module_t digest;
+
+ REGISTER_DEFAULT_DIGESTS;
+
+ ath_mutex_lock (&digests_registered_lock);
+ digest = _gcry_module_lookup_id (digests_registered, algorithm);
+ if (digest)
+ {
+ if (asnlen)
+ *asnlen = ((gcry_md_spec_t *) digest->spec)->asnlen;
+ if (mdlen)
+ *mdlen = ((gcry_md_spec_t *) digest->spec)->mdlen;
+ asnoid = ((gcry_md_spec_t *) digest->spec)->asnoid;
+ _gcry_module_release (digest);
+ }
+ else
+ log_bug ("no ASN.1 OID for md algo %d\n", algorithm);
+ ath_mutex_unlock (&digests_registered_lock);
+
+ return asnoid;
+}
+
+
+
+/****************
+ * Return information about the given cipher algorithm
+ * WHAT select the kind of information returned:
+ * GCRYCTL_TEST_ALGO:
+ * Returns 0 when the specified algorithm is available for use.
+ * buffer and nbytes must be zero.
+ * GCRYCTL_GET_ASNOID:
+ * Return the ASNOID of the algorithm in buffer. if buffer is NULL, only
+ * the required length is returned.
+ *
+ * Note: Because this function is in most cases used to return an
+ * integer value, we can make it easier for the caller to just look at
+ * the return value. The caller will in all cases consult the value
+ * and thereby detecting whether a error occurred or not (i.e. while checking
+ * the block size)
+ */
+gcry_error_t
+gcry_md_algo_info (int algo, int what, void *buffer, size_t *nbytes)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ switch (what)
+ {
+ case GCRYCTL_TEST_ALGO:
+ if (buffer || nbytes)
+ err = GPG_ERR_INV_ARG;
+ else
+ err = check_digest_algo (algo);
+ break;
+
+ case GCRYCTL_GET_ASNOID:
+ /* We need to check that the algo is available because
+ md_asn_oid would otherwise raise an assertion. */
+ err = check_digest_algo (algo);
+ if (!err)
+ {
+ const char unsigned *asn;
+ size_t asnlen;
+
+ asn = md_asn_oid (algo, &asnlen, NULL);
+ if (buffer && (*nbytes >= asnlen))
+ {
+ memcpy (buffer, asn, asnlen);
+ *nbytes = asnlen;
+ }
+ else if (!buffer && nbytes)
+ *nbytes = asnlen;
+ else
+ {
+ if (buffer)
+ err = GPG_ERR_TOO_SHORT;
+ else
+ err = GPG_ERR_INV_ARG;
+ }
+ }
+ break;
+
+ default:
+ err = GPG_ERR_INV_OP;
+ }
+
+ return gcry_error (err);
+}
+
+
+static void
+md_start_debug ( gcry_md_hd_t md, const char *suffix )
+{
+ static int idx=0;
+ char buf[50];
+
+ if (fips_mode ())
+ return;
+
+ if ( md->ctx->debug )
+ {
+ log_debug("Oops: md debug already started\n");
+ return;
+ }
+ idx++;
+ snprintf (buf, DIM(buf)-1, "dbgmd-%05d.%.10s", idx, suffix );
+ md->ctx->debug = fopen(buf, "w");
+ if ( !md->ctx->debug )
+ log_debug("md debug: can't open %s\n", buf );
+}
+
+static void
+md_stop_debug( gcry_md_hd_t md )
+{
+ if ( md->ctx->debug )
+ {
+ if ( md->bufpos )
+ md_write ( md, NULL, 0 );
+ fclose (md->ctx->debug);
+ md->ctx->debug = NULL;
+ }
+
+#ifdef HAVE_U64_TYPEDEF
+ { /* a kludge to pull in the __muldi3 for Solaris */
+ volatile u32 a = (u32)(ulong)md;
+ volatile u64 b = 42;
+ volatile u64 c;
+ c = a * b;
+ (void)c;
+ }
+#endif
+}
+
+
+
+/*
+ * Return information about the digest handle.
+ * GCRYCTL_IS_SECURE:
+ * Returns 1 when the handle works on secured memory
+ * otherwise 0 is returned. There is no error return.
+ * GCRYCTL_IS_ALGO_ENABLED:
+ * Returns 1 if the algo is enabled for that handle.
+ * The algo must be passed as the address of an int.
+ */
+gcry_error_t
+gcry_md_info (gcry_md_hd_t h, int cmd, void *buffer, size_t *nbytes)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ switch (cmd)
+ {
+ case GCRYCTL_IS_SECURE:
+ *nbytes = h->ctx->secure;
+ break;
+
+ case GCRYCTL_IS_ALGO_ENABLED:
+ {
+ GcryDigestEntry *r;
+ int algo;
+
+ if ( !buffer || (nbytes && (*nbytes != sizeof (int))))
+ err = GPG_ERR_INV_ARG;
+ else
+ {
+ algo = *(int*)buffer;
+
+ *nbytes = 0;
+ for(r=h->ctx->list; r; r = r->next ) {
+ if (r->module->mod_id == algo)
+ {
+ *nbytes = 1;
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ default:
+ err = GPG_ERR_INV_OP;
+ }
+
+ return gcry_error (err);
+}
+
+
+/* Explicitly initialize this module. */
+gcry_err_code_t
+_gcry_md_init (void)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ REGISTER_DEFAULT_DIGESTS;
+
+ return err;
+}
+
+
+int
+gcry_md_is_secure (gcry_md_hd_t a)
+{
+ size_t value;
+
+ if (gcry_md_info (a, GCRYCTL_IS_SECURE, NULL, &value))
+ value = 1; /* It seems to be better to assume secure memory on
+ error. */
+ return value;
+}
+
+
+int
+gcry_md_is_enabled (gcry_md_hd_t a, int algo)
+{
+ size_t value;
+
+ value = sizeof algo;
+ if (gcry_md_info (a, GCRYCTL_IS_ALGO_ENABLED, &algo, &value))
+ value = 0;
+ return value;
+}
+
+/* Get a list consisting of the IDs of the loaded message digest
+ modules. If LIST is zero, write the number of loaded message
+ digest modules to LIST_LENGTH and return. If LIST is non-zero, the
+ first *LIST_LENGTH algorithm IDs are stored in LIST, which must be
+ of according size. In case there are less message digest modules
+ than *LIST_LENGTH, *LIST_LENGTH is updated to the correct
+ number. */
+gcry_error_t
+gcry_md_list (int *list, int *list_length)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ ath_mutex_lock (&digests_registered_lock);
+ err = _gcry_module_list (digests_registered, list, list_length);
+ ath_mutex_unlock (&digests_registered_lock);
+
+ return err;
+}
+
+
+/* Run the selftests for digest algorithm ALGO with optional reporting
+ function REPORT. */
+gpg_error_t
+_gcry_md_selftest (int algo, int extended, selftest_report_func_t report)
+{
+ gcry_module_t module = NULL;
+ cipher_extra_spec_t *extraspec = NULL;
+ gcry_err_code_t ec = 0;
+
+ REGISTER_DEFAULT_DIGESTS;
+
+ ath_mutex_lock (&digests_registered_lock);
+ module = _gcry_module_lookup_id (digests_registered, algo);
+ if (module && !(module->flags & FLAG_MODULE_DISABLED))
+ extraspec = module->extraspec;
+ ath_mutex_unlock (&digests_registered_lock);
+ if (extraspec && extraspec->selftest)
+ ec = extraspec->selftest (algo, extended, report);
+ else
+ {
+ ec = GPG_ERR_DIGEST_ALGO;
+ if (report)
+ report ("digest", algo, "module",
+ module && !(module->flags & FLAG_MODULE_DISABLED)?
+ "no selftest available" :
+ module? "algorithm disabled" : "algorithm not found");
+ }
+
+ if (module)
+ {
+ ath_mutex_lock (&digests_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&digests_registered_lock);
+ }
+ return gpg_error (ec);
+}
diff --git a/grub-core/lib/libgcrypt/cipher/md4.c b/grub-core/lib/libgcrypt/cipher/md4.c
new file mode 100644
index 0000000..22fbf8d
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/md4.c
@@ -0,0 +1,327 @@
+/* md4.c - MD4 Message-Digest Algorithm
+ * Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Based on md5.c in libgcrypt, but rewritten to compute md4 checksums
+ * using a public domain md4 implementation with the following comments:
+ *
+ * Modified by Wei Dai from Andrew M. Kuchling's md4.c
+ * The original code and all modifications are in the public domain.
+ *
+ * This is the original introductory comment:
+ *
+ * md4.c : MD4 hash algorithm.
+ *
+ * Part of the Python Cryptography Toolkit, version 1.1
+ *
+ * Distribute and use freely; there are no restrictions on further
+ * dissemination and usage except those imposed by the laws of your
+ * country of residence.
+ *
+ */
+
+/* MD4 test suite:
+ * MD4 ("") = 31d6cfe0d16ae931b73c59d7e0c089c0
+ * MD4 ("a") = bde52cb31de33e46245e05fbdbd6fb24
+ * MD4 ("abc") = a448017aaf21d8525fc10ae87aa6729d
+ * MD4 ("message digest") = d9130a8164549fe818874806e1c7014b
+ * MD4 ("abcdefghijklmnopqrstuvwxyz") = d79e1c308aa5bbcdeea8ed63df412da9
+ * MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
+ * 043f8582f241db351ce627e153e7f0e4
+ * MD4 ("123456789012345678901234567890123456789012345678901234567890123456
+ * 78901234567890") = e33b4ddc9c38f2199c3e7b164fcc0536
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "g10lib.h"
+#include "cipher.h"
+
+#include "bithelp.h"
+
+
+typedef struct {
+ u32 A,B,C,D; /* chaining variables */
+ u32 nblocks;
+ byte buf[64];
+ int count;
+} MD4_CONTEXT;
+
+
+static void
+md4_init( void *context )
+{
+ MD4_CONTEXT *ctx = context;
+
+ ctx->A = 0x67452301;
+ ctx->B = 0xefcdab89;
+ ctx->C = 0x98badcfe;
+ ctx->D = 0x10325476;
+
+ ctx->nblocks = 0;
+ ctx->count = 0;
+}
+
+#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
+#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+
+
+/****************
+ * transform 64 bytes
+ */
+static void
+transform ( MD4_CONTEXT *ctx, const unsigned char *data )
+{
+ u32 in[16];
+ register u32 A = ctx->A;
+ register u32 B = ctx->B;
+ register u32 C = ctx->C;
+ register u32 D = ctx->D;
+
+#ifdef WORDS_BIGENDIAN
+ {
+ int i;
+ byte *p2;
+ const byte *p1;
+ for(i=0, p1=data, p2=(byte*)in; i < 16; i++, p2 += 4 )
+ {
+ p2[3] = *p1++;
+ p2[2] = *p1++;
+ p2[1] = *p1++;
+ p2[0] = *p1++;
+ }
+ }
+#else
+ memcpy (in, data, 64);
+#endif
+
+ /* Round 1. */
+#define function(a,b,c,d,k,s) a=rol(a+F(b,c,d)+in[k],s);
+ function(A,B,C,D, 0, 3);
+ function(D,A,B,C, 1, 7);
+ function(C,D,A,B, 2,11);
+ function(B,C,D,A, 3,19);
+ function(A,B,C,D, 4, 3);
+ function(D,A,B,C, 5, 7);
+ function(C,D,A,B, 6,11);
+ function(B,C,D,A, 7,19);
+ function(A,B,C,D, 8, 3);
+ function(D,A,B,C, 9, 7);
+ function(C,D,A,B,10,11);
+ function(B,C,D,A,11,19);
+ function(A,B,C,D,12, 3);
+ function(D,A,B,C,13, 7);
+ function(C,D,A,B,14,11);
+ function(B,C,D,A,15,19);
+
+#undef function
+
+ /* Round 2. */
+#define function(a,b,c,d,k,s) a=rol(a+G(b,c,d)+in[k]+0x5a827999,s);
+
+ function(A,B,C,D, 0, 3);
+ function(D,A,B,C, 4, 5);
+ function(C,D,A,B, 8, 9);
+ function(B,C,D,A,12,13);
+ function(A,B,C,D, 1, 3);
+ function(D,A,B,C, 5, 5);
+ function(C,D,A,B, 9, 9);
+ function(B,C,D,A,13,13);
+ function(A,B,C,D, 2, 3);
+ function(D,A,B,C, 6, 5);
+ function(C,D,A,B,10, 9);
+ function(B,C,D,A,14,13);
+ function(A,B,C,D, 3, 3);
+ function(D,A,B,C, 7, 5);
+ function(C,D,A,B,11, 9);
+ function(B,C,D,A,15,13);
+
+#undef function
+
+ /* Round 3. */
+#define function(a,b,c,d,k,s) a=rol(a+H(b,c,d)+in[k]+0x6ed9eba1,s);
+
+ function(A,B,C,D, 0, 3);
+ function(D,A,B,C, 8, 9);
+ function(C,D,A,B, 4,11);
+ function(B,C,D,A,12,15);
+ function(A,B,C,D, 2, 3);
+ function(D,A,B,C,10, 9);
+ function(C,D,A,B, 6,11);
+ function(B,C,D,A,14,15);
+ function(A,B,C,D, 1, 3);
+ function(D,A,B,C, 9, 9);
+ function(C,D,A,B, 5,11);
+ function(B,C,D,A,13,15);
+ function(A,B,C,D, 3, 3);
+ function(D,A,B,C,11, 9);
+ function(C,D,A,B, 7,11);
+ function(B,C,D,A,15,15);
+
+
+ /* Put checksum in context given as argument. */
+ ctx->A += A;
+ ctx->B += B;
+ ctx->C += C;
+ ctx->D += D;
+}
+
+
+
+/* The routine updates the message-digest context to
+ * account for the presence of each of the characters inBuf[0..inLen-1]
+ * in the message whose digest is being computed.
+ */
+static void
+md4_write ( void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ MD4_CONTEXT *hd = context;
+
+ if( hd->count == 64 ) /* flush the buffer */
+ {
+ transform( hd, hd->buf );
+ _gcry_burn_stack (80+6*sizeof(void*));
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if( !inbuf )
+ return;
+
+ if( hd->count )
+ {
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+ md4_write( hd, NULL, 0 );
+ if( !inlen )
+ return;
+ }
+ _gcry_burn_stack (80+6*sizeof(void*));
+
+ while( inlen >= 64 )
+ {
+ transform( hd, inbuf );
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 64;
+ inbuf += 64;
+ }
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+
+/* The routine final terminates the message-digest computation and
+ * ends with the desired message digest in mdContext->digest[0...15].
+ * The handle is prepared for a new MD4 cycle.
+ * Returns 16 bytes representing the digest.
+ */
+
+static void
+md4_final( void *context )
+{
+ MD4_CONTEXT *hd = context;
+ u32 t, msb, lsb;
+ byte *p;
+
+ md4_write(hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if( (lsb += hd->count) < t )
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if( hd->count < 56 ) /* enough room */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while( hd->count < 56 )
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else /* need one extra block */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while( hd->count < 64 )
+ hd->buf[hd->count++] = 0;
+ md4_write(hd, NULL, 0); /* flush */;
+ memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = lsb ;
+ hd->buf[57] = lsb >> 8;
+ hd->buf[58] = lsb >> 16;
+ hd->buf[59] = lsb >> 24;
+ hd->buf[60] = msb ;
+ hd->buf[61] = msb >> 8;
+ hd->buf[62] = msb >> 16;
+ hd->buf[63] = msb >> 24;
+ transform( hd, hd->buf );
+ _gcry_burn_stack (80+6*sizeof(void*));
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *p++ = hd->a ; *p++ = hd->a >> 8; \
+ *p++ = hd->a >> 16; *p++ = hd->a >> 24; } while(0)
+#else /* little endian */
+#define X(a) do { *(u32*)p = (*hd).a ; p += 4; } while(0)
+#endif
+ X(A);
+ X(B);
+ X(C);
+ X(D);
+#undef X
+
+}
+
+static byte *
+md4_read (void *context)
+{
+ MD4_CONTEXT *hd = context;
+ return hd->buf;
+}
+
+static byte asn[18] = /* Object ID is 1.2.840.113549.2.4 */
+ { 0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86,0x48,
+ 0x86, 0xf7, 0x0d, 0x02, 0x04, 0x05, 0x00, 0x04, 0x10 };
+
+static gcry_md_oid_spec_t oid_spec_md4[] =
+ {
+ /* iso.member-body.us.rsadsi.digestAlgorithm.md4 */
+ { "1.2.840.113549.2.4" },
+ { NULL },
+ };
+
+gcry_md_spec_t _gcry_digest_spec_md4 =
+ {
+ "MD4", asn, DIM (asn), oid_spec_md4,16,
+ md4_init, md4_write, md4_final, md4_read,
+ sizeof (MD4_CONTEXT)
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/md5.c b/grub-core/lib/libgcrypt/cipher/md5.c
new file mode 100644
index 0000000..a98678a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/md5.c
@@ -0,0 +1,355 @@
+/* md5.c - MD5 Message-Digest Algorithm
+ * Copyright (C) 1995,1996,1998,1999,2001,2002,
+ * 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * According to the definition of MD5 in RFC 1321 from April 1992.
+ * NOTE: This is *not* the same file as the one from glibc.
+ * Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+ * heavily modified for GnuPG by Werner Koch <wk@gnupg.org>
+ */
+
+/* Test values:
+ * "" D4 1D 8C D9 8F 00 B2 04 E9 80 09 98 EC F8 42 7E
+ * "a" 0C C1 75 B9 C0 F1 B6 A8 31 C3 99 E2 69 77 26 61
+ * "abc 90 01 50 98 3C D2 4F B0 D6 96 3F 7D 28 E1 7F 72
+ * "message digest" F9 6B 69 7D 7C B7 93 8D 52 5A 2F 31 AA F1 61 D0
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "g10lib.h"
+#include "cipher.h"
+
+#include "bithelp.h"
+
+
+typedef struct {
+ u32 A,B,C,D; /* chaining variables */
+ u32 nblocks;
+ byte buf[64];
+ int count;
+} MD5_CONTEXT;
+
+
+static void
+md5_init( void *context )
+{
+ MD5_CONTEXT *ctx = context;
+
+ ctx->A = 0x67452301;
+ ctx->B = 0xefcdab89;
+ ctx->C = 0x98badcfe;
+ ctx->D = 0x10325476;
+
+ ctx->nblocks = 0;
+ ctx->count = 0;
+}
+
+
+/* These are the four functions used in the four steps of the MD5 algorithm
+ and defined in the RFC 1321. The first function is a little bit optimized
+ (as found in Colin Plumbs public domain implementation). */
+/* #define FF(b, c, d) ((b & c) | (~b & d)) */
+#define FF(b, c, d) (d ^ (b & (c ^ d)))
+#define FG(b, c, d) FF (d, b, c)
+#define FH(b, c, d) (b ^ c ^ d)
+#define FI(b, c, d) (c ^ (b | ~d))
+
+
+/****************
+ * transform n*64 bytes
+ */
+static void
+transform ( MD5_CONTEXT *ctx, const unsigned char *data )
+{
+ u32 correct_words[16];
+ register u32 A = ctx->A;
+ register u32 B = ctx->B;
+ register u32 C = ctx->C;
+ register u32 D = ctx->D;
+ u32 *cwp = correct_words;
+
+#ifdef WORDS_BIGENDIAN
+ {
+ int i;
+ byte *p2;
+ const byte *p1;
+ for(i=0, p1=data, p2=(byte*)correct_words; i < 16; i++, p2 += 4 )
+ {
+ p2[3] = *p1++;
+ p2[2] = *p1++;
+ p2[1] = *p1++;
+ p2[0] = *p1++;
+ }
+ }
+#else
+ memcpy( correct_words, data, 64 );
+#endif
+
+
+#define OP(a, b, c, d, s, T) \
+ do \
+ { \
+ a += FF (b, c, d) + (*cwp++) + T; \
+ a = rol(a, s); \
+ a += b; \
+ } \
+ while (0)
+
+ /* Before we start, one word about the strange constants.
+ They are defined in RFC 1321 as
+
+ T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
+ */
+
+ /* Round 1. */
+ OP (A, B, C, D, 7, 0xd76aa478);
+ OP (D, A, B, C, 12, 0xe8c7b756);
+ OP (C, D, A, B, 17, 0x242070db);
+ OP (B, C, D, A, 22, 0xc1bdceee);
+ OP (A, B, C, D, 7, 0xf57c0faf);
+ OP (D, A, B, C, 12, 0x4787c62a);
+ OP (C, D, A, B, 17, 0xa8304613);
+ OP (B, C, D, A, 22, 0xfd469501);
+ OP (A, B, C, D, 7, 0x698098d8);
+ OP (D, A, B, C, 12, 0x8b44f7af);
+ OP (C, D, A, B, 17, 0xffff5bb1);
+ OP (B, C, D, A, 22, 0x895cd7be);
+ OP (A, B, C, D, 7, 0x6b901122);
+ OP (D, A, B, C, 12, 0xfd987193);
+ OP (C, D, A, B, 17, 0xa679438e);
+ OP (B, C, D, A, 22, 0x49b40821);
+
+#undef OP
+#define OP(f, a, b, c, d, k, s, T) \
+ do \
+ { \
+ a += f (b, c, d) + correct_words[k] + T; \
+ a = rol(a, s); \
+ a += b; \
+ } \
+ while (0)
+
+ /* Round 2. */
+ OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
+ OP (FG, D, A, B, C, 6, 9, 0xc040b340);
+ OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
+ OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
+ OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
+ OP (FG, D, A, B, C, 10, 9, 0x02441453);
+ OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
+ OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
+ OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
+ OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
+ OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
+ OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
+ OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
+ OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
+ OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
+ OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
+
+ /* Round 3. */
+ OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
+ OP (FH, D, A, B, C, 8, 11, 0x8771f681);
+ OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
+ OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
+ OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
+ OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
+ OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
+ OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
+ OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
+ OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
+ OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
+ OP (FH, B, C, D, A, 6, 23, 0x04881d05);
+ OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
+ OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
+ OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
+ OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
+
+ /* Round 4. */
+ OP (FI, A, B, C, D, 0, 6, 0xf4292244);
+ OP (FI, D, A, B, C, 7, 10, 0x432aff97);
+ OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
+ OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
+ OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
+ OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
+ OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
+ OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
+ OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
+ OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
+ OP (FI, C, D, A, B, 6, 15, 0xa3014314);
+ OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
+ OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
+ OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
+ OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
+ OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
+
+ /* Put checksum in context given as argument. */
+ ctx->A += A;
+ ctx->B += B;
+ ctx->C += C;
+ ctx->D += D;
+}
+
+
+
+/* The routine updates the message-digest context to
+ * account for the presence of each of the characters inBuf[0..inLen-1]
+ * in the message whose digest is being computed.
+ */
+static void
+md5_write( void *context, const void *inbuf_arg , size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ MD5_CONTEXT *hd = context;
+
+ if( hd->count == 64 ) /* flush the buffer */
+ {
+ transform( hd, hd->buf );
+ _gcry_burn_stack (80+6*sizeof(void*));
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if( !inbuf )
+ return;
+
+ if( hd->count )
+ {
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+ md5_write( hd, NULL, 0 );
+ if( !inlen )
+ return;
+ }
+ _gcry_burn_stack (80+6*sizeof(void*));
+
+ while( inlen >= 64 )
+ {
+ transform( hd, inbuf );
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 64;
+ inbuf += 64;
+ }
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+
+}
+
+
+
+/* The routine final terminates the message-digest computation and
+ * ends with the desired message digest in mdContext->digest[0...15].
+ * The handle is prepared for a new MD5 cycle.
+ * Returns 16 bytes representing the digest.
+ */
+
+static void
+md5_final( void *context)
+{
+ MD5_CONTEXT *hd = context;
+ u32 t, msb, lsb;
+ byte *p;
+
+ md5_write(hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if( (lsb += hd->count) < t )
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if( hd->count < 56 ) /* enough room */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while( hd->count < 56 )
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else /* need one extra block */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while( hd->count < 64 )
+ hd->buf[hd->count++] = 0;
+ md5_write(hd, NULL, 0); /* flush */;
+ memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = lsb ;
+ hd->buf[57] = lsb >> 8;
+ hd->buf[58] = lsb >> 16;
+ hd->buf[59] = lsb >> 24;
+ hd->buf[60] = msb ;
+ hd->buf[61] = msb >> 8;
+ hd->buf[62] = msb >> 16;
+ hd->buf[63] = msb >> 24;
+ transform( hd, hd->buf );
+ _gcry_burn_stack (80+6*sizeof(void*));
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *p++ = hd->a ; *p++ = hd->a >> 8; \
+ *p++ = hd->a >> 16; *p++ = hd->a >> 24; } while(0)
+#else /* little endian */
+#define X(a) do { *(u32*)p = (*hd).a ; p += 4; } while(0)
+#endif
+ X(A);
+ X(B);
+ X(C);
+ X(D);
+#undef X
+
+}
+
+static byte *
+md5_read( void *context )
+{
+ MD5_CONTEXT *hd = (MD5_CONTEXT *) context;
+ return hd->buf;
+}
+
+static byte asn[18] = /* Object ID is 1.2.840.113549.2.5 */
+ { 0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86,0x48,
+ 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 };
+
+static gcry_md_oid_spec_t oid_spec_md5[] =
+ {
+ /* iso.member-body.us.rsadsi.pkcs.pkcs-1.4 (md5WithRSAEncryption) */
+ { "1.2.840.113549.1.1.4" },
+ /* RSADSI digestAlgorithm MD5 */
+ { "1.2.840.113549.2.5" },
+ { NULL },
+ };
+
+gcry_md_spec_t _gcry_digest_spec_md5 =
+ {
+ "MD5", asn, DIM (asn), oid_spec_md5, 16,
+ md5_init, md5_write, md5_final, md5_read,
+ sizeof (MD5_CONTEXT)
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/primegen.c b/grub-core/lib/libgcrypt/cipher/primegen.c
new file mode 100644
index 0000000..b12e79b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/primegen.c
@@ -0,0 +1,1861 @@
+/* primegen.c - prime number generator
+ * Copyright (C) 1998, 2000, 2001, 2002, 2003
+ * 2004, 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "g10lib.h"
+#include "mpi.h"
+#include "cipher.h"
+#include "ath.h"
+
+static gcry_mpi_t gen_prime (unsigned int nbits, int secret, int randomlevel,
+ int (*extra_check)(void *, gcry_mpi_t),
+ void *extra_check_arg);
+static int check_prime( gcry_mpi_t prime, gcry_mpi_t val_2, int rm_rounds,
+ gcry_prime_check_func_t cb_func, void *cb_arg );
+static int is_prime (gcry_mpi_t n, int steps, unsigned int *count);
+static void m_out_of_n( char *array, int m, int n );
+
+static void (*progress_cb) (void *,const char*,int,int, int );
+static void *progress_cb_data;
+
+/* Note: 2 is not included because it can be tested more easily by
+ looking at bit 0. The last entry in this list is marked by a zero */
+static ushort small_prime_numbers[] = {
+ 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,
+ 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,
+ 103, 107, 109, 113, 127, 131, 137, 139, 149, 151,
+ 157, 163, 167, 173, 179, 181, 191, 193, 197, 199,
+ 211, 223, 227, 229, 233, 239, 241, 251, 257, 263,
+ 269, 271, 277, 281, 283, 293, 307, 311, 313, 317,
+ 331, 337, 347, 349, 353, 359, 367, 373, 379, 383,
+ 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
+ 449, 457, 461, 463, 467, 479, 487, 491, 499, 503,
+ 509, 521, 523, 541, 547, 557, 563, 569, 571, 577,
+ 587, 593, 599, 601, 607, 613, 617, 619, 631, 641,
+ 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
+ 709, 719, 727, 733, 739, 743, 751, 757, 761, 769,
+ 773, 787, 797, 809, 811, 821, 823, 827, 829, 839,
+ 853, 857, 859, 863, 877, 881, 883, 887, 907, 911,
+ 919, 929, 937, 941, 947, 953, 967, 971, 977, 983,
+ 991, 997, 1009, 1013, 1019, 1021, 1031, 1033,
+ 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091,
+ 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151,
+ 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213,
+ 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277,
+ 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307,
+ 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399,
+ 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451,
+ 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493,
+ 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559,
+ 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609,
+ 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667,
+ 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733,
+ 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789,
+ 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871,
+ 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931,
+ 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997,
+ 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053,
+ 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111,
+ 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161,
+ 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243,
+ 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297,
+ 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357,
+ 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411,
+ 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473,
+ 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551,
+ 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633,
+ 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687,
+ 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729,
+ 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791,
+ 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851,
+ 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917,
+ 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999,
+ 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061,
+ 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137,
+ 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209,
+ 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271,
+ 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331,
+ 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391,
+ 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467,
+ 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533,
+ 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583,
+ 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643,
+ 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709,
+ 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779,
+ 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851,
+ 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917,
+ 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989,
+ 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049,
+ 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111,
+ 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177,
+ 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243,
+ 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297,
+ 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391,
+ 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457,
+ 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519,
+ 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597,
+ 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657,
+ 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729,
+ 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799,
+ 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889,
+ 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951,
+ 4957, 4967, 4969, 4973, 4987, 4993, 4999,
+ 0
+};
+static int no_of_small_prime_numbers = DIM (small_prime_numbers) - 1;
+
+
+
+/* An object and a list to build up a global pool of primes. See
+ save_pool_prime and get_pool_prime. */
+struct primepool_s
+{
+ struct primepool_s *next;
+ gcry_mpi_t prime; /* If this is NULL the entry is not used. */
+ unsigned int nbits;
+ gcry_random_level_t randomlevel;
+};
+struct primepool_s *primepool;
+/* Mutex used to protect access to the primepool. */
+static ath_mutex_t primepool_lock = ATH_MUTEX_INITIALIZER;
+
+
+
+/* Save PRIME which has been generated at RANDOMLEVEL for later
+ use. Needs to be called while primepool_lock is being hold. Note
+ that PRIME should be considered released after calling this
+ function. */
+static void
+save_pool_prime (gcry_mpi_t prime, gcry_random_level_t randomlevel)
+{
+ struct primepool_s *item, *item2;
+ size_t n;
+
+ for (n=0, item = primepool; item; item = item->next, n++)
+ if (!item->prime)
+ break;
+ if (!item && n > 100)
+ {
+ /* Remove some of the entries. Our strategy is removing
+ the last third from the list. */
+ int i;
+
+ for (i=0, item2 = primepool; item2; item2 = item2->next)
+ {
+ if (i >= n/3*2)
+ {
+ gcry_mpi_release (item2->prime);
+ item2->prime = NULL;
+ if (!item)
+ item = item2;
+ }
+ }
+ }
+ if (!item)
+ {
+ item = gcry_calloc (1, sizeof *item);
+ if (!item)
+ {
+ /* Out of memory. Silently giving up. */
+ gcry_mpi_release (prime);
+ return;
+ }
+ item->next = primepool;
+ primepool = item;
+ }
+ item->prime = prime;
+ item->nbits = mpi_get_nbits (prime);
+ item->randomlevel = randomlevel;
+}
+
+
+/* Return a prime for the prime pool or NULL if none has been found.
+ The prime needs to match NBITS and randomlevel. This function needs
+ to be called why the primepool_look is being hold. */
+static gcry_mpi_t
+get_pool_prime (unsigned int nbits, gcry_random_level_t randomlevel)
+{
+ struct primepool_s *item;
+
+ for (item = primepool; item; item = item->next)
+ if (item->prime
+ && item->nbits == nbits && item->randomlevel == randomlevel)
+ {
+ gcry_mpi_t prime = item->prime;
+ item->prime = NULL;
+ gcry_assert (nbits == mpi_get_nbits (prime));
+ return prime;
+ }
+ return NULL;
+}
+
+
+
+
+
+
+void
+_gcry_register_primegen_progress ( void (*cb)(void *,const char*,int,int,int),
+ void *cb_data )
+{
+ progress_cb = cb;
+ progress_cb_data = cb_data;
+}
+
+
+static void
+progress( int c )
+{
+ if ( progress_cb )
+ progress_cb ( progress_cb_data, "primegen", c, 0, 0 );
+}
+
+
+/****************
+ * Generate a prime number (stored in secure memory)
+ */
+gcry_mpi_t
+_gcry_generate_secret_prime (unsigned int nbits,
+ gcry_random_level_t random_level,
+ int (*extra_check)(void*, gcry_mpi_t),
+ void *extra_check_arg)
+{
+ gcry_mpi_t prime;
+
+ prime = gen_prime (nbits, 1, random_level, extra_check, extra_check_arg);
+ progress('\n');
+ return prime;
+}
+
+
+/* Generate a prime number which may be public, i.e. not allocated in
+ secure memory. */
+gcry_mpi_t
+_gcry_generate_public_prime (unsigned int nbits,
+ gcry_random_level_t random_level,
+ int (*extra_check)(void*, gcry_mpi_t),
+ void *extra_check_arg)
+{
+ gcry_mpi_t prime;
+
+ prime = gen_prime (nbits, 0, random_level, extra_check, extra_check_arg);
+ progress('\n');
+ return prime;
+}
+
+
+/* Core prime generation function. The algorithm used to generate
+ practically save primes is due to Lim and Lee as described in the
+ CRYPTO '97 proceedings (ISBN3540633847) page 260.
+
+ NEED_Q_FACTOR: If true make sure that at least one factor is of
+ size qbits. This is for example required for DSA.
+ PRIME_GENERATED: Adresss of a variable where the resulting prime
+ number will be stored.
+ PBITS: Requested size of the prime number. At least 48.
+ QBITS: One factor of the prime needs to be of this size. Maybe 0
+ if this is not required. See also MODE.
+ G: If not NULL an MPI which will receive a generator for the prime
+ for use with Elgamal.
+ RET_FACTORS: if not NULL, an array with all factors are stored at
+ that address.
+ ALL_FACTORS: If set to true all factors of prime-1 are returned.
+ RANDOMLEVEL: How strong should the random numers be.
+ FLAGS: Prime generation bit flags. Currently supported:
+ GCRY_PRIME_FLAG_SECRET - The prime needs to be kept secret.
+ CB_FUNC, CB_ARG: Callback to be used for extra checks.
+
+ */
+static gcry_err_code_t
+prime_generate_internal (int need_q_factor,
+ gcry_mpi_t *prime_generated, unsigned int pbits,
+ unsigned int qbits, gcry_mpi_t g,
+ gcry_mpi_t **ret_factors,
+ gcry_random_level_t randomlevel, unsigned int flags,
+ int all_factors,
+ gcry_prime_check_func_t cb_func, void *cb_arg)
+{
+ gcry_err_code_t err = 0;
+ gcry_mpi_t *factors_new = NULL; /* Factors to return to the
+ caller. */
+ gcry_mpi_t *factors = NULL; /* Current factors. */
+ gcry_random_level_t poolrandomlevel; /* Random level used for pool primes. */
+ gcry_mpi_t *pool = NULL; /* Pool of primes. */
+ int *pool_in_use = NULL; /* Array with currently used POOL elements. */
+ unsigned char *perms = NULL; /* Permutations of POOL. */
+ gcry_mpi_t q_factor = NULL; /* Used if QBITS is non-zero. */
+ unsigned int fbits = 0; /* Length of prime factors. */
+ unsigned int n = 0; /* Number of factors. */
+ unsigned int m = 0; /* Number of primes in pool. */
+ gcry_mpi_t q = NULL; /* First prime factor. */
+ gcry_mpi_t prime = NULL; /* Prime candidate. */
+ unsigned int nprime = 0; /* Bits of PRIME. */
+ unsigned int req_qbits; /* The original QBITS value. */
+ gcry_mpi_t val_2; /* For check_prime(). */
+ int is_locked = 0; /* Flag to help unlocking the primepool. */
+ unsigned int is_secret = (flags & GCRY_PRIME_FLAG_SECRET);
+ unsigned int count1 = 0, count2 = 0;
+ unsigned int i = 0, j = 0;
+
+ if (pbits < 48)
+ return GPG_ERR_INV_ARG;
+
+ /* We won't use a too strong random elvel for the pooled subprimes. */
+ poolrandomlevel = (randomlevel > GCRY_STRONG_RANDOM?
+ GCRY_STRONG_RANDOM : randomlevel);
+
+
+ /* If QBITS is not given, assume a reasonable value. */
+ if (!qbits)
+ qbits = pbits / 3;
+
+ req_qbits = qbits;
+
+ /* Find number of needed prime factors N. */
+ for (n = 1; (pbits - qbits - 1) / n >= qbits; n++)
+ ;
+ n--;
+
+ val_2 = mpi_alloc_set_ui (2);
+
+ if ((! n) || ((need_q_factor) && (n < 2)))
+ {
+ err = GPG_ERR_INV_ARG;
+ goto leave;
+ }
+
+ if (need_q_factor)
+ {
+ n--; /* Need one factor less because we want a specific Q-FACTOR. */
+ fbits = (pbits - 2 * req_qbits -1) / n;
+ qbits = pbits - req_qbits - n * fbits;
+ }
+ else
+ {
+ fbits = (pbits - req_qbits -1) / n;
+ qbits = pbits - n * fbits;
+ }
+
+ if (DBG_CIPHER)
+ log_debug ("gen prime: pbits=%u qbits=%u fbits=%u/%u n=%d\n",
+ pbits, req_qbits, qbits, fbits, n);
+
+ /* Allocate an integer to old the new prime. */
+ prime = gcry_mpi_new (pbits);
+
+ /* Generate first prime factor. */
+ q = gen_prime (qbits, is_secret, randomlevel, NULL, NULL);
+
+ /* Generate a specific Q-Factor if requested. */
+ if (need_q_factor)
+ q_factor = gen_prime (req_qbits, is_secret, randomlevel, NULL, NULL);
+
+ /* Allocate an array to hold all factors + 2 for later usage. */
+ factors = gcry_calloc (n + 2, sizeof (*factors));
+ if (!factors)
+ {
+ err = gpg_err_code_from_errno (errno);
+ goto leave;
+ }
+
+ /* Allocate an array to track pool usage. */
+ pool_in_use = gcry_calloc (n, sizeof *pool_in_use);
+ if (!pool_in_use)
+ {
+ err = gpg_err_code_from_errno (errno);
+ goto leave;
+ }
+ for (i=0; i < n; i++)
+ pool_in_use[i] = -1;
+
+ /* Make a pool of 3n+5 primes (this is an arbitrary value). We
+ require at least 30 primes for are useful selection process.
+
+ Fixme: We need to research the best formula for sizing the pool.
+ */
+ m = n * 3 + 5;
+ if (need_q_factor) /* Need some more in this case. */
+ m += 5;
+ if (m < 30)
+ m = 30;
+ pool = gcry_calloc (m , sizeof (*pool));
+ if (! pool)
+ {
+ err = gpg_err_code_from_errno (errno);
+ goto leave;
+ }
+
+ /* Permutate over the pool of primes until we find a prime of the
+ requested length. */
+ do
+ {
+ next_try:
+ for (i=0; i < n; i++)
+ pool_in_use[i] = -1;
+
+ if (!perms)
+ {
+ /* Allocate new primes. This is done right at the beginning
+ of the loop and if we have later run out of primes. */
+ for (i = 0; i < m; i++)
+ {
+ mpi_free (pool[i]);
+ pool[i] = NULL;
+ }
+
+ /* Init m_out_of_n(). */
+ perms = gcry_calloc (1, m);
+ if (!perms)
+ {
+ err = gpg_err_code_from_errno (errno);
+ goto leave;
+ }
+
+ if (ath_mutex_lock (&primepool_lock))
+ {
+ err = GPG_ERR_INTERNAL;
+ goto leave;
+ }
+ is_locked = 1;
+ for (i = 0; i < n; i++)
+ {
+ perms[i] = 1;
+ /* At a maximum we use strong random for the factors.
+ This saves us a lot of entropy. Given that Q and
+ possible Q-factor are also used in the final prime
+ this should be acceptable. We also don't allocate in
+ secure memory to save on that scare resource too. If
+ Q has been allocated in secure memory, the final
+ prime will be saved there anyway. This is because
+ our MPI routines take care of that. GnuPG has worked
+ this way ever since. */
+ pool[i] = NULL;
+ if (is_locked)
+ {
+ pool[i] = get_pool_prime (fbits, poolrandomlevel);
+ if (!pool[i])
+ {
+ if (ath_mutex_unlock (&primepool_lock))
+ {
+ err = GPG_ERR_INTERNAL;
+ goto leave;
+ }
+ is_locked = 0;
+ }
+ }
+ if (!pool[i])
+ pool[i] = gen_prime (fbits, 0, poolrandomlevel, NULL, NULL);
+ pool_in_use[i] = i;
+ factors[i] = pool[i];
+ }
+ if (is_locked && ath_mutex_unlock (&primepool_lock))
+ {
+ err = GPG_ERR_INTERNAL;
+ goto leave;
+ }
+ is_locked = 0;
+ }
+ else
+ {
+ /* Get next permutation. */
+ m_out_of_n ( (char*)perms, n, m);
+ if (ath_mutex_lock (&primepool_lock))
+ {
+ err = GPG_ERR_INTERNAL;
+ goto leave;
+ }
+ is_locked = 1;
+ for (i = j = 0; (i < m) && (j < n); i++)
+ if (perms[i])
+ {
+ /* If the subprime has not yet beed generated do it now. */
+ if (!pool[i] && is_locked)
+ {
+ pool[i] = get_pool_prime (fbits, poolrandomlevel);
+ if (!pool[i])
+ {
+ if (ath_mutex_unlock (&primepool_lock))
+ {
+ err = GPG_ERR_INTERNAL;
+ goto leave;
+ }
+ is_locked = 0;
+ }
+ }
+ if (!pool[i])
+ pool[i] = gen_prime (fbits, 0, poolrandomlevel, NULL, NULL);
+ pool_in_use[j] = i;
+ factors[j++] = pool[i];
+ }
+ if (is_locked && ath_mutex_unlock (&primepool_lock))
+ {
+ err = GPG_ERR_INTERNAL;
+ goto leave;
+ }
+ is_locked = 0;
+ if (i == n)
+ {
+ /* Ran out of permutations: Allocate new primes. */
+ gcry_free (perms);
+ perms = NULL;
+ progress ('!');
+ goto next_try;
+ }
+ }
+
+ /* Generate next prime candidate:
+ p = 2 * q [ * q_factor] * factor_0 * factor_1 * ... * factor_n + 1.
+ */
+ mpi_set (prime, q);
+ mpi_mul_ui (prime, prime, 2);
+ if (need_q_factor)
+ mpi_mul (prime, prime, q_factor);
+ for(i = 0; i < n; i++)
+ mpi_mul (prime, prime, factors[i]);
+ mpi_add_ui (prime, prime, 1);
+ nprime = mpi_get_nbits (prime);
+
+ if (nprime < pbits)
+ {
+ if (++count1 > 20)
+ {
+ count1 = 0;
+ qbits++;
+ progress('>');
+ mpi_free (q);
+ q = gen_prime (qbits, is_secret, randomlevel, NULL, NULL);
+ goto next_try;
+ }
+ }
+ else
+ count1 = 0;
+
+ if (nprime > pbits)
+ {
+ if (++count2 > 20)
+ {
+ count2 = 0;
+ qbits--;
+ progress('<');
+ mpi_free (q);
+ q = gen_prime (qbits, is_secret, randomlevel, NULL, NULL);
+ goto next_try;
+ }
+ }
+ else
+ count2 = 0;
+ }
+ while (! ((nprime == pbits) && check_prime (prime, val_2, 5,
+ cb_func, cb_arg)));
+
+ if (DBG_CIPHER)
+ {
+ progress ('\n');
+ log_mpidump ("prime : ", prime);
+ log_mpidump ("factor q: ", q);
+ if (need_q_factor)
+ log_mpidump ("factor q0: ", q_factor);
+ for (i = 0; i < n; i++)
+ log_mpidump ("factor pi: ", factors[i]);
+ log_debug ("bit sizes: prime=%u, q=%u",
+ mpi_get_nbits (prime), mpi_get_nbits (q));
+ if (need_q_factor)
+ log_debug (", q0=%u", mpi_get_nbits (q_factor));
+ for (i = 0; i < n; i++)
+ log_debug (", p%d=%u", i, mpi_get_nbits (factors[i]));
+ progress('\n');
+ }
+
+ if (ret_factors)
+ {
+ /* Caller wants the factors. */
+ factors_new = gcry_calloc (n + 4, sizeof (*factors_new));
+ if (! factors_new)
+ {
+ err = gpg_err_code_from_errno (errno);
+ goto leave;
+ }
+
+ if (all_factors)
+ {
+ i = 0;
+ factors_new[i++] = gcry_mpi_set_ui (NULL, 2);
+ factors_new[i++] = mpi_copy (q);
+ if (need_q_factor)
+ factors_new[i++] = mpi_copy (q_factor);
+ for(j=0; j < n; j++)
+ factors_new[i++] = mpi_copy (factors[j]);
+ }
+ else
+ {
+ i = 0;
+ if (need_q_factor)
+ {
+ factors_new[i++] = mpi_copy (q_factor);
+ for (; i <= n; i++)
+ factors_new[i] = mpi_copy (factors[i]);
+ }
+ else
+ for (; i < n; i++ )
+ factors_new[i] = mpi_copy (factors[i]);
+ }
+ }
+
+ if (g)
+ {
+ /* Create a generator (start with 3). */
+ gcry_mpi_t tmp = mpi_alloc (mpi_get_nlimbs (prime));
+ gcry_mpi_t b = mpi_alloc (mpi_get_nlimbs (prime));
+ gcry_mpi_t pmin1 = mpi_alloc (mpi_get_nlimbs (prime));
+
+ if (need_q_factor)
+ err = GPG_ERR_NOT_IMPLEMENTED;
+ else
+ {
+ factors[n] = q;
+ factors[n + 1] = mpi_alloc_set_ui (2);
+ mpi_sub_ui (pmin1, prime, 1);
+ mpi_set_ui (g, 2);
+ do
+ {
+ mpi_add_ui (g, g, 1);
+ if (DBG_CIPHER)
+ {
+ log_debug ("checking g:");
+ gcry_mpi_dump (g);
+ log_printf ("\n");
+ }
+ else
+ progress('^');
+ for (i = 0; i < n + 2; i++)
+ {
+ mpi_fdiv_q (tmp, pmin1, factors[i]);
+ /* No mpi_pow(), but it is okay to use this with mod
+ prime. */
+ gcry_mpi_powm (b, g, tmp, prime);
+ if (! mpi_cmp_ui (b, 1))
+ break;
+ }
+ if (DBG_CIPHER)
+ progress('\n');
+ }
+ while (i < n + 2);
+
+ mpi_free (factors[n+1]);
+ mpi_free (tmp);
+ mpi_free (b);
+ mpi_free (pmin1);
+ }
+ }
+
+ if (! DBG_CIPHER)
+ progress ('\n');
+
+
+ leave:
+ if (pool)
+ {
+ is_locked = !ath_mutex_lock (&primepool_lock);
+ for(i = 0; i < m; i++)
+ {
+ if (pool[i])
+ {
+ for (j=0; j < n; j++)
+ if (pool_in_use[j] == i)
+ break;
+ if (j == n && is_locked)
+ {
+ /* This pooled subprime has not been used. */
+ save_pool_prime (pool[i], poolrandomlevel);
+ }
+ else
+ mpi_free (pool[i]);
+ }
+ }
+ if (is_locked && ath_mutex_unlock (&primepool_lock))
+ err = GPG_ERR_INTERNAL;
+ is_locked = 0;
+ gcry_free (pool);
+ }
+ gcry_free (pool_in_use);
+ if (factors)
+ gcry_free (factors); /* Factors are shallow copies. */
+ if (perms)
+ gcry_free (perms);
+
+ mpi_free (val_2);
+ mpi_free (q);
+ mpi_free (q_factor);
+
+ if (! err)
+ {
+ *prime_generated = prime;
+ if (ret_factors)
+ *ret_factors = factors_new;
+ }
+ else
+ {
+ if (factors_new)
+ {
+ for (i = 0; factors_new[i]; i++)
+ mpi_free (factors_new[i]);
+ gcry_free (factors_new);
+ }
+ mpi_free (prime);
+ }
+
+ return err;
+}
+
+
+/* Generate a prime used for discrete logarithm algorithms; i.e. this
+ prime will be public and no strong random is required. */
+gcry_mpi_t
+_gcry_generate_elg_prime (int mode, unsigned pbits, unsigned qbits,
+ gcry_mpi_t g, gcry_mpi_t **ret_factors)
+{
+ gcry_mpi_t prime = NULL;
+
+ if (prime_generate_internal ((mode == 1), &prime, pbits, qbits, g,
+ ret_factors, GCRY_WEAK_RANDOM, 0, 0,
+ NULL, NULL))
+ prime = NULL; /* (Should be NULL in the error case anyway.) */
+
+ return prime;
+}
+
+
+static gcry_mpi_t
+gen_prime (unsigned int nbits, int secret, int randomlevel,
+ int (*extra_check)(void *, gcry_mpi_t), void *extra_check_arg)
+{
+ gcry_mpi_t prime, ptest, pminus1, val_2, val_3, result;
+ int i;
+ unsigned int x, step;
+ unsigned int count1, count2;
+ int *mods;
+
+/* if ( DBG_CIPHER ) */
+/* log_debug ("generate a prime of %u bits ", nbits ); */
+
+ if (nbits < 16)
+ log_fatal ("can't generate a prime with less than %d bits\n", 16);
+
+ mods = gcry_xcalloc( no_of_small_prime_numbers, sizeof *mods);
+ /* Make nbits fit into gcry_mpi_t implementation. */
+ val_2 = mpi_alloc_set_ui( 2 );
+ val_3 = mpi_alloc_set_ui( 3);
+ prime = secret? gcry_mpi_snew ( nbits ): gcry_mpi_new ( nbits );
+ result = mpi_alloc_like( prime );
+ pminus1= mpi_alloc_like( prime );
+ ptest = mpi_alloc_like( prime );
+ count1 = count2 = 0;
+ for (;;)
+ { /* try forvever */
+ int dotcount=0;
+
+ /* generate a random number */
+ gcry_mpi_randomize( prime, nbits, randomlevel );
+
+ /* Set high order bit to 1, set low order bit to 1. If we are
+ generating a secret prime we are most probably doing that
+ for RSA, to make sure that the modulus does have the
+ requested key size we set the 2 high order bits. */
+ mpi_set_highbit (prime, nbits-1);
+ if (secret)
+ mpi_set_bit (prime, nbits-2);
+ mpi_set_bit(prime, 0);
+
+ /* Calculate all remainders. */
+ for (i=0; (x = small_prime_numbers[i]); i++ )
+ mods[i] = mpi_fdiv_r_ui(NULL, prime, x);
+
+ /* Now try some primes starting with prime. */
+ for(step=0; step < 20000; step += 2 )
+ {
+ /* Check against all the small primes we have in mods. */
+ count1++;
+ for (i=0; (x = small_prime_numbers[i]); i++ )
+ {
+ while ( mods[i] + step >= x )
+ mods[i] -= x;
+ if ( !(mods[i] + step) )
+ break;
+ }
+ if ( x )
+ continue; /* Found a multiple of an already known prime. */
+
+ mpi_add_ui( ptest, prime, step );
+
+ /* Do a fast Fermat test now. */
+ count2++;
+ mpi_sub_ui( pminus1, ptest, 1);
+ gcry_mpi_powm( result, val_2, pminus1, ptest );
+ if ( !mpi_cmp_ui( result, 1 ) )
+ {
+ /* Not composite, perform stronger tests */
+ if (is_prime(ptest, 5, &count2 ))
+ {
+ if (!mpi_test_bit( ptest, nbits-1-secret ))
+ {
+ progress('\n');
+ log_debug ("overflow in prime generation\n");
+ break; /* Stop loop, continue with a new prime. */
+ }
+
+ if (extra_check && extra_check (extra_check_arg, ptest))
+ {
+ /* The extra check told us that this prime is
+ not of the caller's taste. */
+ progress ('/');
+ }
+ else
+ {
+ /* Got it. */
+ mpi_free(val_2);
+ mpi_free(val_3);
+ mpi_free(result);
+ mpi_free(pminus1);
+ mpi_free(prime);
+ gcry_free(mods);
+ return ptest;
+ }
+ }
+ }
+ if (++dotcount == 10 )
+ {
+ progress('.');
+ dotcount = 0;
+ }
+ }
+ progress(':'); /* restart with a new random value */
+ }
+}
+
+/****************
+ * Returns: true if this may be a prime
+ * RM_ROUNDS gives the number of Rabin-Miller tests to run.
+ */
+static int
+check_prime( gcry_mpi_t prime, gcry_mpi_t val_2, int rm_rounds,
+ gcry_prime_check_func_t cb_func, void *cb_arg)
+{
+ int i;
+ unsigned int x;
+ unsigned int count=0;
+
+ /* Check against small primes. */
+ for (i=0; (x = small_prime_numbers[i]); i++ )
+ {
+ if ( mpi_divisible_ui( prime, x ) )
+ return 0;
+ }
+
+ /* A quick Fermat test. */
+ {
+ gcry_mpi_t result = mpi_alloc_like( prime );
+ gcry_mpi_t pminus1 = mpi_alloc_like( prime );
+ mpi_sub_ui( pminus1, prime, 1);
+ gcry_mpi_powm( result, val_2, pminus1, prime );
+ mpi_free( pminus1 );
+ if ( mpi_cmp_ui( result, 1 ) )
+ {
+ /* Is composite. */
+ mpi_free( result );
+ progress('.');
+ return 0;
+ }
+ mpi_free( result );
+ }
+
+ if (!cb_func || cb_func (cb_arg, GCRY_PRIME_CHECK_AT_MAYBE_PRIME, prime))
+ {
+ /* Perform stronger tests. */
+ if ( is_prime( prime, rm_rounds, &count ) )
+ {
+ if (!cb_func
+ || cb_func (cb_arg, GCRY_PRIME_CHECK_AT_GOT_PRIME, prime))
+ return 1; /* Probably a prime. */
+ }
+ }
+ progress('.');
+ return 0;
+}
+
+
+/*
+ * Return true if n is probably a prime
+ */
+static int
+is_prime (gcry_mpi_t n, int steps, unsigned int *count)
+{
+ gcry_mpi_t x = mpi_alloc( mpi_get_nlimbs( n ) );
+ gcry_mpi_t y = mpi_alloc( mpi_get_nlimbs( n ) );
+ gcry_mpi_t z = mpi_alloc( mpi_get_nlimbs( n ) );
+ gcry_mpi_t nminus1 = mpi_alloc( mpi_get_nlimbs( n ) );
+ gcry_mpi_t a2 = mpi_alloc_set_ui( 2 );
+ gcry_mpi_t q;
+ unsigned i, j, k;
+ int rc = 0;
+ unsigned nbits = mpi_get_nbits( n );
+
+ if (steps < 5) /* Make sure that we do at least 5 rounds. */
+ steps = 5;
+
+ mpi_sub_ui( nminus1, n, 1 );
+
+ /* Find q and k, so that n = 1 + 2^k * q . */
+ q = mpi_copy ( nminus1 );
+ k = mpi_trailing_zeros ( q );
+ mpi_tdiv_q_2exp (q, q, k);
+
+ for (i=0 ; i < steps; i++ )
+ {
+ ++*count;
+ if( !i )
+ {
+ mpi_set_ui( x, 2 );
+ }
+ else
+ {
+ gcry_mpi_randomize( x, nbits, GCRY_WEAK_RANDOM );
+
+ /* Make sure that the number is smaller than the prime and
+ keep the randomness of the high bit. */
+ if ( mpi_test_bit ( x, nbits-2) )
+ {
+ mpi_set_highbit ( x, nbits-2); /* Clear all higher bits. */
+ }
+ else
+ {
+ mpi_set_highbit( x, nbits-2 );
+ mpi_clear_bit( x, nbits-2 );
+ }
+ gcry_assert (mpi_cmp (x, nminus1) < 0 && mpi_cmp_ui (x, 1) > 0);
+ }
+ gcry_mpi_powm ( y, x, q, n);
+ if ( mpi_cmp_ui(y, 1) && mpi_cmp( y, nminus1 ) )
+ {
+ for ( j=1; j < k && mpi_cmp( y, nminus1 ); j++ )
+ {
+ gcry_mpi_powm(y, y, a2, n);
+ if( !mpi_cmp_ui( y, 1 ) )
+ goto leave; /* Not a prime. */
+ }
+ if (mpi_cmp( y, nminus1 ) )
+ goto leave; /* Not a prime. */
+ }
+ progress('+');
+ }
+ rc = 1; /* May be a prime. */
+
+ leave:
+ mpi_free( x );
+ mpi_free( y );
+ mpi_free( z );
+ mpi_free( nminus1 );
+ mpi_free( q );
+ mpi_free( a2 );
+
+ return rc;
+}
+
+
+/* Given ARRAY of size N with M elements set to true produce a
+ modified array with the next permutation of M elements. Note, that
+ ARRAY is used in a one-bit-per-byte approach. To detected the last
+ permutation it is useful to initialize the array with the first M
+ element set to true and use this test:
+ m_out_of_n (array, m, n);
+ for (i = j = 0; i < n && j < m; i++)
+ if (array[i])
+ j++;
+ if (j == m)
+ goto ready;
+
+ This code is based on the algorithm 452 from the "Collected
+ Algorithms From ACM, Volume II" by C. N. Liu and D. T. Tang.
+*/
+static void
+m_out_of_n ( char *array, int m, int n )
+{
+ int i=0, i1=0, j=0, jp=0, j1=0, k1=0, k2=0;
+
+ if( !m || m >= n )
+ return;
+
+ /* Need to handle this simple case separately. */
+ if( m == 1 )
+ {
+ for (i=0; i < n; i++ )
+ {
+ if ( array[i] )
+ {
+ array[i++] = 0;
+ if( i >= n )
+ i = 0;
+ array[i] = 1;
+ return;
+ }
+ }
+ BUG();
+ }
+
+
+ for (j=1; j < n; j++ )
+ {
+ if ( array[n-1] == array[n-j-1])
+ continue;
+ j1 = j;
+ break;
+ }
+
+ if ( (m & 1) )
+ {
+ /* M is odd. */
+ if( array[n-1] )
+ {
+ if( j1 & 1 )
+ {
+ k1 = n - j1;
+ k2 = k1+2;
+ if( k2 > n )
+ k2 = n;
+ goto leave;
+ }
+ goto scan;
+ }
+ k2 = n - j1 - 1;
+ if( k2 == 0 )
+ {
+ k1 = i;
+ k2 = n - j1;
+ }
+ else if( array[k2] && array[k2-1] )
+ k1 = n;
+ else
+ k1 = k2 + 1;
+ }
+ else
+ {
+ /* M is even. */
+ if( !array[n-1] )
+ {
+ k1 = n - j1;
+ k2 = k1 + 1;
+ goto leave;
+ }
+
+ if( !(j1 & 1) )
+ {
+ k1 = n - j1;
+ k2 = k1+2;
+ if( k2 > n )
+ k2 = n;
+ goto leave;
+ }
+ scan:
+ jp = n - j1 - 1;
+ for (i=1; i <= jp; i++ )
+ {
+ i1 = jp + 2 - i;
+ if( array[i1-1] )
+ {
+ if( array[i1-2] )
+ {
+ k1 = i1 - 1;
+ k2 = n - j1;
+ }
+ else
+ {
+ k1 = i1 - 1;
+ k2 = n + 1 - j1;
+ }
+ goto leave;
+ }
+ }
+ k1 = 1;
+ k2 = n + 1 - m;
+ }
+ leave:
+ /* Now complement the two selected bits. */
+ array[k1-1] = !array[k1-1];
+ array[k2-1] = !array[k2-1];
+}
+
+
+/* Generate a new prime number of PRIME_BITS bits and store it in
+ PRIME. If FACTOR_BITS is non-zero, one of the prime factors of
+ (prime - 1) / 2 must be FACTOR_BITS bits long. If FACTORS is
+ non-zero, allocate a new, NULL-terminated array holding the prime
+ factors and store it in FACTORS. FLAGS might be used to influence
+ the prime number generation process. */
+gcry_error_t
+gcry_prime_generate (gcry_mpi_t *prime, unsigned int prime_bits,
+ unsigned int factor_bits, gcry_mpi_t **factors,
+ gcry_prime_check_func_t cb_func, void *cb_arg,
+ gcry_random_level_t random_level,
+ unsigned int flags)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ gcry_mpi_t *factors_generated = NULL;
+ gcry_mpi_t prime_generated = NULL;
+ unsigned int mode = 0;
+
+ if (!prime)
+ return gpg_error (GPG_ERR_INV_ARG);
+ *prime = NULL;
+
+ if (flags & GCRY_PRIME_FLAG_SPECIAL_FACTOR)
+ mode = 1;
+
+ /* Generate. */
+ err = prime_generate_internal ((mode==1), &prime_generated, prime_bits,
+ factor_bits, NULL,
+ factors? &factors_generated : NULL,
+ random_level, flags, 1,
+ cb_func, cb_arg);
+
+ if (! err)
+ if (cb_func)
+ {
+ /* Additional check. */
+ if ( !cb_func (cb_arg, GCRY_PRIME_CHECK_AT_FINISH, prime_generated))
+ {
+ /* Failed, deallocate resources. */
+ unsigned int i;
+
+ mpi_free (prime_generated);
+ if (factors)
+ {
+ for (i = 0; factors_generated[i]; i++)
+ mpi_free (factors_generated[i]);
+ gcry_free (factors_generated);
+ }
+ err = GPG_ERR_GENERAL;
+ }
+ }
+
+ if (! err)
+ {
+ if (factors)
+ *factors = factors_generated;
+ *prime = prime_generated;
+ }
+
+ return gcry_error (err);
+}
+
+/* Check whether the number X is prime. */
+gcry_error_t
+gcry_prime_check (gcry_mpi_t x, unsigned int flags)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ gcry_mpi_t val_2 = mpi_alloc_set_ui (2); /* Used by the Fermat test. */
+
+ (void)flags;
+
+ /* We use 64 rounds because the prime we are going to test is not
+ guaranteed to be a random one. */
+ if (! check_prime (x, val_2, 64, NULL, NULL))
+ err = GPG_ERR_NO_PRIME;
+
+ mpi_free (val_2);
+
+ return gcry_error (err);
+}
+
+/* Find a generator for PRIME where the factorization of (prime-1) is
+ in the NULL terminated array FACTORS. Return the generator as a
+ newly allocated MPI in R_G. If START_G is not NULL, use this as s
+ atart for the search. Returns 0 on success.*/
+gcry_error_t
+gcry_prime_group_generator (gcry_mpi_t *r_g,
+ gcry_mpi_t prime, gcry_mpi_t *factors,
+ gcry_mpi_t start_g)
+{
+ gcry_mpi_t tmp = gcry_mpi_new (0);
+ gcry_mpi_t b = gcry_mpi_new (0);
+ gcry_mpi_t pmin1 = gcry_mpi_new (0);
+ gcry_mpi_t g = start_g? gcry_mpi_copy (start_g) : gcry_mpi_set_ui (NULL, 3);
+ int first = 1;
+ int i, n;
+
+ if (!factors || !r_g || !prime)
+ return gpg_error (GPG_ERR_INV_ARG);
+ *r_g = NULL;
+
+ for (n=0; factors[n]; n++)
+ ;
+ if (n < 2)
+ return gpg_error (GPG_ERR_INV_ARG);
+
+ /* Extra sanity check - usually disabled. */
+/* mpi_set (tmp, factors[0]); */
+/* for(i = 1; i < n; i++) */
+/* mpi_mul (tmp, tmp, factors[i]); */
+/* mpi_add_ui (tmp, tmp, 1); */
+/* if (mpi_cmp (prime, tmp)) */
+/* return gpg_error (GPG_ERR_INV_ARG); */
+
+ gcry_mpi_sub_ui (pmin1, prime, 1);
+ do
+ {
+ if (first)
+ first = 0;
+ else
+ gcry_mpi_add_ui (g, g, 1);
+
+ if (DBG_CIPHER)
+ {
+ log_debug ("checking g:");
+ gcry_mpi_dump (g);
+ log_debug ("\n");
+ }
+ else
+ progress('^');
+
+ for (i = 0; i < n; i++)
+ {
+ mpi_fdiv_q (tmp, pmin1, factors[i]);
+ gcry_mpi_powm (b, g, tmp, prime);
+ if (! mpi_cmp_ui (b, 1))
+ break;
+ }
+ if (DBG_CIPHER)
+ progress('\n');
+ }
+ while (i < n);
+
+ gcry_mpi_release (tmp);
+ gcry_mpi_release (b);
+ gcry_mpi_release (pmin1);
+ *r_g = g;
+
+ return 0;
+}
+
+/* Convenience function to release the factors array. */
+void
+gcry_prime_release_factors (gcry_mpi_t *factors)
+{
+ if (factors)
+ {
+ int i;
+
+ for (i=0; factors[i]; i++)
+ mpi_free (factors[i]);
+ gcry_free (factors);
+ }
+}
+
+
+
+/* Helper for _gcry_derive_x931_prime. */
+static gcry_mpi_t
+find_x931_prime (const gcry_mpi_t pfirst)
+{
+ gcry_mpi_t val_2 = mpi_alloc_set_ui (2);
+ gcry_mpi_t prime;
+
+ prime = gcry_mpi_copy (pfirst);
+ /* If P is even add 1. */
+ mpi_set_bit (prime, 0);
+
+ /* We use 64 Rabin-Miller rounds which is better and thus
+ sufficient. We do not have a Lucas test implementaion thus we
+ can't do it in the X9.31 preferred way of running a few
+ Rabin-Miller followed by one Lucas test. */
+ while ( !check_prime (prime, val_2, 64, NULL, NULL) )
+ mpi_add_ui (prime, prime, 2);
+
+ mpi_free (val_2);
+
+ return prime;
+}
+
+
+/* Generate a prime using the algorithm from X9.31 appendix B.4.
+
+ This function requires that the provided public exponent E is odd.
+ XP, XP1 and XP2 are the seed values. All values are mandatory.
+
+ On success the prime is returned. If R_P1 or R_P2 are given the
+ internal values P1 and P2 are saved at these addresses. On error
+ NULL is returned. */
+gcry_mpi_t
+_gcry_derive_x931_prime (const gcry_mpi_t xp,
+ const gcry_mpi_t xp1, const gcry_mpi_t xp2,
+ const gcry_mpi_t e,
+ gcry_mpi_t *r_p1, gcry_mpi_t *r_p2)
+{
+ gcry_mpi_t p1, p2, p1p2, yp0;
+
+ if (!xp || !xp1 || !xp2)
+ return NULL;
+ if (!e || !mpi_test_bit (e, 0))
+ return NULL; /* We support only odd values for E. */
+
+ p1 = find_x931_prime (xp1);
+ p2 = find_x931_prime (xp2);
+ p1p2 = mpi_alloc_like (xp);
+ mpi_mul (p1p2, p1, p2);
+
+ {
+ gcry_mpi_t r1, tmp;
+
+ /* r1 = (p2^{-1} mod p1)p2 - (p1^{-1} mod p2) */
+ tmp = mpi_alloc_like (p1);
+ mpi_invm (tmp, p2, p1);
+ mpi_mul (tmp, tmp, p2);
+ r1 = tmp;
+
+ tmp = mpi_alloc_like (p2);
+ mpi_invm (tmp, p1, p2);
+ mpi_mul (tmp, tmp, p1);
+ mpi_sub (r1, r1, tmp);
+
+ /* Fixup a negative value. */
+ if (mpi_is_neg (r1))
+ mpi_add (r1, r1, p1p2);
+
+ /* yp0 = xp + (r1 - xp mod p1*p2) */
+ yp0 = tmp; tmp = NULL;
+ mpi_subm (yp0, r1, xp, p1p2);
+ mpi_add (yp0, yp0, xp);
+ mpi_free (r1);
+
+ /* Fixup a negative value. */
+ if (mpi_cmp (yp0, xp) < 0 )
+ mpi_add (yp0, yp0, p1p2);
+ }
+
+ /* yp0 is now the first integer greater than xp with p1 being a
+ large prime factor of yp0-1 and p2 a large prime factor of yp0+1. */
+
+ /* Note that the first example from X9.31 (D.1.1) which uses
+ (Xq1 #1A5CF72EE770DE50CB09ACCEA9#)
+ (Xq2 #134E4CAA16D2350A21D775C404#)
+ (Xq #CC1092495D867E64065DEE3E7955F2EBC7D47A2D
+ 7C9953388F97DDDC3E1CA19C35CA659EDC2FC325
+ 6D29C2627479C086A699A49C4C9CEE7EF7BD1B34
+ 321DE34A#))))
+ returns an yp0 of
+ #CC1092495D867E64065DEE3E7955F2EBC7D47A2D
+ 7C9953388F97DDDC3E1CA19C35CA659EDC2FC4E3
+ BF20CB896EE37E098A906313271422162CB6C642
+ 75C1201F#
+ and not
+ #CC1092495D867E64065DEE3E7955F2EBC7D47A2D
+ 7C9953388F97DDDC3E1CA19C35CA659EDC2FC2E6
+ C88FE299D52D78BE405A97E01FD71DD7819ECB91
+ FA85A076#
+ as stated in the standard. This seems to be a bug in X9.31.
+ */
+
+ {
+ gcry_mpi_t val_2 = mpi_alloc_set_ui (2);
+ gcry_mpi_t gcdtmp = mpi_alloc_like (yp0);
+ int gcdres;
+
+ mpi_sub_ui (p1p2, p1p2, 1); /* Adjust for loop body. */
+ mpi_sub_ui (yp0, yp0, 1); /* Ditto. */
+ for (;;)
+ {
+ gcdres = gcry_mpi_gcd (gcdtmp, e, yp0);
+ mpi_add_ui (yp0, yp0, 1);
+ if (!gcdres)
+ progress ('/'); /* gcd (e, yp0-1) != 1 */
+ else if (check_prime (yp0, val_2, 64, NULL, NULL))
+ break; /* Found. */
+ /* We add p1p2-1 because yp0 is incremented after the gcd test. */
+ mpi_add (yp0, yp0, p1p2);
+ }
+ mpi_free (gcdtmp);
+ mpi_free (val_2);
+ }
+
+ mpi_free (p1p2);
+
+ progress('\n');
+ if (r_p1)
+ *r_p1 = p1;
+ else
+ mpi_free (p1);
+ if (r_p2)
+ *r_p2 = p2;
+ else
+ mpi_free (p2);
+ return yp0;
+}
+
+
+
+/* Generate the two prime used for DSA using the algorithm specified
+ in FIPS 186-2. PBITS is the desired length of the prime P and a
+ QBITS the length of the prime Q. If SEED is not supplied and
+ SEEDLEN is 0 the function generates an appropriate SEED. On
+ success the generated primes are stored at R_Q and R_P, the counter
+ value is stored at R_COUNTER and the seed actually used for
+ generation is stored at R_SEED and R_SEEDVALUE. */
+gpg_err_code_t
+_gcry_generate_fips186_2_prime (unsigned int pbits, unsigned int qbits,
+ const void *seed, size_t seedlen,
+ gcry_mpi_t *r_q, gcry_mpi_t *r_p,
+ int *r_counter,
+ void **r_seed, size_t *r_seedlen)
+{
+ gpg_err_code_t ec;
+ unsigned char seed_help_buffer[160/8]; /* Used to hold a generated SEED. */
+ unsigned char *seed_plus; /* Malloced buffer to hold SEED+x. */
+ unsigned char digest[160/8]; /* Helper buffer for SHA-1 digest. */
+ gcry_mpi_t val_2 = NULL; /* Helper for the prime test. */
+ gcry_mpi_t tmpval = NULL; /* Helper variable. */
+ int i;
+
+ unsigned char value_u[160/8];
+ int value_n, value_b, value_k;
+ int counter;
+ gcry_mpi_t value_w = NULL;
+ gcry_mpi_t value_x = NULL;
+ gcry_mpi_t prime_q = NULL;
+ gcry_mpi_t prime_p = NULL;
+
+ /* FIPS 186-2 allows only for 1024/160 bit. */
+ if (pbits != 1024 || qbits != 160)
+ return GPG_ERR_INV_KEYLEN;
+
+ if (!seed && !seedlen)
+ ; /* No seed value given: We are asked to generate it. */
+ else if (!seed || seedlen < qbits/8)
+ return GPG_ERR_INV_ARG;
+
+ /* Allocate a buffer to later compute SEED+some_increment. */
+ seed_plus = gcry_malloc (seedlen < 20? 20:seedlen);
+ if (!seed_plus)
+ {
+ ec = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+
+ val_2 = mpi_alloc_set_ui (2);
+ value_n = (pbits - 1) / qbits;
+ value_b = (pbits - 1) - value_n * qbits;
+ value_w = gcry_mpi_new (pbits);
+ value_x = gcry_mpi_new (pbits);
+
+ restart:
+ /* Generate Q. */
+ for (;;)
+ {
+ /* Step 1: Generate a (new) seed unless one has been supplied. */
+ if (!seed)
+ {
+ seedlen = sizeof seed_help_buffer;
+ gcry_create_nonce (seed_help_buffer, seedlen);
+ seed = seed_help_buffer;
+ }
+
+ /* Step 2: U = sha1(seed) ^ sha1((seed+1) mod 2^{qbits}) */
+ memcpy (seed_plus, seed, seedlen);
+ for (i=seedlen-1; i >= 0; i--)
+ {
+ seed_plus[i]++;
+ if (seed_plus[i])
+ break;
+ }
+ gcry_md_hash_buffer (GCRY_MD_SHA1, value_u, seed, seedlen);
+ gcry_md_hash_buffer (GCRY_MD_SHA1, digest, seed_plus, seedlen);
+ for (i=0; i < sizeof value_u; i++)
+ value_u[i] ^= digest[i];
+
+ /* Step 3: Form q from U */
+ gcry_mpi_release (prime_q); prime_q = NULL;
+ ec = gpg_err_code (gcry_mpi_scan (&prime_q, GCRYMPI_FMT_USG,
+ value_u, sizeof value_u, NULL));
+ if (ec)
+ goto leave;
+ mpi_set_highbit (prime_q, qbits-1 );
+ mpi_set_bit (prime_q, 0);
+
+ /* Step 4: Test whether Q is prime using 64 round of Rabin-Miller. */
+ if (check_prime (prime_q, val_2, 64, NULL, NULL))
+ break; /* Yes, Q is prime. */
+
+ /* Step 5. */
+ seed = NULL; /* Force a new seed at Step 1. */
+ }
+
+ /* Step 6. Note that we do no use an explicit offset but increment
+ SEED_PLUS accordingly. SEED_PLUS is currently SEED+1. */
+ counter = 0;
+
+ /* Generate P. */
+ prime_p = gcry_mpi_new (pbits);
+ for (;;)
+ {
+ /* Step 7: For k = 0,...n let
+ V_k = sha1(seed+offset+k) mod 2^{qbits}
+ Step 8: W = V_0 + V_1*2^160 +
+ ...
+ + V_{n-1}*2^{(n-1)*160}
+ + (V_{n} mod 2^b)*2^{n*160}
+ */
+ mpi_set_ui (value_w, 0);
+ for (value_k=0; value_k <= value_n; value_k++)
+ {
+ /* There is no need to have an explicit offset variable: In
+ the first round we shall have an offset of 2, this is
+ achieved by using SEED_PLUS which is already at SEED+1,
+ thus we just need to increment it once again. The
+ requirement for the next round is to update offset by N,
+ which we implictly did at the end of this loop, and then
+ to add one; this one is the same as in the first round. */
+ for (i=seedlen-1; i >= 0; i--)
+ {
+ seed_plus[i]++;
+ if (seed_plus[i])
+ break;
+ }
+ gcry_md_hash_buffer (GCRY_MD_SHA1, digest, seed_plus, seedlen);
+
+ gcry_mpi_release (tmpval); tmpval = NULL;
+ ec = gpg_err_code (gcry_mpi_scan (&tmpval, GCRYMPI_FMT_USG,
+ digest, sizeof digest, NULL));
+ if (ec)
+ goto leave;
+ if (value_k == value_n)
+ mpi_clear_highbit (tmpval, value_b); /* (V_n mod 2^b) */
+ mpi_lshift (tmpval, tmpval, value_k*qbits);
+ mpi_add (value_w, value_w, tmpval);
+ }
+
+ /* Step 8 continued: X = W + 2^{L-1} */
+ mpi_set_ui (value_x, 0);
+ mpi_set_highbit (value_x, pbits-1);
+ mpi_add (value_x, value_x, value_w);
+
+ /* Step 9: c = X mod 2q, p = X - (c - 1) */
+ mpi_mul_2exp (tmpval, prime_q, 1);
+ mpi_mod (tmpval, value_x, tmpval);
+ mpi_sub_ui (tmpval, tmpval, 1);
+ mpi_sub (prime_p, value_x, tmpval);
+
+ /* Step 10: If p < 2^{L-1} skip the primality test. */
+ /* Step 11 and 12: Primality test. */
+ if (mpi_get_nbits (prime_p) >= pbits-1
+ && check_prime (prime_p, val_2, 64, NULL, NULL) )
+ break; /* Yes, P is prime, continue with Step 15. */
+
+ /* Step 13: counter = counter + 1, offset = offset + n + 1. */
+ counter++;
+
+ /* Step 14: If counter >= 2^12 goto Step 1. */
+ if (counter >= 4096)
+ goto restart;
+ }
+
+ /* Step 15: Save p, q, counter and seed. */
+/* log_debug ("fips186-2 pbits p=%u q=%u counter=%d\n", */
+/* mpi_get_nbits (prime_p), mpi_get_nbits (prime_q), counter); */
+/* log_printhex("fips186-2 seed:", seed, seedlen); */
+/* log_mpidump ("fips186-2 prime p", prime_p); */
+/* log_mpidump ("fips186-2 prime q", prime_q); */
+ if (r_q)
+ {
+ *r_q = prime_q;
+ prime_q = NULL;
+ }
+ if (r_p)
+ {
+ *r_p = prime_p;
+ prime_p = NULL;
+ }
+ if (r_counter)
+ *r_counter = counter;
+ if (r_seed && r_seedlen)
+ {
+ memcpy (seed_plus, seed, seedlen);
+ *r_seed = seed_plus;
+ seed_plus = NULL;
+ *r_seedlen = seedlen;
+ }
+
+
+ leave:
+ gcry_mpi_release (tmpval);
+ gcry_mpi_release (value_x);
+ gcry_mpi_release (value_w);
+ gcry_mpi_release (prime_p);
+ gcry_mpi_release (prime_q);
+ gcry_free (seed_plus);
+ gcry_mpi_release (val_2);
+ return ec;
+}
+
+
+
+/* WARNING: The code below has not yet been tested! However, it is
+ not yet used. We need to wait for FIPS 186-3 final and for test
+ vectors.
+
+ Generate the two prime used for DSA using the algorithm specified
+ in FIPS 186-3, A.1.1.2. PBITS is the desired length of the prime P
+ and a QBITS the length of the prime Q. If SEED is not supplied and
+ SEEDLEN is 0 the function generates an appropriate SEED. On
+ success the generated primes are stored at R_Q and R_P, the counter
+ value is stored at R_COUNTER and the seed actually used for
+ generation is stored at R_SEED and R_SEEDVALUE. The hash algorithm
+ used is stored at R_HASHALGO.
+
+ Note that this function is very similar to the fips186_2 code. Due
+ to the minor differences, other buffer sizes and for documentarion,
+ we use a separate function.
+*/
+gpg_err_code_t
+_gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits,
+ const void *seed, size_t seedlen,
+ gcry_mpi_t *r_q, gcry_mpi_t *r_p,
+ int *r_counter,
+ void **r_seed, size_t *r_seedlen,
+ int *r_hashalgo)
+{
+ gpg_err_code_t ec;
+ unsigned char seed_help_buffer[256/8]; /* Used to hold a generated SEED. */
+ unsigned char *seed_plus; /* Malloced buffer to hold SEED+x. */
+ unsigned char digest[256/8]; /* Helper buffer for SHA-1 digest. */
+ gcry_mpi_t val_2 = NULL; /* Helper for the prime test. */
+ gcry_mpi_t tmpval = NULL; /* Helper variable. */
+ int hashalgo; /* The id of the Approved Hash Function. */
+ int i;
+
+ unsigned char value_u[256/8];
+ int value_n, value_b, value_j;
+ int counter;
+ gcry_mpi_t value_w = NULL;
+ gcry_mpi_t value_x = NULL;
+ gcry_mpi_t prime_q = NULL;
+ gcry_mpi_t prime_p = NULL;
+
+ gcry_assert (sizeof seed_help_buffer == sizeof digest
+ && sizeof seed_help_buffer == sizeof value_u);
+
+ /* Step 1: Check the requested prime lengths. */
+ /* Note that due to the size of our buffers QBITS is limited to 256. */
+ if (pbits == 1024 && qbits == 160)
+ hashalgo = GCRY_MD_SHA1;
+ else if (pbits == 2048 && qbits == 224)
+ hashalgo = GCRY_MD_SHA224;
+ else if (pbits == 2048 && qbits == 256)
+ hashalgo = GCRY_MD_SHA256;
+ else if (pbits == 3072 && qbits == 256)
+ hashalgo = GCRY_MD_SHA256;
+ else
+ return GPG_ERR_INV_KEYLEN;
+
+ /* Also check that the hash algorithm is available. */
+ ec = gpg_err_code (gcry_md_test_algo (hashalgo));
+ if (ec)
+ return ec;
+ gcry_assert (qbits/8 <= sizeof digest);
+ gcry_assert (gcry_md_get_algo_dlen (hashalgo) == qbits/8);
+
+
+ /* Step 2: Check seedlen. */
+ if (!seed && !seedlen)
+ ; /* No seed value given: We are asked to generate it. */
+ else if (!seed || seedlen < qbits/8)
+ return GPG_ERR_INV_ARG;
+
+ /* Allocate a buffer to later compute SEED+some_increment and a few
+ helper variables. */
+ seed_plus = gcry_malloc (seedlen < sizeof seed_help_buffer?
+ sizeof seed_help_buffer : seedlen);
+ if (!seed_plus)
+ {
+ ec = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ val_2 = mpi_alloc_set_ui (2);
+ value_w = gcry_mpi_new (pbits);
+ value_x = gcry_mpi_new (pbits);
+
+ /* Step 3: n = \lceil L / outlen \rceil - 1 */
+ value_n = (pbits + qbits - 1) / qbits - 1;
+ /* Step 4: b = L - 1 - (n * outlen) */
+ value_b = pbits - 1 - (value_n * qbits);
+
+ restart:
+ /* Generate Q. */
+ for (;;)
+ {
+ /* Step 5: Generate a (new) seed unless one has been supplied. */
+ if (!seed)
+ {
+ seedlen = qbits/8;
+ gcry_assert (seedlen <= sizeof seed_help_buffer);
+ gcry_create_nonce (seed_help_buffer, seedlen);
+ seed = seed_help_buffer;
+ }
+
+ /* Step 6: U = hash(seed) */
+ gcry_md_hash_buffer (hashalgo, value_u, seed, seedlen);
+
+ /* Step 7: q = 2^{N-1} + U + 1 - (U mod 2) */
+ if ( !(value_u[qbits/8-1] & 0x01) )
+ {
+ for (i=qbits/8-1; i >= 0; i--)
+ {
+ value_u[i]++;
+ if (value_u[i])
+ break;
+ }
+ }
+ gcry_mpi_release (prime_q); prime_q = NULL;
+ ec = gpg_err_code (gcry_mpi_scan (&prime_q, GCRYMPI_FMT_USG,
+ value_u, sizeof value_u, NULL));
+ if (ec)
+ goto leave;
+ mpi_set_highbit (prime_q, qbits-1 );
+
+ /* Step 8: Test whether Q is prime using 64 round of Rabin-Miller.
+ According to table C.1 this is sufficient for all
+ supported prime sizes (i.e. up 3072/256). */
+ if (check_prime (prime_q, val_2, 64, NULL, NULL))
+ break; /* Yes, Q is prime. */
+
+ /* Step 8. */
+ seed = NULL; /* Force a new seed at Step 5. */
+ }
+
+ /* Step 11. Note that we do no use an explicit offset but increment
+ SEED_PLUS accordingly. */
+ memcpy (seed_plus, seed, seedlen);
+ counter = 0;
+
+ /* Generate P. */
+ prime_p = gcry_mpi_new (pbits);
+ for (;;)
+ {
+ /* Step 11.1: For j = 0,...n let
+ V_j = hash(seed+offset+j)
+ Step 11.2: W = V_0 + V_1*2^outlen +
+ ...
+ + V_{n-1}*2^{(n-1)*outlen}
+ + (V_{n} mod 2^b)*2^{n*outlen}
+ */
+ mpi_set_ui (value_w, 0);
+ for (value_j=0; value_j <= value_n; value_j++)
+ {
+ /* There is no need to have an explicit offset variable: In
+ the first round we shall have an offset of 1 and a j of
+ 0. This is achieved by incrementing SEED_PLUS here. For
+ the next round offset is implicitly updated by using
+ SEED_PLUS again. */
+ for (i=seedlen-1; i >= 0; i--)
+ {
+ seed_plus[i]++;
+ if (seed_plus[i])
+ break;
+ }
+ gcry_md_hash_buffer (GCRY_MD_SHA1, digest, seed_plus, seedlen);
+
+ gcry_mpi_release (tmpval); tmpval = NULL;
+ ec = gpg_err_code (gcry_mpi_scan (&tmpval, GCRYMPI_FMT_USG,
+ digest, sizeof digest, NULL));
+ if (ec)
+ goto leave;
+ if (value_j == value_n)
+ mpi_clear_highbit (tmpval, value_b); /* (V_n mod 2^b) */
+ mpi_lshift (tmpval, tmpval, value_j*qbits);
+ mpi_add (value_w, value_w, tmpval);
+ }
+
+ /* Step 11.3: X = W + 2^{L-1} */
+ mpi_set_ui (value_x, 0);
+ mpi_set_highbit (value_x, pbits-1);
+ mpi_add (value_x, value_x, value_w);
+
+ /* Step 11.4: c = X mod 2q */
+ mpi_mul_2exp (tmpval, prime_q, 1);
+ mpi_mod (tmpval, value_x, tmpval);
+
+ /* Step 11.5: p = X - (c - 1) */
+ mpi_sub_ui (tmpval, tmpval, 1);
+ mpi_sub (prime_p, value_x, tmpval);
+
+ /* Step 11.6: If p < 2^{L-1} skip the primality test. */
+ /* Step 11.7 and 11.8: Primality test. */
+ if (mpi_get_nbits (prime_p) >= pbits-1
+ && check_prime (prime_p, val_2, 64, NULL, NULL) )
+ break; /* Yes, P is prime, continue with Step 15. */
+
+ /* Step 11.9: counter = counter + 1, offset = offset + n + 1.
+ If counter >= 4L goto Step 5. */
+ counter++;
+ if (counter >= 4*pbits)
+ goto restart;
+ }
+
+ /* Step 12: Save p, q, counter and seed. */
+ log_debug ("fips186-3 pbits p=%u q=%u counter=%d\n",
+ mpi_get_nbits (prime_p), mpi_get_nbits (prime_q), counter);
+ log_printhex("fips186-3 seed:", seed, seedlen);
+ log_mpidump ("fips186-3 prime p", prime_p);
+ log_mpidump ("fips186-3 prime q", prime_q);
+ if (r_q)
+ {
+ *r_q = prime_q;
+ prime_q = NULL;
+ }
+ if (r_p)
+ {
+ *r_p = prime_p;
+ prime_p = NULL;
+ }
+ if (r_counter)
+ *r_counter = counter;
+ if (r_seed && r_seedlen)
+ {
+ memcpy (seed_plus, seed, seedlen);
+ *r_seed = seed_plus;
+ seed_plus = NULL;
+ *r_seedlen = seedlen;
+ }
+ if (r_hashalgo)
+ *r_hashalgo = hashalgo;
+
+ leave:
+ gcry_mpi_release (tmpval);
+ gcry_mpi_release (value_x);
+ gcry_mpi_release (value_w);
+ gcry_mpi_release (prime_p);
+ gcry_mpi_release (prime_q);
+ gcry_free (seed_plus);
+ gcry_mpi_release (val_2);
+ return ec;
+}
diff --git a/grub-core/lib/libgcrypt/cipher/pubkey.c b/grub-core/lib/libgcrypt/cipher/pubkey.c
new file mode 100644
index 0000000..ca087ad
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/pubkey.c
@@ -0,0 +1,4212 @@
+/* pubkey.c - pubkey dispatcher
+ * Copyright (C) 1998, 1999, 2000, 2002, 2003, 2005,
+ * 2007, 2008, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "g10lib.h"
+#include "mpi.h"
+#include "cipher.h"
+#include "ath.h"
+
+
+static gcry_err_code_t pubkey_decrypt (int algo, gcry_mpi_t *result,
+ gcry_mpi_t *data, gcry_mpi_t *skey,
+ int flags);
+static gcry_err_code_t pubkey_sign (int algo, gcry_mpi_t *resarr,
+ gcry_mpi_t hash, gcry_mpi_t *skey);
+static gcry_err_code_t pubkey_verify (int algo, gcry_mpi_t hash,
+ gcry_mpi_t *data, gcry_mpi_t *pkey,
+ int (*cmp) (void *, gcry_mpi_t),
+ void *opaque);
+
+
+/* A dummy extraspec so that we do not need to tests the extraspec
+ field from the module specification against NULL and instead
+ directly test the respective fields of extraspecs. */
+static pk_extra_spec_t dummy_extra_spec;
+
+
+/* This is the list of the default public-key ciphers included in
+ libgcrypt. FIPS_ALLOWED indicated whether the algorithm is used in
+ FIPS mode. */
+static struct pubkey_table_entry
+{
+ gcry_pk_spec_t *pubkey;
+ pk_extra_spec_t *extraspec;
+ unsigned int algorithm;
+ int fips_allowed;
+} pubkey_table[] =
+ {
+#if USE_RSA
+ { &_gcry_pubkey_spec_rsa,
+ &_gcry_pubkey_extraspec_rsa, GCRY_PK_RSA, 1},
+#endif
+#if USE_ELGAMAL
+ { &_gcry_pubkey_spec_elg,
+ &_gcry_pubkey_extraspec_elg, GCRY_PK_ELG },
+ { &_gcry_pubkey_spec_elg,
+ &_gcry_pubkey_extraspec_elg, GCRY_PK_ELG_E },
+#endif
+#if USE_DSA
+ { &_gcry_pubkey_spec_dsa,
+ &_gcry_pubkey_extraspec_dsa, GCRY_PK_DSA, 1 },
+#endif
+#if USE_ECC
+ { &_gcry_pubkey_spec_ecdsa,
+ &_gcry_pubkey_extraspec_ecdsa, GCRY_PK_ECDSA, 0 },
+ { &_gcry_pubkey_spec_ecdh,
+ &_gcry_pubkey_extraspec_ecdsa, GCRY_PK_ECDH, 0 },
+#endif
+ { NULL, 0 },
+ };
+
+/* List of registered ciphers. */
+static gcry_module_t pubkeys_registered;
+
+/* This is the lock protecting PUBKEYS_REGISTERED. */
+static ath_mutex_t pubkeys_registered_lock = ATH_MUTEX_INITIALIZER;;
+
+/* Flag to check whether the default pubkeys have already been
+ registered. */
+static int default_pubkeys_registered;
+
+/* Convenient macro for registering the default digests. */
+#define REGISTER_DEFAULT_PUBKEYS \
+ do \
+ { \
+ ath_mutex_lock (&pubkeys_registered_lock); \
+ if (! default_pubkeys_registered) \
+ { \
+ pk_register_default (); \
+ default_pubkeys_registered = 1; \
+ } \
+ ath_mutex_unlock (&pubkeys_registered_lock); \
+ } \
+ while (0)
+
+/* These dummy functions are used in case a cipher implementation
+ refuses to provide it's own functions. */
+
+static gcry_err_code_t
+dummy_generate (int algorithm, unsigned int nbits, unsigned long dummy,
+ gcry_mpi_t *skey, gcry_mpi_t **retfactors)
+{
+ (void)algorithm;
+ (void)nbits;
+ (void)dummy;
+ (void)skey;
+ (void)retfactors;
+ fips_signal_error ("using dummy public key function");
+ return GPG_ERR_NOT_IMPLEMENTED;
+}
+
+static gcry_err_code_t
+dummy_check_secret_key (int algorithm, gcry_mpi_t *skey)
+{
+ (void)algorithm;
+ (void)skey;
+ fips_signal_error ("using dummy public key function");
+ return GPG_ERR_NOT_IMPLEMENTED;
+}
+
+static gcry_err_code_t
+dummy_encrypt (int algorithm, gcry_mpi_t *resarr, gcry_mpi_t data,
+ gcry_mpi_t *pkey, int flags)
+{
+ (void)algorithm;
+ (void)resarr;
+ (void)data;
+ (void)pkey;
+ (void)flags;
+ fips_signal_error ("using dummy public key function");
+ return GPG_ERR_NOT_IMPLEMENTED;
+}
+
+static gcry_err_code_t
+dummy_decrypt (int algorithm, gcry_mpi_t *result, gcry_mpi_t *data,
+ gcry_mpi_t *skey, int flags)
+{
+ (void)algorithm;
+ (void)result;
+ (void)data;
+ (void)skey;
+ (void)flags;
+ fips_signal_error ("using dummy public key function");
+ return GPG_ERR_NOT_IMPLEMENTED;
+}
+
+static gcry_err_code_t
+dummy_sign (int algorithm, gcry_mpi_t *resarr, gcry_mpi_t data,
+ gcry_mpi_t *skey)
+{
+ (void)algorithm;
+ (void)resarr;
+ (void)data;
+ (void)skey;
+ fips_signal_error ("using dummy public key function");
+ return GPG_ERR_NOT_IMPLEMENTED;
+}
+
+static gcry_err_code_t
+dummy_verify (int algorithm, gcry_mpi_t hash, gcry_mpi_t *data,
+ gcry_mpi_t *pkey,
+ int (*cmp) (void *, gcry_mpi_t), void *opaquev)
+{
+ (void)algorithm;
+ (void)hash;
+ (void)data;
+ (void)pkey;
+ (void)cmp;
+ (void)opaquev;
+ fips_signal_error ("using dummy public key function");
+ return GPG_ERR_NOT_IMPLEMENTED;
+}
+
+static unsigned
+dummy_get_nbits (int algorithm, gcry_mpi_t *pkey)
+{
+ (void)algorithm;
+ (void)pkey;
+ fips_signal_error ("using dummy public key function");
+ return 0;
+}
+
+/* Internal function. Register all the pubkeys included in
+ PUBKEY_TABLE. Returns zero on success or an error code. */
+static void
+pk_register_default (void)
+{
+ gcry_err_code_t err = 0;
+ int i;
+
+ for (i = 0; (! err) && pubkey_table[i].pubkey; i++)
+ {
+#define pubkey_use_dummy(func) \
+ if (! pubkey_table[i].pubkey->func) \
+ pubkey_table[i].pubkey->func = dummy_##func;
+
+ pubkey_use_dummy (generate);
+ pubkey_use_dummy (check_secret_key);
+ pubkey_use_dummy (encrypt);
+ pubkey_use_dummy (decrypt);
+ pubkey_use_dummy (sign);
+ pubkey_use_dummy (verify);
+ pubkey_use_dummy (get_nbits);
+#undef pubkey_use_dummy
+
+ err = _gcry_module_add (&pubkeys_registered,
+ pubkey_table[i].algorithm,
+ (void *) pubkey_table[i].pubkey,
+ (void *) pubkey_table[i].extraspec,
+ NULL);
+ }
+
+ if (err)
+ BUG ();
+}
+
+/* Internal callback function. Used via _gcry_module_lookup. */
+static int
+gcry_pk_lookup_func_name (void *spec, void *data)
+{
+ gcry_pk_spec_t *pubkey = (gcry_pk_spec_t *) spec;
+ char *name = (char *) data;
+ const char **aliases = pubkey->aliases;
+ int ret = stricmp (name, pubkey->name);
+
+ while (ret && *aliases)
+ ret = stricmp (name, *aliases++);
+
+ return ! ret;
+}
+
+/* Internal function. Lookup a pubkey entry by it's name. */
+static gcry_module_t
+gcry_pk_lookup_name (const char *name)
+{
+ gcry_module_t pubkey;
+
+ pubkey = _gcry_module_lookup (pubkeys_registered, (void *) name,
+ gcry_pk_lookup_func_name);
+
+ return pubkey;
+}
+
+/* Register a new pubkey module whose specification can be found in
+ PUBKEY. On success, a new algorithm ID is stored in ALGORITHM_ID
+ and a pointer representhing this module is stored in MODULE. */
+gcry_error_t
+_gcry_pk_register (gcry_pk_spec_t *pubkey,
+ pk_extra_spec_t *extraspec,
+ unsigned int *algorithm_id,
+ gcry_module_t *module)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ gcry_module_t mod;
+
+ /* We do not support module loading in fips mode. */
+ if (fips_mode ())
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ err = _gcry_module_add (&pubkeys_registered, 0,
+ (void *) pubkey,
+ (void *)(extraspec? extraspec : &dummy_extra_spec),
+ &mod);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ if (! err)
+ {
+ *module = mod;
+ *algorithm_id = mod->mod_id;
+ }
+
+ return err;
+}
+
+/* Unregister the pubkey identified by ID, which must have been
+ registered with gcry_pk_register. */
+void
+gcry_pk_unregister (gcry_module_t module)
+{
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+}
+
+static void
+release_mpi_array (gcry_mpi_t *array)
+{
+ for (; *array; array++)
+ {
+ mpi_free(*array);
+ *array = NULL;
+ }
+}
+
+/****************
+ * Map a string to the pubkey algo
+ */
+int
+gcry_pk_map_name (const char *string)
+{
+ gcry_module_t pubkey;
+ int algorithm = 0;
+
+ if (!string)
+ return 0;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = gcry_pk_lookup_name (string);
+ if (pubkey)
+ {
+ algorithm = pubkey->mod_id;
+ _gcry_module_release (pubkey);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return algorithm;
+}
+
+
+/* Map the public key algorithm whose ID is contained in ALGORITHM to
+ a string representation of the algorithm name. For unknown
+ algorithm IDs this functions returns "?". */
+const char *
+gcry_pk_algo_name (int algorithm)
+{
+ gcry_module_t pubkey;
+ const char *name;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (pubkey)
+ {
+ name = ((gcry_pk_spec_t *) pubkey->spec)->name;
+ _gcry_module_release (pubkey);
+ }
+ else
+ name = "?";
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return name;
+}
+
+
+/* A special version of gcry_pk_algo name to return the first aliased
+ name of the algorithm. This is required to adhere to the spki
+ specs where the algorithm names are lowercase. */
+const char *
+_gcry_pk_aliased_algo_name (int algorithm)
+{
+ const char *name = NULL;
+ gcry_module_t module;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (module)
+ {
+ gcry_pk_spec_t *pubkey = (gcry_pk_spec_t *) module->spec;
+
+ name = pubkey->aliases? *pubkey->aliases : NULL;
+ if (!name || !*name)
+ name = pubkey->name;
+ _gcry_module_release (module);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return name;
+}
+
+
+static void
+disable_pubkey_algo (int algorithm)
+{
+ gcry_module_t pubkey;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (pubkey)
+ {
+ if (! (pubkey-> flags & FLAG_MODULE_DISABLED))
+ pubkey->flags |= FLAG_MODULE_DISABLED;
+ _gcry_module_release (pubkey);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+}
+
+
+/****************
+ * A USE of 0 means: don't care.
+ */
+static gcry_err_code_t
+check_pubkey_algo (int algorithm, unsigned use)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ gcry_pk_spec_t *pubkey;
+ gcry_module_t module;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (module)
+ {
+ pubkey = (gcry_pk_spec_t *) module->spec;
+
+ if (((use & GCRY_PK_USAGE_SIGN)
+ && (! (pubkey->use & GCRY_PK_USAGE_SIGN)))
+ || ((use & GCRY_PK_USAGE_ENCR)
+ && (! (pubkey->use & GCRY_PK_USAGE_ENCR))))
+ err = GPG_ERR_WRONG_PUBKEY_ALGO;
+ else if (module->flags & FLAG_MODULE_DISABLED)
+ err = GPG_ERR_PUBKEY_ALGO;
+ _gcry_module_release (module);
+ }
+ else
+ err = GPG_ERR_PUBKEY_ALGO;
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return err;
+}
+
+
+/****************
+ * Return the number of public key material numbers
+ */
+static int
+pubkey_get_npkey (int algorithm)
+{
+ gcry_module_t pubkey;
+ int npkey = 0;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (pubkey)
+ {
+ npkey = strlen (((gcry_pk_spec_t *) pubkey->spec)->elements_pkey);
+ _gcry_module_release (pubkey);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return npkey;
+}
+
+/****************
+ * Return the number of secret key material numbers
+ */
+static int
+pubkey_get_nskey (int algorithm)
+{
+ gcry_module_t pubkey;
+ int nskey = 0;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (pubkey)
+ {
+ nskey = strlen (((gcry_pk_spec_t *) pubkey->spec)->elements_skey);
+ _gcry_module_release (pubkey);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return nskey;
+}
+
+/****************
+ * Return the number of signature material numbers
+ */
+static int
+pubkey_get_nsig (int algorithm)
+{
+ gcry_module_t pubkey;
+ int nsig = 0;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (pubkey)
+ {
+ nsig = strlen (((gcry_pk_spec_t *) pubkey->spec)->elements_sig);
+ _gcry_module_release (pubkey);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return nsig;
+}
+
+/****************
+ * Return the number of encryption material numbers
+ */
+static int
+pubkey_get_nenc (int algorithm)
+{
+ gcry_module_t pubkey;
+ int nenc = 0;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (pubkey)
+ {
+ nenc = strlen (((gcry_pk_spec_t *) pubkey->spec)->elements_enc);
+ _gcry_module_release (pubkey);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return nenc;
+}
+
+
+/* Generate a new public key with algorithm ALGORITHM of size NBITS
+ and return it at SKEY. USE_E depends on the ALGORITHM. GENPARMS
+ is passed to the algorithm module if it features an extended
+ generation function. RETFACTOR is used by some algorithms to
+ return certain additional information which are in general not
+ required.
+
+ The function returns the error code number or 0 on success. */
+static gcry_err_code_t
+pubkey_generate (int algorithm,
+ unsigned int nbits,
+ unsigned long use_e,
+ gcry_sexp_t genparms,
+ gcry_mpi_t *skey, gcry_mpi_t **retfactors,
+ gcry_sexp_t *r_extrainfo)
+{
+ gcry_err_code_t ec = GPG_ERR_PUBKEY_ALGO;
+ gcry_module_t pubkey;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (pubkey)
+ {
+ pk_extra_spec_t *extraspec = pubkey->extraspec;
+
+ if (extraspec && extraspec->ext_generate)
+ {
+ /* Use the extended generate function. */
+ ec = extraspec->ext_generate
+ (algorithm, nbits, use_e, genparms, skey, retfactors, r_extrainfo);
+ }
+ else
+ {
+ /* Use the standard generate function. */
+ ec = ((gcry_pk_spec_t *) pubkey->spec)->generate
+ (algorithm, nbits, use_e, skey, retfactors);
+ }
+ _gcry_module_release (pubkey);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return ec;
+}
+
+
+static gcry_err_code_t
+pubkey_check_secret_key (int algorithm, gcry_mpi_t *skey)
+{
+ gcry_err_code_t err = GPG_ERR_PUBKEY_ALGO;
+ gcry_module_t pubkey;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (pubkey)
+ {
+ err = ((gcry_pk_spec_t *) pubkey->spec)->check_secret_key
+ (algorithm, skey);
+ _gcry_module_release (pubkey);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return err;
+}
+
+
+/****************
+ * This is the interface to the public key encryption. Encrypt DATA
+ * with PKEY and put it into RESARR which should be an array of MPIs
+ * of size PUBKEY_MAX_NENC (or less if the algorithm allows this -
+ * check with pubkey_get_nenc() )
+ */
+static gcry_err_code_t
+pubkey_encrypt (int algorithm, gcry_mpi_t *resarr, gcry_mpi_t data,
+ gcry_mpi_t *pkey, int flags)
+{
+ gcry_pk_spec_t *pubkey;
+ gcry_module_t module;
+ gcry_err_code_t rc;
+ int i;
+
+ /* Note: In fips mode DBG_CIPHER will enver evaluate to true but as
+ an extra failsafe protection we explicitly test for fips mode
+ here. */
+ if (DBG_CIPHER && !fips_mode ())
+ {
+ log_debug ("pubkey_encrypt: algo=%d\n", algorithm);
+ for(i = 0; i < pubkey_get_npkey (algorithm); i++)
+ log_mpidump (" pkey:", pkey[i]);
+ log_mpidump (" data:", data);
+ }
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (module)
+ {
+ pubkey = (gcry_pk_spec_t *) module->spec;
+ rc = pubkey->encrypt (algorithm, resarr, data, pkey, flags);
+ _gcry_module_release (module);
+ goto ready;
+ }
+ rc = GPG_ERR_PUBKEY_ALGO;
+
+ ready:
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ if (!rc && DBG_CIPHER && !fips_mode ())
+ {
+ for(i = 0; i < pubkey_get_nenc (algorithm); i++)
+ log_mpidump(" encr:", resarr[i] );
+ }
+ return rc;
+}
+
+
+/****************
+ * This is the interface to the public key decryption.
+ * ALGO gives the algorithm to use and this implicitly determines
+ * the size of the arrays.
+ * result is a pointer to a mpi variable which will receive a
+ * newly allocated mpi or NULL in case of an error.
+ */
+static gcry_err_code_t
+pubkey_decrypt (int algorithm, gcry_mpi_t *result, gcry_mpi_t *data,
+ gcry_mpi_t *skey, int flags)
+{
+ gcry_pk_spec_t *pubkey;
+ gcry_module_t module;
+ gcry_err_code_t rc;
+ int i;
+
+ *result = NULL; /* so the caller can always do a mpi_free */
+ if (DBG_CIPHER && !fips_mode ())
+ {
+ log_debug ("pubkey_decrypt: algo=%d\n", algorithm);
+ for(i = 0; i < pubkey_get_nskey (algorithm); i++)
+ log_mpidump (" skey:", skey[i]);
+ for(i = 0; i < pubkey_get_nenc (algorithm); i++)
+ log_mpidump (" data:", data[i]);
+ }
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (module)
+ {
+ pubkey = (gcry_pk_spec_t *) module->spec;
+ rc = pubkey->decrypt (algorithm, result, data, skey, flags);
+ _gcry_module_release (module);
+ goto ready;
+ }
+
+ rc = GPG_ERR_PUBKEY_ALGO;
+
+ ready:
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ if (!rc && DBG_CIPHER && !fips_mode ())
+ log_mpidump (" plain:", *result);
+
+ return rc;
+}
+
+
+/****************
+ * This is the interface to the public key signing.
+ * Sign data with skey and put the result into resarr which
+ * should be an array of MPIs of size PUBKEY_MAX_NSIG (or less if the
+ * algorithm allows this - check with pubkey_get_nsig() )
+ */
+static gcry_err_code_t
+pubkey_sign (int algorithm, gcry_mpi_t *resarr, gcry_mpi_t data,
+ gcry_mpi_t *skey)
+{
+ gcry_pk_spec_t *pubkey;
+ gcry_module_t module;
+ gcry_err_code_t rc;
+ int i;
+
+ if (DBG_CIPHER && !fips_mode ())
+ {
+ log_debug ("pubkey_sign: algo=%d\n", algorithm);
+ for(i = 0; i < pubkey_get_nskey (algorithm); i++)
+ log_mpidump (" skey:", skey[i]);
+ log_mpidump(" data:", data );
+ }
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (module)
+ {
+ pubkey = (gcry_pk_spec_t *) module->spec;
+ rc = pubkey->sign (algorithm, resarr, data, skey);
+ _gcry_module_release (module);
+ goto ready;
+ }
+
+ rc = GPG_ERR_PUBKEY_ALGO;
+
+ ready:
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ if (!rc && DBG_CIPHER && !fips_mode ())
+ for (i = 0; i < pubkey_get_nsig (algorithm); i++)
+ log_mpidump (" sig:", resarr[i]);
+
+ return rc;
+}
+
+/****************
+ * Verify a public key signature.
+ * Return 0 if the signature is good
+ */
+static gcry_err_code_t
+pubkey_verify (int algorithm, gcry_mpi_t hash, gcry_mpi_t *data,
+ gcry_mpi_t *pkey,
+ int (*cmp)(void *, gcry_mpi_t), void *opaquev)
+{
+ gcry_pk_spec_t *pubkey;
+ gcry_module_t module;
+ gcry_err_code_t rc;
+ int i;
+
+ if (DBG_CIPHER && !fips_mode ())
+ {
+ log_debug ("pubkey_verify: algo=%d\n", algorithm);
+ for (i = 0; i < pubkey_get_npkey (algorithm); i++)
+ log_mpidump (" pkey", pkey[i]);
+ for (i = 0; i < pubkey_get_nsig (algorithm); i++)
+ log_mpidump (" sig", data[i]);
+ log_mpidump (" hash", hash);
+ }
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (module)
+ {
+ pubkey = (gcry_pk_spec_t *) module->spec;
+ rc = pubkey->verify (algorithm, hash, data, pkey, cmp, opaquev);
+ _gcry_module_release (module);
+ goto ready;
+ }
+
+ rc = GPG_ERR_PUBKEY_ALGO;
+
+ ready:
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ return rc;
+}
+
+
+/* Turn VALUE into an octet string and store it in an allocated buffer
+ at R_FRAME or - if R_RAME is NULL - copy it into the caller
+ provided buffer SPACE; either SPACE or R_FRAME may be used. If
+ SPACE if not NULL, the caller must provide a buffer of at least
+ NBYTES. If the resulting octet string is shorter than NBYTES pad
+ it to the left with zeroes. If VALUE does not fit into NBYTES
+ return an error code. */
+static gpg_err_code_t
+octet_string_from_mpi (unsigned char **r_frame, void *space,
+ gcry_mpi_t value, size_t nbytes)
+{
+ gpg_err_code_t rc;
+ size_t nframe, noff, n;
+ unsigned char *frame;
+
+ if (!r_frame == !space)
+ return GPG_ERR_INV_ARG; /* Only one may be used. */
+
+ if (r_frame)
+ *r_frame = NULL;
+
+ rc = gcry_err_code (gcry_mpi_print (GCRYMPI_FMT_USG,
+ NULL, 0, &nframe, value));
+ if (rc)
+ return rc;
+ if (nframe > nbytes)
+ return GPG_ERR_TOO_LARGE; /* Value too long to fit into NBYTES. */
+
+ noff = (nframe < nbytes)? nbytes - nframe : 0;
+ n = nframe + noff;
+ if (space)
+ frame = space;
+ else
+ {
+ frame = mpi_is_secure (value)? gcry_malloc_secure (n) : gcry_malloc (n);
+ if (!frame)
+ {
+ rc = gpg_err_code_from_syserror ();
+ return rc;
+ }
+ }
+ if (noff)
+ memset (frame, 0, noff);
+ nframe += noff;
+ rc = gcry_err_code (gcry_mpi_print (GCRYMPI_FMT_USG,
+ frame+noff, nframe-noff, NULL, value));
+ if (rc)
+ {
+ gcry_free (frame);
+ return rc;
+ }
+
+ if (r_frame)
+ *r_frame = frame;
+ return 0;
+}
+
+
+/* Encode {VALUE,VALUELEN} for an NBITS keys using the pkcs#1 block
+ type 2 padding. On sucess the result is stored as a new MPI at
+ R_RESULT. On error the value at R_RESULT is undefined.
+
+ If {RANDOM_OVERRIDE, RANDOM_OVERRIDE_LEN} is given it is used as
+ the seed instead of using a random string for it. This feature is
+ only useful for regression tests. Note that this value may not
+ contain zero bytes.
+
+ We encode the value in this way:
+
+ 0 2 RND(n bytes) 0 VALUE
+
+ 0 is a marker we unfortunately can't encode because we return an
+ MPI which strips all leading zeroes.
+ 2 is the block type.
+ RND are non-zero random bytes.
+
+ (Note that OpenPGP includes the cipher algorithm and a checksum in
+ VALUE; the caller needs to prepare the value accordingly.)
+ */
+static gcry_err_code_t
+pkcs1_encode_for_encryption (gcry_mpi_t *r_result, unsigned int nbits,
+ const unsigned char *value, size_t valuelen,
+ const unsigned char *random_override,
+ size_t random_override_len)
+{
+ gcry_err_code_t rc = 0;
+ gcry_error_t err;
+ unsigned char *frame = NULL;
+ size_t nframe = (nbits+7) / 8;
+ int i;
+ size_t n;
+ unsigned char *p;
+
+ if (valuelen + 7 > nframe || !nframe)
+ {
+ /* Can't encode a VALUELEN value in a NFRAME bytes frame. */
+ return GPG_ERR_TOO_SHORT; /* The key is too short. */
+ }
+
+ if ( !(frame = gcry_malloc_secure (nframe)))
+ return gpg_err_code_from_syserror ();
+
+ n = 0;
+ frame[n++] = 0;
+ frame[n++] = 2; /* block type */
+ i = nframe - 3 - valuelen;
+ gcry_assert (i > 0);
+
+ if (random_override)
+ {
+ int j;
+
+ if (random_override_len != i)
+ {
+ gcry_free (frame);
+ return GPG_ERR_INV_ARG;
+ }
+ /* Check that random does not include a zero byte. */
+ for (j=0; j < random_override_len; j++)
+ if (!random_override[j])
+ {
+ gcry_free (frame);
+ return GPG_ERR_INV_ARG;
+ }
+ memcpy (frame + n, random_override, random_override_len);
+ n += random_override_len;
+ }
+ else
+ {
+ p = gcry_random_bytes_secure (i, GCRY_STRONG_RANDOM);
+ /* Replace zero bytes by new values. */
+ for (;;)
+ {
+ int j, k;
+ unsigned char *pp;
+
+ /* Count the zero bytes. */
+ for (j=k=0; j < i; j++)
+ {
+ if (!p[j])
+ k++;
+ }
+ if (!k)
+ break; /* Okay: no (more) zero bytes. */
+
+ k += k/128 + 3; /* Better get some more. */
+ pp = gcry_random_bytes_secure (k, GCRY_STRONG_RANDOM);
+ for (j=0; j < i && k; )
+ {
+ if (!p[j])
+ p[j] = pp[--k];
+ if (p[j])
+ j++;
+ }
+ gcry_free (pp);
+ }
+ memcpy (frame+n, p, i);
+ n += i;
+ gcry_free (p);
+ }
+
+ frame[n++] = 0;
+ memcpy (frame+n, value, valuelen);
+ n += valuelen;
+ gcry_assert (n == nframe);
+
+ err = gcry_mpi_scan (r_result, GCRYMPI_FMT_USG, frame, n, &nframe);
+ if (err)
+ rc = gcry_err_code (err);
+ else if (DBG_CIPHER)
+ log_mpidump ("PKCS#1 block type 2 encoded data", *r_result);
+ gcry_free (frame);
+
+ return rc;
+}
+
+
+/* Decode a plaintext in VALUE assuming pkcs#1 block type 2 padding.
+ NBITS is the size of the secret key. On success the result is
+ stored as a newly allocated buffer at R_RESULT and its valid length at
+ R_RESULTLEN. On error NULL is stored at R_RESULT. */
+static gcry_err_code_t
+pkcs1_decode_for_encryption (unsigned char **r_result, size_t *r_resultlen,
+ unsigned int nbits, gcry_mpi_t value)
+{
+ gcry_error_t err;
+ unsigned char *frame = NULL;
+ size_t nframe = (nbits+7) / 8;
+ size_t n;
+
+ *r_result = NULL;
+
+ if ( !(frame = gcry_malloc_secure (nframe)))
+ return gpg_err_code_from_syserror ();
+
+ err = gcry_mpi_print (GCRYMPI_FMT_USG, frame, nframe, &n, value);
+ if (err)
+ {
+ gcry_free (frame);
+ return gcry_err_code (err);
+ }
+
+ nframe = n; /* Set NFRAME to the actual length. */
+
+ /* FRAME = 0x00 || 0x02 || PS || 0x00 || M
+
+ pkcs#1 requires that the first byte is zero. Our MPIs usually
+ strip leading zero bytes; thus we are not able to detect them.
+ However due to the way gcry_mpi_print is implemented we may see
+ leading zero bytes nevertheless. We handle this by making the
+ first zero byte optional. */
+ if (nframe < 4)
+ {
+ gcry_free (frame);
+ return GPG_ERR_ENCODING_PROBLEM; /* Too short. */
+ }
+ n = 0;
+ if (!frame[0])
+ n++;
+ if (frame[n++] != 0x02)
+ {
+ gcry_free (frame);
+ return GPG_ERR_ENCODING_PROBLEM; /* Wrong block type. */
+ }
+
+ /* Skip the non-zero random bytes and the terminating zero byte. */
+ for (; n < nframe && frame[n] != 0x00; n++)
+ ;
+ if (n+1 >= nframe)
+ {
+ gcry_free (frame);
+ return GPG_ERR_ENCODING_PROBLEM; /* No zero byte. */
+ }
+ n++; /* Skip the zero byte. */
+
+ /* To avoid an extra allocation we reuse the frame buffer. The only
+ caller of this function will anyway free the result soon. */
+ memmove (frame, frame + n, nframe - n);
+ *r_result = frame;
+ *r_resultlen = nframe - n;
+
+ if (DBG_CIPHER)
+ log_printhex ("value extracted from PKCS#1 block type 2 encoded data:",
+ *r_result, *r_resultlen);
+
+ return 0;
+}
+
+
+/* Encode {VALUE,VALUELEN} for an NBITS keys and hash algorith ALGO
+ using the pkcs#1 block type 1 padding. On success the result is
+ stored as a new MPI at R_RESULT. On error the value at R_RESULT is
+ undefined.
+
+ We encode the value in this way:
+
+ 0 1 PAD(n bytes) 0 ASN(asnlen bytes) VALUE(valuelen bytes)
+
+ 0 is a marker we unfortunately can't encode because we return an
+ MPI which strips all leading zeroes.
+ 1 is the block type.
+ PAD consists of 0xff bytes.
+ 0 marks the end of the padding.
+ ASN is the DER encoding of the hash algorithm; along with the VALUE
+ it yields a valid DER encoding.
+
+ (Note that PGP prior to version 2.3 encoded the message digest as:
+ 0 1 MD(16 bytes) 0 PAD(n bytes) 1
+ The MD is always 16 bytes here because it's always MD5. GnuPG
+ does not not support pre-v2.3 signatures, but I'm including this
+ comment so the information is easily found if needed.)
+*/
+static gcry_err_code_t
+pkcs1_encode_for_signature (gcry_mpi_t *r_result, unsigned int nbits,
+ const unsigned char *value, size_t valuelen,
+ int algo)
+{
+ gcry_err_code_t rc = 0;
+ gcry_error_t err;
+ byte asn[100];
+ byte *frame = NULL;
+ size_t nframe = (nbits+7) / 8;
+ int i;
+ size_t n;
+ size_t asnlen, dlen;
+
+ asnlen = DIM(asn);
+ dlen = gcry_md_get_algo_dlen (algo);
+
+ if (gcry_md_algo_info (algo, GCRYCTL_GET_ASNOID, asn, &asnlen))
+ {
+ /* We don't have yet all of the above algorithms. */
+ return GPG_ERR_NOT_IMPLEMENTED;
+ }
+
+ if ( valuelen != dlen )
+ {
+ /* Hash value does not match the length of digest for
+ the given algorithm. */
+ return GPG_ERR_CONFLICT;
+ }
+
+ if ( !dlen || dlen + asnlen + 4 > nframe)
+ {
+ /* Can't encode an DLEN byte digest MD into an NFRAME byte
+ frame. */
+ return GPG_ERR_TOO_SHORT;
+ }
+
+ if ( !(frame = gcry_malloc (nframe)) )
+ return gpg_err_code_from_syserror ();
+
+ /* Assemble the pkcs#1 block type 1. */
+ n = 0;
+ frame[n++] = 0;
+ frame[n++] = 1; /* block type */
+ i = nframe - valuelen - asnlen - 3 ;
+ gcry_assert (i > 1);
+ memset (frame+n, 0xff, i );
+ n += i;
+ frame[n++] = 0;
+ memcpy (frame+n, asn, asnlen);
+ n += asnlen;
+ memcpy (frame+n, value, valuelen );
+ n += valuelen;
+ gcry_assert (n == nframe);
+
+ /* Convert it into an MPI. */
+ err = gcry_mpi_scan (r_result, GCRYMPI_FMT_USG, frame, n, &nframe);
+ if (err)
+ rc = gcry_err_code (err);
+ else if (DBG_CIPHER)
+ log_mpidump ("PKCS#1 block type 1 encoded data", *r_result);
+ gcry_free (frame);
+
+ return rc;
+}
+
+
+/* Mask generation function for OAEP. See RFC-3447 B.2.1. */
+static gcry_err_code_t
+mgf1 (unsigned char *output, size_t outlen, unsigned char *seed, size_t seedlen,
+ int algo)
+{
+ size_t dlen, nbytes, n;
+ int idx;
+ gcry_md_hd_t hd;
+ gcry_error_t err;
+
+ err = gcry_md_open (&hd, algo, 0);
+ if (err)
+ return gpg_err_code (err);
+
+ dlen = gcry_md_get_algo_dlen (algo);
+
+ /* We skip step 1 which would be assert(OUTLEN <= 2^32). The loop
+ in step 3 is merged with step 4 by concatenating no more octets
+ than what would fit into OUTPUT. The ceiling for the counter IDX
+ is implemented indirectly. */
+ nbytes = 0; /* Step 2. */
+ idx = 0;
+ while ( nbytes < outlen )
+ {
+ unsigned char c[4], *digest;
+
+ if (idx)
+ gcry_md_reset (hd);
+
+ c[0] = (idx >> 24) & 0xFF;
+ c[1] = (idx >> 16) & 0xFF;
+ c[2] = (idx >> 8) & 0xFF;
+ c[3] = idx & 0xFF;
+ idx++;
+
+ gcry_md_write (hd, seed, seedlen);
+ gcry_md_write (hd, c, 4);
+ digest = gcry_md_read (hd, 0);
+
+ n = (outlen - nbytes < dlen)? (outlen - nbytes) : dlen;
+ memcpy (output+nbytes, digest, n);
+ nbytes += n;
+ }
+
+ gcry_md_close (hd);
+ return GPG_ERR_NO_ERROR;
+}
+
+
+/* RFC-3447 (pkcs#1 v2.1) OAEP encoding. NBITS is the length of the
+ key measured in bits. ALGO is the hash function; it must be a
+ valid and usable algorithm. {VALUE,VALUELEN} is the message to
+ encrypt. {LABEL,LABELLEN} is the optional label to be associated
+ with the message, if LABEL is NULL the default is to use the empty
+ string as label. On success the encoded ciphertext is returned at
+ R_RESULT.
+
+ If {RANDOM_OVERRIDE, RANDOM_OVERRIDE_LEN} is given it is used as
+ the seed instead of using a random string for it. This feature is
+ only useful for regression tests.
+
+ Here is figure 1 from the RFC depicting the process:
+
+ +----------+---------+-------+
+ DB = | lHash | PS | M |
+ +----------+---------+-------+
+ |
+ +----------+ V
+ | seed |--> MGF ---> xor
+ +----------+ |
+ | |
+ +--+ V |
+ |00| xor <----- MGF <-----|
+ +--+ | |
+ | | |
+ V V V
+ +--+----------+----------------------------+
+ EM = |00|maskedSeed| maskedDB |
+ +--+----------+----------------------------+
+ */
+static gcry_err_code_t
+oaep_encode (gcry_mpi_t *r_result, unsigned int nbits, int algo,
+ const unsigned char *value, size_t valuelen,
+ const unsigned char *label, size_t labellen,
+ const void *random_override, size_t random_override_len)
+{
+ gcry_err_code_t rc = 0;
+ gcry_error_t err;
+ unsigned char *frame = NULL;
+ size_t nframe = (nbits+7) / 8;
+ unsigned char *p;
+ size_t hlen;
+ size_t n;
+
+ *r_result = NULL;
+
+ /* Set defaults for LABEL. */
+ if (!label || !labellen)
+ {
+ label = (const unsigned char*)"";
+ labellen = 0;
+ }
+
+ hlen = gcry_md_get_algo_dlen (algo);
+
+ /* We skip step 1a which would be to check that LABELLEN is not
+ greater than 2^61-1. See rfc-3447 7.1.1. */
+
+ /* Step 1b. Note that the obsolete rfc-2437 uses the check:
+ valuelen > nframe - 2 * hlen - 1 . */
+ if (valuelen > nframe - 2 * hlen - 2 || !nframe)
+ {
+ /* Can't encode a VALUELEN value in a NFRAME bytes frame. */
+ return GPG_ERR_TOO_SHORT; /* The key is too short. */
+ }
+
+ /* Allocate the frame. */
+ frame = gcry_calloc_secure (1, nframe);
+ if (!frame)
+ return gpg_err_code_from_syserror ();
+
+ /* Step 2a: Compute the hash of the label. We store it in the frame
+ where later the maskedDB will commence. */
+ gcry_md_hash_buffer (algo, frame + 1 + hlen, label, labellen);
+
+ /* Step 2b: Set octet string to zero. */
+ /* This has already been done while allocating FRAME. */
+
+ /* Step 2c: Create DB by concatenating lHash, PS, 0x01 and M. */
+ n = nframe - valuelen - 1;
+ frame[n] = 0x01;
+ memcpy (frame + n + 1, value, valuelen);
+
+ /* Step 3d: Generate seed. We store it where the maskedSeed will go
+ later. */
+ if (random_override)
+ {
+ if (random_override_len != hlen)
+ {
+ gcry_free (frame);
+ return GPG_ERR_INV_ARG;
+ }
+ memcpy (frame + 1, random_override, hlen);
+ }
+ else
+ gcry_randomize (frame + 1, hlen, GCRY_STRONG_RANDOM);
+
+ /* Step 2e and 2f: Create maskedDB. */
+ {
+ unsigned char *dmask;
+
+ dmask = gcry_malloc_secure (nframe - hlen - 1);
+ if (!dmask)
+ {
+ rc = gpg_err_code_from_syserror ();
+ gcry_free (frame);
+ return rc;
+ }
+ rc = mgf1 (dmask, nframe - hlen - 1, frame+1, hlen, algo);
+ if (rc)
+ {
+ gcry_free (dmask);
+ gcry_free (frame);
+ return rc;
+ }
+ for (n = 1 + hlen, p = dmask; n < nframe; n++)
+ frame[n] ^= *p++;
+ gcry_free (dmask);
+ }
+
+ /* Step 2g and 2h: Create maskedSeed. */
+ {
+ unsigned char *smask;
+
+ smask = gcry_malloc_secure (hlen);
+ if (!smask)
+ {
+ rc = gpg_err_code_from_syserror ();
+ gcry_free (frame);
+ return rc;
+ }
+ rc = mgf1 (smask, hlen, frame + 1 + hlen, nframe - hlen - 1, algo);
+ if (rc)
+ {
+ gcry_free (smask);
+ gcry_free (frame);
+ return rc;
+ }
+ for (n = 1, p = smask; n < 1 + hlen; n++)
+ frame[n] ^= *p++;
+ gcry_free (smask);
+ }
+
+ /* Step 2i: Concatenate 0x00, maskedSeed and maskedDB. */
+ /* This has already been done by using in-place operations. */
+
+ /* Convert the stuff into an MPI as expected by the caller. */
+ err = gcry_mpi_scan (r_result, GCRYMPI_FMT_USG, frame, nframe, NULL);
+ if (err)
+ rc = gcry_err_code (err);
+ else if (DBG_CIPHER)
+ log_mpidump ("OAEP encoded data", *r_result);
+ gcry_free (frame);
+
+ return rc;
+}
+
+
+/* RFC-3447 (pkcs#1 v2.1) OAEP decoding. NBITS is the length of the
+ key measured in bits. ALGO is the hash function; it must be a
+ valid and usable algorithm. VALUE is the raw decrypted message
+ {LABEL,LABELLEN} is the optional label to be associated with the
+ message, if LABEL is NULL the default is to use the empty string as
+ label. On success the plaintext is returned as a newly allocated
+ buffer at R_RESULT; its valid length is stored at R_RESULTLEN. On
+ error NULL is stored at R_RESULT. */
+static gcry_err_code_t
+oaep_decode (unsigned char **r_result, size_t *r_resultlen,
+ unsigned int nbits, int algo,
+ gcry_mpi_t value, const unsigned char *label, size_t labellen)
+{
+ gcry_err_code_t rc;
+ unsigned char *frame = NULL; /* Encoded messages (EM). */
+ unsigned char *masked_seed; /* Points into FRAME. */
+ unsigned char *masked_db; /* Points into FRAME. */
+ unsigned char *seed = NULL; /* Allocated space for the seed and DB. */
+ unsigned char *db; /* Points into SEED. */
+ unsigned char *lhash = NULL; /* Hash of the label. */
+ size_t nframe; /* Length of the ciphertext (EM). */
+ size_t hlen; /* Length of the hash digest. */
+ size_t db_len; /* Length of DB and masked_db. */
+ size_t nkey = (nbits+7)/8; /* Length of the key in bytes. */
+ int failed = 0; /* Error indicator. */
+ size_t n;
+
+ *r_result = NULL;
+
+ /* This code is implemented as described by rfc-3447 7.1.2. */
+
+ /* Set defaults for LABEL. */
+ if (!label || !labellen)
+ {
+ label = (const unsigned char*)"";
+ labellen = 0;
+ }
+
+ /* Get the length of the digest. */
+ hlen = gcry_md_get_algo_dlen (algo);
+
+ /* Hash the label right away. */
+ lhash = gcry_malloc (hlen);
+ if (!lhash)
+ return gpg_err_code_from_syserror ();
+ gcry_md_hash_buffer (algo, lhash, label, labellen);
+
+ /* Turn the MPI into an octet string. If the octet string is
+ shorter than the key we pad it to the left with zeroes. This may
+ happen due to the leading zero in OAEP frames and due to the
+ following random octets (seed^mask) which may have leading zero
+ bytes. This all is needed to cope with our leading zeroes
+ suppressing MPI implementation. The code implictly implements
+ Step 1b (bail out if NFRAME != N). */
+ rc = octet_string_from_mpi (&frame, NULL, value, nkey);
+ if (rc)
+ {
+ gcry_free (lhash);
+ return GPG_ERR_ENCODING_PROBLEM;
+ }
+ nframe = nkey;
+
+ /* Step 1c: Check that the key is long enough. */
+ if ( nframe < 2 * hlen + 2 )
+ {
+ gcry_free (frame);
+ gcry_free (lhash);
+ return GPG_ERR_ENCODING_PROBLEM;
+ }
+
+ /* Step 2 has already been done by the caller and the
+ gcry_mpi_aprint above. */
+
+ /* Allocate space for SEED and DB. */
+ seed = gcry_malloc_secure (nframe - 1);
+ if (!seed)
+ {
+ rc = gpg_err_code_from_syserror ();
+ gcry_free (frame);
+ gcry_free (lhash);
+ return rc;
+ }
+ db = seed + hlen;
+
+ /* To avoid choosen ciphertext attacks from now on we make sure to
+ run all code even in the error case; this avoids possible timing
+ attacks as described by Manger. */
+
+ /* Step 3a: Hash the label. */
+ /* This has already been done. */
+
+ /* Step 3b: Separate the encoded message. */
+ masked_seed = frame + 1;
+ masked_db = frame + 1 + hlen;
+ db_len = nframe - 1 - hlen;
+
+ /* Step 3c and 3d: seed = maskedSeed ^ mgf(maskedDB, hlen). */
+ if (mgf1 (seed, hlen, masked_db, db_len, algo))
+ failed = 1;
+ for (n = 0; n < hlen; n++)
+ seed[n] ^= masked_seed[n];
+
+ /* Step 3e and 3f: db = maskedDB ^ mgf(seed, db_len). */
+ if (mgf1 (db, db_len, seed, hlen, algo))
+ failed = 1;
+ for (n = 0; n < db_len; n++)
+ db[n] ^= masked_db[n];
+
+ /* Step 3g: Check lhash, an possible empty padding string terminated
+ by 0x01 and the first byte of EM being 0. */
+ if (memcmp (lhash, db, hlen))
+ failed = 1;
+ for (n = hlen; n < db_len; n++)
+ if (db[n] == 0x01)
+ break;
+ if (n == db_len)
+ failed = 1;
+ if (frame[0])
+ failed = 1;
+
+ gcry_free (lhash);
+ gcry_free (frame);
+ if (failed)
+ {
+ gcry_free (seed);
+ return GPG_ERR_ENCODING_PROBLEM;
+ }
+
+ /* Step 4: Output M. */
+ /* To avoid an extra allocation we reuse the seed buffer. The only
+ caller of this function will anyway free the result soon. */
+ n++;
+ memmove (seed, db + n, db_len - n);
+ *r_result = seed;
+ *r_resultlen = db_len - n;
+ seed = NULL;
+
+ if (DBG_CIPHER)
+ log_printhex ("value extracted from OAEP encoded data:",
+ *r_result, *r_resultlen);
+
+ return 0;
+}
+
+
+/* RFC-3447 (pkcs#1 v2.1) PSS encoding. Encode {VALUE,VALUELEN} for
+ an NBITS key. Note that VALUE is already the mHash from the
+ picture below. ALGO is a valid hash algorithm and SALTLEN is the
+ length of salt to be used. On success the result is stored as a
+ new MPI at R_RESULT. On error the value at R_RESULT is undefined.
+
+ If {RANDOM_OVERRIDE, RANDOM_OVERRIDE_LEN} is given it is used as
+ the salt instead of using a random string for the salt. This
+ feature is only useful for regression tests.
+
+ Here is figure 2 from the RFC (errata 595 applied) depicting the
+ process:
+
+ +-----------+
+ | M |
+ +-----------+
+ |
+ V
+ Hash
+ |
+ V
+ +--------+----------+----------+
+ M' = |Padding1| mHash | salt |
+ +--------+----------+----------+
+ |
+ +--------+----------+ V
+ DB = |Padding2| salt | Hash
+ +--------+----------+ |
+ | |
+ V | +----+
+ xor <--- MGF <---| |0xbc|
+ | | +----+
+ | | |
+ V V V
+ +-------------------+----------+----+
+ EM = | maskedDB | H |0xbc|
+ +-------------------+----------+----+
+
+ */
+static gcry_err_code_t
+pss_encode (gcry_mpi_t *r_result, unsigned int nbits, int algo,
+ const unsigned char *value, size_t valuelen, int saltlen,
+ const void *random_override, size_t random_override_len)
+{
+ gcry_err_code_t rc = 0;
+ gcry_error_t err;
+ size_t hlen; /* Length of the hash digest. */
+ unsigned char *em = NULL; /* Encoded message. */
+ size_t emlen = (nbits+7)/8; /* Length in bytes of EM. */
+ unsigned char *h; /* Points into EM. */
+ unsigned char *buf = NULL; /* Help buffer. */
+ size_t buflen; /* Length of BUF. */
+ unsigned char *mhash; /* Points into BUF. */
+ unsigned char *salt; /* Points into BUF. */
+ unsigned char *dbmask; /* Points into BUF. */
+ unsigned char *p;
+ size_t n;
+
+ /* This code is implemented as described by rfc-3447 9.1.1. */
+
+ /* Get the length of the digest. */
+ hlen = gcry_md_get_algo_dlen (algo);
+ gcry_assert (hlen); /* We expect a valid ALGO here. */
+
+ /* Allocate a help buffer and setup some pointers. */
+ buflen = 8 + hlen + saltlen + (emlen - hlen - 1);
+ buf = gcry_malloc (buflen);
+ if (!buf)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ mhash = buf + 8;
+ salt = mhash + hlen;
+ dbmask= salt + saltlen;
+
+ /* Step 2: That would be: mHash = Hash(M) but our input is already
+ mHash thus we do only a consistency check and copy to MHASH. */
+ if (valuelen != hlen)
+ {
+ rc = GPG_ERR_INV_LENGTH;
+ goto leave;
+ }
+ memcpy (mhash, value, hlen);
+
+ /* Step 3: Check length constraints. */
+ if (emlen < hlen + saltlen + 2)
+ {
+ rc = GPG_ERR_TOO_SHORT;
+ goto leave;
+ }
+
+ /* Allocate space for EM. */
+ em = gcry_malloc (emlen);
+ if (!em)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ h = em + emlen - 1 - hlen;
+
+ /* Step 4: Create a salt. */
+ if (saltlen)
+ {
+ if (random_override)
+ {
+ if (random_override_len != saltlen)
+ {
+ rc = GPG_ERR_INV_ARG;
+ goto leave;
+ }
+ memcpy (salt, random_override, saltlen);
+ }
+ else
+ gcry_randomize (salt, saltlen, GCRY_STRONG_RANDOM);
+ }
+
+ /* Step 5 and 6: M' = Hash(Padding1 || mHash || salt). */
+ memset (buf, 0, 8); /* Padding. */
+ gcry_md_hash_buffer (algo, h, buf, 8 + hlen + saltlen);
+
+ /* Step 7 and 8: DB = PS || 0x01 || salt. */
+ /* Note that we use EM to store DB and later Xor in-place. */
+ p = em + emlen - 1 - hlen - saltlen - 1;
+ memset (em, 0, p - em);
+ *p++ = 0x01;
+ memcpy (p, salt, saltlen);
+
+ /* Step 9: dbmask = MGF(H, emlen - hlen - 1). */
+ mgf1 (dbmask, emlen - hlen - 1, h, hlen, algo);
+
+ /* Step 10: maskedDB = DB ^ dbMask */
+ for (n = 0, p = dbmask; n < emlen - hlen - 1; n++, p++)
+ em[n] ^= *p;
+
+ /* Step 11: Set the leftmost bits to zero. */
+ em[0] &= 0xFF >> (8 * emlen - nbits);
+
+ /* Step 12: EM = maskedDB || H || 0xbc. */
+ em[emlen-1] = 0xbc;
+
+ /* Convert EM into an MPI. */
+ err = gcry_mpi_scan (r_result, GCRYMPI_FMT_USG, em, emlen, NULL);
+ if (err)
+ rc = gcry_err_code (err);
+ else if (DBG_CIPHER)
+ log_mpidump ("PSS encoded data", *r_result);
+
+ leave:
+ if (em)
+ {
+ wipememory (em, emlen);
+ gcry_free (em);
+ }
+ if (buf)
+ {
+ wipememory (buf, buflen);
+ gcry_free (buf);
+ }
+ return rc;
+}
+
+
+/* Verify a signature assuming PSS padding. VALUE is the hash of the
+ message (mHash) encoded as an MPI; its length must match the digest
+ length of ALGO. ENCODED is the output of the RSA public key
+ function (EM). NBITS is the size of the public key. ALGO is the
+ hash algorithm and SALTLEN is the length of the used salt. The
+ function returns 0 on success or on error code. */
+static gcry_err_code_t
+pss_verify (gcry_mpi_t value, gcry_mpi_t encoded, unsigned int nbits, int algo,
+ size_t saltlen)
+{
+ gcry_err_code_t rc = 0;
+ size_t hlen; /* Length of the hash digest. */
+ unsigned char *em = NULL; /* Encoded message. */
+ size_t emlen = (nbits+7)/8; /* Length in bytes of EM. */
+ unsigned char *salt; /* Points into EM. */
+ unsigned char *h; /* Points into EM. */
+ unsigned char *buf = NULL; /* Help buffer. */
+ size_t buflen; /* Length of BUF. */
+ unsigned char *dbmask; /* Points into BUF. */
+ unsigned char *mhash; /* Points into BUF. */
+ unsigned char *p;
+ size_t n;
+
+ /* This code is implemented as described by rfc-3447 9.1.2. */
+
+ /* Get the length of the digest. */
+ hlen = gcry_md_get_algo_dlen (algo);
+ gcry_assert (hlen); /* We expect a valid ALGO here. */
+
+ /* Allocate a help buffer and setup some pointers.
+ This buffer is used for two purposes:
+ +------------------------------+-------+
+ 1. | dbmask | mHash |
+ +------------------------------+-------+
+ emlen - hlen - 1 hlen
+
+ +----------+-------+---------+-+-------+
+ 2. | padding1 | mHash | salt | | mHash |
+ +----------+-------+---------+-+-------+
+ 8 hlen saltlen hlen
+ */
+ buflen = 8 + hlen + saltlen;
+ if (buflen < emlen - hlen - 1)
+ buflen = emlen - hlen - 1;
+ buflen += hlen;
+ buf = gcry_malloc (buflen);
+ if (!buf)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ dbmask = buf;
+ mhash = buf + buflen - hlen;
+
+ /* Step 2: That would be: mHash = Hash(M) but our input is already
+ mHash thus we only need to convert VALUE into MHASH. */
+ rc = octet_string_from_mpi (NULL, mhash, value, hlen);
+ if (rc)
+ goto leave;
+
+ /* Convert the signature into an octet string. */
+ rc = octet_string_from_mpi (&em, NULL, encoded, emlen);
+ if (rc)
+ goto leave;
+
+ /* Step 3: Check length of EM. Because we internally use MPI
+ functions we can't do this properly; EMLEN is always the length
+ of the key because octet_string_from_mpi needs to left pad the
+ result with zero to cope with the fact that our MPIs suppress all
+ leading zeroes. Thus what we test here are merely the digest and
+ salt lengths to the key. */
+ if (emlen < hlen + saltlen + 2)
+ {
+ rc = GPG_ERR_TOO_SHORT; /* For the hash and saltlen. */
+ goto leave;
+ }
+
+ /* Step 4: Check last octet. */
+ if (em[emlen - 1] != 0xbc)
+ {
+ rc = GPG_ERR_BAD_SIGNATURE;
+ goto leave;
+ }
+
+ /* Step 5: Split EM. */
+ h = em + emlen - 1 - hlen;
+
+ /* Step 6: Check the leftmost bits. */
+ if ((em[0] & ~(0xFF >> (8 * emlen - nbits))))
+ {
+ rc = GPG_ERR_BAD_SIGNATURE;
+ goto leave;
+ }
+
+ /* Step 7: dbmask = MGF(H, emlen - hlen - 1). */
+ mgf1 (dbmask, emlen - hlen - 1, h, hlen, algo);
+
+ /* Step 8: maskedDB = DB ^ dbMask. */
+ for (n = 0, p = dbmask; n < emlen - hlen - 1; n++, p++)
+ em[n] ^= *p;
+
+ /* Step 9: Set leftmost bits in DB to zero. */
+ em[0] &= 0xFF >> (8 * emlen - nbits);
+
+ /* Step 10: Check the padding of DB. */
+ for (n = 0; n < emlen - hlen - saltlen - 2 && !em[n]; n++)
+ ;
+ if (n != emlen - hlen - saltlen - 2 || em[n++] != 1)
+ {
+ rc = GPG_ERR_BAD_SIGNATURE;
+ goto leave;
+ }
+
+ /* Step 11: Extract salt from DB. */
+ salt = em + n;
+
+ /* Step 12: M' = (0x)00 00 00 00 00 00 00 00 || mHash || salt */
+ memset (buf, 0, 8);
+ memcpy (buf+8, mhash, hlen);
+ memcpy (buf+8+hlen, salt, saltlen);
+
+ /* Step 13: H' = Hash(M'). */
+ gcry_md_hash_buffer (algo, buf, buf, 8 + hlen + saltlen);
+
+ /* Step 14: Check H == H'. */
+ rc = memcmp (h, buf, hlen) ? GPG_ERR_BAD_SIGNATURE : GPG_ERR_NO_ERROR;
+
+ leave:
+ if (em)
+ {
+ wipememory (em, emlen);
+ gcry_free (em);
+ }
+ if (buf)
+ {
+ wipememory (buf, buflen);
+ gcry_free (buf);
+ }
+ return rc;
+}
+
+
+/* Callback for the pubkey algorithm code to verify PSS signatures.
+ OPAQUE is the data provided by the actual caller. The meaning of
+ TMP depends on the actual algorithm (but there is only RSA); now
+ for RSA it is the output of running the public key function on the
+ input. */
+static int
+pss_verify_cmp (void *opaque, gcry_mpi_t tmp)
+{
+ struct pk_encoding_ctx *ctx = opaque;
+ gcry_mpi_t hash = ctx->verify_arg;
+
+ return pss_verify (hash, tmp, ctx->nbits - 1, ctx->hash_algo, ctx->saltlen);
+}
+
+
+/* Internal function. */
+static gcry_err_code_t
+sexp_elements_extract (gcry_sexp_t key_sexp, const char *element_names,
+ gcry_mpi_t *elements, const char *algo_name)
+{
+ gcry_err_code_t err = 0;
+ int i, idx;
+ const char *name;
+ gcry_sexp_t list;
+
+ for (name = element_names, idx = 0; *name && !err; name++, idx++)
+ {
+ list = gcry_sexp_find_token (key_sexp, name, 1);
+ if (!list)
+ elements[idx] = NULL;
+ else
+ {
+ elements[idx] = gcry_sexp_nth_mpi (list, 1, GCRYMPI_FMT_USG);
+ gcry_sexp_release (list);
+ if (!elements[idx])
+ err = GPG_ERR_INV_OBJ;
+ }
+ }
+
+ if (!err)
+ {
+ /* Check that all elements are available. */
+ for (name = element_names, idx = 0; *name; name++, idx++)
+ if (!elements[idx])
+ break;
+ if (*name)
+ {
+ err = GPG_ERR_NO_OBJ;
+ /* Some are missing. Before bailing out we test for
+ optional parameters. */
+ if (algo_name && !strcmp (algo_name, "RSA")
+ && !strcmp (element_names, "nedpqu") )
+ {
+ /* This is RSA. Test whether we got N, E and D and that
+ the optional P, Q and U are all missing. */
+ if (elements[0] && elements[1] && elements[2]
+ && !elements[3] && !elements[4] && !elements[5])
+ err = 0;
+ }
+ }
+ }
+
+
+ if (err)
+ {
+ for (i = 0; i < idx; i++)
+ if (elements[i])
+ gcry_free (elements[i]);
+ }
+ return err;
+}
+
+
+/* Internal function used for ecc. Note, that this function makes use
+ of its intimate knowledge about the ECC parameters from ecc.c. */
+static gcry_err_code_t
+sexp_elements_extract_ecc (gcry_sexp_t key_sexp, const char *element_names,
+ gcry_mpi_t *elements, pk_extra_spec_t *extraspec)
+
+{
+ gcry_err_code_t err = 0;
+ int idx;
+ const char *name;
+ gcry_sexp_t list;
+
+ /* Clear the array for easier error cleanup. */
+ for (name = element_names, idx = 0; *name; name++, idx++)
+ elements[idx] = NULL;
+ gcry_assert (idx >= 5); /* We know that ECC has at least 5 elements
+ (params only) or 6 (full public key). */
+ if (idx == 5)
+ elements[5] = NULL; /* Extra clear for the params only case. */
+
+
+ /* Init the array with the available curve parameters. */
+ for (name = element_names, idx = 0; *name && !err; name++, idx++)
+ {
+ list = gcry_sexp_find_token (key_sexp, name, 1);
+ if (!list)
+ elements[idx] = NULL;
+ else
+ {
+ elements[idx] = gcry_sexp_nth_mpi (list, 1, GCRYMPI_FMT_USG);
+ gcry_sexp_release (list);
+ if (!elements[idx])
+ {
+ err = GPG_ERR_INV_OBJ;
+ goto leave;
+ }
+ }
+ }
+
+ /* Check whether a curve parameter has been given and then fill any
+ missing elements. */
+ list = gcry_sexp_find_token (key_sexp, "curve", 5);
+ if (list)
+ {
+ if (extraspec->get_param)
+ {
+ char *curve;
+ gcry_mpi_t params[6];
+
+ for (idx = 0; idx < DIM(params); idx++)
+ params[idx] = NULL;
+
+ curve = _gcry_sexp_nth_string (list, 1);
+ gcry_sexp_release (list);
+ if (!curve)
+ {
+ /* No curve name given (or out of core). */
+ err = GPG_ERR_INV_OBJ;
+ goto leave;
+ }
+ err = extraspec->get_param (curve, params);
+ gcry_free (curve);
+ if (err)
+ goto leave;
+
+ for (idx = 0; idx < DIM(params); idx++)
+ {
+ if (!elements[idx])
+ elements[idx] = params[idx];
+ else
+ mpi_free (params[idx]);
+ }
+ }
+ else
+ {
+ gcry_sexp_release (list);
+ err = GPG_ERR_INV_OBJ; /* "curve" given but ECC not supported. */
+ goto leave;
+ }
+ }
+
+ /* Check that all parameters are known. */
+ for (name = element_names, idx = 0; *name; name++, idx++)
+ if (!elements[idx])
+ {
+ err = GPG_ERR_NO_OBJ;
+ goto leave;
+ }
+
+ leave:
+ if (err)
+ {
+ for (name = element_names, idx = 0; *name; name++, idx++)
+ if (elements[idx])
+ gcry_free (elements[idx]);
+ }
+ return err;
+}
+
+
+
+/****************
+ * Convert a S-Exp with either a private or a public key to our
+ * internal format. Currently we do only support the following
+ * algorithms:
+ * dsa
+ * rsa
+ * openpgp-dsa
+ * openpgp-rsa
+ * openpgp-elg
+ * openpgp-elg-sig
+ * ecdsa
+ * ecdh
+ * Provide a SE with the first element be either "private-key" or
+ * or "public-key". It is followed by a list with its first element
+ * be one of the above algorithm identifiers and the remaning
+ * elements are pairs with parameter-id and value.
+ * NOTE: we look through the list to find a list beginning with
+ * "private-key" or "public-key" - the first one found is used.
+ *
+ * If OVERRIDE_ELEMS is not NULL those elems override the parameter
+ * specification taken from the module. This ise used by
+ * gcry_pk_get_curve.
+ *
+ * Returns: A pointer to an allocated array of MPIs if the return value is
+ * zero; the caller has to release this array.
+ *
+ * Example of a DSA public key:
+ * (private-key
+ * (dsa
+ * (p <mpi>)
+ * (g <mpi>)
+ * (y <mpi>)
+ * (x <mpi>)
+ * )
+ * )
+ * The <mpi> are expected to be in GCRYMPI_FMT_USG
+ */
+static gcry_err_code_t
+sexp_to_key (gcry_sexp_t sexp, int want_private, const char *override_elems,
+ gcry_mpi_t **retarray, gcry_module_t *retalgo)
+{
+ gcry_err_code_t err = 0;
+ gcry_sexp_t list, l2;
+ char *name;
+ const char *elems;
+ gcry_mpi_t *array;
+ gcry_module_t module;
+ gcry_pk_spec_t *pubkey;
+ pk_extra_spec_t *extraspec;
+ int is_ecc;
+
+ /* Check that the first element is valid. */
+ list = gcry_sexp_find_token (sexp,
+ want_private? "private-key":"public-key", 0);
+ if (!list)
+ return GPG_ERR_INV_OBJ; /* Does not contain a key object. */
+
+ l2 = gcry_sexp_cadr( list );
+ gcry_sexp_release ( list );
+ list = l2;
+ name = _gcry_sexp_nth_string (list, 0);
+ if (!name)
+ {
+ gcry_sexp_release ( list );
+ return GPG_ERR_INV_OBJ; /* Invalid structure of object. */
+ }
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = gcry_pk_lookup_name (name);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ /* Fixme: We should make sure that an ECC key is always named "ecc"
+ and not "ecdsa". "ecdsa" should be used for the signature
+ itself. We need a function to test whether an algorithm given
+ with a key is compatible with an application of the key (signing,
+ encryption). For RSA this is easy, but ECC is the first
+ algorithm which has many flavours. */
+ is_ecc = ( !strcmp (name, "ecdsa")
+ || !strcmp (name, "ecdh")
+ || !strcmp (name, "ecc") );
+ gcry_free (name);
+
+ if (!module)
+ {
+ gcry_sexp_release (list);
+ return GPG_ERR_PUBKEY_ALGO; /* Unknown algorithm. */
+ }
+ else
+ {
+ pubkey = (gcry_pk_spec_t *) module->spec;
+ extraspec = module->extraspec;
+ }
+
+ if (override_elems)
+ elems = override_elems;
+ else if (want_private)
+ elems = pubkey->elements_skey;
+ else
+ elems = pubkey->elements_pkey;
+ array = gcry_calloc (strlen (elems) + 1, sizeof (*array));
+ if (!array)
+ err = gpg_err_code_from_syserror ();
+ if (!err)
+ {
+ if (is_ecc)
+ err = sexp_elements_extract_ecc (list, elems, array, extraspec);
+ else
+ err = sexp_elements_extract (list, elems, array, pubkey->name);
+ }
+
+ gcry_sexp_release (list);
+
+ if (err)
+ {
+ gcry_free (array);
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ }
+ else
+ {
+ *retarray = array;
+ *retalgo = module;
+ }
+
+ return err;
+}
+
+
+static gcry_err_code_t
+sexp_to_sig (gcry_sexp_t sexp, gcry_mpi_t **retarray,
+ gcry_module_t *retalgo)
+{
+ gcry_err_code_t err = 0;
+ gcry_sexp_t list, l2;
+ char *name;
+ const char *elems;
+ gcry_mpi_t *array;
+ gcry_module_t module;
+ gcry_pk_spec_t *pubkey;
+
+ /* Check that the first element is valid. */
+ list = gcry_sexp_find_token( sexp, "sig-val" , 0 );
+ if (!list)
+ return GPG_ERR_INV_OBJ; /* Does not contain a signature value object. */
+
+ l2 = gcry_sexp_nth (list, 1);
+ if (!l2)
+ {
+ gcry_sexp_release (list);
+ return GPG_ERR_NO_OBJ; /* No cadr for the sig object. */
+ }
+ name = _gcry_sexp_nth_string (l2, 0);
+ if (!name)
+ {
+ gcry_sexp_release (list);
+ gcry_sexp_release (l2);
+ return GPG_ERR_INV_OBJ; /* Invalid structure of object. */
+ }
+ else if (!strcmp (name, "flags"))
+ {
+ /* Skip flags, since they are not used but here just for the
+ sake of consistent S-expressions. */
+ gcry_free (name);
+ gcry_sexp_release (l2);
+ l2 = gcry_sexp_nth (list, 2);
+ if (!l2)
+ {
+ gcry_sexp_release (list);
+ return GPG_ERR_INV_OBJ;
+ }
+ name = _gcry_sexp_nth_string (l2, 0);
+ }
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = gcry_pk_lookup_name (name);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ gcry_free (name);
+ name = NULL;
+
+ if (!module)
+ {
+ gcry_sexp_release (l2);
+ gcry_sexp_release (list);
+ return GPG_ERR_PUBKEY_ALGO; /* Unknown algorithm. */
+ }
+ else
+ pubkey = (gcry_pk_spec_t *) module->spec;
+
+ elems = pubkey->elements_sig;
+ array = gcry_calloc (strlen (elems) + 1 , sizeof *array );
+ if (!array)
+ err = gpg_err_code_from_syserror ();
+
+ if (!err)
+ err = sexp_elements_extract (list, elems, array, NULL);
+
+ gcry_sexp_release (l2);
+ gcry_sexp_release (list);
+
+ if (err)
+ {
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ gcry_free (array);
+ }
+ else
+ {
+ *retarray = array;
+ *retalgo = module;
+ }
+
+ return err;
+}
+
+static inline int
+get_hash_algo (const char *s, size_t n)
+{
+ static const struct { const char *name; int algo; } hashnames[] = {
+ { "sha1", GCRY_MD_SHA1 },
+ { "md5", GCRY_MD_MD5 },
+ { "sha256", GCRY_MD_SHA256 },
+ { "ripemd160", GCRY_MD_RMD160 },
+ { "rmd160", GCRY_MD_RMD160 },
+ { "sha384", GCRY_MD_SHA384 },
+ { "sha512", GCRY_MD_SHA512 },
+ { "sha224", GCRY_MD_SHA224 },
+ { "md2", GCRY_MD_MD2 },
+ { "md4", GCRY_MD_MD4 },
+ { "tiger", GCRY_MD_TIGER },
+ { "haval", GCRY_MD_HAVAL },
+ { NULL, 0 }
+ };
+ int algo;
+ int i;
+
+ for (i=0; hashnames[i].name; i++)
+ {
+ if ( strlen (hashnames[i].name) == n
+ && !memcmp (hashnames[i].name, s, n))
+ break;
+ }
+ if (hashnames[i].name)
+ algo = hashnames[i].algo;
+ else
+ {
+ /* In case of not listed or dynamically allocated hash
+ algorithm we fall back to this somewhat slower
+ method. Further, it also allows to use OIDs as
+ algorithm names. */
+ char *tmpname;
+
+ tmpname = gcry_malloc (n+1);
+ if (!tmpname)
+ algo = 0; /* Out of core - silently give up. */
+ else
+ {
+ memcpy (tmpname, s, n);
+ tmpname[n] = 0;
+ algo = gcry_md_map_name (tmpname);
+ gcry_free (tmpname);
+ }
+ }
+ return algo;
+}
+
+
+/****************
+ * Take sexp and return an array of MPI as used for our internal decrypt
+ * function.
+ * s_data = (enc-val
+ * [(flags [raw, pkcs1, oaep, no-blinding])]
+ * [(hash-algo <algo>)]
+ * [(label <label>)]
+ * (<algo>
+ * (<param_name1> <mpi>)
+ * ...
+ * (<param_namen> <mpi>)
+ * ))
+ * HASH-ALGO and LABEL are specific to OAEP.
+ * RET_MODERN is set to true when at least an empty flags list has been found.
+ * CTX is used to return encoding information; it may be NULL in which
+ * case raw encoding is used.
+ */
+static gcry_err_code_t
+sexp_to_enc (gcry_sexp_t sexp, gcry_mpi_t **retarray, gcry_module_t *retalgo,
+ int *ret_modern, int *flags, struct pk_encoding_ctx *ctx)
+{
+ gcry_err_code_t err = 0;
+ gcry_sexp_t list = NULL, l2 = NULL;
+ gcry_pk_spec_t *pubkey = NULL;
+ gcry_module_t module = NULL;
+ char *name = NULL;
+ size_t n;
+ int parsed_flags = 0;
+ const char *elems;
+ gcry_mpi_t *array = NULL;
+
+ *ret_modern = 0;
+
+ /* Check that the first element is valid. */
+ list = gcry_sexp_find_token (sexp, "enc-val" , 0);
+ if (!list)
+ {
+ err = GPG_ERR_INV_OBJ; /* Does not contain an encrypted value object. */
+ goto leave;
+ }
+
+ l2 = gcry_sexp_nth (list, 1);
+ if (!l2)
+ {
+ err = GPG_ERR_NO_OBJ; /* No cdr for the data object. */
+ goto leave;
+ }
+
+ /* Extract identifier of sublist. */
+ name = _gcry_sexp_nth_string (l2, 0);
+ if (!name)
+ {
+ err = GPG_ERR_INV_OBJ; /* Invalid structure of object. */
+ goto leave;
+ }
+
+ if (!strcmp (name, "flags"))
+ {
+ /* There is a flags element - process it. */
+ const char *s;
+ int i;
+
+ *ret_modern = 1;
+ for (i = gcry_sexp_length (l2) - 1; i > 0; i--)
+ {
+ s = gcry_sexp_nth_data (l2, i, &n);
+ if (! s)
+ ; /* Not a data element - ignore. */
+ else if (n == 3 && !memcmp (s, "raw", 3)
+ && ctx->encoding == PUBKEY_ENC_UNKNOWN)
+ ctx->encoding = PUBKEY_ENC_RAW;
+ else if (n == 5 && !memcmp (s, "pkcs1", 5)
+ && ctx->encoding == PUBKEY_ENC_UNKNOWN)
+ ctx->encoding = PUBKEY_ENC_PKCS1;
+ else if (n == 4 && !memcmp (s, "oaep", 4)
+ && ctx->encoding == PUBKEY_ENC_UNKNOWN)
+ ctx->encoding = PUBKEY_ENC_OAEP;
+ else if (n == 3 && !memcmp (s, "pss", 3)
+ && ctx->encoding == PUBKEY_ENC_UNKNOWN)
+ {
+ err = GPG_ERR_CONFLICT;
+ goto leave;
+ }
+ else if (n == 11 && ! memcmp (s, "no-blinding", 11))
+ parsed_flags |= PUBKEY_FLAG_NO_BLINDING;
+ else
+ {
+ err = GPG_ERR_INV_FLAG;
+ goto leave;
+ }
+ }
+ gcry_sexp_release (l2);
+
+ /* Get the OAEP parameters HASH-ALGO and LABEL, if any. */
+ if (ctx->encoding == PUBKEY_ENC_OAEP)
+ {
+ /* Get HASH-ALGO. */
+ l2 = gcry_sexp_find_token (list, "hash-algo", 0);
+ if (l2)
+ {
+ s = gcry_sexp_nth_data (l2, 1, &n);
+ if (!s)
+ err = GPG_ERR_NO_OBJ;
+ else
+ {
+ ctx->hash_algo = get_hash_algo (s, n);
+ if (!ctx->hash_algo)
+ err = GPG_ERR_DIGEST_ALGO;
+ }
+ gcry_sexp_release (l2);
+ if (err)
+ goto leave;
+ }
+
+ /* Get LABEL. */
+ l2 = gcry_sexp_find_token (list, "label", 0);
+ if (l2)
+ {
+ s = gcry_sexp_nth_data (l2, 1, &n);
+ if (!s)
+ err = GPG_ERR_NO_OBJ;
+ else if (n > 0)
+ {
+ ctx->label = gcry_malloc (n);
+ if (!ctx->label)
+ err = gpg_err_code_from_syserror ();
+ else
+ {
+ memcpy (ctx->label, s, n);
+ ctx->labellen = n;
+ }
+ }
+ gcry_sexp_release (l2);
+ if (err)
+ goto leave;
+ }
+ }
+
+ /* Get the next which has the actual data - skip HASH-ALGO and LABEL. */
+ for (i = 2; (l2 = gcry_sexp_nth (list, i)) != NULL; i++)
+ {
+ s = gcry_sexp_nth_data (l2, 0, &n);
+ if (!(n == 9 && !memcmp (s, "hash-algo", 9))
+ && !(n == 5 && !memcmp (s, "label", 5))
+ && !(n == 15 && !memcmp (s, "random-override", 15)))
+ break;
+ gcry_sexp_release (l2);
+ }
+
+ if (!l2)
+ {
+ err = GPG_ERR_NO_OBJ; /* No cdr for the data object. */
+ goto leave;
+ }
+
+ /* Extract sublist identifier. */
+ gcry_free (name);
+ name = _gcry_sexp_nth_string (l2, 0);
+ if (!name)
+ {
+ err = GPG_ERR_INV_OBJ; /* Invalid structure of object. */
+ goto leave;
+ }
+
+ gcry_sexp_release (list);
+ list = l2;
+ l2 = NULL;
+ }
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = gcry_pk_lookup_name (name);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ if (!module)
+ {
+ err = GPG_ERR_PUBKEY_ALGO; /* Unknown algorithm. */
+ goto leave;
+ }
+ pubkey = (gcry_pk_spec_t *) module->spec;
+
+ elems = pubkey->elements_enc;
+ array = gcry_calloc (strlen (elems) + 1, sizeof (*array));
+ if (!array)
+ {
+ err = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+
+ err = sexp_elements_extract (list, elems, array, NULL);
+
+ leave:
+ gcry_sexp_release (list);
+ gcry_sexp_release (l2);
+ gcry_free (name);
+
+ if (err)
+ {
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ gcry_free (array);
+ gcry_free (ctx->label);
+ ctx->label = NULL;
+ }
+ else
+ {
+ *retarray = array;
+ *retalgo = module;
+ *flags = parsed_flags;
+ }
+
+ return err;
+}
+
+/* Take the hash value and convert into an MPI, suitable for
+ passing to the low level functions. We currently support the
+ old style way of passing just a MPI and the modern interface which
+ allows to pass flags so that we can choose between raw and pkcs1
+ padding - may be more padding options later.
+
+ (<mpi>)
+ or
+ (data
+ [(flags [raw, pkcs1, oaep, pss, no-blinding])]
+ [(hash <algo> <value>)]
+ [(value <text>)]
+ [(hash-algo <algo>)]
+ [(label <label>)]
+ [(salt-length <length>)]
+ [(random-override <data>)]
+ )
+
+ Either the VALUE or the HASH element must be present for use
+ with signatures. VALUE is used for encryption.
+
+ HASH-ALGO and LABEL are specific to OAEP.
+
+ SALT-LENGTH is for PSS.
+
+ RANDOM-OVERRIDE is used to replace random nonces for regression
+ testing. */
+static gcry_err_code_t
+sexp_data_to_mpi (gcry_sexp_t input, gcry_mpi_t *ret_mpi,
+ struct pk_encoding_ctx *ctx)
+{
+ gcry_err_code_t rc = 0;
+ gcry_sexp_t ldata, lhash, lvalue;
+ int i;
+ size_t n;
+ const char *s;
+ int unknown_flag=0;
+ int parsed_flags = 0;
+
+ *ret_mpi = NULL;
+ ldata = gcry_sexp_find_token (input, "data", 0);
+ if (!ldata)
+ { /* assume old style */
+ *ret_mpi = gcry_sexp_nth_mpi (input, 0, 0);
+ return *ret_mpi ? GPG_ERR_NO_ERROR : GPG_ERR_INV_OBJ;
+ }
+
+ /* see whether there is a flags object */
+ {
+ gcry_sexp_t lflags = gcry_sexp_find_token (ldata, "flags", 0);
+ if (lflags)
+ { /* parse the flags list. */
+ for (i=gcry_sexp_length (lflags)-1; i > 0; i--)
+ {
+ s = gcry_sexp_nth_data (lflags, i, &n);
+ if (!s)
+ ; /* not a data element*/
+ else if ( n == 3 && !memcmp (s, "raw", 3)
+ && ctx->encoding == PUBKEY_ENC_UNKNOWN)
+ ctx->encoding = PUBKEY_ENC_RAW;
+ else if ( n == 5 && !memcmp (s, "pkcs1", 5)
+ && ctx->encoding == PUBKEY_ENC_UNKNOWN)
+ ctx->encoding = PUBKEY_ENC_PKCS1;
+ else if ( n == 4 && !memcmp (s, "oaep", 4)
+ && ctx->encoding == PUBKEY_ENC_UNKNOWN)
+ ctx->encoding = PUBKEY_ENC_OAEP;
+ else if ( n == 3 && !memcmp (s, "pss", 3)
+ && ctx->encoding == PUBKEY_ENC_UNKNOWN)
+ ctx->encoding = PUBKEY_ENC_PSS;
+ else if (n == 11 && ! memcmp (s, "no-blinding", 11))
+ parsed_flags |= PUBKEY_FLAG_NO_BLINDING;
+ else
+ unknown_flag = 1;
+ }
+ gcry_sexp_release (lflags);
+ }
+ }
+
+ if (ctx->encoding == PUBKEY_ENC_UNKNOWN)
+ ctx->encoding = PUBKEY_ENC_RAW; /* default to raw */
+
+ /* Get HASH or MPI */
+ lhash = gcry_sexp_find_token (ldata, "hash", 0);
+ lvalue = lhash? NULL : gcry_sexp_find_token (ldata, "value", 0);
+
+ if (!(!lhash ^ !lvalue))
+ rc = GPG_ERR_INV_OBJ; /* none or both given */
+ else if (unknown_flag)
+ rc = GPG_ERR_INV_FLAG;
+ else if (ctx->encoding == PUBKEY_ENC_RAW && lvalue)
+ {
+ *ret_mpi = gcry_sexp_nth_mpi (lvalue, 1, GCRYMPI_FMT_USG);
+ if (!*ret_mpi)
+ rc = GPG_ERR_INV_OBJ;
+ }
+ else if (ctx->encoding == PUBKEY_ENC_PKCS1 && lvalue
+ && ctx->op == PUBKEY_OP_ENCRYPT)
+ {
+ const void * value;
+ size_t valuelen;
+ gcry_sexp_t list;
+ void *random_override = NULL;
+ size_t random_override_len = 0;
+
+ if ( !(value=gcry_sexp_nth_data (lvalue, 1, &valuelen)) || !valuelen )
+ rc = GPG_ERR_INV_OBJ;
+ else
+ {
+ /* Get optional RANDOM-OVERRIDE. */
+ list = gcry_sexp_find_token (ldata, "random-override", 0);
+ if (list)
+ {
+ s = gcry_sexp_nth_data (list, 1, &n);
+ if (!s)
+ rc = GPG_ERR_NO_OBJ;
+ else if (n > 0)
+ {
+ random_override = gcry_malloc (n);
+ if (!random_override)
+ rc = gpg_err_code_from_syserror ();
+ else
+ {
+ memcpy (random_override, s, n);
+ random_override_len = n;
+ }
+ }
+ gcry_sexp_release (list);
+ if (rc)
+ goto leave;
+ }
+
+ rc = pkcs1_encode_for_encryption (ret_mpi, ctx->nbits,
+ value, valuelen,
+ random_override,
+ random_override_len);
+ gcry_free (random_override);
+ }
+ }
+ else if (ctx->encoding == PUBKEY_ENC_PKCS1 && lhash
+ && (ctx->op == PUBKEY_OP_SIGN || ctx->op == PUBKEY_OP_VERIFY))
+ {
+ if (gcry_sexp_length (lhash) != 3)
+ rc = GPG_ERR_INV_OBJ;
+ else if ( !(s=gcry_sexp_nth_data (lhash, 1, &n)) || !n )
+ rc = GPG_ERR_INV_OBJ;
+ else
+ {
+ const void * value;
+ size_t valuelen;
+
+ ctx->hash_algo = get_hash_algo (s, n);
+
+ if (!ctx->hash_algo)
+ rc = GPG_ERR_DIGEST_ALGO;
+ else if ( !(value=gcry_sexp_nth_data (lhash, 2, &valuelen))
+ || !valuelen )
+ rc = GPG_ERR_INV_OBJ;
+ else
+ rc = pkcs1_encode_for_signature (ret_mpi, ctx->nbits,
+ value, valuelen,
+ ctx->hash_algo);
+ }
+ }
+ else if (ctx->encoding == PUBKEY_ENC_OAEP && lvalue
+ && ctx->op == PUBKEY_OP_ENCRYPT)
+ {
+ const void * value;
+ size_t valuelen;
+
+ if ( !(value=gcry_sexp_nth_data (lvalue, 1, &valuelen)) || !valuelen )
+ rc = GPG_ERR_INV_OBJ;
+ else
+ {
+ gcry_sexp_t list;
+ void *random_override = NULL;
+ size_t random_override_len = 0;
+
+ /* Get HASH-ALGO. */
+ list = gcry_sexp_find_token (ldata, "hash-algo", 0);
+ if (list)
+ {
+ s = gcry_sexp_nth_data (list, 1, &n);
+ if (!s)
+ rc = GPG_ERR_NO_OBJ;
+ else
+ {
+ ctx->hash_algo = get_hash_algo (s, n);
+ if (!ctx->hash_algo)
+ rc = GPG_ERR_DIGEST_ALGO;
+ }
+ gcry_sexp_release (list);
+ if (rc)
+ goto leave;
+ }
+
+ /* Get LABEL. */
+ list = gcry_sexp_find_token (ldata, "label", 0);
+ if (list)
+ {
+ s = gcry_sexp_nth_data (list, 1, &n);
+ if (!s)
+ rc = GPG_ERR_NO_OBJ;
+ else if (n > 0)
+ {
+ ctx->label = gcry_malloc (n);
+ if (!ctx->label)
+ rc = gpg_err_code_from_syserror ();
+ else
+ {
+ memcpy (ctx->label, s, n);
+ ctx->labellen = n;
+ }
+ }
+ gcry_sexp_release (list);
+ if (rc)
+ goto leave;
+ }
+ /* Get optional RANDOM-OVERRIDE. */
+ list = gcry_sexp_find_token (ldata, "random-override", 0);
+ if (list)
+ {
+ s = gcry_sexp_nth_data (list, 1, &n);
+ if (!s)
+ rc = GPG_ERR_NO_OBJ;
+ else if (n > 0)
+ {
+ random_override = gcry_malloc (n);
+ if (!random_override)
+ rc = gpg_err_code_from_syserror ();
+ else
+ {
+ memcpy (random_override, s, n);
+ random_override_len = n;
+ }
+ }
+ gcry_sexp_release (list);
+ if (rc)
+ goto leave;
+ }
+
+ rc = oaep_encode (ret_mpi, ctx->nbits, ctx->hash_algo,
+ value, valuelen,
+ ctx->label, ctx->labellen,
+ random_override, random_override_len);
+
+ gcry_free (random_override);
+ }
+ }
+ else if (ctx->encoding == PUBKEY_ENC_PSS && lhash
+ && ctx->op == PUBKEY_OP_SIGN)
+ {
+ if (gcry_sexp_length (lhash) != 3)
+ rc = GPG_ERR_INV_OBJ;
+ else if ( !(s=gcry_sexp_nth_data (lhash, 1, &n)) || !n )
+ rc = GPG_ERR_INV_OBJ;
+ else
+ {
+ const void * value;
+ size_t valuelen;
+ void *random_override = NULL;
+ size_t random_override_len = 0;
+
+ ctx->hash_algo = get_hash_algo (s, n);
+
+ if (!ctx->hash_algo)
+ rc = GPG_ERR_DIGEST_ALGO;
+ else if ( !(value=gcry_sexp_nth_data (lhash, 2, &valuelen))
+ || !valuelen )
+ rc = GPG_ERR_INV_OBJ;
+ else
+ {
+ gcry_sexp_t list;
+
+ /* Get SALT-LENGTH. */
+ list = gcry_sexp_find_token (ldata, "salt-length", 0);
+ if (list)
+ {
+ s = gcry_sexp_nth_data (list, 1, &n);
+ if (!s)
+ {
+ rc = GPG_ERR_NO_OBJ;
+ goto leave;
+ }
+ ctx->saltlen = (unsigned int)strtoul (s, NULL, 10);
+ gcry_sexp_release (list);
+ }
+
+ /* Get optional RANDOM-OVERRIDE. */
+ list = gcry_sexp_find_token (ldata, "random-override", 0);
+ if (list)
+ {
+ s = gcry_sexp_nth_data (list, 1, &n);
+ if (!s)
+ rc = GPG_ERR_NO_OBJ;
+ else if (n > 0)
+ {
+ random_override = gcry_malloc (n);
+ if (!random_override)
+ rc = gpg_err_code_from_syserror ();
+ else
+ {
+ memcpy (random_override, s, n);
+ random_override_len = n;
+ }
+ }
+ gcry_sexp_release (list);
+ if (rc)
+ goto leave;
+ }
+
+ /* Encode the data. (NBITS-1 is due to 8.1.1, step 1.) */
+ rc = pss_encode (ret_mpi, ctx->nbits - 1, ctx->hash_algo,
+ value, valuelen, ctx->saltlen,
+ random_override, random_override_len);
+
+ gcry_free (random_override);
+ }
+ }
+ }
+ else if (ctx->encoding == PUBKEY_ENC_PSS && lhash
+ && ctx->op == PUBKEY_OP_VERIFY)
+ {
+ if (gcry_sexp_length (lhash) != 3)
+ rc = GPG_ERR_INV_OBJ;
+ else if ( !(s=gcry_sexp_nth_data (lhash, 1, &n)) || !n )
+ rc = GPG_ERR_INV_OBJ;
+ else
+ {
+ ctx->hash_algo = get_hash_algo (s, n);
+
+ if (!ctx->hash_algo)
+ rc = GPG_ERR_DIGEST_ALGO;
+ else
+ {
+ *ret_mpi = gcry_sexp_nth_mpi (lhash, 2, GCRYMPI_FMT_USG);
+ if (!*ret_mpi)
+ rc = GPG_ERR_INV_OBJ;
+ ctx->verify_cmp = pss_verify_cmp;
+ ctx->verify_arg = *ret_mpi;
+ }
+ }
+ }
+ else
+ rc = GPG_ERR_CONFLICT;
+
+ leave:
+ gcry_sexp_release (ldata);
+ gcry_sexp_release (lhash);
+ gcry_sexp_release (lvalue);
+
+ if (!rc)
+ ctx->flags = parsed_flags;
+ else
+ {
+ gcry_free (ctx->label);
+ ctx->label = NULL;
+ }
+
+ return rc;
+}
+
+static void
+init_encoding_ctx (struct pk_encoding_ctx *ctx, enum pk_operation op,
+ unsigned int nbits)
+{
+ ctx->op = op;
+ ctx->nbits = nbits;
+ ctx->encoding = PUBKEY_ENC_UNKNOWN;
+ ctx->flags = 0;
+ ctx->hash_algo = GCRY_MD_SHA1;
+ ctx->label = NULL;
+ ctx->labellen = 0;
+ ctx->saltlen = 20;
+ ctx->verify_cmp = NULL;
+ ctx->verify_arg = NULL;
+}
+
+
+/*
+ Do a PK encrypt operation
+
+ Caller has to provide a public key as the SEXP pkey and data as a
+ SEXP with just one MPI in it. Alternatively S_DATA might be a
+ complex S-Expression, similar to the one used for signature
+ verification. This provides a flag which allows to handle PKCS#1
+ block type 2 padding. The function returns a sexp which may be
+ passed to to pk_decrypt.
+
+ Returns: 0 or an errorcode.
+
+ s_data = See comment for sexp_data_to_mpi
+ s_pkey = <key-as-defined-in-sexp_to_key>
+ r_ciph = (enc-val
+ (<algo>
+ (<param_name1> <mpi>)
+ ...
+ (<param_namen> <mpi>)
+ ))
+
+*/
+gcry_error_t
+gcry_pk_encrypt (gcry_sexp_t *r_ciph, gcry_sexp_t s_data, gcry_sexp_t s_pkey)
+{
+ gcry_mpi_t *pkey = NULL, data = NULL, *ciph = NULL;
+ const char *algo_name, *algo_elems;
+ struct pk_encoding_ctx ctx;
+ gcry_err_code_t rc;
+ gcry_pk_spec_t *pubkey = NULL;
+ gcry_module_t module = NULL;
+
+ *r_ciph = NULL;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ /* Get the key. */
+ rc = sexp_to_key (s_pkey, 0, NULL, &pkey, &module);
+ if (rc)
+ goto leave;
+
+ gcry_assert (module);
+ pubkey = (gcry_pk_spec_t *) module->spec;
+
+ /* If aliases for the algorithm name exists, take the first one
+ instead of the regular name to adhere to SPKI conventions. We
+ assume that the first alias name is the lowercase version of the
+ regular one. This change is required for compatibility with
+ 1.1.12 generated S-expressions. */
+ algo_name = pubkey->aliases? *pubkey->aliases : NULL;
+ if (!algo_name || !*algo_name)
+ algo_name = pubkey->name;
+
+ algo_elems = pubkey->elements_enc;
+
+ /* Get the stuff we want to encrypt. */
+ init_encoding_ctx (&ctx, PUBKEY_OP_ENCRYPT, gcry_pk_get_nbits (s_pkey));
+ rc = sexp_data_to_mpi (s_data, &data, &ctx);
+ if (rc)
+ goto leave;
+
+ /* Now we can encrypt DATA to CIPH. */
+ ciph = gcry_calloc (strlen (algo_elems) + 1, sizeof (*ciph));
+ if (!ciph)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ rc = pubkey_encrypt (module->mod_id, ciph, data, pkey, ctx.flags);
+ mpi_free (data);
+ data = NULL;
+ if (rc)
+ goto leave;
+
+ /* We did it. Now build the return list */
+ if (ctx.encoding == PUBKEY_ENC_OAEP
+ || ctx.encoding == PUBKEY_ENC_PKCS1)
+ {
+ /* We need to make sure to return the correct length to avoid
+ problems with missing leading zeroes. We know that this
+ encoding does only make sense with RSA thus we don't need to
+ build the S-expression on the fly. */
+ unsigned char *em;
+ size_t emlen = (ctx.nbits+7)/8;
+
+ rc = octet_string_from_mpi (&em, NULL, ciph[0], emlen);
+ if (rc)
+ goto leave;
+ rc = gcry_err_code (gcry_sexp_build (r_ciph, NULL,
+ "(enc-val(%s(a%b)))",
+ algo_name, (int)emlen, em));
+ gcry_free (em);
+ if (rc)
+ goto leave;
+ }
+ else
+ {
+ char *string, *p;
+ int i;
+ size_t nelem = strlen (algo_elems);
+ size_t needed = 19 + strlen (algo_name) + (nelem * 5);
+ void **arg_list;
+
+ /* Build the string. */
+ string = p = gcry_malloc (needed);
+ if (!string)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ p = stpcpy ( p, "(enc-val(" );
+ p = stpcpy ( p, algo_name );
+ for (i=0; algo_elems[i]; i++ )
+ {
+ *p++ = '(';
+ *p++ = algo_elems[i];
+ p = stpcpy ( p, "%m)" );
+ }
+ strcpy ( p, "))" );
+
+ /* And now the ugly part: We don't have a function to pass an
+ * array to a format string, so we have to do it this way :-(. */
+ /* FIXME: There is now such a format specifier, so we can
+ change the code to be more clear. */
+ arg_list = calloc (nelem, sizeof *arg_list);
+ if (!arg_list)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+
+ for (i = 0; i < nelem; i++)
+ arg_list[i] = ciph + i;
+
+ rc = gcry_sexp_build_array (r_ciph, NULL, string, arg_list);
+ free (arg_list);
+ if (rc)
+ BUG ();
+ gcry_free (string);
+ }
+
+ leave:
+ if (pkey)
+ {
+ release_mpi_array (pkey);
+ gcry_free (pkey);
+ }
+
+ if (ciph)
+ {
+ release_mpi_array (ciph);
+ gcry_free (ciph);
+ }
+
+ if (module)
+ {
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ }
+
+ gcry_free (ctx.label);
+
+ return gcry_error (rc);
+}
+
+/*
+ Do a PK decrypt operation
+
+ Caller has to provide a secret key as the SEXP skey and data in a
+ format as created by gcry_pk_encrypt. For historic reasons the
+ function returns simply an MPI as an S-expression part; this is
+ deprecated and the new method should be used which returns a real
+ S-expressionl this is selected by adding at least an empty flags
+ list to S_DATA.
+
+ Returns: 0 or an errorcode.
+
+ s_data = (enc-val
+ [(flags [raw, pkcs1, oaep])]
+ (<algo>
+ (<param_name1> <mpi>)
+ ...
+ (<param_namen> <mpi>)
+ ))
+ s_skey = <key-as-defined-in-sexp_to_key>
+ r_plain= Either an incomplete S-expression without the parentheses
+ or if the flags list is used (even if empty) a real S-expression:
+ (value PLAIN). In raw mode (or no flags given) the returned value
+ is to be interpreted as a signed MPI, thus it may have an extra
+ leading zero octet even if not included in the original data.
+ With pkcs1 or oaep decoding enabled the returned value is a
+ verbatim octet string.
+ */
+gcry_error_t
+gcry_pk_decrypt (gcry_sexp_t *r_plain, gcry_sexp_t s_data, gcry_sexp_t s_skey)
+{
+ gcry_mpi_t *skey = NULL, *data = NULL, plain = NULL;
+ unsigned char *unpad = NULL;
+ size_t unpadlen = 0;
+ int modern, flags;
+ struct pk_encoding_ctx ctx;
+ gcry_err_code_t rc;
+ gcry_module_t module_enc = NULL, module_key = NULL;
+
+ *r_plain = NULL;
+ ctx.label = NULL;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ rc = sexp_to_key (s_skey, 1, NULL, &skey, &module_key);
+ if (rc)
+ goto leave;
+
+ init_encoding_ctx (&ctx, PUBKEY_OP_DECRYPT, gcry_pk_get_nbits (s_skey));
+ rc = sexp_to_enc (s_data, &data, &module_enc, &modern, &flags, &ctx);
+ if (rc)
+ goto leave;
+
+ if (module_key->mod_id != module_enc->mod_id)
+ {
+ rc = GPG_ERR_CONFLICT; /* Key algo does not match data algo. */
+ goto leave;
+ }
+
+ rc = pubkey_decrypt (module_key->mod_id, &plain, data, skey, flags);
+ if (rc)
+ goto leave;
+
+ /* Do un-padding if necessary. */
+ switch (ctx.encoding)
+ {
+ case PUBKEY_ENC_PKCS1:
+ rc = pkcs1_decode_for_encryption (&unpad, &unpadlen,
+ gcry_pk_get_nbits (s_skey), plain);
+ mpi_free (plain);
+ plain = NULL;
+ if (!rc)
+ rc = gcry_err_code (gcry_sexp_build (r_plain, NULL, "(value %b)",
+ (int)unpadlen, unpad));
+ break;
+
+ case PUBKEY_ENC_OAEP:
+ rc = oaep_decode (&unpad, &unpadlen,
+ gcry_pk_get_nbits (s_skey), ctx.hash_algo,
+ plain, ctx.label, ctx.labellen);
+ mpi_free (plain);
+ plain = NULL;
+ if (!rc)
+ rc = gcry_err_code (gcry_sexp_build (r_plain, NULL, "(value %b)",
+ (int)unpadlen, unpad));
+ break;
+
+ default:
+ /* Raw format. For backward compatibility we need to assume a
+ signed mpi by using the sexp format string "%m". */
+ rc = gcry_err_code (gcry_sexp_build
+ (r_plain, NULL, modern? "(value %m)" : "%m", plain));
+ break;
+ }
+
+ leave:
+ gcry_free (unpad);
+
+ if (skey)
+ {
+ release_mpi_array (skey);
+ gcry_free (skey);
+ }
+
+ mpi_free (plain);
+
+ if (data)
+ {
+ release_mpi_array (data);
+ gcry_free (data);
+ }
+
+ if (module_key || module_enc)
+ {
+ ath_mutex_lock (&pubkeys_registered_lock);
+ if (module_key)
+ _gcry_module_release (module_key);
+ if (module_enc)
+ _gcry_module_release (module_enc);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ }
+
+ gcry_free (ctx.label);
+
+ return gcry_error (rc);
+}
+
+
+
+/*
+ Create a signature.
+
+ Caller has to provide a secret key as the SEXP skey and data
+ expressed as a SEXP list hash with only one element which should
+ instantly be available as a MPI. Alternatively the structure given
+ below may be used for S_HASH, it provides the abiliy to pass flags
+ to the operation; the flags defined by now are "pkcs1" which does
+ PKCS#1 block type 1 style padding and "pss" for PSS encoding.
+
+ Returns: 0 or an errorcode.
+ In case of 0 the function returns a new SEXP with the
+ signature value; the structure of this signature depends on the
+ other arguments but is always suitable to be passed to
+ gcry_pk_verify
+
+ s_hash = See comment for sexp_data_to_mpi
+
+ s_skey = <key-as-defined-in-sexp_to_key>
+ r_sig = (sig-val
+ (<algo>
+ (<param_name1> <mpi>)
+ ...
+ (<param_namen> <mpi>))
+ [(hash algo)])
+
+ Note that (hash algo) in R_SIG is not used.
+*/
+gcry_error_t
+gcry_pk_sign (gcry_sexp_t *r_sig, gcry_sexp_t s_hash, gcry_sexp_t s_skey)
+{
+ gcry_mpi_t *skey = NULL, hash = NULL, *result = NULL;
+ gcry_pk_spec_t *pubkey = NULL;
+ gcry_module_t module = NULL;
+ const char *algo_name, *algo_elems;
+ struct pk_encoding_ctx ctx;
+ int i;
+ gcry_err_code_t rc;
+
+ *r_sig = NULL;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ rc = sexp_to_key (s_skey, 1, NULL, &skey, &module);
+ if (rc)
+ goto leave;
+
+ gcry_assert (module);
+ pubkey = (gcry_pk_spec_t *) module->spec;
+ algo_name = pubkey->aliases? *pubkey->aliases : NULL;
+ if (!algo_name || !*algo_name)
+ algo_name = pubkey->name;
+
+ algo_elems = pubkey->elements_sig;
+
+ /* Get the stuff we want to sign. Note that pk_get_nbits does also
+ work on a private key. */
+ init_encoding_ctx (&ctx, PUBKEY_OP_SIGN, gcry_pk_get_nbits (s_skey));
+ rc = sexp_data_to_mpi (s_hash, &hash, &ctx);
+ if (rc)
+ goto leave;
+
+ result = gcry_calloc (strlen (algo_elems) + 1, sizeof (*result));
+ if (!result)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ rc = pubkey_sign (module->mod_id, result, hash, skey);
+ if (rc)
+ goto leave;
+
+ if (ctx.encoding == PUBKEY_ENC_PSS
+ || ctx.encoding == PUBKEY_ENC_PKCS1)
+ {
+ /* We need to make sure to return the correct length to avoid
+ problems with missing leading zeroes. We know that this
+ encoding does only make sense with RSA thus we don't need to
+ build the S-expression on the fly. */
+ unsigned char *em;
+ size_t emlen = (ctx.nbits+7)/8;
+
+ rc = octet_string_from_mpi (&em, NULL, result[0], emlen);
+ if (rc)
+ goto leave;
+ rc = gcry_err_code (gcry_sexp_build (r_sig, NULL,
+ "(sig-val(%s(s%b)))",
+ algo_name, (int)emlen, em));
+ gcry_free (em);
+ if (rc)
+ goto leave;
+ }
+ else
+ {
+ /* General purpose output encoding. Do it on the fly. */
+ char *string, *p;
+ size_t nelem, needed = strlen (algo_name) + 20;
+ void **arg_list;
+
+ nelem = strlen (algo_elems);
+
+ /* Count elements, so that we can allocate enough space. */
+ needed += 10 * nelem;
+
+ /* Build the string. */
+ string = p = gcry_malloc (needed);
+ if (!string)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ p = stpcpy (p, "(sig-val(");
+ p = stpcpy (p, algo_name);
+ for (i = 0; algo_elems[i]; i++)
+ {
+ *p++ = '(';
+ *p++ = algo_elems[i];
+ p = stpcpy (p, "%M)");
+ }
+ strcpy (p, "))");
+
+ arg_list = calloc (nelem, sizeof *arg_list);
+ if (!arg_list)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+
+ for (i = 0; i < nelem; i++)
+ arg_list[i] = result + i;
+
+ rc = gcry_sexp_build_array (r_sig, NULL, string, arg_list);
+ free (arg_list);
+ if (rc)
+ BUG ();
+ gcry_free (string);
+ }
+
+ leave:
+ if (skey)
+ {
+ release_mpi_array (skey);
+ gcry_free (skey);
+ }
+
+ if (hash)
+ mpi_free (hash);
+
+ if (result)
+ {
+ release_mpi_array (result);
+ gcry_free (result);
+ }
+
+ return gcry_error (rc);
+}
+
+
+/*
+ Verify a signature.
+
+ Caller has to supply the public key pkey, the signature sig and his
+ hashvalue data. Public key has to be a standard public key given
+ as an S-Exp, sig is a S-Exp as returned from gcry_pk_sign and data
+ must be an S-Exp like the one in sign too. */
+gcry_error_t
+gcry_pk_verify (gcry_sexp_t s_sig, gcry_sexp_t s_hash, gcry_sexp_t s_pkey)
+{
+ gcry_module_t module_key = NULL, module_sig = NULL;
+ gcry_mpi_t *pkey = NULL, hash = NULL, *sig = NULL;
+ struct pk_encoding_ctx ctx;
+ gcry_err_code_t rc;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ rc = sexp_to_key (s_pkey, 0, NULL, &pkey, &module_key);
+ if (rc)
+ goto leave;
+
+ rc = sexp_to_sig (s_sig, &sig, &module_sig);
+ if (rc)
+ goto leave;
+
+ /* Fixme: Check that the algorithm of S_SIG is compatible to the one
+ of S_PKEY. */
+
+ if (module_key->mod_id != module_sig->mod_id)
+ {
+ rc = GPG_ERR_CONFLICT;
+ goto leave;
+ }
+
+ /* Get the stuff we want to verify. */
+ init_encoding_ctx (&ctx, PUBKEY_OP_VERIFY, gcry_pk_get_nbits (s_pkey));
+ rc = sexp_data_to_mpi (s_hash, &hash, &ctx);
+ if (rc)
+ goto leave;
+
+ rc = pubkey_verify (module_key->mod_id, hash, sig, pkey,
+ ctx.verify_cmp, &ctx);
+
+ leave:
+ if (pkey)
+ {
+ release_mpi_array (pkey);
+ gcry_free (pkey);
+ }
+ if (sig)
+ {
+ release_mpi_array (sig);
+ gcry_free (sig);
+ }
+ if (hash)
+ mpi_free (hash);
+
+ if (module_key || module_sig)
+ {
+ ath_mutex_lock (&pubkeys_registered_lock);
+ if (module_key)
+ _gcry_module_release (module_key);
+ if (module_sig)
+ _gcry_module_release (module_sig);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ }
+
+ return gcry_error (rc);
+}
+
+
+/*
+ Test a key.
+
+ This may be used either for a public or a secret key to see whether
+ the internal structure is okay.
+
+ Returns: 0 or an errorcode.
+
+ s_key = <key-as-defined-in-sexp_to_key> */
+gcry_error_t
+gcry_pk_testkey (gcry_sexp_t s_key)
+{
+ gcry_module_t module = NULL;
+ gcry_mpi_t *key = NULL;
+ gcry_err_code_t rc;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ /* Note we currently support only secret key checking. */
+ rc = sexp_to_key (s_key, 1, NULL, &key, &module);
+ if (! rc)
+ {
+ rc = pubkey_check_secret_key (module->mod_id, key);
+ release_mpi_array (key);
+ gcry_free (key);
+ }
+ return gcry_error (rc);
+}
+
+
+/*
+ Create a public key pair and return it in r_key.
+ How the key is created depends on s_parms:
+ (genkey
+ (algo
+ (parameter_name_1 ....)
+ ....
+ (parameter_name_n ....)
+ ))
+ The key is returned in a format depending on the
+ algorithm. Both, private and secret keys are returned
+ and optionally some additional informatin.
+ For elgamal we return this structure:
+ (key-data
+ (public-key
+ (elg
+ (p <mpi>)
+ (g <mpi>)
+ (y <mpi>)
+ )
+ )
+ (private-key
+ (elg
+ (p <mpi>)
+ (g <mpi>)
+ (y <mpi>)
+ (x <mpi>)
+ )
+ )
+ (misc-key-info
+ (pm1-factors n1 n2 ... nn)
+ ))
+ */
+gcry_error_t
+gcry_pk_genkey (gcry_sexp_t *r_key, gcry_sexp_t s_parms)
+{
+ gcry_pk_spec_t *pubkey = NULL;
+ gcry_module_t module = NULL;
+ gcry_sexp_t list = NULL;
+ gcry_sexp_t l2 = NULL;
+ gcry_sexp_t l3 = NULL;
+ char *name = NULL;
+ size_t n;
+ gcry_err_code_t rc = GPG_ERR_NO_ERROR;
+ int i, j;
+ const char *algo_name = NULL;
+ int algo;
+ const char *sec_elems = NULL, *pub_elems = NULL;
+ gcry_mpi_t skey[12];
+ gcry_mpi_t *factors = NULL;
+ gcry_sexp_t extrainfo = NULL;
+ unsigned int nbits = 0;
+ unsigned long use_e = 0;
+
+ skey[0] = NULL;
+ *r_key = NULL;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ list = gcry_sexp_find_token (s_parms, "genkey", 0);
+ if (!list)
+ {
+ rc = GPG_ERR_INV_OBJ; /* Does not contain genkey data. */
+ goto leave;
+ }
+
+ l2 = gcry_sexp_cadr (list);
+ gcry_sexp_release (list);
+ list = l2;
+ l2 = NULL;
+ if (! list)
+ {
+ rc = GPG_ERR_NO_OBJ; /* No cdr for the genkey. */
+ goto leave;
+ }
+
+ name = _gcry_sexp_nth_string (list, 0);
+ if (!name)
+ {
+ rc = GPG_ERR_INV_OBJ; /* Algo string missing. */
+ goto leave;
+ }
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = gcry_pk_lookup_name (name);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ gcry_free (name);
+ name = NULL;
+ if (!module)
+ {
+ rc = GPG_ERR_PUBKEY_ALGO; /* Unknown algorithm. */
+ goto leave;
+ }
+
+ pubkey = (gcry_pk_spec_t *) module->spec;
+ algo = module->mod_id;
+ algo_name = pubkey->aliases? *pubkey->aliases : NULL;
+ if (!algo_name || !*algo_name)
+ algo_name = pubkey->name;
+ pub_elems = pubkey->elements_pkey;
+ sec_elems = pubkey->elements_skey;
+ if (strlen (sec_elems) >= DIM(skey))
+ BUG ();
+
+ /* Handle the optional rsa-use-e element. Actually this belong into
+ the algorithm module but we have this parameter in the public
+ module API, so we need to parse it right here. */
+ l2 = gcry_sexp_find_token (list, "rsa-use-e", 0);
+ if (l2)
+ {
+ char buf[50];
+ const char *s;
+
+ s = gcry_sexp_nth_data (l2, 1, &n);
+ if ( !s || n >= DIM (buf) - 1 )
+ {
+ rc = GPG_ERR_INV_OBJ; /* No value or value too large. */
+ goto leave;
+ }
+ memcpy (buf, s, n);
+ buf[n] = 0;
+ use_e = strtoul (buf, NULL, 0);
+ gcry_sexp_release (l2);
+ l2 = NULL;
+ }
+ else
+ use_e = 65537; /* Not given, use the value generated by old versions. */
+
+
+ /* Get the "nbits" parameter. */
+ l2 = gcry_sexp_find_token (list, "nbits", 0);
+ if (l2)
+ {
+ char buf[50];
+ const char *s;
+
+ s = gcry_sexp_nth_data (l2, 1, &n);
+ if (!s || n >= DIM (buf) - 1 )
+ {
+ rc = GPG_ERR_INV_OBJ; /* NBITS given without a cdr. */
+ goto leave;
+ }
+ memcpy (buf, s, n);
+ buf[n] = 0;
+ nbits = (unsigned int)strtoul (buf, NULL, 0);
+ gcry_sexp_release (l2); l2 = NULL;
+ }
+ else
+ nbits = 0;
+
+ /* Pass control to the algorithm module. */
+ rc = pubkey_generate (module->mod_id, nbits, use_e, list, skey,
+ &factors, &extrainfo);
+ gcry_sexp_release (list); list = NULL;
+ if (rc)
+ goto leave;
+
+ /* Key generation succeeded: Build an S-expression. */
+ {
+ char *string, *p;
+ size_t nelem=0, nelem_cp = 0, needed=0;
+ gcry_mpi_t mpis[30];
+ int percent_s_idx = -1;
+
+ /* Estimate size of format string. */
+ nelem = strlen (pub_elems) + strlen (sec_elems);
+ if (factors)
+ {
+ for (i = 0; factors[i]; i++)
+ nelem++;
+ }
+ nelem_cp = nelem;
+
+ needed += nelem * 10;
+ /* (+5 is for EXTRAINFO ("%S")). */
+ needed += 2 * strlen (algo_name) + 300 + 5;
+ if (nelem > DIM (mpis))
+ BUG ();
+
+ /* Build the string. */
+ nelem = 0;
+ string = p = gcry_malloc (needed);
+ if (!string)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ p = stpcpy (p, "(key-data");
+ p = stpcpy (p, "(public-key(");
+ p = stpcpy (p, algo_name);
+ for(i = 0; pub_elems[i]; i++)
+ {
+ *p++ = '(';
+ *p++ = pub_elems[i];
+ p = stpcpy (p, "%m)");
+ mpis[nelem++] = skey[i];
+ }
+ if (extrainfo && (algo == GCRY_PK_ECDSA || algo == GCRY_PK_ECDH))
+ {
+ /* Very ugly hack to insert the used curve parameter into the
+ list of public key parameters. */
+ percent_s_idx = nelem;
+ p = stpcpy (p, "%S");
+ }
+ p = stpcpy (p, "))");
+ p = stpcpy (p, "(private-key(");
+ p = stpcpy (p, algo_name);
+ for (i = 0; sec_elems[i]; i++)
+ {
+ *p++ = '(';
+ *p++ = sec_elems[i];
+ p = stpcpy (p, "%m)");
+ mpis[nelem++] = skey[i];
+ }
+ p = stpcpy (p, "))");
+
+ /* Hack to make release_mpi_array() work. */
+ skey[i] = NULL;
+
+ if (extrainfo && percent_s_idx == -1)
+ {
+ /* If we have extrainfo we should not have any factors. */
+ p = stpcpy (p, "%S");
+ }
+ else if (factors && factors[0])
+ {
+ p = stpcpy (p, "(misc-key-info(pm1-factors");
+ for(i = 0; factors[i]; i++)
+ {
+ p = stpcpy (p, "%m");
+ mpis[nelem++] = factors[i];
+ }
+ p = stpcpy (p, "))");
+ }
+ strcpy (p, ")");
+ gcry_assert (p - string < needed);
+
+ while (nelem < DIM (mpis))
+ mpis[nelem++] = NULL;
+
+ {
+ int elem_n = strlen (pub_elems) + strlen (sec_elems);
+ void **arg_list;
+
+ /* Allocate one extra for EXTRAINFO ("%S"). */
+ arg_list = gcry_calloc (nelem_cp+1, sizeof *arg_list);
+ if (!arg_list)
+ {
+ rc = gpg_err_code_from_syserror ();
+ goto leave;
+ }
+ for (i = j = 0; i < elem_n; i++)
+ {
+ if (i == percent_s_idx)
+ arg_list[j++] = &extrainfo;
+ arg_list[j++] = mpis + i;
+ }
+ if (extrainfo && percent_s_idx == -1)
+ arg_list[j] = &extrainfo;
+ else if (factors && factors[0])
+ {
+ for (; i < nelem_cp; i++)
+ arg_list[j++] = factors + i - elem_n;
+ }
+ rc = gcry_sexp_build_array (r_key, NULL, string, arg_list);
+ gcry_free (arg_list);
+ if (rc)
+ BUG ();
+ gcry_assert (DIM (mpis) == 30); /* Reminder to make sure that
+ the array gets increased if
+ new parameters are added. */
+ }
+ gcry_free (string);
+ }
+
+ leave:
+ gcry_free (name);
+ gcry_sexp_release (extrainfo);
+ release_mpi_array (skey);
+ /* Don't free SKEY itself, it is an stack allocated array. */
+
+ if (factors)
+ {
+ release_mpi_array ( factors );
+ gcry_free (factors);
+ }
+
+ gcry_sexp_release (l3);
+ gcry_sexp_release (l2);
+ gcry_sexp_release (list);
+
+ if (module)
+ {
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ }
+
+ return gcry_error (rc);
+}
+
+
+/*
+ Get the number of nbits from the public key.
+
+ Hmmm: Should we have really this function or is it better to have a
+ more general function to retrieve different properties of the key? */
+unsigned int
+gcry_pk_get_nbits (gcry_sexp_t key)
+{
+ gcry_module_t module = NULL;
+ gcry_pk_spec_t *pubkey;
+ gcry_mpi_t *keyarr = NULL;
+ unsigned int nbits = 0;
+ gcry_err_code_t rc;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ rc = sexp_to_key (key, 0, NULL, &keyarr, &module);
+ if (rc == GPG_ERR_INV_OBJ)
+ rc = sexp_to_key (key, 1, NULL, &keyarr, &module);
+ if (rc)
+ return 0; /* Error - 0 is a suitable indication for that. */
+
+ pubkey = (gcry_pk_spec_t *) module->spec;
+ nbits = (*pubkey->get_nbits) (module->mod_id, keyarr);
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ release_mpi_array (keyarr);
+ gcry_free (keyarr);
+
+ return nbits;
+}
+
+
+/* Return the so called KEYGRIP which is the SHA-1 hash of the public
+ key parameters expressed in a way depending on the algorithm.
+
+ ARRAY must either be 20 bytes long or NULL; in the latter case a
+ newly allocated array of that size is returned, otherwise ARRAY or
+ NULL is returned to indicate an error which is most likely an
+ unknown algorithm. The function accepts public or secret keys. */
+unsigned char *
+gcry_pk_get_keygrip (gcry_sexp_t key, unsigned char *array)
+{
+ gcry_sexp_t list = NULL, l2 = NULL;
+ gcry_pk_spec_t *pubkey = NULL;
+ gcry_module_t module = NULL;
+ pk_extra_spec_t *extraspec;
+ const char *s;
+ char *name = NULL;
+ int idx;
+ const char *elems;
+ gcry_md_hd_t md = NULL;
+ int okay = 0;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ /* Check that the first element is valid. */
+ list = gcry_sexp_find_token (key, "public-key", 0);
+ if (! list)
+ list = gcry_sexp_find_token (key, "private-key", 0);
+ if (! list)
+ list = gcry_sexp_find_token (key, "protected-private-key", 0);
+ if (! list)
+ list = gcry_sexp_find_token (key, "shadowed-private-key", 0);
+ if (! list)
+ return NULL; /* No public- or private-key object. */
+
+ l2 = gcry_sexp_cadr (list);
+ gcry_sexp_release (list);
+ list = l2;
+ l2 = NULL;
+
+ name = _gcry_sexp_nth_string (list, 0);
+ if (!name)
+ goto fail; /* Invalid structure of object. */
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = gcry_pk_lookup_name (name);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ if (!module)
+ goto fail; /* Unknown algorithm. */
+
+ pubkey = (gcry_pk_spec_t *) module->spec;
+ extraspec = module->extraspec;
+
+ elems = pubkey->elements_grip;
+ if (!elems)
+ goto fail; /* No grip parameter. */
+
+ if (gcry_md_open (&md, GCRY_MD_SHA1, 0))
+ goto fail;
+
+ if (extraspec && extraspec->comp_keygrip)
+ {
+ /* Module specific method to compute a keygrip. */
+ if (extraspec->comp_keygrip (md, list))
+ goto fail;
+ }
+ else
+ {
+ /* Generic method to compute a keygrip. */
+ for (idx = 0, s = elems; *s; s++, idx++)
+ {
+ const char *data;
+ size_t datalen;
+ char buf[30];
+
+ l2 = gcry_sexp_find_token (list, s, 1);
+ if (! l2)
+ goto fail;
+ data = gcry_sexp_nth_data (l2, 1, &datalen);
+ if (! data)
+ goto fail;
+
+ snprintf (buf, sizeof buf, "(1:%c%u:", *s, (unsigned int)datalen);
+ gcry_md_write (md, buf, strlen (buf));
+ gcry_md_write (md, data, datalen);
+ gcry_sexp_release (l2);
+ l2 = NULL;
+ gcry_md_write (md, ")", 1);
+ }
+ }
+
+ if (!array)
+ {
+ array = gcry_malloc (20);
+ if (! array)
+ goto fail;
+ }
+
+ memcpy (array, gcry_md_read (md, GCRY_MD_SHA1), 20);
+ okay = 1;
+
+ fail:
+ gcry_free (name);
+ gcry_sexp_release (l2);
+ gcry_md_close (md);
+ gcry_sexp_release (list);
+ return okay? array : NULL;
+}
+
+
+
+const char *
+gcry_pk_get_curve (gcry_sexp_t key, int iterator, unsigned int *r_nbits)
+{
+ gcry_mpi_t *pkey = NULL;
+ gcry_sexp_t list = NULL;
+ gcry_sexp_t l2;
+ gcry_module_t module = NULL;
+ pk_extra_spec_t *extraspec;
+ char *name = NULL;
+ const char *result = NULL;
+ int want_private = 1;
+
+ if (r_nbits)
+ *r_nbits = 0;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ if (key)
+ {
+ iterator = 0;
+
+ /* Check that the first element is valid. */
+ list = gcry_sexp_find_token (key, "public-key", 0);
+ if (list)
+ want_private = 0;
+ if (!list)
+ list = gcry_sexp_find_token (key, "private-key", 0);
+ if (!list)
+ return NULL; /* No public- or private-key object. */
+
+ l2 = gcry_sexp_cadr (list);
+ gcry_sexp_release (list);
+ list = l2;
+ l2 = NULL;
+
+ name = _gcry_sexp_nth_string (list, 0);
+ if (!name)
+ goto leave; /* Invalid structure of object. */
+
+ /* Get the key. We pass the names of the parameters for
+ override_elems; this allows to call this function without the
+ actual public key parameter. */
+ if (sexp_to_key (key, want_private, "pabgn", &pkey, &module))
+ goto leave;
+ }
+ else
+ {
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = gcry_pk_lookup_name ("ecc");
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ if (!module)
+ goto leave;
+ }
+
+ extraspec = module->extraspec;
+ if (!extraspec || !extraspec->get_curve)
+ goto leave;
+
+ result = extraspec->get_curve (pkey, iterator, r_nbits);
+
+ leave:
+ if (pkey)
+ {
+ release_mpi_array (pkey);
+ gcry_free (pkey);
+ }
+ if (module)
+ {
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ }
+ gcry_free (name);
+ gcry_sexp_release (list);
+ return result;
+}
+
+
+
+gcry_sexp_t
+gcry_pk_get_param (int algo, const char *name)
+{
+ gcry_module_t module = NULL;
+ pk_extra_spec_t *extraspec;
+ gcry_sexp_t result = NULL;
+
+ if (algo != GCRY_PK_ECDSA && algo != GCRY_PK_ECDH)
+ return NULL;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = gcry_pk_lookup_name ("ecc");
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ if (module)
+ {
+ extraspec = module->extraspec;
+ if (extraspec && extraspec->get_curve_param)
+ result = extraspec->get_curve_param (name);
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ }
+ return result;
+}
+
+
+
+gcry_error_t
+gcry_pk_ctl (int cmd, void *buffer, size_t buflen)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ switch (cmd)
+ {
+ case GCRYCTL_DISABLE_ALGO:
+ /* This one expects a buffer pointing to an integer with the
+ algo number. */
+ if ((! buffer) || (buflen != sizeof (int)))
+ err = GPG_ERR_INV_ARG;
+ else
+ disable_pubkey_algo (*((int *) buffer));
+ break;
+
+ default:
+ err = GPG_ERR_INV_OP;
+ }
+
+ return gcry_error (err);
+}
+
+
+/* Return information about the given algorithm
+
+ WHAT selects the kind of information returned:
+
+ GCRYCTL_TEST_ALGO:
+ Returns 0 when the specified algorithm is available for use.
+ Buffer must be NULL, nbytes may have the address of a variable
+ with the required usage of the algorithm. It may be 0 for don't
+ care or a combination of the GCRY_PK_USAGE_xxx flags;
+
+ GCRYCTL_GET_ALGO_USAGE:
+ Return the usage flags for the given algo. An invalid algo
+ returns 0. Disabled algos are ignored here because we
+ only want to know whether the algo is at all capable of
+ the usage.
+
+ Note: Because this function is in most cases used to return an
+ integer value, we can make it easier for the caller to just look at
+ the return value. The caller will in all cases consult the value
+ and thereby detecting whether a error occurred or not (i.e. while
+ checking the block size) */
+gcry_error_t
+gcry_pk_algo_info (int algorithm, int what, void *buffer, size_t *nbytes)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ switch (what)
+ {
+ case GCRYCTL_TEST_ALGO:
+ {
+ int use = nbytes ? *nbytes : 0;
+ if (buffer)
+ err = GPG_ERR_INV_ARG;
+ else if (check_pubkey_algo (algorithm, use))
+ err = GPG_ERR_PUBKEY_ALGO;
+ break;
+ }
+
+ case GCRYCTL_GET_ALGO_USAGE:
+ {
+ gcry_module_t pubkey;
+ int use = 0;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (pubkey)
+ {
+ use = ((gcry_pk_spec_t *) pubkey->spec)->use;
+ _gcry_module_release (pubkey);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ /* FIXME? */
+ *nbytes = use;
+
+ break;
+ }
+
+ case GCRYCTL_GET_ALGO_NPKEY:
+ {
+ /* FIXME? */
+ int npkey = pubkey_get_npkey (algorithm);
+ *nbytes = npkey;
+ break;
+ }
+ case GCRYCTL_GET_ALGO_NSKEY:
+ {
+ /* FIXME? */
+ int nskey = pubkey_get_nskey (algorithm);
+ *nbytes = nskey;
+ break;
+ }
+ case GCRYCTL_GET_ALGO_NSIGN:
+ {
+ /* FIXME? */
+ int nsign = pubkey_get_nsig (algorithm);
+ *nbytes = nsign;
+ break;
+ }
+ case GCRYCTL_GET_ALGO_NENCR:
+ {
+ /* FIXME? */
+ int nencr = pubkey_get_nenc (algorithm);
+ *nbytes = nencr;
+ break;
+ }
+
+ default:
+ err = GPG_ERR_INV_OP;
+ }
+
+ return gcry_error (err);
+}
+
+
+/* Explicitly initialize this module. */
+gcry_err_code_t
+_gcry_pk_init (void)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ return err;
+}
+
+
+gcry_err_code_t
+_gcry_pk_module_lookup (int algorithm, gcry_module_t *module)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ gcry_module_t pubkey;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (pubkey)
+ *module = pubkey;
+ else
+ err = GPG_ERR_PUBKEY_ALGO;
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return err;
+}
+
+
+void
+_gcry_pk_module_release (gcry_module_t module)
+{
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+}
+
+/* Get a list consisting of the IDs of the loaded pubkey modules. If
+ LIST is zero, write the number of loaded pubkey modules to
+ LIST_LENGTH and return. If LIST is non-zero, the first
+ *LIST_LENGTH algorithm IDs are stored in LIST, which must be of
+ according size. In case there are less pubkey modules than
+ *LIST_LENGTH, *LIST_LENGTH is updated to the correct number. */
+gcry_error_t
+gcry_pk_list (int *list, int *list_length)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ err = _gcry_module_list (pubkeys_registered, list, list_length);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return err;
+}
+
+
+/* Run the selftests for pubkey algorithm ALGO with optional reporting
+ function REPORT. */
+gpg_error_t
+_gcry_pk_selftest (int algo, int extended, selftest_report_func_t report)
+{
+ gcry_module_t module = NULL;
+ pk_extra_spec_t *extraspec = NULL;
+ gcry_err_code_t ec = 0;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = _gcry_module_lookup_id (pubkeys_registered, algo);
+ if (module && !(module->flags & FLAG_MODULE_DISABLED))
+ extraspec = module->extraspec;
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ if (extraspec && extraspec->selftest)
+ ec = extraspec->selftest (algo, extended, report);
+ else
+ {
+ ec = GPG_ERR_PUBKEY_ALGO;
+ if (report)
+ report ("pubkey", algo, "module",
+ module && !(module->flags & FLAG_MODULE_DISABLED)?
+ "no selftest available" :
+ module? "algorithm disabled" : "algorithm not found");
+ }
+
+ if (module)
+ {
+ ath_mutex_lock (&pubkeys_registered_lock);
+ _gcry_module_release (module);
+ ath_mutex_unlock (&pubkeys_registered_lock);
+ }
+ return gpg_error (ec);
+}
+
+
+/* This function is only used by ac.c! */
+gcry_err_code_t
+_gcry_pk_get_elements (int algo, char **enc, char **sig)
+{
+ gcry_module_t pubkey;
+ gcry_pk_spec_t *spec;
+ gcry_err_code_t err;
+ char *enc_cp;
+ char *sig_cp;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ enc_cp = NULL;
+ sig_cp = NULL;
+ spec = NULL;
+
+ pubkey = _gcry_module_lookup_id (pubkeys_registered, algo);
+ if (! pubkey)
+ {
+ err = GPG_ERR_INTERNAL;
+ goto out;
+ }
+ spec = pubkey->spec;
+
+ if (enc)
+ {
+ enc_cp = strdup (spec->elements_enc);
+ if (! enc_cp)
+ {
+ err = gpg_err_code_from_syserror ();
+ goto out;
+ }
+ }
+
+ if (sig)
+ {
+ sig_cp = strdup (spec->elements_sig);
+ if (! sig_cp)
+ {
+ err = gpg_err_code_from_syserror ();
+ goto out;
+ }
+ }
+
+ if (enc)
+ *enc = enc_cp;
+ if (sig)
+ *sig = sig_cp;
+ err = 0;
+
+ out:
+
+ _gcry_module_release (pubkey);
+ if (err)
+ {
+ free (enc_cp);
+ free (sig_cp);
+ }
+
+ return err;
+}
diff --git a/grub-core/lib/libgcrypt/cipher/rfc2268.c b/grub-core/lib/libgcrypt/cipher/rfc2268.c
new file mode 100644
index 0000000..1c9c8d4
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/rfc2268.c
@@ -0,0 +1,344 @@
+/* rfc2268.c - The cipher described in rfc2268; aka Ron's Cipher 2.
+ * Copyright (C) 2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/* This implementation was written by Nikos Mavroyanopoulos for GNUTLS
+ * as a Libgcrypt module (gnutls/lib/x509/rc2.c) and later adapted for
+ * direct use by Libgcrypt by Werner Koch. This implementation is
+ * only useful for pkcs#12 decryption.
+ *
+ * The implementation here is based on Peter Gutmann's RRC.2 paper.
+ */
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "g10lib.h"
+#include "types.h"
+#include "cipher.h"
+
+#define RFC2268_BLOCKSIZE 8
+
+typedef struct
+{
+ u16 S[64];
+} RFC2268_context;
+
+static const unsigned char rfc2268_sbox[] = {
+ 217, 120, 249, 196, 25, 221, 181, 237,
+ 40, 233, 253, 121, 74, 160, 216, 157,
+ 198, 126, 55, 131, 43, 118, 83, 142,
+ 98, 76, 100, 136, 68, 139, 251, 162,
+ 23, 154, 89, 245, 135, 179, 79, 19,
+ 97, 69, 109, 141, 9, 129, 125, 50,
+ 189, 143, 64, 235, 134, 183, 123, 11,
+ 240, 149, 33, 34, 92, 107, 78, 130,
+ 84, 214, 101, 147, 206, 96, 178, 28,
+ 115, 86, 192, 20, 167, 140, 241, 220,
+ 18, 117, 202, 31, 59, 190, 228, 209,
+ 66, 61, 212, 48, 163, 60, 182, 38,
+ 111, 191, 14, 218, 70, 105, 7, 87,
+ 39, 242, 29, 155, 188, 148, 67, 3,
+ 248, 17, 199, 246, 144, 239, 62, 231,
+ 6, 195, 213, 47, 200, 102, 30, 215,
+ 8, 232, 234, 222, 128, 82, 238, 247,
+ 132, 170, 114, 172, 53, 77, 106, 42,
+ 150, 26, 210, 113, 90, 21, 73, 116,
+ 75, 159, 208, 94, 4, 24, 164, 236,
+ 194, 224, 65, 110, 15, 81, 203, 204,
+ 36, 145, 175, 80, 161, 244, 112, 57,
+ 153, 124, 58, 133, 35, 184, 180, 122,
+ 252, 2, 54, 91, 37, 85, 151, 49,
+ 45, 93, 250, 152, 227, 138, 146, 174,
+ 5, 223, 41, 16, 103, 108, 186, 201,
+ 211, 0, 230, 207, 225, 158, 168, 44,
+ 99, 22, 1, 63, 88, 226, 137, 169,
+ 13, 56, 52, 27, 171, 51, 255, 176,
+ 187, 72, 12, 95, 185, 177, 205, 46,
+ 197, 243, 219, 71, 229, 165, 156, 119,
+ 10, 166, 32, 104, 254, 127, 193, 173
+};
+
+#define rotl16(x,n) (((x) << ((u16)(n))) | ((x) >> (16 - (u16)(n))))
+#define rotr16(x,n) (((x) >> ((u16)(n))) | ((x) << (16 - (u16)(n))))
+
+static const char *selftest (void);
+
+
+static void
+do_encrypt (void *context, unsigned char *outbuf, const unsigned char *inbuf)
+{
+ RFC2268_context *ctx = context;
+ register int i, j;
+ u16 word0 = 0, word1 = 0, word2 = 0, word3 = 0;
+
+ word0 = (word0 << 8) | inbuf[1];
+ word0 = (word0 << 8) | inbuf[0];
+ word1 = (word1 << 8) | inbuf[3];
+ word1 = (word1 << 8) | inbuf[2];
+ word2 = (word2 << 8) | inbuf[5];
+ word2 = (word2 << 8) | inbuf[4];
+ word3 = (word3 << 8) | inbuf[7];
+ word3 = (word3 << 8) | inbuf[6];
+
+ for (i = 0; i < 16; i++)
+ {
+ j = i * 4;
+ /* For some reason I cannot combine those steps. */
+ word0 += (word1 & ~word3) + (word2 & word3) + ctx->S[j];
+ word0 = rotl16(word0, 1);
+
+ word1 += (word2 & ~word0) + (word3 & word0) + ctx->S[j + 1];
+ word1 = rotl16(word1, 2);
+
+ word2 += (word3 & ~word1) + (word0 & word1) + ctx->S[j + 2];
+ word2 = rotl16(word2, 3);
+
+ word3 += (word0 & ~word2) + (word1 & word2) + ctx->S[j + 3];
+ word3 = rotl16(word3, 5);
+
+ if (i == 4 || i == 10)
+ {
+ word0 += ctx->S[word3 & 63];
+ word1 += ctx->S[word0 & 63];
+ word2 += ctx->S[word1 & 63];
+ word3 += ctx->S[word2 & 63];
+ }
+
+ }
+
+ outbuf[0] = word0 & 255;
+ outbuf[1] = word0 >> 8;
+ outbuf[2] = word1 & 255;
+ outbuf[3] = word1 >> 8;
+ outbuf[4] = word2 & 255;
+ outbuf[5] = word2 >> 8;
+ outbuf[6] = word3 & 255;
+ outbuf[7] = word3 >> 8;
+}
+
+static void
+do_decrypt (void *context, unsigned char *outbuf, const unsigned char *inbuf)
+{
+ RFC2268_context *ctx = context;
+ register int i, j;
+ u16 word0 = 0, word1 = 0, word2 = 0, word3 = 0;
+
+ word0 = (word0 << 8) | inbuf[1];
+ word0 = (word0 << 8) | inbuf[0];
+ word1 = (word1 << 8) | inbuf[3];
+ word1 = (word1 << 8) | inbuf[2];
+ word2 = (word2 << 8) | inbuf[5];
+ word2 = (word2 << 8) | inbuf[4];
+ word3 = (word3 << 8) | inbuf[7];
+ word3 = (word3 << 8) | inbuf[6];
+
+ for (i = 15; i >= 0; i--)
+ {
+ j = i * 4;
+
+ word3 = rotr16(word3, 5);
+ word3 -= (word0 & ~word2) + (word1 & word2) + ctx->S[j + 3];
+
+ word2 = rotr16(word2, 3);
+ word2 -= (word3 & ~word1) + (word0 & word1) + ctx->S[j + 2];
+
+ word1 = rotr16(word1, 2);
+ word1 -= (word2 & ~word0) + (word3 & word0) + ctx->S[j + 1];
+
+ word0 = rotr16(word0, 1);
+ word0 -= (word1 & ~word3) + (word2 & word3) + ctx->S[j];
+
+ if (i == 5 || i == 11)
+ {
+ word3 = word3 - ctx->S[word2 & 63];
+ word2 = word2 - ctx->S[word1 & 63];
+ word1 = word1 - ctx->S[word0 & 63];
+ word0 = word0 - ctx->S[word3 & 63];
+ }
+
+ }
+
+ outbuf[0] = word0 & 255;
+ outbuf[1] = word0 >> 8;
+ outbuf[2] = word1 & 255;
+ outbuf[3] = word1 >> 8;
+ outbuf[4] = word2 & 255;
+ outbuf[5] = word2 >> 8;
+ outbuf[6] = word3 & 255;
+ outbuf[7] = word3 >> 8;
+}
+
+
+static gpg_err_code_t
+setkey_core (void *context, const unsigned char *key, unsigned int keylen, int with_phase2)
+{
+ static int initialized;
+ static const char *selftest_failed;
+ RFC2268_context *ctx = context;
+ unsigned int i;
+ unsigned char *S, x;
+ int len;
+ int bits = keylen * 8;
+
+ if (!initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+ if (selftest_failed)
+ log_error ("RFC2268 selftest failed (%s).\n", selftest_failed);
+ }
+ if (selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ if (keylen < 40 / 8) /* We want at least 40 bits. */
+ return GPG_ERR_INV_KEYLEN;
+
+ S = (unsigned char *) ctx->S;
+
+ for (i = 0; i < keylen; i++)
+ S[i] = key[i];
+
+ for (i = keylen; i < 128; i++)
+ S[i] = rfc2268_sbox[(S[i - keylen] + S[i - 1]) & 255];
+
+ S[0] = rfc2268_sbox[S[0]];
+
+ /* Phase 2 - reduce effective key size to "bits". This was not
+ * discussed in Gutmann's paper. I've copied that from the public
+ * domain code posted in sci.crypt. */
+ if (with_phase2)
+ {
+ len = (bits + 7) >> 3;
+ i = 128 - len;
+ x = rfc2268_sbox[S[i] & (255 >> (7 & -bits))];
+ S[i] = x;
+
+ while (i--)
+ {
+ x = rfc2268_sbox[x ^ S[i + len]];
+ S[i] = x;
+ }
+ }
+
+ /* Make the expanded key, endian independent. */
+ for (i = 0; i < 64; i++)
+ ctx->S[i] = ( (u16) S[i * 2] | (((u16) S[i * 2 + 1]) << 8));
+
+ return 0;
+}
+
+static gpg_err_code_t
+do_setkey (void *context, const unsigned char *key, unsigned int keylen)
+{
+ return setkey_core (context, key, keylen, 1);
+}
+
+static const char *
+selftest (void)
+{
+ RFC2268_context ctx;
+ unsigned char scratch[16];
+
+ /* Test vectors from Peter Gutmann's paper. */
+ static unsigned char key_1[] =
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+ static unsigned char plaintext_1[] =
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ static const unsigned char ciphertext_1[] =
+ { 0x1C, 0x19, 0x8A, 0x83, 0x8D, 0xF0, 0x28, 0xB7 };
+
+ static unsigned char key_2[] =
+ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
+ };
+ static unsigned char plaintext_2[] =
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ static unsigned char ciphertext_2[] =
+ { 0x50, 0xDC, 0x01, 0x62, 0xBD, 0x75, 0x7F, 0x31 };
+
+ /* This one was checked against libmcrypt's RFC2268. */
+ static unsigned char key_3[] =
+ { 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+ static unsigned char plaintext_3[] =
+ { 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ static unsigned char ciphertext_3[] =
+ { 0x8f, 0xd1, 0x03, 0x89, 0x33, 0x6b, 0xf9, 0x5e };
+
+
+ /* First test. */
+ setkey_core (&ctx, key_1, sizeof(key_1), 0);
+ do_encrypt (&ctx, scratch, plaintext_1);
+
+ if (memcmp (scratch, ciphertext_1, sizeof(ciphertext_1)))
+ return "RFC2268 encryption test 1 failed.";
+
+ setkey_core (&ctx, key_1, sizeof(key_1), 0);
+ do_decrypt (&ctx, scratch, scratch);
+ if (memcmp (scratch, plaintext_1, sizeof(plaintext_1)))
+ return "RFC2268 decryption test 1 failed.";
+
+ /* Second test. */
+ setkey_core (&ctx, key_2, sizeof(key_2), 0);
+ do_encrypt (&ctx, scratch, plaintext_2);
+ if (memcmp (scratch, ciphertext_2, sizeof(ciphertext_2)))
+ return "RFC2268 encryption test 2 failed.";
+
+ setkey_core (&ctx, key_2, sizeof(key_2), 0);
+ do_decrypt (&ctx, scratch, scratch);
+ if (memcmp (scratch, plaintext_2, sizeof(plaintext_2)))
+ return "RFC2268 decryption test 2 failed.";
+
+ /* Third test. */
+ setkey_core(&ctx, key_3, sizeof(key_3), 0);
+ do_encrypt(&ctx, scratch, plaintext_3);
+
+ if (memcmp(scratch, ciphertext_3, sizeof(ciphertext_3)))
+ return "RFC2268 encryption test 3 failed.";
+
+ setkey_core (&ctx, key_3, sizeof(key_3), 0);
+ do_decrypt (&ctx, scratch, scratch);
+ if (memcmp(scratch, plaintext_3, sizeof(plaintext_3)))
+ return "RFC2268 decryption test 3 failed.";
+
+ return NULL;
+}
+
+
+
+static gcry_cipher_oid_spec_t oids_rfc2268_40[] =
+ {
+ /*{ "1.2.840.113549.3.2", GCRY_CIPHER_MODE_CBC },*/
+ /* pbeWithSHAAnd40BitRC2_CBC */
+ { "1.2.840.113549.1.12.1.6", GCRY_CIPHER_MODE_CBC },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_40 = {
+ "RFC2268_40", NULL, oids_rfc2268_40,
+ RFC2268_BLOCKSIZE, 40, sizeof(RFC2268_context),
+ do_setkey, do_encrypt, do_decrypt
+};
diff --git a/grub-core/lib/libgcrypt/cipher/rijndael-tables.h b/grub-core/lib/libgcrypt/cipher/rijndael-tables.h
new file mode 100644
index 0000000..b6a5b15
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/rijndael-tables.h
@@ -0,0 +1,1686 @@
+/* rijndael-tables.h - Rijndael (AES) for GnuPG,
+ * Copyright (C) 2000, 2001, 2002, 2003, 2007,
+ * 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* To keep the actual implementation at a readable size we use this
+ include file to define the tables. */
+
+static const unsigned char S[256] =
+ {
+ 99, 124, 119, 123, 242, 107, 111, 197,
+ 48, 1, 103, 43, 254, 215, 171, 118,
+ 202, 130, 201, 125, 250, 89, 71, 240,
+ 173, 212, 162, 175, 156, 164, 114, 192,
+ 183, 253, 147, 38, 54, 63, 247, 204,
+ 52, 165, 229, 241, 113, 216, 49, 21,
+ 4, 199, 35, 195, 24, 150, 5, 154,
+ 7, 18, 128, 226, 235, 39, 178, 117,
+ 9, 131, 44, 26, 27, 110, 90, 160,
+ 82, 59, 214, 179, 41, 227, 47, 132,
+ 83, 209, 0, 237, 32, 252, 177, 91,
+ 106, 203, 190, 57, 74, 76, 88, 207,
+ 208, 239, 170, 251, 67, 77, 51, 133,
+ 69, 249, 2, 127, 80, 60, 159, 168,
+ 81, 163, 64, 143, 146, 157, 56, 245,
+ 188, 182, 218, 33, 16, 255, 243, 210,
+ 205, 12, 19, 236, 95, 151, 68, 23,
+ 196, 167, 126, 61, 100, 93, 25, 115,
+ 96, 129, 79, 220, 34, 42, 144, 136,
+ 70, 238, 184, 20, 222, 94, 11, 219,
+ 224, 50, 58, 10, 73, 6, 36, 92,
+ 194, 211, 172, 98, 145, 149, 228, 121,
+ 231, 200, 55, 109, 141, 213, 78, 169,
+ 108, 86, 244, 234, 101, 122, 174, 8,
+ 186, 120, 37, 46, 28, 166, 180, 198,
+ 232, 221, 116, 31, 75, 189, 139, 138,
+ 112, 62, 181, 102, 72, 3, 246, 14,
+ 97, 53, 87, 185, 134, 193, 29, 158,
+ 225, 248, 152, 17, 105, 217, 142, 148,
+ 155, 30, 135, 233, 206, 85, 40, 223,
+ 140, 161, 137, 13, 191, 230, 66, 104,
+ 65, 153, 45, 15, 176, 84, 187, 22
+ };
+
+
+static const unsigned char T1[256][4] =
+ {
+ { 0xc6,0x63,0x63,0xa5 }, { 0xf8,0x7c,0x7c,0x84 },
+ { 0xee,0x77,0x77,0x99 }, { 0xf6,0x7b,0x7b,0x8d },
+ { 0xff,0xf2,0xf2,0x0d }, { 0xd6,0x6b,0x6b,0xbd },
+ { 0xde,0x6f,0x6f,0xb1 }, { 0x91,0xc5,0xc5,0x54 },
+ { 0x60,0x30,0x30,0x50 }, { 0x02,0x01,0x01,0x03 },
+ { 0xce,0x67,0x67,0xa9 }, { 0x56,0x2b,0x2b,0x7d },
+ { 0xe7,0xfe,0xfe,0x19 }, { 0xb5,0xd7,0xd7,0x62 },
+ { 0x4d,0xab,0xab,0xe6 }, { 0xec,0x76,0x76,0x9a },
+ { 0x8f,0xca,0xca,0x45 }, { 0x1f,0x82,0x82,0x9d },
+ { 0x89,0xc9,0xc9,0x40 }, { 0xfa,0x7d,0x7d,0x87 },
+ { 0xef,0xfa,0xfa,0x15 }, { 0xb2,0x59,0x59,0xeb },
+ { 0x8e,0x47,0x47,0xc9 }, { 0xfb,0xf0,0xf0,0x0b },
+ { 0x41,0xad,0xad,0xec }, { 0xb3,0xd4,0xd4,0x67 },
+ { 0x5f,0xa2,0xa2,0xfd }, { 0x45,0xaf,0xaf,0xea },
+ { 0x23,0x9c,0x9c,0xbf }, { 0x53,0xa4,0xa4,0xf7 },
+ { 0xe4,0x72,0x72,0x96 }, { 0x9b,0xc0,0xc0,0x5b },
+ { 0x75,0xb7,0xb7,0xc2 }, { 0xe1,0xfd,0xfd,0x1c },
+ { 0x3d,0x93,0x93,0xae }, { 0x4c,0x26,0x26,0x6a },
+ { 0x6c,0x36,0x36,0x5a }, { 0x7e,0x3f,0x3f,0x41 },
+ { 0xf5,0xf7,0xf7,0x02 }, { 0x83,0xcc,0xcc,0x4f },
+ { 0x68,0x34,0x34,0x5c }, { 0x51,0xa5,0xa5,0xf4 },
+ { 0xd1,0xe5,0xe5,0x34 }, { 0xf9,0xf1,0xf1,0x08 },
+ { 0xe2,0x71,0x71,0x93 }, { 0xab,0xd8,0xd8,0x73 },
+ { 0x62,0x31,0x31,0x53 }, { 0x2a,0x15,0x15,0x3f },
+ { 0x08,0x04,0x04,0x0c }, { 0x95,0xc7,0xc7,0x52 },
+ { 0x46,0x23,0x23,0x65 }, { 0x9d,0xc3,0xc3,0x5e },
+ { 0x30,0x18,0x18,0x28 }, { 0x37,0x96,0x96,0xa1 },
+ { 0x0a,0x05,0x05,0x0f }, { 0x2f,0x9a,0x9a,0xb5 },
+ { 0x0e,0x07,0x07,0x09 }, { 0x24,0x12,0x12,0x36 },
+ { 0x1b,0x80,0x80,0x9b }, { 0xdf,0xe2,0xe2,0x3d },
+ { 0xcd,0xeb,0xeb,0x26 }, { 0x4e,0x27,0x27,0x69 },
+ { 0x7f,0xb2,0xb2,0xcd }, { 0xea,0x75,0x75,0x9f },
+ { 0x12,0x09,0x09,0x1b }, { 0x1d,0x83,0x83,0x9e },
+ { 0x58,0x2c,0x2c,0x74 }, { 0x34,0x1a,0x1a,0x2e },
+ { 0x36,0x1b,0x1b,0x2d }, { 0xdc,0x6e,0x6e,0xb2 },
+ { 0xb4,0x5a,0x5a,0xee }, { 0x5b,0xa0,0xa0,0xfb },
+ { 0xa4,0x52,0x52,0xf6 }, { 0x76,0x3b,0x3b,0x4d },
+ { 0xb7,0xd6,0xd6,0x61 }, { 0x7d,0xb3,0xb3,0xce },
+ { 0x52,0x29,0x29,0x7b }, { 0xdd,0xe3,0xe3,0x3e },
+ { 0x5e,0x2f,0x2f,0x71 }, { 0x13,0x84,0x84,0x97 },
+ { 0xa6,0x53,0x53,0xf5 }, { 0xb9,0xd1,0xd1,0x68 },
+ { 0x00,0x00,0x00,0x00 }, { 0xc1,0xed,0xed,0x2c },
+ { 0x40,0x20,0x20,0x60 }, { 0xe3,0xfc,0xfc,0x1f },
+ { 0x79,0xb1,0xb1,0xc8 }, { 0xb6,0x5b,0x5b,0xed },
+ { 0xd4,0x6a,0x6a,0xbe }, { 0x8d,0xcb,0xcb,0x46 },
+ { 0x67,0xbe,0xbe,0xd9 }, { 0x72,0x39,0x39,0x4b },
+ { 0x94,0x4a,0x4a,0xde }, { 0x98,0x4c,0x4c,0xd4 },
+ { 0xb0,0x58,0x58,0xe8 }, { 0x85,0xcf,0xcf,0x4a },
+ { 0xbb,0xd0,0xd0,0x6b }, { 0xc5,0xef,0xef,0x2a },
+ { 0x4f,0xaa,0xaa,0xe5 }, { 0xed,0xfb,0xfb,0x16 },
+ { 0x86,0x43,0x43,0xc5 }, { 0x9a,0x4d,0x4d,0xd7 },
+ { 0x66,0x33,0x33,0x55 }, { 0x11,0x85,0x85,0x94 },
+ { 0x8a,0x45,0x45,0xcf }, { 0xe9,0xf9,0xf9,0x10 },
+ { 0x04,0x02,0x02,0x06 }, { 0xfe,0x7f,0x7f,0x81 },
+ { 0xa0,0x50,0x50,0xf0 }, { 0x78,0x3c,0x3c,0x44 },
+ { 0x25,0x9f,0x9f,0xba }, { 0x4b,0xa8,0xa8,0xe3 },
+ { 0xa2,0x51,0x51,0xf3 }, { 0x5d,0xa3,0xa3,0xfe },
+ { 0x80,0x40,0x40,0xc0 }, { 0x05,0x8f,0x8f,0x8a },
+ { 0x3f,0x92,0x92,0xad }, { 0x21,0x9d,0x9d,0xbc },
+ { 0x70,0x38,0x38,0x48 }, { 0xf1,0xf5,0xf5,0x04 },
+ { 0x63,0xbc,0xbc,0xdf }, { 0x77,0xb6,0xb6,0xc1 },
+ { 0xaf,0xda,0xda,0x75 }, { 0x42,0x21,0x21,0x63 },
+ { 0x20,0x10,0x10,0x30 }, { 0xe5,0xff,0xff,0x1a },
+ { 0xfd,0xf3,0xf3,0x0e }, { 0xbf,0xd2,0xd2,0x6d },
+ { 0x81,0xcd,0xcd,0x4c }, { 0x18,0x0c,0x0c,0x14 },
+ { 0x26,0x13,0x13,0x35 }, { 0xc3,0xec,0xec,0x2f },
+ { 0xbe,0x5f,0x5f,0xe1 }, { 0x35,0x97,0x97,0xa2 },
+ { 0x88,0x44,0x44,0xcc }, { 0x2e,0x17,0x17,0x39 },
+ { 0x93,0xc4,0xc4,0x57 }, { 0x55,0xa7,0xa7,0xf2 },
+ { 0xfc,0x7e,0x7e,0x82 }, { 0x7a,0x3d,0x3d,0x47 },
+ { 0xc8,0x64,0x64,0xac }, { 0xba,0x5d,0x5d,0xe7 },
+ { 0x32,0x19,0x19,0x2b }, { 0xe6,0x73,0x73,0x95 },
+ { 0xc0,0x60,0x60,0xa0 }, { 0x19,0x81,0x81,0x98 },
+ { 0x9e,0x4f,0x4f,0xd1 }, { 0xa3,0xdc,0xdc,0x7f },
+ { 0x44,0x22,0x22,0x66 }, { 0x54,0x2a,0x2a,0x7e },
+ { 0x3b,0x90,0x90,0xab }, { 0x0b,0x88,0x88,0x83 },
+ { 0x8c,0x46,0x46,0xca }, { 0xc7,0xee,0xee,0x29 },
+ { 0x6b,0xb8,0xb8,0xd3 }, { 0x28,0x14,0x14,0x3c },
+ { 0xa7,0xde,0xde,0x79 }, { 0xbc,0x5e,0x5e,0xe2 },
+ { 0x16,0x0b,0x0b,0x1d }, { 0xad,0xdb,0xdb,0x76 },
+ { 0xdb,0xe0,0xe0,0x3b }, { 0x64,0x32,0x32,0x56 },
+ { 0x74,0x3a,0x3a,0x4e }, { 0x14,0x0a,0x0a,0x1e },
+ { 0x92,0x49,0x49,0xdb }, { 0x0c,0x06,0x06,0x0a },
+ { 0x48,0x24,0x24,0x6c }, { 0xb8,0x5c,0x5c,0xe4 },
+ { 0x9f,0xc2,0xc2,0x5d }, { 0xbd,0xd3,0xd3,0x6e },
+ { 0x43,0xac,0xac,0xef }, { 0xc4,0x62,0x62,0xa6 },
+ { 0x39,0x91,0x91,0xa8 }, { 0x31,0x95,0x95,0xa4 },
+ { 0xd3,0xe4,0xe4,0x37 }, { 0xf2,0x79,0x79,0x8b },
+ { 0xd5,0xe7,0xe7,0x32 }, { 0x8b,0xc8,0xc8,0x43 },
+ { 0x6e,0x37,0x37,0x59 }, { 0xda,0x6d,0x6d,0xb7 },
+ { 0x01,0x8d,0x8d,0x8c }, { 0xb1,0xd5,0xd5,0x64 },
+ { 0x9c,0x4e,0x4e,0xd2 }, { 0x49,0xa9,0xa9,0xe0 },
+ { 0xd8,0x6c,0x6c,0xb4 }, { 0xac,0x56,0x56,0xfa },
+ { 0xf3,0xf4,0xf4,0x07 }, { 0xcf,0xea,0xea,0x25 },
+ { 0xca,0x65,0x65,0xaf }, { 0xf4,0x7a,0x7a,0x8e },
+ { 0x47,0xae,0xae,0xe9 }, { 0x10,0x08,0x08,0x18 },
+ { 0x6f,0xba,0xba,0xd5 }, { 0xf0,0x78,0x78,0x88 },
+ { 0x4a,0x25,0x25,0x6f }, { 0x5c,0x2e,0x2e,0x72 },
+ { 0x38,0x1c,0x1c,0x24 }, { 0x57,0xa6,0xa6,0xf1 },
+ { 0x73,0xb4,0xb4,0xc7 }, { 0x97,0xc6,0xc6,0x51 },
+ { 0xcb,0xe8,0xe8,0x23 }, { 0xa1,0xdd,0xdd,0x7c },
+ { 0xe8,0x74,0x74,0x9c }, { 0x3e,0x1f,0x1f,0x21 },
+ { 0x96,0x4b,0x4b,0xdd }, { 0x61,0xbd,0xbd,0xdc },
+ { 0x0d,0x8b,0x8b,0x86 }, { 0x0f,0x8a,0x8a,0x85 },
+ { 0xe0,0x70,0x70,0x90 }, { 0x7c,0x3e,0x3e,0x42 },
+ { 0x71,0xb5,0xb5,0xc4 }, { 0xcc,0x66,0x66,0xaa },
+ { 0x90,0x48,0x48,0xd8 }, { 0x06,0x03,0x03,0x05 },
+ { 0xf7,0xf6,0xf6,0x01 }, { 0x1c,0x0e,0x0e,0x12 },
+ { 0xc2,0x61,0x61,0xa3 }, { 0x6a,0x35,0x35,0x5f },
+ { 0xae,0x57,0x57,0xf9 }, { 0x69,0xb9,0xb9,0xd0 },
+ { 0x17,0x86,0x86,0x91 }, { 0x99,0xc1,0xc1,0x58 },
+ { 0x3a,0x1d,0x1d,0x27 }, { 0x27,0x9e,0x9e,0xb9 },
+ { 0xd9,0xe1,0xe1,0x38 }, { 0xeb,0xf8,0xf8,0x13 },
+ { 0x2b,0x98,0x98,0xb3 }, { 0x22,0x11,0x11,0x33 },
+ { 0xd2,0x69,0x69,0xbb }, { 0xa9,0xd9,0xd9,0x70 },
+ { 0x07,0x8e,0x8e,0x89 }, { 0x33,0x94,0x94,0xa7 },
+ { 0x2d,0x9b,0x9b,0xb6 }, { 0x3c,0x1e,0x1e,0x22 },
+ { 0x15,0x87,0x87,0x92 }, { 0xc9,0xe9,0xe9,0x20 },
+ { 0x87,0xce,0xce,0x49 }, { 0xaa,0x55,0x55,0xff },
+ { 0x50,0x28,0x28,0x78 }, { 0xa5,0xdf,0xdf,0x7a },
+ { 0x03,0x8c,0x8c,0x8f }, { 0x59,0xa1,0xa1,0xf8 },
+ { 0x09,0x89,0x89,0x80 }, { 0x1a,0x0d,0x0d,0x17 },
+ { 0x65,0xbf,0xbf,0xda }, { 0xd7,0xe6,0xe6,0x31 },
+ { 0x84,0x42,0x42,0xc6 }, { 0xd0,0x68,0x68,0xb8 },
+ { 0x82,0x41,0x41,0xc3 }, { 0x29,0x99,0x99,0xb0 },
+ { 0x5a,0x2d,0x2d,0x77 }, { 0x1e,0x0f,0x0f,0x11 },
+ { 0x7b,0xb0,0xb0,0xcb }, { 0xa8,0x54,0x54,0xfc },
+ { 0x6d,0xbb,0xbb,0xd6 }, { 0x2c,0x16,0x16,0x3a }
+ };
+
+static const unsigned char T2[256][4] =
+ {
+ { 0xa5,0xc6,0x63,0x63 }, { 0x84,0xf8,0x7c,0x7c },
+ { 0x99,0xee,0x77,0x77 }, { 0x8d,0xf6,0x7b,0x7b },
+ { 0x0d,0xff,0xf2,0xf2 }, { 0xbd,0xd6,0x6b,0x6b },
+ { 0xb1,0xde,0x6f,0x6f }, { 0x54,0x91,0xc5,0xc5 },
+ { 0x50,0x60,0x30,0x30 }, { 0x03,0x02,0x01,0x01 },
+ { 0xa9,0xce,0x67,0x67 }, { 0x7d,0x56,0x2b,0x2b },
+ { 0x19,0xe7,0xfe,0xfe }, { 0x62,0xb5,0xd7,0xd7 },
+ { 0xe6,0x4d,0xab,0xab }, { 0x9a,0xec,0x76,0x76 },
+ { 0x45,0x8f,0xca,0xca }, { 0x9d,0x1f,0x82,0x82 },
+ { 0x40,0x89,0xc9,0xc9 }, { 0x87,0xfa,0x7d,0x7d },
+ { 0x15,0xef,0xfa,0xfa }, { 0xeb,0xb2,0x59,0x59 },
+ { 0xc9,0x8e,0x47,0x47 }, { 0x0b,0xfb,0xf0,0xf0 },
+ { 0xec,0x41,0xad,0xad }, { 0x67,0xb3,0xd4,0xd4 },
+ { 0xfd,0x5f,0xa2,0xa2 }, { 0xea,0x45,0xaf,0xaf },
+ { 0xbf,0x23,0x9c,0x9c }, { 0xf7,0x53,0xa4,0xa4 },
+ { 0x96,0xe4,0x72,0x72 }, { 0x5b,0x9b,0xc0,0xc0 },
+ { 0xc2,0x75,0xb7,0xb7 }, { 0x1c,0xe1,0xfd,0xfd },
+ { 0xae,0x3d,0x93,0x93 }, { 0x6a,0x4c,0x26,0x26 },
+ { 0x5a,0x6c,0x36,0x36 }, { 0x41,0x7e,0x3f,0x3f },
+ { 0x02,0xf5,0xf7,0xf7 }, { 0x4f,0x83,0xcc,0xcc },
+ { 0x5c,0x68,0x34,0x34 }, { 0xf4,0x51,0xa5,0xa5 },
+ { 0x34,0xd1,0xe5,0xe5 }, { 0x08,0xf9,0xf1,0xf1 },
+ { 0x93,0xe2,0x71,0x71 }, { 0x73,0xab,0xd8,0xd8 },
+ { 0x53,0x62,0x31,0x31 }, { 0x3f,0x2a,0x15,0x15 },
+ { 0x0c,0x08,0x04,0x04 }, { 0x52,0x95,0xc7,0xc7 },
+ { 0x65,0x46,0x23,0x23 }, { 0x5e,0x9d,0xc3,0xc3 },
+ { 0x28,0x30,0x18,0x18 }, { 0xa1,0x37,0x96,0x96 },
+ { 0x0f,0x0a,0x05,0x05 }, { 0xb5,0x2f,0x9a,0x9a },
+ { 0x09,0x0e,0x07,0x07 }, { 0x36,0x24,0x12,0x12 },
+ { 0x9b,0x1b,0x80,0x80 }, { 0x3d,0xdf,0xe2,0xe2 },
+ { 0x26,0xcd,0xeb,0xeb }, { 0x69,0x4e,0x27,0x27 },
+ { 0xcd,0x7f,0xb2,0xb2 }, { 0x9f,0xea,0x75,0x75 },
+ { 0x1b,0x12,0x09,0x09 }, { 0x9e,0x1d,0x83,0x83 },
+ { 0x74,0x58,0x2c,0x2c }, { 0x2e,0x34,0x1a,0x1a },
+ { 0x2d,0x36,0x1b,0x1b }, { 0xb2,0xdc,0x6e,0x6e },
+ { 0xee,0xb4,0x5a,0x5a }, { 0xfb,0x5b,0xa0,0xa0 },
+ { 0xf6,0xa4,0x52,0x52 }, { 0x4d,0x76,0x3b,0x3b },
+ { 0x61,0xb7,0xd6,0xd6 }, { 0xce,0x7d,0xb3,0xb3 },
+ { 0x7b,0x52,0x29,0x29 }, { 0x3e,0xdd,0xe3,0xe3 },
+ { 0x71,0x5e,0x2f,0x2f }, { 0x97,0x13,0x84,0x84 },
+ { 0xf5,0xa6,0x53,0x53 }, { 0x68,0xb9,0xd1,0xd1 },
+ { 0x00,0x00,0x00,0x00 }, { 0x2c,0xc1,0xed,0xed },
+ { 0x60,0x40,0x20,0x20 }, { 0x1f,0xe3,0xfc,0xfc },
+ { 0xc8,0x79,0xb1,0xb1 }, { 0xed,0xb6,0x5b,0x5b },
+ { 0xbe,0xd4,0x6a,0x6a }, { 0x46,0x8d,0xcb,0xcb },
+ { 0xd9,0x67,0xbe,0xbe }, { 0x4b,0x72,0x39,0x39 },
+ { 0xde,0x94,0x4a,0x4a }, { 0xd4,0x98,0x4c,0x4c },
+ { 0xe8,0xb0,0x58,0x58 }, { 0x4a,0x85,0xcf,0xcf },
+ { 0x6b,0xbb,0xd0,0xd0 }, { 0x2a,0xc5,0xef,0xef },
+ { 0xe5,0x4f,0xaa,0xaa }, { 0x16,0xed,0xfb,0xfb },
+ { 0xc5,0x86,0x43,0x43 }, { 0xd7,0x9a,0x4d,0x4d },
+ { 0x55,0x66,0x33,0x33 }, { 0x94,0x11,0x85,0x85 },
+ { 0xcf,0x8a,0x45,0x45 }, { 0x10,0xe9,0xf9,0xf9 },
+ { 0x06,0x04,0x02,0x02 }, { 0x81,0xfe,0x7f,0x7f },
+ { 0xf0,0xa0,0x50,0x50 }, { 0x44,0x78,0x3c,0x3c },
+ { 0xba,0x25,0x9f,0x9f }, { 0xe3,0x4b,0xa8,0xa8 },
+ { 0xf3,0xa2,0x51,0x51 }, { 0xfe,0x5d,0xa3,0xa3 },
+ { 0xc0,0x80,0x40,0x40 }, { 0x8a,0x05,0x8f,0x8f },
+ { 0xad,0x3f,0x92,0x92 }, { 0xbc,0x21,0x9d,0x9d },
+ { 0x48,0x70,0x38,0x38 }, { 0x04,0xf1,0xf5,0xf5 },
+ { 0xdf,0x63,0xbc,0xbc }, { 0xc1,0x77,0xb6,0xb6 },
+ { 0x75,0xaf,0xda,0xda }, { 0x63,0x42,0x21,0x21 },
+ { 0x30,0x20,0x10,0x10 }, { 0x1a,0xe5,0xff,0xff },
+ { 0x0e,0xfd,0xf3,0xf3 }, { 0x6d,0xbf,0xd2,0xd2 },
+ { 0x4c,0x81,0xcd,0xcd }, { 0x14,0x18,0x0c,0x0c },
+ { 0x35,0x26,0x13,0x13 }, { 0x2f,0xc3,0xec,0xec },
+ { 0xe1,0xbe,0x5f,0x5f }, { 0xa2,0x35,0x97,0x97 },
+ { 0xcc,0x88,0x44,0x44 }, { 0x39,0x2e,0x17,0x17 },
+ { 0x57,0x93,0xc4,0xc4 }, { 0xf2,0x55,0xa7,0xa7 },
+ { 0x82,0xfc,0x7e,0x7e }, { 0x47,0x7a,0x3d,0x3d },
+ { 0xac,0xc8,0x64,0x64 }, { 0xe7,0xba,0x5d,0x5d },
+ { 0x2b,0x32,0x19,0x19 }, { 0x95,0xe6,0x73,0x73 },
+ { 0xa0,0xc0,0x60,0x60 }, { 0x98,0x19,0x81,0x81 },
+ { 0xd1,0x9e,0x4f,0x4f }, { 0x7f,0xa3,0xdc,0xdc },
+ { 0x66,0x44,0x22,0x22 }, { 0x7e,0x54,0x2a,0x2a },
+ { 0xab,0x3b,0x90,0x90 }, { 0x83,0x0b,0x88,0x88 },
+ { 0xca,0x8c,0x46,0x46 }, { 0x29,0xc7,0xee,0xee },
+ { 0xd3,0x6b,0xb8,0xb8 }, { 0x3c,0x28,0x14,0x14 },
+ { 0x79,0xa7,0xde,0xde }, { 0xe2,0xbc,0x5e,0x5e },
+ { 0x1d,0x16,0x0b,0x0b }, { 0x76,0xad,0xdb,0xdb },
+ { 0x3b,0xdb,0xe0,0xe0 }, { 0x56,0x64,0x32,0x32 },
+ { 0x4e,0x74,0x3a,0x3a }, { 0x1e,0x14,0x0a,0x0a },
+ { 0xdb,0x92,0x49,0x49 }, { 0x0a,0x0c,0x06,0x06 },
+ { 0x6c,0x48,0x24,0x24 }, { 0xe4,0xb8,0x5c,0x5c },
+ { 0x5d,0x9f,0xc2,0xc2 }, { 0x6e,0xbd,0xd3,0xd3 },
+ { 0xef,0x43,0xac,0xac }, { 0xa6,0xc4,0x62,0x62 },
+ { 0xa8,0x39,0x91,0x91 }, { 0xa4,0x31,0x95,0x95 },
+ { 0x37,0xd3,0xe4,0xe4 }, { 0x8b,0xf2,0x79,0x79 },
+ { 0x32,0xd5,0xe7,0xe7 }, { 0x43,0x8b,0xc8,0xc8 },
+ { 0x59,0x6e,0x37,0x37 }, { 0xb7,0xda,0x6d,0x6d },
+ { 0x8c,0x01,0x8d,0x8d }, { 0x64,0xb1,0xd5,0xd5 },
+ { 0xd2,0x9c,0x4e,0x4e }, { 0xe0,0x49,0xa9,0xa9 },
+ { 0xb4,0xd8,0x6c,0x6c }, { 0xfa,0xac,0x56,0x56 },
+ { 0x07,0xf3,0xf4,0xf4 }, { 0x25,0xcf,0xea,0xea },
+ { 0xaf,0xca,0x65,0x65 }, { 0x8e,0xf4,0x7a,0x7a },
+ { 0xe9,0x47,0xae,0xae }, { 0x18,0x10,0x08,0x08 },
+ { 0xd5,0x6f,0xba,0xba }, { 0x88,0xf0,0x78,0x78 },
+ { 0x6f,0x4a,0x25,0x25 }, { 0x72,0x5c,0x2e,0x2e },
+ { 0x24,0x38,0x1c,0x1c }, { 0xf1,0x57,0xa6,0xa6 },
+ { 0xc7,0x73,0xb4,0xb4 }, { 0x51,0x97,0xc6,0xc6 },
+ { 0x23,0xcb,0xe8,0xe8 }, { 0x7c,0xa1,0xdd,0xdd },
+ { 0x9c,0xe8,0x74,0x74 }, { 0x21,0x3e,0x1f,0x1f },
+ { 0xdd,0x96,0x4b,0x4b }, { 0xdc,0x61,0xbd,0xbd },
+ { 0x86,0x0d,0x8b,0x8b }, { 0x85,0x0f,0x8a,0x8a },
+ { 0x90,0xe0,0x70,0x70 }, { 0x42,0x7c,0x3e,0x3e },
+ { 0xc4,0x71,0xb5,0xb5 }, { 0xaa,0xcc,0x66,0x66 },
+ { 0xd8,0x90,0x48,0x48 }, { 0x05,0x06,0x03,0x03 },
+ { 0x01,0xf7,0xf6,0xf6 }, { 0x12,0x1c,0x0e,0x0e },
+ { 0xa3,0xc2,0x61,0x61 }, { 0x5f,0x6a,0x35,0x35 },
+ { 0xf9,0xae,0x57,0x57 }, { 0xd0,0x69,0xb9,0xb9 },
+ { 0x91,0x17,0x86,0x86 }, { 0x58,0x99,0xc1,0xc1 },
+ { 0x27,0x3a,0x1d,0x1d }, { 0xb9,0x27,0x9e,0x9e },
+ { 0x38,0xd9,0xe1,0xe1 }, { 0x13,0xeb,0xf8,0xf8 },
+ { 0xb3,0x2b,0x98,0x98 }, { 0x33,0x22,0x11,0x11 },
+ { 0xbb,0xd2,0x69,0x69 }, { 0x70,0xa9,0xd9,0xd9 },
+ { 0x89,0x07,0x8e,0x8e }, { 0xa7,0x33,0x94,0x94 },
+ { 0xb6,0x2d,0x9b,0x9b }, { 0x22,0x3c,0x1e,0x1e },
+ { 0x92,0x15,0x87,0x87 }, { 0x20,0xc9,0xe9,0xe9 },
+ { 0x49,0x87,0xce,0xce }, { 0xff,0xaa,0x55,0x55 },
+ { 0x78,0x50,0x28,0x28 }, { 0x7a,0xa5,0xdf,0xdf },
+ { 0x8f,0x03,0x8c,0x8c }, { 0xf8,0x59,0xa1,0xa1 },
+ { 0x80,0x09,0x89,0x89 }, { 0x17,0x1a,0x0d,0x0d },
+ { 0xda,0x65,0xbf,0xbf }, { 0x31,0xd7,0xe6,0xe6 },
+ { 0xc6,0x84,0x42,0x42 }, { 0xb8,0xd0,0x68,0x68 },
+ { 0xc3,0x82,0x41,0x41 }, { 0xb0,0x29,0x99,0x99 },
+ { 0x77,0x5a,0x2d,0x2d }, { 0x11,0x1e,0x0f,0x0f },
+ { 0xcb,0x7b,0xb0,0xb0 }, { 0xfc,0xa8,0x54,0x54 },
+ { 0xd6,0x6d,0xbb,0xbb }, { 0x3a,0x2c,0x16,0x16 }
+ };
+
+static const unsigned char T3[256][4] =
+ {
+ { 0x63,0xa5,0xc6,0x63 }, { 0x7c,0x84,0xf8,0x7c },
+ { 0x77,0x99,0xee,0x77 }, { 0x7b,0x8d,0xf6,0x7b },
+ { 0xf2,0x0d,0xff,0xf2 }, { 0x6b,0xbd,0xd6,0x6b },
+ { 0x6f,0xb1,0xde,0x6f }, { 0xc5,0x54,0x91,0xc5 },
+ { 0x30,0x50,0x60,0x30 }, { 0x01,0x03,0x02,0x01 },
+ { 0x67,0xa9,0xce,0x67 }, { 0x2b,0x7d,0x56,0x2b },
+ { 0xfe,0x19,0xe7,0xfe }, { 0xd7,0x62,0xb5,0xd7 },
+ { 0xab,0xe6,0x4d,0xab }, { 0x76,0x9a,0xec,0x76 },
+ { 0xca,0x45,0x8f,0xca }, { 0x82,0x9d,0x1f,0x82 },
+ { 0xc9,0x40,0x89,0xc9 }, { 0x7d,0x87,0xfa,0x7d },
+ { 0xfa,0x15,0xef,0xfa }, { 0x59,0xeb,0xb2,0x59 },
+ { 0x47,0xc9,0x8e,0x47 }, { 0xf0,0x0b,0xfb,0xf0 },
+ { 0xad,0xec,0x41,0xad }, { 0xd4,0x67,0xb3,0xd4 },
+ { 0xa2,0xfd,0x5f,0xa2 }, { 0xaf,0xea,0x45,0xaf },
+ { 0x9c,0xbf,0x23,0x9c }, { 0xa4,0xf7,0x53,0xa4 },
+ { 0x72,0x96,0xe4,0x72 }, { 0xc0,0x5b,0x9b,0xc0 },
+ { 0xb7,0xc2,0x75,0xb7 }, { 0xfd,0x1c,0xe1,0xfd },
+ { 0x93,0xae,0x3d,0x93 }, { 0x26,0x6a,0x4c,0x26 },
+ { 0x36,0x5a,0x6c,0x36 }, { 0x3f,0x41,0x7e,0x3f },
+ { 0xf7,0x02,0xf5,0xf7 }, { 0xcc,0x4f,0x83,0xcc },
+ { 0x34,0x5c,0x68,0x34 }, { 0xa5,0xf4,0x51,0xa5 },
+ { 0xe5,0x34,0xd1,0xe5 }, { 0xf1,0x08,0xf9,0xf1 },
+ { 0x71,0x93,0xe2,0x71 }, { 0xd8,0x73,0xab,0xd8 },
+ { 0x31,0x53,0x62,0x31 }, { 0x15,0x3f,0x2a,0x15 },
+ { 0x04,0x0c,0x08,0x04 }, { 0xc7,0x52,0x95,0xc7 },
+ { 0x23,0x65,0x46,0x23 }, { 0xc3,0x5e,0x9d,0xc3 },
+ { 0x18,0x28,0x30,0x18 }, { 0x96,0xa1,0x37,0x96 },
+ { 0x05,0x0f,0x0a,0x05 }, { 0x9a,0xb5,0x2f,0x9a },
+ { 0x07,0x09,0x0e,0x07 }, { 0x12,0x36,0x24,0x12 },
+ { 0x80,0x9b,0x1b,0x80 }, { 0xe2,0x3d,0xdf,0xe2 },
+ { 0xeb,0x26,0xcd,0xeb }, { 0x27,0x69,0x4e,0x27 },
+ { 0xb2,0xcd,0x7f,0xb2 }, { 0x75,0x9f,0xea,0x75 },
+ { 0x09,0x1b,0x12,0x09 }, { 0x83,0x9e,0x1d,0x83 },
+ { 0x2c,0x74,0x58,0x2c }, { 0x1a,0x2e,0x34,0x1a },
+ { 0x1b,0x2d,0x36,0x1b }, { 0x6e,0xb2,0xdc,0x6e },
+ { 0x5a,0xee,0xb4,0x5a }, { 0xa0,0xfb,0x5b,0xa0 },
+ { 0x52,0xf6,0xa4,0x52 }, { 0x3b,0x4d,0x76,0x3b },
+ { 0xd6,0x61,0xb7,0xd6 }, { 0xb3,0xce,0x7d,0xb3 },
+ { 0x29,0x7b,0x52,0x29 }, { 0xe3,0x3e,0xdd,0xe3 },
+ { 0x2f,0x71,0x5e,0x2f }, { 0x84,0x97,0x13,0x84 },
+ { 0x53,0xf5,0xa6,0x53 }, { 0xd1,0x68,0xb9,0xd1 },
+ { 0x00,0x00,0x00,0x00 }, { 0xed,0x2c,0xc1,0xed },
+ { 0x20,0x60,0x40,0x20 }, { 0xfc,0x1f,0xe3,0xfc },
+ { 0xb1,0xc8,0x79,0xb1 }, { 0x5b,0xed,0xb6,0x5b },
+ { 0x6a,0xbe,0xd4,0x6a }, { 0xcb,0x46,0x8d,0xcb },
+ { 0xbe,0xd9,0x67,0xbe }, { 0x39,0x4b,0x72,0x39 },
+ { 0x4a,0xde,0x94,0x4a }, { 0x4c,0xd4,0x98,0x4c },
+ { 0x58,0xe8,0xb0,0x58 }, { 0xcf,0x4a,0x85,0xcf },
+ { 0xd0,0x6b,0xbb,0xd0 }, { 0xef,0x2a,0xc5,0xef },
+ { 0xaa,0xe5,0x4f,0xaa }, { 0xfb,0x16,0xed,0xfb },
+ { 0x43,0xc5,0x86,0x43 }, { 0x4d,0xd7,0x9a,0x4d },
+ { 0x33,0x55,0x66,0x33 }, { 0x85,0x94,0x11,0x85 },
+ { 0x45,0xcf,0x8a,0x45 }, { 0xf9,0x10,0xe9,0xf9 },
+ { 0x02,0x06,0x04,0x02 }, { 0x7f,0x81,0xfe,0x7f },
+ { 0x50,0xf0,0xa0,0x50 }, { 0x3c,0x44,0x78,0x3c },
+ { 0x9f,0xba,0x25,0x9f }, { 0xa8,0xe3,0x4b,0xa8 },
+ { 0x51,0xf3,0xa2,0x51 }, { 0xa3,0xfe,0x5d,0xa3 },
+ { 0x40,0xc0,0x80,0x40 }, { 0x8f,0x8a,0x05,0x8f },
+ { 0x92,0xad,0x3f,0x92 }, { 0x9d,0xbc,0x21,0x9d },
+ { 0x38,0x48,0x70,0x38 }, { 0xf5,0x04,0xf1,0xf5 },
+ { 0xbc,0xdf,0x63,0xbc }, { 0xb6,0xc1,0x77,0xb6 },
+ { 0xda,0x75,0xaf,0xda }, { 0x21,0x63,0x42,0x21 },
+ { 0x10,0x30,0x20,0x10 }, { 0xff,0x1a,0xe5,0xff },
+ { 0xf3,0x0e,0xfd,0xf3 }, { 0xd2,0x6d,0xbf,0xd2 },
+ { 0xcd,0x4c,0x81,0xcd }, { 0x0c,0x14,0x18,0x0c },
+ { 0x13,0x35,0x26,0x13 }, { 0xec,0x2f,0xc3,0xec },
+ { 0x5f,0xe1,0xbe,0x5f }, { 0x97,0xa2,0x35,0x97 },
+ { 0x44,0xcc,0x88,0x44 }, { 0x17,0x39,0x2e,0x17 },
+ { 0xc4,0x57,0x93,0xc4 }, { 0xa7,0xf2,0x55,0xa7 },
+ { 0x7e,0x82,0xfc,0x7e }, { 0x3d,0x47,0x7a,0x3d },
+ { 0x64,0xac,0xc8,0x64 }, { 0x5d,0xe7,0xba,0x5d },
+ { 0x19,0x2b,0x32,0x19 }, { 0x73,0x95,0xe6,0x73 },
+ { 0x60,0xa0,0xc0,0x60 }, { 0x81,0x98,0x19,0x81 },
+ { 0x4f,0xd1,0x9e,0x4f }, { 0xdc,0x7f,0xa3,0xdc },
+ { 0x22,0x66,0x44,0x22 }, { 0x2a,0x7e,0x54,0x2a },
+ { 0x90,0xab,0x3b,0x90 }, { 0x88,0x83,0x0b,0x88 },
+ { 0x46,0xca,0x8c,0x46 }, { 0xee,0x29,0xc7,0xee },
+ { 0xb8,0xd3,0x6b,0xb8 }, { 0x14,0x3c,0x28,0x14 },
+ { 0xde,0x79,0xa7,0xde }, { 0x5e,0xe2,0xbc,0x5e },
+ { 0x0b,0x1d,0x16,0x0b }, { 0xdb,0x76,0xad,0xdb },
+ { 0xe0,0x3b,0xdb,0xe0 }, { 0x32,0x56,0x64,0x32 },
+ { 0x3a,0x4e,0x74,0x3a }, { 0x0a,0x1e,0x14,0x0a },
+ { 0x49,0xdb,0x92,0x49 }, { 0x06,0x0a,0x0c,0x06 },
+ { 0x24,0x6c,0x48,0x24 }, { 0x5c,0xe4,0xb8,0x5c },
+ { 0xc2,0x5d,0x9f,0xc2 }, { 0xd3,0x6e,0xbd,0xd3 },
+ { 0xac,0xef,0x43,0xac }, { 0x62,0xa6,0xc4,0x62 },
+ { 0x91,0xa8,0x39,0x91 }, { 0x95,0xa4,0x31,0x95 },
+ { 0xe4,0x37,0xd3,0xe4 }, { 0x79,0x8b,0xf2,0x79 },
+ { 0xe7,0x32,0xd5,0xe7 }, { 0xc8,0x43,0x8b,0xc8 },
+ { 0x37,0x59,0x6e,0x37 }, { 0x6d,0xb7,0xda,0x6d },
+ { 0x8d,0x8c,0x01,0x8d }, { 0xd5,0x64,0xb1,0xd5 },
+ { 0x4e,0xd2,0x9c,0x4e }, { 0xa9,0xe0,0x49,0xa9 },
+ { 0x6c,0xb4,0xd8,0x6c }, { 0x56,0xfa,0xac,0x56 },
+ { 0xf4,0x07,0xf3,0xf4 }, { 0xea,0x25,0xcf,0xea },
+ { 0x65,0xaf,0xca,0x65 }, { 0x7a,0x8e,0xf4,0x7a },
+ { 0xae,0xe9,0x47,0xae }, { 0x08,0x18,0x10,0x08 },
+ { 0xba,0xd5,0x6f,0xba }, { 0x78,0x88,0xf0,0x78 },
+ { 0x25,0x6f,0x4a,0x25 }, { 0x2e,0x72,0x5c,0x2e },
+ { 0x1c,0x24,0x38,0x1c }, { 0xa6,0xf1,0x57,0xa6 },
+ { 0xb4,0xc7,0x73,0xb4 }, { 0xc6,0x51,0x97,0xc6 },
+ { 0xe8,0x23,0xcb,0xe8 }, { 0xdd,0x7c,0xa1,0xdd },
+ { 0x74,0x9c,0xe8,0x74 }, { 0x1f,0x21,0x3e,0x1f },
+ { 0x4b,0xdd,0x96,0x4b }, { 0xbd,0xdc,0x61,0xbd },
+ { 0x8b,0x86,0x0d,0x8b }, { 0x8a,0x85,0x0f,0x8a },
+ { 0x70,0x90,0xe0,0x70 }, { 0x3e,0x42,0x7c,0x3e },
+ { 0xb5,0xc4,0x71,0xb5 }, { 0x66,0xaa,0xcc,0x66 },
+ { 0x48,0xd8,0x90,0x48 }, { 0x03,0x05,0x06,0x03 },
+ { 0xf6,0x01,0xf7,0xf6 }, { 0x0e,0x12,0x1c,0x0e },
+ { 0x61,0xa3,0xc2,0x61 }, { 0x35,0x5f,0x6a,0x35 },
+ { 0x57,0xf9,0xae,0x57 }, { 0xb9,0xd0,0x69,0xb9 },
+ { 0x86,0x91,0x17,0x86 }, { 0xc1,0x58,0x99,0xc1 },
+ { 0x1d,0x27,0x3a,0x1d }, { 0x9e,0xb9,0x27,0x9e },
+ { 0xe1,0x38,0xd9,0xe1 }, { 0xf8,0x13,0xeb,0xf8 },
+ { 0x98,0xb3,0x2b,0x98 }, { 0x11,0x33,0x22,0x11 },
+ { 0x69,0xbb,0xd2,0x69 }, { 0xd9,0x70,0xa9,0xd9 },
+ { 0x8e,0x89,0x07,0x8e }, { 0x94,0xa7,0x33,0x94 },
+ { 0x9b,0xb6,0x2d,0x9b }, { 0x1e,0x22,0x3c,0x1e },
+ { 0x87,0x92,0x15,0x87 }, { 0xe9,0x20,0xc9,0xe9 },
+ { 0xce,0x49,0x87,0xce }, { 0x55,0xff,0xaa,0x55 },
+ { 0x28,0x78,0x50,0x28 }, { 0xdf,0x7a,0xa5,0xdf },
+ { 0x8c,0x8f,0x03,0x8c }, { 0xa1,0xf8,0x59,0xa1 },
+ { 0x89,0x80,0x09,0x89 }, { 0x0d,0x17,0x1a,0x0d },
+ { 0xbf,0xda,0x65,0xbf }, { 0xe6,0x31,0xd7,0xe6 },
+ { 0x42,0xc6,0x84,0x42 }, { 0x68,0xb8,0xd0,0x68 },
+ { 0x41,0xc3,0x82,0x41 }, { 0x99,0xb0,0x29,0x99 },
+ { 0x2d,0x77,0x5a,0x2d }, { 0x0f,0x11,0x1e,0x0f },
+ { 0xb0,0xcb,0x7b,0xb0 }, { 0x54,0xfc,0xa8,0x54 },
+ { 0xbb,0xd6,0x6d,0xbb }, { 0x16,0x3a,0x2c,0x16 }
+ };
+
+static const unsigned char T4[256][4] =
+ {
+ { 0x63,0x63,0xa5,0xc6 }, { 0x7c,0x7c,0x84,0xf8 },
+ { 0x77,0x77,0x99,0xee }, { 0x7b,0x7b,0x8d,0xf6 },
+ { 0xf2,0xf2,0x0d,0xff }, { 0x6b,0x6b,0xbd,0xd6 },
+ { 0x6f,0x6f,0xb1,0xde }, { 0xc5,0xc5,0x54,0x91 },
+ { 0x30,0x30,0x50,0x60 }, { 0x01,0x01,0x03,0x02 },
+ { 0x67,0x67,0xa9,0xce }, { 0x2b,0x2b,0x7d,0x56 },
+ { 0xfe,0xfe,0x19,0xe7 }, { 0xd7,0xd7,0x62,0xb5 },
+ { 0xab,0xab,0xe6,0x4d }, { 0x76,0x76,0x9a,0xec },
+ { 0xca,0xca,0x45,0x8f }, { 0x82,0x82,0x9d,0x1f },
+ { 0xc9,0xc9,0x40,0x89 }, { 0x7d,0x7d,0x87,0xfa },
+ { 0xfa,0xfa,0x15,0xef }, { 0x59,0x59,0xeb,0xb2 },
+ { 0x47,0x47,0xc9,0x8e }, { 0xf0,0xf0,0x0b,0xfb },
+ { 0xad,0xad,0xec,0x41 }, { 0xd4,0xd4,0x67,0xb3 },
+ { 0xa2,0xa2,0xfd,0x5f }, { 0xaf,0xaf,0xea,0x45 },
+ { 0x9c,0x9c,0xbf,0x23 }, { 0xa4,0xa4,0xf7,0x53 },
+ { 0x72,0x72,0x96,0xe4 }, { 0xc0,0xc0,0x5b,0x9b },
+ { 0xb7,0xb7,0xc2,0x75 }, { 0xfd,0xfd,0x1c,0xe1 },
+ { 0x93,0x93,0xae,0x3d }, { 0x26,0x26,0x6a,0x4c },
+ { 0x36,0x36,0x5a,0x6c }, { 0x3f,0x3f,0x41,0x7e },
+ { 0xf7,0xf7,0x02,0xf5 }, { 0xcc,0xcc,0x4f,0x83 },
+ { 0x34,0x34,0x5c,0x68 }, { 0xa5,0xa5,0xf4,0x51 },
+ { 0xe5,0xe5,0x34,0xd1 }, { 0xf1,0xf1,0x08,0xf9 },
+ { 0x71,0x71,0x93,0xe2 }, { 0xd8,0xd8,0x73,0xab },
+ { 0x31,0x31,0x53,0x62 }, { 0x15,0x15,0x3f,0x2a },
+ { 0x04,0x04,0x0c,0x08 }, { 0xc7,0xc7,0x52,0x95 },
+ { 0x23,0x23,0x65,0x46 }, { 0xc3,0xc3,0x5e,0x9d },
+ { 0x18,0x18,0x28,0x30 }, { 0x96,0x96,0xa1,0x37 },
+ { 0x05,0x05,0x0f,0x0a }, { 0x9a,0x9a,0xb5,0x2f },
+ { 0x07,0x07,0x09,0x0e }, { 0x12,0x12,0x36,0x24 },
+ { 0x80,0x80,0x9b,0x1b }, { 0xe2,0xe2,0x3d,0xdf },
+ { 0xeb,0xeb,0x26,0xcd }, { 0x27,0x27,0x69,0x4e },
+ { 0xb2,0xb2,0xcd,0x7f }, { 0x75,0x75,0x9f,0xea },
+ { 0x09,0x09,0x1b,0x12 }, { 0x83,0x83,0x9e,0x1d },
+ { 0x2c,0x2c,0x74,0x58 }, { 0x1a,0x1a,0x2e,0x34 },
+ { 0x1b,0x1b,0x2d,0x36 }, { 0x6e,0x6e,0xb2,0xdc },
+ { 0x5a,0x5a,0xee,0xb4 }, { 0xa0,0xa0,0xfb,0x5b },
+ { 0x52,0x52,0xf6,0xa4 }, { 0x3b,0x3b,0x4d,0x76 },
+ { 0xd6,0xd6,0x61,0xb7 }, { 0xb3,0xb3,0xce,0x7d },
+ { 0x29,0x29,0x7b,0x52 }, { 0xe3,0xe3,0x3e,0xdd },
+ { 0x2f,0x2f,0x71,0x5e }, { 0x84,0x84,0x97,0x13 },
+ { 0x53,0x53,0xf5,0xa6 }, { 0xd1,0xd1,0x68,0xb9 },
+ { 0x00,0x00,0x00,0x00 }, { 0xed,0xed,0x2c,0xc1 },
+ { 0x20,0x20,0x60,0x40 }, { 0xfc,0xfc,0x1f,0xe3 },
+ { 0xb1,0xb1,0xc8,0x79 }, { 0x5b,0x5b,0xed,0xb6 },
+ { 0x6a,0x6a,0xbe,0xd4 }, { 0xcb,0xcb,0x46,0x8d },
+ { 0xbe,0xbe,0xd9,0x67 }, { 0x39,0x39,0x4b,0x72 },
+ { 0x4a,0x4a,0xde,0x94 }, { 0x4c,0x4c,0xd4,0x98 },
+ { 0x58,0x58,0xe8,0xb0 }, { 0xcf,0xcf,0x4a,0x85 },
+ { 0xd0,0xd0,0x6b,0xbb }, { 0xef,0xef,0x2a,0xc5 },
+ { 0xaa,0xaa,0xe5,0x4f }, { 0xfb,0xfb,0x16,0xed },
+ { 0x43,0x43,0xc5,0x86 }, { 0x4d,0x4d,0xd7,0x9a },
+ { 0x33,0x33,0x55,0x66 }, { 0x85,0x85,0x94,0x11 },
+ { 0x45,0x45,0xcf,0x8a }, { 0xf9,0xf9,0x10,0xe9 },
+ { 0x02,0x02,0x06,0x04 }, { 0x7f,0x7f,0x81,0xfe },
+ { 0x50,0x50,0xf0,0xa0 }, { 0x3c,0x3c,0x44,0x78 },
+ { 0x9f,0x9f,0xba,0x25 }, { 0xa8,0xa8,0xe3,0x4b },
+ { 0x51,0x51,0xf3,0xa2 }, { 0xa3,0xa3,0xfe,0x5d },
+ { 0x40,0x40,0xc0,0x80 }, { 0x8f,0x8f,0x8a,0x05 },
+ { 0x92,0x92,0xad,0x3f }, { 0x9d,0x9d,0xbc,0x21 },
+ { 0x38,0x38,0x48,0x70 }, { 0xf5,0xf5,0x04,0xf1 },
+ { 0xbc,0xbc,0xdf,0x63 }, { 0xb6,0xb6,0xc1,0x77 },
+ { 0xda,0xda,0x75,0xaf }, { 0x21,0x21,0x63,0x42 },
+ { 0x10,0x10,0x30,0x20 }, { 0xff,0xff,0x1a,0xe5 },
+ { 0xf3,0xf3,0x0e,0xfd }, { 0xd2,0xd2,0x6d,0xbf },
+ { 0xcd,0xcd,0x4c,0x81 }, { 0x0c,0x0c,0x14,0x18 },
+ { 0x13,0x13,0x35,0x26 }, { 0xec,0xec,0x2f,0xc3 },
+ { 0x5f,0x5f,0xe1,0xbe }, { 0x97,0x97,0xa2,0x35 },
+ { 0x44,0x44,0xcc,0x88 }, { 0x17,0x17,0x39,0x2e },
+ { 0xc4,0xc4,0x57,0x93 }, { 0xa7,0xa7,0xf2,0x55 },
+ { 0x7e,0x7e,0x82,0xfc }, { 0x3d,0x3d,0x47,0x7a },
+ { 0x64,0x64,0xac,0xc8 }, { 0x5d,0x5d,0xe7,0xba },
+ { 0x19,0x19,0x2b,0x32 }, { 0x73,0x73,0x95,0xe6 },
+ { 0x60,0x60,0xa0,0xc0 }, { 0x81,0x81,0x98,0x19 },
+ { 0x4f,0x4f,0xd1,0x9e }, { 0xdc,0xdc,0x7f,0xa3 },
+ { 0x22,0x22,0x66,0x44 }, { 0x2a,0x2a,0x7e,0x54 },
+ { 0x90,0x90,0xab,0x3b }, { 0x88,0x88,0x83,0x0b },
+ { 0x46,0x46,0xca,0x8c }, { 0xee,0xee,0x29,0xc7 },
+ { 0xb8,0xb8,0xd3,0x6b }, { 0x14,0x14,0x3c,0x28 },
+ { 0xde,0xde,0x79,0xa7 }, { 0x5e,0x5e,0xe2,0xbc },
+ { 0x0b,0x0b,0x1d,0x16 }, { 0xdb,0xdb,0x76,0xad },
+ { 0xe0,0xe0,0x3b,0xdb }, { 0x32,0x32,0x56,0x64 },
+ { 0x3a,0x3a,0x4e,0x74 }, { 0x0a,0x0a,0x1e,0x14 },
+ { 0x49,0x49,0xdb,0x92 }, { 0x06,0x06,0x0a,0x0c },
+ { 0x24,0x24,0x6c,0x48 }, { 0x5c,0x5c,0xe4,0xb8 },
+ { 0xc2,0xc2,0x5d,0x9f }, { 0xd3,0xd3,0x6e,0xbd },
+ { 0xac,0xac,0xef,0x43 }, { 0x62,0x62,0xa6,0xc4 },
+ { 0x91,0x91,0xa8,0x39 }, { 0x95,0x95,0xa4,0x31 },
+ { 0xe4,0xe4,0x37,0xd3 }, { 0x79,0x79,0x8b,0xf2 },
+ { 0xe7,0xe7,0x32,0xd5 }, { 0xc8,0xc8,0x43,0x8b },
+ { 0x37,0x37,0x59,0x6e }, { 0x6d,0x6d,0xb7,0xda },
+ { 0x8d,0x8d,0x8c,0x01 }, { 0xd5,0xd5,0x64,0xb1 },
+ { 0x4e,0x4e,0xd2,0x9c }, { 0xa9,0xa9,0xe0,0x49 },
+ { 0x6c,0x6c,0xb4,0xd8 }, { 0x56,0x56,0xfa,0xac },
+ { 0xf4,0xf4,0x07,0xf3 }, { 0xea,0xea,0x25,0xcf },
+ { 0x65,0x65,0xaf,0xca }, { 0x7a,0x7a,0x8e,0xf4 },
+ { 0xae,0xae,0xe9,0x47 }, { 0x08,0x08,0x18,0x10 },
+ { 0xba,0xba,0xd5,0x6f }, { 0x78,0x78,0x88,0xf0 },
+ { 0x25,0x25,0x6f,0x4a }, { 0x2e,0x2e,0x72,0x5c },
+ { 0x1c,0x1c,0x24,0x38 }, { 0xa6,0xa6,0xf1,0x57 },
+ { 0xb4,0xb4,0xc7,0x73 }, { 0xc6,0xc6,0x51,0x97 },
+ { 0xe8,0xe8,0x23,0xcb }, { 0xdd,0xdd,0x7c,0xa1 },
+ { 0x74,0x74,0x9c,0xe8 }, { 0x1f,0x1f,0x21,0x3e },
+ { 0x4b,0x4b,0xdd,0x96 }, { 0xbd,0xbd,0xdc,0x61 },
+ { 0x8b,0x8b,0x86,0x0d }, { 0x8a,0x8a,0x85,0x0f },
+ { 0x70,0x70,0x90,0xe0 }, { 0x3e,0x3e,0x42,0x7c },
+ { 0xb5,0xb5,0xc4,0x71 }, { 0x66,0x66,0xaa,0xcc },
+ { 0x48,0x48,0xd8,0x90 }, { 0x03,0x03,0x05,0x06 },
+ { 0xf6,0xf6,0x01,0xf7 }, { 0x0e,0x0e,0x12,0x1c },
+ { 0x61,0x61,0xa3,0xc2 }, { 0x35,0x35,0x5f,0x6a },
+ { 0x57,0x57,0xf9,0xae }, { 0xb9,0xb9,0xd0,0x69 },
+ { 0x86,0x86,0x91,0x17 }, { 0xc1,0xc1,0x58,0x99 },
+ { 0x1d,0x1d,0x27,0x3a }, { 0x9e,0x9e,0xb9,0x27 },
+ { 0xe1,0xe1,0x38,0xd9 }, { 0xf8,0xf8,0x13,0xeb },
+ { 0x98,0x98,0xb3,0x2b }, { 0x11,0x11,0x33,0x22 },
+ { 0x69,0x69,0xbb,0xd2 }, { 0xd9,0xd9,0x70,0xa9 },
+ { 0x8e,0x8e,0x89,0x07 }, { 0x94,0x94,0xa7,0x33 },
+ { 0x9b,0x9b,0xb6,0x2d }, { 0x1e,0x1e,0x22,0x3c },
+ { 0x87,0x87,0x92,0x15 }, { 0xe9,0xe9,0x20,0xc9 },
+ { 0xce,0xce,0x49,0x87 }, { 0x55,0x55,0xff,0xaa },
+ { 0x28,0x28,0x78,0x50 }, { 0xdf,0xdf,0x7a,0xa5 },
+ { 0x8c,0x8c,0x8f,0x03 }, { 0xa1,0xa1,0xf8,0x59 },
+ { 0x89,0x89,0x80,0x09 }, { 0x0d,0x0d,0x17,0x1a },
+ { 0xbf,0xbf,0xda,0x65 }, { 0xe6,0xe6,0x31,0xd7 },
+ { 0x42,0x42,0xc6,0x84 }, { 0x68,0x68,0xb8,0xd0 },
+ { 0x41,0x41,0xc3,0x82 }, { 0x99,0x99,0xb0,0x29 },
+ { 0x2d,0x2d,0x77,0x5a }, { 0x0f,0x0f,0x11,0x1e },
+ { 0xb0,0xb0,0xcb,0x7b }, { 0x54,0x54,0xfc,0xa8 },
+ { 0xbb,0xbb,0xd6,0x6d }, { 0x16,0x16,0x3a,0x2c }
+ };
+
+static const unsigned char T5[256][4] =
+ {
+ { 0x51,0xf4,0xa7,0x50 }, { 0x7e,0x41,0x65,0x53 },
+ { 0x1a,0x17,0xa4,0xc3 }, { 0x3a,0x27,0x5e,0x96 },
+ { 0x3b,0xab,0x6b,0xcb }, { 0x1f,0x9d,0x45,0xf1 },
+ { 0xac,0xfa,0x58,0xab }, { 0x4b,0xe3,0x03,0x93 },
+ { 0x20,0x30,0xfa,0x55 }, { 0xad,0x76,0x6d,0xf6 },
+ { 0x88,0xcc,0x76,0x91 }, { 0xf5,0x02,0x4c,0x25 },
+ { 0x4f,0xe5,0xd7,0xfc }, { 0xc5,0x2a,0xcb,0xd7 },
+ { 0x26,0x35,0x44,0x80 }, { 0xb5,0x62,0xa3,0x8f },
+ { 0xde,0xb1,0x5a,0x49 }, { 0x25,0xba,0x1b,0x67 },
+ { 0x45,0xea,0x0e,0x98 }, { 0x5d,0xfe,0xc0,0xe1 },
+ { 0xc3,0x2f,0x75,0x02 }, { 0x81,0x4c,0xf0,0x12 },
+ { 0x8d,0x46,0x97,0xa3 }, { 0x6b,0xd3,0xf9,0xc6 },
+ { 0x03,0x8f,0x5f,0xe7 }, { 0x15,0x92,0x9c,0x95 },
+ { 0xbf,0x6d,0x7a,0xeb }, { 0x95,0x52,0x59,0xda },
+ { 0xd4,0xbe,0x83,0x2d }, { 0x58,0x74,0x21,0xd3 },
+ { 0x49,0xe0,0x69,0x29 }, { 0x8e,0xc9,0xc8,0x44 },
+ { 0x75,0xc2,0x89,0x6a }, { 0xf4,0x8e,0x79,0x78 },
+ { 0x99,0x58,0x3e,0x6b }, { 0x27,0xb9,0x71,0xdd },
+ { 0xbe,0xe1,0x4f,0xb6 }, { 0xf0,0x88,0xad,0x17 },
+ { 0xc9,0x20,0xac,0x66 }, { 0x7d,0xce,0x3a,0xb4 },
+ { 0x63,0xdf,0x4a,0x18 }, { 0xe5,0x1a,0x31,0x82 },
+ { 0x97,0x51,0x33,0x60 }, { 0x62,0x53,0x7f,0x45 },
+ { 0xb1,0x64,0x77,0xe0 }, { 0xbb,0x6b,0xae,0x84 },
+ { 0xfe,0x81,0xa0,0x1c }, { 0xf9,0x08,0x2b,0x94 },
+ { 0x70,0x48,0x68,0x58 }, { 0x8f,0x45,0xfd,0x19 },
+ { 0x94,0xde,0x6c,0x87 }, { 0x52,0x7b,0xf8,0xb7 },
+ { 0xab,0x73,0xd3,0x23 }, { 0x72,0x4b,0x02,0xe2 },
+ { 0xe3,0x1f,0x8f,0x57 }, { 0x66,0x55,0xab,0x2a },
+ { 0xb2,0xeb,0x28,0x07 }, { 0x2f,0xb5,0xc2,0x03 },
+ { 0x86,0xc5,0x7b,0x9a }, { 0xd3,0x37,0x08,0xa5 },
+ { 0x30,0x28,0x87,0xf2 }, { 0x23,0xbf,0xa5,0xb2 },
+ { 0x02,0x03,0x6a,0xba }, { 0xed,0x16,0x82,0x5c },
+ { 0x8a,0xcf,0x1c,0x2b }, { 0xa7,0x79,0xb4,0x92 },
+ { 0xf3,0x07,0xf2,0xf0 }, { 0x4e,0x69,0xe2,0xa1 },
+ { 0x65,0xda,0xf4,0xcd }, { 0x06,0x05,0xbe,0xd5 },
+ { 0xd1,0x34,0x62,0x1f }, { 0xc4,0xa6,0xfe,0x8a },
+ { 0x34,0x2e,0x53,0x9d }, { 0xa2,0xf3,0x55,0xa0 },
+ { 0x05,0x8a,0xe1,0x32 }, { 0xa4,0xf6,0xeb,0x75 },
+ { 0x0b,0x83,0xec,0x39 }, { 0x40,0x60,0xef,0xaa },
+ { 0x5e,0x71,0x9f,0x06 }, { 0xbd,0x6e,0x10,0x51 },
+ { 0x3e,0x21,0x8a,0xf9 }, { 0x96,0xdd,0x06,0x3d },
+ { 0xdd,0x3e,0x05,0xae }, { 0x4d,0xe6,0xbd,0x46 },
+ { 0x91,0x54,0x8d,0xb5 }, { 0x71,0xc4,0x5d,0x05 },
+ { 0x04,0x06,0xd4,0x6f }, { 0x60,0x50,0x15,0xff },
+ { 0x19,0x98,0xfb,0x24 }, { 0xd6,0xbd,0xe9,0x97 },
+ { 0x89,0x40,0x43,0xcc }, { 0x67,0xd9,0x9e,0x77 },
+ { 0xb0,0xe8,0x42,0xbd }, { 0x07,0x89,0x8b,0x88 },
+ { 0xe7,0x19,0x5b,0x38 }, { 0x79,0xc8,0xee,0xdb },
+ { 0xa1,0x7c,0x0a,0x47 }, { 0x7c,0x42,0x0f,0xe9 },
+ { 0xf8,0x84,0x1e,0xc9 }, { 0x00,0x00,0x00,0x00 },
+ { 0x09,0x80,0x86,0x83 }, { 0x32,0x2b,0xed,0x48 },
+ { 0x1e,0x11,0x70,0xac }, { 0x6c,0x5a,0x72,0x4e },
+ { 0xfd,0x0e,0xff,0xfb }, { 0x0f,0x85,0x38,0x56 },
+ { 0x3d,0xae,0xd5,0x1e }, { 0x36,0x2d,0x39,0x27 },
+ { 0x0a,0x0f,0xd9,0x64 }, { 0x68,0x5c,0xa6,0x21 },
+ { 0x9b,0x5b,0x54,0xd1 }, { 0x24,0x36,0x2e,0x3a },
+ { 0x0c,0x0a,0x67,0xb1 }, { 0x93,0x57,0xe7,0x0f },
+ { 0xb4,0xee,0x96,0xd2 }, { 0x1b,0x9b,0x91,0x9e },
+ { 0x80,0xc0,0xc5,0x4f }, { 0x61,0xdc,0x20,0xa2 },
+ { 0x5a,0x77,0x4b,0x69 }, { 0x1c,0x12,0x1a,0x16 },
+ { 0xe2,0x93,0xba,0x0a }, { 0xc0,0xa0,0x2a,0xe5 },
+ { 0x3c,0x22,0xe0,0x43 }, { 0x12,0x1b,0x17,0x1d },
+ { 0x0e,0x09,0x0d,0x0b }, { 0xf2,0x8b,0xc7,0xad },
+ { 0x2d,0xb6,0xa8,0xb9 }, { 0x14,0x1e,0xa9,0xc8 },
+ { 0x57,0xf1,0x19,0x85 }, { 0xaf,0x75,0x07,0x4c },
+ { 0xee,0x99,0xdd,0xbb }, { 0xa3,0x7f,0x60,0xfd },
+ { 0xf7,0x01,0x26,0x9f }, { 0x5c,0x72,0xf5,0xbc },
+ { 0x44,0x66,0x3b,0xc5 }, { 0x5b,0xfb,0x7e,0x34 },
+ { 0x8b,0x43,0x29,0x76 }, { 0xcb,0x23,0xc6,0xdc },
+ { 0xb6,0xed,0xfc,0x68 }, { 0xb8,0xe4,0xf1,0x63 },
+ { 0xd7,0x31,0xdc,0xca }, { 0x42,0x63,0x85,0x10 },
+ { 0x13,0x97,0x22,0x40 }, { 0x84,0xc6,0x11,0x20 },
+ { 0x85,0x4a,0x24,0x7d }, { 0xd2,0xbb,0x3d,0xf8 },
+ { 0xae,0xf9,0x32,0x11 }, { 0xc7,0x29,0xa1,0x6d },
+ { 0x1d,0x9e,0x2f,0x4b }, { 0xdc,0xb2,0x30,0xf3 },
+ { 0x0d,0x86,0x52,0xec }, { 0x77,0xc1,0xe3,0xd0 },
+ { 0x2b,0xb3,0x16,0x6c }, { 0xa9,0x70,0xb9,0x99 },
+ { 0x11,0x94,0x48,0xfa }, { 0x47,0xe9,0x64,0x22 },
+ { 0xa8,0xfc,0x8c,0xc4 }, { 0xa0,0xf0,0x3f,0x1a },
+ { 0x56,0x7d,0x2c,0xd8 }, { 0x22,0x33,0x90,0xef },
+ { 0x87,0x49,0x4e,0xc7 }, { 0xd9,0x38,0xd1,0xc1 },
+ { 0x8c,0xca,0xa2,0xfe }, { 0x98,0xd4,0x0b,0x36 },
+ { 0xa6,0xf5,0x81,0xcf }, { 0xa5,0x7a,0xde,0x28 },
+ { 0xda,0xb7,0x8e,0x26 }, { 0x3f,0xad,0xbf,0xa4 },
+ { 0x2c,0x3a,0x9d,0xe4 }, { 0x50,0x78,0x92,0x0d },
+ { 0x6a,0x5f,0xcc,0x9b }, { 0x54,0x7e,0x46,0x62 },
+ { 0xf6,0x8d,0x13,0xc2 }, { 0x90,0xd8,0xb8,0xe8 },
+ { 0x2e,0x39,0xf7,0x5e }, { 0x82,0xc3,0xaf,0xf5 },
+ { 0x9f,0x5d,0x80,0xbe }, { 0x69,0xd0,0x93,0x7c },
+ { 0x6f,0xd5,0x2d,0xa9 }, { 0xcf,0x25,0x12,0xb3 },
+ { 0xc8,0xac,0x99,0x3b }, { 0x10,0x18,0x7d,0xa7 },
+ { 0xe8,0x9c,0x63,0x6e }, { 0xdb,0x3b,0xbb,0x7b },
+ { 0xcd,0x26,0x78,0x09 }, { 0x6e,0x59,0x18,0xf4 },
+ { 0xec,0x9a,0xb7,0x01 }, { 0x83,0x4f,0x9a,0xa8 },
+ { 0xe6,0x95,0x6e,0x65 }, { 0xaa,0xff,0xe6,0x7e },
+ { 0x21,0xbc,0xcf,0x08 }, { 0xef,0x15,0xe8,0xe6 },
+ { 0xba,0xe7,0x9b,0xd9 }, { 0x4a,0x6f,0x36,0xce },
+ { 0xea,0x9f,0x09,0xd4 }, { 0x29,0xb0,0x7c,0xd6 },
+ { 0x31,0xa4,0xb2,0xaf }, { 0x2a,0x3f,0x23,0x31 },
+ { 0xc6,0xa5,0x94,0x30 }, { 0x35,0xa2,0x66,0xc0 },
+ { 0x74,0x4e,0xbc,0x37 }, { 0xfc,0x82,0xca,0xa6 },
+ { 0xe0,0x90,0xd0,0xb0 }, { 0x33,0xa7,0xd8,0x15 },
+ { 0xf1,0x04,0x98,0x4a }, { 0x41,0xec,0xda,0xf7 },
+ { 0x7f,0xcd,0x50,0x0e }, { 0x17,0x91,0xf6,0x2f },
+ { 0x76,0x4d,0xd6,0x8d }, { 0x43,0xef,0xb0,0x4d },
+ { 0xcc,0xaa,0x4d,0x54 }, { 0xe4,0x96,0x04,0xdf },
+ { 0x9e,0xd1,0xb5,0xe3 }, { 0x4c,0x6a,0x88,0x1b },
+ { 0xc1,0x2c,0x1f,0xb8 }, { 0x46,0x65,0x51,0x7f },
+ { 0x9d,0x5e,0xea,0x04 }, { 0x01,0x8c,0x35,0x5d },
+ { 0xfa,0x87,0x74,0x73 }, { 0xfb,0x0b,0x41,0x2e },
+ { 0xb3,0x67,0x1d,0x5a }, { 0x92,0xdb,0xd2,0x52 },
+ { 0xe9,0x10,0x56,0x33 }, { 0x6d,0xd6,0x47,0x13 },
+ { 0x9a,0xd7,0x61,0x8c }, { 0x37,0xa1,0x0c,0x7a },
+ { 0x59,0xf8,0x14,0x8e }, { 0xeb,0x13,0x3c,0x89 },
+ { 0xce,0xa9,0x27,0xee }, { 0xb7,0x61,0xc9,0x35 },
+ { 0xe1,0x1c,0xe5,0xed }, { 0x7a,0x47,0xb1,0x3c },
+ { 0x9c,0xd2,0xdf,0x59 }, { 0x55,0xf2,0x73,0x3f },
+ { 0x18,0x14,0xce,0x79 }, { 0x73,0xc7,0x37,0xbf },
+ { 0x53,0xf7,0xcd,0xea }, { 0x5f,0xfd,0xaa,0x5b },
+ { 0xdf,0x3d,0x6f,0x14 }, { 0x78,0x44,0xdb,0x86 },
+ { 0xca,0xaf,0xf3,0x81 }, { 0xb9,0x68,0xc4,0x3e },
+ { 0x38,0x24,0x34,0x2c }, { 0xc2,0xa3,0x40,0x5f },
+ { 0x16,0x1d,0xc3,0x72 }, { 0xbc,0xe2,0x25,0x0c },
+ { 0x28,0x3c,0x49,0x8b }, { 0xff,0x0d,0x95,0x41 },
+ { 0x39,0xa8,0x01,0x71 }, { 0x08,0x0c,0xb3,0xde },
+ { 0xd8,0xb4,0xe4,0x9c }, { 0x64,0x56,0xc1,0x90 },
+ { 0x7b,0xcb,0x84,0x61 }, { 0xd5,0x32,0xb6,0x70 },
+ { 0x48,0x6c,0x5c,0x74 }, { 0xd0,0xb8,0x57,0x42 }
+ };
+
+static const unsigned char T6[256][4] =
+ {
+ { 0x50,0x51,0xf4,0xa7 }, { 0x53,0x7e,0x41,0x65 },
+ { 0xc3,0x1a,0x17,0xa4 }, { 0x96,0x3a,0x27,0x5e },
+ { 0xcb,0x3b,0xab,0x6b }, { 0xf1,0x1f,0x9d,0x45 },
+ { 0xab,0xac,0xfa,0x58 }, { 0x93,0x4b,0xe3,0x03 },
+ { 0x55,0x20,0x30,0xfa }, { 0xf6,0xad,0x76,0x6d },
+ { 0x91,0x88,0xcc,0x76 }, { 0x25,0xf5,0x02,0x4c },
+ { 0xfc,0x4f,0xe5,0xd7 }, { 0xd7,0xc5,0x2a,0xcb },
+ { 0x80,0x26,0x35,0x44 }, { 0x8f,0xb5,0x62,0xa3 },
+ { 0x49,0xde,0xb1,0x5a }, { 0x67,0x25,0xba,0x1b },
+ { 0x98,0x45,0xea,0x0e }, { 0xe1,0x5d,0xfe,0xc0 },
+ { 0x02,0xc3,0x2f,0x75 }, { 0x12,0x81,0x4c,0xf0 },
+ { 0xa3,0x8d,0x46,0x97 }, { 0xc6,0x6b,0xd3,0xf9 },
+ { 0xe7,0x03,0x8f,0x5f }, { 0x95,0x15,0x92,0x9c },
+ { 0xeb,0xbf,0x6d,0x7a }, { 0xda,0x95,0x52,0x59 },
+ { 0x2d,0xd4,0xbe,0x83 }, { 0xd3,0x58,0x74,0x21 },
+ { 0x29,0x49,0xe0,0x69 }, { 0x44,0x8e,0xc9,0xc8 },
+ { 0x6a,0x75,0xc2,0x89 }, { 0x78,0xf4,0x8e,0x79 },
+ { 0x6b,0x99,0x58,0x3e }, { 0xdd,0x27,0xb9,0x71 },
+ { 0xb6,0xbe,0xe1,0x4f }, { 0x17,0xf0,0x88,0xad },
+ { 0x66,0xc9,0x20,0xac }, { 0xb4,0x7d,0xce,0x3a },
+ { 0x18,0x63,0xdf,0x4a }, { 0x82,0xe5,0x1a,0x31 },
+ { 0x60,0x97,0x51,0x33 }, { 0x45,0x62,0x53,0x7f },
+ { 0xe0,0xb1,0x64,0x77 }, { 0x84,0xbb,0x6b,0xae },
+ { 0x1c,0xfe,0x81,0xa0 }, { 0x94,0xf9,0x08,0x2b },
+ { 0x58,0x70,0x48,0x68 }, { 0x19,0x8f,0x45,0xfd },
+ { 0x87,0x94,0xde,0x6c }, { 0xb7,0x52,0x7b,0xf8 },
+ { 0x23,0xab,0x73,0xd3 }, { 0xe2,0x72,0x4b,0x02 },
+ { 0x57,0xe3,0x1f,0x8f }, { 0x2a,0x66,0x55,0xab },
+ { 0x07,0xb2,0xeb,0x28 }, { 0x03,0x2f,0xb5,0xc2 },
+ { 0x9a,0x86,0xc5,0x7b }, { 0xa5,0xd3,0x37,0x08 },
+ { 0xf2,0x30,0x28,0x87 }, { 0xb2,0x23,0xbf,0xa5 },
+ { 0xba,0x02,0x03,0x6a }, { 0x5c,0xed,0x16,0x82 },
+ { 0x2b,0x8a,0xcf,0x1c }, { 0x92,0xa7,0x79,0xb4 },
+ { 0xf0,0xf3,0x07,0xf2 }, { 0xa1,0x4e,0x69,0xe2 },
+ { 0xcd,0x65,0xda,0xf4 }, { 0xd5,0x06,0x05,0xbe },
+ { 0x1f,0xd1,0x34,0x62 }, { 0x8a,0xc4,0xa6,0xfe },
+ { 0x9d,0x34,0x2e,0x53 }, { 0xa0,0xa2,0xf3,0x55 },
+ { 0x32,0x05,0x8a,0xe1 }, { 0x75,0xa4,0xf6,0xeb },
+ { 0x39,0x0b,0x83,0xec }, { 0xaa,0x40,0x60,0xef },
+ { 0x06,0x5e,0x71,0x9f }, { 0x51,0xbd,0x6e,0x10 },
+ { 0xf9,0x3e,0x21,0x8a }, { 0x3d,0x96,0xdd,0x06 },
+ { 0xae,0xdd,0x3e,0x05 }, { 0x46,0x4d,0xe6,0xbd },
+ { 0xb5,0x91,0x54,0x8d }, { 0x05,0x71,0xc4,0x5d },
+ { 0x6f,0x04,0x06,0xd4 }, { 0xff,0x60,0x50,0x15 },
+ { 0x24,0x19,0x98,0xfb }, { 0x97,0xd6,0xbd,0xe9 },
+ { 0xcc,0x89,0x40,0x43 }, { 0x77,0x67,0xd9,0x9e },
+ { 0xbd,0xb0,0xe8,0x42 }, { 0x88,0x07,0x89,0x8b },
+ { 0x38,0xe7,0x19,0x5b }, { 0xdb,0x79,0xc8,0xee },
+ { 0x47,0xa1,0x7c,0x0a }, { 0xe9,0x7c,0x42,0x0f },
+ { 0xc9,0xf8,0x84,0x1e }, { 0x00,0x00,0x00,0x00 },
+ { 0x83,0x09,0x80,0x86 }, { 0x48,0x32,0x2b,0xed },
+ { 0xac,0x1e,0x11,0x70 }, { 0x4e,0x6c,0x5a,0x72 },
+ { 0xfb,0xfd,0x0e,0xff }, { 0x56,0x0f,0x85,0x38 },
+ { 0x1e,0x3d,0xae,0xd5 }, { 0x27,0x36,0x2d,0x39 },
+ { 0x64,0x0a,0x0f,0xd9 }, { 0x21,0x68,0x5c,0xa6 },
+ { 0xd1,0x9b,0x5b,0x54 }, { 0x3a,0x24,0x36,0x2e },
+ { 0xb1,0x0c,0x0a,0x67 }, { 0x0f,0x93,0x57,0xe7 },
+ { 0xd2,0xb4,0xee,0x96 }, { 0x9e,0x1b,0x9b,0x91 },
+ { 0x4f,0x80,0xc0,0xc5 }, { 0xa2,0x61,0xdc,0x20 },
+ { 0x69,0x5a,0x77,0x4b }, { 0x16,0x1c,0x12,0x1a },
+ { 0x0a,0xe2,0x93,0xba }, { 0xe5,0xc0,0xa0,0x2a },
+ { 0x43,0x3c,0x22,0xe0 }, { 0x1d,0x12,0x1b,0x17 },
+ { 0x0b,0x0e,0x09,0x0d }, { 0xad,0xf2,0x8b,0xc7 },
+ { 0xb9,0x2d,0xb6,0xa8 }, { 0xc8,0x14,0x1e,0xa9 },
+ { 0x85,0x57,0xf1,0x19 }, { 0x4c,0xaf,0x75,0x07 },
+ { 0xbb,0xee,0x99,0xdd }, { 0xfd,0xa3,0x7f,0x60 },
+ { 0x9f,0xf7,0x01,0x26 }, { 0xbc,0x5c,0x72,0xf5 },
+ { 0xc5,0x44,0x66,0x3b }, { 0x34,0x5b,0xfb,0x7e },
+ { 0x76,0x8b,0x43,0x29 }, { 0xdc,0xcb,0x23,0xc6 },
+ { 0x68,0xb6,0xed,0xfc }, { 0x63,0xb8,0xe4,0xf1 },
+ { 0xca,0xd7,0x31,0xdc }, { 0x10,0x42,0x63,0x85 },
+ { 0x40,0x13,0x97,0x22 }, { 0x20,0x84,0xc6,0x11 },
+ { 0x7d,0x85,0x4a,0x24 }, { 0xf8,0xd2,0xbb,0x3d },
+ { 0x11,0xae,0xf9,0x32 }, { 0x6d,0xc7,0x29,0xa1 },
+ { 0x4b,0x1d,0x9e,0x2f }, { 0xf3,0xdc,0xb2,0x30 },
+ { 0xec,0x0d,0x86,0x52 }, { 0xd0,0x77,0xc1,0xe3 },
+ { 0x6c,0x2b,0xb3,0x16 }, { 0x99,0xa9,0x70,0xb9 },
+ { 0xfa,0x11,0x94,0x48 }, { 0x22,0x47,0xe9,0x64 },
+ { 0xc4,0xa8,0xfc,0x8c }, { 0x1a,0xa0,0xf0,0x3f },
+ { 0xd8,0x56,0x7d,0x2c }, { 0xef,0x22,0x33,0x90 },
+ { 0xc7,0x87,0x49,0x4e }, { 0xc1,0xd9,0x38,0xd1 },
+ { 0xfe,0x8c,0xca,0xa2 }, { 0x36,0x98,0xd4,0x0b },
+ { 0xcf,0xa6,0xf5,0x81 }, { 0x28,0xa5,0x7a,0xde },
+ { 0x26,0xda,0xb7,0x8e }, { 0xa4,0x3f,0xad,0xbf },
+ { 0xe4,0x2c,0x3a,0x9d }, { 0x0d,0x50,0x78,0x92 },
+ { 0x9b,0x6a,0x5f,0xcc }, { 0x62,0x54,0x7e,0x46 },
+ { 0xc2,0xf6,0x8d,0x13 }, { 0xe8,0x90,0xd8,0xb8 },
+ { 0x5e,0x2e,0x39,0xf7 }, { 0xf5,0x82,0xc3,0xaf },
+ { 0xbe,0x9f,0x5d,0x80 }, { 0x7c,0x69,0xd0,0x93 },
+ { 0xa9,0x6f,0xd5,0x2d }, { 0xb3,0xcf,0x25,0x12 },
+ { 0x3b,0xc8,0xac,0x99 }, { 0xa7,0x10,0x18,0x7d },
+ { 0x6e,0xe8,0x9c,0x63 }, { 0x7b,0xdb,0x3b,0xbb },
+ { 0x09,0xcd,0x26,0x78 }, { 0xf4,0x6e,0x59,0x18 },
+ { 0x01,0xec,0x9a,0xb7 }, { 0xa8,0x83,0x4f,0x9a },
+ { 0x65,0xe6,0x95,0x6e }, { 0x7e,0xaa,0xff,0xe6 },
+ { 0x08,0x21,0xbc,0xcf }, { 0xe6,0xef,0x15,0xe8 },
+ { 0xd9,0xba,0xe7,0x9b }, { 0xce,0x4a,0x6f,0x36 },
+ { 0xd4,0xea,0x9f,0x09 }, { 0xd6,0x29,0xb0,0x7c },
+ { 0xaf,0x31,0xa4,0xb2 }, { 0x31,0x2a,0x3f,0x23 },
+ { 0x30,0xc6,0xa5,0x94 }, { 0xc0,0x35,0xa2,0x66 },
+ { 0x37,0x74,0x4e,0xbc }, { 0xa6,0xfc,0x82,0xca },
+ { 0xb0,0xe0,0x90,0xd0 }, { 0x15,0x33,0xa7,0xd8 },
+ { 0x4a,0xf1,0x04,0x98 }, { 0xf7,0x41,0xec,0xda },
+ { 0x0e,0x7f,0xcd,0x50 }, { 0x2f,0x17,0x91,0xf6 },
+ { 0x8d,0x76,0x4d,0xd6 }, { 0x4d,0x43,0xef,0xb0 },
+ { 0x54,0xcc,0xaa,0x4d }, { 0xdf,0xe4,0x96,0x04 },
+ { 0xe3,0x9e,0xd1,0xb5 }, { 0x1b,0x4c,0x6a,0x88 },
+ { 0xb8,0xc1,0x2c,0x1f }, { 0x7f,0x46,0x65,0x51 },
+ { 0x04,0x9d,0x5e,0xea }, { 0x5d,0x01,0x8c,0x35 },
+ { 0x73,0xfa,0x87,0x74 }, { 0x2e,0xfb,0x0b,0x41 },
+ { 0x5a,0xb3,0x67,0x1d }, { 0x52,0x92,0xdb,0xd2 },
+ { 0x33,0xe9,0x10,0x56 }, { 0x13,0x6d,0xd6,0x47 },
+ { 0x8c,0x9a,0xd7,0x61 }, { 0x7a,0x37,0xa1,0x0c },
+ { 0x8e,0x59,0xf8,0x14 }, { 0x89,0xeb,0x13,0x3c },
+ { 0xee,0xce,0xa9,0x27 }, { 0x35,0xb7,0x61,0xc9 },
+ { 0xed,0xe1,0x1c,0xe5 }, { 0x3c,0x7a,0x47,0xb1 },
+ { 0x59,0x9c,0xd2,0xdf }, { 0x3f,0x55,0xf2,0x73 },
+ { 0x79,0x18,0x14,0xce }, { 0xbf,0x73,0xc7,0x37 },
+ { 0xea,0x53,0xf7,0xcd }, { 0x5b,0x5f,0xfd,0xaa },
+ { 0x14,0xdf,0x3d,0x6f }, { 0x86,0x78,0x44,0xdb },
+ { 0x81,0xca,0xaf,0xf3 }, { 0x3e,0xb9,0x68,0xc4 },
+ { 0x2c,0x38,0x24,0x34 }, { 0x5f,0xc2,0xa3,0x40 },
+ { 0x72,0x16,0x1d,0xc3 }, { 0x0c,0xbc,0xe2,0x25 },
+ { 0x8b,0x28,0x3c,0x49 }, { 0x41,0xff,0x0d,0x95 },
+ { 0x71,0x39,0xa8,0x01 }, { 0xde,0x08,0x0c,0xb3 },
+ { 0x9c,0xd8,0xb4,0xe4 }, { 0x90,0x64,0x56,0xc1 },
+ { 0x61,0x7b,0xcb,0x84 }, { 0x70,0xd5,0x32,0xb6 },
+ { 0x74,0x48,0x6c,0x5c }, { 0x42,0xd0,0xb8,0x57 }
+ };
+
+static const unsigned char T7[256][4] =
+ {
+ { 0xa7,0x50,0x51,0xf4 }, { 0x65,0x53,0x7e,0x41 },
+ { 0xa4,0xc3,0x1a,0x17 }, { 0x5e,0x96,0x3a,0x27 },
+ { 0x6b,0xcb,0x3b,0xab }, { 0x45,0xf1,0x1f,0x9d },
+ { 0x58,0xab,0xac,0xfa }, { 0x03,0x93,0x4b,0xe3 },
+ { 0xfa,0x55,0x20,0x30 }, { 0x6d,0xf6,0xad,0x76 },
+ { 0x76,0x91,0x88,0xcc }, { 0x4c,0x25,0xf5,0x02 },
+ { 0xd7,0xfc,0x4f,0xe5 }, { 0xcb,0xd7,0xc5,0x2a },
+ { 0x44,0x80,0x26,0x35 }, { 0xa3,0x8f,0xb5,0x62 },
+ { 0x5a,0x49,0xde,0xb1 }, { 0x1b,0x67,0x25,0xba },
+ { 0x0e,0x98,0x45,0xea }, { 0xc0,0xe1,0x5d,0xfe },
+ { 0x75,0x02,0xc3,0x2f }, { 0xf0,0x12,0x81,0x4c },
+ { 0x97,0xa3,0x8d,0x46 }, { 0xf9,0xc6,0x6b,0xd3 },
+ { 0x5f,0xe7,0x03,0x8f }, { 0x9c,0x95,0x15,0x92 },
+ { 0x7a,0xeb,0xbf,0x6d }, { 0x59,0xda,0x95,0x52 },
+ { 0x83,0x2d,0xd4,0xbe }, { 0x21,0xd3,0x58,0x74 },
+ { 0x69,0x29,0x49,0xe0 }, { 0xc8,0x44,0x8e,0xc9 },
+ { 0x89,0x6a,0x75,0xc2 }, { 0x79,0x78,0xf4,0x8e },
+ { 0x3e,0x6b,0x99,0x58 }, { 0x71,0xdd,0x27,0xb9 },
+ { 0x4f,0xb6,0xbe,0xe1 }, { 0xad,0x17,0xf0,0x88 },
+ { 0xac,0x66,0xc9,0x20 }, { 0x3a,0xb4,0x7d,0xce },
+ { 0x4a,0x18,0x63,0xdf }, { 0x31,0x82,0xe5,0x1a },
+ { 0x33,0x60,0x97,0x51 }, { 0x7f,0x45,0x62,0x53 },
+ { 0x77,0xe0,0xb1,0x64 }, { 0xae,0x84,0xbb,0x6b },
+ { 0xa0,0x1c,0xfe,0x81 }, { 0x2b,0x94,0xf9,0x08 },
+ { 0x68,0x58,0x70,0x48 }, { 0xfd,0x19,0x8f,0x45 },
+ { 0x6c,0x87,0x94,0xde }, { 0xf8,0xb7,0x52,0x7b },
+ { 0xd3,0x23,0xab,0x73 }, { 0x02,0xe2,0x72,0x4b },
+ { 0x8f,0x57,0xe3,0x1f }, { 0xab,0x2a,0x66,0x55 },
+ { 0x28,0x07,0xb2,0xeb }, { 0xc2,0x03,0x2f,0xb5 },
+ { 0x7b,0x9a,0x86,0xc5 }, { 0x08,0xa5,0xd3,0x37 },
+ { 0x87,0xf2,0x30,0x28 }, { 0xa5,0xb2,0x23,0xbf },
+ { 0x6a,0xba,0x02,0x03 }, { 0x82,0x5c,0xed,0x16 },
+ { 0x1c,0x2b,0x8a,0xcf }, { 0xb4,0x92,0xa7,0x79 },
+ { 0xf2,0xf0,0xf3,0x07 }, { 0xe2,0xa1,0x4e,0x69 },
+ { 0xf4,0xcd,0x65,0xda }, { 0xbe,0xd5,0x06,0x05 },
+ { 0x62,0x1f,0xd1,0x34 }, { 0xfe,0x8a,0xc4,0xa6 },
+ { 0x53,0x9d,0x34,0x2e }, { 0x55,0xa0,0xa2,0xf3 },
+ { 0xe1,0x32,0x05,0x8a }, { 0xeb,0x75,0xa4,0xf6 },
+ { 0xec,0x39,0x0b,0x83 }, { 0xef,0xaa,0x40,0x60 },
+ { 0x9f,0x06,0x5e,0x71 }, { 0x10,0x51,0xbd,0x6e },
+ { 0x8a,0xf9,0x3e,0x21 }, { 0x06,0x3d,0x96,0xdd },
+ { 0x05,0xae,0xdd,0x3e }, { 0xbd,0x46,0x4d,0xe6 },
+ { 0x8d,0xb5,0x91,0x54 }, { 0x5d,0x05,0x71,0xc4 },
+ { 0xd4,0x6f,0x04,0x06 }, { 0x15,0xff,0x60,0x50 },
+ { 0xfb,0x24,0x19,0x98 }, { 0xe9,0x97,0xd6,0xbd },
+ { 0x43,0xcc,0x89,0x40 }, { 0x9e,0x77,0x67,0xd9 },
+ { 0x42,0xbd,0xb0,0xe8 }, { 0x8b,0x88,0x07,0x89 },
+ { 0x5b,0x38,0xe7,0x19 }, { 0xee,0xdb,0x79,0xc8 },
+ { 0x0a,0x47,0xa1,0x7c }, { 0x0f,0xe9,0x7c,0x42 },
+ { 0x1e,0xc9,0xf8,0x84 }, { 0x00,0x00,0x00,0x00 },
+ { 0x86,0x83,0x09,0x80 }, { 0xed,0x48,0x32,0x2b },
+ { 0x70,0xac,0x1e,0x11 }, { 0x72,0x4e,0x6c,0x5a },
+ { 0xff,0xfb,0xfd,0x0e }, { 0x38,0x56,0x0f,0x85 },
+ { 0xd5,0x1e,0x3d,0xae }, { 0x39,0x27,0x36,0x2d },
+ { 0xd9,0x64,0x0a,0x0f }, { 0xa6,0x21,0x68,0x5c },
+ { 0x54,0xd1,0x9b,0x5b }, { 0x2e,0x3a,0x24,0x36 },
+ { 0x67,0xb1,0x0c,0x0a }, { 0xe7,0x0f,0x93,0x57 },
+ { 0x96,0xd2,0xb4,0xee }, { 0x91,0x9e,0x1b,0x9b },
+ { 0xc5,0x4f,0x80,0xc0 }, { 0x20,0xa2,0x61,0xdc },
+ { 0x4b,0x69,0x5a,0x77 }, { 0x1a,0x16,0x1c,0x12 },
+ { 0xba,0x0a,0xe2,0x93 }, { 0x2a,0xe5,0xc0,0xa0 },
+ { 0xe0,0x43,0x3c,0x22 }, { 0x17,0x1d,0x12,0x1b },
+ { 0x0d,0x0b,0x0e,0x09 }, { 0xc7,0xad,0xf2,0x8b },
+ { 0xa8,0xb9,0x2d,0xb6 }, { 0xa9,0xc8,0x14,0x1e },
+ { 0x19,0x85,0x57,0xf1 }, { 0x07,0x4c,0xaf,0x75 },
+ { 0xdd,0xbb,0xee,0x99 }, { 0x60,0xfd,0xa3,0x7f },
+ { 0x26,0x9f,0xf7,0x01 }, { 0xf5,0xbc,0x5c,0x72 },
+ { 0x3b,0xc5,0x44,0x66 }, { 0x7e,0x34,0x5b,0xfb },
+ { 0x29,0x76,0x8b,0x43 }, { 0xc6,0xdc,0xcb,0x23 },
+ { 0xfc,0x68,0xb6,0xed }, { 0xf1,0x63,0xb8,0xe4 },
+ { 0xdc,0xca,0xd7,0x31 }, { 0x85,0x10,0x42,0x63 },
+ { 0x22,0x40,0x13,0x97 }, { 0x11,0x20,0x84,0xc6 },
+ { 0x24,0x7d,0x85,0x4a }, { 0x3d,0xf8,0xd2,0xbb },
+ { 0x32,0x11,0xae,0xf9 }, { 0xa1,0x6d,0xc7,0x29 },
+ { 0x2f,0x4b,0x1d,0x9e }, { 0x30,0xf3,0xdc,0xb2 },
+ { 0x52,0xec,0x0d,0x86 }, { 0xe3,0xd0,0x77,0xc1 },
+ { 0x16,0x6c,0x2b,0xb3 }, { 0xb9,0x99,0xa9,0x70 },
+ { 0x48,0xfa,0x11,0x94 }, { 0x64,0x22,0x47,0xe9 },
+ { 0x8c,0xc4,0xa8,0xfc }, { 0x3f,0x1a,0xa0,0xf0 },
+ { 0x2c,0xd8,0x56,0x7d }, { 0x90,0xef,0x22,0x33 },
+ { 0x4e,0xc7,0x87,0x49 }, { 0xd1,0xc1,0xd9,0x38 },
+ { 0xa2,0xfe,0x8c,0xca }, { 0x0b,0x36,0x98,0xd4 },
+ { 0x81,0xcf,0xa6,0xf5 }, { 0xde,0x28,0xa5,0x7a },
+ { 0x8e,0x26,0xda,0xb7 }, { 0xbf,0xa4,0x3f,0xad },
+ { 0x9d,0xe4,0x2c,0x3a }, { 0x92,0x0d,0x50,0x78 },
+ { 0xcc,0x9b,0x6a,0x5f }, { 0x46,0x62,0x54,0x7e },
+ { 0x13,0xc2,0xf6,0x8d }, { 0xb8,0xe8,0x90,0xd8 },
+ { 0xf7,0x5e,0x2e,0x39 }, { 0xaf,0xf5,0x82,0xc3 },
+ { 0x80,0xbe,0x9f,0x5d }, { 0x93,0x7c,0x69,0xd0 },
+ { 0x2d,0xa9,0x6f,0xd5 }, { 0x12,0xb3,0xcf,0x25 },
+ { 0x99,0x3b,0xc8,0xac }, { 0x7d,0xa7,0x10,0x18 },
+ { 0x63,0x6e,0xe8,0x9c }, { 0xbb,0x7b,0xdb,0x3b },
+ { 0x78,0x09,0xcd,0x26 }, { 0x18,0xf4,0x6e,0x59 },
+ { 0xb7,0x01,0xec,0x9a }, { 0x9a,0xa8,0x83,0x4f },
+ { 0x6e,0x65,0xe6,0x95 }, { 0xe6,0x7e,0xaa,0xff },
+ { 0xcf,0x08,0x21,0xbc }, { 0xe8,0xe6,0xef,0x15 },
+ { 0x9b,0xd9,0xba,0xe7 }, { 0x36,0xce,0x4a,0x6f },
+ { 0x09,0xd4,0xea,0x9f }, { 0x7c,0xd6,0x29,0xb0 },
+ { 0xb2,0xaf,0x31,0xa4 }, { 0x23,0x31,0x2a,0x3f },
+ { 0x94,0x30,0xc6,0xa5 }, { 0x66,0xc0,0x35,0xa2 },
+ { 0xbc,0x37,0x74,0x4e }, { 0xca,0xa6,0xfc,0x82 },
+ { 0xd0,0xb0,0xe0,0x90 }, { 0xd8,0x15,0x33,0xa7 },
+ { 0x98,0x4a,0xf1,0x04 }, { 0xda,0xf7,0x41,0xec },
+ { 0x50,0x0e,0x7f,0xcd }, { 0xf6,0x2f,0x17,0x91 },
+ { 0xd6,0x8d,0x76,0x4d }, { 0xb0,0x4d,0x43,0xef },
+ { 0x4d,0x54,0xcc,0xaa }, { 0x04,0xdf,0xe4,0x96 },
+ { 0xb5,0xe3,0x9e,0xd1 }, { 0x88,0x1b,0x4c,0x6a },
+ { 0x1f,0xb8,0xc1,0x2c }, { 0x51,0x7f,0x46,0x65 },
+ { 0xea,0x04,0x9d,0x5e }, { 0x35,0x5d,0x01,0x8c },
+ { 0x74,0x73,0xfa,0x87 }, { 0x41,0x2e,0xfb,0x0b },
+ { 0x1d,0x5a,0xb3,0x67 }, { 0xd2,0x52,0x92,0xdb },
+ { 0x56,0x33,0xe9,0x10 }, { 0x47,0x13,0x6d,0xd6 },
+ { 0x61,0x8c,0x9a,0xd7 }, { 0x0c,0x7a,0x37,0xa1 },
+ { 0x14,0x8e,0x59,0xf8 }, { 0x3c,0x89,0xeb,0x13 },
+ { 0x27,0xee,0xce,0xa9 }, { 0xc9,0x35,0xb7,0x61 },
+ { 0xe5,0xed,0xe1,0x1c }, { 0xb1,0x3c,0x7a,0x47 },
+ { 0xdf,0x59,0x9c,0xd2 }, { 0x73,0x3f,0x55,0xf2 },
+ { 0xce,0x79,0x18,0x14 }, { 0x37,0xbf,0x73,0xc7 },
+ { 0xcd,0xea,0x53,0xf7 }, { 0xaa,0x5b,0x5f,0xfd },
+ { 0x6f,0x14,0xdf,0x3d }, { 0xdb,0x86,0x78,0x44 },
+ { 0xf3,0x81,0xca,0xaf }, { 0xc4,0x3e,0xb9,0x68 },
+ { 0x34,0x2c,0x38,0x24 }, { 0x40,0x5f,0xc2,0xa3 },
+ { 0xc3,0x72,0x16,0x1d }, { 0x25,0x0c,0xbc,0xe2 },
+ { 0x49,0x8b,0x28,0x3c }, { 0x95,0x41,0xff,0x0d },
+ { 0x01,0x71,0x39,0xa8 }, { 0xb3,0xde,0x08,0x0c },
+ { 0xe4,0x9c,0xd8,0xb4 }, { 0xc1,0x90,0x64,0x56 },
+ { 0x84,0x61,0x7b,0xcb }, { 0xb6,0x70,0xd5,0x32 },
+ { 0x5c,0x74,0x48,0x6c }, { 0x57,0x42,0xd0,0xb8 }
+ };
+
+static const unsigned char T8[256][4] =
+ {
+ { 0xf4,0xa7,0x50,0x51 }, { 0x41,0x65,0x53,0x7e },
+ { 0x17,0xa4,0xc3,0x1a }, { 0x27,0x5e,0x96,0x3a },
+ { 0xab,0x6b,0xcb,0x3b }, { 0x9d,0x45,0xf1,0x1f },
+ { 0xfa,0x58,0xab,0xac }, { 0xe3,0x03,0x93,0x4b },
+ { 0x30,0xfa,0x55,0x20 }, { 0x76,0x6d,0xf6,0xad },
+ { 0xcc,0x76,0x91,0x88 }, { 0x02,0x4c,0x25,0xf5 },
+ { 0xe5,0xd7,0xfc,0x4f }, { 0x2a,0xcb,0xd7,0xc5 },
+ { 0x35,0x44,0x80,0x26 }, { 0x62,0xa3,0x8f,0xb5 },
+ { 0xb1,0x5a,0x49,0xde }, { 0xba,0x1b,0x67,0x25 },
+ { 0xea,0x0e,0x98,0x45 }, { 0xfe,0xc0,0xe1,0x5d },
+ { 0x2f,0x75,0x02,0xc3 }, { 0x4c,0xf0,0x12,0x81 },
+ { 0x46,0x97,0xa3,0x8d }, { 0xd3,0xf9,0xc6,0x6b },
+ { 0x8f,0x5f,0xe7,0x03 }, { 0x92,0x9c,0x95,0x15 },
+ { 0x6d,0x7a,0xeb,0xbf }, { 0x52,0x59,0xda,0x95 },
+ { 0xbe,0x83,0x2d,0xd4 }, { 0x74,0x21,0xd3,0x58 },
+ { 0xe0,0x69,0x29,0x49 }, { 0xc9,0xc8,0x44,0x8e },
+ { 0xc2,0x89,0x6a,0x75 }, { 0x8e,0x79,0x78,0xf4 },
+ { 0x58,0x3e,0x6b,0x99 }, { 0xb9,0x71,0xdd,0x27 },
+ { 0xe1,0x4f,0xb6,0xbe }, { 0x88,0xad,0x17,0xf0 },
+ { 0x20,0xac,0x66,0xc9 }, { 0xce,0x3a,0xb4,0x7d },
+ { 0xdf,0x4a,0x18,0x63 }, { 0x1a,0x31,0x82,0xe5 },
+ { 0x51,0x33,0x60,0x97 }, { 0x53,0x7f,0x45,0x62 },
+ { 0x64,0x77,0xe0,0xb1 }, { 0x6b,0xae,0x84,0xbb },
+ { 0x81,0xa0,0x1c,0xfe }, { 0x08,0x2b,0x94,0xf9 },
+ { 0x48,0x68,0x58,0x70 }, { 0x45,0xfd,0x19,0x8f },
+ { 0xde,0x6c,0x87,0x94 }, { 0x7b,0xf8,0xb7,0x52 },
+ { 0x73,0xd3,0x23,0xab }, { 0x4b,0x02,0xe2,0x72 },
+ { 0x1f,0x8f,0x57,0xe3 }, { 0x55,0xab,0x2a,0x66 },
+ { 0xeb,0x28,0x07,0xb2 }, { 0xb5,0xc2,0x03,0x2f },
+ { 0xc5,0x7b,0x9a,0x86 }, { 0x37,0x08,0xa5,0xd3 },
+ { 0x28,0x87,0xf2,0x30 }, { 0xbf,0xa5,0xb2,0x23 },
+ { 0x03,0x6a,0xba,0x02 }, { 0x16,0x82,0x5c,0xed },
+ { 0xcf,0x1c,0x2b,0x8a }, { 0x79,0xb4,0x92,0xa7 },
+ { 0x07,0xf2,0xf0,0xf3 }, { 0x69,0xe2,0xa1,0x4e },
+ { 0xda,0xf4,0xcd,0x65 }, { 0x05,0xbe,0xd5,0x06 },
+ { 0x34,0x62,0x1f,0xd1 }, { 0xa6,0xfe,0x8a,0xc4 },
+ { 0x2e,0x53,0x9d,0x34 }, { 0xf3,0x55,0xa0,0xa2 },
+ { 0x8a,0xe1,0x32,0x05 }, { 0xf6,0xeb,0x75,0xa4 },
+ { 0x83,0xec,0x39,0x0b }, { 0x60,0xef,0xaa,0x40 },
+ { 0x71,0x9f,0x06,0x5e }, { 0x6e,0x10,0x51,0xbd },
+ { 0x21,0x8a,0xf9,0x3e }, { 0xdd,0x06,0x3d,0x96 },
+ { 0x3e,0x05,0xae,0xdd }, { 0xe6,0xbd,0x46,0x4d },
+ { 0x54,0x8d,0xb5,0x91 }, { 0xc4,0x5d,0x05,0x71 },
+ { 0x06,0xd4,0x6f,0x04 }, { 0x50,0x15,0xff,0x60 },
+ { 0x98,0xfb,0x24,0x19 }, { 0xbd,0xe9,0x97,0xd6 },
+ { 0x40,0x43,0xcc,0x89 }, { 0xd9,0x9e,0x77,0x67 },
+ { 0xe8,0x42,0xbd,0xb0 }, { 0x89,0x8b,0x88,0x07 },
+ { 0x19,0x5b,0x38,0xe7 }, { 0xc8,0xee,0xdb,0x79 },
+ { 0x7c,0x0a,0x47,0xa1 }, { 0x42,0x0f,0xe9,0x7c },
+ { 0x84,0x1e,0xc9,0xf8 }, { 0x00,0x00,0x00,0x00 },
+ { 0x80,0x86,0x83,0x09 }, { 0x2b,0xed,0x48,0x32 },
+ { 0x11,0x70,0xac,0x1e }, { 0x5a,0x72,0x4e,0x6c },
+ { 0x0e,0xff,0xfb,0xfd }, { 0x85,0x38,0x56,0x0f },
+ { 0xae,0xd5,0x1e,0x3d }, { 0x2d,0x39,0x27,0x36 },
+ { 0x0f,0xd9,0x64,0x0a }, { 0x5c,0xa6,0x21,0x68 },
+ { 0x5b,0x54,0xd1,0x9b }, { 0x36,0x2e,0x3a,0x24 },
+ { 0x0a,0x67,0xb1,0x0c }, { 0x57,0xe7,0x0f,0x93 },
+ { 0xee,0x96,0xd2,0xb4 }, { 0x9b,0x91,0x9e,0x1b },
+ { 0xc0,0xc5,0x4f,0x80 }, { 0xdc,0x20,0xa2,0x61 },
+ { 0x77,0x4b,0x69,0x5a }, { 0x12,0x1a,0x16,0x1c },
+ { 0x93,0xba,0x0a,0xe2 }, { 0xa0,0x2a,0xe5,0xc0 },
+ { 0x22,0xe0,0x43,0x3c }, { 0x1b,0x17,0x1d,0x12 },
+ { 0x09,0x0d,0x0b,0x0e }, { 0x8b,0xc7,0xad,0xf2 },
+ { 0xb6,0xa8,0xb9,0x2d }, { 0x1e,0xa9,0xc8,0x14 },
+ { 0xf1,0x19,0x85,0x57 }, { 0x75,0x07,0x4c,0xaf },
+ { 0x99,0xdd,0xbb,0xee }, { 0x7f,0x60,0xfd,0xa3 },
+ { 0x01,0x26,0x9f,0xf7 }, { 0x72,0xf5,0xbc,0x5c },
+ { 0x66,0x3b,0xc5,0x44 }, { 0xfb,0x7e,0x34,0x5b },
+ { 0x43,0x29,0x76,0x8b }, { 0x23,0xc6,0xdc,0xcb },
+ { 0xed,0xfc,0x68,0xb6 }, { 0xe4,0xf1,0x63,0xb8 },
+ { 0x31,0xdc,0xca,0xd7 }, { 0x63,0x85,0x10,0x42 },
+ { 0x97,0x22,0x40,0x13 }, { 0xc6,0x11,0x20,0x84 },
+ { 0x4a,0x24,0x7d,0x85 }, { 0xbb,0x3d,0xf8,0xd2 },
+ { 0xf9,0x32,0x11,0xae }, { 0x29,0xa1,0x6d,0xc7 },
+ { 0x9e,0x2f,0x4b,0x1d }, { 0xb2,0x30,0xf3,0xdc },
+ { 0x86,0x52,0xec,0x0d }, { 0xc1,0xe3,0xd0,0x77 },
+ { 0xb3,0x16,0x6c,0x2b }, { 0x70,0xb9,0x99,0xa9 },
+ { 0x94,0x48,0xfa,0x11 }, { 0xe9,0x64,0x22,0x47 },
+ { 0xfc,0x8c,0xc4,0xa8 }, { 0xf0,0x3f,0x1a,0xa0 },
+ { 0x7d,0x2c,0xd8,0x56 }, { 0x33,0x90,0xef,0x22 },
+ { 0x49,0x4e,0xc7,0x87 }, { 0x38,0xd1,0xc1,0xd9 },
+ { 0xca,0xa2,0xfe,0x8c }, { 0xd4,0x0b,0x36,0x98 },
+ { 0xf5,0x81,0xcf,0xa6 }, { 0x7a,0xde,0x28,0xa5 },
+ { 0xb7,0x8e,0x26,0xda }, { 0xad,0xbf,0xa4,0x3f },
+ { 0x3a,0x9d,0xe4,0x2c }, { 0x78,0x92,0x0d,0x50 },
+ { 0x5f,0xcc,0x9b,0x6a }, { 0x7e,0x46,0x62,0x54 },
+ { 0x8d,0x13,0xc2,0xf6 }, { 0xd8,0xb8,0xe8,0x90 },
+ { 0x39,0xf7,0x5e,0x2e }, { 0xc3,0xaf,0xf5,0x82 },
+ { 0x5d,0x80,0xbe,0x9f }, { 0xd0,0x93,0x7c,0x69 },
+ { 0xd5,0x2d,0xa9,0x6f }, { 0x25,0x12,0xb3,0xcf },
+ { 0xac,0x99,0x3b,0xc8 }, { 0x18,0x7d,0xa7,0x10 },
+ { 0x9c,0x63,0x6e,0xe8 }, { 0x3b,0xbb,0x7b,0xdb },
+ { 0x26,0x78,0x09,0xcd }, { 0x59,0x18,0xf4,0x6e },
+ { 0x9a,0xb7,0x01,0xec }, { 0x4f,0x9a,0xa8,0x83 },
+ { 0x95,0x6e,0x65,0xe6 }, { 0xff,0xe6,0x7e,0xaa },
+ { 0xbc,0xcf,0x08,0x21 }, { 0x15,0xe8,0xe6,0xef },
+ { 0xe7,0x9b,0xd9,0xba }, { 0x6f,0x36,0xce,0x4a },
+ { 0x9f,0x09,0xd4,0xea }, { 0xb0,0x7c,0xd6,0x29 },
+ { 0xa4,0xb2,0xaf,0x31 }, { 0x3f,0x23,0x31,0x2a },
+ { 0xa5,0x94,0x30,0xc6 }, { 0xa2,0x66,0xc0,0x35 },
+ { 0x4e,0xbc,0x37,0x74 }, { 0x82,0xca,0xa6,0xfc },
+ { 0x90,0xd0,0xb0,0xe0 }, { 0xa7,0xd8,0x15,0x33 },
+ { 0x04,0x98,0x4a,0xf1 }, { 0xec,0xda,0xf7,0x41 },
+ { 0xcd,0x50,0x0e,0x7f }, { 0x91,0xf6,0x2f,0x17 },
+ { 0x4d,0xd6,0x8d,0x76 }, { 0xef,0xb0,0x4d,0x43 },
+ { 0xaa,0x4d,0x54,0xcc }, { 0x96,0x04,0xdf,0xe4 },
+ { 0xd1,0xb5,0xe3,0x9e }, { 0x6a,0x88,0x1b,0x4c },
+ { 0x2c,0x1f,0xb8,0xc1 }, { 0x65,0x51,0x7f,0x46 },
+ { 0x5e,0xea,0x04,0x9d }, { 0x8c,0x35,0x5d,0x01 },
+ { 0x87,0x74,0x73,0xfa }, { 0x0b,0x41,0x2e,0xfb },
+ { 0x67,0x1d,0x5a,0xb3 }, { 0xdb,0xd2,0x52,0x92 },
+ { 0x10,0x56,0x33,0xe9 }, { 0xd6,0x47,0x13,0x6d },
+ { 0xd7,0x61,0x8c,0x9a }, { 0xa1,0x0c,0x7a,0x37 },
+ { 0xf8,0x14,0x8e,0x59 }, { 0x13,0x3c,0x89,0xeb },
+ { 0xa9,0x27,0xee,0xce }, { 0x61,0xc9,0x35,0xb7 },
+ { 0x1c,0xe5,0xed,0xe1 }, { 0x47,0xb1,0x3c,0x7a },
+ { 0xd2,0xdf,0x59,0x9c }, { 0xf2,0x73,0x3f,0x55 },
+ { 0x14,0xce,0x79,0x18 }, { 0xc7,0x37,0xbf,0x73 },
+ { 0xf7,0xcd,0xea,0x53 }, { 0xfd,0xaa,0x5b,0x5f },
+ { 0x3d,0x6f,0x14,0xdf }, { 0x44,0xdb,0x86,0x78 },
+ { 0xaf,0xf3,0x81,0xca }, { 0x68,0xc4,0x3e,0xb9 },
+ { 0x24,0x34,0x2c,0x38 }, { 0xa3,0x40,0x5f,0xc2 },
+ { 0x1d,0xc3,0x72,0x16 }, { 0xe2,0x25,0x0c,0xbc },
+ { 0x3c,0x49,0x8b,0x28 }, { 0x0d,0x95,0x41,0xff },
+ { 0xa8,0x01,0x71,0x39 }, { 0x0c,0xb3,0xde,0x08 },
+ { 0xb4,0xe4,0x9c,0xd8 }, { 0x56,0xc1,0x90,0x64 },
+ { 0xcb,0x84,0x61,0x7b }, { 0x32,0xb6,0x70,0xd5 },
+ { 0x6c,0x5c,0x74,0x48 }, { 0xb8,0x57,0x42,0xd0 }
+ };
+
+static const unsigned char S5[256] =
+ {
+ 0x52,0x09,0x6a,0xd5,0x30,0x36,0xa5,0x38,
+ 0xbf,0x40,0xa3,0x9e,0x81,0xf3,0xd7,0xfb,
+ 0x7c,0xe3,0x39,0x82,0x9b,0x2f,0xff,0x87,
+ 0x34,0x8e,0x43,0x44,0xc4,0xde,0xe9,0xcb,
+ 0x54,0x7b,0x94,0x32,0xa6,0xc2,0x23,0x3d,
+ 0xee,0x4c,0x95,0x0b,0x42,0xfa,0xc3,0x4e,
+ 0x08,0x2e,0xa1,0x66,0x28,0xd9,0x24,0xb2,
+ 0x76,0x5b,0xa2,0x49,0x6d,0x8b,0xd1,0x25,
+ 0x72,0xf8,0xf6,0x64,0x86,0x68,0x98,0x16,
+ 0xd4,0xa4,0x5c,0xcc,0x5d,0x65,0xb6,0x92,
+ 0x6c,0x70,0x48,0x50,0xfd,0xed,0xb9,0xda,
+ 0x5e,0x15,0x46,0x57,0xa7,0x8d,0x9d,0x84,
+ 0x90,0xd8,0xab,0x00,0x8c,0xbc,0xd3,0x0a,
+ 0xf7,0xe4,0x58,0x05,0xb8,0xb3,0x45,0x06,
+ 0xd0,0x2c,0x1e,0x8f,0xca,0x3f,0x0f,0x02,
+ 0xc1,0xaf,0xbd,0x03,0x01,0x13,0x8a,0x6b,
+ 0x3a,0x91,0x11,0x41,0x4f,0x67,0xdc,0xea,
+ 0x97,0xf2,0xcf,0xce,0xf0,0xb4,0xe6,0x73,
+ 0x96,0xac,0x74,0x22,0xe7,0xad,0x35,0x85,
+ 0xe2,0xf9,0x37,0xe8,0x1c,0x75,0xdf,0x6e,
+ 0x47,0xf1,0x1a,0x71,0x1d,0x29,0xc5,0x89,
+ 0x6f,0xb7,0x62,0x0e,0xaa,0x18,0xbe,0x1b,
+ 0xfc,0x56,0x3e,0x4b,0xc6,0xd2,0x79,0x20,
+ 0x9a,0xdb,0xc0,0xfe,0x78,0xcd,0x5a,0xf4,
+ 0x1f,0xdd,0xa8,0x33,0x88,0x07,0xc7,0x31,
+ 0xb1,0x12,0x10,0x59,0x27,0x80,0xec,0x5f,
+ 0x60,0x51,0x7f,0xa9,0x19,0xb5,0x4a,0x0d,
+ 0x2d,0xe5,0x7a,0x9f,0x93,0xc9,0x9c,0xef,
+ 0xa0,0xe0,0x3b,0x4d,0xae,0x2a,0xf5,0xb0,
+ 0xc8,0xeb,0xbb,0x3c,0x83,0x53,0x99,0x61,
+ 0x17,0x2b,0x04,0x7e,0xba,0x77,0xd6,0x26,
+ 0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d
+ };
+
+static const unsigned char U1[256][4] =
+ {
+ { 0x00,0x00,0x00,0x00 }, { 0x0e,0x09,0x0d,0x0b },
+ { 0x1c,0x12,0x1a,0x16 }, { 0x12,0x1b,0x17,0x1d },
+ { 0x38,0x24,0x34,0x2c }, { 0x36,0x2d,0x39,0x27 },
+ { 0x24,0x36,0x2e,0x3a }, { 0x2a,0x3f,0x23,0x31 },
+ { 0x70,0x48,0x68,0x58 }, { 0x7e,0x41,0x65,0x53 },
+ { 0x6c,0x5a,0x72,0x4e }, { 0x62,0x53,0x7f,0x45 },
+ { 0x48,0x6c,0x5c,0x74 }, { 0x46,0x65,0x51,0x7f },
+ { 0x54,0x7e,0x46,0x62 }, { 0x5a,0x77,0x4b,0x69 },
+ { 0xe0,0x90,0xd0,0xb0 }, { 0xee,0x99,0xdd,0xbb },
+ { 0xfc,0x82,0xca,0xa6 }, { 0xf2,0x8b,0xc7,0xad },
+ { 0xd8,0xb4,0xe4,0x9c }, { 0xd6,0xbd,0xe9,0x97 },
+ { 0xc4,0xa6,0xfe,0x8a }, { 0xca,0xaf,0xf3,0x81 },
+ { 0x90,0xd8,0xb8,0xe8 }, { 0x9e,0xd1,0xb5,0xe3 },
+ { 0x8c,0xca,0xa2,0xfe }, { 0x82,0xc3,0xaf,0xf5 },
+ { 0xa8,0xfc,0x8c,0xc4 }, { 0xa6,0xf5,0x81,0xcf },
+ { 0xb4,0xee,0x96,0xd2 }, { 0xba,0xe7,0x9b,0xd9 },
+ { 0xdb,0x3b,0xbb,0x7b }, { 0xd5,0x32,0xb6,0x70 },
+ { 0xc7,0x29,0xa1,0x6d }, { 0xc9,0x20,0xac,0x66 },
+ { 0xe3,0x1f,0x8f,0x57 }, { 0xed,0x16,0x82,0x5c },
+ { 0xff,0x0d,0x95,0x41 }, { 0xf1,0x04,0x98,0x4a },
+ { 0xab,0x73,0xd3,0x23 }, { 0xa5,0x7a,0xde,0x28 },
+ { 0xb7,0x61,0xc9,0x35 }, { 0xb9,0x68,0xc4,0x3e },
+ { 0x93,0x57,0xe7,0x0f }, { 0x9d,0x5e,0xea,0x04 },
+ { 0x8f,0x45,0xfd,0x19 }, { 0x81,0x4c,0xf0,0x12 },
+ { 0x3b,0xab,0x6b,0xcb }, { 0x35,0xa2,0x66,0xc0 },
+ { 0x27,0xb9,0x71,0xdd }, { 0x29,0xb0,0x7c,0xd6 },
+ { 0x03,0x8f,0x5f,0xe7 }, { 0x0d,0x86,0x52,0xec },
+ { 0x1f,0x9d,0x45,0xf1 }, { 0x11,0x94,0x48,0xfa },
+ { 0x4b,0xe3,0x03,0x93 }, { 0x45,0xea,0x0e,0x98 },
+ { 0x57,0xf1,0x19,0x85 }, { 0x59,0xf8,0x14,0x8e },
+ { 0x73,0xc7,0x37,0xbf }, { 0x7d,0xce,0x3a,0xb4 },
+ { 0x6f,0xd5,0x2d,0xa9 }, { 0x61,0xdc,0x20,0xa2 },
+ { 0xad,0x76,0x6d,0xf6 }, { 0xa3,0x7f,0x60,0xfd },
+ { 0xb1,0x64,0x77,0xe0 }, { 0xbf,0x6d,0x7a,0xeb },
+ { 0x95,0x52,0x59,0xda }, { 0x9b,0x5b,0x54,0xd1 },
+ { 0x89,0x40,0x43,0xcc }, { 0x87,0x49,0x4e,0xc7 },
+ { 0xdd,0x3e,0x05,0xae }, { 0xd3,0x37,0x08,0xa5 },
+ { 0xc1,0x2c,0x1f,0xb8 }, { 0xcf,0x25,0x12,0xb3 },
+ { 0xe5,0x1a,0x31,0x82 }, { 0xeb,0x13,0x3c,0x89 },
+ { 0xf9,0x08,0x2b,0x94 }, { 0xf7,0x01,0x26,0x9f },
+ { 0x4d,0xe6,0xbd,0x46 }, { 0x43,0xef,0xb0,0x4d },
+ { 0x51,0xf4,0xa7,0x50 }, { 0x5f,0xfd,0xaa,0x5b },
+ { 0x75,0xc2,0x89,0x6a }, { 0x7b,0xcb,0x84,0x61 },
+ { 0x69,0xd0,0x93,0x7c }, { 0x67,0xd9,0x9e,0x77 },
+ { 0x3d,0xae,0xd5,0x1e }, { 0x33,0xa7,0xd8,0x15 },
+ { 0x21,0xbc,0xcf,0x08 }, { 0x2f,0xb5,0xc2,0x03 },
+ { 0x05,0x8a,0xe1,0x32 }, { 0x0b,0x83,0xec,0x39 },
+ { 0x19,0x98,0xfb,0x24 }, { 0x17,0x91,0xf6,0x2f },
+ { 0x76,0x4d,0xd6,0x8d }, { 0x78,0x44,0xdb,0x86 },
+ { 0x6a,0x5f,0xcc,0x9b }, { 0x64,0x56,0xc1,0x90 },
+ { 0x4e,0x69,0xe2,0xa1 }, { 0x40,0x60,0xef,0xaa },
+ { 0x52,0x7b,0xf8,0xb7 }, { 0x5c,0x72,0xf5,0xbc },
+ { 0x06,0x05,0xbe,0xd5 }, { 0x08,0x0c,0xb3,0xde },
+ { 0x1a,0x17,0xa4,0xc3 }, { 0x14,0x1e,0xa9,0xc8 },
+ { 0x3e,0x21,0x8a,0xf9 }, { 0x30,0x28,0x87,0xf2 },
+ { 0x22,0x33,0x90,0xef }, { 0x2c,0x3a,0x9d,0xe4 },
+ { 0x96,0xdd,0x06,0x3d }, { 0x98,0xd4,0x0b,0x36 },
+ { 0x8a,0xcf,0x1c,0x2b }, { 0x84,0xc6,0x11,0x20 },
+ { 0xae,0xf9,0x32,0x11 }, { 0xa0,0xf0,0x3f,0x1a },
+ { 0xb2,0xeb,0x28,0x07 }, { 0xbc,0xe2,0x25,0x0c },
+ { 0xe6,0x95,0x6e,0x65 }, { 0xe8,0x9c,0x63,0x6e },
+ { 0xfa,0x87,0x74,0x73 }, { 0xf4,0x8e,0x79,0x78 },
+ { 0xde,0xb1,0x5a,0x49 }, { 0xd0,0xb8,0x57,0x42 },
+ { 0xc2,0xa3,0x40,0x5f }, { 0xcc,0xaa,0x4d,0x54 },
+ { 0x41,0xec,0xda,0xf7 }, { 0x4f,0xe5,0xd7,0xfc },
+ { 0x5d,0xfe,0xc0,0xe1 }, { 0x53,0xf7,0xcd,0xea },
+ { 0x79,0xc8,0xee,0xdb }, { 0x77,0xc1,0xe3,0xd0 },
+ { 0x65,0xda,0xf4,0xcd }, { 0x6b,0xd3,0xf9,0xc6 },
+ { 0x31,0xa4,0xb2,0xaf }, { 0x3f,0xad,0xbf,0xa4 },
+ { 0x2d,0xb6,0xa8,0xb9 }, { 0x23,0xbf,0xa5,0xb2 },
+ { 0x09,0x80,0x86,0x83 }, { 0x07,0x89,0x8b,0x88 },
+ { 0x15,0x92,0x9c,0x95 }, { 0x1b,0x9b,0x91,0x9e },
+ { 0xa1,0x7c,0x0a,0x47 }, { 0xaf,0x75,0x07,0x4c },
+ { 0xbd,0x6e,0x10,0x51 }, { 0xb3,0x67,0x1d,0x5a },
+ { 0x99,0x58,0x3e,0x6b }, { 0x97,0x51,0x33,0x60 },
+ { 0x85,0x4a,0x24,0x7d }, { 0x8b,0x43,0x29,0x76 },
+ { 0xd1,0x34,0x62,0x1f }, { 0xdf,0x3d,0x6f,0x14 },
+ { 0xcd,0x26,0x78,0x09 }, { 0xc3,0x2f,0x75,0x02 },
+ { 0xe9,0x10,0x56,0x33 }, { 0xe7,0x19,0x5b,0x38 },
+ { 0xf5,0x02,0x4c,0x25 }, { 0xfb,0x0b,0x41,0x2e },
+ { 0x9a,0xd7,0x61,0x8c }, { 0x94,0xde,0x6c,0x87 },
+ { 0x86,0xc5,0x7b,0x9a }, { 0x88,0xcc,0x76,0x91 },
+ { 0xa2,0xf3,0x55,0xa0 }, { 0xac,0xfa,0x58,0xab },
+ { 0xbe,0xe1,0x4f,0xb6 }, { 0xb0,0xe8,0x42,0xbd },
+ { 0xea,0x9f,0x09,0xd4 }, { 0xe4,0x96,0x04,0xdf },
+ { 0xf6,0x8d,0x13,0xc2 }, { 0xf8,0x84,0x1e,0xc9 },
+ { 0xd2,0xbb,0x3d,0xf8 }, { 0xdc,0xb2,0x30,0xf3 },
+ { 0xce,0xa9,0x27,0xee }, { 0xc0,0xa0,0x2a,0xe5 },
+ { 0x7a,0x47,0xb1,0x3c }, { 0x74,0x4e,0xbc,0x37 },
+ { 0x66,0x55,0xab,0x2a }, { 0x68,0x5c,0xa6,0x21 },
+ { 0x42,0x63,0x85,0x10 }, { 0x4c,0x6a,0x88,0x1b },
+ { 0x5e,0x71,0x9f,0x06 }, { 0x50,0x78,0x92,0x0d },
+ { 0x0a,0x0f,0xd9,0x64 }, { 0x04,0x06,0xd4,0x6f },
+ { 0x16,0x1d,0xc3,0x72 }, { 0x18,0x14,0xce,0x79 },
+ { 0x32,0x2b,0xed,0x48 }, { 0x3c,0x22,0xe0,0x43 },
+ { 0x2e,0x39,0xf7,0x5e }, { 0x20,0x30,0xfa,0x55 },
+ { 0xec,0x9a,0xb7,0x01 }, { 0xe2,0x93,0xba,0x0a },
+ { 0xf0,0x88,0xad,0x17 }, { 0xfe,0x81,0xa0,0x1c },
+ { 0xd4,0xbe,0x83,0x2d }, { 0xda,0xb7,0x8e,0x26 },
+ { 0xc8,0xac,0x99,0x3b }, { 0xc6,0xa5,0x94,0x30 },
+ { 0x9c,0xd2,0xdf,0x59 }, { 0x92,0xdb,0xd2,0x52 },
+ { 0x80,0xc0,0xc5,0x4f }, { 0x8e,0xc9,0xc8,0x44 },
+ { 0xa4,0xf6,0xeb,0x75 }, { 0xaa,0xff,0xe6,0x7e },
+ { 0xb8,0xe4,0xf1,0x63 }, { 0xb6,0xed,0xfc,0x68 },
+ { 0x0c,0x0a,0x67,0xb1 }, { 0x02,0x03,0x6a,0xba },
+ { 0x10,0x18,0x7d,0xa7 }, { 0x1e,0x11,0x70,0xac },
+ { 0x34,0x2e,0x53,0x9d }, { 0x3a,0x27,0x5e,0x96 },
+ { 0x28,0x3c,0x49,0x8b }, { 0x26,0x35,0x44,0x80 },
+ { 0x7c,0x42,0x0f,0xe9 }, { 0x72,0x4b,0x02,0xe2 },
+ { 0x60,0x50,0x15,0xff }, { 0x6e,0x59,0x18,0xf4 },
+ { 0x44,0x66,0x3b,0xc5 }, { 0x4a,0x6f,0x36,0xce },
+ { 0x58,0x74,0x21,0xd3 }, { 0x56,0x7d,0x2c,0xd8 },
+ { 0x37,0xa1,0x0c,0x7a }, { 0x39,0xa8,0x01,0x71 },
+ { 0x2b,0xb3,0x16,0x6c }, { 0x25,0xba,0x1b,0x67 },
+ { 0x0f,0x85,0x38,0x56 }, { 0x01,0x8c,0x35,0x5d },
+ { 0x13,0x97,0x22,0x40 }, { 0x1d,0x9e,0x2f,0x4b },
+ { 0x47,0xe9,0x64,0x22 }, { 0x49,0xe0,0x69,0x29 },
+ { 0x5b,0xfb,0x7e,0x34 }, { 0x55,0xf2,0x73,0x3f },
+ { 0x7f,0xcd,0x50,0x0e }, { 0x71,0xc4,0x5d,0x05 },
+ { 0x63,0xdf,0x4a,0x18 }, { 0x6d,0xd6,0x47,0x13 },
+ { 0xd7,0x31,0xdc,0xca }, { 0xd9,0x38,0xd1,0xc1 },
+ { 0xcb,0x23,0xc6,0xdc }, { 0xc5,0x2a,0xcb,0xd7 },
+ { 0xef,0x15,0xe8,0xe6 }, { 0xe1,0x1c,0xe5,0xed },
+ { 0xf3,0x07,0xf2,0xf0 }, { 0xfd,0x0e,0xff,0xfb },
+ { 0xa7,0x79,0xb4,0x92 }, { 0xa9,0x70,0xb9,0x99 },
+ { 0xbb,0x6b,0xae,0x84 }, { 0xb5,0x62,0xa3,0x8f },
+ { 0x9f,0x5d,0x80,0xbe }, { 0x91,0x54,0x8d,0xb5 },
+ { 0x83,0x4f,0x9a,0xa8 }, { 0x8d,0x46,0x97,0xa3 }
+ };
+
+static const unsigned char U2[256][4] =
+ {
+ { 0x00,0x00,0x00,0x00 }, { 0x0b,0x0e,0x09,0x0d },
+ { 0x16,0x1c,0x12,0x1a }, { 0x1d,0x12,0x1b,0x17 },
+ { 0x2c,0x38,0x24,0x34 }, { 0x27,0x36,0x2d,0x39 },
+ { 0x3a,0x24,0x36,0x2e }, { 0x31,0x2a,0x3f,0x23 },
+ { 0x58,0x70,0x48,0x68 }, { 0x53,0x7e,0x41,0x65 },
+ { 0x4e,0x6c,0x5a,0x72 }, { 0x45,0x62,0x53,0x7f },
+ { 0x74,0x48,0x6c,0x5c }, { 0x7f,0x46,0x65,0x51 },
+ { 0x62,0x54,0x7e,0x46 }, { 0x69,0x5a,0x77,0x4b },
+ { 0xb0,0xe0,0x90,0xd0 }, { 0xbb,0xee,0x99,0xdd },
+ { 0xa6,0xfc,0x82,0xca }, { 0xad,0xf2,0x8b,0xc7 },
+ { 0x9c,0xd8,0xb4,0xe4 }, { 0x97,0xd6,0xbd,0xe9 },
+ { 0x8a,0xc4,0xa6,0xfe }, { 0x81,0xca,0xaf,0xf3 },
+ { 0xe8,0x90,0xd8,0xb8 }, { 0xe3,0x9e,0xd1,0xb5 },
+ { 0xfe,0x8c,0xca,0xa2 }, { 0xf5,0x82,0xc3,0xaf },
+ { 0xc4,0xa8,0xfc,0x8c }, { 0xcf,0xa6,0xf5,0x81 },
+ { 0xd2,0xb4,0xee,0x96 }, { 0xd9,0xba,0xe7,0x9b },
+ { 0x7b,0xdb,0x3b,0xbb }, { 0x70,0xd5,0x32,0xb6 },
+ { 0x6d,0xc7,0x29,0xa1 }, { 0x66,0xc9,0x20,0xac },
+ { 0x57,0xe3,0x1f,0x8f }, { 0x5c,0xed,0x16,0x82 },
+ { 0x41,0xff,0x0d,0x95 }, { 0x4a,0xf1,0x04,0x98 },
+ { 0x23,0xab,0x73,0xd3 }, { 0x28,0xa5,0x7a,0xde },
+ { 0x35,0xb7,0x61,0xc9 }, { 0x3e,0xb9,0x68,0xc4 },
+ { 0x0f,0x93,0x57,0xe7 }, { 0x04,0x9d,0x5e,0xea },
+ { 0x19,0x8f,0x45,0xfd }, { 0x12,0x81,0x4c,0xf0 },
+ { 0xcb,0x3b,0xab,0x6b }, { 0xc0,0x35,0xa2,0x66 },
+ { 0xdd,0x27,0xb9,0x71 }, { 0xd6,0x29,0xb0,0x7c },
+ { 0xe7,0x03,0x8f,0x5f }, { 0xec,0x0d,0x86,0x52 },
+ { 0xf1,0x1f,0x9d,0x45 }, { 0xfa,0x11,0x94,0x48 },
+ { 0x93,0x4b,0xe3,0x03 }, { 0x98,0x45,0xea,0x0e },
+ { 0x85,0x57,0xf1,0x19 }, { 0x8e,0x59,0xf8,0x14 },
+ { 0xbf,0x73,0xc7,0x37 }, { 0xb4,0x7d,0xce,0x3a },
+ { 0xa9,0x6f,0xd5,0x2d }, { 0xa2,0x61,0xdc,0x20 },
+ { 0xf6,0xad,0x76,0x6d }, { 0xfd,0xa3,0x7f,0x60 },
+ { 0xe0,0xb1,0x64,0x77 }, { 0xeb,0xbf,0x6d,0x7a },
+ { 0xda,0x95,0x52,0x59 }, { 0xd1,0x9b,0x5b,0x54 },
+ { 0xcc,0x89,0x40,0x43 }, { 0xc7,0x87,0x49,0x4e },
+ { 0xae,0xdd,0x3e,0x05 }, { 0xa5,0xd3,0x37,0x08 },
+ { 0xb8,0xc1,0x2c,0x1f }, { 0xb3,0xcf,0x25,0x12 },
+ { 0x82,0xe5,0x1a,0x31 }, { 0x89,0xeb,0x13,0x3c },
+ { 0x94,0xf9,0x08,0x2b }, { 0x9f,0xf7,0x01,0x26 },
+ { 0x46,0x4d,0xe6,0xbd }, { 0x4d,0x43,0xef,0xb0 },
+ { 0x50,0x51,0xf4,0xa7 }, { 0x5b,0x5f,0xfd,0xaa },
+ { 0x6a,0x75,0xc2,0x89 }, { 0x61,0x7b,0xcb,0x84 },
+ { 0x7c,0x69,0xd0,0x93 }, { 0x77,0x67,0xd9,0x9e },
+ { 0x1e,0x3d,0xae,0xd5 }, { 0x15,0x33,0xa7,0xd8 },
+ { 0x08,0x21,0xbc,0xcf }, { 0x03,0x2f,0xb5,0xc2 },
+ { 0x32,0x05,0x8a,0xe1 }, { 0x39,0x0b,0x83,0xec },
+ { 0x24,0x19,0x98,0xfb }, { 0x2f,0x17,0x91,0xf6 },
+ { 0x8d,0x76,0x4d,0xd6 }, { 0x86,0x78,0x44,0xdb },
+ { 0x9b,0x6a,0x5f,0xcc }, { 0x90,0x64,0x56,0xc1 },
+ { 0xa1,0x4e,0x69,0xe2 }, { 0xaa,0x40,0x60,0xef },
+ { 0xb7,0x52,0x7b,0xf8 }, { 0xbc,0x5c,0x72,0xf5 },
+ { 0xd5,0x06,0x05,0xbe }, { 0xde,0x08,0x0c,0xb3 },
+ { 0xc3,0x1a,0x17,0xa4 }, { 0xc8,0x14,0x1e,0xa9 },
+ { 0xf9,0x3e,0x21,0x8a }, { 0xf2,0x30,0x28,0x87 },
+ { 0xef,0x22,0x33,0x90 }, { 0xe4,0x2c,0x3a,0x9d },
+ { 0x3d,0x96,0xdd,0x06 }, { 0x36,0x98,0xd4,0x0b },
+ { 0x2b,0x8a,0xcf,0x1c }, { 0x20,0x84,0xc6,0x11 },
+ { 0x11,0xae,0xf9,0x32 }, { 0x1a,0xa0,0xf0,0x3f },
+ { 0x07,0xb2,0xeb,0x28 }, { 0x0c,0xbc,0xe2,0x25 },
+ { 0x65,0xe6,0x95,0x6e }, { 0x6e,0xe8,0x9c,0x63 },
+ { 0x73,0xfa,0x87,0x74 }, { 0x78,0xf4,0x8e,0x79 },
+ { 0x49,0xde,0xb1,0x5a }, { 0x42,0xd0,0xb8,0x57 },
+ { 0x5f,0xc2,0xa3,0x40 }, { 0x54,0xcc,0xaa,0x4d },
+ { 0xf7,0x41,0xec,0xda }, { 0xfc,0x4f,0xe5,0xd7 },
+ { 0xe1,0x5d,0xfe,0xc0 }, { 0xea,0x53,0xf7,0xcd },
+ { 0xdb,0x79,0xc8,0xee }, { 0xd0,0x77,0xc1,0xe3 },
+ { 0xcd,0x65,0xda,0xf4 }, { 0xc6,0x6b,0xd3,0xf9 },
+ { 0xaf,0x31,0xa4,0xb2 }, { 0xa4,0x3f,0xad,0xbf },
+ { 0xb9,0x2d,0xb6,0xa8 }, { 0xb2,0x23,0xbf,0xa5 },
+ { 0x83,0x09,0x80,0x86 }, { 0x88,0x07,0x89,0x8b },
+ { 0x95,0x15,0x92,0x9c }, { 0x9e,0x1b,0x9b,0x91 },
+ { 0x47,0xa1,0x7c,0x0a }, { 0x4c,0xaf,0x75,0x07 },
+ { 0x51,0xbd,0x6e,0x10 }, { 0x5a,0xb3,0x67,0x1d },
+ { 0x6b,0x99,0x58,0x3e }, { 0x60,0x97,0x51,0x33 },
+ { 0x7d,0x85,0x4a,0x24 }, { 0x76,0x8b,0x43,0x29 },
+ { 0x1f,0xd1,0x34,0x62 }, { 0x14,0xdf,0x3d,0x6f },
+ { 0x09,0xcd,0x26,0x78 }, { 0x02,0xc3,0x2f,0x75 },
+ { 0x33,0xe9,0x10,0x56 }, { 0x38,0xe7,0x19,0x5b },
+ { 0x25,0xf5,0x02,0x4c }, { 0x2e,0xfb,0x0b,0x41 },
+ { 0x8c,0x9a,0xd7,0x61 }, { 0x87,0x94,0xde,0x6c },
+ { 0x9a,0x86,0xc5,0x7b }, { 0x91,0x88,0xcc,0x76 },
+ { 0xa0,0xa2,0xf3,0x55 }, { 0xab,0xac,0xfa,0x58 },
+ { 0xb6,0xbe,0xe1,0x4f }, { 0xbd,0xb0,0xe8,0x42 },
+ { 0xd4,0xea,0x9f,0x09 }, { 0xdf,0xe4,0x96,0x04 },
+ { 0xc2,0xf6,0x8d,0x13 }, { 0xc9,0xf8,0x84,0x1e },
+ { 0xf8,0xd2,0xbb,0x3d }, { 0xf3,0xdc,0xb2,0x30 },
+ { 0xee,0xce,0xa9,0x27 }, { 0xe5,0xc0,0xa0,0x2a },
+ { 0x3c,0x7a,0x47,0xb1 }, { 0x37,0x74,0x4e,0xbc },
+ { 0x2a,0x66,0x55,0xab }, { 0x21,0x68,0x5c,0xa6 },
+ { 0x10,0x42,0x63,0x85 }, { 0x1b,0x4c,0x6a,0x88 },
+ { 0x06,0x5e,0x71,0x9f }, { 0x0d,0x50,0x78,0x92 },
+ { 0x64,0x0a,0x0f,0xd9 }, { 0x6f,0x04,0x06,0xd4 },
+ { 0x72,0x16,0x1d,0xc3 }, { 0x79,0x18,0x14,0xce },
+ { 0x48,0x32,0x2b,0xed }, { 0x43,0x3c,0x22,0xe0 },
+ { 0x5e,0x2e,0x39,0xf7 }, { 0x55,0x20,0x30,0xfa },
+ { 0x01,0xec,0x9a,0xb7 }, { 0x0a,0xe2,0x93,0xba },
+ { 0x17,0xf0,0x88,0xad }, { 0x1c,0xfe,0x81,0xa0 },
+ { 0x2d,0xd4,0xbe,0x83 }, { 0x26,0xda,0xb7,0x8e },
+ { 0x3b,0xc8,0xac,0x99 }, { 0x30,0xc6,0xa5,0x94 },
+ { 0x59,0x9c,0xd2,0xdf }, { 0x52,0x92,0xdb,0xd2 },
+ { 0x4f,0x80,0xc0,0xc5 }, { 0x44,0x8e,0xc9,0xc8 },
+ { 0x75,0xa4,0xf6,0xeb }, { 0x7e,0xaa,0xff,0xe6 },
+ { 0x63,0xb8,0xe4,0xf1 }, { 0x68,0xb6,0xed,0xfc },
+ { 0xb1,0x0c,0x0a,0x67 }, { 0xba,0x02,0x03,0x6a },
+ { 0xa7,0x10,0x18,0x7d }, { 0xac,0x1e,0x11,0x70 },
+ { 0x9d,0x34,0x2e,0x53 }, { 0x96,0x3a,0x27,0x5e },
+ { 0x8b,0x28,0x3c,0x49 }, { 0x80,0x26,0x35,0x44 },
+ { 0xe9,0x7c,0x42,0x0f }, { 0xe2,0x72,0x4b,0x02 },
+ { 0xff,0x60,0x50,0x15 }, { 0xf4,0x6e,0x59,0x18 },
+ { 0xc5,0x44,0x66,0x3b }, { 0xce,0x4a,0x6f,0x36 },
+ { 0xd3,0x58,0x74,0x21 }, { 0xd8,0x56,0x7d,0x2c },
+ { 0x7a,0x37,0xa1,0x0c }, { 0x71,0x39,0xa8,0x01 },
+ { 0x6c,0x2b,0xb3,0x16 }, { 0x67,0x25,0xba,0x1b },
+ { 0x56,0x0f,0x85,0x38 }, { 0x5d,0x01,0x8c,0x35 },
+ { 0x40,0x13,0x97,0x22 }, { 0x4b,0x1d,0x9e,0x2f },
+ { 0x22,0x47,0xe9,0x64 }, { 0x29,0x49,0xe0,0x69 },
+ { 0x34,0x5b,0xfb,0x7e }, { 0x3f,0x55,0xf2,0x73 },
+ { 0x0e,0x7f,0xcd,0x50 }, { 0x05,0x71,0xc4,0x5d },
+ { 0x18,0x63,0xdf,0x4a }, { 0x13,0x6d,0xd6,0x47 },
+ { 0xca,0xd7,0x31,0xdc }, { 0xc1,0xd9,0x38,0xd1 },
+ { 0xdc,0xcb,0x23,0xc6 }, { 0xd7,0xc5,0x2a,0xcb },
+ { 0xe6,0xef,0x15,0xe8 }, { 0xed,0xe1,0x1c,0xe5 },
+ { 0xf0,0xf3,0x07,0xf2 }, { 0xfb,0xfd,0x0e,0xff },
+ { 0x92,0xa7,0x79,0xb4 }, { 0x99,0xa9,0x70,0xb9 },
+ { 0x84,0xbb,0x6b,0xae }, { 0x8f,0xb5,0x62,0xa3 },
+ { 0xbe,0x9f,0x5d,0x80 }, { 0xb5,0x91,0x54,0x8d },
+ { 0xa8,0x83,0x4f,0x9a }, { 0xa3,0x8d,0x46,0x97 }
+ };
+
+static const unsigned char U3[256][4] =
+ {
+ { 0x00,0x00,0x00,0x00 }, { 0x0d,0x0b,0x0e,0x09 },
+ { 0x1a,0x16,0x1c,0x12 }, { 0x17,0x1d,0x12,0x1b },
+ { 0x34,0x2c,0x38,0x24 }, { 0x39,0x27,0x36,0x2d },
+ { 0x2e,0x3a,0x24,0x36 }, { 0x23,0x31,0x2a,0x3f },
+ { 0x68,0x58,0x70,0x48 }, { 0x65,0x53,0x7e,0x41 },
+ { 0x72,0x4e,0x6c,0x5a }, { 0x7f,0x45,0x62,0x53 },
+ { 0x5c,0x74,0x48,0x6c }, { 0x51,0x7f,0x46,0x65 },
+ { 0x46,0x62,0x54,0x7e }, { 0x4b,0x69,0x5a,0x77 },
+ { 0xd0,0xb0,0xe0,0x90 }, { 0xdd,0xbb,0xee,0x99 },
+ { 0xca,0xa6,0xfc,0x82 }, { 0xc7,0xad,0xf2,0x8b },
+ { 0xe4,0x9c,0xd8,0xb4 }, { 0xe9,0x97,0xd6,0xbd },
+ { 0xfe,0x8a,0xc4,0xa6 }, { 0xf3,0x81,0xca,0xaf },
+ { 0xb8,0xe8,0x90,0xd8 }, { 0xb5,0xe3,0x9e,0xd1 },
+ { 0xa2,0xfe,0x8c,0xca }, { 0xaf,0xf5,0x82,0xc3 },
+ { 0x8c,0xc4,0xa8,0xfc }, { 0x81,0xcf,0xa6,0xf5 },
+ { 0x96,0xd2,0xb4,0xee }, { 0x9b,0xd9,0xba,0xe7 },
+ { 0xbb,0x7b,0xdb,0x3b }, { 0xb6,0x70,0xd5,0x32 },
+ { 0xa1,0x6d,0xc7,0x29 }, { 0xac,0x66,0xc9,0x20 },
+ { 0x8f,0x57,0xe3,0x1f }, { 0x82,0x5c,0xed,0x16 },
+ { 0x95,0x41,0xff,0x0d }, { 0x98,0x4a,0xf1,0x04 },
+ { 0xd3,0x23,0xab,0x73 }, { 0xde,0x28,0xa5,0x7a },
+ { 0xc9,0x35,0xb7,0x61 }, { 0xc4,0x3e,0xb9,0x68 },
+ { 0xe7,0x0f,0x93,0x57 }, { 0xea,0x04,0x9d,0x5e },
+ { 0xfd,0x19,0x8f,0x45 }, { 0xf0,0x12,0x81,0x4c },
+ { 0x6b,0xcb,0x3b,0xab }, { 0x66,0xc0,0x35,0xa2 },
+ { 0x71,0xdd,0x27,0xb9 }, { 0x7c,0xd6,0x29,0xb0 },
+ { 0x5f,0xe7,0x03,0x8f }, { 0x52,0xec,0x0d,0x86 },
+ { 0x45,0xf1,0x1f,0x9d }, { 0x48,0xfa,0x11,0x94 },
+ { 0x03,0x93,0x4b,0xe3 }, { 0x0e,0x98,0x45,0xea },
+ { 0x19,0x85,0x57,0xf1 }, { 0x14,0x8e,0x59,0xf8 },
+ { 0x37,0xbf,0x73,0xc7 }, { 0x3a,0xb4,0x7d,0xce },
+ { 0x2d,0xa9,0x6f,0xd5 }, { 0x20,0xa2,0x61,0xdc },
+ { 0x6d,0xf6,0xad,0x76 }, { 0x60,0xfd,0xa3,0x7f },
+ { 0x77,0xe0,0xb1,0x64 }, { 0x7a,0xeb,0xbf,0x6d },
+ { 0x59,0xda,0x95,0x52 }, { 0x54,0xd1,0x9b,0x5b },
+ { 0x43,0xcc,0x89,0x40 }, { 0x4e,0xc7,0x87,0x49 },
+ { 0x05,0xae,0xdd,0x3e }, { 0x08,0xa5,0xd3,0x37 },
+ { 0x1f,0xb8,0xc1,0x2c }, { 0x12,0xb3,0xcf,0x25 },
+ { 0x31,0x82,0xe5,0x1a }, { 0x3c,0x89,0xeb,0x13 },
+ { 0x2b,0x94,0xf9,0x08 }, { 0x26,0x9f,0xf7,0x01 },
+ { 0xbd,0x46,0x4d,0xe6 }, { 0xb0,0x4d,0x43,0xef },
+ { 0xa7,0x50,0x51,0xf4 }, { 0xaa,0x5b,0x5f,0xfd },
+ { 0x89,0x6a,0x75,0xc2 }, { 0x84,0x61,0x7b,0xcb },
+ { 0x93,0x7c,0x69,0xd0 }, { 0x9e,0x77,0x67,0xd9 },
+ { 0xd5,0x1e,0x3d,0xae }, { 0xd8,0x15,0x33,0xa7 },
+ { 0xcf,0x08,0x21,0xbc }, { 0xc2,0x03,0x2f,0xb5 },
+ { 0xe1,0x32,0x05,0x8a }, { 0xec,0x39,0x0b,0x83 },
+ { 0xfb,0x24,0x19,0x98 }, { 0xf6,0x2f,0x17,0x91 },
+ { 0xd6,0x8d,0x76,0x4d }, { 0xdb,0x86,0x78,0x44 },
+ { 0xcc,0x9b,0x6a,0x5f }, { 0xc1,0x90,0x64,0x56 },
+ { 0xe2,0xa1,0x4e,0x69 }, { 0xef,0xaa,0x40,0x60 },
+ { 0xf8,0xb7,0x52,0x7b }, { 0xf5,0xbc,0x5c,0x72 },
+ { 0xbe,0xd5,0x06,0x05 }, { 0xb3,0xde,0x08,0x0c },
+ { 0xa4,0xc3,0x1a,0x17 }, { 0xa9,0xc8,0x14,0x1e },
+ { 0x8a,0xf9,0x3e,0x21 }, { 0x87,0xf2,0x30,0x28 },
+ { 0x90,0xef,0x22,0x33 }, { 0x9d,0xe4,0x2c,0x3a },
+ { 0x06,0x3d,0x96,0xdd }, { 0x0b,0x36,0x98,0xd4 },
+ { 0x1c,0x2b,0x8a,0xcf }, { 0x11,0x20,0x84,0xc6 },
+ { 0x32,0x11,0xae,0xf9 }, { 0x3f,0x1a,0xa0,0xf0 },
+ { 0x28,0x07,0xb2,0xeb }, { 0x25,0x0c,0xbc,0xe2 },
+ { 0x6e,0x65,0xe6,0x95 }, { 0x63,0x6e,0xe8,0x9c },
+ { 0x74,0x73,0xfa,0x87 }, { 0x79,0x78,0xf4,0x8e },
+ { 0x5a,0x49,0xde,0xb1 }, { 0x57,0x42,0xd0,0xb8 },
+ { 0x40,0x5f,0xc2,0xa3 }, { 0x4d,0x54,0xcc,0xaa },
+ { 0xda,0xf7,0x41,0xec }, { 0xd7,0xfc,0x4f,0xe5 },
+ { 0xc0,0xe1,0x5d,0xfe }, { 0xcd,0xea,0x53,0xf7 },
+ { 0xee,0xdb,0x79,0xc8 }, { 0xe3,0xd0,0x77,0xc1 },
+ { 0xf4,0xcd,0x65,0xda }, { 0xf9,0xc6,0x6b,0xd3 },
+ { 0xb2,0xaf,0x31,0xa4 }, { 0xbf,0xa4,0x3f,0xad },
+ { 0xa8,0xb9,0x2d,0xb6 }, { 0xa5,0xb2,0x23,0xbf },
+ { 0x86,0x83,0x09,0x80 }, { 0x8b,0x88,0x07,0x89 },
+ { 0x9c,0x95,0x15,0x92 }, { 0x91,0x9e,0x1b,0x9b },
+ { 0x0a,0x47,0xa1,0x7c }, { 0x07,0x4c,0xaf,0x75 },
+ { 0x10,0x51,0xbd,0x6e }, { 0x1d,0x5a,0xb3,0x67 },
+ { 0x3e,0x6b,0x99,0x58 }, { 0x33,0x60,0x97,0x51 },
+ { 0x24,0x7d,0x85,0x4a }, { 0x29,0x76,0x8b,0x43 },
+ { 0x62,0x1f,0xd1,0x34 }, { 0x6f,0x14,0xdf,0x3d },
+ { 0x78,0x09,0xcd,0x26 }, { 0x75,0x02,0xc3,0x2f },
+ { 0x56,0x33,0xe9,0x10 }, { 0x5b,0x38,0xe7,0x19 },
+ { 0x4c,0x25,0xf5,0x02 }, { 0x41,0x2e,0xfb,0x0b },
+ { 0x61,0x8c,0x9a,0xd7 }, { 0x6c,0x87,0x94,0xde },
+ { 0x7b,0x9a,0x86,0xc5 }, { 0x76,0x91,0x88,0xcc },
+ { 0x55,0xa0,0xa2,0xf3 }, { 0x58,0xab,0xac,0xfa },
+ { 0x4f,0xb6,0xbe,0xe1 }, { 0x42,0xbd,0xb0,0xe8 },
+ { 0x09,0xd4,0xea,0x9f }, { 0x04,0xdf,0xe4,0x96 },
+ { 0x13,0xc2,0xf6,0x8d }, { 0x1e,0xc9,0xf8,0x84 },
+ { 0x3d,0xf8,0xd2,0xbb }, { 0x30,0xf3,0xdc,0xb2 },
+ { 0x27,0xee,0xce,0xa9 }, { 0x2a,0xe5,0xc0,0xa0 },
+ { 0xb1,0x3c,0x7a,0x47 }, { 0xbc,0x37,0x74,0x4e },
+ { 0xab,0x2a,0x66,0x55 }, { 0xa6,0x21,0x68,0x5c },
+ { 0x85,0x10,0x42,0x63 }, { 0x88,0x1b,0x4c,0x6a },
+ { 0x9f,0x06,0x5e,0x71 }, { 0x92,0x0d,0x50,0x78 },
+ { 0xd9,0x64,0x0a,0x0f }, { 0xd4,0x6f,0x04,0x06 },
+ { 0xc3,0x72,0x16,0x1d }, { 0xce,0x79,0x18,0x14 },
+ { 0xed,0x48,0x32,0x2b }, { 0xe0,0x43,0x3c,0x22 },
+ { 0xf7,0x5e,0x2e,0x39 }, { 0xfa,0x55,0x20,0x30 },
+ { 0xb7,0x01,0xec,0x9a }, { 0xba,0x0a,0xe2,0x93 },
+ { 0xad,0x17,0xf0,0x88 }, { 0xa0,0x1c,0xfe,0x81 },
+ { 0x83,0x2d,0xd4,0xbe }, { 0x8e,0x26,0xda,0xb7 },
+ { 0x99,0x3b,0xc8,0xac }, { 0x94,0x30,0xc6,0xa5 },
+ { 0xdf,0x59,0x9c,0xd2 }, { 0xd2,0x52,0x92,0xdb },
+ { 0xc5,0x4f,0x80,0xc0 }, { 0xc8,0x44,0x8e,0xc9 },
+ { 0xeb,0x75,0xa4,0xf6 }, { 0xe6,0x7e,0xaa,0xff },
+ { 0xf1,0x63,0xb8,0xe4 }, { 0xfc,0x68,0xb6,0xed },
+ { 0x67,0xb1,0x0c,0x0a }, { 0x6a,0xba,0x02,0x03 },
+ { 0x7d,0xa7,0x10,0x18 }, { 0x70,0xac,0x1e,0x11 },
+ { 0x53,0x9d,0x34,0x2e }, { 0x5e,0x96,0x3a,0x27 },
+ { 0x49,0x8b,0x28,0x3c }, { 0x44,0x80,0x26,0x35 },
+ { 0x0f,0xe9,0x7c,0x42 }, { 0x02,0xe2,0x72,0x4b },
+ { 0x15,0xff,0x60,0x50 }, { 0x18,0xf4,0x6e,0x59 },
+ { 0x3b,0xc5,0x44,0x66 }, { 0x36,0xce,0x4a,0x6f },
+ { 0x21,0xd3,0x58,0x74 }, { 0x2c,0xd8,0x56,0x7d },
+ { 0x0c,0x7a,0x37,0xa1 }, { 0x01,0x71,0x39,0xa8 },
+ { 0x16,0x6c,0x2b,0xb3 }, { 0x1b,0x67,0x25,0xba },
+ { 0x38,0x56,0x0f,0x85 }, { 0x35,0x5d,0x01,0x8c },
+ { 0x22,0x40,0x13,0x97 }, { 0x2f,0x4b,0x1d,0x9e },
+ { 0x64,0x22,0x47,0xe9 }, { 0x69,0x29,0x49,0xe0 },
+ { 0x7e,0x34,0x5b,0xfb }, { 0x73,0x3f,0x55,0xf2 },
+ { 0x50,0x0e,0x7f,0xcd }, { 0x5d,0x05,0x71,0xc4 },
+ { 0x4a,0x18,0x63,0xdf }, { 0x47,0x13,0x6d,0xd6 },
+ { 0xdc,0xca,0xd7,0x31 }, { 0xd1,0xc1,0xd9,0x38 },
+ { 0xc6,0xdc,0xcb,0x23 }, { 0xcb,0xd7,0xc5,0x2a },
+ { 0xe8,0xe6,0xef,0x15 }, { 0xe5,0xed,0xe1,0x1c },
+ { 0xf2,0xf0,0xf3,0x07 }, { 0xff,0xfb,0xfd,0x0e },
+ { 0xb4,0x92,0xa7,0x79 }, { 0xb9,0x99,0xa9,0x70 },
+ { 0xae,0x84,0xbb,0x6b }, { 0xa3,0x8f,0xb5,0x62 },
+ { 0x80,0xbe,0x9f,0x5d }, { 0x8d,0xb5,0x91,0x54 },
+ { 0x9a,0xa8,0x83,0x4f }, { 0x97,0xa3,0x8d,0x46 }
+ };
+
+static const unsigned char U4[256][4] =
+ {
+ { 0x00,0x00,0x00,0x00 }, { 0x09,0x0d,0x0b,0x0e },
+ { 0x12,0x1a,0x16,0x1c }, { 0x1b,0x17,0x1d,0x12 },
+ { 0x24,0x34,0x2c,0x38 }, { 0x2d,0x39,0x27,0x36 },
+ { 0x36,0x2e,0x3a,0x24 }, { 0x3f,0x23,0x31,0x2a },
+ { 0x48,0x68,0x58,0x70 }, { 0x41,0x65,0x53,0x7e },
+ { 0x5a,0x72,0x4e,0x6c }, { 0x53,0x7f,0x45,0x62 },
+ { 0x6c,0x5c,0x74,0x48 }, { 0x65,0x51,0x7f,0x46 },
+ { 0x7e,0x46,0x62,0x54 }, { 0x77,0x4b,0x69,0x5a },
+ { 0x90,0xd0,0xb0,0xe0 }, { 0x99,0xdd,0xbb,0xee },
+ { 0x82,0xca,0xa6,0xfc }, { 0x8b,0xc7,0xad,0xf2 },
+ { 0xb4,0xe4,0x9c,0xd8 }, { 0xbd,0xe9,0x97,0xd6 },
+ { 0xa6,0xfe,0x8a,0xc4 }, { 0xaf,0xf3,0x81,0xca },
+ { 0xd8,0xb8,0xe8,0x90 }, { 0xd1,0xb5,0xe3,0x9e },
+ { 0xca,0xa2,0xfe,0x8c }, { 0xc3,0xaf,0xf5,0x82 },
+ { 0xfc,0x8c,0xc4,0xa8 }, { 0xf5,0x81,0xcf,0xa6 },
+ { 0xee,0x96,0xd2,0xb4 }, { 0xe7,0x9b,0xd9,0xba },
+ { 0x3b,0xbb,0x7b,0xdb }, { 0x32,0xb6,0x70,0xd5 },
+ { 0x29,0xa1,0x6d,0xc7 }, { 0x20,0xac,0x66,0xc9 },
+ { 0x1f,0x8f,0x57,0xe3 }, { 0x16,0x82,0x5c,0xed },
+ { 0x0d,0x95,0x41,0xff }, { 0x04,0x98,0x4a,0xf1 },
+ { 0x73,0xd3,0x23,0xab }, { 0x7a,0xde,0x28,0xa5 },
+ { 0x61,0xc9,0x35,0xb7 }, { 0x68,0xc4,0x3e,0xb9 },
+ { 0x57,0xe7,0x0f,0x93 }, { 0x5e,0xea,0x04,0x9d },
+ { 0x45,0xfd,0x19,0x8f }, { 0x4c,0xf0,0x12,0x81 },
+ { 0xab,0x6b,0xcb,0x3b }, { 0xa2,0x66,0xc0,0x35 },
+ { 0xb9,0x71,0xdd,0x27 }, { 0xb0,0x7c,0xd6,0x29 },
+ { 0x8f,0x5f,0xe7,0x03 }, { 0x86,0x52,0xec,0x0d },
+ { 0x9d,0x45,0xf1,0x1f }, { 0x94,0x48,0xfa,0x11 },
+ { 0xe3,0x03,0x93,0x4b }, { 0xea,0x0e,0x98,0x45 },
+ { 0xf1,0x19,0x85,0x57 }, { 0xf8,0x14,0x8e,0x59 },
+ { 0xc7,0x37,0xbf,0x73 }, { 0xce,0x3a,0xb4,0x7d },
+ { 0xd5,0x2d,0xa9,0x6f }, { 0xdc,0x20,0xa2,0x61 },
+ { 0x76,0x6d,0xf6,0xad }, { 0x7f,0x60,0xfd,0xa3 },
+ { 0x64,0x77,0xe0,0xb1 }, { 0x6d,0x7a,0xeb,0xbf },
+ { 0x52,0x59,0xda,0x95 }, { 0x5b,0x54,0xd1,0x9b },
+ { 0x40,0x43,0xcc,0x89 }, { 0x49,0x4e,0xc7,0x87 },
+ { 0x3e,0x05,0xae,0xdd }, { 0x37,0x08,0xa5,0xd3 },
+ { 0x2c,0x1f,0xb8,0xc1 }, { 0x25,0x12,0xb3,0xcf },
+ { 0x1a,0x31,0x82,0xe5 }, { 0x13,0x3c,0x89,0xeb },
+ { 0x08,0x2b,0x94,0xf9 }, { 0x01,0x26,0x9f,0xf7 },
+ { 0xe6,0xbd,0x46,0x4d }, { 0xef,0xb0,0x4d,0x43 },
+ { 0xf4,0xa7,0x50,0x51 }, { 0xfd,0xaa,0x5b,0x5f },
+ { 0xc2,0x89,0x6a,0x75 }, { 0xcb,0x84,0x61,0x7b },
+ { 0xd0,0x93,0x7c,0x69 }, { 0xd9,0x9e,0x77,0x67 },
+ { 0xae,0xd5,0x1e,0x3d }, { 0xa7,0xd8,0x15,0x33 },
+ { 0xbc,0xcf,0x08,0x21 }, { 0xb5,0xc2,0x03,0x2f },
+ { 0x8a,0xe1,0x32,0x05 }, { 0x83,0xec,0x39,0x0b },
+ { 0x98,0xfb,0x24,0x19 }, { 0x91,0xf6,0x2f,0x17 },
+ { 0x4d,0xd6,0x8d,0x76 }, { 0x44,0xdb,0x86,0x78 },
+ { 0x5f,0xcc,0x9b,0x6a }, { 0x56,0xc1,0x90,0x64 },
+ { 0x69,0xe2,0xa1,0x4e }, { 0x60,0xef,0xaa,0x40 },
+ { 0x7b,0xf8,0xb7,0x52 }, { 0x72,0xf5,0xbc,0x5c },
+ { 0x05,0xbe,0xd5,0x06 }, { 0x0c,0xb3,0xde,0x08 },
+ { 0x17,0xa4,0xc3,0x1a }, { 0x1e,0xa9,0xc8,0x14 },
+ { 0x21,0x8a,0xf9,0x3e }, { 0x28,0x87,0xf2,0x30 },
+ { 0x33,0x90,0xef,0x22 }, { 0x3a,0x9d,0xe4,0x2c },
+ { 0xdd,0x06,0x3d,0x96 }, { 0xd4,0x0b,0x36,0x98 },
+ { 0xcf,0x1c,0x2b,0x8a }, { 0xc6,0x11,0x20,0x84 },
+ { 0xf9,0x32,0x11,0xae }, { 0xf0,0x3f,0x1a,0xa0 },
+ { 0xeb,0x28,0x07,0xb2 }, { 0xe2,0x25,0x0c,0xbc },
+ { 0x95,0x6e,0x65,0xe6 }, { 0x9c,0x63,0x6e,0xe8 },
+ { 0x87,0x74,0x73,0xfa }, { 0x8e,0x79,0x78,0xf4 },
+ { 0xb1,0x5a,0x49,0xde }, { 0xb8,0x57,0x42,0xd0 },
+ { 0xa3,0x40,0x5f,0xc2 }, { 0xaa,0x4d,0x54,0xcc },
+ { 0xec,0xda,0xf7,0x41 }, { 0xe5,0xd7,0xfc,0x4f },
+ { 0xfe,0xc0,0xe1,0x5d }, { 0xf7,0xcd,0xea,0x53 },
+ { 0xc8,0xee,0xdb,0x79 }, { 0xc1,0xe3,0xd0,0x77 },
+ { 0xda,0xf4,0xcd,0x65 }, { 0xd3,0xf9,0xc6,0x6b },
+ { 0xa4,0xb2,0xaf,0x31 }, { 0xad,0xbf,0xa4,0x3f },
+ { 0xb6,0xa8,0xb9,0x2d }, { 0xbf,0xa5,0xb2,0x23 },
+ { 0x80,0x86,0x83,0x09 }, { 0x89,0x8b,0x88,0x07 },
+ { 0x92,0x9c,0x95,0x15 }, { 0x9b,0x91,0x9e,0x1b },
+ { 0x7c,0x0a,0x47,0xa1 }, { 0x75,0x07,0x4c,0xaf },
+ { 0x6e,0x10,0x51,0xbd }, { 0x67,0x1d,0x5a,0xb3 },
+ { 0x58,0x3e,0x6b,0x99 }, { 0x51,0x33,0x60,0x97 },
+ { 0x4a,0x24,0x7d,0x85 }, { 0x43,0x29,0x76,0x8b },
+ { 0x34,0x62,0x1f,0xd1 }, { 0x3d,0x6f,0x14,0xdf },
+ { 0x26,0x78,0x09,0xcd }, { 0x2f,0x75,0x02,0xc3 },
+ { 0x10,0x56,0x33,0xe9 }, { 0x19,0x5b,0x38,0xe7 },
+ { 0x02,0x4c,0x25,0xf5 }, { 0x0b,0x41,0x2e,0xfb },
+ { 0xd7,0x61,0x8c,0x9a }, { 0xde,0x6c,0x87,0x94 },
+ { 0xc5,0x7b,0x9a,0x86 }, { 0xcc,0x76,0x91,0x88 },
+ { 0xf3,0x55,0xa0,0xa2 }, { 0xfa,0x58,0xab,0xac },
+ { 0xe1,0x4f,0xb6,0xbe }, { 0xe8,0x42,0xbd,0xb0 },
+ { 0x9f,0x09,0xd4,0xea }, { 0x96,0x04,0xdf,0xe4 },
+ { 0x8d,0x13,0xc2,0xf6 }, { 0x84,0x1e,0xc9,0xf8 },
+ { 0xbb,0x3d,0xf8,0xd2 }, { 0xb2,0x30,0xf3,0xdc },
+ { 0xa9,0x27,0xee,0xce }, { 0xa0,0x2a,0xe5,0xc0 },
+ { 0x47,0xb1,0x3c,0x7a }, { 0x4e,0xbc,0x37,0x74 },
+ { 0x55,0xab,0x2a,0x66 }, { 0x5c,0xa6,0x21,0x68 },
+ { 0x63,0x85,0x10,0x42 }, { 0x6a,0x88,0x1b,0x4c },
+ { 0x71,0x9f,0x06,0x5e }, { 0x78,0x92,0x0d,0x50 },
+ { 0x0f,0xd9,0x64,0x0a }, { 0x06,0xd4,0x6f,0x04 },
+ { 0x1d,0xc3,0x72,0x16 }, { 0x14,0xce,0x79,0x18 },
+ { 0x2b,0xed,0x48,0x32 }, { 0x22,0xe0,0x43,0x3c },
+ { 0x39,0xf7,0x5e,0x2e }, { 0x30,0xfa,0x55,0x20 },
+ { 0x9a,0xb7,0x01,0xec }, { 0x93,0xba,0x0a,0xe2 },
+ { 0x88,0xad,0x17,0xf0 }, { 0x81,0xa0,0x1c,0xfe },
+ { 0xbe,0x83,0x2d,0xd4 }, { 0xb7,0x8e,0x26,0xda },
+ { 0xac,0x99,0x3b,0xc8 }, { 0xa5,0x94,0x30,0xc6 },
+ { 0xd2,0xdf,0x59,0x9c }, { 0xdb,0xd2,0x52,0x92 },
+ { 0xc0,0xc5,0x4f,0x80 }, { 0xc9,0xc8,0x44,0x8e },
+ { 0xf6,0xeb,0x75,0xa4 }, { 0xff,0xe6,0x7e,0xaa },
+ { 0xe4,0xf1,0x63,0xb8 }, { 0xed,0xfc,0x68,0xb6 },
+ { 0x0a,0x67,0xb1,0x0c }, { 0x03,0x6a,0xba,0x02 },
+ { 0x18,0x7d,0xa7,0x10 }, { 0x11,0x70,0xac,0x1e },
+ { 0x2e,0x53,0x9d,0x34 }, { 0x27,0x5e,0x96,0x3a },
+ { 0x3c,0x49,0x8b,0x28 }, { 0x35,0x44,0x80,0x26 },
+ { 0x42,0x0f,0xe9,0x7c }, { 0x4b,0x02,0xe2,0x72 },
+ { 0x50,0x15,0xff,0x60 }, { 0x59,0x18,0xf4,0x6e },
+ { 0x66,0x3b,0xc5,0x44 }, { 0x6f,0x36,0xce,0x4a },
+ { 0x74,0x21,0xd3,0x58 }, { 0x7d,0x2c,0xd8,0x56 },
+ { 0xa1,0x0c,0x7a,0x37 }, { 0xa8,0x01,0x71,0x39 },
+ { 0xb3,0x16,0x6c,0x2b }, { 0xba,0x1b,0x67,0x25 },
+ { 0x85,0x38,0x56,0x0f }, { 0x8c,0x35,0x5d,0x01 },
+ { 0x97,0x22,0x40,0x13 }, { 0x9e,0x2f,0x4b,0x1d },
+ { 0xe9,0x64,0x22,0x47 }, { 0xe0,0x69,0x29,0x49 },
+ { 0xfb,0x7e,0x34,0x5b }, { 0xf2,0x73,0x3f,0x55 },
+ { 0xcd,0x50,0x0e,0x7f }, { 0xc4,0x5d,0x05,0x71 },
+ { 0xdf,0x4a,0x18,0x63 }, { 0xd6,0x47,0x13,0x6d },
+ { 0x31,0xdc,0xca,0xd7 }, { 0x38,0xd1,0xc1,0xd9 },
+ { 0x23,0xc6,0xdc,0xcb }, { 0x2a,0xcb,0xd7,0xc5 },
+ { 0x15,0xe8,0xe6,0xef }, { 0x1c,0xe5,0xed,0xe1 },
+ { 0x07,0xf2,0xf0,0xf3 }, { 0x0e,0xff,0xfb,0xfd },
+ { 0x79,0xb4,0x92,0xa7 }, { 0x70,0xb9,0x99,0xa9 },
+ { 0x6b,0xae,0x84,0xbb }, { 0x62,0xa3,0x8f,0xb5 },
+ { 0x5d,0x80,0xbe,0x9f }, { 0x54,0x8d,0xb5,0x91 },
+ { 0x4f,0x9a,0xa8,0x83 }, { 0x46,0x97,0xa3,0x8d }
+ };
+
+static const u32 rcon[30] =
+ {
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c,
+ 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35,
+ 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/rijndael.c b/grub-core/lib/libgcrypt/cipher/rijndael.c
new file mode 100644
index 0000000..559550b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/rijndael.c
@@ -0,0 +1,2092 @@
+/* Rijndael (AES) for GnuPG
+ * Copyright (C) 2000, 2001, 2002, 2003, 2007,
+ * 2008, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *******************************************************************
+ * The code here is based on the optimized implementation taken from
+ * http://www.esat.kuleuven.ac.be/~rijmen/rijndael/ on Oct 2, 2000,
+ * which carries this notice:
+ *------------------------------------------
+ * rijndael-alg-fst.c v2.3 April '2000
+ *
+ * Optimised ANSI C code
+ *
+ * authors: v1.0: Antoon Bosselaers
+ * v2.0: Vincent Rijmen
+ * v2.3: Paulo Barreto
+ *
+ * This code is placed in the public domain.
+ *------------------------------------------
+ *
+ * The SP800-38a document is available at:
+ * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
+ *
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h> /* for memcmp() */
+
+#include "types.h" /* for byte and u32 typedefs */
+#include "g10lib.h"
+#include "cipher.h"
+
+#define MAXKC (256/32)
+#define MAXROUNDS 14
+#define BLOCKSIZE (128/8)
+
+
+/* Helper macro to force alignment to 16 bytes. */
+#ifdef __GNUC__
+# define ATTR_ALIGNED_16 __attribute__ ((aligned (16)))
+#else
+# define ATTR_ALIGNED_16
+#endif
+
+
+/* USE_PADLOCK indicates whether to compile the padlock specific
+ code. */
+#undef USE_PADLOCK
+#ifdef ENABLE_PADLOCK_SUPPORT
+# if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4 && defined (__GNUC__)
+# define USE_PADLOCK 1
+# endif
+#endif /*ENABLE_PADLOCK_SUPPORT*/
+
+/* USE_AESNI inidicates whether to compile with Intel AES-NI code. We
+ need the vector-size attribute which seems to be available since
+ gcc 3. However, to be on the safe side we require at least gcc 4. */
+#undef USE_AESNI
+#ifdef ENABLE_AESNI_SUPPORT
+# if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4 && __GNUC__ >= 4
+# define USE_AESNI 1
+# endif
+#endif /* ENABLE_AESNI_SUPPORT */
+
+#ifdef USE_AESNI
+ typedef int m128i_t __attribute__ ((__vector_size__ (16)));
+#endif /*USE_AESNI*/
+
+/* Define an u32 variant for the sake of gcc 4.4's strict aliasing. */
+#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )
+typedef u32 __attribute__ ((__may_alias__)) u32_a_t;
+#else
+typedef u32 u32_a_t;
+#endif
+
+
+
+/* Our context object. */
+typedef struct
+{
+ /* The first fields are the keyschedule arrays. This is so that
+ they are aligned on a 16 byte boundary if using gcc. This
+ alignment is required for the AES-NI code and a good idea in any
+ case. The alignment is guaranteed due to the way cipher.c
+ allocates the space for the context. The PROPERLY_ALIGNED_TYPE
+ hack is used to force a minimal alignment if not using gcc of if
+ the alignment requirement is higher that 16 bytes. */
+ union
+ {
+ PROPERLY_ALIGNED_TYPE dummy;
+ byte keyschedule[MAXROUNDS+1][4][4];
+#ifdef USE_PADLOCK
+ /* The key as passed to the padlock engine. It is only used if
+ the padlock engine is used (USE_PADLOCK, below). */
+ unsigned char padlock_key[16] __attribute__ ((aligned (16)));
+#endif /*USE_PADLOCK*/
+ } u1;
+ union
+ {
+ PROPERLY_ALIGNED_TYPE dummy;
+ byte keyschedule[MAXROUNDS+1][4][4];
+ } u2;
+ int rounds; /* Key-length-dependent number of rounds. */
+ int decryption_prepared; /* The decryption key schedule is available. */
+#ifdef USE_PADLOCK
+ int use_padlock; /* Padlock shall be used. */
+#endif /*USE_PADLOCK*/
+#ifdef USE_AESNI
+ int use_aesni; /* AES-NI shall be used. */
+#endif /*USE_AESNI*/
+} RIJNDAEL_context ATTR_ALIGNED_16;
+
+/* Macros defining alias for the keyschedules. */
+#define keyschenc u1.keyschedule
+#define keyschdec u2.keyschedule
+#define padlockkey u1.padlock_key
+
+/* Two macros to be called prior and after the use of AESNI
+ instructions. There should be no external function calls between
+ the use of these macros. There purpose is to make sure that the
+ SSE regsiters are cleared and won't reveal any information about
+ the key or the data. */
+#ifdef USE_AESNI
+# define aesni_prepare() do { } while (0)
+# define aesni_cleanup() \
+ do { asm volatile ("pxor %%xmm0, %%xmm0\n\t" \
+ "pxor %%xmm1, %%xmm1\n" :: ); \
+ } while (0)
+# define aesni_cleanup_2_4() \
+ do { asm volatile ("pxor %%xmm2, %%xmm2\n\t" \
+ "pxor %%xmm3, %%xmm3\n" \
+ "pxor %%xmm4, %%xmm4\n":: ); \
+ } while (0)
+#else
+# define aesni_prepare() do { } while (0)
+# define aesni_cleanup() do { } while (0)
+#endif
+
+
+/* All the numbers. */
+#include "rijndael-tables.h"
+
+
+
+/* Function prototypes. */
+#ifdef USE_AESNI
+/* We don't want to inline these functions to help gcc allocate enough
+ registers. */
+static void do_aesni_ctr (const RIJNDAEL_context *ctx, unsigned char *ctr,
+ unsigned char *b, const unsigned char *a)
+ __attribute__ ((__noinline__));
+static void do_aesni_ctr_4 (const RIJNDAEL_context *ctx, unsigned char *ctr,
+ unsigned char *b, const unsigned char *a)
+ __attribute__ ((__noinline__));
+#endif /*USE_AESNI*/
+
+static const char *selftest(void);
+
+
+
+/* Perform the key setup. */
+static gcry_err_code_t
+do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
+{
+ static int initialized = 0;
+ static const char *selftest_failed=0;
+ int rounds;
+ int i,j, r, t, rconpointer = 0;
+ int KC;
+ union
+ {
+ PROPERLY_ALIGNED_TYPE dummy;
+ byte k[MAXKC][4];
+ } k;
+#define k k.k
+ union
+ {
+ PROPERLY_ALIGNED_TYPE dummy;
+ byte tk[MAXKC][4];
+ } tk;
+#define tk tk.tk
+
+ /* The on-the-fly self tests are only run in non-fips mode. In fips
+ mode explicit self-tests are required. Actually the on-the-fly
+ self-tests are not fully thread-safe and it might happen that a
+ failed self-test won't get noticed in another thread.
+
+ FIXME: We might want to have a central registry of succeeded
+ self-tests. */
+ if (!fips_mode () && !initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+ if (selftest_failed)
+ log_error ("%s\n", selftest_failed );
+ }
+ if (selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ ctx->decryption_prepared = 0;
+#ifdef USE_PADLOCK
+ ctx->use_padlock = 0;
+#endif
+#ifdef USE_AESNI
+ ctx->use_aesni = 0;
+#endif
+
+ if( keylen == 128/8 )
+ {
+ rounds = 10;
+ KC = 4;
+
+ if (0)
+ ;
+#ifdef USE_PADLOCK
+ else if ((_gcry_get_hw_features () & HWF_PADLOCK_AES))
+ {
+ ctx->use_padlock = 1;
+ memcpy (ctx->padlockkey, key, keylen);
+ }
+#endif
+#ifdef USE_AESNI
+ else if ((_gcry_get_hw_features () & HWF_INTEL_AESNI))
+ {
+ ctx->use_aesni = 1;
+ }
+#endif
+ }
+ else if ( keylen == 192/8 )
+ {
+ rounds = 12;
+ KC = 6;
+
+ if (0)
+ {
+ ;
+ }
+#ifdef USE_AESNI
+ else if ((_gcry_get_hw_features () & HWF_INTEL_AESNI))
+ {
+ ctx->use_aesni = 1;
+ }
+#endif
+ }
+ else if ( keylen == 256/8 )
+ {
+ rounds = 14;
+ KC = 8;
+
+ if (0)
+ {
+ ;
+ }
+#ifdef USE_AESNI
+ else if ((_gcry_get_hw_features () & HWF_INTEL_AESNI))
+ {
+ ctx->use_aesni = 1;
+ }
+#endif
+ }
+ else
+ return GPG_ERR_INV_KEYLEN;
+
+ ctx->rounds = rounds;
+
+ /* NB: We don't yet support Padlock hardware key generation. */
+
+ if (0)
+ ;
+#ifdef USE_AESNI_is_disabled_here
+ else if (ctx->use_aesni && ctx->rounds == 10)
+ {
+ /* Note: This code works for AES-128 but it is not much better
+ than using the standard key schedule. We disable it for
+ now and don't put any effort into implementing this for
+ AES-192 and AES-256. */
+ asm volatile ("movl %[key], %%esi\n\t"
+ "movdqu (%%esi), %%xmm1\n\t" /* xmm1 := key */
+ "movl %[ksch], %%esi\n\t"
+ "movdqa %%xmm1, (%%esi)\n\t" /* ksch[0] := xmm1 */
+ "aeskeygenassist $0x01, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x10(%%esi)\n\t" /* ksch[1] := xmm1 */
+ "aeskeygenassist $0x02, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x20(%%esi)\n\t" /* ksch[2] := xmm1 */
+ "aeskeygenassist $0x04, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x30(%%esi)\n\t" /* ksch[3] := xmm1 */
+ "aeskeygenassist $0x08, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x40(%%esi)\n\t" /* ksch[4] := xmm1 */
+ "aeskeygenassist $0x10, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x50(%%esi)\n\t" /* ksch[5] := xmm1 */
+ "aeskeygenassist $0x20, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x60(%%esi)\n\t" /* ksch[6] := xmm1 */
+ "aeskeygenassist $0x40, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x70(%%esi)\n\t" /* ksch[7] := xmm1 */
+ "aeskeygenassist $0x80, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x80(%%esi)\n\t" /* ksch[8] := xmm1 */
+ "aeskeygenassist $0x1b, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0x90(%%esi)\n\t" /* ksch[9] := xmm1 */
+ "aeskeygenassist $0x36, %%xmm1, %%xmm2\n\t"
+ "call .Lexpand128_%=\n\t"
+ "movdqa %%xmm1, 0xa0(%%esi)\n\t" /* ksch[10] := xmm1 */
+ "jmp .Lleave%=\n"
+
+ ".Lexpand128_%=:\n\t"
+ "pshufd $0xff, %%xmm2, %%xmm2\n\t"
+ "movdqa %%xmm1, %%xmm3\n\t"
+ "pslldq $4, %%xmm3\n\t"
+ "pxor %%xmm3, %%xmm1\n\t"
+ "pslldq $4, %%xmm3\n\t"
+ "pxor %%xmm3, %%xmm1\n\t"
+ "pslldq $4, %%xmm3\n\t"
+ "pxor %%xmm3, %%xmm2\n\t"
+ "pxor %%xmm2, %%xmm1\n\t"
+ "ret\n"
+
+ ".Lleave%=:\n\t"
+ "pxor %%xmm1, %%xmm1\n\t"
+ "pxor %%xmm2, %%xmm2\n\t"
+ "pxor %%xmm3, %%xmm3\n"
+ :
+ : [key] "g" (key), [ksch] "g" (ctx->keyschenc)
+ : "%esi", "cc", "memory" );
+ }
+#endif /*USE_AESNI*/
+ else
+ {
+#define W (ctx->keyschenc)
+ for (i = 0; i < keylen; i++)
+ {
+ k[i >> 2][i & 3] = key[i];
+ }
+
+ for (j = KC-1; j >= 0; j--)
+ {
+ *((u32_a_t*)tk[j]) = *((u32_a_t*)k[j]);
+ }
+ r = 0;
+ t = 0;
+ /* Copy values into round key array. */
+ for (j = 0; (j < KC) && (r < rounds + 1); )
+ {
+ for (; (j < KC) && (t < 4); j++, t++)
+ {
+ *((u32_a_t*)W[r][t]) = *((u32_a_t*)tk[j]);
+ }
+ if (t == 4)
+ {
+ r++;
+ t = 0;
+ }
+ }
+
+ while (r < rounds + 1)
+ {
+ /* While not enough round key material calculated calculate
+ new values. */
+ tk[0][0] ^= S[tk[KC-1][1]];
+ tk[0][1] ^= S[tk[KC-1][2]];
+ tk[0][2] ^= S[tk[KC-1][3]];
+ tk[0][3] ^= S[tk[KC-1][0]];
+ tk[0][0] ^= rcon[rconpointer++];
+
+ if (KC != 8)
+ {
+ for (j = 1; j < KC; j++)
+ {
+ *((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
+ }
+ }
+ else
+ {
+ for (j = 1; j < KC/2; j++)
+ {
+ *((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]];
+ tk[KC/2][2] ^= S[tk[KC/2 - 1][2]];
+ tk[KC/2][3] ^= S[tk[KC/2 - 1][3]];
+ for (j = KC/2 + 1; j < KC; j++)
+ {
+ *((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
+ }
+ }
+
+ /* Copy values into round key array. */
+ for (j = 0; (j < KC) && (r < rounds + 1); )
+ {
+ for (; (j < KC) && (t < 4); j++, t++)
+ {
+ *((u32_a_t*)W[r][t]) = *((u32_a_t*)tk[j]);
+ }
+ if (t == 4)
+ {
+ r++;
+ t = 0;
+ }
+ }
+ }
+#undef W
+ }
+
+ return 0;
+#undef tk
+#undef k
+}
+
+
+static gcry_err_code_t
+rijndael_setkey (void *context, const byte *key, const unsigned keylen)
+{
+ RIJNDAEL_context *ctx = context;
+
+ int rc = do_setkey (ctx, key, keylen);
+ _gcry_burn_stack ( 100 + 16*sizeof(int));
+ return rc;
+}
+
+
+/* Make a decryption key from an encryption key. */
+static void
+prepare_decryption( RIJNDAEL_context *ctx )
+{
+ int r;
+
+#ifdef USE_AESNI
+ if (ctx->use_aesni)
+ {
+ /* The AES-NI decrypt instructions use the Equivalent Inverse
+ Cipher, thus we can't use the the standard decrypt key
+ preparation. */
+ m128i_t *ekey = (m128i_t*)ctx->keyschenc;
+ m128i_t *dkey = (m128i_t*)ctx->keyschdec;
+ int rr;
+
+ dkey[0] = ekey[ctx->rounds];
+ for (r=1, rr=ctx->rounds-1; r < ctx->rounds; r++, rr--)
+ {
+ asm volatile
+ ("movdqu %[ekey], %%xmm1\n\t"
+ /*"aesimc %%xmm1, %%xmm1\n\t"*/
+ ".byte 0x66, 0x0f, 0x38, 0xdb, 0xc9\n\t"
+ "movdqu %%xmm1, %[dkey]"
+ : [dkey] "=m" (dkey[r])
+ : [ekey] "m" (ekey[rr]) );
+ }
+ dkey[r] = ekey[0];
+ }
+ else
+#endif /*USE_AESNI*/
+ {
+ union
+ {
+ PROPERLY_ALIGNED_TYPE dummy;
+ byte *w;
+ } w;
+#define w w.w
+
+ for (r=0; r < MAXROUNDS+1; r++ )
+ {
+ *((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_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_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_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_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
+ }
+}
+
+
+/* Encrypt one block. A and B need to be aligned on a 4 byte
+ boundary. A and B may be the same. */
+static void
+do_encrypt_aligned (const RIJNDAEL_context *ctx,
+ unsigned char *b, const unsigned char *a)
+{
+#define rk (ctx->keyschenc)
+ int rounds = ctx->rounds;
+ int r;
+ union
+ {
+ u32 tempu32[4]; /* Force correct alignment. */
+ byte temp[4][4];
+ } u;
+
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(a )) ^ *((u32_a_t*)rk[0][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(a+ 4)) ^ *((u32_a_t*)rk[0][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(a+ 8)) ^ *((u32_a_t*)rk[0][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(a+12)) ^ *((u32_a_t*)rk[0][3]);
+ *((u32_a_t*)(b )) = (*((u32_a_t*)T1[u.temp[0][0]])
+ ^ *((u32_a_t*)T2[u.temp[1][1]])
+ ^ *((u32_a_t*)T3[u.temp[2][2]])
+ ^ *((u32_a_t*)T4[u.temp[3][3]]));
+ *((u32_a_t*)(b + 4)) = (*((u32_a_t*)T1[u.temp[1][0]])
+ ^ *((u32_a_t*)T2[u.temp[2][1]])
+ ^ *((u32_a_t*)T3[u.temp[3][2]])
+ ^ *((u32_a_t*)T4[u.temp[0][3]]));
+ *((u32_a_t*)(b + 8)) = (*((u32_a_t*)T1[u.temp[2][0]])
+ ^ *((u32_a_t*)T2[u.temp[3][1]])
+ ^ *((u32_a_t*)T3[u.temp[0][2]])
+ ^ *((u32_a_t*)T4[u.temp[1][3]]));
+ *((u32_a_t*)(b +12)) = (*((u32_a_t*)T1[u.temp[3][0]])
+ ^ *((u32_a_t*)T2[u.temp[0][1]])
+ ^ *((u32_a_t*)T3[u.temp[1][2]])
+ ^ *((u32_a_t*)T4[u.temp[2][3]]));
+
+ for (r = 1; r < rounds-1; r++)
+ {
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(b )) ^ *((u32_a_t*)rk[r][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(b+ 4)) ^ *((u32_a_t*)rk[r][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(b+ 8)) ^ *((u32_a_t*)rk[r][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(b+12)) ^ *((u32_a_t*)rk[r][3]);
+
+ *((u32_a_t*)(b )) = (*((u32_a_t*)T1[u.temp[0][0]])
+ ^ *((u32_a_t*)T2[u.temp[1][1]])
+ ^ *((u32_a_t*)T3[u.temp[2][2]])
+ ^ *((u32_a_t*)T4[u.temp[3][3]]));
+ *((u32_a_t*)(b + 4)) = (*((u32_a_t*)T1[u.temp[1][0]])
+ ^ *((u32_a_t*)T2[u.temp[2][1]])
+ ^ *((u32_a_t*)T3[u.temp[3][2]])
+ ^ *((u32_a_t*)T4[u.temp[0][3]]));
+ *((u32_a_t*)(b + 8)) = (*((u32_a_t*)T1[u.temp[2][0]])
+ ^ *((u32_a_t*)T2[u.temp[3][1]])
+ ^ *((u32_a_t*)T3[u.temp[0][2]])
+ ^ *((u32_a_t*)T4[u.temp[1][3]]));
+ *((u32_a_t*)(b +12)) = (*((u32_a_t*)T1[u.temp[3][0]])
+ ^ *((u32_a_t*)T2[u.temp[0][1]])
+ ^ *((u32_a_t*)T3[u.temp[1][2]])
+ ^ *((u32_a_t*)T4[u.temp[2][3]]));
+ }
+
+ /* Last round is special. */
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(b )) ^ *((u32_a_t*)rk[rounds-1][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(b+ 4)) ^ *((u32_a_t*)rk[rounds-1][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(b+ 8)) ^ *((u32_a_t*)rk[rounds-1][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(b+12)) ^ *((u32_a_t*)rk[rounds-1][3]);
+ b[ 0] = T1[u.temp[0][0]][1];
+ b[ 1] = T1[u.temp[1][1]][1];
+ b[ 2] = T1[u.temp[2][2]][1];
+ b[ 3] = T1[u.temp[3][3]][1];
+ b[ 4] = T1[u.temp[1][0]][1];
+ b[ 5] = T1[u.temp[2][1]][1];
+ b[ 6] = T1[u.temp[3][2]][1];
+ b[ 7] = T1[u.temp[0][3]][1];
+ b[ 8] = T1[u.temp[2][0]][1];
+ b[ 9] = T1[u.temp[3][1]][1];
+ b[10] = T1[u.temp[0][2]][1];
+ b[11] = T1[u.temp[1][3]][1];
+ b[12] = T1[u.temp[3][0]][1];
+ b[13] = T1[u.temp[0][1]][1];
+ b[14] = T1[u.temp[1][2]][1];
+ b[15] = T1[u.temp[2][3]][1];
+ *((u32_a_t*)(b )) ^= *((u32_a_t*)rk[rounds][0]);
+ *((u32_a_t*)(b+ 4)) ^= *((u32_a_t*)rk[rounds][1]);
+ *((u32_a_t*)(b+ 8)) ^= *((u32_a_t*)rk[rounds][2]);
+ *((u32_a_t*)(b+12)) ^= *((u32_a_t*)rk[rounds][3]);
+#undef rk
+}
+
+
+static void
+do_encrypt (const RIJNDAEL_context *ctx,
+ unsigned char *bx, const unsigned char *ax)
+{
+ /* BX and AX are not necessary correctly aligned. Thus we might
+ need to copy them here. We try to align to a 16 bytes. */
+ if (((size_t)ax & 0x0f) || ((size_t)bx & 0x0f))
+ {
+ union
+ {
+ u32 dummy[4];
+ byte a[16] ATTR_ALIGNED_16;
+ } a;
+ union
+ {
+ u32 dummy[4];
+ byte b[16] ATTR_ALIGNED_16;
+ } b;
+
+ memcpy (a.a, ax, 16);
+ do_encrypt_aligned (ctx, b.b, a.a);
+ memcpy (bx, b.b, 16);
+ }
+ else
+ {
+ do_encrypt_aligned (ctx, bx, ax);
+ }
+}
+
+
+/* Encrypt or decrypt one block using the padlock engine. A and B may
+ be the same. */
+#ifdef USE_PADLOCK
+static void
+do_padlock (const RIJNDAEL_context *ctx, int decrypt_flag,
+ unsigned char *bx, const unsigned char *ax)
+{
+ /* BX and AX are not necessary correctly aligned. Thus we need to
+ copy them here. */
+ unsigned char a[16] __attribute__ ((aligned (16)));
+ unsigned char b[16] __attribute__ ((aligned (16)));
+ unsigned int cword[4] __attribute__ ((aligned (16)));
+
+ /* The control word fields are:
+ 127:12 11:10 9 8 7 6 5 4 3:0
+ RESERVED KSIZE CRYPT INTER KEYGN CIPHR ALIGN DGEST ROUND */
+ cword[0] = (ctx->rounds & 15); /* (The mask is just a safeguard.) */
+ cword[1] = 0;
+ cword[2] = 0;
+ cword[3] = 0;
+ if (decrypt_flag)
+ cword[0] |= 0x00000200;
+
+ memcpy (a, ax, 16);
+
+ asm volatile
+ ("pushfl\n\t" /* Force key reload. */
+ "popfl\n\t"
+ "xchg %3, %%ebx\n\t" /* Load key. */
+ "movl $1, %%ecx\n\t" /* Init counter for just one block. */
+ ".byte 0xf3, 0x0f, 0xa7, 0xc8\n\t" /* REP XSTORE ECB. */
+ "xchg %3, %%ebx\n" /* Restore GOT register. */
+ : /* No output */
+ : "S" (a), "D" (b), "d" (cword), "r" (ctx->padlockkey)
+ : "%ecx", "cc", "memory"
+ );
+
+ memcpy (bx, b, 16);
+
+}
+#endif /*USE_PADLOCK*/
+
+
+#ifdef USE_AESNI
+/* Encrypt one block using the Intel AES-NI instructions. A and B may
+ be the same; they need to be properly aligned to 16 bytes.
+
+ Our problem here is that gcc does not allow the "x" constraint for
+ SSE registers in asm unless you compile with -msse. The common
+ wisdom is to use a separate file for SSE instructions and build it
+ separately. This would require a lot of extra build system stuff,
+ similar to what we do in mpi/ for the asm stuff. What we do
+ instead is to use standard registers and a bit more of plain asm
+ which copies the data and key stuff to the SSE registers and later
+ back. If we decide to implement some block modes with parallelized
+ AES instructions, it might indeed be better to use plain asm ala
+ mpi/. */
+static void
+do_aesni_enc_aligned (const RIJNDAEL_context *ctx,
+ unsigned char *b, const unsigned char *a)
+{
+#define aesenc_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xc1\n\t"
+#define aesenclast_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xc1\n\t"
+ /* Note: For now we relax the alignment requirement for A and B: It
+ does not make much difference because in many case we would need
+ to memcpy them to an extra buffer; using the movdqu is much faster
+ that memcpy and movdqa. For CFB we know that the IV is properly
+ aligned but that is a special case. We should better implement
+ CFB direct in asm. */
+ asm volatile ("movdqu %[src], %%xmm0\n\t" /* xmm0 := *a */
+ "movl %[key], %%esi\n\t" /* esi := keyschenc */
+ "movdqa (%%esi), %%xmm1\n\t" /* xmm1 := key[0] */
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 ^= key[0] */
+ "movdqa 0x10(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x20(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x30(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x40(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x50(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x60(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x70(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x80(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x90(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xa0(%%esi), %%xmm1\n\t"
+ "cmp $10, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xb0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xc0(%%esi), %%xmm1\n\t"
+ "cmp $12, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xd0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xe0(%%esi), %%xmm1\n"
+
+ ".Lenclast%=:\n\t"
+ aesenclast_xmm1_xmm0
+ "movdqu %%xmm0, %[dst]\n"
+ : [dst] "=m" (*b)
+ : [src] "m" (*a),
+ [key] "r" (ctx->keyschenc),
+ [rounds] "r" (ctx->rounds)
+ : "%esi", "cc", "memory");
+#undef aesenc_xmm1_xmm0
+#undef aesenclast_xmm1_xmm0
+}
+
+
+static void
+do_aesni_dec_aligned (const RIJNDAEL_context *ctx,
+ unsigned char *b, const unsigned char *a)
+{
+#define aesdec_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xde, 0xc1\n\t"
+#define aesdeclast_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdf, 0xc1\n\t"
+ asm volatile ("movdqu %[src], %%xmm0\n\t" /* xmm0 := *a */
+ "movl %[key], %%esi\n\t"
+ "movdqa (%%esi), %%xmm1\n\t"
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 ^= key[0] */
+ "movdqa 0x10(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x20(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x30(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x40(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x50(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x60(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x70(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x80(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0x90(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0xa0(%%esi), %%xmm1\n\t"
+ "cmp $10, %[rounds]\n\t"
+ "jz .Ldeclast%=\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0xb0(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0xc0(%%esi), %%xmm1\n\t"
+ "cmp $12, %[rounds]\n\t"
+ "jz .Ldeclast%=\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0xd0(%%esi), %%xmm1\n\t"
+ aesdec_xmm1_xmm0
+ "movdqa 0xe0(%%esi), %%xmm1\n"
+
+ ".Ldeclast%=:\n\t"
+ aesdeclast_xmm1_xmm0
+ "movdqu %%xmm0, %[dst]\n"
+ : [dst] "=m" (*b)
+ : [src] "m" (*a),
+ [key] "r" (ctx->keyschdec),
+ [rounds] "r" (ctx->rounds)
+ : "%esi", "cc", "memory");
+#undef aesdec_xmm1_xmm0
+#undef aesdeclast_xmm1_xmm0
+}
+
+
+/* Perform a CFB encryption or decryption round using the
+ initialization vector IV and the input block A. Write the result
+ to the output block B and update IV. IV needs to be 16 byte
+ aligned. */
+static void
+do_aesni_cfb (const RIJNDAEL_context *ctx, int decrypt_flag,
+ unsigned char *iv, unsigned char *b, const unsigned char *a)
+{
+#define aesenc_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xc1\n\t"
+#define aesenclast_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xc1\n\t"
+ asm volatile ("movdqa %[iv], %%xmm0\n\t" /* xmm0 := IV */
+ "movl %[key], %%esi\n\t" /* esi := keyschenc */
+ "movdqa (%%esi), %%xmm1\n\t" /* xmm1 := key[0] */
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 ^= key[0] */
+ "movdqa 0x10(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x20(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x30(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x40(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x50(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x60(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x70(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x80(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x90(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xa0(%%esi), %%xmm1\n\t"
+ "cmp $10, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xb0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xc0(%%esi), %%xmm1\n\t"
+ "cmp $12, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xd0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xe0(%%esi), %%xmm1\n"
+
+ ".Lenclast%=:\n\t"
+ aesenclast_xmm1_xmm0
+ "movdqu %[src], %%xmm1\n\t" /* Save input. */
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 = input ^ IV */
+
+ "cmp $1, %[decrypt]\n\t"
+ "jz .Ldecrypt_%=\n\t"
+ "movdqa %%xmm0, %[iv]\n\t" /* [encrypt] Store IV. */
+ "jmp .Lleave_%=\n"
+ ".Ldecrypt_%=:\n\t"
+ "movdqa %%xmm1, %[iv]\n" /* [decrypt] Store IV. */
+ ".Lleave_%=:\n\t"
+ "movdqu %%xmm0, %[dst]\n" /* Store output. */
+ : [iv] "+m" (*iv), [dst] "=m" (*b)
+ : [src] "m" (*a),
+ [key] "g" (ctx->keyschenc),
+ [rounds] "g" (ctx->rounds),
+ [decrypt] "m" (decrypt_flag)
+ : "%esi", "cc", "memory");
+#undef aesenc_xmm1_xmm0
+#undef aesenclast_xmm1_xmm0
+}
+
+/* Perform a CTR encryption round using the counter CTR and the input
+ block A. Write the result to the output block B and update CTR.
+ CTR needs to be a 16 byte aligned little-endian value. */
+static void
+do_aesni_ctr (const RIJNDAEL_context *ctx,
+ unsigned char *ctr, unsigned char *b, const unsigned char *a)
+{
+#define aesenc_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xc1\n\t"
+#define aesenclast_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xc1\n\t"
+ static unsigned char be_mask[16] __attribute__ ((aligned (16))) =
+ { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
+
+ asm volatile ("movdqa %[ctr], %%xmm0\n\t" /* xmm0, xmm2 := CTR */
+ "movaps %%xmm0, %%xmm2\n\t"
+ "mov $1, %%esi\n\t" /* xmm2++ (big-endian) */
+ "movd %%esi, %%xmm1\n\t"
+ "pshufb %[mask], %%xmm2\n\t"
+ "paddq %%xmm1, %%xmm2\n\t"
+ "pshufb %[mask], %%xmm2\n\t"
+ "movdqa %%xmm2, %[ctr]\n" /* Update CTR. */
+
+ "movl %[key], %%esi\n\t" /* esi := keyschenc */
+ "movdqa (%%esi), %%xmm1\n\t" /* xmm1 := key[0] */
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 ^= key[0] */
+ "movdqa 0x10(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x20(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x30(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x40(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x50(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x60(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x70(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x80(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0x90(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xa0(%%esi), %%xmm1\n\t"
+ "cmp $10, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xb0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xc0(%%esi), %%xmm1\n\t"
+ "cmp $12, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xd0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ "movdqa 0xe0(%%esi), %%xmm1\n"
+
+ ".Lenclast%=:\n\t"
+ aesenclast_xmm1_xmm0
+ "movdqu %[src], %%xmm1\n\t" /* xmm1 := input */
+ "pxor %%xmm1, %%xmm0\n\t" /* EncCTR ^= input */
+ "movdqu %%xmm0, %[dst]" /* Store EncCTR. */
+
+ : [ctr] "+m" (*ctr), [dst] "=m" (*b)
+ : [src] "m" (*a),
+ [key] "g" (ctx->keyschenc),
+ [rounds] "g" (ctx->rounds),
+ [mask] "m" (*be_mask)
+ : "%esi", "cc", "memory");
+#undef aesenc_xmm1_xmm0
+#undef aesenclast_xmm1_xmm0
+}
+
+
+/* Four blocks at a time variant of do_aesni_ctr. */
+static void
+do_aesni_ctr_4 (const RIJNDAEL_context *ctx,
+ unsigned char *ctr, unsigned char *b, const unsigned char *a)
+{
+#define aesenc_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xc1\n\t"
+#define aesenc_xmm1_xmm2 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xd1\n\t"
+#define aesenc_xmm1_xmm3 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xd9\n\t"
+#define aesenc_xmm1_xmm4 ".byte 0x66, 0x0f, 0x38, 0xdc, 0xe1\n\t"
+#define aesenclast_xmm1_xmm0 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xc1\n\t"
+#define aesenclast_xmm1_xmm2 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xd1\n\t"
+#define aesenclast_xmm1_xmm3 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xd9\n\t"
+#define aesenclast_xmm1_xmm4 ".byte 0x66, 0x0f, 0x38, 0xdd, 0xe1\n\t"
+
+ static unsigned char be_mask[16] __attribute__ ((aligned (16))) =
+ { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
+
+ /* Register usage:
+ esi keyschedule
+ xmm0 CTR-0
+ xmm1 temp / round key
+ xmm2 CTR-1
+ xmm3 CTR-2
+ xmm4 CTR-3
+ xmm5 temp
+ */
+
+ asm volatile ("movdqa %[ctr], %%xmm0\n\t" /* xmm0, xmm2 := CTR */
+ "movaps %%xmm0, %%xmm2\n\t"
+ "mov $1, %%esi\n\t" /* xmm1 := 1 */
+ "movd %%esi, %%xmm1\n\t"
+ "pshufb %[mask], %%xmm2\n\t" /* xmm2 := le(xmm2) */
+ "paddq %%xmm1, %%xmm2\n\t" /* xmm2++ */
+ "movaps %%xmm2, %%xmm3\n\t" /* xmm3 := xmm2 */
+ "paddq %%xmm1, %%xmm3\n\t" /* xmm3++ */
+ "movaps %%xmm3, %%xmm4\n\t" /* xmm4 := xmm3 */
+ "paddq %%xmm1, %%xmm4\n\t" /* xmm4++ */
+ "movaps %%xmm4, %%xmm5\n\t" /* xmm5 := xmm4 */
+ "paddq %%xmm1, %%xmm5\n\t" /* xmm5++ */
+ "pshufb %[mask], %%xmm2\n\t" /* xmm2 := be(xmm2) */
+ "pshufb %[mask], %%xmm3\n\t" /* xmm3 := be(xmm3) */
+ "pshufb %[mask], %%xmm4\n\t" /* xmm4 := be(xmm4) */
+ "pshufb %[mask], %%xmm5\n\t" /* xmm5 := be(xmm5) */
+ "movdqa %%xmm5, %[ctr]\n" /* Update CTR. */
+
+ "movl %[key], %%esi\n\t" /* esi := keyschenc */
+ "movdqa (%%esi), %%xmm1\n\t" /* xmm1 := key[0] */
+ "pxor %%xmm1, %%xmm0\n\t" /* xmm0 ^= key[0] */
+ "pxor %%xmm1, %%xmm2\n\t" /* xmm2 ^= key[0] */
+ "pxor %%xmm1, %%xmm3\n\t" /* xmm3 ^= key[0] */
+ "pxor %%xmm1, %%xmm4\n\t" /* xmm4 ^= key[0] */
+ "movdqa 0x10(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x20(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x30(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x40(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x50(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x60(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x70(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x80(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0x90(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0xa0(%%esi), %%xmm1\n\t"
+ "cmp $10, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0xb0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0xc0(%%esi), %%xmm1\n\t"
+ "cmp $12, %[rounds]\n\t"
+ "jz .Lenclast%=\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0xd0(%%esi), %%xmm1\n\t"
+ aesenc_xmm1_xmm0
+ aesenc_xmm1_xmm2
+ aesenc_xmm1_xmm3
+ aesenc_xmm1_xmm4
+ "movdqa 0xe0(%%esi), %%xmm1\n"
+
+ ".Lenclast%=:\n\t"
+ aesenclast_xmm1_xmm0
+ aesenclast_xmm1_xmm2
+ aesenclast_xmm1_xmm3
+ aesenclast_xmm1_xmm4
+
+ "movdqu %[src], %%xmm1\n\t" /* Get block 1. */
+ "pxor %%xmm1, %%xmm0\n\t" /* EncCTR-1 ^= input */
+ "movdqu %%xmm0, %[dst]\n\t" /* Store block 1 */
+
+ "movdqu (16)%[src], %%xmm1\n\t" /* Get block 2. */
+ "pxor %%xmm1, %%xmm2\n\t" /* EncCTR-2 ^= input */
+ "movdqu %%xmm2, (16)%[dst]\n\t" /* Store block 2. */
+
+ "movdqu (32)%[src], %%xmm1\n\t" /* Get block 3. */
+ "pxor %%xmm1, %%xmm3\n\t" /* EncCTR-3 ^= input */
+ "movdqu %%xmm3, (32)%[dst]\n\t" /* Store block 3. */
+
+ "movdqu (48)%[src], %%xmm1\n\t" /* Get block 4. */
+ "pxor %%xmm1, %%xmm4\n\t" /* EncCTR-4 ^= input */
+ "movdqu %%xmm4, (48)%[dst]" /* Store block 4. */
+
+ : [ctr] "+m" (*ctr), [dst] "=m" (*b)
+ : [src] "m" (*a),
+ [key] "g" (ctx->keyschenc),
+ [rounds] "g" (ctx->rounds),
+ [mask] "m" (*be_mask)
+ : "%esi", "cc", "memory");
+#undef aesenc_xmm1_xmm0
+#undef aesenc_xmm1_xmm2
+#undef aesenc_xmm1_xmm3
+#undef aesenc_xmm1_xmm4
+#undef aesenclast_xmm1_xmm0
+#undef aesenclast_xmm1_xmm2
+#undef aesenclast_xmm1_xmm3
+#undef aesenclast_xmm1_xmm4
+}
+
+
+static void
+do_aesni (RIJNDAEL_context *ctx, int decrypt_flag,
+ unsigned char *bx, const unsigned char *ax)
+{
+
+ if (decrypt_flag)
+ {
+ if (!ctx->decryption_prepared )
+ {
+ prepare_decryption ( ctx );
+ ctx->decryption_prepared = 1;
+ }
+ do_aesni_dec_aligned (ctx, bx, ax);
+ }
+ else
+ do_aesni_enc_aligned (ctx, bx, ax);
+}
+#endif /*USE_AESNI*/
+
+
+static void
+rijndael_encrypt (void *context, byte *b, const byte *a)
+{
+ RIJNDAEL_context *ctx = context;
+
+ if (0)
+ ;
+#ifdef USE_PADLOCK
+ else if (ctx->use_padlock)
+ {
+ do_padlock (ctx, 0, b, a);
+ _gcry_burn_stack (48 + 15 /* possible padding for alignment */);
+ }
+#endif /*USE_PADLOCK*/
+#ifdef USE_AESNI
+ else if (ctx->use_aesni)
+ {
+ aesni_prepare ();
+ do_aesni (ctx, 0, b, a);
+ aesni_cleanup ();
+ }
+#endif /*USE_AESNI*/
+ else
+ {
+ do_encrypt (ctx, b, a);
+ _gcry_burn_stack (56 + 2*sizeof(int));
+ }
+}
+
+
+/* Bulk encryption of complete blocks in CFB mode. Caller needs to
+ make sure that IV is aligned on an unsigned long boundary. This
+ function is only intended for the bulk encryption feature of
+ cipher.c. */
+void
+_gcry_aes_cfb_enc (void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks)
+{
+ RIJNDAEL_context *ctx = context;
+ unsigned char *outbuf = outbuf_arg;
+ const unsigned char *inbuf = inbuf_arg;
+ unsigned char *ivp;
+ int i;
+
+ if (0)
+ ;
+#ifdef USE_PADLOCK
+ else if (ctx->use_padlock)
+ {
+ /* Fixme: Let Padlock do the CFBing. */
+ for ( ;nblocks; nblocks-- )
+ {
+ /* Encrypt the IV. */
+ do_padlock (ctx, 0, iv, iv);
+ /* XOR the input with the IV and store input into IV. */
+ for (ivp=iv,i=0; i < BLOCKSIZE; i++ )
+ *outbuf++ = (*ivp++ ^= *inbuf++);
+ }
+ }
+#endif /*USE_PADLOCK*/
+#ifdef USE_AESNI
+ else if (ctx->use_aesni)
+ {
+ aesni_prepare ();
+ for ( ;nblocks; nblocks-- )
+ {
+ do_aesni_cfb (ctx, 0, iv, outbuf, inbuf);
+ outbuf += BLOCKSIZE;
+ inbuf += BLOCKSIZE;
+ }
+ aesni_cleanup ();
+ }
+#endif /*USE_AESNI*/
+ else
+ {
+ for ( ;nblocks; nblocks-- )
+ {
+ /* Encrypt the IV. */
+ do_encrypt_aligned (ctx, iv, iv);
+ /* XOR the input with the IV and store input into IV. */
+ for (ivp=iv,i=0; i < BLOCKSIZE; i++ )
+ *outbuf++ = (*ivp++ ^= *inbuf++);
+ }
+ }
+
+ _gcry_burn_stack (48 + 2*sizeof(int));
+}
+
+
+/* Bulk encryption of complete blocks in CBC mode. Caller needs to
+ make sure that IV is aligned on an unsigned long boundary. This
+ function is only intended for the bulk encryption feature of
+ cipher.c. */
+void
+_gcry_aes_cbc_enc (void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks, int cbc_mac)
+{
+ RIJNDAEL_context *ctx = context;
+ unsigned char *outbuf = outbuf_arg;
+ const unsigned char *inbuf = inbuf_arg;
+ unsigned char *ivp;
+ int i;
+
+#ifdef USE_AESNI
+ if (ctx->use_aesni)
+ aesni_prepare ();
+#endif /*USE_AESNI*/
+
+ for ( ;nblocks; nblocks-- )
+ {
+ for (ivp=iv, i=0; i < BLOCKSIZE; i++ )
+ outbuf[i] = inbuf[i] ^ *ivp++;
+
+ if (0)
+ ;
+#ifdef USE_PADLOCK
+ else if (ctx->use_padlock)
+ do_padlock (ctx, 0, outbuf, outbuf);
+#endif /*USE_PADLOCK*/
+#ifdef USE_AESNI
+ else if (ctx->use_aesni)
+ do_aesni (ctx, 0, outbuf, outbuf);
+#endif /*USE_AESNI*/
+ else
+ do_encrypt (ctx, outbuf, outbuf );
+
+ memcpy (iv, outbuf, BLOCKSIZE);
+ inbuf += BLOCKSIZE;
+ if (!cbc_mac)
+ outbuf += BLOCKSIZE;
+ }
+
+#ifdef USE_AESNI
+ if (ctx->use_aesni)
+ aesni_cleanup ();
+#endif /*USE_AESNI*/
+
+ _gcry_burn_stack (48 + 2*sizeof(int));
+}
+
+
+/* Bulk encryption of complete blocks in CTR mode. Caller needs to
+ make sure that CTR is aligned on a 16 byte boundary if AESNI; the
+ minimum alignment is for an u32. This function is only intended
+ for the bulk encryption feature of cipher.c. CTR is expected to be
+ of size BLOCKSIZE. */
+void
+_gcry_aes_ctr_enc (void *context, unsigned char *ctr,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks)
+{
+ RIJNDAEL_context *ctx = context;
+ unsigned char *outbuf = outbuf_arg;
+ const unsigned char *inbuf = inbuf_arg;
+ unsigned char *p;
+ int i;
+
+ if (0)
+ ;
+#ifdef USE_AESNI
+ else if (ctx->use_aesni)
+ {
+ aesni_prepare ();
+ for ( ;nblocks > 3 ; nblocks -= 4 )
+ {
+ do_aesni_ctr_4 (ctx, ctr, outbuf, inbuf);
+ outbuf += 4*BLOCKSIZE;
+ inbuf += 4*BLOCKSIZE;
+ }
+ for ( ;nblocks; nblocks-- )
+ {
+ do_aesni_ctr (ctx, ctr, outbuf, inbuf);
+ outbuf += BLOCKSIZE;
+ inbuf += BLOCKSIZE;
+ }
+ aesni_cleanup ();
+ aesni_cleanup_2_4 ();
+ }
+#endif /*USE_AESNI*/
+ else
+ {
+ union { unsigned char x1[16]; u32 x32[4]; } tmp;
+
+ for ( ;nblocks; nblocks-- )
+ {
+ /* Encrypt the counter. */
+ do_encrypt_aligned (ctx, tmp.x1, ctr);
+ /* XOR the input with the encrypted counter and store in output. */
+ for (p=tmp.x1, i=0; i < BLOCKSIZE; i++)
+ *outbuf++ = (*p++ ^= *inbuf++);
+ /* Increment the counter. */
+ for (i = BLOCKSIZE; i > 0; i--)
+ {
+ ctr[i-1]++;
+ if (ctr[i-1])
+ break;
+ }
+ }
+ }
+
+ _gcry_burn_stack (48 + 2*sizeof(int));
+}
+
+
+
+/* Decrypt one block. A and B need to be aligned on a 4 byte boundary
+ and the decryption must have been prepared. A and B may be the
+ same. */
+static void
+do_decrypt_aligned (RIJNDAEL_context *ctx,
+ unsigned char *b, const unsigned char *a)
+{
+#define rk (ctx->keyschdec)
+ int rounds = ctx->rounds;
+ int r;
+ union
+ {
+ u32 tempu32[4]; /* Force correct alignment. */
+ byte temp[4][4];
+ } u;
+
+
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(a )) ^ *((u32_a_t*)rk[rounds][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(a+ 4)) ^ *((u32_a_t*)rk[rounds][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(a+ 8)) ^ *((u32_a_t*)rk[rounds][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(a+12)) ^ *((u32_a_t*)rk[rounds][3]);
+
+ *((u32_a_t*)(b )) = (*((u32_a_t*)T5[u.temp[0][0]])
+ ^ *((u32_a_t*)T6[u.temp[3][1]])
+ ^ *((u32_a_t*)T7[u.temp[2][2]])
+ ^ *((u32_a_t*)T8[u.temp[1][3]]));
+ *((u32_a_t*)(b+ 4)) = (*((u32_a_t*)T5[u.temp[1][0]])
+ ^ *((u32_a_t*)T6[u.temp[0][1]])
+ ^ *((u32_a_t*)T7[u.temp[3][2]])
+ ^ *((u32_a_t*)T8[u.temp[2][3]]));
+ *((u32_a_t*)(b+ 8)) = (*((u32_a_t*)T5[u.temp[2][0]])
+ ^ *((u32_a_t*)T6[u.temp[1][1]])
+ ^ *((u32_a_t*)T7[u.temp[0][2]])
+ ^ *((u32_a_t*)T8[u.temp[3][3]]));
+ *((u32_a_t*)(b+12)) = (*((u32_a_t*)T5[u.temp[3][0]])
+ ^ *((u32_a_t*)T6[u.temp[2][1]])
+ ^ *((u32_a_t*)T7[u.temp[1][2]])
+ ^ *((u32_a_t*)T8[u.temp[0][3]]));
+
+ for (r = rounds-1; r > 1; r--)
+ {
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(b )) ^ *((u32_a_t*)rk[r][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(b+ 4)) ^ *((u32_a_t*)rk[r][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(b+ 8)) ^ *((u32_a_t*)rk[r][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(b+12)) ^ *((u32_a_t*)rk[r][3]);
+ *((u32_a_t*)(b )) = (*((u32_a_t*)T5[u.temp[0][0]])
+ ^ *((u32_a_t*)T6[u.temp[3][1]])
+ ^ *((u32_a_t*)T7[u.temp[2][2]])
+ ^ *((u32_a_t*)T8[u.temp[1][3]]));
+ *((u32_a_t*)(b+ 4)) = (*((u32_a_t*)T5[u.temp[1][0]])
+ ^ *((u32_a_t*)T6[u.temp[0][1]])
+ ^ *((u32_a_t*)T7[u.temp[3][2]])
+ ^ *((u32_a_t*)T8[u.temp[2][3]]));
+ *((u32_a_t*)(b+ 8)) = (*((u32_a_t*)T5[u.temp[2][0]])
+ ^ *((u32_a_t*)T6[u.temp[1][1]])
+ ^ *((u32_a_t*)T7[u.temp[0][2]])
+ ^ *((u32_a_t*)T8[u.temp[3][3]]));
+ *((u32_a_t*)(b+12)) = (*((u32_a_t*)T5[u.temp[3][0]])
+ ^ *((u32_a_t*)T6[u.temp[2][1]])
+ ^ *((u32_a_t*)T7[u.temp[1][2]])
+ ^ *((u32_a_t*)T8[u.temp[0][3]]));
+ }
+
+ /* Last round is special. */
+ *((u32_a_t*)u.temp[0]) = *((u32_a_t*)(b )) ^ *((u32_a_t*)rk[1][0]);
+ *((u32_a_t*)u.temp[1]) = *((u32_a_t*)(b+ 4)) ^ *((u32_a_t*)rk[1][1]);
+ *((u32_a_t*)u.temp[2]) = *((u32_a_t*)(b+ 8)) ^ *((u32_a_t*)rk[1][2]);
+ *((u32_a_t*)u.temp[3]) = *((u32_a_t*)(b+12)) ^ *((u32_a_t*)rk[1][3]);
+ b[ 0] = S5[u.temp[0][0]];
+ b[ 1] = S5[u.temp[3][1]];
+ b[ 2] = S5[u.temp[2][2]];
+ b[ 3] = S5[u.temp[1][3]];
+ b[ 4] = S5[u.temp[1][0]];
+ b[ 5] = S5[u.temp[0][1]];
+ b[ 6] = S5[u.temp[3][2]];
+ b[ 7] = S5[u.temp[2][3]];
+ b[ 8] = S5[u.temp[2][0]];
+ b[ 9] = S5[u.temp[1][1]];
+ b[10] = S5[u.temp[0][2]];
+ b[11] = S5[u.temp[3][3]];
+ b[12] = S5[u.temp[3][0]];
+ b[13] = S5[u.temp[2][1]];
+ b[14] = S5[u.temp[1][2]];
+ b[15] = S5[u.temp[0][3]];
+ *((u32_a_t*)(b )) ^= *((u32_a_t*)rk[0][0]);
+ *((u32_a_t*)(b+ 4)) ^= *((u32_a_t*)rk[0][1]);
+ *((u32_a_t*)(b+ 8)) ^= *((u32_a_t*)rk[0][2]);
+ *((u32_a_t*)(b+12)) ^= *((u32_a_t*)rk[0][3]);
+#undef rk
+}
+
+
+/* Decrypt one block. AX and BX may be the same. */
+static void
+do_decrypt (RIJNDAEL_context *ctx, byte *bx, const byte *ax)
+{
+ if ( !ctx->decryption_prepared )
+ {
+ prepare_decryption ( ctx );
+ _gcry_burn_stack (64);
+ ctx->decryption_prepared = 1;
+ }
+
+ /* BX and AX are not necessary correctly aligned. Thus we might
+ need to copy them here. We try to align to a 16 bytes. */
+ if (((size_t)ax & 0x0f) || ((size_t)bx & 0x0f))
+ {
+ union
+ {
+ u32 dummy[4];
+ byte a[16] ATTR_ALIGNED_16;
+ } a;
+ union
+ {
+ u32 dummy[4];
+ byte b[16] ATTR_ALIGNED_16;
+ } b;
+
+ memcpy (a.a, ax, 16);
+ do_decrypt_aligned (ctx, b.b, a.a);
+ memcpy (bx, b.b, 16);
+ }
+ else
+ {
+ do_decrypt_aligned (ctx, bx, ax);
+ }
+}
+
+
+
+
+static void
+rijndael_decrypt (void *context, byte *b, const byte *a)
+{
+ RIJNDAEL_context *ctx = context;
+
+ if (0)
+ ;
+#ifdef USE_PADLOCK
+ else if (ctx->use_padlock)
+ {
+ do_padlock (ctx, 1, b, a);
+ _gcry_burn_stack (48 + 2*sizeof(int) /* FIXME */);
+ }
+#endif /*USE_PADLOCK*/
+#ifdef USE_AESNI
+ else if (ctx->use_aesni)
+ {
+ aesni_prepare ();
+ do_aesni (ctx, 1, b, a);
+ aesni_cleanup ();
+ }
+#endif /*USE_AESNI*/
+ else
+ {
+ do_decrypt (ctx, b, a);
+ _gcry_burn_stack (56+2*sizeof(int));
+ }
+}
+
+
+/* Bulk decryption of complete blocks in CFB mode. Caller needs to
+ make sure that IV is aligned on an unisgned lonhg boundary. This
+ function is only intended for the bulk encryption feature of
+ cipher.c. */
+void
+_gcry_aes_cfb_dec (void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks)
+{
+ RIJNDAEL_context *ctx = context;
+ unsigned char *outbuf = outbuf_arg;
+ const unsigned char *inbuf = inbuf_arg;
+ unsigned char *ivp;
+ unsigned char temp;
+ int i;
+
+ if (0)
+ ;
+#ifdef USE_PADLOCK
+ else if (ctx->use_padlock)
+ {
+ /* Fixme: Let Padlock do the CFBing. */
+ for ( ;nblocks; nblocks-- )
+ {
+ do_padlock (ctx, 0, iv, iv);
+ for (ivp=iv,i=0; i < BLOCKSIZE; i++ )
+ {
+ temp = *inbuf++;
+ *outbuf++ = *ivp ^ temp;
+ *ivp++ = temp;
+ }
+ }
+ }
+#endif /*USE_PADLOCK*/
+#ifdef USE_AESNI
+ else if (ctx->use_aesni)
+ {
+ aesni_prepare ();
+ for ( ;nblocks; nblocks-- )
+ {
+ do_aesni_cfb (ctx, 1, iv, outbuf, inbuf);
+ outbuf += BLOCKSIZE;
+ inbuf += BLOCKSIZE;
+ }
+ aesni_cleanup ();
+ }
+#endif /*USE_AESNI*/
+ else
+ {
+ for ( ;nblocks; nblocks-- )
+ {
+ do_encrypt_aligned (ctx, iv, iv);
+ for (ivp=iv,i=0; i < BLOCKSIZE; i++ )
+ {
+ temp = *inbuf++;
+ *outbuf++ = *ivp ^ temp;
+ *ivp++ = temp;
+ }
+ }
+ }
+
+ _gcry_burn_stack (48 + 2*sizeof(int));
+}
+
+
+/* Bulk decryption of complete blocks in CBC mode. Caller needs to
+ make sure that IV is aligned on an unsigned long boundary. This
+ function is only intended for the bulk encryption feature of
+ cipher.c. */
+void
+_gcry_aes_cbc_dec (void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks)
+{
+ RIJNDAEL_context *ctx = context;
+ unsigned char *outbuf = outbuf_arg;
+ const unsigned char *inbuf = inbuf_arg;
+ unsigned char *ivp;
+ int i;
+ unsigned char savebuf[BLOCKSIZE];
+
+#ifdef USE_AESNI
+ if (ctx->use_aesni)
+ aesni_prepare ();
+#endif /*USE_AESNI*/
+
+ for ( ;nblocks; nblocks-- )
+ {
+ /* We need to save INBUF away because it may be identical to
+ OUTBUF. */
+ memcpy (savebuf, inbuf, BLOCKSIZE);
+
+ if (0)
+ ;
+#ifdef USE_PADLOCK
+ else if (ctx->use_padlock)
+ do_padlock (ctx, 1, outbuf, inbuf);
+#endif /*USE_PADLOCK*/
+#ifdef USE_AESNI
+ else if (ctx->use_aesni)
+ do_aesni (ctx, 1, outbuf, inbuf);
+#endif /*USE_AESNI*/
+ else
+ do_decrypt (ctx, outbuf, inbuf);
+
+ for (ivp=iv, i=0; i < BLOCKSIZE; i++ )
+ outbuf[i] ^= *ivp++;
+ memcpy (iv, savebuf, BLOCKSIZE);
+ inbuf += BLOCKSIZE;
+ outbuf += BLOCKSIZE;
+ }
+
+#ifdef USE_AESNI
+ if (ctx->use_aesni)
+ aesni_cleanup ();
+#endif /*USE_AESNI*/
+
+ _gcry_burn_stack (48 + 2*sizeof(int) + BLOCKSIZE + 4*sizeof (char*));
+}
+
+
+
+
+/* Run the self-tests for AES 128. Returns NULL on success. */
+static const char*
+selftest_basic_128 (void)
+{
+ RIJNDAEL_context ctx;
+ unsigned char scratch[16];
+
+ /* The test vectors are from the AES supplied ones; more or less
+ randomly taken from ecb_tbl.txt (I=42,81,14) */
+#if 1
+ static const unsigned char plaintext_128[16] =
+ {
+ 0x01,0x4B,0xAF,0x22,0x78,0xA6,0x9D,0x33,
+ 0x1D,0x51,0x80,0x10,0x36,0x43,0xE9,0x9A
+ };
+ static const unsigned char key_128[16] =
+ {
+ 0xE8,0xE9,0xEA,0xEB,0xED,0xEE,0xEF,0xF0,
+ 0xF2,0xF3,0xF4,0xF5,0xF7,0xF8,0xF9,0xFA
+ };
+ static const unsigned char ciphertext_128[16] =
+ {
+ 0x67,0x43,0xC3,0xD1,0x51,0x9A,0xB4,0xF2,
+ 0xCD,0x9A,0x78,0xAB,0x09,0xA5,0x11,0xBD
+ };
+#else
+ /* Test vectors from fips-197, appendix C. */
+# warning debug test vectors in use
+ static const unsigned char plaintext_128[16] =
+ {
+ 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
+ 0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff
+ };
+ static const unsigned char key_128[16] =
+ {
+ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
+ 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f
+ /* 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, */
+ /* 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c */
+ };
+ static const unsigned char ciphertext_128[16] =
+ {
+ 0x69,0xc4,0xe0,0xd8,0x6a,0x7b,0x04,0x30,
+ 0xd8,0xcd,0xb7,0x80,0x70,0xb4,0xc5,0x5a
+ };
+#endif
+
+ rijndael_setkey (&ctx, key_128, sizeof (key_128));
+ rijndael_encrypt (&ctx, scratch, plaintext_128);
+ if (memcmp (scratch, ciphertext_128, sizeof (ciphertext_128)))
+ return "AES-128 test encryption failed.";
+ rijndael_decrypt (&ctx, scratch, scratch);
+ if (memcmp (scratch, plaintext_128, sizeof (plaintext_128)))
+ return "AES-128 test decryption failed.";
+
+ return NULL;
+}
+
+/* Run the self-tests for AES 192. Returns NULL on success. */
+static const char*
+selftest_basic_192 (void)
+{
+ RIJNDAEL_context ctx;
+ unsigned char scratch[16];
+
+ static unsigned char plaintext_192[16] =
+ {
+ 0x76,0x77,0x74,0x75,0xF1,0xF2,0xF3,0xF4,
+ 0xF8,0xF9,0xE6,0xE7,0x77,0x70,0x71,0x72
+ };
+ static unsigned char key_192[24] =
+ {
+ 0x04,0x05,0x06,0x07,0x09,0x0A,0x0B,0x0C,
+ 0x0E,0x0F,0x10,0x11,0x13,0x14,0x15,0x16,
+ 0x18,0x19,0x1A,0x1B,0x1D,0x1E,0x1F,0x20
+ };
+ static const unsigned char ciphertext_192[16] =
+ {
+ 0x5D,0x1E,0xF2,0x0D,0xCE,0xD6,0xBC,0xBC,
+ 0x12,0x13,0x1A,0xC7,0xC5,0x47,0x88,0xAA
+ };
+
+ rijndael_setkey (&ctx, key_192, sizeof(key_192));
+ rijndael_encrypt (&ctx, scratch, plaintext_192);
+ if (memcmp (scratch, ciphertext_192, sizeof (ciphertext_192)))
+ return "AES-192 test encryption failed.";
+ rijndael_decrypt (&ctx, scratch, scratch);
+ if (memcmp (scratch, plaintext_192, sizeof (plaintext_192)))
+ return "AES-192 test decryption failed.";
+
+ return NULL;
+}
+
+
+/* Run the self-tests for AES 256. Returns NULL on success. */
+static const char*
+selftest_basic_256 (void)
+{
+ RIJNDAEL_context ctx;
+ unsigned char scratch[16];
+
+ static unsigned char plaintext_256[16] =
+ {
+ 0x06,0x9A,0x00,0x7F,0xC7,0x6A,0x45,0x9F,
+ 0x98,0xBA,0xF9,0x17,0xFE,0xDF,0x95,0x21
+ };
+ static unsigned char key_256[32] =
+ {
+ 0x08,0x09,0x0A,0x0B,0x0D,0x0E,0x0F,0x10,
+ 0x12,0x13,0x14,0x15,0x17,0x18,0x19,0x1A,
+ 0x1C,0x1D,0x1E,0x1F,0x21,0x22,0x23,0x24,
+ 0x26,0x27,0x28,0x29,0x2B,0x2C,0x2D,0x2E
+ };
+ static const unsigned char ciphertext_256[16] =
+ {
+ 0x08,0x0E,0x95,0x17,0xEB,0x16,0x77,0x71,
+ 0x9A,0xCF,0x72,0x80,0x86,0x04,0x0A,0xE3
+ };
+
+ rijndael_setkey (&ctx, key_256, sizeof(key_256));
+ rijndael_encrypt (&ctx, scratch, plaintext_256);
+ if (memcmp (scratch, ciphertext_256, sizeof (ciphertext_256)))
+ return "AES-256 test encryption failed.";
+ rijndael_decrypt (&ctx, scratch, scratch);
+ if (memcmp (scratch, plaintext_256, sizeof (plaintext_256)))
+ return "AES-256 test decryption failed.";
+
+ return NULL;
+}
+
+/* Run all the self-tests and return NULL on success. This function
+ is used for the on-the-fly self-tests. */
+static const char *
+selftest (void)
+{
+ const char *r;
+
+ if ( (r = selftest_basic_128 ())
+ || (r = selftest_basic_192 ())
+ || (r = selftest_basic_256 ()) )
+ return r;
+
+ return r;
+}
+
+
+/* SP800-38a.pdf for AES-128. */
+static const char *
+selftest_fips_128_38a (int requested_mode)
+{
+ struct tv
+ {
+ int mode;
+ const unsigned char key[16];
+ const unsigned char iv[16];
+ struct
+ {
+ const unsigned char input[16];
+ const unsigned char output[16];
+ } data[4];
+ } tv[2] =
+ {
+ {
+ GCRY_CIPHER_MODE_CFB, /* F.3.13, CFB128-AES128 */
+ { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c },
+ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ {
+ { { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a },
+ { 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20,
+ 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a } },
+
+ { { 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51 },
+ { 0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f,
+ 0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b } },
+
+ { { 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef },
+ { 0x26, 0x75, 0x1f, 0x67, 0xa3, 0xcb, 0xb1, 0x40,
+ 0xb1, 0x80, 0x8c, 0xf1, 0x87, 0xa4, 0xf4, 0xdf } },
+
+ { { 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
+ { 0xc0, 0x4b, 0x05, 0x35, 0x7c, 0x5d, 0x1c, 0x0e,
+ 0xea, 0xc4, 0xc6, 0x6f, 0x9f, 0xf7, 0xf2, 0xe6 } }
+ }
+ },
+ {
+ GCRY_CIPHER_MODE_OFB,
+ { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c },
+ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
+ {
+ { { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a },
+ { 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20,
+ 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a } },
+
+ { { 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51 },
+ { 0x77, 0x89, 0x50, 0x8d, 0x16, 0x91, 0x8f, 0x03,
+ 0xf5, 0x3c, 0x52, 0xda, 0xc5, 0x4e, 0xd8, 0x25 } },
+
+ { { 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef },
+ { 0x97, 0x40, 0x05, 0x1e, 0x9c, 0x5f, 0xec, 0xf6,
+ 0x43, 0x44, 0xf7, 0xa8, 0x22, 0x60, 0xed, 0xcc } },
+
+ { { 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
+ { 0x30, 0x4c, 0x65, 0x28, 0xf6, 0x59, 0xc7, 0x78,
+ 0x66, 0xa5, 0x10, 0xd9, 0xc1, 0xd6, 0xae, 0x5e } },
+ }
+ }
+ };
+ unsigned char scratch[16];
+ gpg_error_t err;
+ int tvi, idx;
+ gcry_cipher_hd_t hdenc = NULL;
+ gcry_cipher_hd_t hddec = NULL;
+
+#define Fail(a) do { \
+ _gcry_cipher_close (hdenc); \
+ _gcry_cipher_close (hddec); \
+ return a; \
+ } while (0)
+
+ gcry_assert (sizeof tv[0].data[0].input == sizeof scratch);
+ gcry_assert (sizeof tv[0].data[0].output == sizeof scratch);
+
+ for (tvi=0; tvi < DIM (tv); tvi++)
+ if (tv[tvi].mode == requested_mode)
+ break;
+ if (tvi == DIM (tv))
+ Fail ("no test data for this mode");
+
+ err = _gcry_cipher_open (&hdenc, GCRY_CIPHER_AES, tv[tvi].mode, 0);
+ if (err)
+ Fail ("open");
+ err = _gcry_cipher_open (&hddec, GCRY_CIPHER_AES, tv[tvi].mode, 0);
+ if (err)
+ Fail ("open");
+ err = _gcry_cipher_setkey (hdenc, tv[tvi].key, sizeof tv[tvi].key);
+ if (!err)
+ err = _gcry_cipher_setkey (hddec, tv[tvi].key, sizeof tv[tvi].key);
+ if (err)
+ Fail ("set key");
+ err = _gcry_cipher_setiv (hdenc, tv[tvi].iv, sizeof tv[tvi].iv);
+ if (!err)
+ err = _gcry_cipher_setiv (hddec, tv[tvi].iv, sizeof tv[tvi].iv);
+ if (err)
+ Fail ("set IV");
+ for (idx=0; idx < DIM (tv[tvi].data); idx++)
+ {
+ err = _gcry_cipher_encrypt (hdenc, scratch, sizeof scratch,
+ tv[tvi].data[idx].input,
+ sizeof tv[tvi].data[idx].input);
+ if (err)
+ Fail ("encrypt command");
+ if (memcmp (scratch, tv[tvi].data[idx].output, sizeof scratch))
+ Fail ("encrypt mismatch");
+ err = _gcry_cipher_decrypt (hddec, scratch, sizeof scratch,
+ tv[tvi].data[idx].output,
+ sizeof tv[tvi].data[idx].output);
+ if (err)
+ Fail ("decrypt command");
+ if (memcmp (scratch, tv[tvi].data[idx].input, sizeof scratch))
+ Fail ("decrypt mismatch");
+ }
+
+#undef Fail
+ _gcry_cipher_close (hdenc);
+ _gcry_cipher_close (hddec);
+ return NULL;
+}
+
+
+/* Complete selftest for AES-128 with all modes and driver code. */
+static gpg_err_code_t
+selftest_fips_128 (int extended, selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+
+ what = "low-level";
+ errtxt = selftest_basic_128 ();
+ if (errtxt)
+ goto failed;
+
+ if (extended)
+ {
+ what = "cfb";
+ errtxt = selftest_fips_128_38a (GCRY_CIPHER_MODE_CFB);
+ if (errtxt)
+ goto failed;
+
+ what = "ofb";
+ errtxt = selftest_fips_128_38a (GCRY_CIPHER_MODE_OFB);
+ if (errtxt)
+ goto failed;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("cipher", GCRY_CIPHER_AES128, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+/* Complete selftest for AES-192. */
+static gpg_err_code_t
+selftest_fips_192 (int extended, selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+
+ (void)extended; /* No extended tests available. */
+
+ what = "low-level";
+ errtxt = selftest_basic_192 ();
+ if (errtxt)
+ goto failed;
+
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("cipher", GCRY_CIPHER_AES192, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+/* Complete selftest for AES-256. */
+static gpg_err_code_t
+selftest_fips_256 (int extended, selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+
+ (void)extended; /* No extended tests available. */
+
+ what = "low-level";
+ errtxt = selftest_basic_256 ();
+ if (errtxt)
+ goto failed;
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("cipher", GCRY_CIPHER_AES256, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+static gpg_err_code_t
+run_selftests (int algo, int extended, selftest_report_func_t report)
+{
+ gpg_err_code_t ec;
+
+ switch (algo)
+ {
+ case GCRY_CIPHER_AES128:
+ ec = selftest_fips_128 (extended, report);
+ break;
+ case GCRY_CIPHER_AES192:
+ ec = selftest_fips_192 (extended, report);
+ break;
+ case GCRY_CIPHER_AES256:
+ ec = selftest_fips_256 (extended, report);
+ break;
+ default:
+ ec = GPG_ERR_CIPHER_ALGO;
+ break;
+
+ }
+ return ec;
+}
+
+
+
+
+static const char *rijndael_names[] =
+ {
+ "RIJNDAEL",
+ "AES128",
+ "AES-128",
+ NULL
+ };
+
+static gcry_cipher_oid_spec_t rijndael_oids[] =
+ {
+ { "2.16.840.1.101.3.4.1.1", GCRY_CIPHER_MODE_ECB },
+ { "2.16.840.1.101.3.4.1.2", GCRY_CIPHER_MODE_CBC },
+ { "2.16.840.1.101.3.4.1.3", GCRY_CIPHER_MODE_OFB },
+ { "2.16.840.1.101.3.4.1.4", GCRY_CIPHER_MODE_CFB },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_aes =
+ {
+ "AES", rijndael_names, rijndael_oids, 16, 128, sizeof (RIJNDAEL_context),
+ rijndael_setkey, rijndael_encrypt, rijndael_decrypt
+ };
+cipher_extra_spec_t _gcry_cipher_extraspec_aes =
+ {
+ run_selftests
+ };
+
+static const char *rijndael192_names[] =
+ {
+ "RIJNDAEL192",
+ "AES-192",
+ NULL
+ };
+
+static gcry_cipher_oid_spec_t rijndael192_oids[] =
+ {
+ { "2.16.840.1.101.3.4.1.21", GCRY_CIPHER_MODE_ECB },
+ { "2.16.840.1.101.3.4.1.22", GCRY_CIPHER_MODE_CBC },
+ { "2.16.840.1.101.3.4.1.23", GCRY_CIPHER_MODE_OFB },
+ { "2.16.840.1.101.3.4.1.24", GCRY_CIPHER_MODE_CFB },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_aes192 =
+ {
+ "AES192", rijndael192_names, rijndael192_oids, 16, 192, sizeof (RIJNDAEL_context),
+ rijndael_setkey, rijndael_encrypt, rijndael_decrypt
+ };
+cipher_extra_spec_t _gcry_cipher_extraspec_aes192 =
+ {
+ run_selftests
+ };
+
+static const char *rijndael256_names[] =
+ {
+ "RIJNDAEL256",
+ "AES-256",
+ NULL
+ };
+
+static gcry_cipher_oid_spec_t rijndael256_oids[] =
+ {
+ { "2.16.840.1.101.3.4.1.41", GCRY_CIPHER_MODE_ECB },
+ { "2.16.840.1.101.3.4.1.42", GCRY_CIPHER_MODE_CBC },
+ { "2.16.840.1.101.3.4.1.43", GCRY_CIPHER_MODE_OFB },
+ { "2.16.840.1.101.3.4.1.44", GCRY_CIPHER_MODE_CFB },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_aes256 =
+ {
+ "AES256", rijndael256_names, rijndael256_oids, 16, 256,
+ sizeof (RIJNDAEL_context),
+ rijndael_setkey, rijndael_encrypt, rijndael_decrypt
+ };
+
+cipher_extra_spec_t _gcry_cipher_extraspec_aes256 =
+ {
+ run_selftests
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/rmd.h b/grub-core/lib/libgcrypt/cipher/rmd.h
new file mode 100644
index 0000000..6a9fe31
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/rmd.h
@@ -0,0 +1,36 @@
+/* rmd.h - RIPE-MD hash functions
+ * Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+#ifndef G10_RMD_H
+#define G10_RMD_H
+
+
+/* We need this here because random.c must have direct access. */
+typedef struct
+{
+ u32 h0,h1,h2,h3,h4;
+ u32 nblocks;
+ byte buf[64];
+ int count;
+} RMD160_CONTEXT;
+
+void _gcry_rmd160_init ( void *context );
+void _gcry_rmd160_mixblock ( RMD160_CONTEXT *hd, void *blockof64byte );
+
+#endif /*G10_RMD_H*/
diff --git a/grub-core/lib/libgcrypt/cipher/rmd160.c b/grub-core/lib/libgcrypt/cipher/rmd160.c
new file mode 100644
index 0000000..179a4d9
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/rmd160.c
@@ -0,0 +1,572 @@
+/* rmd160.c - RIPE-MD160
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "g10lib.h"
+#include "rmd.h"
+#include "cipher.h" /* Only used for the rmd160_hash_buffer() prototype. */
+
+#include "bithelp.h"
+
+/*********************************
+ * RIPEMD-160 is not patented, see (as of 25.10.97)
+ * http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html
+ * Note that the code uses Little Endian byteorder, which is good for
+ * 386 etc, but we must add some conversion when used on a big endian box.
+ *
+ *
+ * Pseudo-code for RIPEMD-160
+ *
+ * RIPEMD-160 is an iterative hash function that operates on 32-bit words.
+ * The round function takes as input a 5-word chaining variable and a 16-word
+ * message block and maps this to a new chaining variable. All operations are
+ * defined on 32-bit words. Padding is identical to that of MD4.
+ *
+ *
+ * RIPEMD-160: definitions
+ *
+ *
+ * nonlinear functions at bit level: exor, mux, -, mux, -
+ *
+ * f(j, x, y, z) = x XOR y XOR z (0 <= j <= 15)
+ * f(j, x, y, z) = (x AND y) OR (NOT(x) AND z) (16 <= j <= 31)
+ * f(j, x, y, z) = (x OR NOT(y)) XOR z (32 <= j <= 47)
+ * f(j, x, y, z) = (x AND z) OR (y AND NOT(z)) (48 <= j <= 63)
+ * f(j, x, y, z) = x XOR (y OR NOT(z)) (64 <= j <= 79)
+ *
+ *
+ * added constants (hexadecimal)
+ *
+ * K(j) = 0x00000000 (0 <= j <= 15)
+ * K(j) = 0x5A827999 (16 <= j <= 31) int(2**30 x sqrt(2))
+ * K(j) = 0x6ED9EBA1 (32 <= j <= 47) int(2**30 x sqrt(3))
+ * K(j) = 0x8F1BBCDC (48 <= j <= 63) int(2**30 x sqrt(5))
+ * K(j) = 0xA953FD4E (64 <= j <= 79) int(2**30 x sqrt(7))
+ * K'(j) = 0x50A28BE6 (0 <= j <= 15) int(2**30 x cbrt(2))
+ * K'(j) = 0x5C4DD124 (16 <= j <= 31) int(2**30 x cbrt(3))
+ * K'(j) = 0x6D703EF3 (32 <= j <= 47) int(2**30 x cbrt(5))
+ * K'(j) = 0x7A6D76E9 (48 <= j <= 63) int(2**30 x cbrt(7))
+ * K'(j) = 0x00000000 (64 <= j <= 79)
+ *
+ *
+ * selection of message word
+ *
+ * r(j) = j (0 <= j <= 15)
+ * r(16..31) = 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8
+ * r(32..47) = 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12
+ * r(48..63) = 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2
+ * r(64..79) = 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
+ * r0(0..15) = 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12
+ * r0(16..31)= 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2
+ * r0(32..47)= 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13
+ * r0(48..63)= 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14
+ * r0(64..79)= 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
+ *
+ *
+ * amount for rotate left (rol)
+ *
+ * s(0..15) = 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8
+ * s(16..31) = 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12
+ * s(32..47) = 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5
+ * s(48..63) = 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12
+ * s(64..79) = 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
+ * s'(0..15) = 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6
+ * s'(16..31)= 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11
+ * s'(32..47)= 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5
+ * s'(48..63)= 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8
+ * s'(64..79)= 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
+ *
+ *
+ * initial value (hexadecimal)
+ *
+ * h0 = 0x67452301; h1 = 0xEFCDAB89; h2 = 0x98BADCFE; h3 = 0x10325476;
+ * h4 = 0xC3D2E1F0;
+ *
+ *
+ * RIPEMD-160: pseudo-code
+ *
+ * It is assumed that the message after padding consists of t 16-word blocks
+ * that will be denoted with X[i][j], with 0 <= i <= t-1 and 0 <= j <= 15.
+ * The symbol [+] denotes addition modulo 2**32 and rol_s denotes cyclic left
+ * shift (rotate) over s positions.
+ *
+ *
+ * for i := 0 to t-1 {
+ * A := h0; B := h1; C := h2; D = h3; E = h4;
+ * A' := h0; B' := h1; C' := h2; D' = h3; E' = h4;
+ * for j := 0 to 79 {
+ * T := rol_s(j)(A [+] f(j, B, C, D) [+] X[i][r(j)] [+] K(j)) [+] E;
+ * A := E; E := D; D := rol_10(C); C := B; B := T;
+ * T := rol_s'(j)(A' [+] f(79-j, B', C', D') [+] X[i][r'(j)]
+ [+] K'(j)) [+] E';
+ * A' := E'; E' := D'; D' := rol_10(C'); C' := B'; B' := T;
+ * }
+ * T := h1 [+] C [+] D'; h1 := h2 [+] D [+] E'; h2 := h3 [+] E [+] A';
+ * h3 := h4 [+] A [+] B'; h4 := h0 [+] B [+] C'; h0 := T;
+ * }
+ */
+
+/* Some examples:
+ * "" 9c1185a5c5e9fc54612808977ee8f548b2258d31
+ * "a" 0bdc9d2d256b3ee9daae347be6f4dc835a467ffe
+ * "abc" 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc
+ * "message digest" 5d0689ef49d2fae572b881b123a85ffa21595f36
+ * "a...z" f71c27109c692c1b56bbdceb5b9d2865b3708dbc
+ * "abcdbcde...nopq" 12a053384a9c0c88e405a06c27dcf49ada62eb2b
+ * "A...Za...z0...9" b0e20b6e3116640286ed3a87a5713079b21f5189
+ * 8 times "1234567890" 9b752e45573d4b39f4dbd3323cab82bf63326bfb
+ * 1 million times "a" 52783243c1697bdbe16d37f97f68f08325dc1528
+ */
+
+
+void
+_gcry_rmd160_init (void *context)
+{
+ RMD160_CONTEXT *hd = context;
+
+ hd->h0 = 0x67452301;
+ hd->h1 = 0xEFCDAB89;
+ hd->h2 = 0x98BADCFE;
+ hd->h3 = 0x10325476;
+ hd->h4 = 0xC3D2E1F0;
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+
+
+/****************
+ * Transform the message X which consists of 16 32-bit-words
+ */
+static void
+transform ( RMD160_CONTEXT *hd, const unsigned char *data )
+{
+ register u32 a,b,c,d,e;
+ u32 aa,bb,cc,dd,ee,t;
+#ifdef WORDS_BIGENDIAN
+ u32 x[16];
+ {
+ int i;
+ byte *p2;
+ const byte *p1;
+ for (i=0, p1=data, p2=(byte*)x; i < 16; i++, p2 += 4 )
+ {
+ p2[3] = *p1++;
+ p2[2] = *p1++;
+ p2[1] = *p1++;
+ p2[0] = *p1++;
+ }
+ }
+#else
+ /* This version is better because it is always aligned;
+ * The performance penalty on a 586-100 is about 6% which
+ * is acceptable - because the data is more local it might
+ * also be possible that this is faster on some machines.
+ * This function (when compiled with -02 on gcc 2.7.2)
+ * executes on a 586-100 (39.73 bogomips) at about 1900kb/sec;
+ * [measured with a 4MB data and "gpgm --print-md rmd160"] */
+ u32 x[16];
+ memcpy( x, data, 64 );
+#endif
+
+
+#define K0 0x00000000
+#define K1 0x5A827999
+#define K2 0x6ED9EBA1
+#define K3 0x8F1BBCDC
+#define K4 0xA953FD4E
+#define KK0 0x50A28BE6
+#define KK1 0x5C4DD124
+#define KK2 0x6D703EF3
+#define KK3 0x7A6D76E9
+#define KK4 0x00000000
+#define F0(x,y,z) ( (x) ^ (y) ^ (z) )
+#define F1(x,y,z) ( ((x) & (y)) | (~(x) & (z)) )
+#define F2(x,y,z) ( ((x) | ~(y)) ^ (z) )
+#define F3(x,y,z) ( ((x) & (z)) | ((y) & ~(z)) )
+#define F4(x,y,z) ( (x) ^ ((y) | ~(z)) )
+#define R(a,b,c,d,e,f,k,r,s) do { t = a + f(b,c,d) + k + x[r]; \
+ a = rol(t,s) + e; \
+ c = rol(c,10); \
+ } while(0)
+
+ /* left lane */
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+ R( a, b, c, d, e, F0, K0, 0, 11 );
+ R( e, a, b, c, d, F0, K0, 1, 14 );
+ R( d, e, a, b, c, F0, K0, 2, 15 );
+ R( c, d, e, a, b, F0, K0, 3, 12 );
+ R( b, c, d, e, a, F0, K0, 4, 5 );
+ R( a, b, c, d, e, F0, K0, 5, 8 );
+ R( e, a, b, c, d, F0, K0, 6, 7 );
+ R( d, e, a, b, c, F0, K0, 7, 9 );
+ R( c, d, e, a, b, F0, K0, 8, 11 );
+ R( b, c, d, e, a, F0, K0, 9, 13 );
+ R( a, b, c, d, e, F0, K0, 10, 14 );
+ R( e, a, b, c, d, F0, K0, 11, 15 );
+ R( d, e, a, b, c, F0, K0, 12, 6 );
+ R( c, d, e, a, b, F0, K0, 13, 7 );
+ R( b, c, d, e, a, F0, K0, 14, 9 );
+ R( a, b, c, d, e, F0, K0, 15, 8 );
+ R( e, a, b, c, d, F1, K1, 7, 7 );
+ R( d, e, a, b, c, F1, K1, 4, 6 );
+ R( c, d, e, a, b, F1, K1, 13, 8 );
+ R( b, c, d, e, a, F1, K1, 1, 13 );
+ R( a, b, c, d, e, F1, K1, 10, 11 );
+ R( e, a, b, c, d, F1, K1, 6, 9 );
+ R( d, e, a, b, c, F1, K1, 15, 7 );
+ R( c, d, e, a, b, F1, K1, 3, 15 );
+ R( b, c, d, e, a, F1, K1, 12, 7 );
+ R( a, b, c, d, e, F1, K1, 0, 12 );
+ R( e, a, b, c, d, F1, K1, 9, 15 );
+ R( d, e, a, b, c, F1, K1, 5, 9 );
+ R( c, d, e, a, b, F1, K1, 2, 11 );
+ R( b, c, d, e, a, F1, K1, 14, 7 );
+ R( a, b, c, d, e, F1, K1, 11, 13 );
+ R( e, a, b, c, d, F1, K1, 8, 12 );
+ R( d, e, a, b, c, F2, K2, 3, 11 );
+ R( c, d, e, a, b, F2, K2, 10, 13 );
+ R( b, c, d, e, a, F2, K2, 14, 6 );
+ R( a, b, c, d, e, F2, K2, 4, 7 );
+ R( e, a, b, c, d, F2, K2, 9, 14 );
+ R( d, e, a, b, c, F2, K2, 15, 9 );
+ R( c, d, e, a, b, F2, K2, 8, 13 );
+ R( b, c, d, e, a, F2, K2, 1, 15 );
+ R( a, b, c, d, e, F2, K2, 2, 14 );
+ R( e, a, b, c, d, F2, K2, 7, 8 );
+ R( d, e, a, b, c, F2, K2, 0, 13 );
+ R( c, d, e, a, b, F2, K2, 6, 6 );
+ R( b, c, d, e, a, F2, K2, 13, 5 );
+ R( a, b, c, d, e, F2, K2, 11, 12 );
+ R( e, a, b, c, d, F2, K2, 5, 7 );
+ R( d, e, a, b, c, F2, K2, 12, 5 );
+ R( c, d, e, a, b, F3, K3, 1, 11 );
+ R( b, c, d, e, a, F3, K3, 9, 12 );
+ R( a, b, c, d, e, F3, K3, 11, 14 );
+ R( e, a, b, c, d, F3, K3, 10, 15 );
+ R( d, e, a, b, c, F3, K3, 0, 14 );
+ R( c, d, e, a, b, F3, K3, 8, 15 );
+ R( b, c, d, e, a, F3, K3, 12, 9 );
+ R( a, b, c, d, e, F3, K3, 4, 8 );
+ R( e, a, b, c, d, F3, K3, 13, 9 );
+ R( d, e, a, b, c, F3, K3, 3, 14 );
+ R( c, d, e, a, b, F3, K3, 7, 5 );
+ R( b, c, d, e, a, F3, K3, 15, 6 );
+ R( a, b, c, d, e, F3, K3, 14, 8 );
+ R( e, a, b, c, d, F3, K3, 5, 6 );
+ R( d, e, a, b, c, F3, K3, 6, 5 );
+ R( c, d, e, a, b, F3, K3, 2, 12 );
+ R( b, c, d, e, a, F4, K4, 4, 9 );
+ R( a, b, c, d, e, F4, K4, 0, 15 );
+ R( e, a, b, c, d, F4, K4, 5, 5 );
+ R( d, e, a, b, c, F4, K4, 9, 11 );
+ R( c, d, e, a, b, F4, K4, 7, 6 );
+ R( b, c, d, e, a, F4, K4, 12, 8 );
+ R( a, b, c, d, e, F4, K4, 2, 13 );
+ R( e, a, b, c, d, F4, K4, 10, 12 );
+ R( d, e, a, b, c, F4, K4, 14, 5 );
+ R( c, d, e, a, b, F4, K4, 1, 12 );
+ R( b, c, d, e, a, F4, K4, 3, 13 );
+ R( a, b, c, d, e, F4, K4, 8, 14 );
+ R( e, a, b, c, d, F4, K4, 11, 11 );
+ R( d, e, a, b, c, F4, K4, 6, 8 );
+ R( c, d, e, a, b, F4, K4, 15, 5 );
+ R( b, c, d, e, a, F4, K4, 13, 6 );
+
+ aa = a; bb = b; cc = c; dd = d; ee = e;
+
+ /* right lane */
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+ R( a, b, c, d, e, F4, KK0, 5, 8);
+ R( e, a, b, c, d, F4, KK0, 14, 9);
+ R( d, e, a, b, c, F4, KK0, 7, 9);
+ R( c, d, e, a, b, F4, KK0, 0, 11);
+ R( b, c, d, e, a, F4, KK0, 9, 13);
+ R( a, b, c, d, e, F4, KK0, 2, 15);
+ R( e, a, b, c, d, F4, KK0, 11, 15);
+ R( d, e, a, b, c, F4, KK0, 4, 5);
+ R( c, d, e, a, b, F4, KK0, 13, 7);
+ R( b, c, d, e, a, F4, KK0, 6, 7);
+ R( a, b, c, d, e, F4, KK0, 15, 8);
+ R( e, a, b, c, d, F4, KK0, 8, 11);
+ R( d, e, a, b, c, F4, KK0, 1, 14);
+ R( c, d, e, a, b, F4, KK0, 10, 14);
+ R( b, c, d, e, a, F4, KK0, 3, 12);
+ R( a, b, c, d, e, F4, KK0, 12, 6);
+ R( e, a, b, c, d, F3, KK1, 6, 9);
+ R( d, e, a, b, c, F3, KK1, 11, 13);
+ R( c, d, e, a, b, F3, KK1, 3, 15);
+ R( b, c, d, e, a, F3, KK1, 7, 7);
+ R( a, b, c, d, e, F3, KK1, 0, 12);
+ R( e, a, b, c, d, F3, KK1, 13, 8);
+ R( d, e, a, b, c, F3, KK1, 5, 9);
+ R( c, d, e, a, b, F3, KK1, 10, 11);
+ R( b, c, d, e, a, F3, KK1, 14, 7);
+ R( a, b, c, d, e, F3, KK1, 15, 7);
+ R( e, a, b, c, d, F3, KK1, 8, 12);
+ R( d, e, a, b, c, F3, KK1, 12, 7);
+ R( c, d, e, a, b, F3, KK1, 4, 6);
+ R( b, c, d, e, a, F3, KK1, 9, 15);
+ R( a, b, c, d, e, F3, KK1, 1, 13);
+ R( e, a, b, c, d, F3, KK1, 2, 11);
+ R( d, e, a, b, c, F2, KK2, 15, 9);
+ R( c, d, e, a, b, F2, KK2, 5, 7);
+ R( b, c, d, e, a, F2, KK2, 1, 15);
+ R( a, b, c, d, e, F2, KK2, 3, 11);
+ R( e, a, b, c, d, F2, KK2, 7, 8);
+ R( d, e, a, b, c, F2, KK2, 14, 6);
+ R( c, d, e, a, b, F2, KK2, 6, 6);
+ R( b, c, d, e, a, F2, KK2, 9, 14);
+ R( a, b, c, d, e, F2, KK2, 11, 12);
+ R( e, a, b, c, d, F2, KK2, 8, 13);
+ R( d, e, a, b, c, F2, KK2, 12, 5);
+ R( c, d, e, a, b, F2, KK2, 2, 14);
+ R( b, c, d, e, a, F2, KK2, 10, 13);
+ R( a, b, c, d, e, F2, KK2, 0, 13);
+ R( e, a, b, c, d, F2, KK2, 4, 7);
+ R( d, e, a, b, c, F2, KK2, 13, 5);
+ R( c, d, e, a, b, F1, KK3, 8, 15);
+ R( b, c, d, e, a, F1, KK3, 6, 5);
+ R( a, b, c, d, e, F1, KK3, 4, 8);
+ R( e, a, b, c, d, F1, KK3, 1, 11);
+ R( d, e, a, b, c, F1, KK3, 3, 14);
+ R( c, d, e, a, b, F1, KK3, 11, 14);
+ R( b, c, d, e, a, F1, KK3, 15, 6);
+ R( a, b, c, d, e, F1, KK3, 0, 14);
+ R( e, a, b, c, d, F1, KK3, 5, 6);
+ R( d, e, a, b, c, F1, KK3, 12, 9);
+ R( c, d, e, a, b, F1, KK3, 2, 12);
+ R( b, c, d, e, a, F1, KK3, 13, 9);
+ R( a, b, c, d, e, F1, KK3, 9, 12);
+ R( e, a, b, c, d, F1, KK3, 7, 5);
+ R( d, e, a, b, c, F1, KK3, 10, 15);
+ R( c, d, e, a, b, F1, KK3, 14, 8);
+ R( b, c, d, e, a, F0, KK4, 12, 8);
+ R( a, b, c, d, e, F0, KK4, 15, 5);
+ R( e, a, b, c, d, F0, KK4, 10, 12);
+ R( d, e, a, b, c, F0, KK4, 4, 9);
+ R( c, d, e, a, b, F0, KK4, 1, 12);
+ R( b, c, d, e, a, F0, KK4, 5, 5);
+ R( a, b, c, d, e, F0, KK4, 8, 14);
+ R( e, a, b, c, d, F0, KK4, 7, 6);
+ R( d, e, a, b, c, F0, KK4, 6, 8);
+ R( c, d, e, a, b, F0, KK4, 2, 13);
+ R( b, c, d, e, a, F0, KK4, 13, 6);
+ R( a, b, c, d, e, F0, KK4, 14, 5);
+ R( e, a, b, c, d, F0, KK4, 0, 15);
+ R( d, e, a, b, c, F0, KK4, 3, 13);
+ R( c, d, e, a, b, F0, KK4, 9, 11);
+ R( b, c, d, e, a, F0, KK4, 11, 11);
+
+
+ t = hd->h1 + d + cc;
+ hd->h1 = hd->h2 + e + dd;
+ hd->h2 = hd->h3 + a + ee;
+ hd->h3 = hd->h4 + b + aa;
+ hd->h4 = hd->h0 + c + bb;
+ hd->h0 = t;
+}
+
+
+/* Update the message digest with the contents
+ * of INBUF with length INLEN.
+ */
+static void
+rmd160_write ( void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ RMD160_CONTEXT *hd = context;
+
+ if( hd->count == 64 ) /* flush the buffer */
+ {
+ transform( hd, hd->buf );
+ _gcry_burn_stack (108+5*sizeof(void*));
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if( !inbuf )
+ return;
+ if( hd->count )
+ {
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+ rmd160_write( hd, NULL, 0 );
+ if( !inlen )
+ return;
+ }
+
+ while( inlen >= 64 )
+ {
+ transform( hd, inbuf );
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 64;
+ inbuf += 64;
+ }
+ _gcry_burn_stack (108+5*sizeof(void*));
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+/****************
+ * Apply the rmd160 transform function on the buffer which must have
+ * a length 64 bytes. Do not use this function together with the
+ * other functions, use rmd160_init to initialize internal variables.
+ * Returns: 16 bytes in buffer with the mixed contentes of buffer.
+ */
+void
+_gcry_rmd160_mixblock ( RMD160_CONTEXT *hd, void *blockof64byte )
+{
+ char *p = blockof64byte;
+
+ transform ( hd, blockof64byte );
+#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
+ X(0);
+ X(1);
+ X(2);
+ X(3);
+ X(4);
+#undef X
+}
+
+
+/* The routine terminates the computation
+ */
+
+static void
+rmd160_final( void *context )
+{
+ RMD160_CONTEXT *hd = context;
+ u32 t, msb, lsb;
+ byte *p;
+
+ rmd160_write(hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if( (lsb += hd->count) < t )
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if( hd->count < 56 ) /* enough room */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while( hd->count < 56 )
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else /* need one extra block */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while( hd->count < 64 )
+ hd->buf[hd->count++] = 0;
+ rmd160_write(hd, NULL, 0); /* flush */;
+ memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = lsb ;
+ hd->buf[57] = lsb >> 8;
+ hd->buf[58] = lsb >> 16;
+ hd->buf[59] = lsb >> 24;
+ hd->buf[60] = msb ;
+ hd->buf[61] = msb >> 8;
+ hd->buf[62] = msb >> 16;
+ hd->buf[63] = msb >> 24;
+ transform( hd, hd->buf );
+ _gcry_burn_stack (108+5*sizeof(void*));
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *p++ = hd->h##a ; *p++ = hd->h##a >> 8; \
+ *p++ = hd->h##a >> 16; *p++ = hd->h##a >> 24; } while(0)
+#else /* little endian */
+#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
+#endif
+ X(0);
+ X(1);
+ X(2);
+ X(3);
+ X(4);
+#undef X
+}
+
+static byte *
+rmd160_read( void *context )
+{
+ RMD160_CONTEXT *hd = context;
+
+ return hd->buf;
+}
+
+
+
+/****************
+ * Shortcut functions which puts the hash value of the supplied buffer
+ * into outbuf which must have a size of 20 bytes.
+ */
+void
+_gcry_rmd160_hash_buffer (void *outbuf, const void *buffer, size_t length )
+{
+ RMD160_CONTEXT hd;
+
+ _gcry_rmd160_init ( &hd );
+ rmd160_write ( &hd, buffer, length );
+ rmd160_final ( &hd );
+ memcpy ( outbuf, hd.buf, 20 );
+}
+
+static byte asn[15] = /* Object ID is 1.3.36.3.2.1 */
+ { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x24, 0x03,
+ 0x02, 0x01, 0x05, 0x00, 0x04, 0x14 };
+
+static gcry_md_oid_spec_t oid_spec_rmd160[] =
+ {
+ /* rsaSignatureWithripemd160 */
+ { "1.3.36.3.3.1.2" },
+ /* TeleTrust hash algorithm. */
+ { "1.3.36.3.2.1" },
+ { NULL }
+ };
+
+gcry_md_spec_t _gcry_digest_spec_rmd160 =
+ {
+ "RIPEMD160", asn, DIM (asn), oid_spec_rmd160, 20,
+ _gcry_rmd160_init, rmd160_write, rmd160_final, rmd160_read,
+ sizeof (RMD160_CONTEXT)
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/rsa.c b/grub-core/lib/libgcrypt/cipher/rsa.c
new file mode 100644
index 0000000..ccc9f96
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/rsa.c
@@ -0,0 +1,1390 @@
+/* rsa.c - RSA implementation
+ * Copyright (C) 1997, 1998, 1999 by Werner Koch (dd9jn)
+ * Copyright (C) 2000, 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This code uses an algorithm protected by U.S. Patent #4,405,829
+ which expired on September 20, 2000. The patent holder placed that
+ patent into the public domain on Sep 6th, 2000.
+*/
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "g10lib.h"
+#include "mpi.h"
+#include "cipher.h"
+
+
+typedef struct
+{
+ gcry_mpi_t n; /* modulus */
+ gcry_mpi_t e; /* exponent */
+} RSA_public_key;
+
+
+typedef struct
+{
+ gcry_mpi_t n; /* public modulus */
+ gcry_mpi_t e; /* public exponent */
+ gcry_mpi_t d; /* exponent */
+ gcry_mpi_t p; /* prime p. */
+ gcry_mpi_t q; /* prime q. */
+ gcry_mpi_t u; /* inverse of p mod q. */
+} RSA_secret_key;
+
+
+/* A sample 1024 bit RSA key used for the selftests. */
+static const char sample_secret_key[] =
+"(private-key"
+" (rsa"
+" (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa"
+" 2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291"
+" ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7"
+" 891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)"
+" (e #010001#)"
+" (d #046129f2489d71579be0a75fe029bd6cdb574ebf57ea8a5b0fda942cab943b11"
+" 7d7bb95e5d28875e0f9fc5fcc06a72f6d502464dabded78ef6b716177b83d5bd"
+" c543dc5d3fed932e59f5897e92e6f58a0f33424106a3b6fa2cbf877510e4ac21"
+" c3ee47851e97d12996222ac3566d4ccb0b83d164074abf7de655fc2446da1781#)"
+" (p #00e861b700e17e8afe6837e7512e35b6ca11d0ae47d8b85161c67baf64377213"
+" fe52d772f2035b3ca830af41d8a4120e1c1c70d12cc22f00d28d31dd48a8d424f1#)"
+" (q #00f7a7ca5367c661f8e62df34f0d05c10c88e5492348dd7bddc942c9a8f369f9"
+" 35a07785d2db805215ed786e4285df1658eed3ce84f469b81b50d358407b4ad361#)"
+" (u #304559a9ead56d2309d203811a641bb1a09626bc8eb36fffa23c968ec5bd891e"
+" ebbafc73ae666e01ba7c8990bae06cc2bbe10b75e69fcacb353a6473079d8e9b#)))";
+/* A sample 1024 bit RSA key used for the selftests (public only). */
+static const char sample_public_key[] =
+"(public-key"
+" (rsa"
+" (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa"
+" 2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291"
+" ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7"
+" 891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)"
+" (e #010001#)))";
+
+
+
+
+static int test_keys (RSA_secret_key *sk, unsigned nbits);
+static int check_secret_key (RSA_secret_key *sk);
+static void public (gcry_mpi_t output, gcry_mpi_t input, RSA_public_key *skey);
+static void secret (gcry_mpi_t output, gcry_mpi_t input, RSA_secret_key *skey);
+
+
+/* Check that a freshly generated key actually works. Returns 0 on success. */
+static int
+test_keys (RSA_secret_key *sk, unsigned int nbits)
+{
+ int result = -1; /* Default to failure. */
+ RSA_public_key pk;
+ gcry_mpi_t plaintext = gcry_mpi_new (nbits);
+ gcry_mpi_t ciphertext = gcry_mpi_new (nbits);
+ gcry_mpi_t decr_plaintext = gcry_mpi_new (nbits);
+ gcry_mpi_t signature = gcry_mpi_new (nbits);
+
+ /* Put the relevant parameters into a public key structure. */
+ pk.n = sk->n;
+ pk.e = sk->e;
+
+ /* Create a random plaintext. */
+ gcry_mpi_randomize (plaintext, nbits, GCRY_WEAK_RANDOM);
+
+ /* Encrypt using the public key. */
+ public (ciphertext, plaintext, &pk);
+
+ /* Check that the cipher text does not match the plaintext. */
+ if (!gcry_mpi_cmp (ciphertext, plaintext))
+ goto leave; /* Ciphertext is identical to the plaintext. */
+
+ /* Decrypt using the secret key. */
+ secret (decr_plaintext, ciphertext, sk);
+
+ /* Check that the decrypted plaintext matches the original plaintext. */
+ if (gcry_mpi_cmp (decr_plaintext, plaintext))
+ goto leave; /* Plaintext does not match. */
+
+ /* Create another random plaintext as data for signature checking. */
+ gcry_mpi_randomize (plaintext, nbits, GCRY_WEAK_RANDOM);
+
+ /* Use the RSA secret function to create a signature of the plaintext. */
+ secret (signature, plaintext, sk);
+
+ /* Use the RSA public function to verify this signature. */
+ public (decr_plaintext, signature, &pk);
+ if (gcry_mpi_cmp (decr_plaintext, plaintext))
+ goto leave; /* Signature does not match. */
+
+ /* Modify the signature and check that the signing fails. */
+ gcry_mpi_add_ui (signature, signature, 1);
+ public (decr_plaintext, signature, &pk);
+ if (!gcry_mpi_cmp (decr_plaintext, plaintext))
+ goto leave; /* Signature matches but should not. */
+
+ result = 0; /* All tests succeeded. */
+
+ leave:
+ gcry_mpi_release (signature);
+ gcry_mpi_release (decr_plaintext);
+ gcry_mpi_release (ciphertext);
+ gcry_mpi_release (plaintext);
+ return result;
+}
+
+
+/* Callback used by the prime generation to test whether the exponent
+ is suitable. Returns 0 if the test has been passed. */
+static int
+check_exponent (void *arg, gcry_mpi_t a)
+{
+ gcry_mpi_t e = arg;
+ gcry_mpi_t tmp;
+ int result;
+
+ mpi_sub_ui (a, a, 1);
+ tmp = _gcry_mpi_alloc_like (a);
+ result = !gcry_mpi_gcd(tmp, e, a); /* GCD is not 1. */
+ gcry_mpi_release (tmp);
+ mpi_add_ui (a, a, 1);
+ return result;
+}
+
+/****************
+ * Generate a key pair with a key of size NBITS.
+ * USE_E = 0 let Libcgrypt decide what exponent to use.
+ * = 1 request the use of a "secure" exponent; this is required by some
+ * specification to be 65537.
+ * > 2 Use this public exponent. If the given exponent
+ * is not odd one is internally added to it.
+ * TRANSIENT_KEY: If true, generate the primes using the standard RNG.
+ * Returns: 2 structures filled with all needed values
+ */
+static gpg_err_code_t
+generate_std (RSA_secret_key *sk, unsigned int nbits, unsigned long use_e,
+ int transient_key)
+{
+ gcry_mpi_t p, q; /* the two primes */
+ gcry_mpi_t d; /* the private key */
+ gcry_mpi_t u;
+ gcry_mpi_t t1, t2;
+ gcry_mpi_t n; /* the public key */
+ gcry_mpi_t e; /* the exponent */
+ gcry_mpi_t phi; /* helper: (p-1)(q-1) */
+ gcry_mpi_t g;
+ gcry_mpi_t f;
+ gcry_random_level_t random_level;
+
+ if (fips_mode ())
+ {
+ if (nbits < 1024)
+ return GPG_ERR_INV_VALUE;
+ if (transient_key)
+ return GPG_ERR_INV_VALUE;
+ }
+
+ /* The random quality depends on the transient_key flag. */
+ random_level = transient_key ? GCRY_STRONG_RANDOM : GCRY_VERY_STRONG_RANDOM;
+
+ /* Make sure that nbits is even so that we generate p, q of equal size. */
+ if ( (nbits&1) )
+ nbits++;
+
+ if (use_e == 1) /* Alias for a secure value */
+ use_e = 65537; /* as demanded by Sphinx. */
+
+ /* Public exponent:
+ In general we use 41 as this is quite fast and more secure than the
+ commonly used 17. Benchmarking the RSA verify function
+ with a 1024 bit key yields (2001-11-08):
+ e=17 0.54 ms
+ e=41 0.75 ms
+ e=257 0.95 ms
+ e=65537 1.80 ms
+ */
+ e = mpi_alloc( (32+BITS_PER_MPI_LIMB-1)/BITS_PER_MPI_LIMB );
+ if (!use_e)
+ mpi_set_ui (e, 41); /* This is a reasonable secure and fast value */
+ else
+ {
+ use_e |= 1; /* make sure this is odd */
+ mpi_set_ui (e, use_e);
+ }
+
+ n = gcry_mpi_new (nbits);
+
+ p = q = NULL;
+ do
+ {
+ /* select two (very secret) primes */
+ if (p)
+ gcry_mpi_release (p);
+ if (q)
+ gcry_mpi_release (q);
+ if (use_e)
+ { /* Do an extra test to ensure that the given exponent is
+ suitable. */
+ p = _gcry_generate_secret_prime (nbits/2, random_level,
+ check_exponent, e);
+ q = _gcry_generate_secret_prime (nbits/2, random_level,
+ check_exponent, e);
+ }
+ else
+ { /* We check the exponent later. */
+ p = _gcry_generate_secret_prime (nbits/2, random_level, NULL, NULL);
+ q = _gcry_generate_secret_prime (nbits/2, random_level, NULL, NULL);
+ }
+ if (mpi_cmp (p, q) > 0 ) /* p shall be smaller than q (for calc of u)*/
+ mpi_swap(p,q);
+ /* calculate the modulus */
+ mpi_mul( n, p, q );
+ }
+ while ( mpi_get_nbits(n) != nbits );
+
+ /* calculate Euler totient: phi = (p-1)(q-1) */
+ t1 = mpi_alloc_secure( mpi_get_nlimbs(p) );
+ t2 = mpi_alloc_secure( mpi_get_nlimbs(p) );
+ phi = gcry_mpi_snew ( nbits );
+ g = gcry_mpi_snew ( nbits );
+ f = gcry_mpi_snew ( nbits );
+ mpi_sub_ui( t1, p, 1 );
+ mpi_sub_ui( t2, q, 1 );
+ mpi_mul( phi, t1, t2 );
+ gcry_mpi_gcd(g, t1, t2);
+ mpi_fdiv_q(f, phi, g);
+
+ while (!gcry_mpi_gcd(t1, e, phi)) /* (while gcd is not 1) */
+ {
+ if (use_e)
+ BUG (); /* The prime generator already made sure that we
+ never can get to here. */
+ mpi_add_ui (e, e, 2);
+ }
+
+ /* calculate the secret key d = e^1 mod phi */
+ d = gcry_mpi_snew ( nbits );
+ mpi_invm(d, e, f );
+ /* calculate the inverse of p and q (used for chinese remainder theorem)*/
+ u = gcry_mpi_snew ( nbits );
+ mpi_invm(u, p, q );
+
+ if( DBG_CIPHER )
+ {
+ log_mpidump(" p= ", p );
+ log_mpidump(" q= ", q );
+ log_mpidump("phi= ", phi );
+ log_mpidump(" g= ", g );
+ log_mpidump(" f= ", f );
+ log_mpidump(" n= ", n );
+ log_mpidump(" e= ", e );
+ log_mpidump(" d= ", d );
+ log_mpidump(" u= ", u );
+ }
+
+ gcry_mpi_release (t1);
+ gcry_mpi_release (t2);
+ gcry_mpi_release (phi);
+ gcry_mpi_release (f);
+ gcry_mpi_release (g);
+
+ sk->n = n;
+ sk->e = e;
+ sk->p = p;
+ sk->q = q;
+ sk->d = d;
+ sk->u = u;
+
+ /* Now we can test our keys. */
+ if (test_keys (sk, nbits - 64))
+ {
+ gcry_mpi_release (sk->n); sk->n = NULL;
+ gcry_mpi_release (sk->e); sk->e = NULL;
+ gcry_mpi_release (sk->p); sk->p = NULL;
+ gcry_mpi_release (sk->q); sk->q = NULL;
+ gcry_mpi_release (sk->d); sk->d = NULL;
+ gcry_mpi_release (sk->u); sk->u = NULL;
+ fips_signal_error ("self-test after key generation failed");
+ return GPG_ERR_SELFTEST_FAILED;
+ }
+
+ return 0;
+}
+
+
+/* Helper for generate_x931. */
+static gcry_mpi_t
+gen_x931_parm_xp (unsigned int nbits)
+{
+ gcry_mpi_t xp;
+
+ xp = gcry_mpi_snew (nbits);
+ gcry_mpi_randomize (xp, nbits, GCRY_VERY_STRONG_RANDOM);
+
+ /* The requirement for Xp is:
+
+ sqrt{2}*2^{nbits-1} <= xp <= 2^{nbits} - 1
+
+ We set the two high order bits to 1 to satisfy the lower bound.
+ By using mpi_set_highbit we make sure that the upper bound is
+ satisfied as well. */
+ mpi_set_highbit (xp, nbits-1);
+ mpi_set_bit (xp, nbits-2);
+ gcry_assert ( mpi_get_nbits (xp) == nbits );
+
+ return xp;
+}
+
+
+/* Helper for generate_x931. */
+static gcry_mpi_t
+gen_x931_parm_xi (void)
+{
+ gcry_mpi_t xi;
+
+ xi = gcry_mpi_snew (101);
+ gcry_mpi_randomize (xi, 101, GCRY_VERY_STRONG_RANDOM);
+ mpi_set_highbit (xi, 100);
+ gcry_assert ( mpi_get_nbits (xi) == 101 );
+
+ return xi;
+}
+
+
+
+/* Variant of the standard key generation code using the algorithm
+ from X9.31. Using this algorithm has the advantage that the
+ generation can be made deterministic which is required for CAVS
+ testing. */
+static gpg_err_code_t
+generate_x931 (RSA_secret_key *sk, unsigned int nbits, unsigned long e_value,
+ gcry_sexp_t deriveparms, int *swapped)
+{
+ gcry_mpi_t p, q; /* The two primes. */
+ gcry_mpi_t e; /* The public exponent. */
+ gcry_mpi_t n; /* The public key. */
+ gcry_mpi_t d; /* The private key */
+ gcry_mpi_t u; /* The inverse of p and q. */
+ gcry_mpi_t pm1; /* p - 1 */
+ gcry_mpi_t qm1; /* q - 1 */
+ gcry_mpi_t phi; /* Euler totient. */
+ gcry_mpi_t f, g; /* Helper. */
+
+ *swapped = 0;
+
+ if (e_value == 1) /* Alias for a secure value. */
+ e_value = 65537;
+
+ /* Point 1 of section 4.1: k = 1024 + 256s with S >= 0 */
+ if (nbits < 1024 || (nbits % 256))
+ return GPG_ERR_INV_VALUE;
+
+ /* Point 2: 2 <= bitlength(e) < 2^{k-2}
+ Note that we do not need to check the upper bound because we use
+ an unsigned long for E and thus there is no way for E to reach
+ that limit. */
+ if (e_value < 3)
+ return GPG_ERR_INV_VALUE;
+
+ /* Our implementaion requires E to be odd. */
+ if (!(e_value & 1))
+ return GPG_ERR_INV_VALUE;
+
+ /* Point 3: e > 0 or e 0 if it is to be randomly generated.
+ We support only a fixed E and thus there is no need for an extra test. */
+
+
+ /* Compute or extract the derive parameters. */
+ {
+ gcry_mpi_t xp1 = NULL;
+ gcry_mpi_t xp2 = NULL;
+ gcry_mpi_t xp = NULL;
+ gcry_mpi_t xq1 = NULL;
+ gcry_mpi_t xq2 = NULL;
+ gcry_mpi_t xq = NULL;
+ gcry_mpi_t tmpval;
+
+ if (!deriveparms)
+ {
+ /* Not given: Generate them. */
+ xp = gen_x931_parm_xp (nbits/2);
+ /* Make sure that |xp - xq| > 2^{nbits - 100} holds. */
+ tmpval = gcry_mpi_snew (nbits/2);
+ do
+ {
+ gcry_mpi_release (xq);
+ xq = gen_x931_parm_xp (nbits/2);
+ mpi_sub (tmpval, xp, xq);
+ }
+ while (mpi_get_nbits (tmpval) <= (nbits/2 - 100));
+ gcry_mpi_release (tmpval);
+
+ xp1 = gen_x931_parm_xi ();
+ xp2 = gen_x931_parm_xi ();
+ xq1 = gen_x931_parm_xi ();
+ xq2 = gen_x931_parm_xi ();
+
+ }
+ else
+ {
+ /* Parameters to derive the key are given. */
+ /* Note that we explicitly need to setup the values of tbl
+ because some compilers (e.g. OpenWatcom, IRIX) don't allow
+ to initialize a structure with automatic variables. */
+ struct { const char *name; gcry_mpi_t *value; } tbl[] = {
+ { "Xp1" },
+ { "Xp2" },
+ { "Xp" },
+ { "Xq1" },
+ { "Xq2" },
+ { "Xq" },
+ { NULL }
+ };
+ int idx;
+ gcry_sexp_t oneparm;
+
+ tbl[0].value = &xp1;
+ tbl[1].value = &xp2;
+ tbl[2].value = &xp;
+ tbl[3].value = &xq1;
+ tbl[4].value = &xq2;
+ tbl[5].value = &xq;
+
+ for (idx=0; tbl[idx].name; idx++)
+ {
+ oneparm = gcry_sexp_find_token (deriveparms, tbl[idx].name, 0);
+ if (oneparm)
+ {
+ *tbl[idx].value = gcry_sexp_nth_mpi (oneparm, 1,
+ GCRYMPI_FMT_USG);
+ gcry_sexp_release (oneparm);
+ }
+ }
+ for (idx=0; tbl[idx].name; idx++)
+ if (!*tbl[idx].value)
+ break;
+ if (tbl[idx].name)
+ {
+ /* At least one parameter is missing. */
+ for (idx=0; tbl[idx].name; idx++)
+ gcry_mpi_release (*tbl[idx].value);
+ return GPG_ERR_MISSING_VALUE;
+ }
+ }
+
+ e = mpi_alloc_set_ui (e_value);
+
+ /* Find two prime numbers. */
+ p = _gcry_derive_x931_prime (xp, xp1, xp2, e, NULL, NULL);
+ q = _gcry_derive_x931_prime (xq, xq1, xq2, e, NULL, NULL);
+ gcry_mpi_release (xp); xp = NULL;
+ gcry_mpi_release (xp1); xp1 = NULL;
+ gcry_mpi_release (xp2); xp2 = NULL;
+ gcry_mpi_release (xq); xq = NULL;
+ gcry_mpi_release (xq1); xq1 = NULL;
+ gcry_mpi_release (xq2); xq2 = NULL;
+ if (!p || !q)
+ {
+ gcry_mpi_release (p);
+ gcry_mpi_release (q);
+ gcry_mpi_release (e);
+ return GPG_ERR_NO_PRIME;
+ }
+ }
+
+
+ /* Compute the public modulus. We make sure that p is smaller than
+ q to allow the use of the CRT. */
+ if (mpi_cmp (p, q) > 0 )
+ {
+ mpi_swap (p, q);
+ *swapped = 1;
+ }
+ n = gcry_mpi_new (nbits);
+ mpi_mul (n, p, q);
+
+ /* Compute the Euler totient: phi = (p-1)(q-1) */
+ pm1 = gcry_mpi_snew (nbits/2);
+ qm1 = gcry_mpi_snew (nbits/2);
+ phi = gcry_mpi_snew (nbits);
+ mpi_sub_ui (pm1, p, 1);
+ mpi_sub_ui (qm1, q, 1);
+ mpi_mul (phi, pm1, qm1);
+
+ g = gcry_mpi_snew (nbits);
+ gcry_assert (gcry_mpi_gcd (g, e, phi));
+
+ /* Compute: f = lcm(p-1,q-1) = phi / gcd(p-1,q-1) */
+ gcry_mpi_gcd (g, pm1, qm1);
+ f = pm1; pm1 = NULL;
+ gcry_mpi_release (qm1); qm1 = NULL;
+ mpi_fdiv_q (f, phi, g);
+ gcry_mpi_release (phi); phi = NULL;
+ d = g; g = NULL;
+ /* Compute the secret key: d = e^{-1} mod lcm(p-1,q-1) */
+ mpi_invm (d, e, f);
+
+ /* Compute the inverse of p and q. */
+ u = f; f = NULL;
+ mpi_invm (u, p, q );
+
+ if( DBG_CIPHER )
+ {
+ if (*swapped)
+ log_debug ("p and q are swapped\n");
+ log_mpidump(" p", p );
+ log_mpidump(" q", q );
+ log_mpidump(" n", n );
+ log_mpidump(" e", e );
+ log_mpidump(" d", d );
+ log_mpidump(" u", u );
+ }
+
+
+ sk->n = n;
+ sk->e = e;
+ sk->p = p;
+ sk->q = q;
+ sk->d = d;
+ sk->u = u;
+
+ /* Now we can test our keys. */
+ if (test_keys (sk, nbits - 64))
+ {
+ gcry_mpi_release (sk->n); sk->n = NULL;
+ gcry_mpi_release (sk->e); sk->e = NULL;
+ gcry_mpi_release (sk->p); sk->p = NULL;
+ gcry_mpi_release (sk->q); sk->q = NULL;
+ gcry_mpi_release (sk->d); sk->d = NULL;
+ gcry_mpi_release (sk->u); sk->u = NULL;
+ fips_signal_error ("self-test after key generation failed");
+ return GPG_ERR_SELFTEST_FAILED;
+ }
+
+ return 0;
+}
+
+
+/****************
+ * Test whether the secret key is valid.
+ * Returns: true if this is a valid key.
+ */
+static int
+check_secret_key( RSA_secret_key *sk )
+{
+ int rc;
+ gcry_mpi_t temp = mpi_alloc( mpi_get_nlimbs(sk->p)*2 );
+
+ mpi_mul(temp, sk->p, sk->q );
+ rc = mpi_cmp( temp, sk->n );
+ mpi_free(temp);
+ return !rc;
+}
+
+
+
+/****************
+ * Public key operation. Encrypt INPUT with PKEY and put result into OUTPUT.
+ *
+ * c = m^e mod n
+ *
+ * Where c is OUTPUT, m is INPUT and e,n are elements of PKEY.
+ */
+static void
+public(gcry_mpi_t output, gcry_mpi_t input, RSA_public_key *pkey )
+{
+ if( output == input ) /* powm doesn't like output and input the same */
+ {
+ gcry_mpi_t x = mpi_alloc( mpi_get_nlimbs(input)*2 );
+ mpi_powm( x, input, pkey->e, pkey->n );
+ mpi_set(output, x);
+ mpi_free(x);
+ }
+ else
+ mpi_powm( output, input, pkey->e, pkey->n );
+}
+
+#if 0
+static void
+stronger_key_check ( RSA_secret_key *skey )
+{
+ gcry_mpi_t t = mpi_alloc_secure ( 0 );
+ gcry_mpi_t t1 = mpi_alloc_secure ( 0 );
+ gcry_mpi_t t2 = mpi_alloc_secure ( 0 );
+ gcry_mpi_t phi = mpi_alloc_secure ( 0 );
+
+ /* check that n == p * q */
+ mpi_mul( t, skey->p, skey->q);
+ if (mpi_cmp( t, skey->n) )
+ log_info ( "RSA Oops: n != p * q\n" );
+
+ /* check that p is less than q */
+ if( mpi_cmp( skey->p, skey->q ) > 0 )
+ {
+ log_info ("RSA Oops: p >= q - fixed\n");
+ _gcry_mpi_swap ( skey->p, skey->q);
+ }
+
+ /* check that e divides neither p-1 nor q-1 */
+ mpi_sub_ui(t, skey->p, 1 );
+ mpi_fdiv_r(t, t, skey->e );
+ if ( !mpi_cmp_ui( t, 0) )
+ log_info ( "RSA Oops: e divides p-1\n" );
+ mpi_sub_ui(t, skey->q, 1 );
+ mpi_fdiv_r(t, t, skey->e );
+ if ( !mpi_cmp_ui( t, 0) )
+ log_info ( "RSA Oops: e divides q-1\n" );
+
+ /* check that d is correct */
+ mpi_sub_ui( t1, skey->p, 1 );
+ mpi_sub_ui( t2, skey->q, 1 );
+ mpi_mul( phi, t1, t2 );
+ gcry_mpi_gcd(t, t1, t2);
+ mpi_fdiv_q(t, phi, t);
+ mpi_invm(t, skey->e, t );
+ if ( mpi_cmp(t, skey->d ) )
+ {
+ log_info ( "RSA Oops: d is wrong - fixed\n");
+ mpi_set (skey->d, t);
+ _gcry_log_mpidump (" fixed d", skey->d);
+ }
+
+ /* check for correctness of u */
+ mpi_invm(t, skey->p, skey->q );
+ if ( mpi_cmp(t, skey->u ) )
+ {
+ log_info ( "RSA Oops: u is wrong - fixed\n");
+ mpi_set (skey->u, t);
+ _gcry_log_mpidump (" fixed u", skey->u);
+ }
+
+ log_info ( "RSA secret key check finished\n");
+
+ mpi_free (t);
+ mpi_free (t1);
+ mpi_free (t2);
+ mpi_free (phi);
+}
+#endif
+
+
+
+/****************
+ * Secret key operation. Encrypt INPUT with SKEY and put result into OUTPUT.
+ *
+ * m = c^d mod n
+ *
+ * Or faster:
+ *
+ * m1 = c ^ (d mod (p-1)) mod p
+ * m2 = c ^ (d mod (q-1)) mod q
+ * h = u * (m2 - m1) mod q
+ * m = m1 + h * p
+ *
+ * Where m is OUTPUT, c is INPUT and d,n,p,q,u are elements of SKEY.
+ */
+static void
+secret(gcry_mpi_t output, gcry_mpi_t input, RSA_secret_key *skey )
+{
+ if (!skey->p || !skey->q || !skey->u)
+ {
+ mpi_powm (output, input, skey->d, skey->n);
+ }
+ else
+ {
+ gcry_mpi_t m1 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );
+ gcry_mpi_t m2 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );
+ gcry_mpi_t h = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );
+
+ /* m1 = c ^ (d mod (p-1)) mod p */
+ mpi_sub_ui( h, skey->p, 1 );
+ mpi_fdiv_r( h, skey->d, h );
+ mpi_powm( m1, input, h, skey->p );
+ /* m2 = c ^ (d mod (q-1)) mod q */
+ mpi_sub_ui( h, skey->q, 1 );
+ mpi_fdiv_r( h, skey->d, h );
+ mpi_powm( m2, input, h, skey->q );
+ /* h = u * ( m2 - m1 ) mod q */
+ mpi_sub( h, m2, m1 );
+ if ( mpi_is_neg( h ) )
+ mpi_add ( h, h, skey->q );
+ mpi_mulm( h, skey->u, h, skey->q );
+ /* m = m2 + h * p */
+ mpi_mul ( h, h, skey->p );
+ mpi_add ( output, m1, h );
+
+ mpi_free ( h );
+ mpi_free ( m1 );
+ mpi_free ( m2 );
+ }
+}
+
+
+
+/* Perform RSA blinding. */
+static gcry_mpi_t
+rsa_blind (gcry_mpi_t x, gcry_mpi_t r, gcry_mpi_t e, gcry_mpi_t n)
+{
+ /* A helper. */
+ gcry_mpi_t a;
+
+ /* Result. */
+ gcry_mpi_t y;
+
+ a = gcry_mpi_snew (gcry_mpi_get_nbits (n));
+ y = gcry_mpi_snew (gcry_mpi_get_nbits (n));
+
+ /* Now we calculate: y = (x * r^e) mod n, where r is the random
+ number, e is the public exponent, x is the non-blinded data and n
+ is the RSA modulus. */
+ gcry_mpi_powm (a, r, e, n);
+ gcry_mpi_mulm (y, a, x, n);
+
+ gcry_mpi_release (a);
+
+ return y;
+}
+
+/* Undo RSA blinding. */
+static gcry_mpi_t
+rsa_unblind (gcry_mpi_t x, gcry_mpi_t ri, gcry_mpi_t n)
+{
+ gcry_mpi_t y;
+
+ y = gcry_mpi_snew (gcry_mpi_get_nbits (n));
+
+ /* Here we calculate: y = (x * r^-1) mod n, where x is the blinded
+ decrypted data, ri is the modular multiplicative inverse of r and
+ n is the RSA modulus. */
+
+ gcry_mpi_mulm (y, ri, x, n);
+
+ return y;
+}
+
+/*********************************************
+ ************** interface ******************
+ *********************************************/
+
+static gcry_err_code_t
+rsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue,
+ const gcry_sexp_t genparms,
+ gcry_mpi_t *skey, gcry_mpi_t **retfactors,
+ gcry_sexp_t *r_extrainfo)
+{
+ RSA_secret_key sk;
+ gpg_err_code_t ec;
+ gcry_sexp_t deriveparms;
+ int transient_key = 0;
+ int use_x931 = 0;
+ gcry_sexp_t l1;
+
+ (void)algo;
+
+ *retfactors = NULL; /* We don't return them. */
+
+ deriveparms = (genparms?
+ gcry_sexp_find_token (genparms, "derive-parms", 0) : NULL);
+ if (!deriveparms)
+ {
+ /* Parse the optional "use-x931" flag. */
+ l1 = gcry_sexp_find_token (genparms, "use-x931", 0);
+ if (l1)
+ {
+ use_x931 = 1;
+ gcry_sexp_release (l1);
+ }
+ }
+
+ if (deriveparms || use_x931 || fips_mode ())
+ {
+ int swapped;
+ ec = generate_x931 (&sk, nbits, evalue, deriveparms, &swapped);
+ gcry_sexp_release (deriveparms);
+ if (!ec && r_extrainfo && swapped)
+ {
+ ec = gcry_sexp_new (r_extrainfo,
+ "(misc-key-info(p-q-swapped))", 0, 1);
+ if (ec)
+ {
+ gcry_mpi_release (sk.n); sk.n = NULL;
+ gcry_mpi_release (sk.e); sk.e = NULL;
+ gcry_mpi_release (sk.p); sk.p = NULL;
+ gcry_mpi_release (sk.q); sk.q = NULL;
+ gcry_mpi_release (sk.d); sk.d = NULL;
+ gcry_mpi_release (sk.u); sk.u = NULL;
+ }
+ }
+ }
+ else
+ {
+ /* Parse the optional "transient-key" flag. */
+ l1 = gcry_sexp_find_token (genparms, "transient-key", 0);
+ if (l1)
+ {
+ transient_key = 1;
+ gcry_sexp_release (l1);
+ }
+ /* Generate. */
+ ec = generate_std (&sk, nbits, evalue, transient_key);
+ }
+
+ if (!ec)
+ {
+ skey[0] = sk.n;
+ skey[1] = sk.e;
+ skey[2] = sk.d;
+ skey[3] = sk.p;
+ skey[4] = sk.q;
+ skey[5] = sk.u;
+ }
+
+ return ec;
+}
+
+
+static gcry_err_code_t
+rsa_generate (int algo, unsigned int nbits, unsigned long evalue,
+ gcry_mpi_t *skey, gcry_mpi_t **retfactors)
+{
+ return rsa_generate_ext (algo, nbits, evalue, NULL, skey, retfactors, NULL);
+}
+
+
+static gcry_err_code_t
+rsa_check_secret_key (int algo, gcry_mpi_t *skey)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ RSA_secret_key sk;
+
+ (void)algo;
+
+ sk.n = skey[0];
+ sk.e = skey[1];
+ sk.d = skey[2];
+ sk.p = skey[3];
+ sk.q = skey[4];
+ sk.u = skey[5];
+
+ if (!sk.p || !sk.q || !sk.u)
+ err = GPG_ERR_NO_OBJ; /* To check the key we need the optional
+ parameters. */
+ else if (!check_secret_key (&sk))
+ err = GPG_ERR_BAD_SECKEY;
+
+ return err;
+}
+
+
+static gcry_err_code_t
+rsa_encrypt (int algo, gcry_mpi_t *resarr, gcry_mpi_t data,
+ gcry_mpi_t *pkey, int flags)
+{
+ RSA_public_key pk;
+
+ (void)algo;
+ (void)flags;
+
+ pk.n = pkey[0];
+ pk.e = pkey[1];
+ resarr[0] = mpi_alloc (mpi_get_nlimbs (pk.n));
+ public (resarr[0], data, &pk);
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+static gcry_err_code_t
+rsa_decrypt (int algo, gcry_mpi_t *result, gcry_mpi_t *data,
+ gcry_mpi_t *skey, int flags)
+{
+ RSA_secret_key sk;
+ gcry_mpi_t r = MPI_NULL; /* Random number needed for blinding. */
+ gcry_mpi_t ri = MPI_NULL; /* Modular multiplicative inverse of
+ r. */
+ gcry_mpi_t x = MPI_NULL; /* Data to decrypt. */
+ gcry_mpi_t y; /* Result. */
+
+ (void)algo;
+
+ /* Extract private key. */
+ sk.n = skey[0];
+ sk.e = skey[1];
+ sk.d = skey[2];
+ sk.p = skey[3]; /* Optional. */
+ sk.q = skey[4]; /* Optional. */
+ sk.u = skey[5]; /* Optional. */
+
+ y = gcry_mpi_snew (gcry_mpi_get_nbits (sk.n));
+
+ /* We use blinding by default to mitigate timing attacks which can
+ be practically mounted over the network as shown by Brumley and
+ Boney in 2003. */
+ if (! (flags & PUBKEY_FLAG_NO_BLINDING))
+ {
+ /* Initialize blinding. */
+
+ /* First, we need a random number r between 0 and n - 1, which
+ is relatively prime to n (i.e. it is neither p nor q). The
+ random number needs to be only unpredictable, thus we employ
+ the gcry_create_nonce function by using GCRY_WEAK_RANDOM with
+ gcry_mpi_randomize. */
+ r = gcry_mpi_snew (gcry_mpi_get_nbits (sk.n));
+ ri = gcry_mpi_snew (gcry_mpi_get_nbits (sk.n));
+
+ gcry_mpi_randomize (r, gcry_mpi_get_nbits (sk.n), GCRY_WEAK_RANDOM);
+ gcry_mpi_mod (r, r, sk.n);
+
+ /* Calculate inverse of r. It practically impossible that the
+ following test fails, thus we do not add code to release
+ allocated resources. */
+ if (!gcry_mpi_invm (ri, r, sk.n))
+ return GPG_ERR_INTERNAL;
+ }
+
+ if (! (flags & PUBKEY_FLAG_NO_BLINDING))
+ x = rsa_blind (data[0], r, sk.e, sk.n);
+ else
+ x = data[0];
+
+ /* Do the encryption. */
+ secret (y, x, &sk);
+
+ if (! (flags & PUBKEY_FLAG_NO_BLINDING))
+ {
+ /* Undo blinding. */
+ gcry_mpi_t a = gcry_mpi_copy (y);
+
+ gcry_mpi_release (y);
+ y = rsa_unblind (a, ri, sk.n);
+
+ gcry_mpi_release (a);
+ }
+
+ if (! (flags & PUBKEY_FLAG_NO_BLINDING))
+ {
+ /* Deallocate resources needed for blinding. */
+ gcry_mpi_release (x);
+ gcry_mpi_release (r);
+ gcry_mpi_release (ri);
+ }
+
+ /* Copy out result. */
+ *result = y;
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+static gcry_err_code_t
+rsa_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey)
+{
+ RSA_secret_key sk;
+
+ (void)algo;
+
+ sk.n = skey[0];
+ sk.e = skey[1];
+ sk.d = skey[2];
+ sk.p = skey[3];
+ sk.q = skey[4];
+ sk.u = skey[5];
+ resarr[0] = mpi_alloc( mpi_get_nlimbs (sk.n));
+ secret (resarr[0], data, &sk);
+
+ return GPG_ERR_NO_ERROR;
+}
+
+
+static gcry_err_code_t
+rsa_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey,
+ int (*cmp) (void *opaque, gcry_mpi_t tmp),
+ void *opaquev)
+{
+ RSA_public_key pk;
+ gcry_mpi_t result;
+ gcry_err_code_t rc;
+
+ (void)algo;
+ (void)cmp;
+ (void)opaquev;
+
+ pk.n = pkey[0];
+ pk.e = pkey[1];
+ result = gcry_mpi_new ( 160 );
+ public( result, data[0], &pk );
+#ifdef IS_DEVELOPMENT_VERSION
+ if (DBG_CIPHER)
+ {
+ log_mpidump ("rsa verify result:", result );
+ log_mpidump (" hash:", hash );
+ }
+#endif /*IS_DEVELOPMENT_VERSION*/
+ if (cmp)
+ rc = (*cmp) (opaquev, result);
+ else
+ rc = mpi_cmp (result, hash) ? GPG_ERR_BAD_SIGNATURE : GPG_ERR_NO_ERROR;
+ gcry_mpi_release (result);
+
+ return rc;
+}
+
+
+static unsigned int
+rsa_get_nbits (int algo, gcry_mpi_t *pkey)
+{
+ (void)algo;
+
+ return mpi_get_nbits (pkey[0]);
+}
+
+
+/* Compute a keygrip. MD is the hash context which we are going to
+ update. KEYPARAM is an S-expression with the key parameters, this
+ is usually a public key but may also be a secret key. An example
+ of such an S-expression is:
+
+ (rsa
+ (n #00B...#)
+ (e #010001#))
+
+ PKCS-15 says that for RSA only the modulus should be hashed -
+ however, it is not clear whether this is meant to use the raw bytes
+ (assuming this is an unsigned integer) or whether the DER required
+ 0 should be prefixed. We hash the raw bytes. */
+static gpg_err_code_t
+compute_keygrip (gcry_md_hd_t md, gcry_sexp_t keyparam)
+{
+ gcry_sexp_t l1;
+ const char *data;
+ size_t datalen;
+
+ l1 = gcry_sexp_find_token (keyparam, "n", 1);
+ if (!l1)
+ return GPG_ERR_NO_OBJ;
+
+ data = gcry_sexp_nth_data (l1, 1, &datalen);
+ if (!data)
+ {
+ gcry_sexp_release (l1);
+ return GPG_ERR_NO_OBJ;
+ }
+
+ gcry_md_write (md, data, datalen);
+ gcry_sexp_release (l1);
+
+ return 0;
+}
+
+
+
+
+/*
+ Self-test section.
+ */
+
+static const char *
+selftest_sign_1024 (gcry_sexp_t pkey, gcry_sexp_t skey)
+{
+ static const char sample_data[] =
+ "(data (flags pkcs1)"
+ " (hash sha1 #11223344556677889900aabbccddeeff10203040#))";
+ static const char sample_data_bad[] =
+ "(data (flags pkcs1)"
+ " (hash sha1 #11223344556677889900aabbccddeeff80203040#))";
+
+ const char *errtxt = NULL;
+ gcry_error_t err;
+ gcry_sexp_t data = NULL;
+ gcry_sexp_t data_bad = NULL;
+ gcry_sexp_t sig = NULL;
+
+ err = gcry_sexp_sscan (&data, NULL,
+ sample_data, strlen (sample_data));
+ if (!err)
+ err = gcry_sexp_sscan (&data_bad, NULL,
+ sample_data_bad, strlen (sample_data_bad));
+ if (err)
+ {
+ errtxt = "converting data failed";
+ goto leave;
+ }
+
+ err = gcry_pk_sign (&sig, data, skey);
+ if (err)
+ {
+ errtxt = "signing failed";
+ goto leave;
+ }
+ err = gcry_pk_verify (sig, data, pkey);
+ if (err)
+ {
+ errtxt = "verify failed";
+ goto leave;
+ }
+ err = gcry_pk_verify (sig, data_bad, pkey);
+ if (gcry_err_code (err) != GPG_ERR_BAD_SIGNATURE)
+ {
+ errtxt = "bad signature not detected";
+ goto leave;
+ }
+
+
+ leave:
+ gcry_sexp_release (sig);
+ gcry_sexp_release (data_bad);
+ gcry_sexp_release (data);
+ return errtxt;
+}
+
+
+
+/* Given an S-expression ENCR_DATA of the form:
+
+ (enc-val
+ (rsa
+ (a a-value)))
+
+ as returned by gcry_pk_decrypt, return the the A-VALUE. On error,
+ return NULL. */
+static gcry_mpi_t
+extract_a_from_sexp (gcry_sexp_t encr_data)
+{
+ gcry_sexp_t l1, l2, l3;
+ gcry_mpi_t a_value;
+
+ l1 = gcry_sexp_find_token (encr_data, "enc-val", 0);
+ if (!l1)
+ return NULL;
+ l2 = gcry_sexp_find_token (l1, "rsa", 0);
+ gcry_sexp_release (l1);
+ if (!l2)
+ return NULL;
+ l3 = gcry_sexp_find_token (l2, "a", 0);
+ gcry_sexp_release (l2);
+ if (!l3)
+ return NULL;
+ a_value = gcry_sexp_nth_mpi (l3, 1, 0);
+ gcry_sexp_release (l3);
+
+ return a_value;
+}
+
+
+static const char *
+selftest_encr_1024 (gcry_sexp_t pkey, gcry_sexp_t skey)
+{
+ const char *errtxt = NULL;
+ gcry_error_t err;
+ const unsigned int nbits = 1000; /* Encrypt 1000 random bits. */
+ gcry_mpi_t plaintext = NULL;
+ gcry_sexp_t plain = NULL;
+ gcry_sexp_t encr = NULL;
+ gcry_mpi_t ciphertext = NULL;
+ gcry_sexp_t decr = NULL;
+ gcry_mpi_t decr_plaintext = NULL;
+ gcry_sexp_t tmplist = NULL;
+
+ /* Create plaintext. The plaintext is actually a big integer number. */
+ plaintext = gcry_mpi_new (nbits);
+ gcry_mpi_randomize (plaintext, nbits, GCRY_WEAK_RANDOM);
+
+ /* Put the plaintext into an S-expression. */
+ err = gcry_sexp_build (&plain, NULL,
+ "(data (flags raw) (value %m))", plaintext);
+ if (err)
+ {
+ errtxt = "converting data failed";
+ goto leave;
+ }
+
+ /* Encrypt. */
+ err = gcry_pk_encrypt (&encr, plain, pkey);
+ if (err)
+ {
+ errtxt = "encrypt failed";
+ goto leave;
+ }
+
+ /* Extraxt the ciphertext from the returned S-expression. */
+ /*gcry_sexp_dump (encr);*/
+ ciphertext = extract_a_from_sexp (encr);
+ if (!ciphertext)
+ {
+ errtxt = "gcry_pk_decrypt returned garbage";
+ goto leave;
+ }
+
+ /* Check that the ciphertext does no match the plaintext. */
+ /* _gcry_log_mpidump ("plaintext", plaintext); */
+ /* _gcry_log_mpidump ("ciphertxt", ciphertext); */
+ if (!gcry_mpi_cmp (plaintext, ciphertext))
+ {
+ errtxt = "ciphertext matches plaintext";
+ goto leave;
+ }
+
+ /* Decrypt. */
+ err = gcry_pk_decrypt (&decr, encr, skey);
+ if (err)
+ {
+ errtxt = "decrypt failed";
+ goto leave;
+ }
+
+ /* Extract the decrypted data from the S-expression. Note that the
+ output of gcry_pk_decrypt depends on whether a flags lists occurs
+ in its input data. Because we passed the output of
+ gcry_pk_encrypt directly to gcry_pk_decrypt, such a flag value
+ won't be there as of today. To be prepared for future changes we
+ take care of it anyway. */
+ tmplist = gcry_sexp_find_token (decr, "value", 0);
+ if (tmplist)
+ decr_plaintext = gcry_sexp_nth_mpi (tmplist, 1, GCRYMPI_FMT_USG);
+ else
+ decr_plaintext = gcry_sexp_nth_mpi (decr, 0, GCRYMPI_FMT_USG);
+ if (!decr_plaintext)
+ {
+ errtxt = "decrypt returned no plaintext";
+ goto leave;
+ }
+
+ /* Check that the decrypted plaintext matches the original plaintext. */
+ if (gcry_mpi_cmp (plaintext, decr_plaintext))
+ {
+ errtxt = "mismatch";
+ goto leave;
+ }
+
+ leave:
+ gcry_sexp_release (tmplist);
+ gcry_mpi_release (decr_plaintext);
+ gcry_sexp_release (decr);
+ gcry_mpi_release (ciphertext);
+ gcry_sexp_release (encr);
+ gcry_sexp_release (plain);
+ gcry_mpi_release (plaintext);
+ return errtxt;
+}
+
+
+static gpg_err_code_t
+selftests_rsa (selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+ gcry_error_t err;
+ gcry_sexp_t skey = NULL;
+ gcry_sexp_t pkey = NULL;
+
+ /* Convert the S-expressions into the internal representation. */
+ what = "convert";
+ err = gcry_sexp_sscan (&skey, NULL,
+ sample_secret_key, strlen (sample_secret_key));
+ if (!err)
+ err = gcry_sexp_sscan (&pkey, NULL,
+ sample_public_key, strlen (sample_public_key));
+ if (err)
+ {
+ errtxt = gcry_strerror (err);
+ goto failed;
+ }
+
+ what = "key consistency";
+ err = gcry_pk_testkey (skey);
+ if (err)
+ {
+ errtxt = gcry_strerror (err);
+ goto failed;
+ }
+
+ what = "sign";
+ errtxt = selftest_sign_1024 (pkey, skey);
+ if (errtxt)
+ goto failed;
+
+ what = "encrypt";
+ errtxt = selftest_encr_1024 (pkey, skey);
+ if (errtxt)
+ goto failed;
+
+ gcry_sexp_release (pkey);
+ gcry_sexp_release (skey);
+ return 0; /* Succeeded. */
+
+ failed:
+ gcry_sexp_release (pkey);
+ gcry_sexp_release (skey);
+ if (report)
+ report ("pubkey", GCRY_PK_RSA, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+static gpg_err_code_t
+run_selftests (int algo, int extended, selftest_report_func_t report)
+{
+ gpg_err_code_t ec;
+
+ (void)extended;
+
+ switch (algo)
+ {
+ case GCRY_PK_RSA:
+ ec = selftests_rsa (report);
+ break;
+ default:
+ ec = GPG_ERR_PUBKEY_ALGO;
+ break;
+
+ }
+ return ec;
+}
+
+
+
+
+static const char *rsa_names[] =
+ {
+ "rsa",
+ "openpgp-rsa",
+ "oid.1.2.840.113549.1.1.1",
+ NULL,
+ };
+
+gcry_pk_spec_t _gcry_pubkey_spec_rsa =
+ {
+ "RSA", rsa_names,
+ "ne", "nedpqu", "a", "s", "n",
+ GCRY_PK_USAGE_SIGN | GCRY_PK_USAGE_ENCR,
+ rsa_generate,
+ rsa_check_secret_key,
+ rsa_encrypt,
+ rsa_decrypt,
+ rsa_sign,
+ rsa_verify,
+ rsa_get_nbits,
+ };
+pk_extra_spec_t _gcry_pubkey_extraspec_rsa =
+ {
+ run_selftests,
+ rsa_generate_ext,
+ compute_keygrip
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/seed.c b/grub-core/lib/libgcrypt/cipher/seed.c
new file mode 100644
index 0000000..ae26e67
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/seed.c
@@ -0,0 +1,478 @@
+/* SEED for libgcrypt
+ * Copyright (C) 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --
+ * This implementation was provided for libgcrypt in public domain
+ * by Hye-Shik Chang <perky@FreeBSD.org>, July 2006.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "types.h" /* for byte and u32 typedefs */
+#include "g10lib.h"
+#include "cipher.h"
+
+#define NUMKC 16
+
+#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
+ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
+#define PUTU32(ct, st) { (ct)[0] = (byte)((st) >> 24); \
+ (ct)[1] = (byte)((st) >> 16); \
+ (ct)[2] = (byte)((st) >> 8); \
+ (ct)[3] = (byte)(st); }
+
+union wordbuf
+{
+ u32 w;
+ byte b[4];
+};
+
+#ifdef WORDS_BIGENDIAN
+#define b0 b[3]
+#define b1 b[2]
+#define b2 b[1]
+#define b3 b[0]
+#else
+#define b0 b[0]
+#define b1 b[1]
+#define b2 b[2]
+#define b3 b[3]
+#endif
+
+static const char *selftest(void);
+
+typedef struct
+{
+ u32 keyschedule[32];
+} SEED_context;
+
+static const u32 SS0[256] = {
+ 0x2989a1a8, 0x05858184, 0x16c6d2d4, 0x13c3d3d0, 0x14445054, 0x1d0d111c,
+ 0x2c8ca0ac, 0x25052124, 0x1d4d515c, 0x03434340, 0x18081018, 0x1e0e121c,
+ 0x11415150, 0x3cccf0fc, 0x0acac2c8, 0x23436360, 0x28082028, 0x04444044,
+ 0x20002020, 0x1d8d919c, 0x20c0e0e0, 0x22c2e2e0, 0x08c8c0c8, 0x17071314,
+ 0x2585a1a4, 0x0f8f838c, 0x03030300, 0x3b4b7378, 0x3b8bb3b8, 0x13031310,
+ 0x12c2d2d0, 0x2ecee2ec, 0x30407070, 0x0c8c808c, 0x3f0f333c, 0x2888a0a8,
+ 0x32023230, 0x1dcdd1dc, 0x36c6f2f4, 0x34447074, 0x2ccce0ec, 0x15859194,
+ 0x0b0b0308, 0x17475354, 0x1c4c505c, 0x1b4b5358, 0x3d8db1bc, 0x01010100,
+ 0x24042024, 0x1c0c101c, 0x33437370, 0x18889098, 0x10001010, 0x0cccc0cc,
+ 0x32c2f2f0, 0x19c9d1d8, 0x2c0c202c, 0x27c7e3e4, 0x32427270, 0x03838380,
+ 0x1b8b9398, 0x11c1d1d0, 0x06868284, 0x09c9c1c8, 0x20406060, 0x10405050,
+ 0x2383a3a0, 0x2bcbe3e8, 0x0d0d010c, 0x3686b2b4, 0x1e8e929c, 0x0f4f434c,
+ 0x3787b3b4, 0x1a4a5258, 0x06c6c2c4, 0x38487078, 0x2686a2a4, 0x12021210,
+ 0x2f8fa3ac, 0x15c5d1d4, 0x21416160, 0x03c3c3c0, 0x3484b0b4, 0x01414140,
+ 0x12425250, 0x3d4d717c, 0x0d8d818c, 0x08080008, 0x1f0f131c, 0x19899198,
+ 0x00000000, 0x19091118, 0x04040004, 0x13435350, 0x37c7f3f4, 0x21c1e1e0,
+ 0x3dcdf1fc, 0x36467274, 0x2f0f232c, 0x27072324, 0x3080b0b0, 0x0b8b8388,
+ 0x0e0e020c, 0x2b8ba3a8, 0x2282a2a0, 0x2e4e626c, 0x13839390, 0x0d4d414c,
+ 0x29496168, 0x3c4c707c, 0x09090108, 0x0a0a0208, 0x3f8fb3bc, 0x2fcfe3ec,
+ 0x33c3f3f0, 0x05c5c1c4, 0x07878384, 0x14041014, 0x3ecef2fc, 0x24446064,
+ 0x1eced2dc, 0x2e0e222c, 0x0b4b4348, 0x1a0a1218, 0x06060204, 0x21012120,
+ 0x2b4b6368, 0x26466264, 0x02020200, 0x35c5f1f4, 0x12829290, 0x0a8a8288,
+ 0x0c0c000c, 0x3383b3b0, 0x3e4e727c, 0x10c0d0d0, 0x3a4a7278, 0x07474344,
+ 0x16869294, 0x25c5e1e4, 0x26062224, 0x00808080, 0x2d8da1ac, 0x1fcfd3dc,
+ 0x2181a1a0, 0x30003030, 0x37073334, 0x2e8ea2ac, 0x36063234, 0x15051114,
+ 0x22022220, 0x38083038, 0x34c4f0f4, 0x2787a3a4, 0x05454144, 0x0c4c404c,
+ 0x01818180, 0x29c9e1e8, 0x04848084, 0x17879394, 0x35053134, 0x0bcbc3c8,
+ 0x0ecec2cc, 0x3c0c303c, 0x31417170, 0x11011110, 0x07c7c3c4, 0x09898188,
+ 0x35457174, 0x3bcbf3f8, 0x1acad2d8, 0x38c8f0f8, 0x14849094, 0x19495158,
+ 0x02828280, 0x04c4c0c4, 0x3fcff3fc, 0x09494148, 0x39093138, 0x27476364,
+ 0x00c0c0c0, 0x0fcfc3cc, 0x17c7d3d4, 0x3888b0b8, 0x0f0f030c, 0x0e8e828c,
+ 0x02424240, 0x23032320, 0x11819190, 0x2c4c606c, 0x1bcbd3d8, 0x2484a0a4,
+ 0x34043034, 0x31c1f1f0, 0x08484048, 0x02c2c2c0, 0x2f4f636c, 0x3d0d313c,
+ 0x2d0d212c, 0x00404040, 0x3e8eb2bc, 0x3e0e323c, 0x3c8cb0bc, 0x01c1c1c0,
+ 0x2a8aa2a8, 0x3a8ab2b8, 0x0e4e424c, 0x15455154, 0x3b0b3338, 0x1cccd0dc,
+ 0x28486068, 0x3f4f737c, 0x1c8c909c, 0x18c8d0d8, 0x0a4a4248, 0x16465254,
+ 0x37477374, 0x2080a0a0, 0x2dcde1ec, 0x06464244, 0x3585b1b4, 0x2b0b2328,
+ 0x25456164, 0x3acaf2f8, 0x23c3e3e0, 0x3989b1b8, 0x3181b1b0, 0x1f8f939c,
+ 0x1e4e525c, 0x39c9f1f8, 0x26c6e2e4, 0x3282b2b0, 0x31013130, 0x2acae2e8,
+ 0x2d4d616c, 0x1f4f535c, 0x24c4e0e4, 0x30c0f0f0, 0x0dcdc1cc, 0x08888088,
+ 0x16061214, 0x3a0a3238, 0x18485058, 0x14c4d0d4, 0x22426260, 0x29092128,
+ 0x07070304, 0x33033330, 0x28c8e0e8, 0x1b0b1318, 0x05050104, 0x39497178,
+ 0x10809090, 0x2a4a6268, 0x2a0a2228, 0x1a8a9298,
+};
+
+static const u32 SS1[256] = {
+ 0x38380830, 0xe828c8e0, 0x2c2d0d21, 0xa42686a2, 0xcc0fcfc3, 0xdc1eced2,
+ 0xb03383b3, 0xb83888b0, 0xac2f8fa3, 0x60204060, 0x54154551, 0xc407c7c3,
+ 0x44044440, 0x6c2f4f63, 0x682b4b63, 0x581b4b53, 0xc003c3c3, 0x60224262,
+ 0x30330333, 0xb43585b1, 0x28290921, 0xa02080a0, 0xe022c2e2, 0xa42787a3,
+ 0xd013c3d3, 0x90118191, 0x10110111, 0x04060602, 0x1c1c0c10, 0xbc3c8cb0,
+ 0x34360632, 0x480b4b43, 0xec2fcfe3, 0x88088880, 0x6c2c4c60, 0xa82888a0,
+ 0x14170713, 0xc404c4c0, 0x14160612, 0xf434c4f0, 0xc002c2c2, 0x44054541,
+ 0xe021c1e1, 0xd416c6d2, 0x3c3f0f33, 0x3c3d0d31, 0x8c0e8e82, 0x98188890,
+ 0x28280820, 0x4c0e4e42, 0xf436c6f2, 0x3c3e0e32, 0xa42585a1, 0xf839c9f1,
+ 0x0c0d0d01, 0xdc1fcfd3, 0xd818c8d0, 0x282b0b23, 0x64264662, 0x783a4a72,
+ 0x24270723, 0x2c2f0f23, 0xf031c1f1, 0x70324272, 0x40024242, 0xd414c4d0,
+ 0x40014141, 0xc000c0c0, 0x70334373, 0x64274763, 0xac2c8ca0, 0x880b8b83,
+ 0xf437c7f3, 0xac2d8da1, 0x80008080, 0x1c1f0f13, 0xc80acac2, 0x2c2c0c20,
+ 0xa82a8aa2, 0x34340430, 0xd012c2d2, 0x080b0b03, 0xec2ecee2, 0xe829c9e1,
+ 0x5c1d4d51, 0x94148490, 0x18180810, 0xf838c8f0, 0x54174753, 0xac2e8ea2,
+ 0x08080800, 0xc405c5c1, 0x10130313, 0xcc0dcdc1, 0x84068682, 0xb83989b1,
+ 0xfc3fcff3, 0x7c3d4d71, 0xc001c1c1, 0x30310131, 0xf435c5f1, 0x880a8a82,
+ 0x682a4a62, 0xb03181b1, 0xd011c1d1, 0x20200020, 0xd417c7d3, 0x00020202,
+ 0x20220222, 0x04040400, 0x68284860, 0x70314171, 0x04070703, 0xd81bcbd3,
+ 0x9c1d8d91, 0x98198991, 0x60214161, 0xbc3e8eb2, 0xe426c6e2, 0x58194951,
+ 0xdc1dcdd1, 0x50114151, 0x90108090, 0xdc1cccd0, 0x981a8a92, 0xa02383a3,
+ 0xa82b8ba3, 0xd010c0d0, 0x80018181, 0x0c0f0f03, 0x44074743, 0x181a0a12,
+ 0xe023c3e3, 0xec2ccce0, 0x8c0d8d81, 0xbc3f8fb3, 0x94168692, 0x783b4b73,
+ 0x5c1c4c50, 0xa02282a2, 0xa02181a1, 0x60234363, 0x20230323, 0x4c0d4d41,
+ 0xc808c8c0, 0x9c1e8e92, 0x9c1c8c90, 0x383a0a32, 0x0c0c0c00, 0x2c2e0e22,
+ 0xb83a8ab2, 0x6c2e4e62, 0x9c1f8f93, 0x581a4a52, 0xf032c2f2, 0x90128292,
+ 0xf033c3f3, 0x48094941, 0x78384870, 0xcc0cccc0, 0x14150511, 0xf83bcbf3,
+ 0x70304070, 0x74354571, 0x7c3f4f73, 0x34350531, 0x10100010, 0x00030303,
+ 0x64244460, 0x6c2d4d61, 0xc406c6c2, 0x74344470, 0xd415c5d1, 0xb43484b0,
+ 0xe82acae2, 0x08090901, 0x74364672, 0x18190911, 0xfc3ecef2, 0x40004040,
+ 0x10120212, 0xe020c0e0, 0xbc3d8db1, 0x04050501, 0xf83acaf2, 0x00010101,
+ 0xf030c0f0, 0x282a0a22, 0x5c1e4e52, 0xa82989a1, 0x54164652, 0x40034343,
+ 0x84058581, 0x14140410, 0x88098981, 0x981b8b93, 0xb03080b0, 0xe425c5e1,
+ 0x48084840, 0x78394971, 0x94178793, 0xfc3cccf0, 0x1c1e0e12, 0x80028282,
+ 0x20210121, 0x8c0c8c80, 0x181b0b13, 0x5c1f4f53, 0x74374773, 0x54144450,
+ 0xb03282b2, 0x1c1d0d11, 0x24250521, 0x4c0f4f43, 0x00000000, 0x44064642,
+ 0xec2dcde1, 0x58184850, 0x50124252, 0xe82bcbe3, 0x7c3e4e72, 0xd81acad2,
+ 0xc809c9c1, 0xfc3dcdf1, 0x30300030, 0x94158591, 0x64254561, 0x3c3c0c30,
+ 0xb43686b2, 0xe424c4e0, 0xb83b8bb3, 0x7c3c4c70, 0x0c0e0e02, 0x50104050,
+ 0x38390931, 0x24260622, 0x30320232, 0x84048480, 0x68294961, 0x90138393,
+ 0x34370733, 0xe427c7e3, 0x24240420, 0xa42484a0, 0xc80bcbc3, 0x50134353,
+ 0x080a0a02, 0x84078783, 0xd819c9d1, 0x4c0c4c40, 0x80038383, 0x8c0f8f83,
+ 0xcc0ecec2, 0x383b0b33, 0x480a4a42, 0xb43787b3,
+};
+
+static const u32 SS2[256] = {
+ 0xa1a82989, 0x81840585, 0xd2d416c6, 0xd3d013c3, 0x50541444, 0x111c1d0d,
+ 0xa0ac2c8c, 0x21242505, 0x515c1d4d, 0x43400343, 0x10181808, 0x121c1e0e,
+ 0x51501141, 0xf0fc3ccc, 0xc2c80aca, 0x63602343, 0x20282808, 0x40440444,
+ 0x20202000, 0x919c1d8d, 0xe0e020c0, 0xe2e022c2, 0xc0c808c8, 0x13141707,
+ 0xa1a42585, 0x838c0f8f, 0x03000303, 0x73783b4b, 0xb3b83b8b, 0x13101303,
+ 0xd2d012c2, 0xe2ec2ece, 0x70703040, 0x808c0c8c, 0x333c3f0f, 0xa0a82888,
+ 0x32303202, 0xd1dc1dcd, 0xf2f436c6, 0x70743444, 0xe0ec2ccc, 0x91941585,
+ 0x03080b0b, 0x53541747, 0x505c1c4c, 0x53581b4b, 0xb1bc3d8d, 0x01000101,
+ 0x20242404, 0x101c1c0c, 0x73703343, 0x90981888, 0x10101000, 0xc0cc0ccc,
+ 0xf2f032c2, 0xd1d819c9, 0x202c2c0c, 0xe3e427c7, 0x72703242, 0x83800383,
+ 0x93981b8b, 0xd1d011c1, 0x82840686, 0xc1c809c9, 0x60602040, 0x50501040,
+ 0xa3a02383, 0xe3e82bcb, 0x010c0d0d, 0xb2b43686, 0x929c1e8e, 0x434c0f4f,
+ 0xb3b43787, 0x52581a4a, 0xc2c406c6, 0x70783848, 0xa2a42686, 0x12101202,
+ 0xa3ac2f8f, 0xd1d415c5, 0x61602141, 0xc3c003c3, 0xb0b43484, 0x41400141,
+ 0x52501242, 0x717c3d4d, 0x818c0d8d, 0x00080808, 0x131c1f0f, 0x91981989,
+ 0x00000000, 0x11181909, 0x00040404, 0x53501343, 0xf3f437c7, 0xe1e021c1,
+ 0xf1fc3dcd, 0x72743646, 0x232c2f0f, 0x23242707, 0xb0b03080, 0x83880b8b,
+ 0x020c0e0e, 0xa3a82b8b, 0xa2a02282, 0x626c2e4e, 0x93901383, 0x414c0d4d,
+ 0x61682949, 0x707c3c4c, 0x01080909, 0x02080a0a, 0xb3bc3f8f, 0xe3ec2fcf,
+ 0xf3f033c3, 0xc1c405c5, 0x83840787, 0x10141404, 0xf2fc3ece, 0x60642444,
+ 0xd2dc1ece, 0x222c2e0e, 0x43480b4b, 0x12181a0a, 0x02040606, 0x21202101,
+ 0x63682b4b, 0x62642646, 0x02000202, 0xf1f435c5, 0x92901282, 0x82880a8a,
+ 0x000c0c0c, 0xb3b03383, 0x727c3e4e, 0xd0d010c0, 0x72783a4a, 0x43440747,
+ 0x92941686, 0xe1e425c5, 0x22242606, 0x80800080, 0xa1ac2d8d, 0xd3dc1fcf,
+ 0xa1a02181, 0x30303000, 0x33343707, 0xa2ac2e8e, 0x32343606, 0x11141505,
+ 0x22202202, 0x30383808, 0xf0f434c4, 0xa3a42787, 0x41440545, 0x404c0c4c,
+ 0x81800181, 0xe1e829c9, 0x80840484, 0x93941787, 0x31343505, 0xc3c80bcb,
+ 0xc2cc0ece, 0x303c3c0c, 0x71703141, 0x11101101, 0xc3c407c7, 0x81880989,
+ 0x71743545, 0xf3f83bcb, 0xd2d81aca, 0xf0f838c8, 0x90941484, 0x51581949,
+ 0x82800282, 0xc0c404c4, 0xf3fc3fcf, 0x41480949, 0x31383909, 0x63642747,
+ 0xc0c000c0, 0xc3cc0fcf, 0xd3d417c7, 0xb0b83888, 0x030c0f0f, 0x828c0e8e,
+ 0x42400242, 0x23202303, 0x91901181, 0x606c2c4c, 0xd3d81bcb, 0xa0a42484,
+ 0x30343404, 0xf1f031c1, 0x40480848, 0xc2c002c2, 0x636c2f4f, 0x313c3d0d,
+ 0x212c2d0d, 0x40400040, 0xb2bc3e8e, 0x323c3e0e, 0xb0bc3c8c, 0xc1c001c1,
+ 0xa2a82a8a, 0xb2b83a8a, 0x424c0e4e, 0x51541545, 0x33383b0b, 0xd0dc1ccc,
+ 0x60682848, 0x737c3f4f, 0x909c1c8c, 0xd0d818c8, 0x42480a4a, 0x52541646,
+ 0x73743747, 0xa0a02080, 0xe1ec2dcd, 0x42440646, 0xb1b43585, 0x23282b0b,
+ 0x61642545, 0xf2f83aca, 0xe3e023c3, 0xb1b83989, 0xb1b03181, 0x939c1f8f,
+ 0x525c1e4e, 0xf1f839c9, 0xe2e426c6, 0xb2b03282, 0x31303101, 0xe2e82aca,
+ 0x616c2d4d, 0x535c1f4f, 0xe0e424c4, 0xf0f030c0, 0xc1cc0dcd, 0x80880888,
+ 0x12141606, 0x32383a0a, 0x50581848, 0xd0d414c4, 0x62602242, 0x21282909,
+ 0x03040707, 0x33303303, 0xe0e828c8, 0x13181b0b, 0x01040505, 0x71783949,
+ 0x90901080, 0x62682a4a, 0x22282a0a, 0x92981a8a,
+};
+
+static const u32 SS3[256] = {
+ 0x08303838, 0xc8e0e828, 0x0d212c2d, 0x86a2a426, 0xcfc3cc0f, 0xced2dc1e,
+ 0x83b3b033, 0x88b0b838, 0x8fa3ac2f, 0x40606020, 0x45515415, 0xc7c3c407,
+ 0x44404404, 0x4f636c2f, 0x4b63682b, 0x4b53581b, 0xc3c3c003, 0x42626022,
+ 0x03333033, 0x85b1b435, 0x09212829, 0x80a0a020, 0xc2e2e022, 0x87a3a427,
+ 0xc3d3d013, 0x81919011, 0x01111011, 0x06020406, 0x0c101c1c, 0x8cb0bc3c,
+ 0x06323436, 0x4b43480b, 0xcfe3ec2f, 0x88808808, 0x4c606c2c, 0x88a0a828,
+ 0x07131417, 0xc4c0c404, 0x06121416, 0xc4f0f434, 0xc2c2c002, 0x45414405,
+ 0xc1e1e021, 0xc6d2d416, 0x0f333c3f, 0x0d313c3d, 0x8e828c0e, 0x88909818,
+ 0x08202828, 0x4e424c0e, 0xc6f2f436, 0x0e323c3e, 0x85a1a425, 0xc9f1f839,
+ 0x0d010c0d, 0xcfd3dc1f, 0xc8d0d818, 0x0b23282b, 0x46626426, 0x4a72783a,
+ 0x07232427, 0x0f232c2f, 0xc1f1f031, 0x42727032, 0x42424002, 0xc4d0d414,
+ 0x41414001, 0xc0c0c000, 0x43737033, 0x47636427, 0x8ca0ac2c, 0x8b83880b,
+ 0xc7f3f437, 0x8da1ac2d, 0x80808000, 0x0f131c1f, 0xcac2c80a, 0x0c202c2c,
+ 0x8aa2a82a, 0x04303434, 0xc2d2d012, 0x0b03080b, 0xcee2ec2e, 0xc9e1e829,
+ 0x4d515c1d, 0x84909414, 0x08101818, 0xc8f0f838, 0x47535417, 0x8ea2ac2e,
+ 0x08000808, 0xc5c1c405, 0x03131013, 0xcdc1cc0d, 0x86828406, 0x89b1b839,
+ 0xcff3fc3f, 0x4d717c3d, 0xc1c1c001, 0x01313031, 0xc5f1f435, 0x8a82880a,
+ 0x4a62682a, 0x81b1b031, 0xc1d1d011, 0x00202020, 0xc7d3d417, 0x02020002,
+ 0x02222022, 0x04000404, 0x48606828, 0x41717031, 0x07030407, 0xcbd3d81b,
+ 0x8d919c1d, 0x89919819, 0x41616021, 0x8eb2bc3e, 0xc6e2e426, 0x49515819,
+ 0xcdd1dc1d, 0x41515011, 0x80909010, 0xccd0dc1c, 0x8a92981a, 0x83a3a023,
+ 0x8ba3a82b, 0xc0d0d010, 0x81818001, 0x0f030c0f, 0x47434407, 0x0a12181a,
+ 0xc3e3e023, 0xcce0ec2c, 0x8d818c0d, 0x8fb3bc3f, 0x86929416, 0x4b73783b,
+ 0x4c505c1c, 0x82a2a022, 0x81a1a021, 0x43636023, 0x03232023, 0x4d414c0d,
+ 0xc8c0c808, 0x8e929c1e, 0x8c909c1c, 0x0a32383a, 0x0c000c0c, 0x0e222c2e,
+ 0x8ab2b83a, 0x4e626c2e, 0x8f939c1f, 0x4a52581a, 0xc2f2f032, 0x82929012,
+ 0xc3f3f033, 0x49414809, 0x48707838, 0xccc0cc0c, 0x05111415, 0xcbf3f83b,
+ 0x40707030, 0x45717435, 0x4f737c3f, 0x05313435, 0x00101010, 0x03030003,
+ 0x44606424, 0x4d616c2d, 0xc6c2c406, 0x44707434, 0xc5d1d415, 0x84b0b434,
+ 0xcae2e82a, 0x09010809, 0x46727436, 0x09111819, 0xcef2fc3e, 0x40404000,
+ 0x02121012, 0xc0e0e020, 0x8db1bc3d, 0x05010405, 0xcaf2f83a, 0x01010001,
+ 0xc0f0f030, 0x0a22282a, 0x4e525c1e, 0x89a1a829, 0x46525416, 0x43434003,
+ 0x85818405, 0x04101414, 0x89818809, 0x8b93981b, 0x80b0b030, 0xc5e1e425,
+ 0x48404808, 0x49717839, 0x87939417, 0xccf0fc3c, 0x0e121c1e, 0x82828002,
+ 0x01212021, 0x8c808c0c, 0x0b13181b, 0x4f535c1f, 0x47737437, 0x44505414,
+ 0x82b2b032, 0x0d111c1d, 0x05212425, 0x4f434c0f, 0x00000000, 0x46424406,
+ 0xcde1ec2d, 0x48505818, 0x42525012, 0xcbe3e82b, 0x4e727c3e, 0xcad2d81a,
+ 0xc9c1c809, 0xcdf1fc3d, 0x00303030, 0x85919415, 0x45616425, 0x0c303c3c,
+ 0x86b2b436, 0xc4e0e424, 0x8bb3b83b, 0x4c707c3c, 0x0e020c0e, 0x40505010,
+ 0x09313839, 0x06222426, 0x02323032, 0x84808404, 0x49616829, 0x83939013,
+ 0x07333437, 0xc7e3e427, 0x04202424, 0x84a0a424, 0xcbc3c80b, 0x43535013,
+ 0x0a02080a, 0x87838407, 0xc9d1d819, 0x4c404c0c, 0x83838003, 0x8f838c0f,
+ 0xcec2cc0e, 0x0b33383b, 0x4a42480a, 0x87b3b437,
+};
+
+static const u32 KC[NUMKC] = {
+ 0x9e3779b9, 0x3c6ef373, 0x78dde6e6, 0xf1bbcdcc,
+ 0xe3779b99, 0xc6ef3733, 0x8dde6e67, 0x1bbcdccf,
+ 0x3779b99e, 0x6ef3733c, 0xdde6e678, 0xbbcdccf1,
+ 0x779b99e3, 0xef3733c6, 0xde6e678d, 0xbcdccf1b,
+};
+
+
+
+/* Perform the key setup.
+ */
+static gcry_err_code_t
+do_setkey (SEED_context *ctx, const byte *key, const unsigned keylen)
+{
+ static int initialized = 0;
+ static const char *selftest_failed=0;
+ u32 x1, x2, x3, x4;
+ union wordbuf t0, t1;
+ u32 *keyout = ctx->keyschedule;
+ int i;
+
+ if (!initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+ if( selftest_failed )
+ log_error ("%s\n", selftest_failed );
+ }
+ if (selftest_failed)
+ return GPG_ERR_SELFTEST_FAILED;
+
+ if (keylen != 16)
+ return GPG_ERR_INV_KEYLEN;
+
+ x1 = GETU32 (key);
+ x2 = GETU32 (key+4);
+ x3 = GETU32 (key+8);
+ x4 = GETU32 (key+12);
+
+ for (i = 0; i < NUMKC; i++)
+ {
+ t0.w = x1 + x3 - KC[i];
+ t1.w = x2 + KC[i] - x4;
+ *(keyout++) = SS0[t0.b0] ^ SS1[t0.b1] ^ SS2[t0.b2] ^ SS3[t0.b3];
+ *(keyout++) = SS0[t1.b0] ^ SS1[t1.b1] ^ SS2[t1.b2] ^ SS3[t1.b3];
+
+ if (i % 2 == 0)
+ {
+ t0.w = x1;
+ x1 = (x1>>8) ^ (x2<<24);
+ x2 = (x2>>8) ^ (t0.w<<24);
+ }
+ else
+ {
+ t0.w = x3;
+ x3 = (x3<<8) ^ (x4>>24);
+ x4 = (x4<<8) ^ (t0.w>>24);
+ }
+ }
+
+ return 0;
+}
+
+static gcry_err_code_t
+seed_setkey (void *context, const byte *key, const unsigned keylen)
+{
+ SEED_context *ctx = context;
+
+ int rc = do_setkey (ctx, key, keylen);
+ _gcry_burn_stack (4*6 + sizeof(void*)*2 + sizeof(int)*2);
+ return rc;
+}
+
+
+
+#define OP(X1, X2, X3, X4, rbase) \
+ t0.w = X3 ^ ctx->keyschedule[rbase]; \
+ t1.w = X4 ^ ctx->keyschedule[rbase+1]; \
+ t1.w ^= t0.w; \
+ t1.w = SS0[t1.b0] ^ SS1[t1.b1] ^ SS2[t1.b2] ^ SS3[t1.b3]; \
+ t0.w += t1.w; \
+ t0.w = SS0[t0.b0] ^ SS1[t0.b1] ^ SS2[t0.b2] ^ SS3[t0.b3]; \
+ t1.w += t0.w; \
+ t1.w = SS0[t1.b0] ^ SS1[t1.b1] ^ SS2[t1.b2] ^ SS3[t1.b3]; \
+ t0.w += t1.w; \
+ X1 ^= t0.w; \
+ X2 ^= t1.w;
+
+/* Encrypt one block. inbuf and outbuf may be the same. */
+static void
+do_encrypt (const SEED_context *ctx, byte *outbuf, const byte *inbuf)
+{
+ u32 x1, x2, x3, x4;
+ union wordbuf t0, t1;
+
+ x1 = GETU32 (inbuf);
+ x2 = GETU32 (inbuf+4);
+ x3 = GETU32 (inbuf+8);
+ x4 = GETU32 (inbuf+12);
+
+ OP (x1, x2, x3, x4, 0);
+ OP (x3, x4, x1, x2, 2);
+ OP (x1, x2, x3, x4, 4);
+ OP (x3, x4, x1, x2, 6);
+ OP (x1, x2, x3, x4, 8);
+ OP (x3, x4, x1, x2, 10);
+ OP (x1, x2, x3, x4, 12);
+ OP (x3, x4, x1, x2, 14);
+ OP (x1, x2, x3, x4, 16);
+ OP (x3, x4, x1, x2, 18);
+ OP (x1, x2, x3, x4, 20);
+ OP (x3, x4, x1, x2, 22);
+ OP (x1, x2, x3, x4, 24);
+ OP (x3, x4, x1, x2, 26);
+ OP (x1, x2, x3, x4, 28);
+ OP (x3, x4, x1, x2, 30);
+
+ PUTU32 (outbuf, x3);
+ PUTU32 (outbuf+4, x4);
+ PUTU32 (outbuf+8, x1);
+ PUTU32 (outbuf+12, x2);
+}
+
+static void
+seed_encrypt (void *context, byte *outbuf, const byte *inbuf)
+{
+ SEED_context *ctx = context;
+
+ do_encrypt (ctx, outbuf, inbuf);
+ _gcry_burn_stack (4*6);
+}
+
+
+
+/* Decrypt one block. inbuf and outbuf may be the same. */
+static void
+do_decrypt (SEED_context *ctx, byte *outbuf, const byte *inbuf)
+{
+ u32 x1, x2, x3, x4;
+ union wordbuf t0, t1;
+
+ x1 = GETU32 (inbuf);
+ x2 = GETU32 (inbuf+4);
+ x3 = GETU32 (inbuf+8);
+ x4 = GETU32 (inbuf+12);
+
+ OP (x1, x2, x3, x4, 30);
+ OP (x3, x4, x1, x2, 28);
+ OP (x1, x2, x3, x4, 26);
+ OP (x3, x4, x1, x2, 24);
+ OP (x1, x2, x3, x4, 22);
+ OP (x3, x4, x1, x2, 20);
+ OP (x1, x2, x3, x4, 18);
+ OP (x3, x4, x1, x2, 16);
+ OP (x1, x2, x3, x4, 14);
+ OP (x3, x4, x1, x2, 12);
+ OP (x1, x2, x3, x4, 10);
+ OP (x3, x4, x1, x2, 8);
+ OP (x1, x2, x3, x4, 6);
+ OP (x3, x4, x1, x2, 4);
+ OP (x1, x2, x3, x4, 2);
+ OP (x3, x4, x1, x2, 0);
+
+ PUTU32 (outbuf, x3);
+ PUTU32 (outbuf+4, x4);
+ PUTU32 (outbuf+8, x1);
+ PUTU32 (outbuf+12, x2);
+}
+
+static void
+seed_decrypt (void *context, byte *outbuf, const byte *inbuf)
+{
+ SEED_context *ctx = context;
+
+ do_decrypt (ctx, outbuf, inbuf);
+ _gcry_burn_stack (4*6);
+}
+
+
+/* Test a single encryption and decryption with each key size. */
+static const char*
+selftest (void)
+{
+ SEED_context ctx;
+ byte scratch[16];
+
+ /* The test vector is taken from the appendix section B.3 of RFC4269.
+ */
+ static const byte plaintext[16] = {
+ 0x83, 0xA2, 0xF8, 0xA2, 0x88, 0x64, 0x1F, 0xB9,
+ 0xA4, 0xE9, 0xA5, 0xCC, 0x2F, 0x13, 0x1C, 0x7D
+ };
+ static const byte key[16] = {
+ 0x47, 0x06, 0x48, 0x08, 0x51, 0xE6, 0x1B, 0xE8,
+ 0x5D, 0x74, 0xBF, 0xB3, 0xFD, 0x95, 0x61, 0x85
+ };
+ static const byte ciphertext[16] = {
+ 0xEE, 0x54, 0xD1, 0x3E, 0xBC, 0xAE, 0x70, 0x6D,
+ 0x22, 0x6B, 0xC3, 0x14, 0x2C, 0xD4, 0x0D, 0x4A,
+ };
+
+ seed_setkey (&ctx, key, sizeof(key));
+ seed_encrypt (&ctx, scratch, plaintext);
+ if (memcmp (scratch, ciphertext, sizeof (ciphertext)))
+ return "SEED test encryption failed.";
+ seed_decrypt (&ctx, scratch, scratch);
+ if (memcmp (scratch, plaintext, sizeof (plaintext)))
+ return "SEED test decryption failed.";
+
+ return NULL;
+}
+
+
+
+static gcry_cipher_oid_spec_t seed_oids[] =
+ {
+ { "1.2.410.200004.1.3", GCRY_CIPHER_MODE_ECB },
+ { "1.2.410.200004.1.4", GCRY_CIPHER_MODE_CBC },
+ { "1.2.410.200004.1.5", GCRY_CIPHER_MODE_CFB },
+ { "1.2.410.200004.1.6", GCRY_CIPHER_MODE_OFB },
+ { NULL }
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_seed =
+ {
+ "SEED", NULL, seed_oids, 16, 128, sizeof (SEED_context),
+ seed_setkey, seed_encrypt, seed_decrypt,
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/serpent.c b/grub-core/lib/libgcrypt/cipher/serpent.c
new file mode 100644
index 0000000..ea14c7e
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/serpent.c
@@ -0,0 +1,953 @@
+/* serpent.c - Implementation of the Serpent encryption algorithm.
+ * Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <stdio.h>
+
+#include "types.h"
+#include "g10lib.h"
+#include "cipher.h"
+#include "bithelp.h"
+
+/* Number of rounds per Serpent encrypt/decrypt operation. */
+#define ROUNDS 32
+
+/* Magic number, used during generating of the subkeys. */
+#define PHI 0x9E3779B9
+
+/* Serpent works on 128 bit blocks. */
+typedef u32 serpent_block_t[4];
+
+/* Serpent key, provided by the user. If the original key is shorter
+ than 256 bits, it is padded. */
+typedef u32 serpent_key_t[8];
+
+/* The key schedule consists of 33 128 bit subkeys. */
+typedef u32 serpent_subkeys_t[ROUNDS + 1][4];
+
+/* A Serpent context. */
+typedef struct serpent_context
+{
+ serpent_subkeys_t keys; /* Generated subkeys. */
+} serpent_context_t;
+
+
+/* A prototype. */
+static const char *serpent_test (void);
+
+
+#define byte_swap_32(x) \
+ (0 \
+ | (((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
+ | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+
+/* These are the S-Boxes of Serpent. They are copied from Serpents
+ reference implementation (the optimized one, contained in
+ `floppy2') and are therefore:
+
+ Copyright (C) 1998 Ross Anderson, Eli Biham, Lars Knudsen.
+
+ To quote the Serpent homepage
+ (http://www.cl.cam.ac.uk/~rja14/serpent.html):
+
+ "Serpent is now completely in the public domain, and we impose no
+ restrictions on its use. This was announced on the 21st August at
+ the First AES Candidate Conference. The optimised implementations
+ in the submission package are now under the GNU PUBLIC LICENSE
+ (GPL), although some comments in the code still say otherwise. You
+ are welcome to use Serpent for any application." */
+
+#define SBOX0(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t05, t06, t07, t08, t09; \
+ u32 t11, t12, t13, t14, t15, t17, t01; \
+ t01 = b ^ c ; \
+ t02 = a | d ; \
+ t03 = a ^ b ; \
+ z = t02 ^ t01; \
+ t05 = c | z ; \
+ t06 = a ^ d ; \
+ t07 = b | c ; \
+ t08 = d & t05; \
+ t09 = t03 & t07; \
+ y = t09 ^ t08; \
+ t11 = t09 & y ; \
+ t12 = c ^ d ; \
+ t13 = t07 ^ t11; \
+ t14 = b & t06; \
+ t15 = t06 ^ t13; \
+ w = ~ t15; \
+ t17 = w ^ t14; \
+ x = t12 ^ t17; \
+ }
+
+#define SBOX0_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t08, t09, t10; \
+ u32 t12, t13, t14, t15, t17, t18, t01; \
+ t01 = c ^ d ; \
+ t02 = a | b ; \
+ t03 = b | c ; \
+ t04 = c & t01; \
+ t05 = t02 ^ t01; \
+ t06 = a | t04; \
+ y = ~ t05; \
+ t08 = b ^ d ; \
+ t09 = t03 & t08; \
+ t10 = d | y ; \
+ x = t09 ^ t06; \
+ t12 = a | t05; \
+ t13 = x ^ t12; \
+ t14 = t03 ^ t10; \
+ t15 = a ^ c ; \
+ z = t14 ^ t13; \
+ t17 = t05 & t13; \
+ t18 = t14 | t17; \
+ w = t15 ^ t18; \
+ }
+
+#define SBOX1(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t08; \
+ u32 t10, t11, t12, t13, t16, t17, t01; \
+ t01 = a | d ; \
+ t02 = c ^ d ; \
+ t03 = ~ b ; \
+ t04 = a ^ c ; \
+ t05 = a | t03; \
+ t06 = d & t04; \
+ t07 = t01 & t02; \
+ t08 = b | t06; \
+ y = t02 ^ t05; \
+ t10 = t07 ^ t08; \
+ t11 = t01 ^ t10; \
+ t12 = y ^ t11; \
+ t13 = b & d ; \
+ z = ~ t10; \
+ x = t13 ^ t12; \
+ t16 = t10 | x ; \
+ t17 = t05 & t16; \
+ w = c ^ t17; \
+ }
+
+#define SBOX1_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t08; \
+ u32 t09, t10, t11, t14, t15, t17, t01; \
+ t01 = a ^ b ; \
+ t02 = b | d ; \
+ t03 = a & c ; \
+ t04 = c ^ t02; \
+ t05 = a | t04; \
+ t06 = t01 & t05; \
+ t07 = d | t03; \
+ t08 = b ^ t06; \
+ t09 = t07 ^ t06; \
+ t10 = t04 | t03; \
+ t11 = d & t08; \
+ y = ~ t09; \
+ x = t10 ^ t11; \
+ t14 = a | y ; \
+ t15 = t06 ^ x ; \
+ z = t01 ^ t04; \
+ t17 = c ^ t15; \
+ w = t14 ^ t17; \
+ }
+
+#define SBOX2(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t05, t06, t07, t08; \
+ u32 t09, t10, t12, t13, t14, t01; \
+ t01 = a | c ; \
+ t02 = a ^ b ; \
+ t03 = d ^ t01; \
+ w = t02 ^ t03; \
+ t05 = c ^ w ; \
+ t06 = b ^ t05; \
+ t07 = b | t05; \
+ t08 = t01 & t06; \
+ t09 = t03 ^ t07; \
+ t10 = t02 | t09; \
+ x = t10 ^ t08; \
+ t12 = a | d ; \
+ t13 = t09 ^ x ; \
+ t14 = b ^ t13; \
+ z = ~ t09; \
+ y = t12 ^ t14; \
+ }
+
+#define SBOX2_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t06, t07, t08, t09; \
+ u32 t10, t11, t12, t15, t16, t17, t01; \
+ t01 = a ^ d ; \
+ t02 = c ^ d ; \
+ t03 = a & c ; \
+ t04 = b | t02; \
+ w = t01 ^ t04; \
+ t06 = a | c ; \
+ t07 = d | w ; \
+ t08 = ~ d ; \
+ t09 = b & t06; \
+ t10 = t08 | t03; \
+ t11 = b & t07; \
+ t12 = t06 & t02; \
+ z = t09 ^ t10; \
+ x = t12 ^ t11; \
+ t15 = c & z ; \
+ t16 = w ^ x ; \
+ t17 = t10 ^ t15; \
+ y = t16 ^ t17; \
+ }
+
+#define SBOX3(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t08; \
+ u32 t09, t10, t11, t13, t14, t15, t01; \
+ t01 = a ^ c ; \
+ t02 = a | d ; \
+ t03 = a & d ; \
+ t04 = t01 & t02; \
+ t05 = b | t03; \
+ t06 = a & b ; \
+ t07 = d ^ t04; \
+ t08 = c | t06; \
+ t09 = b ^ t07; \
+ t10 = d & t05; \
+ t11 = t02 ^ t10; \
+ z = t08 ^ t09; \
+ t13 = d | z ; \
+ t14 = a | t07; \
+ t15 = b & t13; \
+ y = t08 ^ t11; \
+ w = t14 ^ t15; \
+ x = t05 ^ t04; \
+ }
+
+#define SBOX3_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t09; \
+ u32 t11, t12, t13, t14, t16, t01; \
+ t01 = c | d ; \
+ t02 = a | d ; \
+ t03 = c ^ t02; \
+ t04 = b ^ t02; \
+ t05 = a ^ d ; \
+ t06 = t04 & t03; \
+ t07 = b & t01; \
+ y = t05 ^ t06; \
+ t09 = a ^ t03; \
+ w = t07 ^ t03; \
+ t11 = w | t05; \
+ t12 = t09 & t11; \
+ t13 = a & y ; \
+ t14 = t01 ^ t05; \
+ x = b ^ t12; \
+ t16 = b | t13; \
+ z = t14 ^ t16; \
+ }
+
+#define SBOX4(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t08, t09; \
+ u32 t10, t11, t12, t13, t14, t15, t16, t01; \
+ t01 = a | b ; \
+ t02 = b | c ; \
+ t03 = a ^ t02; \
+ t04 = b ^ d ; \
+ t05 = d | t03; \
+ t06 = d & t01; \
+ z = t03 ^ t06; \
+ t08 = z & t04; \
+ t09 = t04 & t05; \
+ t10 = c ^ t06; \
+ t11 = b & c ; \
+ t12 = t04 ^ t08; \
+ t13 = t11 | t03; \
+ t14 = t10 ^ t09; \
+ t15 = a & t05; \
+ t16 = t11 | t12; \
+ y = t13 ^ t08; \
+ x = t15 ^ t16; \
+ w = ~ t14; \
+ }
+
+#define SBOX4_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t09; \
+ u32 t10, t11, t12, t13, t15, t01; \
+ t01 = b | d ; \
+ t02 = c | d ; \
+ t03 = a & t01; \
+ t04 = b ^ t02; \
+ t05 = c ^ d ; \
+ t06 = ~ t03; \
+ t07 = a & t04; \
+ x = t05 ^ t07; \
+ t09 = x | t06; \
+ t10 = a ^ t07; \
+ t11 = t01 ^ t09; \
+ t12 = d ^ t04; \
+ t13 = c | t10; \
+ z = t03 ^ t12; \
+ t15 = a ^ t04; \
+ y = t11 ^ t13; \
+ w = t15 ^ t09; \
+ }
+
+#define SBOX5(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t07, t08, t09; \
+ u32 t10, t11, t12, t13, t14, t01; \
+ t01 = b ^ d ; \
+ t02 = b | d ; \
+ t03 = a & t01; \
+ t04 = c ^ t02; \
+ t05 = t03 ^ t04; \
+ w = ~ t05; \
+ t07 = a ^ t01; \
+ t08 = d | w ; \
+ t09 = b | t05; \
+ t10 = d ^ t08; \
+ t11 = b | t07; \
+ t12 = t03 | w ; \
+ t13 = t07 | t10; \
+ t14 = t01 ^ t11; \
+ y = t09 ^ t13; \
+ x = t07 ^ t08; \
+ z = t12 ^ t14; \
+ }
+
+#define SBOX5_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t07, t08, t09; \
+ u32 t10, t12, t13, t15, t16, t01; \
+ t01 = a & d ; \
+ t02 = c ^ t01; \
+ t03 = a ^ d ; \
+ t04 = b & t02; \
+ t05 = a & c ; \
+ w = t03 ^ t04; \
+ t07 = a & w ; \
+ t08 = t01 ^ w ; \
+ t09 = b | t05; \
+ t10 = ~ b ; \
+ x = t08 ^ t09; \
+ t12 = t10 | t07; \
+ t13 = w | x ; \
+ z = t02 ^ t12; \
+ t15 = t02 ^ t13; \
+ t16 = b ^ d ; \
+ y = t16 ^ t15; \
+ }
+
+#define SBOX6(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t07, t08, t09, t10; \
+ u32 t11, t12, t13, t15, t17, t18, t01; \
+ t01 = a & d ; \
+ t02 = b ^ c ; \
+ t03 = a ^ d ; \
+ t04 = t01 ^ t02; \
+ t05 = b | c ; \
+ x = ~ t04; \
+ t07 = t03 & t05; \
+ t08 = b & x ; \
+ t09 = a | c ; \
+ t10 = t07 ^ t08; \
+ t11 = b | d ; \
+ t12 = c ^ t11; \
+ t13 = t09 ^ t10; \
+ y = ~ t13; \
+ t15 = x & t03; \
+ z = t12 ^ t07; \
+ t17 = a ^ b ; \
+ t18 = y ^ t15; \
+ w = t17 ^ t18; \
+ }
+
+#define SBOX6_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t07, t08, t09; \
+ u32 t12, t13, t14, t15, t16, t17, t01; \
+ t01 = a ^ c ; \
+ t02 = ~ c ; \
+ t03 = b & t01; \
+ t04 = b | t02; \
+ t05 = d | t03; \
+ t06 = b ^ d ; \
+ t07 = a & t04; \
+ t08 = a | t02; \
+ t09 = t07 ^ t05; \
+ x = t06 ^ t08; \
+ w = ~ t09; \
+ t12 = b & w ; \
+ t13 = t01 & t05; \
+ t14 = t01 ^ t12; \
+ t15 = t07 ^ t13; \
+ t16 = d | t02; \
+ t17 = a ^ x ; \
+ z = t17 ^ t15; \
+ y = t16 ^ t14; \
+ }
+
+#define SBOX7(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t05, t06, t08, t09, t10; \
+ u32 t11, t13, t14, t15, t16, t17, t01; \
+ t01 = a & c ; \
+ t02 = ~ d ; \
+ t03 = a & t02; \
+ t04 = b | t01; \
+ t05 = a & b ; \
+ t06 = c ^ t04; \
+ z = t03 ^ t06; \
+ t08 = c | z ; \
+ t09 = d | t05; \
+ t10 = a ^ t08; \
+ t11 = t04 & z ; \
+ x = t09 ^ t10; \
+ t13 = b ^ x ; \
+ t14 = t01 ^ x ; \
+ t15 = c ^ t05; \
+ t16 = t11 | t13; \
+ t17 = t02 | t14; \
+ w = t15 ^ t17; \
+ y = a ^ t16; \
+ }
+
+#define SBOX7_INVERSE(a, b, c, d, w, x, y, z) \
+ { \
+ u32 t02, t03, t04, t06, t07, t08, t09; \
+ u32 t10, t11, t13, t14, t15, t16, t01; \
+ t01 = a & b ; \
+ t02 = a | b ; \
+ t03 = c | t01; \
+ t04 = d & t02; \
+ z = t03 ^ t04; \
+ t06 = b ^ t04; \
+ t07 = d ^ z ; \
+ t08 = ~ t07; \
+ t09 = t06 | t08; \
+ t10 = b ^ d ; \
+ t11 = a | d ; \
+ x = a ^ t09; \
+ t13 = c ^ t06; \
+ t14 = c & t11; \
+ t15 = d | x ; \
+ t16 = t01 | t10; \
+ w = t13 ^ t15; \
+ y = t14 ^ t16; \
+ }
+
+/* XOR BLOCK1 into BLOCK0. */
+#define BLOCK_XOR(block0, block1) \
+ { \
+ block0[0] ^= block1[0]; \
+ block0[1] ^= block1[1]; \
+ block0[2] ^= block1[2]; \
+ block0[3] ^= block1[3]; \
+ }
+
+/* Copy BLOCK_SRC to BLOCK_DST. */
+#define BLOCK_COPY(block_dst, block_src) \
+ { \
+ block_dst[0] = block_src[0]; \
+ block_dst[1] = block_src[1]; \
+ block_dst[2] = block_src[2]; \
+ block_dst[3] = block_src[3]; \
+ }
+
+/* Apply SBOX number WHICH to to the block found in ARRAY0 at index
+ INDEX, writing the output to the block found in ARRAY1 at index
+ INDEX. */
+#define SBOX(which, array0, array1, index) \
+ SBOX##which (array0[index + 0], array0[index + 1], \
+ array0[index + 2], array0[index + 3], \
+ array1[index + 0], array1[index + 1], \
+ array1[index + 2], array1[index + 3]);
+
+/* Apply inverse SBOX number WHICH to to the block found in ARRAY0 at
+ index INDEX, writing the output to the block found in ARRAY1 at
+ index INDEX. */
+#define SBOX_INVERSE(which, array0, array1, index) \
+ SBOX##which##_INVERSE (array0[index + 0], array0[index + 1], \
+ array0[index + 2], array0[index + 3], \
+ array1[index + 0], array1[index + 1], \
+ array1[index + 2], array1[index + 3]);
+
+/* Apply the linear transformation to BLOCK. */
+#define LINEAR_TRANSFORMATION(block) \
+ { \
+ block[0] = rol (block[0], 13); \
+ block[2] = rol (block[2], 3); \
+ block[1] = block[1] ^ block[0] ^ block[2]; \
+ block[3] = block[3] ^ block[2] ^ (block[0] << 3); \
+ block[1] = rol (block[1], 1); \
+ block[3] = rol (block[3], 7); \
+ block[0] = block[0] ^ block[1] ^ block[3]; \
+ block[2] = block[2] ^ block[3] ^ (block[1] << 7); \
+ block[0] = rol (block[0], 5); \
+ block[2] = rol (block[2], 22); \
+ }
+
+/* Apply the inverse linear transformation to BLOCK. */
+#define LINEAR_TRANSFORMATION_INVERSE(block) \
+ { \
+ block[2] = ror (block[2], 22); \
+ block[0] = ror (block[0] , 5); \
+ block[2] = block[2] ^ block[3] ^ (block[1] << 7); \
+ block[0] = block[0] ^ block[1] ^ block[3]; \
+ block[3] = ror (block[3], 7); \
+ block[1] = ror (block[1], 1); \
+ block[3] = block[3] ^ block[2] ^ (block[0] << 3); \
+ block[1] = block[1] ^ block[0] ^ block[2]; \
+ block[2] = ror (block[2], 3); \
+ block[0] = ror (block[0], 13); \
+ }
+
+/* Apply a Serpent round to BLOCK, using the SBOX number WHICH and the
+ subkeys contained in SUBKEYS. Use BLOCK_TMP as temporary storage.
+ This macro increments `round'. */
+#define ROUND(which, subkeys, block, block_tmp) \
+ { \
+ BLOCK_XOR (block, subkeys[round]); \
+ round++; \
+ SBOX (which, block, block_tmp, 0); \
+ LINEAR_TRANSFORMATION (block_tmp); \
+ BLOCK_COPY (block, block_tmp); \
+ }
+
+/* Apply the last Serpent round to BLOCK, using the SBOX number WHICH
+ and the subkeys contained in SUBKEYS. Use BLOCK_TMP as temporary
+ storage. The result will be stored in BLOCK_TMP. This macro
+ increments `round'. */
+#define ROUND_LAST(which, subkeys, block, block_tmp) \
+ { \
+ BLOCK_XOR (block, subkeys[round]); \
+ round++; \
+ SBOX (which, block, block_tmp, 0); \
+ BLOCK_XOR (block_tmp, subkeys[round]); \
+ round++; \
+ }
+
+/* Apply an inverse Serpent round to BLOCK, using the SBOX number
+ WHICH and the subkeys contained in SUBKEYS. Use BLOCK_TMP as
+ temporary storage. This macro increments `round'. */
+#define ROUND_INVERSE(which, subkey, block, block_tmp) \
+ { \
+ LINEAR_TRANSFORMATION_INVERSE (block); \
+ SBOX_INVERSE (which, block, block_tmp, 0); \
+ BLOCK_XOR (block_tmp, subkey[round]); \
+ round--; \
+ BLOCK_COPY (block, block_tmp); \
+ }
+
+/* Apply the first Serpent round to BLOCK, using the SBOX number WHICH
+ and the subkeys contained in SUBKEYS. Use BLOCK_TMP as temporary
+ storage. The result will be stored in BLOCK_TMP. This macro
+ increments `round'. */
+#define ROUND_FIRST_INVERSE(which, subkeys, block, block_tmp) \
+ { \
+ BLOCK_XOR (block, subkeys[round]); \
+ round--; \
+ SBOX_INVERSE (which, block, block_tmp, 0); \
+ BLOCK_XOR (block_tmp, subkeys[round]); \
+ round--; \
+ }
+
+/* Convert the user provided key KEY of KEY_LENGTH bytes into the
+ internally used format. */
+static void
+serpent_key_prepare (const byte *key, unsigned int key_length,
+ serpent_key_t key_prepared)
+{
+ int i;
+
+ /* Copy key. */
+ memcpy (key_prepared, key, key_length);
+ key_length /= 4;
+#ifdef WORDS_BIGENDIAN
+ for (i = 0; i < key_length; i++)
+ key_prepared[i] = byte_swap_32 (key_prepared[i]);
+#else
+ i = key_length;
+#endif
+ if (i < 8)
+ {
+ /* Key must be padded according to the Serpent
+ specification. */
+ key_prepared[i] = 0x00000001;
+
+ for (i++; i < 8; i++)
+ key_prepared[i] = 0;
+ }
+}
+
+/* Derive the 33 subkeys from KEY and store them in SUBKEYS. */
+static void
+serpent_subkeys_generate (serpent_key_t key, serpent_subkeys_t subkeys)
+{
+ u32 w_real[140]; /* The `prekey'. */
+ u32 k[132];
+ u32 *w = &w_real[8];
+ int i, j;
+
+ /* Initialize with key values. */
+ for (i = 0; i < 8; i++)
+ w[i - 8] = key[i];
+
+ /* Expand to intermediate key using the affine recurrence. */
+ for (i = 0; i < 132; i++)
+ w[i] = rol (w[i - 8] ^ w[i - 5] ^ w[i - 3] ^ w[i - 1] ^ PHI ^ i, 11);
+
+ /* Calculate subkeys via S-Boxes, in bitslice mode. */
+ SBOX (3, w, k, 0);
+ SBOX (2, w, k, 4);
+ SBOX (1, w, k, 8);
+ SBOX (0, w, k, 12);
+ SBOX (7, w, k, 16);
+ SBOX (6, w, k, 20);
+ SBOX (5, w, k, 24);
+ SBOX (4, w, k, 28);
+ SBOX (3, w, k, 32);
+ SBOX (2, w, k, 36);
+ SBOX (1, w, k, 40);
+ SBOX (0, w, k, 44);
+ SBOX (7, w, k, 48);
+ SBOX (6, w, k, 52);
+ SBOX (5, w, k, 56);
+ SBOX (4, w, k, 60);
+ SBOX (3, w, k, 64);
+ SBOX (2, w, k, 68);
+ SBOX (1, w, k, 72);
+ SBOX (0, w, k, 76);
+ SBOX (7, w, k, 80);
+ SBOX (6, w, k, 84);
+ SBOX (5, w, k, 88);
+ SBOX (4, w, k, 92);
+ SBOX (3, w, k, 96);
+ SBOX (2, w, k, 100);
+ SBOX (1, w, k, 104);
+ SBOX (0, w, k, 108);
+ SBOX (7, w, k, 112);
+ SBOX (6, w, k, 116);
+ SBOX (5, w, k, 120);
+ SBOX (4, w, k, 124);
+ SBOX (3, w, k, 128);
+
+ /* Renumber subkeys. */
+ for (i = 0; i < ROUNDS + 1; i++)
+ for (j = 0; j < 4; j++)
+ subkeys[i][j] = k[4 * i + j];
+}
+
+/* Initialize CONTEXT with the key KEY of KEY_LENGTH bits. */
+static void
+serpent_setkey_internal (serpent_context_t *context,
+ const byte *key, unsigned int key_length)
+{
+ serpent_key_t key_prepared;
+
+ serpent_key_prepare (key, key_length, key_prepared);
+ serpent_subkeys_generate (key_prepared, context->keys);
+ _gcry_burn_stack (272 * sizeof (u32));
+}
+
+/* Initialize CTX with the key KEY of KEY_LENGTH bytes. */
+static gcry_err_code_t
+serpent_setkey (void *ctx,
+ const byte *key, unsigned int key_length)
+{
+ serpent_context_t *context = ctx;
+ static const char *serpent_test_ret;
+ static int serpent_init_done;
+ gcry_err_code_t ret = GPG_ERR_NO_ERROR;
+
+ if (! serpent_init_done)
+ {
+ /* Execute a self-test the first time, Serpent is used. */
+ serpent_test_ret = serpent_test ();
+ if (serpent_test_ret)
+ log_error ("Serpent test failure: %s\n", serpent_test_ret);
+ serpent_init_done = 1;
+ }
+
+ if (serpent_test_ret)
+ ret = GPG_ERR_SELFTEST_FAILED;
+ else
+ {
+ serpent_setkey_internal (context, key, key_length);
+ _gcry_burn_stack (sizeof (serpent_key_t));
+ }
+
+ return ret;
+}
+
+static void
+serpent_encrypt_internal (serpent_context_t *context,
+ const byte *input, byte *output)
+{
+ serpent_block_t b, b_next;
+ int round = 0;
+
+ memcpy (b, input, sizeof (b));
+#ifdef WORDS_BIGENDIAN
+ b[0] = byte_swap_32 (b[0]);
+ b[1] = byte_swap_32 (b[1]);
+ b[2] = byte_swap_32 (b[2]);
+ b[3] = byte_swap_32 (b[3]);
+#endif
+
+ ROUND (0, context->keys, b, b_next);
+ ROUND (1, context->keys, b, b_next);
+ ROUND (2, context->keys, b, b_next);
+ ROUND (3, context->keys, b, b_next);
+ ROUND (4, context->keys, b, b_next);
+ ROUND (5, context->keys, b, b_next);
+ ROUND (6, context->keys, b, b_next);
+ ROUND (7, context->keys, b, b_next);
+ ROUND (0, context->keys, b, b_next);
+ ROUND (1, context->keys, b, b_next);
+ ROUND (2, context->keys, b, b_next);
+ ROUND (3, context->keys, b, b_next);
+ ROUND (4, context->keys, b, b_next);
+ ROUND (5, context->keys, b, b_next);
+ ROUND (6, context->keys, b, b_next);
+ ROUND (7, context->keys, b, b_next);
+ ROUND (0, context->keys, b, b_next);
+ ROUND (1, context->keys, b, b_next);
+ ROUND (2, context->keys, b, b_next);
+ ROUND (3, context->keys, b, b_next);
+ ROUND (4, context->keys, b, b_next);
+ ROUND (5, context->keys, b, b_next);
+ ROUND (6, context->keys, b, b_next);
+ ROUND (7, context->keys, b, b_next);
+ ROUND (0, context->keys, b, b_next);
+ ROUND (1, context->keys, b, b_next);
+ ROUND (2, context->keys, b, b_next);
+ ROUND (3, context->keys, b, b_next);
+ ROUND (4, context->keys, b, b_next);
+ ROUND (5, context->keys, b, b_next);
+ ROUND (6, context->keys, b, b_next);
+
+ ROUND_LAST (7, context->keys, b, b_next);
+
+#ifdef WORDS_BIGENDIAN
+ b_next[0] = byte_swap_32 (b_next[0]);
+ b_next[1] = byte_swap_32 (b_next[1]);
+ b_next[2] = byte_swap_32 (b_next[2]);
+ b_next[3] = byte_swap_32 (b_next[3]);
+#endif
+ memcpy (output, b_next, sizeof (b_next));
+}
+
+static void
+serpent_decrypt_internal (serpent_context_t *context,
+ const byte *input, byte *output)
+{
+ serpent_block_t b, b_next;
+ int round = ROUNDS;
+
+ memcpy (b_next, input, sizeof (b));
+#ifdef WORDS_BIGENDIAN
+ b_next[0] = byte_swap_32 (b_next[0]);
+ b_next[1] = byte_swap_32 (b_next[1]);
+ b_next[2] = byte_swap_32 (b_next[2]);
+ b_next[3] = byte_swap_32 (b_next[3]);
+#endif
+
+ ROUND_FIRST_INVERSE (7, context->keys, b_next, b);
+
+ ROUND_INVERSE (6, context->keys, b, b_next);
+ ROUND_INVERSE (5, context->keys, b, b_next);
+ ROUND_INVERSE (4, context->keys, b, b_next);
+ ROUND_INVERSE (3, context->keys, b, b_next);
+ ROUND_INVERSE (2, context->keys, b, b_next);
+ ROUND_INVERSE (1, context->keys, b, b_next);
+ ROUND_INVERSE (0, context->keys, b, b_next);
+ ROUND_INVERSE (7, context->keys, b, b_next);
+ ROUND_INVERSE (6, context->keys, b, b_next);
+ ROUND_INVERSE (5, context->keys, b, b_next);
+ ROUND_INVERSE (4, context->keys, b, b_next);
+ ROUND_INVERSE (3, context->keys, b, b_next);
+ ROUND_INVERSE (2, context->keys, b, b_next);
+ ROUND_INVERSE (1, context->keys, b, b_next);
+ ROUND_INVERSE (0, context->keys, b, b_next);
+ ROUND_INVERSE (7, context->keys, b, b_next);
+ ROUND_INVERSE (6, context->keys, b, b_next);
+ ROUND_INVERSE (5, context->keys, b, b_next);
+ ROUND_INVERSE (4, context->keys, b, b_next);
+ ROUND_INVERSE (3, context->keys, b, b_next);
+ ROUND_INVERSE (2, context->keys, b, b_next);
+ ROUND_INVERSE (1, context->keys, b, b_next);
+ ROUND_INVERSE (0, context->keys, b, b_next);
+ ROUND_INVERSE (7, context->keys, b, b_next);
+ ROUND_INVERSE (6, context->keys, b, b_next);
+ ROUND_INVERSE (5, context->keys, b, b_next);
+ ROUND_INVERSE (4, context->keys, b, b_next);
+ ROUND_INVERSE (3, context->keys, b, b_next);
+ ROUND_INVERSE (2, context->keys, b, b_next);
+ ROUND_INVERSE (1, context->keys, b, b_next);
+ ROUND_INVERSE (0, context->keys, b, b_next);
+
+#ifdef WORDS_BIGENDIAN
+ b_next[0] = byte_swap_32 (b_next[0]);
+ b_next[1] = byte_swap_32 (b_next[1]);
+ b_next[2] = byte_swap_32 (b_next[2]);
+ b_next[3] = byte_swap_32 (b_next[3]);
+#endif
+ memcpy (output, b_next, sizeof (b_next));
+}
+
+static void
+serpent_encrypt (void *ctx, byte *buffer_out, const byte *buffer_in)
+{
+ serpent_context_t *context = ctx;
+
+ serpent_encrypt_internal (context, buffer_in, buffer_out);
+ _gcry_burn_stack (2 * sizeof (serpent_block_t));
+}
+
+static void
+serpent_decrypt (void *ctx, byte *buffer_out, const byte *buffer_in)
+{
+ serpent_context_t *context = ctx;
+
+ serpent_decrypt_internal (context, buffer_in, buffer_out);
+ _gcry_burn_stack (2 * sizeof (serpent_block_t));
+}
+
+
+
+/* Serpent test. */
+
+static const char *
+serpent_test (void)
+{
+ serpent_context_t context;
+ unsigned char scratch[16];
+ unsigned int i;
+
+ static struct test
+ {
+ int key_length;
+ unsigned char key[32];
+ unsigned char text_plain[16];
+ unsigned char text_cipher[16];
+ } test_data[] =
+ {
+ {
+ 16,
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ "\xD2\x9D\x57\x6F\xCE\xA3\xA3\xA7\xED\x90\x99\xF2\x92\x73\xD7\x8E",
+ "\xB2\x28\x8B\x96\x8A\xE8\xB0\x86\x48\xD1\xCE\x96\x06\xFD\x99\x2D"
+ },
+ {
+ 24,
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ "\xD2\x9D\x57\x6F\xCE\xAB\xA3\xA7\xED\x98\x99\xF2\x92\x7B\xD7\x8E",
+ "\x13\x0E\x35\x3E\x10\x37\xC2\x24\x05\xE8\xFA\xEF\xB2\xC3\xC3\xE9"
+ },
+ {
+ 32,
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ "\xD0\x95\x57\x6F\xCE\xA3\xE3\xA7\xED\x98\xD9\xF2\x90\x73\xD7\x8E",
+ "\xB9\x0E\xE5\x86\x2D\xE6\x91\x68\xF2\xBD\xD5\x12\x5B\x45\x47\x2B"
+ },
+ {
+ 32,
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
+ "\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00",
+ "\x20\x61\xA4\x27\x82\xBD\x52\xEC\x69\x1E\xC3\x83\xB0\x3B\xA7\x7C"
+ },
+ {
+ 0
+ },
+ };
+
+ for (i = 0; test_data[i].key_length; i++)
+ {
+ serpent_setkey_internal (&context, test_data[i].key,
+ test_data[i].key_length);
+ serpent_encrypt_internal (&context, test_data[i].text_plain, scratch);
+
+ if (memcmp (scratch, test_data[i].text_cipher, sizeof (serpent_block_t)))
+ switch (test_data[i].key_length)
+ {
+ case 16:
+ return "Serpent-128 test encryption failed.";
+ case 24:
+ return "Serpent-192 test encryption failed.";
+ case 32:
+ return "Serpent-256 test encryption failed.";
+ }
+
+ serpent_decrypt_internal (&context, test_data[i].text_cipher, scratch);
+ if (memcmp (scratch, test_data[i].text_plain, sizeof (serpent_block_t)))
+ switch (test_data[i].key_length)
+ {
+ case 16:
+ return "Serpent-128 test decryption failed.";
+ case 24:
+ return "Serpent-192 test decryption failed.";
+ case 32:
+ return "Serpent-256 test decryption failed.";
+ }
+ }
+
+ return NULL;
+}
+
+
+
+/* "SERPENT" is an alias for "SERPENT128". */
+static const char *cipher_spec_serpent128_aliases[] =
+ {
+ "SERPENT",
+ NULL
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_serpent128 =
+ {
+ "SERPENT128", cipher_spec_serpent128_aliases, NULL, 16, 128,
+ sizeof (serpent_context_t),
+ serpent_setkey, serpent_encrypt, serpent_decrypt
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_serpent192 =
+ {
+ "SERPENT192", NULL, NULL, 16, 192,
+ sizeof (serpent_context_t),
+ serpent_setkey, serpent_encrypt, serpent_decrypt
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_serpent256 =
+ {
+ "SERPENT256", NULL, NULL, 16, 256,
+ sizeof (serpent_context_t),
+ serpent_setkey, serpent_encrypt, serpent_decrypt
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/sha1.c b/grub-core/lib/libgcrypt/cipher/sha1.c
new file mode 100644
index 0000000..4b784ac
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/sha1.c
@@ -0,0 +1,477 @@
+/* sha1.c - SHA1 hash function
+ * Copyright (C) 1998, 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/* Test vectors:
+ *
+ * "abc"
+ * A999 3E36 4706 816A BA3E 2571 7850 C26C 9CD0 D89D
+ *
+ * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ * 8498 3E44 1C3B D26E BAAE 4AA1 F951 29E5 E546 70F1
+ */
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+#include "g10lib.h"
+#include "bithelp.h"
+#include "cipher.h"
+#include "hash-common.h"
+
+
+/* A macro to test whether P is properly aligned for an u32 type.
+ Note that config.h provides a suitable replacement for uintptr_t if
+ it does not exist in stdint.h. */
+/* #if __GNUC__ >= 2 */
+/* # define U32_ALIGNED_P(p) (!(((uintptr_t)p) % __alignof__ (u32))) */
+/* #else */
+/* # define U32_ALIGNED_P(p) (!(((uintptr_t)p) % sizeof (u32))) */
+/* #endif */
+
+#define TRANSFORM(x,d,n) transform ((x), (d), (n))
+
+
+typedef struct
+{
+ u32 h0,h1,h2,h3,h4;
+ u32 nblocks;
+ unsigned char buf[64];
+ int count;
+} SHA1_CONTEXT;
+
+
+
+static void
+sha1_init (void *context)
+{
+ SHA1_CONTEXT *hd = context;
+
+ hd->h0 = 0x67452301;
+ hd->h1 = 0xefcdab89;
+ hd->h2 = 0x98badcfe;
+ hd->h3 = 0x10325476;
+ hd->h4 = 0xc3d2e1f0;
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+
+/* Round function macros. */
+#define K1 0x5A827999L
+#define K2 0x6ED9EBA1L
+#define K3 0x8F1BBCDCL
+#define K4 0xCA62C1D6L
+#define F1(x,y,z) ( z ^ ( x & ( y ^ z ) ) )
+#define F2(x,y,z) ( x ^ y ^ z )
+#define F3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) )
+#define F4(x,y,z) ( x ^ y ^ z )
+#define M(i) ( tm = x[ i &0x0f] \
+ ^ x[(i-14)&0x0f] \
+ ^ x[(i-8) &0x0f] \
+ ^ x[(i-3) &0x0f], \
+ (x[i&0x0f] = rol(tm, 1)))
+#define R(a,b,c,d,e,f,k,m) do { e += rol( a, 5 ) \
+ + f( b, c, d ) \
+ + k \
+ + m; \
+ b = rol( b, 30 ); \
+ } while(0)
+
+
+/*
+ * Transform NBLOCKS of each 64 bytes (16 32-bit words) at DATA.
+ */
+static void
+transform (SHA1_CONTEXT *hd, const unsigned char *data, size_t nblocks)
+{
+ register u32 a, b, c, d, e; /* Local copies of the chaining variables. */
+ register u32 tm; /* Helper. */
+ u32 x[16]; /* The array we work on. */
+
+ /* Loop over all blocks. */
+ for ( ;nblocks; nblocks--)
+ {
+#ifdef WORDS_BIGENDIAN
+ memcpy (x, data, 64);
+ data += 64;
+#else
+ {
+ int i;
+ unsigned char *p;
+
+ for(i=0, p=(unsigned char*)x; i < 16; i++, p += 4 )
+ {
+ p[3] = *data++;
+ p[2] = *data++;
+ p[1] = *data++;
+ p[0] = *data++;
+ }
+ }
+#endif
+ /* Get the values of the chaining variables. */
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+
+ /* Transform. */
+ R( a, b, c, d, e, F1, K1, x[ 0] );
+ R( e, a, b, c, d, F1, K1, x[ 1] );
+ R( d, e, a, b, c, F1, K1, x[ 2] );
+ R( c, d, e, a, b, F1, K1, x[ 3] );
+ R( b, c, d, e, a, F1, K1, x[ 4] );
+ R( a, b, c, d, e, F1, K1, x[ 5] );
+ R( e, a, b, c, d, F1, K1, x[ 6] );
+ R( d, e, a, b, c, F1, K1, x[ 7] );
+ R( c, d, e, a, b, F1, K1, x[ 8] );
+ R( b, c, d, e, a, F1, K1, x[ 9] );
+ R( a, b, c, d, e, F1, K1, x[10] );
+ R( e, a, b, c, d, F1, K1, x[11] );
+ R( d, e, a, b, c, F1, K1, x[12] );
+ R( c, d, e, a, b, F1, K1, x[13] );
+ R( b, c, d, e, a, F1, K1, x[14] );
+ R( a, b, c, d, e, F1, K1, x[15] );
+ R( e, a, b, c, d, F1, K1, M(16) );
+ R( d, e, a, b, c, F1, K1, M(17) );
+ R( c, d, e, a, b, F1, K1, M(18) );
+ R( b, c, d, e, a, F1, K1, M(19) );
+ R( a, b, c, d, e, F2, K2, M(20) );
+ R( e, a, b, c, d, F2, K2, M(21) );
+ R( d, e, a, b, c, F2, K2, M(22) );
+ R( c, d, e, a, b, F2, K2, M(23) );
+ R( b, c, d, e, a, F2, K2, M(24) );
+ R( a, b, c, d, e, F2, K2, M(25) );
+ R( e, a, b, c, d, F2, K2, M(26) );
+ R( d, e, a, b, c, F2, K2, M(27) );
+ R( c, d, e, a, b, F2, K2, M(28) );
+ R( b, c, d, e, a, F2, K2, M(29) );
+ R( a, b, c, d, e, F2, K2, M(30) );
+ R( e, a, b, c, d, F2, K2, M(31) );
+ R( d, e, a, b, c, F2, K2, M(32) );
+ R( c, d, e, a, b, F2, K2, M(33) );
+ R( b, c, d, e, a, F2, K2, M(34) );
+ R( a, b, c, d, e, F2, K2, M(35) );
+ R( e, a, b, c, d, F2, K2, M(36) );
+ R( d, e, a, b, c, F2, K2, M(37) );
+ R( c, d, e, a, b, F2, K2, M(38) );
+ R( b, c, d, e, a, F2, K2, M(39) );
+ R( a, b, c, d, e, F3, K3, M(40) );
+ R( e, a, b, c, d, F3, K3, M(41) );
+ R( d, e, a, b, c, F3, K3, M(42) );
+ R( c, d, e, a, b, F3, K3, M(43) );
+ R( b, c, d, e, a, F3, K3, M(44) );
+ R( a, b, c, d, e, F3, K3, M(45) );
+ R( e, a, b, c, d, F3, K3, M(46) );
+ R( d, e, a, b, c, F3, K3, M(47) );
+ R( c, d, e, a, b, F3, K3, M(48) );
+ R( b, c, d, e, a, F3, K3, M(49) );
+ R( a, b, c, d, e, F3, K3, M(50) );
+ R( e, a, b, c, d, F3, K3, M(51) );
+ R( d, e, a, b, c, F3, K3, M(52) );
+ R( c, d, e, a, b, F3, K3, M(53) );
+ R( b, c, d, e, a, F3, K3, M(54) );
+ R( a, b, c, d, e, F3, K3, M(55) );
+ R( e, a, b, c, d, F3, K3, M(56) );
+ R( d, e, a, b, c, F3, K3, M(57) );
+ R( c, d, e, a, b, F3, K3, M(58) );
+ R( b, c, d, e, a, F3, K3, M(59) );
+ R( a, b, c, d, e, F4, K4, M(60) );
+ R( e, a, b, c, d, F4, K4, M(61) );
+ R( d, e, a, b, c, F4, K4, M(62) );
+ R( c, d, e, a, b, F4, K4, M(63) );
+ R( b, c, d, e, a, F4, K4, M(64) );
+ R( a, b, c, d, e, F4, K4, M(65) );
+ R( e, a, b, c, d, F4, K4, M(66) );
+ R( d, e, a, b, c, F4, K4, M(67) );
+ R( c, d, e, a, b, F4, K4, M(68) );
+ R( b, c, d, e, a, F4, K4, M(69) );
+ R( a, b, c, d, e, F4, K4, M(70) );
+ R( e, a, b, c, d, F4, K4, M(71) );
+ R( d, e, a, b, c, F4, K4, M(72) );
+ R( c, d, e, a, b, F4, K4, M(73) );
+ R( b, c, d, e, a, F4, K4, M(74) );
+ R( a, b, c, d, e, F4, K4, M(75) );
+ R( e, a, b, c, d, F4, K4, M(76) );
+ R( d, e, a, b, c, F4, K4, M(77) );
+ R( c, d, e, a, b, F4, K4, M(78) );
+ R( b, c, d, e, a, F4, K4, M(79) );
+
+ /* Update the chaining variables. */
+ hd->h0 += a;
+ hd->h1 += b;
+ hd->h2 += c;
+ hd->h3 += d;
+ hd->h4 += e;
+ }
+}
+
+
+/* Update the message digest with the contents
+ * of INBUF with length INLEN.
+ */
+static void
+sha1_write( void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ SHA1_CONTEXT *hd = context;
+ size_t nblocks;
+
+ if (hd->count == 64) /* Flush the buffer. */
+ {
+ TRANSFORM( hd, hd->buf, 1 );
+ _gcry_burn_stack (88+4*sizeof(void*));
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if (!inbuf)
+ return;
+
+ if (hd->count)
+ {
+ for (; inlen && hd->count < 64; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+ sha1_write (hd, NULL, 0);
+ if (!inlen)
+ return;
+ }
+
+ nblocks = inlen / 64;
+ if (nblocks)
+ {
+ TRANSFORM (hd, inbuf, nblocks);
+ hd->count = 0;
+ hd->nblocks += nblocks;
+ inlen -= nblocks * 64;
+ inbuf += nblocks * 64;
+ }
+ _gcry_burn_stack (88+4*sizeof(void*));
+
+ /* Save remaining bytes. */
+ for (; inlen && hd->count < 64; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+/* The routine final terminates the computation and
+ * returns the digest.
+ * The handle is prepared for a new cycle, but adding bytes to the
+ * handle will the destroy the returned buffer.
+ * Returns: 20 bytes representing the digest.
+ */
+
+static void
+sha1_final(void *context)
+{
+ SHA1_CONTEXT *hd = context;
+
+ u32 t, msb, lsb;
+ unsigned char *p;
+
+ sha1_write(hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if( (lsb += hd->count) < t )
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if( hd->count < 56 ) /* enough room */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while( hd->count < 56 )
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else /* need one extra block */
+ {
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while( hd->count < 64 )
+ hd->buf[hd->count++] = 0;
+ sha1_write(hd, NULL, 0); /* flush */;
+ memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = msb >> 24;
+ hd->buf[57] = msb >> 16;
+ hd->buf[58] = msb >> 8;
+ hd->buf[59] = msb ;
+ hd->buf[60] = lsb >> 24;
+ hd->buf[61] = lsb >> 16;
+ hd->buf[62] = lsb >> 8;
+ hd->buf[63] = lsb ;
+ TRANSFORM( hd, hd->buf, 1 );
+ _gcry_burn_stack (88+4*sizeof(void*));
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
+#else /* little endian */
+#define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \
+ *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0)
+#endif
+ X(0);
+ X(1);
+ X(2);
+ X(3);
+ X(4);
+#undef X
+
+}
+
+static unsigned char *
+sha1_read( void *context )
+{
+ SHA1_CONTEXT *hd = context;
+
+ return hd->buf;
+}
+
+/****************
+ * Shortcut functions which puts the hash value of the supplied buffer
+ * into outbuf which must have a size of 20 bytes.
+ */
+void
+_gcry_sha1_hash_buffer (void *outbuf, const void *buffer, size_t length)
+{
+ SHA1_CONTEXT hd;
+
+ sha1_init (&hd);
+ sha1_write (&hd, buffer, length);
+ sha1_final (&hd);
+ memcpy (outbuf, hd.buf, 20);
+}
+
+
+
+/*
+ Self-test section.
+ */
+
+
+static gpg_err_code_t
+selftests_sha1 (int extended, selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+
+ what = "short string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA1, 0,
+ "abc", 3,
+ "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E"
+ "\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D", 20);
+ if (errtxt)
+ goto failed;
+
+ if (extended)
+ {
+ what = "long string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA1, 0,
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56,
+ "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE"
+ "\x4A\xA1\xF9\x51\x29\xE5\xE5\x46\x70\xF1", 20);
+ if (errtxt)
+ goto failed;
+
+ what = "one million \"a\"";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA1, 1,
+ NULL, 0,
+ "\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E"
+ "\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F", 20);
+ if (errtxt)
+ goto failed;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("digest", GCRY_MD_SHA1, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+static gpg_err_code_t
+run_selftests (int algo, int extended, selftest_report_func_t report)
+{
+ gpg_err_code_t ec;
+
+ switch (algo)
+ {
+ case GCRY_MD_SHA1:
+ ec = selftests_sha1 (extended, report);
+ break;
+ default:
+ ec = GPG_ERR_DIGEST_ALGO;
+ break;
+
+ }
+ return ec;
+}
+
+
+
+
+static unsigned char asn[15] = /* Object ID is 1.3.14.3.2.26 */
+ { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03,
+ 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 };
+
+static gcry_md_oid_spec_t oid_spec_sha1[] =
+ {
+ /* iso.member-body.us.rsadsi.pkcs.pkcs-1.5 (sha1WithRSAEncryption) */
+ { "1.2.840.113549.1.1.5" },
+ /* iso.member-body.us.x9-57.x9cm.3 (dsaWithSha1)*/
+ { "1.2.840.10040.4.3" },
+ /* from NIST's OIW (sha1) */
+ { "1.3.14.3.2.26" },
+ /* from NIST OIW (sha-1WithRSAEncryption) */
+ { "1.3.14.3.2.29" },
+ /* iso.member-body.us.ansi-x9-62.signatures.ecdsa-with-sha1 */
+ { "1.2.840.10045.4.1" },
+ { NULL },
+ };
+
+gcry_md_spec_t _gcry_digest_spec_sha1 =
+ {
+ "SHA1", asn, DIM (asn), oid_spec_sha1, 20,
+ sha1_init, sha1_write, sha1_final, sha1_read,
+ sizeof (SHA1_CONTEXT)
+ };
+md_extra_spec_t _gcry_digest_extraspec_sha1 =
+ {
+ run_selftests
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/sha256.c b/grub-core/lib/libgcrypt/cipher/sha256.c
new file mode 100644
index 0000000..309fa3b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/sha256.c
@@ -0,0 +1,554 @@
+/* sha256.c - SHA256 hash function
+ * Copyright (C) 2003, 2006, 2008, 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/* Test vectors:
+
+ "abc"
+ SHA224: 23097d22 3405d822 8642a477 bda255b3 2aadbce4 bda0b3f7 e36c9da7
+ SHA256: ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad
+
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ SHA224: 75388b16 512776cc 5dba5da1 fd890150 b0c6455c b4f58b19 52522525
+ SHA256: 248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1
+
+ "a" one million times
+ SHA224: 20794655 980c91d8 bbb4c1ea 97618a4b f03f4258 1948b2ee 4ee7ad67
+ SHA256: cdc76e5c 9914fb92 81a1c7e2 84d73e67 f1809a48 a497200e 046d39cc c7112cd0
+
+ */
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "g10lib.h"
+#include "bithelp.h"
+#include "cipher.h"
+#include "hash-common.h"
+
+typedef struct {
+ u32 h0,h1,h2,h3,h4,h5,h6,h7;
+ u32 nblocks;
+ byte buf[64];
+ int count;
+} SHA256_CONTEXT;
+
+
+static void
+sha256_init (void *context)
+{
+ SHA256_CONTEXT *hd = context;
+
+ hd->h0 = 0x6a09e667;
+ hd->h1 = 0xbb67ae85;
+ hd->h2 = 0x3c6ef372;
+ hd->h3 = 0xa54ff53a;
+ hd->h4 = 0x510e527f;
+ hd->h5 = 0x9b05688c;
+ hd->h6 = 0x1f83d9ab;
+ hd->h7 = 0x5be0cd19;
+
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+
+static void
+sha224_init (void *context)
+{
+ SHA256_CONTEXT *hd = context;
+
+ hd->h0 = 0xc1059ed8;
+ hd->h1 = 0x367cd507;
+ hd->h2 = 0x3070dd17;
+ hd->h3 = 0xf70e5939;
+ hd->h4 = 0xffc00b31;
+ hd->h5 = 0x68581511;
+ hd->h6 = 0x64f98fa7;
+ hd->h7 = 0xbefa4fa4;
+
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+
+/*
+ Transform the message X which consists of 16 32-bit-words. See FIPS
+ 180-2 for details. */
+#define S0(x) (ror ((x), 7) ^ ror ((x), 18) ^ ((x) >> 3)) /* (4.6) */
+#define S1(x) (ror ((x), 17) ^ ror ((x), 19) ^ ((x) >> 10)) /* (4.7) */
+#define R(a,b,c,d,e,f,g,h,k,w) do \
+ { \
+ t1 = (h) + Sum1((e)) + Cho((e),(f),(g)) + (k) + (w); \
+ t2 = Sum0((a)) + Maj((a),(b),(c)); \
+ h = g; \
+ g = f; \
+ f = e; \
+ e = d + t1; \
+ d = c; \
+ c = b; \
+ b = a; \
+ a = t1 + t2; \
+ } while (0)
+
+/* (4.2) same as SHA-1's F1. */
+static inline u32
+Cho (u32 x, u32 y, u32 z)
+{
+ return (z ^ (x & (y ^ z)));
+}
+
+/* (4.3) same as SHA-1's F3 */
+static inline u32
+Maj (u32 x, u32 y, u32 z)
+{
+ return ((x & y) | (z & (x|y)));
+}
+
+/* (4.4) */
+static inline u32
+Sum0 (u32 x)
+{
+ return (ror (x, 2) ^ ror (x, 13) ^ ror (x, 22));
+}
+
+/* (4.5) */
+static inline u32
+Sum1 (u32 x)
+{
+ return (ror (x, 6) ^ ror (x, 11) ^ ror (x, 25));
+}
+
+
+static void
+transform (SHA256_CONTEXT *hd, const unsigned char *data)
+{
+ static const u32 K[64] = {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+ };
+
+ u32 a,b,c,d,e,f,g,h,t1,t2;
+ u32 x[16];
+ u32 w[64];
+ int i;
+
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+ f = hd->h5;
+ g = hd->h6;
+ h = hd->h7;
+
+#ifdef WORDS_BIGENDIAN
+ memcpy (x, data, 64);
+#else
+ {
+ byte *p2;
+
+ for (i=0, p2=(byte*)x; i < 16; i++, p2 += 4 )
+ {
+ p2[3] = *data++;
+ p2[2] = *data++;
+ p2[1] = *data++;
+ p2[0] = *data++;
+ }
+ }
+#endif
+
+ for (i=0; i < 16; i++)
+ w[i] = x[i];
+ for (; i < 64; i++)
+ w[i] = S1(w[i-2]) + w[i-7] + S0(w[i-15]) + w[i-16];
+
+ for (i=0; i < 64;)
+ {
+#if 0
+ R(a,b,c,d,e,f,g,h,K[i],w[i]);
+ i++;
+#else
+ t1 = h + Sum1 (e) + Cho (e, f, g) + K[i] + w[i];
+ t2 = Sum0 (a) + Maj (a, b, c);
+ d += t1;
+ h = t1 + t2;
+
+ t1 = g + Sum1 (d) + Cho (d, e, f) + K[i+1] + w[i+1];
+ t2 = Sum0 (h) + Maj (h, a, b);
+ c += t1;
+ g = t1 + t2;
+
+ t1 = f + Sum1 (c) + Cho (c, d, e) + K[i+2] + w[i+2];
+ t2 = Sum0 (g) + Maj (g, h, a);
+ b += t1;
+ f = t1 + t2;
+
+ t1 = e + Sum1 (b) + Cho (b, c, d) + K[i+3] + w[i+3];
+ t2 = Sum0 (f) + Maj (f, g, h);
+ a += t1;
+ e = t1 + t2;
+
+ t1 = d + Sum1 (a) + Cho (a, b, c) + K[i+4] + w[i+4];
+ t2 = Sum0 (e) + Maj (e, f, g);
+ h += t1;
+ d = t1 + t2;
+
+ t1 = c + Sum1 (h) + Cho (h, a, b) + K[i+5] + w[i+5];
+ t2 = Sum0 (d) + Maj (d, e, f);
+ g += t1;
+ c = t1 + t2;
+
+ t1 = b + Sum1 (g) + Cho (g, h, a) + K[i+6] + w[i+6];
+ t2 = Sum0 (c) + Maj (c, d, e);
+ f += t1;
+ b = t1 + t2;
+
+ t1 = a + Sum1 (f) + Cho (f, g, h) + K[i+7] + w[i+7];
+ t2 = Sum0 (b) + Maj (b, c, d);
+ e += t1;
+ a = t1 + t2;
+
+ i += 8;
+#endif
+ }
+
+ hd->h0 += a;
+ hd->h1 += b;
+ hd->h2 += c;
+ hd->h3 += d;
+ hd->h4 += e;
+ hd->h5 += f;
+ hd->h6 += g;
+ hd->h7 += h;
+}
+#undef S0
+#undef S1
+#undef R
+
+
+/* Update the message digest with the contents of INBUF with length
+ INLEN. */
+static void
+sha256_write (void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ SHA256_CONTEXT *hd = context;
+
+ if (hd->count == 64)
+ { /* flush the buffer */
+ transform (hd, hd->buf);
+ _gcry_burn_stack (74*4+32);
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if (!inbuf)
+ return;
+ if (hd->count)
+ {
+ for (; inlen && hd->count < 64; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+ sha256_write (hd, NULL, 0);
+ if (!inlen)
+ return;
+ }
+
+ while (inlen >= 64)
+ {
+ transform (hd, inbuf);
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 64;
+ inbuf += 64;
+ }
+ _gcry_burn_stack (74*4+32);
+ for (; inlen && hd->count < 64; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+/*
+ The routine finally terminates the computation and returns the
+ digest. The handle is prepared for a new cycle, but adding bytes
+ to the handle will the destroy the returned buffer. Returns: 32
+ bytes with the message the digest. */
+static void
+sha256_final(void *context)
+{
+ SHA256_CONTEXT *hd = context;
+ u32 t, msb, lsb;
+ byte *p;
+
+ sha256_write (hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if ((lsb += hd->count) < t)
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if (hd->count < 56)
+ { /* enough room */
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while (hd->count < 56)
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else
+ { /* need one extra block */
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while (hd->count < 64)
+ hd->buf[hd->count++] = 0;
+ sha256_write (hd, NULL, 0); /* flush */;
+ memset (hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = msb >> 24;
+ hd->buf[57] = msb >> 16;
+ hd->buf[58] = msb >> 8;
+ hd->buf[59] = msb;
+ hd->buf[60] = lsb >> 24;
+ hd->buf[61] = lsb >> 16;
+ hd->buf[62] = lsb >> 8;
+ hd->buf[63] = lsb;
+ transform (hd, hd->buf);
+ _gcry_burn_stack (74*4+32);
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
+#else /* little endian */
+#define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \
+ *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0)
+#endif
+ X(0);
+ X(1);
+ X(2);
+ X(3);
+ X(4);
+ X(5);
+ X(6);
+ X(7);
+#undef X
+}
+
+static byte *
+sha256_read (void *context)
+{
+ SHA256_CONTEXT *hd = context;
+
+ return hd->buf;
+}
+
+
+
+/*
+ Self-test section.
+ */
+
+
+static gpg_err_code_t
+selftests_sha224 (int extended, selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+
+ what = "short string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA224, 0,
+ "abc", 3,
+ "\x23\x09\x7d\x22\x34\x05\xd8\x22\x86\x42\xa4\x77\xbd\xa2\x55\xb3"
+ "\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7\xe3\x6c\x9d\xa7", 28);
+ if (errtxt)
+ goto failed;
+
+ if (extended)
+ {
+ what = "long string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA224, 0,
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56,
+ "\x75\x38\x8b\x16\x51\x27\x76\xcc\x5d\xba\x5d\xa1\xfd\x89\x01\x50"
+ "\xb0\xc6\x45\x5c\xb4\xf5\x8b\x19\x52\x52\x25\x25", 28);
+ if (errtxt)
+ goto failed;
+
+ what = "one million \"a\"";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA224, 1,
+ NULL, 0,
+ "\x20\x79\x46\x55\x98\x0c\x91\xd8\xbb\xb4\xc1\xea\x97\x61\x8a\x4b"
+ "\xf0\x3f\x42\x58\x19\x48\xb2\xee\x4e\xe7\xad\x67", 28);
+ if (errtxt)
+ goto failed;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("digest", GCRY_MD_SHA224, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+static gpg_err_code_t
+selftests_sha256 (int extended, selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+
+ what = "short string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA256, 0,
+ "abc", 3,
+ "\xba\x78\x16\xbf\x8f\x01\xcf\xea\x41\x41\x40\xde\x5d\xae\x22\x23"
+ "\xb0\x03\x61\xa3\x96\x17\x7a\x9c\xb4\x10\xff\x61\xf2\x00\x15\xad", 32);
+ if (errtxt)
+ goto failed;
+
+ if (extended)
+ {
+ what = "long string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA256, 0,
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56,
+ "\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
+ "\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1",
+ 32);
+ if (errtxt)
+ goto failed;
+
+ what = "one million \"a\"";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA256, 1,
+ NULL, 0,
+ "\xcd\xc7\x6e\x5c\x99\x14\xfb\x92\x81\xa1\xc7\xe2\x84\xd7\x3e\x67"
+ "\xf1\x80\x9a\x48\xa4\x97\x20\x0e\x04\x6d\x39\xcc\xc7\x11\x2c\xd0",
+ 32);
+ if (errtxt)
+ goto failed;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("digest", GCRY_MD_SHA256, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+static gpg_err_code_t
+run_selftests (int algo, int extended, selftest_report_func_t report)
+{
+ gpg_err_code_t ec;
+
+ switch (algo)
+ {
+ case GCRY_MD_SHA224:
+ ec = selftests_sha224 (extended, report);
+ break;
+ case GCRY_MD_SHA256:
+ ec = selftests_sha256 (extended, report);
+ break;
+ default:
+ ec = GPG_ERR_DIGEST_ALGO;
+ break;
+
+ }
+ return ec;
+}
+
+
+
+
+static byte asn224[19] = /* Object ID is 2.16.840.1.101.3.4.2.4 */
+ { 0x30, 0x2D, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48,
+ 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04,
+ 0x1C
+ };
+
+static gcry_md_oid_spec_t oid_spec_sha224[] =
+ {
+ /* From RFC3874, Section 4 */
+ { "2.16.840.1.101.3.4.2.4" },
+ { NULL },
+ };
+
+static byte asn256[19] = /* Object ID is 2.16.840.1.101.3.4.2.1 */
+ { 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
+ 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
+ 0x00, 0x04, 0x20 };
+
+static gcry_md_oid_spec_t oid_spec_sha256[] =
+ {
+ /* According to the OpenPGP draft rfc2440-bis06 */
+ { "2.16.840.1.101.3.4.2.1" },
+ /* PKCS#1 sha256WithRSAEncryption */
+ { "1.2.840.113549.1.1.11" },
+
+ { NULL },
+ };
+
+gcry_md_spec_t _gcry_digest_spec_sha224 =
+ {
+ "SHA224", asn224, DIM (asn224), oid_spec_sha224, 28,
+ sha224_init, sha256_write, sha256_final, sha256_read,
+ sizeof (SHA256_CONTEXT)
+ };
+md_extra_spec_t _gcry_digest_extraspec_sha224 =
+ {
+ run_selftests
+ };
+
+gcry_md_spec_t _gcry_digest_spec_sha256 =
+ {
+ "SHA256", asn256, DIM (asn256), oid_spec_sha256, 32,
+ sha256_init, sha256_write, sha256_final, sha256_read,
+ sizeof (SHA256_CONTEXT)
+ };
+md_extra_spec_t _gcry_digest_extraspec_sha256 =
+ {
+ run_selftests
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/sha512.c b/grub-core/lib/libgcrypt/cipher/sha512.c
new file mode 100644
index 0000000..2163e60
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/sha512.c
@@ -0,0 +1,629 @@
+/* sha512.c - SHA384 and SHA512 hash functions
+ * Copyright (C) 2003, 2008, 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/* Test vectors from FIPS-180-2:
+ *
+ * "abc"
+ * 384:
+ * CB00753F 45A35E8B B5A03D69 9AC65007 272C32AB 0EDED163
+ * 1A8B605A 43FF5BED 8086072B A1E7CC23 58BAECA1 34C825A7
+ * 512:
+ * DDAF35A1 93617ABA CC417349 AE204131 12E6FA4E 89A97EA2 0A9EEEE6 4B55D39A
+ * 2192992A 274FC1A8 36BA3C23 A3FEEBBD 454D4423 643CE80E 2A9AC94F A54CA49F
+ *
+ * "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
+ * 384:
+ * 09330C33 F71147E8 3D192FC7 82CD1B47 53111B17 3B3B05D2
+ * 2FA08086 E3B0F712 FCC7C71A 557E2DB9 66C3E9FA 91746039
+ * 512:
+ * 8E959B75 DAE313DA 8CF4F728 14FC143F 8F7779C6 EB9F7FA1 7299AEAD B6889018
+ * 501D289E 4900F7E4 331B99DE C4B5433A C7D329EE B6DD2654 5E96E55B 874BE909
+ *
+ * "a" x 1000000
+ * 384:
+ * 9D0E1809 716474CB 086E834E 310A4A1C ED149E9C 00F24852
+ * 7972CEC5 704C2A5B 07B8B3DC 38ECC4EB AE97DDD8 7F3D8985
+ * 512:
+ * E718483D 0CE76964 4E2E42C7 BC15B463 8E1F98B1 3B204428 5632A803 AFA973EB
+ * DE0FF244 877EA60A 4CB0432C E577C31B EB009C5C 2C49AA2E 4EADB217 AD8CC09B
+ */
+
+
+#include <config.h>
+#include <string.h>
+#include "g10lib.h"
+#include "bithelp.h"
+#include "cipher.h"
+#include "hash-common.h"
+
+typedef struct
+{
+ u64 h0, h1, h2, h3, h4, h5, h6, h7;
+ u64 nblocks;
+ byte buf[128];
+ int count;
+} SHA512_CONTEXT;
+
+static void
+sha512_init (void *context)
+{
+ SHA512_CONTEXT *hd = context;
+
+ hd->h0 = U64_C(0x6a09e667f3bcc908);
+ hd->h1 = U64_C(0xbb67ae8584caa73b);
+ hd->h2 = U64_C(0x3c6ef372fe94f82b);
+ hd->h3 = U64_C(0xa54ff53a5f1d36f1);
+ hd->h4 = U64_C(0x510e527fade682d1);
+ hd->h5 = U64_C(0x9b05688c2b3e6c1f);
+ hd->h6 = U64_C(0x1f83d9abfb41bd6b);
+ hd->h7 = U64_C(0x5be0cd19137e2179);
+
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+static void
+sha384_init (void *context)
+{
+ SHA512_CONTEXT *hd = context;
+
+ hd->h0 = U64_C(0xcbbb9d5dc1059ed8);
+ hd->h1 = U64_C(0x629a292a367cd507);
+ hd->h2 = U64_C(0x9159015a3070dd17);
+ hd->h3 = U64_C(0x152fecd8f70e5939);
+ hd->h4 = U64_C(0x67332667ffc00b31);
+ hd->h5 = U64_C(0x8eb44a8768581511);
+ hd->h6 = U64_C(0xdb0c2e0d64f98fa7);
+ hd->h7 = U64_C(0x47b5481dbefa4fa4);
+
+ hd->nblocks = 0;
+ hd->count = 0;
+}
+
+
+static inline u64
+ROTR (u64 x, u64 n)
+{
+ return ((x >> n) | (x << (64 - n)));
+}
+
+static inline u64
+Ch (u64 x, u64 y, u64 z)
+{
+ return ((x & y) ^ ( ~x & z));
+}
+
+static inline u64
+Maj (u64 x, u64 y, u64 z)
+{
+ return ((x & y) ^ (x & z) ^ (y & z));
+}
+
+static inline u64
+Sum0 (u64 x)
+{
+ return (ROTR (x, 28) ^ ROTR (x, 34) ^ ROTR (x, 39));
+}
+
+static inline u64
+Sum1 (u64 x)
+{
+ return (ROTR (x, 14) ^ ROTR (x, 18) ^ ROTR (x, 41));
+}
+
+/****************
+ * Transform the message W which consists of 16 64-bit-words
+ */
+static void
+transform (SHA512_CONTEXT *hd, const unsigned char *data)
+{
+ u64 a, b, c, d, e, f, g, h;
+ u64 w[80];
+ int t;
+ static const u64 k[] =
+ {
+ U64_C(0x428a2f98d728ae22), U64_C(0x7137449123ef65cd),
+ U64_C(0xb5c0fbcfec4d3b2f), U64_C(0xe9b5dba58189dbbc),
+ U64_C(0x3956c25bf348b538), U64_C(0x59f111f1b605d019),
+ U64_C(0x923f82a4af194f9b), U64_C(0xab1c5ed5da6d8118),
+ U64_C(0xd807aa98a3030242), U64_C(0x12835b0145706fbe),
+ U64_C(0x243185be4ee4b28c), U64_C(0x550c7dc3d5ffb4e2),
+ U64_C(0x72be5d74f27b896f), U64_C(0x80deb1fe3b1696b1),
+ U64_C(0x9bdc06a725c71235), U64_C(0xc19bf174cf692694),
+ U64_C(0xe49b69c19ef14ad2), U64_C(0xefbe4786384f25e3),
+ U64_C(0x0fc19dc68b8cd5b5), U64_C(0x240ca1cc77ac9c65),
+ U64_C(0x2de92c6f592b0275), U64_C(0x4a7484aa6ea6e483),
+ U64_C(0x5cb0a9dcbd41fbd4), U64_C(0x76f988da831153b5),
+ U64_C(0x983e5152ee66dfab), U64_C(0xa831c66d2db43210),
+ U64_C(0xb00327c898fb213f), U64_C(0xbf597fc7beef0ee4),
+ U64_C(0xc6e00bf33da88fc2), U64_C(0xd5a79147930aa725),
+ U64_C(0x06ca6351e003826f), U64_C(0x142929670a0e6e70),
+ U64_C(0x27b70a8546d22ffc), U64_C(0x2e1b21385c26c926),
+ U64_C(0x4d2c6dfc5ac42aed), U64_C(0x53380d139d95b3df),
+ U64_C(0x650a73548baf63de), U64_C(0x766a0abb3c77b2a8),
+ U64_C(0x81c2c92e47edaee6), U64_C(0x92722c851482353b),
+ U64_C(0xa2bfe8a14cf10364), U64_C(0xa81a664bbc423001),
+ U64_C(0xc24b8b70d0f89791), U64_C(0xc76c51a30654be30),
+ U64_C(0xd192e819d6ef5218), U64_C(0xd69906245565a910),
+ U64_C(0xf40e35855771202a), U64_C(0x106aa07032bbd1b8),
+ U64_C(0x19a4c116b8d2d0c8), U64_C(0x1e376c085141ab53),
+ U64_C(0x2748774cdf8eeb99), U64_C(0x34b0bcb5e19b48a8),
+ U64_C(0x391c0cb3c5c95a63), U64_C(0x4ed8aa4ae3418acb),
+ U64_C(0x5b9cca4f7763e373), U64_C(0x682e6ff3d6b2b8a3),
+ U64_C(0x748f82ee5defb2fc), U64_C(0x78a5636f43172f60),
+ U64_C(0x84c87814a1f0ab72), U64_C(0x8cc702081a6439ec),
+ U64_C(0x90befffa23631e28), U64_C(0xa4506cebde82bde9),
+ U64_C(0xbef9a3f7b2c67915), U64_C(0xc67178f2e372532b),
+ U64_C(0xca273eceea26619c), U64_C(0xd186b8c721c0c207),
+ U64_C(0xeada7dd6cde0eb1e), U64_C(0xf57d4f7fee6ed178),
+ U64_C(0x06f067aa72176fba), U64_C(0x0a637dc5a2c898a6),
+ U64_C(0x113f9804bef90dae), U64_C(0x1b710b35131c471b),
+ U64_C(0x28db77f523047d84), U64_C(0x32caab7b40c72493),
+ U64_C(0x3c9ebe0a15c9bebc), U64_C(0x431d67c49c100d4c),
+ U64_C(0x4cc5d4becb3e42b6), U64_C(0x597f299cfc657e2a),
+ U64_C(0x5fcb6fab3ad6faec), U64_C(0x6c44198c4a475817)
+ };
+
+ /* get values from the chaining vars */
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+ f = hd->h5;
+ g = hd->h6;
+ h = hd->h7;
+
+#ifdef WORDS_BIGENDIAN
+ memcpy (w, data, 128);
+#else
+ {
+ int i;
+ byte *p2;
+
+ for (i = 0, p2 = (byte *) w; i < 16; i++, p2 += 8)
+ {
+ p2[7] = *data++;
+ p2[6] = *data++;
+ p2[5] = *data++;
+ p2[4] = *data++;
+ p2[3] = *data++;
+ p2[2] = *data++;
+ p2[1] = *data++;
+ p2[0] = *data++;
+ }
+ }
+#endif
+
+#define S0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7))
+#define S1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6))
+
+ for (t = 16; t < 80; t++)
+ w[t] = S1 (w[t - 2]) + w[t - 7] + S0 (w[t - 15]) + w[t - 16];
+
+
+ for (t = 0; t < 80; )
+ {
+ u64 t1, t2;
+
+ /* Performance on a AMD Athlon(tm) Dual Core Processor 4050e
+ with gcc 4.3.3 using gcry_md_hash_buffer of each 10000 bytes
+ initialized to 0,1,2,3...255,0,... and 1000 iterations:
+
+ Not unrolled with macros: 440ms
+ Unrolled with macros: 350ms
+ Unrolled with inline: 330ms
+ */
+#if 0 /* Not unrolled. */
+ t1 = h + Sum1 (e) + Ch (e, f, g) + k[t] + w[t];
+ t2 = Sum0 (a) + Maj (a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + t1;
+ d = c;
+ c = b;
+ b = a;
+ a = t1 + t2;
+ t++;
+#else /* Unrolled to interweave the chain variables. */
+ t1 = h + Sum1 (e) + Ch (e, f, g) + k[t] + w[t];
+ t2 = Sum0 (a) + Maj (a, b, c);
+ d += t1;
+ h = t1 + t2;
+
+ t1 = g + Sum1 (d) + Ch (d, e, f) + k[t+1] + w[t+1];
+ t2 = Sum0 (h) + Maj (h, a, b);
+ c += t1;
+ g = t1 + t2;
+
+ t1 = f + Sum1 (c) + Ch (c, d, e) + k[t+2] + w[t+2];
+ t2 = Sum0 (g) + Maj (g, h, a);
+ b += t1;
+ f = t1 + t2;
+
+ t1 = e + Sum1 (b) + Ch (b, c, d) + k[t+3] + w[t+3];
+ t2 = Sum0 (f) + Maj (f, g, h);
+ a += t1;
+ e = t1 + t2;
+
+ t1 = d + Sum1 (a) + Ch (a, b, c) + k[t+4] + w[t+4];
+ t2 = Sum0 (e) + Maj (e, f, g);
+ h += t1;
+ d = t1 + t2;
+
+ t1 = c + Sum1 (h) + Ch (h, a, b) + k[t+5] + w[t+5];
+ t2 = Sum0 (d) + Maj (d, e, f);
+ g += t1;
+ c = t1 + t2;
+
+ t1 = b + Sum1 (g) + Ch (g, h, a) + k[t+6] + w[t+6];
+ t2 = Sum0 (c) + Maj (c, d, e);
+ f += t1;
+ b = t1 + t2;
+
+ t1 = a + Sum1 (f) + Ch (f, g, h) + k[t+7] + w[t+7];
+ t2 = Sum0 (b) + Maj (b, c, d);
+ e += t1;
+ a = t1 + t2;
+
+ t += 8;
+#endif
+ }
+
+ /* Update chaining vars. */
+ hd->h0 += a;
+ hd->h1 += b;
+ hd->h2 += c;
+ hd->h3 += d;
+ hd->h4 += e;
+ hd->h5 += f;
+ hd->h6 += g;
+ hd->h7 += h;
+}
+
+
+/* Update the message digest with the contents
+ * of INBUF with length INLEN.
+ */
+static void
+sha512_write (void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ SHA512_CONTEXT *hd = context;
+
+ if (hd->count == 128)
+ { /* flush the buffer */
+ transform (hd, hd->buf);
+ _gcry_burn_stack (768);
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if (!inbuf)
+ return;
+ if (hd->count)
+ {
+ for (; inlen && hd->count < 128; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+ sha512_write (context, NULL, 0);
+ if (!inlen)
+ return;
+ }
+
+ while (inlen >= 128)
+ {
+ transform (hd, inbuf);
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 128;
+ inbuf += 128;
+ }
+ _gcry_burn_stack (768);
+ for (; inlen && hd->count < 128; inlen--)
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+/* The routine final terminates the computation and
+ * returns the digest.
+ * The handle is prepared for a new cycle, but adding bytes to the
+ * handle will the destroy the returned buffer.
+ * Returns: 64 bytes representing the digest. When used for sha384,
+ * we take the leftmost 48 of those bytes.
+ */
+
+static void
+sha512_final (void *context)
+{
+ SHA512_CONTEXT *hd = context;
+ u64 t, msb, lsb;
+ byte *p;
+
+ sha512_write (context, NULL, 0); /* flush */ ;
+
+ t = hd->nblocks;
+ /* multiply by 128 to make a byte count */
+ lsb = t << 7;
+ msb = t >> 57;
+ /* add the count */
+ t = lsb;
+ if ((lsb += hd->count) < t)
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 61;
+
+ if (hd->count < 112)
+ { /* enough room */
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while (hd->count < 112)
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else
+ { /* need one extra block */
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while (hd->count < 128)
+ hd->buf[hd->count++] = 0;
+ sha512_write (context, NULL, 0); /* flush */ ;
+ memset (hd->buf, 0, 112); /* fill next block with zeroes */
+ }
+ /* append the 128 bit count */
+ hd->buf[112] = msb >> 56;
+ hd->buf[113] = msb >> 48;
+ hd->buf[114] = msb >> 40;
+ hd->buf[115] = msb >> 32;
+ hd->buf[116] = msb >> 24;
+ hd->buf[117] = msb >> 16;
+ hd->buf[118] = msb >> 8;
+ hd->buf[119] = msb;
+
+ hd->buf[120] = lsb >> 56;
+ hd->buf[121] = lsb >> 48;
+ hd->buf[122] = lsb >> 40;
+ hd->buf[123] = lsb >> 32;
+ hd->buf[124] = lsb >> 24;
+ hd->buf[125] = lsb >> 16;
+ hd->buf[126] = lsb >> 8;
+ hd->buf[127] = lsb;
+ transform (hd, hd->buf);
+ _gcry_burn_stack (768);
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *(u64*)p = hd->h##a ; p += 8; } while (0)
+#else /* little endian */
+#define X(a) do { *p++ = hd->h##a >> 56; *p++ = hd->h##a >> 48; \
+ *p++ = hd->h##a >> 40; *p++ = hd->h##a >> 32; \
+ *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \
+ *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while (0)
+#endif
+ X (0);
+ X (1);
+ X (2);
+ X (3);
+ X (4);
+ X (5);
+ /* Note that these last two chunks are included even for SHA384.
+ We just ignore them. */
+ X (6);
+ X (7);
+#undef X
+}
+
+static byte *
+sha512_read (void *context)
+{
+ SHA512_CONTEXT *hd = (SHA512_CONTEXT *) context;
+ return hd->buf;
+}
+
+
+
+/*
+ Self-test section.
+ */
+
+
+static gpg_err_code_t
+selftests_sha384 (int extended, selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+
+ what = "short string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA384, 0,
+ "abc", 3,
+ "\xcb\x00\x75\x3f\x45\xa3\x5e\x8b\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
+ "\x27\x2c\x32\xab\x0e\xde\xd1\x63\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
+ "\x80\x86\x07\x2b\xa1\xe7\xcc\x23\x58\xba\xec\xa1\x34\xc8\x25\xa7", 48);
+ if (errtxt)
+ goto failed;
+
+ if (extended)
+ {
+ what = "long string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA384, 0,
+ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
+ "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 112,
+ "\x09\x33\x0C\x33\xF7\x11\x47\xE8\x3D\x19\x2F\xC7\x82\xCD\x1B\x47"
+ "\x53\x11\x1B\x17\x3B\x3B\x05\xD2\x2F\xA0\x80\x86\xE3\xB0\xF7\x12"
+ "\xFC\xC7\xC7\x1A\x55\x7E\x2D\xB9\x66\xC3\xE9\xFA\x91\x74\x60\x39",
+ 48);
+ if (errtxt)
+ goto failed;
+
+ what = "one million \"a\"";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA384, 1,
+ NULL, 0,
+ "\x9D\x0E\x18\x09\x71\x64\x74\xCB\x08\x6E\x83\x4E\x31\x0A\x4A\x1C"
+ "\xED\x14\x9E\x9C\x00\xF2\x48\x52\x79\x72\xCE\xC5\x70\x4C\x2A\x5B"
+ "\x07\xB8\xB3\xDC\x38\xEC\xC4\xEB\xAE\x97\xDD\xD8\x7F\x3D\x89\x85",
+ 48);
+ if (errtxt)
+ goto failed;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("digest", GCRY_MD_SHA384, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+static gpg_err_code_t
+selftests_sha512 (int extended, selftest_report_func_t report)
+{
+ const char *what;
+ const char *errtxt;
+
+ what = "short string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA512, 0,
+ "abc", 3,
+ "\xDD\xAF\x35\xA1\x93\x61\x7A\xBA\xCC\x41\x73\x49\xAE\x20\x41\x31"
+ "\x12\xE6\xFA\x4E\x89\xA9\x7E\xA2\x0A\x9E\xEE\xE6\x4B\x55\xD3\x9A"
+ "\x21\x92\x99\x2A\x27\x4F\xC1\xA8\x36\xBA\x3C\x23\xA3\xFE\xEB\xBD"
+ "\x45\x4D\x44\x23\x64\x3C\xE8\x0E\x2A\x9A\xC9\x4F\xA5\x4C\xA4\x9F", 64);
+ if (errtxt)
+ goto failed;
+
+ if (extended)
+ {
+ what = "long string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA512, 0,
+ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
+ "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 112,
+ "\x8E\x95\x9B\x75\xDA\xE3\x13\xDA\x8C\xF4\xF7\x28\x14\xFC\x14\x3F"
+ "\x8F\x77\x79\xC6\xEB\x9F\x7F\xA1\x72\x99\xAE\xAD\xB6\x88\x90\x18"
+ "\x50\x1D\x28\x9E\x49\x00\xF7\xE4\x33\x1B\x99\xDE\xC4\xB5\x43\x3A"
+ "\xC7\xD3\x29\xEE\xB6\xDD\x26\x54\x5E\x96\xE5\x5B\x87\x4B\xE9\x09",
+ 64);
+ if (errtxt)
+ goto failed;
+
+ what = "one million \"a\"";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA512, 1,
+ NULL, 0,
+ "\xE7\x18\x48\x3D\x0C\xE7\x69\x64\x4E\x2E\x42\xC7\xBC\x15\xB4\x63"
+ "\x8E\x1F\x98\xB1\x3B\x20\x44\x28\x56\x32\xA8\x03\xAF\xA9\x73\xEB"
+ "\xDE\x0F\xF2\x44\x87\x7E\xA6\x0A\x4C\xB0\x43\x2C\xE5\x77\xC3\x1B"
+ "\xEB\x00\x9C\x5C\x2C\x49\xAA\x2E\x4E\xAD\xB2\x17\xAD\x8C\xC0\x9B",
+ 64);
+ if (errtxt)
+ goto failed;
+ }
+
+ return 0; /* Succeeded. */
+
+ failed:
+ if (report)
+ report ("digest", GCRY_MD_SHA512, what, errtxt);
+ return GPG_ERR_SELFTEST_FAILED;
+}
+
+
+/* Run a full self-test for ALGO and return 0 on success. */
+static gpg_err_code_t
+run_selftests (int algo, int extended, selftest_report_func_t report)
+{
+ gpg_err_code_t ec;
+
+ switch (algo)
+ {
+ case GCRY_MD_SHA384:
+ ec = selftests_sha384 (extended, report);
+ break;
+ case GCRY_MD_SHA512:
+ ec = selftests_sha512 (extended, report);
+ break;
+ default:
+ ec = GPG_ERR_DIGEST_ALGO;
+ break;
+
+ }
+ return ec;
+}
+
+
+
+
+static byte sha512_asn[] = /* Object ID is 2.16.840.1.101.3.4.2.3 */
+ {
+ 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
+ 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
+ 0x00, 0x04, 0x40
+ };
+
+static gcry_md_oid_spec_t oid_spec_sha512[] =
+ {
+ { "2.16.840.1.101.3.4.2.3" },
+
+ /* PKCS#1 sha512WithRSAEncryption */
+ { "1.2.840.113549.1.1.13" },
+
+ { NULL }
+ };
+
+gcry_md_spec_t _gcry_digest_spec_sha512 =
+ {
+ "SHA512", sha512_asn, DIM (sha512_asn), oid_spec_sha512, 64,
+ sha512_init, sha512_write, sha512_final, sha512_read,
+ sizeof (SHA512_CONTEXT),
+ };
+md_extra_spec_t _gcry_digest_extraspec_sha512 =
+ {
+ run_selftests
+ };
+
+static byte sha384_asn[] = /* Object ID is 2.16.840.1.101.3.4.2.2 */
+ {
+ 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
+ 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
+ 0x00, 0x04, 0x30
+ };
+
+static gcry_md_oid_spec_t oid_spec_sha384[] =
+ {
+ { "2.16.840.1.101.3.4.2.2" },
+
+ /* PKCS#1 sha384WithRSAEncryption */
+ { "1.2.840.113549.1.1.12" },
+
+ { NULL },
+ };
+
+gcry_md_spec_t _gcry_digest_spec_sha384 =
+ {
+ "SHA384", sha384_asn, DIM (sha384_asn), oid_spec_sha384, 48,
+ sha384_init, sha512_write, sha512_final, sha512_read,
+ sizeof (SHA512_CONTEXT),
+ };
+md_extra_spec_t _gcry_digest_extraspec_sha384 =
+ {
+ run_selftests
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/test-getrusage.c b/grub-core/lib/libgcrypt/cipher/test-getrusage.c
new file mode 100644
index 0000000..479eaab
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/test-getrusage.c
@@ -0,0 +1,105 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/resource.h>
+
+int
+main (int argc, char **argv)
+{
+ struct rusage buf;
+
+ if (argc > 1)
+ {
+ system (argv[1]);
+
+ if (getrusage (RUSAGE_CHILDREN, &buf ))
+ {
+ perror ("getrusage");
+ return 1;
+ }
+ }
+ else
+ {
+ if (getrusage (RUSAGE_SELF, &buf ))
+ {
+ perror ("getrusage");
+ return 1;
+ }
+ }
+
+ printf ("ru_utime = %ld.%06ld\n",
+ buf.ru_utime.tv_sec, buf.ru_utime.tv_usec);
+ printf ("ru_stime = %ld.%06ld\n",
+ buf.ru_stime.tv_sec, buf.ru_stime.tv_usec);
+ printf ("ru_maxrss = %ld\n", buf.ru_maxrss );
+ printf ("ru_ixrss = %ld\n", buf.ru_ixrss );
+ printf ("ru_idrss = %ld\n", buf.ru_idrss );
+ printf ("ru_isrss = %ld\n", buf.ru_isrss );
+ printf ("ru_minflt = %ld\n", buf.ru_minflt );
+ printf ("ru_majflt = %ld\n", buf.ru_majflt );
+ printf ("ru_nswap = %ld\n", buf.ru_nswap );
+ printf ("ru_inblock = %ld\n", buf.ru_inblock );
+ printf ("ru_oublock = %ld\n", buf.ru_oublock );
+ printf ("ru_msgsnd = %ld\n", buf.ru_msgsnd );
+ printf ("ru_msgrcv = %ld\n", buf.ru_msgrcv );
+ printf ("ru_nsignals= %ld\n", buf.ru_nsignals );
+ printf ("ru_nvcsw = %ld\n", buf.ru_nvcsw );
+ printf ("ru_nivcsw = %ld\n", buf.ru_nivcsw );
+
+ fprintf (stderr, "ru_utime ru_stime ru_minflt ru_nccsw ru_nivcsw\n");
+ fprintf (stderr, "%ld.%06ld %ld.%06ld %5ld %5ld %5ld\n");
+
+
+ return 0;
+}
+
+
+/* Codesnippet for debugging in random.c. */
+#if 0
+static void
+collect_rusage_stats (struct rusage *rb)
+{
+ static int idx;
+ static struct rusage buf[100];
+
+ if (!rb)
+ {
+ int i;
+
+ fprintf (stderr, "ru_utime ru_stime ru_minflt ru_nvcsw ru_nivcsw\n");
+ for (i=0; i < idx; i++)
+ fprintf (stderr, "%ld.%06ld %ld.%06ld %5ld %5ld %5ld\n",
+ buf[i].ru_utime.tv_sec, buf[i].ru_utime.tv_usec,
+ buf[i].ru_stime.tv_sec, buf[i].ru_stime.tv_usec,
+ buf[i].ru_minflt,
+ buf[i].ru_nvcsw,
+ buf[i].ru_nivcsw);
+ }
+ else if (idx < DIM(buf))
+ {
+ buf[idx++] = *rb;
+ }
+}
+#endif
+/*
+ void
+ _gcry_random_dump_stats()
+ {
+@@ -233,8 +261,11 @@
+ rndstats.naddbytes, rndstats.addbytes,
+ rndstats.mixkey, rndstats.ngetbytes1, rndstats.getbytes1,
+ rndstats.ngetbytes2, rndstats.getbytes2 );
++
++ collect_rusage_stats (NULL);
+ }
+
+========
+
+ getrusage (RUSAGE_SELF, &buf );
++ collect_rusage_stats (&buf);
+ add_randomness( &buf, sizeof buf, 1 );
+ memset( &buf, 0, sizeof buf );
+ }
+
+*/
+
+
diff --git a/grub-core/lib/libgcrypt/cipher/tiger.c b/grub-core/lib/libgcrypt/cipher/tiger.c
new file mode 100644
index 0000000..d4ad514
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/tiger.c
@@ -0,0 +1,911 @@
+/* tiger.c - The TIGER hash function
+ * Copyright (C) 1998, 2001, 2002, 2003, 2010 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/* See http://www.cs.technion.ac.il/~biham/Reports/Tiger/ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "g10lib.h"
+#include "cipher.h"
+
+/* We really need a 64 bit type for this code. */
+#ifdef HAVE_U64_TYPEDEF
+
+typedef struct
+{
+ u64 a, b, c;
+ byte buf[64];
+ int count;
+ u32 nblocks;
+ int variant; /* 0 = old code, 1 = fixed code, 2 - TIGER2. */
+} TIGER_CONTEXT;
+
+
+/*********************************
+ * Okay, okay, this is not the fastest code - improvements are welcome.
+ *
+ */
+
+/* Some test vectors:
+ * "" 24F0130C63AC9332 16166E76B1BB925F F373DE2D49584E7A
+ * "abc" F258C1E88414AB2A 527AB541FFC5B8BF 935F7B951C132951
+ * "Tiger" 9F00F599072300DD 276ABB38C8EB6DEC 37790C116F9D2BDF
+ * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"
+ * 87FB2A9083851CF7 470D2CF810E6DF9E B586445034A5A386
+ * "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789"
+ * 467DB80863EBCE48 8DF1CD1261655DE9 57896565975F9197
+ * "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham"
+ * 0C410A042968868A 1671DA5A3FD29A72 5EC1E457D3CDB303
+ * "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proc"
+ * "eedings of Fast Software Encryption 3, Cambridge."
+ * EBF591D5AFA655CE 7F22894FF87F54AC 89C811B6B0DA3193
+ * "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proc"
+ * "eedings of Fast Software Encryption 3, Cambridge, 1996."
+ * 3D9AEB03D1BD1A63 57B2774DFD6D5B24 DD68151D503974FC
+ * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEF"
+ * "GHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"
+ * 00B83EB4E53440C5 76AC6AAEE0A74858 25FD15E70A59FFE4
+ */
+
+static u64 sbox1[256] = {
+ U64_C(0x02aab17cf7e90c5e) /* 0 */, U64_C(0xac424b03e243a8ec) /* 1 */,
+ U64_C(0x72cd5be30dd5fcd3) /* 2 */, U64_C(0x6d019b93f6f97f3a) /* 3 */,
+ U64_C(0xcd9978ffd21f9193) /* 4 */, U64_C(0x7573a1c9708029e2) /* 5 */,
+ U64_C(0xb164326b922a83c3) /* 6 */, U64_C(0x46883eee04915870) /* 7 */,
+ U64_C(0xeaace3057103ece6) /* 8 */, U64_C(0xc54169b808a3535c) /* 9 */,
+ U64_C(0x4ce754918ddec47c) /* 10 */, U64_C(0x0aa2f4dfdc0df40c) /* 11 */,
+ U64_C(0x10b76f18a74dbefa) /* 12 */, U64_C(0xc6ccb6235ad1ab6a) /* 13 */,
+ U64_C(0x13726121572fe2ff) /* 14 */, U64_C(0x1a488c6f199d921e) /* 15 */,
+ U64_C(0x4bc9f9f4da0007ca) /* 16 */, U64_C(0x26f5e6f6e85241c7) /* 17 */,
+ U64_C(0x859079dbea5947b6) /* 18 */, U64_C(0x4f1885c5c99e8c92) /* 19 */,
+ U64_C(0xd78e761ea96f864b) /* 20 */, U64_C(0x8e36428c52b5c17d) /* 21 */,
+ U64_C(0x69cf6827373063c1) /* 22 */, U64_C(0xb607c93d9bb4c56e) /* 23 */,
+ U64_C(0x7d820e760e76b5ea) /* 24 */, U64_C(0x645c9cc6f07fdc42) /* 25 */,
+ U64_C(0xbf38a078243342e0) /* 26 */, U64_C(0x5f6b343c9d2e7d04) /* 27 */,
+ U64_C(0xf2c28aeb600b0ec6) /* 28 */, U64_C(0x6c0ed85f7254bcac) /* 29 */,
+ U64_C(0x71592281a4db4fe5) /* 30 */, U64_C(0x1967fa69ce0fed9f) /* 31 */,
+ U64_C(0xfd5293f8b96545db) /* 32 */, U64_C(0xc879e9d7f2a7600b) /* 33 */,
+ U64_C(0x860248920193194e) /* 34 */, U64_C(0xa4f9533b2d9cc0b3) /* 35 */,
+ U64_C(0x9053836c15957613) /* 36 */, U64_C(0xdb6dcf8afc357bf1) /* 37 */,
+ U64_C(0x18beea7a7a370f57) /* 38 */, U64_C(0x037117ca50b99066) /* 39 */,
+ U64_C(0x6ab30a9774424a35) /* 40 */, U64_C(0xf4e92f02e325249b) /* 41 */,
+ U64_C(0x7739db07061ccae1) /* 42 */, U64_C(0xd8f3b49ceca42a05) /* 43 */,
+ U64_C(0xbd56be3f51382f73) /* 44 */, U64_C(0x45faed5843b0bb28) /* 45 */,
+ U64_C(0x1c813d5c11bf1f83) /* 46 */, U64_C(0x8af0e4b6d75fa169) /* 47 */,
+ U64_C(0x33ee18a487ad9999) /* 48 */, U64_C(0x3c26e8eab1c94410) /* 49 */,
+ U64_C(0xb510102bc0a822f9) /* 50 */, U64_C(0x141eef310ce6123b) /* 51 */,
+ U64_C(0xfc65b90059ddb154) /* 52 */, U64_C(0xe0158640c5e0e607) /* 53 */,
+ U64_C(0x884e079826c3a3cf) /* 54 */, U64_C(0x930d0d9523c535fd) /* 55 */,
+ U64_C(0x35638d754e9a2b00) /* 56 */, U64_C(0x4085fccf40469dd5) /* 57 */,
+ U64_C(0xc4b17ad28be23a4c) /* 58 */, U64_C(0xcab2f0fc6a3e6a2e) /* 59 */,
+ U64_C(0x2860971a6b943fcd) /* 60 */, U64_C(0x3dde6ee212e30446) /* 61 */,
+ U64_C(0x6222f32ae01765ae) /* 62 */, U64_C(0x5d550bb5478308fe) /* 63 */,
+ U64_C(0xa9efa98da0eda22a) /* 64 */, U64_C(0xc351a71686c40da7) /* 65 */,
+ U64_C(0x1105586d9c867c84) /* 66 */, U64_C(0xdcffee85fda22853) /* 67 */,
+ U64_C(0xccfbd0262c5eef76) /* 68 */, U64_C(0xbaf294cb8990d201) /* 69 */,
+ U64_C(0xe69464f52afad975) /* 70 */, U64_C(0x94b013afdf133e14) /* 71 */,
+ U64_C(0x06a7d1a32823c958) /* 72 */, U64_C(0x6f95fe5130f61119) /* 73 */,
+ U64_C(0xd92ab34e462c06c0) /* 74 */, U64_C(0xed7bde33887c71d2) /* 75 */,
+ U64_C(0x79746d6e6518393e) /* 76 */, U64_C(0x5ba419385d713329) /* 77 */,
+ U64_C(0x7c1ba6b948a97564) /* 78 */, U64_C(0x31987c197bfdac67) /* 79 */,
+ U64_C(0xde6c23c44b053d02) /* 80 */, U64_C(0x581c49fed002d64d) /* 81 */,
+ U64_C(0xdd474d6338261571) /* 82 */, U64_C(0xaa4546c3e473d062) /* 83 */,
+ U64_C(0x928fce349455f860) /* 84 */, U64_C(0x48161bbacaab94d9) /* 85 */,
+ U64_C(0x63912430770e6f68) /* 86 */, U64_C(0x6ec8a5e602c6641c) /* 87 */,
+ U64_C(0x87282515337ddd2b) /* 88 */, U64_C(0x2cda6b42034b701b) /* 89 */,
+ U64_C(0xb03d37c181cb096d) /* 90 */, U64_C(0xe108438266c71c6f) /* 91 */,
+ U64_C(0x2b3180c7eb51b255) /* 92 */, U64_C(0xdf92b82f96c08bbc) /* 93 */,
+ U64_C(0x5c68c8c0a632f3ba) /* 94 */, U64_C(0x5504cc861c3d0556) /* 95 */,
+ U64_C(0xabbfa4e55fb26b8f) /* 96 */, U64_C(0x41848b0ab3baceb4) /* 97 */,
+ U64_C(0xb334a273aa445d32) /* 98 */, U64_C(0xbca696f0a85ad881) /* 99 */,
+ U64_C(0x24f6ec65b528d56c) /* 100 */, U64_C(0x0ce1512e90f4524a) /* 101 */,
+ U64_C(0x4e9dd79d5506d35a) /* 102 */, U64_C(0x258905fac6ce9779) /* 103 */,
+ U64_C(0x2019295b3e109b33) /* 104 */, U64_C(0xf8a9478b73a054cc) /* 105 */,
+ U64_C(0x2924f2f934417eb0) /* 106 */, U64_C(0x3993357d536d1bc4) /* 107 */,
+ U64_C(0x38a81ac21db6ff8b) /* 108 */, U64_C(0x47c4fbf17d6016bf) /* 109 */,
+ U64_C(0x1e0faadd7667e3f5) /* 110 */, U64_C(0x7abcff62938beb96) /* 111 */,
+ U64_C(0xa78dad948fc179c9) /* 112 */, U64_C(0x8f1f98b72911e50d) /* 113 */,
+ U64_C(0x61e48eae27121a91) /* 114 */, U64_C(0x4d62f7ad31859808) /* 115 */,
+ U64_C(0xeceba345ef5ceaeb) /* 116 */, U64_C(0xf5ceb25ebc9684ce) /* 117 */,
+ U64_C(0xf633e20cb7f76221) /* 118 */, U64_C(0xa32cdf06ab8293e4) /* 119 */,
+ U64_C(0x985a202ca5ee2ca4) /* 120 */, U64_C(0xcf0b8447cc8a8fb1) /* 121 */,
+ U64_C(0x9f765244979859a3) /* 122 */, U64_C(0xa8d516b1a1240017) /* 123 */,
+ U64_C(0x0bd7ba3ebb5dc726) /* 124 */, U64_C(0xe54bca55b86adb39) /* 125 */,
+ U64_C(0x1d7a3afd6c478063) /* 126 */, U64_C(0x519ec608e7669edd) /* 127 */,
+ U64_C(0x0e5715a2d149aa23) /* 128 */, U64_C(0x177d4571848ff194) /* 129 */,
+ U64_C(0xeeb55f3241014c22) /* 130 */, U64_C(0x0f5e5ca13a6e2ec2) /* 131 */,
+ U64_C(0x8029927b75f5c361) /* 132 */, U64_C(0xad139fabc3d6e436) /* 133 */,
+ U64_C(0x0d5df1a94ccf402f) /* 134 */, U64_C(0x3e8bd948bea5dfc8) /* 135 */,
+ U64_C(0xa5a0d357bd3ff77e) /* 136 */, U64_C(0xa2d12e251f74f645) /* 137 */,
+ U64_C(0x66fd9e525e81a082) /* 138 */, U64_C(0x2e0c90ce7f687a49) /* 139 */,
+ U64_C(0xc2e8bcbeba973bc5) /* 140 */, U64_C(0x000001bce509745f) /* 141 */,
+ U64_C(0x423777bbe6dab3d6) /* 142 */, U64_C(0xd1661c7eaef06eb5) /* 143 */,
+ U64_C(0xa1781f354daacfd8) /* 144 */, U64_C(0x2d11284a2b16affc) /* 145 */,
+ U64_C(0xf1fc4f67fa891d1f) /* 146 */, U64_C(0x73ecc25dcb920ada) /* 147 */,
+ U64_C(0xae610c22c2a12651) /* 148 */, U64_C(0x96e0a810d356b78a) /* 149 */,
+ U64_C(0x5a9a381f2fe7870f) /* 150 */, U64_C(0xd5ad62ede94e5530) /* 151 */,
+ U64_C(0xd225e5e8368d1427) /* 152 */, U64_C(0x65977b70c7af4631) /* 153 */,
+ U64_C(0x99f889b2de39d74f) /* 154 */, U64_C(0x233f30bf54e1d143) /* 155 */,
+ U64_C(0x9a9675d3d9a63c97) /* 156 */, U64_C(0x5470554ff334f9a8) /* 157 */,
+ U64_C(0x166acb744a4f5688) /* 158 */, U64_C(0x70c74caab2e4aead) /* 159 */,
+ U64_C(0xf0d091646f294d12) /* 160 */, U64_C(0x57b82a89684031d1) /* 161 */,
+ U64_C(0xefd95a5a61be0b6b) /* 162 */, U64_C(0x2fbd12e969f2f29a) /* 163 */,
+ U64_C(0x9bd37013feff9fe8) /* 164 */, U64_C(0x3f9b0404d6085a06) /* 165 */,
+ U64_C(0x4940c1f3166cfe15) /* 166 */, U64_C(0x09542c4dcdf3defb) /* 167 */,
+ U64_C(0xb4c5218385cd5ce3) /* 168 */, U64_C(0xc935b7dc4462a641) /* 169 */,
+ U64_C(0x3417f8a68ed3b63f) /* 170 */, U64_C(0xb80959295b215b40) /* 171 */,
+ U64_C(0xf99cdaef3b8c8572) /* 172 */, U64_C(0x018c0614f8fcb95d) /* 173 */,
+ U64_C(0x1b14accd1a3acdf3) /* 174 */, U64_C(0x84d471f200bb732d) /* 175 */,
+ U64_C(0xc1a3110e95e8da16) /* 176 */, U64_C(0x430a7220bf1a82b8) /* 177 */,
+ U64_C(0xb77e090d39df210e) /* 178 */, U64_C(0x5ef4bd9f3cd05e9d) /* 179 */,
+ U64_C(0x9d4ff6da7e57a444) /* 180 */, U64_C(0xda1d60e183d4a5f8) /* 181 */,
+ U64_C(0xb287c38417998e47) /* 182 */, U64_C(0xfe3edc121bb31886) /* 183 */,
+ U64_C(0xc7fe3ccc980ccbef) /* 184 */, U64_C(0xe46fb590189bfd03) /* 185 */,
+ U64_C(0x3732fd469a4c57dc) /* 186 */, U64_C(0x7ef700a07cf1ad65) /* 187 */,
+ U64_C(0x59c64468a31d8859) /* 188 */, U64_C(0x762fb0b4d45b61f6) /* 189 */,
+ U64_C(0x155baed099047718) /* 190 */, U64_C(0x68755e4c3d50baa6) /* 191 */,
+ U64_C(0xe9214e7f22d8b4df) /* 192 */, U64_C(0x2addbf532eac95f4) /* 193 */,
+ U64_C(0x32ae3909b4bd0109) /* 194 */, U64_C(0x834df537b08e3450) /* 195 */,
+ U64_C(0xfa209da84220728d) /* 196 */, U64_C(0x9e691d9b9efe23f7) /* 197 */,
+ U64_C(0x0446d288c4ae8d7f) /* 198 */, U64_C(0x7b4cc524e169785b) /* 199 */,
+ U64_C(0x21d87f0135ca1385) /* 200 */, U64_C(0xcebb400f137b8aa5) /* 201 */,
+ U64_C(0x272e2b66580796be) /* 202 */, U64_C(0x3612264125c2b0de) /* 203 */,
+ U64_C(0x057702bdad1efbb2) /* 204 */, U64_C(0xd4babb8eacf84be9) /* 205 */,
+ U64_C(0x91583139641bc67b) /* 206 */, U64_C(0x8bdc2de08036e024) /* 207 */,
+ U64_C(0x603c8156f49f68ed) /* 208 */, U64_C(0xf7d236f7dbef5111) /* 209 */,
+ U64_C(0x9727c4598ad21e80) /* 210 */, U64_C(0xa08a0896670a5fd7) /* 211 */,
+ U64_C(0xcb4a8f4309eba9cb) /* 212 */, U64_C(0x81af564b0f7036a1) /* 213 */,
+ U64_C(0xc0b99aa778199abd) /* 214 */, U64_C(0x959f1ec83fc8e952) /* 215 */,
+ U64_C(0x8c505077794a81b9) /* 216 */, U64_C(0x3acaaf8f056338f0) /* 217 */,
+ U64_C(0x07b43f50627a6778) /* 218 */, U64_C(0x4a44ab49f5eccc77) /* 219 */,
+ U64_C(0x3bc3d6e4b679ee98) /* 220 */, U64_C(0x9cc0d4d1cf14108c) /* 221 */,
+ U64_C(0x4406c00b206bc8a0) /* 222 */, U64_C(0x82a18854c8d72d89) /* 223 */,
+ U64_C(0x67e366b35c3c432c) /* 224 */, U64_C(0xb923dd61102b37f2) /* 225 */,
+ U64_C(0x56ab2779d884271d) /* 226 */, U64_C(0xbe83e1b0ff1525af) /* 227 */,
+ U64_C(0xfb7c65d4217e49a9) /* 228 */, U64_C(0x6bdbe0e76d48e7d4) /* 229 */,
+ U64_C(0x08df828745d9179e) /* 230 */, U64_C(0x22ea6a9add53bd34) /* 231 */,
+ U64_C(0xe36e141c5622200a) /* 232 */, U64_C(0x7f805d1b8cb750ee) /* 233 */,
+ U64_C(0xafe5c7a59f58e837) /* 234 */, U64_C(0xe27f996a4fb1c23c) /* 235 */,
+ U64_C(0xd3867dfb0775f0d0) /* 236 */, U64_C(0xd0e673de6e88891a) /* 237 */,
+ U64_C(0x123aeb9eafb86c25) /* 238 */, U64_C(0x30f1d5d5c145b895) /* 239 */,
+ U64_C(0xbb434a2dee7269e7) /* 240 */, U64_C(0x78cb67ecf931fa38) /* 241 */,
+ U64_C(0xf33b0372323bbf9c) /* 242 */, U64_C(0x52d66336fb279c74) /* 243 */,
+ U64_C(0x505f33ac0afb4eaa) /* 244 */, U64_C(0xe8a5cd99a2cce187) /* 245 */,
+ U64_C(0x534974801e2d30bb) /* 246 */, U64_C(0x8d2d5711d5876d90) /* 247 */,
+ U64_C(0x1f1a412891bc038e) /* 248 */, U64_C(0xd6e2e71d82e56648) /* 249 */,
+ U64_C(0x74036c3a497732b7) /* 250 */, U64_C(0x89b67ed96361f5ab) /* 251 */,
+ U64_C(0xffed95d8f1ea02a2) /* 252 */, U64_C(0xe72b3bd61464d43d) /* 253 */,
+ U64_C(0xa6300f170bdc4820) /* 254 */, U64_C(0xebc18760ed78a77a) /* 255 */
+};
+static u64 sbox2[256] = {
+ U64_C(0xe6a6be5a05a12138) /* 256 */, U64_C(0xb5a122a5b4f87c98) /* 257 */,
+ U64_C(0x563c6089140b6990) /* 258 */, U64_C(0x4c46cb2e391f5dd5) /* 259 */,
+ U64_C(0xd932addbc9b79434) /* 260 */, U64_C(0x08ea70e42015aff5) /* 261 */,
+ U64_C(0xd765a6673e478cf1) /* 262 */, U64_C(0xc4fb757eab278d99) /* 263 */,
+ U64_C(0xdf11c6862d6e0692) /* 264 */, U64_C(0xddeb84f10d7f3b16) /* 265 */,
+ U64_C(0x6f2ef604a665ea04) /* 266 */, U64_C(0x4a8e0f0ff0e0dfb3) /* 267 */,
+ U64_C(0xa5edeef83dbcba51) /* 268 */, U64_C(0xfc4f0a2a0ea4371e) /* 269 */,
+ U64_C(0xe83e1da85cb38429) /* 270 */, U64_C(0xdc8ff882ba1b1ce2) /* 271 */,
+ U64_C(0xcd45505e8353e80d) /* 272 */, U64_C(0x18d19a00d4db0717) /* 273 */,
+ U64_C(0x34a0cfeda5f38101) /* 274 */, U64_C(0x0be77e518887caf2) /* 275 */,
+ U64_C(0x1e341438b3c45136) /* 276 */, U64_C(0xe05797f49089ccf9) /* 277 */,
+ U64_C(0xffd23f9df2591d14) /* 278 */, U64_C(0x543dda228595c5cd) /* 279 */,
+ U64_C(0x661f81fd99052a33) /* 280 */, U64_C(0x8736e641db0f7b76) /* 281 */,
+ U64_C(0x15227725418e5307) /* 282 */, U64_C(0xe25f7f46162eb2fa) /* 283 */,
+ U64_C(0x48a8b2126c13d9fe) /* 284 */, U64_C(0xafdc541792e76eea) /* 285 */,
+ U64_C(0x03d912bfc6d1898f) /* 286 */, U64_C(0x31b1aafa1b83f51b) /* 287 */,
+ U64_C(0xf1ac2796e42ab7d9) /* 288 */, U64_C(0x40a3a7d7fcd2ebac) /* 289 */,
+ U64_C(0x1056136d0afbbcc5) /* 290 */, U64_C(0x7889e1dd9a6d0c85) /* 291 */,
+ U64_C(0xd33525782a7974aa) /* 292 */, U64_C(0xa7e25d09078ac09b) /* 293 */,
+ U64_C(0xbd4138b3eac6edd0) /* 294 */, U64_C(0x920abfbe71eb9e70) /* 295 */,
+ U64_C(0xa2a5d0f54fc2625c) /* 296 */, U64_C(0xc054e36b0b1290a3) /* 297 */,
+ U64_C(0xf6dd59ff62fe932b) /* 298 */, U64_C(0x3537354511a8ac7d) /* 299 */,
+ U64_C(0xca845e9172fadcd4) /* 300 */, U64_C(0x84f82b60329d20dc) /* 301 */,
+ U64_C(0x79c62ce1cd672f18) /* 302 */, U64_C(0x8b09a2add124642c) /* 303 */,
+ U64_C(0xd0c1e96a19d9e726) /* 304 */, U64_C(0x5a786a9b4ba9500c) /* 305 */,
+ U64_C(0x0e020336634c43f3) /* 306 */, U64_C(0xc17b474aeb66d822) /* 307 */,
+ U64_C(0x6a731ae3ec9baac2) /* 308 */, U64_C(0x8226667ae0840258) /* 309 */,
+ U64_C(0x67d4567691caeca5) /* 310 */, U64_C(0x1d94155c4875adb5) /* 311 */,
+ U64_C(0x6d00fd985b813fdf) /* 312 */, U64_C(0x51286efcb774cd06) /* 313 */,
+ U64_C(0x5e8834471fa744af) /* 314 */, U64_C(0xf72ca0aee761ae2e) /* 315 */,
+ U64_C(0xbe40e4cdaee8e09a) /* 316 */, U64_C(0xe9970bbb5118f665) /* 317 */,
+ U64_C(0x726e4beb33df1964) /* 318 */, U64_C(0x703b000729199762) /* 319 */,
+ U64_C(0x4631d816f5ef30a7) /* 320 */, U64_C(0xb880b5b51504a6be) /* 321 */,
+ U64_C(0x641793c37ed84b6c) /* 322 */, U64_C(0x7b21ed77f6e97d96) /* 323 */,
+ U64_C(0x776306312ef96b73) /* 324 */, U64_C(0xae528948e86ff3f4) /* 325 */,
+ U64_C(0x53dbd7f286a3f8f8) /* 326 */, U64_C(0x16cadce74cfc1063) /* 327 */,
+ U64_C(0x005c19bdfa52c6dd) /* 328 */, U64_C(0x68868f5d64d46ad3) /* 329 */,
+ U64_C(0x3a9d512ccf1e186a) /* 330 */, U64_C(0x367e62c2385660ae) /* 331 */,
+ U64_C(0xe359e7ea77dcb1d7) /* 332 */, U64_C(0x526c0773749abe6e) /* 333 */,
+ U64_C(0x735ae5f9d09f734b) /* 334 */, U64_C(0x493fc7cc8a558ba8) /* 335 */,
+ U64_C(0xb0b9c1533041ab45) /* 336 */, U64_C(0x321958ba470a59bd) /* 337 */,
+ U64_C(0x852db00b5f46c393) /* 338 */, U64_C(0x91209b2bd336b0e5) /* 339 */,
+ U64_C(0x6e604f7d659ef19f) /* 340 */, U64_C(0xb99a8ae2782ccb24) /* 341 */,
+ U64_C(0xccf52ab6c814c4c7) /* 342 */, U64_C(0x4727d9afbe11727b) /* 343 */,
+ U64_C(0x7e950d0c0121b34d) /* 344 */, U64_C(0x756f435670ad471f) /* 345 */,
+ U64_C(0xf5add442615a6849) /* 346 */, U64_C(0x4e87e09980b9957a) /* 347 */,
+ U64_C(0x2acfa1df50aee355) /* 348 */, U64_C(0xd898263afd2fd556) /* 349 */,
+ U64_C(0xc8f4924dd80c8fd6) /* 350 */, U64_C(0xcf99ca3d754a173a) /* 351 */,
+ U64_C(0xfe477bacaf91bf3c) /* 352 */, U64_C(0xed5371f6d690c12d) /* 353 */,
+ U64_C(0x831a5c285e687094) /* 354 */, U64_C(0xc5d3c90a3708a0a4) /* 355 */,
+ U64_C(0x0f7f903717d06580) /* 356 */, U64_C(0x19f9bb13b8fdf27f) /* 357 */,
+ U64_C(0xb1bd6f1b4d502843) /* 358 */, U64_C(0x1c761ba38fff4012) /* 359 */,
+ U64_C(0x0d1530c4e2e21f3b) /* 360 */, U64_C(0x8943ce69a7372c8a) /* 361 */,
+ U64_C(0xe5184e11feb5ce66) /* 362 */, U64_C(0x618bdb80bd736621) /* 363 */,
+ U64_C(0x7d29bad68b574d0b) /* 364 */, U64_C(0x81bb613e25e6fe5b) /* 365 */,
+ U64_C(0x071c9c10bc07913f) /* 366 */, U64_C(0xc7beeb7909ac2d97) /* 367 */,
+ U64_C(0xc3e58d353bc5d757) /* 368 */, U64_C(0xeb017892f38f61e8) /* 369 */,
+ U64_C(0xd4effb9c9b1cc21a) /* 370 */, U64_C(0x99727d26f494f7ab) /* 371 */,
+ U64_C(0xa3e063a2956b3e03) /* 372 */, U64_C(0x9d4a8b9a4aa09c30) /* 373 */,
+ U64_C(0x3f6ab7d500090fb4) /* 374 */, U64_C(0x9cc0f2a057268ac0) /* 375 */,
+ U64_C(0x3dee9d2dedbf42d1) /* 376 */, U64_C(0x330f49c87960a972) /* 377 */,
+ U64_C(0xc6b2720287421b41) /* 378 */, U64_C(0x0ac59ec07c00369c) /* 379 */,
+ U64_C(0xef4eac49cb353425) /* 380 */, U64_C(0xf450244eef0129d8) /* 381 */,
+ U64_C(0x8acc46e5caf4deb6) /* 382 */, U64_C(0x2ffeab63989263f7) /* 383 */,
+ U64_C(0x8f7cb9fe5d7a4578) /* 384 */, U64_C(0x5bd8f7644e634635) /* 385 */,
+ U64_C(0x427a7315bf2dc900) /* 386 */, U64_C(0x17d0c4aa2125261c) /* 387 */,
+ U64_C(0x3992486c93518e50) /* 388 */, U64_C(0xb4cbfee0a2d7d4c3) /* 389 */,
+ U64_C(0x7c75d6202c5ddd8d) /* 390 */, U64_C(0xdbc295d8e35b6c61) /* 391 */,
+ U64_C(0x60b369d302032b19) /* 392 */, U64_C(0xce42685fdce44132) /* 393 */,
+ U64_C(0x06f3ddb9ddf65610) /* 394 */, U64_C(0x8ea4d21db5e148f0) /* 395 */,
+ U64_C(0x20b0fce62fcd496f) /* 396 */, U64_C(0x2c1b912358b0ee31) /* 397 */,
+ U64_C(0xb28317b818f5a308) /* 398 */, U64_C(0xa89c1e189ca6d2cf) /* 399 */,
+ U64_C(0x0c6b18576aaadbc8) /* 400 */, U64_C(0xb65deaa91299fae3) /* 401 */,
+ U64_C(0xfb2b794b7f1027e7) /* 402 */, U64_C(0x04e4317f443b5beb) /* 403 */,
+ U64_C(0x4b852d325939d0a6) /* 404 */, U64_C(0xd5ae6beefb207ffc) /* 405 */,
+ U64_C(0x309682b281c7d374) /* 406 */, U64_C(0xbae309a194c3b475) /* 407 */,
+ U64_C(0x8cc3f97b13b49f05) /* 408 */, U64_C(0x98a9422ff8293967) /* 409 */,
+ U64_C(0x244b16b01076ff7c) /* 410 */, U64_C(0xf8bf571c663d67ee) /* 411 */,
+ U64_C(0x1f0d6758eee30da1) /* 412 */, U64_C(0xc9b611d97adeb9b7) /* 413 */,
+ U64_C(0xb7afd5887b6c57a2) /* 414 */, U64_C(0x6290ae846b984fe1) /* 415 */,
+ U64_C(0x94df4cdeacc1a5fd) /* 416 */, U64_C(0x058a5bd1c5483aff) /* 417 */,
+ U64_C(0x63166cc142ba3c37) /* 418 */, U64_C(0x8db8526eb2f76f40) /* 419 */,
+ U64_C(0xe10880036f0d6d4e) /* 420 */, U64_C(0x9e0523c9971d311d) /* 421 */,
+ U64_C(0x45ec2824cc7cd691) /* 422 */, U64_C(0x575b8359e62382c9) /* 423 */,
+ U64_C(0xfa9e400dc4889995) /* 424 */, U64_C(0xd1823ecb45721568) /* 425 */,
+ U64_C(0xdafd983b8206082f) /* 426 */, U64_C(0xaa7d29082386a8cb) /* 427 */,
+ U64_C(0x269fcd4403b87588) /* 428 */, U64_C(0x1b91f5f728bdd1e0) /* 429 */,
+ U64_C(0xe4669f39040201f6) /* 430 */, U64_C(0x7a1d7c218cf04ade) /* 431 */,
+ U64_C(0x65623c29d79ce5ce) /* 432 */, U64_C(0x2368449096c00bb1) /* 433 */,
+ U64_C(0xab9bf1879da503ba) /* 434 */, U64_C(0xbc23ecb1a458058e) /* 435 */,
+ U64_C(0x9a58df01bb401ecc) /* 436 */, U64_C(0xa070e868a85f143d) /* 437 */,
+ U64_C(0x4ff188307df2239e) /* 438 */, U64_C(0x14d565b41a641183) /* 439 */,
+ U64_C(0xee13337452701602) /* 440 */, U64_C(0x950e3dcf3f285e09) /* 441 */,
+ U64_C(0x59930254b9c80953) /* 442 */, U64_C(0x3bf299408930da6d) /* 443 */,
+ U64_C(0xa955943f53691387) /* 444 */, U64_C(0xa15edecaa9cb8784) /* 445 */,
+ U64_C(0x29142127352be9a0) /* 446 */, U64_C(0x76f0371fff4e7afb) /* 447 */,
+ U64_C(0x0239f450274f2228) /* 448 */, U64_C(0xbb073af01d5e868b) /* 449 */,
+ U64_C(0xbfc80571c10e96c1) /* 450 */, U64_C(0xd267088568222e23) /* 451 */,
+ U64_C(0x9671a3d48e80b5b0) /* 452 */, U64_C(0x55b5d38ae193bb81) /* 453 */,
+ U64_C(0x693ae2d0a18b04b8) /* 454 */, U64_C(0x5c48b4ecadd5335f) /* 455 */,
+ U64_C(0xfd743b194916a1ca) /* 456 */, U64_C(0x2577018134be98c4) /* 457 */,
+ U64_C(0xe77987e83c54a4ad) /* 458 */, U64_C(0x28e11014da33e1b9) /* 459 */,
+ U64_C(0x270cc59e226aa213) /* 460 */, U64_C(0x71495f756d1a5f60) /* 461 */,
+ U64_C(0x9be853fb60afef77) /* 462 */, U64_C(0xadc786a7f7443dbf) /* 463 */,
+ U64_C(0x0904456173b29a82) /* 464 */, U64_C(0x58bc7a66c232bd5e) /* 465 */,
+ U64_C(0xf306558c673ac8b2) /* 466 */, U64_C(0x41f639c6b6c9772a) /* 467 */,
+ U64_C(0x216defe99fda35da) /* 468 */, U64_C(0x11640cc71c7be615) /* 469 */,
+ U64_C(0x93c43694565c5527) /* 470 */, U64_C(0xea038e6246777839) /* 471 */,
+ U64_C(0xf9abf3ce5a3e2469) /* 472 */, U64_C(0x741e768d0fd312d2) /* 473 */,
+ U64_C(0x0144b883ced652c6) /* 474 */, U64_C(0xc20b5a5ba33f8552) /* 475 */,
+ U64_C(0x1ae69633c3435a9d) /* 476 */, U64_C(0x97a28ca4088cfdec) /* 477 */,
+ U64_C(0x8824a43c1e96f420) /* 478 */, U64_C(0x37612fa66eeea746) /* 479 */,
+ U64_C(0x6b4cb165f9cf0e5a) /* 480 */, U64_C(0x43aa1c06a0abfb4a) /* 481 */,
+ U64_C(0x7f4dc26ff162796b) /* 482 */, U64_C(0x6cbacc8e54ed9b0f) /* 483 */,
+ U64_C(0xa6b7ffefd2bb253e) /* 484 */, U64_C(0x2e25bc95b0a29d4f) /* 485 */,
+ U64_C(0x86d6a58bdef1388c) /* 486 */, U64_C(0xded74ac576b6f054) /* 487 */,
+ U64_C(0x8030bdbc2b45805d) /* 488 */, U64_C(0x3c81af70e94d9289) /* 489 */,
+ U64_C(0x3eff6dda9e3100db) /* 490 */, U64_C(0xb38dc39fdfcc8847) /* 491 */,
+ U64_C(0x123885528d17b87e) /* 492 */, U64_C(0xf2da0ed240b1b642) /* 493 */,
+ U64_C(0x44cefadcd54bf9a9) /* 494 */, U64_C(0x1312200e433c7ee6) /* 495 */,
+ U64_C(0x9ffcc84f3a78c748) /* 496 */, U64_C(0xf0cd1f72248576bb) /* 497 */,
+ U64_C(0xec6974053638cfe4) /* 498 */, U64_C(0x2ba7b67c0cec4e4c) /* 499 */,
+ U64_C(0xac2f4df3e5ce32ed) /* 500 */, U64_C(0xcb33d14326ea4c11) /* 501 */,
+ U64_C(0xa4e9044cc77e58bc) /* 502 */, U64_C(0x5f513293d934fcef) /* 503 */,
+ U64_C(0x5dc9645506e55444) /* 504 */, U64_C(0x50de418f317de40a) /* 505 */,
+ U64_C(0x388cb31a69dde259) /* 506 */, U64_C(0x2db4a83455820a86) /* 507 */,
+ U64_C(0x9010a91e84711ae9) /* 508 */, U64_C(0x4df7f0b7b1498371) /* 509 */,
+ U64_C(0xd62a2eabc0977179) /* 510 */, U64_C(0x22fac097aa8d5c0e) /* 511 */
+};
+static u64 sbox3[256] = {
+ U64_C(0xf49fcc2ff1daf39b) /* 512 */, U64_C(0x487fd5c66ff29281) /* 513 */,
+ U64_C(0xe8a30667fcdca83f) /* 514 */, U64_C(0x2c9b4be3d2fcce63) /* 515 */,
+ U64_C(0xda3ff74b93fbbbc2) /* 516 */, U64_C(0x2fa165d2fe70ba66) /* 517 */,
+ U64_C(0xa103e279970e93d4) /* 518 */, U64_C(0xbecdec77b0e45e71) /* 519 */,
+ U64_C(0xcfb41e723985e497) /* 520 */, U64_C(0xb70aaa025ef75017) /* 521 */,
+ U64_C(0xd42309f03840b8e0) /* 522 */, U64_C(0x8efc1ad035898579) /* 523 */,
+ U64_C(0x96c6920be2b2abc5) /* 524 */, U64_C(0x66af4163375a9172) /* 525 */,
+ U64_C(0x2174abdcca7127fb) /* 526 */, U64_C(0xb33ccea64a72ff41) /* 527 */,
+ U64_C(0xf04a4933083066a5) /* 528 */, U64_C(0x8d970acdd7289af5) /* 529 */,
+ U64_C(0x8f96e8e031c8c25e) /* 530 */, U64_C(0xf3fec02276875d47) /* 531 */,
+ U64_C(0xec7bf310056190dd) /* 532 */, U64_C(0xf5adb0aebb0f1491) /* 533 */,
+ U64_C(0x9b50f8850fd58892) /* 534 */, U64_C(0x4975488358b74de8) /* 535 */,
+ U64_C(0xa3354ff691531c61) /* 536 */, U64_C(0x0702bbe481d2c6ee) /* 537 */,
+ U64_C(0x89fb24057deded98) /* 538 */, U64_C(0xac3075138596e902) /* 539 */,
+ U64_C(0x1d2d3580172772ed) /* 540 */, U64_C(0xeb738fc28e6bc30d) /* 541 */,
+ U64_C(0x5854ef8f63044326) /* 542 */, U64_C(0x9e5c52325add3bbe) /* 543 */,
+ U64_C(0x90aa53cf325c4623) /* 544 */, U64_C(0xc1d24d51349dd067) /* 545 */,
+ U64_C(0x2051cfeea69ea624) /* 546 */, U64_C(0x13220f0a862e7e4f) /* 547 */,
+ U64_C(0xce39399404e04864) /* 548 */, U64_C(0xd9c42ca47086fcb7) /* 549 */,
+ U64_C(0x685ad2238a03e7cc) /* 550 */, U64_C(0x066484b2ab2ff1db) /* 551 */,
+ U64_C(0xfe9d5d70efbf79ec) /* 552 */, U64_C(0x5b13b9dd9c481854) /* 553 */,
+ U64_C(0x15f0d475ed1509ad) /* 554 */, U64_C(0x0bebcd060ec79851) /* 555 */,
+ U64_C(0xd58c6791183ab7f8) /* 556 */, U64_C(0xd1187c5052f3eee4) /* 557 */,
+ U64_C(0xc95d1192e54e82ff) /* 558 */, U64_C(0x86eea14cb9ac6ca2) /* 559 */,
+ U64_C(0x3485beb153677d5d) /* 560 */, U64_C(0xdd191d781f8c492a) /* 561 */,
+ U64_C(0xf60866baa784ebf9) /* 562 */, U64_C(0x518f643ba2d08c74) /* 563 */,
+ U64_C(0x8852e956e1087c22) /* 564 */, U64_C(0xa768cb8dc410ae8d) /* 565 */,
+ U64_C(0x38047726bfec8e1a) /* 566 */, U64_C(0xa67738b4cd3b45aa) /* 567 */,
+ U64_C(0xad16691cec0dde19) /* 568 */, U64_C(0xc6d4319380462e07) /* 569 */,
+ U64_C(0xc5a5876d0ba61938) /* 570 */, U64_C(0x16b9fa1fa58fd840) /* 571 */,
+ U64_C(0x188ab1173ca74f18) /* 572 */, U64_C(0xabda2f98c99c021f) /* 573 */,
+ U64_C(0x3e0580ab134ae816) /* 574 */, U64_C(0x5f3b05b773645abb) /* 575 */,
+ U64_C(0x2501a2be5575f2f6) /* 576 */, U64_C(0x1b2f74004e7e8ba9) /* 577 */,
+ U64_C(0x1cd7580371e8d953) /* 578 */, U64_C(0x7f6ed89562764e30) /* 579 */,
+ U64_C(0xb15926ff596f003d) /* 580 */, U64_C(0x9f65293da8c5d6b9) /* 581 */,
+ U64_C(0x6ecef04dd690f84c) /* 582 */, U64_C(0x4782275fff33af88) /* 583 */,
+ U64_C(0xe41433083f820801) /* 584 */, U64_C(0xfd0dfe409a1af9b5) /* 585 */,
+ U64_C(0x4325a3342cdb396b) /* 586 */, U64_C(0x8ae77e62b301b252) /* 587 */,
+ U64_C(0xc36f9e9f6655615a) /* 588 */, U64_C(0x85455a2d92d32c09) /* 589 */,
+ U64_C(0xf2c7dea949477485) /* 590 */, U64_C(0x63cfb4c133a39eba) /* 591 */,
+ U64_C(0x83b040cc6ebc5462) /* 592 */, U64_C(0x3b9454c8fdb326b0) /* 593 */,
+ U64_C(0x56f56a9e87ffd78c) /* 594 */, U64_C(0x2dc2940d99f42bc6) /* 595 */,
+ U64_C(0x98f7df096b096e2d) /* 596 */, U64_C(0x19a6e01e3ad852bf) /* 597 */,
+ U64_C(0x42a99ccbdbd4b40b) /* 598 */, U64_C(0xa59998af45e9c559) /* 599 */,
+ U64_C(0x366295e807d93186) /* 600 */, U64_C(0x6b48181bfaa1f773) /* 601 */,
+ U64_C(0x1fec57e2157a0a1d) /* 602 */, U64_C(0x4667446af6201ad5) /* 603 */,
+ U64_C(0xe615ebcacfb0f075) /* 604 */, U64_C(0xb8f31f4f68290778) /* 605 */,
+ U64_C(0x22713ed6ce22d11e) /* 606 */, U64_C(0x3057c1a72ec3c93b) /* 607 */,
+ U64_C(0xcb46acc37c3f1f2f) /* 608 */, U64_C(0xdbb893fd02aaf50e) /* 609 */,
+ U64_C(0x331fd92e600b9fcf) /* 610 */, U64_C(0xa498f96148ea3ad6) /* 611 */,
+ U64_C(0xa8d8426e8b6a83ea) /* 612 */, U64_C(0xa089b274b7735cdc) /* 613 */,
+ U64_C(0x87f6b3731e524a11) /* 614 */, U64_C(0x118808e5cbc96749) /* 615 */,
+ U64_C(0x9906e4c7b19bd394) /* 616 */, U64_C(0xafed7f7e9b24a20c) /* 617 */,
+ U64_C(0x6509eadeeb3644a7) /* 618 */, U64_C(0x6c1ef1d3e8ef0ede) /* 619 */,
+ U64_C(0xb9c97d43e9798fb4) /* 620 */, U64_C(0xa2f2d784740c28a3) /* 621 */,
+ U64_C(0x7b8496476197566f) /* 622 */, U64_C(0x7a5be3e6b65f069d) /* 623 */,
+ U64_C(0xf96330ed78be6f10) /* 624 */, U64_C(0xeee60de77a076a15) /* 625 */,
+ U64_C(0x2b4bee4aa08b9bd0) /* 626 */, U64_C(0x6a56a63ec7b8894e) /* 627 */,
+ U64_C(0x02121359ba34fef4) /* 628 */, U64_C(0x4cbf99f8283703fc) /* 629 */,
+ U64_C(0x398071350caf30c8) /* 630 */, U64_C(0xd0a77a89f017687a) /* 631 */,
+ U64_C(0xf1c1a9eb9e423569) /* 632 */, U64_C(0x8c7976282dee8199) /* 633 */,
+ U64_C(0x5d1737a5dd1f7abd) /* 634 */, U64_C(0x4f53433c09a9fa80) /* 635 */,
+ U64_C(0xfa8b0c53df7ca1d9) /* 636 */, U64_C(0x3fd9dcbc886ccb77) /* 637 */,
+ U64_C(0xc040917ca91b4720) /* 638 */, U64_C(0x7dd00142f9d1dcdf) /* 639 */,
+ U64_C(0x8476fc1d4f387b58) /* 640 */, U64_C(0x23f8e7c5f3316503) /* 641 */,
+ U64_C(0x032a2244e7e37339) /* 642 */, U64_C(0x5c87a5d750f5a74b) /* 643 */,
+ U64_C(0x082b4cc43698992e) /* 644 */, U64_C(0xdf917becb858f63c) /* 645 */,
+ U64_C(0x3270b8fc5bf86dda) /* 646 */, U64_C(0x10ae72bb29b5dd76) /* 647 */,
+ U64_C(0x576ac94e7700362b) /* 648 */, U64_C(0x1ad112dac61efb8f) /* 649 */,
+ U64_C(0x691bc30ec5faa427) /* 650 */, U64_C(0xff246311cc327143) /* 651 */,
+ U64_C(0x3142368e30e53206) /* 652 */, U64_C(0x71380e31e02ca396) /* 653 */,
+ U64_C(0x958d5c960aad76f1) /* 654 */, U64_C(0xf8d6f430c16da536) /* 655 */,
+ U64_C(0xc8ffd13f1be7e1d2) /* 656 */, U64_C(0x7578ae66004ddbe1) /* 657 */,
+ U64_C(0x05833f01067be646) /* 658 */, U64_C(0xbb34b5ad3bfe586d) /* 659 */,
+ U64_C(0x095f34c9a12b97f0) /* 660 */, U64_C(0x247ab64525d60ca8) /* 661 */,
+ U64_C(0xdcdbc6f3017477d1) /* 662 */, U64_C(0x4a2e14d4decad24d) /* 663 */,
+ U64_C(0xbdb5e6d9be0a1eeb) /* 664 */, U64_C(0x2a7e70f7794301ab) /* 665 */,
+ U64_C(0xdef42d8a270540fd) /* 666 */, U64_C(0x01078ec0a34c22c1) /* 667 */,
+ U64_C(0xe5de511af4c16387) /* 668 */, U64_C(0x7ebb3a52bd9a330a) /* 669 */,
+ U64_C(0x77697857aa7d6435) /* 670 */, U64_C(0x004e831603ae4c32) /* 671 */,
+ U64_C(0xe7a21020ad78e312) /* 672 */, U64_C(0x9d41a70c6ab420f2) /* 673 */,
+ U64_C(0x28e06c18ea1141e6) /* 674 */, U64_C(0xd2b28cbd984f6b28) /* 675 */,
+ U64_C(0x26b75f6c446e9d83) /* 676 */, U64_C(0xba47568c4d418d7f) /* 677 */,
+ U64_C(0xd80badbfe6183d8e) /* 678 */, U64_C(0x0e206d7f5f166044) /* 679 */,
+ U64_C(0xe258a43911cbca3e) /* 680 */, U64_C(0x723a1746b21dc0bc) /* 681 */,
+ U64_C(0xc7caa854f5d7cdd3) /* 682 */, U64_C(0x7cac32883d261d9c) /* 683 */,
+ U64_C(0x7690c26423ba942c) /* 684 */, U64_C(0x17e55524478042b8) /* 685 */,
+ U64_C(0xe0be477656a2389f) /* 686 */, U64_C(0x4d289b5e67ab2da0) /* 687 */,
+ U64_C(0x44862b9c8fbbfd31) /* 688 */, U64_C(0xb47cc8049d141365) /* 689 */,
+ U64_C(0x822c1b362b91c793) /* 690 */, U64_C(0x4eb14655fb13dfd8) /* 691 */,
+ U64_C(0x1ecbba0714e2a97b) /* 692 */, U64_C(0x6143459d5cde5f14) /* 693 */,
+ U64_C(0x53a8fbf1d5f0ac89) /* 694 */, U64_C(0x97ea04d81c5e5b00) /* 695 */,
+ U64_C(0x622181a8d4fdb3f3) /* 696 */, U64_C(0xe9bcd341572a1208) /* 697 */,
+ U64_C(0x1411258643cce58a) /* 698 */, U64_C(0x9144c5fea4c6e0a4) /* 699 */,
+ U64_C(0x0d33d06565cf620f) /* 700 */, U64_C(0x54a48d489f219ca1) /* 701 */,
+ U64_C(0xc43e5eac6d63c821) /* 702 */, U64_C(0xa9728b3a72770daf) /* 703 */,
+ U64_C(0xd7934e7b20df87ef) /* 704 */, U64_C(0xe35503b61a3e86e5) /* 705 */,
+ U64_C(0xcae321fbc819d504) /* 706 */, U64_C(0x129a50b3ac60bfa6) /* 707 */,
+ U64_C(0xcd5e68ea7e9fb6c3) /* 708 */, U64_C(0xb01c90199483b1c7) /* 709 */,
+ U64_C(0x3de93cd5c295376c) /* 710 */, U64_C(0xaed52edf2ab9ad13) /* 711 */,
+ U64_C(0x2e60f512c0a07884) /* 712 */, U64_C(0xbc3d86a3e36210c9) /* 713 */,
+ U64_C(0x35269d9b163951ce) /* 714 */, U64_C(0x0c7d6e2ad0cdb5fa) /* 715 */,
+ U64_C(0x59e86297d87f5733) /* 716 */, U64_C(0x298ef221898db0e7) /* 717 */,
+ U64_C(0x55000029d1a5aa7e) /* 718 */, U64_C(0x8bc08ae1b5061b45) /* 719 */,
+ U64_C(0xc2c31c2b6c92703a) /* 720 */, U64_C(0x94cc596baf25ef42) /* 721 */,
+ U64_C(0x0a1d73db22540456) /* 722 */, U64_C(0x04b6a0f9d9c4179a) /* 723 */,
+ U64_C(0xeffdafa2ae3d3c60) /* 724 */, U64_C(0xf7c8075bb49496c4) /* 725 */,
+ U64_C(0x9cc5c7141d1cd4e3) /* 726 */, U64_C(0x78bd1638218e5534) /* 727 */,
+ U64_C(0xb2f11568f850246a) /* 728 */, U64_C(0xedfabcfa9502bc29) /* 729 */,
+ U64_C(0x796ce5f2da23051b) /* 730 */, U64_C(0xaae128b0dc93537c) /* 731 */,
+ U64_C(0x3a493da0ee4b29ae) /* 732 */, U64_C(0xb5df6b2c416895d7) /* 733 */,
+ U64_C(0xfcabbd25122d7f37) /* 734 */, U64_C(0x70810b58105dc4b1) /* 735 */,
+ U64_C(0xe10fdd37f7882a90) /* 736 */, U64_C(0x524dcab5518a3f5c) /* 737 */,
+ U64_C(0x3c9e85878451255b) /* 738 */, U64_C(0x4029828119bd34e2) /* 739 */,
+ U64_C(0x74a05b6f5d3ceccb) /* 740 */, U64_C(0xb610021542e13eca) /* 741 */,
+ U64_C(0x0ff979d12f59e2ac) /* 742 */, U64_C(0x6037da27e4f9cc50) /* 743 */,
+ U64_C(0x5e92975a0df1847d) /* 744 */, U64_C(0xd66de190d3e623fe) /* 745 */,
+ U64_C(0x5032d6b87b568048) /* 746 */, U64_C(0x9a36b7ce8235216e) /* 747 */,
+ U64_C(0x80272a7a24f64b4a) /* 748 */, U64_C(0x93efed8b8c6916f7) /* 749 */,
+ U64_C(0x37ddbff44cce1555) /* 750 */, U64_C(0x4b95db5d4b99bd25) /* 751 */,
+ U64_C(0x92d3fda169812fc0) /* 752 */, U64_C(0xfb1a4a9a90660bb6) /* 753 */,
+ U64_C(0x730c196946a4b9b2) /* 754 */, U64_C(0x81e289aa7f49da68) /* 755 */,
+ U64_C(0x64669a0f83b1a05f) /* 756 */, U64_C(0x27b3ff7d9644f48b) /* 757 */,
+ U64_C(0xcc6b615c8db675b3) /* 758 */, U64_C(0x674f20b9bcebbe95) /* 759 */,
+ U64_C(0x6f31238275655982) /* 760 */, U64_C(0x5ae488713e45cf05) /* 761 */,
+ U64_C(0xbf619f9954c21157) /* 762 */, U64_C(0xeabac46040a8eae9) /* 763 */,
+ U64_C(0x454c6fe9f2c0c1cd) /* 764 */, U64_C(0x419cf6496412691c) /* 765 */,
+ U64_C(0xd3dc3bef265b0f70) /* 766 */, U64_C(0x6d0e60f5c3578a9e) /* 767 */
+};
+static u64 sbox4[256] = {
+ U64_C(0x5b0e608526323c55) /* 768 */, U64_C(0x1a46c1a9fa1b59f5) /* 769 */,
+ U64_C(0xa9e245a17c4c8ffa) /* 770 */, U64_C(0x65ca5159db2955d7) /* 771 */,
+ U64_C(0x05db0a76ce35afc2) /* 772 */, U64_C(0x81eac77ea9113d45) /* 773 */,
+ U64_C(0x528ef88ab6ac0a0d) /* 774 */, U64_C(0xa09ea253597be3ff) /* 775 */,
+ U64_C(0x430ddfb3ac48cd56) /* 776 */, U64_C(0xc4b3a67af45ce46f) /* 777 */,
+ U64_C(0x4ececfd8fbe2d05e) /* 778 */, U64_C(0x3ef56f10b39935f0) /* 779 */,
+ U64_C(0x0b22d6829cd619c6) /* 780 */, U64_C(0x17fd460a74df2069) /* 781 */,
+ U64_C(0x6cf8cc8e8510ed40) /* 782 */, U64_C(0xd6c824bf3a6ecaa7) /* 783 */,
+ U64_C(0x61243d581a817049) /* 784 */, U64_C(0x048bacb6bbc163a2) /* 785 */,
+ U64_C(0xd9a38ac27d44cc32) /* 786 */, U64_C(0x7fddff5baaf410ab) /* 787 */,
+ U64_C(0xad6d495aa804824b) /* 788 */, U64_C(0xe1a6a74f2d8c9f94) /* 789 */,
+ U64_C(0xd4f7851235dee8e3) /* 790 */, U64_C(0xfd4b7f886540d893) /* 791 */,
+ U64_C(0x247c20042aa4bfda) /* 792 */, U64_C(0x096ea1c517d1327c) /* 793 */,
+ U64_C(0xd56966b4361a6685) /* 794 */, U64_C(0x277da5c31221057d) /* 795 */,
+ U64_C(0x94d59893a43acff7) /* 796 */, U64_C(0x64f0c51ccdc02281) /* 797 */,
+ U64_C(0x3d33bcc4ff6189db) /* 798 */, U64_C(0xe005cb184ce66af1) /* 799 */,
+ U64_C(0xff5ccd1d1db99bea) /* 800 */, U64_C(0xb0b854a7fe42980f) /* 801 */,
+ U64_C(0x7bd46a6a718d4b9f) /* 802 */, U64_C(0xd10fa8cc22a5fd8c) /* 803 */,
+ U64_C(0xd31484952be4bd31) /* 804 */, U64_C(0xc7fa975fcb243847) /* 805 */,
+ U64_C(0x4886ed1e5846c407) /* 806 */, U64_C(0x28cddb791eb70b04) /* 807 */,
+ U64_C(0xc2b00be2f573417f) /* 808 */, U64_C(0x5c9590452180f877) /* 809 */,
+ U64_C(0x7a6bddfff370eb00) /* 810 */, U64_C(0xce509e38d6d9d6a4) /* 811 */,
+ U64_C(0xebeb0f00647fa702) /* 812 */, U64_C(0x1dcc06cf76606f06) /* 813 */,
+ U64_C(0xe4d9f28ba286ff0a) /* 814 */, U64_C(0xd85a305dc918c262) /* 815 */,
+ U64_C(0x475b1d8732225f54) /* 816 */, U64_C(0x2d4fb51668ccb5fe) /* 817 */,
+ U64_C(0xa679b9d9d72bba20) /* 818 */, U64_C(0x53841c0d912d43a5) /* 819 */,
+ U64_C(0x3b7eaa48bf12a4e8) /* 820 */, U64_C(0x781e0e47f22f1ddf) /* 821 */,
+ U64_C(0xeff20ce60ab50973) /* 822 */, U64_C(0x20d261d19dffb742) /* 823 */,
+ U64_C(0x16a12b03062a2e39) /* 824 */, U64_C(0x1960eb2239650495) /* 825 */,
+ U64_C(0x251c16fed50eb8b8) /* 826 */, U64_C(0x9ac0c330f826016e) /* 827 */,
+ U64_C(0xed152665953e7671) /* 828 */, U64_C(0x02d63194a6369570) /* 829 */,
+ U64_C(0x5074f08394b1c987) /* 830 */, U64_C(0x70ba598c90b25ce1) /* 831 */,
+ U64_C(0x794a15810b9742f6) /* 832 */, U64_C(0x0d5925e9fcaf8c6c) /* 833 */,
+ U64_C(0x3067716cd868744e) /* 834 */, U64_C(0x910ab077e8d7731b) /* 835 */,
+ U64_C(0x6a61bbdb5ac42f61) /* 836 */, U64_C(0x93513efbf0851567) /* 837 */,
+ U64_C(0xf494724b9e83e9d5) /* 838 */, U64_C(0xe887e1985c09648d) /* 839 */,
+ U64_C(0x34b1d3c675370cfd) /* 840 */, U64_C(0xdc35e433bc0d255d) /* 841 */,
+ U64_C(0xd0aab84234131be0) /* 842 */, U64_C(0x08042a50b48b7eaf) /* 843 */,
+ U64_C(0x9997c4ee44a3ab35) /* 844 */, U64_C(0x829a7b49201799d0) /* 845 */,
+ U64_C(0x263b8307b7c54441) /* 846 */, U64_C(0x752f95f4fd6a6ca6) /* 847 */,
+ U64_C(0x927217402c08c6e5) /* 848 */, U64_C(0x2a8ab754a795d9ee) /* 849 */,
+ U64_C(0xa442f7552f72943d) /* 850 */, U64_C(0x2c31334e19781208) /* 851 */,
+ U64_C(0x4fa98d7ceaee6291) /* 852 */, U64_C(0x55c3862f665db309) /* 853 */,
+ U64_C(0xbd0610175d53b1f3) /* 854 */, U64_C(0x46fe6cb840413f27) /* 855 */,
+ U64_C(0x3fe03792df0cfa59) /* 856 */, U64_C(0xcfe700372eb85e8f) /* 857 */,
+ U64_C(0xa7be29e7adbce118) /* 858 */, U64_C(0xe544ee5cde8431dd) /* 859 */,
+ U64_C(0x8a781b1b41f1873e) /* 860 */, U64_C(0xa5c94c78a0d2f0e7) /* 861 */,
+ U64_C(0x39412e2877b60728) /* 862 */, U64_C(0xa1265ef3afc9a62c) /* 863 */,
+ U64_C(0xbcc2770c6a2506c5) /* 864 */, U64_C(0x3ab66dd5dce1ce12) /* 865 */,
+ U64_C(0xe65499d04a675b37) /* 866 */, U64_C(0x7d8f523481bfd216) /* 867 */,
+ U64_C(0x0f6f64fcec15f389) /* 868 */, U64_C(0x74efbe618b5b13c8) /* 869 */,
+ U64_C(0xacdc82b714273e1d) /* 870 */, U64_C(0xdd40bfe003199d17) /* 871 */,
+ U64_C(0x37e99257e7e061f8) /* 872 */, U64_C(0xfa52626904775aaa) /* 873 */,
+ U64_C(0x8bbbf63a463d56f9) /* 874 */, U64_C(0xf0013f1543a26e64) /* 875 */,
+ U64_C(0xa8307e9f879ec898) /* 876 */, U64_C(0xcc4c27a4150177cc) /* 877 */,
+ U64_C(0x1b432f2cca1d3348) /* 878 */, U64_C(0xde1d1f8f9f6fa013) /* 879 */,
+ U64_C(0x606602a047a7ddd6) /* 880 */, U64_C(0xd237ab64cc1cb2c7) /* 881 */,
+ U64_C(0x9b938e7225fcd1d3) /* 882 */, U64_C(0xec4e03708e0ff476) /* 883 */,
+ U64_C(0xfeb2fbda3d03c12d) /* 884 */, U64_C(0xae0bced2ee43889a) /* 885 */,
+ U64_C(0x22cb8923ebfb4f43) /* 886 */, U64_C(0x69360d013cf7396d) /* 887 */,
+ U64_C(0x855e3602d2d4e022) /* 888 */, U64_C(0x073805bad01f784c) /* 889 */,
+ U64_C(0x33e17a133852f546) /* 890 */, U64_C(0xdf4874058ac7b638) /* 891 */,
+ U64_C(0xba92b29c678aa14a) /* 892 */, U64_C(0x0ce89fc76cfaadcd) /* 893 */,
+ U64_C(0x5f9d4e0908339e34) /* 894 */, U64_C(0xf1afe9291f5923b9) /* 895 */,
+ U64_C(0x6e3480f60f4a265f) /* 896 */, U64_C(0xeebf3a2ab29b841c) /* 897 */,
+ U64_C(0xe21938a88f91b4ad) /* 898 */, U64_C(0x57dfeff845c6d3c3) /* 899 */,
+ U64_C(0x2f006b0bf62caaf2) /* 900 */, U64_C(0x62f479ef6f75ee78) /* 901 */,
+ U64_C(0x11a55ad41c8916a9) /* 902 */, U64_C(0xf229d29084fed453) /* 903 */,
+ U64_C(0x42f1c27b16b000e6) /* 904 */, U64_C(0x2b1f76749823c074) /* 905 */,
+ U64_C(0x4b76eca3c2745360) /* 906 */, U64_C(0x8c98f463b91691bd) /* 907 */,
+ U64_C(0x14bcc93cf1ade66a) /* 908 */, U64_C(0x8885213e6d458397) /* 909 */,
+ U64_C(0x8e177df0274d4711) /* 910 */, U64_C(0xb49b73b5503f2951) /* 911 */,
+ U64_C(0x10168168c3f96b6b) /* 912 */, U64_C(0x0e3d963b63cab0ae) /* 913 */,
+ U64_C(0x8dfc4b5655a1db14) /* 914 */, U64_C(0xf789f1356e14de5c) /* 915 */,
+ U64_C(0x683e68af4e51dac1) /* 916 */, U64_C(0xc9a84f9d8d4b0fd9) /* 917 */,
+ U64_C(0x3691e03f52a0f9d1) /* 918 */, U64_C(0x5ed86e46e1878e80) /* 919 */,
+ U64_C(0x3c711a0e99d07150) /* 920 */, U64_C(0x5a0865b20c4e9310) /* 921 */,
+ U64_C(0x56fbfc1fe4f0682e) /* 922 */, U64_C(0xea8d5de3105edf9b) /* 923 */,
+ U64_C(0x71abfdb12379187a) /* 924 */, U64_C(0x2eb99de1bee77b9c) /* 925 */,
+ U64_C(0x21ecc0ea33cf4523) /* 926 */, U64_C(0x59a4d7521805c7a1) /* 927 */,
+ U64_C(0x3896f5eb56ae7c72) /* 928 */, U64_C(0xaa638f3db18f75dc) /* 929 */,
+ U64_C(0x9f39358dabe9808e) /* 930 */, U64_C(0xb7defa91c00b72ac) /* 931 */,
+ U64_C(0x6b5541fd62492d92) /* 932 */, U64_C(0x6dc6dee8f92e4d5b) /* 933 */,
+ U64_C(0x353f57abc4beea7e) /* 934 */, U64_C(0x735769d6da5690ce) /* 935 */,
+ U64_C(0x0a234aa642391484) /* 936 */, U64_C(0xf6f9508028f80d9d) /* 937 */,
+ U64_C(0xb8e319a27ab3f215) /* 938 */, U64_C(0x31ad9c1151341a4d) /* 939 */,
+ U64_C(0x773c22a57bef5805) /* 940 */, U64_C(0x45c7561a07968633) /* 941 */,
+ U64_C(0xf913da9e249dbe36) /* 942 */, U64_C(0xda652d9b78a64c68) /* 943 */,
+ U64_C(0x4c27a97f3bc334ef) /* 944 */, U64_C(0x76621220e66b17f4) /* 945 */,
+ U64_C(0x967743899acd7d0b) /* 946 */, U64_C(0xf3ee5bcae0ed6782) /* 947 */,
+ U64_C(0x409f753600c879fc) /* 948 */, U64_C(0x06d09a39b5926db6) /* 949 */,
+ U64_C(0x6f83aeb0317ac588) /* 950 */, U64_C(0x01e6ca4a86381f21) /* 951 */,
+ U64_C(0x66ff3462d19f3025) /* 952 */, U64_C(0x72207c24ddfd3bfb) /* 953 */,
+ U64_C(0x4af6b6d3e2ece2eb) /* 954 */, U64_C(0x9c994dbec7ea08de) /* 955 */,
+ U64_C(0x49ace597b09a8bc4) /* 956 */, U64_C(0xb38c4766cf0797ba) /* 957 */,
+ U64_C(0x131b9373c57c2a75) /* 958 */, U64_C(0xb1822cce61931e58) /* 959 */,
+ U64_C(0x9d7555b909ba1c0c) /* 960 */, U64_C(0x127fafdd937d11d2) /* 961 */,
+ U64_C(0x29da3badc66d92e4) /* 962 */, U64_C(0xa2c1d57154c2ecbc) /* 963 */,
+ U64_C(0x58c5134d82f6fe24) /* 964 */, U64_C(0x1c3ae3515b62274f) /* 965 */,
+ U64_C(0xe907c82e01cb8126) /* 966 */, U64_C(0xf8ed091913e37fcb) /* 967 */,
+ U64_C(0x3249d8f9c80046c9) /* 968 */, U64_C(0x80cf9bede388fb63) /* 969 */,
+ U64_C(0x1881539a116cf19e) /* 970 */, U64_C(0x5103f3f76bd52457) /* 971 */,
+ U64_C(0x15b7e6f5ae47f7a8) /* 972 */, U64_C(0xdbd7c6ded47e9ccf) /* 973 */,
+ U64_C(0x44e55c410228bb1a) /* 974 */, U64_C(0xb647d4255edb4e99) /* 975 */,
+ U64_C(0x5d11882bb8aafc30) /* 976 */, U64_C(0xf5098bbb29d3212a) /* 977 */,
+ U64_C(0x8fb5ea14e90296b3) /* 978 */, U64_C(0x677b942157dd025a) /* 979 */,
+ U64_C(0xfb58e7c0a390acb5) /* 980 */, U64_C(0x89d3674c83bd4a01) /* 981 */,
+ U64_C(0x9e2da4df4bf3b93b) /* 982 */, U64_C(0xfcc41e328cab4829) /* 983 */,
+ U64_C(0x03f38c96ba582c52) /* 984 */, U64_C(0xcad1bdbd7fd85db2) /* 985 */,
+ U64_C(0xbbb442c16082ae83) /* 986 */, U64_C(0xb95fe86ba5da9ab0) /* 987 */,
+ U64_C(0xb22e04673771a93f) /* 988 */, U64_C(0x845358c9493152d8) /* 989 */,
+ U64_C(0xbe2a488697b4541e) /* 990 */, U64_C(0x95a2dc2dd38e6966) /* 991 */,
+ U64_C(0xc02c11ac923c852b) /* 992 */, U64_C(0x2388b1990df2a87b) /* 993 */,
+ U64_C(0x7c8008fa1b4f37be) /* 994 */, U64_C(0x1f70d0c84d54e503) /* 995 */,
+ U64_C(0x5490adec7ece57d4) /* 996 */, U64_C(0x002b3c27d9063a3a) /* 997 */,
+ U64_C(0x7eaea3848030a2bf) /* 998 */, U64_C(0xc602326ded2003c0) /* 999 */,
+ U64_C(0x83a7287d69a94086) /* 1000 */, U64_C(0xc57a5fcb30f57a8a) /* 1001 */,
+ U64_C(0xb56844e479ebe779) /* 1002 */, U64_C(0xa373b40f05dcbce9) /* 1003 */,
+ U64_C(0xd71a786e88570ee2) /* 1004 */, U64_C(0x879cbacdbde8f6a0) /* 1005 */,
+ U64_C(0x976ad1bcc164a32f) /* 1006 */, U64_C(0xab21e25e9666d78b) /* 1007 */,
+ U64_C(0x901063aae5e5c33c) /* 1008 */, U64_C(0x9818b34448698d90) /* 1009 */,
+ U64_C(0xe36487ae3e1e8abb) /* 1010 */, U64_C(0xafbdf931893bdcb4) /* 1011 */,
+ U64_C(0x6345a0dc5fbbd519) /* 1012 */, U64_C(0x8628fe269b9465ca) /* 1013 */,
+ U64_C(0x1e5d01603f9c51ec) /* 1014 */, U64_C(0x4de44006a15049b7) /* 1015 */,
+ U64_C(0xbf6c70e5f776cbb1) /* 1016 */, U64_C(0x411218f2ef552bed) /* 1017 */,
+ U64_C(0xcb0c0708705a36a3) /* 1018 */, U64_C(0xe74d14754f986044) /* 1019 */,
+ U64_C(0xcd56d9430ea8280e) /* 1020 */, U64_C(0xc12591d7535f5065) /* 1021 */,
+ U64_C(0xc83223f1720aef96) /* 1022 */, U64_C(0xc3a0396f7363a51f) /* 1023 */
+};
+
+static void
+do_init (void *context, int variant)
+{
+ TIGER_CONTEXT *hd = context;
+
+ hd->a = 0x0123456789abcdefLL;
+ hd->b = 0xfedcba9876543210LL;
+ hd->c = 0xf096a5b4c3b2e187LL;
+ hd->nblocks = 0;
+ hd->count = 0;
+ hd->variant = variant;
+}
+
+static void
+tiger_init (void *context)
+{
+ do_init (context, 0);
+}
+
+static void
+tiger1_init (void *context)
+{
+ do_init (context, 1);
+}
+
+static void
+tiger2_init (void *context)
+{
+ do_init (context, 2);
+}
+
+static void
+tiger_round( u64 *ra, u64 *rb, u64 *rc, u64 x, int mul )
+{
+ u64 a = *ra;
+ u64 b = *rb;
+ u64 c = *rc;
+
+ c ^= x;
+ a -= ( sbox1[ c & 0xff ] ^ sbox2[ (c >> 16) & 0xff ]
+ ^ sbox3[ (c >> 32) & 0xff ] ^ sbox4[ (c >> 48) & 0xff ]);
+ b += ( sbox4[ (c >> 8) & 0xff ] ^ sbox3[ (c >> 24) & 0xff ]
+ ^ sbox2[ (c >> 40) & 0xff ] ^ sbox1[ (c >> 56) & 0xff ]);
+ b *= mul;
+
+ *ra = a;
+ *rb = b;
+ *rc = c;
+}
+
+
+static void
+pass( u64 *ra, u64 *rb, u64 *rc, u64 *x, int mul )
+{
+ u64 a = *ra;
+ u64 b = *rb;
+ u64 c = *rc;
+
+ tiger_round( &a, &b, &c, x[0], mul );
+ tiger_round( &b, &c, &a, x[1], mul );
+ tiger_round( &c, &a, &b, x[2], mul );
+ tiger_round( &a, &b, &c, x[3], mul );
+ tiger_round( &b, &c, &a, x[4], mul );
+ tiger_round( &c, &a, &b, x[5], mul );
+ tiger_round( &a, &b, &c, x[6], mul );
+ tiger_round( &b, &c, &a, x[7], mul );
+
+ *ra = a;
+ *rb = b;
+ *rc = c;
+}
+
+
+static void
+key_schedule( u64 *x )
+{
+ x[0] -= x[7] ^ 0xa5a5a5a5a5a5a5a5LL;
+ x[1] ^= x[0];
+ x[2] += x[1];
+ x[3] -= x[2] ^ ((~x[1]) << 19 );
+ x[4] ^= x[3];
+ x[5] += x[4];
+ x[6] -= x[5] ^ ((~x[4]) >> 23 );
+ x[7] ^= x[6];
+ x[0] += x[7];
+ x[1] -= x[0] ^ ((~x[7]) << 19 );
+ x[2] ^= x[1];
+ x[3] += x[2];
+ x[4] -= x[3] ^ ((~x[2]) >> 23 );
+ x[5] ^= x[4];
+ x[6] += x[5];
+ x[7] -= x[6] ^ 0x0123456789abcdefLL;
+}
+
+
+/****************
+ * Transform the message DATA which consists of 512 bytes (8 words)
+ */
+static void
+transform ( TIGER_CONTEXT *hd, const unsigned char *data )
+{
+ u64 a,b,c,aa,bb,cc;
+ u64 x[8];
+#ifdef WORDS_BIGENDIAN
+#define MKWORD(d,n) \
+ ( ((u64)(d)[8*(n)+7]) << 56 | ((u64)(d)[8*(n)+6]) << 48 \
+ | ((u64)(d)[8*(n)+5]) << 40 | ((u64)(d)[8*(n)+4]) << 32 \
+ | ((u64)(d)[8*(n)+3]) << 24 | ((u64)(d)[8*(n)+2]) << 16 \
+ | ((u64)(d)[8*(n)+1]) << 8 | ((u64)(d)[8*(n) ]) )
+ x[0] = MKWORD(data, 0);
+ x[1] = MKWORD(data, 1);
+ x[2] = MKWORD(data, 2);
+ x[3] = MKWORD(data, 3);
+ x[4] = MKWORD(data, 4);
+ x[5] = MKWORD(data, 5);
+ x[6] = MKWORD(data, 6);
+ x[7] = MKWORD(data, 7);
+#undef MKWORD
+#else
+ memcpy( &x[0], data, 64 );
+#endif
+
+ /* save */
+ a = aa = hd->a;
+ b = bb = hd->b;
+ c = cc = hd->c;
+
+ pass( &a, &b, &c, x, 5);
+ key_schedule( x );
+ pass( &c, &a, &b, x, 7);
+ key_schedule( x );
+ pass( &b, &c, &a, x, 9);
+
+ /* feedforward */
+ a ^= aa;
+ b -= bb;
+ c += cc;
+ /* store */
+ hd->a = a;
+ hd->b = b;
+ hd->c = c;
+}
+
+
+
+/* Update the message digest with the contents
+ * of INBUF with length INLEN.
+ */
+static void
+tiger_write ( void *context, const void *inbuf_arg, size_t inlen)
+{
+ const unsigned char *inbuf = inbuf_arg;
+ TIGER_CONTEXT *hd = context;
+
+ if( hd->count == 64 ) /* flush the buffer */
+ {
+ transform( hd, hd->buf );
+ _gcry_burn_stack (21*8+11*sizeof(void*));
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if( !inbuf )
+ return;
+ if( hd->count )
+ {
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+ tiger_write( hd, NULL, 0 );
+ if( !inlen )
+ return;
+ }
+
+ while( inlen >= 64 )
+ {
+ transform( hd, inbuf );
+ hd->count = 0;
+ hd->nblocks++;
+ inlen -= 64;
+ inbuf += 64;
+ }
+ _gcry_burn_stack (21*8+11*sizeof(void*));
+ for( ; inlen && hd->count < 64; inlen-- )
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+
+/* The routine terminates the computation
+ */
+static void
+tiger_final( void *context )
+{
+ TIGER_CONTEXT *hd = context;
+ u32 t, msb, lsb;
+ byte *p;
+ byte pad = hd->variant == 2? 0x80 : 0x01;
+
+ tiger_write(hd, NULL, 0); /* flush */;
+
+ t = hd->nblocks;
+ /* multiply by 64 to make a byte count */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* add the count */
+ t = lsb;
+ if( (lsb += hd->count) < t )
+ msb++;
+ /* multiply by 8 to make a bit count */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if( hd->count < 56 ) /* enough room */
+ {
+ hd->buf[hd->count++] = pad;
+ while( hd->count < 56 )
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else /* need one extra block */
+ {
+ hd->buf[hd->count++] = pad; /* pad character */
+ while( hd->count < 64 )
+ hd->buf[hd->count++] = 0;
+ tiger_write(hd, NULL, 0); /* flush */;
+ memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
+ }
+ /* append the 64 bit count */
+ hd->buf[56] = lsb ;
+ hd->buf[57] = lsb >> 8;
+ hd->buf[58] = lsb >> 16;
+ hd->buf[59] = lsb >> 24;
+ hd->buf[60] = msb ;
+ hd->buf[61] = msb >> 8;
+ hd->buf[62] = msb >> 16;
+ hd->buf[63] = msb >> 24;
+ transform( hd, hd->buf );
+ _gcry_burn_stack (21*8+11*sizeof(void*));
+
+ p = hd->buf;
+#ifdef WORDS_BIGENDIAN
+#define X(a) do { *(u64*)p = hd->a ; p += 8; } while(0)
+#else /* little endian */
+#define X(a) do { *p++ = hd->a >> 56; *p++ = hd->a >> 48; \
+ *p++ = hd->a >> 40; *p++ = hd->a >> 32; \
+ *p++ = hd->a >> 24; *p++ = hd->a >> 16; \
+ *p++ = hd->a >> 8; *p++ = hd->a; } while(0)
+#endif
+#define Y(a) do { *p++ = hd->a ; *p++ = hd->a >> 8; \
+ *p++ = hd->a >> 16; *p++ = hd->a >> 24; \
+ *p++ = hd->a >> 32; *p++ = hd->a >> 40; \
+ *p++ = hd->a >> 48; *p++ = hd->a >> 56; } while(0)
+ if (hd->variant == 0)
+ {
+ X(a);
+ X(b);
+ X(c);
+ }
+ else
+ {
+ Y(a);
+ Y(b);
+ Y(c);
+ }
+#undef X
+#undef Y
+}
+
+static byte *
+tiger_read( void *context )
+{
+ TIGER_CONTEXT *hd = context;
+
+ return hd->buf;
+}
+
+
+
+/* This is the old TIGER variant based on the unfixed reference
+ implementation. IT was used in GnupG up to 1.3.2. We don't provide
+ an OID anymore because that would not be correct. */
+gcry_md_spec_t _gcry_digest_spec_tiger =
+ {
+ "TIGER192", NULL, 0, NULL, 24,
+ tiger_init, tiger_write, tiger_final, tiger_read,
+ sizeof (TIGER_CONTEXT)
+ };
+
+
+
+/* This is the fixed TIGER implementation. */
+static byte asn1[19] = /* Object ID is 1.3.6.1.4.1.11591.12.2 */
+ { 0x30, 0x29, 0x30, 0x0d, 0x06, 0x09, 0x2b, 0x06,
+ 0x01, 0x04, 0x01, 0xda, 0x47, 0x0c, 0x02,
+ 0x05, 0x00, 0x04, 0x18 };
+
+static gcry_md_oid_spec_t oid_spec_tiger1[] =
+ {
+ /* GNU.digestAlgorithm TIGER */
+ { "1.3.6.1.4.1.11591.12.2" },
+ { NULL }
+ };
+
+gcry_md_spec_t _gcry_digest_spec_tiger1 =
+ {
+ "TIGER", asn1, DIM (asn1), oid_spec_tiger1, 24,
+ tiger1_init, tiger_write, tiger_final, tiger_read,
+ sizeof (TIGER_CONTEXT)
+ };
+
+
+
+/* This is TIGER2 which usues a changed padding algorithm. */
+gcry_md_spec_t _gcry_digest_spec_tiger2 =
+ {
+ "TIGER2", NULL, 0, NULL, 24,
+ tiger2_init, tiger_write, tiger_final, tiger_read,
+ sizeof (TIGER_CONTEXT)
+ };
+
+#endif /* HAVE_U64_TYPEDEF */
diff --git a/grub-core/lib/libgcrypt/cipher/twofish.c b/grub-core/lib/libgcrypt/cipher/twofish.c
new file mode 100644
index 0000000..f1a93ca
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/twofish.c
@@ -0,0 +1,1040 @@
+/* Twofish for GPG
+ * Copyright (C) 1998, 2002, 2003 Free Software Foundation, Inc.
+ * Written by Matthew Skala <mskala@ansuz.sooke.bc.ca>, July 26, 1998
+ * 256-bit key length added March 20, 1999
+ * Some modifications to reduce the text size by Werner Koch, April, 1998
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ ********************************************************************
+ *
+ * This code is a "clean room" implementation, written from the paper
+ * _Twofish: A 128-Bit Block Cipher_ by Bruce Schneier, John Kelsey,
+ * Doug Whiting, David Wagner, Chris Hall, and Niels Ferguson, available
+ * through http://www.counterpane.com/twofish.html
+ *
+ * For background information on multiplication in finite fields, used for
+ * the matrix operations in the key schedule, see the book _Contemporary
+ * Abstract Algebra_ by Joseph A. Gallian, especially chapter 22 in the
+ * Third Edition.
+ *
+ * Only the 128- and 256-bit key sizes are supported. This code is intended
+ * for GNU C on a 32-bit system, but it should work almost anywhere. Loops
+ * are unrolled, precomputation tables are used, etc., for maximum speed at
+ * some cost in memory consumption. */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h> /* for memcmp() */
+
+#include "types.h" /* for byte and u32 typedefs */
+#include "g10lib.h"
+#include "cipher.h"
+
+/* Prototype for the self-test function. */
+static const char *selftest(void);
+
+/* Structure for an expanded Twofish key. s contains the key-dependent
+ * S-boxes composed with the MDS matrix; w contains the eight "whitening"
+ * subkeys, K[0] through K[7]. k holds the remaining, "round" subkeys. Note
+ * that k[i] corresponds to what the Twofish paper calls K[i+8]. */
+typedef struct {
+ u32 s[4][256], w[8], k[32];
+} TWOFISH_context;
+
+/* These two tables are the q0 and q1 permutations, exactly as described in
+ * the Twofish paper. */
+
+static const byte q0[256] = {
+ 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78,
+ 0xE4, 0xDD, 0xD1, 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C,
+ 0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, 0xF2, 0xD0, 0x8B, 0x30,
+ 0x84, 0x54, 0xDF, 0x23, 0x19, 0x5B, 0x3D, 0x59, 0xF3, 0xAE, 0xA2, 0x82,
+ 0x63, 0x01, 0x83, 0x2E, 0xD9, 0x51, 0x9B, 0x7C, 0xA6, 0xEB, 0xA5, 0xBE,
+ 0x16, 0x0C, 0xE3, 0x61, 0xC0, 0x8C, 0x3A, 0xF5, 0x73, 0x2C, 0x25, 0x0B,
+ 0xBB, 0x4E, 0x89, 0x6B, 0x53, 0x6A, 0xB4, 0xF1, 0xE1, 0xE6, 0xBD, 0x45,
+ 0xE2, 0xF4, 0xB6, 0x66, 0xCC, 0x95, 0x03, 0x56, 0xD4, 0x1C, 0x1E, 0xD7,
+ 0xFB, 0xC3, 0x8E, 0xB5, 0xE9, 0xCF, 0xBF, 0xBA, 0xEA, 0x77, 0x39, 0xAF,
+ 0x33, 0xC9, 0x62, 0x71, 0x81, 0x79, 0x09, 0xAD, 0x24, 0xCD, 0xF9, 0xD8,
+ 0xE5, 0xC5, 0xB9, 0x4D, 0x44, 0x08, 0x86, 0xE7, 0xA1, 0x1D, 0xAA, 0xED,
+ 0x06, 0x70, 0xB2, 0xD2, 0x41, 0x7B, 0xA0, 0x11, 0x31, 0xC2, 0x27, 0x90,
+ 0x20, 0xF6, 0x60, 0xFF, 0x96, 0x5C, 0xB1, 0xAB, 0x9E, 0x9C, 0x52, 0x1B,
+ 0x5F, 0x93, 0x0A, 0xEF, 0x91, 0x85, 0x49, 0xEE, 0x2D, 0x4F, 0x8F, 0x3B,
+ 0x47, 0x87, 0x6D, 0x46, 0xD6, 0x3E, 0x69, 0x64, 0x2A, 0xCE, 0xCB, 0x2F,
+ 0xFC, 0x97, 0x05, 0x7A, 0xAC, 0x7F, 0xD5, 0x1A, 0x4B, 0x0E, 0xA7, 0x5A,
+ 0x28, 0x14, 0x3F, 0x29, 0x88, 0x3C, 0x4C, 0x02, 0xB8, 0xDA, 0xB0, 0x17,
+ 0x55, 0x1F, 0x8A, 0x7D, 0x57, 0xC7, 0x8D, 0x74, 0xB7, 0xC4, 0x9F, 0x72,
+ 0x7E, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34, 0x6E, 0x50, 0xDE, 0x68,
+ 0x65, 0xBC, 0xDB, 0xF8, 0xC8, 0xA8, 0x2B, 0x40, 0xDC, 0xFE, 0x32, 0xA4,
+ 0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, 0x6F, 0x9D, 0x36, 0x42,
+ 0x4A, 0x5E, 0xC1, 0xE0
+};
+
+static const byte q1[256] = {
+ 0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B,
+ 0x45, 0x7D, 0xE8, 0x4B, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1,
+ 0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, 0x5E, 0xBA, 0xAE, 0x5B,
+ 0x8A, 0x00, 0xBC, 0x9D, 0x6D, 0xC1, 0xB1, 0x0E, 0x80, 0x5D, 0xD2, 0xD5,
+ 0xA0, 0x84, 0x07, 0x14, 0xB5, 0x90, 0x2C, 0xA3, 0xB2, 0x73, 0x4C, 0x54,
+ 0x92, 0x74, 0x36, 0x51, 0x38, 0xB0, 0xBD, 0x5A, 0xFC, 0x60, 0x62, 0x96,
+ 0x6C, 0x42, 0xF7, 0x10, 0x7C, 0x28, 0x27, 0x8C, 0x13, 0x95, 0x9C, 0xC7,
+ 0x24, 0x46, 0x3B, 0x70, 0xCA, 0xE3, 0x85, 0xCB, 0x11, 0xD0, 0x93, 0xB8,
+ 0xA6, 0x83, 0x20, 0xFF, 0x9F, 0x77, 0xC3, 0xCC, 0x03, 0x6F, 0x08, 0xBF,
+ 0x40, 0xE7, 0x2B, 0xE2, 0x79, 0x0C, 0xAA, 0x82, 0x41, 0x3A, 0xEA, 0xB9,
+ 0xE4, 0x9A, 0xA4, 0x97, 0x7E, 0xDA, 0x7A, 0x17, 0x66, 0x94, 0xA1, 0x1D,
+ 0x3D, 0xF0, 0xDE, 0xB3, 0x0B, 0x72, 0xA7, 0x1C, 0xEF, 0xD1, 0x53, 0x3E,
+ 0x8F, 0x33, 0x26, 0x5F, 0xEC, 0x76, 0x2A, 0x49, 0x81, 0x88, 0xEE, 0x21,
+ 0xC4, 0x1A, 0xEB, 0xD9, 0xC5, 0x39, 0x99, 0xCD, 0xAD, 0x31, 0x8B, 0x01,
+ 0x18, 0x23, 0xDD, 0x1F, 0x4E, 0x2D, 0xF9, 0x48, 0x4F, 0xF2, 0x65, 0x8E,
+ 0x78, 0x5C, 0x58, 0x19, 0x8D, 0xE5, 0x98, 0x57, 0x67, 0x7F, 0x05, 0x64,
+ 0xAF, 0x63, 0xB6, 0xFE, 0xF5, 0xB7, 0x3C, 0xA5, 0xCE, 0xE9, 0x68, 0x44,
+ 0xE0, 0x4D, 0x43, 0x69, 0x29, 0x2E, 0xAC, 0x15, 0x59, 0xA8, 0x0A, 0x9E,
+ 0x6E, 0x47, 0xDF, 0x34, 0x35, 0x6A, 0xCF, 0xDC, 0x22, 0xC9, 0xC0, 0x9B,
+ 0x89, 0xD4, 0xED, 0xAB, 0x12, 0xA2, 0x0D, 0x52, 0xBB, 0x02, 0x2F, 0xA9,
+ 0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, 0x16, 0x25, 0x86, 0x56,
+ 0x55, 0x09, 0xBE, 0x91
+};
+
+/* These MDS tables are actually tables of MDS composed with q0 and q1,
+ * because it is only ever used that way and we can save some time by
+ * precomputing. Of course the main saving comes from precomputing the
+ * GF(2^8) multiplication involved in the MDS matrix multiply; by looking
+ * things up in these tables we reduce the matrix multiply to four lookups
+ * and three XORs. Semi-formally, the definition of these tables is:
+ * mds[0][i] = MDS (q1[i] 0 0 0)^T mds[1][i] = MDS (0 q0[i] 0 0)^T
+ * mds[2][i] = MDS (0 0 q1[i] 0)^T mds[3][i] = MDS (0 0 0 q0[i])^T
+ * where ^T means "transpose", the matrix multiply is performed in GF(2^8)
+ * represented as GF(2)[x]/v(x) where v(x)=x^8+x^6+x^5+x^3+1 as described
+ * by Schneier et al, and I'm casually glossing over the byte/word
+ * conversion issues. */
+
+static const u32 mds[4][256] = {
+ {0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B,
+ 0xE2E22BFB, 0x9E9EFAC8, 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B,
+ 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, 0x3C3C57D6, 0x93938A32,
+ 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1,
+ 0x24243C30, 0x5151E20F, 0xBABAC6F8, 0x4A4AF31B, 0xBFBF4887, 0x0D0D70FA,
+ 0xB0B0B306, 0x7575DE3F, 0xD2D2FD5E, 0x7D7D20BA, 0x666631AE, 0x3A3AA35B,
+ 0x59591C8A, 0x00000000, 0xCDCD93BC, 0x1A1AE09D, 0xAEAE2C6D, 0x7F7FABC1,
+ 0x2B2BC7B1, 0xBEBEB90E, 0xE0E0A080, 0x8A8A105D, 0x3B3B52D2, 0x6464BAD5,
+ 0xD8D888A0, 0xE7E7A584, 0x5F5FE807, 0x1B1B1114, 0x2C2CC2B5, 0xFCFCB490,
+ 0x3131272C, 0x808065A3, 0x73732AB2, 0x0C0C8173, 0x79795F4C, 0x6B6B4154,
+ 0x4B4B0292, 0x53536974, 0x94948F36, 0x83831F51, 0x2A2A3638, 0xC4C49CB0,
+ 0x2222C8BD, 0xD5D5F85A, 0xBDBDC3FC, 0x48487860, 0xFFFFCE62, 0x4C4C0796,
+ 0x4141776C, 0xC7C7E642, 0xEBEB24F7, 0x1C1C1410, 0x5D5D637C, 0x36362228,
+ 0x6767C027, 0xE9E9AF8C, 0x4444F913, 0x1414EA95, 0xF5F5BB9C, 0xCFCF18C7,
+ 0x3F3F2D24, 0xC0C0E346, 0x7272DB3B, 0x54546C70, 0x29294CCA, 0xF0F035E3,
+ 0x0808FE85, 0xC6C617CB, 0xF3F34F11, 0x8C8CE4D0, 0xA4A45993, 0xCACA96B8,
+ 0x68683BA6, 0xB8B84D83, 0x38382820, 0xE5E52EFF, 0xADAD569F, 0x0B0B8477,
+ 0xC8C81DC3, 0x9999FFCC, 0x5858ED03, 0x19199A6F, 0x0E0E0A08, 0x95957EBF,
+ 0x70705040, 0xF7F730E7, 0x6E6ECF2B, 0x1F1F6EE2, 0xB5B53D79, 0x09090F0C,
+ 0x616134AA, 0x57571682, 0x9F9F0B41, 0x9D9D803A, 0x111164EA, 0x2525CDB9,
+ 0xAFAFDDE4, 0x4545089A, 0xDFDF8DA4, 0xA3A35C97, 0xEAEAD57E, 0x353558DA,
+ 0xEDEDD07A, 0x4343FC17, 0xF8F8CB66, 0xFBFBB194, 0x3737D3A1, 0xFAFA401D,
+ 0xC2C2683D, 0xB4B4CCF0, 0x32325DDE, 0x9C9C71B3, 0x5656E70B, 0xE3E3DA72,
+ 0x878760A7, 0x15151B1C, 0xF9F93AEF, 0x6363BFD1, 0x3434A953, 0x9A9A853E,
+ 0xB1B1428F, 0x7C7CD133, 0x88889B26, 0x3D3DA65F, 0xA1A1D7EC, 0xE4E4DF76,
+ 0x8181942A, 0x91910149, 0x0F0FFB81, 0xEEEEAA88, 0x161661EE, 0xD7D77321,
+ 0x9797F5C4, 0xA5A5A81A, 0xFEFE3FEB, 0x6D6DB5D9, 0x7878AEC5, 0xC5C56D39,
+ 0x1D1DE599, 0x7676A4CD, 0x3E3EDCAD, 0xCBCB6731, 0xB6B6478B, 0xEFEF5B01,
+ 0x12121E18, 0x6060C523, 0x6A6AB0DD, 0x4D4DF61F, 0xCECEE94E, 0xDEDE7C2D,
+ 0x55559DF9, 0x7E7E5A48, 0x2121B24F, 0x03037AF2, 0xA0A02665, 0x5E5E198E,
+ 0x5A5A6678, 0x65654B5C, 0x62624E58, 0xFDFD4519, 0x0606F48D, 0x404086E5,
+ 0xF2F2BE98, 0x3333AC57, 0x17179067, 0x05058E7F, 0xE8E85E05, 0x4F4F7D64,
+ 0x89896AAF, 0x10109563, 0x74742FB6, 0x0A0A75FE, 0x5C5C92F5, 0x9B9B74B7,
+ 0x2D2D333C, 0x3030D6A5, 0x2E2E49CE, 0x494989E9, 0x46467268, 0x77775544,
+ 0xA8A8D8E0, 0x9696044D, 0x2828BD43, 0xA9A92969, 0xD9D97929, 0x8686912E,
+ 0xD1D187AC, 0xF4F44A15, 0x8D8D1559, 0xD6D682A8, 0xB9B9BC0A, 0x42420D9E,
+ 0xF6F6C16E, 0x2F2FB847, 0xDDDD06DF, 0x23233934, 0xCCCC6235, 0xF1F1C46A,
+ 0xC1C112CF, 0x8585EBDC, 0x8F8F9E22, 0x7171A1C9, 0x9090F0C0, 0xAAAA539B,
+ 0x0101F189, 0x8B8BE1D4, 0x4E4E8CED, 0x8E8E6FAB, 0xABABA212, 0x6F6F3EA2,
+ 0xE6E6540D, 0xDBDBF252, 0x92927BBB, 0xB7B7B602, 0x6969CA2F, 0x3939D9A9,
+ 0xD3D30CD7, 0xA7A72361, 0xA2A2AD1E, 0xC3C399B4, 0x6C6C4450, 0x07070504,
+ 0x04047FF6, 0x272746C2, 0xACACA716, 0xD0D07625, 0x50501386, 0xDCDCF756,
+ 0x84841A55, 0xE1E15109, 0x7A7A25BE, 0x1313EF91},
+
+ {0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252,
+ 0xA3658080, 0x76DFE4E4, 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A,
+ 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, 0x0D54E6E6, 0xC6432020,
+ 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141,
+ 0x43BD2828, 0x7532BCBC, 0x37D47B7B, 0x269B8888, 0xFA700D0D, 0x13F94444,
+ 0x94B1FBFB, 0x485A7E7E, 0xF27A0303, 0xD0E48C8C, 0x8B47B6B6, 0x303C2424,
+ 0x84A5E7E7, 0x54416B6B, 0xDF06DDDD, 0x23C56060, 0x1945FDFD, 0x5BA33A3A,
+ 0x3D68C2C2, 0x59158D8D, 0xF321ECEC, 0xAE316666, 0xA23E6F6F, 0x82165757,
+ 0x63951010, 0x015BEFEF, 0x834DB8B8, 0x2E918686, 0xD9B56D6D, 0x511F8383,
+ 0x9B53AAAA, 0x7C635D5D, 0xA63B6868, 0xEB3FFEFE, 0xA5D63030, 0xBE257A7A,
+ 0x16A7ACAC, 0x0C0F0909, 0xE335F0F0, 0x6123A7A7, 0xC0F09090, 0x8CAFE9E9,
+ 0x3A809D9D, 0xF5925C5C, 0x73810C0C, 0x2C273131, 0x2576D0D0, 0x0BE75656,
+ 0xBB7B9292, 0x4EE9CECE, 0x89F10101, 0x6B9F1E1E, 0x53A93434, 0x6AC4F1F1,
+ 0xB499C3C3, 0xF1975B5B, 0xE1834747, 0xE66B1818, 0xBDC82222, 0x450E9898,
+ 0xE26E1F1F, 0xF4C9B3B3, 0xB62F7474, 0x66CBF8F8, 0xCCFF9999, 0x95EA1414,
+ 0x03ED5858, 0x56F7DCDC, 0xD4E18B8B, 0x1C1B1515, 0x1EADA2A2, 0xD70CD3D3,
+ 0xFB2BE2E2, 0xC31DC8C8, 0x8E195E5E, 0xB5C22C2C, 0xE9894949, 0xCF12C1C1,
+ 0xBF7E9595, 0xBA207D7D, 0xEA641111, 0x77840B0B, 0x396DC5C5, 0xAF6A8989,
+ 0x33D17C7C, 0xC9A17171, 0x62CEFFFF, 0x7137BBBB, 0x81FB0F0F, 0x793DB5B5,
+ 0x0951E1E1, 0xADDC3E3E, 0x242D3F3F, 0xCDA47676, 0xF99D5555, 0xD8EE8282,
+ 0xE5864040, 0xC5AE7878, 0xB9CD2525, 0x4D049696, 0x44557777, 0x080A0E0E,
+ 0x86135050, 0xE730F7F7, 0xA1D33737, 0x1D40FAFA, 0xAA346161, 0xED8C4E4E,
+ 0x06B3B0B0, 0x706C5454, 0xB22A7373, 0xD2523B3B, 0x410B9F9F, 0x7B8B0202,
+ 0xA088D8D8, 0x114FF3F3, 0x3167CBCB, 0xC2462727, 0x27C06767, 0x90B4FCFC,
+ 0x20283838, 0xF67F0404, 0x60784848, 0xFF2EE5E5, 0x96074C4C, 0x5C4B6565,
+ 0xB1C72B2B, 0xAB6F8E8E, 0x9E0D4242, 0x9CBBF5F5, 0x52F2DBDB, 0x1BF34A4A,
+ 0x5FA63D3D, 0x9359A4A4, 0x0ABCB9B9, 0xEF3AF9F9, 0x91EF1313, 0x85FE0808,
+ 0x49019191, 0xEE611616, 0x2D7CDEDE, 0x4FB22121, 0x8F42B1B1, 0x3BDB7272,
+ 0x47B82F2F, 0x8748BFBF, 0x6D2CAEAE, 0x46E3C0C0, 0xD6573C3C, 0x3E859A9A,
+ 0x6929A9A9, 0x647D4F4F, 0x2A948181, 0xCE492E2E, 0xCB17C6C6, 0x2FCA6969,
+ 0xFCC3BDBD, 0x975CA3A3, 0x055EE8E8, 0x7AD0EDED, 0xAC87D1D1, 0x7F8E0505,
+ 0xD5BA6464, 0x1AA8A5A5, 0x4BB72626, 0x0EB9BEBE, 0xA7608787, 0x5AF8D5D5,
+ 0x28223636, 0x14111B1B, 0x3FDE7575, 0x2979D9D9, 0x88AAEEEE, 0x3C332D2D,
+ 0x4C5F7979, 0x02B6B7B7, 0xB896CACA, 0xDA583535, 0xB09CC4C4, 0x17FC4343,
+ 0x551A8484, 0x1FF64D4D, 0x8A1C5959, 0x7D38B2B2, 0x57AC3333, 0xC718CFCF,
+ 0x8DF40606, 0x74695353, 0xB7749B9B, 0xC4F59797, 0x9F56ADAD, 0x72DAE3E3,
+ 0x7ED5EAEA, 0x154AF4F4, 0x229E8F8F, 0x12A2ABAB, 0x584E6262, 0x07E85F5F,
+ 0x99E51D1D, 0x34392323, 0x6EC1F6F6, 0x50446C6C, 0xDE5D3232, 0x68724646,
+ 0x6526A0A0, 0xBC93CDCD, 0xDB03DADA, 0xF8C6BABA, 0xC8FA9E9E, 0xA882D6D6,
+ 0x2BCF6E6E, 0x40507070, 0xDCEB8585, 0xFE750A0A, 0x328A9393, 0xA48DDFDF,
+ 0xCA4C2929, 0x10141C1C, 0x2173D7D7, 0xF0CCB4B4, 0xD309D4D4, 0x5D108A8A,
+ 0x0FE25151, 0x00000000, 0x6F9A1919, 0x9DE01A1A, 0x368F9494, 0x42E6C7C7,
+ 0x4AECC9C9, 0x5EFDD2D2, 0xC1AB7F7F, 0xE0D8A8A8},
+
+ {0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B,
+ 0xE2FBE22B, 0x9EC89EFA, 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F,
+ 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, 0x3CD63C57, 0x9332938A,
+ 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783,
+ 0x2430243C, 0x510F51E2, 0xBAF8BAC6, 0x4A1B4AF3, 0xBF87BF48, 0x0DFA0D70,
+ 0xB006B0B3, 0x753F75DE, 0xD25ED2FD, 0x7DBA7D20, 0x66AE6631, 0x3A5B3AA3,
+ 0x598A591C, 0x00000000, 0xCDBCCD93, 0x1A9D1AE0, 0xAE6DAE2C, 0x7FC17FAB,
+ 0x2BB12BC7, 0xBE0EBEB9, 0xE080E0A0, 0x8A5D8A10, 0x3BD23B52, 0x64D564BA,
+ 0xD8A0D888, 0xE784E7A5, 0x5F075FE8, 0x1B141B11, 0x2CB52CC2, 0xFC90FCB4,
+ 0x312C3127, 0x80A38065, 0x73B2732A, 0x0C730C81, 0x794C795F, 0x6B546B41,
+ 0x4B924B02, 0x53745369, 0x9436948F, 0x8351831F, 0x2A382A36, 0xC4B0C49C,
+ 0x22BD22C8, 0xD55AD5F8, 0xBDFCBDC3, 0x48604878, 0xFF62FFCE, 0x4C964C07,
+ 0x416C4177, 0xC742C7E6, 0xEBF7EB24, 0x1C101C14, 0x5D7C5D63, 0x36283622,
+ 0x672767C0, 0xE98CE9AF, 0x441344F9, 0x149514EA, 0xF59CF5BB, 0xCFC7CF18,
+ 0x3F243F2D, 0xC046C0E3, 0x723B72DB, 0x5470546C, 0x29CA294C, 0xF0E3F035,
+ 0x088508FE, 0xC6CBC617, 0xF311F34F, 0x8CD08CE4, 0xA493A459, 0xCAB8CA96,
+ 0x68A6683B, 0xB883B84D, 0x38203828, 0xE5FFE52E, 0xAD9FAD56, 0x0B770B84,
+ 0xC8C3C81D, 0x99CC99FF, 0x580358ED, 0x196F199A, 0x0E080E0A, 0x95BF957E,
+ 0x70407050, 0xF7E7F730, 0x6E2B6ECF, 0x1FE21F6E, 0xB579B53D, 0x090C090F,
+ 0x61AA6134, 0x57825716, 0x9F419F0B, 0x9D3A9D80, 0x11EA1164, 0x25B925CD,
+ 0xAFE4AFDD, 0x459A4508, 0xDFA4DF8D, 0xA397A35C, 0xEA7EEAD5, 0x35DA3558,
+ 0xED7AEDD0, 0x431743FC, 0xF866F8CB, 0xFB94FBB1, 0x37A137D3, 0xFA1DFA40,
+ 0xC23DC268, 0xB4F0B4CC, 0x32DE325D, 0x9CB39C71, 0x560B56E7, 0xE372E3DA,
+ 0x87A78760, 0x151C151B, 0xF9EFF93A, 0x63D163BF, 0x345334A9, 0x9A3E9A85,
+ 0xB18FB142, 0x7C337CD1, 0x8826889B, 0x3D5F3DA6, 0xA1ECA1D7, 0xE476E4DF,
+ 0x812A8194, 0x91499101, 0x0F810FFB, 0xEE88EEAA, 0x16EE1661, 0xD721D773,
+ 0x97C497F5, 0xA51AA5A8, 0xFEEBFE3F, 0x6DD96DB5, 0x78C578AE, 0xC539C56D,
+ 0x1D991DE5, 0x76CD76A4, 0x3EAD3EDC, 0xCB31CB67, 0xB68BB647, 0xEF01EF5B,
+ 0x1218121E, 0x602360C5, 0x6ADD6AB0, 0x4D1F4DF6, 0xCE4ECEE9, 0xDE2DDE7C,
+ 0x55F9559D, 0x7E487E5A, 0x214F21B2, 0x03F2037A, 0xA065A026, 0x5E8E5E19,
+ 0x5A785A66, 0x655C654B, 0x6258624E, 0xFD19FD45, 0x068D06F4, 0x40E54086,
+ 0xF298F2BE, 0x335733AC, 0x17671790, 0x057F058E, 0xE805E85E, 0x4F644F7D,
+ 0x89AF896A, 0x10631095, 0x74B6742F, 0x0AFE0A75, 0x5CF55C92, 0x9BB79B74,
+ 0x2D3C2D33, 0x30A530D6, 0x2ECE2E49, 0x49E94989, 0x46684672, 0x77447755,
+ 0xA8E0A8D8, 0x964D9604, 0x284328BD, 0xA969A929, 0xD929D979, 0x862E8691,
+ 0xD1ACD187, 0xF415F44A, 0x8D598D15, 0xD6A8D682, 0xB90AB9BC, 0x429E420D,
+ 0xF66EF6C1, 0x2F472FB8, 0xDDDFDD06, 0x23342339, 0xCC35CC62, 0xF16AF1C4,
+ 0xC1CFC112, 0x85DC85EB, 0x8F228F9E, 0x71C971A1, 0x90C090F0, 0xAA9BAA53,
+ 0x018901F1, 0x8BD48BE1, 0x4EED4E8C, 0x8EAB8E6F, 0xAB12ABA2, 0x6FA26F3E,
+ 0xE60DE654, 0xDB52DBF2, 0x92BB927B, 0xB702B7B6, 0x692F69CA, 0x39A939D9,
+ 0xD3D7D30C, 0xA761A723, 0xA21EA2AD, 0xC3B4C399, 0x6C506C44, 0x07040705,
+ 0x04F6047F, 0x27C22746, 0xAC16ACA7, 0xD025D076, 0x50865013, 0xDC56DCF7,
+ 0x8455841A, 0xE109E151, 0x7ABE7A25, 0x139113EF},
+
+ {0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98,
+ 0x6580A365, 0xDFE476DF, 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866,
+ 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, 0x54E60D54, 0x4320C643,
+ 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77,
+ 0xBD2843BD, 0x32BC7532, 0xD47B37D4, 0x9B88269B, 0x700DFA70, 0xF94413F9,
+ 0xB1FB94B1, 0x5A7E485A, 0x7A03F27A, 0xE48CD0E4, 0x47B68B47, 0x3C24303C,
+ 0xA5E784A5, 0x416B5441, 0x06DDDF06, 0xC56023C5, 0x45FD1945, 0xA33A5BA3,
+ 0x68C23D68, 0x158D5915, 0x21ECF321, 0x3166AE31, 0x3E6FA23E, 0x16578216,
+ 0x95106395, 0x5BEF015B, 0x4DB8834D, 0x91862E91, 0xB56DD9B5, 0x1F83511F,
+ 0x53AA9B53, 0x635D7C63, 0x3B68A63B, 0x3FFEEB3F, 0xD630A5D6, 0x257ABE25,
+ 0xA7AC16A7, 0x0F090C0F, 0x35F0E335, 0x23A76123, 0xF090C0F0, 0xAFE98CAF,
+ 0x809D3A80, 0x925CF592, 0x810C7381, 0x27312C27, 0x76D02576, 0xE7560BE7,
+ 0x7B92BB7B, 0xE9CE4EE9, 0xF10189F1, 0x9F1E6B9F, 0xA93453A9, 0xC4F16AC4,
+ 0x99C3B499, 0x975BF197, 0x8347E183, 0x6B18E66B, 0xC822BDC8, 0x0E98450E,
+ 0x6E1FE26E, 0xC9B3F4C9, 0x2F74B62F, 0xCBF866CB, 0xFF99CCFF, 0xEA1495EA,
+ 0xED5803ED, 0xF7DC56F7, 0xE18BD4E1, 0x1B151C1B, 0xADA21EAD, 0x0CD3D70C,
+ 0x2BE2FB2B, 0x1DC8C31D, 0x195E8E19, 0xC22CB5C2, 0x8949E989, 0x12C1CF12,
+ 0x7E95BF7E, 0x207DBA20, 0x6411EA64, 0x840B7784, 0x6DC5396D, 0x6A89AF6A,
+ 0xD17C33D1, 0xA171C9A1, 0xCEFF62CE, 0x37BB7137, 0xFB0F81FB, 0x3DB5793D,
+ 0x51E10951, 0xDC3EADDC, 0x2D3F242D, 0xA476CDA4, 0x9D55F99D, 0xEE82D8EE,
+ 0x8640E586, 0xAE78C5AE, 0xCD25B9CD, 0x04964D04, 0x55774455, 0x0A0E080A,
+ 0x13508613, 0x30F7E730, 0xD337A1D3, 0x40FA1D40, 0x3461AA34, 0x8C4EED8C,
+ 0xB3B006B3, 0x6C54706C, 0x2A73B22A, 0x523BD252, 0x0B9F410B, 0x8B027B8B,
+ 0x88D8A088, 0x4FF3114F, 0x67CB3167, 0x4627C246, 0xC06727C0, 0xB4FC90B4,
+ 0x28382028, 0x7F04F67F, 0x78486078, 0x2EE5FF2E, 0x074C9607, 0x4B655C4B,
+ 0xC72BB1C7, 0x6F8EAB6F, 0x0D429E0D, 0xBBF59CBB, 0xF2DB52F2, 0xF34A1BF3,
+ 0xA63D5FA6, 0x59A49359, 0xBCB90ABC, 0x3AF9EF3A, 0xEF1391EF, 0xFE0885FE,
+ 0x01914901, 0x6116EE61, 0x7CDE2D7C, 0xB2214FB2, 0x42B18F42, 0xDB723BDB,
+ 0xB82F47B8, 0x48BF8748, 0x2CAE6D2C, 0xE3C046E3, 0x573CD657, 0x859A3E85,
+ 0x29A96929, 0x7D4F647D, 0x94812A94, 0x492ECE49, 0x17C6CB17, 0xCA692FCA,
+ 0xC3BDFCC3, 0x5CA3975C, 0x5EE8055E, 0xD0ED7AD0, 0x87D1AC87, 0x8E057F8E,
+ 0xBA64D5BA, 0xA8A51AA8, 0xB7264BB7, 0xB9BE0EB9, 0x6087A760, 0xF8D55AF8,
+ 0x22362822, 0x111B1411, 0xDE753FDE, 0x79D92979, 0xAAEE88AA, 0x332D3C33,
+ 0x5F794C5F, 0xB6B702B6, 0x96CAB896, 0x5835DA58, 0x9CC4B09C, 0xFC4317FC,
+ 0x1A84551A, 0xF64D1FF6, 0x1C598A1C, 0x38B27D38, 0xAC3357AC, 0x18CFC718,
+ 0xF4068DF4, 0x69537469, 0x749BB774, 0xF597C4F5, 0x56AD9F56, 0xDAE372DA,
+ 0xD5EA7ED5, 0x4AF4154A, 0x9E8F229E, 0xA2AB12A2, 0x4E62584E, 0xE85F07E8,
+ 0xE51D99E5, 0x39233439, 0xC1F66EC1, 0x446C5044, 0x5D32DE5D, 0x72466872,
+ 0x26A06526, 0x93CDBC93, 0x03DADB03, 0xC6BAF8C6, 0xFA9EC8FA, 0x82D6A882,
+ 0xCF6E2BCF, 0x50704050, 0xEB85DCEB, 0x750AFE75, 0x8A93328A, 0x8DDFA48D,
+ 0x4C29CA4C, 0x141C1014, 0x73D72173, 0xCCB4F0CC, 0x09D4D309, 0x108A5D10,
+ 0xE2510FE2, 0x00000000, 0x9A196F9A, 0xE01A9DE0, 0x8F94368F, 0xE6C742E6,
+ 0xECC94AEC, 0xFDD25EFD, 0xAB7FC1AB, 0xD8A8E0D8}
+};
+
+/* The exp_to_poly and poly_to_exp tables are used to perform efficient
+ * operations in GF(2^8) represented as GF(2)[x]/w(x) where
+ * w(x)=x^8+x^6+x^3+x^2+1. We care about doing that because it's part of the
+ * definition of the RS matrix in the key schedule. Elements of that field
+ * are polynomials of degree not greater than 7 and all coefficients 0 or 1,
+ * which can be represented naturally by bytes (just substitute x=2). In that
+ * form, GF(2^8) addition is the same as bitwise XOR, but GF(2^8)
+ * multiplication is inefficient without hardware support. To multiply
+ * faster, I make use of the fact x is a generator for the nonzero elements,
+ * so that every element p of GF(2)[x]/w(x) is either 0 or equal to (x)^n for
+ * some n in 0..254. Note that that caret is exponentiation in GF(2^8),
+ * *not* polynomial notation. So if I want to compute pq where p and q are
+ * in GF(2^8), I can just say:
+ * 1. if p=0 or q=0 then pq=0
+ * 2. otherwise, find m and n such that p=x^m and q=x^n
+ * 3. pq=(x^m)(x^n)=x^(m+n), so add m and n and find pq
+ * The translations in steps 2 and 3 are looked up in the tables
+ * poly_to_exp (for step 2) and exp_to_poly (for step 3). To see this
+ * in action, look at the CALC_S macro. As additional wrinkles, note that
+ * one of my operands is always a constant, so the poly_to_exp lookup on it
+ * is done in advance; I included the original values in the comments so
+ * readers can have some chance of recognizing that this *is* the RS matrix
+ * from the Twofish paper. I've only included the table entries I actually
+ * need; I never do a lookup on a variable input of zero and the biggest
+ * exponents I'll ever see are 254 (variable) and 237 (constant), so they'll
+ * never sum to more than 491. I'm repeating part of the exp_to_poly table
+ * so that I don't have to do mod-255 reduction in the exponent arithmetic.
+ * Since I know my constant operands are never zero, I only have to worry
+ * about zero values in the variable operand, and I do it with a simple
+ * conditional branch. I know conditionals are expensive, but I couldn't
+ * see a non-horrible way of avoiding them, and I did manage to group the
+ * statements so that each if covers four group multiplications. */
+
+static const byte poly_to_exp[255] = {
+ 0x00, 0x01, 0x17, 0x02, 0x2E, 0x18, 0x53, 0x03, 0x6A, 0x2F, 0x93, 0x19,
+ 0x34, 0x54, 0x45, 0x04, 0x5C, 0x6B, 0xB6, 0x30, 0xA6, 0x94, 0x4B, 0x1A,
+ 0x8C, 0x35, 0x81, 0x55, 0xAA, 0x46, 0x0D, 0x05, 0x24, 0x5D, 0x87, 0x6C,
+ 0x9B, 0xB7, 0xC1, 0x31, 0x2B, 0xA7, 0xA3, 0x95, 0x98, 0x4C, 0xCA, 0x1B,
+ 0xE6, 0x8D, 0x73, 0x36, 0xCD, 0x82, 0x12, 0x56, 0x62, 0xAB, 0xF0, 0x47,
+ 0x4F, 0x0E, 0xBD, 0x06, 0xD4, 0x25, 0xD2, 0x5E, 0x27, 0x88, 0x66, 0x6D,
+ 0xD6, 0x9C, 0x79, 0xB8, 0x08, 0xC2, 0xDF, 0x32, 0x68, 0x2C, 0xFD, 0xA8,
+ 0x8A, 0xA4, 0x5A, 0x96, 0x29, 0x99, 0x22, 0x4D, 0x60, 0xCB, 0xE4, 0x1C,
+ 0x7B, 0xE7, 0x3B, 0x8E, 0x9E, 0x74, 0xF4, 0x37, 0xD8, 0xCE, 0xF9, 0x83,
+ 0x6F, 0x13, 0xB2, 0x57, 0xE1, 0x63, 0xDC, 0xAC, 0xC4, 0xF1, 0xAF, 0x48,
+ 0x0A, 0x50, 0x42, 0x0F, 0xBA, 0xBE, 0xC7, 0x07, 0xDE, 0xD5, 0x78, 0x26,
+ 0x65, 0xD3, 0xD1, 0x5F, 0xE3, 0x28, 0x21, 0x89, 0x59, 0x67, 0xFC, 0x6E,
+ 0xB1, 0xD7, 0xF8, 0x9D, 0xF3, 0x7A, 0x3A, 0xB9, 0xC6, 0x09, 0x41, 0xC3,
+ 0xAE, 0xE0, 0xDB, 0x33, 0x44, 0x69, 0x92, 0x2D, 0x52, 0xFE, 0x16, 0xA9,
+ 0x0C, 0x8B, 0x80, 0xA5, 0x4A, 0x5B, 0xB5, 0x97, 0xC9, 0x2A, 0xA2, 0x9A,
+ 0xC0, 0x23, 0x86, 0x4E, 0xBC, 0x61, 0xEF, 0xCC, 0x11, 0xE5, 0x72, 0x1D,
+ 0x3D, 0x7C, 0xEB, 0xE8, 0xE9, 0x3C, 0xEA, 0x8F, 0x7D, 0x9F, 0xEC, 0x75,
+ 0x1E, 0xF5, 0x3E, 0x38, 0xF6, 0xD9, 0x3F, 0xCF, 0x76, 0xFA, 0x1F, 0x84,
+ 0xA0, 0x70, 0xED, 0x14, 0x90, 0xB3, 0x7E, 0x58, 0xFB, 0xE2, 0x20, 0x64,
+ 0xD0, 0xDD, 0x77, 0xAD, 0xDA, 0xC5, 0x40, 0xF2, 0x39, 0xB0, 0xF7, 0x49,
+ 0xB4, 0x0B, 0x7F, 0x51, 0x15, 0x43, 0x91, 0x10, 0x71, 0xBB, 0xEE, 0xBF,
+ 0x85, 0xC8, 0xA1
+};
+
+static const byte exp_to_poly[492] = {
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x4D, 0x9A, 0x79, 0xF2,
+ 0xA9, 0x1F, 0x3E, 0x7C, 0xF8, 0xBD, 0x37, 0x6E, 0xDC, 0xF5, 0xA7, 0x03,
+ 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xCD, 0xD7, 0xE3, 0x8B, 0x5B, 0xB6,
+ 0x21, 0x42, 0x84, 0x45, 0x8A, 0x59, 0xB2, 0x29, 0x52, 0xA4, 0x05, 0x0A,
+ 0x14, 0x28, 0x50, 0xA0, 0x0D, 0x1A, 0x34, 0x68, 0xD0, 0xED, 0x97, 0x63,
+ 0xC6, 0xC1, 0xCF, 0xD3, 0xEB, 0x9B, 0x7B, 0xF6, 0xA1, 0x0F, 0x1E, 0x3C,
+ 0x78, 0xF0, 0xAD, 0x17, 0x2E, 0x5C, 0xB8, 0x3D, 0x7A, 0xF4, 0xA5, 0x07,
+ 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0x8D, 0x57, 0xAE, 0x11, 0x22, 0x44, 0x88,
+ 0x5D, 0xBA, 0x39, 0x72, 0xE4, 0x85, 0x47, 0x8E, 0x51, 0xA2, 0x09, 0x12,
+ 0x24, 0x48, 0x90, 0x6D, 0xDA, 0xF9, 0xBF, 0x33, 0x66, 0xCC, 0xD5, 0xE7,
+ 0x83, 0x4B, 0x96, 0x61, 0xC2, 0xC9, 0xDF, 0xF3, 0xAB, 0x1B, 0x36, 0x6C,
+ 0xD8, 0xFD, 0xB7, 0x23, 0x46, 0x8C, 0x55, 0xAA, 0x19, 0x32, 0x64, 0xC8,
+ 0xDD, 0xF7, 0xA3, 0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x2D, 0x5A, 0xB4, 0x25,
+ 0x4A, 0x94, 0x65, 0xCA, 0xD9, 0xFF, 0xB3, 0x2B, 0x56, 0xAC, 0x15, 0x2A,
+ 0x54, 0xA8, 0x1D, 0x3A, 0x74, 0xE8, 0x9D, 0x77, 0xEE, 0x91, 0x6F, 0xDE,
+ 0xF1, 0xAF, 0x13, 0x26, 0x4C, 0x98, 0x7D, 0xFA, 0xB9, 0x3F, 0x7E, 0xFC,
+ 0xB5, 0x27, 0x4E, 0x9C, 0x75, 0xEA, 0x99, 0x7F, 0xFE, 0xB1, 0x2F, 0x5E,
+ 0xBC, 0x35, 0x6A, 0xD4, 0xE5, 0x87, 0x43, 0x86, 0x41, 0x82, 0x49, 0x92,
+ 0x69, 0xD2, 0xE9, 0x9F, 0x73, 0xE6, 0x81, 0x4F, 0x9E, 0x71, 0xE2, 0x89,
+ 0x5F, 0xBE, 0x31, 0x62, 0xC4, 0xC5, 0xC7, 0xC3, 0xCB, 0xDB, 0xFB, 0xBB,
+ 0x3B, 0x76, 0xEC, 0x95, 0x67, 0xCE, 0xD1, 0xEF, 0x93, 0x6B, 0xD6, 0xE1,
+ 0x8F, 0x53, 0xA6, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x4D,
+ 0x9A, 0x79, 0xF2, 0xA9, 0x1F, 0x3E, 0x7C, 0xF8, 0xBD, 0x37, 0x6E, 0xDC,
+ 0xF5, 0xA7, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xCD, 0xD7, 0xE3,
+ 0x8B, 0x5B, 0xB6, 0x21, 0x42, 0x84, 0x45, 0x8A, 0x59, 0xB2, 0x29, 0x52,
+ 0xA4, 0x05, 0x0A, 0x14, 0x28, 0x50, 0xA0, 0x0D, 0x1A, 0x34, 0x68, 0xD0,
+ 0xED, 0x97, 0x63, 0xC6, 0xC1, 0xCF, 0xD3, 0xEB, 0x9B, 0x7B, 0xF6, 0xA1,
+ 0x0F, 0x1E, 0x3C, 0x78, 0xF0, 0xAD, 0x17, 0x2E, 0x5C, 0xB8, 0x3D, 0x7A,
+ 0xF4, 0xA5, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0x8D, 0x57, 0xAE, 0x11,
+ 0x22, 0x44, 0x88, 0x5D, 0xBA, 0x39, 0x72, 0xE4, 0x85, 0x47, 0x8E, 0x51,
+ 0xA2, 0x09, 0x12, 0x24, 0x48, 0x90, 0x6D, 0xDA, 0xF9, 0xBF, 0x33, 0x66,
+ 0xCC, 0xD5, 0xE7, 0x83, 0x4B, 0x96, 0x61, 0xC2, 0xC9, 0xDF, 0xF3, 0xAB,
+ 0x1B, 0x36, 0x6C, 0xD8, 0xFD, 0xB7, 0x23, 0x46, 0x8C, 0x55, 0xAA, 0x19,
+ 0x32, 0x64, 0xC8, 0xDD, 0xF7, 0xA3, 0x0B, 0x16, 0x2C, 0x58, 0xB0, 0x2D,
+ 0x5A, 0xB4, 0x25, 0x4A, 0x94, 0x65, 0xCA, 0xD9, 0xFF, 0xB3, 0x2B, 0x56,
+ 0xAC, 0x15, 0x2A, 0x54, 0xA8, 0x1D, 0x3A, 0x74, 0xE8, 0x9D, 0x77, 0xEE,
+ 0x91, 0x6F, 0xDE, 0xF1, 0xAF, 0x13, 0x26, 0x4C, 0x98, 0x7D, 0xFA, 0xB9,
+ 0x3F, 0x7E, 0xFC, 0xB5, 0x27, 0x4E, 0x9C, 0x75, 0xEA, 0x99, 0x7F, 0xFE,
+ 0xB1, 0x2F, 0x5E, 0xBC, 0x35, 0x6A, 0xD4, 0xE5, 0x87, 0x43, 0x86, 0x41,
+ 0x82, 0x49, 0x92, 0x69, 0xD2, 0xE9, 0x9F, 0x73, 0xE6, 0x81, 0x4F, 0x9E,
+ 0x71, 0xE2, 0x89, 0x5F, 0xBE, 0x31, 0x62, 0xC4, 0xC5, 0xC7, 0xC3, 0xCB
+};
+
+
+/* The table constants are indices of
+ * S-box entries, preprocessed through q0 and q1. */
+static byte calc_sb_tbl[512] = {
+ 0xA9, 0x75, 0x67, 0xF3, 0xB3, 0xC6, 0xE8, 0xF4,
+ 0x04, 0xDB, 0xFD, 0x7B, 0xA3, 0xFB, 0x76, 0xC8,
+ 0x9A, 0x4A, 0x92, 0xD3, 0x80, 0xE6, 0x78, 0x6B,
+ 0xE4, 0x45, 0xDD, 0x7D, 0xD1, 0xE8, 0x38, 0x4B,
+ 0x0D, 0xD6, 0xC6, 0x32, 0x35, 0xD8, 0x98, 0xFD,
+ 0x18, 0x37, 0xF7, 0x71, 0xEC, 0xF1, 0x6C, 0xE1,
+ 0x43, 0x30, 0x75, 0x0F, 0x37, 0xF8, 0x26, 0x1B,
+ 0xFA, 0x87, 0x13, 0xFA, 0x94, 0x06, 0x48, 0x3F,
+ 0xF2, 0x5E, 0xD0, 0xBA, 0x8B, 0xAE, 0x30, 0x5B,
+ 0x84, 0x8A, 0x54, 0x00, 0xDF, 0xBC, 0x23, 0x9D,
+ 0x19, 0x6D, 0x5B, 0xC1, 0x3D, 0xB1, 0x59, 0x0E,
+ 0xF3, 0x80, 0xAE, 0x5D, 0xA2, 0xD2, 0x82, 0xD5,
+ 0x63, 0xA0, 0x01, 0x84, 0x83, 0x07, 0x2E, 0x14,
+ 0xD9, 0xB5, 0x51, 0x90, 0x9B, 0x2C, 0x7C, 0xA3,
+ 0xA6, 0xB2, 0xEB, 0x73, 0xA5, 0x4C, 0xBE, 0x54,
+ 0x16, 0x92, 0x0C, 0x74, 0xE3, 0x36, 0x61, 0x51,
+ 0xC0, 0x38, 0x8C, 0xB0, 0x3A, 0xBD, 0xF5, 0x5A,
+ 0x73, 0xFC, 0x2C, 0x60, 0x25, 0x62, 0x0B, 0x96,
+ 0xBB, 0x6C, 0x4E, 0x42, 0x89, 0xF7, 0x6B, 0x10,
+ 0x53, 0x7C, 0x6A, 0x28, 0xB4, 0x27, 0xF1, 0x8C,
+ 0xE1, 0x13, 0xE6, 0x95, 0xBD, 0x9C, 0x45, 0xC7,
+ 0xE2, 0x24, 0xF4, 0x46, 0xB6, 0x3B, 0x66, 0x70,
+ 0xCC, 0xCA, 0x95, 0xE3, 0x03, 0x85, 0x56, 0xCB,
+ 0xD4, 0x11, 0x1C, 0xD0, 0x1E, 0x93, 0xD7, 0xB8,
+ 0xFB, 0xA6, 0xC3, 0x83, 0x8E, 0x20, 0xB5, 0xFF,
+ 0xE9, 0x9F, 0xCF, 0x77, 0xBF, 0xC3, 0xBA, 0xCC,
+ 0xEA, 0x03, 0x77, 0x6F, 0x39, 0x08, 0xAF, 0xBF,
+ 0x33, 0x40, 0xC9, 0xE7, 0x62, 0x2B, 0x71, 0xE2,
+ 0x81, 0x79, 0x79, 0x0C, 0x09, 0xAA, 0xAD, 0x82,
+ 0x24, 0x41, 0xCD, 0x3A, 0xF9, 0xEA, 0xD8, 0xB9,
+ 0xE5, 0xE4, 0xC5, 0x9A, 0xB9, 0xA4, 0x4D, 0x97,
+ 0x44, 0x7E, 0x08, 0xDA, 0x86, 0x7A, 0xE7, 0x17,
+ 0xA1, 0x66, 0x1D, 0x94, 0xAA, 0xA1, 0xED, 0x1D,
+ 0x06, 0x3D, 0x70, 0xF0, 0xB2, 0xDE, 0xD2, 0xB3,
+ 0x41, 0x0B, 0x7B, 0x72, 0xA0, 0xA7, 0x11, 0x1C,
+ 0x31, 0xEF, 0xC2, 0xD1, 0x27, 0x53, 0x90, 0x3E,
+ 0x20, 0x8F, 0xF6, 0x33, 0x60, 0x26, 0xFF, 0x5F,
+ 0x96, 0xEC, 0x5C, 0x76, 0xB1, 0x2A, 0xAB, 0x49,
+ 0x9E, 0x81, 0x9C, 0x88, 0x52, 0xEE, 0x1B, 0x21,
+ 0x5F, 0xC4, 0x93, 0x1A, 0x0A, 0xEB, 0xEF, 0xD9,
+ 0x91, 0xC5, 0x85, 0x39, 0x49, 0x99, 0xEE, 0xCD,
+ 0x2D, 0xAD, 0x4F, 0x31, 0x8F, 0x8B, 0x3B, 0x01,
+ 0x47, 0x18, 0x87, 0x23, 0x6D, 0xDD, 0x46, 0x1F,
+ 0xD6, 0x4E, 0x3E, 0x2D, 0x69, 0xF9, 0x64, 0x48,
+ 0x2A, 0x4F, 0xCE, 0xF2, 0xCB, 0x65, 0x2F, 0x8E,
+ 0xFC, 0x78, 0x97, 0x5C, 0x05, 0x58, 0x7A, 0x19,
+ 0xAC, 0x8D, 0x7F, 0xE5, 0xD5, 0x98, 0x1A, 0x57,
+ 0x4B, 0x67, 0x0E, 0x7F, 0xA7, 0x05, 0x5A, 0x64,
+ 0x28, 0xAF, 0x14, 0x63, 0x3F, 0xB6, 0x29, 0xFE,
+ 0x88, 0xF5, 0x3C, 0xB7, 0x4C, 0x3C, 0x02, 0xA5,
+ 0xB8, 0xCE, 0xDA, 0xE9, 0xB0, 0x68, 0x17, 0x44,
+ 0x55, 0xE0, 0x1F, 0x4D, 0x8A, 0x43, 0x7D, 0x69,
+ 0x57, 0x29, 0xC7, 0x2E, 0x8D, 0xAC, 0x74, 0x15,
+ 0xB7, 0x59, 0xC4, 0xA8, 0x9F, 0x0A, 0x72, 0x9E,
+ 0x7E, 0x6E, 0x15, 0x47, 0x22, 0xDF, 0x12, 0x34,
+ 0x58, 0x35, 0x07, 0x6A, 0x99, 0xCF, 0x34, 0xDC,
+ 0x6E, 0x22, 0x50, 0xC9, 0xDE, 0xC0, 0x68, 0x9B,
+ 0x65, 0x89, 0xBC, 0xD4, 0xDB, 0xED, 0xF8, 0xAB,
+ 0xC8, 0x12, 0xA8, 0xA2, 0x2B, 0x0D, 0x40, 0x52,
+ 0xDC, 0xBB, 0xFE, 0x02, 0x32, 0x2F, 0xA4, 0xA9,
+ 0xCA, 0xD7, 0x10, 0x61, 0x21, 0x1E, 0xF0, 0xB4,
+ 0xD3, 0x50, 0x5D, 0x04, 0x0F, 0xF6, 0x00, 0xC2,
+ 0x6F, 0x16, 0x9D, 0x25, 0x36, 0x86, 0x42, 0x56,
+ 0x4A, 0x55, 0x5E, 0x09, 0xC1, 0xBE, 0xE0, 0x91
+};
+/* Macro to perform one column of the RS matrix multiplication. The
+ * parameters a, b, c, and d are the four bytes of output; i is the index
+ * of the key bytes, and w, x, y, and z, are the column of constants from
+ * the RS matrix, preprocessed through the poly_to_exp table. */
+
+#define CALC_S(a, b, c, d, i, w, x, y, z) \
+ if (key[i]) { \
+ tmp = poly_to_exp[key[i] - 1]; \
+ (a) ^= exp_to_poly[tmp + (w)]; \
+ (b) ^= exp_to_poly[tmp + (x)]; \
+ (c) ^= exp_to_poly[tmp + (y)]; \
+ (d) ^= exp_to_poly[tmp + (z)]; \
+ }
+
+/* Macros to calculate the key-dependent S-boxes for a 128-bit key using
+ * the S vector from CALC_S. CALC_SB_2 computes a single entry in all
+ * four S-boxes, where i is the index of the entry to compute, and a and b
+ * are the index numbers preprocessed through the q0 and q1 tables
+ * respectively. CALC_SB is simply a convenience to make the code shorter;
+ * it calls CALC_SB_2 four times with consecutive indices from i to i+3,
+ * using the remaining parameters two by two. */
+
+#define CALC_SB_2(i, a, b) \
+ ctx->s[0][i] = mds[0][q0[(a) ^ sa] ^ se]; \
+ ctx->s[1][i] = mds[1][q0[(b) ^ sb] ^ sf]; \
+ ctx->s[2][i] = mds[2][q1[(a) ^ sc] ^ sg]; \
+ ctx->s[3][i] = mds[3][q1[(b) ^ sd] ^ sh]
+
+#define CALC_SB(i, a, b, c, d, e, f, g, h) \
+ CALC_SB_2 (i, a, b); CALC_SB_2 ((i)+1, c, d); \
+ CALC_SB_2 ((i)+2, e, f); CALC_SB_2 ((i)+3, g, h)
+
+/* Macros exactly like CALC_SB and CALC_SB_2, but for 256-bit keys. */
+
+#define CALC_SB256_2(i, a, b) \
+ ctx->s[0][i] = mds[0][q0[q0[q1[(b) ^ sa] ^ se] ^ si] ^ sm]; \
+ ctx->s[1][i] = mds[1][q0[q1[q1[(a) ^ sb] ^ sf] ^ sj] ^ sn]; \
+ ctx->s[2][i] = mds[2][q1[q0[q0[(a) ^ sc] ^ sg] ^ sk] ^ so]; \
+ ctx->s[3][i] = mds[3][q1[q1[q0[(b) ^ sd] ^ sh] ^ sl] ^ sp];
+
+#define CALC_SB256(i, a, b, c, d, e, f, g, h) \
+ CALC_SB256_2 (i, a, b); CALC_SB256_2 ((i)+1, c, d); \
+ CALC_SB256_2 ((i)+2, e, f); CALC_SB256_2 ((i)+3, g, h)
+
+/* Macros to calculate the whitening and round subkeys. CALC_K_2 computes the
+ * last two stages of the h() function for a given index (either 2i or 2i+1).
+ * a, b, c, and d are the four bytes going into the last two stages. For
+ * 128-bit keys, this is the entire h() function and a and c are the index
+ * preprocessed through q0 and q1 respectively; for longer keys they are the
+ * output of previous stages. j is the index of the first key byte to use.
+ * CALC_K computes a pair of subkeys for 128-bit Twofish, by calling CALC_K_2
+ * twice, doing the Pseudo-Hadamard Transform, and doing the necessary
+ * rotations. Its parameters are: a, the array to write the results into,
+ * j, the index of the first output entry, k and l, the preprocessed indices
+ * for index 2i, and m and n, the preprocessed indices for index 2i+1.
+ * CALC_K256_2 expands CALC_K_2 to handle 256-bit keys, by doing two
+ * additional lookup-and-XOR stages. The parameters a and b are the index
+ * preprocessed through q0 and q1 respectively; j is the index of the first
+ * key byte to use. CALC_K256 is identical to CALC_K but for using the
+ * CALC_K256_2 macro instead of CALC_K_2. */
+
+#define CALC_K_2(a, b, c, d, j) \
+ mds[0][q0[a ^ key[(j) + 8]] ^ key[j]] \
+ ^ mds[1][q0[b ^ key[(j) + 9]] ^ key[(j) + 1]] \
+ ^ mds[2][q1[c ^ key[(j) + 10]] ^ key[(j) + 2]] \
+ ^ mds[3][q1[d ^ key[(j) + 11]] ^ key[(j) + 3]]
+
+#define CALC_K(a, j, k, l, m, n) \
+ x = CALC_K_2 (k, l, k, l, 0); \
+ y = CALC_K_2 (m, n, m, n, 4); \
+ y = (y << 8) + (y >> 24); \
+ x += y; y += x; ctx->a[j] = x; \
+ ctx->a[(j) + 1] = (y << 9) + (y >> 23)
+
+#define CALC_K256_2(a, b, j) \
+ CALC_K_2 (q0[q1[b ^ key[(j) + 24]] ^ key[(j) + 16]], \
+ q1[q1[a ^ key[(j) + 25]] ^ key[(j) + 17]], \
+ q0[q0[a ^ key[(j) + 26]] ^ key[(j) + 18]], \
+ q1[q0[b ^ key[(j) + 27]] ^ key[(j) + 19]], j)
+
+#define CALC_K256(a, j, k, l, m, n) \
+ x = CALC_K256_2 (k, l, 0); \
+ y = CALC_K256_2 (m, n, 4); \
+ y = (y << 8) + (y >> 24); \
+ x += y; y += x; ctx->a[j] = x; \
+ ctx->a[(j) + 1] = (y << 9) + (y >> 23)
+
+
+
+/* Perform the key setup. Note that this works only with 128- and 256-bit
+ * keys, despite the API that looks like it might support other sizes. */
+
+static gcry_err_code_t
+do_twofish_setkey (TWOFISH_context *ctx, const byte *key, const unsigned keylen)
+{
+ int i, j, k;
+
+ /* Temporaries for CALC_K. */
+ u32 x, y;
+
+ /* The S vector used to key the S-boxes, split up into individual bytes.
+ * 128-bit keys use only sa through sh; 256-bit use all of them. */
+ byte sa = 0, sb = 0, sc = 0, sd = 0, se = 0, sf = 0, sg = 0, sh = 0;
+ byte si = 0, sj = 0, sk = 0, sl = 0, sm = 0, sn = 0, so = 0, sp = 0;
+
+ /* Temporary for CALC_S. */
+ byte tmp;
+
+ /* Flags for self-test. */
+ static int initialized = 0;
+ static const char *selftest_failed=0;
+
+ /* Check key length. */
+ if( ( ( keylen - 16 ) | 16 ) != 16 )
+ return GPG_ERR_INV_KEYLEN;
+
+ /* Do self-test if necessary. */
+ if (!initialized)
+ {
+ initialized = 1;
+ selftest_failed = selftest ();
+ if( selftest_failed )
+ log_error("%s\n", selftest_failed );
+ }
+ if( selftest_failed )
+ return GPG_ERR_SELFTEST_FAILED;
+
+ /* Compute the first two words of the S vector. The magic numbers are
+ * the entries of the RS matrix, preprocessed through poly_to_exp. The
+ * numbers in the comments are the original (polynomial form) matrix
+ * entries. */
+ CALC_S (sa, sb, sc, sd, 0, 0x00, 0x2D, 0x01, 0x2D); /* 01 A4 02 A4 */
+ CALC_S (sa, sb, sc, sd, 1, 0x2D, 0xA4, 0x44, 0x8A); /* A4 56 A1 55 */
+ CALC_S (sa, sb, sc, sd, 2, 0x8A, 0xD5, 0xBF, 0xD1); /* 55 82 FC 87 */
+ CALC_S (sa, sb, sc, sd, 3, 0xD1, 0x7F, 0x3D, 0x99); /* 87 F3 C1 5A */
+ CALC_S (sa, sb, sc, sd, 4, 0x99, 0x46, 0x66, 0x96); /* 5A 1E 47 58 */
+ CALC_S (sa, sb, sc, sd, 5, 0x96, 0x3C, 0x5B, 0xED); /* 58 C6 AE DB */
+ CALC_S (sa, sb, sc, sd, 6, 0xED, 0x37, 0x4F, 0xE0); /* DB 68 3D 9E */
+ CALC_S (sa, sb, sc, sd, 7, 0xE0, 0xD0, 0x8C, 0x17); /* 9E E5 19 03 */
+ CALC_S (se, sf, sg, sh, 8, 0x00, 0x2D, 0x01, 0x2D); /* 01 A4 02 A4 */
+ CALC_S (se, sf, sg, sh, 9, 0x2D, 0xA4, 0x44, 0x8A); /* A4 56 A1 55 */
+ CALC_S (se, sf, sg, sh, 10, 0x8A, 0xD5, 0xBF, 0xD1); /* 55 82 FC 87 */
+ CALC_S (se, sf, sg, sh, 11, 0xD1, 0x7F, 0x3D, 0x99); /* 87 F3 C1 5A */
+ CALC_S (se, sf, sg, sh, 12, 0x99, 0x46, 0x66, 0x96); /* 5A 1E 47 58 */
+ CALC_S (se, sf, sg, sh, 13, 0x96, 0x3C, 0x5B, 0xED); /* 58 C6 AE DB */
+ CALC_S (se, sf, sg, sh, 14, 0xED, 0x37, 0x4F, 0xE0); /* DB 68 3D 9E */
+ CALC_S (se, sf, sg, sh, 15, 0xE0, 0xD0, 0x8C, 0x17); /* 9E E5 19 03 */
+
+ if (keylen == 32) /* 256-bit key */
+ {
+ /* Calculate the remaining two words of the S vector */
+ CALC_S (si, sj, sk, sl, 16, 0x00, 0x2D, 0x01, 0x2D); /* 01 A4 02 A4 */
+ CALC_S (si, sj, sk, sl, 17, 0x2D, 0xA4, 0x44, 0x8A); /* A4 56 A1 55 */
+ CALC_S (si, sj, sk, sl, 18, 0x8A, 0xD5, 0xBF, 0xD1); /* 55 82 FC 87 */
+ CALC_S (si, sj, sk, sl, 19, 0xD1, 0x7F, 0x3D, 0x99); /* 87 F3 C1 5A */
+ CALC_S (si, sj, sk, sl, 20, 0x99, 0x46, 0x66, 0x96); /* 5A 1E 47 58 */
+ CALC_S (si, sj, sk, sl, 21, 0x96, 0x3C, 0x5B, 0xED); /* 58 C6 AE DB */
+ CALC_S (si, sj, sk, sl, 22, 0xED, 0x37, 0x4F, 0xE0); /* DB 68 3D 9E */
+ CALC_S (si, sj, sk, sl, 23, 0xE0, 0xD0, 0x8C, 0x17); /* 9E E5 19 03 */
+ CALC_S (sm, sn, so, sp, 24, 0x00, 0x2D, 0x01, 0x2D); /* 01 A4 02 A4 */
+ CALC_S (sm, sn, so, sp, 25, 0x2D, 0xA4, 0x44, 0x8A); /* A4 56 A1 55 */
+ CALC_S (sm, sn, so, sp, 26, 0x8A, 0xD5, 0xBF, 0xD1); /* 55 82 FC 87 */
+ CALC_S (sm, sn, so, sp, 27, 0xD1, 0x7F, 0x3D, 0x99); /* 87 F3 C1 5A */
+ CALC_S (sm, sn, so, sp, 28, 0x99, 0x46, 0x66, 0x96); /* 5A 1E 47 58 */
+ CALC_S (sm, sn, so, sp, 29, 0x96, 0x3C, 0x5B, 0xED); /* 58 C6 AE DB */
+ CALC_S (sm, sn, so, sp, 30, 0xED, 0x37, 0x4F, 0xE0); /* DB 68 3D 9E */
+ CALC_S (sm, sn, so, sp, 31, 0xE0, 0xD0, 0x8C, 0x17); /* 9E E5 19 03 */
+
+ /* Compute the S-boxes. */
+ for(i=j=0,k=1; i < 256; i++, j += 2, k += 2 )
+ {
+ CALC_SB256_2( i, calc_sb_tbl[j], calc_sb_tbl[k] );
+ }
+
+ /* Calculate whitening and round subkeys. The constants are
+ * indices of subkeys, preprocessed through q0 and q1. */
+ CALC_K256 (w, 0, 0xA9, 0x75, 0x67, 0xF3);
+ CALC_K256 (w, 2, 0xB3, 0xC6, 0xE8, 0xF4);
+ CALC_K256 (w, 4, 0x04, 0xDB, 0xFD, 0x7B);
+ CALC_K256 (w, 6, 0xA3, 0xFB, 0x76, 0xC8);
+ CALC_K256 (k, 0, 0x9A, 0x4A, 0x92, 0xD3);
+ CALC_K256 (k, 2, 0x80, 0xE6, 0x78, 0x6B);
+ CALC_K256 (k, 4, 0xE4, 0x45, 0xDD, 0x7D);
+ CALC_K256 (k, 6, 0xD1, 0xE8, 0x38, 0x4B);
+ CALC_K256 (k, 8, 0x0D, 0xD6, 0xC6, 0x32);
+ CALC_K256 (k, 10, 0x35, 0xD8, 0x98, 0xFD);
+ CALC_K256 (k, 12, 0x18, 0x37, 0xF7, 0x71);
+ CALC_K256 (k, 14, 0xEC, 0xF1, 0x6C, 0xE1);
+ CALC_K256 (k, 16, 0x43, 0x30, 0x75, 0x0F);
+ CALC_K256 (k, 18, 0x37, 0xF8, 0x26, 0x1B);
+ CALC_K256 (k, 20, 0xFA, 0x87, 0x13, 0xFA);
+ CALC_K256 (k, 22, 0x94, 0x06, 0x48, 0x3F);
+ CALC_K256 (k, 24, 0xF2, 0x5E, 0xD0, 0xBA);
+ CALC_K256 (k, 26, 0x8B, 0xAE, 0x30, 0x5B);
+ CALC_K256 (k, 28, 0x84, 0x8A, 0x54, 0x00);
+ CALC_K256 (k, 30, 0xDF, 0xBC, 0x23, 0x9D);
+ }
+ else
+ {
+ /* Compute the S-boxes. */
+ for(i=j=0,k=1; i < 256; i++, j += 2, k += 2 )
+ {
+ CALC_SB_2( i, calc_sb_tbl[j], calc_sb_tbl[k] );
+ }
+
+ /* Calculate whitening and round subkeys. The constants are
+ * indices of subkeys, preprocessed through q0 and q1. */
+ CALC_K (w, 0, 0xA9, 0x75, 0x67, 0xF3);
+ CALC_K (w, 2, 0xB3, 0xC6, 0xE8, 0xF4);
+ CALC_K (w, 4, 0x04, 0xDB, 0xFD, 0x7B);
+ CALC_K (w, 6, 0xA3, 0xFB, 0x76, 0xC8);
+ CALC_K (k, 0, 0x9A, 0x4A, 0x92, 0xD3);
+ CALC_K (k, 2, 0x80, 0xE6, 0x78, 0x6B);
+ CALC_K (k, 4, 0xE4, 0x45, 0xDD, 0x7D);
+ CALC_K (k, 6, 0xD1, 0xE8, 0x38, 0x4B);
+ CALC_K (k, 8, 0x0D, 0xD6, 0xC6, 0x32);
+ CALC_K (k, 10, 0x35, 0xD8, 0x98, 0xFD);
+ CALC_K (k, 12, 0x18, 0x37, 0xF7, 0x71);
+ CALC_K (k, 14, 0xEC, 0xF1, 0x6C, 0xE1);
+ CALC_K (k, 16, 0x43, 0x30, 0x75, 0x0F);
+ CALC_K (k, 18, 0x37, 0xF8, 0x26, 0x1B);
+ CALC_K (k, 20, 0xFA, 0x87, 0x13, 0xFA);
+ CALC_K (k, 22, 0x94, 0x06, 0x48, 0x3F);
+ CALC_K (k, 24, 0xF2, 0x5E, 0xD0, 0xBA);
+ CALC_K (k, 26, 0x8B, 0xAE, 0x30, 0x5B);
+ CALC_K (k, 28, 0x84, 0x8A, 0x54, 0x00);
+ CALC_K (k, 30, 0xDF, 0xBC, 0x23, 0x9D);
+ }
+
+ return 0;
+}
+
+static gcry_err_code_t
+twofish_setkey (void *context, const byte *key, unsigned int keylen)
+{
+ TWOFISH_context *ctx = context;
+ int rc = do_twofish_setkey (ctx, key, keylen);
+ _gcry_burn_stack (23+6*sizeof(void*));
+ return rc;
+}
+
+
+
+/* Macros to compute the g() function in the encryption and decryption
+ * rounds. G1 is the straight g() function; G2 includes the 8-bit
+ * rotation for the high 32-bit word. */
+
+#define G1(a) \
+ (ctx->s[0][(a) & 0xFF]) ^ (ctx->s[1][((a) >> 8) & 0xFF]) \
+ ^ (ctx->s[2][((a) >> 16) & 0xFF]) ^ (ctx->s[3][(a) >> 24])
+
+#define G2(b) \
+ (ctx->s[1][(b) & 0xFF]) ^ (ctx->s[2][((b) >> 8) & 0xFF]) \
+ ^ (ctx->s[3][((b) >> 16) & 0xFF]) ^ (ctx->s[0][(b) >> 24])
+
+/* Encryption and decryption Feistel rounds. Each one calls the two g()
+ * macros, does the PHT, and performs the XOR and the appropriate bit
+ * rotations. The parameters are the round number (used to select subkeys),
+ * and the four 32-bit chunks of the text. */
+
+#define ENCROUND(n, a, b, c, d) \
+ x = G1 (a); y = G2 (b); \
+ x += y; y += x + ctx->k[2 * (n) + 1]; \
+ (c) ^= x + ctx->k[2 * (n)]; \
+ (c) = ((c) >> 1) + ((c) << 31); \
+ (d) = (((d) << 1)+((d) >> 31)) ^ y
+
+#define DECROUND(n, a, b, c, d) \
+ x = G1 (a); y = G2 (b); \
+ x += y; y += x; \
+ (d) ^= y + ctx->k[2 * (n) + 1]; \
+ (d) = ((d) >> 1) + ((d) << 31); \
+ (c) = (((c) << 1)+((c) >> 31)); \
+ (c) ^= (x + ctx->k[2 * (n)])
+
+/* Encryption and decryption cycles; each one is simply two Feistel rounds
+ * with the 32-bit chunks re-ordered to simulate the "swap" */
+
+#define ENCCYCLE(n) \
+ ENCROUND (2 * (n), a, b, c, d); \
+ ENCROUND (2 * (n) + 1, c, d, a, b)
+
+#define DECCYCLE(n) \
+ DECROUND (2 * (n) + 1, c, d, a, b); \
+ DECROUND (2 * (n), a, b, c, d)
+
+/* Macros to convert the input and output bytes into 32-bit words,
+ * and simultaneously perform the whitening step. INPACK packs word
+ * number n into the variable named by x, using whitening subkey number m.
+ * OUTUNPACK unpacks word number n from the variable named by x, using
+ * whitening subkey number m. */
+
+#define INPACK(n, x, m) \
+ x = in[4 * (n)] ^ (in[4 * (n) + 1] << 8) \
+ ^ (in[4 * (n) + 2] << 16) ^ (in[4 * (n) + 3] << 24) ^ ctx->w[m]
+
+#define OUTUNPACK(n, x, m) \
+ x ^= ctx->w[m]; \
+ out[4 * (n)] = x; out[4 * (n) + 1] = x >> 8; \
+ out[4 * (n) + 2] = x >> 16; out[4 * (n) + 3] = x >> 24
+
+/* Encrypt one block. in and out may be the same. */
+
+static void
+do_twofish_encrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
+{
+ /* The four 32-bit chunks of the text. */
+ u32 a, b, c, d;
+
+ /* Temporaries used by the round function. */
+ u32 x, y;
+
+ /* Input whitening and packing. */
+ INPACK (0, a, 0);
+ INPACK (1, b, 1);
+ INPACK (2, c, 2);
+ INPACK (3, d, 3);
+
+ /* Encryption Feistel cycles. */
+ ENCCYCLE (0);
+ ENCCYCLE (1);
+ ENCCYCLE (2);
+ ENCCYCLE (3);
+ ENCCYCLE (4);
+ ENCCYCLE (5);
+ ENCCYCLE (6);
+ ENCCYCLE (7);
+
+ /* Output whitening and unpacking. */
+ OUTUNPACK (0, c, 4);
+ OUTUNPACK (1, d, 5);
+ OUTUNPACK (2, a, 6);
+ OUTUNPACK (3, b, 7);
+}
+
+static void
+twofish_encrypt (void *context, byte *out, const byte *in)
+{
+ TWOFISH_context *ctx = context;
+ do_twofish_encrypt (ctx, out, in);
+ _gcry_burn_stack (24+3*sizeof (void*));
+}
+
+
+/* Decrypt one block. in and out may be the same. */
+
+static void
+do_twofish_decrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
+{
+ /* The four 32-bit chunks of the text. */
+ u32 a, b, c, d;
+
+ /* Temporaries used by the round function. */
+ u32 x, y;
+
+ /* Input whitening and packing. */
+ INPACK (0, c, 4);
+ INPACK (1, d, 5);
+ INPACK (2, a, 6);
+ INPACK (3, b, 7);
+
+ /* Encryption Feistel cycles. */
+ DECCYCLE (7);
+ DECCYCLE (6);
+ DECCYCLE (5);
+ DECCYCLE (4);
+ DECCYCLE (3);
+ DECCYCLE (2);
+ DECCYCLE (1);
+ DECCYCLE (0);
+
+ /* Output whitening and unpacking. */
+ OUTUNPACK (0, a, 0);
+ OUTUNPACK (1, b, 1);
+ OUTUNPACK (2, c, 2);
+ OUTUNPACK (3, d, 3);
+}
+
+static void
+twofish_decrypt (void *context, byte *out, const byte *in)
+{
+ TWOFISH_context *ctx = context;
+
+ do_twofish_decrypt (ctx, out, in);
+ _gcry_burn_stack (24+3*sizeof (void*));
+}
+
+
+/* Test a single encryption and decryption with each key size. */
+
+static const char*
+selftest (void)
+{
+ TWOFISH_context ctx; /* Expanded key. */
+ byte scratch[16]; /* Encryption/decryption result buffer. */
+
+ /* Test vectors for single encryption/decryption. Note that I am using
+ * the vectors from the Twofish paper's "known answer test", I=3 for
+ * 128-bit and I=4 for 256-bit, instead of the all-0 vectors from the
+ * "intermediate value test", because an all-0 key would trigger all the
+ * special cases in the RS matrix multiply, leaving the math untested. */
+ static byte plaintext[16] = {
+ 0xD4, 0x91, 0xDB, 0x16, 0xE7, 0xB1, 0xC3, 0x9E,
+ 0x86, 0xCB, 0x08, 0x6B, 0x78, 0x9F, 0x54, 0x19
+ };
+ static byte key[16] = {
+ 0x9F, 0x58, 0x9F, 0x5C, 0xF6, 0x12, 0x2C, 0x32,
+ 0xB6, 0xBF, 0xEC, 0x2F, 0x2A, 0xE8, 0xC3, 0x5A
+ };
+ static const byte ciphertext[16] = {
+ 0x01, 0x9F, 0x98, 0x09, 0xDE, 0x17, 0x11, 0x85,
+ 0x8F, 0xAA, 0xC3, 0xA3, 0xBA, 0x20, 0xFB, 0xC3
+ };
+ static byte plaintext_256[16] = {
+ 0x90, 0xAF, 0xE9, 0x1B, 0xB2, 0x88, 0x54, 0x4F,
+ 0x2C, 0x32, 0xDC, 0x23, 0x9B, 0x26, 0x35, 0xE6
+ };
+ static byte key_256[32] = {
+ 0xD4, 0x3B, 0xB7, 0x55, 0x6E, 0xA3, 0x2E, 0x46,
+ 0xF2, 0xA2, 0x82, 0xB7, 0xD4, 0x5B, 0x4E, 0x0D,
+ 0x57, 0xFF, 0x73, 0x9D, 0x4D, 0xC9, 0x2C, 0x1B,
+ 0xD7, 0xFC, 0x01, 0x70, 0x0C, 0xC8, 0x21, 0x6F
+ };
+ static const byte ciphertext_256[16] = {
+ 0x6C, 0xB4, 0x56, 0x1C, 0x40, 0xBF, 0x0A, 0x97,
+ 0x05, 0x93, 0x1C, 0xB6, 0xD4, 0x08, 0xE7, 0xFA
+ };
+
+ twofish_setkey (&ctx, key, sizeof(key));
+ twofish_encrypt (&ctx, scratch, plaintext);
+ if (memcmp (scratch, ciphertext, sizeof (ciphertext)))
+ return "Twofish-128 test encryption failed.";
+ twofish_decrypt (&ctx, scratch, scratch);
+ if (memcmp (scratch, plaintext, sizeof (plaintext)))
+ return "Twofish-128 test decryption failed.";
+
+ twofish_setkey (&ctx, key_256, sizeof(key_256));
+ twofish_encrypt (&ctx, scratch, plaintext_256);
+ if (memcmp (scratch, ciphertext_256, sizeof (ciphertext_256)))
+ return "Twofish-256 test encryption failed.";
+ twofish_decrypt (&ctx, scratch, scratch);
+ if (memcmp (scratch, plaintext_256, sizeof (plaintext_256)))
+ return "Twofish-256 test decryption failed.";
+
+ return NULL;
+}
+
+/* More complete test program. This does 1000 encryptions and decryptions
+ * with each of 250 128-bit keys and 2000 encryptions and decryptions with
+ * each of 125 256-bit keys, using a feedback scheme similar to a Feistel
+ * cipher, so as to be sure of testing all the table entries pretty
+ * thoroughly. We keep changing the keys so as to get a more meaningful
+ * performance number, since the key setup is non-trivial for Twofish. */
+
+#ifdef TEST
+
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+int
+main()
+{
+ TWOFISH_context ctx; /* Expanded key. */
+ int i, j; /* Loop counters. */
+
+ const char *encrypt_msg; /* Message to print regarding encryption test;
+ * the printf is done outside the loop to avoid
+ * stuffing up the timing. */
+ clock_t timer; /* For computing elapsed time. */
+
+ /* Test buffer. */
+ byte buffer[4][16] = {
+ {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF},
+ {0x0F, 0x1E, 0x2D, 0x3C, 0x4B, 0x5A, 0x69, 0x78,
+ 0x87, 0x96, 0xA5, 0xB4, 0xC3, 0xD2 ,0xE1, 0xF0},
+ {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54 ,0x32, 0x10},
+ {0x01, 0x23, 0x45, 0x67, 0x76, 0x54 ,0x32, 0x10,
+ 0x89, 0xAB, 0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98}
+ };
+
+ /* Expected outputs for the million-operation test */
+ static const byte test_encrypt[4][16] = {
+ {0xC8, 0x23, 0xB8, 0xB7, 0x6B, 0xFE, 0x91, 0x13,
+ 0x2F, 0xA7, 0x5E, 0xE6, 0x94, 0x77, 0x6F, 0x6B},
+ {0x90, 0x36, 0xD8, 0x29, 0xD5, 0x96, 0xC2, 0x8E,
+ 0xE4, 0xFF, 0x76, 0xBC, 0xE5, 0x77, 0x88, 0x27},
+ {0xB8, 0x78, 0x69, 0xAF, 0x42, 0x8B, 0x48, 0x64,
+ 0xF7, 0xE9, 0xF3, 0x9C, 0x42, 0x18, 0x7B, 0x73},
+ {0x7A, 0x88, 0xFB, 0xEB, 0x90, 0xA4, 0xB4, 0xA8,
+ 0x43, 0xA3, 0x1D, 0xF1, 0x26, 0xC4, 0x53, 0x57}
+ };
+ static const byte test_decrypt[4][16] = {
+ {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF},
+ {0x0F, 0x1E, 0x2D, 0x3C, 0x4B, 0x5A, 0x69, 0x78,
+ 0x87, 0x96, 0xA5, 0xB4, 0xC3, 0xD2 ,0xE1, 0xF0},
+ {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54 ,0x32, 0x10},
+ {0x01, 0x23, 0x45, 0x67, 0x76, 0x54 ,0x32, 0x10,
+ 0x89, 0xAB, 0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98}
+ };
+
+ /* Start the timer ticking. */
+ timer = clock ();
+
+ /* Encryption test. */
+ for (i = 0; i < 125; i++)
+ {
+ twofish_setkey (&ctx, buffer[0], sizeof (buffer[0]));
+ for (j = 0; j < 1000; j++)
+ twofish_encrypt (&ctx, buffer[2], buffer[2]);
+ twofish_setkey (&ctx, buffer[1], sizeof (buffer[1]));
+ for (j = 0; j < 1000; j++)
+ twofish_encrypt (&ctx, buffer[3], buffer[3]);
+ twofish_setkey (&ctx, buffer[2], sizeof (buffer[2])*2);
+ for (j = 0; j < 1000; j++) {
+ twofish_encrypt (&ctx, buffer[0], buffer[0]);
+ twofish_encrypt (&ctx, buffer[1], buffer[1]);
+ }
+ }
+ encrypt_msg = memcmp (buffer, test_encrypt, sizeof (test_encrypt)) ?
+ "encryption failure!\n" : "encryption OK!\n";
+
+ /* Decryption test. */
+ for (i = 0; i < 125; i++)
+ {
+ twofish_setkey (&ctx, buffer[2], sizeof (buffer[2])*2);
+ for (j = 0; j < 1000; j++) {
+ twofish_decrypt (&ctx, buffer[0], buffer[0]);
+ twofish_decrypt (&ctx, buffer[1], buffer[1]);
+ }
+ twofish_setkey (&ctx, buffer[1], sizeof (buffer[1]));
+ for (j = 0; j < 1000; j++)
+ twofish_decrypt (&ctx, buffer[3], buffer[3]);
+ twofish_setkey (&ctx, buffer[0], sizeof (buffer[0]));
+ for (j = 0; j < 1000; j++)
+ twofish_decrypt (&ctx, buffer[2], buffer[2]);
+ }
+
+ /* Stop the timer, and print results. */
+ timer = clock () - timer;
+ printf (encrypt_msg);
+ printf (memcmp (buffer, test_decrypt, sizeof (test_decrypt)) ?
+ "decryption failure!\n" : "decryption OK!\n");
+ printf ("elapsed time: %.1f s.\n", (float) timer / CLOCKS_PER_SEC);
+
+ return 0;
+}
+
+#endif /* TEST */
+
+
+
+gcry_cipher_spec_t _gcry_cipher_spec_twofish =
+ {
+ "TWOFISH", NULL, NULL, 16, 256, sizeof (TWOFISH_context),
+ twofish_setkey, twofish_encrypt, twofish_decrypt
+ };
+
+gcry_cipher_spec_t _gcry_cipher_spec_twofish128 =
+ {
+ "TWOFISH128", NULL, NULL, 16, 128, sizeof (TWOFISH_context),
+ twofish_setkey, twofish_encrypt, twofish_decrypt
+ };
diff --git a/grub-core/lib/libgcrypt/cipher/whirlpool.c b/grub-core/lib/libgcrypt/cipher/whirlpool.c
new file mode 100644
index 0000000..c89a572
--- /dev/null
+++ b/grub-core/lib/libgcrypt/cipher/whirlpool.c
@@ -0,0 +1,1405 @@
+/* whirlpool.c - Whirlpool hashing algorithm
+ * Copyright (C) 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ */
+
+/* This is an implementation of the Whirlpool hashing algorithm, which
+ has been developed by Vincent Rijmen and Paulo S. L. M. Barreto;
+ it's homepage is located at:
+ http://planeta.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html.
+
+ The S-Boxes and the structure of the main transformation function,
+ which implements an optimized version of the algorithm, is taken
+ from the reference implementation available from
+ http://planeta.terra.com.br/informatica/paulobarreto/whirlpool.zip. */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "types.h"
+#include "g10lib.h"
+#include "cipher.h"
+
+#include "bithelp.h"
+
+/* Size of a whirlpool block (in bytes). */
+#define BLOCK_SIZE 64
+
+/* Number of rounds. */
+#define R 10
+
+
+
+/* Types. */
+typedef u64 whirlpool_block_t[BLOCK_SIZE / 8];
+
+typedef struct {
+ whirlpool_block_t hash_state;
+ unsigned char buffer[BLOCK_SIZE];
+ size_t count;
+ unsigned char length[32];
+} whirlpool_context_t;
+
+
+
+/* Macros. */
+
+/* Convert the the buffer BUFFER into a block BLOCK, using I as
+ counter. */
+#define buffer_to_block(buffer, block, i) \
+ for (i = 0; i < 8; i++) \
+ (block)[i] = ((u64) (0 \
+ | (((u64) (buffer)[i * 8 + 0]) << 56) \
+ | (((u64) (buffer)[i * 8 + 1]) << 48) \
+ | (((u64) (buffer)[i * 8 + 2]) << 40) \
+ | (((u64) (buffer)[i * 8 + 3]) << 32) \
+ | (((u64) (buffer)[i * 8 + 4]) << 24) \
+ | (((u64) (buffer)[i * 8 + 5]) << 16) \
+ | (((u64) (buffer)[i * 8 + 6]) << 8) \
+ | (((u64) (buffer)[i * 8 + 7]) << 0)));
+
+/* Convert the block BLOCK into a buffer BUFFER, using I as
+ counter. */
+#define block_to_buffer(buffer, block, i) \
+ for (i = 0; i < 8; i++) \
+ { \
+ (buffer)[i * 8 + 0] = (block[i] >> 56) & 0xFF; \
+ (buffer)[i * 8 + 1] = (block[i] >> 48) & 0xFF; \
+ (buffer)[i * 8 + 2] = (block[i] >> 40) & 0xFF; \
+ (buffer)[i * 8 + 3] = (block[i] >> 32) & 0xFF; \
+ (buffer)[i * 8 + 4] = (block[i] >> 24) & 0xFF; \
+ (buffer)[i * 8 + 5] = (block[i] >> 16) & 0xFF; \
+ (buffer)[i * 8 + 6] = (block[i] >> 8) & 0xFF; \
+ (buffer)[i * 8 + 7] = (block[i] >> 0) & 0xFF; \
+ }
+
+/* Copy the block BLOCK_SRC to BLOCK_DST, using I as counter. */
+#define block_copy(block_dst, block_src, i) \
+ for (i = 0; i < 8; i++) \
+ block_dst[i] = block_src[i];
+
+/* XOR the block BLOCK_SRC into BLOCK_DST, using I as counter. */
+#define block_xor(block_dst, block_src, i) \
+ for (i = 0; i < 8; i++) \
+ block_dst[i] ^= block_src[i];
+
+
+
+/* Round constants. */
+static const u64 rc[R] =
+ {
+ U64_C (0x1823c6e887b8014f),
+ U64_C (0x36a6d2f5796f9152),
+ U64_C (0x60bc9b8ea30c7b35),
+ U64_C (0x1de0d7c22e4bfe57),
+ U64_C (0x157737e59ff04ada),
+ U64_C (0x58c9290ab1a06b85),
+ U64_C (0xbd5d10f4cb3e0567),
+ U64_C (0xe427418ba77d95d8),
+ U64_C (0xfbee7c66dd17479e),
+ U64_C (0xca2dbf07ad5a8333),
+ };
+
+
+
+/* Main lookup boxes. */
+static const u64 C0[256] =
+ {
+ U64_C (0x18186018c07830d8), U64_C (0x23238c2305af4626),
+ U64_C (0xc6c63fc67ef991b8), U64_C (0xe8e887e8136fcdfb),
+ U64_C (0x878726874ca113cb), U64_C (0xb8b8dab8a9626d11),
+ U64_C (0x0101040108050209), U64_C (0x4f4f214f426e9e0d),
+ U64_C (0x3636d836adee6c9b), U64_C (0xa6a6a2a6590451ff),
+ U64_C (0xd2d26fd2debdb90c), U64_C (0xf5f5f3f5fb06f70e),
+ U64_C (0x7979f979ef80f296), U64_C (0x6f6fa16f5fcede30),
+ U64_C (0x91917e91fcef3f6d), U64_C (0x52525552aa07a4f8),
+ U64_C (0x60609d6027fdc047), U64_C (0xbcbccabc89766535),
+ U64_C (0x9b9b569baccd2b37), U64_C (0x8e8e028e048c018a),
+ U64_C (0xa3a3b6a371155bd2), U64_C (0x0c0c300c603c186c),
+ U64_C (0x7b7bf17bff8af684), U64_C (0x3535d435b5e16a80),
+ U64_C (0x1d1d741de8693af5), U64_C (0xe0e0a7e05347ddb3),
+ U64_C (0xd7d77bd7f6acb321), U64_C (0xc2c22fc25eed999c),
+ U64_C (0x2e2eb82e6d965c43), U64_C (0x4b4b314b627a9629),
+ U64_C (0xfefedffea321e15d), U64_C (0x575741578216aed5),
+ U64_C (0x15155415a8412abd), U64_C (0x7777c1779fb6eee8),
+ U64_C (0x3737dc37a5eb6e92), U64_C (0xe5e5b3e57b56d79e),
+ U64_C (0x9f9f469f8cd92313), U64_C (0xf0f0e7f0d317fd23),
+ U64_C (0x4a4a354a6a7f9420), U64_C (0xdada4fda9e95a944),
+ U64_C (0x58587d58fa25b0a2), U64_C (0xc9c903c906ca8fcf),
+ U64_C (0x2929a429558d527c), U64_C (0x0a0a280a5022145a),
+ U64_C (0xb1b1feb1e14f7f50), U64_C (0xa0a0baa0691a5dc9),
+ U64_C (0x6b6bb16b7fdad614), U64_C (0x85852e855cab17d9),
+ U64_C (0xbdbdcebd8173673c), U64_C (0x5d5d695dd234ba8f),
+ U64_C (0x1010401080502090), U64_C (0xf4f4f7f4f303f507),
+ U64_C (0xcbcb0bcb16c08bdd), U64_C (0x3e3ef83eedc67cd3),
+ U64_C (0x0505140528110a2d), U64_C (0x676781671fe6ce78),
+ U64_C (0xe4e4b7e47353d597), U64_C (0x27279c2725bb4e02),
+ U64_C (0x4141194132588273), U64_C (0x8b8b168b2c9d0ba7),
+ U64_C (0xa7a7a6a7510153f6), U64_C (0x7d7de97dcf94fab2),
+ U64_C (0x95956e95dcfb3749), U64_C (0xd8d847d88e9fad56),
+ U64_C (0xfbfbcbfb8b30eb70), U64_C (0xeeee9fee2371c1cd),
+ U64_C (0x7c7ced7cc791f8bb), U64_C (0x6666856617e3cc71),
+ U64_C (0xdddd53dda68ea77b), U64_C (0x17175c17b84b2eaf),
+ U64_C (0x4747014702468e45), U64_C (0x9e9e429e84dc211a),
+ U64_C (0xcaca0fca1ec589d4), U64_C (0x2d2db42d75995a58),
+ U64_C (0xbfbfc6bf9179632e), U64_C (0x07071c07381b0e3f),
+ U64_C (0xadad8ead012347ac), U64_C (0x5a5a755aea2fb4b0),
+ U64_C (0x838336836cb51bef), U64_C (0x3333cc3385ff66b6),
+ U64_C (0x636391633ff2c65c), U64_C (0x02020802100a0412),
+ U64_C (0xaaaa92aa39384993), U64_C (0x7171d971afa8e2de),
+ U64_C (0xc8c807c80ecf8dc6), U64_C (0x19196419c87d32d1),
+ U64_C (0x494939497270923b), U64_C (0xd9d943d9869aaf5f),
+ U64_C (0xf2f2eff2c31df931), U64_C (0xe3e3abe34b48dba8),
+ U64_C (0x5b5b715be22ab6b9), U64_C (0x88881a8834920dbc),
+ U64_C (0x9a9a529aa4c8293e), U64_C (0x262698262dbe4c0b),
+ U64_C (0x3232c8328dfa64bf), U64_C (0xb0b0fab0e94a7d59),
+ U64_C (0xe9e983e91b6acff2), U64_C (0x0f0f3c0f78331e77),
+ U64_C (0xd5d573d5e6a6b733), U64_C (0x80803a8074ba1df4),
+ U64_C (0xbebec2be997c6127), U64_C (0xcdcd13cd26de87eb),
+ U64_C (0x3434d034bde46889), U64_C (0x48483d487a759032),
+ U64_C (0xffffdbffab24e354), U64_C (0x7a7af57af78ff48d),
+ U64_C (0x90907a90f4ea3d64), U64_C (0x5f5f615fc23ebe9d),
+ U64_C (0x202080201da0403d), U64_C (0x6868bd6867d5d00f),
+ U64_C (0x1a1a681ad07234ca), U64_C (0xaeae82ae192c41b7),
+ U64_C (0xb4b4eab4c95e757d), U64_C (0x54544d549a19a8ce),
+ U64_C (0x93937693ece53b7f), U64_C (0x222288220daa442f),
+ U64_C (0x64648d6407e9c863), U64_C (0xf1f1e3f1db12ff2a),
+ U64_C (0x7373d173bfa2e6cc), U64_C (0x12124812905a2482),
+ U64_C (0x40401d403a5d807a), U64_C (0x0808200840281048),
+ U64_C (0xc3c32bc356e89b95), U64_C (0xecec97ec337bc5df),
+ U64_C (0xdbdb4bdb9690ab4d), U64_C (0xa1a1bea1611f5fc0),
+ U64_C (0x8d8d0e8d1c830791), U64_C (0x3d3df43df5c97ac8),
+ U64_C (0x97976697ccf1335b), U64_C (0x0000000000000000),
+ U64_C (0xcfcf1bcf36d483f9), U64_C (0x2b2bac2b4587566e),
+ U64_C (0x7676c57697b3ece1), U64_C (0x8282328264b019e6),
+ U64_C (0xd6d67fd6fea9b128), U64_C (0x1b1b6c1bd87736c3),
+ U64_C (0xb5b5eeb5c15b7774), U64_C (0xafaf86af112943be),
+ U64_C (0x6a6ab56a77dfd41d), U64_C (0x50505d50ba0da0ea),
+ U64_C (0x45450945124c8a57), U64_C (0xf3f3ebf3cb18fb38),
+ U64_C (0x3030c0309df060ad), U64_C (0xefef9bef2b74c3c4),
+ U64_C (0x3f3ffc3fe5c37eda), U64_C (0x55554955921caac7),
+ U64_C (0xa2a2b2a2791059db), U64_C (0xeaea8fea0365c9e9),
+ U64_C (0x656589650fecca6a), U64_C (0xbabad2bab9686903),
+ U64_C (0x2f2fbc2f65935e4a), U64_C (0xc0c027c04ee79d8e),
+ U64_C (0xdede5fdebe81a160), U64_C (0x1c1c701ce06c38fc),
+ U64_C (0xfdfdd3fdbb2ee746), U64_C (0x4d4d294d52649a1f),
+ U64_C (0x92927292e4e03976), U64_C (0x7575c9758fbceafa),
+ U64_C (0x06061806301e0c36), U64_C (0x8a8a128a249809ae),
+ U64_C (0xb2b2f2b2f940794b), U64_C (0xe6e6bfe66359d185),
+ U64_C (0x0e0e380e70361c7e), U64_C (0x1f1f7c1ff8633ee7),
+ U64_C (0x6262956237f7c455), U64_C (0xd4d477d4eea3b53a),
+ U64_C (0xa8a89aa829324d81), U64_C (0x96966296c4f43152),
+ U64_C (0xf9f9c3f99b3aef62), U64_C (0xc5c533c566f697a3),
+ U64_C (0x2525942535b14a10), U64_C (0x59597959f220b2ab),
+ U64_C (0x84842a8454ae15d0), U64_C (0x7272d572b7a7e4c5),
+ U64_C (0x3939e439d5dd72ec), U64_C (0x4c4c2d4c5a619816),
+ U64_C (0x5e5e655eca3bbc94), U64_C (0x7878fd78e785f09f),
+ U64_C (0x3838e038ddd870e5), U64_C (0x8c8c0a8c14860598),
+ U64_C (0xd1d163d1c6b2bf17), U64_C (0xa5a5aea5410b57e4),
+ U64_C (0xe2e2afe2434dd9a1), U64_C (0x616199612ff8c24e),
+ U64_C (0xb3b3f6b3f1457b42), U64_C (0x2121842115a54234),
+ U64_C (0x9c9c4a9c94d62508), U64_C (0x1e1e781ef0663cee),
+ U64_C (0x4343114322528661), U64_C (0xc7c73bc776fc93b1),
+ U64_C (0xfcfcd7fcb32be54f), U64_C (0x0404100420140824),
+ U64_C (0x51515951b208a2e3), U64_C (0x99995e99bcc72f25),
+ U64_C (0x6d6da96d4fc4da22), U64_C (0x0d0d340d68391a65),
+ U64_C (0xfafacffa8335e979), U64_C (0xdfdf5bdfb684a369),
+ U64_C (0x7e7ee57ed79bfca9), U64_C (0x242490243db44819),
+ U64_C (0x3b3bec3bc5d776fe), U64_C (0xabab96ab313d4b9a),
+ U64_C (0xcece1fce3ed181f0), U64_C (0x1111441188552299),
+ U64_C (0x8f8f068f0c890383), U64_C (0x4e4e254e4a6b9c04),
+ U64_C (0xb7b7e6b7d1517366), U64_C (0xebeb8beb0b60cbe0),
+ U64_C (0x3c3cf03cfdcc78c1), U64_C (0x81813e817cbf1ffd),
+ U64_C (0x94946a94d4fe3540), U64_C (0xf7f7fbf7eb0cf31c),
+ U64_C (0xb9b9deb9a1676f18), U64_C (0x13134c13985f268b),
+ U64_C (0x2c2cb02c7d9c5851), U64_C (0xd3d36bd3d6b8bb05),
+ U64_C (0xe7e7bbe76b5cd38c), U64_C (0x6e6ea56e57cbdc39),
+ U64_C (0xc4c437c46ef395aa), U64_C (0x03030c03180f061b),
+ U64_C (0x565645568a13acdc), U64_C (0x44440d441a49885e),
+ U64_C (0x7f7fe17fdf9efea0), U64_C (0xa9a99ea921374f88),
+ U64_C (0x2a2aa82a4d825467), U64_C (0xbbbbd6bbb16d6b0a),
+ U64_C (0xc1c123c146e29f87), U64_C (0x53535153a202a6f1),
+ U64_C (0xdcdc57dcae8ba572), U64_C (0x0b0b2c0b58271653),
+ U64_C (0x9d9d4e9d9cd32701), U64_C (0x6c6cad6c47c1d82b),
+ U64_C (0x3131c43195f562a4), U64_C (0x7474cd7487b9e8f3),
+ U64_C (0xf6f6fff6e309f115), U64_C (0x464605460a438c4c),
+ U64_C (0xacac8aac092645a5), U64_C (0x89891e893c970fb5),
+ U64_C (0x14145014a04428b4), U64_C (0xe1e1a3e15b42dfba),
+ U64_C (0x16165816b04e2ca6), U64_C (0x3a3ae83acdd274f7),
+ U64_C (0x6969b9696fd0d206), U64_C (0x09092409482d1241),
+ U64_C (0x7070dd70a7ade0d7), U64_C (0xb6b6e2b6d954716f),
+ U64_C (0xd0d067d0ceb7bd1e), U64_C (0xeded93ed3b7ec7d6),
+ U64_C (0xcccc17cc2edb85e2), U64_C (0x424215422a578468),
+ U64_C (0x98985a98b4c22d2c), U64_C (0xa4a4aaa4490e55ed),
+ U64_C (0x2828a0285d885075), U64_C (0x5c5c6d5cda31b886),
+ U64_C (0xf8f8c7f8933fed6b), U64_C (0x8686228644a411c2),
+ };
+
+static const u64 C1[256] =
+ {
+ U64_C (0xd818186018c07830), U64_C (0x2623238c2305af46),
+ U64_C (0xb8c6c63fc67ef991), U64_C (0xfbe8e887e8136fcd),
+ U64_C (0xcb878726874ca113), U64_C (0x11b8b8dab8a9626d),
+ U64_C (0x0901010401080502), U64_C (0x0d4f4f214f426e9e),
+ U64_C (0x9b3636d836adee6c), U64_C (0xffa6a6a2a6590451),
+ U64_C (0x0cd2d26fd2debdb9), U64_C (0x0ef5f5f3f5fb06f7),
+ U64_C (0x967979f979ef80f2), U64_C (0x306f6fa16f5fcede),
+ U64_C (0x6d91917e91fcef3f), U64_C (0xf852525552aa07a4),
+ U64_C (0x4760609d6027fdc0), U64_C (0x35bcbccabc897665),
+ U64_C (0x379b9b569baccd2b), U64_C (0x8a8e8e028e048c01),
+ U64_C (0xd2a3a3b6a371155b), U64_C (0x6c0c0c300c603c18),
+ U64_C (0x847b7bf17bff8af6), U64_C (0x803535d435b5e16a),
+ U64_C (0xf51d1d741de8693a), U64_C (0xb3e0e0a7e05347dd),
+ U64_C (0x21d7d77bd7f6acb3), U64_C (0x9cc2c22fc25eed99),
+ U64_C (0x432e2eb82e6d965c), U64_C (0x294b4b314b627a96),
+ U64_C (0x5dfefedffea321e1), U64_C (0xd5575741578216ae),
+ U64_C (0xbd15155415a8412a), U64_C (0xe87777c1779fb6ee),
+ U64_C (0x923737dc37a5eb6e), U64_C (0x9ee5e5b3e57b56d7),
+ U64_C (0x139f9f469f8cd923), U64_C (0x23f0f0e7f0d317fd),
+ U64_C (0x204a4a354a6a7f94), U64_C (0x44dada4fda9e95a9),
+ U64_C (0xa258587d58fa25b0), U64_C (0xcfc9c903c906ca8f),
+ U64_C (0x7c2929a429558d52), U64_C (0x5a0a0a280a502214),
+ U64_C (0x50b1b1feb1e14f7f), U64_C (0xc9a0a0baa0691a5d),
+ U64_C (0x146b6bb16b7fdad6), U64_C (0xd985852e855cab17),
+ U64_C (0x3cbdbdcebd817367), U64_C (0x8f5d5d695dd234ba),
+ U64_C (0x9010104010805020), U64_C (0x07f4f4f7f4f303f5),
+ U64_C (0xddcbcb0bcb16c08b), U64_C (0xd33e3ef83eedc67c),
+ U64_C (0x2d0505140528110a), U64_C (0x78676781671fe6ce),
+ U64_C (0x97e4e4b7e47353d5), U64_C (0x0227279c2725bb4e),
+ U64_C (0x7341411941325882), U64_C (0xa78b8b168b2c9d0b),
+ U64_C (0xf6a7a7a6a7510153), U64_C (0xb27d7de97dcf94fa),
+ U64_C (0x4995956e95dcfb37), U64_C (0x56d8d847d88e9fad),
+ U64_C (0x70fbfbcbfb8b30eb), U64_C (0xcdeeee9fee2371c1),
+ U64_C (0xbb7c7ced7cc791f8), U64_C (0x716666856617e3cc),
+ U64_C (0x7bdddd53dda68ea7), U64_C (0xaf17175c17b84b2e),
+ U64_C (0x454747014702468e), U64_C (0x1a9e9e429e84dc21),
+ U64_C (0xd4caca0fca1ec589), U64_C (0x582d2db42d75995a),
+ U64_C (0x2ebfbfc6bf917963), U64_C (0x3f07071c07381b0e),
+ U64_C (0xacadad8ead012347), U64_C (0xb05a5a755aea2fb4),
+ U64_C (0xef838336836cb51b), U64_C (0xb63333cc3385ff66),
+ U64_C (0x5c636391633ff2c6), U64_C (0x1202020802100a04),
+ U64_C (0x93aaaa92aa393849), U64_C (0xde7171d971afa8e2),
+ U64_C (0xc6c8c807c80ecf8d), U64_C (0xd119196419c87d32),
+ U64_C (0x3b49493949727092), U64_C (0x5fd9d943d9869aaf),
+ U64_C (0x31f2f2eff2c31df9), U64_C (0xa8e3e3abe34b48db),
+ U64_C (0xb95b5b715be22ab6), U64_C (0xbc88881a8834920d),
+ U64_C (0x3e9a9a529aa4c829), U64_C (0x0b262698262dbe4c),
+ U64_C (0xbf3232c8328dfa64), U64_C (0x59b0b0fab0e94a7d),
+ U64_C (0xf2e9e983e91b6acf), U64_C (0x770f0f3c0f78331e),
+ U64_C (0x33d5d573d5e6a6b7), U64_C (0xf480803a8074ba1d),
+ U64_C (0x27bebec2be997c61), U64_C (0xebcdcd13cd26de87),
+ U64_C (0x893434d034bde468), U64_C (0x3248483d487a7590),
+ U64_C (0x54ffffdbffab24e3), U64_C (0x8d7a7af57af78ff4),
+ U64_C (0x6490907a90f4ea3d), U64_C (0x9d5f5f615fc23ebe),
+ U64_C (0x3d202080201da040), U64_C (0x0f6868bd6867d5d0),
+ U64_C (0xca1a1a681ad07234), U64_C (0xb7aeae82ae192c41),
+ U64_C (0x7db4b4eab4c95e75), U64_C (0xce54544d549a19a8),
+ U64_C (0x7f93937693ece53b), U64_C (0x2f222288220daa44),
+ U64_C (0x6364648d6407e9c8), U64_C (0x2af1f1e3f1db12ff),
+ U64_C (0xcc7373d173bfa2e6), U64_C (0x8212124812905a24),
+ U64_C (0x7a40401d403a5d80), U64_C (0x4808082008402810),
+ U64_C (0x95c3c32bc356e89b), U64_C (0xdfecec97ec337bc5),
+ U64_C (0x4ddbdb4bdb9690ab), U64_C (0xc0a1a1bea1611f5f),
+ U64_C (0x918d8d0e8d1c8307), U64_C (0xc83d3df43df5c97a),
+ U64_C (0x5b97976697ccf133), U64_C (0x0000000000000000),
+ U64_C (0xf9cfcf1bcf36d483), U64_C (0x6e2b2bac2b458756),
+ U64_C (0xe17676c57697b3ec), U64_C (0xe68282328264b019),
+ U64_C (0x28d6d67fd6fea9b1), U64_C (0xc31b1b6c1bd87736),
+ U64_C (0x74b5b5eeb5c15b77), U64_C (0xbeafaf86af112943),
+ U64_C (0x1d6a6ab56a77dfd4), U64_C (0xea50505d50ba0da0),
+ U64_C (0x5745450945124c8a), U64_C (0x38f3f3ebf3cb18fb),
+ U64_C (0xad3030c0309df060), U64_C (0xc4efef9bef2b74c3),
+ U64_C (0xda3f3ffc3fe5c37e), U64_C (0xc755554955921caa),
+ U64_C (0xdba2a2b2a2791059), U64_C (0xe9eaea8fea0365c9),
+ U64_C (0x6a656589650fecca), U64_C (0x03babad2bab96869),
+ U64_C (0x4a2f2fbc2f65935e), U64_C (0x8ec0c027c04ee79d),
+ U64_C (0x60dede5fdebe81a1), U64_C (0xfc1c1c701ce06c38),
+ U64_C (0x46fdfdd3fdbb2ee7), U64_C (0x1f4d4d294d52649a),
+ U64_C (0x7692927292e4e039), U64_C (0xfa7575c9758fbcea),
+ U64_C (0x3606061806301e0c), U64_C (0xae8a8a128a249809),
+ U64_C (0x4bb2b2f2b2f94079), U64_C (0x85e6e6bfe66359d1),
+ U64_C (0x7e0e0e380e70361c), U64_C (0xe71f1f7c1ff8633e),
+ U64_C (0x556262956237f7c4), U64_C (0x3ad4d477d4eea3b5),
+ U64_C (0x81a8a89aa829324d), U64_C (0x5296966296c4f431),
+ U64_C (0x62f9f9c3f99b3aef), U64_C (0xa3c5c533c566f697),
+ U64_C (0x102525942535b14a), U64_C (0xab59597959f220b2),
+ U64_C (0xd084842a8454ae15), U64_C (0xc57272d572b7a7e4),
+ U64_C (0xec3939e439d5dd72), U64_C (0x164c4c2d4c5a6198),
+ U64_C (0x945e5e655eca3bbc), U64_C (0x9f7878fd78e785f0),
+ U64_C (0xe53838e038ddd870), U64_C (0x988c8c0a8c148605),
+ U64_C (0x17d1d163d1c6b2bf), U64_C (0xe4a5a5aea5410b57),
+ U64_C (0xa1e2e2afe2434dd9), U64_C (0x4e616199612ff8c2),
+ U64_C (0x42b3b3f6b3f1457b), U64_C (0x342121842115a542),
+ U64_C (0x089c9c4a9c94d625), U64_C (0xee1e1e781ef0663c),
+ U64_C (0x6143431143225286), U64_C (0xb1c7c73bc776fc93),
+ U64_C (0x4ffcfcd7fcb32be5), U64_C (0x2404041004201408),
+ U64_C (0xe351515951b208a2), U64_C (0x2599995e99bcc72f),
+ U64_C (0x226d6da96d4fc4da), U64_C (0x650d0d340d68391a),
+ U64_C (0x79fafacffa8335e9), U64_C (0x69dfdf5bdfb684a3),
+ U64_C (0xa97e7ee57ed79bfc), U64_C (0x19242490243db448),
+ U64_C (0xfe3b3bec3bc5d776), U64_C (0x9aabab96ab313d4b),
+ U64_C (0xf0cece1fce3ed181), U64_C (0x9911114411885522),
+ U64_C (0x838f8f068f0c8903), U64_C (0x044e4e254e4a6b9c),
+ U64_C (0x66b7b7e6b7d15173), U64_C (0xe0ebeb8beb0b60cb),
+ U64_C (0xc13c3cf03cfdcc78), U64_C (0xfd81813e817cbf1f),
+ U64_C (0x4094946a94d4fe35), U64_C (0x1cf7f7fbf7eb0cf3),
+ U64_C (0x18b9b9deb9a1676f), U64_C (0x8b13134c13985f26),
+ U64_C (0x512c2cb02c7d9c58), U64_C (0x05d3d36bd3d6b8bb),
+ U64_C (0x8ce7e7bbe76b5cd3), U64_C (0x396e6ea56e57cbdc),
+ U64_C (0xaac4c437c46ef395), U64_C (0x1b03030c03180f06),
+ U64_C (0xdc565645568a13ac), U64_C (0x5e44440d441a4988),
+ U64_C (0xa07f7fe17fdf9efe), U64_C (0x88a9a99ea921374f),
+ U64_C (0x672a2aa82a4d8254), U64_C (0x0abbbbd6bbb16d6b),
+ U64_C (0x87c1c123c146e29f), U64_C (0xf153535153a202a6),
+ U64_C (0x72dcdc57dcae8ba5), U64_C (0x530b0b2c0b582716),
+ U64_C (0x019d9d4e9d9cd327), U64_C (0x2b6c6cad6c47c1d8),
+ U64_C (0xa43131c43195f562), U64_C (0xf37474cd7487b9e8),
+ U64_C (0x15f6f6fff6e309f1), U64_C (0x4c464605460a438c),
+ U64_C (0xa5acac8aac092645), U64_C (0xb589891e893c970f),
+ U64_C (0xb414145014a04428), U64_C (0xbae1e1a3e15b42df),
+ U64_C (0xa616165816b04e2c), U64_C (0xf73a3ae83acdd274),
+ U64_C (0x066969b9696fd0d2), U64_C (0x4109092409482d12),
+ U64_C (0xd77070dd70a7ade0), U64_C (0x6fb6b6e2b6d95471),
+ U64_C (0x1ed0d067d0ceb7bd), U64_C (0xd6eded93ed3b7ec7),
+ U64_C (0xe2cccc17cc2edb85), U64_C (0x68424215422a5784),
+ U64_C (0x2c98985a98b4c22d), U64_C (0xeda4a4aaa4490e55),
+ U64_C (0x752828a0285d8850), U64_C (0x865c5c6d5cda31b8),
+ U64_C (0x6bf8f8c7f8933fed), U64_C (0xc28686228644a411),
+ };
+
+static const u64 C2[256] =
+ {
+ U64_C (0x30d818186018c078), U64_C (0x462623238c2305af),
+ U64_C (0x91b8c6c63fc67ef9), U64_C (0xcdfbe8e887e8136f),
+ U64_C (0x13cb878726874ca1), U64_C (0x6d11b8b8dab8a962),
+ U64_C (0x0209010104010805), U64_C (0x9e0d4f4f214f426e),
+ U64_C (0x6c9b3636d836adee), U64_C (0x51ffa6a6a2a65904),
+ U64_C (0xb90cd2d26fd2debd), U64_C (0xf70ef5f5f3f5fb06),
+ U64_C (0xf2967979f979ef80), U64_C (0xde306f6fa16f5fce),
+ U64_C (0x3f6d91917e91fcef), U64_C (0xa4f852525552aa07),
+ U64_C (0xc04760609d6027fd), U64_C (0x6535bcbccabc8976),
+ U64_C (0x2b379b9b569baccd), U64_C (0x018a8e8e028e048c),
+ U64_C (0x5bd2a3a3b6a37115), U64_C (0x186c0c0c300c603c),
+ U64_C (0xf6847b7bf17bff8a), U64_C (0x6a803535d435b5e1),
+ U64_C (0x3af51d1d741de869), U64_C (0xddb3e0e0a7e05347),
+ U64_C (0xb321d7d77bd7f6ac), U64_C (0x999cc2c22fc25eed),
+ U64_C (0x5c432e2eb82e6d96), U64_C (0x96294b4b314b627a),
+ U64_C (0xe15dfefedffea321), U64_C (0xaed5575741578216),
+ U64_C (0x2abd15155415a841), U64_C (0xeee87777c1779fb6),
+ U64_C (0x6e923737dc37a5eb), U64_C (0xd79ee5e5b3e57b56),
+ U64_C (0x23139f9f469f8cd9), U64_C (0xfd23f0f0e7f0d317),
+ U64_C (0x94204a4a354a6a7f), U64_C (0xa944dada4fda9e95),
+ U64_C (0xb0a258587d58fa25), U64_C (0x8fcfc9c903c906ca),
+ U64_C (0x527c2929a429558d), U64_C (0x145a0a0a280a5022),
+ U64_C (0x7f50b1b1feb1e14f), U64_C (0x5dc9a0a0baa0691a),
+ U64_C (0xd6146b6bb16b7fda), U64_C (0x17d985852e855cab),
+ U64_C (0x673cbdbdcebd8173), U64_C (0xba8f5d5d695dd234),
+ U64_C (0x2090101040108050), U64_C (0xf507f4f4f7f4f303),
+ U64_C (0x8bddcbcb0bcb16c0), U64_C (0x7cd33e3ef83eedc6),
+ U64_C (0x0a2d050514052811), U64_C (0xce78676781671fe6),
+ U64_C (0xd597e4e4b7e47353), U64_C (0x4e0227279c2725bb),
+ U64_C (0x8273414119413258), U64_C (0x0ba78b8b168b2c9d),
+ U64_C (0x53f6a7a7a6a75101), U64_C (0xfab27d7de97dcf94),
+ U64_C (0x374995956e95dcfb), U64_C (0xad56d8d847d88e9f),
+ U64_C (0xeb70fbfbcbfb8b30), U64_C (0xc1cdeeee9fee2371),
+ U64_C (0xf8bb7c7ced7cc791), U64_C (0xcc716666856617e3),
+ U64_C (0xa77bdddd53dda68e), U64_C (0x2eaf17175c17b84b),
+ U64_C (0x8e45474701470246), U64_C (0x211a9e9e429e84dc),
+ U64_C (0x89d4caca0fca1ec5), U64_C (0x5a582d2db42d7599),
+ U64_C (0x632ebfbfc6bf9179), U64_C (0x0e3f07071c07381b),
+ U64_C (0x47acadad8ead0123), U64_C (0xb4b05a5a755aea2f),
+ U64_C (0x1bef838336836cb5), U64_C (0x66b63333cc3385ff),
+ U64_C (0xc65c636391633ff2), U64_C (0x041202020802100a),
+ U64_C (0x4993aaaa92aa3938), U64_C (0xe2de7171d971afa8),
+ U64_C (0x8dc6c8c807c80ecf), U64_C (0x32d119196419c87d),
+ U64_C (0x923b494939497270), U64_C (0xaf5fd9d943d9869a),
+ U64_C (0xf931f2f2eff2c31d), U64_C (0xdba8e3e3abe34b48),
+ U64_C (0xb6b95b5b715be22a), U64_C (0x0dbc88881a883492),
+ U64_C (0x293e9a9a529aa4c8), U64_C (0x4c0b262698262dbe),
+ U64_C (0x64bf3232c8328dfa), U64_C (0x7d59b0b0fab0e94a),
+ U64_C (0xcff2e9e983e91b6a), U64_C (0x1e770f0f3c0f7833),
+ U64_C (0xb733d5d573d5e6a6), U64_C (0x1df480803a8074ba),
+ U64_C (0x6127bebec2be997c), U64_C (0x87ebcdcd13cd26de),
+ U64_C (0x68893434d034bde4), U64_C (0x903248483d487a75),
+ U64_C (0xe354ffffdbffab24), U64_C (0xf48d7a7af57af78f),
+ U64_C (0x3d6490907a90f4ea), U64_C (0xbe9d5f5f615fc23e),
+ U64_C (0x403d202080201da0), U64_C (0xd00f6868bd6867d5),
+ U64_C (0x34ca1a1a681ad072), U64_C (0x41b7aeae82ae192c),
+ U64_C (0x757db4b4eab4c95e), U64_C (0xa8ce54544d549a19),
+ U64_C (0x3b7f93937693ece5), U64_C (0x442f222288220daa),
+ U64_C (0xc86364648d6407e9), U64_C (0xff2af1f1e3f1db12),
+ U64_C (0xe6cc7373d173bfa2), U64_C (0x248212124812905a),
+ U64_C (0x807a40401d403a5d), U64_C (0x1048080820084028),
+ U64_C (0x9b95c3c32bc356e8), U64_C (0xc5dfecec97ec337b),
+ U64_C (0xab4ddbdb4bdb9690), U64_C (0x5fc0a1a1bea1611f),
+ U64_C (0x07918d8d0e8d1c83), U64_C (0x7ac83d3df43df5c9),
+ U64_C (0x335b97976697ccf1), U64_C (0x0000000000000000),
+ U64_C (0x83f9cfcf1bcf36d4), U64_C (0x566e2b2bac2b4587),
+ U64_C (0xece17676c57697b3), U64_C (0x19e68282328264b0),
+ U64_C (0xb128d6d67fd6fea9), U64_C (0x36c31b1b6c1bd877),
+ U64_C (0x7774b5b5eeb5c15b), U64_C (0x43beafaf86af1129),
+ U64_C (0xd41d6a6ab56a77df), U64_C (0xa0ea50505d50ba0d),
+ U64_C (0x8a5745450945124c), U64_C (0xfb38f3f3ebf3cb18),
+ U64_C (0x60ad3030c0309df0), U64_C (0xc3c4efef9bef2b74),
+ U64_C (0x7eda3f3ffc3fe5c3), U64_C (0xaac755554955921c),
+ U64_C (0x59dba2a2b2a27910), U64_C (0xc9e9eaea8fea0365),
+ U64_C (0xca6a656589650fec), U64_C (0x6903babad2bab968),
+ U64_C (0x5e4a2f2fbc2f6593), U64_C (0x9d8ec0c027c04ee7),
+ U64_C (0xa160dede5fdebe81), U64_C (0x38fc1c1c701ce06c),
+ U64_C (0xe746fdfdd3fdbb2e), U64_C (0x9a1f4d4d294d5264),
+ U64_C (0x397692927292e4e0), U64_C (0xeafa7575c9758fbc),
+ U64_C (0x0c3606061806301e), U64_C (0x09ae8a8a128a2498),
+ U64_C (0x794bb2b2f2b2f940), U64_C (0xd185e6e6bfe66359),
+ U64_C (0x1c7e0e0e380e7036), U64_C (0x3ee71f1f7c1ff863),
+ U64_C (0xc4556262956237f7), U64_C (0xb53ad4d477d4eea3),
+ U64_C (0x4d81a8a89aa82932), U64_C (0x315296966296c4f4),
+ U64_C (0xef62f9f9c3f99b3a), U64_C (0x97a3c5c533c566f6),
+ U64_C (0x4a102525942535b1), U64_C (0xb2ab59597959f220),
+ U64_C (0x15d084842a8454ae), U64_C (0xe4c57272d572b7a7),
+ U64_C (0x72ec3939e439d5dd), U64_C (0x98164c4c2d4c5a61),
+ U64_C (0xbc945e5e655eca3b), U64_C (0xf09f7878fd78e785),
+ U64_C (0x70e53838e038ddd8), U64_C (0x05988c8c0a8c1486),
+ U64_C (0xbf17d1d163d1c6b2), U64_C (0x57e4a5a5aea5410b),
+ U64_C (0xd9a1e2e2afe2434d), U64_C (0xc24e616199612ff8),
+ U64_C (0x7b42b3b3f6b3f145), U64_C (0x42342121842115a5),
+ U64_C (0x25089c9c4a9c94d6), U64_C (0x3cee1e1e781ef066),
+ U64_C (0x8661434311432252), U64_C (0x93b1c7c73bc776fc),
+ U64_C (0xe54ffcfcd7fcb32b), U64_C (0x0824040410042014),
+ U64_C (0xa2e351515951b208), U64_C (0x2f2599995e99bcc7),
+ U64_C (0xda226d6da96d4fc4), U64_C (0x1a650d0d340d6839),
+ U64_C (0xe979fafacffa8335), U64_C (0xa369dfdf5bdfb684),
+ U64_C (0xfca97e7ee57ed79b), U64_C (0x4819242490243db4),
+ U64_C (0x76fe3b3bec3bc5d7), U64_C (0x4b9aabab96ab313d),
+ U64_C (0x81f0cece1fce3ed1), U64_C (0x2299111144118855),
+ U64_C (0x03838f8f068f0c89), U64_C (0x9c044e4e254e4a6b),
+ U64_C (0x7366b7b7e6b7d151), U64_C (0xcbe0ebeb8beb0b60),
+ U64_C (0x78c13c3cf03cfdcc), U64_C (0x1ffd81813e817cbf),
+ U64_C (0x354094946a94d4fe), U64_C (0xf31cf7f7fbf7eb0c),
+ U64_C (0x6f18b9b9deb9a167), U64_C (0x268b13134c13985f),
+ U64_C (0x58512c2cb02c7d9c), U64_C (0xbb05d3d36bd3d6b8),
+ U64_C (0xd38ce7e7bbe76b5c), U64_C (0xdc396e6ea56e57cb),
+ U64_C (0x95aac4c437c46ef3), U64_C (0x061b03030c03180f),
+ U64_C (0xacdc565645568a13), U64_C (0x885e44440d441a49),
+ U64_C (0xfea07f7fe17fdf9e), U64_C (0x4f88a9a99ea92137),
+ U64_C (0x54672a2aa82a4d82), U64_C (0x6b0abbbbd6bbb16d),
+ U64_C (0x9f87c1c123c146e2), U64_C (0xa6f153535153a202),
+ U64_C (0xa572dcdc57dcae8b), U64_C (0x16530b0b2c0b5827),
+ U64_C (0x27019d9d4e9d9cd3), U64_C (0xd82b6c6cad6c47c1),
+ U64_C (0x62a43131c43195f5), U64_C (0xe8f37474cd7487b9),
+ U64_C (0xf115f6f6fff6e309), U64_C (0x8c4c464605460a43),
+ U64_C (0x45a5acac8aac0926), U64_C (0x0fb589891e893c97),
+ U64_C (0x28b414145014a044), U64_C (0xdfbae1e1a3e15b42),
+ U64_C (0x2ca616165816b04e), U64_C (0x74f73a3ae83acdd2),
+ U64_C (0xd2066969b9696fd0), U64_C (0x124109092409482d),
+ U64_C (0xe0d77070dd70a7ad), U64_C (0x716fb6b6e2b6d954),
+ U64_C (0xbd1ed0d067d0ceb7), U64_C (0xc7d6eded93ed3b7e),
+ U64_C (0x85e2cccc17cc2edb), U64_C (0x8468424215422a57),
+ U64_C (0x2d2c98985a98b4c2), U64_C (0x55eda4a4aaa4490e),
+ U64_C (0x50752828a0285d88), U64_C (0xb8865c5c6d5cda31),
+ U64_C (0xed6bf8f8c7f8933f), U64_C (0x11c28686228644a4),
+ };
+
+static const u64 C3[256] =
+ {
+ U64_C (0x7830d818186018c0), U64_C (0xaf462623238c2305),
+ U64_C (0xf991b8c6c63fc67e), U64_C (0x6fcdfbe8e887e813),
+ U64_C (0xa113cb878726874c), U64_C (0x626d11b8b8dab8a9),
+ U64_C (0x0502090101040108), U64_C (0x6e9e0d4f4f214f42),
+ U64_C (0xee6c9b3636d836ad), U64_C (0x0451ffa6a6a2a659),
+ U64_C (0xbdb90cd2d26fd2de), U64_C (0x06f70ef5f5f3f5fb),
+ U64_C (0x80f2967979f979ef), U64_C (0xcede306f6fa16f5f),
+ U64_C (0xef3f6d91917e91fc), U64_C (0x07a4f852525552aa),
+ U64_C (0xfdc04760609d6027), U64_C (0x766535bcbccabc89),
+ U64_C (0xcd2b379b9b569bac), U64_C (0x8c018a8e8e028e04),
+ U64_C (0x155bd2a3a3b6a371), U64_C (0x3c186c0c0c300c60),
+ U64_C (0x8af6847b7bf17bff), U64_C (0xe16a803535d435b5),
+ U64_C (0x693af51d1d741de8), U64_C (0x47ddb3e0e0a7e053),
+ U64_C (0xacb321d7d77bd7f6), U64_C (0xed999cc2c22fc25e),
+ U64_C (0x965c432e2eb82e6d), U64_C (0x7a96294b4b314b62),
+ U64_C (0x21e15dfefedffea3), U64_C (0x16aed55757415782),
+ U64_C (0x412abd15155415a8), U64_C (0xb6eee87777c1779f),
+ U64_C (0xeb6e923737dc37a5), U64_C (0x56d79ee5e5b3e57b),
+ U64_C (0xd923139f9f469f8c), U64_C (0x17fd23f0f0e7f0d3),
+ U64_C (0x7f94204a4a354a6a), U64_C (0x95a944dada4fda9e),
+ U64_C (0x25b0a258587d58fa), U64_C (0xca8fcfc9c903c906),
+ U64_C (0x8d527c2929a42955), U64_C (0x22145a0a0a280a50),
+ U64_C (0x4f7f50b1b1feb1e1), U64_C (0x1a5dc9a0a0baa069),
+ U64_C (0xdad6146b6bb16b7f), U64_C (0xab17d985852e855c),
+ U64_C (0x73673cbdbdcebd81), U64_C (0x34ba8f5d5d695dd2),
+ U64_C (0x5020901010401080), U64_C (0x03f507f4f4f7f4f3),
+ U64_C (0xc08bddcbcb0bcb16), U64_C (0xc67cd33e3ef83eed),
+ U64_C (0x110a2d0505140528), U64_C (0xe6ce78676781671f),
+ U64_C (0x53d597e4e4b7e473), U64_C (0xbb4e0227279c2725),
+ U64_C (0x5882734141194132), U64_C (0x9d0ba78b8b168b2c),
+ U64_C (0x0153f6a7a7a6a751), U64_C (0x94fab27d7de97dcf),
+ U64_C (0xfb374995956e95dc), U64_C (0x9fad56d8d847d88e),
+ U64_C (0x30eb70fbfbcbfb8b), U64_C (0x71c1cdeeee9fee23),
+ U64_C (0x91f8bb7c7ced7cc7), U64_C (0xe3cc716666856617),
+ U64_C (0x8ea77bdddd53dda6), U64_C (0x4b2eaf17175c17b8),
+ U64_C (0x468e454747014702), U64_C (0xdc211a9e9e429e84),
+ U64_C (0xc589d4caca0fca1e), U64_C (0x995a582d2db42d75),
+ U64_C (0x79632ebfbfc6bf91), U64_C (0x1b0e3f07071c0738),
+ U64_C (0x2347acadad8ead01), U64_C (0x2fb4b05a5a755aea),
+ U64_C (0xb51bef838336836c), U64_C (0xff66b63333cc3385),
+ U64_C (0xf2c65c636391633f), U64_C (0x0a04120202080210),
+ U64_C (0x384993aaaa92aa39), U64_C (0xa8e2de7171d971af),
+ U64_C (0xcf8dc6c8c807c80e), U64_C (0x7d32d119196419c8),
+ U64_C (0x70923b4949394972), U64_C (0x9aaf5fd9d943d986),
+ U64_C (0x1df931f2f2eff2c3), U64_C (0x48dba8e3e3abe34b),
+ U64_C (0x2ab6b95b5b715be2), U64_C (0x920dbc88881a8834),
+ U64_C (0xc8293e9a9a529aa4), U64_C (0xbe4c0b262698262d),
+ U64_C (0xfa64bf3232c8328d), U64_C (0x4a7d59b0b0fab0e9),
+ U64_C (0x6acff2e9e983e91b), U64_C (0x331e770f0f3c0f78),
+ U64_C (0xa6b733d5d573d5e6), U64_C (0xba1df480803a8074),
+ U64_C (0x7c6127bebec2be99), U64_C (0xde87ebcdcd13cd26),
+ U64_C (0xe468893434d034bd), U64_C (0x75903248483d487a),
+ U64_C (0x24e354ffffdbffab), U64_C (0x8ff48d7a7af57af7),
+ U64_C (0xea3d6490907a90f4), U64_C (0x3ebe9d5f5f615fc2),
+ U64_C (0xa0403d202080201d), U64_C (0xd5d00f6868bd6867),
+ U64_C (0x7234ca1a1a681ad0), U64_C (0x2c41b7aeae82ae19),
+ U64_C (0x5e757db4b4eab4c9), U64_C (0x19a8ce54544d549a),
+ U64_C (0xe53b7f93937693ec), U64_C (0xaa442f222288220d),
+ U64_C (0xe9c86364648d6407), U64_C (0x12ff2af1f1e3f1db),
+ U64_C (0xa2e6cc7373d173bf), U64_C (0x5a24821212481290),
+ U64_C (0x5d807a40401d403a), U64_C (0x2810480808200840),
+ U64_C (0xe89b95c3c32bc356), U64_C (0x7bc5dfecec97ec33),
+ U64_C (0x90ab4ddbdb4bdb96), U64_C (0x1f5fc0a1a1bea161),
+ U64_C (0x8307918d8d0e8d1c), U64_C (0xc97ac83d3df43df5),
+ U64_C (0xf1335b97976697cc), U64_C (0x0000000000000000),
+ U64_C (0xd483f9cfcf1bcf36), U64_C (0x87566e2b2bac2b45),
+ U64_C (0xb3ece17676c57697), U64_C (0xb019e68282328264),
+ U64_C (0xa9b128d6d67fd6fe), U64_C (0x7736c31b1b6c1bd8),
+ U64_C (0x5b7774b5b5eeb5c1), U64_C (0x2943beafaf86af11),
+ U64_C (0xdfd41d6a6ab56a77), U64_C (0x0da0ea50505d50ba),
+ U64_C (0x4c8a574545094512), U64_C (0x18fb38f3f3ebf3cb),
+ U64_C (0xf060ad3030c0309d), U64_C (0x74c3c4efef9bef2b),
+ U64_C (0xc37eda3f3ffc3fe5), U64_C (0x1caac75555495592),
+ U64_C (0x1059dba2a2b2a279), U64_C (0x65c9e9eaea8fea03),
+ U64_C (0xecca6a656589650f), U64_C (0x686903babad2bab9),
+ U64_C (0x935e4a2f2fbc2f65), U64_C (0xe79d8ec0c027c04e),
+ U64_C (0x81a160dede5fdebe), U64_C (0x6c38fc1c1c701ce0),
+ U64_C (0x2ee746fdfdd3fdbb), U64_C (0x649a1f4d4d294d52),
+ U64_C (0xe0397692927292e4), U64_C (0xbceafa7575c9758f),
+ U64_C (0x1e0c360606180630), U64_C (0x9809ae8a8a128a24),
+ U64_C (0x40794bb2b2f2b2f9), U64_C (0x59d185e6e6bfe663),
+ U64_C (0x361c7e0e0e380e70), U64_C (0x633ee71f1f7c1ff8),
+ U64_C (0xf7c4556262956237), U64_C (0xa3b53ad4d477d4ee),
+ U64_C (0x324d81a8a89aa829), U64_C (0xf4315296966296c4),
+ U64_C (0x3aef62f9f9c3f99b), U64_C (0xf697a3c5c533c566),
+ U64_C (0xb14a102525942535), U64_C (0x20b2ab59597959f2),
+ U64_C (0xae15d084842a8454), U64_C (0xa7e4c57272d572b7),
+ U64_C (0xdd72ec3939e439d5), U64_C (0x6198164c4c2d4c5a),
+ U64_C (0x3bbc945e5e655eca), U64_C (0x85f09f7878fd78e7),
+ U64_C (0xd870e53838e038dd), U64_C (0x8605988c8c0a8c14),
+ U64_C (0xb2bf17d1d163d1c6), U64_C (0x0b57e4a5a5aea541),
+ U64_C (0x4dd9a1e2e2afe243), U64_C (0xf8c24e616199612f),
+ U64_C (0x457b42b3b3f6b3f1), U64_C (0xa542342121842115),
+ U64_C (0xd625089c9c4a9c94), U64_C (0x663cee1e1e781ef0),
+ U64_C (0x5286614343114322), U64_C (0xfc93b1c7c73bc776),
+ U64_C (0x2be54ffcfcd7fcb3), U64_C (0x1408240404100420),
+ U64_C (0x08a2e351515951b2), U64_C (0xc72f2599995e99bc),
+ U64_C (0xc4da226d6da96d4f), U64_C (0x391a650d0d340d68),
+ U64_C (0x35e979fafacffa83), U64_C (0x84a369dfdf5bdfb6),
+ U64_C (0x9bfca97e7ee57ed7), U64_C (0xb44819242490243d),
+ U64_C (0xd776fe3b3bec3bc5), U64_C (0x3d4b9aabab96ab31),
+ U64_C (0xd181f0cece1fce3e), U64_C (0x5522991111441188),
+ U64_C (0x8903838f8f068f0c), U64_C (0x6b9c044e4e254e4a),
+ U64_C (0x517366b7b7e6b7d1), U64_C (0x60cbe0ebeb8beb0b),
+ U64_C (0xcc78c13c3cf03cfd), U64_C (0xbf1ffd81813e817c),
+ U64_C (0xfe354094946a94d4), U64_C (0x0cf31cf7f7fbf7eb),
+ U64_C (0x676f18b9b9deb9a1), U64_C (0x5f268b13134c1398),
+ U64_C (0x9c58512c2cb02c7d), U64_C (0xb8bb05d3d36bd3d6),
+ U64_C (0x5cd38ce7e7bbe76b), U64_C (0xcbdc396e6ea56e57),
+ U64_C (0xf395aac4c437c46e), U64_C (0x0f061b03030c0318),
+ U64_C (0x13acdc565645568a), U64_C (0x49885e44440d441a),
+ U64_C (0x9efea07f7fe17fdf), U64_C (0x374f88a9a99ea921),
+ U64_C (0x8254672a2aa82a4d), U64_C (0x6d6b0abbbbd6bbb1),
+ U64_C (0xe29f87c1c123c146), U64_C (0x02a6f153535153a2),
+ U64_C (0x8ba572dcdc57dcae), U64_C (0x2716530b0b2c0b58),
+ U64_C (0xd327019d9d4e9d9c), U64_C (0xc1d82b6c6cad6c47),
+ U64_C (0xf562a43131c43195), U64_C (0xb9e8f37474cd7487),
+ U64_C (0x09f115f6f6fff6e3), U64_C (0x438c4c464605460a),
+ U64_C (0x2645a5acac8aac09), U64_C (0x970fb589891e893c),
+ U64_C (0x4428b414145014a0), U64_C (0x42dfbae1e1a3e15b),
+ U64_C (0x4e2ca616165816b0), U64_C (0xd274f73a3ae83acd),
+ U64_C (0xd0d2066969b9696f), U64_C (0x2d12410909240948),
+ U64_C (0xade0d77070dd70a7), U64_C (0x54716fb6b6e2b6d9),
+ U64_C (0xb7bd1ed0d067d0ce), U64_C (0x7ec7d6eded93ed3b),
+ U64_C (0xdb85e2cccc17cc2e), U64_C (0x578468424215422a),
+ U64_C (0xc22d2c98985a98b4), U64_C (0x0e55eda4a4aaa449),
+ U64_C (0x8850752828a0285d), U64_C (0x31b8865c5c6d5cda),
+ U64_C (0x3fed6bf8f8c7f893), U64_C (0xa411c28686228644),
+ };
+
+static const u64 C4[256] =
+ {
+ U64_C (0xc07830d818186018), U64_C (0x05af462623238c23),
+ U64_C (0x7ef991b8c6c63fc6), U64_C (0x136fcdfbe8e887e8),
+ U64_C (0x4ca113cb87872687), U64_C (0xa9626d11b8b8dab8),
+ U64_C (0x0805020901010401), U64_C (0x426e9e0d4f4f214f),
+ U64_C (0xadee6c9b3636d836), U64_C (0x590451ffa6a6a2a6),
+ U64_C (0xdebdb90cd2d26fd2), U64_C (0xfb06f70ef5f5f3f5),
+ U64_C (0xef80f2967979f979), U64_C (0x5fcede306f6fa16f),
+ U64_C (0xfcef3f6d91917e91), U64_C (0xaa07a4f852525552),
+ U64_C (0x27fdc04760609d60), U64_C (0x89766535bcbccabc),
+ U64_C (0xaccd2b379b9b569b), U64_C (0x048c018a8e8e028e),
+ U64_C (0x71155bd2a3a3b6a3), U64_C (0x603c186c0c0c300c),
+ U64_C (0xff8af6847b7bf17b), U64_C (0xb5e16a803535d435),
+ U64_C (0xe8693af51d1d741d), U64_C (0x5347ddb3e0e0a7e0),
+ U64_C (0xf6acb321d7d77bd7), U64_C (0x5eed999cc2c22fc2),
+ U64_C (0x6d965c432e2eb82e), U64_C (0x627a96294b4b314b),
+ U64_C (0xa321e15dfefedffe), U64_C (0x8216aed557574157),
+ U64_C (0xa8412abd15155415), U64_C (0x9fb6eee87777c177),
+ U64_C (0xa5eb6e923737dc37), U64_C (0x7b56d79ee5e5b3e5),
+ U64_C (0x8cd923139f9f469f), U64_C (0xd317fd23f0f0e7f0),
+ U64_C (0x6a7f94204a4a354a), U64_C (0x9e95a944dada4fda),
+ U64_C (0xfa25b0a258587d58), U64_C (0x06ca8fcfc9c903c9),
+ U64_C (0x558d527c2929a429), U64_C (0x5022145a0a0a280a),
+ U64_C (0xe14f7f50b1b1feb1), U64_C (0x691a5dc9a0a0baa0),
+ U64_C (0x7fdad6146b6bb16b), U64_C (0x5cab17d985852e85),
+ U64_C (0x8173673cbdbdcebd), U64_C (0xd234ba8f5d5d695d),
+ U64_C (0x8050209010104010), U64_C (0xf303f507f4f4f7f4),
+ U64_C (0x16c08bddcbcb0bcb), U64_C (0xedc67cd33e3ef83e),
+ U64_C (0x28110a2d05051405), U64_C (0x1fe6ce7867678167),
+ U64_C (0x7353d597e4e4b7e4), U64_C (0x25bb4e0227279c27),
+ U64_C (0x3258827341411941), U64_C (0x2c9d0ba78b8b168b),
+ U64_C (0x510153f6a7a7a6a7), U64_C (0xcf94fab27d7de97d),
+ U64_C (0xdcfb374995956e95), U64_C (0x8e9fad56d8d847d8),
+ U64_C (0x8b30eb70fbfbcbfb), U64_C (0x2371c1cdeeee9fee),
+ U64_C (0xc791f8bb7c7ced7c), U64_C (0x17e3cc7166668566),
+ U64_C (0xa68ea77bdddd53dd), U64_C (0xb84b2eaf17175c17),
+ U64_C (0x02468e4547470147), U64_C (0x84dc211a9e9e429e),
+ U64_C (0x1ec589d4caca0fca), U64_C (0x75995a582d2db42d),
+ U64_C (0x9179632ebfbfc6bf), U64_C (0x381b0e3f07071c07),
+ U64_C (0x012347acadad8ead), U64_C (0xea2fb4b05a5a755a),
+ U64_C (0x6cb51bef83833683), U64_C (0x85ff66b63333cc33),
+ U64_C (0x3ff2c65c63639163), U64_C (0x100a041202020802),
+ U64_C (0x39384993aaaa92aa), U64_C (0xafa8e2de7171d971),
+ U64_C (0x0ecf8dc6c8c807c8), U64_C (0xc87d32d119196419),
+ U64_C (0x7270923b49493949), U64_C (0x869aaf5fd9d943d9),
+ U64_C (0xc31df931f2f2eff2), U64_C (0x4b48dba8e3e3abe3),
+ U64_C (0xe22ab6b95b5b715b), U64_C (0x34920dbc88881a88),
+ U64_C (0xa4c8293e9a9a529a), U64_C (0x2dbe4c0b26269826),
+ U64_C (0x8dfa64bf3232c832), U64_C (0xe94a7d59b0b0fab0),
+ U64_C (0x1b6acff2e9e983e9), U64_C (0x78331e770f0f3c0f),
+ U64_C (0xe6a6b733d5d573d5), U64_C (0x74ba1df480803a80),
+ U64_C (0x997c6127bebec2be), U64_C (0x26de87ebcdcd13cd),
+ U64_C (0xbde468893434d034), U64_C (0x7a75903248483d48),
+ U64_C (0xab24e354ffffdbff), U64_C (0xf78ff48d7a7af57a),
+ U64_C (0xf4ea3d6490907a90), U64_C (0xc23ebe9d5f5f615f),
+ U64_C (0x1da0403d20208020), U64_C (0x67d5d00f6868bd68),
+ U64_C (0xd07234ca1a1a681a), U64_C (0x192c41b7aeae82ae),
+ U64_C (0xc95e757db4b4eab4), U64_C (0x9a19a8ce54544d54),
+ U64_C (0xece53b7f93937693), U64_C (0x0daa442f22228822),
+ U64_C (0x07e9c86364648d64), U64_C (0xdb12ff2af1f1e3f1),
+ U64_C (0xbfa2e6cc7373d173), U64_C (0x905a248212124812),
+ U64_C (0x3a5d807a40401d40), U64_C (0x4028104808082008),
+ U64_C (0x56e89b95c3c32bc3), U64_C (0x337bc5dfecec97ec),
+ U64_C (0x9690ab4ddbdb4bdb), U64_C (0x611f5fc0a1a1bea1),
+ U64_C (0x1c8307918d8d0e8d), U64_C (0xf5c97ac83d3df43d),
+ U64_C (0xccf1335b97976697), U64_C (0x0000000000000000),
+ U64_C (0x36d483f9cfcf1bcf), U64_C (0x4587566e2b2bac2b),
+ U64_C (0x97b3ece17676c576), U64_C (0x64b019e682823282),
+ U64_C (0xfea9b128d6d67fd6), U64_C (0xd87736c31b1b6c1b),
+ U64_C (0xc15b7774b5b5eeb5), U64_C (0x112943beafaf86af),
+ U64_C (0x77dfd41d6a6ab56a), U64_C (0xba0da0ea50505d50),
+ U64_C (0x124c8a5745450945), U64_C (0xcb18fb38f3f3ebf3),
+ U64_C (0x9df060ad3030c030), U64_C (0x2b74c3c4efef9bef),
+ U64_C (0xe5c37eda3f3ffc3f), U64_C (0x921caac755554955),
+ U64_C (0x791059dba2a2b2a2), U64_C (0x0365c9e9eaea8fea),
+ U64_C (0x0fecca6a65658965), U64_C (0xb9686903babad2ba),
+ U64_C (0x65935e4a2f2fbc2f), U64_C (0x4ee79d8ec0c027c0),
+ U64_C (0xbe81a160dede5fde), U64_C (0xe06c38fc1c1c701c),
+ U64_C (0xbb2ee746fdfdd3fd), U64_C (0x52649a1f4d4d294d),
+ U64_C (0xe4e0397692927292), U64_C (0x8fbceafa7575c975),
+ U64_C (0x301e0c3606061806), U64_C (0x249809ae8a8a128a),
+ U64_C (0xf940794bb2b2f2b2), U64_C (0x6359d185e6e6bfe6),
+ U64_C (0x70361c7e0e0e380e), U64_C (0xf8633ee71f1f7c1f),
+ U64_C (0x37f7c45562629562), U64_C (0xeea3b53ad4d477d4),
+ U64_C (0x29324d81a8a89aa8), U64_C (0xc4f4315296966296),
+ U64_C (0x9b3aef62f9f9c3f9), U64_C (0x66f697a3c5c533c5),
+ U64_C (0x35b14a1025259425), U64_C (0xf220b2ab59597959),
+ U64_C (0x54ae15d084842a84), U64_C (0xb7a7e4c57272d572),
+ U64_C (0xd5dd72ec3939e439), U64_C (0x5a6198164c4c2d4c),
+ U64_C (0xca3bbc945e5e655e), U64_C (0xe785f09f7878fd78),
+ U64_C (0xddd870e53838e038), U64_C (0x148605988c8c0a8c),
+ U64_C (0xc6b2bf17d1d163d1), U64_C (0x410b57e4a5a5aea5),
+ U64_C (0x434dd9a1e2e2afe2), U64_C (0x2ff8c24e61619961),
+ U64_C (0xf1457b42b3b3f6b3), U64_C (0x15a5423421218421),
+ U64_C (0x94d625089c9c4a9c), U64_C (0xf0663cee1e1e781e),
+ U64_C (0x2252866143431143), U64_C (0x76fc93b1c7c73bc7),
+ U64_C (0xb32be54ffcfcd7fc), U64_C (0x2014082404041004),
+ U64_C (0xb208a2e351515951), U64_C (0xbcc72f2599995e99),
+ U64_C (0x4fc4da226d6da96d), U64_C (0x68391a650d0d340d),
+ U64_C (0x8335e979fafacffa), U64_C (0xb684a369dfdf5bdf),
+ U64_C (0xd79bfca97e7ee57e), U64_C (0x3db4481924249024),
+ U64_C (0xc5d776fe3b3bec3b), U64_C (0x313d4b9aabab96ab),
+ U64_C (0x3ed181f0cece1fce), U64_C (0x8855229911114411),
+ U64_C (0x0c8903838f8f068f), U64_C (0x4a6b9c044e4e254e),
+ U64_C (0xd1517366b7b7e6b7), U64_C (0x0b60cbe0ebeb8beb),
+ U64_C (0xfdcc78c13c3cf03c), U64_C (0x7cbf1ffd81813e81),
+ U64_C (0xd4fe354094946a94), U64_C (0xeb0cf31cf7f7fbf7),
+ U64_C (0xa1676f18b9b9deb9), U64_C (0x985f268b13134c13),
+ U64_C (0x7d9c58512c2cb02c), U64_C (0xd6b8bb05d3d36bd3),
+ U64_C (0x6b5cd38ce7e7bbe7), U64_C (0x57cbdc396e6ea56e),
+ U64_C (0x6ef395aac4c437c4), U64_C (0x180f061b03030c03),
+ U64_C (0x8a13acdc56564556), U64_C (0x1a49885e44440d44),
+ U64_C (0xdf9efea07f7fe17f), U64_C (0x21374f88a9a99ea9),
+ U64_C (0x4d8254672a2aa82a), U64_C (0xb16d6b0abbbbd6bb),
+ U64_C (0x46e29f87c1c123c1), U64_C (0xa202a6f153535153),
+ U64_C (0xae8ba572dcdc57dc), U64_C (0x582716530b0b2c0b),
+ U64_C (0x9cd327019d9d4e9d), U64_C (0x47c1d82b6c6cad6c),
+ U64_C (0x95f562a43131c431), U64_C (0x87b9e8f37474cd74),
+ U64_C (0xe309f115f6f6fff6), U64_C (0x0a438c4c46460546),
+ U64_C (0x092645a5acac8aac), U64_C (0x3c970fb589891e89),
+ U64_C (0xa04428b414145014), U64_C (0x5b42dfbae1e1a3e1),
+ U64_C (0xb04e2ca616165816), U64_C (0xcdd274f73a3ae83a),
+ U64_C (0x6fd0d2066969b969), U64_C (0x482d124109092409),
+ U64_C (0xa7ade0d77070dd70), U64_C (0xd954716fb6b6e2b6),
+ U64_C (0xceb7bd1ed0d067d0), U64_C (0x3b7ec7d6eded93ed),
+ U64_C (0x2edb85e2cccc17cc), U64_C (0x2a57846842421542),
+ U64_C (0xb4c22d2c98985a98), U64_C (0x490e55eda4a4aaa4),
+ U64_C (0x5d8850752828a028), U64_C (0xda31b8865c5c6d5c),
+ U64_C (0x933fed6bf8f8c7f8), U64_C (0x44a411c286862286),
+ };
+
+static const u64 C5[256] =
+ {
+ U64_C (0x18c07830d8181860), U64_C (0x2305af462623238c),
+ U64_C (0xc67ef991b8c6c63f), U64_C (0xe8136fcdfbe8e887),
+ U64_C (0x874ca113cb878726), U64_C (0xb8a9626d11b8b8da),
+ U64_C (0x0108050209010104), U64_C (0x4f426e9e0d4f4f21),
+ U64_C (0x36adee6c9b3636d8), U64_C (0xa6590451ffa6a6a2),
+ U64_C (0xd2debdb90cd2d26f), U64_C (0xf5fb06f70ef5f5f3),
+ U64_C (0x79ef80f2967979f9), U64_C (0x6f5fcede306f6fa1),
+ U64_C (0x91fcef3f6d91917e), U64_C (0x52aa07a4f8525255),
+ U64_C (0x6027fdc04760609d), U64_C (0xbc89766535bcbcca),
+ U64_C (0x9baccd2b379b9b56), U64_C (0x8e048c018a8e8e02),
+ U64_C (0xa371155bd2a3a3b6), U64_C (0x0c603c186c0c0c30),
+ U64_C (0x7bff8af6847b7bf1), U64_C (0x35b5e16a803535d4),
+ U64_C (0x1de8693af51d1d74), U64_C (0xe05347ddb3e0e0a7),
+ U64_C (0xd7f6acb321d7d77b), U64_C (0xc25eed999cc2c22f),
+ U64_C (0x2e6d965c432e2eb8), U64_C (0x4b627a96294b4b31),
+ U64_C (0xfea321e15dfefedf), U64_C (0x578216aed5575741),
+ U64_C (0x15a8412abd151554), U64_C (0x779fb6eee87777c1),
+ U64_C (0x37a5eb6e923737dc), U64_C (0xe57b56d79ee5e5b3),
+ U64_C (0x9f8cd923139f9f46), U64_C (0xf0d317fd23f0f0e7),
+ U64_C (0x4a6a7f94204a4a35), U64_C (0xda9e95a944dada4f),
+ U64_C (0x58fa25b0a258587d), U64_C (0xc906ca8fcfc9c903),
+ U64_C (0x29558d527c2929a4), U64_C (0x0a5022145a0a0a28),
+ U64_C (0xb1e14f7f50b1b1fe), U64_C (0xa0691a5dc9a0a0ba),
+ U64_C (0x6b7fdad6146b6bb1), U64_C (0x855cab17d985852e),
+ U64_C (0xbd8173673cbdbdce), U64_C (0x5dd234ba8f5d5d69),
+ U64_C (0x1080502090101040), U64_C (0xf4f303f507f4f4f7),
+ U64_C (0xcb16c08bddcbcb0b), U64_C (0x3eedc67cd33e3ef8),
+ U64_C (0x0528110a2d050514), U64_C (0x671fe6ce78676781),
+ U64_C (0xe47353d597e4e4b7), U64_C (0x2725bb4e0227279c),
+ U64_C (0x4132588273414119), U64_C (0x8b2c9d0ba78b8b16),
+ U64_C (0xa7510153f6a7a7a6), U64_C (0x7dcf94fab27d7de9),
+ U64_C (0x95dcfb374995956e), U64_C (0xd88e9fad56d8d847),
+ U64_C (0xfb8b30eb70fbfbcb), U64_C (0xee2371c1cdeeee9f),
+ U64_C (0x7cc791f8bb7c7ced), U64_C (0x6617e3cc71666685),
+ U64_C (0xdda68ea77bdddd53), U64_C (0x17b84b2eaf17175c),
+ U64_C (0x4702468e45474701), U64_C (0x9e84dc211a9e9e42),
+ U64_C (0xca1ec589d4caca0f), U64_C (0x2d75995a582d2db4),
+ U64_C (0xbf9179632ebfbfc6), U64_C (0x07381b0e3f07071c),
+ U64_C (0xad012347acadad8e), U64_C (0x5aea2fb4b05a5a75),
+ U64_C (0x836cb51bef838336), U64_C (0x3385ff66b63333cc),
+ U64_C (0x633ff2c65c636391), U64_C (0x02100a0412020208),
+ U64_C (0xaa39384993aaaa92), U64_C (0x71afa8e2de7171d9),
+ U64_C (0xc80ecf8dc6c8c807), U64_C (0x19c87d32d1191964),
+ U64_C (0x497270923b494939), U64_C (0xd9869aaf5fd9d943),
+ U64_C (0xf2c31df931f2f2ef), U64_C (0xe34b48dba8e3e3ab),
+ U64_C (0x5be22ab6b95b5b71), U64_C (0x8834920dbc88881a),
+ U64_C (0x9aa4c8293e9a9a52), U64_C (0x262dbe4c0b262698),
+ U64_C (0x328dfa64bf3232c8), U64_C (0xb0e94a7d59b0b0fa),
+ U64_C (0xe91b6acff2e9e983), U64_C (0x0f78331e770f0f3c),
+ U64_C (0xd5e6a6b733d5d573), U64_C (0x8074ba1df480803a),
+ U64_C (0xbe997c6127bebec2), U64_C (0xcd26de87ebcdcd13),
+ U64_C (0x34bde468893434d0), U64_C (0x487a75903248483d),
+ U64_C (0xffab24e354ffffdb), U64_C (0x7af78ff48d7a7af5),
+ U64_C (0x90f4ea3d6490907a), U64_C (0x5fc23ebe9d5f5f61),
+ U64_C (0x201da0403d202080), U64_C (0x6867d5d00f6868bd),
+ U64_C (0x1ad07234ca1a1a68), U64_C (0xae192c41b7aeae82),
+ U64_C (0xb4c95e757db4b4ea), U64_C (0x549a19a8ce54544d),
+ U64_C (0x93ece53b7f939376), U64_C (0x220daa442f222288),
+ U64_C (0x6407e9c86364648d), U64_C (0xf1db12ff2af1f1e3),
+ U64_C (0x73bfa2e6cc7373d1), U64_C (0x12905a2482121248),
+ U64_C (0x403a5d807a40401d), U64_C (0x0840281048080820),
+ U64_C (0xc356e89b95c3c32b), U64_C (0xec337bc5dfecec97),
+ U64_C (0xdb9690ab4ddbdb4b), U64_C (0xa1611f5fc0a1a1be),
+ U64_C (0x8d1c8307918d8d0e), U64_C (0x3df5c97ac83d3df4),
+ U64_C (0x97ccf1335b979766), U64_C (0x0000000000000000),
+ U64_C (0xcf36d483f9cfcf1b), U64_C (0x2b4587566e2b2bac),
+ U64_C (0x7697b3ece17676c5), U64_C (0x8264b019e6828232),
+ U64_C (0xd6fea9b128d6d67f), U64_C (0x1bd87736c31b1b6c),
+ U64_C (0xb5c15b7774b5b5ee), U64_C (0xaf112943beafaf86),
+ U64_C (0x6a77dfd41d6a6ab5), U64_C (0x50ba0da0ea50505d),
+ U64_C (0x45124c8a57454509), U64_C (0xf3cb18fb38f3f3eb),
+ U64_C (0x309df060ad3030c0), U64_C (0xef2b74c3c4efef9b),
+ U64_C (0x3fe5c37eda3f3ffc), U64_C (0x55921caac7555549),
+ U64_C (0xa2791059dba2a2b2), U64_C (0xea0365c9e9eaea8f),
+ U64_C (0x650fecca6a656589), U64_C (0xbab9686903babad2),
+ U64_C (0x2f65935e4a2f2fbc), U64_C (0xc04ee79d8ec0c027),
+ U64_C (0xdebe81a160dede5f), U64_C (0x1ce06c38fc1c1c70),
+ U64_C (0xfdbb2ee746fdfdd3), U64_C (0x4d52649a1f4d4d29),
+ U64_C (0x92e4e03976929272), U64_C (0x758fbceafa7575c9),
+ U64_C (0x06301e0c36060618), U64_C (0x8a249809ae8a8a12),
+ U64_C (0xb2f940794bb2b2f2), U64_C (0xe66359d185e6e6bf),
+ U64_C (0x0e70361c7e0e0e38), U64_C (0x1ff8633ee71f1f7c),
+ U64_C (0x6237f7c455626295), U64_C (0xd4eea3b53ad4d477),
+ U64_C (0xa829324d81a8a89a), U64_C (0x96c4f43152969662),
+ U64_C (0xf99b3aef62f9f9c3), U64_C (0xc566f697a3c5c533),
+ U64_C (0x2535b14a10252594), U64_C (0x59f220b2ab595979),
+ U64_C (0x8454ae15d084842a), U64_C (0x72b7a7e4c57272d5),
+ U64_C (0x39d5dd72ec3939e4), U64_C (0x4c5a6198164c4c2d),
+ U64_C (0x5eca3bbc945e5e65), U64_C (0x78e785f09f7878fd),
+ U64_C (0x38ddd870e53838e0), U64_C (0x8c148605988c8c0a),
+ U64_C (0xd1c6b2bf17d1d163), U64_C (0xa5410b57e4a5a5ae),
+ U64_C (0xe2434dd9a1e2e2af), U64_C (0x612ff8c24e616199),
+ U64_C (0xb3f1457b42b3b3f6), U64_C (0x2115a54234212184),
+ U64_C (0x9c94d625089c9c4a), U64_C (0x1ef0663cee1e1e78),
+ U64_C (0x4322528661434311), U64_C (0xc776fc93b1c7c73b),
+ U64_C (0xfcb32be54ffcfcd7), U64_C (0x0420140824040410),
+ U64_C (0x51b208a2e3515159), U64_C (0x99bcc72f2599995e),
+ U64_C (0x6d4fc4da226d6da9), U64_C (0x0d68391a650d0d34),
+ U64_C (0xfa8335e979fafacf), U64_C (0xdfb684a369dfdf5b),
+ U64_C (0x7ed79bfca97e7ee5), U64_C (0x243db44819242490),
+ U64_C (0x3bc5d776fe3b3bec), U64_C (0xab313d4b9aabab96),
+ U64_C (0xce3ed181f0cece1f), U64_C (0x1188552299111144),
+ U64_C (0x8f0c8903838f8f06), U64_C (0x4e4a6b9c044e4e25),
+ U64_C (0xb7d1517366b7b7e6), U64_C (0xeb0b60cbe0ebeb8b),
+ U64_C (0x3cfdcc78c13c3cf0), U64_C (0x817cbf1ffd81813e),
+ U64_C (0x94d4fe354094946a), U64_C (0xf7eb0cf31cf7f7fb),
+ U64_C (0xb9a1676f18b9b9de), U64_C (0x13985f268b13134c),
+ U64_C (0x2c7d9c58512c2cb0), U64_C (0xd3d6b8bb05d3d36b),
+ U64_C (0xe76b5cd38ce7e7bb), U64_C (0x6e57cbdc396e6ea5),
+ U64_C (0xc46ef395aac4c437), U64_C (0x03180f061b03030c),
+ U64_C (0x568a13acdc565645), U64_C (0x441a49885e44440d),
+ U64_C (0x7fdf9efea07f7fe1), U64_C (0xa921374f88a9a99e),
+ U64_C (0x2a4d8254672a2aa8), U64_C (0xbbb16d6b0abbbbd6),
+ U64_C (0xc146e29f87c1c123), U64_C (0x53a202a6f1535351),
+ U64_C (0xdcae8ba572dcdc57), U64_C (0x0b582716530b0b2c),
+ U64_C (0x9d9cd327019d9d4e), U64_C (0x6c47c1d82b6c6cad),
+ U64_C (0x3195f562a43131c4), U64_C (0x7487b9e8f37474cd),
+ U64_C (0xf6e309f115f6f6ff), U64_C (0x460a438c4c464605),
+ U64_C (0xac092645a5acac8a), U64_C (0x893c970fb589891e),
+ U64_C (0x14a04428b4141450), U64_C (0xe15b42dfbae1e1a3),
+ U64_C (0x16b04e2ca6161658), U64_C (0x3acdd274f73a3ae8),
+ U64_C (0x696fd0d2066969b9), U64_C (0x09482d1241090924),
+ U64_C (0x70a7ade0d77070dd), U64_C (0xb6d954716fb6b6e2),
+ U64_C (0xd0ceb7bd1ed0d067), U64_C (0xed3b7ec7d6eded93),
+ U64_C (0xcc2edb85e2cccc17), U64_C (0x422a578468424215),
+ U64_C (0x98b4c22d2c98985a), U64_C (0xa4490e55eda4a4aa),
+ U64_C (0x285d8850752828a0), U64_C (0x5cda31b8865c5c6d),
+ U64_C (0xf8933fed6bf8f8c7), U64_C (0x8644a411c2868622),
+ };
+
+static const u64 C6[256] =
+ {
+ U64_C (0x6018c07830d81818), U64_C (0x8c2305af46262323),
+ U64_C (0x3fc67ef991b8c6c6), U64_C (0x87e8136fcdfbe8e8),
+ U64_C (0x26874ca113cb8787), U64_C (0xdab8a9626d11b8b8),
+ U64_C (0x0401080502090101), U64_C (0x214f426e9e0d4f4f),
+ U64_C (0xd836adee6c9b3636), U64_C (0xa2a6590451ffa6a6),
+ U64_C (0x6fd2debdb90cd2d2), U64_C (0xf3f5fb06f70ef5f5),
+ U64_C (0xf979ef80f2967979), U64_C (0xa16f5fcede306f6f),
+ U64_C (0x7e91fcef3f6d9191), U64_C (0x5552aa07a4f85252),
+ U64_C (0x9d6027fdc0476060), U64_C (0xcabc89766535bcbc),
+ U64_C (0x569baccd2b379b9b), U64_C (0x028e048c018a8e8e),
+ U64_C (0xb6a371155bd2a3a3), U64_C (0x300c603c186c0c0c),
+ U64_C (0xf17bff8af6847b7b), U64_C (0xd435b5e16a803535),
+ U64_C (0x741de8693af51d1d), U64_C (0xa7e05347ddb3e0e0),
+ U64_C (0x7bd7f6acb321d7d7), U64_C (0x2fc25eed999cc2c2),
+ U64_C (0xb82e6d965c432e2e), U64_C (0x314b627a96294b4b),
+ U64_C (0xdffea321e15dfefe), U64_C (0x41578216aed55757),
+ U64_C (0x5415a8412abd1515), U64_C (0xc1779fb6eee87777),
+ U64_C (0xdc37a5eb6e923737), U64_C (0xb3e57b56d79ee5e5),
+ U64_C (0x469f8cd923139f9f), U64_C (0xe7f0d317fd23f0f0),
+ U64_C (0x354a6a7f94204a4a), U64_C (0x4fda9e95a944dada),
+ U64_C (0x7d58fa25b0a25858), U64_C (0x03c906ca8fcfc9c9),
+ U64_C (0xa429558d527c2929), U64_C (0x280a5022145a0a0a),
+ U64_C (0xfeb1e14f7f50b1b1), U64_C (0xbaa0691a5dc9a0a0),
+ U64_C (0xb16b7fdad6146b6b), U64_C (0x2e855cab17d98585),
+ U64_C (0xcebd8173673cbdbd), U64_C (0x695dd234ba8f5d5d),
+ U64_C (0x4010805020901010), U64_C (0xf7f4f303f507f4f4),
+ U64_C (0x0bcb16c08bddcbcb), U64_C (0xf83eedc67cd33e3e),
+ U64_C (0x140528110a2d0505), U64_C (0x81671fe6ce786767),
+ U64_C (0xb7e47353d597e4e4), U64_C (0x9c2725bb4e022727),
+ U64_C (0x1941325882734141), U64_C (0x168b2c9d0ba78b8b),
+ U64_C (0xa6a7510153f6a7a7), U64_C (0xe97dcf94fab27d7d),
+ U64_C (0x6e95dcfb37499595), U64_C (0x47d88e9fad56d8d8),
+ U64_C (0xcbfb8b30eb70fbfb), U64_C (0x9fee2371c1cdeeee),
+ U64_C (0xed7cc791f8bb7c7c), U64_C (0x856617e3cc716666),
+ U64_C (0x53dda68ea77bdddd), U64_C (0x5c17b84b2eaf1717),
+ U64_C (0x014702468e454747), U64_C (0x429e84dc211a9e9e),
+ U64_C (0x0fca1ec589d4caca), U64_C (0xb42d75995a582d2d),
+ U64_C (0xc6bf9179632ebfbf), U64_C (0x1c07381b0e3f0707),
+ U64_C (0x8ead012347acadad), U64_C (0x755aea2fb4b05a5a),
+ U64_C (0x36836cb51bef8383), U64_C (0xcc3385ff66b63333),
+ U64_C (0x91633ff2c65c6363), U64_C (0x0802100a04120202),
+ U64_C (0x92aa39384993aaaa), U64_C (0xd971afa8e2de7171),
+ U64_C (0x07c80ecf8dc6c8c8), U64_C (0x6419c87d32d11919),
+ U64_C (0x39497270923b4949), U64_C (0x43d9869aaf5fd9d9),
+ U64_C (0xeff2c31df931f2f2), U64_C (0xabe34b48dba8e3e3),
+ U64_C (0x715be22ab6b95b5b), U64_C (0x1a8834920dbc8888),
+ U64_C (0x529aa4c8293e9a9a), U64_C (0x98262dbe4c0b2626),
+ U64_C (0xc8328dfa64bf3232), U64_C (0xfab0e94a7d59b0b0),
+ U64_C (0x83e91b6acff2e9e9), U64_C (0x3c0f78331e770f0f),
+ U64_C (0x73d5e6a6b733d5d5), U64_C (0x3a8074ba1df48080),
+ U64_C (0xc2be997c6127bebe), U64_C (0x13cd26de87ebcdcd),
+ U64_C (0xd034bde468893434), U64_C (0x3d487a7590324848),
+ U64_C (0xdbffab24e354ffff), U64_C (0xf57af78ff48d7a7a),
+ U64_C (0x7a90f4ea3d649090), U64_C (0x615fc23ebe9d5f5f),
+ U64_C (0x80201da0403d2020), U64_C (0xbd6867d5d00f6868),
+ U64_C (0x681ad07234ca1a1a), U64_C (0x82ae192c41b7aeae),
+ U64_C (0xeab4c95e757db4b4), U64_C (0x4d549a19a8ce5454),
+ U64_C (0x7693ece53b7f9393), U64_C (0x88220daa442f2222),
+ U64_C (0x8d6407e9c8636464), U64_C (0xe3f1db12ff2af1f1),
+ U64_C (0xd173bfa2e6cc7373), U64_C (0x4812905a24821212),
+ U64_C (0x1d403a5d807a4040), U64_C (0x2008402810480808),
+ U64_C (0x2bc356e89b95c3c3), U64_C (0x97ec337bc5dfecec),
+ U64_C (0x4bdb9690ab4ddbdb), U64_C (0xbea1611f5fc0a1a1),
+ U64_C (0x0e8d1c8307918d8d), U64_C (0xf43df5c97ac83d3d),
+ U64_C (0x6697ccf1335b9797), U64_C (0x0000000000000000),
+ U64_C (0x1bcf36d483f9cfcf), U64_C (0xac2b4587566e2b2b),
+ U64_C (0xc57697b3ece17676), U64_C (0x328264b019e68282),
+ U64_C (0x7fd6fea9b128d6d6), U64_C (0x6c1bd87736c31b1b),
+ U64_C (0xeeb5c15b7774b5b5), U64_C (0x86af112943beafaf),
+ U64_C (0xb56a77dfd41d6a6a), U64_C (0x5d50ba0da0ea5050),
+ U64_C (0x0945124c8a574545), U64_C (0xebf3cb18fb38f3f3),
+ U64_C (0xc0309df060ad3030), U64_C (0x9bef2b74c3c4efef),
+ U64_C (0xfc3fe5c37eda3f3f), U64_C (0x4955921caac75555),
+ U64_C (0xb2a2791059dba2a2), U64_C (0x8fea0365c9e9eaea),
+ U64_C (0x89650fecca6a6565), U64_C (0xd2bab9686903baba),
+ U64_C (0xbc2f65935e4a2f2f), U64_C (0x27c04ee79d8ec0c0),
+ U64_C (0x5fdebe81a160dede), U64_C (0x701ce06c38fc1c1c),
+ U64_C (0xd3fdbb2ee746fdfd), U64_C (0x294d52649a1f4d4d),
+ U64_C (0x7292e4e039769292), U64_C (0xc9758fbceafa7575),
+ U64_C (0x1806301e0c360606), U64_C (0x128a249809ae8a8a),
+ U64_C (0xf2b2f940794bb2b2), U64_C (0xbfe66359d185e6e6),
+ U64_C (0x380e70361c7e0e0e), U64_C (0x7c1ff8633ee71f1f),
+ U64_C (0x956237f7c4556262), U64_C (0x77d4eea3b53ad4d4),
+ U64_C (0x9aa829324d81a8a8), U64_C (0x6296c4f431529696),
+ U64_C (0xc3f99b3aef62f9f9), U64_C (0x33c566f697a3c5c5),
+ U64_C (0x942535b14a102525), U64_C (0x7959f220b2ab5959),
+ U64_C (0x2a8454ae15d08484), U64_C (0xd572b7a7e4c57272),
+ U64_C (0xe439d5dd72ec3939), U64_C (0x2d4c5a6198164c4c),
+ U64_C (0x655eca3bbc945e5e), U64_C (0xfd78e785f09f7878),
+ U64_C (0xe038ddd870e53838), U64_C (0x0a8c148605988c8c),
+ U64_C (0x63d1c6b2bf17d1d1), U64_C (0xaea5410b57e4a5a5),
+ U64_C (0xafe2434dd9a1e2e2), U64_C (0x99612ff8c24e6161),
+ U64_C (0xf6b3f1457b42b3b3), U64_C (0x842115a542342121),
+ U64_C (0x4a9c94d625089c9c), U64_C (0x781ef0663cee1e1e),
+ U64_C (0x1143225286614343), U64_C (0x3bc776fc93b1c7c7),
+ U64_C (0xd7fcb32be54ffcfc), U64_C (0x1004201408240404),
+ U64_C (0x5951b208a2e35151), U64_C (0x5e99bcc72f259999),
+ U64_C (0xa96d4fc4da226d6d), U64_C (0x340d68391a650d0d),
+ U64_C (0xcffa8335e979fafa), U64_C (0x5bdfb684a369dfdf),
+ U64_C (0xe57ed79bfca97e7e), U64_C (0x90243db448192424),
+ U64_C (0xec3bc5d776fe3b3b), U64_C (0x96ab313d4b9aabab),
+ U64_C (0x1fce3ed181f0cece), U64_C (0x4411885522991111),
+ U64_C (0x068f0c8903838f8f), U64_C (0x254e4a6b9c044e4e),
+ U64_C (0xe6b7d1517366b7b7), U64_C (0x8beb0b60cbe0ebeb),
+ U64_C (0xf03cfdcc78c13c3c), U64_C (0x3e817cbf1ffd8181),
+ U64_C (0x6a94d4fe35409494), U64_C (0xfbf7eb0cf31cf7f7),
+ U64_C (0xdeb9a1676f18b9b9), U64_C (0x4c13985f268b1313),
+ U64_C (0xb02c7d9c58512c2c), U64_C (0x6bd3d6b8bb05d3d3),
+ U64_C (0xbbe76b5cd38ce7e7), U64_C (0xa56e57cbdc396e6e),
+ U64_C (0x37c46ef395aac4c4), U64_C (0x0c03180f061b0303),
+ U64_C (0x45568a13acdc5656), U64_C (0x0d441a49885e4444),
+ U64_C (0xe17fdf9efea07f7f), U64_C (0x9ea921374f88a9a9),
+ U64_C (0xa82a4d8254672a2a), U64_C (0xd6bbb16d6b0abbbb),
+ U64_C (0x23c146e29f87c1c1), U64_C (0x5153a202a6f15353),
+ U64_C (0x57dcae8ba572dcdc), U64_C (0x2c0b582716530b0b),
+ U64_C (0x4e9d9cd327019d9d), U64_C (0xad6c47c1d82b6c6c),
+ U64_C (0xc43195f562a43131), U64_C (0xcd7487b9e8f37474),
+ U64_C (0xfff6e309f115f6f6), U64_C (0x05460a438c4c4646),
+ U64_C (0x8aac092645a5acac), U64_C (0x1e893c970fb58989),
+ U64_C (0x5014a04428b41414), U64_C (0xa3e15b42dfbae1e1),
+ U64_C (0x5816b04e2ca61616), U64_C (0xe83acdd274f73a3a),
+ U64_C (0xb9696fd0d2066969), U64_C (0x2409482d12410909),
+ U64_C (0xdd70a7ade0d77070), U64_C (0xe2b6d954716fb6b6),
+ U64_C (0x67d0ceb7bd1ed0d0), U64_C (0x93ed3b7ec7d6eded),
+ U64_C (0x17cc2edb85e2cccc), U64_C (0x15422a5784684242),
+ U64_C (0x5a98b4c22d2c9898), U64_C (0xaaa4490e55eda4a4),
+ U64_C (0xa0285d8850752828), U64_C (0x6d5cda31b8865c5c),
+ U64_C (0xc7f8933fed6bf8f8), U64_C (0x228644a411c28686),
+ };
+
+static const u64 C7[256] =
+ {
+ U64_C (0x186018c07830d818), U64_C (0x238c2305af462623),
+ U64_C (0xc63fc67ef991b8c6), U64_C (0xe887e8136fcdfbe8),
+ U64_C (0x8726874ca113cb87), U64_C (0xb8dab8a9626d11b8),
+ U64_C (0x0104010805020901), U64_C (0x4f214f426e9e0d4f),
+ U64_C (0x36d836adee6c9b36), U64_C (0xa6a2a6590451ffa6),
+ U64_C (0xd26fd2debdb90cd2), U64_C (0xf5f3f5fb06f70ef5),
+ U64_C (0x79f979ef80f29679), U64_C (0x6fa16f5fcede306f),
+ U64_C (0x917e91fcef3f6d91), U64_C (0x525552aa07a4f852),
+ U64_C (0x609d6027fdc04760), U64_C (0xbccabc89766535bc),
+ U64_C (0x9b569baccd2b379b), U64_C (0x8e028e048c018a8e),
+ U64_C (0xa3b6a371155bd2a3), U64_C (0x0c300c603c186c0c),
+ U64_C (0x7bf17bff8af6847b), U64_C (0x35d435b5e16a8035),
+ U64_C (0x1d741de8693af51d), U64_C (0xe0a7e05347ddb3e0),
+ U64_C (0xd77bd7f6acb321d7), U64_C (0xc22fc25eed999cc2),
+ U64_C (0x2eb82e6d965c432e), U64_C (0x4b314b627a96294b),
+ U64_C (0xfedffea321e15dfe), U64_C (0x5741578216aed557),
+ U64_C (0x155415a8412abd15), U64_C (0x77c1779fb6eee877),
+ U64_C (0x37dc37a5eb6e9237), U64_C (0xe5b3e57b56d79ee5),
+ U64_C (0x9f469f8cd923139f), U64_C (0xf0e7f0d317fd23f0),
+ U64_C (0x4a354a6a7f94204a), U64_C (0xda4fda9e95a944da),
+ U64_C (0x587d58fa25b0a258), U64_C (0xc903c906ca8fcfc9),
+ U64_C (0x29a429558d527c29), U64_C (0x0a280a5022145a0a),
+ U64_C (0xb1feb1e14f7f50b1), U64_C (0xa0baa0691a5dc9a0),
+ U64_C (0x6bb16b7fdad6146b), U64_C (0x852e855cab17d985),
+ U64_C (0xbdcebd8173673cbd), U64_C (0x5d695dd234ba8f5d),
+ U64_C (0x1040108050209010), U64_C (0xf4f7f4f303f507f4),
+ U64_C (0xcb0bcb16c08bddcb), U64_C (0x3ef83eedc67cd33e),
+ U64_C (0x05140528110a2d05), U64_C (0x6781671fe6ce7867),
+ U64_C (0xe4b7e47353d597e4), U64_C (0x279c2725bb4e0227),
+ U64_C (0x4119413258827341), U64_C (0x8b168b2c9d0ba78b),
+ U64_C (0xa7a6a7510153f6a7), U64_C (0x7de97dcf94fab27d),
+ U64_C (0x956e95dcfb374995), U64_C (0xd847d88e9fad56d8),
+ U64_C (0xfbcbfb8b30eb70fb), U64_C (0xee9fee2371c1cdee),
+ U64_C (0x7ced7cc791f8bb7c), U64_C (0x66856617e3cc7166),
+ U64_C (0xdd53dda68ea77bdd), U64_C (0x175c17b84b2eaf17),
+ U64_C (0x47014702468e4547), U64_C (0x9e429e84dc211a9e),
+ U64_C (0xca0fca1ec589d4ca), U64_C (0x2db42d75995a582d),
+ U64_C (0xbfc6bf9179632ebf), U64_C (0x071c07381b0e3f07),
+ U64_C (0xad8ead012347acad), U64_C (0x5a755aea2fb4b05a),
+ U64_C (0x8336836cb51bef83), U64_C (0x33cc3385ff66b633),
+ U64_C (0x6391633ff2c65c63), U64_C (0x020802100a041202),
+ U64_C (0xaa92aa39384993aa), U64_C (0x71d971afa8e2de71),
+ U64_C (0xc807c80ecf8dc6c8), U64_C (0x196419c87d32d119),
+ U64_C (0x4939497270923b49), U64_C (0xd943d9869aaf5fd9),
+ U64_C (0xf2eff2c31df931f2), U64_C (0xe3abe34b48dba8e3),
+ U64_C (0x5b715be22ab6b95b), U64_C (0x881a8834920dbc88),
+ U64_C (0x9a529aa4c8293e9a), U64_C (0x2698262dbe4c0b26),
+ U64_C (0x32c8328dfa64bf32), U64_C (0xb0fab0e94a7d59b0),
+ U64_C (0xe983e91b6acff2e9), U64_C (0x0f3c0f78331e770f),
+ U64_C (0xd573d5e6a6b733d5), U64_C (0x803a8074ba1df480),
+ U64_C (0xbec2be997c6127be), U64_C (0xcd13cd26de87ebcd),
+ U64_C (0x34d034bde4688934), U64_C (0x483d487a75903248),
+ U64_C (0xffdbffab24e354ff), U64_C (0x7af57af78ff48d7a),
+ U64_C (0x907a90f4ea3d6490), U64_C (0x5f615fc23ebe9d5f),
+ U64_C (0x2080201da0403d20), U64_C (0x68bd6867d5d00f68),
+ U64_C (0x1a681ad07234ca1a), U64_C (0xae82ae192c41b7ae),
+ U64_C (0xb4eab4c95e757db4), U64_C (0x544d549a19a8ce54),
+ U64_C (0x937693ece53b7f93), U64_C (0x2288220daa442f22),
+ U64_C (0x648d6407e9c86364), U64_C (0xf1e3f1db12ff2af1),
+ U64_C (0x73d173bfa2e6cc73), U64_C (0x124812905a248212),
+ U64_C (0x401d403a5d807a40), U64_C (0x0820084028104808),
+ U64_C (0xc32bc356e89b95c3), U64_C (0xec97ec337bc5dfec),
+ U64_C (0xdb4bdb9690ab4ddb), U64_C (0xa1bea1611f5fc0a1),
+ U64_C (0x8d0e8d1c8307918d), U64_C (0x3df43df5c97ac83d),
+ U64_C (0x976697ccf1335b97), U64_C (0x0000000000000000),
+ U64_C (0xcf1bcf36d483f9cf), U64_C (0x2bac2b4587566e2b),
+ U64_C (0x76c57697b3ece176), U64_C (0x82328264b019e682),
+ U64_C (0xd67fd6fea9b128d6), U64_C (0x1b6c1bd87736c31b),
+ U64_C (0xb5eeb5c15b7774b5), U64_C (0xaf86af112943beaf),
+ U64_C (0x6ab56a77dfd41d6a), U64_C (0x505d50ba0da0ea50),
+ U64_C (0x450945124c8a5745), U64_C (0xf3ebf3cb18fb38f3),
+ U64_C (0x30c0309df060ad30), U64_C (0xef9bef2b74c3c4ef),
+ U64_C (0x3ffc3fe5c37eda3f), U64_C (0x554955921caac755),
+ U64_C (0xa2b2a2791059dba2), U64_C (0xea8fea0365c9e9ea),
+ U64_C (0x6589650fecca6a65), U64_C (0xbad2bab9686903ba),
+ U64_C (0x2fbc2f65935e4a2f), U64_C (0xc027c04ee79d8ec0),
+ U64_C (0xde5fdebe81a160de), U64_C (0x1c701ce06c38fc1c),
+ U64_C (0xfdd3fdbb2ee746fd), U64_C (0x4d294d52649a1f4d),
+ U64_C (0x927292e4e0397692), U64_C (0x75c9758fbceafa75),
+ U64_C (0x061806301e0c3606), U64_C (0x8a128a249809ae8a),
+ U64_C (0xb2f2b2f940794bb2), U64_C (0xe6bfe66359d185e6),
+ U64_C (0x0e380e70361c7e0e), U64_C (0x1f7c1ff8633ee71f),
+ U64_C (0x62956237f7c45562), U64_C (0xd477d4eea3b53ad4),
+ U64_C (0xa89aa829324d81a8), U64_C (0x966296c4f4315296),
+ U64_C (0xf9c3f99b3aef62f9), U64_C (0xc533c566f697a3c5),
+ U64_C (0x25942535b14a1025), U64_C (0x597959f220b2ab59),
+ U64_C (0x842a8454ae15d084), U64_C (0x72d572b7a7e4c572),
+ U64_C (0x39e439d5dd72ec39), U64_C (0x4c2d4c5a6198164c),
+ U64_C (0x5e655eca3bbc945e), U64_C (0x78fd78e785f09f78),
+ U64_C (0x38e038ddd870e538), U64_C (0x8c0a8c148605988c),
+ U64_C (0xd163d1c6b2bf17d1), U64_C (0xa5aea5410b57e4a5),
+ U64_C (0xe2afe2434dd9a1e2), U64_C (0x6199612ff8c24e61),
+ U64_C (0xb3f6b3f1457b42b3), U64_C (0x21842115a5423421),
+ U64_C (0x9c4a9c94d625089c), U64_C (0x1e781ef0663cee1e),
+ U64_C (0x4311432252866143), U64_C (0xc73bc776fc93b1c7),
+ U64_C (0xfcd7fcb32be54ffc), U64_C (0x0410042014082404),
+ U64_C (0x515951b208a2e351), U64_C (0x995e99bcc72f2599),
+ U64_C (0x6da96d4fc4da226d), U64_C (0x0d340d68391a650d),
+ U64_C (0xfacffa8335e979fa), U64_C (0xdf5bdfb684a369df),
+ U64_C (0x7ee57ed79bfca97e), U64_C (0x2490243db4481924),
+ U64_C (0x3bec3bc5d776fe3b), U64_C (0xab96ab313d4b9aab),
+ U64_C (0xce1fce3ed181f0ce), U64_C (0x1144118855229911),
+ U64_C (0x8f068f0c8903838f), U64_C (0x4e254e4a6b9c044e),
+ U64_C (0xb7e6b7d1517366b7), U64_C (0xeb8beb0b60cbe0eb),
+ U64_C (0x3cf03cfdcc78c13c), U64_C (0x813e817cbf1ffd81),
+ U64_C (0x946a94d4fe354094), U64_C (0xf7fbf7eb0cf31cf7),
+ U64_C (0xb9deb9a1676f18b9), U64_C (0x134c13985f268b13),
+ U64_C (0x2cb02c7d9c58512c), U64_C (0xd36bd3d6b8bb05d3),
+ U64_C (0xe7bbe76b5cd38ce7), U64_C (0x6ea56e57cbdc396e),
+ U64_C (0xc437c46ef395aac4), U64_C (0x030c03180f061b03),
+ U64_C (0x5645568a13acdc56), U64_C (0x440d441a49885e44),
+ U64_C (0x7fe17fdf9efea07f), U64_C (0xa99ea921374f88a9),
+ U64_C (0x2aa82a4d8254672a), U64_C (0xbbd6bbb16d6b0abb),
+ U64_C (0xc123c146e29f87c1), U64_C (0x535153a202a6f153),
+ U64_C (0xdc57dcae8ba572dc), U64_C (0x0b2c0b582716530b),
+ U64_C (0x9d4e9d9cd327019d), U64_C (0x6cad6c47c1d82b6c),
+ U64_C (0x31c43195f562a431), U64_C (0x74cd7487b9e8f374),
+ U64_C (0xf6fff6e309f115f6), U64_C (0x4605460a438c4c46),
+ U64_C (0xac8aac092645a5ac), U64_C (0x891e893c970fb589),
+ U64_C (0x145014a04428b414), U64_C (0xe1a3e15b42dfbae1),
+ U64_C (0x165816b04e2ca616), U64_C (0x3ae83acdd274f73a),
+ U64_C (0x69b9696fd0d20669), U64_C (0x092409482d124109),
+ U64_C (0x70dd70a7ade0d770), U64_C (0xb6e2b6d954716fb6),
+ U64_C (0xd067d0ceb7bd1ed0), U64_C (0xed93ed3b7ec7d6ed),
+ U64_C (0xcc17cc2edb85e2cc), U64_C (0x4215422a57846842),
+ U64_C (0x985a98b4c22d2c98), U64_C (0xa4aaa4490e55eda4),
+ U64_C (0x28a0285d88507528), U64_C (0x5c6d5cda31b8865c),
+ U64_C (0xf8c7f8933fed6bf8), U64_C (0x86228644a411c286),
+ };
+
+
+
+static void
+whirlpool_init (void *ctx)
+{
+ whirlpool_context_t *context = ctx;
+
+ memset (context, 0, sizeof (*context));
+}
+
+
+/*
+ * Transform block.
+ */
+static void
+whirlpool_transform (whirlpool_context_t *context, const unsigned char *data)
+{
+ whirlpool_block_t data_block;
+ whirlpool_block_t key;
+ whirlpool_block_t state;
+ whirlpool_block_t block;
+ unsigned int r;
+ unsigned int i;
+
+ buffer_to_block (data, data_block, i);
+ block_copy (key, context->hash_state, i);
+ block_copy (state, context->hash_state, i);
+ block_xor (state, data_block, i);
+
+ for (r = 0; r < R; r++)
+ {
+ /* Compute round key K^r. */
+
+ block[0] = (C0[(key[0] >> 56) & 0xFF] ^ C1[(key[7] >> 48) & 0xFF] ^
+ C2[(key[6] >> 40) & 0xFF] ^ C3[(key[5] >> 32) & 0xFF] ^
+ C4[(key[4] >> 24) & 0xFF] ^ C5[(key[3] >> 16) & 0xFF] ^
+ C6[(key[2] >> 8) & 0xFF] ^ C7[(key[1] >> 0) & 0xFF] ^ rc[r]);
+ block[1] = (C0[(key[1] >> 56) & 0xFF] ^ C1[(key[0] >> 48) & 0xFF] ^
+ C2[(key[7] >> 40) & 0xFF] ^ C3[(key[6] >> 32) & 0xFF] ^
+ C4[(key[5] >> 24) & 0xFF] ^ C5[(key[4] >> 16) & 0xFF] ^
+ C6[(key[3] >> 8) & 0xFF] ^ C7[(key[2] >> 0) & 0xFF]);
+ block[2] = (C0[(key[2] >> 56) & 0xFF] ^ C1[(key[1] >> 48) & 0xFF] ^
+ C2[(key[0] >> 40) & 0xFF] ^ C3[(key[7] >> 32) & 0xFF] ^
+ C4[(key[6] >> 24) & 0xFF] ^ C5[(key[5] >> 16) & 0xFF] ^
+ C6[(key[4] >> 8) & 0xFF] ^ C7[(key[3] >> 0) & 0xFF]);
+ block[3] = (C0[(key[3] >> 56) & 0xFF] ^ C1[(key[2] >> 48) & 0xFF] ^
+ C2[(key[1] >> 40) & 0xFF] ^ C3[(key[0] >> 32) & 0xFF] ^
+ C4[(key[7] >> 24) & 0xFF] ^ C5[(key[6] >> 16) & 0xFF] ^
+ C6[(key[5] >> 8) & 0xFF] ^ C7[(key[4] >> 0) & 0xFF]);
+ block[4] = (C0[(key[4] >> 56) & 0xFF] ^ C1[(key[3] >> 48) & 0xFF] ^
+ C2[(key[2] >> 40) & 0xFF] ^ C3[(key[1] >> 32) & 0xFF] ^
+ C4[(key[0] >> 24) & 0xFF] ^ C5[(key[7] >> 16) & 0xFF] ^
+ C6[(key[6] >> 8) & 0xFF] ^ C7[(key[5] >> 0) & 0xFF]);
+ block[5] = (C0[(key[5] >> 56) & 0xFF] ^ C1[(key[4] >> 48) & 0xFF] ^
+ C2[(key[3] >> 40) & 0xFF] ^ C3[(key[2] >> 32) & 0xFF] ^
+ C4[(key[1] >> 24) & 0xFF] ^ C5[(key[0] >> 16) & 0xFF] ^
+ C6[(key[7] >> 8) & 0xFF] ^ C7[(key[6] >> 0) & 0xFF]);
+ block[6] = (C0[(key[6] >> 56) & 0xFF] ^ C1[(key[5] >> 48) & 0xFF] ^
+ C2[(key[4] >> 40) & 0xFF] ^ C3[(key[3] >> 32) & 0xFF] ^
+ C4[(key[2] >> 24) & 0xFF] ^ C5[(key[1] >> 16) & 0xFF] ^
+ C6[(key[0] >> 8) & 0xFF] ^ C7[(key[7] >> 0) & 0xFF]);
+ block[7] = (C0[(key[7] >> 56) & 0xFF] ^ C1[(key[6] >> 48) & 0xFF] ^
+ C2[(key[5] >> 40) & 0xFF] ^ C3[(key[4] >> 32) & 0xFF] ^
+ C4[(key[3] >> 24) & 0xFF] ^ C5[(key[2] >> 16) & 0xFF] ^
+ C6[(key[1] >> 8) & 0xFF] ^ C7[(key[0] >> 0) & 0xFF]);
+ block_copy (key, block, i);
+
+ /* Apply r-th round transformation. */
+
+ block[0] = (C0[(state[0] >> 56) & 0xFF] ^ C1[(state[7] >> 48) & 0xFF] ^
+ C2[(state[6] >> 40) & 0xFF] ^ C3[(state[5] >> 32) & 0xFF] ^
+ C4[(state[4] >> 24) & 0xFF] ^ C5[(state[3] >> 16) & 0xFF] ^
+ C6[(state[2] >> 8) & 0xFF] ^ C7[(state[1] >> 0) & 0xFF] ^ key[0]);
+ block[1] = (C0[(state[1] >> 56) & 0xFF] ^ C1[(state[0] >> 48) & 0xFF] ^
+ C2[(state[7] >> 40) & 0xFF] ^ C3[(state[6] >> 32) & 0xFF] ^
+ C4[(state[5] >> 24) & 0xFF] ^ C5[(state[4] >> 16) & 0xFF] ^
+ C6[(state[3] >> 8) & 0xFF] ^ C7[(state[2] >> 0) & 0xFF] ^ key[1]);
+ block[2] = (C0[(state[2] >> 56) & 0xFF] ^ C1[(state[1] >> 48) & 0xFF] ^
+ C2[(state[0] >> 40) & 0xFF] ^ C3[(state[7] >> 32) & 0xFF] ^
+ C4[(state[6] >> 24) & 0xFF] ^ C5[(state[5] >> 16) & 0xFF] ^
+ C6[(state[4] >> 8) & 0xFF] ^ C7[(state[3] >> 0) & 0xFF] ^ key[2]);
+ block[3] = (C0[(state[3] >> 56) & 0xFF] ^ C1[(state[2] >> 48) & 0xFF] ^
+ C2[(state[1] >> 40) & 0xFF] ^ C3[(state[0] >> 32) & 0xFF] ^
+ C4[(state[7] >> 24) & 0xFF] ^ C5[(state[6] >> 16) & 0xFF] ^
+ C6[(state[5] >> 8) & 0xFF] ^ C7[(state[4] >> 0) & 0xFF] ^ key[3]);
+ block[4] = (C0[(state[4] >> 56) & 0xFF] ^ C1[(state[3] >> 48) & 0xFF] ^
+ C2[(state[2] >> 40) & 0xFF] ^ C3[(state[1] >> 32) & 0xFF] ^
+ C4[(state[0] >> 24) & 0xFF] ^ C5[(state[7] >> 16) & 0xFF] ^
+ C6[(state[6] >> 8) & 0xFF] ^ C7[(state[5] >> 0) & 0xFF] ^ key[4]);
+ block[5] = (C0[(state[5] >> 56) & 0xFF] ^ C1[(state[4] >> 48) & 0xFF] ^
+ C2[(state[3] >> 40) & 0xFF] ^ C3[(state[2] >> 32) & 0xFF] ^
+ C4[(state[1] >> 24) & 0xFF] ^ C5[(state[0] >> 16) & 0xFF] ^
+ C6[(state[7] >> 8) & 0xFF] ^ C7[(state[6] >> 0) & 0xFF] ^ key[5]);
+ block[6] = (C0[(state[6] >> 56) & 0xFF] ^ C1[(state[5] >> 48) & 0xFF] ^
+ C2[(state[4] >> 40) & 0xFF] ^ C3[(state[3] >> 32) & 0xFF] ^
+ C4[(state[2] >> 24) & 0xFF] ^ C5[(state[1] >> 16) & 0xFF] ^
+ C6[(state[0] >> 8) & 0xFF] ^ C7[(state[7] >> 0) & 0xFF] ^ key[6]);
+ block[7] = (C0[(state[7] >> 56) & 0xFF] ^ C1[(state[6] >> 48) & 0xFF] ^
+ C2[(state[5] >> 40) & 0xFF] ^ C3[(state[4] >> 32) & 0xFF] ^
+ C4[(state[3] >> 24) & 0xFF] ^ C5[(state[2] >> 16) & 0xFF] ^
+ C6[(state[1] >> 8) & 0xFF] ^ C7[(state[0] >> 0) & 0xFF] ^ key[7]);
+ block_copy (state, block, i);
+ }
+
+ /* Compression. */
+
+ block_xor (context->hash_state, data_block, i);
+ block_xor (context->hash_state, state, i);
+}
+
+static void
+whirlpool_add (whirlpool_context_t *context,
+ const void *buffer_arg, size_t buffer_n)
+{
+ const unsigned char *buffer = buffer_arg;
+ u64 buffer_size;
+ unsigned int carry;
+ unsigned int i;
+
+ buffer_size = buffer_n;
+
+ if (context->count == BLOCK_SIZE)
+ {
+ /* Flush the buffer. */
+ whirlpool_transform (context, context->buffer);
+ /*_gcry_burn_stack (80+6*sizeof(void*));*/ /* FIXME */
+ context->count = 0;
+ }
+ if (! buffer)
+ return; /* Nothing to add. */
+
+ if (context->count)
+ {
+ while (buffer_n && (context->count < BLOCK_SIZE))
+ {
+ context->buffer[context->count++] = *buffer++;
+ buffer_n--;
+ }
+ whirlpool_add (context, NULL, 0);
+ if (!buffer_n)
+ /* Done. */
+ return;
+ }
+ /*_gcry_burn_stack (80+6*sizeof(void*));*/ /* FIXME */
+
+ while (buffer_n >= BLOCK_SIZE)
+ {
+ whirlpool_transform (context, buffer);
+ context->count = 0;
+ buffer_n -= BLOCK_SIZE;
+ buffer += BLOCK_SIZE;
+ }
+ while (buffer_n && (context->count < BLOCK_SIZE))
+ {
+ context->buffer[context->count++] = *buffer++;
+ buffer_n--;
+ }
+
+ /* Update bit counter. */
+ carry = 0;
+ buffer_size <<= 3;
+ for (i = 1; i <= 32; i++)
+ {
+ if (! (buffer_size || carry))
+ break;
+
+ carry += context->length[32 - i] + (buffer_size & 0xFF);
+ context->length[32 - i] = carry;
+ buffer_size >>= 8;
+ carry >>= 8;
+ }
+ gcry_assert (! (buffer_size || carry));
+}
+
+static void
+whirlpool_write (void *ctx, const void *buffer, size_t buffer_n)
+{
+ whirlpool_context_t *context = ctx;
+
+ whirlpool_add (context, buffer, buffer_n);
+}
+
+static void
+whirlpool_final (void *ctx)
+{
+ whirlpool_context_t *context = ctx;
+ unsigned int i;
+
+ /* Flush. */
+ whirlpool_add (context, NULL, 0);
+
+ /* Pad. */
+ context->buffer[context->count++] = 0x80;
+
+ if (context->count > 32)
+ {
+ /* An extra block is necessary. */
+ while (context->count < 64)
+ context->buffer[context->count++] = 0;
+ whirlpool_add (context, NULL, 0);
+ }
+ while (context->count < 32)
+ context->buffer[context->count++] = 0;
+
+ /* Add length of message. */
+ memcpy (context->buffer + context->count, context->length, 32);
+ context->count += 32;
+ whirlpool_add (context, NULL, 0);
+
+ block_to_buffer (context->buffer, context->hash_state, i);
+}
+
+static byte *
+whirlpool_read (void *ctx)
+{
+ whirlpool_context_t *context = ctx;
+
+ return context->buffer;
+}
+
+gcry_md_spec_t _gcry_digest_spec_whirlpool =
+ {
+ "WHIRLPOOL", NULL, 0, NULL, 64,
+ whirlpool_init, whirlpool_write, whirlpool_final, whirlpool_read,
+ sizeof (whirlpool_context_t)
+ };
diff --git a/grub-core/lib/libgcrypt/mpi/ChangeLog-2011 b/grub-core/lib/libgcrypt/mpi/ChangeLog-2011
new file mode 100644
index 0000000..9307171
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/ChangeLog-2011
@@ -0,0 +1,822 @@
+2011-12-01 Werner Koch <wk@g10code.com>
+
+ NB: ChangeLog files are no longer manually maintained. Starting
+ on December 1st, 2011 we put change information only in the GIT
+ commit log, and generate a top-level ChangeLog file from logs at
+ "make dist". See doc/HACKING for details.
+
+2011-03-28 Werner Koch <wk@g10code.com>
+
+ * mpi-pow.c (gcry_mpi_powm): Remove unused var RSEC.
+
+2011-02-01 Werner Koch <wk@g10code.com>
+
+ * mpi-cmp.c (gcry_mpi_cmp): Allow comparing of opaque MPIs.
+
+2010-04-12 Brad Hards <bradh@frogmouth.net> (wk)
+
+ Spelling fixes.
+
+2010-02-22 Aurelien Jarno <aurel32@debian.org> (wk)
+
+ * longlong.h (umul_ppmm) <mips> [__GNUC__ >= 4.4]: Patch according
+ to recommended gcc 4.4 changes.
+
+2009-12-09 Werner Koch <wk@g10code.com>
+
+ * config.links: Remove asm modules for all sparc64. This is
+ debian#560028.
+
+2009-05-26 Werner Koch <wk@g10code.com>
+
+ * mpicoder.c (mpi_read_from_buffer): Allow zero-sized MPIs (i.e a
+ zero).
+
+2009-02-16 Werner Koch <wk@g10code.com>
+
+ * mpiutil.c: Remove memory.h.
+
+2008-12-05 Werner Koch <wk@g10code.com>
+
+ * mpicoder.c (mpi_read_from_buffer): Do not bail out if the mpi is
+ larger than the buffer (potential problem). Do not print error
+ messages.
+ (mpi_fromstr): Return an error instead of hitting an assert.
+ (gcry_mpi_scan) <PGP>: Fix potential double free problem.
+ (gcry_mpi_scan) <HEX>: Fix potential memory leak.
+ (do_get_buffer): Return NULL on memory allocation failure.
+ (gcry_mpi_print): Check result of do_get_buffer.
+ (gcry_mpi_aprint): Return error on a memory allocation failure.
+
+ * mpicoder.c: Re-indent.
+
+2008-12-03 Werner Koch <wk@g10code.com>
+
+ * mpi-pow.c (gcry_mpi_powm): Fix last change. Asserts are really
+ useful!
+
+2008-12-02 Werner Koch <wk@g10code.com>
+
+ * mpi-pow.c (gcry_mpi_powm): Re-indent.
+ (gcry_mpi_powm): Simplified allocation of the result to fix a
+ double free bug. This is bug#977. Reported by Haakon Ringberg.
+
+2008-08-20 Werner Koch <wk@g10code.com>
+
+ * mpi-bit.c (gcry_mpi_lshift): Actually implement.
+
+2008-08-19 Werner Koch <wk@g10code.com>
+
+ * mpi-bit.c (gcry_mpi_lshift): New.
+
+2007-10-31 Werner Koch <wk@g10code.com>
+
+ * mpi-mod.c (gcry_mpi_mod): Remove
+ * mpi-inv.c (_gcry_mpi_invm): Remove _ prefix.
+ * mpiutil.c (_gcry_mpi_swap): Remove.
+ (_gcry_mpi_new): Remove.
+ (_gcry_mpi_snew): Remove.
+ (gcry_mpi_invm): Remove.
+ (gcry_mpi_copy): Remove and rename _version to this.
+ (gcry_mpi_set, gcry_mpi_set_ui): Merge with _ version.
+ * mpi-inv.c (gcry_mpi_invm): Remove _ prefix and return 1.
+ * mpi-mul.c (gcry_mpi_mul_2exp): Remove and rename _ version to this.
+
+2007-10-29 Werner Koch <wk@g10code.com>
+
+ * config.links: No Candadian Cross here, thus use $host instead of
+ $target.
+
+2007-10-26 Werner Koch <wk@g10code.com>
+
+ * config.links (mpi_optional_modules): Special rules for Apple
+ Darwin on ia32 from Gregor Riepl.
+
+2007-05-09 Marcus Brinkmann <marcus@g10code.de>
+
+ * config.links: Rename assembler file links by suffixing "-asm".
+ * Makefile.am (CCASCOMPILE, LTCCASCOMPILE, CLEANFILES,
+ libmpi_la_LIBADD, libmpi_la_DEPENDENCIES, SUFFIXES, .S.o, .S.obj,
+ .S.lo): Removed variables and targets.
+ (mpih_add1, mpih_sub1, mpih_mul1, mpih_mul2, mpih_mul3,
+ mpih_lshift, mpih_rshift, mpih_udiv, mpih_udiv_qrnnd,
+ nodist_libmpi_la_SOURCES): New variables.
+ (DISTCLEANFILES): Rename assembler file links by suffixing "-asm".
+ Add variants for C file links.
+
+2007-05-04 Werner Koch <wk@g10code.com>
+
+ * config.links (path): Allowthe sue of colons as delimiters.
+
+2007-05-03 Werner Koch <wk@g10code.com>
+
+ * pentium4/distfiles: Fixed.
+
+2007-04-30 Werner Koch <wk@g10code.com>
+
+ * config.links: Create a file mod-source-info.h.
+ * Makefile.am (DISTCLEANFILES): Add that file.
+ * mpiutil.c (_gcry_mpi_get_hw_config): New.
+
+2007-04-28 Marcus Brinkmann <marcus@g10code.de>
+
+ * config.links: Add additional assembler search directories.
+
+2007-03-28 Werner Koch <wk@g10code.com>
+
+ * ec.c: New.
+
+2007-03-23 Werner Koch <wk@g10code.com>
+
+ * mpi-bit.c (_gcry_mpi_lshift_limbs): Assign AP after the resize.
+
+ * mpi-div.c (gcry_mpi_mod, _gcry_mpi_mod): Moved to ..
+ * mpi-mod.c: .. new file.
+ (_gcry_mpi_barrett_init, _gcry_mpi_barrett_free): New.
+ (_gcry_mpi_mod_barrett): New.
+ (_gcry_mpi_mul_barrett): New.
+
+2007-03-22 Werner Koch <wk@g10code.com>
+
+ * mpi-div.c (_gcry_mpi_mod): New.
+ * mpiutil.c (_gcry_mpi_new, _gcry_mpi_snew): New.
+
+2007-03-13 Werner Dittmann <Werner.Dittmann@t-online.de> (wk)
+
+ * amd64/mpih-add1.S, amd64/mpih-add1.S, amd64/mpih-lshift.S
+ * amd64/mpih-mul1.S, amd64/mpih-mul2.S, amd64/mpih-mul3.S
+ * amd64/mpih-rshift.S, amd64/mpih-sub1.S: New.
+ * config.links: Add case for x86_64.
+
+2007-02-23 Werner Koch <wk@g10code.com>
+
+ * mpi-pow.c (gcry_mpi_powm): Remove unused var ESIGN.
+
+ * mpiutil.c (gcry_mpi_get_flag): Let it return a value to silent
+ MIPSpro cc warning.
+
+2007-02-21 Werner Koch <wk@g10code.com>
+
+ * mpicoder.c (_gcry_mpi_set_buffer): Made BUFFER a void*.
+
+2006-11-15 Werner Koch <wk@g10code.com>
+
+ * Makefile.am (.S.o): Check for srcdir also in in CPP pass.
+ (INCLUDES): Removed.
+ (AM_CPPFLAGS, AM_CFLAGS): New, modified. Merged with Moritz'
+ changes.
+
+2006-11-05 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (AM_CFLAGS): Added -I$(top_builddir)/src so that the
+ new gcrypt.h is used, not the one installed in the system.
+
+2006-10-23 Werner Koch <wk@g10code.com>
+
+ * config.links (mpi_optional_modules): Make sure that powerpc64 is
+ matched before a generic powerpc. Reported by Andreas Metzler.
+ Should fix Debian bug 284609.
+
+2006-08-25 Werner Koch <wk@g10code.com>
+
+ * mpi-bit.c (gcry_mpi_rshift): Don't shift if N == 0 but do a
+ plain copy.
+
+2006-08-04 Werner Koch <wk@g10code.com>
+
+ * mpi-bit.c (gcry_mpi_rshift): Rewritten to remove the limitation
+ on N (which used to be less than BITS_PER_MPI_LIMB).
+
+2006-08-03 Werner Koch <wk@g10code.com>
+
+ * mpi-bit.c (gcry_mpi_set_bit, gcry_mpi_set_highbit): Fixed
+ allocation. Reported by bpgcrypt at itaparica.org.
+ * mpiutil.c (_gcry_mpi_resize): Clear the new part of the resized
+ limb space.
+
+2006-07-26 Werner Koch <wk@g10code.com>
+
+ * mpiutil.c (gcry_mpi_randomize): Changed P to unsigned char*.
+
+ * mpicoder.c (gcry_mpi_scan): Changed arg BUFFER to void*.
+ (mpi_read_from_buffer): Made BUFFER arg const.
+ (gcry_mpi_scan): Removed now needless cast. Add cast for arg to
+ mpi_fromstr.
+ (gcry_mpi_print): Made TMP unsigned.
+
+ * Makefile.am (AM_CCASFLAGS): New.
+
+2005-10-09 Moritz Schulte <moritz@g10code.com>
+
+ * mpi-cmp.c (gcry_mpi_cmp_ui): Rewritten; correctly handle case of
+ zero limbs in U.
+
+2005-04-27 Moritz Schulte <moritz@g10code.com>
+
+ * mpiutil.c (gcry_mpi_randomize): Store random data in secure
+ memory if the given MPI is secure - not the other way around (argl).
+
+2005-04-23 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am: Don't assume the compiler will pre-process the .S
+ files. Some compilers, like those from HP and IBM, don't do
+ this. So, we use the same solution gnupg-1.4.0 does. Preprocess
+ first and then compile.
+
+ * hppa1.1/mpih-mul3.S: Add "level 1.1" directive to disable
+ warning about using PA-RISC1.1 opcodes.
+ * hppa1.1/mpih-mul2.S: Likewise.
+ * hppa1.1/mpih-mul1.S: Likewise.
+ * hppa1.1/udiv-qrnnd.S: Likewise.
+
+2005-02-16 Moritz Schulte <moritz@g10code.com>
+
+ * mpiutil.c (_gcry_mpi_alloc_limb_space): Rewritten, fixed memory
+ corruption.
+
+2005-02-06 Moritz Schulte <moritz@g10code.com>
+
+ * mpiutil.c (_gcry_mpi_get_ui, gcry_mpi_get_ui): New functions.
+
+2005-01-05 Werner Koch <wk@g10code.com>
+
+ * hppa1.1/udiv-qrnnd.S: Reverted change of 2004-03-02 but kept the
+ .align directive.
+
+2004-12-16 Werner Koch <wk@g10code.com>
+
+ * config.links (mpi_optional_modules): Move entry for powerpc64
+ before generic powerpc. Suggested by Rafael Ãvila de Espíndola.
+
+2004-03-02 Werner Koch <wk@gnupg.org>
+
+ * hppa1.1/udiv-qrnnd.S: Alignment fix from Lamont Jones for
+ Debian. Taken from gnupg-1.3.
+
+ * longlong.h: Added PowerPC 64 bit code from GPM-4.1.2 but didn't
+ enable it yet. Some whitespace changes in HPPA to fix assembler
+ problems on HP-UX. From gnupg 1.3
+
+ * mpiutil.c (_gcry_mpi_alloc_limb_space): Better allocate
+ something even if NLIMBS is passed as 0.
+
+ * config.links: Updated system list to match gnupg 1.3.
+
+2003-12-19 Werner Koch <wk@gnupg.org>
+
+ * mpi-internal.h [M_DEBUG]: Removed this unused code.
+ (struct karatsuba_ctx): Added TSPACE_NLIMBS and TP_NLIMBS.
+ * mpiutil.c (_gcry_mpi_free_limb_space): Add arg NLIMBS and wipe
+ out the memory. Changed all callers.
+ * mpih-mul.c (_gcry_mpih_mul_karatsuba_case): Keep track of
+ allocated limbs.
+ * mpi-div.c (_gcry_mpi_tdiv_qr): Keep track of allocated limbs.
+ * mpi-mul.c (gcry_mpi_mul): Ditto.
+ * mpi-pow.c (gcry_mpi_powm): Ditto.
+
+ * Manifest: Empty new file. Also add Manifest files to all CPU
+ specific directories.
+ * Makefile.am: Added.
+
+ * mpiutil.c (gcry_mpi_randomize): Use gcry_create_nonce if WEAK
+ random has been requested.
+
+2003-10-31 Werner Koch <wk@gnupg.org>
+
+ * i386/mpih-rshift.S, i386/mpih-lshift.S: Use %dl and not %edx for
+ testb; this avoids an assembler warning.
+
+ * mpi-pow.c (gcry_mpi_powm): s/exp/expo/ to avoid shadowing warning.
+
+2003-08-19 Marcus Brinkmann <marcus@g10code.de>
+
+ * Makefile.am (SUFFIXES): New variable.
+ (.S.o, .S.lo, .S.obj): Rewritten.
+
+2003-07-30 Moritz Schulte <moritz@g10code.com>
+
+ * longlong.h (__clz_tab): Renamed to _gcry_clz_tab.
+ * mpi-bit.c (__clz_tab): Likewise.
+
+2003-07-27 Werner Koch <wk@gnupg.org>
+
+ * mpicoder.c (gcry_mpi_scan): New argument BUFLEN to replace the
+ use of the intial value of NBYTES. Changed BUFFER to unsigned.
+ (gcry_mpi_print): Likewise.
+ (gcry_mpi_dump): New.
+ (_gcry_log_mpidump): Make use of gcry_mpi_dump.
+ (mpi_print): Removed.
+ (gcry_mpi_scan): Allocated mpi in secure memory when required.
+ (gcry_mpi_aprint): Changed BUFFER to unsigned char*.
+
+2003-07-14 Moritz Schulte <moritz@g10code.com>
+
+ * mpicoder.c: Used gcry_err* wrappers for libgpg-error symbols.
+
+2003-06-16 Moritz Schulte <moritz@g10code.com>
+
+ * mpi-add.c: Replace last occurences of old type names with newer
+ names (i.e. replace MPI with gcry_mpi_t).
+ * mpi-bit.c: Likewise.
+ * mpi-cmp.c: Likewise.
+ * mpi-div.c: Likewise.
+ * mpi-gcd.c: Likewise.
+ * mpi-internal.h: Likewise.
+ * mpi-inv.c: Likewise.
+ * mpi-mpow.c: Likewise.
+ * mpi-mul.c: Likewise.
+ * mpi-pow.c: Likewise.
+ * mpi-scan.c: Likewise.
+ * mpicoder.c: Likewise.
+ * mpiutil.c: Likewise.
+
+2003-06-09 Moritz Schulte <moritz@g10code.com>
+
+ * mpicoder.c (gcry_mpi_scan): Adjust for libgpg-error.
+ (gcry_mpi_print): Likewise.
+ (gcry_mpi_aprint): Likewise.
+
+2003-06-07 Moritz Schulte <moritz@g10code.com>
+
+ * longlong.h, mpi-add.c, mpi-bit.c, mpi-cmp.c, mpi-div.c,
+ mpi-gcd.c, mpi-inline.c, mpi-inline.h, mpi-internal.h, mpi-inv.c,
+ mpi-mpow.c, mpi-mul.c, mpi-pow.c, mpi-scan.c, mpicoder.c,
+ mpih-div.c, mpih-mul.c, mpiutil.c, generic/mpi-asm-defs.h,
+ generic/mpih-add1.c, generic/mpih-lshift.c, generic/mpih-mul1.c,
+ generic/mpih-mul2.c, generic/mpih-mul3.c, generic/mpih-rshift.c,
+ generic/mpih-sub1.c, generic/udiv-w-sdiv.c, i386/syntax.h,
+ m68k/syntax.h, mips3/mpi-asm-defs.h, powerpc32/syntax.h: Edited
+ all preprocessor instructions to remove whitespace before the '#'.
+ This is not required by C89, but there are some compilers out
+ there that don't like it. Replaced any occurence of the now
+ deprecated type names with the new ones.
+
+2003-05-21 Moritz Schulte <moritz@g10code.com>
+
+ * mpiutil.c (_gcry_mpi_alloc_limb_space): Only try to allocate
+ memory in case the amount of bytes to allocate is non-zero.
+
+2003-04-27 Moritz Schulte <moritz@g10code.com>
+
+ * mpiutil.c (_gcry_mpi_resize): Allocate secure memory, in case
+ bit zero of `flags' is set.
+
+ * mpi-add.c (gcry_mpi_sub): Simplify function; always use a
+ temporary variable now.
+
+2003-04-15 Werner Koch <wk@gnupg.org>
+
+ * longlong.h (umul_ppmm): Support SH3 and SH4. Thanks to
+ kazuya.s@jp.yokogawa.com.
+
+2003-04-02 Werner Koch <wk@gnupg.org>
+
+ * mpicoder.c (gcry_mpi_print): Fixed testing against possible
+ uninitialized LEN. Valgrinded by Nikos Mavroyanopoulos.
+
+2003-01-15 Werner Koch <wk@gnupg.org>
+
+ * longlong.h: Removed some spaces between backslashes and newlines.
+
+2002-09-20 Werner Koch <wk@gnupg.org>
+
+ * mpi-mul.c (gcry_mpi_mul_2exp): New. This was declared in
+ gcrypt.h but only implemented as internal function. Noted by Timo
+ but a few minutes to late for today's release.
+
+ * Makefile.am (DISTCLEANFILES): Include mpi-asm-defs.h
+
+2002-09-18 Werner Koch <wk@gnupg.org>
+
+ * Makefile.am (.S.lo): Pass -DPIC. i386, PPC and Sparc code
+ require it. It worked for me because I am using the i586 code.
+
+2002-08-23 Werner Koch <wk@gnupg.org>
+
+ * Makefile.am (.S.lo): Fixed for libtool build with --disable-shared.
+
+2002-07-24 Werner Koch <wk@gnupg.org>
+
+ * longlong.h: Replaced all K&R multiline strings by ISO ones for
+ the sake of modern compilers. Suggested by Marco Parrone.
+
+2002-06-24 Werner Koch <wk@gnupg.org>
+
+ * mpiutil.c (gcry_mpi_swap): New.
+
+ * mpi-div.c (gcry_mpi_div): New.
+ (gcry_mpi_mod): New.
+ * mpi-inv.c (gcry_mpi_invm): New.
+
+ * mpicoder.c (do_get_buffer): Make sure that we allocate at least
+ one byte.
+
+2002-06-12 Werner Koch <wk@gnupg.org>
+
+ * hppa1.1/udiv-qrnnd.S: Changes for PIC by Randolph Chung.
+
+2002-05-15 Werner Koch <wk@gnupg.org>
+
+ * config.links: Chnage the way the mpi modules are determined.
+ * Makefile.am: Revamped to better handle modules
+
+2002-05-14 Werner Koch <wk@gnupg.org>
+
+ Changed license of all files to the LGPL.
+
+2002-04-18 Werner Koch <wk@gnupg.org>
+
+ * mpicoder.c (gcry_mpi_scan): Don't use normalize on a NULL MPI.
+
+2002-03-20 Werner Koch <wk@gnupg.org>
+
+ * mpicoder.c (mpi_read_from_buffer): Bail out on a zero length
+ buffer because we can't eventually do an malloc of this size.
+ Reported by Timo.
+
+2002-01-14 Werner Koch <wk@gnupg.org>
+
+ * mpi-inv.c (_gcry_mpi_invm): Typo fixes, noted by Carlo Perassi.
+
+2001-11-01 Werner Koch <wk@gnupg.org>
+
+ * mpicoder.c (gcry_mpi_scan): Allow to pass a nbytes as NULL or
+ with value 0 for format GCRY_FMT_SSH, so that the length is not
+ used for any checks, only the length stored in the bufer is used.
+ This is a nice format becuase we can just pass a buffer around and
+ don't need to care about its length.
+
+2001-08-03 Werner Koch <wk@gnupg.org>
+
+ * config.links: Changed the way the list of files to be
+ symlinked is returned.
+
+2001-05-31 Werner Koch <wk@gnupg.org>
+
+ * mpih-cmp.c: Removed and moved mpihelp_cmp to ..
+ * mpi-inline.h: .. here.
+
+ Major function renaming. All global functions are now prefixed
+ with _gcry_ or gcry_. Renamed also all mpihelp_ to just mpih_ so
+ that functions names are not getting to long an unreadable and for
+ better matching with the filenames.
+
+2001-05-28 Werner Koch <wk@gnupg.org>
+
+ * mpicoder.c (mpi_fromstr): Made static and assume that all input
+ is in hexformat.
+
+ Updated all CPU specific code with the one from GnuPG-1.0.5. This
+ is just a change of text formatting and the use of .label
+ instead of labels for hppa and pa7100.
+
+ * longlong.h: Fixes for ARM by Phil Blundell.
+
+2001-03-29 Werner Koch <wk@gnupg.org>
+
+ * mpi-mul.c (mpi_mul): Make sure that secret temporary results are
+ not stored in w. Suggested by Florian Weimer.
+
+ * config.links: Use i386 code for i386. According to tests by
+ Kevin Ryde the i586 code runs slow on i386 CPUs. Ditto for i786.
+
+2001-01-11 Werner Koch <wk@gnupg.org>
+
+ * Makefile.am: Removed mpi.h.
+
+2000-12-19 Werner Koch <wk@gnupg.org>
+
+ * mpi-internal.h: Put limb_t definition in an ifdef.
+
+ Major change:
+ Removed all GnuPG stuff and renamed this piece of software
+ to gcrypt.
+
+2000-11-14 Werner Koch <wk@gnupg.org>
+
+ * mpi-internal.h, mpi.h: Changed the way they are called and
+ introduced DID_MPI_LIMP_TYPEDEF hack. Very ugly, should all be
+ revamped.
+
+ * Makefile.am (OMIT_DEPENDENCIES): Hack to work around dependency
+ problems.
+
+2000-10-11 Werner Koch <wk@gnupg.org>
+
+ * generic/mpi-asm-defs.h: New.
+ * mips3/mpi-asm-defs.h: New.
+ * config.links: Create a link to one of the above files.
+
+Fri Jul 28 18:19:11 CEST 2000 Werner Koch <wk@openit.de>
+
+ * mpicoder.c (gcry_mpi_scan): Normalize the returned MPI.
+
+Tue Jul 25 17:44:15 CEST 2000 Werner Koch <wk@openit.de>
+
+ * config.links: Support for powerpc--netbsd by Gabriel Rosenkoetter.
+
+Mon Jul 17 16:35:47 CEST 2000 Werner Koch <wk@>
+
+ * power/: Add all files from GMP for this CPU. Converted comments to
+ CPP comments because some ASes complain about ' in comments.
+
+ * config.links: Support for BSDI 4.x; by Wayne Chapeskie. Add support
+ for FreeBSD 5 and made the case stmt looking nicer; by Jun Kuriyama.
+ Add support for NetBSD.
+ (sparc8): Made the search path the same as sparc9
+ (sparc64-unknown-linux-gnu): use udiv module; by Adam Mitchell.
+
+ * Makefile.am: c/SFLAGS/ASFLAGS/. This has only been used by the
+ powerpc and actually never passed the -Wa,foo to the cc.
+
+ * mpih-div.c (mpihelp_divrem): The MPN_COPY_DECR copied one element
+ too many. This is a gmp2.0.2p9.txt patch.
+
+ * longlong.h (umul_ppmm): Fixes for ARM-4. By Sean MacLennan.
+
+ * mpi-internal.h (karatsuba_ctx): New.
+ * mpih-mul.c (mpihelp_release_karatsuba_ctx): New.
+ (mpihelp_mul_karatsuba_case): New.
+ (mpihelp_mul): Splitted to make use of the new functions.
+ * mpi-pow.c (mpi_powm): Make use of the new splitted function to avoid
+ multiple allocation of temporary memory during the karatsuba operations.
+ * mpi_mpow.c: Removed the unused Barrett code.
+
+2000-03-21 16:17:30 Werner Koch (wk@habibti.openit.de)
+
+ * config.links: Add support for FreeBSD 5.
+
+Mon Jan 24 22:24:38 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * mpicoder.c (gcry_mpi_aprint): Now really returns the length.
+
+Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * mpiutil.c: Removed all memory debugging code.
+
+ * mpicoder.c (gcry_mpi_aprint): New.
+
+ * Replaced all m_ memory functions by g10_ ones.
+
+Fri Dec 31 14:06:56 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * mpi-bit.c (gcry_mpi_get_nbits): New.
+
+ * mpiutil.c (mpi_set_secure): made static.
+ (gcry_mpi_get_flag): New.
+ (gcry_mpi_set_flag): New.
+ (gcry_mpi_clear_flag): New.
+ (mpi_set_opaque): renamed to gcry_mpi_set_opaque.
+ (mpi_get_opaque): renamed to gcry_mpi_get_opaque.
+
+Fri Dec 31 12:48:31 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * mpicoder.c (mpi_read_from_buffer): Made static.
+ (gcry_mpi_print): A buffer of NULL is now allowed to get the required
+ length back.
+ (mpi_get_keyid): Removed.
+ (mpi_print): Made static - should be removed.
+
+Wed Dec 8 21:58:32 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * Makefile.am (INCLUDES): Add ../gcrypt.
+
+ * g10m.c : Removed.
+
+ * mpicoder.c (mpi_write): Removed.
+ (mpi_read): Removed.
+ (gcry_mpi_scan): New. Taken from ../gcrypt/mpiapi.c.
+ (gcry_mpi_print): Ditto.
+
+ * mpi-pow.c (mpi_powm): Renamed to ...
+ (gcry_mpi_powm): ... this.
+
+ * mpiutil.c (gcry_mpi_new): New as a wrapper around the old function.
+ Taken from ../gcrypt/mpiapi.c.
+ (gcry_mpi_snew): Ditto.
+ (gcry_mpi_release): Ditto.
+ (gcry_mpi_copy): Ditto.
+ (gcry_mpi_set): Ditto.
+ (gcry_mpi_set_ui): Ditto.
+ (gcry_mpi_cmp): Ditto.
+ (gcry_mpi_cmp_ui): Ditto.
+ (gcry_mpi_randomize): Ditto.
+
+ * mpicoder.c (mpi_print): Removed the nbit_info kludge.
+ * mpi-bits.c (mpi_get_nbits): Replaced the is_protected stuff by
+ checking whether it is an opaque mpi and then returns it's length
+ in bits.
+ * mpiutil.c (mpi_set_opaque): Changed the interface to take a number
+ of bits for the length. Adjusted all users.
+ (mpi_get_opaque): Ditto.
+
+Fri Nov 19 17:15:20 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * mpicoder.c (g10_log_mpidump): Add a temporary workaround
+
+ * mpih-mul.c (mpihelp_mul_n): s/m_is_ecure/g10_is_secure/
+
+ * mpiutil.c (mpi_alloc): Remved the debug mode because it has turned
+ out, that this feature was not very useful in the past. Use the
+ new alloc functions.
+ (mpi_alloc_secure): Ditto.
+ (mpi_alloc_limb_space): Ditto.
+ (mpi_free_limb_space): Ditto.
+ (mpi_resize): Ditto.
+ (mpi_free): Ditto.
+ (mpi_set_secure): Removed the debug stuff.
+ (mpi_set_opaque): Ditto.
+ (mpi_copy): Ditto.
+ (mpi_alloc_set_ui): Ditto.
+ (mpi_m_check): Use g10_ wrapper.
+
+Mon Aug 30 20:38:33 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+
+ * config.links: Add case label for DJGPP
+
+Wed Jul 14 19:42:08 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+
+ * Makefile.am: Use .s files as temporaries, disabled other .S rules.
+
+Wed Jul 7 13:08:40 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+
+ * mpicoder.c (g10_log_mpidump): New.
+
+ * Makefile.am: Support for libtool.
+
+Fri Jul 2 11:45:54 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+
+ * mpi-bit.c (mpi_lshift_limbs,mpi_rshift_limbs): New.
+ * mpi-mpow.c (barrett_mulm): New but diabled.
+
+Tue Jun 1 16:01:46 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * config.links (i[56]86*-*-freebsdelf*): New.
+
+Sun May 23 14:20:22 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * config.links (sysdep.h): Not any more conditionally created.
+
+Tue May 4 15:47:53 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * mpiutil.c (mpi_alloc_like): New.
+
+Mon Apr 26 17:48:15 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * mpih-add.c, mpih-sub.c: Removed
+ * mpi-inline.c: New.
+ * mpi-inline.h: Make it usable by mpi-inline.c.
+
+Sun Apr 18 10:11:28 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * mpih-mul.c (mpihelp_mul_n): Fixed use of memory region.
+ (mpihelp_mul): Ditto.
+
+Wed Apr 7 20:51:39 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Explicit rules to invoke cpp on *.S
+
+Mon Mar 8 20:47:17 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * config.links: Take advantage of the with_symbol_underscore macro.
+ Add support for freebsd 4.
+
+Wed Feb 24 11:07:27 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * mips3/mpih-sub1.S: Removed left over junk in last line. (Should I
+ blame me or my editor?).
+
+Sat Feb 13 12:04:43 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * Makefile.am: Removed the +=. Add MPI_OPT_FLAGS.
+
+Sat Jan 9 16:02:23 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * mpi-cmp.c (mpi_cmp_ui): Normalized the arg.
+
+Thu Jan 7 18:00:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * mpi-bit.c (mpi_normalize): New.
+ (mpi_get_nbits): Normalize the MPI.
+ * mpi-bit.c (mpi_cmp): Normalize the MPI before the compare.
+
+
+Tue Dec 8 13:15:16 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * config.links: Moved the case for powerpc*linux
+ * powerpcp32/*.S: Removed some underscores.
+
+Thu Nov 26 07:27:52 1998 Werner Koch <werner.koch@guug.de>
+
+ * config.links: Support for ppc with ELF
+ * powerpc32/syntax.h: New.
+ * powerpc32/*.S: Applied ELF patches (glibc patches)
+
+Tue Nov 10 19:31:37 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * power*/ : Started with stuff for PPC
+ * config.links: Some stuff for PPC.
+ * generic/udiv-w-sdiv.c: New but disabled.
+
+Tue Oct 27 12:37:46 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * config.links (freebsd): Fixes for FreeBSD 3.0
+
+Wed Oct 14 09:59:30 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * config.links (freebsd): ELF patches from Jun Kuriyama.
+
+Thu Oct 8 13:28:17 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * mpi-mpow.c (mpi_mulpowm): Fixed mem leak (m_free/mpi_free).
+
+Thu Sep 17 18:08:50 1998 Werner Koch (wk@(none))
+
+ * hppa1.1/udiv-qrnnd.S: Fix from Steffen Zahn for HPUX 10.20
+
+Thu Aug 6 16:39:28 1998 Werner Koch,mobil,,, (wk@tobold)
+
+ * mpi-bit.c (mpi_set_bytes): Removed.
+
+Wed Aug 5 15:11:12 1998 Werner Koch (wk@(none))
+
+ * mpicoder.c (mpi_read_from_buffer): New.
+
+ * mpiutil.c (mpi_set_opaque): New.
+ (mpi_get_opaque): New.
+ (mpi_copy): Changed to support opauqe flag
+ (mpi_free): Ditto.
+
+Sat Jul 4 10:11:11 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * mpiutil.c (mpi_clear): Reset flags.
+ (mpi_set): Ditto.
+ (mpi_alloc_secure): Set flag to 1 and not ored the 1 in, tsss..
+
+Fri Jun 26 11:19:06 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * mpiutil.c (mpi_alloc): set nbits to 0.
+ (mpi_alloc_secure): Ditto.
+ (mpi_clear): Ditto.
+
+Thu Jun 25 11:50:01 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * mips3/*.S: New
+
+Mon May 18 13:47:06 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * config.links: split mpih-shift into mpih-[lr]shift and
+ changed all implementations.
+ * mpi/alpha: add some new assembler stuff.
+
+Wed May 13 11:04:29 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * config.links: Add support for MIPS
+
+Thu Apr 9 11:31:36 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * mpicoder.c (mpi_get_secure_buffer): New.
+
+Wed Apr 8 09:44:33 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * config.links: Applied small fix from Ulf Möller.
+
+Mon Apr 6 12:38:52 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * mpicoder.c (mpi_get_buffer): Removed returned leading zeroes
+ and changed all callers.
+
+Tue Mar 10 13:40:34 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * mpi-bit.c (mpi_clear_highbit): New.
+
+Mon Mar 2 19:29:00 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * Makefile.am (DISTCLEANFILES): New
+
+Thu Feb 26 06:48:54 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * config.links (X86_BROKEN_ALIGN): Added for some systems.
+
+Mon Feb 23 12:21:40 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * mpi/m68k/mpih-shift.S (Lspecial): Changed duplicate symbol.
+
+Mon Feb 16 13:00:27 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * config.links : Add detection of m68k cpus
+
+
+ Copyright 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+
+ This file is free software; as a special exception the author gives
+ unlimited permission to copy and/or distribute it, with or without
+ modifications, as long as this notice is preserved.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/grub-core/lib/libgcrypt/mpi/Makefile.am b/grub-core/lib/libgcrypt/mpi/Makefile.am
new file mode 100644
index 0000000..e900539
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/Makefile.am
@@ -0,0 +1,177 @@
+## Process this file with automake to produce Makefile.in
+# Copyright (C) 1992, 1999, 2000, 2002 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+# 1.5 leads to a combinatorial explosion due to all the conditionals
+# I was not able to build it with 64Megs - 1.6 fixes this.
+# not anymore required: AUTOMAKE_OPTIONS = 1.6
+
+# Need to include ../src in addition to top_srcdir because gcrypt.h is
+# a built header.
+AM_CPPFLAGS = -I../src -I$(top_srcdir)/src
+AM_CFLAGS = $(GPG_ERROR_CFLAGS)
+
+AM_ASFLAGS = $(MPI_SFLAGS)
+AM_CCASFLAGS = $(NOEXECSTACK_FLAGS)
+
+EXTRA_DIST = Manifest config.links
+DISTCLEANFILES = mpi-asm-defs.h \
+ mpih-add1-asm.S mpih-mul1-asm.S mpih-mul2-asm.S mpih-mul3-asm.S \
+ mpih-lshift-asm.S mpih-rshift-asm.S mpih-sub1-asm.S asm-syntax.h \
+ mpih-add1.c mpih-mul1.c mpih-mul2.c mpih-mul3.c \
+ mpih-lshift.c mpih-rshift.c mpih-sub1.c \
+ sysdep.h mod-source-info.h
+
+# Beware: The following list is not a comment but grepped by
+# config.links to get the list of symlinked modules
+# Optional modules are marked with an O in the second column.
+#BEGIN_ASM_LIST
+# mpih-add1 C
+# mpih-sub1 C
+# mpih-mul1 C
+# mpih-mul2 C
+# mpih-mul3 C
+# mpih-lshift C
+# mpih-rshift C
+# udiv O
+# udiv-qrnnd O
+#END_ASM_LIST
+
+# Note: This function has not yet been implemented. There is only a dummy in
+# generic/
+# udiv-w-sdiv O
+
+# And we need to have conditionals for all modules because
+# we don't know whether they are .c or .S. Very ugly; I know.
+# Remember to define them all in configure.ac
+if MPI_MOD_ASM_MPIH_ADD1
+mpih_add1 = mpih-add1-asm.S
+else
+if MPI_MOD_C_MPIH_ADD1
+mpih_add1 = mpih-add1.c
+else
+mpih_add1 =
+endif
+endif
+
+if MPI_MOD_ASM_MPIH_SUB1
+mpih_sub1 = mpih-sub1-asm.S
+else
+if MPI_MOD_C_MPIH_SUB1
+mpih_sub1 = mpih-sub1.c
+else
+mpih_sub1 =
+endif
+endif
+
+if MPI_MOD_ASM_MPIH_MUL1
+mpih_mul1 = mpih-mul1-asm.S
+else
+if MPI_MOD_C_MPIH_MUL1
+mpih_mul1 = mpih-mul1.c
+else
+mpih_mul1 =
+endif
+endif
+
+if MPI_MOD_ASM_MPIH_MUL2
+mpih_mul2 = mpih-mul2-asm.S
+else
+if MPI_MOD_C_MPIH_MUL2
+mpih_mul2 = mpih-mul2.c
+else
+mpih_mul2 =
+endif
+endif
+
+if MPI_MOD_ASM_MPIH_MUL3
+mpih_mul3 = mpih-mul3-asm.S
+else
+if MPI_MOD_C_MPIH_MUL3
+mpih_mul3 = mpih-mul3.c
+else
+mpih_mul3 =
+endif
+endif
+
+if MPI_MOD_ASM_MPIH_LSHIFT
+mpih_lshift = mpih-lshift-asm.S
+else
+if MPI_MOD_C_MPIH_LSHIFT
+mpih_lshift = mpih-lshift.c
+else
+mpih_lshift =
+endif
+endif
+
+if MPI_MOD_ASM_MPIH_RSHIFT
+mpih_rshift = mpih-rshift-asm.S
+else
+if MPI_MOD_C_MPIH_RSHIFT
+mpih_rshift = mpih-rshift.c
+else
+mpih_rshift =
+endif
+endif
+
+if MPI_MOD_ASM_UDIV
+udiv = udiv-asm.S
+else
+if MPI_MOD_C_UDIV
+udiv = udiv.c
+else
+udiv =
+endif
+endif
+
+if MPI_MOD_ASM_UDIV_QRNND
+udiv_qrnnd = udiv-qrnnd-asm.S
+else
+if MPI_MOD_C_UDIV_QRNND
+udiv_qrnnd = udiv-qrnnd.c
+else
+udiv_qrnnd =
+endif
+endif
+
+noinst_LTLIBRARIES = libmpi.la
+
+libmpi_la_LDFLAGS =
+nodist_libmpi_la_SOURCES = $(mpih_add1) $(mpih_sub1) $(mpih_mul1) \
+ $(mpih_mul2) $(mpih_mul3) $(mpih_lshift) $(mpih_rshift) \
+ $(udiv) $(udiv_qrnnd)
+libmpi_la_SOURCES = longlong.h \
+ mpi-add.c \
+ mpi-bit.c \
+ mpi-cmp.c \
+ mpi-div.c \
+ mpi-gcd.c \
+ mpi-internal.h \
+ mpi-inline.h \
+ mpi-inline.c \
+ mpi-inv.c \
+ mpi-mul.c \
+ mpi-mod.c \
+ mpi-pow.c \
+ mpi-mpow.c \
+ mpi-scan.c \
+ mpicoder.c \
+ mpih-div.c \
+ mpih-mul.c \
+ mpiutil.c \
+ ec.c
diff --git a/grub-core/lib/libgcrypt/mpi/Manifest b/grub-core/lib/libgcrypt/mpi/Manifest
new file mode 100644
index 0000000..3b0d673
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/Manifest
@@ -0,0 +1,41 @@
+# Manifest - checksums of the mpi directory
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+Makefile.am
+config.links
+longlong.h
+mpi-add.c
+mpi-bit.c
+mpi-cmp.c
+mpi-div.c
+mpi-gcd.c
+mpi-inline.c
+mpi-inline.h
+mpi-internal.h
+mpi-inv.c
+mpi-mpow.c
+mpi-mul.c
+mpi-pow.c
+mpi-scan.c
+mpicoder.c
+mpih-div.c
+mpih-mul.c
+mpiutil.c
+$names$ iQCVAwUAP+LmfDEAnp832S/7AQKZJQQAkR/gQITUM+6Ygy9WAOAO17btyKAlCtGTXp5XSZ+J3X0o/rYneRdSCW89IJvwFRJjAOcFJd52MXs6ZVFF/RQBC8MvJzuQChbEzvihK8o2VgK34YWjU+6XH9sFgRMIgzkHs/51ZZxeQUOPy1XF7TyKB0WE7YBUVisFiRaqB1qGIOs==Z3qB
+
diff --git a/grub-core/lib/libgcrypt/mpi/alpha/README b/grub-core/lib/libgcrypt/mpi/alpha/README
new file mode 100644
index 0000000..55c0a29
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/alpha/README
@@ -0,0 +1,53 @@
+This directory contains mpn functions optimized for DEC Alpha processors.
+
+RELEVANT OPTIMIZATION ISSUES
+
+EV4
+
+1. This chip has very limited store bandwidth. The on-chip L1 cache is
+write-through, and a cache line is transfered from the store buffer to the
+off-chip L2 in as much 15 cycles on most systems. This delay hurts
+mpn_add_n, mpn_sub_n, mpn_lshift, and mpn_rshift.
+
+2. Pairing is possible between memory instructions and integer arithmetic
+instructions.
+
+3. mulq and umulh is documented to have a latency of 23 cycles, but 2 of
+these cycles are pipelined. Thus, multiply instructions can be issued at a
+rate of one each 21nd cycle.
+
+EV5
+
+1. The memory bandwidth of this chip seems excellent, both for loads and
+stores. Even when the working set is larger than the on-chip L1 and L2
+caches, the perfromance remain almost unaffected.
+
+2. mulq has a measured latency of 13 cycles and an issue rate of 1 each 8th
+cycle. umulh has a measured latency of 15 cycles and an issue rate of 1
+each 10th cycle. But the exact timing is somewhat confusing.
+
+3. mpn_add_n. With 4-fold unrolling, we need 37 instructions, whereof 12
+ are memory operations. This will take at least
+ ceil(37/2) [dual issue] + 1 [taken branch] = 20 cycles
+ We have 12 memory cycles, plus 4 after-store conflict cycles, or 16 data
+ cache cycles, which should be completely hidden in the 20 issue cycles.
+ The computation is inherently serial, with these dependencies:
+ addq
+ / \
+ addq cmpult
+ | |
+ cmpult |
+ \ /
+ or
+ I.e., there is a 4 cycle path for each limb, making 16 cycles the absolute
+ minimum. We could replace the `or' with a cmoveq/cmovne, which would save
+ a cycle on EV5, but that might waste a cycle on EV4. Also, cmov takes 2
+ cycles.
+ addq
+ / \
+ addq cmpult
+ | \
+ cmpult -> cmovne
+
+STATUS
+
diff --git a/grub-core/lib/libgcrypt/mpi/alpha/distfiles b/grub-core/lib/libgcrypt/mpi/alpha/distfiles
new file mode 100644
index 0000000..f2ab9fc
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/alpha/distfiles
@@ -0,0 +1,11 @@
+README
+mpih-add1.S
+mpih-sub1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-lshift.S
+mpih-rshift.S
+
+udiv-qrnnd.S
+
diff --git a/grub-core/lib/libgcrypt/mpi/alpha/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/alpha/mpih-add1.S
new file mode 100644
index 0000000..50dbb2b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/alpha/mpih-add1.S
@@ -0,0 +1,124 @@
+/* alpha add_n -- Add two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ * Copyright (C) 1995, 1998, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr, ($16)
+ * mpi_ptr_t s1_ptr, ($17)
+ * mpi_ptr_t s2_ptr, ($18)
+ * mpi_size_t size) ($19)
+ */
+
+
+ .set noreorder
+ .set noat
+.text
+ .align 3
+ .globl _gcry_mpih_add_n
+ .ent _gcry_mpih_add_n
+_gcry_mpih_add_n:
+ .frame $30,0,$26,0
+
+ ldq $3,0($17)
+ ldq $4,0($18)
+
+ subq $19,1,$19
+ and $19,4-1,$2 # number of limbs in first loop
+ bis $31,$31,$0
+ beq $2,.L0 # if multiple of 4 limbs, skip first loop
+
+ subq $19,$2,$19
+
+.Loop0: subq $2,1,$2
+ ldq $5,8($17)
+ addq $4,$0,$4
+ ldq $6,8($18)
+ cmpult $4,$0,$1
+ addq $3,$4,$4
+ cmpult $4,$3,$0
+ stq $4,0($16)
+ or $0,$1,$0
+
+ addq $17,8,$17
+ addq $18,8,$18
+ bis $5,$5,$3
+ bis $6,$6,$4
+ addq $16,8,$16
+ bne $2,.Loop0
+
+.L0: beq $19,.Lend
+
+ .align 3
+.Loop: subq $19,4,$19
+
+ ldq $5,8($17)
+ addq $4,$0,$4
+ ldq $6,8($18)
+ cmpult $4,$0,$1
+ addq $3,$4,$4
+ cmpult $4,$3,$0
+ stq $4,0($16)
+ or $0,$1,$0
+
+ ldq $3,16($17)
+ addq $6,$0,$6
+ ldq $4,16($18)
+ cmpult $6,$0,$1
+ addq $5,$6,$6
+ cmpult $6,$5,$0
+ stq $6,8($16)
+ or $0,$1,$0
+
+ ldq $5,24($17)
+ addq $4,$0,$4
+ ldq $6,24($18)
+ cmpult $4,$0,$1
+ addq $3,$4,$4
+ cmpult $4,$3,$0
+ stq $4,16($16)
+ or $0,$1,$0
+
+ ldq $3,32($17)
+ addq $6,$0,$6
+ ldq $4,32($18)
+ cmpult $6,$0,$1
+ addq $5,$6,$6
+ cmpult $6,$5,$0
+ stq $6,24($16)
+ or $0,$1,$0
+
+ addq $17,32,$17
+ addq $18,32,$18
+ addq $16,32,$16
+ bne $19,.Loop
+
+.Lend: addq $4,$0,$4
+ cmpult $4,$0,$1
+ addq $3,$4,$4
+ cmpult $4,$3,$0
+ stq $4,0($16)
+ or $0,$1,$0
+ ret $31,($26),1
+
+ .end _gcry_mpih_add_n
+
diff --git a/grub-core/lib/libgcrypt/mpi/alpha/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/alpha/mpih-lshift.S
new file mode 100644
index 0000000..ded4b15
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/alpha/mpih-lshift.S
@@ -0,0 +1,122 @@
+/* alpha - left shift
+ *
+ * Copyright (C) 1994, 1995, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp, (r16)
+ * mpi_ptr_t up, (r17)
+ * mpi_size_t usize, (r18)
+ * unsigned cnt) (r19)
+ *
+ * This code runs at 4.8 cycles/limb on the 21064. With infinite unrolling,
+ * it would take 4 cycles/limb. It should be possible to get down to 3
+ * cycles/limb since both ldq and stq can be paired with the other used
+ * instructions. But there are many restrictions in the 21064 pipeline that
+ * makes it hard, if not impossible, to get down to 3 cycles/limb:
+ *
+ * 1. ldq has a 3 cycle delay, srl and sll have a 2 cycle delay.
+ * 2. Only aligned instruction pairs can be paired.
+ * 3. The store buffer or silo might not be able to deal with the bandwidth.
+ */
+
+ .set noreorder
+ .set noat
+.text
+ .align 3
+ .globl _gcry_mpih_lshift
+ .ent _gcry_mpih_lshift
+_gcry_mpih_lshift:
+ .frame $30,0,$26,0
+
+ s8addq $18,$17,$17 # make r17 point at end of s1
+ ldq $4,-8($17) # load first limb
+ subq $17,8,$17
+ subq $31,$19,$7
+ s8addq $18,$16,$16 # make r16 point at end of RES
+ subq $18,1,$18
+ and $18,4-1,$20 # number of limbs in first loop
+ srl $4,$7,$0 # compute function result
+
+ beq $20,.L0
+ subq $18,$20,$18
+
+ .align 3
+.Loop0:
+ ldq $3,-8($17)
+ subq $16,8,$16
+ subq $17,8,$17
+ subq $20,1,$20
+ sll $4,$19,$5
+ srl $3,$7,$6
+ bis $3,$3,$4
+ bis $5,$6,$8
+ stq $8,0($16)
+ bne $20,.Loop0
+
+.L0: beq $18,.Lend
+
+ .align 3
+.Loop: ldq $3,-8($17)
+ subq $16,32,$16
+ subq $18,4,$18
+ sll $4,$19,$5
+ srl $3,$7,$6
+
+ ldq $4,-16($17)
+ sll $3,$19,$1
+ bis $5,$6,$8
+ stq $8,24($16)
+ srl $4,$7,$2
+
+ ldq $3,-24($17)
+ sll $4,$19,$5
+ bis $1,$2,$8
+ stq $8,16($16)
+ srl $3,$7,$6
+
+ ldq $4,-32($17)
+ sll $3,$19,$1
+ bis $5,$6,$8
+ stq $8,8($16)
+ srl $4,$7,$2
+
+ subq $17,32,$17
+ bis $1,$2,$8
+ stq $8,0($16)
+
+ bgt $18,.Loop
+
+.Lend: sll $4,$19,$8
+ stq $8,-8($16)
+ ret $31,($26),1
+ .end _gcry_mpih_lshift
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/alpha/mpih-mul1.S b/grub-core/lib/libgcrypt/mpi/alpha/mpih-mul1.S
new file mode 100644
index 0000000..cd91b10
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/alpha/mpih-mul1.S
@@ -0,0 +1,90 @@
+/* Alpha 21064 mpih-mul1.S -- Multiply a limb vector with a limb and store
+ * the result in a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (r16)
+ * mpi_ptr_t s1_ptr, (r17)
+ * mpi_size_t s1_size, (r18)
+ * mpi_limb_t s2_limb) (r19)
+ *
+ * This code runs at 42 cycles/limb on the EV4 and 18 cycles/limb on the EV5.
+ *
+ * To improve performance for long multiplications, we would use
+ * 'fetch' for S1 and 'fetch_m' for RES. It's not obvious how to use
+ * these instructions without slowing down the general code: 1. We can
+ * only have two prefetches in operation at any time in the Alpha
+ * architecture. 2. There will seldom be any special alignment
+ * between RES_PTR and S1_PTR. Maybe we can simply divide the current
+ * loop into an inner and outer loop, having the inner loop handle
+ * exactly one prefetch block?
+ */
+
+ .set noreorder
+ .set noat
+.text
+ .align 3
+ .globl _gcry_mpih_mul_1
+ .ent _gcry_mpih_mul_1 2
+_gcry_mpih_mul_1:
+ .frame $30,0,$26
+
+ ldq $2,0($17) # $2 = s1_limb
+ subq $18,1,$18 # size--
+ mulq $2,$19,$3 # $3 = prod_low
+ bic $31,$31,$4 # clear cy_limb
+ umulh $2,$19,$0 # $0 = prod_high
+ beq $18,Lend1 # jump if size was == 1
+ ldq $2,8($17) # $2 = s1_limb
+ subq $18,1,$18 # size--
+ stq $3,0($16)
+ beq $18,Lend2 # jump if size was == 2
+
+ .align 3
+Loop: mulq $2,$19,$3 # $3 = prod_low
+ addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
+ subq $18,1,$18 # size--
+ umulh $2,$19,$4 # $4 = cy_limb
+ ldq $2,16($17) # $2 = s1_limb
+ addq $17,8,$17 # s1_ptr++
+ addq $3,$0,$3 # $3 = cy_limb + prod_low
+ stq $3,8($16)
+ cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
+ addq $16,8,$16 # res_ptr++
+ bne $18,Loop
+
+Lend2: mulq $2,$19,$3 # $3 = prod_low
+ addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
+ umulh $2,$19,$4 # $4 = cy_limb
+ addq $3,$0,$3 # $3 = cy_limb + prod_low
+ cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
+ stq $3,8($16)
+ addq $4,$0,$0 # cy_limb = prod_high + cy
+ ret $31,($26),1
+Lend1: stq $3,0($16)
+ ret $31,($26),1
+
+ .end _gcry_mpih_mul_1
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/alpha/mpih-mul2.S b/grub-core/lib/libgcrypt/mpi/alpha/mpih-mul2.S
new file mode 100644
index 0000000..5eb6b98
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/alpha/mpih-mul2.S
@@ -0,0 +1,97 @@
+/* Alpha 21064 addmul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (r16)
+ * mpi_ptr_t s1_ptr, (r17)
+ * mpi_size_t s1_size, (r18)
+ * mpi_limb_t s2_limb) (r19)
+ *
+ * This code runs at 42 cycles/limb on EV4 and 18 cycles/limb on EV5.
+ */
+
+
+ .set noreorder
+ .set noat
+.text
+ .align 3
+ .globl _gcry_mpih_addmul_1
+ .ent _gcry_mpih_addmul_1 2
+_gcry_mpih_addmul_1:
+ .frame $30,0,$26
+
+ ldq $2,0($17) # $2 = s1_limb
+ addq $17,8,$17 # s1_ptr++
+ subq $18,1,$18 # size--
+ mulq $2,$19,$3 # $3 = prod_low
+ ldq $5,0($16) # $5 = *res_ptr
+ umulh $2,$19,$0 # $0 = prod_high
+ beq $18,.Lend1 # jump if size was == 1
+ ldq $2,0($17) # $2 = s1_limb
+ addq $17,8,$17 # s1_ptr++
+ subq $18,1,$18 # size--
+ addq $5,$3,$3
+ cmpult $3,$5,$4
+ stq $3,0($16)
+ addq $16,8,$16 # res_ptr++
+ beq $18,.Lend2 # jump if size was == 2
+
+ .align 3
+.Loop: mulq $2,$19,$3 # $3 = prod_low
+ ldq $5,0($16) # $5 = *res_ptr
+ addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
+ subq $18,1,$18 # size--
+ umulh $2,$19,$4 # $4 = cy_limb
+ ldq $2,0($17) # $2 = s1_limb
+ addq $17,8,$17 # s1_ptr++
+ addq $3,$0,$3 # $3 = cy_limb + prod_low
+ cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
+ addq $5,$3,$3
+ cmpult $3,$5,$5
+ stq $3,0($16)
+ addq $16,8,$16 # res_ptr++
+ addq $5,$0,$0 # combine carries
+ bne $18,.Loop
+
+.Lend2: mulq $2,$19,$3 # $3 = prod_low
+ ldq $5,0($16) # $5 = *res_ptr
+ addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
+ umulh $2,$19,$4 # $4 = cy_limb
+ addq $3,$0,$3 # $3 = cy_limb + prod_low
+ cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
+ addq $5,$3,$3
+ cmpult $3,$5,$5
+ stq $3,0($16)
+ addq $5,$0,$0 # combine carries
+ addq $4,$0,$0 # cy_limb = prod_high + cy
+ ret $31,($26),1
+.Lend1: addq $5,$3,$3
+ cmpult $3,$5,$5
+ stq $3,0($16)
+ addq $0,$5,$0
+ ret $31,($26),1
+
+ .end _gcry_mpih_addmul_1
+
diff --git a/grub-core/lib/libgcrypt/mpi/alpha/mpih-mul3.S b/grub-core/lib/libgcrypt/mpi/alpha/mpih-mul3.S
new file mode 100644
index 0000000..7d5d2af
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/alpha/mpih-mul3.S
@@ -0,0 +1,95 @@
+/* Alpha 21064 submul_1 -- Multiply a limb vector with a limb and
+ * subtract the result from a second limb vector.
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (r16 )
+ * mpi_ptr_t s1_ptr, (r17 )
+ * mpi_size_t s1_size, (r18 )
+ * mpi_limb_t s2_limb) (r19 )
+ *
+ * This code runs at 42 cycles/limb on EV4 and 18 cycles/limb on EV5.
+ */
+
+ .set noreorder
+ .set noat
+.text
+ .align 3
+ .globl _gcry_mpih_submul_1
+ .ent _gcry_mpih_submul_1 2
+_gcry_mpih_submul_1:
+ .frame $30,0,$26
+
+ ldq $2,0($17) # $2 = s1_limb
+ addq $17,8,$17 # s1_ptr++
+ subq $18,1,$18 # size--
+ mulq $2,$19,$3 # $3 = prod_low
+ ldq $5,0($16) # $5 = *res_ptr
+ umulh $2,$19,$0 # $0 = prod_high
+ beq $18,.Lend1 # jump if size was == 1
+ ldq $2,0($17) # $2 = s1_limb
+ addq $17,8,$17 # s1_ptr++
+ subq $18,1,$18 # size--
+ subq $5,$3,$3
+ cmpult $5,$3,$4
+ stq $3,0($16)
+ addq $16,8,$16 # res_ptr++
+ beq $18,.Lend2 # jump if size was == 2
+
+ .align 3
+.Loop: mulq $2,$19,$3 # $3 = prod_low
+ ldq $5,0($16) # $5 = *res_ptr
+ addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
+ subq $18,1,$18 # size--
+ umulh $2,$19,$4 # $4 = cy_limb
+ ldq $2,0($17) # $2 = s1_limb
+ addq $17,8,$17 # s1_ptr++
+ addq $3,$0,$3 # $3 = cy_limb + prod_low
+ cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
+ subq $5,$3,$3
+ cmpult $5,$3,$5
+ stq $3,0($16)
+ addq $16,8,$16 # res_ptr++
+ addq $5,$0,$0 # combine carries
+ bne $18,.Loop
+
+.Lend2: mulq $2,$19,$3 # $3 = prod_low
+ ldq $5,0($16) # $5 = *res_ptr
+ addq $4,$0,$0 # cy_limb = cy_limb + 'cy'
+ umulh $2,$19,$4 # $4 = cy_limb
+ addq $3,$0,$3 # $3 = cy_limb + prod_low
+ cmpult $3,$0,$0 # $0 = carry from (cy_limb + prod_low)
+ subq $5,$3,$3
+ cmpult $5,$3,$5
+ stq $3,0($16)
+ addq $5,$0,$0 # combine carries
+ addq $4,$0,$0 # cy_limb = prod_high + cy
+ ret $31,($26),1
+.Lend1: subq $5,$3,$3
+ cmpult $5,$3,$5
+ stq $3,0($16)
+ addq $0,$5,$0
+ ret $31,($26),1
+
+ .end _gcry_mpih_submul_1
+
diff --git a/grub-core/lib/libgcrypt/mpi/alpha/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/alpha/mpih-rshift.S
new file mode 100644
index 0000000..f0c9814
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/alpha/mpih-rshift.S
@@ -0,0 +1,118 @@
+/* alpha rshift
+ * Copyright (C) 1994, 1995, 1998, 1999,
+ * 2000, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp, (r16)
+ * mpi_ptr_t up, (r17)
+ * mpi_size_t usize, (r18)
+ * unsigned cnt) (r19)
+ *
+ * This code runs at 4.8 cycles/limb on the 21064. With infinite unrolling,
+ * it would take 4 cycles/limb. It should be possible to get down to 3
+ * cycles/limb since both ldq and stq can be paired with the other used
+ * instructions. But there are many restrictions in the 21064 pipeline that
+ * makes it hard, if not impossible, to get down to 3 cycles/limb:
+ *
+ * 1. ldq has a 3 cycle delay, srl and sll have a 2 cycle delay.
+ * 2. Only aligned instruction pairs can be paired.
+ * 3. The store buffer or silo might not be able to deal with the bandwidth.
+ */
+
+ .set noreorder
+ .set noat
+.text
+ .align 3
+ .globl _gcry_mpih_rshift
+ .ent _gcry_mpih_rshift
+_gcry_mpih_rshift:
+ .frame $30,0,$26,0
+
+ ldq $4,0($17) # load first limb
+ addq $17,8,$17
+ subq $31,$19,$7
+ subq $18,1,$18
+ and $18,4-1,$20 # number of limbs in first loop
+ sll $4,$7,$0 # compute function result
+
+ beq $20,.R0
+ subq $18,$20,$18
+
+ .align 3
+.Roop0:
+ ldq $3,0($17)
+ addq $16,8,$16
+ addq $17,8,$17
+ subq $20,1,$20
+ srl $4,$19,$5
+ sll $3,$7,$6
+ bis $3,$3,$4
+ bis $5,$6,$8
+ stq $8,-8($16)
+ bne $20,.Roop0
+
+.R0: beq $18,.Rend
+
+ .align 3
+.Roop: ldq $3,0($17)
+ addq $16,32,$16
+ subq $18,4,$18
+ srl $4,$19,$5
+ sll $3,$7,$6
+
+ ldq $4,8($17)
+ srl $3,$19,$1
+ bis $5,$6,$8
+ stq $8,-32($16)
+ sll $4,$7,$2
+
+ ldq $3,16($17)
+ srl $4,$19,$5
+ bis $1,$2,$8
+ stq $8,-24($16)
+ sll $3,$7,$6
+
+ ldq $4,24($17)
+ srl $3,$19,$1
+ bis $5,$6,$8
+ stq $8,-16($16)
+ sll $4,$7,$2
+
+ addq $17,32,$17
+ bis $1,$2,$8
+ stq $8,-8($16)
+
+ bgt $18,.Roop
+
+.Rend: srl $4,$19,$8
+ stq $8,0($16)
+ ret $31,($26),1
+ .end _gcry_mpih_rshift
+
diff --git a/grub-core/lib/libgcrypt/mpi/alpha/mpih-sub1.S b/grub-core/lib/libgcrypt/mpi/alpha/mpih-sub1.S
new file mode 100644
index 0000000..9a64446
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/alpha/mpih-sub1.S
@@ -0,0 +1,124 @@
+/* Alpha sub_n -- Subtract two limb vectors of the same length > 0 and
+ * store difference in a third limb vector.
+ * Copyright (C) 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (r16)
+ * mpi_ptr_t s1_ptr, (r17)
+ * mpi_ptr_t s2_ptr, (r18)
+ * mpi_size_t size) (r19)
+ */
+
+ .set noreorder
+ .set noat
+.text
+ .align 3
+ .globl _gcry_mpih_sub_n
+ .ent _gcry_mpih_sub_n
+_gcry_mpih_sub_n:
+ .frame $30,0,$26,0
+
+ ldq $3,0($17)
+ ldq $4,0($18)
+
+ subq $19,1,$19
+ and $19,4-1,$2 # number of limbs in first loop
+ bis $31,$31,$0
+ beq $2,.L0 # if multiple of 4 limbs, skip first loop
+
+ subq $19,$2,$19
+
+.Loop0: subq $2,1,$2
+ ldq $5,8($17)
+ addq $4,$0,$4
+ ldq $6,8($18)
+ cmpult $4,$0,$1
+ subq $3,$4,$4
+ cmpult $3,$4,$0
+ stq $4,0($16)
+ or $0,$1,$0
+
+ addq $17,8,$17
+ addq $18,8,$18
+ bis $5,$5,$3
+ bis $6,$6,$4
+ addq $16,8,$16
+ bne $2,.Loop0
+
+.L0: beq $19,.Lend
+
+ .align 3
+.Loop: subq $19,4,$19
+
+ ldq $5,8($17)
+ addq $4,$0,$4
+ ldq $6,8($18)
+ cmpult $4,$0,$1
+ subq $3,$4,$4
+ cmpult $3,$4,$0
+ stq $4,0($16)
+ or $0,$1,$0
+
+ ldq $3,16($17)
+ addq $6,$0,$6
+ ldq $4,16($18)
+ cmpult $6,$0,$1
+ subq $5,$6,$6
+ cmpult $5,$6,$0
+ stq $6,8($16)
+ or $0,$1,$0
+
+ ldq $5,24($17)
+ addq $4,$0,$4
+ ldq $6,24($18)
+ cmpult $4,$0,$1
+ subq $3,$4,$4
+ cmpult $3,$4,$0
+ stq $4,16($16)
+ or $0,$1,$0
+
+ ldq $3,32($17)
+ addq $6,$0,$6
+ ldq $4,32($18)
+ cmpult $6,$0,$1
+ subq $5,$6,$6
+ cmpult $5,$6,$0
+ stq $6,24($16)
+ or $0,$1,$0
+
+ addq $17,32,$17
+ addq $18,32,$18
+ addq $16,32,$16
+ bne $19,.Loop
+
+.Lend: addq $4,$0,$4
+ cmpult $4,$0,$1
+ subq $3,$4,$4
+ cmpult $3,$4,$0
+ stq $4,0($16)
+ or $0,$1,$0
+ ret $31,($26),1
+
+ .end _gcry_mpih_sub_n
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/alpha/udiv-qrnnd.S b/grub-core/lib/libgcrypt/mpi/alpha/udiv-qrnnd.S
new file mode 100644
index 0000000..dd0c52d
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/alpha/udiv-qrnnd.S
@@ -0,0 +1,159 @@
+/* Alpha 21064 __udiv_qrnnd
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+
+ .set noreorder
+ .set noat
+.text
+ .align 3
+ .globl __udiv_qrnnd
+ .ent __udiv_qrnnd
+__udiv_qrnnd:
+ .frame $30,0,$26,0
+ .prologue 0
+#define cnt $2
+#define tmp $3
+#define rem_ptr $16
+#define n1 $17
+#define n0 $18
+#define d $19
+#define qb $20
+
+ ldiq cnt,16
+ blt d,.Largedivisor
+
+.Loop1: cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ subq cnt,1,cnt
+ bgt cnt,.Loop1
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+.Largedivisor:
+ and n0,1,$4
+
+ srl n0,1,n0
+ sll n1,63,tmp
+ or tmp,n0,n0
+ srl n1,1,n1
+
+ and d,1,$6
+ srl d,1,$5
+ addq $5,$6,$5
+
+.Loop2: cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ subq cnt,1,cnt
+ bgt cnt,.Loop2
+
+ addq n1,n1,n1
+ addq $4,n1,n1
+ bne $6,.LOdd
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+.LOdd:
+ /* q' in n0. r' in n1 */
+ addq n1,n0,n1
+ cmpult n1,n0,tmp # tmp := carry from addq
+ beq tmp,.LLp6
+ addq n0,1,n0
+ subq n1,d,n1
+.LLp6: cmpult n1,d,tmp
+ bne tmp,.LLp7
+ addq n0,1,n0
+ subq n1,d,n1
+.LLp7:
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+ .end __udiv_qrnnd
diff --git a/grub-core/lib/libgcrypt/mpi/amd64/distfiles b/grub-core/lib/libgcrypt/mpi/amd64/distfiles
new file mode 100644
index 0000000..634e36f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/amd64/distfiles
@@ -0,0 +1,8 @@
+mpih-add1.S
+mpih-lshift.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-rshift.S
+mpih-sub1.S
+mpi-asm-defs.h
diff --git a/grub-core/lib/libgcrypt/mpi/amd64/mpi-asm-defs.h b/grub-core/lib/libgcrypt/mpi/amd64/mpi-asm-defs.h
new file mode 100644
index 0000000..17de1c1
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/amd64/mpi-asm-defs.h
@@ -0,0 +1,4 @@
+/* This file defines some basic constants for the MPI machinery. We
+ * need to define the types on a per-CPU basis, so it is done with
+ * this file here. */
+#define BYTES_PER_MPI_LIMB 8
diff --git a/grub-core/lib/libgcrypt/mpi/amd64/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/amd64/mpih-add1.S
new file mode 100644
index 0000000..f0ec89c
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/amd64/mpih-add1.S
@@ -0,0 +1,63 @@
+/* AMD64 (x86_64) add_n -- Add two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr, rdi
+ * mpi_ptr_t s1_ptr, rsi
+ * mpi_ptr_t s2_ptr, rdx
+ * mpi_size_t size) rcx
+ */
+
+.text
+ .globl C_SYMBOL_NAME(_gcry_mpih_add_n)
+C_SYMBOL_NAME(_gcry_mpih_add_n:)
+ leaq (%rsi,%rcx,8), %rsi
+ leaq (%rdi,%rcx,8), %rdi
+ leaq (%rdx,%rcx,8), %rdx
+ negq %rcx
+ xorl %eax, %eax /* clear cy */
+
+ ALIGN(4) /* minimal alignment for claimed speed */
+.Loop: movq (%rsi,%rcx,8), %rax
+ movq (%rdx,%rcx,8), %r10
+ adcq %r10, %rax
+ movq %rax, (%rdi,%rcx,8)
+ incq %rcx
+ jne .Loop
+
+ movq %rcx, %rax /* zero %rax */
+ adcq %rax, %rax
+ ret
+ \ No newline at end of file
diff --git a/grub-core/lib/libgcrypt/mpi/amd64/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/amd64/mpih-lshift.S
new file mode 100644
index 0000000..e87dd1a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/amd64/mpih-lshift.S
@@ -0,0 +1,77 @@
+/* AMD64 (x86_64) lshift -- Left shift a limb vector and store
+ * result in a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp, rdi
+ * mpi_ptr_t up, rsi
+ * mpi_size_t usize, rdx
+ * unsigned cnt) rcx
+ */
+
+.text
+ .globl C_SYMBOL_NAME(_gcry_mpih_lshift)
+C_SYMBOL_NAME(_gcry_mpih_lshift:)
+ movq -8(%rsi,%rdx,8), %mm7
+ movd %ecx, %mm1
+ movl $64, %eax
+ subl %ecx, %eax
+ movd %eax, %mm0
+ movq %mm7, %mm3
+ psrlq %mm0, %mm7
+ movd %mm7, %rax
+ subq $2, %rdx
+ jl .Lendo
+
+ ALIGN(4) /* minimal alignment for claimed speed */
+.Loop: movq (%rsi,%rdx,8), %mm6
+ movq %mm6, %mm2
+ psrlq %mm0, %mm6
+ psllq %mm1, %mm3
+ por %mm6, %mm3
+ movq %mm3, 8(%rdi,%rdx,8)
+ je .Lende
+ movq -8(%rsi,%rdx,8), %mm7
+ movq %mm7, %mm3
+ psrlq %mm0, %mm7
+ psllq %mm1, %mm2
+ por %mm7, %mm2
+ movq %mm2, (%rdi,%rdx,8)
+ subq $2, %rdx
+ jge .Loop
+
+.Lendo: movq %mm3, %mm2
+.Lende: psllq %mm1, %mm2
+ movq %mm2, (%rdi)
+ emms
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/amd64/mpih-mul1.S b/grub-core/lib/libgcrypt/mpi/amd64/mpih-mul1.S
new file mode 100644
index 0000000..54b0ab4
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/amd64/mpih-mul1.S
@@ -0,0 +1,65 @@
+/* AMD64 mul_1 -- Multiply a limb vector with a limb and store
+ * the result in a second limb vector.
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (rdi)
+ * mpi_ptr_t s1_ptr, (rsi)
+ * mpi_size_t s1_size, (rdx)
+ * mpi_limb_t s2_limb) (rcx)
+ */
+
+
+ TEXT
+ ALIGN(5)
+ .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1)
+C_SYMBOL_NAME(_gcry_mpih_mul_1:)
+
+ movq %rdx, %r11
+ leaq (%rsi,%rdx,8), %rsi
+ leaq (%rdi,%rdx,8), %rdi
+ negq %r11
+ xorl %r8d, %r8d
+
+.Loop: movq (%rsi,%r11,8), %rax
+ mulq %rcx
+ addq %r8, %rax
+ movl $0, %r8d
+ adcq %rdx, %r8
+ movq %rax, (%rdi,%r11,8)
+ incq %r11
+ jne .Loop
+
+ movq %r8, %rax
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/amd64/mpih-mul2.S b/grub-core/lib/libgcrypt/mpi/amd64/mpih-mul2.S
new file mode 100644
index 0000000..1180f76
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/amd64/mpih-mul2.S
@@ -0,0 +1,107 @@
+/* AMD64 addmul2 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_addmul_2( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ */
+
+ /* i80386 addmul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (rdi)
+ * mpi_ptr_t s1_ptr, (rsi)
+ * mpi_size_t s1_size, (rdx)
+ * mpi_limb_t s2_limb) (rcx)
+ */
+ TEXT
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1)
+C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
+ movq %rdx, %r11
+ leaq (%rsi,%rdx,8), %rsi
+ leaq (%rdi,%rdx,8), %rdi
+ negq %r11
+ xorl %r8d, %r8d
+ xorl %r10d, %r10d
+
+ ALIGN(3) /* minimal alignment for claimed speed */
+.Loop: movq (%rsi,%r11,8), %rax
+ mulq %rcx
+ addq (%rdi,%r11,8), %rax
+ adcq %r10, %rdx
+ addq %r8, %rax
+ movq %r10, %r8
+ movq %rax, (%rdi,%r11,8)
+ adcq %rdx, %r8
+ incq %r11
+ jne .Loop
+
+ movq %r8, %rax
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/amd64/mpih-mul3.S b/grub-core/lib/libgcrypt/mpi/amd64/mpih-mul3.S
new file mode 100644
index 0000000..4d458a7
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/amd64/mpih-mul3.S
@@ -0,0 +1,66 @@
+/* AMD64 submul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (rdi)
+ * mpi_ptr_t s1_ptr, (rsi)
+ * mpi_size_t s1_size, (rdx)
+ * mpi_limb_t s2_limb) (rcx)
+ */
+ TEXT
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1)
+C_SYMBOL_NAME(_gcry_mpih_submul_1:)
+
+ movq %rdx, %r11
+ leaq (%rsi,%r11,8), %rsi
+ leaq (%rdi,%r11,8), %rdi
+ negq %r11
+ xorl %r8d, %r8d
+
+ ALIGN(3) /* minimal alignment for claimed speed */
+.Loop: movq (%rsi,%r11,8), %rax
+ movq (%rdi,%r11,8), %r10
+ mulq %rcx
+ subq %r8, %r10
+ movl $0, %r8d
+ adcl %r8d, %r8d
+ subq %rax, %r10
+ adcq %rdx, %r8
+ movq %r10, (%rdi,%r11,8)
+ incq %r11
+ jne .Loop
+
+ movq %r8, %rax
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/amd64/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/amd64/mpih-rshift.S
new file mode 100644
index 0000000..4cfc8f6
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/amd64/mpih-rshift.S
@@ -0,0 +1,80 @@
+/* AMD64 (x86_64) rshift -- Right shift a limb vector and store
+ * result in a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp, rdi
+ * mpi_ptr_t up, rsi
+ * mpi_size_t usize, rdx
+ * unsigned cnt) rcx
+ */
+
+.text
+ .globl C_SYMBOL_NAME(_gcry_mpih_rshift)
+C_SYMBOL_NAME(_gcry_mpih_rshift:)
+ movq (%rsi), %mm7
+ movd %ecx, %mm1
+ movl $64, %eax
+ subl %ecx, %eax
+ movd %eax, %mm0
+ movq %mm7, %mm3
+ psllq %mm0, %mm7
+ movd %mm7, %rax
+ leaq (%rsi,%rdx,8), %rsi
+ leaq (%rdi,%rdx,8), %rdi
+ negq %rdx
+ addq $2, %rdx
+ jg .Lendo
+
+ ALIGN(8) /* minimal alignment for claimed speed */
+.Loop: movq -8(%rsi,%rdx,8), %mm6
+ movq %mm6, %mm2
+ psllq %mm0, %mm6
+ psrlq %mm1, %mm3
+ por %mm6, %mm3
+ movq %mm3, -16(%rdi,%rdx,8)
+ je .Lende
+ movq (%rsi,%rdx,8), %mm7
+ movq %mm7, %mm3
+ psllq %mm0, %mm7
+ psrlq %mm1, %mm2
+ por %mm7, %mm2
+ movq %mm2, -8(%rdi,%rdx,8)
+ addq $2, %rdx
+ jle .Loop
+
+.Lendo: movq %mm3, %mm2
+.Lende: psrlq %mm1, %mm2
+ movq %mm2, -8(%rdi)
+ emms
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/amd64/mpih-sub1.S b/grub-core/lib/libgcrypt/mpi/amd64/mpih-sub1.S
new file mode 100644
index 0000000..b3609b0
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/amd64/mpih-sub1.S
@@ -0,0 +1,61 @@
+/* AMD64 (x86_64) sub_n -- Subtract two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, rdi
+ * mpi_ptr_t s1_ptr, rsi
+ * mpi_ptr_t s2_ptr, rdx
+ * mpi_size_t size) rcx
+ */
+.text
+ .globl C_SYMBOL_NAME(_gcry_mpih_sub_n)
+C_SYMBOL_NAME(_gcry_mpih_sub_n:)
+ leaq (%rsi,%rcx,8), %rsi
+ leaq (%rdi,%rcx,8), %rdi
+ leaq (%rdx,%rcx,8), %rdx
+ negq %rcx
+ xorl %eax, %eax /* clear cy */
+
+ ALIGN(4) /* minimal alignment for claimed speed */
+.Loop: movq (%rsi,%rcx,8), %rax
+ movq (%rdx,%rcx,8), %r10
+ sbbq %r10, %rax
+ movq %rax, (%rdi,%rcx,8)
+ incq %rcx
+ jne .Loop
+
+ movq %rcx, %rax /* zero %rax */
+ adcq %rax, %rax
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/config.links b/grub-core/lib/libgcrypt/mpi/config.links
new file mode 100644
index 0000000..7e910ee
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/config.links
@@ -0,0 +1,360 @@
+# config.links - helper for ../configure -*- mode: sh -*-
+# Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+#
+# sourced by ../configure to get the list of files to link
+# this should set $mpi_ln_list.
+# Note: this is called from the above directory.
+
+mpi_sflags=
+mpi_extra_modules=
+
+test -d ./mpi || mkdir ./mpi
+
+# We grep the list of modules from the Makefile so that
+# we don't need to maintain them here.
+mpi_standard_modules=`$AWK '/^#BEGIN_ASM_LIST/,/^#END_ASM_LIST/ {
+ if( $3 != "O" ) print $2 }' $srcdir/mpi/Makefile.am`
+mpi_optional_modules=`$AWK '/^#BEGIN_ASM_LIST/,/^#END_ASM_LIST/ {
+ if( $3 == "O" ) print $2 }' $srcdir/mpi/Makefile.am`
+
+
+echo '/* created by config.links - do not edit */' >./mpi/asm-syntax.h
+echo "/* Host: ${host} */" >>./mpi/asm-syntax.h
+
+if test "$try_asm_modules" = "yes" ; then
+case "${host}" in
+ powerpc-apple-darwin* | \
+ i[34567]86*-*-openbsd[12]* | \
+ i[34567]86*-*-openbsd3.[0123]*)
+ echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
+ path=""
+ ;;
+ i[3467]86*-*-openbsd* | \
+ i[3467]86*-*-freebsd*-elf | \
+ i[3467]86*-*-freebsd[3-9]* | \
+ i[3467]86*-*-freebsdelf* | \
+ i[3467]86*-*-netbsd* | \
+ i[3467]86*-*-k*bsd*)
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ path="i386"
+ ;;
+ i586*-*-openbsd* | \
+ i586*-*-freebsd*-elf | \
+ i586*-*-freebsd[3-9]* | \
+ i586*-*-freebsdelf* | \
+ i586*-*-netbsd* | \
+ i586*-*-k*bsd* | \
+ pentium-*-netbsd* | \
+ pentiumpro-*-netbsd*)
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ path="i586 i386"
+ ;;
+ i[34]86*-*-bsdi4*)
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ path="i386"
+ ;;
+ i[3467]86*-*-linuxaout* | \
+ i[3467]86*-*-linuxoldld* | \
+ i[3467]86*-*-*bsd*)
+ echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
+ echo '#define X86_BROKEN_ALIGN' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ path="i386"
+ ;;
+ i586*-*-linuxaout* | \
+ i586*-*-linuxoldld* | \
+ i586*-*-*bsd*)
+ echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
+ echo '#define X86_BROKEN_ALIGN' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ path="i586 i386"
+ ;;
+ i[3467]86*-msdosdjgpp* | \
+ i[34]86*-apple-darwin*)
+ echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ path="i386"
+ ;;
+ i586*-msdosdjgpp* | \
+ i[567]86*-apple-darwin*)
+ echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ path="i586 i386"
+ ;;
+ i[3467]86*-*-*)
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ path="i386"
+ ;;
+ i586*-*-* | \
+ pentium-*-* | \
+ pentiumpro-*-*)
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ path="i586 i386"
+ ;;
+ x86_64-*-*)
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ path="amd64"
+ ;;
+ alpha*-*-*)
+ echo '/* configured for alpha */' >>./mpi/asm-syntax.h
+ path="alpha"
+ mpi_extra_modules="udiv-qrnnd"
+ ;;
+ hppa7000*-*-*)
+ echo '/* configured for HPPA (pa7000) */' >>./mpi/asm-syntax.h
+ path="hppa1.1 hppa"
+ mpi_extra_modules="udiv-qrnnd"
+ ;;
+ hppa1.0*-*-*)
+ echo '/* configured for HPPA 1.0 */' >>./mpi/asm-syntax.h
+ path="hppa"
+ mpi_extra_modules="udiv-qrnnd"
+ ;;
+ hppa*-*-*) # assume pa7100
+ echo '/* configured for HPPA (pa7100) */' >>./mpi/asm-syntax.h
+ path="pa7100 hppa1.1 hppa"
+ mpi_extra_modules="udiv-qrnnd"
+ ;;
+ sparc64-*-linux-gnu)
+ echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
+ path=""
+ ;;
+ sparc64-sun-solaris2*)
+ echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
+ path=""
+ ;;
+ sparc64-*-netbsd* | sparc64-*-freebsd* | sparc64-*-openbsd*)
+ # There are no sparc64 assembler modules that work on the
+ # *BSDs, so use the generic C functions.
+ echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
+ path=""
+ ;;
+ sparc64*-*-*)
+ echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
+ path=""
+ ;;
+ sparc9*-*-* | \
+ ultrasparc*-*-* )
+ echo '/* configured for sparc9 or higher */' >>./mpi/asm-syntax.h
+ path="sparc32v8 sparc32"
+ ;;
+ sparc8*-*-* | \
+ microsparc*-*-*)
+ echo '/* configured for sparc8 */' >>./mpi/asm-syntax.h
+ path="sparc32v8 sparc32"
+ ;;
+ supersparc*-*-*)
+ echo '/* configured for supersparc */' >>./mpi/asm-syntax.h
+ path="supersparc sparc32v8 sparc32"
+ mpi_extra_modules="udiv"
+ ;;
+ sparc*-*-*)
+ echo '/* configured for sparc */' >>./mpi/asm-syntax.h
+ path="sparc32"
+ mpi_extra_modules="udiv"
+ ;;
+ mips[34]*-*-* | \
+ mips*-*-irix6*)
+ echo '/* configured for MIPS3 */' >>./mpi/asm-syntax.h
+ path="mips3"
+ ;;
+ mips*-*-*)
+ echo '/* configured for MIPS2 */' >>./mpi/asm-syntax.h
+ path="mips2"
+ ;;
+
+ # Motorola 68k configurations. Let m68k mean 68020-68040.
+ # mc68000 or mc68060 configurations need to be specified explicitly
+ m680[234]0*-*-linuxaout* | \
+ m68k*-*-linuxaout*)
+ echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
+ path="m68k/mc68020 m68k"
+ ;;
+ m68060*-*-linuxaout*)
+ echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
+ path="m68k"
+ ;;
+ m680[234]0*-*-linux* | \
+ m68k*-*-linux*)
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
+ ;;
+ m68060*-*-linux*)
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
+ path="m68k"
+ ;;
+ m68k-atari-mint)
+ echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
+ path="m68k/mc68020 m68k"
+ ;;
+ m68000*-*-* | \
+ m68060*-*-*)
+ echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
+ path="m68k/mc68000"
+ ;;
+ m680[234]0*-*-* | \
+ m68k*-*-*)
+ echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
+ path="m68k/mc68020 m68k"
+ ;;
+
+ powerpc*-*-netbsd* | powerpc*-*-openbsd*)
+ echo '/* configured {Open,Net}BSD on powerpc */' >>./mpi/asm-syntax.h
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/powerpc32/syntax.h >>./mpi/asm-syntax.h
+ mpi_sflags="-Wa,-mppc"
+ path="powerpc32"
+ ;;
+
+ ppc620-*-* | \
+ powerpc64*-*-*)
+ mpi_sflags="-Wa,-mppc"
+ path="powerpc64"
+ ;;
+ powerpc*-*-linux*)
+ echo '/* configured for powerpc/ELF */' >>./mpi/asm-syntax.h
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/powerpc32/syntax.h >>./mpi/asm-syntax.h
+ path="powerpc32"
+ ;;
+
+ rs6000-*-aix[456789]* | \
+ rs6000-*-aix3.2.[456789])
+ mpi_sflags="-Wa,-mpwr"
+ path="power"
+ mpi_extra_modules="udiv-w-sdiv"
+ ;;
+ rs6000-*-* | \
+ power-*-* | \
+ power2-*-*)
+ mpi_sflags="-Wa,-mppc"
+ path="power"
+ mpi_extra_modules="udiv-w-sdiv"
+ ;;
+ powerpc-ibm-aix4.2.* )
+ # I am not sure about this one but a machine identified by
+ # powerpc-ibm-aix4.2.1.0 cannot use the powerpc32 code.
+ mpi_sflags="-Wa,-mpwr"
+ path="power"
+ mpi_extra_modules="udiv-w-sdiv"
+ ;;
+ ppc601-*-*)
+ mpi_sflags="-Wa,-mppc"
+ path="power powerpc32"
+ ;;
+ ppc60[234]*-*-*)
+ mpi_sflags="-Wa,-mppc"
+ path="powerpc32"
+ ;;
+ powerpc*-*-*)
+ mpi_sflags="-Wa,-mppc"
+ path="powerpc32"
+ ;;
+ *)
+ echo '/* No assembler modules configured */' >>./mpi/asm-syntax.h
+ path=""
+ ;;
+esac
+else
+ echo '/* Assembler modules disabled on request */' >>./mpi/asm-syntax.h
+ path=""
+fi
+
+
+# Make sysdep.h
+echo '/* created by config.links - do not edit */' >./mpi/sysdep.h
+if test x$ac_cv_sys_symbol_underscore = xyes; then
+ cat <<EOF >>./mpi/sysdep.h
+#if __STDC__
+#define C_SYMBOL_NAME(name) _##name
+#else
+#define C_SYMBOL_NAME(name) _/**/name
+#endif
+EOF
+else
+ cat <<EOF >>./mpi/sysdep.h
+#define C_SYMBOL_NAME(name) name
+EOF
+fi
+
+
+# Figure the required modules out
+mpi_required_modules=$mpi_standard_modules
+if test "$mpi_extra_modules" != ""; then
+ for fn in $mpi_extra_modules; do
+ for i in $mpi_optional_modules; do
+ if test "$fn" = "$i" ; then
+ mpi_required_modules="$mpi_required_modules $fn"
+ fi
+ done
+ done
+fi
+
+# Try to get file to link from the assembler subdirectory and
+# if this fails get it from the generic subdirectory.
+mpi_ln_list=
+mpi_mod_list=
+path=`echo "$mpi_extra_path $path generic" | tr ':' ' '`
+echo '/* Created by config.links - do not edit */' >./mpi/mod-source-info.h
+echo "/* Host: ${host} */" >>./mpi/mod-source-info.h
+echo "static char mod_source_info[] =" >>./mpi/mod-source-info.h
+for fn in $mpi_required_modules ; do
+ fnu=`echo $fn | sed 's/-/_/g'`
+ eval mpi_mod_c_${fnu}=no
+ eval mpi_mod_asm_${fnu}=no
+ for dir in $path ; do
+ rm -f $srcdir/mpi/$fn.[Sc]
+ if test -f $srcdir/mpi/$dir/$fn.S ; then
+ echo " \":$dir/$fn.S\"" >>./mpi/mod-source-info.h
+ mpi_ln_list="$mpi_ln_list mpi/$fn-asm.S:mpi/$dir/$fn.S"
+ eval mpi_mod_asm_${fnu}=yes
+ mpi_mod_list="$mpi_mod_list $fn"
+ break;
+ elif test -f $srcdir/mpi/$dir/$fn.c ; then
+ echo " \":$dir/$fn.c\"" >>./mpi/mod-source-info.h
+ mpi_ln_list="$mpi_ln_list mpi/$fn.c:mpi/$dir/$fn.c"
+ eval mpi_mod_c_${fnu}=yes
+ mpi_mod_list="$mpi_mod_list $fn"
+ break;
+ fi
+ done
+done
+echo " ;" >>./mpi/mod-source-info.h
+
+# Same thing for the file which defines the limb size
+path=`echo "$path generic" | tr ':' ' '`
+for dir in $path ; do
+ rm -f $srcdir/mpi/mpi-asm-defs.h
+ if test -f $srcdir/mpi/$dir/mpi-asm-defs.h ; then
+ mpi_ln_list="$mpi_ln_list mpi/mpi-asm-defs.h:mpi/$dir/mpi-asm-defs.h"
+ break;
+ fi
+done
diff --git a/grub-core/lib/libgcrypt/mpi/ec.c b/grub-core/lib/libgcrypt/mpi/ec.c
new file mode 100644
index 0000000..fa00818
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/ec.c
@@ -0,0 +1,721 @@
+/* ec.c - Elliptic Curve functions
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+ This file is part of Libgcrypt.
+
+ Libgcrypt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Libgcrypt is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mpi-internal.h"
+#include "longlong.h"
+#include "g10lib.h"
+
+
+#define point_init(a) _gcry_mpi_ec_point_init ((a))
+#define point_free(a) _gcry_mpi_ec_point_free ((a))
+
+
+/* Object to represent a point in projective coordinates. */
+/* Currently defined in mpi.h */
+
+/* This context is used with all our EC functions. */
+struct mpi_ec_ctx_s
+{
+ /* Domain parameters. */
+ gcry_mpi_t p; /* Prime specifying the field GF(p). */
+ gcry_mpi_t a; /* First coefficient of the Weierstrass equation. */
+
+ int a_is_pminus3; /* True if A = P - 3. */
+
+ /* Some often used constants. */
+ gcry_mpi_t one;
+ gcry_mpi_t two;
+ gcry_mpi_t three;
+ gcry_mpi_t four;
+ gcry_mpi_t eight;
+ gcry_mpi_t two_inv_p;
+
+ /* Scratch variables. */
+ gcry_mpi_t scratch[11];
+
+ /* Helper for fast reduction. */
+/* int nist_nbits; /\* If this is a NIST curve, the number of bits. *\/ */
+/* gcry_mpi_t s[10]; */
+/* gcry_mpi_t c; */
+
+};
+
+
+
+/* Initialized a point object. gcry_mpi_ec_point_free shall be used
+ to release this object. */
+void
+_gcry_mpi_ec_point_init (mpi_point_t *p)
+{
+ p->x = mpi_new (0);
+ p->y = mpi_new (0);
+ p->z = mpi_new (0);
+}
+
+
+/* Release a point object. */
+void
+_gcry_mpi_ec_point_free (mpi_point_t *p)
+{
+ mpi_free (p->x); p->x = NULL;
+ mpi_free (p->y); p->y = NULL;
+ mpi_free (p->z); p->z = NULL;
+}
+
+/* Set the value from S into D. */
+static void
+point_set (mpi_point_t *d, mpi_point_t *s)
+{
+ mpi_set (d->x, s->x);
+ mpi_set (d->y, s->y);
+ mpi_set (d->z, s->z);
+}
+
+
+
+static void
+ec_addm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, mpi_ec_t ctx)
+{
+ mpi_addm (w, u, v, ctx->p);
+}
+
+static void
+ec_subm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, mpi_ec_t ctx)
+{
+ mpi_subm (w, u, v, ctx->p);
+}
+
+static void
+ec_mulm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, mpi_ec_t ctx)
+{
+#if 0
+ /* NOTE: This code works only for limb sizes of 32 bit. */
+ mpi_limb_t *wp, *sp;
+
+ if (ctx->nist_nbits == 192)
+ {
+ mpi_mul (w, u, v);
+ mpi_resize (w, 12);
+ wp = w->d;
+
+ sp = ctx->s[0]->d;
+ sp[0*2+0] = wp[0*2+0];
+ sp[0*2+1] = wp[0*2+1];
+ sp[1*2+0] = wp[1*2+0];
+ sp[1*2+1] = wp[1*2+1];
+ sp[2*2+0] = wp[2*2+0];
+ sp[2*2+1] = wp[2*2+1];
+
+ sp = ctx->s[1]->d;
+ sp[0*2+0] = wp[3*2+0];
+ sp[0*2+1] = wp[3*2+1];
+ sp[1*2+0] = wp[3*2+0];
+ sp[1*2+1] = wp[3*2+1];
+ sp[2*2+0] = 0;
+ sp[2*2+1] = 0;
+
+ sp = ctx->s[2]->d;
+ sp[0*2+0] = 0;
+ sp[0*2+1] = 0;
+ sp[1*2+0] = wp[4*2+0];
+ sp[1*2+1] = wp[4*2+1];
+ sp[2*2+0] = wp[4*2+0];
+ sp[2*2+1] = wp[4*2+1];
+
+ sp = ctx->s[3]->d;
+ sp[0*2+0] = wp[5*2+0];
+ sp[0*2+1] = wp[5*2+1];
+ sp[1*2+0] = wp[5*2+0];
+ sp[1*2+1] = wp[5*2+1];
+ sp[2*2+0] = wp[5*2+0];
+ sp[2*2+1] = wp[5*2+1];
+
+ ctx->s[0]->nlimbs = 6;
+ ctx->s[1]->nlimbs = 6;
+ ctx->s[2]->nlimbs = 6;
+ ctx->s[3]->nlimbs = 6;
+
+ mpi_add (ctx->c, ctx->s[0], ctx->s[1]);
+ mpi_add (ctx->c, ctx->c, ctx->s[2]);
+ mpi_add (ctx->c, ctx->c, ctx->s[3]);
+
+ while ( mpi_cmp (ctx->c, ctx->p ) >= 0 )
+ mpi_sub ( ctx->c, ctx->c, ctx->p );
+ mpi_set (w, ctx->c);
+ }
+ else if (ctx->nist_nbits == 384)
+ {
+ int i;
+ mpi_mul (w, u, v);
+ mpi_resize (w, 24);
+ wp = w->d;
+
+#define NEXT(a) do { ctx->s[(a)]->nlimbs = 12; \
+ sp = ctx->s[(a)]->d; \
+ i = 0; } while (0)
+#define X(a) do { sp[i++] = wp[(a)];} while (0)
+#define X0(a) do { sp[i++] = 0; } while (0)
+ NEXT(0);
+ X(0);X(1);X(2);X(3);X(4);X(5);X(6);X(7);X(8);X(9);X(10);X(11);
+ NEXT(1);
+ X0();X0();X0();X0();X(21);X(22);X(23);X0();X0();X0();X0();X0();
+ NEXT(2);
+ X(12);X(13);X(14);X(15);X(16);X(17);X(18);X(19);X(20);X(21);X(22);X(23);
+ NEXT(3);
+ X(21);X(22);X(23);X(12);X(13);X(14);X(15);X(16);X(17);X(18);X(19);X(20);
+ NEXT(4);
+ X0();X(23);X0();X(20);X(12);X(13);X(14);X(15);X(16);X(17);X(18);X(19);
+ NEXT(5);
+ X0();X0();X0();X0();X(20);X(21);X(22);X(23);X0();X0();X0();X0();
+ NEXT(6);
+ X(20);X0();X0();X(21);X(22);X(23);X0();X0();X0();X0();X0();X0();
+ NEXT(7);
+ X(23);X(12);X(13);X(14);X(15);X(16);X(17);X(18);X(19);X(20);X(21);X(22);
+ NEXT(8);
+ X0();X(20);X(21);X(22);X(23);X0();X0();X0();X0();X0();X0();X0();
+ NEXT(9);
+ X0();X0();X0();X(23);X(23);X0();X0();X0();X0();X0();X0();X0();
+#undef X0
+#undef X
+#undef NEXT
+ mpi_add (ctx->c, ctx->s[0], ctx->s[1]);
+ mpi_add (ctx->c, ctx->c, ctx->s[1]);
+ mpi_add (ctx->c, ctx->c, ctx->s[2]);
+ mpi_add (ctx->c, ctx->c, ctx->s[3]);
+ mpi_add (ctx->c, ctx->c, ctx->s[4]);
+ mpi_add (ctx->c, ctx->c, ctx->s[5]);
+ mpi_add (ctx->c, ctx->c, ctx->s[6]);
+ mpi_sub (ctx->c, ctx->c, ctx->s[7]);
+ mpi_sub (ctx->c, ctx->c, ctx->s[8]);
+ mpi_sub (ctx->c, ctx->c, ctx->s[9]);
+
+ while ( mpi_cmp (ctx->c, ctx->p ) >= 0 )
+ mpi_sub ( ctx->c, ctx->c, ctx->p );
+ while ( ctx->c->sign )
+ mpi_add ( ctx->c, ctx->c, ctx->p );
+ mpi_set (w, ctx->c);
+ }
+ else
+#endif /*0*/
+ mpi_mulm (w, u, v, ctx->p);
+}
+
+static void
+ec_powm (gcry_mpi_t w, const gcry_mpi_t b, const gcry_mpi_t e,
+ mpi_ec_t ctx)
+{
+ mpi_powm (w, b, e, ctx->p);
+}
+
+static void
+ec_invm (gcry_mpi_t x, gcry_mpi_t a, mpi_ec_t ctx)
+{
+ mpi_invm (x, a, ctx->p);
+}
+
+
+
+/* This function returns a new context for elliptic curve based on the
+ field GF(p). P is the prime specifying thuis field, A is the first
+ coefficient.
+
+ This context needs to be released using _gcry_mpi_ec_free. */
+mpi_ec_t
+_gcry_mpi_ec_init (gcry_mpi_t p, gcry_mpi_t a)
+{
+ int i;
+ mpi_ec_t ctx;
+ gcry_mpi_t tmp;
+
+ mpi_normalize (p);
+ mpi_normalize (a);
+
+ /* Fixme: Do we want to check some constraints? e.g.
+ a < p
+ */
+
+ ctx = gcry_xcalloc (1, sizeof *ctx);
+
+ ctx->p = mpi_copy (p);
+ ctx->a = mpi_copy (a);
+
+ tmp = mpi_alloc_like (ctx->p);
+ mpi_sub_ui (tmp, ctx->p, 3);
+ ctx->a_is_pminus3 = !mpi_cmp (ctx->a, tmp);
+ mpi_free (tmp);
+
+
+ /* Allocate constants. */
+ ctx->one = mpi_alloc_set_ui (1);
+ ctx->two = mpi_alloc_set_ui (2);
+ ctx->three = mpi_alloc_set_ui (3);
+ ctx->four = mpi_alloc_set_ui (4);
+ ctx->eight = mpi_alloc_set_ui (8);
+ ctx->two_inv_p = mpi_alloc (0);
+ ec_invm (ctx->two_inv_p, ctx->two, ctx);
+
+ /* Allocate scratch variables. */
+ for (i=0; i< DIM(ctx->scratch); i++)
+ ctx->scratch[i] = mpi_alloc_like (ctx->p);
+
+ /* Prepare for fast reduction. */
+ /* FIXME: need a test for NIST values. However it does not gain us
+ any real advantage, for 384 bits it is actually slower than using
+ mpi_mulm. */
+/* ctx->nist_nbits = mpi_get_nbits (ctx->p); */
+/* if (ctx->nist_nbits == 192) */
+/* { */
+/* for (i=0; i < 4; i++) */
+/* ctx->s[i] = mpi_new (192); */
+/* ctx->c = mpi_new (192*2); */
+/* } */
+/* else if (ctx->nist_nbits == 384) */
+/* { */
+/* for (i=0; i < 10; i++) */
+/* ctx->s[i] = mpi_new (384); */
+/* ctx->c = mpi_new (384*2); */
+/* } */
+
+ return ctx;
+}
+
+void
+_gcry_mpi_ec_free (mpi_ec_t ctx)
+{
+ int i;
+
+ if (!ctx)
+ return;
+
+ mpi_free (ctx->p);
+ mpi_free (ctx->a);
+
+ mpi_free (ctx->one);
+ mpi_free (ctx->two);
+ mpi_free (ctx->three);
+ mpi_free (ctx->four);
+ mpi_free (ctx->eight);
+
+ mpi_free (ctx->two_inv_p);
+
+ for (i=0; i< DIM(ctx->scratch); i++)
+ mpi_free (ctx->scratch[i]);
+
+/* if (ctx->nist_nbits == 192) */
+/* { */
+/* for (i=0; i < 4; i++) */
+/* mpi_free (ctx->s[i]); */
+/* mpi_free (ctx->c); */
+/* } */
+/* else if (ctx->nist_nbits == 384) */
+/* { */
+/* for (i=0; i < 10; i++) */
+/* mpi_free (ctx->s[i]); */
+/* mpi_free (ctx->c); */
+/* } */
+
+ gcry_free (ctx);
+}
+
+/* Compute the affine coordinates from the projective coordinates in
+ POINT. Set them into X and Y. If one coordinate is not required,
+ X or Y may be passed as NULL. CTX is the usual context. Returns: 0
+ on success or !0 if POINT is at infinity. */
+int
+_gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, mpi_point_t *point,
+ mpi_ec_t ctx)
+{
+ gcry_mpi_t z1, z2, z3;
+
+ if (!mpi_cmp_ui (point->z, 0))
+ return -1;
+
+ z1 = mpi_new (0);
+ z2 = mpi_new (0);
+ ec_invm (z1, point->z, ctx); /* z1 = z^(-1) mod p */
+ ec_mulm (z2, z1, z1, ctx); /* z2 = z^(-2) mod p */
+
+ if (x)
+ ec_mulm (x, point->x, z2, ctx);
+
+ if (y)
+ {
+ z3 = mpi_new (0);
+ ec_mulm (z3, z2, z1, ctx); /* z3 = z^(-3) mod p */
+ ec_mulm (y, point->y, z3, ctx);
+ mpi_free (z3);
+ }
+
+ mpi_free (z2);
+ mpi_free (z1);
+ return 0;
+}
+
+
+
+
+
+/* RESULT = 2 * POINT */
+void
+_gcry_mpi_ec_dup_point (mpi_point_t *result, mpi_point_t *point, mpi_ec_t ctx)
+{
+#define x3 (result->x)
+#define y3 (result->y)
+#define z3 (result->z)
+#define t1 (ctx->scratch[0])
+#define t2 (ctx->scratch[1])
+#define t3 (ctx->scratch[2])
+#define l1 (ctx->scratch[3])
+#define l2 (ctx->scratch[4])
+#define l3 (ctx->scratch[5])
+
+ if (!mpi_cmp_ui (point->y, 0) || !mpi_cmp_ui (point->z, 0))
+ {
+ /* P_y == 0 || P_z == 0 => [1:1:0] */
+ mpi_set_ui (x3, 1);
+ mpi_set_ui (y3, 1);
+ mpi_set_ui (z3, 0);
+ }
+ else
+ {
+ if (ctx->a_is_pminus3) /* Use the faster case. */
+ {
+ /* L1 = 3(X - Z^2)(X + Z^2) */
+ /* T1: used for Z^2. */
+ /* T2: used for the right term. */
+ ec_powm (t1, point->z, ctx->two, ctx);
+ ec_subm (l1, point->x, t1, ctx);
+ ec_mulm (l1, l1, ctx->three, ctx);
+ ec_addm (t2, point->x, t1, ctx);
+ ec_mulm (l1, l1, t2, ctx);
+ }
+ else /* Standard case. */
+ {
+ /* L1 = 3X^2 + aZ^4 */
+ /* T1: used for aZ^4. */
+ ec_powm (l1, point->x, ctx->two, ctx);
+ ec_mulm (l1, l1, ctx->three, ctx);
+ ec_powm (t1, point->z, ctx->four, ctx);
+ ec_mulm (t1, t1, ctx->a, ctx);
+ ec_addm (l1, l1, t1, ctx);
+ }
+ /* Z3 = 2YZ */
+ ec_mulm (z3, point->y, point->z, ctx);
+ ec_mulm (z3, z3, ctx->two, ctx);
+
+ /* L2 = 4XY^2 */
+ /* T2: used for Y2; required later. */
+ ec_powm (t2, point->y, ctx->two, ctx);
+ ec_mulm (l2, t2, point->x, ctx);
+ ec_mulm (l2, l2, ctx->four, ctx);
+
+ /* X3 = L1^2 - 2L2 */
+ /* T1: used for L2^2. */
+ ec_powm (x3, l1, ctx->two, ctx);
+ ec_mulm (t1, l2, ctx->two, ctx);
+ ec_subm (x3, x3, t1, ctx);
+
+ /* L3 = 8Y^4 */
+ /* T2: taken from above. */
+ ec_powm (t2, t2, ctx->two, ctx);
+ ec_mulm (l3, t2, ctx->eight, ctx);
+
+ /* Y3 = L1(L2 - X3) - L3 */
+ ec_subm (y3, l2, x3, ctx);
+ ec_mulm (y3, y3, l1, ctx);
+ ec_subm (y3, y3, l3, ctx);
+ }
+
+#undef x3
+#undef y3
+#undef z3
+#undef t1
+#undef t2
+#undef t3
+#undef l1
+#undef l2
+#undef l3
+}
+
+
+
+/* RESULT = P1 + P2 */
+void
+_gcry_mpi_ec_add_points (mpi_point_t *result,
+ mpi_point_t *p1, mpi_point_t *p2,
+ mpi_ec_t ctx)
+{
+#define x1 (p1->x )
+#define y1 (p1->y )
+#define z1 (p1->z )
+#define x2 (p2->x )
+#define y2 (p2->y )
+#define z2 (p2->z )
+#define x3 (result->x)
+#define y3 (result->y)
+#define z3 (result->z)
+#define l1 (ctx->scratch[0])
+#define l2 (ctx->scratch[1])
+#define l3 (ctx->scratch[2])
+#define l4 (ctx->scratch[3])
+#define l5 (ctx->scratch[4])
+#define l6 (ctx->scratch[5])
+#define l7 (ctx->scratch[6])
+#define l8 (ctx->scratch[7])
+#define l9 (ctx->scratch[8])
+#define t1 (ctx->scratch[9])
+#define t2 (ctx->scratch[10])
+
+ if ( (!mpi_cmp (x1, x2)) && (!mpi_cmp (y1, y2)) && (!mpi_cmp (z1, z2)) )
+ {
+ /* Same point; need to call the duplicate function. */
+ _gcry_mpi_ec_dup_point (result, p1, ctx);
+ }
+ else if (!mpi_cmp_ui (z1, 0))
+ {
+ /* P1 is at infinity. */
+ mpi_set (x3, p2->x);
+ mpi_set (y3, p2->y);
+ mpi_set (z3, p2->z);
+ }
+ else if (!mpi_cmp_ui (z2, 0))
+ {
+ /* P2 is at infinity. */
+ mpi_set (x3, p1->x);
+ mpi_set (y3, p1->y);
+ mpi_set (z3, p1->z);
+ }
+ else
+ {
+ int z1_is_one = !mpi_cmp_ui (z1, 1);
+ int z2_is_one = !mpi_cmp_ui (z2, 1);
+
+ /* l1 = x1 z2^2 */
+ /* l2 = x2 z1^2 */
+ if (z2_is_one)
+ mpi_set (l1, x1);
+ else
+ {
+ ec_powm (l1, z2, ctx->two, ctx);
+ ec_mulm (l1, l1, x1, ctx);
+ }
+ if (z1_is_one)
+ mpi_set (l2, x2);
+ else
+ {
+ ec_powm (l2, z1, ctx->two, ctx);
+ ec_mulm (l2, l2, x2, ctx);
+ }
+ /* l3 = l1 - l2 */
+ ec_subm (l3, l1, l2, ctx);
+ /* l4 = y1 z2^3 */
+ ec_powm (l4, z2, ctx->three, ctx);
+ ec_mulm (l4, l4, y1, ctx);
+ /* l5 = y2 z1^3 */
+ ec_powm (l5, z1, ctx->three, ctx);
+ ec_mulm (l5, l5, y2, ctx);
+ /* l6 = l4 - l5 */
+ ec_subm (l6, l4, l5, ctx);
+
+ if (!mpi_cmp_ui (l3, 0))
+ {
+ if (!mpi_cmp_ui (l6, 0))
+ {
+ /* P1 and P2 are the same - use duplicate function. */
+ _gcry_mpi_ec_dup_point (result, p1, ctx);
+ }
+ else
+ {
+ /* P1 is the inverse of P2. */
+ mpi_set_ui (x3, 1);
+ mpi_set_ui (y3, 1);
+ mpi_set_ui (z3, 0);
+ }
+ }
+ else
+ {
+ /* l7 = l1 + l2 */
+ ec_addm (l7, l1, l2, ctx);
+ /* l8 = l4 + l5 */
+ ec_addm (l8, l4, l5, ctx);
+ /* z3 = z1 z2 l3 */
+ ec_mulm (z3, z1, z2, ctx);
+ ec_mulm (z3, z3, l3, ctx);
+ /* x3 = l6^2 - l7 l3^2 */
+ ec_powm (t1, l6, ctx->two, ctx);
+ ec_powm (t2, l3, ctx->two, ctx);
+ ec_mulm (t2, t2, l7, ctx);
+ ec_subm (x3, t1, t2, ctx);
+ /* l9 = l7 l3^2 - 2 x3 */
+ ec_mulm (t1, x3, ctx->two, ctx);
+ ec_subm (l9, t2, t1, ctx);
+ /* y3 = (l9 l6 - l8 l3^3)/2 */
+ ec_mulm (l9, l9, l6, ctx);
+ ec_powm (t1, l3, ctx->three, ctx); /* fixme: Use saved value*/
+ ec_mulm (t1, t1, l8, ctx);
+ ec_subm (y3, l9, t1, ctx);
+ ec_mulm (y3, y3, ctx->two_inv_p, ctx);
+ }
+ }
+
+#undef x1
+#undef y1
+#undef z1
+#undef x2
+#undef y2
+#undef z2
+#undef x3
+#undef y3
+#undef z3
+#undef l1
+#undef l2
+#undef l3
+#undef l4
+#undef l5
+#undef l6
+#undef l7
+#undef l8
+#undef l9
+#undef t1
+#undef t2
+}
+
+
+
+/* Scalar point multiplication - the main function for ECC. If takes
+ an integer SCALAR and a POINT as well as the usual context CTX.
+ RESULT will be set to the resulting point. */
+void
+_gcry_mpi_ec_mul_point (mpi_point_t *result,
+ gcry_mpi_t scalar, mpi_point_t *point,
+ mpi_ec_t ctx)
+{
+#if 0
+ /* Simple left to right binary method. GECC Algorithm 3.27 */
+ unsigned int nbits;
+ int i;
+
+ nbits = mpi_get_nbits (scalar);
+ mpi_set_ui (result->x, 1);
+ mpi_set_ui (result->y, 1);
+ mpi_set_ui (result->z, 0);
+
+ for (i=nbits-1; i >= 0; i--)
+ {
+ _gcry_mpi_ec_dup_point (result, result, ctx);
+ if (mpi_test_bit (scalar, i) == 1)
+ _gcry_mpi_ec_add_points (result, result, point, ctx);
+ }
+
+#else
+ gcry_mpi_t x1, y1, z1, k, h, yy;
+ unsigned int i, loops;
+ mpi_point_t p1, p2, p1inv;
+
+ x1 = mpi_alloc_like (ctx->p);
+ y1 = mpi_alloc_like (ctx->p);
+ h = mpi_alloc_like (ctx->p);
+ k = mpi_copy (scalar);
+ yy = mpi_copy (point->y);
+
+ if ( mpi_is_neg (k) )
+ {
+ k->sign = 0;
+ ec_invm (yy, yy, ctx);
+ }
+
+ if (!mpi_cmp_ui (point->z, 1))
+ {
+ mpi_set (x1, point->x);
+ mpi_set (y1, yy);
+ }
+ else
+ {
+ gcry_mpi_t z2, z3;
+
+ z2 = mpi_alloc_like (ctx->p);
+ z3 = mpi_alloc_like (ctx->p);
+ ec_mulm (z2, point->z, point->z, ctx);
+ ec_mulm (z3, point->z, z2, ctx);
+ ec_invm (z2, z2, ctx);
+ ec_mulm (x1, point->x, z2, ctx);
+ ec_invm (z3, z3, ctx);
+ ec_mulm (y1, yy, z3, ctx);
+ mpi_free (z2);
+ mpi_free (z3);
+ }
+ z1 = mpi_copy (ctx->one);
+
+ mpi_mul (h, k, ctx->three); /* h = 3k */
+ loops = mpi_get_nbits (h);
+ if (loops < 2)
+ {
+ /* If SCALAR is zero, the above mpi_mul sets H to zero and thus
+ LOOPs will be zero. To avoid an underflow of I in the main
+ loop we set LOOP to 2 and the result to (0,0,0). */
+ loops = 2;
+ mpi_clear (result->x);
+ mpi_clear (result->y);
+ mpi_clear (result->z);
+ }
+ else
+ {
+ mpi_set (result->x, point->x);
+ mpi_set (result->y, yy);
+ mpi_set (result->z, point->z);
+ }
+ mpi_free (yy); yy = NULL;
+
+ p1.x = x1; x1 = NULL;
+ p1.y = y1; y1 = NULL;
+ p1.z = z1; z1 = NULL;
+ point_init (&p2);
+ point_init (&p1inv);
+
+ for (i=loops-2; i > 0; i--)
+ {
+ _gcry_mpi_ec_dup_point (result, result, ctx);
+ if (mpi_test_bit (h, i) == 1 && mpi_test_bit (k, i) == 0)
+ {
+ point_set (&p2, result);
+ _gcry_mpi_ec_add_points (result, &p2, &p1, ctx);
+ }
+ if (mpi_test_bit (h, i) == 0 && mpi_test_bit (k, i) == 1)
+ {
+ point_set (&p2, result);
+ /* Invert point: y = p - y mod p */
+ point_set (&p1inv, &p1);
+ ec_subm (p1inv.y, ctx->p, p1inv.y, ctx);
+ _gcry_mpi_ec_add_points (result, &p2, &p1inv, ctx);
+ }
+ }
+
+ point_free (&p1);
+ point_free (&p2);
+ point_free (&p1inv);
+ mpi_free (h);
+ mpi_free (k);
+#endif
+}
diff --git a/grub-core/lib/libgcrypt/mpi/generic/Manifest b/grub-core/lib/libgcrypt/mpi/generic/Manifest
new file mode 100644
index 0000000..c429fde
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/Manifest
@@ -0,0 +1,29 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-add1.c iQCVAwUAP+Lj2DEAnp832S/7AQKn/AQAwQLWggl6zNQ5EZ+lE+jKV8W3FsogW3/6tp9T5rrSR5JnlWyoHQ9/Pu4knOcLjS6nIfVOiAEifu3nuIysQr9jDSSSJA2LylSUBSXKLKDamPsOCwXOLxiZODslJT3CCGAUtLvXJrWDbTZQrkEuwnLnjQFDzuA7iY9JLrG9kAoXD6Q==WoWm
+mpih-mul1.c iQCVAwUAP+LkCTEAnp832S/7AQKFVQP+MhBNjcY73JtnsHZfnaVZq3TiKwN151cWV51nDc1RnTaMhSIFeuNlj3vNML2W0Gn8n+GnyiWE2XXdQEaik6BL02eekUn9aq7I/rdpnTHuOjQPK1uwjuNl8RuJ9YrERBAxq4oB71f+iwMab8dsMSUlVC+NdeAocRqLLgnR/efkdLc==2Tkb
+mpih-mul2.c iQCVAwUAP+LkMjEAnp832S/7AQLPeAQAqmRzxFe/mDqTdZr/pTXT8RVyB1vKB0Ei2THV05BxmI4OPv39uysfFpLMt/INsX7AGqdOlj4jOZ/qNaFXR1ceMrlSXvo8u/epk6rCXFp82kM7Qs983LjoP//PrMCkYkXwblaVrgUGiBUCbuPMliWTK6qKkxxXtEfqZ7nVbEWdBx8==Kwhl
+mpih-mul3.c iQCVAwUAP+LkVDEAnp832S/7AQL91gP/Qd5iZWxRiN5DdEIVHAedoNvl23NPrT2UUdXvnSK49DpplTxkLiMBj0WqCayG/YIET2NpMRCeLvAZNcSt6lOm0bSZDYo1Hv/N+UoqD3V1McjY16REBv/nnPaMWMZcx7rl5yKTVZiX2PgV6oQOL7Yfrt5ZIOlrHBRs9S2/zcCaVz0==9BQe
+mpih-lshift.c iQCVAwUAP+LlATEAnp832S/7AQIACAQAhMrpx0SRXE/LN1NkjMO9n74nMrvmzYJyru0gw2O4BYrUPvD/LWGju2FZaggKV0IBjmi0cDoCrNeK9EGjKOO1lfgODbX2IZ1LUhr9jDuMj0QRqj6T9YkAFYTNUk4GfpwIf7T6Ybo7c78Jx93PidCJt7d39eMMEalooC7LZ4IU3NM==nZ4k
+mpih-rshift.c iQCVAwUAP+LlIjEAnp832S/7AQKiuAP/eYC2ZScd+taBx/kNzRvGjA0eAXvORMkMLV6Ot+OXVzVUi04eoP2yXdxSNFKwUj12p8GWXkdoMG3aOGBKg2a7bY5Q5RUho3hUWb9UsVYVUfXLf7IOTt/3a6MLh2CmV5dFPWJmSlbCyQRcn6n/fLDeJ3A2bWTS/BhqGfpOXUIU1ws==jCf8
+mpih-sub1.c iQCVAwUAP+LlZzEAnp832S/7AQIEPgP/dLHTDRbPrYJhsLp9SjGstU1M8/IC5XytcDtO3NQeu4mx6vaXjpujtsTvKIbX4QL5IahNntVVKv1xFLEm2yFg7L2ns0uD/mfwGgOhCG1j2o/SaTAWP5KxP7ae5UDcZl2w6NWvEuMj9t32zmziAZjP8W73A37FUspeRDYiL9sQzkI==QQzk
+udiv-w-sdiv.c iQCVAwUAP+Lk0TEAnp832S/7AQICXAQAsxe1SQD4+xZaZTqBC0V9Cyuo0mrdccnRFzthOtm0ARwKFXU2cuLW/ZBOkmeWOVmOFhBp22/I8dEGYnMA3gcfmOMCpNu9i9zk/XHfptdunA1MnOe3GsoWgfHL0rhpAyPhp/X043ICB41NElnnuxADuQQlD4Z1fca5ygYxMr2crJg==EI/6
+mpi-asm-defs.h iQCVAwUAP+LkgDEAnp832S/7AQK0FgQAxJZ7xvXhoZa33GWe23LRb3asrno/loZSyAIXrntqtVH8M3pEsCY0OyW4ry4hX2RnxpuhRCM/PdRNLG3xXyMSVIhkHU8WVRLqzF2LLjEkyU3cAmHnnTQ9aO/XpUWtJGTZ8q2bv7ZsAEi4aPl0p6KhPXcPgM9vQ2XcyOPn3Dl0d6Q==xpjI
+$names$ iQCVAwUAP+LmNDEAnp832S/7AQJa+gP+KQNJpbNOgc+s2UX+Ya2gDaOFcAROImIllhg3ej8EaBF8xxdHmWT1zaKwTwi3moEEleykMR104YAGWyQeMbFYiuPPBW+ohrT6KxRBVJpIA9auOOqqJMyglZyoR3Hv7gduVYUW1h/DebnqiKXKEfzQDFqYuT0ayuteoOR4B5NICbE==nLSh
diff --git a/grub-core/lib/libgcrypt/mpi/generic/distfiles b/grub-core/lib/libgcrypt/mpi/generic/distfiles
new file mode 100644
index 0000000..9810eef
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/distfiles
@@ -0,0 +1,11 @@
+Manifest
+mpih-add1.c
+mpih-mul1.c
+mpih-mul2.c
+mpih-mul3.c
+mpih-lshift.c
+mpih-rshift.c
+mpih-sub1.c
+udiv-w-sdiv.c
+mpi-asm-defs.h
+
diff --git a/grub-core/lib/libgcrypt/mpi/generic/mpi-asm-defs.h b/grub-core/lib/libgcrypt/mpi/generic/mpi-asm-defs.h
new file mode 100644
index 0000000..13424e2
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/mpi-asm-defs.h
@@ -0,0 +1,10 @@
+/* This file defines some basic constants for the MPI machinery. We
+ * need to define the types on a per-CPU basis, so it is done with
+ * this file here. */
+#define BYTES_PER_MPI_LIMB (SIZEOF_UNSIGNED_LONG)
+
+
+
+
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/generic/mpih-add1.c b/grub-core/lib/libgcrypt/mpi/generic/mpih-add1.c
new file mode 100644
index 0000000..4a84df6
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/mpih-add1.c
@@ -0,0 +1,65 @@
+/* mpihelp-add_1.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998,
+ * 2000, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+_gcry_mpih_add_n (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_ptr_t s2_ptr, mpi_size_t size)
+{
+ mpi_limb_t x, y, cy;
+ mpi_size_t j;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ the loop becomes faster. */
+ j = -size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ s2_ptr -= j;
+ res_ptr -= j;
+
+ cy = 0;
+ do
+ {
+ y = s2_ptr[j];
+ x = s1_ptr[j];
+ y += cy; /* add previous carry to one addend */
+ cy = y < cy; /* get out carry from that addition */
+ y += x; /* add other addend */
+ cy += y < x; /* get out carry from that add, combine */
+ res_ptr[j] = y;
+ }
+ while ( ++j );
+
+ return cy;
+}
+
diff --git a/grub-core/lib/libgcrypt/mpi/generic/mpih-lshift.c b/grub-core/lib/libgcrypt/mpi/generic/mpih-lshift.c
new file mode 100644
index 0000000..f48c12c
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/mpih-lshift.c
@@ -0,0 +1,68 @@
+/* mpi-lshift.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left
+ * and store the USIZE least significant digits of the result at WP.
+ * Return the bits shifted out from the most significant digit.
+ *
+ * Argument constraints:
+ * 1. 0 < CNT < BITS_PER_MP_LIMB
+ * 2. If the result is to be written over the input, WP must be >= UP.
+ */
+
+mpi_limb_t
+_gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
+ unsigned int cnt)
+{
+ mpi_limb_t high_limb, low_limb;
+ unsigned sh_1, sh_2;
+ mpi_size_t i;
+ mpi_limb_t retval;
+
+ sh_1 = cnt;
+ wp += 1;
+ sh_2 = BITS_PER_MPI_LIMB - sh_1;
+ i = usize - 1;
+ low_limb = up[i];
+ retval = low_limb >> sh_2;
+ high_limb = low_limb;
+ while ( --i >= 0 )
+ {
+ low_limb = up[i];
+ wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
+ high_limb = low_limb;
+ }
+ wp[i] = high_limb << sh_1;
+
+ return retval;
+}
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/generic/mpih-mul1.c b/grub-core/lib/libgcrypt/mpi/generic/mpih-mul1.c
new file mode 100644
index 0000000..0e8197d
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/mpih-mul1.c
@@ -0,0 +1,62 @@
+/* mpihelp-mul_1.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+_gcry_mpih_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_limb_t s2_limb)
+{
+ mpi_limb_t cy_limb;
+ mpi_size_t j;
+ mpi_limb_t prod_high, prod_low;
+
+ /* The loop counter and index J goes from -S1_SIZE to -1. This way
+ * the loop becomes faster. */
+ j = -s1_size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ res_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+ res_ptr[j] = prod_low;
+ }
+ while( ++j );
+
+ return cy_limb;
+}
+
diff --git a/grub-core/lib/libgcrypt/mpi/generic/mpih-mul2.c b/grub-core/lib/libgcrypt/mpi/generic/mpih-mul2.c
new file mode 100644
index 0000000..3b75496
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/mpih-mul2.c
@@ -0,0 +1,68 @@
+/* mpih-mul2.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+mpi_limb_t
+_gcry_mpih_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+ mpi_limb_t cy_limb;
+ mpi_size_t j;
+ mpi_limb_t prod_high, prod_low;
+ mpi_limb_t x;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ * the loop becomes faster. */
+ j = -s1_size;
+ res_ptr -= j;
+ s1_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
+
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+
+ x = res_ptr[j];
+ prod_low = x + prod_low;
+ cy_limb += prod_low < x?1:0;
+ res_ptr[j] = prod_low;
+ }
+ while ( ++j );
+
+ return cy_limb;
+}
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/generic/mpih-mul3.c b/grub-core/lib/libgcrypt/mpi/generic/mpih-mul3.c
new file mode 100644
index 0000000..5e84f94
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/mpih-mul3.c
@@ -0,0 +1,68 @@
+/* mpih-mul3.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+mpi_limb_t
+_gcry_mpih_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+ mpi_limb_t cy_limb;
+ mpi_size_t j;
+ mpi_limb_t prod_high, prod_low;
+ mpi_limb_t x;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ * the loop becomes faster. */
+ j = -s1_size;
+ res_ptr -= j;
+ s1_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb);
+
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb?1:0) + prod_high;
+
+ x = res_ptr[j];
+ prod_low = x - prod_low;
+ cy_limb += prod_low > x?1:0;
+ res_ptr[j] = prod_low;
+ }
+ while( ++j );
+
+ return cy_limb;
+}
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/generic/mpih-rshift.c b/grub-core/lib/libgcrypt/mpi/generic/mpih-rshift.c
new file mode 100644
index 0000000..e40794f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/mpih-rshift.c
@@ -0,0 +1,67 @@
+/* mpih-rshift.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 1999,
+ * 2000, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+
+/* Shift U (pointed to by UP and USIZE limbs long) CNT bits to the right
+ * and store the USIZE least significant limbs of the result at WP.
+ * The bits shifted out to the right are returned.
+ *
+ * Argument constraints:
+ * 1. 0 < CNT < BITS_PER_MP_LIMB
+ * 2. If the result is to be written over the input, WP must be <= UP.
+ */
+
+mpi_limb_t
+_gcry_mpih_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt)
+{
+ mpi_limb_t high_limb, low_limb;
+ unsigned sh_1, sh_2;
+ mpi_size_t i;
+ mpi_limb_t retval;
+
+ sh_1 = cnt;
+ wp -= 1;
+ sh_2 = BITS_PER_MPI_LIMB - sh_1;
+ high_limb = up[0];
+ retval = high_limb << sh_2;
+ low_limb = high_limb;
+ for (i=1; i < usize; i++)
+ {
+ high_limb = up[i];
+ wp[i] = (low_limb >> sh_1) | (high_limb << sh_2);
+ low_limb = high_limb;
+ }
+ wp[i] = low_limb >> sh_1;
+
+ return retval;
+}
+
diff --git a/grub-core/lib/libgcrypt/mpi/generic/mpih-sub1.c b/grub-core/lib/libgcrypt/mpi/generic/mpih-sub1.c
new file mode 100644
index 0000000..e88821b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/mpih-sub1.c
@@ -0,0 +1,66 @@
+/* mpihelp-add_2.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1997, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+mpi_limb_t
+_gcry_mpih_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_ptr_t s2_ptr, mpi_size_t size)
+{
+ mpi_limb_t x, y, cy;
+ mpi_size_t j;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ the loop becomes faster. */
+ j = -size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ s2_ptr -= j;
+ res_ptr -= j;
+
+ cy = 0;
+ do
+ {
+ y = s2_ptr[j];
+ x = s1_ptr[j];
+ y += cy; /* add previous carry to subtrahend */
+ cy = y < cy; /* get out carry from that addition */
+ y = x - y; /* main subtract */
+ cy += y > x; /* get out carry from the subtract, combine */
+ res_ptr[j] = y;
+ }
+ while( ++j );
+
+ return cy;
+}
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/generic/udiv-w-sdiv.c b/grub-core/lib/libgcrypt/mpi/generic/udiv-w-sdiv.c
new file mode 100644
index 0000000..e80d98b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/generic/udiv-w-sdiv.c
@@ -0,0 +1,133 @@
+/* mpih-w-sdiv -- implement udiv_qrnnd on machines with only signed
+ * division.
+ * Copyright (C) 1992, 1994, 1996, 1998, 2002 Free Software Foundation, Inc.
+ * Contributed by Peter L. Montgomery.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+#if 0 /* not yet ported to MPI */
+
+mpi_limb_t
+mpihelp_udiv_w_sdiv( mpi_limp_t *rp,
+ mpi_limp_t *a1,
+ mpi_limp_t *a0,
+ mpi_limp_t *d )
+{
+ mp_limb_t q, r;
+ mp_limb_t c0, c1, b1;
+
+ if ((mpi_limb_signed_t) d >= 0)
+ {
+ if (a1 < d - a1 - (a0 >> (BITS_PER_MP_LIMB - 1)))
+ {
+ /* dividend, divisor, and quotient are nonnegative */
+ sdiv_qrnnd (q, r, a1, a0, d);
+ }
+ else
+ {
+ /* Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d */
+ sub_ddmmss (c1, c0, a1, a0, d >> 1, d << (BITS_PER_MP_LIMB - 1));
+ /* Divide (c1*2^32 + c0) by d */
+ sdiv_qrnnd (q, r, c1, c0, d);
+ /* Add 2^31 to quotient */
+ q += (mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1);
+ }
+ }
+ else
+ {
+ b1 = d >> 1; /* d/2, between 2^30 and 2^31 - 1 */
+ c1 = a1 >> 1; /* A/2 */
+ c0 = (a1 << (BITS_PER_MP_LIMB - 1)) + (a0 >> 1);
+
+ if (a1 < b1) /* A < 2^32*b1, so A/2 < 2^31*b1 */
+ {
+ sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
+
+ r = 2*r + (a0 & 1); /* Remainder from A/(2*b1) */
+ if ((d & 1) != 0)
+ {
+ if (r >= q)
+ r = r - q;
+ else if (q - r <= d)
+ {
+ r = r - q + d;
+ q--;
+ }
+ else
+ {
+ r = r - q + 2*d;
+ q -= 2;
+ }
+ }
+ }
+ else if (c1 < b1) /* So 2^31 <= (A/2)/b1 < 2^32 */
+ {
+ c1 = (b1 - 1) - c1;
+ c0 = ~c0; /* logical NOT */
+
+ sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
+
+ q = ~q; /* (A/2)/b1 */
+ r = (b1 - 1) - r;
+
+ r = 2*r + (a0 & 1); /* A/(2*b1) */
+
+ if ((d & 1) != 0)
+ {
+ if (r >= q)
+ r = r - q;
+ else if (q - r <= d)
+ {
+ r = r - q + d;
+ q--;
+ }
+ else
+ {
+ r = r - q + 2*d;
+ q -= 2;
+ }
+ }
+ }
+ else /* Implies c1 = b1 */
+ { /* Hence a1 = d - 1 = 2*b1 - 1 */
+ if (a0 >= -d)
+ {
+ q = -1;
+ r = a0 + d;
+ }
+ else
+ {
+ q = -2;
+ r = a0 + 2*d;
+ }
+ }
+ }
+
+ *rp = r;
+ return q;
+}
+
+#endif
+
diff --git a/grub-core/lib/libgcrypt/mpi/hppa/README b/grub-core/lib/libgcrypt/mpi/hppa/README
new file mode 100644
index 0000000..5a2d5fd
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/hppa/README
@@ -0,0 +1,84 @@
+This directory contains mpn functions for various HP PA-RISC chips. Code
+that runs faster on the PA7100 and later implementations, is in the pa7100
+directory.
+
+RELEVANT OPTIMIZATION ISSUES
+
+ Load and Store timing
+
+On the PA7000 no memory instructions can issue the two cycles after a store.
+For the PA7100, this is reduced to one cycle.
+
+The PA7100 has a lookup-free cache, so it helps to schedule loads and the
+dependent instruction really far from each other.
+
+STATUS
+
+1. mpn_mul_1 could be improved to 6.5 cycles/limb on the PA7100, using the
+ instructions bwlow (but some sw pipelining is needed to avoid the
+ xmpyu-fstds delay):
+
+ fldds s1_ptr
+
+ xmpyu
+ fstds N(%r30)
+ xmpyu
+ fstds N(%r30)
+
+ ldws N(%r30)
+ ldws N(%r30)
+ ldws N(%r30)
+ ldws N(%r30)
+
+ addc
+ stws res_ptr
+ addc
+ stws res_ptr
+
+ addib Loop
+
+2. mpn_addmul_1 could be improved from the current 10 to 7.5 cycles/limb
+ (asymptotically) on the PA7100, using the instructions below. With proper
+ sw pipelining and the unrolling level below, the speed becomes 8
+ cycles/limb.
+
+ fldds s1_ptr
+ fldds s1_ptr
+
+ xmpyu
+ fstds N(%r30)
+ xmpyu
+ fstds N(%r30)
+ xmpyu
+ fstds N(%r30)
+ xmpyu
+ fstds N(%r30)
+
+ ldws N(%r30)
+ ldws N(%r30)
+ ldws N(%r30)
+ ldws N(%r30)
+ ldws N(%r30)
+ ldws N(%r30)
+ ldws N(%r30)
+ ldws N(%r30)
+ addc
+ addc
+ addc
+ addc
+ addc %r0,%r0,cy-limb
+
+ ldws res_ptr
+ ldws res_ptr
+ ldws res_ptr
+ ldws res_ptr
+ add
+ stws res_ptr
+ addc
+ stws res_ptr
+ addc
+ stws res_ptr
+ addc
+ stws res_ptr
+
+ addib
diff --git a/grub-core/lib/libgcrypt/mpi/hppa/distfiles b/grub-core/lib/libgcrypt/mpi/hppa/distfiles
new file mode 100644
index 0000000..7f24205
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/hppa/distfiles
@@ -0,0 +1,7 @@
+README
+udiv-qrnnd.S
+mpih-add1.S
+mpih-sub1.S
+mpih-lshift.S
+mpih-rshift.S
+
diff --git a/grub-core/lib/libgcrypt/mpi/hppa/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/hppa/mpih-add1.S
new file mode 100644
index 0000000..3bc0e5e
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/hppa/mpih-add1.S
@@ -0,0 +1,70 @@
+/* hppa add_n -- Add two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Fee Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (gr26)
+ * mpi_ptr_t s1_ptr, (gr25)
+ * mpi_ptr_t s2_ptr, (gr24)
+ * mpi_size_t size) (gr23)
+ *
+ * One might want to unroll this as for other processors, but it turns
+ * out that the data cache contention after a store makes such
+ * unrolling useless. We can't come under 5 cycles/limb anyway.
+ */
+
+ .code
+ .export _gcry_mpih_add_n
+ .label _gcry_mpih_add_n
+ .proc
+ .callinfo frame=0,no_calls
+ .entry
+
+ ldws,ma 4(0,%r25),%r20
+ ldws,ma 4(0,%r24),%r19
+
+ addib,= -1,%r23,L$end ; check for (SIZE == 1)
+ add %r20,%r19,%r28 ; add first limbs ignoring cy
+
+ .label L$loop
+ ldws,ma 4(0,%r25),%r20
+ ldws,ma 4(0,%r24),%r19
+ stws,ma %r28,4(0,%r26)
+ addib,<> -1,%r23,L$loop
+ addc %r20,%r19,%r28
+
+ .label L$end
+ stws %r28,0(0,%r26)
+ bv 0(%r2)
+ addc %r0,%r0,%r28
+
+ .exit
+ .procend
diff --git a/grub-core/lib/libgcrypt/mpi/hppa/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/hppa/mpih-lshift.S
new file mode 100644
index 0000000..91b29bb
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/hppa/mpih-lshift.S
@@ -0,0 +1,77 @@
+/* hppa lshift
+ *
+ * Copyright (C) 1992, 1994, 1998
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp, (gr26)
+ * mpi_ptr_t up, (gr25)
+ * mpi_size_t usize, (gr24)
+ * unsigned cnt) (gr23)
+ */
+
+ .code
+ .export _gcry_mpih_lshift
+ .label _gcry_mpih_lshift
+ .proc
+ .callinfo frame=64,no_calls
+ .entry
+
+ sh2add %r24,%r25,%r25
+ sh2add %r24,%r26,%r26
+ ldws,mb -4(0,%r25),%r22
+ subi 32,%r23,%r1
+ mtsar %r1
+ addib,= -1,%r24,L$0004
+ vshd %r0,%r22,%r28 ; compute carry out limb
+ ldws,mb -4(0,%r25),%r29
+ addib,= -1,%r24,L$0002
+ vshd %r22,%r29,%r20
+
+ .label L$loop
+ ldws,mb -4(0,%r25),%r22
+ stws,mb %r20,-4(0,%r26)
+ addib,= -1,%r24,L$0003
+ vshd %r29,%r22,%r20
+ ldws,mb -4(0,%r25),%r29
+ stws,mb %r20,-4(0,%r26)
+ addib,<> -1,%r24,L$loop
+ vshd %r22,%r29,%r20
+
+ .label L$0002
+ stws,mb %r20,-4(0,%r26)
+ vshd %r29,%r0,%r20
+ bv 0(%r2)
+ stw %r20,-4(0,%r26)
+ .label L$0003
+ stws,mb %r20,-4(0,%r26)
+ .label L$0004
+ vshd %r22,%r0,%r20
+ bv 0(%r2)
+ stw %r20,-4(0,%r26)
+
+ .exit
+ .procend
+
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/hppa/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/hppa/mpih-rshift.S
new file mode 100644
index 0000000..37a9d4e
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/hppa/mpih-rshift.S
@@ -0,0 +1,73 @@
+/* hppa rshift
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp, (gr26)
+ * mpi_ptr_t up, (gr25)
+ * mpi_size_t usize, (gr24)
+ * unsigned cnt) (gr23)
+ */
+
+ .code
+ .export _gcry_mpih_rshift
+ .label _gcry_mpih_rshift
+ .proc
+ .callinfo frame=64,no_calls
+ .entry
+
+ ldws,ma 4(0,%r25),%r22
+ mtsar %r23
+ addib,= -1,%r24,L$r004
+ vshd %r22,%r0,%r28 ; compute carry out limb
+ ldws,ma 4(0,%r25),%r29
+ addib,= -1,%r24,L$r002
+ vshd %r29,%r22,%r20
+
+ .label L$roop
+ ldws,ma 4(0,%r25),%r22
+ stws,ma %r20,4(0,%r26)
+ addib,= -1,%r24,L$r003
+ vshd %r22,%r29,%r20
+ ldws,ma 4(0,%r25),%r29
+ stws,ma %r20,4(0,%r26)
+ addib,<> -1,%r24,L$roop
+ vshd %r29,%r22,%r20
+
+ .label L$r002
+ stws,ma %r20,4(0,%r26)
+ vshd %r0,%r29,%r20
+ bv 0(%r2)
+ stw %r20,0(0,%r26)
+ .label L$r003
+ stws,ma %r20,4(0,%r26)
+ .label L$r004
+ vshd %r0,%r22,%r20
+ bv 0(%r2)
+ stw %r20,0(0,%r26)
+
+ .exit
+ .procend
+
diff --git a/grub-core/lib/libgcrypt/mpi/hppa/mpih-sub1.S b/grub-core/lib/libgcrypt/mpi/hppa/mpih-sub1.S
new file mode 100644
index 0000000..8d197e4
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/hppa/mpih-sub1.S
@@ -0,0 +1,78 @@
+/* hppa sub_n -- Sub two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (gr26)
+ * mpi_ptr_t s1_ptr, (gr25)
+ * mpi_ptr_t s2_ptr, (gr24)
+ * mpi_size_t size) (gr23)
+ *
+ * One might want to unroll this as for other processors, but it turns
+ * out that the data cache contention after a store makes such
+ * unrolling useless. We can't come under 5 cycles/limb anyway.
+ */
+
+
+ .code
+ .export _gcry_mpih_sub_n
+ .label _gcry_mpih_sub_n
+ .proc
+ .callinfo frame=0,no_calls
+ .entry
+
+ ldws,ma 4(0,%r25),%r20
+ ldws,ma 4(0,%r24),%r19
+
+ addib,= -1,%r23,L$end ; check for (SIZE == 1)
+ sub %r20,%r19,%r28 ; subtract first limbs ignoring cy
+
+ .label L$loop
+ ldws,ma 4(0,%r25),%r20
+ ldws,ma 4(0,%r24),%r19
+ stws,ma %r28,4(0,%r26)
+ addib,<> -1,%r23,L$loop
+ subb %r20,%r19,%r28
+
+ .label L$end
+ stws %r28,0(0,%r26)
+ addc %r0,%r0,%r28
+ bv 0(%r2)
+ subi 1,%r28,%r28
+
+ .exit
+ .procend
+
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/hppa/udiv-qrnnd.S b/grub-core/lib/libgcrypt/mpi/hppa/udiv-qrnnd.S
new file mode 100644
index 0000000..59ebf7a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/hppa/udiv-qrnnd.S
@@ -0,0 +1,297 @@
+/* HP-PA __udiv_qrnnd division support, used from longlong.h.
+ * This version runs fast on pre-PA7000 CPUs.
+ *
+ * Copyright (C) 1993, 1994, 1998, 2001,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+
+/* INPUT PARAMETERS
+ * rem_ptr gr26
+ * n1 gr25
+ * n0 gr24
+ * d gr23
+ *
+ * The code size is a bit excessive. We could merge the last two ds;addc
+ * sequences by simply moving the "bb,< Odd" instruction down. The only
+ * trouble is the FFFFFFFF code that would need some hacking.
+ */
+
+ .code
+ .export __udiv_qrnnd
+ .label __udiv_qrnnd
+ .proc
+ .callinfo frame=0,no_calls
+ .entry
+
+ comb,< %r23,0,L$largedivisor
+ sub %r0,%r23,%r1 ; clear cy as side-effect
+ ds %r0,%r1,%r0
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r28
+ ds %r25,%r23,%r25
+ comclr,>= %r25,%r0,%r0
+ addl %r25,%r23,%r25
+ stws %r25,0(0,%r26)
+ bv 0(%r2)
+ addc %r28,%r28,%r28
+
+ .label L$largedivisor
+ extru %r24,31,1,%r19 ; r19 = n0 & 1
+ bb,< %r23,31,L$odd
+ extru %r23,30,31,%r22 ; r22 = d >> 1
+ shd %r25,%r24,1,%r24 ; r24 = new n0
+ extru %r25,30,31,%r25 ; r25 = new n1
+ sub %r0,%r22,%r21
+ ds %r0,%r21,%r0
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ comclr,>= %r25,%r0,%r0
+ addl %r25,%r22,%r25
+ sh1addl %r25,%r19,%r25
+ stws %r25,0(0,%r26)
+ bv 0(%r2)
+ addc %r24,%r24,%r28
+
+ .label L$odd
+ addib,sv,n 1,%r22,L$FF.. ; r22 = (d / 2 + 1)
+ shd %r25,%r24,1,%r24 ; r24 = new n0
+ extru %r25,30,31,%r25 ; r25 = new n1
+ sub %r0,%r22,%r21
+ ds %r0,%r21,%r0
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r28
+ comclr,>= %r25,%r0,%r0
+ addl %r25,%r22,%r25
+ sh1addl %r25,%r19,%r25
+; We have computed (n1,,n0) / (d + 1), q' = r28, r' = r25
+ add,nuv %r28,%r25,%r25
+ addl %r25,%r1,%r25
+ addc %r0,%r28,%r28
+ sub,<< %r25,%r23,%r0
+ addl %r25,%r1,%r25
+ stws %r25,0(0,%r26)
+ bv 0(%r2)
+ addc %r0,%r28,%r28
+
+; This is just a special case of the code above.
+; We come here when d == 0xFFFFFFFF
+ .label L$FF..
+ add,uv %r25,%r24,%r24
+ sub,<< %r24,%r23,%r0
+ ldo 1(%r24),%r24
+ stws %r24,0(0,%r26)
+ bv 0(%r2)
+ addc %r0,%r25,%r28
+
+ .exit
+ .procend
diff --git a/grub-core/lib/libgcrypt/mpi/i386/Manifest b/grub-core/lib/libgcrypt/mpi/i386/Manifest
new file mode 100644
index 0000000..812bc8a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i386/Manifest
@@ -0,0 +1,28 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-add1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-lshift.S
+mpih-rshift.S
+mpih-sub1.S
+syntax.h
+$names$ iQCVAwUAP+LmOTEAnp832S/7AQJZmgQA1+GIl7rXiEY00y5xD2kG5Lm2QD6c9aBME8hTl812OEcj0ul/QSpdv8E2NEKooifr4SiLVhEVfLNaLqAgN3cIsttn3rRX3/pMC5JwSKHDJPsUbpN9tzb5dr2YC9GG9m8xngAQrN11IQPnGfvFLJK+oDnEMIAeHDpOnX9NeQPDAQA==bnOy
diff --git a/grub-core/lib/libgcrypt/mpi/i386/distfiles b/grub-core/lib/libgcrypt/mpi/i386/distfiles
new file mode 100644
index 0000000..22b9979
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i386/distfiles
@@ -0,0 +1,10 @@
+Manifest
+mpih-add1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-lshift.S
+mpih-rshift.S
+mpih-sub1.S
+syntax.h
+
diff --git a/grub-core/lib/libgcrypt/mpi/i386/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/i386/mpih-add1.S
new file mode 100644
index 0000000..652b232
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i386/mpih-add1.S
@@ -0,0 +1,116 @@
+/* i80386 add_n -- Add two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_ptr_t s2_ptr, (sp + 12)
+ * mpi_size_t size) (sp + 16)
+ */
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_add_n)
+C_SYMBOL_NAME(_gcry_mpih_add_n:)
+ pushl %edi
+ pushl %esi
+
+ movl 12(%esp),%edi /* res_ptr */
+ movl 16(%esp),%esi /* s1_ptr */
+ movl 20(%esp),%edx /* s2_ptr */
+ movl 24(%esp),%ecx /* size */
+
+ movl %ecx,%eax
+ shrl $3,%ecx /* compute count for unrolled loop */
+ negl %eax
+ andl $7,%eax /* get index where to start loop */
+ jz Loop /* necessary special case for 0 */
+ incl %ecx /* adjust loop count */
+ shll $2,%eax /* adjustment for pointers... */
+ subl %eax,%edi /* ... since they are offset ... */
+ subl %eax,%esi /* ... by a constant when we ... */
+ subl %eax,%edx /* ... enter the loop */
+ shrl $2,%eax /* restore previous value */
+#ifdef PIC
+/* Calculate start address in loop for PIC. Due to limitations in some
+ assemblers, Loop-L0-3 cannot be put into the leal */
+ call L0
+L0: leal (%eax,%eax,8),%eax
+ addl (%esp),%eax
+ addl $(Loop-L0-3),%eax
+ addl $4,%esp
+#else
+/* Calculate start address in loop for non-PIC. */
+ leal (Loop - 3)(%eax,%eax,8),%eax
+#endif
+ jmp *%eax /* jump into loop */
+ ALIGN (3)
+Loop: movl (%esi),%eax
+ adcl (%edx),%eax
+ movl %eax,(%edi)
+ movl 4(%esi),%eax
+ adcl 4(%edx),%eax
+ movl %eax,4(%edi)
+ movl 8(%esi),%eax
+ adcl 8(%edx),%eax
+ movl %eax,8(%edi)
+ movl 12(%esi),%eax
+ adcl 12(%edx),%eax
+ movl %eax,12(%edi)
+ movl 16(%esi),%eax
+ adcl 16(%edx),%eax
+ movl %eax,16(%edi)
+ movl 20(%esi),%eax
+ adcl 20(%edx),%eax
+ movl %eax,20(%edi)
+ movl 24(%esi),%eax
+ adcl 24(%edx),%eax
+ movl %eax,24(%edi)
+ movl 28(%esi),%eax
+ adcl 28(%edx),%eax
+ movl %eax,28(%edi)
+ leal 32(%edi),%edi
+ leal 32(%esi),%esi
+ leal 32(%edx),%edx
+ decl %ecx
+ jnz Loop
+
+ sbbl %eax,%eax
+ negl %eax
+
+ popl %esi
+ popl %edi
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i386/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/i386/mpih-lshift.S
new file mode 100644
index 0000000..bf8ed9d
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i386/mpih-lshift.S
@@ -0,0 +1,94 @@
+/* i80386 lshift
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp, (sp + 4)
+ * mpi_ptr_t up, (sp + 8)
+ * mpi_size_t usize, (sp + 12)
+ * unsigned cnt) (sp + 16)
+ */
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_lshift)
+C_SYMBOL_NAME(_gcry_mpih_lshift:)
+ pushl %edi
+ pushl %esi
+ pushl %ebx
+
+ movl 16(%esp),%edi /* res_ptr */
+ movl 20(%esp),%esi /* s_ptr */
+ movl 24(%esp),%edx /* size */
+ movl 28(%esp),%ecx /* cnt */
+
+ subl $4,%esi /* adjust s_ptr */
+
+ movl (%esi,%edx,4),%ebx /* read most significant limb */
+ xorl %eax,%eax
+ shldl %cl,%ebx,%eax /* compute carry limb */
+ decl %edx
+ jz Lend
+ pushl %eax /* push carry limb onto stack */
+ testb $1,%dl
+ jnz L1 /* enter loop in the middle */
+ movl %ebx,%eax
+
+ ALIGN (3)
+Loop: movl (%esi,%edx,4),%ebx /* load next lower limb */
+ shldl %cl,%ebx,%eax /* compute result limb */
+ movl %eax,(%edi,%edx,4) /* store it */
+ decl %edx
+L1: movl (%esi,%edx,4),%eax
+ shldl %cl,%eax,%ebx
+ movl %ebx,(%edi,%edx,4)
+ decl %edx
+ jnz Loop
+
+ shll %cl,%eax /* compute least significant limb */
+ movl %eax,(%edi) /* store it */
+
+ popl %eax /* pop carry limb */
+
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
+Lend: shll %cl,%ebx /* compute least significant limb */
+ movl %ebx,(%edi) /* store it */
+
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i386/mpih-mul1.S b/grub-core/lib/libgcrypt/mpi/i386/mpih-mul1.S
new file mode 100644
index 0000000..c9760ef
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i386/mpih-mul1.S
@@ -0,0 +1,84 @@
+/* i80386 mul_1 -- Multiply a limb vector with a limb and store
+ * the result in a second limb vector.
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ */
+
+#define res_ptr edi
+#define s1_ptr esi
+#define size ecx
+#define s2_limb ebp
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1)
+C_SYMBOL_NAME(_gcry_mpih_mul_1:)
+
+ INSN1(push,l ,R(edi))
+ INSN1(push,l ,R(esi))
+ INSN1(push,l ,R(ebx))
+ INSN1(push,l ,R(ebp))
+
+ INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
+ INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
+ INSN2(mov,l ,R(size),MEM_DISP(esp,28))
+ INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
+
+ INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
+ INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
+ INSN1(neg,l ,R(size))
+ INSN2(xor,l ,R(ebx),R(ebx))
+ ALIGN (3)
+Loop:
+ INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
+ INSN1(mul,l ,R(s2_limb))
+ INSN2(add,l ,R(eax),R(ebx))
+ INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(eax))
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(mov,l ,R(ebx),R(edx))
+
+ INSN1(inc,l ,R(size))
+ INSN1(jnz, ,Loop)
+ INSN2(mov,l ,R(eax),R(ebx))
+
+ INSN1(pop,l ,R(ebp))
+ INSN1(pop,l ,R(ebx))
+ INSN1(pop,l ,R(esi))
+ INSN1(pop,l ,R(edi))
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i386/mpih-mul2.S b/grub-core/lib/libgcrypt/mpi/i386/mpih-mul2.S
new file mode 100644
index 0000000..9794e11
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i386/mpih-mul2.S
@@ -0,0 +1,86 @@
+/* i80386 addmul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ */
+
+#define res_ptr edi
+#define s1_ptr esi
+#define size ecx
+#define s2_limb ebp
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1)
+C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
+
+ INSN1(push,l ,R(edi))
+ INSN1(push,l ,R(esi))
+ INSN1(push,l ,R(ebx))
+ INSN1(push,l ,R(ebp))
+
+ INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
+ INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
+ INSN2(mov,l ,R(size),MEM_DISP(esp,28))
+ INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
+
+ INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
+ INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
+ INSN1(neg,l ,R(size))
+ INSN2(xor,l ,R(ebx),R(ebx))
+ ALIGN (3)
+Loop:
+ INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
+ INSN1(mul,l ,R(s2_limb))
+ INSN2(add,l ,R(eax),R(ebx))
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(add,l ,MEM_INDEX(res_ptr,size,4),R(eax))
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(mov,l ,R(ebx),R(edx))
+
+ INSN1(inc,l ,R(size))
+ INSN1(jnz, ,Loop)
+ INSN2(mov,l ,R(eax),R(ebx))
+
+ INSN1(pop,l ,R(ebp))
+ INSN1(pop,l ,R(ebx))
+ INSN1(pop,l ,R(esi))
+ INSN1(pop,l ,R(edi))
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i386/mpih-mul3.S b/grub-core/lib/libgcrypt/mpi/i386/mpih-mul3.S
new file mode 100644
index 0000000..6df2017
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i386/mpih-mul3.S
@@ -0,0 +1,86 @@
+/* i80386 submul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ */
+
+#define res_ptr edi
+#define s1_ptr esi
+#define size ecx
+#define s2_limb ebp
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1)
+C_SYMBOL_NAME(_gcry_mpih_submul_1:)
+
+ INSN1(push,l ,R(edi))
+ INSN1(push,l ,R(esi))
+ INSN1(push,l ,R(ebx))
+ INSN1(push,l ,R(ebp))
+
+ INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
+ INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
+ INSN2(mov,l ,R(size),MEM_DISP(esp,28))
+ INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
+
+ INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
+ INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
+ INSN1(neg,l ,R(size))
+ INSN2(xor,l ,R(ebx),R(ebx))
+ ALIGN (3)
+Loop:
+ INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
+ INSN1(mul,l ,R(s2_limb))
+ INSN2(add,l ,R(eax),R(ebx))
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(sub,l ,MEM_INDEX(res_ptr,size,4),R(eax))
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(mov,l ,R(ebx),R(edx))
+
+ INSN1(inc,l ,R(size))
+ INSN1(jnz, ,Loop)
+ INSN2(mov,l ,R(eax),R(ebx))
+
+ INSN1(pop,l ,R(ebp))
+ INSN1(pop,l ,R(ebx))
+ INSN1(pop,l ,R(esi))
+ INSN1(pop,l ,R(edi))
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i386/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/i386/mpih-rshift.S
new file mode 100644
index 0000000..2920e55
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i386/mpih-rshift.S
@@ -0,0 +1,97 @@
+/* i80386 rshift
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp, (sp + 4)
+ * mpi_ptr_t up, (sp + 8)
+ * mpi_size_t usize, (sp + 12)
+ * unsigned cnt) (sp + 16)
+ */
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_rshift)
+C_SYMBOL_NAME(_gcry_mpih_rshift:)
+ pushl %edi
+ pushl %esi
+ pushl %ebx
+
+ movl 16(%esp),%edi /* wp */
+ movl 20(%esp),%esi /* up */
+ movl 24(%esp),%edx /* usize */
+ movl 28(%esp),%ecx /* cnt */
+
+ leal -4(%edi,%edx,4),%edi
+ leal (%esi,%edx,4),%esi
+ negl %edx
+
+ movl (%esi,%edx,4),%ebx /* read least significant limb */
+ xorl %eax,%eax
+ shrdl %cl,%ebx,%eax /* compute carry limb */
+ incl %edx
+ jz Lend2
+ pushl %eax /* push carry limb onto stack */
+ testb $1,%dl
+ jnz L2 /* enter loop in the middle */
+ movl %ebx,%eax
+
+ ALIGN (3)
+Loop2: movl (%esi,%edx,4),%ebx /* load next higher limb */
+ shrdl %cl,%ebx,%eax /* compute result limb */
+ movl %eax,(%edi,%edx,4) /* store it */
+ incl %edx
+L2: movl (%esi,%edx,4),%eax
+ shrdl %cl,%eax,%ebx
+ movl %ebx,(%edi,%edx,4)
+ incl %edx
+ jnz Loop2
+
+ shrl %cl,%eax /* compute most significant limb */
+ movl %eax,(%edi) /* store it */
+
+ popl %eax /* pop carry limb */
+
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
+Lend2: shrl %cl,%ebx /* compute most significant limb */
+ movl %ebx,(%edi) /* store it */
+
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i386/mpih-sub1.S b/grub-core/lib/libgcrypt/mpi/i386/mpih-sub1.S
new file mode 100644
index 0000000..f447f7a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i386/mpih-sub1.S
@@ -0,0 +1,117 @@
+/* i80386 sub_n -- Sub two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_ptr_t s2_ptr, (sp + 12)
+ * mpi_size_t size) (sp + 16)
+ */
+
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_sub_n)
+C_SYMBOL_NAME(_gcry_mpih_sub_n:)
+ pushl %edi
+ pushl %esi
+
+ movl 12(%esp),%edi /* res_ptr */
+ movl 16(%esp),%esi /* s1_ptr */
+ movl 20(%esp),%edx /* s2_ptr */
+ movl 24(%esp),%ecx /* size */
+
+ movl %ecx,%eax
+ shrl $3,%ecx /* compute count for unrolled loop */
+ negl %eax
+ andl $7,%eax /* get index where to start loop */
+ jz Loop /* necessary special case for 0 */
+ incl %ecx /* adjust loop count */
+ shll $2,%eax /* adjustment for pointers... */
+ subl %eax,%edi /* ... since they are offset ... */
+ subl %eax,%esi /* ... by a constant when we ... */
+ subl %eax,%edx /* ... enter the loop */
+ shrl $2,%eax /* restore previous value */
+#ifdef PIC
+/* Calculate start address in loop for PIC. Due to limitations in some
+ assemblers, Loop-L0-3 cannot be put into the leal */
+ call L0
+L0: leal (%eax,%eax,8),%eax
+ addl (%esp),%eax
+ addl $(Loop-L0-3),%eax
+ addl $4,%esp
+#else
+/* Calculate start address in loop for non-PIC. */
+ leal (Loop - 3)(%eax,%eax,8),%eax
+#endif
+ jmp *%eax /* jump into loop */
+ ALIGN (3)
+Loop: movl (%esi),%eax
+ sbbl (%edx),%eax
+ movl %eax,(%edi)
+ movl 4(%esi),%eax
+ sbbl 4(%edx),%eax
+ movl %eax,4(%edi)
+ movl 8(%esi),%eax
+ sbbl 8(%edx),%eax
+ movl %eax,8(%edi)
+ movl 12(%esi),%eax
+ sbbl 12(%edx),%eax
+ movl %eax,12(%edi)
+ movl 16(%esi),%eax
+ sbbl 16(%edx),%eax
+ movl %eax,16(%edi)
+ movl 20(%esi),%eax
+ sbbl 20(%edx),%eax
+ movl %eax,20(%edi)
+ movl 24(%esi),%eax
+ sbbl 24(%edx),%eax
+ movl %eax,24(%edi)
+ movl 28(%esi),%eax
+ sbbl 28(%edx),%eax
+ movl %eax,28(%edi)
+ leal 32(%edi),%edi
+ leal 32(%esi),%esi
+ leal 32(%edx),%edx
+ decl %ecx
+ jnz Loop
+
+ sbbl %eax,%eax
+ negl %eax
+
+ popl %esi
+ popl %edi
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i386/syntax.h b/grub-core/lib/libgcrypt/mpi/i386/syntax.h
new file mode 100644
index 0000000..39ede98
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i386/syntax.h
@@ -0,0 +1,68 @@
+/* syntax.h -- Definitions for x86 syntax variations.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#undef ALIGN
+
+#if defined (BSD_SYNTAX) || defined (ELF_SYNTAX)
+#define R(r) %r
+#define MEM(base)(base)
+#define MEM_DISP(base,displacement)displacement(R(base))
+#define MEM_INDEX(base,index,size)(R(base),R(index),size)
+#ifdef __STDC__
+#define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst
+#else
+#define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst
+#endif
+#define TEXT .text
+#if defined (BSD_SYNTAX)
+#define ALIGN(log) .align log
+#endif
+#if defined (ELF_SYNTAX)
+#define ALIGN(log) .align 1<<(log)
+#endif
+#define GLOBL .globl
+#endif
+
+#ifdef INTEL_SYNTAX
+#define R(r) r
+#define MEM(base)[base]
+#define MEM_DISP(base,displacement)[base+(displacement)]
+#define MEM_INDEX(base,index,size)[base+index*size]
+#define INSN1(mnemonic,size_suffix,dst)mnemonic dst
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic dst,src
+#define TEXT .text
+#define ALIGN(log) .align log
+#define GLOBL .globl
+#endif
+
+#ifdef X86_BROKEN_ALIGN
+#undef ALIGN
+#define ALIGN(log) .align log,0x90
+#endif
diff --git a/grub-core/lib/libgcrypt/mpi/i586/Manifest b/grub-core/lib/libgcrypt/mpi/i586/Manifest
new file mode 100644
index 0000000..6d1d7f8
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i586/Manifest
@@ -0,0 +1,27 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-add1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-lshift.S
+mpih-rshift.S
+mpih-sub1.S
+$names$ iQCVAwUAP+LmQDEAnp832S/7AQKCmgQAhG+E7X0KB4qdVf3sMb6Qr+Iv5Jlehzoub/5vxTRgePKzRuOHidCnTzSSoyzA++UcHrOjHQQDMsXnO6PqpS1d/TKkxjnGN7rE8mvMYlFAT8RsawTozSfh14mCzI0HTDbaKL9Z8pcMJtadB3XqAuqWJNO8kyECJFwurt3DRWXSWS8==Rug5
diff --git a/grub-core/lib/libgcrypt/mpi/i586/README b/grub-core/lib/libgcrypt/mpi/i586/README
new file mode 100644
index 0000000..d73b082
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i586/README
@@ -0,0 +1,26 @@
+This directory contains mpn functions optimized for Intel Pentium
+processors.
+
+RELEVANT OPTIMIZATION ISSUES
+
+1. Pentium doesn't allocate cache lines on writes, unlike most other modern
+processors. Since the functions in the mpn class do array writes, we have to
+handle allocating the destination cache lines by reading a word from it in the
+loops, to achieve the best performance.
+
+2. Pairing of memory operations requires that the two issued operations refer
+to different cache banks. The simplest way to insure this is to read/write
+two words from the same object. If we make operations on different objects,
+they might or might not be to the same cache bank.
+
+STATUS
+
+1. mpn_lshift and mpn_rshift run at about 6 cycles/limb, but the Pentium
+documentation indicates that they should take only 43/8 = 5.375 cycles/limb,
+or 5 cycles/limb asymptotically.
+
+2. mpn_add_n and mpn_sub_n run at asymptotically 2 cycles/limb. Due to loop
+overhead and other delays (cache refill?), they run at or near 2.5 cycles/limb.
+
+3. mpn_mul_1, mpn_addmul_1, mpn_submul_1 all run 1 cycle faster than they
+should...
diff --git a/grub-core/lib/libgcrypt/mpi/i586/distfiles b/grub-core/lib/libgcrypt/mpi/i586/distfiles
new file mode 100644
index 0000000..546f777
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i586/distfiles
@@ -0,0 +1,10 @@
+Manifest
+mpih-add1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-lshift.S
+mpih-rshift.S
+mpih-sub1.S
+README
+
diff --git a/grub-core/lib/libgcrypt/mpi/i586/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/i586/mpih-add1.S
new file mode 100644
index 0000000..7436d59
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i586/mpih-add1.S
@@ -0,0 +1,135 @@
+/* i80586 add_n -- Add two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_ptr_t s2_ptr, (sp + 12)
+ * mpi_size_t size) (sp + 16)
+ */
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_add_n)
+C_SYMBOL_NAME(_gcry_mpih_add_n:)
+ pushl %edi
+ pushl %esi
+ pushl %ebx
+ pushl %ebp
+
+ movl 20(%esp),%edi /* res_ptr */
+ movl 24(%esp),%esi /* s1_ptr */
+ movl 28(%esp),%ebp /* s2_ptr */
+ movl 32(%esp),%ecx /* size */
+
+ movl (%ebp),%ebx
+
+ decl %ecx
+ movl %ecx,%edx
+ shrl $3,%ecx
+ andl $7,%edx
+ testl %ecx,%ecx /* zero carry flag */
+ jz Lend
+ pushl %edx
+
+ ALIGN (3)
+Loop: movl 28(%edi),%eax /* fetch destination cache line */
+ leal 32(%edi),%edi
+
+L1: movl (%esi),%eax
+ movl 4(%esi),%edx
+ adcl %ebx,%eax
+ movl 4(%ebp),%ebx
+ adcl %ebx,%edx
+ movl 8(%ebp),%ebx
+ movl %eax,-32(%edi)
+ movl %edx,-28(%edi)
+
+L2: movl 8(%esi),%eax
+ movl 12(%esi),%edx
+ adcl %ebx,%eax
+ movl 12(%ebp),%ebx
+ adcl %ebx,%edx
+ movl 16(%ebp),%ebx
+ movl %eax,-24(%edi)
+ movl %edx,-20(%edi)
+
+L3: movl 16(%esi),%eax
+ movl 20(%esi),%edx
+ adcl %ebx,%eax
+ movl 20(%ebp),%ebx
+ adcl %ebx,%edx
+ movl 24(%ebp),%ebx
+ movl %eax,-16(%edi)
+ movl %edx,-12(%edi)
+
+L4: movl 24(%esi),%eax
+ movl 28(%esi),%edx
+ adcl %ebx,%eax
+ movl 28(%ebp),%ebx
+ adcl %ebx,%edx
+ movl 32(%ebp),%ebx
+ movl %eax,-8(%edi)
+ movl %edx,-4(%edi)
+
+ leal 32(%esi),%esi
+ leal 32(%ebp),%ebp
+ decl %ecx
+ jnz Loop
+
+ popl %edx
+Lend:
+ decl %edx /* test %edx w/o clobbering carry */
+ js Lend2
+ incl %edx
+Loop2:
+ leal 4(%edi),%edi
+ movl (%esi),%eax
+ adcl %ebx,%eax
+ movl 4(%ebp),%ebx
+ movl %eax,-4(%edi)
+ leal 4(%esi),%esi
+ leal 4(%ebp),%ebp
+ decl %edx
+ jnz Loop2
+Lend2:
+ movl (%esi),%eax
+ adcl %ebx,%eax
+ movl %eax,(%edi)
+
+ sbbl %eax,%eax
+ negl %eax
+
+ popl %ebp
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/i586/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/i586/mpih-lshift.S
new file mode 100644
index 0000000..9d25fe9
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i586/mpih-lshift.S
@@ -0,0 +1,229 @@
+/* i80586 lshift
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp, (sp + 4)
+ * mpi_ptr_t up, (sp + 8)
+ * mpi_size_t usize, (sp + 12)
+ * unsigned cnt) (sp + 16)
+ */
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_lshift)
+C_SYMBOL_NAME(_gcry_mpih_lshift:)
+
+ pushl %edi
+ pushl %esi
+ pushl %ebx
+ pushl %ebp
+
+ movl 20(%esp),%edi /* res_ptr */
+ movl 24(%esp),%esi /* s_ptr */
+ movl 28(%esp),%ebp /* size */
+ movl 32(%esp),%ecx /* cnt */
+
+/* We can use faster code for shift-by-1 under certain conditions. */
+ cmp $1,%ecx
+ jne Lnormal
+ leal 4(%esi),%eax
+ cmpl %edi,%eax
+ jnc Lspecial /* jump if s_ptr + 1 >= res_ptr */
+ leal (%esi,%ebp,4),%eax
+ cmpl %eax,%edi
+ jnc Lspecial /* jump if res_ptr >= s_ptr + size */
+
+Lnormal:
+ leal -4(%edi,%ebp,4),%edi
+ leal -4(%esi,%ebp,4),%esi
+
+ movl (%esi),%edx
+ subl $4,%esi
+ xorl %eax,%eax
+ shldl %cl,%edx,%eax /* compute carry limb */
+ pushl %eax /* push carry limb onto stack */
+
+ decl %ebp
+ pushl %ebp
+ shrl $3,%ebp
+ jz Lend
+
+ movl (%edi),%eax /* fetch destination cache line */
+
+ ALIGN (2)
+Loop: movl -28(%edi),%eax /* fetch destination cache line */
+ movl %edx,%ebx
+
+ movl (%esi),%eax
+ movl -4(%esi),%edx
+ shldl %cl,%eax,%ebx
+ shldl %cl,%edx,%eax
+ movl %ebx,(%edi)
+ movl %eax,-4(%edi)
+
+ movl -8(%esi),%ebx
+ movl -12(%esi),%eax
+ shldl %cl,%ebx,%edx
+ shldl %cl,%eax,%ebx
+ movl %edx,-8(%edi)
+ movl %ebx,-12(%edi)
+
+ movl -16(%esi),%edx
+ movl -20(%esi),%ebx
+ shldl %cl,%edx,%eax
+ shldl %cl,%ebx,%edx
+ movl %eax,-16(%edi)
+ movl %edx,-20(%edi)
+
+ movl -24(%esi),%eax
+ movl -28(%esi),%edx
+ shldl %cl,%eax,%ebx
+ shldl %cl,%edx,%eax
+ movl %ebx,-24(%edi)
+ movl %eax,-28(%edi)
+
+ subl $32,%esi
+ subl $32,%edi
+ decl %ebp
+ jnz Loop
+
+Lend: popl %ebp
+ andl $7,%ebp
+ jz Lend2
+Loop2: movl (%esi),%eax
+ shldl %cl,%eax,%edx
+ movl %edx,(%edi)
+ movl %eax,%edx
+ subl $4,%esi
+ subl $4,%edi
+ decl %ebp
+ jnz Loop2
+
+Lend2: shll %cl,%edx /* compute least significant limb */
+ movl %edx,(%edi) /* store it */
+
+ popl %eax /* pop carry limb */
+
+ popl %ebp
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
+/* We loop from least significant end of the arrays, which is only
+ permissable if the source and destination don't overlap, since the
+ function is documented to work for overlapping source and destination.
+*/
+
+Lspecial:
+ movl (%esi),%edx
+ addl $4,%esi
+
+ decl %ebp
+ pushl %ebp
+ shrl $3,%ebp
+
+ addl %edx,%edx
+ incl %ebp
+ decl %ebp
+ jz LLend
+
+ movl (%edi),%eax /* fetch destination cache line */
+
+ ALIGN (2)
+LLoop: movl 28(%edi),%eax /* fetch destination cache line */
+ movl %edx,%ebx
+
+ movl (%esi),%eax
+ movl 4(%esi),%edx
+ adcl %eax,%eax
+ movl %ebx,(%edi)
+ adcl %edx,%edx
+ movl %eax,4(%edi)
+
+ movl 8(%esi),%ebx
+ movl 12(%esi),%eax
+ adcl %ebx,%ebx
+ movl %edx,8(%edi)
+ adcl %eax,%eax
+ movl %ebx,12(%edi)
+
+ movl 16(%esi),%edx
+ movl 20(%esi),%ebx
+ adcl %edx,%edx
+ movl %eax,16(%edi)
+ adcl %ebx,%ebx
+ movl %edx,20(%edi)
+
+ movl 24(%esi),%eax
+ movl 28(%esi),%edx
+ adcl %eax,%eax
+ movl %ebx,24(%edi)
+ adcl %edx,%edx
+ movl %eax,28(%edi)
+
+ leal 32(%esi),%esi /* use leal not to clobber carry */
+ leal 32(%edi),%edi
+ decl %ebp
+ jnz LLoop
+
+LLend: popl %ebp
+ sbbl %eax,%eax /* save carry in %eax */
+ andl $7,%ebp
+ jz LLend2
+ addl %eax,%eax /* restore carry from eax */
+LLoop2: movl %edx,%ebx
+ movl (%esi),%edx
+ adcl %edx,%edx
+ movl %ebx,(%edi)
+
+ leal 4(%esi),%esi /* use leal not to clobber carry */
+ leal 4(%edi),%edi
+ decl %ebp
+ jnz LLoop2
+
+ jmp LL1
+LLend2: addl %eax,%eax /* restore carry from eax */
+LL1: movl %edx,(%edi) /* store last limb */
+
+ sbbl %eax,%eax
+ negl %eax
+
+ popl %ebp
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/i586/mpih-mul1.S b/grub-core/lib/libgcrypt/mpi/i586/mpih-mul1.S
new file mode 100644
index 0000000..3601d96
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i586/mpih-mul1.S
@@ -0,0 +1,89 @@
+/* i80586 mul_1 -- Multiply a limb vector with a limb and store
+ * the result in a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ */
+
+#define res_ptr edi
+#define s1_ptr esi
+#define size ecx
+#define s2_limb ebp
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1)
+C_SYMBOL_NAME(_gcry_mpih_mul_1:)
+
+ INSN1(push,l ,R(edi))
+ INSN1(push,l ,R(esi))
+ INSN1(push,l ,R(ebx))
+ INSN1(push,l ,R(ebp))
+
+ INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
+ INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
+ INSN2(mov,l ,R(size),MEM_DISP(esp,28))
+ INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
+
+ INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
+ INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
+ INSN1(neg,l ,R(size))
+ INSN2(xor,l ,R(ebx),R(ebx))
+ ALIGN (3)
+
+Loop: INSN2(adc,l ,R(ebx),$0)
+ INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
+
+ INSN1(mul,l ,R(s2_limb))
+
+ INSN2(add,l ,R(ebx),R(eax))
+
+ INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(ebx))
+ INSN1(inc,l ,R(size))
+
+ INSN2(mov,l ,R(ebx),R(edx))
+ INSN1(jnz, ,Loop)
+
+ INSN2(adc,l ,R(ebx),$0)
+ INSN2(mov,l ,R(eax),R(ebx))
+ INSN1(pop,l ,R(ebp))
+ INSN1(pop,l ,R(ebx))
+ INSN1(pop,l ,R(esi))
+ INSN1(pop,l ,R(edi))
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i586/mpih-mul2.S b/grub-core/lib/libgcrypt/mpi/i586/mpih-mul2.S
new file mode 100644
index 0000000..f32d363
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i586/mpih-mul2.S
@@ -0,0 +1,93 @@
+/* i80586 addmul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ */
+
+#define res_ptr edi
+#define s1_ptr esi
+#define size ecx
+#define s2_limb ebp
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1)
+C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
+
+ INSN1(push,l ,R(edi))
+ INSN1(push,l ,R(esi))
+ INSN1(push,l ,R(ebx))
+ INSN1(push,l ,R(ebp))
+
+ INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
+ INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
+ INSN2(mov,l ,R(size),MEM_DISP(esp,28))
+ INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
+
+ INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
+ INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
+ INSN1(neg,l ,R(size))
+ INSN2(xor,l ,R(ebx),R(ebx))
+ ALIGN (3)
+
+Loop: INSN2(adc,l ,R(ebx),$0)
+ INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
+
+ INSN1(mul,l ,R(s2_limb))
+
+ INSN2(add,l ,R(eax),R(ebx))
+ INSN2(mov,l ,R(ebx),MEM_INDEX(res_ptr,size,4))
+
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(add,l ,R(ebx),R(eax))
+
+ INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(ebx))
+ INSN1(inc,l ,R(size))
+
+ INSN2(mov,l ,R(ebx),R(edx))
+ INSN1(jnz, ,Loop)
+
+ INSN2(adc,l ,R(ebx),$0)
+ INSN2(mov,l ,R(eax),R(ebx))
+ INSN1(pop,l ,R(ebp))
+ INSN1(pop,l ,R(ebx))
+ INSN1(pop,l ,R(esi))
+ INSN1(pop,l ,R(edi))
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i586/mpih-mul3.S b/grub-core/lib/libgcrypt/mpi/i586/mpih-mul3.S
new file mode 100644
index 0000000..fa27d4e
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i586/mpih-mul3.S
@@ -0,0 +1,93 @@
+/* i80586 submul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ */
+
+#define res_ptr edi
+#define s1_ptr esi
+#define size ecx
+#define s2_limb ebp
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1)
+C_SYMBOL_NAME(_gcry_mpih_submul_1:)
+
+ INSN1(push,l ,R(edi))
+ INSN1(push,l ,R(esi))
+ INSN1(push,l ,R(ebx))
+ INSN1(push,l ,R(ebp))
+
+ INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
+ INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
+ INSN2(mov,l ,R(size),MEM_DISP(esp,28))
+ INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
+
+ INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
+ INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
+ INSN1(neg,l ,R(size))
+ INSN2(xor,l ,R(ebx),R(ebx))
+ ALIGN (3)
+
+Loop: INSN2(adc,l ,R(ebx),$0)
+ INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
+
+ INSN1(mul,l ,R(s2_limb))
+
+ INSN2(add,l ,R(eax),R(ebx))
+ INSN2(mov,l ,R(ebx),MEM_INDEX(res_ptr,size,4))
+
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(sub,l ,R(ebx),R(eax))
+
+ INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(ebx))
+ INSN1(inc,l ,R(size))
+
+ INSN2(mov,l ,R(ebx),R(edx))
+ INSN1(jnz, ,Loop)
+
+ INSN2(adc,l ,R(ebx),$0)
+ INSN2(mov,l ,R(eax),R(ebx))
+ INSN1(pop,l ,R(ebp))
+ INSN1(pop,l ,R(ebx))
+ INSN1(pop,l ,R(esi))
+ INSN1(pop,l ,R(edi))
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i586/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/i586/mpih-rshift.S
new file mode 100644
index 0000000..c661e3d
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i586/mpih-rshift.S
@@ -0,0 +1,228 @@
+/* i80586 rshift
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp, (sp + 4)
+ * mpi_ptr_t up, (sp + 8)
+ * mpi_size_t usize, (sp + 12)
+ * unsigned cnt) (sp + 16)
+ */
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_rshift)
+C_SYMBOL_NAME(_gcry_mpih_rshift:)
+ pushl %edi
+ pushl %esi
+ pushl %ebx
+ pushl %ebp
+
+ movl 20(%esp),%edi /* res_ptr */
+ movl 24(%esp),%esi /* s_ptr */
+ movl 28(%esp),%ebp /* size */
+ movl 32(%esp),%ecx /* cnt */
+
+/* We can use faster code for shift-by-1 under certain conditions. */
+ cmp $1,%ecx
+ jne Rnormal
+ leal 4(%edi),%eax
+ cmpl %esi,%eax
+ jnc Rspecial /* jump if res_ptr + 1 >= s_ptr */
+ leal (%edi,%ebp,4),%eax
+ cmpl %eax,%esi
+ jnc Rspecial /* jump if s_ptr >= res_ptr + size */
+
+Rnormal:
+ movl (%esi),%edx
+ addl $4,%esi
+ xorl %eax,%eax
+ shrdl %cl,%edx,%eax /* compute carry limb */
+ pushl %eax /* push carry limb onto stack */
+
+ decl %ebp
+ pushl %ebp
+ shrl $3,%ebp
+ jz Rend
+
+ movl (%edi),%eax /* fetch destination cache line */
+
+ ALIGN (2)
+Roop: movl 28(%edi),%eax /* fetch destination cache line */
+ movl %edx,%ebx
+
+ movl (%esi),%eax
+ movl 4(%esi),%edx
+ shrdl %cl,%eax,%ebx
+ shrdl %cl,%edx,%eax
+ movl %ebx,(%edi)
+ movl %eax,4(%edi)
+
+ movl 8(%esi),%ebx
+ movl 12(%esi),%eax
+ shrdl %cl,%ebx,%edx
+ shrdl %cl,%eax,%ebx
+ movl %edx,8(%edi)
+ movl %ebx,12(%edi)
+
+ movl 16(%esi),%edx
+ movl 20(%esi),%ebx
+ shrdl %cl,%edx,%eax
+ shrdl %cl,%ebx,%edx
+ movl %eax,16(%edi)
+ movl %edx,20(%edi)
+
+ movl 24(%esi),%eax
+ movl 28(%esi),%edx
+ shrdl %cl,%eax,%ebx
+ shrdl %cl,%edx,%eax
+ movl %ebx,24(%edi)
+ movl %eax,28(%edi)
+
+ addl $32,%esi
+ addl $32,%edi
+ decl %ebp
+ jnz Roop
+
+Rend: popl %ebp
+ andl $7,%ebp
+ jz Rend2
+Roop2: movl (%esi),%eax
+ shrdl %cl,%eax,%edx /* compute result limb */
+ movl %edx,(%edi)
+ movl %eax,%edx
+ addl $4,%esi
+ addl $4,%edi
+ decl %ebp
+ jnz Roop2
+
+Rend2: shrl %cl,%edx /* compute most significant limb */
+ movl %edx,(%edi) /* store it */
+
+ popl %eax /* pop carry limb */
+
+ popl %ebp
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
+/* We loop from least significant end of the arrays, which is only
+ permissable if the source and destination don't overlap, since the
+ function is documented to work for overlapping source and destination.
+*/
+
+Rspecial:
+ leal -4(%edi,%ebp,4),%edi
+ leal -4(%esi,%ebp,4),%esi
+
+ movl (%esi),%edx
+ subl $4,%esi
+
+ decl %ebp
+ pushl %ebp
+ shrl $3,%ebp
+
+ shrl $1,%edx
+ incl %ebp
+ decl %ebp
+ jz RLend
+
+ movl (%edi),%eax /* fetch destination cache line */
+
+ ALIGN (2)
+RLoop: movl -28(%edi),%eax /* fetch destination cache line */
+ movl %edx,%ebx
+
+ movl (%esi),%eax
+ movl -4(%esi),%edx
+ rcrl $1,%eax
+ movl %ebx,(%edi)
+ rcrl $1,%edx
+ movl %eax,-4(%edi)
+
+ movl -8(%esi),%ebx
+ movl -12(%esi),%eax
+ rcrl $1,%ebx
+ movl %edx,-8(%edi)
+ rcrl $1,%eax
+ movl %ebx,-12(%edi)
+
+ movl -16(%esi),%edx
+ movl -20(%esi),%ebx
+ rcrl $1,%edx
+ movl %eax,-16(%edi)
+ rcrl $1,%ebx
+ movl %edx,-20(%edi)
+
+ movl -24(%esi),%eax
+ movl -28(%esi),%edx
+ rcrl $1,%eax
+ movl %ebx,-24(%edi)
+ rcrl $1,%edx
+ movl %eax,-28(%edi)
+
+ leal -32(%esi),%esi /* use leal not to clobber carry */
+ leal -32(%edi),%edi
+ decl %ebp
+ jnz RLoop
+
+RLend: popl %ebp
+ sbbl %eax,%eax /* save carry in %eax */
+ andl $7,%ebp
+ jz RLend2
+ addl %eax,%eax /* restore carry from eax */
+RLoop2: movl %edx,%ebx
+ movl (%esi),%edx
+ rcrl $1,%edx
+ movl %ebx,(%edi)
+
+ leal -4(%esi),%esi /* use leal not to clobber carry */
+ leal -4(%edi),%edi
+ decl %ebp
+ jnz RLoop2
+
+ jmp RL1
+RLend2: addl %eax,%eax /* restore carry from eax */
+RL1: movl %edx,(%edi) /* store last limb */
+
+ movl $0,%eax
+ rcrl $1,%eax
+
+ popl %ebp
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/i586/mpih-sub1.S b/grub-core/lib/libgcrypt/mpi/i586/mpih-sub1.S
new file mode 100644
index 0000000..ef2d580
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/i586/mpih-sub1.S
@@ -0,0 +1,142 @@
+/* i80586 sub_n -- Sub two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_ptr_t s2_ptr, (sp + 12)
+ * mpi_size_t size) (sp + 16)
+ */
+
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_sub_n)
+C_SYMBOL_NAME(_gcry_mpih_sub_n:)
+
+ pushl %edi
+ pushl %esi
+ pushl %ebx
+ pushl %ebp
+
+ movl 20(%esp),%edi /* res_ptr */
+ movl 24(%esp),%esi /* s1_ptr */
+ movl 28(%esp),%ebp /* s2_ptr */
+ movl 32(%esp),%ecx /* size */
+
+ movl (%ebp),%ebx
+
+ decl %ecx
+ movl %ecx,%edx
+ shrl $3,%ecx
+ andl $7,%edx
+ testl %ecx,%ecx /* zero carry flag */
+ jz Lend
+ pushl %edx
+
+ ALIGN (3)
+Loop: movl 28(%edi),%eax /* fetch destination cache line */
+ leal 32(%edi),%edi
+
+L1: movl (%esi),%eax
+ movl 4(%esi),%edx
+ sbbl %ebx,%eax
+ movl 4(%ebp),%ebx
+ sbbl %ebx,%edx
+ movl 8(%ebp),%ebx
+ movl %eax,-32(%edi)
+ movl %edx,-28(%edi)
+
+L2: movl 8(%esi),%eax
+ movl 12(%esi),%edx
+ sbbl %ebx,%eax
+ movl 12(%ebp),%ebx
+ sbbl %ebx,%edx
+ movl 16(%ebp),%ebx
+ movl %eax,-24(%edi)
+ movl %edx,-20(%edi)
+
+L3: movl 16(%esi),%eax
+ movl 20(%esi),%edx
+ sbbl %ebx,%eax
+ movl 20(%ebp),%ebx
+ sbbl %ebx,%edx
+ movl 24(%ebp),%ebx
+ movl %eax,-16(%edi)
+ movl %edx,-12(%edi)
+
+L4: movl 24(%esi),%eax
+ movl 28(%esi),%edx
+ sbbl %ebx,%eax
+ movl 28(%ebp),%ebx
+ sbbl %ebx,%edx
+ movl 32(%ebp),%ebx
+ movl %eax,-8(%edi)
+ movl %edx,-4(%edi)
+
+ leal 32(%esi),%esi
+ leal 32(%ebp),%ebp
+ decl %ecx
+ jnz Loop
+
+ popl %edx
+Lend:
+ decl %edx /* test %edx w/o clobbering carry */
+ js Lend2
+ incl %edx
+Loop2:
+ leal 4(%edi),%edi
+ movl (%esi),%eax
+ sbbl %ebx,%eax
+ movl 4(%ebp),%ebx
+ movl %eax,-4(%edi)
+ leal 4(%esi),%esi
+ leal 4(%ebp),%ebp
+ decl %edx
+ jnz Loop2
+Lend2:
+ movl (%esi),%eax
+ sbbl %ebx,%eax
+ movl %eax,(%edi)
+
+ sbbl %eax,%eax
+ negl %eax
+
+ popl %ebp
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/longlong.h b/grub-core/lib/libgcrypt/mpi/longlong.h
new file mode 100644
index 0000000..b3fce09
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/longlong.h
@@ -0,0 +1,1613 @@
+/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
+ Note: I added some stuff for use with gnupg
+
+Copyright (C) 1991, 1992, 1993, 1994, 1996, 1998,
+ 2000, 2001, 2002, 2003, 2004, 2011 Free Software Foundation, Inc.
+
+This file is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or (at your
+option) any later version.
+
+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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Library General Public License
+along with this file; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/* You have to define the following before including this file:
+
+ UWtype -- An unsigned type, default type for operations (typically a "word")
+ UHWtype -- An unsigned type, at least half the size of UWtype.
+ UDWtype -- An unsigned type, at least twice as large a UWtype
+ W_TYPE_SIZE -- size in bits of UWtype
+
+ SItype, USItype -- Signed and unsigned 32 bit types.
+ DItype, UDItype -- Signed and unsigned 64 bit types.
+
+ On a 32 bit machine UWtype should typically be USItype;
+ on a 64 bit machine, UWtype should typically be UDItype.
+*/
+
+#define __BITS4 (W_TYPE_SIZE / 4)
+#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
+#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
+#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
+
+/* This is used to make sure no undesirable sharing between different libraries
+ that use this file takes place. */
+#ifndef __MPN
+#define __MPN(x) __##x
+#endif
+
+/* Define auxiliary asm macros.
+
+ 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) multiplies two
+ UWtype integers MULTIPLER and MULTIPLICAND, and generates a two UWtype
+ word product in HIGH_PROD and LOW_PROD.
+
+ 2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a
+ UDWtype product. This is just a variant of umul_ppmm.
+
+ 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
+ denominator) divides a UDWtype, composed by the UWtype integers
+ HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
+ in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
+ than DENOMINATOR for correct operation. If, in addition, the most
+ significant bit of DENOMINATOR must be 1, then the pre-processor symbol
+ UDIV_NEEDS_NORMALIZATION is defined to 1.
+
+ 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
+ denominator). Like udiv_qrnnd but the numbers are signed. The quotient
+ is rounded towards 0.
+
+ 5) count_leading_zeros(count, x) counts the number of zero-bits from the
+ msb to the first non-zero bit in the UWtype X. This is the number of
+ steps X needs to be shifted left to set the msb. Undefined for X == 0,
+ unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
+
+ 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts
+ from the least significant end.
+
+ 7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
+ high_addend_2, low_addend_2) adds two UWtype integers, composed by
+ HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2
+ respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow
+ (i.e. carry out) is not stored anywhere, and is lost.
+
+ 8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend,
+ high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
+ composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
+ LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE
+ and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
+ and is lost.
+
+ If any of these macros are left undefined for a particular CPU,
+ C macros are used. */
+
+/* The CPUs come in alphabetical order below.
+
+ Please add support for more CPUs here, or improve the current support
+ for the CPUs below! */
+
+#ifdef __riscos__
+#pragma continue_after_hash_error
+#else /* !__riscos__ */
+#if defined (__GNUC__) && !defined (NO_ASM)
+
+/* We sometimes need to clobber "cc" with gcc2, but that would not be
+ understood by gcc1. Use cpp to avoid major code duplication. */
+#if __GNUC__ < 2
+#define __CLOBBER_CC
+#define __AND_CLOBBER_CC
+#else /* __GNUC__ >= 2 */
+#define __CLOBBER_CC : "cc"
+#define __AND_CLOBBER_CC , "cc"
+#endif /* __GNUC__ < 2 */
+
+
+/***************************************
+ ************** A29K *****************
+ ***************************************/
+#if (defined (__a29k__) || defined (_AM29K)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add %1,%4,%5\n" \
+ "addc %0,%2,%3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%r" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "%r" ((USItype)(al)), \
+ "rI" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub %1,%4,%5\n" \
+ "subc %0,%2,%3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "r" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "r" ((USItype)(al)), \
+ "rI" ((USItype)(bl)))
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("multiplu %0,%1,%2" \
+ : "=r" ((USItype)(xl)) \
+ : "r" (__m0), \
+ "r" (__m1)); \
+ __asm__ ("multmu %0,%1,%2" \
+ : "=r" ((USItype)(xh)) \
+ : "r" (__m0), \
+ "r" (__m1)); \
+ } while (0)
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("dividu %0,%3,%4" \
+ : "=r" ((USItype)(q)), \
+ "=q" ((USItype)(r)) \
+ : "1" ((USItype)(n1)), \
+ "r" ((USItype)(n0)), \
+ "r" ((USItype)(d)))
+#define count_leading_zeros(count, x) \
+ __asm__ ("clz %0,%1" \
+ : "=r" ((USItype)(count)) \
+ : "r" ((USItype)(x)))
+#define COUNT_LEADING_ZEROS_0 32
+#endif /* __a29k__ */
+
+
+#if defined (__alpha) && W_TYPE_SIZE == 64
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ UDItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("umulh %r1,%2,%0" \
+ : "=r" ((UDItype) ph) \
+ : "%rJ" (__m0), \
+ "rI" (__m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define UMUL_TIME 46
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { UDItype __r; \
+ (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
+ (r) = __r; \
+ } while (0)
+extern UDItype __udiv_qrnnd ();
+#define UDIV_TIME 220
+#endif /* LONGLONG_STANDALONE */
+#endif /* __alpha */
+
+/***************************************
+ ************** ARM ******************
+ ***************************************/
+#if defined (__arm__) && W_TYPE_SIZE == 32 && \
+ (!defined (__thumb__) || defined (__thumb2__))
+/* The __ARM_ARCH define is provided by gcc 4.8. Construct it otherwise. */
+#ifndef __ARM_ARCH
+# ifdef __ARM_ARCH_2__
+# define __ARM_ARCH 2
+# elif defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
+# define __ARM_ARCH 3
+# elif defined (__ARM_ARCH_4__) || defined (__ARM_ARCH_4T__)
+# define __ARM_ARCH 4
+# elif defined (__ARM_ARCH_5__) || defined (__ARM_ARCH_5E__) \
+ || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) \
+ || defined(__ARM_ARCH_5TEJ__)
+# define __ARM_ARCH 5
+# elif defined (__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
+ || defined (__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
+ || defined (__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__)
+# define __ARM_ARCH 6
+# elif defined (__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
+ || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
+ || defined(__ARM_ARCH_7EM__)
+# define __ARM_ARCH 7
+# else
+ /* could not detect? */
+# endif
+#endif
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("adds %1, %4, %5\n" \
+ "adc %0, %2, %3" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "%r" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "%r" ((USItype)(al)), \
+ "rI" ((USItype)(bl)) __CLOBBER_CC)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subs %1, %4, %5\n" \
+ "sbc %0, %2, %3" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "r" ((USItype)(al)), \
+ "rI" ((USItype)(bl)) __CLOBBER_CC)
+#if (defined __ARM_ARCH && __ARM_ARCH <= 3)
+#define umul_ppmm(xh, xl, a, b) \
+ __asm__ ("@ Inlined umul_ppmm\n" \
+ "mov %|r0, %2, lsr #16 @ AAAA\n" \
+ "mov %|r2, %3, lsr #16 @ BBBB\n" \
+ "bic %|r1, %2, %|r0, lsl #16 @ aaaa\n" \
+ "bic %0, %3, %|r2, lsl #16 @ bbbb\n" \
+ "mul %1, %|r1, %|r2 @ aaaa * BBBB\n" \
+ "mul %|r2, %|r0, %|r2 @ AAAA * BBBB\n" \
+ "mul %|r1, %0, %|r1 @ aaaa * bbbb\n" \
+ "mul %0, %|r0, %0 @ AAAA * bbbb\n" \
+ "adds %|r0, %1, %0 @ central sum\n" \
+ "addcs %|r2, %|r2, #65536\n" \
+ "adds %1, %|r1, %|r0, lsl #16\n" \
+ "adc %0, %|r2, %|r0, lsr #16" \
+ : "=&r" ((xh)), \
+ "=r" ((xl)) \
+ : "r" ((USItype)(a)), \
+ "r" ((USItype)(b)) \
+ : "r0", "r1", "r2" __AND_CLOBBER_CC)
+#else /* __ARM_ARCH >= 4 */
+#define umul_ppmm(xh, xl, a, b) \
+ __asm__ ("@ Inlined umul_ppmm\n" \
+ "umull %1, %0, %2, %3" \
+ : "=&r" ((xh)), \
+ "=r" ((xl)) \
+ : "r" ((USItype)(a)), \
+ "r" ((USItype)(b)))
+#endif /* __ARM_ARCH >= 4 */
+#define UMUL_TIME 20
+#define UDIV_TIME 100
+#if (defined __ARM_ARCH && __ARM_ARCH >= 5)
+#define count_leading_zeros(count, x) \
+ __asm__ ("clz %0, %1" \
+ : "=r" ((count)) \
+ : "r" ((USItype)(x)))
+#endif /* __ARM_ARCH >= 5 */
+#endif /* __arm__ */
+
+/***************************************
+ ************** CLIPPER **************
+ ***************************************/
+#if defined (__clipper__) && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+ ({union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ __asm__ ("mulwux %2,%0" \
+ : "=r" (__xx.__ll) \
+ : "%0" ((USItype)(u)), \
+ "r" ((USItype)(v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define smul_ppmm(w1, w0, u, v) \
+ ({union {DItype __ll; \
+ struct {SItype __l, __h;} __i; \
+ } __xx; \
+ __asm__ ("mulwx %2,%0" \
+ : "=r" (__xx.__ll) \
+ : "%0" ((SItype)(u)), \
+ "r" ((SItype)(v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define __umulsidi3(u, v) \
+ ({UDItype __w; \
+ __asm__ ("mulwux %2,%0" \
+ : "=r" (__w) \
+ : "%0" ((USItype)(u)), \
+ "r" ((USItype)(v))); \
+ __w; })
+#endif /* __clipper__ */
+
+
+/***************************************
+ ************** GMICRO ***************
+ ***************************************/
+#if defined (__gmicro__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add.w %5,%1\n" \
+ "addx %3,%0" \
+ : "=g" ((USItype)(sh)), \
+ "=&g" ((USItype)(sl)) \
+ : "%0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub.w %5,%1\n" \
+ "subx %3,%0" \
+ : "=g" ((USItype)(sh)), \
+ "=&g" ((USItype)(sl)) \
+ : "0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define umul_ppmm(ph, pl, m0, m1) \
+ __asm__ ("mulx %3,%0,%1" \
+ : "=g" ((USItype)(ph)), \
+ "=r" ((USItype)(pl)) \
+ : "%0" ((USItype)(m0)), \
+ "g" ((USItype)(m1)))
+#define udiv_qrnnd(q, r, nh, nl, d) \
+ __asm__ ("divx %4,%0,%1" \
+ : "=g" ((USItype)(q)), \
+ "=r" ((USItype)(r)) \
+ : "1" ((USItype)(nh)), \
+ "0" ((USItype)(nl)), \
+ "g" ((USItype)(d)))
+#define count_leading_zeros(count, x) \
+ __asm__ ("bsch/1 %1,%0" \
+ : "=g" (count) \
+ : "g" ((USItype)(x)), \
+ "0" ((USItype)0))
+#endif
+
+
+/***************************************
+ ************** HPPA *****************
+ ***************************************/
+#if defined (__hppa) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ (" add %4,%5,%1\n" \
+ " addc %2,%3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%rM" ((USItype)(ah)), \
+ "rM" ((USItype)(bh)), \
+ "%rM" ((USItype)(al)), \
+ "rM" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ (" sub %4,%5,%1\n" \
+ " subb %2,%3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "rM" ((USItype)(ah)), \
+ "rM" ((USItype)(bh)), \
+ "rM" ((USItype)(al)), \
+ "rM" ((USItype)(bl)))
+#if defined (_PA_RISC1_1)
+#define umul_ppmm(wh, wl, u, v) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ __asm__ (" xmpyu %1,%2,%0" \
+ : "=*f" (__xx.__ll) \
+ : "*f" ((USItype)(u)), \
+ "*f" ((USItype)(v))); \
+ (wh) = __xx.__i.__h; \
+ (wl) = __xx.__i.__l; \
+ } while (0)
+#define UMUL_TIME 8
+#define UDIV_TIME 60
+#else
+#define UMUL_TIME 40
+#define UDIV_TIME 80
+#endif
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { USItype __r; \
+ (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
+ (r) = __r; \
+ } while (0)
+extern USItype __udiv_qrnnd ();
+#endif /* LONGLONG_STANDALONE */
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __tmp; \
+ __asm__ ( \
+ " ldi 1,%0 \n" \
+ " extru,= %1,15,16,%%r0 ; Bits 31..16 zero? \n" \
+ " extru,tr %1,15,16,%1 ; No. Shift down, skip add.\n" \
+ " ldo 16(%0),%0 ; Yes. Perform add. \n" \
+ " extru,= %1,23,8,%%r0 ; Bits 15..8 zero? \n" \
+ " extru,tr %1,23,8,%1 ; No. Shift down, skip add.\n" \
+ " ldo 8(%0),%0 ; Yes. Perform add. \n" \
+ " extru,= %1,27,4,%%r0 ; Bits 7..4 zero? \n" \
+ " extru,tr %1,27,4,%1 ; No. Shift down, skip add.\n" \
+ " ldo 4(%0),%0 ; Yes. Perform add. \n" \
+ " extru,= %1,29,2,%%r0 ; Bits 3..2 zero? \n" \
+ " extru,tr %1,29,2,%1 ; No. Shift down, skip add.\n" \
+ " ldo 2(%0),%0 ; Yes. Perform add. \n" \
+ " extru %1,30,1,%1 ; Extract bit 1. \n" \
+ " sub %0,%1,%0 ; Subtract it. " \
+ : "=r" (count), "=r" (__tmp) : "1" (x)); \
+ } while (0)
+#endif /* hppa */
+
+
+/***************************************
+ ************** I370 *****************
+ ***************************************/
+#if (defined (__i370__) || defined (__mvs__)) && W_TYPE_SIZE == 32
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mr %0,%3" \
+ : "=r" (__xx.__i.__h), \
+ "=r" (__xx.__i.__l) \
+ : "%1" (__m0), \
+ "r" (__m1)); \
+ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
+ (xh) += ((((SItype) __m0 >> 31) & __m1) \
+ + (((SItype) __m1 >> 31) & __m0)); \
+ } while (0)
+#define smul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {DItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ __asm__ ("mr %0,%3" \
+ : "=r" (__xx.__i.__h), \
+ "=r" (__xx.__i.__l) \
+ : "%1" (m0), \
+ "r" (m1)); \
+ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
+ } while (0)
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+ do { \
+ union {DItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ __xx.__i.__h = n1; __xx.__i.__l = n0; \
+ __asm__ ("dr %0,%2" \
+ : "=r" (__xx.__ll) \
+ : "0" (__xx.__ll), "r" (d)); \
+ (q) = __xx.__i.__l; (r) = __xx.__i.__h; \
+ } while (0)
+#endif
+
+
+/***************************************
+ ************** I386 *****************
+ ***************************************/
+#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addl %5,%1\n" \
+ "adcl %3,%0" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "%0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "g" ((USItype)(bl)) \
+ __CLOBBER_CC)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subl %5,%1\n" \
+ "sbbl %3,%0" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "g" ((USItype)(bl)) \
+ __CLOBBER_CC)
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("mull %3" \
+ : "=a" ((w0)), \
+ "=d" ((w1)) \
+ : "%0" ((USItype)(u)), \
+ "rm" ((USItype)(v)) \
+ __CLOBBER_CC)
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("divl %4" \
+ : "=a" ((q)), \
+ "=d" ((r)) \
+ : "0" ((USItype)(n0)), \
+ "1" ((USItype)(n1)), \
+ "rm" ((USItype)(d)) \
+ __CLOBBER_CC)
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __cbtmp; \
+ __asm__ ("bsrl %1,%0" \
+ : "=r" (__cbtmp) : "rm" ((USItype)(x)) \
+ __CLOBBER_CC); \
+ (count) = __cbtmp ^ 31; \
+ } while (0)
+#define count_trailing_zeros(count, x) \
+ __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((USItype)(x)) __CLOBBER_CC)
+#ifndef UMUL_TIME
+#define UMUL_TIME 40
+#endif
+#ifndef UDIV_TIME
+#define UDIV_TIME 40
+#endif
+#endif /* 80x86 */
+
+
+/***************************************
+ ************** I860 *****************
+ ***************************************/
+#if defined (__i860__) && W_TYPE_SIZE == 32
+#define rshift_rhlc(r,h,l,c) \
+ __asm__ ("shr %3,r0,r0\n" \
+ "shrd %1,%2,%0" \
+ "=r" (r) : "r" (h), "r" (l), "rn" (c))
+#endif /* i860 */
+
+/***************************************
+ ************** I960 *****************
+ ***************************************/
+#if defined (__i960__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("cmpo 1,0\n" \
+ "addc %5,%4,%1\n" \
+ "addc %3,%2,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%dI" ((USItype)(ah)), \
+ "dI" ((USItype)(bh)), \
+ "%dI" ((USItype)(al)), \
+ "dI" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("cmpo 0,0\n" \
+ "subc %5,%4,%1\n" \
+ "subc %3,%2,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "dI" ((USItype)(ah)), \
+ "dI" ((USItype)(bh)), \
+ "dI" ((USItype)(al)), \
+ "dI" ((USItype)(bl)))
+#define umul_ppmm(w1, w0, u, v) \
+ ({union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ __asm__ ("emul %2,%1,%0" \
+ : "=d" (__xx.__ll) \
+ : "%dI" ((USItype)(u)), \
+ "dI" ((USItype)(v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define __umulsidi3(u, v) \
+ ({UDItype __w; \
+ __asm__ ("emul %2,%1,%0" \
+ : "=d" (__w) \
+ : "%dI" ((USItype)(u)), \
+ "dI" ((USItype)(v))); \
+ __w; })
+#define udiv_qrnnd(q, r, nh, nl, d) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __nn; \
+ __nn.__i.__h = (nh); __nn.__i.__l = (nl); \
+ __asm__ ("ediv %d,%n,%0" \
+ : "=d" (__rq.__ll) \
+ : "dI" (__nn.__ll), \
+ "dI" ((USItype)(d))); \
+ (r) = __rq.__i.__l; (q) = __rq.__i.__h; \
+ } while (0)
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __cbtmp; \
+ __asm__ ("scanbit %1,%0" \
+ : "=r" (__cbtmp) \
+ : "r" ((USItype)(x))); \
+ (count) = __cbtmp ^ 31; \
+ } while (0)
+#define COUNT_LEADING_ZEROS_0 (-32) /* sic */
+#if defined (__i960mx) /* what is the proper symbol to test??? */
+#define rshift_rhlc(r,h,l,c) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __nn; \
+ __nn.__i.__h = (h); __nn.__i.__l = (l); \
+ __asm__ ("shre %2,%1,%0" \
+ : "=d" (r) : "dI" (__nn.__ll), "dI" (c)); \
+ }
+#endif /* i960mx */
+#endif /* i960 */
+
+
+/***************************************
+ ************** 68000 ****************
+ ***************************************/
+#if (defined (__mc68000__) || defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add%.l %5,%1\n" \
+ "addx%.l %3,%0" \
+ : "=d" ((USItype)(sh)), \
+ "=&d" ((USItype)(sl)) \
+ : "%0" ((USItype)(ah)), \
+ "d" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub%.l %5,%1\n" \
+ "subx%.l %3,%0" \
+ : "=d" ((USItype)(sh)), \
+ "=&d" ((USItype)(sl)) \
+ : "0" ((USItype)(ah)), \
+ "d" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("mulu%.l %3,%1:%0" \
+ : "=d" ((USItype)(w0)), \
+ "=d" ((USItype)(w1)) \
+ : "%0" ((USItype)(u)), \
+ "dmi" ((USItype)(v)))
+#define UMUL_TIME 45
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("divu%.l %4,%1:%0" \
+ : "=d" ((USItype)(q)), \
+ "=d" ((USItype)(r)) \
+ : "0" ((USItype)(n0)), \
+ "1" ((USItype)(n1)), \
+ "dmi" ((USItype)(d)))
+#define UDIV_TIME 90
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("divs%.l %4,%1:%0" \
+ : "=d" ((USItype)(q)), \
+ "=d" ((USItype)(r)) \
+ : "0" ((USItype)(n0)), \
+ "1" ((USItype)(n1)), \
+ "dmi" ((USItype)(d)))
+#define count_leading_zeros(count, x) \
+ __asm__ ("bfffo %1{%b2:%b2},%0" \
+ : "=d" ((USItype)(count)) \
+ : "od" ((USItype)(x)), "n" (0))
+#define COUNT_LEADING_ZEROS_0 32
+#else /* not mc68020 */
+#define umul_ppmm(xh, xl, a, b) \
+ do { USItype __umul_tmp1, __umul_tmp2; \
+ __asm__ ("| Inlined umul_ppmm \n" \
+ " move%.l %5,%3 \n" \
+ " move%.l %2,%0 \n" \
+ " move%.w %3,%1 \n" \
+ " swap %3 \n" \
+ " swap %0 \n" \
+ " mulu %2,%1 \n" \
+ " mulu %3,%0 \n" \
+ " mulu %2,%3 \n" \
+ " swap %2 \n" \
+ " mulu %5,%2 \n" \
+ " add%.l %3,%2 \n" \
+ " jcc 1f \n" \
+ " add%.l %#0x10000,%0 \n" \
+ "1: move%.l %2,%3 \n" \
+ " clr%.w %2 \n" \
+ " swap %2 \n" \
+ " swap %3 \n" \
+ " clr%.w %3 \n" \
+ " add%.l %3,%1 \n" \
+ " addx%.l %2,%0 \n" \
+ " | End inlined umul_ppmm" \
+ : "=&d" ((USItype)(xh)), "=&d" ((USItype)(xl)), \
+ "=d" (__umul_tmp1), "=&d" (__umul_tmp2) \
+ : "%2" ((USItype)(a)), "d" ((USItype)(b))); \
+ } while (0)
+#define UMUL_TIME 100
+#define UDIV_TIME 400
+#endif /* not mc68020 */
+#endif /* mc68000 */
+
+
+/***************************************
+ ************** 88000 ****************
+ ***************************************/
+#if defined (__m88000__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addu.co %1,%r4,%r5\n" \
+ "addu.ci %0,%r2,%r3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%rJ" ((USItype)(ah)), \
+ "rJ" ((USItype)(bh)), \
+ "%rJ" ((USItype)(al)), \
+ "rJ" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subu.co %1,%r4,%r5\n" \
+ "subu.ci %0,%r2,%r3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "rJ" ((USItype)(ah)), \
+ "rJ" ((USItype)(bh)), \
+ "rJ" ((USItype)(al)), \
+ "rJ" ((USItype)(bl)))
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __cbtmp; \
+ __asm__ ("ff1 %0,%1" \
+ : "=r" (__cbtmp) \
+ : "r" ((USItype)(x))); \
+ (count) = __cbtmp ^ 31; \
+ } while (0)
+#define COUNT_LEADING_ZEROS_0 63 /* sic */
+#if defined (__m88110__)
+#define umul_ppmm(wh, wl, u, v) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __x; \
+ __asm__ ("mulu.d %0,%1,%2" : "=r" (__x.__ll) : "r" (u), "r" (v)); \
+ (wh) = __x.__i.__h; \
+ (wl) = __x.__i.__l; \
+ } while (0)
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ ({union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __x, __q; \
+ __x.__i.__h = (n1); __x.__i.__l = (n0); \
+ __asm__ ("divu.d %0,%1,%2" \
+ : "=r" (__q.__ll) : "r" (__x.__ll), "r" (d)); \
+ (r) = (n0) - __q.__l * (d); (q) = __q.__l; })
+#define UMUL_TIME 5
+#define UDIV_TIME 25
+#else
+#define UMUL_TIME 17
+#define UDIV_TIME 150
+#endif /* __m88110__ */
+#endif /* __m88000__ */
+
+/***************************************
+ ************** MIPS *****************
+ ***************************************/
+#if defined (__mips__) && W_TYPE_SIZE == 32
+#if defined (__clang__) || (__GNUC__ >= 5) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ UDItype _r; \
+ _r = (UDItype) u * v; \
+ (w1) = _r >> 32; \
+ (w0) = (USItype) _r; \
+ } while (0)
+#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("multu %2,%3" \
+ : "=l" ((USItype)(w0)), \
+ "=h" ((USItype)(w1)) \
+ : "d" ((USItype)(u)), \
+ "d" ((USItype)(v)))
+#else
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("multu %2,%3 \n" \
+ "mflo %0 \n" \
+ "mfhi %1" \
+ : "=d" ((USItype)(w0)), \
+ "=d" ((USItype)(w1)) \
+ : "d" ((USItype)(u)), \
+ "d" ((USItype)(v)))
+#endif
+#define UMUL_TIME 10
+#define UDIV_TIME 100
+#endif /* __mips__ */
+
+/***************************************
+ ************** MIPS/64 **************
+ ***************************************/
+#if (defined (__mips) && __mips >= 3) && W_TYPE_SIZE == 64
+#if (__GNUC__ >= 5) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+typedef unsigned int UTItype __attribute__ ((mode (TI)));
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ UTItype _r; \
+ _r = (UTItype) u * v; \
+ (w1) = _r >> 64; \
+ (w0) = (UDItype) _r; \
+ } while (0)
+#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("dmultu %2,%3" \
+ : "=l" ((UDItype)(w0)), \
+ "=h" ((UDItype)(w1)) \
+ : "d" ((UDItype)(u)), \
+ "d" ((UDItype)(v)))
+#else
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("dmultu %2,%3 \n" \
+ "mflo %0 \n" \
+ "mfhi %1" \
+ : "=d" ((UDItype)(w0)), \
+ "=d" ((UDItype)(w1)) \
+ : "d" ((UDItype)(u)), \
+ "d" ((UDItype)(v)))
+#endif
+#define UMUL_TIME 20
+#define UDIV_TIME 140
+#endif /* __mips__ */
+
+
+/***************************************
+ ************** 32000 ****************
+ ***************************************/
+#if defined (__ns32000__) && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+ ({union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ __asm__ ("meid %2,%0" \
+ : "=g" (__xx.__ll) \
+ : "%0" ((USItype)(u)), \
+ "g" ((USItype)(v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define __umulsidi3(u, v) \
+ ({UDItype __w; \
+ __asm__ ("meid %2,%0" \
+ : "=g" (__w) \
+ : "%0" ((USItype)(u)), \
+ "g" ((USItype)(v))); \
+ __w; })
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ ({union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
+ __asm__ ("deid %2,%0" \
+ : "=g" (__xx.__ll) \
+ : "0" (__xx.__ll), \
+ "g" ((USItype)(d))); \
+ (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
+#define count_trailing_zeros(count,x) \
+ do {
+ __asm__ ("ffsd %2,%0" \
+ : "=r" ((USItype) (count)) \
+ : "0" ((USItype) 0), \
+ "r" ((USItype) (x))); \
+ } while (0)
+#endif /* __ns32000__ */
+
+
+/***************************************
+ ************** PPC ******************
+ ***************************************/
+#if (defined (_ARCH_PPC) || defined (_IBMR2)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "%r" ((USItype)(ah)), \
+ "%r" ((USItype)(al)), \
+ "rI" ((USItype)(bl))); \
+ else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "%r" ((USItype)(ah)), \
+ "%r" ((USItype)(al)), \
+ "rI" ((USItype)(bl))); \
+ else \
+ __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "%r" ((USItype)(ah)), \
+ "r" ((USItype)(bh)), \
+ "%r" ((USItype)(al)), \
+ "rI" ((USItype)(bl))); \
+ } while (0)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (ah) && (ah) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(bh)), \
+ "rI" ((USItype)(al)), \
+ "r" ((USItype)(bl))); \
+ else if (__builtin_constant_p (ah) && (ah) ==~(USItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(bh)), \
+ "rI" ((USItype)(al)), \
+ "r" ((USItype)(bl))); \
+ else if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(ah)), \
+ "rI" ((USItype)(al)), \
+ "r" ((USItype)(bl))); \
+ else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(ah)), \
+ "rI" ((USItype)(al)), \
+ "r" ((USItype)(bl))); \
+ else \
+ __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
+ : "=r" ((sh)), \
+ "=&r" ((sl)) \
+ : "r" ((USItype)(ah)), \
+ "r" ((USItype)(bh)), \
+ "rI" ((USItype)(al)), \
+ "r" ((USItype)(bl))); \
+ } while (0)
+#define count_leading_zeros(count, x) \
+ __asm__ ("{cntlz|cntlzw} %0,%1" \
+ : "=r" ((count)) \
+ : "r" ((USItype)(x)))
+#define COUNT_LEADING_ZEROS_0 32
+#if defined (_ARCH_PPC)
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhwu %0,%1,%2" \
+ : "=r" (ph) \
+ : "%r" (__m0), \
+ "r" (__m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define UMUL_TIME 15
+#define smul_ppmm(ph, pl, m0, m1) \
+ do { \
+ SItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhw %0,%1,%2" \
+ : "=r" ((SItype) ph) \
+ : "%r" (__m0), \
+ "r" (__m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define SMUL_TIME 14
+#define UDIV_TIME 120
+#else
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mul %0,%2,%3" \
+ : "=r" ((xh)), \
+ "=q" ((xl)) \
+ : "r" (__m0), \
+ "r" (__m1)); \
+ (xh) += ((((SItype) __m0 >> 31) & __m1) \
+ + (((SItype) __m1 >> 31) & __m0)); \
+ } while (0)
+#define UMUL_TIME 8
+#define smul_ppmm(xh, xl, m0, m1) \
+ __asm__ ("mul %0,%2,%3" \
+ : "=r" ((SItype)(xh)), \
+ "=q" ((SItype)(xl)) \
+ : "r" (m0), \
+ "r" (m1))
+#define SMUL_TIME 4
+#define sdiv_qrnnd(q, r, nh, nl, d) \
+ __asm__ ("div %0,%2,%4" \
+ : "=r" ((SItype)(q)), "=q" ((SItype)(r)) \
+ : "r" ((SItype)(nh)), "1" ((SItype)(nl)), "r" ((SItype)(d)))
+#define UDIV_TIME 100
+#endif
+#endif /* Power architecture variants. */
+
+/* Powerpc 64 bit support taken from gmp-4.1.2. */
+/* We should test _IBMR2 here when we add assembly support for the system
+ vendor compilers. */
+#if 0 /* Not yet enabled because we don't have hardware for a test. */
+#if (defined (_ARCH_PPC) || defined (__powerpc__)) && W_TYPE_SIZE == 64
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+ else \
+ __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
+ : "=r" (sh), "=&r" (sl) \
+ : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
+ } while (0)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (ah) && (ah) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+ else \
+ __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
+ : "=r" (sh), "=&r" (sl) \
+ : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \
+ } while (0)
+#define count_leading_zeros(count, x) \
+ __asm__ ("cntlzd %0,%1" : "=r" (count) : "r" (x))
+#define COUNT_LEADING_ZEROS_0 64
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ UDItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhdu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define UMUL_TIME 15
+#define smul_ppmm(ph, pl, m0, m1) \
+ do { \
+ DItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhd %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define SMUL_TIME 14 /* ??? */
+#define UDIV_TIME 120 /* ??? */
+#endif /* 64-bit PowerPC. */
+#endif /* if 0 */
+
+/***************************************
+ ************** PYR ******************
+ ***************************************/
+#if defined (__pyr__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addw %5,%1 \n" \
+ "addwc %3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subw %5,%1 \n" \
+ "subwb %3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+/* This insn works on Pyramids with AP, XP, or MI CPUs, but not with SP. */
+#define umul_ppmm(w1, w0, u, v) \
+ ({union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ __asm__ ("movw %1,%R0 \n" \
+ "uemul %2,%0" \
+ : "=&r" (__xx.__ll) \
+ : "g" ((USItype) (u)), \
+ "g" ((USItype)(v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#endif /* __pyr__ */
+
+
+/***************************************
+ ************** RT/ROMP **************
+ ***************************************/
+#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("a %1,%5 \n" \
+ "ae %0,%3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%0" ((USItype)(ah)), \
+ "r" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "r" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("s %1,%5\n" \
+ "se %0,%3" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "0" ((USItype)(ah)), \
+ "r" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "r" ((USItype)(bl)))
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ( \
+ "s r2,r2 \n" \
+ "mts r10,%2 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "m r2,%3 \n" \
+ "cas %0,r2,r0 \n" \
+ "mfs r10,%1" \
+ : "=r" ((USItype)(ph)), \
+ "=r" ((USItype)(pl)) \
+ : "%r" (__m0), \
+ "r" (__m1) \
+ : "r2"); \
+ (ph) += ((((SItype) __m0 >> 31) & __m1) \
+ + (((SItype) __m1 >> 31) & __m0)); \
+ } while (0)
+#define UMUL_TIME 20
+#define UDIV_TIME 200
+#define count_leading_zeros(count, x) \
+ do { \
+ if ((x) >= 0x10000) \
+ __asm__ ("clz %0,%1" \
+ : "=r" ((USItype)(count)) \
+ : "r" ((USItype)(x) >> 16)); \
+ else \
+ { \
+ __asm__ ("clz %0,%1" \
+ : "=r" ((USItype)(count)) \
+ : "r" ((USItype)(x))); \
+ (count) += 16; \
+ } \
+ } while (0)
+#endif /* RT/ROMP */
+
+
+/***************************************
+ ************** SH2 ******************
+ ***************************************/
+#if (defined (__sh2__) || defined(__sh3__) || defined(__SH4__) ) \
+ && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ( \
+ "dmulu.l %2,%3\n" \
+ "sts macl,%1\n" \
+ "sts mach,%0" \
+ : "=r" ((USItype)(w1)), \
+ "=r" ((USItype)(w0)) \
+ : "r" ((USItype)(u)), \
+ "r" ((USItype)(v)) \
+ : "macl", "mach")
+#define UMUL_TIME 5
+#endif
+
+/***************************************
+ ************** SPARC ****************
+ ***************************************/
+#if defined (__sparc__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addcc %r4,%5,%1\n" \
+ "addx %r2,%3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "%rJ" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "%rJ" ((USItype)(al)), \
+ "rI" ((USItype)(bl)) \
+ __CLOBBER_CC)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subcc %r4,%5,%1\n" \
+ "subx %r2,%3,%0" \
+ : "=r" ((USItype)(sh)), \
+ "=&r" ((USItype)(sl)) \
+ : "rJ" ((USItype)(ah)), \
+ "rI" ((USItype)(bh)), \
+ "rJ" ((USItype)(al)), \
+ "rI" ((USItype)(bl)) \
+ __CLOBBER_CC)
+#if defined (__sparc_v8__)
+/* Don't match immediate range because, 1) it is not often useful,
+ 2) the 'I' flag thinks of the range as a 13 bit signed interval,
+ while we want to match a 13 bit interval, sign extended to 32 bits,
+ but INTERPRETED AS UNSIGNED. */
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("umul %2,%3,%1;rd %%y,%0" \
+ : "=r" ((USItype)(w1)), \
+ "=r" ((USItype)(w0)) \
+ : "r" ((USItype)(u)), \
+ "r" ((USItype)(v)))
+#define UMUL_TIME 5
+#ifndef SUPERSPARC /* SuperSPARC's udiv only handles 53 bit dividends */
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { \
+ USItype __q; \
+ __asm__ ("mov %1,%%y;nop;nop;nop;udiv %2,%3,%0" \
+ : "=r" ((USItype)(__q)) \
+ : "r" ((USItype)(n1)), \
+ "r" ((USItype)(n0)), \
+ "r" ((USItype)(d))); \
+ (r) = (n0) - __q * (d); \
+ (q) = __q; \
+ } while (0)
+#define UDIV_TIME 25
+#endif /* SUPERSPARC */
+#else /* ! __sparc_v8__ */
+#if defined (__sparclite__)
+/* This has hardware multiply but not divide. It also has two additional
+ instructions scan (ffs from high bit) and divscc. */
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("umul %2,%3,%1;rd %%y,%0" \
+ : "=r" ((USItype)(w1)), \
+ "=r" ((USItype)(w0)) \
+ : "r" ((USItype)(u)), \
+ "r" ((USItype)(v)))
+#define UMUL_TIME 5
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("! Inlined udiv_qrnnd \n" \
+ " wr %%g0,%2,%%y ! Not a delayed write for sparclite \n" \
+ " tst %%g0 \n" \
+ " divscc %3,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%%g1 \n" \
+ " divscc %%g1,%4,%0 \n" \
+ " rd %%y,%1 \n" \
+ " bl,a 1f \n" \
+ " add %1,%4,%1 \n" \
+ "1: ! End of inline udiv_qrnnd" \
+ : "=r" ((USItype)(q)), \
+ "=r" ((USItype)(r)) \
+ : "r" ((USItype)(n1)), \
+ "r" ((USItype)(n0)), \
+ "rI" ((USItype)(d)) \
+ : "%g1" __AND_CLOBBER_CC)
+#define UDIV_TIME 37
+#define count_leading_zeros(count, x) \
+ __asm__ ("scan %1,0,%0" \
+ : "=r" ((USItype)(x)) \
+ : "r" ((USItype)(count)))
+/* Early sparclites return 63 for an argument of 0, but they warn that future
+ implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0
+ undefined. */
+#endif /* __sparclite__ */
+#endif /* __sparc_v8__ */
+/* Default to sparc v7 versions of umul_ppmm and udiv_qrnnd. */
+#ifndef umul_ppmm
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("! Inlined umul_ppmm \n" \
+ " wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr \n" \
+ " sra %3,31,%%g2 ! Don't move this insn \n" \
+ " and %2,%%g2,%%g2 ! Don't move this insn \n" \
+ " andcc %%g0,0,%%g1 ! Don't move this insn \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,%3,%%g1 \n" \
+ " mulscc %%g1,0,%%g1 \n" \
+ " add %%g1,%%g2,%0 \n" \
+ " rd %%y,%1" \
+ : "=r" ((USItype)(w1)), \
+ "=r" ((USItype)(w0)) \
+ : "%rI" ((USItype)(u)), \
+ "r" ((USItype)(v)) \
+ : "%g1", "%g2" __AND_CLOBBER_CC)
+#define UMUL_TIME 39 /* 39 instructions */
+#endif
+#ifndef udiv_qrnnd
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { USItype __r; \
+ (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
+ (r) = __r; \
+ } while (0)
+extern USItype __udiv_qrnnd ();
+#define UDIV_TIME 140
+#endif /* LONGLONG_STANDALONE */
+#endif /* udiv_qrnnd */
+#endif /* __sparc__ */
+
+
+/***************************************
+ ************** VAX ******************
+ ***************************************/
+#if defined (__vax__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addl2 %5,%1\n" \
+ "adwc %3,%0" \
+ : "=g" ((USItype)(sh)), \
+ "=&g" ((USItype)(sl)) \
+ : "%0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "%1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subl2 %5,%1\n" \
+ "sbwc %3,%0" \
+ : "=g" ((USItype)(sh)), \
+ "=&g" ((USItype)(sl)) \
+ : "0" ((USItype)(ah)), \
+ "g" ((USItype)(bh)), \
+ "1" ((USItype)(al)), \
+ "g" ((USItype)(bl)))
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("emul %1,%2,$0,%0" \
+ : "=g" (__xx.__ll) \
+ : "g" (__m0), \
+ "g" (__m1)); \
+ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
+ (xh) += ((((SItype) __m0 >> 31) & __m1) \
+ + (((SItype) __m1 >> 31) & __m0)); \
+ } while (0)
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+ do { \
+ union {DItype __ll; \
+ struct {SItype __l, __h;} __i; \
+ } __xx; \
+ __xx.__i.__h = n1; __xx.__i.__l = n0; \
+ __asm__ ("ediv %3,%2,%0,%1" \
+ : "=g" (q), "=g" (r) \
+ : "g" (__xx.__ll), "g" (d)); \
+ } while (0)
+#endif /* __vax__ */
+
+
+/***************************************
+ ************** Z8000 ****************
+ ***************************************/
+#if defined (__z8000__) && W_TYPE_SIZE == 16
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \
+ : "=r" ((unsigned int)(sh)), \
+ "=&r" ((unsigned int)(sl)) \
+ : "%0" ((unsigned int)(ah)), \
+ "r" ((unsigned int)(bh)), \
+ "%1" ((unsigned int)(al)), \
+ "rQR" ((unsigned int)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \
+ : "=r" ((unsigned int)(sh)), \
+ "=&r" ((unsigned int)(sl)) \
+ : "0" ((unsigned int)(ah)), \
+ "r" ((unsigned int)(bh)), \
+ "1" ((unsigned int)(al)), \
+ "rQR" ((unsigned int)(bl)))
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {long int __ll; \
+ struct {unsigned int __h, __l;} __i; \
+ } __xx; \
+ unsigned int __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mult %S0,%H3" \
+ : "=r" (__xx.__i.__h), \
+ "=r" (__xx.__i.__l) \
+ : "%1" (__m0), \
+ "rQR" (__m1)); \
+ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
+ (xh) += ((((signed int) __m0 >> 15) & __m1) \
+ + (((signed int) __m1 >> 15) & __m0)); \
+ } while (0)
+#endif /* __z8000__ */
+
+#endif /* __GNUC__ */
+#endif /* !__riscos__ */
+
+
+/***************************************
+ *********** Generic Versions ********
+ ***************************************/
+#if !defined (umul_ppmm) && defined (__umulsidi3)
+#define umul_ppmm(ph, pl, m0, m1) \
+ { \
+ UDWtype __ll = __umulsidi3 (m0, m1); \
+ ph = (UWtype) (__ll >> W_TYPE_SIZE); \
+ pl = (UWtype) __ll; \
+ }
+#endif
+
+#if !defined (__umulsidi3)
+#define __umulsidi3(u, v) \
+ ({UWtype __hi, __lo; \
+ umul_ppmm (__hi, __lo, u, v); \
+ ((UDWtype) __hi << W_TYPE_SIZE) | __lo; })
+#endif
+
+/* If this machine has no inline assembler, use C macros. */
+
+#if !defined (add_ssaaaa)
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ do { \
+ UWtype __x; \
+ __x = (al) + (bl); \
+ (sh) = (ah) + (bh) + (__x < (al)); \
+ (sl) = __x; \
+ } while (0)
+#endif
+
+#if !defined (sub_ddmmss)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ UWtype __x; \
+ __x = (al) - (bl); \
+ (sh) = (ah) - (bh) - (__x > (al)); \
+ (sl) = __x; \
+ } while (0)
+#endif
+
+#if !defined (umul_ppmm)
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ UWtype __x0, __x1, __x2, __x3; \
+ UHWtype __ul, __vl, __uh, __vh; \
+ UWtype __u = (u), __v = (v); \
+ \
+ __ul = __ll_lowpart (__u); \
+ __uh = __ll_highpart (__u); \
+ __vl = __ll_lowpart (__v); \
+ __vh = __ll_highpart (__v); \
+ \
+ __x0 = (UWtype) __ul * __vl; \
+ __x1 = (UWtype) __ul * __vh; \
+ __x2 = (UWtype) __uh * __vl; \
+ __x3 = (UWtype) __uh * __vh; \
+ \
+ __x1 += __ll_highpart (__x0);/* this can't give carry */ \
+ __x1 += __x2; /* but this indeed can */ \
+ if (__x1 < __x2) /* did we get it? */ \
+ __x3 += __ll_B; /* yes, add it in the proper pos. */ \
+ \
+ (w1) = __x3 + __ll_highpart (__x1); \
+ (w0) = (__ll_lowpart (__x1) << W_TYPE_SIZE/2) + __ll_lowpart (__x0);\
+ } while (0)
+#endif
+
+#if !defined (umul_ppmm)
+#define smul_ppmm(w1, w0, u, v) \
+ do { \
+ UWtype __w1; \
+ UWtype __m0 = (u), __m1 = (v); \
+ umul_ppmm (__w1, w0, __m0, __m1); \
+ (w1) = __w1 - (-(__m0 >> (W_TYPE_SIZE - 1)) & __m1) \
+ - (-(__m1 >> (W_TYPE_SIZE - 1)) & __m0); \
+ } while (0)
+#endif
+
+/* Define this unconditionally, so it can be used for debugging. */
+#define __udiv_qrnnd_c(q, r, n1, n0, d) \
+ do { \
+ UWtype __d1, __d0, __q1, __q0, __r1, __r0, __m; \
+ __d1 = __ll_highpart (d); \
+ __d0 = __ll_lowpart (d); \
+ \
+ __r1 = (n1) % __d1; \
+ __q1 = (n1) / __d1; \
+ __m = (UWtype) __q1 * __d0; \
+ __r1 = __r1 * __ll_B | __ll_highpart (n0); \
+ if (__r1 < __m) \
+ { \
+ __q1--, __r1 += (d); \
+ if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
+ if (__r1 < __m) \
+ __q1--, __r1 += (d); \
+ } \
+ __r1 -= __m; \
+ \
+ __r0 = __r1 % __d1; \
+ __q0 = __r1 / __d1; \
+ __m = (UWtype) __q0 * __d0; \
+ __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
+ if (__r0 < __m) \
+ { \
+ __q0--, __r0 += (d); \
+ if (__r0 >= (d)) \
+ if (__r0 < __m) \
+ __q0--, __r0 += (d); \
+ } \
+ __r0 -= __m; \
+ \
+ (q) = (UWtype) __q1 * __ll_B | __q0; \
+ (r) = __r0; \
+ } while (0)
+
+/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
+ __udiv_w_sdiv (defined in libgcc or elsewhere). */
+#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
+#define udiv_qrnnd(q, r, nh, nl, d) \
+ do { \
+ UWtype __r; \
+ (q) = __MPN(udiv_w_sdiv) (&__r, nh, nl, d); \
+ (r) = __r; \
+ } while (0)
+#endif
+
+/* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */
+#if !defined (udiv_qrnnd)
+#define UDIV_NEEDS_NORMALIZATION 1
+#define udiv_qrnnd __udiv_qrnnd_c
+#endif
+
+#if !defined (count_leading_zeros)
+extern
+#ifdef __STDC__
+const
+#endif
+unsigned char _gcry_clz_tab[];
+#define MPI_INTERNAL_NEED_CLZ_TAB 1
+#define count_leading_zeros(count, x) \
+ do { \
+ UWtype __xr = (x); \
+ UWtype __a; \
+ \
+ if (W_TYPE_SIZE <= 32) \
+ { \
+ __a = __xr < ((UWtype) 1 << 2*__BITS4) \
+ ? (__xr < ((UWtype) 1 << __BITS4) ? 0 : __BITS4) \
+ : (__xr < ((UWtype) 1 << 3*__BITS4) ? 2*__BITS4 : 3*__BITS4);\
+ } \
+ else \
+ { \
+ for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \
+ if (((__xr >> __a) & 0xff) != 0) \
+ break; \
+ } \
+ \
+ (count) = W_TYPE_SIZE - (_gcry_clz_tab[__xr >> __a] + __a); \
+ } while (0)
+/* This version gives a well-defined value for zero. */
+#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
+#endif
+
+#if !defined (count_trailing_zeros)
+/* Define count_trailing_zeros using count_leading_zeros. The latter might be
+ defined in asm, but if it is not, the C version above is good enough. */
+#define count_trailing_zeros(count, x) \
+ do { \
+ UWtype __ctz_x = (x); \
+ UWtype __ctz_c; \
+ count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \
+ (count) = W_TYPE_SIZE - 1 - __ctz_c; \
+ } while (0)
+#endif
+
+#ifndef UDIV_NEEDS_NORMALIZATION
+#define UDIV_NEEDS_NORMALIZATION 0
+#endif
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/Manifest b/grub-core/lib/libgcrypt/mpi/m68k/Manifest
new file mode 100644
index 0000000..8e0538a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/Manifest
@@ -0,0 +1,25 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+syntax.h
+mpih-lshift.S
+mpih-rshift.S
+mpih-add1.S
+mpih-sub1.S
+$names$ iQCVAwUAP+LmTDEAnp832S/7AQJHUAP/dxfq2U0pDc5ZLoEizoqgjjcnHIyb9EjMG3YjvgK6jQ62yoAOCuo/jFYlJS+Mdve6bgfdTzYMrnKV7BG2SEcwb263pVnIntS7ZhKQPiMCbFgXWR2VjN3+a1v8yjQDZtgqEgm8OlQ+u7jKBY13Oryiuq5nPNxsXZqJpelG6Zkdg9M==PIee
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/distfiles b/grub-core/lib/libgcrypt/mpi/m68k/distfiles
new file mode 100644
index 0000000..1e2e36f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/distfiles
@@ -0,0 +1,9 @@
+Manifest
+syntax.h
+mpih-lshift.S
+mpih-rshift.S
+mpih-add1.S
+mpih-sub1.S
+
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/mc68020/Manifest b/grub-core/lib/libgcrypt/mpi/m68k/mc68020/Manifest
new file mode 100644
index 0000000..bcb2768
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/mc68020/Manifest
@@ -0,0 +1,23 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+$names$ iQCVAwUAP+LmRTEAnp832S/7AQK3rwP/TyGBbii5HCrjDiLCVJHiDNeOdENx6AicRXnu4vuJmMmPZ0y+i7MPusDaeTbIUA0w6RaJx+Ep41nIvthmNDnFePY5Mw0pIUJcpI7AJR4vYqpwNQA6nlEdn/m1jg6sPLKZXUXNUkhroEzcHzoU+12BPS+nvSXlwSksg6rXEGOJ+Ms==XCXP
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/mc68020/distfiles b/grub-core/lib/libgcrypt/mpi/m68k/mc68020/distfiles
new file mode 100644
index 0000000..6b96433
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/mc68020/distfiles
@@ -0,0 +1,4 @@
+Manifest
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul1.S b/grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul1.S
new file mode 100644
index 0000000..007c94c
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul1.S
@@ -0,0 +1,104 @@
+/* mc68020 __mpn_mul_1 -- Multiply a limb vector with a limb and store
+ * the result in a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ */
+
+
+ TEXT
+ ALIGN
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1)
+
+C_SYMBOL_NAME(_gcry_mpih_mul_1:)
+PROLOG(_gcry_mpih_mul_1)
+
+#define res_ptr a0
+#define s1_ptr a1
+#define s1_size d2
+#define s2_limb d4
+
+/* Save used registers on the stack. */
+ moveml R(d2)-R(d4),MEM_PREDEC(sp)
+#if 0
+ movel R(d2),MEM_PREDEC(sp)
+ movel R(d3),MEM_PREDEC(sp)
+ movel R(d4),MEM_PREDEC(sp)
+#endif
+
+/* Copy the arguments to registers. Better use movem? */
+ movel MEM_DISP(sp,16),R(res_ptr)
+ movel MEM_DISP(sp,20),R(s1_ptr)
+ movel MEM_DISP(sp,24),R(s1_size)
+ movel MEM_DISP(sp,28),R(s2_limb)
+
+ eorw #1,R(s1_size)
+ clrl R(d1)
+ lsrl #1,R(s1_size)
+ bcc L(L1)
+ subql #1,R(s1_size)
+ subl R(d0),R(d0) /* (d0,cy) <= (0,0) */
+
+L(Loop:)
+ movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d1):R(d3)
+ addxl R(d0),R(d3)
+ movel R(d3),MEM_POSTINC(res_ptr)
+L(L1:) movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d0):R(d3)
+ addxl R(d1),R(d3)
+ movel R(d3),MEM_POSTINC(res_ptr)
+
+ dbf R(s1_size),L(Loop)
+ clrl R(d3)
+ addxl R(d3),R(d0)
+ subl #0x10000,R(s1_size)
+ bcc L(Loop)
+
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d4)
+#if 0
+ movel MEM_POSTINC(sp),R(d4)
+ movel MEM_POSTINC(sp),R(d3)
+ movel MEM_POSTINC(sp),R(d2)
+#endif
+ rts
+EPILOG(_gcry_mpih_mul_1)
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul2.S b/grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul2.S
new file mode 100644
index 0000000..44baa8d
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul2.S
@@ -0,0 +1,94 @@
+/* mc68020 __mpn_addmul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ */
+
+
+ TEXT
+ ALIGN
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1)
+
+C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
+PROLOG(_gcry_mpih_addmul_1)
+
+#define res_ptr a0
+#define s1_ptr a1
+#define s1_size d2
+#define s2_limb d4
+
+/* Save used registers on the stack. */
+ moveml R(d2)-R(d5),MEM_PREDEC(sp)
+
+/* Copy the arguments to registers. Better use movem? */
+ movel MEM_DISP(sp,20),R(res_ptr)
+ movel MEM_DISP(sp,24),R(s1_ptr)
+ movel MEM_DISP(sp,28),R(s1_size)
+ movel MEM_DISP(sp,32),R(s2_limb)
+
+ eorw #1,R(s1_size)
+ clrl R(d1)
+ clrl R(d5)
+ lsrl #1,R(s1_size)
+ bcc L(L1)
+ subql #1,R(s1_size)
+ subl R(d0),R(d0) /* (d0,cy) <= (0,0) */
+
+L(Loop:)
+ movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d1):R(d3)
+ addxl R(d0),R(d3)
+ addxl R(d5),R(d1)
+ addl R(d3),MEM_POSTINC(res_ptr)
+L(L1:) movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d0):R(d3)
+ addxl R(d1),R(d3)
+ addxl R(d5),R(d0)
+ addl R(d3),MEM_POSTINC(res_ptr)
+
+ dbf R(s1_size),L(Loop)
+ addxl R(d5),R(d0)
+ subl #0x10000,R(s1_size)
+ bcc L(Loop)
+
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d5)
+
+ rts
+EPILOG(_gcry_mpih_addmul_1)
+
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul3.S b/grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul3.S
new file mode 100644
index 0000000..e958ef6
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/mc68020/mpih-mul3.S
@@ -0,0 +1,97 @@
+/* mc68020 __mpn_submul_1 -- Multiply a limb vector with a limb and subtract
+ * the result from a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ */
+
+
+ TEXT
+ ALIGN
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1)
+
+C_SYMBOL_NAME(_gcry_mpih_submul_1:)
+PROLOG(_gcry_mpih_submul_1)
+
+#define res_ptr a0
+#define s1_ptr a1
+#define s1_size d2
+#define s2_limb d4
+
+/* Save used registers on the stack. */
+ moveml R(d2)-R(d5),MEM_PREDEC(sp)
+
+/* Copy the arguments to registers. Better use movem? */
+ movel MEM_DISP(sp,20),R(res_ptr)
+ movel MEM_DISP(sp,24),R(s1_ptr)
+ movel MEM_DISP(sp,28),R(s1_size)
+ movel MEM_DISP(sp,32),R(s2_limb)
+
+ eorw #1,R(s1_size)
+ clrl R(d1)
+ clrl R(d5)
+ lsrl #1,R(s1_size)
+ bcc L(L1)
+ subql #1,R(s1_size)
+ subl R(d0),R(d0) /* (d0,cy) <= (0,0) */
+
+L(Loop:)
+ movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d1):R(d3)
+ addxl R(d0),R(d3)
+ addxl R(d5),R(d1)
+ subl R(d3),MEM_POSTINC(res_ptr)
+L(L1:) movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d0):R(d3)
+ addxl R(d1),R(d3)
+ addxl R(d5),R(d0)
+ subl R(d3),MEM_POSTINC(res_ptr)
+
+ dbf R(s1_size),L(Loop)
+ addxl R(d5),R(d0)
+ subl #0x10000,R(s1_size)
+ bcc L(Loop)
+
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d5)
+
+ rts
+EPILOG(_gcry_mpih_submul_1)
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/m68k/mpih-add1.S
new file mode 100644
index 0000000..8182d21
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/mpih-add1.S
@@ -0,0 +1,92 @@
+/* mc68020 __mpn_add_n -- Add two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994,1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_ptr_t s2_ptr, (sp + 16)
+ * mpi_size_t size) (sp + 12)
+ */
+
+
+ TEXT
+ ALIGN
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_add_n)
+
+C_SYMBOL_NAME(_gcry_mpih_add_n:)
+PROLOG(_gcry_mpih_add_n)
+ /* Save used registers on the stack. */
+ movel R(d2),MEM_PREDEC(sp)
+ movel R(a2),MEM_PREDEC(sp)
+
+ /* Copy the arguments to registers. Better use movem? */
+ movel MEM_DISP(sp,12),R(a2)
+ movel MEM_DISP(sp,16),R(a0)
+ movel MEM_DISP(sp,20),R(a1)
+ movel MEM_DISP(sp,24),R(d2)
+
+ eorw #1,R(d2)
+ lsrl #1,R(d2)
+ bcc L(L1)
+ subql #1,R(d2) /* clears cy as side effect */
+
+L(Loop:)
+ movel MEM_POSTINC(a0),R(d0)
+ movel MEM_POSTINC(a1),R(d1)
+ addxl R(d1),R(d0)
+ movel R(d0),MEM_POSTINC(a2)
+L(L1:) movel MEM_POSTINC(a0),R(d0)
+ movel MEM_POSTINC(a1),R(d1)
+ addxl R(d1),R(d0)
+ movel R(d0),MEM_POSTINC(a2)
+
+ dbf R(d2),L(Loop) /* loop until 16 lsb of %4 == -1 */
+ subxl R(d0),R(d0) /* d0 <= -cy; save cy as 0 or -1 in d0 */
+ subl #0x10000,R(d2)
+ bcs L(L2)
+ addl R(d0),R(d0) /* restore cy */
+ bra L(Loop)
+
+L(L2:)
+ negl R(d0)
+
+ /* Restore used registers from stack frame. */
+ movel MEM_POSTINC(sp),R(a2)
+ movel MEM_POSTINC(sp),R(d2)
+
+ rts
+EPILOG(_gcry_mpih_add_n)
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/m68k/mpih-lshift.S
new file mode 100644
index 0000000..133d1aa
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/mpih-lshift.S
@@ -0,0 +1,164 @@
+/* mc68020 lshift -- Shift left a low-level natural-number integer.
+ *
+ * Copyright (C) 1996, 1998, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp, (sp + 4)
+ * mpi_ptr_t up, (sp + 8)
+ * mpi_size_t usize, (sp + 12)
+ * unsigned cnt) (sp + 16)
+ */
+
+#define res_ptr a1
+#define s_ptr a0
+#define s_size d6
+#define cnt d4
+
+ TEXT
+ ALIGN
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_lshift)
+
+C_SYMBOL_NAME(_gcry_mpih_lshift:)
+PROLOG(_gcry_mpih_lshift)
+
+ /* Save used registers on the stack. */
+ moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp)
+
+ /* Copy the arguments to registers. */
+ movel MEM_DISP(sp,28),R(res_ptr)
+ movel MEM_DISP(sp,32),R(s_ptr)
+ movel MEM_DISP(sp,36),R(s_size)
+ movel MEM_DISP(sp,40),R(cnt)
+
+ moveql #1,R(d5)
+ cmpl R(d5),R(cnt)
+ bne L(Lnormal)
+ cmpl R(s_ptr),R(res_ptr)
+ bls L(Lspecial) /* jump if s_ptr >= res_ptr */
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+ lea MEM_INDX1(s_ptr,s_size,l,4),R(a2)
+#else /* not mc68020 */
+ movel R(s_size),R(d0)
+ asll #2,R(d0)
+ lea MEM_INDX(s_ptr,d0,l),R(a2)
+#endif
+ cmpl R(res_ptr),R(a2)
+ bls L(Lspecial) /* jump if res_ptr >= s_ptr + s_size */
+
+L(Lnormal:)
+ moveql #32,R(d5)
+ subl R(cnt),R(d5)
+
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+ lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr)
+ lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr)
+#else /* not mc68000 */
+ movel R(s_size),R(d0)
+ asll #2,R(d0)
+ addl R(s_size),R(s_ptr)
+ addl R(s_size),R(res_ptr)
+#endif
+ movel MEM_PREDEC(s_ptr),R(d2)
+ movel R(d2),R(d0)
+ lsrl R(d5),R(d0) /* compute carry limb */
+
+ lsll R(cnt),R(d2)
+ movel R(d2),R(d1)
+ subql #1,R(s_size)
+ beq L(Lend)
+ lsrl #1,R(s_size)
+ bcs L(L1)
+ subql #1,R(s_size)
+
+L(Loop:)
+ movel MEM_PREDEC(s_ptr),R(d2)
+ movel R(d2),R(d3)
+ lsrl R(d5),R(d3)
+ orl R(d3),R(d1)
+ movel R(d1),MEM_PREDEC(res_ptr)
+ lsll R(cnt),R(d2)
+L(L1:)
+ movel MEM_PREDEC(s_ptr),R(d1)
+ movel R(d1),R(d3)
+ lsrl R(d5),R(d3)
+ orl R(d3),R(d2)
+ movel R(d2),MEM_PREDEC(res_ptr)
+ lsll R(cnt),R(d1)
+
+ dbf R(s_size),L(Loop)
+ subl #0x10000,R(s_size)
+ bcc L(Loop)
+
+L(Lend:)
+ movel R(d1),MEM_PREDEC(res_ptr) /* store least significant limb */
+
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
+ rts
+
+/* We loop from least significant end of the arrays, which is only
+ permissable if the source and destination don't overlap, since the
+ function is documented to work for overlapping source and destination. */
+
+L(Lspecial:)
+ clrl R(d0) /* initialize carry */
+ eorw #1,R(s_size)
+ lsrl #1,R(s_size)
+ bcc L(LL1)
+ subql #1,R(s_size)
+
+L(LLoop:)
+ movel MEM_POSTINC(s_ptr),R(d2)
+ addxl R(d2),R(d2)
+ movel R(d2),MEM_POSTINC(res_ptr)
+L(LL1:)
+ movel MEM_POSTINC(s_ptr),R(d2)
+ addxl R(d2),R(d2)
+ movel R(d2),MEM_POSTINC(res_ptr)
+
+ dbf R(s_size),L(LLoop)
+ addxl R(d0),R(d0) /* save cy in lsb */
+ subl #0x10000,R(s_size)
+ bcs L(LLend)
+ lsrl #1,R(d0) /* restore cy */
+ bra L(LLoop)
+
+L(LLend:)
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
+ rts
+EPILOG(_gcry_mpih_lshift)
+
+
+
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/m68k/mpih-rshift.S
new file mode 100644
index 0000000..be9f435
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/mpih-rshift.S
@@ -0,0 +1,162 @@
+/* mc68020 rshift -- Shift right a low-level natural-number integer.
+ *
+ * Copyright (C) 1996, 1998, 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp, (sp + 4)
+ * mpi_ptr_t up, (sp + 8)
+ * mpi_size_t usize, (sp + 12)
+ * unsigned cnt) (sp + 16)
+ */
+
+#define res_ptr a1
+#define s_ptr a0
+#define s_size d6
+#define cnt d4
+
+ TEXT
+ ALIGN
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_rshift)
+
+C_SYMBOL_NAME(_gcry_mpih_rshift:)
+PROLOG(_gcry_mpih_rshift)
+ /* Save used registers on the stack. */
+ moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp)
+
+ /* Copy the arguments to registers. */
+ movel MEM_DISP(sp,28),R(res_ptr)
+ movel MEM_DISP(sp,32),R(s_ptr)
+ movel MEM_DISP(sp,36),R(s_size)
+ movel MEM_DISP(sp,40),R(cnt)
+
+ moveql #1,R(d5)
+ cmpl R(d5),R(cnt)
+ bne L(Rnormal)
+ cmpl R(res_ptr),R(s_ptr)
+ bls L(Rspecial) /* jump if res_ptr >= s_ptr */
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+ lea MEM_INDX1(res_ptr,s_size,l,4),R(a2)
+#else /* not mc68020 */
+ movel R(s_size),R(d0)
+ asll #2,R(d0)
+ lea MEM_INDX(res_ptr,d0,l),R(a2)
+#endif
+ cmpl R(s_ptr),R(a2)
+ bls L(Rspecial) /* jump if s_ptr >= res_ptr + s_size */
+
+L(Rnormal:)
+ moveql #32,R(d5)
+ subl R(cnt),R(d5)
+ movel MEM_POSTINC(s_ptr),R(d2)
+ movel R(d2),R(d0)
+ lsll R(d5),R(d0) /* compute carry limb */
+
+ lsrl R(cnt),R(d2)
+ movel R(d2),R(d1)
+ subql #1,R(s_size)
+ beq L(Rend)
+ lsrl #1,R(s_size)
+ bcs L(R1)
+ subql #1,R(s_size)
+
+L(Roop:)
+ movel MEM_POSTINC(s_ptr),R(d2)
+ movel R(d2),R(d3)
+ lsll R(d5),R(d3)
+ orl R(d3),R(d1)
+ movel R(d1),MEM_POSTINC(res_ptr)
+ lsrl R(cnt),R(d2)
+L(R1:)
+ movel MEM_POSTINC(s_ptr),R(d1)
+ movel R(d1),R(d3)
+ lsll R(d5),R(d3)
+ orl R(d3),R(d2)
+ movel R(d2),MEM_POSTINC(res_ptr)
+ lsrl R(cnt),R(d1)
+
+ dbf R(s_size),L(Roop)
+ subl #0x10000,R(s_size)
+ bcc L(Roop)
+
+L(Rend:)
+ movel R(d1),MEM(res_ptr) /* store most significant limb */
+
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
+ rts
+
+/* We loop from most significant end of the arrays, which is only
+ permissable if the source and destination don't overlap, since the
+ function is documented to work for overlapping source and destination. */
+
+L(Rspecial:)
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+ lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr)
+ lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr)
+#else /* not mc68000 */
+ movel R(s_size),R(d0)
+ asll #2,R(d0)
+ addl R(s_size),R(s_ptr)
+ addl R(s_size),R(res_ptr)
+#endif
+
+ clrl R(d0) /* initialize carry */
+ eorw #1,R(s_size)
+ lsrl #1,R(s_size)
+ bcc L(LR1)
+ subql #1,R(s_size)
+
+L(LRoop:)
+ movel MEM_PREDEC(s_ptr),R(d2)
+ roxrl #1,R(d2)
+ movel R(d2),MEM_PREDEC(res_ptr)
+L(LR1:)
+ movel MEM_PREDEC(s_ptr),R(d2)
+ roxrl #1,R(d2)
+ movel R(d2),MEM_PREDEC(res_ptr)
+
+ dbf R(s_size),L(LRoop)
+ roxrl #1,R(d0) /* save cy in msb */
+ subl #0x10000,R(s_size)
+ bcs L(LRend)
+ addl R(d0),R(d0) /* restore cy */
+ bra L(LRoop)
+
+L(LRend:)
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
+ rts
+EPILOG(_gcry_mpih_rshift)
+
+
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/mpih-sub1.S b/grub-core/lib/libgcrypt/mpi/m68k/mpih-sub1.S
new file mode 100644
index 0000000..ee7555f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/mpih-sub1.S
@@ -0,0 +1,91 @@
+/* mc68020 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
+ * store difference in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_ptr_t s2_ptr, (sp + 16)
+ * mpi_size_t size) (sp + 12)
+ */
+
+
+ TEXT
+ ALIGN
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_sub_n)
+
+C_SYMBOL_NAME(_gcry_mpih_sub_n:)
+PROLOG(_gcry_mpih_sub_n)
+/* Save used registers on the stack. */
+ movel R(d2),MEM_PREDEC(sp)
+ movel R(a2),MEM_PREDEC(sp)
+
+/* Copy the arguments to registers. Better use movem? */
+ movel MEM_DISP(sp,12),R(a2)
+ movel MEM_DISP(sp,16),R(a0)
+ movel MEM_DISP(sp,20),R(a1)
+ movel MEM_DISP(sp,24),R(d2)
+
+ eorw #1,R(d2)
+ lsrl #1,R(d2)
+ bcc L(L1)
+ subql #1,R(d2) /* clears cy as side effect */
+
+L(Loop:)
+ movel MEM_POSTINC(a0),R(d0)
+ movel MEM_POSTINC(a1),R(d1)
+ subxl R(d1),R(d0)
+ movel R(d0),MEM_POSTINC(a2)
+L(L1:) movel MEM_POSTINC(a0),R(d0)
+ movel MEM_POSTINC(a1),R(d1)
+ subxl R(d1),R(d0)
+ movel R(d0),MEM_POSTINC(a2)
+
+ dbf R(d2),L(Loop) /* loop until 16 lsb of %4 == -1 */
+ subxl R(d0),R(d0) /* d0 <= -cy; save cy as 0 or -1 in d0 */
+ subl #0x10000,R(d2)
+ bcs L(L2)
+ addl R(d0),R(d0) /* restore cy */
+ bra L(Loop)
+
+L(L2:)
+ negl R(d0)
+
+/* Restore used registers from stack frame. */
+ movel MEM_POSTINC(sp),R(a2)
+ movel MEM_POSTINC(sp),R(d2)
+
+ rts
+EPILOG(_gcry_mpih_sub_n)
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/m68k/syntax.h b/grub-core/lib/libgcrypt/mpi/m68k/syntax.h
new file mode 100644
index 0000000..e27de98
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/m68k/syntax.h
@@ -0,0 +1,185 @@
+/* asm.h -- Definitions for 68k syntax variations.
+ *
+ * Copyright (C) 1992, 1994, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#undef ALIGN
+
+#ifdef MIT_SYNTAX
+#define PROLOG(name)
+#define EPILOG(name)
+#define R(r)r
+#define MEM(base)base@
+#define MEM_DISP(base,displacement)base@(displacement)
+#define MEM_INDX(base,idx,size_suffix)base@(idx:size_suffix)
+#define MEM_INDX1(base,idx,size_suffix,scale)base@(idx:size_suffix:scale)
+#define MEM_PREDEC(memory_base)memory_base@-
+#define MEM_POSTINC(memory_base)memory_base@+
+#define L(label) label
+#define TEXT .text
+#define ALIGN .even
+#define GLOBL .globl
+#define moveql moveq
+/* Use variable sized opcodes. */
+#define bcc jcc
+#define bcs jcs
+#define bls jls
+#define beq jeq
+#define bne jne
+#define bra jra
+#endif
+
+#ifdef SONY_SYNTAX
+#define PROLOG(name)
+#define EPILOG(name)
+#define R(r)r
+#define MEM(base)(base)
+#define MEM_DISP(base,displacement)(displacement,base)
+#define MEM_INDX(base,idx,size_suffix)(base,idx.size_suffix)
+#define MEM_INDX1(base,idx,size_suffix,scale)(base,idx.size_suffix*scale)
+#define MEM_PREDEC(memory_base)-(memory_base)
+#define MEM_POSTINC(memory_base)(memory_base)+
+#define L(label) label
+#define TEXT .text
+#define ALIGN .even
+#define GLOBL .globl
+#endif
+
+#ifdef MOTOROLA_SYNTAX
+#define PROLOG(name)
+#define EPILOG(name)
+#define R(r)r
+#define MEM(base)(base)
+#define MEM_DISP(base,displacement)(displacement,base)
+#define MEM_INDX(base,idx,size_suffix)(base,idx.size_suffix)
+#define MEM_INDX1(base,idx,size_suffix,scale)(base,idx.size_suffix*scale)
+#define MEM_PREDEC(memory_base)-(memory_base)
+#define MEM_POSTINC(memory_base)(memory_base)+
+#define L(label) label
+#define TEXT
+#define ALIGN
+#define GLOBL XDEF
+#define lea LEA
+#define movel MOVE.L
+#define moveml MOVEM.L
+#define moveql MOVEQ.L
+#define cmpl CMP.L
+#define orl OR.L
+#define clrl CLR.L
+#define eorw EOR.W
+#define lsrl LSR.L
+#define lsll LSL.L
+#define roxrl ROXR.L
+#define roxll ROXL.L
+#define addl ADD.L
+#define addxl ADDX.L
+#define addql ADDQ.L
+#define subl SUB.L
+#define subxl SUBX.L
+#define subql SUBQ.L
+#define negl NEG.L
+#define mulul MULU.L
+#define bcc BCC
+#define bcs BCS
+#define bls BLS
+#define beq BEQ
+#define bne BNE
+#define bra BRA
+#define dbf DBF
+#define rts RTS
+#define d0 D0
+#define d1 D1
+#define d2 D2
+#define d3 D3
+#define d4 D4
+#define d5 D5
+#define d6 D6
+#define d7 D7
+#define a0 A0
+#define a1 A1
+#define a2 A2
+#define a3 A3
+#define a4 A4
+#define a5 A5
+#define a6 A6
+#define a7 A7
+#define sp SP
+#endif
+
+#ifdef ELF_SYNTAX
+#define PROLOG(name) .type name,@function
+#define EPILOG(name) .size name,.-name
+#define MEM(base)(R(base))
+#define MEM_DISP(base,displacement)(displacement,R(base))
+#define MEM_PREDEC(memory_base)-(R(memory_base))
+#define MEM_POSTINC(memory_base)(R(memory_base))+
+#ifdef __STDC__
+#define R_(r)%##r
+#define R(r)R_(r)
+#define MEM_INDX_(base,idx,size_suffix)(R(base),R(idx##.##size_suffix))
+#define MEM_INDX(base,idx,size_suffix)MEM_INDX_(base,idx,size_suffix)
+#define MEM_INDX1_(base,idx,size_suffix,scale)(R(base),R(idx##.##size_suffix*scale))
+#define MEM_INDX1(base,idx,size_suffix,scale)MEM_INDX1_(base,idx,size_suffix,scale)
+#define L(label) .##label
+#else
+#define R(r)%/**/r
+#define MEM_INDX(base,idx,size_suffix)(R(base),R(idx).size_suffix)
+#define MEM_INDX1(base,idx,size_suffix,scale)(R(base),R(idx).size_suffix*scale)
+#define L(label) ./**/label
+#endif
+#define TEXT .text
+#define ALIGN .align 2
+#define GLOBL .globl
+#define bcc jbcc
+#define bcs jbcs
+#define bls jbls
+#define beq jbeq
+#define bne jbne
+#define bra jbra
+#endif
+
+#if defined (SONY_SYNTAX) || defined (ELF_SYNTAX)
+#define movel move.l
+#define moveml movem.l
+#define moveql moveq.l
+#define cmpl cmp.l
+#define orl or.l
+#define clrl clr.l
+#define eorw eor.w
+#define lsrl lsr.l
+#define lsll lsl.l
+#define roxrl roxr.l
+#define roxll roxl.l
+#define addl add.l
+#define addxl addx.l
+#define addql addq.l
+#define subl sub.l
+#define subxl subx.l
+#define subql subq.l
+#define negl neg.l
+#define mulul mulu.l
+#endif
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/Manifest b/grub-core/lib/libgcrypt/mpi/mips3/Manifest
new file mode 100644
index 0000000..e191184
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/Manifest
@@ -0,0 +1,28 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-add1.S
+mpih-sub1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-lshift.S
+mpih-rshift.S
+mpi-asm-defs.h
+$names$ iQCVAwUAP+LmUTEAnp832S/7AQLm/gP/RHR2aLMwHPxsq0mGO5H0kneVn8a9l9yDNEZBefkYcOJMb7MZGKxbGspyENiU04Mc2TFnA1wS9gjNHlRWtUYxxn/wyuV6BIRgfstXt2nXGgEQrK07GIz8ETFcYqcxu7JKiICIuXZgnIgdwBJswbBV1zaMUDXeg5B8vkkEeRWj8hQ==IQVO
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/README b/grub-core/lib/libgcrypt/mpi/mips3/README
new file mode 100644
index 0000000..e94b2c7
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/README
@@ -0,0 +1,23 @@
+This directory contains mpn functions optimized for MIPS3. Example of
+processors that implement MIPS3 are R4000, R4400, R4600, R4700, and R8000.
+
+RELEVANT OPTIMIZATION ISSUES
+
+1. On the R4000 and R4400, branches, both the plain and the "likely" ones,
+ take 3 cycles to execute. (The fastest possible loop will take 4 cycles,
+ because of the delay insn.)
+
+ On the R4600, branches takes a single cycle
+
+ On the R8000, branches often take no noticable cycles, as they are
+ executed in a separate function unit..
+
+2. The R4000 and R4400 have a load latency of 4 cycles.
+
+3. On the R4000 and R4400, multiplies take a data-dependent number of
+ cycles, contrary to the SGI documentation. There seem to be 3 or 4
+ possible latencies.
+
+STATUS
+
+Good...
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/distfiles b/grub-core/lib/libgcrypt/mpi/mips3/distfiles
new file mode 100644
index 0000000..ef9b6fe
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/distfiles
@@ -0,0 +1,11 @@
+Manifest
+README
+mpih-add1.S
+mpih-sub1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-lshift.S
+mpih-rshift.S
+mpi-asm-defs.h
+
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/mpi-asm-defs.h b/grub-core/lib/libgcrypt/mpi/mips3/mpi-asm-defs.h
new file mode 100644
index 0000000..2d9a9c1
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/mpi-asm-defs.h
@@ -0,0 +1,10 @@
+/* This file defines some basic constants for the MPI machinery. We
+ * need to define the types on a per-CPU basis, so it is done with
+ * this file here. */
+#define BYTES_PER_MPI_LIMB 8
+
+
+
+
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/mips3/mpih-add1.S
new file mode 100644
index 0000000..f3db029
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/mpih-add1.S
@@ -0,0 +1,124 @@
+/* mips3 add_n -- Add two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1995, 1998, 2000
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr, ($4)
+ * mpi_ptr_t s1_ptr, ($5)
+ * mpi_ptr_t s2_ptr, ($6)
+ * mpi_size_t size) ($7)
+ */
+
+ .text
+ .align 2
+ .globl _gcry_mpih_add_n
+ .ent _gcry_mpih_add_n
+_gcry_mpih_add_n:
+ .set noreorder
+ .set nomacro
+
+ ld $10,0($5)
+ ld $11,0($6)
+
+ daddiu $7,$7,-1
+ and $9,$7,4-1 # number of limbs in first loop
+ beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop
+ move $2,$0
+
+ dsubu $7,$7,$9
+
+.Loop0: daddiu $9,$9,-1
+ ld $12,8($5)
+ daddu $11,$11,$2
+ ld $13,8($6)
+ sltu $8,$11,$2
+ daddu $11,$10,$11
+ sltu $2,$11,$10
+ sd $11,0($4)
+ or $2,$2,$8
+
+ daddiu $5,$5,8
+ daddiu $6,$6,8
+ move $10,$12
+ move $11,$13
+ bne $9,$0,.Loop0
+ daddiu $4,$4,8
+
+.L0: beq $7,$0,.Lend
+ nop
+
+.Loop: daddiu $7,$7,-4
+
+ ld $12,8($5)
+ daddu $11,$11,$2
+ ld $13,8($6)
+ sltu $8,$11,$2
+ daddu $11,$10,$11
+ sltu $2,$11,$10
+ sd $11,0($4)
+ or $2,$2,$8
+
+ ld $10,16($5)
+ daddu $13,$13,$2
+ ld $11,16($6)
+ sltu $8,$13,$2
+ daddu $13,$12,$13
+ sltu $2,$13,$12
+ sd $13,8($4)
+ or $2,$2,$8
+
+ ld $12,24($5)
+ daddu $11,$11,$2
+ ld $13,24($6)
+ sltu $8,$11,$2
+ daddu $11,$10,$11
+ sltu $2,$11,$10
+ sd $11,16($4)
+ or $2,$2,$8
+
+ ld $10,32($5)
+ daddu $13,$13,$2
+ ld $11,32($6)
+ sltu $8,$13,$2
+ daddu $13,$12,$13
+ sltu $2,$13,$12
+ sd $13,24($4)
+ or $2,$2,$8
+
+ daddiu $5,$5,32
+ daddiu $6,$6,32
+
+ bne $7,$0,.Loop
+ daddiu $4,$4,32
+
+.Lend: daddu $11,$11,$2
+ sltu $8,$11,$2
+ daddu $11,$10,$11
+ sltu $2,$11,$10
+ sd $11,0($4)
+ j $31
+ or $2,$2,$8
+
+ .end _gcry_mpih_add_n
+
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/mips3/mpih-lshift.S
new file mode 100644
index 0000000..084c109
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/mpih-lshift.S
@@ -0,0 +1,97 @@
+/* mips3 lshift
+ *
+ * Copyright (C) 1995, 1998, 2000,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp, ($4)
+ * mpi_ptr_t up, ($5)
+ * mpi_size_t usize, ($6)
+ * unsigned cnt) ($7)
+ */
+
+ .text
+ .align 2
+ .globl _gcry_mpih_lshift
+ .ent _gcry_mpih_lshift
+_gcry_mpih_lshift:
+ .set noreorder
+ .set nomacro
+
+ dsll $2,$6,3
+ daddu $5,$5,$2 # make r5 point at end of src
+ ld $10,-8($5) # load first limb
+ dsubu $13,$0,$7
+ daddu $4,$4,$2 # make r4 point at end of res
+ daddiu $6,$6,-1
+ and $9,$6,4-1 # number of limbs in first loop
+ beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop
+ dsrl $2,$10,$13 # compute function result
+
+ dsubu $6,$6,$9
+
+.Loop0: ld $3,-16($5)
+ daddiu $4,$4,-8
+ daddiu $5,$5,-8
+ daddiu $9,$9,-1
+ dsll $11,$10,$7
+ dsrl $12,$3,$13
+ move $10,$3
+ or $8,$11,$12
+ bne $9,$0,.Loop0
+ sd $8,0($4)
+
+.L0: beq $6,$0,.Lend
+ nop
+
+.Loop: ld $3,-16($5)
+ daddiu $4,$4,-32
+ daddiu $6,$6,-4
+ dsll $11,$10,$7
+ dsrl $12,$3,$13
+
+ ld $10,-24($5)
+ dsll $14,$3,$7
+ or $8,$11,$12
+ sd $8,24($4)
+ dsrl $9,$10,$13
+
+ ld $3,-32($5)
+ dsll $11,$10,$7
+ or $8,$14,$9
+ sd $8,16($4)
+ dsrl $12,$3,$13
+
+ ld $10,-40($5)
+ dsll $14,$3,$7
+ or $8,$11,$12
+ sd $8,8($4)
+ dsrl $9,$10,$13
+
+ daddiu $5,$5,-32
+ or $8,$14,$9
+ bgtz $6,.Loop
+ sd $8,0($4)
+
+.Lend: dsll $8,$10,$7
+ j $31
+ sd $8,-8($4)
+ .end _gcry_mpih_lshift
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/mpih-mul1.S b/grub-core/lib/libgcrypt/mpi/mips3/mpih-mul1.S
new file mode 100644
index 0000000..6c0099d
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/mpih-mul1.S
@@ -0,0 +1,89 @@
+/* mips3 mpih-mul1.S -- Multiply a limb vector with a limb and store
+ * the result in a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998, 2000
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (r4)
+ * mpi_ptr_t s1_ptr, (r5)
+ * mpi_size_t s1_size, (r6)
+ * mpi_limb_t s2_limb) (r7)
+ */
+
+ .text
+ .align 4
+ .globl _gcry_mpih_mul_1
+ .ent _gcry_mpih_mul_1
+_gcry_mpih_mul_1:
+ .set noreorder
+ .set nomacro
+
+/* # warm up phase 0 */
+ ld $8,0($5)
+
+/* # warm up phase 1 */
+ daddiu $5,$5,8
+ dmultu $8,$7
+
+ daddiu $6,$6,-1
+ beq $6,$0,$LC0
+ move $2,$0 # zero cy2
+
+ daddiu $6,$6,-1
+ beq $6,$0,$LC1
+ ld $8,0($5) # load new s1 limb as early as possible
+
+Loop: mflo $10
+ mfhi $9
+ daddiu $5,$5,8
+ daddu $10,$10,$2 # add old carry limb to low product limb
+ dmultu $8,$7
+ ld $8,0($5) # load new s1 limb as early as possible
+ daddiu $6,$6,-1 # decrement loop counter
+ sltu $2,$10,$2 # carry from previous addition -> $2
+ sd $10,0($4)
+ daddiu $4,$4,8
+ bne $6,$0,Loop
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+/* # cool down phase 1 */
+$LC1: mflo $10
+ mfhi $9
+ daddu $10,$10,$2
+ sltu $2,$10,$2
+ dmultu $8,$7
+ sd $10,0($4)
+ daddiu $4,$4,8
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+/* # cool down phase 0 */
+$LC0: mflo $10
+ mfhi $9
+ daddu $10,$10,$2
+ sltu $2,$10,$2
+ sd $10,0($4)
+ j $31
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ .end _gcry_mpih_mul_1
+
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/mpih-mul2.S b/grub-core/lib/libgcrypt/mpi/mips3/mpih-mul2.S
new file mode 100644
index 0000000..ca82763
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/mpih-mul2.S
@@ -0,0 +1,101 @@
+/* MIPS3 addmul_1 -- Multiply a limb vector with a single limb and
+ * add the product to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998, 2000
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (r4)
+ * mpi_ptr_t s1_ptr, (r5)
+ * mpi_size_t s1_size, (r6)
+ * mpi_limb_t s2_limb) (r7)
+ */
+
+ .text
+ .align 4
+ .globl _gcry_mpih_addmul_1
+ .ent _gcry_mpih_addmul_1
+_gcry_mpih_addmul_1:
+ .set noreorder
+ .set nomacro
+
+/* # warm up phase 0 */
+ ld $8,0($5)
+
+/* # warm up phase 1 */
+ daddiu $5,$5,8
+ dmultu $8,$7
+
+ daddiu $6,$6,-1
+ beq $6,$0,$LC0
+ move $2,$0 # zero cy2
+
+ daddiu $6,$6,-1
+ beq $6,$0,$LC1
+ ld $8,0($5) # load new s1 limb as early as possible
+
+Loop: ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddiu $5,$5,8
+ daddu $3,$3,$2 # add old carry limb to low product limb
+ dmultu $8,$7
+ ld $8,0($5) # load new s1 limb as early as possible
+ daddiu $6,$6,-1 # decrement loop counter
+ sltu $2,$3,$2 # carry from previous addition -> $2
+ daddu $3,$10,$3
+ sltu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ daddiu $4,$4,8
+ bne $6,$0,Loop
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+/* # cool down phase 1 */
+$LC1: ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddu $3,$3,$2
+ sltu $2,$3,$2
+ dmultu $8,$7
+ daddu $3,$10,$3
+ sltu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ daddiu $4,$4,8
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+/* # cool down phase 0 */
+$LC0: ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddu $3,$3,$2
+ sltu $2,$3,$2
+ daddu $3,$10,$3
+ sltu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ j $31
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ .end _gcry_mpih_addmul_1
+
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/mpih-mul3.S b/grub-core/lib/libgcrypt/mpi/mips3/mpih-mul3.S
new file mode 100644
index 0000000..be421a6
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/mpih-mul3.S
@@ -0,0 +1,101 @@
+/* MIPS3 submul_1 -- Multiply a limb vector with a single limb and
+ * subtract the product from a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998, 2000
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (r4)
+ * mpi_ptr_t s1_ptr, (r5)
+ * mpi_size_t s1_size, (r6)
+ * mpi_limb_t s2_limb) (r7)
+ */
+
+ .text
+ .align 4
+ .globl _gcry_mpih_submul_1
+ .ent _gcry_mpih_submul_1
+_gcry_mpih_submul_1:
+ .set noreorder
+ .set nomacro
+
+/* # warm up phase 0 */
+ ld $8,0($5)
+
+/* # warm up phase 1 */
+ daddiu $5,$5,8
+ dmultu $8,$7
+
+ daddiu $6,$6,-1
+ beq $6,$0,$LC0
+ move $2,$0 # zero cy2
+
+ daddiu $6,$6,-1
+ beq $6,$0,$LC1
+ ld $8,0($5) # load new s1 limb as early as possible
+
+Loop: ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddiu $5,$5,8
+ daddu $3,$3,$2 # add old carry limb to low product limb
+ dmultu $8,$7
+ ld $8,0($5) # load new s1 limb as early as possible
+ daddiu $6,$6,-1 # decrement loop counter
+ sltu $2,$3,$2 # carry from previous addition -> $2
+ dsubu $3,$10,$3
+ sgtu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ daddiu $4,$4,8
+ bne $6,$0,Loop
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+/* # cool down phase 1 */
+$LC1: ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddu $3,$3,$2
+ sltu $2,$3,$2
+ dmultu $8,$7
+ dsubu $3,$10,$3
+ sgtu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ daddiu $4,$4,8
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+/* # cool down phase 0 */
+$LC0: ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddu $3,$3,$2
+ sltu $2,$3,$2
+ dsubu $3,$10,$3
+ sgtu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ j $31
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ .end _gcry_mpih_submul_1
+
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/mips3/mpih-rshift.S
new file mode 100644
index 0000000..e7e035a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/mpih-rshift.S
@@ -0,0 +1,95 @@
+/* mips3 rshift
+ *
+ * Copyright (C) 1995, 1998, 2000
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp, ($4)
+ * mpi_ptr_t up, ($5)
+ * mpi_size_t usize, ($6)
+ * unsigned cnt) ($7)
+ */
+
+ .text
+ .align 2
+ .globl _gcry_mpih_rshift
+ .ent _gcry_mpih_rshift
+_gcry_mpih_rshift:
+ .set noreorder
+ .set nomacro
+
+ ld $10,0($5) # load first limb
+ dsubu $13,$0,$7
+ daddiu $6,$6,-1
+ and $9,$6,4-1 # number of limbs in first loop
+ beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop
+ dsll $2,$10,$13 # compute function result
+
+ dsubu $6,$6,$9
+
+.Loop0: ld $3,8($5)
+ daddiu $4,$4,8
+ daddiu $5,$5,8
+ daddiu $9,$9,-1
+ dsrl $11,$10,$7
+ dsll $12,$3,$13
+ move $10,$3
+ or $8,$11,$12
+ bne $9,$0,.Loop0
+ sd $8,-8($4)
+
+.L0: beq $6,$0,.Lend
+ nop
+
+.Loop: ld $3,8($5)
+ daddiu $4,$4,32
+ daddiu $6,$6,-4
+ dsrl $11,$10,$7
+ dsll $12,$3,$13
+
+ ld $10,16($5)
+ dsrl $14,$3,$7
+ or $8,$11,$12
+ sd $8,-32($4)
+ dsll $9,$10,$13
+
+ ld $3,24($5)
+ dsrl $11,$10,$7
+ or $8,$14,$9
+ sd $8,-24($4)
+ dsll $12,$3,$13
+
+ ld $10,32($5)
+ dsrl $14,$3,$7
+ or $8,$11,$12
+ sd $8,-16($4)
+ dsll $9,$10,$13
+
+ daddiu $5,$5,32
+ or $8,$14,$9
+ bgtz $6,.Loop
+ sd $8,-8($4)
+
+.Lend: dsrl $8,$10,$7
+ j $31
+ sd $8,0($4)
+ .end _gcry_mpih_rshift
+
diff --git a/grub-core/lib/libgcrypt/mpi/mips3/mpih-sub1.S b/grub-core/lib/libgcrypt/mpi/mips3/mpih-sub1.S
new file mode 100644
index 0000000..9fac674
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mips3/mpih-sub1.S
@@ -0,0 +1,125 @@
+/* mips3 sub_n -- Subtract two limb vectors of the same length > 0 and
+ * store difference in a third limb vector.
+ *
+ * Copyright (C) 1995, 1998, 1999, 2000,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (r4)
+ * mpi_ptr_t s1_ptr, (r5)
+ * mpi_ptr_t s2_ptr, (r6)
+ * mpi_size_t size) (r7)
+ */
+
+
+ .text
+ .align 2
+ .globl _gcry_mpih_sub_n
+ .ent _gcry_mpih_sub_n
+_gcry_mpih_sub_n:
+ .set noreorder
+ .set nomacro
+
+ ld $10,0($5)
+ ld $11,0($6)
+
+ daddiu $7,$7,-1
+ and $9,$7,4-1 # number of limbs in first loop
+ beq $9,$0,.L0 # if multiple of 4 limbs, skip first loop
+ move $2,$0
+
+ dsubu $7,$7,$9
+
+.Loop0: daddiu $9,$9,-1
+ ld $12,8($5)
+ daddu $11,$11,$2
+ ld $13,8($6)
+ sltu $8,$11,$2
+ dsubu $11,$10,$11
+ sltu $2,$10,$11
+ sd $11,0($4)
+ or $2,$2,$8
+
+ daddiu $5,$5,8
+ daddiu $6,$6,8
+ move $10,$12
+ move $11,$13
+ bne $9,$0,.Loop0
+ daddiu $4,$4,8
+
+.L0: beq $7,$0,.Lend
+ nop
+
+.Loop: daddiu $7,$7,-4
+
+ ld $12,8($5)
+ daddu $11,$11,$2
+ ld $13,8($6)
+ sltu $8,$11,$2
+ dsubu $11,$10,$11
+ sltu $2,$10,$11
+ sd $11,0($4)
+ or $2,$2,$8
+
+ ld $10,16($5)
+ daddu $13,$13,$2
+ ld $11,16($6)
+ sltu $8,$13,$2
+ dsubu $13,$12,$13
+ sltu $2,$12,$13
+ sd $13,8($4)
+ or $2,$2,$8
+
+ ld $12,24($5)
+ daddu $11,$11,$2
+ ld $13,24($6)
+ sltu $8,$11,$2
+ dsubu $11,$10,$11
+ sltu $2,$10,$11
+ sd $11,16($4)
+ or $2,$2,$8
+
+ ld $10,32($5)
+ daddu $13,$13,$2
+ ld $11,32($6)
+ sltu $8,$13,$2
+ dsubu $13,$12,$13
+ sltu $2,$12,$13
+ sd $13,24($4)
+ or $2,$2,$8
+
+ daddiu $5,$5,32
+ daddiu $6,$6,32
+
+ bne $7,$0,.Loop
+ daddiu $4,$4,32
+
+.Lend: daddu $11,$11,$2
+ sltu $8,$11,$2
+ dsubu $11,$10,$11
+ sltu $2,$10,$11
+ sd $11,0($4)
+ j $31
+ or $2,$2,$8
+
+ .end _gcry_mpih_sub_n
+
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-add.c b/grub-core/lib/libgcrypt/mpi/mpi-add.c
new file mode 100644
index 0000000..98abc56
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-add.c
@@ -0,0 +1,235 @@
+/* mpi-add.c - MPI functions
+ * Copyright (C) 1994, 1996, 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mpi-internal.h"
+
+
+/****************
+ * Add the unsigned integer V to the mpi-integer U and store the
+ * result in W. U and V may be the same.
+ */
+void
+gcry_mpi_add_ui(gcry_mpi_t w, gcry_mpi_t u, unsigned long v )
+{
+ mpi_ptr_t wp, up;
+ mpi_size_t usize, wsize;
+ int usign, wsign;
+
+ usize = u->nlimbs;
+ usign = u->sign;
+ wsign = 0;
+
+ /* If not space for W (and possible carry), increase space. */
+ wsize = usize + 1;
+ if( w->alloced < wsize )
+ mpi_resize(w, wsize);
+
+ /* These must be after realloc (U may be the same as W). */
+ up = u->d;
+ wp = w->d;
+
+ if( !usize ) { /* simple */
+ wp[0] = v;
+ wsize = v? 1:0;
+ }
+ else if( !usign ) { /* mpi is not negative */
+ mpi_limb_t cy;
+ cy = _gcry_mpih_add_1(wp, up, usize, v);
+ wp[usize] = cy;
+ wsize = usize + cy;
+ }
+ else { /* The signs are different. Need exact comparison to determine
+ * which operand to subtract from which. */
+ if( usize == 1 && up[0] < v ) {
+ wp[0] = v - up[0];
+ wsize = 1;
+ }
+ else {
+ _gcry_mpih_sub_1(wp, up, usize, v);
+ /* Size can decrease with at most one limb. */
+ wsize = usize - (wp[usize-1]==0);
+ wsign = 1;
+ }
+ }
+
+ w->nlimbs = wsize;
+ w->sign = wsign;
+}
+
+
+void
+gcry_mpi_add(gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ mpi_ptr_t wp, up, vp;
+ mpi_size_t usize, vsize, wsize;
+ int usign, vsign, wsign;
+
+ if( u->nlimbs < v->nlimbs ) { /* Swap U and V. */
+ usize = v->nlimbs;
+ usign = v->sign;
+ vsize = u->nlimbs;
+ vsign = u->sign;
+ wsize = usize + 1;
+ RESIZE_IF_NEEDED(w, wsize);
+ /* These must be after realloc (u or v may be the same as w). */
+ up = v->d;
+ vp = u->d;
+ }
+ else {
+ usize = u->nlimbs;
+ usign = u->sign;
+ vsize = v->nlimbs;
+ vsign = v->sign;
+ wsize = usize + 1;
+ RESIZE_IF_NEEDED(w, wsize);
+ /* These must be after realloc (u or v may be the same as w). */
+ up = u->d;
+ vp = v->d;
+ }
+ wp = w->d;
+ wsign = 0;
+
+ if( !vsize ) { /* simple */
+ MPN_COPY(wp, up, usize );
+ wsize = usize;
+ wsign = usign;
+ }
+ else if( usign != vsign ) { /* different sign */
+ /* This test is right since USIZE >= VSIZE */
+ if( usize != vsize ) {
+ _gcry_mpih_sub(wp, up, usize, vp, vsize);
+ wsize = usize;
+ MPN_NORMALIZE(wp, wsize);
+ wsign = usign;
+ }
+ else if( _gcry_mpih_cmp(up, vp, usize) < 0 ) {
+ _gcry_mpih_sub_n(wp, vp, up, usize);
+ wsize = usize;
+ MPN_NORMALIZE(wp, wsize);
+ if( !usign )
+ wsign = 1;
+ }
+ else {
+ _gcry_mpih_sub_n(wp, up, vp, usize);
+ wsize = usize;
+ MPN_NORMALIZE(wp, wsize);
+ if( usign )
+ wsign = 1;
+ }
+ }
+ else { /* U and V have same sign. Add them. */
+ mpi_limb_t cy = _gcry_mpih_add(wp, up, usize, vp, vsize);
+ wp[usize] = cy;
+ wsize = usize + cy;
+ if( usign )
+ wsign = 1;
+ }
+
+ w->nlimbs = wsize;
+ w->sign = wsign;
+}
+
+
+/****************
+ * Subtract the unsigned integer V from the mpi-integer U and store the
+ * result in W.
+ */
+void
+gcry_mpi_sub_ui(gcry_mpi_t w, gcry_mpi_t u, unsigned long v )
+{
+ mpi_ptr_t wp, up;
+ mpi_size_t usize, wsize;
+ int usign, wsign;
+
+ usize = u->nlimbs;
+ usign = u->sign;
+ wsign = 0;
+
+ /* If not space for W (and possible carry), increase space. */
+ wsize = usize + 1;
+ if( w->alloced < wsize )
+ mpi_resize(w, wsize);
+
+ /* These must be after realloc (U may be the same as W). */
+ up = u->d;
+ wp = w->d;
+
+ if( !usize ) { /* simple */
+ wp[0] = v;
+ wsize = v? 1:0;
+ wsign = 1;
+ }
+ else if( usign ) { /* mpi and v are negative */
+ mpi_limb_t cy;
+ cy = _gcry_mpih_add_1(wp, up, usize, v);
+ wp[usize] = cy;
+ wsize = usize + cy;
+ }
+ else { /* The signs are different. Need exact comparison to determine
+ * which operand to subtract from which. */
+ if( usize == 1 && up[0] < v ) {
+ wp[0] = v - up[0];
+ wsize = 1;
+ wsign = 1;
+ }
+ else {
+ _gcry_mpih_sub_1(wp, up, usize, v);
+ /* Size can decrease with at most one limb. */
+ wsize = usize - (wp[usize-1]==0);
+ }
+ }
+
+ w->nlimbs = wsize;
+ w->sign = wsign;
+}
+
+void
+gcry_mpi_sub(gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ gcry_mpi_t vv = mpi_copy (v);
+ vv->sign = ! vv->sign;
+ gcry_mpi_add (w, u, vv);
+ mpi_free (vv);
+}
+
+
+void
+gcry_mpi_addm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ gcry_mpi_add(w, u, v);
+ _gcry_mpi_fdiv_r( w, w, m );
+}
+
+void
+gcry_mpi_subm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ gcry_mpi_sub(w, u, v);
+ _gcry_mpi_fdiv_r( w, w, m );
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-bit.c b/grub-core/lib/libgcrypt/mpi/mpi-bit.c
new file mode 100644
index 0000000..cdc6b0b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-bit.c
@@ -0,0 +1,364 @@
+/* mpi-bit.c - MPI bit level functions
+ * Copyright (C) 1998, 1999, 2001, 2002, 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+#ifdef MPI_INTERNAL_NEED_CLZ_TAB
+#ifdef __STDC__
+const
+#endif
+unsigned char
+_gcry_clz_tab[] =
+{
+ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+};
+#endif
+
+
+#define A_LIMB_1 ((mpi_limb_t)1)
+
+
+/****************
+ * Sometimes we have MSL (most significant limbs) which are 0;
+ * this is for some reasons not good, so this function removes them.
+ */
+void
+_gcry_mpi_normalize( gcry_mpi_t a )
+{
+ if( mpi_is_opaque(a) )
+ return;
+
+ for( ; a->nlimbs && !a->d[a->nlimbs-1]; a->nlimbs-- )
+ ;
+}
+
+
+
+/****************
+ * Return the number of bits in A.
+ */
+unsigned int
+gcry_mpi_get_nbits( gcry_mpi_t a )
+{
+ unsigned n;
+
+ if( mpi_is_opaque(a) ) {
+ return a->sign; /* which holds the number of bits */
+ }
+
+ _gcry_mpi_normalize( a );
+ if( a->nlimbs ) {
+ mpi_limb_t alimb = a->d[a->nlimbs-1];
+ if( alimb )
+ count_leading_zeros( n, alimb );
+ else
+ n = BITS_PER_MPI_LIMB;
+ n = BITS_PER_MPI_LIMB - n + (a->nlimbs-1) * BITS_PER_MPI_LIMB;
+ }
+ else
+ n = 0;
+ return n;
+}
+
+
+/****************
+ * Test whether bit N is set.
+ */
+int
+gcry_mpi_test_bit( gcry_mpi_t a, unsigned int n )
+{
+ unsigned int limbno, bitno;
+ mpi_limb_t limb;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if( limbno >= a->nlimbs )
+ return 0; /* too far left: this is a 0 */
+ limb = a->d[limbno];
+ return (limb & (A_LIMB_1 << bitno))? 1: 0;
+}
+
+
+/****************
+ * Set bit N of A.
+ */
+void
+gcry_mpi_set_bit( gcry_mpi_t a, unsigned int n )
+{
+ unsigned int limbno, bitno;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if ( limbno >= a->nlimbs )
+ {
+ mpi_resize (a, limbno+1 );
+ a->nlimbs = limbno+1;
+ }
+ a->d[limbno] |= (A_LIMB_1<<bitno);
+}
+
+/****************
+ * Set bit N of A. and clear all bits above
+ */
+void
+gcry_mpi_set_highbit( gcry_mpi_t a, unsigned int n )
+{
+ unsigned int limbno, bitno;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if ( limbno >= a->nlimbs )
+ {
+ mpi_resize (a, limbno+1 );
+ a->nlimbs = limbno+1;
+ }
+ a->d[limbno] |= (A_LIMB_1<<bitno);
+ for ( bitno++; bitno < BITS_PER_MPI_LIMB; bitno++ )
+ a->d[limbno] &= ~(A_LIMB_1 << bitno);
+ a->nlimbs = limbno+1;
+}
+
+/****************
+ * clear bit N of A and all bits above
+ */
+void
+gcry_mpi_clear_highbit( gcry_mpi_t a, unsigned int n )
+{
+ unsigned int limbno, bitno;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if( limbno >= a->nlimbs )
+ return; /* not allocated, therefore no need to clear bits
+ :-) */
+
+ for( ; bitno < BITS_PER_MPI_LIMB; bitno++ )
+ a->d[limbno] &= ~(A_LIMB_1 << bitno);
+ a->nlimbs = limbno+1;
+}
+
+/****************
+ * Clear bit N of A.
+ */
+void
+gcry_mpi_clear_bit( gcry_mpi_t a, unsigned int n )
+{
+ unsigned int limbno, bitno;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if( limbno >= a->nlimbs )
+ return; /* don't need to clear this bit, it's to far to left */
+ a->d[limbno] &= ~(A_LIMB_1 << bitno);
+}
+
+
+/****************
+ * Shift A by COUNT limbs to the right
+ * This is used only within the MPI library
+ */
+void
+_gcry_mpi_rshift_limbs( gcry_mpi_t a, unsigned int count )
+{
+ mpi_ptr_t ap = a->d;
+ mpi_size_t n = a->nlimbs;
+ unsigned int i;
+
+ if( count >= n ) {
+ a->nlimbs = 0;
+ return;
+ }
+
+ for( i = 0; i < n - count; i++ )
+ ap[i] = ap[i+count];
+ ap[i] = 0;
+ a->nlimbs -= count;
+}
+
+
+/*
+ * Shift A by N bits to the right.
+ */
+void
+gcry_mpi_rshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n )
+{
+ mpi_size_t xsize;
+ unsigned int i;
+ unsigned int nlimbs = (n/BITS_PER_MPI_LIMB);
+ unsigned int nbits = (n%BITS_PER_MPI_LIMB);
+
+ if ( x == a )
+ {
+ /* In-place operation. */
+ if ( nlimbs >= x->nlimbs )
+ {
+ x->nlimbs = 0;
+ return;
+ }
+
+ if (nlimbs)
+ {
+ for (i=0; i < x->nlimbs - nlimbs; i++ )
+ x->d[i] = x->d[i+nlimbs];
+ x->d[i] = 0;
+ x->nlimbs -= nlimbs;
+
+ }
+ if ( x->nlimbs && nbits )
+ _gcry_mpih_rshift ( x->d, x->d, x->nlimbs, nbits );
+ }
+ else if ( nlimbs )
+ {
+ /* Copy and shift by more or equal bits than in a limb. */
+ xsize = a->nlimbs;
+ x->sign = a->sign;
+ RESIZE_IF_NEEDED (x, xsize);
+ x->nlimbs = xsize;
+ for (i=0; i < a->nlimbs; i++ )
+ x->d[i] = a->d[i];
+ x->nlimbs = i;
+
+ if ( nlimbs >= x->nlimbs )
+ {
+ x->nlimbs = 0;
+ return;
+ }
+
+ if (nlimbs)
+ {
+ for (i=0; i < x->nlimbs - nlimbs; i++ )
+ x->d[i] = x->d[i+nlimbs];
+ x->d[i] = 0;
+ x->nlimbs -= nlimbs;
+ }
+
+ if ( x->nlimbs && nbits )
+ _gcry_mpih_rshift ( x->d, x->d, x->nlimbs, nbits );
+ }
+ else
+ {
+ /* Copy and shift by less than bits in a limb. */
+ xsize = a->nlimbs;
+ x->sign = a->sign;
+ RESIZE_IF_NEEDED (x, xsize);
+ x->nlimbs = xsize;
+
+ if ( xsize )
+ {
+ if (nbits )
+ _gcry_mpih_rshift (x->d, a->d, x->nlimbs, nbits );
+ else
+ {
+ /* The rshift helper function is not specified for
+ NBITS==0, thus we do a plain copy here. */
+ for (i=0; i < x->nlimbs; i++ )
+ x->d[i] = a->d[i];
+ }
+ }
+ }
+ MPN_NORMALIZE (x->d, x->nlimbs);
+}
+
+
+/****************
+ * Shift A by COUNT limbs to the left
+ * This is used only within the MPI library
+ */
+void
+_gcry_mpi_lshift_limbs (gcry_mpi_t a, unsigned int count)
+{
+ mpi_ptr_t ap;
+ int n = a->nlimbs;
+ int i;
+
+ if (!count || !n)
+ return;
+
+ RESIZE_IF_NEEDED (a, n+count);
+
+ ap = a->d;
+ for (i = n-1; i >= 0; i--)
+ ap[i+count] = ap[i];
+ for (i=0; i < count; i++ )
+ ap[i] = 0;
+ a->nlimbs += count;
+}
+
+
+/*
+ * Shift A by N bits to the left.
+ */
+void
+gcry_mpi_lshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n )
+{
+ unsigned int nlimbs = (n/BITS_PER_MPI_LIMB);
+ unsigned int nbits = (n%BITS_PER_MPI_LIMB);
+
+ if (x == a && !n)
+ return; /* In-place shift with an amount of zero. */
+
+ if ( x != a )
+ {
+ /* Copy A to X. */
+ unsigned int alimbs = a->nlimbs;
+ int asign = a->sign;
+ mpi_ptr_t xp, ap;
+
+ RESIZE_IF_NEEDED (x, alimbs+nlimbs+1);
+ xp = x->d;
+ ap = a->d;
+ MPN_COPY (xp, ap, alimbs);
+ x->nlimbs = alimbs;
+ x->flags = a->flags;
+ x->sign = asign;
+ }
+
+ if (nlimbs && !nbits)
+ {
+ /* Shift a full number of limbs. */
+ _gcry_mpi_lshift_limbs (x, nlimbs);
+ }
+ else if (n)
+ {
+ /* We use a very dump approach: Shift left by the number of
+ limbs plus one and than fix it up by an rshift. */
+ _gcry_mpi_lshift_limbs (x, nlimbs+1);
+ gcry_mpi_rshift (x, x, BITS_PER_MPI_LIMB - nbits);
+ }
+
+ MPN_NORMALIZE (x->d, x->nlimbs);
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-cmp.c b/grub-core/lib/libgcrypt/mpi/mpi-cmp.c
new file mode 100644
index 0000000..30e1fce
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-cmp.c
@@ -0,0 +1,107 @@
+/* mpi-cmp.c - MPI functions
+ * Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+int
+gcry_mpi_cmp_ui (gcry_mpi_t u, unsigned long v)
+{
+ mpi_limb_t limb = v;
+
+ _gcry_mpi_normalize (u);
+
+ /* Handle the case that U contains no limb. */
+ if (u->nlimbs == 0)
+ return -(limb != 0);
+
+ /* Handle the case that U is negative. */
+ if (u->sign)
+ return -1;
+
+ if (u->nlimbs == 1)
+ {
+ /* Handle the case that U contains exactly one limb. */
+
+ if (u->d[0] > limb)
+ return 1;
+ if (u->d[0] < limb)
+ return -1;
+ return 0;
+ }
+ else
+ /* Handle the case that U contains more than one limb. */
+ return 1;
+}
+
+
+int
+gcry_mpi_cmp (gcry_mpi_t u, gcry_mpi_t v)
+{
+ mpi_size_t usize;
+ mpi_size_t vsize;
+ int cmp;
+
+ if (mpi_is_opaque (u) || mpi_is_opaque (v))
+ {
+ if (mpi_is_opaque (u) && !mpi_is_opaque (v))
+ return -1;
+ if (!mpi_is_opaque (u) && mpi_is_opaque (v))
+ return 1;
+ if (!u->sign && !v->sign)
+ return 0; /* Empty buffers are identical. */
+ if (u->sign < v->sign)
+ return -1;
+ if (u->sign > v->sign)
+ return 1;
+ return memcmp (u->d, v->d, (u->sign+7)/8);
+ }
+ else
+ {
+ _gcry_mpi_normalize (u);
+ _gcry_mpi_normalize (v);
+
+ usize = u->nlimbs;
+ vsize = v->nlimbs;
+
+ /* Compare sign bits. */
+
+ if (!u->sign && v->sign)
+ return 1;
+ if (u->sign && !v->sign)
+ return -1;
+
+ /* U and V are either both positive or both negative. */
+
+ if (usize != vsize && !u->sign && !v->sign)
+ return usize - vsize;
+ if (usize != vsize && u->sign && v->sign)
+ return vsize + usize;
+ if (!usize )
+ return 0;
+ if (!(cmp = _gcry_mpih_cmp (u->d, v->d, usize)))
+ return 0;
+ if ((cmp < 0?1:0) == (u->sign?1:0))
+ return 1;
+ }
+ return -1;
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-div.c b/grub-core/lib/libgcrypt/mpi/mpi-div.c
new file mode 100644
index 0000000..a6ee300
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-div.c
@@ -0,0 +1,355 @@
+/* mpi-div.c - MPI functions
+ * Copyright (C) 1994, 1996, 1998, 2001, 2002,
+ * 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+#include "g10lib.h"
+
+
+void
+_gcry_mpi_fdiv_r( gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor )
+{
+ int divisor_sign = divisor->sign;
+ gcry_mpi_t temp_divisor = NULL;
+
+ /* We need the original value of the divisor after the remainder has been
+ * preliminary calculated. We have to copy it to temporary space if it's
+ * the same variable as REM. */
+ if( rem == divisor ) {
+ temp_divisor = mpi_copy( divisor );
+ divisor = temp_divisor;
+ }
+
+ _gcry_mpi_tdiv_r( rem, dividend, divisor );
+
+ if( ((divisor_sign?1:0) ^ (dividend->sign?1:0)) && rem->nlimbs )
+ gcry_mpi_add( rem, rem, divisor);
+
+ if( temp_divisor )
+ mpi_free(temp_divisor);
+}
+
+
+
+/****************
+ * Division rounding the quotient towards -infinity.
+ * The remainder gets the same sign as the denominator.
+ * rem is optional
+ */
+
+ulong
+_gcry_mpi_fdiv_r_ui( gcry_mpi_t rem, gcry_mpi_t dividend, ulong divisor )
+{
+ mpi_limb_t rlimb;
+
+ rlimb = _gcry_mpih_mod_1( dividend->d, dividend->nlimbs, divisor );
+ if( rlimb && dividend->sign )
+ rlimb = divisor - rlimb;
+
+ if( rem ) {
+ rem->d[0] = rlimb;
+ rem->nlimbs = rlimb? 1:0;
+ }
+ return rlimb;
+}
+
+
+void
+_gcry_mpi_fdiv_q( gcry_mpi_t quot, gcry_mpi_t dividend, gcry_mpi_t divisor )
+{
+ gcry_mpi_t tmp = mpi_alloc( mpi_get_nlimbs(quot) );
+ _gcry_mpi_fdiv_qr( quot, tmp, dividend, divisor);
+ mpi_free(tmp);
+}
+
+void
+_gcry_mpi_fdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor )
+{
+ int divisor_sign = divisor->sign;
+ gcry_mpi_t temp_divisor = NULL;
+
+ if( quot == divisor || rem == divisor ) {
+ temp_divisor = mpi_copy( divisor );
+ divisor = temp_divisor;
+ }
+
+ _gcry_mpi_tdiv_qr( quot, rem, dividend, divisor );
+
+ if( (divisor_sign ^ dividend->sign) && rem->nlimbs ) {
+ gcry_mpi_sub_ui( quot, quot, 1 );
+ gcry_mpi_add( rem, rem, divisor);
+ }
+
+ if( temp_divisor )
+ mpi_free(temp_divisor);
+}
+
+
+/* If den == quot, den needs temporary storage.
+ * If den == rem, den needs temporary storage.
+ * If num == quot, num needs temporary storage.
+ * If den has temporary storage, it can be normalized while being copied,
+ * i.e no extra storage should be allocated.
+ */
+
+void
+_gcry_mpi_tdiv_r( gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t den)
+{
+ _gcry_mpi_tdiv_qr(NULL, rem, num, den );
+}
+
+void
+_gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t den)
+{
+ mpi_ptr_t np, dp;
+ mpi_ptr_t qp, rp;
+ mpi_size_t nsize = num->nlimbs;
+ mpi_size_t dsize = den->nlimbs;
+ mpi_size_t qsize, rsize;
+ mpi_size_t sign_remainder = num->sign;
+ mpi_size_t sign_quotient = num->sign ^ den->sign;
+ unsigned normalization_steps;
+ mpi_limb_t q_limb;
+ mpi_ptr_t marker[5];
+ unsigned int marker_nlimbs[5];
+ int markidx=0;
+
+ /* Ensure space is enough for quotient and remainder.
+ * We need space for an extra limb in the remainder, because it's
+ * up-shifted (normalized) below. */
+ rsize = nsize + 1;
+ mpi_resize( rem, rsize);
+
+ qsize = rsize - dsize; /* qsize cannot be bigger than this. */
+ if( qsize <= 0 ) {
+ if( num != rem ) {
+ rem->nlimbs = num->nlimbs;
+ rem->sign = num->sign;
+ MPN_COPY(rem->d, num->d, nsize);
+ }
+ if( quot ) {
+ /* This needs to follow the assignment to rem, in case the
+ * numerator and quotient are the same. */
+ quot->nlimbs = 0;
+ quot->sign = 0;
+ }
+ return;
+ }
+
+ if( quot )
+ mpi_resize( quot, qsize);
+
+ /* Read pointers here, when reallocation is finished. */
+ np = num->d;
+ dp = den->d;
+ rp = rem->d;
+
+ /* Optimize division by a single-limb divisor. */
+ if( dsize == 1 ) {
+ mpi_limb_t rlimb;
+ if( quot ) {
+ qp = quot->d;
+ rlimb = _gcry_mpih_divmod_1( qp, np, nsize, dp[0] );
+ qsize -= qp[qsize - 1] == 0;
+ quot->nlimbs = qsize;
+ quot->sign = sign_quotient;
+ }
+ else
+ rlimb = _gcry_mpih_mod_1( np, nsize, dp[0] );
+ rp[0] = rlimb;
+ rsize = rlimb != 0?1:0;
+ rem->nlimbs = rsize;
+ rem->sign = sign_remainder;
+ return;
+ }
+
+
+ if( quot ) {
+ qp = quot->d;
+ /* Make sure QP and NP point to different objects. Otherwise the
+ * numerator would be gradually overwritten by the quotient limbs. */
+ if(qp == np) { /* Copy NP object to temporary space. */
+ marker_nlimbs[markidx] = nsize;
+ np = marker[markidx++] = mpi_alloc_limb_space(nsize,
+ mpi_is_secure(quot));
+ MPN_COPY(np, qp, nsize);
+ }
+ }
+ else /* Put quotient at top of remainder. */
+ qp = rp + dsize;
+
+ count_leading_zeros( normalization_steps, dp[dsize - 1] );
+
+ /* Normalize the denominator, i.e. make its most significant bit set by
+ * shifting it NORMALIZATION_STEPS bits to the left. Also shift the
+ * numerator the same number of steps (to keep the quotient the same!).
+ */
+ if( normalization_steps ) {
+ mpi_ptr_t tp;
+ mpi_limb_t nlimb;
+
+ /* Shift up the denominator setting the most significant bit of
+ * the most significant word. Use temporary storage not to clobber
+ * the original contents of the denominator. */
+ marker_nlimbs[markidx] = dsize;
+ tp = marker[markidx++] = mpi_alloc_limb_space(dsize,mpi_is_secure(den));
+ _gcry_mpih_lshift( tp, dp, dsize, normalization_steps );
+ dp = tp;
+
+ /* Shift up the numerator, possibly introducing a new most
+ * significant word. Move the shifted numerator in the remainder
+ * meanwhile. */
+ nlimb = _gcry_mpih_lshift(rp, np, nsize, normalization_steps);
+ if( nlimb ) {
+ rp[nsize] = nlimb;
+ rsize = nsize + 1;
+ }
+ else
+ rsize = nsize;
+ }
+ else {
+ /* The denominator is already normalized, as required. Copy it to
+ * temporary space if it overlaps with the quotient or remainder. */
+ if( dp == rp || (quot && (dp == qp))) {
+ mpi_ptr_t tp;
+
+ marker_nlimbs[markidx] = dsize;
+ tp = marker[markidx++] = mpi_alloc_limb_space(dsize,
+ mpi_is_secure(den));
+ MPN_COPY( tp, dp, dsize );
+ dp = tp;
+ }
+
+ /* Move the numerator to the remainder. */
+ if( rp != np )
+ MPN_COPY(rp, np, nsize);
+
+ rsize = nsize;
+ }
+
+ q_limb = _gcry_mpih_divrem( qp, 0, rp, rsize, dp, dsize );
+
+ if( quot ) {
+ qsize = rsize - dsize;
+ if(q_limb) {
+ qp[qsize] = q_limb;
+ qsize += 1;
+ }
+
+ quot->nlimbs = qsize;
+ quot->sign = sign_quotient;
+ }
+
+ rsize = dsize;
+ MPN_NORMALIZE (rp, rsize);
+
+ if( normalization_steps && rsize ) {
+ _gcry_mpih_rshift(rp, rp, rsize, normalization_steps);
+ rsize -= rp[rsize - 1] == 0?1:0;
+ }
+
+ rem->nlimbs = rsize;
+ rem->sign = sign_remainder;
+ while( markidx )
+ {
+ markidx--;
+ _gcry_mpi_free_limb_space (marker[markidx], marker_nlimbs[markidx]);
+ }
+}
+
+void
+_gcry_mpi_tdiv_q_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned int count )
+{
+ mpi_size_t usize, wsize;
+ mpi_size_t limb_cnt;
+
+ usize = u->nlimbs;
+ limb_cnt = count / BITS_PER_MPI_LIMB;
+ wsize = usize - limb_cnt;
+ if( limb_cnt >= usize )
+ w->nlimbs = 0;
+ else {
+ mpi_ptr_t wp;
+ mpi_ptr_t up;
+
+ RESIZE_IF_NEEDED( w, wsize );
+ wp = w->d;
+ up = u->d;
+
+ count %= BITS_PER_MPI_LIMB;
+ if( count ) {
+ _gcry_mpih_rshift( wp, up + limb_cnt, wsize, count );
+ wsize -= !wp[wsize - 1];
+ }
+ else {
+ MPN_COPY_INCR( wp, up + limb_cnt, wsize);
+ }
+
+ w->nlimbs = wsize;
+ }
+}
+
+/****************
+ * Check whether dividend is divisible by divisor
+ * (note: divisor must fit into a limb)
+ */
+int
+_gcry_mpi_divisible_ui(gcry_mpi_t dividend, ulong divisor )
+{
+ return !_gcry_mpih_mod_1( dividend->d, dividend->nlimbs, divisor );
+}
+
+
+void
+gcry_mpi_div (gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor, int round)
+{
+ if (!round)
+ {
+ if (!rem)
+ {
+ gcry_mpi_t tmp = mpi_alloc (mpi_get_nlimbs(quot));
+ _gcry_mpi_tdiv_qr (quot, tmp, dividend, divisor);
+ mpi_free (tmp);
+ }
+ else
+ _gcry_mpi_tdiv_qr (quot, rem, dividend, divisor);
+ }
+ else if (round < 0)
+ {
+ if (!rem)
+ _gcry_mpi_fdiv_q (quot, dividend, divisor);
+ else if (!quot)
+ _gcry_mpi_fdiv_r (rem, dividend, divisor);
+ else
+ _gcry_mpi_fdiv_qr (quot, rem, dividend, divisor);
+ }
+ else
+ log_bug ("mpi rounding to ceiling not yet implemented\n");
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-gcd.c b/grub-core/lib/libgcrypt/mpi/mpi-gcd.c
new file mode 100644
index 0000000..5cbefa1
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-gcd.c
@@ -0,0 +1,51 @@
+/* mpi-gcd.c - MPI functions
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+/****************
+ * Find the greatest common divisor G of A and B.
+ * Return: true if this 1, false in all other cases
+ */
+int
+gcry_mpi_gcd( gcry_mpi_t g, gcry_mpi_t xa, gcry_mpi_t xb )
+{
+ gcry_mpi_t a, b;
+
+ a = mpi_copy(xa);
+ b = mpi_copy(xb);
+
+ /* TAOCP Vol II, 4.5.2, Algorithm A */
+ a->sign = 0;
+ b->sign = 0;
+ while( gcry_mpi_cmp_ui( b, 0 ) ) {
+ _gcry_mpi_fdiv_r( g, a, b ); /* g used as temorary variable */
+ mpi_set(a,b);
+ mpi_set(b,g);
+ }
+ mpi_set(g, a);
+
+ mpi_free(a);
+ mpi_free(b);
+ return !gcry_mpi_cmp_ui( g, 1);
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-inline.c b/grub-core/lib/libgcrypt/mpi/mpi-inline.c
new file mode 100644
index 0000000..39e2222
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-inline.c
@@ -0,0 +1,35 @@
+/* mpi-inline.c
+ * Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* put the inline functions as real functions into the lib */
+#define G10_MPI_INLINE_DECL
+
+#include "mpi-internal.h"
+
+/* always include the header because it is only
+ * included by mpi-internal if __GCC__ is defined but we
+ * need it here in all cases and the above definition of
+ * of the macro allows us to do so
+ */
+#include "mpi-inline.h"
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-inline.h b/grub-core/lib/libgcrypt/mpi/mpi-inline.h
new file mode 100644
index 0000000..94e2aec
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-inline.h
@@ -0,0 +1,161 @@
+/* mpi-inline.h - Internal to the Multi Precision Integers
+ * Copyright (C) 1994, 1996, 1998, 1999,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#ifndef G10_MPI_INLINE_H
+#define G10_MPI_INLINE_H
+
+/* Starting with gcc 4.3 "extern inline" conforms in c99 mode to the
+ c99 semantics. To keep the useful old semantics we use an
+ attribute. */
+#ifndef G10_MPI_INLINE_DECL
+# ifdef __GNUC_STDC_INLINE__
+# define G10_MPI_INLINE_DECL extern inline __attribute__ ((__gnu_inline__))
+# else
+# define G10_MPI_INLINE_DECL extern __inline__
+# endif
+#endif
+
+G10_MPI_INLINE_DECL mpi_limb_t
+_gcry_mpih_add_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb)
+{
+ mpi_limb_t x;
+
+ x = *s1_ptr++;
+ s2_limb += x;
+ *res_ptr++ = s2_limb;
+ if( s2_limb < x ) { /* sum is less than the left operand: handle carry */
+ while( --s1_size ) {
+ x = *s1_ptr++ + 1; /* add carry */
+ *res_ptr++ = x; /* and store */
+ if( x ) /* not 0 (no overflow): we can stop */
+ goto leave;
+ }
+ return 1; /* return carry (size of s1 to small) */
+ }
+
+ leave:
+ if( res_ptr != s1_ptr ) { /* not the same variable */
+ mpi_size_t i; /* copy the rest */
+ for( i=0; i < s1_size-1; i++ )
+ res_ptr[i] = s1_ptr[i];
+ }
+ return 0; /* no carry */
+}
+
+
+
+G10_MPI_INLINE_DECL mpi_limb_t
+_gcry_mpih_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_ptr_t s2_ptr, mpi_size_t s2_size)
+{
+ mpi_limb_t cy = 0;
+
+ if( s2_size )
+ cy = _gcry_mpih_add_n( res_ptr, s1_ptr, s2_ptr, s2_size );
+
+ if( s1_size - s2_size )
+ cy = _gcry_mpih_add_1( res_ptr + s2_size, s1_ptr + s2_size,
+ s1_size - s2_size, cy);
+ return cy;
+}
+
+
+G10_MPI_INLINE_DECL mpi_limb_t
+_gcry_mpih_sub_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb )
+{
+ mpi_limb_t x;
+
+ x = *s1_ptr++;
+ s2_limb = x - s2_limb;
+ *res_ptr++ = s2_limb;
+ if( s2_limb > x ) {
+ while( --s1_size ) {
+ x = *s1_ptr++;
+ *res_ptr++ = x - 1;
+ if( x )
+ goto leave;
+ }
+ return 1;
+ }
+
+ leave:
+ if( res_ptr != s1_ptr ) {
+ mpi_size_t i;
+ for( i=0; i < s1_size-1; i++ )
+ res_ptr[i] = s1_ptr[i];
+ }
+ return 0;
+}
+
+
+
+G10_MPI_INLINE_DECL mpi_limb_t
+_gcry_mpih_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_ptr_t s2_ptr, mpi_size_t s2_size)
+{
+ mpi_limb_t cy = 0;
+
+ if( s2_size )
+ cy = _gcry_mpih_sub_n(res_ptr, s1_ptr, s2_ptr, s2_size);
+
+ if( s1_size - s2_size )
+ cy = _gcry_mpih_sub_1(res_ptr + s2_size, s1_ptr + s2_size,
+ s1_size - s2_size, cy);
+ return cy;
+}
+
+/****************
+ * Compare OP1_PTR/OP1_SIZE with OP2_PTR/OP2_SIZE.
+ * There are no restrictions on the relative sizes of
+ * the two arguments.
+ * Return 1 if OP1 > OP2, 0 if they are equal, and -1 if OP1 < OP2.
+ */
+G10_MPI_INLINE_DECL int
+_gcry_mpih_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size )
+{
+ mpi_size_t i;
+ mpi_limb_t op1_word, op2_word;
+
+ for( i = size - 1; i >= 0 ; i--) {
+ op1_word = op1_ptr[i];
+ op2_word = op2_ptr[i];
+ if( op1_word != op2_word )
+ goto diff;
+ }
+ return 0;
+
+ diff:
+ /* This can *not* be simplified to
+ * op2_word - op2_word
+ * since that expression might give signed overflow. */
+ return (op1_word > op2_word) ? 1 : -1;
+}
+
+
+#endif /*G10_MPI_INLINE_H*/
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-internal.h b/grub-core/lib/libgcrypt/mpi/mpi-internal.h
new file mode 100644
index 0000000..e75b7c6
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-internal.h
@@ -0,0 +1,277 @@
+/* mpi-internal.h - Internal to the Multi Precision Integers
+ * Copyright (C) 1994, 1996, 1998, 2000, 2002,
+ * 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#ifndef G10_MPI_INTERNAL_H
+#define G10_MPI_INTERNAL_H
+
+#include "mpi-asm-defs.h"
+
+#ifndef BITS_PER_MPI_LIMB
+#if BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_INT
+ typedef unsigned int mpi_limb_t;
+ typedef signed int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_LONG
+ typedef unsigned long int mpi_limb_t;
+ typedef signed long int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_LONG_LONG
+ typedef unsigned long long int mpi_limb_t;
+ typedef signed long long int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_SHORT
+ typedef unsigned short int mpi_limb_t;
+ typedef signed short int mpi_limb_signed_t;
+#else
+#error BYTES_PER_MPI_LIMB does not match any C type
+#endif
+#define BITS_PER_MPI_LIMB (8*BYTES_PER_MPI_LIMB)
+#endif /*BITS_PER_MPI_LIMB*/
+
+#include "mpi.h"
+
+/* If KARATSUBA_THRESHOLD is not already defined, define it to a
+ * value which is good on most machines. */
+
+/* tested 4, 16, 32 and 64, where 16 gave the best performance when
+ * checking a 768 and a 1024 bit ElGamal signature.
+ * (wk 22.12.97) */
+#ifndef KARATSUBA_THRESHOLD
+#define KARATSUBA_THRESHOLD 16
+#endif
+
+/* The code can't handle KARATSUBA_THRESHOLD smaller than 2. */
+#if KARATSUBA_THRESHOLD < 2
+#undef KARATSUBA_THRESHOLD
+#define KARATSUBA_THRESHOLD 2
+#endif
+
+
+typedef mpi_limb_t *mpi_ptr_t; /* pointer to a limb */
+typedef int mpi_size_t; /* (must be a signed type) */
+
+#define ABS(x) (x >= 0 ? x : -x)
+#define MIN(l,o) ((l) < (o) ? (l) : (o))
+#define MAX(h,i) ((h) > (i) ? (h) : (i))
+#define RESIZE_IF_NEEDED(a,b) \
+ do { \
+ if( (a)->alloced < (b) ) \
+ mpi_resize((a), (b)); \
+ } while(0)
+
+/* Copy N limbs from S to D. */
+#define MPN_COPY( d, s, n) \
+ do { \
+ mpi_size_t _i; \
+ for( _i = 0; _i < (n); _i++ ) \
+ (d)[_i] = (s)[_i]; \
+ } while(0)
+
+#define MPN_COPY_INCR( d, s, n) \
+ do { \
+ mpi_size_t _i; \
+ for( _i = 0; _i < (n); _i++ ) \
+ (d)[_i] = (d)[_i]; \
+ } while (0)
+
+#define MPN_COPY_DECR( d, s, n ) \
+ do { \
+ mpi_size_t _i; \
+ for( _i = (n)-1; _i >= 0; _i--) \
+ (d)[_i] = (s)[_i]; \
+ } while(0)
+
+/* Zero N limbs at D */
+#define MPN_ZERO(d, n) \
+ do { \
+ int _i; \
+ for( _i = 0; _i < (n); _i++ ) \
+ (d)[_i] = 0; \
+ } while (0)
+
+#define MPN_NORMALIZE(d, n) \
+ do { \
+ while( (n) > 0 ) { \
+ if( (d)[(n)-1] ) \
+ break; \
+ (n)--; \
+ } \
+ } while(0)
+
+#define MPN_NORMALIZE_NOT_ZERO(d, n) \
+ do { \
+ for(;;) { \
+ if( (d)[(n)-1] ) \
+ break; \
+ (n)--; \
+ } \
+ } while(0)
+
+#define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \
+ do { \
+ if( (size) < KARATSUBA_THRESHOLD ) \
+ mul_n_basecase (prodp, up, vp, size); \
+ else \
+ mul_n (prodp, up, vp, size, tspace); \
+ } while (0);
+
+
+/* Divide the two-limb number in (NH,,NL) by D, with DI being the largest
+ * limb not larger than (2**(2*BITS_PER_MP_LIMB))/D - (2**BITS_PER_MP_LIMB).
+ * If this would yield overflow, DI should be the largest possible number
+ * (i.e., only ones). For correct operation, the most significant bit of D
+ * has to be set. Put the quotient in Q and the remainder in R.
+ */
+#define UDIV_QRNND_PREINV(q, r, nh, nl, d, di) \
+ do { \
+ mpi_limb_t _q, _ql, _r; \
+ mpi_limb_t _xh, _xl; \
+ umul_ppmm (_q, _ql, (nh), (di)); \
+ _q += (nh); /* DI is 2**BITS_PER_MPI_LIMB too small */ \
+ umul_ppmm (_xh, _xl, _q, (d)); \
+ sub_ddmmss (_xh, _r, (nh), (nl), _xh, _xl); \
+ if( _xh ) { \
+ sub_ddmmss (_xh, _r, _xh, _r, 0, (d)); \
+ _q++; \
+ if( _xh) { \
+ sub_ddmmss (_xh, _r, _xh, _r, 0, (d)); \
+ _q++; \
+ } \
+ } \
+ if( _r >= (d) ) { \
+ _r -= (d); \
+ _q++; \
+ } \
+ (r) = _r; \
+ (q) = _q; \
+ } while (0)
+
+
+/*-- mpiutil.c --*/
+#define mpi_alloc_limb_space(n,f) _gcry_mpi_alloc_limb_space((n),(f))
+mpi_ptr_t _gcry_mpi_alloc_limb_space( unsigned nlimbs, int sec );
+void _gcry_mpi_free_limb_space( mpi_ptr_t a, unsigned int nlimbs );
+void _gcry_mpi_assign_limb_space( gcry_mpi_t a, mpi_ptr_t ap, unsigned nlimbs );
+
+/*-- mpi-bit.c --*/
+#define mpi_rshift_limbs(a,n) _gcry_mpi_rshift_limbs ((a), (n))
+#define mpi_lshift_limbs(a,n) _gcry_mpi_lshift_limbs ((a), (n))
+
+void _gcry_mpi_rshift_limbs( gcry_mpi_t a, unsigned int count );
+void _gcry_mpi_lshift_limbs( gcry_mpi_t a, unsigned int count );
+
+
+/*-- mpih-add.c --*/
+mpi_limb_t _gcry_mpih_add_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb );
+mpi_limb_t _gcry_mpih_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_ptr_t s2_ptr, mpi_size_t size);
+mpi_limb_t _gcry_mpih_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_ptr_t s2_ptr, mpi_size_t s2_size);
+
+/*-- mpih-sub.c --*/
+mpi_limb_t _gcry_mpih_sub_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb );
+mpi_limb_t _gcry_mpih_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_ptr_t s2_ptr, mpi_size_t size);
+mpi_limb_t _gcry_mpih_sub(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+ mpi_ptr_t s2_ptr, mpi_size_t s2_size);
+
+/*-- mpih-cmp.c --*/
+int _gcry_mpih_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size );
+
+/*-- mpih-mul.c --*/
+
+struct karatsuba_ctx {
+ struct karatsuba_ctx *next;
+ mpi_ptr_t tspace;
+ unsigned int tspace_nlimbs;
+ mpi_size_t tspace_size;
+ mpi_ptr_t tp;
+ unsigned int tp_nlimbs;
+ mpi_size_t tp_size;
+};
+
+void _gcry_mpih_release_karatsuba_ctx( struct karatsuba_ctx *ctx );
+
+mpi_limb_t _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb);
+mpi_limb_t _gcry_mpih_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb);
+void _gcry_mpih_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp,
+ mpi_size_t size);
+mpi_limb_t _gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize,
+ mpi_ptr_t vp, mpi_size_t vsize);
+void _gcry_mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size );
+void _gcry_mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size,
+ mpi_ptr_t tspace);
+
+void _gcry_mpih_mul_karatsuba_case( mpi_ptr_t prodp,
+ mpi_ptr_t up, mpi_size_t usize,
+ mpi_ptr_t vp, mpi_size_t vsize,
+ struct karatsuba_ctx *ctx );
+
+
+/*-- mpih-mul_1.c (or xxx/cpu/ *.S) --*/
+mpi_limb_t _gcry_mpih_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+ mpi_size_t s1_size, mpi_limb_t s2_limb);
+
+/*-- mpih-div.c --*/
+mpi_limb_t _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+ mpi_limb_t divisor_limb);
+mpi_limb_t _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs,
+ mpi_ptr_t np, mpi_size_t nsize,
+ mpi_ptr_t dp, mpi_size_t dsize);
+mpi_limb_t _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr,
+ mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+ mpi_limb_t divisor_limb);
+
+/*-- mpih-shift.c --*/
+mpi_limb_t _gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
+ unsigned cnt);
+mpi_limb_t _gcry_mpih_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
+ unsigned cnt);
+
+
+/* Define stuff for longlong.h. */
+#define W_TYPE_SIZE BITS_PER_MPI_LIMB
+ typedef mpi_limb_t UWtype;
+ typedef unsigned int UHWtype;
+#if defined (__GNUC__)
+ typedef unsigned int UQItype __attribute__ ((mode (QI)));
+ typedef int SItype __attribute__ ((mode (SI)));
+ typedef unsigned int USItype __attribute__ ((mode (SI)));
+ typedef int DItype __attribute__ ((mode (DI)));
+ typedef unsigned int UDItype __attribute__ ((mode (DI)));
+#else
+ typedef unsigned char UQItype;
+ typedef long SItype;
+ typedef unsigned long USItype;
+#endif
+
+#ifdef __GNUC__
+#include "mpi-inline.h"
+#endif
+
+#endif /*G10_MPI_INTERNAL_H*/
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-inv.c b/grub-core/lib/libgcrypt/mpi/mpi-inv.c
new file mode 100644
index 0000000..5d26946
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-inv.c
@@ -0,0 +1,267 @@
+/* mpi-inv.c - MPI functions
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "g10lib.h"
+
+/****************
+ * Calculate the multiplicative inverse X of A mod N
+ * That is: Find the solution x for
+ * 1 = (a*x) mod n
+ */
+int
+gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n )
+{
+#if 0
+ gcry_mpi_t u, v, u1, u2, u3, v1, v2, v3, q, t1, t2, t3;
+ gcry_mpi_t ta, tb, tc;
+
+ u = mpi_copy(a);
+ v = mpi_copy(n);
+ u1 = mpi_alloc_set_ui(1);
+ u2 = mpi_alloc_set_ui(0);
+ u3 = mpi_copy(u);
+ v1 = mpi_alloc_set_ui(0);
+ v2 = mpi_alloc_set_ui(1);
+ v3 = mpi_copy(v);
+ q = mpi_alloc( mpi_get_nlimbs(u)+1 );
+ t1 = mpi_alloc( mpi_get_nlimbs(u)+1 );
+ t2 = mpi_alloc( mpi_get_nlimbs(u)+1 );
+ t3 = mpi_alloc( mpi_get_nlimbs(u)+1 );
+ while( mpi_cmp_ui( v3, 0 ) ) {
+ mpi_fdiv_q( q, u3, v3 );
+ mpi_mul(t1, v1, q); mpi_mul(t2, v2, q); mpi_mul(t3, v3, q);
+ mpi_sub(t1, u1, t1); mpi_sub(t2, u2, t2); mpi_sub(t3, u3, t3);
+ mpi_set(u1, v1); mpi_set(u2, v2); mpi_set(u3, v3);
+ mpi_set(v1, t1); mpi_set(v2, t2); mpi_set(v3, t3);
+ }
+ /* log_debug("result:\n");
+ log_mpidump("q =", q );
+ log_mpidump("u1=", u1);
+ log_mpidump("u2=", u2);
+ log_mpidump("u3=", u3);
+ log_mpidump("v1=", v1);
+ log_mpidump("v2=", v2); */
+ mpi_set(x, u1);
+
+ mpi_free(u1);
+ mpi_free(u2);
+ mpi_free(u3);
+ mpi_free(v1);
+ mpi_free(v2);
+ mpi_free(v3);
+ mpi_free(q);
+ mpi_free(t1);
+ mpi_free(t2);
+ mpi_free(t3);
+ mpi_free(u);
+ mpi_free(v);
+#elif 0
+ /* Extended Euclid's algorithm (See TAOCP Vol II, 4.5.2, Alg X)
+ * modified according to Michael Penk's solution for Exercise 35 */
+
+ /* FIXME: we can simplify this in most cases (see Knuth) */
+ gcry_mpi_t u, v, u1, u2, u3, v1, v2, v3, t1, t2, t3;
+ unsigned k;
+ int sign;
+
+ u = mpi_copy(a);
+ v = mpi_copy(n);
+ for(k=0; !mpi_test_bit(u,0) && !mpi_test_bit(v,0); k++ ) {
+ mpi_rshift(u, u, 1);
+ mpi_rshift(v, v, 1);
+ }
+
+
+ u1 = mpi_alloc_set_ui(1);
+ u2 = mpi_alloc_set_ui(0);
+ u3 = mpi_copy(u);
+ v1 = mpi_copy(v); /* !-- used as const 1 */
+ v2 = mpi_alloc( mpi_get_nlimbs(u) ); mpi_sub( v2, u1, u );
+ v3 = mpi_copy(v);
+ if( mpi_test_bit(u, 0) ) { /* u is odd */
+ t1 = mpi_alloc_set_ui(0);
+ t2 = mpi_alloc_set_ui(1); t2->sign = 1;
+ t3 = mpi_copy(v); t3->sign = !t3->sign;
+ goto Y4;
+ }
+ else {
+ t1 = mpi_alloc_set_ui(1);
+ t2 = mpi_alloc_set_ui(0);
+ t3 = mpi_copy(u);
+ }
+ do {
+ do {
+ if( mpi_test_bit(t1, 0) || mpi_test_bit(t2, 0) ) { /* one is odd */
+ mpi_add(t1, t1, v);
+ mpi_sub(t2, t2, u);
+ }
+ mpi_rshift(t1, t1, 1);
+ mpi_rshift(t2, t2, 1);
+ mpi_rshift(t3, t3, 1);
+ Y4:
+ ;
+ } while( !mpi_test_bit( t3, 0 ) ); /* while t3 is even */
+
+ if( !t3->sign ) {
+ mpi_set(u1, t1);
+ mpi_set(u2, t2);
+ mpi_set(u3, t3);
+ }
+ else {
+ mpi_sub(v1, v, t1);
+ sign = u->sign; u->sign = !u->sign;
+ mpi_sub(v2, u, t2);
+ u->sign = sign;
+ sign = t3->sign; t3->sign = !t3->sign;
+ mpi_set(v3, t3);
+ t3->sign = sign;
+ }
+ mpi_sub(t1, u1, v1);
+ mpi_sub(t2, u2, v2);
+ mpi_sub(t3, u3, v3);
+ if( t1->sign ) {
+ mpi_add(t1, t1, v);
+ mpi_sub(t2, t2, u);
+ }
+ } while( mpi_cmp_ui( t3, 0 ) ); /* while t3 != 0 */
+ /* mpi_lshift( u3, k ); */
+ mpi_set(x, u1);
+
+ mpi_free(u1);
+ mpi_free(u2);
+ mpi_free(u3);
+ mpi_free(v1);
+ mpi_free(v2);
+ mpi_free(v3);
+ mpi_free(t1);
+ mpi_free(t2);
+ mpi_free(t3);
+#else
+ /* Extended Euclid's algorithm (See TAOCP Vol II, 4.5.2, Alg X)
+ * modified according to Michael Penk's solution for Exercise 35
+ * with further enhancement */
+ gcry_mpi_t u, v, u1, u2=NULL, u3, v1, v2=NULL, v3, t1, t2=NULL, t3;
+ unsigned k;
+ int sign;
+ int odd ;
+
+ u = mpi_copy(a);
+ v = mpi_copy(n);
+
+ for(k=0; !mpi_test_bit(u,0) && !mpi_test_bit(v,0); k++ ) {
+ mpi_rshift(u, u, 1);
+ mpi_rshift(v, v, 1);
+ }
+ odd = mpi_test_bit(v,0);
+
+ u1 = mpi_alloc_set_ui(1);
+ if( !odd )
+ u2 = mpi_alloc_set_ui(0);
+ u3 = mpi_copy(u);
+ v1 = mpi_copy(v);
+ if( !odd ) {
+ v2 = mpi_alloc( mpi_get_nlimbs(u) );
+ mpi_sub( v2, u1, u ); /* U is used as const 1 */
+ }
+ v3 = mpi_copy(v);
+ if( mpi_test_bit(u, 0) ) { /* u is odd */
+ t1 = mpi_alloc_set_ui(0);
+ if( !odd ) {
+ t2 = mpi_alloc_set_ui(1); t2->sign = 1;
+ }
+ t3 = mpi_copy(v); t3->sign = !t3->sign;
+ goto Y4;
+ }
+ else {
+ t1 = mpi_alloc_set_ui(1);
+ if( !odd )
+ t2 = mpi_alloc_set_ui(0);
+ t3 = mpi_copy(u);
+ }
+ do {
+ do {
+ if( !odd ) {
+ if( mpi_test_bit(t1, 0) || mpi_test_bit(t2, 0) ) { /* one is odd */
+ mpi_add(t1, t1, v);
+ mpi_sub(t2, t2, u);
+ }
+ mpi_rshift(t1, t1, 1);
+ mpi_rshift(t2, t2, 1);
+ mpi_rshift(t3, t3, 1);
+ }
+ else {
+ if( mpi_test_bit(t1, 0) )
+ mpi_add(t1, t1, v);
+ mpi_rshift(t1, t1, 1);
+ mpi_rshift(t3, t3, 1);
+ }
+ Y4:
+ ;
+ } while( !mpi_test_bit( t3, 0 ) ); /* while t3 is even */
+
+ if( !t3->sign ) {
+ mpi_set(u1, t1);
+ if( !odd )
+ mpi_set(u2, t2);
+ mpi_set(u3, t3);
+ }
+ else {
+ mpi_sub(v1, v, t1);
+ sign = u->sign; u->sign = !u->sign;
+ if( !odd )
+ mpi_sub(v2, u, t2);
+ u->sign = sign;
+ sign = t3->sign; t3->sign = !t3->sign;
+ mpi_set(v3, t3);
+ t3->sign = sign;
+ }
+ mpi_sub(t1, u1, v1);
+ if( !odd )
+ mpi_sub(t2, u2, v2);
+ mpi_sub(t3, u3, v3);
+ if( t1->sign ) {
+ mpi_add(t1, t1, v);
+ if( !odd )
+ mpi_sub(t2, t2, u);
+ }
+ } while( mpi_cmp_ui( t3, 0 ) ); /* while t3 != 0 */
+ /* mpi_lshift( u3, k ); */
+ mpi_set(x, u1);
+
+ mpi_free(u1);
+ mpi_free(v1);
+ mpi_free(t1);
+ if( !odd ) {
+ mpi_free(u2);
+ mpi_free(v2);
+ mpi_free(t2);
+ }
+ mpi_free(u3);
+ mpi_free(v3);
+ mpi_free(t3);
+
+ mpi_free(u);
+ mpi_free(v);
+#endif
+ return 1;
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-mod.c b/grub-core/lib/libgcrypt/mpi/mpi-mod.c
new file mode 100644
index 0000000..7ebfe6d
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-mod.c
@@ -0,0 +1,184 @@
+/* mpi-mod.c - Modular reduction
+ Copyright (C) 1998, 1999, 2001, 2002, 2003,
+ 2007 Free Software Foundation, Inc.
+
+ This file is part of Libgcrypt.
+
+ Libgcrypt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Libgcrypt is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mpi-internal.h"
+#include "longlong.h"
+#include "g10lib.h"
+
+
+/* Context used with Barrett reduction. */
+struct barrett_ctx_s
+{
+ gcry_mpi_t m; /* The modulus - may not be modified. */
+ int m_copied; /* If true, M needs to be released. */
+ int k;
+ gcry_mpi_t y;
+ gcry_mpi_t r1; /* Helper MPI. */
+ gcry_mpi_t r2; /* Helper MPI. */
+ gcry_mpi_t r3; /* Helper MPI allocated on demand. */
+};
+
+
+
+void
+_gcry_mpi_mod (gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor)
+{
+ _gcry_mpi_fdiv_r (rem, dividend, divisor);
+ rem->sign = 0;
+}
+
+
+/* This function returns a new context for Barrett based operations on
+ the modulus M. This context needs to be released using
+ _gcry_mpi_barrett_free. If COPY is true M will be transferred to
+ the context and the user may change M. If COPY is false, M may not
+ be changed until gcry_mpi_barrett_free has been called. */
+mpi_barrett_t
+_gcry_mpi_barrett_init (gcry_mpi_t m, int copy)
+{
+ mpi_barrett_t ctx;
+ gcry_mpi_t tmp;
+
+ mpi_normalize (m);
+ ctx = gcry_xcalloc (1, sizeof *ctx);
+
+ if (copy)
+ {
+ ctx->m = mpi_copy (m);
+ ctx->m_copied = 1;
+ }
+ else
+ ctx->m = m;
+
+ ctx->k = mpi_get_nlimbs (m);
+ tmp = mpi_alloc (ctx->k + 1);
+
+ /* Barrett precalculation: y = floor(b^(2k) / m). */
+ mpi_set_ui (tmp, 1);
+ mpi_lshift_limbs (tmp, 2 * ctx->k);
+ mpi_fdiv_q (tmp, tmp, m);
+
+ ctx->y = tmp;
+ ctx->r1 = mpi_alloc ( 2 * ctx->k + 1 );
+ ctx->r2 = mpi_alloc ( 2 * ctx->k + 1 );
+
+ return ctx;
+}
+
+void
+_gcry_mpi_barrett_free (mpi_barrett_t ctx)
+{
+ if (ctx)
+ {
+ mpi_free (ctx->y);
+ mpi_free (ctx->r1);
+ mpi_free (ctx->r2);
+ if (ctx->r3)
+ mpi_free (ctx->r3);
+ if (ctx->m_copied)
+ mpi_free (ctx->m);
+ gcry_free (ctx);
+ }
+}
+
+
+/* R = X mod M
+
+ Using Barrett reduction. Before using this function
+ _gcry_mpi_barrett_init must have been called to do the
+ precalculations. CTX is the context created by this precalculation
+ and also conveys M. If the Barret reduction could no be done a
+ starightforward reduction method is used.
+
+ We assume that these conditions are met:
+ Input: x =(x_2k-1 ...x_0)_b
+ m =(m_k-1 ....m_0)_b with m_k-1 != 0
+ Output: r = x mod m
+ */
+void
+_gcry_mpi_mod_barrett (gcry_mpi_t r, gcry_mpi_t x, mpi_barrett_t ctx)
+{
+ gcry_mpi_t m = ctx->m;
+ int k = ctx->k;
+ gcry_mpi_t y = ctx->y;
+ gcry_mpi_t r1 = ctx->r1;
+ gcry_mpi_t r2 = ctx->r2;
+
+ mpi_normalize (x);
+ if (mpi_get_nlimbs (x) > 2*k )
+ {
+ mpi_mod (r, x, m);
+ return;
+ }
+
+ /* 1. q1 = floor( x / b^k-1)
+ * q2 = q1 * y
+ * q3 = floor( q2 / b^k+1 )
+ * Actually, we don't need qx, we can work direct on r2
+ */
+ mpi_set ( r2, x );
+ mpi_rshift_limbs ( r2, k-1 );
+ mpi_mul ( r2, r2, y );
+ mpi_rshift_limbs ( r2, k+1 );
+
+ /* 2. r1 = x mod b^k+1
+ * r2 = q3 * m mod b^k+1
+ * r = r1 - r2
+ * 3. if r < 0 then r = r + b^k+1
+ */
+ mpi_set ( r1, x );
+ if ( r1->nlimbs > k+1 ) /* Quick modulo operation. */
+ r1->nlimbs = k+1;
+ mpi_mul ( r2, r2, m );
+ if ( r2->nlimbs > k+1 ) /* Quick modulo operation. */
+ r2->nlimbs = k+1;
+ mpi_sub ( r, r1, r2 );
+
+ if ( mpi_is_neg( r ) )
+ {
+ if (!ctx->r3)
+ {
+ ctx->r3 = mpi_alloc ( k + 2 );
+ mpi_set_ui (ctx->r3, 1);
+ mpi_lshift_limbs (ctx->r3, k + 1 );
+ }
+ mpi_add ( r, r, ctx->r3 );
+ }
+
+ /* 4. while r >= m do r = r - m */
+ while ( mpi_cmp( r, m ) >= 0 )
+ mpi_sub ( r, r, m );
+
+}
+
+
+void
+_gcry_mpi_mul_barrett (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v,
+ mpi_barrett_t ctx)
+{
+ gcry_mpi_mul (w, u, v);
+ mpi_mod_barrett (w, w, ctx);
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-mpow.c b/grub-core/lib/libgcrypt/mpi/mpi-mpow.c
new file mode 100644
index 0000000..ca5b3f1
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-mpow.c
@@ -0,0 +1,223 @@
+/* mpi-mpow.c - MPI functions
+ * Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mpi-internal.h"
+#include "longlong.h"
+#include "g10lib.h"
+
+
+/* Barrett is slower than the classical way. It can be tweaked by
+ * using partial multiplications
+ */
+/*#define USE_BARRETT*/
+
+
+
+#ifdef USE_BARRETT
+static void barrett_mulm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m, gcry_mpi_t y, int k, gcry_mpi_t r1, gcry_mpi_t r2 );
+static gcry_mpi_t init_barrett( gcry_mpi_t m, int *k, gcry_mpi_t *r1, gcry_mpi_t *r2 );
+static int calc_barrett( gcry_mpi_t r, gcry_mpi_t x, gcry_mpi_t m, gcry_mpi_t y, int k, gcry_mpi_t r1, gcry_mpi_t r2 );
+#else
+#define barrett_mulm( w, u, v, m, y, k, r1, r2 ) gcry_mpi_mulm( (w), (u), (v), (m) )
+#endif
+
+
+static int
+build_index( gcry_mpi_t *exparray, int k, int i, int t )
+{
+ int j, bitno;
+ int idx = 0;
+
+ bitno = t-i;
+ for(j=k-1; j >= 0; j-- ) {
+ idx <<= 1;
+ if( mpi_test_bit( exparray[j], bitno ) )
+ idx |= 1;
+ }
+ /*log_debug("t=%d i=%d idx=%d\n", t, i, idx );*/
+ return idx;
+}
+
+/****************
+ * RES = (BASE[0] ^ EXP[0]) * (BASE[1] ^ EXP[1]) * ... * mod M
+ */
+void
+_gcry_mpi_mulpowm( gcry_mpi_t res, gcry_mpi_t *basearray, gcry_mpi_t *exparray, gcry_mpi_t m)
+{
+ int k; /* number of elements */
+ int t; /* bit size of largest exponent */
+ int i, j, idx;
+ gcry_mpi_t *G; /* table with precomputed values of size 2^k */
+ gcry_mpi_t tmp;
+#ifdef USE_BARRETT
+ gcry_mpi_t barrett_y, barrett_r1, barrett_r2;
+ int barrett_k;
+#endif
+
+ for(k=0; basearray[k]; k++ )
+ ;
+ gcry_assert(k);
+ for(t=0, i=0; (tmp=exparray[i]); i++ ) {
+ /*log_mpidump("exp: ", tmp );*/
+ j = mpi_get_nbits(tmp);
+ if( j > t )
+ t = j;
+ }
+ /*log_mpidump("mod: ", m );*/
+ gcry_assert (i==k);
+ gcry_assert (t);
+ gcry_assert (k < 10);
+
+ G = gcry_xcalloc( (1<<k) , sizeof *G );
+#ifdef USE_BARRETT
+ barrett_y = init_barrett( m, &barrett_k, &barrett_r1, &barrett_r2 );
+#endif
+ /* and calculate */
+ tmp = mpi_alloc( mpi_get_nlimbs(m)+1 );
+ mpi_set_ui( res, 1 );
+ for(i = 1; i <= t; i++ ) {
+ barrett_mulm(tmp, res, res, m, barrett_y, barrett_k,
+ barrett_r1, barrett_r2 );
+ idx = build_index( exparray, k, i, t );
+ gcry_assert (idx >= 0 && idx < (1<<k));
+ if( !G[idx] ) {
+ if( !idx )
+ G[0] = mpi_alloc_set_ui( 1 );
+ else {
+ for(j=0; j < k; j++ ) {
+ if( (idx & (1<<j) ) ) {
+ if( !G[idx] )
+ G[idx] = mpi_copy( basearray[j] );
+ else
+ barrett_mulm( G[idx], G[idx], basearray[j],
+ m, barrett_y, barrett_k, barrett_r1, barrett_r2 );
+ }
+ }
+ if( !G[idx] )
+ G[idx] = mpi_alloc(0);
+ }
+ }
+ barrett_mulm(res, tmp, G[idx], m, barrett_y, barrett_k, barrett_r1, barrett_r2 );
+ }
+
+ /* cleanup */
+ mpi_free(tmp);
+#ifdef USE_BARRETT
+ mpi_free(barrett_y);
+ mpi_free(barrett_r1);
+ mpi_free(barrett_r2);
+#endif
+ for(i=0; i < (1<<k); i++ )
+ mpi_free(G[i]);
+ gcry_free(G);
+}
+
+
+
+#ifdef USE_BARRETT
+static void
+barrett_mulm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m, gcry_mpi_t y, int k, gcry_mpi_t r1, gcry_mpi_t r2 )
+{
+ mpi_mul(w, u, v);
+ if( calc_barrett( w, w, m, y, k, r1, r2 ) )
+ mpi_fdiv_r( w, w, m );
+}
+
+/****************
+ * Barrett precalculation: y = floor(b^(2k) / m)
+ */
+static gcry_mpi_t
+init_barrett( gcry_mpi_t m, int *k, gcry_mpi_t *r1, gcry_mpi_t *r2 )
+{
+ gcry_mpi_t tmp;
+
+ mpi_normalize( m );
+ *k = mpi_get_nlimbs( m );
+ tmp = mpi_alloc( *k + 1 );
+ mpi_set_ui( tmp, 1 );
+ mpi_lshift_limbs( tmp, 2 * *k );
+ mpi_fdiv_q( tmp, tmp, m );
+ *r1 = mpi_alloc( 2* *k + 1 );
+ *r2 = mpi_alloc( 2* *k + 1 );
+ return tmp;
+}
+
+/****************
+ * Barrett reduction: We assume that these conditions are met:
+ * Given x =(x_2k-1 ...x_0)_b
+ * m =(m_k-1 ....m_0)_b with m_k-1 != 0
+ * Output r = x mod m
+ * Before using this function init_barret must be used to calucalte y and k.
+ * Returns: false = no error
+ * true = can't perform barret reduction
+ */
+static int
+calc_barrett( gcry_mpi_t r, gcry_mpi_t x, gcry_mpi_t m, gcry_mpi_t y, int k, gcry_mpi_t r1, gcry_mpi_t r2 )
+{
+ int xx = k > 3 ? k-3:0;
+
+ mpi_normalize( x );
+ if( mpi_get_nlimbs(x) > 2*k )
+ return 1; /* can't do it */
+
+ /* 1. q1 = floor( x / b^k-1)
+ * q2 = q1 * y
+ * q3 = floor( q2 / b^k+1 )
+ * Actually, we don't need qx, we can work direct on r2
+ */
+ mpi_set( r2, x );
+ mpi_rshift_limbs( r2, k-1 );
+ mpi_mul( r2, r2, y );
+ mpi_rshift_limbs( r2, k+1 );
+
+ /* 2. r1 = x mod b^k+1
+ * r2 = q3 * m mod b^k+1
+ * r = r1 - r2
+ * 3. if r < 0 then r = r + b^k+1
+ */
+ mpi_set( r1, x );
+ if( r1->nlimbs > k+1 ) /* quick modulo operation */
+ r1->nlimbs = k+1;
+ mpi_mul( r2, r2, m );
+ if( r2->nlimbs > k+1 ) /* quick modulo operation */
+ r2->nlimbs = k+1;
+ mpi_sub( r, r1, r2 );
+
+ if( mpi_is_neg( r ) ) {
+ gcry_mpi_t tmp;
+
+ tmp = mpi_alloc( k + 2 );
+ mpi_set_ui( tmp, 1 );
+ mpi_lshift_limbs( tmp, k+1 );
+ mpi_add( r, r, tmp );
+ mpi_free(tmp);
+ }
+
+ /* 4. while r >= m do r = r - m */
+ while( mpi_cmp( r, m ) >= 0 )
+ mpi_sub( r, r, m );
+
+ return 0;
+}
+#endif /* USE_BARRETT */
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-mul.c b/grub-core/lib/libgcrypt/mpi/mpi-mul.c
new file mode 100644
index 0000000..9aefd21
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-mul.c
@@ -0,0 +1,212 @@
+/* mpi-mul.c - MPI functions
+ * Copyright (C) 1994, 1996, 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+
+
+void
+gcry_mpi_mul_ui( gcry_mpi_t prod, gcry_mpi_t mult, unsigned long small_mult )
+{
+ mpi_size_t size, prod_size;
+ mpi_ptr_t prod_ptr;
+ mpi_limb_t cy;
+ int sign;
+
+ size = mult->nlimbs;
+ sign = mult->sign;
+
+ if( !size || !small_mult ) {
+ prod->nlimbs = 0;
+ prod->sign = 0;
+ return;
+ }
+
+ prod_size = size + 1;
+ if( prod->alloced < prod_size )
+ mpi_resize( prod, prod_size );
+ prod_ptr = prod->d;
+
+ cy = _gcry_mpih_mul_1( prod_ptr, mult->d, size, (mpi_limb_t)small_mult );
+ if( cy )
+ prod_ptr[size++] = cy;
+ prod->nlimbs = size;
+ prod->sign = sign;
+}
+
+
+void
+gcry_mpi_mul_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt)
+{
+ mpi_size_t usize, wsize, limb_cnt;
+ mpi_ptr_t wp;
+ mpi_limb_t wlimb;
+ int usign, wsign;
+
+ usize = u->nlimbs;
+ usign = u->sign;
+
+ if( !usize ) {
+ w->nlimbs = 0;
+ w->sign = 0;
+ return;
+ }
+
+ limb_cnt = cnt / BITS_PER_MPI_LIMB;
+ wsize = usize + limb_cnt + 1;
+ if( w->alloced < wsize )
+ mpi_resize(w, wsize );
+ wp = w->d;
+ wsize = usize + limb_cnt;
+ wsign = usign;
+
+ cnt %= BITS_PER_MPI_LIMB;
+ if( cnt ) {
+ wlimb = _gcry_mpih_lshift( wp + limb_cnt, u->d, usize, cnt );
+ if( wlimb ) {
+ wp[wsize] = wlimb;
+ wsize++;
+ }
+ }
+ else {
+ MPN_COPY_DECR( wp + limb_cnt, u->d, usize );
+ }
+
+ /* Zero all whole limbs at low end. Do it here and not before calling
+ * mpn_lshift, not to lose for U == W. */
+ MPN_ZERO( wp, limb_cnt );
+
+ w->nlimbs = wsize;
+ w->sign = wsign;
+}
+
+
+void
+gcry_mpi_mul( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ mpi_size_t usize, vsize, wsize;
+ mpi_ptr_t up, vp, wp;
+ mpi_limb_t cy;
+ int usign, vsign, usecure, vsecure, sign_product;
+ int assign_wp=0;
+ mpi_ptr_t tmp_limb=NULL;
+ unsigned int tmp_limb_nlimbs = 0;
+
+ if( u->nlimbs < v->nlimbs ) { /* Swap U and V. */
+ usize = v->nlimbs;
+ usign = v->sign;
+ usecure = mpi_is_secure(v);
+ up = v->d;
+ vsize = u->nlimbs;
+ vsign = u->sign;
+ vsecure = mpi_is_secure(u);
+ vp = u->d;
+ }
+ else {
+ usize = u->nlimbs;
+ usign = u->sign;
+ usecure = mpi_is_secure(u);
+ up = u->d;
+ vsize = v->nlimbs;
+ vsign = v->sign;
+ vsecure = mpi_is_secure(v);
+ vp = v->d;
+ }
+ sign_product = usign ^ vsign;
+ wp = w->d;
+
+ /* Ensure W has space enough to store the result. */
+ wsize = usize + vsize;
+ if ( !mpi_is_secure (w) && (mpi_is_secure (u) || mpi_is_secure (v)) ) {
+ /* w is not allocated in secure space but u or v is. To make sure
+ * that no temporray results are stored in w, we temporary use
+ * a newly allocated limb space for w */
+ wp = mpi_alloc_limb_space( wsize, 1 );
+ assign_wp = 2; /* mark it as 2 so that we can later copy it back to
+ * mormal memory */
+ }
+ else if( w->alloced < wsize ) {
+ if( wp == up || wp == vp ) {
+ wp = mpi_alloc_limb_space( wsize, mpi_is_secure(w) );
+ assign_wp = 1;
+ }
+ else {
+ mpi_resize(w, wsize );
+ wp = w->d;
+ }
+ }
+ else { /* Make U and V not overlap with W. */
+ if( wp == up ) {
+ /* W and U are identical. Allocate temporary space for U. */
+ tmp_limb_nlimbs = usize;
+ up = tmp_limb = mpi_alloc_limb_space( usize, usecure );
+ /* Is V identical too? Keep it identical with U. */
+ if( wp == vp )
+ vp = up;
+ /* Copy to the temporary space. */
+ MPN_COPY( up, wp, usize );
+ }
+ else if( wp == vp ) {
+ /* W and V are identical. Allocate temporary space for V. */
+ tmp_limb_nlimbs = vsize;
+ vp = tmp_limb = mpi_alloc_limb_space( vsize, vsecure );
+ /* Copy to the temporary space. */
+ MPN_COPY( vp, wp, vsize );
+ }
+ }
+
+ if( !vsize )
+ wsize = 0;
+ else {
+ cy = _gcry_mpih_mul( wp, up, usize, vp, vsize );
+ wsize -= cy? 0:1;
+ }
+
+ if( assign_wp ) {
+ if (assign_wp == 2) {
+ /* copy the temp wp from secure memory back to normal memory */
+ mpi_ptr_t tmp_wp = mpi_alloc_limb_space (wsize, 0);
+ MPN_COPY (tmp_wp, wp, wsize);
+ _gcry_mpi_free_limb_space (wp, 0);
+ wp = tmp_wp;
+ }
+ _gcry_mpi_assign_limb_space( w, wp, wsize );
+ }
+ w->nlimbs = wsize;
+ w->sign = sign_product;
+ if( tmp_limb )
+ _gcry_mpi_free_limb_space (tmp_limb, tmp_limb_nlimbs);
+}
+
+
+void
+gcry_mpi_mulm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ gcry_mpi_mul(w, u, v);
+ _gcry_mpi_fdiv_r( w, w, m );
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-pow.c b/grub-core/lib/libgcrypt/mpi/mpi-pow.c
new file mode 100644
index 0000000..58643fe
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-pow.c
@@ -0,0 +1,338 @@
+/* mpi-pow.c - MPI functions for exponentiation
+ * Copyright (C) 1994, 1996, 1998, 2000, 2002
+ * 2003 Free Software Foundation, Inc.
+ * 2013 g10 Code GmbH
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "mpi-internal.h"
+#include "longlong.h"
+
+
+/****************
+ * RES = BASE ^ EXPO mod MOD
+ */
+void
+gcry_mpi_powm (gcry_mpi_t res,
+ gcry_mpi_t base, gcry_mpi_t expo, gcry_mpi_t mod)
+{
+ /* Pointer to the limbs of the arguments, their size and signs. */
+ mpi_ptr_t rp, ep, mp, bp;
+ mpi_size_t esize, msize, bsize, rsize;
+ int msign, bsign, rsign;
+ /* Flags telling the secure allocation status of the arguments. */
+ int esec, msec, bsec;
+ /* Size of the result including space for temporary values. */
+ mpi_size_t size;
+ /* Helper. */
+ int mod_shift_cnt;
+ int negative_result;
+ mpi_ptr_t mp_marker = NULL;
+ mpi_ptr_t bp_marker = NULL;
+ mpi_ptr_t ep_marker = NULL;
+ mpi_ptr_t xp_marker = NULL;
+ unsigned int mp_nlimbs = 0;
+ unsigned int bp_nlimbs = 0;
+ unsigned int ep_nlimbs = 0;
+ unsigned int xp_nlimbs = 0;
+ mpi_ptr_t tspace = NULL;
+ mpi_size_t tsize = 0;
+
+
+ esize = expo->nlimbs;
+ msize = mod->nlimbs;
+ size = 2 * msize;
+ msign = mod->sign;
+
+ esec = mpi_is_secure(expo);
+ msec = mpi_is_secure(mod);
+ bsec = mpi_is_secure(base);
+
+ rp = res->d;
+ ep = expo->d;
+
+ if (!msize)
+ grub_fatal ("mpi division by zero");
+
+ if (!esize)
+ {
+ /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 depending
+ on if MOD equals 1. */
+ res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1;
+ if (res->nlimbs)
+ {
+ RESIZE_IF_NEEDED (res, 1);
+ rp = res->d;
+ rp[0] = 1;
+ }
+ res->sign = 0;
+ goto leave;
+ }
+
+ /* Normalize MOD (i.e. make its most significant bit set) as
+ required by mpn_divrem. This will make the intermediate values
+ in the calculation slightly larger, but the correct result is
+ obtained after a final reduction using the original MOD value. */
+ mp_nlimbs = msec? msize:0;
+ mp = mp_marker = mpi_alloc_limb_space(msize, msec);
+ count_leading_zeros (mod_shift_cnt, mod->d[msize-1]);
+ if (mod_shift_cnt)
+ _gcry_mpih_lshift (mp, mod->d, msize, mod_shift_cnt);
+ else
+ MPN_COPY( mp, mod->d, msize );
+
+ bsize = base->nlimbs;
+ bsign = base->sign;
+ if (bsize > msize)
+ {
+ /* The base is larger than the module. Reduce it.
+
+ Allocate (BSIZE + 1) with space for remainder and quotient.
+ (The quotient is (bsize - msize + 1) limbs.) */
+ bp_nlimbs = bsec ? (bsize + 1):0;
+ bp = bp_marker = mpi_alloc_limb_space( bsize + 1, bsec );
+ MPN_COPY ( bp, base->d, bsize );
+ /* We don't care about the quotient, store it above the
+ * remainder, at BP + MSIZE. */
+ _gcry_mpih_divrem( bp + msize, 0, bp, bsize, mp, msize );
+ bsize = msize;
+ /* Canonicalize the base, since we are going to multiply with it
+ quite a few times. */
+ MPN_NORMALIZE( bp, bsize );
+ }
+ else
+ bp = base->d;
+
+ if (!bsize)
+ {
+ res->nlimbs = 0;
+ res->sign = 0;
+ goto leave;
+ }
+
+
+ /* Make BASE, EXPO and MOD not overlap with RES. */
+ if ( rp == bp )
+ {
+ /* RES and BASE are identical. Allocate temp. space for BASE. */
+ gcry_assert (!bp_marker);
+ bp_nlimbs = bsec? bsize:0;
+ bp = bp_marker = mpi_alloc_limb_space( bsize, bsec );
+ MPN_COPY(bp, rp, bsize);
+ }
+ if ( rp == ep )
+ {
+ /* RES and EXPO are identical. Allocate temp. space for EXPO. */
+ ep_nlimbs = esec? esize:0;
+ ep = ep_marker = mpi_alloc_limb_space( esize, esec );
+ MPN_COPY(ep, rp, esize);
+ }
+ if ( rp == mp )
+ {
+ /* RES and MOD are identical. Allocate temporary space for MOD.*/
+ gcry_assert (!mp_marker);
+ mp_nlimbs = msec?msize:0;
+ mp = mp_marker = mpi_alloc_limb_space( msize, msec );
+ MPN_COPY(mp, rp, msize);
+ }
+
+ /* Copy base to the result. */
+ if (res->alloced < size)
+ {
+ mpi_resize (res, size);
+ rp = res->d;
+ }
+ MPN_COPY ( rp, bp, bsize );
+ rsize = bsize;
+ rsign = bsign;
+
+ /* Main processing. */
+ {
+ mpi_size_t i;
+ mpi_ptr_t xp;
+ int c;
+ mpi_limb_t e;
+ mpi_limb_t carry_limb;
+ struct karatsuba_ctx karactx;
+
+ xp_nlimbs = msec? (2 * (msize + 1)):0;
+ xp = xp_marker = mpi_alloc_limb_space( 2 * (msize + 1), msec );
+
+ memset( &karactx, 0, sizeof karactx );
+ negative_result = (ep[0] & 1) && base->sign;
+
+ i = esize - 1;
+ e = ep[i];
+ count_leading_zeros (c, e);
+ e = (e << c) << 1; /* Shift the expo bits to the left, lose msb. */
+ c = BITS_PER_MPI_LIMB - 1 - c;
+
+ /* Main loop.
+
+ Make the result be pointed to alternately by XP and RP. This
+ helps us avoid block copying, which would otherwise be
+ necessary with the overlap restrictions of
+ _gcry_mpih_divmod. With 50% probability the result after this
+ loop will be in the area originally pointed by RP (==RES->d),
+ and with 50% probability in the area originally pointed to by XP. */
+ for (;;)
+ {
+ while (c)
+ {
+ mpi_ptr_t tp;
+ mpi_size_t xsize;
+
+ /*mpih_mul_n(xp, rp, rp, rsize);*/
+ if ( rsize < KARATSUBA_THRESHOLD )
+ _gcry_mpih_sqr_n_basecase( xp, rp, rsize );
+ else
+ {
+ if ( !tspace )
+ {
+ tsize = 2 * rsize;
+ tspace = mpi_alloc_limb_space( tsize, 0 );
+ }
+ else if ( tsize < (2*rsize) )
+ {
+ _gcry_mpi_free_limb_space (tspace, 0);
+ tsize = 2 * rsize;
+ tspace = mpi_alloc_limb_space (tsize, 0 );
+ }
+ _gcry_mpih_sqr_n (xp, rp, rsize, tspace);
+ }
+
+ xsize = 2 * rsize;
+ if ( xsize > msize )
+ {
+ _gcry_mpih_divrem(xp + msize, 0, xp, xsize, mp, msize);
+ xsize = msize;
+ }
+
+ tp = rp; rp = xp; xp = tp;
+ rsize = xsize;
+
+ /* To mitigate the Yarom/Falkner flush+reload cache
+ * side-channel attack on the RSA secret exponent, we do
+ * the multiplication regardless of the value of the
+ * high-bit of E. But to avoid this performance penalty
+ * we do it only if the exponent has been stored in secure
+ * memory and we can thus assume it is a secret exponent. */
+ if (esec || (mpi_limb_signed_t)e < 0)
+ {
+ /*mpih_mul( xp, rp, rsize, bp, bsize );*/
+ if( bsize < KARATSUBA_THRESHOLD )
+ _gcry_mpih_mul ( xp, rp, rsize, bp, bsize );
+ else
+ _gcry_mpih_mul_karatsuba_case (xp, rp, rsize, bp, bsize,
+ &karactx);
+
+ xsize = rsize + bsize;
+ if ( xsize > msize )
+ {
+ _gcry_mpih_divrem(xp + msize, 0, xp, xsize, mp, msize);
+ xsize = msize;
+ }
+ }
+ if ( (mpi_limb_signed_t)e < 0 )
+ {
+ tp = rp; rp = xp; xp = tp;
+ rsize = xsize;
+ }
+ e <<= 1;
+ c--;
+ }
+
+ i--;
+ if ( i < 0 )
+ break;
+ e = ep[i];
+ c = BITS_PER_MPI_LIMB;
+ }
+
+ /* We shifted MOD, the modulo reduction argument, left
+ MOD_SHIFT_CNT steps. Adjust the result by reducing it with the
+ original MOD.
+
+ Also make sure the result is put in RES->d (where it already
+ might be, see above). */
+ if ( mod_shift_cnt )
+ {
+ carry_limb = _gcry_mpih_lshift( res->d, rp, rsize, mod_shift_cnt);
+ rp = res->d;
+ if ( carry_limb )
+ {
+ rp[rsize] = carry_limb;
+ rsize++;
+ }
+ }
+ else if (res->d != rp)
+ {
+ MPN_COPY (res->d, rp, rsize);
+ rp = res->d;
+ }
+
+ if ( rsize >= msize )
+ {
+ _gcry_mpih_divrem(rp + msize, 0, rp, rsize, mp, msize);
+ rsize = msize;
+ }
+
+ /* Remove any leading zero words from the result. */
+ if ( mod_shift_cnt )
+ _gcry_mpih_rshift( rp, rp, rsize, mod_shift_cnt);
+ MPN_NORMALIZE (rp, rsize);
+
+ _gcry_mpih_release_karatsuba_ctx (&karactx );
+ }
+
+ /* Fixup for negative results. */
+ if ( negative_result && rsize )
+ {
+ if ( mod_shift_cnt )
+ _gcry_mpih_rshift( mp, mp, msize, mod_shift_cnt);
+ _gcry_mpih_sub( rp, mp, msize, rp, rsize);
+ rsize = msize;
+ rsign = msign;
+ MPN_NORMALIZE(rp, rsize);
+ }
+ gcry_assert (res->d == rp);
+ res->nlimbs = rsize;
+ res->sign = rsign;
+
+ leave:
+ if (mp_marker)
+ _gcry_mpi_free_limb_space( mp_marker, mp_nlimbs );
+ if (bp_marker)
+ _gcry_mpi_free_limb_space( bp_marker, bp_nlimbs );
+ if (ep_marker)
+ _gcry_mpi_free_limb_space( ep_marker, ep_nlimbs );
+ if (xp_marker)
+ _gcry_mpi_free_limb_space( xp_marker, xp_nlimbs );
+ if (tspace)
+ _gcry_mpi_free_limb_space( tspace, 0 );
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpi-scan.c b/grub-core/lib/libgcrypt/mpi/mpi-scan.c
new file mode 100644
index 0000000..2473cd9
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpi-scan.c
@@ -0,0 +1,130 @@
+/* mpi-scan.c - MPI functions
+ * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+/****************
+ * Scan through an mpi and return byte for byte. a -1 is returned to indicate
+ * the end of the mpi. Scanning is done from the lsb to the msb, returned
+ * values are in the range of 0 .. 255.
+ *
+ * FIXME: This code is VERY ugly!
+ */
+int
+_gcry_mpi_getbyte( gcry_mpi_t a, unsigned idx )
+{
+ int i, j;
+ unsigned n;
+ mpi_ptr_t ap;
+ mpi_limb_t limb;
+
+ ap = a->d;
+ for(n=0,i=0; i < a->nlimbs; i++ ) {
+ limb = ap[i];
+ for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ )
+ if( n == idx )
+ return (limb >> j*8) & 0xff;
+ }
+ return -1;
+}
+
+
+/****************
+ * Put a value at position IDX into A. idx counts from lsb to msb
+ */
+void
+_gcry_mpi_putbyte( gcry_mpi_t a, unsigned idx, int xc )
+{
+ int i, j;
+ unsigned n;
+ mpi_ptr_t ap;
+ mpi_limb_t limb, c;
+
+ c = xc & 0xff;
+ ap = a->d;
+ for(n=0,i=0; i < a->alloced; i++ ) {
+ limb = ap[i];
+ for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ )
+ if( n == idx ) {
+ #if BYTES_PER_MPI_LIMB == 4
+ if( j == 0 )
+ limb = (limb & 0xffffff00) | c;
+ else if( j == 1 )
+ limb = (limb & 0xffff00ff) | (c<<8);
+ else if( j == 2 )
+ limb = (limb & 0xff00ffff) | (c<<16);
+ else
+ limb = (limb & 0x00ffffff) | (c<<24);
+ #elif BYTES_PER_MPI_LIMB == 8
+ if( j == 0 )
+ limb = (limb & 0xffffffffffffff00) | c;
+ else if( j == 1 )
+ limb = (limb & 0xffffffffffff00ff) | (c<<8);
+ else if( j == 2 )
+ limb = (limb & 0xffffffffff00ffff) | (c<<16);
+ else if( j == 3 )
+ limb = (limb & 0xffffffff00ffffff) | (c<<24);
+ else if( j == 4 )
+ limb = (limb & 0xffffff00ffffffff) | (c<<32);
+ else if( j == 5 )
+ limb = (limb & 0xffff00ffffffffff) | (c<<40);
+ else if( j == 6 )
+ limb = (limb & 0xff00ffffffffffff) | (c<<48);
+ else
+ limb = (limb & 0x00ffffffffffffff) | (c<<56);
+ #else
+ #error please enhance this function, its ugly - i know.
+ #endif
+ if( a->nlimbs <= i )
+ a->nlimbs = i+1;
+ ap[i] = limb;
+ return;
+ }
+ }
+ abort(); /* index out of range */
+}
+
+
+/****************
+ * Count the number of zerobits at the low end of A
+ */
+unsigned
+_gcry_mpi_trailing_zeros( gcry_mpi_t a )
+{
+ unsigned n, count = 0;
+
+ for(n=0; n < a->nlimbs; n++ ) {
+ if( a->d[n] ) {
+ unsigned nn;
+ mpi_limb_t alimb = a->d[n];
+
+ count_trailing_zeros( nn, alimb );
+ count += nn;
+ break;
+ }
+ count += BITS_PER_MPI_LIMB;
+ }
+ return count;
+
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpicoder.c b/grub-core/lib/libgcrypt/mpi/mpicoder.c
new file mode 100644
index 0000000..6fe3891
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpicoder.c
@@ -0,0 +1,753 @@
+/* mpicoder.c - Coder for the external representation of MPIs
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+ * 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "mpi-internal.h"
+#include "g10lib.h"
+
+#define MAX_EXTERN_MPI_BITS 16384
+
+/* Helper used to scan PGP style MPIs. Returns NULL on failure. */
+static gcry_mpi_t
+mpi_read_from_buffer (const unsigned char *buffer, unsigned *ret_nread,
+ int secure)
+{
+ int i, j;
+ unsigned int nbits, nbytes, nlimbs, nread=0;
+ mpi_limb_t a;
+ gcry_mpi_t val = MPI_NULL;
+
+ if ( *ret_nread < 2 )
+ goto leave;
+ nbits = buffer[0] << 8 | buffer[1];
+ if ( nbits > MAX_EXTERN_MPI_BITS )
+ {
+/* log_debug ("mpi too large (%u bits)\n", nbits); */
+ goto leave;
+ }
+ buffer += 2;
+ nread = 2;
+
+ nbytes = (nbits+7) / 8;
+ nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
+ val = secure? mpi_alloc_secure (nlimbs) : mpi_alloc (nlimbs);
+ i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
+ i %= BYTES_PER_MPI_LIMB;
+ j= val->nlimbs = nlimbs;
+ val->sign = 0;
+ for ( ; j > 0; j-- )
+ {
+ a = 0;
+ for (; i < BYTES_PER_MPI_LIMB; i++ )
+ {
+ if ( ++nread > *ret_nread )
+ {
+/* log_debug ("mpi larger than buffer"); */
+ mpi_free (val);
+ val = NULL;
+ goto leave;
+ }
+ a <<= 8;
+ a |= *buffer++;
+ }
+ i = 0;
+ val->d[j-1] = a;
+ }
+
+ leave:
+ *ret_nread = nread;
+ return val;
+}
+
+
+/****************
+ * Fill the mpi VAL from the hex string in STR.
+ */
+static int
+mpi_fromstr (gcry_mpi_t val, const char *str)
+{
+ int sign = 0;
+ int prepend_zero = 0;
+ int i, j, c, c1, c2;
+ unsigned int nbits, nbytes, nlimbs;
+ mpi_limb_t a;
+
+ if ( *str == '-' )
+ {
+ sign = 1;
+ str++;
+ }
+
+ /* Skip optional hex prefix. */
+ if ( *str == '0' && str[1] == 'x' )
+ str += 2;
+
+ nbits = 4 * strlen (str);
+ if ((nbits % 8))
+ prepend_zero = 1;
+
+ nbytes = (nbits+7) / 8;
+ nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
+
+ if ( val->alloced < nlimbs )
+ mpi_resize (val, nlimbs);
+
+ i = BYTES_PER_MPI_LIMB - (nbytes % BYTES_PER_MPI_LIMB);
+ i %= BYTES_PER_MPI_LIMB;
+ j = val->nlimbs = nlimbs;
+ val->sign = sign;
+ for (; j > 0; j--)
+ {
+ a = 0;
+ for (; i < BYTES_PER_MPI_LIMB; i++)
+ {
+ if (prepend_zero)
+ {
+ c1 = '0';
+ prepend_zero = 0;
+ }
+ else
+ c1 = *str++;
+
+ if (!c1)
+ {
+ mpi_clear (val);
+ return 1; /* Error. */
+ }
+ c2 = *str++;
+ if (!c2)
+ {
+ mpi_clear (val);
+ return 1; /* Error. */
+ }
+ if ( c1 >= '0' && c1 <= '9' )
+ c = c1 - '0';
+ else if ( c1 >= 'a' && c1 <= 'f' )
+ c = c1 - 'a' + 10;
+ else if ( c1 >= 'A' && c1 <= 'F' )
+ c = c1 - 'A' + 10;
+ else
+ {
+ mpi_clear (val);
+ return 1; /* Error. */
+ }
+ c <<= 4;
+ if ( c2 >= '0' && c2 <= '9' )
+ c |= c2 - '0';
+ else if( c2 >= 'a' && c2 <= 'f' )
+ c |= c2 - 'a' + 10;
+ else if( c2 >= 'A' && c2 <= 'F' )
+ c |= c2 - 'A' + 10;
+ else
+ {
+ mpi_clear(val);
+ return 1; /* Error. */
+ }
+ a <<= 8;
+ a |= c;
+ }
+ i = 0;
+ val->d[j-1] = a;
+ }
+
+ return 0; /* Okay. */
+}
+
+
+/* Dump the value of A in a format suitable for debugging to
+ Libgcrypt's logging stream. Note that one leading space but no
+ trailing space or linefeed will be printed. It is okay to pass
+ NULL for A. */
+void
+gcry_mpi_dump (const gcry_mpi_t a)
+{
+ int i;
+
+ log_printf (" ");
+ if (!a)
+ log_printf ("[MPI_NULL]");
+ else
+ {
+ if (a->sign)
+ log_printf ( "-");
+#if BYTES_PER_MPI_LIMB == 2
+# define X "4"
+#elif BYTES_PER_MPI_LIMB == 4
+# define X "8"
+#elif BYTES_PER_MPI_LIMB == 8
+# define X "16"
+#elif BYTES_PER_MPI_LIMB == 16
+# define X "32"
+#else
+# error please define the format here
+#endif
+ for (i=a->nlimbs; i > 0 ; i-- )
+ {
+ log_printf (i != a->nlimbs? "%0" X "lX":"%lX", (ulong)a->d[i-1]);
+ }
+#undef X
+ if (!a->nlimbs)
+ log_printf ("0");
+ }
+}
+
+/* Convience function used internally. */
+void
+_gcry_log_mpidump (const char *text, gcry_mpi_t a)
+{
+ log_printf ("%s:", text);
+ gcry_mpi_dump (a);
+ log_printf ("\n");
+}
+
+
+/* Return an allocated buffer with the MPI (msb first). NBYTES
+ receives the length of this buffer. Caller must free the return
+ string. This function returns an allocated buffer with NBYTES set
+ to zero if the value of A is zero. If sign is not NULL, it will be
+ set to the sign of the A. On error NULL is returned and ERRNO set
+ appropriately. */
+static unsigned char *
+do_get_buffer (gcry_mpi_t a, unsigned int *nbytes, int *sign, int force_secure)
+{
+ unsigned char *p, *buffer;
+ mpi_limb_t alimb;
+ int i;
+ size_t n;
+
+ if (sign)
+ *sign = a->sign;
+
+ *nbytes = a->nlimbs * BYTES_PER_MPI_LIMB;
+ n = *nbytes? *nbytes:1; /* Allocate at least one byte. */
+ p = buffer = (force_secure || mpi_is_secure(a))? gcry_malloc_secure (n)
+ : gcry_malloc (n);
+ if (!buffer)
+ return NULL;
+
+ for (i=a->nlimbs-1; i >= 0; i--)
+ {
+ alimb = a->d[i];
+#if BYTES_PER_MPI_LIMB == 4
+ *p++ = alimb >> 24;
+ *p++ = alimb >> 16;
+ *p++ = alimb >> 8;
+ *p++ = alimb ;
+#elif BYTES_PER_MPI_LIMB == 8
+ *p++ = alimb >> 56;
+ *p++ = alimb >> 48;
+ *p++ = alimb >> 40;
+ *p++ = alimb >> 32;
+ *p++ = alimb >> 24;
+ *p++ = alimb >> 16;
+ *p++ = alimb >> 8;
+ *p++ = alimb ;
+#else
+# error please implement for this limb size.
+#endif
+ }
+
+ /* This is sub-optimal but we need to do the shift operation because
+ the caller has to free the returned buffer. */
+ for (p=buffer; *nbytes && !*p; p++, --*nbytes)
+ ;
+ if (p != buffer)
+ memmove (buffer,p, *nbytes);
+ return buffer;
+}
+
+
+byte *
+_gcry_mpi_get_buffer (gcry_mpi_t a, unsigned int *nbytes, int *sign)
+{
+ return do_get_buffer (a, nbytes, sign, 0);
+}
+
+byte *
+_gcry_mpi_get_secure_buffer (gcry_mpi_t a, unsigned *nbytes, int *sign)
+{
+ return do_get_buffer (a, nbytes, sign, 1);
+}
+
+
+/*
+ * Use the NBYTES at BUFFER_ARG to update A. Set the sign of a to
+ * SIGN.
+ */
+void
+_gcry_mpi_set_buffer (gcry_mpi_t a, const void *buffer_arg,
+ unsigned int nbytes, int sign)
+{
+ const unsigned char *buffer = (const unsigned char*)buffer_arg;
+ const unsigned char *p;
+ mpi_limb_t alimb;
+ int nlimbs;
+ int i;
+
+ nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
+ RESIZE_IF_NEEDED(a, nlimbs);
+ a->sign = sign;
+
+ for (i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; )
+ {
+#if BYTES_PER_MPI_LIMB == 4
+ alimb = *p-- ;
+ alimb |= *p-- << 8 ;
+ alimb |= *p-- << 16 ;
+ alimb |= *p-- << 24 ;
+#elif BYTES_PER_MPI_LIMB == 8
+ alimb = (mpi_limb_t)*p-- ;
+ alimb |= (mpi_limb_t)*p-- << 8 ;
+ alimb |= (mpi_limb_t)*p-- << 16 ;
+ alimb |= (mpi_limb_t)*p-- << 24 ;
+ alimb |= (mpi_limb_t)*p-- << 32 ;
+ alimb |= (mpi_limb_t)*p-- << 40 ;
+ alimb |= (mpi_limb_t)*p-- << 48 ;
+ alimb |= (mpi_limb_t)*p-- << 56 ;
+#else
+# error please implement for this limb size.
+#endif
+ a->d[i++] = alimb;
+ }
+ if ( p >= buffer )
+ {
+#if BYTES_PER_MPI_LIMB == 4
+ alimb = *p--;
+ if (p >= buffer)
+ alimb |= *p-- << 8;
+ if (p >= buffer)
+ alimb |= *p-- << 16;
+ if (p >= buffer)
+ alimb |= *p-- << 24;
+#elif BYTES_PER_MPI_LIMB == 8
+ alimb = (mpi_limb_t)*p--;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 8;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 16;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 24;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 32;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 40;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 48;
+ if (p >= buffer)
+ alimb |= (mpi_limb_t)*p-- << 56;
+#else
+# error please implement for this limb size.
+#endif
+ a->d[i++] = alimb;
+ }
+ a->nlimbs = i;
+ gcry_assert (i == nlimbs);
+}
+
+
+/* Convert the external representation of an integer stored in BUFFER
+ with a length of BUFLEN into a newly create MPI returned in
+ RET_MPI. If NBYTES is not NULL, it will receive the number of
+ bytes actually scanned after a successful operation. */
+gcry_error_t
+gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
+ const void *buffer_arg, size_t buflen, size_t *nscanned)
+{
+ const unsigned char *buffer = (const unsigned char*)buffer_arg;
+ struct gcry_mpi *a = NULL;
+ unsigned int len;
+ int secure = (buffer && gcry_is_secure (buffer));
+
+ if (!buffer)
+ return gcry_error (GPG_ERR_INV_ARG);
+
+ if (format == GCRYMPI_FMT_SSH)
+ len = 0;
+ else
+ len = buflen;
+
+ if (format == GCRYMPI_FMT_STD)
+ {
+ const unsigned char *s = buffer;
+
+ a = secure? mpi_alloc_secure ((len+BYTES_PER_MPI_LIMB-1)
+ /BYTES_PER_MPI_LIMB)
+ : mpi_alloc ((len+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
+ if (len)
+ {
+ a->sign = !!(*s & 0x80);
+ if (a->sign)
+ {
+ /* FIXME: we have to convert from 2compl to magnitude format */
+ mpi_free (a);
+ return gcry_error (GPG_ERR_INTERNAL);
+ }
+ else
+ _gcry_mpi_set_buffer (a, s, len, 0);
+ }
+ if (ret_mpi)
+ {
+ mpi_normalize ( a );
+ *ret_mpi = a;
+ }
+ else
+ mpi_free(a);
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_USG)
+ {
+ a = secure? mpi_alloc_secure ((len+BYTES_PER_MPI_LIMB-1)
+ /BYTES_PER_MPI_LIMB)
+ : mpi_alloc ((len+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
+
+ if (len)
+ _gcry_mpi_set_buffer (a, buffer, len, 0);
+ if (ret_mpi)
+ {
+ mpi_normalize ( a );
+ *ret_mpi = a;
+ }
+ else
+ mpi_free(a);
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_PGP)
+ {
+ a = mpi_read_from_buffer (buffer, &len, secure);
+ if (nscanned)
+ *nscanned = len;
+ if (ret_mpi && a)
+ {
+ mpi_normalize (a);
+ *ret_mpi = a;
+ }
+ else if (a)
+ {
+ mpi_free(a);
+ a = NULL;
+ }
+ return a? 0 : gcry_error (GPG_ERR_INV_OBJ);
+ }
+ else if (format == GCRYMPI_FMT_SSH)
+ {
+ const unsigned char *s = buffer;
+ size_t n;
+
+ /* This test is not strictly necessary and an assert (!len)
+ would be sufficient. We keep this test in case we later
+ allow the BUFLEN argument to act as a sanitiy check. Same
+ below. */
+ if (len && len < 4)
+ return gcry_error (GPG_ERR_TOO_SHORT);
+
+ n = ((size_t)s[0] << 24 | (size_t)s[1] << 16 | (size_t)s[2] << 8 | (size_t)s[3]);
+ s += 4;
+ if (len)
+ len -= 4;
+ if (len && n > len)
+ return gcry_error (GPG_ERR_TOO_LARGE);
+
+ a = secure? mpi_alloc_secure ((n+BYTES_PER_MPI_LIMB-1)
+ /BYTES_PER_MPI_LIMB)
+ : mpi_alloc ((n+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
+ if (n)
+ {
+ a->sign = !!(*s & 0x80);
+ if (a->sign)
+ {
+ /* FIXME: we have to convert from 2compl to magnitude format */
+ mpi_free(a);
+ return gcry_error (GPG_ERR_INTERNAL);
+ }
+ else
+ _gcry_mpi_set_buffer( a, s, n, 0 );
+ }
+ if (nscanned)
+ *nscanned = n+4;
+ if (ret_mpi)
+ {
+ mpi_normalize ( a );
+ *ret_mpi = a;
+ }
+ else
+ mpi_free(a);
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_HEX)
+ {
+ /* We can only handle C strings for now. */
+ if (buflen)
+ return gcry_error (GPG_ERR_INV_ARG);
+
+ a = secure? mpi_alloc_secure (0) : mpi_alloc(0);
+ if (mpi_fromstr (a, (const char *)buffer))
+ {
+ mpi_free (a);
+ return gcry_error (GPG_ERR_INV_OBJ);
+ }
+ if (ret_mpi)
+ {
+ mpi_normalize ( a );
+ *ret_mpi = a;
+ }
+ else
+ mpi_free(a);
+ return 0;
+ }
+ else
+ return gcry_error (GPG_ERR_INV_ARG);
+}
+
+
+/* Convert the big integer A into the external representation
+ described by FORMAT and store it in the provided BUFFER which has
+ been allocated by the user with a size of BUFLEN bytes. NWRITTEN
+ receives the actual length of the external representation unless it
+ has been passed as NULL. BUFFER may be NULL to query the required
+ length. */
+gcry_error_t
+gcry_mpi_print (enum gcry_mpi_format format,
+ unsigned char *buffer, size_t buflen,
+ size_t *nwritten, struct gcry_mpi *a)
+{
+ unsigned int nbits = mpi_get_nbits (a);
+ size_t len;
+ size_t dummy_nwritten;
+
+ if (!nwritten)
+ nwritten = &dummy_nwritten;
+
+ len = buflen;
+ *nwritten = 0;
+ if (format == GCRYMPI_FMT_STD)
+ {
+ unsigned char *tmp;
+ int extra = 0;
+ unsigned int n;
+
+ if (a->sign)
+ return gcry_error (GPG_ERR_INTERNAL); /* Can't handle it yet. */
+
+ tmp = _gcry_mpi_get_buffer (a, &n, NULL);
+ if (!tmp)
+ return gpg_error_from_syserror ();
+ if (n && (*tmp & 0x80))
+ {
+ n++;
+ extra=1;
+ }
+
+ if (buffer && n > len)
+ {
+ /* The provided buffer is too short. */
+ gcry_free (tmp);
+ return gcry_error (GPG_ERR_TOO_SHORT);
+ }
+ if (buffer)
+ {
+ unsigned char *s = buffer;
+
+ if (extra)
+ *s++ = 0;
+ memcpy (s, tmp, n-extra);
+ }
+ gcry_free(tmp);
+ *nwritten = n;
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_USG)
+ {
+ unsigned int n = (nbits + 7)/8;
+
+ /* Note: We ignore the sign for this format. */
+ /* FIXME: for performance reasons we should put this into
+ mpi_aprint because we can then use the buffer directly. */
+ if (buffer && n > len)
+ return gcry_error (GPG_ERR_TOO_SHORT);
+ if (buffer)
+ {
+ unsigned char *tmp;
+
+ tmp = _gcry_mpi_get_buffer (a, &n, NULL);
+ if (!tmp)
+ return gpg_error_from_syserror ();
+ memcpy (buffer, tmp, n);
+ gcry_free (tmp);
+ }
+ *nwritten = n;
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_PGP)
+ {
+ unsigned int n = (nbits + 7)/8;
+
+ /* The PGP format can only handle unsigned integers. */
+ if( a->sign )
+ return gcry_error (GPG_ERR_INV_ARG);
+
+ if (buffer && n+2 > len)
+ return gcry_error (GPG_ERR_TOO_SHORT);
+
+ if (buffer)
+ {
+ unsigned char *tmp;
+ unsigned char *s = buffer;
+
+ s[0] = nbits >> 8;
+ s[1] = nbits;
+
+ tmp = _gcry_mpi_get_buffer (a, &n, NULL);
+ if (!tmp)
+ return gpg_error_from_syserror ();
+ memcpy (s+2, tmp, n);
+ gcry_free (tmp);
+ }
+ *nwritten = n+2;
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_SSH)
+ {
+ unsigned char *tmp;
+ int extra = 0;
+ unsigned int n;
+
+ if (a->sign)
+ return gcry_error (GPG_ERR_INTERNAL); /* Can't handle it yet. */
+
+ tmp = _gcry_mpi_get_buffer (a, &n, NULL);
+ if (!tmp)
+ return gpg_error_from_syserror ();
+ if (n && (*tmp & 0x80))
+ {
+ n++;
+ extra=1;
+ }
+
+ if (buffer && n+4 > len)
+ {
+ gcry_free(tmp);
+ return gcry_error (GPG_ERR_TOO_SHORT);
+ }
+
+ if (buffer)
+ {
+ unsigned char *s = buffer;
+
+ *s++ = n >> 24;
+ *s++ = n >> 16;
+ *s++ = n >> 8;
+ *s++ = n;
+ if (extra)
+ *s++ = 0;
+
+ memcpy (s, tmp, n-extra);
+ }
+ gcry_free (tmp);
+ *nwritten = 4+n;
+ return 0;
+ }
+ else if (format == GCRYMPI_FMT_HEX)
+ {
+ unsigned char *tmp;
+ int i;
+ int extra = 0;
+ unsigned int n = 0;
+
+ tmp = _gcry_mpi_get_buffer (a, &n, NULL);
+ if (!tmp)
+ return gpg_error_from_syserror ();
+ if (!n || (*tmp & 0x80))
+ extra = 2;
+
+ if (buffer && 2*n + extra + !!a->sign + 1 > len)
+ {
+ gcry_free(tmp);
+ return gcry_error (GPG_ERR_TOO_SHORT);
+ }
+ if (buffer)
+ {
+ unsigned char *s = buffer;
+
+ if (a->sign)
+ *s++ = '-';
+ if (extra)
+ {
+ *s++ = '0';
+ *s++ = '0';
+ }
+
+ for (i=0; i < n; i++)
+ {
+ unsigned int c = tmp[i];
+
+ *s++ = (c >> 4) < 10? '0'+(c>>4) : 'A'+(c>>4)-10 ;
+ c &= 15;
+ *s++ = c < 10? '0'+c : 'A'+c-10 ;
+ }
+ *s++ = 0;
+ *nwritten = s - buffer;
+ }
+ else
+ {
+ *nwritten = 2*n + extra + !!a->sign + 1;
+ }
+ gcry_free (tmp);
+ return 0;
+ }
+ else
+ return gcry_error (GPG_ERR_INV_ARG);
+}
+
+
+/*
+ * Like gcry_mpi_print but this function allocates the buffer itself.
+ * The caller has to supply the address of a pointer. NWRITTEN may be
+ * NULL.
+ */
+gcry_error_t
+gcry_mpi_aprint (enum gcry_mpi_format format,
+ unsigned char **buffer, size_t *nwritten,
+ struct gcry_mpi *a)
+{
+ size_t n;
+ gcry_error_t rc;
+
+ *buffer = NULL;
+ rc = gcry_mpi_print (format, NULL, 0, &n, a);
+ if (rc)
+ return rc;
+
+ *buffer = mpi_is_secure(a) ? gcry_malloc_secure (n) : gcry_malloc (n);
+ if (!*buffer)
+ return gpg_error_from_syserror ();
+ rc = gcry_mpi_print( format, *buffer, n, &n, a );
+ if (rc)
+ {
+ gcry_free(*buffer);
+ *buffer = NULL;
+ }
+ else if (nwritten)
+ *nwritten = n;
+ return rc;
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpih-div.c b/grub-core/lib/libgcrypt/mpi/mpih-div.c
new file mode 100644
index 0000000..0b458ff
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpih-div.c
@@ -0,0 +1,534 @@
+/* mpih-div.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 2000,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+
+#ifndef UMUL_TIME
+#define UMUL_TIME 1
+#endif
+#ifndef UDIV_TIME
+#define UDIV_TIME UMUL_TIME
+#endif
+
+/* FIXME: We should be using invert_limb (or invert_normalized_limb)
+ * here (not udiv_qrnnd).
+ */
+
+mpi_limb_t
+_gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+ mpi_limb_t divisor_limb)
+{
+ mpi_size_t i;
+ mpi_limb_t n1, n0, r;
+ int dummy;
+
+ /* Botch: Should this be handled at all? Rely on callers? */
+ if( !dividend_size )
+ return 0;
+
+ /* If multiplication is much faster than division, and the
+ * dividend is large, pre-invert the divisor, and use
+ * only multiplications in the inner loop.
+ *
+ * This test should be read:
+ * Does it ever help to use udiv_qrnnd_preinv?
+ * && Does what we save compensate for the inversion overhead?
+ */
+ if( UDIV_TIME > (2 * UMUL_TIME + 6)
+ && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME ) {
+ int normalization_steps;
+
+ count_leading_zeros( normalization_steps, divisor_limb );
+ if( normalization_steps ) {
+ mpi_limb_t divisor_limb_inverted;
+
+ divisor_limb <<= normalization_steps;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ * most significant bit (with weight 2**N) implicit.
+ *
+ * Special case for DIVISOR_LIMB == 100...000.
+ */
+ if( !(divisor_limb << 1) )
+ divisor_limb_inverted = ~(mpi_limb_t)0;
+ else
+ udiv_qrnnd(divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ * if (r == 0
+ * && divisor_limb > ((n1 << normalization_steps)
+ * | (dividend_ptr[dividend_size - 2] >> ...)))
+ * ...one division less...
+ */
+ for( i = dividend_size - 2; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ UDIV_QRNND_PREINV(dummy, r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+ divisor_limb, divisor_limb_inverted);
+ n1 = n0;
+ }
+ UDIV_QRNND_PREINV(dummy, r, r,
+ n1 << normalization_steps,
+ divisor_limb, divisor_limb_inverted);
+ return r >> normalization_steps;
+ }
+ else {
+ mpi_limb_t divisor_limb_inverted;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ * most significant bit (with weight 2**N) implicit.
+ *
+ * Special case for DIVISOR_LIMB == 100...000.
+ */
+ if( !(divisor_limb << 1) )
+ divisor_limb_inverted = ~(mpi_limb_t)0;
+ else
+ udiv_qrnnd(divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if( r >= divisor_limb )
+ r = 0;
+ else
+ i--;
+
+ for( ; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ UDIV_QRNND_PREINV(dummy, r, r,
+ n0, divisor_limb, divisor_limb_inverted);
+ }
+ return r;
+ }
+ }
+ else {
+ if( UDIV_NEEDS_NORMALIZATION ) {
+ int normalization_steps;
+
+ count_leading_zeros(normalization_steps, divisor_limb);
+ if( normalization_steps ) {
+ divisor_limb <<= normalization_steps;
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ * if (r == 0
+ * && divisor_limb > ((n1 << normalization_steps)
+ * | (dividend_ptr[dividend_size - 2] >> ...)))
+ * ...one division less...
+ */
+ for(i = dividend_size - 2; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd (dummy, r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+ divisor_limb);
+ n1 = n0;
+ }
+ udiv_qrnnd (dummy, r, r,
+ n1 << normalization_steps,
+ divisor_limb);
+ return r >> normalization_steps;
+ }
+ }
+ /* No normalization needed, either because udiv_qrnnd doesn't require
+ * it, or because DIVISOR_LIMB is already normalized. */
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if(r >= divisor_limb)
+ r = 0;
+ else
+ i--;
+
+ for(; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd (dummy, r, r, n0, divisor_limb);
+ }
+ return r;
+ }
+}
+
+/* Divide num (NP/NSIZE) by den (DP/DSIZE) and write
+ * the NSIZE-DSIZE least significant quotient limbs at QP
+ * and the DSIZE long remainder at NP. If QEXTRA_LIMBS is
+ * non-zero, generate that many fraction bits and append them after the
+ * other quotient limbs.
+ * Return the most significant limb of the quotient, this is always 0 or 1.
+ *
+ * Preconditions:
+ * 0. NSIZE >= DSIZE.
+ * 1. The most significant bit of the divisor must be set.
+ * 2. QP must either not overlap with the input operands at all, or
+ * QP + DSIZE >= NP must hold true. (This means that it's
+ * possible to put the quotient in the high part of NUM, right after the
+ * remainder in NUM.
+ * 3. NSIZE >= DSIZE, even if QEXTRA_LIMBS is non-zero.
+ */
+
+mpi_limb_t
+_gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs,
+ mpi_ptr_t np, mpi_size_t nsize,
+ mpi_ptr_t dp, mpi_size_t dsize)
+{
+ mpi_limb_t most_significant_q_limb = 0;
+
+ switch(dsize) {
+ case 0:
+ /* We are asked to divide by zero, so go ahead and do it! (To make
+ the compiler not remove this statement, return the value.) */
+ grub_fatal ("mpi division by zero");
+ return 0;
+
+ case 1:
+ {
+ mpi_size_t i;
+ mpi_limb_t n1;
+ mpi_limb_t d;
+
+ d = dp[0];
+ n1 = np[nsize - 1];
+
+ if( n1 >= d ) {
+ n1 -= d;
+ most_significant_q_limb = 1;
+ }
+
+ qp += qextra_limbs;
+ for( i = nsize - 2; i >= 0; i--)
+ udiv_qrnnd( qp[i], n1, n1, np[i], d );
+ qp -= qextra_limbs;
+
+ for( i = qextra_limbs - 1; i >= 0; i-- )
+ udiv_qrnnd (qp[i], n1, n1, 0, d);
+
+ np[0] = n1;
+ }
+ break;
+
+ case 2:
+ {
+ mpi_size_t i;
+ mpi_limb_t n1, n0, n2;
+ mpi_limb_t d1, d0;
+
+ np += nsize - 2;
+ d1 = dp[1];
+ d0 = dp[0];
+ n1 = np[1];
+ n0 = np[0];
+
+ if( n1 >= d1 && (n1 > d1 || n0 >= d0) ) {
+ sub_ddmmss (n1, n0, n1, n0, d1, d0);
+ most_significant_q_limb = 1;
+ }
+
+ for( i = qextra_limbs + nsize - 2 - 1; i >= 0; i-- ) {
+ mpi_limb_t q;
+ mpi_limb_t r;
+
+ if( i >= qextra_limbs )
+ np--;
+ else
+ np[0] = 0;
+
+ if( n1 == d1 ) {
+ /* Q should be either 111..111 or 111..110. Need special
+ * treatment of this rare case as normal division would
+ * give overflow. */
+ q = ~(mpi_limb_t)0;
+
+ r = n0 + d1;
+ if( r < d1 ) { /* Carry in the addition? */
+ add_ssaaaa( n1, n0, r - d0, np[0], 0, d0 );
+ qp[i] = q;
+ continue;
+ }
+ n1 = d0 - (d0 != 0?1:0);
+ n0 = -d0;
+ }
+ else {
+ udiv_qrnnd (q, r, n1, n0, d1);
+ umul_ppmm (n1, n0, d0, q);
+ }
+
+ n2 = np[0];
+ q_test:
+ if( n1 > r || (n1 == r && n0 > n2) ) {
+ /* The estimated Q was too large. */
+ q--;
+ sub_ddmmss (n1, n0, n1, n0, 0, d0);
+ r += d1;
+ if( r >= d1 ) /* If not carry, test Q again. */
+ goto q_test;
+ }
+
+ qp[i] = q;
+ sub_ddmmss (n1, n0, r, n2, n1, n0);
+ }
+ np[1] = n1;
+ np[0] = n0;
+ }
+ break;
+
+ default:
+ {
+ mpi_size_t i;
+ mpi_limb_t dX, d1, n0;
+
+ np += nsize - dsize;
+ dX = dp[dsize - 1];
+ d1 = dp[dsize - 2];
+ n0 = np[dsize - 1];
+
+ if( n0 >= dX ) {
+ if(n0 > dX || _gcry_mpih_cmp(np, dp, dsize - 1) >= 0 ) {
+ _gcry_mpih_sub_n(np, np, dp, dsize);
+ n0 = np[dsize - 1];
+ most_significant_q_limb = 1;
+ }
+ }
+
+ for( i = qextra_limbs + nsize - dsize - 1; i >= 0; i--) {
+ mpi_limb_t q;
+ mpi_limb_t n1, n2;
+ mpi_limb_t cy_limb;
+
+ if( i >= qextra_limbs ) {
+ np--;
+ n2 = np[dsize];
+ }
+ else {
+ n2 = np[dsize - 1];
+ MPN_COPY_DECR (np + 1, np, dsize - 1);
+ np[0] = 0;
+ }
+
+ if( n0 == dX ) {
+ /* This might over-estimate q, but it's probably not worth
+ * the extra code here to find out. */
+ q = ~(mpi_limb_t)0;
+ }
+ else {
+ mpi_limb_t r;
+
+ udiv_qrnnd(q, r, n0, np[dsize - 1], dX);
+ umul_ppmm(n1, n0, d1, q);
+
+ while( n1 > r || (n1 == r && n0 > np[dsize - 2])) {
+ q--;
+ r += dX;
+ if( r < dX ) /* I.e. "carry in previous addition?" */
+ break;
+ n1 -= n0 < d1;
+ n0 -= d1;
+ }
+ }
+
+ /* Possible optimization: We already have (q * n0) and (1 * n1)
+ * after the calculation of q. Taking advantage of that, we
+ * could make this loop make two iterations less. */
+ cy_limb = _gcry_mpih_submul_1(np, dp, dsize, q);
+
+ if( n2 != cy_limb ) {
+ _gcry_mpih_add_n(np, np, dp, dsize);
+ q--;
+ }
+
+ qp[i] = q;
+ n0 = np[dsize - 1];
+ }
+ }
+ }
+
+ return most_significant_q_limb;
+}
+
+
+/****************
+ * Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by DIVISOR_LIMB.
+ * Write DIVIDEND_SIZE limbs of quotient at QUOT_PTR.
+ * Return the single-limb remainder.
+ * There are no constraints on the value of the divisor.
+ *
+ * QUOT_PTR and DIVIDEND_PTR might point to the same limb.
+ */
+
+mpi_limb_t
+_gcry_mpih_divmod_1( mpi_ptr_t quot_ptr,
+ mpi_ptr_t dividend_ptr, mpi_size_t dividend_size,
+ mpi_limb_t divisor_limb)
+{
+ mpi_size_t i;
+ mpi_limb_t n1, n0, r;
+ int dummy;
+
+ if( !dividend_size )
+ return 0;
+
+ /* If multiplication is much faster than division, and the
+ * dividend is large, pre-invert the divisor, and use
+ * only multiplications in the inner loop.
+ *
+ * This test should be read:
+ * Does it ever help to use udiv_qrnnd_preinv?
+ * && Does what we save compensate for the inversion overhead?
+ */
+ if( UDIV_TIME > (2 * UMUL_TIME + 6)
+ && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME ) {
+ int normalization_steps;
+
+ count_leading_zeros( normalization_steps, divisor_limb );
+ if( normalization_steps ) {
+ mpi_limb_t divisor_limb_inverted;
+
+ divisor_limb <<= normalization_steps;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ * most significant bit (with weight 2**N) implicit.
+ */
+ /* Special case for DIVISOR_LIMB == 100...000. */
+ if( !(divisor_limb << 1) )
+ divisor_limb_inverted = ~(mpi_limb_t)0;
+ else
+ udiv_qrnnd(divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ * if (r == 0
+ * && divisor_limb > ((n1 << normalization_steps)
+ * | (dividend_ptr[dividend_size - 2] >> ...)))
+ * ...one division less...
+ */
+ for( i = dividend_size - 2; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ UDIV_QRNND_PREINV( quot_ptr[i + 1], r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+ divisor_limb, divisor_limb_inverted);
+ n1 = n0;
+ }
+ UDIV_QRNND_PREINV( quot_ptr[0], r, r,
+ n1 << normalization_steps,
+ divisor_limb, divisor_limb_inverted);
+ return r >> normalization_steps;
+ }
+ else {
+ mpi_limb_t divisor_limb_inverted;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ * result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ * most significant bit (with weight 2**N) implicit.
+ */
+ /* Special case for DIVISOR_LIMB == 100...000. */
+ if( !(divisor_limb << 1) )
+ divisor_limb_inverted = ~(mpi_limb_t) 0;
+ else
+ udiv_qrnnd(divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if( r >= divisor_limb )
+ r = 0;
+ else
+ quot_ptr[i--] = 0;
+
+ for( ; i >= 0; i-- ) {
+ n0 = dividend_ptr[i];
+ UDIV_QRNND_PREINV( quot_ptr[i], r, r,
+ n0, divisor_limb, divisor_limb_inverted);
+ }
+ return r;
+ }
+ }
+ else {
+ if(UDIV_NEEDS_NORMALIZATION) {
+ int normalization_steps;
+
+ count_leading_zeros (normalization_steps, divisor_limb);
+ if( normalization_steps ) {
+ divisor_limb <<= normalization_steps;
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MPI_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ * if (r == 0
+ * && divisor_limb > ((n1 << normalization_steps)
+ * | (dividend_ptr[dividend_size - 2] >> ...)))
+ * ...one division less...
+ */
+ for( i = dividend_size - 2; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd (quot_ptr[i + 1], r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MPI_LIMB - normalization_steps))),
+ divisor_limb);
+ n1 = n0;
+ }
+ udiv_qrnnd (quot_ptr[0], r, r,
+ n1 << normalization_steps,
+ divisor_limb);
+ return r >> normalization_steps;
+ }
+ }
+ /* No normalization needed, either because udiv_qrnnd doesn't require
+ * it, or because DIVISOR_LIMB is already normalized. */
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if(r >= divisor_limb)
+ r = 0;
+ else
+ quot_ptr[i--] = 0;
+
+ for(; i >= 0; i--) {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd( quot_ptr[i], r, r, n0, divisor_limb );
+ }
+ return r;
+ }
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpih-mul.c b/grub-core/lib/libgcrypt/mpi/mpih-mul.c
new file mode 100644
index 0000000..b8e0561
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpih-mul.c
@@ -0,0 +1,528 @@
+/* mpih-mul.c - MPI helper functions
+ * Copyright (C) 1994, 1996, 1998, 1999, 2000,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "mpi-internal.h"
+#include "longlong.h"
+#include "g10lib.h"
+
+#define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \
+ do { \
+ if( (size) < KARATSUBA_THRESHOLD ) \
+ mul_n_basecase (prodp, up, vp, size); \
+ else \
+ mul_n (prodp, up, vp, size, tspace); \
+ } while (0);
+
+#define MPN_SQR_N_RECURSE(prodp, up, size, tspace) \
+ do { \
+ if ((size) < KARATSUBA_THRESHOLD) \
+ _gcry_mpih_sqr_n_basecase (prodp, up, size); \
+ else \
+ _gcry_mpih_sqr_n (prodp, up, size, tspace); \
+ } while (0);
+
+
+
+
+/* Multiply the natural numbers u (pointed to by UP) and v (pointed to by VP),
+ * both with SIZE limbs, and store the result at PRODP. 2 * SIZE limbs are
+ * always stored. Return the most significant limb.
+ *
+ * Argument constraints:
+ * 1. PRODP != UP and PRODP != VP, i.e. the destination
+ * must be distinct from the multiplier and the multiplicand.
+ *
+ *
+ * Handle simple cases with traditional multiplication.
+ *
+ * This is the most critical code of multiplication. All multiplies rely
+ * on this, both small and huge. Small ones arrive here immediately. Huge
+ * ones arrive here as this is the base case for Karatsuba's recursive
+ * algorithm below.
+ */
+
+static mpi_limb_t
+mul_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up,
+ mpi_ptr_t vp, mpi_size_t size)
+{
+ mpi_size_t i;
+ mpi_limb_t cy;
+ mpi_limb_t v_limb;
+
+ /* Multiply by the first limb in V separately, as the result can be
+ * stored (not added) to PROD. We also avoid a loop for zeroing. */
+ v_limb = vp[0];
+ if( v_limb <= 1 ) {
+ if( v_limb == 1 )
+ MPN_COPY( prodp, up, size );
+ else
+ MPN_ZERO( prodp, size );
+ cy = 0;
+ }
+ else
+ cy = _gcry_mpih_mul_1( prodp, up, size, v_limb );
+
+ prodp[size] = cy;
+ prodp++;
+
+ /* For each iteration in the outer loop, multiply one limb from
+ * U with one limb from V, and add it to PROD. */
+ for( i = 1; i < size; i++ ) {
+ v_limb = vp[i];
+ if( v_limb <= 1 ) {
+ cy = 0;
+ if( v_limb == 1 )
+ cy = _gcry_mpih_add_n(prodp, prodp, up, size);
+ }
+ else
+ cy = _gcry_mpih_addmul_1(prodp, up, size, v_limb);
+
+ prodp[size] = cy;
+ prodp++;
+ }
+
+ return cy;
+}
+
+
+static void
+mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp,
+ mpi_size_t size, mpi_ptr_t tspace )
+{
+ if( size & 1 ) {
+ /* The size is odd, and the code below doesn't handle that.
+ * Multiply the least significant (size - 1) limbs with a recursive
+ * call, and handle the most significant limb of S1 and S2
+ * separately.
+ * A slightly faster way to do this would be to make the Karatsuba
+ * code below behave as if the size were even, and let it check for
+ * odd size in the end. I.e., in essence move this code to the end.
+ * Doing so would save us a recursive call, and potentially make the
+ * stack grow a lot less.
+ */
+ mpi_size_t esize = size - 1; /* even size */
+ mpi_limb_t cy_limb;
+
+ MPN_MUL_N_RECURSE( prodp, up, vp, esize, tspace );
+ cy_limb = _gcry_mpih_addmul_1( prodp + esize, up, esize, vp[esize] );
+ prodp[esize + esize] = cy_limb;
+ cy_limb = _gcry_mpih_addmul_1( prodp + esize, vp, size, up[esize] );
+ prodp[esize + size] = cy_limb;
+ }
+ else {
+ /* Anatolij Alekseevich Karatsuba's divide-and-conquer algorithm.
+ *
+ * Split U in two pieces, U1 and U0, such that
+ * U = U0 + U1*(B**n),
+ * and V in V1 and V0, such that
+ * V = V0 + V1*(B**n).
+ *
+ * UV is then computed recursively using the identity
+ *
+ * 2n n n n
+ * UV = (B + B )U V + B (U -U )(V -V ) + (B + 1)U V
+ * 1 1 1 0 0 1 0 0
+ *
+ * Where B = 2**BITS_PER_MP_LIMB.
+ */
+ mpi_size_t hsize = size >> 1;
+ mpi_limb_t cy;
+ int negflg;
+
+ /* Product H. ________________ ________________
+ * |_____U1 x V1____||____U0 x V0_____|
+ * Put result in upper part of PROD and pass low part of TSPACE
+ * as new TSPACE.
+ */
+ MPN_MUL_N_RECURSE(prodp + size, up + hsize, vp + hsize, hsize, tspace);
+
+ /* Product M. ________________
+ * |_(U1-U0)(V0-V1)_|
+ */
+ if( _gcry_mpih_cmp(up + hsize, up, hsize) >= 0 ) {
+ _gcry_mpih_sub_n(prodp, up + hsize, up, hsize);
+ negflg = 0;
+ }
+ else {
+ _gcry_mpih_sub_n(prodp, up, up + hsize, hsize);
+ negflg = 1;
+ }
+ if( _gcry_mpih_cmp(vp + hsize, vp, hsize) >= 0 ) {
+ _gcry_mpih_sub_n(prodp + hsize, vp + hsize, vp, hsize);
+ negflg ^= 1;
+ }
+ else {
+ _gcry_mpih_sub_n(prodp + hsize, vp, vp + hsize, hsize);
+ /* No change of NEGFLG. */
+ }
+ /* Read temporary operands from low part of PROD.
+ * Put result in low part of TSPACE using upper part of TSPACE
+ * as new TSPACE.
+ */
+ MPN_MUL_N_RECURSE(tspace, prodp, prodp + hsize, hsize, tspace + size);
+
+ /* Add/copy product H. */
+ MPN_COPY (prodp + hsize, prodp + size, hsize);
+ cy = _gcry_mpih_add_n( prodp + size, prodp + size,
+ prodp + size + hsize, hsize);
+
+ /* Add product M (if NEGFLG M is a negative number) */
+ if(negflg)
+ cy -= _gcry_mpih_sub_n(prodp + hsize, prodp + hsize, tspace, size);
+ else
+ cy += _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace, size);
+
+ /* Product L. ________________ ________________
+ * |________________||____U0 x V0_____|
+ * Read temporary operands from low part of PROD.
+ * Put result in low part of TSPACE using upper part of TSPACE
+ * as new TSPACE.
+ */
+ MPN_MUL_N_RECURSE(tspace, up, vp, hsize, tspace + size);
+
+ /* Add/copy Product L (twice) */
+
+ cy += _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace, size);
+ if( cy )
+ _gcry_mpih_add_1(prodp + hsize + size, prodp + hsize + size, hsize, cy);
+
+ MPN_COPY(prodp, tspace, hsize);
+ cy = _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace + hsize, hsize);
+ if( cy )
+ _gcry_mpih_add_1(prodp + size, prodp + size, size, 1);
+ }
+}
+
+
+void
+_gcry_mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size )
+{
+ mpi_size_t i;
+ mpi_limb_t cy_limb;
+ mpi_limb_t v_limb;
+
+ /* Multiply by the first limb in V separately, as the result can be
+ * stored (not added) to PROD. We also avoid a loop for zeroing. */
+ v_limb = up[0];
+ if( v_limb <= 1 ) {
+ if( v_limb == 1 )
+ MPN_COPY( prodp, up, size );
+ else
+ MPN_ZERO(prodp, size);
+ cy_limb = 0;
+ }
+ else
+ cy_limb = _gcry_mpih_mul_1( prodp, up, size, v_limb );
+
+ prodp[size] = cy_limb;
+ prodp++;
+
+ /* For each iteration in the outer loop, multiply one limb from
+ * U with one limb from V, and add it to PROD. */
+ for( i=1; i < size; i++) {
+ v_limb = up[i];
+ if( v_limb <= 1 ) {
+ cy_limb = 0;
+ if( v_limb == 1 )
+ cy_limb = _gcry_mpih_add_n(prodp, prodp, up, size);
+ }
+ else
+ cy_limb = _gcry_mpih_addmul_1(prodp, up, size, v_limb);
+
+ prodp[size] = cy_limb;
+ prodp++;
+ }
+}
+
+
+void
+_gcry_mpih_sqr_n( mpi_ptr_t prodp,
+ mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace)
+{
+ if( size & 1 ) {
+ /* The size is odd, and the code below doesn't handle that.
+ * Multiply the least significant (size - 1) limbs with a recursive
+ * call, and handle the most significant limb of S1 and S2
+ * separately.
+ * A slightly faster way to do this would be to make the Karatsuba
+ * code below behave as if the size were even, and let it check for
+ * odd size in the end. I.e., in essence move this code to the end.
+ * Doing so would save us a recursive call, and potentially make the
+ * stack grow a lot less.
+ */
+ mpi_size_t esize = size - 1; /* even size */
+ mpi_limb_t cy_limb;
+
+ MPN_SQR_N_RECURSE( prodp, up, esize, tspace );
+ cy_limb = _gcry_mpih_addmul_1( prodp + esize, up, esize, up[esize] );
+ prodp[esize + esize] = cy_limb;
+ cy_limb = _gcry_mpih_addmul_1( prodp + esize, up, size, up[esize] );
+
+ prodp[esize + size] = cy_limb;
+ }
+ else {
+ mpi_size_t hsize = size >> 1;
+ mpi_limb_t cy;
+
+ /* Product H. ________________ ________________
+ * |_____U1 x U1____||____U0 x U0_____|
+ * Put result in upper part of PROD and pass low part of TSPACE
+ * as new TSPACE.
+ */
+ MPN_SQR_N_RECURSE(prodp + size, up + hsize, hsize, tspace);
+
+ /* Product M. ________________
+ * |_(U1-U0)(U0-U1)_|
+ */
+ if( _gcry_mpih_cmp( up + hsize, up, hsize) >= 0 )
+ _gcry_mpih_sub_n( prodp, up + hsize, up, hsize);
+ else
+ _gcry_mpih_sub_n (prodp, up, up + hsize, hsize);
+
+ /* Read temporary operands from low part of PROD.
+ * Put result in low part of TSPACE using upper part of TSPACE
+ * as new TSPACE. */
+ MPN_SQR_N_RECURSE(tspace, prodp, hsize, tspace + size);
+
+ /* Add/copy product H */
+ MPN_COPY(prodp + hsize, prodp + size, hsize);
+ cy = _gcry_mpih_add_n(prodp + size, prodp + size,
+ prodp + size + hsize, hsize);
+
+ /* Add product M (if NEGFLG M is a negative number). */
+ cy -= _gcry_mpih_sub_n (prodp + hsize, prodp + hsize, tspace, size);
+
+ /* Product L. ________________ ________________
+ * |________________||____U0 x U0_____|
+ * Read temporary operands from low part of PROD.
+ * Put result in low part of TSPACE using upper part of TSPACE
+ * as new TSPACE. */
+ MPN_SQR_N_RECURSE (tspace, up, hsize, tspace + size);
+
+ /* Add/copy Product L (twice). */
+ cy += _gcry_mpih_add_n (prodp + hsize, prodp + hsize, tspace, size);
+ if( cy )
+ _gcry_mpih_add_1(prodp + hsize + size, prodp + hsize + size,
+ hsize, cy);
+
+ MPN_COPY(prodp, tspace, hsize);
+ cy = _gcry_mpih_add_n (prodp + hsize, prodp + hsize, tspace + hsize, hsize);
+ if( cy )
+ _gcry_mpih_add_1 (prodp + size, prodp + size, size, 1);
+ }
+}
+
+
+/* This should be made into an inline function in gmp.h. */
+void
+_gcry_mpih_mul_n( mpi_ptr_t prodp,
+ mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size)
+{
+ int secure;
+
+ if( up == vp ) {
+ if( size < KARATSUBA_THRESHOLD )
+ _gcry_mpih_sqr_n_basecase( prodp, up, size );
+ else {
+ mpi_ptr_t tspace;
+ secure = gcry_is_secure( up );
+ tspace = mpi_alloc_limb_space( 2 * size, secure );
+ _gcry_mpih_sqr_n( prodp, up, size, tspace );
+ _gcry_mpi_free_limb_space (tspace, 2 * size );
+ }
+ }
+ else {
+ if( size < KARATSUBA_THRESHOLD )
+ mul_n_basecase( prodp, up, vp, size );
+ else {
+ mpi_ptr_t tspace;
+ secure = gcry_is_secure( up ) || gcry_is_secure( vp );
+ tspace = mpi_alloc_limb_space( 2 * size, secure );
+ mul_n (prodp, up, vp, size, tspace);
+ _gcry_mpi_free_limb_space (tspace, 2 * size );
+ }
+ }
+}
+
+
+
+void
+_gcry_mpih_mul_karatsuba_case( mpi_ptr_t prodp,
+ mpi_ptr_t up, mpi_size_t usize,
+ mpi_ptr_t vp, mpi_size_t vsize,
+ struct karatsuba_ctx *ctx )
+{
+ mpi_limb_t cy;
+
+ if( !ctx->tspace || ctx->tspace_size < vsize ) {
+ if( ctx->tspace )
+ _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs );
+ ctx->tspace_nlimbs = 2 * vsize;
+ ctx->tspace = mpi_alloc_limb_space( 2 * vsize,
+ (gcry_is_secure( up )
+ || gcry_is_secure( vp )) );
+ ctx->tspace_size = vsize;
+ }
+
+ MPN_MUL_N_RECURSE( prodp, up, vp, vsize, ctx->tspace );
+
+ prodp += vsize;
+ up += vsize;
+ usize -= vsize;
+ if( usize >= vsize ) {
+ if( !ctx->tp || ctx->tp_size < vsize ) {
+ if( ctx->tp )
+ _gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs );
+ ctx->tp_nlimbs = 2 * vsize;
+ ctx->tp = mpi_alloc_limb_space( 2 * vsize, gcry_is_secure( up )
+ || gcry_is_secure( vp ) );
+ ctx->tp_size = vsize;
+ }
+
+ do {
+ MPN_MUL_N_RECURSE( ctx->tp, up, vp, vsize, ctx->tspace );
+ cy = _gcry_mpih_add_n( prodp, prodp, ctx->tp, vsize );
+ _gcry_mpih_add_1( prodp + vsize, ctx->tp + vsize, vsize, cy );
+ prodp += vsize;
+ up += vsize;
+ usize -= vsize;
+ } while( usize >= vsize );
+ }
+
+ if( usize ) {
+ if( usize < KARATSUBA_THRESHOLD ) {
+ _gcry_mpih_mul( ctx->tspace, vp, vsize, up, usize );
+ }
+ else {
+ if( !ctx->next ) {
+ ctx->next = gcry_xcalloc( 1, sizeof *ctx );
+ }
+ _gcry_mpih_mul_karatsuba_case( ctx->tspace,
+ vp, vsize,
+ up, usize,
+ ctx->next );
+ }
+
+ cy = _gcry_mpih_add_n( prodp, prodp, ctx->tspace, vsize);
+ _gcry_mpih_add_1( prodp + vsize, ctx->tspace + vsize, usize, cy );
+ }
+}
+
+
+void
+_gcry_mpih_release_karatsuba_ctx( struct karatsuba_ctx *ctx )
+{
+ struct karatsuba_ctx *ctx2;
+
+ if( ctx->tp )
+ _gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs );
+ if( ctx->tspace )
+ _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs );
+ for( ctx=ctx->next; ctx; ctx = ctx2 ) {
+ ctx2 = ctx->next;
+ if( ctx->tp )
+ _gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs );
+ if( ctx->tspace )
+ _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs );
+ gcry_free( ctx );
+ }
+}
+
+/* Multiply the natural numbers u (pointed to by UP, with USIZE limbs)
+ * and v (pointed to by VP, with VSIZE limbs), and store the result at
+ * PRODP. USIZE + VSIZE limbs are always stored, but if the input
+ * operands are normalized. Return the most significant limb of the
+ * result.
+ *
+ * NOTE: The space pointed to by PRODP is overwritten before finished
+ * with U and V, so overlap is an error.
+ *
+ * Argument constraints:
+ * 1. USIZE >= VSIZE.
+ * 2. PRODP != UP and PRODP != VP, i.e. the destination
+ * must be distinct from the multiplier and the multiplicand.
+ */
+
+mpi_limb_t
+_gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize,
+ mpi_ptr_t vp, mpi_size_t vsize)
+{
+ mpi_ptr_t prod_endp = prodp + usize + vsize - 1;
+ mpi_limb_t cy;
+ struct karatsuba_ctx ctx;
+
+ if( vsize < KARATSUBA_THRESHOLD ) {
+ mpi_size_t i;
+ mpi_limb_t v_limb;
+
+ if( !vsize )
+ return 0;
+
+ /* Multiply by the first limb in V separately, as the result can be
+ * stored (not added) to PROD. We also avoid a loop for zeroing. */
+ v_limb = vp[0];
+ if( v_limb <= 1 ) {
+ if( v_limb == 1 )
+ MPN_COPY( prodp, up, usize );
+ else
+ MPN_ZERO( prodp, usize );
+ cy = 0;
+ }
+ else
+ cy = _gcry_mpih_mul_1( prodp, up, usize, v_limb );
+
+ prodp[usize] = cy;
+ prodp++;
+
+ /* For each iteration in the outer loop, multiply one limb from
+ * U with one limb from V, and add it to PROD. */
+ for( i = 1; i < vsize; i++ ) {
+ v_limb = vp[i];
+ if( v_limb <= 1 ) {
+ cy = 0;
+ if( v_limb == 1 )
+ cy = _gcry_mpih_add_n(prodp, prodp, up, usize);
+ }
+ else
+ cy = _gcry_mpih_addmul_1(prodp, up, usize, v_limb);
+
+ prodp[usize] = cy;
+ prodp++;
+ }
+
+ return cy;
+ }
+
+ memset( &ctx, 0, sizeof ctx );
+ _gcry_mpih_mul_karatsuba_case( prodp, up, usize, vp, vsize, &ctx );
+ _gcry_mpih_release_karatsuba_ctx( &ctx );
+ return *prod_endp;
+}
diff --git a/grub-core/lib/libgcrypt/mpi/mpiutil.c b/grub-core/lib/libgcrypt/mpi/mpiutil.c
new file mode 100644
index 0000000..76630a6
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/mpiutil.c
@@ -0,0 +1,460 @@
+/* mpiutil.ac - Utility functions for MPI
+ * Copyright (C) 1998, 2000, 2001, 2002, 2003,
+ * 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "g10lib.h"
+#include "mpi-internal.h"
+#include "mod-source-info.h"
+
+
+const char *
+_gcry_mpi_get_hw_config (void)
+{
+ return mod_source_info + 1;
+}
+
+
+/****************
+ * Note: It was a bad idea to use the number of limbs to allocate
+ * because on a alpha the limbs are large but we normally need
+ * integers of n bits - So we should change this to bits (or bytes).
+ *
+ * But mpi_alloc is used in a lot of places :-(. New code
+ * should use mpi_new.
+ */
+gcry_mpi_t
+_gcry_mpi_alloc( unsigned nlimbs )
+{
+ gcry_mpi_t a;
+
+ a = gcry_xmalloc( sizeof *a );
+ a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 0 ) : NULL;
+ a->alloced = nlimbs;
+ a->nlimbs = 0;
+ a->sign = 0;
+ a->flags = 0;
+ return a;
+}
+
+void
+_gcry_mpi_m_check( gcry_mpi_t a )
+{
+ _gcry_check_heap(a);
+ _gcry_check_heap(a->d);
+}
+
+gcry_mpi_t
+_gcry_mpi_alloc_secure( unsigned nlimbs )
+{
+ gcry_mpi_t a;
+
+ a = gcry_xmalloc( sizeof *a );
+ a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 1 ) : NULL;
+ a->alloced = nlimbs;
+ a->flags = 1;
+ a->nlimbs = 0;
+ a->sign = 0;
+ return a;
+}
+
+
+
+mpi_ptr_t
+_gcry_mpi_alloc_limb_space( unsigned int nlimbs, int secure )
+{
+ mpi_ptr_t p;
+ size_t len;
+
+ len = (nlimbs ? nlimbs : 1) * sizeof (mpi_limb_t);
+ p = secure ? gcry_xmalloc_secure (len) : gcry_xmalloc (len);
+ if (! nlimbs)
+ *p = 0;
+
+ return p;
+}
+
+void
+_gcry_mpi_free_limb_space( mpi_ptr_t a, unsigned int nlimbs)
+{
+ if (a)
+ {
+ size_t len = nlimbs * sizeof(mpi_limb_t);
+
+ /* If we have information on the number of allocated limbs, we
+ better wipe that space out. This is a failsafe feature if
+ secure memory has been disabled or was not properly
+ implemented in user provided allocation functions. */
+ if (len)
+ wipememory (a, len);
+ gcry_free(a);
+ }
+}
+
+
+void
+_gcry_mpi_assign_limb_space( gcry_mpi_t a, mpi_ptr_t ap, unsigned int nlimbs )
+{
+ _gcry_mpi_free_limb_space (a->d, a->alloced);
+ a->d = ap;
+ a->alloced = nlimbs;
+}
+
+
+
+/****************
+ * Resize the array of A to NLIMBS. The additional space is cleared
+ * (set to 0).
+ */
+void
+_gcry_mpi_resize (gcry_mpi_t a, unsigned nlimbs)
+{
+ size_t i;
+
+ if (nlimbs <= a->alloced)
+ {
+ /* We only need to clear the new space (this is a nop if the
+ limb space is already of the correct size. */
+ for (i=a->nlimbs; i < a->alloced; i++)
+ a->d[i] = 0;
+ return;
+ }
+
+ /* Actually resize the limb space. */
+ if (a->d)
+ {
+ a->d = gcry_xrealloc (a->d, nlimbs * sizeof (mpi_limb_t));
+ for (i=a->alloced; i < nlimbs; i++)
+ a->d[i] = 0;
+ }
+ else
+ {
+ if (a->flags & 1)
+ /* Secure memory is wanted. */
+ a->d = gcry_xcalloc_secure (nlimbs , sizeof (mpi_limb_t));
+ else
+ /* Standard memory. */
+ a->d = gcry_xcalloc (nlimbs , sizeof (mpi_limb_t));
+ }
+ a->alloced = nlimbs;
+}
+
+void
+_gcry_mpi_clear( gcry_mpi_t a )
+{
+ a->nlimbs = 0;
+ a->flags = 0;
+}
+
+
+void
+_gcry_mpi_free( gcry_mpi_t a )
+{
+ if (!a )
+ return;
+ if ((a->flags & 4))
+ gcry_free( a->d );
+ else
+ {
+ _gcry_mpi_free_limb_space(a->d, a->alloced);
+ }
+ if ((a->flags & ~7))
+ log_bug("invalid flag value in mpi\n");
+ gcry_free(a);
+}
+
+static void
+mpi_set_secure( gcry_mpi_t a )
+{
+ mpi_ptr_t ap, bp;
+
+ if ( (a->flags & 1) )
+ return;
+ a->flags |= 1;
+ ap = a->d;
+ if (!a->nlimbs)
+ {
+ gcry_assert (!ap);
+ return;
+ }
+ bp = mpi_alloc_limb_space (a->nlimbs, 1);
+ MPN_COPY( bp, ap, a->nlimbs );
+ a->d = bp;
+ _gcry_mpi_free_limb_space (ap, a->alloced);
+}
+
+
+gcry_mpi_t
+gcry_mpi_set_opaque( gcry_mpi_t a, void *p, unsigned int nbits )
+{
+ if (!a)
+ a = mpi_alloc(0);
+
+ if( a->flags & 4 )
+ gcry_free( a->d );
+ else
+ _gcry_mpi_free_limb_space (a->d, a->alloced);
+
+ a->d = p;
+ a->alloced = 0;
+ a->nlimbs = 0;
+ a->sign = nbits;
+ a->flags = 4;
+ return a;
+}
+
+
+void *
+gcry_mpi_get_opaque( gcry_mpi_t a, unsigned int *nbits )
+{
+ if( !(a->flags & 4) )
+ log_bug("mpi_get_opaque on normal mpi\n");
+ if( nbits )
+ *nbits = a->sign;
+ return a->d;
+}
+
+
+/****************
+ * Note: This copy function should not interpret the MPI
+ * but copy it transparently.
+ */
+gcry_mpi_t
+gcry_mpi_copy( gcry_mpi_t a )
+{
+ int i;
+ gcry_mpi_t b;
+
+ if( a && (a->flags & 4) ) {
+ void *p = gcry_is_secure(a->d)? gcry_xmalloc_secure( (a->sign+7)/8 )
+ : gcry_xmalloc( (a->sign+7)/8 );
+ memcpy( p, a->d, (a->sign+7)/8 );
+ b = gcry_mpi_set_opaque( NULL, p, a->sign );
+ }
+ else if( a ) {
+ b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
+ : mpi_alloc( a->nlimbs );
+ b->nlimbs = a->nlimbs;
+ b->sign = a->sign;
+ b->flags = a->flags;
+ for(i=0; i < b->nlimbs; i++ )
+ b->d[i] = a->d[i];
+ }
+ else
+ b = NULL;
+ return b;
+}
+
+
+/****************
+ * This function allocates an MPI which is optimized to hold
+ * a value as large as the one given in the argument and allocates it
+ * with the same flags as A.
+ */
+gcry_mpi_t
+_gcry_mpi_alloc_like( gcry_mpi_t a )
+{
+ gcry_mpi_t b;
+
+ if( a && (a->flags & 4) ) {
+ int n = (a->sign+7)/8;
+ void *p = gcry_is_secure(a->d)? gcry_malloc_secure( n )
+ : gcry_malloc( n );
+ memcpy( p, a->d, n );
+ b = gcry_mpi_set_opaque( NULL, p, a->sign );
+ }
+ else if( a ) {
+ b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
+ : mpi_alloc( a->nlimbs );
+ b->nlimbs = 0;
+ b->sign = 0;
+ b->flags = a->flags;
+ }
+ else
+ b = NULL;
+ return b;
+}
+
+
+gcry_mpi_t
+gcry_mpi_set( gcry_mpi_t w, gcry_mpi_t u)
+{
+ mpi_ptr_t wp, up;
+ mpi_size_t usize = u->nlimbs;
+ int usign = u->sign;
+
+ if (!w)
+ w = _gcry_mpi_alloc( mpi_get_nlimbs(u) );
+ RESIZE_IF_NEEDED(w, usize);
+ wp = w->d;
+ up = u->d;
+ MPN_COPY( wp, up, usize );
+ w->nlimbs = usize;
+ w->flags = u->flags;
+ w->sign = usign;
+ return w;
+}
+
+
+gcry_mpi_t
+gcry_mpi_set_ui( gcry_mpi_t w, unsigned long u)
+{
+ if (!w)
+ w = _gcry_mpi_alloc (1);
+ /* FIXME: If U is 0 we have no need to resize and thus possible
+ allocating the the limbs. */
+ RESIZE_IF_NEEDED(w, 1);
+ w->d[0] = u;
+ w->nlimbs = u? 1:0;
+ w->sign = 0;
+ w->flags = 0;
+ return w;
+}
+
+gcry_err_code_t
+_gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ unsigned long x = 0;
+
+ if (w->nlimbs > 1)
+ err = GPG_ERR_TOO_LARGE;
+ else if (w->nlimbs == 1)
+ x = w->d[0];
+ else
+ x = 0;
+
+ if (! err)
+ *u = x;
+
+ return err;
+}
+
+gcry_error_t
+gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+
+ err = _gcry_mpi_get_ui (w, u);
+
+ return gcry_error (err);
+}
+
+gcry_mpi_t
+_gcry_mpi_alloc_set_ui( unsigned long u)
+{
+ gcry_mpi_t w = mpi_alloc(1);
+ w->d[0] = u;
+ w->nlimbs = u? 1:0;
+ w->sign = 0;
+ return w;
+}
+
+void
+gcry_mpi_swap( gcry_mpi_t a, gcry_mpi_t b)
+{
+ struct gcry_mpi tmp;
+
+ tmp = *a; *a = *b; *b = tmp;
+}
+
+
+gcry_mpi_t
+gcry_mpi_new( unsigned int nbits )
+{
+ return _gcry_mpi_alloc ( (nbits+BITS_PER_MPI_LIMB-1)
+ / BITS_PER_MPI_LIMB );
+}
+
+
+gcry_mpi_t
+gcry_mpi_snew( unsigned int nbits )
+{
+ return _gcry_mpi_alloc_secure ( (nbits+BITS_PER_MPI_LIMB-1)
+ / BITS_PER_MPI_LIMB );
+}
+
+void
+gcry_mpi_release( gcry_mpi_t a )
+{
+ _gcry_mpi_free( a );
+}
+
+void
+gcry_mpi_randomize( gcry_mpi_t w,
+ unsigned int nbits, enum gcry_random_level level )
+{
+ unsigned char *p;
+ size_t nbytes = (nbits+7)/8;
+
+ if (level == GCRY_WEAK_RANDOM)
+ {
+ p = mpi_is_secure(w) ? gcry_xmalloc_secure (nbytes)
+ : gcry_xmalloc (nbytes);
+ gcry_create_nonce (p, nbytes);
+ }
+ else
+ {
+ p = mpi_is_secure(w) ? gcry_random_bytes_secure (nbytes, level)
+ : gcry_random_bytes (nbytes, level);
+ }
+ _gcry_mpi_set_buffer( w, p, nbytes, 0 );
+ gcry_free (p);
+}
+
+
+void
+gcry_mpi_set_flag( gcry_mpi_t a, enum gcry_mpi_flag flag )
+{
+ switch( flag ) {
+ case GCRYMPI_FLAG_SECURE: mpi_set_secure(a); break;
+ case GCRYMPI_FLAG_OPAQUE:
+ default: log_bug("invalid flag value\n");
+ }
+}
+
+void
+gcry_mpi_clear_flag( gcry_mpi_t a, enum gcry_mpi_flag flag )
+{
+ (void)a; /* Not yet used. */
+
+ switch (flag)
+ {
+ case GCRYMPI_FLAG_SECURE:
+ case GCRYMPI_FLAG_OPAQUE:
+ default: log_bug("invalid flag value\n");
+ }
+}
+
+int
+gcry_mpi_get_flag( gcry_mpi_t a, enum gcry_mpi_flag flag )
+{
+ switch (flag)
+ {
+ case GCRYMPI_FLAG_SECURE: return (a->flags & 1);
+ case GCRYMPI_FLAG_OPAQUE: return (a->flags & 4);
+ default: log_bug("invalid flag value\n");
+ }
+ /*NOTREACHED*/
+ return 0;
+}
diff --git a/grub-core/lib/libgcrypt/mpi/pa7100/Manifest b/grub-core/lib/libgcrypt/mpi/pa7100/Manifest
new file mode 100644
index 0000000..f075ab0
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pa7100/Manifest
@@ -0,0 +1,22 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-lshift.S
+mpih-rshift.S
+$names$ iQCVAwUAP+LmVjEAnp832S/7AQKlEQQAv2+x/d+Z0t8FwwHlxKpIKOJDr9e+Y2i8y8orcIEa3dnwU5LMOH3EzFoNSD9crc31FMokgm/X5xeLjqRTdcmGHyJJQJDPJVJyuaOm6qHJaFzzfJjrfMW66nJxfNSXIiIm4DgpP20NmumaorLCkiIZ5Z81KGAc8FiRggbRVYx+wxo==Vjh9
diff --git a/grub-core/lib/libgcrypt/mpi/pa7100/distfiles b/grub-core/lib/libgcrypt/mpi/pa7100/distfiles
new file mode 100644
index 0000000..e1cde4d
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pa7100/distfiles
@@ -0,0 +1,4 @@
+Manifest
+mpih-lshift.S
+mpih-rshift.S
+
diff --git a/grub-core/lib/libgcrypt/mpi/pa7100/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/pa7100/mpih-lshift.S
new file mode 100644
index 0000000..8ade196
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pa7100/mpih-lshift.S
@@ -0,0 +1,96 @@
+/* hppa lshift
+ * optimized for the PA7100, where it runs at 3.25 cycles/limb
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp, (gr26)
+ * mpi_ptr_t up, (gr25)
+ * mpi_size_t usize, (gr24)
+ * unsigned cnt) (gr23)
+ */
+
+ .code
+ .export _gcry_mpih_lshift
+ .label _gcry_mpih_lshift
+ .proc
+ .callinfo frame=64,no_calls
+ .entry
+
+ sh2add %r24,%r25,%r25
+ sh2add %r24,%r26,%r26
+ ldws,mb -4(0,%r25),%r22
+ subi 32,%r23,%r1
+ mtsar %r1
+ addib,= -1,%r24,L$0004
+ vshd %r0,%r22,%r28 ; compute carry out limb
+ ldws,mb -4(0,%r25),%r29
+ addib,<= -5,%r24,L$rest
+ vshd %r22,%r29,%r20
+
+ .label L$loop
+ ldws,mb -4(0,%r25),%r22
+ stws,mb %r20,-4(0,%r26)
+ vshd %r29,%r22,%r20
+ ldws,mb -4(0,%r25),%r29
+ stws,mb %r20,-4(0,%r26)
+ vshd %r22,%r29,%r20
+ ldws,mb -4(0,%r25),%r22
+ stws,mb %r20,-4(0,%r26)
+ vshd %r29,%r22,%r20
+ ldws,mb -4(0,%r25),%r29
+ stws,mb %r20,-4(0,%r26)
+ addib,> -4,%r24,L$loop
+ vshd %r22,%r29,%r20
+
+ .label L$rest
+ addib,= 4,%r24,L$end1
+ nop
+ .label L$eloop
+ ldws,mb -4(0,%r25),%r22
+ stws,mb %r20,-4(0,%r26)
+ addib,<= -1,%r24,L$end2
+ vshd %r29,%r22,%r20
+ ldws,mb -4(0,%r25),%r29
+ stws,mb %r20,-4(0,%r26)
+ addib,> -1,%r24,L$eloop
+ vshd %r22,%r29,%r20
+
+ .label L$end1
+ stws,mb %r20,-4(0,%r26)
+ vshd %r29,%r0,%r20
+ bv 0(%r2)
+ stw %r20,-4(0,%r26)
+ .label L$end2
+ stws,mb %r20,-4(0,%r26)
+ .label L$0004
+ vshd %r22,%r0,%r20
+ bv 0(%r2)
+ stw %r20,-4(0,%r26)
+
+ .exit
+ .procend
+
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/pa7100/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/pa7100/mpih-rshift.S
new file mode 100644
index 0000000..0624202
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pa7100/mpih-rshift.S
@@ -0,0 +1,92 @@
+/* hppa rshift
+ * optimized for the PA7100, where it runs at 3.25 cycles/limb
+ *
+ * Copyright (C) 1992, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp, (gr26)
+ * mpi_ptr_t up, (gr25)
+ * mpi_size_t usize, (gr24)
+ * unsigned cnt) (gr23)
+ */
+
+ .code
+ .export _gcry_mpih_rshift
+ .label _gcry_mpih_rshift
+ .proc
+ .callinfo frame=64,no_calls
+ .entry
+
+ ldws,ma 4(0,%r25),%r22
+ mtsar %r23
+ addib,= -1,%r24,L$r004
+ vshd %r22,%r0,%r28 ; compute carry out limb
+ ldws,ma 4(0,%r25),%r29
+ addib,<= -5,%r24,L$rrest
+ vshd %r29,%r22,%r20
+
+ .label L$roop
+ ldws,ma 4(0,%r25),%r22
+ stws,ma %r20,4(0,%r26)
+ vshd %r22,%r29,%r20
+ ldws,ma 4(0,%r25),%r29
+ stws,ma %r20,4(0,%r26)
+ vshd %r29,%r22,%r20
+ ldws,ma 4(0,%r25),%r22
+ stws,ma %r20,4(0,%r26)
+ vshd %r22,%r29,%r20
+ ldws,ma 4(0,%r25),%r29
+ stws,ma %r20,4(0,%r26)
+ addib,> -4,%r24,L$roop
+ vshd %r29,%r22,%r20
+
+ .label L$rrest
+ addib,= 4,%r24,L$rend1
+ nop
+ .label L$eroop
+ ldws,ma 4(0,%r25),%r22
+ stws,ma %r20,4(0,%r26)
+ addib,<= -1,%r24,L$rend2
+ vshd %r22,%r29,%r20
+ ldws,ma 4(0,%r25),%r29
+ stws,ma %r20,4(0,%r26)
+ addib,> -1,%r24,L$eroop
+ vshd %r29,%r22,%r20
+
+ .label L$rend1
+ stws,ma %r20,4(0,%r26)
+ vshd %r0,%r29,%r20
+ bv 0(%r2)
+ stw %r20,0(0,%r26)
+ .label L$rend2
+ stws,ma %r20,4(0,%r26)
+ .label L$r004
+ vshd %r0,%r22,%r20
+ bv 0(%r2)
+ stw %r20,0(0,%r26)
+
+ .exit
+ .procend
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/README b/grub-core/lib/libgcrypt/mpi/pentium4/README
new file mode 100644
index 0000000..215fc7f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/README
@@ -0,0 +1,115 @@
+Copyright 2001 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.
+
+
+
+
+ INTEL PENTIUM-4 MPN SUBROUTINES
+
+
+This directory contains mpn functions optimized for Intel Pentium-4.
+
+The mmx subdirectory has routines using MMX instructions, the sse2
+subdirectory has routines using SSE2 instructions. All P4s have these, the
+separate directories are just so configure can omit that code if the
+assembler doesn't support it.
+
+
+STATUS
+
+ cycles/limb
+
+ mpn_add_n/sub_n 4 normal, 6 in-place
+
+ mpn_mul_1 4 normal, 6 in-place
+ mpn_addmul_1 6
+ mpn_submul_1 7
+
+ mpn_mul_basecase 6 cycles/crossproduct (approx)
+
+ mpn_sqr_basecase 3.5 cycles/crossproduct (approx)
+ or 7.0 cycles/triangleproduct (approx)
+
+ mpn_l/rshift 1.75
+
+
+
+The shifts ought to be able to go at 1.5 c/l, but not much effort has been
+applied to them yet.
+
+In-place operations, and all addmul, submul, mul_basecase and sqr_basecase
+calls, suffer from pipeline anomalies associated with write combining and
+movd reads and writes to the same or nearby locations. The movq
+instructions do not trigger the same hardware problems. Unfortunately,
+using movq and splitting/combining seems to require too many extra
+instructions to help. Perhaps future chip steppings will be better.
+
+
+
+NOTES
+
+The Pentium-4 pipeline "Netburst", provides for quite a number of surprises.
+Many traditional x86 instructions run very slowly, requiring use of
+alterative instructions for acceptable performance.
+
+adcl and sbbl are quite slow at 8 cycles for reg->reg. paddq of 32-bits
+within a 64-bit mmx register seems better, though the combination
+paddq/psrlq when propagating a carry is still a 4 cycle latency.
+
+incl and decl should be avoided, instead use add $1 and sub $1. Apparently
+the carry flag is not separately renamed, so incl and decl depend on all
+previous flags-setting instructions.
+
+shll and shrl have a 4 cycle latency, or 8 times the latency of the fastest
+integer instructions (addl, subl, orl, andl, and some more). shldl and
+shrdl seem to have 13 and 15 cycles latency, respectively. Bizarre.
+
+movq mmx -> mmx does have 6 cycle latency, as noted in the documentation.
+pxor/por or similar combination at 2 cycles latency can be used instead.
+The movq however executes in the float unit, thereby saving MMX execution
+resources. With the right juggling, data moves shouldn't be on a dependent
+chain.
+
+L1 is write-through, but the write-combining sounds like it does enough to
+not require explicit destination prefetching.
+
+xmm registers so far haven't found a use, but not much effort has been
+expended. A configure test for whether the operating system knows
+fxsave/fxrestor will be needed if they're used.
+
+
+
+REFERENCES
+
+Intel Pentium-4 processor manuals,
+
+ http://developer.intel.com/design/pentium4/manuals
+
+"Intel Pentium 4 Processor Optimization Reference Manual", Intel, 2001,
+order number 248966. Available on-line:
+
+ http://developer.intel.com/design/pentium4/manuals/248966.htm
+
+
+
+----------------
+Local variables:
+mode: text
+fill-column: 76
+End:
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/distfiles b/grub-core/lib/libgcrypt/mpi/pentium4/distfiles
new file mode 100644
index 0000000..b419f85
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/distfiles
@@ -0,0 +1,3 @@
+README
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/mmx/distfiles b/grub-core/lib/libgcrypt/mpi/pentium4/mmx/distfiles
new file mode 100644
index 0000000..8f0ea42
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/mmx/distfiles
@@ -0,0 +1,2 @@
+mpih-lshift.S
+mpih-rshift.S
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/mmx/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/pentium4/mmx/mpih-lshift.S
new file mode 100644
index 0000000..e2dd184
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/mmx/mpih-lshift.S
@@ -0,0 +1,457 @@
+/* Intel Pentium-4 mpn_lshift -- left shift.
+ *
+ * Copyright 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp, (sp + 4)
+ * mpi_ptr_t up, (sp + 8)
+ * mpi_size_t usize, (sp + 12)
+ * unsigned cnt) (sp + 16)
+ *
+ * P4 Willamette, Northwood: 1.75 cycles/limb
+ * P4 Prescott: 2.0 cycles/limb
+ */
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_lshift)
+C_SYMBOL_NAME(_gcry_mpih_lshift:)
+
+
+ pushl %ebx
+ pushl %edi
+
+
+ movl 20(%esp), %eax
+ movl 12(%esp), %edx
+
+ movl 16(%esp), %ebx
+ movl 24(%esp), %ecx
+
+ cmp $5, %eax
+ jae .Lunroll
+
+ movl -4(%ebx,%eax,4), %edi
+ decl %eax
+
+ jnz .Lsimple
+
+ shldl %cl, %edi, %eax
+
+ shll %cl, %edi
+
+ movl %edi, (%edx)
+ popl %edi
+
+ popl %ebx
+
+ ret
+
+
+
+
+
+.Lsimple:
+
+
+
+
+
+
+
+
+
+ movd (%ebx,%eax,4), %mm5
+
+ movd %ecx, %mm6
+ negl %ecx
+
+ psllq %mm6, %mm5
+ addl $32, %ecx
+
+ movd %ecx, %mm7
+ psrlq $32, %mm5
+
+
+.Lsimple_top:
+
+
+
+
+
+
+
+
+
+
+
+
+ movq -4(%ebx,%eax,4), %mm0
+ decl %eax
+
+ psrlq %mm7, %mm0
+
+
+
+ movd %mm0, 4(%edx,%eax,4)
+ jnz .Lsimple_top
+
+
+ movd (%ebx), %mm0
+
+ movd %mm5, %eax
+ psllq %mm6, %mm0
+
+ popl %edi
+ popl %ebx
+
+ movd %mm0, (%edx)
+
+ emms
+
+ ret
+
+
+
+
+
+ .align 8, 0x90
+.Lunroll:
+
+
+
+
+
+
+
+
+
+ movd -4(%ebx,%eax,4), %mm5
+ leal (%ebx,%eax,4), %edi
+
+ movd %ecx, %mm6
+ andl $4, %edi
+
+ psllq %mm6, %mm5
+ jz .Lstart_src_aligned
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ movq -8(%ebx,%eax,4), %mm0
+
+ psllq %mm6, %mm0
+ decl %eax
+
+ psrlq $32, %mm0
+
+
+
+ movd %mm0, (%edx,%eax,4)
+.Lstart_src_aligned:
+
+ movq -8(%ebx,%eax,4), %mm1
+ leal (%edx,%eax,4), %edi
+
+ andl $4, %edi
+ psrlq $32, %mm5
+
+ movq -16(%ebx,%eax,4), %mm3
+ jz .Lstart_dst_aligned
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ movq %mm1, %mm0
+ addl $32, %ecx
+
+ psllq %mm6, %mm0
+
+ movd %ecx, %mm6
+ psrlq $32, %mm0
+
+
+
+ movd %mm0, -4(%edx,%eax,4)
+ subl $4, %edx
+.Lstart_dst_aligned:
+
+
+ psllq %mm6, %mm1
+ negl %ecx
+
+ addl $64, %ecx
+ movq %mm3, %mm2
+
+ movd %ecx, %mm7
+ subl $8, %eax
+
+ psrlq %mm7, %mm3
+
+ por %mm1, %mm3
+ jc .Lfinish
+
+
+
+
+ .align 8, 0x90
+.Lunroll_loop:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ movq 8(%ebx,%eax,4), %mm0
+ psllq %mm6, %mm2
+
+ movq %mm0, %mm1
+ psrlq %mm7, %mm0
+
+ movq %mm3, 24(%edx,%eax,4)
+ por %mm2, %mm0
+
+ movq (%ebx,%eax,4), %mm3
+ psllq %mm6, %mm1
+
+ movq %mm0, 16(%edx,%eax,4)
+ movq %mm3, %mm2
+
+ psrlq %mm7, %mm3
+ subl $4, %eax
+
+ por %mm1, %mm3
+ jnc .Lunroll_loop
+
+
+
+.Lfinish:
+
+
+ testb $2, %al
+
+ jz .Lfinish_no_two
+
+ movq 8(%ebx,%eax,4), %mm0
+ psllq %mm6, %mm2
+
+ movq %mm0, %mm1
+ psrlq %mm7, %mm0
+
+ movq %mm3, 24(%edx,%eax,4)
+ por %mm2, %mm0
+
+ movq %mm1, %mm2
+ movq %mm0, %mm3
+
+ subl $2, %eax
+.Lfinish_no_two:
+
+
+
+
+
+
+
+ testb $1, %al
+ movd %mm5, %eax
+
+ popl %edi
+ jz .Lfinish_zero
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ movd (%ebx), %mm0
+ psllq %mm6, %mm2
+
+ movq %mm3, 12(%edx)
+ psllq $32, %mm0
+
+ movq %mm0, %mm1
+ psrlq %mm7, %mm0
+
+ por %mm2, %mm0
+ psllq %mm6, %mm1
+
+ movq %mm0, 4(%edx)
+ psrlq $32, %mm1
+
+ andl $32, %ecx
+ popl %ebx
+
+ jz .Lfinish_one_unaligned
+
+ movd %mm1, (%edx)
+.Lfinish_one_unaligned:
+
+ emms
+
+ ret
+
+
+
+
+.Lfinish_zero:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ movq %mm3, 8(%edx)
+ andl $32, %ecx
+
+ psllq %mm6, %mm2
+ jz .Lfinish_zero_unaligned
+
+ movq %mm2, (%edx)
+.Lfinish_zero_unaligned:
+
+ psrlq $32, %mm2
+ popl %ebx
+
+ movd %mm5, %eax
+
+ movd %mm2, 4(%edx)
+
+ emms
+
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/mmx/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/pentium4/mmx/mpih-rshift.S
new file mode 100644
index 0000000..e3374e3
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/mmx/mpih-rshift.S
@@ -0,0 +1,453 @@
+/* Intel Pentium-4 mpn_rshift -- right shift.
+ *
+ * Copyright 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp, (sp + 4)
+ * mpi_ptr_t up, (sp + 8)
+ * mpi_size_t usize, (sp + 12)
+ * unsigned cnt) (sp + 16)
+ *
+ * P4 Willamette, Northwood: 1.75 cycles/limb
+ * P4 Prescott: 2.0 cycles/limb
+ */
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_rshift)
+C_SYMBOL_NAME(_gcry_mpih_rshift:)
+ pushl %ebx
+ pushl %edi
+
+
+ movl 20(%esp), %eax
+ movl 12(%esp), %edx
+
+ movl 16(%esp), %ebx
+ movl 24(%esp), %ecx
+
+ cmp $5, %eax
+ jae .Lunroll
+
+ decl %eax
+ movl (%ebx), %edi
+
+ jnz .Lsimple
+
+ shrdl %cl, %edi, %eax
+
+ shrl %cl, %edi
+
+ movl %edi, (%edx)
+ popl %edi
+
+ popl %ebx
+
+ ret
+
+
+
+
+
+ .align 8, 0x90
+.Lsimple:
+
+
+
+
+
+
+
+
+
+ movd (%ebx), %mm5
+ leal (%ebx,%eax,4), %ebx
+
+ movd %ecx, %mm6
+ leal -4(%edx,%eax,4), %edx
+
+ psllq $32, %mm5
+ negl %eax
+
+
+
+
+
+
+
+.Lsimple_top:
+
+
+
+
+
+
+
+
+
+ movq (%ebx,%eax,4), %mm0
+ incl %eax
+
+ psrlq %mm6, %mm0
+
+ movd %mm0, (%edx,%eax,4)
+ jnz .Lsimple_top
+
+
+ movd (%ebx), %mm0
+ psrlq %mm6, %mm5
+
+ psrlq %mm6, %mm0
+ popl %edi
+
+ movd %mm5, %eax
+ popl %ebx
+
+ movd %mm0, 4(%edx)
+
+ emms
+
+ ret
+
+
+
+
+
+ .align 8, 0x90
+.Lunroll:
+
+
+
+
+
+
+
+
+
+ movd (%ebx), %mm5
+ movl $4, %edi
+
+ movd %ecx, %mm6
+ testl %edi, %ebx
+
+ psllq $32, %mm5
+ jz .Lstart_src_aligned
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ movq (%ebx), %mm0
+
+ psrlq %mm6, %mm0
+ addl $4, %ebx
+
+ decl %eax
+
+ movd %mm0, (%edx)
+ addl $4, %edx
+.Lstart_src_aligned:
+
+
+ movq (%ebx), %mm1
+ testl %edi, %edx
+
+ psrlq %mm6, %mm5
+ jz .Lstart_dst_aligned
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ movq %mm1, %mm0
+ addl $32, %ecx
+
+ psrlq %mm6, %mm0
+
+ movd %ecx, %mm6
+
+ movd %mm0, (%edx)
+ addl $4, %edx
+.Lstart_dst_aligned:
+
+
+ movq 8(%ebx), %mm3
+ negl %ecx
+
+ movq %mm3, %mm2
+ addl $64, %ecx
+
+ movd %ecx, %mm7
+ psrlq %mm6, %mm1
+
+ leal -12(%ebx,%eax,4), %ebx
+ leal -20(%edx,%eax,4), %edx
+
+ psllq %mm7, %mm3
+ subl $7, %eax
+
+ por %mm1, %mm3
+ negl %eax
+
+ jns .Lfinish
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .align 8, 0x90
+.Lunroll_loop:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ movq (%ebx,%eax,4), %mm0
+ psrlq %mm6, %mm2
+
+ movq %mm0, %mm1
+ psllq %mm7, %mm0
+
+ movq %mm3, -8(%edx,%eax,4)
+ por %mm2, %mm0
+
+ movq 8(%ebx,%eax,4), %mm3
+ psrlq %mm6, %mm1
+
+ movq %mm0, (%edx,%eax,4)
+ movq %mm3, %mm2
+
+ psllq %mm7, %mm3
+ addl $4, %eax
+
+ por %mm1, %mm3
+ js .Lunroll_loop
+
+
+.Lfinish:
+
+
+ testb $2, %al
+
+ jnz .Lfinish_no_two
+
+ movq (%ebx,%eax,4), %mm0
+ psrlq %mm6, %mm2
+
+ movq %mm0, %mm1
+ psllq %mm7, %mm0
+
+ movq %mm3, -8(%edx,%eax,4)
+ por %mm2, %mm0
+
+ movq %mm1, %mm2
+ movq %mm0, %mm3
+
+ addl $2, %eax
+.Lfinish_no_two:
+
+
+
+
+
+
+
+ testb $1, %al
+ popl %edi
+
+ movd %mm5, %eax
+ jnz .Lfinish_zero
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ movd 8(%ebx), %mm0
+ psrlq %mm6, %mm2
+
+ movq %mm0, %mm1
+ psllq %mm7, %mm0
+
+ movq %mm3, (%edx)
+ por %mm2, %mm0
+
+ psrlq %mm6, %mm1
+ andl $32, %ecx
+
+ popl %ebx
+ jz .Lfinish_one_unaligned
+
+
+ movd %mm1, 16(%edx)
+.Lfinish_one_unaligned:
+
+ movq %mm0, 8(%edx)
+
+ emms
+
+ ret
+
+
+
+
+.Lfinish_zero:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ movq %mm3, 4(%edx)
+ psrlq %mm6, %mm2
+
+ movd %mm2, 12(%edx)
+ andl $32, %ecx
+
+ popl %ebx
+ jz .Lfinish_zero_unaligned
+
+ movq %mm2, 12(%edx)
+.Lfinish_zero_unaligned:
+
+ emms
+
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/sse2/distfiles b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/distfiles
new file mode 100644
index 0000000..7252cd7
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/distfiles
@@ -0,0 +1,5 @@
+mpih-add1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-sub1.S
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-add1.S
new file mode 100644
index 0000000..55ed663
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-add1.S
@@ -0,0 +1,91 @@
+/* Intel Pentium-4 mpn_add_n -- mpn addition.
+ *
+ * Copyright 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+ /*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_ptr_t s2_ptr, (sp + 12)
+ * mpi_size_t size) (sp + 16)
+ *
+ * P4 Willamette, Northwood: 4.0 cycles/limb if dst!=src1 and dst!=src2
+ * 6.0 cycles/limb if dst==src1 or dst==src2
+ * P4 Prescott: >= 5 cycles/limb
+ *
+ * The 4 c/l achieved here isn't particularly good, but is better than 9 c/l
+ * for a basic adc loop.
+ */
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_add_n)
+C_SYMBOL_NAME(_gcry_mpih_add_n:)
+
+ pxor %mm0, %mm0
+
+ movl 8(%esp), %eax /* s1_ptr */
+ movl %ebx, 8(%esp) /* re-use parameter space */
+ movl 12(%esp), %ebx /* res_ptr */
+ movl 4(%esp), %edx /* s2_ptr */
+ movl 16(%esp), %ecx /* size */
+
+ leal (%eax,%ecx,4), %eax /* src1 end */
+ leal (%ebx,%ecx,4), %ebx /* src2 end */
+ leal (%edx,%ecx,4), %edx /* dst end */
+ negl %ecx /* -size */
+
+Ltop:
+/*
+ C eax src1 end
+ C ebx src2 end
+ C ecx counter, limbs, negative
+ C edx dst end
+ C mm0 carry bit
+*/
+
+ movd (%eax,%ecx,4), %mm1
+ movd (%ebx,%ecx,4), %mm2
+ paddq %mm2, %mm1
+
+ paddq %mm1, %mm0
+ movd %mm0, (%edx,%ecx,4)
+
+ psrlq $32, %mm0
+
+ addl $1, %ecx
+ jnz Ltop
+
+
+ movd %mm0, %eax
+ movl 8(%esp), %ebx /* restore saved EBX */
+ emms
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul1.S b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul1.S
new file mode 100644
index 0000000..a0c98fb
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul1.S
@@ -0,0 +1,96 @@
+/* Intel Pentium-4 mpn_mul_1 -- Multiply a limb vector with a limb and store
+ * the result in a second limb vector.
+ *
+ * Copyright 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ *
+ * src != dst src == dst
+ * P6 model 9 (Banias) ?.?
+ * P6 model 13 (Dothan) 4.75 4.75
+ * P4 model 0 (Willamette) 4.0 6.0
+ * P4 model 1 (?) 4.0 6.0
+ * P4 model 2 (Northwood) 4.0 6.0
+ * P4 model 3 (Prescott) ?.? ?.?
+ * P4 model 4 (Nocona) ?.? ?.?
+ * Unfortunately when src==dst the write-combining described in
+ * pentium4/README takes us up to 6 c/l.
+ *
+ */
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1)
+C_SYMBOL_NAME(_gcry_mpih_mul_1:);
+
+ pxor %mm0, %mm0
+
+.Lstart_1c:
+ movl 8(%esp), %eax
+ movd 16(%esp), %mm7
+ movl 4(%esp), %edx
+ movl 12(%esp), %ecx
+
+.Ltop:
+
+/*
+ C eax src, incrementing
+ C ebx
+ C ecx counter, size iterations
+ C edx dst, incrementing
+ C
+ C mm0 carry limb
+ C mm7 multiplier
+*/
+
+ movd (%eax), %mm1
+ addl $4, %eax
+ pmuludq %mm7, %mm1
+
+ paddq %mm1, %mm0
+ movd %mm0, (%edx)
+ addl $4, %edx
+
+ psrlq $32, %mm0
+
+ subl $1, %ecx
+ jnz .Ltop
+
+
+ movd %mm0, %eax
+ emms
+ ret
+
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul2.S b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul2.S
new file mode 100644
index 0000000..f975adf
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul2.S
@@ -0,0 +1,136 @@
+/* Intel Pentium-4 mpn_addmul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ *
+ * P3 model 9 (Banias) ?.?
+ * P3 model 13 (Dothan) 5.8
+ * P4 model 0 (Willamette) 5.5
+ * P4 model 1 (?) 5.5
+ * P4 model 2 (Northwood) 5.5
+ * P4 model 3 (Prescott) 6.0
+ * P4 model 4 (Nocona)
+ *
+ * Only the carry limb propagation is on the dependent chain, but some other
+ * Pentium4 pipeline magic brings down performance to 6 cycles/l from the
+ * ideal 4 cycles/l.
+ */
+
+
+ TEXT
+ ALIGN (4)
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1)
+C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
+
+ pxor %mm4, %mm4
+.Lstart_1c:
+ movl 8(%esp), %eax
+ movl 12(%esp), %ecx
+ movl 4(%esp), %edx
+ movd 16(%esp), %mm7
+
+/*
+ C eax src, incrementing ; 5B
+ C ecx loop counter, decrementing
+ C edx dst, incrementing
+ C
+ C mm4 carry, low 32-bits
+ C mm7 multiplier
+*/
+
+ movd (%eax), %mm2
+ pmuludq %mm7, %mm2
+
+ shrl $1, %ecx
+ jnc .Leven
+
+ leal 4(%eax), %eax
+ movd (%edx), %mm1
+ paddq %mm2, %mm1
+ paddq %mm1, %mm4
+ movd %mm4, (%edx)
+ psrlq $32, %mm4
+
+ testl %ecx, %ecx
+ jz .Lrtn
+ leal 4(%edx), %edx
+
+ movd (%eax), %mm2
+ pmuludq %mm7, %mm2
+.Leven:
+ movd 4(%eax), %mm0
+ movd (%edx), %mm1
+ pmuludq %mm7, %mm0
+
+ subl $1, %ecx
+ jz .Lend
+.Lloop:
+ paddq %mm2, %mm1
+ movd 8(%eax), %mm2
+ paddq %mm1, %mm4
+ movd 4(%edx), %mm3
+ pmuludq %mm7, %mm2
+ movd %mm4, (%edx)
+ psrlq $32, %mm4
+
+ paddq %mm0, %mm3
+ movd 12(%eax), %mm0
+ paddq %mm3, %mm4
+ movd 8(%edx), %mm1
+ pmuludq %mm7, %mm0
+ movd %mm4, 4(%edx)
+ psrlq $32, %mm4
+
+ leal 8(%eax), %eax
+ leal 8(%edx), %edx
+ subl $1, %ecx
+ jnz .Lloop
+.Lend:
+ paddq %mm2, %mm1
+ paddq %mm1, %mm4
+ movd 4(%edx), %mm3
+ movd %mm4, (%edx)
+ psrlq $32, %mm4
+ paddq %mm0, %mm3
+ paddq %mm3, %mm4
+ movd %mm4, 4(%edx)
+ psrlq $32, %mm4
+.Lrtn:
+ movd %mm4, %eax
+ emms
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul3.S b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul3.S
new file mode 100644
index 0000000..ebcd2a6
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-mul3.S
@@ -0,0 +1,127 @@
+/* Intel Pentium-4 mpn_submul_1 -- Multiply a limb vector with a limb and
+ * subtract the result from a second limb vector.
+ *
+ * Copyright 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_size_t s1_size, (sp + 12)
+ * mpi_limb_t s2_limb) (sp + 16)
+ *
+ * P4: 7 cycles/limb, unstable timing, at least on early Pentium4 silicon
+ * (stepping 10).
+ *
+ * This code is not particularly good at 7 c/l. The dependent chain is only
+ * 4 c/l and there's only 4 MMX unit instructions, so it's not clear why that
+ * speed isn't achieved.
+ *
+ * The arrangements made here to get a two instruction dependent chain are
+ * slightly subtle. In the loop the carry (or borrow rather) is a negative
+ * so that a paddq can be used to give a low limb ready to store, and a high
+ * limb ready to become the new carry after a psrlq.
+ *
+ * If the carry was a simple twos complement negative then the psrlq shift
+ * would need to bring in 0 bits or 1 bits according to whether the high was
+ * zero or non-zero, since a non-zero value would represent a negative
+ * needing sign extension. That wouldn't be particularly easy to arrange and
+ * certainly would add an instruction to the dependent chain, so instead an
+ * offset is applied so that the high limb will be 0xFFFFFFFF+c. With c in
+ * the range -0xFFFFFFFF to 0, the value 0xFFFFFFFF+c is in the range 0 to
+ * 0xFFFFFFFF and is therefore always positive and can always have 0 bits
+ * shifted in, which is what psrlq does.
+ *
+ * The extra 0xFFFFFFFF must be subtracted before c is used, but that can be
+ * done off the dependent chain. The total adjustment then is to add
+ * 0xFFFFFFFF00000000 to offset the new carry, and subtract
+ * 0x00000000FFFFFFFF to remove the offset from the current carry, for a net
+ * add of 0xFFFFFFFE00000001. In the code this is applied to the destination
+ * limb when fetched.
+ *
+ * It's also possible to view the 0xFFFFFFFF adjustment as a ones-complement
+ * negative, which is how it's undone for the return value, but that doesn't
+ * seem as clear.
+*/
+
+ TEXT
+ ALIGN (4)
+ GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1)
+C_SYMBOL_NAME(_gcry_mpih_submul_1:)
+
+ pxor %mm1, %mm1
+
+.Lstart_1c:
+ movl 8(%esp), %eax
+ pcmpeqd %mm0, %mm0
+
+ movd 16(%esp), %mm7
+ pcmpeqd %mm6, %mm6
+
+ movl 4(%esp), %edx
+ psrlq $32, %mm0
+
+ movl 12(%esp), %ecx
+ psllq $32, %mm6
+
+ psubq %mm0, %mm6
+
+ psubq %mm1, %mm0
+
+/*
+ C eax src, incrementing
+ C ebx
+ C ecx loop counter, decrementing
+ C edx dst, incrementing
+ C
+ C mm0 0xFFFFFFFF - borrow
+ C mm6 0xFFFFFFFE00000001
+ C mm7 multiplier
+*/
+
+.Lloop:
+ movd (%eax), %mm1
+ leal 4(%eax), %eax
+ movd (%edx), %mm2
+ paddq %mm6, %mm2
+ pmuludq %mm7, %mm1
+ psubq %mm1, %mm2
+ paddq %mm2, %mm0
+ subl $1, %ecx
+ movd %mm0, (%edx)
+ psrlq $32, %mm0
+ leal 4(%edx), %edx
+ jnz .Lloop
+
+ movd %mm0, %eax
+ notl %eax
+ emms
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-sub1.S b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-sub1.S
new file mode 100644
index 0000000..33900c7
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/pentium4/sse2/mpih-sub1.S
@@ -0,0 +1,112 @@
+/* Intel Pentium-4 mpn_sub_n -- mpn subtraction.
+ *
+ * Copyright 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (sp + 4)
+ * mpi_ptr_t s1_ptr, (sp + 8)
+ * mpi_ptr_t s2_ptr, (sp + 12)
+ * mpi_size_t size) (sp + 16)
+ *
+ * P4 Willamette, Northwood: 4.0 cycles/limb if dst!=src1 and dst!=src2
+ * 6.0 cycles/limb if dst==src1 or dst==src2
+ * P4 Prescott: >= 5 cycles/limb
+ *
+ * The main loop code is 2x unrolled so that the carry bit can alternate
+ * between mm0 and mm1.
+ */
+
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(_gcry_mpih_sub_n)
+C_SYMBOL_NAME(_gcry_mpih_sub_n:)
+
+ pxor %mm0, %mm0
+.Lstart_nc:
+ movl 8(%esp), %eax
+ movl %ebx, 8(%esp)
+ movl 12(%esp), %ebx
+ movl 4(%esp), %edx
+ movl 16(%esp), %ecx
+
+ leal (%eax,%ecx,4), %eax
+ leal (%ebx,%ecx,4), %ebx
+ leal (%edx,%ecx,4), %edx
+ negl %ecx
+
+.Ltop:
+/*
+ C eax src1 end
+ C ebx src2 end
+ C ecx counter, limbs, negative
+ C edx dst end
+ C mm0 carry bit
+*/
+
+ movd (%eax,%ecx,4), %mm1
+ movd (%ebx,%ecx,4), %mm2
+ psubq %mm2, %mm1
+
+ psubq %mm0, %mm1
+ movd %mm1, (%edx,%ecx,4)
+
+ psrlq $63, %mm1
+
+ addl $1, %ecx
+ jz .Ldone_mm1
+
+ movd (%eax,%ecx,4), %mm0
+ movd (%ebx,%ecx,4), %mm2
+ psubq %mm2, %mm0
+
+ psubq %mm1, %mm0
+ movd %mm0, (%edx,%ecx,4)
+
+ psrlq $63, %mm0
+
+ addl $1, %ecx
+ jnz .Ltop
+
+
+ movd %mm0, %eax
+ movl 8(%esp), %ebx
+ emms
+ ret
+
+
+
+.Ldone_mm1:
+ movd %mm1, %eax
+ movl 8(%esp), %ebx
+ emms
+ ret
diff --git a/grub-core/lib/libgcrypt/mpi/power/Manifest b/grub-core/lib/libgcrypt/mpi/power/Manifest
new file mode 100644
index 0000000..c60fc23
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/power/Manifest
@@ -0,0 +1,27 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-add1.S
+mpih-lshift.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-rshift.S
+mpih-sub1.S
+$names$ iQCVAwUAP+LmXTEAnp832S/7AQJ+ngP/XYr5Fvl/8WGVHcIKaehxvnKcSD2ILTWZNGubgnWp8ebIxVijjQCxYneTTy+zO0sNaB002neyscyiwaJj/JQIwZXfr06uGweIqlSpwpj9ndkoJc8E4/FZu+5NTO+E3RaBDAD+Tpo+MTfbC1s18p5i+an93VrSTgNck5PPYQrUcPA==sl3t
diff --git a/grub-core/lib/libgcrypt/mpi/power/distfiles b/grub-core/lib/libgcrypt/mpi/power/distfiles
new file mode 100644
index 0000000..e1bc008
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/power/distfiles
@@ -0,0 +1,8 @@
+Manifest
+mpih-add1.S
+mpih-lshift.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-rshift.S
+mpih-sub1.S
diff --git a/grub-core/lib/libgcrypt/mpi/power/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/power/mpih-add1.S
new file mode 100644
index 0000000..876b56c
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/power/mpih-add1.S
@@ -0,0 +1,87 @@
+/* IBM POWER add_n -- Add two limb vectors of equal, non-zero length.
+ *
+ * Copyright (C) 1992, 1994, 1996, 1999,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+/*
+# INPUT PARAMETERS
+# res_ptr r3
+# s1_ptr r4
+# s2_ptr r5
+# size r6
+ */
+
+ .toc
+ .extern _gcry_mpih_add_n[DS]
+ .extern ._gcry_mpih_add_n
+.csect [PR]
+ .align 2
+ .globl _gcry_mpih_add_n
+ .globl ._gcry_mpih_add_n
+ .csect _gcry_mpih_add_n[DS]
+_gcry_mpih_add_n:
+ .long ._gcry_mpih_add_n, TOC[tc0], 0
+ .csect [PR]
+._gcry_mpih_add_n:
+ andil. 10,6,1 # odd or even number of limbs?
+ l 8,0(4) # load least significant s1 limb
+ l 0,0(5) # load least significant s2 limb
+ cal 3,-4(3) # offset res_ptr, it's updated before it's used
+ sri 10,6,1 # count for unrolled loop
+ a 7,0,8 # add least significant limbs, set cy
+ mtctr 10 # copy count into CTR
+ beq 0,Leven # branch if even # of limbs (# of limbs >= 2)
+
+# We have an odd # of limbs. Add the first limbs separately.
+ cmpi 1,10,0 # is count for unrolled loop zero?
+ bne 1,L1 # branch if not
+ st 7,4(3)
+ aze 3,10 # use the fact that r10 is zero...
+ br # return
+
+# We added least significant limbs. Now reload the next limbs to enter loop.
+L1: lu 8,4(4) # load s1 limb and update s1_ptr
+ lu 0,4(5) # load s2 limb and update s2_ptr
+ stu 7,4(3)
+ ae 7,0,8 # add limbs, set cy
+Leven: lu 9,4(4) # load s1 limb and update s1_ptr
+ lu 10,4(5) # load s2 limb and update s2_ptr
+ bdz Lend # If done, skip loop
+
+Loop: lu 8,4(4) # load s1 limb and update s1_ptr
+ lu 0,4(5) # load s2 limb and update s2_ptr
+ ae 11,9,10 # add previous limbs with cy, set cy
+ stu 7,4(3) #
+ lu 9,4(4) # load s1 limb and update s1_ptr
+ lu 10,4(5) # load s2 limb and update s2_ptr
+ ae 7,0,8 # add previous limbs with cy, set cy
+ stu 11,4(3) #
+ bdn Loop # decrement CTR and loop back
+
+Lend: ae 11,9,10 # add limbs with cy, set cy
+ st 7,4(3) #
+ st 11,8(3) #
+ lil 3,0 # load cy into ...
+ aze 3,3 # ... return value register
+ br
+
diff --git a/grub-core/lib/libgcrypt/mpi/power/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/power/mpih-lshift.S
new file mode 100644
index 0000000..d9e42da
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/power/mpih-lshift.S
@@ -0,0 +1,64 @@
+/* IBM POWER lshift
+ *
+ * Copyright (C) 1992, 1994, 1999, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+/*
+# INPUT PARAMETERS
+# res_ptr r3
+# s_ptr r4
+# size r5
+# cnt r6
+ */
+
+ .toc
+ .extern _gcry_mpih_lshift[DS]
+ .extern ._gcry_mpih_lshift
+.csect [PR]
+ .align 2
+ .globl _gcry_mpih_lshift
+ .globl ._gcry_mpih_lshift
+ .csect _gcry_mpih_lshift[DS]
+_gcry_mpih_lshift:
+ .long ._gcry_mpih_lshift, TOC[tc0], 0
+ .csect [PR]
+._gcry_mpih_lshift:
+ sli 0,5,2
+ cax 9,3,0
+ cax 4,4,0
+ sfi 8,6,32
+ mtctr 5 # put limb count in CTR loop register
+ lu 0,-4(4) # read most significant limb
+ sre 3,0,8 # compute carry out limb, and init MQ register
+ bdz Lend2 # if just one limb, skip loop
+ lu 0,-4(4) # read 2:nd most significant limb
+ sreq 7,0,8 # compute most significant limb of result
+ bdz Lend # if just two limb, skip loop
+Loop: lu 0,-4(4) # load next lower limb
+ stu 7,-4(9) # store previous result during read latency
+ sreq 7,0,8 # compute result limb
+ bdn Loop # loop back until CTR is zero
+Lend: stu 7,-4(9) # store 2:nd least significant limb
+Lend2: sle 7,0,6 # compute least significant limb
+ st 7,-4(9) # store it
+ br
+
diff --git a/grub-core/lib/libgcrypt/mpi/power/mpih-mul1.S b/grub-core/lib/libgcrypt/mpi/power/mpih-mul1.S
new file mode 100644
index 0000000..35034fa
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/power/mpih-mul1.S
@@ -0,0 +1,115 @@
+/* IBM POWER mul_1 -- Multiply a limb vector with a limb and store
+ * the result in a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1999, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+/*
+# INPUT PARAMETERS
+# res_ptr r3
+# s1_ptr r4
+# size r5
+# s2_limb r6
+
+# The RS/6000 has no unsigned 32x32->64 bit multiplication instruction. To
+# obtain that operation, we have to use the 32x32->64 signed multiplication
+# instruction, and add the appropriate compensation to the high limb of the
+# result. We add the multiplicand if the multiplier has its most significant
+# bit set, and we add the multiplier if the multiplicand has its most
+# significant bit set. We need to preserve the carry flag between each
+# iteration, so we have to compute the compensation carefully (the natural,
+# srai+and doesn't work). Since the POWER architecture has a branch unit
+# we can branch in zero cycles, so that's how we perform the additions.
+ */
+
+ .toc
+ .csect ._gcry_mpih_mul_1[PR]
+ .align 2
+ .globl _gcry_mpih_mul_1
+ .globl ._gcry_mpih_mul_1
+ .csect _gcry_mpih_mul_1[DS]
+_gcry_mpih_mul_1:
+ .long ._gcry_mpih_mul_1[PR], TOC[tc0], 0
+ .csect ._gcry_mpih_mul_1[PR]
+._gcry_mpih_mul_1:
+
+ cal 3,-4(3)
+ l 0,0(4)
+ cmpi 0,6,0
+ mtctr 5
+ mul 9,0,6
+ srai 7,0,31
+ and 7,7,6
+ mfmq 8
+ ai 0,0,0 # reset carry
+ cax 9,9,7
+ blt Lneg
+Lpos: bdz Lend
+Lploop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ mfmq 0
+ ae 8,0,9
+ bge Lp0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Lp0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ mfmq 0
+ ae 8,0,10
+ bge Lp1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Lp1: bdn Lploop
+ b Lend
+
+Lneg: cax 9,9,0
+ bdz Lend
+Lnloop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ cax 10,10,0 # adjust high limb for negative s2_limb
+ mfmq 0
+ ae 8,0,9
+ bge Ln0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Ln0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ cax 9,9,0 # adjust high limb for negative s2_limb
+ mfmq 0
+ ae 8,0,10
+ bge Ln1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Ln1: bdn Lnloop
+ b Lend
+
+Lend0: cal 9,0(10)
+Lend: st 8,4(3)
+ aze 3,9
+ br
+
diff --git a/grub-core/lib/libgcrypt/mpi/power/mpih-mul2.S b/grub-core/lib/libgcrypt/mpi/power/mpih-mul2.S
new file mode 100644
index 0000000..d056e8f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/power/mpih-mul2.S
@@ -0,0 +1,130 @@
+/* IBM POWER addmul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1999, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+
+/*
+# INPUT PARAMETERS
+# res_ptr r3
+# s1_ptr r4
+# size r5
+# s2_limb r6
+
+# The RS/6000 has no unsigned 32x32->64 bit multiplication instruction. To
+# obtain that operation, we have to use the 32x32->64 signed multiplication
+# instruction, and add the appropriate compensation to the high limb of the
+# result. We add the multiplicand if the multiplier has its most significant
+# bit set, and we add the multiplier if the multiplicand has its most
+# significant bit set. We need to preserve the carry flag between each
+# iteration, so we have to compute the compensation carefully (the natural,
+# srai+and doesn't work). Since the POWER architecture has a branch unit
+# we can branch in zero cycles, so that's how we perform the additions.
+ */
+
+ .toc
+ .csect ._gcry_mpih_addmul_1[PR]
+ .align 2
+ .globl _gcry_mpih_addmul_1
+ .globl ._gcry_mpih_addmul_1
+ .csect _gcry_mpih_addmul_1[DS]
+_gcry_mpih_addmul_1:
+ .long ._gcry_mpih_addmul_1[PR], TOC[tc0], 0
+ .csect ._gcry_mpih_addmul_1[PR]
+._gcry_mpih_addmul_1:
+
+ cal 3,-4(3)
+ l 0,0(4)
+ cmpi 0,6,0
+ mtctr 5
+ mul 9,0,6
+ srai 7,0,31
+ and 7,7,6
+ mfmq 8
+ cax 9,9,7
+ l 7,4(3)
+ a 8,8,7 # add res_limb
+ blt Lneg
+Lpos: bdz Lend
+
+Lploop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ mfmq 0
+ ae 8,0,9 # low limb + old_cy_limb + old cy
+ l 7,4(3)
+ aze 10,10 # propagate cy to new cy_limb
+ a 8,8,7 # add res_limb
+ bge Lp0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Lp0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ mfmq 0
+ ae 8,0,10
+ l 7,4(3)
+ aze 9,9
+ a 8,8,7
+ bge Lp1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Lp1: bdn Lploop
+
+ b Lend
+
+Lneg: cax 9,9,0
+ bdz Lend
+Lnloop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ mfmq 7
+ ae 8,7,9
+ l 7,4(3)
+ ae 10,10,0 # propagate cy to new cy_limb
+ a 8,8,7 # add res_limb
+ bge Ln0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Ln0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ mfmq 7
+ ae 8,7,10
+ l 7,4(3)
+ ae 9,9,0 # propagate cy to new cy_limb
+ a 8,8,7 # add res_limb
+ bge Ln1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Ln1: bdn Lnloop
+ b Lend
+
+Lend0: cal 9,0(10)
+Lend: st 8,4(3)
+ aze 3,9
+ br
+
diff --git a/grub-core/lib/libgcrypt/mpi/power/mpih-mul3.S b/grub-core/lib/libgcrypt/mpi/power/mpih-mul3.S
new file mode 100644
index 0000000..8bc317b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/power/mpih-mul3.S
@@ -0,0 +1,135 @@
+/* IBM POWER submul_1 -- Multiply a limb vector with a limb and subtract
+ * the result from a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1999, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*
+
+# INPUT PARAMETERS
+# res_ptr r3
+# s1_ptr r4
+# size r5
+# s2_limb r6
+
+# The RS/6000 has no unsigned 32x32->64 bit multiplication instruction. To
+# obtain that operation, we have to use the 32x32->64 signed multiplication
+# instruction, and add the appropriate compensation to the high limb of the
+# result. We add the multiplicand if the multiplier has its most significant
+# bit set, and we add the multiplier if the multiplicand has its most
+# significant bit set. We need to preserve the carry flag between each
+# iteration, so we have to compute the compensation carefully (the natural,
+# srai+and doesn't work). Since the POWER architecture has a branch unit
+# we can branch in zero cycles, so that's how we perform the additions.
+ */
+
+ .toc
+ .csect ._gcry_mpih_submul_1[PR]
+ .align 2
+ .globl _gcry_mpih_submul_1
+ .globl ._gcry_mpih_submul_1
+ .csect _gcry_mpih_submul_1[DS]
+_gcry_mpih_submul_1:
+ .long ._gcry_mpih_submul_1[PR], TOC[tc0], 0
+ .csect ._gcry_mpih_submul_1[PR]
+._gcry_mpih_submul_1:
+
+ cal 3,-4(3)
+ l 0,0(4)
+ cmpi 0,6,0
+ mtctr 5
+ mul 9,0,6
+ srai 7,0,31
+ and 7,7,6
+ mfmq 11
+ cax 9,9,7
+ l 7,4(3)
+ sf 8,11,7 # add res_limb
+ a 11,8,11 # invert cy (r11 is junk)
+ blt Lneg
+Lpos: bdz Lend
+
+Lploop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ mfmq 0
+ ae 11,0,9 # low limb + old_cy_limb + old cy
+ l 7,4(3)
+ aze 10,10 # propagate cy to new cy_limb
+ sf 8,11,7 # add res_limb
+ a 11,8,11 # invert cy (r11 is junk)
+ bge Lp0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Lp0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ mfmq 0
+ ae 11,0,10
+ l 7,4(3)
+ aze 9,9
+ sf 8,11,7
+ a 11,8,11 # invert cy (r11 is junk)
+ bge Lp1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Lp1: bdn Lploop
+
+ b Lend
+
+Lneg: cax 9,9,0
+ bdz Lend
+Lnloop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ mfmq 7
+ ae 11,7,9
+ l 7,4(3)
+ ae 10,10,0 # propagate cy to new cy_limb
+ sf 8,11,7 # add res_limb
+ a 11,8,11 # invert cy (r11 is junk)
+ bge Ln0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Ln0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ mfmq 7
+ ae 11,7,10
+ l 7,4(3)
+ ae 9,9,0 # propagate cy to new cy_limb
+ sf 8,11,7 # add res_limb
+ a 11,8,11 # invert cy (r11 is junk)
+ bge Ln1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Ln1: bdn Lnloop
+ b Lend
+
+Lend0: cal 9,0(10)
+Lend: st 8,4(3)
+ aze 3,9
+ br
+
diff --git a/grub-core/lib/libgcrypt/mpi/power/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/power/mpih-rshift.S
new file mode 100644
index 0000000..f131a86
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/power/mpih-rshift.S
@@ -0,0 +1,64 @@
+/* IBM POWER rshift
+ *
+ * Copyright (C) 1992, 1994, 1999, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/*
+# INPUT PARAMETERS
+# res_ptr r3
+# s_ptr r4
+# size r5
+# cnt r6
+*/
+
+ .toc
+ .extern _gcry_mpih_rshift[DS]
+ .extern ._gcry_mpih_rshift
+.csect [PR]
+ .align 2
+ .globl _gcry_mpih_rshift
+ .globl ._gcry_mpih_rshift
+ .csect _gcry_mpih_rshift[DS]
+_gcry_mpih_rshift:
+ .long ._gcry_mpih_rshift, TOC[tc0], 0
+ .csect [PR]
+._gcry_mpih_rshift:
+ sfi 8,6,32
+ mtctr 5 # put limb count in CTR loop register
+ l 0,0(4) # read least significant limb
+ ai 9,3,-4 # adjust res_ptr since it's offset in the stu:s
+ sle 3,0,8 # compute carry limb, and init MQ register
+ bdz Lend2 # if just one limb, skip loop
+ lu 0,4(4) # read 2:nd least significant limb
+ sleq 7,0,8 # compute least significant limb of result
+ bdz Lend # if just two limb, skip loop
+Loop: lu 0,4(4) # load next higher limb
+ stu 7,4(9) # store previous result during read latency
+ sleq 7,0,8 # compute result limb
+ bdn Loop # loop back until CTR is zero
+Lend: stu 7,4(9) # store 2:nd most significant limb
+Lend2: sre 7,0,6 # compute most significant limb
+ st 7,4(9) # store it
+ br
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/power/mpih-sub1.S b/grub-core/lib/libgcrypt/mpi/power/mpih-sub1.S
new file mode 100644
index 0000000..02748fc
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/power/mpih-sub1.S
@@ -0,0 +1,88 @@
+/* IBM POWER sub_n -- Subtract two limb vectors of equal, non-zero length.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1996, 1999,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+/*
+# INPUT PARAMETERS
+# res_ptr r3
+# s1_ptr r4
+# s2_ptr r5
+# size r6
+ */
+
+ .toc
+ .extern _gcry_mpih_sub_n[DS]
+ .extern ._gcry_mpih_sub_n
+.csect [PR]
+ .align 2
+ .globl _gcry_mpih_sub_n
+ .globl ._gcry_mpih_sub_n
+ .csect _gcry_mpih_sub_n[DS]
+_gcry_mpih_sub_n:
+ .long ._gcry_mpih_sub_n, TOC[tc0], 0
+ .csect [PR]
+._gcry_mpih_sub_n:
+ andil. 10,6,1 # odd or even number of limbs?
+ l 8,0(4) # load least significant s1 limb
+ l 0,0(5) # load least significant s2 limb
+ cal 3,-4(3) # offset res_ptr, it's updated before it's used
+ sri 10,6,1 # count for unrolled loop
+ sf 7,0,8 # subtract least significant limbs, set cy
+ mtctr 10 # copy count into CTR
+ beq 0,Leven # branch if even # of limbs (# of limbs >= 2)
+
+# We have an odd # of limbs. Add the first limbs separately.
+ cmpi 1,10,0 # is count for unrolled loop zero?
+ bne 1,L1 # branch if not
+ st 7,4(3)
+ sfe 3,0,0 # load !cy into ...
+ sfi 3,3,0 # ... return value register
+ br # return
+
+# We added least significant limbs. Now reload the next limbs to enter loop.
+L1: lu 8,4(4) # load s1 limb and update s1_ptr
+ lu 0,4(5) # load s2 limb and update s2_ptr
+ stu 7,4(3)
+ sfe 7,0,8 # subtract limbs, set cy
+Leven: lu 9,4(4) # load s1 limb and update s1_ptr
+ lu 10,4(5) # load s2 limb and update s2_ptr
+ bdz Lend # If done, skip loop
+
+Loop: lu 8,4(4) # load s1 limb and update s1_ptr
+ lu 0,4(5) # load s2 limb and update s2_ptr
+ sfe 11,10,9 # subtract previous limbs with cy, set cy
+ stu 7,4(3) #
+ lu 9,4(4) # load s1 limb and update s1_ptr
+ lu 10,4(5) # load s2 limb and update s2_ptr
+ sfe 7,0,8 # subtract previous limbs with cy, set cy
+ stu 11,4(3) #
+ bdn Loop # decrement CTR and loop back
+
+Lend: sfe 11,10,9 # subtract limbs with cy, set cy
+ st 7,4(3) #
+ st 11,8(3) #
+ sfe 3,0,0 # load !cy into ...
+ sfi 3,3,0 # ... return value register
+ br
+
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc32/Manifest b/grub-core/lib/libgcrypt/mpi/powerpc32/Manifest
new file mode 100644
index 0000000..26ab6ea
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc32/Manifest
@@ -0,0 +1,28 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-add1.S
+mpih-sub1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-lshift.S
+mpih-rshift.S
+syntax.h
+$names$ iQCVAwUAP+LmYzEAnp832S/7AQI/cQP+Mcg9rF/c/bJTY48PE1/ARt7vCMtpIlv9alZSSSrU3WHzCtv9nVczFmwHU3DdKFawigY2DljQcK92dZ5ZlOfpFNMz4PKlVMWaKDk+jKlqm2dxvlHuqEvXPpjFAE2gHrhq5qLXS5ZHeMLJIEK84GYC6fjfLUMdZU3altXTUBvoXhA==Yax+
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc32/distfiles b/grub-core/lib/libgcrypt/mpi/powerpc32/distfiles
new file mode 100644
index 0000000..a086614
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc32/distfiles
@@ -0,0 +1,10 @@
+Manifest
+mpih-add1.S
+mpih-sub1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-lshift.S
+mpih-rshift.S
+syntax.h
+
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-add1.S
new file mode 100644
index 0000000..1661f5e
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-add1.S
@@ -0,0 +1,136 @@
+/* PowerPC-32 add_n -- Add two limb vectors of equal, non-zero length.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (r3)
+ * mpi_ptr_t s1_ptr, (r4)
+ * mpi_ptr_t s2_ptr, (r5)
+ * mpi_size_t size) (r6)
+ */
+
+ .toc
+ .extern _gcry_mpih_add_n[DS]
+ .extern ._gcry_mpih_add_n
+.csect [PR]
+ .align 2
+ .globl _gcry_mpih_add_n
+ .globl ._gcry_mpih_add_n
+ .csect _gcry_mpih_add_n[DS]
+_gcry_mpih_add_n:
+ .long ._gcry_mpih_add_n, TOC[tc0], 0
+ .csect [PR]
+._gcry_mpih_add_n:
+ mtctr 6 # copy size into CTR
+ lwz 8,0(4) # load least significant s1 limb
+ lwz 0,0(5) # load least significant s2 limb
+ addi 3,3,-4 # offset res_ptr, it is updated before used
+ addc 7,0,8 # add least significant limbs, set cy
+ bdz Lend # If done, skip loop
+Loop: lwzu 8,4(4) # load s1 limb and update s1_ptr
+ lwzu 0,4(5) # load s2 limb and update s2_ptr
+ stwu 7,4(3) # store previous limb in load latency slot
+ adde 7,0,8 # add new limbs with cy, set cy
+ bdnz Loop # decrement CTR and loop back
+Lend: stw 7,4(3) # store ultimate result limb
+ li 3,0 # load cy into ...
+ addze 3,3 # ... return value register
+ blr
+
+#else
+/* Add two limb vectors of equal, non-zero length for PowerPC.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/* mp_limb_t mpn_add_n (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_srcptr s2_ptr,
+ mp_size_t size)
+ Calculate s1+s2 and put result in res_ptr; return carry, 0 or 1. */
+
+/* Note on optimisation: This code is optimal for the 601. Almost every other
+ possible 2-unrolled inner loop will not be. Also, watch out for the
+ alignment... */
+
+EALIGN(_gcry_mpih_add_n,3,0)
+/* Set up for loop below. */
+ mtcrf 0x01,%r6
+ srwi. %r7,%r6,1
+ li %r10,0
+ mtctr %r7
+ bt 31,2f
+
+/* Clear the carry. */
+ addic %r0,%r0,0
+/* Adjust pointers for loop. */
+ addi %r3,%r3,-4
+ addi %r4,%r4,-4
+ addi %r5,%r5,-4
+ b 0f
+
+2: lwz %r7,0(%r5)
+ lwz %r6,0(%r4)
+ addc %r6,%r6,%r7
+ stw %r6,0(%r3)
+ beq 1f
+
+/* The loop. */
+
+/* Align start of loop to an odd word boundary to guarantee that the
+ last two words can be fetched in one access (for 601). */
+0: lwz %r9,4(%r4)
+ lwz %r8,4(%r5)
+ lwzu %r6,8(%r4)
+ lwzu %r7,8(%r5)
+ adde %r8,%r9,%r8
+ stw %r8,4(%r3)
+ adde %r6,%r6,%r7
+ stwu %r6,8(%r3)
+ bdnz 0b
+/* Return the carry. */
+1: addze %r3,%r10
+ blr
+END(_gcry_mpih_add_n)
+#endif
+
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-lshift.S
new file mode 100644
index 0000000..6231095
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-lshift.S
@@ -0,0 +1,198 @@
+/* PowerPC-32 lshift
+ *
+ * Copyright (C) 1995, 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp, (r3)
+ * mpi_ptr_t up, (r4)
+ * mpi_size_t usize, (r5)
+ * unsigned cnt) (r6)
+ */
+
+ .toc
+.csect .text[PR]
+ .align 2
+ .globl _gcry_mpih_lshift
+ .globl ._gcry_mpih_lshift
+ .csect _gcry_mpih_lshift[DS]
+_gcry_mpih_lshift:
+ .long ._gcry_mpih_lshift, TOC[tc0], 0
+ .csect .text[PR]
+._gcry_mpih_lshift:
+ mtctr 5 # copy size into CTR
+ slwi 0,5,2
+ add 7,3,0 # make r7 point at end of res
+ add 4,4,0 # make r4 point at end of s1
+ subfic 8,6,32
+ lwzu 11,-4(4) # load first s1 limb
+ srw 3,11,8 # compute function return value
+ bdz Lend1
+
+Loop: lwzu 10,-4(4)
+ slw 9,11,6
+ srw 12,10,8
+ or 9,9,12
+ stwu 9,-4(7)
+ bdz Lend2
+ lwzu 11,-4(4)
+ slw 9,10,6
+ srw 12,11,8
+ or 9,9,12
+ stwu 9,-4(7)
+ bdnz Loop
+
+Lend1: slw 0,11,6
+ stw 0,-4(7)
+ blr
+
+Lend2: slw 0,10,6
+ stw 0,-4(7)
+ blr
+
+#else
+/* Shift a limb left, low level routine.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* mp_limb_t mpn_lshift (mp_ptr wp, mp_srcptr up, mp_size_t usize,
+ unsigned int cnt) */
+
+EALIGN(_gcry_mpih_lshift,3,0)
+ mtctr %r5 # copy size into CTR
+ cmplwi %cr0,%r5,16 # is size < 16
+ slwi %r0,%r5,2
+ add %r7,%r3,%r0 # make r7 point at end of res
+ add %r4,%r4,%r0 # make r4 point at end of s1
+ lwzu %r11,-4(%r4) # load first s1 limb
+ subfic %r8,%r6,32
+ srw %r3,%r11,%r8 # compute function return value
+ bge %cr0,L(big) # branch if size >= 16
+
+ bdz L(end1)
+
+0: lwzu %r10,-4(%r4)
+ slw %r9,%r11,%r6
+ srw %r12,%r10,%r8
+ or %r9,%r9,%r12
+ stwu %r9,-4(%r7)
+ bdz L(end2)
+ lwzu %r11,-4(%r4)
+ slw %r9,%r10,%r6
+ srw %r12,%r11,%r8
+ or %r9,%r9,%r12
+ stwu %r9,-4(%r7)
+ bdnz 0b
+
+L(end1):slw %r0,%r11,%r6
+ stw %r0,-4(%r7)
+ blr
+
+
+/* Guaranteed not to succeed. */
+L(boom): tweq %r0,%r0
+
+/* We imitate a case statement, by using (yuk!) fixed-length code chunks,
+ of size 4*12 bytes. We have to do this (or something) to make this PIC. */
+L(big): mflr %r9
+ bltl- %cr0,L(boom) # Never taken, only used to set LR.
+ slwi %r10,%r6,4
+ mflr %r12
+ add %r10,%r12,%r10
+ slwi %r8,%r6,5
+ add %r10,%r8,%r10
+ mtctr %r10
+ addi %r5,%r5,-1
+ mtlr %r9
+ bctr
+
+L(end2):slw %r0,%r10,%r6
+ stw %r0,-4(%r7)
+ blr
+
+#define DO_LSHIFT(n) \
+ mtctr %r5; \
+0: lwzu %r10,-4(%r4); \
+ slwi %r9,%r11,n; \
+ inslwi %r9,%r10,n,32-n; \
+ stwu %r9,-4(%r7); \
+ bdz- L(end2); \
+ lwzu %r11,-4(%r4); \
+ slwi %r9,%r10,n; \
+ inslwi %r9,%r11,n,32-n; \
+ stwu %r9,-4(%r7); \
+ bdnz 0b; \
+ b L(end1)
+
+ DO_LSHIFT(1)
+ DO_LSHIFT(2)
+ DO_LSHIFT(3)
+ DO_LSHIFT(4)
+ DO_LSHIFT(5)
+ DO_LSHIFT(6)
+ DO_LSHIFT(7)
+ DO_LSHIFT(8)
+ DO_LSHIFT(9)
+ DO_LSHIFT(10)
+ DO_LSHIFT(11)
+ DO_LSHIFT(12)
+ DO_LSHIFT(13)
+ DO_LSHIFT(14)
+ DO_LSHIFT(15)
+ DO_LSHIFT(16)
+ DO_LSHIFT(17)
+ DO_LSHIFT(18)
+ DO_LSHIFT(19)
+ DO_LSHIFT(20)
+ DO_LSHIFT(21)
+ DO_LSHIFT(22)
+ DO_LSHIFT(23)
+ DO_LSHIFT(24)
+ DO_LSHIFT(25)
+ DO_LSHIFT(26)
+ DO_LSHIFT(27)
+ DO_LSHIFT(28)
+ DO_LSHIFT(29)
+ DO_LSHIFT(30)
+ DO_LSHIFT(31)
+
+END(_gcry_mpih_lshift)
+#endif
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul1.S b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul1.S
new file mode 100644
index 0000000..bd418f7
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul1.S
@@ -0,0 +1,120 @@
+/* PowerPC-32 mul_1 -- Multiply a limb vector with a limb and store
+ * the result in a second limb vector.
+ *
+ * Copyright (C) 1992, 1993, 1994, 1995,
+ * 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (r3)
+ * mpi_ptr_t s1_ptr, (r4)
+ * mpi_size_t s1_size, (r5)
+ * mpi_limb_t s2_limb) (r6)
+ *
+ * This is a fairly straightforward implementation. The timing of the PC601
+ * is hard to understand, so I will wait to optimize this until I have some
+ * hardware to play with.
+ *
+ * The code trivially generalizes to 64 bit limbs for the PC620.
+ */
+
+ .toc
+ .csect ._gcry_mpih_mul_1[PR]
+ .align 2
+ .globl _gcry_mpih_mul_1
+ .globl ._gcry_mpih_mul_1
+ .csect _gcry_mpih_mul_1[DS]
+_gcry_mpih_mul_1:
+ .long ._gcry_mpih_mul_1[PR], TOC[tc0], 0
+ .csect ._gcry_mpih_mul_1[PR]
+._gcry_mpih_mul_1:
+ mtctr 5
+
+ lwz 0,0(4)
+ mullw 7,0,6
+ mulhwu 10,0,6
+ addi 3,3,-4 # adjust res_ptr
+ addic 5,5,0 # clear cy with dummy insn
+ bdz Lend
+
+Loop: lwzu 0,4(4)
+ stwu 7,4(3)
+ mullw 8,0,6
+ adde 7,8,10
+ mulhwu 10,0,6
+ bdnz Loop
+
+Lend: stw 7,4(3)
+ addze 3,10
+ blr
+
+#else
+/* Multiply a limb vector by a limb, for PowerPC.
+ Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+
+/* mp_limb_t mpn_mul_1 (mp_ptr res_ptr, mp_srcptr s1_ptr,
+ mp_size_t s1_size, mp_limb_t s2_limb)
+ Calculate s1*s2 and put result in res_ptr; return carry. */
+
+ENTRY(_gcry_mpih_mul_1)
+ mtctr %r5
+
+ lwz %r0,0(%r4)
+ mullw %r7,%r0,%r6
+ mulhwu %r10,%r0,%r6
+ addi %r3,%r3,-4 # adjust res_ptr
+ addic %r5,%r5,0 # clear cy with dummy insn
+ bdz 1f
+
+0: lwzu %r0,4(%r4)
+ stwu %r7,4(%r3)
+ mullw %r8,%r0,%r6
+ adde %r7,%r8,%r10
+ mulhwu %r10,%r0,%r6
+ bdnz 0b
+
+1: stw %r7,4(%r3)
+ addze %r3,%r10
+ blr
+END(_gcry_mpih_mul_1)
+#endif
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul2.S b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul2.S
new file mode 100644
index 0000000..1d97b81
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul2.S
@@ -0,0 +1,127 @@
+/* PowerPC-32 addmul_1 -- Multiply a limb vector with a limb and add
+ * the result to a second limb vector.
+ *
+ * Copyright (C) 1995, 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (r3)
+ * mpi_ptr_t s1_ptr, (r4)
+ * mpi_size_t s1_size, (r5)
+ * mpi_limb_t s2_limb) (r6)
+ *
+ * This is a fairly straightforward implementation. The timing of the PC601
+ * is hard to understand, so I will wait to optimize this until I have some
+ * hardware to play with.
+ *
+ * The code trivially generalizes to 64 bit limbs for the PC620.
+ */
+
+
+ .toc
+ .csect ._gcry_mpih_addmul_1[PR]
+ .align 2
+ .globl _gcry_mpih_addmul_1
+ .globl ._gcry_mpih_addmul_1
+ .csect _gcry_mpih_addmul_1[DS]
+_gcry_mpih_addmul_1:
+ .long ._gcry_mpih_addmul_1[PR], TOC[tc0], 0
+ .csect ._gcry_mpih_addmul_1[PR]
+._gcry_mpih_addmul_1:
+ mtctr 5
+
+ lwz 0,0(4)
+ mullw 7,0,6
+ mulhwu 10,0,6
+ lwz 9,0(3)
+ addc 8,7,9
+ addi 3,3,-4
+ bdz Lend
+
+Loop: lwzu 0,4(4)
+ stwu 8,4(3)
+ mullw 8,0,6
+ adde 7,8,10
+ mulhwu 10,0,6
+ lwz 9,4(3)
+ addze 10,10
+ addc 8,7,9
+ bdnz Loop
+
+Lend: stw 8,4(3)
+ addze 3,10
+ blr
+
+#else
+/* Multiply a limb vector by a single limb, for PowerPC.
+ Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+
+/* mp_limb_t mpn_addmul_1 (mp_ptr res_ptr, mp_srcptr s1_ptr,
+ mp_size_t s1_size, mp_limb_t s2_limb)
+ Calculate res+s1*s2 and put result back in res; return carry. */
+ENTRY(_gcry_mpih_addmul_1)
+ mtctr %r5
+
+ lwz %r0,0(%r4)
+ mullw %r7,%r0,%r6
+ mulhwu %r10,%r0,%r6
+ lwz %r9,0(%r3)
+ addc %r8,%r7,%r9
+ addi %r3,%r3,-4 /* adjust res_ptr */
+ bdz 1f
+
+0: lwzu %r0,4(%r4)
+ stwu %r8,4(%r3)
+ mullw %r8,%r0,%r6
+ adde %r7,%r8,%r10
+ mulhwu %r10,%r0,%r6
+ lwz %r9,4(%r3)
+ addze %r10,%r10
+ addc %r8,%r7,%r9
+ bdnz 0b
+
+1: stw %r8,4(%r3)
+ addze %r3,%r10
+ blr
+END(_gcry_mpih_addmul_1)
+#endif
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul3.S b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul3.S
new file mode 100644
index 0000000..c410dbb
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-mul3.S
@@ -0,0 +1,130 @@
+/* PowerPC-32 submul_1 -- Multiply a limb vector with a limb and subtract
+ * the result from a second limb vector.
+ *
+ * Copyright (C) 1995, 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (r3)
+ * mpi_ptr_t s1_ptr, (r4)
+ * mpi_size_t s1_size, (r5)
+ * mpi_limb_t s2_limb) (r6)
+ *
+ * This is a fairly straightforward implementation. The timing of the PC601
+ * is hard to understand, so I will wait to optimize this until I have some
+ * hardware to play with.
+ *
+ * The code trivially generalizes to 64 bit limbs for the PC620.
+ */
+
+ .toc
+ .csect ._gcry_mpih_submul_1[PR]
+ .align 2
+ .globl _gcry_mpih_submul_1
+ .globl ._gcry_mpih_submul_1
+ .csect _gcry_mpih_submul_1[DS]
+_gcry_mpih_submul_1:
+ .long ._gcry_mpih_submul_1[PR], TOC[tc0], 0
+ .csect ._gcry_mpih_submul_1[PR]
+._gcry_mpih_submul_1:
+ mtctr 5
+
+ lwz 0,0(4)
+ mullw 7,0,6
+ mulhwu 10,0,6
+ lwz 9,0(3)
+ subfc 8,7,9
+ addc 7,7,8 # invert cy (r7 is junk)
+ addi 3,3,-4
+ bdz Lend
+
+Loop: lwzu 0,4(4)
+ stwu 8,4(3)
+ mullw 8,0,6
+ adde 7,8,10
+ mulhwu 10,0,6
+ lwz 9,4(3)
+ addze 10,10
+ subfc 8,7,9
+ addc 7,7,8 # invert cy (r7 is junk)
+ bdnz Loop
+
+Lend: stw 8,4(3)
+ addze 3,10
+ blr
+
+#else
+/* Multiply a limb vector by a single limb, for PowerPC.
+ Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* mp_limb_t mpn_submul_1 (mp_ptr res_ptr, mp_srcptr s1_ptr,
+ mp_size_t s1_size, mp_limb_t s2_limb)
+ Calculate res-s1*s2 and put result back in res; return carry. */
+
+ENTRY(_gcry_mpih_submul_1)
+ mtctr %r5
+
+ lwz %r0,0(%r4)
+ mullw %r7,%r0,%r6
+ mulhwu %r10,%r0,%r6
+ lwz %r9,0(%r3)
+ subf %r8,%r7,%r9
+ addc %r7,%r7,%r8 # invert cy (r7 is junk)
+ addi %r3,%r3,-4 # adjust res_ptr
+ bdz 1f
+
+0: lwzu %r0,4(%r4)
+ stwu %r8,4(%r3)
+ mullw %r8,%r0,%r6
+ adde %r7,%r8,%r10
+ mulhwu %r10,%r0,%r6
+ lwz %r9,4(%r3)
+ addze %r10,%r10
+ subf %r8,%r7,%r9
+ addc %r7,%r7,%r8 # invert cy (r7 is junk)
+ bdnz 0b
+
+1: stw %r8,4(%r3)
+ addze %r3,%r10
+ blr
+END(_gcry_mpih_submul_1)
+#endif
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-rshift.S
new file mode 100644
index 0000000..98349ed
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-rshift.S
@@ -0,0 +1,131 @@
+/* PowerPC-32 rshift
+ *
+ * Copyright (C) 1995, 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp, (r3)
+ * mpi_ptr_t up, (r4)
+ * mpi_size_t usize, (r5)
+ * unsigned cnt) (r6)
+ */
+
+ .toc
+.csect .text[PR]
+ .align 2
+ .globl _gcry_mpih_rshift
+ .globl ._gcry_mpih_rshift
+ .csect _gcry_mpih_rshift[DS]
+_gcry_mpih_rshift:
+ .long ._gcry_mpih_rshift, TOC[tc0], 0
+ .csect .text[PR]
+._gcry_mpih_rshift:
+ mtctr 5 # copy size into CTR
+ addi 7,3,-4 # move adjusted res_ptr to free return reg
+ subfic 8,6,32
+ lwz 11,0(4) # load first s1 limb
+ slw 3,11,8 # compute function return value
+ bdz Lend1
+
+Loop: lwzu 10,4(4)
+ srw 9,11,6
+ slw 12,10,8
+ or 9,9,12
+ stwu 9,4(7)
+ bdz Lend2
+ lwzu 11,4(4)
+ srw 9,10,6
+ slw 12,11,8
+ or 9,9,12
+ stwu 9,4(7)
+ bdnz Loop
+
+Lend1: srw 0,11,6
+ stw 0,4(7)
+ blr
+
+Lend2: srw 0,10,6
+ stw 0,4(7)
+ blr
+
+#else
+/* Shift a limb right, low level routine.
+ Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+
+/* INPUT PARAMETERS
+ res_ptr r3
+ s1_ptr r4
+ size r5
+ cnt r6 */
+
+ENTRY(_gcry_mpih_rshift)
+ mtctr 5 # copy size into CTR
+ addi 7,3,-4 # move adjusted res_ptr to free return reg
+ subfic 8,6,32
+ lwz 11,0(4) # load first s1 limb
+ slw 3,11,8 # compute function return value
+ bdz 1f
+
+0: lwzu 10,4(4)
+ srw 9,11,6
+ slw 12,10,8
+ or 9,9,12
+ stwu 9,4(7)
+ bdz 2f
+ lwzu 11,4(4)
+ srw 9,10,6
+ slw 12,11,8
+ or 9,9,12
+ stwu 9,4(7)
+ bdnz 0b
+
+1: srw 0,11,6
+ stw 0,4(7)
+ blr
+
+2: srw 0,10,6
+ stw 0,4(7)
+ blr
+END(_gcry_mpih_rshift)
+#endif
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-sub1.S b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-sub1.S
new file mode 100644
index 0000000..d612ea8
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc32/mpih-sub1.S
@@ -0,0 +1,133 @@
+/* PowerPC-32 sub_n -- Subtract two limb vectors of the same length > 0
+ * and store difference in a third limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (r3)
+ * mpi_ptr_t s1_ptr, (r4)
+ * mpi_ptr_t s2_ptr, (r5)
+ * mpi_size_t size) (r6)
+ */
+
+ .toc
+ .extern _gcry_mpih_sub_n[DS]
+ .extern ._gcry_mpih_sub_n
+.csect [PR]
+ .align 2
+ .globl _gcry_mpih_sub_n
+ .globl ._gcry_mpih_sub_n
+ .csect _gcry_mpih_sub_n[DS]
+_gcry_mpih_sub_n:
+ .long ._gcry_mpih_sub_n, TOC[tc0], 0
+ .csect [PR]
+._gcry_mpih_sub_n:
+ mtctr 6 # copy size into CTR
+ lwz 8,0(4) # load least significant s1 limb
+ lwz 0,0(5) # load least significant s2 limb
+ addi 3,3,-4 # offset res_ptr, it is updated before used
+ subfc 7,0,8 # add least significant limbs, set cy
+ bdz Lend # If done, skip loop
+Loop: lwzu 8,4(4) # load s1 limb and update s1_ptr
+ lwzu 0,4(5) # load s2 limb and update s2_ptr
+ stwu 7,4(3) # store previous limb in load latency slot
+ subfe 7,0,8 # add new limbs with cy, set cy
+ bdnz Loop # decrement CTR and loop back
+Lend: stw 7,4(3) # store ultimate result limb
+ subfe 3,0,0 # load !cy into ...
+ subfic 3,3,0 # ... return value register
+ blr
+
+#else
+/* Subtract two limb vectors of equal, non-zero length for PowerPC.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* mp_limb_t mpn_sub_n (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_srcptr s2_ptr,
+ mp_size_t size)
+ Calculate s1-s2 and put result in res_ptr; return borrow, 0 or 1. */
+
+/* Note on optimisation: This code is optimal for the 601. Almost every other
+ possible 2-unrolled inner loop will not be. Also, watch out for the
+ alignment... */
+
+EALIGN(_gcry_mpih_sub_n,3,1)
+/* Set up for loop below. */
+ mtcrf 0x01,%r6
+ srwi. %r7,%r6,1
+ mtctr %r7
+ bt 31,2f
+
+/* Set the carry (clear the borrow). */
+ subfc %r0,%r0,%r0
+/* Adjust pointers for loop. */
+ addi %r3,%r3,-4
+ addi %r4,%r4,-4
+ addi %r5,%r5,-4
+ b 0f
+
+2: lwz %r7,0(%r5)
+ lwz %r6,0(%r4)
+ subfc %r6,%r7,%r6
+ stw %r6,0(%r3)
+ beq 1f
+
+/* Align start of loop to an odd word boundary to guarantee that the
+ last two words can be fetched in one access (for 601). This turns
+ out to be important. */
+0:
+ lwz %r9,4(%r4)
+ lwz %r8,4(%r5)
+ lwzu %r6,8(%r4)
+ lwzu %r7,8(%r5)
+ subfe %r8,%r8,%r9
+ stw %r8,4(%r3)
+ subfe %r6,%r7,%r6
+ stwu %r6,8(%r3)
+ bdnz 0b
+/* Return the borrow. */
+1: subfe %r3,%r3,%r3
+ neg %r3,%r3
+ blr
+END(_gcry_mpih_sub_n)
+#endif
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc32/syntax.h b/grub-core/lib/libgcrypt/mpi/powerpc32/syntax.h
new file mode 100644
index 0000000..5d4af9f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc32/syntax.h
@@ -0,0 +1,75 @@
+/* gmp2-2.0.2-ppc/mpn/powerpc-linux/syntax.h Tue Oct 6 19:27:01 1998 */
+/* From glibc's sysdeps/unix/sysv/linux/powerpc/sysdep.h */
+
+/* Copyright (C) 1992, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+
+#define USE_PPC_PATCHES 1
+
+/* This seems to always be the case on PPC. */
+#define ALIGNARG(log2) log2
+/* For ELF we need the `.type' directive to make shared libs work right. */
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+#define ASM_GLOBAL_DIRECTIVE .globl
+
+#ifdef __STDC__
+#define C_LABEL(name) C_SYMBOL_NAME(name)##:
+#else
+#define C_LABEL(name) C_SYMBOL_NAME(name)/**/:
+#endif
+
+#ifdef __STDC__
+#define L(body) .L##body
+#else
+#define L(body) .L/**/body
+#endif
+
+/* No profiling of gmp's assembly for now... */
+#define CALL_MCOUNT /* no profiling */
+
+#define ENTRY(name) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(2); \
+ C_LABEL(name) \
+ CALL_MCOUNT
+
+#define EALIGN_W_0 /* No words to insert. */
+#define EALIGN_W_1 nop
+#define EALIGN_W_2 nop;nop
+#define EALIGN_W_3 nop;nop;nop
+#define EALIGN_W_4 EALIGN_W_3;nop
+#define EALIGN_W_5 EALIGN_W_4;nop
+#define EALIGN_W_6 EALIGN_W_5;nop
+#define EALIGN_W_7 EALIGN_W_6;nop
+
+/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
+ past a 2^align boundary. */
+#define EALIGN(name, alignt, words) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(alignt); \
+ EALIGN_W_##words; \
+ C_LABEL(name)
+
+#undef END
+#define END(name) \
+ ASM_SIZE_DIRECTIVE(name)
+
diff --git a/grub-core/lib/libgcrypt/mpi/powerpc64/distfiles b/grub-core/lib/libgcrypt/mpi/powerpc64/distfiles
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/powerpc64/distfiles
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32/Manifest b/grub-core/lib/libgcrypt/mpi/sparc32/Manifest
new file mode 100644
index 0000000..d279229
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32/Manifest
@@ -0,0 +1,24 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-lshift.S
+mpih-rshift.S
+mpih-add1.S
+udiv.S
+$names$ iQCVAwUAP+LmaDEAnp832S/7AQISHgP/Z5orU+CPKBeRFCogSQDm4p7J2VpDovU6mtfMTdjhqWuZG0U6y8WqH0aj3USfziOhtc8YjQHQ+97g3+EnIWZgLjKacWC6pScY/QbATEpF1D0Wrcea5rk3qR1t7isdBVVOrxedZ5vuj5Op2zx/0OlPI+wt6fTtW88BdG/a6w/ZU/8==Py6h
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32/distfiles b/grub-core/lib/libgcrypt/mpi/sparc32/distfiles
new file mode 100644
index 0000000..a20f18e
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32/distfiles
@@ -0,0 +1,6 @@
+Manifest
+mpih-lshift.S
+mpih-rshift.S
+mpih-add1.S
+udiv.S
+
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32/mpih-add1.S b/grub-core/lib/libgcrypt/mpi/sparc32/mpih-add1.S
new file mode 100644
index 0000000..61a80ca
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32/mpih-add1.S
@@ -0,0 +1,239 @@
+/* SPARC _add_n -- Add two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright (C) 1995, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr,
+ * mpi_ptr_t s1_ptr,
+ * mpi_ptr_t s2_ptr,
+ * mpi_size_t size)
+ */
+
+! INPUT PARAMETERS
+#define res_ptr %o0
+#define s1_ptr %o1
+#define s2_ptr %o2
+#define size %o3
+
+#include "sysdep.h"
+
+ .text
+ .align 4
+ .global C_SYMBOL_NAME(_gcry_mpih_add_n)
+C_SYMBOL_NAME(_gcry_mpih_add_n):
+ xor s2_ptr,res_ptr,%g1
+ andcc %g1,4,%g0
+ bne L1 ! branch if alignment differs
+ nop
+! ** V1a **
+L0: andcc res_ptr,4,%g0 ! res_ptr unaligned? Side effect: cy=0
+ be L_v1 ! if no, branch
+ nop
+/* Add least significant limb separately to align res_ptr and s2_ptr */
+ ld [s1_ptr],%g4
+ add s1_ptr,4,s1_ptr
+ ld [s2_ptr],%g2
+ add s2_ptr,4,s2_ptr
+ add size,-1,size
+ addcc %g4,%g2,%o4
+ st %o4,[res_ptr]
+ add res_ptr,4,res_ptr
+L_v1: addx %g0,%g0,%o4 ! save cy in register
+ cmp size,2 ! if size < 2 ...
+ bl Lend2 ! ... branch to tail code
+ subcc %g0,%o4,%g0 ! restore cy
+
+ ld [s1_ptr+0],%g4
+ addcc size,-10,size
+ ld [s1_ptr+4],%g1
+ ldd [s2_ptr+0],%g2
+ blt Lfin1
+ subcc %g0,%o4,%g0 ! restore cy
+/* Add blocks of 8 limbs until less than 8 limbs remain */
+Loop1: addxcc %g4,%g2,%o4
+ ld [s1_ptr+8],%g4
+ addxcc %g1,%g3,%o5
+ ld [s1_ptr+12],%g1
+ ldd [s2_ptr+8],%g2
+ std %o4,[res_ptr+0]
+ addxcc %g4,%g2,%o4
+ ld [s1_ptr+16],%g4
+ addxcc %g1,%g3,%o5
+ ld [s1_ptr+20],%g1
+ ldd [s2_ptr+16],%g2
+ std %o4,[res_ptr+8]
+ addxcc %g4,%g2,%o4
+ ld [s1_ptr+24],%g4
+ addxcc %g1,%g3,%o5
+ ld [s1_ptr+28],%g1
+ ldd [s2_ptr+24],%g2
+ std %o4,[res_ptr+16]
+ addxcc %g4,%g2,%o4
+ ld [s1_ptr+32],%g4
+ addxcc %g1,%g3,%o5
+ ld [s1_ptr+36],%g1
+ ldd [s2_ptr+32],%g2
+ std %o4,[res_ptr+24]
+ addx %g0,%g0,%o4 ! save cy in register
+ addcc size,-8,size
+ add s1_ptr,32,s1_ptr
+ add s2_ptr,32,s2_ptr
+ add res_ptr,32,res_ptr
+ bge Loop1
+ subcc %g0,%o4,%g0 ! restore cy
+
+Lfin1: addcc size,8-2,size
+ blt Lend1
+ subcc %g0,%o4,%g0 ! restore cy
+/* Add blocks of 2 limbs until less than 2 limbs remain */
+Loope1: addxcc %g4,%g2,%o4
+ ld [s1_ptr+8],%g4
+ addxcc %g1,%g3,%o5
+ ld [s1_ptr+12],%g1
+ ldd [s2_ptr+8],%g2
+ std %o4,[res_ptr+0]
+ addx %g0,%g0,%o4 ! save cy in register
+ addcc size,-2,size
+ add s1_ptr,8,s1_ptr
+ add s2_ptr,8,s2_ptr
+ add res_ptr,8,res_ptr
+ bge Loope1
+ subcc %g0,%o4,%g0 ! restore cy
+Lend1: addxcc %g4,%g2,%o4
+ addxcc %g1,%g3,%o5
+ std %o4,[res_ptr+0]
+ addx %g0,%g0,%o4 ! save cy in register
+
+ andcc size,1,%g0
+ be Lret1
+ subcc %g0,%o4,%g0 ! restore cy
+/* Add last limb */
+ ld [s1_ptr+8],%g4
+ ld [s2_ptr+8],%g2
+ addxcc %g4,%g2,%o4
+ st %o4,[res_ptr+8]
+
+Lret1: retl
+ addx %g0,%g0,%o0 ! return carry-out from most sign. limb
+
+L1: xor s1_ptr,res_ptr,%g1
+ andcc %g1,4,%g0
+ bne L2
+ nop
+! ** V1b **
+ mov s2_ptr,%g1
+ mov s1_ptr,s2_ptr
+ b L0
+ mov %g1,s1_ptr
+
+! ** V2 **
+/* If we come here, the alignment of s1_ptr and res_ptr as well as the
+ alignment of s2_ptr and res_ptr differ. Since there are only two ways
+ things can be aligned (that we care about) we now know that the alignment
+ of s1_ptr and s2_ptr are the same. */
+
+L2: cmp size,1
+ be Ljone
+ nop
+ andcc s1_ptr,4,%g0 ! s1_ptr unaligned? Side effect: cy=0
+ be L_v2 ! if no, branch
+ nop
+/* Add least significant limb separately to align s1_ptr and s2_ptr */
+ ld [s1_ptr],%g4
+ add s1_ptr,4,s1_ptr
+ ld [s2_ptr],%g2
+ add s2_ptr,4,s2_ptr
+ add size,-1,size
+ addcc %g4,%g2,%o4
+ st %o4,[res_ptr]
+ add res_ptr,4,res_ptr
+
+L_v2: addx %g0,%g0,%o4 ! save cy in register
+ addcc size,-8,size
+ blt Lfin2
+ subcc %g0,%o4,%g0 ! restore cy
+/* Add blocks of 8 limbs until less than 8 limbs remain */
+Loop2: ldd [s1_ptr+0],%g2
+ ldd [s2_ptr+0],%o4
+ addxcc %g2,%o4,%g2
+ st %g2,[res_ptr+0]
+ addxcc %g3,%o5,%g3
+ st %g3,[res_ptr+4]
+ ldd [s1_ptr+8],%g2
+ ldd [s2_ptr+8],%o4
+ addxcc %g2,%o4,%g2
+ st %g2,[res_ptr+8]
+ addxcc %g3,%o5,%g3
+ st %g3,[res_ptr+12]
+ ldd [s1_ptr+16],%g2
+ ldd [s2_ptr+16],%o4
+ addxcc %g2,%o4,%g2
+ st %g2,[res_ptr+16]
+ addxcc %g3,%o5,%g3
+ st %g3,[res_ptr+20]
+ ldd [s1_ptr+24],%g2
+ ldd [s2_ptr+24],%o4
+ addxcc %g2,%o4,%g2
+ st %g2,[res_ptr+24]
+ addxcc %g3,%o5,%g3
+ st %g3,[res_ptr+28]
+ addx %g0,%g0,%o4 ! save cy in register
+ addcc size,-8,size
+ add s1_ptr,32,s1_ptr
+ add s2_ptr,32,s2_ptr
+ add res_ptr,32,res_ptr
+ bge Loop2
+ subcc %g0,%o4,%g0 ! restore cy
+
+Lfin2: addcc size,8-2,size
+ blt Lend2
+ subcc %g0,%o4,%g0 ! restore cy
+Loope2: ldd [s1_ptr+0],%g2
+ ldd [s2_ptr+0],%o4
+ addxcc %g2,%o4,%g2
+ st %g2,[res_ptr+0]
+ addxcc %g3,%o5,%g3
+ st %g3,[res_ptr+4]
+ addx %g0,%g0,%o4 ! save cy in register
+ addcc size,-2,size
+ add s1_ptr,8,s1_ptr
+ add s2_ptr,8,s2_ptr
+ add res_ptr,8,res_ptr
+ bge Loope2
+ subcc %g0,%o4,%g0 ! restore cy
+Lend2: andcc size,1,%g0
+ be Lret2
+ subcc %g0,%o4,%g0 ! restore cy
+/* Add last limb */
+Ljone: ld [s1_ptr],%g4
+ ld [s2_ptr],%g2
+ addxcc %g4,%g2,%o4
+ st %o4,[res_ptr]
+
+Lret2: retl
+ addx %g0,%g0,%o0 ! return carry-out from most sign. limb
+
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32/mpih-lshift.S b/grub-core/lib/libgcrypt/mpi/sparc32/mpih-lshift.S
new file mode 100644
index 0000000..3422ab0
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32/mpih-lshift.S
@@ -0,0 +1,97 @@
+/* sparc lshift
+ *
+ * Copyright (C) 1995, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+! INPUT PARAMETERS
+! res_ptr %o0
+! src_ptr %o1
+! size %o2
+! cnt %o3
+
+#include "sysdep.h"
+
+ .text
+ .align 4
+ .global C_SYMBOL_NAME(_gcry_mpih_lshift)
+C_SYMBOL_NAME(_gcry_mpih_lshift):
+ sll %o2,2,%g1
+ add %o1,%g1,%o1 ! make %o1 point at end of src
+ ld [%o1-4],%g2 ! load first limb
+ sub %g0,%o3,%o5 ! negate shift count
+ add %o0,%g1,%o0 ! make %o0 point at end of res
+ add %o2,-1,%o2
+ andcc %o2,4-1,%g4 ! number of limbs in first loop
+ srl %g2,%o5,%g1 ! compute function result
+ be L0 ! if multiple of 4 limbs, skip first loop
+ st %g1,[%sp+80]
+
+ sub %o2,%g4,%o2 ! adjust count for main loop
+
+Loop0: ld [%o1-8],%g3
+ add %o0,-4,%o0
+ add %o1,-4,%o1
+ addcc %g4,-1,%g4
+ sll %g2,%o3,%o4
+ srl %g3,%o5,%g1
+ mov %g3,%g2
+ or %o4,%g1,%o4
+ bne Loop0
+ st %o4,[%o0+0]
+
+L0: tst %o2
+ be Lend
+ nop
+
+Loop: ld [%o1-8],%g3
+ add %o0,-16,%o0
+ addcc %o2,-4,%o2
+ sll %g2,%o3,%o4
+ srl %g3,%o5,%g1
+
+ ld [%o1-12],%g2
+ sll %g3,%o3,%g4
+ or %o4,%g1,%o4
+ st %o4,[%o0+12]
+ srl %g2,%o5,%g1
+
+ ld [%o1-16],%g3
+ sll %g2,%o3,%o4
+ or %g4,%g1,%g4
+ st %g4,[%o0+8]
+ srl %g3,%o5,%g1
+
+ ld [%o1-20],%g2
+ sll %g3,%o3,%g4
+ or %o4,%g1,%o4
+ st %o4,[%o0+4]
+ srl %g2,%o5,%g1
+
+ add %o1,-16,%o1
+ or %g4,%g1,%g4
+ bne Loop
+ st %g4,[%o0+0]
+
+Lend: sll %g2,%o3,%g2
+ st %g2,[%o0-4]
+ retl
+ ld [%sp+80],%o0
+
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32/mpih-rshift.S b/grub-core/lib/libgcrypt/mpi/sparc32/mpih-rshift.S
new file mode 100644
index 0000000..cd3db41
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32/mpih-rshift.S
@@ -0,0 +1,93 @@
+/* sparc rshift
+ *
+ * Copyright (C) 1995, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+! INPUT PARAMETERS
+! res_ptr %o0
+! src_ptr %o1
+! size %o2
+! cnt %o3
+
+#include "sysdep.h"
+
+ .text
+ .align 4
+ .global C_SYMBOL_NAME(_gcry_mpih_rshift)
+C_SYMBOL_NAME(_gcry_mpih_rshift):
+ ld [%o1],%g2 ! load first limb
+ sub %g0,%o3,%o5 ! negate shift count
+ add %o2,-1,%o2
+ andcc %o2,4-1,%g4 ! number of limbs in first loop
+ sll %g2,%o5,%g1 ! compute function result
+ be L0 ! if multiple of 4 limbs, skip first loop
+ st %g1,[%sp+80]
+
+ sub %o2,%g4,%o2 ! adjust count for main loop
+
+Loop0: ld [%o1+4],%g3
+ add %o0,4,%o0
+ add %o1,4,%o1
+ addcc %g4,-1,%g4
+ srl %g2,%o3,%o4
+ sll %g3,%o5,%g1
+ mov %g3,%g2
+ or %o4,%g1,%o4
+ bne Loop0
+ st %o4,[%o0-4]
+
+L0: tst %o2
+ be Lend
+ nop
+
+Loop: ld [%o1+4],%g3
+ add %o0,16,%o0
+ addcc %o2,-4,%o2
+ srl %g2,%o3,%o4
+ sll %g3,%o5,%g1
+
+ ld [%o1+8],%g2
+ srl %g3,%o3,%g4
+ or %o4,%g1,%o4
+ st %o4,[%o0-16]
+ sll %g2,%o5,%g1
+
+ ld [%o1+12],%g3
+ srl %g2,%o3,%o4
+ or %g4,%g1,%g4
+ st %g4,[%o0-12]
+ sll %g3,%o5,%g1
+
+ ld [%o1+16],%g2
+ srl %g3,%o3,%g4
+ or %o4,%g1,%o4
+ st %o4,[%o0-8]
+ sll %g2,%o5,%g1
+
+ add %o1,16,%o1
+ or %g4,%g1,%g4
+ bne Loop
+ st %g4,[%o0-4]
+
+Lend: srl %g2,%o3,%g2
+ st %g2,[%o0-0]
+ retl
+ ld [%sp+80],%o0
+
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32/udiv.S b/grub-core/lib/libgcrypt/mpi/sparc32/udiv.S
new file mode 100644
index 0000000..006b5c1
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32/udiv.S
@@ -0,0 +1,195 @@
+/* SPARC v7 __udiv_qrnnd division support, used from longlong.h.
+ * This is for v7 CPUs without a floating-point unit.
+ *
+ * Copyright (C) 1993, 1994, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+! INPUT PARAMETERS
+! rem_ptr o0
+! n1 o1
+! n0 o2
+! d o3
+
+#include "sysdep.h"
+
+ .text
+ .align 4
+ .global C_SYMBOL_NAME(__udiv_qrnnd)
+C_SYMBOL_NAME(__udiv_qrnnd):
+ tst %o3
+ bneg Largedivisor
+ mov 8,%g1
+
+ b Lp1
+ addxcc %o2,%o2,%o2
+
+Lplop: bcc Ln1
+ addxcc %o2,%o2,%o2
+Lp1: addx %o1,%o1,%o1
+ subcc %o1,%o3,%o4
+ bcc Ln2
+ addxcc %o2,%o2,%o2
+Lp2: addx %o1,%o1,%o1
+ subcc %o1,%o3,%o4
+ bcc Ln3
+ addxcc %o2,%o2,%o2
+Lp3: addx %o1,%o1,%o1
+ subcc %o1,%o3,%o4
+ bcc Ln4
+ addxcc %o2,%o2,%o2
+Lp4: addx %o1,%o1,%o1
+ addcc %g1,-1,%g1
+ bne Lplop
+ subcc %o1,%o3,%o4
+ bcc Ln5
+ addxcc %o2,%o2,%o2
+Lp5: st %o1,[%o0]
+ retl
+ xnor %g0,%o2,%o0
+
+Lnlop: bcc Lp1
+ addxcc %o2,%o2,%o2
+Ln1: addx %o4,%o4,%o4
+ subcc %o4,%o3,%o1
+ bcc Lp2
+ addxcc %o2,%o2,%o2
+Ln2: addx %o4,%o4,%o4
+ subcc %o4,%o3,%o1
+ bcc Lp3
+ addxcc %o2,%o2,%o2
+Ln3: addx %o4,%o4,%o4
+ subcc %o4,%o3,%o1
+ bcc Lp4
+ addxcc %o2,%o2,%o2
+Ln4: addx %o4,%o4,%o4
+ addcc %g1,-1,%g1
+ bne Lnlop
+ subcc %o4,%o3,%o1
+ bcc Lp5
+ addxcc %o2,%o2,%o2
+Ln5: st %o4,[%o0]
+ retl
+ xnor %g0,%o2,%o0
+
+Largedivisor:
+ and %o2,1,%o5 ! %o5 = n0 & 1
+
+ srl %o2,1,%o2
+ sll %o1,31,%g2
+ or %g2,%o2,%o2 ! %o2 = lo(n1n0 >> 1)
+ srl %o1,1,%o1 ! %o1 = hi(n1n0 >> 1)
+
+ and %o3,1,%g2
+ srl %o3,1,%g3 ! %g3 = floor(d / 2)
+ add %g3,%g2,%g3 ! %g3 = ceil(d / 2)
+
+ b LLp1
+ addxcc %o2,%o2,%o2
+
+LLplop: bcc LLn1
+ addxcc %o2,%o2,%o2
+LLp1: addx %o1,%o1,%o1
+ subcc %o1,%g3,%o4
+ bcc LLn2
+ addxcc %o2,%o2,%o2
+LLp2: addx %o1,%o1,%o1
+ subcc %o1,%g3,%o4
+ bcc LLn3
+ addxcc %o2,%o2,%o2
+LLp3: addx %o1,%o1,%o1
+ subcc %o1,%g3,%o4
+ bcc LLn4
+ addxcc %o2,%o2,%o2
+LLp4: addx %o1,%o1,%o1
+ addcc %g1,-1,%g1
+ bne LLplop
+ subcc %o1,%g3,%o4
+ bcc LLn5
+ addxcc %o2,%o2,%o2
+LLp5: add %o1,%o1,%o1 ! << 1
+ tst %g2
+ bne Oddp
+ add %o5,%o1,%o1
+ st %o1,[%o0]
+ retl
+ xnor %g0,%o2,%o0
+
+LLnlop: bcc LLp1
+ addxcc %o2,%o2,%o2
+LLn1: addx %o4,%o4,%o4
+ subcc %o4,%g3,%o1
+ bcc LLp2
+ addxcc %o2,%o2,%o2
+LLn2: addx %o4,%o4,%o4
+ subcc %o4,%g3,%o1
+ bcc LLp3
+ addxcc %o2,%o2,%o2
+LLn3: addx %o4,%o4,%o4
+ subcc %o4,%g3,%o1
+ bcc LLp4
+ addxcc %o2,%o2,%o2
+LLn4: addx %o4,%o4,%o4
+ addcc %g1,-1,%g1
+ bne LLnlop
+ subcc %o4,%g3,%o1
+ bcc LLp5
+ addxcc %o2,%o2,%o2
+LLn5: add %o4,%o4,%o4 ! << 1
+ tst %g2
+ bne Oddn
+ add %o5,%o4,%o4
+ st %o4,[%o0]
+ retl
+ xnor %g0,%o2,%o0
+
+Oddp: xnor %g0,%o2,%o2
+ ! q' in %o2. r' in %o1
+ addcc %o1,%o2,%o1
+ bcc LLp6
+ addx %o2,0,%o2
+ sub %o1,%o3,%o1
+LLp6: subcc %o1,%o3,%g0
+ bcs LLp7
+ subx %o2,-1,%o2
+ sub %o1,%o3,%o1
+LLp7: st %o1,[%o0]
+ retl
+ mov %o2,%o0
+
+Oddn: xnor %g0,%o2,%o2
+ ! q' in %o2. r' in %o4
+ addcc %o4,%o2,%o4
+ bcc LLn6
+ addx %o2,0,%o2
+ sub %o4,%o3,%o4
+LLn6: subcc %o4,%o3,%g0
+ bcs LLn7
+ subx %o2,-1,%o2
+ sub %o4,%o3,%o4
+LLn7: st %o4,[%o0]
+ retl
+ mov %o2,%o0
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32v8/Manifest b/grub-core/lib/libgcrypt/mpi/sparc32v8/Manifest
new file mode 100644
index 0000000..dc1ce6a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32v8/Manifest
@@ -0,0 +1,23 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+$names$ iQCVAwUAP+LmbjEAnp832S/7AQKQ2gQAotpCpY9rOJUCdZHbDLXXB9i1UUMraRKbVWimtKq493Y2d2wcqXCK2WaGs1AePK3K6Qk6msxZ0PL5Ho7KgHMkzsZ+wG0EUziiuX0yZRTWNm0r3TYerP6SdWH5GOVdSXn7ckkppk2sVOokfQTy+Tmrnah3+dlYJoujan+fmXWN6Us==DolM
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32v8/distfiles b/grub-core/lib/libgcrypt/mpi/sparc32v8/distfiles
new file mode 100644
index 0000000..6e9a530
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32v8/distfiles
@@ -0,0 +1,5 @@
+Manifest
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul1.S b/grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul1.S
new file mode 100644
index 0000000..03fcdda
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul1.S
@@ -0,0 +1,109 @@
+/* SPARC v8 __mpn_mul_1 -- Multiply a limb vector with a single limb and
+ * store the product in a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+
+! INPUT PARAMETERS
+! res_ptr o0
+! s1_ptr o1
+! size o2
+! s2_limb o3
+
+#include "sysdep.h"
+
+.text
+ .align 8
+ .global C_SYMBOL_NAME(_gcry_mpih_mul_1)
+C_SYMBOL_NAME(_gcry_mpih_mul_1):
+ sll %o2,4,%g1
+ and %g1,(4-1)<<4,%g1
+#if PIC
+ mov %o7,%g4 ! Save return address register
+ call 1f
+ add %o7,LL-1f,%g3
+1: mov %g4,%o7 ! Restore return address register
+#else
+ sethi %hi(LL),%g3
+ or %g3,%lo(LL),%g3
+#endif
+ jmp %g3+%g1
+ ld [%o1+0],%o4 ! 1
+LL:
+LL00: add %o0,-4,%o0
+ add %o1,-4,%o1
+ b Loop00 /* 4, 8, 12, ... */
+ orcc %g0,%g0,%g2
+LL01: b Loop01 /* 1, 5, 9, ... */
+ orcc %g0,%g0,%g2
+ nop
+ nop
+LL10: add %o0,-12,%o0 /* 2, 6, 10, ... */
+ add %o1,4,%o1
+ b Loop10
+ orcc %g0,%g0,%g2
+ nop
+LL11: add %o0,-8,%o0 /* 3, 7, 11, ... */
+ add %o1,-8,%o1
+ b Loop11
+ orcc %g0,%g0,%g2
+
+Loop: addcc %g3,%g2,%g3 ! 1
+ ld [%o1+4],%o4 ! 2
+ st %g3,[%o0+0] ! 1
+ rd %y,%g2 ! 1
+Loop00: umul %o4,%o3,%g3 ! 2
+ addxcc %g3,%g2,%g3 ! 2
+ ld [%o1+8],%o4 ! 3
+ st %g3,[%o0+4] ! 2
+ rd %y,%g2 ! 2
+Loop11: umul %o4,%o3,%g3 ! 3
+ addxcc %g3,%g2,%g3 ! 3
+ ld [%o1+12],%o4 ! 4
+ add %o1,16,%o1
+ st %g3,[%o0+8] ! 3
+ rd %y,%g2 ! 3
+Loop10: umul %o4,%o3,%g3 ! 4
+ addxcc %g3,%g2,%g3 ! 4
+ ld [%o1+0],%o4 ! 1
+ st %g3,[%o0+12] ! 4
+ add %o0,16,%o0
+ rd %y,%g2 ! 4
+ addx %g0,%g2,%g2
+Loop01: addcc %o2,-4,%o2
+ bg Loop
+ umul %o4,%o3,%g3 ! 1
+
+ addcc %g3,%g2,%g3 ! 4
+ st %g3,[%o0+0] ! 4
+ rd %y,%g2 ! 4
+
+ retl
+ addx %g0,%g2,%o0
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul2.S b/grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul2.S
new file mode 100644
index 0000000..6f5cc43
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul2.S
@@ -0,0 +1,132 @@
+/* SPARC v8 __mpn_addmul_1 -- Multiply a limb vector with a limb and
+ * add the result to a second limb vector.
+ *
+ * Copyright (C) 1992, 1993, 1994, 1995, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+
+! INPUT PARAMETERS
+! res_ptr o0
+! s1_ptr o1
+! size o2
+! s2_limb o3
+
+#include "sysdep.h"
+
+.text
+ .align 4
+ .global C_SYMBOL_NAME(_gcry_mpih_addmul_1)
+C_SYMBOL_NAME(_gcry_mpih_addmul_1):
+ orcc %g0,%g0,%g2
+ ld [%o1+0],%o4 ! 1
+
+ sll %o2,4,%g1
+ and %g1,(4-1)<<4,%g1
+#if PIC
+ mov %o7,%g4 ! Save return address register
+ call 1f
+ add %o7,LL-1f,%g3
+1: mov %g4,%o7 ! Restore return address register
+#else
+ sethi %hi(LL),%g3
+ or %g3,%lo(LL),%g3
+#endif
+ jmp %g3+%g1
+ nop
+LL:
+LL00: add %o0,-4,%o0
+ b Loop00 /* 4, 8, 12, ... */
+ add %o1,-4,%o1
+ nop
+LL01: b Loop01 /* 1, 5, 9, ... */
+ nop
+ nop
+ nop
+LL10: add %o0,-12,%o0 /* 2, 6, 10, ... */
+ b Loop10
+ add %o1,4,%o1
+ nop
+LL11: add %o0,-8,%o0 /* 3, 7, 11, ... */
+ b Loop11
+ add %o1,-8,%o1
+ nop
+
+1: addcc %g3,%g2,%g3 ! 1
+ ld [%o1+4],%o4 ! 2
+ rd %y,%g2 ! 1
+ addx %g0,%g2,%g2
+ ld [%o0+0],%g1 ! 2
+ addcc %g1,%g3,%g3
+ st %g3,[%o0+0] ! 1
+Loop00: umul %o4,%o3,%g3 ! 2
+ ld [%o0+4],%g1 ! 2
+ addxcc %g3,%g2,%g3 ! 2
+ ld [%o1+8],%o4 ! 3
+ rd %y,%g2 ! 2
+ addx %g0,%g2,%g2
+ nop
+ addcc %g1,%g3,%g3
+ st %g3,[%o0+4] ! 2
+Loop11: umul %o4,%o3,%g3 ! 3
+ addxcc %g3,%g2,%g3 ! 3
+ ld [%o1+12],%o4 ! 4
+ rd %y,%g2 ! 3
+ add %o1,16,%o1
+ addx %g0,%g2,%g2
+ ld [%o0+8],%g1 ! 2
+ addcc %g1,%g3,%g3
+ st %g3,[%o0+8] ! 3
+Loop10: umul %o4,%o3,%g3 ! 4
+ addxcc %g3,%g2,%g3 ! 4
+ ld [%o1+0],%o4 ! 1
+ rd %y,%g2 ! 4
+ addx %g0,%g2,%g2
+ ld [%o0+12],%g1 ! 2
+ addcc %g1,%g3,%g3
+ st %g3,[%o0+12] ! 4
+ add %o0,16,%o0
+ addx %g0,%g2,%g2
+Loop01: addcc %o2,-4,%o2
+ bg 1b
+ umul %o4,%o3,%g3 ! 1
+
+ addcc %g3,%g2,%g3 ! 4
+ rd %y,%g2 ! 4
+ addx %g0,%g2,%g2
+ ld [%o0+0],%g1 ! 2
+ addcc %g1,%g3,%g3
+ st %g3,[%o0+0] ! 4
+ addx %g0,%g2,%o0
+
+ retl
+ nop
+
+
+! umul, ld, addxcc, rd, st
+
+! umul, ld, addxcc, rd, ld, addcc, st, addx
+
diff --git a/grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul3.S b/grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul3.S
new file mode 100644
index 0000000..93bb194
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/sparc32v8/mpih-mul3.S
@@ -0,0 +1,67 @@
+/* SPARC v8 __mpn_submul_1 -- Multiply a limb vector with a limb and
+ * subtract the result from a second limb vector.
+ *
+ * Copyright (C) 1992, 1993, 1994, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+! INPUT PARAMETERS
+! res_ptr o0
+! s1_ptr o1
+! size o2
+! s2_limb o3
+
+#include "sysdep.h"
+
+.text
+ .align 4
+ .global C_SYMBOL_NAME(_gcry_mpih_submul_1)
+C_SYMBOL_NAME(_gcry_mpih_submul_1):
+ sub %g0,%o2,%o2 ! negate ...
+ sll %o2,2,%o2 ! ... and scale size
+ sub %o1,%o2,%o1 ! o1 is offset s1_ptr
+ sub %o0,%o2,%g1 ! g1 is offset res_ptr
+
+ mov 0,%o0 ! clear cy_limb
+
+Loop: ld [%o1+%o2],%o4
+ ld [%g1+%o2],%g2
+ umul %o4,%o3,%o5
+ rd %y,%g3
+ addcc %o5,%o0,%o5
+ addx %g3,0,%o0
+ subcc %g2,%o5,%g2
+ addx %o0,0,%o0
+ st %g2,[%g1+%o2]
+
+ addcc %o2,4,%o2
+ bne Loop
+ nop
+
+ retl
+ nop
+
+
diff --git a/grub-core/lib/libgcrypt/mpi/supersparc/Manifest b/grub-core/lib/libgcrypt/mpi/supersparc/Manifest
new file mode 100644
index 0000000..869b97b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/supersparc/Manifest
@@ -0,0 +1,21 @@
+# Manifest - checksums
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+udiv.S
+$names$ iQCVAwUAP+LmdjEAnp832S/7AQIrUgQA3YmurZhK7r20DqRvg0gwNe9jMDcFfUY4ZPhW5HkGzMbmrxXtj5Dx50RIPteum72bXE+IhcngljQb/cskiN5Hi9oc2a2CPhyTqVFEeGyF+kJ170GI1pVfFOfzbVG0F4nEwm5lGHgv/nvFsvrjmmAXVW1v/yk5N35wbiLviOFrLOQ==byFc
diff --git a/grub-core/lib/libgcrypt/mpi/supersparc/distfiles b/grub-core/lib/libgcrypt/mpi/supersparc/distfiles
new file mode 100644
index 0000000..ef7c0a5
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/supersparc/distfiles
@@ -0,0 +1,3 @@
+Manifest
+udiv.S
+
diff --git a/grub-core/lib/libgcrypt/mpi/supersparc/udiv.S b/grub-core/lib/libgcrypt/mpi/supersparc/udiv.S
new file mode 100644
index 0000000..79e506a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/mpi/supersparc/udiv.S
@@ -0,0 +1,118 @@
+/* SuperSPARC __udiv_qrnnd division support, used from longlong.h.
+ * This is for SuperSPARC only, to compensate for its
+ * semi-functional udiv instruction.
+ *
+ * Copyright (C) 1993, 1994, 1996, 1998,
+ * 2001, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+
+
+! INPUT PARAMETERS
+! rem_ptr i0
+! n1 i1
+! n0 i2
+! d i3
+
+#include "sysdep.h"
+#undef ret /* Kludge for glibc */
+
+ .text
+ .align 8
+LC0: .double 0r4294967296
+LC1: .double 0r2147483648
+
+ .align 4
+ .global C_SYMBOL_NAME(__udiv_qrnnd)
+C_SYMBOL_NAME(__udiv_qrnnd):
+ !#PROLOGUE# 0
+ save %sp,-104,%sp
+ !#PROLOGUE# 1
+ st %i1,[%fp-8]
+ ld [%fp-8],%f10
+ sethi %hi(LC0),%o7
+ fitod %f10,%f4
+ ldd [%o7+%lo(LC0)],%f8
+ cmp %i1,0
+ bge L248
+ mov %i0,%i5
+ faddd %f4,%f8,%f4
+L248:
+ st %i2,[%fp-8]
+ ld [%fp-8],%f10
+ fmuld %f4,%f8,%f6
+ cmp %i2,0
+ bge L249
+ fitod %f10,%f2
+ faddd %f2,%f8,%f2
+L249:
+ st %i3,[%fp-8]
+ faddd %f6,%f2,%f2
+ ld [%fp-8],%f10
+ cmp %i3,0
+ bge L250
+ fitod %f10,%f4
+ faddd %f4,%f8,%f4
+L250:
+ fdivd %f2,%f4,%f2
+ sethi %hi(LC1),%o7
+ ldd [%o7+%lo(LC1)],%f4
+ fcmped %f2,%f4
+ nop
+ fbge,a L251
+ fsubd %f2,%f4,%f2
+ fdtoi %f2,%f2
+ st %f2,[%fp-8]
+ b L252
+ ld [%fp-8],%i4
+L251:
+ fdtoi %f2,%f2
+ st %f2,[%fp-8]
+ ld [%fp-8],%i4
+ sethi %hi(-2147483648),%g2
+ xor %i4,%g2,%i4
+L252:
+ umul %i3,%i4,%g3
+ rd %y,%i0
+ subcc %i2,%g3,%o7
+ subxcc %i1,%i0,%g0
+ be L253
+ cmp %o7,%i3
+
+ add %i4,-1,%i0
+ add %o7,%i3,%o7
+ st %o7,[%i5]
+ ret
+ restore
+L253:
+ blu L246
+ mov %i4,%i0
+ add %i4,1,%i0
+ sub %o7,%i3,%o7
+L246:
+ st %o7,[%i5]
+ ret
+ restore
+
diff --git a/grub-core/lib/libgcrypt/src/ChangeLog-2011 b/grub-core/lib/libgcrypt/src/ChangeLog-2011
new file mode 100644
index 0000000..796fea4
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/ChangeLog-2011
@@ -0,0 +1,2335 @@
+2011-12-01 Werner Koch <wk@g10code.com>
+
+ NB: ChangeLog files are no longer manually maintained. Starting
+ on December 1st, 2011 we put change information only in the GIT
+ commit log, and generate a top-level ChangeLog file from logs at
+ "make dist". See doc/HACKING for details.
+
+2011-09-08 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in [GCRYPT_NO_DEPRECATED]: Exclude gcry_ac structures.
+
+2011-06-10 Werner Koch <wk@g10code.com>
+
+ * sexp.c (vsexp_sscan): Add new format specifiers 'M' and 'u'.
+
+2011-05-24 Daiki Ueno <ueno@unixuser.org>
+
+ * cipher.h (pk_operation): New.
+ (pk_encoding_ctx): Add new fields: op, nbits, flags, verify_cmp,
+ and verify_arg.
+
+2011-05-19 Daiki Ueno <ueno@unixuser.org>
+
+ * Makefile.am (gcryptrnd_LDADD): Supply $(GPG_ERROR_LIBS) for
+ gpg_strerror.
+
+2011-05-18 Daiki Ueno <ueno@unixuser.org>
+
+ * cipher.h: Remove PUBKEY_FLAG_UNPAD.
+
+2011-05-11 Daiki Ueno <ueno@unixuser.org>
+
+ * cipher.h (PUBKEY_FLAG_UNPAD): New.
+ (enum pk_encoding): New.
+ (struct pk_encoding_ctx): New.
+
+2011-04-19 Werner Koch <wk@g10code.com>
+
+ * stdmem.c (_gcry_private_malloc_secure, _gcry_private_malloc):
+ Set ERRNO on failure.
+ * secmem.c (mb_get_new): Set ERRNO on failure.
+ (_gcry_secmem_malloc_internal): Ditto.
+
+2011-04-01 Werner Koch <wk@g10code.com>
+
+ * global.c (gcry_realloc): Divert to gcry_malloc or gcry_free.
+
+2011-03-09 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (gcry_kdf_algos): New.
+ (gcry_kdf_derive): New.
+ * visibility.c (gcry_kdf_derive): New.
+ * visibility.h, libgcrypt.vers, libgcrypt.def: Add gcry_kdf_derive.
+
+2011-02-23 Werner Koch <wk@g10code.com>
+
+ * libgcrypt-config.in: Add option --host.
+ * libgcrypt.m4: Use AC_PROG_TOOL to find the config script. Print
+ a warning is the config scripts does not match the configure host.
+
+2011-02-21 Werner Koch <wk@g10code.com>
+
+ * global.c (gcry_check_version): Do not take the patchlevel in
+ account; it is not well defined.
+
+2011-02-17 Werner Koch <wk@g10code.com>
+
+ * gcrypt-module.h (gcry_cipher_register, gcry_cipher_unregister)
+ (gcry_pk_register, gcry_pk_unregister, gcry_md_register)
+ (gcry_md_unregister): Mark as deprecated by the API; in a future
+ version the module register feature will be removed.
+
+ * gcrypt.h.in: Attribute all _ac_ functions and types as
+ deprecated by the API.
+
+ * hwfeatures.c (detect_ia32_gnuc): Fix AES-NI detection. Use AND
+ instead of SUB for bit testing.
+
+2011-02-16 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (GCRYCTL_DISABLE_HWF): New.
+ * global.c (_gcry_vcontrol): Support new control code.
+ (print_config): Factor list of hwfeatures out to ...
+ (hwflist): new.
+ (disabled_hw_features): New.
+ (global_init): Pass new variable to _gcry_detect_hw_features.
+ * hwfeatures.c (_gcry_detect_hw_features): Add arg
+ DISABLED_FEATURES and disable detected features.
+
+2011-02-11 Werner Koch <wk@g10code.com>
+
+ * g10lib.h (HWF_INTEL_AES): Rename to HWF_INTEL_AESNI.
+ * hwfeatures.c (detect_ia32_gnuc): Fix setting of this flag.
+
+2011-02-01 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (gcry_pk_get_curve, gcry_pk_get_param): New.
+ * libgcrypt.vers (gcry_pk_get_curve, gcry_pk_get_param): Add.
+ * libgcrypt.def (gcry_pk_get_curve, gcry_pk_get_param): Add.
+ * visibility.c (gcry_pk_get_curve, gcry_pk_get_param): New.
+ * cipher-proto.h (pk_extra_spec): Add fields GET_CURVE and
+ GET_CURVE_PARM.
+
+2011-01-31 Werner Koch <wk@g10code.com>
+
+ * sexp.c (vsexp_sscan): Allow opaque MPIs in "%m".
+
+2010-08-27 Werner Koch <wk@g10code.com>
+
+ * g10lib.h (HWF_INTEL_AES): New.
+ * global.c (print_config): Print new flag.
+ * hwfeatures.c (detect_ia32_gnuc): Detect this flag.
+
+2010-08-16 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in [!WIN32]: Add INSERT_SYS_SELECT_H autoconf substitute.
+
+2010-07-09 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in [!__GNUC__ && W32]: Typedef ssize_t and pid_t to
+ help building with MSVC.
+
+2010-06-24 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in [W32]: Include time.h and not sys/time.h.
+
+2010-04-19 Marcus Brinkmann <marcus@g10code.de>
+
+ * misc.c (write2stderr): Dummy variable to silence gcc warning.
+
+2010-04-16 Marcus Brinkmann <marcus@g10code.de>
+
+ * sexp.c: (sexp_sscan): Make it variable length, and rename the
+ old version to ...
+ (vsexp_sscan): ... this new function. Also swap last two arguments.
+ (gcry_sexp_create): Remove dummy va_list.
+ (gcry_sexp_build): Use vsexp_sscan instead of sexp_sscan.
+ (_gcry_sexp_vbuild): Likewise.
+ (gcry_sexp_build_array): Remove dummy va_list.
+ (gcry_sexp_sscan): Likewise.
+
+2010-04-12 Brad Hards <bradh@frogmouth.net> (wk)
+
+ Spelling fixes.
+
+2010-03-15 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in: Add autoconf template to set generated file to
+ read-only in an Emacs buffer.
+
+2010-01-21 Werner Koch <wk@g10code.com>
+
+ * Makefile.am (arch_gpg_error_cflags, arch_gpg_error_libs): New.
+ (dumpsexp_CFLAGS): New.
+ (dumpsexp_LDADD): Add arch_gpg_error_libs.
+ (hmac256_CFLAGS, hmac256_LDADD): Add the arch variables.
+ (libgcrypt_la_DEPENDENCIES): Add libcompat.
+ * secmem.c (lock_pool): Mark unused args.
+ * global.c (do_malloc, gcry_realloc, gcry_free, gcry_calloc)
+ (gcry_calloc_secure, gcry_xcalloc, gcry_xcalloc_secure): Use
+ gpg_err_set_errno.
+ (_gcry_vcontrol): Call _gcry_compat_identification.
+ * hmac256.c [__MINGW32CE__]: Include gpg-error.h.
+ (_gcry_hmac256_file): Use gpg_err_set_errno.
+ (gpg_err_set_errno) [!GPG_ERR_INLINE]: Add macro.
+ * g10lib.h: Include libcompat.h.
+
+2010-01-05 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (GCRY_PK_ECDH): New.
+
+2009-12-08 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (GCRY_CIPHER_MODE_AESWRAP): New.
+
+2009-12-08 Marcus Brinkmann <marcus@g10code.de>
+
+ * Makefile.am (LTRCCOMPILE): Refactor with ...
+ (RCCOMPILE): ... this new macro. Add $(libgcrypt_la_CPPFLAGS).
+ (SUFFIXES): Add .lo.
+ (.rc.o): Change to ...
+ (.rc.lo): ... this implicit rule.
+ (gcrypt_res_ldflag): Removed.
+ (gcrypt_res): Use libtool object file name here.
+ (libgcrypt_la_LDFLAGS): Remove gcrypt_res_ldflag usage.
+ (libgcrypt_la_LIBADD): Add gcrypt_res.
+
+2009-11-29 Werner Koch <wk@g10code.com>
+
+ * hwfeatures.c (detect_ia32_gnuc): Repalce "=r" by "+r" so that
+ HAS-CPUDID is always initialized. Thanks to Ben Hutchings for
+ pointing out this problem.
+
+2009-08-05 Werner Koch <wk@g10code.com>
+
+ * ath.h: Include sys/msg.h.
+
+2009-07-02 Werner Koch <wk@g10code.com>
+
+ * fips.c (_gcry_initialize_fips_mode): Do not use FIPS mode if
+ /proc/.../fips_enabled has insufficient permissions.
+
+ * dumpsexp.c (main): Fix handling multiple files.
+ (parse_and_print): Implement hex and octal escaping.
+
+ * sexp.c (unquote_string): Remove superfluous clearing of ESC.
+ * dumpsexp.c (parse_and_print): Add missing break.
+ (main): Fix return value.
+ Reported by Fabian Keil.
+
+2009-02-16 Werner Koch <wk@g10code.com>
+
+ * ath.h [HAVE_SYS_SELECT_H]: Include <sys/select.h> for fd_set.
+ [!HAVE_SYS_SELECT_H]: Include <sys/time.h>. Move inclusion of
+ config.h to the top. The actual configure check was already
+ there.
+
+ * sexp.c: Remove memory.h.
+ * mpi.h: Remove memory.h. Add string.h.
+
+2009-02-02 Werner Koch <wk@g10code.com>
+
+ * ath.h: Include sys/time.h. Fixes bug#993.
+
+2009-01-22 Werner Koch <wk@g10code.com>
+
+ * fips.c (_gcry_initialize_fips_mode): Remove superfluous const
+ from static string. Reported by Albert Chin.
+ * hmac256.c (selftest): Ditto and change to unsigned char.
+
+2008-12-10 Werner Koch <wk@g10code.com>
+
+ * hmac256.c (finalize): Fix for big endian hosts.
+
+2008-12-05 Werner Koch <wk@g10code.com>
+
+ * global.c (gcry_free): Save and restore ERRNO if set.
+
+2008-11-24 Werner Koch <wk@g10code.com>
+
+ * sexp.c (get_internal_buffer): New.
+ (sexp_sscan): Add format character S.
+ * cipher-proto.h (pk_ext_generate_t): Add field EXTRAINFO changed
+ all implementors.
+
+ * cipher-proto.h (pk_ext_generate_t): Simplify.
+ (pk_get_param): New.
+ (pk_extra_spec_t): Add field GET_PARAM.
+ * cipher.h (PUBKEY_FLAG_TRANSIENT_KEY): Remove.
+ (_gcry_pubkey_extraspec_elg): New.
+
+2008-11-05 Werner Koch <wk@g10code.com>
+
+ * cipher.h (CIPHER_INFO_NO_WEAK_KEY): New.
+
+ * cipher-proto.h (cipher_set_extra_info_t): New.
+ (cipher_extra_spec): Add field SET_EXTRA_INFO.
+
+2008-10-30 Werner Koch <wk@g10code.com>
+
+ * g10lib.h (GCC_ATTR_FORMAT_ARG): New.
+ (_gcry_gettext): Use it.
+
+2008-10-24 Werner Koch <wk@g10code.com>
+
+ * global.c (inactive_fips_mode): Move to fips.c.
+ (gcry_set_allocation_handler): Factor code out to ...
+ * fips.c (_gcry_inactivate_fips_mode): New.
+ (_gcry_is_fips_mode_inactive): New.
+
+2008-09-29 Werner Koch <wk@g10code.com>
+
+ * gcrypt-module.h (GCRY_MODULE_ID_USER, GCRY_MODULE_ID_USER_LAST):
+ New.
+ * module.c (MODULE_ID_USER, MODULE_ID_USER_LAST): Define using new
+ macros.
+
+2008-09-20 Werner Koch <wk@g10code.com>
+
+ * hmac256.c (finalize) [WORDS_BIGENDIAN]: Fix sigbus problem.
+
+2008-09-18 Werner Koch <wk@g10code.com>
+
+ * cipher-proto.h (pk_ext_generate_t): Add args QBITS, NAME, DOMAIN.
+
+ * fips.c (fips_new_state): Allow Error => Error transition.
+
+2008-09-18 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (gcry_fips_mode_active): New.
+
+ * secmem.c (_gcry_secmem_init): Factor most code out to ..
+ (secmem_init): .. new.
+ (DEFAULT_POOL_SIZE): Rename to MINIMUM_POOL_SIZE.
+ (STANDARD_POOL_SIZE): New.
+ (_gcry_secmem_malloc_internal): Don't abort if the pool is not
+ initialized but try to out intialize it first and only then print
+ an error message and return NULL. If the pool is not locked while
+ in FIPS mode, return NULL.
+
+ * fips.c (FIPS_FORCE_FILE): New constant. Change the file name to
+ "/etc/gcrypt/fips_enabled".
+ (enforced_fips_mode): New.
+ (_gcry_initialize_fips_mode): Set that flag.
+ (_gcry_enforced_fips_mode): New.
+ * global.c (inactive_fips_mode): New.
+ (_gcry_vcontrol): Take that flag in account for GCRYCTL_FIPS_MODE_P.
+ (gcry_set_allocation_handler): Take care of the enforced fips mdoe
+ flag.
+ (get_no_secure_memory): New.
+ (do_malloc, gcry_is_secure): Use it.
+
+2008-09-16 Werner Koch <wk@g10code.com>
+
+ * global.c (print_config): Use y/n for fips mode.
+
+ * fips.c (fips_new_state): Allow transition to Error and
+ Fatal-error from Init.
+
+2008-09-15 Werner Koch <wk@g10code.com>
+
+ * fips.c [HAVE_SYSLOG]: Include syslog.h.
+ (_gcry_initialize_fips_mode, lock_fsm, unlock_fsm)
+ (_gcry_fips_signal_error, fips_new_state)
+ (_gcry_fips_noreturn) [HAVE_SYSLOG]: Also log via syslog.
+ (check_binary_integrity) [HAVE_SYSLOG]: Log failure.
+ * global.h [HAVE_SYSLOG]: Include syslog.h.
+ (_gcry_global_is_operational) [HAVE_SYSLOG]: Print warning.
+
+ * global.c (_gcry_vcontrol): Use GCRYCTL_INITIALIZATION_FINISHED
+ to run power-up tests. Add unpublished control commands 58-60.
+
+ * global.c (_gcry_global_is_operational): New.
+ * g10lib.h (fips_is_operational): Change to call this function.
+
+2008-09-12 Werner Koch <wk@g10code.com>
+
+ * fips.c (_gcry_fips_run_selftests): Add arg EXTENDED.
+ (run_cipher_selftests, run_digest_selftests, run_hmac_selftests)
+ (run_pubkey_selftests): Ditto.
+ * cipher-proto.h (selftest_func_t): Add arg EXTENDED
+
+2008-09-11 Werner Koch <wk@g10code.com>
+
+ * fips.c: Include string.h.
+ (loxtoi_1, loxtoi_2, loxdigit_p): New.
+ (check_binary_integrity): Change the format of the expected file.
+
+ * fips.c (_gcry_fips_run_selftests): Run random tests before the
+ pubkey tests.
+
+2008-09-05 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (GCYRCTL_SELFTEST): New.
+ * global.c (_gcry_vcontrol): Implement.
+ * fips.c (_gcry_fips_run_selftests): Do state transitions only if
+ in fips mode. Return an error code.
+
+2008-09-01 Werner Koch <wk@g10code.com>
+
+ * stdmem.c: Re-indented.
+
+2008-08-29 Werner Koch <wk@g10code.com>
+
+ * fips.c (_gcry_initialize_fips_mode): Changed /proc file to test
+ for FIPS mode.
+
+ * cipher-proto.h (pk_compute_keygrip_t): New.
+ (pk_extra_spec): Add field comp_keygrip.
+
+2008-08-28 Werner Koch <wk@g10code.com>
+
+ * hwfeatures.c (_gcry_detect_hw_features): Disable hardware
+ detection in FIPS mode.
+
+2008-08-27 Werner Koch <wk@g10code.com>
+
+ * global.c (_gcry_vcontrol): Allow running selftests from error
+ state.
+ (gcry_set_outofcore_handler): Only print a warning if used in FIPS
+ mode.
+ (gcry_xmalloc, gcry_xrealloc, gcry_xmalloc_secure, gcry_xstrdup):
+ Ignore an outofcore handler in FIPS mode.
+
+ * fips.c (_gcry_fips_test_error_or_operational): New.
+ (fips_new_state): Allow transition from error into selftest.
+ Disallow error to init.
+
+2008-08-26 Werner Koch <wk@g10code.com>
+
+ * fips.c (fips_new_state): Print state transitions only at
+ verbosity level of 2.
+ (reporter): Likewise.
+
+ * cipher-proto.h (pk_ext_generate_t): New.
+ (pk_extra_spec): Add member ext_generate.
+ * cipher.h (PUBKEY_FLAG_TRANSIENT_KEY): New.
+
+2008-08-22 Werner Koch <wk@g10code.com>
+
+ * hmac256.c (_gcry_hmac256_file): New.
+ (main): New option --binary.
+ * fips.c (check_binary_integrity): New.
+ (_gcry_fips_run_selftests): Run it.
+
+ * global.c (_gcry_vcontrol) <GCRYCTL_UPDATE_RANDOM_SEED_FILE>:
+ Check for fips operational state.
+ (_gcry_vcontrol) <GCRYCTL_FAST_POLL>: Ditt.
+
+2008-08-21 Werner Koch <wk@g10code.com>
+
+ * misc.c (_gcry_log_printhex): New.
+
+2008-08-20 Werner Koch <wk@g10code.com>
+
+ * g10lib.h (gcry_assert): New. use this at almost all places
+ where we used a plain assert.
+ * misc.c (_gcry_assert_failed): New.
+ (_gcry_bug): Also use func variant for ISO-C99.
+
+2008-08-19 Werner Koch <wk@g10code.com>
+
+ * visibility.c, visibility.h (gcry_mpi_lshift): New.
+ * libgcrypt.vers, libgcrypt.def, gcrypt.h.in: Ditto.
+
+2008-08-15 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (gcry_cipher_setkey): Replace macro by function.
+ (gcry_cipher_setiv): Ditto.
+ (gcry_cipher_setctr): Ditto.
+ * visibility.c (gcry_cipher_setkey, gcry_cipher_setiv)
+ (gcry_cipher_setctr): New.
+ * visibility.h (gcry_cipher_setkey, gcry_cipher_setiv)
+ (gcry_cipher_setctr): New.
+ * libgcrypt.vers (gcry_cipher_setkey, gcry_cipher_setiv)
+ (gcry_cipher_setctr): New.
+ * libgcrypt.def (gcry_cipher_setkey, gcry_cipher_setiv)
+ (gcry_cipher_setctr): New.
+
+ * hmac256.h, hmac256.c: New.
+ * Makefile.am (hmac256_SOURCES): New.
+ * Makefile.am (bin_PROGRAMS): Add hmac256.
+
+ * gcrypt.h.in (struct gcry_thread_cbs): Change type of OPTION to
+ unsigned int. Although this is a type change it does not make a
+ difference.
+ * ath.c (ath_install): Take the version of the option field in
+ account.
+
+ * visibility.c (gcry_pk_encrypt, gcry_pk_decrypt, gcry_pk_sign)
+ (gcry_pk_verify, gcry_pk_testkey, gcry_pk_genkey)
+ (gcry_pk_get_nbits, gcry_pk_get_keygrip)
+ (gcry_md_open, gcry_md_copy, gcry_md_enable)
+ (gcry_md_write, md_final, gcry_md_ctl, gcry_md_setkey)
+ (gcry_md_hash_buffer, gcry_md_get_algo, gcry_md_info)
+ (gcry_md_is_enabled)
+ (gcry_cipher_open, gcry_cipher_encrypt)
+ (gcry_cipher_decrypt, gcry_cipher_ctl)
+ (gcry_cipher_algo_info): Check whether the library is operational.
+
+ * cipher-proto.h: New.
+ * cipher.h: Include cipher-proto.h.
+ * visibility.h: Remove duplicate macro definitions. Remove
+ gcry_cipher_register, gcry_md_register, gcry_pk_register macros.
+ * visibility.c: Include cipher-proto.h.
+ (gcry_cipher_register): Pass dummy extra args to the internal
+ register function.
+ (gcry_md_register, gcry_pk_register): Ditto.
+ * g10lib.h (struct gcry_module): Add field EXTRASPEC.
+ * module.c (_gcry_module_add): Add arg EXTRASPEC. Changed all
+ callers to pass NULL.
+
+ * fips.c: New.
+ * gcrypt.h.in (GCRYCTL_FIPS_MODE_P): New.
+ * global.c (global_init): Call fips initialization.
+ (_gcry_vcontrol): Add GCRYCTL_FIPS_MODE_P code.
+ (print_config): Add config item fips-mode.
+ (gcry_set_allocation_handler): Do not allow the use of custom
+ allocation handlers.
+ (gcry_set_outofcore_handler): Ditto.
+ (_gcry_get_debug_flag): Do not return any debug flags in fips mode.
+ * misc.c (_gcry_logv): Signal fips error on BUG or FATAL.
+ (_gcry_fatal_error): Ditto.
+
+2008-07-05 Werner Koch <wk@g10code.com>
+
+ * Makefile.am: Include librandom.la.
+
+2008-04-18 Werner Koch <wk@g10code.com>
+
+ * missing-string.c (vasprintf): Remove. It is not used. Reported
+ by Simon Josefsson.
+
+2008-03-11 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (gcry_ac_em_t, gcry_ac_scheme_t): Remove trailing
+ comma for full C-89 compatibility.
+
+2008-01-21 Marcus Brinkmann <marcus@g10code.de>
+
+ * hwfeatures.c (detect_ia32_gnuc): Fix inline asm.
+
+2007-12-11 Werner Koch <wk@g10code.com>
+
+ * visibility.c (gcry_md_hash_buffer): Don't use return vor a void
+ function. Hey, why does gcc not complain about this?
+ (gcry_ac_io_init_va): Ditto.
+
+2007-12-05 Werner Koch <wk@g10code.com>
+
+ * hwfeatures.c (detect_ia32_gnuc): Depend on ENABLE_PADLOCK_SUPPORT.
+
+2007-12-03 Werner Koch <wk@g10code.com>
+
+ * misc.c (_gcry_logv): Use abort for error levels fatal and bug as
+ this is more approriate for a library. Terminate the secmem
+ before doing so.
+ (_gcry_fatal_error): Terminate secmem before abort.
+ * secmem.c (_gcry_secmem_malloc_internal): Use log_bug instead of
+ exit.
+
+2007-11-29 Werner Koch <wk@g10code.com>
+
+ * hwfeatures.c (detect_ia32_gnuc): Detect Padlock engine.
+
+2007-11-13 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (_GCRY_GCC_ATTR_MALLOC): Fixed gcc version check.
+ Reported by Gabriele Monti.
+
+2007-10-31 Werner Koch <wk@g10code.com>
+
+ * global.c (gcry_control): Factor most code out to ..
+ (_gcry_vcontrol): .. new.
+ * sexp.c (_gcry_sexp_vbuild): New.
+ * mpi.h (_gcry_mpi_set, _gcry_mpi_set_ui, _gcry_mpi_invm): Remove
+ prototypes as they are already in gcrypt.h.
+
+2007-10-30 Werner Koch <wk@g10code.com>
+
+ * sexp.c (gcry_sexp_nth_string): Replace by _gcry_sexp_nth_string.
+
+ * visibility.h, visibility.c: New.
+ * g10lib.h: Include visibility.h instead of gcrypt.h.
+ * globals.c (_gcry_malloc): Rename to ..
+ (do_malloc): .. this.
+
+ * hwfeatures.c: New.
+ * global.c (global_init): Detect features.
+ (print_config): Print them.
+
+2007-08-22 Werner Koch <wk@g10code.com>
+
+ * dumpsexp.c: New.
+ * Makefile.am (bin_PROGRAMS): Install it.
+
+ * getrandom.c (print_version): Use new standard license line.
+ * gcryptrnd.c (print_version): Ditto.
+
+2007-06-06 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (GCRY_THREAD_OPTION_PTH_IMPL): Factror network
+ related code out so that the prototypes can be adjusted for W32.
+ (_GCRY_THREAD_OPTION_PTH_IMPL_NET): New.
+
+2007-05-09 Werner Koch <wk@g10code.com>
+
+ * libgcrypt.m4: Print found version on success.
+
+2007-05-09 Marcus Brinkmann <marcus@g10code.de>
+
+ * gcrypt.h.in (gcry_ac_io_t): Add name for anonymous union, and mark
+ all members as internal (actually: deprecated).
+
+2007-05-04 Werner Koch <wk@g10code.com>
+
+ * Makefile.am (.rc.lo): New to replace gmake specific suffix rule.
+
+2007-05-03 Werner Koch <wk@g10code.com>
+
+ * libgcrypt.def (gcry_sexp_nth_string): New.
+ * Makefile.am (EXTRA_DIST): Add libgcrypt.def.
+
+2007-05-02 Werner Koch <wk@g10code.com>
+
+ * global.c (print_config): Print ciphers, digests and pubkeys.
+
+2007-05-02 David Shaw <dshaw@jabberwocky.com>
+
+ * cipher.h, gcrypt.h.in: Add Camellia.
+
+2007-04-30 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (GCRYCTL_PRINT_CONFIG): New.
+ (GCRYCTL_SET_RNDEGD_SOCKET): New.
+ * global.c (gcry_control): Add GCRYCTL_PRINT_CONFIG and
+ GCRYCTL_SET_RNDEGD_SOCKET.
+ (print_config): New.
+ * misc.c (_gcry_log_info_with_dummy_fp): New.
+
+2007-04-18 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (gcry_sexp_nth_string): New.
+
+ * sexp.c (gcry_sexp_nth_data): Factored code out to ...
+ (sexp_nth_data): ... new.
+ (gcry_sexp_nth_string): New.
+ (gcry_sexp_nth_mpi): Reimplemented in terms of sexp_ntd_data.
+
+2007-04-16 Werner Koch <wk@g10code.com>
+
+ * secmem.c (init_pool): Use sysconf() if available to determine
+ page size.
+
+2007-03-22 Werner Koch <wk@g10code.com>
+
+ * mpi.h (mpi_mod): New.
+ (mpi_new, mpi_snew): New.
+
+ * gcrypt.h.in: Add GCRY_PK_ECDSA.
+
+2007-03-16 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (GCRY_THREAD_OPTION_PTHREAD_IMPL): Fixed typo
+ introduced by me on 2006-10-23.
+
+2007-02-22 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (gcry_ac_id_to_name, gcry_ac_name_to_id): Mark as
+ deprecated.
+
+ * libgcrypt.def (gcry_fast_random_poll): Removed - it is a macro.
+ (gcry_cipher_register, gcry_cipher_unregister): New.
+ (gcry_md_register, gcry_md_unregister): New.
+ (gcry_pk_register, gcry_pk_unregister): New.
+ (gcry_ac_data_from_sexp, gcry_ac_data_to_sexp): New.
+ (gcry_ac_io_init, gcry_ac_io_init_va): New.
+ (gcry_ac_data_encrypt_scheme, gcry_ac_data_decrypt_scheme): New.
+ (gcry_ac_data_sign_scheme, gcry_ac_data_verify_scheme): New.
+
+ * missing-string.c: Include stdio.h for the vsprintf prototype.
+
+ * ath.h (struct ath_ops) [_WIN32]: Use int instead of socklen_t.
+
+2007-02-21 Werner Koch <wk@g10code.com>
+
+ * libgcrypt.def (gcry_create_nonce, gcry_fast_random_poll)
+ (gcry_md_debug): New.
+
+ * libgcrypt-config.in: Remove duplicates from --cflags and --libs.
+ Print a error for option --thread.
+
+ * gcrypt.h.in (gcry_sexp_sprint): Change BUFFER from char* to void*.
+ (gcry_md_ctl): Change BUFFER from unsigned char* to void*.
+ (gcry_md_debug): New.
+ (gcry_cipher_encrypt, gcry_cipher_decrypt): Change buffer args to
+ void*.
+ (gcry_randomize): Change BUFFER to void.
+ (gcry_create_nonce): Ditto.
+
+ * libgcrypt.vers (gcry_md_debug): New.
+
+ * sexp.c (gcry_sexp_sprint): Ditto.
+ (normalize): Make P unsigned.
+ (gcry_sexp_nth_data): Cast return value to char*.
+ (sexp_sscan): Fix sign/unsigned conflicts.
+ (whitespacep): Change P to char*.
+ (unquote_string): Change STRING to char*.
+ (convert_to_hex): Change DEST to char*.
+ (convert_to_string): Change DEST and P to char*.
+ (convert_to_token): Chnage DEST to char*.
+ (gcry_sexp_canon_len): Change DISPHINT to unsigned char*.
+
+ * gcrypt-module.h (gcry_pk_spec): Made ALIASES a const.
+ (gcry_md_write_t): Changed BUF to a const void*.
+
+2007-02-12 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in: Include stdlib.h for the sake fo the trheading
+ macros. Suggested by Andreas Metzler.
+
+ * secmem.c (ptr_into_pool_p): New.
+ (_gcry_private_is_secure): Implement in terms of new function.
+ (BLOCK_VALID): Removed. Replaced all users by new function.
+
+2007-01-31 Werner Koch <wk@g10code.com>
+
+ * secmem.c (_gcry_private_is_secure): Fixed severe implementation
+ flaw. Might be the reason for some of the more obscure bugs.
+ (MB_WIPE_OUT): Use wipememory2.
+
+2006-10-23 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h.in (GCRY_THREAD_OPTION_PTHREAD_IMPL): Add some cast for
+ use by C-doubleplus. In general I don't like this but due to
+ public demand I give up ;-)
+
+2006-10-19 Werner Koch <wk@g10code.com>
+
+ * global.c (gcry_control) <GCRYCTL_INIT_SECMEM>: Return an error
+ if the memory could not be locked.
+ * secmem.c (not_locked): New.
+ (_gcry_secmem_get_flags): Return that flag.
+ * secmem.h (GCRY_SECMEM_FLAG_NOT_LOCKED): New.
+
+2006-10-05 Werner Koch <wk@g10code.com>
+
+ * module.c (_gcry_module_id_new): Don't assign modules in the range
+ the range of 1024..4096.
+ * gcrypt.h (GCRY_MD_USER, GCRY_MD_USER_LAST): New
+ (GCRY_PK_USER, GCRY_PK_USER_LAST): New.
+ (GCRY_CIPHER_USER, GCRY_CIPHER_USER_LAST): New.
+
+2006-10-12 Marcus Brinkmann <marcus@g10code.de>
+
+ * gcrypt.h.in: Replace socklen_t with gcry_socklen_t.
+
+2006-10-11 Marcus Brinkmann <marcus@g10code.de>
+
+ * gcrypt.h.in: Replace version by @VERSION@.
+
+2006-10-10 Marcus Brinkmann <marcus@g10code.de>
+
+ * gcrypt.h: Add fallback type for socklen_t. Move to ...
+ * gcrypt.h.in: ... this file.
+ * Makefile.am (EXTRA_DIST): Add gcrypt.h.in.
+
+2006-09-04 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h: Removed some trailing comma in enums.
+
+2006-08-29 Werner Koch <wk@g10code.com>
+
+ * global.c (gcry_xrealloc): Pass secure flag to outofcore handler.
+
+ * gcrypt.h (GCRY_CIPHER_SEED): New.
+
+2006-08-21 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h (GCRYCTL_FAKED_RANDOM_P): New.
+
+2006-07-29 Marcus Brinkmann <marcus@g10code.de>
+
+ * secmem.c (init_pool): Close FD after establishing the mapping.
+
+2006-07-12 Marcus Brinkmann <marcus@g10code.de>
+
+ * ath.c (ath_mutex_destroy): Microoptimize destruction of unused
+ statitically initialized mutexes. Suggested by Victor Stinner
+ <victor.stinner@inl.fr>.
+
+ * gcrypt.h (GCRY_THREAD_OPTION_PTHREAD_IMPL,
+ (GCRY_THREAD_OPTION_PTH_IMPL): Add missing initializers to
+ suppress gcc warning.
+ Submitted by Victor Stinner <victor.stinner@inl.fr>.
+
+2006-07-04 Marcus Brinkmann <marcus@g10code.de>
+
+ * ath.c: Avoid warning about double defined type byte and other
+ hacks to let it build for W32 (backported from LIBGCRYPT-1-2-BRANCH).
+ * ath.h, gcrypt.h, tests/benchmark.c, src/types.h: Likewise.
+
+ * gcrypt.h: Revert last change, and instead:
+ [_WIN32 || __WIN32__]: Do not include <sys/socket.h>, but
+ <winsock2.h> and <ws2tcpip.h>.
+ Suggested by Simon Josefsson <jas@extundo.com>.
+
+ * Makefile.am (install-data-local, uninstall-local, %.lo,
+ (install-def-file, uninstall-def-file): New targets.
+ (LTRCCOMPILE, gcrypt_res, gcrypt_res_ldflag, no_undefined,
+ (export_symbols, gcrypt_deps): New variables.
+ * versioninfo.rc.in: New file.
+ * libgcrypt.def: New file from ../w32-dll/libgcrypt.def.
+
+ * gcrypt.h [!HAVE_SYS_SOCKET_H]: Do not include sys/socket.h, but
+ the appropriate windows socket header.
+
+2006-06-21 Werner Koch <wk@g10code.com>
+
+ * global.c (gcry_xcalloc, gcry_xcalloc_secure): Made safe against
+ integer overflow.
+
+ * sexp.c (make_space): Return an error on out of core.
+ (sexp_sscan): Remove all xmalloc style calls and return proper
+ error codes on allocation failures.
+ (gcry_sexp_find_token): Ditto.
+ (gcry_sexp_nth):
+
+ * sexp.c (gcry_sexp_find_token): Re-indented and removed a cruft
+ "while(level);" which fortunately had no effect.
+
+2006-04-28 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h (GCRY_MD_SHA224): Change value from 306 to 11 to match
+ the use in OpenPGP. There has been no release yet, so we can
+ safely do it.
+
+2006-04-22 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (gcry_ctl_cmds): New commands:
+ GCRYCTL_SET_RANDOM_DAEMON_SOCKET, GCRYCTL_USE_RANDOM_DAEMON.
+ * global.c (gcry_control): Handle new commands, calling
+ _gcry_set_random_daemon_socket() and _gcry_use_random_daemon().
+
+2006-04-18 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h (GCRY_PK_USAGE_CERT, GCRY_PK_USAGE_AUTH)
+ (GCRY_PK_USAGE_UNKN): New.
+
+2006-04-01 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (gcry_ac_eme_pkcs_v1_5): Removed members: key, handle;
+ added member: key_size.
+
+ * secmem.c (MB_FLAG_ACTIVE): Write braces around MB_FLAG_ACTIVE
+ definition.
+
+2006-03-15 Werner Koch <wk@g10code.com>
+
+ * getrandom.c: New.
+
+2006-03-14 Werner Koch <wk@g10code.com>
+
+ * gcryptrnd.c: New.
+
+2006-03-10 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h: Add GCRY_MD_SHA224.
+
+2005-11-02 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h: Update comments for functions: gcry_cipher_algo_name,
+ gcry_pk_algo_name.
+
+2005-10-31 Moritz Schulte <moritz@g10code.com>
+
+ * global.c: Added documentation.
+
+2005-10-16 Moritz Schulte <moritz@g10code.com>
+
+ * global.c (global_init): Use gcry_error_t instead of
+ gcry_err_code_t; use goto instead of if constructs.
+
+ * stdmem.c: Inserted description of the layered memory management
+ in Libgcrypt.
+
+ * g10lib.h: Removed G10_I18N_H related check; it seems to be a
+ GnuPG relict (Libgcrypt does not define this symbol anywhere).
+ (FLAG_MODULE_DISABLED): Don't forget parantheses around shifted
+ value.
+
+ Removed GCC_ATTR_PURE macro definitions, since gcrypt.h does
+ already contain such a macro named _GCRY_GCC_ATTR_PURE, which we
+ can use here as well.
+
+ Likewise for GCC_ATTR_MALLOC and _GCRY_GCC_ATTR_MALLOC.
+
+ * stdmem.h: Use _GCRY_GCC_ATTR_MALLOC instead of GCC_ATTR_MALLOC.
+ * secmem.h: Likewise.
+
+2005-10-09 Moritz Schulte <moritz@g10code.com>
+
+ * global.c (gcry_control): Call global_init() after passing thread
+ cbs to ath. global_init() MUST to be called AFTER passing the cbs
+ to ath and BEFORE calling library functions, which make use of
+ ath. This change combines cbs installing with ath initialization
+ and thus removes the need to call other library initialization
+ functions inbetween like e.g. gcry_check_version().
+
+2005-10-01 Moritz Schulte <moritz@g10code.com>
+
+ * ath.c: Assign copyright to FSF.
+ * ath.h: Likewise.
+
+2005-06-25 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (pkgconfigdir, pkgconfig_DATA): Removed variables.
+ * libgcrypt.pc.in: Removed file - we do not want to support a
+ second, foreign configuration system.
+
+2005-06-17 Moritz Schulte <moritz@g10code.com>
+
+ * global.c (gcry_xstrdup): Removed superfluous strcpy call.
+
+2005-04-22 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (pkgconfigdir, pkgconfig_DATA): New; support for
+ pkgconfig provided by Albert Chin.
+ * libgcrypt.pc.in (Cflags): New file.
+
+2005-04-16 Moritz Schulte <moritz@g10code.com>
+
+ * g10lib.h (_gcry_ac_init): Declare.
+ * global.c (global_init): Call _gcry_ac_init; don't forget to set
+ err.
+
+2005-04-14 Werner Koch <wk@g10code.com>
+
+ * sexp.c (whitespacep): New.
+ (sexp_sscan): Replaced isdigit and isspace by whitespacep and
+ digitp.
+
+2005-04-11 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (gcry_md_algos): Added: GCRY_MD_WHIRLPOOL.
+ * cipher.h (_gcry_digest_spec_whirlpool): Declare.
+
+2005-03-30 Moritz Schulte <moritz@g10code.com>
+
+ * libgcrypt.vers: Added: gcry_ac_io_init, gry_ac_io_init_va.
+
+ * gcrypt.h (gcry_ac_data_read_cb_t, gcry_ac_data_write_cb_t,
+ gcry_ac_io_mode_t, gcry_ac_io_type_t, gcry_ac_io_t): New types.
+ (gcry_ac_io_init_va): Declare function.
+ (gcry_ac_data_encode, gcry_ac_data_decode,
+ gcry_ac_data_encrypt_scheme, gcry_ac_data_decrypt_scheme,
+ gcry_ac_data_sign_scheme, gcry_ac_data_verify_scheme): Use
+ gcry_ac_io_type_t objects instead of memory strings directly.
+
+2005-03-03 Moritz Schulte <moritz@g10code.com>
+
+ * libgcrypt.vers: Added: gcry_ac_data_to_sexp() and
+ gcry_ac_data_from_sexp().
+
+2005-02-22 Werner Koch <wk@g10code.com>
+
+ * global.c (_gcry_malloc): Make sure ERRNO is set if we return
+ NULL. Remove unneeded initialization of M to allow the compiler
+ to catch errors.
+ (gcry_realloc): Make sure ERRNO is set if we return NULL>
+
+2005-02-13 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h: Declare new functions: gcry_ac_data_encrypt_scheme,
+ gcry_ac_data_decrypt_scheme, gcry_ac_data_sign_scheme,
+ gcry_ac_data_verify_scheme, gcry_ac_data_encode,
+ gcry_ac_data_decode, gcry_ac_data_to_sexp, gcry_ac_data_from_sexp.
+ New types: gcry_ac_emsa_pkcs_v1_5_t, gcry_ac_ssa_pkcs_v1_5_t,
+ gcry_md_algo_t.
+ New enumeration lists: gcry_ac_scheme_t, gcry_ac_em_t.
+ * libgcrypt.vers: Added new ac functions.
+ * g10lib.h: Declare function: _gcry_pk_get_elements.
+ * mpi.h (mpi_get_ui): New macro.
+ Declare function: _gcry_mpi_get_ui.
+
+2004-11-09 Werner Koch <wk@g10code.com>
+
+ * gcrypt.h: Removed 3 trailing commas from enums. Noted by Heiko
+ Stamer.
+
+2004-09-21 Werner Koch <wk@g10code.de>
+
+ * sexp.c (sexp_sscan): Removed C++ style comments. Noted by Yoann
+ Vandoorselaere.
+
+2004-08-23 Moritz Schulte <moritz@g10code.com>
+
+ * global.c: Do not include <assert.h>.
+ * sexp.c: Likewise.
+ * module.c: Likewise.
+ * misc.c: Likewise.
+
+2004-08-18 Moritz Schulte <moritz@g10code.com>
+
+ * secmem.c (_gcry_secmem_init): Try to lock pool into core not
+ only when running with root privileges.
+
+2004-08-16 Werner Koch <wk@g10code.de>
+
+ * secmem.h (_gcry_secmem_set_flags,_gcry_secmem_get_flags):
+ Removed __pure__.
+ (GCRY_SECMEM_FLAG_NO_WARNING): Put macro value into parens.
+
+ * secmem.c (_gcry_secmem_init): Defer printing of the warning.
+
+2004-08-10 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h: Include <sys/time.h>, thanks to Simon Josefsson.
+
+2004-05-07 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: Added GCRYCTL_FAST_POLL.
+ (gcry_fast_random_poll): New.
+ * global.c (gcry_control) <INITIALIZATION_FINISHED>: Do only basic
+ random subsystem init.
+ (gcry_control) <FAST_POLL>: New.
+
+2004-04-22 Marcus Brinkmann <marcus@g10code.de>
+
+ * libgcrypt.m4: Quote first argument to AC_DEFUN.
+
+2004-04-15 Werner Koch <wk@gnupg.org>
+
+ * secmem.c (_gcry_secmem_malloc_internal): Removed old extra info
+ error output.
+ (_gcry_secmem_term): Use wipememory2 here.
+
+ * misc.c (_gcry_burn_stack): Use wipememory to avoid optimizations.
+
+ * string.c: Removed. Was never used.
+ * global.c (gcry_strdup): Replaced by the version from string.c
+ (gcry_xstrdup): Rewritten.
+ * gcrypt.h: Removed duplicate prototype for gcry_strdup.
+
+2004-03-29 Werner Koch <wk@gnupg.org>
+
+ * secmem.c (_gcry_secmem_realloc): Fixed double unlock; bug
+ manifested itself due to the more rigorous checking in the changed
+ ath.h
+
+ * libgcrypt-config.in (Options): Ignore the obsolete --threads
+ option for now.
+
+2004-03-17 Marcus Brinkmann <marcus@g10code.de>
+
+ * libgcrypt-config.in (includedir, libdir): Quote'em. Use
+ $gpg_error_cflags and $gpg_error_libs. Fix construction of
+ $includes.
+
+2004-03-14 Marcus Brinkmann <marcus@g10code.de>
+
+ * libgcrypt-config.in (includedir, libdir): New variables. For
+ --cflags, don't test $cflags. Also check against /include for the
+ GNU/Hurd. Don't overwrite but extend $cflags_final. Likewise for
+ --libs.
+
+2004-03-10 Marcus Brinkmann <marcus@g10code.de>
+
+ * Makefile.am (ltlib_libgcrypt_pthread, ltlib_libgcrypt_pth): Removed.
+ (lib_LTLIBRARIES): Remove those variables from here.
+ (libgcrypt_pthread_la_SOURCES, libgcrypt_pthread_la_LDFLAGS,
+ (libgcrypt_pthread_la_DEPENDENCIES, libgcrypt_pthread_la_LIBADD,
+ (libgcrypt_pth_la_SOURCES, libgcrypt_pth_la_LDFLAGS,
+ (libgcrypt_pth_la_DEPENDENCIES, libgcrypt_pth_la_LIBADD,
+ (noinst_LTLIBRARIES): Removed.
+ (libgcrypt_real_la_SOURCES): Merge with ...
+ (libgcrypt_la_SOURCES): ... likewise.
+ (libgcrypt_real_la_DEPENDENCIES): Merge with ...
+ (libgcrypt_la_DEPENDENCIES): ... this.
+ (libgcrypt_real_la_LIBADD): Merge with ...
+ (libgcrypt_la_LIBADD): ... this.
+ * libgcrypt-config.in (libs_pthread, libs_pth, cflags_pth)
+ (cflags_pthread, thread_module, thread_modules): Removed.
+ (Options): Remove --thread option from help output. If the option
+ is specified, output an error and exit.
+ For --cflags and --libs option, remove pth and pthread from output.
+ * gcrypt.h: Include <sys/types.h> and <sys/socket.h>.
+ (enum gcry_ctl_cmds): Add GCRYCTL_SET_THREAD_CBS.
+ (gcry_thread_cbs): New struct.
+ * global.c (gcry_control): Implement GCRYCTL_SET_THREAD_CBS.
+ (global_init): Don't call ath_init here.
+ * ath.h: Rewritten.
+ * ath.c: Rewritten.
+
+2004-03-06 Werner Koch <wk@gnupg.org>
+
+ * libgcrypt-config.in: s/--soname-number/--api-version/
+ * libgcrypt.m4: Changed test for API version.
+
+2004-03-05 Werner Koch <wk@gnupg.org>
+
+ * libgcrypt.m4: Optionally check the SONAME number.
+
+ * libgcrypt-config.in: Add option --soname-number
+
+2004-03-01 Marcus Brinkmann <marcus@g10code.de>
+
+ * Makefile.am (libgcrypt_la_SOURCES): Add ath.c.
+ * ath.c (ath_init): Add missing function.
+
+ * Makefile.am (ath_pth_src): Removed.
+ (ath_pthread_src): Removed.
+ (libgcrypt_la_SOURCES): Remove ath-compat, $(ath_pth_src) and
+ $(ath_pthread_src).
+ * ath-compat.c, ath-pth-compat.c, ath-pthread-compat.c: Files
+ removed.
+
+2004-02-20 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (GCRY_PRIME_CHECK_AT_GOT_PRIME)
+ (GCRY_PRIME_CHECK_AT_FINISH),
+ (GCRY_PRIME_CHECK_AT_MAYBE_PRIME): New.
+
+2004-02-18 Werner Koch <wk@gnupg.org>
+
+ * libgcrypt-config.in: Ignore setting of --prefix.
+
+2004-02-13 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: Added GCRY_CIPHER_RFC2268_128, alsthough not yet
+ supported.
+
+2004-02-06 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: Added GCRY_CIPHER_RFC2268_40.
+
+2004-02-03 Werner Koch <wk@gnupg.org>
+
+ * secmem.c (_gcry_secmem_init): Do not print the "not locked into
+ core warning" if the NO_WARNING flag has been set.
+
+ * sexp.c (sexp_sscan): Allocate result in secure memory if BUFFER
+ is in secure memory. Switch to secure memory for the a secure %b
+ format item. Extra paranoid wipe on error.
+ (gcry_sexp_release): Added paranoid wiping for securely allocated
+ S-expressions.
+
+2004-01-25 Moritz Schulte <mo@g10code.com>
+
+ * ath.h: Include <config.h>.
+
+2004-01-12 Moritz Schulte <mo@g10code.com>
+
+ * gcrypt.h: Adjusted declarations of: gcry_ac_data_set,
+ gcry_ac_data_get_name, gcry_ac_data_get_index,
+ gcry_ac_key_pair_generate, gcry_ac_key_test,
+ gcry_ac_key_get_nbits, gcry_ac_key_get_grip.
+
+ * gcrypt.h (GCRY_AC_FLAG_DATA_NO_BLINDING): Removed symbol.
+ (GCRY_AC_FLAG_DEALLOC, GCRY_AC_FLAG_COPY)
+ (GCRY_AC_FLAG_NO_BLINDING): New symbols.
+
+ * global.c (gcry_strdup): Removed function.
+ * string.c: New file.
+ * Makefile.am (libgcrypt_real_la_SOURCES): Added: string.c.
+ * string.c (gcry_strdup): New function.
+ * gcrypt.h (gcry_strdup): Declare.
+
+2003-12-19 Werner Koch <wk@gnupg.org>
+
+ * g10lib.h (wipememory, wipememory2): New; taken from gnupg.
+
+2003-11-14 Werner Koch <wk@gnupg.org>
+
+ * global.c (gcry_strdup): Don't copy the string after a malloc
+ error.
+
+2003-11-11 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (sexp_sscan): Implemented "%b" format specifier.
+
+2003-11-11 Moritz Schulte <mo@g10code.com>
+
+ * libgcrypt.m4: Do not set prefix when calling libgcrypt-config.
+ Thanks to Nikos Mavroyanopoulos.
+
+2003-11-08 Moritz Schulte <mo@g10code.com>
+
+ * cipher.h (small_prime_numbers): Removed declaration.
+ (PUBKEY_FLAG_NO_BLINDING): Put braces around shift.
+
+2003-11-04 Werner Koch <wk@gnupg.org>
+
+ * cipher.h (_gcry_sha1_has_buffer): New.
+
+ * gcrypt.h (gcry_create_nonce): New.
+
+2003-10-31 Werner Koch <wk@gnupg.org>
+
+ * libgcrypt.vers (_gcry_generate_elg_prime): Removed this symbol;
+ gnutls does not need it anymore.
+
+ * secmem.c (mb_get_new): s/pool/block/ due to global pool.
+
+ * misc.c (gcry_set_log_handler): s/logf/f/ to avoid shadowing
+ warning against a builtin.
+
+ * ath-pth-compat.c: cast pth_connect to get rid of the const
+ prototype.
+
+2003-10-27 Werner Koch <wk@gnupg.org>
+
+ * ath.h (ATH_MUTEX_INITIALIZER): Removed spurious semicolon.
+
+2003-10-27 Moritz Schulte <mo@g10code.com>
+
+ * libgcrypt-config.in: Include libs/cflags of libgpg-error.
+
+ * sexp.c (sexp_sscan): Cleaned up, deallocate scanned sexp on
+ error.
+
+ * module.c (MODULE_ID_MIN): New symbol, use it.
+
+2003-10-27 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (gcry_pk_testkey): Doc fix.
+
+2003-09-29 Moritz Schulte <mo@g10code.com>
+
+ * libgcrypt-config.in: Fix --algorithms option.
+
+2003-10-23 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (gcry_err_code): Use GPG_ERR_INLINE instead of
+ __inline__.
+
+ * secmem.c (lock_pool): Don't print the warning for certain
+ systems, handle ENOMEM.
+
+2003-10-21 Werner Koch <wk@gnupg.org>
+
+ * secmem.c (_gcry_secmem_dump_stats): Fixed format sepcifier for a
+ size_t. Reported by Stephane Corthesy.
+
+2003-10-10 Werner Koch <wk@gnupg.org>
+
+ * global.c (_gcry_malloc): Handle the no_secure_memory option.
+
+ * gcrypt.h (gcry_prime_group_generator): New.
+ (gcry_prime_release_factors): New.
+
+2003-10-07 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (sexp_sscan): Check that parenthesis are matching.
+
+2003-09-28 Moritz Schulte <mo@g10code.com>
+
+ * g10lib.h: Declare: _gcry_malloc.
+ (GCRY_ALLOC_FLAG_SECURE): New symbol.
+
+ * global.c (_gcry_malloc): New function...
+ (gcry_malloc): ... use it.
+ (gcry_malloc_secure): Likewise.
+
+ * ath.c: Change License to LGPL.
+ * ath-pthread-compat.c: Likewise.
+ * ath-pthread.c: Likewise.
+ * ath-pth-compat.c: Likewise.
+ * ath-pth.c: Likewise.
+ * ath.h: Likewise.
+ * ath-compat.c: Likewise.
+
+ * secmem.c (_gcry_secmem_realloc): Do not forget to release secmem
+ lock. Thanks to low halo for triggering this bug.
+
+2003-09-04 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (_GCRY_ERR_SOURCE_DEFAULT): Removed cruft.
+ (gcry_prime_check_func_t): Renamed arg for clarity.
+
+2003-09-02 Moritz Schulte <mo@g10code.com>
+
+ * gcrypt.h (GCRY_PRIME_FLAG_SPECIAL_FACTOR): New symbol.
+
+2003-09-01 Moritz Schulte <mo@g10code.com>
+
+ * gcrypt.h (gcry_random_level_t): New type.
+ (gcry_prime_check_func_t): Likewise.
+ (GCRY_PRIME_FLAG_SECRET): New symbol.
+ (gcry_prime_generate, gcry_prime_check): Declare functions.
+
+2003-08-28 Werner Koch <wk@gnupg.org>
+
+ * Makefile.am (libgcrypt_pth_la_LDFLAGS): Removed PTH_CFLAGS cruft.
+
+2003-08-27 Moritz Schulte <mo@g10code.com>
+
+ * global.c (gcry_control): Remove call to ath_deinit.
+
+ * Makefile.am (libgcrypt_real_la_DEPENDENCIES): Fixed.
+ (libgcrypt_real_la_LIBADD): Fixed.
+ Removed unecessary variables.
+
+ * libgcrypt-config.in: Adjusted script for new thread handling.
+
+ * Makefile.am: New version, based on GPGMEs Makefile.am.
+
+ * ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
+ ath-pthread.c, ath-pthread-compat.c: New files, merged from GPGME.
+ * ath.c, ath.h, ath-pthread.c, ath-pth.c: Removed files.
+
+2003-08-08 Moritz Schulte <moritz@g10code.com>
+
+ * global.c (gcry_realloc): Remove FIXME about `clearing out
+ realloced memory', since _gcry_secmem_realloc takes care of
+ overwriting old memory.
+
+2003-08-07 Werner Koch <wk@gnupg.org>
+
+ * module.c (_gcry_module_release): Don't act if module is NULL.
+
+2003-07-30 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (enum gcry_ac_id): Added: GCRY_AC_ELG_E.
+ Reverted change: use gcry_md_flags enumeration list instead of
+ defines.
+
+2003-07-29 Werner Koch <wk@gnupg.org>
+
+ * global.c (gcry_control): Add GCRYCTL_SET_RANDOM_SEED_FILE and
+ GCRYCTL_UPDATE_RANDOM_SEED_FILE.
+ * gcrypt.h: Ditto. Renamed index to idx, so avoid warning
+ related to the old index function.
+
+2003-07-28 Moritz Schulte <moritz@g10code.com>
+
+ * global.c (gcry_err_code_from_errno, gcry_err_code_to_errno)
+ (gcry_err_make_from_errno, gcry_error_from_errno): New functions.
+
+ * gcrypt.h: Declared: gcry_err_code_from_errno,
+ gcry_err_code_to_errno, gcry_err_make_from_errno,
+ gcry_error_from_errno.
+
+ * Makefile.am (include_HEADERS): Added: gcrypt-module.h.
+
+ * gcrypt.h: Include <gcrypt-module.h>.
+
+ * gcrypt-module.h: New file.
+
+2003-07-27 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (gcry_mpi_scan, gcry_mpi_print): API change.
+ (gcry_mpi_dump): New.
+
+2003-07-21 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h: Declared: gcry_ac_key_data_get.
+ (gcry_pk_spec): Renamed member `sexp_names' into `aliases'.
+
+2003-07-20 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (gcry_md_oid_spec_t): New type.
+ (gcry_md_spec): New member: oids.
+
+2003-07-19 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (gcry_cipher_oid_spec_t): New type.
+ (gcry_cipher_spec): New member: oids;
+
+2003-07-18 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (gcry_mpi_set_opaque): Add a warning comment.
+
+2003-07-15 Moritz Schulte <moritz@g10code.com>
+
+ * secmem.c (compress_pool): Remove function, since unused blocks
+ are automatically concatenad.
+
+ * gcrypt.h: Bumped version number up to 1.1.42-cvs.
+
+2003-07-14 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (gcry_cipher_spec): New member: aliases.
+
+ * Makefile.am (noinst_PROGRAMS, testapi_SOURCES, testapai_LDADD,
+ benchmark_SOURCES, benchmark_LDADD): Removed.
+
+ * benchmark.c, testapi.c: Removed files.
+
+ * mpi.h: Removed disabled typedef.
+ * g10lib.h: Likewise.
+
+ * benchmark.c, g10lib.h, gcrypt.h, global.c, module.c, sexp.c:
+ Used gcry_err* wrappers for libgpg-error symbols.
+
+2003-07-12 Moritz Schulte <moritz@g10code.com>
+
+ * global.c: Likewise.
+
+ * gcrypt.h: New type: gcry_error_t, gcry_err_code_t and
+ gcry_err_source_t.
+ (gcry_err_make, gcry_error, gcry_err_code, gcry_err_source): New
+ functions.
+
+ * global.c (gcry_strerror): New function.
+ (gcry_strsource): New function.
+
+ * gcrypt.h: New symbol: GCRY_CIPHER_TWOFISH128.
+
+2003-07-09 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (enum gcry_md_flags): Removed, used define instead,
+ since that is more common than an enumeration list when it comes
+ to flags that can be bitwise ORed.
+
+2003-07-08 Moritz Schulte <moritz@g10code.com>
+
+ * global.c: Use new types for handlers.
+
+ * gcrypt.h: Declare: gcry_ac_data_copy.
+
+2003-07-07 Moritz Schulte <moritz@g10code.com>
+
+ * sexp.c (gcry_sexp_build_array): Use dummy argument pointer.
+ Thanks to Simon Josefsson <jas@extunde.com>.
+
+ * gcrypt.h: Declare: gcry_cipher_list, gcry_pk_list, gcry_md_list.
+
+2003-07-05 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h: Declare: gcry_cipher_register, gcry_cipher_unregister,
+ gcry_md_register, gcry_md_unregister, gcry_pk_register,
+ gcry_pk_unregister.
+ (gcry_cipher_spec): Removed member: algorithm.
+ (gcry_pk_spec): Likewise.
+ (gcry_md_spec): Likewise.
+ Adjusted declarations: gcry_cipher_register, gcry_pk_register,
+ gcry_md_register.
+
+ * module.c: Replaced all occurences of `id' with `mod_id', since
+ `id' is a keyword in obj-c.
+
+ * gcrypt.h (gcry_cipher_spec): Renamed member `id' to `algorithm'.
+ (gcry_pk_spec): Likewise.
+ (gcry_md_spec): Likewise.
+
+ * cipher.h: Removed types: gcry_pubkey_generate_t,
+ gcry_pubkey_check_secret_key_t, gcry_pubkey_encrypt_t,
+ gcry_pubkey_decrypt_t, gcry_pubkey_sign_t, gcry_pubkey_verify_t,
+ gcry_pubkey_get_nbits_t, gcry_pk_spec_t, gcry_digest_init_t,
+ gcry_digest_write_t, gcry_digest_final_t, gcry_digest_read_t,
+ gcry_digest_spec_t, gcry_cipher_setkey_t, gcry_cipher_encrypt_t,
+ gcry_cipher_decrypt_t, gcry_cipher_stencrypt_t,
+ gcry_cipher_stdecrypt_t, gcry_cipher_spec_t.
+
+ * gcrypt.h: New types: gcry_pk_generate_t,
+ gcry_pk_check_secret_key_t, gcry_pk_encrypt_t, gcry_pk_decrypt_t,
+ gcry_pk_sign_t, gcry_pk_verify_t, gcry_pk_get_nbits_t,
+ gcry_pk_spec_t, gcry_md_init_t, gcry_md_write_t, gcry_md_final_t,
+ gcry_md_read_t, gcry_md_spec_t, gcry_cipher_setkey_t,
+ gcry_cipher_encrypt_t, gcry_cipher_decrypt_t,
+ gcry_cipher_stencrypt_t, gcry_cipher_stdecrypt_t,
+ gcry_cipher_spec_t, gcry_module_t.
+
+2003-07-04 Moritz Schulte <moritz@g10code.com>
+
+ * module.c (_gcry_module_list): New function.
+
+2003-07-02 Moritz Schulte <moritz@g10code.com>
+
+ * module.c (_gcry_module_lookup): Fixed typo.
+
+ * gcrypt.h: Added all definitions and declarations necessary for
+ the new ac interface.
+
+2003-06-30 Moritz Schulte <moritz@g10code.com>
+
+ * g10lib.h: Added declarations: _gcry_pk_module_lookup,
+ _gcry_pk_module_release.
+
+2003-06-18 Werner Koch <wk@gnupg.org>
+
+ * benchmark.c (cipher_bench): Adjusted for new API of get_blklen
+ and get_keylen.
+
+ * gcrypt.h (gcry_cipher_get_algo_blklen)
+ (gcry_cipher_get_algo_keylen): Replaced macro by funcion.
+
+2003-06-18 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.h: Renamed types GcryDigestSpec, GcryCipherSpec and
+ GcryPubkeySpec into: gcry_digest_spec_t, gcry_cipher_spec_t and
+ gcry_pubkey_spec_t.
+ (gcry_pubkey_spec): Defined member `id' as unsigned.
+ (gcry_digest_spec): Likewise.
+ (gcry_cipher_spec): Likewise.
+
+ * module.c (_gcry_module_id_new): New function.
+ (_gcry_module_add): Generate a new ID via _gcry_module_id_new in
+ case `id' is zero.
+
+ * g10lib.h, module.c: Replace old type GcryModule with newer one:
+ gcry_module_t.
+
+ * module.c (_gcry_module_add): Added argument `id', use it.
+
+ * g10lib.h: Added declaration: _gcry_module_lookup_id.
+ (_gcry_module_add): Added argument `id'.
+
+ * module.c (_gcry_module_lookup_id): New function.
+
+ * g10lib.h (struct gcry_module): New member: id.
+
+ * gcrypt.h: New type: gcry_handler_progress_t,
+ gcry_handler_alloc_t, gcry_haandler_secure_check_t,
+ gcry_handler_realloc_t, gcry_handler_free_t,
+ gcry_handler_no_mem_t, gcry_handler_error_t, gcry_handler_log_t.
+ Use new types.
+
+ * cipher.h: Include <gcrypt.h>.
+ New types: gcry_pk_generate_t, gcry_pk_check_secret_key_t,
+ gcry_pk_encrypt_t, gcry_pk_decrypt_t, gcry_pk_sign_t,
+ gcry_pk_verify_t, gcry_pk_get_nbits_t, gcry_md_init_t,
+ gcry_md_write_t, gcry_md_final_t, gcry_md_read_t,
+ gcry_cipher_setkey_t, gcry_cipher_encrypt_t,
+ gcry_cipher_decrypt_t, gcry_cipher_stencrypt_t,
+ gcry_cipher_stdecrypt_t.
+ Use new types.
+
+2003-06-17 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (AM_CFLAGS): Added: @GPG_ERROR_CFLAGS@.
+
+2003-06-16 Moritz Schulte <moritz@g10code.com>
+
+ * g10lib.h: Replace last occurences of old type names with newer
+ names (i.e. replace MPI with gcry_mpi_t).
+ * mpi.h: Likewise.
+ * sexp.c: Likewise.
+
+2003-06-15 Moritz Schulte <moritz@g10code.com>
+
+ * testapi.c (test_genkey): Use gpg_strerror instead of
+ gcry_strerror.
+
+ * global.c (gcry_control): Fixed typo.
+
+ * misc.c (_gcry_fatal_error): Use gpg_strerror instead of
+ gcry_strerror.
+
+ * types.h (STRLIST): Removed type since it is not used.
+
+2003-06-11 Moritz Schulte <moritz@g10code.com>
+
+ * global.c (global_init): Call: _gcry_cipher_init, _gcry_md_init,
+ _gcry_pk_init.
+
+ * g10lib.h: Declare: _gcry_cipher_init, _gcry_md_init,
+ _gcry_pk_init.
+
+ * global.c (gcry_strerror): Remove compatibility code.
+
+ * Makefile.am: Remove support libgpg-error special handling.
+ (AM_CPPFLAGS): Add @GPG_ERROR_CFLAGS@
+
+ * gcrypt.h: Likewise.
+
+2003-06-13 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (gcry_md_get_algo): Reverted to old API. This is a
+ convenience function anyway and error checking is not approriate.
+ (gcry_md_is_enabled): New.
+ (gcry_md_is_secure): Replaced macro by function and reverted to old
+ API.
+
+2003-06-11 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (GCRYERR): Define _GCRY_ERR_SOURCE_DEFAULT instead of
+ GPG_ERR_SOURCE_DEFAULT, so that libgpg-error still works despite
+ the use of the old gcrypt error codes.
+ (gcry_md_copy): Swapped arguments.
+
+2003-06-09 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am: Support for libgpg-error.
+
+2003-06-08 Moritz Schulte <moritz@g10code.com>
+
+ * sexp.c (gcry_sexp_create): Expect sane error values from
+ gcry_sexp_canon_len instead of the `historical' values.
+
+2003-06-07 Moritz Schulte <moritz@g10code.com>
+
+ * ath.c, ath.c, ath-pth.c, ath-pthread.c, benchmark.c, cipher.h,
+ g10lib.h, gcrypt.h, global.c, misc.c, missing-string.c, module.c,
+ mpi.h, secmem.c, secmem.h, sexp.c, stdmem.c, stdmem.h, testapi.c,
+ types.h: Edited all preprocessor instructions to remove whitespace
+ before the '#'. This is not required by C89, but there are some
+ compilers out there that don't like it. Replaced any occurence of
+ the now deprecated type names with the new ones.
+
+ * gcrypt.h: Re-organized checking for gcc features; New macro:
+ _GCRY_GCC_ATTR_DEPRECATED.
+ Include copy of libgpg-error's gpg-error.h in order to make it
+ easy to build libgcrypt without needing libgpg-error.h.
+
+ (GCRY_MPI, GcryMPI, GCRY_SEXP, GcrySexp, GCRY_CIPHER_HD,
+ GcryCipherHd, GCRY_MD_HD, GcryMDHd): Declared deprecated.
+ (gcry_mpi_t, gcry_sexp_t, gcry_cipher_hd_t, gcry_md_hd_t): New
+ types.
+
+2003-06-04 Moritz Schulte <moritz@g10code.com>
+
+ * sexp.c (sexp_sscan): New argument: arg_list, adjusted all
+ callers.
+ (ARG_NEXT): New macro.
+ (sexp_sscan): Use ARG_NEXT for receiving format string arguments.
+ (gcry_sexp_build_array): New function.
+
+2003-06-02 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h: Added some comments describing the gcry_sexp_*
+ functions.
+ Include <gpg-error.h> instead of <gpg/error.h>.
+
+2003-06-01 Moritz Schulte <moritz@g10code.com>
+
+ * sexp.c (OLDPARSECODE): Removed macro...
+ (gcry_sexp_canon_len): ... and do not use it.
+
+ * gcrypt.h (gcry_errno): Removed declaration.
+
+ * g10lib.h (string_to_pubkey_algo, pubkey_algo_to_string,
+ pubkey_nbits): Removed declarations for non-existing functions.
+
+2003-05-31 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.h (is_RSA, is_ELGAMAL): Removed macros.
+
+ * g10lib.h (set_lasterr): Removed macro.
+ (_gcry_set_lasterr): Removed declaration.
+
+ * gcrypt.h: Changed declarations for: gcry_pk_algo_info,
+ gcry_md_open, gcry_md_copy, gcry_md_algo_info, gcry_md_info,
+ gcry_md_get_algo, gcry_random_add_bytes.
+
+ (gcry_md_is_secure): Adjust macro for new API.
+
+2003-05-29 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h: Changed declarations for: gcry_cipher_open,
+ gcry_cipher_info, gcry_cipher_algo_info.
+ (gcry_cipher_get_algo_keylen): Adjuster for new
+ gcry_cipher_algo_info interface.
+ (gcry_cipher_get_algo_blklen): Likewise.
+
+ * global.c (gcry_errno): Removed function.
+ (gcry_strerror): Do not use gcry_errno.
+ (_gcry_set_lasterr): Removed function.
+ (last_ec): Removed variable.
+
+2003-05-27 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (enum gcry_cipher_algos): Make Serpent IDs do not
+ conflict with OpenPGP. Reported by Timo Schulz.
+
+ * global.c (gcry_control): Fixed name of enum list.
+
+2003-05-25 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.h (gcry_cipher_spec): Adjust return type of `setkey' for
+ libgpg-error.
+ (gcry_pubkey_spec): Adjust return type of `generate',
+ `check_secret_key', `encrypt', `decrypt', `sign' and `verify' for
+ libgpg-error.
+
+ * sexp.c (gcry_sexp_canon_len): Adjusted for libgpg-error.
+ (gcry_sexp_create): Likewise.
+ (gcry_sexp_new): Likewise.
+ (sexp_sscan): Likewise.
+ (gcry_sexp_build): Likewise.
+ (gcry_sexp_sscan): Likewise.
+
+ * module.c (_gcry_module_add): Likewise.
+
+ * global.c (last_ec): Change type to gpg_error_t.
+ (gcry_control): Adjust for libgpg-error.
+ (gcry_errno): Likewise.
+ (gcry_strerror): Likewise.
+ (_gcry_set_lasterr): Likewise.
+ (gcry_xmalloc): Likewise.
+ (gcry_xrealloc): Likewise.
+
+2003-05-22 Moritz Schulte <moritz@g10code.com>
+
+ * types.h: Merged code from GnuPG regarding U64_C.
+
+ * missing-string.c (strsep): Removed function.
+
+ * g10lib.h: Removed declarations: strsep, strlwr.
+
+ * secmem.c (secmem_lock): New variable.
+ (SECMEM_LOCK, SECMEM_UNLOCK): New macros.
+ (_gcry_secmem_set_flags): Use SECMEM_LOCK and SECMEM_UNLOCK.
+ (_gcry_secmem_get_flags): Likewise.
+ (_gcry_secmem_init): Likewie.
+ (_gcry_secmem_malloc): Likewise.
+ (_gcry_secmem_free): Likewise.
+ (_gcry_secmem_malloc): Renamed to ...
+ (_gcry_secmem_malloc_internal): ... this.
+ (_gcry_secmem_malloc): New function, use SECMEM_LOCK,
+ SECMEM_UNLOCK, call _gcry_secmem_malloc_internal.
+ (_gcry_secmem_free): Renamed to ...
+ (_gcry_secmem_free_internal): ... this.
+ (_gcry_secmem_free): New function, use SECMEM_LOCK, SECMEM_UNLOCK,
+ call _gcry_secmem_free_internal.
+ (_gcry_secmem_realloc): Use SECMEM_LOCK, SECMEM_UNLOCK, call
+ _gcry_secmem_malloc_internal and _gcry_secmem_free_internal.
+ (_gcry_private_is_secure): Use SECMEM_LOCK, SECMEM_UNLOCK.
+ (_gcry_secmem_dump_stats): Likewise.
+ (_gcry_secmem_malloc_internal): Removed unused variable:
+ compressed.
+ Include "ath.h".
+
+2003-05-21 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (GCRY_CIPHER_SERPENT128, GCRY_CIPHER_SERPENT192,
+ GCRY_CIPHER_SERPENT256): New symbols.
+
+2003-05-19 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h: Reversed changes from 2003-03-03 since they would have
+ been an unnecessary ABI break.
+
+2003-05-13 Moritz Schulte <moritz@g10code.com>
+
+ * secmem.c (stats_update): New function.
+ (BLOCK_HEAD_SIZE): New symbol.
+ (MB_FLAG_ACTIVE): New symbol.
+ (ADDR_TO_BLOCK, BLOCK_VALID): New macros.
+ (mb_get_next): New function.
+ (mb_get_prev): New function.
+ (mb_merge): New function.
+ (mb_get_new): New function.
+ (unused_blocks): Removed variable.
+ (init_pool): Initialize new memory pool.
+ (_gcry_secmem_malloc): Use new heap management code.
+ (_gcry_secmem_free): Likewise.
+ (_gcry_secmem_realloc): Likewise.
+ Renamed type MEMBLOCK to memblock_t.
+
+2003-04-27 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.h (gcry_pubkey_spec): New member: sexp_names.
+
+2003-04-23 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.h (gcry_pubkey_spec): Removed members: npkey, nskey,
+ nenc, nsig.
+ (gcry_pubkey_spec): Added members: elements_pkey, elements_skey,
+ elements_enc, elements_sig, elements_grip.
+
+2003-04-17 Moritz Schulte <moritz@g10code.com>
+
+ * g10lib.h (GcryModule): New typedef.
+
+ * gcrypt.h (gcry_cipher_register, gcry_cipher_unregister,
+ gcry_digest_register, gcry_digest_unregister,
+ gcry_pubkey_register, gcry_pubkey_unregister): Function
+ declarations removed - for now.
+
+ * gcrypt.h (GcryModule): Declaration removed.
+ * gcrypt.h (GcryPubkeySpec, GcryDigestSpec, GcryCipherSpec):
+ Types Moved...
+ * cipher.h: ... here.
+
+2003-04-17 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.h: Declare digest_spec_sha512 and digest_spec_384.
+
+2003-04-16 Moritz Schulte <moritz@g10code.com>
+
+ * module.c (_gcry_module_use): New function.
+ * g10lib.h (_gcry_module_use): Declare function.
+
+ * libgcrypt-config.in: Support for --algorithms switch, which
+ prints the algorithms included in the built libgcrypt.
+
+ * global.c (gcry_set_progress_handler): Register progress
+ functions depending on the enabled algorithms.
+
+2003-04-07 Moritz Schulte <moritz@g10code.com>
+
+ * Makefile.am (libgcrypt_la_SOURCES): Added module.c
+
+ * module.c: New file.
+ (_gcry_module_add): New function.
+ (_gcry_module_drop): New function.
+ (_gcry_module_lookup): New function.
+ (_gcry_module_release): New function.
+
+ * g10lib.h (GcryModule): New types.
+ (FLAG_MODULE_DISABLED): New symbol.
+ Added declarations for _gcry_module_add, _gcry_module_release and
+ _gcry_module_lookup.
+
+ * gcrypt.h: New types: GcryPubkeySpec, GcryDigestSpec,
+ GcryCipherSpec.
+ Added declarations for: gcry_cipher_register,
+ gcry_cipher_unregister, gcry_digest_register,
+ gcry_digest_unregister, gcry_pubkey_register and
+ gcry_pubkey_unregister.
+
+ * cipher.h: Removed symbols: CIPHER_ALGO_NONE, CIPHER_ALGO_IDEA,
+ CIPHER_ALGO_3DES, CIPHER_ALGO_CAST5, CIPHER_ALGO_BLOWFISH,
+ CIPHER_ALGO_SAFER_SK128, CIPHER_ALGO_DES_SK, CIPHER_ALGO_TWOFISH,
+ CIPHER_ALGO_TWOFISH_OLD, CIPHER_ALGO_DUMMY, PUBKEY_USAGE_SIG,
+ PUBKEY_USAGE_ENC, DIGEST_ALGO_MD5, DIGEST_ALGO_SHA1,
+ DIGEST_ALGO_RMD160, DIGEST_ALGO_TIGER, PUBKEY_ALGO_RSA,
+ PUBKEY_ALGO_RSA_E, PUBKEY_ALGO_RSA_S, PUBKEY_ALGO_DSA,
+ PUBKEY_ALGO_ELGAMAL, PUBKEY_ALGO_ELGAMAL_E.
+
+2003-04-02 Moritz Schulte <moritz@g10code.com>
+
+ * benchmark.c (md_bench): Fix error message.
+
+2003-03-31 Moritz Schulte <moritz@g10code.com>
+
+ * benchmark.c (cipher_bench): Added CTR mode.
+
+2003-03-30 Simon Josefsson <jas@extundo.com>
+
+ * gcrypt.h (enum gcry_control_cmds): Add GCRY_SET_CTR.
+ (enum gcry_cipher_modes): Add GCRY_CIPHER_MODE_CTR.
+ (gcry_cipher_setctr): New macro to set counter.
+
+2003-03-19 Moritz Schulte <moritz@g10code.com>
+
+ * cipher.h (PUBKEY_FLAG_NO_BLINDING): New symbol.
+
+2003-03-22 Simon Josefsson <jas@extundo.com>
+
+ * gcrypt.h: Add GCRYCTL_SET_CBC_MAC and GCRY_CIPHER_CBC_MAC.
+
+2003-03-19 Werner Koch <wk@gnupg.org>
+
+ * g10lib.h: Adjusted primegen.c prototypes.
+
+2003-03-12 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (sexp_sscan): Initialize NM. Thanks to Ian Peters for
+ valgrinding this.
+
+2003-03-06 Moritz Schulte <mo@g10code.com>
+
+ * secmem.h (GCRY_SECMEM_FLAG_NO_WARNING,
+ GCRY_SECMEM_FLAG_SUSPEND_WARNING): New symbols.
+
+ * global.c (gcry_control): Use
+ GCRY_SECMEM_FLAG_{NO,SUSPEND}_WARNING, instead of hard-coded
+ values.
+ * secmem.c (_gcry_secmem_set_flags): Likewise.
+ * secmem.c (_gcry_secmem_get_flags): Likewise.
+
+2003-03-03 Moritz Schulte <moritz@g10code.com>
+
+ * misc.c: Removed old FIXME, since there is already a function to
+ set the value of `verbosity_level'.
+
+ * gcrypt.h: Removed enumeration list: gcry_ctl_cmds.
+ New enumeration lists: gcry_global_control_cmds,
+ gcry_control_cmds, gcry_info_cmds, gcry_algo_info_cmds.
+
+2003-03-02 Moritz Schulte <moritz@g10code.com>
+
+ * gcrypt.h (gcry_cipher_reset): New macro for resetting a handle.
+
+2003-02-28 Moritz Schulte <moritz@g10code.com>
+
+ * secmem.c (DEFAULT_PAGESIZE): New symbol.
+ (init_pool): Use DEFAULT_PAGESIZE.
+
+2003-02-23 Moritz Schulte <moritz@g10code.com>
+
+ * secmem.h: Fix typo in declaration of _gcry_secmem_term.
+
+ * sexp.c: Move macro definitions of `digitp', `octdigit', `alphap'
+ and `hexdigit' ...
+ * g10lib.h: ... here.
+
+ * misc.c (_gcry_burn_stack): New function (former name:
+ burn_stack).
+
+ * g10lib.h (burn_stack): Declare _gcry_burn_stack().
+
+2003-01-24 Werner Koch <wk@gnupg.org>
+
+ * global.c (gcry_set_progress_handler): Register a random progress
+ handler.
+
+2003-01-23 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (GCRY_ENABLE_QUICK_RANDOM): New.
+ * global.c (gcry_control): Make use of it.
+
+2003-01-21 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (gcry_random_add_bytes): Add QUALITY argument.
+
+2003-01-21 Timo Schulz <twoaday@freakmail.de>
+
+ * gcrypt.h (gcry_random_add_bytes): New.
+
+2003-01-20 Simon Josefsson <jas@extundo.com>
+
+ * gcrypt.h (gcry_md_algos): Add GCRY_MD_CRC32,
+ GCRY_MD_CRC32_RFC1510, GCRY_MD_CRC24_RFC2440.
+
+2003-01-16 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (gcry_md_write): Changed type of 2nd argument to void*.
+ (gcry_md_hash_buffer): Changed type of both buffers to void*.
+ (gcry_md_setkey): Changed type of 2nd argument to void*.
+ (gcry_md_get_asnoid): New.
+
+2003-01-15 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (gcry_sexp_length): Fixed. This was seriously broken.
+
+2003-01-14 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (GCRYERR_INV_FLAG), global.c (gcry_strerror): New.
+
+2003-01-02 Werner Koch <wk@gnupg.org>
+
+ * libgcrypt.vers: Temporary export _gcry_generate_elg_prime for
+ use by GNUTLS.
+
+2002-12-21 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: Make use of gcc's pure and malloc attributes
+ (gcry_md_putc): Use a helper variable to avoid multiple
+ evaluation of H.
+ * g10lib.h, stdmem.h, secmem.h: Use gcc attributes pure and malloc.
+
+ * stdmem.c (use_m_guard): Don't default to yes.
+
+2002-12-19 Werner Koch <wk@gnupg.org>
+
+ * global.c (global_init): The meat was never run due to a faulty
+ check. Thanks to Nikos for pointing this out.
+
+ * global.c (gcry_control): Return 1 and not -1 for the
+ initialization tests.
+
+ * libgcrypt.vers: New.
+ * Makefile.am: Use this instead of the build symbol file.
+
+ * global.c (gcry_control) <initialization>: Call the random module
+ initializer to make sure that the pool lock flag has been
+ initialized.
+
+2002-12-09 Werner Koch <wk@gnupg.org>
+
+ * global.c (gcry_calloc,gcry_calloc_secure): Check for overflow.
+ Noted by Florian Weimer.
+
+2002-11-10 Simon Josefsson <jas@extundo.com>
+
+ * gcrypt.h (gcry_ctl_cmds): New GCRYCTL_SET_CBC_CTS control flag.
+ (gcry_cipher_flags): New GCRY_CIPHER_CBC_CTS gcry_cipher_open() flag.
+ (gcry_cipher_cts): New macro for toggling CTS.
+
+2002-11-10 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (GCRY_MD_MD4): New. We use a non OpenPGP value here.
+
+2002-09-20 Werner Koch <wk@gnupg.org>
+
+ * ath.c: Include sys.time.h if sys/select.h does not exist.
+ (ath_select, ath_waitpid): Shortcut for Windows.
+ * ath.h: Include some Windows headers. By Timo.
+
+2002-09-18 Werner Koch <wk@gnupg.org>
+
+ * ath.h: Prefix ath_deinit.
+
+2002-09-17 Werner Koch <wk@gnupg.org>
+
+ * benchmark.c: New.
+ (mpi_bench, do_powm): Add a a simple test for RSA.
+
+ * global.c (global_init): New. Use it instead of the setting
+ any_init_done. Initialize the ATH system.
+ (gcry_check_version): Hook global_init in. This is the suggested
+ way to initialize the library.
+ (_gcry_no_internal_locking): Removed. We simply call a ath_deinit
+ and leave it to ATH to disbale the locking.
+
+ * ath.c, ath.h, ath-pth.c, ath-pthread.c: New. Taken from GPGME.
+ * mutex.h: Removed.
+ * Makefile.am (ath_components): New.
+
+2002-09-16 Werner Koch <wk@gnupg.org>
+
+ * secmem.c (_gcry_secmem_dump_stats): Replaced fprintf by log_*.
+
+2002-08-23 Werner Koch <wk@gnupg.org>
+
+ * missing-string.c: Removed unneeded strlwr.
+
+ * libgcrypt.m4: Made much more simple.
+ * libgcrypt-config.in: Made --prefix work for --libs.
+
+2002-08-14 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: Add GCRY_CIPGER_DES. Included string.h for size_t.
+ Suggested by Simon Josefsson.
+
+2002-07-25 Werner Koch <wk@gnupg.org>
+
+ * cipher.h: Added prototypes for progress functions.
+ * global.c: Include cipher.h for those prototypes.
+
+ * stdmem.c (_gcry_private_realloc): Replaced void* by char * for
+ pointer arithmetic reasons. Noted by Stephan Austermuehle.
+
+2002-06-24 Werner Koch <wk@gnupg.org>
+
+ * missing-string.c: Include ctype.h.
+
+ * gcrypt.h (gcry_mpi_invm, gcry_mpi_div, gcry_mpi_mod)
+ (gcry_mpi_swap): New.
+
+2002-06-18 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: Added a bunch of brief function descriptions.
+
+2002-05-21 Werner Koch <wk@gnupg.org>
+
+ * misc.c (_gcry_log_printf): Don't initialize a va_list. Noted by
+ Jeff Johnson.
+
+ * global.c (gcry_set_progress_handler): New.
+
+ * gcrypt.h: Replaced the typedef for byte.
+
+2002-05-16 Werner Koch <wk@gnupg.org>
+
+ * missing-string.c: New.
+
+ * gcrypt.h: Add new error codes GCRYERR_SEXP_ and typedefs
+ GcryMPI, GcrySexp, GcryCipherHd, GcryMDHd as aliases for the old
+ ones using an underscore.
+
+ * global.c (gcry_strerror): Add strings fro the new error codes.
+ * sexp.c (gcry_sexp_canon_len): Use a macro to convert from new to
+ old error codes.
+ (gcry_sexp_create,gcry_sexp_new): New.
+
+2002-05-15 Werner Koch <wk@gnupg.org>
+
+ * mutex.h (DEFINE_LOCAL_MUTEX): Macro to define a mutex and
+ initialize it so that we can detect an unitialized mutex and don't
+ read from stdin.
+
+2002-05-14 Werner Koch <wk@gnupg.org>
+
+ Changed license of all files to the LGPL.
+
+2002-05-07 Werner Koch <wk@gnupg.org>
+
+ * global.c (gcry_control): Add commands
+ GCRYCTL_ANY_INITIALIZATION_P and GCRYCTL_INITIALIZATION_FINISHED_P
+ so that other libraries are able to check for required
+ initializations.
+
+2002-05-02 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h (GCRYCTL_DISABLE_INTERNAL_LOCKING): New.
+ * global.c (gcry_control): Implement it.
+ (_gcry_no_internal_locking): New.
+ * mutex.h: Prefixed all fucntions with _gcry_. Bypass all
+ functions when desired.
+
+ * gcrypt.h (GCRYCTL_DISABLE_SECMEM): New.
+ * global.c (gcry_control,gcry_malloc_secure,gcry_is_secure):
+ Implement it here.
+ * secmem.c (_gcry_private_is_secure): Return false if the pool is
+ not initialized.
+
+ * gcrypt.h (GCRYCTL_INITIALIZATION_FINISHED): New.
+
+ * gcrypt.h (gcry_cipher_algos): Replaced RINDAEL by AES and change
+ the macros to expand from rijdael to aes.
+
+ * stdmem.c (_gcry_private_malloc): Return NULL for 0 byte allocation.
+ (_gcry_private_malloc_secure): Ditto.
+
+ * g10lib.h: Copied the JNLIB_GCC macros from ../jnlib/mischelp.h
+ and removed the inclusion of that file.
+
+2002-04-15 Werner Koch <wk@gnupg.org>
+
+ * global.c (gcry_strdup): New.
+
+2002-03-18 Werner Koch <wk@gnupg.org>
+
+ * mutex.h: New file with a portable thread mutex implementation
+ written by Marcus Brinkmann. Taken from GPGME.
+
+2002-02-18 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (gcry_sexp_sscan): Don't initialize the dummy
+ variable. Suggested by Jordi Mallach.
+
+2002-01-31 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (suitable_encoding,convert_to_hex,convert_to_string)
+ (convert_to_token): New.
+ (gcry_sexp_sprint): Better formatting of advanced encoding, does
+ now insert LFs and escapes all unprintable characters.
+ (unquote_string): New.
+ (sexp_sscan): Implemented the missing conversion of quoted strings.
+
+2002-01-26 Werner Koch <wk@gnupg.org>
+
+ * libgcrypt-config.in: Add copyright notice.
+
+2002-01-11 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (gcry_sexp_canon_len): Fixed last change.
+
+2002-01-01 Timo Schulz <ts@winpt.org>
+
+ * stdmem.c (_gcry_private_realloc): If pointer is NULL now realloc
+ behaves like malloc.
+
+2001-12-20 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (gcry_sexp_canon_len): Describe the error codes and
+ return an error if this is not a S-Exp; i.e. it does not start
+ with an open parenthesis.
+
+2001-12-18 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (gcry_sexp_canon_len): Fixed the test on NULL buffer.
+
+ * Makefile.am (DISTCLEANFILES): Include libgcrypt.sym
+
+ * sexp.c: Removed the commented test code because we now have a
+ test in ../tests/
+
+2001-12-17 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (gcry_sexp_canon_len): New.
+
+2001-12-11 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: Fixed AES128 macro, add enum for OFB mode.
+
+2001-12-05 Werner Koch <wk@gnupg.org>
+
+ * misc.c (_gcry_log_printf): New.
+ * sexp.c (dump_string,gcry_sexp_dump): Use logging functions
+ instead of stderr.
+
+2001-11-16 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: New constant GCRYCTL_IS_ALGO_ENABLED.
+
+2001-10-02 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: Removed a couple of trailing commas.
+
+2001-08-28 Werner Koch <wk@gnupg.org>
+
+ * sexp.c (sexp_sscan): Add an argument to enable the
+ arg_ptr. Changed all callers. Suggested by Tom Holroyd.
+
+2001-08-03 Werner Koch <wk@gnupg.org>
+
+ * global.c (gcry_strerror): Updated list of error codes.
+
+2001-07-23 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: Replaced the last ulong. Noted by Rami Lehti.
+
+2001-05-31 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h, mpi.h: Made some mpi functions public.
+
+ * wrapper.c: Removed.
+ * global.c: Renamed all g10_ prefixed functions which had wrappers
+ to gcry_xxx. So we now use the exported memory functions inernally.
+
+ Renamed all g10_ prefixed functions to _gcry_ prefixed ones.
+
+ * g10lib.h (_GCRYPT_IN_LIBGCRYPT): Replace defintion by a test on it.
+
+2001-05-28 Werner Koch <wk@gnupg.org>
+
+ * libgcrypt.m4: Check GCRYPT_VERSION macro and not LIBGCRYPT_VERSION.
+
+ * mpi.h: Removed mpi_fromstr prototype.
+
+2001-01-11 Werner Koch <wk@gnupg.org>
+
+ * Makefile.am (libgcrypt_la_SOURCES): Add mpi.h
+
+2000-12-19 Werner Koch <wk@gnupg.org>
+
+ * types.h: Moved from ../include to here.
+
+ Major change:
+ Removed all GnuPG stuff and renamed this piece of software
+ to gcrypt.
+
+2000-11-14 Werner Koch <wk@gnupg.org>
+
+ * mpi.h: Moved to ../mpi.
+
+ * Makefile.am (OMIT_DEPENDENCIES): Hack to work around dependency
+ problems.
+
+2000-10-11 Werner Koch <wk@gnupg.org>
+
+ * mpi.h: Changed the way mpi_limb_t is defined.
+
+2000-10-10 Werner Koch <wk@gnupg.org>
+
+ * Makefile.am: Take version-info from configure.
+
+2000-10-09 Werner Koch <wk@gnupg.org>
+
+ * gcrypt.h: New cipher mode, new algo Arcfour and new error code
+ GCRYERR_INV_CIPHER_MODE.
+ * global.c (gcry_strerror): New errorcode.
+
+Wed Oct 4 13:16:18 CEST 2000 Werner Koch <wk@openit.de>
+
+ * gcrypt.h (gcry_md_setkey): Replaced macro by function prototype.
+
+Mon Sep 18 16:35:45 CEST 2000 Werner Koch <wk@openit.de>
+
+ * gcrypt.h (GCRYCTL_GET_ALGO_USAGE): New.
+
+ * secmem.c (secmem_realloc): check for failed secmem_malloc. By
+ Matt Kraai.
+
+Mon Jul 31 10:04:47 CEST 2000 Werner Koch <wk@openit.de>
+
+ * sexp.c: Removed the datalen fields from list tags.
+ (gcry_sexp_car_data,gcry_sexp_cdr_data,gcry_sexp_car_mpi,
+ gcry_sexp_cdr_mpi): Removed.
+ (gcry_sexp_nth,gcry_sexp_nth_data,gcry_sexp_nth_mpi): New.
+
+Fri Jul 28 18:19:11 CEST 2000 Werner Koch <wk@openit.de>
+
+ * sexp.c (sexp_sscan): Fixed reallocation to secure memory.
+ (new_empty_list): Removed
+ (gcry_sexp_length): New.
+ (gcry_sexp_enum): Removed.
+ (normalize): New. Reworked the whole thing to use NULL for an empty list.
+ (make_space): New instead of the macro.
+
+Tue Jul 25 17:44:15 CEST 2000 Werner Koch <wk@openit.de>
+
+ * sexp.c: Major rewrite.
+ (gcry_sexp_sscan): Reordered arguments. Moved functionality to ..
+ (sexp_sscan): .. this.
+ (gcry_sexp_build): New.
+ (gcry_sexp_new_name_mpi, gcry_sexp_new_name_data, gcry_sexp_new_data,
+ gcry_sexp_new_mpi): Removed.
+
+Fri Jul 14 19:38:23 CEST 2000 Werner Koch <wk@>
+
+ * gcrypt.h (gcry_md_start_debug, gcry_md_stop_debug): New.
+ (gcry_ctl_cmds): New control values
+
+ * sexp.c (gcry_sexp_sscan): Add hex format parsing.
+
+ * secmem.c (lock_pool): Check for ENOSYS return my mlock() on old SCOs.
+ (pool_is_mmapped): Made volatile.
+ (lock_pool): No more warning for QNX. By Sam Roberts.
+ (lock_pool,secmem_init): Additional check for dropped privs.
+
+2000-03-21 09:18:48 Werner Koch (wk@habibti.gnupg.de)
+
+ * gcrypt.h (gcry_md_setkey): New.
+ (GCRY_MD_FLAG_HMAC): New.
+
+Mon Jan 31 16:37:34 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * Makefile.am: Add g10lib.h
+
+Thu Jan 27 18:00:44 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * sexp.c (gcry_sexp_sscan): Allow NULL for erroff.
+
+Mon Jan 24 22:24:38 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * sexp.c (gcry_sexp_alist): New.
+
+Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de>
+
+ * secmem.c: Moved from ../util to here.
+ * secmem.h: New.
+ * stdmem.c: New. Based on the old ../util/memory.c.
+ * stdmem.h: New.
+
+Wed Dec 8 21:58:32 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * gcrypt.m4: New.
+ * gcrypt-config: New.
+
+ * mpi.h (mpi_get_nbit_info): Removed
+ (mpi_set_nbit_info): Removed.
+ (struct gcry_mpi): Removed the nbits field.
+
+ * misc.c (g10_log_verbosity): New.
+
+ * global.c (g10_xstrdup): New.
+
+ * mpiapi.c: Removed.
+
+ * mpi.h: Moved from ../include to here. Removed some obsolete
+ prototypes and the iobuf.h header.
+ * cipher.h: Moved from ../include to here. Removed the mpi.h header.
+ * g10lib.h: Moved from ../include to here.
+
+Fri Nov 19 17:15:20 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * sexp.c (dump_string): New. Taken from gnupg/util/miscutil.c.
+ (do_dump_list): s/print_string/dump_string/.
+
+ * testapi.c: New.
+
+ * mpiapi.c (gcry_mpi_randomize): Use new random API.
+
+Sat Nov 13 17:44:23 CET 1999 Werner Koch <wk@gnupg.de>
+
+ * gloabl.c (gcry_control): Add cases for dumping random
+ and secmem stats.
+
+Tue Oct 26 14:10:21 CEST 1999 Werner Koch <wk@gnupg.de>
+
+ * pkapi.c: Removed.
+
+ * symapi.c: Removed.
+
+ * g10lib.h: Moved to ../include.
+
+ * mdapi.c: Removed.
+
+Wed Jul 7 13:08:40 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * sexp.c: New.
+
+Tue Dec 8 13:15:16 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * gcrypt.h: New
+ * mpiapi.c: New
+
+
+ Copyright (C) 1998,1999,2000,2001,2002,2003
+ 2004,2005,2008,2009,2011 Free Software Foundation, Inc.
+
+ This file is free software; as a special exception the author gives
+ unlimited permission to copy and/or distribute it, with or without
+ modifications, as long as this notice is preserved.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/grub-core/lib/libgcrypt/src/Makefile.am b/grub-core/lib/libgcrypt/src/Makefile.am
new file mode 100644
index 0000000..9168022
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/Makefile.am
@@ -0,0 +1,143 @@
+# Makefile.am - for gcrypt/src
+# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+# 2006, 2007 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+
+## Process this file with automake to produce Makefile.in
+
+EXTRA_DIST = Manifest libgcrypt-config.in libgcrypt.m4 libgcrypt.vers \
+ gcrypt.h.in libgcrypt.def
+
+bin_SCRIPTS = libgcrypt-config
+m4datadir = $(datadir)/aclocal
+m4data_DATA = libgcrypt.m4
+include_HEADERS = gcrypt.h gcrypt-module.h
+
+lib_LTLIBRARIES = libgcrypt.la
+bin_PROGRAMS = dumpsexp hmac256
+if USE_RANDOM_DAEMON
+sbin_PROGRAMS = gcryptrnd
+bin_PROGRAMS += getrandom
+endif USE_RANDOM_DAEMON
+
+# Depending on the architecture some targets require libgpg-error.
+if HAVE_W32CE_SYSTEM
+arch_gpg_error_cflags = $(GPG_ERROR_CFLAGS)
+arch_gpg_error_libs = $(GPG_ERROR_LIBS)
+else
+arch_gpg_error_cflags =
+arch_gpg_error_libs =
+endif
+
+
+if HAVE_LD_VERSION_SCRIPT
+ libgcrypt_version_script_cmd = -Wl,--version-script=$(srcdir)/libgcrypt.vers
+else
+ libgcrypt_version_script_cmd =
+endif
+
+libgcrypt_la_CFLAGS = $(GPG_ERROR_CFLAGS)
+libgcrypt_la_SOURCES = g10lib.h visibility.c visibility.h types.h \
+ cipher.h cipher-proto.h \
+ misc.c global.c sexp.c hwfeatures.c \
+ stdmem.c stdmem.h secmem.c secmem.h \
+ mpi.h missing-string.c module.c fips.c \
+ hmac256.c hmac256.h \
+ ath.h ath.c
+
+if HAVE_W32_SYSTEM
+
+RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(libgcrypt_la_CPPFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS)
+LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE)
+
+SUFFIXES = .rc .lo
+
+.rc.lo:
+ $(LTRCCOMPILE) -i "$<" -o "$@"
+
+gcrypt_res = versioninfo.lo
+no_undefined = -no-undefined
+export_symbols = -export-symbols $(srcdir)/libgcrypt.def
+
+install-def-file:
+ $(INSTALL) $(srcdir)/libgcrypt.def $(DESTDIR)$(libdir)/libgcrypt.def
+
+uninstall-def-file:
+ -rm $(DESTDIR)$(libdir)/libgcrypt.def
+
+gcrypt_deps = $(gcrypt_res) libgcrypt.def
+
+else !HAVE_W32_SYSTEM
+
+gcrypt_res =
+gcrypt_res_ldflag =
+no_undefined =
+export_symbols =
+install-def-file:
+uninstall-def-file:
+
+gcrypt_deps =
+
+endif !HAVE_W32_SYSTEM
+
+
+libgcrypt_la_LDFLAGS = $(no_undefined) $(export_symbols) \
+ $(libgcrypt_version_script_cmd) -version-info \
+ @LIBGCRYPT_LT_CURRENT@:@LIBGCRYPT_LT_REVISION@:@LIBGCRYPT_LT_AGE@
+libgcrypt_la_DEPENDENCIES = \
+ ../cipher/libcipher.la \
+ ../random/librandom.la \
+ ../mpi/libmpi.la \
+ ../compat/libcompat.la \
+ $(srcdir)/libgcrypt.vers $(gcrypt_deps)
+libgcrypt_la_LIBADD = $(gcrypt_res) \
+ ../cipher/libcipher.la \
+ ../random/librandom.la \
+ ../mpi/libmpi.la \
+ ../compat/libcompat.la $(GPG_ERROR_LIBS)
+
+
+dumpsexp_SOURCES = dumpsexp.c
+dumpsexp_CFLAGS = $(arch_gpg_error_cflags)
+dumpsexp_LDADD = $(arch_gpg_error_libs)
+
+hmac256_SOURCES = hmac256.c
+hmac256_CFLAGS = -DSTANDALONE $(arch_gpg_error_cflags)
+hmac256_LDADD = $(arch_gpg_error_libs)
+
+if USE_RANDOM_DAEMON
+gcryptrnd_SOURCES = gcryptrnd.c
+gcryptrnd_CFLAGS = $(GPG_ERROR_CFLAGS) $(PTH_CFLAGS)
+gcryptrnd_LDADD = libgcrypt.la $(GPG_ERROR_LIBS) $(PTH_LIBS)
+
+getrandom_SOURCES = getrandom.c
+endif USE_RANDOM_DAEMON
+
+
+install-data-local: install-def-file
+
+uninstall-local: uninstall-def-file
+
+# FIXME: We need to figure out how to get the actual name (parsing
+# libgcrypt.la?) and how to create the hmac file already at link time
+# so that it can be used without installing libgcrypt first.
+#install-exec-hook:
+# ./hmac256 "What am I, a doctor or a moonshuttle conductor?" \
+# < $(DESTDIR)$(libdir)/libgcrypt.so.11.5.0 \
+# > $(DESTDIR)$(libdir)/.libgcrypt.so.11.5.0.hmac
diff --git a/grub-core/lib/libgcrypt/src/Manifest b/grub-core/lib/libgcrypt/src/Manifest
new file mode 100644
index 0000000..2d003d8
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/Manifest
@@ -0,0 +1,58 @@
+# Manifest - checksums of the src directory
+# Copyright 2004 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+# Checksums for all source files in this directory. Format is
+# filename, blanks, base-64 part of an OpenPGP detached signature
+# without the header lines. Blank lines and lines beginning with a
+# hash mark are ignored. A tool to process this file is available by
+# cvs -d :pserver:anoncvs@cvs.gnupg.org:/cvs/wk co misc-scripts/manifest-tool
+#
+# The special entry "$names$" holds a signature over all sorted
+# filenames excluding itself.
+
+gcrypt.h iQCVAwUAQH5RsTEAnp832S/7AQK7xgP+Kc3NY9lipZkaAMrnHDkQVLdHYwTbZWuGOYdTLp8Xy7Auh9wtWV9hrWVUqs+kxDzT/2iF6XkO3WT3rf/PmQ/Q0TIGfOyjE3c/qvB/jVippaxoGda3tnGpODytdI3XPhfPS0Ss8nDzfCStPBGAEq0OVU7imnExrFzhRXt+Gljr0o0==Yagz
+gcrypt-module.h iQCVAwUAQH5UXzEAnp832S/7AQJMQgQAzumz9aaZelhw+FxTCeVadphBxt1bbNQvMrnddYYblyJv+AcxZ9ZxGz2oPeusN58Qg54DQcaW3lYhTgnWfXultsi+Ruxlz7400OUrzSXOl3At7KssdODAoscFzZIgh94G9lzQxEBr9lTXI9R3LsPFJP6muNG4frcNBAA42yckK7w==BBp5
+
+ath.c iQCVAwUAQH5E+DEAnp832S/7AQKFpgP+KSZHtVcnh9FFggIyHKbALUljW2FXauasZvFyN8Sk/mIMgKxyXFOG1THBAUzWLaKWIEWU+WkYU7uThqBtpnEImM5AenWzbQuJjftPC3gVHO8yjjmBWD4zmJj28htoKDoa/xDsoqumrHxae3FYcaCWtYGVjM/Pbl+OMRMOFAhp0ho==lQZ3
+ath.h iQCVAwUAQH5FODEAnp832S/7AQKiuQQAg4K+KOAn1LWBZN32MAhms4FeZKoce0fAuZW7BpyY4cCxIVgxqrtUC90CDykw8XegFfOyyYrgd0NmaMVdY7HZDncNOvIPxpgFQPCZrycsMOoAtoVwjK704RDeNo3zmeyxTKeDH+3M1J7JmLiafaEdSbOC8flX/W0icaV0Ol4dmBc==Ll6w
+
+cipher.h iQCVAwUAQH5FUzEAnp832S/7AQJKLgP9GSSk9f7EINIRqSQH1XKX+dYzt3phDHdqFTUGIfYNh7YzGdy0drvgFhG4k15nqDouKRuFVM/hKY3ZVY7JccmKXKGAH6+ZYShoG6LMFfIGgDX8zne0dNxc72PLfns3fVxNn/RlHmHBkrQ+ppjR9HnSthFmOqzbQaW1BKmc3Z2x5GU==lIeW
+g10lib.h iQCVAwUAQH5FejEAnp832S/7AQJ75wP/ZjOybwRix5eoXdfVeXPjoPygejzpYJJdMUGN3Y5UtkfBu9mPREsKfvZ6tH+Evjx+3xfeAb4bU/k2mRMp0tiWnk2koToS08vI9uxnioKQr9oulZH6r28S+NLSgMQuEGN1JNUky6RQ9TTNRndeTjKKSrEjZ7V6bv+rb8A1bYCKChs==P5mk
+mpi.h iQCVAwUAQH5FwzEAnp832S/7AQJJ4wP9E3jVkcO9M0YtSBHIbjG3hDWKWXzi86AlUh51qiE8/2XP0FfjA4TosyvmicZs7j48HitAByr9tHOSxnbeo7NBf17ICwAo6Eqty+wKDg+eyLeEGUy7VpVK3RJRQAA4H+kl3S2l3YMTKf3WJlbc7qkWSXZspdy5c9sAxeodCKrAubU==oALf
+
+global.c iQCVAwUAQH5HFzEAnp832S/7AQJc+QQAvi53ZkMCzLnVULHvhI6W+EX537zi9n8cplYguvIJqUhAZrP68yGAIyqyCONbZVDyB7wqeXdUMLzMk7W8fg+xuk5JSDpppAQf2m/bdQyze6XVqJso682eYBM8+b9z/IVEvLaFwhZcOKO1bcXudBlBCcJgVDpupfTtAWgPnewil9Q==Xwy1
+misc.c iQCVAwUAQH5IIjEAnp832S/7AQKNJAQAkEpyY3fCG7tvADJFAW9xA7DEQwLCa8YmiUhHvrEsWOI4YgvS7LUbWWc7VqK+ryORvXLKRAVieznbnHAuy0TKtqdnmA/kUmiurS0ah5SWqR/iuAeJtt0RGsmZaZ6oa2m4PZ2Y2GCHSTZqcclvwsetS9eq5AipxHxYFUltu5wGZNI==twM2
+missing-string.c iQCVAwUAQH5JfjEAnp832S/7AQI3ZQQAg55eEJbGQQHyBEJGxvt/FXpQiXcoDit3ZHzvdaQn/NUgdLjCHiWVzhyCXACGivLWMNModDaSaZk073NXxVkWfPcX9vkF//Wugwzidd5P3Bfu5k35o+Xxz82fsk5KuFGGq1mBUZ07xUYQ8KkKkhADUkr0QiQAuypp079Yq0uUC7Q==zvKn
+module.c iQCVAwUAQH5JvjEAnp832S/7AQKlMgQAjZYTXMpWb5kHxCMXzRi069Ku/4/xnWsD+S0dje1LiKzCnRpwTTxARzc/y10Y8OcygkMuR4unEaWedO+9syjjty3fBCcue/j7YlLitq5EC9UE4o23poWvWCuX9Tadm2DK5qf4p7smMJ22O22cLTYTVCyAoYTQ2xC8ajzBsBRkX80==yRRD
+secmem.c iQCVAwUAQH5LLDEAnp832S/7AQKtFwQAwY2wBr6WJC1cwqp/1DQoKzHx9C3plONxbZMazwR7VMI83NUbBAbv1mcxpeZWXmb2dRrnsR1VBbNPDSbJLN5T6czLQ2nIb6mnq9u8Ip4SAa+GCWfDV4AUtAJ4hN/yvWo8iEKu+KD5iJ6xJh31NdXjt5yk6vnk46SA6R4FkHdIEXc==UKVr
+secmem.h iQCVAwUAQH5LTDEAnp832S/7AQIsJwQAkZUu4hvmh9NXCLNm98+tGZFzWYvZO/NffC2wdPE8Q/OTa/m3g+oBbEhaV1ze3oY4t1F/p7ZHFx5CsIp4zVjyPkxlni8AAVMUOQr/LopyxouHn2OjKO+dVqecWQf01+nPWjklbL2FZ3mQ99k2qeWZlVSkz0nm8u39F3v7z3OTCss==AJqE
+sexp.c iQCVAwUAQH5LojEAnp832S/7AQKCTQQArlrj1KGwR2x93fcyN3M0iXuGkBq5R9KNu+1Bq04G4SLlpZ1RRY0OjV3L9To1BHTd01lXlO8MNz7NpRxWlG1Sw5FohbBlhWZQRcW8GdAawJPcfIY2Y8Ek6Yx8quZKbk9uD3bcBmStmg0P+TIA0nr20bmtfB3uX2KQVHQqWZQT5qU==P8FE
+stdmem.c iQCVAwUAQH5LzjEAnp832S/7AQLOUAP9FU16itXBBrkfRDGmhUjAOeEEKdd+brQ3XdT8xoLvP/IH/6U1Kq3ampP2/xcL4kwVdz2rw6NRzP7jlL/yM3tW722lSS/JPJkH+2+qUkcb0fYNoql/WYPMYp1/Mzu6ttXnjag1cQGlKIyYAD+G6h3FtpLwQy0hEJopnF9+Ovd8U7A==CkiZ
+stdmem.h iQCVAwUAQH5L8jEAnp832S/7AQIH0wP+Lyqh0tj++s2L79Tmf/gqgCK+HLMxTddcewF3XbsYf9T5FmLez1gz6Ggti4Ss9VjozOA3ti3trCiA/YNRmV9AYw4zLUPm+MsjJuveL/AgB9HdoD2v+RfJm0WwgSKiysp+8iyjg3Plopmhba4cGuOP5MJ3CWTqYwPmJVscUKC6g38==02MN
+
+types.h iQCVAwUAQH5MKTEAnp832S/7AQLqTAP6A3mUMD5MMkBkebq4bRY6Bq0KsgdKfZ8TLhc2o87gFay8YD0Uom3YJNG2LF/rAIct2ih4jYJaIb5dRfJ0KJoPi2ETd462J8OFCL4fjq9TaSjB2pXcB+kWoxzPasGNg2Ukk0dQ6lvF1tSYrtt32PVI7q/UaPsjTylgRmzLfX/VxrU==OMu3
+
+
+# Configuration
+Makefile.am iQCVAwUAQH5WVjEAnp832S/7AQLmsQP/bbI8/UWAC5yITVhGcCOCbN/FaMqXVKjxESzo6GTs02jxK1y3RuuaoNU1ssQZGAxpFiMJW8u933V3yTHFMxWpwHemDnEyv/a8YACxJBQ0tQgpgHS716BjMbHOfcuOis2WlCOOm0ErjhAYNa4NQ1q3jwkOvTDLFpdnqaWI2wWn08U==Yjun
+libgcrypt.m4 iQCVAwUAQH5MbTEAnp832S/7AQJ1uAQA1C6xI7qXiKVtUeXawhPytAldosrzcXmqz34xi7JklQqw83d68WtWHFMBEUa7MKfi4WCbuQb7FjGUvMRw5z/T9ez7CoDekHc63+cIIZLQ23weUK8GaA1uQLoD0scmT41J5RkBlJbH7ck1zRd3d04o75rWNEUNit6KBvrQ4Pd8oQ8==uMgB
+libgcrypt-config.in iQCVAwUAQH5UbzEAnp832S/7AQJISgP+Nbd2AQnDM/k8sQLbvz8YZjwX3LigZM+AkF1VAwyAm6YOU3nrXnz5t+cXkQD2dkz4L2F0AAsIkFiJsrgmZgCp2h1L6LeFnH+hoId9RhbYw4NkDaHb+MC9JcalpcfFvvxq6vM/W37bSFimM78P+5RLKypXCytVQNAAaIRgZjVfXY8==IGDS
+libgcrypt.vers iQCVAwUAQH5MjTEAnp832S/7AQKCdQQAotG6Z3zdcePI0V33YY2sh91uYkLBNhQw+PzyE3BRRAVhMGLOBD1nSWJHJvE3eyCVOqFY0ZmvpVex51Fa0D/TwsJOO4RVxf1L9bbAncu9OuEXaGXKytLZp54TliDTAWGDq0lvtx1TvDDgtM8TbbaXvMbjfQ4wXBxdLvaenFCTlR4==kgHq
+
+$names$ iQCVAwUAQH5UhDEAnp832S/7AQK/jwP9H7A3mI99M1NGuhD+16C+2gJIITB8GJeYeUd3vm8kWQ5n76WyMCdeA62qn0JUddIBjAbagtfvTL5aesnD9MlhEGaNlHauU7SINTIJ8njKf87EAAfDZrhS/tGDziC2nakMPweRxXQCLDWHkBPjYfrspSLLohjdegqBvTNyVM76+KE==3p9Z
diff --git a/grub-core/lib/libgcrypt/src/ath.c b/grub-core/lib/libgcrypt/src/ath.c
new file mode 100644
index 0000000..656ed89
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/ath.c
@@ -0,0 +1,344 @@
+/* ath.c - Thread-safeness library.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+ This file is part of Libgcrypt.
+
+ Libgcrypt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Libgcrypt is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Libgcrypt; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h> /* Right: We need to use assert and not gcry_assert. */
+#include <unistd.h>
+#ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#else
+# include <sys/time.h>
+#endif
+#include <sys/types.h>
+#ifndef _WIN32
+#include <sys/wait.h>
+#endif
+#include <errno.h>
+
+#include "ath.h"
+
+
+
+/* The interface table. */
+static struct ath_ops ops;
+
+/* True if we should use the external callbacks. */
+static int ops_set;
+
+
+/* For the dummy interface. */
+#define MUTEX_UNLOCKED ((ath_mutex_t) 0)
+#define MUTEX_LOCKED ((ath_mutex_t) 1)
+#define MUTEX_DESTROYED ((ath_mutex_t) 2)
+
+
+/* Return the thread type from the option field. */
+#define GET_OPTION(a) ((a) & 0xff)
+/* Return the version number from the option field. */
+#define GET_VERSION(a) (((a) >> 8)& 0xff)
+
+
+
+/* The lock we take while checking for lazy lock initialization. */
+static ath_mutex_t check_init_lock = ATH_MUTEX_INITIALIZER;
+
+int
+ath_init (void)
+{
+ int err = 0;
+
+ if (ops_set)
+ {
+ if (ops.init)
+ err = (*ops.init) ();
+ if (err)
+ return err;
+ err = (*ops.mutex_init) (&check_init_lock);
+ }
+ return err;
+}
+
+
+/* Initialize the locking library. Returns 0 if the operation was
+ successful, EINVAL if the operation table was invalid and EBUSY if
+ we already were initialized. */
+gpg_err_code_t
+ath_install (struct ath_ops *ath_ops, int check_only)
+{
+ if (check_only)
+ {
+ unsigned int option = 0;
+
+ /* Check if the requested thread option is compatible to the
+ thread option we are already committed to. */
+ if (ath_ops)
+ option = ath_ops->option;
+
+ if (!ops_set && GET_OPTION (option))
+ return GPG_ERR_NOT_SUPPORTED;
+
+ if (GET_OPTION (ops.option) == ATH_THREAD_OPTION_USER
+ || GET_OPTION (option) == ATH_THREAD_OPTION_USER
+ || GET_OPTION (ops.option) != GET_OPTION (option)
+ || GET_VERSION (ops.option) != GET_VERSION (option))
+ return GPG_ERR_NOT_SUPPORTED;
+
+ return 0;
+ }
+
+ if (ath_ops)
+ {
+ /* It is convenient to not require DESTROY. */
+ if (!ath_ops->mutex_init || !ath_ops->mutex_lock
+ || !ath_ops->mutex_unlock)
+ return GPG_ERR_INV_ARG;
+
+ ops = *ath_ops;
+ ops_set = 1;
+ }
+ else
+ ops_set = 0;
+
+ return 0;
+}
+
+
+static int
+mutex_init (ath_mutex_t *lock, int just_check)
+{
+ int err = 0;
+
+ if (just_check)
+ (*ops.mutex_lock) (&check_init_lock);
+ if (*lock == ATH_MUTEX_INITIALIZER || !just_check)
+ err = (*ops.mutex_init) (lock);
+ if (just_check)
+ (*ops.mutex_unlock) (&check_init_lock);
+ return err;
+}
+
+
+int
+ath_mutex_init (ath_mutex_t *lock)
+{
+ if (ops_set)
+ return mutex_init (lock, 0);
+
+#ifndef NDEBUG
+ *lock = MUTEX_UNLOCKED;
+#endif
+ return 0;
+}
+
+
+int
+ath_mutex_destroy (ath_mutex_t *lock)
+{
+ if (ops_set)
+ {
+ if (!ops.mutex_destroy)
+ return 0;
+
+ (*ops.mutex_lock) (&check_init_lock);
+ if (*lock == ATH_MUTEX_INITIALIZER)
+ {
+ (*ops.mutex_unlock) (&check_init_lock);
+ return 0;
+ }
+ (*ops.mutex_unlock) (&check_init_lock);
+ return (*ops.mutex_destroy) (lock);
+ }
+
+#ifndef NDEBUG
+ assert (*lock == MUTEX_UNLOCKED);
+
+ *lock = MUTEX_DESTROYED;
+#endif
+ return 0;
+}
+
+
+int
+ath_mutex_lock (ath_mutex_t *lock)
+{
+ if (ops_set)
+ {
+ int ret = mutex_init (lock, 1);
+ if (ret)
+ return ret;
+ return (*ops.mutex_lock) (lock);
+ }
+
+#ifndef NDEBUG
+ assert (*lock == MUTEX_UNLOCKED);
+
+ *lock = MUTEX_LOCKED;
+#endif
+ return 0;
+}
+
+
+int
+ath_mutex_unlock (ath_mutex_t *lock)
+{
+ if (ops_set)
+ {
+ int ret = mutex_init (lock, 1);
+ if (ret)
+ return ret;
+ return (*ops.mutex_unlock) (lock);
+ }
+
+#ifndef NDEBUG
+ assert (*lock == MUTEX_LOCKED);
+
+ *lock = MUTEX_UNLOCKED;
+#endif
+ return 0;
+}
+
+
+ssize_t
+ath_read (int fd, void *buf, size_t nbytes)
+{
+ if (ops_set && ops.read)
+ return (*ops.read) (fd, buf, nbytes);
+ else
+ return read (fd, buf, nbytes);
+}
+
+
+ssize_t
+ath_write (int fd, const void *buf, size_t nbytes)
+{
+ if (ops_set && ops.write)
+ return (*ops.write) (fd, buf, nbytes);
+ else
+ return write (fd, buf, nbytes);
+}
+
+
+ssize_t
+#ifdef _WIN32
+ath_select (int nfd, void *rset, void *wset, void *eset,
+ struct timeval *timeout)
+#else
+ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
+ struct timeval *timeout)
+#endif
+{
+ if (ops_set && ops.select)
+ return (*ops.select) (nfd, rset, wset, eset, timeout);
+ else
+#ifdef _WIN32
+ return -1;
+#else
+ return select (nfd, rset, wset, eset, timeout);
+#endif
+}
+
+
+ssize_t
+ath_waitpid (pid_t pid, int *status, int options)
+{
+ if (ops_set && ops.waitpid)
+ return (*ops.waitpid) (pid, status, options);
+ else
+#ifdef _WIN32
+ return -1;
+#else
+ return waitpid (pid, status, options);
+#endif
+}
+
+
+int
+#ifdef _WIN32
+ath_accept (int s, void *addr, int *length_ptr)
+#else
+ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr)
+#endif
+{
+ if (ops_set && ops.accept)
+ return (*ops.accept) (s, addr, length_ptr);
+ else
+#ifdef _WIN32
+ return -1;
+#else
+ return accept (s, addr, length_ptr);
+#endif
+}
+
+
+int
+#ifdef _WIN32
+ath_connect (int s, void *addr, int length)
+#else
+ath_connect (int s, struct sockaddr *addr, socklen_t length)
+#endif
+{
+ if (ops_set && ops.connect)
+ return (*ops.connect) (s, addr, length);
+ else
+#ifdef _WIN32
+ return -1;
+#else
+ return connect (s, addr, length);
+#endif
+}
+
+
+int
+#ifdef _WIN32
+ath_sendmsg (int s, const void *msg, int flags)
+#else
+ath_sendmsg (int s, const struct msghdr *msg, int flags)
+#endif
+{
+ if (ops_set && ops.sendmsg)
+ return (*ops.sendmsg) (s, msg, flags);
+ else
+#ifdef _WIN32
+ return -1;
+#else
+ return sendmsg (s, msg, flags);
+#endif
+}
+
+
+int
+#ifdef _WIN32
+ath_recvmsg (int s, void *msg, int flags)
+#else
+ath_recvmsg (int s, struct msghdr *msg, int flags)
+#endif
+{
+ if (ops_set && ops.recvmsg)
+ return (*ops.recvmsg) (s, msg, flags);
+ else
+#ifdef _WIN32
+ return -1;
+#else
+ return recvmsg (s, msg, flags);
+#endif
+}
diff --git a/grub-core/lib/libgcrypt/src/ath.h b/grub-core/lib/libgcrypt/src/ath.h
new file mode 100644
index 0000000..8769551
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/ath.h
@@ -0,0 +1,147 @@
+/* ath.h - Thread-safeness library.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+ This file is part of Libgcrypt.
+
+ Libgcrypt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Libgcrypt is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Libgcrypt; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#ifndef ATH_H
+#define ATH_H
+
+#include <config.h>
+
+#ifdef _WIN32
+# include <windows.h>
+#else /* !_WIN32 */
+# ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+# else
+# include <sys/time.h>
+# endif
+# include <sys/types.h>
+# ifdef HAVE_SYS_MSG_H
+# include <sys/msg.h> /* (e.g. for zOS) */
+# endif
+# include <sys/socket.h>
+#endif /* !_WIN32 */
+#include <gpg-error.h>
+
+
+
+/* Define _ATH_EXT_SYM_PREFIX if you want to give all external symbols
+ a prefix. */
+#define _ATH_EXT_SYM_PREFIX _gcry_
+
+#ifdef _ATH_EXT_SYM_PREFIX
+#define _ATH_PREFIX1(x,y) x ## y
+#define _ATH_PREFIX2(x,y) _ATH_PREFIX1(x,y)
+#define _ATH_PREFIX(x) _ATH_PREFIX2(_ATH_EXT_SYM_PREFIX,x)
+#define ath_install _ATH_PREFIX(ath_install)
+#define ath_init _ATH_PREFIX(ath_init)
+#define ath_mutex_init _ATH_PREFIX(ath_mutex_init)
+#define ath_mutex_destroy _ATH_PREFIX(ath_mutex_destroy)
+#define ath_mutex_lock _ATH_PREFIX(ath_mutex_lock)
+#define ath_mutex_unlock _ATH_PREFIX(ath_mutex_unlock)
+#define ath_read _ATH_PREFIX(ath_read)
+#define ath_write _ATH_PREFIX(ath_write)
+#define ath_select _ATH_PREFIX(ath_select)
+#define ath_waitpid _ATH_PREFIX(ath_waitpid)
+#define ath_connect _ATH_PREFIX(ath_connect)
+#define ath_accept _ATH_PREFIX(ath_accept)
+#define ath_sendmsg _ATH_PREFIX(ath_sendmsg)
+#define ath_recvmsg _ATH_PREFIX(ath_recvmsg)
+#endif
+
+
+enum ath_thread_option
+ {
+ ATH_THREAD_OPTION_DEFAULT = 0,
+ ATH_THREAD_OPTION_USER = 1,
+ ATH_THREAD_OPTION_PTH = 2,
+ ATH_THREAD_OPTION_PTHREAD = 3
+ };
+
+struct ath_ops
+{
+ /* The OPTION field encodes the thread model and the version number
+ of this structure.
+ Bits 7 - 0 are used for the thread model
+ Bits 15 - 8 are used for the version number.
+ */
+ unsigned int option;
+
+ int (*init) (void);
+ int (*mutex_init) (void **priv);
+ int (*mutex_destroy) (void *priv);
+ int (*mutex_lock) (void *priv);
+ int (*mutex_unlock) (void *priv);
+ ssize_t (*read) (int fd, void *buf, size_t nbytes);
+ ssize_t (*write) (int fd, const void *buf, size_t nbytes);
+#ifdef _WIN32
+ ssize_t (*select) (int nfd, void *rset, void *wset, void *eset,
+ struct timeval *timeout);
+ ssize_t (*waitpid) (pid_t pid, int *status, int options);
+ int (*accept) (int s, void *addr, int *length_ptr);
+ int (*connect) (int s, void *addr, int length);
+ int (*sendmsg) (int s, const void *msg, int flags);
+ int (*recvmsg) (int s, void *msg, int flags);
+#else
+ ssize_t (*select) (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
+ struct timeval *timeout);
+ ssize_t (*waitpid) (pid_t pid, int *status, int options);
+ int (*accept) (int s, struct sockaddr *addr, socklen_t *length_ptr);
+ int (*connect) (int s, struct sockaddr *addr, socklen_t length);
+ int (*sendmsg) (int s, const struct msghdr *msg, int flags);
+ int (*recvmsg) (int s, struct msghdr *msg, int flags);
+#endif
+};
+
+gpg_err_code_t ath_install (struct ath_ops *ath_ops, int check_only);
+int ath_init (void);
+
+
+/* Functions for mutual exclusion. */
+typedef void *ath_mutex_t;
+#define ATH_MUTEX_INITIALIZER 0
+
+int ath_mutex_init (ath_mutex_t *mutex);
+int ath_mutex_destroy (ath_mutex_t *mutex);
+int ath_mutex_lock (ath_mutex_t *mutex);
+int ath_mutex_unlock (ath_mutex_t *mutex);
+
+/* Replacement for the POSIX functions, which can be used to allow
+ other (user-level) threads to run. */
+ssize_t ath_read (int fd, void *buf, size_t nbytes);
+ssize_t ath_write (int fd, const void *buf, size_t nbytes);
+#ifdef _WIN32
+ssize_t ath_select (int nfd, void *rset, void *wset, void *eset,
+ struct timeval *timeout);
+ssize_t ath_waitpid (pid_t pid, int *status, int options);
+int ath_accept (int s, void *addr, int *length_ptr);
+int ath_connect (int s, void *addr, int length);
+int ath_sendmsg (int s, const void *msg, int flags);
+int ath_recvmsg (int s, void *msg, int flags);
+#else
+ssize_t ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
+ struct timeval *timeout);
+ssize_t ath_waitpid (pid_t pid, int *status, int options);
+int ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr);
+int ath_connect (int s, struct sockaddr *addr, socklen_t length);
+int ath_sendmsg (int s, const struct msghdr *msg, int flags);
+int ath_recvmsg (int s, struct msghdr *msg, int flags);
+#endif
+
+#endif /* ATH_H */
diff --git a/grub-core/lib/libgcrypt/src/cipher-proto.h b/grub-core/lib/libgcrypt/src/cipher-proto.h
new file mode 100644
index 0000000..347681f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/cipher-proto.h
@@ -0,0 +1,124 @@
+/* cipher-proto.h - Internal declarations
+ * Copyright (C) 2008, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This file has been factored out from cipher.h so that it can be
+ used standalone in visibility.c . */
+
+#ifndef G10_CIPHER_PROTO_H
+#define G10_CIPHER_PROTO_H
+
+/* Definition of a function used to report selftest failures.
+ DOMAIN is a string describing the function block:
+ "cipher", "digest", "pubkey or "random",
+ ALGO is the algorithm under test,
+ WHAT is a string describing what has been tested,
+ DESC is a string describing the error. */
+typedef void (*selftest_report_func_t)(const char *domain,
+ int algo,
+ const char *what,
+ const char *errdesc);
+
+/* Definition of the selftest functions. */
+typedef gpg_err_code_t (*selftest_func_t)
+ (int algo, int extended, selftest_report_func_t report);
+
+
+/* An extended type of the generate function. */
+typedef gcry_err_code_t (*pk_ext_generate_t)
+ (int algo,
+ unsigned int nbits,
+ unsigned long evalue,
+ gcry_sexp_t genparms,
+ gcry_mpi_t *skey,
+ gcry_mpi_t **retfactors,
+ gcry_sexp_t *extrainfo);
+
+/* The type used to compute the keygrip. */
+typedef gpg_err_code_t (*pk_comp_keygrip_t)
+ (gcry_md_hd_t md, gcry_sexp_t keyparm);
+
+/* The type used to query ECC curve parameters. */
+typedef gcry_err_code_t (*pk_get_param_t)
+ (const char *name, gcry_mpi_t *pkey);
+
+/* The type used to query an ECC curve name. */
+typedef const char *(*pk_get_curve_t)(gcry_mpi_t *pkey, int iterator,
+ unsigned int *r_nbits);
+
+/* The type used to query ECC curve parameters by name. */
+typedef gcry_sexp_t (*pk_get_curve_param_t)(const char *name);
+
+/* The type used to convey additional information to a cipher. */
+typedef gpg_err_code_t (*cipher_set_extra_info_t)
+ (void *c, int what, const void *buffer, size_t buflen);
+
+
+/* Extra module specification structures. These are used for internal
+ modules which provide more functions than available through the
+ public algorithm register APIs. */
+typedef struct cipher_extra_spec
+{
+ selftest_func_t selftest;
+ cipher_set_extra_info_t set_extra_info;
+} cipher_extra_spec_t;
+
+typedef struct md_extra_spec
+{
+ selftest_func_t selftest;
+} md_extra_spec_t;
+
+typedef struct pk_extra_spec
+{
+ selftest_func_t selftest;
+ pk_ext_generate_t ext_generate;
+ pk_comp_keygrip_t comp_keygrip;
+ pk_get_param_t get_param;
+ pk_get_curve_t get_curve;
+ pk_get_curve_param_t get_curve_param;
+} pk_extra_spec_t;
+
+
+
+/* The private register functions. */
+gcry_error_t _gcry_cipher_register (gcry_cipher_spec_t *cipher,
+ cipher_extra_spec_t *extraspec,
+ int *algorithm_id,
+ gcry_module_t *module);
+gcry_error_t _gcry_md_register (gcry_md_spec_t *cipher,
+ md_extra_spec_t *extraspec,
+ unsigned int *algorithm_id,
+ gcry_module_t *module);
+gcry_error_t _gcry_pk_register (gcry_pk_spec_t *cipher,
+ pk_extra_spec_t *extraspec,
+ unsigned int *algorithm_id,
+ gcry_module_t *module);
+
+/* The selftest functions. */
+gcry_error_t _gcry_cipher_selftest (int algo, int extended,
+ selftest_report_func_t report);
+gcry_error_t _gcry_md_selftest (int algo, int extended,
+ selftest_report_func_t report);
+gcry_error_t _gcry_pk_selftest (int algo, int extended,
+ selftest_report_func_t report);
+gcry_error_t _gcry_hmac_selftest (int algo, int extended,
+ selftest_report_func_t report);
+
+gcry_error_t _gcry_random_selftest (selftest_report_func_t report);
+
+#endif /*G10_CIPHER_PROTO_H*/
diff --git a/grub-core/lib/libgcrypt/src/cipher.h b/grub-core/lib/libgcrypt/src/cipher.h
new file mode 100644
index 0000000..48eeeda
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/cipher.h
@@ -0,0 +1,182 @@
+/* cipher.h
+ * Copyright (C) 1998, 2002, 2003, 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+#ifndef G10_CIPHER_H
+#define G10_CIPHER_H
+
+#include <gcrypt.h>
+
+#define DBG_CIPHER _gcry_get_debug_flag( 1 )
+
+#include "../random/random.h"
+
+#define PUBKEY_FLAG_NO_BLINDING (1 << 0)
+
+enum pk_operation
+ {
+ PUBKEY_OP_ENCRYPT,
+ PUBKEY_OP_DECRYPT,
+ PUBKEY_OP_SIGN,
+ PUBKEY_OP_VERIFY
+ };
+
+enum pk_encoding
+ {
+ PUBKEY_ENC_RAW,
+ PUBKEY_ENC_PKCS1,
+ PUBKEY_ENC_OAEP,
+ PUBKEY_ENC_PSS,
+ PUBKEY_ENC_UNKNOWN
+ };
+
+struct pk_encoding_ctx
+{
+ enum pk_operation op;
+ unsigned int nbits;
+
+ enum pk_encoding encoding;
+ int flags;
+
+ int hash_algo;
+
+ /* for OAEP */
+ unsigned char *label;
+ size_t labellen;
+
+ /* for PSS */
+ size_t saltlen;
+
+ int (* verify_cmp) (void *opaque, gcry_mpi_t tmp);
+ void *verify_arg;
+};
+
+#define CIPHER_INFO_NO_WEAK_KEY 1
+
+#include "cipher-proto.h"
+
+
+/*-- rmd160.c --*/
+void _gcry_rmd160_hash_buffer (void *outbuf,
+ const void *buffer, size_t length);
+/*-- sha1.c --*/
+void _gcry_sha1_hash_buffer (void *outbuf,
+ const void *buffer, size_t length);
+
+/*-- rijndael.c --*/
+void _gcry_aes_cfb_enc (void *context, unsigned char *iv,
+ void *outbuf, const void *inbuf,
+ unsigned int nblocks);
+void _gcry_aes_cfb_dec (void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks);
+void _gcry_aes_cbc_enc (void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks, int cbc_mac);
+void _gcry_aes_cbc_dec (void *context, unsigned char *iv,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks);
+void _gcry_aes_ctr_enc (void *context, unsigned char *ctr,
+ void *outbuf_arg, const void *inbuf_arg,
+ unsigned int nblocks);
+
+
+/*-- dsa.c --*/
+void _gcry_register_pk_dsa_progress (gcry_handler_progress_t cbc, void *cb_data);
+
+/*-- elgamal.c --*/
+void _gcry_register_pk_elg_progress (gcry_handler_progress_t cb,
+ void *cb_data);
+
+
+/*-- ecc.c --*/
+void _gcry_register_pk_ecc_progress (gcry_handler_progress_t cbc,
+ void *cb_data);
+
+
+/*-- primegen.c --*/
+void _gcry_register_primegen_progress (gcry_handler_progress_t cb,
+ void *cb_data);
+
+/*-- pubkey.c --*/
+const char * _gcry_pk_aliased_algo_name (int algorithm);
+
+/* Declarations for the cipher specifications. */
+extern gcry_cipher_spec_t _gcry_cipher_spec_blowfish;
+extern gcry_cipher_spec_t _gcry_cipher_spec_des;
+extern gcry_cipher_spec_t _gcry_cipher_spec_tripledes;
+extern gcry_cipher_spec_t _gcry_cipher_spec_arcfour;
+extern gcry_cipher_spec_t _gcry_cipher_spec_cast5;
+extern gcry_cipher_spec_t _gcry_cipher_spec_aes;
+extern gcry_cipher_spec_t _gcry_cipher_spec_aes192;
+extern gcry_cipher_spec_t _gcry_cipher_spec_aes256;
+extern gcry_cipher_spec_t _gcry_cipher_spec_twofish;
+extern gcry_cipher_spec_t _gcry_cipher_spec_twofish128;
+extern gcry_cipher_spec_t _gcry_cipher_spec_serpent128;
+extern gcry_cipher_spec_t _gcry_cipher_spec_serpent192;
+extern gcry_cipher_spec_t _gcry_cipher_spec_serpent256;
+extern gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_40;
+extern gcry_cipher_spec_t _gcry_cipher_spec_seed;
+extern gcry_cipher_spec_t _gcry_cipher_spec_camellia128;
+extern gcry_cipher_spec_t _gcry_cipher_spec_camellia192;
+extern gcry_cipher_spec_t _gcry_cipher_spec_camellia256;
+extern gcry_cipher_spec_t _gcry_cipher_spec_idea;
+
+extern cipher_extra_spec_t _gcry_cipher_extraspec_tripledes;
+extern cipher_extra_spec_t _gcry_cipher_extraspec_aes;
+extern cipher_extra_spec_t _gcry_cipher_extraspec_aes192;
+extern cipher_extra_spec_t _gcry_cipher_extraspec_aes256;
+
+
+/* Declarations for the digest specifications. */
+extern gcry_md_spec_t _gcry_digest_spec_crc32;
+extern gcry_md_spec_t _gcry_digest_spec_crc32_rfc1510;
+extern gcry_md_spec_t _gcry_digest_spec_crc24_rfc2440;
+extern gcry_md_spec_t _gcry_digest_spec_md4;
+extern gcry_md_spec_t _gcry_digest_spec_md5;
+extern gcry_md_spec_t _gcry_digest_spec_rmd160;
+extern gcry_md_spec_t _gcry_digest_spec_sha1;
+extern gcry_md_spec_t _gcry_digest_spec_sha224;
+extern gcry_md_spec_t _gcry_digest_spec_sha256;
+extern gcry_md_spec_t _gcry_digest_spec_sha512;
+extern gcry_md_spec_t _gcry_digest_spec_sha384;
+extern gcry_md_spec_t _gcry_digest_spec_tiger;
+extern gcry_md_spec_t _gcry_digest_spec_tiger1;
+extern gcry_md_spec_t _gcry_digest_spec_tiger2;
+extern gcry_md_spec_t _gcry_digest_spec_whirlpool;
+
+extern md_extra_spec_t _gcry_digest_extraspec_sha1;
+extern md_extra_spec_t _gcry_digest_extraspec_sha224;
+extern md_extra_spec_t _gcry_digest_extraspec_sha256;
+extern md_extra_spec_t _gcry_digest_extraspec_sha384;
+extern md_extra_spec_t _gcry_digest_extraspec_sha512;
+
+/* Declarations for the pubkey cipher specifications. */
+extern gcry_pk_spec_t _gcry_pubkey_spec_rsa;
+extern gcry_pk_spec_t _gcry_pubkey_spec_elg;
+extern gcry_pk_spec_t _gcry_pubkey_spec_dsa;
+extern gcry_pk_spec_t _gcry_pubkey_spec_ecdsa;
+extern gcry_pk_spec_t _gcry_pubkey_spec_ecdh;
+
+extern pk_extra_spec_t _gcry_pubkey_extraspec_rsa;
+extern pk_extra_spec_t _gcry_pubkey_extraspec_dsa;
+extern pk_extra_spec_t _gcry_pubkey_extraspec_elg;
+extern pk_extra_spec_t _gcry_pubkey_extraspec_ecdsa;
+
+
+#endif /*G10_CIPHER_H*/
diff --git a/grub-core/lib/libgcrypt/src/dumpsexp.c b/grub-core/lib/libgcrypt/src/dumpsexp.c
new file mode 100644
index 0000000..f6384d7
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/dumpsexp.c
@@ -0,0 +1,766 @@
+/* dumpsexp.c - Dump S-expressions.
+ * Copyright (C) 2007, 2010 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <errno.h>
+/* For a native WindowsCE binary we need to include gpg-error.h to
+ provide a replacement for strerror. */
+#ifdef __MINGW32CE__
+# include <gpg-error.h>
+#endif
+
+#define PGM "dumpsexp"
+#define MYVERSION_LINE PGM " (Libgcrypt) " VERSION
+#define BUGREPORT_LINE "\nReport bugs to <bug-libgcrypt@gnupg.org>.\n"
+
+
+static int verbose; /* Verbose mode. */
+static int decimal; /* Print addresses in decimal. */
+static int assume_hex; /* Assume input is hexencoded. */
+static int advanced; /* Advanced format output. */
+
+static void
+print_version (int with_help)
+{
+ fputs (MYVERSION_LINE "\n"
+ "Copyright (C) 2010 Free Software Foundation, Inc.\n"
+ "License GPLv3+: GNU GPL version 3 or later "
+ "<http://gnu.org/licenses/gpl.html>\n"
+ "This is free software: you are free to change and redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n",
+ stdout);
+
+ if (with_help)
+ fputs ("\n"
+ "Usage: " PGM " [OPTIONS] [file]\n"
+ "Debug tool for S-expressions\n"
+ "\n"
+ " --decimal Print offsets using decimal notation\n"
+ " --assume-hex Assume input is a hex dump\n"
+ " --advanced Print file in advanced format\n"
+ " --verbose Show what we are doing\n"
+ " --version Print version of the program and exit\n"
+ " --help Display this help and exit\n"
+ BUGREPORT_LINE, stdout );
+
+ exit (0);
+}
+
+static int
+print_usage (void)
+{
+ fputs ("usage: " PGM " [OPTIONS] NBYTES\n", stderr);
+ fputs (" (use --help to display options)\n", stderr);
+ exit (1);
+}
+
+
+#define space_p(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t')
+#define digit_p(a) ((a) >= '0' && (a) <= '9')
+#define octdigit_p(a) ((a) >= '0' && (a) <= '7')
+#define alpha_p(a) ( ((a) >= 'A' && (a) <= 'Z') \
+ || ((a) >= 'a' && (a) <= 'z'))
+#define hexdigit_p(a) (digit_p (a) \
+ || ((a) >= 'A' && (a) <= 'F') \
+ || ((a) >= 'a' && (a) <= 'f'))
+#define xtoi_1(a) ((a) <= '9'? ((a)- '0'): \
+ (a) <= 'F'? ((a)-'A'+10):((a)-'a'+10))
+
+
+/* Return true if P points to a byte containing a whitespace according
+ to the S-expressions definition. */
+static inline int
+whitespace_p (int c)
+{
+ switch (c)
+ {
+ case ' ': case '\t': case '\v': case '\f': case '\r': case '\n': return 1;
+ default: return 0;
+ }
+}
+
+static void
+logit (const char *format, ...)
+{
+ va_list arg_ptr;
+
+ va_start (arg_ptr, format) ;
+ fputs (PGM ": ", stderr);
+ vfprintf (stderr, format, arg_ptr);
+ putc ('\n', stderr);
+ va_end (arg_ptr);
+}
+
+/* The raw data buffer and its current length */
+static unsigned char databuffer[16];
+static int databufferlen;
+/* The number of bytes in databuffer which should be skipped at a flush. */
+static int skipdatabufferlen;
+/* The number of raw bytes printed on the last line. */
+static int nbytesprinted;
+/* The file offset of the current data buffer . */
+static unsigned long databufferoffset;
+
+
+
+static int
+my_getc (FILE *fp)
+{
+ int c1, c2;
+
+ if (!assume_hex)
+ return getc (fp);
+
+ while ( (c1=getc (fp)) != EOF && space_p (c1) )
+ ;
+ if (c1 == EOF)
+ return EOF;
+
+ if (!hexdigit_p (c1))
+ {
+ logit ("non hex-digit encountered\n");
+ return EOF;
+ }
+
+ while ( (c2=getc (fp)) != EOF && space_p (c2) )
+ ;
+ if (c2 == EOF)
+ {
+ logit ("error reading second hex nibble\n");
+ return EOF;
+ }
+ if (!hexdigit_p (c2))
+ {
+ logit ("second hex nibble is not a hex-digit\n");
+ return EOF;
+ }
+ return xtoi_1 (c1) * 16 + xtoi_1 (c2);
+}
+
+
+
+
+
+/* Flush the raw data buffer. */
+static void
+flushdatabuffer (void)
+{
+ int i;
+
+ if (!databufferlen)
+ return;
+ nbytesprinted = 0;
+ if (decimal)
+ printf ("%08lu ", databufferoffset);
+ else
+ printf ("%08lx ", databufferoffset);
+ for (i=0; i < databufferlen; i++)
+ {
+ if (i == 8)
+ putchar (' ');
+ if (i < skipdatabufferlen)
+ fputs (" ", stdout);
+ else
+ {
+ printf (" %02x", databuffer[i]);
+ databufferoffset++;
+ }
+ nbytesprinted++;
+ }
+ for (; i < sizeof (databuffer); i++)
+ {
+ if (i == 8)
+ putchar (' ');
+ fputs (" ", stdout);
+ }
+ fputs (" |", stdout);
+ for (i=0; i < databufferlen; i++)
+ {
+ if (i < skipdatabufferlen)
+ putchar (' ');
+ else if (databuffer[i] >= ' ' && databuffer[i] <= '~'
+ && databuffer[i] != '|')
+ putchar (databuffer[i]);
+ else
+ putchar ('.');
+ }
+ putchar ('|');
+ putchar ('\n');
+ databufferlen = 0;
+ skipdatabufferlen = 0;
+}
+
+
+/* Add C to the raw data buffer and flush as needed. */
+static void
+addrawdata (int c)
+{
+ if ( databufferlen >= sizeof databuffer )
+ flushdatabuffer ();
+ databuffer[databufferlen++] = c;
+}
+
+
+static void
+printcursor (int both)
+{
+ int i;
+
+ flushdatabuffer ();
+ printf ("%8s ", "");
+ for (i=0; i < sizeof (databuffer); i++)
+ {
+ if (i == 8)
+ putchar (' ');
+ if (i+1 == nbytesprinted)
+ {
+ fputs (" ^ ", stdout);
+ if (!both)
+ break;
+ }
+ else
+ fputs (" ", stdout);
+ }
+ if (both)
+ {
+ fputs (" ", stdout);
+ for (i=0; i < nbytesprinted-1; i++)
+ putchar (' ');
+ putchar ('^');
+ }
+ databufferlen = skipdatabufferlen = nbytesprinted;
+}
+
+static void
+printerr (const char *text)
+{
+ printcursor (1);
+ printf ("\n Error: %s\n", text);
+}
+
+static void
+printctl (const char *text)
+{
+ if (verbose && !advanced)
+ {
+ printcursor (0);
+ printf ("%s\n", text);
+ }
+}
+
+static void
+printchr (int c)
+{
+ putchar (c);
+}
+
+/* static void */
+/* printhex (int c) */
+/* { */
+/* printf ("\\x%02x", c); */
+/* } */
+
+
+#if 0
+/****************
+ * Print SEXP to buffer using the MODE. Returns the length of the
+ * SEXP in buffer or 0 if the buffer is too short (We have at least an
+ * empty list consisting of 2 bytes). If a buffer of NULL is provided,
+ * the required length is returned.
+ */
+size_t
+gcry_sexp_sprint (const gcry_sexp_t list,
+ void *buffer, size_t maxlength )
+{
+ static unsigned char empty[3] = { ST_OPEN, ST_CLOSE, ST_STOP };
+ const unsigned char *s;
+ char *d;
+ DATALEN n;
+ char numbuf[20];
+ int i, indent = 0;
+
+ s = list? list->d : empty;
+ d = buffer;
+ while ( *s != ST_STOP )
+ {
+ switch ( *s )
+ {
+ case ST_OPEN:
+ s++;
+ if (indent)
+ putchar ('\n');
+ for (i=0; i < indent; i++)
+ putchar (' ');
+ putchar ('(');
+ indent++;
+ break;
+ case ST_CLOSE:
+ s++;
+ putchar (')');
+ indent--;
+ if (*s != ST_OPEN && *s != ST_STOP)
+ {
+ putchar ('\n');
+ for (i=0; i < indent; i++)
+ putchar (' ');
+ }
+ break;
+ case ST_DATA:
+ s++;
+ memcpy (&n, s, sizeof n);
+ s += sizeof n;
+ {
+ int type;
+ size_t nn;
+
+ switch ( (type=suitable_encoding (s, n)))
+ {
+ case 1: nn = convert_to_string (s, n, NULL); break;
+ case 2: nn = convert_to_token (s, n, NULL); break;
+ default: nn = convert_to_hex (s, n, NULL); break;
+ }
+ switch (type)
+ {
+ case 1: convert_to_string (s, n, d); break;
+ case 2: convert_to_token (s, n, d); break;
+ default: convert_to_hex (s, n, d); break;
+ }
+ d += nn;
+ if (s[n] != ST_CLOSE)
+ putchar (' ');
+ }
+ else
+ {
+ snprintf (numbuf, sizeof numbuf, "%u:", (unsigned int)n );
+ d = stpcpy (d, numbuf);
+ memcpy (d, s, n);
+ d += n;
+ }
+ s += n;
+ break;
+ default:
+ BUG ();
+ }
+ }
+ putchar ('\n');
+ return len;
+}
+#endif
+
+
+/* Prepare for saving a chunk of data. */
+static void
+init_data (void)
+{
+
+}
+
+/* Push C on the current data chunk. */
+static void
+push_data (int c)
+{
+ (void)c;
+}
+
+/* Flush and thus print the current data chunk. */
+static void
+flush_data (void)
+{
+
+}
+
+
+/* Returns 0 on success. */
+static int
+parse_and_print (FILE *fp)
+{
+ static const char tokenchars[] =
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-./_:*+=";
+ int c;
+ int level = 0;
+ int tokenc = 0;
+ int hexcount = 0;
+ int disphint = 0;
+ unsigned long datalen = 0;
+ char quote_buf[10];
+ int quote_idx = 0;
+ enum
+ {
+ INIT_STATE = 0, IN_NUMBER, PRE_DATA, IN_DATA, IN_STRING,
+ IN_ESCAPE, IN_OCT_ESC, IN_HEX_ESC,
+ CR_ESC, LF_ESC, IN_HEXFMT, IN_BASE64
+ }
+ state = INIT_STATE;
+
+
+ while ((c = my_getc (fp)) != EOF )
+ {
+ addrawdata (c);
+ switch (state)
+ {
+ case INIT_STATE:
+ if (tokenc)
+ {
+ if (strchr (tokenchars, c))
+ {
+ printchr (c);
+ continue;
+ }
+ tokenc = 0;
+ }
+ parse_init_state:
+ if (c == '(')
+ {
+ if (disphint)
+ {
+ printerr ("unmatched display hint");
+ disphint = 0;
+ }
+ printctl ("open");
+ level++;
+ }
+ else if (c == ')')
+ {
+ if (disphint)
+ {
+ printerr ("unmatched display hint");
+ disphint = 0;
+ }
+ printctl ("close");
+ level--;
+ }
+ else if (c == '\"')
+ {
+ state = IN_STRING;
+ printctl ("beginstring");
+ init_data ();
+ }
+ else if (c == '#')
+ {
+ state = IN_HEXFMT;
+ hexcount = 0;
+ printctl ("beginhex");
+ init_data ();
+ }
+ else if (c == '|')
+ {
+ state = IN_BASE64;
+ printctl ("beginbase64");
+ init_data ();
+ }
+ else if (c == '[')
+ {
+ if (disphint)
+ printerr ("nested display hint");
+ disphint = c;
+ }
+ else if (c == ']')
+ {
+ if (!disphint)
+ printerr ("no open display hint");
+ disphint = 0;
+ }
+ else if (c >= '0' && c <= '9')
+ {
+ if (c == '0')
+ printerr ("zero prefixed length");
+ state = IN_NUMBER;
+ datalen = (c - '0');
+ }
+ else if (strchr (tokenchars, c))
+ {
+ printchr (c);
+ tokenc = c;
+ }
+ else if (whitespace_p (c))
+ ;
+ else if (c == '{')
+ {
+ printerr ("rescanning is not supported");
+ }
+ else if (c == '&' || c == '\\')
+ {
+ printerr ("reserved punctuation detected");
+ }
+ else
+ {
+ printerr ("bad character detected");
+ }
+ break;
+
+ case IN_NUMBER:
+ if (digit_p (c))
+ {
+ unsigned long tmp = datalen * 10 + (c - '0');
+ if (tmp < datalen)
+ {
+ printerr ("overflow in data length");
+ state = INIT_STATE;
+ datalen = 0;
+ }
+ else
+ datalen = tmp;
+ }
+ else if (c == ':')
+ {
+ if (!datalen)
+ {
+ printerr ("no data length");
+ state = INIT_STATE;
+ }
+ else
+ state = PRE_DATA;
+ }
+ else if (c == '\"' || c == '#' || c == '|' )
+ {
+ /* We ignore the optional length and divert to the init
+ state parser code. */
+ goto parse_init_state;
+ }
+ else
+ printerr ("invalid length specification");
+ break;
+
+ case PRE_DATA:
+ state = IN_DATA;
+ printctl ("begindata");
+ init_data ();
+ case IN_DATA:
+ if (datalen)
+ {
+ push_data (c);
+ datalen--;
+ }
+ if (!datalen)
+ {
+ state = INIT_STATE;
+ printctl ("enddata");
+ flush_data ();
+ }
+ break;
+
+ case IN_STRING:
+ if (c == '\"')
+ {
+ printctl ("endstring");
+ flush_data ();
+ state = INIT_STATE;
+ }
+ else if (c == '\\')
+ state = IN_ESCAPE;
+ else
+ push_data (c);
+ break;
+
+ case IN_ESCAPE:
+ switch (c)
+ {
+ case 'b': push_data ('\b'); state = IN_STRING; break;
+ case 't': push_data ('\t'); state = IN_STRING; break;
+ case 'v': push_data ('\v'); state = IN_STRING; break;
+ case 'n': push_data ('\n'); state = IN_STRING; break;
+ case 'f': push_data ('\f'); state = IN_STRING; break;
+ case 'r': push_data ('\r'); state = IN_STRING; break;
+ case '"': push_data ('"'); state = IN_STRING; break;
+ case '\'': push_data ('\''); state = IN_STRING; break;
+ case '\\': push_data ('\\'); state = IN_STRING; break;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7':
+ state = IN_OCT_ESC;
+ quote_idx = 0;
+ quote_buf[quote_idx++] = c;
+ break;
+
+ case 'x':
+ state = IN_HEX_ESC;
+ quote_idx = 0;
+ break;
+
+ case '\r':
+ state = CR_ESC;
+ break;
+
+ case '\n':
+ state = LF_ESC;
+ break;
+
+ default:
+ printerr ("invalid escape sequence");
+ state = IN_STRING;
+ break;
+ }
+ break;
+
+ case IN_OCT_ESC:
+ if (quote_idx < 3 && strchr ("01234567", c))
+ {
+ quote_buf[quote_idx++] = c;
+ if (quote_idx == 3)
+ {
+ push_data ((unsigned int)quote_buf[0] * 8 * 8
+ + (unsigned int)quote_buf[1] * 8
+ + (unsigned int)quote_buf[2]);
+ state = IN_STRING;
+ }
+ }
+ else
+ state = IN_STRING;
+ break;
+ case IN_HEX_ESC:
+ if (quote_idx < 2 && strchr ("0123456789abcdefABCDEF", c))
+ {
+ quote_buf[quote_idx++] = c;
+ if (quote_idx == 2)
+ {
+ push_data (xtoi_1 (quote_buf[0]) * 16
+ + xtoi_1 (quote_buf[1]));
+ state = IN_STRING;
+ }
+ }
+ else
+ state = IN_STRING;
+ break;
+ case CR_ESC:
+ state = IN_STRING;
+ break;
+ case LF_ESC:
+ state = IN_STRING;
+ break;
+
+ case IN_HEXFMT:
+ if (hexdigit_p (c))
+ {
+ push_data (c);
+ hexcount++;
+ }
+ else if (c == '#')
+ {
+ if ((hexcount & 1))
+ printerr ("odd number of hex digits");
+ printctl ("endhex");
+ flush_data ();
+ state = INIT_STATE;
+ }
+ else if (!whitespace_p (c))
+ printerr ("bad hex character");
+ break;
+
+ case IN_BASE64:
+ if (c == '|')
+ {
+ printctl ("endbase64");
+ flush_data ();
+ state = INIT_STATE;
+ }
+ else
+ push_data (c);
+ break;
+
+ default:
+ logit ("invalid state %d detected", state);
+ exit (1);
+ }
+ }
+ flushdatabuffer ();
+ if (ferror (fp))
+ {
+ logit ("error reading input: %s\n", strerror (errno));
+ return -1;
+ }
+ return 0;
+}
+
+
+
+int
+main (int argc, char **argv)
+{
+ int rc;
+
+ if (argc)
+ {
+ argc--; argv++;
+ }
+ while (argc && **argv == '-' && (*argv)[1] == '-')
+ {
+ if (!(*argv)[2])
+ {
+ argc--; argv++;
+ break;
+ }
+ else if (!strcmp (*argv, "--version"))
+ print_version (0);
+ else if (!strcmp (*argv, "--help"))
+ print_version (1);
+ else if (!strcmp (*argv, "--verbose"))
+ {
+ argc--; argv++;
+ verbose = 1;
+ }
+ else if (!strcmp (*argv, "--decimal"))
+ {
+ argc--; argv++;
+ decimal = 1;
+ }
+ else if (!strcmp (*argv, "--assume-hex"))
+ {
+ argc--; argv++;
+ assume_hex = 1;
+ }
+ else if (!strcmp (*argv, "--advanced"))
+ {
+ argc--; argv++;
+ advanced = 1;
+ }
+ else
+ print_usage ();
+ }
+
+ if (!argc)
+ {
+ rc = parse_and_print (stdin);
+ }
+ else
+ {
+ rc = 0;
+ for (; argc; argv++, argc--)
+ {
+ FILE *fp = fopen (*argv, "rb");
+ if (!fp)
+ {
+ logit ("can't open `%s': %s\n", *argv, strerror (errno));
+ rc = 1;
+ }
+ else
+ {
+ if (parse_and_print (fp))
+ rc = 1;
+ fclose (fp);
+ }
+ }
+ }
+
+ return !!rc;
+}
diff --git a/grub-core/lib/libgcrypt/src/fips.c b/grub-core/lib/libgcrypt/src/fips.c
new file mode 100644
index 0000000..c5737a7
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/fips.c
@@ -0,0 +1,860 @@
+/* fips.c - FIPS mode management
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#ifdef ENABLE_HMAC_BINARY_CHECK
+# include <dlfcn.h>
+#endif
+#ifdef HAVE_SYSLOG
+# include <syslog.h>
+#endif /*HAVE_SYSLOG*/
+
+#include "g10lib.h"
+#include "ath.h"
+#include "cipher-proto.h"
+#include "hmac256.h"
+
+
+/* The name of the file used to foce libgcrypt into fips mode. */
+#define FIPS_FORCE_FILE "/etc/gcrypt/fips_enabled"
+
+
+/* The states of the finite state machine used in fips mode. */
+enum module_states
+ {
+ /* POWEROFF cannot be represented. */
+ STATE_POWERON = 0,
+ STATE_INIT,
+ STATE_SELFTEST,
+ STATE_OPERATIONAL,
+ STATE_ERROR,
+ STATE_FATALERROR,
+ STATE_SHUTDOWN
+ };
+
+
+/* Flag telling whether we are in fips mode. It uses inverse logic so
+ that fips mode is the default unless changed by the initialization
+ code. To check whether fips mode is enabled, use the function
+ fips_mode()! */
+static int no_fips_mode_required;
+
+/* Flag to indicate that we are in the enforced FIPS mode. */
+static int enforced_fips_mode;
+
+/* If this flag is set, the application may no longer assume that the
+ process is running in FIPS mode. This flag is protected by the
+ FSM_LOCK. */
+static int inactive_fips_mode;
+
+/* This is the lock we use to protect the FSM. */
+static ath_mutex_t fsm_lock = ATH_MUTEX_INITIALIZER;
+
+/* The current state of the FSM. The whole state machinery is only
+ used while in fips mode. Change this only while holding fsm_lock. */
+static enum module_states current_state;
+
+
+
+
+
+static void fips_new_state (enum module_states new_state);
+
+
+
+/* Convert lowercase hex digits; assumes valid hex digits. */
+#define loxtoi_1(p) (*(p) <= '9'? (*(p)- '0'): (*(p)-'a'+10))
+#define loxtoi_2(p) ((loxtoi_1(p) * 16) + loxtoi_1((p)+1))
+
+/* Returns true if P points to a lowercase hex digit. */
+#define loxdigit_p(p) !!strchr ("01234567890abcdef", *(p))
+
+
+
+/* Check whether the OS is in FIPS mode and record that in a module
+ local variable. If FORCE is passed as true, fips mode will be
+ enabled anyway. Note: This function is not thread-safe and should
+ be called before any threads are created. This function may only
+ be called once. */
+void
+_gcry_initialize_fips_mode (int force)
+{
+ static int done;
+ gpg_error_t err;
+
+ /* Make sure we are not accidently called twice. */
+ if (done)
+ {
+ if ( fips_mode () )
+ {
+ fips_new_state (STATE_FATALERROR);
+ fips_noreturn ();
+ }
+ /* If not in fips mode an assert is sufficient. */
+ gcry_assert (!done);
+ }
+ done = 1;
+
+ /* If the calling application explicitly requested fipsmode, do so. */
+ if (force)
+ {
+ gcry_assert (!no_fips_mode_required);
+ goto leave;
+ }
+
+ /* For testing the system it is useful to override the system
+ provided detection of the FIPS mode and force FIPS mode using a
+ file. The filename is hardwired so that there won't be any
+ confusion on whether /etc/gcrypt/ or /usr/local/etc/gcrypt/ is
+ actually used. The file itself may be empty. */
+ if ( !access (FIPS_FORCE_FILE, F_OK) )
+ {
+ gcry_assert (!no_fips_mode_required);
+ goto leave;
+ }
+
+ /* Checking based on /proc file properties. */
+ {
+ static const char procfname[] = "/proc/sys/crypto/fips_enabled";
+ FILE *fp;
+ int saved_errno;
+
+ fp = fopen (procfname, "r");
+ if (fp)
+ {
+ char line[256];
+
+ if (fgets (line, sizeof line, fp) && atoi (line))
+ {
+ /* System is in fips mode. */
+ fclose (fp);
+ gcry_assert (!no_fips_mode_required);
+ goto leave;
+ }
+ fclose (fp);
+ }
+ else if ((saved_errno = errno) != ENOENT
+ && saved_errno != EACCES
+ && !access ("/proc/version", F_OK) )
+ {
+ /* Problem reading the fips file despite that we have the proc
+ file system. We better stop right away. */
+ log_info ("FATAL: error reading `%s' in libgcrypt: %s\n",
+ procfname, strerror (saved_errno));
+#ifdef HAVE_SYSLOG
+ syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
+ "reading `%s' failed: %s - abort",
+ procfname, strerror (saved_errno));
+#endif /*HAVE_SYSLOG*/
+ abort ();
+ }
+ }
+
+ /* Fips not not requested, set flag. */
+ no_fips_mode_required = 1;
+
+ leave:
+ if (!no_fips_mode_required)
+ {
+ /* Yes, we are in FIPS mode. */
+ FILE *fp;
+
+ /* Intitialize the lock to protect the FSM. */
+ err = ath_mutex_init (&fsm_lock);
+ if (err)
+ {
+ /* If that fails we can't do anything but abort the
+ process. We need to use log_info so that the FSM won't
+ get involved. */
+ log_info ("FATAL: failed to create the FSM lock in libgcrypt: %s\n",
+ strerror (err));
+#ifdef HAVE_SYSLOG
+ syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
+ "creating FSM lock failed: %s - abort",
+ strerror (err));
+#endif /*HAVE_SYSLOG*/
+ abort ();
+ }
+
+
+ /* If the FIPS force files exists, is readable and has a number
+ != 0 on its first line, we enable the enforced fips mode. */
+ fp = fopen (FIPS_FORCE_FILE, "r");
+ if (fp)
+ {
+ char line[256];
+
+ if (fgets (line, sizeof line, fp) && atoi (line))
+ enforced_fips_mode = 1;
+ fclose (fp);
+ }
+
+ /* Now get us into the INIT state. */
+ fips_new_state (STATE_INIT);
+
+ }
+ return;
+}
+
+static void
+lock_fsm (void)
+{
+ gpg_error_t err;
+
+ err = ath_mutex_lock (&fsm_lock);
+ if (err)
+ {
+ log_info ("FATAL: failed to acquire the FSM lock in libgrypt: %s\n",
+ strerror (err));
+#ifdef HAVE_SYSLOG
+ syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
+ "acquiring FSM lock failed: %s - abort",
+ strerror (err));
+#endif /*HAVE_SYSLOG*/
+ abort ();
+ }
+}
+
+static void
+unlock_fsm (void)
+{
+ gpg_error_t err;
+
+ err = ath_mutex_unlock (&fsm_lock);
+ if (err)
+ {
+ log_info ("FATAL: failed to release the FSM lock in libgrypt: %s\n",
+ strerror (err));
+#ifdef HAVE_SYSLOG
+ syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
+ "releasing FSM lock failed: %s - abort",
+ strerror (err));
+#endif /*HAVE_SYSLOG*/
+ abort ();
+ }
+}
+
+
+/* This function returns true if fips mode is enabled. This is
+ independent of the fips required finite state machine and only used
+ to enable fips specific code. Please use the fips_mode macro
+ instead of calling this function directly. */
+int
+_gcry_fips_mode (void)
+{
+ /* No locking is required because we have the requirement that this
+ variable is only initialized once with no other threads
+ existing. */
+ return !no_fips_mode_required;
+}
+
+
+/* Return a flag telling whether we are in the enforced fips mode. */
+int
+_gcry_enforced_fips_mode (void)
+{
+ if (!_gcry_fips_mode ())
+ return 0;
+ return enforced_fips_mode;
+}
+
+/* Set a flag telling whether we are in the enforced fips mode. */
+void
+_gcry_set_enforced_fips_mode (void)
+{
+ enforced_fips_mode = 1;
+}
+
+/* If we do not want to enforce the fips mode, we can set a flag so
+ that the application may check whether it is still in fips mode.
+ TEXT will be printed as part of a syslog message. This function
+ may only be be called if in fips mode. */
+void
+_gcry_inactivate_fips_mode (const char *text)
+{
+ gcry_assert (_gcry_fips_mode ());
+
+ if (_gcry_enforced_fips_mode () )
+ {
+ /* Get us into the error state. */
+ fips_signal_error (text);
+ return;
+ }
+
+ lock_fsm ();
+ if (!inactive_fips_mode)
+ {
+ inactive_fips_mode = 1;
+ unlock_fsm ();
+#ifdef HAVE_SYSLOG
+ syslog (LOG_USER|LOG_WARNING, "Libgcrypt warning: "
+ "%s - FIPS mode inactivated", text);
+#endif /*HAVE_SYSLOG*/
+ }
+ else
+ unlock_fsm ();
+}
+
+
+/* Return the FIPS mode inactive flag. If it is true the FIPS mode is
+ not anymore active. */
+int
+_gcry_is_fips_mode_inactive (void)
+{
+ int flag;
+
+ if (!_gcry_fips_mode ())
+ return 0;
+ lock_fsm ();
+ flag = inactive_fips_mode;
+ unlock_fsm ();
+ return flag;
+}
+
+
+
+static const char *
+state2str (enum module_states state)
+{
+ const char *s;
+
+ switch (state)
+ {
+ case STATE_POWERON: s = "Power-On"; break;
+ case STATE_INIT: s = "Init"; break;
+ case STATE_SELFTEST: s = "Self-Test"; break;
+ case STATE_OPERATIONAL: s = "Operational"; break;
+ case STATE_ERROR: s = "Error"; break;
+ case STATE_FATALERROR: s = "Fatal-Error"; break;
+ case STATE_SHUTDOWN: s = "Shutdown"; break;
+ default: s = "?"; break;
+ }
+ return s;
+}
+
+
+/* Return true if the library is in the operational state. */
+int
+_gcry_fips_is_operational (void)
+{
+ int result;
+
+ if (!fips_mode ())
+ result = 1;
+ else
+ {
+ lock_fsm ();
+ if (current_state == STATE_INIT)
+ {
+ /* If we are still in the INIT state, we need to run the
+ selftests so that the FSM can eventually get into
+ operational state. Given that we would need a 2-phase
+ initialization of libgcrypt, but that has traditionally
+ not been enforced, we use this on demand self-test
+ checking. Note that Proper applications would do the
+ application specific libgcrypt initialization between a
+ gcry_check_version() and gcry_control
+ (GCRYCTL_INITIALIZATION_FINISHED) where the latter will
+ run the selftests. The drawback of these on-demand
+ self-tests are a small chance that self-tests are
+ performed by severeal threads; that is no problem because
+ our FSM make sure that we won't oversee any error. */
+ unlock_fsm ();
+ _gcry_fips_run_selftests (0);
+ lock_fsm ();
+ }
+
+ result = (current_state == STATE_OPERATIONAL);
+ unlock_fsm ();
+ }
+ return result;
+}
+
+
+/* This is test on whether the library is in the operational state. In
+ contrast to _gcry_fips_is_operational this function won't do a
+ state transition on the fly. */
+int
+_gcry_fips_test_operational (void)
+{
+ int result;
+
+ if (!fips_mode ())
+ result = 1;
+ else
+ {
+ lock_fsm ();
+ result = (current_state == STATE_OPERATIONAL);
+ unlock_fsm ();
+ }
+ return result;
+}
+
+
+/* This is a test on whether the library is in the error or
+ operational state. */
+int
+_gcry_fips_test_error_or_operational (void)
+{
+ int result;
+
+ if (!fips_mode ())
+ result = 1;
+ else
+ {
+ lock_fsm ();
+ result = (current_state == STATE_OPERATIONAL
+ || current_state == STATE_ERROR);
+ unlock_fsm ();
+ }
+ return result;
+}
+
+
+static void
+reporter (const char *domain, int algo, const char *what, const char *errtxt)
+{
+ if (!errtxt && !_gcry_log_verbosity (2))
+ return;
+
+ log_info ("libgcrypt selftest: %s %s%s (%d): %s%s%s%s\n",
+ !strcmp (domain, "hmac")? "digest":domain,
+ !strcmp (domain, "hmac")? "HMAC-":"",
+ !strcmp (domain, "cipher")? _gcry_cipher_algo_name (algo) :
+ !strcmp (domain, "digest")? _gcry_md_algo_name (algo) :
+ !strcmp (domain, "hmac")? _gcry_md_algo_name (algo) :
+ !strcmp (domain, "pubkey")? _gcry_pk_algo_name (algo) : "",
+ algo, errtxt? errtxt:"Okay",
+ what?" (":"", what? what:"", what?")":"");
+}
+
+/* Run self-tests for all required cipher algorithms. Return 0 on
+ success. */
+static int
+run_cipher_selftests (int extended)
+{
+ static int algos[] =
+ {
+ GCRY_CIPHER_3DES,
+ GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES192,
+ GCRY_CIPHER_AES256,
+ 0
+ };
+ int idx;
+ gpg_error_t err;
+ int anyerr = 0;
+
+ for (idx=0; algos[idx]; idx++)
+ {
+ err = _gcry_cipher_selftest (algos[idx], extended, reporter);
+ reporter ("cipher", algos[idx], NULL,
+ err? gpg_strerror (err):NULL);
+ if (err)
+ anyerr = 1;
+ }
+ return anyerr;
+}
+
+
+/* Run self-tests for all required hash algorithms. Return 0 on
+ success. */
+static int
+run_digest_selftests (int extended)
+{
+ static int algos[] =
+ {
+ GCRY_MD_SHA1,
+ GCRY_MD_SHA224,
+ GCRY_MD_SHA256,
+ GCRY_MD_SHA384,
+ GCRY_MD_SHA512,
+ 0
+ };
+ int idx;
+ gpg_error_t err;
+ int anyerr = 0;
+
+ for (idx=0; algos[idx]; idx++)
+ {
+ err = _gcry_md_selftest (algos[idx], extended, reporter);
+ reporter ("digest", algos[idx], NULL,
+ err? gpg_strerror (err):NULL);
+ if (err)
+ anyerr = 1;
+ }
+ return anyerr;
+}
+
+
+/* Run self-tests for all HMAC algorithms. Return 0 on success. */
+static int
+run_hmac_selftests (int extended)
+{
+ static int algos[] =
+ {
+ GCRY_MD_SHA1,
+ GCRY_MD_SHA224,
+ GCRY_MD_SHA256,
+ GCRY_MD_SHA384,
+ GCRY_MD_SHA512,
+ 0
+ };
+ int idx;
+ gpg_error_t err;
+ int anyerr = 0;
+
+ for (idx=0; algos[idx]; idx++)
+ {
+ err = _gcry_hmac_selftest (algos[idx], extended, reporter);
+ reporter ("hmac", algos[idx], NULL,
+ err? gpg_strerror (err):NULL);
+ if (err)
+ anyerr = 1;
+ }
+ return anyerr;
+}
+
+
+/* Run self-tests for all required public key algorithms. Return 0 on
+ success. */
+static int
+run_pubkey_selftests (int extended)
+{
+ static int algos[] =
+ {
+ GCRY_PK_RSA,
+ GCRY_PK_DSA,
+ /* GCRY_PK_ECDSA is not enabled in fips mode. */
+ 0
+ };
+ int idx;
+ gpg_error_t err;
+ int anyerr = 0;
+
+ for (idx=0; algos[idx]; idx++)
+ {
+ err = _gcry_pk_selftest (algos[idx], extended, reporter);
+ reporter ("pubkey", algos[idx], NULL,
+ err? gpg_strerror (err):NULL);
+ if (err)
+ anyerr = 1;
+ }
+ return anyerr;
+}
+
+
+/* Run self-tests for the random number generator. Returns 0 on
+ success. */
+static int
+run_random_selftests (void)
+{
+ gpg_error_t err;
+
+ err = _gcry_random_selftest (reporter);
+ reporter ("random", 0, NULL, err? gpg_strerror (err):NULL);
+
+ return !!err;
+}
+
+/* Run an integrity check on the binary. Returns 0 on success. */
+static int
+check_binary_integrity (void)
+{
+#ifdef ENABLE_HMAC_BINARY_CHECK
+ gpg_error_t err;
+ Dl_info info;
+ unsigned char digest[32];
+ int dlen;
+ char *fname = NULL;
+ const char key[] = "What am I, a doctor or a moonshuttle conductor?";
+
+ if (!dladdr ("gcry_check_version", &info))
+ err = gpg_error_from_syserror ();
+ else
+ {
+ dlen = _gcry_hmac256_file (digest, sizeof digest, info.dli_fname,
+ key, strlen (key));
+ if (dlen < 0)
+ err = gpg_error_from_syserror ();
+ else if (dlen != 32)
+ err = gpg_error (GPG_ERR_INTERNAL);
+ else
+ {
+ fname = gcry_malloc (strlen (info.dli_fname) + 1 + 5 + 1 );
+ if (!fname)
+ err = gpg_error_from_syserror ();
+ else
+ {
+ FILE *fp;
+ char *p;
+
+ /* Prefix the basename with a dot. */
+ strcpy (fname, info.dli_fname);
+ p = strrchr (fname, '/');
+ if (p)
+ p++;
+ else
+ p = fname;
+ memmove (p+1, p, strlen (p)+1);
+ *p = '.';
+ strcat (fname, ".hmac");
+
+ /* Open the file. */
+ fp = fopen (fname, "r");
+ if (!fp)
+ err = gpg_error_from_syserror ();
+ else
+ {
+ /* A buffer of 64 bytes plus one for a LF and one to
+ detect garbage. */
+ unsigned char buffer[64+1+1];
+ const unsigned char *s;
+ int n;
+
+ /* The HMAC files consists of lowercase hex digits
+ only with an optional trailing linefeed. Fail if
+ there is any garbage. */
+ err = gpg_error (GPG_ERR_SELFTEST_FAILED);
+ n = fread (buffer, 1, sizeof buffer, fp);
+ if (n == 64 || (n == 65 && buffer[64] == '\n'))
+ {
+ buffer[64] = 0;
+ for (n=0, s= buffer;
+ n < 32 && loxdigit_p (s) && loxdigit_p (s+1);
+ n++, s += 2)
+ buffer[n] = loxtoi_2 (s);
+ if ( n == 32 && !memcmp (digest, buffer, 32) )
+ err = 0;
+ }
+ fclose (fp);
+ }
+ }
+ }
+ }
+ reporter ("binary", 0, fname, err? gpg_strerror (err):NULL);
+#ifdef HAVE_SYSLOG
+ if (err)
+ syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
+ "integrity check using `%s' failed: %s",
+ fname? fname:"[?]", gpg_strerror (err));
+#endif /*HAVE_SYSLOG*/
+ gcry_free (fname);
+ return !!err;
+#else
+ return 0;
+#endif
+}
+
+
+/* Run the self-tests. If EXTENDED is true, extended versions of the
+ selftest are run, that is more tests than required by FIPS. */
+gpg_err_code_t
+_gcry_fips_run_selftests (int extended)
+{
+ enum module_states result = STATE_ERROR;
+ gcry_err_code_t ec = GPG_ERR_SELFTEST_FAILED;
+
+ if (fips_mode ())
+ fips_new_state (STATE_SELFTEST);
+
+ if (run_cipher_selftests (extended))
+ goto leave;
+
+ if (run_digest_selftests (extended))
+ goto leave;
+
+ if (run_hmac_selftests (extended))
+ goto leave;
+
+ /* Run random tests before the pubkey tests because the latter
+ require random. */
+ if (run_random_selftests ())
+ goto leave;
+
+ if (run_pubkey_selftests (extended))
+ goto leave;
+
+ /* Now check the integrity of the binary. We do this this after
+ having checked the HMAC code. */
+ if (check_binary_integrity ())
+ goto leave;
+
+ /* All selftests passed. */
+ result = STATE_OPERATIONAL;
+ ec = 0;
+
+ leave:
+ if (fips_mode ())
+ fips_new_state (result);
+
+ return ec;
+}
+
+
+/* This function is used to tell the FSM about errors in the library.
+ The FSM will be put into an error state. This function should not
+ be called directly but by one of the macros
+
+ fips_signal_error (description)
+ fips_signal_fatal_error (description)
+
+ where DESCRIPTION is a string describing the error. */
+void
+_gcry_fips_signal_error (const char *srcfile, int srcline, const char *srcfunc,
+ int is_fatal, const char *description)
+{
+ if (!fips_mode ())
+ return; /* Not required. */
+
+ /* Set new state before printing an error. */
+ fips_new_state (is_fatal? STATE_FATALERROR : STATE_ERROR);
+
+ /* Print error. */
+ log_info ("%serror in libgcrypt, file %s, line %d%s%s: %s\n",
+ is_fatal? "fatal ":"",
+ srcfile, srcline,
+ srcfunc? ", function ":"", srcfunc? srcfunc:"",
+ description? description : "no description available");
+#ifdef HAVE_SYSLOG
+ syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
+ "%serror in file %s, line %d%s%s: %s",
+ is_fatal? "fatal ":"",
+ srcfile, srcline,
+ srcfunc? ", function ":"", srcfunc? srcfunc:"",
+ description? description : "no description available");
+#endif /*HAVE_SYSLOG*/
+}
+
+
+/* Perform a state transition to NEW_STATE. If this is an invalid
+ transition, the module will go into a fatal error state. */
+static void
+fips_new_state (enum module_states new_state)
+{
+ int ok = 0;
+ enum module_states last_state;
+
+ lock_fsm ();
+
+ last_state = current_state;
+ switch (current_state)
+ {
+ case STATE_POWERON:
+ if (new_state == STATE_INIT
+ || new_state == STATE_ERROR
+ || new_state == STATE_FATALERROR)
+ ok = 1;
+ break;
+
+ case STATE_INIT:
+ if (new_state == STATE_SELFTEST
+ || new_state == STATE_ERROR
+ || new_state == STATE_FATALERROR)
+ ok = 1;
+ break;
+
+ case STATE_SELFTEST:
+ if (new_state == STATE_OPERATIONAL
+ || new_state == STATE_ERROR
+ || new_state == STATE_FATALERROR)
+ ok = 1;
+ break;
+
+ case STATE_OPERATIONAL:
+ if (new_state == STATE_SHUTDOWN
+ || new_state == STATE_SELFTEST
+ || new_state == STATE_ERROR
+ || new_state == STATE_FATALERROR)
+ ok = 1;
+ break;
+
+ case STATE_ERROR:
+ if (new_state == STATE_SHUTDOWN
+ || new_state == STATE_ERROR
+ || new_state == STATE_FATALERROR
+ || new_state == STATE_SELFTEST)
+ ok = 1;
+ break;
+
+ case STATE_FATALERROR:
+ if (new_state == STATE_SHUTDOWN )
+ ok = 1;
+ break;
+
+ case STATE_SHUTDOWN:
+ /* We won't see any transition *from* Shutdown because the only
+ allowed new state is Power-Off and that one can't be
+ represented. */
+ break;
+
+ }
+
+ if (ok)
+ {
+ current_state = new_state;
+ }
+
+ unlock_fsm ();
+
+ if (!ok || _gcry_log_verbosity (2))
+ log_info ("libgcrypt state transition %s => %s %s\n",
+ state2str (last_state), state2str (new_state),
+ ok? "granted":"denied");
+
+ if (!ok)
+ {
+ /* Invalid state transition. Halting library. */
+#ifdef HAVE_SYSLOG
+ syslog (LOG_USER|LOG_ERR,
+ "Libgcrypt error: invalid state transition %s => %s",
+ state2str (last_state), state2str (new_state));
+#endif /*HAVE_SYSLOG*/
+ fips_noreturn ();
+ }
+ else if (new_state == STATE_ERROR || new_state == STATE_FATALERROR)
+ {
+#ifdef HAVE_SYSLOG
+ syslog (LOG_USER|LOG_WARNING,
+ "Libgcrypt notice: state transition %s => %s",
+ state2str (last_state), state2str (new_state));
+#endif /*HAVE_SYSLOG*/
+ }
+}
+
+
+
+
+/* This function should be called to ensure that the execution shall
+ not continue. */
+void
+_gcry_fips_noreturn (void)
+{
+#ifdef HAVE_SYSLOG
+ syslog (LOG_USER|LOG_ERR, "Libgcrypt terminated the application");
+#endif /*HAVE_SYSLOG*/
+ fflush (NULL);
+ abort ();
+ /*NOTREACHED*/
+}
diff --git a/grub-core/lib/libgcrypt/src/g10lib.h b/grub-core/lib/libgcrypt/src/g10lib.h
new file mode 100644
index 0000000..6bde20f
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/g10lib.h
@@ -0,0 +1,302 @@
+/* g10lib.h - Internal definitions for libgcrypt
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
+ * 2007, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This header is to be used inside of libgcrypt in place of gcrypt.h.
+ This way we can better distinguish between internal and external
+ usage of gcrypt.h. */
+
+#ifndef G10LIB_H
+#define G10LIB_H 1
+
+#ifdef _GCRYPT_H
+#error gcrypt.h already included
+#endif
+
+#ifndef _GCRYPT_IN_LIBGCRYPT
+#error something is wrong with config.h
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "visibility.h"
+#include "types.h"
+
+
+
+
+/* Attribute handling macros. */
+
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
+#define JNLIB_GCC_M_FUNCTION 1
+#define JNLIB_GCC_A_NR __attribute__ ((noreturn))
+#define JNLIB_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a)))
+#define JNLIB_GCC_A_NR_PRINTF( f, a ) \
+ __attribute__ ((noreturn, format (printf,f,a)))
+#define GCC_ATTR_NORETURN __attribute__ ((__noreturn__))
+#else
+#define JNLIB_GCC_A_NR
+#define JNLIB_GCC_A_PRINTF( f, a )
+#define JNLIB_GCC_A_NR_PRINTF( f, a )
+#define GCC_ATTR_NORETURN
+#endif
+
+#if __GNUC__ >= 3
+/* According to glibc this attribute is available since 2.8 however we
+ better play safe and use it only with gcc 3 or newer. */
+#define GCC_ATTR_FORMAT_ARG(a) __attribute__ ((format_arg (a)))
+#else
+#define GCC_ATTR_FORMAT_ARG(a)
+#endif
+
+
+/* Gettext macros. */
+
+/* Some handy macros */
+#ifndef STR
+#define STR(v) #v
+#endif
+#define STR2(v) STR(v)
+#define DIM(v) (sizeof(v)/sizeof((v)[0]))
+#define DIMof(type,member) DIM(((type *)0)->member)
+
+
+
+/*-- src/global.c -*/
+int _gcry_global_is_operational (void);
+gcry_error_t _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr);
+void _gcry_check_heap (const void *a);
+int _gcry_get_debug_flag (unsigned int mask);
+
+
+/*-- src/misc.c --*/
+
+#if defined(JNLIB_GCC_M_FUNCTION) || __STDC_VERSION__ >= 199901L
+void _gcry_bug (const char *file, int line,
+ const char *func) GCC_ATTR_NORETURN;
+void _gcry_assert_failed (const char *expr, const char *file, int line,
+ const char *func) GCC_ATTR_NORETURN;
+#else
+void _gcry_bug (const char *file, int line);
+void _gcry_assert_failed (const char *expr, const char *file, int line);
+#endif
+
+const char *_gcry_gettext (const char *key) GCC_ATTR_FORMAT_ARG(1);
+void _gcry_fatal_error(int rc, const char *text ) JNLIB_GCC_A_NR;
+void _gcry_log( int level, const char *fmt, ... ) JNLIB_GCC_A_PRINTF(2,3);
+void _gcry_log_bug( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2);
+void _gcry_log_fatal( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2);
+void _gcry_log_error( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
+void _gcry_log_info( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
+int _gcry_log_info_with_dummy_fp (FILE *fp, const char *fmt, ... )
+ JNLIB_GCC_A_PRINTF(2,3);
+void _gcry_log_debug( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
+void _gcry_log_printf ( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
+void _gcry_log_printhex (const char *text, const void *buffer, size_t length);
+
+void _gcry_set_log_verbosity( int level );
+int _gcry_log_verbosity( int level );
+
+#ifdef JNLIB_GCC_M_FUNCTION
+#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
+#define gcry_assert(expr) ((expr)? (void)0 \
+ : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
+#elif __STDC_VERSION__ >= 199901L
+#define BUG() _gcry_bug( __FILE__ , __LINE__, __func__ )
+#define gcry_assert(expr) ((expr)? (void)0 \
+ : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __func__))
+#else
+#define BUG() _gcry_bug( __FILE__ , __LINE__ )
+#define gcry_assert(expr) ((expr)? (void)0 \
+ : _gcry_assert_failed (STR(expr), __FILE__, __LINE__))
+#endif
+
+
+#define log_bug _gcry_log_bug
+#define log_fatal _gcry_log_fatal
+#define log_error _gcry_log_error
+#define log_info _gcry_log_info
+#define log_debug _gcry_log_debug
+#define log_printf _gcry_log_printf
+#define log_printhex _gcry_log_printhex
+
+
+/*-- src/hwfeatures.c --*/
+/* (Do not change these values unless synced with the asm code.) */
+#define HWF_PADLOCK_RNG 1
+#define HWF_PADLOCK_AES 2
+#define HWF_PADLOCK_SHA 4
+#define HWF_PADLOCK_MMUL 8
+
+#define HWF_INTEL_AESNI 256
+
+
+unsigned int _gcry_get_hw_features (void);
+void _gcry_detect_hw_features (unsigned int);
+
+
+/*-- mpi/mpiutil.c --*/
+const char *_gcry_mpi_get_hw_config (void);
+
+
+/*-- cipher/pubkey.c --*/
+
+/* FIXME: shouldn't this go into mpi.h? */
+#ifndef mpi_powm
+#define mpi_powm(w,b,e,m) gcry_mpi_powm( (w), (b), (e), (m) )
+#endif
+
+/*-- primegen.c --*/
+gcry_mpi_t _gcry_generate_secret_prime (unsigned int nbits,
+ gcry_random_level_t random_level,
+ int (*extra_check)(void*, gcry_mpi_t),
+ void *extra_check_arg);
+gcry_mpi_t _gcry_generate_public_prime (unsigned int nbits,
+ gcry_random_level_t random_level,
+ int (*extra_check)(void*, gcry_mpi_t),
+ void *extra_check_arg);
+gcry_mpi_t _gcry_generate_elg_prime (int mode,
+ unsigned int pbits, unsigned int qbits,
+ gcry_mpi_t g, gcry_mpi_t **factors);
+gcry_mpi_t _gcry_derive_x931_prime (const gcry_mpi_t xp,
+ const gcry_mpi_t xp1, const gcry_mpi_t xp2,
+ const gcry_mpi_t e,
+ gcry_mpi_t *r_p1, gcry_mpi_t *r_p2);
+gpg_err_code_t _gcry_generate_fips186_2_prime
+ (unsigned int pbits, unsigned int qbits,
+ const void *seed, size_t seedlen,
+ gcry_mpi_t *r_q, gcry_mpi_t *r_p,
+ int *r_counter,
+ void **r_seed, size_t *r_seedlen);
+gpg_err_code_t _gcry_generate_fips186_3_prime
+ (unsigned int pbits, unsigned int qbits,
+ const void *seed, size_t seedlen,
+ gcry_mpi_t *r_q, gcry_mpi_t *r_p,
+ int *r_counter,
+ void **r_seed, size_t *r_seedlen, int *r_hashalgo);
+
+
+/* Replacements of missing functions (missing-string.c). */
+#ifndef HAVE_STPCPY
+char *stpcpy (char *a, const char *b);
+#endif
+#ifndef HAVE_STRCASECMP
+int strcasecmp (const char *a, const char *b) _GCRY_GCC_ATTR_PURE;
+#endif
+
+
+/* Macros used to rename missing functions. */
+#ifndef HAVE_STRTOUL
+#define strtoul(a,b,c) ((unsigned long)strtol((a),(b),(c)))
+#endif
+#ifndef HAVE_MEMMOVE
+#define memmove(d, s, n) bcopy((s), (d), (n))
+#endif
+#ifndef HAVE_STRICMP
+#define stricmp(a,b) strcasecmp( (a), (b) )
+#endif
+#ifndef HAVE_ATEXIT
+#define atexit(a) (on_exit((a),0))
+#endif
+#ifndef HAVE_RAISE
+#define raise(a) kill(getpid(), (a))
+#endif
+
+
+/* Stack burning. */
+
+void _gcry_burn_stack (int bytes);
+
+
+/* To avoid that a compiler optimizes certain memset calls away, these
+ macros may be used instead. */
+#define wipememory2(_ptr,_set,_len) do { \
+ volatile char *_vptr=(volatile char *)(_ptr); \
+ size_t _vlen=(_len); \
+ while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
+ } while(0)
+#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
+
+
+
+/* Digit predicates. */
+
+#define digitp(p) (*(p) >= '0' && *(p) <= '9')
+#define octdigitp(p) (*(p) >= '0' && *(p) <= '7')
+#define alphap(a) ( (*(a) >= 'A' && *(a) <= 'Z') \
+ || (*(a) >= 'a' && *(a) <= 'z'))
+#define hexdigitp(a) (digitp (a) \
+ || (*(a) >= 'A' && *(a) <= 'F') \
+ || (*(a) >= 'a' && *(a) <= 'f'))
+
+
+/*-- sexp.c --*/
+gcry_error_t _gcry_sexp_vbuild (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, va_list arg_ptr);
+char *_gcry_sexp_nth_string (const gcry_sexp_t list, int number);
+
+
+/*-- fips.c --*/
+
+void _gcry_initialize_fips_mode (int force);
+
+int _gcry_fips_mode (void);
+#define fips_mode() _gcry_fips_mode ()
+
+int _gcry_enforced_fips_mode (void);
+
+void _gcry_set_enforced_fips_mode (void);
+
+void _gcry_inactivate_fips_mode (const char *text);
+int _gcry_is_fips_mode_inactive (void);
+
+
+void _gcry_fips_signal_error (const char *srcfile,
+ int srcline,
+ const char *srcfunc,
+ int is_fatal,
+ const char *description);
+#ifdef JNLIB_GCC_M_FUNCTION
+# define fips_signal_error(a) \
+ _gcry_fips_signal_error (__FILE__, __LINE__, __FUNCTION__, 0, (a))
+# define fips_signal_fatal_error(a) \
+ _gcry_fips_signal_error (__FILE__, __LINE__, __FUNCTION__, 1, (a))
+#else
+# define fips_signal_error(a) \
+ _gcry_fips_signal_error (__FILE__, __LINE__, NULL, 0, (a))
+# define fips_signal_fatal_error(a) \
+ _gcry_fips_signal_error (__FILE__, __LINE__, NULL, 1, (a))
+#endif
+
+int _gcry_fips_is_operational (void);
+#define fips_is_operational() (_gcry_global_is_operational ())
+#define fips_not_operational() (GCRY_GPG_ERR_NOT_OPERATIONAL)
+
+int _gcry_fips_test_operational (void);
+int _gcry_fips_test_error_or_operational (void);
+
+gpg_err_code_t _gcry_fips_run_selftests (int extended);
+
+void _gcry_fips_noreturn (void);
+#define fips_noreturn() (_gcry_fips_noreturn ())
+
+
+
+#endif /* G10LIB_H */
diff --git a/grub-core/lib/libgcrypt/src/gcrypt-module.h b/grub-core/lib/libgcrypt/src/gcrypt-module.h
new file mode 100644
index 0000000..f39e2b5
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/gcrypt-module.h
@@ -0,0 +1,240 @@
+/* gcrypt-module.h - GNU Cryptographic Library Interface
+ Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+
+ This file is part of Libgcrypt.
+
+ Libgcrypt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Libgcrypt is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ This file contains the necessary declarations/definitions for
+ working with Libgcrypt modules.
+ */
+
+#ifndef _GCRYPT_MODULE_H
+#define _GCRYPT_MODULE_H
+
+#ifdef __cplusplus
+extern "C" {
+#if 0 /* keep Emacsens's auto-indent happy */
+}
+#endif
+#endif
+
+/* The interfaces using the module system reserve a certain range of
+ IDs for application use. These IDs are not valid within Libgcrypt
+ but Libgcrypt makes sure never to allocate such a module ID. */
+#define GCRY_MODULE_ID_USER 1024
+#define GCRY_MODULE_ID_USER_LAST 4095
+
+
+/* This type represents a `module'. */
+typedef struct gcry_module *gcry_module_t;
+
+/* Check that the library fulfills the version requirement. */
+
+/* Type for the cipher_setkey function. */
+typedef gcry_err_code_t (*gcry_cipher_setkey_t) (void *c,
+ const unsigned char *key,
+ unsigned keylen);
+
+/* Type for the cipher_encrypt function. */
+typedef void (*gcry_cipher_encrypt_t) (void *c,
+ unsigned char *outbuf,
+ const unsigned char *inbuf);
+
+/* Type for the cipher_decrypt function. */
+typedef void (*gcry_cipher_decrypt_t) (void *c,
+ unsigned char *outbuf,
+ const unsigned char *inbuf);
+
+/* Type for the cipher_stencrypt function. */
+typedef void (*gcry_cipher_stencrypt_t) (void *c,
+ unsigned char *outbuf,
+ const unsigned char *inbuf,
+ unsigned int n);
+
+/* Type for the cipher_stdecrypt function. */
+typedef void (*gcry_cipher_stdecrypt_t) (void *c,
+ unsigned char *outbuf,
+ const unsigned char *inbuf,
+ unsigned int n);
+
+typedef struct gcry_cipher_oid_spec
+{
+ const char *oid;
+ int mode;
+} gcry_cipher_oid_spec_t;
+
+/* Module specification structure for ciphers. */
+typedef struct gcry_cipher_spec
+{
+ const char *name;
+ const char **aliases;
+ gcry_cipher_oid_spec_t *oids;
+ size_t blocksize;
+ size_t keylen;
+ size_t contextsize;
+ gcry_cipher_setkey_t setkey;
+ gcry_cipher_encrypt_t encrypt;
+ gcry_cipher_decrypt_t decrypt;
+ gcry_cipher_stencrypt_t stencrypt;
+ gcry_cipher_stdecrypt_t stdecrypt;
+} gcry_cipher_spec_t;
+
+/* Register a new cipher module whose specification can be found in
+ CIPHER. On success, a new algorithm ID is stored in ALGORITHM_ID
+ and a pointer representing this module is stored in MODULE. */
+gcry_error_t gcry_cipher_register (gcry_cipher_spec_t *cipher,
+ int *algorithm_id,
+ gcry_module_t *module)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+
+/* Unregister the cipher identified by MODULE, which must have been
+ registered with gcry_cipher_register. */
+void gcry_cipher_unregister (gcry_module_t module)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* ********************** */
+
+/* Type for the pk_generate function. */
+typedef gcry_err_code_t (*gcry_pk_generate_t) (int algo,
+ unsigned int nbits,
+ unsigned long use_e,
+ gcry_mpi_t *skey,
+ gcry_mpi_t **retfactors);
+
+/* Type for the pk_check_secret_key function. */
+typedef gcry_err_code_t (*gcry_pk_check_secret_key_t) (int algo,
+ gcry_mpi_t *skey);
+
+/* Type for the pk_encrypt function. */
+typedef gcry_err_code_t (*gcry_pk_encrypt_t) (int algo,
+ gcry_mpi_t *resarr,
+ gcry_mpi_t data,
+ gcry_mpi_t *pkey,
+ int flags);
+
+/* Type for the pk_decrypt function. */
+typedef gcry_err_code_t (*gcry_pk_decrypt_t) (int algo,
+ gcry_mpi_t *result,
+ gcry_mpi_t *data,
+ gcry_mpi_t *skey,
+ int flags);
+
+/* Type for the pk_sign function. */
+typedef gcry_err_code_t (*gcry_pk_sign_t) (int algo,
+ gcry_mpi_t *resarr,
+ gcry_mpi_t data,
+ gcry_mpi_t *skey);
+
+/* Type for the pk_verify function. */
+typedef gcry_err_code_t (*gcry_pk_verify_t) (int algo,
+ gcry_mpi_t hash,
+ gcry_mpi_t *data,
+ gcry_mpi_t *pkey,
+ int (*cmp) (void *, gcry_mpi_t),
+ void *opaquev);
+
+/* Type for the pk_get_nbits function. */
+typedef unsigned (*gcry_pk_get_nbits_t) (int algo, gcry_mpi_t *pkey);
+
+/* Module specification structure for message digests. */
+typedef struct gcry_pk_spec
+{
+ const char *name;
+ const char **aliases;
+ const char *elements_pkey;
+ const char *elements_skey;
+ const char *elements_enc;
+ const char *elements_sig;
+ const char *elements_grip;
+ int use;
+ gcry_pk_generate_t generate;
+ gcry_pk_check_secret_key_t check_secret_key;
+ gcry_pk_encrypt_t encrypt;
+ gcry_pk_decrypt_t decrypt;
+ gcry_pk_sign_t sign;
+ gcry_pk_verify_t verify;
+ gcry_pk_get_nbits_t get_nbits;
+} gcry_pk_spec_t;
+
+/* Register a new pubkey module whose specification can be found in
+ PUBKEY. On success, a new algorithm ID is stored in ALGORITHM_ID
+ and a pointer representhing this module is stored in MODULE. */
+gcry_error_t gcry_pk_register (gcry_pk_spec_t *pubkey,
+ unsigned int *algorithm_id,
+ gcry_module_t *module)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Unregister the pubkey identified by ID, which must have been
+ registered with gcry_pk_register. */
+void gcry_pk_unregister (gcry_module_t module)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* ********************** */
+
+/* Type for the md_init function. */
+typedef void (*gcry_md_init_t) (void *c);
+
+/* Type for the md_write function. */
+typedef void (*gcry_md_write_t) (void *c, const void *buf, size_t nbytes);
+
+/* Type for the md_final function. */
+typedef void (*gcry_md_final_t) (void *c);
+
+/* Type for the md_read function. */
+typedef unsigned char *(*gcry_md_read_t) (void *c);
+
+typedef struct gcry_md_oid_spec
+{
+ const char *oidstring;
+} gcry_md_oid_spec_t;
+
+/* Module specification structure for message digests. */
+typedef struct gcry_md_spec
+{
+ const char *name;
+ unsigned char *asnoid;
+ int asnlen;
+ gcry_md_oid_spec_t *oids;
+ int mdlen;
+ gcry_md_init_t init;
+ gcry_md_write_t write;
+ gcry_md_final_t final;
+ gcry_md_read_t read;
+ size_t contextsize; /* allocate this amount of context */
+} gcry_md_spec_t;
+
+/* Register a new digest module whose specification can be found in
+ DIGEST. On success, a new algorithm ID is stored in ALGORITHM_ID
+ and a pointer representhing this module is stored in MODULE. */
+gcry_error_t gcry_md_register (gcry_md_spec_t *digest,
+ unsigned int *algorithm_id,
+ gcry_module_t *module)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Unregister the digest identified by ID, which must have been
+ registered with gcry_digest_register. */
+void gcry_md_unregister (gcry_module_t module)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+#if 0 /* keep Emacsens's auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/grub-core/lib/libgcrypt/src/gcrypt.h.in b/grub-core/lib/libgcrypt/src/gcrypt.h.in
new file mode 100644
index 0000000..b65184e
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/gcrypt.h.in
@@ -0,0 +1,1760 @@
+/* gcrypt.h - GNU Cryptographic Library Interface -*- c -*-
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
+ 2007, 2008, 2009, 2010, 2011,
+ 2012 Free Software Foundation, Inc.
+ Copyright (C) 2012, 2013 g10 Code GmbH
+
+ This file is part of Libgcrypt.
+
+ Libgcrypt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ Libgcrypt is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ File: @configure_input@ */
+
+#ifndef _GCRYPT_H
+#define _GCRYPT_H
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include <gpg-error.h>
+
+#include <sys/types.h>
+
+#if defined _WIN32 || defined __WIN32__
+# include <winsock2.h>
+# include <ws2tcpip.h>
+# include <time.h>
+# ifndef __GNUC__
+ typedef long ssize_t;
+ typedef int pid_t;
+# endif /*!__GNUC__*/
+#else
+# include <sys/socket.h>
+# include <sys/time.h>
+#@INSERT_SYS_SELECT_H@
+#endif /*!_WIN32*/
+
+@FALLBACK_SOCKLEN_T@
+
+/* This is required for error code compatibility. */
+#define _GCRY_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_GCRYPT
+
+#ifdef __cplusplus
+extern "C" {
+#if 0 /* (Keep Emacsens' auto-indent happy.) */
+}
+#endif
+#endif
+
+/* The version of this header should match the one of the library. It
+ should not be used by a program because gcry_check_version() should
+ return the same version. The purpose of this macro is to let
+ autoconf (using the AM_PATH_GCRYPT macro) check that this header
+ matches the installed library. */
+#define GCRYPT_VERSION "@VERSION@"
+
+/* The version number of this header. It may be used to handle minor
+ API incompatibilities. */
+#define GCRYPT_VERSION_NUMBER @VERSION_NUMBER@
+
+
+/* Internal: We can't use the convenience macros for the multi
+ precision integer functions when building this library. */
+#ifdef _GCRYPT_IN_LIBGCRYPT
+#ifndef GCRYPT_NO_MPI_MACROS
+#define GCRYPT_NO_MPI_MACROS 1
+#endif
+#endif
+
+/* We want to use gcc attributes when possible. Warning: Don't use
+ these macros in your programs: As indicated by the leading
+ underscore they are subject to change without notice. */
+#ifdef __GNUC__
+
+#define _GCRY_GCC_VERSION (__GNUC__ * 10000 \
+ + __GNUC_MINOR__ * 100 \
+ + __GNUC_PATCHLEVEL__)
+
+#if _GCRY_GCC_VERSION >= 30100
+#define _GCRY_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#if _GCRY_GCC_VERSION >= 29600
+#define _GCRY_GCC_ATTR_PURE __attribute__ ((__pure__))
+#endif
+
+#if _GCRY_GCC_VERSION >= 30200
+#define _GCRY_GCC_ATTR_MALLOC __attribute__ ((__malloc__))
+#endif
+
+#endif /*__GNUC__*/
+
+#ifndef _GCRY_GCC_ATTR_DEPRECATED
+#define _GCRY_GCC_ATTR_DEPRECATED
+#endif
+#ifndef _GCRY_GCC_ATTR_PURE
+#define _GCRY_GCC_ATTR_PURE
+#endif
+#ifndef _GCRY_GCC_ATTR_MALLOC
+#define _GCRY_GCC_ATTR_MALLOC
+#endif
+
+/* Make up an attribute to mark functions and types as deprecated but
+ allow internal use by Libgcrypt. */
+#ifdef _GCRYPT_IN_LIBGCRYPT
+#define _GCRY_ATTR_INTERNAL
+#else
+#define _GCRY_ATTR_INTERNAL _GCRY_GCC_ATTR_DEPRECATED
+#endif
+
+/* Wrappers for the libgpg-error library. */
+
+typedef gpg_error_t gcry_error_t;
+typedef gpg_err_code_t gcry_err_code_t;
+typedef gpg_err_source_t gcry_err_source_t;
+
+static GPG_ERR_INLINE gcry_error_t
+gcry_err_make (gcry_err_source_t source, gcry_err_code_t code)
+{
+ return gpg_err_make (source, code);
+}
+
+/* The user can define GPG_ERR_SOURCE_DEFAULT before including this
+ file to specify a default source for gpg_error. */
+#ifndef GCRY_ERR_SOURCE_DEFAULT
+#define GCRY_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1
+#endif
+
+static GPG_ERR_INLINE gcry_error_t
+gcry_error (gcry_err_code_t code)
+{
+ return gcry_err_make (GCRY_ERR_SOURCE_DEFAULT, code);
+}
+
+static GPG_ERR_INLINE gcry_err_code_t
+gcry_err_code (gcry_error_t err)
+{
+ return gpg_err_code (err);
+}
+
+
+static GPG_ERR_INLINE gcry_err_source_t
+gcry_err_source (gcry_error_t err)
+{
+ return gpg_err_source (err);
+}
+
+/* Return a pointer to a string containing a description of the error
+ code in the error value ERR. */
+const char *gcry_strerror (gcry_error_t err);
+
+/* Return a pointer to a string containing a description of the error
+ source in the error value ERR. */
+const char *gcry_strsource (gcry_error_t err);
+
+/* Retrieve the error code for the system error ERR. This returns
+ GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
+ this). */
+gcry_err_code_t gcry_err_code_from_errno (int err);
+
+/* Retrieve the system error for the error code CODE. This returns 0
+ if CODE is not a system error code. */
+int gcry_err_code_to_errno (gcry_err_code_t code);
+
+/* Return an error value with the error source SOURCE and the system
+ error ERR. */
+gcry_error_t gcry_err_make_from_errno (gcry_err_source_t source, int err);
+
+/* Return an error value with the system error ERR. */
+gcry_err_code_t gcry_error_from_errno (int err);
+
+
+/* The data object used to hold a multi precision integer. */
+struct gcry_mpi;
+typedef struct gcry_mpi *gcry_mpi_t;
+
+#ifndef GCRYPT_NO_DEPRECATED
+typedef struct gcry_mpi *GCRY_MPI _GCRY_GCC_ATTR_DEPRECATED;
+typedef struct gcry_mpi *GcryMPI _GCRY_GCC_ATTR_DEPRECATED;
+#endif
+
+
+
+/* Check that the library fulfills the version requirement. */
+const char *gcry_check_version (const char *req_version);
+
+/* Codes for function dispatchers. */
+
+/* Codes used with the gcry_control function. */
+enum gcry_ctl_cmds
+ {
+ GCRYCTL_SET_KEY = 1,
+ GCRYCTL_SET_IV = 2,
+ GCRYCTL_CFB_SYNC = 3,
+ GCRYCTL_RESET = 4, /* e.g. for MDs */
+ GCRYCTL_FINALIZE = 5,
+ GCRYCTL_GET_KEYLEN = 6,
+ GCRYCTL_GET_BLKLEN = 7,
+ GCRYCTL_TEST_ALGO = 8,
+ GCRYCTL_IS_SECURE = 9,
+ GCRYCTL_GET_ASNOID = 10,
+ GCRYCTL_ENABLE_ALGO = 11,
+ GCRYCTL_DISABLE_ALGO = 12,
+ GCRYCTL_DUMP_RANDOM_STATS = 13,
+ GCRYCTL_DUMP_SECMEM_STATS = 14,
+ GCRYCTL_GET_ALGO_NPKEY = 15,
+ GCRYCTL_GET_ALGO_NSKEY = 16,
+ GCRYCTL_GET_ALGO_NSIGN = 17,
+ GCRYCTL_GET_ALGO_NENCR = 18,
+ GCRYCTL_SET_VERBOSITY = 19,
+ GCRYCTL_SET_DEBUG_FLAGS = 20,
+ GCRYCTL_CLEAR_DEBUG_FLAGS = 21,
+ GCRYCTL_USE_SECURE_RNDPOOL= 22,
+ GCRYCTL_DUMP_MEMORY_STATS = 23,
+ GCRYCTL_INIT_SECMEM = 24,
+ GCRYCTL_TERM_SECMEM = 25,
+ GCRYCTL_DISABLE_SECMEM_WARN = 27,
+ GCRYCTL_SUSPEND_SECMEM_WARN = 28,
+ GCRYCTL_RESUME_SECMEM_WARN = 29,
+ GCRYCTL_DROP_PRIVS = 30,
+ GCRYCTL_ENABLE_M_GUARD = 31,
+ GCRYCTL_START_DUMP = 32,
+ GCRYCTL_STOP_DUMP = 33,
+ GCRYCTL_GET_ALGO_USAGE = 34,
+ GCRYCTL_IS_ALGO_ENABLED = 35,
+ GCRYCTL_DISABLE_INTERNAL_LOCKING = 36,
+ GCRYCTL_DISABLE_SECMEM = 37,
+ GCRYCTL_INITIALIZATION_FINISHED = 38,
+ GCRYCTL_INITIALIZATION_FINISHED_P = 39,
+ GCRYCTL_ANY_INITIALIZATION_P = 40,
+ GCRYCTL_SET_CBC_CTS = 41,
+ GCRYCTL_SET_CBC_MAC = 42,
+ GCRYCTL_SET_CTR = 43,
+ GCRYCTL_ENABLE_QUICK_RANDOM = 44,
+ GCRYCTL_SET_RANDOM_SEED_FILE = 45,
+ GCRYCTL_UPDATE_RANDOM_SEED_FILE = 46,
+ GCRYCTL_SET_THREAD_CBS = 47,
+ GCRYCTL_FAST_POLL = 48,
+ GCRYCTL_SET_RANDOM_DAEMON_SOCKET = 49,
+ GCRYCTL_USE_RANDOM_DAEMON = 50,
+ GCRYCTL_FAKED_RANDOM_P = 51,
+ GCRYCTL_SET_RNDEGD_SOCKET = 52,
+ GCRYCTL_PRINT_CONFIG = 53,
+ GCRYCTL_OPERATIONAL_P = 54,
+ GCRYCTL_FIPS_MODE_P = 55,
+ GCRYCTL_FORCE_FIPS_MODE = 56,
+ GCRYCTL_SELFTEST = 57,
+ /* Note: 58 .. 62 are used internally. */
+ GCRYCTL_DISABLE_HWF = 63,
+ GCRYCTL_SET_ENFORCED_FIPS_FLAG = 64
+ };
+
+/* Perform various operations defined by CMD. */
+gcry_error_t gcry_control (enum gcry_ctl_cmds CMD, ...);
+
+
+/* S-expression management. */
+
+/* The object to represent an S-expression as used with the public key
+ functions. */
+struct gcry_sexp;
+typedef struct gcry_sexp *gcry_sexp_t;
+
+#ifndef GCRYPT_NO_DEPRECATED
+typedef struct gcry_sexp *GCRY_SEXP _GCRY_GCC_ATTR_DEPRECATED;
+typedef struct gcry_sexp *GcrySexp _GCRY_GCC_ATTR_DEPRECATED;
+#endif
+
+/* The possible values for the S-expression format. */
+enum gcry_sexp_format
+ {
+ GCRYSEXP_FMT_DEFAULT = 0,
+ GCRYSEXP_FMT_CANON = 1,
+ GCRYSEXP_FMT_BASE64 = 2,
+ GCRYSEXP_FMT_ADVANCED = 3
+ };
+
+/* Create an new S-expression object from BUFFER of size LENGTH and
+ return it in RETSEXP. With AUTODETECT set to 0 the data in BUFFER
+ is expected to be in canonized format. */
+gcry_error_t gcry_sexp_new (gcry_sexp_t *retsexp,
+ const void *buffer, size_t length,
+ int autodetect);
+
+ /* Same as gcry_sexp_new but allows to pass a FREEFNC which has the
+ effect to transfer ownership of BUFFER to the created object. */
+gcry_error_t gcry_sexp_create (gcry_sexp_t *retsexp,
+ void *buffer, size_t length,
+ int autodetect, void (*freefnc) (void *));
+
+/* Scan BUFFER and return a new S-expression object in RETSEXP. This
+ function expects a printf like string in BUFFER. */
+gcry_error_t gcry_sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *buffer, size_t length);
+
+/* Same as gcry_sexp_sscan but expects a string in FORMAT and can thus
+ only be used for certain encodings. */
+gcry_error_t gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, ...);
+
+/* Like gcry_sexp_build, but uses an array instead of variable
+ function arguments. */
+gcry_error_t gcry_sexp_build_array (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, void **arg_list);
+
+/* Release the S-expression object SEXP */
+void gcry_sexp_release (gcry_sexp_t sexp);
+
+/* Calculate the length of an canonized S-expresion in BUFFER and
+ check for a valid encoding. */
+size_t gcry_sexp_canon_len (const unsigned char *buffer, size_t length,
+ size_t *erroff, gcry_error_t *errcode);
+
+/* Copies the S-expression object SEXP into BUFFER using the format
+ specified in MODE. */
+size_t gcry_sexp_sprint (gcry_sexp_t sexp, int mode, void *buffer,
+ size_t maxlength);
+
+/* Dumps the S-expression object A in a format suitable for debugging
+ to Libgcrypt's logging stream. */
+void gcry_sexp_dump (const gcry_sexp_t a);
+
+gcry_sexp_t gcry_sexp_cons (const gcry_sexp_t a, const gcry_sexp_t b);
+gcry_sexp_t gcry_sexp_alist (const gcry_sexp_t *array);
+gcry_sexp_t gcry_sexp_vlist (const gcry_sexp_t a, ...);
+gcry_sexp_t gcry_sexp_append (const gcry_sexp_t a, const gcry_sexp_t n);
+gcry_sexp_t gcry_sexp_prepend (const gcry_sexp_t a, const gcry_sexp_t n);
+
+/* Scan the S-expression for a sublist with a type (the car of the
+ list) matching the string TOKEN. If TOKLEN is not 0, the token is
+ assumed to be raw memory of this length. The function returns a
+ newly allocated S-expression consisting of the found sublist or
+ `NULL' when not found. */
+gcry_sexp_t gcry_sexp_find_token (gcry_sexp_t list,
+ const char *tok, size_t toklen);
+/* Return the length of the LIST. For a valid S-expression this
+ should be at least 1. */
+int gcry_sexp_length (const gcry_sexp_t list);
+
+/* Create and return a new S-expression from the element with index
+ NUMBER in LIST. Note that the first element has the index 0. If
+ there is no such element, `NULL' is returned. */
+gcry_sexp_t gcry_sexp_nth (const gcry_sexp_t list, int number);
+
+/* Create and return a new S-expression from the first element in
+ LIST; this called the "type" and should always exist and be a
+ string. `NULL' is returned in case of a problem. */
+gcry_sexp_t gcry_sexp_car (const gcry_sexp_t list);
+
+/* Create and return a new list form all elements except for the first
+ one. Note, that this function may return an invalid S-expression
+ because it is not guaranteed, that the type exists and is a string.
+ However, for parsing a complex S-expression it might be useful for
+ intermediate lists. Returns `NULL' on error. */
+gcry_sexp_t gcry_sexp_cdr (const gcry_sexp_t list);
+
+gcry_sexp_t gcry_sexp_cadr (const gcry_sexp_t list);
+
+
+/* This function is used to get data from a LIST. A pointer to the
+ actual data with index NUMBER is returned and the length of this
+ data will be stored to DATALEN. If there is no data at the given
+ index or the index represents another list, `NULL' is returned.
+ *Note:* The returned pointer is valid as long as LIST is not
+ modified or released. */
+const char *gcry_sexp_nth_data (const gcry_sexp_t list, int number,
+ size_t *datalen);
+
+/* This function is used to get and convert data from a LIST. The
+ data is assumed to be a Nul terminated string. The caller must
+ release the returned value using `gcry_free'. If there is no data
+ at the given index, the index represents a list or the value can't
+ be converted to a string, `NULL' is returned. */
+char *gcry_sexp_nth_string (gcry_sexp_t list, int number);
+
+/* This function is used to get and convert data from a LIST. This
+ data is assumed to be an MPI stored in the format described by
+ MPIFMT and returned as a standard Libgcrypt MPI. The caller must
+ release this returned value using `gcry_mpi_release'. If there is
+ no data at the given index, the index represents a list or the
+ value can't be converted to an MPI, `NULL' is returned. */
+gcry_mpi_t gcry_sexp_nth_mpi (gcry_sexp_t list, int number, int mpifmt);
+
+
+
+/*******************************************
+ * *
+ * Multi Precision Integer Functions *
+ * *
+ *******************************************/
+
+/* Different formats of external big integer representation. */
+enum gcry_mpi_format
+ {
+ GCRYMPI_FMT_NONE= 0,
+ GCRYMPI_FMT_STD = 1, /* Twos complement stored without length. */
+ GCRYMPI_FMT_PGP = 2, /* As used by OpenPGP (unsigned only). */
+ GCRYMPI_FMT_SSH = 3, /* As used by SSH (like STD but with length). */
+ GCRYMPI_FMT_HEX = 4, /* Hex format. */
+ GCRYMPI_FMT_USG = 5 /* Like STD but unsigned. */
+ };
+
+/* Flags used for creating big integers. */
+enum gcry_mpi_flag
+ {
+ GCRYMPI_FLAG_SECURE = 1, /* Allocate the number in "secure" memory. */
+ GCRYMPI_FLAG_OPAQUE = 2 /* The number is not a real one but just
+ a way to store some bytes. This is
+ useful for encrypted big integers. */
+ };
+
+
+/* Allocate a new big integer object, initialize it with 0 and
+ initially allocate memory for a number of at least NBITS. */
+gcry_mpi_t gcry_mpi_new (unsigned int nbits);
+
+/* Same as gcry_mpi_new() but allocate in "secure" memory. */
+gcry_mpi_t gcry_mpi_snew (unsigned int nbits);
+
+/* Release the number A and free all associated resources. */
+void gcry_mpi_release (gcry_mpi_t a);
+
+/* Create a new number with the same value as A. */
+gcry_mpi_t gcry_mpi_copy (const gcry_mpi_t a);
+
+/* Store the big integer value U in W. */
+gcry_mpi_t gcry_mpi_set (gcry_mpi_t w, const gcry_mpi_t u);
+
+/* Store the unsigned integer value U in W. */
+gcry_mpi_t gcry_mpi_set_ui (gcry_mpi_t w, unsigned long u);
+
+/* Swap the values of A and B. */
+void gcry_mpi_swap (gcry_mpi_t a, gcry_mpi_t b);
+
+/* Compare the big integer number U and V returning 0 for equality, a
+ positive value for U > V and a negative for U < V. */
+int gcry_mpi_cmp (const gcry_mpi_t u, const gcry_mpi_t v);
+
+/* Compare the big integer number U with the unsigned integer V
+ returning 0 for equality, a positive value for U > V and a negative
+ for U < V. */
+int gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v);
+
+/* Convert the external representation of an integer stored in BUFFER
+ with a length of BUFLEN into a newly create MPI returned in
+ RET_MPI. If NSCANNED is not NULL, it will receive the number of
+ bytes actually scanned after a successful operation. */
+gcry_error_t gcry_mpi_scan (gcry_mpi_t *ret_mpi, enum gcry_mpi_format format,
+ const void *buffer, size_t buflen,
+ size_t *nscanned);
+
+/* Convert the big integer A into the external representation
+ described by FORMAT and store it in the provided BUFFER which has
+ been allocated by the user with a size of BUFLEN bytes. NWRITTEN
+ receives the actual length of the external representation unless it
+ has been passed as NULL. */
+gcry_error_t gcry_mpi_print (enum gcry_mpi_format format,
+ unsigned char *buffer, size_t buflen,
+ size_t *nwritten,
+ const gcry_mpi_t a);
+
+/* Convert the big integer A int the external representation described
+ by FORMAT and store it in a newly allocated buffer which address
+ will be put into BUFFER. NWRITTEN receives the actual lengths of the
+ external representation. */
+gcry_error_t gcry_mpi_aprint (enum gcry_mpi_format format,
+ unsigned char **buffer, size_t *nwritten,
+ const gcry_mpi_t a);
+
+/* Dump the value of A in a format suitable for debugging to
+ Libgcrypt's logging stream. Note that one leading space but no
+ trailing space or linefeed will be printed. It is okay to pass
+ NULL for A. */
+void gcry_mpi_dump (const gcry_mpi_t a);
+
+
+/* W = U + V. */
+void gcry_mpi_add (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v);
+
+/* W = U + V. V is an unsigned integer. */
+void gcry_mpi_add_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v);
+
+/* W = U + V mod M. */
+void gcry_mpi_addm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m);
+
+/* W = U - V. */
+void gcry_mpi_sub (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v);
+
+/* W = U - V. V is an unsigned integer. */
+void gcry_mpi_sub_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v );
+
+/* W = U - V mod M */
+void gcry_mpi_subm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m);
+
+/* W = U * V. */
+void gcry_mpi_mul (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v);
+
+/* W = U * V. V is an unsigned integer. */
+void gcry_mpi_mul_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v );
+
+/* W = U * V mod M. */
+void gcry_mpi_mulm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m);
+
+/* W = U * (2 ^ CNT). */
+void gcry_mpi_mul_2exp (gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt);
+
+/* Q = DIVIDEND / DIVISOR, R = DIVIDEND % DIVISOR,
+ Q or R may be passed as NULL. ROUND should be negative or 0. */
+void gcry_mpi_div (gcry_mpi_t q, gcry_mpi_t r,
+ gcry_mpi_t dividend, gcry_mpi_t divisor, int round);
+
+/* R = DIVIDEND % DIVISOR */
+void gcry_mpi_mod (gcry_mpi_t r, gcry_mpi_t dividend, gcry_mpi_t divisor);
+
+/* W = B ^ E mod M. */
+void gcry_mpi_powm (gcry_mpi_t w,
+ const gcry_mpi_t b, const gcry_mpi_t e,
+ const gcry_mpi_t m);
+
+/* Set G to the greatest common divisor of A and B.
+ Return true if the G is 1. */
+int gcry_mpi_gcd (gcry_mpi_t g, gcry_mpi_t a, gcry_mpi_t b);
+
+/* Set X to the multiplicative inverse of A mod M.
+ Return true if the value exists. */
+int gcry_mpi_invm (gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t m);
+
+
+/* Return the number of bits required to represent A. */
+unsigned int gcry_mpi_get_nbits (gcry_mpi_t a);
+
+/* Return true when bit number N (counting from 0) is set in A. */
+int gcry_mpi_test_bit (gcry_mpi_t a, unsigned int n);
+
+/* Set bit number N in A. */
+void gcry_mpi_set_bit (gcry_mpi_t a, unsigned int n);
+
+/* Clear bit number N in A. */
+void gcry_mpi_clear_bit (gcry_mpi_t a, unsigned int n);
+
+/* Set bit number N in A and clear all bits greater than N. */
+void gcry_mpi_set_highbit (gcry_mpi_t a, unsigned int n);
+
+/* Clear bit number N in A and all bits greater than N. */
+void gcry_mpi_clear_highbit (gcry_mpi_t a, unsigned int n);
+
+/* Shift the value of A by N bits to the right and store the result in X. */
+void gcry_mpi_rshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n);
+
+/* Shift the value of A by N bits to the left and store the result in X. */
+void gcry_mpi_lshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n);
+
+/* Store NBITS of the value P points to in A and mark A as an opaque
+ value. WARNING: Never use an opaque MPI for anything thing else then
+ gcry_mpi_release, gcry_mpi_get_opaque. */
+gcry_mpi_t gcry_mpi_set_opaque (gcry_mpi_t a, void *p, unsigned int nbits);
+
+/* Return a pointer to an opaque value stored in A and return its size
+ in NBITS. Note that the returned pointer is still owned by A and
+ that the function should never be used for an non-opaque MPI. */
+void *gcry_mpi_get_opaque (gcry_mpi_t a, unsigned int *nbits);
+
+/* Set the FLAG for the big integer A. Currently only the flag
+ GCRYMPI_FLAG_SECURE is allowed to convert A into an big intger
+ stored in "secure" memory. */
+void gcry_mpi_set_flag (gcry_mpi_t a, enum gcry_mpi_flag flag);
+
+/* Clear FLAG for the big integer A. Note that this function is
+ currently useless as no flags are allowed. */
+void gcry_mpi_clear_flag (gcry_mpi_t a, enum gcry_mpi_flag flag);
+
+/* Return true when the FLAG is set for A. */
+int gcry_mpi_get_flag (gcry_mpi_t a, enum gcry_mpi_flag flag);
+
+/* Unless the GCRYPT_NO_MPI_MACROS is used, provide a couple of
+ convenience macros for the big integer functions. */
+#ifndef GCRYPT_NO_MPI_MACROS
+#define mpi_new(n) gcry_mpi_new( (n) )
+#define mpi_secure_new( n ) gcry_mpi_snew( (n) )
+#define mpi_release(a) \
+ do \
+ { \
+ gcry_mpi_release ((a)); \
+ (a) = NULL; \
+ } \
+ while (0)
+
+#define mpi_copy( a ) gcry_mpi_copy( (a) )
+#define mpi_set( w, u) gcry_mpi_set( (w), (u) )
+#define mpi_set_ui( w, u) gcry_mpi_set_ui( (w), (u) )
+#define mpi_cmp( u, v ) gcry_mpi_cmp( (u), (v) )
+#define mpi_cmp_ui( u, v ) gcry_mpi_cmp_ui( (u), (v) )
+
+#define mpi_add_ui(w,u,v) gcry_mpi_add_ui((w),(u),(v))
+#define mpi_add(w,u,v) gcry_mpi_add ((w),(u),(v))
+#define mpi_addm(w,u,v,m) gcry_mpi_addm ((w),(u),(v),(m))
+#define mpi_sub_ui(w,u,v) gcry_mpi_sub_ui ((w),(u),(v))
+#define mpi_sub(w,u,v) gcry_mpi_sub ((w),(u),(v))
+#define mpi_subm(w,u,v,m) gcry_mpi_subm ((w),(u),(v),(m))
+#define mpi_mul_ui(w,u,v) gcry_mpi_mul_ui ((w),(u),(v))
+#define mpi_mul_2exp(w,u,v) gcry_mpi_mul_2exp ((w),(u),(v))
+#define mpi_mul(w,u,v) gcry_mpi_mul ((w),(u),(v))
+#define mpi_mulm(w,u,v,m) gcry_mpi_mulm ((w),(u),(v),(m))
+#define mpi_powm(w,b,e,m) gcry_mpi_powm ( (w), (b), (e), (m) )
+#define mpi_tdiv(q,r,a,m) gcry_mpi_div ( (q), (r), (a), (m), 0)
+#define mpi_fdiv(q,r,a,m) gcry_mpi_div ( (q), (r), (a), (m), -1)
+#define mpi_mod(r,a,m) gcry_mpi_mod ((r), (a), (m))
+#define mpi_gcd(g,a,b) gcry_mpi_gcd ( (g), (a), (b) )
+#define mpi_invm(g,a,b) gcry_mpi_invm ( (g), (a), (b) )
+
+#define mpi_get_nbits(a) gcry_mpi_get_nbits ((a))
+#define mpi_test_bit(a,b) gcry_mpi_test_bit ((a),(b))
+#define mpi_set_bit(a,b) gcry_mpi_set_bit ((a),(b))
+#define mpi_set_highbit(a,b) gcry_mpi_set_highbit ((a),(b))
+#define mpi_clear_bit(a,b) gcry_mpi_clear_bit ((a),(b))
+#define mpi_clear_highbit(a,b) gcry_mpi_clear_highbit ((a),(b))
+#define mpi_rshift(a,b,c) gcry_mpi_rshift ((a),(b),(c))
+#define mpi_lshift(a,b,c) gcry_mpi_lshift ((a),(b),(c))
+
+#define mpi_set_opaque(a,b,c) gcry_mpi_set_opaque( (a), (b), (c) )
+#define mpi_get_opaque(a,b) gcry_mpi_get_opaque( (a), (b) )
+#endif /* GCRYPT_NO_MPI_MACROS */
+
+
+
+/************************************
+ * *
+ * Symmetric Cipher Functions *
+ * *
+ ************************************/
+
+/* The data object used to hold a handle to an encryption object. */
+struct gcry_cipher_handle;
+typedef struct gcry_cipher_handle *gcry_cipher_hd_t;
+
+#ifndef GCRYPT_NO_DEPRECATED
+typedef struct gcry_cipher_handle *GCRY_CIPHER_HD _GCRY_GCC_ATTR_DEPRECATED;
+typedef struct gcry_cipher_handle *GcryCipherHd _GCRY_GCC_ATTR_DEPRECATED;
+#endif
+
+/* All symmetric encryption algorithms are identified by their IDs.
+ More IDs may be registered at runtime. */
+enum gcry_cipher_algos
+ {
+ GCRY_CIPHER_NONE = 0,
+ GCRY_CIPHER_IDEA = 1,
+ GCRY_CIPHER_3DES = 2,
+ GCRY_CIPHER_CAST5 = 3,
+ GCRY_CIPHER_BLOWFISH = 4,
+ GCRY_CIPHER_SAFER_SK128 = 5,
+ GCRY_CIPHER_DES_SK = 6,
+ GCRY_CIPHER_AES = 7,
+ GCRY_CIPHER_AES192 = 8,
+ GCRY_CIPHER_AES256 = 9,
+ GCRY_CIPHER_TWOFISH = 10,
+
+ /* Other cipher numbers are above 300 for OpenPGP reasons. */
+ GCRY_CIPHER_ARCFOUR = 301, /* Fully compatible with RSA's RC4 (tm). */
+ GCRY_CIPHER_DES = 302, /* Yes, this is single key 56 bit DES. */
+ GCRY_CIPHER_TWOFISH128 = 303,
+ GCRY_CIPHER_SERPENT128 = 304,
+ GCRY_CIPHER_SERPENT192 = 305,
+ GCRY_CIPHER_SERPENT256 = 306,
+ GCRY_CIPHER_RFC2268_40 = 307, /* Ron's Cipher 2 (40 bit). */
+ GCRY_CIPHER_RFC2268_128 = 308, /* Ron's Cipher 2 (128 bit). */
+ GCRY_CIPHER_SEED = 309, /* 128 bit cipher described in RFC4269. */
+ GCRY_CIPHER_CAMELLIA128 = 310,
+ GCRY_CIPHER_CAMELLIA192 = 311,
+ GCRY_CIPHER_CAMELLIA256 = 312
+ };
+
+/* The Rijndael algorithm is basically AES, so provide some macros. */
+#define GCRY_CIPHER_AES128 GCRY_CIPHER_AES
+#define GCRY_CIPHER_RIJNDAEL GCRY_CIPHER_AES
+#define GCRY_CIPHER_RIJNDAEL128 GCRY_CIPHER_AES128
+#define GCRY_CIPHER_RIJNDAEL192 GCRY_CIPHER_AES192
+#define GCRY_CIPHER_RIJNDAEL256 GCRY_CIPHER_AES256
+
+/* The supported encryption modes. Note that not all of them are
+ supported for each algorithm. */
+enum gcry_cipher_modes
+ {
+ GCRY_CIPHER_MODE_NONE = 0, /* Not yet specified. */
+ GCRY_CIPHER_MODE_ECB = 1, /* Electronic codebook. */
+ GCRY_CIPHER_MODE_CFB = 2, /* Cipher feedback. */
+ GCRY_CIPHER_MODE_CBC = 3, /* Cipher block chaining. */
+ GCRY_CIPHER_MODE_STREAM = 4, /* Used with stream ciphers. */
+ GCRY_CIPHER_MODE_OFB = 5, /* Outer feedback. */
+ GCRY_CIPHER_MODE_CTR = 6, /* Counter. */
+ GCRY_CIPHER_MODE_AESWRAP= 7 /* AES-WRAP algorithm. */
+ };
+
+/* Flags used with the open function. */
+enum gcry_cipher_flags
+ {
+ GCRY_CIPHER_SECURE = 1, /* Allocate in secure memory. */
+ GCRY_CIPHER_ENABLE_SYNC = 2, /* Enable CFB sync mode. */
+ GCRY_CIPHER_CBC_CTS = 4, /* Enable CBC cipher text stealing (CTS). */
+ GCRY_CIPHER_CBC_MAC = 8 /* Enable CBC message auth. code (MAC). */
+ };
+
+
+/* Create a handle for algorithm ALGO to be used in MODE. FLAGS may
+ be given as an bitwise OR of the gcry_cipher_flags values. */
+gcry_error_t gcry_cipher_open (gcry_cipher_hd_t *handle,
+ int algo, int mode, unsigned int flags);
+
+/* Close the cioher handle H and release all resource. */
+void gcry_cipher_close (gcry_cipher_hd_t h);
+
+/* Perform various operations on the cipher object H. */
+gcry_error_t gcry_cipher_ctl (gcry_cipher_hd_t h, int cmd, void *buffer,
+ size_t buflen);
+
+/* Retrieve various information about the cipher object H. */
+gcry_error_t gcry_cipher_info (gcry_cipher_hd_t h, int what, void *buffer,
+ size_t *nbytes);
+
+/* Retrieve various information about the cipher algorithm ALGO. */
+gcry_error_t gcry_cipher_algo_info (int algo, int what, void *buffer,
+ size_t *nbytes);
+
+/* Map the cipher algorithm whose ID is contained in ALGORITHM to a
+ string representation of the algorithm name. For unknown algorithm
+ IDs this function returns "?". */
+const char *gcry_cipher_algo_name (int algorithm) _GCRY_GCC_ATTR_PURE;
+
+/* Map the algorithm name NAME to an cipher algorithm ID. Return 0 if
+ the algorithm name is not known. */
+int gcry_cipher_map_name (const char *name) _GCRY_GCC_ATTR_PURE;
+
+/* Given an ASN.1 object identifier in standard IETF dotted decimal
+ format in STRING, return the encryption mode associated with that
+ OID or 0 if not known or applicable. */
+int gcry_cipher_mode_from_oid (const char *string) _GCRY_GCC_ATTR_PURE;
+
+/* Encrypt the plaintext of size INLEN in IN using the cipher handle H
+ into the buffer OUT which has an allocated length of OUTSIZE. For
+ most algorithms it is possible to pass NULL for in and 0 for INLEN
+ and do a in-place decryption of the data provided in OUT. */
+gcry_error_t gcry_cipher_encrypt (gcry_cipher_hd_t h,
+ void *out, size_t outsize,
+ const void *in, size_t inlen);
+
+/* The counterpart to gcry_cipher_encrypt. */
+gcry_error_t gcry_cipher_decrypt (gcry_cipher_hd_t h,
+ void *out, size_t outsize,
+ const void *in, size_t inlen);
+
+/* Set KEY of length KEYLEN bytes for the cipher handle HD. */
+gcry_error_t gcry_cipher_setkey (gcry_cipher_hd_t hd,
+ const void *key, size_t keylen);
+
+
+/* Set initialization vector IV of length IVLEN for the cipher handle HD. */
+gcry_error_t gcry_cipher_setiv (gcry_cipher_hd_t hd,
+ const void *iv, size_t ivlen);
+
+
+/* Reset the handle to the state after open. */
+#define gcry_cipher_reset(h) gcry_cipher_ctl ((h), GCRYCTL_RESET, NULL, 0)
+
+/* Perform the OpenPGP sync operation if this is enabled for the
+ cipher handle H. */
+#define gcry_cipher_sync(h) gcry_cipher_ctl( (h), GCRYCTL_CFB_SYNC, NULL, 0)
+
+/* Enable or disable CTS in future calls to gcry_encrypt(). CBC mode only. */
+#define gcry_cipher_cts(h,on) gcry_cipher_ctl( (h), GCRYCTL_SET_CBC_CTS, \
+ NULL, on )
+
+/* Set counter for CTR mode. (CTR,CTRLEN) must denote a buffer of
+ block size length, or (NULL,0) to set the CTR to the all-zero block. */
+gpg_error_t gcry_cipher_setctr (gcry_cipher_hd_t hd,
+ const void *ctr, size_t ctrlen);
+
+/* Retrieve the key length in bytes used with algorithm A. */
+size_t gcry_cipher_get_algo_keylen (int algo);
+
+/* Retrieve the block length in bytes used with algorithm A. */
+size_t gcry_cipher_get_algo_blklen (int algo);
+
+/* Return 0 if the algorithm A is available for use. */
+#define gcry_cipher_test_algo(a) \
+ gcry_cipher_algo_info( (a), GCRYCTL_TEST_ALGO, NULL, NULL )
+
+/* Get a list consisting of the IDs of the loaded cipher modules. If
+ LIST is zero, write the number of loaded cipher modules to
+ LIST_LENGTH and return. If LIST is non-zero, the first
+ *LIST_LENGTH algorithm IDs are stored in LIST, which must be of
+ according size. In case there are less cipher modules than
+ *LIST_LENGTH, *LIST_LENGTH is updated to the correct number. */
+gcry_error_t gcry_cipher_list (int *list, int *list_length);
+
+
+/************************************
+ * *
+ * Asymmetric Cipher Functions *
+ * *
+ ************************************/
+
+/* The algorithms and their IDs we support. */
+enum gcry_pk_algos
+ {
+ GCRY_PK_RSA = 1,
+ GCRY_PK_RSA_E = 2, /* (deprecated) */
+ GCRY_PK_RSA_S = 3, /* (deprecated) */
+ GCRY_PK_ELG_E = 16,
+ GCRY_PK_DSA = 17,
+ GCRY_PK_ELG = 20,
+ GCRY_PK_ECDSA = 301,
+ GCRY_PK_ECDH = 302
+ };
+
+/* Flags describing usage capabilities of a PK algorithm. */
+#define GCRY_PK_USAGE_SIGN 1 /* Good for signatures. */
+#define GCRY_PK_USAGE_ENCR 2 /* Good for encryption. */
+#define GCRY_PK_USAGE_CERT 4 /* Good to certify other keys. */
+#define GCRY_PK_USAGE_AUTH 8 /* Good for authentication. */
+#define GCRY_PK_USAGE_UNKN 128 /* Unknown usage flag. */
+
+/* Encrypt the DATA using the public key PKEY and store the result as
+ a newly created S-expression at RESULT. */
+gcry_error_t gcry_pk_encrypt (gcry_sexp_t *result,
+ gcry_sexp_t data, gcry_sexp_t pkey);
+
+/* Decrypt the DATA using the private key SKEY and store the result as
+ a newly created S-expression at RESULT. */
+gcry_error_t gcry_pk_decrypt (gcry_sexp_t *result,
+ gcry_sexp_t data, gcry_sexp_t skey);
+
+/* Sign the DATA using the private key SKEY and store the result as
+ a newly created S-expression at RESULT. */
+gcry_error_t gcry_pk_sign (gcry_sexp_t *result,
+ gcry_sexp_t data, gcry_sexp_t skey);
+
+/* Check the signature SIGVAL on DATA using the public key PKEY. */
+gcry_error_t gcry_pk_verify (gcry_sexp_t sigval,
+ gcry_sexp_t data, gcry_sexp_t pkey);
+
+/* Check that private KEY is sane. */
+gcry_error_t gcry_pk_testkey (gcry_sexp_t key);
+
+/* Generate a new key pair according to the parameters given in
+ S_PARMS. The new key pair is returned in as an S-expression in
+ R_KEY. */
+gcry_error_t gcry_pk_genkey (gcry_sexp_t *r_key, gcry_sexp_t s_parms);
+
+/* Catch all function for miscellaneous operations. */
+gcry_error_t gcry_pk_ctl (int cmd, void *buffer, size_t buflen);
+
+/* Retrieve information about the public key algorithm ALGO. */
+gcry_error_t gcry_pk_algo_info (int algo, int what,
+ void *buffer, size_t *nbytes);
+
+/* Map the public key algorithm whose ID is contained in ALGORITHM to
+ a string representation of the algorithm name. For unknown
+ algorithm IDs this functions returns "?". */
+const char *gcry_pk_algo_name (int algorithm) _GCRY_GCC_ATTR_PURE;
+
+/* Map the algorithm NAME to a public key algorithm Id. Return 0 if
+ the algorithm name is not known. */
+int gcry_pk_map_name (const char* name) _GCRY_GCC_ATTR_PURE;
+
+/* Return what is commonly referred as the key length for the given
+ public or private KEY. */
+unsigned int gcry_pk_get_nbits (gcry_sexp_t key) _GCRY_GCC_ATTR_PURE;
+
+/* Please note that keygrip is still experimental and should not be
+ used without contacting the author. */
+unsigned char *gcry_pk_get_keygrip (gcry_sexp_t key, unsigned char *array);
+
+/* Return the name of the curve matching KEY. */
+const char *gcry_pk_get_curve (gcry_sexp_t key, int iterator,
+ unsigned int *r_nbits);
+
+/* Return an S-expression with the parameters of the named ECC curve
+ NAME. ALGO must be set to an ECC algorithm. */
+gcry_sexp_t gcry_pk_get_param (int algo, const char *name);
+
+/* Return 0 if the public key algorithm A is available for use. */
+#define gcry_pk_test_algo(a) \
+ gcry_pk_algo_info( (a), GCRYCTL_TEST_ALGO, NULL, NULL )
+
+/* Get a list consisting of the IDs of the loaded pubkey modules. If
+ LIST is zero, write the number of loaded pubkey modules to
+ LIST_LENGTH and return. If LIST is non-zero, the first
+ *LIST_LENGTH algorithm IDs are stored in LIST, which must be of
+ according size. In case there are less pubkey modules than
+ *LIST_LENGTH, *LIST_LENGTH is updated to the correct number. */
+gcry_error_t gcry_pk_list (int *list, int *list_length);
+
+
+
+/************************************
+ * *
+ * Cryptograhic Hash Functions *
+ * *
+ ************************************/
+
+/* Algorithm IDs for the hash functions we know about. Not all of them
+ are implemnted. */
+enum gcry_md_algos
+ {
+ GCRY_MD_NONE = 0,
+ GCRY_MD_MD5 = 1,
+ GCRY_MD_SHA1 = 2,
+ GCRY_MD_RMD160 = 3,
+ GCRY_MD_MD2 = 5,
+ GCRY_MD_TIGER = 6, /* TIGER/192 as used by gpg <= 1.3.2. */
+ GCRY_MD_HAVAL = 7, /* HAVAL, 5 pass, 160 bit. */
+ GCRY_MD_SHA256 = 8,
+ GCRY_MD_SHA384 = 9,
+ GCRY_MD_SHA512 = 10,
+ GCRY_MD_SHA224 = 11,
+ GCRY_MD_MD4 = 301,
+ GCRY_MD_CRC32 = 302,
+ GCRY_MD_CRC32_RFC1510 = 303,
+ GCRY_MD_CRC24_RFC2440 = 304,
+ GCRY_MD_WHIRLPOOL = 305,
+ GCRY_MD_TIGER1 = 306, /* TIGER fixed. */
+ GCRY_MD_TIGER2 = 307 /* TIGER2 variant. */
+ };
+
+/* Flags used with the open function. */
+enum gcry_md_flags
+ {
+ GCRY_MD_FLAG_SECURE = 1, /* Allocate all buffers in "secure" memory. */
+ GCRY_MD_FLAG_HMAC = 2 /* Make an HMAC out of this algorithm. */
+ };
+
+/* (Forward declaration.) */
+struct gcry_md_context;
+
+/* This object is used to hold a handle to a message digest object.
+ This structure is private - only to be used by the public gcry_md_*
+ macros. */
+typedef struct gcry_md_handle
+{
+ /* Actual context. */
+ struct gcry_md_context *ctx;
+
+ /* Buffer management. */
+ int bufpos;
+ int bufsize;
+ unsigned char buf[1];
+} *gcry_md_hd_t;
+
+/* Compatibility types, do not use them. */
+#ifndef GCRYPT_NO_DEPRECATED
+typedef struct gcry_md_handle *GCRY_MD_HD _GCRY_GCC_ATTR_DEPRECATED;
+typedef struct gcry_md_handle *GcryMDHd _GCRY_GCC_ATTR_DEPRECATED;
+#endif
+
+/* Create a message digest object for algorithm ALGO. FLAGS may be
+ given as an bitwise OR of the gcry_md_flags values. ALGO may be
+ given as 0 if the algorithms to be used are later set using
+ gcry_md_enable. */
+gcry_error_t gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags);
+
+/* Release the message digest object HD. */
+void gcry_md_close (gcry_md_hd_t hd);
+
+/* Add the message digest algorithm ALGO to the digest object HD. */
+gcry_error_t gcry_md_enable (gcry_md_hd_t hd, int algo);
+
+/* Create a new digest object as an exact copy of the object HD. */
+gcry_error_t gcry_md_copy (gcry_md_hd_t *bhd, gcry_md_hd_t ahd);
+
+/* Reset the digest object HD to its initial state. */
+void gcry_md_reset (gcry_md_hd_t hd);
+
+/* Perform various operations on the digest object HD. */
+gcry_error_t gcry_md_ctl (gcry_md_hd_t hd, int cmd,
+ void *buffer, size_t buflen);
+
+/* Pass LENGTH bytes of data in BUFFER to the digest object HD so that
+ it can update the digest values. This is the actual hash
+ function. */
+void gcry_md_write (gcry_md_hd_t hd, const void *buffer, size_t length);
+
+/* Read out the final digest from HD return the digest value for
+ algorithm ALGO. */
+unsigned char *gcry_md_read (gcry_md_hd_t hd, int algo);
+
+/* Convenience function to calculate the hash from the data in BUFFER
+ of size LENGTH using the algorithm ALGO avoiding the creating of a
+ hash object. The hash is returned in the caller provided buffer
+ DIGEST which must be large enough to hold the digest of the given
+ algorithm. */
+void gcry_md_hash_buffer (int algo, void *digest,
+ const void *buffer, size_t length);
+
+/* Retrieve the algorithm used with HD. This does not work reliable
+ if more than one algorithm is enabled in HD. */
+int gcry_md_get_algo (gcry_md_hd_t hd);
+
+/* Retrieve the length in bytes of the digest yielded by algorithm
+ ALGO. */
+unsigned int gcry_md_get_algo_dlen (int algo);
+
+/* Return true if the the algorithm ALGO is enabled in the digest
+ object A. */
+int gcry_md_is_enabled (gcry_md_hd_t a, int algo);
+
+/* Return true if the digest object A is allocated in "secure" memory. */
+int gcry_md_is_secure (gcry_md_hd_t a);
+
+/* Retrieve various information about the object H. */
+gcry_error_t gcry_md_info (gcry_md_hd_t h, int what, void *buffer,
+ size_t *nbytes);
+
+/* Retrieve various information about the algorithm ALGO. */
+gcry_error_t gcry_md_algo_info (int algo, int what, void *buffer,
+ size_t *nbytes);
+
+/* Map the digest algorithm id ALGO to a string representation of the
+ algorithm name. For unknown algorithms this function returns
+ "?". */
+const char *gcry_md_algo_name (int algo) _GCRY_GCC_ATTR_PURE;
+
+/* Map the algorithm NAME to a digest algorithm Id. Return 0 if
+ the algorithm name is not known. */
+int gcry_md_map_name (const char* name) _GCRY_GCC_ATTR_PURE;
+
+/* For use with the HMAC feature, the set MAC key to the KEY of
+ KEYLEN bytes. */
+gcry_error_t gcry_md_setkey (gcry_md_hd_t hd, const void *key, size_t keylen);
+
+/* Start or stop debugging for digest handle HD; i.e. create a file
+ named dbgmd-<n>.<suffix> while hashing. If SUFFIX is NULL,
+ debugging stops and the file will be closed. */
+void gcry_md_debug (gcry_md_hd_t hd, const char *suffix);
+
+
+/* Update the hash(s) of H with the character C. This is a buffered
+ version of the gcry_md_write function. */
+#define gcry_md_putc(h,c) \
+ do { \
+ gcry_md_hd_t h__ = (h); \
+ if( (h__)->bufpos == (h__)->bufsize ) \
+ gcry_md_write( (h__), NULL, 0 ); \
+ (h__)->buf[(h__)->bufpos++] = (c) & 0xff; \
+ } while(0)
+
+/* Finalize the digest calculation. This is not really needed because
+ gcry_md_read() does this implicitly. */
+#define gcry_md_final(a) \
+ gcry_md_ctl ((a), GCRYCTL_FINALIZE, NULL, 0)
+
+/* Return 0 if the algorithm A is available for use. */
+#define gcry_md_test_algo(a) \
+ gcry_md_algo_info( (a), GCRYCTL_TEST_ALGO, NULL, NULL )
+
+/* Return an DER encoded ASN.1 OID for the algorithm A in buffer B. N
+ must point to size_t variable with the available size of buffer B.
+ After return it will receive the actual size of the returned
+ OID. */
+#define gcry_md_get_asnoid(a,b,n) \
+ gcry_md_algo_info((a), GCRYCTL_GET_ASNOID, (b), (n))
+
+/* Enable debugging for digest object A; i.e. create files named
+ dbgmd-<n>.<string> while hashing. B is a string used as the suffix
+ for the filename. This macro is deprecated, use gcry_md_debug. */
+#ifndef GCRYPT_NO_DEPRECATED
+#define gcry_md_start_debug(a,b) \
+ gcry_md_ctl( (a), GCRYCTL_START_DUMP, (b), 0 )
+
+/* Disable the debugging of A. This macro is deprecated, use
+ gcry_md_debug. */
+#define gcry_md_stop_debug(a,b) \
+ gcry_md_ctl( (a), GCRYCTL_STOP_DUMP, (b), 0 )
+#endif
+
+/* Get a list consisting of the IDs of the loaded message digest
+ modules. If LIST is zero, write the number of loaded message
+ digest modules to LIST_LENGTH and return. If LIST is non-zero, the
+ first *LIST_LENGTH algorithm IDs are stored in LIST, which must be
+ of according size. In case there are less message digest modules
+ than *LIST_LENGTH, *LIST_LENGTH is updated to the correct
+ number. */
+gcry_error_t gcry_md_list (int *list, int *list_length);
+
+
+#if !defined(GCRYPT_NO_DEPRECATED) || defined(_GCRYPT_IN_LIBGCRYPT)
+/* Alternative interface for asymmetric cryptography. This interface
+ is deprecated. */
+
+/* The algorithm IDs. */
+typedef enum gcry_ac_id
+ {
+ GCRY_AC_RSA = 1,
+ GCRY_AC_DSA = 17,
+ GCRY_AC_ELG = 20,
+ GCRY_AC_ELG_E = 16
+ }
+gcry_ac_id_t _GCRY_ATTR_INTERNAL;
+
+/* Key types. */
+typedef enum gcry_ac_key_type
+ {
+ GCRY_AC_KEY_SECRET,
+ GCRY_AC_KEY_PUBLIC
+ }
+gcry_ac_key_type_t _GCRY_ATTR_INTERNAL;
+
+/* Encoding methods. */
+typedef enum gcry_ac_em
+ {
+ GCRY_AC_EME_PKCS_V1_5,
+ GCRY_AC_EMSA_PKCS_V1_5
+ }
+gcry_ac_em_t _GCRY_ATTR_INTERNAL;
+
+/* Encryption and Signature schemes. */
+typedef enum gcry_ac_scheme
+ {
+ GCRY_AC_ES_PKCS_V1_5,
+ GCRY_AC_SSA_PKCS_V1_5
+ }
+gcry_ac_scheme_t _GCRY_ATTR_INTERNAL;
+
+/* AC data. */
+#define GCRY_AC_FLAG_DEALLOC (1 << 0)
+#define GCRY_AC_FLAG_COPY (1 << 1)
+#define GCRY_AC_FLAG_NO_BLINDING (1 << 2)
+
+/* This type represents a `data set'. */
+typedef struct gcry_ac_data *gcry_ac_data_t _GCRY_ATTR_INTERNAL;
+
+/* This type represents a single `key', either a secret one or a
+ public one. */
+typedef struct gcry_ac_key *gcry_ac_key_t _GCRY_ATTR_INTERNAL;
+
+/* This type represents a `key pair' containing a secret and a public
+ key. */
+typedef struct gcry_ac_key_pair *gcry_ac_key_pair_t _GCRY_ATTR_INTERNAL;
+
+/* This type represents a `handle' that is needed by functions
+ performing cryptographic operations. */
+typedef struct gcry_ac_handle *gcry_ac_handle_t _GCRY_ATTR_INTERNAL;
+
+typedef gpg_error_t (*gcry_ac_data_read_cb_t) (void *opaque,
+ unsigned char *buffer,
+ size_t *buffer_n)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+typedef gpg_error_t (*gcry_ac_data_write_cb_t) (void *opaque,
+ unsigned char *buffer,
+ size_t buffer_n)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+typedef enum
+ {
+ GCRY_AC_IO_READABLE,
+ GCRY_AC_IO_WRITABLE
+ }
+gcry_ac_io_mode_t _GCRY_ATTR_INTERNAL;
+
+typedef enum
+ {
+ GCRY_AC_IO_STRING,
+ GCRY_AC_IO_CALLBACK
+ }
+gcry_ac_io_type_t _GCRY_ATTR_INTERNAL;
+
+typedef struct gcry_ac_io
+{
+ /* This is an INTERNAL structure, do NOT use manually. */
+ gcry_ac_io_mode_t mode _GCRY_ATTR_INTERNAL;
+ gcry_ac_io_type_t type _GCRY_ATTR_INTERNAL;
+ union
+ {
+ union
+ {
+ struct
+ {
+ gcry_ac_data_read_cb_t cb;
+ void *opaque;
+ } callback;
+ struct
+ {
+ unsigned char *data;
+ size_t data_n;
+ } string;
+ void *opaque;
+ } readable;
+ union
+ {
+ struct
+ {
+ gcry_ac_data_write_cb_t cb;
+ void *opaque;
+ } callback;
+ struct
+ {
+ unsigned char **data;
+ size_t *data_n;
+ } string;
+ void *opaque;
+ } writable;
+ } io _GCRY_ATTR_INTERNAL;
+}
+gcry_ac_io_t _GCRY_ATTR_INTERNAL;
+
+/* The caller of gcry_ac_key_pair_generate can provide one of these
+ structures in order to influence the key generation process in an
+ algorithm-specific way. */
+typedef struct gcry_ac_key_spec_rsa
+{
+ gcry_mpi_t e; /* E to use. */
+} gcry_ac_key_spec_rsa_t _GCRY_ATTR_INTERNAL;
+
+/* Structure used for passing data to the implementation of the
+ `EME-PKCS-V1_5' encoding method. */
+typedef struct gcry_ac_eme_pkcs_v1_5
+{
+ size_t key_size;
+} gcry_ac_eme_pkcs_v1_5_t _GCRY_ATTR_INTERNAL;
+
+typedef enum gcry_md_algos gcry_md_algo_t _GCRY_ATTR_INTERNAL;
+
+/* Structure used for passing data to the implementation of the
+ `EMSA-PKCS-V1_5' encoding method. */
+typedef struct gcry_ac_emsa_pkcs_v1_5
+{
+ gcry_md_algo_t md;
+ size_t em_n;
+} gcry_ac_emsa_pkcs_v1_5_t _GCRY_ATTR_INTERNAL;
+
+/* Structure used for passing data to the implementation of the
+ `SSA-PKCS-V1_5' signature scheme. */
+typedef struct gcry_ac_ssa_pkcs_v1_5
+{
+ gcry_md_algo_t md;
+} gcry_ac_ssa_pkcs_v1_5_t _GCRY_ATTR_INTERNAL;
+#endif /* !GCRYPT_NO_DEPRECATED || !_GCRYPT_IN_LIBGCRYPT */
+
+
+#ifndef GCRYPT_NO_DEPRECATED
+/* Returns a new, empty data set in DATA. */
+gcry_error_t gcry_ac_data_new (gcry_ac_data_t *data)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Destroy the data set DATA. */
+void gcry_ac_data_destroy (gcry_ac_data_t data)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Create a copy of the data set DATA and store it in DATA_CP. */
+gcry_error_t gcry_ac_data_copy (gcry_ac_data_t *data_cp,
+ gcry_ac_data_t data)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Return the number of named MPI values inside of the data set
+ DATA. */
+unsigned int gcry_ac_data_length (gcry_ac_data_t data)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Destroy any values contained in the data set DATA. */
+void gcry_ac_data_clear (gcry_ac_data_t data)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Add the value MPI to DATA with the label NAME. If FLAGS contains
+ GCRY_AC_FLAG_DATA_COPY, the data set will contain copies of NAME
+ and MPI. If FLAGS contains GCRY_AC_FLAG_DATA_DEALLOC or
+ GCRY_AC_FLAG_DATA_COPY, the values contained in the data set will
+ be deallocated when they are to be removed from the data set. */
+gcry_error_t gcry_ac_data_set (gcry_ac_data_t data, unsigned int flags,
+ const char *name, gcry_mpi_t mpi)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Store the value labelled with NAME found in DATA in MPI. If FLAGS
+ contains GCRY_AC_FLAG_COPY, store a copy of the MPI value contained
+ in the data set. MPI may be NULL. */
+gcry_error_t gcry_ac_data_get_name (gcry_ac_data_t data, unsigned int flags,
+ const char *name, gcry_mpi_t *mpi)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Stores in NAME and MPI the named MPI value contained in the data
+ set DATA with the index IDX. If FLAGS contains GCRY_AC_FLAG_COPY,
+ store copies of the values contained in the data set. NAME or MPI
+ may be NULL. */
+gcry_error_t gcry_ac_data_get_index (gcry_ac_data_t data, unsigned int flags,
+ unsigned int idx,
+ const char **name, gcry_mpi_t *mpi)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Convert the data set DATA into a new S-Expression, which is to be
+ stored in SEXP, according to the identifiers contained in
+ IDENTIFIERS. */
+gcry_error_t gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp,
+ const char **identifiers)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Create a new data set, which is to be stored in DATA_SET, from the
+ S-Expression SEXP, according to the identifiers contained in
+ IDENTIFIERS. */
+gcry_error_t gcry_ac_data_from_sexp (gcry_ac_data_t *data, gcry_sexp_t sexp,
+ const char **identifiers)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Initialize AC_IO according to MODE, TYPE and the variable list of
+ arguments. The list of variable arguments to specify depends on
+ the given TYPE. */
+void gcry_ac_io_init (gcry_ac_io_t *ac_io, gcry_ac_io_mode_t mode,
+ gcry_ac_io_type_t type, ...)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Initialize AC_IO according to MODE, TYPE and the variable list of
+ arguments AP. The list of variable arguments to specify depends on
+ the given TYPE. */
+void gcry_ac_io_init_va (gcry_ac_io_t *ac_io, gcry_ac_io_mode_t mode,
+ gcry_ac_io_type_t type, va_list ap)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Create a new ac handle. */
+gcry_error_t gcry_ac_open (gcry_ac_handle_t *handle,
+ gcry_ac_id_t algorithm, unsigned int flags)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Destroy an ac handle. */
+void gcry_ac_close (gcry_ac_handle_t handle)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Initialize a key from a given data set. */
+gcry_error_t gcry_ac_key_init (gcry_ac_key_t *key, gcry_ac_handle_t handle,
+ gcry_ac_key_type_t type, gcry_ac_data_t data)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Generates a new key pair via the handle HANDLE of NBITS bits and
+ stores it in KEY_PAIR. In case non-standard settings are wanted, a
+ pointer to a structure of type gcry_ac_key_spec_<algorithm>_t,
+ matching the selected algorithm, can be given as KEY_SPEC.
+ MISC_DATA is not used yet. */
+gcry_error_t gcry_ac_key_pair_generate (gcry_ac_handle_t handle,
+ unsigned int nbits, void *spec,
+ gcry_ac_key_pair_t *key_pair,
+ gcry_mpi_t **misc_data)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Returns the key of type WHICH out of the key pair KEY_PAIR. */
+gcry_ac_key_t gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair,
+ gcry_ac_key_type_t which)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Returns the data set contained in the key KEY. */
+gcry_ac_data_t gcry_ac_key_data_get (gcry_ac_key_t key)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Verifies that the key KEY is sane via HANDLE. */
+gcry_error_t gcry_ac_key_test (gcry_ac_handle_t handle, gcry_ac_key_t key)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Stores the number of bits of the key KEY in NBITS via HANDLE. */
+gcry_error_t gcry_ac_key_get_nbits (gcry_ac_handle_t handle,
+ gcry_ac_key_t key, unsigned int *nbits)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Writes the 20 byte long key grip of the key KEY to KEY_GRIP via
+ HANDLE. */
+gcry_error_t gcry_ac_key_get_grip (gcry_ac_handle_t handle, gcry_ac_key_t key,
+ unsigned char *key_grip)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Destroy a key. */
+void gcry_ac_key_destroy (gcry_ac_key_t key)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Destroy a key pair. */
+void gcry_ac_key_pair_destroy (gcry_ac_key_pair_t key_pair)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Encodes a message according to the encoding method METHOD. OPTIONS
+ must be a pointer to a method-specific structure
+ (gcry_ac_em*_t). */
+gcry_error_t gcry_ac_data_encode (gcry_ac_em_t method,
+ unsigned int flags, void *options,
+ gcry_ac_io_t *io_read,
+ gcry_ac_io_t *io_write)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Decodes a message according to the encoding method METHOD. OPTIONS
+ must be a pointer to a method-specific structure
+ (gcry_ac_em*_t). */
+gcry_error_t gcry_ac_data_decode (gcry_ac_em_t method,
+ unsigned int flags, void *options,
+ gcry_ac_io_t *io_read,
+ gcry_ac_io_t *io_write)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Encrypt the plain text MPI value DATA_PLAIN with the key KEY under
+ the control of the flags FLAGS and store the resulting data set
+ into DATA_ENCRYPTED. */
+gcry_error_t gcry_ac_data_encrypt (gcry_ac_handle_t handle,
+ unsigned int flags,
+ gcry_ac_key_t key,
+ gcry_mpi_t data_plain,
+ gcry_ac_data_t *data_encrypted)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Decrypt the decrypted data contained in the data set DATA_ENCRYPTED
+ with the key KEY under the control of the flags FLAGS and store the
+ resulting plain text MPI value in DATA_PLAIN. */
+gcry_error_t gcry_ac_data_decrypt (gcry_ac_handle_t handle,
+ unsigned int flags,
+ gcry_ac_key_t key,
+ gcry_mpi_t *data_plain,
+ gcry_ac_data_t data_encrypted)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Sign the data contained in DATA with the key KEY and store the
+ resulting signature in the data set DATA_SIGNATURE. */
+gcry_error_t gcry_ac_data_sign (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ gcry_mpi_t data,
+ gcry_ac_data_t *data_signature)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Verify that the signature contained in the data set DATA_SIGNATURE
+ is indeed the result of signing the data contained in DATA with the
+ secret key belonging to the public key KEY. */
+gcry_error_t gcry_ac_data_verify (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ gcry_mpi_t data,
+ gcry_ac_data_t data_signature)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Encrypts the plain text readable from IO_MESSAGE through HANDLE
+ with the public key KEY according to SCHEME, FLAGS and OPTS. If
+ OPTS is not NULL, it has to be a pointer to a structure specific to
+ the chosen scheme (gcry_ac_es_*_t). The encrypted message is
+ written to IO_CIPHER. */
+gcry_error_t gcry_ac_data_encrypt_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_cipher)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Decrypts the cipher text readable from IO_CIPHER through HANDLE
+ with the secret key KEY according to SCHEME, @var{flags} and OPTS.
+ If OPTS is not NULL, it has to be a pointer to a structure specific
+ to the chosen scheme (gcry_ac_es_*_t). The decrypted message is
+ written to IO_MESSAGE. */
+gcry_error_t gcry_ac_data_decrypt_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_cipher,
+ gcry_ac_io_t *io_message)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Signs the message readable from IO_MESSAGE through HANDLE with the
+ secret key KEY according to SCHEME, FLAGS and OPTS. If OPTS is not
+ NULL, it has to be a pointer to a structure specific to the chosen
+ scheme (gcry_ac_ssa_*_t). The signature is written to
+ IO_SIGNATURE. */
+gcry_error_t gcry_ac_data_sign_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_signature)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Verifies through HANDLE that the signature readable from
+ IO_SIGNATURE is indeed the result of signing the message readable
+ from IO_MESSAGE with the secret key belonging to the public key KEY
+ according to SCHEME and OPTS. If OPTS is not NULL, it has to be an
+ anonymous structure (gcry_ac_ssa_*_t) specific to the chosen
+ scheme. */
+gcry_error_t gcry_ac_data_verify_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_signature)
+ /* */ _GCRY_ATTR_INTERNAL;
+
+/* Store the textual representation of the algorithm whose id is given
+ in ALGORITHM in NAME. This function is deprecated; use
+ gcry_pk_algo_name. */
+gcry_error_t gcry_ac_id_to_name (gcry_ac_id_t algorithm,
+ const char **name)
+ /* */ _GCRY_GCC_ATTR_DEPRECATED;
+/* Store the numeric ID of the algorithm whose textual representation
+ is contained in NAME in ALGORITHM. This function is deprecated;
+ use gcry_pk_map_name. */
+gcry_error_t gcry_ac_name_to_id (const char *name,
+ gcry_ac_id_t *algorithm)
+ /* */ _GCRY_GCC_ATTR_DEPRECATED;
+#endif /*GCRYPT_NO_DEPRECATED*/
+
+
+/******************************
+ * *
+ * Key Derivation Functions *
+ * *
+ ******************************/
+
+/* Algorithm IDs for the KDFs. */
+enum gcry_kdf_algos
+ {
+ GCRY_KDF_NONE = 0,
+ GCRY_KDF_SIMPLE_S2K = 16,
+ GCRY_KDF_SALTED_S2K = 17,
+ GCRY_KDF_ITERSALTED_S2K = 19,
+ GCRY_KDF_PBKDF1 = 33,
+ GCRY_KDF_PBKDF2 = 34
+ };
+
+/* Derive a key from a passphrase. */
+gpg_error_t gcry_kdf_derive (const void *passphrase, size_t passphraselen,
+ int algo, int subalgo,
+ const void *salt, size_t saltlen,
+ unsigned long iterations,
+ size_t keysize, void *keybuffer);
+
+
+
+
+/************************************
+ * *
+ * Random Generating Functions *
+ * *
+ ************************************/
+
+/* The possible values for the random quality. The rule of thumb is
+ to use STRONG for session keys and VERY_STRONG for key material.
+ WEAK is usually an alias for STRONG and should not be used anymore
+ (except with gcry_mpi_randomize); use gcry_create_nonce instead. */
+typedef enum gcry_random_level
+ {
+ GCRY_WEAK_RANDOM = 0,
+ GCRY_STRONG_RANDOM = 1,
+ GCRY_VERY_STRONG_RANDOM = 2
+ }
+gcry_random_level_t;
+
+/* Fill BUFFER with LENGTH bytes of random, using random numbers of
+ quality LEVEL. */
+void gcry_randomize (void *buffer, size_t length,
+ enum gcry_random_level level);
+
+/* Add the external random from BUFFER with LENGTH bytes into the
+ pool. QUALITY should either be -1 for unknown or in the range of 0
+ to 100 */
+gcry_error_t gcry_random_add_bytes (const void *buffer, size_t length,
+ int quality);
+
+/* If random numbers are used in an application, this macro should be
+ called from time to time so that new stuff gets added to the
+ internal pool of the RNG. */
+#define gcry_fast_random_poll() gcry_control (GCRYCTL_FAST_POLL, NULL)
+
+
+/* Return NBYTES of allocated random using a random numbers of quality
+ LEVEL. */
+void *gcry_random_bytes (size_t nbytes, enum gcry_random_level level)
+ _GCRY_GCC_ATTR_MALLOC;
+
+/* Return NBYTES of allocated random using a random numbers of quality
+ LEVEL. The random numbers are created returned in "secure"
+ memory. */
+void *gcry_random_bytes_secure (size_t nbytes, enum gcry_random_level level)
+ _GCRY_GCC_ATTR_MALLOC;
+
+
+/* Set the big integer W to a random value of NBITS using a random
+ generator with quality LEVEL. Note that by using a level of
+ GCRY_WEAK_RANDOM gcry_create_nonce is used internally. */
+void gcry_mpi_randomize (gcry_mpi_t w,
+ unsigned int nbits, enum gcry_random_level level);
+
+
+/* Create an unpredicable nonce of LENGTH bytes in BUFFER. */
+void gcry_create_nonce (void *buffer, size_t length);
+
+
+
+
+
+/*******************************/
+/* */
+/* Prime Number Functions */
+/* */
+/*******************************/
+
+/* Mode values passed to a gcry_prime_check_func_t. */
+#define GCRY_PRIME_CHECK_AT_FINISH 0
+#define GCRY_PRIME_CHECK_AT_GOT_PRIME 1
+#define GCRY_PRIME_CHECK_AT_MAYBE_PRIME 2
+
+/* The function should return 1 if the operation shall continue, 0 to
+ reject the prime candidate. */
+typedef int (*gcry_prime_check_func_t) (void *arg, int mode,
+ gcry_mpi_t candidate);
+
+/* Flags for gcry_prime_generate(): */
+
+/* Allocate prime numbers and factors in secure memory. */
+#define GCRY_PRIME_FLAG_SECRET (1 << 0)
+
+/* Make sure that at least one prime factor is of size
+ `FACTOR_BITS'. */
+#define GCRY_PRIME_FLAG_SPECIAL_FACTOR (1 << 1)
+
+/* Generate a new prime number of PRIME_BITS bits and store it in
+ PRIME. If FACTOR_BITS is non-zero, one of the prime factors of
+ (prime - 1) / 2 must be FACTOR_BITS bits long. If FACTORS is
+ non-zero, allocate a new, NULL-terminated array holding the prime
+ factors and store it in FACTORS. FLAGS might be used to influence
+ the prime number generation process. */
+gcry_error_t gcry_prime_generate (gcry_mpi_t *prime,
+ unsigned int prime_bits,
+ unsigned int factor_bits,
+ gcry_mpi_t **factors,
+ gcry_prime_check_func_t cb_func,
+ void *cb_arg,
+ gcry_random_level_t random_level,
+ unsigned int flags);
+
+/* Find a generator for PRIME where the factorization of (prime-1) is
+ in the NULL terminated array FACTORS. Return the generator as a
+ newly allocated MPI in R_G. If START_G is not NULL, use this as
+ teh start for the search. */
+gcry_error_t gcry_prime_group_generator (gcry_mpi_t *r_g,
+ gcry_mpi_t prime,
+ gcry_mpi_t *factors,
+ gcry_mpi_t start_g);
+
+
+/* Convenience function to release the FACTORS array. */
+void gcry_prime_release_factors (gcry_mpi_t *factors);
+
+
+/* Check wether the number X is prime. */
+gcry_error_t gcry_prime_check (gcry_mpi_t x, unsigned int flags);
+
+
+
+/************************************
+ * *
+ * Miscellaneous Stuff *
+ * *
+ ************************************/
+
+/* Log levels used by the internal logging facility. */
+enum gcry_log_levels
+ {
+ GCRY_LOG_CONT = 0, /* (Continue the last log line.) */
+ GCRY_LOG_INFO = 10,
+ GCRY_LOG_WARN = 20,
+ GCRY_LOG_ERROR = 30,
+ GCRY_LOG_FATAL = 40,
+ GCRY_LOG_BUG = 50,
+ GCRY_LOG_DEBUG = 100
+ };
+
+/* Type for progress handlers. */
+typedef void (*gcry_handler_progress_t) (void *, const char *, int, int, int);
+
+/* Type for memory allocation handlers. */
+typedef void *(*gcry_handler_alloc_t) (size_t n);
+
+/* Type for secure memory check handlers. */
+typedef int (*gcry_handler_secure_check_t) (const void *);
+
+/* Type for memory reallocation handlers. */
+typedef void *(*gcry_handler_realloc_t) (void *p, size_t n);
+
+/* Type for memory free handlers. */
+typedef void (*gcry_handler_free_t) (void *);
+
+/* Type for out-of-memory handlers. */
+typedef int (*gcry_handler_no_mem_t) (void *, size_t, unsigned int);
+
+/* Type for fatal error handlers. */
+typedef void (*gcry_handler_error_t) (void *, int, const char *);
+
+/* Type for logging handlers. */
+typedef void (*gcry_handler_log_t) (void *, int, const char *, va_list);
+
+/* Certain operations can provide progress information. This function
+ is used to register a handler for retrieving these information. */
+void gcry_set_progress_handler (gcry_handler_progress_t cb, void *cb_data);
+
+
+/* Register a custom memory allocation functions. */
+void gcry_set_allocation_handler (
+ gcry_handler_alloc_t func_alloc,
+ gcry_handler_alloc_t func_alloc_secure,
+ gcry_handler_secure_check_t func_secure_check,
+ gcry_handler_realloc_t func_realloc,
+ gcry_handler_free_t func_free);
+
+/* Register a function used instead of the internal out of memory
+ handler. */
+void gcry_set_outofcore_handler (gcry_handler_no_mem_t h, void *opaque);
+
+/* Register a function used instead of the internal fatal error
+ handler. */
+void gcry_set_fatalerror_handler (gcry_handler_error_t fnc, void *opaque);
+
+/* Register a function used instead of the internal logging
+ facility. */
+void gcry_set_log_handler (gcry_handler_log_t f, void *opaque);
+
+/* Reserved for future use. */
+void gcry_set_gettext_handler (const char *(*f)(const char*));
+
+/* Libgcrypt uses its own memory allocation. It is important to use
+ gcry_free () to release memory allocated by libgcrypt. */
+void *gcry_malloc (size_t n) _GCRY_GCC_ATTR_MALLOC;
+void *gcry_calloc (size_t n, size_t m) _GCRY_GCC_ATTR_MALLOC;
+void *gcry_malloc_secure (size_t n) _GCRY_GCC_ATTR_MALLOC;
+void *gcry_calloc_secure (size_t n, size_t m) _GCRY_GCC_ATTR_MALLOC;
+void *gcry_realloc (void *a, size_t n);
+char *gcry_strdup (const char *string) _GCRY_GCC_ATTR_MALLOC;
+void *gcry_xmalloc (size_t n) _GCRY_GCC_ATTR_MALLOC;
+void *gcry_xcalloc (size_t n, size_t m) _GCRY_GCC_ATTR_MALLOC;
+void *gcry_xmalloc_secure (size_t n) _GCRY_GCC_ATTR_MALLOC;
+void *gcry_xcalloc_secure (size_t n, size_t m) _GCRY_GCC_ATTR_MALLOC;
+void *gcry_xrealloc (void *a, size_t n);
+char *gcry_xstrdup (const char * a) _GCRY_GCC_ATTR_MALLOC;
+void gcry_free (void *a);
+
+/* Return true if A is allocated in "secure" memory. */
+int gcry_is_secure (const void *a) _GCRY_GCC_ATTR_PURE;
+
+/* Return true if Libgcrypt is in FIPS mode. */
+#define gcry_fips_mode_active() !!gcry_control (GCRYCTL_FIPS_MODE_P, 0)
+
+
+/* Include support for Libgcrypt modules. */
+#include <gcrypt-module.h>
+
+#if 0 /* (Keep Emacsens' auto-indent happy.) */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif /* _GCRYPT_H */
+/*
+@emacs_local_vars_begin@
+@emacs_local_vars_read_only@
+@emacs_local_vars_end@
+*/
diff --git a/grub-core/lib/libgcrypt/src/gcryptrnd.c b/grub-core/lib/libgcrypt/src/gcryptrnd.c
new file mode 100644
index 0000000..b13931b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/gcryptrnd.c
@@ -0,0 +1,680 @@
+/* gcryptrnd.c - Libgcrypt Random Number Daemon
+ * Copyright (C) 2006 Free Software Foundation, Inc.
+ *
+ * Gcryptend is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * Gcryptrnd is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+/* We require vsyslog pth
+ We need to test for: setrlimit
+
+ We should also prioritize requests. This is best done by putting
+ the requests into queues and have a main thread processing these
+ queues.
+
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <time.h>
+#include <sys/times.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdarg.h>
+#include <syslog.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <errno.h>
+#include <pth.h>
+#include <gcrypt.h>
+
+#define PGM "gcryptrnd"
+#define MYVERSION_LINE PGM " (Libgcrypt) " VERSION
+#define BUGREPORT_LINE "\nReport bugs to <bug-libgcrypt@gnupg.org>.\n"
+
+/* Pth wrapper function definitions. */
+GCRY_THREAD_OPTION_PTH_IMPL;
+
+
+/* Flag set to true if we have been daemonized. */
+static int running_detached;
+/* Flag indicating that a shutdown has been requested. */
+static int shutdown_pending;
+/* Counter for active connections. */
+static int active_connections;
+
+
+
+/* Local prototypes. */
+static void serve (int listen_fd);
+
+
+
+
+
+/* To avoid that a compiler optimizes certain memset calls away, these
+ macros may be used instead. */
+#define wipememory2(_ptr,_set,_len) do { \
+ volatile char *_vptr=(volatile char *)(_ptr); \
+ size_t _vlen=(_len); \
+ while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
+ } while(0)
+#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
+
+
+
+
+/* Error printing utility. PRIORITY should be one of syslog's
+ priority levels. This functions prints to the stderr or syslog
+ depending on whether we are already daemonized. */
+static void
+logit (int priority, const char *format, ...)
+{
+ va_list arg_ptr;
+
+ va_start (arg_ptr, format) ;
+ if (running_detached)
+ {
+ vsyslog (priority, format, arg_ptr);
+ }
+ else
+ {
+ fputs (PGM ": ", stderr);
+ vfprintf (stderr, format, arg_ptr);
+ putc ('\n', stderr);
+ }
+ va_end (arg_ptr);
+}
+
+/* Callback used by libgcrypt for logging. */
+static void
+my_gcry_logger (void *dummy, int level, const char *format, va_list arg_ptr)
+{
+ (void)dummy;
+
+ /* Map the log levels. */
+ switch (level)
+ {
+ case GCRY_LOG_CONT: level = LOG_INFO /* FIXME */; break;
+ case GCRY_LOG_INFO: level = LOG_INFO; break;
+ case GCRY_LOG_WARN: level = LOG_WARNING; break;
+ case GCRY_LOG_ERROR:level = LOG_ERR; break;
+ case GCRY_LOG_FATAL:level = LOG_CRIT; break;
+ case GCRY_LOG_BUG: level = LOG_CRIT; break;
+ case GCRY_LOG_DEBUG:level = LOG_DEBUG; break;
+ default: level = LOG_ERR; break;
+ }
+ if (running_detached)
+ {
+ vsyslog (level, format, arg_ptr);
+ }
+ else
+ {
+ fputs (PGM ": ", stderr);
+ vfprintf (stderr, format, arg_ptr);
+ if (!*format || format[strlen (format)-1] != '\n')
+ putc ('\n', stderr);
+ }
+}
+
+
+/* The cleanup handler - used to wipe out the secure memory. */
+static void
+cleanup (void)
+{
+ gcry_control (GCRYCTL_TERM_SECMEM );
+}
+
+
+/* Make us a daemon and open the syslog. */
+static void
+daemonize (void)
+{
+ int i;
+ pid_t pid;
+
+ fflush (NULL);
+
+ pid = fork ();
+ if (pid == (pid_t)-1)
+ {
+ logit (LOG_CRIT, "fork failed: %s", strerror (errno));
+ exit (1);
+ }
+ if (pid)
+ exit (0);
+
+ if (setsid() == -1)
+ {
+ logit (LOG_CRIT, "setsid() failed: %s", strerror(errno));
+ exit (1);
+ }
+
+ signal (SIGHUP, SIG_IGN);
+
+ pid = fork ();
+ if (pid == (pid_t)-1)
+ {
+ logit (LOG_CRIT, PGM ": second fork failed: %s", strerror (errno));
+ exit (1);
+ }
+ if (pid)
+ exit (0); /* First child exits. */
+
+ running_detached = 1;
+
+ if (chdir("/"))
+ {
+ logit (LOG_CRIT, "chdir(\"/\") failed: %s", strerror (errno));
+ exit (1);
+ }
+ umask (0);
+
+ for (i=0; i <= 2; i++)
+ close (i);
+
+ openlog (PGM, LOG_PID, LOG_DAEMON);
+}
+
+
+static void
+disable_core_dumps (void)
+{
+#ifdef HAVE_SETRLIMIT
+ struct rlimit limit;
+
+ if (getrlimit (RLIMIT_CORE, &limit))
+ limit.rlim_max = 0;
+ limit.rlim_cur = 0;
+ if( !setrlimit (RLIMIT_CORE, &limit) )
+ return 0;
+ if (errno != EINVAL && errno != ENOSYS)
+ logit (LOG_ERR, "can't disable core dumps: %s\n", strerror (errno));
+#endif /* HAVE_SETRLIMIT */
+}
+
+
+
+static void
+print_version (int with_help)
+{
+ fputs (MYVERSION_LINE "\n"
+ "Copyright (C) 2006 Free Software Foundation, Inc.\n"
+ "License GPLv2+: GNU GPL version 2 or later "
+ "<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n"
+ "This is free software: you are free to change and redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n",
+ stdout);
+
+ if (with_help)
+ fputs ("\n"
+ "Usage: " PGM " [OPTIONS] [SOCKETNAME]\n"
+ "Start Libgcrypt's random number daemon listening"
+ " on socket SOCKETNAME\n"
+ "SOCKETNAME defaults to XXX\n"
+ "\n"
+ " --no-detach do not deatach from the console\n"
+ " --version print version of the program and exit\n"
+ " --help display this help and exit\n"
+ BUGREPORT_LINE, stdout );
+
+ exit (0);
+}
+
+static int
+print_usage (void)
+{
+ fputs ("usage: " PGM " [OPTIONS] [SOCKETNAME]\n", stderr);
+ fputs (" (use --help to display options)\n", stderr);
+ exit (1);
+}
+
+
+int
+main (int argc, char **argv)
+{
+ int no_detach = 0;
+ gpg_error_t err;
+ struct sockaddr_un *srvr_addr;
+ socklen_t addrlen;
+ int fd;
+ int rc;
+ const char *socketname = "/var/run/libgcrypt/S.gcryptrnd";
+
+
+ if (argc)
+ {
+ argc--; argv++;
+ }
+ while (argc && **argv == '-' && (*argv)[1] == '-')
+ {
+ if (!(*argv)[2])
+ {
+ argc--; argv++;
+ break;
+ }
+ else if (!strcmp (*argv, "--version"))
+ print_version (0);
+ else if (!strcmp (*argv, "--help"))
+ print_version (1);
+ else if (!strcmp (*argv, "--no-detach"))
+ {
+ no_detach = 1;
+ argc--; argv++;
+ }
+ else
+ print_usage ();
+ }
+
+ if (argc == 1)
+ socketname = argv[0];
+ else if (argc > 1)
+ print_usage ();
+
+ if (!no_detach)
+ daemonize ();
+
+ signal (SIGPIPE, SIG_IGN);
+
+ logit (LOG_NOTICE, "started version " VERSION );
+
+ /* Libgcrypt requires us to register the threading model before we
+ do anything else with it. Note that this also calls pth_init. We
+ do the initialization while already running as a daemon to avoid
+ overhead with double initialization of Libgcrypt. */
+ err = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth);
+ if (err)
+ {
+ logit (LOG_CRIT, "can't register GNU Pth with Libgcrypt: %s",
+ gpg_strerror (err));
+ exit (1);
+ }
+
+ /* Check that the libgcrypt version is sufficient. */
+ if (!gcry_check_version (VERSION) )
+ {
+ logit (LOG_CRIT, "libgcrypt is too old (need %s, have %s)",
+ VERSION, gcry_check_version (NULL) );
+ exit (1);
+ }
+
+ /* Register the logging callback and tell Libcgrypt to put the
+ random pool into secure memory. */
+ gcry_set_log_handler (my_gcry_logger, NULL);
+ gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
+
+ /* Obviously we don't want to allow any core dumps. */
+ disable_core_dumps ();
+
+ /* Initialize the secure memory stuff which will also drop any extra
+ privileges we have. */
+ gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
+
+ /* Register a cleanup handler. */
+ atexit (cleanup);
+
+ /* Create and listen on the socket. */
+ fd = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (fd == -1)
+ {
+ logit (LOG_CRIT, "can't create socket: %s", strerror (errno));
+ exit (1);
+ }
+ srvr_addr = gcry_xmalloc (sizeof *srvr_addr);
+ memset (srvr_addr, 0, sizeof *srvr_addr);
+ srvr_addr->sun_family = AF_UNIX;
+ if (strlen (socketname) + 1 >= sizeof (srvr_addr->sun_path))
+ {
+ logit (LOG_CRIT, "socket name `%s' too long", socketname);
+ exit (1);
+ }
+ strcpy (srvr_addr->sun_path, socketname);
+ addrlen = (offsetof (struct sockaddr_un, sun_path)
+ + strlen (srvr_addr->sun_path) + 1);
+ rc = bind (fd, (struct sockaddr*) srvr_addr, addrlen);
+ if (rc == -1 && errno == EADDRINUSE)
+ {
+ remove (socketname);
+ rc = bind (fd, (struct sockaddr*) srvr_addr, addrlen);
+ }
+ if (rc == -1)
+ {
+ logit (LOG_CRIT, "error binding socket to `%s': %s",
+ srvr_addr->sun_path, strerror (errno));
+ close (fd);
+ exit (1);
+ }
+
+ if (listen (fd, 5 ) == -1)
+ {
+ logit (LOG_CRIT, "listen() failed: %s", strerror (errno));
+ close (fd);
+ exit (1);
+ }
+
+ logit (LOG_INFO, "listening on socket `%s', fd=%d",
+ srvr_addr->sun_path, fd);
+
+ serve (fd);
+ close (fd);
+
+ logit (LOG_NOTICE, "stopped version " VERSION );
+ return 0;
+}
+
+
+/* Send LENGTH bytes of BUFFER to file descriptor FD. Returns 0 on
+ success or another value on write error. */
+static int
+writen (int fd, const void *buffer, size_t length)
+{
+ while (length)
+ {
+ ssize_t n = pth_write (fd, buffer, length);
+ if (n < 0)
+ {
+ logit (LOG_ERR, "connection %d: write error: %s",
+ fd, strerror (errno));
+ return -1; /* write error */
+ }
+ length -= n;
+ buffer = (const char*)buffer + n;
+ }
+ return 0; /* Okay */
+}
+
+
+/* Send an error response back. Returns 0 on success. */
+static int
+send_error (int fd, int errcode)
+{
+ unsigned char buf[2];
+
+ buf[0] = errcode;
+ buf[1] = 0;
+ return writen (fd, buf, 2 );
+}
+
+/* Send a pong response back. Returns 0 on success or another value
+ on write error. */
+static int
+send_pong (int fd)
+{
+ return writen (fd, "\x00\x04pong", 6);
+}
+
+/* Send a nonce of size LENGTH back. Return 0 on success. */
+static int
+send_nonce (int fd, int length)
+{
+ unsigned char buf[2+255];
+ int rc;
+
+ assert (length >= 0 && length <= 255);
+ buf[0] = 0;
+ buf[1] = length;
+ gcry_create_nonce (buf+2, length);
+ rc = writen (fd, buf, 2+length );
+ wipememory (buf+2, length);
+ return rc;
+}
+
+/* Send a random of size LENGTH with quality LEVEL back. Return 0 on
+ success. */
+static int
+send_random (int fd, int length, int level)
+{
+ unsigned char buf[2+255];
+ int rc;
+
+ assert (length >= 0 && length <= 255);
+ assert (level == GCRY_STRONG_RANDOM || level == GCRY_VERY_STRONG_RANDOM);
+ buf[0] = 0;
+ buf[1] = length;
+ /* Note that we don't bother putting the random stuff into secure
+ memory because this daemon is anyway intended to be run under
+ root and it is questionable whether the kernel buffers etc. are
+ equally well protected. */
+ gcry_randomize (buf+2, length, level);
+ rc = writen (fd, buf, 2+length );
+ wipememory (buf+2, length);
+ return rc;
+}
+
+/* Main processing loop for a connection.
+
+ A request is made up of:
+
+ 1 byte Total length of request; must be 3
+ 1 byte Command
+ 0 = Ping
+ 10 = GetNonce
+ 11 = GetStrongRandom
+ 12 = GetVeryStrongRandom
+ (all other values are reserved)
+ 1 byte Number of requested bytes.
+ This is ignored for command Ping.
+
+ A response is made up of:
+
+ 1 byte Error Code
+ 0 = Everything is fine
+ 1 = Bad Command
+ 0xff = Other error.
+ (For a bad request the connection will simply be closed)
+ 1 byte Length of data
+ n byte data
+
+ The requests are read as long as the connection is open.
+
+
+ */
+static void
+connection_loop (int fd)
+{
+ unsigned char request[3];
+ unsigned char *p;
+ int nleft, n;
+ int rc;
+
+ for (;;)
+ {
+ for (nleft=3, p=request; nleft > 0; )
+ {
+ n = pth_read (fd, p, nleft);
+ if (!n && p == request)
+ return; /* Client terminated connection. */
+ if (n <= 0)
+ {
+ logit (LOG_ERR, "connection %d: read error: %s",
+ fd, n? strerror (errno) : "Unexpected EOF");
+ return;
+ }
+ p += n;
+ nleft -= n;
+ }
+ if (request[0] != 3)
+ {
+ logit (LOG_ERR, "connection %d: invalid length (%d) of request",
+ fd, request[0]);
+ return;
+ }
+
+ switch (request[1])
+ {
+ case 0: /* Ping */
+ rc = send_pong (fd);
+ break;
+ case 10: /* GetNonce */
+ rc = send_nonce (fd, request[2]);
+ break;
+ case 11: /* GetStrongRandom */
+ rc = send_random (fd, request[2], GCRY_STRONG_RANDOM);
+ break;
+ case 12: /* GetVeryStrongRandom */
+ rc = send_random (fd, request[2], GCRY_VERY_STRONG_RANDOM);
+ break;
+
+ default: /* Invalid command */
+ rc = send_error (fd, 1);
+ break;
+ }
+ if (rc)
+ break; /* A write error occurred while sending the response. */
+ }
+}
+
+
+
+/* Entry point for a connection's thread. */
+static void *
+connection_thread (void *arg)
+{
+ int fd = (int)arg;
+
+ active_connections++;
+ logit (LOG_INFO, "connection handler for fd %d started", fd);
+
+ connection_loop (fd);
+
+ close (fd);
+ logit (LOG_INFO, "connection handler for fd %d terminated", fd);
+ active_connections--;
+
+ return NULL;
+}
+
+
+/* This signal handler is called from the main loop between acepting
+ connections. It is called on the regular stack, thus no special
+ caution needs to be taken. It returns true to indicate that the
+ process should terminate. */
+static int
+handle_signal (int signo)
+{
+ switch (signo)
+ {
+ case SIGHUP:
+ logit (LOG_NOTICE, "SIGHUP received - re-reading configuration");
+ break;
+
+ case SIGUSR1:
+ logit (LOG_NOTICE, "SIGUSR1 received - no action defined");
+ break;
+
+ case SIGUSR2:
+ logit (LOG_NOTICE, "SIGUSR2 received - no action defined");
+ break;
+
+ case SIGTERM:
+ if (!shutdown_pending)
+ logit (LOG_NOTICE, "SIGTERM received - shutting down ...");
+ else
+ logit (LOG_NOTICE, "SIGTERM received - still %d active connections",
+ active_connections);
+ shutdown_pending++;
+ if (shutdown_pending > 2)
+ {
+ logit (LOG_NOTICE, "shutdown forced");
+ return 1;
+ }
+ break;
+
+ case SIGINT:
+ logit (LOG_NOTICE, "SIGINT received - immediate shutdown");
+ return 1;
+
+ default:
+ logit (LOG_NOTICE, "signal %d received - no action defined\n", signo);
+ }
+ return 0;
+}
+
+
+
+/* Main server loop. This is called with the FD of the listening
+ socket. */
+static void
+serve (int listen_fd)
+{
+ pth_attr_t tattr;
+ pth_event_t ev;
+ sigset_t sigs;
+ int signo;
+ struct sockaddr_un paddr;
+ socklen_t plen = sizeof (paddr);
+ int fd;
+
+ tattr = pth_attr_new();
+ pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0);
+ pth_attr_set (tattr, PTH_ATTR_STACK_SIZE, 256*1024);
+ pth_attr_set (tattr, PTH_ATTR_NAME, "connection");
+
+ sigemptyset (&sigs);
+ sigaddset (&sigs, SIGHUP);
+ sigaddset (&sigs, SIGUSR1);
+ sigaddset (&sigs, SIGUSR2);
+ sigaddset (&sigs, SIGINT);
+ sigaddset (&sigs, SIGTERM);
+ ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
+
+ for (;;)
+ {
+ if (shutdown_pending)
+ {
+ if (!active_connections)
+ break; /* Ready. */
+
+ /* Do not accept anymore connections but wait for existing
+ connections to terminate. */
+ signo = 0;
+ pth_wait (ev);
+ if (pth_event_occurred (ev) && signo)
+ if (handle_signal (signo))
+ break; /* Stop the loop. */
+ continue;
+ }
+
+ gcry_fast_random_poll ();
+ fd = pth_accept_ev (listen_fd, (struct sockaddr *)&paddr, &plen, ev);
+ if (fd == -1)
+ {
+ if (pth_event_occurred (ev))
+ {
+ if (handle_signal (signo))
+ break; /* Stop the loop. */
+ continue;
+ }
+ logit (LOG_WARNING, "accept failed: %s - waiting 1s\n",
+ strerror (errno));
+ gcry_fast_random_poll ();
+ pth_sleep (1);
+ continue;
+ }
+
+ if (!pth_spawn (tattr, connection_thread, (void*)fd))
+ {
+ logit (LOG_ERR, "error spawning connection handler: %s\n",
+ strerror (errno) );
+ close (fd);
+ }
+ }
+
+ pth_event_free (ev, PTH_FREE_ALL);
+}
diff --git a/grub-core/lib/libgcrypt/src/getrandom.c b/grub-core/lib/libgcrypt/src/getrandom.c
new file mode 100644
index 0000000..f9bb5c0
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/getrandom.c
@@ -0,0 +1,326 @@
+/* getrandom.c - Libgcrypt Random Number client
+ * Copyright (C) 2006 Free Software Foundation, Inc.
+ *
+ * Getrandom is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * Getrandom is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdarg.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <errno.h>
+
+#define PGM "getrandom"
+#define MYVERSION_LINE PGM " (Libgcrypt) " VERSION
+#define BUGREPORT_LINE "\nReport bugs to <bug-libgcrypt@gnupg.org>.\n"
+
+
+static void
+logit (const char *format, ...)
+{
+ va_list arg_ptr;
+
+ va_start (arg_ptr, format) ;
+ fputs (PGM ": ", stderr);
+ vfprintf (stderr, format, arg_ptr);
+ putc ('\n', stderr);
+ va_end (arg_ptr);
+}
+
+
+/* Send LENGTH bytes of BUFFER to file descriptor FD. Returns 0 on
+ success or another value on write error. */
+static int
+writen (int fd, const void *buffer, size_t length)
+{
+ while (length)
+ {
+ ssize_t n;
+
+ do
+ n = write (fd, buffer, length);
+ while (n < 0 && errno == EINTR);
+ if (n < 0)
+ {
+ logit ("write error: %s", strerror (errno));
+ return -1; /* write error */
+ }
+ length -= n;
+ buffer = (const char *)buffer + n;
+ }
+ return 0; /* Okay */
+}
+
+
+
+
+static void
+print_version (int with_help)
+{
+ fputs (MYVERSION_LINE "\n"
+ "Copyright (C) 2006 Free Software Foundation, Inc.\n"
+ "License GPLv2+: GNU GPL version 2 or later "
+ "<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n"
+ "This is free software: you are free to change and redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n",
+ stdout);
+
+ if (with_help)
+ fputs ("\n"
+ "Usage: " PGM " [OPTIONS] NBYTES\n"
+ "Connect to libgcrypt's random number daemon and "
+ "return random numbers"
+ "\n"
+ " --nonce Return weak random suitable for a nonce\n"
+ " --very-strong Return very strong random\n"
+ " --ping Send a ping\n"
+ " --socket NAME Name of sockket to connect to\n"
+ " --hex Return result as a hex dump\n"
+ " --verbose Show what we are doing\n"
+ " --version Print version of the program and exit\n"
+ " --help Display this help and exit\n"
+ BUGREPORT_LINE, stdout );
+
+ exit (0);
+}
+
+static int
+print_usage (void)
+{
+ fputs ("usage: " PGM " [OPTIONS] NBYTES\n", stderr);
+ fputs (" (use --help to display options)\n", stderr);
+ exit (1);
+}
+
+
+int
+main (int argc, char **argv)
+{
+ struct sockaddr_un *srvr_addr;
+ socklen_t addrlen;
+ int fd;
+ int rc;
+ unsigned char buffer[300];
+ int nleft, nread;
+ const char *socketname = "/var/run/libgcrypt/S.gcryptrnd";
+ int do_ping = 0;
+ int get_nonce = 0;
+ int get_very_strong = 0;
+ int req_nbytes, nbytes, n;
+ int verbose = 0;
+ int fail = 0;
+ int do_hex = 0;
+
+ if (argc)
+ {
+ argc--; argv++;
+ }
+ while (argc && **argv == '-' && (*argv)[1] == '-')
+ {
+ if (!(*argv)[2])
+ {
+ argc--; argv++;
+ break;
+ }
+ else if (!strcmp (*argv, "--version"))
+ print_version (0);
+ else if (!strcmp (*argv, "--help"))
+ print_version (1);
+ else if (!strcmp (*argv, "--socket") && argc > 1 )
+ {
+ argc--; argv++;
+ socketname = *argv;
+ argc--; argv++;
+ }
+ else if (!strcmp (*argv, "--nonce"))
+ {
+ argc--; argv++;
+ get_nonce = 1;
+ }
+ else if (!strcmp (*argv, "--very-strong"))
+ {
+ argc--; argv++;
+ get_very_strong = 1;
+ }
+ else if (!strcmp (*argv, "--ping"))
+ {
+ argc--; argv++;
+ do_ping = 1;
+ }
+ else if (!strcmp (*argv, "--hex"))
+ {
+ argc--; argv++;
+ do_hex = 1;
+ }
+ else if (!strcmp (*argv, "--verbose"))
+ {
+ argc--; argv++;
+ verbose = 1;
+ }
+ else
+ print_usage ();
+ }
+
+
+ if (!argc && do_ping)
+ ; /* This is allowed. */
+ else if (argc != 1)
+ print_usage ();
+ req_nbytes = argc? atoi (*argv) : 0;
+
+ if (req_nbytes < 0)
+ print_usage ();
+
+ /* Create a socket. */
+ fd = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (fd == -1)
+ {
+ logit ("can't create socket: %s", strerror (errno));
+ exit (1);
+ }
+ srvr_addr = malloc (sizeof *srvr_addr);
+ if (!srvr_addr)
+ {
+ logit ("malloc failed: %s", strerror (errno));
+ exit (1);
+ }
+ memset (srvr_addr, 0, sizeof *srvr_addr);
+ srvr_addr->sun_family = AF_UNIX;
+ if (strlen (socketname) + 1 >= sizeof (srvr_addr->sun_path))
+ {
+ logit ("socket name `%s' too long", socketname);
+ exit (1);
+ }
+ strcpy (srvr_addr->sun_path, socketname);
+ addrlen = (offsetof (struct sockaddr_un, sun_path)
+ + strlen (srvr_addr->sun_path) + 1);
+ rc = connect (fd, (struct sockaddr*) srvr_addr, addrlen);
+ if (rc == -1)
+ {
+ logit ("error connecting socket `%s': %s",
+ srvr_addr->sun_path, strerror (errno));
+ close (fd);
+ exit (1);
+ }
+
+ do
+ {
+ nbytes = req_nbytes > 255? 255 : req_nbytes;
+ req_nbytes -= nbytes;
+
+ buffer[0] = 3;
+ if (do_ping)
+ buffer[1] = 0;
+ else if (get_nonce)
+ buffer[1] = 10;
+ else if (get_very_strong)
+ buffer[1] = 12;
+ else
+ buffer[1] = 11;
+ buffer[2] = nbytes;
+ if (writen (fd, buffer, 3))
+ fail = 1;
+ else
+ {
+ for (nleft=2, nread=0; nleft > 0; )
+ {
+ do
+ n = read (fd, buffer+nread, nleft);
+ while (n < 0 && errno == EINTR);
+ if (n < 0)
+ {
+ logit ("read error: %s", strerror (errno));
+ exit (1);
+ }
+ nleft -= n;
+ nread += n;
+ if (nread && buffer[0])
+ {
+ logit ("server returned error code %d", buffer[0]);
+ exit (1);
+ }
+ }
+ if (verbose)
+ logit ("received response with %d bytes of data", buffer[1]);
+ if (buffer[1] < nbytes)
+ {
+ logit ("warning: server returned less bytes than requested");
+ fail = 1;
+ }
+ else if (buffer[1] > nbytes && !do_ping)
+ {
+ logit ("warning: server returned more bytes than requested");
+ fail = 1;
+ }
+ nbytes = buffer[1];
+ if (nbytes > sizeof buffer)
+ {
+ logit ("buffer too short to receive data");
+ exit (1);
+ }
+
+ for (nleft=nbytes, nread=0; nleft > 0; )
+ {
+ do
+ n = read (fd, buffer+nread, nleft);
+ while (n < 0 && errno == EINTR);
+ if (n < 0)
+ {
+ logit ("read error: %s", strerror (errno));
+ exit (1);
+ }
+ nleft -= n;
+ nread += n;
+ }
+
+ if (do_hex)
+ {
+ for (n=0; n < nbytes; n++)
+ {
+ if (!n)
+ ;
+ else if (!(n % 16))
+ putchar ('\n');
+ else
+ putchar (' ');
+ printf ("%02X", buffer[n]);
+ }
+ if (nbytes)
+ putchar ('\n');
+ }
+ else
+ {
+ if (fwrite (buffer, nbytes, 1, stdout) != 1)
+ {
+ logit ("error writing to stdout: %s", strerror (errno));
+ fail = 1;
+ }
+ }
+ }
+ }
+ while (!fail && req_nbytes);
+
+ close (fd);
+ free (srvr_addr);
+ return fail? 1 : 0;
+}
diff --git a/grub-core/lib/libgcrypt/src/global.c b/grub-core/lib/libgcrypt/src/global.c
new file mode 100644
index 0000000..9b9d531
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/global.c
@@ -0,0 +1,1123 @@
+/* global.c - global control functions
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+ * 2004, 2005, 2006, 2008, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <limits.h>
+#include <errno.h>
+#include <unistd.h>
+#ifdef HAVE_SYSLOG
+# include <syslog.h>
+#endif /*HAVE_SYSLOG*/
+
+#include "g10lib.h"
+#include "cipher.h"
+#include "stdmem.h" /* our own memory allocator */
+#include "secmem.h" /* our own secmem allocator */
+#include "ath.h"
+
+
+
+/****************
+ * flag bits: 0 : general cipher debug
+ * 1 : general MPI debug
+ */
+static unsigned int debug_flags;
+
+/* gcry_control (GCRYCTL_SET_FIPS_MODE), sets this flag so that the
+ initialization code switched fips mode on. */
+static int force_fips_mode;
+
+/* Controlled by global_init(). */
+static int any_init_done;
+
+/* A table to map hardware features to a string. */
+static struct
+{
+ unsigned int flag;
+ const char *desc;
+} hwflist[] =
+ {
+ { HWF_PADLOCK_RNG, "padlock-rng" },
+ { HWF_PADLOCK_AES, "padlock-aes" },
+ { HWF_PADLOCK_SHA, "padlock-sha" },
+ { HWF_PADLOCK_MMUL,"padlock-mmul"},
+ { HWF_INTEL_AESNI, "intel-aesni" },
+ { 0, NULL}
+ };
+
+/* A bit vector with the hardware features which shall not be used.
+ This variable must be set prior to any initialization. */
+static unsigned int disabled_hw_features;
+
+
+/* Memory management. */
+
+static gcry_handler_alloc_t alloc_func;
+static gcry_handler_alloc_t alloc_secure_func;
+static gcry_handler_secure_check_t is_secure_func;
+static gcry_handler_realloc_t realloc_func;
+static gcry_handler_free_t free_func;
+static gcry_handler_no_mem_t outofcore_handler;
+static void *outofcore_handler_value;
+static int no_secure_memory;
+
+
+
+
+
+/* This is our handmade constructor. It gets called by any function
+ likely to be called at startup. The suggested way for an
+ application to make sure that this has been called is by using
+ gcry_check_version. */
+static void
+global_init (void)
+{
+ gcry_error_t err = 0;
+
+ if (any_init_done)
+ return;
+ any_init_done = 1;
+
+ /* Initialize our portable thread/mutex wrapper. */
+ err = ath_init ();
+ if (err)
+ goto fail;
+
+ /* See whether the system is in FIPS mode. This needs to come as
+ early as possible put after the ATH has been initialized. */
+ _gcry_initialize_fips_mode (force_fips_mode);
+
+ /* Before we do any other initialization we need to test available
+ hardware features. */
+ _gcry_detect_hw_features (disabled_hw_features);
+
+ err = _gcry_cipher_init ();
+ if (err)
+ goto fail;
+ err = _gcry_md_init ();
+ if (err)
+ goto fail;
+ err = _gcry_pk_init ();
+ if (err)
+ goto fail;
+#if 0
+ /* Hmmm, as of now ac_init does nothing. */
+ if ( !fips_mode () )
+ {
+ err = _gcry_ac_init ();
+ if (err)
+ goto fail;
+ }
+#endif
+
+ return;
+
+ fail:
+ BUG ();
+}
+
+
+/* This function is called by the macro fips_is_operational and makes
+ sure that the minimal initialization has been done. This is far
+ from a perfect solution and hides problems with an improper
+ initialization but at least in single-threaded mode it should work
+ reliable.
+
+ The reason we need this is that a lot of applications don't use
+ Libgcrypt properly by not running any initialization code at all.
+ They just call a Libgcrypt function and that is all what they want.
+ Now with the FIPS mode, that has the side effect of entering FIPS
+ mode (for security reasons, FIPS mode is the default if no
+ initialization has been done) and bailing out immediately because
+ the FSM is in the wrong state. If we always run the init code,
+ Libgcrypt can test for FIPS mode and at least if not in FIPS mode,
+ it will behave as before. Note that this on-the-fly initialization
+ is only done for the cryptographic functions subject to FIPS mode
+ and thus not all API calls will do such an initialization. */
+int
+_gcry_global_is_operational (void)
+{
+ if (!any_init_done)
+ {
+#ifdef HAVE_SYSLOG
+ syslog (LOG_USER|LOG_WARNING, "Libgcrypt warning: "
+ "missing initialization - please fix the application");
+#endif /*HAVE_SYSLOG*/
+ global_init ();
+ }
+ return _gcry_fips_is_operational ();
+}
+
+
+
+
+/* Version number parsing. */
+
+/* This function parses the first portion of the version number S and
+ stores it in *NUMBER. On success, this function returns a pointer
+ into S starting with the first character, which is not part of the
+ initial number portion; on failure, NULL is returned. */
+static const char*
+parse_version_number( const char *s, int *number )
+{
+ int val = 0;
+
+ if( *s == '0' && isdigit(s[1]) )
+ return NULL; /* leading zeros are not allowed */
+ for ( ; isdigit(*s); s++ ) {
+ val *= 10;
+ val += *s - '0';
+ }
+ *number = val;
+ return val < 0? NULL : s;
+}
+
+/* This function breaks up the complete string-representation of the
+ version number S, which is of the following struture: <major
+ number>.<minor number>.<micro number><patch level>. The major,
+ minor and micro number components will be stored in *MAJOR, *MINOR
+ and *MICRO.
+
+ On success, the last component, the patch level, will be returned;
+ in failure, NULL will be returned. */
+
+static const char *
+parse_version_string( const char *s, int *major, int *minor, int *micro )
+{
+ s = parse_version_number( s, major );
+ if( !s || *s != '.' )
+ return NULL;
+ s++;
+ s = parse_version_number( s, minor );
+ if( !s || *s != '.' )
+ return NULL;
+ s++;
+ s = parse_version_number( s, micro );
+ if( !s )
+ return NULL;
+ return s; /* patchlevel */
+}
+
+/* If REQ_VERSION is non-NULL, check that the version of the library
+ is at minimum the requested one. Returns the string representation
+ of the library version if the condition is satisfied; return NULL
+ if the requested version is newer than that of the library.
+
+ If a NULL is passed to this function, no check is done, but the
+ string representation of the library is simply returned. */
+const char *
+gcry_check_version( const char *req_version )
+{
+ const char *ver = VERSION;
+ int my_major, my_minor, my_micro;
+ int rq_major, rq_minor, rq_micro;
+ const char *my_plvl;
+
+ if (req_version && req_version[0] == 1 && req_version[1] == 1)
+ return _gcry_compat_identification ();
+
+ /* Initialize library. */
+ global_init ();
+
+ if ( !req_version )
+ /* Caller wants our version number. */
+ return ver;
+
+ /* Parse own version number. */
+ my_plvl = parse_version_string( ver, &my_major, &my_minor, &my_micro );
+ if ( !my_plvl )
+ /* very strange our own version is bogus. Shouldn't we use
+ assert() here and bail out in case this happens? -mo. */
+ return NULL;
+
+ /* Parse requested version number. */
+ if (!parse_version_string (req_version, &rq_major, &rq_minor, &rq_micro))
+ return NULL; /* req version string is invalid, this can happen. */
+
+ /* Compare version numbers. */
+ if ( my_major > rq_major
+ || (my_major == rq_major && my_minor > rq_minor)
+ || (my_major == rq_major && my_minor == rq_minor && my_micro > rq_micro)
+ || (my_major == rq_major && my_minor == rq_minor
+ && my_micro == rq_micro))
+ {
+ return ver;
+ }
+
+ return NULL;
+}
+
+
+static void
+print_config ( int (*fnc)(FILE *fp, const char *format, ...), FILE *fp)
+{
+ unsigned int hwf;
+ int i;
+
+ fnc (fp, "version:%s:\n", VERSION);
+ fnc (fp, "ciphers:%s:\n", LIBGCRYPT_CIPHERS);
+ fnc (fp, "pubkeys:%s:\n", LIBGCRYPT_PUBKEY_CIPHERS);
+ fnc (fp, "digests:%s:\n", LIBGCRYPT_DIGESTS);
+ fnc (fp, "rnd-mod:"
+#if USE_RNDEGD
+ "egd:"
+#endif
+#if USE_RNDLINUX
+ "linux:"
+#endif
+#if USE_RNDUNIX
+ "unix:"
+#endif
+#if USE_RNDW32
+ "w32:"
+#endif
+ "\n");
+ fnc (fp, "mpi-asm:%s:\n", _gcry_mpi_get_hw_config ());
+ hwf = _gcry_get_hw_features ();
+ fnc (fp, "hwflist:");
+ for (i=0; hwflist[i].desc; i++)
+ if ( (hwf & hwflist[i].flag) )
+ fnc (fp, "%s:", hwflist[i].desc);
+ fnc (fp, "\n");
+ /* We use y/n instead of 1/0 for the simple reason that Emacsen's
+ compile error parser would accidently flag that line when printed
+ during "make check" as an error. */
+ fnc (fp, "fips-mode:%c:%c:\n",
+ fips_mode ()? 'y':'n',
+ _gcry_enforced_fips_mode ()? 'y':'n' );
+}
+
+
+
+
+/* Command dispatcher function, acting as general control
+ function. */
+gcry_error_t
+_gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr)
+{
+ static int init_finished = 0;
+ gcry_err_code_t err = 0;
+
+ switch (cmd)
+ {
+ case GCRYCTL_ENABLE_M_GUARD:
+ _gcry_private_enable_m_guard ();
+ break;
+
+ case GCRYCTL_ENABLE_QUICK_RANDOM:
+ _gcry_enable_quick_random_gen ();
+ break;
+
+ case GCRYCTL_FAKED_RANDOM_P:
+ /* Return an error if the RNG is faked one (e.g. enabled by
+ ENABLE_QUICK_RANDOM. */
+ if (_gcry_random_is_faked ())
+ err = GPG_ERR_GENERAL; /* Use as TRUE value. */
+ break;
+
+ case GCRYCTL_DUMP_RANDOM_STATS:
+ _gcry_random_dump_stats ();
+ break;
+
+ case GCRYCTL_DUMP_MEMORY_STATS:
+ /*m_print_stats("[fixme: prefix]");*/
+ break;
+
+ case GCRYCTL_DUMP_SECMEM_STATS:
+ _gcry_secmem_dump_stats ();
+ break;
+
+ case GCRYCTL_DROP_PRIVS:
+ global_init ();
+ _gcry_secmem_init (0);
+ break;
+
+ case GCRYCTL_DISABLE_SECMEM:
+ global_init ();
+ no_secure_memory = 1;
+ break;
+
+ case GCRYCTL_INIT_SECMEM:
+ global_init ();
+ _gcry_secmem_init (va_arg (arg_ptr, unsigned int));
+ if ((_gcry_secmem_get_flags () & GCRY_SECMEM_FLAG_NOT_LOCKED))
+ err = GPG_ERR_GENERAL;
+ break;
+
+ case GCRYCTL_TERM_SECMEM:
+ global_init ();
+ _gcry_secmem_term ();
+ break;
+
+ case GCRYCTL_DISABLE_SECMEM_WARN:
+ _gcry_secmem_set_flags ((_gcry_secmem_get_flags ()
+ | GCRY_SECMEM_FLAG_NO_WARNING));
+ break;
+
+ case GCRYCTL_SUSPEND_SECMEM_WARN:
+ _gcry_secmem_set_flags ((_gcry_secmem_get_flags ()
+ | GCRY_SECMEM_FLAG_SUSPEND_WARNING));
+ break;
+
+ case GCRYCTL_RESUME_SECMEM_WARN:
+ _gcry_secmem_set_flags ((_gcry_secmem_get_flags ()
+ & ~GCRY_SECMEM_FLAG_SUSPEND_WARNING));
+ break;
+
+ case GCRYCTL_USE_SECURE_RNDPOOL:
+ global_init ();
+ _gcry_secure_random_alloc (); /* Put random number into secure memory. */
+ break;
+
+ case GCRYCTL_SET_RANDOM_SEED_FILE:
+ _gcry_set_random_seed_file (va_arg (arg_ptr, const char *));
+ break;
+
+ case GCRYCTL_UPDATE_RANDOM_SEED_FILE:
+ if ( fips_is_operational () )
+ _gcry_update_random_seed_file ();
+ break;
+
+ case GCRYCTL_SET_VERBOSITY:
+ _gcry_set_log_verbosity (va_arg (arg_ptr, int));
+ break;
+
+ case GCRYCTL_SET_DEBUG_FLAGS:
+ debug_flags |= va_arg (arg_ptr, unsigned int);
+ break;
+
+ case GCRYCTL_CLEAR_DEBUG_FLAGS:
+ debug_flags &= ~va_arg (arg_ptr, unsigned int);
+ break;
+
+ case GCRYCTL_DISABLE_INTERNAL_LOCKING:
+ /* Not used anymore. */
+ global_init ();
+ break;
+
+ case GCRYCTL_ANY_INITIALIZATION_P:
+ if (any_init_done)
+ err = GPG_ERR_GENERAL;
+ break;
+
+ case GCRYCTL_INITIALIZATION_FINISHED_P:
+ if (init_finished)
+ err = GPG_ERR_GENERAL; /* Yes. */
+ break;
+
+ case GCRYCTL_INITIALIZATION_FINISHED:
+ /* This is a hook which should be used by an application after
+ all initialization has been done and right before any threads
+ are started. It is not really needed but the only way to be
+ really sure that all initialization for thread-safety has
+ been done. */
+ if (! init_finished)
+ {
+ global_init ();
+ /* Do only a basic random initialization, i.e. init the
+ mutexes. */
+ _gcry_random_initialize (0);
+ init_finished = 1;
+ /* Force us into operational state if in FIPS mode. */
+ (void)fips_is_operational ();
+ }
+ break;
+
+ case GCRYCTL_SET_THREAD_CBS:
+ err = ath_install (va_arg (arg_ptr, void *), any_init_done);
+ if (! err)
+ global_init ();
+ break;
+
+ case GCRYCTL_FAST_POLL:
+ /* We need to do make sure that the random pool is really
+ initialized so that the poll function is not a NOP. */
+ _gcry_random_initialize (1);
+
+ if ( fips_is_operational () )
+ _gcry_fast_random_poll ();
+ break;
+
+ case GCRYCTL_SET_RNDEGD_SOCKET:
+#if USE_RNDEGD
+ err = _gcry_rndegd_set_socket_name (va_arg (arg_ptr, const char *));
+#else
+ err = gpg_error (GPG_ERR_NOT_SUPPORTED);
+#endif
+ break;
+
+ case GCRYCTL_SET_RANDOM_DAEMON_SOCKET:
+ _gcry_set_random_daemon_socket (va_arg (arg_ptr, const char *));
+ break;
+
+ case GCRYCTL_USE_RANDOM_DAEMON:
+ /* We need to do make sure that the random pool is really
+ initialized so that the poll function is not a NOP. */
+ _gcry_random_initialize (1);
+ _gcry_use_random_daemon (!! va_arg (arg_ptr, int));
+ break;
+
+ /* This command dumps information pertaining to the
+ configuration of libgcrypt to the given stream. It may be
+ used before the initialization has been finished but not
+ before a gcry_version_check. */
+ case GCRYCTL_PRINT_CONFIG:
+ {
+ FILE *fp = va_arg (arg_ptr, FILE *);
+ print_config (fp?fprintf:_gcry_log_info_with_dummy_fp, fp);
+ }
+ break;
+
+ case GCRYCTL_OPERATIONAL_P:
+ /* Returns true if the library is in an operational state. This
+ is always true for non-fips mode. */
+ if (_gcry_fips_test_operational ())
+ err = GPG_ERR_GENERAL; /* Used as TRUE value */
+ break;
+
+ case GCRYCTL_FIPS_MODE_P:
+ if (fips_mode ()
+ && !_gcry_is_fips_mode_inactive ()
+ && !no_secure_memory)
+ err = GPG_ERR_GENERAL; /* Used as TRUE value */
+ break;
+
+ case GCRYCTL_FORCE_FIPS_MODE:
+ /* Performing this command puts the library into fips mode. If
+ the library has already been initialized into fips mode, a
+ selftest is triggered. It is not possible to put the libraty
+ into fips mode after having passed the initialization. */
+ if (!any_init_done)
+ {
+ /* Not yet intialized at all. Set a flag so that we are put
+ into fips mode during initialization. */
+ force_fips_mode = 1;
+ }
+ else
+ {
+ /* Already initialized. If we are already operational we
+ run a selftest. If not we use the is_operational call to
+ force us into operational state if possible. */
+ if (_gcry_fips_test_error_or_operational ())
+ _gcry_fips_run_selftests (1);
+ if (_gcry_fips_is_operational ())
+ err = GPG_ERR_GENERAL; /* Used as TRUE value */
+ }
+ break;
+
+ case GCRYCTL_SELFTEST:
+ /* Run a selftest. This works in fips mode as well as in
+ standard mode. In contrast to the power-up tests, we use an
+ extended version of the selftests. Returns 0 on success or an
+ error code. */
+ global_init ();
+ err = _gcry_fips_run_selftests (1);
+ break;
+
+#if _GCRY_GCC_VERSION >= 40600
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wswitch"
+#endif
+ case 58: /* Init external random test. */
+ {
+ void **rctx = va_arg (arg_ptr, void **);
+ unsigned int flags = va_arg (arg_ptr, unsigned int);
+ const void *key = va_arg (arg_ptr, const void *);
+ size_t keylen = va_arg (arg_ptr, size_t);
+ const void *seed = va_arg (arg_ptr, const void *);
+ size_t seedlen = va_arg (arg_ptr, size_t);
+ const void *dt = va_arg (arg_ptr, const void *);
+ size_t dtlen = va_arg (arg_ptr, size_t);
+ if (!fips_is_operational ())
+ err = fips_not_operational ();
+ else
+ err = _gcry_random_init_external_test (rctx, flags, key, keylen,
+ seed, seedlen, dt, dtlen);
+ }
+ break;
+ case 59: /* Run external random test. */
+ {
+ void *ctx = va_arg (arg_ptr, void *);
+ void *buffer = va_arg (arg_ptr, void *);
+ size_t buflen = va_arg (arg_ptr, size_t);
+ if (!fips_is_operational ())
+ err = fips_not_operational ();
+ else
+ err = _gcry_random_run_external_test (ctx, buffer, buflen);
+ }
+ break;
+ case 60: /* Deinit external random test. */
+ {
+ void *ctx = va_arg (arg_ptr, void *);
+ _gcry_random_deinit_external_test (ctx);
+ }
+ break;
+ case 61: /* RFU */
+ break;
+ case 62: /* RFU */
+ break;
+#if _GCRY_GCC_VERSION >= 40600
+# pragma GCC diagnostic pop
+#endif
+
+ case GCRYCTL_DISABLE_HWF:
+ {
+ const char *name = va_arg (arg_ptr, const char *);
+ int i;
+
+ for (i=0; hwflist[i].desc; i++)
+ if (!strcmp (hwflist[i].desc, name))
+ {
+ disabled_hw_features |= hwflist[i].flag;
+ break;
+ }
+ if (!hwflist[i].desc)
+ err = GPG_ERR_INV_NAME;
+ }
+ break;
+
+ case GCRYCTL_SET_ENFORCED_FIPS_FLAG:
+ if (!any_init_done)
+ {
+ /* Not yet intialized at all. Set the enforced fips mode flag */
+ _gcry_set_enforced_fips_mode ();
+ }
+ else
+ err = GPG_ERR_GENERAL;
+ break;
+
+ default:
+ err = GPG_ERR_INV_OP;
+ }
+
+ return gcry_error (err);
+}
+
+
+/* Command dispatcher function, acting as general control
+ function. */
+gcry_error_t
+gcry_control (enum gcry_ctl_cmds cmd, ...)
+{
+ gcry_error_t err;
+ va_list arg_ptr;
+
+ va_start (arg_ptr, cmd);
+ err = _gcry_vcontrol (cmd, arg_ptr);
+ va_end(arg_ptr);
+ return err;
+}
+
+
+
+/* Return a pointer to a string containing a description of the error
+ code in the error value ERR. */
+const char *
+gcry_strerror (gcry_error_t err)
+{
+ return gpg_strerror (err);
+}
+
+/* Return a pointer to a string containing a description of the error
+ source in the error value ERR. */
+const char *
+gcry_strsource (gcry_error_t err)
+{
+ return gpg_strsource (err);
+}
+
+/* Retrieve the error code for the system error ERR. This returns
+ GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
+ this). */
+gcry_err_code_t
+gcry_err_code_from_errno (int err)
+{
+ return gpg_err_code_from_errno (err);
+}
+
+
+/* Retrieve the system error for the error code CODE. This returns 0
+ if CODE is not a system error code. */
+int
+gcry_err_code_to_errno (gcry_err_code_t code)
+{
+ return gpg_err_code_from_errno (code);
+}
+
+
+/* Return an error value with the error source SOURCE and the system
+ error ERR. */
+gcry_error_t
+gcry_err_make_from_errno (gpg_err_source_t source, int err)
+{
+ return gpg_err_make_from_errno (source, err);
+}
+
+
+/* Return an error value with the system error ERR. */
+gcry_err_code_t
+gcry_error_from_errno (int err)
+{
+ return gcry_error (gpg_err_code_from_errno (err));
+}
+
+
+/* Set custom allocation handlers. This is in general not useful
+ * because the libgcrypt allocation functions are guaranteed to
+ * provide proper allocation handlers which zeroize memory if needed.
+ * NOTE: All 5 functions should be set. */
+void
+gcry_set_allocation_handler (gcry_handler_alloc_t new_alloc_func,
+ gcry_handler_alloc_t new_alloc_secure_func,
+ gcry_handler_secure_check_t new_is_secure_func,
+ gcry_handler_realloc_t new_realloc_func,
+ gcry_handler_free_t new_free_func)
+{
+ global_init ();
+
+ if (fips_mode ())
+ {
+ /* We do not want to enforce the fips mode, but merely set a
+ flag so that the application may check whether it is still in
+ fips mode. */
+ _gcry_inactivate_fips_mode ("custom allocation handler");
+ }
+
+ alloc_func = new_alloc_func;
+ alloc_secure_func = new_alloc_secure_func;
+ is_secure_func = new_is_secure_func;
+ realloc_func = new_realloc_func;
+ free_func = new_free_func;
+}
+
+
+
+/****************
+ * Set an optional handler which is called in case the xmalloc functions
+ * ran out of memory. This handler may do one of these things:
+ * o free some memory and return true, so that the xmalloc function
+ * tries again.
+ * o Do whatever it like and return false, so that the xmalloc functions
+ * use the default fatal error handler.
+ * o Terminate the program and don't return.
+ *
+ * The handler function is called with 3 arguments: The opaque value set with
+ * this function, the requested memory size, and a flag with these bits
+ * currently defined:
+ * bit 0 set = secure memory has been requested.
+ */
+void
+gcry_set_outofcore_handler( int (*f)( void*, size_t, unsigned int ),
+ void *value )
+{
+ global_init ();
+
+ if (fips_mode () )
+ {
+ log_info ("out of core handler ignored in FIPS mode\n");
+ return;
+ }
+
+ outofcore_handler = f;
+ outofcore_handler_value = value;
+}
+
+/* Return the no_secure_memory flag. */
+static int
+get_no_secure_memory (void)
+{
+ if (!no_secure_memory)
+ return 0;
+ if (_gcry_enforced_fips_mode ())
+ {
+ no_secure_memory = 0;
+ return 0;
+ }
+ return no_secure_memory;
+}
+
+
+static gcry_err_code_t
+do_malloc (size_t n, unsigned int flags, void **mem)
+{
+ gcry_err_code_t err = 0;
+ void *m;
+
+ if ((flags & GCRY_ALLOC_FLAG_SECURE) && !get_no_secure_memory ())
+ {
+ if (alloc_secure_func)
+ m = (*alloc_secure_func) (n);
+ else
+ m = _gcry_private_malloc_secure (n);
+ }
+ else
+ {
+ if (alloc_func)
+ m = (*alloc_func) (n);
+ else
+ m = _gcry_private_malloc (n);
+ }
+
+ if (!m)
+ {
+ /* Make sure that ERRNO has been set in case a user supplied
+ memory handler didn't it correctly. */
+ if (!errno)
+ gpg_err_set_errno (ENOMEM);
+ err = gpg_err_code_from_errno (errno);
+ }
+ else
+ *mem = m;
+
+ return err;
+}
+
+void *
+gcry_malloc (size_t n)
+{
+ void *mem = NULL;
+
+ do_malloc (n, 0, &mem);
+
+ return mem;
+}
+
+void *
+gcry_malloc_secure (size_t n)
+{
+ void *mem = NULL;
+
+ do_malloc (n, GCRY_ALLOC_FLAG_SECURE, &mem);
+
+ return mem;
+}
+
+int
+gcry_is_secure (const void *a)
+{
+ if (get_no_secure_memory ())
+ return 0;
+ if (is_secure_func)
+ return is_secure_func (a) ;
+ return _gcry_private_is_secure (a);
+}
+
+void
+_gcry_check_heap( const void *a )
+{
+ (void)a;
+
+ /* FIXME: implement this*/
+#if 0
+ if( some_handler )
+ some_handler(a)
+ else
+ _gcry_private_check_heap(a)
+#endif
+}
+
+void *
+gcry_realloc (void *a, size_t n)
+{
+ void *p;
+
+ /* To avoid problems with non-standard realloc implementations and
+ our own secmem_realloc, we divert to malloc and free here. */
+ if (!a)
+ return gcry_malloc (n);
+ if (!n)
+ {
+ gcry_free (a);
+ return NULL;
+ }
+
+ if (realloc_func)
+ p = realloc_func (a, n);
+ else
+ p = _gcry_private_realloc (a, n);
+ if (!p && !errno)
+ gpg_err_set_errno (ENOMEM);
+ return p;
+}
+
+void
+gcry_free (void *p)
+{
+ int save_errno;
+
+ if (!p)
+ return;
+
+ /* In case ERRNO is set we better save it so that the free machinery
+ may not accidently change ERRNO. We restore it only if it was
+ already set to comply with the usual C semantic for ERRNO. */
+ save_errno = errno;
+ if (free_func)
+ free_func (p);
+ else
+ _gcry_private_free (p);
+
+ if (save_errno)
+ gpg_err_set_errno (save_errno);
+}
+
+void *
+gcry_calloc (size_t n, size_t m)
+{
+ size_t bytes;
+ void *p;
+
+ bytes = n * m; /* size_t is unsigned so the behavior on overflow is
+ defined. */
+ if (m && bytes / m != n)
+ {
+ gpg_err_set_errno (ENOMEM);
+ return NULL;
+ }
+
+ p = gcry_malloc (bytes);
+ if (p)
+ memset (p, 0, bytes);
+ return p;
+}
+
+void *
+gcry_calloc_secure (size_t n, size_t m)
+{
+ size_t bytes;
+ void *p;
+
+ bytes = n * m; /* size_t is unsigned so the behavior on overflow is
+ defined. */
+ if (m && bytes / m != n)
+ {
+ gpg_err_set_errno (ENOMEM);
+ return NULL;
+ }
+
+ p = gcry_malloc_secure (bytes);
+ if (p)
+ memset (p, 0, bytes);
+ return p;
+}
+
+
+/* Create and return a copy of the null-terminated string STRING. If
+ it is contained in secure memory, the copy will be contained in
+ secure memory as well. In an out-of-memory condition, NULL is
+ returned. */
+char *
+gcry_strdup (const char *string)
+{
+ char *string_cp = NULL;
+ size_t string_n = 0;
+
+ string_n = strlen (string);
+
+ if (gcry_is_secure (string))
+ string_cp = gcry_malloc_secure (string_n + 1);
+ else
+ string_cp = gcry_malloc (string_n + 1);
+
+ if (string_cp)
+ strcpy (string_cp, string);
+
+ return string_cp;
+}
+
+
+void *
+gcry_xmalloc( size_t n )
+{
+ void *p;
+
+ while ( !(p = gcry_malloc( n )) )
+ {
+ if ( fips_mode ()
+ || !outofcore_handler
+ || !outofcore_handler (outofcore_handler_value, n, 0) )
+ {
+ _gcry_fatal_error (gpg_err_code_from_errno (errno), NULL);
+ }
+ }
+ return p;
+}
+
+void *
+gcry_xrealloc( void *a, size_t n )
+{
+ void *p;
+
+ while ( !(p = gcry_realloc( a, n )) )
+ {
+ if ( fips_mode ()
+ || !outofcore_handler
+ || !outofcore_handler (outofcore_handler_value, n,
+ gcry_is_secure(a)? 3:2 ) )
+ {
+ _gcry_fatal_error (gpg_err_code_from_errno (errno), NULL );
+ }
+ }
+ return p;
+}
+
+void *
+gcry_xmalloc_secure( size_t n )
+{
+ void *p;
+
+ while ( !(p = gcry_malloc_secure( n )) )
+ {
+ if ( fips_mode ()
+ || !outofcore_handler
+ || !outofcore_handler (outofcore_handler_value, n, 1) )
+ {
+ _gcry_fatal_error (gpg_err_code_from_errno (errno),
+ _("out of core in secure memory"));
+ }
+ }
+ return p;
+}
+
+
+void *
+gcry_xcalloc( size_t n, size_t m )
+{
+ size_t nbytes;
+ void *p;
+
+ nbytes = n * m;
+ if (m && nbytes / m != n)
+ {
+ gpg_err_set_errno (ENOMEM);
+ _gcry_fatal_error(gpg_err_code_from_errno (errno), NULL );
+ }
+
+ p = gcry_xmalloc ( nbytes );
+ memset ( p, 0, nbytes );
+ return p;
+}
+
+void *
+gcry_xcalloc_secure( size_t n, size_t m )
+{
+ size_t nbytes;
+ void *p;
+
+ nbytes = n * m;
+ if (m && nbytes / m != n)
+ {
+ gpg_err_set_errno (ENOMEM);
+ _gcry_fatal_error(gpg_err_code_from_errno (errno), NULL );
+ }
+
+ p = gcry_xmalloc_secure ( nbytes );
+ memset ( p, 0, nbytes );
+ return p;
+}
+
+char *
+gcry_xstrdup (const char *string)
+{
+ char *p;
+
+ while ( !(p = gcry_strdup (string)) )
+ {
+ size_t n = strlen (string);
+ int is_sec = !!gcry_is_secure (string);
+
+ if (fips_mode ()
+ || !outofcore_handler
+ || !outofcore_handler (outofcore_handler_value, n, is_sec) )
+ {
+ _gcry_fatal_error (gpg_err_code_from_errno (errno),
+ is_sec? _("out of core in secure memory"):NULL);
+ }
+ }
+
+ return p;
+}
+
+
+int
+_gcry_get_debug_flag (unsigned int mask)
+{
+ if ( fips_mode () )
+ return 0;
+ return (debug_flags & mask);
+}
+
+
+
+/* It is often useful to get some feedback of long running operations.
+ This function may be used to register a handler for this.
+ The callback function CB is used as:
+
+ void cb (void *opaque, const char *what, int printchar,
+ int current, int total);
+
+ Where WHAT is a string identifying the the type of the progress
+ output, PRINTCHAR the character usually printed, CURRENT the amount
+ of progress currently done and TOTAL the expected amount of
+ progress. A value of 0 for TOTAL indicates that there is no
+ estimation available.
+
+ Defined values for WHAT:
+
+ "need_entropy" X 0 number-of-bytes-required
+ When running low on entropy
+ "primegen" '\n' 0 0
+ Prime generated
+ '!'
+ Need to refresh the prime pool
+ '<','>'
+ Number of bits adjusted
+ '^'
+ Looking for a generator
+ '.'
+ Fermat tests on 10 candidates failed
+ ':'
+ Restart with a new random value
+ '+'
+ Rabin Miller test passed
+ "pk_elg" '+','-','.','\n' 0 0
+ Only used in debugging mode.
+ "pk_dsa"
+ Only used in debugging mode.
+*/
+void
+gcry_set_progress_handler (void (*cb)(void *,const char*,int, int, int),
+ void *cb_data)
+{
+#if USE_DSA
+ _gcry_register_pk_dsa_progress (cb, cb_data);
+#endif
+#if USE_ELGAMAL
+ _gcry_register_pk_elg_progress (cb, cb_data);
+#endif
+ _gcry_register_primegen_progress (cb, cb_data);
+ _gcry_register_random_progress (cb, cb_data);
+}
diff --git a/grub-core/lib/libgcrypt/src/hmac256.c b/grub-core/lib/libgcrypt/src/hmac256.c
new file mode 100644
index 0000000..f3bc092
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/hmac256.c
@@ -0,0 +1,793 @@
+/* hmac256.c - Standalone HMAC implementation
+ * Copyright (C) 2003, 2006, 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ This is a standalone HMAC-SHA-256 implementation based on the code
+ from ../cipher/sha256.c. It is a second implementation to allow
+ comparing against the standard implementations and to be used for
+ internal consistency checks. It should not be used for sensitive
+ data because no mechanisms to clear the stack etc are used.
+
+ This module may be used standalone and requires only a few
+ standard definitions to be provided in a config.h file.
+
+ Types:
+
+ u32 - unsigned 32 bit type.
+
+ Constants:
+
+ WORDS_BIGENDIAN Defined to 1 on big endian systems.
+ inline If defined, it should yield the keyword used
+ to inline a function.
+ HAVE_U32_TYPEDEF Defined if the u32 type is available.
+ SIZEOF_UNSIGNED_INT Defined to the size in bytes of an unsigned int.
+ SIZEOF_UNSIGNED_LONG Defined to the size in bytes of an unsigned long.
+
+ STANDALONE Compile a test driver similar to the
+ sha1sum tool. This driver uses a self-test
+ identically to the one used by Libcgrypt
+ for testing this included module.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+#if defined(__WIN32) && defined(STANDALONE)
+# include <fcntl.h> /* We need setmode(). */
+#endif
+
+/* For a native WindowsCE binary we need to include gpg-error.h to
+ provide a replacement for strerror. In other cases we need a
+ replacement macro for gpg_err_set_errno. */
+#ifdef __MINGW32CE__
+# include <gpg-error.h>
+#else
+# define gpg_err_set_errno(a) (errno = (a))
+#endif
+
+#include "hmac256.h"
+
+
+
+#ifndef HAVE_U32_TYPEDEF
+# undef u32 /* Undef a possible macro with that name. */
+# if SIZEOF_UNSIGNED_INT == 4
+ typedef unsigned int u32;
+# elif SIZEOF_UNSIGNED_LONG == 4
+ typedef unsigned long u32;
+# else
+# error no typedef for u32
+# endif
+# define HAVE_U32_TYPEDEF
+#endif
+
+
+
+
+/* The context used by this module. */
+struct hmac256_context
+{
+ u32 h0, h1, h2, h3, h4, h5, h6, h7;
+ u32 nblocks;
+ int count;
+ int finalized:1;
+ int use_hmac:1;
+ unsigned char buf[64];
+ unsigned char opad[64];
+};
+
+
+/* Rotate a 32 bit word. */
+#if defined(__GNUC__) && defined(__i386__)
+static inline u32
+ror(u32 x, int n)
+{
+ __asm__("rorl %%cl,%0"
+ :"=r" (x)
+ :"0" (x),"c" (n));
+ return x;
+}
+#else
+#define ror(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) )
+#endif
+
+#define my_wipememory2(_ptr,_set,_len) do { \
+ volatile char *_vptr=(volatile char *)(_ptr); \
+ size_t _vlen=(_len); \
+ while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
+ } while(0)
+#define my_wipememory(_ptr,_len) my_wipememory2(_ptr,0,_len)
+
+
+
+
+/*
+ The SHA-256 core: Transform the message X which consists of 16
+ 32-bit-words. See FIPS 180-2 for details.
+ */
+static void
+transform (hmac256_context_t hd, const void *data_arg)
+{
+ const unsigned char *data = data_arg;
+
+#define Cho(x,y,z) (z ^ (x & (y ^ z))) /* (4.2) same as SHA-1's F1 */
+#define Maj(x,y,z) ((x & y) | (z & (x|y))) /* (4.3) same as SHA-1's F3 */
+#define Sum0(x) (ror ((x), 2) ^ ror ((x), 13) ^ ror ((x), 22)) /* (4.4) */
+#define Sum1(x) (ror ((x), 6) ^ ror ((x), 11) ^ ror ((x), 25)) /* (4.5) */
+#define S0(x) (ror ((x), 7) ^ ror ((x), 18) ^ ((x) >> 3)) /* (4.6) */
+#define S1(x) (ror ((x), 17) ^ ror ((x), 19) ^ ((x) >> 10)) /* (4.7) */
+#define R(a,b,c,d,e,f,g,h,k,w) do \
+ { \
+ t1 = (h) + Sum1((e)) + Cho((e),(f),(g)) + (k) + (w); \
+ t2 = Sum0((a)) + Maj((a),(b),(c)); \
+ h = g; \
+ g = f; \
+ f = e; \
+ e = d + t1; \
+ d = c; \
+ c = b; \
+ b = a; \
+ a = t1 + t2; \
+ } while (0)
+
+ static const u32 K[64] =
+ {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+ };
+
+ u32 a, b, c, d, e, f, g, h, t1, t2;
+ u32 x[16];
+ u32 w[64];
+ int i;
+
+ a = hd->h0;
+ b = hd->h1;
+ c = hd->h2;
+ d = hd->h3;
+ e = hd->h4;
+ f = hd->h5;
+ g = hd->h6;
+ h = hd->h7;
+
+#ifdef WORDS_BIGENDIAN
+ memcpy (x, data, 64);
+#else /*!WORDS_BIGENDIAN*/
+ {
+ unsigned char *p2;
+
+ for (i=0, p2=(unsigned char*)x; i < 16; i++, p2 += 4 )
+ {
+ p2[3] = *data++;
+ p2[2] = *data++;
+ p2[1] = *data++;
+ p2[0] = *data++;
+ }
+ }
+#endif /*!WORDS_BIGENDIAN*/
+
+ for (i=0; i < 16; i++)
+ w[i] = x[i];
+ for (; i < 64; i++)
+ w[i] = S1(w[i-2]) + w[i-7] + S0(w[i-15]) + w[i-16];
+
+ for (i=0; i < 64; i++)
+ R(a,b,c,d,e,f,g,h,K[i],w[i]);
+
+ hd->h0 += a;
+ hd->h1 += b;
+ hd->h2 += c;
+ hd->h3 += d;
+ hd->h4 += e;
+ hd->h5 += f;
+ hd->h6 += g;
+ hd->h7 += h;
+}
+#undef Cho
+#undef Maj
+#undef Sum0
+#undef Sum1
+#undef S0
+#undef S1
+#undef R
+
+
+/* Finalize the current SHA256 calculation. */
+static void
+finalize (hmac256_context_t hd)
+{
+ u32 t, msb, lsb;
+ unsigned char *p;
+
+ if (hd->finalized)
+ return; /* Silently ignore a finalized context. */
+
+ _gcry_hmac256_update (hd, NULL, 0); /* Flush. */
+
+ t = hd->nblocks;
+ /* Multiply by 64 to make a byte count. */
+ lsb = t << 6;
+ msb = t >> 26;
+ /* Add the count. */
+ t = lsb;
+ if ((lsb += hd->count) < t)
+ msb++;
+ /* Multiply by 8 to make a bit count. */
+ t = lsb;
+ lsb <<= 3;
+ msb <<= 3;
+ msb |= t >> 29;
+
+ if (hd->count < 56)
+ { /* Enough room. */
+ hd->buf[hd->count++] = 0x80; /* pad */
+ while (hd->count < 56)
+ hd->buf[hd->count++] = 0; /* pad */
+ }
+ else
+ { /* Need one extra block. */
+ hd->buf[hd->count++] = 0x80; /* pad character */
+ while (hd->count < 64)
+ hd->buf[hd->count++] = 0;
+ _gcry_hmac256_update (hd, NULL, 0); /* Flush. */;
+ memset (hd->buf, 0, 56 ); /* Zero out next next block. */
+ }
+ /* Append the 64 bit count. */
+ hd->buf[56] = msb >> 24;
+ hd->buf[57] = msb >> 16;
+ hd->buf[58] = msb >> 8;
+ hd->buf[59] = msb;
+ hd->buf[60] = lsb >> 24;
+ hd->buf[61] = lsb >> 16;
+ hd->buf[62] = lsb >> 8;
+ hd->buf[63] = lsb;
+ transform (hd, hd->buf);
+
+ /* Store the digest into hd->buf. */
+ p = hd->buf;
+#define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \
+ *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0)
+ X(0);
+ X(1);
+ X(2);
+ X(3);
+ X(4);
+ X(5);
+ X(6);
+ X(7);
+#undef X
+ hd->finalized = 1;
+}
+
+
+
+/* Create a new context. On error NULL is returned and errno is set
+ appropriately. If KEY is given the function computes HMAC using
+ this key; with KEY given as NULL, a plain SHA-256 digest is
+ computed. */
+hmac256_context_t
+_gcry_hmac256_new (const void *key, size_t keylen)
+{
+ hmac256_context_t hd;
+
+ hd = malloc (sizeof *hd);
+ if (!hd)
+ return NULL;
+
+ hd->h0 = 0x6a09e667;
+ hd->h1 = 0xbb67ae85;
+ hd->h2 = 0x3c6ef372;
+ hd->h3 = 0xa54ff53a;
+ hd->h4 = 0x510e527f;
+ hd->h5 = 0x9b05688c;
+ hd->h6 = 0x1f83d9ab;
+ hd->h7 = 0x5be0cd19;
+ hd->nblocks = 0;
+ hd->count = 0;
+ hd->finalized = 0;
+ hd->use_hmac = 0;
+
+ if (key)
+ {
+ int i;
+ unsigned char ipad[64];
+
+ memset (ipad, 0, 64);
+ memset (hd->opad, 0, 64);
+ if (keylen <= 64)
+ {
+ memcpy (ipad, key, keylen);
+ memcpy (hd->opad, key, keylen);
+ }
+ else
+ {
+ hmac256_context_t tmphd;
+
+ tmphd = _gcry_hmac256_new (NULL, 0);
+ if (!tmphd)
+ {
+ free (hd);
+ return NULL;
+ }
+ _gcry_hmac256_update (tmphd, key, keylen);
+ finalize (tmphd);
+ memcpy (ipad, tmphd->buf, 32);
+ memcpy (hd->opad, tmphd->buf, 32);
+ _gcry_hmac256_release (tmphd);
+ }
+ for (i=0; i < 64; i++)
+ {
+ ipad[i] ^= 0x36;
+ hd->opad[i] ^= 0x5c;
+ }
+ hd->use_hmac = 1;
+ _gcry_hmac256_update (hd, ipad, 64);
+ my_wipememory (ipad, 64);
+ }
+
+ return hd;
+}
+
+/* Release a context created by _gcry_hmac256_new. CTX may be NULL
+ in which case the function does nothing. */
+void
+_gcry_hmac256_release (hmac256_context_t ctx)
+{
+ if (ctx)
+ {
+ /* Note: We need to take care not to modify errno. */
+ if (ctx->use_hmac)
+ my_wipememory (ctx->opad, 64);
+ free (ctx);
+ }
+}
+
+
+/* Update the message digest with the contents of BUFFER containing
+ LENGTH bytes. */
+void
+_gcry_hmac256_update (hmac256_context_t hd,
+ const void *buffer, size_t length)
+{
+ const unsigned char *inbuf = buffer;
+
+ if (hd->finalized)
+ return; /* Silently ignore a finalized context. */
+
+ if (hd->count == 64)
+ {
+ /* Flush the buffer. */
+ transform (hd, hd->buf);
+ hd->count = 0;
+ hd->nblocks++;
+ }
+ if (!inbuf)
+ return; /* Only flushing was requested. */
+ if (hd->count)
+ {
+ for (; length && hd->count < 64; length--)
+ hd->buf[hd->count++] = *inbuf++;
+ _gcry_hmac256_update (hd, NULL, 0); /* Flush. */
+ if (!length)
+ return;
+ }
+
+
+ while (length >= 64)
+ {
+ transform (hd, inbuf);
+ hd->count = 0;
+ hd->nblocks++;
+ length -= 64;
+ inbuf += 64;
+ }
+ for (; length && hd->count < 64; length--)
+ hd->buf[hd->count++] = *inbuf++;
+}
+
+
+/* Finalize an operation and return the digest. If R_DLEN is not NULL
+ the length of the digest will be stored at that address. The
+ returned value is valid as long as the context exists. On error
+ NULL is returned. */
+const void *
+_gcry_hmac256_finalize (hmac256_context_t hd, size_t *r_dlen)
+{
+ finalize (hd);
+ if (hd->use_hmac)
+ {
+ hmac256_context_t tmphd;
+
+ tmphd = _gcry_hmac256_new (NULL, 0);
+ if (!tmphd)
+ {
+ free (hd);
+ return NULL;
+ }
+ _gcry_hmac256_update (tmphd, hd->opad, 64);
+ _gcry_hmac256_update (tmphd, hd->buf, 32);
+ finalize (tmphd);
+ memcpy (hd->buf, tmphd->buf, 32);
+ _gcry_hmac256_release (tmphd);
+ }
+ if (r_dlen)
+ *r_dlen = 32;
+ return (void*)hd->buf;
+}
+
+
+/* Convenience function to compute the HMAC-SHA256 of one file. The
+ user needs to provide a buffer RESULT of at least 32 bytes, he
+ needs to put the size of the buffer into RESULTSIZE and the
+ FILENAME. KEY and KEYLEN are as described for _gcry_hmac256_new.
+ On success the function returns the valid length of the result
+ buffer (which will be 32) or -1 on error. On error ERRNO is set
+ appropriate. */
+int
+_gcry_hmac256_file (void *result, size_t resultsize, const char *filename,
+ const void *key, size_t keylen)
+{
+ FILE *fp;
+ hmac256_context_t hd;
+ size_t buffer_size, nread, digestlen;
+ char *buffer;
+ const unsigned char *digest;
+
+ fp = fopen (filename, "rb");
+ if (!fp)
+ return -1;
+
+ hd = _gcry_hmac256_new (key, keylen);
+ if (!hd)
+ {
+ fclose (fp);
+ return -1;
+ }
+
+ buffer_size = 32768;
+ buffer = malloc (buffer_size);
+ if (!buffer)
+ {
+ fclose (fp);
+ _gcry_hmac256_release (hd);
+ return -1;
+ }
+
+ while ( (nread = fread (buffer, 1, buffer_size, fp)))
+ _gcry_hmac256_update (hd, buffer, nread);
+
+ free (buffer);
+
+ if (ferror (fp))
+ {
+ fclose (fp);
+ _gcry_hmac256_release (hd);
+ return -1;
+ }
+
+ fclose (fp);
+
+ digest = _gcry_hmac256_finalize (hd, &digestlen);
+ if (!digest)
+ {
+ _gcry_hmac256_release (hd);
+ return -1;
+ }
+
+ if (digestlen > resultsize)
+ {
+ _gcry_hmac256_release (hd);
+ gpg_err_set_errno (EINVAL);
+ return -1;
+ }
+ memcpy (result, digest, digestlen);
+ _gcry_hmac256_release (hd);
+
+ return digestlen;
+}
+
+
+
+#ifdef STANDALONE
+static int
+selftest (void)
+{
+ static struct
+ {
+ const char * const desc;
+ const char * const data;
+ const char * const key;
+ const unsigned char expect[32];
+ } tv[] =
+ {
+ { "data-28 key-4",
+ "what do ya want for nothing?",
+ "Jefe",
+ { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
+ 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
+ 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
+ 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 } },
+
+ { "data-9 key-20",
+ "Hi There",
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+ { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53,
+ 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b,
+ 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7,
+ 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7 } },
+
+ { "data-50 key-20",
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
+ "\xdd\xdd",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa",
+ { 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46,
+ 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7,
+ 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22,
+ 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe } },
+
+ { "data-50 key-26",
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
+ "\xcd\xcd",
+ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
+ "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
+ { 0x82, 0x55, 0x8a, 0x38, 0x9a, 0x44, 0x3c, 0x0e,
+ 0xa4, 0xcc, 0x81, 0x98, 0x99, 0xf2, 0x08, 0x3a,
+ 0x85, 0xf0, 0xfa, 0xa3, 0xe5, 0x78, 0xf8, 0x07,
+ 0x7a, 0x2e, 0x3f, 0xf4, 0x67, 0x29, 0x66, 0x5b } },
+
+ { "data-54 key-131",
+ "Test Using Larger Than Block-Size Key - Hash Key First",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ { 0x60, 0xe4, 0x31, 0x59, 0x1e, 0xe0, 0xb6, 0x7f,
+ 0x0d, 0x8a, 0x26, 0xaa, 0xcb, 0xf5, 0xb7, 0x7f,
+ 0x8e, 0x0b, 0xc6, 0x21, 0x37, 0x28, 0xc5, 0x14,
+ 0x05, 0x46, 0x04, 0x0f, 0x0e, 0xe3, 0x7f, 0x54 } },
+
+ { "data-152 key-131",
+ "This is a test using a larger than block-size key and a larger "
+ "than block-size data. The key needs to be hashed before being "
+ "used by the HMAC algorithm.",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa",
+ { 0x9b, 0x09, 0xff, 0xa7, 0x1b, 0x94, 0x2f, 0xcb,
+ 0x27, 0x63, 0x5f, 0xbc, 0xd5, 0xb0, 0xe9, 0x44,
+ 0xbf, 0xdc, 0x63, 0x64, 0x4f, 0x07, 0x13, 0x93,
+ 0x8a, 0x7f, 0x51, 0x53, 0x5c, 0x3a, 0x35, 0xe2 } },
+
+ { NULL }
+ };
+ int tvidx;
+
+ for (tvidx=0; tv[tvidx].desc; tvidx++)
+ {
+ hmac256_context_t hmachd;
+ const unsigned char *digest;
+ size_t dlen;
+
+ hmachd = _gcry_hmac256_new (tv[tvidx].key, strlen (tv[tvidx].key));
+ if (!hmachd)
+ return -1;
+ _gcry_hmac256_update (hmachd, tv[tvidx].data, strlen (tv[tvidx].data));
+ digest = _gcry_hmac256_finalize (hmachd, &dlen);
+ if (!digest)
+ {
+ _gcry_hmac256_release (hmachd);
+ return -1;
+ }
+ if (dlen != sizeof (tv[tvidx].expect)
+ || memcmp (digest, tv[tvidx].expect, sizeof (tv[tvidx].expect)))
+ {
+ _gcry_hmac256_release (hmachd);
+ return -1;
+ }
+ _gcry_hmac256_release (hmachd);
+ }
+
+ return 0; /* Succeeded. */
+}
+
+
+int
+main (int argc, char **argv)
+{
+ const char *pgm;
+ int last_argc = -1;
+ const char *key;
+ size_t keylen;
+ FILE *fp;
+ hmac256_context_t hd;
+ const unsigned char *digest;
+ char buffer[4096];
+ size_t n, dlen, idx;
+ int use_stdin = 0;
+ int use_binary = 0;
+
+ assert (sizeof (u32) == 4);
+#ifdef __WIN32
+ setmode (fileno (stdin), O_BINARY);
+#endif
+
+ if (argc)
+ {
+ pgm = strrchr (*argv, '/');
+ if (pgm)
+ pgm++;
+ else
+ pgm = *argv;
+ argc--; argv++;
+ }
+ else
+ pgm = "?";
+
+ while (argc && last_argc != argc )
+ {
+ last_argc = argc;
+ if (!strcmp (*argv, "--"))
+ {
+ argc--; argv++;
+ break;
+ }
+ else if (!strcmp (*argv, "--version"))
+ {
+ fputs ("hmac256 (Libgcrypt) " VERSION "\n"
+ "Copyright (C) 2008 Free Software Foundation, Inc.\n"
+ "License LGPLv2.1+: GNU LGPL version 2.1 or later "
+ "<http://gnu.org/licenses/old-licenses/lgpl-2.1.html>\n"
+ "This is free software: you are free to change and "
+ "redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n",
+ stdout);
+ exit (0);
+ }
+ else if (!strcmp (*argv, "--binary"))
+ {
+ argc--; argv++;
+ use_binary = 1;
+ }
+ }
+
+ if (argc < 1)
+ {
+ fprintf (stderr, "usage: %s [--binary] key [filename]\n", pgm);
+ exit (1);
+ }
+
+#ifdef __WIN32
+ if (use_binary)
+ setmode (fileno (stdout), O_BINARY);
+#endif
+
+ key = *argv;
+ argc--, argv++;
+ keylen = strlen (key);
+ use_stdin = !argc;
+
+ if (selftest ())
+ {
+ fprintf (stderr, "%s: fatal error: self-test failed\n", pgm);
+ exit (2);
+ }
+
+ for (; argc || use_stdin; argv++, argc--)
+ {
+ const char *fname = use_stdin? "-" : *argv;
+ fp = use_stdin? stdin : fopen (fname, "rb");
+ if (!fp)
+ {
+ fprintf (stderr, "%s: can't open `%s': %s\n",
+ pgm, fname, strerror (errno));
+ exit (1);
+ }
+ hd = _gcry_hmac256_new (key, keylen);
+ if (!hd)
+ {
+ fprintf (stderr, "%s: can't allocate context: %s\n",
+ pgm, strerror (errno));
+ exit (1);
+ }
+ while ( (n = fread (buffer, 1, sizeof buffer, fp)))
+ _gcry_hmac256_update (hd, buffer, n);
+ if (ferror (fp))
+ {
+ fprintf (stderr, "%s: error reading `%s': %s\n",
+ pgm, fname, strerror (errno));
+ exit (1);
+ }
+ if (!use_stdin)
+ fclose (fp);
+
+ digest = _gcry_hmac256_finalize (hd, &dlen);
+ if (!digest)
+ {
+ fprintf (stderr, "%s: error computing HMAC: %s\n",
+ pgm, strerror (errno));
+ exit (1);
+ }
+ if (use_binary)
+ {
+ if (fwrite (digest, dlen, 1, stdout) != 1)
+ {
+ fprintf (stderr, "%s: error writing output: %s\n",
+ pgm, strerror (errno));
+ exit (1);
+ }
+ }
+ else
+ {
+ for (idx=0; idx < dlen; idx++)
+ printf ("%02x", digest[idx]);
+ _gcry_hmac256_release (hd);
+ if (use_stdin)
+ {
+ putchar ('\n');
+ break;
+ }
+ printf (" %s\n", fname);
+ }
+ }
+
+ return 0;
+}
+#endif /*STANDALONE*/
+
+
+/*
+Local Variables:
+compile-command: "cc -Wall -g -I.. -DSTANDALONE -o hmac256 hmac256.c"
+End:
+*/
diff --git a/grub-core/lib/libgcrypt/src/hmac256.h b/grub-core/lib/libgcrypt/src/hmac256.h
new file mode 100644
index 0000000..df28e72
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/hmac256.h
@@ -0,0 +1,36 @@
+/* hmac256.h - Declarations for _gcry_hmac256
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef HMAC256_H
+#define HMAC256_H
+
+
+struct hmac256_context;
+typedef struct hmac256_context *hmac256_context_t;
+
+hmac256_context_t _gcry_hmac256_new (const void *key, size_t keylen);
+void _gcry_hmac256_update (hmac256_context_t hd, const void *buf, size_t len);
+const void *_gcry_hmac256_finalize (hmac256_context_t hd, size_t *r_dlen);
+void _gcry_hmac256_release (hmac256_context_t hd);
+
+int _gcry_hmac256_file (void *result, size_t resultsize, const char *filename,
+ const void *key, size_t keylen);
+
+
+#endif /*HMAC256_H*/
diff --git a/grub-core/lib/libgcrypt/src/hwfeatures.c b/grub-core/lib/libgcrypt/src/hwfeatures.c
new file mode 100644
index 0000000..c356798
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/hwfeatures.c
@@ -0,0 +1,192 @@
+/* hwfeatures.c - Detect hardware features.
+ * Copyright (C) 2007, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+
+#include "g10lib.h"
+
+/* A bit vector describing the hardware features currently
+ available. */
+static unsigned int hw_features;
+
+
+/* Return a bit vector describing the available hardware features.
+ The HWF_ constants are used to test for them. */
+unsigned int
+_gcry_get_hw_features (void)
+{
+ return hw_features;
+}
+
+
+#if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4 && defined (__GNUC__)
+static void
+detect_ia32_gnuc (void)
+{
+ /* The code here is only useful for the PadLock engine thus we don't
+ build it if that support has been disabled. */
+ int has_cpuid = 0;
+ char vendor_id[12+1];
+
+ /* Detect the CPUID feature by testing some undefined behaviour (16
+ vs 32 bit pushf/popf). */
+ asm volatile
+ ("pushf\n\t" /* Copy flags to EAX. */
+ "popl %%eax\n\t"
+ "movl %%eax, %%ecx\n\t" /* Save flags into ECX. */
+ "xorl $0x200000, %%eax\n\t" /* Toggle ID bit and copy it to the flags. */
+ "pushl %%eax\n\t"
+ "popf\n\t"
+ "pushf\n\t" /* Copy changed flags again to EAX. */
+ "popl %%eax\n\t"
+ "pushl %%ecx\n\t" /* Restore flags from ECX. */
+ "popf\n\t"
+ "xorl %%eax, %%ecx\n\t" /* Compare flags against saved flags. */
+ "jz .Lno_cpuid%=\n\t" /* Toggling did not work, thus no CPUID. */
+ "movl $1, %0\n" /* Worked. true -> HAS_CPUID. */
+ ".Lno_cpuid%=:\n\t"
+ : "+r" (has_cpuid)
+ :
+ : "%eax", "%ecx", "cc"
+ );
+
+ if (!has_cpuid)
+ return; /* No way. */
+
+ asm volatile
+ ("pushl %%ebx\n\t" /* Save GOT register. */
+ "xorl %%eax, %%eax\n\t" /* 0 -> EAX. */
+ "cpuid\n\t" /* Get vendor ID. */
+ "movl %%ebx, (%0)\n\t" /* EBX,EDX,ECX -> VENDOR_ID. */
+ "movl %%edx, 4(%0)\n\t"
+ "movl %%ecx, 8(%0)\n\t"
+ "popl %%ebx\n"
+ :
+ : "S" (&vendor_id[0])
+ : "%eax", "%ecx", "%edx", "cc"
+ );
+ vendor_id[12] = 0;
+
+ if (0)
+ ; /* Just to make "else if" and ifdef macros look pretty. */
+#ifdef ENABLE_PADLOCK_SUPPORT
+ else if (!strcmp (vendor_id, "CentaurHauls"))
+ {
+ /* This is a VIA CPU. Check what PadLock features we have. */
+ asm volatile
+ ("pushl %%ebx\n\t" /* Save GOT register. */
+ "movl $0xC0000000, %%eax\n\t" /* Check for extended centaur */
+ "cpuid\n\t" /* feature flags. */
+ "popl %%ebx\n\t" /* Restore GOT register. */
+ "cmpl $0xC0000001, %%eax\n\t"
+ "jb .Lready%=\n\t" /* EAX < 0xC0000000 => no padlock. */
+
+ "pushl %%ebx\n\t" /* Save GOT register. */
+ "movl $0xC0000001, %%eax\n\t" /* Ask for the extended */
+ "cpuid\n\t" /* feature flags. */
+ "popl %%ebx\n\t" /* Restore GOT register. */
+
+ "movl %%edx, %%eax\n\t" /* Take copy of feature flags. */
+ "andl $0x0C, %%eax\n\t" /* Test bits 2 and 3 to see whether */
+ "cmpl $0x0C, %%eax\n\t" /* the RNG exists and is enabled. */
+ "jnz .Lno_rng%=\n\t"
+ "orl $1, %0\n" /* Set our HWF_PADLOCK_RNG bit. */
+
+ ".Lno_rng%=:\n\t"
+ "movl %%edx, %%eax\n\t" /* Take copy of feature flags. */
+ "andl $0xC0, %%eax\n\t" /* Test bits 6 and 7 to see whether */
+ "cmpl $0xC0, %%eax\n\t" /* the ACE exists and is enabled. */
+ "jnz .Lno_ace%=\n\t"
+ "orl $2, %0\n" /* Set our HWF_PADLOCK_AES bit. */
+
+ ".Lno_ace%=:\n\t"
+ "movl %%edx, %%eax\n\t" /* Take copy of feature flags. */
+ "andl $0xC00, %%eax\n\t" /* Test bits 10, 11 to see whether */
+ "cmpl $0xC00, %%eax\n\t" /* the PHE exists and is enabled. */
+ "jnz .Lno_phe%=\n\t"
+ "orl $4, %0\n" /* Set our HWF_PADLOCK_SHA bit. */
+
+ ".Lno_phe%=:\n\t"
+ "movl %%edx, %%eax\n\t" /* Take copy of feature flags. */
+ "andl $0x3000, %%eax\n\t" /* Test bits 12, 13 to see whether */
+ "cmpl $0x3000, %%eax\n\t" /* MONTMUL exists and is enabled. */
+ "jnz .Lready%=\n\t"
+ "orl $8, %0\n" /* Set our HWF_PADLOCK_MMUL bit. */
+
+ ".Lready%=:\n"
+ : "+r" (hw_features)
+ :
+ : "%eax", "%edx", "cc"
+ );
+ }
+#endif /*ENABLE_PADLOCK_SUPPORT*/
+ else if (!strcmp (vendor_id, "GenuineIntel"))
+ {
+ /* This is an Intel CPU. */
+ asm volatile
+ ("pushl %%ebx\n\t" /* Save GOT register. */
+ "movl $1, %%eax\n\t" /* Get CPU info and feature flags. */
+ "cpuid\n"
+ "popl %%ebx\n\t" /* Restore GOT register. */
+ "testl $0x02000000, %%ecx\n\t" /* Test bit 25. */
+ "jz .Lno_aes%=\n\t" /* No AES support. */
+ "orl $256, %0\n" /* Set our HWF_INTEL_AES bit. */
+
+ ".Lno_aes%=:\n"
+ : "+r" (hw_features)
+ :
+ : "%eax", "%ecx", "%edx", "cc"
+ );
+ }
+ else if (!strcmp (vendor_id, "AuthenticAMD"))
+ {
+ /* This is an AMD CPU. */
+
+ }
+}
+#endif /* __i386__ && SIZEOF_UNSIGNED_LONG == 4 && __GNUC__ */
+
+
+/* Detect the available hardware features. This function is called
+ once right at startup and we assume that no other threads are
+ running. */
+void
+_gcry_detect_hw_features (unsigned int disabled_features)
+{
+ hw_features = 0;
+
+ if (fips_mode ())
+ return; /* Hardware support is not to be evaluated. */
+
+#if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4
+#ifdef __GNUC__
+ detect_ia32_gnuc ();
+#endif
+#elif defined (__i386__) && SIZEOF_UNSIGNED_LONG == 8
+#ifdef __GNUC__
+#endif
+#endif
+
+ hw_features &= ~disabled_features;
+}
diff --git a/grub-core/lib/libgcrypt/src/libgcrypt-config.in b/grub-core/lib/libgcrypt/src/libgcrypt-config.in
new file mode 100644
index 0000000..c052638
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/libgcrypt-config.in
@@ -0,0 +1,189 @@
+#!/bin/sh
+# Copyright (C) 1999, 2002, 2003, 2004, 2011 Free Software Foundation, Inc.
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# File: @configure_input@
+
+# General.
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+version="@VERSION@"
+includedir="@includedir@"
+libdir="@libdir@"
+gpg_error_libs="@GPG_ERROR_LIBS@"
+gpg_error_cflags="@GPG_ERROR_CFLAGS@"
+
+# libgcrypt values.
+libs="@LIBGCRYPT_CONFIG_LIBS@"
+cflags="@LIBGCRYPT_CONFIG_CFLAGS@"
+
+# API info
+api_version="@LIBGCRYPT_CONFIG_API_VERSION@"
+
+# Configured for host
+my_host="@LIBGCRYPT_CONFIG_HOST@"
+
+# Misc information.
+symmetric_ciphers="@LIBGCRYPT_CIPHERS@"
+asymmetric_ciphers="@LIBGCRYPT_PUBKEY_CIPHERS@"
+digests="@LIBGCRYPT_DIGESTS@"
+
+# State variables.
+echo_libs=no
+echo_cflags=no
+echo_prefix=no
+echo_algorithms=no
+echo_exec_prefix=no
+echo_version=no
+echo_api_version=no
+echo_host=no
+
+# Prints usage information.
+usage()
+{
+ cat <<EOF
+Usage: $0 [OPTIONS]
+Options:
+ [--prefix]
+ [--exec-prefix]
+ [--version]
+ [--api-version]
+ [--libs]
+ [--cflags]
+ [--algorithms]
+ [--host]
+EOF
+ exit $1
+}
+
+if test $# -eq 0; then
+ # Nothing to do.
+ usage 1 1>&2
+fi
+
+while test $# -gt 0; do
+ case "$1" in
+ # Set up `optarg'.
+ --*=*)
+ optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
+ ;;
+ *)
+ optarg=""
+ ;;
+ esac
+
+ case $1 in
+ --thread=*)
+ echo "$0: --thread option obsolete: use the thread callback interface" 1>&2
+ exit 1
+ ;;
+ --prefix=*)
+ # For compatibility reasons with old M4 macros, we ignore
+ # setting of prefix.
+ ;;
+ --prefix)
+ echo_prefix=yes
+ ;;
+ --exec-prefix=*)
+ ;;
+ --exec-prefix)
+ echo_exec_prefix=yes
+ ;;
+ --version)
+ echo_version=yes
+ ;;
+ --api-version)
+ echo_api_version=yes
+ ;;
+ --cflags)
+ echo_cflags=yes
+ ;;
+ --libs)
+ echo_libs=yes
+ ;;
+ --algorithms)
+ echo_algorithms=yes
+ ;;
+ --host)
+ echo_host=yes
+ ;;
+ *)
+ usage 1 1>&2
+ ;;
+ esac
+ shift
+done
+
+if test "$echo_prefix" = "yes"; then
+ echo "$prefix"
+fi
+
+if test "$echo_exec_prefix" = "yes"; then
+ echo "$exec_prefix"
+fi
+
+if test "$echo_cflags" = "yes"; then
+ includes=""
+ cflags_final="$cflags"
+
+ # Set up `includes'.
+ if test "x$includedir" != "x/usr/include" -a "x$includedir" != "x/include"; then
+ includes="-I$includedir"
+ fi
+ # Set up `cflags_final'.
+ cflags_final="$cflags_final $gpg_error_cflags"
+
+ tmp=""
+ for i in $includes $cflags_final; do
+ if echo "$tmp" | fgrep -v -- "$i" >/dev/null; then
+ tmp="$tmp $i"
+ fi
+ done
+ echo $tmp
+fi
+
+if test "$echo_libs" = "yes"; then
+ libdirs=""
+ libs_final="$libs"
+
+ # Set up `libdirs'.
+ if test "x$libdir" != "x/usr/lib" -a "x$libdir" != "x/lib"; then
+ libdirs="-L$libdir"
+ fi
+
+ # Set up `libs_final'.
+ libs_final="$libs_final $gpg_error_libs"
+
+ tmp=""
+ for i in $libdirs $libs_final; do
+ if echo "$tmp" | fgrep -v -- "$i" >/dev/null; then
+ tmp="$tmp $i"
+ fi
+ done
+ echo $tmp
+fi
+
+if test "$echo_version" = "yes"; then
+ echo "$version"
+fi
+
+if test "$echo_api_version" = "yes"; then
+ echo "$api_version"
+fi
+
+if test "$echo_host" = "yes"; then
+ echo "$my_host"
+fi
+
+if test "$echo_algorithms" = "yes"; then
+ echo "Symmetric cipher algorithms: $symmetric_ciphers"
+ echo "Public-key cipher algorithms: $asymmetric_ciphers"
+ echo "Message digest algorithms: $digests"
+fi
diff --git a/grub-core/lib/libgcrypt/src/libgcrypt.def b/grub-core/lib/libgcrypt/src/libgcrypt.def
new file mode 100644
index 0000000..031b941
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/libgcrypt.def
@@ -0,0 +1,239 @@
+;; libgcrypt.defs - Exported symbols for W32
+;; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+;;
+;; This file is part of Libgcrypt.
+;;
+;; Libgcrypt is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU Lesser General Public License as
+;; published by the Free Software Foundation; either version 2.1 of
+;; the License, or (at your option) any later version.
+;;
+;; Libgcrypt is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+;;
+
+;; Note: This file should be updated manually and the ordinals shall
+;; never be changed. Also check libgcrypt.vers and visibility.h.
+
+
+EXPORTS
+ gcry_check_version @1
+ gcry_control @2
+
+ gcry_malloc @3
+ gcry_calloc @4
+ gcry_malloc_secure @5
+ gcry_calloc_secure @6
+ gcry_realloc @7
+ gcry_strdup @8
+ gcry_xmalloc @9
+ gcry_xcalloc @10
+ gcry_xmalloc_secure @11
+ gcry_xcalloc_secure @12
+ gcry_xrealloc @13
+ gcry_xstrdup @14
+ gcry_is_secure @15
+ gcry_free @16
+
+ gcry_set_progress_handler @17
+ gcry_set_allocation_handler @18
+ gcry_set_outofcore_handler @19
+ gcry_set_fatalerror_handler @20
+ gcry_set_log_handler @21
+ gcry_set_gettext_handler @22
+
+ gcry_strerror @23
+ gcry_strsource @24
+ gcry_err_code_from_errno @25
+ gcry_err_code_to_errno @26
+ gcry_err_make_from_errno @27
+ gcry_error_from_errno @28
+
+ gcry_sexp_new @29
+ gcry_sexp_create @30
+ gcry_sexp_sscan @31
+ gcry_sexp_build @32
+ gcry_sexp_build_array @33
+ gcry_sexp_release @34
+ gcry_sexp_canon_len @35
+ gcry_sexp_sprint @36
+ gcry_sexp_dump @37
+ gcry_sexp_cons @38
+ gcry_sexp_alist @39
+ gcry_sexp_vlist @40
+ gcry_sexp_append @41
+ gcry_sexp_prepend @42
+ gcry_sexp_find_token @43
+ gcry_sexp_length @44
+ gcry_sexp_nth @45
+ gcry_sexp_car @46
+ gcry_sexp_cdr @47
+ gcry_sexp_cadr @48
+ gcry_sexp_nth_data @49
+ gcry_sexp_nth_mpi @50
+
+ gcry_mpi_new @51
+ gcry_mpi_snew @52
+ gcry_mpi_release @53
+ gcry_mpi_copy @54
+ gcry_mpi_set @55
+ gcry_mpi_set_ui @56
+ gcry_mpi_swap @57
+ gcry_mpi_cmp @58
+ gcry_mpi_cmp_ui @59
+ gcry_mpi_scan @60
+ gcry_mpi_print @61
+ gcry_mpi_aprint @62
+ gcry_mpi_dump @63
+ gcry_mpi_add @64
+ gcry_mpi_add_ui @65
+ gcry_mpi_addm @66
+ gcry_mpi_sub @67
+ gcry_mpi_sub_ui @68
+ gcry_mpi_subm @69
+ gcry_mpi_mul @70
+ gcry_mpi_mul_ui @71
+ gcry_mpi_mulm @72
+ gcry_mpi_mul_2exp @73
+ gcry_mpi_div @74
+ gcry_mpi_mod @75
+ gcry_mpi_powm @76
+ gcry_mpi_gcd @77
+ gcry_mpi_invm @78
+ gcry_mpi_get_nbits @79
+ gcry_mpi_test_bit @80
+ gcry_mpi_set_bit @81
+ gcry_mpi_clear_bit @82
+ gcry_mpi_set_highbit @83
+ gcry_mpi_clear_highbit @84
+ gcry_mpi_rshift @85
+ gcry_mpi_set_opaque @86
+ gcry_mpi_get_opaque @87
+ gcry_mpi_set_flag @88
+ gcry_mpi_clear_flag @89
+ gcry_mpi_get_flag @90
+
+
+ gcry_cipher_open @92
+ gcry_cipher_close @93
+ gcry_cipher_ctl @94
+ gcry_cipher_info @95
+ gcry_cipher_algo_info @96
+ gcry_cipher_algo_name @97
+ gcry_cipher_map_name @98
+ gcry_cipher_mode_from_oid @99
+ gcry_cipher_encrypt @100
+ gcry_cipher_decrypt @101
+ gcry_cipher_get_algo_keylen @102
+ gcry_cipher_get_algo_blklen @103
+ gcry_cipher_list @104
+
+ gcry_pk_encrypt @105
+ gcry_pk_decrypt @106
+ gcry_pk_sign @107
+ gcry_pk_verify @108
+ gcry_pk_testkey @109
+ gcry_pk_genkey @110
+ gcry_pk_ctl @111
+ gcry_pk_algo_info @112
+ gcry_pk_algo_name @113
+ gcry_pk_map_name @114
+ gcry_pk_get_nbits @115
+ gcry_pk_get_keygrip @116
+ gcry_pk_list @117
+
+ gcry_ac_data_new @118
+ gcry_ac_data_destroy @119
+ gcry_ac_data_set @120
+ gcry_ac_data_copy @121
+ gcry_ac_data_length @122
+ gcry_ac_data_get_name @123
+ gcry_ac_data_get_index @124
+ gcry_ac_data_clear @125
+ gcry_ac_open @126
+ gcry_ac_close @127
+ gcry_ac_key_init @128
+ gcry_ac_key_pair_generate @129
+ gcry_ac_key_pair_extract @130
+ gcry_ac_key_data_get @131
+ gcry_ac_key_test @132
+ gcry_ac_key_get_nbits @133
+ gcry_ac_key_get_grip @134
+ gcry_ac_key_destroy @135
+ gcry_ac_key_pair_destroy @136
+ gcry_ac_data_encrypt @137
+ gcry_ac_data_decrypt @138
+ gcry_ac_data_sign @139
+ gcry_ac_data_verify @140
+ gcry_ac_id_to_name @141
+ gcry_ac_name_to_id @142
+
+ gcry_md_open @143
+ gcry_md_close @144
+ gcry_md_enable @145
+ gcry_md_copy @146
+ gcry_md_reset @147
+ gcry_md_ctl @148
+ gcry_md_write @149
+ gcry_md_read @150
+ gcry_md_hash_buffer @151
+ gcry_md_get_algo @152
+ gcry_md_get_algo_dlen @153
+ gcry_md_is_enabled @154
+ gcry_md_is_secure @155
+ gcry_md_info @156
+ gcry_md_algo_info @157
+ gcry_md_algo_name @158
+ gcry_md_map_name @159
+ gcry_md_setkey @160
+ gcry_md_list @161
+
+ gcry_randomize @162
+ gcry_random_add_bytes @163
+ gcry_random_bytes @164
+ gcry_random_bytes_secure @165
+ gcry_mpi_randomize @166
+
+ gcry_prime_generate @167
+ gcry_prime_group_generator @168
+ gcry_prime_release_factors @169
+ gcry_prime_check @170
+
+ gcry_create_nonce @171
+
+ gcry_md_debug @172
+
+ gcry_cipher_register @173
+ gcry_cipher_unregister @174
+ gcry_md_register @175
+ gcry_md_unregister @176
+ gcry_pk_register @177
+ gcry_pk_unregister @178
+
+ gcry_ac_data_from_sexp @179
+ gcry_ac_data_to_sexp @180
+ gcry_ac_io_init @181
+ gcry_ac_io_init_va @182
+ gcry_ac_data_encrypt_scheme @183
+ gcry_ac_data_decrypt_scheme @184
+ gcry_ac_data_sign_scheme @185
+ gcry_ac_data_verify_scheme @186
+
+ gcry_sexp_nth_string @187
+
+ gcry_cipher_setkey @188
+ gcry_cipher_setiv @189
+ gcry_cipher_setctr @190
+
+ gcry_mpi_lshift @191
+
+ gcry_pk_get_curve @192
+ gcry_pk_get_param @193
+
+ gcry_kdf_derive @194
diff --git a/grub-core/lib/libgcrypt/src/libgcrypt.m4 b/grub-core/lib/libgcrypt/src/libgcrypt.m4
new file mode 100644
index 0000000..831dc0c
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/libgcrypt.m4
@@ -0,0 +1,123 @@
+dnl Autoconf macros for libgcrypt
+dnl Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+dnl
+dnl This file is free software; as a special exception the author gives
+dnl unlimited permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+dnl This file is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+
+dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS.
+dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed
+dnl with the API version to also check the API compatibility. Example:
+dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed
+dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using
+dnl this features allows to prevent build against newer versions of libgcrypt
+dnl with a changed API.
+dnl
+AC_DEFUN([AM_PATH_LIBGCRYPT],
+[ AC_ARG_WITH(libgcrypt-prefix,
+ AC_HELP_STRING([--with-libgcrypt-prefix=PFX],
+ [prefix where LIBGCRYPT is installed (optional)]),
+ libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
+ if test x$libgcrypt_config_prefix != x ; then
+ if test x${LIBGCRYPT_CONFIG+set} != xset ; then
+ LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config
+ fi
+ fi
+
+ AC_PATH_TOOL(LIBGCRYPT_CONFIG, libgcrypt-config, no)
+ tmp=ifelse([$1], ,1:1.2.0,$1)
+ if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+ req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
+ min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+ else
+ req_libgcrypt_api=0
+ min_libgcrypt_version="$tmp"
+ fi
+
+ AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version)
+ ok=no
+ if test "$LIBGCRYPT_CONFIG" != "no" ; then
+ req_major=`echo $min_libgcrypt_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_libgcrypt_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ req_micro=`echo $min_libgcrypt_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+ libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version`
+ major=`echo $libgcrypt_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+ minor=`echo $libgcrypt_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+ micro=`echo $libgcrypt_config_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
+ if test "$major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$major" -eq "$req_major"; then
+ if test "$minor" -gt "$req_minor"; then
+ ok=yes
+ else
+ if test "$minor" -eq "$req_minor"; then
+ if test "$micro" -ge "$req_micro"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ AC_MSG_RESULT([yes ($libgcrypt_config_version)])
+ else
+ AC_MSG_RESULT(no)
+ fi
+ if test $ok = yes; then
+ # If we have a recent libgcrypt, we should also check that the
+ # API is compatible
+ if test "$req_libgcrypt_api" -gt 0 ; then
+ tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0`
+ if test "$tmp" -gt 0 ; then
+ AC_MSG_CHECKING([LIBGCRYPT API version])
+ if test "$req_libgcrypt_api" -eq "$tmp" ; then
+ AC_MSG_RESULT([okay])
+ else
+ ok=no
+ AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp])
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags`
+ LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs`
+ ifelse([$2], , :, [$2])
+ if test x"$host" != x ; then
+ libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none`
+ if test x"$libgcrypt_config_host" != xnone ; then
+ if test x"$libgcrypt_config_host" != x"$host" ; then
+ AC_MSG_WARN([[
+***
+*** The config script $LIBGCRYPT_CONFIG was
+*** built for $libgcrypt_config_host and thus may not match the
+*** used host $host.
+*** You may want to use the configure option --with-libgcrypt-prefix
+*** to specify a matching config script.
+***]])
+ fi
+ fi
+ fi
+ else
+ LIBGCRYPT_CFLAGS=""
+ LIBGCRYPT_LIBS=""
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(LIBGCRYPT_CFLAGS)
+ AC_SUBST(LIBGCRYPT_LIBS)
+])
diff --git a/grub-core/lib/libgcrypt/src/libgcrypt.vers b/grub-core/lib/libgcrypt/src/libgcrypt.vers
new file mode 100644
index 0000000..5a617cc
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/libgcrypt.vers
@@ -0,0 +1,111 @@
+# libgcrypt.vers - What symbols to export -*- std -*-
+# Copyright (C) 2002, 2004, 2008 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser general Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+# NOTE: When adding new functions, please make sure to add them to
+# visibility.h and libgcrypt.def as well.
+
+GCRYPT_1.2 {
+ global:
+ gcry_check_version; gcry_control;
+ gcry_set_allocation_handler; gcry_set_fatalerror_handler;
+ gcry_set_gettext_handler; gcry_set_log_handler;
+ gcry_set_outofcore_handler; gcry_set_progress_handler;
+
+ gcry_err_code_from_errno; gcry_err_code_to_errno;
+ gcry_err_make_from_errno; gcry_error_from_errno;
+ gcry_strerror; gcry_strsource;
+
+ gcry_free; gcry_malloc; gcry_malloc_secure; gcry_calloc;
+ gcry_calloc_secure; gcry_realloc; gcry_strdup; gcry_is_secure;
+ gcry_xcalloc; gcry_xcalloc_secure; gcry_xmalloc;
+ gcry_xmalloc_secure; gcry_xrealloc; gcry_xstrdup;
+
+ gcry_md_algo_info; gcry_md_algo_name; gcry_md_close;
+ gcry_md_copy; gcry_md_ctl; gcry_md_enable; gcry_md_get;
+ gcry_md_get_algo; gcry_md_get_algo_dlen; gcry_md_hash_buffer;
+ gcry_md_info; gcry_md_is_enabled; gcry_md_is_secure;
+ gcry_md_list; gcry_md_map_name; gcry_md_open; gcry_md_read;
+ gcry_md_register; gcry_md_reset; gcry_md_setkey;
+ gcry_md_unregister; gcry_md_write; gcry_md_debug;
+
+ gcry_cipher_algo_info; gcry_cipher_algo_name; gcry_cipher_close;
+ gcry_cipher_ctl; gcry_cipher_decrypt; gcry_cipher_encrypt;
+ gcry_cipher_get_algo_blklen; gcry_cipher_get_algo_keylen;
+ gcry_cipher_info; gcry_cipher_list; gcry_cipher_map_name;
+ gcry_cipher_mode_from_oid; gcry_cipher_open;
+ gcry_cipher_register; gcry_cipher_unregister;
+ gcry_cipher_setkey; gcry_cipher_setiv; gcry_cipher_setctr;
+
+ gcry_pk_algo_info; gcry_pk_algo_name; gcry_pk_ctl;
+ gcry_pk_decrypt; gcry_pk_encrypt; gcry_pk_genkey;
+ gcry_pk_get_keygrip; gcry_pk_get_nbits; gcry_pk_list;
+ gcry_pk_map_name; gcry_pk_register; gcry_pk_sign;
+ gcry_pk_testkey; gcry_pk_unregister; gcry_pk_verify;
+ gcry_pk_get_curve; gcry_pk_get_param;
+
+ gcry_ac_data_new; gcry_ac_data_destroy; gcry_ac_data_copy;
+ gcry_ac_data_length; gcry_ac_data_clear; gcry_ac_data_set;
+ gcry_ac_data_get_name; gcry_ac_data_get_index; gcry_ac_open;
+ gcry_ac_close; gcry_ac_key_init; gcry_ac_key_pair_generate;
+ gcry_ac_key_pair_extract; gcry_ac_key_data_get; gcry_ac_key_test;
+ gcry_ac_key_get_nbits; gcry_ac_key_get_grip; gcry_ac_key_destroy;
+ gcry_ac_key_pair_destroy; gcry_ac_data_encrypt; gcry_ac_data_decrypt;
+ gcry_ac_data_sign; gcry_ac_data_verify; gcry_ac_id_to_name;
+ gcry_ac_name_to_id; gcry_ac_list; gcry_ac_data_encode;
+ gcry_ac_data_decode; gcry_ac_mpi_to_os; gcry_ac_mpi_to_os_alloc;
+ gcry_ac_os_to_mpi; gcry_ac_data_encrypt_scheme;
+ gcry_ac_data_decrypt_scheme;
+ gcry_ac_data_sign_scheme; gcry_ac_data_verify_scheme;
+ gcry_ac_data_to_sexp; gcry_ac_data_from_sexp;
+ gcry_ac_io_init; gcry_ac_io_init_va;
+
+ gcry_kdf_derive;
+
+ gcry_prime_check; gcry_prime_generate;
+ gcry_prime_group_generator; gcry_prime_release_factors;
+
+ gcry_random_add_bytes; gcry_random_bytes; gcry_random_bytes_secure;
+ gcry_randomize; gcry_create_nonce;
+
+ gcry_sexp_alist; gcry_sexp_append; gcry_sexp_build;
+ gcry_sexp_build_array; gcry_sexp_cadr; gcry_sexp_canon_len;
+ gcry_sexp_car; gcry_sexp_cdr; gcry_sexp_cons; gcry_sexp_create;
+ gcry_sexp_dump; gcry_sexp_find_token; gcry_sexp_length;
+ gcry_sexp_new; gcry_sexp_nth; gcry_sexp_nth_data;
+ gcry_sexp_nth_mpi; gcry_sexp_prepend; gcry_sexp_release;
+ gcry_sexp_sprint; gcry_sexp_sscan; gcry_sexp_vlist;
+ gcry_sexp_nth_string;
+
+ gcry_mpi_add; gcry_mpi_add_ui; gcry_mpi_addm; gcry_mpi_aprint;
+ gcry_mpi_clear_bit; gcry_mpi_clear_flag; gcry_mpi_clear_highbit;
+ gcry_mpi_cmp; gcry_mpi_cmp_ui; gcry_mpi_copy; gcry_mpi_div;
+ gcry_mpi_dump; gcry_mpi_gcd; gcry_mpi_get_flag; gcry_mpi_get_nbits;
+ gcry_mpi_get_opaque; gcry_mpi_invm; gcry_mpi_mod; gcry_mpi_mul;
+ gcry_mpi_mul_2exp; gcry_mpi_mul_ui; gcry_mpi_mulm; gcry_mpi_new;
+ gcry_mpi_powm; gcry_mpi_print; gcry_mpi_randomize; gcry_mpi_release;
+ gcry_mpi_rshift; gcry_mpi_scan; gcry_mpi_set; gcry_mpi_set_bit;
+ gcry_mpi_set_flag; gcry_mpi_set_highbit; gcry_mpi_set_opaque;
+ gcry_mpi_set_ui; gcry_mpi_snew; gcry_mpi_sub; gcry_mpi_sub_ui;
+ gcry_mpi_subm; gcry_mpi_swap; gcry_mpi_test_bit;
+ gcry_mpi_lshift;
+
+ local:
+ *;
+
+};
diff --git a/grub-core/lib/libgcrypt/src/misc.c b/grub-core/lib/libgcrypt/src/misc.c
new file mode 100644
index 0000000..17bd546
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/misc.c
@@ -0,0 +1,298 @@
+/* misc.c
+ * Copyright (C) 1999, 2001, 2002, 2003, 2007,
+ * 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+
+#include "g10lib.h"
+#include "secmem.h"
+
+static int verbosity_level = 0;
+
+static void (*fatal_error_handler)(void*,int, const char*) = NULL;
+static void *fatal_error_handler_value = 0;
+static void (*log_handler)(void*,int, const char*, va_list) = NULL;
+static void *log_handler_value = 0;
+
+static const char *(*user_gettext_handler)( const char * ) = NULL;
+
+void
+gcry_set_gettext_handler( const char *(*f)(const char*) )
+{
+ user_gettext_handler = f;
+}
+
+
+const char *
+_gcry_gettext( const char *key )
+{
+ if( user_gettext_handler )
+ return user_gettext_handler( key );
+ /* FIXME: switch the domain to gnupg and restore later */
+ return key;
+}
+
+void
+gcry_set_fatalerror_handler( void (*fnc)(void*,int, const char*), void *value)
+{
+ fatal_error_handler_value = value;
+ fatal_error_handler = fnc;
+}
+
+static void
+write2stderr( const char *s )
+{
+ /* Dummy variable to silence gcc warning. */
+ int res = write( 2, s, strlen(s) );
+ (void) res;
+}
+
+/*
+ * This function is called for fatal errors. A caller might want to
+ * set his own handler because this function simply calls abort().
+ */
+void
+_gcry_fatal_error (int rc, const char *text)
+{
+ if ( !text ) /* get a default text */
+ text = gpg_strerror (rc);
+
+ if (fatal_error_handler && !fips_mode () )
+ fatal_error_handler (fatal_error_handler_value, rc, text);
+
+ fips_signal_fatal_error (text);
+ write2stderr("\nFatal error: ");
+ write2stderr(text);
+ write2stderr("\n");
+ _gcry_secmem_term ();
+ abort ();
+}
+
+void
+gcry_set_log_handler( void (*f)(void*,int, const char*, va_list ),
+ void *opaque )
+{
+ log_handler = f;
+ log_handler_value = opaque;
+}
+
+void
+_gcry_set_log_verbosity( int level )
+{
+ verbosity_level = level;
+}
+
+int
+_gcry_log_verbosity( int level )
+{
+ return verbosity_level >= level;
+}
+
+/****************
+ * This is our log function which prints all log messages to stderr or
+ * using the function defined with gcry_set_log_handler().
+ */
+static void
+_gcry_logv( int level, const char *fmt, va_list arg_ptr )
+{
+ if (log_handler)
+ log_handler (log_handler_value, level, fmt, arg_ptr);
+ else
+ {
+ switch (level)
+ {
+ case GCRY_LOG_CONT: break;
+ case GCRY_LOG_INFO: break;
+ case GCRY_LOG_WARN: break;
+ case GCRY_LOG_ERROR: break;
+ case GCRY_LOG_FATAL: fputs("Fatal: ",stderr ); break;
+ case GCRY_LOG_BUG: fputs("Ohhhh jeeee: ", stderr); break;
+ case GCRY_LOG_DEBUG: fputs("DBG: ", stderr ); break;
+ default: fprintf(stderr,"[Unknown log level %d]: ", level ); break;
+ }
+ vfprintf(stderr,fmt,arg_ptr) ;
+ }
+
+ if ( level == GCRY_LOG_FATAL || level == GCRY_LOG_BUG )
+ {
+ fips_signal_fatal_error ("internal error (fatal or bug)");
+ _gcry_secmem_term ();
+ abort ();
+ }
+}
+
+
+void
+_gcry_log( int level, const char *fmt, ... )
+{
+ va_list arg_ptr ;
+
+ va_start( arg_ptr, fmt ) ;
+ _gcry_logv( level, fmt, arg_ptr );
+ va_end(arg_ptr);
+}
+
+
+#if defined(JNLIB_GCC_M_FUNCTION) || __STDC_VERSION__ >= 199901L
+void
+_gcry_bug( const char *file, int line, const char *func )
+{
+ _gcry_log( GCRY_LOG_BUG,
+ ("... this is a bug (%s:%d:%s)\n"), file, line, func );
+ abort(); /* never called, but it makes the compiler happy */
+}
+void
+_gcry_assert_failed (const char *expr, const char *file, int line,
+ const char *func)
+{
+ _gcry_log (GCRY_LOG_BUG,
+ ("Assertion `%s' failed (%s:%d:%s)\n"), expr, file, line, func );
+ abort(); /* Never called, but it makes the compiler happy. */
+}
+#else
+void
+_gcry_bug( const char *file, int line )
+{
+ _gcry_log( GCRY_LOG_BUG,
+ _("you found a bug ... (%s:%d)\n"), file, line);
+ abort(); /* never called, but it makes the compiler happy */
+}
+void
+_gcry_assert_failed (const char *expr, const char *file, int line)
+{
+ _gcry_log (GCRY_LOG_BUG,
+ ("Assertion `%s' failed (%s:%d)\n"), expr, file, line);
+ abort(); /* Never called, but it makes the compiler happy. */
+}
+#endif
+
+void
+_gcry_log_info( const char *fmt, ... )
+{
+ va_list arg_ptr ;
+
+ va_start( arg_ptr, fmt ) ;
+ _gcry_logv( GCRY_LOG_INFO, fmt, arg_ptr );
+ va_end(arg_ptr);
+}
+
+int
+_gcry_log_info_with_dummy_fp (FILE *fp, const char *fmt, ... )
+{
+ va_list arg_ptr;
+
+ (void)fp;
+ va_start( arg_ptr, fmt ) ;
+ _gcry_logv( GCRY_LOG_INFO, fmt, arg_ptr );
+ va_end(arg_ptr);
+ return 0;
+}
+
+void
+_gcry_log_error( const char *fmt, ... )
+{
+ va_list arg_ptr ;
+
+ va_start( arg_ptr, fmt ) ;
+ _gcry_logv( GCRY_LOG_ERROR, fmt, arg_ptr );
+ va_end(arg_ptr);
+}
+
+
+void
+_gcry_log_fatal( const char *fmt, ... )
+{
+ va_list arg_ptr ;
+
+ va_start( arg_ptr, fmt ) ;
+ _gcry_logv( GCRY_LOG_FATAL, fmt, arg_ptr );
+ va_end(arg_ptr);
+ abort(); /* never called, but it makes the compiler happy */
+}
+
+void
+_gcry_log_bug( const char *fmt, ... )
+{
+ va_list arg_ptr ;
+
+ va_start( arg_ptr, fmt ) ;
+ _gcry_logv( GCRY_LOG_BUG, fmt, arg_ptr );
+ va_end(arg_ptr);
+ abort(); /* never called, but it makes the compiler happy */
+}
+
+void
+_gcry_log_debug( const char *fmt, ... )
+{
+ va_list arg_ptr ;
+
+ va_start( arg_ptr, fmt ) ;
+ _gcry_logv( GCRY_LOG_DEBUG, fmt, arg_ptr );
+ va_end(arg_ptr);
+}
+
+
+void
+_gcry_log_printf (const char *fmt, ...)
+{
+ va_list arg_ptr;
+
+ if (fmt)
+ {
+ va_start( arg_ptr, fmt ) ;
+ _gcry_logv (GCRY_LOG_CONT, fmt, arg_ptr);
+ va_end(arg_ptr);
+ }
+}
+
+/* Print a hexdump of BUFFER. With TEXT of NULL print just the raw
+ dump, with TEXT an empty string, print a trailing linefeed,
+ otherwise print an entire debug line. */
+void
+_gcry_log_printhex (const char *text, const void *buffer, size_t length)
+{
+ if (text && *text)
+ log_debug ("%s ", text);
+ if (length)
+ {
+ const unsigned char *p = buffer;
+ log_printf ("%02X", *p);
+ for (length--, p++; length--; p++)
+ log_printf (" %02X", *p);
+ }
+ if (text)
+ log_printf ("\n");
+}
+
+
+void
+_gcry_burn_stack (int bytes)
+{
+ char buf[64];
+
+ wipememory (buf, sizeof buf);
+ bytes -= sizeof buf;
+ if (bytes > 0)
+ _gcry_burn_stack (bytes);
+}
diff --git a/grub-core/lib/libgcrypt/src/missing-string.c b/grub-core/lib/libgcrypt/src/missing-string.c
new file mode 100644
index 0000000..4756c00
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/missing-string.c
@@ -0,0 +1,54 @@
+/* missing-string.c - missing string utilities
+ * Copyright (C) 1994, 1998, 1999, 2000, 2001,
+ * 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "g10lib.h"
+
+
+#ifndef HAVE_STPCPY
+char *
+stpcpy(char *a,const char *b)
+{
+ while( *b )
+ *a++ = *b++;
+ *a = 0;
+
+ return (char*)a;
+}
+#endif
+
+
+#ifndef HAVE_STRCASECMP
+int
+strcasecmp( const char *a, const char *b )
+{
+ for( ; *a && *b; a++, b++ ) {
+ if( *a != *b && toupper(*a) != toupper(*b) )
+ break;
+ }
+ return *(const byte*)a - *(const byte*)b;
+}
+#endif
diff --git a/grub-core/lib/libgcrypt/src/module.c b/grub-core/lib/libgcrypt/src/module.c
new file mode 100644
index 0000000..32f668d
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/module.c
@@ -0,0 +1,212 @@
+/* module.c - Module management for libgcrypt.
+ * Copyright (C) 2003, 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <errno.h>
+#include "g10lib.h"
+
+/* Please match these numbers with the allocated algorithm
+ numbers. */
+#define MODULE_ID_MIN 600
+#define MODULE_ID_LAST 65500
+#define MODULE_ID_USER GCRY_MODULE_ID_USER
+#define MODULE_ID_USER_LAST GCRY_MODULE_ID_USER_LAST
+
+#if MODULE_ID_MIN >= MODULE_ID_USER
+#error Need to implement a different search strategy
+#endif
+
+/* Internal function. Generate a new, unique module ID for a module
+ that should be inserted into the module chain starting at
+ MODULES. */
+static gcry_err_code_t
+_gcry_module_id_new (gcry_module_t modules, unsigned int *id_new)
+{
+ unsigned int mod_id;
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ gcry_module_t module;
+
+ /* Search for unused ID. */
+ for (mod_id = MODULE_ID_MIN; mod_id < MODULE_ID_LAST; mod_id++)
+ {
+ if (mod_id == MODULE_ID_USER)
+ {
+ mod_id = MODULE_ID_USER_LAST;
+ continue;
+ }
+
+ /* Search for a module with the current ID. */
+ for (module = modules; module; module = module->next)
+ if (mod_id == module->mod_id)
+ break;
+
+ if (! module)
+ /* None found -> the ID is available for use. */
+ break;
+ }
+
+ if (mod_id < MODULE_ID_LAST)
+ /* Done. */
+ *id_new = mod_id;
+ else
+ /* No free ID found. */
+ err = GPG_ERR_INTERNAL;
+
+ return err;
+}
+
+/* Add a module specification to the list ENTRIES. The new module has
+ it's use-counter set to one. */
+gcry_err_code_t
+_gcry_module_add (gcry_module_t *entries, unsigned int mod_id,
+ void *spec, void *extraspec, gcry_module_t *module)
+{
+ gcry_err_code_t err = 0;
+ gcry_module_t entry;
+
+ if (! mod_id)
+ err = _gcry_module_id_new (*entries, &mod_id);
+
+ if (! err)
+ {
+ entry = gcry_malloc (sizeof (struct gcry_module));
+ if (! entry)
+ err = gpg_err_code_from_errno (errno);
+ }
+
+ if (! err)
+ {
+ /* Fill new module entry. */
+ entry->flags = 0;
+ entry->counter = 1;
+ entry->spec = spec;
+ entry->extraspec = extraspec;
+ entry->mod_id = mod_id;
+
+ /* Link it into the list. */
+ entry->next = *entries;
+ entry->prevp = entries;
+ if (*entries)
+ (*entries)->prevp = &entry->next;
+ *entries = entry;
+
+ /* And give it to the caller. */
+ if (module)
+ *module = entry;
+ }
+ return err;
+}
+
+/* Internal function. Unlink CIPHER_ENTRY from the list of registered
+ ciphers and destroy it. */
+static void
+_gcry_module_drop (gcry_module_t entry)
+{
+ *entry->prevp = entry->next;
+ if (entry->next)
+ entry->next->prevp = entry->prevp;
+
+ gcry_free (entry);
+}
+
+/* Lookup a module specification by it's ID. After a successful
+ lookup, the module has it's resource counter incremented. */
+gcry_module_t
+_gcry_module_lookup_id (gcry_module_t entries, unsigned int mod_id)
+{
+ gcry_module_t entry;
+
+ for (entry = entries; entry; entry = entry->next)
+ if (entry->mod_id == mod_id)
+ {
+ entry->counter++;
+ break;
+ }
+
+ return entry;
+}
+
+/* Lookup a module specification. After a successful lookup, the
+ module has it's resource counter incremented. FUNC is a function
+ provided by the caller, which is responsible for identifying the
+ wanted module. */
+gcry_module_t
+_gcry_module_lookup (gcry_module_t entries, void *data,
+ gcry_module_lookup_t func)
+{
+ gcry_module_t entry;
+
+ for (entry = entries; entry; entry = entry->next)
+ if ((*func) (entry->spec, data))
+ {
+ entry->counter++;
+ break;
+ }
+
+ return entry;
+}
+
+/* Release a module. In case the use-counter reaches zero, destroy
+ the module. Passing MODULE as NULL is a dummy operation (similar
+ to free()). */
+void
+_gcry_module_release (gcry_module_t module)
+{
+ if (module && ! --module->counter)
+ _gcry_module_drop (module);
+}
+
+/* Add a reference to a module. */
+void
+_gcry_module_use (gcry_module_t module)
+{
+ ++module->counter;
+}
+
+/* If LIST is zero, write the number of modules identified by MODULES
+ to LIST_LENGTH and return. If LIST is non-zero, the first
+ *LIST_LENGTH algorithm IDs are stored in LIST, which must be of
+ according size. In case there are less cipher modules than
+ *LIST_LENGTH, *LIST_LENGTH is updated to the correct number. */
+gcry_err_code_t
+_gcry_module_list (gcry_module_t modules,
+ int *list, int *list_length)
+{
+ gcry_err_code_t err = GPG_ERR_NO_ERROR;
+ gcry_module_t module;
+ int length, i;
+
+ for (module = modules, length = 0; module; module = module->next, length++);
+
+ if (list)
+ {
+ if (length > *list_length)
+ length = *list_length;
+
+ for (module = modules, i = 0; i < length; module = module->next, i++)
+ list[i] = module->mod_id;
+
+ if (length < *list_length)
+ *list_length = length;
+ }
+ else
+ *list_length = length;
+
+ return err;
+}
diff --git a/grub-core/lib/libgcrypt/src/mpi.h b/grub-core/lib/libgcrypt/src/mpi.h
new file mode 100644
index 0000000..5883196
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/mpi.h
@@ -0,0 +1,266 @@
+/* mpi.h - Multi Precision Integers
+ * Copyright (C) 1994, 1996, 1998,
+ * 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ */
+
+#ifndef G10_MPI_H
+#define G10_MPI_H
+
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "types.h"
+#include "../mpi/mpi-asm-defs.h"
+
+#include "g10lib.h"
+
+#ifndef _GCRYPT_IN_LIBGCRYPT
+#error this file should only be used inside libgcrypt
+#endif
+
+#ifndef BITS_PER_MPI_LIMB
+#if BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_INT
+ typedef unsigned int mpi_limb_t;
+ typedef signed int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_LONG
+ typedef unsigned long int mpi_limb_t;
+ typedef signed long int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_LONG_LONG
+ typedef unsigned long long int mpi_limb_t;
+ typedef signed long long int mpi_limb_signed_t;
+#elif BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_SHORT
+ typedef unsigned short int mpi_limb_t;
+ typedef signed short int mpi_limb_signed_t;
+#else
+#error BYTES_PER_MPI_LIMB does not match any C type
+#endif
+#define BITS_PER_MPI_LIMB (8*BYTES_PER_MPI_LIMB)
+#endif /*BITS_PER_MPI_LIMB*/
+
+#define DBG_MPI _gcry_get_debug_flag( 2 );
+
+struct gcry_mpi
+{
+ int alloced; /* Array size (# of allocated limbs). */
+ int nlimbs; /* Number of valid limbs. */
+ int sign; /* Indicates a negative number and is also used
+ for opaque MPIs to store the length. */
+ unsigned int flags; /* Bit 0: Array to be allocated in secure memory space.*/
+ /* Bit 2: the limb is a pointer to some m_alloced data.*/
+ mpi_limb_t *d; /* Array with the limbs */
+};
+
+#define MPI_NULL NULL
+
+#define mpi_get_nlimbs(a) ((a)->nlimbs)
+#define mpi_is_neg(a) ((a)->sign)
+
+/*-- mpiutil.c --*/
+
+#ifdef M_DEBUG
+# define mpi_alloc(n) _gcry_mpi_debug_alloc((n), M_DBGINFO( __LINE__ ) )
+# define mpi_alloc_secure(n) _gcry_mpi_debug_alloc_secure((n), M_DBGINFO( __LINE__ ) )
+# define mpi_free(a) _gcry_mpi_debug_free((a), M_DBGINFO(__LINE__) )
+# define mpi_resize(a,b) _gcry_mpi_debug_resize((a),(b), M_DBGINFO(__LINE__) )
+# define mpi_copy(a) _gcry_mpi_debug_copy((a), M_DBGINFO(__LINE__) )
+ gcry_mpi_t _gcry_mpi_debug_alloc( unsigned nlimbs, const char *info );
+ gcry_mpi_t _gcry_mpi_debug_alloc_secure( unsigned nlimbs, const char *info );
+ void _gcry_mpi_debug_free( gcry_mpi_t a, const char *info );
+ void _gcry_mpi_debug_resize( gcry_mpi_t a, unsigned nlimbs, const char *info );
+ gcry_mpi_t _gcry_mpi_debug_copy( gcry_mpi_t a, const char *info );
+#else
+# define mpi_alloc(n) _gcry_mpi_alloc((n) )
+# define mpi_alloc_secure(n) _gcry_mpi_alloc_secure((n) )
+# define mpi_free(a) _gcry_mpi_free((a) )
+# define mpi_resize(a,b) _gcry_mpi_resize((a),(b))
+# define mpi_copy(a) _gcry_mpi_copy((a))
+ gcry_mpi_t _gcry_mpi_alloc( unsigned nlimbs );
+ gcry_mpi_t _gcry_mpi_alloc_secure( unsigned nlimbs );
+ void _gcry_mpi_free( gcry_mpi_t a );
+ void _gcry_mpi_resize( gcry_mpi_t a, unsigned nlimbs );
+ gcry_mpi_t _gcry_mpi_copy( gcry_mpi_t a );
+#endif
+
+#define gcry_mpi_copy _gcry_mpi_copy
+
+#define mpi_is_opaque(a) ((a) && ((a)->flags&4))
+#define mpi_is_secure(a) ((a) && ((a)->flags&1))
+#define mpi_clear(a) _gcry_mpi_clear ((a))
+#define mpi_alloc_like(a) _gcry_mpi_alloc_like((a))
+#define mpi_set(a,b) gcry_mpi_set ((a),(b))
+#define mpi_set_ui(a,b) gcry_mpi_set_ui ((a),(b))
+#define mpi_get_ui(a,b) _gcry_mpi_get_ui ((a),(b))
+#define mpi_alloc_set_ui(a) _gcry_mpi_alloc_set_ui ((a))
+#define mpi_m_check(a) _gcry_mpi_m_check ((a))
+#define mpi_swap(a,b) _gcry_mpi_swap ((a),(b))
+#define mpi_new(n) _gcry_mpi_new ((n))
+#define mpi_snew(n) _gcry_mpi_snew ((n))
+
+void _gcry_mpi_clear( gcry_mpi_t a );
+gcry_mpi_t _gcry_mpi_alloc_like( gcry_mpi_t a );
+gcry_mpi_t _gcry_mpi_alloc_set_ui( unsigned long u);
+gcry_err_code_t _gcry_mpi_get_ui (gcry_mpi_t w, ulong *u);
+gcry_err_code_t gcry_mpi_get_ui (gcry_mpi_t w, ulong *u);
+void _gcry_mpi_m_check( gcry_mpi_t a );
+void _gcry_mpi_swap( gcry_mpi_t a, gcry_mpi_t b);
+gcry_mpi_t _gcry_mpi_new (unsigned int nbits);
+gcry_mpi_t _gcry_mpi_snew (unsigned int nbits);
+
+/*-- mpicoder.c --*/
+void _gcry_log_mpidump( const char *text, gcry_mpi_t a );
+u32 _gcry_mpi_get_keyid( gcry_mpi_t a, u32 *keyid );
+byte *_gcry_mpi_get_buffer( gcry_mpi_t a, unsigned *nbytes, int *sign );
+byte *_gcry_mpi_get_secure_buffer( gcry_mpi_t a, unsigned *nbytes, int *sign );
+void _gcry_mpi_set_buffer ( gcry_mpi_t a, const void *buffer,
+ unsigned int nbytes, int sign );
+
+#define log_mpidump _gcry_log_mpidump
+
+/*-- mpi-add.c --*/
+#define mpi_add_ui(w,u,v) gcry_mpi_add_ui((w),(u),(v))
+#define mpi_add(w,u,v) gcry_mpi_add ((w),(u),(v))
+#define mpi_addm(w,u,v,m) gcry_mpi_addm ((w),(u),(v),(m))
+#define mpi_sub_ui(w,u,v) gcry_mpi_sub_ui ((w),(u),(v))
+#define mpi_sub(w,u,v) gcry_mpi_sub ((w),(u),(v))
+#define mpi_subm(w,u,v,m) gcry_mpi_subm ((w),(u),(v),(m))
+
+
+/*-- mpi-mul.c --*/
+#define mpi_mul_ui(w,u,v) gcry_mpi_mul_ui ((w),(u),(v))
+#define mpi_mul_2exp(w,u,v) gcry_mpi_mul_2exp ((w),(u),(v))
+#define mpi_mul(w,u,v) gcry_mpi_mul ((w),(u),(v))
+#define mpi_mulm(w,u,v,m) gcry_mpi_mulm ((w),(u),(v),(m))
+
+
+/*-- mpi-div.c --*/
+#define mpi_fdiv_r_ui(a,b,c) _gcry_mpi_fdiv_r_ui((a),(b),(c))
+#define mpi_fdiv_r(a,b,c) _gcry_mpi_fdiv_r((a),(b),(c))
+#define mpi_fdiv_q(a,b,c) _gcry_mpi_fdiv_q((a),(b),(c))
+#define mpi_fdiv_qr(a,b,c,d) _gcry_mpi_fdiv_qr((a),(b),(c),(d))
+#define mpi_tdiv_r(a,b,c) _gcry_mpi_tdiv_r((a),(b),(c))
+#define mpi_tdiv_qr(a,b,c,d) _gcry_mpi_tdiv_qr((a),(b),(c),(d))
+#define mpi_tdiv_q_2exp(a,b,c) _gcry_mpi_tdiv_q_2exp((a),(b),(c))
+#define mpi_divisible_ui(a,b) _gcry_mpi_divisible_ui((a),(b))
+
+ulong _gcry_mpi_fdiv_r_ui( gcry_mpi_t rem, gcry_mpi_t dividend, ulong divisor );
+void _gcry_mpi_fdiv_r( gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor );
+void _gcry_mpi_fdiv_q( gcry_mpi_t quot, gcry_mpi_t dividend, gcry_mpi_t divisor );
+void _gcry_mpi_fdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor );
+void _gcry_mpi_tdiv_r( gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t den);
+void _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t den);
+void _gcry_mpi_tdiv_q_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned count );
+int _gcry_mpi_divisible_ui(gcry_mpi_t dividend, ulong divisor );
+
+
+/*-- mpi-mod.c --*/
+#define mpi_mod(r,a,m) _gcry_mpi_mod ((r), (a), (m))
+#define mpi_barrett_init(m,f) _gcry_mpi_barrett_init ((m),(f))
+#define mpi_barrett_free(c) _gcry_mpi_barrett_free ((c))
+#define mpi_mod_barrett(r,a,c) _gcry_mpi_mod_barrett ((r), (a), (c))
+#define mpi_mul_barrett(r,u,v,c) _gcry_mpi_mul_barrett ((r), (u), (v), (c))
+
+void _gcry_mpi_mod (gcry_mpi_t r, gcry_mpi_t dividend, gcry_mpi_t divisor);
+
+/* Context used with Barrett reduction. */
+struct barrett_ctx_s;
+typedef struct barrett_ctx_s *mpi_barrett_t;
+
+mpi_barrett_t _gcry_mpi_barrett_init (gcry_mpi_t m, int copy);
+void _gcry_mpi_barrett_free (mpi_barrett_t ctx);
+void _gcry_mpi_mod_barrett (gcry_mpi_t r, gcry_mpi_t x, mpi_barrett_t ctx);
+void _gcry_mpi_mul_barrett (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v,
+ mpi_barrett_t ctx);
+
+
+
+/*-- mpi-gcd.c --*/
+
+/*-- mpi-mpow.c --*/
+#define mpi_mulpowm(a,b,c,d) _gcry_mpi_mulpowm ((a),(b),(c),(d))
+void _gcry_mpi_mulpowm( gcry_mpi_t res, gcry_mpi_t *basearray, gcry_mpi_t *exparray, gcry_mpi_t mod);
+
+/*-- mpi-cmp.c --*/
+#define mpi_cmp_ui(a,b) gcry_mpi_cmp_ui ((a),(b))
+#define mpi_cmp(a,b) gcry_mpi_cmp ((a),(b))
+int gcry_mpi_cmp_ui( gcry_mpi_t u, ulong v );
+int gcry_mpi_cmp( gcry_mpi_t u, gcry_mpi_t v );
+
+/*-- mpi-scan.c --*/
+#define mpi_trailing_zeros(a) _gcry_mpi_trailing_zeros ((a))
+int _gcry_mpi_getbyte( gcry_mpi_t a, unsigned idx );
+void _gcry_mpi_putbyte( gcry_mpi_t a, unsigned idx, int value );
+unsigned _gcry_mpi_trailing_zeros( gcry_mpi_t a );
+
+/*-- mpi-bit.c --*/
+#define mpi_normalize(a) _gcry_mpi_normalize ((a))
+#define mpi_get_nbits(a) gcry_mpi_get_nbits ((a))
+#define mpi_test_bit(a,b) gcry_mpi_test_bit ((a),(b))
+#define mpi_set_bit(a,b) gcry_mpi_set_bit ((a),(b))
+#define mpi_set_highbit(a,b) gcry_mpi_set_highbit ((a),(b))
+#define mpi_clear_bit(a,b) gcry_mpi_clear_bit ((a),(b))
+#define mpi_clear_highbit(a,b) gcry_mpi_clear_highbit ((a),(b))
+#define mpi_rshift(a,b,c) gcry_mpi_rshift ((a),(b),(c))
+#define mpi_lshift(a,b,c) gcry_mpi_lshift ((a),(b),(c))
+
+void _gcry_mpi_normalize( gcry_mpi_t a );
+
+/*-- mpi-inv.c --*/
+#define mpi_invm(a,b,c) gcry_mpi_invm ((a),(b),(c))
+
+/*-- ec.c --*/
+
+/* Object to represent a point in projective coordinates. */
+struct mpi_point_s;
+typedef struct mpi_point_s mpi_point_t;
+struct mpi_point_s
+{
+ gcry_mpi_t x;
+ gcry_mpi_t y;
+ gcry_mpi_t z;
+};
+
+/* Context used with elliptic curve functions. */
+struct mpi_ec_ctx_s;
+typedef struct mpi_ec_ctx_s *mpi_ec_t;
+
+void _gcry_mpi_ec_point_init (mpi_point_t *p);
+void _gcry_mpi_ec_point_free (mpi_point_t *p);
+mpi_ec_t _gcry_mpi_ec_init (gcry_mpi_t p, gcry_mpi_t a);
+void _gcry_mpi_ec_free (mpi_ec_t ctx);
+int _gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, mpi_point_t *point,
+ mpi_ec_t ctx);
+void _gcry_mpi_ec_dup_point (mpi_point_t *result,
+ mpi_point_t *point, mpi_ec_t ctx);
+void _gcry_mpi_ec_add_points (mpi_point_t *result,
+ mpi_point_t *p1, mpi_point_t *p2,
+ mpi_ec_t ctx);
+void _gcry_mpi_ec_mul_point (mpi_point_t *result,
+ gcry_mpi_t scalar, mpi_point_t *point,
+ mpi_ec_t ctx);
+
+
+
+#endif /*G10_MPI_H*/
diff --git a/grub-core/lib/libgcrypt/src/secmem.c b/grub-core/lib/libgcrypt/src/secmem.c
new file mode 100644
index 0000000..2beb234
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/secmem.c
@@ -0,0 +1,696 @@
+/* secmem.c - memory allocation from a secure heap
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002,
+ * 2003, 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <stddef.h>
+
+#if defined(HAVE_MLOCK) || defined(HAVE_MMAP)
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#ifdef USE_CAPABILITIES
+#include <sys/capability.h>
+#endif
+#endif
+
+#include "ath.h"
+#include "g10lib.h"
+#include "secmem.h"
+
+#if defined (MAP_ANON) && ! defined (MAP_ANONYMOUS)
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
+#define MINIMUM_POOL_SIZE 16384
+#define STANDARD_POOL_SIZE 32768
+#define DEFAULT_PAGE_SIZE 4096
+
+typedef struct memblock
+{
+ unsigned size; /* Size of the memory available to the
+ user. */
+ int flags; /* See below. */
+ PROPERLY_ALIGNED_TYPE aligned;
+} memblock_t;
+
+/* This flag specifies that the memory block is in use. */
+#define MB_FLAG_ACTIVE (1 << 0)
+
+/* The pool of secure memory. */
+static void *pool;
+
+/* Size of POOL in bytes. */
+static size_t pool_size;
+
+/* True, if the memory pool is ready for use. May be checked in an
+ atexit function. */
+static volatile int pool_okay;
+
+/* True, if the memory pool is mmapped. */
+static volatile int pool_is_mmapped;
+
+/* FIXME? */
+static int disable_secmem;
+static int show_warning;
+static int not_locked;
+static int no_warning;
+static int suspend_warning;
+
+/* Stats. */
+static unsigned int cur_alloced, cur_blocks;
+
+/* Lock protecting accesses to the memory pool. */
+static ath_mutex_t secmem_lock;
+
+/* Convenient macros. */
+#define SECMEM_LOCK ath_mutex_lock (&secmem_lock)
+#define SECMEM_UNLOCK ath_mutex_unlock (&secmem_lock)
+
+/* The size of the memblock structure; this does not include the
+ memory that is available to the user. */
+#define BLOCK_HEAD_SIZE \
+ offsetof (memblock_t, aligned)
+
+/* Convert an address into the according memory block structure. */
+#define ADDR_TO_BLOCK(addr) \
+ (memblock_t *) ((char *) addr - BLOCK_HEAD_SIZE)
+
+/* Check whether P points into the pool. */
+static int
+ptr_into_pool_p (const void *p)
+{
+ /* We need to convert pointers to addresses. This is required by
+ C-99 6.5.8 to avoid undefined behaviour. Using size_t is at
+ least only implementation defined. See also
+ http://lists.gnupg.org/pipermail/gcrypt-devel/2007-February/001102.html
+ */
+ size_t p_addr = (size_t)p;
+ size_t pool_addr = (size_t)pool;
+
+ return p_addr >= pool_addr && p_addr < pool_addr+pool_size;
+}
+
+/* Update the stats. */
+static void
+stats_update (size_t add, size_t sub)
+{
+ if (add)
+ {
+ cur_alloced += add;
+ cur_blocks++;
+ }
+ if (sub)
+ {
+ cur_alloced -= sub;
+ cur_blocks--;
+ }
+}
+
+/* Return the block following MB or NULL, if MB is the last block. */
+static memblock_t *
+mb_get_next (memblock_t *mb)
+{
+ memblock_t *mb_next;
+
+ mb_next = (memblock_t *) ((char *) mb + BLOCK_HEAD_SIZE + mb->size);
+
+ if (! ptr_into_pool_p (mb_next))
+ mb_next = NULL;
+
+ return mb_next;
+}
+
+/* Return the block preceding MB or NULL, if MB is the first
+ block. */
+static memblock_t *
+mb_get_prev (memblock_t *mb)
+{
+ memblock_t *mb_prev, *mb_next;
+
+ if (mb == pool)
+ mb_prev = NULL;
+ else
+ {
+ mb_prev = (memblock_t *) pool;
+ while (1)
+ {
+ mb_next = mb_get_next (mb_prev);
+ if (mb_next == mb)
+ break;
+ else
+ mb_prev = mb_next;
+ }
+ }
+
+ return mb_prev;
+}
+
+/* If the preceding block of MB and/or the following block of MB
+ exist and are not active, merge them to form a bigger block. */
+static void
+mb_merge (memblock_t *mb)
+{
+ memblock_t *mb_prev, *mb_next;
+
+ mb_prev = mb_get_prev (mb);
+ mb_next = mb_get_next (mb);
+
+ if (mb_prev && (! (mb_prev->flags & MB_FLAG_ACTIVE)))
+ {
+ mb_prev->size += BLOCK_HEAD_SIZE + mb->size;
+ mb = mb_prev;
+ }
+ if (mb_next && (! (mb_next->flags & MB_FLAG_ACTIVE)))
+ mb->size += BLOCK_HEAD_SIZE + mb_next->size;
+}
+
+/* Return a new block, which can hold SIZE bytes. */
+static memblock_t *
+mb_get_new (memblock_t *block, size_t size)
+{
+ memblock_t *mb, *mb_split;
+
+ for (mb = block; ptr_into_pool_p (mb); mb = mb_get_next (mb))
+ if (! (mb->flags & MB_FLAG_ACTIVE) && mb->size >= size)
+ {
+ /* Found a free block. */
+ mb->flags |= MB_FLAG_ACTIVE;
+
+ if (mb->size - size > BLOCK_HEAD_SIZE)
+ {
+ /* Split block. */
+
+ mb_split = (memblock_t *) (((char *) mb) + BLOCK_HEAD_SIZE + size);
+ mb_split->size = mb->size - size - BLOCK_HEAD_SIZE;
+ mb_split->flags = 0;
+
+ mb->size = size;
+
+ mb_merge (mb_split);
+
+ }
+
+ break;
+ }
+
+ if (! ptr_into_pool_p (mb))
+ {
+ gpg_err_set_errno (ENOMEM);
+ mb = NULL;
+ }
+
+ return mb;
+}
+
+/* Print a warning message. */
+static void
+print_warn (void)
+{
+ if (!no_warning)
+ log_info (_("Warning: using insecure memory!\n"));
+}
+
+/* Lock the memory pages into core and drop privileges. */
+static void
+lock_pool (void *p, size_t n)
+{
+#if defined(USE_CAPABILITIES) && defined(HAVE_MLOCK)
+ int err;
+
+ cap_set_proc (cap_from_text ("cap_ipc_lock+ep"));
+ err = mlock (p, n);
+ if (err && errno)
+ err = errno;
+ cap_set_proc (cap_from_text ("cap_ipc_lock+p"));
+
+ if (err)
+ {
+ if (errno != EPERM
+#ifdef EAGAIN /* OpenBSD returns this */
+ && errno != EAGAIN
+#endif
+#ifdef ENOSYS /* Some SCOs return this (function not implemented) */
+ && errno != ENOSYS
+#endif
+#ifdef ENOMEM /* Linux might return this. */
+ && errno != ENOMEM
+#endif
+ )
+ log_error ("can't lock memory: %s\n", strerror (err));
+ show_warning = 1;
+ not_locked = 1;
+ }
+
+#elif defined(HAVE_MLOCK)
+ uid_t uid;
+ int err;
+
+ uid = getuid ();
+
+#ifdef HAVE_BROKEN_MLOCK
+ /* Under HP/UX mlock segfaults if called by non-root. Note, we have
+ noch checked whether mlock does really work under AIX where we
+ also detected a broken nlock. Note further, that using plock ()
+ is not a good idea under AIX. */
+ if (uid)
+ {
+ errno = EPERM;
+ err = errno;
+ }
+ else
+ {
+ err = mlock (p, n);
+ if (err && errno)
+ err = errno;
+ }
+#else /* !HAVE_BROKEN_MLOCK */
+ err = mlock (p, n);
+ if (err && errno)
+ err = errno;
+#endif /* !HAVE_BROKEN_MLOCK */
+
+ if (uid && ! geteuid ())
+ {
+ /* check that we really dropped the privs.
+ * Note: setuid(0) should always fail */
+ if (setuid (uid) || getuid () != geteuid () || !setuid (0))
+ log_fatal ("failed to reset uid: %s\n", strerror (errno));
+ }
+
+ if (err)
+ {
+ if (errno != EPERM
+#ifdef EAGAIN /* OpenBSD returns this. */
+ && errno != EAGAIN
+#endif
+#ifdef ENOSYS /* Some SCOs return this (function not implemented). */
+ && errno != ENOSYS
+#endif
+#ifdef ENOMEM /* Linux might return this. */
+ && errno != ENOMEM
+#endif
+ )
+ log_error ("can't lock memory: %s\n", strerror (err));
+ show_warning = 1;
+ not_locked = 1;
+ }
+
+#elif defined ( __QNX__ )
+ /* QNX does not page at all, so the whole secure memory stuff does
+ * not make much sense. However it is still of use because it
+ * wipes out the memory on a free().
+ * Therefore it is sufficient to suppress the warning. */
+ (void)p;
+ (void)n;
+#elif defined (HAVE_DOSISH_SYSTEM) || defined (__CYGWIN__)
+ /* It does not make sense to print such a warning, given the fact that
+ * this whole Windows !@#$% and their user base are inherently insecure. */
+ (void)p;
+ (void)n;
+#elif defined (__riscos__)
+ /* No virtual memory on RISC OS, so no pages are swapped to disc,
+ * besides we don't have mmap, so we don't use it! ;-)
+ * But don't complain, as explained above. */
+ (void)p;
+ (void)n;
+#else
+ (void)p;
+ (void)n;
+ log_info ("Please note that you don't have secure memory on this system\n");
+#endif
+}
+
+/* Initialize POOL. */
+static void
+init_pool (size_t n)
+{
+ size_t pgsize;
+ long int pgsize_val;
+ memblock_t *mb;
+
+ pool_size = n;
+
+ if (disable_secmem)
+ log_bug ("secure memory is disabled");
+
+#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+ pgsize_val = sysconf (_SC_PAGESIZE);
+#elif defined(HAVE_GETPAGESIZE)
+ pgsize_val = getpagesize ();
+#else
+ pgsize_val = -1;
+#endif
+ pgsize = (pgsize_val != -1 && pgsize_val > 0)? pgsize_val:DEFAULT_PAGE_SIZE;
+
+
+#if HAVE_MMAP
+ pool_size = (pool_size + pgsize - 1) & ~(pgsize - 1);
+#ifdef MAP_ANONYMOUS
+ pool = mmap (0, pool_size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+#else /* map /dev/zero instead */
+ {
+ int fd;
+
+ fd = open ("/dev/zero", O_RDWR);
+ if (fd == -1)
+ {
+ log_error ("can't open /dev/zero: %s\n", strerror (errno));
+ pool = (void *) -1;
+ }
+ else
+ {
+ pool = mmap (0, pool_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+ close (fd);
+ }
+ }
+#endif
+ if (pool == (void *) -1)
+ log_info ("can't mmap pool of %u bytes: %s - using malloc\n",
+ (unsigned) pool_size, strerror (errno));
+ else
+ {
+ pool_is_mmapped = 1;
+ pool_okay = 1;
+ }
+
+#endif
+ if (!pool_okay)
+ {
+ pool = malloc (pool_size);
+ if (!pool)
+ log_fatal ("can't allocate memory pool of %u bytes\n",
+ (unsigned) pool_size);
+ else
+ pool_okay = 1;
+ }
+
+ /* Initialize first memory block. */
+ mb = (memblock_t *) pool;
+ mb->size = pool_size;
+ mb->flags = 0;
+}
+
+void
+_gcry_secmem_set_flags (unsigned flags)
+{
+ int was_susp;
+
+ SECMEM_LOCK;
+
+ was_susp = suspend_warning;
+ no_warning = flags & GCRY_SECMEM_FLAG_NO_WARNING;
+ suspend_warning = flags & GCRY_SECMEM_FLAG_SUSPEND_WARNING;
+
+ /* and now issue the warning if it is not longer suspended */
+ if (was_susp && !suspend_warning && show_warning)
+ {
+ show_warning = 0;
+ print_warn ();
+ }
+
+ SECMEM_UNLOCK;
+}
+
+unsigned int
+_gcry_secmem_get_flags (void)
+{
+ unsigned flags;
+
+ SECMEM_LOCK;
+
+ flags = no_warning ? GCRY_SECMEM_FLAG_NO_WARNING : 0;
+ flags |= suspend_warning ? GCRY_SECMEM_FLAG_SUSPEND_WARNING : 0;
+ flags |= not_locked ? GCRY_SECMEM_FLAG_NOT_LOCKED : 0;
+
+ SECMEM_UNLOCK;
+
+ return flags;
+}
+
+
+/* See _gcry_secmem_init. This function is expected to be called with
+ the secmem lock held. */
+static void
+secmem_init (size_t n)
+{
+ if (!n)
+ {
+#ifdef USE_CAPABILITIES
+ /* drop all capabilities */
+ cap_set_proc (cap_from_text ("all-eip"));
+
+#elif !defined(HAVE_DOSISH_SYSTEM)
+ uid_t uid;
+
+ disable_secmem = 1;
+ uid = getuid ();
+ if (uid != geteuid ())
+ {
+ if (setuid (uid) || getuid () != geteuid () || !setuid (0))
+ log_fatal ("failed to drop setuid\n");
+ }
+#endif
+ }
+ else
+ {
+ if (n < MINIMUM_POOL_SIZE)
+ n = MINIMUM_POOL_SIZE;
+ if (! pool_okay)
+ {
+ init_pool (n);
+ lock_pool (pool, n);
+ }
+ else
+ log_error ("Oops, secure memory pool already initialized\n");
+ }
+}
+
+
+
+/* Initialize the secure memory system. If running with the necessary
+ privileges, the secure memory pool will be locked into the core in
+ order to prevent page-outs of the data. Furthermore allocated
+ secure memory will be wiped out when released. */
+void
+_gcry_secmem_init (size_t n)
+{
+ SECMEM_LOCK;
+
+ secmem_init (n);
+
+ SECMEM_UNLOCK;
+}
+
+
+static void *
+_gcry_secmem_malloc_internal (size_t size)
+{
+ memblock_t *mb;
+
+ if (!pool_okay)
+ {
+ /* Try to initialize the pool if the user forgot about it. */
+ secmem_init (STANDARD_POOL_SIZE);
+ if (!pool_okay)
+ {
+ log_info (_("operation is not possible without "
+ "initialized secure memory\n"));
+ gpg_err_set_errno (ENOMEM);
+ return NULL;
+ }
+ }
+ if (not_locked && fips_mode ())
+ {
+ log_info (_("secure memory pool is not locked while in FIPS mode\n"));
+ gpg_err_set_errno (ENOMEM);
+ return NULL;
+ }
+ if (show_warning && !suspend_warning)
+ {
+ show_warning = 0;
+ print_warn ();
+ }
+
+ /* Blocks are always a multiple of 32. */
+ size = ((size + 31) / 32) * 32;
+
+ mb = mb_get_new ((memblock_t *) pool, size);
+ if (mb)
+ stats_update (size, 0);
+
+ return mb ? &mb->aligned.c : NULL;
+}
+
+void *
+_gcry_secmem_malloc (size_t size)
+{
+ void *p;
+
+ SECMEM_LOCK;
+ p = _gcry_secmem_malloc_internal (size);
+ SECMEM_UNLOCK;
+
+ return p;
+}
+
+static void
+_gcry_secmem_free_internal (void *a)
+{
+ memblock_t *mb;
+ int size;
+
+ if (!a)
+ return;
+
+ mb = ADDR_TO_BLOCK (a);
+ size = mb->size;
+
+ /* This does not make much sense: probably this memory is held in the
+ * cache. We do it anyway: */
+#define MB_WIPE_OUT(byte) \
+ wipememory2 ((memblock_t *) ((char *) mb + BLOCK_HEAD_SIZE), (byte), size);
+
+ MB_WIPE_OUT (0xff);
+ MB_WIPE_OUT (0xaa);
+ MB_WIPE_OUT (0x55);
+ MB_WIPE_OUT (0x00);
+
+ stats_update (0, size);
+
+ mb->flags &= ~MB_FLAG_ACTIVE;
+
+ /* Update stats. */
+
+ mb_merge (mb);
+}
+
+/* Wipe out and release memory. */
+void
+_gcry_secmem_free (void *a)
+{
+ SECMEM_LOCK;
+ _gcry_secmem_free_internal (a);
+ SECMEM_UNLOCK;
+}
+
+/* Realloc memory. */
+void *
+_gcry_secmem_realloc (void *p, size_t newsize)
+{
+ memblock_t *mb;
+ size_t size;
+ void *a;
+
+ SECMEM_LOCK;
+
+ mb = (memblock_t *) ((char *) p - ((size_t) &((memblock_t *) 0)->aligned.c));
+ size = mb->size;
+ if (newsize < size)
+ {
+ /* It is easier to not shrink the memory. */
+ a = p;
+ }
+ else
+ {
+ a = _gcry_secmem_malloc_internal (newsize);
+ if (a)
+ {
+ memcpy (a, p, size);
+ memset ((char *) a + size, 0, newsize - size);
+ _gcry_secmem_free_internal (p);
+ }
+ }
+
+ SECMEM_UNLOCK;
+
+ return a;
+}
+
+
+/* Return true if P points into the secure memory area. */
+int
+_gcry_private_is_secure (const void *p)
+{
+ return pool_okay && ptr_into_pool_p (p);
+}
+
+
+/****************
+ * Warning: This code might be called by an interrupt handler
+ * and frankly, there should really be such a handler,
+ * to make sure that the memory is wiped out.
+ * We hope that the OS wipes out mlocked memory after
+ * receiving a SIGKILL - it really should do so, otherwise
+ * there is no chance to get the secure memory cleaned.
+ */
+void
+_gcry_secmem_term ()
+{
+ if (!pool_okay)
+ return;
+
+ wipememory2 (pool, 0xff, pool_size);
+ wipememory2 (pool, 0xaa, pool_size);
+ wipememory2 (pool, 0x55, pool_size);
+ wipememory2 (pool, 0x00, pool_size);
+#if HAVE_MMAP
+ if (pool_is_mmapped)
+ munmap (pool, pool_size);
+#endif
+ pool = NULL;
+ pool_okay = 0;
+ pool_size = 0;
+ not_locked = 0;
+}
+
+
+void
+_gcry_secmem_dump_stats ()
+{
+#if 1
+ SECMEM_LOCK;
+
+ if (pool_okay)
+ log_info ("secmem usage: %u/%lu bytes in %u blocks\n",
+ cur_alloced, (unsigned long)pool_size, cur_blocks);
+ SECMEM_UNLOCK;
+#else
+ memblock_t *mb;
+ int i;
+
+ SECMEM_LOCK;
+
+ for (i = 0, mb = (memblock_t *) pool;
+ ptr_into_pool_p (mb);
+ mb = mb_get_next (mb), i++)
+ log_info ("SECMEM: [%s] block: %i; size: %i\n",
+ (mb->flags & MB_FLAG_ACTIVE) ? "used" : "free",
+ i,
+ mb->size);
+ SECMEM_UNLOCK;
+#endif
+}
diff --git a/grub-core/lib/libgcrypt/src/secmem.h b/grub-core/lib/libgcrypt/src/secmem.h
new file mode 100644
index 0000000..29e151a
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/secmem.h
@@ -0,0 +1,39 @@
+/* secmem.h - internal definitions for secmem
+ * Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef G10_SECMEM_H
+#define G10_SECMEM_H 1
+
+void _gcry_secmem_init (size_t npool);
+void _gcry_secmem_term (void);
+void *_gcry_secmem_malloc (size_t size) _GCRY_GCC_ATTR_MALLOC;
+void *_gcry_secmem_realloc (void *a, size_t newsize);
+void _gcry_secmem_free (void *a);
+void _gcry_secmem_dump_stats (void);
+void _gcry_secmem_set_flags (unsigned flags);
+unsigned _gcry_secmem_get_flags(void);
+int _gcry_private_is_secure (const void *p);
+
+/* Flags for _gcry_secmem_{set,get}_flags. */
+#define GCRY_SECMEM_FLAG_NO_WARNING (1 << 0)
+#define GCRY_SECMEM_FLAG_SUSPEND_WARNING (1 << 1)
+#define GCRY_SECMEM_FLAG_NOT_LOCKED (1 << 2)
+
+#endif /* G10_SECMEM_H */
diff --git a/grub-core/lib/libgcrypt/src/sexp.c b/grub-core/lib/libgcrypt/src/sexp.c
new file mode 100644
index 0000000..78013fd
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/sexp.c
@@ -0,0 +1,2045 @@
+/* sexp.c - S-Expression handling
+ * Copyright (C) 1999, 2000, 2001, 2002, 2003,
+ * 2004, 2006, 2007, 2008, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <errno.h>
+
+#define GCRYPT_NO_MPI_MACROS 1
+#include "g10lib.h"
+
+typedef struct gcry_sexp *NODE;
+typedef unsigned short DATALEN;
+
+struct gcry_sexp
+{
+ byte d[1];
+};
+
+#define ST_STOP 0
+#define ST_DATA 1 /* datalen follows */
+#define ST_HINT 2 /* datalen follows */
+#define ST_OPEN 3
+#define ST_CLOSE 4
+
+/* the atoi macros assume that the buffer has only valid digits */
+#define atoi_1(p) (*(p) - '0' )
+#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
+ *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
+#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
+
+#define TOKEN_SPECIALS "-./_:*+="
+
+static gcry_error_t
+vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *buffer, size_t length, int argflag,
+ void **arg_list, va_list arg_ptr);
+
+static gcry_error_t
+sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *buffer, size_t length, int argflag,
+ void **arg_list, ...);
+
+/* Return true if P points to a byte containing a whitespace according
+ to the S-expressions definition. */
+#undef whitespacep
+static GPG_ERR_INLINE int
+whitespacep (const char *p)
+{
+ switch (*p)
+ {
+ case ' ': case '\t': case '\v': case '\f': case '\r': case '\n': return 1;
+ default: return 0;
+ }
+}
+
+
+#if 0
+static void
+dump_mpi( gcry_mpi_t a )
+{
+ char buffer[1000];
+ size_t n = 1000;
+
+ if( !a )
+ fputs("[no MPI]", stderr );
+ else if( gcry_mpi_print( GCRYMPI_FMT_HEX, buffer, &n, a ) )
+ fputs("[MPI too large to print]", stderr );
+ else
+ fputs( buffer, stderr );
+}
+#endif
+
+static void
+dump_string (const byte *p, size_t n, int delim )
+{
+ for (; n; n--, p++ )
+ {
+ if ((*p & 0x80) || iscntrl( *p ) || *p == delim )
+ {
+ if( *p == '\n' )
+ log_printf ("\\n");
+ else if( *p == '\r' )
+ log_printf ("\\r");
+ else if( *p == '\f' )
+ log_printf ("\\f");
+ else if( *p == '\v' )
+ log_printf ("\\v");
+ else if( *p == '\b' )
+ log_printf ("\\b");
+ else if( !*p )
+ log_printf ("\\0");
+ else
+ log_printf ("\\x%02x", *p );
+ }
+ else
+ log_printf ("%c", *p);
+ }
+}
+
+
+void
+gcry_sexp_dump (const gcry_sexp_t a)
+{
+ const byte *p;
+ int indent = 0;
+ int type;
+
+ if (!a)
+ {
+ log_printf ( "[nil]\n");
+ return;
+ }
+
+ p = a->d;
+ while ( (type = *p) != ST_STOP )
+ {
+ p++;
+ switch ( type )
+ {
+ case ST_OPEN:
+ log_printf ("%*s[open]\n", 2*indent, "");
+ indent++;
+ break;
+ case ST_CLOSE:
+ if( indent )
+ indent--;
+ log_printf ("%*s[close]\n", 2*indent, "");
+ break;
+ case ST_DATA: {
+ DATALEN n;
+ memcpy ( &n, p, sizeof n );
+ p += sizeof n;
+ log_printf ("%*s[data=\"", 2*indent, "" );
+ dump_string (p, n, '\"' );
+ log_printf ("\"]\n");
+ p += n;
+ }
+ break;
+ default:
+ log_printf ("%*s[unknown tag %d]\n", 2*indent, "", type);
+ break;
+ }
+ }
+}
+
+/****************
+ * Pass list through except when it is an empty list - in that case
+ * return NULL and release the passed list.
+ */
+static gcry_sexp_t
+normalize ( gcry_sexp_t list )
+{
+ unsigned char *p;
+
+ if ( !list )
+ return NULL;
+ p = list->d;
+ if ( *p == ST_STOP )
+ {
+ /* this is "" */
+ gcry_sexp_release ( list );
+ return NULL;
+ }
+ if ( *p == ST_OPEN && p[1] == ST_CLOSE )
+ {
+ /* this is "()" */
+ gcry_sexp_release ( list );
+ return NULL;
+ }
+
+ return list;
+}
+
+/* Create a new S-expression object by reading LENGTH bytes from
+ BUFFER, assuming it is canonical encoded or autodetected encoding
+ when AUTODETECT is set to 1. With FREEFNC not NULL, ownership of
+ the buffer is transferred to the newly created object. FREEFNC
+ should be the freefnc used to release BUFFER; there is no guarantee
+ at which point this function is called; most likey you want to use
+ free() or gcry_free().
+
+ Passing LENGTH and AUTODETECT as 0 is allowed to indicate that
+ BUFFER points to a valid canonical encoded S-expression. A LENGTH
+ of 0 and AUTODETECT 1 indicates that buffer points to a
+ null-terminated string.
+
+ This function returns 0 and and the pointer to the new object in
+ RETSEXP or an error code in which case RETSEXP is set to NULL. */
+gcry_error_t
+gcry_sexp_create (gcry_sexp_t *retsexp, void *buffer, size_t length,
+ int autodetect, void (*freefnc)(void*) )
+{
+ gcry_error_t errcode;
+ gcry_sexp_t se;
+
+ if (!retsexp)
+ return gcry_error (GPG_ERR_INV_ARG);
+ *retsexp = NULL;
+ if (autodetect < 0 || autodetect > 1 || !buffer)
+ return gcry_error (GPG_ERR_INV_ARG);
+
+ if (!length && !autodetect)
+ { /* What a brave caller to assume that there is really a canonical
+ encoded S-expression in buffer */
+ length = gcry_sexp_canon_len (buffer, 0, NULL, &errcode);
+ if (!length)
+ return errcode;
+ }
+ else if (!length && autodetect)
+ { /* buffer is a string */
+ length = strlen ((char *)buffer);
+ }
+
+ errcode = sexp_sscan (&se, NULL, buffer, length, 0, NULL);
+ if (errcode)
+ return errcode;
+
+ *retsexp = se;
+ if (freefnc)
+ {
+ /* For now we release the buffer immediately. As soon as we
+ have changed the internal represenation of S-expression to
+ the canoncial format - which has the advantage of faster
+ parsing - we will use this function as a closure in our
+ GCRYSEXP object and use the BUFFER directly. */
+ freefnc (buffer);
+ }
+ return gcry_error (GPG_ERR_NO_ERROR);
+}
+
+/* Same as gcry_sexp_create but don't transfer ownership */
+gcry_error_t
+gcry_sexp_new (gcry_sexp_t *retsexp, const void *buffer, size_t length,
+ int autodetect)
+{
+ return gcry_sexp_create (retsexp, (void *)buffer, length, autodetect, NULL);
+}
+
+
+/****************
+ * Release resource of the given SEXP object.
+ */
+void
+gcry_sexp_release( gcry_sexp_t sexp )
+{
+ if (sexp)
+ {
+ if (gcry_is_secure (sexp))
+ {
+ /* Extra paranoid wiping. */
+ const byte *p = sexp->d;
+ int type;
+
+ while ( (type = *p) != ST_STOP )
+ {
+ p++;
+ switch ( type )
+ {
+ case ST_OPEN:
+ break;
+ case ST_CLOSE:
+ break;
+ case ST_DATA:
+ {
+ DATALEN n;
+ memcpy ( &n, p, sizeof n );
+ p += sizeof n;
+ p += n;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ wipememory (sexp->d, p - sexp->d);
+ }
+ gcry_free ( sexp );
+ }
+}
+
+
+/****************
+ * Make a pair from lists a and b, don't use a or b later on.
+ * Special behaviour: If one is a single element list we put the
+ * element straight into the new pair.
+ */
+gcry_sexp_t
+gcry_sexp_cons( const gcry_sexp_t a, const gcry_sexp_t b )
+{
+ (void)a;
+ (void)b;
+
+ /* NYI: Implementation should be quite easy with our new data
+ representation */
+ BUG ();
+ return NULL;
+}
+
+
+/****************
+ * Make a list from all items in the array the end of the array is marked
+ * with a NULL.
+ */
+gcry_sexp_t
+gcry_sexp_alist( const gcry_sexp_t *array )
+{
+ (void)array;
+
+ /* NYI: Implementation should be quite easy with our new data
+ representation. */
+ BUG ();
+ return NULL;
+}
+
+/****************
+ * Make a list from all items, the end of list is indicated by a NULL
+ */
+gcry_sexp_t
+gcry_sexp_vlist( const gcry_sexp_t a, ... )
+{
+ (void)a;
+ /* NYI: Implementation should be quite easy with our new data
+ representation. */
+ BUG ();
+ return NULL;
+}
+
+
+/****************
+ * Append n to the list a
+ * Returns: a new ist (which maybe a)
+ */
+gcry_sexp_t
+gcry_sexp_append( const gcry_sexp_t a, const gcry_sexp_t n )
+{
+ (void)a;
+ (void)n;
+ /* NYI: Implementation should be quite easy with our new data
+ representation. */
+ BUG ();
+ return NULL;
+}
+
+gcry_sexp_t
+gcry_sexp_prepend( const gcry_sexp_t a, const gcry_sexp_t n )
+{
+ (void)a;
+ (void)n;
+ /* NYI: Implementation should be quite easy with our new data
+ representation. */
+ BUG ();
+ return NULL;
+}
+
+
+
+/****************
+ * Locate token in a list. The token must be the car of a sublist.
+ * Returns: A new list with this sublist or NULL if not found.
+ */
+gcry_sexp_t
+gcry_sexp_find_token( const gcry_sexp_t list, const char *tok, size_t toklen )
+{
+ const byte *p;
+ DATALEN n;
+
+ if ( !list )
+ return NULL;
+
+ if ( !toklen )
+ toklen = strlen(tok);
+
+ p = list->d;
+ while ( *p != ST_STOP )
+ {
+ if ( *p == ST_OPEN && p[1] == ST_DATA )
+ {
+ const byte *head = p;
+
+ p += 2;
+ memcpy ( &n, p, sizeof n );
+ p += sizeof n;
+ if ( n == toklen && !memcmp( p, tok, toklen ) )
+ { /* found it */
+ gcry_sexp_t newlist;
+ byte *d;
+ int level = 1;
+
+ /* Look for the end of the list. */
+ for ( p += n; level; p++ )
+ {
+ if ( *p == ST_DATA )
+ {
+ memcpy ( &n, ++p, sizeof n );
+ p += sizeof n + n;
+ p--; /* Compensate for later increment. */
+ }
+ else if ( *p == ST_OPEN )
+ {
+ level++;
+ }
+ else if ( *p == ST_CLOSE )
+ {
+ level--;
+ }
+ else if ( *p == ST_STOP )
+ {
+ BUG ();
+ }
+ }
+ n = p - head;
+
+ newlist = gcry_malloc ( sizeof *newlist + n );
+ if (!newlist)
+ {
+ /* No way to return an error code, so we can only
+ return Not Found. */
+ return NULL;
+ }
+ d = newlist->d;
+ memcpy ( d, head, n ); d += n;
+ *d++ = ST_STOP;
+ return normalize ( newlist );
+ }
+ p += n;
+ }
+ else if ( *p == ST_DATA )
+ {
+ memcpy ( &n, ++p, sizeof n ); p += sizeof n;
+ p += n;
+ }
+ else
+ p++;
+ }
+ return NULL;
+}
+
+/****************
+ * Return the length of the given list
+ */
+int
+gcry_sexp_length( const gcry_sexp_t list )
+{
+ const byte *p;
+ DATALEN n;
+ int type;
+ int length = 0;
+ int level = 0;
+
+ if ( !list )
+ return 0;
+
+ p = list->d;
+ while ( (type=*p) != ST_STOP ) {
+ p++;
+ if ( type == ST_DATA ) {
+ memcpy ( &n, p, sizeof n );
+ p += sizeof n + n;
+ if ( level == 1 )
+ length++;
+ }
+ else if ( type == ST_OPEN ) {
+ if ( level == 1 )
+ length++;
+ level++;
+ }
+ else if ( type == ST_CLOSE ) {
+ level--;
+ }
+ }
+ return length;
+}
+
+
+/* Return the internal lengths offset of LIST. That is the size of
+ the buffer from the first ST_OPEN, which is retruned at R_OFF, to
+ the corresponding ST_CLOSE inclusive. */
+static size_t
+get_internal_buffer (const gcry_sexp_t list, size_t *r_off)
+{
+ const unsigned char *p;
+ DATALEN n;
+ int type;
+ int level = 0;
+
+ *r_off = 0;
+ if (list)
+ {
+ p = list->d;
+ while ( (type=*p) != ST_STOP )
+ {
+ p++;
+ if (type == ST_DATA)
+ {
+ memcpy (&n, p, sizeof n);
+ p += sizeof n + n;
+ }
+ else if (type == ST_OPEN)
+ {
+ if (!level)
+ *r_off = (p-1) - list->d;
+ level++;
+ }
+ else if ( type == ST_CLOSE )
+ {
+ level--;
+ if (!level)
+ return p - list->d;
+ }
+ }
+ }
+ return 0; /* Not a proper list. */
+}
+
+
+
+/* Extract the CAR of the given list. May return NULL for bad lists
+ or memory failure. */
+gcry_sexp_t
+gcry_sexp_nth( const gcry_sexp_t list, int number )
+{
+ const byte *p;
+ DATALEN n;
+ gcry_sexp_t newlist;
+ byte *d;
+ int level = 0;
+
+ if ( !list || list->d[0] != ST_OPEN )
+ return NULL;
+ p = list->d;
+
+ while ( number > 0 ) {
+ p++;
+ if ( *p == ST_DATA ) {
+ memcpy ( &n, ++p, sizeof n );
+ p += sizeof n + n;
+ p--;
+ if ( !level )
+ number--;
+ }
+ else if ( *p == ST_OPEN ) {
+ level++;
+ }
+ else if ( *p == ST_CLOSE ) {
+ level--;
+ if ( !level )
+ number--;
+ }
+ else if ( *p == ST_STOP ) {
+ return NULL;
+ }
+ }
+ p++;
+
+ if ( *p == ST_DATA ) {
+ memcpy ( &n, p, sizeof n );
+ /* Allocate 1 (=sizeof *newlist) byte for ST_OPEN
+ 1 byte for ST_DATA
+ sizeof n byte for n
+ n byte for the data
+ 1 byte for ST_CLOSE
+ 1 byte for ST_STOP */
+ newlist = gcry_malloc ( sizeof *newlist + 1 + sizeof n + n + 2 );
+ if (!newlist)
+ return NULL;
+ d = newlist->d;
+ *d = ST_OPEN; /* Put the ST_OPEN flag */
+ d++; /* Move forward */
+ /* Copy ST_DATA, n and the data from p to d */
+ memcpy ( d, p, 1 + sizeof n + n );
+ d += 1 + sizeof n + n; /* Move after the data copied */
+ *d = ST_CLOSE; /* Put the ST_CLOSE flag */
+ d++; /* Move forward */
+ *d = ST_STOP; /* Put the ST_STOP flag */
+ }
+ else if ( *p == ST_OPEN ) {
+ const byte *head = p;
+
+ level = 1;
+ do {
+ p++;
+ if ( *p == ST_DATA ) {
+ memcpy ( &n, ++p, sizeof n );
+ p += sizeof n + n;
+ p--;
+ }
+ else if ( *p == ST_OPEN ) {
+ level++;
+ }
+ else if ( *p == ST_CLOSE ) {
+ level--;
+ }
+ else if ( *p == ST_STOP ) {
+ BUG ();
+ }
+ } while ( level );
+ n = p + 1 - head;
+
+ newlist = gcry_malloc ( sizeof *newlist + n );
+ if (!newlist)
+ return NULL;
+ d = newlist->d;
+ memcpy ( d, head, n ); d += n;
+ *d++ = ST_STOP;
+ }
+ else
+ newlist = NULL;
+
+ return normalize (newlist);
+}
+
+gcry_sexp_t
+gcry_sexp_car( const gcry_sexp_t list )
+{
+ return gcry_sexp_nth ( list, 0 );
+}
+
+
+/* Helper to get data from the car. The returned value is valid as
+ long as the list is not modified. */
+static const char *
+sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen)
+{
+ const byte *p;
+ DATALEN n;
+ int level = 0;
+
+ *datalen = 0;
+ if ( !list )
+ return NULL;
+
+ p = list->d;
+ if ( *p == ST_OPEN )
+ p++; /* Yep, a list. */
+ else if (number)
+ return NULL; /* Not a list but N > 0 requested. */
+
+ /* Skip over N elements. */
+ while ( number > 0 )
+ {
+ if ( *p == ST_DATA )
+ {
+ memcpy ( &n, ++p, sizeof n );
+ p += sizeof n + n;
+ p--;
+ if ( !level )
+ number--;
+ }
+ else if ( *p == ST_OPEN )
+ {
+ level++;
+ }
+ else if ( *p == ST_CLOSE )
+ {
+ level--;
+ if ( !level )
+ number--;
+ }
+ else if ( *p == ST_STOP )
+ {
+ return NULL;
+ }
+ p++;
+ }
+
+ /* If this is data, return it. */
+ if ( *p == ST_DATA )
+ {
+ memcpy ( &n, ++p, sizeof n );
+ *datalen = n;
+ return (const char*)p + sizeof n;
+ }
+
+ return NULL;
+}
+
+
+/* Get data from the car. The returned value is valid as long as the
+ list is not modified. */
+const char *
+gcry_sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen )
+{
+ return sexp_nth_data (list, number, datalen);
+}
+
+
+/* Get a string from the car. The returned value is a malloced string
+ and needs to be freed by the caller. */
+char *
+gcry_sexp_nth_string (const gcry_sexp_t list, int number)
+{
+ const char *s;
+ size_t n;
+ char *buf;
+
+ s = sexp_nth_data (list, number, &n);
+ if (!s || n < 1 || (n+1) < 1)
+ return NULL;
+ buf = gcry_malloc (n+1);
+ if (!buf)
+ return NULL;
+ memcpy (buf, s, n);
+ buf[n] = 0;
+ return buf;
+}
+
+/*
+ * Get a MPI from the car
+ */
+gcry_mpi_t
+gcry_sexp_nth_mpi( gcry_sexp_t list, int number, int mpifmt )
+{
+ const char *s;
+ size_t n;
+ gcry_mpi_t a;
+
+ if ( !mpifmt )
+ mpifmt = GCRYMPI_FMT_STD;
+
+ s = sexp_nth_data (list, number, &n);
+ if (!s)
+ return NULL;
+
+ if ( gcry_mpi_scan ( &a, mpifmt, s, n, NULL ) )
+ return NULL;
+
+ return a;
+}
+
+
+/****************
+ * Get the CDR
+ */
+gcry_sexp_t
+gcry_sexp_cdr( const gcry_sexp_t list )
+{
+ const byte *p;
+ const byte *head;
+ DATALEN n;
+ gcry_sexp_t newlist;
+ byte *d;
+ int level = 0;
+ int skip = 1;
+
+ if ( !list || list->d[0] != ST_OPEN )
+ return NULL;
+ p = list->d;
+
+ while ( skip > 0 ) {
+ p++;
+ if ( *p == ST_DATA ) {
+ memcpy ( &n, ++p, sizeof n );
+ p += sizeof n + n;
+ p--;
+ if ( !level )
+ skip--;
+ }
+ else if ( *p == ST_OPEN ) {
+ level++;
+ }
+ else if ( *p == ST_CLOSE ) {
+ level--;
+ if ( !level )
+ skip--;
+ }
+ else if ( *p == ST_STOP ) {
+ return NULL;
+ }
+ }
+ p++;
+
+ head = p;
+ level = 0;
+ do {
+ if ( *p == ST_DATA ) {
+ memcpy ( &n, ++p, sizeof n );
+ p += sizeof n + n;
+ p--;
+ }
+ else if ( *p == ST_OPEN ) {
+ level++;
+ }
+ else if ( *p == ST_CLOSE ) {
+ level--;
+ }
+ else if ( *p == ST_STOP ) {
+ return NULL;
+ }
+ p++;
+ } while ( level );
+ n = p - head;
+
+ newlist = gcry_malloc ( sizeof *newlist + n + 2 );
+ if (!newlist)
+ return NULL;
+ d = newlist->d;
+ *d++ = ST_OPEN;
+ memcpy ( d, head, n ); d += n;
+ *d++ = ST_CLOSE;
+ *d++ = ST_STOP;
+
+ return normalize (newlist);
+}
+
+gcry_sexp_t
+gcry_sexp_cadr ( const gcry_sexp_t list )
+{
+ gcry_sexp_t a, b;
+
+ a = gcry_sexp_cdr ( list );
+ b = gcry_sexp_car ( a );
+ gcry_sexp_release ( a );
+ return b;
+}
+
+
+
+static int
+hextobyte( const byte *s )
+{
+ int c=0;
+
+ if( *s >= '0' && *s <= '9' )
+ c = 16 * (*s - '0');
+ else if( *s >= 'A' && *s <= 'F' )
+ c = 16 * (10 + *s - 'A');
+ else if( *s >= 'a' && *s <= 'f' ) {
+ c = 16 * (10 + *s - 'a');
+ }
+ s++;
+ if( *s >= '0' && *s <= '9' )
+ c += *s - '0';
+ else if( *s >= 'A' && *s <= 'F' )
+ c += 10 + *s - 'A';
+ else if( *s >= 'a' && *s <= 'f' ) {
+ c += 10 + *s - 'a';
+ }
+ return c;
+}
+
+struct make_space_ctx {
+ gcry_sexp_t sexp;
+ size_t allocated;
+ byte *pos;
+};
+
+static gpg_err_code_t
+make_space ( struct make_space_ctx *c, size_t n )
+{
+ size_t used = c->pos - c->sexp->d;
+
+ if ( used + n + sizeof(DATALEN) + 1 >= c->allocated )
+ {
+ gcry_sexp_t newsexp;
+ byte *newhead;
+ size_t newsize;
+
+ newsize = c->allocated + 2*(n+sizeof(DATALEN)+1);
+ if (newsize <= c->allocated)
+ return GPG_ERR_TOO_LARGE;
+ newsexp = gcry_realloc ( c->sexp, sizeof *newsexp + newsize - 1);
+ if (!newsexp)
+ return gpg_err_code_from_errno (errno);
+ c->allocated = newsize;
+ newhead = newsexp->d;
+ c->pos = newhead + used;
+ c->sexp = newsexp;
+ }
+ return 0;
+}
+
+
+/* Unquote STRING of LENGTH and store it into BUF. The surrounding
+ quotes are must already be removed from STRING. We assume that the
+ quoted string is syntacillay correct. */
+static size_t
+unquote_string (const char *string, size_t length, unsigned char *buf)
+{
+ int esc = 0;
+ const unsigned char *s = (const unsigned char*)string;
+ unsigned char *d = buf;
+ size_t n = length;
+
+ for (; n; n--, s++)
+ {
+ if (esc)
+ {
+ switch (*s)
+ {
+ case 'b': *d++ = '\b'; break;
+ case 't': *d++ = '\t'; break;
+ case 'v': *d++ = '\v'; break;
+ case 'n': *d++ = '\n'; break;
+ case 'f': *d++ = '\f'; break;
+ case 'r': *d++ = '\r'; break;
+ case '"': *d++ = '\"'; break;
+ case '\'': *d++ = '\''; break;
+ case '\\': *d++ = '\\'; break;
+
+ case '\r': /* ignore CR[,LF] */
+ if (n>1 && s[1] == '\n')
+ {
+ s++; n--;
+ }
+ break;
+
+ case '\n': /* ignore LF[,CR] */
+ if (n>1 && s[1] == '\r')
+ {
+ s++; n--;
+ }
+ break;
+
+ case 'x': /* hex value */
+ if (n>2 && hexdigitp (s+1) && hexdigitp (s+2))
+ {
+ s++; n--;
+ *d++ = xtoi_2 (s);
+ s++; n--;
+ }
+ break;
+
+ default:
+ if (n>2 && octdigitp (s) && octdigitp (s+1) && octdigitp (s+2))
+ {
+ *d++ = (atoi_1 (s)*64) + (atoi_1 (s+1)*8) + atoi_1 (s+2);
+ s += 2;
+ n -= 2;
+ }
+ break;
+ }
+ esc = 0;
+ }
+ else if( *s == '\\' )
+ esc = 1;
+ else
+ *d++ = *s;
+ }
+
+ return d - buf;
+}
+
+/****************
+ * Scan the provided buffer and return the S expression in our internal
+ * format. Returns a newly allocated expression. If erroff is not NULL and
+ * a parsing error has occurred, the offset into buffer will be returned.
+ * If ARGFLAG is true, the function supports some printf like
+ * expressions.
+ * These are:
+ * %m - MPI
+ * %s - string (no autoswitch to secure allocation)
+ * %d - integer stored as string (no autoswitch to secure allocation)
+ * %b - memory buffer; this takes _two_ arguments: an integer with the
+ * length of the buffer and a pointer to the buffer.
+ * %S - Copy an gcry_sexp_t here. The S-expression needs to be a
+ * regular one, starting with a parenthesis.
+ * (no autoswitch to secure allocation)
+ * all other format elements are currently not defined and return an error.
+ * this includes the "%%" sequence becauce the percent sign is not an
+ * allowed character.
+ * FIXME: We should find a way to store the secure-MPIs not in the string
+ * but as reference to somewhere - this can help us to save huge amounts
+ * of secure memory. The problem is, that if only one element is secure, all
+ * other elements are automagicaly copied to secure memory too, so the most
+ * common operation gcry_sexp_cdr_mpi() will always return a secure MPI
+ * regardless whether it is needed or not.
+ */
+static gcry_error_t
+vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *buffer, size_t length, int argflag,
+ void **arg_list, va_list arg_ptr)
+{
+ gcry_err_code_t err = 0;
+ static const char tokenchars[] =
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-./_:*+=";
+ const char *p;
+ size_t n;
+ const char *digptr = NULL;
+ const char *quoted = NULL;
+ const char *tokenp = NULL;
+ const char *hexfmt = NULL;
+ const char *base64 = NULL;
+ const char *disphint = NULL;
+ const char *percent = NULL;
+ int hexcount = 0;
+ int quoted_esc = 0;
+ int datalen = 0;
+ size_t dummy_erroff;
+ struct make_space_ctx c;
+ int arg_counter = 0;
+ int level = 0;
+
+ if (!erroff)
+ erroff = &dummy_erroff;
+
+ /* Depending on whether ARG_LIST is non-zero or not, this macro gives
+ us the next argument, either from the variable argument list as
+ specified by ARG_PTR or from the argument array ARG_LIST. */
+#define ARG_NEXT(storage, type) \
+ do \
+ { \
+ if (!arg_list) \
+ storage = va_arg (arg_ptr, type); \
+ else \
+ storage = *((type *) (arg_list[arg_counter++])); \
+ } \
+ while (0)
+
+ /* The MAKE_SPACE macro is used before each store operation to
+ ensure that the buffer is large enough. It requires a global
+ context named C and jumps out to the label LEAVE on error! It
+ also sets ERROFF using the variables BUFFER and P. */
+#define MAKE_SPACE(n) do { \
+ gpg_err_code_t _ms_err = make_space (&c, (n)); \
+ if (_ms_err) \
+ { \
+ err = _ms_err; \
+ *erroff = p - buffer; \
+ goto leave; \
+ } \
+ } while (0)
+
+ /* The STORE_LEN macro is used to store the length N at buffer P. */
+#define STORE_LEN(p,n) do { \
+ DATALEN ashort = (n); \
+ memcpy ( (p), &ashort, sizeof(ashort) ); \
+ (p) += sizeof (ashort); \
+ } while (0)
+
+ /* We assume that the internal representation takes less memory than
+ the provided one. However, we add space for one extra datalen so
+ that the code which does the ST_CLOSE can use MAKE_SPACE */
+ c.allocated = length + sizeof(DATALEN);
+ if (buffer && length && gcry_is_secure (buffer))
+ c.sexp = gcry_malloc_secure (sizeof *c.sexp + c.allocated - 1);
+ else
+ c.sexp = gcry_malloc (sizeof *c.sexp + c.allocated - 1);
+ if (!c.sexp)
+ {
+ err = gpg_err_code_from_errno (errno);
+ *erroff = 0;
+ goto leave;
+ }
+ c.pos = c.sexp->d;
+
+ for (p = buffer, n = length; n; p++, n--)
+ {
+ if (tokenp && !hexfmt)
+ {
+ if (strchr (tokenchars, *p))
+ continue;
+ else
+ {
+ datalen = p - tokenp;
+ MAKE_SPACE (datalen);
+ *c.pos++ = ST_DATA;
+ STORE_LEN (c.pos, datalen);
+ memcpy (c.pos, tokenp, datalen);
+ c.pos += datalen;
+ tokenp = NULL;
+ }
+ }
+
+ if (quoted)
+ {
+ if (quoted_esc)
+ {
+ switch (*p)
+ {
+ case 'b': case 't': case 'v': case 'n': case 'f':
+ case 'r': case '"': case '\'': case '\\':
+ quoted_esc = 0;
+ break;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7':
+ if (!((n > 2)
+ && (p[1] >= '0') && (p[1] <= '7')
+ && (p[2] >= '0') && (p[2] <= '7')))
+ {
+ *erroff = p - buffer;
+ /* Invalid octal value. */
+ err = GPG_ERR_SEXP_BAD_QUOTATION;
+ goto leave;
+ }
+ p += 2;
+ n -= 2;
+ quoted_esc = 0;
+ break;
+
+ case 'x':
+ if (!((n > 2) && hexdigitp (p+1) && hexdigitp (p+2)))
+ {
+ *erroff = p - buffer;
+ /* Invalid hex value. */
+ err = GPG_ERR_SEXP_BAD_QUOTATION;
+ goto leave;
+ }
+ p += 2;
+ n -= 2;
+ quoted_esc = 0;
+ break;
+
+ case '\r':
+ /* ignore CR[,LF] */
+ if (n && (p[1] == '\n'))
+ {
+ p++;
+ n--;
+ }
+ quoted_esc = 0;
+ break;
+
+ case '\n':
+ /* ignore LF[,CR] */
+ if (n && (p[1] == '\r'))
+ {
+ p++;
+ n--;
+ }
+ quoted_esc = 0;
+ break;
+
+ default:
+ *erroff = p - buffer;
+ /* Invalid quoted string escape. */
+ err = GPG_ERR_SEXP_BAD_QUOTATION;
+ goto leave;
+ }
+ }
+ else if (*p == '\\')
+ quoted_esc = 1;
+ else if (*p == '\"')
+ {
+ /* Keep it easy - we know that the unquoted string will
+ never be larger. */
+ unsigned char *save;
+ size_t len;
+
+ quoted++; /* Skip leading quote. */
+ MAKE_SPACE (p - quoted);
+ *c.pos++ = ST_DATA;
+ save = c.pos;
+ STORE_LEN (c.pos, 0); /* Will be fixed up later. */
+ len = unquote_string (quoted, p - quoted, c.pos);
+ c.pos += len;
+ STORE_LEN (save, len);
+ quoted = NULL;
+ }
+ }
+ else if (hexfmt)
+ {
+ if (isxdigit (*p))
+ hexcount++;
+ else if (*p == '#')
+ {
+ if ((hexcount & 1))
+ {
+ *erroff = p - buffer;
+ err = GPG_ERR_SEXP_ODD_HEX_NUMBERS;
+ goto leave;
+ }
+
+ datalen = hexcount / 2;
+ MAKE_SPACE (datalen);
+ *c.pos++ = ST_DATA;
+ STORE_LEN (c.pos, datalen);
+ for (hexfmt++; hexfmt < p; hexfmt++)
+ {
+ if (whitespacep (hexfmt))
+ continue;
+ *c.pos++ = hextobyte ((const unsigned char*)hexfmt);
+ hexfmt++;
+ }
+ hexfmt = NULL;
+ }
+ else if (!whitespacep (p))
+ {
+ *erroff = p - buffer;
+ err = GPG_ERR_SEXP_BAD_HEX_CHAR;
+ goto leave;
+ }
+ }
+ else if (base64)
+ {
+ if (*p == '|')
+ base64 = NULL;
+ }
+ else if (digptr)
+ {
+ if (digitp (p))
+ ;
+ else if (*p == ':')
+ {
+ datalen = atoi (digptr); /* FIXME: check for overflow. */
+ digptr = NULL;
+ if (datalen > n - 1)
+ {
+ *erroff = p - buffer;
+ /* Buffer too short. */
+ err = GPG_ERR_SEXP_STRING_TOO_LONG;
+ goto leave;
+ }
+ /* Make a new list entry. */
+ MAKE_SPACE (datalen);
+ *c.pos++ = ST_DATA;
+ STORE_LEN (c.pos, datalen);
+ memcpy (c.pos, p + 1, datalen);
+ c.pos += datalen;
+ n -= datalen;
+ p += datalen;
+ }
+ else if (*p == '\"')
+ {
+ digptr = NULL; /* We ignore the optional length. */
+ quoted = p;
+ quoted_esc = 0;
+ }
+ else if (*p == '#')
+ {
+ digptr = NULL; /* We ignore the optional length. */
+ hexfmt = p;
+ hexcount = 0;
+ }
+ else if (*p == '|')
+ {
+ digptr = NULL; /* We ignore the optional length. */
+ base64 = p;
+ }
+ else
+ {
+ *erroff = p - buffer;
+ err = GPG_ERR_SEXP_INV_LEN_SPEC;
+ goto leave;
+ }
+ }
+ else if (percent)
+ {
+ if (*p == 'm' || *p == 'M')
+ {
+ /* Insert an MPI. */
+ gcry_mpi_t m;
+ size_t nm = 0;
+ int mpifmt = *p == 'm'? GCRYMPI_FMT_STD: GCRYMPI_FMT_USG;
+
+ ARG_NEXT (m, gcry_mpi_t);
+
+ if (gcry_mpi_get_flag (m, GCRYMPI_FLAG_OPAQUE))
+ {
+ void *mp;
+ unsigned int nbits;
+
+ mp = gcry_mpi_get_opaque (m, &nbits);
+ nm = (nbits+7)/8;
+ if (mp && nm)
+ {
+ MAKE_SPACE (nm);
+ if (!gcry_is_secure (c.sexp->d)
+ && gcry_mpi_get_flag (m, GCRYMPI_FLAG_SECURE))
+ {
+ /* We have to switch to secure allocation. */
+ gcry_sexp_t newsexp;
+ byte *newhead;
+
+ newsexp = gcry_malloc_secure (sizeof *newsexp
+ + c.allocated - 1);
+ if (!newsexp)
+ {
+ err = gpg_err_code_from_errno (errno);
+ goto leave;
+ }
+ newhead = newsexp->d;
+ memcpy (newhead, c.sexp->d, (c.pos - c.sexp->d));
+ c.pos = newhead + (c.pos - c.sexp->d);
+ gcry_free (c.sexp);
+ c.sexp = newsexp;
+ }
+
+ *c.pos++ = ST_DATA;
+ STORE_LEN (c.pos, nm);
+ memcpy (c.pos, mp, nm);
+ c.pos += nm;
+ }
+ }
+ else
+ {
+ if (gcry_mpi_print (mpifmt, NULL, 0, &nm, m))
+ BUG ();
+
+ MAKE_SPACE (nm);
+ if (!gcry_is_secure (c.sexp->d)
+ && gcry_mpi_get_flag ( m, GCRYMPI_FLAG_SECURE))
+ {
+ /* We have to switch to secure allocation. */
+ gcry_sexp_t newsexp;
+ byte *newhead;
+
+ newsexp = gcry_malloc_secure (sizeof *newsexp
+ + c.allocated - 1);
+ if (!newsexp)
+ {
+ err = gpg_err_code_from_errno (errno);
+ goto leave;
+ }
+ newhead = newsexp->d;
+ memcpy (newhead, c.sexp->d, (c.pos - c.sexp->d));
+ c.pos = newhead + (c.pos - c.sexp->d);
+ gcry_free (c.sexp);
+ c.sexp = newsexp;
+ }
+
+ *c.pos++ = ST_DATA;
+ STORE_LEN (c.pos, nm);
+ if (gcry_mpi_print (mpifmt, c.pos, nm, &nm, m))
+ BUG ();
+ c.pos += nm;
+ }
+ }
+ else if (*p == 's')
+ {
+ /* Insert an string. */
+ const char *astr;
+ size_t alen;
+
+ ARG_NEXT (astr, const char *);
+ alen = strlen (astr);
+
+ MAKE_SPACE (alen);
+ *c.pos++ = ST_DATA;
+ STORE_LEN (c.pos, alen);
+ memcpy (c.pos, astr, alen);
+ c.pos += alen;
+ }
+ else if (*p == 'b')
+ {
+ /* Insert a memory buffer. */
+ const char *astr;
+ int alen;
+
+ ARG_NEXT (alen, int);
+ ARG_NEXT (astr, const char *);
+
+ MAKE_SPACE (alen);
+ if (alen
+ && !gcry_is_secure (c.sexp->d)
+ && gcry_is_secure (astr))
+ {
+ /* We have to switch to secure allocation. */
+ gcry_sexp_t newsexp;
+ byte *newhead;
+
+ newsexp = gcry_malloc_secure (sizeof *newsexp
+ + c.allocated - 1);
+ if (!newsexp)
+ {
+ err = gpg_err_code_from_errno (errno);
+ goto leave;
+ }
+ newhead = newsexp->d;
+ memcpy (newhead, c.sexp->d, (c.pos - c.sexp->d));
+ c.pos = newhead + (c.pos - c.sexp->d);
+ gcry_free (c.sexp);
+ c.sexp = newsexp;
+ }
+
+ *c.pos++ = ST_DATA;
+ STORE_LEN (c.pos, alen);
+ memcpy (c.pos, astr, alen);
+ c.pos += alen;
+ }
+ else if (*p == 'd')
+ {
+ /* Insert an integer as string. */
+ int aint;
+ size_t alen;
+ char buf[35];
+
+ ARG_NEXT (aint, int);
+ sprintf (buf, "%d", aint);
+ alen = strlen (buf);
+ MAKE_SPACE (alen);
+ *c.pos++ = ST_DATA;
+ STORE_LEN (c.pos, alen);
+ memcpy (c.pos, buf, alen);
+ c.pos += alen;
+ }
+ else if (*p == 'u')
+ {
+ /* Insert an unsigned integer as string. */
+ unsigned int aint;
+ size_t alen;
+ char buf[35];
+
+ ARG_NEXT (aint, unsigned int);
+ sprintf (buf, "%u", aint);
+ alen = strlen (buf);
+ MAKE_SPACE (alen);
+ *c.pos++ = ST_DATA;
+ STORE_LEN (c.pos, alen);
+ memcpy (c.pos, buf, alen);
+ c.pos += alen;
+ }
+ else if (*p == 'S')
+ {
+ /* Insert a gcry_sexp_t. */
+ gcry_sexp_t asexp;
+ size_t alen, aoff;
+
+ ARG_NEXT (asexp, gcry_sexp_t);
+ alen = get_internal_buffer (asexp, &aoff);
+ if (alen)
+ {
+ MAKE_SPACE (alen);
+ memcpy (c.pos, asexp->d + aoff, alen);
+ c.pos += alen;
+ }
+ }
+ else
+ {
+ *erroff = p - buffer;
+ /* Invalid format specifier. */
+ err = GPG_ERR_SEXP_INV_LEN_SPEC;
+ goto leave;
+ }
+ percent = NULL;
+ }
+ else if (*p == '(')
+ {
+ if (disphint)
+ {
+ *erroff = p - buffer;
+ /* Open display hint. */
+ err = GPG_ERR_SEXP_UNMATCHED_DH;
+ goto leave;
+ }
+ MAKE_SPACE (0);
+ *c.pos++ = ST_OPEN;
+ level++;
+ }
+ else if (*p == ')')
+ {
+ /* Walk up. */
+ if (disphint)
+ {
+ *erroff = p - buffer;
+ /* Open display hint. */
+ err = GPG_ERR_SEXP_UNMATCHED_DH;
+ goto leave;
+ }
+ MAKE_SPACE (0);
+ *c.pos++ = ST_CLOSE;
+ level--;
+ }
+ else if (*p == '\"')
+ {
+ quoted = p;
+ quoted_esc = 0;
+ }
+ else if (*p == '#')
+ {
+ hexfmt = p;
+ hexcount = 0;
+ }
+ else if (*p == '|')
+ base64 = p;
+ else if (*p == '[')
+ {
+ if (disphint)
+ {
+ *erroff = p - buffer;
+ /* Open display hint. */
+ err = GPG_ERR_SEXP_NESTED_DH;
+ goto leave;
+ }
+ disphint = p;
+ }
+ else if (*p == ']')
+ {
+ if (!disphint)
+ {
+ *erroff = p - buffer;
+ /* Open display hint. */
+ err = GPG_ERR_SEXP_UNMATCHED_DH;
+ goto leave;
+ }
+ disphint = NULL;
+ }
+ else if (digitp (p))
+ {
+ if (*p == '0')
+ {
+ /* A length may not begin with zero. */
+ *erroff = p - buffer;
+ err = GPG_ERR_SEXP_ZERO_PREFIX;
+ goto leave;
+ }
+ digptr = p;
+ }
+ else if (strchr (tokenchars, *p))
+ tokenp = p;
+ else if (whitespacep (p))
+ ;
+ else if (*p == '{')
+ {
+ /* fixme: handle rescanning: we can do this by saving our
+ current state and start over at p+1 -- Hmmm. At this
+ point here we are in a well defined state, so we don't
+ need to save it. Great. */
+ *erroff = p - buffer;
+ err = GPG_ERR_SEXP_UNEXPECTED_PUNC;
+ goto leave;
+ }
+ else if (strchr ("&\\", *p))
+ {
+ /* Reserved punctuation. */
+ *erroff = p - buffer;
+ err = GPG_ERR_SEXP_UNEXPECTED_PUNC;
+ goto leave;
+ }
+ else if (argflag && (*p == '%'))
+ percent = p;
+ else
+ {
+ /* Bad or unavailable. */
+ *erroff = p - buffer;
+ err = GPG_ERR_SEXP_BAD_CHARACTER;
+ goto leave;
+ }
+ }
+ MAKE_SPACE (0);
+ *c.pos++ = ST_STOP;
+
+ if (level && !err)
+ err = GPG_ERR_SEXP_UNMATCHED_PAREN;
+
+ leave:
+ if (err)
+ {
+ /* Error -> deallocate. */
+ if (c.sexp)
+ {
+ /* Extra paranoid wipe on error. */
+ if (gcry_is_secure (c.sexp))
+ wipememory (c.sexp, sizeof (struct gcry_sexp) + c.allocated - 1);
+ gcry_free (c.sexp);
+ }
+ /* This might be expected by existing code... */
+ *retsexp = NULL;
+ }
+ else
+ *retsexp = normalize (c.sexp);
+
+ return gcry_error (err);
+#undef MAKE_SPACE
+#undef STORE_LEN
+}
+
+
+static gcry_error_t
+sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *buffer, size_t length, int argflag,
+ void **arg_list, ...)
+{
+ gcry_error_t rc;
+ va_list arg_ptr;
+
+ va_start (arg_ptr, arg_list);
+ rc = vsexp_sscan (retsexp, erroff, buffer, length, argflag,
+ arg_list, arg_ptr);
+ va_end (arg_ptr);
+
+ return rc;
+}
+
+
+gcry_error_t
+gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff, const char *format, ...)
+{
+ gcry_error_t rc;
+ va_list arg_ptr;
+
+ va_start (arg_ptr, format);
+ rc = vsexp_sscan (retsexp, erroff, format, strlen(format), 1,
+ NULL, arg_ptr);
+ va_end (arg_ptr);
+
+ return rc;
+}
+
+
+gcry_error_t
+_gcry_sexp_vbuild (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, va_list arg_ptr)
+{
+ return vsexp_sscan (retsexp, erroff, format, strlen(format), 1,
+ NULL, arg_ptr);
+}
+
+
+/* Like gcry_sexp_build, but uses an array instead of variable
+ function arguments. */
+gcry_error_t
+gcry_sexp_build_array (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, void **arg_list)
+{
+ return sexp_sscan (retsexp, erroff, format, strlen(format), 1, arg_list);
+}
+
+
+gcry_error_t
+gcry_sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *buffer, size_t length)
+{
+ return sexp_sscan (retsexp, erroff, buffer, length, 0, NULL);
+}
+
+
+/* Figure out a suitable encoding for BUFFER of LENGTH.
+ Returns: 0 = Binary
+ 1 = String possible
+ 2 = Token possible
+*/
+static int
+suitable_encoding (const unsigned char *buffer, size_t length)
+{
+ const unsigned char *s;
+ int maybe_token = 1;
+
+ if (!length)
+ return 1;
+
+ for (s=buffer; length; s++, length--)
+ {
+ if ( (*s < 0x20 || (*s >= 0x7f && *s <= 0xa0))
+ && !strchr ("\b\t\v\n\f\r\"\'\\", *s))
+ return 0; /*binary*/
+ if ( maybe_token
+ && !alphap (s) && !digitp (s) && !strchr (TOKEN_SPECIALS, *s))
+ maybe_token = 0;
+ }
+ s = buffer;
+ if ( maybe_token && !digitp (s) )
+ return 2;
+ return 1;
+}
+
+
+static int
+convert_to_hex (const unsigned char *src, size_t len, char *dest)
+{
+ int i;
+
+ if (dest)
+ {
+ *dest++ = '#';
+ for (i=0; i < len; i++, dest += 2 )
+ sprintf (dest, "%02X", src[i]);
+ *dest++ = '#';
+ }
+ return len*2+2;
+}
+
+static int
+convert_to_string (const unsigned char *s, size_t len, char *dest)
+{
+ if (dest)
+ {
+ char *p = dest;
+ *p++ = '\"';
+ for (; len; len--, s++ )
+ {
+ switch (*s)
+ {
+ case '\b': *p++ = '\\'; *p++ = 'b'; break;
+ case '\t': *p++ = '\\'; *p++ = 't'; break;
+ case '\v': *p++ = '\\'; *p++ = 'v'; break;
+ case '\n': *p++ = '\\'; *p++ = 'n'; break;
+ case '\f': *p++ = '\\'; *p++ = 'f'; break;
+ case '\r': *p++ = '\\'; *p++ = 'r'; break;
+ case '\"': *p++ = '\\'; *p++ = '\"'; break;
+ case '\'': *p++ = '\\'; *p++ = '\''; break;
+ case '\\': *p++ = '\\'; *p++ = '\\'; break;
+ default:
+ if ( (*s < 0x20 || (*s >= 0x7f && *s <= 0xa0)))
+ {
+ sprintf (p, "\\x%02x", *s);
+ p += 4;
+ }
+ else
+ *p++ = *s;
+ }
+ }
+ *p++ = '\"';
+ return p - dest;
+ }
+ else
+ {
+ int count = 2;
+ for (; len; len--, s++ )
+ {
+ switch (*s)
+ {
+ case '\b':
+ case '\t':
+ case '\v':
+ case '\n':
+ case '\f':
+ case '\r':
+ case '\"':
+ case '\'':
+ case '\\': count += 2; break;
+ default:
+ if ( (*s < 0x20 || (*s >= 0x7f && *s <= 0xa0)))
+ count += 4;
+ else
+ count++;
+ }
+ }
+ return count;
+ }
+}
+
+
+
+static int
+convert_to_token (const unsigned char *src, size_t len, char *dest)
+{
+ if (dest)
+ memcpy (dest, src, len);
+ return len;
+}
+
+
+/****************
+ * Print SEXP to buffer using the MODE. Returns the length of the
+ * SEXP in buffer or 0 if the buffer is too short (We have at least an
+ * empty list consisting of 2 bytes). If a buffer of NULL is provided,
+ * the required length is returned.
+ */
+size_t
+gcry_sexp_sprint (const gcry_sexp_t list, int mode,
+ void *buffer, size_t maxlength )
+{
+ static unsigned char empty[3] = { ST_OPEN, ST_CLOSE, ST_STOP };
+ const unsigned char *s;
+ char *d;
+ DATALEN n;
+ char numbuf[20];
+ size_t len = 0;
+ int i, indent = 0;
+
+ s = list? list->d : empty;
+ d = buffer;
+ while ( *s != ST_STOP )
+ {
+ switch ( *s )
+ {
+ case ST_OPEN:
+ s++;
+ if ( mode != GCRYSEXP_FMT_CANON )
+ {
+ if (indent)
+ len++;
+ len += indent;
+ }
+ len++;
+ if ( buffer )
+ {
+ if ( len >= maxlength )
+ return 0;
+ if ( mode != GCRYSEXP_FMT_CANON )
+ {
+ if (indent)
+ *d++ = '\n';
+ for (i=0; i < indent; i++)
+ *d++ = ' ';
+ }
+ *d++ = '(';
+ }
+ indent++;
+ break;
+ case ST_CLOSE:
+ s++;
+ len++;
+ if ( buffer )
+ {
+ if ( len >= maxlength )
+ return 0;
+ *d++ = ')';
+ }
+ indent--;
+ if (*s != ST_OPEN && *s != ST_STOP && mode != GCRYSEXP_FMT_CANON)
+ {
+ len++;
+ len += indent;
+ if (buffer)
+ {
+ if (len >= maxlength)
+ return 0;
+ *d++ = '\n';
+ for (i=0; i < indent; i++)
+ *d++ = ' ';
+ }
+ }
+ break;
+ case ST_DATA:
+ s++;
+ memcpy ( &n, s, sizeof n ); s += sizeof n;
+ if (mode == GCRYSEXP_FMT_ADVANCED)
+ {
+ int type;
+ size_t nn;
+
+ switch ( (type=suitable_encoding (s, n)))
+ {
+ case 1: nn = convert_to_string (s, n, NULL); break;
+ case 2: nn = convert_to_token (s, n, NULL); break;
+ default: nn = convert_to_hex (s, n, NULL); break;
+ }
+ len += nn;
+ if (buffer)
+ {
+ if (len >= maxlength)
+ return 0;
+ switch (type)
+ {
+ case 1: convert_to_string (s, n, d); break;
+ case 2: convert_to_token (s, n, d); break;
+ default: convert_to_hex (s, n, d); break;
+ }
+ d += nn;
+ }
+ if (s[n] != ST_CLOSE)
+ {
+ len++;
+ if (buffer)
+ {
+ if (len >= maxlength)
+ return 0;
+ *d++ = ' ';
+ }
+ }
+ }
+ else
+ {
+ sprintf (numbuf, "%u:", (unsigned int)n );
+ len += strlen (numbuf) + n;
+ if ( buffer )
+ {
+ if ( len >= maxlength )
+ return 0;
+ d = stpcpy ( d, numbuf );
+ memcpy ( d, s, n ); d += n;
+ }
+ }
+ s += n;
+ break;
+ default:
+ BUG ();
+ }
+ }
+ if ( mode != GCRYSEXP_FMT_CANON )
+ {
+ len++;
+ if (buffer)
+ {
+ if ( len >= maxlength )
+ return 0;
+ *d++ = '\n';
+ }
+ }
+ if (buffer)
+ {
+ if ( len >= maxlength )
+ return 0;
+ *d++ = 0; /* for convenience we make a C string */
+ }
+ else
+ len++; /* we need one byte more for this */
+
+ return len;
+}
+
+
+/* Scan a canonical encoded buffer with implicit length values and
+ return the actual length this S-expression uses. For a valid S-Exp
+ it should never return 0. If LENGTH is not zero, the maximum
+ length to scan is given - this can be used for syntax checks of
+ data passed from outside. errorcode and erroff may both be passed as
+ NULL. */
+size_t
+gcry_sexp_canon_len (const unsigned char *buffer, size_t length,
+ size_t *erroff, gcry_error_t *errcode)
+{
+ const unsigned char *p;
+ const unsigned char *disphint = NULL;
+ unsigned int datalen = 0;
+ size_t dummy_erroff;
+ gcry_error_t dummy_errcode;
+ size_t count = 0;
+ int level = 0;
+
+ if (!erroff)
+ erroff = &dummy_erroff;
+ if (!errcode)
+ errcode = &dummy_errcode;
+
+ *errcode = gcry_error (GPG_ERR_NO_ERROR);
+ *erroff = 0;
+ if (!buffer)
+ return 0;
+ if (*buffer != '(')
+ {
+ *errcode = gcry_error (GPG_ERR_SEXP_NOT_CANONICAL);
+ return 0;
+ }
+
+ for (p=buffer; ; p++, count++ )
+ {
+ if (length && count >= length)
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_STRING_TOO_LONG);
+ return 0;
+ }
+
+ if (datalen)
+ {
+ if (*p == ':')
+ {
+ if (length && (count+datalen) >= length)
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_STRING_TOO_LONG);
+ return 0;
+ }
+ count += datalen;
+ p += datalen;
+ datalen = 0;
+ }
+ else if (digitp(p))
+ datalen = datalen*10 + atoi_1(p);
+ else
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_INV_LEN_SPEC);
+ return 0;
+ }
+ }
+ else if (*p == '(')
+ {
+ if (disphint)
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_UNMATCHED_DH);
+ return 0;
+ }
+ level++;
+ }
+ else if (*p == ')')
+ { /* walk up */
+ if (!level)
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_UNMATCHED_PAREN);
+ return 0;
+ }
+ if (disphint)
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_UNMATCHED_DH);
+ return 0;
+ }
+ if (!--level)
+ return ++count; /* ready */
+ }
+ else if (*p == '[')
+ {
+ if (disphint)
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_NESTED_DH);
+ return 0;
+ }
+ disphint = p;
+ }
+ else if (*p == ']')
+ {
+ if ( !disphint )
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_UNMATCHED_DH);
+ return 0;
+ }
+ disphint = NULL;
+ }
+ else if (digitp (p) )
+ {
+ if (*p == '0')
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_ZERO_PREFIX);
+ return 0;
+ }
+ datalen = atoi_1 (p);
+ }
+ else if (*p == '&' || *p == '\\')
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_UNEXPECTED_PUNC);
+ return 0;
+ }
+ else
+ {
+ *erroff = count;
+ *errcode = gcry_error (GPG_ERR_SEXP_BAD_CHARACTER);
+ return 0;
+ }
+ }
+}
diff --git a/grub-core/lib/libgcrypt/src/stdmem.c b/grub-core/lib/libgcrypt/src/stdmem.c
new file mode 100644
index 0000000..189da37
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/stdmem.c
@@ -0,0 +1,242 @@
+/* stdmem.c - private memory allocator
+ * Copyright (C) 1998, 2000, 2002, 2005, 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Description of the layered memory management in Libgcrypt:
+ *
+ * [User]
+ * |
+ * |
+ * \ /
+ * global.c: [MM entrance points] -----> [user callbacks]
+ * | |
+ * | |
+ * \ / \ /
+ *
+ * stdmem.c: [non-secure handlers] [secure handlers]
+ *
+ * | |
+ * | |
+ * \ / \ /
+ *
+ * stdmem.c: [ memory guard ]
+ *
+ * | |
+ * | |
+ * \ / \ /
+ *
+ * libc: [ MM functions ] secmem.c: [ secure MM functions]
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#include "g10lib.h"
+#include "stdmem.h"
+#include "secmem.h"
+
+
+
+#define MAGIC_NOR_BYTE 0x55
+#define MAGIC_SEC_BYTE 0xcc
+#define MAGIC_END_BYTE 0xaa
+
+#if SIZEOF_UNSIGNED_LONG == 8
+#define EXTRA_ALIGN 4
+#else
+#define EXTRA_ALIGN 0
+#endif
+
+
+static int use_m_guard = 0;
+
+/****************
+ * Warning: Never use this function after any of the functions
+ * here have been used.
+ */
+void
+_gcry_private_enable_m_guard (void)
+{
+ use_m_guard = 1;
+}
+
+
+/*
+ * Allocate memory of size n.
+ * Return NULL if we are out of memory.
+ */
+void *
+_gcry_private_malloc (size_t n)
+{
+ if (!n)
+ {
+ gpg_err_set_errno (EINVAL);
+ return NULL; /* Allocating 0 bytes is undefined - we better return
+ an error to detect such coding errors. */
+ }
+
+ if (use_m_guard)
+ {
+ char *p;
+
+ if ( !(p = malloc (n + EXTRA_ALIGN+5)) )
+ return NULL;
+ ((byte*)p)[EXTRA_ALIGN+0] = n;
+ ((byte*)p)[EXTRA_ALIGN+1] = n >> 8 ;
+ ((byte*)p)[EXTRA_ALIGN+2] = n >> 16 ;
+ ((byte*)p)[EXTRA_ALIGN+3] = MAGIC_NOR_BYTE;
+ p[4+EXTRA_ALIGN+n] = MAGIC_END_BYTE;
+ return p+EXTRA_ALIGN+4;
+ }
+ else
+ {
+ return malloc( n );
+ }
+}
+
+
+/*
+ * Allocate memory of size N from the secure memory pool. Return NULL
+ * if we are out of memory.
+ */
+void *
+_gcry_private_malloc_secure (size_t n)
+{
+ if (!n)
+ {
+ gpg_err_set_errno (EINVAL);
+ return NULL; /* Allocating 0 bytes is undefined - better return an
+ error to detect such coding errors. */
+ }
+
+ if (use_m_guard)
+ {
+ char *p;
+
+ if ( !(p = _gcry_secmem_malloc (n +EXTRA_ALIGN+ 5)) )
+ return NULL;
+ ((byte*)p)[EXTRA_ALIGN+0] = n;
+ ((byte*)p)[EXTRA_ALIGN+1] = n >> 8 ;
+ ((byte*)p)[EXTRA_ALIGN+2] = n >> 16 ;
+ ((byte*)p)[EXTRA_ALIGN+3] = MAGIC_SEC_BYTE;
+ p[4+EXTRA_ALIGN+n] = MAGIC_END_BYTE;
+ return p+EXTRA_ALIGN+4;
+ }
+ else
+ {
+ return _gcry_secmem_malloc( n );
+ }
+}
+
+
+/*
+ * Realloc and clear the old space
+ * Return NULL if there is not enough memory.
+ */
+void *
+_gcry_private_realloc ( void *a, size_t n )
+{
+ if (use_m_guard)
+ {
+ unsigned char *p = a;
+ char *b;
+ size_t len;
+
+ if (!a)
+ return _gcry_private_malloc(n);
+
+ _gcry_private_check_heap(p);
+ len = p[-4];
+ len |= p[-3] << 8;
+ len |= p[-2] << 16;
+ if( len >= n ) /* We don't shrink for now. */
+ return a;
+ if (p[-1] == MAGIC_SEC_BYTE)
+ b = _gcry_private_malloc_secure(n);
+ else
+ b = _gcry_private_malloc(n);
+ if (!b)
+ return NULL;
+ memcpy (b, a, len);
+ memset (b+len, 0, n-len);
+ _gcry_private_free (p);
+ return b;
+ }
+ else if ( _gcry_private_is_secure(a) )
+ {
+ return _gcry_secmem_realloc( a, n );
+ }
+ else
+ {
+ return realloc( a, n );
+ }
+}
+
+
+void
+_gcry_private_check_heap (const void *a)
+{
+ if (use_m_guard)
+ {
+ const byte *p = a;
+ size_t len;
+
+ if (!p)
+ return;
+
+ if ( !(p[-1] == MAGIC_NOR_BYTE || p[-1] == MAGIC_SEC_BYTE) )
+ _gcry_log_fatal ("memory at %p corrupted (underflow=%02x)\n", p, p[-1]);
+ len = p[-4];
+ len |= p[-3] << 8;
+ len |= p[-2] << 16;
+ if ( p[len] != MAGIC_END_BYTE )
+ _gcry_log_fatal ("memory at %p corrupted (overflow=%02x)\n", p, p[-1]);
+ }
+}
+
+
+/*
+ * Free a memory block allocated by this or the secmem module
+ */
+void
+_gcry_private_free (void *a)
+{
+ unsigned char *p = a;
+
+ if (!p)
+ return;
+ if (use_m_guard )
+ {
+ _gcry_private_check_heap(p);
+ if ( _gcry_private_is_secure(a) )
+ _gcry_secmem_free(p-EXTRA_ALIGN-4);
+ else
+ {
+ free(p-EXTRA_ALIGN-4);
+ }
+ }
+ else if ( _gcry_private_is_secure(a) )
+ _gcry_secmem_free(p);
+ else
+ free(p);
+}
diff --git a/grub-core/lib/libgcrypt/src/stdmem.h b/grub-core/lib/libgcrypt/src/stdmem.h
new file mode 100644
index 0000000..b476e7e
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/stdmem.h
@@ -0,0 +1,32 @@
+/* stdmem.h - internal definitions for stdmem
+ * Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef G10_STDMEM_H
+#define G10_STDMEM_H 1
+
+void _gcry_private_enable_m_guard(void);
+
+void *_gcry_private_malloc (size_t n) _GCRY_GCC_ATTR_MALLOC;
+void *_gcry_private_malloc_secure (size_t n) _GCRY_GCC_ATTR_MALLOC;
+void *_gcry_private_realloc (void *a, size_t n);
+void _gcry_private_check_heap (const void *a);
+void _gcry_private_free (void *a);
+
+#endif /* G10_STDMEM_H */
diff --git a/grub-core/lib/libgcrypt/src/types.h b/grub-core/lib/libgcrypt/src/types.h
new file mode 100644
index 0000000..ee0a62b
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/types.h
@@ -0,0 +1,128 @@
+/* types.h - some common typedefs
+ * Copyright (C) 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef GCRYPT_TYPES_H
+#define GCRYPT_TYPES_H
+
+
+/* The AC_CHECK_SIZEOF() in configure fails for some machines.
+ * we provide some fallback values here */
+#if !SIZEOF_UNSIGNED_SHORT
+#undef SIZEOF_UNSIGNED_SHORT
+#define SIZEOF_UNSIGNED_SHORT 2
+#endif
+#if !SIZEOF_UNSIGNED_INT
+#undef SIZEOF_UNSIGNED_INT
+#define SIZEOF_UNSIGNED_INT 4
+#endif
+#if !SIZEOF_UNSIGNED_LONG
+#undef SIZEOF_UNSIGNED_LONG
+#define SIZEOF_UNSIGNED_LONG 4
+#endif
+
+
+#include <sys/types.h>
+
+
+#ifndef HAVE_BYTE_TYPEDEF
+#undef byte /* maybe there is a macro with this name */
+/* Windows typedefs byte in the rpc headers. Avoid warning about
+ double definition. */
+#if !(defined(_WIN32) && defined(cbNDRContext))
+ typedef unsigned char byte;
+#endif
+#define HAVE_BYTE_TYPEDEF
+#endif
+
+#ifndef HAVE_USHORT_TYPEDEF
+#undef ushort /* maybe there is a macro with this name */
+ typedef unsigned short ushort;
+#define HAVE_USHORT_TYPEDEF
+#endif
+
+#ifndef HAVE_ULONG_TYPEDEF
+#undef ulong /* maybe there is a macro with this name */
+ typedef unsigned long ulong;
+#define HAVE_ULONG_TYPEDEF
+#endif
+
+#ifndef HAVE_U16_TYPEDEF
+#undef u16 /* maybe there is a macro with this name */
+#if SIZEOF_UNSIGNED_INT == 2
+ typedef unsigned int u16;
+#elif SIZEOF_UNSIGNED_SHORT == 2
+ typedef unsigned short u16;
+#else
+#error no typedef for u16
+#endif
+#define HAVE_U16_TYPEDEF
+#endif
+
+#ifndef HAVE_U32_TYPEDEF
+#undef u32 /* maybe there is a macro with this name */
+#if SIZEOF_UNSIGNED_INT == 4
+ typedef unsigned int u32;
+#elif SIZEOF_UNSIGNED_LONG == 4
+ typedef unsigned long u32;
+#else
+#error no typedef for u32
+#endif
+#define HAVE_U32_TYPEDEF
+#endif
+
+/****************
+ * Warning: Some systems segfault when this u64 typedef and
+ * the dummy code in cipher/md.c is not available. Examples are
+ * Solaris and IRIX.
+ */
+#ifndef HAVE_U64_TYPEDEF
+#undef u64 /* maybe there is a macro with this name */
+#if SIZEOF_UNSIGNED_INT == 8
+ typedef unsigned int u64;
+#define U64_C(c) (c ## U)
+#define HAVE_U64_TYPEDEF
+#elif SIZEOF_UNSIGNED_LONG == 8
+ typedef unsigned long u64;
+#define U64_C(c) (c ## UL)
+#define HAVE_U64_TYPEDEF
+#elif SIZEOF_UNSIGNED_LONG_LONG == 8
+ typedef unsigned long long u64;
+#define U64_C(c) (c ## ULL)
+#define HAVE_U64_TYPEDEF
+#elif SIZEOF_UINT64_T == 8
+ typedef uint64_t u64;
+#define U64_C(c) (UINT64_C(c))
+#define HAVE_U64_TYPEDEF
+#endif
+#endif
+
+typedef union {
+ int a;
+ short b;
+ char c[1];
+ long d;
+#ifdef HAVE_U64_TYPEDEF
+ u64 e;
+#endif
+ float f;
+ double g;
+} PROPERLY_ALIGNED_TYPE;
+
+#endif /*GCRYPT_TYPES_H*/
diff --git a/grub-core/lib/libgcrypt/src/versioninfo.rc.in b/grub-core/lib/libgcrypt/src/versioninfo.rc.in
new file mode 100644
index 0000000..3199521
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/versioninfo.rc.in
@@ -0,0 +1,51 @@
+/* versioninfo.rc.in - for libgcrypt
+ * Copyright (C) 2005, 2006 g10 Code GmbH
+ *
+ * This file is free software; as a special exception the author gives
+ * unlimited permission to copy and/or distribute it, with or without
+ * modifications, as long as this notice is preserved.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/* This file is processed by configure to create versioninfo.rc */
+
+#line __LINE__ "versioninfo.rc.in"
+
+#include <afxres.h>
+
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @BUILD_FILEVERSION@
+ PRODUCTVERSION @BUILD_FILEVERSION@
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x21L
+#else
+ FILEFLAGS 0x20L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "Provided under the terms of the GNU Lesser General Public License (LGPLv2.1+).\0"
+ VALUE "CompanyName", "g10 Code GmbH\0"
+ VALUE "FileDescription", "Libgcrypt - The GNU Crypto Library\0"
+ VALUE "FileVersion", "@LIBGCRYPT_LT_CURRENT@.@LIBGCRYPT_LT_AGE@.@LIBGCRYPT_LT_REVISION@.@BUILD_REVISION@\0"
+ VALUE "InternalName", "libgcrypt\0"
+ VALUE "LegalCopyright", "Copyright © 2012 Free Software Foundation, Inc.\0"
+ VALUE "LegalTrademarks", "\0"
+ VALUE "OriginalFilename", "libgcrypt.dll\0"
+ VALUE "PrivateBuild", "\0"
+ VALUE "ProductName", "libgcrypt\0"
+ VALUE "ProductVersion", "@VERSION@\0"
+ VALUE "SpecialBuild", "@BUILD_TIMESTAMP@\0"
+ END
+ END
+END
diff --git a/grub-core/lib/libgcrypt/src/visibility.c b/grub-core/lib/libgcrypt/src/visibility.c
new file mode 100644
index 0000000..2fccb01
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/visibility.c
@@ -0,0 +1,1486 @@
+/* visibility.c - Wrapper for all public functions.
+ * Copyright (C) 2007, 2008, 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdarg.h>
+
+#define _GCRY_INCLUDED_BY_VISIBILITY_C
+#include "g10lib.h"
+#include "cipher-proto.h"
+
+
+
+const char *
+gcry_strerror (gcry_error_t err)
+{
+ return _gcry_strerror (err);
+}
+
+const char *
+gcry_strsource (gcry_error_t err)
+{
+ return _gcry_strsource (err);
+}
+
+gcry_err_code_t
+gcry_err_code_from_errno (int err)
+{
+ return _gcry_err_code_from_errno (err);
+}
+
+int
+gcry_err_code_to_errno (gcry_err_code_t code)
+{
+ return _gcry_err_code_to_errno (code);
+}
+
+gcry_error_t
+gcry_err_make_from_errno (gcry_err_source_t source, int err)
+{
+ return _gcry_err_make_from_errno (source, err);
+}
+
+gcry_err_code_t
+gcry_error_from_errno (int err)
+{
+ return _gcry_error_from_errno (err);
+}
+
+const char *
+gcry_check_version (const char *req_version)
+{
+ return _gcry_check_version (req_version);
+}
+
+gcry_error_t
+gcry_control (enum gcry_ctl_cmds cmd, ...)
+{
+ gcry_error_t err;
+ va_list arg_ptr;
+
+ va_start (arg_ptr, cmd);
+ err = _gcry_vcontrol (cmd, arg_ptr);
+ va_end(arg_ptr);
+ return err;
+}
+
+gcry_error_t
+gcry_sexp_new (gcry_sexp_t *retsexp,
+ const void *buffer, size_t length,
+ int autodetect)
+{
+ return _gcry_sexp_new (retsexp, buffer, length, autodetect);
+}
+
+gcry_error_t
+gcry_sexp_create (gcry_sexp_t *retsexp,
+ void *buffer, size_t length,
+ int autodetect, void (*freefnc) (void *))
+{
+ return _gcry_sexp_create (retsexp, buffer, length,
+ autodetect, freefnc);
+}
+
+gcry_error_t
+gcry_sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *buffer, size_t length)
+{
+ return _gcry_sexp_sscan (retsexp, erroff, buffer, length);
+}
+
+gcry_error_t
+gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, ...)
+{
+ gcry_error_t err;
+ va_list arg_ptr;
+
+ va_start (arg_ptr, format);
+ err = _gcry_sexp_vbuild (retsexp, erroff, format, arg_ptr);
+ va_end (arg_ptr);
+ return err;
+}
+
+gcry_error_t
+gcry_sexp_build_array (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, void **arg_list)
+{
+ return _gcry_sexp_build_array (retsexp, erroff, format, arg_list);
+}
+
+void
+gcry_sexp_release (gcry_sexp_t sexp)
+{
+ _gcry_sexp_release (sexp);
+}
+
+size_t
+gcry_sexp_canon_len (const unsigned char *buffer, size_t length,
+ size_t *erroff, gcry_error_t *errcode)
+{
+ return _gcry_sexp_canon_len (buffer, length, erroff, errcode);
+}
+
+size_t
+gcry_sexp_sprint (gcry_sexp_t sexp, int mode, void *buffer, size_t maxlength)
+{
+ return _gcry_sexp_sprint (sexp, mode, buffer, maxlength);
+}
+
+void
+gcry_sexp_dump (const gcry_sexp_t a)
+{
+ _gcry_sexp_dump (a);
+}
+
+gcry_sexp_t
+gcry_sexp_cons (const gcry_sexp_t a, const gcry_sexp_t b)
+{
+ return _gcry_sexp_cons (a, b);
+}
+
+gcry_sexp_t
+gcry_sexp_alist (const gcry_sexp_t *array)
+{
+ return _gcry_sexp_alist (array);
+}
+
+gcry_sexp_t
+gcry_sexp_vlist (const gcry_sexp_t a, ...)
+{
+ /* This is not yet implemented in sexp.c. */
+ (void)a;
+ BUG ();
+ return NULL;
+}
+
+gcry_sexp_t
+gcry_sexp_append (const gcry_sexp_t a, const gcry_sexp_t n)
+{
+ return _gcry_sexp_append (a, n);
+}
+
+gcry_sexp_t
+gcry_sexp_prepend (const gcry_sexp_t a, const gcry_sexp_t n)
+{
+ return _gcry_sexp_prepend (a, n);
+}
+
+
+gcry_sexp_t
+gcry_sexp_find_token (gcry_sexp_t list, const char *tok, size_t toklen)
+{
+ return _gcry_sexp_find_token (list, tok, toklen);
+}
+
+int
+gcry_sexp_length (const gcry_sexp_t list)
+{
+ return _gcry_sexp_length (list);
+}
+
+gcry_sexp_t
+gcry_sexp_nth (const gcry_sexp_t list, int number)
+{
+ return _gcry_sexp_nth (list, number);
+}
+
+gcry_sexp_t
+gcry_sexp_car (const gcry_sexp_t list)
+{
+ return _gcry_sexp_car (list);
+}
+
+gcry_sexp_t
+gcry_sexp_cdr (const gcry_sexp_t list)
+{
+ return _gcry_sexp_cdr (list);
+}
+
+gcry_sexp_t
+gcry_sexp_cadr (const gcry_sexp_t list)
+{
+ return _gcry_sexp_cadr (list);
+}
+
+const char *
+gcry_sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen)
+{
+ return _gcry_sexp_nth_data (list, number, datalen);
+}
+
+char *
+gcry_sexp_nth_string (gcry_sexp_t list, int number)
+{
+ return _gcry_sexp_nth_string (list, number);
+}
+
+gcry_mpi_t
+gcry_sexp_nth_mpi (gcry_sexp_t list, int number, int mpifmt)
+{
+ return _gcry_sexp_nth_mpi (list, number, mpifmt);
+}
+
+gcry_mpi_t
+gcry_mpi_new (unsigned int nbits)
+{
+ return _gcry_mpi_new (nbits);
+}
+
+gcry_mpi_t
+gcry_mpi_snew (unsigned int nbits)
+{
+ return _gcry_mpi_snew (nbits);
+}
+
+void
+gcry_mpi_release (gcry_mpi_t a)
+{
+ _gcry_mpi_release (a);
+}
+
+gcry_mpi_t
+gcry_mpi_copy (const gcry_mpi_t a)
+{
+ return _gcry_mpi_copy (a);
+}
+
+gcry_mpi_t
+gcry_mpi_set (gcry_mpi_t w, const gcry_mpi_t u)
+{
+ return _gcry_mpi_set (w, u);
+}
+
+gcry_mpi_t
+gcry_mpi_set_ui (gcry_mpi_t w, unsigned long u)
+{
+ return _gcry_mpi_set_ui (w, u);
+}
+
+void
+gcry_mpi_swap (gcry_mpi_t a, gcry_mpi_t b)
+{
+ _gcry_mpi_swap (a, b);
+}
+
+int
+gcry_mpi_cmp (const gcry_mpi_t u, const gcry_mpi_t v)
+{
+ return _gcry_mpi_cmp (u, v);
+}
+
+int
+gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v)
+{
+ return _gcry_mpi_cmp_ui (u, v);
+}
+
+gcry_error_t
+gcry_mpi_scan (gcry_mpi_t *ret_mpi, enum gcry_mpi_format format,
+ const void *buffer, size_t buflen,
+ size_t *nscanned)
+{
+ return _gcry_mpi_scan (ret_mpi, format, buffer, buflen, nscanned);
+}
+
+gcry_error_t
+gcry_mpi_print (enum gcry_mpi_format format,
+ unsigned char *buffer, size_t buflen,
+ size_t *nwritten,
+ const gcry_mpi_t a)
+{
+ return _gcry_mpi_print (format, buffer, buflen, nwritten, a);
+}
+
+gcry_error_t
+gcry_mpi_aprint (enum gcry_mpi_format format,
+ unsigned char **buffer, size_t *nwritten,
+ const gcry_mpi_t a)
+{
+ return _gcry_mpi_aprint (format, buffer, nwritten, a);
+}
+
+void
+gcry_mpi_dump (const gcry_mpi_t a)
+{
+ _gcry_mpi_dump (a);
+}
+
+void
+gcry_mpi_add (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ _gcry_mpi_add (w, u, v);
+}
+
+void
+gcry_mpi_add_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v)
+{
+ _gcry_mpi_add_ui (w, u, v);
+}
+
+void
+gcry_mpi_addm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ _gcry_mpi_addm (w, u, v, m);
+}
+
+void
+gcry_mpi_sub (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ _gcry_mpi_sub (w, u, v);
+}
+
+void
+gcry_mpi_sub_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v )
+{
+ _gcry_mpi_sub_ui (w, u, v);
+}
+
+void
+gcry_mpi_subm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ _gcry_mpi_subm (w, u, v, m);
+}
+
+void
+gcry_mpi_mul (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ _gcry_mpi_mul (w, u, v);
+}
+
+void
+gcry_mpi_mul_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v )
+{
+ _gcry_mpi_mul_ui (w, u, v);
+}
+
+void
+gcry_mpi_mulm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ _gcry_mpi_mulm (w, u, v, m);
+}
+
+void
+gcry_mpi_mul_2exp (gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt)
+{
+ _gcry_mpi_mul_2exp (w, u, cnt);
+}
+
+void
+gcry_mpi_div (gcry_mpi_t q, gcry_mpi_t r,
+ gcry_mpi_t dividend, gcry_mpi_t divisor, int round)
+{
+ _gcry_mpi_div (q, r, dividend, divisor, round);
+}
+
+void
+gcry_mpi_mod (gcry_mpi_t r, gcry_mpi_t dividend, gcry_mpi_t divisor)
+{
+ _gcry_mpi_mod (r, dividend, divisor);
+}
+
+void
+gcry_mpi_powm (gcry_mpi_t w, const gcry_mpi_t b, const gcry_mpi_t e,
+ const gcry_mpi_t m)
+{
+ _gcry_mpi_powm (w, b, e, m);
+}
+
+int
+gcry_mpi_gcd (gcry_mpi_t g, gcry_mpi_t a, gcry_mpi_t b)
+{
+ return _gcry_mpi_gcd (g, a, b);
+}
+
+int
+gcry_mpi_invm (gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t m)
+{
+ return _gcry_mpi_invm (x, a, m);
+}
+
+
+unsigned int
+gcry_mpi_get_nbits (gcry_mpi_t a)
+{
+ return _gcry_mpi_get_nbits (a);
+}
+
+int
+gcry_mpi_test_bit (gcry_mpi_t a, unsigned int n)
+{
+ return _gcry_mpi_test_bit (a, n);
+}
+
+void
+gcry_mpi_set_bit (gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_set_bit (a, n);
+}
+
+void
+gcry_mpi_clear_bit (gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_clear_bit (a, n);
+}
+
+void
+gcry_mpi_set_highbit (gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_set_highbit (a, n);
+}
+
+void
+gcry_mpi_clear_highbit (gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_clear_highbit (a, n);
+}
+
+void
+gcry_mpi_rshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_rshift (x, a, n);
+}
+
+void
+gcry_mpi_lshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_lshift (x, a, n);
+}
+
+gcry_mpi_t
+gcry_mpi_set_opaque (gcry_mpi_t a, void *p, unsigned int nbits)
+{
+ return _gcry_mpi_set_opaque (a, p, nbits);
+}
+
+void *
+gcry_mpi_get_opaque (gcry_mpi_t a, unsigned int *nbits)
+{
+ return _gcry_mpi_get_opaque (a, nbits);
+}
+
+void
+gcry_mpi_set_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)
+{
+ _gcry_mpi_set_flag (a, flag);
+}
+
+void
+gcry_mpi_clear_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)
+{
+ _gcry_mpi_clear_flag (a, flag);
+}
+
+int
+gcry_mpi_get_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)
+{
+ return _gcry_mpi_get_flag (a, flag);
+}
+
+gcry_error_t
+gcry_cipher_open (gcry_cipher_hd_t *handle,
+ int algo, int mode, unsigned int flags)
+{
+ if (!fips_is_operational ())
+ {
+ *handle = NULL;
+ return gpg_error (fips_not_operational ());
+ }
+
+ return _gcry_cipher_open (handle, algo, mode, flags);
+}
+
+void
+gcry_cipher_close (gcry_cipher_hd_t h)
+{
+ _gcry_cipher_close (h);
+}
+
+gcry_error_t
+gcry_cipher_setkey (gcry_cipher_hd_t hd, const void *key, size_t keylen)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+
+ return _gcry_cipher_setkey (hd, key, keylen);
+}
+
+gcry_error_t
+gcry_cipher_setiv (gcry_cipher_hd_t hd, const void *iv, size_t ivlen)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+
+ return _gcry_cipher_setiv (hd, iv, ivlen);
+}
+
+gpg_error_t
+gcry_cipher_setctr (gcry_cipher_hd_t hd, const void *ctr, size_t ctrlen)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+
+ return _gcry_cipher_setctr (hd, ctr, ctrlen);
+}
+
+
+gcry_error_t
+gcry_cipher_ctl (gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+
+ return _gcry_cipher_ctl (h, cmd, buffer, buflen);
+}
+
+gcry_error_t
+gcry_cipher_info (gcry_cipher_hd_t h, int what, void *buffer, size_t *nbytes)
+{
+ return _gcry_cipher_info (h, what, buffer, nbytes);
+}
+
+gcry_error_t
+gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+
+ return _gcry_cipher_algo_info (algo, what, buffer, nbytes);
+}
+
+const char *
+gcry_cipher_algo_name (int algorithm)
+{
+ return _gcry_cipher_algo_name (algorithm);
+}
+
+int
+gcry_cipher_map_name (const char *name)
+{
+ return _gcry_cipher_map_name (name);
+}
+
+int
+gcry_cipher_mode_from_oid (const char *string)
+{
+ return _gcry_cipher_mode_from_oid (string);
+}
+
+gcry_error_t
+gcry_cipher_encrypt (gcry_cipher_hd_t h,
+ void *out, size_t outsize,
+ const void *in, size_t inlen)
+{
+ if (!fips_is_operational ())
+ {
+ /* Make sure that the plaintext will never make it to OUT. */
+ if (out)
+ memset (out, 0x42, outsize);
+ return gpg_error (fips_not_operational ());
+ }
+
+ return _gcry_cipher_encrypt (h, out, outsize, in, inlen);
+}
+
+gcry_error_t
+gcry_cipher_decrypt (gcry_cipher_hd_t h,
+ void *out, size_t outsize,
+ const void *in, size_t inlen)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+
+ return _gcry_cipher_decrypt (h, out, outsize, in, inlen);
+}
+
+size_t
+gcry_cipher_get_algo_keylen (int algo)
+{
+ return _gcry_cipher_get_algo_keylen (algo);
+}
+
+size_t
+gcry_cipher_get_algo_blklen (int algo)
+{
+ return _gcry_cipher_get_algo_blklen (algo);
+}
+
+gcry_error_t
+gcry_cipher_list (int *list, int *list_length)
+{
+ return _gcry_cipher_list (list, list_length);
+}
+
+gcry_error_t
+gcry_pk_encrypt (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t pkey)
+{
+ if (!fips_is_operational ())
+ {
+ *result = NULL;
+ return gpg_error (fips_not_operational ());
+ }
+ return _gcry_pk_encrypt (result, data, pkey);
+}
+
+gcry_error_t
+gcry_pk_decrypt (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t skey)
+{
+ if (!fips_is_operational ())
+ {
+ *result = NULL;
+ return gpg_error (fips_not_operational ());
+ }
+ return _gcry_pk_decrypt (result, data, skey);
+}
+
+gcry_error_t
+gcry_pk_sign (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t skey)
+{
+ if (!fips_is_operational ())
+ {
+ *result = NULL;
+ return gpg_error (fips_not_operational ());
+ }
+ return _gcry_pk_sign (result, data, skey);
+}
+
+gcry_error_t
+gcry_pk_verify (gcry_sexp_t sigval, gcry_sexp_t data, gcry_sexp_t pkey)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+ return _gcry_pk_verify (sigval, data, pkey);
+}
+
+gcry_error_t
+gcry_pk_testkey (gcry_sexp_t key)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+ return _gcry_pk_testkey (key);
+}
+
+gcry_error_t
+gcry_pk_genkey (gcry_sexp_t *r_key, gcry_sexp_t s_parms)
+{
+ if (!fips_is_operational ())
+ {
+ *r_key = NULL;
+ return gpg_error (fips_not_operational ());
+ }
+ return _gcry_pk_genkey (r_key, s_parms);
+}
+
+gcry_error_t
+gcry_pk_ctl (int cmd, void *buffer, size_t buflen)
+{
+ return _gcry_pk_ctl (cmd, buffer, buflen);
+}
+
+gcry_error_t
+gcry_pk_algo_info (int algo, int what, void *buffer, size_t *nbytes)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+
+ return _gcry_pk_algo_info (algo, what, buffer, nbytes);
+}
+
+const char *
+gcry_pk_algo_name (int algorithm)
+{
+ return _gcry_pk_algo_name (algorithm);
+}
+
+int
+gcry_pk_map_name (const char *name)
+{
+ return _gcry_pk_map_name (name);
+}
+
+unsigned int
+gcry_pk_get_nbits (gcry_sexp_t key)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ return 0;
+ }
+
+ return _gcry_pk_get_nbits (key);
+}
+
+unsigned char *
+gcry_pk_get_keygrip (gcry_sexp_t key, unsigned char *array)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ return NULL;
+ }
+ return _gcry_pk_get_keygrip (key, array);
+}
+
+const char *
+gcry_pk_get_curve (gcry_sexp_t key, int iterator, unsigned int *r_nbits)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ return NULL;
+ }
+ return _gcry_pk_get_curve (key, iterator, r_nbits);
+}
+
+gcry_sexp_t
+gcry_pk_get_param (int algo, const char *name)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ return NULL;
+ }
+ return _gcry_pk_get_param (algo, name);
+}
+
+gcry_error_t
+gcry_pk_list (int *list, int *list_length)
+{
+ return _gcry_pk_list (list, list_length);
+}
+
+gcry_error_t
+gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags)
+{
+ if (!fips_is_operational ())
+ {
+ *h = NULL;
+ return gpg_error (fips_not_operational ());
+ }
+
+ return _gcry_md_open (h, algo, flags);
+}
+
+void
+gcry_md_close (gcry_md_hd_t hd)
+{
+ _gcry_md_close (hd);
+}
+
+gcry_error_t
+gcry_md_enable (gcry_md_hd_t hd, int algo)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+ return _gcry_md_enable (hd, algo);
+}
+
+gcry_error_t
+gcry_md_copy (gcry_md_hd_t *bhd, gcry_md_hd_t ahd)
+{
+ if (!fips_is_operational ())
+ {
+ *bhd = NULL;
+ return gpg_error (fips_not_operational ());
+ }
+ return _gcry_md_copy (bhd, ahd);
+}
+
+void
+gcry_md_reset (gcry_md_hd_t hd)
+{
+ _gcry_md_reset (hd);
+}
+
+gcry_error_t
+gcry_md_ctl (gcry_md_hd_t hd, int cmd, void *buffer, size_t buflen)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+ return _gcry_md_ctl (hd, cmd, buffer, buflen);
+}
+
+void
+gcry_md_write (gcry_md_hd_t hd, const void *buffer, size_t length)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ return;
+ }
+ _gcry_md_write (hd, buffer, length);
+}
+
+unsigned char *
+gcry_md_read (gcry_md_hd_t hd, int algo)
+{
+ return _gcry_md_read (hd, algo);
+}
+
+void
+gcry_md_hash_buffer (int algo, void *digest,
+ const void *buffer, size_t length)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ fips_signal_error ("called in non-operational state");
+ }
+ _gcry_md_hash_buffer (algo, digest, buffer, length);
+}
+
+int
+gcry_md_get_algo (gcry_md_hd_t hd)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ fips_signal_error ("used in non-operational state");
+ return 0;
+ }
+ return _gcry_md_get_algo (hd);
+}
+
+unsigned int
+gcry_md_get_algo_dlen (int algo)
+{
+ return _gcry_md_get_algo_dlen (algo);
+}
+
+int
+gcry_md_is_enabled (gcry_md_hd_t a, int algo)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ return 0;
+ }
+
+ return _gcry_md_is_enabled (a, algo);
+}
+
+int
+gcry_md_is_secure (gcry_md_hd_t a)
+{
+ return _gcry_md_is_secure (a);
+}
+
+gcry_error_t
+gcry_md_info (gcry_md_hd_t h, int what, void *buffer, size_t *nbytes)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+
+ return _gcry_md_info (h, what, buffer, nbytes);
+}
+
+gcry_error_t
+gcry_md_algo_info (int algo, int what, void *buffer, size_t *nbytes)
+{
+ return _gcry_md_algo_info (algo, what, buffer, nbytes);
+}
+
+const char *
+gcry_md_algo_name (int algo)
+{
+ return _gcry_md_algo_name (algo);
+}
+
+int
+gcry_md_map_name (const char* name)
+{
+ return _gcry_md_map_name (name);
+}
+
+gcry_error_t
+gcry_md_setkey (gcry_md_hd_t hd, const void *key, size_t keylen)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+ return _gcry_md_setkey (hd, key, keylen);
+}
+
+void
+gcry_md_debug (gcry_md_hd_t hd, const char *suffix)
+{
+ _gcry_md_debug (hd, suffix);
+}
+
+gcry_error_t
+gcry_md_list (int *list, int *list_length)
+{
+ return _gcry_md_list (list, list_length);
+}
+
+gcry_error_t
+gcry_ac_data_new (gcry_ac_data_t *data)
+{
+ return _gcry_ac_data_new (data);
+}
+
+void
+gcry_ac_data_destroy (gcry_ac_data_t data)
+{
+ _gcry_ac_data_destroy (data);
+}
+
+gcry_error_t
+gcry_ac_data_copy (gcry_ac_data_t *data_cp, gcry_ac_data_t data)
+{
+ return _gcry_ac_data_copy (data_cp, data);
+}
+
+unsigned int
+gcry_ac_data_length (gcry_ac_data_t data)
+{
+ return _gcry_ac_data_length (data);
+}
+
+void
+gcry_ac_data_clear (gcry_ac_data_t data)
+{
+ _gcry_ac_data_clear (data);
+}
+
+gcry_error_t
+gcry_ac_data_set (gcry_ac_data_t data, unsigned int flags,
+ const char *name, gcry_mpi_t mpi)
+{
+ return _gcry_ac_data_set (data, flags, name, mpi);
+}
+
+gcry_error_t
+gcry_ac_data_get_name (gcry_ac_data_t data, unsigned int flags,
+ const char *name, gcry_mpi_t *mpi)
+{
+ return _gcry_ac_data_get_name (data, flags, name, mpi);
+}
+
+gcry_error_t
+gcry_ac_data_get_index (gcry_ac_data_t data, unsigned int flags,
+ unsigned int idx, const char **name, gcry_mpi_t *mpi)
+{
+ return _gcry_ac_data_get_index (data, flags, idx, name, mpi);
+}
+
+gcry_error_t
+gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp,
+ const char **identifiers)
+{
+ return _gcry_ac_data_to_sexp (data, sexp, identifiers);
+}
+
+gcry_error_t
+gcry_ac_data_from_sexp (gcry_ac_data_t *data, gcry_sexp_t sexp,
+ const char **identifiers)
+{
+ return _gcry_ac_data_from_sexp (data, sexp, identifiers);
+}
+
+void
+gcry_ac_io_init (gcry_ac_io_t *ac_io, gcry_ac_io_mode_t mode,
+ gcry_ac_io_type_t type, ...)
+{
+ va_list arg_ptr;
+
+ va_start (arg_ptr, type);
+ _gcry_ac_io_init_va (ac_io, mode, type, arg_ptr);
+ va_end (arg_ptr);
+}
+
+void
+gcry_ac_io_init_va (gcry_ac_io_t *ac_io, gcry_ac_io_mode_t mode,
+ gcry_ac_io_type_t type, va_list ap)
+{
+ _gcry_ac_io_init_va (ac_io, mode, type, ap);
+}
+
+gcry_error_t
+gcry_ac_open (gcry_ac_handle_t *handle,
+ gcry_ac_id_t algorithm, unsigned int flags)
+{
+ return _gcry_ac_open (handle, algorithm, flags);
+}
+
+void
+gcry_ac_close (gcry_ac_handle_t handle)
+{
+ _gcry_ac_close (handle);
+}
+
+gcry_error_t
+gcry_ac_key_init (gcry_ac_key_t *key, gcry_ac_handle_t handle,
+ gcry_ac_key_type_t type, gcry_ac_data_t data)
+{
+ return _gcry_ac_key_init (key, handle, type, data);
+}
+
+gcry_error_t
+gcry_ac_key_pair_generate (gcry_ac_handle_t handle,
+ unsigned int nbits, void *spec,
+ gcry_ac_key_pair_t *key_pair,
+ gcry_mpi_t **miscdata)
+{
+ return _gcry_ac_key_pair_generate ( handle, nbits, spec, key_pair, miscdata);
+}
+
+gcry_ac_key_t
+gcry_ac_key_pair_extract (gcry_ac_key_pair_t keypair, gcry_ac_key_type_t which)
+{
+ return _gcry_ac_key_pair_extract (keypair, which);
+}
+
+gcry_ac_data_t
+gcry_ac_key_data_get (gcry_ac_key_t key)
+{
+ return _gcry_ac_key_data_get (key);
+}
+
+gcry_error_t
+gcry_ac_key_test (gcry_ac_handle_t handle, gcry_ac_key_t key)
+{
+ return _gcry_ac_key_test (handle, key);
+}
+
+gcry_error_t
+gcry_ac_key_get_nbits (gcry_ac_handle_t handle,
+ gcry_ac_key_t key, unsigned int *nbits)
+{
+ return _gcry_ac_key_get_nbits (handle, key, nbits);
+}
+
+gcry_error_t
+gcry_ac_key_get_grip (gcry_ac_handle_t handle, gcry_ac_key_t key,
+ unsigned char *key_grip)
+{
+ return _gcry_ac_key_get_grip (handle, key, key_grip);
+}
+
+void
+gcry_ac_key_destroy (gcry_ac_key_t key)
+{
+ _gcry_ac_key_destroy (key);
+}
+
+void
+gcry_ac_key_pair_destroy (gcry_ac_key_pair_t key_pair)
+{
+ _gcry_ac_key_pair_destroy (key_pair);
+}
+
+gcry_error_t
+gcry_ac_data_encode (gcry_ac_em_t method, unsigned int flags, void *options,
+ gcry_ac_io_t *io_read, gcry_ac_io_t *io_write)
+{
+ return _gcry_ac_data_encode (method, flags, options, io_read, io_write);
+}
+
+gcry_error_t
+gcry_ac_data_decode (gcry_ac_em_t method, unsigned int flags, void *options,
+ gcry_ac_io_t *io_read, gcry_ac_io_t *io_write)
+{
+ return _gcry_ac_data_decode (method, flags, options, io_read, io_write);
+}
+
+gcry_error_t
+gcry_ac_data_encrypt (gcry_ac_handle_t handle,
+ unsigned int flags,
+ gcry_ac_key_t key,
+ gcry_mpi_t data_plain,
+ gcry_ac_data_t *data_encrypted)
+{
+ return _gcry_ac_data_encrypt (handle, flags, key,
+ data_plain, data_encrypted);
+}
+
+gcry_error_t
+gcry_ac_data_decrypt (gcry_ac_handle_t handle,
+ unsigned int flags,
+ gcry_ac_key_t key,
+ gcry_mpi_t *data_plain,
+ gcry_ac_data_t data_encrypted)
+{
+ return _gcry_ac_data_decrypt (handle, flags, key,
+ data_plain, data_encrypted);
+}
+
+gcry_error_t
+gcry_ac_data_sign (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ gcry_mpi_t data,
+ gcry_ac_data_t *data_signature)
+{
+ return _gcry_ac_data_sign (handle, key, data, data_signature);
+}
+
+gcry_error_t
+gcry_ac_data_verify (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ gcry_mpi_t data,
+ gcry_ac_data_t data_signature)
+{
+ return _gcry_ac_data_verify (handle, key, data, data_signature);
+}
+
+gcry_error_t
+gcry_ac_data_encrypt_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_cipher)
+{
+ return _gcry_ac_data_encrypt_scheme (handle, scheme, flags, opts, key,
+ io_message, io_cipher);
+}
+
+gcry_error_t
+gcry_ac_data_decrypt_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_cipher,
+ gcry_ac_io_t *io_message)
+{
+ return _gcry_ac_data_decrypt_scheme (handle, scheme, flags, opts, key,
+ io_cipher, io_message);
+}
+
+gcry_error_t
+gcry_ac_data_sign_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_signature)
+{
+ return _gcry_ac_data_sign_scheme (handle, scheme, flags, opts, key,
+ io_message, io_signature);
+}
+
+gcry_error_t
+gcry_ac_data_verify_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_signature)
+{
+ return _gcry_ac_data_verify_scheme (handle, scheme, flags, opts, key,
+ io_message, io_signature);
+}
+
+gcry_error_t
+gcry_ac_id_to_name (gcry_ac_id_t algorithm, const char **name)
+{
+ /* This function is deprecated. We implement it in terms of the
+ suggested replacement. */
+ const char *tmp = _gcry_pk_algo_name (algorithm);
+ if (!*tmp)
+ return gcry_error (GPG_ERR_PUBKEY_ALGO);
+ *name = tmp;
+ return 0;
+}
+
+gcry_error_t
+gcry_ac_name_to_id (const char *name, gcry_ac_id_t *algorithm)
+{
+ /* This function is deprecated. We implement it in terms of the
+ suggested replacement. */
+ int algo = _gcry_pk_map_name (name);
+ if (!algo)
+ return gcry_error (GPG_ERR_PUBKEY_ALGO);
+ *algorithm = algo;
+ return 0;
+}
+
+gpg_error_t
+gcry_kdf_derive (const void *passphrase, size_t passphraselen,
+ int algo, int hashalgo,
+ const void *salt, size_t saltlen,
+ unsigned long iterations,
+ size_t keysize, void *keybuffer)
+{
+ return _gcry_kdf_derive (passphrase, passphraselen, algo, hashalgo,
+ salt, saltlen, iterations, keysize, keybuffer);
+}
+
+void
+gcry_randomize (void *buffer, size_t length, enum gcry_random_level level)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ fips_signal_fatal_error ("called in non-operational state");
+ fips_noreturn ();
+ }
+ _gcry_randomize (buffer, length, level);
+}
+
+gcry_error_t
+gcry_random_add_bytes (const void *buffer, size_t length, int quality)
+{
+ if (!fips_is_operational ())
+ return gpg_error (fips_not_operational ());
+ return _gcry_random_add_bytes (buffer, length, quality);
+}
+
+void *
+gcry_random_bytes (size_t nbytes, enum gcry_random_level level)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ fips_signal_fatal_error ("called in non-operational state");
+ fips_noreturn ();
+ }
+
+ return _gcry_random_bytes (nbytes,level);
+}
+
+void *
+gcry_random_bytes_secure (size_t nbytes, enum gcry_random_level level)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ fips_signal_fatal_error ("called in non-operational state");
+ fips_noreturn ();
+ }
+
+ return _gcry_random_bytes_secure (nbytes, level);
+}
+
+void
+gcry_mpi_randomize (gcry_mpi_t w,
+ unsigned int nbits, enum gcry_random_level level)
+{
+ _gcry_mpi_randomize (w, nbits, level);
+}
+
+void
+gcry_create_nonce (void *buffer, size_t length)
+{
+ if (!fips_is_operational ())
+ {
+ (void)fips_not_operational ();
+ fips_signal_fatal_error ("called in non-operational state");
+ fips_noreturn ();
+ }
+ _gcry_create_nonce (buffer, length);
+}
+
+gcry_error_t
+gcry_prime_generate (gcry_mpi_t *prime,
+ unsigned int prime_bits,
+ unsigned int factor_bits,
+ gcry_mpi_t **factors,
+ gcry_prime_check_func_t cb_func,
+ void *cb_arg,
+ gcry_random_level_t random_level,
+ unsigned int flags)
+{
+ return _gcry_prime_generate (prime, prime_bits, factor_bits, factors,
+ cb_func, cb_arg, random_level, flags);
+}
+
+gcry_error_t
+gcry_prime_group_generator (gcry_mpi_t *r_g,
+ gcry_mpi_t prime, gcry_mpi_t *factors,
+ gcry_mpi_t start_g)
+{
+ return _gcry_prime_group_generator (r_g, prime, factors, start_g);
+}
+
+void
+gcry_prime_release_factors (gcry_mpi_t *factors)
+{
+ _gcry_prime_release_factors (factors);
+}
+
+gcry_error_t
+gcry_prime_check (gcry_mpi_t x, unsigned int flags)
+{
+ return _gcry_prime_check (x, flags);
+}
+
+void
+gcry_set_progress_handler (gcry_handler_progress_t cb, void *cb_data)
+{
+ _gcry_set_progress_handler (cb, cb_data);
+}
+
+void
+gcry_set_allocation_handler (gcry_handler_alloc_t func_alloc,
+ gcry_handler_alloc_t func_alloc_secure,
+ gcry_handler_secure_check_t func_secure_check,
+ gcry_handler_realloc_t func_realloc,
+ gcry_handler_free_t func_free)
+{
+ _gcry_set_allocation_handler (func_alloc, func_alloc_secure,
+ func_secure_check, func_realloc, func_free);
+}
+
+void
+gcry_set_outofcore_handler (gcry_handler_no_mem_t h, void *opaque)
+{
+ _gcry_set_outofcore_handler (h, opaque);
+}
+
+void
+gcry_set_fatalerror_handler (gcry_handler_error_t fnc, void *opaque)
+{
+ _gcry_set_fatalerror_handler (fnc, opaque);
+}
+
+void
+gcry_set_log_handler (gcry_handler_log_t f, void *opaque)
+{
+ _gcry_set_log_handler (f, opaque);
+}
+
+void
+gcry_set_gettext_handler (const char *(*f)(const char*))
+{
+ _gcry_set_gettext_handler (f);
+}
+
+void *
+gcry_malloc (size_t n)
+{
+ return _gcry_malloc (n);
+}
+
+void *
+gcry_calloc (size_t n, size_t m)
+{
+ return _gcry_calloc (n, m);
+}
+
+void *
+gcry_malloc_secure (size_t n)
+{
+ return _gcry_malloc_secure (n);
+}
+
+void *
+gcry_calloc_secure (size_t n, size_t m)
+{
+ return _gcry_calloc_secure (n,m);
+}
+
+void *
+gcry_realloc (void *a, size_t n)
+{
+ return _gcry_realloc (a, n);
+}
+
+char *
+gcry_strdup (const char *string)
+{
+ return _gcry_strdup (string);
+}
+
+void *
+gcry_xmalloc (size_t n)
+{
+ return _gcry_xmalloc (n);
+}
+
+void *
+gcry_xcalloc (size_t n, size_t m)
+{
+ return _gcry_xcalloc (n, m);
+}
+
+void *
+gcry_xmalloc_secure (size_t n)
+{
+ return _gcry_xmalloc_secure (n);
+}
+
+void *
+gcry_xcalloc_secure (size_t n, size_t m)
+{
+ return _gcry_xcalloc_secure (n, m);
+}
+
+void *
+gcry_xrealloc (void *a, size_t n)
+{
+ return _gcry_xrealloc (a, n);
+}
+
+char *
+gcry_xstrdup (const char *a)
+{
+ return _gcry_xstrdup (a);
+}
+
+void
+gcry_free (void *a)
+{
+ _gcry_free (a);
+}
+
+int
+gcry_is_secure (const void *a)
+{
+ return _gcry_is_secure (a);
+}
+
+
+gcry_error_t
+gcry_cipher_register (gcry_cipher_spec_t *cipher, int *algorithm_id,
+ gcry_module_t *module)
+{
+ return _gcry_cipher_register (cipher, NULL, algorithm_id, module);
+}
+
+void
+gcry_cipher_unregister (gcry_module_t module)
+{
+ _gcry_cipher_unregister (module);
+}
+
+gcry_error_t
+gcry_pk_register (gcry_pk_spec_t *pubkey, unsigned int *algorithm_id,
+ gcry_module_t *module)
+{
+ return _gcry_pk_register (pubkey, NULL, algorithm_id, module);
+}
+
+void
+gcry_pk_unregister (gcry_module_t module)
+{
+ _gcry_pk_unregister (module);
+}
+
+gcry_error_t
+gcry_md_register (gcry_md_spec_t *digest, unsigned int *algorithm_id,
+ gcry_module_t *module)
+{
+ return _gcry_md_register (digest, NULL, algorithm_id, module);
+}
+
+void
+gcry_md_unregister (gcry_module_t module)
+{
+ _gcry_md_unregister (module);
+}
diff --git a/grub-core/lib/libgcrypt/src/visibility.h b/grub-core/lib/libgcrypt/src/visibility.h
new file mode 100644
index 0000000..3c1e8aa
--- /dev/null
+++ b/grub-core/lib/libgcrypt/src/visibility.h
@@ -0,0 +1,807 @@
+/* visibility.h - Set visibility attribute
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GCRY_VISIBILITY_H
+#define GCRY_VISIBILITY_H
+
+/* Redefine all public symbols with an underscore unless we already
+ use the underscore prefixed version internally. */
+#define gcry_check_version _gcry_check_version
+#define gcry_control _gcry_control
+
+#define gcry_set_allocation_handler _gcry_set_allocation_handler
+#define gcry_set_fatalerror_handler _gcry_set_fatalerror_handler
+#define gcry_set_gettext_handler _gcry_set_gettext_handler
+#define gcry_set_log_handler _gcry_set_log_handler
+#define gcry_set_outofcore_handler _gcry_set_outofcore_handler
+#define gcry_set_progress_handler _gcry_set_progress_handler
+#define gcry_err_code_from_errno _gcry_err_code_from_errno
+#define gcry_err_code_to_errno _gcry_err_code_to_errno
+#define gcry_err_make_from_errno _gcry_err_make_from_errno
+#define gcry_error_from_errno _gcry_error_from_errno
+#define gcry_strerror _gcry_strerror
+#define gcry_strsource _gcry_strsource
+
+#define gcry_free _gcry_free
+#define gcry_malloc _gcry_malloc
+#define gcry_malloc_secure _gcry_malloc_secure
+#define gcry_calloc _gcry_calloc
+#define gcry_calloc_secure _gcry_calloc_secure
+#define gcry_realloc _gcry_realloc
+#define gcry_strdup _gcry_strdup
+#define gcry_is_secure _gcry_is_secure
+#define gcry_xcalloc _gcry_xcalloc
+#define gcry_xcalloc_secure _gcry_xcalloc_secure
+#define gcry_xmalloc _gcry_xmalloc
+#define gcry_xmalloc_secure _gcry_xmalloc_secure
+#define gcry_xrealloc _gcry_xrealloc
+#define gcry_xstrdup _gcry_xstrdup
+
+#define gcry_md_algo_info _gcry_md_algo_info
+#define gcry_md_algo_name _gcry_md_algo_name
+#define gcry_md_close _gcry_md_close
+#define gcry_md_copy _gcry_md_copy
+#define gcry_md_ctl _gcry_md_ctl
+#define gcry_md_enable _gcry_md_enable
+#define gcry_md_get _gcry_md_get
+#define gcry_md_get_algo _gcry_md_get_algo
+#define gcry_md_get_algo_dlen _gcry_md_get_algo_dlen
+#define gcry_md_hash_buffer _gcry_md_hash_buffer
+#define gcry_md_info _gcry_md_info
+#define gcry_md_is_enabled _gcry_md_is_enabled
+#define gcry_md_is_secure _gcry_md_is_secure
+#define gcry_md_list _gcry_md_list
+#define gcry_md_map_name _gcry_md_map_name
+#define gcry_md_open _gcry_md_open
+#define gcry_md_read _gcry_md_read
+/* gcry_md_register and _gcry_md_register differ. */
+#define gcry_md_unregister _gcry_md_unregister
+#define gcry_md_reset _gcry_md_reset
+#define gcry_md_setkey _gcry_md_setkey
+#define gcry_md_write _gcry_md_write
+#define gcry_md_debug _gcry_md_debug
+
+#define gcry_cipher_algo_info _gcry_cipher_algo_info
+#define gcry_cipher_algo_name _gcry_cipher_algo_name
+#define gcry_cipher_close _gcry_cipher_close
+#define gcry_cipher_setkey _gcry_cipher_setkey
+#define gcry_cipher_setiv _gcry_cipher_setiv
+#define gcry_cipher_setctr _gcry_cipher_setctr
+#define gcry_cipher_ctl _gcry_cipher_ctl
+#define gcry_cipher_decrypt _gcry_cipher_decrypt
+#define gcry_cipher_encrypt _gcry_cipher_encrypt
+#define gcry_cipher_get_algo_blklen _gcry_cipher_get_algo_blklen
+#define gcry_cipher_get_algo_keylen _gcry_cipher_get_algo_keylen
+#define gcry_cipher_info _gcry_cipher_info
+#define gcry_cipher_list _gcry_cipher_list
+#define gcry_cipher_map_name _gcry_cipher_map_name
+#define gcry_cipher_mode_from_oid _gcry_cipher_mode_from_oid
+#define gcry_cipher_open _gcry_cipher_open
+/* gcry_cipher_register and _gcry_cipher_register differ. */
+#define gcry_cipher_unregister _gcry_cipher_unregister
+
+#define gcry_pk_algo_info _gcry_pk_algo_info
+#define gcry_pk_algo_name _gcry_pk_algo_name
+#define gcry_pk_ctl _gcry_pk_ctl
+#define gcry_pk_decrypt _gcry_pk_decrypt
+#define gcry_pk_encrypt _gcry_pk_encrypt
+#define gcry_pk_genkey _gcry_pk_genkey
+#define gcry_pk_get_keygrip _gcry_pk_get_keygrip
+#define gcry_pk_get_curve _gcry_pk_get_curve
+#define gcry_pk_get_param _gcry_pk_get_param
+#define gcry_pk_get_nbits _gcry_pk_get_nbits
+#define gcry_pk_list _gcry_pk_list
+#define gcry_pk_map_name _gcry_pk_map_name
+/* gcry_pk_register and _gcry_pk_register differ. */
+#define gcry_pk_unregister _gcry_pk_unregister
+#define gcry_pk_sign _gcry_pk_sign
+#define gcry_pk_testkey _gcry_pk_testkey
+#define gcry_pk_verify _gcry_pk_verify
+
+#define gcry_ac_data_new _gcry_ac_data_new
+#define gcry_ac_data_destroy _gcry_ac_data_destroy
+#define gcry_ac_data_copy _gcry_ac_data_copy
+#define gcry_ac_data_length _gcry_ac_data_length
+#define gcry_ac_data_clear _gcry_ac_data_clear
+#define gcry_ac_data_set _gcry_ac_data_set
+#define gcry_ac_data_get_name _gcry_ac_data_get_name
+#define gcry_ac_data_get_index _gcry_ac_data_get_index
+#define gcry_ac_open _gcry_ac_open
+#define gcry_ac_close _gcry_ac_close
+#define gcry_ac_key_init _gcry_ac_key_init
+#define gcry_ac_key_pair_generate _gcry_ac_key_pair_generate
+#define gcry_ac_key_pair_extract _gcry_ac_key_pair_extract
+#define gcry_ac_key_data_get _gcry_ac_key_data_get
+#define gcry_ac_key_test _gcry_ac_key_test
+#define gcry_ac_key_get_nbits _gcry_ac_key_get_nbits
+#define gcry_ac_key_get_grip _gcry_ac_key_get_grip
+#define gcry_ac_key_destroy _gcry_ac_key_destroy
+#define gcry_ac_key_pair_destroy _gcry_ac_key_pair_destroy
+#define gcry_ac_data_encrypt _gcry_ac_data_encrypt
+#define gcry_ac_data_decrypt _gcry_ac_data_decrypt
+#define gcry_ac_data_sign _gcry_ac_data_sign
+#define gcry_ac_data_verify _gcry_ac_data_verify
+#define gcry_ac_id_to_name _gcry_ac_id_to_name
+#define gcry_ac_name_to_id _gcry_ac_name_to_id
+#define gcry_ac_data_encode _gcry_ac_data_encode
+#define gcry_ac_data_decode _gcry_ac_data_decode
+#define gcry_ac_mpi_to_os _gcry_ac_mpi_to_os
+#define gcry_ac_mpi_to_os_alloc _gcry_ac_mpi_to_os_alloc
+#define gcry_ac_os_to_mpi _gcry_ac_os_to_mpi
+#define gcry_ac_data_encrypt_scheme _gcry_ac_data_encrypt_scheme
+#define gcry_ac_data_decrypt_scheme _gcry_ac_data_decrypt_scheme
+#define gcry_ac_data_sign_scheme _gcry_ac_data_sign_scheme
+#define gcry_ac_data_verify_scheme _gcry_ac_data_verify_scheme
+#define gcry_ac_data_to_sexp _gcry_ac_data_to_sexp
+#define gcry_ac_data_from_sexp _gcry_ac_data_from_sexp
+#define gcry_ac_io_init _gcry_ac_io_init
+#define gcry_ac_io_init_va _gcry_ac_io_init_va
+
+#define gcry_kdf_derive _gcry_kdf_derive
+
+#define gcry_prime_check _gcry_prime_check
+#define gcry_prime_generate _gcry_prime_generate
+#define gcry_prime_group_generator _gcry_prime_group_generator
+#define gcry_prime_release_factors _gcry_prime_release_factors
+
+#define gcry_random_add_bytes _gcry_random_add_bytes
+#define gcry_random_bytes _gcry_random_bytes
+#define gcry_random_bytes_secure _gcry_random_bytes_secure
+#define gcry_randomize _gcry_randomize
+#define gcry_create_nonce _gcry_create_nonce
+
+#define gcry_sexp_alist _gcry_sexp_alist
+#define gcry_sexp_append _gcry_sexp_append
+#define gcry_sexp_build _gcry_sexp_build
+#define gcry_sexp_build_array _gcry_sexp_build_array
+#define gcry_sexp_cadr _gcry_sexp_cadr
+#define gcry_sexp_canon_len _gcry_sexp_canon_len
+#define gcry_sexp_car _gcry_sexp_car
+#define gcry_sexp_cdr _gcry_sexp_cdr
+#define gcry_sexp_cons _gcry_sexp_cons
+#define gcry_sexp_create _gcry_sexp_create
+#define gcry_sexp_dump _gcry_sexp_dump
+#define gcry_sexp_find_token _gcry_sexp_find_token
+#define gcry_sexp_length _gcry_sexp_length
+#define gcry_sexp_new _gcry_sexp_new
+#define gcry_sexp_nth _gcry_sexp_nth
+#define gcry_sexp_nth_data _gcry_sexp_nth_data
+#define gcry_sexp_nth_mpi _gcry_sexp_nth_mpi
+#define gcry_sexp_prepend _gcry_sexp_prepend
+#define gcry_sexp_release _gcry_sexp_release
+#define gcry_sexp_sprint _gcry_sexp_sprint
+#define gcry_sexp_sscan _gcry_sexp_sscan
+#define gcry_sexp_vlist _gcry_sexp_vlist
+#define gcry_sexp_nth_string _gcry_sexp_nth_string
+
+#define gcry_mpi_add _gcry_mpi_add
+#define gcry_mpi_add_ui _gcry_mpi_add_ui
+#define gcry_mpi_addm _gcry_mpi_addm
+#define gcry_mpi_aprint _gcry_mpi_aprint
+#define gcry_mpi_clear_bit _gcry_mpi_clear_bit
+#define gcry_mpi_clear_flag _gcry_mpi_clear_flag
+#define gcry_mpi_clear_highbit _gcry_mpi_clear_highbit
+#define gcry_mpi_cmp _gcry_mpi_cmp
+#define gcry_mpi_cmp_ui _gcry_mpi_cmp_ui
+#define gcry_mpi_copy _gcry_mpi_copy
+#define gcry_mpi_div _gcry_mpi_div
+#define gcry_mpi_dump _gcry_mpi_dump
+#define gcry_mpi_gcd _gcry_mpi_gcd
+#define gcry_mpi_get_flag _gcry_mpi_get_flag
+#define gcry_mpi_get_nbits _gcry_mpi_get_nbits
+#define gcry_mpi_get_opaque _gcry_mpi_get_opaque
+#define gcry_mpi_invm _gcry_mpi_invm
+#define gcry_mpi_mod _gcry_mpi_mod
+#define gcry_mpi_mul _gcry_mpi_mul
+#define gcry_mpi_mul_2exp _gcry_mpi_mul_2exp
+#define gcry_mpi_mul_ui _gcry_mpi_mul_ui
+#define gcry_mpi_mulm _gcry_mpi_mulm
+#define gcry_mpi_new _gcry_mpi_new
+#define gcry_mpi_powm _gcry_mpi_powm
+#define gcry_mpi_print _gcry_mpi_print
+#define gcry_mpi_randomize _gcry_mpi_randomize
+#define gcry_mpi_release _gcry_mpi_release
+#define gcry_mpi_rshift _gcry_mpi_rshift
+#define gcry_mpi_lshift _gcry_mpi_lshift
+#define gcry_mpi_scan _gcry_mpi_scan
+#define gcry_mpi_set _gcry_mpi_set
+#define gcry_mpi_set_bit _gcry_mpi_set_bit
+#define gcry_mpi_set_flag _gcry_mpi_set_flag
+#define gcry_mpi_set_highbit _gcry_mpi_set_highbit
+#define gcry_mpi_set_opaque _gcry_mpi_set_opaque
+#define gcry_mpi_set_ui _gcry_mpi_set_ui
+#define gcry_mpi_snew _gcry_mpi_snew
+#define gcry_mpi_sub _gcry_mpi_sub
+#define gcry_mpi_sub_ui _gcry_mpi_sub_ui
+#define gcry_mpi_subm _gcry_mpi_subm
+#define gcry_mpi_swap _gcry_mpi_swap
+#define gcry_mpi_test_bit _gcry_mpi_test_bit
+
+
+/* Include the main header here so that public symbols are mapped to
+ the internal underscored ones. */
+#ifdef _GCRY_INCLUDED_BY_VISIBILITY_C
+ /* We need to redeclare the deprecated functions without the
+ deprecated attribute. */
+# define GCRYPT_NO_DEPRECATED
+# include "gcrypt.h"
+/* The algorithm IDs. */
+ gcry_error_t gcry_ac_data_new (gcry_ac_data_t *data);
+ void gcry_ac_data_destroy (gcry_ac_data_t data);
+ gcry_error_t gcry_ac_data_copy (gcry_ac_data_t *data_cp,
+ gcry_ac_data_t data);
+ unsigned int gcry_ac_data_length (gcry_ac_data_t data);
+ void gcry_ac_data_clear (gcry_ac_data_t data);
+ gcry_error_t gcry_ac_data_set (gcry_ac_data_t data, unsigned int flags,
+ const char *name, gcry_mpi_t mpi);
+ gcry_error_t gcry_ac_data_get_name (gcry_ac_data_t data, unsigned int flags,
+ const char *name, gcry_mpi_t *mpi);
+ gcry_error_t gcry_ac_data_get_index (gcry_ac_data_t data, unsigned int flags,
+ unsigned int idx,
+ const char **name, gcry_mpi_t *mpi);
+ gcry_error_t gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp,
+ const char **identifiers);
+ gcry_error_t gcry_ac_data_from_sexp (gcry_ac_data_t *data, gcry_sexp_t sexp,
+ const char **identifiers);
+ void gcry_ac_io_init (gcry_ac_io_t *ac_io, gcry_ac_io_mode_t mode,
+ gcry_ac_io_type_t type, ...);
+ void gcry_ac_io_init_va (gcry_ac_io_t *ac_io, gcry_ac_io_mode_t mode,
+ gcry_ac_io_type_t type, va_list ap);
+ gcry_error_t gcry_ac_open (gcry_ac_handle_t *handle,
+ gcry_ac_id_t algorithm, unsigned int flags);
+ void gcry_ac_close (gcry_ac_handle_t handle);
+ gcry_error_t gcry_ac_key_init (gcry_ac_key_t *key, gcry_ac_handle_t handle,
+ gcry_ac_key_type_t type, gcry_ac_data_t data);
+ gcry_error_t gcry_ac_key_pair_generate (gcry_ac_handle_t handle,
+ unsigned int nbits, void *spec,
+ gcry_ac_key_pair_t *key_pair,
+ gcry_mpi_t **misc_data);
+ gcry_ac_key_t gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair,
+ gcry_ac_key_type_t which);
+ gcry_ac_data_t gcry_ac_key_data_get (gcry_ac_key_t key);
+ gcry_error_t gcry_ac_key_test (gcry_ac_handle_t handle, gcry_ac_key_t key);
+ gcry_error_t gcry_ac_key_get_nbits (gcry_ac_handle_t handle,
+ gcry_ac_key_t key, unsigned int *nbits);
+ gcry_error_t gcry_ac_key_get_grip (gcry_ac_handle_t handle, gcry_ac_key_t key,
+ unsigned char *key_grip);
+ void gcry_ac_key_destroy (gcry_ac_key_t key);
+ void gcry_ac_key_pair_destroy (gcry_ac_key_pair_t key_pair);
+ gcry_error_t gcry_ac_data_encode (gcry_ac_em_t method,
+ unsigned int flags, void *options,
+ gcry_ac_io_t *io_read,
+ gcry_ac_io_t *io_write);
+ gcry_error_t gcry_ac_data_decode (gcry_ac_em_t method,
+ unsigned int flags, void *options,
+ gcry_ac_io_t *io_read,
+ gcry_ac_io_t *io_write);
+ gcry_error_t gcry_ac_data_encrypt (gcry_ac_handle_t handle,
+ unsigned int flags,
+ gcry_ac_key_t key,
+ gcry_mpi_t data_plain,
+ gcry_ac_data_t *data_encrypted);
+ gcry_error_t gcry_ac_data_decrypt (gcry_ac_handle_t handle,
+ unsigned int flags,
+ gcry_ac_key_t key,
+ gcry_mpi_t *data_plain,
+ gcry_ac_data_t data_encrypted);
+ gcry_error_t gcry_ac_data_sign (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ gcry_mpi_t data,
+ gcry_ac_data_t *data_signature);
+ gcry_error_t gcry_ac_data_verify (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ gcry_mpi_t data,
+ gcry_ac_data_t data_signature);
+ gcry_error_t gcry_ac_data_encrypt_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_cipher);
+ gcry_error_t gcry_ac_data_decrypt_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_cipher,
+ gcry_ac_io_t *io_message);
+ gcry_error_t gcry_ac_data_sign_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_signature);
+ gcry_error_t gcry_ac_data_verify_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_signature);
+ gcry_error_t gcry_ac_id_to_name (gcry_ac_id_t algorithm, const char **name);
+ gcry_error_t gcry_ac_name_to_id (const char *name, gcry_ac_id_t *algorithm);
+#else
+# include "gcrypt.h"
+#endif
+
+/* Prototypes of functions exported but not ready for use. */
+gcry_err_code_t gcry_md_get (gcry_md_hd_t hd, int algo,
+ unsigned char *buffer, int buflen);
+void gcry_ac_mpi_to_os (gcry_mpi_t mpi, unsigned char *os, size_t os_n);
+gcry_error_t gcry_ac_mpi_to_os_alloc (gcry_mpi_t mpi, unsigned char **os,
+ size_t *os_n);
+void gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n);
+
+
+
+/* Our use of the ELF visibility feature works by passing
+ -fvisibiliy=hidden on the command line and by explicitly marking
+ all exported functions as visible.
+
+ NOTE: When adding new functions, please make sure to add them to
+ libgcrypt.vers and libgcrypt.def as well. */
+
+#ifdef _GCRY_INCLUDED_BY_VISIBILITY_C
+
+/* A macro to flag a function as visible. Note that we take the
+ definition from the mapped name. */
+#ifdef GCRY_USE_VISIBILITY
+# define MARK_VISIBLE(name) \
+ extern __typeof__ (_##name) name __attribute__ ((visibility("default")));
+# define MARK_VISIBLEX(name) \
+ extern __typeof__ (name) name __attribute__ ((visibility("default")));
+#else
+# define MARK_VISIBLE(name) /* */
+# define MARK_VISIBLEX(name) /* */
+#endif
+
+
+/* First undef all redefined symbols so that we set the attribute on
+ the correct version name. */
+#undef gcry_check_version
+#undef gcry_control
+
+#undef gcry_set_allocation_handler
+#undef gcry_set_fatalerror_handler
+#undef gcry_set_gettext_handler
+#undef gcry_set_log_handler
+#undef gcry_set_outofcore_handler
+#undef gcry_set_progress_handler
+#undef gcry_err_code_from_errno
+#undef gcry_err_code_to_errno
+#undef gcry_err_make_from_errno
+#undef gcry_error_from_errno
+#undef gcry_strerror
+#undef gcry_strsource
+
+#undef gcry_free
+#undef gcry_malloc
+#undef gcry_malloc_secure
+#undef gcry_calloc
+#undef gcry_calloc_secure
+#undef gcry_realloc
+#undef gcry_strdup
+#undef gcry_is_secure
+#undef gcry_xcalloc
+#undef gcry_xcalloc_secure
+#undef gcry_xmalloc
+#undef gcry_xmalloc_secure
+#undef gcry_xrealloc
+#undef gcry_xstrdup
+
+#undef gcry_md_algo_info
+#undef gcry_md_algo_name
+#undef gcry_md_close
+#undef gcry_md_copy
+#undef gcry_md_ctl
+#undef gcry_md_enable
+#undef gcry_md_get
+#undef gcry_md_get_algo
+#undef gcry_md_get_algo_dlen
+#undef gcry_md_hash_buffer
+#undef gcry_md_info
+#undef gcry_md_is_enabled
+#undef gcry_md_is_secure
+#undef gcry_md_list
+#undef gcry_md_map_name
+#undef gcry_md_open
+#undef gcry_md_read
+/* gcry_md_register is not anymore a macro. */
+#undef gcry_md_unregister
+#undef gcry_md_reset
+#undef gcry_md_setkey
+#undef gcry_md_write
+#undef gcry_md_debug
+
+#undef gcry_cipher_algo_info
+#undef gcry_cipher_algo_name
+#undef gcry_cipher_close
+#undef gcry_cipher_setkey
+#undef gcry_cipher_setiv
+#undef gcry_cipher_setctr
+#undef gcry_cipher_ctl
+#undef gcry_cipher_decrypt
+#undef gcry_cipher_encrypt
+#undef gcry_cipher_get_algo_blklen
+#undef gcry_cipher_get_algo_keylen
+#undef gcry_cipher_info
+#undef gcry_cipher_list
+#undef gcry_cipher_map_name
+#undef gcry_cipher_mode_from_oid
+#undef gcry_cipher_open
+/* gcry_cipher_register is not anymore a macro. */
+#undef gcry_cipher_unregister
+
+#undef gcry_pk_algo_info
+#undef gcry_pk_algo_name
+#undef gcry_pk_ctl
+#undef gcry_pk_decrypt
+#undef gcry_pk_encrypt
+#undef gcry_pk_genkey
+#undef gcry_pk_get_keygrip
+#undef gcry_pk_get_curve
+#undef gcry_pk_get_param
+#undef gcry_pk_get_nbits
+#undef gcry_pk_list
+#undef gcry_pk_map_name
+/* gcry_pk_register is not anymore a macro. */
+#undef gcry_pk_unregister
+#undef gcry_pk_sign
+#undef gcry_pk_testkey
+#undef gcry_pk_verify
+
+#undef gcry_ac_data_new
+#undef gcry_ac_data_destroy
+#undef gcry_ac_data_copy
+#undef gcry_ac_data_length
+#undef gcry_ac_data_clear
+#undef gcry_ac_data_set
+#undef gcry_ac_data_get_name
+#undef gcry_ac_data_get_index
+#undef gcry_ac_open
+#undef gcry_ac_close
+#undef gcry_ac_key_init
+#undef gcry_ac_key_pair_generate
+#undef gcry_ac_key_pair_extract
+#undef gcry_ac_key_data_get
+#undef gcry_ac_key_test
+#undef gcry_ac_key_get_nbits
+#undef gcry_ac_key_get_grip
+#undef gcry_ac_key_destroy
+#undef gcry_ac_key_pair_destroy
+#undef gcry_ac_data_encrypt
+#undef gcry_ac_data_decrypt
+#undef gcry_ac_data_sign
+#undef gcry_ac_data_verify
+#undef gcry_ac_id_to_name
+#undef gcry_ac_name_to_id
+#undef gcry_ac_data_encode
+#undef gcry_ac_data_decode
+#undef gcry_ac_mpi_to_os
+#undef gcry_ac_mpi_to_os_alloc
+#undef gcry_ac_os_to_mpi
+#undef gcry_ac_data_encrypt_scheme
+#undef gcry_ac_data_decrypt_scheme
+#undef gcry_ac_data_sign_scheme
+#undef gcry_ac_data_verify_scheme
+#undef gcry_ac_data_to_sexp
+#undef gcry_ac_data_from_sexp
+#undef gcry_ac_io_init
+#undef gcry_ac_io_init_va
+
+#undef gcry_kdf_derive
+
+#undef gcry_prime_check
+#undef gcry_prime_generate
+#undef gcry_prime_group_generator
+#undef gcry_prime_release_factors
+
+#undef gcry_random_add_bytes
+#undef gcry_random_bytes
+#undef gcry_random_bytes_secure
+#undef gcry_randomize
+#undef gcry_create_nonce
+
+#undef gcry_sexp_alist
+#undef gcry_sexp_append
+#undef gcry_sexp_build
+#undef gcry_sexp_build_array
+#undef gcry_sexp_cadr
+#undef gcry_sexp_canon_len
+#undef gcry_sexp_car
+#undef gcry_sexp_cdr
+#undef gcry_sexp_cons
+#undef gcry_sexp_create
+#undef gcry_sexp_dump
+#undef gcry_sexp_find_token
+#undef gcry_sexp_length
+#undef gcry_sexp_new
+#undef gcry_sexp_nth
+#undef gcry_sexp_nth_data
+#undef gcry_sexp_nth_mpi
+#undef gcry_sexp_prepend
+#undef gcry_sexp_release
+#undef gcry_sexp_sprint
+#undef gcry_sexp_sscan
+#undef gcry_sexp_vlist
+#undef gcry_sexp_nth_string
+
+#undef gcry_mpi_add
+#undef gcry_mpi_add_ui
+#undef gcry_mpi_addm
+#undef gcry_mpi_aprint
+#undef gcry_mpi_clear_bit
+#undef gcry_mpi_clear_flag
+#undef gcry_mpi_clear_highbit
+#undef gcry_mpi_cmp
+#undef gcry_mpi_cmp_ui
+#undef gcry_mpi_copy
+#undef gcry_mpi_div
+#undef gcry_mpi_dump
+#undef gcry_mpi_gcd
+#undef gcry_mpi_get_flag
+#undef gcry_mpi_get_nbits
+#undef gcry_mpi_get_opaque
+#undef gcry_mpi_invm
+#undef gcry_mpi_mod
+#undef gcry_mpi_mul
+#undef gcry_mpi_mul_2exp
+#undef gcry_mpi_mul_ui
+#undef gcry_mpi_mulm
+#undef gcry_mpi_new
+#undef gcry_mpi_powm
+#undef gcry_mpi_print
+#undef gcry_mpi_randomize
+#undef gcry_mpi_release
+#undef gcry_mpi_rshift
+#undef gcry_mpi_lshift
+#undef gcry_mpi_scan
+#undef gcry_mpi_set
+#undef gcry_mpi_set_bit
+#undef gcry_mpi_set_flag
+#undef gcry_mpi_set_highbit
+#undef gcry_mpi_set_opaque
+#undef gcry_mpi_set_ui
+#undef gcry_mpi_snew
+#undef gcry_mpi_sub
+#undef gcry_mpi_sub_ui
+#undef gcry_mpi_subm
+#undef gcry_mpi_swap
+#undef gcry_mpi_test_bit
+
+
+/* Now mark all symbols. */
+
+MARK_VISIBLE (gcry_check_version)
+MARK_VISIBLE (gcry_control)
+
+MARK_VISIBLE (gcry_set_allocation_handler)
+MARK_VISIBLE (gcry_set_fatalerror_handler)
+MARK_VISIBLE (gcry_set_gettext_handler)
+MARK_VISIBLE (gcry_set_log_handler)
+MARK_VISIBLE (gcry_set_outofcore_handler)
+MARK_VISIBLE (gcry_set_progress_handler)
+MARK_VISIBLE (gcry_err_code_from_errno)
+MARK_VISIBLE (gcry_err_code_to_errno)
+MARK_VISIBLE (gcry_err_make_from_errno)
+MARK_VISIBLE (gcry_error_from_errno)
+MARK_VISIBLE (gcry_strerror)
+MARK_VISIBLE (gcry_strsource)
+
+MARK_VISIBLE (gcry_free)
+MARK_VISIBLE (gcry_malloc)
+MARK_VISIBLE (gcry_malloc_secure)
+MARK_VISIBLE (gcry_calloc)
+MARK_VISIBLE (gcry_calloc_secure)
+MARK_VISIBLE (gcry_realloc)
+MARK_VISIBLE (gcry_strdup)
+MARK_VISIBLE (gcry_is_secure)
+MARK_VISIBLE (gcry_xcalloc)
+MARK_VISIBLE (gcry_xcalloc_secure)
+MARK_VISIBLE (gcry_xmalloc)
+MARK_VISIBLE (gcry_xmalloc_secure)
+MARK_VISIBLE (gcry_xrealloc)
+MARK_VISIBLE (gcry_xstrdup)
+
+MARK_VISIBLE (gcry_md_algo_info)
+MARK_VISIBLE (gcry_md_algo_name)
+MARK_VISIBLE (gcry_md_close)
+MARK_VISIBLE (gcry_md_copy)
+MARK_VISIBLE (gcry_md_ctl)
+MARK_VISIBLE (gcry_md_enable)
+MARK_VISIBLE (gcry_md_get)
+MARK_VISIBLE (gcry_md_get_algo)
+MARK_VISIBLE (gcry_md_get_algo_dlen)
+MARK_VISIBLE (gcry_md_hash_buffer)
+MARK_VISIBLE (gcry_md_info)
+MARK_VISIBLE (gcry_md_is_enabled)
+MARK_VISIBLE (gcry_md_is_secure)
+MARK_VISIBLE (gcry_md_list)
+MARK_VISIBLE (gcry_md_map_name)
+MARK_VISIBLE (gcry_md_open)
+MARK_VISIBLE (gcry_md_read)
+MARK_VISIBLEX(gcry_md_register)
+MARK_VISIBLE (gcry_md_reset)
+MARK_VISIBLE (gcry_md_setkey)
+MARK_VISIBLE (gcry_md_unregister)
+MARK_VISIBLE (gcry_md_write)
+MARK_VISIBLE (gcry_md_debug)
+
+MARK_VISIBLE (gcry_cipher_algo_info)
+MARK_VISIBLE (gcry_cipher_algo_name)
+MARK_VISIBLE (gcry_cipher_close)
+MARK_VISIBLE (gcry_cipher_setkey)
+MARK_VISIBLE (gcry_cipher_setiv)
+MARK_VISIBLE (gcry_cipher_setctr)
+MARK_VISIBLE (gcry_cipher_ctl)
+MARK_VISIBLE (gcry_cipher_decrypt)
+MARK_VISIBLE (gcry_cipher_encrypt)
+MARK_VISIBLE (gcry_cipher_get_algo_blklen)
+MARK_VISIBLE (gcry_cipher_get_algo_keylen)
+MARK_VISIBLE (gcry_cipher_info)
+MARK_VISIBLE (gcry_cipher_list)
+MARK_VISIBLE (gcry_cipher_map_name)
+MARK_VISIBLE (gcry_cipher_mode_from_oid)
+MARK_VISIBLE (gcry_cipher_open)
+MARK_VISIBLEX(gcry_cipher_register)
+MARK_VISIBLE (gcry_cipher_unregister)
+
+MARK_VISIBLE (gcry_pk_algo_info)
+MARK_VISIBLE (gcry_pk_algo_name)
+MARK_VISIBLE (gcry_pk_ctl)
+MARK_VISIBLE (gcry_pk_decrypt)
+MARK_VISIBLE (gcry_pk_encrypt)
+MARK_VISIBLE (gcry_pk_genkey)
+MARK_VISIBLE (gcry_pk_get_keygrip)
+MARK_VISIBLE (gcry_pk_get_curve)
+MARK_VISIBLE (gcry_pk_get_param)
+MARK_VISIBLE (gcry_pk_get_nbits)
+MARK_VISIBLE (gcry_pk_list)
+MARK_VISIBLE (gcry_pk_map_name)
+MARK_VISIBLEX(gcry_pk_register)
+MARK_VISIBLE (gcry_pk_sign)
+MARK_VISIBLE (gcry_pk_testkey)
+MARK_VISIBLE (gcry_pk_unregister)
+MARK_VISIBLE (gcry_pk_verify)
+
+MARK_VISIBLE (gcry_ac_data_new)
+MARK_VISIBLE (gcry_ac_data_destroy)
+MARK_VISIBLE (gcry_ac_data_copy)
+MARK_VISIBLE (gcry_ac_data_length)
+MARK_VISIBLE (gcry_ac_data_clear)
+MARK_VISIBLE (gcry_ac_data_set)
+MARK_VISIBLE (gcry_ac_data_get_name)
+MARK_VISIBLE (gcry_ac_data_get_index)
+MARK_VISIBLE (gcry_ac_open)
+MARK_VISIBLE (gcry_ac_close)
+MARK_VISIBLE (gcry_ac_key_init)
+MARK_VISIBLE (gcry_ac_key_pair_generate)
+MARK_VISIBLE (gcry_ac_key_pair_extract)
+MARK_VISIBLE (gcry_ac_key_data_get)
+MARK_VISIBLE (gcry_ac_key_test)
+MARK_VISIBLE (gcry_ac_key_get_nbits)
+MARK_VISIBLE (gcry_ac_key_get_grip)
+MARK_VISIBLE (gcry_ac_key_destroy)
+MARK_VISIBLE (gcry_ac_key_pair_destroy)
+MARK_VISIBLE (gcry_ac_data_encrypt)
+MARK_VISIBLE (gcry_ac_data_decrypt)
+MARK_VISIBLE (gcry_ac_data_sign)
+MARK_VISIBLE (gcry_ac_data_verify)
+MARK_VISIBLE (gcry_ac_id_to_name)
+MARK_VISIBLE (gcry_ac_name_to_id)
+/* MARK_VISIBLE (gcry_ac_list) Not defined although it is in
+ libgcrypt.vers. */
+MARK_VISIBLE (gcry_ac_data_encode)
+MARK_VISIBLE (gcry_ac_data_decode)
+MARK_VISIBLE (gcry_ac_mpi_to_os)
+MARK_VISIBLE (gcry_ac_mpi_to_os_alloc)
+MARK_VISIBLE (gcry_ac_os_to_mpi)
+MARK_VISIBLE (gcry_ac_data_encrypt_scheme)
+MARK_VISIBLE (gcry_ac_data_decrypt_scheme)
+MARK_VISIBLE (gcry_ac_data_sign_scheme)
+MARK_VISIBLE (gcry_ac_data_verify_scheme)
+MARK_VISIBLE (gcry_ac_data_to_sexp)
+MARK_VISIBLE (gcry_ac_data_from_sexp)
+MARK_VISIBLE (gcry_ac_io_init)
+MARK_VISIBLE (gcry_ac_io_init_va)
+
+MARK_VISIBLE (gcry_kdf_derive)
+
+MARK_VISIBLE (gcry_prime_check)
+MARK_VISIBLE (gcry_prime_generate)
+MARK_VISIBLE (gcry_prime_group_generator)
+MARK_VISIBLE (gcry_prime_release_factors)
+
+MARK_VISIBLE (gcry_random_add_bytes)
+MARK_VISIBLE (gcry_random_bytes)
+MARK_VISIBLE (gcry_random_bytes_secure)
+MARK_VISIBLE (gcry_randomize)
+MARK_VISIBLE (gcry_create_nonce)
+
+MARK_VISIBLE (gcry_sexp_alist)
+MARK_VISIBLE (gcry_sexp_append)
+MARK_VISIBLE (gcry_sexp_build)
+MARK_VISIBLE (gcry_sexp_build_array)
+MARK_VISIBLE (gcry_sexp_cadr)
+MARK_VISIBLE (gcry_sexp_canon_len)
+MARK_VISIBLE (gcry_sexp_car)
+MARK_VISIBLE (gcry_sexp_cdr)
+MARK_VISIBLE (gcry_sexp_cons)
+MARK_VISIBLE (gcry_sexp_create)
+MARK_VISIBLE (gcry_sexp_dump)
+MARK_VISIBLE (gcry_sexp_find_token)
+MARK_VISIBLE (gcry_sexp_length)
+MARK_VISIBLE (gcry_sexp_new)
+MARK_VISIBLE (gcry_sexp_nth)
+MARK_VISIBLE (gcry_sexp_nth_data)
+MARK_VISIBLE (gcry_sexp_nth_mpi)
+MARK_VISIBLE (gcry_sexp_prepend)
+MARK_VISIBLE (gcry_sexp_release)
+MARK_VISIBLE (gcry_sexp_sprint)
+MARK_VISIBLE (gcry_sexp_sscan)
+MARK_VISIBLE (gcry_sexp_vlist)
+MARK_VISIBLE (gcry_sexp_nth_string)
+
+MARK_VISIBLE (gcry_mpi_add)
+MARK_VISIBLE (gcry_mpi_add_ui)
+MARK_VISIBLE (gcry_mpi_addm)
+MARK_VISIBLE (gcry_mpi_aprint)
+MARK_VISIBLE (gcry_mpi_clear_bit)
+MARK_VISIBLE (gcry_mpi_clear_flag)
+MARK_VISIBLE (gcry_mpi_clear_highbit)
+MARK_VISIBLE (gcry_mpi_cmp)
+MARK_VISIBLE (gcry_mpi_cmp_ui)
+MARK_VISIBLE (gcry_mpi_copy)
+MARK_VISIBLE (gcry_mpi_div)
+MARK_VISIBLE (gcry_mpi_dump)
+MARK_VISIBLE (gcry_mpi_gcd)
+MARK_VISIBLE (gcry_mpi_get_flag)
+MARK_VISIBLE (gcry_mpi_get_nbits)
+MARK_VISIBLE (gcry_mpi_get_opaque)
+MARK_VISIBLE (gcry_mpi_invm)
+MARK_VISIBLE (gcry_mpi_mod)
+MARK_VISIBLE (gcry_mpi_mul)
+MARK_VISIBLE (gcry_mpi_mul_2exp)
+MARK_VISIBLE (gcry_mpi_mul_ui)
+MARK_VISIBLE (gcry_mpi_mulm)
+MARK_VISIBLE (gcry_mpi_new)
+MARK_VISIBLE (gcry_mpi_powm)
+MARK_VISIBLE (gcry_mpi_print)
+MARK_VISIBLE (gcry_mpi_randomize)
+MARK_VISIBLE (gcry_mpi_release)
+MARK_VISIBLE (gcry_mpi_rshift)
+MARK_VISIBLE (gcry_mpi_lshift)
+MARK_VISIBLE (gcry_mpi_scan)
+MARK_VISIBLE (gcry_mpi_set)
+MARK_VISIBLE (gcry_mpi_set_bit)
+MARK_VISIBLE (gcry_mpi_set_flag)
+MARK_VISIBLE (gcry_mpi_set_highbit)
+MARK_VISIBLE (gcry_mpi_set_opaque)
+MARK_VISIBLE (gcry_mpi_set_ui)
+MARK_VISIBLE (gcry_mpi_snew)
+MARK_VISIBLE (gcry_mpi_sub)
+MARK_VISIBLE (gcry_mpi_sub_ui)
+MARK_VISIBLE (gcry_mpi_subm)
+MARK_VISIBLE (gcry_mpi_swap)
+MARK_VISIBLE (gcry_mpi_test_bit)
+
+
+
+#undef MARK_VISIBLE
+#endif /*_GCRY_INCLUDED_BY_VISIBILITY_C*/
+
+#endif /*GCRY_VISIBILITY_H*/
diff --git a/grub-core/lib/libgcrypt_wrap/cipher_wrap.h b/grub-core/lib/libgcrypt_wrap/cipher_wrap.h
new file mode 100644
index 0000000..4283549
--- /dev/null
+++ b/grub-core/lib/libgcrypt_wrap/cipher_wrap.h
@@ -0,0 +1,77 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_GCRY_WRAP_HEADER
+#define GRUB_GCRY_WRAP_HEADER 1
+
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/crypto.h>
+
+#include <sys/types.h>
+
+#define _gcry_mpi_invm gcry_mpi_invm
+#define _gcry_mpi_set gcry_mpi_set
+#define _gcry_mpi_set_ui gcry_mpi_set_ui
+#define size_t grub_size_t
+
+#undef __GNU_LIBRARY__
+#define __GNU_LIBRARY__ 1
+
+#define U64_C(c) (c ## ULL)
+
+#define PUBKEY_FLAG_NO_BLINDING (1 << 0)
+
+#define CIPHER_INFO_NO_WEAK_KEY 1
+
+#define HAVE_U64_TYPEDEF 1
+
+/* Selftests are in separate modules. */
+static inline char *
+selftest (void)
+{
+ return NULL;
+}
+
+static inline int
+_gcry_fips_mode (void)
+{
+ return 0;
+}
+
+#define assert gcry_assert
+
+#ifdef GRUB_UTIL
+
+#define memset grub_memset
+
+#endif
+
+
+#define DBG_CIPHER 0
+
+#include <string.h>
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+#include <grub/gcrypt/g10lib.h>
+#include <grub/gcrypt/gcrypt.h>
+
+#define gcry_mpi_mod _gcry_mpi_mod
+
+#endif
diff --git a/grub-core/lib/libgcrypt_wrap/mem.c b/grub-core/lib/libgcrypt_wrap/mem.c
new file mode 100644
index 0000000..74c6eaf
--- /dev/null
+++ b/grub-core/lib/libgcrypt_wrap/mem.c
@@ -0,0 +1,140 @@
+#include <grub/gcrypt/g10lib.h>
+#include <grub/gcrypt/gpg-error.h>
+#include <grub/term.h>
+#include <grub/crypto.h>
+#include <grub/dl.h>
+#include <grub/env.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+void *
+gcry_malloc (size_t n)
+{
+ return grub_malloc (n);
+}
+
+void *
+gcry_malloc_secure (size_t n)
+{
+ return grub_malloc (n);
+}
+
+void
+gcry_free (void *a)
+{
+ grub_free (a);
+}
+
+int
+gcry_is_secure (const void *a __attribute__ ((unused)))
+{
+ return 0;
+}
+
+/* FIXME: implement "exit". */
+void *
+gcry_xcalloc (size_t n, size_t m)
+{
+ void *ret;
+ size_t sz;
+ if (grub_mul (n, m, &sz))
+ grub_fatal ("gcry_xcalloc would overflow");
+ ret = grub_zalloc (sz);
+ if (!ret)
+ grub_fatal ("gcry_xcalloc failed");
+ return ret;
+}
+
+void *
+gcry_xmalloc_secure (size_t n)
+{
+ void *ret;
+ ret = grub_malloc (n);
+ if (!ret)
+ grub_fatal ("gcry_xmalloc failed");
+ return ret;
+}
+
+void *
+gcry_xcalloc_secure (size_t n, size_t m)
+{
+ void *ret;
+ size_t sz;
+ if (grub_mul (n, m, &sz))
+ grub_fatal ("gcry_xcalloc would overflow");
+ ret = grub_zalloc (sz);
+ if (!ret)
+ grub_fatal ("gcry_xcalloc failed");
+ return ret;
+}
+
+void *
+gcry_xmalloc (size_t n)
+{
+ void *ret;
+ ret = grub_malloc (n);
+ if (!ret)
+ grub_fatal ("gcry_xmalloc failed");
+ return ret;
+}
+
+void *
+gcry_xrealloc (void *a, size_t n)
+{
+ void *ret;
+ ret = grub_realloc (a, n);
+ if (!ret)
+ grub_fatal ("gcry_xrealloc failed");
+ return ret;
+}
+
+void
+_gcry_check_heap (const void *a __attribute__ ((unused)))
+{
+
+}
+
+void _gcry_log_printf (const char *fmt, ...)
+{
+ va_list args;
+ const char *debug = grub_env_get ("debug");
+
+ if (! debug)
+ return;
+
+ if (grub_strword (debug, "all") || grub_strword (debug, "gcrypt"))
+ {
+ grub_printf ("gcrypt: ");
+ va_start (args, fmt);
+ grub_vprintf (fmt, args);
+ va_end (args);
+ grub_refresh ();
+ }
+}
+
+void _gcry_log_bug (const char *fmt, ...)
+{
+ va_list args;
+
+ grub_printf ("gcrypt bug: ");
+ va_start (args, fmt);
+ grub_vprintf (fmt, args);
+ va_end (args);
+ grub_refresh ();
+ grub_fatal ("gcrypt bug");
+}
+
+gcry_err_code_t
+gpg_error_from_syserror (void)
+{
+ switch (grub_errno)
+ {
+ case GRUB_ERR_NONE:
+ return GPG_ERR_NO_ERROR;
+ case GRUB_ERR_OUT_OF_MEMORY:
+ return GPG_ERR_OUT_OF_MEMORY;
+ default:
+ return GPG_ERR_GENERAL;
+ }
+}
diff --git a/grub-core/lib/minilzo/lzoconf.h b/grub-core/lib/minilzo/lzoconf.h
new file mode 100644
index 0000000..61be29c
--- /dev/null
+++ b/grub-core/lib/minilzo/lzoconf.h
@@ -0,0 +1,444 @@
+/* lzoconf.h -- configuration of the LZO data compression library
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
+ All Rights Reserved.
+
+ The LZO library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ The LZO library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the LZO library; see the file COPYING.
+ If not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Markus F.X.J. Oberhumer
+ <markus@oberhumer.com>
+ http://www.oberhumer.com/opensource/lzo/
+ */
+
+
+#ifndef __LZOCONF_H_INCLUDED
+#define __LZOCONF_H_INCLUDED 1
+
+#define LZO_VERSION 0x2080
+#define LZO_VERSION_STRING "2.08"
+#define LZO_VERSION_DATE "Jun 29 2014"
+
+/* internal Autoconf configuration file - only used when building LZO */
+#if defined(LZO_HAVE_CONFIG_H)
+# include <config.h>
+#endif
+#include <limits.h>
+#include <stddef.h>
+
+
+/***********************************************************************
+// LZO requires a conforming <limits.h>
+************************************************************************/
+
+#if !defined(CHAR_BIT) || (CHAR_BIT != 8)
+# error "invalid CHAR_BIT"
+#endif
+#if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
+# error "check your compiler installation"
+#endif
+#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
+# error "your limits.h macros are broken"
+#endif
+
+/* get OS and architecture defines */
+#ifndef __LZODEFS_H_INCLUDED
+#include "lzodefs.h"
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/***********************************************************************
+// some core defines
+************************************************************************/
+
+/* memory checkers */
+#if !defined(__LZO_CHECKER)
+# if defined(__BOUNDS_CHECKING_ON)
+# define __LZO_CHECKER 1
+# elif defined(__CHECKER__)
+# define __LZO_CHECKER 1
+# elif defined(__INSURE__)
+# define __LZO_CHECKER 1
+# elif defined(__PURIFY__)
+# define __LZO_CHECKER 1
+# endif
+#endif
+
+
+/***********************************************************************
+// integral and pointer types
+************************************************************************/
+
+/* lzo_uint must match size_t */
+#if !defined(LZO_UINT_MAX)
+# if (LZO_ABI_LLP64)
+# if (LZO_OS_WIN64)
+ typedef unsigned __int64 lzo_uint;
+ typedef __int64 lzo_int;
+# else
+ typedef lzo_ullong_t lzo_uint;
+ typedef lzo_llong_t lzo_int;
+# endif
+# define LZO_SIZEOF_LZO_UINT 8
+# define LZO_UINT_MAX 0xffffffffffffffffull
+# define LZO_INT_MAX 9223372036854775807LL
+# define LZO_INT_MIN (-1LL - LZO_INT_MAX)
+# elif (LZO_ABI_IP32L64) /* MIPS R5900 */
+ typedef unsigned int lzo_uint;
+ typedef int lzo_int;
+# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_INT
+# define LZO_UINT_MAX UINT_MAX
+# define LZO_INT_MAX INT_MAX
+# define LZO_INT_MIN INT_MIN
+# elif (ULONG_MAX >= LZO_0xffffffffL)
+ typedef unsigned long lzo_uint;
+ typedef long lzo_int;
+# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LONG
+# define LZO_UINT_MAX ULONG_MAX
+# define LZO_INT_MAX LONG_MAX
+# define LZO_INT_MIN LONG_MIN
+# else
+# error "lzo_uint"
+# endif
+#endif
+
+/* The larger type of lzo_uint and lzo_uint32_t. */
+#if (LZO_SIZEOF_LZO_UINT >= 4)
+# define lzo_xint lzo_uint
+#else
+# define lzo_xint lzo_uint32_t
+#endif
+
+typedef int lzo_bool;
+
+/* sanity checks */
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint))
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t))
+
+#ifndef __LZO_MMODEL
+#define __LZO_MMODEL /*empty*/
+#endif
+
+/* no typedef here because of const-pointer issues */
+#define lzo_bytep unsigned char __LZO_MMODEL *
+#define lzo_charp char __LZO_MMODEL *
+#define lzo_voidp void __LZO_MMODEL *
+#define lzo_shortp short __LZO_MMODEL *
+#define lzo_ushortp unsigned short __LZO_MMODEL *
+#define lzo_intp lzo_int __LZO_MMODEL *
+#define lzo_uintp lzo_uint __LZO_MMODEL *
+#define lzo_xintp lzo_xint __LZO_MMODEL *
+#define lzo_voidpp lzo_voidp __LZO_MMODEL *
+#define lzo_bytepp lzo_bytep __LZO_MMODEL *
+
+#define lzo_int8_tp lzo_int8_t __LZO_MMODEL *
+#define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL *
+#define lzo_int16_tp lzo_int16_t __LZO_MMODEL *
+#define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL *
+#define lzo_int32_tp lzo_int32_t __LZO_MMODEL *
+#define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL *
+#if defined(lzo_int64_t)
+#define lzo_int64_tp lzo_int64_t __LZO_MMODEL *
+#define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL *
+#endif
+
+/* Older LZO versions used to support ancient systems and memory models
+ * like 16-bit MSDOS with __huge pointers and Cray PVP, but these
+ * obsolete configurations are not supported any longer.
+ */
+#if defined(__LZO_MMODEL_HUGE)
+#error "__LZO_MMODEL_HUGE is unsupported"
+#endif
+#if (LZO_MM_PVP)
+#error "LZO_MM_PVP is unsupported"
+#endif
+#if (LZO_SIZEOF_INT < 4)
+#error "LZO_SIZEOF_INT < 4 is unsupported"
+#endif
+#if (__LZO_UINTPTR_T_IS_POINTER)
+#error "__LZO_UINTPTR_T_IS_POINTER is unsupported"
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4)
+/* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should
+ * work but have not received much testing lately, so be strict here.
+ */
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t))
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t))
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t))
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t))
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t))
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t))
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp))
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep))
+
+
+/***********************************************************************
+// function types
+************************************************************************/
+
+/* name mangling */
+#if !defined(__LZO_EXTERN_C)
+# ifdef __cplusplus
+# define __LZO_EXTERN_C extern "C"
+# else
+# define __LZO_EXTERN_C extern
+# endif
+#endif
+
+/* calling convention */
+#if !defined(__LZO_CDECL)
+# define __LZO_CDECL __lzo_cdecl
+#endif
+
+/* DLL export information */
+#if !defined(__LZO_EXPORT1)
+# define __LZO_EXPORT1 /*empty*/
+#endif
+#if !defined(__LZO_EXPORT2)
+# define __LZO_EXPORT2 /*empty*/
+#endif
+
+/* __cdecl calling convention for public C and assembly functions */
+#if !defined(LZO_PUBLIC)
+# define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
+#endif
+#if !defined(LZO_EXTERN)
+# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype)
+#endif
+#if !defined(LZO_PRIVATE)
+# define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL
+#endif
+
+/* function types */
+typedef int
+(__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len,
+ lzo_bytep dst, lzo_uintp dst_len,
+ lzo_voidp wrkmem );
+
+typedef int
+(__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len,
+ lzo_bytep dst, lzo_uintp dst_len,
+ lzo_voidp wrkmem );
+
+typedef int
+(__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len,
+ lzo_bytep dst, lzo_uintp dst_len,
+ lzo_voidp wrkmem );
+
+typedef int
+(__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len,
+ lzo_bytep dst, lzo_uintp dst_len,
+ lzo_voidp wrkmem,
+ const lzo_bytep dict, lzo_uint dict_len );
+
+typedef int
+(__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len,
+ lzo_bytep dst, lzo_uintp dst_len,
+ lzo_voidp wrkmem,
+ const lzo_bytep dict, lzo_uint dict_len );
+
+
+/* Callback interface. Currently only the progress indicator ("nprogress")
+ * is used, but this may change in a future release. */
+
+struct lzo_callback_t;
+typedef struct lzo_callback_t lzo_callback_t;
+#define lzo_callback_p lzo_callback_t __LZO_MMODEL *
+
+/* malloc & free function types */
+typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t)
+ (lzo_callback_p self, lzo_uint items, lzo_uint size);
+typedef void (__LZO_CDECL *lzo_free_func_t)
+ (lzo_callback_p self, lzo_voidp ptr);
+
+/* a progress indicator callback function */
+typedef void (__LZO_CDECL *lzo_progress_func_t)
+ (lzo_callback_p, lzo_uint, lzo_uint, int);
+
+struct lzo_callback_t
+{
+ /* custom allocators (set to 0 to disable) */
+ lzo_alloc_func_t nalloc; /* [not used right now] */
+ lzo_free_func_t nfree; /* [not used right now] */
+
+ /* a progress indicator callback function (set to 0 to disable) */
+ lzo_progress_func_t nprogress;
+
+ /* INFO: the first parameter "self" of the nalloc/nfree/nprogress
+ * callbacks points back to this struct, so you are free to store
+ * some extra info in the following variables. */
+ lzo_voidp user1;
+ lzo_xint user2;
+ lzo_xint user3;
+};
+
+
+/***********************************************************************
+// error codes and prototypes
+************************************************************************/
+
+/* Error codes for the compression/decompression functions. Negative
+ * values are errors, positive values will be used for special but
+ * normal events.
+ */
+#define LZO_E_OK 0
+#define LZO_E_ERROR (-1)
+#define LZO_E_OUT_OF_MEMORY (-2) /* [lzo_alloc_func_t failure] */
+#define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */
+#define LZO_E_INPUT_OVERRUN (-4)
+#define LZO_E_OUTPUT_OVERRUN (-5)
+#define LZO_E_LOOKBEHIND_OVERRUN (-6)
+#define LZO_E_EOF_NOT_FOUND (-7)
+#define LZO_E_INPUT_NOT_CONSUMED (-8)
+#define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */
+#define LZO_E_INVALID_ARGUMENT (-10)
+#define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */
+#define LZO_E_OUTPUT_NOT_CONSUMED (-12)
+#define LZO_E_INTERNAL_ERROR (-99)
+
+
+#ifndef lzo_sizeof_dict_t
+# define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep))
+#endif
+
+/* lzo_init() should be the first function you call.
+ * Check the return code !
+ *
+ * lzo_init() is a macro to allow checking that the library and the
+ * compiler's view of various types are consistent.
+ */
+#define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
+ (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\
+ (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
+ (int)sizeof(lzo_callback_t))
+LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int);
+
+/* version functions (useful for shared libraries) */
+LZO_EXTERN(unsigned) lzo_version(void);
+LZO_EXTERN(const char *) lzo_version_string(void);
+LZO_EXTERN(const char *) lzo_version_date(void);
+LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
+LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
+
+/* string functions */
+LZO_EXTERN(int)
+ lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len);
+LZO_EXTERN(lzo_voidp)
+ lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
+LZO_EXTERN(lzo_voidp)
+ lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
+LZO_EXTERN(lzo_voidp)
+ lzo_memset(lzo_voidp buf, int c, lzo_uint len);
+
+/* checksum functions */
+LZO_EXTERN(lzo_uint32_t)
+ lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
+LZO_EXTERN(lzo_uint32_t)
+ lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
+LZO_EXTERN(const lzo_uint32_tp)
+ lzo_get_crc32_table(void);
+
+/* misc. */
+LZO_EXTERN(int) _lzo_config_check(void);
+typedef union {
+ lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04;
+ void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09;
+#if defined(lzo_int64_t)
+ lzo_uint64_t a10;
+#endif
+} lzo_align_t;
+
+/* align a char pointer on a boundary that is a multiple of 'size' */
+LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size);
+#define LZO_PTR_ALIGN_UP(p,size) \
+ ((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size)))
+
+
+/***********************************************************************
+// deprecated macros - only for backward compatibility
+************************************************************************/
+
+/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */
+#define lzo_byte unsigned char
+/* deprecated type names */
+#define lzo_int32 lzo_int32_t
+#define lzo_uint32 lzo_uint32_t
+#define lzo_int32p lzo_int32_t __LZO_MMODEL *
+#define lzo_uint32p lzo_uint32_t __LZO_MMODEL *
+#define LZO_INT32_MAX LZO_INT32_C(2147483647)
+#define LZO_UINT32_MAX LZO_UINT32_C(4294967295)
+#if defined(lzo_int64_t)
+#define lzo_int64 lzo_int64_t
+#define lzo_uint64 lzo_uint64_t
+#define lzo_int64p lzo_int64_t __LZO_MMODEL *
+#define lzo_uint64p lzo_uint64_t __LZO_MMODEL *
+#define LZO_INT64_MAX LZO_INT64_C(9223372036854775807)
+#define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615)
+#endif
+/* deprecated types */
+typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u;
+typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u;
+
+#if defined(LZO_CFG_COMPAT)
+
+#define __LZOCONF_H 1
+
+#if defined(LZO_ARCH_I086)
+# define __LZO_i386 1
+#elif defined(LZO_ARCH_I386)
+# define __LZO_i386 1
+#endif
+
+#if defined(LZO_OS_DOS16)
+# define __LZO_DOS 1
+# define __LZO_DOS16 1
+#elif defined(LZO_OS_DOS32)
+# define __LZO_DOS 1
+#elif defined(LZO_OS_WIN16)
+# define __LZO_WIN 1
+# define __LZO_WIN16 1
+#elif defined(LZO_OS_WIN32)
+# define __LZO_WIN 1
+#endif
+
+#define __LZO_CMODEL /*empty*/
+#define __LZO_DMODEL /*empty*/
+#define __LZO_ENTRY __LZO_CDECL
+#define LZO_EXTERN_CDECL LZO_EXTERN
+#define LZO_ALIGN LZO_PTR_ALIGN_UP
+
+#define lzo_compress_asm_t lzo_compress_t
+#define lzo_decompress_asm_t lzo_decompress_t
+
+#endif /* LZO_CFG_COMPAT */
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* already included */
+
+
+/* vim:set ts=4 sw=4 et: */
diff --git a/grub-core/lib/minilzo/lzodefs.h b/grub-core/lib/minilzo/lzodefs.h
new file mode 100644
index 0000000..f4ae948
--- /dev/null
+++ b/grub-core/lib/minilzo/lzodefs.h
@@ -0,0 +1,2998 @@
+/* lzodefs.h -- architecture, OS and compiler specific defines
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
+ All Rights Reserved.
+
+ The LZO library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ The LZO library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the LZO library; see the file COPYING.
+ If not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Markus F.X.J. Oberhumer
+ <markus@oberhumer.com>
+ http://www.oberhumer.com/opensource/lzo/
+ */
+
+
+#ifndef __LZODEFS_H_INCLUDED
+#define __LZODEFS_H_INCLUDED 1
+
+#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
+# define __CYGWIN__ __CYGWIN32__
+#endif
+#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
+# define _ALL_SOURCE 1
+#endif
+#if defined(__mips__) && defined(__R5900__)
+# if !defined(__LONG_MAX__)
+# define __LONG_MAX__ 9223372036854775807L
+# endif
+#endif
+#if !defined(LZO_CFG_NO_DISABLE_WUNDEF)
+#if defined(__ARMCC_VERSION)
+# pragma diag_suppress 193
+#elif defined(__clang__) && defined(__clang_minor__)
+# pragma clang diagnostic ignored "-Wundef"
+#elif defined(__INTEL_COMPILER)
+# pragma warning(disable: 193)
+#elif defined(__KEIL__) && defined(__C166__)
+# pragma warning disable = 322
+#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__)
+# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2))
+# pragma GCC diagnostic ignored "-Wundef"
+# endif
+#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
+# if ((_MSC_VER-0) >= 1300)
+# pragma warning(disable: 4668)
+# endif
+#endif
+#endif
+#if 0 && defined(__POCC__) && defined(_WIN32)
+# if (__POCC__ >= 400)
+# pragma warn(disable: 2216)
+# endif
+#endif
+#if 0 && defined(__WATCOMC__)
+# if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060)
+# pragma warning 203 9
+# endif
+#endif
+#if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__)
+# pragma option -h
+#endif
+#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC)
+#ifndef _CRT_NONSTDC_NO_DEPRECATE
+#define _CRT_NONSTDC_NO_DEPRECATE 1
+#endif
+#ifndef _CRT_NONSTDC_NO_WARNINGS
+#define _CRT_NONSTDC_NO_WARNINGS 1
+#endif
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS 1
+#endif
+#endif
+#if 0
+#define LZO_0xffffUL 0xfffful
+#define LZO_0xffffffffUL 0xfffffffful
+#else
+#define LZO_0xffffUL 65535ul
+#define LZO_0xffffffffUL 4294967295ul
+#endif
+#define LZO_0xffffL LZO_0xffffUL
+#define LZO_0xffffffffL LZO_0xffffffffUL
+#if (LZO_0xffffL == LZO_0xffffffffL)
+# error "your preprocessor is broken 1"
+#endif
+#if (16ul * 16384ul != 262144ul)
+# error "your preprocessor is broken 2"
+#endif
+#if 0
+#if (32767 >= 4294967295ul)
+# error "your preprocessor is broken 3"
+#endif
+#if (65535u >= 4294967295ul)
+# error "your preprocessor is broken 4"
+#endif
+#endif
+#if defined(__COUNTER__)
+# ifndef LZO_CFG_USE_COUNTER
+# define LZO_CFG_USE_COUNTER 1
+# endif
+#else
+# undef LZO_CFG_USE_COUNTER
+#endif
+#if (UINT_MAX == LZO_0xffffL)
+#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
+# if !defined(MSDOS)
+# define MSDOS 1
+# endif
+# if !defined(_MSDOS)
+# define _MSDOS 1
+# endif
+#elif 0 && defined(__VERSION) && defined(MB_LEN_MAX)
+# if (__VERSION == 520) && (MB_LEN_MAX == 1)
+# if !defined(__AZTEC_C__)
+# define __AZTEC_C__ __VERSION
+# endif
+# if !defined(__DOS__)
+# define __DOS__ 1
+# endif
+# endif
+#endif
+#endif
+#if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL)
+# define ptrdiff_t long
+# define _PTRDIFF_T_DEFINED 1
+#endif
+#if (UINT_MAX == LZO_0xffffL)
+# undef __LZO_RENAME_A
+# undef __LZO_RENAME_B
+# if defined(__AZTEC_C__) && defined(__DOS__)
+# define __LZO_RENAME_A 1
+# elif defined(_MSC_VER) && defined(MSDOS)
+# if (_MSC_VER < 600)
+# define __LZO_RENAME_A 1
+# elif (_MSC_VER < 700)
+# define __LZO_RENAME_B 1
+# endif
+# elif defined(__TSC__) && defined(__OS2__)
+# define __LZO_RENAME_A 1
+# elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410)
+# define __LZO_RENAME_A 1
+# elif defined(__PACIFIC__) && defined(DOS)
+# if !defined(__far)
+# define __far far
+# endif
+# if !defined(__near)
+# define __near near
+# endif
+# endif
+# if defined(__LZO_RENAME_A)
+# if !defined(__cdecl)
+# define __cdecl cdecl
+# endif
+# if !defined(__far)
+# define __far far
+# endif
+# if !defined(__huge)
+# define __huge huge
+# endif
+# if !defined(__near)
+# define __near near
+# endif
+# if !defined(__pascal)
+# define __pascal pascal
+# endif
+# if !defined(__huge)
+# define __huge huge
+# endif
+# elif defined(__LZO_RENAME_B)
+# if !defined(__cdecl)
+# define __cdecl _cdecl
+# endif
+# if !defined(__far)
+# define __far _far
+# endif
+# if !defined(__huge)
+# define __huge _huge
+# endif
+# if !defined(__near)
+# define __near _near
+# endif
+# if !defined(__pascal)
+# define __pascal _pascal
+# endif
+# elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
+# if !defined(__cdecl)
+# define __cdecl cdecl
+# endif
+# if !defined(__pascal)
+# define __pascal pascal
+# endif
+# endif
+# undef __LZO_RENAME_A
+# undef __LZO_RENAME_B
+#endif
+#if (UINT_MAX == LZO_0xffffL)
+#if defined(__AZTEC_C__) && defined(__DOS__)
+# define LZO_BROKEN_CDECL_ALT_SYNTAX 1
+#elif defined(_MSC_VER) && defined(MSDOS)
+# if (_MSC_VER < 600)
+# define LZO_BROKEN_INTEGRAL_CONSTANTS 1
+# endif
+# if (_MSC_VER < 700)
+# define LZO_BROKEN_INTEGRAL_PROMOTION 1
+# define LZO_BROKEN_SIZEOF 1
+# endif
+#elif defined(__PACIFIC__) && defined(DOS)
+# define LZO_BROKEN_INTEGRAL_CONSTANTS 1
+#elif defined(__TURBOC__) && defined(__MSDOS__)
+# if (__TURBOC__ < 0x0150)
+# define LZO_BROKEN_CDECL_ALT_SYNTAX 1
+# define LZO_BROKEN_INTEGRAL_CONSTANTS 1
+# define LZO_BROKEN_INTEGRAL_PROMOTION 1
+# endif
+# if (__TURBOC__ < 0x0200)
+# define LZO_BROKEN_SIZEOF 1
+# endif
+# if (__TURBOC__ < 0x0400) && defined(__cplusplus)
+# define LZO_BROKEN_CDECL_ALT_SYNTAX 1
+# endif
+#elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
+# define LZO_BROKEN_CDECL_ALT_SYNTAX 1
+# define LZO_BROKEN_SIZEOF 1
+#endif
+#endif
+#if defined(__WATCOMC__) && (__WATCOMC__ < 900)
+# define LZO_BROKEN_INTEGRAL_CONSTANTS 1
+#endif
+#if defined(_CRAY) && defined(_CRAY1)
+# define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1
+#endif
+#define LZO_PP_STRINGIZE(x) #x
+#define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x)
+#define LZO_PP_CONCAT0() /*empty*/
+#define LZO_PP_CONCAT1(a) a
+#define LZO_PP_CONCAT2(a,b) a ## b
+#define LZO_PP_CONCAT3(a,b,c) a ## b ## c
+#define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d
+#define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
+#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f
+#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g
+#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0()
+#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a)
+#define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b)
+#define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c)
+#define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d)
+#define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e)
+#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f)
+#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g)
+#define LZO_PP_EMPTY /*empty*/
+#define LZO_PP_EMPTY0() /*empty*/
+#define LZO_PP_EMPTY1(a) /*empty*/
+#define LZO_PP_EMPTY2(a,b) /*empty*/
+#define LZO_PP_EMPTY3(a,b,c) /*empty*/
+#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/
+#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/
+#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/
+#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/
+#if 1
+#define LZO_CPP_STRINGIZE(x) #x
+#define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x)
+#define LZO_CPP_CONCAT2(a,b) a ## b
+#define LZO_CPP_CONCAT3(a,b,c) a ## b ## c
+#define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d
+#define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
+#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f
+#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g
+#define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b)
+#define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c)
+#define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d)
+#define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e)
+#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f)
+#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g)
+#endif
+#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b))
+#if 1 && defined(__cplusplus)
+# if !defined(__STDC_CONSTANT_MACROS)
+# define __STDC_CONSTANT_MACROS 1
+# endif
+# if !defined(__STDC_LIMIT_MACROS)
+# define __STDC_LIMIT_MACROS 1
+# endif
+#endif
+#if defined(__cplusplus)
+# define LZO_EXTERN_C extern "C"
+# define LZO_EXTERN_C_BEGIN extern "C" {
+# define LZO_EXTERN_C_END }
+#else
+# define LZO_EXTERN_C extern
+# define LZO_EXTERN_C_BEGIN /*empty*/
+# define LZO_EXTERN_C_END /*empty*/
+#endif
+#if !defined(__LZO_OS_OVERRIDE)
+#if (LZO_OS_FREESTANDING)
+# define LZO_INFO_OS "freestanding"
+#elif (LZO_OS_EMBEDDED)
+# define LZO_INFO_OS "embedded"
+#elif 1 && defined(__IAR_SYSTEMS_ICC__)
+# define LZO_OS_EMBEDDED 1
+# define LZO_INFO_OS "embedded"
+#elif defined(__CYGWIN__) && defined(__GNUC__)
+# define LZO_OS_CYGWIN 1
+# define LZO_INFO_OS "cygwin"
+#elif defined(__EMX__) && defined(__GNUC__)
+# define LZO_OS_EMX 1
+# define LZO_INFO_OS "emx"
+#elif defined(__BEOS__)
+# define LZO_OS_BEOS 1
+# define LZO_INFO_OS "beos"
+#elif defined(__Lynx__)
+# define LZO_OS_LYNXOS 1
+# define LZO_INFO_OS "lynxos"
+#elif defined(__OS400__)
+# define LZO_OS_OS400 1
+# define LZO_INFO_OS "os400"
+#elif defined(__QNX__)
+# define LZO_OS_QNX 1
+# define LZO_INFO_OS "qnx"
+#elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460)
+# define LZO_OS_DOS32 1
+# define LZO_INFO_OS "dos32"
+#elif defined(__BORLANDC__) && defined(__DPMI16__)
+# define LZO_OS_DOS16 1
+# define LZO_INFO_OS "dos16"
+#elif defined(__ZTC__) && defined(DOS386)
+# define LZO_OS_DOS32 1
+# define LZO_INFO_OS "dos32"
+#elif defined(__OS2__) || defined(__OS2V2__)
+# if (UINT_MAX == LZO_0xffffL)
+# define LZO_OS_OS216 1
+# define LZO_INFO_OS "os216"
+# elif (UINT_MAX == LZO_0xffffffffL)
+# define LZO_OS_OS2 1
+# define LZO_INFO_OS "os2"
+# else
+# error "check your limits.h header"
+# endif
+#elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64)
+# define LZO_OS_WIN64 1
+# define LZO_INFO_OS "win64"
+#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__)
+# define LZO_OS_WIN32 1
+# define LZO_INFO_OS "win32"
+#elif defined(__MWERKS__) && defined(__INTEL__)
+# define LZO_OS_WIN32 1
+# define LZO_INFO_OS "win32"
+#elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
+# if (UINT_MAX == LZO_0xffffL)
+# define LZO_OS_WIN16 1
+# define LZO_INFO_OS "win16"
+# elif (UINT_MAX == LZO_0xffffffffL)
+# define LZO_OS_WIN32 1
+# define LZO_INFO_OS "win32"
+# else
+# error "check your limits.h header"
+# endif
+#elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS))
+# if (UINT_MAX == LZO_0xffffL)
+# define LZO_OS_DOS16 1
+# define LZO_INFO_OS "dos16"
+# elif (UINT_MAX == LZO_0xffffffffL)
+# define LZO_OS_DOS32 1
+# define LZO_INFO_OS "dos32"
+# else
+# error "check your limits.h header"
+# endif
+#elif defined(__WATCOMC__)
+# if defined(__NT__) && (UINT_MAX == LZO_0xffffL)
+# define LZO_OS_DOS16 1
+# define LZO_INFO_OS "dos16"
+# elif defined(__NT__) && (__WATCOMC__ < 1100)
+# define LZO_OS_WIN32 1
+# define LZO_INFO_OS "win32"
+# elif defined(__linux__) || defined(__LINUX__)
+# define LZO_OS_POSIX 1
+# define LZO_INFO_OS "posix"
+# else
+# error "please specify a target using the -bt compiler option"
+# endif
+#elif defined(__palmos__)
+# define LZO_OS_PALMOS 1
+# define LZO_INFO_OS "palmos"
+#elif defined(__TOS__) || defined(__atarist__)
+# define LZO_OS_TOS 1
+# define LZO_INFO_OS "tos"
+#elif defined(macintosh) && !defined(__ppc__)
+# define LZO_OS_MACCLASSIC 1
+# define LZO_INFO_OS "macclassic"
+#elif defined(__VMS)
+# define LZO_OS_VMS 1
+# define LZO_INFO_OS "vms"
+#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)
+# define LZO_OS_CONSOLE 1
+# define LZO_OS_CONSOLE_PS2 1
+# define LZO_INFO_OS "console"
+# define LZO_INFO_OS_CONSOLE "ps2"
+#elif defined(__mips__) && defined(__psp__)
+# define LZO_OS_CONSOLE 1
+# define LZO_OS_CONSOLE_PSP 1
+# define LZO_INFO_OS "console"
+# define LZO_INFO_OS_CONSOLE "psp"
+#else
+# define LZO_OS_POSIX 1
+# define LZO_INFO_OS "posix"
+#endif
+#if (LZO_OS_POSIX)
+# if defined(_AIX) || defined(__AIX__) || defined(__aix__)
+# define LZO_OS_POSIX_AIX 1
+# define LZO_INFO_OS_POSIX "aix"
+# elif defined(__FreeBSD__)
+# define LZO_OS_POSIX_FREEBSD 1
+# define LZO_INFO_OS_POSIX "freebsd"
+# elif defined(__hpux__) || defined(__hpux)
+# define LZO_OS_POSIX_HPUX 1
+# define LZO_INFO_OS_POSIX "hpux"
+# elif defined(__INTERIX)
+# define LZO_OS_POSIX_INTERIX 1
+# define LZO_INFO_OS_POSIX "interix"
+# elif defined(__IRIX__) || defined(__irix__)
+# define LZO_OS_POSIX_IRIX 1
+# define LZO_INFO_OS_POSIX "irix"
+# elif defined(__linux__) || defined(__linux) || defined(__LINUX__)
+# define LZO_OS_POSIX_LINUX 1
+# define LZO_INFO_OS_POSIX "linux"
+# elif defined(__APPLE__) && defined(__MACH__)
+# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000)
+# define LZO_OS_POSIX_DARWIN 1040
+# define LZO_INFO_OS_POSIX "darwin_iphone"
+# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040)
+# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
+# define LZO_INFO_OS_POSIX "darwin"
+# else
+# define LZO_OS_POSIX_DARWIN 1
+# define LZO_INFO_OS_POSIX "darwin"
+# endif
+# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN
+# elif defined(__minix__) || defined(__minix)
+# define LZO_OS_POSIX_MINIX 1
+# define LZO_INFO_OS_POSIX "minix"
+# elif defined(__NetBSD__)
+# define LZO_OS_POSIX_NETBSD 1
+# define LZO_INFO_OS_POSIX "netbsd"
+# elif defined(__OpenBSD__)
+# define LZO_OS_POSIX_OPENBSD 1
+# define LZO_INFO_OS_POSIX "openbsd"
+# elif defined(__osf__)
+# define LZO_OS_POSIX_OSF 1
+# define LZO_INFO_OS_POSIX "osf"
+# elif defined(__solaris__) || defined(__sun)
+# if defined(__SVR4) || defined(__svr4__)
+# define LZO_OS_POSIX_SOLARIS 1
+# define LZO_INFO_OS_POSIX "solaris"
+# else
+# define LZO_OS_POSIX_SUNOS 1
+# define LZO_INFO_OS_POSIX "sunos"
+# endif
+# elif defined(__ultrix__) || defined(__ultrix)
+# define LZO_OS_POSIX_ULTRIX 1
+# define LZO_INFO_OS_POSIX "ultrix"
+# elif defined(_UNICOS)
+# define LZO_OS_POSIX_UNICOS 1
+# define LZO_INFO_OS_POSIX "unicos"
+# else
+# define LZO_OS_POSIX_UNKNOWN 1
+# define LZO_INFO_OS_POSIX "unknown"
+# endif
+#endif
+#endif
+#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
+# if (UINT_MAX != LZO_0xffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+# if (ULONG_MAX != LZO_0xffffffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+#endif
+#if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64)
+# if (UINT_MAX != LZO_0xffffffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+# if (ULONG_MAX != LZO_0xffffffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+#endif
+#if defined(CIL) && defined(_GNUCC) && defined(__GNUC__)
+# define LZO_CC_CILLY 1
+# define LZO_INFO_CC "Cilly"
+# if defined(__CILLY__)
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__)
+# else
+# define LZO_INFO_CCVER "unknown"
+# endif
+#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__)
+# define LZO_CC_SDCC 1
+# define LZO_INFO_CC "sdcc"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC)
+#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
+# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0))
+# define LZO_INFO_CC "Pathscale C"
+# define LZO_INFO_CCVER __PATHSCALE__
+# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# endif
+#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0)
+# define LZO_CC_INTELC __INTEL_COMPILER
+# define LZO_INFO_CC "Intel C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER)
+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0)
+# define LZO_CC_INTELC_MSC _MSC_VER
+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# endif
+#elif defined(__POCC__) && defined(_WIN32)
+# define LZO_CC_PELLESC 1
+# define LZO_INFO_CC "Pelles C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__)
+#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# if defined(__GNUC_PATCHLEVEL__)
+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# else
+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100)
+# endif
+# define LZO_CC_ARMCC __ARMCC_VERSION
+# define LZO_INFO_CC "ARM C Compiler"
+# define LZO_INFO_CCVER __VERSION__
+#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__)
+# if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
+# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0))
+# else
+# define LZO_CC_CLANG 0x010000L
+# endif
+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0)
+# define LZO_CC_CLANG_MSC _MSC_VER
+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# endif
+# define LZO_INFO_CC "clang"
+# define LZO_INFO_CCVER __VERSION__
+#elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# if defined(__GNUC_PATCHLEVEL__)
+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# else
+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100)
+# endif
+# define LZO_CC_LLVM LZO_CC_LLVM_GNUC
+# define LZO_INFO_CC "llvm-gcc"
+# define LZO_INFO_CCVER __VERSION__
+#elif defined(__ACK__) && defined(_ACK)
+# define LZO_CC_ACK 1
+# define LZO_INFO_CC "Amsterdam Compiler Kit C"
+# define LZO_INFO_CCVER "unknown"
+#elif defined(__ARMCC_VERSION) && !defined(__GNUC__)
+# define LZO_CC_ARMCC __ARMCC_VERSION
+# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION
+# define LZO_INFO_CC "ARM C Compiler"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION)
+#elif defined(__AZTEC_C__)
+# define LZO_CC_AZTECC 1
+# define LZO_INFO_CC "Aztec C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__)
+#elif defined(__CODEGEARC__)
+# define LZO_CC_CODEGEARC 1
+# define LZO_INFO_CC "CodeGear C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__)
+#elif defined(__BORLANDC__)
+# define LZO_CC_BORLANDC 1
+# define LZO_INFO_CC "Borland C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__)
+#elif defined(_CRAYC) && defined(_RELEASE)
+# define LZO_CC_CRAYC 1
+# define LZO_INFO_CC "Cray C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE)
+#elif defined(__DMC__) && defined(__SC__)
+# define LZO_CC_DMC 1
+# define LZO_INFO_CC "Digital Mars C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__)
+#elif defined(__DECC)
+# define LZO_CC_DECC 1
+# define LZO_INFO_CC "DEC C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC)
+#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0)
+# define LZO_CC_GHS 1
+# define LZO_INFO_CC "Green Hills C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER)
+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0)
+# define LZO_CC_GHS_MSC _MSC_VER
+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# endif
+#elif defined(__HIGHC__)
+# define LZO_CC_HIGHC 1
+# define LZO_INFO_CC "MetaWare High C"
+# define LZO_INFO_CCVER "unknown"
+#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0)
+# define LZO_CC_HPACC __HP_aCC
+# define LZO_INFO_CC "HP aCC"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC)
+#elif defined(__IAR_SYSTEMS_ICC__)
+# define LZO_CC_IARC 1
+# define LZO_INFO_CC "IAR C"
+# if defined(__VER__)
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__)
+# else
+# define LZO_INFO_CCVER "unknown"
+# endif
+#elif defined(__IBMC__) && ((__IBMC__-0) > 0)
+# define LZO_CC_IBMC __IBMC__
+# define LZO_INFO_CC "IBM C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__)
+#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0)
+# define LZO_CC_IBMC __IBMCPP__
+# define LZO_INFO_CC "IBM C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__)
+#elif defined(__KEIL__) && defined(__C166__)
+# define LZO_CC_KEILC 1
+# define LZO_INFO_CC "Keil C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__)
+#elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL)
+# define LZO_CC_LCCWIN32 1
+# define LZO_INFO_CC "lcc-win32"
+# define LZO_INFO_CCVER "unknown"
+#elif defined(__LCC__)
+# define LZO_CC_LCC 1
+# define LZO_INFO_CC "lcc"
+# if defined(__LCC_VERSION__)
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__)
+# else
+# define LZO_INFO_CCVER "unknown"
+# endif
+#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0)
+# define LZO_CC_MWERKS __MWERKS__
+# define LZO_INFO_CC "Metrowerks C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__)
+#elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386)
+# define LZO_CC_NDPC 1
+# define LZO_INFO_CC "Microway NDP C"
+# define LZO_INFO_CCVER "unknown"
+#elif defined(__PACIFIC__)
+# define LZO_CC_PACIFICC 1
+# define LZO_INFO_CC "Pacific C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__)
+#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__)
+# if defined(__PGIC_PATCHLEVEL__)
+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0))
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__)
+# else
+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100)
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0"
+# endif
+# define LZO_INFO_CC "Portland Group PGI C"
+#elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__))
+# define LZO_CC_PGI 1
+# define LZO_INFO_CC "Portland Group PGI C"
+# define LZO_INFO_CCVER "unknown"
+#elif defined(__PUREC__) && defined(__TOS__)
+# define LZO_CC_PUREC 1
+# define LZO_INFO_CC "Pure C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__)
+#elif defined(__SC__) && defined(__ZTC__)
+# define LZO_CC_SYMANTECC 1
+# define LZO_INFO_CC "Symantec C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__)
+#elif defined(__SUNPRO_C)
+# define LZO_INFO_CC "SunPro C"
+# if ((__SUNPRO_C-0) > 0)
+# define LZO_CC_SUNPROC __SUNPRO_C
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C)
+# else
+# define LZO_CC_SUNPROC 1
+# define LZO_INFO_CCVER "unknown"
+# endif
+#elif defined(__SUNPRO_CC)
+# define LZO_INFO_CC "SunPro C"
+# if ((__SUNPRO_CC-0) > 0)
+# define LZO_CC_SUNPROC __SUNPRO_CC
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC)
+# else
+# define LZO_CC_SUNPROC 1
+# define LZO_INFO_CCVER "unknown"
+# endif
+#elif defined(__TINYC__)
+# define LZO_CC_TINYC 1
+# define LZO_INFO_CC "Tiny C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__)
+#elif defined(__TSC__)
+# define LZO_CC_TOPSPEEDC 1
+# define LZO_INFO_CC "TopSpeed C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__)
+#elif defined(__WATCOMC__)
+# define LZO_CC_WATCOMC 1
+# define LZO_INFO_CC "Watcom C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__)
+#elif defined(__TURBOC__)
+# define LZO_CC_TURBOC 1
+# define LZO_INFO_CC "Turbo C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__)
+#elif defined(__ZTC__)
+# define LZO_CC_ZORTECHC 1
+# define LZO_INFO_CC "Zortech C"
+# if ((__ZTC__-0) == 0x310)
+# define LZO_INFO_CCVER "0x310"
+# else
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__)
+# endif
+#elif defined(__GNUC__) && defined(__VERSION__)
+# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# elif defined(__GNUC_MINOR__)
+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100)
+# else
+# define LZO_CC_GNUC (__GNUC__ * 0x10000L)
+# endif
+# define LZO_INFO_CC "gcc"
+# define LZO_INFO_CCVER __VERSION__
+#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0)
+# define LZO_CC_MSC _MSC_VER
+# define LZO_INFO_CC "Microsoft C"
+# if defined(_MSC_FULL_VER)
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER)
+# else
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER)
+# endif
+#else
+# define LZO_CC_UNKNOWN 1
+# define LZO_INFO_CC "unknown"
+# define LZO_INFO_CCVER "unknown"
+#endif
+#if (LZO_CC_GNUC) && defined(__OPEN64__)
+# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__)
+# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0))
+# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC
+# endif
+#endif
+#if (LZO_CC_GNUC) && defined(__PCC__)
+# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__)
+# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0))
+# define LZO_CC_PCC_GNUC LZO_CC_GNUC
+# endif
+#endif
+#if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
+# error "LZO_CC_MSC: _MSC_FULL_VER is not defined"
+#endif
+#if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY)
+# if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY)
+# if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E)
+# define LZO_ARCH_CRAY_MPP 1
+# elif defined(_CRAY1)
+# define LZO_ARCH_CRAY_PVP 1
+# endif
+# endif
+#endif
+#if !defined(__LZO_ARCH_OVERRIDE)
+#if (LZO_ARCH_GENERIC)
+# define LZO_INFO_ARCH "generic"
+#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
+# define LZO_ARCH_I086 1
+# define LZO_INFO_ARCH "i086"
+#elif defined(__aarch64__)
+# define LZO_ARCH_ARM64 1
+# define LZO_INFO_ARCH "arm64"
+#elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
+# define LZO_ARCH_ALPHA 1
+# define LZO_INFO_ARCH "alpha"
+#elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E))
+# define LZO_ARCH_ALPHA 1
+# define LZO_INFO_ARCH "alpha"
+#elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
+# define LZO_ARCH_AMD64 1
+# define LZO_INFO_ARCH "amd64"
+#elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB))
+# define LZO_ARCH_ARM 1
+# define LZO_ARCH_ARM_THUMB 1
+# define LZO_INFO_ARCH "arm_thumb"
+#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__)
+# define LZO_ARCH_ARM 1
+# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1)
+# define LZO_ARCH_ARM_THUMB 1
+# define LZO_INFO_ARCH "arm_thumb"
+# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2)
+# define LZO_INFO_ARCH "arm"
+# else
+# define LZO_INFO_ARCH "arm"
+# endif
+#elif defined(__arm__) || defined(_M_ARM)
+# define LZO_ARCH_ARM 1
+# define LZO_INFO_ARCH "arm"
+#elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__)
+# define LZO_ARCH_AVR 1
+# define LZO_INFO_ARCH "avr"
+#elif defined(__avr32__) || defined(__AVR32__)
+# define LZO_ARCH_AVR32 1
+# define LZO_INFO_ARCH "avr32"
+#elif defined(__bfin__)
+# define LZO_ARCH_BLACKFIN 1
+# define LZO_INFO_ARCH "blackfin"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__C166__)
+# define LZO_ARCH_C166 1
+# define LZO_INFO_ARCH "c166"
+#elif defined(__cris__)
+# define LZO_ARCH_CRIS 1
+# define LZO_INFO_ARCH "cris"
+#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__)
+# define LZO_ARCH_EZ80 1
+# define LZO_INFO_ARCH "ez80"
+#elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+# define LZO_ARCH_H8300 1
+# define LZO_INFO_ARCH "h8300"
+#elif defined(__hppa__) || defined(__hppa)
+# define LZO_ARCH_HPPA 1
+# define LZO_INFO_ARCH "hppa"
+#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386)
+# define LZO_ARCH_I386 1
+# define LZO_ARCH_IA32 1
+# define LZO_INFO_ARCH "i386"
+#elif (LZO_CC_ZORTECHC && defined(__I86__))
+# define LZO_ARCH_I386 1
+# define LZO_ARCH_IA32 1
+# define LZO_INFO_ARCH "i386"
+#elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386)
+# define LZO_ARCH_I386 1
+# define LZO_ARCH_IA32 1
+# define LZO_INFO_ARCH "i386"
+#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
+# define LZO_ARCH_IA64 1
+# define LZO_INFO_ARCH "ia64"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__)
+# define LZO_ARCH_M16C 1
+# define LZO_INFO_ARCH "m16c"
+#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__)
+# define LZO_ARCH_M16C 1
+# define LZO_INFO_ARCH "m16c"
+#elif defined(__m32r__)
+# define LZO_ARCH_M32R 1
+# define LZO_INFO_ARCH "m32r"
+#elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K)
+# define LZO_ARCH_M68K 1
+# define LZO_INFO_ARCH "m68k"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__C251__)
+# define LZO_ARCH_MCS251 1
+# define LZO_INFO_ARCH "mcs251"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__C51__)
+# define LZO_ARCH_MCS51 1
+# define LZO_INFO_ARCH "mcs51"
+#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__)
+# define LZO_ARCH_MCS51 1
+# define LZO_INFO_ARCH "mcs51"
+#elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000)
+# define LZO_ARCH_MIPS 1
+# define LZO_INFO_ARCH "mips"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__)
+# define LZO_ARCH_MSP430 1
+# define LZO_INFO_ARCH "msp430"
+#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__)
+# define LZO_ARCH_MSP430 1
+# define LZO_INFO_ARCH "msp430"
+#elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR)
+# define LZO_ARCH_POWERPC 1
+# define LZO_INFO_ARCH "powerpc"
+#elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x)
+# define LZO_ARCH_S390 1
+# define LZO_INFO_ARCH "s390"
+#elif defined(__sh__) || defined(_M_SH)
+# define LZO_ARCH_SH 1
+# define LZO_INFO_ARCH "sh"
+#elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8)
+# define LZO_ARCH_SPARC 1
+# define LZO_INFO_ARCH "sparc"
+#elif defined(__SPU__)
+# define LZO_ARCH_SPU 1
+# define LZO_INFO_ARCH "spu"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__z80)
+# define LZO_ARCH_Z80 1
+# define LZO_INFO_ARCH "z80"
+#elif (LZO_ARCH_CRAY_PVP)
+# if defined(_CRAYSV1)
+# define LZO_ARCH_CRAY_SV1 1
+# define LZO_INFO_ARCH "cray_sv1"
+# elif (_ADDR64)
+# define LZO_ARCH_CRAY_T90 1
+# define LZO_INFO_ARCH "cray_t90"
+# elif (_ADDR32)
+# define LZO_ARCH_CRAY_YMP 1
+# define LZO_INFO_ARCH "cray_ymp"
+# else
+# define LZO_ARCH_CRAY_XMP 1
+# define LZO_INFO_ARCH "cray_xmp"
+# endif
+#else
+# define LZO_ARCH_UNKNOWN 1
+# define LZO_INFO_ARCH "unknown"
+#endif
+#endif
+#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2)
+# error "FIXME - missing define for CPU architecture"
+#endif
+#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32)
+# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture"
+#endif
+#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64)
+# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture"
+#endif
+#if (LZO_OS_OS216 || LZO_OS_WIN16)
+# define LZO_ARCH_I086PM 1
+#elif 1 && (LZO_OS_DOS16 && defined(BLX286))
+# define LZO_ARCH_I086PM 1
+#elif 1 && (LZO_OS_DOS16 && defined(DOSX286))
+# define LZO_ARCH_I086PM 1
+#elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__))
+# define LZO_ARCH_I086PM 1
+#endif
+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64)
+# define LZO_ARCH_X64 1
+#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE)
+# define LZO_ARCH_AMD64 1
+#endif
+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64)
+# define LZO_ARCH_AARCH64 1
+#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE)
+# define LZO_ARCH_ARM64 1
+#endif
+#if (LZO_ARCH_I386 && !LZO_ARCH_X86)
+# define LZO_ARCH_X86 1
+#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE)
+# define LZO_ARCH_I386 1
+#endif
+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_I086PM && !LZO_ARCH_I086)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_I086)
+# if (UINT_MAX != LZO_0xffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+# if (ULONG_MAX != LZO_0xffffffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+#endif
+#if (LZO_ARCH_I386)
+# if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
+# error "unexpected configuration - check your compiler defines"
+# endif
+# if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
+# error "unexpected configuration - check your compiler defines"
+# endif
+# if (ULONG_MAX != LZO_0xffffffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+#endif
+#if (LZO_ARCH_AMD64 || LZO_ARCH_I386)
+# if !defined(LZO_TARGET_FEATURE_SSE2)
+# if defined(__SSE2__)
+# define LZO_TARGET_FEATURE_SSE2 1
+# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64))
+# define LZO_TARGET_FEATURE_SSE2 1
+# endif
+# endif
+# if !defined(LZO_TARGET_FEATURE_SSSE3)
+# if (LZO_TARGET_FEATURE_SSE2)
+# if defined(__SSSE3__)
+# define LZO_TARGET_FEATURE_SSSE3 1
+# elif defined(_MSC_VER) && defined(__AVX__)
+# define LZO_TARGET_FEATURE_SSSE3 1
+# endif
+# endif
+# endif
+# if !defined(LZO_TARGET_FEATURE_SSE4_2)
+# if (LZO_TARGET_FEATURE_SSSE3)
+# if defined(__SSE4_2__)
+# define LZO_TARGET_FEATURE_SSE4_2 1
+# endif
+# endif
+# endif
+# if !defined(LZO_TARGET_FEATURE_AVX)
+# if (LZO_TARGET_FEATURE_SSSE3)
+# if defined(__AVX__)
+# define LZO_TARGET_FEATURE_AVX 1
+# endif
+# endif
+# endif
+# if !defined(LZO_TARGET_FEATURE_AVX2)
+# if (LZO_TARGET_FEATURE_AVX)
+# if defined(__AVX2__)
+# define LZO_TARGET_FEATURE_AVX2 1
+# endif
+# endif
+# endif
+#endif
+#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2))
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3))
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3))
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX))
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM)
+# if !defined(LZO_TARGET_FEATURE_NEON)
+# if defined(__ARM_NEON__)
+# define LZO_TARGET_FEATURE_NEON 1
+# endif
+# endif
+#elif (LZO_ARCH_ARM64)
+# if !defined(LZO_TARGET_FEATURE_NEON)
+# if 1
+# define LZO_TARGET_FEATURE_NEON 1
+# endif
+# endif
+#endif
+#if 0
+#elif !defined(__LZO_MM_OVERRIDE)
+#if (LZO_ARCH_I086)
+#if (UINT_MAX != LZO_0xffffL)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM)
+# define LZO_MM_TINY 1
+#elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM)
+# define LZO_MM_HUGE 1
+#elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL)
+# define LZO_MM_SMALL 1
+#elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM)
+# define LZO_MM_MEDIUM 1
+#elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM)
+# define LZO_MM_COMPACT 1
+#elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL)
+# define LZO_MM_LARGE 1
+#elif (LZO_CC_AZTECC)
+# if defined(_LARGE_CODE) && defined(_LARGE_DATA)
+# define LZO_MM_LARGE 1
+# elif defined(_LARGE_CODE)
+# define LZO_MM_MEDIUM 1
+# elif defined(_LARGE_DATA)
+# define LZO_MM_COMPACT 1
+# else
+# define LZO_MM_SMALL 1
+# endif
+#elif (LZO_CC_ZORTECHC && defined(__VCM__))
+# define LZO_MM_LARGE 1
+#else
+# error "unknown LZO_ARCH_I086 memory model"
+#endif
+#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
+#define LZO_HAVE_MM_HUGE_PTR 1
+#define LZO_HAVE_MM_HUGE_ARRAY 1
+#if (LZO_MM_TINY)
+# undef LZO_HAVE_MM_HUGE_ARRAY
+#endif
+#if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC)
+# undef LZO_HAVE_MM_HUGE_PTR
+# undef LZO_HAVE_MM_HUGE_ARRAY
+#elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
+# undef LZO_HAVE_MM_HUGE_ARRAY
+#elif (LZO_CC_MSC && defined(_QC))
+# undef LZO_HAVE_MM_HUGE_ARRAY
+# if (_MSC_VER < 600)
+# undef LZO_HAVE_MM_HUGE_PTR
+# endif
+#elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295))
+# undef LZO_HAVE_MM_HUGE_ARRAY
+#endif
+#if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR)
+# if (LZO_OS_DOS16)
+# error "unexpected configuration - check your compiler defines"
+# elif (LZO_CC_ZORTECHC)
+# else
+# error "unexpected configuration - check your compiler defines"
+# endif
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+#if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
+ extern void __near __cdecl _AHSHIFT(void);
+# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
+#elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
+ extern void __near __cdecl _AHSHIFT(void);
+# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
+#elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC)
+ extern void __near __cdecl _AHSHIFT(void);
+# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
+#elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295))
+ extern void __near __cdecl _AHSHIFT(void);
+# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
+#elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16)
+# define LZO_MM_AHSHIFT 12
+#elif (LZO_CC_WATCOMC)
+ extern unsigned char _HShift;
+# define LZO_MM_AHSHIFT ((unsigned) _HShift)
+#else
+# error "FIXME - implement LZO_MM_AHSHIFT"
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
+#elif (LZO_ARCH_C166)
+#if !defined(__MODEL__)
+# error "FIXME - LZO_ARCH_C166 __MODEL__"
+#elif ((__MODEL__) == 0)
+# define LZO_MM_SMALL 1
+#elif ((__MODEL__) == 1)
+# define LZO_MM_SMALL 1
+#elif ((__MODEL__) == 2)
+# define LZO_MM_LARGE 1
+#elif ((__MODEL__) == 3)
+# define LZO_MM_TINY 1
+#elif ((__MODEL__) == 4)
+# define LZO_MM_XTINY 1
+#elif ((__MODEL__) == 5)
+# define LZO_MM_XSMALL 1
+#else
+# error "FIXME - LZO_ARCH_C166 __MODEL__"
+#endif
+#elif (LZO_ARCH_MCS251)
+#if !defined(__MODEL__)
+# error "FIXME - LZO_ARCH_MCS251 __MODEL__"
+#elif ((__MODEL__) == 0)
+# define LZO_MM_SMALL 1
+#elif ((__MODEL__) == 2)
+# define LZO_MM_LARGE 1
+#elif ((__MODEL__) == 3)
+# define LZO_MM_TINY 1
+#elif ((__MODEL__) == 4)
+# define LZO_MM_XTINY 1
+#elif ((__MODEL__) == 5)
+# define LZO_MM_XSMALL 1
+#else
+# error "FIXME - LZO_ARCH_MCS251 __MODEL__"
+#endif
+#elif (LZO_ARCH_MCS51)
+#if !defined(__MODEL__)
+# error "FIXME - LZO_ARCH_MCS51 __MODEL__"
+#elif ((__MODEL__) == 1)
+# define LZO_MM_SMALL 1
+#elif ((__MODEL__) == 2)
+# define LZO_MM_LARGE 1
+#elif ((__MODEL__) == 3)
+# define LZO_MM_TINY 1
+#elif ((__MODEL__) == 4)
+# define LZO_MM_XTINY 1
+#elif ((__MODEL__) == 5)
+# define LZO_MM_XSMALL 1
+#else
+# error "FIXME - LZO_ARCH_MCS51 __MODEL__"
+#endif
+#elif (LZO_ARCH_CRAY_PVP)
+# define LZO_MM_PVP 1
+#else
+# define LZO_MM_FLAT 1
+#endif
+#if (LZO_MM_COMPACT)
+# define LZO_INFO_MM "compact"
+#elif (LZO_MM_FLAT)
+# define LZO_INFO_MM "flat"
+#elif (LZO_MM_HUGE)
+# define LZO_INFO_MM "huge"
+#elif (LZO_MM_LARGE)
+# define LZO_INFO_MM "large"
+#elif (LZO_MM_MEDIUM)
+# define LZO_INFO_MM "medium"
+#elif (LZO_MM_PVP)
+# define LZO_INFO_MM "pvp"
+#elif (LZO_MM_SMALL)
+# define LZO_INFO_MM "small"
+#elif (LZO_MM_TINY)
+# define LZO_INFO_MM "tiny"
+#else
+# error "unknown memory model"
+#endif
+#endif
+#if !defined(__lzo_gnuc_extension__)
+#if (LZO_CC_GNUC >= 0x020800ul)
+# define __lzo_gnuc_extension__ __extension__
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_gnuc_extension__ __extension__
+#elif (LZO_CC_IBMC >= 600)
+# define __lzo_gnuc_extension__ __extension__
+#else
+#endif
+#endif
+#if !defined(__lzo_gnuc_extension__)
+# define __lzo_gnuc_extension__ /*empty*/
+#endif
+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0
+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul))
+# define LZO_CFG_USE_NEW_STYLE_CASTS 0
+# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200))
+# define LZO_CFG_USE_NEW_STYLE_CASTS 0
+# else
+# define LZO_CFG_USE_NEW_STYLE_CASTS 1
+# endif
+#endif
+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_CFG_USE_NEW_STYLE_CASTS 0
+#endif
+#if !defined(__cplusplus)
+# if defined(LZO_CFG_USE_NEW_STYLE_CASTS)
+# undef LZO_CFG_USE_NEW_STYLE_CASTS
+# endif
+# define LZO_CFG_USE_NEW_STYLE_CASTS 0
+#endif
+#if !defined(LZO_REINTERPRET_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast<t> (e))
+# endif
+#endif
+#if !defined(LZO_REINTERPRET_CAST)
+# define LZO_REINTERPRET_CAST(t,e) ((t) (e))
+#endif
+#if !defined(LZO_STATIC_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_STATIC_CAST(t,e) (static_cast<t> (e))
+# endif
+#endif
+#if !defined(LZO_STATIC_CAST)
+# define LZO_STATIC_CAST(t,e) ((t) (e))
+#endif
+#if !defined(LZO_STATIC_CAST2)
+# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e))
+#endif
+#if !defined(LZO_UNCONST_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_UNCONST_CAST(t,e) (const_cast<t> (e))
+# elif (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_UNCONST_CAST(t,e) ((t) (e))
+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e)))))
+# endif
+#endif
+#if !defined(LZO_UNCONST_CAST)
+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e))))
+#endif
+#if !defined(LZO_UNCONST_VOLATILE_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast<t> (e))
+# elif (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e))
+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e)))))
+# endif
+#endif
+#if !defined(LZO_UNCONST_VOLATILE_CAST)
+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e))))
+#endif
+#if !defined(LZO_UNVOLATILE_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_UNVOLATILE_CAST(t,e) (const_cast<t> (e))
+# elif (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_UNVOLATILE_CAST(t,e) ((t) (e))
+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e)))))
+# endif
+#endif
+#if !defined(LZO_UNVOLATILE_CAST)
+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e))))
+#endif
+#if !defined(LZO_UNVOLATILE_CONST_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast<t> (e))
+# elif (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e))
+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e)))))
+# endif
+#endif
+#if !defined(LZO_UNVOLATILE_CONST_CAST)
+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e))))
+#endif
+#if !defined(LZO_PCAST)
+# if (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_PCAST(t,e) ((t) (e))
+# endif
+#endif
+#if !defined(LZO_PCAST)
+# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e))
+#endif
+#if !defined(LZO_CCAST)
+# if (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_CCAST(t,e) ((t) (e))
+# endif
+#endif
+#if !defined(LZO_CCAST)
+# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e))
+#endif
+#if !defined(LZO_ICONV)
+# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e)
+#endif
+#if !defined(LZO_ICAST)
+# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e)
+#endif
+#if !defined(LZO_ITRUNC)
+# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e)
+#endif
+#if !defined(__lzo_cte)
+# if (LZO_CC_MSC || LZO_CC_WATCOMC)
+# define __lzo_cte(e) ((void)0,(e))
+# elif 1
+# define __lzo_cte(e) ((void)0,(e))
+# endif
+#endif
+#if !defined(__lzo_cte)
+# define __lzo_cte(e) (e)
+#endif
+#if !defined(LZO_BLOCK_BEGIN)
+# define LZO_BLOCK_BEGIN do {
+# define LZO_BLOCK_END } while __lzo_cte(0)
+#endif
+#if !defined(LZO_UNUSED)
+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
+# define LZO_UNUSED(var) ((void) &var)
+# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC)
+# define LZO_UNUSED(var) if (&var) ; else
+# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul))
+# define LZO_UNUSED(var) ((void) &var)
+# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_UNUSED(var) ((void) var)
+# elif (LZO_CC_MSC && (_MSC_VER < 900))
+# define LZO_UNUSED(var) if (&var) ; else
+# elif (LZO_CC_KEILC)
+# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];}
+# elif (LZO_CC_PACIFICC)
+# define LZO_UNUSED(var) ((void) sizeof(var))
+# elif (LZO_CC_WATCOMC) && defined(__cplusplus)
+# define LZO_UNUSED(var) ((void) var)
+# else
+# define LZO_UNUSED(var) ((void) &var)
+# endif
+#endif
+#if !defined(LZO_UNUSED_FUNC)
+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
+# define LZO_UNUSED_FUNC(func) ((void) func)
+# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC)
+# define LZO_UNUSED_FUNC(func) if (func) ; else
+# elif (LZO_CC_CLANG || LZO_CC_LLVM)
+# define LZO_UNUSED_FUNC(func) ((void) &func)
+# elif (LZO_CC_MSC && (_MSC_VER < 900))
+# define LZO_UNUSED_FUNC(func) if (func) ; else
+# elif (LZO_CC_MSC)
+# define LZO_UNUSED_FUNC(func) ((void) &func)
+# elif (LZO_CC_KEILC || LZO_CC_PELLESC)
+# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];}
+# else
+# define LZO_UNUSED_FUNC(func) ((void) func)
+# endif
+#endif
+#if !defined(LZO_UNUSED_LABEL)
+# if (LZO_CC_CLANG >= 0x020800ul)
+# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l)))
+# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC)
+# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l
+# else
+# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l
+# endif
+#endif
+#if !defined(LZO_DEFINE_UNINITIALIZED_VAR)
+# if 0
+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var
+# elif 0 && (LZO_CC_GNUC)
+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var
+# else
+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init
+# endif
+#endif
+#if !defined(__lzo_inline)
+#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295))
+#elif defined(__cplusplus)
+# define __lzo_inline inline
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L)
+# define __lzo_inline inline
+#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
+# define __lzo_inline __inline
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
+# define __lzo_inline __inline__
+#elif (LZO_CC_DMC)
+# define __lzo_inline __inline
+#elif (LZO_CC_GHS)
+# define __lzo_inline __inline__
+#elif (LZO_CC_IBMC >= 600)
+# define __lzo_inline __inline__
+#elif (LZO_CC_INTELC)
+# define __lzo_inline __inline
+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405))
+# define __lzo_inline __inline
+#elif (LZO_CC_MSC && (_MSC_VER >= 900))
+# define __lzo_inline __inline
+#elif (LZO_CC_SUNPROC >= 0x5100)
+# define __lzo_inline __inline__
+#endif
+#endif
+#if defined(__lzo_inline)
+# ifndef __lzo_HAVE_inline
+# define __lzo_HAVE_inline 1
+# endif
+#else
+# define __lzo_inline /*empty*/
+#endif
+#if !defined(__lzo_forceinline)
+#if (LZO_CC_GNUC >= 0x030200ul)
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#elif (LZO_CC_IBMC >= 700)
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450))
+# define __lzo_forceinline __forceinline
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#elif (LZO_CC_MSC && (_MSC_VER >= 1200))
+# define __lzo_forceinline __forceinline
+#elif (LZO_CC_PGI >= 0x0d0a00ul)
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#elif (LZO_CC_SUNPROC >= 0x5100)
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#endif
+#endif
+#if defined(__lzo_forceinline)
+# ifndef __lzo_HAVE_forceinline
+# define __lzo_HAVE_forceinline 1
+# endif
+#else
+# define __lzo_forceinline __lzo_inline
+#endif
+#if !defined(__lzo_noinline)
+#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul)
+# define __lzo_noinline __attribute__((__noinline__,__used__))
+#elif (LZO_CC_GNUC >= 0x030200ul)
+# define __lzo_noinline __attribute__((__noinline__))
+#elif (LZO_CC_IBMC >= 700)
+# define __lzo_noinline __attribute__((__noinline__))
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600))
+# define __lzo_noinline __declspec(noinline)
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
+# define __lzo_noinline __attribute__((__noinline__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_noinline __attribute__((__noinline__))
+#elif (LZO_CC_MSC && (_MSC_VER >= 1300))
+# define __lzo_noinline __declspec(noinline)
+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64))
+# if defined(__cplusplus)
+# else
+# define __lzo_noinline __declspec(noinline)
+# endif
+#elif (LZO_CC_PGI >= 0x0d0a00ul)
+# define __lzo_noinline __attribute__((__noinline__))
+#elif (LZO_CC_SUNPROC >= 0x5100)
+# define __lzo_noinline __attribute__((__noinline__))
+#endif
+#endif
+#if defined(__lzo_noinline)
+# ifndef __lzo_HAVE_noinline
+# define __lzo_HAVE_noinline 1
+# endif
+#else
+# define __lzo_noinline /*empty*/
+#endif
+#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if !defined(__lzo_static_inline)
+#if (LZO_CC_IBMC)
+# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline
+#endif
+#endif
+#if !defined(__lzo_static_inline)
+# define __lzo_static_inline static __lzo_inline
+#endif
+#if !defined(__lzo_static_forceinline)
+#if (LZO_CC_IBMC)
+# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline
+#endif
+#endif
+#if !defined(__lzo_static_forceinline)
+# define __lzo_static_forceinline static __lzo_forceinline
+#endif
+#if !defined(__lzo_static_noinline)
+#if (LZO_CC_IBMC)
+# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline
+#endif
+#endif
+#if !defined(__lzo_static_noinline)
+# define __lzo_static_noinline static __lzo_noinline
+#endif
+#if !defined(__lzo_c99_extern_inline)
+#if defined(__GNUC_GNU_INLINE__)
+# define __lzo_c99_extern_inline __lzo_inline
+#elif defined(__GNUC_STDC_INLINE__)
+# define __lzo_c99_extern_inline extern __lzo_inline
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L)
+# define __lzo_c99_extern_inline extern __lzo_inline
+#endif
+#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline)
+# define __lzo_c99_extern_inline __lzo_inline
+#endif
+#endif
+#if defined(__lzo_c99_extern_inline)
+# ifndef __lzo_HAVE_c99_extern_inline
+# define __lzo_HAVE_c99_extern_inline 1
+# endif
+#else
+# define __lzo_c99_extern_inline /*empty*/
+#endif
+#if !defined(__lzo_may_alias)
+#if (LZO_CC_GNUC >= 0x030400ul)
+# define __lzo_may_alias __attribute__((__may_alias__))
+#elif (LZO_CC_CLANG >= 0x020900ul)
+# define __lzo_may_alias __attribute__((__may_alias__))
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0
+# define __lzo_may_alias __attribute__((__may_alias__))
+#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0
+# define __lzo_may_alias __attribute__((__may_alias__))
+#endif
+#endif
+#if defined(__lzo_may_alias)
+# ifndef __lzo_HAVE_may_alias
+# define __lzo_HAVE_may_alias 1
+# endif
+#else
+# define __lzo_may_alias /*empty*/
+#endif
+#if !defined(__lzo_noreturn)
+#if (LZO_CC_GNUC >= 0x020700ul)
+# define __lzo_noreturn __attribute__((__noreturn__))
+#elif (LZO_CC_IBMC >= 700)
+# define __lzo_noreturn __attribute__((__noreturn__))
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450))
+# define __lzo_noreturn __declspec(noreturn)
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600))
+# define __lzo_noreturn __attribute__((__noreturn__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_noreturn __attribute__((__noreturn__))
+#elif (LZO_CC_MSC && (_MSC_VER >= 1200))
+# define __lzo_noreturn __declspec(noreturn)
+#elif (LZO_CC_PGI >= 0x0d0a00ul)
+# define __lzo_noreturn __attribute__((__noreturn__))
+#endif
+#endif
+#if defined(__lzo_noreturn)
+# ifndef __lzo_HAVE_noreturn
+# define __lzo_HAVE_noreturn 1
+# endif
+#else
+# define __lzo_noreturn /*empty*/
+#endif
+#if !defined(__lzo_nothrow)
+#if (LZO_CC_GNUC >= 0x030300ul)
+# define __lzo_nothrow __attribute__((__nothrow__))
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus)
+# define __lzo_nothrow __declspec(nothrow)
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900))
+# define __lzo_nothrow __attribute__((__nothrow__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_nothrow __attribute__((__nothrow__))
+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
+# define __lzo_nothrow __declspec(nothrow)
+#endif
+#endif
+#if defined(__lzo_nothrow)
+# ifndef __lzo_HAVE_nothrow
+# define __lzo_HAVE_nothrow 1
+# endif
+#else
+# define __lzo_nothrow /*empty*/
+#endif
+#if !defined(__lzo_restrict)
+#if (LZO_CC_GNUC >= 0x030400ul)
+# define __lzo_restrict __restrict__
+#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus)
+# define __lzo_restrict __restrict__
+#elif (LZO_CC_IBMC >= 1210)
+# define __lzo_restrict __restrict__
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600))
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600))
+# define __lzo_restrict __restrict__
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM)
+# define __lzo_restrict __restrict__
+#elif (LZO_CC_MSC && (_MSC_VER >= 1400))
+# define __lzo_restrict __restrict
+#elif (LZO_CC_PGI >= 0x0d0a00ul)
+# define __lzo_restrict __restrict__
+#endif
+#endif
+#if defined(__lzo_restrict)
+# ifndef __lzo_HAVE_restrict
+# define __lzo_HAVE_restrict 1
+# endif
+#else
+# define __lzo_restrict /*empty*/
+#endif
+#if !defined(__lzo_alignof)
+#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
+# define __lzo_alignof(e) __alignof__(e)
+#elif (LZO_CC_GHS) && !defined(__cplusplus)
+# define __lzo_alignof(e) __alignof__(e)
+#elif (LZO_CC_IBMC >= 600)
+# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e))
+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700))
+# define __lzo_alignof(e) __alignof__(e)
+#elif (LZO_CC_MSC && (_MSC_VER >= 1300))
+# define __lzo_alignof(e) __alignof(e)
+#elif (LZO_CC_SUNPROC >= 0x5100)
+# define __lzo_alignof(e) __alignof__(e)
+#endif
+#endif
+#if defined(__lzo_alignof)
+# ifndef __lzo_HAVE_alignof
+# define __lzo_HAVE_alignof 1
+# endif
+#endif
+#if !defined(__lzo_struct_packed)
+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus)
+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul))
+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus)
+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul))
+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus)
+#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
+# define __lzo_struct_packed(s) struct s {
+# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__));
+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__));
+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100))
+# define __lzo_struct_packed(s) struct s {
+# define __lzo_struct_packed_end() } __attribute__((__packed__));
+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__));
+#elif (LZO_CC_IBMC >= 700)
+# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s {
+# define __lzo_struct_packed_end() } __attribute__((__packed__));
+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__));
+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300))
+# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s {
+# define __lzo_struct_packed_end() } __pragma(pack(pop));
+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900))
+# define __lzo_struct_packed(s) _Packed struct s {
+# define __lzo_struct_packed_end() };
+#endif
+#endif
+#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma)
+# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s)
+#endif
+#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end)
+# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end()
+#endif
+#if !defined(__lzo_byte_struct)
+#if defined(__lzo_struct_packed)
+# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end()
+# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end()
+#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100))
+# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__));
+# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__));
+#endif
+#endif
+#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma)
+# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n)
+#endif
+#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof)
+#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul))
+#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus)
+#elif (LZO_CC_CILLY || LZO_CC_PCC)
+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300))
+# define __lzo_struct_align16(s) struct __declspec(align(16)) s {
+# define __lzo_struct_align16_end() };
+# define __lzo_struct_align32(s) struct __declspec(align(32)) s {
+# define __lzo_struct_align32_end() };
+# define __lzo_struct_align64(s) struct __declspec(align(64)) s {
+# define __lzo_struct_align64_end() };
+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_struct_align16(s) struct s {
+# define __lzo_struct_align16_end() } __attribute__((__aligned__(16)));
+# define __lzo_struct_align32(s) struct s {
+# define __lzo_struct_align32_end() } __attribute__((__aligned__(32)));
+# define __lzo_struct_align64(s) struct s {
+# define __lzo_struct_align64_end() } __attribute__((__aligned__(64)));
+#endif
+#endif
+#if !defined(__lzo_union_um)
+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus)
+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul))
+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus)
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810))
+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul))
+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus)
+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100))
+# define __lzo_union_am(s) union s {
+# define __lzo_union_am_end() } __lzo_may_alias;
+# define __lzo_union_um(s) union s {
+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__));
+#elif (LZO_CC_IBMC >= 700)
+# define __lzo_union_am(s) __lzo_gnuc_extension__ union s {
+# define __lzo_union_am_end() } __lzo_may_alias;
+# define __lzo_union_um(s) __lzo_gnuc_extension__ union s {
+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__));
+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300))
+# define __lzo_union_um(s) __pragma(pack(push,1)) union s {
+# define __lzo_union_um_end() } __pragma(pack(pop));
+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900))
+# define __lzo_union_um(s) _Packed union s {
+# define __lzo_union_um_end() };
+#endif
+#endif
+#if !defined(__lzo_union_am)
+# define __lzo_union_am(s) union s {
+# define __lzo_union_am_end() };
+#endif
+#if !defined(__lzo_constructor)
+#if (LZO_CC_GNUC >= 0x030400ul)
+# define __lzo_constructor __attribute__((__constructor__,__used__))
+#elif (LZO_CC_GNUC >= 0x020700ul)
+# define __lzo_constructor __attribute__((__constructor__))
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
+# define __lzo_constructor __attribute__((__constructor__,__used__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_constructor __attribute__((__constructor__))
+#endif
+#endif
+#if defined(__lzo_constructor)
+# ifndef __lzo_HAVE_constructor
+# define __lzo_HAVE_constructor 1
+# endif
+#endif
+#if !defined(__lzo_destructor)
+#if (LZO_CC_GNUC >= 0x030400ul)
+# define __lzo_destructor __attribute__((__destructor__,__used__))
+#elif (LZO_CC_GNUC >= 0x020700ul)
+# define __lzo_destructor __attribute__((__destructor__))
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
+# define __lzo_destructor __attribute__((__destructor__,__used__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_destructor __attribute__((__destructor__))
+#endif
+#endif
+#if defined(__lzo_destructor)
+# ifndef __lzo_HAVE_destructor
+# define __lzo_HAVE_destructor 1
+# endif
+#endif
+#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if !defined(__lzo_likely) && !defined(__lzo_unlikely)
+#if (LZO_CC_GNUC >= 0x030200ul)
+# define __lzo_likely(e) (__builtin_expect(!!(e),1))
+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
+#elif (LZO_CC_IBMC >= 1010)
+# define __lzo_likely(e) (__builtin_expect(!!(e),1))
+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800))
+# define __lzo_likely(e) (__builtin_expect(!!(e),1))
+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_likely(e) (__builtin_expect(!!(e),1))
+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
+#endif
+#endif
+#if defined(__lzo_likely)
+# ifndef __lzo_HAVE_likely
+# define __lzo_HAVE_likely 1
+# endif
+#else
+# define __lzo_likely(e) (e)
+#endif
+#if defined(__lzo_unlikely)
+# ifndef __lzo_HAVE_unlikely
+# define __lzo_HAVE_unlikely 1
+# endif
+#else
+# define __lzo_unlikely(e) (e)
+#endif
+#if !defined(__lzo_static_unused_void_func)
+# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
+# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void)
+# else
+# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void)
+# endif
+#endif
+#if !defined(__lzo_loop_forever)
+# if (LZO_CC_IBMC)
+# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END
+# else
+# define __lzo_loop_forever() do { ; } while __lzo_cte(1)
+# endif
+#endif
+#if !defined(__lzo_unreachable)
+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul))
+# define __lzo_unreachable() __builtin_unreachable();
+#elif (LZO_CC_GNUC >= 0x040500ul)
+# define __lzo_unreachable() __builtin_unreachable();
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1
+# define __lzo_unreachable() __builtin_unreachable();
+#endif
+#endif
+#if defined(__lzo_unreachable)
+# ifndef __lzo_HAVE_unreachable
+# define __lzo_HAVE_unreachable 1
+# endif
+#else
+# if 0
+# define __lzo_unreachable() ((void)0);
+# else
+# define __lzo_unreachable() __lzo_loop_forever();
+# endif
+#endif
+#ifndef __LZO_CTA_NAME
+#if (LZO_CFG_USE_COUNTER)
+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__)
+#else
+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__)
+#endif
+#endif
+#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER)
+# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC)
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END
+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END
+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END
+# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus)
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END
+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__)
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END
+# else
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END
+# endif
+#endif
+#if !defined(LZO_COMPILE_TIME_ASSERT)
+# if (LZO_CC_AZTECC)
+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];}
+# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__)
+# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));}
+# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus)
+# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));}
+# elif (LZO_CC_GNUC >= 0x040700ul)
+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));}
+# elif (LZO_CC_MSC && (_MSC_VER < 900))
+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
+# else
+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];}
+# endif
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1)
+#if defined(__cplusplus)
+extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) }
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3)
+#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64)
+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC)
+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
+# define __lzo_cdecl __cdecl
+# define __lzo_cdecl_atexit /*empty*/
+# define __lzo_cdecl_main __cdecl
+# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
+# define __lzo_cdecl_qsort __pascal
+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
+# define __lzo_cdecl_qsort _stdcall
+# else
+# define __lzo_cdecl_qsort __cdecl
+# endif
+# elif (LZO_CC_WATCOMC)
+# define __lzo_cdecl __cdecl
+# else
+# define __lzo_cdecl __cdecl
+# define __lzo_cdecl_atexit __cdecl
+# define __lzo_cdecl_main __cdecl
+# define __lzo_cdecl_qsort __cdecl
+# endif
+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC)
+# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
+# define __lzo_cdecl_sighandler __pascal
+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
+# define __lzo_cdecl_sighandler _stdcall
+# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE)
+# define __lzo_cdecl_sighandler __clrcall
+# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
+# if defined(_DLL)
+# define __lzo_cdecl_sighandler _far _cdecl _loadds
+# elif defined(_MT)
+# define __lzo_cdecl_sighandler _far _cdecl
+# else
+# define __lzo_cdecl_sighandler _cdecl
+# endif
+# else
+# define __lzo_cdecl_sighandler __cdecl
+# endif
+#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC)
+# define __lzo_cdecl __cdecl
+#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
+# define __lzo_cdecl cdecl
+#endif
+#if !defined(__lzo_cdecl)
+# define __lzo_cdecl /*empty*/
+#endif
+#if !defined(__lzo_cdecl_atexit)
+# define __lzo_cdecl_atexit /*empty*/
+#endif
+#if !defined(__lzo_cdecl_main)
+# define __lzo_cdecl_main /*empty*/
+#endif
+#if !defined(__lzo_cdecl_qsort)
+# define __lzo_cdecl_qsort /*empty*/
+#endif
+#if !defined(__lzo_cdecl_sighandler)
+# define __lzo_cdecl_sighandler /*empty*/
+#endif
+#if !defined(__lzo_cdecl_va)
+# define __lzo_cdecl_va __lzo_cdecl
+#endif
+#if !(LZO_CFG_NO_WINDOWS_H)
+#if !defined(LZO_HAVE_WINDOWS_H)
+#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64)
+# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000))
+# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
+# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul)))
+# else
+# define LZO_HAVE_WINDOWS_H 1
+# endif
+#endif
+#endif
+#endif
+#ifndef LZO_SIZEOF_SHORT
+#if defined(SIZEOF_SHORT)
+# define LZO_SIZEOF_SHORT (SIZEOF_SHORT)
+#elif defined(__SIZEOF_SHORT__)
+# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__)
+#endif
+#endif
+#ifndef LZO_SIZEOF_INT
+#if defined(SIZEOF_INT)
+# define LZO_SIZEOF_INT (SIZEOF_INT)
+#elif defined(__SIZEOF_INT__)
+# define LZO_SIZEOF_INT (__SIZEOF_INT__)
+#endif
+#endif
+#ifndef LZO_SIZEOF_LONG
+#if defined(SIZEOF_LONG)
+# define LZO_SIZEOF_LONG (SIZEOF_LONG)
+#elif defined(__SIZEOF_LONG__)
+# define LZO_SIZEOF_LONG (__SIZEOF_LONG__)
+#endif
+#endif
+#ifndef LZO_SIZEOF_LONG_LONG
+#if defined(SIZEOF_LONG_LONG)
+# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG)
+#elif defined(__SIZEOF_LONG_LONG__)
+# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__)
+#endif
+#endif
+#ifndef LZO_SIZEOF___INT16
+#if defined(SIZEOF___INT16)
+# define LZO_SIZEOF___INT16 (SIZEOF___INT16)
+#endif
+#endif
+#ifndef LZO_SIZEOF___INT32
+#if defined(SIZEOF___INT32)
+# define LZO_SIZEOF___INT32 (SIZEOF___INT32)
+#endif
+#endif
+#ifndef LZO_SIZEOF___INT64
+#if defined(SIZEOF___INT64)
+# define LZO_SIZEOF___INT64 (SIZEOF___INT64)
+#endif
+#endif
+#ifndef LZO_SIZEOF_VOID_P
+#if defined(SIZEOF_VOID_P)
+# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P)
+#elif defined(__SIZEOF_POINTER__)
+# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__)
+#endif
+#endif
+#ifndef LZO_SIZEOF_SIZE_T
+#if defined(SIZEOF_SIZE_T)
+# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T)
+#elif defined(__SIZEOF_SIZE_T__)
+# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__)
+#endif
+#endif
+#ifndef LZO_SIZEOF_PTRDIFF_T
+#if defined(SIZEOF_PTRDIFF_T)
+# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T)
+#elif defined(__SIZEOF_PTRDIFF_T__)
+# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__)
+#endif
+#endif
+#define __LZO_LSR(x,b) (((x)+0ul) >> (b))
+#if !defined(LZO_SIZEOF_SHORT)
+# if (LZO_ARCH_CRAY_PVP)
+# define LZO_SIZEOF_SHORT 8
+# elif (USHRT_MAX == LZO_0xffffL)
+# define LZO_SIZEOF_SHORT 2
+# elif (__LZO_LSR(USHRT_MAX,7) == 1)
+# define LZO_SIZEOF_SHORT 1
+# elif (__LZO_LSR(USHRT_MAX,15) == 1)
+# define LZO_SIZEOF_SHORT 2
+# elif (__LZO_LSR(USHRT_MAX,31) == 1)
+# define LZO_SIZEOF_SHORT 4
+# elif (__LZO_LSR(USHRT_MAX,63) == 1)
+# define LZO_SIZEOF_SHORT 8
+# elif (__LZO_LSR(USHRT_MAX,127) == 1)
+# define LZO_SIZEOF_SHORT 16
+# else
+# error "LZO_SIZEOF_SHORT"
+# endif
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short))
+#if !defined(LZO_SIZEOF_INT)
+# if (LZO_ARCH_CRAY_PVP)
+# define LZO_SIZEOF_INT 8
+# elif (UINT_MAX == LZO_0xffffL)
+# define LZO_SIZEOF_INT 2
+# elif (UINT_MAX == LZO_0xffffffffL)
+# define LZO_SIZEOF_INT 4
+# elif (__LZO_LSR(UINT_MAX,7) == 1)
+# define LZO_SIZEOF_INT 1
+# elif (__LZO_LSR(UINT_MAX,15) == 1)
+# define LZO_SIZEOF_INT 2
+# elif (__LZO_LSR(UINT_MAX,31) == 1)
+# define LZO_SIZEOF_INT 4
+# elif (__LZO_LSR(UINT_MAX,63) == 1)
+# define LZO_SIZEOF_INT 8
+# elif (__LZO_LSR(UINT_MAX,127) == 1)
+# define LZO_SIZEOF_INT 16
+# else
+# error "LZO_SIZEOF_INT"
+# endif
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int))
+#if !defined(LZO_SIZEOF_LONG)
+# if (ULONG_MAX == LZO_0xffffffffL)
+# define LZO_SIZEOF_LONG 4
+# elif (__LZO_LSR(ULONG_MAX,7) == 1)
+# define LZO_SIZEOF_LONG 1
+# elif (__LZO_LSR(ULONG_MAX,15) == 1)
+# define LZO_SIZEOF_LONG 2
+# elif (__LZO_LSR(ULONG_MAX,31) == 1)
+# define LZO_SIZEOF_LONG 4
+# elif (__LZO_LSR(ULONG_MAX,39) == 1)
+# define LZO_SIZEOF_LONG 5
+# elif (__LZO_LSR(ULONG_MAX,63) == 1)
+# define LZO_SIZEOF_LONG 8
+# elif (__LZO_LSR(ULONG_MAX,127) == 1)
+# define LZO_SIZEOF_LONG 16
+# else
+# error "LZO_SIZEOF_LONG"
+# endif
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long))
+#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
+#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
+# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__)
+# if (LZO_CC_GNUC >= 0x030300ul)
+# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0))
+# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG
+# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1)
+# define LZO_SIZEOF_LONG_LONG 4
+# endif
+# endif
+# endif
+#endif
+#endif
+#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
+#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
+#if (LZO_ARCH_I086 && LZO_CC_DMC)
+#elif (LZO_CC_CILLY) && defined(__GNUC__)
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_SIZEOF_LONG_LONG 8
+#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_OS_WIN64 || defined(_WIN64))
+# define LZO_SIZEOF___INT64 8
+#elif (LZO_ARCH_I386 && (LZO_CC_DMC))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700)))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__)))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC))
+# define LZO_SIZEOF___INT64 8
+#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC))
+# define LZO_SIZEOF___INT64 8
+#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520)))
+# define LZO_SIZEOF___INT64 8
+#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100)))
+# define LZO_SIZEOF___INT64 8
+#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64))
+# define LZO_SIZEOF___INT64 8
+#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64)
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2)
+#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+# define LZO_SIZEOF_LONG_LONG 8
+#endif
+#endif
+#endif
+#if defined(__cplusplus) && (LZO_CC_GNUC)
+# if (LZO_CC_GNUC < 0x020800ul)
+# undef LZO_SIZEOF_LONG_LONG
+# endif
+#endif
+#if (LZO_CFG_NO_LONG_LONG)
+# undef LZO_SIZEOF_LONG_LONG
+#elif defined(__NO_LONG_LONG)
+# undef LZO_SIZEOF_LONG_LONG
+#elif defined(_NO_LONGLONG)
+# undef LZO_SIZEOF_LONG_LONG
+#endif
+#if !defined(LZO_WORDSIZE)
+#if (LZO_ARCH_ALPHA)
+# define LZO_WORDSIZE 8
+#elif (LZO_ARCH_AMD64)
+# define LZO_WORDSIZE 8
+#elif (LZO_ARCH_AVR)
+# define LZO_WORDSIZE 1
+#elif (LZO_ARCH_H8300)
+# if defined(__NORMAL_MODE__)
+# define LZO_WORDSIZE 4
+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+# define LZO_WORDSIZE 4
+# else
+# define LZO_WORDSIZE 2
+# endif
+#elif (LZO_ARCH_I086)
+# define LZO_WORDSIZE 2
+#elif (LZO_ARCH_IA64)
+# define LZO_WORDSIZE 8
+#elif (LZO_ARCH_M16C)
+# define LZO_WORDSIZE 2
+#elif (LZO_ARCH_SPU)
+# define LZO_WORDSIZE 4
+#elif (LZO_ARCH_Z80)
+# define LZO_WORDSIZE 1
+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
+# define LZO_WORDSIZE 8
+#elif (LZO_OS_OS400 || defined(__OS400__))
+# define LZO_WORDSIZE 8
+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
+# define LZO_WORDSIZE 8
+#endif
+#endif
+#if !defined(LZO_SIZEOF_VOID_P)
+#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4)
+# define LZO_SIZEOF_VOID_P 4
+#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8)
+# define LZO_SIZEOF_VOID_P 8
+#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4)
+# define LZO_SIZEOF_VOID_P 8
+#elif defined(__LP64__) || defined(__LP64) || defined(_LP64)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8)
+# define LZO_SIZEOF_VOID_P 8
+#elif (LZO_ARCH_AVR)
+# define LZO_SIZEOF_VOID_P 2
+#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430)
+# define LZO_SIZEOF_VOID_P 2
+#elif (LZO_ARCH_H8300)
+# if defined(__NORMAL_MODE__)
+# define LZO_SIZEOF_VOID_P 2
+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+# define LZO_SIZEOF_VOID_P 4
+# else
+# define LZO_SIZEOF_VOID_P 2
+# endif
+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4)
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT
+# endif
+#elif (LZO_ARCH_I086)
+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
+# define LZO_SIZEOF_VOID_P 2
+# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
+# define LZO_SIZEOF_VOID_P 4
+# else
+# error "invalid LZO_ARCH_I086 memory model"
+# endif
+#elif (LZO_ARCH_M16C)
+# if defined(__m32c_cpu__) || defined(__m32cm_cpu__)
+# define LZO_SIZEOF_VOID_P 4
+# else
+# define LZO_SIZEOF_VOID_P 2
+# endif
+#elif (LZO_ARCH_SPU)
+# define LZO_SIZEOF_VOID_P 4
+#elif (LZO_ARCH_Z80)
+# define LZO_SIZEOF_VOID_P 2
+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
+# define LZO_SIZEOF_VOID_P 4
+#elif (LZO_OS_OS400 || defined(__OS400__))
+# if defined(__LLP64_IFC__)
+# define LZO_SIZEOF_VOID_P 8
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
+# else
+# define LZO_SIZEOF_VOID_P 16
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
+# endif
+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
+# define LZO_SIZEOF_VOID_P 8
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
+#endif
+#endif
+#if !defined(LZO_SIZEOF_VOID_P)
+# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *))
+#if !defined(LZO_SIZEOF_SIZE_T)
+#if (LZO_ARCH_I086 || LZO_ARCH_M16C)
+# define LZO_SIZEOF_SIZE_T 2
+#endif
+#endif
+#if !defined(LZO_SIZEOF_SIZE_T)
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P
+#endif
+#if defined(offsetof)
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t))
+#endif
+#if !defined(LZO_SIZEOF_PTRDIFF_T)
+#if (LZO_ARCH_I086)
+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE)
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P
+# elif (LZO_MM_COMPACT || LZO_MM_LARGE)
+# if (LZO_CC_BORLANDC || LZO_CC_TURBOC)
+# define LZO_SIZEOF_PTRDIFF_T 4
+# else
+# define LZO_SIZEOF_PTRDIFF_T 2
+# endif
+# else
+# error "invalid LZO_ARCH_I086 memory model"
+# endif
+#endif
+#endif
+#if !defined(LZO_SIZEOF_PTRDIFF_T)
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T
+#endif
+#if defined(offsetof)
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
+#endif
+#if !defined(LZO_WORDSIZE)
+# define LZO_WORDSIZE LZO_SIZEOF_VOID_P
+#endif
+#if (LZO_ABI_NEUTRAL_ENDIAN)
+# undef LZO_ABI_BIG_ENDIAN
+# undef LZO_ABI_LITTLE_ENDIAN
+#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN)
+#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__)
+# if (__LITTLE_ENDIAN__ == 1)
+# define LZO_ABI_LITTLE_ENDIAN 1
+# else
+# define LZO_ABI_BIG_ENDIAN 1
+# endif
+#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC)
+# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN)
+# error "unexpected configuration - check your compiler defines"
+# elif defined(__BIG_ENDIAN)
+# define LZO_ABI_BIG_ENDIAN 1
+# else
+# define LZO_ABI_LITTLE_ENDIAN 1
+# endif
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#endif
+#endif
+#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ABI_BIG_ENDIAN)
+# define LZO_INFO_ABI_ENDIAN "be"
+#elif (LZO_ABI_LITTLE_ENDIAN)
+# define LZO_INFO_ABI_ENDIAN "le"
+#elif (LZO_ABI_NEUTRAL_ENDIAN)
+# define LZO_INFO_ABI_ENDIAN "neutral"
+#endif
+#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
+# define LZO_ABI_I8LP16 1
+# define LZO_INFO_ABI_PM "i8lp16"
+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
+# define LZO_ABI_ILP16 1
+# define LZO_INFO_ABI_PM "ilp16"
+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
+# define LZO_ABI_LP32 1
+# define LZO_INFO_ABI_PM "lp32"
+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
+# define LZO_ABI_ILP32 1
+# define LZO_INFO_ABI_PM "ilp32"
+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8)
+# define LZO_ABI_LLP64 1
+# define LZO_INFO_ABI_PM "llp64"
+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
+# define LZO_ABI_LP64 1
+# define LZO_INFO_ABI_PM "lp64"
+#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
+# define LZO_ABI_ILP64 1
+# define LZO_INFO_ABI_PM "ilp64"
+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4)
+# define LZO_ABI_IP32L64 1
+# define LZO_INFO_ABI_PM "ip32l64"
+#endif
+#if 0
+#elif !defined(__LZO_LIBC_OVERRIDE)
+#if (LZO_LIBC_NAKED)
+# define LZO_INFO_LIBC "naked"
+#elif (LZO_LIBC_FREESTANDING)
+# define LZO_INFO_LIBC "freestanding"
+#elif (LZO_LIBC_MOSTLY_FREESTANDING)
+# define LZO_INFO_LIBC "mfreestanding"
+#elif (LZO_LIBC_ISOC90)
+# define LZO_INFO_LIBC "isoc90"
+#elif (LZO_LIBC_ISOC99)
+# define LZO_INFO_LIBC "isoc99"
+#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION)
+# define LZO_LIBC_ISOC90 1
+# define LZO_INFO_LIBC "isoc90"
+#elif defined(__dietlibc__)
+# define LZO_LIBC_DIETLIBC 1
+# define LZO_INFO_LIBC "dietlibc"
+#elif defined(_NEWLIB_VERSION)
+# define LZO_LIBC_NEWLIB 1
+# define LZO_INFO_LIBC "newlib"
+#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
+# if defined(__UCLIBC_SUBLEVEL__)
+# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0))
+# else
+# define LZO_LIBC_UCLIBC 0x00090bL
+# endif
+# define LZO_INFO_LIBC "uc" "libc"
+#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)
+# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100)
+# define LZO_INFO_LIBC "glibc"
+#elif (LZO_CC_MWERKS) && defined(__MSL__)
+# define LZO_LIBC_MSL __MSL__
+# define LZO_INFO_LIBC "msl"
+#elif 1 && defined(__IAR_SYSTEMS_ICC__)
+# define LZO_LIBC_ISOC90 1
+# define LZO_INFO_LIBC "isoc90"
+#else
+# define LZO_LIBC_DEFAULT 1
+# define LZO_INFO_LIBC "default"
+#endif
+#endif
+#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
+# define LZO_ASM_SYNTAX_MSC 1
+#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
+#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul))
+#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
+# define LZO_ASM_SYNTAX_GNUC 1
+#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
+# define LZO_ASM_SYNTAX_GNUC 1
+#elif (LZO_CC_GNUC)
+# define LZO_ASM_SYNTAX_GNUC 1
+#endif
+#if (LZO_ASM_SYNTAX_GNUC)
+#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
+# define __LZO_ASM_CLOBBER "ax"
+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/
+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/
+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/
+#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000))
+# define __LZO_ASM_CLOBBER "memory"
+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/
+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory"
+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/
+#else
+# define __LZO_ASM_CLOBBER "cc", "memory"
+# define __LZO_ASM_CLOBBER_LIST_CC : "cc"
+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory"
+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/
+#endif
+#endif
+#if (LZO_ARCH_ALPHA)
+# define LZO_OPT_AVOID_UINT_INDEX 1
+#elif (LZO_ARCH_AMD64)
+# define LZO_OPT_AVOID_INT_INDEX 1
+# define LZO_OPT_AVOID_UINT_INDEX 1
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# ifndef LZO_OPT_UNALIGNED64
+# define LZO_OPT_UNALIGNED64 1
+# endif
+#elif (LZO_ARCH_ARM)
+# if defined(__ARM_FEATURE_UNALIGNED)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# endif
+#elif (LZO_ARCH_ARM64)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# ifndef LZO_OPT_UNALIGNED64
+# define LZO_OPT_UNALIGNED64 1
+# endif
+#elif (LZO_ARCH_CRIS)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+#elif (LZO_ARCH_I386)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+#elif (LZO_ARCH_IA64)
+# define LZO_OPT_AVOID_INT_INDEX 1
+# define LZO_OPT_AVOID_UINT_INDEX 1
+# define LZO_OPT_PREFER_POSTINC 1
+#elif (LZO_ARCH_M68K)
+# define LZO_OPT_PREFER_POSTINC 1
+# define LZO_OPT_PREFER_PREDEC 1
+# if defined(__mc68020__) && !defined(__mcoldfire__)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# endif
+#elif (LZO_ARCH_MIPS)
+# define LZO_OPT_AVOID_UINT_INDEX 1
+#elif (LZO_ARCH_POWERPC)
+# define LZO_OPT_PREFER_PREINC 1
+# define LZO_OPT_PREFER_PREDEC 1
+# if (LZO_ABI_BIG_ENDIAN)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# if (LZO_WORDSIZE == 8)
+# ifndef LZO_OPT_UNALIGNED64
+# define LZO_OPT_UNALIGNED64 1
+# endif
+# endif
+# endif
+#elif (LZO_ARCH_S390)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# if (LZO_WORDSIZE == 8)
+# ifndef LZO_OPT_UNALIGNED64
+# define LZO_OPT_UNALIGNED64 1
+# endif
+# endif
+#elif (LZO_ARCH_SH)
+# define LZO_OPT_PREFER_POSTINC 1
+# define LZO_OPT_PREFER_PREDEC 1
+#endif
+#ifndef LZO_CFG_NO_INLINE_ASM
+#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC)
+# define LZO_CFG_NO_INLINE_ASM 1
+#elif (LZO_CC_LLVM)
+# define LZO_CFG_NO_INLINE_ASM 1
+#endif
+#endif
+#if (LZO_CFG_NO_INLINE_ASM)
+# undef LZO_ASM_SYNTAX_MSC
+# undef LZO_ASM_SYNTAX_GNUC
+# undef __LZO_ASM_CLOBBER
+# undef __LZO_ASM_CLOBBER_LIST_CC
+# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY
+# undef __LZO_ASM_CLOBBER_LIST_EMPTY
+#endif
+#ifndef LZO_CFG_NO_UNALIGNED
+#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC)
+# define LZO_CFG_NO_UNALIGNED 1
+#endif
+#endif
+#if (LZO_CFG_NO_UNALIGNED)
+# undef LZO_OPT_UNALIGNED16
+# undef LZO_OPT_UNALIGNED32
+# undef LZO_OPT_UNALIGNED64
+#endif
+#if defined(__LZO_INFOSTR_MM)
+#elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM))
+# define __LZO_INFOSTR_MM ""
+#elif defined(LZO_INFO_MM)
+# define __LZO_INFOSTR_MM "." LZO_INFO_MM
+#else
+# define __LZO_INFOSTR_MM ""
+#endif
+#if defined(__LZO_INFOSTR_PM)
+#elif defined(LZO_INFO_ABI_PM)
+# define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM
+#else
+# define __LZO_INFOSTR_PM ""
+#endif
+#if defined(__LZO_INFOSTR_ENDIAN)
+#elif defined(LZO_INFO_ABI_ENDIAN)
+# define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN
+#else
+# define __LZO_INFOSTR_ENDIAN ""
+#endif
+#if defined(__LZO_INFOSTR_OSNAME)
+#elif defined(LZO_INFO_OS_CONSOLE)
+# define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE
+#elif defined(LZO_INFO_OS_POSIX)
+# define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX
+#else
+# define __LZO_INFOSTR_OSNAME LZO_INFO_OS
+#endif
+#if defined(__LZO_INFOSTR_LIBC)
+#elif defined(LZO_INFO_LIBC)
+# define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC
+#else
+# define __LZO_INFOSTR_LIBC ""
+#endif
+#if defined(__LZO_INFOSTR_CCVER)
+#elif defined(LZO_INFO_CCVER)
+# define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER
+#else
+# define __LZO_INFOSTR_CCVER ""
+#endif
+#define LZO_INFO_STRING \
+ LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \
+ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER
+#if !(LZO_CFG_SKIP_LZO_TYPES)
+#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0))
+# error "missing defines for sizes"
+#endif
+#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0))
+# error "missing defines for sizes"
+#endif
+#if !defined(lzo_llong_t)
+#if (LZO_SIZEOF_LONG_LONG+0 > 0)
+__lzo_gnuc_extension__ typedef long long lzo_llong_t__;
+__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
+# define lzo_llong_t lzo_llong_t__
+# define lzo_ullong_t lzo_ullong_t__
+#endif
+#endif
+#if !defined(lzo_int16e_t)
+#if (LZO_SIZEOF_LONG == 2)
+# define lzo_int16e_t long
+# define lzo_uint16e_t unsigned long
+#elif (LZO_SIZEOF_INT == 2)
+# define lzo_int16e_t int
+# define lzo_uint16e_t unsigned int
+#elif (LZO_SIZEOF_SHORT == 2)
+# define lzo_int16e_t short int
+# define lzo_uint16e_t unsigned short int
+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM)
+ typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__)));
+ typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__)));
+# define lzo_int16e_t lzo_int16e_hi_t__
+# define lzo_uint16e_t lzo_uint16e_hi_t__
+#elif (LZO_SIZEOF___INT16 == 2)
+# define lzo_int16e_t __int16
+# define lzo_uint16e_t unsigned __int16
+#else
+#endif
+#endif
+#if defined(lzo_int16e_t)
+# define LZO_SIZEOF_LZO_INT16E_T 2
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T)
+#endif
+#if !defined(lzo_int32e_t)
+#if (LZO_SIZEOF_LONG == 4)
+# define lzo_int32e_t long int
+# define lzo_uint32e_t unsigned long int
+#elif (LZO_SIZEOF_INT == 4)
+# define lzo_int32e_t int
+# define lzo_uint32e_t unsigned int
+#elif (LZO_SIZEOF_SHORT == 4)
+# define lzo_int32e_t short int
+# define lzo_uint32e_t unsigned short int
+#elif (LZO_SIZEOF_LONG_LONG == 4)
+# define lzo_int32e_t lzo_llong_t
+# define lzo_uint32e_t lzo_ullong_t
+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L)
+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__)));
+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
+# define lzo_int32e_t lzo_int32e_si_t__
+# define lzo_uint32e_t lzo_uint32e_si_t__
+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L)
+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__)));
+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
+# define lzo_int32e_t lzo_int32e_si_t__
+# define lzo_uint32e_t lzo_uint32e_si_t__
+# define LZO_INT32_C(c) (c##LL)
+# define LZO_UINT32_C(c) (c##ULL)
+#elif (LZO_SIZEOF___INT32 == 4)
+# define lzo_int32e_t __int32
+# define lzo_uint32e_t unsigned __int32
+#else
+#endif
+#endif
+#if defined(lzo_int32e_t)
+# define LZO_SIZEOF_LZO_INT32E_T 4
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T)
+#endif
+#if !defined(lzo_int64e_t)
+#if (LZO_SIZEOF___INT64 == 8)
+# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64)
+# define LZO_CFG_TYPE_PREFER___INT64 1
+# endif
+#endif
+#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
+# define lzo_int64e_t int
+# define lzo_uint64e_t unsigned int
+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT
+#elif (LZO_SIZEOF_LONG == 8)
+# define lzo_int64e_t long int
+# define lzo_uint64e_t unsigned long int
+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG
+#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64)
+# define lzo_int64e_t lzo_llong_t
+# define lzo_uint64e_t lzo_ullong_t
+# if (LZO_CC_BORLANDC)
+# define LZO_INT64_C(c) ((c) + 0ll)
+# define LZO_UINT64_C(c) ((c) + 0ull)
+# elif 0
+# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL))
+# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL))
+# else
+# define LZO_INT64_C(c) (c##LL)
+# define LZO_UINT64_C(c) (c##ULL)
+# endif
+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG
+#elif (LZO_SIZEOF___INT64 == 8)
+# define lzo_int64e_t __int64
+# define lzo_uint64e_t unsigned __int64
+# if (LZO_CC_BORLANDC)
+# define LZO_INT64_C(c) ((c) + 0i64)
+# define LZO_UINT64_C(c) ((c) + 0ui64)
+# else
+# define LZO_INT64_C(c) (c##i64)
+# define LZO_UINT64_C(c) (c##ui64)
+# endif
+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64
+#else
+#endif
+#endif
+#if defined(lzo_int64e_t)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T)
+#endif
+#if !defined(lzo_int32l_t)
+#if defined(lzo_int32e_t)
+# define lzo_int32l_t lzo_int32e_t
+# define lzo_uint32l_t lzo_uint32e_t
+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T
+#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
+# define lzo_int32l_t int
+# define lzo_uint32l_t unsigned int
+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT
+#elif (LZO_SIZEOF_LONG >= 4)
+# define lzo_int32l_t long int
+# define lzo_uint32l_t unsigned long int
+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG
+#else
+# error "lzo_int32l_t"
+#endif
+#endif
+#if 1
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T)
+#endif
+#if !defined(lzo_int64l_t)
+#if defined(lzo_int64e_t)
+# define lzo_int64l_t lzo_int64e_t
+# define lzo_uint64l_t lzo_uint64e_t
+# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T
+#else
+#endif
+#endif
+#if defined(lzo_int64l_t)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T)
+#endif
+#if !defined(lzo_int32f_t)
+#if (LZO_SIZEOF_SIZE_T >= 8)
+# define lzo_int32f_t lzo_int64l_t
+# define lzo_uint32f_t lzo_uint64l_t
+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T
+#else
+# define lzo_int32f_t lzo_int32l_t
+# define lzo_uint32f_t lzo_uint32l_t
+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T
+#endif
+#endif
+#if 1
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T)
+#endif
+#if !defined(lzo_int64f_t)
+#if defined(lzo_int64l_t)
+# define lzo_int64f_t lzo_int64l_t
+# define lzo_uint64f_t lzo_uint64l_t
+# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T
+#else
+#endif
+#endif
+#if defined(lzo_int64f_t)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T)
+#endif
+#if !defined(lzo_intptr_t)
+#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16))
+# define __LZO_INTPTR_T_IS_POINTER 1
+ typedef char* lzo_intptr_t;
+ typedef char* lzo_uintptr_t;
+# define lzo_intptr_t lzo_intptr_t
+# define lzo_uintptr_t lzo_uintptr_t
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P
+#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4))
+ typedef __w64 int lzo_intptr_t;
+ typedef __w64 unsigned int lzo_uintptr_t;
+# define lzo_intptr_t lzo_intptr_t
+# define lzo_uintptr_t lzo_uintptr_t
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT
+#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P)
+# define lzo_intptr_t short
+# define lzo_uintptr_t unsigned short
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT
+#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
+# define lzo_intptr_t int
+# define lzo_uintptr_t unsigned int
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT
+#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P)
+# define lzo_intptr_t long
+# define lzo_uintptr_t unsigned long
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG
+#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P)
+# define lzo_intptr_t lzo_int64l_t
+# define lzo_uintptr_t lzo_uint64l_t
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T
+#else
+# error "lzo_intptr_t"
+#endif
+#endif
+#if 1
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *))
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t))
+#endif
+#if !defined(lzo_word_t)
+#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0)
+#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER)
+# define lzo_word_t lzo_uintptr_t
+# define lzo_sword_t lzo_intptr_t
+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T
+#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG)
+# define lzo_word_t unsigned long
+# define lzo_sword_t long
+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG
+#elif (LZO_WORDSIZE == LZO_SIZEOF_INT)
+# define lzo_word_t unsigned int
+# define lzo_sword_t int
+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT
+#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT)
+# define lzo_word_t unsigned short
+# define lzo_sword_t short
+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT
+#elif (LZO_WORDSIZE == 1)
+# define lzo_word_t unsigned char
+# define lzo_sword_t signed char
+# define LZO_SIZEOF_LZO_WORD_T 1
+#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T)
+# define lzo_word_t lzo_uint64l_t
+# define lzo_sword_t lzo_int64l_t
+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T
+#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC)
+#if 0
+ typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__)));
+ typedef int lzo_sword_t __attribute__((__mode__(__V16QI__)));
+# define lzo_word_t lzo_word_t
+# define lzo_sword_t lzo_sword_t
+# define LZO_SIZEOF_LZO_WORD_T 16
+#endif
+#else
+# error "lzo_word_t"
+#endif
+#endif
+#endif
+#if 1 && defined(lzo_word_t)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE)
+#endif
+#if 1
+#define lzo_int8_t signed char
+#define lzo_uint8_t unsigned char
+#define LZO_SIZEOF_LZO_INT8_T 1
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t))
+#endif
+#if defined(lzo_int16e_t)
+#define lzo_int16_t lzo_int16e_t
+#define lzo_uint16_t lzo_uint16e_t
+#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t))
+#endif
+#if defined(lzo_int32e_t)
+#define lzo_int32_t lzo_int32e_t
+#define lzo_uint32_t lzo_uint32e_t
+#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t))
+#endif
+#if defined(lzo_int64e_t)
+#define lzo_int64_t lzo_int64e_t
+#define lzo_uint64_t lzo_uint64e_t
+#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t))
+#endif
+#if 1
+#define lzo_int_least32_t lzo_int32l_t
+#define lzo_uint_least32_t lzo_uint32l_t
+#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t))
+#endif
+#if defined(lzo_int64l_t)
+#define lzo_int_least64_t lzo_int64l_t
+#define lzo_uint_least64_t lzo_uint64l_t
+#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t))
+#endif
+#if 1
+#define lzo_int_fast32_t lzo_int32f_t
+#define lzo_uint_fast32_t lzo_uint32f_t
+#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t))
+#endif
+#if defined(lzo_int64f_t)
+#define lzo_int_fast64_t lzo_int64f_t
+#define lzo_uint_fast64_t lzo_uint64f_t
+#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t))
+#endif
+#if !defined(LZO_INT16_C)
+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2)
+# define LZO_INT16_C(c) ((c) + 0)
+# define LZO_UINT16_C(c) ((c) + 0U)
+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2)
+# define LZO_INT16_C(c) ((c) + 0L)
+# define LZO_UINT16_C(c) ((c) + 0UL)
+# elif (LZO_SIZEOF_INT >= 2)
+# define LZO_INT16_C(c) (c)
+# define LZO_UINT16_C(c) (c##U)
+# elif (LZO_SIZEOF_LONG >= 2)
+# define LZO_INT16_C(c) (c##L)
+# define LZO_UINT16_C(c) (c##UL)
+# else
+# error "LZO_INT16_C"
+# endif
+#endif
+#if !defined(LZO_INT32_C)
+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4)
+# define LZO_INT32_C(c) ((c) + 0)
+# define LZO_UINT32_C(c) ((c) + 0U)
+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4)
+# define LZO_INT32_C(c) ((c) + 0L)
+# define LZO_UINT32_C(c) ((c) + 0UL)
+# elif (LZO_SIZEOF_INT >= 4)
+# define LZO_INT32_C(c) (c)
+# define LZO_UINT32_C(c) (c##U)
+# elif (LZO_SIZEOF_LONG >= 4)
+# define LZO_INT32_C(c) (c##L)
+# define LZO_UINT32_C(c) (c##UL)
+# elif (LZO_SIZEOF_LONG_LONG >= 4)
+# define LZO_INT32_C(c) (c##LL)
+# define LZO_UINT32_C(c) (c##ULL)
+# else
+# error "LZO_INT32_C"
+# endif
+#endif
+#if !defined(LZO_INT64_C) && defined(lzo_int64l_t)
+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8)
+# define LZO_INT64_C(c) ((c) + 0)
+# define LZO_UINT64_C(c) ((c) + 0U)
+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8)
+# define LZO_INT64_C(c) ((c) + 0L)
+# define LZO_UINT64_C(c) ((c) + 0UL)
+# elif (LZO_SIZEOF_INT >= 8)
+# define LZO_INT64_C(c) (c)
+# define LZO_UINT64_C(c) (c##U)
+# elif (LZO_SIZEOF_LONG >= 8)
+# define LZO_INT64_C(c) (c##L)
+# define LZO_UINT64_C(c) (c##UL)
+# else
+# error "LZO_INT64_C"
+# endif
+#endif
+#endif
+
+#endif /* already included */
+
+/* vim:set ts=4 sw=4 et: */
diff --git a/grub-core/lib/minilzo/minilzo.c b/grub-core/lib/minilzo/minilzo.c
new file mode 100644
index 0000000..ab2be5f
--- /dev/null
+++ b/grub-core/lib/minilzo/minilzo.c
@@ -0,0 +1,6053 @@
+/* minilzo.c -- mini subset of the LZO real-time data compression library
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
+ All Rights Reserved.
+
+ The LZO library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ The LZO library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the LZO library; see the file COPYING.
+ If not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Markus F.X.J. Oberhumer
+ <markus@oberhumer.com>
+ http://www.oberhumer.com/opensource/lzo/
+ */
+
+/*
+ * NOTE:
+ * the full LZO package can be found at
+ * http://www.oberhumer.com/opensource/lzo/
+ */
+
+#define __LZO_IN_MINILZO 1
+
+#if defined(LZO_CFG_FREESTANDING)
+# undef MINILZO_HAVE_CONFIG_H
+# define LZO_LIBC_FREESTANDING 1
+# define LZO_OS_FREESTANDING 1
+#endif
+
+#ifdef MINILZO_HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <limits.h>
+#include <stddef.h>
+#if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS)
+
+#ifndef __LZODEFS_H_INCLUDED
+#define __LZODEFS_H_INCLUDED 1
+
+#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
+# define __CYGWIN__ __CYGWIN32__
+#endif
+#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
+# define _ALL_SOURCE 1
+#endif
+#if defined(__mips__) && defined(__R5900__)
+# if !defined(__LONG_MAX__)
+# define __LONG_MAX__ 9223372036854775807L
+# endif
+#endif
+#if !defined(LZO_CFG_NO_DISABLE_WUNDEF)
+#if defined(__ARMCC_VERSION)
+# pragma diag_suppress 193
+#elif defined(__clang__) && defined(__clang_minor__)
+# pragma clang diagnostic ignored "-Wundef"
+#elif defined(__INTEL_COMPILER)
+# pragma warning(disable: 193)
+#elif defined(__KEIL__) && defined(__C166__)
+# pragma warning disable = 322
+#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__)
+# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2))
+# pragma GCC diagnostic ignored "-Wundef"
+# endif
+#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
+# if ((_MSC_VER-0) >= 1300)
+# pragma warning(disable: 4668)
+# endif
+#endif
+#endif
+#if 0 && defined(__POCC__) && defined(_WIN32)
+# if (__POCC__ >= 400)
+# pragma warn(disable: 2216)
+# endif
+#endif
+#if 0 && defined(__WATCOMC__)
+# if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060)
+# pragma warning 203 9
+# endif
+#endif
+#if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__)
+# pragma option -h
+#endif
+#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC)
+#ifndef _CRT_NONSTDC_NO_DEPRECATE
+#define _CRT_NONSTDC_NO_DEPRECATE 1
+#endif
+#ifndef _CRT_NONSTDC_NO_WARNINGS
+#define _CRT_NONSTDC_NO_WARNINGS 1
+#endif
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+#ifndef _CRT_SECURE_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS 1
+#endif
+#endif
+#if 0
+#define LZO_0xffffUL 0xfffful
+#define LZO_0xffffffffUL 0xfffffffful
+#else
+#define LZO_0xffffUL 65535ul
+#define LZO_0xffffffffUL 4294967295ul
+#endif
+#define LZO_0xffffL LZO_0xffffUL
+#define LZO_0xffffffffL LZO_0xffffffffUL
+#if (LZO_0xffffL == LZO_0xffffffffL)
+# error "your preprocessor is broken 1"
+#endif
+#if (16ul * 16384ul != 262144ul)
+# error "your preprocessor is broken 2"
+#endif
+#if 0
+#if (32767 >= 4294967295ul)
+# error "your preprocessor is broken 3"
+#endif
+#if (65535u >= 4294967295ul)
+# error "your preprocessor is broken 4"
+#endif
+#endif
+#if defined(__COUNTER__)
+# ifndef LZO_CFG_USE_COUNTER
+# define LZO_CFG_USE_COUNTER 1
+# endif
+#else
+# undef LZO_CFG_USE_COUNTER
+#endif
+#if (UINT_MAX == LZO_0xffffL)
+#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
+# if !defined(MSDOS)
+# define MSDOS 1
+# endif
+# if !defined(_MSDOS)
+# define _MSDOS 1
+# endif
+#elif 0 && defined(__VERSION) && defined(MB_LEN_MAX)
+# if (__VERSION == 520) && (MB_LEN_MAX == 1)
+# if !defined(__AZTEC_C__)
+# define __AZTEC_C__ __VERSION
+# endif
+# if !defined(__DOS__)
+# define __DOS__ 1
+# endif
+# endif
+#endif
+#endif
+#if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL)
+# define ptrdiff_t long
+# define _PTRDIFF_T_DEFINED 1
+#endif
+#if (UINT_MAX == LZO_0xffffL)
+# undef __LZO_RENAME_A
+# undef __LZO_RENAME_B
+# if defined(__AZTEC_C__) && defined(__DOS__)
+# define __LZO_RENAME_A 1
+# elif defined(_MSC_VER) && defined(MSDOS)
+# if (_MSC_VER < 600)
+# define __LZO_RENAME_A 1
+# elif (_MSC_VER < 700)
+# define __LZO_RENAME_B 1
+# endif
+# elif defined(__TSC__) && defined(__OS2__)
+# define __LZO_RENAME_A 1
+# elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410)
+# define __LZO_RENAME_A 1
+# elif defined(__PACIFIC__) && defined(DOS)
+# if !defined(__far)
+# define __far far
+# endif
+# if !defined(__near)
+# define __near near
+# endif
+# endif
+# if defined(__LZO_RENAME_A)
+# if !defined(__cdecl)
+# define __cdecl cdecl
+# endif
+# if !defined(__far)
+# define __far far
+# endif
+# if !defined(__huge)
+# define __huge huge
+# endif
+# if !defined(__near)
+# define __near near
+# endif
+# if !defined(__pascal)
+# define __pascal pascal
+# endif
+# if !defined(__huge)
+# define __huge huge
+# endif
+# elif defined(__LZO_RENAME_B)
+# if !defined(__cdecl)
+# define __cdecl _cdecl
+# endif
+# if !defined(__far)
+# define __far _far
+# endif
+# if !defined(__huge)
+# define __huge _huge
+# endif
+# if !defined(__near)
+# define __near _near
+# endif
+# if !defined(__pascal)
+# define __pascal _pascal
+# endif
+# elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
+# if !defined(__cdecl)
+# define __cdecl cdecl
+# endif
+# if !defined(__pascal)
+# define __pascal pascal
+# endif
+# endif
+# undef __LZO_RENAME_A
+# undef __LZO_RENAME_B
+#endif
+#if (UINT_MAX == LZO_0xffffL)
+#if defined(__AZTEC_C__) && defined(__DOS__)
+# define LZO_BROKEN_CDECL_ALT_SYNTAX 1
+#elif defined(_MSC_VER) && defined(MSDOS)
+# if (_MSC_VER < 600)
+# define LZO_BROKEN_INTEGRAL_CONSTANTS 1
+# endif
+# if (_MSC_VER < 700)
+# define LZO_BROKEN_INTEGRAL_PROMOTION 1
+# define LZO_BROKEN_SIZEOF 1
+# endif
+#elif defined(__PACIFIC__) && defined(DOS)
+# define LZO_BROKEN_INTEGRAL_CONSTANTS 1
+#elif defined(__TURBOC__) && defined(__MSDOS__)
+# if (__TURBOC__ < 0x0150)
+# define LZO_BROKEN_CDECL_ALT_SYNTAX 1
+# define LZO_BROKEN_INTEGRAL_CONSTANTS 1
+# define LZO_BROKEN_INTEGRAL_PROMOTION 1
+# endif
+# if (__TURBOC__ < 0x0200)
+# define LZO_BROKEN_SIZEOF 1
+# endif
+# if (__TURBOC__ < 0x0400) && defined(__cplusplus)
+# define LZO_BROKEN_CDECL_ALT_SYNTAX 1
+# endif
+#elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
+# define LZO_BROKEN_CDECL_ALT_SYNTAX 1
+# define LZO_BROKEN_SIZEOF 1
+#endif
+#endif
+#if defined(__WATCOMC__) && (__WATCOMC__ < 900)
+# define LZO_BROKEN_INTEGRAL_CONSTANTS 1
+#endif
+#if defined(_CRAY) && defined(_CRAY1)
+# define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1
+#endif
+#define LZO_PP_STRINGIZE(x) #x
+#define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x)
+#define LZO_PP_CONCAT0() /*empty*/
+#define LZO_PP_CONCAT1(a) a
+#define LZO_PP_CONCAT2(a,b) a ## b
+#define LZO_PP_CONCAT3(a,b,c) a ## b ## c
+#define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d
+#define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
+#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f
+#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g
+#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0()
+#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a)
+#define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b)
+#define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c)
+#define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d)
+#define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e)
+#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f)
+#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g)
+#define LZO_PP_EMPTY /*empty*/
+#define LZO_PP_EMPTY0() /*empty*/
+#define LZO_PP_EMPTY1(a) /*empty*/
+#define LZO_PP_EMPTY2(a,b) /*empty*/
+#define LZO_PP_EMPTY3(a,b,c) /*empty*/
+#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/
+#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/
+#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/
+#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/
+#if 1
+#define LZO_CPP_STRINGIZE(x) #x
+#define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x)
+#define LZO_CPP_CONCAT2(a,b) a ## b
+#define LZO_CPP_CONCAT3(a,b,c) a ## b ## c
+#define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d
+#define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
+#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f
+#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g
+#define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b)
+#define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c)
+#define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d)
+#define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e)
+#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f)
+#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g)
+#endif
+#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b))
+#if 1 && defined(__cplusplus)
+# if !defined(__STDC_CONSTANT_MACROS)
+# define __STDC_CONSTANT_MACROS 1
+# endif
+# if !defined(__STDC_LIMIT_MACROS)
+# define __STDC_LIMIT_MACROS 1
+# endif
+#endif
+#if defined(__cplusplus)
+# define LZO_EXTERN_C extern "C"
+# define LZO_EXTERN_C_BEGIN extern "C" {
+# define LZO_EXTERN_C_END }
+#else
+# define LZO_EXTERN_C extern
+# define LZO_EXTERN_C_BEGIN /*empty*/
+# define LZO_EXTERN_C_END /*empty*/
+#endif
+#if !defined(__LZO_OS_OVERRIDE)
+#if (LZO_OS_FREESTANDING)
+# define LZO_INFO_OS "freestanding"
+#elif (LZO_OS_EMBEDDED)
+# define LZO_INFO_OS "embedded"
+#elif 1 && defined(__IAR_SYSTEMS_ICC__)
+# define LZO_OS_EMBEDDED 1
+# define LZO_INFO_OS "embedded"
+#elif defined(__CYGWIN__) && defined(__GNUC__)
+# define LZO_OS_CYGWIN 1
+# define LZO_INFO_OS "cygwin"
+#elif defined(__EMX__) && defined(__GNUC__)
+# define LZO_OS_EMX 1
+# define LZO_INFO_OS "emx"
+#elif defined(__BEOS__)
+# define LZO_OS_BEOS 1
+# define LZO_INFO_OS "beos"
+#elif defined(__Lynx__)
+# define LZO_OS_LYNXOS 1
+# define LZO_INFO_OS "lynxos"
+#elif defined(__OS400__)
+# define LZO_OS_OS400 1
+# define LZO_INFO_OS "os400"
+#elif defined(__QNX__)
+# define LZO_OS_QNX 1
+# define LZO_INFO_OS "qnx"
+#elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460)
+# define LZO_OS_DOS32 1
+# define LZO_INFO_OS "dos32"
+#elif defined(__BORLANDC__) && defined(__DPMI16__)
+# define LZO_OS_DOS16 1
+# define LZO_INFO_OS "dos16"
+#elif defined(__ZTC__) && defined(DOS386)
+# define LZO_OS_DOS32 1
+# define LZO_INFO_OS "dos32"
+#elif defined(__OS2__) || defined(__OS2V2__)
+# if (UINT_MAX == LZO_0xffffL)
+# define LZO_OS_OS216 1
+# define LZO_INFO_OS "os216"
+# elif (UINT_MAX == LZO_0xffffffffL)
+# define LZO_OS_OS2 1
+# define LZO_INFO_OS "os2"
+# else
+# error "check your limits.h header"
+# endif
+#elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64)
+# define LZO_OS_WIN64 1
+# define LZO_INFO_OS "win64"
+#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__)
+# define LZO_OS_WIN32 1
+# define LZO_INFO_OS "win32"
+#elif defined(__MWERKS__) && defined(__INTEL__)
+# define LZO_OS_WIN32 1
+# define LZO_INFO_OS "win32"
+#elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
+# if (UINT_MAX == LZO_0xffffL)
+# define LZO_OS_WIN16 1
+# define LZO_INFO_OS "win16"
+# elif (UINT_MAX == LZO_0xffffffffL)
+# define LZO_OS_WIN32 1
+# define LZO_INFO_OS "win32"
+# else
+# error "check your limits.h header"
+# endif
+#elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS))
+# if (UINT_MAX == LZO_0xffffL)
+# define LZO_OS_DOS16 1
+# define LZO_INFO_OS "dos16"
+# elif (UINT_MAX == LZO_0xffffffffL)
+# define LZO_OS_DOS32 1
+# define LZO_INFO_OS "dos32"
+# else
+# error "check your limits.h header"
+# endif
+#elif defined(__WATCOMC__)
+# if defined(__NT__) && (UINT_MAX == LZO_0xffffL)
+# define LZO_OS_DOS16 1
+# define LZO_INFO_OS "dos16"
+# elif defined(__NT__) && (__WATCOMC__ < 1100)
+# define LZO_OS_WIN32 1
+# define LZO_INFO_OS "win32"
+# elif defined(__linux__) || defined(__LINUX__)
+# define LZO_OS_POSIX 1
+# define LZO_INFO_OS "posix"
+# else
+# error "please specify a target using the -bt compiler option"
+# endif
+#elif defined(__palmos__)
+# define LZO_OS_PALMOS 1
+# define LZO_INFO_OS "palmos"
+#elif defined(__TOS__) || defined(__atarist__)
+# define LZO_OS_TOS 1
+# define LZO_INFO_OS "tos"
+#elif defined(macintosh) && !defined(__ppc__)
+# define LZO_OS_MACCLASSIC 1
+# define LZO_INFO_OS "macclassic"
+#elif defined(__VMS)
+# define LZO_OS_VMS 1
+# define LZO_INFO_OS "vms"
+#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)
+# define LZO_OS_CONSOLE 1
+# define LZO_OS_CONSOLE_PS2 1
+# define LZO_INFO_OS "console"
+# define LZO_INFO_OS_CONSOLE "ps2"
+#elif defined(__mips__) && defined(__psp__)
+# define LZO_OS_CONSOLE 1
+# define LZO_OS_CONSOLE_PSP 1
+# define LZO_INFO_OS "console"
+# define LZO_INFO_OS_CONSOLE "psp"
+#else
+# define LZO_OS_POSIX 1
+# define LZO_INFO_OS "posix"
+#endif
+#if (LZO_OS_POSIX)
+# if defined(_AIX) || defined(__AIX__) || defined(__aix__)
+# define LZO_OS_POSIX_AIX 1
+# define LZO_INFO_OS_POSIX "aix"
+# elif defined(__FreeBSD__)
+# define LZO_OS_POSIX_FREEBSD 1
+# define LZO_INFO_OS_POSIX "freebsd"
+# elif defined(__hpux__) || defined(__hpux)
+# define LZO_OS_POSIX_HPUX 1
+# define LZO_INFO_OS_POSIX "hpux"
+# elif defined(__INTERIX)
+# define LZO_OS_POSIX_INTERIX 1
+# define LZO_INFO_OS_POSIX "interix"
+# elif defined(__IRIX__) || defined(__irix__)
+# define LZO_OS_POSIX_IRIX 1
+# define LZO_INFO_OS_POSIX "irix"
+# elif defined(__linux__) || defined(__linux) || defined(__LINUX__)
+# define LZO_OS_POSIX_LINUX 1
+# define LZO_INFO_OS_POSIX "linux"
+# elif defined(__APPLE__) && defined(__MACH__)
+# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000)
+# define LZO_OS_POSIX_DARWIN 1040
+# define LZO_INFO_OS_POSIX "darwin_iphone"
+# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040)
+# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
+# define LZO_INFO_OS_POSIX "darwin"
+# else
+# define LZO_OS_POSIX_DARWIN 1
+# define LZO_INFO_OS_POSIX "darwin"
+# endif
+# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN
+# elif defined(__minix__) || defined(__minix)
+# define LZO_OS_POSIX_MINIX 1
+# define LZO_INFO_OS_POSIX "minix"
+# elif defined(__NetBSD__)
+# define LZO_OS_POSIX_NETBSD 1
+# define LZO_INFO_OS_POSIX "netbsd"
+# elif defined(__OpenBSD__)
+# define LZO_OS_POSIX_OPENBSD 1
+# define LZO_INFO_OS_POSIX "openbsd"
+# elif defined(__osf__)
+# define LZO_OS_POSIX_OSF 1
+# define LZO_INFO_OS_POSIX "osf"
+# elif defined(__solaris__) || defined(__sun)
+# if defined(__SVR4) || defined(__svr4__)
+# define LZO_OS_POSIX_SOLARIS 1
+# define LZO_INFO_OS_POSIX "solaris"
+# else
+# define LZO_OS_POSIX_SUNOS 1
+# define LZO_INFO_OS_POSIX "sunos"
+# endif
+# elif defined(__ultrix__) || defined(__ultrix)
+# define LZO_OS_POSIX_ULTRIX 1
+# define LZO_INFO_OS_POSIX "ultrix"
+# elif defined(_UNICOS)
+# define LZO_OS_POSIX_UNICOS 1
+# define LZO_INFO_OS_POSIX "unicos"
+# else
+# define LZO_OS_POSIX_UNKNOWN 1
+# define LZO_INFO_OS_POSIX "unknown"
+# endif
+#endif
+#endif
+#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
+# if (UINT_MAX != LZO_0xffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+# if (ULONG_MAX != LZO_0xffffffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+#endif
+#if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64)
+# if (UINT_MAX != LZO_0xffffffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+# if (ULONG_MAX != LZO_0xffffffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+#endif
+#if defined(CIL) && defined(_GNUCC) && defined(__GNUC__)
+# define LZO_CC_CILLY 1
+# define LZO_INFO_CC "Cilly"
+# if defined(__CILLY__)
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__)
+# else
+# define LZO_INFO_CCVER "unknown"
+# endif
+#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__)
+# define LZO_CC_SDCC 1
+# define LZO_INFO_CC "sdcc"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC)
+#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
+# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0))
+# define LZO_INFO_CC "Pathscale C"
+# define LZO_INFO_CCVER __PATHSCALE__
+# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# endif
+#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0)
+# define LZO_CC_INTELC __INTEL_COMPILER
+# define LZO_INFO_CC "Intel C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER)
+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0)
+# define LZO_CC_INTELC_MSC _MSC_VER
+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# endif
+#elif defined(__POCC__) && defined(_WIN32)
+# define LZO_CC_PELLESC 1
+# define LZO_INFO_CC "Pelles C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__)
+#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# if defined(__GNUC_PATCHLEVEL__)
+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# else
+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100)
+# endif
+# define LZO_CC_ARMCC __ARMCC_VERSION
+# define LZO_INFO_CC "ARM C Compiler"
+# define LZO_INFO_CCVER __VERSION__
+#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__)
+# if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
+# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0))
+# else
+# define LZO_CC_CLANG 0x010000L
+# endif
+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0)
+# define LZO_CC_CLANG_MSC _MSC_VER
+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# endif
+# define LZO_INFO_CC "clang"
+# define LZO_INFO_CCVER __VERSION__
+#elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# if defined(__GNUC_PATCHLEVEL__)
+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# else
+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100)
+# endif
+# define LZO_CC_LLVM LZO_CC_LLVM_GNUC
+# define LZO_INFO_CC "llvm-gcc"
+# define LZO_INFO_CCVER __VERSION__
+#elif defined(__ACK__) && defined(_ACK)
+# define LZO_CC_ACK 1
+# define LZO_INFO_CC "Amsterdam Compiler Kit C"
+# define LZO_INFO_CCVER "unknown"
+#elif defined(__ARMCC_VERSION) && !defined(__GNUC__)
+# define LZO_CC_ARMCC __ARMCC_VERSION
+# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION
+# define LZO_INFO_CC "ARM C Compiler"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION)
+#elif defined(__AZTEC_C__)
+# define LZO_CC_AZTECC 1
+# define LZO_INFO_CC "Aztec C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__)
+#elif defined(__CODEGEARC__)
+# define LZO_CC_CODEGEARC 1
+# define LZO_INFO_CC "CodeGear C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__)
+#elif defined(__BORLANDC__)
+# define LZO_CC_BORLANDC 1
+# define LZO_INFO_CC "Borland C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__)
+#elif defined(_CRAYC) && defined(_RELEASE)
+# define LZO_CC_CRAYC 1
+# define LZO_INFO_CC "Cray C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE)
+#elif defined(__DMC__) && defined(__SC__)
+# define LZO_CC_DMC 1
+# define LZO_INFO_CC "Digital Mars C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__)
+#elif defined(__DECC)
+# define LZO_CC_DECC 1
+# define LZO_INFO_CC "DEC C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC)
+#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0)
+# define LZO_CC_GHS 1
+# define LZO_INFO_CC "Green Hills C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER)
+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0)
+# define LZO_CC_GHS_MSC _MSC_VER
+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
+# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# endif
+#elif defined(__HIGHC__)
+# define LZO_CC_HIGHC 1
+# define LZO_INFO_CC "MetaWare High C"
+# define LZO_INFO_CCVER "unknown"
+#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0)
+# define LZO_CC_HPACC __HP_aCC
+# define LZO_INFO_CC "HP aCC"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC)
+#elif defined(__IAR_SYSTEMS_ICC__)
+# define LZO_CC_IARC 1
+# define LZO_INFO_CC "IAR C"
+# if defined(__VER__)
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__)
+# else
+# define LZO_INFO_CCVER "unknown"
+# endif
+#elif defined(__IBMC__) && ((__IBMC__-0) > 0)
+# define LZO_CC_IBMC __IBMC__
+# define LZO_INFO_CC "IBM C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__)
+#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0)
+# define LZO_CC_IBMC __IBMCPP__
+# define LZO_INFO_CC "IBM C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__)
+#elif defined(__KEIL__) && defined(__C166__)
+# define LZO_CC_KEILC 1
+# define LZO_INFO_CC "Keil C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__)
+#elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL)
+# define LZO_CC_LCCWIN32 1
+# define LZO_INFO_CC "lcc-win32"
+# define LZO_INFO_CCVER "unknown"
+#elif defined(__LCC__)
+# define LZO_CC_LCC 1
+# define LZO_INFO_CC "lcc"
+# if defined(__LCC_VERSION__)
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__)
+# else
+# define LZO_INFO_CCVER "unknown"
+# endif
+#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0)
+# define LZO_CC_MWERKS __MWERKS__
+# define LZO_INFO_CC "Metrowerks C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__)
+#elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386)
+# define LZO_CC_NDPC 1
+# define LZO_INFO_CC "Microway NDP C"
+# define LZO_INFO_CCVER "unknown"
+#elif defined(__PACIFIC__)
+# define LZO_CC_PACIFICC 1
+# define LZO_INFO_CC "Pacific C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__)
+#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__)
+# if defined(__PGIC_PATCHLEVEL__)
+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0))
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__)
+# else
+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100)
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0"
+# endif
+# define LZO_INFO_CC "Portland Group PGI C"
+#elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__))
+# define LZO_CC_PGI 1
+# define LZO_INFO_CC "Portland Group PGI C"
+# define LZO_INFO_CCVER "unknown"
+#elif defined(__PUREC__) && defined(__TOS__)
+# define LZO_CC_PUREC 1
+# define LZO_INFO_CC "Pure C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__)
+#elif defined(__SC__) && defined(__ZTC__)
+# define LZO_CC_SYMANTECC 1
+# define LZO_INFO_CC "Symantec C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__)
+#elif defined(__SUNPRO_C)
+# define LZO_INFO_CC "SunPro C"
+# if ((__SUNPRO_C-0) > 0)
+# define LZO_CC_SUNPROC __SUNPRO_C
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C)
+# else
+# define LZO_CC_SUNPROC 1
+# define LZO_INFO_CCVER "unknown"
+# endif
+#elif defined(__SUNPRO_CC)
+# define LZO_INFO_CC "SunPro C"
+# if ((__SUNPRO_CC-0) > 0)
+# define LZO_CC_SUNPROC __SUNPRO_CC
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC)
+# else
+# define LZO_CC_SUNPROC 1
+# define LZO_INFO_CCVER "unknown"
+# endif
+#elif defined(__TINYC__)
+# define LZO_CC_TINYC 1
+# define LZO_INFO_CC "Tiny C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__)
+#elif defined(__TSC__)
+# define LZO_CC_TOPSPEEDC 1
+# define LZO_INFO_CC "TopSpeed C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__)
+#elif defined(__WATCOMC__)
+# define LZO_CC_WATCOMC 1
+# define LZO_INFO_CC "Watcom C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__)
+#elif defined(__TURBOC__)
+# define LZO_CC_TURBOC 1
+# define LZO_INFO_CC "Turbo C"
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__)
+#elif defined(__ZTC__)
+# define LZO_CC_ZORTECHC 1
+# define LZO_INFO_CC "Zortech C"
+# if ((__ZTC__-0) == 0x310)
+# define LZO_INFO_CCVER "0x310"
+# else
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__)
+# endif
+#elif defined(__GNUC__) && defined(__VERSION__)
+# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
+# elif defined(__GNUC_MINOR__)
+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100)
+# else
+# define LZO_CC_GNUC (__GNUC__ * 0x10000L)
+# endif
+# define LZO_INFO_CC "gcc"
+# define LZO_INFO_CCVER __VERSION__
+#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0)
+# define LZO_CC_MSC _MSC_VER
+# define LZO_INFO_CC "Microsoft C"
+# if defined(_MSC_FULL_VER)
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER)
+# else
+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER)
+# endif
+#else
+# define LZO_CC_UNKNOWN 1
+# define LZO_INFO_CC "unknown"
+# define LZO_INFO_CCVER "unknown"
+#endif
+#if (LZO_CC_GNUC) && defined(__OPEN64__)
+# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__)
+# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0))
+# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC
+# endif
+#endif
+#if (LZO_CC_GNUC) && defined(__PCC__)
+# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__)
+# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0))
+# define LZO_CC_PCC_GNUC LZO_CC_GNUC
+# endif
+#endif
+#if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
+# error "LZO_CC_MSC: _MSC_FULL_VER is not defined"
+#endif
+#if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY)
+# if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY)
+# if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E)
+# define LZO_ARCH_CRAY_MPP 1
+# elif defined(_CRAY1)
+# define LZO_ARCH_CRAY_PVP 1
+# endif
+# endif
+#endif
+#if !defined(__LZO_ARCH_OVERRIDE)
+#if (LZO_ARCH_GENERIC)
+# define LZO_INFO_ARCH "generic"
+#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
+# define LZO_ARCH_I086 1
+# define LZO_INFO_ARCH "i086"
+#elif defined(__aarch64__)
+# define LZO_ARCH_ARM64 1
+# define LZO_INFO_ARCH "arm64"
+#elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
+# define LZO_ARCH_ALPHA 1
+# define LZO_INFO_ARCH "alpha"
+#elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E))
+# define LZO_ARCH_ALPHA 1
+# define LZO_INFO_ARCH "alpha"
+#elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
+# define LZO_ARCH_AMD64 1
+# define LZO_INFO_ARCH "amd64"
+#elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB))
+# define LZO_ARCH_ARM 1
+# define LZO_ARCH_ARM_THUMB 1
+# define LZO_INFO_ARCH "arm_thumb"
+#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__)
+# define LZO_ARCH_ARM 1
+# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1)
+# define LZO_ARCH_ARM_THUMB 1
+# define LZO_INFO_ARCH "arm_thumb"
+# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2)
+# define LZO_INFO_ARCH "arm"
+# else
+# define LZO_INFO_ARCH "arm"
+# endif
+#elif defined(__arm__) || defined(_M_ARM)
+# define LZO_ARCH_ARM 1
+# define LZO_INFO_ARCH "arm"
+#elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__)
+# define LZO_ARCH_AVR 1
+# define LZO_INFO_ARCH "avr"
+#elif defined(__avr32__) || defined(__AVR32__)
+# define LZO_ARCH_AVR32 1
+# define LZO_INFO_ARCH "avr32"
+#elif defined(__bfin__)
+# define LZO_ARCH_BLACKFIN 1
+# define LZO_INFO_ARCH "blackfin"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__C166__)
+# define LZO_ARCH_C166 1
+# define LZO_INFO_ARCH "c166"
+#elif defined(__cris__)
+# define LZO_ARCH_CRIS 1
+# define LZO_INFO_ARCH "cris"
+#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__)
+# define LZO_ARCH_EZ80 1
+# define LZO_INFO_ARCH "ez80"
+#elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+# define LZO_ARCH_H8300 1
+# define LZO_INFO_ARCH "h8300"
+#elif defined(__hppa__) || defined(__hppa)
+# define LZO_ARCH_HPPA 1
+# define LZO_INFO_ARCH "hppa"
+#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386)
+# define LZO_ARCH_I386 1
+# define LZO_ARCH_IA32 1
+# define LZO_INFO_ARCH "i386"
+#elif (LZO_CC_ZORTECHC && defined(__I86__))
+# define LZO_ARCH_I386 1
+# define LZO_ARCH_IA32 1
+# define LZO_INFO_ARCH "i386"
+#elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386)
+# define LZO_ARCH_I386 1
+# define LZO_ARCH_IA32 1
+# define LZO_INFO_ARCH "i386"
+#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
+# define LZO_ARCH_IA64 1
+# define LZO_INFO_ARCH "ia64"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__)
+# define LZO_ARCH_M16C 1
+# define LZO_INFO_ARCH "m16c"
+#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__)
+# define LZO_ARCH_M16C 1
+# define LZO_INFO_ARCH "m16c"
+#elif defined(__m32r__)
+# define LZO_ARCH_M32R 1
+# define LZO_INFO_ARCH "m32r"
+#elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K)
+# define LZO_ARCH_M68K 1
+# define LZO_INFO_ARCH "m68k"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__C251__)
+# define LZO_ARCH_MCS251 1
+# define LZO_INFO_ARCH "mcs251"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__C51__)
+# define LZO_ARCH_MCS51 1
+# define LZO_INFO_ARCH "mcs51"
+#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__)
+# define LZO_ARCH_MCS51 1
+# define LZO_INFO_ARCH "mcs51"
+#elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000)
+# define LZO_ARCH_MIPS 1
+# define LZO_INFO_ARCH "mips"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__)
+# define LZO_ARCH_MSP430 1
+# define LZO_INFO_ARCH "msp430"
+#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__)
+# define LZO_ARCH_MSP430 1
+# define LZO_INFO_ARCH "msp430"
+#elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR)
+# define LZO_ARCH_POWERPC 1
+# define LZO_INFO_ARCH "powerpc"
+#elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x)
+# define LZO_ARCH_S390 1
+# define LZO_INFO_ARCH "s390"
+#elif defined(__sh__) || defined(_M_SH)
+# define LZO_ARCH_SH 1
+# define LZO_INFO_ARCH "sh"
+#elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8)
+# define LZO_ARCH_SPARC 1
+# define LZO_INFO_ARCH "sparc"
+#elif defined(__SPU__)
+# define LZO_ARCH_SPU 1
+# define LZO_INFO_ARCH "spu"
+#elif (UINT_MAX == LZO_0xffffL) && defined(__z80)
+# define LZO_ARCH_Z80 1
+# define LZO_INFO_ARCH "z80"
+#elif (LZO_ARCH_CRAY_PVP)
+# if defined(_CRAYSV1)
+# define LZO_ARCH_CRAY_SV1 1
+# define LZO_INFO_ARCH "cray_sv1"
+# elif (_ADDR64)
+# define LZO_ARCH_CRAY_T90 1
+# define LZO_INFO_ARCH "cray_t90"
+# elif (_ADDR32)
+# define LZO_ARCH_CRAY_YMP 1
+# define LZO_INFO_ARCH "cray_ymp"
+# else
+# define LZO_ARCH_CRAY_XMP 1
+# define LZO_INFO_ARCH "cray_xmp"
+# endif
+#else
+# define LZO_ARCH_UNKNOWN 1
+# define LZO_INFO_ARCH "unknown"
+#endif
+#endif
+#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2)
+# error "FIXME - missing define for CPU architecture"
+#endif
+#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32)
+# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture"
+#endif
+#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64)
+# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture"
+#endif
+#if (LZO_OS_OS216 || LZO_OS_WIN16)
+# define LZO_ARCH_I086PM 1
+#elif 1 && (LZO_OS_DOS16 && defined(BLX286))
+# define LZO_ARCH_I086PM 1
+#elif 1 && (LZO_OS_DOS16 && defined(DOSX286))
+# define LZO_ARCH_I086PM 1
+#elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__))
+# define LZO_ARCH_I086PM 1
+#endif
+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64)
+# define LZO_ARCH_X64 1
+#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE)
+# define LZO_ARCH_AMD64 1
+#endif
+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64)
+# define LZO_ARCH_AARCH64 1
+#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE)
+# define LZO_ARCH_ARM64 1
+#endif
+#if (LZO_ARCH_I386 && !LZO_ARCH_X86)
+# define LZO_ARCH_X86 1
+#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE)
+# define LZO_ARCH_I386 1
+#endif
+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_I086PM && !LZO_ARCH_I086)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_I086)
+# if (UINT_MAX != LZO_0xffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+# if (ULONG_MAX != LZO_0xffffffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+#endif
+#if (LZO_ARCH_I386)
+# if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
+# error "unexpected configuration - check your compiler defines"
+# endif
+# if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
+# error "unexpected configuration - check your compiler defines"
+# endif
+# if (ULONG_MAX != LZO_0xffffffffL)
+# error "unexpected configuration - check your compiler defines"
+# endif
+#endif
+#if (LZO_ARCH_AMD64 || LZO_ARCH_I386)
+# if !defined(LZO_TARGET_FEATURE_SSE2)
+# if defined(__SSE2__)
+# define LZO_TARGET_FEATURE_SSE2 1
+# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64))
+# define LZO_TARGET_FEATURE_SSE2 1
+# endif
+# endif
+# if !defined(LZO_TARGET_FEATURE_SSSE3)
+# if (LZO_TARGET_FEATURE_SSE2)
+# if defined(__SSSE3__)
+# define LZO_TARGET_FEATURE_SSSE3 1
+# elif defined(_MSC_VER) && defined(__AVX__)
+# define LZO_TARGET_FEATURE_SSSE3 1
+# endif
+# endif
+# endif
+# if !defined(LZO_TARGET_FEATURE_SSE4_2)
+# if (LZO_TARGET_FEATURE_SSSE3)
+# if defined(__SSE4_2__)
+# define LZO_TARGET_FEATURE_SSE4_2 1
+# endif
+# endif
+# endif
+# if !defined(LZO_TARGET_FEATURE_AVX)
+# if (LZO_TARGET_FEATURE_SSSE3)
+# if defined(__AVX__)
+# define LZO_TARGET_FEATURE_AVX 1
+# endif
+# endif
+# endif
+# if !defined(LZO_TARGET_FEATURE_AVX2)
+# if (LZO_TARGET_FEATURE_AVX)
+# if defined(__AVX2__)
+# define LZO_TARGET_FEATURE_AVX2 1
+# endif
+# endif
+# endif
+#endif
+#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2))
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3))
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3))
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX))
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ARCH_ARM)
+# if !defined(LZO_TARGET_FEATURE_NEON)
+# if defined(__ARM_NEON__)
+# define LZO_TARGET_FEATURE_NEON 1
+# endif
+# endif
+#elif (LZO_ARCH_ARM64)
+# if !defined(LZO_TARGET_FEATURE_NEON)
+# if 1
+# define LZO_TARGET_FEATURE_NEON 1
+# endif
+# endif
+#endif
+#if 0
+#elif !defined(__LZO_MM_OVERRIDE)
+#if (LZO_ARCH_I086)
+#if (UINT_MAX != LZO_0xffffL)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM)
+# define LZO_MM_TINY 1
+#elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM)
+# define LZO_MM_HUGE 1
+#elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL)
+# define LZO_MM_SMALL 1
+#elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM)
+# define LZO_MM_MEDIUM 1
+#elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM)
+# define LZO_MM_COMPACT 1
+#elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL)
+# define LZO_MM_LARGE 1
+#elif (LZO_CC_AZTECC)
+# if defined(_LARGE_CODE) && defined(_LARGE_DATA)
+# define LZO_MM_LARGE 1
+# elif defined(_LARGE_CODE)
+# define LZO_MM_MEDIUM 1
+# elif defined(_LARGE_DATA)
+# define LZO_MM_COMPACT 1
+# else
+# define LZO_MM_SMALL 1
+# endif
+#elif (LZO_CC_ZORTECHC && defined(__VCM__))
+# define LZO_MM_LARGE 1
+#else
+# error "unknown LZO_ARCH_I086 memory model"
+#endif
+#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
+#define LZO_HAVE_MM_HUGE_PTR 1
+#define LZO_HAVE_MM_HUGE_ARRAY 1
+#if (LZO_MM_TINY)
+# undef LZO_HAVE_MM_HUGE_ARRAY
+#endif
+#if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC)
+# undef LZO_HAVE_MM_HUGE_PTR
+# undef LZO_HAVE_MM_HUGE_ARRAY
+#elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
+# undef LZO_HAVE_MM_HUGE_ARRAY
+#elif (LZO_CC_MSC && defined(_QC))
+# undef LZO_HAVE_MM_HUGE_ARRAY
+# if (_MSC_VER < 600)
+# undef LZO_HAVE_MM_HUGE_PTR
+# endif
+#elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295))
+# undef LZO_HAVE_MM_HUGE_ARRAY
+#endif
+#if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR)
+# if (LZO_OS_DOS16)
+# error "unexpected configuration - check your compiler defines"
+# elif (LZO_CC_ZORTECHC)
+# else
+# error "unexpected configuration - check your compiler defines"
+# endif
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+#if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
+ extern void __near __cdecl _AHSHIFT(void);
+# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
+#elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
+ extern void __near __cdecl _AHSHIFT(void);
+# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
+#elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC)
+ extern void __near __cdecl _AHSHIFT(void);
+# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
+#elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295))
+ extern void __near __cdecl _AHSHIFT(void);
+# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
+#elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16)
+# define LZO_MM_AHSHIFT 12
+#elif (LZO_CC_WATCOMC)
+ extern unsigned char _HShift;
+# define LZO_MM_AHSHIFT ((unsigned) _HShift)
+#else
+# error "FIXME - implement LZO_MM_AHSHIFT"
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
+#elif (LZO_ARCH_C166)
+#if !defined(__MODEL__)
+# error "FIXME - LZO_ARCH_C166 __MODEL__"
+#elif ((__MODEL__) == 0)
+# define LZO_MM_SMALL 1
+#elif ((__MODEL__) == 1)
+# define LZO_MM_SMALL 1
+#elif ((__MODEL__) == 2)
+# define LZO_MM_LARGE 1
+#elif ((__MODEL__) == 3)
+# define LZO_MM_TINY 1
+#elif ((__MODEL__) == 4)
+# define LZO_MM_XTINY 1
+#elif ((__MODEL__) == 5)
+# define LZO_MM_XSMALL 1
+#else
+# error "FIXME - LZO_ARCH_C166 __MODEL__"
+#endif
+#elif (LZO_ARCH_MCS251)
+#if !defined(__MODEL__)
+# error "FIXME - LZO_ARCH_MCS251 __MODEL__"
+#elif ((__MODEL__) == 0)
+# define LZO_MM_SMALL 1
+#elif ((__MODEL__) == 2)
+# define LZO_MM_LARGE 1
+#elif ((__MODEL__) == 3)
+# define LZO_MM_TINY 1
+#elif ((__MODEL__) == 4)
+# define LZO_MM_XTINY 1
+#elif ((__MODEL__) == 5)
+# define LZO_MM_XSMALL 1
+#else
+# error "FIXME - LZO_ARCH_MCS251 __MODEL__"
+#endif
+#elif (LZO_ARCH_MCS51)
+#if !defined(__MODEL__)
+# error "FIXME - LZO_ARCH_MCS51 __MODEL__"
+#elif ((__MODEL__) == 1)
+# define LZO_MM_SMALL 1
+#elif ((__MODEL__) == 2)
+# define LZO_MM_LARGE 1
+#elif ((__MODEL__) == 3)
+# define LZO_MM_TINY 1
+#elif ((__MODEL__) == 4)
+# define LZO_MM_XTINY 1
+#elif ((__MODEL__) == 5)
+# define LZO_MM_XSMALL 1
+#else
+# error "FIXME - LZO_ARCH_MCS51 __MODEL__"
+#endif
+#elif (LZO_ARCH_CRAY_PVP)
+# define LZO_MM_PVP 1
+#else
+# define LZO_MM_FLAT 1
+#endif
+#if (LZO_MM_COMPACT)
+# define LZO_INFO_MM "compact"
+#elif (LZO_MM_FLAT)
+# define LZO_INFO_MM "flat"
+#elif (LZO_MM_HUGE)
+# define LZO_INFO_MM "huge"
+#elif (LZO_MM_LARGE)
+# define LZO_INFO_MM "large"
+#elif (LZO_MM_MEDIUM)
+# define LZO_INFO_MM "medium"
+#elif (LZO_MM_PVP)
+# define LZO_INFO_MM "pvp"
+#elif (LZO_MM_SMALL)
+# define LZO_INFO_MM "small"
+#elif (LZO_MM_TINY)
+# define LZO_INFO_MM "tiny"
+#else
+# error "unknown memory model"
+#endif
+#endif
+#if !defined(__lzo_gnuc_extension__)
+#if (LZO_CC_GNUC >= 0x020800ul)
+# define __lzo_gnuc_extension__ __extension__
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_gnuc_extension__ __extension__
+#elif (LZO_CC_IBMC >= 600)
+# define __lzo_gnuc_extension__ __extension__
+#else
+#endif
+#endif
+#if !defined(__lzo_gnuc_extension__)
+# define __lzo_gnuc_extension__ /*empty*/
+#endif
+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0
+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul))
+# define LZO_CFG_USE_NEW_STYLE_CASTS 0
+# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200))
+# define LZO_CFG_USE_NEW_STYLE_CASTS 0
+# else
+# define LZO_CFG_USE_NEW_STYLE_CASTS 1
+# endif
+#endif
+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_CFG_USE_NEW_STYLE_CASTS 0
+#endif
+#if !defined(__cplusplus)
+# if defined(LZO_CFG_USE_NEW_STYLE_CASTS)
+# undef LZO_CFG_USE_NEW_STYLE_CASTS
+# endif
+# define LZO_CFG_USE_NEW_STYLE_CASTS 0
+#endif
+#if !defined(LZO_REINTERPRET_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast<t> (e))
+# endif
+#endif
+#if !defined(LZO_REINTERPRET_CAST)
+# define LZO_REINTERPRET_CAST(t,e) ((t) (e))
+#endif
+#if !defined(LZO_STATIC_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_STATIC_CAST(t,e) (static_cast<t> (e))
+# endif
+#endif
+#if !defined(LZO_STATIC_CAST)
+# define LZO_STATIC_CAST(t,e) ((t) (e))
+#endif
+#if !defined(LZO_STATIC_CAST2)
+# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e))
+#endif
+#if !defined(LZO_UNCONST_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_UNCONST_CAST(t,e) (const_cast<t> (e))
+# elif (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_UNCONST_CAST(t,e) ((t) (e))
+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e)))))
+# endif
+#endif
+#if !defined(LZO_UNCONST_CAST)
+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e))))
+#endif
+#if !defined(LZO_UNCONST_VOLATILE_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast<t> (e))
+# elif (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e))
+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e)))))
+# endif
+#endif
+#if !defined(LZO_UNCONST_VOLATILE_CAST)
+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e))))
+#endif
+#if !defined(LZO_UNVOLATILE_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_UNVOLATILE_CAST(t,e) (const_cast<t> (e))
+# elif (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_UNVOLATILE_CAST(t,e) ((t) (e))
+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e)))))
+# endif
+#endif
+#if !defined(LZO_UNVOLATILE_CAST)
+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e))))
+#endif
+#if !defined(LZO_UNVOLATILE_CONST_CAST)
+# if (LZO_CFG_USE_NEW_STYLE_CASTS)
+# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast<t> (e))
+# elif (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e))
+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e)))))
+# endif
+#endif
+#if !defined(LZO_UNVOLATILE_CONST_CAST)
+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e))))
+#endif
+#if !defined(LZO_PCAST)
+# if (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_PCAST(t,e) ((t) (e))
+# endif
+#endif
+#if !defined(LZO_PCAST)
+# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e))
+#endif
+#if !defined(LZO_CCAST)
+# if (LZO_HAVE_MM_HUGE_PTR)
+# define LZO_CCAST(t,e) ((t) (e))
+# endif
+#endif
+#if !defined(LZO_CCAST)
+# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e))
+#endif
+#if !defined(LZO_ICONV)
+# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e)
+#endif
+#if !defined(LZO_ICAST)
+# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e)
+#endif
+#if !defined(LZO_ITRUNC)
+# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e)
+#endif
+#if !defined(__lzo_cte)
+# if (LZO_CC_MSC || LZO_CC_WATCOMC)
+# define __lzo_cte(e) ((void)0,(e))
+# elif 1
+# define __lzo_cte(e) ((void)0,(e))
+# endif
+#endif
+#if !defined(__lzo_cte)
+# define __lzo_cte(e) (e)
+#endif
+#if !defined(LZO_BLOCK_BEGIN)
+# define LZO_BLOCK_BEGIN do {
+# define LZO_BLOCK_END } while __lzo_cte(0)
+#endif
+#if !defined(LZO_UNUSED)
+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
+# define LZO_UNUSED(var) ((void) &var)
+# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC)
+# define LZO_UNUSED(var) if (&var) ; else
+# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul))
+# define LZO_UNUSED(var) ((void) &var)
+# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_UNUSED(var) ((void) var)
+# elif (LZO_CC_MSC && (_MSC_VER < 900))
+# define LZO_UNUSED(var) if (&var) ; else
+# elif (LZO_CC_KEILC)
+# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];}
+# elif (LZO_CC_PACIFICC)
+# define LZO_UNUSED(var) ((void) sizeof(var))
+# elif (LZO_CC_WATCOMC) && defined(__cplusplus)
+# define LZO_UNUSED(var) ((void) var)
+# else
+# define LZO_UNUSED(var) ((void) &var)
+# endif
+#endif
+#if !defined(LZO_UNUSED_FUNC)
+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
+# define LZO_UNUSED_FUNC(func) ((void) func)
+# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC)
+# define LZO_UNUSED_FUNC(func) if (func) ; else
+# elif (LZO_CC_CLANG || LZO_CC_LLVM)
+# define LZO_UNUSED_FUNC(func) ((void) &func)
+# elif (LZO_CC_MSC && (_MSC_VER < 900))
+# define LZO_UNUSED_FUNC(func) if (func) ; else
+# elif (LZO_CC_MSC)
+# define LZO_UNUSED_FUNC(func) ((void) &func)
+# elif (LZO_CC_KEILC || LZO_CC_PELLESC)
+# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];}
+# else
+# define LZO_UNUSED_FUNC(func) ((void) func)
+# endif
+#endif
+#if !defined(LZO_UNUSED_LABEL)
+# if (LZO_CC_CLANG >= 0x020800ul)
+# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l)))
+# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC)
+# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l
+# else
+# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l
+# endif
+#endif
+#if !defined(LZO_DEFINE_UNINITIALIZED_VAR)
+# if 0
+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var
+# elif 0 && (LZO_CC_GNUC)
+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var
+# else
+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init
+# endif
+#endif
+#if !defined(__lzo_inline)
+#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295))
+#elif defined(__cplusplus)
+# define __lzo_inline inline
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L)
+# define __lzo_inline inline
+#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
+# define __lzo_inline __inline
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
+# define __lzo_inline __inline__
+#elif (LZO_CC_DMC)
+# define __lzo_inline __inline
+#elif (LZO_CC_GHS)
+# define __lzo_inline __inline__
+#elif (LZO_CC_IBMC >= 600)
+# define __lzo_inline __inline__
+#elif (LZO_CC_INTELC)
+# define __lzo_inline __inline
+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405))
+# define __lzo_inline __inline
+#elif (LZO_CC_MSC && (_MSC_VER >= 900))
+# define __lzo_inline __inline
+#elif (LZO_CC_SUNPROC >= 0x5100)
+# define __lzo_inline __inline__
+#endif
+#endif
+#if defined(__lzo_inline)
+# ifndef __lzo_HAVE_inline
+# define __lzo_HAVE_inline 1
+# endif
+#else
+# define __lzo_inline /*empty*/
+#endif
+#if !defined(__lzo_forceinline)
+#if (LZO_CC_GNUC >= 0x030200ul)
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#elif (LZO_CC_IBMC >= 700)
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450))
+# define __lzo_forceinline __forceinline
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#elif (LZO_CC_MSC && (_MSC_VER >= 1200))
+# define __lzo_forceinline __forceinline
+#elif (LZO_CC_PGI >= 0x0d0a00ul)
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#elif (LZO_CC_SUNPROC >= 0x5100)
+# define __lzo_forceinline __inline__ __attribute__((__always_inline__))
+#endif
+#endif
+#if defined(__lzo_forceinline)
+# ifndef __lzo_HAVE_forceinline
+# define __lzo_HAVE_forceinline 1
+# endif
+#else
+# define __lzo_forceinline __lzo_inline
+#endif
+#if !defined(__lzo_noinline)
+#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul)
+# define __lzo_noinline __attribute__((__noinline__,__used__))
+#elif (LZO_CC_GNUC >= 0x030200ul)
+# define __lzo_noinline __attribute__((__noinline__))
+#elif (LZO_CC_IBMC >= 700)
+# define __lzo_noinline __attribute__((__noinline__))
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600))
+# define __lzo_noinline __declspec(noinline)
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
+# define __lzo_noinline __attribute__((__noinline__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_noinline __attribute__((__noinline__))
+#elif (LZO_CC_MSC && (_MSC_VER >= 1300))
+# define __lzo_noinline __declspec(noinline)
+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64))
+# if defined(__cplusplus)
+# else
+# define __lzo_noinline __declspec(noinline)
+# endif
+#elif (LZO_CC_PGI >= 0x0d0a00ul)
+# define __lzo_noinline __attribute__((__noinline__))
+#elif (LZO_CC_SUNPROC >= 0x5100)
+# define __lzo_noinline __attribute__((__noinline__))
+#endif
+#endif
+#if defined(__lzo_noinline)
+# ifndef __lzo_HAVE_noinline
+# define __lzo_HAVE_noinline 1
+# endif
+#else
+# define __lzo_noinline /*empty*/
+#endif
+#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if !defined(__lzo_static_inline)
+#if (LZO_CC_IBMC)
+# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline
+#endif
+#endif
+#if !defined(__lzo_static_inline)
+# define __lzo_static_inline static __lzo_inline
+#endif
+#if !defined(__lzo_static_forceinline)
+#if (LZO_CC_IBMC)
+# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline
+#endif
+#endif
+#if !defined(__lzo_static_forceinline)
+# define __lzo_static_forceinline static __lzo_forceinline
+#endif
+#if !defined(__lzo_static_noinline)
+#if (LZO_CC_IBMC)
+# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline
+#endif
+#endif
+#if !defined(__lzo_static_noinline)
+# define __lzo_static_noinline static __lzo_noinline
+#endif
+#if !defined(__lzo_c99_extern_inline)
+#if defined(__GNUC_GNU_INLINE__)
+# define __lzo_c99_extern_inline __lzo_inline
+#elif defined(__GNUC_STDC_INLINE__)
+# define __lzo_c99_extern_inline extern __lzo_inline
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L)
+# define __lzo_c99_extern_inline extern __lzo_inline
+#endif
+#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline)
+# define __lzo_c99_extern_inline __lzo_inline
+#endif
+#endif
+#if defined(__lzo_c99_extern_inline)
+# ifndef __lzo_HAVE_c99_extern_inline
+# define __lzo_HAVE_c99_extern_inline 1
+# endif
+#else
+# define __lzo_c99_extern_inline /*empty*/
+#endif
+#if !defined(__lzo_may_alias)
+#if (LZO_CC_GNUC >= 0x030400ul)
+# define __lzo_may_alias __attribute__((__may_alias__))
+#elif (LZO_CC_CLANG >= 0x020900ul)
+# define __lzo_may_alias __attribute__((__may_alias__))
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0
+# define __lzo_may_alias __attribute__((__may_alias__))
+#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0
+# define __lzo_may_alias __attribute__((__may_alias__))
+#endif
+#endif
+#if defined(__lzo_may_alias)
+# ifndef __lzo_HAVE_may_alias
+# define __lzo_HAVE_may_alias 1
+# endif
+#else
+# define __lzo_may_alias /*empty*/
+#endif
+#if !defined(__lzo_noreturn)
+#if (LZO_CC_GNUC >= 0x020700ul)
+# define __lzo_noreturn __attribute__((__noreturn__))
+#elif (LZO_CC_IBMC >= 700)
+# define __lzo_noreturn __attribute__((__noreturn__))
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450))
+# define __lzo_noreturn __declspec(noreturn)
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600))
+# define __lzo_noreturn __attribute__((__noreturn__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_noreturn __attribute__((__noreturn__))
+#elif (LZO_CC_MSC && (_MSC_VER >= 1200))
+# define __lzo_noreturn __declspec(noreturn)
+#elif (LZO_CC_PGI >= 0x0d0a00ul)
+# define __lzo_noreturn __attribute__((__noreturn__))
+#endif
+#endif
+#if defined(__lzo_noreturn)
+# ifndef __lzo_HAVE_noreturn
+# define __lzo_HAVE_noreturn 1
+# endif
+#else
+# define __lzo_noreturn /*empty*/
+#endif
+#if !defined(__lzo_nothrow)
+#if (LZO_CC_GNUC >= 0x030300ul)
+# define __lzo_nothrow __attribute__((__nothrow__))
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus)
+# define __lzo_nothrow __declspec(nothrow)
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900))
+# define __lzo_nothrow __attribute__((__nothrow__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_nothrow __attribute__((__nothrow__))
+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
+# define __lzo_nothrow __declspec(nothrow)
+#endif
+#endif
+#if defined(__lzo_nothrow)
+# ifndef __lzo_HAVE_nothrow
+# define __lzo_HAVE_nothrow 1
+# endif
+#else
+# define __lzo_nothrow /*empty*/
+#endif
+#if !defined(__lzo_restrict)
+#if (LZO_CC_GNUC >= 0x030400ul)
+# define __lzo_restrict __restrict__
+#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus)
+# define __lzo_restrict __restrict__
+#elif (LZO_CC_IBMC >= 1210)
+# define __lzo_restrict __restrict__
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600))
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600))
+# define __lzo_restrict __restrict__
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM)
+# define __lzo_restrict __restrict__
+#elif (LZO_CC_MSC && (_MSC_VER >= 1400))
+# define __lzo_restrict __restrict
+#elif (LZO_CC_PGI >= 0x0d0a00ul)
+# define __lzo_restrict __restrict__
+#endif
+#endif
+#if defined(__lzo_restrict)
+# ifndef __lzo_HAVE_restrict
+# define __lzo_HAVE_restrict 1
+# endif
+#else
+# define __lzo_restrict /*empty*/
+#endif
+#if !defined(__lzo_alignof)
+#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
+# define __lzo_alignof(e) __alignof__(e)
+#elif (LZO_CC_GHS) && !defined(__cplusplus)
+# define __lzo_alignof(e) __alignof__(e)
+#elif (LZO_CC_IBMC >= 600)
+# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e))
+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700))
+# define __lzo_alignof(e) __alignof__(e)
+#elif (LZO_CC_MSC && (_MSC_VER >= 1300))
+# define __lzo_alignof(e) __alignof(e)
+#elif (LZO_CC_SUNPROC >= 0x5100)
+# define __lzo_alignof(e) __alignof__(e)
+#endif
+#endif
+#if defined(__lzo_alignof)
+# ifndef __lzo_HAVE_alignof
+# define __lzo_HAVE_alignof 1
+# endif
+#endif
+#if !defined(__lzo_struct_packed)
+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus)
+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul))
+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus)
+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul))
+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus)
+#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
+# define __lzo_struct_packed(s) struct s {
+# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__));
+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__));
+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100))
+# define __lzo_struct_packed(s) struct s {
+# define __lzo_struct_packed_end() } __attribute__((__packed__));
+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__));
+#elif (LZO_CC_IBMC >= 700)
+# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s {
+# define __lzo_struct_packed_end() } __attribute__((__packed__));
+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__));
+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300))
+# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s {
+# define __lzo_struct_packed_end() } __pragma(pack(pop));
+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900))
+# define __lzo_struct_packed(s) _Packed struct s {
+# define __lzo_struct_packed_end() };
+#endif
+#endif
+#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma)
+# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s)
+#endif
+#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end)
+# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end()
+#endif
+#if !defined(__lzo_byte_struct)
+#if defined(__lzo_struct_packed)
+# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end()
+# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end()
+#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100))
+# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__));
+# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__));
+#endif
+#endif
+#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma)
+# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n)
+#endif
+#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof)
+#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul))
+#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus)
+#elif (LZO_CC_CILLY || LZO_CC_PCC)
+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300))
+# define __lzo_struct_align16(s) struct __declspec(align(16)) s {
+# define __lzo_struct_align16_end() };
+# define __lzo_struct_align32(s) struct __declspec(align(32)) s {
+# define __lzo_struct_align32_end() };
+# define __lzo_struct_align64(s) struct __declspec(align(64)) s {
+# define __lzo_struct_align64_end() };
+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_struct_align16(s) struct s {
+# define __lzo_struct_align16_end() } __attribute__((__aligned__(16)));
+# define __lzo_struct_align32(s) struct s {
+# define __lzo_struct_align32_end() } __attribute__((__aligned__(32)));
+# define __lzo_struct_align64(s) struct s {
+# define __lzo_struct_align64_end() } __attribute__((__aligned__(64)));
+#endif
+#endif
+#if !defined(__lzo_union_um)
+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus)
+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul))
+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus)
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810))
+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul))
+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus)
+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100))
+# define __lzo_union_am(s) union s {
+# define __lzo_union_am_end() } __lzo_may_alias;
+# define __lzo_union_um(s) union s {
+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__));
+#elif (LZO_CC_IBMC >= 700)
+# define __lzo_union_am(s) __lzo_gnuc_extension__ union s {
+# define __lzo_union_am_end() } __lzo_may_alias;
+# define __lzo_union_um(s) __lzo_gnuc_extension__ union s {
+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__));
+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300))
+# define __lzo_union_um(s) __pragma(pack(push,1)) union s {
+# define __lzo_union_um_end() } __pragma(pack(pop));
+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900))
+# define __lzo_union_um(s) _Packed union s {
+# define __lzo_union_um_end() };
+#endif
+#endif
+#if !defined(__lzo_union_am)
+# define __lzo_union_am(s) union s {
+# define __lzo_union_am_end() };
+#endif
+#if !defined(__lzo_constructor)
+#if (LZO_CC_GNUC >= 0x030400ul)
+# define __lzo_constructor __attribute__((__constructor__,__used__))
+#elif (LZO_CC_GNUC >= 0x020700ul)
+# define __lzo_constructor __attribute__((__constructor__))
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
+# define __lzo_constructor __attribute__((__constructor__,__used__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_constructor __attribute__((__constructor__))
+#endif
+#endif
+#if defined(__lzo_constructor)
+# ifndef __lzo_HAVE_constructor
+# define __lzo_HAVE_constructor 1
+# endif
+#endif
+#if !defined(__lzo_destructor)
+#if (LZO_CC_GNUC >= 0x030400ul)
+# define __lzo_destructor __attribute__((__destructor__,__used__))
+#elif (LZO_CC_GNUC >= 0x020700ul)
+# define __lzo_destructor __attribute__((__destructor__))
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
+# define __lzo_destructor __attribute__((__destructor__,__used__))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_destructor __attribute__((__destructor__))
+#endif
+#endif
+#if defined(__lzo_destructor)
+# ifndef __lzo_HAVE_destructor
+# define __lzo_HAVE_destructor 1
+# endif
+#endif
+#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if !defined(__lzo_likely) && !defined(__lzo_unlikely)
+#if (LZO_CC_GNUC >= 0x030200ul)
+# define __lzo_likely(e) (__builtin_expect(!!(e),1))
+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
+#elif (LZO_CC_IBMC >= 1010)
+# define __lzo_likely(e) (__builtin_expect(!!(e),1))
+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800))
+# define __lzo_likely(e) (__builtin_expect(!!(e),1))
+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define __lzo_likely(e) (__builtin_expect(!!(e),1))
+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
+#endif
+#endif
+#if defined(__lzo_likely)
+# ifndef __lzo_HAVE_likely
+# define __lzo_HAVE_likely 1
+# endif
+#else
+# define __lzo_likely(e) (e)
+#endif
+#if defined(__lzo_unlikely)
+# ifndef __lzo_HAVE_unlikely
+# define __lzo_HAVE_unlikely 1
+# endif
+#else
+# define __lzo_unlikely(e) (e)
+#endif
+#if !defined(__lzo_static_unused_void_func)
+# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
+# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void)
+# else
+# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void)
+# endif
+#endif
+#if !defined(__lzo_loop_forever)
+# if (LZO_CC_IBMC)
+# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END
+# else
+# define __lzo_loop_forever() do { ; } while __lzo_cte(1)
+# endif
+#endif
+#if !defined(__lzo_unreachable)
+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul))
+# define __lzo_unreachable() __builtin_unreachable();
+#elif (LZO_CC_GNUC >= 0x040500ul)
+# define __lzo_unreachable() __builtin_unreachable();
+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1
+# define __lzo_unreachable() __builtin_unreachable();
+#endif
+#endif
+#if defined(__lzo_unreachable)
+# ifndef __lzo_HAVE_unreachable
+# define __lzo_HAVE_unreachable 1
+# endif
+#else
+# if 0
+# define __lzo_unreachable() ((void)0);
+# else
+# define __lzo_unreachable() __lzo_loop_forever();
+# endif
+#endif
+#ifndef __LZO_CTA_NAME
+#if (LZO_CFG_USE_COUNTER)
+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__)
+#else
+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__)
+#endif
+#endif
+#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER)
+# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC)
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END
+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END
+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END
+# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus)
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END
+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__)
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END
+# else
+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END
+# endif
+#endif
+#if !defined(LZO_COMPILE_TIME_ASSERT)
+# if (LZO_CC_AZTECC)
+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];}
+# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__)
+# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));}
+# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus)
+# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));}
+# elif (LZO_CC_GNUC >= 0x040700ul)
+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));}
+# elif (LZO_CC_MSC && (_MSC_VER < 900))
+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
+# else
+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];}
+# endif
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1)
+#if defined(__cplusplus)
+extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) }
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3)
+#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64)
+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC)
+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
+# define __lzo_cdecl __cdecl
+# define __lzo_cdecl_atexit /*empty*/
+# define __lzo_cdecl_main __cdecl
+# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
+# define __lzo_cdecl_qsort __pascal
+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
+# define __lzo_cdecl_qsort _stdcall
+# else
+# define __lzo_cdecl_qsort __cdecl
+# endif
+# elif (LZO_CC_WATCOMC)
+# define __lzo_cdecl __cdecl
+# else
+# define __lzo_cdecl __cdecl
+# define __lzo_cdecl_atexit __cdecl
+# define __lzo_cdecl_main __cdecl
+# define __lzo_cdecl_qsort __cdecl
+# endif
+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC)
+# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
+# define __lzo_cdecl_sighandler __pascal
+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
+# define __lzo_cdecl_sighandler _stdcall
+# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE)
+# define __lzo_cdecl_sighandler __clrcall
+# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
+# if defined(_DLL)
+# define __lzo_cdecl_sighandler _far _cdecl _loadds
+# elif defined(_MT)
+# define __lzo_cdecl_sighandler _far _cdecl
+# else
+# define __lzo_cdecl_sighandler _cdecl
+# endif
+# else
+# define __lzo_cdecl_sighandler __cdecl
+# endif
+#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC)
+# define __lzo_cdecl __cdecl
+#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
+# define __lzo_cdecl cdecl
+#endif
+#if !defined(__lzo_cdecl)
+# define __lzo_cdecl /*empty*/
+#endif
+#if !defined(__lzo_cdecl_atexit)
+# define __lzo_cdecl_atexit /*empty*/
+#endif
+#if !defined(__lzo_cdecl_main)
+# define __lzo_cdecl_main /*empty*/
+#endif
+#if !defined(__lzo_cdecl_qsort)
+# define __lzo_cdecl_qsort /*empty*/
+#endif
+#if !defined(__lzo_cdecl_sighandler)
+# define __lzo_cdecl_sighandler /*empty*/
+#endif
+#if !defined(__lzo_cdecl_va)
+# define __lzo_cdecl_va __lzo_cdecl
+#endif
+#if !(LZO_CFG_NO_WINDOWS_H)
+#if !defined(LZO_HAVE_WINDOWS_H)
+#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64)
+# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000))
+# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
+# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul)))
+# else
+# define LZO_HAVE_WINDOWS_H 1
+# endif
+#endif
+#endif
+#endif
+#ifndef LZO_SIZEOF_SHORT
+#if defined(SIZEOF_SHORT)
+# define LZO_SIZEOF_SHORT (SIZEOF_SHORT)
+#elif defined(__SIZEOF_SHORT__)
+# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__)
+#endif
+#endif
+#ifndef LZO_SIZEOF_INT
+#if defined(SIZEOF_INT)
+# define LZO_SIZEOF_INT (SIZEOF_INT)
+#elif defined(__SIZEOF_INT__)
+# define LZO_SIZEOF_INT (__SIZEOF_INT__)
+#endif
+#endif
+#ifndef LZO_SIZEOF_LONG
+#if defined(SIZEOF_LONG)
+# define LZO_SIZEOF_LONG (SIZEOF_LONG)
+#elif defined(__SIZEOF_LONG__)
+# define LZO_SIZEOF_LONG (__SIZEOF_LONG__)
+#endif
+#endif
+#ifndef LZO_SIZEOF_LONG_LONG
+#if defined(SIZEOF_LONG_LONG)
+# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG)
+#elif defined(__SIZEOF_LONG_LONG__)
+# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__)
+#endif
+#endif
+#ifndef LZO_SIZEOF___INT16
+#if defined(SIZEOF___INT16)
+# define LZO_SIZEOF___INT16 (SIZEOF___INT16)
+#endif
+#endif
+#ifndef LZO_SIZEOF___INT32
+#if defined(SIZEOF___INT32)
+# define LZO_SIZEOF___INT32 (SIZEOF___INT32)
+#endif
+#endif
+#ifndef LZO_SIZEOF___INT64
+#if defined(SIZEOF___INT64)
+# define LZO_SIZEOF___INT64 (SIZEOF___INT64)
+#endif
+#endif
+#ifndef LZO_SIZEOF_VOID_P
+#if defined(SIZEOF_VOID_P)
+# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P)
+#elif defined(__SIZEOF_POINTER__)
+# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__)
+#endif
+#endif
+#ifndef LZO_SIZEOF_SIZE_T
+#if defined(SIZEOF_SIZE_T)
+# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T)
+#elif defined(__SIZEOF_SIZE_T__)
+# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__)
+#endif
+#endif
+#ifndef LZO_SIZEOF_PTRDIFF_T
+#if defined(SIZEOF_PTRDIFF_T)
+# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T)
+#elif defined(__SIZEOF_PTRDIFF_T__)
+# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__)
+#endif
+#endif
+#define __LZO_LSR(x,b) (((x)+0ul) >> (b))
+#if !defined(LZO_SIZEOF_SHORT)
+# if (LZO_ARCH_CRAY_PVP)
+# define LZO_SIZEOF_SHORT 8
+# elif (USHRT_MAX == LZO_0xffffL)
+# define LZO_SIZEOF_SHORT 2
+# elif (__LZO_LSR(USHRT_MAX,7) == 1)
+# define LZO_SIZEOF_SHORT 1
+# elif (__LZO_LSR(USHRT_MAX,15) == 1)
+# define LZO_SIZEOF_SHORT 2
+# elif (__LZO_LSR(USHRT_MAX,31) == 1)
+# define LZO_SIZEOF_SHORT 4
+# elif (__LZO_LSR(USHRT_MAX,63) == 1)
+# define LZO_SIZEOF_SHORT 8
+# elif (__LZO_LSR(USHRT_MAX,127) == 1)
+# define LZO_SIZEOF_SHORT 16
+# else
+# error "LZO_SIZEOF_SHORT"
+# endif
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short))
+#if !defined(LZO_SIZEOF_INT)
+# if (LZO_ARCH_CRAY_PVP)
+# define LZO_SIZEOF_INT 8
+# elif (UINT_MAX == LZO_0xffffL)
+# define LZO_SIZEOF_INT 2
+# elif (UINT_MAX == LZO_0xffffffffL)
+# define LZO_SIZEOF_INT 4
+# elif (__LZO_LSR(UINT_MAX,7) == 1)
+# define LZO_SIZEOF_INT 1
+# elif (__LZO_LSR(UINT_MAX,15) == 1)
+# define LZO_SIZEOF_INT 2
+# elif (__LZO_LSR(UINT_MAX,31) == 1)
+# define LZO_SIZEOF_INT 4
+# elif (__LZO_LSR(UINT_MAX,63) == 1)
+# define LZO_SIZEOF_INT 8
+# elif (__LZO_LSR(UINT_MAX,127) == 1)
+# define LZO_SIZEOF_INT 16
+# else
+# error "LZO_SIZEOF_INT"
+# endif
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int))
+#if !defined(LZO_SIZEOF_LONG)
+# if (ULONG_MAX == LZO_0xffffffffL)
+# define LZO_SIZEOF_LONG 4
+# elif (__LZO_LSR(ULONG_MAX,7) == 1)
+# define LZO_SIZEOF_LONG 1
+# elif (__LZO_LSR(ULONG_MAX,15) == 1)
+# define LZO_SIZEOF_LONG 2
+# elif (__LZO_LSR(ULONG_MAX,31) == 1)
+# define LZO_SIZEOF_LONG 4
+# elif (__LZO_LSR(ULONG_MAX,39) == 1)
+# define LZO_SIZEOF_LONG 5
+# elif (__LZO_LSR(ULONG_MAX,63) == 1)
+# define LZO_SIZEOF_LONG 8
+# elif (__LZO_LSR(ULONG_MAX,127) == 1)
+# define LZO_SIZEOF_LONG 16
+# else
+# error "LZO_SIZEOF_LONG"
+# endif
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long))
+#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
+#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
+# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__)
+# if (LZO_CC_GNUC >= 0x030300ul)
+# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0))
+# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG
+# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1)
+# define LZO_SIZEOF_LONG_LONG 4
+# endif
+# endif
+# endif
+#endif
+#endif
+#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
+#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
+#if (LZO_ARCH_I086 && LZO_CC_DMC)
+#elif (LZO_CC_CILLY) && defined(__GNUC__)
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
+# define LZO_SIZEOF_LONG_LONG 8
+#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_OS_WIN64 || defined(_WIN64))
+# define LZO_SIZEOF___INT64 8
+#elif (LZO_ARCH_I386 && (LZO_CC_DMC))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700)))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__)))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC))
+# define LZO_SIZEOF___INT64 8
+#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC))
+# define LZO_SIZEOF___INT64 8
+#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520)))
+# define LZO_SIZEOF___INT64 8
+#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100)))
+# define LZO_SIZEOF___INT64 8
+#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64))
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64))
+# define LZO_SIZEOF___INT64 8
+#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64)
+# define LZO_SIZEOF_LONG_LONG 8
+#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2)
+#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+# define LZO_SIZEOF_LONG_LONG 8
+#endif
+#endif
+#endif
+#if defined(__cplusplus) && (LZO_CC_GNUC)
+# if (LZO_CC_GNUC < 0x020800ul)
+# undef LZO_SIZEOF_LONG_LONG
+# endif
+#endif
+#if (LZO_CFG_NO_LONG_LONG)
+# undef LZO_SIZEOF_LONG_LONG
+#elif defined(__NO_LONG_LONG)
+# undef LZO_SIZEOF_LONG_LONG
+#elif defined(_NO_LONGLONG)
+# undef LZO_SIZEOF_LONG_LONG
+#endif
+#if !defined(LZO_WORDSIZE)
+#if (LZO_ARCH_ALPHA)
+# define LZO_WORDSIZE 8
+#elif (LZO_ARCH_AMD64)
+# define LZO_WORDSIZE 8
+#elif (LZO_ARCH_AVR)
+# define LZO_WORDSIZE 1
+#elif (LZO_ARCH_H8300)
+# if defined(__NORMAL_MODE__)
+# define LZO_WORDSIZE 4
+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+# define LZO_WORDSIZE 4
+# else
+# define LZO_WORDSIZE 2
+# endif
+#elif (LZO_ARCH_I086)
+# define LZO_WORDSIZE 2
+#elif (LZO_ARCH_IA64)
+# define LZO_WORDSIZE 8
+#elif (LZO_ARCH_M16C)
+# define LZO_WORDSIZE 2
+#elif (LZO_ARCH_SPU)
+# define LZO_WORDSIZE 4
+#elif (LZO_ARCH_Z80)
+# define LZO_WORDSIZE 1
+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
+# define LZO_WORDSIZE 8
+#elif (LZO_OS_OS400 || defined(__OS400__))
+# define LZO_WORDSIZE 8
+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
+# define LZO_WORDSIZE 8
+#endif
+#endif
+#if !defined(LZO_SIZEOF_VOID_P)
+#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4)
+# define LZO_SIZEOF_VOID_P 4
+#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8)
+# define LZO_SIZEOF_VOID_P 8
+#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4)
+# define LZO_SIZEOF_VOID_P 8
+#elif defined(__LP64__) || defined(__LP64) || defined(_LP64)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8)
+# define LZO_SIZEOF_VOID_P 8
+#elif (LZO_ARCH_AVR)
+# define LZO_SIZEOF_VOID_P 2
+#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430)
+# define LZO_SIZEOF_VOID_P 2
+#elif (LZO_ARCH_H8300)
+# if defined(__NORMAL_MODE__)
+# define LZO_SIZEOF_VOID_P 2
+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
+# define LZO_SIZEOF_VOID_P 4
+# else
+# define LZO_SIZEOF_VOID_P 2
+# endif
+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4)
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT
+# endif
+#elif (LZO_ARCH_I086)
+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
+# define LZO_SIZEOF_VOID_P 2
+# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
+# define LZO_SIZEOF_VOID_P 4
+# else
+# error "invalid LZO_ARCH_I086 memory model"
+# endif
+#elif (LZO_ARCH_M16C)
+# if defined(__m32c_cpu__) || defined(__m32cm_cpu__)
+# define LZO_SIZEOF_VOID_P 4
+# else
+# define LZO_SIZEOF_VOID_P 2
+# endif
+#elif (LZO_ARCH_SPU)
+# define LZO_SIZEOF_VOID_P 4
+#elif (LZO_ARCH_Z80)
+# define LZO_SIZEOF_VOID_P 2
+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
+# define LZO_SIZEOF_VOID_P 4
+#elif (LZO_OS_OS400 || defined(__OS400__))
+# if defined(__LLP64_IFC__)
+# define LZO_SIZEOF_VOID_P 8
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
+# else
+# define LZO_SIZEOF_VOID_P 16
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
+# endif
+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
+# define LZO_SIZEOF_VOID_P 8
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
+#endif
+#endif
+#if !defined(LZO_SIZEOF_VOID_P)
+# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
+#endif
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *))
+#if !defined(LZO_SIZEOF_SIZE_T)
+#if (LZO_ARCH_I086 || LZO_ARCH_M16C)
+# define LZO_SIZEOF_SIZE_T 2
+#endif
+#endif
+#if !defined(LZO_SIZEOF_SIZE_T)
+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P
+#endif
+#if defined(offsetof)
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t))
+#endif
+#if !defined(LZO_SIZEOF_PTRDIFF_T)
+#if (LZO_ARCH_I086)
+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE)
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P
+# elif (LZO_MM_COMPACT || LZO_MM_LARGE)
+# if (LZO_CC_BORLANDC || LZO_CC_TURBOC)
+# define LZO_SIZEOF_PTRDIFF_T 4
+# else
+# define LZO_SIZEOF_PTRDIFF_T 2
+# endif
+# else
+# error "invalid LZO_ARCH_I086 memory model"
+# endif
+#endif
+#endif
+#if !defined(LZO_SIZEOF_PTRDIFF_T)
+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T
+#endif
+#if defined(offsetof)
+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
+#endif
+#if !defined(LZO_WORDSIZE)
+# define LZO_WORDSIZE LZO_SIZEOF_VOID_P
+#endif
+#if (LZO_ABI_NEUTRAL_ENDIAN)
+# undef LZO_ABI_BIG_ENDIAN
+# undef LZO_ABI_LITTLE_ENDIAN
+#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN)
+#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__)
+# if (__LITTLE_ENDIAN__ == 1)
+# define LZO_ABI_LITTLE_ENDIAN 1
+# else
+# define LZO_ABI_BIG_ENDIAN 1
+# endif
+#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC)
+# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN)
+# error "unexpected configuration - check your compiler defines"
+# elif defined(__BIG_ENDIAN)
+# define LZO_ABI_BIG_ENDIAN 1
+# else
+# define LZO_ABI_LITTLE_ENDIAN 1
+# endif
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__)
+# define LZO_ABI_BIG_ENDIAN 1
+#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__)
+# define LZO_ABI_LITTLE_ENDIAN 1
+#endif
+#endif
+#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN)
+# error "unexpected configuration - check your compiler defines"
+#endif
+#if (LZO_ABI_BIG_ENDIAN)
+# define LZO_INFO_ABI_ENDIAN "be"
+#elif (LZO_ABI_LITTLE_ENDIAN)
+# define LZO_INFO_ABI_ENDIAN "le"
+#elif (LZO_ABI_NEUTRAL_ENDIAN)
+# define LZO_INFO_ABI_ENDIAN "neutral"
+#endif
+#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
+# define LZO_ABI_I8LP16 1
+# define LZO_INFO_ABI_PM "i8lp16"
+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
+# define LZO_ABI_ILP16 1
+# define LZO_INFO_ABI_PM "ilp16"
+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
+# define LZO_ABI_LP32 1
+# define LZO_INFO_ABI_PM "lp32"
+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
+# define LZO_ABI_ILP32 1
+# define LZO_INFO_ABI_PM "ilp32"
+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8)
+# define LZO_ABI_LLP64 1
+# define LZO_INFO_ABI_PM "llp64"
+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
+# define LZO_ABI_LP64 1
+# define LZO_INFO_ABI_PM "lp64"
+#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
+# define LZO_ABI_ILP64 1
+# define LZO_INFO_ABI_PM "ilp64"
+#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4)
+# define LZO_ABI_IP32L64 1
+# define LZO_INFO_ABI_PM "ip32l64"
+#endif
+#if 0
+#elif !defined(__LZO_LIBC_OVERRIDE)
+#if (LZO_LIBC_NAKED)
+# define LZO_INFO_LIBC "naked"
+#elif (LZO_LIBC_FREESTANDING)
+# define LZO_INFO_LIBC "freestanding"
+#elif (LZO_LIBC_MOSTLY_FREESTANDING)
+# define LZO_INFO_LIBC "mfreestanding"
+#elif (LZO_LIBC_ISOC90)
+# define LZO_INFO_LIBC "isoc90"
+#elif (LZO_LIBC_ISOC99)
+# define LZO_INFO_LIBC "isoc99"
+#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION)
+# define LZO_LIBC_ISOC90 1
+# define LZO_INFO_LIBC "isoc90"
+#elif defined(__dietlibc__)
+# define LZO_LIBC_DIETLIBC 1
+# define LZO_INFO_LIBC "dietlibc"
+#elif defined(_NEWLIB_VERSION)
+# define LZO_LIBC_NEWLIB 1
+# define LZO_INFO_LIBC "newlib"
+#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
+# if defined(__UCLIBC_SUBLEVEL__)
+# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0))
+# else
+# define LZO_LIBC_UCLIBC 0x00090bL
+# endif
+# define LZO_INFO_LIBC "uc" "libc"
+#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)
+# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100)
+# define LZO_INFO_LIBC "glibc"
+#elif (LZO_CC_MWERKS) && defined(__MSL__)
+# define LZO_LIBC_MSL __MSL__
+# define LZO_INFO_LIBC "msl"
+#elif 1 && defined(__IAR_SYSTEMS_ICC__)
+# define LZO_LIBC_ISOC90 1
+# define LZO_INFO_LIBC "isoc90"
+#else
+# define LZO_LIBC_DEFAULT 1
+# define LZO_INFO_LIBC "default"
+#endif
+#endif
+#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
+# define LZO_ASM_SYNTAX_MSC 1
+#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
+#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul))
+#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
+# define LZO_ASM_SYNTAX_GNUC 1
+#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
+# define LZO_ASM_SYNTAX_GNUC 1
+#elif (LZO_CC_GNUC)
+# define LZO_ASM_SYNTAX_GNUC 1
+#endif
+#if (LZO_ASM_SYNTAX_GNUC)
+#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
+# define __LZO_ASM_CLOBBER "ax"
+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/
+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/
+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/
+#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000))
+# define __LZO_ASM_CLOBBER "memory"
+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/
+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory"
+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/
+#else
+# define __LZO_ASM_CLOBBER "cc", "memory"
+# define __LZO_ASM_CLOBBER_LIST_CC : "cc"
+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory"
+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/
+#endif
+#endif
+#if (LZO_ARCH_ALPHA)
+# define LZO_OPT_AVOID_UINT_INDEX 1
+#elif (LZO_ARCH_AMD64)
+# define LZO_OPT_AVOID_INT_INDEX 1
+# define LZO_OPT_AVOID_UINT_INDEX 1
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# ifndef LZO_OPT_UNALIGNED64
+# define LZO_OPT_UNALIGNED64 1
+# endif
+#elif (LZO_ARCH_ARM)
+# if defined(__ARM_FEATURE_UNALIGNED)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# endif
+#elif (LZO_ARCH_ARM64)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# ifndef LZO_OPT_UNALIGNED64
+# define LZO_OPT_UNALIGNED64 1
+# endif
+#elif (LZO_ARCH_CRIS)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+#elif (LZO_ARCH_I386)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+#elif (LZO_ARCH_IA64)
+# define LZO_OPT_AVOID_INT_INDEX 1
+# define LZO_OPT_AVOID_UINT_INDEX 1
+# define LZO_OPT_PREFER_POSTINC 1
+#elif (LZO_ARCH_M68K)
+# define LZO_OPT_PREFER_POSTINC 1
+# define LZO_OPT_PREFER_PREDEC 1
+# if defined(__mc68020__) && !defined(__mcoldfire__)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# endif
+#elif (LZO_ARCH_MIPS)
+# define LZO_OPT_AVOID_UINT_INDEX 1
+#elif (LZO_ARCH_POWERPC)
+# define LZO_OPT_PREFER_PREINC 1
+# define LZO_OPT_PREFER_PREDEC 1
+# if (LZO_ABI_BIG_ENDIAN)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# if (LZO_WORDSIZE == 8)
+# ifndef LZO_OPT_UNALIGNED64
+# define LZO_OPT_UNALIGNED64 1
+# endif
+# endif
+# endif
+#elif (LZO_ARCH_S390)
+# ifndef LZO_OPT_UNALIGNED16
+# define LZO_OPT_UNALIGNED16 1
+# endif
+# ifndef LZO_OPT_UNALIGNED32
+# define LZO_OPT_UNALIGNED32 1
+# endif
+# if (LZO_WORDSIZE == 8)
+# ifndef LZO_OPT_UNALIGNED64
+# define LZO_OPT_UNALIGNED64 1
+# endif
+# endif
+#elif (LZO_ARCH_SH)
+# define LZO_OPT_PREFER_POSTINC 1
+# define LZO_OPT_PREFER_PREDEC 1
+#endif
+#ifndef LZO_CFG_NO_INLINE_ASM
+#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC)
+# define LZO_CFG_NO_INLINE_ASM 1
+#elif (LZO_CC_LLVM)
+# define LZO_CFG_NO_INLINE_ASM 1
+#endif
+#endif
+#if (LZO_CFG_NO_INLINE_ASM)
+# undef LZO_ASM_SYNTAX_MSC
+# undef LZO_ASM_SYNTAX_GNUC
+# undef __LZO_ASM_CLOBBER
+# undef __LZO_ASM_CLOBBER_LIST_CC
+# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY
+# undef __LZO_ASM_CLOBBER_LIST_EMPTY
+#endif
+#ifndef LZO_CFG_NO_UNALIGNED
+#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC)
+# define LZO_CFG_NO_UNALIGNED 1
+#endif
+#endif
+#if (LZO_CFG_NO_UNALIGNED)
+# undef LZO_OPT_UNALIGNED16
+# undef LZO_OPT_UNALIGNED32
+# undef LZO_OPT_UNALIGNED64
+#endif
+#if defined(__LZO_INFOSTR_MM)
+#elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM))
+# define __LZO_INFOSTR_MM ""
+#elif defined(LZO_INFO_MM)
+# define __LZO_INFOSTR_MM "." LZO_INFO_MM
+#else
+# define __LZO_INFOSTR_MM ""
+#endif
+#if defined(__LZO_INFOSTR_PM)
+#elif defined(LZO_INFO_ABI_PM)
+# define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM
+#else
+# define __LZO_INFOSTR_PM ""
+#endif
+#if defined(__LZO_INFOSTR_ENDIAN)
+#elif defined(LZO_INFO_ABI_ENDIAN)
+# define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN
+#else
+# define __LZO_INFOSTR_ENDIAN ""
+#endif
+#if defined(__LZO_INFOSTR_OSNAME)
+#elif defined(LZO_INFO_OS_CONSOLE)
+# define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE
+#elif defined(LZO_INFO_OS_POSIX)
+# define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX
+#else
+# define __LZO_INFOSTR_OSNAME LZO_INFO_OS
+#endif
+#if defined(__LZO_INFOSTR_LIBC)
+#elif defined(LZO_INFO_LIBC)
+# define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC
+#else
+# define __LZO_INFOSTR_LIBC ""
+#endif
+#if defined(__LZO_INFOSTR_CCVER)
+#elif defined(LZO_INFO_CCVER)
+# define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER
+#else
+# define __LZO_INFOSTR_CCVER ""
+#endif
+#define LZO_INFO_STRING \
+ LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \
+ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER
+#if !(LZO_CFG_SKIP_LZO_TYPES)
+#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0))
+# error "missing defines for sizes"
+#endif
+#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0))
+# error "missing defines for sizes"
+#endif
+#if !defined(lzo_llong_t)
+#if (LZO_SIZEOF_LONG_LONG+0 > 0)
+__lzo_gnuc_extension__ typedef long long lzo_llong_t__;
+__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
+# define lzo_llong_t lzo_llong_t__
+# define lzo_ullong_t lzo_ullong_t__
+#endif
+#endif
+#if !defined(lzo_int16e_t)
+#if (LZO_SIZEOF_LONG == 2)
+# define lzo_int16e_t long
+# define lzo_uint16e_t unsigned long
+#elif (LZO_SIZEOF_INT == 2)
+# define lzo_int16e_t int
+# define lzo_uint16e_t unsigned int
+#elif (LZO_SIZEOF_SHORT == 2)
+# define lzo_int16e_t short int
+# define lzo_uint16e_t unsigned short int
+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM)
+ typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__)));
+ typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__)));
+# define lzo_int16e_t lzo_int16e_hi_t__
+# define lzo_uint16e_t lzo_uint16e_hi_t__
+#elif (LZO_SIZEOF___INT16 == 2)
+# define lzo_int16e_t __int16
+# define lzo_uint16e_t unsigned __int16
+#else
+#endif
+#endif
+#if defined(lzo_int16e_t)
+# define LZO_SIZEOF_LZO_INT16E_T 2
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T)
+#endif
+#if !defined(lzo_int32e_t)
+#if (LZO_SIZEOF_LONG == 4)
+# define lzo_int32e_t long int
+# define lzo_uint32e_t unsigned long int
+#elif (LZO_SIZEOF_INT == 4)
+# define lzo_int32e_t int
+# define lzo_uint32e_t unsigned int
+#elif (LZO_SIZEOF_SHORT == 4)
+# define lzo_int32e_t short int
+# define lzo_uint32e_t unsigned short int
+#elif (LZO_SIZEOF_LONG_LONG == 4)
+# define lzo_int32e_t lzo_llong_t
+# define lzo_uint32e_t lzo_ullong_t
+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L)
+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__)));
+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
+# define lzo_int32e_t lzo_int32e_si_t__
+# define lzo_uint32e_t lzo_uint32e_si_t__
+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L)
+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__)));
+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
+# define lzo_int32e_t lzo_int32e_si_t__
+# define lzo_uint32e_t lzo_uint32e_si_t__
+# define LZO_INT32_C(c) (c##LL)
+# define LZO_UINT32_C(c) (c##ULL)
+#elif (LZO_SIZEOF___INT32 == 4)
+# define lzo_int32e_t __int32
+# define lzo_uint32e_t unsigned __int32
+#else
+#endif
+#endif
+#if defined(lzo_int32e_t)
+# define LZO_SIZEOF_LZO_INT32E_T 4
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T)
+#endif
+#if !defined(lzo_int64e_t)
+#if (LZO_SIZEOF___INT64 == 8)
+# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64)
+# define LZO_CFG_TYPE_PREFER___INT64 1
+# endif
+#endif
+#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
+# define lzo_int64e_t int
+# define lzo_uint64e_t unsigned int
+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT
+#elif (LZO_SIZEOF_LONG == 8)
+# define lzo_int64e_t long int
+# define lzo_uint64e_t unsigned long int
+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG
+#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64)
+# define lzo_int64e_t lzo_llong_t
+# define lzo_uint64e_t lzo_ullong_t
+# if (LZO_CC_BORLANDC)
+# define LZO_INT64_C(c) ((c) + 0ll)
+# define LZO_UINT64_C(c) ((c) + 0ull)
+# elif 0
+# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL))
+# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL))
+# else
+# define LZO_INT64_C(c) (c##LL)
+# define LZO_UINT64_C(c) (c##ULL)
+# endif
+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG
+#elif (LZO_SIZEOF___INT64 == 8)
+# define lzo_int64e_t __int64
+# define lzo_uint64e_t unsigned __int64
+# if (LZO_CC_BORLANDC)
+# define LZO_INT64_C(c) ((c) + 0i64)
+# define LZO_UINT64_C(c) ((c) + 0ui64)
+# else
+# define LZO_INT64_C(c) (c##i64)
+# define LZO_UINT64_C(c) (c##ui64)
+# endif
+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64
+#else
+#endif
+#endif
+#if defined(lzo_int64e_t)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T)
+#endif
+#if !defined(lzo_int32l_t)
+#if defined(lzo_int32e_t)
+# define lzo_int32l_t lzo_int32e_t
+# define lzo_uint32l_t lzo_uint32e_t
+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T
+#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
+# define lzo_int32l_t int
+# define lzo_uint32l_t unsigned int
+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT
+#elif (LZO_SIZEOF_LONG >= 4)
+# define lzo_int32l_t long int
+# define lzo_uint32l_t unsigned long int
+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG
+#else
+# error "lzo_int32l_t"
+#endif
+#endif
+#if 1
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T)
+#endif
+#if !defined(lzo_int64l_t)
+#if defined(lzo_int64e_t)
+# define lzo_int64l_t lzo_int64e_t
+# define lzo_uint64l_t lzo_uint64e_t
+# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T
+#else
+#endif
+#endif
+#if defined(lzo_int64l_t)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T)
+#endif
+#if !defined(lzo_int32f_t)
+#if (LZO_SIZEOF_SIZE_T >= 8)
+# define lzo_int32f_t lzo_int64l_t
+# define lzo_uint32f_t lzo_uint64l_t
+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T
+#else
+# define lzo_int32f_t lzo_int32l_t
+# define lzo_uint32f_t lzo_uint32l_t
+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T
+#endif
+#endif
+#if 1
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T)
+#endif
+#if !defined(lzo_int64f_t)
+#if defined(lzo_int64l_t)
+# define lzo_int64f_t lzo_int64l_t
+# define lzo_uint64f_t lzo_uint64l_t
+# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T
+#else
+#endif
+#endif
+#if defined(lzo_int64f_t)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T)
+#endif
+#if !defined(lzo_intptr_t)
+#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16))
+# define __LZO_INTPTR_T_IS_POINTER 1
+ typedef char* lzo_intptr_t;
+ typedef char* lzo_uintptr_t;
+# define lzo_intptr_t lzo_intptr_t
+# define lzo_uintptr_t lzo_uintptr_t
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P
+#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4))
+ typedef __w64 int lzo_intptr_t;
+ typedef __w64 unsigned int lzo_uintptr_t;
+# define lzo_intptr_t lzo_intptr_t
+# define lzo_uintptr_t lzo_uintptr_t
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT
+#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P)
+# define lzo_intptr_t short
+# define lzo_uintptr_t unsigned short
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT
+#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
+# define lzo_intptr_t int
+# define lzo_uintptr_t unsigned int
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT
+#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P)
+# define lzo_intptr_t long
+# define lzo_uintptr_t unsigned long
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG
+#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P)
+# define lzo_intptr_t lzo_int64l_t
+# define lzo_uintptr_t lzo_uint64l_t
+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T
+#else
+# error "lzo_intptr_t"
+#endif
+#endif
+#if 1
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *))
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t))
+#endif
+#if !defined(lzo_word_t)
+#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0)
+#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER)
+# define lzo_word_t lzo_uintptr_t
+# define lzo_sword_t lzo_intptr_t
+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T
+#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG)
+# define lzo_word_t unsigned long
+# define lzo_sword_t long
+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG
+#elif (LZO_WORDSIZE == LZO_SIZEOF_INT)
+# define lzo_word_t unsigned int
+# define lzo_sword_t int
+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT
+#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT)
+# define lzo_word_t unsigned short
+# define lzo_sword_t short
+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT
+#elif (LZO_WORDSIZE == 1)
+# define lzo_word_t unsigned char
+# define lzo_sword_t signed char
+# define LZO_SIZEOF_LZO_WORD_T 1
+#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T)
+# define lzo_word_t lzo_uint64l_t
+# define lzo_sword_t lzo_int64l_t
+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T
+#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC)
+#if 0
+ typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__)));
+ typedef int lzo_sword_t __attribute__((__mode__(__V16QI__)));
+# define lzo_word_t lzo_word_t
+# define lzo_sword_t lzo_sword_t
+# define LZO_SIZEOF_LZO_WORD_T 16
+#endif
+#else
+# error "lzo_word_t"
+#endif
+#endif
+#endif
+#if 1 && defined(lzo_word_t)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE)
+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE)
+#endif
+#if 1
+#define lzo_int8_t signed char
+#define lzo_uint8_t unsigned char
+#define LZO_SIZEOF_LZO_INT8_T 1
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t))
+#endif
+#if defined(lzo_int16e_t)
+#define lzo_int16_t lzo_int16e_t
+#define lzo_uint16_t lzo_uint16e_t
+#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t))
+#endif
+#if defined(lzo_int32e_t)
+#define lzo_int32_t lzo_int32e_t
+#define lzo_uint32_t lzo_uint32e_t
+#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t))
+#endif
+#if defined(lzo_int64e_t)
+#define lzo_int64_t lzo_int64e_t
+#define lzo_uint64_t lzo_uint64e_t
+#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t))
+#endif
+#if 1
+#define lzo_int_least32_t lzo_int32l_t
+#define lzo_uint_least32_t lzo_uint32l_t
+#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t))
+#endif
+#if defined(lzo_int64l_t)
+#define lzo_int_least64_t lzo_int64l_t
+#define lzo_uint_least64_t lzo_uint64l_t
+#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t))
+#endif
+#if 1
+#define lzo_int_fast32_t lzo_int32f_t
+#define lzo_uint_fast32_t lzo_uint32f_t
+#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t))
+#endif
+#if defined(lzo_int64f_t)
+#define lzo_int_fast64_t lzo_int64f_t
+#define lzo_uint_fast64_t lzo_uint64f_t
+#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t))
+#endif
+#if !defined(LZO_INT16_C)
+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2)
+# define LZO_INT16_C(c) ((c) + 0)
+# define LZO_UINT16_C(c) ((c) + 0U)
+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2)
+# define LZO_INT16_C(c) ((c) + 0L)
+# define LZO_UINT16_C(c) ((c) + 0UL)
+# elif (LZO_SIZEOF_INT >= 2)
+# define LZO_INT16_C(c) (c)
+# define LZO_UINT16_C(c) (c##U)
+# elif (LZO_SIZEOF_LONG >= 2)
+# define LZO_INT16_C(c) (c##L)
+# define LZO_UINT16_C(c) (c##UL)
+# else
+# error "LZO_INT16_C"
+# endif
+#endif
+#if !defined(LZO_INT32_C)
+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4)
+# define LZO_INT32_C(c) ((c) + 0)
+# define LZO_UINT32_C(c) ((c) + 0U)
+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4)
+# define LZO_INT32_C(c) ((c) + 0L)
+# define LZO_UINT32_C(c) ((c) + 0UL)
+# elif (LZO_SIZEOF_INT >= 4)
+# define LZO_INT32_C(c) (c)
+# define LZO_UINT32_C(c) (c##U)
+# elif (LZO_SIZEOF_LONG >= 4)
+# define LZO_INT32_C(c) (c##L)
+# define LZO_UINT32_C(c) (c##UL)
+# elif (LZO_SIZEOF_LONG_LONG >= 4)
+# define LZO_INT32_C(c) (c##LL)
+# define LZO_UINT32_C(c) (c##ULL)
+# else
+# error "LZO_INT32_C"
+# endif
+#endif
+#if !defined(LZO_INT64_C) && defined(lzo_int64l_t)
+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8)
+# define LZO_INT64_C(c) ((c) + 0)
+# define LZO_UINT64_C(c) ((c) + 0U)
+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8)
+# define LZO_INT64_C(c) ((c) + 0L)
+# define LZO_UINT64_C(c) ((c) + 0UL)
+# elif (LZO_SIZEOF_INT >= 8)
+# define LZO_INT64_C(c) (c)
+# define LZO_UINT64_C(c) (c##U)
+# elif (LZO_SIZEOF_LONG >= 8)
+# define LZO_INT64_C(c) (c##L)
+# define LZO_UINT64_C(c) (c##UL)
+# else
+# error "LZO_INT64_C"
+# endif
+#endif
+#endif
+
+#endif
+
+#endif
+
+#undef LZO_HAVE_CONFIG_H
+#include "minilzo.h"
+
+#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2080)
+# error "version mismatch in miniLZO source files"
+#endif
+
+#ifdef MINILZO_HAVE_CONFIG_H
+# define LZO_HAVE_CONFIG_H 1
+#endif
+
+#ifndef __LZO_CONF_H
+#define __LZO_CONF_H 1
+
+#if !defined(__LZO_IN_MINILZO)
+#if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING)
+# define LZO_LIBC_FREESTANDING 1
+# define LZO_OS_FREESTANDING 1
+#endif
+#if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
+# include LZO_CFG_EXTRA_CONFIG_HEADER
+#endif
+#if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
+# error "include this file first"
+#endif
+#include "lzo/lzoconf.h"
+#if defined(LZO_CFG_EXTRA_CONFIG_HEADER2)
+# include LZO_CFG_EXTRA_CONFIG_HEADER2
+#endif
+#endif
+
+#if (LZO_VERSION < 0x2080) || !defined(__LZOCONF_H_INCLUDED)
+# error "version mismatch"
+#endif
+
+#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100))
+# pragma warning(disable: 4702)
+#endif
+#if (LZO_CC_MSC && (_MSC_VER >= 1000))
+# pragma warning(disable: 4127 4701)
+# pragma warning(disable: 4514 4710 4711)
+#endif
+#if (LZO_CC_MSC && (_MSC_VER >= 1300))
+# pragma warning(disable: 4820)
+#endif
+#if (LZO_CC_MSC && (_MSC_VER >= 1800))
+# pragma warning(disable: 4746)
+#endif
+
+#if (LZO_CC_SUNPROC)
+#if !defined(__cplusplus)
+# pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
+# pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
+# pragma error_messages(off,E_STATEMENT_NOT_REACHED)
+#endif
+#endif
+
+#if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING)
+#elif 1
+# include <string.h>
+#else
+# define LZO_WANT_ACC_INCD_H 1
+#endif
+#if defined(LZO_HAVE_CONFIG_H)
+# define LZO_CFG_NO_CONFIG_HEADER 1
+#endif
+
+#if 1 && !defined(LZO_CFG_FREESTANDING)
+#if 1 && !defined(HAVE_STRING_H)
+#define HAVE_STRING_H 1
+#endif
+#if 1 && !defined(HAVE_MEMCMP)
+#define HAVE_MEMCMP 1
+#endif
+#if 1 && !defined(HAVE_MEMCPY)
+#define HAVE_MEMCPY 1
+#endif
+#if 1 && !defined(HAVE_MEMMOVE)
+#define HAVE_MEMMOVE 1
+#endif
+#if 1 && !defined(HAVE_MEMSET)
+#define HAVE_MEMSET 1
+#endif
+#endif
+
+#if 1 && defined(HAVE_STRING_H)
+#include <string.h>
+#endif
+
+#if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1)
+#endif
+#if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2)
+#endif
+#if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4)
+#endif
+#if defined(lzo_int64_t) || defined(lzo_uint64_t)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8)
+#endif
+
+#if (LZO_CFG_FREESTANDING)
+# undef HAVE_MEMCMP
+# undef HAVE_MEMCPY
+# undef HAVE_MEMMOVE
+# undef HAVE_MEMSET
+#endif
+
+#if !(HAVE_MEMCMP)
+# undef memcmp
+# define memcmp(a,b,c) lzo_memcmp(a,b,c)
+#else
+# undef lzo_memcmp
+# define lzo_memcmp(a,b,c) memcmp(a,b,c)
+#endif
+#if !(HAVE_MEMCPY)
+# undef memcpy
+# define memcpy(a,b,c) lzo_memcpy(a,b,c)
+#else
+# undef lzo_memcpy
+# define lzo_memcpy(a,b,c) memcpy(a,b,c)
+#endif
+#if !(HAVE_MEMMOVE)
+# undef memmove
+# define memmove(a,b,c) lzo_memmove(a,b,c)
+#else
+# undef lzo_memmove
+# define lzo_memmove(a,b,c) memmove(a,b,c)
+#endif
+#if !(HAVE_MEMSET)
+# undef memset
+# define memset(a,b,c) lzo_memset(a,b,c)
+#else
+# undef lzo_memset
+# define lzo_memset(a,b,c) memset(a,b,c)
+#endif
+
+#undef NDEBUG
+#if (LZO_CFG_FREESTANDING)
+# undef LZO_DEBUG
+# define NDEBUG 1
+# undef assert
+# define assert(e) ((void)0)
+#else
+# if !defined(LZO_DEBUG)
+# define NDEBUG 1
+# endif
+# include <assert.h>
+#endif
+
+#if 0 && defined(__BOUNDS_CHECKING_ON)
+# include <unchecked.h>
+#else
+# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
+# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
+#endif
+
+#if (LZO_CFG_PGO)
+# undef __lzo_likely
+# undef __lzo_unlikely
+# define __lzo_likely(e) (e)
+# define __lzo_unlikely(e) (e)
+#endif
+
+#undef _
+#undef __
+#undef ___
+#undef ____
+#undef _p0
+#undef _p1
+#undef _p2
+#undef _p3
+#undef _p4
+#undef _s0
+#undef _s1
+#undef _s2
+#undef _s3
+#undef _s4
+#undef _ww
+
+#if 1
+# define LZO_BYTE(x) ((unsigned char) (x))
+#else
+# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
+#endif
+
+#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
+#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
+#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
+#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
+
+#define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
+
+#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
+
+#define LZO_SIZE(bits) (1u << (bits))
+#define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
+
+#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
+#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
+
+#if !defined(DMUL)
+#if 0
+
+# define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b)))
+#else
+# define DMUL(a,b) ((lzo_xint) ((a) * (b)))
+#endif
+#endif
+
+#ifndef __LZO_FUNC_H
+#define __LZO_FUNC_H 1
+
+#if !defined(LZO_BITOPS_USE_ASM_BITSCAN) && !defined(LZO_BITOPS_USE_GNUC_BITSCAN) && !defined(LZO_BITOPS_USE_MSC_BITSCAN)
+#if 1 && (LZO_ARCH_AMD64) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_ASM_SYNTAX_GNUC)
+#define LZO_BITOPS_USE_ASM_BITSCAN 1
+#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul))))
+#define LZO_BITOPS_USE_GNUC_BITSCAN 1
+#elif (LZO_OS_WIN32 || LZO_OS_WIN64) && ((LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1010)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
+#define LZO_BITOPS_USE_MSC_BITSCAN 1
+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
+#include <intrin.h>
+#endif
+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
+#pragma intrinsic(_BitScanReverse)
+#pragma intrinsic(_BitScanForward)
+#endif
+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64)
+#pragma intrinsic(_BitScanReverse64)
+#pragma intrinsic(_BitScanForward64)
+#endif
+#endif
+#endif
+
+__lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v)
+{
+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
+ unsigned long r; (void) _BitScanReverse(&r, v); return (unsigned) r ^ 31;
+#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v)
+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
+ lzo_uint32_t r;
+ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC);
+ return (unsigned) r ^ 31;
+#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v)
+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4)
+ unsigned r; r = (unsigned) __builtin_clz(v); return r;
+#define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v))
+#else
+ LZO_UNUSED(v); return 0;
+#endif
+}
+
+#if defined(lzo_uint64_t)
+__lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v)
+{
+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64)
+ unsigned long r; (void) _BitScanReverse64(&r, v); return (unsigned) r ^ 63;
+#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v)
+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC)
+ lzo_uint64_t r;
+ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC);
+ return (unsigned) r ^ 63;
+#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v)
+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8)
+ unsigned r; r = (unsigned) __builtin_clzl(v); return r;
+#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v))
+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8)
+ unsigned r; r = (unsigned) __builtin_clzll(v); return r;
+#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v))
+#else
+ LZO_UNUSED(v); return 0;
+#endif
+}
+#endif
+
+__lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v)
+{
+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
+ unsigned long r; (void) _BitScanForward(&r, v); return (unsigned) r;
+#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v)
+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
+ lzo_uint32_t r;
+ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC);
+ return (unsigned) r;
+#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v)
+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4)
+ unsigned r; r = (unsigned) __builtin_ctz(v); return r;
+#define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v))
+#else
+ LZO_UNUSED(v); return 0;
+#endif
+}
+
+#if defined(lzo_uint64_t)
+__lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v)
+{
+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64)
+ unsigned long r; (void) _BitScanForward64(&r, v); return (unsigned) r;
+#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v)
+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC)
+ lzo_uint64_t r;
+ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC);
+ return (unsigned) r;
+#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v)
+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8)
+ unsigned r; r = (unsigned) __builtin_ctzl(v); return r;
+#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v))
+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8)
+ unsigned r; r = (unsigned) __builtin_ctzll(v); return r;
+#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v))
+#else
+ LZO_UNUSED(v); return 0;
+#endif
+}
+#endif
+
+#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
+static void __attribute__((__unused__))
+#else
+__lzo_static_forceinline void
+#endif
+lzo_bitops_unused_funcs(void)
+{
+ LZO_UNUSED_FUNC(lzo_bitops_ctlz32_func);
+ LZO_UNUSED_FUNC(lzo_bitops_cttz32_func);
+#if defined(lzo_uint64_t)
+ LZO_UNUSED_FUNC(lzo_bitops_ctlz64_func);
+ LZO_UNUSED_FUNC(lzo_bitops_cttz64_func);
+#endif
+ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs);
+}
+
+#if defined(__lzo_alignof) && !(LZO_CFG_NO_UNALIGNED)
+#ifndef __lzo_memops_tcheck
+#define __lzo_memops_tcheck(t,a,b) ((void)0, sizeof(t) == (a) && __lzo_alignof(t) == (b))
+#endif
+#endif
+#ifndef lzo_memops_TU0p
+#define lzo_memops_TU0p void __LZO_MMODEL *
+#endif
+#ifndef lzo_memops_TU1p
+#define lzo_memops_TU1p unsigned char __LZO_MMODEL *
+#endif
+#ifndef lzo_memops_TU2p
+#if (LZO_OPT_UNALIGNED16)
+typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2;
+#define lzo_memops_TU2p volatile lzo_memops_TU2 *
+#elif defined(__lzo_byte_struct)
+__lzo_byte_struct(lzo_memops_TU2_struct,2)
+typedef struct lzo_memops_TU2_struct lzo_memops_TU2;
+#else
+struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias;
+typedef struct lzo_memops_TU2_struct lzo_memops_TU2;
+#endif
+#ifndef lzo_memops_TU2p
+#define lzo_memops_TU2p lzo_memops_TU2 *
+#endif
+#endif
+#ifndef lzo_memops_TU4p
+#if (LZO_OPT_UNALIGNED32)
+typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4;
+#define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL *
+#elif defined(__lzo_byte_struct)
+__lzo_byte_struct(lzo_memops_TU4_struct,4)
+typedef struct lzo_memops_TU4_struct lzo_memops_TU4;
+#else
+struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias;
+typedef struct lzo_memops_TU4_struct lzo_memops_TU4;
+#endif
+#ifndef lzo_memops_TU4p
+#define lzo_memops_TU4p lzo_memops_TU4 __LZO_MMODEL *
+#endif
+#endif
+#ifndef lzo_memops_TU8p
+#if (LZO_OPT_UNALIGNED64)
+typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8;
+#define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL *
+#elif defined(__lzo_byte_struct)
+__lzo_byte_struct(lzo_memops_TU8_struct,8)
+typedef struct lzo_memops_TU8_struct lzo_memops_TU8;
+#else
+struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias;
+typedef struct lzo_memops_TU8_struct lzo_memops_TU8;
+#endif
+#ifndef lzo_memops_TU8p
+#define lzo_memops_TU8p lzo_memops_TU8 __LZO_MMODEL *
+#endif
+#endif
+#ifndef lzo_memops_set_TU1p
+#define lzo_memops_set_TU1p volatile lzo_memops_TU1p
+#endif
+#ifndef lzo_memops_move_TU1p
+#define lzo_memops_move_TU1p lzo_memops_TU1p
+#endif
+#define LZO_MEMOPS_SET1(dd,cc) \
+ LZO_BLOCK_BEGIN \
+ lzo_memops_set_TU1p d__1 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \
+ d__1[0] = LZO_BYTE(cc); \
+ LZO_BLOCK_END
+#define LZO_MEMOPS_SET2(dd,cc) \
+ LZO_BLOCK_BEGIN \
+ lzo_memops_set_TU1p d__2 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \
+ d__2[0] = LZO_BYTE(cc); d__2[1] = LZO_BYTE(cc); \
+ LZO_BLOCK_END
+#define LZO_MEMOPS_SET3(dd,cc) \
+ LZO_BLOCK_BEGIN \
+ lzo_memops_set_TU1p d__3 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \
+ d__3[0] = LZO_BYTE(cc); d__3[1] = LZO_BYTE(cc); d__3[2] = LZO_BYTE(cc); \
+ LZO_BLOCK_END
+#define LZO_MEMOPS_SET4(dd,cc) \
+ LZO_BLOCK_BEGIN \
+ lzo_memops_set_TU1p d__4 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \
+ d__4[0] = LZO_BYTE(cc); d__4[1] = LZO_BYTE(cc); d__4[2] = LZO_BYTE(cc); d__4[3] = LZO_BYTE(cc); \
+ LZO_BLOCK_END
+#define LZO_MEMOPS_MOVE1(dd,ss) \
+ LZO_BLOCK_BEGIN \
+ lzo_memops_move_TU1p d__1 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \
+ const lzo_memops_move_TU1p s__1 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \
+ d__1[0] = s__1[0]; \
+ LZO_BLOCK_END
+#define LZO_MEMOPS_MOVE2(dd,ss) \
+ LZO_BLOCK_BEGIN \
+ lzo_memops_move_TU1p d__2 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \
+ const lzo_memops_move_TU1p s__2 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \
+ d__2[0] = s__2[0]; d__2[1] = s__2[1]; \
+ LZO_BLOCK_END
+#define LZO_MEMOPS_MOVE3(dd,ss) \
+ LZO_BLOCK_BEGIN \
+ lzo_memops_move_TU1p d__3 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \
+ const lzo_memops_move_TU1p s__3 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \
+ d__3[0] = s__3[0]; d__3[1] = s__3[1]; d__3[2] = s__3[2]; \
+ LZO_BLOCK_END
+#define LZO_MEMOPS_MOVE4(dd,ss) \
+ LZO_BLOCK_BEGIN \
+ lzo_memops_move_TU1p d__4 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \
+ const lzo_memops_move_TU1p s__4 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \
+ d__4[0] = s__4[0]; d__4[1] = s__4[1]; d__4[2] = s__4[2]; d__4[3] = s__4[3]; \
+ LZO_BLOCK_END
+#define LZO_MEMOPS_MOVE8(dd,ss) \
+ LZO_BLOCK_BEGIN \
+ lzo_memops_move_TU1p d__8 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \
+ const lzo_memops_move_TU1p s__8 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \
+ d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \
+ d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \
+ LZO_BLOCK_END
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0)==1)
+#define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss)
+#if (LZO_OPT_UNALIGNED16)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2)
+#define LZO_MEMOPS_COPY2(dd,ss) \
+ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss)
+#elif defined(__lzo_memops_tcheck)
+#define LZO_MEMOPS_COPY2(dd,ss) \
+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU2,2,1)) { \
+ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss); \
+ } else { LZO_MEMOPS_MOVE2(dd,ss); } LZO_BLOCK_END
+#else
+#define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss)
+#endif
+#if (LZO_OPT_UNALIGNED32)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4)
+#define LZO_MEMOPS_COPY4(dd,ss) \
+ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss)
+#elif defined(__lzo_memops_tcheck)
+#define LZO_MEMOPS_COPY4(dd,ss) \
+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU4,4,1)) { \
+ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss); \
+ } else { LZO_MEMOPS_MOVE4(dd,ss); } LZO_BLOCK_END
+#else
+#define LZO_MEMOPS_COPY4(dd,ss) LZO_MEMOPS_MOVE4(dd,ss)
+#endif
+#if (LZO_WORDSIZE != 8)
+#define LZO_MEMOPS_COPY8(dd,ss) \
+ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END
+#else
+#if (LZO_OPT_UNALIGNED64)
+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8)
+#define LZO_MEMOPS_COPY8(dd,ss) \
+ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss)
+#elif (LZO_OPT_UNALIGNED32)
+#define LZO_MEMOPS_COPY8(dd,ss) \
+ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END
+#elif defined(__lzo_memops_tcheck)
+#define LZO_MEMOPS_COPY8(dd,ss) \
+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU8,8,1)) { \
+ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss); \
+ } else { LZO_MEMOPS_MOVE8(dd,ss); } LZO_BLOCK_END
+#else
+#define LZO_MEMOPS_COPY8(dd,ss) LZO_MEMOPS_MOVE8(dd,ss)
+#endif
+#endif
+#define LZO_MEMOPS_COPYN(dd,ss,nn) \
+ LZO_BLOCK_BEGIN \
+ lzo_memops_TU1p d__n = (lzo_memops_TU1p) (lzo_memops_TU0p) (dd); \
+ const lzo_memops_TU1p s__n = (const lzo_memops_TU1p) (const lzo_memops_TU0p) (ss); \
+ lzo_uint n__n = (nn); \
+ while ((void)0, n__n >= 8) { LZO_MEMOPS_COPY8(d__n, s__n); d__n += 8; s__n += 8; n__n -= 8; } \
+ if ((void)0, n__n >= 4) { LZO_MEMOPS_COPY4(d__n, s__n); d__n += 4; s__n += 4; n__n -= 4; } \
+ if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \
+ LZO_BLOCK_END
+
+__lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss)
+{
+ lzo_uint16_t v;
+#if (LZO_ABI_LITTLE_ENDIAN)
+ LZO_MEMOPS_COPY2(&v, ss);
+#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
+ const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss;
+ unsigned long vv;
+ __asm__("lhbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s));
+ v = (lzo_uint16_t) vv;
+#else
+ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss;
+ v = (lzo_uint16_t) (((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8));
+#endif
+ return v;
+}
+#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
+#define LZO_MEMOPS_GET_LE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss)
+#else
+#define LZO_MEMOPS_GET_LE16(ss) lzo_memops_get_le16(ss)
+#endif
+
+__lzo_static_forceinline lzo_uint32_t lzo_memops_get_le32(const lzo_voidp ss)
+{
+ lzo_uint32_t v;
+#if (LZO_ABI_LITTLE_ENDIAN)
+ LZO_MEMOPS_COPY4(&v, ss);
+#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
+ const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss;
+ unsigned long vv;
+ __asm__("lwbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s));
+ v = (lzo_uint32_t) vv;
+#else
+ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss;
+ v = (lzo_uint32_t) (((lzo_uint32_t)s[0]) | ((lzo_uint32_t)s[1] << 8) | ((lzo_uint32_t)s[2] << 16) | ((lzo_uint32_t)s[3] << 24));
+#endif
+ return v;
+}
+#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN)
+#define LZO_MEMOPS_GET_LE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss)
+#else
+#define LZO_MEMOPS_GET_LE32(ss) lzo_memops_get_le32(ss)
+#endif
+
+#if (LZO_OPT_UNALIGNED64) && (LZO_ABI_LITTLE_ENDIAN)
+#define LZO_MEMOPS_GET_LE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss)
+#endif
+
+__lzo_static_forceinline lzo_uint16_t lzo_memops_get_ne16(const lzo_voidp ss)
+{
+ lzo_uint16_t v;
+ LZO_MEMOPS_COPY2(&v, ss);
+ return v;
+}
+#if (LZO_OPT_UNALIGNED16)
+#define LZO_MEMOPS_GET_NE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss)
+#else
+#define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss)
+#endif
+
+__lzo_static_forceinline lzo_uint32_t lzo_memops_get_ne32(const lzo_voidp ss)
+{
+ lzo_uint32_t v;
+ LZO_MEMOPS_COPY4(&v, ss);
+ return v;
+}
+#if (LZO_OPT_UNALIGNED32)
+#define LZO_MEMOPS_GET_NE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss)
+#else
+#define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss)
+#endif
+
+#if (LZO_OPT_UNALIGNED64)
+#define LZO_MEMOPS_GET_NE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss)
+#endif
+
+__lzo_static_forceinline void lzo_memops_put_le16(lzo_voidp dd, lzo_uint16_t vv)
+{
+#if (LZO_ABI_LITTLE_ENDIAN)
+ LZO_MEMOPS_COPY2(dd, &vv);
+#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
+ lzo_memops_TU2p d = (lzo_memops_TU2p) dd;
+ unsigned long v = vv;
+ __asm__("sthbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v));
+#else
+ lzo_memops_TU1p d = (lzo_memops_TU1p) dd;
+ d[0] = LZO_BYTE((vv ) & 0xff);
+ d[1] = LZO_BYTE((vv >> 8) & 0xff);
+#endif
+}
+#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
+#define LZO_MEMOPS_PUT_LE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv))
+#else
+#define LZO_MEMOPS_PUT_LE16(dd,vv) lzo_memops_put_le16(dd,vv)
+#endif
+
+__lzo_static_forceinline void lzo_memops_put_le32(lzo_voidp dd, lzo_uint32_t vv)
+{
+#if (LZO_ABI_LITTLE_ENDIAN)
+ LZO_MEMOPS_COPY4(dd, &vv);
+#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
+ lzo_memops_TU4p d = (lzo_memops_TU4p) dd;
+ unsigned long v = vv;
+ __asm__("stwbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v));
+#else
+ lzo_memops_TU1p d = (lzo_memops_TU1p) dd;
+ d[0] = LZO_BYTE((vv ) & 0xff);
+ d[1] = LZO_BYTE((vv >> 8) & 0xff);
+ d[2] = LZO_BYTE((vv >> 16) & 0xff);
+ d[3] = LZO_BYTE((vv >> 24) & 0xff);
+#endif
+}
+#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN)
+#define LZO_MEMOPS_PUT_LE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv))
+#else
+#define LZO_MEMOPS_PUT_LE32(dd,vv) lzo_memops_put_le32(dd,vv)
+#endif
+
+__lzo_static_forceinline void lzo_memops_put_ne16(lzo_voidp dd, lzo_uint16_t vv)
+{
+ LZO_MEMOPS_COPY2(dd, &vv);
+}
+#if (LZO_OPT_UNALIGNED16)
+#define LZO_MEMOPS_PUT_NE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv))
+#else
+#define LZO_MEMOPS_PUT_NE16(dd,vv) lzo_memops_put_ne16(dd,vv)
+#endif
+
+__lzo_static_forceinline void lzo_memops_put_ne32(lzo_voidp dd, lzo_uint32_t vv)
+{
+ LZO_MEMOPS_COPY4(dd, &vv);
+}
+#if (LZO_OPT_UNALIGNED32)
+#define LZO_MEMOPS_PUT_NE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv))
+#else
+#define LZO_MEMOPS_PUT_NE32(dd,vv) lzo_memops_put_ne32(dd,vv)
+#endif
+
+#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
+static void __attribute__((__unused__))
+#else
+__lzo_static_forceinline void
+#endif
+lzo_memops_unused_funcs(void)
+{
+ LZO_UNUSED_FUNC(lzo_memops_get_le16);
+ LZO_UNUSED_FUNC(lzo_memops_get_le32);
+ LZO_UNUSED_FUNC(lzo_memops_get_ne16);
+ LZO_UNUSED_FUNC(lzo_memops_get_ne32);
+ LZO_UNUSED_FUNC(lzo_memops_put_le16);
+ LZO_UNUSED_FUNC(lzo_memops_put_le32);
+ LZO_UNUSED_FUNC(lzo_memops_put_ne16);
+ LZO_UNUSED_FUNC(lzo_memops_put_ne32);
+ LZO_UNUSED_FUNC(lzo_memops_unused_funcs);
+}
+
+#endif
+
+#ifndef UA_SET1
+#define UA_SET1 LZO_MEMOPS_SET1
+#endif
+#ifndef UA_SET2
+#define UA_SET2 LZO_MEMOPS_SET2
+#endif
+#ifndef UA_SET3
+#define UA_SET3 LZO_MEMOPS_SET3
+#endif
+#ifndef UA_SET4
+#define UA_SET4 LZO_MEMOPS_SET4
+#endif
+#ifndef UA_MOVE1
+#define UA_MOVE1 LZO_MEMOPS_MOVE1
+#endif
+#ifndef UA_MOVE2
+#define UA_MOVE2 LZO_MEMOPS_MOVE2
+#endif
+#ifndef UA_MOVE3
+#define UA_MOVE3 LZO_MEMOPS_MOVE3
+#endif
+#ifndef UA_MOVE4
+#define UA_MOVE4 LZO_MEMOPS_MOVE4
+#endif
+#ifndef UA_MOVE8
+#define UA_MOVE8 LZO_MEMOPS_MOVE8
+#endif
+#ifndef UA_COPY1
+#define UA_COPY1 LZO_MEMOPS_COPY1
+#endif
+#ifndef UA_COPY2
+#define UA_COPY2 LZO_MEMOPS_COPY2
+#endif
+#ifndef UA_COPY3
+#define UA_COPY3 LZO_MEMOPS_COPY3
+#endif
+#ifndef UA_COPY4
+#define UA_COPY4 LZO_MEMOPS_COPY4
+#endif
+#ifndef UA_COPY8
+#define UA_COPY8 LZO_MEMOPS_COPY8
+#endif
+#ifndef UA_COPYN
+#define UA_COPYN LZO_MEMOPS_COPYN
+#endif
+#ifndef UA_COPYN_X
+#define UA_COPYN_X LZO_MEMOPS_COPYN
+#endif
+#ifndef UA_GET_LE16
+#define UA_GET_LE16 LZO_MEMOPS_GET_LE16
+#endif
+#ifndef UA_GET_LE32
+#define UA_GET_LE32 LZO_MEMOPS_GET_LE32
+#endif
+#ifdef LZO_MEMOPS_GET_LE64
+#ifndef UA_GET_LE64
+#define UA_GET_LE64 LZO_MEMOPS_GET_LE64
+#endif
+#endif
+#ifndef UA_GET_NE16
+#define UA_GET_NE16 LZO_MEMOPS_GET_NE16
+#endif
+#ifndef UA_GET_NE32
+#define UA_GET_NE32 LZO_MEMOPS_GET_NE32
+#endif
+#ifdef LZO_MEMOPS_GET_NE64
+#ifndef UA_GET_NE64
+#define UA_GET_NE64 LZO_MEMOPS_GET_NE64
+#endif
+#endif
+#ifndef UA_PUT_LE16
+#define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16
+#endif
+#ifndef UA_PUT_LE32
+#define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32
+#endif
+#ifndef UA_PUT_NE16
+#define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16
+#endif
+#ifndef UA_PUT_NE32
+#define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32
+#endif
+
+#define MEMCPY8_DS(dest,src,len) \
+ lzo_memcpy(dest,src,len); dest += len; src += len
+
+#define BZERO8_PTR(s,l,n) \
+ lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
+
+#define MEMCPY_DS(dest,src,len) \
+ do *dest++ = *src++; while (--len > 0)
+
+LZO_EXTERN(const lzo_bytep) lzo_copyright(void);
+
+#ifndef __LZO_PTR_H
+#define __LZO_PTR_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if (LZO_ARCH_I086)
+#error "LZO_ARCH_I086 is unsupported"
+#elif (LZO_MM_PVP)
+#error "LZO_MM_PVP is unsupported"
+#else
+#define PTR(a) ((lzo_uintptr_t) (a))
+#define PTR_LINEAR(a) PTR(a)
+#define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0)
+#define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0)
+#define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
+#define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
+#endif
+
+#define PTR_LT(a,b) (PTR(a) < PTR(b))
+#define PTR_GE(a,b) (PTR(a) >= PTR(b))
+#define PTR_DIFF(a,b) (PTR(a) - PTR(b))
+#define pd(a,b) ((lzo_uint) ((a)-(b)))
+
+LZO_EXTERN(lzo_uintptr_t)
+__lzo_ptr_linear(const lzo_voidp ptr);
+
+typedef union
+{
+ char a_char;
+ unsigned char a_uchar;
+ short a_short;
+ unsigned short a_ushort;
+ int a_int;
+ unsigned int a_uint;
+ long a_long;
+ unsigned long a_ulong;
+ lzo_int a_lzo_int;
+ lzo_uint a_lzo_uint;
+ lzo_xint a_lzo_xint;
+ lzo_int16_t a_lzo_int16_t;
+ lzo_uint16_t a_lzo_uint16_t;
+ lzo_int32_t a_lzo_int32_t;
+ lzo_uint32_t a_lzo_uint32_t;
+#if defined(lzo_uint64_t)
+ lzo_int64_t a_lzo_int64_t;
+ lzo_uint64_t a_lzo_uint64_t;
+#endif
+ size_t a_size_t;
+ ptrdiff_t a_ptrdiff_t;
+ lzo_uintptr_t a_lzo_uintptr_t;
+ void * a_void_p;
+ char * a_char_p;
+ unsigned char * a_uchar_p;
+ const void * a_c_void_p;
+ const char * a_c_char_p;
+ const unsigned char * a_c_uchar_p;
+ lzo_voidp a_lzo_voidp;
+ lzo_bytep a_lzo_bytep;
+ const lzo_voidp a_c_lzo_voidp;
+ const lzo_bytep a_c_lzo_bytep;
+}
+lzo_full_align_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+#ifndef LZO_DETERMINISTIC
+#define LZO_DETERMINISTIC 1
+#endif
+
+#ifndef LZO_DICT_USE_PTR
+#define LZO_DICT_USE_PTR 1
+#endif
+
+#if (LZO_DICT_USE_PTR)
+# define lzo_dict_t const lzo_bytep
+# define lzo_dict_p lzo_dict_t *
+#else
+# define lzo_dict_t lzo_uint
+# define lzo_dict_p lzo_dict_t *
+#endif
+
+#endif
+
+#if !defined(MINILZO_CFG_SKIP_LZO_PTR)
+
+LZO_PUBLIC(lzo_uintptr_t)
+__lzo_ptr_linear(const lzo_voidp ptr)
+{
+ lzo_uintptr_t p;
+
+#if (LZO_ARCH_I086)
+#error "LZO_ARCH_I086 is unsupported"
+#elif (LZO_MM_PVP)
+#error "LZO_MM_PVP is unsupported"
+#else
+ p = (lzo_uintptr_t) PTR_LINEAR(ptr);
+#endif
+
+ return p;
+}
+
+LZO_PUBLIC(unsigned)
+__lzo_align_gap(const lzo_voidp ptr, lzo_uint size)
+{
+#if (__LZO_UINTPTR_T_IS_POINTER)
+#error "__LZO_UINTPTR_T_IS_POINTER is unsupported"
+#else
+ lzo_uintptr_t p, n;
+ p = __lzo_ptr_linear(ptr);
+ n = (((p + size - 1) / size) * size) - p;
+#endif
+
+ assert(size > 0);
+ assert((long)n >= 0);
+ assert(n <= size);
+ return (unsigned)n;
+}
+
+#endif
+#if !defined(MINILZO_CFG_SKIP_LZO_UTIL)
+
+/* If you use the LZO library in a product, I would appreciate that you
+ * keep this copyright string in the executable of your product.
+ */
+
+static const char __lzo_copyright[] =
+#if !defined(__LZO_IN_MINLZO)
+ LZO_VERSION_STRING;
+#else
+ "\r\n\n"
+ "LZO data compression library.\n"
+ "$Copyright: LZO Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\n"
+ "<markus@oberhumer.com>\n"
+ "http://www.oberhumer.com $\n\n"
+ "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n"
+ "$Info: " LZO_INFO_STRING " $\n";
+#endif
+
+LZO_PUBLIC(const lzo_bytep)
+lzo_copyright(void)
+{
+ return (const lzo_bytep) __lzo_copyright;
+}
+
+LZO_PUBLIC(unsigned)
+lzo_version(void)
+{
+ return LZO_VERSION;
+}
+
+LZO_PUBLIC(const char *)
+lzo_version_string(void)
+{
+ return LZO_VERSION_STRING;
+}
+
+LZO_PUBLIC(const char *)
+lzo_version_date(void)
+{
+ return LZO_VERSION_DATE;
+}
+
+LZO_PUBLIC(const lzo_charp)
+_lzo_version_string(void)
+{
+ return LZO_VERSION_STRING;
+}
+
+LZO_PUBLIC(const lzo_charp)
+_lzo_version_date(void)
+{
+ return LZO_VERSION_DATE;
+}
+
+#define LZO_BASE 65521u
+#define LZO_NMAX 5552
+
+#define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1
+#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1)
+#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2)
+#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4)
+#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8)
+
+LZO_PUBLIC(lzo_uint32_t)
+lzo_adler32(lzo_uint32_t adler, const lzo_bytep buf, lzo_uint len)
+{
+ lzo_uint32_t s1 = adler & 0xffff;
+ lzo_uint32_t s2 = (adler >> 16) & 0xffff;
+ unsigned k;
+
+ if (buf == NULL)
+ return 1;
+
+ while (len > 0)
+ {
+ k = len < LZO_NMAX ? (unsigned) len : LZO_NMAX;
+ len -= k;
+ if (k >= 16) do
+ {
+ LZO_DO16(buf,0);
+ buf += 16;
+ k -= 16;
+ } while (k >= 16);
+ if (k != 0) do
+ {
+ s1 += *buf++;
+ s2 += s1;
+ } while (--k > 0);
+ s1 %= LZO_BASE;
+ s2 %= LZO_BASE;
+ }
+ return (s2 << 16) | s1;
+}
+
+#undef LZO_DO1
+#undef LZO_DO2
+#undef LZO_DO4
+#undef LZO_DO8
+#undef LZO_DO16
+
+#endif
+#if !defined(MINILZO_CFG_SKIP_LZO_STRING)
+#undef lzo_memcmp
+#undef lzo_memcpy
+#undef lzo_memmove
+#undef lzo_memset
+#if !defined(__LZO_MMODEL_HUGE)
+# undef LZO_HAVE_MM_HUGE_PTR
+#endif
+#define lzo_hsize_t lzo_uint
+#define lzo_hvoid_p lzo_voidp
+#define lzo_hbyte_p lzo_bytep
+#define LZOLIB_PUBLIC(r,f) LZO_PUBLIC(r) f
+#define lzo_hmemcmp lzo_memcmp
+#define lzo_hmemcpy lzo_memcpy
+#define lzo_hmemmove lzo_memmove
+#define lzo_hmemset lzo_memset
+#define __LZOLIB_HMEMCPY_CH_INCLUDED 1
+#if !defined(LZOLIB_PUBLIC)
+# define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f)
+#endif
+LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len)
+{
+#if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP)
+ const lzo_hbyte_p p1 = LZO_STATIC_CAST(const lzo_hbyte_p, s1);
+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, s2);
+ if __lzo_likely(len > 0) do
+ {
+ int d = *p1 - *p2;
+ if (d != 0)
+ return d;
+ p1++; p2++;
+ } while __lzo_likely(--len > 0);
+ return 0;
+#else
+ return memcmp(s1, s2, len);
+#endif
+}
+LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len)
+{
+#if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY)
+ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest);
+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src);
+ if (!(len > 0) || p1 == p2)
+ return dest;
+ do
+ *p1++ = *p2++;
+ while __lzo_likely(--len > 0);
+ return dest;
+#else
+ return memcpy(dest, src, len);
+#endif
+}
+LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len)
+{
+#if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE)
+ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest);
+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src);
+ if (!(len > 0) || p1 == p2)
+ return dest;
+ if (p1 < p2)
+ {
+ do
+ *p1++ = *p2++;
+ while __lzo_likely(--len > 0);
+ }
+ else
+ {
+ p1 += len;
+ p2 += len;
+ do
+ *--p1 = *--p2;
+ while __lzo_likely(--len > 0);
+ }
+ return dest;
+#else
+ return memmove(dest, src, len);
+#endif
+}
+LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int cc, lzo_hsize_t len)
+{
+#if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET)
+ lzo_hbyte_p p = LZO_STATIC_CAST(lzo_hbyte_p, s);
+ unsigned char c = LZO_ITRUNC(unsigned char, cc);
+ if __lzo_likely(len > 0) do
+ *p++ = c;
+ while __lzo_likely(--len > 0);
+ return s;
+#else
+ return memset(s, cc, len);
+#endif
+}
+#undef LZOLIB_PUBLIC
+#endif
+#if !defined(MINILZO_CFG_SKIP_LZO_INIT)
+
+#if !defined(__LZO_IN_MINILZO)
+
+#define LZO_WANT_ACC_CHK_CH 1
+#undef LZOCHK_ASSERT
+
+ LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0)
+ LZOCHK_ASSERT_IS_SIGNED_T(lzo_int)
+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint)
+#if !(__LZO_UINTPTR_T_IS_POINTER)
+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t)
+#endif
+ LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp))
+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint)
+
+#endif
+#undef LZOCHK_ASSERT
+
+union lzo_config_check_union {
+ lzo_uint a[2];
+ unsigned char b[2*LZO_MAX(8,sizeof(lzo_uint))];
+#if defined(lzo_uint64_t)
+ lzo_uint64_t c[2];
+#endif
+};
+
+#if 0
+#define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off)))
+#else
+static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off)
+{
+ return (lzo_voidp) ((lzo_bytep) ptr + off);
+}
+#endif
+
+LZO_PUBLIC(int)
+_lzo_config_check(void)
+{
+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030100ul && LZO_CC_CLANG < 0x030300ul))
+# if 0
+ volatile
+# endif
+#endif
+ union lzo_config_check_union u;
+ lzo_voidp p;
+ unsigned r = 1;
+
+ u.a[0] = u.a[1] = 0;
+ p = u2p(&u, 0);
+ r &= ((* (lzo_bytep) p) == 0);
+#if !(LZO_CFG_NO_CONFIG_CHECK)
+#if (LZO_ABI_BIG_ENDIAN)
+ u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128;
+ p = u2p(&u, 0);
+ r &= ((* (lzo_uintp) p) == 128);
+#endif
+#if (LZO_ABI_LITTLE_ENDIAN)
+ u.a[0] = u.a[1] = 0; u.b[0] = 128;
+ p = u2p(&u, 0);
+ r &= ((* (lzo_uintp) p) == 128);
+#endif
+ u.a[0] = u.a[1] = 0;
+ u.b[0] = 1; u.b[3] = 2;
+ p = u2p(&u, 1);
+ r &= UA_GET_NE16(p) == 0;
+ r &= UA_GET_LE16(p) == 0;
+ u.b[1] = 128;
+ r &= UA_GET_LE16(p) == 128;
+ u.b[2] = 129;
+ r &= UA_GET_LE16(p) == LZO_UINT16_C(0x8180);
+#if (LZO_ABI_BIG_ENDIAN)
+ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8081);
+#endif
+#if (LZO_ABI_LITTLE_ENDIAN)
+ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8180);
+#endif
+ u.a[0] = u.a[1] = 0;
+ u.b[0] = 3; u.b[5] = 4;
+ p = u2p(&u, 1);
+ r &= UA_GET_NE32(p) == 0;
+ r &= UA_GET_LE32(p) == 0;
+ u.b[1] = 128;
+ r &= UA_GET_LE32(p) == 128;
+ u.b[2] = 129; u.b[3] = 130; u.b[4] = 131;
+ r &= UA_GET_LE32(p) == LZO_UINT32_C(0x83828180);
+#if (LZO_ABI_BIG_ENDIAN)
+ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x80818283);
+#endif
+#if (LZO_ABI_LITTLE_ENDIAN)
+ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x83828180);
+#endif
+#if defined(UA_GET_NE64)
+ u.c[0] = u.c[1] = 0;
+ u.b[0] = 5; u.b[9] = 6;
+ p = u2p(&u, 1);
+ u.c[0] = u.c[1] = 0;
+ r &= UA_GET_NE64(p) == 0;
+#if defined(UA_GET_LE64)
+ r &= UA_GET_LE64(p) == 0;
+ u.b[1] = 128;
+ r &= UA_GET_LE64(p) == 128;
+#endif
+#endif
+#if defined(lzo_bitops_ctlz32)
+ { unsigned i = 0; lzo_uint32_t v;
+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) {
+ r &= lzo_bitops_ctlz32(v) == 31 - i;
+ r &= lzo_bitops_ctlz32_func(v) == 31 - i;
+ }}
+#endif
+#if defined(lzo_bitops_ctlz64)
+ { unsigned i = 0; lzo_uint64_t v;
+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) {
+ r &= lzo_bitops_ctlz64(v) == 63 - i;
+ r &= lzo_bitops_ctlz64_func(v) == 63 - i;
+ }}
+#endif
+#if defined(lzo_bitops_cttz32)
+ { unsigned i = 0; lzo_uint32_t v;
+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) {
+ r &= lzo_bitops_cttz32(v) == i;
+ r &= lzo_bitops_cttz32_func(v) == i;
+ }}
+#endif
+#if defined(lzo_bitops_cttz64)
+ { unsigned i = 0; lzo_uint64_t v;
+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) {
+ r &= lzo_bitops_cttz64(v) == i;
+ r &= lzo_bitops_cttz64_func(v) == i;
+ }}
+#endif
+#endif
+ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs);
+
+ return r == 1 ? LZO_E_OK : LZO_E_ERROR;
+}
+
+LZO_PUBLIC(int)
+__lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5,
+ int s6, int s7, int s8, int s9)
+{
+ int r;
+
+#if defined(__LZO_IN_MINILZO)
+#elif (LZO_CC_MSC && ((_MSC_VER) < 700))
+#else
+#define LZO_WANT_ACC_CHK_CH 1
+#undef LZOCHK_ASSERT
+#define LZOCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr)
+#endif
+#undef LZOCHK_ASSERT
+
+ if (v == 0)
+ return LZO_E_ERROR;
+
+ r = (s1 == -1 || s1 == (int) sizeof(short)) &&
+ (s2 == -1 || s2 == (int) sizeof(int)) &&
+ (s3 == -1 || s3 == (int) sizeof(long)) &&
+ (s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) &&
+ (s5 == -1 || s5 == (int) sizeof(lzo_uint)) &&
+ (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) &&
+ (s7 == -1 || s7 == (int) sizeof(char *)) &&
+ (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) &&
+ (s9 == -1 || s9 == (int) sizeof(lzo_callback_t));
+ if (!r)
+ return LZO_E_ERROR;
+
+ r = _lzo_config_check();
+ if (r != LZO_E_OK)
+ return r;
+
+ return r;
+}
+
+#if !defined(__LZO_IN_MINILZO)
+
+#if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD)
+
+#if 0
+BOOL FAR PASCAL LibMain ( HANDLE hInstance, WORD wDataSegment,
+ WORD wHeapSize, LPSTR lpszCmdLine )
+#else
+int __far __pascal LibMain ( int a, short b, short c, long d )
+#endif
+{
+ LZO_UNUSED(a); LZO_UNUSED(b); LZO_UNUSED(c); LZO_UNUSED(d);
+ return 1;
+}
+
+#endif
+
+#endif
+
+#endif
+
+#define LZO1X 1
+#define LZO_EOF_CODE 1
+#define M2_MAX_OFFSET 0x0800
+
+#if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS)
+
+#if 1 && defined(UA_GET_LE32)
+#undef LZO_DICT_USE_PTR
+#define LZO_DICT_USE_PTR 0
+#undef lzo_dict_t
+#define lzo_dict_t lzo_uint16_t
+#endif
+
+#define LZO_NEED_DICT_H 1
+#ifndef D_BITS
+#define D_BITS 14
+#endif
+#define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
+#define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
+#if 1
+#define DINDEX(dv,p) DM(((DMUL(0x1824429d,dv)) >> (32-D_BITS)))
+#else
+#define DINDEX(dv,p) DM((dv) + ((dv) >> (32-D_BITS)))
+#endif
+
+#ifndef __LZO_CONFIG1X_H
+#define __LZO_CONFIG1X_H 1
+
+#if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z)
+# define LZO1X 1
+#endif
+
+#if !defined(__LZO_IN_MINILZO)
+#include "lzo/lzo1x.h"
+#endif
+
+#ifndef LZO_EOF_CODE
+#define LZO_EOF_CODE 1
+#endif
+#undef LZO_DETERMINISTIC
+
+#define M1_MAX_OFFSET 0x0400
+#ifndef M2_MAX_OFFSET
+#define M2_MAX_OFFSET 0x0800
+#endif
+#define M3_MAX_OFFSET 0x4000
+#define M4_MAX_OFFSET 0xbfff
+
+#define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
+
+#define M1_MIN_LEN 2
+#define M1_MAX_LEN 2
+#define M2_MIN_LEN 3
+#ifndef M2_MAX_LEN
+#define M2_MAX_LEN 8
+#endif
+#define M3_MIN_LEN 3
+#define M3_MAX_LEN 33
+#define M4_MIN_LEN 3
+#define M4_MAX_LEN 9
+
+#define M1_MARKER 0
+#define M2_MARKER 64
+#define M3_MARKER 32
+#define M4_MARKER 16
+
+#ifndef MIN_LOOKAHEAD
+#define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
+#endif
+
+#if defined(LZO_NEED_DICT_H)
+
+#ifndef LZO_HASH
+#define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B
+#endif
+#define DL_MIN_LEN M2_MIN_LEN
+
+#ifndef __LZO_DICT_H
+#define __LZO_DICT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(D_BITS) && defined(DBITS)
+# define D_BITS DBITS
+#endif
+#if !defined(D_BITS)
+# error "D_BITS is not defined"
+#endif
+#if (D_BITS < 16)
+# define D_SIZE LZO_SIZE(D_BITS)
+# define D_MASK LZO_MASK(D_BITS)
+#else
+# define D_SIZE LZO_USIZE(D_BITS)
+# define D_MASK LZO_UMASK(D_BITS)
+#endif
+#define D_HIGH ((D_MASK >> 1) + 1)
+
+#if !defined(DD_BITS)
+# define DD_BITS 0
+#endif
+#define DD_SIZE LZO_SIZE(DD_BITS)
+#define DD_MASK LZO_MASK(DD_BITS)
+
+#if !defined(DL_BITS)
+# define DL_BITS (D_BITS - DD_BITS)
+#endif
+#if (DL_BITS < 16)
+# define DL_SIZE LZO_SIZE(DL_BITS)
+# define DL_MASK LZO_MASK(DL_BITS)
+#else
+# define DL_SIZE LZO_USIZE(DL_BITS)
+# define DL_MASK LZO_UMASK(DL_BITS)
+#endif
+
+#if (D_BITS != DL_BITS + DD_BITS)
+# error "D_BITS does not match"
+#endif
+#if (D_BITS < 6 || D_BITS > 18)
+# error "invalid D_BITS"
+#endif
+#if (DL_BITS < 6 || DL_BITS > 20)
+# error "invalid DL_BITS"
+#endif
+#if (DD_BITS < 0 || DD_BITS > 6)
+# error "invalid DD_BITS"
+#endif
+
+#if !defined(DL_MIN_LEN)
+# define DL_MIN_LEN 3
+#endif
+#if !defined(DL_SHIFT)
+# define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN)
+#endif
+
+#define LZO_HASH_GZIP 1
+#define LZO_HASH_GZIP_INCREMENTAL 2
+#define LZO_HASH_LZO_INCREMENTAL_A 3
+#define LZO_HASH_LZO_INCREMENTAL_B 4
+
+#if !defined(LZO_HASH)
+# error "choose a hashing strategy"
+#endif
+
+#undef DM
+#undef DX
+
+#if (DL_MIN_LEN == 3)
+# define _DV2_A(p,shift1,shift2) \
+ (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
+# define _DV2_B(p,shift1,shift2) \
+ (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
+# define _DV3_B(p,shift1,shift2,shift3) \
+ ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
+#elif (DL_MIN_LEN == 2)
+# define _DV2_A(p,shift1,shift2) \
+ (( (lzo_xint)(p[0]) << shift1) ^ p[1])
+# define _DV2_B(p,shift1,shift2) \
+ (( (lzo_xint)(p[1]) << shift1) ^ p[2])
+#else
+# error "invalid DL_MIN_LEN"
+#endif
+#define _DV_A(p,shift) _DV2_A(p,shift,shift)
+#define _DV_B(p,shift) _DV2_B(p,shift,shift)
+#define DA2(p,s1,s2) \
+ (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
+#define DS2(p,s1,s2) \
+ (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
+#define DX2(p,s1,s2) \
+ (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
+#define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
+#define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
+#define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
+#define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s)))
+#define DM(v) DMS(v,0)
+
+#if (LZO_HASH == LZO_HASH_GZIP)
+# define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
+
+#elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
+# define __LZO_HASH_INCREMENTAL 1
+# define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
+# define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
+# define _DINDEX(dv,p) (dv)
+# define DVAL_LOOKAHEAD DL_MIN_LEN
+
+#elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
+# define __LZO_HASH_INCREMENTAL 1
+# define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
+# define DVAL_NEXT(dv,p) \
+ dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
+# define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
+# define DVAL_LOOKAHEAD DL_MIN_LEN
+
+#elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
+# define __LZO_HASH_INCREMENTAL 1
+# define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
+# define DVAL_NEXT(dv,p) \
+ dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5)))
+# define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
+# define DVAL_LOOKAHEAD DL_MIN_LEN
+
+#else
+# error "choose a hashing strategy"
+#endif
+
+#ifndef DINDEX
+#define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS)
+#endif
+#if !defined(DINDEX1) && defined(D_INDEX1)
+#define DINDEX1 D_INDEX1
+#endif
+#if !defined(DINDEX2) && defined(D_INDEX2)
+#define DINDEX2 D_INDEX2
+#endif
+
+#if !defined(__LZO_HASH_INCREMENTAL)
+# define DVAL_FIRST(dv,p) ((void) 0)
+# define DVAL_NEXT(dv,p) ((void) 0)
+# define DVAL_LOOKAHEAD 0
+#endif
+
+#if !defined(DVAL_ASSERT)
+#if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
+#if (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_LLVM)
+static void __attribute__((__unused__))
+#else
+static void
+#endif
+DVAL_ASSERT(lzo_xint dv, const lzo_bytep p)
+{
+ lzo_xint df;
+ DVAL_FIRST(df,(p));
+ assert(DINDEX(dv,p) == DINDEX(df,p));
+}
+#else
+# define DVAL_ASSERT(dv,p) ((void) 0)
+#endif
+#endif
+
+#if (LZO_DICT_USE_PTR)
+# define DENTRY(p,in) (p)
+# define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
+#else
+# define DENTRY(p,in) ((lzo_dict_t) pd(p, in))
+# define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex]
+#endif
+
+#if (DD_BITS == 0)
+
+# define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in)
+# define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
+# define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in)
+
+#else
+
+# define UPDATE_D(dict,drun,dv,p,in) \
+ dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
+# define UPDATE_I(dict,drun,index,p,in) \
+ dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
+# define UPDATE_P(ptr,drun,p,in) \
+ (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
+
+#endif
+
+#if (LZO_DICT_USE_PTR)
+
+#define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
+ (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset)
+
+#define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
+ (BOUNDS_CHECKING_OFF_IN_EXPR(( \
+ m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \
+ PTR_LT(m_pos,in) || \
+ (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) == 0 || \
+ m_off > max_offset )))
+
+#else
+
+#define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
+ (m_off == 0 || \
+ ((m_off = pd(ip, in) - m_off) > max_offset) || \
+ (m_pos = (ip) - (m_off), 0) )
+
+#define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
+ (pd(ip, in) <= m_off || \
+ ((m_off = pd(ip, in) - m_off) > max_offset) || \
+ (m_pos = (ip) - (m_off), 0) )
+
+#endif
+
+#if (LZO_DETERMINISTIC)
+# define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET
+#else
+# define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+#endif
+
+#endif
+
+#define LZO_DETERMINISTIC !(LZO_DICT_USE_PTR)
+
+#ifndef DO_COMPRESS
+#define DO_COMPRESS lzo1x_1_compress
+#endif
+
+#if 1 && defined(DO_COMPRESS) && !defined(do_compress)
+# define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core)
+#endif
+
+static __lzo_noinline lzo_uint
+do_compress ( const lzo_bytep in , lzo_uint in_len,
+ lzo_bytep out, lzo_uintp out_len,
+ lzo_uint ti, lzo_voidp wrkmem)
+{
+ const lzo_bytep ip;
+ lzo_bytep op;
+ const lzo_bytep const in_end = in + in_len;
+ const lzo_bytep const ip_end = in + in_len - 20;
+ const lzo_bytep ii;
+ lzo_dict_p const dict = (lzo_dict_p) wrkmem;
+
+ op = out;
+ ip = in;
+ ii = ip;
+
+ ip += ti < 4 ? 4 - ti : 0;
+ for (;;)
+ {
+ const lzo_bytep m_pos;
+#if !(LZO_DETERMINISTIC)
+ LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
+ lzo_uint m_len;
+ lzo_uint dindex;
+next:
+ if __lzo_unlikely(ip >= ip_end)
+ break;
+ DINDEX1(dindex,ip);
+ GINDEX(m_pos,m_off,dict,dindex,in);
+ if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
+ goto literal;
+#if 1
+ if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
+ goto try_match;
+ DINDEX2(dindex,ip);
+#endif
+ GINDEX(m_pos,m_off,dict,dindex,in);
+ if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
+ goto literal;
+ if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
+ goto try_match;
+ goto literal;
+
+try_match:
+#if (LZO_OPT_UNALIGNED32)
+ if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip))
+#else
+ if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3])
+#endif
+ {
+literal:
+ UPDATE_I(dict,0,dindex,ip,in);
+ ip += 1 + ((ip - ii) >> 5);
+ continue;
+ }
+ UPDATE_I(dict,0,dindex,ip,in);
+#else
+ lzo_uint m_off;
+ lzo_uint m_len;
+ {
+ lzo_uint32_t dv;
+ lzo_uint dindex;
+literal:
+ ip += 1 + ((ip - ii) >> 5);
+next:
+ if __lzo_unlikely(ip >= ip_end)
+ break;
+ dv = UA_GET_LE32(ip);
+ dindex = DINDEX(dv,ip);
+ GINDEX(m_off,m_pos,in+dict,dindex,in);
+ UPDATE_I(dict,0,dindex,ip,in);
+ if __lzo_unlikely(dv != UA_GET_LE32(m_pos))
+ goto literal;
+ }
+#endif
+
+ ii -= ti; ti = 0;
+ {
+ lzo_uint t = pd(ip,ii);
+ if (t != 0)
+ {
+ if (t <= 3)
+ {
+ op[-2] = LZO_BYTE(op[-2] | t);
+#if (LZO_OPT_UNALIGNED32)
+ UA_COPY4(op, ii);
+ op += t;
+#else
+ { do *op++ = *ii++; while (--t > 0); }
+#endif
+ }
+#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64)
+ else if (t <= 16)
+ {
+ *op++ = LZO_BYTE(t - 3);
+ UA_COPY8(op, ii);
+ UA_COPY8(op+8, ii+8);
+ op += t;
+ }
+#endif
+ else
+ {
+ if (t <= 18)
+ *op++ = LZO_BYTE(t - 3);
+ else
+ {
+ lzo_uint tt = t - 18;
+ *op++ = 0;
+ while __lzo_unlikely(tt > 255)
+ {
+ tt -= 255;
+ UA_SET1(op, 0);
+ op++;
+ }
+ assert(tt > 0);
+ *op++ = LZO_BYTE(tt);
+ }
+#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64)
+ do {
+ UA_COPY8(op, ii);
+ UA_COPY8(op+8, ii+8);
+ op += 16; ii += 16; t -= 16;
+ } while (t >= 16); if (t > 0)
+#endif
+ { do *op++ = *ii++; while (--t > 0); }
+ }
+ }
+ }
+ m_len = 4;
+ {
+#if (LZO_OPT_UNALIGNED64)
+ lzo_uint64_t v;
+ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len);
+ if __lzo_unlikely(v == 0) {
+ do {
+ m_len += 8;
+ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len);
+ if __lzo_unlikely(ip + m_len >= ip_end)
+ goto m_len_done;
+ } while (v == 0);
+ }
+#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64)
+ m_len += lzo_bitops_ctlz64(v) / CHAR_BIT;
+#elif (LZO_ABI_BIG_ENDIAN)
+ if ((v >> (64 - CHAR_BIT)) == 0) do {
+ v <<= CHAR_BIT;
+ m_len += 1;
+ } while ((v >> (64 - CHAR_BIT)) == 0);
+#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64)
+ m_len += lzo_bitops_cttz64(v) / CHAR_BIT;
+#elif (LZO_ABI_LITTLE_ENDIAN)
+ if ((v & UCHAR_MAX) == 0) do {
+ v >>= CHAR_BIT;
+ m_len += 1;
+ } while ((v & UCHAR_MAX) == 0);
+#else
+ if (ip[m_len] == m_pos[m_len]) do {
+ m_len += 1;
+ } while (ip[m_len] == m_pos[m_len]);
+#endif
+#elif (LZO_OPT_UNALIGNED32)
+ lzo_uint32_t v;
+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len);
+ if __lzo_unlikely(v == 0) {
+ do {
+ m_len += 4;
+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len);
+ if (v != 0)
+ break;
+ m_len += 4;
+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len);
+ if __lzo_unlikely(ip + m_len >= ip_end)
+ goto m_len_done;
+ } while (v == 0);
+ }
+#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32)
+ m_len += lzo_bitops_ctlz32(v) / CHAR_BIT;
+#elif (LZO_ABI_BIG_ENDIAN)
+ if ((v >> (32 - CHAR_BIT)) == 0) do {
+ v <<= CHAR_BIT;
+ m_len += 1;
+ } while ((v >> (32 - CHAR_BIT)) == 0);
+#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32)
+ m_len += lzo_bitops_cttz32(v) / CHAR_BIT;
+#elif (LZO_ABI_LITTLE_ENDIAN)
+ if ((v & UCHAR_MAX) == 0) do {
+ v >>= CHAR_BIT;
+ m_len += 1;
+ } while ((v & UCHAR_MAX) == 0);
+#else
+ if (ip[m_len] == m_pos[m_len]) do {
+ m_len += 1;
+ } while (ip[m_len] == m_pos[m_len]);
+#endif
+#else
+ if __lzo_unlikely(ip[m_len] == m_pos[m_len]) {
+ do {
+ m_len += 1;
+ if (ip[m_len] != m_pos[m_len])
+ break;
+ m_len += 1;
+ if (ip[m_len] != m_pos[m_len])
+ break;
+ m_len += 1;
+ if (ip[m_len] != m_pos[m_len])
+ break;
+ m_len += 1;
+ if (ip[m_len] != m_pos[m_len])
+ break;
+ m_len += 1;
+ if (ip[m_len] != m_pos[m_len])
+ break;
+ m_len += 1;
+ if (ip[m_len] != m_pos[m_len])
+ break;
+ m_len += 1;
+ if (ip[m_len] != m_pos[m_len])
+ break;
+ m_len += 1;
+ if __lzo_unlikely(ip + m_len >= ip_end)
+ goto m_len_done;
+ } while (ip[m_len] == m_pos[m_len]);
+ }
+#endif
+ }
+m_len_done:
+ m_off = pd(ip,m_pos);
+ ip += m_len;
+ ii = ip;
+ if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
+ {
+ m_off -= 1;
+#if defined(LZO1X)
+ *op++ = LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2));
+ *op++ = LZO_BYTE(m_off >> 3);
+#elif defined(LZO1Y)
+ *op++ = LZO_BYTE(((m_len + 1) << 4) | ((m_off & 3) << 2));
+ *op++ = LZO_BYTE(m_off >> 2);
+#endif
+ }
+ else if (m_off <= M3_MAX_OFFSET)
+ {
+ m_off -= 1;
+ if (m_len <= M3_MAX_LEN)
+ *op++ = LZO_BYTE(M3_MARKER | (m_len - 2));
+ else
+ {
+ m_len -= M3_MAX_LEN;
+ *op++ = M3_MARKER | 0;
+ while __lzo_unlikely(m_len > 255)
+ {
+ m_len -= 255;
+ UA_SET1(op, 0);
+ op++;
+ }
+ *op++ = LZO_BYTE(m_len);
+ }
+ *op++ = LZO_BYTE(m_off << 2);
+ *op++ = LZO_BYTE(m_off >> 6);
+ }
+ else
+ {
+ m_off -= 0x4000;
+ if (m_len <= M4_MAX_LEN)
+ *op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8) | (m_len - 2));
+ else
+ {
+ m_len -= M4_MAX_LEN;
+ *op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8));
+ while __lzo_unlikely(m_len > 255)
+ {
+ m_len -= 255;
+ UA_SET1(op, 0);
+ op++;
+ }
+ *op++ = LZO_BYTE(m_len);
+ }
+ *op++ = LZO_BYTE(m_off << 2);
+ *op++ = LZO_BYTE(m_off >> 6);
+ }
+ goto next;
+ }
+
+ *out_len = pd(op, out);
+ return pd(in_end,ii-ti);
+}
+
+LZO_PUBLIC(int)
+DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len,
+ lzo_bytep out, lzo_uintp out_len,
+ lzo_voidp wrkmem )
+{
+ const lzo_bytep ip = in;
+ lzo_bytep op = out;
+ lzo_uint l = in_len;
+ lzo_uint t = 0;
+
+ while (l > 20)
+ {
+ lzo_uint ll = l;
+ lzo_uintptr_t ll_end;
+#if 0 || (LZO_DETERMINISTIC)
+ ll = LZO_MIN(ll, 49152);
+#endif
+ ll_end = (lzo_uintptr_t)ip + ll;
+ if ((ll_end + ((t + ll) >> 5)) <= ll_end || (const lzo_bytep)(ll_end + ((t + ll) >> 5)) <= ip + ll)
+ break;
+#if (LZO_DETERMINISTIC)
+ lzo_memset(wrkmem, 0, ((lzo_uint)1 << D_BITS) * sizeof(lzo_dict_t));
+#endif
+ t = do_compress(ip,ll,op,out_len,t,wrkmem);
+ ip += ll;
+ op += *out_len;
+ l -= ll;
+ }
+ t += l;
+
+ if (t > 0)
+ {
+ const lzo_bytep ii = in + in_len - t;
+
+ if (op == out && t <= 238)
+ *op++ = LZO_BYTE(17 + t);
+ else if (t <= 3)
+ op[-2] = LZO_BYTE(op[-2] | t);
+ else if (t <= 18)
+ *op++ = LZO_BYTE(t - 3);
+ else
+ {
+ lzo_uint tt = t - 18;
+
+ *op++ = 0;
+ while (tt > 255)
+ {
+ tt -= 255;
+ UA_SET1(op, 0);
+ op++;
+ }
+ assert(tt > 0);
+ *op++ = LZO_BYTE(tt);
+ }
+ UA_COPYN(op, ii, t);
+ op += t;
+ }
+
+ *op++ = M4_MARKER | 1;
+ *op++ = 0;
+ *op++ = 0;
+
+ *out_len = pd(op, out);
+ return LZO_E_OK;
+}
+
+#endif
+
+#undef do_compress
+#undef DO_COMPRESS
+#undef LZO_HASH
+
+#undef LZO_TEST_OVERRUN
+#undef DO_DECOMPRESS
+#define DO_DECOMPRESS lzo1x_decompress
+
+#if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS)
+
+#if defined(LZO_TEST_OVERRUN)
+# if !defined(LZO_TEST_OVERRUN_INPUT)
+# define LZO_TEST_OVERRUN_INPUT 2
+# endif
+# if !defined(LZO_TEST_OVERRUN_OUTPUT)
+# define LZO_TEST_OVERRUN_OUTPUT 2
+# endif
+# if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
+# define LZO_TEST_OVERRUN_LOOKBEHIND 1
+# endif
+#endif
+
+#undef TEST_IP
+#undef TEST_OP
+#undef TEST_IP_AND_TEST_OP
+#undef TEST_LB
+#undef TEST_LBO
+#undef NEED_IP
+#undef NEED_OP
+#undef TEST_IV
+#undef TEST_OV
+#undef HAVE_TEST_IP
+#undef HAVE_TEST_OP
+#undef HAVE_NEED_IP
+#undef HAVE_NEED_OP
+#undef HAVE_ANY_IP
+#undef HAVE_ANY_OP
+
+#if defined(LZO_TEST_OVERRUN_INPUT)
+# if (LZO_TEST_OVERRUN_INPUT >= 1)
+# define TEST_IP (ip < ip_end)
+# endif
+# if (LZO_TEST_OVERRUN_INPUT >= 2)
+# define NEED_IP(x) \
+ if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
+# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun
+# endif
+#endif
+
+#if defined(LZO_TEST_OVERRUN_OUTPUT)
+# if (LZO_TEST_OVERRUN_OUTPUT >= 1)
+# define TEST_OP (op <= op_end)
+# endif
+# if (LZO_TEST_OVERRUN_OUTPUT >= 2)
+# undef TEST_OP
+# define NEED_OP(x) \
+ if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
+# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun
+# endif
+#endif
+
+#if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
+# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun
+# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun
+#else
+# define TEST_LB(m_pos) ((void) 0)
+# define TEST_LBO(m_pos,o) ((void) 0)
+#endif
+
+#if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
+# define TEST_IP (ip < ip_end)
+#endif
+
+#if defined(TEST_IP)
+# define HAVE_TEST_IP 1
+#else
+# define TEST_IP 1
+#endif
+#if defined(TEST_OP)
+# define HAVE_TEST_OP 1
+#else
+# define TEST_OP 1
+#endif
+
+#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP)
+# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP)
+#elif defined(HAVE_TEST_IP)
+# define TEST_IP_AND_TEST_OP TEST_IP
+#elif defined(HAVE_TEST_OP)
+# define TEST_IP_AND_TEST_OP TEST_OP
+#else
+# define TEST_IP_AND_TEST_OP 1
+#endif
+
+#if defined(NEED_IP)
+# define HAVE_NEED_IP 1
+#else
+# define NEED_IP(x) ((void) 0)
+# define TEST_IV(x) ((void) 0)
+#endif
+#if defined(NEED_OP)
+# define HAVE_NEED_OP 1
+#else
+# define NEED_OP(x) ((void) 0)
+# define TEST_OV(x) ((void) 0)
+#endif
+
+#if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
+# define HAVE_ANY_IP 1
+#endif
+#if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
+# define HAVE_ANY_OP 1
+#endif
+
+#if defined(DO_DECOMPRESS)
+LZO_PUBLIC(int)
+DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
+ lzo_bytep out, lzo_uintp out_len,
+ lzo_voidp wrkmem )
+#endif
+{
+ lzo_bytep op;
+ const lzo_bytep ip;
+ lzo_uint t;
+#if defined(COPY_DICT)
+ lzo_uint m_off;
+ const lzo_bytep dict_end;
+#else
+ const lzo_bytep m_pos;
+#endif
+
+ const lzo_bytep const ip_end = in + in_len;
+#if defined(HAVE_ANY_OP)
+ lzo_bytep const op_end = out + *out_len;
+#endif
+#if defined(LZO1Z)
+ lzo_uint last_m_off = 0;
+#endif
+
+ LZO_UNUSED(wrkmem);
+
+#if defined(COPY_DICT)
+ if (dict)
+ {
+ if (dict_len > M4_MAX_OFFSET)
+ {
+ dict += dict_len - M4_MAX_OFFSET;
+ dict_len = M4_MAX_OFFSET;
+ }
+ dict_end = dict + dict_len;
+ }
+ else
+ {
+ dict_len = 0;
+ dict_end = NULL;
+ }
+#endif
+
+ *out_len = 0;
+
+ op = out;
+ ip = in;
+
+ NEED_IP(1);
+ if (*ip > 17)
+ {
+ t = *ip++ - 17;
+ if (t < 4)
+ goto match_next;
+ assert(t > 0); NEED_OP(t); NEED_IP(t+3);
+ do *op++ = *ip++; while (--t > 0);
+ goto first_literal_run;
+ }
+
+ for (;;)
+ {
+ NEED_IP(3);
+ t = *ip++;
+ if (t >= 16)
+ goto match;
+ if (t == 0)
+ {
+ while (*ip == 0)
+ {
+ t += 255;
+ ip++;
+ TEST_IV(t);
+ NEED_IP(1);
+ }
+ t += 15 + *ip++;
+ }
+ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6);
+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32)
+ t += 3;
+ if (t >= 8) do
+ {
+ UA_COPY8(op,ip);
+ op += 8; ip += 8; t -= 8;
+ } while (t >= 8);
+ if (t >= 4)
+ {
+ UA_COPY4(op,ip);
+ op += 4; ip += 4; t -= 4;
+ }
+ if (t > 0)
+ {
+ *op++ = *ip++;
+ if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
+ }
+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4)
+#if !(LZO_OPT_UNALIGNED32)
+ if (PTR_ALIGNED2_4(op,ip))
+ {
+#endif
+ UA_COPY4(op,ip);
+ op += 4; ip += 4;
+ if (--t > 0)
+ {
+ if (t >= 4)
+ {
+ do {
+ UA_COPY4(op,ip);
+ op += 4; ip += 4; t -= 4;
+ } while (t >= 4);
+ if (t > 0) do *op++ = *ip++; while (--t > 0);
+ }
+ else
+ do *op++ = *ip++; while (--t > 0);
+ }
+#if !(LZO_OPT_UNALIGNED32)
+ }
+ else
+#endif
+#endif
+#if !(LZO_OPT_UNALIGNED32)
+ {
+ *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
+ do *op++ = *ip++; while (--t > 0);
+ }
+#endif
+
+first_literal_run:
+
+ t = *ip++;
+ if (t >= 16)
+ goto match;
+#if defined(COPY_DICT)
+#if defined(LZO1Z)
+ m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
+ last_m_off = m_off;
+#else
+ m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
+#endif
+ NEED_OP(3);
+ t = 3; COPY_DICT(t,m_off)
+#else
+#if defined(LZO1Z)
+ t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
+ m_pos = op - t;
+ last_m_off = t;
+#else
+ m_pos = op - (1 + M2_MAX_OFFSET);
+ m_pos -= t >> 2;
+ m_pos -= *ip++ << 2;
+#endif
+ TEST_LB(m_pos); NEED_OP(3);
+ *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
+#endif
+ goto match_done;
+
+ for (;;) {
+match:
+ if (t >= 64)
+ {
+#if defined(COPY_DICT)
+#if defined(LZO1X)
+ m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
+ t = (t >> 5) - 1;
+#elif defined(LZO1Y)
+ m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
+ t = (t >> 4) - 3;
+#elif defined(LZO1Z)
+ m_off = t & 0x1f;
+ if (m_off >= 0x1c)
+ m_off = last_m_off;
+ else
+ {
+ m_off = 1 + (m_off << 6) + (*ip++ >> 2);
+ last_m_off = m_off;
+ }
+ t = (t >> 5) - 1;
+#endif
+#else
+#if defined(LZO1X)
+ m_pos = op - 1;
+ m_pos -= (t >> 2) & 7;
+ m_pos -= *ip++ << 3;
+ t = (t >> 5) - 1;
+#elif defined(LZO1Y)
+ m_pos = op - 1;
+ m_pos -= (t >> 2) & 3;
+ m_pos -= *ip++ << 2;
+ t = (t >> 4) - 3;
+#elif defined(LZO1Z)
+ {
+ lzo_uint off = t & 0x1f;
+ m_pos = op;
+ if (off >= 0x1c)
+ {
+ assert(last_m_off > 0);
+ m_pos -= last_m_off;
+ }
+ else
+ {
+ off = 1 + (off << 6) + (*ip++ >> 2);
+ m_pos -= off;
+ last_m_off = off;
+ }
+ }
+ t = (t >> 5) - 1;
+#endif
+ TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
+ goto copy_match;
+#endif
+ }
+ else if (t >= 32)
+ {
+ t &= 31;
+ if (t == 0)
+ {
+ while (*ip == 0)
+ {
+ t += 255;
+ ip++;
+ TEST_OV(t);
+ NEED_IP(1);
+ }
+ t += 31 + *ip++;
+ NEED_IP(2);
+ }
+#if defined(COPY_DICT)
+#if defined(LZO1Z)
+ m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
+ last_m_off = m_off;
+#else
+ m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
+#endif
+#else
+#if defined(LZO1Z)
+ {
+ lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2);
+ m_pos = op - off;
+ last_m_off = off;
+ }
+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
+ m_pos = op - 1;
+ m_pos -= UA_GET_LE16(ip) >> 2;
+#else
+ m_pos = op - 1;
+ m_pos -= (ip[0] >> 2) + (ip[1] << 6);
+#endif
+#endif
+ ip += 2;
+ }
+ else if (t >= 16)
+ {
+#if defined(COPY_DICT)
+ m_off = (t & 8) << 11;
+#else
+ m_pos = op;
+ m_pos -= (t & 8) << 11;
+#endif
+ t &= 7;
+ if (t == 0)
+ {
+ while (*ip == 0)
+ {
+ t += 255;
+ ip++;
+ TEST_OV(t);
+ NEED_IP(1);
+ }
+ t += 7 + *ip++;
+ NEED_IP(2);
+ }
+#if defined(COPY_DICT)
+#if defined(LZO1Z)
+ m_off += (ip[0] << 6) + (ip[1] >> 2);
+#else
+ m_off += (ip[0] >> 2) + (ip[1] << 6);
+#endif
+ ip += 2;
+ if (m_off == 0)
+ goto eof_found;
+ m_off += 0x4000;
+#if defined(LZO1Z)
+ last_m_off = m_off;
+#endif
+#else
+#if defined(LZO1Z)
+ m_pos -= (ip[0] << 6) + (ip[1] >> 2);
+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
+ m_pos -= UA_GET_LE16(ip) >> 2;
+#else
+ m_pos -= (ip[0] >> 2) + (ip[1] << 6);
+#endif
+ ip += 2;
+ if (m_pos == op)
+ goto eof_found;
+ m_pos -= 0x4000;
+#if defined(LZO1Z)
+ last_m_off = pd((const lzo_bytep)op, m_pos);
+#endif
+#endif
+ }
+ else
+ {
+#if defined(COPY_DICT)
+#if defined(LZO1Z)
+ m_off = 1 + (t << 6) + (*ip++ >> 2);
+ last_m_off = m_off;
+#else
+ m_off = 1 + (t >> 2) + (*ip++ << 2);
+#endif
+ NEED_OP(2);
+ t = 2; COPY_DICT(t,m_off)
+#else
+#if defined(LZO1Z)
+ t = 1 + (t << 6) + (*ip++ >> 2);
+ m_pos = op - t;
+ last_m_off = t;
+#else
+ m_pos = op - 1;
+ m_pos -= t >> 2;
+ m_pos -= *ip++ << 2;
+#endif
+ TEST_LB(m_pos); NEED_OP(2);
+ *op++ = *m_pos++; *op++ = *m_pos;
+#endif
+ goto match_done;
+ }
+
+#if defined(COPY_DICT)
+
+ NEED_OP(t+3-1);
+ t += 3-1; COPY_DICT(t,m_off)
+
+#else
+
+ TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32)
+ if (op - m_pos >= 8)
+ {
+ t += (3 - 1);
+ if (t >= 8) do
+ {
+ UA_COPY8(op,m_pos);
+ op += 8; m_pos += 8; t -= 8;
+ } while (t >= 8);
+ if (t >= 4)
+ {
+ UA_COPY4(op,m_pos);
+ op += 4; m_pos += 4; t -= 4;
+ }
+ if (t > 0)
+ {
+ *op++ = m_pos[0];
+ if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } }
+ }
+ }
+ else
+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4)
+#if !(LZO_OPT_UNALIGNED32)
+ if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos))
+ {
+ assert((op - m_pos) >= 4);
+#else
+ if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
+ {
+#endif
+ UA_COPY4(op,m_pos);
+ op += 4; m_pos += 4; t -= 4 - (3 - 1);
+ do {
+ UA_COPY4(op,m_pos);
+ op += 4; m_pos += 4; t -= 4;
+ } while (t >= 4);
+ if (t > 0) do *op++ = *m_pos++; while (--t > 0);
+ }
+ else
+#endif
+ {
+copy_match:
+ *op++ = *m_pos++; *op++ = *m_pos++;
+ do *op++ = *m_pos++; while (--t > 0);
+ }
+
+#endif
+
+match_done:
+#if defined(LZO1Z)
+ t = ip[-1] & 3;
+#else
+ t = ip[-2] & 3;
+#endif
+ if (t == 0)
+ break;
+
+match_next:
+ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3);
+#if 0
+ do *op++ = *ip++; while (--t > 0);
+#else
+ *op++ = *ip++;
+ if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
+#endif
+ t = *ip++;
+ }
+ }
+
+eof_found:
+ *out_len = pd(op, out);
+ return (ip == ip_end ? LZO_E_OK :
+ (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
+
+#if defined(HAVE_NEED_IP)
+input_overrun:
+ *out_len = pd(op, out);
+ return LZO_E_INPUT_OVERRUN;
+#endif
+
+#if defined(HAVE_NEED_OP)
+output_overrun:
+ *out_len = pd(op, out);
+ return LZO_E_OUTPUT_OVERRUN;
+#endif
+
+#if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
+lookbehind_overrun:
+ *out_len = pd(op, out);
+ return LZO_E_LOOKBEHIND_OVERRUN;
+#endif
+}
+
+#endif
+
+#define LZO_TEST_OVERRUN 1
+#undef DO_DECOMPRESS
+#define DO_DECOMPRESS lzo1x_decompress_safe
+
+#if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE)
+
+#if defined(LZO_TEST_OVERRUN)
+# if !defined(LZO_TEST_OVERRUN_INPUT)
+# define LZO_TEST_OVERRUN_INPUT 2
+# endif
+# if !defined(LZO_TEST_OVERRUN_OUTPUT)
+# define LZO_TEST_OVERRUN_OUTPUT 2
+# endif
+# if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
+# define LZO_TEST_OVERRUN_LOOKBEHIND 1
+# endif
+#endif
+
+#undef TEST_IP
+#undef TEST_OP
+#undef TEST_IP_AND_TEST_OP
+#undef TEST_LB
+#undef TEST_LBO
+#undef NEED_IP
+#undef NEED_OP
+#undef TEST_IV
+#undef TEST_OV
+#undef HAVE_TEST_IP
+#undef HAVE_TEST_OP
+#undef HAVE_NEED_IP
+#undef HAVE_NEED_OP
+#undef HAVE_ANY_IP
+#undef HAVE_ANY_OP
+
+#if defined(LZO_TEST_OVERRUN_INPUT)
+# if (LZO_TEST_OVERRUN_INPUT >= 1)
+# define TEST_IP (ip < ip_end)
+# endif
+# if (LZO_TEST_OVERRUN_INPUT >= 2)
+# define NEED_IP(x) \
+ if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
+# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun
+# endif
+#endif
+
+#if defined(LZO_TEST_OVERRUN_OUTPUT)
+# if (LZO_TEST_OVERRUN_OUTPUT >= 1)
+# define TEST_OP (op <= op_end)
+# endif
+# if (LZO_TEST_OVERRUN_OUTPUT >= 2)
+# undef TEST_OP
+# define NEED_OP(x) \
+ if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
+# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun
+# endif
+#endif
+
+#if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
+# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun
+# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun
+#else
+# define TEST_LB(m_pos) ((void) 0)
+# define TEST_LBO(m_pos,o) ((void) 0)
+#endif
+
+#if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
+# define TEST_IP (ip < ip_end)
+#endif
+
+#if defined(TEST_IP)
+# define HAVE_TEST_IP 1
+#else
+# define TEST_IP 1
+#endif
+#if defined(TEST_OP)
+# define HAVE_TEST_OP 1
+#else
+# define TEST_OP 1
+#endif
+
+#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP)
+# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP)
+#elif defined(HAVE_TEST_IP)
+# define TEST_IP_AND_TEST_OP TEST_IP
+#elif defined(HAVE_TEST_OP)
+# define TEST_IP_AND_TEST_OP TEST_OP
+#else
+# define TEST_IP_AND_TEST_OP 1
+#endif
+
+#if defined(NEED_IP)
+# define HAVE_NEED_IP 1
+#else
+# define NEED_IP(x) ((void) 0)
+# define TEST_IV(x) ((void) 0)
+#endif
+#if defined(NEED_OP)
+# define HAVE_NEED_OP 1
+#else
+# define NEED_OP(x) ((void) 0)
+# define TEST_OV(x) ((void) 0)
+#endif
+
+#if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
+# define HAVE_ANY_IP 1
+#endif
+#if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
+# define HAVE_ANY_OP 1
+#endif
+
+#if defined(DO_DECOMPRESS)
+LZO_PUBLIC(int)
+DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
+ lzo_bytep out, lzo_uintp out_len,
+ lzo_voidp wrkmem )
+#endif
+{
+ lzo_bytep op;
+ const lzo_bytep ip;
+ lzo_uint t;
+#if defined(COPY_DICT)
+ lzo_uint m_off;
+ const lzo_bytep dict_end;
+#else
+ const lzo_bytep m_pos;
+#endif
+
+ const lzo_bytep const ip_end = in + in_len;
+#if defined(HAVE_ANY_OP)
+ lzo_bytep const op_end = out + *out_len;
+#endif
+#if defined(LZO1Z)
+ lzo_uint last_m_off = 0;
+#endif
+
+ LZO_UNUSED(wrkmem);
+
+#if defined(COPY_DICT)
+ if (dict)
+ {
+ if (dict_len > M4_MAX_OFFSET)
+ {
+ dict += dict_len - M4_MAX_OFFSET;
+ dict_len = M4_MAX_OFFSET;
+ }
+ dict_end = dict + dict_len;
+ }
+ else
+ {
+ dict_len = 0;
+ dict_end = NULL;
+ }
+#endif
+
+ *out_len = 0;
+
+ op = out;
+ ip = in;
+
+ NEED_IP(1);
+ if (*ip > 17)
+ {
+ t = *ip++ - 17;
+ if (t < 4)
+ goto match_next;
+ assert(t > 0); NEED_OP(t); NEED_IP(t+3);
+ do *op++ = *ip++; while (--t > 0);
+ goto first_literal_run;
+ }
+
+ for (;;)
+ {
+ NEED_IP(3);
+ t = *ip++;
+ if (t >= 16)
+ goto match;
+ if (t == 0)
+ {
+ while (*ip == 0)
+ {
+ t += 255;
+ ip++;
+ TEST_IV(t);
+ NEED_IP(1);
+ }
+ t += 15 + *ip++;
+ }
+ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6);
+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32)
+ t += 3;
+ if (t >= 8) do
+ {
+ UA_COPY8(op,ip);
+ op += 8; ip += 8; t -= 8;
+ } while (t >= 8);
+ if (t >= 4)
+ {
+ UA_COPY4(op,ip);
+ op += 4; ip += 4; t -= 4;
+ }
+ if (t > 0)
+ {
+ *op++ = *ip++;
+ if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
+ }
+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4)
+#if !(LZO_OPT_UNALIGNED32)
+ if (PTR_ALIGNED2_4(op,ip))
+ {
+#endif
+ UA_COPY4(op,ip);
+ op += 4; ip += 4;
+ if (--t > 0)
+ {
+ if (t >= 4)
+ {
+ do {
+ UA_COPY4(op,ip);
+ op += 4; ip += 4; t -= 4;
+ } while (t >= 4);
+ if (t > 0) do *op++ = *ip++; while (--t > 0);
+ }
+ else
+ do *op++ = *ip++; while (--t > 0);
+ }
+#if !(LZO_OPT_UNALIGNED32)
+ }
+ else
+#endif
+#endif
+#if !(LZO_OPT_UNALIGNED32)
+ {
+ *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
+ do *op++ = *ip++; while (--t > 0);
+ }
+#endif
+
+first_literal_run:
+
+ t = *ip++;
+ if (t >= 16)
+ goto match;
+#if defined(COPY_DICT)
+#if defined(LZO1Z)
+ m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
+ last_m_off = m_off;
+#else
+ m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
+#endif
+ NEED_OP(3);
+ t = 3; COPY_DICT(t,m_off)
+#else
+#if defined(LZO1Z)
+ t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
+ m_pos = op - t;
+ last_m_off = t;
+#else
+ m_pos = op - (1 + M2_MAX_OFFSET);
+ m_pos -= t >> 2;
+ m_pos -= *ip++ << 2;
+#endif
+ TEST_LB(m_pos); NEED_OP(3);
+ *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
+#endif
+ goto match_done;
+
+ for (;;) {
+match:
+ if (t >= 64)
+ {
+#if defined(COPY_DICT)
+#if defined(LZO1X)
+ m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
+ t = (t >> 5) - 1;
+#elif defined(LZO1Y)
+ m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
+ t = (t >> 4) - 3;
+#elif defined(LZO1Z)
+ m_off = t & 0x1f;
+ if (m_off >= 0x1c)
+ m_off = last_m_off;
+ else
+ {
+ m_off = 1 + (m_off << 6) + (*ip++ >> 2);
+ last_m_off = m_off;
+ }
+ t = (t >> 5) - 1;
+#endif
+#else
+#if defined(LZO1X)
+ m_pos = op - 1;
+ m_pos -= (t >> 2) & 7;
+ m_pos -= *ip++ << 3;
+ t = (t >> 5) - 1;
+#elif defined(LZO1Y)
+ m_pos = op - 1;
+ m_pos -= (t >> 2) & 3;
+ m_pos -= *ip++ << 2;
+ t = (t >> 4) - 3;
+#elif defined(LZO1Z)
+ {
+ lzo_uint off = t & 0x1f;
+ m_pos = op;
+ if (off >= 0x1c)
+ {
+ assert(last_m_off > 0);
+ m_pos -= last_m_off;
+ }
+ else
+ {
+ off = 1 + (off << 6) + (*ip++ >> 2);
+ m_pos -= off;
+ last_m_off = off;
+ }
+ }
+ t = (t >> 5) - 1;
+#endif
+ TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
+ goto copy_match;
+#endif
+ }
+ else if (t >= 32)
+ {
+ t &= 31;
+ if (t == 0)
+ {
+ while (*ip == 0)
+ {
+ t += 255;
+ ip++;
+ TEST_OV(t);
+ NEED_IP(1);
+ }
+ t += 31 + *ip++;
+ NEED_IP(2);
+ }
+#if defined(COPY_DICT)
+#if defined(LZO1Z)
+ m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
+ last_m_off = m_off;
+#else
+ m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
+#endif
+#else
+#if defined(LZO1Z)
+ {
+ lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2);
+ m_pos = op - off;
+ last_m_off = off;
+ }
+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
+ m_pos = op - 1;
+ m_pos -= UA_GET_LE16(ip) >> 2;
+#else
+ m_pos = op - 1;
+ m_pos -= (ip[0] >> 2) + (ip[1] << 6);
+#endif
+#endif
+ ip += 2;
+ }
+ else if (t >= 16)
+ {
+#if defined(COPY_DICT)
+ m_off = (t & 8) << 11;
+#else
+ m_pos = op;
+ m_pos -= (t & 8) << 11;
+#endif
+ t &= 7;
+ if (t == 0)
+ {
+ while (*ip == 0)
+ {
+ t += 255;
+ ip++;
+ TEST_OV(t);
+ NEED_IP(1);
+ }
+ t += 7 + *ip++;
+ NEED_IP(2);
+ }
+#if defined(COPY_DICT)
+#if defined(LZO1Z)
+ m_off += (ip[0] << 6) + (ip[1] >> 2);
+#else
+ m_off += (ip[0] >> 2) + (ip[1] << 6);
+#endif
+ ip += 2;
+ if (m_off == 0)
+ goto eof_found;
+ m_off += 0x4000;
+#if defined(LZO1Z)
+ last_m_off = m_off;
+#endif
+#else
+#if defined(LZO1Z)
+ m_pos -= (ip[0] << 6) + (ip[1] >> 2);
+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
+ m_pos -= UA_GET_LE16(ip) >> 2;
+#else
+ m_pos -= (ip[0] >> 2) + (ip[1] << 6);
+#endif
+ ip += 2;
+ if (m_pos == op)
+ goto eof_found;
+ m_pos -= 0x4000;
+#if defined(LZO1Z)
+ last_m_off = pd((const lzo_bytep)op, m_pos);
+#endif
+#endif
+ }
+ else
+ {
+#if defined(COPY_DICT)
+#if defined(LZO1Z)
+ m_off = 1 + (t << 6) + (*ip++ >> 2);
+ last_m_off = m_off;
+#else
+ m_off = 1 + (t >> 2) + (*ip++ << 2);
+#endif
+ NEED_OP(2);
+ t = 2; COPY_DICT(t,m_off)
+#else
+#if defined(LZO1Z)
+ t = 1 + (t << 6) + (*ip++ >> 2);
+ m_pos = op - t;
+ last_m_off = t;
+#else
+ m_pos = op - 1;
+ m_pos -= t >> 2;
+ m_pos -= *ip++ << 2;
+#endif
+ TEST_LB(m_pos); NEED_OP(2);
+ *op++ = *m_pos++; *op++ = *m_pos;
+#endif
+ goto match_done;
+ }
+
+#if defined(COPY_DICT)
+
+ NEED_OP(t+3-1);
+ t += 3-1; COPY_DICT(t,m_off)
+
+#else
+
+ TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32)
+ if (op - m_pos >= 8)
+ {
+ t += (3 - 1);
+ if (t >= 8) do
+ {
+ UA_COPY8(op,m_pos);
+ op += 8; m_pos += 8; t -= 8;
+ } while (t >= 8);
+ if (t >= 4)
+ {
+ UA_COPY4(op,m_pos);
+ op += 4; m_pos += 4; t -= 4;
+ }
+ if (t > 0)
+ {
+ *op++ = m_pos[0];
+ if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } }
+ }
+ }
+ else
+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4)
+#if !(LZO_OPT_UNALIGNED32)
+ if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos))
+ {
+ assert((op - m_pos) >= 4);
+#else
+ if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
+ {
+#endif
+ UA_COPY4(op,m_pos);
+ op += 4; m_pos += 4; t -= 4 - (3 - 1);
+ do {
+ UA_COPY4(op,m_pos);
+ op += 4; m_pos += 4; t -= 4;
+ } while (t >= 4);
+ if (t > 0) do *op++ = *m_pos++; while (--t > 0);
+ }
+ else
+#endif
+ {
+copy_match:
+ *op++ = *m_pos++; *op++ = *m_pos++;
+ do *op++ = *m_pos++; while (--t > 0);
+ }
+
+#endif
+
+match_done:
+#if defined(LZO1Z)
+ t = ip[-1] & 3;
+#else
+ t = ip[-2] & 3;
+#endif
+ if (t == 0)
+ break;
+
+match_next:
+ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3);
+#if 0
+ do *op++ = *ip++; while (--t > 0);
+#else
+ *op++ = *ip++;
+ if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
+#endif
+ t = *ip++;
+ }
+ }
+
+eof_found:
+ *out_len = pd(op, out);
+ return (ip == ip_end ? LZO_E_OK :
+ (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
+
+#if defined(HAVE_NEED_IP)
+input_overrun:
+ *out_len = pd(op, out);
+ return LZO_E_INPUT_OVERRUN;
+#endif
+
+#if defined(HAVE_NEED_OP)
+output_overrun:
+ *out_len = pd(op, out);
+ return LZO_E_OUTPUT_OVERRUN;
+#endif
+
+#if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
+lookbehind_overrun:
+ *out_len = pd(op, out);
+ return LZO_E_LOOKBEHIND_OVERRUN;
+#endif
+}
+
+#endif
+
+/***** End of minilzo.c *****/
diff --git a/grub-core/lib/minilzo/minilzo.h b/grub-core/lib/minilzo/minilzo.h
new file mode 100644
index 0000000..7937454
--- /dev/null
+++ b/grub-core/lib/minilzo/minilzo.h
@@ -0,0 +1,94 @@
+/* minilzo.h -- mini subset of the LZO real-time data compression library
+
+ This file is part of the LZO real-time data compression library.
+
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
+ All Rights Reserved.
+
+ The LZO library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ The LZO library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the LZO library; see the file COPYING.
+ If not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Markus F.X.J. Oberhumer
+ <markus@oberhumer.com>
+ http://www.oberhumer.com/opensource/lzo/
+ */
+
+/*
+ * NOTE:
+ * the full LZO package can be found at
+ * http://www.oberhumer.com/opensource/lzo/
+ */
+
+
+#ifndef __MINILZO_H
+#define __MINILZO_H 1
+
+#define MINILZO_VERSION 0x2080
+
+#ifdef __LZOCONF_H
+# error "you cannot use both LZO and miniLZO"
+#endif
+
+#undef LZO_HAVE_CONFIG_H
+#include "lzoconf.h"
+
+#if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION)
+# error "version mismatch in header files"
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/***********************************************************************
+//
+************************************************************************/
+
+/* Memory required for the wrkmem parameter.
+ * When the required size is 0, you can also pass a NULL pointer.
+ */
+
+#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS
+#define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t))
+#define LZO1X_MEM_DECOMPRESS (0)
+
+
+/* compression */
+LZO_EXTERN(int)
+lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len,
+ lzo_bytep dst, lzo_uintp dst_len,
+ lzo_voidp wrkmem );
+
+/* decompression */
+LZO_EXTERN(int)
+lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len,
+ lzo_bytep dst, lzo_uintp dst_len,
+ lzo_voidp wrkmem /* NOT USED */ );
+
+/* safe decompression with overrun testing */
+LZO_EXTERN(int)
+lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len,
+ lzo_bytep dst, lzo_uintp dst_len,
+ lzo_voidp wrkmem /* NOT USED */ );
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* already included */
+
diff --git a/grub-core/lib/mips/arc/reboot.c b/grub-core/lib/mips/arc/reboot.c
new file mode 100644
index 0000000..ecf12a7
--- /dev/null
+++ b/grub-core/lib/mips/arc/reboot.c
@@ -0,0 +1,35 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/arc/arc.h>
+#include <grub/misc.h>
+#include <grub/time.h>
+#include <grub/term.h>
+#include <grub/i18n.h>
+
+void
+grub_reboot (void)
+{
+ GRUB_ARC_FIRMWARE_VECTOR->restart ();
+
+ grub_millisleep (1500);
+
+ grub_puts_ (N_("Reboot failed"));
+ grub_refresh ();
+ while (1);
+}
diff --git a/grub-core/lib/mips/loongson/reboot.c b/grub-core/lib/mips/loongson/reboot.c
new file mode 100644
index 0000000..a20e574
--- /dev/null
+++ b/grub-core/lib/mips/loongson/reboot.c
@@ -0,0 +1,64 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/machine/ec.h>
+#include <grub/machine/kernel.h>
+#include <grub/machine/memory.h>
+#include <grub/misc.h>
+#include <grub/pci.h>
+#include <grub/cs5536.h>
+#include <grub/time.h>
+#include <grub/term.h>
+#include <grub/i18n.h>
+
+void
+grub_reboot (void)
+{
+ switch (grub_arch_machine)
+ {
+ case GRUB_ARCH_MACHINE_FULOONG2E:
+ grub_outl (grub_inl (0xbfe00104) & ~4, 0xbfe00104);
+ grub_outl (grub_inl (0xbfe00104) | 4, 0xbfe00104);
+ break;
+ case GRUB_ARCH_MACHINE_FULOONG2F:
+ {
+ grub_pci_device_t dev;
+ if (!grub_cs5536_find (&dev))
+ break;
+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_RESET,
+ grub_cs5536_read_msr (dev,
+ GRUB_CS5536_MSR_DIVIL_RESET)
+ | 1);
+ break;
+ }
+ case GRUB_ARCH_MACHINE_YEELOONG:
+ grub_write_ec (GRUB_MACHINE_EC_COMMAND_REBOOT);
+ break;
+ case GRUB_ARCH_MACHINE_YEELOONG_3A:
+ grub_millisleep (1);
+ grub_outb (0x4e, GRUB_MACHINE_PCI_IO_BASE_3A | 0x66);
+ grub_millisleep (1);
+ grub_outb (1, GRUB_MACHINE_PCI_IO_BASE_3A | 0x62);
+ grub_millisleep (5000);
+ }
+ grub_millisleep (1500);
+
+ grub_puts_ (N_("Reboot failed"));
+ grub_refresh ();
+ while (1);
+}
diff --git a/grub-core/lib/mips/qemu_mips/reboot.c b/grub-core/lib/mips/qemu_mips/reboot.c
new file mode 100644
index 0000000..ba0f6ac
--- /dev/null
+++ b/grub-core/lib/mips/qemu_mips/reboot.c
@@ -0,0 +1,27 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/cpu/io.h>
+
+void
+grub_reboot (void)
+{
+ grub_outl (42, 0xbfbf0000);
+ while (1);
+}
diff --git a/grub-core/lib/mips/relocator.c b/grub-core/lib/mips/relocator.c
new file mode 100644
index 0000000..743b213
--- /dev/null
+++ b/grub-core/lib/mips/relocator.c
@@ -0,0 +1,147 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+
+#include <grub/types.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/cache.h>
+
+#include <grub/mips/relocator.h>
+#include <grub/relocator_private.h>
+
+/* Do we need mips64? */
+
+extern grub_uint8_t grub_relocator_forward_start;
+extern grub_uint8_t grub_relocator_forward_end;
+extern grub_uint8_t grub_relocator_backward_start;
+extern grub_uint8_t grub_relocator_backward_end;
+
+#define REGW_SIZEOF (2 * sizeof (grub_uint32_t))
+#define JUMP_SIZEOF (2 * sizeof (grub_uint32_t))
+
+#define RELOCATOR_SRC_SIZEOF(x) (&grub_relocator_##x##_end \
+ - &grub_relocator_##x##_start)
+#define RELOCATOR_SIZEOF(x) (RELOCATOR_SRC_SIZEOF(x) \
+ + REGW_SIZEOF * 3)
+grub_size_t grub_relocator_align = sizeof (grub_uint32_t);
+grub_size_t grub_relocator_forward_size;
+grub_size_t grub_relocator_backward_size;
+grub_size_t grub_relocator_jumper_size = JUMP_SIZEOF + REGW_SIZEOF;
+
+void
+grub_cpu_relocator_init (void)
+{
+ grub_relocator_forward_size = RELOCATOR_SIZEOF(forward);
+ grub_relocator_backward_size = RELOCATOR_SIZEOF(backward);
+}
+
+static void
+write_reg (int regn, grub_uint32_t val, void **target)
+{
+ /* lui $r, (val+0x8000). */
+ *(grub_uint32_t *) *target = ((0x3c00 | regn) << 16) | ((val + 0x8000) >> 16);
+ *target = ((grub_uint32_t *) *target) + 1;
+ /* addiu $r, $r, val. */
+ *(grub_uint32_t *) *target = (((0x2400 | regn << 5 | regn) << 16)
+ | (val & 0xffff));
+ *target = ((grub_uint32_t *) *target) + 1;
+}
+
+static void
+write_jump (int regn, void **target)
+{
+ /* j $r. */
+ *(grub_uint32_t *) *target = (regn<<21) | 0x8;
+ *target = ((grub_uint32_t *) *target) + 1;
+ /* nop. */
+ *(grub_uint32_t *) *target = 0;
+ *target = ((grub_uint32_t *) *target) + 1;
+}
+
+void
+grub_cpu_relocator_jumper (void *rels, grub_addr_t addr)
+{
+ write_reg (1, addr, &rels);
+ write_jump (1, &rels);
+}
+
+void
+grub_cpu_relocator_backward (void *ptr0, void *src, void *dest,
+ grub_size_t size)
+{
+ void *ptr = ptr0;
+ write_reg (8, (grub_uint32_t) src, &ptr);
+ write_reg (9, (grub_uint32_t) dest, &ptr);
+ write_reg (10, (grub_uint32_t) size, &ptr);
+ grub_memcpy (ptr, &grub_relocator_backward_start,
+ RELOCATOR_SRC_SIZEOF (backward));
+}
+
+void
+grub_cpu_relocator_forward (void *ptr0, void *src, void *dest,
+ grub_size_t size)
+{
+ void *ptr = ptr0;
+ write_reg (8, (grub_uint32_t) src, &ptr);
+ write_reg (9, (grub_uint32_t) dest, &ptr);
+ write_reg (10, (grub_uint32_t) size, &ptr);
+ grub_memcpy (ptr, &grub_relocator_forward_start,
+ RELOCATOR_SRC_SIZEOF (forward));
+}
+
+grub_err_t
+grub_relocator32_boot (struct grub_relocator *rel,
+ struct grub_relocator32_state state)
+{
+ grub_relocator_chunk_t ch;
+ void *ptr;
+ grub_err_t err;
+ void *relst;
+ grub_size_t relsize;
+ grub_size_t stateset_size = 31 * REGW_SIZEOF + JUMP_SIZEOF;
+ unsigned i;
+ grub_addr_t vtarget;
+
+ err = grub_relocator_alloc_chunk_align (rel, &ch, 0, UP_TO_TOP32 (stateset_size),
+ stateset_size, sizeof (grub_uint32_t),
+ GRUB_RELOCATOR_PREFERENCE_NONE, 0);
+ if (err)
+ return err;
+
+ ptr = get_virtual_current_address (ch);
+ for (i = 1; i < 32; i++)
+ write_reg (i, state.gpr[i], &ptr);
+ write_jump (state.jumpreg, &ptr);
+
+ vtarget = (grub_addr_t) grub_map_memory (get_physical_target_address (ch),
+ stateset_size);
+
+ err = grub_relocator_prepare_relocs (rel, vtarget, &relst, &relsize);
+ if (err)
+ return err;
+
+ grub_arch_sync_caches ((void *) relst, relsize);
+
+ ((void (*) (void)) relst) ();
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/lib/mips/relocator_asm.S b/grub-core/lib/mips/relocator_asm.S
new file mode 100644
index 0000000..1d142a4
--- /dev/null
+++ b/grub-core/lib/mips/relocator_asm.S
@@ -0,0 +1,61 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+
+ .p2align 4 /* force 16-byte alignment */
+
+ .set noreorder
+ .set nomacro
+
+VARIABLE (grub_relocator_forward_start)
+ move $a0, $9
+ move $a1, $10
+
+copycont1:
+ lb $11,0($8)
+ sb $11,0($9)
+ addiu $8, $8, 1
+ addiu $10, $10, -1
+ bne $10, $0, copycont1
+ addiu $9, $9, 1
+
+#include "../../kern/mips/cache_flush.S"
+
+VARIABLE (grub_relocator_forward_end)
+
+VARIABLE (grub_relocator_backward_start)
+ move $a0, $9
+ move $a1, $10
+
+ addu $9, $9, $10
+ addu $8, $8, $10
+ /* Backward movsl is implicitly off-by-one. compensate that. */
+ addiu $9, $9, -1
+ addiu $8, $8, -1
+copycont2:
+ lb $11,0($8)
+ sb $11,0($9)
+ addiu $8, $8, -1
+ addiu $10, $10, -1
+ bne $10, $0, copycont2
+ addiu $9, $9, -1
+
+#include "../../kern/mips/cache_flush.S"
+
+VARIABLE (grub_relocator_backward_end)
diff --git a/grub-core/lib/mips/setjmp.S b/grub-core/lib/mips/setjmp.S
new file mode 100644
index 0000000..895235b
--- /dev/null
+++ b/grub-core/lib/mips/setjmp.S
@@ -0,0 +1,71 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,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/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/dl.h>
+#include <grub/mips/asm.h>
+
+ .file "setjmp.S"
+
+GRUB_MOD_LICENSE "GPLv3+"
+
+ .text
+
+/*
+ * int grub_setjmp (grub_jmp_buf env)
+ */
+FUNCTION(grub_setjmp)
+ 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)
+ 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
new file mode 100644
index 0000000..28aa96c
--- /dev/null
+++ b/grub-core/lib/pbkdf2.c
@@ -0,0 +1,109 @@
+/* gc-pbkdf2-sha1.c --- Password-Based Key Derivation Function a'la PKCS#5
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009 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 2, 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, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Simon Josefsson. */
+/* Imported from gnulib. */
+
+#include <grub/crypto.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv2+");
+
+/* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant
+ of digest supplied by MD. Inputs are the password P of length PLEN,
+ the salt S of length SLEN, the iteration counter C (> 0), and the
+ desired derived output length DKLEN. Output buffer is DK which
+ must have room for at least DKLEN octets. The output buffer will
+ be filled with the derived data. */
+
+gcry_err_code_t
+grub_crypto_pbkdf2 (const struct gcry_md_spec *md,
+ const grub_uint8_t *P, grub_size_t Plen,
+ const grub_uint8_t *S, grub_size_t Slen,
+ unsigned int c,
+ grub_uint8_t *DK, grub_size_t dkLen)
+{
+ unsigned int hLen = md->mdlen;
+ grub_uint8_t U[GRUB_CRYPTO_MAX_MDLEN];
+ grub_uint8_t T[GRUB_CRYPTO_MAX_MDLEN];
+ unsigned int u;
+ unsigned int l;
+ unsigned int r;
+ unsigned int i;
+ unsigned int k;
+ gcry_err_code_t rc;
+ grub_uint8_t *tmp;
+ grub_size_t tmplen = Slen + 4;
+
+ if (md->mdlen > GRUB_CRYPTO_MAX_MDLEN || md->mdlen == 0)
+ return GPG_ERR_INV_ARG;
+
+ if (c == 0)
+ return GPG_ERR_INV_ARG;
+
+ if (dkLen == 0)
+ return GPG_ERR_INV_ARG;
+
+ if (dkLen > 4294967295U)
+ return GPG_ERR_INV_ARG;
+
+ l = ((dkLen - 1) / hLen) + 1;
+ r = dkLen - (l - 1) * hLen;
+
+ tmp = grub_malloc (tmplen);
+ if (tmp == NULL)
+ return GPG_ERR_OUT_OF_MEMORY;
+
+ grub_memcpy (tmp, S, Slen);
+
+ for (i = 1; i - 1 < l; i++)
+ {
+ grub_memset (T, 0, hLen);
+
+ for (u = 0; u < c; u++)
+ {
+ if (u == 0)
+ {
+ tmp[Slen + 0] = (i & 0xff000000) >> 24;
+ tmp[Slen + 1] = (i & 0x00ff0000) >> 16;
+ tmp[Slen + 2] = (i & 0x0000ff00) >> 8;
+ tmp[Slen + 3] = (i & 0x000000ff) >> 0;
+
+ rc = grub_crypto_hmac_buffer (md, P, Plen, tmp, tmplen, U);
+ }
+ else
+ rc = grub_crypto_hmac_buffer (md, P, Plen, U, hLen, U);
+
+ if (rc != GPG_ERR_NO_ERROR)
+ {
+ grub_free (tmp);
+ return rc;
+ }
+
+ for (k = 0; k < hLen; k++)
+ T[k] ^= U[k];
+ }
+
+ grub_memcpy (DK + (i - 1) * hLen, T, i == l ? r : hLen);
+ }
+
+ grub_free (tmp);
+
+ return GPG_ERR_NO_ERROR;
+}
diff --git a/grub-core/lib/posix_wrap/assert.h b/grub-core/lib/posix_wrap/assert.h
new file mode 100644
index 0000000..6b00a0b
--- /dev/null
+++ b/grub-core/lib/posix_wrap/assert.h
@@ -0,0 +1,33 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_ASSERT_H
+#define GRUB_POSIX_ASSERT_H 1
+
+#include <grub/misc.h>
+
+#define assert(x) assert_real(__FILE__, __LINE__, x)
+
+static inline void
+assert_real (const char *file, int line, int cond)
+{
+ if (!cond)
+ grub_printf ("Assertion failed at %s:%d\n", file, line);
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/ctype.h b/grub-core/lib/posix_wrap/ctype.h
new file mode 100644
index 0000000..38b5727
--- /dev/null
+++ b/grub-core/lib/posix_wrap/ctype.h
@@ -0,0 +1,108 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_CTYPE_H
+#define GRUB_POSIX_CTYPE_H 1
+
+#include <grub/misc.h>
+
+static inline int
+toupper (int c)
+{
+ return grub_toupper (c);
+}
+
+static inline int
+isspace (int c)
+{
+ return grub_isspace (c);
+}
+
+static inline int
+isdigit (int c)
+{
+ return grub_isdigit (c);
+}
+
+static inline int
+islower (int c)
+{
+ return grub_islower (c);
+}
+
+static inline int
+isascii (int c)
+{
+ return !(c & ~0x7f);
+}
+
+static inline int
+isupper (int c)
+{
+ return grub_isupper (c);
+}
+
+static inline int
+isxdigit (int c)
+{
+ return grub_isxdigit (c);
+}
+
+static inline int
+isprint (int c)
+{
+ return grub_isprint (c);
+}
+
+static inline int
+iscntrl (int c)
+{
+ return !grub_isprint (c);
+}
+
+static inline int
+isgraph (int c)
+{
+ return grub_isprint (c) && !grub_isspace (c);
+}
+
+static inline int
+isalnum (int c)
+{
+ return grub_isalpha (c) || grub_isdigit (c);
+}
+
+static inline int
+ispunct (int c)
+{
+ return grub_isprint (c) && !grub_isspace (c) && !isalnum (c);
+}
+
+static inline int
+isalpha (int c)
+{
+ return grub_isalpha (c);
+}
+
+static inline int
+tolower (int c)
+{
+ return grub_tolower (c);
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/errno.h b/grub-core/lib/posix_wrap/errno.h
new file mode 100644
index 0000000..ba63b23
--- /dev/null
+++ b/grub-core/lib/posix_wrap/errno.h
@@ -0,0 +1,29 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_ERRNO_H
+#define GRUB_POSIX_ERRNO_H 1
+
+#include <grub/err.h>
+
+#undef errno
+#define errno grub_errno
+#define EINVAL GRUB_ERR_BAD_NUMBER
+#define ENOMEM GRUB_ERR_OUT_OF_MEMORY
+
+#endif
diff --git a/grub-core/lib/posix_wrap/inttypes.h b/grub-core/lib/posix_wrap/inttypes.h
new file mode 100644
index 0000000..a12c43b
--- /dev/null
+++ b/grub-core/lib/posix_wrap/inttypes.h
@@ -0,0 +1 @@
+#include <sys/types.h>
diff --git a/grub-core/lib/posix_wrap/langinfo.h b/grub-core/lib/posix_wrap/langinfo.h
new file mode 100644
index 0000000..ab75af1
--- /dev/null
+++ b/grub-core/lib/posix_wrap/langinfo.h
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_LANGINFO_H
+#define GRUB_POSIX_LANGINFO_H 1
+
+#include <localcharset.h>
+
+typedef enum { CODESET } nl_item;
+
+static inline const char *
+nl_langinfo (nl_item item)
+{
+ switch (item)
+ {
+ case CODESET:
+ return "UTF-8";
+ default:
+ return "";
+ }
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/limits.h b/grub-core/lib/posix_wrap/limits.h
new file mode 100644
index 0000000..7217138
--- /dev/null
+++ b/grub-core/lib/posix_wrap/limits.h
@@ -0,0 +1,41 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_LIMITS_H
+#define GRUB_POSIX_LIMITS_H
+
+#include <grub/types.h>
+
+#define UCHAR_MAX GRUB_UCHAR_MAX
+#define USHRT_MAX GRUB_USHRT_MAX
+#define UINT_MAX GRUB_UINT_MAX
+#define ULONG_MAX GRUB_ULONG_MAX
+#define SIZE_MAX GRUB_SIZE_MAX
+
+#define SCHAR_MIN GRUB_SCHAR_MIN
+#define SCHAR_MAX GRUB_SCHAR_MAX
+#define SHRT_MIN GRUB_SHRT_MIN
+#define SHRT_MAX GRUB_SHRT_MAX
+#define INT_MIN GRUB_INT_MIN
+#define INT_MAX GRUB_INT_MAX
+#define LONG_MIN GRUB_LONG_MIN
+#define LONG_MAX GRUB_LONG_MAX
+
+#define CHAR_BIT 8
+
+#endif
diff --git a/grub-core/lib/posix_wrap/localcharset.h b/grub-core/lib/posix_wrap/localcharset.h
new file mode 100644
index 0000000..502d860
--- /dev/null
+++ b/grub-core/lib/posix_wrap/localcharset.h
@@ -0,0 +1,28 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_LOCALCHARSET_H
+#define GRUB_POSIX_LOCALCHARSET_H 1
+
+static inline const char *
+locale_charset (void)
+{
+ return "UTF-8";
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/locale.h b/grub-core/lib/posix_wrap/locale.h
new file mode 100644
index 0000000..569a765
--- /dev/null
+++ b/grub-core/lib/posix_wrap/locale.h
@@ -0,0 +1,3 @@
+#ifdef GRUB_UTIL
+#include_next <locale.h>
+#endif
diff --git a/grub-core/lib/posix_wrap/stdint.h b/grub-core/lib/posix_wrap/stdint.h
new file mode 100644
index 0000000..a12c43b
--- /dev/null
+++ b/grub-core/lib/posix_wrap/stdint.h
@@ -0,0 +1 @@
+#include <sys/types.h>
diff --git a/grub-core/lib/posix_wrap/stdio.h b/grub-core/lib/posix_wrap/stdio.h
new file mode 100644
index 0000000..d5a8b75
--- /dev/null
+++ b/grub-core/lib/posix_wrap/stdio.h
@@ -0,0 +1,43 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_STDIO_H
+#define GRUB_POSIX_STDIO_H 1
+
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <sys/types.h>
+
+typedef struct grub_file FILE;
+
+#define EOF -1
+
+static inline int
+snprintf (char *str, grub_size_t n, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start (ap, fmt);
+ ret = grub_vsnprintf (str, n, fmt, ap);
+ va_end (ap);
+
+ return ret;
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/stdlib.h b/grub-core/lib/posix_wrap/stdlib.h
new file mode 100644
index 0000000..7a8d385
--- /dev/null
+++ b/grub-core/lib/posix_wrap/stdlib.h
@@ -0,0 +1,61 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_STDLIB_H
+#define GRUB_POSIX_STDLIB_H 1
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/safemath.h>
+
+static inline void
+free (void *ptr)
+{
+ grub_free (ptr);
+}
+
+static inline void *
+malloc (grub_size_t size)
+{
+ return grub_malloc (size);
+}
+
+static inline void *
+calloc (grub_size_t size, grub_size_t nelem)
+{
+ grub_size_t sz;
+
+ if (grub_mul (size, nelem, &sz))
+ return NULL;
+
+ return grub_zalloc (sz);
+}
+
+static inline void *
+realloc (void *ptr, grub_size_t size)
+{
+ return grub_realloc (ptr, size);
+}
+
+static inline int
+abs (int c)
+{
+ return (c >= 0) ? c : -c;
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/string.h b/grub-core/lib/posix_wrap/string.h
new file mode 100644
index 0000000..7ae6eee
--- /dev/null
+++ b/grub-core/lib/posix_wrap/string.h
@@ -0,0 +1,92 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_STRING_H
+#define GRUB_POSIX_STRING_H 1
+
+#include <grub/misc.h>
+#include <sys/types.h>
+
+#define HAVE_STRCASECMP 1
+
+static inline grub_size_t
+strlen (const char *s)
+{
+ return grub_strlen (s);
+}
+
+static inline int
+strcmp (const char *s1, const char *s2)
+{
+ return grub_strcmp (s1, s2);
+}
+
+static inline int
+strcasecmp (const char *s1, const char *s2)
+{
+ return grub_strcasecmp (s1, s2);
+}
+
+static inline void
+bcopy (const void *src, void *dest, grub_size_t n)
+{
+ grub_memcpy (dest, src, n);
+}
+
+static inline char *
+strcpy (char *dest, const char *src)
+{
+ return grub_strcpy (dest, src);
+}
+
+static inline char *
+strstr (const char *haystack, const char *needle)
+{
+ return grub_strstr (haystack, needle);
+}
+
+static inline char *
+strchr (const char *s, int c)
+{
+ return grub_strchr (s, c);
+}
+
+static inline char *
+strncpy (char *dest, const char *src, grub_size_t n)
+{
+ return grub_strncpy (dest, src, n);
+}
+
+static inline int
+strcoll (const char *s1, const char *s2)
+{
+ return grub_strcmp (s1, s2);
+}
+
+static inline void *
+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/posix_wrap/sys/types.h b/grub-core/lib/posix_wrap/sys/types.h
new file mode 100644
index 0000000..854eb01
--- /dev/null
+++ b/grub-core/lib/posix_wrap/sys/types.h
@@ -0,0 +1,65 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_SYS_TYPES_H
+#define GRUB_POSIX_SYS_TYPES_H 1
+
+#include <grub/misc.h>
+
+#include <stddef.h>
+
+typedef grub_ssize_t ssize_t;
+#ifndef GRUB_POSIX_BOOL_DEFINED
+typedef enum { false = 0, true = 1 } bool;
+#define GRUB_POSIX_BOOL_DEFINED 1
+#endif
+
+typedef grub_uint8_t uint8_t;
+typedef grub_uint16_t uint16_t;
+typedef grub_uint32_t uint32_t;
+typedef grub_uint64_t uint64_t;
+
+typedef grub_int8_t int8_t;
+typedef grub_int16_t int16_t;
+typedef grub_int32_t int32_t;
+typedef grub_int64_t int64_t;
+
+#define HAVE_U64_TYPEDEF 1
+typedef grub_uint64_t u64;
+#define HAVE_U32_TYPEDEF 1
+typedef grub_uint32_t u32;
+#define HAVE_U16_TYPEDEF 1
+typedef grub_uint16_t u16;
+#define HAVE_BYTE_TYPEDEF 1
+typedef grub_uint8_t byte;
+
+typedef grub_addr_t uintptr_t;
+
+#define SIZEOF_UNSIGNED_LONG GRUB_CPU_SIZEOF_LONG
+#define SIZEOF_UNSIGNED_INT 4
+#define SIZEOF_UNSIGNED_LONG_LONG 8
+#define SIZEOF_UNSIGNED_SHORT 2
+#define SIZEOF_UINT64_T 8
+
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+#define WORDS_BIGENDIAN 1
+#else
+#undef WORDS_BIGENDIAN
+#endif
+
+#endif
diff --git a/grub-core/lib/posix_wrap/unistd.h b/grub-core/lib/posix_wrap/unistd.h
new file mode 100644
index 0000000..a12c43b
--- /dev/null
+++ b/grub-core/lib/posix_wrap/unistd.h
@@ -0,0 +1 @@
+#include <sys/types.h>
diff --git a/grub-core/lib/posix_wrap/wchar.h b/grub-core/lib/posix_wrap/wchar.h
new file mode 100644
index 0000000..e0e04a6
--- /dev/null
+++ b/grub-core/lib/posix_wrap/wchar.h
@@ -0,0 +1,119 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_POSIX_WCHAR_H
+#define GRUB_POSIX_WCHAR_H 1
+
+#include <grub/charset.h>
+
+#define wint_t grub_posix_wint_t
+#define wchar_t grub_posix_wchar_t
+#define mbstate_t grub_posix_mbstate_t
+
+/* UCS-4. */
+typedef grub_int32_t wint_t;
+enum
+ {
+ WEOF = -1
+ };
+
+/* UCS-4. */
+typedef grub_int32_t wchar_t;
+
+typedef struct mbstate {
+ grub_uint32_t code;
+ int count;
+} mbstate_t;
+
+/* UTF-8. */
+#define MB_CUR_MAX 4
+#define MB_LEN_MAX 4
+
+static inline size_t
+mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+ const char *ptr;
+ if (!s)
+ {
+ pwc = 0;
+ s = "";
+ n = 1;
+ }
+
+ if (pwc)
+ *pwc = 0;
+
+ for (ptr = s; ptr < s + n; ptr++)
+ {
+ if (!grub_utf8_process (*ptr, &ps->code, &ps->count))
+ return -1;
+ if (ps->count)
+ continue;
+ if (pwc)
+ *pwc = ps->code;
+ if (ps->code == 0)
+ return 0;
+ return ptr - s + 1;
+ }
+ return -2;
+}
+
+static inline int
+mbsinit(const mbstate_t *ps)
+{
+ return ps->count == 0;
+}
+
+static inline size_t
+wcrtomb (char *s, wchar_t wc, mbstate_t *ps __attribute__ ((unused)))
+{
+ if (s == 0)
+ return 1;
+ return grub_encode_utf8_character ((grub_uint8_t *) s,
+ (grub_uint8_t *) s + MB_LEN_MAX,
+ wc);
+}
+
+static inline wint_t btowc (int c)
+{
+ if (c & ~0x7f)
+ return WEOF;
+ return c;
+}
+
+
+static inline int
+wcscoll (const wchar_t *s1, const wchar_t *s2)
+{
+ while (*s1 && *s2)
+ {
+ if (*s1 != *s2)
+ break;
+
+ s1++;
+ s2++;
+ }
+
+ if (*s1 < *s2)
+ return -1;
+ if (*s1 > *s2)
+ return +1;
+ return 0;
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/wctype.h b/grub-core/lib/posix_wrap/wctype.h
new file mode 100644
index 0000000..3771dc5
--- /dev/null
+++ b/grub-core/lib/posix_wrap/wctype.h
@@ -0,0 +1,110 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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_POSIX_WCTYPE_H
+#define GRUB_POSIX_WCTYPE_H 1
+
+#include <grub/misc.h>
+#include <wchar.h>
+
+#define wctype_t grub_posix_wctype_t
+
+typedef enum { GRUB_CTYPE_INVALID,
+ GRUB_CTYPE_ALNUM, GRUB_CTYPE_CNTRL, GRUB_CTYPE_LOWER,
+ GRUB_CTYPE_SPACE, GRUB_CTYPE_ALPHA, GRUB_CTYPE_DIGIT,
+ GRUB_CTYPE_PRINT, GRUB_CTYPE_UPPER, GRUB_CTYPE_BLANK,
+ GRUB_CTYPE_GRAPH, GRUB_CTYPE_PUNCT, GRUB_CTYPE_XDIGIT,
+ GRUB_CTYPE_MAX} wctype_t;
+
+#define CHARCLASS_NAME_MAX (sizeof ("xdigit") - 1)
+
+static inline wctype_t
+wctype (const char *name)
+{
+ wctype_t i;
+ static const char names[][10] = { "",
+ "alnum", "cntrl", "lower",
+ "space", "alpha", "digit",
+ "print", "upper", "blank",
+ "graph", "punct", "xdigit" };
+ for (i = GRUB_CTYPE_INVALID; i < GRUB_CTYPE_MAX; i++)
+ if (grub_strcmp (names[i], name) == 0)
+ return i;
+ return GRUB_CTYPE_INVALID;
+}
+
+/* FIXME: take into account international lowercase characters. */
+static inline int
+iswlower (wint_t wc)
+{
+ return grub_islower (wc);
+}
+
+static inline wint_t
+towlower (wint_t c)
+{
+ return grub_tolower (c);
+}
+
+static inline wint_t
+towupper (wint_t c)
+{
+ return grub_toupper (c);
+}
+
+static inline int
+iswalnum (wint_t c)
+{
+ return grub_isalpha (c) || grub_isdigit (c);
+}
+
+static inline int
+iswctype (wint_t wc, wctype_t desc)
+{
+ switch (desc)
+ {
+ case GRUB_CTYPE_ALNUM:
+ return iswalnum (wc);
+ case GRUB_CTYPE_CNTRL:
+ return grub_iscntrl (wc);
+ case GRUB_CTYPE_LOWER:
+ return iswlower (wc);
+ case GRUB_CTYPE_SPACE:
+ return grub_isspace (wc);
+ case GRUB_CTYPE_ALPHA:
+ return grub_isalpha (wc);
+ case GRUB_CTYPE_DIGIT:
+ return grub_isdigit (wc);
+ case GRUB_CTYPE_PRINT:
+ return grub_isprint (wc);
+ case GRUB_CTYPE_UPPER:
+ return grub_isupper (wc);
+ case GRUB_CTYPE_BLANK:
+ return wc == ' ' || wc == '\t';
+ case GRUB_CTYPE_GRAPH:
+ return grub_isgraph (wc);
+ case GRUB_CTYPE_PUNCT:
+ return grub_isprint (wc) && !grub_isspace (wc) && !iswalnum (wc);
+ case GRUB_CTYPE_XDIGIT:
+ return grub_isxdigit (wc);
+ default:
+ return 0;
+ }
+}
+
+#endif
diff --git a/grub-core/lib/powerpc/relocator.c b/grub-core/lib/powerpc/relocator.c
new file mode 100644
index 0000000..8ffb8b6
--- /dev/null
+++ b/grub-core/lib/powerpc/relocator.c
@@ -0,0 +1,140 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+
+#include <grub/types.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/cache.h>
+
+#include <grub/powerpc/relocator.h>
+#include <grub/relocator_private.h>
+
+extern grub_uint8_t grub_relocator_forward_start;
+extern grub_uint8_t grub_relocator_forward_end;
+extern grub_uint8_t grub_relocator_backward_start;
+extern grub_uint8_t grub_relocator_backward_end;
+
+#define REGW_SIZEOF (2 * sizeof (grub_uint32_t))
+#define JUMP_SIZEOF (sizeof (grub_uint32_t))
+
+#define RELOCATOR_SRC_SIZEOF(x) (&grub_relocator_##x##_end \
+ - &grub_relocator_##x##_start)
+#define RELOCATOR_SIZEOF(x) (RELOCATOR_SRC_SIZEOF(x) \
+ + REGW_SIZEOF * 3)
+grub_size_t grub_relocator_align = sizeof (grub_uint32_t);
+grub_size_t grub_relocator_forward_size;
+grub_size_t grub_relocator_backward_size;
+grub_size_t grub_relocator_jumper_size = JUMP_SIZEOF + REGW_SIZEOF;
+
+void
+grub_cpu_relocator_init (void)
+{
+ grub_relocator_forward_size = RELOCATOR_SIZEOF(forward);
+ grub_relocator_backward_size = RELOCATOR_SIZEOF(backward);
+}
+
+static void
+write_reg (int regn, grub_uint32_t val, void **target)
+{
+ /* lis r, val >> 16 */
+ *(grub_uint32_t *) *target =
+ ((0x3c00 | (regn << 5)) << 16) | (val >> 16);
+ *target = ((grub_uint32_t *) *target) + 1;
+ /* ori r, r, val & 0xffff. */
+ *(grub_uint32_t *) *target = (((0x6000 | regn << 5 | regn) << 16)
+ | (val & 0xffff));
+ *target = ((grub_uint32_t *) *target) + 1;
+}
+
+static void
+write_jump (void **target)
+{
+ /* blr. */
+ *(grub_uint32_t *) *target = 0x4e800020;
+ *target = ((grub_uint32_t *) *target) + 1;
+}
+
+void
+grub_cpu_relocator_jumper (void *rels, grub_addr_t addr)
+{
+ write_reg (GRUB_PPC_JUMP_REGISTER, addr, &rels);
+ write_jump (&rels);
+}
+
+void
+grub_cpu_relocator_backward (void *ptr0, void *src, void *dest,
+ grub_size_t size)
+{
+ void *ptr = ptr0;
+ write_reg (8, (grub_uint32_t) src, &ptr);
+ write_reg (9, (grub_uint32_t) dest, &ptr);
+ write_reg (10, (grub_uint32_t) size, &ptr);
+ grub_memcpy (ptr, &grub_relocator_backward_start,
+ RELOCATOR_SRC_SIZEOF (backward));
+}
+
+void
+grub_cpu_relocator_forward (void *ptr0, void *src, void *dest,
+ grub_size_t size)
+{
+ void *ptr = ptr0;
+ write_reg (8, (grub_uint32_t) src, &ptr);
+ write_reg (9, (grub_uint32_t) dest, &ptr);
+ write_reg (10, (grub_uint32_t) size, &ptr);
+ grub_memcpy (ptr, &grub_relocator_forward_start,
+ RELOCATOR_SRC_SIZEOF (forward));
+}
+
+grub_err_t
+grub_relocator32_boot (struct grub_relocator *rel,
+ struct grub_relocator32_state state)
+{
+ void *ptr;
+ grub_err_t err;
+ void *relst;
+ grub_size_t relsize;
+ grub_size_t stateset_size = 32 * REGW_SIZEOF + JUMP_SIZEOF;
+ unsigned i;
+ grub_relocator_chunk_t ch;
+
+ err = grub_relocator_alloc_chunk_align (rel, &ch, 0, UP_TO_TOP32 (stateset_size),
+ stateset_size, sizeof (grub_uint32_t),
+ GRUB_RELOCATOR_PREFERENCE_NONE, 0);
+ if (err)
+ return err;
+
+ ptr = get_virtual_current_address (ch);
+ for (i = 0; i < 32; i++)
+ write_reg (i, state.gpr[i], &ptr);
+ write_jump (&ptr);
+
+ err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
+ &relst, &relsize);
+ if (err)
+ return err;
+
+ grub_arch_sync_caches ((void *) relst, relsize);
+
+ ((void (*) (void)) relst) ();
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/lib/powerpc/relocator_asm.S b/grub-core/lib/powerpc/relocator_asm.S
new file mode 100644
index 0000000..355e9c8
--- /dev/null
+++ b/grub-core/lib/powerpc/relocator_asm.S
@@ -0,0 +1,60 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+
+ .p2align 4 /* force 16-byte alignment */
+
+VARIABLE (grub_relocator_forward_start)
+ mr 3, 9
+ mr 4, 10
+
+copycont1:
+ lbz 11,0(8)
+ stb 11,0(9)
+ addi 8, 8, 0x1
+ addi 9, 9, 0x1
+ addi 10, 10, -1
+ cmpwi 10, 0
+ bne copycont1
+
+#include "../../kern/powerpc/cache_flush.S"
+
+VARIABLE (grub_relocator_forward_end)
+
+VARIABLE (grub_relocator_backward_start)
+ mr 3, 9
+ mr 4, 10
+
+ add 9, 9, 10
+ add 8, 8, 10
+ /* Backward movsl is implicitly off-by-one. compensate that. */
+ addi 9, 9, -1
+ addi 8, 8, -1
+copycont2:
+ lbz 11,0(8)
+ stb 11,0(9)
+ addi 8, 8, -1
+ addi 9, 9, -1
+ addi 10, 10, -1
+ cmpwi 10, 0
+ bne copycont2
+
+#include "../../kern/powerpc/cache_flush.S"
+
+VARIABLE (grub_relocator_backward_end)
diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S
new file mode 100644
index 0000000..716b563
--- /dev/null
+++ b/grub-core/lib/powerpc/setjmp.S
@@ -0,0 +1,89 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/dl.h>
+
+ .file "setjmp.S"
+
+GRUB_MOD_LICENSE "GPLv3+"
+
+ .text
+
+/*
+ * int grub_setjmp (grub_jmp_buf env)
+ */
+FUNCTION(grub_setjmp)
+ stw 1, 0(3)
+ stw 14, 4(3)
+ stw 15, 8(3)
+ stw 16, 12(3)
+ stw 17, 16(3)
+ stw 18, 20(3)
+ stw 19, 24(3)
+ stw 20, 28(3)
+ stw 21, 32(3)
+ stw 22, 36(3)
+ stw 23, 40(3)
+ stw 24, 44(3)
+ stw 25, 48(3)
+ stw 26, 52(3)
+ stw 27, 56(3)
+ stw 28, 60(3)
+ stw 29, 64(3)
+ stw 30, 68(3)
+ stw 31, 72(3)
+ mflr 4
+ stw 4, 76(3)
+ mfcr 4
+ stw 4, 80(3)
+ li 3, 0
+ blr
+
+/*
+ * int grub_longjmp (grub_jmp_buf env, int val)
+ */
+FUNCTION(grub_longjmp)
+ lwz 1, 0(3)
+ lwz 14, 4(3)
+ lwz 15, 8(3)
+ lwz 16, 12(3)
+ lwz 17, 16(3)
+ lwz 18, 20(3)
+ lwz 19, 24(3)
+ lwz 20, 28(3)
+ lwz 21, 32(3)
+ lwz 22, 36(3)
+ lwz 23, 40(3)
+ lwz 24, 44(3)
+ lwz 25, 48(3)
+ lwz 26, 52(3)
+ lwz 27, 56(3)
+ lwz 28, 60(3)
+ lwz 29, 64(3)
+ lwz 30, 68(3)
+ lwz 31, 72(3)
+ lwz 5, 76(3)
+ mtlr 5
+ lwz 5, 80(3)
+ mtcr 5
+ mr. 3, 4
+ bne 1f
+ li 3, 1
+1: blr
+
diff --git a/grub-core/lib/priority_queue.c b/grub-core/lib/priority_queue.c
new file mode 100644
index 0000000..7d5e7c0
--- /dev/null
+++ b/grub-core/lib/priority_queue.c
@@ -0,0 +1,163 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/priority_queue.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_priority_queue
+{
+ grub_size_t elsize;
+ grub_size_t allocated;
+ grub_size_t used;
+ grub_comparator_t cmp;
+ void *els;
+};
+
+static inline void *
+element (struct grub_priority_queue *pq, grub_size_t k)
+{
+ return ((grub_uint8_t *) pq->els) + k * pq->elsize;
+}
+
+static inline void
+swap (struct grub_priority_queue *pq, grub_size_t m, grub_size_t n)
+{
+ grub_uint8_t *p1, *p2;
+ grub_size_t l;
+ p1 = (grub_uint8_t *) element (pq, m);
+ p2 = (grub_uint8_t *) element (pq, n);
+ for (l = pq->elsize; l; l--, p1++, p2++)
+ {
+ grub_uint8_t t;
+ t = *p1;
+ *p1 = *p2;
+ *p2 = t;
+ }
+}
+
+static inline grub_size_t
+parent (grub_size_t v)
+{
+ return (v - 1) / 2;
+}
+
+static inline grub_size_t
+left_child (grub_size_t v)
+{
+ return 2 * v + 1;
+}
+
+static inline grub_size_t
+right_child (grub_size_t v)
+{
+ return 2 * v + 2;
+}
+
+void *
+grub_priority_queue_top (grub_priority_queue_t pq)
+{
+ if (!pq->used)
+ return 0;
+ return element (pq, 0);
+}
+
+void
+grub_priority_queue_destroy (grub_priority_queue_t pq)
+{
+ grub_free (pq->els);
+ grub_free (pq);
+}
+
+grub_priority_queue_t
+grub_priority_queue_new (grub_size_t elsize,
+ grub_comparator_t cmp)
+{
+ struct grub_priority_queue *ret;
+ void *els;
+ els = grub_calloc (8, elsize);
+ if (!els)
+ return 0;
+ ret = (struct grub_priority_queue *) grub_malloc (sizeof (*ret));
+ if (!ret)
+ {
+ grub_free (els);
+ return 0;
+ }
+ ret->elsize = elsize;
+ ret->allocated = 8;
+ ret->used = 0;
+ ret->cmp = cmp;
+ ret->els = els;
+ return ret;
+}
+
+/* Heap property: pq->cmp (element (pq, p), element (pq, parent (p))) <= 0. */
+grub_err_t
+grub_priority_queue_push (grub_priority_queue_t pq, const void *el)
+{
+ grub_size_t p;
+ if (pq->used == pq->allocated)
+ {
+ void *els;
+ els = grub_realloc (pq->els, pq->elsize * 2 * pq->allocated);
+ if (!els)
+ return grub_errno;
+ pq->allocated *= 2;
+ pq->els = els;
+ }
+ pq->used++;
+ grub_memcpy (element (pq, pq->used - 1), el, pq->elsize);
+ for (p = pq->used - 1; p; p = parent (p))
+ {
+ if (pq->cmp (element (pq, p), element (pq, parent (p))) <= 0)
+ break;
+ swap (pq, p, parent (p));
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_priority_queue_pop (grub_priority_queue_t pq)
+{
+ grub_size_t p;
+
+ swap (pq, 0, pq->used - 1);
+ pq->used--;
+ for (p = 0; left_child (p) < pq->used; )
+ {
+ grub_size_t c;
+ if (pq->cmp (element (pq, left_child (p)), element (pq, p)) <= 0
+ && (right_child (p) >= pq->used
+ || pq->cmp (element (pq, right_child (p)), element (pq, p)) <= 0))
+ break;
+ if (right_child (p) >= pq->used
+ || pq->cmp (element (pq, left_child (p)),
+ element (pq, right_child (p))) > 0)
+ c = left_child (p);
+ else
+ c = right_child (p);
+ swap (pq, p, c);
+ p = c;
+ }
+}
+
+
diff --git a/grub-core/lib/progress.c b/grub-core/lib/progress.c
new file mode 100644
index 0000000..4b7cbbc
--- /dev/null
+++ b/grub-core/lib/progress.c
@@ -0,0 +1,145 @@
+/* progress.c - show loading progress */
+/*
+ * 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/types.h>
+#include <grub/time.h>
+#include <grub/term.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/normal.h>
+#include <grub/net.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define UPDATE_INTERVAL 800
+
+static void
+grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)),
+ unsigned offset __attribute__ ((unused)),
+ unsigned length, void *data)
+{
+ static int call_depth = 0;
+ 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 ();
+
+ if (((now - last_progress_update_time > UPDATE_INTERVAL) &&
+ (file->progress_offset - file->offset > 0)) ||
+ (file->progress_offset == file->size))
+ {
+ static char buffer[80];
+ struct grub_term_output *term;
+ const char *partial_file_name;
+
+ unsigned long long percent;
+ grub_uint64_t current_speed;
+
+ if (now - file->last_progress_time < 10)
+ current_speed = 0;
+ else
+ current_speed = grub_divmod64 ((file->progress_offset
+ - file->last_progress_offset)
+ * 100ULL * 1000ULL,
+ now - file->last_progress_time, 0);
+
+ if (file->size == 0)
+ percent = 100;
+ else
+ percent = grub_divmod64 (100 * file->progress_offset,
+ file->size, 0);
+
+ /* 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
+ partial_file_name = "";
+
+ file->estimated_speed = (file->estimated_speed + current_speed) >> 1;
+
+ grub_snprintf (buffer, sizeof (buffer), " [ %.20s %s %llu%% ",
+ partial_file_name,
+ grub_get_human_size (file->progress_offset,
+ GRUB_HUMAN_SIZE_NORMAL),
+ (unsigned long long) percent);
+
+ char *ptr = buffer + grub_strlen (buffer);
+ grub_snprintf (ptr, sizeof (buffer) - (ptr - buffer), "%s ]",
+ grub_get_human_size (file->estimated_speed,
+ GRUB_HUMAN_SIZE_SPEED));
+
+ grub_size_t len = grub_strlen (buffer);
+ FOR_ACTIVE_TERM_OUTPUTS (term)
+ {
+ if (term->progress_update_counter++ > term->progress_update_divisor
+ || (file->progress_offset == file->size
+ && term->progress_update_divisor
+ != (unsigned) GRUB_PROGRESS_NO_UPDATE))
+ {
+ struct grub_term_coordinate old_pos = grub_term_getxy (term);
+ struct grub_term_coordinate new_pos = old_pos;
+ new_pos.x = grub_term_width (term) - len - 1;
+
+ grub_term_gotoxy (term, new_pos);
+ grub_puts_terminal (buffer, term);
+ grub_term_gotoxy (term, old_pos);
+
+ term->progress_update_counter = 0;
+
+ if (term->refresh)
+ term->refresh (term);
+ }
+ }
+
+ file->last_progress_offset = file->progress_offset;
+ file->last_progress_time = now;
+ last_progress_update_time = now;
+ }
+ call_depth = 0;
+}
+
+GRUB_MOD_INIT(progress)
+{
+ grub_file_progress_hook = grub_file_progress_hook_real;
+}
+
+GRUB_MOD_FINI(progress)
+{
+ grub_file_progress_hook = 0;
+}
diff --git a/grub-core/lib/random.c b/grub-core/lib/random.c
new file mode 100644
index 0000000..43b9664
--- /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
new file mode 100644
index 0000000..467305b
--- /dev/null
+++ b/grub-core/lib/reed_solomon.c
@@ -0,0 +1,493 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef TEST
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define xcalloc calloc
+#define xmalloc malloc
+#define grub_memset memset
+#define grub_memcpy memcpy
+#endif
+
+#ifndef STANDALONE
+#include <assert.h>
+#endif
+
+#ifndef STANDALONE
+#ifdef TEST
+typedef unsigned int grub_size_t;
+typedef unsigned char grub_uint8_t;
+#else
+#include <grub/types.h>
+#include <grub/reed_solomon.h>
+#include <grub/util/misc.h>
+#include <grub/misc.h>
+#endif
+#endif
+
+#define SECTOR_SIZE 512
+#define MAX_BLOCK_SIZE (200 * SECTOR_SIZE)
+
+#ifdef STANDALONE
+#ifdef TEST
+typedef unsigned int grub_size_t;
+typedef unsigned char grub_uint8_t;
+#else
+#include <grub/types.h>
+#include <grub/misc.h>
+#endif
+#ifdef __i386__
+#define REED_SOLOMON_ATTRIBUTE __attribute__ ((regparm(3)))
+#else
+#define REED_SOLOMON_ATTRIBUTE
+#endif
+void
+grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs)
+ REED_SOLOMON_ATTRIBUTE;
+#else
+#define REED_SOLOMON_ATTRIBUTE
+#endif
+
+#define GF_SIZE 8
+typedef grub_uint8_t gf_single_t;
+#define GF_POLYNOMIAL 0x1d
+#define GF_INVERT2 0x8e
+#if defined (STANDALONE) && !defined (TEST)
+
+#ifdef __APPLE__
+#define ATTRIBUTE_TEXT __attribute__ ((section("_text,_text")))
+#else
+#define ATTRIBUTE_TEXT __attribute__ ((section(".text")))
+#endif
+
+static gf_single_t * const gf_powx ATTRIBUTE_TEXT = (void *) 0x100000;
+static gf_single_t * const gf_powx_inv ATTRIBUTE_TEXT = (void *) 0x100200;
+static int *const chosenstat ATTRIBUTE_TEXT = (void *) 0x100300;
+static gf_single_t *const sigma ATTRIBUTE_TEXT = (void *) 0x100700;
+static gf_single_t *const errpot ATTRIBUTE_TEXT = (void *) 0x100800;
+static int *const errpos ATTRIBUTE_TEXT = (void *) 0x100900;
+static gf_single_t *const sy ATTRIBUTE_TEXT = (void *) 0x100d00;
+static gf_single_t *const mstat ATTRIBUTE_TEXT = (void *) 0x100e00;
+static gf_single_t *const errvals ATTRIBUTE_TEXT = (void *) 0x100f00;
+static gf_single_t *const eqstat ATTRIBUTE_TEXT = (void *) 0x101000;
+/* Next available address: (void *) 0x112000. */
+#else
+
+static gf_single_t gf_powx[255 * 2];
+static gf_single_t gf_powx_inv[256];
+static int chosenstat[256];
+static gf_single_t sigma[256];
+static gf_single_t errpot[256];
+static int errpos[256];
+static gf_single_t sy[256];
+static gf_single_t mstat[256];
+static gf_single_t errvals[256];
+static gf_single_t eqstat[65536 + 256];
+#endif
+
+static gf_single_t
+gf_mul (gf_single_t a, gf_single_t b)
+{
+ if (a == 0 || b == 0)
+ return 0;
+ return gf_powx[(int) gf_powx_inv[a] + (int) gf_powx_inv[b]];
+}
+
+static inline gf_single_t
+gf_invert (gf_single_t a)
+{
+ return gf_powx[255 - (int) gf_powx_inv[a]];
+}
+
+static void
+init_powx (void)
+{
+ int i;
+ grub_uint8_t cur = 1;
+
+ gf_powx_inv[0] = 0;
+ for (i = 0; i < 255; i++)
+ {
+ gf_powx[i] = cur;
+ gf_powx[i + 255] = cur;
+ gf_powx_inv[cur] = i;
+ if (cur & (1ULL << (GF_SIZE - 1)))
+ cur = (cur << 1) ^ GF_POLYNOMIAL;
+ else
+ cur <<= 1;
+ }
+}
+
+static gf_single_t
+pol_evaluate (gf_single_t *pol, grub_size_t degree, int log_x)
+{
+ int i;
+ gf_single_t s = 0;
+ int log_xn = 0;
+ for (i = degree; i >= 0; i--)
+ {
+ if (pol[i])
+ s ^= gf_powx[(int) gf_powx_inv[pol[i]] + log_xn];
+ log_xn += log_x;
+ if (log_xn >= ((1 << GF_SIZE) - 1))
+ log_xn -= ((1 << GF_SIZE) - 1);
+ }
+ return s;
+}
+
+#if !defined (STANDALONE)
+static void
+rs_encode (gf_single_t *data, grub_size_t s, grub_size_t rs)
+{
+ gf_single_t *rs_polynomial;
+ int i, j;
+ gf_single_t *m;
+ m = xcalloc (s + rs, sizeof (gf_single_t));
+ grub_memcpy (m, data, s * sizeof (gf_single_t));
+ rs_polynomial = xcalloc (rs + 1, sizeof (gf_single_t));
+ rs_polynomial[rs] = 1;
+ /* Multiply with X - a^r */
+ for (j = 0; j < rs; j++)
+ {
+ for (i = 0; i < rs; i++)
+ if (rs_polynomial[i])
+ rs_polynomial[i] = (rs_polynomial[i + 1]
+ ^ gf_powx[j + (int) gf_powx_inv[rs_polynomial[i]]]);
+ else
+ rs_polynomial[i] = rs_polynomial[i + 1];
+ if (rs_polynomial[rs])
+ rs_polynomial[rs] = gf_powx[j + (int) gf_powx_inv[rs_polynomial[rs]]];
+ }
+ for (j = 0; j < s; j++)
+ if (m[j])
+ {
+ gf_single_t f = m[j];
+ for (i = 0; i <= rs; i++)
+ m[i+j] ^= gf_mul (rs_polynomial[i], f);
+ }
+ free (rs_polynomial);
+ grub_memcpy (data + s, m + s, rs * sizeof (gf_single_t));
+ free (m);
+}
+#endif
+
+static void
+gauss_eliminate (gf_single_t *eq, int n, int m, int *chosen)
+{
+ int i, j;
+
+ for (i = 0 ; i < n; i++)
+ {
+ int nzidx;
+ int k;
+ gf_single_t r;
+ for (nzidx = 0; nzidx < m && (eq[i * (m + 1) + nzidx] == 0);
+ nzidx++);
+ if (nzidx == m)
+ continue;
+ chosen[i] = nzidx;
+ r = gf_invert (eq[i * (m + 1) + nzidx]);
+ for (j = 0; j < m + 1; j++)
+ eq[i * (m + 1) + j] = gf_mul (eq[i * (m + 1) + j], r);
+ for (j = i + 1; j < n; j++)
+ {
+ gf_single_t rr = eq[j * (m + 1) + nzidx];
+ for (k = 0; k < m + 1; k++)
+ eq[j * (m + 1) + k] ^= gf_mul (eq[i * (m + 1) + k], rr);
+ }
+ }
+}
+
+static void
+gauss_solve (gf_single_t *eq, int n, int m, gf_single_t *sol)
+{
+ int i, j;
+
+ for (i = 0; i < n; i++)
+ chosenstat[i] = -1;
+ for (i = 0; i < m; i++)
+ sol[i] = 0;
+ gauss_eliminate (eq, n, m, chosenstat);
+ for (i = n - 1; i >= 0; i--)
+ {
+ gf_single_t s = 0;
+ if (chosenstat[i] == -1)
+ continue;
+ for (j = 0; j < m; j++)
+ s ^= gf_mul (eq[i * (m + 1) + j], sol[j]);
+ s ^= eq[i * (m + 1) + m];
+ sol[chosenstat[i]] = s;
+ }
+}
+
+static void
+rs_recover (gf_single_t *mm, grub_size_t s, grub_size_t rs)
+{
+ grub_size_t rs2 = rs / 2;
+ int errnum = 0;
+ int i, j;
+
+ for (i = 0; i < (int) rs; i++)
+ sy[i] = pol_evaluate (mm, s + rs - 1, i);
+
+ for (i = 0; i < (int) rs; i++)
+ if (sy[i] != 0)
+ break;
+
+ /* No error detected. */
+ if (i == (int) rs)
+ return;
+
+ {
+
+ for (i = 0; i < (int) rs2; i++)
+ for (j = 0; j < (int) rs2 + 1; j++)
+ eqstat[i * (rs2 + 1) + j] = sy[i+j];
+
+ for (i = 0; i < (int) rs2; i++)
+ sigma[i] = 0;
+
+ gauss_solve (eqstat, rs2, rs2, sigma);
+ }
+
+ for (i = 0; i < (int) (rs + s); i++)
+ if (pol_evaluate (sigma, rs2 - 1, 255 - i) == gf_powx[i])
+ {
+ errpot[errnum] = gf_powx[i];
+ errpos[errnum++] = s + rs - i - 1;
+ }
+ {
+ for (j = 0; j < errnum; j++)
+ eqstat[j] = 1;
+ eqstat[errnum] = sy[0];
+ for (i = 1; i < (int) rs; i++)
+ {
+ for (j = 0; j < (int) errnum; j++)
+ eqstat[(errnum + 1) * i + j] = gf_mul (errpot[j],
+ eqstat[(errnum + 1) * (i - 1)
+ + j]);
+ eqstat[(errnum + 1) * i + errnum] = sy[i];
+ }
+
+ gauss_solve (eqstat, rs, errnum, errvals);
+
+ for (i = 0; i < (int) errnum; i++)
+ mm[errpos[i]] ^= errvals[i];
+ }
+}
+
+static void
+decode_block (gf_single_t *ptr, grub_size_t s,
+ gf_single_t *rptr, grub_size_t rs)
+{
+ int i, j;
+ for (i = 0; i < SECTOR_SIZE; i++)
+ {
+ grub_size_t ds = (s + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
+ grub_size_t rr = (rs + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
+
+ /* Nothing to do. */
+ if (!ds || !rr)
+ continue;
+
+ for (j = 0; j < (int) ds; j++)
+ mstat[j] = ptr[SECTOR_SIZE * j + i];
+ for (j = 0; j < (int) rr; j++)
+ mstat[j + ds] = rptr[SECTOR_SIZE * j + i];
+
+ rs_recover (mstat, ds, rr);
+
+ for (j = 0; j < (int) ds; j++)
+ ptr[SECTOR_SIZE * j + i] = mstat[j];
+ }
+}
+
+#if !defined (STANDALONE)
+static void
+encode_block (gf_single_t *ptr, grub_size_t s,
+ gf_single_t *rptr, grub_size_t rs)
+{
+ int i, j;
+ for (i = 0; i < SECTOR_SIZE; i++)
+ {
+ grub_size_t ds = (s + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
+ grub_size_t rr = (rs + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
+ gf_single_t *m;
+
+ if (!ds || !rr)
+ continue;
+
+ m = xmalloc (ds + rr);
+ for (j = 0; j < ds; j++)
+ m[j] = ptr[SECTOR_SIZE * j + i];
+ rs_encode (m, ds, rr);
+ for (j = 0; j < rr; j++)
+ rptr[SECTOR_SIZE * j + i] = m[j + ds];
+ free (m);
+ }
+}
+#endif
+
+#if !defined (STANDALONE)
+void
+grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
+ grub_size_t redundancy)
+{
+ grub_size_t s = data_size;
+ grub_size_t rs = redundancy;
+ gf_single_t *ptr = buffer;
+ gf_single_t *rptr = ptr + s;
+ void *tmp;
+
+ tmp = xmalloc (data_size);
+ grub_memcpy (tmp, buffer, data_size);
+
+ /* Nothing to do. */
+ if (!rs)
+ goto exit;
+
+ init_powx ();
+
+ while (s > 0)
+ {
+ grub_size_t tt;
+ grub_size_t cs, crs;
+ cs = s;
+ crs = rs;
+ tt = cs + crs;
+ if (tt > MAX_BLOCK_SIZE)
+ {
+ cs = ((cs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
+ crs = ((crs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
+ }
+ encode_block (ptr, cs, rptr, crs);
+ ptr += cs;
+ rptr += crs;
+ s -= cs;
+ rs -= crs;
+ }
+
+#ifndef TEST
+ assert (grub_memcmp (tmp, buffer, data_size) == 0);
+#endif
+exit:
+ free (tmp);
+}
+#endif
+
+void REED_SOLOMON_ATTRIBUTE
+grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs)
+{
+ gf_single_t *ptr = ptr_;
+ gf_single_t *rptr = ptr + s;
+ grub_uint8_t *cptr;
+
+ /* Nothing to do. */
+ if (!rs)
+ return;
+
+ for (cptr = rptr + rs - 1; cptr >= rptr; cptr--)
+ if (*cptr)
+ break;
+ if (rptr + rs - 1 - cptr > (grub_ssize_t) rs / 2)
+ return;
+
+ init_powx ();
+
+ while (s > 0)
+ {
+ grub_size_t tt;
+ grub_size_t cs, crs;
+ cs = s;
+ crs = rs;
+ tt = cs + crs;
+ if (tt > MAX_BLOCK_SIZE)
+ {
+ cs = ((cs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
+ crs = ((crs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
+ }
+ decode_block (ptr, cs, rptr, crs);
+ ptr += cs;
+ rptr += crs;
+ s -= cs;
+ rs -= crs;
+ }
+}
+
+#ifdef TEST
+int
+main (int argc, char **argv)
+{
+ FILE *in, *out;
+ grub_size_t s, rs;
+ char *buf;
+
+ grub_memset (gf_powx, 0xee, sizeof (gf_powx));
+ grub_memset (gf_powx_inv, 0xdd, sizeof (gf_powx_inv));
+
+#ifndef STANDALONE
+ init_powx ();
+#endif
+
+#ifndef STANDALONE
+ in = grub_util_fopen ("tst.bin", "rb");
+ if (!in)
+ return 1;
+ fseek (in, 0, SEEK_END);
+ s = ftell (in);
+ fseek (in, 0, SEEK_SET);
+ rs = 0x7007;
+ buf = xmalloc (s + rs + SECTOR_SIZE);
+ fread (buf, 1, s, in);
+ fclose (in);
+
+ grub_reed_solomon_add_redundancy (buf, s, rs);
+
+ out = grub_util_fopen ("tst_rs.bin", "wb");
+ fwrite (buf, 1, s + rs, out);
+ fclose (out);
+#else
+ out = grub_util_fopen ("tst_rs.bin", "rb");
+ fseek (out, 0, SEEK_END);
+ s = ftell (out);
+ fseek (out, 0, SEEK_SET);
+ rs = 0x7007;
+ s -= rs;
+
+ buf = xmalloc (s + rs + SECTOR_SIZE);
+ fread (buf, 1, s + rs, out);
+ fclose (out);
+#endif
+#if 1
+ grub_memset (buf + 512 * 15, 0, 512);
+#endif
+
+ out = grub_util_fopen ("tst_dam.bin", "wb");
+ fwrite (buf, 1, s + rs, out);
+ fclose (out);
+ grub_reed_solomon_recover (buf, s, rs);
+
+ out = grub_util_fopen ("tst_rec.bin", "wb");
+ fwrite (buf, 1, s, out);
+ fclose (out);
+
+ return 0;
+}
+#endif
diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c
new file mode 100644
index 0000000..f2c1944
--- /dev/null
+++ b/grub-core/lib/relocator.c
@@ -0,0 +1,1657 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/relocator.h>
+#include <grub/relocator_private.h>
+#include <grub/mm_private.h>
+#include <grub/misc.h>
+#include <grub/cache.h>
+#include <grub/memory.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_relocator
+{
+ struct grub_relocator_chunk *chunks;
+ grub_phys_addr_t postchunks;
+ grub_phys_addr_t highestaddr;
+ grub_phys_addr_t highestnonpostaddr;
+ grub_size_t relocators_size;
+};
+
+struct grub_relocator_subchunk
+{
+ enum {CHUNK_TYPE_IN_REGION, CHUNK_TYPE_REGION_START,
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ CHUNK_TYPE_FIRMWARE, CHUNK_TYPE_LEFTOVER
+#endif
+ } type;
+ grub_mm_region_t reg;
+ grub_phys_addr_t start;
+ grub_size_t size;
+ grub_size_t pre_size;
+ struct grub_relocator_extra_block *extra;
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ struct grub_relocator_fw_leftover *pre, *post;
+#endif
+};
+
+struct grub_relocator_chunk
+{
+ struct grub_relocator_chunk *next;
+ grub_phys_addr_t src;
+ void *srcv;
+ grub_phys_addr_t target;
+ grub_size_t size;
+ struct grub_relocator_subchunk *subchunks;
+ unsigned nsubchunks;
+};
+
+struct grub_relocator_extra_block
+{
+ struct grub_relocator_extra_block *next;
+ struct grub_relocator_extra_block **prev;
+ grub_phys_addr_t start;
+ grub_phys_addr_t end;
+};
+
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+struct grub_relocator_fw_leftover
+{
+ struct grub_relocator_fw_leftover *next;
+ struct grub_relocator_fw_leftover **prev;
+ grub_phys_addr_t quantstart;
+ grub_uint8_t freebytes[GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT / 8];
+};
+
+static struct grub_relocator_fw_leftover *leftovers;
+#endif
+
+static struct grub_relocator_extra_block *extra_blocks;
+
+void *
+get_virtual_current_address (grub_relocator_chunk_t in)
+{
+ return in->srcv;
+}
+
+grub_phys_addr_t
+get_physical_target_address (grub_relocator_chunk_t in)
+{
+ return in->target;
+}
+
+struct grub_relocator *
+grub_relocator_new (void)
+{
+ struct grub_relocator *ret;
+
+ grub_cpu_relocator_init ();
+
+ ret = grub_zalloc (sizeof (struct grub_relocator));
+ if (!ret)
+ return NULL;
+
+ ret->postchunks = ~(grub_phys_addr_t) 0;
+ ret->relocators_size = grub_relocator_jumper_size;
+ grub_dprintf ("relocator", "relocators_size=%lu\n",
+ (unsigned long) ret->relocators_size);
+ return ret;
+}
+
+#define DIGITSORT_BITS 8
+#define DIGITSORT_MASK ((1 << DIGITSORT_BITS) - 1)
+#define BITS_IN_BYTE 8
+
+#define max(a, b) (((a) > (b)) ? (a) : (b))
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+
+static inline int
+is_start (int type)
+{
+ return !(type & 1) && (type != COLLISION_START);
+}
+
+static void
+allocate_regstart (grub_phys_addr_t addr, grub_size_t size, grub_mm_region_t rb,
+ grub_mm_region_t *regancestor, grub_mm_header_t hancestor)
+{
+ grub_addr_t newreg_start, newreg_raw_start
+ = (grub_addr_t) rb + (addr - grub_vtop (rb)) + size;
+ grub_addr_t newreg_size, newreg_presize;
+ grub_mm_header_t new_header;
+ grub_mm_header_t hb = (grub_mm_header_t) (rb + 1);
+
+#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF
+ grub_dprintf ("relocator", "ra = %p, rb = %p\n", regancestor, rb);
+#endif
+ newreg_start = ALIGN_UP (newreg_raw_start, GRUB_MM_ALIGN);
+ newreg_presize = newreg_start - newreg_raw_start;
+ newreg_size = rb->size - (newreg_start - (grub_addr_t) rb);
+ if ((hb->size << GRUB_MM_ALIGN_LOG2) >= newreg_start
+ - (grub_addr_t) rb)
+ {
+ grub_mm_header_t newhnext = hb->next;
+ grub_size_t newhsize = ((hb->size << GRUB_MM_ALIGN_LOG2)
+ - (newreg_start
+ - (grub_addr_t) rb)) >> GRUB_MM_ALIGN_LOG2;
+ new_header = (void *) (newreg_start + sizeof (*rb));
+ if (newhnext == hb)
+ newhnext = new_header;
+ new_header->next = newhnext;
+ new_header->size = newhsize;
+ new_header->magic = GRUB_MM_FREE_MAGIC;
+ }
+ else
+ {
+ new_header = hb->next;
+ if (new_header == hb)
+ new_header = (void *) (newreg_start + sizeof (*rb));
+ }
+ {
+ struct grub_mm_header *newregfirst = rb->first;
+ struct grub_mm_region *newregnext = rb->next;
+ struct grub_mm_region *newreg = (void *) newreg_start;
+ hancestor->next = new_header;
+ if (newregfirst == hb)
+ newregfirst = new_header;
+ newreg->first = newregfirst;
+ newreg->next = newregnext;
+ newreg->pre_size = newreg_presize;
+ newreg->size = newreg_size;
+ *regancestor = newreg;
+ {
+ grub_mm_header_t h = newreg->first, hp = NULL;
+ do
+ {
+ if ((void *) h < (void *) (newreg + 1))
+ grub_fatal ("Failed to adjust memory region: %p, %p, %p, %p, %p",
+ newreg, newreg->first, h, hp, hb);
+#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF
+ if ((void *) h == (void *) (newreg + 1))
+ grub_dprintf ("relocator",
+ "Free start memory region: %p, %p, %p, %p, %p",
+ newreg, newreg->first, h, hp, hb);
+#endif
+ hp = h;
+ h = h->next;
+ }
+ while (h != newreg->first);
+ }
+ }
+}
+
+static void
+allocate_inreg (grub_phys_addr_t paddr, grub_size_t size,
+ grub_mm_header_t hb, grub_mm_header_t hbp,
+ grub_mm_region_t rb)
+{
+ struct grub_mm_header *foll = NULL;
+ grub_addr_t vaddr = (grub_addr_t) hb + (paddr - grub_vtop (hb));
+
+#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF
+ grub_dprintf ("relocator", "inreg paddr = 0x%lx, size = %lu,"
+ " hb = %p, hbp = %p, rb = %p, vaddr = 0x%lx\n",
+ (unsigned long) paddr, (unsigned long) size, hb, hbp,
+ rb, (unsigned long) vaddr);
+#endif
+
+ if (ALIGN_UP (vaddr + size, GRUB_MM_ALIGN) + GRUB_MM_ALIGN
+ <= (grub_addr_t) (hb + hb->size))
+ {
+ foll = (void *) ALIGN_UP (vaddr + size, GRUB_MM_ALIGN);
+ foll->magic = GRUB_MM_FREE_MAGIC;
+ foll->size = hb + hb->size - foll;
+#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF
+ grub_dprintf ("relocator", "foll = %p, foll->size = %lu\n", foll,
+ (unsigned long) foll->size);
+#endif
+ }
+
+ if (vaddr - (grub_addr_t) hb >= sizeof (*hb))
+ {
+ hb->size = ((vaddr - (grub_addr_t) hb) >> GRUB_MM_ALIGN_LOG2);
+ if (foll)
+ {
+ foll->next = hb;
+ hbp->next = foll;
+ if (rb->first == hb)
+ {
+ rb->first = foll;
+ }
+ }
+ }
+ else
+ {
+ if (foll)
+ {
+ foll->next = hb->next;
+ }
+ else
+ foll = hb->next;
+
+ hbp->next = foll;
+ if (rb->first == hb)
+ {
+ rb->first = foll;
+ }
+ if (rb->first == hb)
+ {
+ rb->first = (void *) (rb + 1);
+ }
+ }
+}
+
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+static void
+check_leftover (struct grub_relocator_fw_leftover *lo)
+{
+ unsigned i;
+ for (i = 0; i < sizeof (lo->freebytes); i++)
+ if (lo->freebytes[i] != 0xff)
+ return;
+ grub_relocator_firmware_free_region (lo->quantstart,
+ GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT);
+ *lo->prev = lo->next;
+ if (lo->next)
+ lo->next->prev = lo->prev;
+}
+#endif
+
+static void
+free_subchunk (const struct grub_relocator_subchunk *subchu)
+{
+ switch (subchu->type)
+ {
+ case CHUNK_TYPE_REGION_START:
+ {
+ grub_mm_region_t r1, r2, *rp;
+ grub_mm_header_t h;
+ grub_size_t pre_size;
+ r1 = subchu->reg;
+ r2 = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) subchu->reg
+ + (grub_vtop (subchu->reg)
+ - subchu->start) + subchu->size,
+ GRUB_MM_ALIGN);
+ for (rp = &grub_mm_base; *rp && *rp != r2; rp = &((*rp)->next));
+ pre_size = subchu->pre_size;
+
+ if (*rp)
+ {
+ grub_mm_header_t h2, *hp;
+ r1->first = r2->first;
+ r1->next = r2->next;
+ r1->pre_size = pre_size;
+ r1->size = r2->size + (r2 - r1) * sizeof (*r2);
+ *rp = r1;
+ h = (grub_mm_header_t) (r1 + 1);
+ h->next = r2->first;
+ h->magic = GRUB_MM_FREE_MAGIC;
+ h->size = (r2 - r1 - 1);
+ for (hp = &r2->first, h2 = *hp; h2->next != r2->first;
+ hp = &(h2->next), h2 = *hp)
+ if (h2 == (grub_mm_header_t) (r2 + 1))
+ break;
+ if (h2 == (grub_mm_header_t) (r2 + 1))
+ {
+ h->size = h2->size + (h2 - h);
+ h->next = h2->next;
+ *hp = h;
+ if (hp == &r2->first)
+ {
+ for (h2 = r2->first; h2->next != r2->first; h2 = h2->next);
+ h2->next = h;
+ }
+ }
+ else
+ {
+ h2->next = h;
+ }
+ }
+ else
+ {
+ r1->pre_size = pre_size;
+ r1->size = (r2 - r1) * sizeof (*r2);
+ /* Find where to insert this region.
+ Put a smaller one before bigger ones,
+ to prevent fragmentation. */
+ for (rp = &grub_mm_base; *rp; rp = &((*rp)->next))
+ if ((*rp)->size > r1->size)
+ break;
+ r1->next = *rp;
+ *rp = r1->next;
+ h = (grub_mm_header_t) (r1 + 1);
+ r1->first = h;
+ h->next = h;
+ h->magic = GRUB_MM_FREE_MAGIC;
+ h->size = (r2 - r1 - 1);
+ }
+ for (r2 = grub_mm_base; r2; r2 = r2->next)
+ if ((grub_addr_t) r2 + r2->size == (grub_addr_t) r1)
+ break;
+ if (r2)
+ {
+ grub_mm_header_t hl2, hl, g;
+ g = (grub_mm_header_t) ((grub_addr_t) r2 + r2->size);
+ g->size = (grub_mm_header_t) r1 - g;
+ r2->size += r1->size;
+ for (hl = r2->first; hl->next != r2->first; hl = hl->next);
+ for (hl2 = r1->first; hl2->next != r1->first; hl2 = hl2->next);
+ hl2->next = r2->first;
+ r2->first = r1->first;
+ hl->next = r2->first;
+ *rp = (*rp)->next;
+ grub_free (g + 1);
+ }
+ break;
+ }
+ case CHUNK_TYPE_IN_REGION:
+ {
+ grub_mm_header_t h = (grub_mm_header_t) ALIGN_DOWN ((grub_addr_t) subchu->start,
+ GRUB_MM_ALIGN);
+ h->size
+ = ((subchu->start + subchu->size + GRUB_MM_ALIGN - 1) / GRUB_MM_ALIGN)
+ - (subchu->start / GRUB_MM_ALIGN) - 1;
+ h->next = h;
+ h->magic = GRUB_MM_ALLOC_MAGIC;
+ grub_free (h + 1);
+ break;
+ }
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ case CHUNK_TYPE_FIRMWARE:
+ case CHUNK_TYPE_LEFTOVER:
+ {
+ grub_addr_t fstart, fend;
+ fstart = ALIGN_UP (subchu->start,
+ GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT);
+ fend = ALIGN_DOWN (subchu->start + subchu->size,
+ GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT);
+ if (fstart < fend)
+ grub_relocator_firmware_free_region (fstart, fend - fstart);
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ if (subchu->pre)
+ {
+ int off = subchu->start - fstart
+ - GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT;
+ grub_memset (subchu->pre->freebytes + off / 8 + 1,
+ 0xff, sizeof (subchu->pre->freebytes) - off / 8 - 1);
+ subchu->pre->freebytes[off / 8] |= ~((1 << (off % 8)) - 1);
+ check_leftover (subchu->pre);
+ }
+ if (subchu->post)
+ {
+ int off = subchu->start + subchu->size - fend;
+ grub_memset (subchu->pre->freebytes,
+ 0xff, sizeof (subchu->pre->freebytes) - off / 8);
+ subchu->pre->freebytes[off / 8] |= ((1 << (8 - (off % 8))) - 1);
+ check_leftover (subchu->post);
+ }
+#endif
+ *subchu->extra->prev = subchu->extra->next;
+ grub_free (subchu->extra);
+ }
+ break;
+#endif
+ }
+}
+
+static int
+malloc_in_range (struct grub_relocator *rel,
+ grub_addr_t start, grub_addr_t end, grub_addr_t align,
+ grub_size_t size, struct grub_relocator_chunk *res,
+ int from_low_priv, int collisioncheck)
+{
+ grub_mm_region_t r, *ra, base_saved;
+ struct grub_relocator_mmap_event *events = NULL, *eventt = NULL, *t;
+ /* 128 is just in case of additional malloc (shouldn't happen). */
+ unsigned maxevents = 2 + 128;
+ grub_mm_header_t p, pa;
+ unsigned *counter;
+ int nallocs = 0;
+ unsigned j, N = 0;
+ grub_addr_t target = 0;
+
+ grub_dprintf ("relocator",
+ "trying to allocate in 0x%lx-0x%lx aligned 0x%lx size 0x%lx\n",
+ (unsigned long) start, (unsigned long) end,
+ (unsigned long) align, (unsigned long) size);
+
+ start = ALIGN_UP (start, align);
+ end = ALIGN_DOWN (end - size, align) + size;
+
+ if (end < start + size)
+ return 0;
+
+ /* We have to avoid any allocations when filling scanline events.
+ Hence 2-stages.
+ */
+ for (r = grub_mm_base; r; r = r->next)
+ {
+ p = r->first;
+ do
+ {
+ if ((grub_addr_t) p < (grub_addr_t) (r + 1)
+ || (grub_addr_t) p >= (grub_addr_t) (r + 1) + r->size)
+ grub_fatal ("%d: out of range pointer: %p\n", __LINE__, p);
+ maxevents += 2;
+ p = p->next;
+ }
+ while (p != r->first);
+ maxevents += 4;
+ }
+
+ if (collisioncheck && rel)
+ {
+ struct grub_relocator_chunk *chunk;
+ for (chunk = rel->chunks; chunk; chunk = chunk->next)
+ maxevents += 2;
+ }
+
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ {
+ struct grub_relocator_extra_block *cur;
+ for (cur = extra_blocks; cur; cur = cur->next)
+ maxevents += 2;
+ }
+ for (r = grub_mm_base; r; r = r->next)
+ maxevents += 2;
+
+ maxevents += grub_relocator_firmware_get_max_events ();
+#endif
+
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ {
+ struct grub_relocator_fw_leftover *cur;
+ for (cur = leftovers; cur; cur = cur->next)
+ {
+ int l = 0;
+ unsigned i;
+ for (i = 0; i < GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT; i++)
+ {
+ if (l != ((cur->freebytes[i / 8] >> (i % 8)) & 1))
+ maxevents++;
+ l = ((cur->freebytes[i / 8] >> (i % 8)) & 1);
+ }
+ if (l)
+ maxevents++;
+ }
+ }
+#endif
+
+ eventt = grub_calloc (maxevents, sizeof (events[0]));
+ counter = grub_malloc ((DIGITSORT_MASK + 2) * sizeof (counter[0]));
+ events = grub_calloc (maxevents, sizeof (events[0]));
+ if (!events || !eventt || !counter)
+ {
+ grub_dprintf ("relocator", "events or counter allocation failed %d\n",
+ maxevents);
+ grub_free (events);
+ grub_free (eventt);
+ grub_free (counter);
+ return 0;
+ }
+
+ if (collisioncheck && rel)
+ {
+ struct grub_relocator_chunk *chunk;
+ for (chunk = rel->chunks; chunk; chunk = chunk->next)
+ {
+ events[N].type = COLLISION_START;
+ events[N].pos = chunk->target;
+ N++;
+ events[N].type = COLLISION_END;
+ events[N].pos = chunk->target + chunk->size;
+ N++;
+ }
+ }
+
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ for (r = grub_mm_base; r; r = r->next)
+ {
+#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF
+ grub_dprintf ("relocator", "Blocking at 0x%lx-0x%lx\n",
+ (unsigned long) r - r->pre_size,
+ (unsigned long) (r + 1) + r->size);
+#endif
+ events[N].type = FIRMWARE_BLOCK_START;
+ events[N].pos = (grub_addr_t) r - r->pre_size;
+ N++;
+ events[N].type = FIRMWARE_BLOCK_END;
+ events[N].pos = (grub_addr_t) (r + 1) + r->size;
+ N++;
+ }
+ {
+ struct grub_relocator_extra_block *cur;
+ for (cur = extra_blocks; cur; cur = cur->next)
+ {
+#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF
+ grub_dprintf ("relocator", "Blocking at 0x%lx-0x%lx\n",
+ (unsigned long) cur->start, (unsigned long) cur->end);
+#endif
+ events[N].type = FIRMWARE_BLOCK_START;
+ events[N].pos = cur->start;
+ N++;
+ events[N].type = FIRMWARE_BLOCK_END;
+ events[N].pos = cur->end;
+ N++;
+ }
+ }
+
+ N += grub_relocator_firmware_fill_events (events + N);
+
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ {
+ struct grub_relocator_fw_leftover *cur;
+ for (cur = leftovers; cur; cur = cur->next)
+ {
+ unsigned i;
+ int l = 0;
+ for (i = 0; i < GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT; i++)
+ {
+ if (l != ((cur->freebytes[i / 8] >> (i % 8)) & 1))
+ {
+ events[N].type = l ? REG_LEFTOVER_END : REG_LEFTOVER_START;
+ events[N].pos = cur->quantstart + i;
+ events[N].leftover = cur;
+ N++;
+ }
+ l = ((cur->freebytes[i / 8] >> (i % 8)) & 1);
+ }
+ if (l)
+ {
+ events[N].type = REG_LEFTOVER_END;
+ events[N].pos = cur->quantstart + i;
+ events[N].leftover = cur;
+ N++;
+ }
+ }
+ }
+#endif
+#endif
+
+ /* No malloc from this point. */
+ base_saved = grub_mm_base;
+ grub_mm_base = NULL;
+
+ for (ra = &base_saved, r = *ra; r; ra = &(r->next), r = *ra)
+ {
+ pa = r->first;
+ p = pa->next;
+ if (p->magic == GRUB_MM_ALLOC_MAGIC)
+ continue;
+ do
+ {
+ if (p->magic != GRUB_MM_FREE_MAGIC)
+ grub_fatal ("%s:%d free magic broken at %p (0x%x)\n",
+ __FILE__,
+ __LINE__, p, p->magic);
+ if (p == (grub_mm_header_t) (r + 1))
+ {
+ events[N].type = REG_BEG_START;
+ events[N].pos = grub_vtop (r) - r->pre_size;
+ events[N].reg = r;
+ events[N].regancestor = ra;
+ events[N].head = p;
+ events[N].hancestor = pa;
+ N++;
+ events[N].type = REG_BEG_END;
+ events[N].pos = grub_vtop (p + p->size) - sizeof (*r)
+ - sizeof (struct grub_mm_header);
+ N++;
+ }
+ else
+ {
+ events[N].type = IN_REG_START;
+ events[N].pos = grub_vtop (p);
+ events[N].head = p;
+ events[N].hancestor = pa;
+ events[N].reg = r;
+ N++;
+ events[N].type = IN_REG_END;
+ events[N].pos = grub_vtop (p + p->size);
+ N++;
+ }
+ pa = p;
+ p = pa->next;
+ }
+ while (pa != r->first);
+ }
+
+ /* Put ending events after starting events. */
+ {
+ int st = 0, e = N / 2;
+ for (j = 0; j < N; j++)
+ if (is_start (events[j].type) || events[j].type == COLLISION_START)
+ eventt[st++] = events[j];
+ else
+ eventt[e++] = events[j];
+ t = eventt;
+ eventt = events;
+ events = t;
+ }
+
+ {
+ unsigned i;
+ for (i = 0; i < (BITS_IN_BYTE * sizeof (grub_addr_t) / DIGITSORT_BITS);
+ i++)
+ {
+ 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]++;
+ for (j = 0; j <= DIGITSORT_MASK; j++)
+ counter[j+1] += counter[j];
+ for (j = 0; j < N; j++)
+ eventt[counter[((events[j].pos >> (DIGITSORT_BITS * i))
+ & DIGITSORT_MASK)]++] = events[j];
+ t = eventt;
+ eventt = events;
+ events = t;
+ }
+ }
+
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ retry:
+#endif
+
+ /* Now events are nicely sorted. */
+ {
+ int nstarted = 0, ncollisions = 0, nstartedfw = 0, nblockfw = 0;
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ int nlefto = 0;
+#else
+ const int nlefto = 0;
+#endif
+ grub_addr_t starta = 0;
+ for (j = from_low_priv ? 0 : N - 1; from_low_priv ? j < N : (j + 1);
+ from_low_priv ? j++ : j--)
+ {
+ int isinsidebefore, isinsideafter;
+ isinsidebefore = (!ncollisions && (nstarted || (((nlefto || nstartedfw)
+ && !nblockfw))));
+ switch (events[j].type)
+ {
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ case REG_FIRMWARE_START:
+ nstartedfw++;
+ break;
+
+ case REG_FIRMWARE_END:
+ nstartedfw--;
+ break;
+
+ case FIRMWARE_BLOCK_START:
+ nblockfw++;
+ break;
+
+ case FIRMWARE_BLOCK_END:
+ nblockfw--;
+ break;
+#endif
+
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ case REG_LEFTOVER_START:
+ nlefto++;
+ break;
+
+ case REG_LEFTOVER_END:
+ nlefto--;
+ break;
+#endif
+
+ case COLLISION_START:
+ ncollisions++;
+ break;
+
+ case COLLISION_END:
+ ncollisions--;
+ break;
+
+ case IN_REG_START:
+ case REG_BEG_START:
+ nstarted++;
+ break;
+
+ case IN_REG_END:
+ case REG_BEG_END:
+ nstarted--;
+ break;
+ }
+ isinsideafter = (!ncollisions && (nstarted || ((nlefto || nstartedfw)
+ && !nblockfw)));
+ 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;
+ }
+ }
+ }
+ }
+
+ grub_mm_base = base_saved;
+ grub_free (events);
+ grub_free (eventt);
+ grub_free (counter);
+ return 0;
+
+ found:
+ {
+ int inreg = 0, regbeg = 0, ncol = 0;
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ int fwin = 0, fwb = 0, fwlefto = 0;
+#endif
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ int last_lo = 0;
+#endif
+ int last_start = 0;
+ for (j = 0; j < N; j++)
+ {
+ int typepre;
+ if (ncol)
+ typepre = -1;
+ else if (regbeg)
+ typepre = CHUNK_TYPE_REGION_START;
+ else if (inreg)
+ typepre = CHUNK_TYPE_IN_REGION;
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ else if (fwin && !fwb)
+ typepre = CHUNK_TYPE_FIRMWARE;
+ else if (fwlefto && !fwb)
+ typepre = CHUNK_TYPE_LEFTOVER;
+#endif
+ else
+ typepre = -1;
+
+ if (j != 0 && events[j - 1].pos != events[j].pos)
+ {
+ grub_addr_t alloc_start, alloc_end;
+ alloc_start = max (events[j - 1].pos, target);
+ alloc_end = min (events[j].pos, target + size);
+ if (alloc_end > alloc_start)
+ {
+ switch (typepre)
+ {
+ case CHUNK_TYPE_REGION_START:
+ allocate_regstart (alloc_start, alloc_end - alloc_start,
+ events[last_start].reg,
+ events[last_start].regancestor,
+ events[last_start].hancestor);
+ /* TODO: maintain a reverse lookup tree for hancestor. */
+ {
+ unsigned k;
+ for (k = 0; k < N; k++)
+ if (events[k].hancestor == events[last_start].head)
+ events[k].hancestor = events[last_start].hancestor;
+ }
+ break;
+ case CHUNK_TYPE_IN_REGION:
+ allocate_inreg (alloc_start, alloc_end - alloc_start,
+ events[last_start].head,
+ events[last_start].hancestor,
+ events[last_start].reg);
+ {
+ unsigned k;
+ for (k = 0; k < N; k++)
+ if (events[k].hancestor == events[last_start].head)
+ events[k].hancestor = events[last_start].hancestor;
+ }
+ break;
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ case CHUNK_TYPE_FIRMWARE:
+ {
+ grub_addr_t fstart, fend;
+ fstart
+ = ALIGN_DOWN (alloc_start,
+ GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT);
+ fend
+ = ALIGN_UP (alloc_end,
+ GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT);
+#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF
+ grub_dprintf ("relocator", "requesting %lx-%lx\n",
+ (unsigned long) fstart,
+ (unsigned long) fend);
+#endif
+ /* The failure here can be very expensive. */
+ if (!grub_relocator_firmware_alloc_region (fstart,
+ fend - fstart))
+ {
+ if (from_low_priv)
+ start = fend;
+ else
+ end = fstart;
+ goto retry;
+ }
+ break;
+ }
+#endif
+
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ case CHUNK_TYPE_LEFTOVER:
+ {
+ unsigned offstart = alloc_start
+ % GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT;
+ unsigned offend = alloc_end
+ % 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,
+ offend / 8 - (offstart + 7) / 8);
+ lo->freebytes[offend / 8] &= ~((1 << (offend % 8)) - 1);
+ }
+ break;
+#endif
+ }
+ nallocs++;
+ }
+ }
+
+ switch (events[j].type)
+ {
+ case REG_BEG_START:
+ case IN_REG_START:
+ if (events[j].type == REG_BEG_START &&
+ (grub_addr_t) (events[j].reg + 1) > target)
+ regbeg++;
+ else
+ inreg++;
+ last_start = j;
+ break;
+
+ case REG_BEG_END:
+ case IN_REG_END:
+ if (regbeg)
+ regbeg--;
+ else
+ inreg--;
+ break;
+
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ case REG_FIRMWARE_START:
+ fwin++;
+ break;
+
+ case REG_FIRMWARE_END:
+ fwin--;
+ break;
+
+ case FIRMWARE_BLOCK_START:
+ fwb++;
+ break;
+
+ case FIRMWARE_BLOCK_END:
+ fwb--;
+ break;
+#endif
+
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ case REG_LEFTOVER_START:
+ fwlefto++;
+ last_lo = j;
+ break;
+
+ case REG_LEFTOVER_END:
+ fwlefto--;
+ break;
+#endif
+ case COLLISION_START:
+ ncol++;
+ break;
+ case COLLISION_END:
+ ncol--;
+ break;
+ }
+
+ }
+ }
+
+ /* Malloc is available again. */
+ grub_mm_base = base_saved;
+
+ grub_free (eventt);
+ grub_free (counter);
+
+ {
+ int last_start = 0;
+ int inreg = 0, regbeg = 0, ncol = 0;
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ int fwin = 0, fwlefto = 0, fwb = 0;
+#endif
+ unsigned cural = 0;
+ int oom = 0;
+ res->subchunks = grub_calloc (nallocs, sizeof (res->subchunks[0]));
+ if (!res->subchunks)
+ oom = 1;
+ res->nsubchunks = nallocs;
+
+ for (j = 0; j < N; j++)
+ {
+ int typepre;
+ if (ncol)
+ typepre = -1;
+ else if (regbeg)
+ typepre = CHUNK_TYPE_REGION_START;
+ else if (inreg)
+ typepre = CHUNK_TYPE_IN_REGION;
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ else if (fwin && !fwb)
+ typepre = CHUNK_TYPE_FIRMWARE;
+ else if (fwlefto && !fwb)
+ typepre = CHUNK_TYPE_LEFTOVER;
+#endif
+ else
+ typepre = -1;
+
+ if (j != 0 && events[j - 1].pos != events[j].pos)
+ {
+ grub_addr_t alloc_start, alloc_end;
+ struct grub_relocator_subchunk tofree;
+ struct grub_relocator_subchunk *curschu = &tofree;
+ if (!oom)
+ curschu = &res->subchunks[cural];
+ alloc_start = max (events[j - 1].pos, target);
+ alloc_end = min (events[j].pos, target + size);
+ if (alloc_end > alloc_start)
+ {
+#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF
+ grub_dprintf ("relocator", "subchunk 0x%lx-0x%lx, %d\n",
+ (unsigned long) alloc_start,
+ (unsigned long) alloc_end, typepre);
+#endif
+ curschu->type = typepre;
+ curschu->start = alloc_start;
+ curschu->size = alloc_end - alloc_start;
+ if (typepre == CHUNK_TYPE_REGION_START
+ || typepre == CHUNK_TYPE_IN_REGION)
+ {
+ curschu->reg = events[last_start].reg;
+ curschu->pre_size = alloc_start - events[j - 1].pos;
+ }
+ if (!oom && (typepre == CHUNK_TYPE_REGION_START
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ || typepre == CHUNK_TYPE_FIRMWARE
+#endif
+ ))
+ {
+ struct grub_relocator_extra_block *ne;
+ ne = grub_malloc (sizeof (*ne));
+ if (!ne)
+ {
+ oom = 1;
+ grub_memcpy (&tofree, curschu, sizeof (tofree));
+ }
+ else
+ {
+ ne->start = alloc_start;
+ ne->end = alloc_end;
+ ne->next = extra_blocks;
+ ne->prev = &extra_blocks;
+ if (extra_blocks)
+ extra_blocks->prev = &(ne->next);
+ extra_blocks = ne;
+ curschu->extra = ne;
+ }
+ }
+
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ if (!oom && typepre == CHUNK_TYPE_FIRMWARE)
+ {
+ grub_addr_t fstart, fend;
+
+ fstart
+ = ALIGN_DOWN (alloc_start,
+ GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT);
+ fend
+ = ALIGN_UP (alloc_end,
+ GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT);
+
+ {
+ struct grub_relocator_fw_leftover *lo1 = NULL;
+ struct grub_relocator_fw_leftover *lo2 = NULL;
+ if (fstart != alloc_start)
+ lo1 = grub_malloc (sizeof (*lo1));
+ if (fend != alloc_end)
+ lo2 = grub_malloc (sizeof (*lo2));
+ if ((!lo1 && fstart != alloc_start)
+ || (!lo2 && fend != alloc_end))
+ {
+ struct grub_relocator_extra_block *ne;
+ grub_free (lo1);
+ grub_free (lo2);
+ lo1 = NULL;
+ lo2 = NULL;
+ oom = 1;
+ grub_memcpy (&tofree, curschu, sizeof (tofree));
+ ne = extra_blocks;
+ extra_blocks = extra_blocks->next;
+ grub_free (ne);
+ }
+ if (lo1)
+ {
+ lo1->quantstart = fstart;
+ grub_memset (lo1->freebytes, 0xff,
+ (alloc_start - fstart) / 8);
+ lo1->freebytes[(alloc_start - fstart) / 8]
+ = (1 << ((alloc_start - fstart) % 8)) - 1;
+ grub_memset (lo1->freebytes
+ + ((alloc_start - fstart) / 8) + 1, 0,
+ sizeof (lo1->freebytes)
+ - (alloc_start - fstart) / 8 - 1);
+ lo1->next = leftovers;
+ lo1->prev = &leftovers;
+ if (leftovers)
+ leftovers->prev = &lo1->next;
+ leftovers = lo1;
+ }
+ if (lo2)
+ {
+ lo2->quantstart
+ = fend - GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT;
+ grub_memset (lo2->freebytes, 0,
+ (alloc_end - lo2->quantstart) / 8);
+ lo2->freebytes[(alloc_end - lo2->quantstart) / 8]
+ = ~((1 << ((alloc_end - lo2->quantstart) % 8)) - 1);
+ grub_memset (lo2->freebytes
+ + ((alloc_end - lo2->quantstart) / 8)
+ + 1, 0, sizeof (lo2->freebytes)
+ - (alloc_end - lo2->quantstart) / 8 - 1);
+ lo2->prev = &leftovers;
+ if (leftovers)
+ leftovers->prev = &lo2->next;
+ lo2->next = leftovers;
+ leftovers = lo2;
+ }
+ curschu->pre = lo1;
+ curschu->post = lo2;
+ }
+ }
+
+ if (typepre == CHUNK_TYPE_LEFTOVER)
+ {
+ curschu->pre = events[last_start].leftover;
+ curschu->post = events[last_start].leftover;
+ }
+#endif
+
+ if (!oom)
+ cural++;
+ else
+ free_subchunk (&tofree);
+ }
+ }
+
+ switch (events[j].type)
+ {
+ case REG_BEG_START:
+ case IN_REG_START:
+ if (events[j].type == REG_BEG_START &&
+ (grub_addr_t) (events[j].reg + 1) > target)
+ regbeg++;
+ else
+ inreg++;
+ last_start = j;
+ break;
+
+ case REG_BEG_END:
+ case IN_REG_END:
+ inreg = regbeg = 0;
+ break;
+
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ case REG_FIRMWARE_START:
+ fwin++;
+ break;
+
+ case REG_FIRMWARE_END:
+ fwin--;
+ break;
+
+ case FIRMWARE_BLOCK_START:
+ fwb++;
+ break;
+
+ case FIRMWARE_BLOCK_END:
+ fwb--;
+ break;
+#endif
+
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ case REG_LEFTOVER_START:
+ fwlefto++;
+ break;
+
+ case REG_LEFTOVER_END:
+ fwlefto--;
+ break;
+#endif
+ case COLLISION_START:
+ ncol++;
+ break;
+ case COLLISION_END:
+ ncol--;
+ break;
+ }
+ }
+ if (oom)
+ {
+ unsigned i;
+ for (i = 0; i < cural; i++)
+ free_subchunk (&res->subchunks[i]);
+ grub_free (res->subchunks);
+ grub_dprintf ("relocator", "allocation failed with out-of-memory\n");
+ grub_free (events);
+
+ return 0;
+ }
+ }
+
+ res->src = target;
+ res->size = size;
+
+ grub_free (events);
+
+ grub_dprintf ("relocator", "allocated: 0x%lx+0x%lx\n", (unsigned long) target,
+ (unsigned long) size);
+
+ return 1;
+}
+
+static void
+adjust_limits (struct grub_relocator *rel,
+ grub_phys_addr_t *min_addr, grub_phys_addr_t *max_addr,
+ grub_phys_addr_t in_min, grub_phys_addr_t in_max)
+{
+ struct grub_relocator_chunk *chunk;
+
+ *min_addr = 0;
+ *max_addr = rel->postchunks;
+
+ /* Keep chunks in memory in the same order as they'll be after relocation. */
+ for (chunk = rel->chunks; chunk; chunk = chunk->next)
+ {
+ if (chunk->target > in_max && chunk->src < *max_addr
+ && chunk->src < rel->postchunks)
+ *max_addr = chunk->src;
+ if (chunk->target + chunk->size <= in_min
+ && chunk->src + chunk->size > *min_addr
+ && chunk->src < rel->postchunks)
+ *min_addr = chunk->src + chunk->size;
+ }
+}
+
+grub_err_t
+grub_relocator_alloc_chunk_addr (struct grub_relocator *rel,
+ grub_relocator_chunk_t *out,
+ grub_phys_addr_t target, grub_size_t size)
+{
+ struct grub_relocator_chunk *chunk;
+ grub_phys_addr_t min_addr = 0, max_addr;
+
+ if (target > ~size)
+ return grub_error (GRUB_ERR_BUG, "address is out of range");
+
+ adjust_limits (rel, &min_addr, &max_addr, target, target);
+
+ for (chunk = rel->chunks; chunk; chunk = chunk->next)
+ if ((chunk->target <= target && target < chunk->target + chunk->size)
+ || (target <= chunk->target && chunk->target < target + size))
+ return grub_error (GRUB_ERR_BUG, "overlap detected");
+
+ chunk = grub_malloc (sizeof (struct grub_relocator_chunk));
+ if (!chunk)
+ return grub_errno;
+
+ grub_dprintf ("relocator",
+ "min_addr = 0x%llx, max_addr = 0x%llx, target = 0x%llx\n",
+ (unsigned long long) min_addr, (unsigned long long) max_addr,
+ (unsigned long long) target);
+
+ do
+ {
+ /* A trick to improve Linux allocation. */
+#if defined (__i386__) || defined (__x86_64__)
+ if (target < 0x100000)
+ if (malloc_in_range (rel, rel->highestnonpostaddr, ~(grub_addr_t)0, 1,
+ size, chunk, 0, 1))
+ {
+ if (rel->postchunks > chunk->src)
+ rel->postchunks = chunk->src;
+ break;
+ }
+#endif
+ if (malloc_in_range (rel, target, max_addr, 1, size, chunk, 1, 0))
+ break;
+
+ if (malloc_in_range (rel, min_addr, target, 1, size, chunk, 0, 0))
+ break;
+
+ if (malloc_in_range (rel, rel->highestnonpostaddr, ~(grub_addr_t)0, 1,
+ size, chunk, 0, 1))
+ {
+ if (rel->postchunks > chunk->src)
+ rel->postchunks = chunk->src;
+ break;
+ }
+
+ grub_dprintf ("relocator", "not allocated\n");
+ grub_free (chunk);
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ }
+ while (0);
+
+ grub_dprintf ("relocator", "allocated 0x%llx/0x%llx\n",
+ (unsigned long long) chunk->src, (unsigned long long) target);
+
+ if (rel->highestaddr < target + size)
+ rel->highestaddr = target + size;
+
+ if (rel->highestaddr < chunk->src + size)
+ rel->highestaddr = chunk->src + size;
+
+ if (chunk->src < rel->postchunks)
+ {
+ if (rel->highestnonpostaddr < target + size)
+ rel->highestnonpostaddr = target + size;
+
+ if (rel->highestnonpostaddr < chunk->src + size)
+ rel->highestnonpostaddr = chunk->src + size;
+ }
+
+ grub_dprintf ("relocator", "relocators_size=%ld\n",
+ (unsigned long) rel->relocators_size);
+
+ if (chunk->src < target)
+ rel->relocators_size += grub_relocator_backward_size;
+ if (chunk->src > target)
+ rel->relocators_size += grub_relocator_forward_size;
+
+ grub_dprintf ("relocator", "relocators_size=%ld\n",
+ (unsigned long) rel->relocators_size);
+
+ chunk->target = target;
+ chunk->size = size;
+ chunk->next = rel->chunks;
+ rel->chunks = chunk;
+ grub_dprintf ("relocator", "cur = %p, next = %p\n", rel->chunks,
+ rel->chunks->next);
+
+ chunk->srcv = grub_map_memory (chunk->src, chunk->size);
+ *out = chunk;
+#ifdef DEBUG_RELOCATOR
+ grub_memset (chunk->srcv, 0xfa, chunk->size);
+ grub_mm_check ();
+#endif
+ return GRUB_ERR_NONE;
+}
+
+/* Context for grub_relocator_alloc_chunk_align. */
+struct grub_relocator_alloc_chunk_align_ctx
+{
+ grub_phys_addr_t min_addr, max_addr;
+ grub_size_t size, align;
+ int preference;
+ struct grub_relocator_chunk *chunk;
+ int found;
+};
+
+/* Helper for grub_relocator_alloc_chunk_align. */
+static int
+grub_relocator_alloc_chunk_align_iter (grub_uint64_t addr, grub_uint64_t sz,
+ grub_memory_type_t type, void *data)
+{
+ struct grub_relocator_alloc_chunk_align_ctx *ctx = data;
+ grub_uint64_t candidate;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+ candidate = ALIGN_UP (addr, ctx->align);
+ if (candidate < ctx->min_addr)
+ candidate = ALIGN_UP (ctx->min_addr, ctx->align);
+ if (candidate + ctx->size > addr + sz
+ || candidate > ALIGN_DOWN (ctx->max_addr, ctx->align))
+ return 0;
+ if (ctx->preference == GRUB_RELOCATOR_PREFERENCE_HIGH)
+ candidate = ALIGN_DOWN (min (addr + sz - ctx->size, ctx->max_addr),
+ ctx->align);
+ if (!ctx->found || (ctx->preference == GRUB_RELOCATOR_PREFERENCE_HIGH
+ && candidate > ctx->chunk->target))
+ ctx->chunk->target = candidate;
+ if (!ctx->found || (ctx->preference == GRUB_RELOCATOR_PREFERENCE_LOW
+ && candidate < ctx->chunk->target))
+ ctx->chunk->target = candidate;
+ ctx->found = 1;
+ return 0;
+}
+
+grub_err_t
+grub_relocator_alloc_chunk_align (struct grub_relocator *rel,
+ grub_relocator_chunk_t *out,
+ grub_phys_addr_t min_addr,
+ grub_phys_addr_t max_addr,
+ grub_size_t size, grub_size_t align,
+ int preference,
+ int avoid_efi_boot_services)
+{
+ struct grub_relocator_alloc_chunk_align_ctx ctx = {
+ .min_addr = min_addr,
+ .max_addr = max_addr,
+ .size = size,
+ .align = align,
+ .preference = preference,
+ .found = 0
+ };
+ grub_addr_t min_addr2 = 0, max_addr2;
+
+ if (size && (max_addr > ~size))
+ max_addr = ~size + 1;
+
+#ifdef GRUB_MACHINE_PCBIOS
+ if (min_addr < 0x1000)
+ min_addr = 0x1000;
+#endif
+
+ grub_dprintf ("relocator", "chunks = %p\n", rel->chunks);
+
+ ctx.chunk = grub_malloc (sizeof (struct grub_relocator_chunk));
+ if (!ctx.chunk)
+ return grub_errno;
+
+ if (malloc_in_range (rel, min_addr, max_addr, align,
+ size, ctx.chunk,
+ preference != GRUB_RELOCATOR_PREFERENCE_HIGH, 1))
+ {
+ grub_dprintf ("relocator", "allocated 0x%llx/0x%llx\n",
+ (unsigned long long) ctx.chunk->src,
+ (unsigned long long) ctx.chunk->src);
+ grub_dprintf ("relocator", "chunks = %p\n", rel->chunks);
+ ctx.chunk->target = ctx.chunk->src;
+ ctx.chunk->size = size;
+ ctx.chunk->next = rel->chunks;
+ rel->chunks = ctx.chunk;
+ ctx.chunk->srcv = grub_map_memory (ctx.chunk->src, ctx.chunk->size);
+ *out = ctx.chunk;
+ return GRUB_ERR_NONE;
+ }
+
+ adjust_limits (rel, &min_addr2, &max_addr2, min_addr, max_addr);
+ grub_dprintf ("relocator", "Adjusted limits from %lx-%lx to %lx-%lx\n",
+ (unsigned long) min_addr, (unsigned long) max_addr,
+ (unsigned long) min_addr2, (unsigned long) max_addr2);
+
+ do
+ {
+ if (malloc_in_range (rel, min_addr2, max_addr2, align,
+ size, ctx.chunk, 1, 1))
+ break;
+
+ if (malloc_in_range (rel, rel->highestnonpostaddr, ~(grub_addr_t)0, 1,
+ size, ctx.chunk, 0, 1))
+ {
+ if (rel->postchunks > ctx.chunk->src)
+ rel->postchunks = ctx.chunk->src;
+ break;
+ }
+
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ }
+ while (0);
+
+ {
+#ifdef GRUB_MACHINE_EFI
+ grub_efi_mmap_iterate (grub_relocator_alloc_chunk_align_iter, &ctx,
+ avoid_efi_boot_services);
+#elif defined (__powerpc__) || defined (GRUB_MACHINE_XEN)
+ (void) avoid_efi_boot_services;
+ grub_machine_mmap_iterate (grub_relocator_alloc_chunk_align_iter, &ctx);
+#else
+ (void) avoid_efi_boot_services;
+ grub_mmap_iterate (grub_relocator_alloc_chunk_align_iter, &ctx);
+#endif
+ if (!ctx.found)
+ return grub_error (GRUB_ERR_BAD_OS, "couldn't find suitable memory target");
+ }
+ while (1)
+ {
+ struct grub_relocator_chunk *chunk2;
+ for (chunk2 = rel->chunks; chunk2; chunk2 = chunk2->next)
+ if ((chunk2->target <= ctx.chunk->target
+ && ctx.chunk->target < chunk2->target + chunk2->size)
+ || (ctx.chunk->target <= chunk2->target && chunk2->target
+ < ctx.chunk->target + size))
+ {
+ if (preference == GRUB_RELOCATOR_PREFERENCE_HIGH)
+ ctx.chunk->target = ALIGN_DOWN (chunk2->target, align);
+ else
+ ctx.chunk->target = ALIGN_UP (chunk2->target + chunk2->size,
+ align);
+ break;
+ }
+ if (!chunk2)
+ break;
+ }
+
+ grub_dprintf ("relocator", "relocators_size=%ld\n",
+ (unsigned long) rel->relocators_size);
+
+ if (ctx.chunk->src < ctx.chunk->target)
+ rel->relocators_size += grub_relocator_backward_size;
+ if (ctx.chunk->src > ctx.chunk->target)
+ rel->relocators_size += grub_relocator_forward_size;
+
+ grub_dprintf ("relocator", "relocators_size=%ld\n",
+ (unsigned long) rel->relocators_size);
+
+ ctx.chunk->size = size;
+ ctx.chunk->next = rel->chunks;
+ rel->chunks = ctx.chunk;
+ grub_dprintf ("relocator", "cur = %p, next = %p\n", rel->chunks,
+ rel->chunks->next);
+ ctx.chunk->srcv = grub_map_memory (ctx.chunk->src, ctx.chunk->size);
+ *out = ctx.chunk;
+#ifdef DEBUG_RELOCATOR
+ grub_memset (ctx.chunk->srcv, 0xfa, ctx.chunk->size);
+ grub_mm_check ();
+#endif
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_relocator_unload (struct grub_relocator *rel)
+{
+ struct grub_relocator_chunk *chunk, *next;
+ if (!rel)
+ return;
+ for (chunk = rel->chunks; chunk; chunk = next)
+ {
+ unsigned i;
+ for (i = 0; i < chunk->nsubchunks; i++)
+ free_subchunk (&chunk->subchunks[i]);
+ grub_unmap_memory (chunk->srcv, chunk->size);
+ next = chunk->next;
+ grub_free (chunk->subchunks);
+ grub_free (chunk);
+ }
+ grub_free (rel);
+}
+
+grub_err_t
+grub_relocator_prepare_relocs (struct grub_relocator *rel, grub_addr_t addr,
+ void **relstart, grub_size_t *relsize)
+{
+ grub_uint8_t *rels;
+ grub_uint8_t *rels0;
+ struct grub_relocator_chunk *sorted;
+ grub_size_t nchunks = 0;
+ unsigned j;
+ struct grub_relocator_chunk movers_chunk;
+
+ grub_dprintf ("relocator", "Preparing relocs (size=%ld)\n",
+ (unsigned long) rel->relocators_size);
+
+ if (!malloc_in_range (rel, 0, ~(grub_addr_t)0 - rel->relocators_size + 1,
+ grub_relocator_align,
+ rel->relocators_size, &movers_chunk, 1, 1))
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ movers_chunk.srcv = rels = rels0
+ = grub_map_memory (movers_chunk.src, movers_chunk.size);
+
+ if (relsize)
+ *relsize = rel->relocators_size;
+
+ grub_dprintf ("relocator", "Relocs allocated at %p\n", movers_chunk.srcv);
+
+ {
+ unsigned i;
+ grub_size_t count[257];
+ struct grub_relocator_chunk *from, *to, *tmp;
+
+ grub_memset (count, 0, sizeof (count));
+
+ {
+ struct grub_relocator_chunk *chunk;
+ for (chunk = rel->chunks; chunk; chunk = chunk->next)
+ {
+ grub_dprintf ("relocator", "chunk %p->%p, 0x%lx\n",
+ (void *) chunk->src, (void *) chunk->target,
+ (unsigned long) chunk->size);
+ nchunks++;
+ count[(chunk->src & 0xff) + 1]++;
+ }
+ }
+ from = grub_calloc (nchunks, sizeof (sorted[0]));
+ to = grub_calloc (nchunks, sizeof (sorted[0]));
+ if (!from || !to)
+ {
+ grub_free (from);
+ grub_free (to);
+ return grub_errno;
+ }
+
+ for (j = 0; j < 256; j++)
+ count[j+1] += count[j];
+
+ {
+ struct grub_relocator_chunk *chunk;
+ for (chunk = rel->chunks; chunk; chunk = chunk->next)
+ from[count[chunk->src & 0xff]++] = *chunk;
+ }
+
+ for (i = 1; i < GRUB_CPU_SIZEOF_VOID_P; i++)
+ {
+ grub_memset (count, 0, sizeof (count));
+ for (j = 0; j < nchunks; j++)
+ count[((from[j].src >> (8 * i)) & 0xff) + 1]++;
+ for (j = 0; j < 256; j++)
+ count[j+1] += count[j];
+ for (j = 0; j < nchunks; j++)
+ to[count[(from[j].src >> (8 * i)) & 0xff]++] = from[j];
+ tmp = to;
+ to = from;
+ from = tmp;
+ }
+ sorted = from;
+ grub_free (to);
+ }
+
+ for (j = 0; j < nchunks; j++)
+ {
+ grub_dprintf ("relocator", "sorted chunk %p->%p, 0x%lx\n",
+ (void *) sorted[j].src, (void *) sorted[j].target,
+ (unsigned long) sorted[j].size);
+ if (sorted[j].src < sorted[j].target)
+ {
+ grub_cpu_relocator_backward ((void *) rels,
+ sorted[j].srcv,
+ grub_map_memory (sorted[j].target,
+ sorted[j].size),
+ sorted[j].size);
+ rels += grub_relocator_backward_size;
+ }
+ if (sorted[j].src > sorted[j].target)
+ {
+ grub_cpu_relocator_forward ((void *) rels,
+ sorted[j].srcv,
+ grub_map_memory (sorted[j].target,
+ sorted[j].size),
+ sorted[j].size);
+ rels += grub_relocator_forward_size;
+ }
+ if (sorted[j].src == sorted[j].target)
+ grub_arch_sync_caches (sorted[j].srcv, sorted[j].size);
+ }
+ grub_cpu_relocator_jumper ((void *) rels, (grub_addr_t) addr);
+ *relstart = rels0;
+ grub_free (sorted);
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_mm_check_real (const char *file, int line)
+{
+ grub_mm_region_t r;
+ grub_mm_header_t p, pa;
+
+ for (r = grub_mm_base; r; r = r->next)
+ {
+ pa = r->first;
+ p = pa->next;
+ if (p->magic == GRUB_MM_ALLOC_MAGIC)
+ continue;
+ do
+ {
+ if ((grub_addr_t) p < (grub_addr_t) (r + 1)
+ || (grub_addr_t) p >= (grub_addr_t) (r + 1) + r->size)
+ grub_fatal ("%s:%d: out of range pointer: %p\n", file, line, p);
+ if (p->magic != GRUB_MM_FREE_MAGIC)
+ grub_fatal ("%s:%d free magic broken at %p (0x%x)\n", file,
+ line, p, p->magic);
+ pa = p;
+ p = pa->next;
+ }
+ while (pa != r->first);
+ }
+}
diff --git a/grub-core/lib/riscv/setjmp.S b/grub-core/lib/riscv/setjmp.S
new file mode 100644
index 0000000..b48ef29
--- /dev/null
+++ b/grub-core/lib/riscv/setjmp.S
@@ -0,0 +1,84 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/dl.h>
+
+ .file "setjmp.S"
+
+GRUB_MOD_LICENSE "GPLv3+"
+
+ .text
+
+#if __riscv_xlen == 64
+#define STORE_IDX(reg, idx) sd reg, (idx*8)(a0)
+#define LOAD_IDX(reg, idx) ld reg, (idx*8)(a0)
+#else
+#define STORE_IDX(reg, idx) sw reg, (idx*4)(a0)
+#define LOAD_IDX(reg, idx) lw reg, (idx*4)(a0)
+#endif
+
+/*
+ * int grub_setjmp (grub_jmp_buf env)
+ */
+FUNCTION(grub_setjmp)
+ /* Preserve all callee-saved registers and the SP */
+ STORE_IDX(s0, 0)
+ STORE_IDX(s1, 1)
+ STORE_IDX(s2, 2)
+ STORE_IDX(s3, 3)
+ STORE_IDX(s4, 4)
+ STORE_IDX(s5, 5)
+ STORE_IDX(s6, 6)
+ STORE_IDX(s7, 7)
+ STORE_IDX(s8, 8)
+ STORE_IDX(s9, 9)
+ STORE_IDX(s10, 10)
+ STORE_IDX(s11, 11)
+ STORE_IDX(ra, 12)
+ STORE_IDX(sp, 13)
+ li a0, 0
+ ret
+
+/*
+ * int grub_longjmp (grub_jmp_buf env, int val)
+ */
+FUNCTION(grub_longjmp)
+ LOAD_IDX(s0, 0)
+ LOAD_IDX(s1, 1)
+ LOAD_IDX(s2, 2)
+ LOAD_IDX(s3, 3)
+ LOAD_IDX(s4, 4)
+ LOAD_IDX(s5, 5)
+ LOAD_IDX(s6, 6)
+ LOAD_IDX(s7, 7)
+ LOAD_IDX(s8, 8)
+ LOAD_IDX(s9, 9)
+ LOAD_IDX(s10, 10)
+ LOAD_IDX(s11, 11)
+ LOAD_IDX(ra, 12)
+ LOAD_IDX(sp, 13)
+
+ /* Move the return value in place, but return 1 if passed 0. */
+ beq a1, zero, longjmp_1
+ mv a0, a1
+ ret
+
+ longjmp_1:
+ li a0, 1
+ ret
diff --git a/grub-core/lib/setjmp.S b/grub-core/lib/setjmp.S
new file mode 100644
index 0000000..aa297ab
--- /dev/null
+++ b/grub-core/lib/setjmp.S
@@ -0,0 +1,22 @@
+#if defined(__i386__)
+#include "./i386/setjmp.S"
+#elif defined(__x86_64__)
+#include "./x86_64/setjmp.S"
+#elif defined(__sparc__)
+#include "./sparc64/setjmp.S"
+#elif defined(__mips__)
+#include "./mips/setjmp.S"
+#elif defined(__powerpc__) || defined(__PPC__)
+#include "./powerpc/setjmp.S"
+#elif defined(__ia64__)
+#include "./ia64/setjmp.S"
+#include "./ia64/longjmp.S"
+#elif defined(__arm__)
+#include "./arm/setjmp.S"
+#elif defined(__aarch64__)
+#include "./arm64/setjmp.S"
+#elif defined(__riscv)
+#include "./riscv/setjmp.S"
+#else
+#error "Unknown target cpu type"
+#endif
diff --git a/grub-core/lib/sparc64/setjmp.S b/grub-core/lib/sparc64/setjmp.S
new file mode 100644
index 0000000..6c11bdd
--- /dev/null
+++ b/grub-core/lib/sparc64/setjmp.S
@@ -0,0 +1,54 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/dl.h>
+
+ .file "setjmp.S"
+
+GRUB_MOD_LICENSE "GPLv3+"
+
+ .text
+
+/*
+ * int grub_setjmp (grub_jmp_buf env)
+ */
+FUNCTION(grub_setjmp)
+ stx %o7, [%o0 + 0x00]
+ stx %sp, [%o0 + 0x08]
+ stx %fp, [%o0 + 0x10]
+ retl
+ clr %o0
+
+/*
+ * int grub_longjmp (grub_jmp_buf env, int val)
+ */
+FUNCTION(grub_longjmp)
+ ldx [%o0 + 0x10], %g1
+ movrz %o1, 1, %o1
+
+ save %sp, -64, %sp
+ flushw
+ restore
+
+ ldx [%o0 + 0x00], %o7
+ ldx [%o0 + 0x08], %fp
+ sub %fp, 192, %sp
+ stx %g1, [%sp + 2047 + (14 * 8)]
+ retl
+ restore %o1, 0, %o0
diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c
new file mode 100644
index 0000000..ff244d2
--- /dev/null
+++ b/grub-core/lib/syslinux_parse.c
@@ -0,0 +1,1555 @@
+/*
+ * 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/mm.h>
+#include <grub/file.h>
+#include <grub/normal.h>
+#include <grub/syslinux_parse.h>
+
+struct syslinux_say
+{
+ struct syslinux_say *next;
+ struct syslinux_say *prev;
+ char msg[0];
+};
+
+struct initrd_list
+{
+ struct initrd_list *next;
+ char *file;
+};
+
+struct syslinux_menuentry
+{
+ struct syslinux_menuentry *next;
+ struct syslinux_menuentry *prev;
+ char *label;
+ char *extlabel;
+ char *kernel_file;
+ struct initrd_list *initrds;
+ struct initrd_list *initrds_last;
+ char *append;
+ char *argument;
+ char *help;
+ char *comments;
+ grub_size_t commentslen;
+ char hotkey;
+ int make_default;
+ struct syslinux_say *say;
+
+ enum { KERNEL_NO_KERNEL, KERNEL_LINUX, KERNEL_CHAINLOADER,
+ KERNEL_BIN, KERNEL_PXE, KERNEL_CHAINLOADER_BPB,
+ KERNEL_COM32, KERNEL_COM, KERNEL_IMG, KERNEL_CONFIG, LOCALBOOT }
+ entry_type;
+};
+
+struct syslinux_menu
+{
+ struct syslinux_menu *parent;
+ struct syslinux_menuentry *entries;
+ char *def;
+ char *comments;
+ char *background;
+ const char *root_read_directory;
+ const char *root_target_directory;
+ const char *current_read_directory;
+ const char *current_target_directory;
+ const char *filename;
+ grub_size_t commentslen;
+ unsigned long timeout;
+ struct syslinux_say *say;
+ grub_syslinux_flavour_t flavour;
+};
+
+struct output_buffer
+{
+ grub_size_t alloc;
+ grub_size_t ptr;
+ char *buf;
+};
+
+static grub_err_t
+syslinux_parse_real (struct syslinux_menu *menu);
+static grub_err_t
+config_file (struct output_buffer *outbuf,
+ const char *root, const char *target_root,
+ const char *cwd, const char *target_cwd,
+ const char *fname, struct syslinux_menu *parent,
+ grub_syslinux_flavour_t flav);
+static grub_err_t
+print_entry (struct output_buffer *outbuf,
+ struct syslinux_menu *menu,
+ const char *str);
+
+static grub_err_t
+ensure_space (struct output_buffer *outbuf, grub_size_t len)
+{
+ grub_size_t newlen;
+ char *newbuf;
+ if (len < outbuf->alloc - outbuf->ptr)
+ return GRUB_ERR_NONE;
+ newlen = (outbuf->ptr + len + 10) * 2;
+ newbuf = grub_realloc (outbuf->buf, newlen);
+ if (!newbuf)
+ return grub_errno;
+ outbuf->alloc = newlen;
+ outbuf->buf = newbuf;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+print (struct output_buffer *outbuf, const char *str, grub_size_t len)
+{
+ grub_err_t err;
+ err = ensure_space (outbuf, len);
+ if (err)
+ return err;
+ grub_memcpy (&outbuf->buf[outbuf->ptr], str, len);
+ outbuf->ptr += len;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+add_comment (struct syslinux_menu *menu, const char *comment, int nl)
+{
+ if (menu->entries)
+ {
+ if (menu->entries->commentslen == 0 && *comment == 0)
+ return GRUB_ERR_NONE;
+ menu->entries->comments = grub_realloc (menu->entries->comments,
+ menu->entries->commentslen
+ + 2 + grub_strlen (comment));
+ if (!menu->entries->comments)
+ return grub_errno;
+ menu->entries->commentslen
+ += grub_stpcpy (menu->entries->comments + menu->entries->commentslen,
+ comment)
+ - (menu->entries->comments + menu->entries->commentslen);
+ if (nl)
+ menu->entries->comments[menu->entries->commentslen++] = '\n';
+ menu->entries->comments[menu->entries->commentslen] = '\0';
+ }
+ else
+ {
+ if (menu->commentslen == 0 && *comment == 0)
+ return GRUB_ERR_NONE;
+ menu->comments = grub_realloc (menu->comments, menu->commentslen
+ + 2 + grub_strlen (comment));
+ if (!menu->comments)
+ return grub_errno;
+ menu->commentslen += grub_stpcpy (menu->comments + menu->commentslen,
+ comment)
+ - (menu->comments + menu->commentslen);
+ if (nl)
+ menu->comments[menu->commentslen++] = '\n';
+ menu->comments[menu->commentslen] = '\0';
+ }
+ return GRUB_ERR_NONE;
+}
+
+
+#define print_string(x) do { err = print (outbuf, x, sizeof (x) - 1); if (err) return err; } while (0)
+
+static grub_err_t
+print_num (struct output_buffer *outbuf, int n)
+{
+ char buf[20];
+ grub_snprintf (buf, sizeof (buf), "%d", n);
+ return print (outbuf, buf, grub_strlen (buf));
+}
+
+static grub_err_t
+label (const char *line, struct syslinux_menu *menu)
+{
+ struct syslinux_menuentry *entry;
+
+ entry = grub_malloc (sizeof (*entry));
+ if (!entry)
+ return grub_errno;
+ grub_memset (entry, 0, sizeof (*entry));
+ entry->label = grub_strdup (line);
+ if (!entry->label)
+ {
+ grub_free (entry);
+ return grub_errno;
+ }
+ entry->next = menu->entries;
+ entry->prev = NULL;
+ if (menu->entries)
+ menu->entries->prev = entry;
+ menu->entries = entry;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+kernel (const char *line, struct syslinux_menu *menu)
+{
+ const char *end = line + grub_strlen (line);
+
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->kernel_file = grub_strdup (line);
+ if (!menu->entries->kernel_file)
+ return grub_errno;
+
+ menu->entries->entry_type = KERNEL_LINUX;
+
+ if (end - line >= 2 && grub_strcmp (end - 2, ".0") == 0)
+ menu->entries->entry_type = KERNEL_PXE;
+
+ if (end - line >= 4 && grub_strcasecmp (end - 4, ".bin") == 0)
+ menu->entries->entry_type = KERNEL_BIN;
+
+ if (end - line >= 3 && grub_strcasecmp (end - 3, ".bs") == 0)
+ menu->entries->entry_type = KERNEL_CHAINLOADER;
+
+ if (end - line >= 4 && grub_strcasecmp (end - 4, ".bss") == 0)
+ menu->entries->entry_type = KERNEL_CHAINLOADER_BPB;
+
+ if (end - line >= 4 && grub_strcasecmp (end - 4, ".c32") == 0)
+ menu->entries->entry_type = KERNEL_COM32;
+
+ if (end - line >= 4 && grub_strcasecmp (end - 4, ".cbt") == 0)
+ menu->entries->entry_type = KERNEL_COM;
+
+ if (end - line >= 4 && grub_strcasecmp (end - 4, ".com") == 0)
+ menu->entries->entry_type = KERNEL_COM;
+
+ if (end - line >= 4 && grub_strcasecmp (end - 4, ".img") == 0)
+ menu->entries->entry_type = KERNEL_IMG;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_linux (const char *line, struct syslinux_menu *menu)
+{
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->kernel_file = grub_strdup (line);
+ if (!menu->entries->kernel_file)
+ return grub_errno;
+ menu->entries->entry_type = KERNEL_LINUX;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_boot (const char *line, struct syslinux_menu *menu)
+{
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->kernel_file = grub_strdup (line);
+ if (!menu->entries->kernel_file)
+ return grub_errno;
+ menu->entries->entry_type = KERNEL_CHAINLOADER;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_bss (const char *line, struct syslinux_menu *menu)
+{
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->kernel_file = grub_strdup (line);
+ if (!menu->entries->kernel_file)
+ return grub_errno;
+ menu->entries->entry_type = KERNEL_CHAINLOADER_BPB;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_pxe (const char *line, struct syslinux_menu *menu)
+{
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->kernel_file = grub_strdup (line);
+ if (!menu->entries->kernel_file)
+ return grub_errno;
+ menu->entries->entry_type = KERNEL_PXE;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_fdimage (const char *line, struct syslinux_menu *menu)
+{
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->kernel_file = grub_strdup (line);
+ if (!menu->entries->kernel_file)
+ return grub_errno;
+ menu->entries->entry_type = KERNEL_IMG;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_comboot (const char *line, struct syslinux_menu *menu)
+{
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->kernel_file = grub_strdup (line);
+ if (!menu->entries->kernel_file)
+ return grub_errno;
+ menu->entries->entry_type = KERNEL_COM;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_com32 (const char *line, struct syslinux_menu *menu)
+{
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->kernel_file = grub_strdup (line);
+ if (!menu->entries->kernel_file)
+ return grub_errno;
+ menu->entries->entry_type = KERNEL_COM32;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_config (const char *line, struct syslinux_menu *menu)
+{
+ const char *space;
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ for (space = line; *space && !grub_isspace (*space); space++);
+ menu->entries->kernel_file = grub_strndup (line, space - line);
+ if (!menu->entries->kernel_file)
+ return grub_errno;
+ for (; *space && grub_isspace (*space); space++);
+ if (*space)
+ {
+ menu->entries->argument = grub_strdup (space);
+ if (!menu->entries->argument)
+ return grub_errno;
+ }
+ menu->entries->entry_type = KERNEL_CONFIG;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_append (const char *line, struct syslinux_menu *menu)
+{
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->append = grub_strdup (line);
+ if (!menu->entries->append)
+ return grub_errno;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_initrd (const char *line, struct syslinux_menu *menu)
+{
+ struct initrd_list *ninitrd;
+ const char *comma;
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ while (*line)
+ {
+ for (comma = line; *comma && *comma != ','; comma++);
+
+ ninitrd = grub_malloc (sizeof (*ninitrd));
+ if (!ninitrd)
+ return grub_errno;
+ ninitrd->file = grub_strndup (line, comma - line);
+ if (!ninitrd->file)
+ {
+ grub_free (ninitrd);
+ return grub_errno;
+ }
+ ninitrd->next = NULL;
+ if (menu->entries->initrds_last)
+ menu->entries->initrds_last->next = ninitrd;
+ else
+ {
+ menu->entries->initrds_last = ninitrd;
+ menu->entries->initrds = ninitrd;
+ }
+
+ line = comma;
+ while (*line == ',')
+ line++;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_default (const char *line, struct syslinux_menu *menu)
+{
+ menu->def = grub_strdup (line);
+ if (!menu->def)
+ return grub_errno;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_timeout (const char *line, struct syslinux_menu *menu)
+{
+ menu->timeout = grub_strtoul (line, NULL, 0);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_menudefault (const char *line __attribute__ ((unused)),
+ struct syslinux_menu *menu)
+{
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->make_default = 1;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_menubackground (const char *line,
+ struct syslinux_menu *menu)
+{
+ menu->background = grub_strdup (line);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_localboot (const char *line,
+ struct syslinux_menu *menu)
+{
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->kernel_file = grub_strdup (line);
+ if (!menu->entries->kernel_file)
+ return grub_errno;
+ menu->entries->entry_type = LOCALBOOT;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+cmd_extlabel (const char *line, struct syslinux_menu *menu)
+{
+ const char *in;
+ char *out;
+
+ if (!menu->entries)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "kernel without label");
+
+ menu->entries->extlabel = grub_malloc (grub_strlen (line) + 1);
+ if (!menu->entries->extlabel)
+ return grub_errno;
+ in = line;
+ out = menu->entries->extlabel;
+ while (*in)
+ {
+ if (in[0] == '^' && in[1])
+ {
+ menu->entries->hotkey = grub_tolower (in[1]);
+ in++;
+ }
+ *out++ = *in++;
+ }
+ *out = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+
+static grub_err_t
+cmd_say (const char *line, struct syslinux_menu *menu)
+{
+ struct syslinux_say *nsay;
+ nsay = grub_malloc (sizeof (*nsay) + grub_strlen (line) + 1);
+ if (!nsay)
+ return grub_errno;
+ nsay->prev = NULL;
+ if (menu->entries)
+ {
+ nsay->next = menu->entries->say;
+ menu->entries->say = nsay;
+ }
+ else
+ {
+ nsay->next = menu->say;
+ menu->say = nsay;
+ }
+
+ if (nsay->next)
+ nsay->next->prev = nsay;
+
+ grub_memcpy (nsay->msg, line, grub_strlen (line) + 1);
+ return GRUB_ERR_NONE;
+}
+
+static char *
+get_read_filename (struct syslinux_menu *menu,
+ const char *filename)
+{
+ return grub_xasprintf ("%s/%s",
+ filename[0] == '/' ? menu->root_read_directory
+ : menu->current_read_directory, filename);
+}
+
+static char *
+get_target_filename (struct syslinux_menu *menu,
+ const char *filename)
+{
+ return grub_xasprintf ("%s/%s",
+ filename[0] == '/' ? menu->root_target_directory
+ : menu->current_target_directory, filename);
+}
+
+static grub_err_t
+syslinux_parse (const char *filename,
+ struct syslinux_menu *menu)
+{
+ const char *old_filename = menu->filename;
+ grub_err_t ret;
+ char *nf;
+ nf = get_read_filename (menu, filename);
+ if (!nf)
+ return grub_errno;
+ menu->filename = nf;
+ ret = syslinux_parse_real (menu);
+ if (ret == GRUB_ERR_FILE_NOT_FOUND
+ || ret == GRUB_ERR_BAD_FILENAME)
+ {
+ grub_errno = ret = GRUB_ERR_NONE;
+ add_comment (menu, "# File ", 0);
+ add_comment (menu, nf, 0);
+ add_comment (menu, " not found", 1);
+ }
+ grub_free (nf);
+ menu->filename = old_filename;
+ return ret;
+}
+
+struct
+{
+ const char *name1;
+ const char *name2;
+ grub_err_t (*parse) (const char *line, struct syslinux_menu *menu);
+} commands[] = {
+ /* FIXME: support tagname. */
+ {"include", NULL, syslinux_parse},
+ {"menu", "include", syslinux_parse},
+ {"label", NULL, label},
+ {"kernel", NULL, kernel},
+ {"linux", NULL, cmd_linux},
+ {"boot", NULL, cmd_boot},
+ {"bss", NULL, cmd_bss},
+ {"pxe", NULL, cmd_pxe},
+ {"fdimage", NULL, cmd_fdimage},
+ {"comboot", NULL, cmd_comboot},
+ {"com32", NULL, cmd_com32},
+ {"config", NULL, cmd_config},
+ {"append", NULL, cmd_append},
+ /* FIXME: ipappend not supported. */
+ {"localboot", NULL, cmd_localboot},
+ {"initrd", NULL, cmd_initrd},
+ {"default", NULL, cmd_default},
+ {"menu", "label", cmd_extlabel},
+ /* FIXME: MENU LABEL not supported. */
+ /* FIXME: MENU HIDDEN not supported. */
+ /* FIXME: MENU SEPARATOR not supported. */
+ /* FIXME: MENU INDENT not supported. */
+ /* FIXME: MENU DISABLE not supported. */
+ /* FIXME: MENU HIDE not supported. */
+ {"menu", "default", cmd_menudefault},
+ /* FIXME: MENU PASSWD not supported. */
+ /* FIXME: MENU MASTER PASSWD not supported. */
+ {"menu", "background", cmd_menubackground},
+ /* FIXME: MENU BEGIN not supported. */
+ /* FIXME: MENU GOTO not supported. */
+ /* FIXME: MENU EXIT not supported. */
+ /* FIXME: MENU QUIT not supported. */
+ /* FIXME: MENU START not supported. */
+ /* FIXME: MENU AUTOBOOT not supported. */
+ /* FIXME: MENU TABMSG not supported. */
+ /* FIXME: MENU NOTABMSG not supported. */
+ /* FIXME: MENU PASSPROMPT not supported. */
+ /* FIXME: MENU COLOR not supported. */
+ /* FIXME: MENU MSGCOLOR not supported. */
+ /* FIXME: MENU WIDTH not supported. */
+ /* FIXME: MENU MARGIN not supported. */
+ /* FIXME: MENU PASSWORDMARGIN not supported. */
+ /* FIXME: MENU ROWS not supported. */
+ /* FIXME: MENU TABMSGROW not supported. */
+ /* FIXME: MENU CMDLINEROW not supported. */
+ /* FIXME: MENU ENDROW not supported. */
+ /* FIXME: MENU PASSWORDROW not supported. */
+ /* FIXME: MENU TIMEOUTROW not supported. */
+ /* FIXME: MENU HELPMSGROW not supported. */
+ /* FIXME: MENU HELPMSGENDROW not supported. */
+ /* FIXME: MENU HIDDENROW not supported. */
+ /* FIXME: MENU HSHIFT not supported. */
+ /* FIXME: MENU VSHIFT not supported. */
+ {"timeout", NULL, cmd_timeout},
+ /* FIXME: TOTALTIMEOUT not supported. */
+ /* FIXME: ONTIMEOUT not supported. */
+ /* FIXME: ONERROR not supported. */
+ /* FIXME: SERIAL not supported. */
+ /* FIXME: CONSOLE not supported. */
+ /* FIXME: FONT not supported. */
+ /* FIXME: KBDMAP not supported. */
+ {"say", NULL, cmd_say},
+ /* FIXME: DISPLAY not supported. */
+ /* FIXME: F* not supported. */
+
+ /* Commands to control interface behaviour which aren't needed with GRUB.
+ If they are important in your environment please contact GRUB team.
+ */
+ {"prompt", NULL, NULL},
+ {"nocomplete", NULL, NULL},
+ {"noescape", NULL, NULL},
+ {"implicit", NULL, NULL},
+ {"allowoptions", NULL, NULL}
+};
+
+static grub_err_t
+helptext (const char *line, grub_file_t file, struct syslinux_menu *menu)
+{
+ char *help;
+ char *buf = NULL;
+ 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)))
+ {
+ char *ptr;
+ grub_size_t needlen;
+ for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++);
+ if (grub_strncasecmp (ptr, "endtext", sizeof ("endtext") - 1) == 0)
+ {
+ ptr += sizeof ("endtext") - 1;
+ for (; *ptr && (grub_isspace (*ptr) || *ptr == '\n' || *ptr == '\r');
+ ptr++);
+ if (!*ptr)
+ {
+ menu->entries->help = help;
+ grub_free (buf);
+ return GRUB_ERR_NONE;
+ }
+ }
+ needlen = helplen + 1 + grub_strlen (buf);
+ if (alloclen < needlen)
+ {
+ alloclen = 2 * needlen;
+ help = grub_realloc (help, alloclen);
+ if (!help)
+ {
+ grub_free (buf);
+ return grub_errno;
+ }
+ }
+ helplen += grub_stpcpy (help + helplen, buf) - (help + helplen);
+ }
+
+ grub_free (buf);
+ grub_free (help);
+ return grub_errno;
+}
+
+
+static grub_err_t
+syslinux_parse_real (struct syslinux_menu *menu)
+{
+ grub_file_t file;
+ char *buf = NULL;
+ grub_err_t err = GRUB_ERR_NONE;
+
+ file = grub_file_open (menu->filename, GRUB_FILE_TYPE_CONFIG);
+ if (!file)
+ return grub_errno;
+ while ((grub_free (buf), buf = grub_file_getline (file)))
+ {
+ const char *ptr1, *ptr2, *ptr3, *ptr4, *ptr5;
+ char *end;
+ unsigned i;
+ end = buf + grub_strlen (buf);
+ while (end > buf && (end[-1] == '\n' || end[-1] == '\r'))
+ end--;
+ *end = 0;
+ for (ptr1 = buf; *ptr1 && grub_isspace (*ptr1); ptr1++);
+ if (*ptr1 == '#' || *ptr1 == 0)
+ {
+ err = add_comment (menu, ptr1, 1);
+ if (err)
+ goto fail;
+ continue;
+ }
+ for (ptr2 = ptr1; !grub_isspace (*ptr2) && *ptr2; ptr2++);
+ 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 < 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
+ || (grub_strlen (commands[i].name2)
+ == (grub_size_t) (ptr4 - ptr3)
+ && grub_strncasecmp (commands[i].name2, ptr3, ptr4 - ptr3)
+ == 0)))
+ break;
+ if (i == ARRAY_SIZE(commands))
+ {
+ if (sizeof ("text") - 1 == ptr2 - ptr1
+ && grub_strncasecmp ("text", ptr1, ptr2 - ptr1) == 0
+ && (sizeof ("help") - 1 == ptr4 - ptr3
+ && grub_strncasecmp ("help", ptr3, ptr4 - ptr3) == 0))
+ {
+ if (helptext (ptr5, file, menu))
+ {
+ grub_free (buf);
+ return 1;
+ }
+ continue;
+ }
+
+ add_comment (menu, " # UNSUPPORTED command '", 0);
+ add_comment (menu, ptr1, 0);
+ add_comment (menu, "'", 1);
+
+ continue;
+ }
+ if (commands[i].parse)
+ {
+ err = commands[i].parse (commands[i].name2
+ ? ptr5 : ptr3, menu);
+ if (err)
+ goto fail;
+ }
+ }
+ fail:
+ grub_file_close (file);
+ grub_free (buf);
+ return err;
+}
+
+static grub_err_t
+print_escaped (struct output_buffer *outbuf,
+ const char *from, const char *to)
+{
+ const char *ptr;
+ grub_err_t err;
+ if (!to)
+ to = from + grub_strlen (from);
+ err = ensure_space (outbuf, (to - from) * 4 + 2);
+ if (err)
+ return err;
+ outbuf->buf[outbuf->ptr++] = '\'';
+ for (ptr = from; *ptr && ptr < to; ptr++)
+ {
+ if (*ptr == '\'')
+ {
+ outbuf->buf[outbuf->ptr++] = '\'';
+ outbuf->buf[outbuf->ptr++] = '\\';
+ outbuf->buf[outbuf->ptr++] = '\'';
+ outbuf->buf[outbuf->ptr++] = '\'';
+ }
+ else
+ outbuf->buf[outbuf->ptr++] = *ptr;
+ }
+ outbuf->buf[outbuf->ptr++] = '\'';
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+print_file (struct output_buffer *outbuf,
+ struct syslinux_menu *menu, const char *from, const char *to)
+{
+ grub_err_t err;
+ if (!to)
+ to = from + grub_strlen (from);
+ err = print_escaped (outbuf, from[0] == '/'
+ ? menu->root_target_directory
+ : menu->current_target_directory, NULL);
+ if (err)
+ return err;
+
+ err = print (outbuf, "/", 1);
+ if (err)
+ return err;
+ return print_escaped (outbuf, from, to);
+}
+
+/*
+ * Makefile.am mimics this when generating tests/syslinux/ubuntu10.04_grub.cfg,
+ * so changes here may need to be reflected there too.
+ */
+static void
+simplify_filename (char *str)
+{
+ char *iptr, *optr = str;
+ for (iptr = str; *iptr; iptr++)
+ {
+ if (*iptr == '/' && optr != str && optr[-1] == '/')
+ continue;
+ if (iptr[0] == '/' && iptr[1] == '.' && iptr[2] == '/')
+ {
+ iptr += 2;
+ continue;
+ }
+ if (iptr[0] == '/' && iptr[1] == '.' && iptr[2] == '.'
+ && iptr[3] == '/')
+ {
+ iptr += 3;
+ while (optr >= str && *optr != '/')
+ optr--;
+ if (optr < str)
+ {
+ str[0] = '/';
+ optr = str;
+ }
+ optr++;
+ continue;
+ }
+ *optr++ = *iptr;
+ }
+ *optr = '\0';
+}
+
+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)
+ {
+ 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);
+ for (; say && say->prev; say = say->prev)
+ {
+ print_string ("echo ");
+ if (print_escaped (outbuf, say->msg, NULL)) return grub_errno;
+ print_string ("\n");
+ }
+ }
+
+ /* FIXME: support help text. */
+ switch (curentry->entry_type)
+ {
+ case KERNEL_LINUX:
+ {
+ 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)
+ == 0)
+ break;
+ if (ptr && *ptr)
+ {
+ initrd = ptr + sizeof ("initrd=") - 1;
+ for (initrde = initrd; *initrde && !grub_isspace (*initrde); initrde++);
+ }
+ 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 (curentry->append)
+ {
+ err = print (outbuf, curentry->append, grub_strlen (curentry->append));
+ if (err)
+ return err;
+ }
+ print_string ("\n");
+ if (initrd || curentry->initrds)
+ {
+ struct initrd_list *lst;
+ print_string (" initrd$linux_suffix ");
+ if (initrd)
+ {
+ print_file (outbuf, menu, initrd, initrde);
+ print_string (" ");
+ }
+ for (lst = curentry->initrds; lst; lst = lst->next)
+ {
+ print_file (outbuf, menu, lst->file, NULL);
+ print_string (" ");
+ }
+
+ print_string ("\n");
+ }
+ }
+ break;
+ case KERNEL_CHAINLOADER:
+ print_string (" chainloader ");
+ print_file (outbuf, menu, curentry->kernel_file, NULL);
+ print_string ("\n");
+ break;
+ case KERNEL_CHAINLOADER_BPB:
+ print_string (" chainloader --bpb ");
+ print_file (outbuf, menu, curentry->kernel_file, NULL);
+ print_string ("\n");
+ break;
+ case LOCALBOOT:
+ /* FIXME: support -1. */
+ /* FIXME: PXELINUX. */
+ {
+ int n = grub_strtol (curentry->kernel_file, NULL, 0);
+ if (n >= 0 && n <= 0x02)
+ {
+ print_string (" root=fd");
+ if (print_num (outbuf, n))
+ return grub_errno;
+ print_string (";\n chainloader +1;\n");
+
+ break;
+ }
+ if (n >= 0x80 && n < 0x8a)
+ {
+ print_string (" root=hd");
+ if (print_num (outbuf, n - 0x80))
+ return grub_errno;
+ print_string (";\n chainloader +1;\n");
+ break;
+ }
+ print_string (" # UNSUPPORTED localboot type ");
+ print_string ("\ntrue;\n");
+ if (print_num (outbuf, n))
+ return grub_errno;
+ print_string ("\n");
+ break;
+ }
+ case KERNEL_COM32:
+ case KERNEL_COM:
+ {
+ char *basename = NULL;
+
+ {
+ char *ptr;
+ for (ptr = curentry->kernel_file; *ptr; ptr++)
+ if (*ptr == '/' || *ptr == '\\')
+ basename = ptr;
+ }
+ if (!basename)
+ basename = curentry->kernel_file;
+ else
+ basename++;
+ if (grub_strcasecmp (basename, "chain.c32") == 0)
+ {
+ char *file = NULL;
+ int is_fd = -1, devn = 0;
+ int part = -1;
+ int swap = 0;
+ char *ptr;
+ for (ptr = curentry->append; *ptr; )
+ {
+ while (grub_isspace (*ptr))
+ ptr++;
+ /* FIXME: support mbr: and boot. */
+ if (ptr[0] == 'h' && ptr[1] == 'd')
+ {
+ is_fd = 0;
+ devn = grub_strtoul (ptr + 2, (const char **)&ptr, 0);
+ continue;
+ }
+ if (grub_strncasecmp (ptr, "file=", 5) == 0)
+ {
+ file = ptr + 5;
+ for (ptr = file; *ptr && !grub_isspace (*ptr); ptr++);
+ if (*ptr)
+ {
+ *ptr = 0;
+ ptr++;
+ }
+ continue;
+ }
+ if (grub_strncasecmp (ptr, "swap", sizeof ("swap") - 1) == 0)
+ {
+ swap = 1;
+ ptr += sizeof ("swap") - 1;
+ continue;
+ }
+
+ if (ptr[0] == 'f' && ptr[1] == 'd')
+ {
+ is_fd = 1;
+ devn = grub_strtoul (ptr + 2, (const char **)&ptr, 0);
+ continue;
+ }
+ if (grub_isdigit (ptr[0]))
+ {
+ part = grub_strtoul (ptr, (const char **)&ptr, 0);
+ continue;
+ }
+ /* FIXME: isolinux, ntldr, cmldr, *dos, seg, hide
+ FIXME: sethidden. */
+ print_string (" # UNSUPPORTED option ");
+ if (print (outbuf, ptr, grub_strlen (ptr)))
+ return 0;
+ print_string ("\n");
+ break;
+ }
+ if (is_fd == -1)
+ {
+ print_string (" # no drive specified\n");
+ break;
+ }
+ if (!*ptr)
+ {
+ print_string (is_fd ? " root=fd": " root=hd");
+ if (print_num (outbuf, devn))
+ return grub_errno;
+ if (part != -1)
+ {
+ print_string (",");
+ if (print_num (outbuf, part + 1))
+ return grub_errno;
+ }
+ print_string (";\n");
+ if (file)
+ {
+ print_string (" chainloader ");
+ print_file (outbuf, menu, file, NULL);
+ print_string (";\n");
+ }
+ else
+ print_string (" chainloader +1;\n");
+ if (swap)
+ print_string (" drivemap -s hd0 \"root\";\n");
+ }
+ break;
+ }
+
+ if (grub_strcasecmp (basename, "mboot.c32") == 0)
+ {
+ char *ptr;
+ int first = 1;
+ int is_kernel = 1;
+ for (ptr = curentry->append; *ptr; )
+ {
+ char *ptrr = ptr;
+ while (*ptr && !grub_isspace (*ptr))
+ ptr++;
+ if (ptrr + 2 == ptr && ptrr[0] == '-' && ptrr[1] == '-')
+ {
+ print_string ("\n");
+ first = 1;
+ continue;
+ }
+ if (first)
+ {
+ if (is_kernel)
+ print_string (" multiboot ");
+ else
+ print_string (" module ");
+ first = 0;
+ is_kernel = 0;
+ if (print_file (outbuf, menu, ptrr, ptr))
+ return grub_errno;
+ continue;
+ }
+ if (print_escaped (outbuf, ptrr, ptr))
+ return grub_errno;
+ }
+ break;
+ }
+
+ if (grub_strcasecmp (basename, "ifcpu64.c32") == 0)
+ {
+ char *lm, *lme, *pae = 0, *paee = 0, *i386s = 0, *i386e = 0;
+ char *ptr;
+ ptr = curentry->append;
+ while (grub_isspace (*ptr))
+ ptr++;
+ lm = ptr;
+ while (*ptr && !grub_isspace (*ptr))
+ ptr++;
+ lme = ptr;
+ while (grub_isspace (*ptr))
+ ptr++;
+ if (ptr[0] == '-' && ptr[1] == '-')
+ {
+ ptr += 2;
+ while (grub_isspace (*ptr))
+ ptr++;
+ pae = ptr;
+ while (*ptr && !grub_isspace (*ptr))
+ ptr++;
+ paee = ptr;
+ }
+ while (grub_isspace (*ptr))
+ ptr++;
+ if (ptr[0] == '-' && ptr[1] == '-')
+ {
+ ptr += 2;
+ while (grub_isspace (*ptr))
+ ptr++;
+ i386s = ptr;
+ while (*ptr && !grub_isspace (*ptr))
+ ptr++;
+ i386e = ptr;
+ }
+ *lme = '\0';
+ if (paee)
+ *paee = '\0';
+ if (i386e)
+ *i386e = '\0';
+ if (!i386s)
+ {
+ i386s = pae;
+ pae = 0;
+ }
+ print_string ("if cpuid --long-mode; then true;\n");
+ if (print_entry (outbuf, menu, lm))
+ return grub_errno;
+ if (pae)
+ {
+ print_string ("elif cpuid --pae; then true;\n");
+ if (print_entry (outbuf, menu, pae))
+ return grub_errno;
+ }
+ print_string ("else\n");
+ if (print_entry (outbuf, menu, i386s))
+ return grub_errno;
+ print_string ("fi\n");
+ break;
+ }
+
+ if (grub_strcasecmp (basename, "reboot.c32") == 0)
+ {
+ print_string (" reboot\n");
+ break;
+ }
+
+ if (grub_strcasecmp (basename, "poweroff.com") == 0)
+ {
+ print_string (" halt\n");
+ break;
+ }
+
+ if (grub_strcasecmp (basename, "whichsys.c32") == 0)
+ {
+ grub_syslinux_flavour_t flavour = GRUB_SYSLINUX_ISOLINUX;
+ const char *flav[] =
+ {
+ [GRUB_SYSLINUX_ISOLINUX] = "iso",
+ [GRUB_SYSLINUX_PXELINUX] = "pxe",
+ [GRUB_SYSLINUX_SYSLINUX] = "sys"
+ };
+ char *ptr;
+ for (ptr = curentry->append; *ptr; )
+ {
+ char *bptr, c;
+ while (grub_isspace (*ptr))
+ ptr++;
+ if (grub_strncasecmp (ptr, "-iso-", 5) == 0)
+ {
+ ptr += sizeof ("-iso-") - 1;
+ flavour = GRUB_SYSLINUX_ISOLINUX;
+ continue;
+ }
+ if (grub_strncasecmp (ptr, "-pxe-", 5) == 0)
+ {
+ ptr += sizeof ("-pxe-") - 1;
+ flavour = GRUB_SYSLINUX_PXELINUX;
+ continue;
+ }
+ if (grub_strncasecmp (ptr, "-sys-", 5) == 0)
+ {
+ ptr += sizeof ("-sys-") - 1;
+ flavour = GRUB_SYSLINUX_SYSLINUX;
+ continue;
+ }
+ bptr = ptr;
+ while (*ptr && !grub_isspace (*ptr))
+ ptr++;
+ c = *ptr;
+ *ptr = '\0';
+ if (menu->flavour == GRUB_SYSLINUX_UNKNOWN
+ && flavour == GRUB_SYSLINUX_ISOLINUX)
+ {
+ print_string ("if [ x$syslinux_flavour = xiso -o x$syslinux_flavour = x ]; then true;\n");
+ menu->flavour = GRUB_SYSLINUX_ISOLINUX;
+ print_entry (outbuf, menu, bptr);
+ menu->flavour = GRUB_SYSLINUX_UNKNOWN;
+ print_string ("fi\n");
+ }
+ else if (menu->flavour == GRUB_SYSLINUX_UNKNOWN)
+ {
+ print_string ("if [ x$syslinux_flavour = x");
+ err = print (outbuf, flav[flavour], grub_strlen (flav[flavour]));
+ if (err)
+ return err;
+ print_string (" ]; then true;\n");
+ menu->flavour = flavour;
+ print_entry (outbuf, menu, bptr);
+ menu->flavour = GRUB_SYSLINUX_UNKNOWN;
+ print_string ("fi\n");
+ }
+ if (menu->flavour != GRUB_SYSLINUX_UNKNOWN
+ && menu->flavour == flavour)
+ print_entry (outbuf, menu, bptr);
+ *ptr = c;
+ }
+ 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 */
+
+ print_string (" # UNSUPPORTED com(32) ");
+ err = print (outbuf, basename, grub_strlen (basename));
+ if (err)
+ return err;
+ print_string ("\ntrue;\n");
+ break;
+ }
+ case KERNEL_CONFIG:
+ {
+ const char *ap;
+ ap = curentry->append;
+ if (!ap)
+ ap = curentry->argument;
+ if (!ap)
+ ap = "";
+ print_config (outbuf, menu, curentry->kernel_file, ap);
+ }
+ break;
+ case KERNEL_NO_KERNEL:
+ /* FIXME: support this. */
+ case KERNEL_BIN:
+ case KERNEL_PXE:
+ case KERNEL_IMG:
+ print_string (" # UNSUPPORTED entry type ");
+ if (print_num (outbuf, curentry->entry_type))
+ return grub_errno;
+ print_string ("\ntrue;\n");
+ break;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+print_entry (struct output_buffer *outbuf,
+ struct syslinux_menu *menu,
+ const char *str)
+{
+ struct syslinux_menuentry *curentry;
+ for (curentry = menu->entries; curentry; curentry = curentry->next)
+ if (grub_strcasecmp (curentry->label, str) == 0)
+ {
+ grub_err_t err;
+ err = write_entry (outbuf, menu, curentry);
+ if (err)
+ return err;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static void
+free_menu (struct syslinux_menu *menu)
+{
+ struct syslinux_say *say, *nsay;
+ struct syslinux_menuentry *entry, *nentry;
+
+ grub_free (menu->def);
+ grub_free (menu->comments);
+ grub_free (menu->background);
+ for (say = menu->say; say ; say = nsay)
+ {
+ nsay = say->next;
+ grub_free (say);
+ }
+
+ for (entry = menu->entries; entry ; entry = nentry)
+ {
+ nentry = entry->next;
+ struct initrd_list *initrd, *ninitrd;
+
+ for (initrd = entry->initrds; initrd ; initrd = ninitrd)
+ {
+ ninitrd = initrd->next;
+ grub_free (initrd->file);
+ grub_free (initrd);
+ }
+
+ grub_free (entry->comments);
+ grub_free (entry->kernel_file);
+ grub_free (entry->label);
+ grub_free (entry->extlabel);
+ grub_free (entry->append);
+ grub_free (entry->help);
+ grub_free (entry);
+ }
+}
+
+static grub_err_t
+config_file (struct output_buffer *outbuf,
+ const char *root, const char *target_root,
+ const char *cwd, const char *target_cwd,
+ const char *fname, struct syslinux_menu *parent,
+ grub_syslinux_flavour_t flav)
+{
+ grub_err_t err;
+ struct syslinux_menu menu;
+ struct syslinux_menuentry *curentry, *lentry;
+ struct syslinux_say *say;
+
+ grub_memset (&menu, 0, sizeof (menu));
+ menu.flavour = flav;
+ menu.root_read_directory = root;
+ menu.root_target_directory = target_root;
+ menu.current_read_directory = cwd;
+ menu.current_target_directory = target_cwd;
+
+ menu.filename = fname;
+ menu.parent = parent;
+ err = syslinux_parse_real (&menu);
+ if (err)
+ return err;
+
+ for (say = menu.say; say && say->next; say = say->next);
+ for (; say && say->prev; say = say->prev)
+ {
+ print_string ("echo ");
+ err = print_escaped (outbuf, say->msg, NULL);
+ if (err)
+ return err;
+ print_string ("\n");
+ }
+
+ if (menu.background)
+ {
+ print_string (" background_image ");
+ err = print_file (outbuf, &menu, menu.background, NULL);
+ 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.timeout == 0 && menu.entries && menu.def)
+ {
+ err = print_entry (outbuf, &menu, menu.def);
+ if (err)
+ return err;
+ }
+ else if (menu.entries)
+ {
+ for (curentry = menu.entries; curentry->next; curentry = curentry->next);
+ lentry = curentry;
+
+ print_string ("set timeout=");
+ err = print_num (outbuf, (menu.timeout + 9) / 10);
+ if (err)
+ return err;
+ print_string ("\n");
+
+ if (menu.def)
+ {
+ print_string (" default=");
+ err = print_escaped (outbuf, menu.def, NULL);
+ if (err)
+ return err;
+ print_string ("\n");
+ }
+ for (curentry = lentry; curentry; curentry = curentry->prev)
+ {
+ print_string ("menuentry ");
+ err = print_escaped (outbuf,
+ curentry->extlabel ? : curentry->label, NULL);
+ if (err)
+ return err;
+ if (curentry->hotkey)
+ {
+ char hk[] = { curentry->hotkey, '\0' };
+ print_string (" --hotkey '");
+ print_string (hk);
+ print_string ("'");
+ }
+ print_string (" --id ");
+ err = print_escaped (outbuf, curentry->label, NULL);
+ if (err)
+ return err;
+ print_string (" {\n");
+
+ err = write_entry (outbuf, &menu, curentry);
+ if (err)
+ return err;
+
+ print_string ("}\n");
+ }
+ }
+ free_menu (&menu);
+ return GRUB_ERR_NONE;
+}
+
+char *
+grub_syslinux_config_file (const char *base, const char *target_base,
+ const char *cwd, const char *target_cwd,
+ const char *fname, grub_syslinux_flavour_t flav)
+{
+ struct output_buffer outbuf = { 0, 0, 0 };
+ grub_err_t err;
+ err = config_file (&outbuf, base, target_base, cwd, target_cwd,
+ fname, NULL, flav);
+ if (err)
+ return NULL;
+ err = print (&outbuf, "\0", 1);
+ if (err)
+ return NULL;
+ return outbuf.buf;
+}
diff --git a/grub-core/lib/uboot/reboot.c b/grub-core/lib/uboot/reboot.c
new file mode 100644
index 0000000..00a2507
--- /dev/null
+++ b/grub-core/lib/uboot/reboot.c
@@ -0,0 +1,31 @@
+/*
+ * 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/kernel.h>
+#include <grub/misc.h>
+#include <grub/uboot/uboot.h>
+#include <grub/loader.h>
+
+void
+grub_reboot (void)
+{
+ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN);
+
+ grub_uboot_reset ();
+ while (1);
+}
diff --git a/grub-core/lib/x86_64/efi/relocator.c b/grub-core/lib/x86_64/efi/relocator.c
new file mode 100644
index 0000000..7d200a1
--- /dev/null
+++ b/grub-core/lib/x86_64/efi/relocator.c
@@ -0,0 +1,79 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ * Copyright (C) 2016 Oracle and/or its affiliates. All rights reserved.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/mm.h>
+#include <grub/misc.h>
+
+#include <grub/types.h>
+#include <grub/err.h>
+
+#include <grub/i386/relocator.h>
+#include <grub/relocator_private.h>
+
+extern grub_uint64_t grub_relocator64_rax;
+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_rsi;
+
+extern grub_uint8_t grub_relocator64_efi_start;
+extern grub_uint8_t grub_relocator64_efi_end;
+
+#define RELOCATOR_SIZEOF(x) (&grub_relocator##x##_end - &grub_relocator##x##_start)
+
+grub_err_t
+grub_relocator64_efi_boot (struct grub_relocator *rel,
+ struct grub_relocator64_efi_state state)
+{
+ grub_err_t err;
+ void *relst;
+ grub_relocator_chunk_t ch;
+
+ /*
+ * 64-bit relocator code may live above 4 GiB quite well.
+ * However, I do not want ask for problems. Just in case.
+ */
+ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, 0, 0x100000000,
+ RELOCATOR_SIZEOF (64_efi), 16,
+ GRUB_RELOCATOR_PREFERENCE_NONE, 1);
+ if (err)
+ return err;
+
+ /* Do not touch %rsp! It points to EFI created stack. */
+ grub_relocator64_rax = state.rax;
+ grub_relocator64_rbx = state.rbx;
+ grub_relocator64_rcx = state.rcx;
+ grub_relocator64_rdx = state.rdx;
+ grub_relocator64_rip = state.rip;
+ grub_relocator64_rsi = state.rsi;
+
+ grub_memmove (get_virtual_current_address (ch), &grub_relocator64_efi_start,
+ RELOCATOR_SIZEOF (64_efi));
+
+ err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
+ &relst, NULL);
+ if (err)
+ return err;
+
+ ((void (*) (void)) relst) ();
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/lib/x86_64/relocator_asm.S b/grub-core/lib/x86_64/relocator_asm.S
new file mode 100644
index 0000000..2ab6d8c
--- /dev/null
+++ b/grub-core/lib/x86_64/relocator_asm.S
@@ -0,0 +1,85 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/i386/memory.h>
+
+ .p2align 2
+
+VARIABLE(grub_relocator_backward_start)
+ /* mov imm32, %rax */
+ .byte 0x48
+ .byte 0xb8
+VARIABLE(grub_relocator_backward_dest)
+ .long 0, 0
+ movq %rax, %rdi
+
+ /* mov imm64, %rax */
+ .byte 0x48
+ .byte 0xb8
+VARIABLE(grub_relocator_backward_src)
+ .long 0, 0
+ movq %rax, %rsi
+
+ /* mov imm64, %rcx */
+ .byte 0x48
+ .byte 0xb9
+VARIABLE(grub_relocator_backward_chunk_size)
+ .long 0, 0
+
+ add %rcx, %rsi
+ add %rcx, %rdi
+
+ /* Backward movsb is implicitly off-by-one. compensate that. */
+ sub $1, %rsi
+ sub $1, %rdi
+
+ /* Backward copy. */
+ std
+
+ rep
+ movsb
+VARIABLE(grub_relocator_backward_end)
+
+
+VARIABLE(grub_relocator_forward_start)
+ /* mov imm64, %rax */
+ .byte 0x48
+ .byte 0xb8
+VARIABLE(grub_relocator_forward_dest)
+ .long 0, 0
+ movq %rax, %rdi
+
+ /* mov imm64, %rax */
+ .byte 0x48
+ .byte 0xb8
+VARIABLE(grub_relocator_forward_src)
+ .long 0, 0
+ movq %rax, %rsi
+
+ /* mov imm64, %rcx */
+ .byte 0x48
+ .byte 0xb9
+VARIABLE(grub_relocator_forward_chunk_size)
+ .long 0, 0
+
+ /* Forward copy. */
+ cld
+ rep
+ movsb
+VARIABLE(grub_relocator_forward_end)
diff --git a/grub-core/lib/x86_64/setjmp.S b/grub-core/lib/x86_64/setjmp.S
new file mode 100644
index 0000000..6b151bc
--- /dev/null
+++ b/grub-core/lib/x86_64/setjmp.S
@@ -0,0 +1,68 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/dl.h>
+
+ .file "setjmp.S"
+
+GRUB_MOD_LICENSE "GPLv3+"
+
+ .text
+
+/*
+ * jmp_buf:
+ * rbx rsp rbp r12 r13 r14 r15 rip
+ * 0 8 16 24 32 40 48 56
+ */
+
+/*
+ * int grub_setjmp (grub_jmp_buf env)
+ */
+FUNCTION(grub_setjmp)
+ pop %rsi /* Return address, and adjust the stack */
+ xorq %rax, %rax
+ movq %rbx, 0(%rdi) /* RBX */
+ movq %rsp, 8(%rdi) /* RSP */
+ push %rsi
+ movq %rbp, 16(%rdi) /* RBP */
+ movq %r12, 24(%rdi) /* R12 */
+ movq %r13, 32(%rdi) /* R13 */
+ movq %r14, 40(%rdi) /* R14 */
+ movq %r15, 48(%rdi) /* R15 */
+ movq %rsi, 56(%rdi) /* RSI */
+ ret
+
+/*
+ * int grub_longjmp (grub_jmp_buf env, int val)
+ */
+FUNCTION(grub_longjmp)
+ movl %esi, %eax
+ orl %eax, %eax
+ jnz 1f
+ incl %eax
+1:
+
+ movq (%rdi), %rbx
+ movq 8(%rdi), %rsp
+ movq 16(%rdi), %rbp
+ movq 24(%rdi), %r12
+ movq 32(%rdi), %r13
+ movq 40(%rdi), %r14
+ movq 48(%rdi), %r15
+ jmp *56(%rdi)
diff --git a/grub-core/lib/x86_64/xen/relocator.S b/grub-core/lib/x86_64/xen/relocator.S
new file mode 100644
index 0000000..f5364ed
--- /dev/null
+++ b/grub-core/lib/x86_64/xen/relocator.S
@@ -0,0 +1,133 @@
+/*
+ * 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/x86_64/memory.h>
+#include <grub/x86_64/types.h>
+#include <grub/symbol.h>
+#include <grub/xen.h>
+
+/* Macro to load an imm64 value stored by the C-part into %rax: */
+#define MOV_IMM64_RAX(var) .byte 0x48, 0xb8; VARIABLE(var); .quad 0
+
+ .p2align 4 /* force 16-byte alignment */
+
+VARIABLE(grub_relocator_xen_remap_start)
+LOCAL(base):
+ /* Remap the remapper to it's new address. */
+ MOV_IMM64_RAX(grub_relocator_xen_remapper_virt)
+
+ movq %rax, %rdi /* %rdi: new virtual address of remapper */
+ movq %rax, %rbx /* Remember new virtual address */
+
+ MOV_IMM64_RAX(grub_relocator_xen_remapper_map)
+
+ movq %rax, %rsi /* %rsi: page table entry */
+
+ movq $UVMF_INVLPG, %rdx /* %rdx: flags (inv. single entry) */
+ movq $__HYPERVISOR_update_va_mapping, %rax
+ syscall /* Do the remap operation */
+
+ addq $(LOCAL(cont) - LOCAL(base)), %rbx
+
+ jmp *%rbx /* Continue with new virtual address */
+
+LOCAL(cont):
+ /* Modify mappings of new page tables to be read-only. */
+ MOV_IMM64_RAX(grub_relocator_xen_mfn_list)
+
+ movq %rax, %rbx /* %rbx is the base of the p2m list */
+ leaq EXT_C(grub_relocator_xen_paging_areas) (%rip), %r8
+
+1:
+ movq 0(%r8), %r12 /* Get start pfn of the current area */
+ movq GRUB_TARGET_SIZEOF_LONG(%r8), %rcx /* Get # of pg tables */
+ testq %rcx, %rcx /* 0 -> last area reached */
+ jz 3f
+2:
+ movq %r12, %rdi
+ shlq $PAGE_SHIFT, %rdi /* virtual address (1:1 mapping) */
+ movq (%rbx, %r12, 8), %rsi /* mfn */
+ shlq $PAGE_SHIFT, %rsi
+ orq $(GRUB_PAGE_PRESENT | GRUB_PAGE_USER), %rsi /* Build pte */
+ movq $UVMF_INVLPG, %rdx
+ movq %rcx, %r9 /* %rcx clobbered by hypercall */
+ movq $__HYPERVISOR_update_va_mapping, %rax
+ syscall
+
+ movq %r9, %rcx
+ incq %r12 /* next pfn */
+
+ loop 2b
+
+ addq $(2 * GRUB_TARGET_SIZEOF_LONG), %r8 /* next pg table area */
+ jmp 1b
+
+3:
+ /* Switch page tables: pin new L4 pt, load cr3, unpin old L4. */
+ leaq EXT_C(grub_relocator_xen_mmu_op) (%rip), %rdi
+ movq $3, %rsi /* 3 mmu ops */
+ movq $0, %rdx /* pdone (not used) */
+ movq $DOMID_SELF, %r10
+ movq $__HYPERVISOR_mmuext_op, %rax
+ syscall
+
+ /* Continue in virtual kernel mapping. */
+ MOV_IMM64_RAX(grub_relocator_xen_remap_continue)
+
+ jmp *%rax
+
+VARIABLE(grub_relocator_xen_paging_areas)
+ /* array of start, size pairs, size 0 is end marker */
+ .quad 0, 0, 0, 0, 0, 0, 0, 0
+
+VARIABLE(grub_relocator_xen_mmu_op)
+ .space 256
+
+VARIABLE(grub_relocator_xen_remap_end)
+
+
+VARIABLE(grub_relocator_xen_start)
+ /* Unmap old remapper area. */
+ MOV_IMM64_RAX(grub_relocator_xen_remapper_virt2)
+
+ movq %rax, %rdi
+
+ xorq %rax, %rax /* Invalid pte */
+ movq %rax, %rsi
+
+ movq $UVMF_INVLPG, %rdx
+ movq $__HYPERVISOR_update_va_mapping, %rax
+ syscall
+
+ /* Prepare registers for starting kernel. */
+ MOV_IMM64_RAX(grub_relocator_xen_stack)
+
+ movq %rax, %rsp
+
+ MOV_IMM64_RAX(grub_relocator_xen_start_info)
+
+ movq %rax, %rsi
+
+ cld
+
+ MOV_IMM64_RAX(grub_relocator_xen_entry_point)
+
+ /* Now start the new kernel. */
+ jmp *%rax
+
+VARIABLE(grub_relocator_xen_end)
diff --git a/grub-core/lib/xen/datetime.c b/grub-core/lib/xen/datetime.c
new file mode 100644
index 0000000..d96176e
--- /dev/null
+++ b/grub-core/lib/xen/datetime.c
@@ -0,0 +1,40 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/datetime.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/xen.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+grub_err_t
+grub_get_datetime (struct grub_datetime *datetime)
+{
+ long long nix;
+ nix = (grub_xen_shared_info->wc_sec
+ + grub_divmod64 (grub_xen_shared_info->vcpu_info[0].time.system_time, 1000000000, 0));
+ grub_unixtime2datetime (nix, datetime);
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_set_datetime (struct grub_datetime *datetime __attribute__ ((unused)))
+{
+ return grub_error (GRUB_ERR_IO, "setting time isn't supported");
+}
diff --git a/grub-core/lib/xen/halt.c b/grub-core/lib/xen/halt.c
new file mode 100644
index 0000000..2aceead
--- /dev/null
+++ b/grub-core/lib/xen/halt.c
@@ -0,0 +1,32 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/mm.h>
+#include <grub/misc.h>
+#include <grub/kernel.h>
+#include <grub/xen.h>
+
+void
+grub_halt (void)
+{
+ struct sched_shutdown arg;
+
+ arg.reason = SHUTDOWN_poweroff;
+ grub_xen_sched_op (SCHEDOP_shutdown, &arg);
+ for (;;);
+}
diff --git a/grub-core/lib/xen/reboot.c b/grub-core/lib/xen/reboot.c
new file mode 100644
index 0000000..fd7609a
--- /dev/null
+++ b/grub-core/lib/xen/reboot.c
@@ -0,0 +1,32 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/mm.h>
+#include <grub/misc.h>
+#include <grub/kernel.h>
+#include <grub/xen.h>
+
+void
+grub_reboot (void)
+{
+ struct sched_shutdown arg;
+
+ arg.reason = SHUTDOWN_reboot;
+ grub_xen_sched_op (SCHEDOP_shutdown, &arg);
+ for (;;);
+}
diff --git a/grub-core/lib/xen/relocator.c b/grub-core/lib/xen/relocator.c
new file mode 100644
index 0000000..4d0cbca
--- /dev/null
+++ b/grub-core/lib/xen/relocator.c
@@ -0,0 +1,137 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/term.h>
+#include <grub/xen.h>
+
+#include <grub/xen/relocator.h>
+#include <grub/relocator_private.h>
+
+typedef grub_addr_t grub_xen_reg_t;
+
+struct grub_relocator_xen_paging_area {
+ grub_xen_reg_t start;
+ grub_xen_reg_t size;
+} GRUB_PACKED;
+
+extern grub_uint8_t grub_relocator_xen_start;
+extern grub_uint8_t grub_relocator_xen_end;
+extern grub_uint8_t grub_relocator_xen_remap_start;
+extern grub_uint8_t grub_relocator_xen_remap_end;
+extern grub_xen_reg_t grub_relocator_xen_stack;
+extern grub_xen_reg_t grub_relocator_xen_start_info;
+extern grub_xen_reg_t grub_relocator_xen_entry_point;
+extern grub_xen_reg_t grub_relocator_xen_remapper_virt;
+extern grub_xen_reg_t grub_relocator_xen_remapper_virt2;
+extern grub_xen_reg_t grub_relocator_xen_remapper_map;
+extern grub_xen_reg_t grub_relocator_xen_mfn_list;
+extern struct grub_relocator_xen_paging_area
+ grub_relocator_xen_paging_areas[XEN_MAX_MAPPINGS];
+extern grub_xen_reg_t grub_relocator_xen_remap_continue;
+#ifdef __i386__
+extern grub_xen_reg_t grub_relocator_xen_mmu_op_addr;
+extern grub_xen_reg_t grub_relocator_xen_paging_areas_addr;
+extern grub_xen_reg_t grub_relocator_xen_remapper_map_high;
+#endif
+extern mmuext_op_t grub_relocator_xen_mmu_op[3];
+
+#define RELOCATOR_SIZEOF(x) (&grub_relocator##x##_end - &grub_relocator##x##_start)
+
+grub_err_t
+grub_relocator_xen_boot (struct grub_relocator *rel,
+ struct grub_relocator_xen_state state,
+ grub_uint64_t remapper_pfn,
+ grub_addr_t remapper_virt,
+ grub_uint64_t trampoline_pfn,
+ grub_addr_t trampoline_virt)
+{
+ grub_err_t err;
+ void *relst;
+ int i;
+ grub_relocator_chunk_t ch, ch_tramp;
+ grub_xen_mfn_t *mfn_list =
+ (grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list;
+
+ err = grub_relocator_alloc_chunk_addr (rel, &ch, remapper_pfn << 12,
+ RELOCATOR_SIZEOF (_xen_remap));
+ if (err)
+ return err;
+ err = grub_relocator_alloc_chunk_addr (rel, &ch_tramp, trampoline_pfn << 12,
+ RELOCATOR_SIZEOF (_xen));
+ if (err)
+ return err;
+
+ grub_relocator_xen_stack = state.stack;
+ grub_relocator_xen_start_info = state.start_info;
+ grub_relocator_xen_entry_point = state.entry_point;
+ for (i = 0; i < XEN_MAX_MAPPINGS; i++)
+ {
+ grub_relocator_xen_paging_areas[i].start = state.paging_start[i];
+ grub_relocator_xen_paging_areas[i].size = state.paging_size[i];
+ }
+ grub_relocator_xen_remapper_virt = remapper_virt;
+ grub_relocator_xen_remapper_virt2 = remapper_virt;
+ grub_relocator_xen_remap_continue = trampoline_virt;
+
+ grub_relocator_xen_remapper_map = (mfn_list[remapper_pfn] << 12) | 5;
+#ifdef __i386__
+ grub_relocator_xen_remapper_map_high = (mfn_list[remapper_pfn] >> 20);
+ grub_relocator_xen_mmu_op_addr = (char *) &grub_relocator_xen_mmu_op
+ - (char *) &grub_relocator_xen_remap_start + remapper_virt;
+ grub_relocator_xen_paging_areas_addr =
+ (char *) &grub_relocator_xen_paging_areas
+ - (char *) &grub_relocator_xen_remap_start + remapper_virt;
+#endif
+
+ grub_relocator_xen_mfn_list = state.mfn_list;
+
+ grub_memset (grub_relocator_xen_mmu_op, 0,
+ sizeof (grub_relocator_xen_mmu_op));
+#ifdef __i386__
+ grub_relocator_xen_mmu_op[0].cmd = MMUEXT_PIN_L3_TABLE;
+#else
+ grub_relocator_xen_mmu_op[0].cmd = MMUEXT_PIN_L4_TABLE;
+#endif
+ grub_relocator_xen_mmu_op[0].arg1.mfn = mfn_list[state.paging_start[0]];
+ grub_relocator_xen_mmu_op[1].cmd = MMUEXT_NEW_BASEPTR;
+ grub_relocator_xen_mmu_op[1].arg1.mfn = mfn_list[state.paging_start[0]];
+ grub_relocator_xen_mmu_op[2].cmd = MMUEXT_UNPIN_TABLE;
+ grub_relocator_xen_mmu_op[2].arg1.mfn =
+ mfn_list[grub_xen_start_page_addr->pt_base >> 12];
+
+ grub_memmove (get_virtual_current_address (ch),
+ &grub_relocator_xen_remap_start,
+ RELOCATOR_SIZEOF (_xen_remap));
+ grub_memmove (get_virtual_current_address (ch_tramp),
+ &grub_relocator_xen_start, RELOCATOR_SIZEOF (_xen));
+
+ err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
+ &relst, NULL);
+ if (err)
+ return err;
+
+ ((void (*)(void)) relst) ();
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/lib/xzembed/xz.h b/grub-core/lib/xzembed/xz.h
new file mode 100644
index 0000000..f7b32d8
--- /dev/null
+++ b/grub-core/lib/xzembed/xz.h
@@ -0,0 +1,188 @@
+/* xz.h - XZ decompressor */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * This file is based on code from XZ embedded project
+ * http://tukaani.org/xz/embedded.html
+ */
+
+#ifndef XZ_H
+#define XZ_H
+
+#include <config.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <string.h>
+#include <grub/misc.h>
+
+#ifndef GRUB_POSIX_BOOL_DEFINED
+typedef enum { false = 0, true = 1 } bool;
+#endif
+
+/**
+ * enum xz_ret - Return codes
+ * @XZ_OK: Everything is OK so far. More input or more output
+ * space is required to continue.
+ * @XZ_STREAM_END: Operation finished successfully.
+ * @XZ_MEMLIMIT_ERROR: Not enough memory was preallocated at decoder
+ * initialization time.
+ * @XZ_FORMAT_ERROR: File format was not recognized (wrong magic bytes).
+ * @XZ_OPTIONS_ERROR: This implementation doesn't support the requested
+ * compression options. In the decoder this means that
+ * the header CRC32 matches, but the header itself
+ * specifies something that we don't support.
+ * @XZ_DATA_ERROR: Compressed data is corrupt.
+ * @XZ_BUF_ERROR: Cannot make any progress. Details are slightly
+ * different between multi-call and single-call mode;
+ * more information below.
+ *
+ * In multi-call mode, XZ_BUF_ERROR is returned when two consecutive calls
+ * to XZ code cannot consume any input and cannot produce any new output.
+ * This happens when there is no new input available, or the output buffer
+ * is full while at least one output byte is still pending. Assuming your
+ * code is not buggy, you can get this error only when decoding a compressed
+ * stream that is truncated or otherwise corrupt.
+ *
+ * In single-call mode, XZ_BUF_ERROR is returned only when the output buffer
+ * is too small, or the compressed input is corrupt in a way that makes the
+ * decoder produce more output than the caller expected. When it is
+ * (relatively) clear that the compressed input is truncated, XZ_DATA_ERROR
+ * is used instead of XZ_BUF_ERROR.
+ */
+enum xz_ret {
+ XZ_OK,
+ XZ_STREAM_END,
+ XZ_MEMLIMIT_ERROR,
+ XZ_FORMAT_ERROR,
+ XZ_OPTIONS_ERROR,
+ XZ_DATA_ERROR,
+ XZ_BUF_ERROR
+};
+
+/**
+ * struct xz_buf - Passing input and output buffers to XZ code
+ * @in: Beginning of the input buffer. This may be NULL if and only
+ * if in_pos is equal to in_size.
+ * @in_pos: Current position in the input buffer. This must not exceed
+ * in_size.
+ * @in_size: Size of the input buffer
+ * @out: Beginning of the output buffer. This may be NULL if and only
+ * if out_pos is equal to out_size.
+ * @out_pos: Current position in the output buffer. This must not exceed
+ * out_size.
+ * @out_size: Size of the output buffer
+ *
+ * Only the contents of the output buffer from out[out_pos] onward, and
+ * the variables in_pos and out_pos are modified by the XZ code.
+ */
+struct xz_buf {
+ const uint8_t *in;
+ size_t in_pos;
+ size_t in_size;
+
+ uint8_t *out;
+ size_t out_pos;
+ size_t out_size;
+};
+
+/**
+ * struct xz_dec - Opaque type to hold the XZ decoder state
+ */
+struct xz_dec;
+
+/**
+ * xz_dec_init() - Allocate and initialize a XZ decoder state
+ * @dict_max: Maximum size of the LZMA2 dictionary (history buffer) for
+ * multi-call decoding, or special value of zero to indicate
+ * single-call decoding mode.
+ *
+ * If dict_max > 0, the decoder is initialized to work in multi-call mode.
+ * dict_max number of bytes of memory is preallocated for the LZMA2
+ * dictionary. This way there is no risk that xz_dec_run() could run out
+ * of memory, since xz_dec_run() will never allocate any memory. Instead,
+ * if the preallocated dictionary is too small for decoding the given input
+ * stream, xz_dec_run() will return XZ_MEMLIMIT_ERROR. Thus, it is important
+ * to know what kind of data will be decoded to avoid allocating excessive
+ * amount of memory for the dictionary.
+ *
+ * LZMA2 dictionary is always 2^n bytes or 2^n + 2^(n-1) bytes (the latter
+ * sizes are less common in practice). In the kernel, dictionary sizes of
+ * 64 KiB, 128 KiB, 256 KiB, 512 KiB, and 1 MiB are probably the only
+ * reasonable values.
+ *
+ * If dict_max == 0, the decoder is initialized to work in single-call mode.
+ * In single-call mode, xz_dec_run() decodes the whole stream at once. The
+ * caller must provide enough output space or the decoding will fail. The
+ * output space is used as the dictionary buffer, which is why there is
+ * no need to allocate the dictionary as part of the decoder's internal
+ * state.
+ *
+ * Because the output buffer is used as the workspace, streams encoded using
+ * a big dictionary are not a problem in single-call. It is enough that the
+ * output buffer is is big enough to hold the actual uncompressed data; it
+ * can be smaller than the dictionary size stored in the stream headers.
+ *
+ * On success, xz_dec_init() returns a pointer to struct xz_dec, which is
+ * ready to be used with xz_dec_run(). On error, xz_dec_init() returns NULL.
+ */
+struct xz_dec * xz_dec_init(uint32_t dict_max);
+
+/**
+ * xz_dec_run() - Run the XZ decoder
+ * @s: Decoder state allocated using xz_dec_init()
+ * @b: Input and output buffers
+ *
+ * In multi-call mode, this function may return any of the values listed in
+ * enum xz_ret.
+ *
+ * In single-call mode, this function never returns XZ_OK. If an error occurs
+ * in single-call mode (return value is not XZ_STREAM_END), b->in_pos and
+ * b->out_pos are not modified, and the contents of the output buffer from
+ * b->out[b->out_pos] onward are undefined.
+ *
+ * NOTE: In single-call mode, the contents of the output buffer are undefined
+ * also after XZ_BUF_ERROR. This is because with some filter chains, there
+ * may be a second pass over the output buffer, and this pass cannot be
+ * properly done if the output buffer is truncated. Thus, you cannot give
+ * the single-call decoder a too small buffer and then expect to get that
+ * amount valid data from the beginning of the stream. You must use the
+ * multi-call decoder if you don't want to uncompress the whole stream.
+ */
+enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b);
+
+/**
+ * xz_dec_reset() - Reset an already allocated decoder state
+ * @s: Decoder state allocated using xz_dec_init()
+ *
+ * This function can be used to reset the multi-call decoder state without
+ * freeing and reallocating memory with xz_dec_end() and xz_dec_init().
+ *
+ * In single-call mode, xz_dec_reset() is always called in the beginning of
+ * xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in
+ * multi-call mode.
+ */
+void xz_dec_reset(struct xz_dec *s);
+
+/**
+ * xz_dec_end() - Free the memory allocated for the decoder state
+ * @s: Decoder state allocated using xz_dec_init(). If s is NULL,
+ * this function does nothing.
+ */
+void xz_dec_end(struct xz_dec *s);
+
+#endif
diff --git a/grub-core/lib/xzembed/xz_config.h b/grub-core/lib/xzembed/xz_config.h
new file mode 100644
index 0000000..24d570f
--- /dev/null
+++ b/grub-core/lib/xzembed/xz_config.h
@@ -0,0 +1,152 @@
+/* xz_config.h - Private includes and definitions for userspace use */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * This file is based on code from XZ embedded project
+ * http://tukaani.org/xz/embedded.html
+ */
+
+#ifndef XZ_CONFIG_H
+#define XZ_CONFIG_H
+
+/* Enable BCJ filter decoders. */
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+
+#define XZ_DEC_X86
+#define XZ_DEC_POWERPC
+#define XZ_DEC_IA64
+#define XZ_DEC_ARM
+#define XZ_DEC_ARMTHUMB
+#define XZ_DEC_SPARC
+
+#else
+
+#if defined(__i386__) || defined(__x86_64__)
+ #define XZ_DEC_X86
+#endif
+
+#ifdef __powerpc__
+ #define XZ_DEC_POWERPC
+#endif
+
+#ifdef __ia64__
+ #define XZ_DEC_IA64
+#endif
+
+#ifdef __arm__
+ #define XZ_DEC_ARM
+#endif
+
+#ifdef __arm__
+ #define XZ_DEC_ARMTHUMB
+#endif
+
+#ifdef __sparc__
+ #define XZ_DEC_SPARC
+#endif
+#endif
+
+#include "xz.h"
+#include <stdlib.h>
+
+#define kmalloc(size, flags) malloc(size)
+#define kfree(ptr) free(ptr)
+#define vmalloc(size) malloc(size)
+#define vfree(ptr) free(ptr)
+
+#define memeq(a, b, size) (memcmp(a, b, size) == 0)
+#define memzero(buf, size) memset(buf, 0, size)
+
+#define min(x, y) ((x) < (y) ? (x) : (y))
+#define min_t(type, x, y) min(x, y)
+
+/*
+ * Some functions have been marked with __always_inline to keep the
+ * performance reasonable even when the compiler is optimizing for
+ * small code size. You may be able to save a few bytes by #defining
+ * __always_inline to plain inline, but don't complain if the code
+ * becomes slow.
+ *
+ * NOTE: System headers on GNU/Linux may #define this macro already,
+ * so if you want to change it, it you need to #undef it first.
+ */
+#ifndef __always_inline
+# ifdef __GNUC__
+# define __always_inline \
+ inline __attribute__((__always_inline__))
+# else
+# define __always_inline inline
+# endif
+#endif
+
+/*
+ * Some functions are marked to never be inlined to reduce stack usage.
+ * If you don't care about stack usage, you may want to modify this so
+ * that noinline_for_stack is #defined to be empty even when using GCC.
+ * Doing so may save a few bytes in binary size.
+ */
+#ifndef noinline_for_stack
+# ifdef __GNUC__
+# define noinline_for_stack __attribute__((__noinline__))
+# else
+# define noinline_for_stack
+# endif
+#endif
+
+/* Inline functions to access unaligned unsigned 32-bit integers */
+static inline uint32_t get_unaligned_le32(const uint8_t *buf)
+{
+ return (uint32_t)buf[0]
+ | ((uint32_t)buf[1] << 8)
+ | ((uint32_t)buf[2] << 16)
+ | ((uint32_t)buf[3] << 24);
+}
+
+static inline uint32_t get_unaligned_be32(const uint8_t *buf)
+{
+ return (uint32_t)(buf[0] << 24)
+ | ((uint32_t)buf[1] << 16)
+ | ((uint32_t)buf[2] << 8)
+ | (uint32_t)buf[3];
+}
+
+static inline void put_unaligned_le32(uint32_t val, uint8_t *buf)
+{
+ buf[0] = (uint8_t)val;
+ buf[1] = (uint8_t)(val >> 8);
+ buf[2] = (uint8_t)(val >> 16);
+ buf[3] = (uint8_t)(val >> 24);
+}
+
+static inline void put_unaligned_be32(uint32_t val, uint8_t *buf)
+{
+ buf[0] = (uint8_t)(val >> 24);
+ buf[1] = (uint8_t)(val >> 16);
+ buf[2] = (uint8_t)(val >> 8);
+ buf[3] = (uint8_t)val;
+}
+
+/*
+ * Use get_unaligned_le32() also for aligned access for simplicity. On
+ * little endian systems, #define get_le32(ptr) (*(const uint32_t *)(ptr))
+ * could save a few bytes in code size.
+ */
+#define get_le32 get_unaligned_le32
+
+#endif
diff --git a/grub-core/lib/xzembed/xz_dec_bcj.c b/grub-core/lib/xzembed/xz_dec_bcj.c
new file mode 100644
index 0000000..bf6b586
--- /dev/null
+++ b/grub-core/lib/xzembed/xz_dec_bcj.c
@@ -0,0 +1,578 @@
+/* xz_dec_bcj.c - Branch/Call/Jump (BCJ) filter decoders */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * This file is based on code from XZ embedded project
+ * http://tukaani.org/xz/embedded.html
+ */
+
+#include "xz_private.h"
+
+struct xz_dec_bcj {
+ /* Type of the BCJ filter being used */
+ enum {
+ BCJ_X86 = 4, /* x86 or x86-64 */
+ BCJ_POWERPC = 5, /* Big endian only */
+ BCJ_IA64 = 6, /* Big or little endian */
+ BCJ_ARM = 7, /* Little endian only */
+ BCJ_ARMTHUMB = 8, /* Little endian only */
+ BCJ_SPARC = 9 /* Big or little endian */
+ } type;
+
+ /*
+ * Return value of the next filter in the chain. We need to preserve
+ * this information across calls, because we must not call the next
+ * filter anymore once it has returned XZ_STREAM_END.
+ */
+ enum xz_ret ret;
+
+ /* True if we are operating in single-call mode. */
+ bool single_call;
+
+ /*
+ * Absolute position relative to the beginning of the uncompressed
+ * data (in a single .xz Block). We care only about the lowest 32
+ * bits so this doesn't need to be uint64_t even with big files.
+ */
+ uint32_t pos;
+
+ /* x86 filter state */
+ uint32_t x86_prev_mask;
+
+ /* Temporary space to hold the variables from struct xz_buf */
+ uint8_t *out;
+ size_t out_pos;
+ size_t out_size;
+
+ struct {
+ /* Amount of already filtered data in the beginning of buf */
+ size_t filtered;
+
+ /* Total amount of data currently stored in buf */
+ size_t size;
+
+ /*
+ * Buffer to hold a mix of filtered and unfiltered data. This
+ * needs to be big enough to hold Alignment + 2 * Look-ahead:
+ *
+ * Type Alignment Look-ahead
+ * x86 1 4
+ * PowerPC 4 0
+ * IA-64 16 0
+ * ARM 4 0
+ * ARM-Thumb 2 2
+ * SPARC 4 0
+ */
+ uint8_t buf[16];
+ } temp;
+};
+
+#ifdef XZ_DEC_X86
+/*
+ * This is macro used to test the most significant byte of a memory address
+ * in an x86 instruction.
+ */
+#define bcj_x86_test_msbyte(b) ((b) == 0x00 || (b) == 0xFF)
+
+static noinline_for_stack size_t bcj_x86(
+ struct xz_dec_bcj *s, uint8_t *buf, size_t size)
+{
+ static const bool mask_to_allowed_status[8]
+ = { true, true, true, false, true, false, false, false };
+
+ static const uint8_t mask_to_bit_num[8] = { 0, 1, 2, 2, 3, 3, 3, 3 };
+
+ size_t i;
+ size_t prev_pos = (size_t)-1;
+ uint32_t prev_mask = s->x86_prev_mask;
+ uint32_t src;
+ uint32_t dest;
+ uint32_t j;
+ uint8_t b;
+
+ if (size <= 4)
+ return 0;
+
+ size -= 4;
+ for (i = 0; i < size; ++i) {
+ if ((buf[i] & 0xFE) != 0xE8)
+ continue;
+
+ prev_pos = i - prev_pos;
+ if (prev_pos > 3) {
+ prev_mask = 0;
+ } else {
+ prev_mask = (prev_mask << (prev_pos - 1)) & 7;
+ if (prev_mask != 0) {
+ b = buf[i + 4 - mask_to_bit_num[prev_mask]];
+ if (!mask_to_allowed_status[prev_mask]
+ || bcj_x86_test_msbyte(b)) {
+ prev_pos = i;
+ prev_mask = (prev_mask << 1) | 1;
+ continue;
+ }
+ }
+ }
+
+ prev_pos = i;
+
+ if (bcj_x86_test_msbyte(buf[i + 4])) {
+ src = get_unaligned_le32(buf + i + 1);
+ while (true) {
+ dest = src - (s->pos + (uint32_t)i + 5);
+ if (prev_mask == 0)
+ break;
+
+ j = mask_to_bit_num[prev_mask] * 8;
+ b = (uint8_t)(dest >> (24 - j));
+ if (!bcj_x86_test_msbyte(b))
+ break;
+
+ src = dest ^ (((uint32_t)1 << (32 - j)) - 1);
+ }
+
+ dest &= 0x01FFFFFF;
+ dest |= (uint32_t)0 - (dest & 0x01000000);
+ put_unaligned_le32(dest, buf + i + 1);
+ i += 4;
+ } else {
+ prev_mask = (prev_mask << 1) | 1;
+ }
+ }
+
+ prev_pos = i - prev_pos;
+ s->x86_prev_mask = prev_pos > 3 ? 0 : prev_mask << (prev_pos - 1);
+ return i;
+}
+#endif
+
+#ifdef XZ_DEC_POWERPC
+static noinline_for_stack size_t bcj_powerpc(
+ struct xz_dec_bcj *s, uint8_t *buf, size_t size)
+{
+ size_t i;
+ uint32_t instr;
+
+ for (i = 0; i + 3 < size; i += 4) {
+ instr = get_unaligned_be32(buf + i);
+ if ((instr & 0xFC000003) == 0x48000001) {
+ instr &= 0x03FFFFFC;
+ instr -= s->pos + (uint32_t)i;
+ instr &= 0x03FFFFFC;
+ instr |= 0x48000001;
+ put_unaligned_be32(instr, buf + i);
+ }
+ }
+
+ return i;
+}
+#endif
+
+#ifdef XZ_DEC_IA64
+static noinline_for_stack size_t bcj_ia64(
+ struct xz_dec_bcj *s, uint8_t *buf, size_t size)
+{
+ static const uint8_t branch_table[32] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 4, 4, 6, 6, 0, 0, 7, 7,
+ 4, 4, 0, 0, 4, 4, 0, 0
+ };
+
+ /*
+ * The local variables take a little bit stack space, but it's less
+ * than what LZMA2 decoder takes, so it doesn't make sense to reduce
+ * stack usage here without doing that for the LZMA2 decoder too.
+ */
+
+ /* Loop counters */
+ size_t i;
+ size_t j;
+
+ /* Instruction slot (0, 1, or 2) in the 128-bit instruction word */
+ uint32_t slot;
+
+ /* Bitwise offset of the instruction indicated by slot */
+ uint32_t bit_pos;
+
+ /* bit_pos split into byte and bit parts */
+ uint32_t byte_pos;
+ uint32_t bit_res;
+
+ /* Address part of an instruction */
+ uint32_t addr;
+
+ /* Mask used to detect which instructions to convert */
+ uint32_t mask;
+
+ /* 41-bit instruction stored somewhere in the lowest 48 bits */
+ uint64_t instr;
+
+ /* Instruction normalized with bit_res for easier manipulation */
+ uint64_t norm;
+
+ for (i = 0; i + 16 <= size; i += 16) {
+ mask = branch_table[buf[i] & 0x1F];
+ for (slot = 0, bit_pos = 5; slot < 3; ++slot, bit_pos += 41) {
+ if (((mask >> slot) & 1) == 0)
+ continue;
+
+ byte_pos = bit_pos >> 3;
+ bit_res = bit_pos & 7;
+ instr = 0;
+ for (j = 0; j < 6; ++j)
+ instr |= (uint64_t)(buf[i + j + byte_pos])
+ << (8 * j);
+
+ norm = instr >> bit_res;
+
+ if (((norm >> 37) & 0x0F) == 0x05
+ && ((norm >> 9) & 0x07) == 0) {
+ addr = (norm >> 13) & 0x0FFFFF;
+ addr |= ((uint32_t)(norm >> 36) & 1) << 20;
+ addr <<= 4;
+ addr -= s->pos + (uint32_t)i;
+ addr >>= 4;
+
+ norm &= ~((uint64_t)0x8FFFFF << 13);
+ norm |= (uint64_t)(addr & 0x0FFFFF) << 13;
+ norm |= (uint64_t)(addr & 0x100000)
+ << (36 - 20);
+
+ instr &= (1 << bit_res) - 1;
+ instr |= norm << bit_res;
+
+ for (j = 0; j < 6; j++)
+ buf[i + j + byte_pos]
+ = (uint8_t)(instr >> (8 * j));
+ }
+ }
+ }
+
+ return i;
+}
+#endif
+
+#ifdef XZ_DEC_ARM
+static noinline_for_stack size_t bcj_arm(
+ struct xz_dec_bcj *s, uint8_t *buf, size_t size)
+{
+ size_t i;
+ uint32_t addr;
+
+ for (i = 0; i + 4 <= size; i += 4) {
+ if (buf[i + 3] == 0xEB) {
+ addr = (uint32_t)buf[i] | ((uint32_t)buf[i + 1] << 8)
+ | ((uint32_t)buf[i + 2] << 16);
+ addr <<= 2;
+ addr -= s->pos + (uint32_t)i + 8;
+ addr >>= 2;
+ buf[i] = (uint8_t)addr;
+ buf[i + 1] = (uint8_t)(addr >> 8);
+ buf[i + 2] = (uint8_t)(addr >> 16);
+ }
+ }
+
+ return i;
+}
+#endif
+
+#ifdef XZ_DEC_ARMTHUMB
+static noinline_for_stack size_t bcj_armthumb(
+ struct xz_dec_bcj *s, uint8_t *buf, size_t size)
+{
+ size_t i;
+ uint32_t addr;
+
+ for (i = 0; i + 4 <= size; i += 2) {
+ if ((buf[i + 1] & 0xF8) == 0xF0
+ && (buf[i + 3] & 0xF8) == 0xF8) {
+ addr = (((uint32_t)buf[i + 1] & 0x07) << 19)
+ | ((uint32_t)buf[i] << 11)
+ | (((uint32_t)buf[i + 3] & 0x07) << 8)
+ | (uint32_t)buf[i + 2];
+ addr <<= 1;
+ addr -= s->pos + (uint32_t)i + 4;
+ addr >>= 1;
+ buf[i + 1] = (uint8_t)(0xF0 | ((addr >> 19) & 0x07));
+ buf[i] = (uint8_t)(addr >> 11);
+ buf[i + 3] = (uint8_t)(0xF8 | ((addr >> 8) & 0x07));
+ buf[i + 2] = (uint8_t)addr;
+ i += 2;
+ }
+ }
+
+ return i;
+}
+#endif
+
+#ifdef XZ_DEC_SPARC
+static noinline_for_stack size_t bcj_sparc(
+ struct xz_dec_bcj *s, uint8_t *buf, size_t size)
+{
+ size_t i;
+ uint32_t instr;
+
+ for (i = 0; i + 4 <= size; i += 4) {
+ instr = get_unaligned_be32(buf + i);
+ if ((instr >> 22) == 0x100 || (instr >> 22) == 0x1FF) {
+ instr <<= 2;
+ instr -= s->pos + (uint32_t)i;
+ instr >>= 2;
+ instr = ((uint32_t)0x40000000 - (instr & 0x400000))
+ | 0x40000000 | (instr & 0x3FFFFF);
+ put_unaligned_be32(instr, buf + i);
+ }
+ }
+
+ return i;
+}
+#endif
+
+/*
+ * Apply the selected BCJ filter. Update *pos and s->pos to match the amount
+ * of data that got filtered.
+ *
+ * NOTE: This is implemented as a switch statement to avoid using function
+ * pointers, which could be problematic in the kernel boot code, which must
+ * avoid pointers to static data (at least on x86).
+ */
+static void bcj_apply(struct xz_dec_bcj *s,
+ uint8_t *buf, size_t *pos, size_t size)
+{
+ size_t filtered;
+
+ buf += *pos;
+ size -= *pos;
+
+ switch (s->type) {
+#ifdef XZ_DEC_X86
+ case BCJ_X86:
+ filtered = bcj_x86(s, buf, size);
+ break;
+#endif
+#ifdef XZ_DEC_POWERPC
+ case BCJ_POWERPC:
+ filtered = bcj_powerpc(s, buf, size);
+ break;
+#endif
+#ifdef XZ_DEC_IA64
+ case BCJ_IA64:
+ filtered = bcj_ia64(s, buf, size);
+ break;
+#endif
+#ifdef XZ_DEC_ARM
+ case BCJ_ARM:
+ filtered = bcj_arm(s, buf, size);
+ break;
+#endif
+#ifdef XZ_DEC_ARMTHUMB
+ case BCJ_ARMTHUMB:
+ filtered = bcj_armthumb(s, buf, size);
+ break;
+#endif
+#ifdef XZ_DEC_SPARC
+ case BCJ_SPARC:
+ filtered = bcj_sparc(s, buf, size);
+ break;
+#endif
+ default:
+ /* Never reached but silence compiler warnings. */
+ filtered = 0;
+ break;
+ }
+
+ *pos += filtered;
+ s->pos += filtered;
+}
+
+/*
+ * Flush pending filtered data from temp to the output buffer.
+ * Move the remaining mixture of possibly filtered and unfiltered
+ * data to the beginning of temp.
+ */
+static void bcj_flush(struct xz_dec_bcj *s, struct xz_buf *b)
+{
+ size_t copy_size;
+
+ copy_size = min_t(size_t, s->temp.filtered, b->out_size - b->out_pos);
+ memcpy(b->out + b->out_pos, s->temp.buf, copy_size);
+ b->out_pos += copy_size;
+
+ s->temp.filtered -= copy_size;
+ s->temp.size -= copy_size;
+ memmove(s->temp.buf, s->temp.buf + copy_size, s->temp.size);
+}
+
+/*
+ * The BCJ filter functions are primitive in sense that they process the
+ * data in chunks of 1-16 bytes. To hide this issue, this function does
+ * some buffering.
+ */
+enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
+ struct xz_dec_lzma2 *lzma2, struct xz_buf *b)
+{
+ size_t out_start;
+
+ /*
+ * Flush pending already filtered data to the output buffer. Return
+ * immediatelly if we couldn't flush everything, or if the next
+ * filter in the chain had already returned XZ_STREAM_END.
+ */
+ if (s->temp.filtered > 0) {
+ bcj_flush(s, b);
+ if (s->temp.filtered > 0)
+ return XZ_OK;
+
+ if (s->ret == XZ_STREAM_END)
+ return XZ_STREAM_END;
+ }
+
+ /*
+ * If we have more output space than what is currently pending in
+ * temp, copy the unfiltered data from temp to the output buffer
+ * and try to fill the output buffer by decoding more data from the
+ * next filter in the chain. Apply the BCJ filter on the new data
+ * in the output buffer. If everything cannot be filtered, copy it
+ * to temp and rewind the output buffer position accordingly.
+ */
+ if (s->temp.size < b->out_size - b->out_pos) {
+ out_start = b->out_pos;
+ memcpy(b->out + b->out_pos, s->temp.buf, s->temp.size);
+ b->out_pos += s->temp.size;
+
+ s->ret = xz_dec_lzma2_run(lzma2, b);
+ if (s->ret != XZ_STREAM_END
+ && (s->ret != XZ_OK || s->single_call))
+ return s->ret;
+
+ bcj_apply(s, b->out, &out_start, b->out_pos);
+
+ /*
+ * As an exception, if the next filter returned XZ_STREAM_END,
+ * we can do that too, since the last few bytes that remain
+ * unfiltered are meant to remain unfiltered.
+ */
+ if (s->ret == XZ_STREAM_END)
+ return XZ_STREAM_END;
+
+ s->temp.size = b->out_pos - out_start;
+ b->out_pos -= s->temp.size;
+ memcpy(s->temp.buf, b->out + b->out_pos, s->temp.size);
+ }
+
+ /*
+ * If we have unfiltered data in temp, try to fill by decoding more
+ * data from the next filter. Apply the BCJ filter on temp. Then we
+ * hopefully can fill the actual output buffer by copying filtered
+ * data from temp. A mix of filtered and unfiltered data may be left
+ * in temp; it will be taken care on the next call to this function.
+ */
+ if (s->temp.size > 0) {
+ /* Make b->out{,_pos,_size} temporarily point to s->temp. */
+ s->out = b->out;
+ s->out_pos = b->out_pos;
+ s->out_size = b->out_size;
+ b->out = s->temp.buf;
+ b->out_pos = s->temp.size;
+ b->out_size = sizeof(s->temp.buf);
+
+ s->ret = xz_dec_lzma2_run(lzma2, b);
+
+ s->temp.size = b->out_pos;
+ b->out = s->out;
+ b->out_pos = s->out_pos;
+ b->out_size = s->out_size;
+
+ if (s->ret != XZ_OK && s->ret != XZ_STREAM_END)
+ return s->ret;
+
+ bcj_apply(s, s->temp.buf, &s->temp.filtered, s->temp.size);
+
+ /*
+ * If the next filter returned XZ_STREAM_END, we mark that
+ * everything is filtered, since the last unfiltered bytes
+ * of the stream are meant to be left as is.
+ */
+ if (s->ret == XZ_STREAM_END)
+ s->temp.filtered = s->temp.size;
+
+ bcj_flush(s, b);
+ if (s->temp.filtered > 0)
+ return XZ_OK;
+ }
+
+ return s->ret;
+}
+
+#ifdef GRUB_EMBED_DECOMPRESSOR
+struct xz_dec_bcj bcj;
+#endif
+
+struct xz_dec_bcj * xz_dec_bcj_create(bool single_call)
+{
+ struct xz_dec_bcj *s;
+#ifdef GRUB_EMBED_DECOMPRESSOR
+ s = &bcj;
+#else
+ s = kmalloc(sizeof(*s), GFP_KERNEL);
+#endif
+ if (s != NULL)
+ s->single_call = single_call;
+
+ return s;
+}
+
+enum xz_ret xz_dec_bcj_reset(
+ struct xz_dec_bcj *s, uint8_t id)
+{
+ switch (id) {
+#ifdef XZ_DEC_X86
+ case BCJ_X86:
+#endif
+#ifdef XZ_DEC_POWERPC
+ case BCJ_POWERPC:
+#endif
+#ifdef XZ_DEC_IA64
+ case BCJ_IA64:
+#endif
+#ifdef XZ_DEC_ARM
+ case BCJ_ARM:
+#endif
+#ifdef XZ_DEC_ARMTHUMB
+ case BCJ_ARMTHUMB:
+#endif
+#ifdef XZ_DEC_SPARC
+ case BCJ_SPARC:
+#endif
+ break;
+
+ default:
+ /* Unsupported Filter ID */
+ return XZ_OPTIONS_ERROR;
+ }
+
+ s->type = id;
+ s->ret = XZ_OK;
+ s->pos = 0;
+ s->x86_prev_mask = 0;
+ s->temp.filtered = 0;
+ s->temp.size = 0;
+
+ return XZ_OK;
+}
diff --git a/grub-core/lib/xzembed/xz_dec_lzma2.c b/grub-core/lib/xzembed/xz_dec_lzma2.c
new file mode 100644
index 0000000..af7b770
--- /dev/null
+++ b/grub-core/lib/xzembed/xz_dec_lzma2.c
@@ -0,0 +1,1188 @@
+/* xz_dec_lzma2.c - LZMA2 decoder */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * This file is based on code from XZ embedded project
+ * http://tukaani.org/xz/embedded.html
+ */
+
+#include "xz_private.h"
+#include "xz_lzma2.h"
+
+#pragma GCC diagnostic warning "-Wattributes"
+
+/*
+ * Range decoder initialization eats the first five bytes of each LZMA chunk.
+ */
+#define RC_INIT_BYTES 5
+
+/*
+ * Minimum number of usable input buffer to safely decode one LZMA symbol.
+ * The worst case is that we decode 22 bits using probabilities and 26
+ * direct bits. This may decode at maximum of 20 bytes of input. However,
+ * lzma_main() does an extra normalization before returning, thus we
+ * need to put 21 here.
+ */
+#define LZMA_IN_REQUIRED 21
+
+/*
+ * Dictionary (history buffer)
+ *
+ * These are always true:
+ * start <= pos <= full <= end
+ * pos <= limit <= end
+ *
+ * In multi-call mode, also these are true:
+ * end == size
+ * size <= allocated
+ *
+ * Most of these variables are size_t to support single-call mode,
+ * in which the dictionary variables address the actual output
+ * buffer directly.
+ */
+struct dictionary {
+ /* Beginning of the history buffer */
+ uint8_t *buf;
+
+ /* Old position in buf (before decoding more data) */
+ size_t start;
+
+ /* Position in buf */
+ size_t pos;
+
+ /*
+ * How full dictionary is. This is used to detect corrupt input that
+ * would read beyond the beginning of the uncompressed stream.
+ */
+ size_t full;
+
+ /* Write limit; we don't write to buf[limit] or later bytes. */
+ size_t limit;
+
+ /*
+ * End of the dictionary buffer. In multi-call mode, this is
+ * the same as the dictionary size. In single-call mode, this
+ * indicates the size of the output buffer.
+ */
+ size_t end;
+
+ /*
+ * Size of the dictionary as specified in Block Header. This is used
+ * together with "full" to detect corrupt input that would make us
+ * read beyond the beginning of the uncompressed stream.
+ */
+ uint32_t size;
+
+ /*
+ * Amount of memory allocated for the dictionary. A special
+ * value of zero indicates that we are in single-call mode,
+ * where the output buffer works as the dictionary.
+ */
+ uint32_t allocated;
+};
+
+/* Range decoder */
+struct rc_dec {
+ uint32_t range;
+ uint32_t code;
+
+ /*
+ * Number of initializing bytes remaining to be read
+ * by rc_read_init().
+ */
+ uint32_t init_bytes_left;
+
+ /*
+ * Buffer from which we read our input. It can be either
+ * temp.buf or the caller-provided input buffer.
+ */
+ const uint8_t *in;
+ size_t in_pos;
+ size_t in_limit;
+};
+
+/* Probabilities for a length decoder. */
+struct lzma_len_dec {
+ /* Probability of match length being at least 10 */
+ uint16_t choice;
+
+ /* Probability of match length being at least 18 */
+ uint16_t choice2;
+
+ /* Probabilities for match lengths 2-9 */
+ uint16_t low[POS_STATES_MAX][LEN_LOW_SYMBOLS];
+
+ /* Probabilities for match lengths 10-17 */
+ uint16_t mid[POS_STATES_MAX][LEN_MID_SYMBOLS];
+
+ /* Probabilities for match lengths 18-273 */
+ uint16_t high[LEN_HIGH_SYMBOLS];
+};
+
+struct lzma_dec {
+ /*
+ * LZMA properties or related bit masks (number of literal
+ * context bits, a mask dervied from the number of literal
+ * position bits, and a mask dervied from the number
+ * position bits)
+ */
+ uint32_t lc;
+ uint32_t literal_pos_mask; /* (1 << lp) - 1 */
+ uint32_t pos_mask; /* (1 << pb) - 1 */
+
+ /* Types of the most recently seen LZMA symbols */
+ enum lzma_state state;
+
+ /* Distances of latest four matches */
+ uint32_t rep0;
+ uint32_t rep1;
+ uint32_t rep2;
+ uint32_t rep3;
+
+ /*
+ * Length of a match. This is updated so that dict_repeat can
+ * be called again to finish repeating the whole match.
+ */
+ uint32_t len;
+
+ /* If 1, it's a match. Otherwise it's a single 8-bit literal. */
+ uint16_t is_match[STATES][POS_STATES_MAX];
+
+ /* If 1, it's a repeated match. The distance is one of rep0 .. rep3. */
+ uint16_t is_rep[STATES];
+
+ /*
+ * If 0, distance of a repeated match is rep0.
+ * Otherwise check is_rep1.
+ */
+ uint16_t is_rep0[STATES];
+
+ /*
+ * If 0, distance of a repeated match is rep1.
+ * Otherwise check is_rep2.
+ */
+ uint16_t is_rep1[STATES];
+
+ /* If 0, distance of a repeated match is rep2. Otherwise it is rep3. */
+ uint16_t is_rep2[STATES];
+
+ /*
+ * If 1, the repeated match has length of one byte. Otherwise
+ * the length is decoded from rep_len_decoder.
+ */
+ uint16_t is_rep0_long[STATES][POS_STATES_MAX];
+
+ /*
+ * Probability tree for the highest two bits of the match
+ * distance. There is a separate probability tree for match
+ * lengths of 2 (i.e. MATCH_LEN_MIN), 3, 4, and [5, 273].
+ */
+ uint16_t dist_slot[DIST_STATES][DIST_SLOTS];
+
+ /*
+ * Probility trees for additional bits for match distance
+ * when the distance is in the range [4, 127].
+ */
+ uint16_t dist_special[FULL_DISTANCES - DIST_MODEL_END];
+
+ /*
+ * Probability tree for the lowest four bits of a match
+ * distance that is equal to or greater than 128.
+ */
+ uint16_t dist_align[ALIGN_SIZE];
+
+ /* Length of a normal match */
+ struct lzma_len_dec match_len_dec;
+
+ /* Length of a repeated match */
+ struct lzma_len_dec rep_len_dec;
+
+ /* Probabilities of literals */
+ uint16_t literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE];
+};
+
+struct xz_dec_lzma2 {
+ /* LZMA2 */
+ struct {
+ /* Position in xz_dec_lzma2_run(). */
+ enum lzma2_seq {
+ SEQ_CONTROL,
+ SEQ_UNCOMPRESSED_1,
+ SEQ_UNCOMPRESSED_2,
+ SEQ_COMPRESSED_0,
+ SEQ_COMPRESSED_1,
+ SEQ_PROPERTIES,
+ SEQ_LZMA_PREPARE,
+ SEQ_LZMA_RUN,
+ SEQ_COPY
+ } sequence;
+
+ /*
+ * Next position after decoding the compressed size of
+ * the chunk.
+ */
+ enum lzma2_seq next_sequence;
+
+ /* Uncompressed size of LZMA chunk (2 MiB at maximum) */
+ uint32_t uncompressed;
+
+ /*
+ * Compressed size of LZMA chunk or compressed/uncompressed
+ * size of uncompressed chunk (64 KiB at maximum)
+ */
+ uint32_t compressed;
+
+ /*
+ * True if dictionary reset is needed. This is false before
+ * the first chunk (LZMA or uncompressed).
+ */
+ bool need_dict_reset;
+
+ /*
+ * True if new LZMA properties are needed. This is false
+ * before the first LZMA chunk.
+ */
+ bool need_props;
+ } lzma2;
+
+ /*
+ * Temporary buffer which holds small number of input bytes between
+ * decoder calls. See lzma2_lzma() for details.
+ */
+ struct {
+ uint32_t size;
+ uint8_t buf[3 * LZMA_IN_REQUIRED];
+ } temp;
+
+ struct dictionary dict;
+ struct rc_dec rc;
+ struct lzma_dec lzma;
+};
+
+/**************
+ * Dictionary *
+ **************/
+
+/*
+ * Reset the dictionary state. When in single-call mode, set up the beginning
+ * of the dictionary to point to the actual output buffer.
+ */
+static void dict_reset(struct dictionary *dict, struct xz_buf *b)
+{
+ if (dict->allocated == 0) {
+ dict->buf = b->out + b->out_pos;
+ dict->end = b->out_size - b->out_pos;
+ }
+ dict->start = 0;
+ dict->pos = 0;
+ dict->limit = 0;
+ dict->full = 0;
+}
+
+/* Set dictionary write limit */
+static void dict_limit(struct dictionary *dict, size_t out_max)
+{
+ if (dict->end - dict->pos <= out_max)
+ dict->limit = dict->end;
+ else
+ dict->limit = dict->pos + out_max;
+}
+
+/* Return true if at least one byte can be written into the dictionary. */
+static inline bool dict_has_space(const struct dictionary *dict)
+{
+ return dict->pos < dict->limit;
+}
+
+/*
+ * Get a byte from the dictionary at the given distance. The distance is
+ * assumed to valid, or as a special case, zero when the dictionary is
+ * still empty. This special case is needed for single-call decoding to
+ * avoid writing a '\0' to the end of the destination buffer.
+ */
+static inline uint32_t dict_get(
+ const struct dictionary *dict, uint32_t dist)
+{
+ size_t offset = dict->pos - dist - 1;
+
+ if (dist >= dict->pos)
+ offset += dict->end;
+
+ return dict->full > 0 ? dict->buf[offset] : 0;
+}
+
+/*
+ * Put one byte into the dictionary. It is assumed that there is space for it.
+ */
+static inline void dict_put(struct dictionary *dict, uint8_t b)
+{
+ dict->buf[dict->pos++] = b;
+
+ if (dict->full < dict->pos)
+ dict->full = dict->pos;
+}
+
+/*
+ * Repeat given number of bytes from the given distance. If the distance is
+ * invalid, false is returned. On success, true is returned and *len is
+ * updated to indicate how many bytes were left to be repeated.
+ */
+static bool dict_repeat(
+ struct dictionary *dict, uint32_t *len, uint32_t dist)
+{
+ size_t back;
+ uint32_t left;
+
+ if (dist >= dict->full || dist >= dict->size)
+ return false;
+
+ left = min_t(size_t, dict->limit - dict->pos, *len);
+ *len -= left;
+
+ back = dict->pos - dist - 1;
+ if (dist >= dict->pos)
+ back += dict->end;
+
+ do {
+ dict->buf[dict->pos++] = dict->buf[back++];
+ if (back == dict->end)
+ back = 0;
+ } while (--left > 0);
+
+ if (dict->full < dict->pos)
+ dict->full = dict->pos;
+
+ return true;
+}
+
+/* Copy uncompressed data as is from input to dictionary and output buffers. */
+static void dict_uncompressed(
+ struct dictionary *dict, struct xz_buf *b, uint32_t *left)
+{
+ size_t copy_size;
+
+ while (*left > 0 && b->in_pos < b->in_size
+ && b->out_pos < b->out_size) {
+ copy_size = min(b->in_size - b->in_pos,
+ b->out_size - b->out_pos);
+ if (copy_size > dict->end - dict->pos)
+ copy_size = dict->end - dict->pos;
+ if (copy_size > *left)
+ copy_size = *left;
+
+ *left -= copy_size;
+
+ memcpy(dict->buf + dict->pos, b->in + b->in_pos, copy_size);
+ dict->pos += copy_size;
+
+ if (dict->full < dict->pos)
+ dict->full = dict->pos;
+
+ if (dict->allocated != 0) {
+ if (dict->pos == dict->end)
+ dict->pos = 0;
+
+ memcpy(b->out + b->out_pos, b->in + b->in_pos,
+ copy_size);
+ }
+
+ dict->start = dict->pos;
+
+ b->out_pos += copy_size;
+ b->in_pos += copy_size;
+
+ }
+}
+
+/*
+ * Flush pending data from dictionary to b->out. It is assumed that there is
+ * enough space in b->out. This is guaranteed because caller uses dict_limit()
+ * before decoding data into the dictionary.
+ */
+static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b)
+{
+ size_t copy_size = dict->pos - dict->start;
+
+ if (dict->allocated != 0) {
+ if (dict->pos == dict->end)
+ dict->pos = 0;
+
+ memcpy(b->out + b->out_pos, dict->buf + dict->start,
+ copy_size);
+ }
+
+ dict->start = dict->pos;
+ b->out_pos += copy_size;
+ return copy_size;
+}
+
+/*****************
+ * Range decoder *
+ *****************/
+
+/* Reset the range decoder. */
+static void rc_reset(struct rc_dec *rc)
+{
+ rc->range = (uint32_t)-1;
+ rc->code = 0;
+ rc->init_bytes_left = RC_INIT_BYTES;
+}
+
+/*
+ * Read the first five initial bytes into rc->code if they haven't been
+ * read already. (Yes, the first byte gets completely ignored.)
+ */
+static bool rc_read_init(struct rc_dec *rc, struct xz_buf *b)
+{
+ while (rc->init_bytes_left > 0) {
+ if (b->in_pos == b->in_size)
+ return false;
+
+ rc->code = (rc->code << 8) + b->in[b->in_pos++];
+ --rc->init_bytes_left;
+ }
+
+ return true;
+}
+
+/* Return true if there may not be enough input for the next decoding loop. */
+static inline bool rc_limit_exceeded(const struct rc_dec *rc)
+{
+ return rc->in_pos > rc->in_limit;
+}
+
+/*
+ * Return true if it is possible (from point of view of range decoder) that
+ * we have reached the end of the LZMA chunk.
+ */
+static inline bool rc_is_finished(const struct rc_dec *rc)
+{
+ return rc->code == 0;
+}
+
+/* Read the next input byte if needed. */
+static __always_inline void rc_normalize(struct rc_dec *rc)
+{
+ if (rc->range < RC_TOP_VALUE) {
+ rc->range <<= RC_SHIFT_BITS;
+ rc->code = (rc->code << RC_SHIFT_BITS) + rc->in[rc->in_pos++];
+ }
+}
+
+/*
+ * Decode one bit. In some versions, this function has been splitted in three
+ * functions so that the compiler is supposed to be able to more easily avoid
+ * an extra branch. In this particular version of the LZMA decoder, this
+ * doesn't seem to be a good idea (tested with GCC 3.3.6, 3.4.6, and 4.3.3
+ * on x86). Using a non-splitted version results in nicer looking code too.
+ *
+ * NOTE: This must return an int. Do not make it return a bool or the speed
+ * of the code generated by GCC 3.x decreases 10-15 %. (GCC 4.3 doesn't care,
+ * and it generates 10-20 % faster code than GCC 3.x from this file anyway.)
+ */
+static __always_inline int rc_bit(struct rc_dec *rc, uint16_t *prob)
+{
+ uint32_t bound;
+ int bit;
+
+ rc_normalize(rc);
+ bound = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) * *prob;
+ if (rc->code < bound) {
+ rc->range = bound;
+ *prob += (RC_BIT_MODEL_TOTAL - *prob) >> RC_MOVE_BITS;
+ bit = 0;
+ } else {
+ rc->range -= bound;
+ rc->code -= bound;
+ *prob -= *prob >> RC_MOVE_BITS;
+ bit = 1;
+ }
+
+ return bit;
+}
+
+/* Decode a bittree starting from the most significant bit. */
+static __always_inline uint32_t rc_bittree(
+ struct rc_dec *rc, uint16_t *probs, uint32_t limit)
+{
+ uint32_t symbol = 1;
+
+ do {
+ if (rc_bit(rc, &probs[symbol]))
+ symbol = (symbol << 1) + 1;
+ else
+ symbol <<= 1;
+ } while (symbol < limit);
+
+ return symbol;
+}
+
+/* Decode a bittree starting from the least significant bit. */
+static __always_inline void rc_bittree_reverse(struct rc_dec *rc,
+ uint16_t *probs, uint32_t *dest, uint32_t limit)
+{
+ uint32_t symbol = 1;
+ uint32_t i = 0;
+
+ do {
+ if (rc_bit(rc, &probs[symbol])) {
+ symbol = (symbol << 1) + 1;
+ *dest += 1 << i;
+ } else {
+ symbol <<= 1;
+ }
+ } while (++i < limit);
+}
+
+/* Decode direct bits (fixed fifty-fifty probability) */
+static inline void rc_direct(
+ struct rc_dec *rc, uint32_t *dest, uint32_t limit)
+{
+ uint32_t mask;
+
+ do {
+ rc_normalize(rc);
+ rc->range >>= 1;
+ rc->code -= rc->range;
+ mask = (uint32_t)0 - (rc->code >> 31);
+ rc->code += rc->range & mask;
+ *dest = (*dest << 1) + (mask + 1);
+ } while (--limit > 0);
+}
+
+/********
+ * LZMA *
+ ********/
+
+/* Get pointer to literal coder probability array. */
+static uint16_t * lzma_literal_probs(struct xz_dec_lzma2 *s)
+{
+ uint32_t prev_byte = dict_get(&s->dict, 0);
+ uint32_t low = prev_byte >> (8 - s->lzma.lc);
+ uint32_t high = (s->dict.pos & s->lzma.literal_pos_mask) << s->lzma.lc;
+ return s->lzma.literal[low + high];
+}
+
+/* Decode a literal (one 8-bit byte) */
+static void lzma_literal(struct xz_dec_lzma2 *s)
+{
+ uint16_t *probs;
+ uint32_t symbol;
+ uint32_t match_byte;
+ uint32_t match_bit;
+ uint32_t offset;
+ uint32_t i;
+
+ probs = lzma_literal_probs(s);
+
+ if (lzma_state_is_literal(s->lzma.state)) {
+ symbol = rc_bittree(&s->rc, probs, 0x100);
+ } else {
+ symbol = 1;
+ match_byte = dict_get(&s->dict, s->lzma.rep0) << 1;
+ offset = 0x100;
+
+ do {
+ match_bit = match_byte & offset;
+ match_byte <<= 1;
+ i = offset + match_bit + symbol;
+
+ if (rc_bit(&s->rc, &probs[i])) {
+ symbol = (symbol << 1) + 1;
+ offset &= match_bit;
+ } else {
+ symbol <<= 1;
+ offset &= ~match_bit;
+ }
+ } while (symbol < 0x100);
+ }
+
+ dict_put(&s->dict, (uint8_t)symbol);
+ lzma_state_literal(&s->lzma.state);
+}
+
+/* Decode the length of the match into s->lzma.len. */
+static void lzma_len(struct xz_dec_lzma2 *s, struct lzma_len_dec *l,
+ uint32_t pos_state)
+{
+ uint16_t *probs;
+ uint32_t limit;
+
+ if (!rc_bit(&s->rc, &l->choice)) {
+ probs = l->low[pos_state];
+ limit = LEN_LOW_SYMBOLS;
+ s->lzma.len = MATCH_LEN_MIN;
+ } else {
+ if (!rc_bit(&s->rc, &l->choice2)) {
+ probs = l->mid[pos_state];
+ limit = LEN_MID_SYMBOLS;
+ s->lzma.len = MATCH_LEN_MIN + LEN_LOW_SYMBOLS;
+ } else {
+ probs = l->high;
+ limit = LEN_HIGH_SYMBOLS;
+ s->lzma.len = MATCH_LEN_MIN + LEN_LOW_SYMBOLS
+ + LEN_MID_SYMBOLS;
+ }
+ }
+
+ s->lzma.len += rc_bittree(&s->rc, probs, limit) - limit;
+}
+
+/* Decode a match. The distance will be stored in s->lzma.rep0. */
+static void lzma_match(struct xz_dec_lzma2 *s, uint32_t pos_state)
+{
+ uint16_t *probs;
+ uint32_t dist_slot;
+ uint32_t limit;
+
+ lzma_state_match(&s->lzma.state);
+
+ s->lzma.rep3 = s->lzma.rep2;
+ s->lzma.rep2 = s->lzma.rep1;
+ s->lzma.rep1 = s->lzma.rep0;
+
+ lzma_len(s, &s->lzma.match_len_dec, pos_state);
+
+ probs = s->lzma.dist_slot[lzma_get_dist_state(s->lzma.len)];
+ dist_slot = rc_bittree(&s->rc, probs, DIST_SLOTS) - DIST_SLOTS;
+
+ if (dist_slot < DIST_MODEL_START) {
+ s->lzma.rep0 = dist_slot;
+ } else {
+ limit = (dist_slot >> 1) - 1;
+ s->lzma.rep0 = 2 + (dist_slot & 1);
+
+ if (dist_slot < DIST_MODEL_END) {
+ s->lzma.rep0 <<= limit;
+ probs = s->lzma.dist_special + s->lzma.rep0
+ - dist_slot - 1;
+ rc_bittree_reverse(&s->rc, probs,
+ &s->lzma.rep0, limit);
+ } else {
+ rc_direct(&s->rc, &s->lzma.rep0, limit - ALIGN_BITS);
+ s->lzma.rep0 <<= ALIGN_BITS;
+ rc_bittree_reverse(&s->rc, s->lzma.dist_align,
+ &s->lzma.rep0, ALIGN_BITS);
+ }
+ }
+}
+
+/*
+ * Decode a repeated match. The distance is one of the four most recently
+ * seen matches. The distance will be stored in s->lzma.rep0.
+ */
+static void lzma_rep_match(struct xz_dec_lzma2 *s, uint32_t pos_state)
+{
+ uint32_t tmp;
+
+ if (!rc_bit(&s->rc, &s->lzma.is_rep0[s->lzma.state])) {
+ if (!rc_bit(&s->rc, &s->lzma.is_rep0_long[
+ s->lzma.state][pos_state])) {
+ lzma_state_short_rep(&s->lzma.state);
+ s->lzma.len = 1;
+ return;
+ }
+ } else {
+ if (!rc_bit(&s->rc, &s->lzma.is_rep1[s->lzma.state])) {
+ tmp = s->lzma.rep1;
+ } else {
+ if (!rc_bit(&s->rc, &s->lzma.is_rep2[s->lzma.state])) {
+ tmp = s->lzma.rep2;
+ } else {
+ tmp = s->lzma.rep3;
+ s->lzma.rep3 = s->lzma.rep2;
+ }
+
+ s->lzma.rep2 = s->lzma.rep1;
+ }
+
+ s->lzma.rep1 = s->lzma.rep0;
+ s->lzma.rep0 = tmp;
+ }
+
+ lzma_state_long_rep(&s->lzma.state);
+ lzma_len(s, &s->lzma.rep_len_dec, pos_state);
+}
+
+/* LZMA decoder core */
+static bool lzma_main(struct xz_dec_lzma2 *s)
+{
+ uint32_t pos_state;
+
+ /*
+ * If the dictionary was reached during the previous call, try to
+ * finish the possibly pending repeat in the dictionary.
+ */
+ if (dict_has_space(&s->dict) && s->lzma.len > 0)
+ dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0);
+
+ /*
+ * Decode more LZMA symbols. One iteration may consume up to
+ * LZMA_IN_REQUIRED - 1 bytes.
+ */
+ while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) {
+ pos_state = s->dict.pos & s->lzma.pos_mask;
+
+ if (!rc_bit(&s->rc, &s->lzma.is_match[
+ s->lzma.state][pos_state])) {
+ lzma_literal(s);
+ } else {
+ if (rc_bit(&s->rc, &s->lzma.is_rep[s->lzma.state]))
+ lzma_rep_match(s, pos_state);
+ else
+ lzma_match(s, pos_state);
+
+ if (!dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0))
+ return false;
+ }
+ }
+
+ /*
+ * Having the range decoder always normalized when we are outside
+ * this function makes it easier to correctly handle end of the chunk.
+ */
+ rc_normalize(&s->rc);
+
+ return true;
+}
+
+/*
+ * Reset the LZMA decoder and range decoder state. Dictionary is nore reset
+ * here, because LZMA state may be reset without resetting the dictionary.
+ */
+static void lzma_reset(struct xz_dec_lzma2 *s)
+{
+ uint16_t *probs;
+ size_t i;
+
+ s->lzma.state = STATE_LIT_LIT;
+ s->lzma.rep0 = 0;
+ s->lzma.rep1 = 0;
+ s->lzma.rep2 = 0;
+ s->lzma.rep3 = 0;
+
+ /*
+ * All probabilities are initialized to the same value. This hack
+ * makes the code smaller by avoiding a separate loop for each
+ * probability array.
+ *
+ * This could be optimized so that only that part of literal
+ * probabilities that are actually required. In the common case
+ * we would write 12 KiB less.
+ */
+ probs = s->lzma.is_match[0];
+ for (i = 0; i < PROBS_TOTAL; ++i)
+ probs[i] = RC_BIT_MODEL_TOTAL / 2;
+
+ rc_reset(&s->rc);
+}
+
+/*
+ * Decode and validate LZMA properties (lc/lp/pb) and calculate the bit masks
+ * from the decoded lp and pb values. On success, the LZMA decoder state is
+ * reset and true is returned.
+ */
+static bool lzma_props(struct xz_dec_lzma2 *s, uint8_t props)
+{
+ if (props > (4 * 5 + 4) * 9 + 8)
+ return false;
+
+ s->lzma.pos_mask = 0;
+ while (props >= 9 * 5) {
+ props -= 9 * 5;
+ ++s->lzma.pos_mask;
+ }
+
+ s->lzma.pos_mask = (1 << s->lzma.pos_mask) - 1;
+
+ s->lzma.literal_pos_mask = 0;
+ while (props >= 9) {
+ props -= 9;
+ ++s->lzma.literal_pos_mask;
+ }
+
+ s->lzma.lc = props;
+
+ if (s->lzma.lc + s->lzma.literal_pos_mask > 4)
+ return false;
+
+ s->lzma.literal_pos_mask = (1 << s->lzma.literal_pos_mask) - 1;
+
+ lzma_reset(s);
+
+ return true;
+}
+
+/*********
+ * LZMA2 *
+ *********/
+
+/*
+ * The LZMA decoder assumes that if the input limit (s->rc.in_limit) hasn't
+ * been exceeded, it is safe to read up to LZMA_IN_REQUIRED bytes. This
+ * wrapper function takes care of making the LZMA decoder's assumption safe.
+ *
+ * As long as there is plenty of input left to be decoded in the current LZMA
+ * chunk, we decode directly from the caller-supplied input buffer until
+ * there's LZMA_IN_REQUIRED bytes left. Those remaining bytes are copied into
+ * s->temp.buf, which (hopefully) gets filled on the next call to this
+ * function. We decode a few bytes from the temporary buffer so that we can
+ * continue decoding from the caller-supplied input buffer again.
+ */
+static bool lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b)
+{
+ size_t in_avail;
+ uint32_t tmp;
+
+ in_avail = b->in_size - b->in_pos;
+ if (s->temp.size > 0 || s->lzma2.compressed == 0) {
+ tmp = 2 * LZMA_IN_REQUIRED - s->temp.size;
+ if (tmp > s->lzma2.compressed - s->temp.size)
+ tmp = s->lzma2.compressed - s->temp.size;
+ if (tmp > in_avail)
+ tmp = in_avail;
+
+ memcpy(s->temp.buf + s->temp.size, b->in + b->in_pos, tmp);
+
+ if (s->temp.size + tmp == s->lzma2.compressed) {
+ memzero(s->temp.buf + s->temp.size + tmp,
+ sizeof(s->temp.buf)
+ - s->temp.size - tmp);
+ s->rc.in_limit = s->temp.size + tmp;
+ } else if (s->temp.size + tmp < LZMA_IN_REQUIRED) {
+ s->temp.size += tmp;
+ b->in_pos += tmp;
+ return true;
+ } else {
+ s->rc.in_limit = s->temp.size + tmp - LZMA_IN_REQUIRED;
+ }
+
+ s->rc.in = s->temp.buf;
+ s->rc.in_pos = 0;
+
+ if (!lzma_main(s) || s->rc.in_pos > s->temp.size + tmp)
+ return false;
+
+ s->lzma2.compressed -= s->rc.in_pos;
+
+ if (s->rc.in_pos < s->temp.size) {
+ s->temp.size -= s->rc.in_pos;
+ memmove(s->temp.buf, s->temp.buf + s->rc.in_pos,
+ s->temp.size);
+ return true;
+ }
+
+ b->in_pos += s->rc.in_pos - s->temp.size;
+ s->temp.size = 0;
+ }
+
+ in_avail = b->in_size - b->in_pos;
+ if (in_avail >= LZMA_IN_REQUIRED) {
+ s->rc.in = b->in;
+ s->rc.in_pos = b->in_pos;
+
+ if (in_avail >= s->lzma2.compressed + LZMA_IN_REQUIRED)
+ s->rc.in_limit = b->in_pos + s->lzma2.compressed;
+ else
+ s->rc.in_limit = b->in_size - LZMA_IN_REQUIRED;
+
+ if (!lzma_main(s))
+ return false;
+
+ in_avail = s->rc.in_pos - b->in_pos;
+ if (in_avail > s->lzma2.compressed)
+ return false;
+
+ s->lzma2.compressed -= in_avail;
+ b->in_pos = s->rc.in_pos;
+ }
+
+ in_avail = b->in_size - b->in_pos;
+ if (in_avail < LZMA_IN_REQUIRED) {
+ if (in_avail > s->lzma2.compressed)
+ in_avail = s->lzma2.compressed;
+
+ memcpy(s->temp.buf, b->in + b->in_pos, in_avail);
+ s->temp.size = in_avail;
+ b->in_pos += in_avail;
+ }
+
+ return true;
+}
+
+/*
+ * Take care of the LZMA2 control layer, and forward the job of actual LZMA
+ * decoding or copying of uncompressed chunks to other functions.
+ */
+enum xz_ret xz_dec_lzma2_run(
+ struct xz_dec_lzma2 *s, struct xz_buf *b)
+{
+ uint32_t tmp;
+
+ while (b->in_pos < b->in_size || s->lzma2.sequence == SEQ_LZMA_RUN) {
+ switch (s->lzma2.sequence) {
+ case SEQ_CONTROL:
+ /*
+ * LZMA2 control byte
+ *
+ * Exact values:
+ * 0x00 End marker
+ * 0x01 Dictionary reset followed by
+ * an uncompressed chunk
+ * 0x02 Uncompressed chunk (no dictionary reset)
+ *
+ * Highest three bits (s->control & 0xE0):
+ * 0xE0 Dictionary reset, new properties and state
+ * reset, followed by LZMA compressed chunk
+ * 0xC0 New properties and state reset, followed
+ * by LZMA compressed chunk (no dictionary
+ * reset)
+ * 0xA0 State reset using old properties,
+ * followed by LZMA compressed chunk (no
+ * dictionary reset)
+ * 0x80 LZMA chunk (no dictionary or state reset)
+ *
+ * For LZMA compressed chunks, the lowest five bits
+ * (s->control & 1F) are the highest bits of the
+ * uncompressed size (bits 16-20).
+ *
+ * A new LZMA2 stream must begin with a dictionary
+ * reset. The first LZMA chunk must set new
+ * properties and reset the LZMA state.
+ *
+ * Values that don't match anything described above
+ * are invalid and we return XZ_DATA_ERROR.
+ */
+ tmp = b->in[b->in_pos++];
+
+ if (tmp >= 0xE0 || tmp == 0x01) {
+ s->lzma2.need_props = true;
+ s->lzma2.need_dict_reset = false;
+ dict_reset(&s->dict, b);
+ } else if (s->lzma2.need_dict_reset) {
+ return XZ_DATA_ERROR;
+ }
+
+ if (tmp >= 0x80) {
+ s->lzma2.uncompressed = (tmp & 0x1F) << 16;
+ s->lzma2.sequence = SEQ_UNCOMPRESSED_1;
+
+ if (tmp >= 0xC0) {
+ /*
+ * When there are new properties,
+ * state reset is done at
+ * SEQ_PROPERTIES.
+ */
+ s->lzma2.need_props = false;
+ s->lzma2.next_sequence
+ = SEQ_PROPERTIES;
+
+ } else if (s->lzma2.need_props) {
+ return XZ_DATA_ERROR;
+
+ } else {
+ s->lzma2.next_sequence
+ = SEQ_LZMA_PREPARE;
+ if (tmp >= 0xA0)
+ lzma_reset(s);
+ }
+ } else {
+ if (tmp == 0x00)
+ return XZ_STREAM_END;
+
+ if (tmp > 0x02)
+ return XZ_DATA_ERROR;
+
+ s->lzma2.sequence = SEQ_COMPRESSED_0;
+ s->lzma2.next_sequence = SEQ_COPY;
+ }
+
+ break;
+
+ case SEQ_UNCOMPRESSED_1:
+ s->lzma2.uncompressed
+ += (uint32_t)b->in[b->in_pos++] << 8;
+ s->lzma2.sequence = SEQ_UNCOMPRESSED_2;
+ break;
+
+ case SEQ_UNCOMPRESSED_2:
+ s->lzma2.uncompressed
+ += (uint32_t)b->in[b->in_pos++] + 1;
+ s->lzma2.sequence = SEQ_COMPRESSED_0;
+ break;
+
+ case SEQ_COMPRESSED_0:
+ s->lzma2.compressed
+ = (uint32_t)b->in[b->in_pos++] << 8;
+ s->lzma2.sequence = SEQ_COMPRESSED_1;
+ break;
+
+ case SEQ_COMPRESSED_1:
+ s->lzma2.compressed
+ += (uint32_t)b->in[b->in_pos++] + 1;
+ s->lzma2.sequence = s->lzma2.next_sequence;
+ break;
+
+ case SEQ_PROPERTIES:
+ if (!lzma_props(s, b->in[b->in_pos++]))
+ return XZ_DATA_ERROR;
+
+ s->lzma2.sequence = SEQ_LZMA_PREPARE;
+
+ /* Fall through */
+
+ case SEQ_LZMA_PREPARE:
+ if (s->lzma2.compressed < RC_INIT_BYTES)
+ return XZ_DATA_ERROR;
+
+ if (!rc_read_init(&s->rc, b))
+ return XZ_OK;
+
+ s->lzma2.compressed -= RC_INIT_BYTES;
+ s->lzma2.sequence = SEQ_LZMA_RUN;
+
+ /* Fall through */
+
+ case SEQ_LZMA_RUN:
+ /*
+ * Set dictionary limit to indicate how much we want
+ * to be encoded at maximum. Decode new data into the
+ * dictionary. Flush the new data from dictionary to
+ * b->out. Check if we finished decoding this chunk.
+ * In case the dictionary got full but we didn't fill
+ * the output buffer yet, we may run this loop
+ * multiple times without changing s->lzma2.sequence.
+ */
+ dict_limit(&s->dict, min_t(size_t,
+ b->out_size - b->out_pos,
+ s->lzma2.uncompressed));
+ if (!lzma2_lzma(s, b))
+ return XZ_DATA_ERROR;
+
+ s->lzma2.uncompressed -= dict_flush(&s->dict, b);
+
+ if (s->lzma2.uncompressed == 0) {
+ if (s->lzma2.compressed > 0 || s->lzma.len > 0
+ || !rc_is_finished(&s->rc))
+ return XZ_DATA_ERROR;
+
+ rc_reset(&s->rc);
+ s->lzma2.sequence = SEQ_CONTROL;
+
+ } else if (b->out_pos == b->out_size
+ || (b->in_pos == b->in_size
+ && s->temp.size
+ < s->lzma2.compressed)) {
+ return XZ_OK;
+ }
+
+ break;
+
+ case SEQ_COPY:
+ dict_uncompressed(&s->dict, b, &s->lzma2.compressed);
+ if (s->lzma2.compressed > 0)
+ return XZ_OK;
+
+ s->lzma2.sequence = SEQ_CONTROL;
+ break;
+ }
+ }
+
+ return XZ_OK;
+}
+
+#ifdef GRUB_EMBED_DECOMPRESSOR
+#include <grub/decompressor.h>
+static struct xz_dec_lzma2 lzma2;
+#endif
+
+struct xz_dec_lzma2 * xz_dec_lzma2_create(uint32_t dict_max)
+{
+ struct xz_dec_lzma2 *s;
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ /* Maximum supported dictionary by this implementation is 3 GiB. */
+ if (dict_max > ((uint32_t)3 << 30))
+ return NULL;
+
+ s = kmalloc(sizeof(*s), GFP_KERNEL);
+ if (s == NULL)
+ return NULL;
+
+ if (dict_max > 0) {
+ s->dict.buf = vmalloc(dict_max);
+ if (s->dict.buf == NULL) {
+ kfree(s);
+ return NULL;
+ }
+ }
+
+#else
+ s = &lzma2;
+ s->dict.buf = grub_decompressor_scratch;
+#endif
+
+ s->dict.allocated = dict_max;
+
+ return s;
+}
+
+enum xz_ret xz_dec_lzma2_reset(
+ struct xz_dec_lzma2 *s, uint8_t props)
+{
+ /* This limits dictionary size to 3 GiB (39) to keep parsing simpler. */
+ if (props > ( min (DICT_BIT_SIZE,39)) )
+ return XZ_OPTIONS_ERROR;
+
+ s->dict.size = 2 + (props & 1);
+ s->dict.size <<= (props >> 1) + 11;
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->dict.allocated > 0 && s->dict.allocated < s->dict.size)
+ {
+ /* enlarge dictionary buffer */
+ uint8_t * newdict = realloc(s->dict.buf,s->dict.size);
+
+ if (! newdict)
+ return XZ_MEMLIMIT_ERROR;
+
+ s->dict.buf = newdict;
+ s->dict.allocated = s->dict.size;
+ }
+#endif
+ s->dict.end = s->dict.size;
+
+ s->lzma.len = 0;
+
+ s->lzma2.sequence = SEQ_CONTROL;
+ s->lzma2.need_dict_reset = true;
+
+ s->temp.size = 0;
+
+ return XZ_OK;
+}
+
+void xz_dec_lzma2_end(struct xz_dec_lzma2 *s __attribute__ ((unused)))
+{
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->dict.allocated > 0)
+ vfree(s->dict.buf);
+
+ kfree(s);
+#endif
+}
diff --git a/grub-core/lib/xzembed/xz_dec_stream.c b/grub-core/lib/xzembed/xz_dec_stream.c
new file mode 100644
index 0000000..a29751e
--- /dev/null
+++ b/grub-core/lib/xzembed/xz_dec_stream.c
@@ -0,0 +1,1042 @@
+/* xz_dec_stream.c - .xz Stream decoder */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * This file is based on code from XZ embedded project
+ * http://tukaani.org/xz/embedded.html
+ */
+
+#include "xz_config.h"
+#include "xz_private.h"
+#include "xz_stream.h"
+
+#include <grub/crypto.h>
+
+/* Hash used to validate the Index field */
+struct xz_dec_hash {
+ vli_type unpadded;
+ vli_type uncompressed;
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ uint64_t *hash_context;
+#endif
+};
+
+/* Enough for up to 512 bits. */
+#define MAX_HASH_SIZE 64
+
+struct xz_dec {
+ /* Position in dec_main() */
+ enum {
+ SEQ_STREAM_HEADER,
+ SEQ_BLOCK_START,
+ SEQ_BLOCK_HEADER,
+ SEQ_BLOCK_UNCOMPRESS,
+ SEQ_BLOCK_PADDING,
+ SEQ_BLOCK_CHECK,
+ SEQ_INDEX,
+ SEQ_INDEX_PADDING,
+ SEQ_INDEX_CRC32,
+ SEQ_STREAM_FOOTER
+ } sequence;
+
+ /* Position in variable-length integers and Check fields */
+ uint32_t pos;
+
+ /* Variable-length integer decoded by dec_vli() */
+ vli_type vli;
+
+ /* Saved in_pos and out_pos */
+ size_t in_start;
+ size_t out_start;
+
+ /* CRC32 value in Block or Index */
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ uint8_t hash_value[MAX_HASH_SIZE]; /* need for crc32_validate*/
+#endif
+ int have_hash_value;
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ uint64_t *hash_context;
+ uint64_t *crc32_context;
+#endif
+
+ /* Hash function calculated from uncompressed data */
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ const gcry_md_spec_t *hash;
+ const gcry_md_spec_t *crc32;
+ grub_uint8_t hash_id;
+#endif
+ grub_size_t hash_size;
+
+ /* True if we are operating in single-call mode. */
+ bool single_call;
+
+ /*
+ * True if the next call to xz_dec_run() is allowed to return
+ * XZ_BUF_ERROR.
+ */
+ bool allow_buf_error;
+
+ /* Information stored in Block Header */
+ struct {
+ /*
+ * Value stored in the Compressed Size field, or
+ * VLI_UNKNOWN if Compressed Size is not present.
+ */
+ vli_type compressed;
+
+ /*
+ * Value stored in the Uncompressed Size field, or
+ * VLI_UNKNOWN if Uncompressed Size is not present.
+ */
+ vli_type uncompressed;
+
+ /* Size of the Block Header field */
+ uint32_t size;
+ } block_header;
+
+ /* Information collected when decoding Blocks */
+ struct {
+ /* Observed compressed size of the current Block */
+ vli_type compressed;
+
+ /* Observed uncompressed size of the current Block */
+ vli_type uncompressed;
+
+ /* Number of Blocks decoded so far */
+ vli_type count;
+
+ /*
+ * Hash calculated from the Block sizes. This is used to
+ * validate the Index field.
+ */
+ struct xz_dec_hash hash;
+ } block;
+
+ /* Variables needed when verifying the Index field */
+ struct {
+ /* Position in dec_index() */
+ enum {
+ SEQ_INDEX_COUNT,
+ SEQ_INDEX_UNPADDED,
+ SEQ_INDEX_UNCOMPRESSED
+ } sequence;
+
+ /* Size of the Index in bytes */
+ vli_type size;
+
+ /* Number of Records (matches block.count in valid files) */
+ vli_type count;
+
+ /*
+ * Hash calculated from the Records (matches block.hash in
+ * valid files).
+ */
+ struct xz_dec_hash hash;
+ } index;
+
+ /*
+ * Temporary buffer needed to hold Stream Header, Block Header,
+ * and Stream Footer. The Block Header is the biggest (1 KiB)
+ * so we reserve space according to that. buf[] has to be aligned
+ * to a multiple of four bytes; the size_t variables before it
+ * should guarantee this.
+ */
+ struct {
+ size_t pos;
+ size_t size;
+ uint8_t buf[1024];
+ } temp;
+
+ struct xz_dec_lzma2 *lzma2;
+
+#ifdef XZ_DEC_BCJ
+ struct xz_dec_bcj *bcj;
+ bool bcj_active;
+#endif
+};
+
+/*
+ * Fill s->temp by copying data starting from b->in[b->in_pos]. Caller
+ * must have set s->temp.pos to indicate how much data we are supposed
+ * to copy into s->temp.buf. Return true once s->temp.pos has reached
+ * s->temp.size.
+ */
+static bool fill_temp(struct xz_dec *s, struct xz_buf *b)
+{
+ size_t copy_size = min_t(size_t,
+ b->in_size - b->in_pos, s->temp.size - s->temp.pos);
+
+ memcpy(s->temp.buf + s->temp.pos, b->in + b->in_pos, copy_size);
+ b->in_pos += copy_size;
+ s->temp.pos += copy_size;
+
+ if (s->temp.pos == s->temp.size) {
+ s->temp.pos = 0;
+ return true;
+ }
+
+ return false;
+}
+
+/* Decode a variable-length integer (little-endian base-128 encoding) */
+static enum xz_ret dec_vli(struct xz_dec *s,
+ const uint8_t *in, size_t *in_pos, size_t in_size)
+{
+ uint8_t b;
+
+ if (s->pos == 0)
+ s->vli = 0;
+
+ while (*in_pos < in_size) {
+ b = in[*in_pos];
+ ++*in_pos;
+
+ s->vli |= (vli_type)(b & 0x7F) << s->pos;
+
+ if ((b & 0x80) == 0) {
+ /* Don't allow non-minimal encodings. */
+ if (b == 0 && s->pos != 0)
+ return XZ_DATA_ERROR;
+
+ s->pos = 0;
+ return XZ_STREAM_END;
+ }
+
+ s->pos += 7;
+ if (s->pos == 7 * VLI_BYTES_MAX)
+ return XZ_DATA_ERROR;
+ }
+
+ return XZ_OK;
+}
+
+/*
+ * Decode the Compressed Data field from a Block. Update and validate
+ * the observed compressed and uncompressed sizes of the Block so that
+ * they don't exceed the values possibly stored in the Block Header
+ * (validation assumes that no integer overflow occurs, since vli_type
+ * is normally uint64_t). Update the CRC32 if presence of the CRC32
+ * field was indicated in Stream Header.
+ *
+ * Once the decoding is finished, validate that the observed sizes match
+ * the sizes possibly stored in the Block Header. Update the hash and
+ * Block count, which are later used to validate the Index field.
+ */
+static enum xz_ret dec_block(struct xz_dec *s, struct xz_buf *b)
+{
+ enum xz_ret ret;
+
+ s->in_start = b->in_pos;
+ s->out_start = b->out_pos;
+
+#ifdef XZ_DEC_BCJ
+ if (s->bcj_active)
+ ret = xz_dec_bcj_run(s->bcj, s->lzma2, b);
+ else
+#endif
+ ret = xz_dec_lzma2_run(s->lzma2, b);
+
+ s->block.compressed += b->in_pos - s->in_start;
+ s->block.uncompressed += b->out_pos - s->out_start;
+
+ /*
+ * There is no need to separately check for VLI_UNKNOWN, since
+ * the observed sizes are always smaller than VLI_UNKNOWN.
+ */
+ if (s->block.compressed > s->block_header.compressed
+ || s->block.uncompressed
+ > s->block_header.uncompressed)
+ return XZ_DATA_ERROR;
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->hash)
+ s->hash->write(s->hash_context,b->out + s->out_start,
+ b->out_pos - s->out_start);
+ if (s->crc32)
+ s->crc32->write(s->crc32_context,b->out + s->out_start,
+ b->out_pos - s->out_start);
+#endif
+
+ if (ret == XZ_STREAM_END) {
+ if (s->block_header.compressed != VLI_UNKNOWN
+ && s->block_header.compressed
+ != s->block.compressed)
+ return XZ_DATA_ERROR;
+
+ if (s->block_header.uncompressed != VLI_UNKNOWN
+ && s->block_header.uncompressed
+ != s->block.uncompressed)
+ return XZ_DATA_ERROR;
+
+ s->block.hash.unpadded += s->block_header.size
+ + s->block.compressed;
+ s->block.hash.unpadded += s->hash_size;
+
+ s->block.hash.uncompressed += s->block.uncompressed;
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->hash)
+ s->hash->write(s->block.hash.hash_context,
+ (const uint8_t *)&s->block.hash,
+ 2 * sizeof(vli_type));
+#endif
+
+ ++s->block.count;
+ }
+
+ return ret;
+}
+
+/* Update the Index size and the CRC32 value. */
+static void index_update(struct xz_dec *s, const struct xz_buf *b)
+{
+ size_t in_used = b->in_pos - s->in_start;
+ s->index.size += in_used;
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->hash)
+ s->hash->write(s->hash_context,b->in + s->in_start, in_used);
+ if (s->crc32)
+ s->crc32->write(s->crc32_context,b->in + s->in_start, in_used);
+#endif
+}
+
+/*
+ * Decode the Number of Records, Unpadded Size, and Uncompressed Size
+ * fields from the Index field. That is, Index Padding and CRC32 are not
+ * decoded by this function.
+ *
+ * This can return XZ_OK (more input needed), XZ_STREAM_END (everything
+ * successfully decoded), or XZ_DATA_ERROR (input is corrupt).
+ */
+static enum xz_ret dec_index(struct xz_dec *s, struct xz_buf *b)
+{
+ enum xz_ret ret;
+
+ do {
+ ret = dec_vli(s, b->in, &b->in_pos, b->in_size);
+ if (ret != XZ_STREAM_END) {
+ index_update(s, b);
+ return ret;
+ }
+
+ switch (s->index.sequence) {
+ case SEQ_INDEX_COUNT:
+ s->index.count = s->vli;
+
+ /*
+ * Validate that the Number of Records field
+ * indicates the same number of Records as
+ * there were Blocks in the Stream.
+ */
+ if (s->index.count != s->block.count)
+ return XZ_DATA_ERROR;
+
+ s->index.sequence = SEQ_INDEX_UNPADDED;
+ break;
+
+ case SEQ_INDEX_UNPADDED:
+ s->index.hash.unpadded += s->vli;
+ s->index.sequence = SEQ_INDEX_UNCOMPRESSED;
+ break;
+
+ case SEQ_INDEX_UNCOMPRESSED:
+ s->index.hash.uncompressed += s->vli;
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->hash)
+ s->hash->write(s->index.hash.hash_context,
+ (const uint8_t *)&s->index.hash, 2 * sizeof(vli_type));
+#endif
+
+ --s->index.count;
+ s->index.sequence = SEQ_INDEX_UNPADDED;
+ break;
+ }
+ } while (s->index.count > 0);
+
+ return XZ_STREAM_END;
+}
+
+/*
+ * Validate that the next four input bytes match the value of s->crc32.
+ * s->pos must be zero when starting to validate the first byte.
+ */
+static enum xz_ret hash_validate(struct xz_dec *s, struct xz_buf *b,
+ int crc32)
+{
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ const gcry_md_spec_t *hash = crc32 ? s->crc32 : s->hash;
+ void *hash_context = crc32 ? s->crc32_context
+ : s->hash_context;
+ if(!s->have_hash_value && hash
+ && sizeof (s->hash_value) >= hash->mdlen)
+ {
+ hash->final(hash_context);
+ grub_memcpy (s->hash_value, hash->read(hash_context),
+ hash->mdlen);
+ s->have_hash_value = 1;
+ if (s->hash_id == 1 || crc32)
+ {
+ grub_uint8_t t;
+ t = s->hash_value[0];
+ s->hash_value[0] = s->hash_value[3];
+ s->hash_value[3] = t;
+ t = s->hash_value[1];
+ s->hash_value[1] = s->hash_value[2];
+ s->hash_value[2] = t;
+ }
+ }
+#endif
+
+ if (b->in_pos == b->in_size)
+ return XZ_OK;
+
+ if (!crc32 && s->hash_size == 0)
+ s->pos += 8;
+
+ while (s->pos < (crc32 ? 32 : s->hash_size * 8)) {
+ if (b->in_pos == b->in_size)
+ return XZ_OK;
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (hash && s->hash_value[s->pos / 8] != b->in[b->in_pos])
+ return XZ_DATA_ERROR;
+#endif
+ b->in_pos++;
+
+ s->pos += 8;
+
+ }
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->hash)
+ s->hash->init(s->hash_context);
+ if (s->crc32)
+ s->crc32->init(s->crc32_context);
+#endif
+ s->have_hash_value = 0;
+ s->pos = 0;
+
+ return XZ_STREAM_END;
+}
+
+static const struct
+{
+ const char *name;
+ grub_size_t size;
+} hashes[] = {
+ [0x01] = { "CRC32", 4},
+ [0x04] = { "CRC64", 8},
+ [0x0A] = { "SHA256", 32},
+};
+
+/* Decode the Stream Header field (the first 12 bytes of the .xz Stream). */
+static enum xz_ret dec_stream_header(struct xz_dec *s)
+{
+ if (! memeq(s->temp.buf, HEADER_MAGIC, HEADER_MAGIC_SIZE))
+ return XZ_FORMAT_ERROR;
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ s->crc32 = grub_crypto_lookup_md_by_name ("CRC32");
+
+ if (s->crc32)
+ {
+ uint8_t readhash[4];
+ uint8_t computed_hash[4];
+
+ if(4 != s->crc32->mdlen)
+ return XZ_DATA_ERROR;
+
+ grub_crypto_hash (s->crc32, computed_hash,
+ s->temp.buf + HEADER_MAGIC_SIZE, 2);
+
+ readhash[0] = s->temp.buf[HEADER_MAGIC_SIZE + 5];
+ readhash[1] = s->temp.buf[HEADER_MAGIC_SIZE + 4];
+ readhash[2] = s->temp.buf[HEADER_MAGIC_SIZE + 3];
+ readhash[3] = s->temp.buf[HEADER_MAGIC_SIZE + 2];
+
+ if (grub_memcmp (readhash, computed_hash,
+ s->crc32->mdlen) != 0)
+ return XZ_DATA_ERROR;
+ }
+#endif
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ /*
+ * Decode the Stream Flags field.
+ */
+ if (s->temp.buf[HEADER_MAGIC_SIZE] != 0
+ || s->temp.buf[HEADER_MAGIC_SIZE + 1] >= ARRAY_SIZE (hashes)
+ || (hashes[s->temp.buf[HEADER_MAGIC_SIZE + 1]].name == 0
+ && s->temp.buf[HEADER_MAGIC_SIZE + 1] != 0))
+ return XZ_OPTIONS_ERROR;
+
+ s->hash_id = s->temp.buf[HEADER_MAGIC_SIZE + 1];
+
+ if (s->crc32)
+ {
+ s->crc32_context = kmalloc(s->crc32->contextsize, GFP_KERNEL);
+ if (s->crc32_context == NULL)
+ return XZ_MEMLIMIT_ERROR;
+ s->crc32->init(s->crc32_context);
+ }
+#endif
+
+ if (s->temp.buf[HEADER_MAGIC_SIZE + 1])
+ {
+ s->hash_size = hashes[s->temp.buf[HEADER_MAGIC_SIZE + 1]].size;
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ s->hash = grub_crypto_lookup_md_by_name (hashes[s->temp.buf[HEADER_MAGIC_SIZE + 1]].name);
+ if (s->hash)
+ {
+ if (s->hash->mdlen != s->hash_size)
+ return XZ_OPTIONS_ERROR;
+ s->hash_context = kmalloc(s->hash->contextsize, GFP_KERNEL);
+ if (s->hash_context == NULL)
+ {
+ kfree(s->crc32_context);
+ return XZ_MEMLIMIT_ERROR;
+ }
+
+ s->index.hash.hash_context = kmalloc(s->hash->contextsize,
+ GFP_KERNEL);
+ if (s->index.hash.hash_context == NULL)
+ {
+ kfree(s->hash_context);
+ kfree(s->crc32_context);
+ return XZ_MEMLIMIT_ERROR;
+ }
+
+ s->block.hash.hash_context = kmalloc(s->hash->contextsize, GFP_KERNEL);
+ if (s->block.hash.hash_context == NULL)
+ {
+ kfree(s->index.hash.hash_context);
+ kfree(s->hash_context);
+ kfree(s->crc32_context);
+ return XZ_MEMLIMIT_ERROR;
+ }
+
+ s->hash->init(s->hash_context);
+ s->hash->init(s->index.hash.hash_context);
+ s->hash->init(s->block.hash.hash_context);
+ }
+#endif
+ }
+ else
+ {
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ s->hash = 0;
+#endif
+ s->hash_size = 0;
+ }
+
+ s->have_hash_value = 0;
+
+
+ return XZ_OK;
+}
+
+/* Decode the Stream Footer field (the last 12 bytes of the .xz Stream) */
+static enum xz_ret dec_stream_footer(struct xz_dec *s)
+{
+ if (! memeq(s->temp.buf + 10, FOOTER_MAGIC, FOOTER_MAGIC_SIZE))
+ return XZ_DATA_ERROR;
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->crc32)
+ {
+ uint8_t readhash[4];
+ uint8_t computed_hash[4];
+
+ if (4 != s->crc32->mdlen)
+ return XZ_DATA_ERROR;
+
+ grub_crypto_hash (s->crc32, computed_hash,
+ s->temp.buf + 4, 6);
+
+ readhash[0] = s->temp.buf[3];
+ readhash[1] = s->temp.buf[2];
+ readhash[2] = s->temp.buf[1];
+ readhash[3] = s->temp.buf[0];
+
+ if(grub_memcmp (readhash, computed_hash,
+ s->crc32->mdlen) != 0)
+ return XZ_DATA_ERROR;
+ }
+#endif
+
+
+ /*
+ * Validate Backward Size. Note that we never added the size of the
+ * Index CRC32 field to s->index.size, thus we use s->index.size / 4
+ * instead of s->index.size / 4 - 1.
+ */
+ if ((s->index.size >> 2) != get_le32(s->temp.buf + 4))
+ return XZ_DATA_ERROR;
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->temp.buf[8] != 0 || s->temp.buf[9] != s->hash_id)
+ return XZ_DATA_ERROR;
+#endif
+
+ /*
+ * Use XZ_STREAM_END instead of XZ_OK to be more convenient
+ * for the caller.
+ */
+ return XZ_STREAM_END;
+}
+
+/* Decode the Block Header and initialize the filter chain. */
+static enum xz_ret dec_block_header(struct xz_dec *s)
+{
+ enum xz_ret ret;
+
+ /*
+ * Validate the CRC32. We know that the temp buffer is at least
+ * eight bytes so this is safe.
+ */
+ s->temp.size -= 4;
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->crc32)
+ {
+ uint8_t readhash[4], computed_hash[4];
+
+ if(4 != s->crc32->mdlen)
+ return XZ_DATA_ERROR;
+
+ grub_crypto_hash (s->crc32, computed_hash,
+ s->temp.buf, s->temp.size);
+
+ readhash[3] = s->temp.buf[s->temp.size];
+ readhash[2] = s->temp.buf[s->temp.size + 1];
+ readhash[1] = s->temp.buf[s->temp.size + 2];
+ readhash[0] = s->temp.buf[s->temp.size + 3];
+
+ if(grub_memcmp (readhash, computed_hash,
+ s->crc32->mdlen) != 0)
+ return XZ_DATA_ERROR;
+ }
+#endif
+
+ s->temp.pos = 2;
+
+ /*
+ * Catch unsupported Block Flags. We support only one or two filters
+ * in the chain, so we catch that with the same test.
+ */
+#ifdef XZ_DEC_BCJ
+ if (s->temp.buf[1] & 0x3E)
+#else
+ if (s->temp.buf[1] & 0x3F)
+#endif
+ return XZ_OPTIONS_ERROR;
+
+ /* Compressed Size */
+ if (s->temp.buf[1] & 0x40) {
+ if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size)
+ != XZ_STREAM_END)
+ return XZ_DATA_ERROR;
+
+ s->block_header.compressed = s->vli;
+ } else {
+ s->block_header.compressed = VLI_UNKNOWN;
+ }
+
+ /* Uncompressed Size */
+ if (s->temp.buf[1] & 0x80) {
+ if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size)
+ != XZ_STREAM_END)
+ return XZ_DATA_ERROR;
+
+ s->block_header.uncompressed = s->vli;
+ } else {
+ s->block_header.uncompressed = VLI_UNKNOWN;
+ }
+
+#ifdef XZ_DEC_BCJ
+ /* If there are two filters, the first one must be a BCJ filter. */
+ s->bcj_active = s->temp.buf[1] & 0x01;
+ if (s->bcj_active) {
+ if (s->temp.size - s->temp.pos < 2)
+ return XZ_OPTIONS_ERROR;
+
+ ret = xz_dec_bcj_reset(s->bcj, s->temp.buf[s->temp.pos++]);
+ if (ret != XZ_OK)
+ return ret;
+
+ /*
+ * We don't support custom start offset,
+ * so Size of Properties must be zero.
+ */
+ if (s->temp.buf[s->temp.pos++] != 0x00)
+ return XZ_OPTIONS_ERROR;
+ }
+#endif
+
+ /* Valid Filter Flags always take at least two bytes. */
+ if (s->temp.size - s->temp.pos < 2)
+ return XZ_DATA_ERROR;
+
+ /* Filter ID = LZMA2 */
+ if (s->temp.buf[s->temp.pos++] != 0x21)
+ return XZ_OPTIONS_ERROR;
+
+ /* Size of Properties = 1-byte Filter Properties */
+ if (s->temp.buf[s->temp.pos++] != 0x01)
+ return XZ_OPTIONS_ERROR;
+
+ /* Filter Properties contains LZMA2 dictionary size. */
+ if (s->temp.size - s->temp.pos < 1)
+ return XZ_DATA_ERROR;
+
+ ret = xz_dec_lzma2_reset(s->lzma2, s->temp.buf[s->temp.pos++]);
+ if (ret != XZ_OK)
+ return ret;
+
+ /* The rest must be Header Padding. */
+ while (s->temp.pos < s->temp.size)
+ if (s->temp.buf[s->temp.pos++] != 0x00)
+ return XZ_OPTIONS_ERROR;
+
+ s->temp.pos = 0;
+ s->block.compressed = 0;
+ s->block.uncompressed = 0;
+
+ return XZ_OK;
+}
+
+static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
+{
+ enum xz_ret ret;
+
+ /*
+ * Store the start position for the case when we are in the middle
+ * of the Index field.
+ */
+ s->in_start = b->in_pos;
+
+ while (true) {
+ switch (s->sequence) {
+ case SEQ_STREAM_HEADER:
+ /*
+ * Stream Header is copied to s->temp, and then
+ * decoded from there. This way if the caller
+ * gives us only little input at a time, we can
+ * still keep the Stream Header decoding code
+ * simple. Similar approach is used in many places
+ * in this file.
+ */
+ if (!fill_temp(s, b))
+ return XZ_OK;
+
+ ret = dec_stream_header(s);
+ if (ret != XZ_OK)
+ return ret;
+
+ s->sequence = SEQ_BLOCK_START;
+
+ /* FALLTHROUGH */
+ case SEQ_BLOCK_START:
+ /* We need one byte of input to continue. */
+ if (b->in_pos == b->in_size)
+ return XZ_OK;
+
+ /* See if this is the beginning of the Index field. */
+ if (b->in[b->in_pos] == 0) {
+ s->in_start = b->in_pos++;
+ s->sequence = SEQ_INDEX;
+ break;
+ }
+
+ /*
+ * Calculate the size of the Block Header and
+ * prepare to decode it.
+ */
+ s->block_header.size
+ = ((uint32_t)b->in[b->in_pos] + 1) * 4;
+
+ s->temp.size = s->block_header.size;
+ s->temp.pos = 0;
+ s->sequence = SEQ_BLOCK_HEADER;
+
+ /* FALLTHROUGH */
+ case SEQ_BLOCK_HEADER:
+ if (!fill_temp(s, b))
+ return XZ_OK;
+
+ ret = dec_block_header(s);
+ if (ret != XZ_OK)
+ return ret;
+
+ s->sequence = SEQ_BLOCK_UNCOMPRESS;
+
+ /* FALLTHROUGH */
+ case SEQ_BLOCK_UNCOMPRESS:
+ ret = dec_block(s, b);
+ if (ret != XZ_STREAM_END)
+ return ret;
+
+ s->sequence = SEQ_BLOCK_PADDING;
+
+ case SEQ_BLOCK_PADDING:
+ /*
+ * Size of Compressed Data + Block Padding
+ * must be a multiple of four. We don't need
+ * s->block.compressed for anything else
+ * anymore, so we use it here to test the size
+ * of the Block Padding field.
+ */
+ while (s->block.compressed & 3) {
+ if (b->in_pos == b->in_size)
+ return XZ_OK;
+
+ if (b->in[b->in_pos++] != 0)
+ return XZ_DATA_ERROR;
+
+ ++s->block.compressed;
+ }
+
+ s->sequence = SEQ_BLOCK_CHECK;
+
+ /* FALLTHROUGH */
+ case SEQ_BLOCK_CHECK:
+ ret = hash_validate(s, b, 0);
+ if (ret != XZ_STREAM_END)
+ return ret;
+
+ s->sequence = SEQ_BLOCK_START;
+ break;
+
+ case SEQ_INDEX:
+ ret = dec_index(s, b);
+ if (ret != XZ_STREAM_END)
+ return ret;
+
+ s->sequence = SEQ_INDEX_PADDING;
+
+ case SEQ_INDEX_PADDING:
+ while ((s->index.size + (b->in_pos - s->in_start))
+ & 3) {
+ if (b->in_pos == b->in_size) {
+ index_update(s, b);
+ return XZ_OK;
+ }
+
+ if (b->in[b->in_pos++] != 0)
+ return XZ_DATA_ERROR;
+ }
+
+ /* Finish the CRC32 value and Index size. */
+ index_update(s, b);
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->hash)
+ {
+ /* Compare the hashes to validate the Index field. */
+ s->hash->final(s->block.hash.hash_context);
+ s->hash->final(s->index.hash.hash_context);
+
+ if (s->block.hash.unpadded != s->index.hash.unpadded
+ || s->block.hash.uncompressed != s->index.hash.uncompressed
+ || grub_memcmp (s->hash->read(s->block.hash.hash_context),
+ s->hash->read(s->index.hash.hash_context),
+ s->hash->mdlen) != 0)
+ return XZ_DATA_ERROR;
+ }
+#endif
+
+ s->sequence = SEQ_INDEX_CRC32;
+
+ /* FALLTHROUGH */
+ case SEQ_INDEX_CRC32:
+ ret = hash_validate(s, b, 1);
+ if (ret != XZ_STREAM_END)
+ return ret;
+
+ s->temp.size = STREAM_HEADER_SIZE;
+ s->sequence = SEQ_STREAM_FOOTER;
+
+ /* FALLTHROUGH */
+ case SEQ_STREAM_FOOTER:
+ if (!fill_temp(s, b))
+ return XZ_OK;
+
+ return dec_stream_footer(s);
+ }
+ }
+
+ /* Never reached */
+}
+
+/*
+ * xz_dec_run() is a wrapper for dec_main() to handle some special cases in
+ * multi-call and single-call decoding.
+ *
+ * In multi-call mode, we must return XZ_BUF_ERROR when it seems clear that we
+ * are not going to make any progress anymore. This is to prevent the caller
+ * from calling us infinitely when the input file is truncated or otherwise
+ * corrupt. Since zlib-style API allows that the caller fills the input buffer
+ * only when the decoder doesn't produce any new output, we have to be careful
+ * to avoid returning XZ_BUF_ERROR too easily: XZ_BUF_ERROR is returned only
+ * after the second consecutive call to xz_dec_run() that makes no progress.
+ *
+ * In single-call mode, if we couldn't decode everything and no error
+ * occurred, either the input is truncated or the output buffer is too small.
+ * Since we know that the last input byte never produces any output, we know
+ * that if all the input was consumed and decoding wasn't finished, the file
+ * must be corrupt. Otherwise the output buffer has to be too small or the
+ * file is corrupt in a way that decoding it produces too big output.
+ *
+ * If single-call decoding fails, we reset b->in_pos and b->out_pos back to
+ * their original values. This is because with some filter chains there won't
+ * be any valid uncompressed data in the output buffer unless the decoding
+ * actually succeeds (that's the price to pay of using the output buffer as
+ * the workspace).
+ */
+enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b)
+{
+ size_t in_start;
+ size_t out_start;
+ enum xz_ret ret;
+
+ if (s->single_call)
+ xz_dec_reset(s);
+
+ in_start = b->in_pos;
+ out_start = b->out_pos;
+ ret = dec_main(s, b);
+
+ if (s->single_call) {
+ if (ret == XZ_OK)
+ ret = b->in_pos == b->in_size
+ ? XZ_DATA_ERROR : XZ_BUF_ERROR;
+
+ if (ret != XZ_STREAM_END) {
+ b->in_pos = in_start;
+ b->out_pos = out_start;
+ }
+
+ } else if (ret == XZ_OK && in_start == b->in_pos
+ && out_start == b->out_pos) {
+ if (s->allow_buf_error)
+ ret = XZ_BUF_ERROR;
+
+ s->allow_buf_error = true;
+ } else {
+ s->allow_buf_error = false;
+ }
+
+ return ret;
+}
+
+#ifdef GRUB_EMBED_DECOMPRESSOR
+struct xz_dec decoder;
+#endif
+
+struct xz_dec * xz_dec_init(uint32_t dict_max)
+{
+ struct xz_dec *s;
+#ifdef GRUB_EMBED_DECOMPRESSOR
+ s = &decoder;
+#else
+ s = kmalloc(sizeof(*s), GFP_KERNEL);
+ if (s == NULL)
+ return NULL;
+#endif
+
+ memset (s, 0, sizeof (*s));
+
+ s->single_call = dict_max == 0;
+
+#ifdef XZ_DEC_BCJ
+ s->bcj = xz_dec_bcj_create(s->single_call);
+ if (s->bcj == NULL)
+ goto error_bcj;
+#endif
+
+ s->lzma2 = xz_dec_lzma2_create(dict_max);
+ if (s->lzma2 == NULL)
+ goto error_lzma2;
+
+ xz_dec_reset(s);
+ return s;
+
+error_lzma2:
+#ifdef XZ_DEC_BCJ
+ xz_dec_bcj_end(s->bcj);
+error_bcj:
+#endif
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ kfree(s);
+#endif
+ return NULL;
+}
+
+void xz_dec_reset(struct xz_dec *s)
+{
+ s->sequence = SEQ_STREAM_HEADER;
+ s->allow_buf_error = false;
+ s->pos = 0;
+
+ {
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ uint64_t *t;
+ t = s->block.hash.hash_context;
+#endif
+ memzero(&s->block, sizeof(s->block));
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ s->block.hash.hash_context = t;
+ t = s->index.hash.hash_context;
+#endif
+ memzero(&s->index, sizeof(s->index));
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ s->index.hash.hash_context = t;
+#endif
+ }
+ s->temp.pos = 0;
+ s->temp.size = STREAM_HEADER_SIZE;
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ if (s->hash)
+ {
+ s->hash->init(s->hash_context);
+ s->hash->init(s->index.hash.hash_context);
+ s->hash->init(s->block.hash.hash_context);
+ }
+#endif
+ s->have_hash_value = 0;
+}
+
+void xz_dec_end(struct xz_dec *s)
+{
+ if (s != NULL) {
+ xz_dec_lzma2_end(s->lzma2);
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ kfree(s->index.hash.hash_context);
+ kfree(s->block.hash.hash_context);
+ kfree(s->hash_context);
+ kfree(s->crc32_context);
+#endif
+#ifdef XZ_DEC_BCJ
+ xz_dec_bcj_end(s->bcj);
+#endif
+#ifndef GRUB_EMBED_DECOMPRESSOR
+ kfree(s);
+#endif
+ }
+}
diff --git a/grub-core/lib/xzembed/xz_lzma2.h b/grub-core/lib/xzembed/xz_lzma2.h
new file mode 100644
index 0000000..15e553d
--- /dev/null
+++ b/grub-core/lib/xzembed/xz_lzma2.h
@@ -0,0 +1,236 @@
+/* xz_lzma2.h - LZMA2 definitions */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * This file is based on code from XZ embedded project
+ * http://tukaani.org/xz/embedded.html
+ */
+
+#ifndef XZ_LZMA2_H
+#define XZ_LZMA2_H
+
+/* dictionary size hard limit
+ * actual size limit is calculated as shown in 5.3.1
+ * http://tukaani.org/xz/xz-file-format.txt
+ *
+ * if bits > 39 dictionary_size = UINT32_MAX
+ * else
+ * dictionary_size = 2 | (bits & 1);
+ * dictionary_size <<= bits / 2 + 11;
+ *
+ * i.e.
+ * 0 - 4 KiB
+ * 6 - 32 KiB
+ * 30 - 128MiB
+ * 39 - 3072 MiB
+ * 40 - 4096 MiB - 1 B
+ * note: implementation supports 39 at maximum
+ */
+#define DICT_BIT_SIZE 30
+
+/* Range coder constants */
+#define RC_SHIFT_BITS 8
+#define RC_TOP_BITS 24
+#define RC_TOP_VALUE (1 << RC_TOP_BITS)
+#define RC_BIT_MODEL_TOTAL_BITS 11
+#define RC_BIT_MODEL_TOTAL (1 << RC_BIT_MODEL_TOTAL_BITS)
+#define RC_MOVE_BITS 5
+
+/*
+ * Maximum number of position states. A position state is the lowest pb
+ * number of bits of the current uncompressed offset. In some places there
+ * are different sets of probabilities for different position states.
+ */
+#define POS_STATES_MAX (1 << 4)
+
+/*
+ * This enum is used to track which LZMA symbols have occurred most recently
+ * and in which order. This information is used to predict the next symbol.
+ *
+ * Symbols:
+ * - Literal: One 8-bit byte
+ * - Match: Repeat a chunk of data at some distance
+ * - Long repeat: Multi-byte match at a recently seen distance
+ * - Short repeat: One-byte repeat at a recently seen distance
+ *
+ * The symbol names are in from STATE_oldest_older_previous. REP means
+ * either short or long repeated match, and NONLIT means any non-literal.
+ */
+enum lzma_state {
+ STATE_LIT_LIT,
+ STATE_MATCH_LIT_LIT,
+ STATE_REP_LIT_LIT,
+ STATE_SHORTREP_LIT_LIT,
+ STATE_MATCH_LIT,
+ STATE_REP_LIT,
+ STATE_SHORTREP_LIT,
+ STATE_LIT_MATCH,
+ STATE_LIT_LONGREP,
+ STATE_LIT_SHORTREP,
+ STATE_NONLIT_MATCH,
+ STATE_NONLIT_REP
+};
+
+/* Total number of states */
+#define STATES 12
+
+/* The lowest 7 states indicate that the previous state was a literal. */
+#define LIT_STATES 7
+
+/* Indicate that the latest symbol was a literal. */
+static inline void lzma_state_literal(enum lzma_state *state)
+{
+ if (*state <= STATE_SHORTREP_LIT_LIT)
+ *state = STATE_LIT_LIT;
+ else if (*state <= STATE_LIT_SHORTREP)
+ *state -= 3;
+ else
+ *state -= 6;
+}
+
+/* Indicate that the latest symbol was a match. */
+static inline void lzma_state_match(enum lzma_state *state)
+{
+ *state = *state < LIT_STATES ? STATE_LIT_MATCH : STATE_NONLIT_MATCH;
+}
+
+/* Indicate that the latest state was a long repeated match. */
+static inline void lzma_state_long_rep(enum lzma_state *state)
+{
+ *state = *state < LIT_STATES ? STATE_LIT_LONGREP : STATE_NONLIT_REP;
+}
+
+/* Indicate that the latest symbol was a short match. */
+static inline void lzma_state_short_rep(enum lzma_state *state)
+{
+ *state = *state < LIT_STATES ? STATE_LIT_SHORTREP : STATE_NONLIT_REP;
+}
+
+/* Test if the previous symbol was a literal. */
+static inline bool lzma_state_is_literal(enum lzma_state state)
+{
+ return state < LIT_STATES;
+}
+
+/* Each literal coder is divided in three sections:
+ * - 0x001-0x0FF: Without match byte
+ * - 0x101-0x1FF: With match byte; match bit is 0
+ * - 0x201-0x2FF: With match byte; match bit is 1
+ *
+ * Match byte is used when the previous LZMA symbol was something else than
+ * a literal (that is, it was some kind of match).
+ */
+#define LITERAL_CODER_SIZE 0x300
+
+/* Maximum number of literal coders */
+#define LITERAL_CODERS_MAX (1 << 4)
+
+/* Minimum length of a match is two bytes. */
+#define MATCH_LEN_MIN 2
+
+/* Match length is encoded with 4, 5, or 10 bits.
+ *
+ * Length Bits
+ * 2-9 4 = Choice=0 + 3 bits
+ * 10-17 5 = Choice=1 + Choice2=0 + 3 bits
+ * 18-273 10 = Choice=1 + Choice2=1 + 8 bits
+ */
+#define LEN_LOW_BITS 3
+#define LEN_LOW_SYMBOLS (1 << LEN_LOW_BITS)
+#define LEN_MID_BITS 3
+#define LEN_MID_SYMBOLS (1 << LEN_MID_BITS)
+#define LEN_HIGH_BITS 8
+#define LEN_HIGH_SYMBOLS (1 << LEN_HIGH_BITS)
+#define LEN_SYMBOLS (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS)
+
+/*
+ * Maximum length of a match is 273 which is a result of the encoding
+ * described above.
+ */
+#define MATCH_LEN_MAX (MATCH_LEN_MIN + LEN_SYMBOLS - 1)
+
+/*
+ * Different sets of probabilities are used for match distances that have
+ * very short match length: Lengths of 2, 3, and 4 bytes have a separate
+ * set of probabilities for each length. The matches with longer length
+ * use a shared set of probabilities.
+ */
+#define DIST_STATES 4
+
+/*
+ * Get the index of the appropriate probability array for decoding
+ * the distance slot.
+ */
+static inline uint32_t lzma_get_dist_state(uint32_t len)
+{
+ return len < DIST_STATES + MATCH_LEN_MIN
+ ? len - MATCH_LEN_MIN : DIST_STATES - 1;
+}
+
+/*
+ * The highest two bits of a 32-bit match distance are encoded using six bits.
+ * This six-bit value is called a distance slot. This way encoding a 32-bit
+ * value takes 6-36 bits, larger values taking more bits.
+ */
+#define DIST_SLOT_BITS 6
+#define DIST_SLOTS (1 << DIST_SLOT_BITS)
+
+/* Match distances up to 127 are fully encoded using probabilities. Since
+ * the highest two bits (distance slot) are always encoded using six bits,
+ * the distances 0-3 don't need any additional bits to encode, since the
+ * distance slot itself is the same as the actual distance. DIST_MODEL_START
+ * indicates the first distance slot where at least one additional bit is
+ * needed.
+ */
+#define DIST_MODEL_START 4
+
+/*
+ * Match distances greater than 127 are encoded in three pieces:
+ * - distance slot: the highest two bits
+ * - direct bits: 2-26 bits below the highest two bits
+ * - alignment bits: four lowest bits
+ *
+ * Direct bits don't use any probabilities.
+ *
+ * The distance slot value of 14 is for distances 128-191.
+ */
+#define DIST_MODEL_END 14
+
+/* Distance slots that indicate a distance <= 127. */
+#define FULL_DISTANCES_BITS (DIST_MODEL_END / 2)
+#define FULL_DISTANCES (1 << FULL_DISTANCES_BITS)
+
+/*
+ * For match distances greater than 127, only the highest two bits and the
+ * lowest four bits (alignment) is encoded using probabilities.
+ */
+#define ALIGN_BITS 4
+#define ALIGN_SIZE (1 << ALIGN_BITS)
+#define ALIGN_MASK (ALIGN_SIZE - 1)
+
+/* Total number of all probability variables */
+#define PROBS_TOTAL (1846 + LITERAL_CODERS_MAX * LITERAL_CODER_SIZE)
+
+/*
+ * LZMA remembers the four most recent match distances. Reusing these
+ * distances tends to take less space than re-encoding the actual
+ * distance value.
+ */
+#define REPS 4
+
+#endif
diff --git a/grub-core/lib/xzembed/xz_private.h b/grub-core/lib/xzembed/xz_private.h
new file mode 100644
index 0000000..fc845c9
--- /dev/null
+++ b/grub-core/lib/xzembed/xz_private.h
@@ -0,0 +1,96 @@
+/* xz_private.h - Private includes and definitions */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * This file is based on code from XZ embedded project
+ * http://tukaani.org/xz/embedded.html
+ */
+
+#ifndef XZ_PRIVATE_H
+#define XZ_PRIVATE_H
+
+/*
+ * For userspace builds, use a separate header to define the required
+ * macros and functions. This makes it easier to adapt the code into
+ * different environments and avoids clutter in the Linux kernel tree.
+ */
+#include "xz_config.h"
+
+/*
+ * If any of the BCJ filter decoders are wanted, define XZ_DEC_BCJ.
+ * XZ_DEC_BCJ is used to enable generic support for BCJ decoders.
+ */
+#ifndef XZ_DEC_BCJ
+# if defined(XZ_DEC_X86) || defined(XZ_DEC_POWERPC) \
+ || defined(XZ_DEC_IA64) || defined(XZ_DEC_ARM) \
+ || defined(XZ_DEC_ARM) || defined(XZ_DEC_ARMTHUMB) \
+ || defined(XZ_DEC_SPARC)
+# define XZ_DEC_BCJ
+# endif
+#endif
+
+/*
+ * Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used
+ * before calling xz_dec_lzma2_run().
+ */
+struct xz_dec_lzma2 * xz_dec_lzma2_create(
+ uint32_t dict_max);
+
+/*
+ * Decode the LZMA2 properties (one byte) and reset the decoder. Return
+ * XZ_OK on success, XZ_MEMLIMIT_ERROR if the preallocated dictionary is not
+ * big enough, and XZ_OPTIONS_ERROR if props indicates something that this
+ * decoder doesn't support.
+ */
+enum xz_ret xz_dec_lzma2_reset(
+ struct xz_dec_lzma2 *s, uint8_t props);
+
+/* Decode raw LZMA2 stream from b->in to b->out. */
+enum xz_ret xz_dec_lzma2_run(
+ struct xz_dec_lzma2 *s, struct xz_buf *b);
+
+/* Free the memory allocated for the LZMA2 decoder. */
+void xz_dec_lzma2_end(struct xz_dec_lzma2 *s);
+
+/*
+ * Allocate memory for BCJ decoders. xz_dec_bcj_reset() must be used before
+ * calling xz_dec_bcj_run().
+ */
+struct xz_dec_bcj * xz_dec_bcj_create(bool single_call);
+
+/*
+ * Decode the Filter ID of a BCJ filter. This implementation doesn't
+ * support custom start offsets, so no decoding of Filter Properties
+ * is needed. Returns XZ_OK if the given Filter ID is supported.
+ * Otherwise XZ_OPTIONS_ERROR is returned.
+ */
+enum xz_ret xz_dec_bcj_reset(
+ struct xz_dec_bcj *s, uint8_t id);
+
+/*
+ * Decode raw BCJ + LZMA2 stream. This must be used only if there actually is
+ * a BCJ filter in the chain. If the chain has only LZMA2, xz_dec_lzma2_run()
+ * must be called directly.
+ */
+enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
+ struct xz_dec_lzma2 *lzma2, struct xz_buf *b);
+
+/* Free the memory allocated for the BCJ filters. */
+#define xz_dec_bcj_end(s) kfree(s)
+
+#endif
diff --git a/grub-core/lib/xzembed/xz_stream.h b/grub-core/lib/xzembed/xz_stream.h
new file mode 100644
index 0000000..f58397a
--- /dev/null
+++ b/grub-core/lib/xzembed/xz_stream.h
@@ -0,0 +1,53 @@
+/* xz_stream.h - Definitions for handling the .xz file format */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * This file is based on code from XZ embedded project
+ * http://tukaani.org/xz/embedded.html
+ */
+
+#ifndef XZ_STREAM_H
+#define XZ_STREAM_H
+
+/*
+ * See the .xz file format specification at
+ * http://tukaani.org/xz/xz-file-format.txt
+ * to understand the container format.
+ */
+
+#define STREAM_HEADER_SIZE 12
+
+#define HEADER_MAGIC "\3757zXZ\0"
+#define HEADER_MAGIC_SIZE 6
+
+#define FOOTER_MAGIC "YZ"
+#define FOOTER_MAGIC_SIZE 2
+
+/*
+ * Variable-length integer can hold a 63-bit unsigned integer, or a special
+ * value to indicate that the value is unknown.
+ */
+typedef uint64_t vli_type;
+
+#define VLI_MAX ((vli_type)-1 / 2)
+#define VLI_UNKNOWN ((vli_type)-1)
+
+/* Maximum encoded size of a VLI */
+#define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7)
+
+#endif
diff --git a/grub-core/lib/zstd/bitstream.h b/grub-core/lib/zstd/bitstream.h
new file mode 100644
index 0000000..2f91460
--- /dev/null
+++ b/grub-core/lib/zstd/bitstream.h
@@ -0,0 +1,458 @@
+/* ******************************************************************
+ bitstream
+ Part of FSE library
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+#ifndef BITSTREAM_H_MODULE
+#define BITSTREAM_H_MODULE
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/*
+* This API consists of small unitary functions, which must be inlined for best performance.
+* Since link-time-optimization is not available for all compilers,
+* these functions are defined into a .h to be included.
+*/
+
+/*-****************************************
+* Dependencies
+******************************************/
+#include "mem.h" /* unaligned access routines */
+#include "debug.h" /* assert(), DEBUGLOG(), RAWLOG() */
+#include "error_private.h" /* error codes and messages */
+
+
+/*=========================================
+* Target specific
+=========================================*/
+#if defined(__BMI__) && defined(__GNUC__)
+# include <immintrin.h> /* support for bextr (experimental) */
+#endif
+
+#define STREAM_ACCUMULATOR_MIN_32 25
+#define STREAM_ACCUMULATOR_MIN_64 57
+#define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64))
+
+
+/*-******************************************
+* bitStream encoding API (write forward)
+********************************************/
+/* bitStream can mix input from multiple sources.
+ * A critical property of these streams is that they encode and decode in **reverse** direction.
+ * So the first bit sequence you add will be the last to be read, like a LIFO stack.
+ */
+typedef struct {
+ size_t bitContainer;
+ unsigned bitPos;
+ char* startPtr;
+ char* ptr;
+ char* endPtr;
+} BIT_CStream_t;
+
+MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, void* dstBuffer, size_t dstCapacity);
+MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, size_t value, unsigned nbBits);
+MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC);
+MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
+
+/* Start with initCStream, providing the size of buffer to write into.
+* bitStream will never write outside of this buffer.
+* `dstCapacity` must be >= sizeof(bitD->bitContainer), otherwise @return will be an error code.
+*
+* bits are first added to a local register.
+* Local register is size_t, hence 64-bits on 64-bits systems, or 32-bits on 32-bits systems.
+* Writing data into memory is an explicit operation, performed by the flushBits function.
+* Hence keep track how many bits are potentially stored into local register to avoid register overflow.
+* After a flushBits, a maximum of 7 bits might still be stored into local register.
+*
+* Avoid storing elements of more than 24 bits if you want compatibility with 32-bits bitstream readers.
+*
+* Last operation is to close the bitStream.
+* The function returns the final size of CStream in bytes.
+* If data couldn't fit into `dstBuffer`, it will return a 0 ( == not storable)
+*/
+
+
+/*-********************************************
+* bitStream decoding API (read backward)
+**********************************************/
+typedef struct {
+ size_t bitContainer;
+ unsigned bitsConsumed;
+ const char* ptr;
+ const char* start;
+ const char* limitPtr;
+} BIT_DStream_t;
+
+typedef enum { BIT_DStream_unfinished = 0,
+ BIT_DStream_endOfBuffer = 1,
+ BIT_DStream_completed = 2,
+ BIT_DStream_overflow = 3 } BIT_DStream_status; /* result of BIT_reloadDStream() */
+ /* 1,2,4,8 would be better for bitmap combinations, but slows down performance a bit ... :( */
+
+MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize);
+MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits);
+MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD);
+MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD);
+
+
+/* Start by invoking BIT_initDStream().
+* A chunk of the bitStream is then stored into a local register.
+* Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t).
+* You can then retrieve bitFields stored into the local register, **in reverse order**.
+* Local register is explicitly reloaded from memory by the BIT_reloadDStream() method.
+* A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BIT_DStream_unfinished.
+* Otherwise, it can be less than that, so proceed accordingly.
+* Checking if DStream has reached its end can be performed with BIT_endOfDStream().
+*/
+
+
+/*-****************************************
+* unsafe API
+******************************************/
+MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, size_t value, unsigned nbBits);
+/* faster, but works only if value is "clean", meaning all high bits above nbBits are 0 */
+
+MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC);
+/* unsafe version; does not check buffer overflow */
+
+MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits);
+/* faster, but works only if nbBits >= 1 */
+
+
+
+/*-**************************************************************
+* Internal functions
+****************************************************************/
+MEM_STATIC unsigned BIT_highbit32 (U32 val)
+{
+ assert(val != 0);
+ {
+# if defined(_MSC_VER) /* Visual */
+ unsigned long r=0;
+ _BitScanReverse ( &r, val );
+ return (unsigned) r;
+# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
+ return 31 - __builtin_clz (val);
+# else /* Software version */
+ static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29,
+ 11, 14, 16, 18, 22, 25, 3, 30,
+ 8, 12, 20, 28, 15, 17, 24, 7,
+ 19, 27, 23, 6, 26, 5, 4, 31 };
+ U32 v = val;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ return DeBruijnClz[ (U32) (v * 0x07C4ACDDU) >> 27];
+# endif
+ }
+}
+
+/*===== Local Constants =====*/
+static const unsigned BIT_mask[] = {
+ 0, 1, 3, 7, 0xF, 0x1F,
+ 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF,
+ 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, 0x1FFFF,
+ 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF,
+ 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF,
+ 0x3FFFFFFF, 0x7FFFFFFF}; /* up to 31 bits */
+#define BIT_MASK_SIZE (sizeof(BIT_mask) / sizeof(BIT_mask[0]))
+
+/*-**************************************************************
+* bitStream encoding
+****************************************************************/
+/*! BIT_initCStream() :
+ * `dstCapacity` must be > sizeof(size_t)
+ * @return : 0 if success,
+ * otherwise an error code (can be tested using ERR_isError()) */
+MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC,
+ void* startPtr, size_t dstCapacity)
+{
+ bitC->bitContainer = 0;
+ bitC->bitPos = 0;
+ bitC->startPtr = (char*)startPtr;
+ bitC->ptr = bitC->startPtr;
+ bitC->endPtr = bitC->startPtr + dstCapacity - sizeof(bitC->bitContainer);
+ if (dstCapacity <= sizeof(bitC->bitContainer)) return ERROR(dstSize_tooSmall);
+ return 0;
+}
+
+/*! BIT_addBits() :
+ * can add up to 31 bits into `bitC`.
+ * Note : does not check for register overflow ! */
+MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC,
+ size_t value, unsigned nbBits)
+{
+ MEM_STATIC_ASSERT(BIT_MASK_SIZE == 32);
+ assert(nbBits < BIT_MASK_SIZE);
+ assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
+ bitC->bitContainer |= (value & BIT_mask[nbBits]) << bitC->bitPos;
+ bitC->bitPos += nbBits;
+}
+
+/*! BIT_addBitsFast() :
+ * works only if `value` is _clean_,
+ * meaning all high bits above nbBits are 0 */
+MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC,
+ size_t value, unsigned nbBits)
+{
+ assert((value>>nbBits) == 0);
+ assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
+ bitC->bitContainer |= value << bitC->bitPos;
+ bitC->bitPos += nbBits;
+}
+
+/*! BIT_flushBitsFast() :
+ * assumption : bitContainer has not overflowed
+ * unsafe version; does not check buffer overflow */
+MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC)
+{
+ size_t const nbBytes = bitC->bitPos >> 3;
+ assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
+ MEM_writeLEST(bitC->ptr, bitC->bitContainer);
+ bitC->ptr += nbBytes;
+ assert(bitC->ptr <= bitC->endPtr);
+ bitC->bitPos &= 7;
+ bitC->bitContainer >>= nbBytes*8;
+}
+
+/*! BIT_flushBits() :
+ * assumption : bitContainer has not overflowed
+ * safe version; check for buffer overflow, and prevents it.
+ * note : does not signal buffer overflow.
+ * overflow will be revealed later on using BIT_closeCStream() */
+MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC)
+{
+ size_t const nbBytes = bitC->bitPos >> 3;
+ assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
+ MEM_writeLEST(bitC->ptr, bitC->bitContainer);
+ bitC->ptr += nbBytes;
+ if (bitC->ptr > bitC->endPtr) bitC->ptr = bitC->endPtr;
+ bitC->bitPos &= 7;
+ bitC->bitContainer >>= nbBytes*8;
+}
+
+/*! BIT_closeCStream() :
+ * @return : size of CStream, in bytes,
+ * or 0 if it could not fit into dstBuffer */
+MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC)
+{
+ BIT_addBitsFast(bitC, 1, 1); /* endMark */
+ BIT_flushBits(bitC);
+ if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */
+ return (bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0);
+}
+
+
+/*-********************************************************
+* bitStream decoding
+**********************************************************/
+/*! BIT_initDStream() :
+ * Initialize a BIT_DStream_t.
+ * `bitD` : a pointer to an already allocated BIT_DStream_t structure.
+ * `srcSize` must be the *exact* size of the bitStream, in bytes.
+ * @return : size of stream (== srcSize), or an errorCode if a problem is detected
+ */
+MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize)
+{
+ if (srcSize < 1) { memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); }
+
+ bitD->start = (const char*)srcBuffer;
+ bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer);
+
+ if (srcSize >= sizeof(bitD->bitContainer)) { /* normal case */
+ bitD->ptr = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer);
+ bitD->bitContainer = MEM_readLEST(bitD->ptr);
+ { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
+ bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; /* ensures bitsConsumed is always set */
+ if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ }
+ } else {
+ bitD->ptr = bitD->start;
+ bitD->bitContainer = *(const BYTE*)(bitD->start);
+ switch(srcSize)
+ {
+ case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
+ /* fall-through */
+
+ case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
+ /* fall-through */
+
+ case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
+ /* fall-through */
+
+ case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24;
+ /* fall-through */
+
+ case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16;
+ /* fall-through */
+
+ case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8;
+ /* fall-through */
+
+ default: break;
+ }
+ { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
+ bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0;
+ if (lastByte == 0) return ERROR(corruption_detected); /* endMark not present */
+ }
+ bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8;
+ }
+
+ return srcSize;
+}
+
+MEM_STATIC size_t BIT_getUpperBits(size_t bitContainer, U32 const start)
+{
+ return bitContainer >> start;
+}
+
+MEM_STATIC size_t BIT_getMiddleBits(size_t bitContainer, U32 const start, U32 const nbBits)
+{
+#if defined(__BMI__) && defined(__GNUC__) && __GNUC__*1000+__GNUC_MINOR__ >= 4008 /* experimental */
+# if defined(__x86_64__)
+ if (sizeof(bitContainer)==8)
+ return _bextr_u64(bitContainer, start, nbBits);
+ else
+# endif
+ return _bextr_u32(bitContainer, start, nbBits);
+#else
+ assert(nbBits < BIT_MASK_SIZE);
+ return (bitContainer >> start) & BIT_mask[nbBits];
+#endif
+}
+
+MEM_STATIC size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits)
+{
+ assert(nbBits < BIT_MASK_SIZE);
+ return bitContainer & BIT_mask[nbBits];
+}
+
+/*! BIT_lookBits() :
+ * Provides next n bits from local register.
+ * local register is not modified.
+ * On 32-bits, maxNbBits==24.
+ * On 64-bits, maxNbBits==56.
+ * @return : value extracted */
+MEM_STATIC size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits)
+{
+#if defined(__BMI__) && defined(__GNUC__) /* experimental; fails if bitD->bitsConsumed + nbBits > sizeof(bitD->bitContainer)*8 */
+ return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed - nbBits, nbBits);
+#else
+ U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
+ return ((bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> 1) >> ((regMask-nbBits) & regMask);
+#endif
+}
+
+/*! BIT_lookBitsFast() :
+ * unsafe version; only works if nbBits >= 1 */
+MEM_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits)
+{
+ U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
+ assert(nbBits >= 1);
+ return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask);
+}
+
+MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits)
+{
+ bitD->bitsConsumed += nbBits;
+}
+
+/*! BIT_readBits() :
+ * Read (consume) next n bits from local register and update.
+ * Pay attention to not read more than nbBits contained into local register.
+ * @return : extracted value. */
+MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits)
+{
+ size_t const value = BIT_lookBits(bitD, nbBits);
+ BIT_skipBits(bitD, nbBits);
+ return value;
+}
+
+/*! BIT_readBitsFast() :
+ * unsafe version; only works only if nbBits >= 1 */
+MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits)
+{
+ size_t const value = BIT_lookBitsFast(bitD, nbBits);
+ assert(nbBits >= 1);
+ BIT_skipBits(bitD, nbBits);
+ return value;
+}
+
+/*! BIT_reloadDStream() :
+ * Refill `bitD` from buffer previously set in BIT_initDStream() .
+ * This function is safe, it guarantees it will not read beyond src buffer.
+ * @return : status of `BIT_DStream_t` internal register.
+ * when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */
+MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
+{
+ if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */
+ return BIT_DStream_overflow;
+
+ if (bitD->ptr >= bitD->limitPtr) {
+ bitD->ptr -= bitD->bitsConsumed >> 3;
+ bitD->bitsConsumed &= 7;
+ bitD->bitContainer = MEM_readLEST(bitD->ptr);
+ return BIT_DStream_unfinished;
+ }
+ if (bitD->ptr == bitD->start) {
+ if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer;
+ return BIT_DStream_completed;
+ }
+ /* start < ptr < limitPtr */
+ { U32 nbBytes = bitD->bitsConsumed >> 3;
+ BIT_DStream_status result = BIT_DStream_unfinished;
+ if (bitD->ptr - nbBytes < bitD->start) {
+ nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */
+ result = BIT_DStream_endOfBuffer;
+ }
+ bitD->ptr -= nbBytes;
+ bitD->bitsConsumed -= nbBytes*8;
+ bitD->bitContainer = MEM_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */
+ return result;
+ }
+}
+
+/*! BIT_endOfDStream() :
+ * @return : 1 if DStream has _exactly_ reached its end (all bits consumed).
+ */
+MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream)
+{
+ return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8));
+}
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* BITSTREAM_H_MODULE */
diff --git a/grub-core/lib/zstd/compiler.h b/grub-core/lib/zstd/compiler.h
new file mode 100644
index 0000000..07f875e
--- /dev/null
+++ b/grub-core/lib/zstd/compiler.h
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_COMPILER_H
+#define ZSTD_COMPILER_H
+
+/*-*******************************************************
+* Compiler specifics
+*********************************************************/
+/* force inlining */
+#if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
+# define INLINE_KEYWORD inline
+#else
+# define INLINE_KEYWORD
+#endif
+
+#if defined(__GNUC__)
+# define FORCE_INLINE_ATTR __attribute__((always_inline))
+#elif defined(_MSC_VER)
+# define FORCE_INLINE_ATTR __forceinline
+#else
+# define FORCE_INLINE_ATTR
+#endif
+
+/**
+ * FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant
+ * parameters. They must be inlined for the compiler to elimininate the constant
+ * branches.
+ */
+#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
+/**
+ * HINT_INLINE is used to help the compiler generate better code. It is *not*
+ * used for "templates", so it can be tweaked based on the compilers
+ * performance.
+ *
+ * gcc-4.8 and gcc-4.9 have been shown to benefit from leaving off the
+ * always_inline attribute.
+ *
+ * clang up to 5.0.0 (trunk) benefit tremendously from the always_inline
+ * attribute.
+ */
+#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 && __GNUC__ < 5
+# define HINT_INLINE static INLINE_KEYWORD
+#else
+# define HINT_INLINE static INLINE_KEYWORD FORCE_INLINE_ATTR
+#endif
+
+/* force no inlining */
+#ifdef _MSC_VER
+# define FORCE_NOINLINE static __declspec(noinline)
+#else
+# ifdef __GNUC__
+# define FORCE_NOINLINE static __attribute__((__noinline__))
+# else
+# define FORCE_NOINLINE static
+# endif
+#endif
+
+/* target attribute */
+#ifndef __has_attribute
+ #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
+#endif
+#if defined(__GNUC__)
+# define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
+#else
+# define TARGET_ATTRIBUTE(target)
+#endif
+
+/* Enable runtime BMI2 dispatch based on the CPU.
+ * Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default.
+ */
+#ifndef DYNAMIC_BMI2
+ #if ((defined(__clang__) && __has_attribute(__target__)) \
+ || (defined(__GNUC__) \
+ && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \
+ && (defined(__x86_64__) || defined(_M_X86)) \
+ && !defined(__BMI2__)
+ # define DYNAMIC_BMI2 1
+ #else
+ # define DYNAMIC_BMI2 0
+ #endif
+#endif
+
+/* prefetch
+ * can be disabled, by declaring NO_PREFETCH macro
+ * All prefetch invocations use a single default locality 2,
+ * generating instruction prefetcht1,
+ * which, according to Intel, means "load data into L2 cache".
+ * This is a good enough "middle ground" for the time being,
+ * though in theory, it would be better to specialize locality depending on data being prefetched.
+ * Tests could not determine any sensible difference based on locality value. */
+#if defined(NO_PREFETCH)
+# define PREFETCH(ptr) (void)(ptr) /* disabled */
+#else
+# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
+# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
+# define PREFETCH(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
+# elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
+# define PREFETCH(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
+# else
+# define PREFETCH(ptr) (void)(ptr) /* disabled */
+# endif
+#endif /* NO_PREFETCH */
+
+#define CACHELINE_SIZE 64
+
+#define PREFETCH_AREA(p, s) { \
+ const char* const _ptr = (const char*)(p); \
+ size_t const _size = (size_t)(s); \
+ size_t _pos; \
+ for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \
+ PREFETCH(_ptr + _pos); \
+ } \
+}
+
+/* disable warnings */
+#ifdef _MSC_VER /* Visual Studio */
+# include <intrin.h> /* For Visual 2005 */
+# pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */
+# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
+# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
+# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */
+# pragma warning(disable : 4324) /* disable: C4324: padded structure */
+#endif
+
+#endif /* ZSTD_COMPILER_H */
diff --git a/grub-core/lib/zstd/cpu.h b/grub-core/lib/zstd/cpu.h
new file mode 100644
index 0000000..eeb428a
--- /dev/null
+++ b/grub-core/lib/zstd/cpu.h
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2018-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_COMMON_CPU_H
+#define ZSTD_COMMON_CPU_H
+
+/**
+ * Implementation taken from folly/CpuId.h
+ * https://github.com/facebook/folly/blob/master/folly/CpuId.h
+ */
+
+#include <string.h>
+
+#include "mem.h"
+
+#ifdef _MSC_VER
+#include <intrin.h>
+#endif
+
+typedef struct {
+ U32 f1c;
+ U32 f1d;
+ U32 f7b;
+ U32 f7c;
+} ZSTD_cpuid_t;
+
+MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
+ U32 f1c = 0;
+ U32 f1d = 0;
+ U32 f7b = 0;
+ U32 f7c = 0;
+#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
+ int reg[4];
+ __cpuid((int*)reg, 0);
+ {
+ int const n = reg[0];
+ if (n >= 1) {
+ __cpuid((int*)reg, 1);
+ f1c = (U32)reg[2];
+ f1d = (U32)reg[3];
+ }
+ if (n >= 7) {
+ __cpuidex((int*)reg, 7, 0);
+ f7b = (U32)reg[1];
+ f7c = (U32)reg[2];
+ }
+ }
+#elif defined(__i386__) && defined(__PIC__) && !defined(__clang__) && defined(__GNUC__)
+ /* The following block like the normal cpuid branch below, but gcc
+ * reserves ebx for use of its pic register so we must specially
+ * handle the save and restore to avoid clobbering the register
+ */
+ U32 n;
+ __asm__(
+ "pushl %%ebx\n\t"
+ "cpuid\n\t"
+ "popl %%ebx\n\t"
+ : "=a"(n)
+ : "a"(0)
+ : "ecx", "edx");
+ if (n >= 1) {
+ U32 f1a;
+ __asm__(
+ "pushl %%ebx\n\t"
+ "cpuid\n\t"
+ "popl %%ebx\n\t"
+ : "=a"(f1a), "=c"(f1c), "=d"(f1d)
+ : "a"(1));
+ }
+ if (n >= 7) {
+ __asm__(
+ "pushl %%ebx\n\t"
+ "cpuid\n\t"
+ "movl %%ebx, %%eax\n\r"
+ "popl %%ebx"
+ : "=a"(f7b), "=c"(f7c)
+ : "a"(7), "c"(0)
+ : "edx");
+ }
+#elif defined(__x86_64__) || defined(_M_X64) || defined(__i386__)
+ U32 n;
+ __asm__("cpuid" : "=a"(n) : "a"(0) : "ebx", "ecx", "edx");
+ if (n >= 1) {
+ U32 f1a;
+ __asm__("cpuid" : "=a"(f1a), "=c"(f1c), "=d"(f1d) : "a"(1) : "ebx");
+ }
+ if (n >= 7) {
+ U32 f7a;
+ __asm__("cpuid"
+ : "=a"(f7a), "=b"(f7b), "=c"(f7c)
+ : "a"(7), "c"(0)
+ : "edx");
+ }
+#endif
+ {
+ ZSTD_cpuid_t cpuid;
+ cpuid.f1c = f1c;
+ cpuid.f1d = f1d;
+ cpuid.f7b = f7b;
+ cpuid.f7c = f7c;
+ return cpuid;
+ }
+}
+
+#define X(name, r, bit) \
+ MEM_STATIC int ZSTD_cpuid_##name(ZSTD_cpuid_t const cpuid) { \
+ return ((cpuid.r) & (1U << bit)) != 0; \
+ }
+
+/* cpuid(1): Processor Info and Feature Bits. */
+#define C(name, bit) X(name, f1c, bit)
+ C(sse3, 0)
+ C(pclmuldq, 1)
+ C(dtes64, 2)
+ C(monitor, 3)
+ C(dscpl, 4)
+ C(vmx, 5)
+ C(smx, 6)
+ C(eist, 7)
+ C(tm2, 8)
+ C(ssse3, 9)
+ C(cnxtid, 10)
+ C(fma, 12)
+ C(cx16, 13)
+ C(xtpr, 14)
+ C(pdcm, 15)
+ C(pcid, 17)
+ C(dca, 18)
+ C(sse41, 19)
+ C(sse42, 20)
+ C(x2apic, 21)
+ C(movbe, 22)
+ C(popcnt, 23)
+ C(tscdeadline, 24)
+ C(aes, 25)
+ C(xsave, 26)
+ C(osxsave, 27)
+ C(avx, 28)
+ C(f16c, 29)
+ C(rdrand, 30)
+#undef C
+#define D(name, bit) X(name, f1d, bit)
+ D(fpu, 0)
+ D(vme, 1)
+ D(de, 2)
+ D(pse, 3)
+ D(tsc, 4)
+ D(msr, 5)
+ D(pae, 6)
+ D(mce, 7)
+ D(cx8, 8)
+ D(apic, 9)
+ D(sep, 11)
+ D(mtrr, 12)
+ D(pge, 13)
+ D(mca, 14)
+ D(cmov, 15)
+ D(pat, 16)
+ D(pse36, 17)
+ D(psn, 18)
+ D(clfsh, 19)
+ D(ds, 21)
+ D(acpi, 22)
+ D(mmx, 23)
+ D(fxsr, 24)
+ D(sse, 25)
+ D(sse2, 26)
+ D(ss, 27)
+ D(htt, 28)
+ D(tm, 29)
+ D(pbe, 31)
+#undef D
+
+/* cpuid(7): Extended Features. */
+#define B(name, bit) X(name, f7b, bit)
+ B(bmi1, 3)
+ B(hle, 4)
+ B(avx2, 5)
+ B(smep, 7)
+ B(bmi2, 8)
+ B(erms, 9)
+ B(invpcid, 10)
+ B(rtm, 11)
+ B(mpx, 14)
+ B(avx512f, 16)
+ B(avx512dq, 17)
+ B(rdseed, 18)
+ B(adx, 19)
+ B(smap, 20)
+ B(avx512ifma, 21)
+ B(pcommit, 22)
+ B(clflushopt, 23)
+ B(clwb, 24)
+ B(avx512pf, 26)
+ B(avx512er, 27)
+ B(avx512cd, 28)
+ B(sha, 29)
+ B(avx512bw, 30)
+ B(avx512vl, 31)
+#undef B
+#define C(name, bit) X(name, f7c, bit)
+ C(prefetchwt1, 0)
+ C(avx512vbmi, 1)
+#undef C
+
+#undef X
+
+#endif /* ZSTD_COMMON_CPU_H */
diff --git a/grub-core/lib/zstd/debug.c b/grub-core/lib/zstd/debug.c
new file mode 100644
index 0000000..3ebdd1c
--- /dev/null
+++ b/grub-core/lib/zstd/debug.c
@@ -0,0 +1,44 @@
+/* ******************************************************************
+ debug
+ Part of FSE library
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+
+
+/*
+ * This module only hosts one global variable
+ * which can be used to dynamically influence the verbosity of traces,
+ * such as DEBUGLOG and RAWLOG
+ */
+
+#include "debug.h"
+
+int g_debuglevel = DEBUGLEVEL;
diff --git a/grub-core/lib/zstd/debug.h b/grub-core/lib/zstd/debug.h
new file mode 100644
index 0000000..0c04ad2
--- /dev/null
+++ b/grub-core/lib/zstd/debug.h
@@ -0,0 +1,123 @@
+/* ******************************************************************
+ debug
+ Part of FSE library
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+
+
+/*
+ * The purpose of this header is to enable debug functions.
+ * They regroup assert(), DEBUGLOG() and RAWLOG() for run-time,
+ * and DEBUG_STATIC_ASSERT() for compile-time.
+ *
+ * By default, DEBUGLEVEL==0, which means run-time debug is disabled.
+ *
+ * Level 1 enables assert() only.
+ * Starting level 2, traces can be generated and pushed to stderr.
+ * The higher the level, the more verbose the traces.
+ *
+ * It's possible to dynamically adjust level using variable g_debug_level,
+ * which is only declared if DEBUGLEVEL>=2,
+ * and is a global variable, not multi-thread protected (use with care)
+ */
+
+#ifndef DEBUG_H_12987983217
+#define DEBUG_H_12987983217
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* static assert is triggered at compile time, leaving no runtime artefact,
+ * but can only work with compile-time constants.
+ * This variant can only be used inside a function. */
+#define DEBUG_STATIC_ASSERT(c) (void)sizeof(char[(c) ? 1 : -1])
+
+
+/* DEBUGLEVEL is expected to be defined externally,
+ * typically through compiler command line.
+ * Value must be a number. */
+#ifndef DEBUGLEVEL
+# define DEBUGLEVEL 0
+#endif
+
+/* recommended values for DEBUGLEVEL :
+ * 0 : no debug, all run-time functions disabled
+ * 1 : no display, enables assert() only
+ * 2 : reserved, for currently active debug path
+ * 3 : events once per object lifetime (CCtx, CDict, etc.)
+ * 4 : events once per frame
+ * 5 : events once per block
+ * 6 : events once per sequence (verbose)
+ * 7+: events at every position (*very* verbose)
+ *
+ * It's generally inconvenient to output traces > 5.
+ * In which case, it's possible to selectively enable higher verbosity levels
+ * by modifying g_debug_level.
+ */
+
+#if (DEBUGLEVEL>=1)
+# include <assert.h>
+#else
+# ifndef assert /* assert may be already defined, due to prior #include <assert.h> */
+# define assert(condition) ((void)0) /* disable assert (default) */
+# endif
+#endif
+
+#if (DEBUGLEVEL>=2)
+# include <stdio.h>
+extern int g_debuglevel; /* here, this variable is only declared,
+ it actually lives in debug.c,
+ and is shared by the whole process.
+ It's typically used to enable very verbose levels
+ on selective conditions (such as position in src) */
+
+# define RAWLOG(l, ...) { \
+ if (l<=g_debuglevel) { \
+ fprintf(stderr, __VA_ARGS__); \
+ } }
+# define DEBUGLOG(l, ...) { \
+ if (l<=g_debuglevel) { \
+ fprintf(stderr, __FILE__ ": " __VA_ARGS__); \
+ fprintf(stderr, " \n"); \
+ } }
+#else
+# define RAWLOG(l, ...) {} /* disabled */
+# define DEBUGLOG(l, ...) {} /* disabled */
+#endif
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* DEBUG_H_12987983217 */
diff --git a/grub-core/lib/zstd/entropy_common.c b/grub-core/lib/zstd/entropy_common.c
new file mode 100644
index 0000000..b12944e
--- /dev/null
+++ b/grub-core/lib/zstd/entropy_common.c
@@ -0,0 +1,236 @@
+/*
+ Common functions of New Generation Entropy library
+ Copyright (C) 2016, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
+ - Public forum : https://groups.google.com/forum/#!forum/lz4c
+*************************************************************************** */
+
+/* *************************************
+* Dependencies
+***************************************/
+#include "mem.h"
+#include "error_private.h" /* ERR_*, ERROR */
+#define FSE_STATIC_LINKING_ONLY /* FSE_MIN_TABLELOG */
+#include "fse.h"
+#define HUF_STATIC_LINKING_ONLY /* HUF_TABLELOG_ABSOLUTEMAX */
+#include "huf.h"
+
+
+/*=== Version ===*/
+unsigned FSE_versionNumber(void) { return FSE_VERSION_NUMBER; }
+
+
+/*=== Error Management ===*/
+unsigned FSE_isError(size_t code) { return ERR_isError(code); }
+const char* FSE_getErrorName(size_t code) { return ERR_getErrorName(code); }
+
+unsigned HUF_isError(size_t code) { return ERR_isError(code); }
+const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); }
+
+
+/*-**************************************************************
+* FSE NCount encoding-decoding
+****************************************************************/
+size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
+ const void* headerBuffer, size_t hbSize)
+{
+ const BYTE* const istart = (const BYTE*) headerBuffer;
+ const BYTE* const iend = istart + hbSize;
+ const BYTE* ip = istart;
+ int nbBits;
+ int remaining;
+ int threshold;
+ U32 bitStream;
+ int bitCount;
+ unsigned charnum = 0;
+ int previous0 = 0;
+
+ if (hbSize < 4) {
+ /* This function only works when hbSize >= 4 */
+ char buffer[4];
+ memset(buffer, 0, sizeof(buffer));
+ memcpy(buffer, headerBuffer, hbSize);
+ { size_t const countSize = FSE_readNCount(normalizedCounter, maxSVPtr, tableLogPtr,
+ buffer, sizeof(buffer));
+ if (FSE_isError(countSize)) return countSize;
+ if (countSize > hbSize) return ERROR(corruption_detected);
+ return countSize;
+ } }
+ assert(hbSize >= 4);
+
+ /* init */
+ memset(normalizedCounter, 0, (*maxSVPtr+1) * sizeof(normalizedCounter[0])); /* all symbols not present in NCount have a frequency of 0 */
+ bitStream = MEM_readLE32(ip);
+ nbBits = (bitStream & 0xF) + FSE_MIN_TABLELOG; /* extract tableLog */
+ if (nbBits > FSE_TABLELOG_ABSOLUTE_MAX) return ERROR(tableLog_tooLarge);
+ bitStream >>= 4;
+ bitCount = 4;
+ *tableLogPtr = nbBits;
+ remaining = (1<<nbBits)+1;
+ threshold = 1<<nbBits;
+ nbBits++;
+
+ while ((remaining>1) & (charnum<=*maxSVPtr)) {
+ if (previous0) {
+ unsigned n0 = charnum;
+ while ((bitStream & 0xFFFF) == 0xFFFF) {
+ n0 += 24;
+ if (ip < iend-5) {
+ ip += 2;
+ bitStream = MEM_readLE32(ip) >> bitCount;
+ } else {
+ bitStream >>= 16;
+ bitCount += 16;
+ } }
+ while ((bitStream & 3) == 3) {
+ n0 += 3;
+ bitStream >>= 2;
+ bitCount += 2;
+ }
+ n0 += bitStream & 3;
+ bitCount += 2;
+ if (n0 > *maxSVPtr) return ERROR(maxSymbolValue_tooSmall);
+ while (charnum < n0) normalizedCounter[charnum++] = 0;
+ if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) {
+ assert((bitCount >> 3) <= 3); /* For first condition to work */
+ ip += bitCount>>3;
+ bitCount &= 7;
+ bitStream = MEM_readLE32(ip) >> bitCount;
+ } else {
+ bitStream >>= 2;
+ } }
+ { int const max = (2*threshold-1) - remaining;
+ int count;
+
+ if ((bitStream & (threshold-1)) < (U32)max) {
+ count = bitStream & (threshold-1);
+ bitCount += nbBits-1;
+ } else {
+ count = bitStream & (2*threshold-1);
+ if (count >= threshold) count -= max;
+ bitCount += nbBits;
+ }
+
+ count--; /* extra accuracy */
+ remaining -= count < 0 ? -count : count; /* -1 means +1 */
+ normalizedCounter[charnum++] = (short)count;
+ previous0 = !count;
+ while (remaining < threshold) {
+ nbBits--;
+ threshold >>= 1;
+ }
+
+ if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) {
+ ip += bitCount>>3;
+ bitCount &= 7;
+ } else {
+ bitCount -= (int)(8 * (iend - 4 - ip));
+ ip = iend - 4;
+ }
+ bitStream = MEM_readLE32(ip) >> (bitCount & 31);
+ } } /* while ((remaining>1) & (charnum<=*maxSVPtr)) */
+ if (remaining != 1) return ERROR(corruption_detected);
+ if (bitCount > 32) return ERROR(corruption_detected);
+ *maxSVPtr = charnum-1;
+
+ ip += (bitCount+7)>>3;
+ return ip-istart;
+}
+
+
+/*! HUF_readStats() :
+ Read compact Huffman tree, saved by HUF_writeCTable().
+ `huffWeight` is destination buffer.
+ `rankStats` is assumed to be a table of at least HUF_TABLELOG_MAX U32.
+ @return : size read from `src` , or an error Code .
+ Note : Needed by HUF_readCTable() and HUF_readDTableX?() .
+*/
+size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
+ U32* nbSymbolsPtr, U32* tableLogPtr,
+ const void* src, size_t srcSize)
+{
+ U32 weightTotal;
+ const BYTE* ip = (const BYTE*) src;
+ size_t iSize;
+ size_t oSize;
+
+ if (!srcSize) return ERROR(srcSize_wrong);
+ iSize = ip[0];
+ /* memset(huffWeight, 0, hwSize); *//* is not necessary, even though some analyzer complain ... */
+
+ if (iSize >= 128) { /* special header */
+ oSize = iSize - 127;
+ iSize = ((oSize+1)/2);
+ if (iSize+1 > srcSize) return ERROR(srcSize_wrong);
+ if (oSize >= hwSize) return ERROR(corruption_detected);
+ ip += 1;
+ { U32 n;
+ for (n=0; n<oSize; n+=2) {
+ huffWeight[n] = ip[n/2] >> 4;
+ huffWeight[n+1] = ip[n/2] & 15;
+ } } }
+ else { /* header compressed with FSE (normal case) */
+ FSE_DTable fseWorkspace[FSE_DTABLE_SIZE_U32(6)]; /* 6 is max possible tableLog for HUF header (maybe even 5, to be tested) */
+ if (iSize+1 > srcSize) return ERROR(srcSize_wrong);
+ oSize = FSE_decompress_wksp(huffWeight, hwSize-1, ip+1, iSize, fseWorkspace, 6); /* max (hwSize-1) values decoded, as last one is implied */
+ if (FSE_isError(oSize)) return oSize;
+ }
+
+ /* collect weight stats */
+ memset(rankStats, 0, (HUF_TABLELOG_MAX + 1) * sizeof(U32));
+ weightTotal = 0;
+ { U32 n; for (n=0; n<oSize; n++) {
+ if (huffWeight[n] >= HUF_TABLELOG_MAX) return ERROR(corruption_detected);
+ rankStats[huffWeight[n]]++;
+ weightTotal += (1 << huffWeight[n]) >> 1;
+ } }
+ if (weightTotal == 0) return ERROR(corruption_detected);
+
+ /* get last non-null symbol weight (implied, total must be 2^n) */
+ { U32 const tableLog = BIT_highbit32(weightTotal) + 1;
+ if (tableLog > HUF_TABLELOG_MAX) return ERROR(corruption_detected);
+ *tableLogPtr = tableLog;
+ /* determine last weight */
+ { U32 const total = 1 << tableLog;
+ U32 const rest = total - weightTotal;
+ U32 const verif = 1 << BIT_highbit32(rest);
+ U32 const lastWeight = BIT_highbit32(rest) + 1;
+ if (verif != rest) return ERROR(corruption_detected); /* last value must be a clean power of 2 */
+ huffWeight[oSize] = (BYTE)lastWeight;
+ rankStats[lastWeight]++;
+ } }
+
+ /* check tree construction validity */
+ if ((rankStats[1] < 2) || (rankStats[1] & 1)) return ERROR(corruption_detected); /* by construction : at least 2 elts of rank 1, must be even */
+
+ /* results */
+ *nbSymbolsPtr = (U32)(oSize+1);
+ return iSize+1;
+}
diff --git a/grub-core/lib/zstd/error_private.c b/grub-core/lib/zstd/error_private.c
new file mode 100644
index 0000000..d004ee6
--- /dev/null
+++ b/grub-core/lib/zstd/error_private.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/* The purpose of this file is to have a single list of error strings embedded in binary */
+
+#include "error_private.h"
+
+const char* ERR_getErrorString(ERR_enum code)
+{
+ static const char* const notErrorCode = "Unspecified error code";
+ switch( code )
+ {
+ case PREFIX(no_error): return "No error detected";
+ case PREFIX(GENERIC): return "Error (generic)";
+ case PREFIX(prefix_unknown): return "Unknown frame descriptor";
+ case PREFIX(version_unsupported): return "Version not supported";
+ case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter";
+ case PREFIX(frameParameter_windowTooLarge): return "Frame requires too much memory for decoding";
+ case PREFIX(corruption_detected): return "Corrupted block detected";
+ case PREFIX(checksum_wrong): return "Restored data doesn't match checksum";
+ case PREFIX(parameter_unsupported): return "Unsupported parameter";
+ case PREFIX(parameter_outOfBound): return "Parameter is out of bound";
+ case PREFIX(init_missing): return "Context should be init first";
+ case PREFIX(memory_allocation): return "Allocation error : not enough memory";
+ case PREFIX(workSpace_tooSmall): return "workSpace buffer is not large enough";
+ case PREFIX(stage_wrong): return "Operation not authorized at current processing stage";
+ case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported";
+ case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large";
+ case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small";
+ case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
+ case PREFIX(dictionary_wrong): return "Dictionary mismatch";
+ case PREFIX(dictionaryCreation_failed): return "Cannot create Dictionary from provided samples";
+ case PREFIX(dstSize_tooSmall): return "Destination buffer is too small";
+ case PREFIX(srcSize_wrong): return "Src size is incorrect";
+ /* following error codes are not stable and may be removed or changed in a future version */
+ case PREFIX(frameIndex_tooLarge): return "Frame index is too large";
+ case PREFIX(seekableIO): return "An I/O error occurred when reading/seeking";
+ case PREFIX(maxCode):
+ default: return notErrorCode;
+ }
+}
diff --git a/grub-core/lib/zstd/error_private.h b/grub-core/lib/zstd/error_private.h
new file mode 100644
index 0000000..0d2fa7e
--- /dev/null
+++ b/grub-core/lib/zstd/error_private.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/* Note : this module is expected to remain private, do not expose it */
+
+#ifndef ERROR_H_MODULE
+#define ERROR_H_MODULE
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* ****************************************
+* Dependencies
+******************************************/
+#include <stddef.h> /* size_t */
+#include "zstd_errors.h" /* enum list */
+
+
+/* ****************************************
+* Compiler-specific
+******************************************/
+#if defined(__GNUC__)
+# define ERR_STATIC static __attribute__((unused))
+#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
+# define ERR_STATIC static inline
+#elif defined(_MSC_VER)
+# define ERR_STATIC static __inline
+#else
+# define ERR_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
+#endif
+
+
+/*-****************************************
+* Customization (error_public.h)
+******************************************/
+typedef ZSTD_ErrorCode ERR_enum;
+#define PREFIX(name) ZSTD_error_##name
+
+
+/*-****************************************
+* Error codes handling
+******************************************/
+#undef ERROR /* reported already defined on VS 2015 (Rich Geldreich) */
+#define ERROR(name) ZSTD_ERROR(name)
+#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
+
+ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
+
+ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; return (ERR_enum) (0-code); }
+
+
+/*-****************************************
+* Error Strings
+******************************************/
+
+const char* ERR_getErrorString(ERR_enum code); /* error_private.c */
+
+ERR_STATIC const char* ERR_getErrorName(size_t code)
+{
+ return ERR_getErrorString(ERR_getErrorCode(code));
+}
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ERROR_H_MODULE */
diff --git a/grub-core/lib/zstd/fse.h b/grub-core/lib/zstd/fse.h
new file mode 100644
index 0000000..a5a6b6d
--- /dev/null
+++ b/grub-core/lib/zstd/fse.h
@@ -0,0 +1,708 @@
+/* ******************************************************************
+ FSE : Finite State Entropy codec
+ Public Prototypes declaration
+ Copyright (C) 2013-2016, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#ifndef FSE_H
+#define FSE_H
+
+
+/*-*****************************************
+* Dependencies
+******************************************/
+#include <stddef.h> /* size_t, ptrdiff_t */
+
+
+/*-*****************************************
+* FSE_PUBLIC_API : control library symbols visibility
+******************************************/
+#if defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) && defined(__GNUC__) && (__GNUC__ >= 4)
+# define FSE_PUBLIC_API __attribute__ ((visibility ("default")))
+#elif defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) /* Visual expected */
+# define FSE_PUBLIC_API __declspec(dllexport)
+#elif defined(FSE_DLL_IMPORT) && (FSE_DLL_IMPORT==1)
+# define FSE_PUBLIC_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
+#else
+# define FSE_PUBLIC_API
+#endif
+
+/*------ Version ------*/
+#define FSE_VERSION_MAJOR 0
+#define FSE_VERSION_MINOR 9
+#define FSE_VERSION_RELEASE 0
+
+#define FSE_LIB_VERSION FSE_VERSION_MAJOR.FSE_VERSION_MINOR.FSE_VERSION_RELEASE
+#define FSE_QUOTE(str) #str
+#define FSE_EXPAND_AND_QUOTE(str) FSE_QUOTE(str)
+#define FSE_VERSION_STRING FSE_EXPAND_AND_QUOTE(FSE_LIB_VERSION)
+
+#define FSE_VERSION_NUMBER (FSE_VERSION_MAJOR *100*100 + FSE_VERSION_MINOR *100 + FSE_VERSION_RELEASE)
+FSE_PUBLIC_API unsigned FSE_versionNumber(void); /**< library version number; to be used when checking dll version */
+
+
+/*-****************************************
+* FSE simple functions
+******************************************/
+/*! FSE_compress() :
+ Compress content of buffer 'src', of size 'srcSize', into destination buffer 'dst'.
+ 'dst' buffer must be already allocated. Compression runs faster is dstCapacity >= FSE_compressBound(srcSize).
+ @return : size of compressed data (<= dstCapacity).
+ Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!!
+ if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression instead.
+ if FSE_isError(return), compression failed (more details using FSE_getErrorName())
+*/
+FSE_PUBLIC_API size_t FSE_compress(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize);
+
+/*! FSE_decompress():
+ Decompress FSE data from buffer 'cSrc', of size 'cSrcSize',
+ into already allocated destination buffer 'dst', of size 'dstCapacity'.
+ @return : size of regenerated data (<= maxDstSize),
+ or an error code, which can be tested using FSE_isError() .
+
+ ** Important ** : FSE_decompress() does not decompress non-compressible nor RLE data !!!
+ Why ? : making this distinction requires a header.
+ Header management is intentionally delegated to the user layer, which can better manage special cases.
+*/
+FSE_PUBLIC_API size_t FSE_decompress(void* dst, size_t dstCapacity,
+ const void* cSrc, size_t cSrcSize);
+
+
+/*-*****************************************
+* Tool functions
+******************************************/
+FSE_PUBLIC_API size_t FSE_compressBound(size_t size); /* maximum compressed size */
+
+/* Error Management */
+FSE_PUBLIC_API unsigned FSE_isError(size_t code); /* tells if a return value is an error code */
+FSE_PUBLIC_API const char* FSE_getErrorName(size_t code); /* provides error code string (useful for debugging) */
+
+
+/*-*****************************************
+* FSE advanced functions
+******************************************/
+/*! FSE_compress2() :
+ Same as FSE_compress(), but allows the selection of 'maxSymbolValue' and 'tableLog'
+ Both parameters can be defined as '0' to mean : use default value
+ @return : size of compressed data
+ Special values : if return == 0, srcData is not compressible => Nothing is stored within cSrc !!!
+ if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression.
+ if FSE_isError(return), it's an error code.
+*/
+FSE_PUBLIC_API size_t FSE_compress2 (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog);
+
+
+/*-*****************************************
+* FSE detailed API
+******************************************/
+/*!
+FSE_compress() does the following:
+1. count symbol occurrence from source[] into table count[] (see hist.h)
+2. normalize counters so that sum(count[]) == Power_of_2 (2^tableLog)
+3. save normalized counters to memory buffer using writeNCount()
+4. build encoding table 'CTable' from normalized counters
+5. encode the data stream using encoding table 'CTable'
+
+FSE_decompress() does the following:
+1. read normalized counters with readNCount()
+2. build decoding table 'DTable' from normalized counters
+3. decode the data stream using decoding table 'DTable'
+
+The following API allows targeting specific sub-functions for advanced tasks.
+For example, it's possible to compress several blocks using the same 'CTable',
+or to save and provide normalized distribution using external method.
+*/
+
+/* *** COMPRESSION *** */
+
+/*! FSE_optimalTableLog():
+ dynamically downsize 'tableLog' when conditions are met.
+ It saves CPU time, by using smaller tables, while preserving or even improving compression ratio.
+ @return : recommended tableLog (necessarily <= 'maxTableLog') */
+FSE_PUBLIC_API unsigned FSE_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue);
+
+/*! FSE_normalizeCount():
+ normalize counts so that sum(count[]) == Power_of_2 (2^tableLog)
+ 'normalizedCounter' is a table of short, of minimum size (maxSymbolValue+1).
+ @return : tableLog,
+ or an errorCode, which can be tested using FSE_isError() */
+FSE_PUBLIC_API size_t FSE_normalizeCount(short* normalizedCounter, unsigned tableLog,
+ const unsigned* count, size_t srcSize, unsigned maxSymbolValue);
+
+/*! FSE_NCountWriteBound():
+ Provides the maximum possible size of an FSE normalized table, given 'maxSymbolValue' and 'tableLog'.
+ Typically useful for allocation purpose. */
+FSE_PUBLIC_API size_t FSE_NCountWriteBound(unsigned maxSymbolValue, unsigned tableLog);
+
+/*! FSE_writeNCount():
+ Compactly save 'normalizedCounter' into 'buffer'.
+ @return : size of the compressed table,
+ or an errorCode, which can be tested using FSE_isError(). */
+FSE_PUBLIC_API size_t FSE_writeNCount (void* buffer, size_t bufferSize,
+ const short* normalizedCounter,
+ unsigned maxSymbolValue, unsigned tableLog);
+
+/*! Constructor and Destructor of FSE_CTable.
+ Note that FSE_CTable size depends on 'tableLog' and 'maxSymbolValue' */
+typedef unsigned FSE_CTable; /* don't allocate that. It's only meant to be more restrictive than void* */
+FSE_PUBLIC_API FSE_CTable* FSE_createCTable (unsigned maxSymbolValue, unsigned tableLog);
+FSE_PUBLIC_API void FSE_freeCTable (FSE_CTable* ct);
+
+/*! FSE_buildCTable():
+ Builds `ct`, which must be already allocated, using FSE_createCTable().
+ @return : 0, or an errorCode, which can be tested using FSE_isError() */
+FSE_PUBLIC_API size_t FSE_buildCTable(FSE_CTable* ct, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
+
+/*! FSE_compress_usingCTable():
+ Compress `src` using `ct` into `dst` which must be already allocated.
+ @return : size of compressed data (<= `dstCapacity`),
+ or 0 if compressed data could not fit into `dst`,
+ or an errorCode, which can be tested using FSE_isError() */
+FSE_PUBLIC_API size_t FSE_compress_usingCTable (void* dst, size_t dstCapacity, const void* src, size_t srcSize, const FSE_CTable* ct);
+
+/*!
+Tutorial :
+----------
+The first step is to count all symbols. FSE_count() does this job very fast.
+Result will be saved into 'count', a table of unsigned int, which must be already allocated, and have 'maxSymbolValuePtr[0]+1' cells.
+'src' is a table of bytes of size 'srcSize'. All values within 'src' MUST be <= maxSymbolValuePtr[0]
+maxSymbolValuePtr[0] will be updated, with its real value (necessarily <= original value)
+FSE_count() will return the number of occurrence of the most frequent symbol.
+This can be used to know if there is a single symbol within 'src', and to quickly evaluate its compressibility.
+If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError()).
+
+The next step is to normalize the frequencies.
+FSE_normalizeCount() will ensure that sum of frequencies is == 2 ^'tableLog'.
+It also guarantees a minimum of 1 to any Symbol with frequency >= 1.
+You can use 'tableLog'==0 to mean "use default tableLog value".
+If you are unsure of which tableLog value to use, you can ask FSE_optimalTableLog(),
+which will provide the optimal valid tableLog given sourceSize, maxSymbolValue, and a user-defined maximum (0 means "default").
+
+The result of FSE_normalizeCount() will be saved into a table,
+called 'normalizedCounter', which is a table of signed short.
+'normalizedCounter' must be already allocated, and have at least 'maxSymbolValue+1' cells.
+The return value is tableLog if everything proceeded as expected.
+It is 0 if there is a single symbol within distribution.
+If there is an error (ex: invalid tableLog value), the function will return an ErrorCode (which can be tested using FSE_isError()).
+
+'normalizedCounter' can be saved in a compact manner to a memory area using FSE_writeNCount().
+'buffer' must be already allocated.
+For guaranteed success, buffer size must be at least FSE_headerBound().
+The result of the function is the number of bytes written into 'buffer'.
+If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError(); ex : buffer size too small).
+
+'normalizedCounter' can then be used to create the compression table 'CTable'.
+The space required by 'CTable' must be already allocated, using FSE_createCTable().
+You can then use FSE_buildCTable() to fill 'CTable'.
+If there is an error, both functions will return an ErrorCode (which can be tested using FSE_isError()).
+
+'CTable' can then be used to compress 'src', with FSE_compress_usingCTable().
+Similar to FSE_count(), the convention is that 'src' is assumed to be a table of char of size 'srcSize'
+The function returns the size of compressed data (without header), necessarily <= `dstCapacity`.
+If it returns '0', compressed data could not fit into 'dst'.
+If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError()).
+*/
+
+
+/* *** DECOMPRESSION *** */
+
+/*! FSE_readNCount():
+ Read compactly saved 'normalizedCounter' from 'rBuffer'.
+ @return : size read from 'rBuffer',
+ or an errorCode, which can be tested using FSE_isError().
+ maxSymbolValuePtr[0] and tableLogPtr[0] will also be updated with their respective values */
+FSE_PUBLIC_API size_t FSE_readNCount (short* normalizedCounter,
+ unsigned* maxSymbolValuePtr, unsigned* tableLogPtr,
+ const void* rBuffer, size_t rBuffSize);
+
+/*! Constructor and Destructor of FSE_DTable.
+ Note that its size depends on 'tableLog' */
+typedef unsigned FSE_DTable; /* don't allocate that. It's just a way to be more restrictive than void* */
+FSE_PUBLIC_API FSE_DTable* FSE_createDTable(unsigned tableLog);
+FSE_PUBLIC_API void FSE_freeDTable(FSE_DTable* dt);
+
+/*! FSE_buildDTable():
+ Builds 'dt', which must be already allocated, using FSE_createDTable().
+ return : 0, or an errorCode, which can be tested using FSE_isError() */
+FSE_PUBLIC_API size_t FSE_buildDTable (FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
+
+/*! FSE_decompress_usingDTable():
+ Decompress compressed source `cSrc` of size `cSrcSize` using `dt`
+ into `dst` which must be already allocated.
+ @return : size of regenerated data (necessarily <= `dstCapacity`),
+ or an errorCode, which can be tested using FSE_isError() */
+FSE_PUBLIC_API size_t FSE_decompress_usingDTable(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, const FSE_DTable* dt);
+
+/*!
+Tutorial :
+----------
+(Note : these functions only decompress FSE-compressed blocks.
+ If block is uncompressed, use memcpy() instead
+ If block is a single repeated byte, use memset() instead )
+
+The first step is to obtain the normalized frequencies of symbols.
+This can be performed by FSE_readNCount() if it was saved using FSE_writeNCount().
+'normalizedCounter' must be already allocated, and have at least 'maxSymbolValuePtr[0]+1' cells of signed short.
+In practice, that means it's necessary to know 'maxSymbolValue' beforehand,
+or size the table to handle worst case situations (typically 256).
+FSE_readNCount() will provide 'tableLog' and 'maxSymbolValue'.
+The result of FSE_readNCount() is the number of bytes read from 'rBuffer'.
+Note that 'rBufferSize' must be at least 4 bytes, even if useful information is less than that.
+If there is an error, the function will return an error code, which can be tested using FSE_isError().
+
+The next step is to build the decompression tables 'FSE_DTable' from 'normalizedCounter'.
+This is performed by the function FSE_buildDTable().
+The space required by 'FSE_DTable' must be already allocated using FSE_createDTable().
+If there is an error, the function will return an error code, which can be tested using FSE_isError().
+
+`FSE_DTable` can then be used to decompress `cSrc`, with FSE_decompress_usingDTable().
+`cSrcSize` must be strictly correct, otherwise decompression will fail.
+FSE_decompress_usingDTable() result will tell how many bytes were regenerated (<=`dstCapacity`).
+If there is an error, the function will return an error code, which can be tested using FSE_isError(). (ex: dst buffer too small)
+*/
+
+#endif /* FSE_H */
+
+#if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY)
+#define FSE_H_FSE_STATIC_LINKING_ONLY
+
+/* *** Dependency *** */
+#include "bitstream.h"
+
+
+/* *****************************************
+* Static allocation
+*******************************************/
+/* FSE buffer bounds */
+#define FSE_NCOUNTBOUND 512
+#define FSE_BLOCKBOUND(size) (size + (size>>7))
+#define FSE_COMPRESSBOUND(size) (FSE_NCOUNTBOUND + FSE_BLOCKBOUND(size)) /* Macro version, useful for static allocation */
+
+/* It is possible to statically allocate FSE CTable/DTable as a table of FSE_CTable/FSE_DTable using below macros */
+#define FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) (1 + (1<<(maxTableLog-1)) + ((maxSymbolValue+1)*2))
+#define FSE_DTABLE_SIZE_U32(maxTableLog) (1 + (1<<maxTableLog))
+
+/* or use the size to malloc() space directly. Pay attention to alignment restrictions though */
+#define FSE_CTABLE_SIZE(maxTableLog, maxSymbolValue) (FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) * sizeof(FSE_CTable))
+#define FSE_DTABLE_SIZE(maxTableLog) (FSE_DTABLE_SIZE_U32(maxTableLog) * sizeof(FSE_DTable))
+
+
+/* *****************************************
+ * FSE advanced API
+ ***************************************** */
+
+unsigned FSE_optimalTableLog_internal(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue, unsigned minus);
+/**< same as FSE_optimalTableLog(), which used `minus==2` */
+
+/* FSE_compress_wksp() :
+ * Same as FSE_compress2(), but using an externally allocated scratch buffer (`workSpace`).
+ * FSE_WKSP_SIZE_U32() provides the minimum size required for `workSpace` as a table of FSE_CTable.
+ */
+#define FSE_WKSP_SIZE_U32(maxTableLog, maxSymbolValue) ( FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) + ((maxTableLog > 12) ? (1 << (maxTableLog - 2)) : 1024) )
+size_t FSE_compress_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
+
+size_t FSE_buildCTable_raw (FSE_CTable* ct, unsigned nbBits);
+/**< build a fake FSE_CTable, designed for a flat distribution, where each symbol uses nbBits */
+
+size_t FSE_buildCTable_rle (FSE_CTable* ct, unsigned char symbolValue);
+/**< build a fake FSE_CTable, designed to compress always the same symbolValue */
+
+/* FSE_buildCTable_wksp() :
+ * Same as FSE_buildCTable(), but using an externally allocated scratch buffer (`workSpace`).
+ * `wkspSize` must be >= `(1<<tableLog)`.
+ */
+size_t FSE_buildCTable_wksp(FSE_CTable* ct, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
+
+size_t FSE_buildDTable_raw (FSE_DTable* dt, unsigned nbBits);
+/**< build a fake FSE_DTable, designed to read a flat distribution where each symbol uses nbBits */
+
+size_t FSE_buildDTable_rle (FSE_DTable* dt, unsigned char symbolValue);
+/**< build a fake FSE_DTable, designed to always generate the same symbolValue */
+
+size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, FSE_DTable* workSpace, unsigned maxLog);
+/**< same as FSE_decompress(), using an externally allocated `workSpace` produced with `FSE_DTABLE_SIZE_U32(maxLog)` */
+
+typedef enum {
+ FSE_repeat_none, /**< Cannot use the previous table */
+ FSE_repeat_check, /**< Can use the previous table but it must be checked */
+ FSE_repeat_valid /**< Can use the previous table and it is asumed to be valid */
+ } FSE_repeat;
+
+/* *****************************************
+* FSE symbol compression API
+*******************************************/
+/*!
+ This API consists of small unitary functions, which highly benefit from being inlined.
+ Hence their body are included in next section.
+*/
+typedef struct {
+ ptrdiff_t value;
+ const void* stateTable;
+ const void* symbolTT;
+ unsigned stateLog;
+} FSE_CState_t;
+
+static void FSE_initCState(FSE_CState_t* CStatePtr, const FSE_CTable* ct);
+
+static void FSE_encodeSymbol(BIT_CStream_t* bitC, FSE_CState_t* CStatePtr, unsigned symbol);
+
+static void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* CStatePtr);
+
+/**<
+These functions are inner components of FSE_compress_usingCTable().
+They allow the creation of custom streams, mixing multiple tables and bit sources.
+
+A key property to keep in mind is that encoding and decoding are done **in reverse direction**.
+So the first symbol you will encode is the last you will decode, like a LIFO stack.
+
+You will need a few variables to track your CStream. They are :
+
+FSE_CTable ct; // Provided by FSE_buildCTable()
+BIT_CStream_t bitStream; // bitStream tracking structure
+FSE_CState_t state; // State tracking structure (can have several)
+
+
+The first thing to do is to init bitStream and state.
+ size_t errorCode = BIT_initCStream(&bitStream, dstBuffer, maxDstSize);
+ FSE_initCState(&state, ct);
+
+Note that BIT_initCStream() can produce an error code, so its result should be tested, using FSE_isError();
+You can then encode your input data, byte after byte.
+FSE_encodeSymbol() outputs a maximum of 'tableLog' bits at a time.
+Remember decoding will be done in reverse direction.
+ FSE_encodeByte(&bitStream, &state, symbol);
+
+At any time, you can also add any bit sequence.
+Note : maximum allowed nbBits is 25, for compatibility with 32-bits decoders
+ BIT_addBits(&bitStream, bitField, nbBits);
+
+The above methods don't commit data to memory, they just store it into local register, for speed.
+Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t).
+Writing data to memory is a manual operation, performed by the flushBits function.
+ BIT_flushBits(&bitStream);
+
+Your last FSE encoding operation shall be to flush your last state value(s).
+ FSE_flushState(&bitStream, &state);
+
+Finally, you must close the bitStream.
+The function returns the size of CStream in bytes.
+If data couldn't fit into dstBuffer, it will return a 0 ( == not compressible)
+If there is an error, it returns an errorCode (which can be tested using FSE_isError()).
+ size_t size = BIT_closeCStream(&bitStream);
+*/
+
+
+/* *****************************************
+* FSE symbol decompression API
+*******************************************/
+typedef struct {
+ size_t state;
+ const void* table; /* precise table may vary, depending on U16 */
+} FSE_DState_t;
+
+
+static void FSE_initDState(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD, const FSE_DTable* dt);
+
+static unsigned char FSE_decodeSymbol(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD);
+
+static unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr);
+
+/**<
+Let's now decompose FSE_decompress_usingDTable() into its unitary components.
+You will decode FSE-encoded symbols from the bitStream,
+and also any other bitFields you put in, **in reverse order**.
+
+You will need a few variables to track your bitStream. They are :
+
+BIT_DStream_t DStream; // Stream context
+FSE_DState_t DState; // State context. Multiple ones are possible
+FSE_DTable* DTablePtr; // Decoding table, provided by FSE_buildDTable()
+
+The first thing to do is to init the bitStream.
+ errorCode = BIT_initDStream(&DStream, srcBuffer, srcSize);
+
+You should then retrieve your initial state(s)
+(in reverse flushing order if you have several ones) :
+ errorCode = FSE_initDState(&DState, &DStream, DTablePtr);
+
+You can then decode your data, symbol after symbol.
+For information the maximum number of bits read by FSE_decodeSymbol() is 'tableLog'.
+Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out).
+ unsigned char symbol = FSE_decodeSymbol(&DState, &DStream);
+
+You can retrieve any bitfield you eventually stored into the bitStream (in reverse order)
+Note : maximum allowed nbBits is 25, for 32-bits compatibility
+ size_t bitField = BIT_readBits(&DStream, nbBits);
+
+All above operations only read from local register (which size depends on size_t).
+Refueling the register from memory is manually performed by the reload method.
+ endSignal = FSE_reloadDStream(&DStream);
+
+BIT_reloadDStream() result tells if there is still some more data to read from DStream.
+BIT_DStream_unfinished : there is still some data left into the DStream.
+BIT_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled.
+BIT_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed.
+BIT_DStream_tooFar : Dstream went too far. Decompression result is corrupted.
+
+When reaching end of buffer (BIT_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop,
+to properly detect the exact end of stream.
+After each decoded symbol, check if DStream is fully consumed using this simple test :
+ BIT_reloadDStream(&DStream) >= BIT_DStream_completed
+
+When it's done, verify decompression is fully completed, by checking both DStream and the relevant states.
+Checking if DStream has reached its end is performed by :
+ BIT_endOfDStream(&DStream);
+Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible.
+ FSE_endOfDState(&DState);
+*/
+
+
+/* *****************************************
+* FSE unsafe API
+*******************************************/
+static unsigned char FSE_decodeSymbolFast(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD);
+/* faster, but works only if nbBits is always >= 1 (otherwise, result will be corrupted) */
+
+
+/* *****************************************
+* Implementation of inlined functions
+*******************************************/
+typedef struct {
+ int deltaFindState;
+ U32 deltaNbBits;
+} FSE_symbolCompressionTransform; /* total 8 bytes */
+
+MEM_STATIC void FSE_initCState(FSE_CState_t* statePtr, const FSE_CTable* ct)
+{
+ const void* ptr = ct;
+ const U16* u16ptr = (const U16*) ptr;
+ const U32 tableLog = MEM_read16(ptr);
+ statePtr->value = (ptrdiff_t)1<<tableLog;
+ statePtr->stateTable = u16ptr+2;
+ statePtr->symbolTT = ((const U32*)ct + 1 + (tableLog ? (1<<(tableLog-1)) : 1));
+ statePtr->stateLog = tableLog;
+}
+
+
+/*! FSE_initCState2() :
+* Same as FSE_initCState(), but the first symbol to include (which will be the last to be read)
+* uses the smallest state value possible, saving the cost of this symbol */
+MEM_STATIC void FSE_initCState2(FSE_CState_t* statePtr, const FSE_CTable* ct, U32 symbol)
+{
+ FSE_initCState(statePtr, ct);
+ { const FSE_symbolCompressionTransform symbolTT = ((const FSE_symbolCompressionTransform*)(statePtr->symbolTT))[symbol];
+ const U16* stateTable = (const U16*)(statePtr->stateTable);
+ U32 nbBitsOut = (U32)((symbolTT.deltaNbBits + (1<<15)) >> 16);
+ statePtr->value = (nbBitsOut << 16) - symbolTT.deltaNbBits;
+ statePtr->value = stateTable[(statePtr->value >> nbBitsOut) + symbolTT.deltaFindState];
+ }
+}
+
+MEM_STATIC void FSE_encodeSymbol(BIT_CStream_t* bitC, FSE_CState_t* statePtr, U32 symbol)
+{
+ FSE_symbolCompressionTransform const symbolTT = ((const FSE_symbolCompressionTransform*)(statePtr->symbolTT))[symbol];
+ const U16* const stateTable = (const U16*)(statePtr->stateTable);
+ U32 const nbBitsOut = (U32)((statePtr->value + symbolTT.deltaNbBits) >> 16);
+ BIT_addBits(bitC, statePtr->value, nbBitsOut);
+ statePtr->value = stateTable[ (statePtr->value >> nbBitsOut) + symbolTT.deltaFindState];
+}
+
+MEM_STATIC void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* statePtr)
+{
+ BIT_addBits(bitC, statePtr->value, statePtr->stateLog);
+ BIT_flushBits(bitC);
+}
+
+
+/* FSE_getMaxNbBits() :
+ * Approximate maximum cost of a symbol, in bits.
+ * Fractional get rounded up (i.e : a symbol with a normalized frequency of 3 gives the same result as a frequency of 2)
+ * note 1 : assume symbolValue is valid (<= maxSymbolValue)
+ * note 2 : if freq[symbolValue]==0, @return a fake cost of tableLog+1 bits */
+MEM_STATIC U32 FSE_getMaxNbBits(const void* symbolTTPtr, U32 symbolValue)
+{
+ const FSE_symbolCompressionTransform* symbolTT = (const FSE_symbolCompressionTransform*) symbolTTPtr;
+ return (symbolTT[symbolValue].deltaNbBits + ((1<<16)-1)) >> 16;
+}
+
+/* FSE_bitCost() :
+ * Approximate symbol cost, as fractional value, using fixed-point format (accuracyLog fractional bits)
+ * note 1 : assume symbolValue is valid (<= maxSymbolValue)
+ * note 2 : if freq[symbolValue]==0, @return a fake cost of tableLog+1 bits */
+MEM_STATIC U32 FSE_bitCost(const void* symbolTTPtr, U32 tableLog, U32 symbolValue, U32 accuracyLog)
+{
+ const FSE_symbolCompressionTransform* symbolTT = (const FSE_symbolCompressionTransform*) symbolTTPtr;
+ U32 const minNbBits = symbolTT[symbolValue].deltaNbBits >> 16;
+ U32 const threshold = (minNbBits+1) << 16;
+ assert(tableLog < 16);
+ assert(accuracyLog < 31-tableLog); /* ensure enough room for renormalization double shift */
+ { U32 const tableSize = 1 << tableLog;
+ U32 const deltaFromThreshold = threshold - (symbolTT[symbolValue].deltaNbBits + tableSize);
+ U32 const normalizedDeltaFromThreshold = (deltaFromThreshold << accuracyLog) >> tableLog; /* linear interpolation (very approximate) */
+ U32 const bitMultiplier = 1 << accuracyLog;
+ assert(symbolTT[symbolValue].deltaNbBits + tableSize <= threshold);
+ assert(normalizedDeltaFromThreshold <= bitMultiplier);
+ return (minNbBits+1)*bitMultiplier - normalizedDeltaFromThreshold;
+ }
+}
+
+
+/* ====== Decompression ====== */
+
+typedef struct {
+ U16 tableLog;
+ U16 fastMode;
+} FSE_DTableHeader; /* sizeof U32 */
+
+typedef struct
+{
+ unsigned short newState;
+ unsigned char symbol;
+ unsigned char nbBits;
+} FSE_decode_t; /* size == U32 */
+
+MEM_STATIC void FSE_initDState(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD, const FSE_DTable* dt)
+{
+ const void* ptr = dt;
+ const FSE_DTableHeader* const DTableH = (const FSE_DTableHeader*)ptr;
+ DStatePtr->state = BIT_readBits(bitD, DTableH->tableLog);
+ BIT_reloadDStream(bitD);
+ DStatePtr->table = dt + 1;
+}
+
+MEM_STATIC BYTE FSE_peekSymbol(const FSE_DState_t* DStatePtr)
+{
+ FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state];
+ return DInfo.symbol;
+}
+
+MEM_STATIC void FSE_updateState(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD)
+{
+ FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state];
+ U32 const nbBits = DInfo.nbBits;
+ size_t const lowBits = BIT_readBits(bitD, nbBits);
+ DStatePtr->state = DInfo.newState + lowBits;
+}
+
+MEM_STATIC BYTE FSE_decodeSymbol(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD)
+{
+ FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state];
+ U32 const nbBits = DInfo.nbBits;
+ BYTE const symbol = DInfo.symbol;
+ size_t const lowBits = BIT_readBits(bitD, nbBits);
+
+ DStatePtr->state = DInfo.newState + lowBits;
+ return symbol;
+}
+
+/*! FSE_decodeSymbolFast() :
+ unsafe, only works if no symbol has a probability > 50% */
+MEM_STATIC BYTE FSE_decodeSymbolFast(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD)
+{
+ FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state];
+ U32 const nbBits = DInfo.nbBits;
+ BYTE const symbol = DInfo.symbol;
+ size_t const lowBits = BIT_readBitsFast(bitD, nbBits);
+
+ DStatePtr->state = DInfo.newState + lowBits;
+ return symbol;
+}
+
+MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr)
+{
+ return DStatePtr->state == 0;
+}
+
+
+
+#ifndef FSE_COMMONDEFS_ONLY
+
+/* **************************************************************
+* Tuning parameters
+****************************************************************/
+/*!MEMORY_USAGE :
+* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.)
+* Increasing memory usage improves compression ratio
+* Reduced memory usage can improve speed, due to cache effect
+* Recommended max value is 14, for 16KB, which nicely fits into Intel x86 L1 cache */
+#ifndef FSE_MAX_MEMORY_USAGE
+# define FSE_MAX_MEMORY_USAGE 14
+#endif
+#ifndef FSE_DEFAULT_MEMORY_USAGE
+# define FSE_DEFAULT_MEMORY_USAGE 13
+#endif
+
+/*!FSE_MAX_SYMBOL_VALUE :
+* Maximum symbol value authorized.
+* Required for proper stack allocation */
+#ifndef FSE_MAX_SYMBOL_VALUE
+# define FSE_MAX_SYMBOL_VALUE 255
+#endif
+
+/* **************************************************************
+* template functions type & suffix
+****************************************************************/
+#define FSE_FUNCTION_TYPE BYTE
+#define FSE_FUNCTION_EXTENSION
+#define FSE_DECODE_TYPE FSE_decode_t
+
+
+#endif /* !FSE_COMMONDEFS_ONLY */
+
+
+/* ***************************************************************
+* Constants
+*****************************************************************/
+#define FSE_MAX_TABLELOG (FSE_MAX_MEMORY_USAGE-2)
+#define FSE_MAX_TABLESIZE (1U<<FSE_MAX_TABLELOG)
+#define FSE_MAXTABLESIZE_MASK (FSE_MAX_TABLESIZE-1)
+#define FSE_DEFAULT_TABLELOG (FSE_DEFAULT_MEMORY_USAGE-2)
+#define FSE_MIN_TABLELOG 5
+
+#define FSE_TABLELOG_ABSOLUTE_MAX 15
+#if FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX
+# error "FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX is not supported"
+#endif
+
+#define FSE_TABLESTEP(tableSize) ((tableSize>>1) + (tableSize>>3) + 3)
+
+
+#endif /* FSE_STATIC_LINKING_ONLY */
+
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/grub-core/lib/zstd/fse_decompress.c b/grub-core/lib/zstd/fse_decompress.c
new file mode 100644
index 0000000..2227b84
--- /dev/null
+++ b/grub-core/lib/zstd/fse_decompress.c
@@ -0,0 +1,309 @@
+/* ******************************************************************
+ FSE : Finite State Entropy decoder
+ Copyright (C) 2013-2015, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
+ - Public forum : https://groups.google.com/forum/#!forum/lz4c
+****************************************************************** */
+
+
+/* **************************************************************
+* Includes
+****************************************************************/
+#include <stdlib.h> /* malloc, free, qsort */
+#include <string.h> /* memcpy, memset */
+#include "bitstream.h"
+#include "compiler.h"
+#define FSE_STATIC_LINKING_ONLY
+#include "fse.h"
+#include "error_private.h"
+
+
+/* **************************************************************
+* Error Management
+****************************************************************/
+#define FSE_isError ERR_isError
+#define FSE_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c) /* use only *after* variable declarations */
+
+/* check and forward error code */
+#define CHECK_F(f) { size_t const e = f; if (FSE_isError(e)) return e; }
+
+
+/* **************************************************************
+* Templates
+****************************************************************/
+/*
+ designed to be included
+ for type-specific functions (template emulation in C)
+ Objective is to write these functions only once, for improved maintenance
+*/
+
+/* safety checks */
+#ifndef FSE_FUNCTION_EXTENSION
+# error "FSE_FUNCTION_EXTENSION must be defined"
+#endif
+#ifndef FSE_FUNCTION_TYPE
+# error "FSE_FUNCTION_TYPE must be defined"
+#endif
+
+/* Function names */
+#define FSE_CAT(X,Y) X##Y
+#define FSE_FUNCTION_NAME(X,Y) FSE_CAT(X,Y)
+#define FSE_TYPE_NAME(X,Y) FSE_CAT(X,Y)
+
+
+/* Function templates */
+FSE_DTable* FSE_createDTable (unsigned tableLog)
+{
+ if (tableLog > FSE_TABLELOG_ABSOLUTE_MAX) tableLog = FSE_TABLELOG_ABSOLUTE_MAX;
+ return (FSE_DTable*)calloc( FSE_DTABLE_SIZE_U32(tableLog), sizeof (U32) );
+}
+
+void FSE_freeDTable (FSE_DTable* dt)
+{
+ free(dt);
+}
+
+size_t FSE_buildDTable(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog)
+{
+ void* const tdPtr = dt+1; /* because *dt is unsigned, 32-bits aligned on 32-bits */
+ FSE_DECODE_TYPE* const tableDecode = (FSE_DECODE_TYPE*) (tdPtr);
+ U16 symbolNext[FSE_MAX_SYMBOL_VALUE+1];
+
+ U32 const maxSV1 = maxSymbolValue + 1;
+ U32 const tableSize = 1 << tableLog;
+ U32 highThreshold = tableSize-1;
+
+ /* Sanity Checks */
+ if (maxSymbolValue > FSE_MAX_SYMBOL_VALUE) return ERROR(maxSymbolValue_tooLarge);
+ if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge);
+
+ /* Init, lay down lowprob symbols */
+ { FSE_DTableHeader DTableH;
+ DTableH.tableLog = (U16)tableLog;
+ DTableH.fastMode = 1;
+ { S16 const largeLimit= (S16)(1 << (tableLog-1));
+ U32 s;
+ for (s=0; s<maxSV1; s++) {
+ if (normalizedCounter[s]==-1) {
+ tableDecode[highThreshold--].symbol = (FSE_FUNCTION_TYPE)s;
+ symbolNext[s] = 1;
+ } else {
+ if (normalizedCounter[s] >= largeLimit) DTableH.fastMode=0;
+ symbolNext[s] = normalizedCounter[s];
+ } } }
+ memcpy(dt, &DTableH, sizeof(DTableH));
+ }
+
+ /* Spread symbols */
+ { U32 const tableMask = tableSize-1;
+ U32 const step = FSE_TABLESTEP(tableSize);
+ U32 s, position = 0;
+ for (s=0; s<maxSV1; s++) {
+ int i;
+ for (i=0; i<normalizedCounter[s]; i++) {
+ tableDecode[position].symbol = (FSE_FUNCTION_TYPE)s;
+ position = (position + step) & tableMask;
+ while (position > highThreshold) position = (position + step) & tableMask; /* lowprob area */
+ } }
+ if (position!=0) return ERROR(GENERIC); /* position must reach all cells once, otherwise normalizedCounter is incorrect */
+ }
+
+ /* Build Decoding table */
+ { U32 u;
+ for (u=0; u<tableSize; u++) {
+ FSE_FUNCTION_TYPE const symbol = (FSE_FUNCTION_TYPE)(tableDecode[u].symbol);
+ U32 const nextState = symbolNext[symbol]++;
+ tableDecode[u].nbBits = (BYTE) (tableLog - BIT_highbit32(nextState) );
+ tableDecode[u].newState = (U16) ( (nextState << tableDecode[u].nbBits) - tableSize);
+ } }
+
+ return 0;
+}
+
+
+#ifndef FSE_COMMONDEFS_ONLY
+
+/*-*******************************************************
+* Decompression (Byte symbols)
+*********************************************************/
+size_t FSE_buildDTable_rle (FSE_DTable* dt, BYTE symbolValue)
+{
+ void* ptr = dt;
+ FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr;
+ void* dPtr = dt + 1;
+ FSE_decode_t* const cell = (FSE_decode_t*)dPtr;
+
+ DTableH->tableLog = 0;
+ DTableH->fastMode = 0;
+
+ cell->newState = 0;
+ cell->symbol = symbolValue;
+ cell->nbBits = 0;
+
+ return 0;
+}
+
+
+size_t FSE_buildDTable_raw (FSE_DTable* dt, unsigned nbBits)
+{
+ void* ptr = dt;
+ FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr;
+ void* dPtr = dt + 1;
+ FSE_decode_t* const dinfo = (FSE_decode_t*)dPtr;
+ const unsigned tableSize = 1 << nbBits;
+ const unsigned tableMask = tableSize - 1;
+ const unsigned maxSV1 = tableMask+1;
+ unsigned s;
+
+ /* Sanity checks */
+ if (nbBits < 1) return ERROR(GENERIC); /* min size */
+
+ /* Build Decoding Table */
+ DTableH->tableLog = (U16)nbBits;
+ DTableH->fastMode = 1;
+ for (s=0; s<maxSV1; s++) {
+ dinfo[s].newState = 0;
+ dinfo[s].symbol = (BYTE)s;
+ dinfo[s].nbBits = (BYTE)nbBits;
+ }
+
+ return 0;
+}
+
+FORCE_INLINE_TEMPLATE size_t FSE_decompress_usingDTable_generic(
+ void* dst, size_t maxDstSize,
+ const void* cSrc, size_t cSrcSize,
+ const FSE_DTable* dt, const unsigned fast)
+{
+ BYTE* const ostart = (BYTE*) dst;
+ BYTE* op = ostart;
+ BYTE* const omax = op + maxDstSize;
+ BYTE* const olimit = omax-3;
+
+ BIT_DStream_t bitD;
+ FSE_DState_t state1;
+ FSE_DState_t state2;
+
+ /* Init */
+ CHECK_F(BIT_initDStream(&bitD, cSrc, cSrcSize));
+
+ FSE_initDState(&state1, &bitD, dt);
+ FSE_initDState(&state2, &bitD, dt);
+
+#define FSE_GETSYMBOL(statePtr) fast ? FSE_decodeSymbolFast(statePtr, &bitD) : FSE_decodeSymbol(statePtr, &bitD)
+
+ /* 4 symbols per loop */
+ for ( ; (BIT_reloadDStream(&bitD)==BIT_DStream_unfinished) & (op<olimit) ; op+=4) {
+ op[0] = FSE_GETSYMBOL(&state1);
+
+ if (FSE_MAX_TABLELOG*2+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */
+ BIT_reloadDStream(&bitD);
+
+ op[1] = FSE_GETSYMBOL(&state2);
+
+ if (FSE_MAX_TABLELOG*4+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */
+ { if (BIT_reloadDStream(&bitD) > BIT_DStream_unfinished) { op+=2; break; } }
+
+ op[2] = FSE_GETSYMBOL(&state1);
+
+ if (FSE_MAX_TABLELOG*2+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */
+ BIT_reloadDStream(&bitD);
+
+ op[3] = FSE_GETSYMBOL(&state2);
+ }
+
+ /* tail */
+ /* note : BIT_reloadDStream(&bitD) >= FSE_DStream_partiallyFilled; Ends at exactly BIT_DStream_completed */
+ while (1) {
+ if (op>(omax-2)) return ERROR(dstSize_tooSmall);
+ *op++ = FSE_GETSYMBOL(&state1);
+ if (BIT_reloadDStream(&bitD)==BIT_DStream_overflow) {
+ *op++ = FSE_GETSYMBOL(&state2);
+ break;
+ }
+
+ if (op>(omax-2)) return ERROR(dstSize_tooSmall);
+ *op++ = FSE_GETSYMBOL(&state2);
+ if (BIT_reloadDStream(&bitD)==BIT_DStream_overflow) {
+ *op++ = FSE_GETSYMBOL(&state1);
+ break;
+ } }
+
+ return op-ostart;
+}
+
+
+size_t FSE_decompress_usingDTable(void* dst, size_t originalSize,
+ const void* cSrc, size_t cSrcSize,
+ const FSE_DTable* dt)
+{
+ const void* ptr = dt;
+ const FSE_DTableHeader* DTableH = (const FSE_DTableHeader*)ptr;
+ const U32 fastMode = DTableH->fastMode;
+
+ /* select fast mode (static) */
+ if (fastMode) return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 1);
+ return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 0);
+}
+
+
+size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, FSE_DTable* workSpace, unsigned maxLog)
+{
+ const BYTE* const istart = (const BYTE*)cSrc;
+ const BYTE* ip = istart;
+ short counting[FSE_MAX_SYMBOL_VALUE+1];
+ unsigned tableLog;
+ unsigned maxSymbolValue = FSE_MAX_SYMBOL_VALUE;
+
+ /* normal FSE decoding mode */
+ size_t const NCountLength = FSE_readNCount (counting, &maxSymbolValue, &tableLog, istart, cSrcSize);
+ if (FSE_isError(NCountLength)) return NCountLength;
+ //if (NCountLength >= cSrcSize) return ERROR(srcSize_wrong); /* too small input size; supposed to be already checked in NCountLength, only remaining case : NCountLength==cSrcSize */
+ if (tableLog > maxLog) return ERROR(tableLog_tooLarge);
+ ip += NCountLength;
+ cSrcSize -= NCountLength;
+
+ CHECK_F( FSE_buildDTable (workSpace, counting, maxSymbolValue, tableLog) );
+
+ return FSE_decompress_usingDTable (dst, dstCapacity, ip, cSrcSize, workSpace); /* always return, even if it is an error code */
+}
+
+
+typedef FSE_DTable DTable_max_t[FSE_DTABLE_SIZE_U32(FSE_MAX_TABLELOG)];
+
+size_t FSE_decompress(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize)
+{
+ DTable_max_t dt; /* Static analyzer seems unable to understand this table will be properly initialized later */
+ return FSE_decompress_wksp(dst, dstCapacity, cSrc, cSrcSize, dt, FSE_MAX_TABLELOG);
+}
+
+
+
+#endif /* FSE_COMMONDEFS_ONLY */
diff --git a/grub-core/lib/zstd/huf.h b/grub-core/lib/zstd/huf.h
new file mode 100644
index 0000000..de94641
--- /dev/null
+++ b/grub-core/lib/zstd/huf.h
@@ -0,0 +1,334 @@
+/* ******************************************************************
+ huff0 huffman codec,
+ part of Finite State Entropy library
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#ifndef HUF_H_298734234
+#define HUF_H_298734234
+
+/* *** Dependencies *** */
+#include <stddef.h> /* size_t */
+
+
+/* *** library symbols visibility *** */
+/* Note : when linking with -fvisibility=hidden on gcc, or by default on Visual,
+ * HUF symbols remain "private" (internal symbols for library only).
+ * Set macro FSE_DLL_EXPORT to 1 if you want HUF symbols visible on DLL interface */
+#if defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) && defined(__GNUC__) && (__GNUC__ >= 4)
+# define HUF_PUBLIC_API __attribute__ ((visibility ("default")))
+#elif defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) /* Visual expected */
+# define HUF_PUBLIC_API __declspec(dllexport)
+#elif defined(FSE_DLL_IMPORT) && (FSE_DLL_IMPORT==1)
+# define HUF_PUBLIC_API __declspec(dllimport) /* not required, just to generate faster code (saves a function pointer load from IAT and an indirect jump) */
+#else
+# define HUF_PUBLIC_API
+#endif
+
+
+/* ========================== */
+/* *** simple functions *** */
+/* ========================== */
+
+/** HUF_compress() :
+ * Compress content from buffer 'src', of size 'srcSize', into buffer 'dst'.
+ * 'dst' buffer must be already allocated.
+ * Compression runs faster if `dstCapacity` >= HUF_compressBound(srcSize).
+ * `srcSize` must be <= `HUF_BLOCKSIZE_MAX` == 128 KB.
+ * @return : size of compressed data (<= `dstCapacity`).
+ * Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!!
+ * if HUF_isError(return), compression failed (more details using HUF_getErrorName())
+ */
+HUF_PUBLIC_API size_t HUF_compress(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize);
+
+/** HUF_decompress() :
+ * Decompress HUF data from buffer 'cSrc', of size 'cSrcSize',
+ * into already allocated buffer 'dst', of minimum size 'dstSize'.
+ * `originalSize` : **must** be the ***exact*** size of original (uncompressed) data.
+ * Note : in contrast with FSE, HUF_decompress can regenerate
+ * RLE (cSrcSize==1) and uncompressed (cSrcSize==dstSize) data,
+ * because it knows size to regenerate (originalSize).
+ * @return : size of regenerated data (== originalSize),
+ * or an error code, which can be tested using HUF_isError()
+ */
+HUF_PUBLIC_API size_t HUF_decompress(void* dst, size_t originalSize,
+ const void* cSrc, size_t cSrcSize);
+
+
+/* *** Tool functions *** */
+#define HUF_BLOCKSIZE_MAX (128 * 1024) /**< maximum input size for a single block compressed with HUF_compress */
+HUF_PUBLIC_API size_t HUF_compressBound(size_t size); /**< maximum compressed size (worst case) */
+
+/* Error Management */
+HUF_PUBLIC_API unsigned HUF_isError(size_t code); /**< tells if a return value is an error code */
+HUF_PUBLIC_API const char* HUF_getErrorName(size_t code); /**< provides error code string (useful for debugging) */
+
+
+/* *** Advanced function *** */
+
+/** HUF_compress2() :
+ * Same as HUF_compress(), but offers control over `maxSymbolValue` and `tableLog`.
+ * `maxSymbolValue` must be <= HUF_SYMBOLVALUE_MAX .
+ * `tableLog` must be `<= HUF_TABLELOG_MAX` . */
+HUF_PUBLIC_API size_t HUF_compress2 (void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned tableLog);
+
+/** HUF_compress4X_wksp() :
+ * Same as HUF_compress2(), but uses externally allocated `workSpace`.
+ * `workspace` must have minimum alignment of 4, and be at least as large as HUF_WORKSPACE_SIZE */
+#define HUF_WORKSPACE_SIZE (6 << 10)
+#define HUF_WORKSPACE_SIZE_U32 (HUF_WORKSPACE_SIZE / sizeof(U32))
+HUF_PUBLIC_API size_t HUF_compress4X_wksp (void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned tableLog,
+ void* workSpace, size_t wkspSize);
+
+#endif /* HUF_H_298734234 */
+
+/* ******************************************************************
+ * WARNING !!
+ * The following section contains advanced and experimental definitions
+ * which shall never be used in the context of a dynamic library,
+ * because they are not guaranteed to remain stable in the future.
+ * Only consider them in association with static linking.
+ * *****************************************************************/
+#if defined(HUF_STATIC_LINKING_ONLY) && !defined(HUF_H_HUF_STATIC_LINKING_ONLY)
+#define HUF_H_HUF_STATIC_LINKING_ONLY
+
+/* *** Dependencies *** */
+#include "mem.h" /* U32 */
+
+
+/* *** Constants *** */
+#define HUF_TABLELOG_MAX 12 /* max runtime value of tableLog (due to static allocation); can be modified up to HUF_ABSOLUTEMAX_TABLELOG */
+#define HUF_TABLELOG_DEFAULT 11 /* default tableLog value when none specified */
+#define HUF_SYMBOLVALUE_MAX 255
+
+#define HUF_TABLELOG_ABSOLUTEMAX 15 /* absolute limit of HUF_MAX_TABLELOG. Beyond that value, code does not work */
+#if (HUF_TABLELOG_MAX > HUF_TABLELOG_ABSOLUTEMAX)
+# error "HUF_TABLELOG_MAX is too large !"
+#endif
+
+
+/* ****************************************
+* Static allocation
+******************************************/
+/* HUF buffer bounds */
+#define HUF_CTABLEBOUND 129
+#define HUF_BLOCKBOUND(size) (size + (size>>8) + 8) /* only true when incompressible is pre-filtered with fast heuristic */
+#define HUF_COMPRESSBOUND(size) (HUF_CTABLEBOUND + HUF_BLOCKBOUND(size)) /* Macro version, useful for static allocation */
+
+/* static allocation of HUF's Compression Table */
+#define HUF_CTABLE_SIZE_U32(maxSymbolValue) ((maxSymbolValue)+1) /* Use tables of U32, for proper alignment */
+#define HUF_CTABLE_SIZE(maxSymbolValue) (HUF_CTABLE_SIZE_U32(maxSymbolValue) * sizeof(U32))
+#define HUF_CREATE_STATIC_CTABLE(name, maxSymbolValue) \
+ U32 name##hb[HUF_CTABLE_SIZE_U32(maxSymbolValue)]; \
+ void* name##hv = &(name##hb); \
+ HUF_CElt* name = (HUF_CElt*)(name##hv) /* no final ; */
+
+/* static allocation of HUF's DTable */
+typedef U32 HUF_DTable;
+#define HUF_DTABLE_SIZE(maxTableLog) (1 + (1<<(maxTableLog)))
+#define HUF_CREATE_STATIC_DTABLEX1(DTable, maxTableLog) \
+ HUF_DTable DTable[HUF_DTABLE_SIZE((maxTableLog)-1)] = { ((U32)((maxTableLog)-1) * 0x01000001) }
+#define HUF_CREATE_STATIC_DTABLEX2(DTable, maxTableLog) \
+ HUF_DTable DTable[HUF_DTABLE_SIZE(maxTableLog)] = { ((U32)(maxTableLog) * 0x01000001) }
+
+
+/* ****************************************
+* Advanced decompression functions
+******************************************/
+size_t HUF_decompress4X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
+size_t HUF_decompress4X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
+
+size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< decodes RLE and uncompressed */
+size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< considers RLE and uncompressed as errors */
+size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< considers RLE and uncompressed as errors */
+size_t HUF_decompress4X1_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
+size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */
+size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
+size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */
+
+
+/* ****************************************
+ * HUF detailed API
+ * ****************************************/
+
+/*! HUF_compress() does the following:
+ * 1. count symbol occurrence from source[] into table count[] using FSE_count() (exposed within "fse.h")
+ * 2. (optional) refine tableLog using HUF_optimalTableLog()
+ * 3. build Huffman table from count using HUF_buildCTable()
+ * 4. save Huffman table to memory buffer using HUF_writeCTable()
+ * 5. encode the data stream using HUF_compress4X_usingCTable()
+ *
+ * The following API allows targeting specific sub-functions for advanced tasks.
+ * For example, it's possible to compress several blocks using the same 'CTable',
+ * or to save and regenerate 'CTable' using external methods.
+ */
+unsigned HUF_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue);
+typedef struct HUF_CElt_s HUF_CElt; /* incomplete type */
+size_t HUF_buildCTable (HUF_CElt* CTable, const unsigned* count, unsigned maxSymbolValue, unsigned maxNbBits); /* @return : maxNbBits; CTable and count can overlap. In which case, CTable will overwrite count content */
+size_t HUF_writeCTable (void* dst, size_t maxDstSize, const HUF_CElt* CTable, unsigned maxSymbolValue, unsigned huffLog);
+size_t HUF_compress4X_usingCTable(void* dst, size_t dstSize, const void* src, size_t srcSize, const HUF_CElt* CTable);
+
+typedef enum {
+ HUF_repeat_none, /**< Cannot use the previous table */
+ HUF_repeat_check, /**< Can use the previous table but it must be checked. Note : The previous table must have been constructed by HUF_compress{1, 4}X_repeat */
+ HUF_repeat_valid /**< Can use the previous table and it is assumed to be valid */
+ } HUF_repeat;
+/** HUF_compress4X_repeat() :
+ * Same as HUF_compress4X_wksp(), but considers using hufTable if *repeat != HUF_repeat_none.
+ * If it uses hufTable it does not modify hufTable or repeat.
+ * If it doesn't, it sets *repeat = HUF_repeat_none, and it sets hufTable to the table used.
+ * If preferRepeat then the old table will always be used if valid. */
+size_t HUF_compress4X_repeat(void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned tableLog,
+ void* workSpace, size_t wkspSize, /**< `workSpace` must be aligned on 4-bytes boundaries, `wkspSize` must be >= HUF_WORKSPACE_SIZE */
+ HUF_CElt* hufTable, HUF_repeat* repeat, int preferRepeat, int bmi2);
+
+/** HUF_buildCTable_wksp() :
+ * Same as HUF_buildCTable(), but using externally allocated scratch buffer.
+ * `workSpace` must be aligned on 4-bytes boundaries, and its size must be >= HUF_CTABLE_WORKSPACE_SIZE.
+ */
+#define HUF_CTABLE_WORKSPACE_SIZE_U32 (2*HUF_SYMBOLVALUE_MAX +1 +1)
+#define HUF_CTABLE_WORKSPACE_SIZE (HUF_CTABLE_WORKSPACE_SIZE_U32 * sizeof(unsigned))
+size_t HUF_buildCTable_wksp (HUF_CElt* tree,
+ const U32* count, U32 maxSymbolValue, U32 maxNbBits,
+ void* workSpace, size_t wkspSize);
+
+/*! HUF_readStats() :
+ * Read compact Huffman tree, saved by HUF_writeCTable().
+ * `huffWeight` is destination buffer.
+ * @return : size read from `src` , or an error Code .
+ * Note : Needed by HUF_readCTable() and HUF_readDTableXn() . */
+size_t HUF_readStats(BYTE* huffWeight, size_t hwSize,
+ U32* rankStats, U32* nbSymbolsPtr, U32* tableLogPtr,
+ const void* src, size_t srcSize);
+
+/** HUF_readCTable() :
+ * Loading a CTable saved with HUF_writeCTable() */
+size_t HUF_readCTable (HUF_CElt* CTable, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize);
+
+/** HUF_getNbBits() :
+ * Read nbBits from CTable symbolTable, for symbol `symbolValue` presumed <= HUF_SYMBOLVALUE_MAX
+ * Note 1 : is not inlined, as HUF_CElt definition is private
+ * Note 2 : const void* used, so that it can provide a statically allocated table as argument (which uses type U32) */
+U32 HUF_getNbBits(const void* symbolTable, U32 symbolValue);
+
+/*
+ * HUF_decompress() does the following:
+ * 1. select the decompression algorithm (X1, X2) based on pre-computed heuristics
+ * 2. build Huffman table from save, using HUF_readDTableX?()
+ * 3. decode 1 or 4 segments in parallel using HUF_decompress?X?_usingDTable()
+ */
+
+/** HUF_selectDecoder() :
+ * Tells which decoder is likely to decode faster,
+ * based on a set of pre-computed metrics.
+ * @return : 0==HUF_decompress4X1, 1==HUF_decompress4X2 .
+ * Assumption : 0 < dstSize <= 128 KB */
+U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize);
+
+/**
+ * The minimum workspace size for the `workSpace` used in
+ * HUF_readDTableX1_wksp() and HUF_readDTableX2_wksp().
+ *
+ * The space used depends on HUF_TABLELOG_MAX, ranging from ~1500 bytes when
+ * HUF_TABLE_LOG_MAX=12 to ~1850 bytes when HUF_TABLE_LOG_MAX=15.
+ * Buffer overflow errors may potentially occur if code modifications result in
+ * a required workspace size greater than that specified in the following
+ * macro.
+ */
+#define HUF_DECOMPRESS_WORKSPACE_SIZE (2 << 10)
+#define HUF_DECOMPRESS_WORKSPACE_SIZE_U32 (HUF_DECOMPRESS_WORKSPACE_SIZE / sizeof(U32))
+
+size_t HUF_readDTableX1 (HUF_DTable* DTable, const void* src, size_t srcSize);
+size_t HUF_readDTableX1_wksp (HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize);
+size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize);
+size_t HUF_readDTableX2_wksp (HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize);
+
+size_t HUF_decompress4X_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
+size_t HUF_decompress4X1_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
+size_t HUF_decompress4X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
+
+
+/* ====================== */
+/* single stream variants */
+/* ====================== */
+
+size_t HUF_compress1X (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog);
+size_t HUF_compress1X_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize); /**< `workSpace` must be a table of at least HUF_WORKSPACE_SIZE_U32 unsigned */
+size_t HUF_compress1X_usingCTable(void* dst, size_t dstSize, const void* src, size_t srcSize, const HUF_CElt* CTable);
+/** HUF_compress1X_repeat() :
+ * Same as HUF_compress1X_wksp(), but considers using hufTable if *repeat != HUF_repeat_none.
+ * If it uses hufTable it does not modify hufTable or repeat.
+ * If it doesn't, it sets *repeat = HUF_repeat_none, and it sets hufTable to the table used.
+ * If preferRepeat then the old table will always be used if valid. */
+size_t HUF_compress1X_repeat(void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned tableLog,
+ void* workSpace, size_t wkspSize, /**< `workSpace` must be aligned on 4-bytes boundaries, `wkspSize` must be >= HUF_WORKSPACE_SIZE */
+ HUF_CElt* hufTable, HUF_repeat* repeat, int preferRepeat, int bmi2);
+
+size_t HUF_decompress1X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /* single-symbol decoder */
+size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /* double-symbol decoder */
+
+size_t HUF_decompress1X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize);
+size_t HUF_decompress1X_DCtx_wksp (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize);
+size_t HUF_decompress1X1_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
+size_t HUF_decompress1X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */
+size_t HUF_decompress1X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
+size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */
+
+size_t HUF_decompress1X_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable); /**< automatic selection of sing or double symbol decoder, based on DTable */
+size_t HUF_decompress1X1_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
+size_t HUF_decompress1X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
+
+/* BMI2 variants.
+ * If the CPU has BMI2 support, pass bmi2=1, otherwise pass bmi2=0.
+ */
+size_t HUF_decompress1X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2);
+size_t HUF_decompress1X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2);
+size_t HUF_decompress4X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2);
+size_t HUF_decompress4X_hufOnly_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2);
+
+#endif /* HUF_STATIC_LINKING_ONLY */
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/grub-core/lib/zstd/huf_decompress.c b/grub-core/lib/zstd/huf_decompress.c
new file mode 100644
index 0000000..83ecaff
--- /dev/null
+++ b/grub-core/lib/zstd/huf_decompress.c
@@ -0,0 +1,1096 @@
+/* ******************************************************************
+ huff0 huffman decoder,
+ part of Finite State Entropy library
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+
+/* **************************************************************
+* Dependencies
+****************************************************************/
+#include <string.h> /* memcpy, memset */
+#include "compiler.h"
+#include "bitstream.h" /* BIT_* */
+#include "fse.h" /* to compress headers */
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h"
+#include "error_private.h"
+
+
+/* **************************************************************
+* Error Management
+****************************************************************/
+#define HUF_isError ERR_isError
+#define CHECK_F(f) { size_t const err_ = (f); if (HUF_isError(err_)) return err_; }
+
+
+/* **************************************************************
+* Byte alignment for workSpace management
+****************************************************************/
+#define HUF_ALIGN(x, a) HUF_ALIGN_MASK((x), (a) - 1)
+#define HUF_ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
+
+
+/*-***************************/
+/* generic DTableDesc */
+/*-***************************/
+typedef struct { BYTE maxTableLog; BYTE tableType; BYTE tableLog; BYTE reserved; } DTableDesc;
+
+static DTableDesc HUF_getDTableDesc(const HUF_DTable* table)
+{
+ DTableDesc dtd;
+ memcpy(&dtd, table, sizeof(dtd));
+ return dtd;
+}
+
+
+/*-***************************/
+/* single-symbol decoding */
+/*-***************************/
+typedef struct { BYTE byte; BYTE nbBits; } HUF_DEltX1; /* single-symbol decoding */
+
+size_t HUF_readDTableX1_wksp(HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize)
+{
+ U32 tableLog = 0;
+ U32 nbSymbols = 0;
+ size_t iSize;
+ void* const dtPtr = DTable + 1;
+ HUF_DEltX1* const dt = (HUF_DEltX1*)dtPtr;
+
+ U32* rankVal;
+ BYTE* huffWeight;
+ size_t spaceUsed32 = 0;
+
+ rankVal = (U32 *)workSpace + spaceUsed32;
+ spaceUsed32 += HUF_TABLELOG_ABSOLUTEMAX + 1;
+ huffWeight = (BYTE *)((U32 *)workSpace + spaceUsed32);
+ spaceUsed32 += HUF_ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2;
+
+ if ((spaceUsed32 << 2) > wkspSize) return ERROR(tableLog_tooLarge);
+
+ DEBUG_STATIC_ASSERT(sizeof(DTableDesc) == sizeof(HUF_DTable));
+ /* memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */
+
+ iSize = HUF_readStats(huffWeight, HUF_SYMBOLVALUE_MAX + 1, rankVal, &nbSymbols, &tableLog, src, srcSize);
+ if (HUF_isError(iSize)) return iSize;
+
+ /* Table header */
+ { DTableDesc dtd = HUF_getDTableDesc(DTable);
+ if (tableLog > (U32)(dtd.maxTableLog+1)) return ERROR(tableLog_tooLarge); /* DTable too small, Huffman tree cannot fit in */
+ dtd.tableType = 0;
+ dtd.tableLog = (BYTE)tableLog;
+ memcpy(DTable, &dtd, sizeof(dtd));
+ }
+
+ /* Calculate starting value for each rank */
+ { U32 n, nextRankStart = 0;
+ for (n=1; n<tableLog+1; n++) {
+ U32 const current = nextRankStart;
+ nextRankStart += (rankVal[n] << (n-1));
+ rankVal[n] = current;
+ } }
+
+ /* fill DTable */
+ { U32 n;
+ for (n=0; n<nbSymbols; n++) {
+ U32 const w = huffWeight[n];
+ U32 const length = (1 << w) >> 1;
+ U32 u;
+ HUF_DEltX1 D;
+ D.byte = (BYTE)n; D.nbBits = (BYTE)(tableLog + 1 - w);
+ for (u = rankVal[w]; u < rankVal[w] + length; u++)
+ dt[u] = D;
+ rankVal[w] += length;
+ } }
+
+ return iSize;
+}
+
+size_t HUF_readDTableX1(HUF_DTable* DTable, const void* src, size_t srcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_readDTableX1_wksp(DTable, src, srcSize,
+ workSpace, sizeof(workSpace));
+}
+
+FORCE_INLINE_TEMPLATE BYTE
+HUF_decodeSymbolX1(BIT_DStream_t* Dstream, const HUF_DEltX1* dt, const U32 dtLog)
+{
+ size_t const val = BIT_lookBitsFast(Dstream, dtLog); /* note : dtLog >= 1 */
+ BYTE const c = dt[val].byte;
+ BIT_skipBits(Dstream, dt[val].nbBits);
+ return c;
+}
+
+#define HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr) \
+ *ptr++ = HUF_decodeSymbolX1(DStreamPtr, dt, dtLog)
+
+#define HUF_DECODE_SYMBOLX1_1(ptr, DStreamPtr) \
+ if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \
+ HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr)
+
+#define HUF_DECODE_SYMBOLX1_2(ptr, DStreamPtr) \
+ if (MEM_64bits()) \
+ HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr)
+
+HINT_INLINE size_t
+HUF_decodeStreamX1(BYTE* p, BIT_DStream_t* const bitDPtr, BYTE* const pEnd, const HUF_DEltX1* const dt, const U32 dtLog)
+{
+ BYTE* const pStart = p;
+
+ /* up to 4 symbols at a time */
+ while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p < pEnd-3)) {
+ HUF_DECODE_SYMBOLX1_2(p, bitDPtr);
+ HUF_DECODE_SYMBOLX1_1(p, bitDPtr);
+ HUF_DECODE_SYMBOLX1_2(p, bitDPtr);
+ HUF_DECODE_SYMBOLX1_0(p, bitDPtr);
+ }
+
+ /* [0-3] symbols remaining */
+ if (MEM_32bits())
+ while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p < pEnd))
+ HUF_DECODE_SYMBOLX1_0(p, bitDPtr);
+
+ /* no more data to retrieve from bitstream, no need to reload */
+ while (p < pEnd)
+ HUF_DECODE_SYMBOLX1_0(p, bitDPtr);
+
+ return pEnd-pStart;
+}
+
+FORCE_INLINE_TEMPLATE size_t
+HUF_decompress1X1_usingDTable_internal_body(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ BYTE* op = (BYTE*)dst;
+ BYTE* const oend = op + dstSize;
+ const void* dtPtr = DTable + 1;
+ const HUF_DEltX1* const dt = (const HUF_DEltX1*)dtPtr;
+ BIT_DStream_t bitD;
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ U32 const dtLog = dtd.tableLog;
+
+ CHECK_F( BIT_initDStream(&bitD, cSrc, cSrcSize) );
+
+ HUF_decodeStreamX1(op, &bitD, oend, dt, dtLog);
+
+ if (!BIT_endOfDStream(&bitD)) return ERROR(corruption_detected);
+
+ return dstSize;
+}
+
+FORCE_INLINE_TEMPLATE size_t
+HUF_decompress4X1_usingDTable_internal_body(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ /* Check */
+ if (cSrcSize < 10) return ERROR(corruption_detected); /* strict minimum : jump table + 1 byte per stream */
+
+ { const BYTE* const istart = (const BYTE*) cSrc;
+ BYTE* const ostart = (BYTE*) dst;
+ BYTE* const oend = ostart + dstSize;
+ const void* const dtPtr = DTable + 1;
+ const HUF_DEltX1* const dt = (const HUF_DEltX1*)dtPtr;
+
+ /* Init */
+ BIT_DStream_t bitD1;
+ BIT_DStream_t bitD2;
+ BIT_DStream_t bitD3;
+ BIT_DStream_t bitD4;
+ size_t const length1 = MEM_readLE16(istart);
+ size_t const length2 = MEM_readLE16(istart+2);
+ size_t const length3 = MEM_readLE16(istart+4);
+ size_t const length4 = cSrcSize - (length1 + length2 + length3 + 6);
+ const BYTE* const istart1 = istart + 6; /* jumpTable */
+ const BYTE* const istart2 = istart1 + length1;
+ const BYTE* const istart3 = istart2 + length2;
+ const BYTE* const istart4 = istart3 + length3;
+ const size_t segmentSize = (dstSize+3) / 4;
+ BYTE* const opStart2 = ostart + segmentSize;
+ BYTE* const opStart3 = opStart2 + segmentSize;
+ BYTE* const opStart4 = opStart3 + segmentSize;
+ BYTE* op1 = ostart;
+ BYTE* op2 = opStart2;
+ BYTE* op3 = opStart3;
+ BYTE* op4 = opStart4;
+ U32 endSignal = BIT_DStream_unfinished;
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ U32 const dtLog = dtd.tableLog;
+
+ if (length4 > cSrcSize) return ERROR(corruption_detected); /* overflow */
+ CHECK_F( BIT_initDStream(&bitD1, istart1, length1) );
+ CHECK_F( BIT_initDStream(&bitD2, istart2, length2) );
+ CHECK_F( BIT_initDStream(&bitD3, istart3, length3) );
+ CHECK_F( BIT_initDStream(&bitD4, istart4, length4) );
+
+ /* up to 16 symbols per loop (4 symbols per stream) in 64-bit mode */
+ endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4);
+ while ( (endSignal==BIT_DStream_unfinished) && (op4<(oend-3)) ) {
+ HUF_DECODE_SYMBOLX1_2(op1, &bitD1);
+ HUF_DECODE_SYMBOLX1_2(op2, &bitD2);
+ HUF_DECODE_SYMBOLX1_2(op3, &bitD3);
+ HUF_DECODE_SYMBOLX1_2(op4, &bitD4);
+ HUF_DECODE_SYMBOLX1_1(op1, &bitD1);
+ HUF_DECODE_SYMBOLX1_1(op2, &bitD2);
+ HUF_DECODE_SYMBOLX1_1(op3, &bitD3);
+ HUF_DECODE_SYMBOLX1_1(op4, &bitD4);
+ HUF_DECODE_SYMBOLX1_2(op1, &bitD1);
+ HUF_DECODE_SYMBOLX1_2(op2, &bitD2);
+ HUF_DECODE_SYMBOLX1_2(op3, &bitD3);
+ HUF_DECODE_SYMBOLX1_2(op4, &bitD4);
+ HUF_DECODE_SYMBOLX1_0(op1, &bitD1);
+ HUF_DECODE_SYMBOLX1_0(op2, &bitD2);
+ HUF_DECODE_SYMBOLX1_0(op3, &bitD3);
+ HUF_DECODE_SYMBOLX1_0(op4, &bitD4);
+ BIT_reloadDStream(&bitD1);
+ BIT_reloadDStream(&bitD2);
+ BIT_reloadDStream(&bitD3);
+ BIT_reloadDStream(&bitD4);
+ }
+
+ /* check corruption */
+ /* note : should not be necessary : op# advance in lock step, and we control op4.
+ * but curiously, binary generated by gcc 7.2 & 7.3 with -mbmi2 runs faster when >=1 test is present */
+ if (op1 > opStart2) return ERROR(corruption_detected);
+ if (op2 > opStart3) return ERROR(corruption_detected);
+ if (op3 > opStart4) return ERROR(corruption_detected);
+ /* note : op4 supposed already verified within main loop */
+
+ /* finish bitStreams one by one */
+ HUF_decodeStreamX1(op1, &bitD1, opStart2, dt, dtLog);
+ HUF_decodeStreamX1(op2, &bitD2, opStart3, dt, dtLog);
+ HUF_decodeStreamX1(op3, &bitD3, opStart4, dt, dtLog);
+ HUF_decodeStreamX1(op4, &bitD4, oend, dt, dtLog);
+
+ /* check */
+ { U32 const endCheck = BIT_endOfDStream(&bitD1) & BIT_endOfDStream(&bitD2) & BIT_endOfDStream(&bitD3) & BIT_endOfDStream(&bitD4);
+ if (!endCheck) return ERROR(corruption_detected); }
+
+ /* decoded size */
+ return dstSize;
+ }
+}
+
+
+typedef size_t (*HUF_decompress_usingDTable_t)(void *dst, size_t dstSize,
+ const void *cSrc,
+ size_t cSrcSize,
+ const HUF_DTable *DTable);
+#if DYNAMIC_BMI2
+
+#define HUF_DGEN(fn) \
+ \
+ static size_t fn##_default( \
+ void* dst, size_t dstSize, \
+ const void* cSrc, size_t cSrcSize, \
+ const HUF_DTable* DTable) \
+ { \
+ return fn##_body(dst, dstSize, cSrc, cSrcSize, DTable); \
+ } \
+ \
+ static TARGET_ATTRIBUTE("bmi2") size_t fn##_bmi2( \
+ void* dst, size_t dstSize, \
+ const void* cSrc, size_t cSrcSize, \
+ const HUF_DTable* DTable) \
+ { \
+ return fn##_body(dst, dstSize, cSrc, cSrcSize, DTable); \
+ } \
+ \
+ static size_t fn(void* dst, size_t dstSize, void const* cSrc, \
+ size_t cSrcSize, HUF_DTable const* DTable, int bmi2) \
+ { \
+ if (bmi2) { \
+ return fn##_bmi2(dst, dstSize, cSrc, cSrcSize, DTable); \
+ } \
+ return fn##_default(dst, dstSize, cSrc, cSrcSize, DTable); \
+ }
+
+#else
+
+#define HUF_DGEN(fn) \
+ static size_t fn(void* dst, size_t dstSize, void const* cSrc, \
+ size_t cSrcSize, HUF_DTable const* DTable, int bmi2) \
+ { \
+ (void)bmi2; \
+ return fn##_body(dst, dstSize, cSrc, cSrcSize, DTable); \
+ }
+
+#endif
+
+HUF_DGEN(HUF_decompress1X1_usingDTable_internal)
+HUF_DGEN(HUF_decompress4X1_usingDTable_internal)
+
+
+
+size_t HUF_decompress1X1_usingDTable(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc dtd = HUF_getDTableDesc(DTable);
+ if (dtd.tableType != 0) return ERROR(GENERIC);
+ return HUF_decompress1X1_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+}
+
+size_t HUF_decompress1X1_DCtx_wksp(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
+{
+ const BYTE* ip = (const BYTE*) cSrc;
+
+ size_t const hSize = HUF_readDTableX1_wksp(DCtx, cSrc, cSrcSize, workSpace, wkspSize);
+ if (HUF_isError(hSize)) return hSize;
+ if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
+ ip += hSize; cSrcSize -= hSize;
+
+ return HUF_decompress1X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, DCtx, /* bmi2 */ 0);
+}
+
+
+size_t HUF_decompress1X1_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress1X1_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+size_t HUF_decompress1X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ HUF_CREATE_STATIC_DTABLEX1(DTable, HUF_TABLELOG_MAX);
+ return HUF_decompress1X1_DCtx (DTable, dst, dstSize, cSrc, cSrcSize);
+}
+
+size_t HUF_decompress4X1_usingDTable(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc dtd = HUF_getDTableDesc(DTable);
+ if (dtd.tableType != 0) return ERROR(GENERIC);
+ return HUF_decompress4X1_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+}
+
+static size_t HUF_decompress4X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize, int bmi2)
+{
+ const BYTE* ip = (const BYTE*) cSrc;
+
+ size_t const hSize = HUF_readDTableX1_wksp (dctx, cSrc, cSrcSize,
+ workSpace, wkspSize);
+ if (HUF_isError(hSize)) return hSize;
+ if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
+ ip += hSize; cSrcSize -= hSize;
+
+ return HUF_decompress4X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2);
+}
+
+size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
+{
+ return HUF_decompress4X1_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, 0);
+}
+
+
+size_t HUF_decompress4X1_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+size_t HUF_decompress4X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ HUF_CREATE_STATIC_DTABLEX1(DTable, HUF_TABLELOG_MAX);
+ return HUF_decompress4X1_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
+}
+
+
+/* *************************/
+/* double-symbols decoding */
+/* *************************/
+
+typedef struct { U16 sequence; BYTE nbBits; BYTE length; } HUF_DEltX2; /* double-symbols decoding */
+typedef struct { BYTE symbol; BYTE weight; } sortedSymbol_t;
+typedef U32 rankValCol_t[HUF_TABLELOG_MAX + 1];
+typedef rankValCol_t rankVal_t[HUF_TABLELOG_MAX];
+
+
+/* HUF_fillDTableX2Level2() :
+ * `rankValOrigin` must be a table of at least (HUF_TABLELOG_MAX + 1) U32 */
+static void HUF_fillDTableX2Level2(HUF_DEltX2* DTable, U32 sizeLog, const U32 consumed,
+ const U32* rankValOrigin, const int minWeight,
+ const sortedSymbol_t* sortedSymbols, const U32 sortedListSize,
+ U32 nbBitsBaseline, U16 baseSeq)
+{
+ HUF_DEltX2 DElt;
+ U32 rankVal[HUF_TABLELOG_MAX + 1];
+
+ /* get pre-calculated rankVal */
+ memcpy(rankVal, rankValOrigin, sizeof(rankVal));
+
+ /* fill skipped values */
+ if (minWeight>1) {
+ U32 i, skipSize = rankVal[minWeight];
+ MEM_writeLE16(&(DElt.sequence), baseSeq);
+ DElt.nbBits = (BYTE)(consumed);
+ DElt.length = 1;
+ for (i = 0; i < skipSize; i++)
+ DTable[i] = DElt;
+ }
+
+ /* fill DTable */
+ { U32 s; for (s=0; s<sortedListSize; s++) { /* note : sortedSymbols already skipped */
+ const U32 symbol = sortedSymbols[s].symbol;
+ const U32 weight = sortedSymbols[s].weight;
+ const U32 nbBits = nbBitsBaseline - weight;
+ const U32 length = 1 << (sizeLog-nbBits);
+ const U32 start = rankVal[weight];
+ U32 i = start;
+ const U32 end = start + length;
+
+ MEM_writeLE16(&(DElt.sequence), (U16)(baseSeq + (symbol << 8)));
+ DElt.nbBits = (BYTE)(nbBits + consumed);
+ DElt.length = 2;
+ do { DTable[i++] = DElt; } while (i<end); /* since length >= 1 */
+
+ rankVal[weight] += length;
+ } }
+}
+
+
+static void HUF_fillDTableX2(HUF_DEltX2* DTable, const U32 targetLog,
+ const sortedSymbol_t* sortedList, const U32 sortedListSize,
+ const U32* rankStart, rankVal_t rankValOrigin, const U32 maxWeight,
+ const U32 nbBitsBaseline)
+{
+ U32 rankVal[HUF_TABLELOG_MAX + 1];
+ const int scaleLog = nbBitsBaseline - targetLog; /* note : targetLog >= srcLog, hence scaleLog <= 1 */
+ const U32 minBits = nbBitsBaseline - maxWeight;
+ U32 s;
+
+ memcpy(rankVal, rankValOrigin, sizeof(rankVal));
+
+ /* fill DTable */
+ for (s=0; s<sortedListSize; s++) {
+ const U16 symbol = sortedList[s].symbol;
+ const U32 weight = sortedList[s].weight;
+ const U32 nbBits = nbBitsBaseline - weight;
+ const U32 start = rankVal[weight];
+ const U32 length = 1 << (targetLog-nbBits);
+
+ if (targetLog-nbBits >= minBits) { /* enough room for a second symbol */
+ U32 sortedRank;
+ int minWeight = nbBits + scaleLog;
+ if (minWeight < 1) minWeight = 1;
+ sortedRank = rankStart[minWeight];
+ HUF_fillDTableX2Level2(DTable+start, targetLog-nbBits, nbBits,
+ rankValOrigin[nbBits], minWeight,
+ sortedList+sortedRank, sortedListSize-sortedRank,
+ nbBitsBaseline, symbol);
+ } else {
+ HUF_DEltX2 DElt;
+ MEM_writeLE16(&(DElt.sequence), symbol);
+ DElt.nbBits = (BYTE)(nbBits);
+ DElt.length = 1;
+ { U32 const end = start + length;
+ U32 u;
+ for (u = start; u < end; u++) DTable[u] = DElt;
+ } }
+ rankVal[weight] += length;
+ }
+}
+
+size_t HUF_readDTableX2_wksp(HUF_DTable* DTable,
+ const void* src, size_t srcSize,
+ void* workSpace, size_t wkspSize)
+{
+ U32 tableLog, maxW, sizeOfSort, nbSymbols;
+ DTableDesc dtd = HUF_getDTableDesc(DTable);
+ U32 const maxTableLog = dtd.maxTableLog;
+ size_t iSize;
+ void* dtPtr = DTable+1; /* force compiler to avoid strict-aliasing */
+ HUF_DEltX2* const dt = (HUF_DEltX2*)dtPtr;
+ U32 *rankStart;
+
+ rankValCol_t* rankVal;
+ U32* rankStats;
+ U32* rankStart0;
+ sortedSymbol_t* sortedSymbol;
+ BYTE* weightList;
+ size_t spaceUsed32 = 0;
+
+ rankVal = (rankValCol_t *)((U32 *)workSpace + spaceUsed32);
+ spaceUsed32 += (sizeof(rankValCol_t) * HUF_TABLELOG_MAX) >> 2;
+ rankStats = (U32 *)workSpace + spaceUsed32;
+ spaceUsed32 += HUF_TABLELOG_MAX + 1;
+ rankStart0 = (U32 *)workSpace + spaceUsed32;
+ spaceUsed32 += HUF_TABLELOG_MAX + 2;
+ sortedSymbol = (sortedSymbol_t *)workSpace + (spaceUsed32 * sizeof(U32)) / sizeof(sortedSymbol_t);
+ spaceUsed32 += HUF_ALIGN(sizeof(sortedSymbol_t) * (HUF_SYMBOLVALUE_MAX + 1), sizeof(U32)) >> 2;
+ weightList = (BYTE *)((U32 *)workSpace + spaceUsed32);
+ spaceUsed32 += HUF_ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2;
+
+ if ((spaceUsed32 << 2) > wkspSize) return ERROR(tableLog_tooLarge);
+
+ rankStart = rankStart0 + 1;
+ memset(rankStats, 0, sizeof(U32) * (2 * HUF_TABLELOG_MAX + 2 + 1));
+
+ DEBUG_STATIC_ASSERT(sizeof(HUF_DEltX2) == sizeof(HUF_DTable)); /* if compiler fails here, assertion is wrong */
+ if (maxTableLog > HUF_TABLELOG_MAX) return ERROR(tableLog_tooLarge);
+ /* memset(weightList, 0, sizeof(weightList)); */ /* is not necessary, even though some analyzer complain ... */
+
+ iSize = HUF_readStats(weightList, HUF_SYMBOLVALUE_MAX + 1, rankStats, &nbSymbols, &tableLog, src, srcSize);
+ if (HUF_isError(iSize)) return iSize;
+
+ /* check result */
+ if (tableLog > maxTableLog) return ERROR(tableLog_tooLarge); /* DTable can't fit code depth */
+
+ /* find maxWeight */
+ for (maxW = tableLog; rankStats[maxW]==0; maxW--) {} /* necessarily finds a solution before 0 */
+
+ /* Get start index of each weight */
+ { U32 w, nextRankStart = 0;
+ for (w=1; w<maxW+1; w++) {
+ U32 current = nextRankStart;
+ nextRankStart += rankStats[w];
+ rankStart[w] = current;
+ }
+ rankStart[0] = nextRankStart; /* put all 0w symbols at the end of sorted list*/
+ sizeOfSort = nextRankStart;
+ }
+
+ /* sort symbols by weight */
+ { U32 s;
+ for (s=0; s<nbSymbols; s++) {
+ U32 const w = weightList[s];
+ U32 const r = rankStart[w]++;
+ sortedSymbol[r].symbol = (BYTE)s;
+ sortedSymbol[r].weight = (BYTE)w;
+ }
+ rankStart[0] = 0; /* forget 0w symbols; this is beginning of weight(1) */
+ }
+
+ /* Build rankVal */
+ { U32* const rankVal0 = rankVal[0];
+ { int const rescale = (maxTableLog-tableLog) - 1; /* tableLog <= maxTableLog */
+ U32 nextRankVal = 0;
+ U32 w;
+ for (w=1; w<maxW+1; w++) {
+ U32 current = nextRankVal;
+ nextRankVal += rankStats[w] << (w+rescale);
+ rankVal0[w] = current;
+ } }
+ { U32 const minBits = tableLog+1 - maxW;
+ U32 consumed;
+ for (consumed = minBits; consumed < maxTableLog - minBits + 1; consumed++) {
+ U32* const rankValPtr = rankVal[consumed];
+ U32 w;
+ for (w = 1; w < maxW+1; w++) {
+ rankValPtr[w] = rankVal0[w] >> consumed;
+ } } } }
+
+ HUF_fillDTableX2(dt, maxTableLog,
+ sortedSymbol, sizeOfSort,
+ rankStart0, rankVal, maxW,
+ tableLog+1);
+
+ dtd.tableLog = (BYTE)maxTableLog;
+ dtd.tableType = 1;
+ memcpy(DTable, &dtd, sizeof(dtd));
+ return iSize;
+}
+
+size_t HUF_readDTableX2(HUF_DTable* DTable, const void* src, size_t srcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_readDTableX2_wksp(DTable, src, srcSize,
+ workSpace, sizeof(workSpace));
+}
+
+
+FORCE_INLINE_TEMPLATE U32
+HUF_decodeSymbolX2(void* op, BIT_DStream_t* DStream, const HUF_DEltX2* dt, const U32 dtLog)
+{
+ size_t const val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */
+ memcpy(op, dt+val, 2);
+ BIT_skipBits(DStream, dt[val].nbBits);
+ return dt[val].length;
+}
+
+FORCE_INLINE_TEMPLATE U32
+HUF_decodeLastSymbolX2(void* op, BIT_DStream_t* DStream, const HUF_DEltX2* dt, const U32 dtLog)
+{
+ size_t const val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */
+ memcpy(op, dt+val, 1);
+ if (dt[val].length==1) BIT_skipBits(DStream, dt[val].nbBits);
+ else {
+ if (DStream->bitsConsumed < (sizeof(DStream->bitContainer)*8)) {
+ BIT_skipBits(DStream, dt[val].nbBits);
+ if (DStream->bitsConsumed > (sizeof(DStream->bitContainer)*8))
+ /* ugly hack; works only because it's the last symbol. Note : can't easily extract nbBits from just this symbol */
+ DStream->bitsConsumed = (sizeof(DStream->bitContainer)*8);
+ } }
+ return 1;
+}
+
+#define HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr) \
+ ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog)
+
+#define HUF_DECODE_SYMBOLX2_1(ptr, DStreamPtr) \
+ if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \
+ ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog)
+
+#define HUF_DECODE_SYMBOLX2_2(ptr, DStreamPtr) \
+ if (MEM_64bits()) \
+ ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog)
+
+HINT_INLINE size_t
+HUF_decodeStreamX2(BYTE* p, BIT_DStream_t* bitDPtr, BYTE* const pEnd,
+ const HUF_DEltX2* const dt, const U32 dtLog)
+{
+ BYTE* const pStart = p;
+
+ /* up to 8 symbols at a time */
+ while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p < pEnd-(sizeof(bitDPtr->bitContainer)-1))) {
+ HUF_DECODE_SYMBOLX2_2(p, bitDPtr);
+ HUF_DECODE_SYMBOLX2_1(p, bitDPtr);
+ HUF_DECODE_SYMBOLX2_2(p, bitDPtr);
+ HUF_DECODE_SYMBOLX2_0(p, bitDPtr);
+ }
+
+ /* closer to end : up to 2 symbols at a time */
+ while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p <= pEnd-2))
+ HUF_DECODE_SYMBOLX2_0(p, bitDPtr);
+
+ while (p <= pEnd-2)
+ HUF_DECODE_SYMBOLX2_0(p, bitDPtr); /* no need to reload : reached the end of DStream */
+
+ if (p < pEnd)
+ p += HUF_decodeLastSymbolX2(p, bitDPtr, dt, dtLog);
+
+ return p-pStart;
+}
+
+FORCE_INLINE_TEMPLATE size_t
+HUF_decompress1X2_usingDTable_internal_body(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ BIT_DStream_t bitD;
+
+ /* Init */
+ CHECK_F( BIT_initDStream(&bitD, cSrc, cSrcSize) );
+
+ /* decode */
+ { BYTE* const ostart = (BYTE*) dst;
+ BYTE* const oend = ostart + dstSize;
+ const void* const dtPtr = DTable+1; /* force compiler to not use strict-aliasing */
+ const HUF_DEltX2* const dt = (const HUF_DEltX2*)dtPtr;
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ HUF_decodeStreamX2(ostart, &bitD, oend, dt, dtd.tableLog);
+ }
+
+ /* check */
+ if (!BIT_endOfDStream(&bitD)) return ERROR(corruption_detected);
+
+ /* decoded size */
+ return dstSize;
+}
+
+
+FORCE_INLINE_TEMPLATE size_t
+HUF_decompress4X2_usingDTable_internal_body(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ if (cSrcSize < 10) return ERROR(corruption_detected); /* strict minimum : jump table + 1 byte per stream */
+
+ { const BYTE* const istart = (const BYTE*) cSrc;
+ BYTE* const ostart = (BYTE*) dst;
+ BYTE* const oend = ostart + dstSize;
+ const void* const dtPtr = DTable+1;
+ const HUF_DEltX2* const dt = (const HUF_DEltX2*)dtPtr;
+
+ /* Init */
+ BIT_DStream_t bitD1;
+ BIT_DStream_t bitD2;
+ BIT_DStream_t bitD3;
+ BIT_DStream_t bitD4;
+ size_t const length1 = MEM_readLE16(istart);
+ size_t const length2 = MEM_readLE16(istart+2);
+ size_t const length3 = MEM_readLE16(istart+4);
+ size_t const length4 = cSrcSize - (length1 + length2 + length3 + 6);
+ const BYTE* const istart1 = istart + 6; /* jumpTable */
+ const BYTE* const istart2 = istart1 + length1;
+ const BYTE* const istart3 = istart2 + length2;
+ const BYTE* const istart4 = istart3 + length3;
+ size_t const segmentSize = (dstSize+3) / 4;
+ BYTE* const opStart2 = ostart + segmentSize;
+ BYTE* const opStart3 = opStart2 + segmentSize;
+ BYTE* const opStart4 = opStart3 + segmentSize;
+ BYTE* op1 = ostart;
+ BYTE* op2 = opStart2;
+ BYTE* op3 = opStart3;
+ BYTE* op4 = opStart4;
+ U32 endSignal;
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ U32 const dtLog = dtd.tableLog;
+
+ if (length4 > cSrcSize) return ERROR(corruption_detected); /* overflow */
+ CHECK_F( BIT_initDStream(&bitD1, istart1, length1) );
+ CHECK_F( BIT_initDStream(&bitD2, istart2, length2) );
+ CHECK_F( BIT_initDStream(&bitD3, istart3, length3) );
+ CHECK_F( BIT_initDStream(&bitD4, istart4, length4) );
+
+ /* 16-32 symbols per loop (4-8 symbols per stream) */
+ endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4);
+ for ( ; (endSignal==BIT_DStream_unfinished) & (op4<(oend-(sizeof(bitD4.bitContainer)-1))) ; ) {
+ HUF_DECODE_SYMBOLX2_2(op1, &bitD1);
+ HUF_DECODE_SYMBOLX2_2(op2, &bitD2);
+ HUF_DECODE_SYMBOLX2_2(op3, &bitD3);
+ HUF_DECODE_SYMBOLX2_2(op4, &bitD4);
+ HUF_DECODE_SYMBOLX2_1(op1, &bitD1);
+ HUF_DECODE_SYMBOLX2_1(op2, &bitD2);
+ HUF_DECODE_SYMBOLX2_1(op3, &bitD3);
+ HUF_DECODE_SYMBOLX2_1(op4, &bitD4);
+ HUF_DECODE_SYMBOLX2_2(op1, &bitD1);
+ HUF_DECODE_SYMBOLX2_2(op2, &bitD2);
+ HUF_DECODE_SYMBOLX2_2(op3, &bitD3);
+ HUF_DECODE_SYMBOLX2_2(op4, &bitD4);
+ HUF_DECODE_SYMBOLX2_0(op1, &bitD1);
+ HUF_DECODE_SYMBOLX2_0(op2, &bitD2);
+ HUF_DECODE_SYMBOLX2_0(op3, &bitD3);
+ HUF_DECODE_SYMBOLX2_0(op4, &bitD4);
+
+ endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4);
+ }
+
+ /* check corruption */
+ if (op1 > opStart2) return ERROR(corruption_detected);
+ if (op2 > opStart3) return ERROR(corruption_detected);
+ if (op3 > opStart4) return ERROR(corruption_detected);
+ /* note : op4 already verified within main loop */
+
+ /* finish bitStreams one by one */
+ HUF_decodeStreamX2(op1, &bitD1, opStart2, dt, dtLog);
+ HUF_decodeStreamX2(op2, &bitD2, opStart3, dt, dtLog);
+ HUF_decodeStreamX2(op3, &bitD3, opStart4, dt, dtLog);
+ HUF_decodeStreamX2(op4, &bitD4, oend, dt, dtLog);
+
+ /* check */
+ { U32 const endCheck = BIT_endOfDStream(&bitD1) & BIT_endOfDStream(&bitD2) & BIT_endOfDStream(&bitD3) & BIT_endOfDStream(&bitD4);
+ if (!endCheck) return ERROR(corruption_detected); }
+
+ /* decoded size */
+ return dstSize;
+ }
+}
+
+HUF_DGEN(HUF_decompress1X2_usingDTable_internal)
+HUF_DGEN(HUF_decompress4X2_usingDTable_internal)
+
+size_t HUF_decompress1X2_usingDTable(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc dtd = HUF_getDTableDesc(DTable);
+ if (dtd.tableType != 1) return ERROR(GENERIC);
+ return HUF_decompress1X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+}
+
+size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
+{
+ const BYTE* ip = (const BYTE*) cSrc;
+
+ size_t const hSize = HUF_readDTableX2_wksp(DCtx, cSrc, cSrcSize,
+ workSpace, wkspSize);
+ if (HUF_isError(hSize)) return hSize;
+ if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
+ ip += hSize; cSrcSize -= hSize;
+
+ return HUF_decompress1X2_usingDTable_internal(dst, dstSize, ip, cSrcSize, DCtx, /* bmi2 */ 0);
+}
+
+
+size_t HUF_decompress1X2_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress1X2_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX);
+ return HUF_decompress1X2_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
+}
+
+size_t HUF_decompress4X2_usingDTable(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc dtd = HUF_getDTableDesc(DTable);
+ if (dtd.tableType != 1) return ERROR(GENERIC);
+ return HUF_decompress4X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+}
+
+static size_t HUF_decompress4X2_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize, int bmi2)
+{
+ const BYTE* ip = (const BYTE*) cSrc;
+
+ size_t hSize = HUF_readDTableX2_wksp(dctx, cSrc, cSrcSize,
+ workSpace, wkspSize);
+ if (HUF_isError(hSize)) return hSize;
+ if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
+ ip += hSize; cSrcSize -= hSize;
+
+ return HUF_decompress4X2_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2);
+}
+
+size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
+{
+ return HUF_decompress4X2_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, /* bmi2 */ 0);
+}
+
+
+size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+size_t HUF_decompress4X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX);
+ return HUF_decompress4X2_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
+}
+
+
+/* ***********************************/
+/* Universal decompression selectors */
+/* ***********************************/
+
+size_t HUF_decompress1X_usingDTable(void* dst, size_t maxDstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ return dtd.tableType ? HUF_decompress1X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0) :
+ HUF_decompress1X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+}
+
+size_t HUF_decompress4X_usingDTable(void* dst, size_t maxDstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ return dtd.tableType ? HUF_decompress4X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0) :
+ HUF_decompress4X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+}
+
+
+typedef struct { U32 tableTime; U32 decode256Time; } algo_time_t;
+static const algo_time_t algoTime[16 /* Quantization */][3 /* single, double, quad */] =
+{
+ /* single, double, quad */
+ {{0,0}, {1,1}, {2,2}}, /* Q==0 : impossible */
+ {{0,0}, {1,1}, {2,2}}, /* Q==1 : impossible */
+ {{ 38,130}, {1313, 74}, {2151, 38}}, /* Q == 2 : 12-18% */
+ {{ 448,128}, {1353, 74}, {2238, 41}}, /* Q == 3 : 18-25% */
+ {{ 556,128}, {1353, 74}, {2238, 47}}, /* Q == 4 : 25-32% */
+ {{ 714,128}, {1418, 74}, {2436, 53}}, /* Q == 5 : 32-38% */
+ {{ 883,128}, {1437, 74}, {2464, 61}}, /* Q == 6 : 38-44% */
+ {{ 897,128}, {1515, 75}, {2622, 68}}, /* Q == 7 : 44-50% */
+ {{ 926,128}, {1613, 75}, {2730, 75}}, /* Q == 8 : 50-56% */
+ {{ 947,128}, {1729, 77}, {3359, 77}}, /* Q == 9 : 56-62% */
+ {{1107,128}, {2083, 81}, {4006, 84}}, /* Q ==10 : 62-69% */
+ {{1177,128}, {2379, 87}, {4785, 88}}, /* Q ==11 : 69-75% */
+ {{1242,128}, {2415, 93}, {5155, 84}}, /* Q ==12 : 75-81% */
+ {{1349,128}, {2644,106}, {5260,106}}, /* Q ==13 : 81-87% */
+ {{1455,128}, {2422,124}, {4174,124}}, /* Q ==14 : 87-93% */
+ {{ 722,128}, {1891,145}, {1936,146}}, /* Q ==15 : 93-99% */
+};
+
+/** HUF_selectDecoder() :
+ * Tells which decoder is likely to decode faster,
+ * based on a set of pre-computed metrics.
+ * @return : 0==HUF_decompress4X1, 1==HUF_decompress4X2 .
+ * Assumption : 0 < dstSize <= 128 KB */
+U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize)
+{
+ assert(dstSize > 0);
+ assert(dstSize <= 128*1024);
+ /* decoder timing evaluation */
+ { U32 const Q = (cSrcSize >= dstSize) ? 15 : (U32)(cSrcSize * 16 / dstSize); /* Q < 16 */
+ U32 const D256 = (U32)(dstSize >> 8);
+ U32 const DTime0 = algoTime[Q][0].tableTime + (algoTime[Q][0].decode256Time * D256);
+ U32 DTime1 = algoTime[Q][1].tableTime + (algoTime[Q][1].decode256Time * D256);
+ DTime1 += DTime1 >> 3; /* advantage to algorithm using less memory, to reduce cache eviction */
+ return DTime1 < DTime0;
+} }
+
+
+typedef size_t (*decompressionAlgo)(void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize);
+
+size_t HUF_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ static const decompressionAlgo decompress[2] = { HUF_decompress4X1, HUF_decompress4X2 };
+
+ /* validation checks */
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
+ if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
+ if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
+ if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
+
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
+ return decompress[algoNb](dst, dstSize, cSrc, cSrcSize);
+ }
+}
+
+size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ /* validation checks */
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
+ if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
+ if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
+ if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
+
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
+ return algoNb ? HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) :
+ HUF_decompress4X1_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) ;
+ }
+}
+
+size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress4X_hufOnly_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+
+size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst,
+ size_t dstSize, const void* cSrc,
+ size_t cSrcSize, void* workSpace,
+ size_t wkspSize)
+{
+ /* validation checks */
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
+ if (cSrcSize == 0) return ERROR(corruption_detected);
+
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
+ return algoNb ? HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize):
+ HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize);
+ }
+}
+
+size_t HUF_decompress1X_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
+{
+ /* validation checks */
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
+ if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
+ if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
+ if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
+
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
+ return algoNb ? HUF_decompress1X2_DCtx_wksp(dctx, dst, dstSize, cSrc,
+ cSrcSize, workSpace, wkspSize):
+ HUF_decompress1X1_DCtx_wksp(dctx, dst, dstSize, cSrc,
+ cSrcSize, workSpace, wkspSize);
+ }
+}
+
+size_t HUF_decompress1X_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress1X_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+
+size_t HUF_decompress1X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2)
+{
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ return dtd.tableType ? HUF_decompress1X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2) :
+ HUF_decompress1X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2);
+}
+
+size_t HUF_decompress1X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2)
+{
+ const BYTE* ip = (const BYTE*) cSrc;
+
+ size_t const hSize = HUF_readDTableX1_wksp(dctx, cSrc, cSrcSize, workSpace, wkspSize);
+ if (HUF_isError(hSize)) return hSize;
+ if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
+ ip += hSize; cSrcSize -= hSize;
+
+ return HUF_decompress1X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2);
+}
+
+size_t HUF_decompress4X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2)
+{
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ return dtd.tableType ? HUF_decompress4X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2) :
+ HUF_decompress4X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2);
+}
+
+size_t HUF_decompress4X_hufOnly_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2)
+{
+ /* validation checks */
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
+ if (cSrcSize == 0) return ERROR(corruption_detected);
+
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
+ return algoNb ? HUF_decompress4X2_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2) :
+ HUF_decompress4X1_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2);
+ }
+}
diff --git a/grub-core/lib/zstd/mem.h b/grub-core/lib/zstd/mem.h
new file mode 100644
index 0000000..2051bca
--- /dev/null
+++ b/grub-core/lib/zstd/mem.h
@@ -0,0 +1,374 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef MEM_H_MODULE
+#define MEM_H_MODULE
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/*-****************************************
+* Dependencies
+******************************************/
+#include <stddef.h> /* size_t, ptrdiff_t */
+#include <string.h> /* memcpy */
+
+
+/*-****************************************
+* Compiler specifics
+******************************************/
+#if defined(_MSC_VER) /* Visual Studio */
+# include <stdlib.h> /* _byteswap_ulong */
+# include <intrin.h> /* _byteswap_* */
+#endif
+#if defined(__GNUC__)
+# define MEM_STATIC static __inline __attribute__((unused))
+#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
+# define MEM_STATIC static inline
+#elif defined(_MSC_VER)
+# define MEM_STATIC static __inline
+#else
+# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
+#endif
+
+/* code only tested on 32 and 64 bits systems */
+#define MEM_STATIC_ASSERT(c) { enum { MEM_static_assert = 1/(int)(!!(c)) }; }
+MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (sizeof(size_t)==8)); }
+
+
+/*-**************************************************************
+* Basic Types
+*****************************************************************/
+#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
+# include <stdint.h>
+ typedef uint8_t BYTE;
+ typedef uint16_t U16;
+ typedef int16_t S16;
+ typedef uint32_t U32;
+ typedef int32_t S32;
+ typedef uint64_t U64;
+ typedef int64_t S64;
+#else
+# include <limits.h>
+#if CHAR_BIT != 8
+# error "this implementation requires char to be exactly 8-bit type"
+#endif
+ typedef unsigned char BYTE;
+#if USHRT_MAX != 65535
+# error "this implementation requires short to be exactly 16-bit type"
+#endif
+ typedef unsigned short U16;
+ typedef signed short S16;
+#if UINT_MAX != 4294967295
+# error "this implementation requires int to be exactly 32-bit type"
+#endif
+ typedef unsigned int U32;
+ typedef signed int S32;
+/* note : there are no limits defined for long long type in C90.
+ * limits exist in C99, however, in such case, <stdint.h> is preferred */
+ typedef unsigned long long U64;
+ typedef signed long long S64;
+#endif
+
+
+/*-**************************************************************
+* Memory I/O
+*****************************************************************/
+/* MEM_FORCE_MEMORY_ACCESS :
+ * By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
+ * Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
+ * The below switch allow to select different access method for improved performance.
+ * Method 0 (default) : use `memcpy()`. Safe and portable.
+ * Method 1 : `__packed` statement. It depends on compiler extension (i.e., not portable).
+ * This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
+ * Method 2 : direct access. This method is portable but violate C standard.
+ * It can generate buggy code on targets depending on alignment.
+ * In some circumstances, it's the only known way to get the most performance (i.e. GCC + ARMv6)
+ * See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details.
+ * Prefer these methods in priority order (0 > 1 > 2)
+ */
+#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
+# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
+# define MEM_FORCE_MEMORY_ACCESS 2
+# elif defined(__INTEL_COMPILER) || defined(__GNUC__)
+# define MEM_FORCE_MEMORY_ACCESS 1
+# endif
+#endif
+
+MEM_STATIC unsigned MEM_32bits(void) { return sizeof(size_t)==4; }
+MEM_STATIC unsigned MEM_64bits(void) { return sizeof(size_t)==8; }
+
+MEM_STATIC unsigned MEM_isLittleEndian(void)
+{
+ const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
+ return one.c[0];
+}
+
+#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
+
+/* violates C standard, by lying on structure alignment.
+Only use if no other choice to achieve best performance on target platform */
+MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
+MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
+MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
+MEM_STATIC size_t MEM_readST(const void* memPtr) { return *(const size_t*) memPtr; }
+
+MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
+MEM_STATIC void MEM_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
+MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; }
+
+#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
+
+/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
+/* currently only defined for gcc and icc */
+#if defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(WIN32))
+ __pragma( pack(push, 1) )
+ typedef struct { U16 v; } unalign16;
+ typedef struct { U32 v; } unalign32;
+ typedef struct { U64 v; } unalign64;
+ typedef struct { size_t v; } unalignArch;
+ __pragma( pack(pop) )
+#else
+ typedef struct { U16 v; } __attribute__((packed)) unalign16;
+ typedef struct { U32 v; } __attribute__((packed)) unalign32;
+ typedef struct { U64 v; } __attribute__((packed)) unalign64;
+ typedef struct { size_t v; } __attribute__((packed)) unalignArch;
+#endif
+
+MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign16*)ptr)->v; }
+MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign32*)ptr)->v; }
+MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign64*)ptr)->v; }
+MEM_STATIC size_t MEM_readST(const void* ptr) { return ((const unalignArch*)ptr)->v; }
+
+MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign16*)memPtr)->v = value; }
+MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign32*)memPtr)->v = value; }
+MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((unalign64*)memPtr)->v = value; }
+
+#else
+
+/* default method, safe and standard.
+ can sometimes prove slower */
+
+MEM_STATIC U16 MEM_read16(const void* memPtr)
+{
+ U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
+}
+
+MEM_STATIC U32 MEM_read32(const void* memPtr)
+{
+ U32 val; memcpy(&val, memPtr, sizeof(val)); return val;
+}
+
+MEM_STATIC U64 MEM_read64(const void* memPtr)
+{
+ U64 val; memcpy(&val, memPtr, sizeof(val)); return val;
+}
+
+MEM_STATIC size_t MEM_readST(const void* memPtr)
+{
+ size_t val; memcpy(&val, memPtr, sizeof(val)); return val;
+}
+
+MEM_STATIC void MEM_write16(void* memPtr, U16 value)
+{
+ memcpy(memPtr, &value, sizeof(value));
+}
+
+MEM_STATIC void MEM_write32(void* memPtr, U32 value)
+{
+ memcpy(memPtr, &value, sizeof(value));
+}
+
+MEM_STATIC void MEM_write64(void* memPtr, U64 value)
+{
+ memcpy(memPtr, &value, sizeof(value));
+}
+
+#endif /* MEM_FORCE_MEMORY_ACCESS */
+
+MEM_STATIC U32 MEM_swap32(U32 in)
+{
+#if defined(_MSC_VER) /* Visual Studio */
+ return _byteswap_ulong(in);
+#elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)
+ return __builtin_bswap32(in);
+#else
+ return ((in << 24) & 0xff000000 ) |
+ ((in << 8) & 0x00ff0000 ) |
+ ((in >> 8) & 0x0000ff00 ) |
+ ((in >> 24) & 0x000000ff );
+#endif
+}
+
+MEM_STATIC U64 MEM_swap64(U64 in)
+{
+#if defined(_MSC_VER) /* Visual Studio */
+ return _byteswap_uint64(in);
+#elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)
+ return __builtin_bswap64(in);
+#else
+ return ((in << 56) & 0xff00000000000000ULL) |
+ ((in << 40) & 0x00ff000000000000ULL) |
+ ((in << 24) & 0x0000ff0000000000ULL) |
+ ((in << 8) & 0x000000ff00000000ULL) |
+ ((in >> 8) & 0x00000000ff000000ULL) |
+ ((in >> 24) & 0x0000000000ff0000ULL) |
+ ((in >> 40) & 0x000000000000ff00ULL) |
+ ((in >> 56) & 0x00000000000000ffULL);
+#endif
+}
+
+MEM_STATIC size_t MEM_swapST(size_t in)
+{
+ if (MEM_32bits())
+ return (size_t)MEM_swap32((U32)in);
+ else
+ return (size_t)MEM_swap64((U64)in);
+}
+
+/*=== Little endian r/w ===*/
+
+MEM_STATIC U16 MEM_readLE16(const void* memPtr)
+{
+ if (MEM_isLittleEndian())
+ return MEM_read16(memPtr);
+ else {
+ const BYTE* p = (const BYTE*)memPtr;
+ return (U16)(p[0] + (p[1]<<8));
+ }
+}
+
+MEM_STATIC void MEM_writeLE16(void* memPtr, U16 val)
+{
+ if (MEM_isLittleEndian()) {
+ MEM_write16(memPtr, val);
+ } else {
+ BYTE* p = (BYTE*)memPtr;
+ p[0] = (BYTE)val;
+ p[1] = (BYTE)(val>>8);
+ }
+}
+
+MEM_STATIC U32 MEM_readLE24(const void* memPtr)
+{
+ return MEM_readLE16(memPtr) + (((const BYTE*)memPtr)[2] << 16);
+}
+
+MEM_STATIC void MEM_writeLE24(void* memPtr, U32 val)
+{
+ MEM_writeLE16(memPtr, (U16)val);
+ ((BYTE*)memPtr)[2] = (BYTE)(val>>16);
+}
+
+MEM_STATIC U32 MEM_readLE32(const void* memPtr)
+{
+ if (MEM_isLittleEndian())
+ return MEM_read32(memPtr);
+ else
+ return MEM_swap32(MEM_read32(memPtr));
+}
+
+MEM_STATIC void MEM_writeLE32(void* memPtr, U32 val32)
+{
+ if (MEM_isLittleEndian())
+ MEM_write32(memPtr, val32);
+ else
+ MEM_write32(memPtr, MEM_swap32(val32));
+}
+
+MEM_STATIC U64 MEM_readLE64(const void* memPtr)
+{
+ if (MEM_isLittleEndian())
+ return MEM_read64(memPtr);
+ else
+ return MEM_swap64(MEM_read64(memPtr));
+}
+
+MEM_STATIC void MEM_writeLE64(void* memPtr, U64 val64)
+{
+ if (MEM_isLittleEndian())
+ MEM_write64(memPtr, val64);
+ else
+ MEM_write64(memPtr, MEM_swap64(val64));
+}
+
+MEM_STATIC size_t MEM_readLEST(const void* memPtr)
+{
+ if (MEM_32bits())
+ return (size_t)MEM_readLE32(memPtr);
+ else
+ return (size_t)MEM_readLE64(memPtr);
+}
+
+MEM_STATIC void MEM_writeLEST(void* memPtr, size_t val)
+{
+ if (MEM_32bits())
+ MEM_writeLE32(memPtr, (U32)val);
+ else
+ MEM_writeLE64(memPtr, (U64)val);
+}
+
+/*=== Big endian r/w ===*/
+
+MEM_STATIC U32 MEM_readBE32(const void* memPtr)
+{
+ if (MEM_isLittleEndian())
+ return MEM_swap32(MEM_read32(memPtr));
+ else
+ return MEM_read32(memPtr);
+}
+
+MEM_STATIC void MEM_writeBE32(void* memPtr, U32 val32)
+{
+ if (MEM_isLittleEndian())
+ MEM_write32(memPtr, MEM_swap32(val32));
+ else
+ MEM_write32(memPtr, val32);
+}
+
+MEM_STATIC U64 MEM_readBE64(const void* memPtr)
+{
+ if (MEM_isLittleEndian())
+ return MEM_swap64(MEM_read64(memPtr));
+ else
+ return MEM_read64(memPtr);
+}
+
+MEM_STATIC void MEM_writeBE64(void* memPtr, U64 val64)
+{
+ if (MEM_isLittleEndian())
+ MEM_write64(memPtr, MEM_swap64(val64));
+ else
+ MEM_write64(memPtr, val64);
+}
+
+MEM_STATIC size_t MEM_readBEST(const void* memPtr)
+{
+ if (MEM_32bits())
+ return (size_t)MEM_readBE32(memPtr);
+ else
+ return (size_t)MEM_readBE64(memPtr);
+}
+
+MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val)
+{
+ if (MEM_32bits())
+ MEM_writeBE32(memPtr, (U32)val);
+ else
+ MEM_writeBE64(memPtr, (U64)val);
+}
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* MEM_H_MODULE */
diff --git a/grub-core/lib/zstd/module.c b/grub-core/lib/zstd/module.c
new file mode 100644
index 0000000..e64d068
--- /dev/null
+++ b/grub-core/lib/zstd/module.c
@@ -0,0 +1,21 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3");
diff --git a/grub-core/lib/zstd/xxhash.c b/grub-core/lib/zstd/xxhash.c
new file mode 100644
index 0000000..532b816
--- /dev/null
+++ b/grub-core/lib/zstd/xxhash.c
@@ -0,0 +1,876 @@
+/*
+* xxHash - Fast Hash algorithm
+* Copyright (C) 2012-2016, Yann Collet
+*
+* BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are
+* met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following disclaimer
+* in the documentation and/or other materials provided with the
+* distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+* You can contact the author at :
+* - xxHash homepage: http://www.xxhash.com
+* - xxHash source repository : https://github.com/Cyan4973/xxHash
+*/
+
+
+/* *************************************
+* Tuning parameters
+***************************************/
+/*!XXH_FORCE_MEMORY_ACCESS :
+ * By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
+ * Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
+ * The below switch allow to select different access method for improved performance.
+ * Method 0 (default) : use `memcpy()`. Safe and portable.
+ * Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable).
+ * This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
+ * Method 2 : direct access. This method doesn't depend on compiler but violate C standard.
+ * It can generate buggy code on targets which do not support unaligned memory accesses.
+ * But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6)
+ * See http://stackoverflow.com/a/32095106/646947 for details.
+ * Prefer these methods in priority order (0 > 1 > 2)
+ */
+#ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
+# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
+# define XXH_FORCE_MEMORY_ACCESS 2
+# elif (defined(__INTEL_COMPILER) && !defined(WIN32)) || \
+ (defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) ))
+# define XXH_FORCE_MEMORY_ACCESS 1
+# endif
+#endif
+
+/*!XXH_ACCEPT_NULL_INPUT_POINTER :
+ * If the input pointer is a null pointer, xxHash default behavior is to trigger a memory access error, since it is a bad pointer.
+ * When this option is enabled, xxHash output for null input pointers will be the same as a null-length input.
+ * By default, this option is disabled. To enable it, uncomment below define :
+ */
+/* #define XXH_ACCEPT_NULL_INPUT_POINTER 1 */
+
+/*!XXH_FORCE_NATIVE_FORMAT :
+ * By default, xxHash library provides endian-independant Hash values, based on little-endian convention.
+ * Results are therefore identical for little-endian and big-endian CPU.
+ * This comes at a performance cost for big-endian CPU, since some swapping is required to emulate little-endian format.
+ * Should endian-independance be of no importance for your application, you may set the #define below to 1,
+ * to improve speed for Big-endian CPU.
+ * This option has no impact on Little_Endian CPU.
+ */
+#ifndef XXH_FORCE_NATIVE_FORMAT /* can be defined externally */
+# define XXH_FORCE_NATIVE_FORMAT 0
+#endif
+
+/*!XXH_FORCE_ALIGN_CHECK :
+ * This is a minor performance trick, only useful with lots of very small keys.
+ * It means : check for aligned/unaligned input.
+ * The check costs one initial branch per hash; set to 0 when the input data
+ * is guaranteed to be aligned.
+ */
+#ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */
+# if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
+# define XXH_FORCE_ALIGN_CHECK 0
+# else
+# define XXH_FORCE_ALIGN_CHECK 1
+# endif
+#endif
+
+
+/* *************************************
+* Includes & Memory related functions
+***************************************/
+/* Modify the local functions below should you wish to use some other memory routines */
+/* for malloc(), free() */
+#include <stdlib.h>
+#include <stddef.h> /* size_t */
+static void* XXH_malloc(size_t s) { return malloc(s); }
+static void XXH_free (void* p) { free(p); }
+/* for memcpy() */
+#include <string.h>
+static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
+
+#ifndef XXH_STATIC_LINKING_ONLY
+# define XXH_STATIC_LINKING_ONLY
+#endif
+#include "xxhash.h"
+
+
+/* *************************************
+* Compiler Specific Options
+***************************************/
+#if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
+# define INLINE_KEYWORD inline
+#else
+# define INLINE_KEYWORD
+#endif
+
+#if defined(__GNUC__)
+# define FORCE_INLINE_ATTR __attribute__((always_inline))
+#elif defined(_MSC_VER)
+# define FORCE_INLINE_ATTR __forceinline
+#else
+# define FORCE_INLINE_ATTR
+#endif
+
+#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
+
+
+#ifdef _MSC_VER
+# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
+#endif
+
+
+/* *************************************
+* Basic Types
+***************************************/
+#ifndef MEM_MODULE
+# define MEM_MODULE
+# if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
+# include <stdint.h>
+ typedef uint8_t BYTE;
+ typedef uint16_t U16;
+ typedef uint32_t U32;
+ typedef int32_t S32;
+ typedef uint64_t U64;
+# else
+ typedef unsigned char BYTE;
+ typedef unsigned short U16;
+ typedef unsigned int U32;
+ typedef signed int S32;
+ typedef unsigned long long U64; /* if your compiler doesn't support unsigned long long, replace by another 64-bit type here. Note that xxhash.h will also need to be updated. */
+# endif
+#endif
+
+
+#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2))
+
+/* Force direct memory access. Only works on CPU which support unaligned memory access in hardware */
+static U32 XXH_read32(const void* memPtr) { return *(const U32*) memPtr; }
+static U64 XXH_read64(const void* memPtr) { return *(const U64*) memPtr; }
+
+#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1))
+
+/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
+/* currently only defined for gcc and icc */
+typedef union { U32 u32; U64 u64; } __attribute__((packed)) unalign;
+
+static U32 XXH_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
+static U64 XXH_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
+
+#else
+
+/* portable and safe solution. Generally efficient.
+ * see : http://stackoverflow.com/a/32095106/646947
+ */
+
+static U32 XXH_read32(const void* memPtr)
+{
+ U32 val;
+ memcpy(&val, memPtr, sizeof(val));
+ return val;
+}
+
+static U64 XXH_read64(const void* memPtr)
+{
+ U64 val;
+ memcpy(&val, memPtr, sizeof(val));
+ return val;
+}
+
+#endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */
+
+
+/* ****************************************
+* Compiler-specific Functions and Macros
+******************************************/
+#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+
+/* Note : although _rotl exists for minGW (GCC under windows), performance seems poor */
+#if defined(_MSC_VER)
+# define XXH_rotl32(x,r) _rotl(x,r)
+# define XXH_rotl64(x,r) _rotl64(x,r)
+#else
+# define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
+# define XXH_rotl64(x,r) ((x << r) | (x >> (64 - r)))
+#endif
+
+#if defined(_MSC_VER) /* Visual Studio */
+# define XXH_swap32 _byteswap_ulong
+# define XXH_swap64 _byteswap_uint64
+#elif GCC_VERSION >= 403
+# define XXH_swap32 __builtin_bswap32
+# define XXH_swap64 __builtin_bswap64
+#else
+static U32 XXH_swap32 (U32 x)
+{
+ return ((x << 24) & 0xff000000 ) |
+ ((x << 8) & 0x00ff0000 ) |
+ ((x >> 8) & 0x0000ff00 ) |
+ ((x >> 24) & 0x000000ff );
+}
+static U64 XXH_swap64 (U64 x)
+{
+ return ((x << 56) & 0xff00000000000000ULL) |
+ ((x << 40) & 0x00ff000000000000ULL) |
+ ((x << 24) & 0x0000ff0000000000ULL) |
+ ((x << 8) & 0x000000ff00000000ULL) |
+ ((x >> 8) & 0x00000000ff000000ULL) |
+ ((x >> 24) & 0x0000000000ff0000ULL) |
+ ((x >> 40) & 0x000000000000ff00ULL) |
+ ((x >> 56) & 0x00000000000000ffULL);
+}
+#endif
+
+
+/* *************************************
+* Architecture Macros
+***************************************/
+typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
+
+/* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example on the compiler command line */
+#ifndef XXH_CPU_LITTLE_ENDIAN
+ static const int g_one = 1;
+# define XXH_CPU_LITTLE_ENDIAN (*(const char*)(&g_one))
+#endif
+
+
+/* ***************************
+* Memory reads
+*****************************/
+typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment;
+
+FORCE_INLINE_TEMPLATE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
+{
+ if (align==XXH_unaligned)
+ return endian==XXH_littleEndian ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr));
+ else
+ return endian==XXH_littleEndian ? *(const U32*)ptr : XXH_swap32(*(const U32*)ptr);
+}
+
+FORCE_INLINE_TEMPLATE U32 XXH_readLE32(const void* ptr, XXH_endianess endian)
+{
+ return XXH_readLE32_align(ptr, endian, XXH_unaligned);
+}
+
+static U32 XXH_readBE32(const void* ptr)
+{
+ return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32(XXH_read32(ptr)) : XXH_read32(ptr);
+}
+
+FORCE_INLINE_TEMPLATE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
+{
+ if (align==XXH_unaligned)
+ return endian==XXH_littleEndian ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr));
+ else
+ return endian==XXH_littleEndian ? *(const U64*)ptr : XXH_swap64(*(const U64*)ptr);
+}
+
+FORCE_INLINE_TEMPLATE U64 XXH_readLE64(const void* ptr, XXH_endianess endian)
+{
+ return XXH_readLE64_align(ptr, endian, XXH_unaligned);
+}
+
+static U64 XXH_readBE64(const void* ptr)
+{
+ return XXH_CPU_LITTLE_ENDIAN ? XXH_swap64(XXH_read64(ptr)) : XXH_read64(ptr);
+}
+
+
+/* *************************************
+* Macros
+***************************************/
+#define XXH_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
+
+
+/* *************************************
+* Constants
+***************************************/
+static const U32 PRIME32_1 = 2654435761U;
+static const U32 PRIME32_2 = 2246822519U;
+static const U32 PRIME32_3 = 3266489917U;
+static const U32 PRIME32_4 = 668265263U;
+static const U32 PRIME32_5 = 374761393U;
+
+static const U64 PRIME64_1 = 11400714785074694791ULL;
+static const U64 PRIME64_2 = 14029467366897019727ULL;
+static const U64 PRIME64_3 = 1609587929392839161ULL;
+static const U64 PRIME64_4 = 9650029242287828579ULL;
+static const U64 PRIME64_5 = 2870177450012600261ULL;
+
+XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; }
+
+
+/* **************************
+* Utils
+****************************/
+XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* restrict dstState, const XXH32_state_t* restrict srcState)
+{
+ memcpy(dstState, srcState, sizeof(*dstState));
+}
+
+XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* restrict dstState, const XXH64_state_t* restrict srcState)
+{
+ memcpy(dstState, srcState, sizeof(*dstState));
+}
+
+
+/* ***************************
+* Simple Hash Functions
+*****************************/
+
+static U32 XXH32_round(U32 seed, U32 input)
+{
+ seed += input * PRIME32_2;
+ seed = XXH_rotl32(seed, 13);
+ seed *= PRIME32_1;
+ return seed;
+}
+
+FORCE_INLINE_TEMPLATE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align)
+{
+ const BYTE* p = (const BYTE*)input;
+ const BYTE* bEnd = p + len;
+ U32 h32;
+#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
+
+#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+ if (p==NULL) {
+ len=0;
+ bEnd=p=(const BYTE*)(size_t)16;
+ }
+#endif
+
+ if (len>=16) {
+ const BYTE* const limit = bEnd - 16;
+ U32 v1 = seed + PRIME32_1 + PRIME32_2;
+ U32 v2 = seed + PRIME32_2;
+ U32 v3 = seed + 0;
+ U32 v4 = seed - PRIME32_1;
+
+ do {
+ v1 = XXH32_round(v1, XXH_get32bits(p)); p+=4;
+ v2 = XXH32_round(v2, XXH_get32bits(p)); p+=4;
+ v3 = XXH32_round(v3, XXH_get32bits(p)); p+=4;
+ v4 = XXH32_round(v4, XXH_get32bits(p)); p+=4;
+ } while (p<=limit);
+
+ h32 = XXH_rotl32(v1, 1) + XXH_rotl32(v2, 7) + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18);
+ } else {
+ h32 = seed + PRIME32_5;
+ }
+
+ h32 += (U32) len;
+
+ while (p+4<=bEnd) {
+ h32 += XXH_get32bits(p) * PRIME32_3;
+ h32 = XXH_rotl32(h32, 17) * PRIME32_4 ;
+ p+=4;
+ }
+
+ while (p<bEnd) {
+ h32 += (*p) * PRIME32_5;
+ h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
+ p++;
+ }
+
+ h32 ^= h32 >> 15;
+ h32 *= PRIME32_2;
+ h32 ^= h32 >> 13;
+ h32 *= PRIME32_3;
+ h32 ^= h32 >> 16;
+
+ return h32;
+}
+
+
+XXH_PUBLIC_API unsigned int XXH32 (const void* input, size_t len, unsigned int seed)
+{
+#if 0
+ /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
+ XXH32_CREATESTATE_STATIC(state);
+ XXH32_reset(state, seed);
+ XXH32_update(state, input, len);
+ return XXH32_digest(state);
+#else
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if (XXH_FORCE_ALIGN_CHECK) {
+ if ((((size_t)input) & 3) == 0) { /* Input is 4-bytes aligned, leverage the speed benefit */
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned);
+ else
+ return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned);
+ } }
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned);
+ else
+ return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned);
+#endif
+}
+
+
+static U64 XXH64_round(U64 acc, U64 input)
+{
+ acc += input * PRIME64_2;
+ acc = XXH_rotl64(acc, 31);
+ acc *= PRIME64_1;
+ return acc;
+}
+
+static U64 XXH64_mergeRound(U64 acc, U64 val)
+{
+ val = XXH64_round(0, val);
+ acc ^= val;
+ acc = acc * PRIME64_1 + PRIME64_4;
+ return acc;
+}
+
+FORCE_INLINE_TEMPLATE U64 XXH64_endian_align(const void* input, size_t len, U64 seed, XXH_endianess endian, XXH_alignment align)
+{
+ const BYTE* p = (const BYTE*)input;
+ const BYTE* const bEnd = p + len;
+ U64 h64;
+#define XXH_get64bits(p) XXH_readLE64_align(p, endian, align)
+
+#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+ if (p==NULL) {
+ len=0;
+ bEnd=p=(const BYTE*)(size_t)32;
+ }
+#endif
+
+ if (len>=32) {
+ const BYTE* const limit = bEnd - 32;
+ U64 v1 = seed + PRIME64_1 + PRIME64_2;
+ U64 v2 = seed + PRIME64_2;
+ U64 v3 = seed + 0;
+ U64 v4 = seed - PRIME64_1;
+
+ do {
+ v1 = XXH64_round(v1, XXH_get64bits(p)); p+=8;
+ v2 = XXH64_round(v2, XXH_get64bits(p)); p+=8;
+ v3 = XXH64_round(v3, XXH_get64bits(p)); p+=8;
+ v4 = XXH64_round(v4, XXH_get64bits(p)); p+=8;
+ } while (p<=limit);
+
+ h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18);
+ h64 = XXH64_mergeRound(h64, v1);
+ h64 = XXH64_mergeRound(h64, v2);
+ h64 = XXH64_mergeRound(h64, v3);
+ h64 = XXH64_mergeRound(h64, v4);
+
+ } else {
+ h64 = seed + PRIME64_5;
+ }
+
+ h64 += (U64) len;
+
+ while (p+8<=bEnd) {
+ U64 const k1 = XXH64_round(0, XXH_get64bits(p));
+ h64 ^= k1;
+ h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4;
+ p+=8;
+ }
+
+ if (p+4<=bEnd) {
+ h64 ^= (U64)(XXH_get32bits(p)) * PRIME64_1;
+ h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
+ p+=4;
+ }
+
+ while (p<bEnd) {
+ h64 ^= (*p) * PRIME64_5;
+ h64 = XXH_rotl64(h64, 11) * PRIME64_1;
+ p++;
+ }
+
+ h64 ^= h64 >> 33;
+ h64 *= PRIME64_2;
+ h64 ^= h64 >> 29;
+ h64 *= PRIME64_3;
+ h64 ^= h64 >> 32;
+
+ return h64;
+}
+
+
+XXH_PUBLIC_API unsigned long long XXH64 (const void* input, size_t len, unsigned long long seed)
+{
+#if 0
+ /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
+ XXH64_CREATESTATE_STATIC(state);
+ XXH64_reset(state, seed);
+ XXH64_update(state, input, len);
+ return XXH64_digest(state);
+#else
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if (XXH_FORCE_ALIGN_CHECK) {
+ if ((((size_t)input) & 7)==0) { /* Input is aligned, let's leverage the speed advantage */
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned);
+ else
+ return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned);
+ } }
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned);
+ else
+ return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned);
+#endif
+}
+
+
+/* **************************************************
+* Advanced Hash Functions
+****************************************************/
+
+XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void)
+{
+ return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t));
+}
+XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr)
+{
+ XXH_free(statePtr);
+ return XXH_OK;
+}
+
+XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void)
+{
+ return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t));
+}
+XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr)
+{
+ XXH_free(statePtr);
+ return XXH_OK;
+}
+
+
+/*** Hash feed ***/
+
+XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, unsigned int seed)
+{
+ XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
+ memset(&state, 0, sizeof(state)-4); /* do not write into reserved, for future removal */
+ state.v1 = seed + PRIME32_1 + PRIME32_2;
+ state.v2 = seed + PRIME32_2;
+ state.v3 = seed + 0;
+ state.v4 = seed - PRIME32_1;
+ memcpy(statePtr, &state, sizeof(state));
+ return XXH_OK;
+}
+
+
+XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, unsigned long long seed)
+{
+ XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
+ memset(&state, 0, sizeof(state)-8); /* do not write into reserved, for future removal */
+ state.v1 = seed + PRIME64_1 + PRIME64_2;
+ state.v2 = seed + PRIME64_2;
+ state.v3 = seed + 0;
+ state.v4 = seed - PRIME64_1;
+ memcpy(statePtr, &state, sizeof(state));
+ return XXH_OK;
+}
+
+
+FORCE_INLINE_TEMPLATE XXH_errorcode XXH32_update_endian (XXH32_state_t* state, const void* input, size_t len, XXH_endianess endian)
+{
+ const BYTE* p = (const BYTE*)input;
+ const BYTE* const bEnd = p + len;
+
+#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+ if (input==NULL) return XXH_ERROR;
+#endif
+
+ state->total_len_32 += (unsigned)len;
+ state->large_len |= (len>=16) | (state->total_len_32>=16);
+
+ if (state->memsize + len < 16) { /* fill in tmp buffer */
+ XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, len);
+ state->memsize += (unsigned)len;
+ return XXH_OK;
+ }
+
+ if (state->memsize) { /* some data left from previous update */
+ XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, 16-state->memsize);
+ { const U32* p32 = state->mem32;
+ state->v1 = XXH32_round(state->v1, XXH_readLE32(p32, endian)); p32++;
+ state->v2 = XXH32_round(state->v2, XXH_readLE32(p32, endian)); p32++;
+ state->v3 = XXH32_round(state->v3, XXH_readLE32(p32, endian)); p32++;
+ state->v4 = XXH32_round(state->v4, XXH_readLE32(p32, endian)); p32++;
+ }
+ p += 16-state->memsize;
+ state->memsize = 0;
+ }
+
+ if (p <= bEnd-16) {
+ const BYTE* const limit = bEnd - 16;
+ U32 v1 = state->v1;
+ U32 v2 = state->v2;
+ U32 v3 = state->v3;
+ U32 v4 = state->v4;
+
+ do {
+ v1 = XXH32_round(v1, XXH_readLE32(p, endian)); p+=4;
+ v2 = XXH32_round(v2, XXH_readLE32(p, endian)); p+=4;
+ v3 = XXH32_round(v3, XXH_readLE32(p, endian)); p+=4;
+ v4 = XXH32_round(v4, XXH_readLE32(p, endian)); p+=4;
+ } while (p<=limit);
+
+ state->v1 = v1;
+ state->v2 = v2;
+ state->v3 = v3;
+ state->v4 = v4;
+ }
+
+ if (p < bEnd) {
+ XXH_memcpy(state->mem32, p, (size_t)(bEnd-p));
+ state->memsize = (unsigned)(bEnd-p);
+ }
+
+ return XXH_OK;
+}
+
+XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* state_in, const void* input, size_t len)
+{
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH32_update_endian(state_in, input, len, XXH_littleEndian);
+ else
+ return XXH32_update_endian(state_in, input, len, XXH_bigEndian);
+}
+
+
+
+FORCE_INLINE_TEMPLATE U32 XXH32_digest_endian (const XXH32_state_t* state, XXH_endianess endian)
+{
+ const BYTE * p = (const BYTE*)state->mem32;
+ const BYTE* const bEnd = (const BYTE*)(state->mem32) + state->memsize;
+ U32 h32;
+
+ if (state->large_len) {
+ h32 = XXH_rotl32(state->v1, 1) + XXH_rotl32(state->v2, 7) + XXH_rotl32(state->v3, 12) + XXH_rotl32(state->v4, 18);
+ } else {
+ h32 = state->v3 /* == seed */ + PRIME32_5;
+ }
+
+ h32 += state->total_len_32;
+
+ while (p+4<=bEnd) {
+ h32 += XXH_readLE32(p, endian) * PRIME32_3;
+ h32 = XXH_rotl32(h32, 17) * PRIME32_4;
+ p+=4;
+ }
+
+ while (p<bEnd) {
+ h32 += (*p) * PRIME32_5;
+ h32 = XXH_rotl32(h32, 11) * PRIME32_1;
+ p++;
+ }
+
+ h32 ^= h32 >> 15;
+ h32 *= PRIME32_2;
+ h32 ^= h32 >> 13;
+ h32 *= PRIME32_3;
+ h32 ^= h32 >> 16;
+
+ return h32;
+}
+
+
+XXH_PUBLIC_API unsigned int XXH32_digest (const XXH32_state_t* state_in)
+{
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH32_digest_endian(state_in, XXH_littleEndian);
+ else
+ return XXH32_digest_endian(state_in, XXH_bigEndian);
+}
+
+
+
+/* **** XXH64 **** */
+
+FORCE_INLINE_TEMPLATE XXH_errorcode XXH64_update_endian (XXH64_state_t* state, const void* input, size_t len, XXH_endianess endian)
+{
+ const BYTE* p = (const BYTE*)input;
+ const BYTE* const bEnd = p + len;
+
+#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+ if (input==NULL) return XXH_ERROR;
+#endif
+
+ state->total_len += len;
+
+ if (state->memsize + len < 32) { /* fill in tmp buffer */
+ XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, len);
+ state->memsize += (U32)len;
+ return XXH_OK;
+ }
+
+ if (state->memsize) { /* tmp buffer is full */
+ XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, 32-state->memsize);
+ state->v1 = XXH64_round(state->v1, XXH_readLE64(state->mem64+0, endian));
+ state->v2 = XXH64_round(state->v2, XXH_readLE64(state->mem64+1, endian));
+ state->v3 = XXH64_round(state->v3, XXH_readLE64(state->mem64+2, endian));
+ state->v4 = XXH64_round(state->v4, XXH_readLE64(state->mem64+3, endian));
+ p += 32-state->memsize;
+ state->memsize = 0;
+ }
+
+ if (p+32 <= bEnd) {
+ const BYTE* const limit = bEnd - 32;
+ U64 v1 = state->v1;
+ U64 v2 = state->v2;
+ U64 v3 = state->v3;
+ U64 v4 = state->v4;
+
+ do {
+ v1 = XXH64_round(v1, XXH_readLE64(p, endian)); p+=8;
+ v2 = XXH64_round(v2, XXH_readLE64(p, endian)); p+=8;
+ v3 = XXH64_round(v3, XXH_readLE64(p, endian)); p+=8;
+ v4 = XXH64_round(v4, XXH_readLE64(p, endian)); p+=8;
+ } while (p<=limit);
+
+ state->v1 = v1;
+ state->v2 = v2;
+ state->v3 = v3;
+ state->v4 = v4;
+ }
+
+ if (p < bEnd) {
+ XXH_memcpy(state->mem64, p, (size_t)(bEnd-p));
+ state->memsize = (unsigned)(bEnd-p);
+ }
+
+ return XXH_OK;
+}
+
+XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* state_in, const void* input, size_t len)
+{
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH64_update_endian(state_in, input, len, XXH_littleEndian);
+ else
+ return XXH64_update_endian(state_in, input, len, XXH_bigEndian);
+}
+
+
+
+FORCE_INLINE_TEMPLATE U64 XXH64_digest_endian (const XXH64_state_t* state, XXH_endianess endian)
+{
+ const BYTE * p = (const BYTE*)state->mem64;
+ const BYTE* const bEnd = (const BYTE*)state->mem64 + state->memsize;
+ U64 h64;
+
+ if (state->total_len >= 32) {
+ U64 const v1 = state->v1;
+ U64 const v2 = state->v2;
+ U64 const v3 = state->v3;
+ U64 const v4 = state->v4;
+
+ h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18);
+ h64 = XXH64_mergeRound(h64, v1);
+ h64 = XXH64_mergeRound(h64, v2);
+ h64 = XXH64_mergeRound(h64, v3);
+ h64 = XXH64_mergeRound(h64, v4);
+ } else {
+ h64 = state->v3 + PRIME64_5;
+ }
+
+ h64 += (U64) state->total_len;
+
+ while (p+8<=bEnd) {
+ U64 const k1 = XXH64_round(0, XXH_readLE64(p, endian));
+ h64 ^= k1;
+ h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4;
+ p+=8;
+ }
+
+ if (p+4<=bEnd) {
+ h64 ^= (U64)(XXH_readLE32(p, endian)) * PRIME64_1;
+ h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
+ p+=4;
+ }
+
+ while (p<bEnd) {
+ h64 ^= (*p) * PRIME64_5;
+ h64 = XXH_rotl64(h64, 11) * PRIME64_1;
+ p++;
+ }
+
+ h64 ^= h64 >> 33;
+ h64 *= PRIME64_2;
+ h64 ^= h64 >> 29;
+ h64 *= PRIME64_3;
+ h64 ^= h64 >> 32;
+
+ return h64;
+}
+
+
+XXH_PUBLIC_API unsigned long long XXH64_digest (const XXH64_state_t* state_in)
+{
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH64_digest_endian(state_in, XXH_littleEndian);
+ else
+ return XXH64_digest_endian(state_in, XXH_bigEndian);
+}
+
+
+/* **************************
+* Canonical representation
+****************************/
+
+/*! Default XXH result types are basic unsigned 32 and 64 bits.
+* The canonical representation follows human-readable write convention, aka big-endian (large digits first).
+* These functions allow transformation of hash result into and from its canonical format.
+* This way, hash values can be written into a file or buffer, and remain comparable across different systems and programs.
+*/
+
+XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash)
+{
+ XXH_STATIC_ASSERT(sizeof(XXH32_canonical_t) == sizeof(XXH32_hash_t));
+ if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap32(hash);
+ memcpy(dst, &hash, sizeof(*dst));
+}
+
+XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash)
+{
+ XXH_STATIC_ASSERT(sizeof(XXH64_canonical_t) == sizeof(XXH64_hash_t));
+ if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap64(hash);
+ memcpy(dst, &hash, sizeof(*dst));
+}
+
+XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src)
+{
+ return XXH_readBE32(src);
+}
+
+XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src)
+{
+ return XXH_readBE64(src);
+}
diff --git a/grub-core/lib/zstd/xxhash.h b/grub-core/lib/zstd/xxhash.h
new file mode 100644
index 0000000..9bad1f5
--- /dev/null
+++ b/grub-core/lib/zstd/xxhash.h
@@ -0,0 +1,305 @@
+/*
+ xxHash - Extremely Fast Hash algorithm
+ Header File
+ Copyright (C) 2012-2016, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - xxHash source repository : https://github.com/Cyan4973/xxHash
+*/
+
+/* Notice extracted from xxHash homepage :
+
+xxHash is an extremely fast Hash algorithm, running at RAM speed limits.
+It also successfully passes all tests from the SMHasher suite.
+
+Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz)
+
+Name Speed Q.Score Author
+xxHash 5.4 GB/s 10
+CrapWow 3.2 GB/s 2 Andrew
+MumurHash 3a 2.7 GB/s 10 Austin Appleby
+SpookyHash 2.0 GB/s 10 Bob Jenkins
+SBox 1.4 GB/s 9 Bret Mulvey
+Lookup3 1.2 GB/s 9 Bob Jenkins
+SuperFastHash 1.2 GB/s 1 Paul Hsieh
+CityHash64 1.05 GB/s 10 Pike & Alakuijala
+FNV 0.55 GB/s 5 Fowler, Noll, Vo
+CRC32 0.43 GB/s 9
+MD5-32 0.33 GB/s 10 Ronald L. Rivest
+SHA1-32 0.28 GB/s 10
+
+Q.Score is a measure of quality of the hash function.
+It depends on successfully passing SMHasher test set.
+10 is a perfect score.
+
+A 64-bits version, named XXH64, is available since r35.
+It offers much better speed, but for 64-bits applications only.
+Name Speed on 64 bits Speed on 32 bits
+XXH64 13.8 GB/s 1.9 GB/s
+XXH32 6.8 GB/s 6.0 GB/s
+*/
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#ifndef XXHASH_H_5627135585666179
+#define XXHASH_H_5627135585666179 1
+
+
+/* ****************************
+* Definitions
+******************************/
+#include <stddef.h> /* size_t */
+typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
+
+
+/* ****************************
+* API modifier
+******************************/
+/** XXH_PRIVATE_API
+* This is useful if you want to include xxhash functions in `static` mode
+* in order to inline them, and remove their symbol from the public list.
+* Methodology :
+* #define XXH_PRIVATE_API
+* #include "xxhash.h"
+* `xxhash.c` is automatically included.
+* It's not useful to compile and link it as a separate module anymore.
+*/
+#ifdef XXH_PRIVATE_API
+# ifndef XXH_STATIC_LINKING_ONLY
+# define XXH_STATIC_LINKING_ONLY
+# endif
+# if defined(__GNUC__)
+# define XXH_PUBLIC_API static __inline __attribute__((unused))
+# elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
+# define XXH_PUBLIC_API static inline
+# elif defined(_MSC_VER)
+# define XXH_PUBLIC_API static __inline
+# else
+# define XXH_PUBLIC_API static /* this version may generate warnings for unused static functions; disable the relevant warning */
+# endif
+#else
+# define XXH_PUBLIC_API /* do nothing */
+#endif /* XXH_PRIVATE_API */
+
+/*!XXH_NAMESPACE, aka Namespace Emulation :
+
+If you want to include _and expose_ xxHash functions from within your own library,
+but also want to avoid symbol collisions with another library which also includes xxHash,
+
+you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library
+with the value of XXH_NAMESPACE (so avoid to keep it NULL and avoid numeric values).
+
+Note that no change is required within the calling program as long as it includes `xxhash.h` :
+regular symbol name will be automatically translated by this header.
+*/
+#ifdef XXH_NAMESPACE
+# define XXH_CAT(A,B) A##B
+# define XXH_NAME2(A,B) XXH_CAT(A,B)
+# define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
+# define XXH64 XXH_NAME2(XXH_NAMESPACE, XXH64)
+# define XXH_versionNumber XXH_NAME2(XXH_NAMESPACE, XXH_versionNumber)
+# define XXH32_createState XXH_NAME2(XXH_NAMESPACE, XXH32_createState)
+# define XXH64_createState XXH_NAME2(XXH_NAMESPACE, XXH64_createState)
+# define XXH32_freeState XXH_NAME2(XXH_NAMESPACE, XXH32_freeState)
+# define XXH64_freeState XXH_NAME2(XXH_NAMESPACE, XXH64_freeState)
+# define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset)
+# define XXH64_reset XXH_NAME2(XXH_NAMESPACE, XXH64_reset)
+# define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
+# define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update)
+# define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
+# define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest)
+# define XXH32_copyState XXH_NAME2(XXH_NAMESPACE, XXH32_copyState)
+# define XXH64_copyState XXH_NAME2(XXH_NAMESPACE, XXH64_copyState)
+# define XXH32_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH32_canonicalFromHash)
+# define XXH64_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH64_canonicalFromHash)
+# define XXH32_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH32_hashFromCanonical)
+# define XXH64_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH64_hashFromCanonical)
+#endif
+
+
+/* *************************************
+* Version
+***************************************/
+#define XXH_VERSION_MAJOR 0
+#define XXH_VERSION_MINOR 6
+#define XXH_VERSION_RELEASE 2
+#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
+XXH_PUBLIC_API unsigned XXH_versionNumber (void);
+
+
+/* ****************************
+* Simple Hash Functions
+******************************/
+typedef unsigned int XXH32_hash_t;
+typedef unsigned long long XXH64_hash_t;
+
+XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, unsigned int seed);
+XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, unsigned long long seed);
+
+/*!
+XXH32() :
+ Calculate the 32-bits hash of sequence "length" bytes stored at memory address "input".
+ The memory between input & input+length must be valid (allocated and read-accessible).
+ "seed" can be used to alter the result predictably.
+ Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s
+XXH64() :
+ Calculate the 64-bits hash of sequence of length "len" stored at memory address "input".
+ "seed" can be used to alter the result predictably.
+ This function runs 2x faster on 64-bits systems, but slower on 32-bits systems (see benchmark).
+*/
+
+
+/* ****************************
+* Streaming Hash Functions
+******************************/
+typedef struct XXH32_state_s XXH32_state_t; /* incomplete type */
+typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */
+
+/*! State allocation, compatible with dynamic libraries */
+
+XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void);
+XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr);
+
+XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void);
+XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr);
+
+
+/* hash streaming */
+
+XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, unsigned int seed);
+XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length);
+XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr);
+
+XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, unsigned long long seed);
+XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length);
+XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr);
+
+/*
+These functions generate the xxHash of an input provided in multiple segments.
+Note that, for small input, they are slower than single-call functions, due to state management.
+For small input, prefer `XXH32()` and `XXH64()` .
+
+XXH state must first be allocated, using XXH*_createState() .
+
+Start a new hash by initializing state with a seed, using XXH*_reset().
+
+Then, feed the hash state by calling XXH*_update() as many times as necessary.
+Obviously, input must be allocated and read accessible.
+The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
+
+Finally, a hash value can be produced anytime, by using XXH*_digest().
+This function returns the nn-bits hash as an int or long long.
+
+It's still possible to continue inserting input into the hash state after a digest,
+and generate some new hashes later on, by calling again XXH*_digest().
+
+When done, free XXH state space if it was allocated dynamically.
+*/
+
+
+/* **************************
+* Utils
+****************************/
+#if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) /* ! C99 */
+# define restrict /* disable restrict */
+#endif
+
+XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* restrict dst_state, const XXH32_state_t* restrict src_state);
+XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* restrict dst_state, const XXH64_state_t* restrict src_state);
+
+
+/* **************************
+* Canonical representation
+****************************/
+/* Default result type for XXH functions are primitive unsigned 32 and 64 bits.
+* The canonical representation uses human-readable write convention, aka big-endian (large digits first).
+* These functions allow transformation of hash result into and from its canonical format.
+* This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
+*/
+typedef struct { unsigned char digest[4]; } XXH32_canonical_t;
+typedef struct { unsigned char digest[8]; } XXH64_canonical_t;
+
+XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash);
+XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash);
+
+XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src);
+XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src);
+
+#endif /* XXHASH_H_5627135585666179 */
+
+
+
+/* ================================================================================================
+ This section contains definitions which are not guaranteed to remain stable.
+ They may change in future versions, becoming incompatible with a different version of the library.
+ They shall only be used with static linking.
+ Never use these definitions in association with dynamic linking !
+=================================================================================================== */
+#if defined(XXH_STATIC_LINKING_ONLY) && !defined(XXH_STATIC_H_3543687687345)
+#define XXH_STATIC_H_3543687687345
+
+/* These definitions are only meant to allow allocation of XXH state
+ statically, on stack, or in a struct for example.
+ Do not use members directly. */
+
+ struct XXH32_state_s {
+ unsigned total_len_32;
+ unsigned large_len;
+ unsigned v1;
+ unsigned v2;
+ unsigned v3;
+ unsigned v4;
+ unsigned mem32[4]; /* buffer defined as U32 for alignment */
+ unsigned memsize;
+ unsigned reserved; /* never read nor write, will be removed in a future version */
+ }; /* typedef'd to XXH32_state_t */
+
+ struct XXH64_state_s {
+ unsigned long long total_len;
+ unsigned long long v1;
+ unsigned long long v2;
+ unsigned long long v3;
+ unsigned long long v4;
+ unsigned long long mem64[4]; /* buffer defined as U64 for alignment */
+ unsigned memsize;
+ unsigned reserved[2]; /* never read nor write, will be removed in a future version */
+ }; /* typedef'd to XXH64_state_t */
+
+
+# ifdef XXH_PRIVATE_API
+# include "xxhash.c" /* include xxhash functions as `static`, for inlining */
+# endif
+
+#endif /* XXH_STATIC_LINKING_ONLY && XXH_STATIC_H_3543687687345 */
+
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/grub-core/lib/zstd/zstd.h b/grub-core/lib/zstd/zstd.h
new file mode 100644
index 0000000..7b6964b
--- /dev/null
+++ b/grub-core/lib/zstd/zstd.h
@@ -0,0 +1,1516 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#ifndef ZSTD_H_235446
+#define ZSTD_H_235446
+
+/* ====== Dependency ======*/
+#include <stddef.h> /* size_t */
+
+
+/* ===== ZSTDLIB_API : control library symbols visibility ===== */
+#ifndef ZSTDLIB_VISIBILITY
+# if defined(__GNUC__) && (__GNUC__ >= 4)
+# define ZSTDLIB_VISIBILITY __attribute__ ((visibility ("default")))
+# else
+# define ZSTDLIB_VISIBILITY
+# endif
+#endif
+#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
+# define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBILITY
+#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
+# define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
+#else
+# define ZSTDLIB_API ZSTDLIB_VISIBILITY
+#endif
+
+
+/*******************************************************************************
+ Introduction
+
+ zstd, short for Zstandard, is a fast lossless compression algorithm, targeting
+ real-time compression scenarios at zlib-level and better compression ratios.
+ The zstd compression library provides in-memory compression and decompression
+ functions.
+
+ The library supports regular compression levels from 1 up to ZSTD_maxCLevel(),
+ which is currently 22. Levels >= 20, labeled `--ultra`, should be used with
+ caution, as they require more memory. The library also offers negative
+ compression levels, which extend the range of speed vs. ratio preferences.
+ The lower the level, the faster the speed (at the cost of compression).
+
+ Compression can be done in:
+ - a single step (described as Simple API)
+ - a single step, reusing a context (described as Explicit context)
+ - unbounded multiple steps (described as Streaming compression)
+
+ The compression ratio achievable on small data can be highly improved using
+ a dictionary. Dictionary compression can be performed in:
+ - a single step (described as Simple dictionary API)
+ - a single step, reusing a dictionary (described as Bulk-processing
+ dictionary API)
+
+ Advanced experimental functions can be accessed using
+ `#define ZSTD_STATIC_LINKING_ONLY` before including zstd.h.
+
+ Advanced experimental APIs should never be used with a dynamically-linked
+ library. They are not "stable"; their definitions or signatures may change in
+ the future. Only static linking is allowed.
+*******************************************************************************/
+
+/*------ Version ------*/
+#define ZSTD_VERSION_MAJOR 1
+#define ZSTD_VERSION_MINOR 3
+#define ZSTD_VERSION_RELEASE 6
+
+#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
+ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< useful to check dll version */
+
+#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
+#define ZSTD_QUOTE(str) #str
+#define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str)
+#define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
+ZSTDLIB_API const char* ZSTD_versionString(void); /* v1.3.0+ */
+
+/***************************************
+* Default constant
+***************************************/
+#ifndef ZSTD_CLEVEL_DEFAULT
+# define ZSTD_CLEVEL_DEFAULT 3
+#endif
+
+/***************************************
+* Simple API
+***************************************/
+/*! ZSTD_compress() :
+ * Compresses `src` content as a single zstd compressed frame into already allocated `dst`.
+ * Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`.
+ * @return : compressed size written into `dst` (<= `dstCapacity),
+ * or an error code if it fails (which can be tested using ZSTD_isError()). */
+ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel);
+
+/*! ZSTD_decompress() :
+ * `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
+ * `dstCapacity` is an upper bound of originalSize to regenerate.
+ * If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
+ * @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
+ * or an errorCode if it fails (which can be tested using ZSTD_isError()). */
+ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
+ const void* src, size_t compressedSize);
+
+/*! ZSTD_getFrameContentSize() : added in v1.3.0
+ * `src` should point to the start of a ZSTD encoded frame.
+ * `srcSize` must be at least as large as the frame header.
+ * hint : any size >= `ZSTD_frameHeaderSize_max` is large enough.
+ * @return : - decompressed size of `src` frame content, if known
+ * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
+ * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
+ * note 1 : a 0 return value means the frame is valid but "empty".
+ * note 2 : decompressed size is an optional field, it may not be present, typically in streaming mode.
+ * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
+ * In which case, it's necessary to use streaming mode to decompress data.
+ * Optionally, application can rely on some implicit limit,
+ * as ZSTD_decompress() only needs an upper bound of decompressed size.
+ * (For example, data could be necessarily cut into blocks <= 16 KB).
+ * note 3 : decompressed size is always present when compression is completed using single-pass functions,
+ * such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict().
+ * note 4 : decompressed size can be very large (64-bits value),
+ * potentially larger than what local system can handle as a single memory segment.
+ * In which case, it's necessary to use streaming mode to decompress data.
+ * note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified.
+ * Always ensure return value fits within application's authorized limits.
+ * Each application can set its own limits.
+ * note 6 : This function replaces ZSTD_getDecompressedSize() */
+#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
+#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
+ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
+
+/*! ZSTD_getDecompressedSize() :
+ * NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize().
+ * Both functions work the same way, but ZSTD_getDecompressedSize() blends
+ * "empty", "unknown" and "error" results to the same return value (0),
+ * while ZSTD_getFrameContentSize() gives them separate return values.
+ * @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */
+ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
+
+
+/*====== Helper functions ======*/
+#define ZSTD_COMPRESSBOUND(srcSize) ((srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */
+ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */
+ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
+ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readable string from an error code */
+ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */
+
+
+/***************************************
+* Explicit context
+***************************************/
+/*= Compression context
+ * When compressing many times,
+ * it is recommended to allocate a context just once, and re-use it for each successive compression operation.
+ * This will make workload friendlier for system's memory.
+ * Use one context per thread for parallel execution in multi-threaded environments. */
+typedef struct ZSTD_CCtx_s ZSTD_CCtx;
+ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void);
+ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
+
+/*! ZSTD_compressCCtx() :
+ * Same as ZSTD_compress(), requires an allocated ZSTD_CCtx (see ZSTD_createCCtx()). */
+ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* ctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel);
+
+/*= Decompression context
+ * When decompressing many times,
+ * it is recommended to allocate a context only once,
+ * and re-use it for each successive compression operation.
+ * This will make workload friendlier for system's memory.
+ * Use one context per thread for parallel execution. */
+typedef struct ZSTD_DCtx_s ZSTD_DCtx;
+ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void);
+ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
+
+/*! ZSTD_decompressDCtx() :
+ * Same as ZSTD_decompress(), requires an allocated ZSTD_DCtx (see ZSTD_createDCtx()) */
+ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* ctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize);
+
+
+/**************************
+* Simple dictionary API
+***************************/
+/*! ZSTD_compress_usingDict() :
+ * Compression using a predefined Dictionary (see dictBuilder/zdict.h).
+ * Note : This function loads the dictionary, resulting in significant startup delay.
+ * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */
+ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict,size_t dictSize,
+ int compressionLevel);
+
+/*! ZSTD_decompress_usingDict() :
+ * Decompression using a predefined Dictionary (see dictBuilder/zdict.h).
+ * Dictionary must be identical to the one used during compression.
+ * Note : This function loads the dictionary, resulting in significant startup delay.
+ * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */
+ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict,size_t dictSize);
+
+
+/**********************************
+ * Bulk processing dictionary API
+ *********************************/
+typedef struct ZSTD_CDict_s ZSTD_CDict;
+
+/*! ZSTD_createCDict() :
+ * When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once.
+ * ZSTD_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
+ * ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
+ * `dictBuffer` can be released after ZSTD_CDict creation, since its content is copied within CDict
+ * Note : A ZSTD_CDict can be created with an empty dictionary, but it is inefficient for small data. */
+ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize,
+ int compressionLevel);
+
+/*! ZSTD_freeCDict() :
+ * Function frees memory allocated by ZSTD_createCDict(). */
+ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict);
+
+/*! ZSTD_compress_usingCDict() :
+ * Compression using a digested Dictionary.
+ * Faster startup than ZSTD_compress_usingDict(), recommended when same dictionary is used multiple times.
+ * Note that compression level is decided during dictionary creation.
+ * Frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no)
+ * Note : ZSTD_compress_usingCDict() can be used with a ZSTD_CDict created from an empty dictionary.
+ * But it is inefficient for small data, and it is recommended to use ZSTD_compressCCtx(). */
+ZSTDLIB_API size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_CDict* cdict);
+
+
+typedef struct ZSTD_DDict_s ZSTD_DDict;
+
+/*! ZSTD_createDDict() :
+ * Create a digested dictionary, ready to start decompression operation without startup delay.
+ * dictBuffer can be released after DDict creation, as its content is copied inside DDict */
+ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize);
+
+/*! ZSTD_freeDDict() :
+ * Function frees memory allocated with ZSTD_createDDict() */
+ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict);
+
+/*! ZSTD_decompress_usingDDict() :
+ * Decompression using a digested Dictionary.
+ * Faster startup than ZSTD_decompress_usingDict(), recommended when same dictionary is used multiple times. */
+ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_DDict* ddict);
+
+
+/****************************
+* Streaming
+****************************/
+
+typedef struct ZSTD_inBuffer_s {
+ const void* src; /**< start of input buffer */
+ size_t size; /**< size of input buffer */
+ size_t pos; /**< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size */
+} ZSTD_inBuffer;
+
+typedef struct ZSTD_outBuffer_s {
+ void* dst; /**< start of output buffer */
+ size_t size; /**< size of output buffer */
+ size_t pos; /**< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size */
+} ZSTD_outBuffer;
+
+
+
+/*-***********************************************************************
+* Streaming compression - HowTo
+*
+* A ZSTD_CStream object is required to track streaming operation.
+* Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources.
+* ZSTD_CStream objects can be reused multiple times on consecutive compression operations.
+* It is recommended to re-use ZSTD_CStream in situations where many streaming operations will be achieved consecutively,
+* since it will play nicer with system's memory, by re-using already allocated memory.
+* Use one separate ZSTD_CStream per thread for parallel execution.
+*
+* Start a new compression by initializing ZSTD_CStream context.
+* Use ZSTD_initCStream() to start a new compression operation.
+* Use variants ZSTD_initCStream_usingDict() or ZSTD_initCStream_usingCDict() for streaming with dictionary (experimental section)
+*
+* Use ZSTD_compressStream() as many times as necessary to consume input stream.
+* The function will automatically update both `pos` fields within `input` and `output`.
+* Note that the function may not consume the entire input,
+* for example, because the output buffer is already full,
+* in which case `input.pos < input.size`.
+* The caller must check if input has been entirely consumed.
+* If not, the caller must make some room to receive more compressed data,
+* typically by emptying output buffer, or allocating a new output buffer,
+* and then present again remaining input data.
+* @return : a size hint, preferred nb of bytes to use as input for next function call
+* or an error code, which can be tested using ZSTD_isError().
+* Note 1 : it's just a hint, to help latency a little, any other value will work fine.
+* Note 2 : size hint is guaranteed to be <= ZSTD_CStreamInSize()
+*
+* At any moment, it's possible to flush whatever data might remain stuck within internal buffer,
+* using ZSTD_flushStream(). `output->pos` will be updated.
+* Note that, if `output->size` is too small, a single invocation of ZSTD_flushStream() might not be enough (return code > 0).
+* In which case, make some room to receive more compressed data, and call again ZSTD_flushStream().
+* @return : 0 if internal buffers are entirely flushed,
+* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
+* or an error code, which can be tested using ZSTD_isError().
+*
+* ZSTD_endStream() instructs to finish a frame.
+* It will perform a flush and write frame epilogue.
+* The epilogue is required for decoders to consider a frame completed.
+* flush() operation is the same, and follows same rules as ZSTD_flushStream().
+* @return : 0 if frame fully completed and fully flushed,
+* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
+* or an error code, which can be tested using ZSTD_isError().
+*
+* *******************************************************************/
+
+typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same object (>= v1.3.0) */
+ /* Continue to distinguish them for compatibility with older versions <= v1.2.0 */
+/*===== ZSTD_CStream management functions =====*/
+ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void);
+ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs);
+
+/*===== Streaming compression functions =====*/
+ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel);
+ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
+ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
+ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
+
+ZSTDLIB_API size_t ZSTD_CStreamInSize(void); /**< recommended size for input buffer */
+ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output buffer. Guarantee to successfully flush at least one complete compressed block in all circumstances. */
+
+
+
+/*-***************************************************************************
+* Streaming decompression - HowTo
+*
+* A ZSTD_DStream object is required to track streaming operations.
+* Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources.
+* ZSTD_DStream objects can be re-used multiple times.
+*
+* Use ZSTD_initDStream() to start a new decompression operation,
+* or ZSTD_initDStream_usingDict() if decompression requires a dictionary.
+* @return : recommended first input size
+*
+* Use ZSTD_decompressStream() repetitively to consume your input.
+* The function will update both `pos` fields.
+* If `input.pos < input.size`, some input has not been consumed.
+* It's up to the caller to present again remaining data.
+* If `output.pos < output.size`, decoder has flushed everything it could.
+* @return : 0 when a frame is completely decoded and fully flushed,
+* an error code, which can be tested using ZSTD_isError(),
+* any other value > 0, which means there is still some decoding to do to complete current frame.
+* The return value is a suggested next input size (a hint to improve latency) that will never load more than the current frame.
+* *******************************************************************************/
+
+typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same object (>= v1.3.0) */
+ /* For compatibility with versions <= v1.2.0, continue to consider them separated. */
+/*===== ZSTD_DStream management functions =====*/
+ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void);
+ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds);
+
+/*===== Streaming decompression functions =====*/
+ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
+ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
+
+ZSTDLIB_API size_t ZSTD_DStreamInSize(void); /*!< recommended size for input buffer */
+ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */
+
+#endif /* ZSTD_H_235446 */
+
+
+
+
+#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
+#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
+
+/****************************************************************************************
+ * ADVANCED AND EXPERIMENTAL FUNCTIONS
+ ****************************************************************************************
+ * The definitions in this section are considered experimental.
+ * They should never be used with a dynamic library, as prototypes may change in the future.
+ * They are provided for advanced scenarios.
+ * Use them only in association with static linking.
+ * ***************************************************************************************/
+
+ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed */
+
+/* --- Constants ---*/
+#define ZSTD_MAGICNUMBER 0xFD2FB528 /* v0.8+ */
+#define ZSTD_MAGIC_DICTIONARY 0xEC30A437 /* v0.7+ */
+#define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50U
+
+#define ZSTD_BLOCKSIZELOG_MAX 17
+#define ZSTD_BLOCKSIZE_MAX (1<<ZSTD_BLOCKSIZELOG_MAX) /* define, for static allocation */
+
+#define ZSTD_WINDOWLOG_MAX_32 30
+#define ZSTD_WINDOWLOG_MAX_64 31
+#define ZSTD_WINDOWLOG_MAX ((unsigned)(sizeof(size_t) == 4 ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64))
+#define ZSTD_WINDOWLOG_MIN 10
+#define ZSTD_HASHLOG_MAX ((ZSTD_WINDOWLOG_MAX < 30) ? ZSTD_WINDOWLOG_MAX : 30)
+#define ZSTD_HASHLOG_MIN 6
+#define ZSTD_CHAINLOG_MAX_32 29
+#define ZSTD_CHAINLOG_MAX_64 30
+#define ZSTD_CHAINLOG_MAX ((unsigned)(sizeof(size_t) == 4 ? ZSTD_CHAINLOG_MAX_32 : ZSTD_CHAINLOG_MAX_64))
+#define ZSTD_CHAINLOG_MIN ZSTD_HASHLOG_MIN
+#define ZSTD_HASHLOG3_MAX 17
+#define ZSTD_SEARCHLOG_MAX (ZSTD_WINDOWLOG_MAX-1)
+#define ZSTD_SEARCHLOG_MIN 1
+#define ZSTD_SEARCHLENGTH_MAX 7 /* only for ZSTD_fast, other strategies are limited to 6 */
+#define ZSTD_SEARCHLENGTH_MIN 3 /* only for ZSTD_btopt, other strategies are limited to 4 */
+#define ZSTD_TARGETLENGTH_MAX ZSTD_BLOCKSIZE_MAX
+#define ZSTD_TARGETLENGTH_MIN 0 /* note : comparing this constant to an unsigned results in a tautological test */
+#define ZSTD_LDM_MINMATCH_MAX 4096
+#define ZSTD_LDM_MINMATCH_MIN 4
+#define ZSTD_LDM_BUCKETSIZELOG_MAX 8
+
+#define ZSTD_FRAMEHEADERSIZE_PREFIX 5 /* minimum input size to know frame header size */
+#define ZSTD_FRAMEHEADERSIZE_MIN 6
+#define ZSTD_FRAMEHEADERSIZE_MAX 18 /* for static allocation */
+static const size_t ZSTD_frameHeaderSize_prefix = ZSTD_FRAMEHEADERSIZE_PREFIX;
+static const size_t ZSTD_frameHeaderSize_min = ZSTD_FRAMEHEADERSIZE_MIN;
+static const size_t ZSTD_frameHeaderSize_max = ZSTD_FRAMEHEADERSIZE_MAX;
+static const size_t ZSTD_skippableHeaderSize = 8; /* magic number + skippable frame length */
+
+
+
+/* --- Advanced types --- */
+typedef enum { ZSTD_fast=1, ZSTD_dfast, ZSTD_greedy, ZSTD_lazy, ZSTD_lazy2,
+ ZSTD_btlazy2, ZSTD_btopt, ZSTD_btultra } ZSTD_strategy; /* from faster to stronger */
+
+typedef struct {
+ unsigned windowLog; /**< largest match distance : larger == more compression, more memory needed during decompression */
+ unsigned chainLog; /**< fully searched segment : larger == more compression, slower, more memory (useless for fast) */
+ unsigned hashLog; /**< dispatch table : larger == faster, more memory */
+ unsigned searchLog; /**< nb of searches : larger == more compression, slower */
+ unsigned searchLength; /**< match length searched : larger == faster decompression, sometimes less compression */
+ unsigned targetLength; /**< acceptable match size for optimal parser (only) : larger == more compression, slower */
+ ZSTD_strategy strategy;
+} ZSTD_compressionParameters;
+
+typedef struct {
+ unsigned contentSizeFlag; /**< 1: content size will be in frame header (when known) */
+ unsigned checksumFlag; /**< 1: generate a 32-bits checksum at end of frame, for error detection */
+ unsigned noDictIDFlag; /**< 1: no dictID will be saved into frame header (if dictionary compression) */
+} ZSTD_frameParameters;
+
+typedef struct {
+ ZSTD_compressionParameters cParams;
+ ZSTD_frameParameters fParams;
+} ZSTD_parameters;
+
+typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
+
+typedef enum {
+ ZSTD_dct_auto=0, /* dictionary is "full" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */
+ ZSTD_dct_rawContent, /* ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */
+ ZSTD_dct_fullDict /* refuses to load a dictionary if it does not respect Zstandard's specification */
+} ZSTD_dictContentType_e;
+
+typedef enum {
+ ZSTD_dlm_byCopy = 0, /**< Copy dictionary content internally */
+ ZSTD_dlm_byRef, /**< Reference dictionary content -- the dictionary buffer must outlive its users. */
+} ZSTD_dictLoadMethod_e;
+
+
+
+/***************************************
+* Frame size functions
+***************************************/
+
+/*! ZSTD_findFrameCompressedSize() :
+ * `src` should point to the start of a ZSTD encoded frame or skippable frame
+ * `srcSize` must be >= first frame size
+ * @return : the compressed size of the first frame starting at `src`,
+ * suitable to pass to `ZSTD_decompress` or similar,
+ * or an error code if input is invalid */
+ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize);
+
+/*! ZSTD_findDecompressedSize() :
+ * `src` should point the start of a series of ZSTD encoded and/or skippable frames
+ * `srcSize` must be the _exact_ size of this series
+ * (i.e. there should be a frame boundary exactly at `srcSize` bytes after `src`)
+ * @return : - decompressed size of all data in all successive frames
+ * - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN
+ * - if an error occurred: ZSTD_CONTENTSIZE_ERROR
+ *
+ * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
+ * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
+ * In which case, it's necessary to use streaming mode to decompress data.
+ * note 2 : decompressed size is always present when compression is done with ZSTD_compress()
+ * note 3 : decompressed size can be very large (64-bits value),
+ * potentially larger than what local system can handle as a single memory segment.
+ * In which case, it's necessary to use streaming mode to decompress data.
+ * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified.
+ * Always ensure result fits within application's authorized limits.
+ * Each application can set its own limits.
+ * note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to
+ * read each contained frame header. This is fast as most of the data is skipped,
+ * however it does mean that all frame data must be present and valid. */
+ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
+
+/*! ZSTD_frameHeaderSize() :
+ * srcSize must be >= ZSTD_frameHeaderSize_prefix.
+ * @return : size of the Frame Header,
+ * or an error code (if srcSize is too small) */
+ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
+
+
+/***************************************
+* Memory management
+***************************************/
+
+/*! ZSTD_sizeof_*() :
+ * These functions give the current memory usage of selected object.
+ * Object memory usage can evolve when re-used. */
+ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
+ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx);
+ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs);
+ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
+ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict);
+ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
+
+/*! ZSTD_estimate*() :
+ * These functions make it possible to estimate memory usage
+ * of a future {D,C}Ctx, before its creation.
+ * ZSTD_estimateCCtxSize() will provide a budget large enough for any compression level up to selected one.
+ * It will also consider src size to be arbitrarily "large", which is worst case.
+ * If srcSize is known to always be small, ZSTD_estimateCCtxSize_usingCParams() can provide a tighter estimation.
+ * ZSTD_estimateCCtxSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
+ * ZSTD_estimateCCtxSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbWorkers is >= 1.
+ * Note : CCtx size estimation is only correct for single-threaded compression. */
+ZSTDLIB_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
+ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
+ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
+ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
+
+/*! ZSTD_estimateCStreamSize() :
+ * ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one.
+ * It will also consider src size to be arbitrarily "large", which is worst case.
+ * If srcSize is known to always be small, ZSTD_estimateCStreamSize_usingCParams() can provide a tighter estimation.
+ * ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
+ * ZSTD_estimateCStreamSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_p_nbWorkers is >= 1.
+ * Note : CStream size estimation is only correct for single-threaded compression.
+ * ZSTD_DStream memory budget depends on window Size.
+ * This information can be passed manually, using ZSTD_estimateDStreamSize,
+ * or deducted from a valid frame Header, using ZSTD_estimateDStreamSize_fromFrame();
+ * Note : if streaming is init with function ZSTD_init?Stream_usingDict(),
+ * an internal ?Dict will be created, which additional size is not estimated here.
+ * In this case, get total size by adding ZSTD_estimate?DictSize */
+ZSTDLIB_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
+ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
+ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
+ZSTDLIB_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
+ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
+
+/*! ZSTD_estimate?DictSize() :
+ * ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict().
+ * ZSTD_estimateCDictSize_advanced() makes it possible to control compression parameters precisely, like ZSTD_createCDict_advanced().
+ * Note : dictionaries created by reference (`ZSTD_dlm_byRef`) are logically smaller.
+ */
+ZSTDLIB_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
+ZSTDLIB_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod);
+ZSTDLIB_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod);
+
+/*! ZSTD_initStatic*() :
+ * Initialize an object using a pre-allocated fixed-size buffer.
+ * workspace: The memory area to emplace the object into.
+ * Provided pointer *must be 8-bytes aligned*.
+ * Buffer must outlive object.
+ * workspaceSize: Use ZSTD_estimate*Size() to determine
+ * how large workspace must be to support target scenario.
+ * @return : pointer to object (same address as workspace, just different type),
+ * or NULL if error (size too small, incorrect alignment, etc.)
+ * Note : zstd will never resize nor malloc() when using a static buffer.
+ * If the object requires more memory than available,
+ * zstd will just error out (typically ZSTD_error_memory_allocation).
+ * Note 2 : there is no corresponding "free" function.
+ * Since workspace is allocated externally, it must be freed externally too.
+ * Note 3 : cParams : use ZSTD_getCParams() to convert a compression level
+ * into its associated cParams.
+ * Limitation 1 : currently not compatible with internal dictionary creation, triggered by
+ * ZSTD_CCtx_loadDictionary(), ZSTD_initCStream_usingDict() or ZSTD_initDStream_usingDict().
+ * Limitation 2 : static cctx currently not compatible with multi-threading.
+ * Limitation 3 : static dctx is incompatible with legacy support.
+ */
+ZSTDLIB_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize);
+ZSTDLIB_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticCCtx() */
+
+ZSTDLIB_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize);
+ZSTDLIB_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticDCtx() */
+
+ZSTDLIB_API const ZSTD_CDict* ZSTD_initStaticCDict(
+ void* workspace, size_t workspaceSize,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_compressionParameters cParams);
+
+ZSTDLIB_API const ZSTD_DDict* ZSTD_initStaticDDict(
+ void* workspace, size_t workspaceSize,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType);
+
+/*! Custom memory allocation :
+ * These prototypes make it possible to pass your own allocation/free functions.
+ * ZSTD_customMem is provided at creation time, using ZSTD_create*_advanced() variants listed below.
+ * All allocation/free operations will be completed using these custom variants instead of regular <stdlib.h> ones.
+ */
+typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
+typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
+typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
+static ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */
+
+ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
+ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
+ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem);
+ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem);
+
+ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_compressionParameters cParams,
+ ZSTD_customMem customMem);
+
+ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_customMem customMem);
+
+
+
+/***************************************
+* Advanced compression functions
+***************************************/
+
+/*! ZSTD_createCDict_byReference() :
+ * Create a digested dictionary for compression
+ * Dictionary content is simply referenced, and therefore stays in dictBuffer.
+ * It is important that dictBuffer outlives CDict, it must remain read accessible throughout the lifetime of CDict */
+ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
+
+/*! ZSTD_getCParams() :
+* @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize.
+* `estimatedSrcSize` value is optional, select 0 if not known */
+ZSTDLIB_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
+
+/*! ZSTD_getParams() :
+* same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`.
+* All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 */
+ZSTDLIB_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
+
+/*! ZSTD_checkCParams() :
+* Ensure param values remain within authorized range */
+ZSTDLIB_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
+
+/*! ZSTD_adjustCParams() :
+ * optimize params for a given `srcSize` and `dictSize`.
+ * both values are optional, select `0` if unknown. */
+ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
+
+/*! ZSTD_compress_advanced() :
+* Same as ZSTD_compress_usingDict(), with fine-tune control over each compression parameter */
+ZSTDLIB_API size_t ZSTD_compress_advanced (ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict,size_t dictSize,
+ ZSTD_parameters params);
+
+/*! ZSTD_compress_usingCDict_advanced() :
+* Same as ZSTD_compress_usingCDict(), with fine-tune control over frame parameters */
+ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_CDict* cdict, ZSTD_frameParameters fParams);
+
+
+/*--- Advanced decompression functions ---*/
+
+/*! ZSTD_isFrame() :
+ * Tells if the content of `buffer` starts with a valid Frame Identifier.
+ * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0.
+ * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled.
+ * Note 3 : Skippable Frame Identifiers are considered valid. */
+ZSTDLIB_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
+
+/*! ZSTD_createDDict_byReference() :
+ * Create a digested dictionary, ready to start decompression operation without startup delay.
+ * Dictionary content is referenced, and therefore stays in dictBuffer.
+ * It is important that dictBuffer outlives DDict,
+ * it must remain read accessible throughout the lifetime of DDict */
+ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
+
+
+/*! ZSTD_getDictID_fromDict() :
+ * Provides the dictID stored within dictionary.
+ * if @return == 0, the dictionary is not conformant with Zstandard specification.
+ * It can still be loaded, but as a content-only dictionary. */
+ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize);
+
+/*! ZSTD_getDictID_fromDDict() :
+ * Provides the dictID of the dictionary loaded into `ddict`.
+ * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
+ * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
+ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
+
+/*! ZSTD_getDictID_fromFrame() :
+ * Provides the dictID required to decompressed the frame stored within `src`.
+ * If @return == 0, the dictID could not be decoded.
+ * This could for one of the following reasons :
+ * - The frame does not require a dictionary to be decoded (most common case).
+ * - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden information.
+ * Note : this use case also happens when using a non-conformant dictionary.
+ * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`).
+ * - This is not a Zstandard frame.
+ * When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code. */
+ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
+
+
+/********************************************************************
+* Advanced streaming functions
+********************************************************************/
+
+/*===== Advanced Streaming compression functions =====*/
+ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct. If it is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs, "0" also disables frame content size field. It may be enabled in the future. */
+ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); /**< creates of an internal CDict (incompatible with static CCtx), except if dict == NULL or dictSize < 8, in which case no dict is used. Note: dict is loaded with ZSTD_dm_auto (treated as a full zstd dictionary if it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy.*/
+ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct. If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. dict is loaded with ZSTD_dm_auto and ZSTD_dlm_byCopy. */
+ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); /**< note : cdict will just be referenced, and must outlive compression session */
+ZSTDLIB_API size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, ZSTD_frameParameters fParams, unsigned long long pledgedSrcSize); /**< same as ZSTD_initCStream_usingCDict(), with control over frame parameters. pledgedSrcSize must be correct. If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. */
+
+/*! ZSTD_resetCStream() :
+ * start a new compression job, using same parameters from previous job.
+ * This is typically useful to skip dictionary loading stage, since it will re-use it in-place.
+ * Note that zcs must be init at least once before using ZSTD_resetCStream().
+ * If pledgedSrcSize is not known at reset time, use macro ZSTD_CONTENTSIZE_UNKNOWN.
+ * If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end.
+ * For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs,
+ * but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead.
+ * @return : 0, or an error code (which can be tested using ZSTD_isError())
+ */
+ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
+
+
+typedef struct {
+ unsigned long long ingested; /* nb input bytes read and buffered */
+ unsigned long long consumed; /* nb input bytes actually compressed */
+ unsigned long long produced; /* nb of compressed bytes generated and buffered */
+ unsigned long long flushed; /* nb of compressed bytes flushed : not provided; can be tracked from caller side */
+ unsigned currentJobID; /* MT only : latest started job nb */
+ unsigned nbActiveWorkers; /* MT only : nb of workers actively compressing at probe time */
+} ZSTD_frameProgression;
+
+/* ZSTD_getFrameProgression() :
+ * tells how much data has been ingested (read from input)
+ * consumed (input actually compressed) and produced (output) for current frame.
+ * Note : (ingested - consumed) is amount of input data buffered internally, not yet compressed.
+ * Aggregates progression inside active worker threads.
+ */
+ZSTDLIB_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx);
+
+/*! ZSTD_toFlushNow() :
+ * Tell how many bytes are ready to be flushed immediately.
+ * Useful for multithreading scenarios (nbWorkers >= 1).
+ * Probe the oldest active job, defined as oldest job not yet entirely flushed,
+ * and check its output buffer.
+ * @return : amount of data stored in oldest job and ready to be flushed immediately.
+ * if @return == 0, it means either :
+ * + there is no active job (could be checked with ZSTD_frameProgression()), or
+ * + oldest job is still actively compressing data,
+ * but everything it has produced has also been flushed so far,
+ * therefore flushing speed is currently limited by production speed of oldest job
+ * irrespective of the speed of concurrent newer jobs.
+ */
+ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
+
+
+
+/*===== Advanced Streaming decompression functions =====*/
+typedef enum { DStream_p_maxWindowSize } ZSTD_DStreamParameter_e;
+ZSTDLIB_API size_t ZSTD_setDStreamParameter(ZSTD_DStream* zds, ZSTD_DStreamParameter_e paramType, unsigned paramValue); /* obsolete : this API will be removed in a future version */
+ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); /**< note: no dictionary will be used if dict == NULL or dictSize < 8 */
+ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict); /**< note : ddict is referenced, it must outlive decompression session */
+ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompression parameters from previous init; saves dictionary loading */
+
+
+/*********************************************************************
+* Buffer-less and synchronous inner streaming functions
+*
+* This is an advanced API, giving full control over buffer management, for users which need direct control over memory.
+* But it's also a complex one, with several restrictions, documented below.
+* Prefer normal streaming API for an easier experience.
+********************************************************************* */
+
+/**
+ Buffer-less streaming compression (synchronous mode)
+
+ A ZSTD_CCtx object is required to track streaming operations.
+ Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource.
+ ZSTD_CCtx object can be re-used multiple times within successive compression operations.
+
+ Start by initializing a context.
+ Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression,
+ or ZSTD_compressBegin_advanced(), for finer parameter control.
+ It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx()
+
+ Then, consume your input using ZSTD_compressContinue().
+ There are some important considerations to keep in mind when using this advanced function :
+ - ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only.
+ - Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks.
+ - Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario.
+ Worst case evaluation is provided by ZSTD_compressBound().
+ ZSTD_compressContinue() doesn't guarantee recover after a failed compression.
+ - ZSTD_compressContinue() presumes prior input ***is still accessible and unmodified*** (up to maximum distance size, see WindowLog).
+ It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks)
+ - ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps.
+ In which case, it will "discard" the relevant memory section from its history.
+
+ Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum.
+ It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
+ Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders.
+
+ `ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again.
+*/
+
+/*===== Buffer-less streaming compression functions =====*/
+ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
+ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
+ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */
+ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
+ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize); /* compression parameters are already set within cdict. pledgedSrcSize must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */
+ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */
+
+ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+
+
+/*-
+ Buffer-less streaming decompression (synchronous mode)
+
+ A ZSTD_DCtx object is required to track streaming operations.
+ Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it.
+ A ZSTD_DCtx object can be re-used multiple times.
+
+ First typical operation is to retrieve frame parameters, using ZSTD_getFrameHeader().
+ Frame header is extracted from the beginning of compressed frame, so providing only the frame's beginning is enough.
+ Data fragment must be large enough to ensure successful decoding.
+ `ZSTD_frameHeaderSize_max` bytes is guaranteed to always be large enough.
+ @result : 0 : successful decoding, the `ZSTD_frameHeader` structure is correctly filled.
+ >0 : `srcSize` is too small, please provide at least @result bytes on next attempt.
+ errorCode, which can be tested using ZSTD_isError().
+
+ It fills a ZSTD_frameHeader structure with important information to correctly decode the frame,
+ such as the dictionary ID, content size, or maximum back-reference distance (`windowSize`).
+ Note that these values could be wrong, either because of data corruption, or because a 3rd party deliberately spoofs false information.
+ As a consequence, check that values remain within valid application range.
+ For example, do not allocate memory blindly, check that `windowSize` is within expectation.
+ Each application can set its own limits, depending on local restrictions.
+ For extended interoperability, it is recommended to support `windowSize` of at least 8 MB.
+
+ ZSTD_decompressContinue() needs previous data blocks during decompression, up to `windowSize` bytes.
+ ZSTD_decompressContinue() is very sensitive to contiguity,
+ if 2 blocks don't follow each other, make sure that either the compressor breaks contiguity at the same place,
+ or that previous contiguous segment is large enough to properly handle maximum back-reference distance.
+ There are multiple ways to guarantee this condition.
+
+ The most memory efficient way is to use a round buffer of sufficient size.
+ Sufficient size is determined by invoking ZSTD_decodingBufferSize_min(),
+ which can @return an error code if required value is too large for current system (in 32-bits mode).
+ In a round buffer methodology, ZSTD_decompressContinue() decompresses each block next to previous one,
+ up to the moment there is not enough room left in the buffer to guarantee decoding another full block,
+ which maximum size is provided in `ZSTD_frameHeader` structure, field `blockSizeMax`.
+ At which point, decoding can resume from the beginning of the buffer.
+ Note that already decoded data stored in the buffer should be flushed before being overwritten.
+
+ There are alternatives possible, for example using two or more buffers of size `windowSize` each, though they consume more memory.
+
+ Finally, if you control the compression process, you can also ignore all buffer size rules,
+ as long as the encoder and decoder progress in "lock-step",
+ aka use exactly the same buffer sizes, break contiguity at the same place, etc.
+
+ Once buffers are setup, start decompression, with ZSTD_decompressBegin().
+ If decompression requires a dictionary, use ZSTD_decompressBegin_usingDict() or ZSTD_decompressBegin_usingDDict().
+
+ Then use ZSTD_nextSrcSizeToDecompress() and ZSTD_decompressContinue() alternatively.
+ ZSTD_nextSrcSizeToDecompress() tells how many bytes to provide as 'srcSize' to ZSTD_decompressContinue().
+ ZSTD_decompressContinue() requires this _exact_ amount of bytes, or it will fail.
+
+ @result of ZSTD_decompressContinue() is the number of bytes regenerated within 'dst' (necessarily <= dstCapacity).
+ It can be zero : it just means ZSTD_decompressContinue() has decoded some metadata item.
+ It can also be an error code, which can be tested with ZSTD_isError().
+
+ A frame is fully decoded when ZSTD_nextSrcSizeToDecompress() returns zero.
+ Context can then be reset to start a new decompression.
+
+ Note : it's possible to know if next input to present is a header or a block, using ZSTD_nextInputType().
+ This information is not required to properly decode a frame.
+
+ == Special case : skippable frames ==
+
+ Skippable frames allow integration of user-defined data into a flow of concatenated frames.
+ Skippable frames will be ignored (skipped) by decompressor.
+ The format of skippable frames is as follows :
+ a) Skippable frame ID - 4 Bytes, Little endian format, any value from 0x184D2A50 to 0x184D2A5F
+ b) Frame Size - 4 Bytes, Little endian format, unsigned 32-bits
+ c) Frame Content - any content (User Data) of length equal to Frame Size
+ For skippable frames ZSTD_getFrameHeader() returns zfhPtr->frameType==ZSTD_skippableFrame.
+ For skippable frames ZSTD_decompressContinue() always returns 0 : it only skips the content.
+*/
+
+/*===== Buffer-less streaming decompression functions =====*/
+typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_frameType_e;
+typedef struct {
+ unsigned long long frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */
+ unsigned long long windowSize; /* can be very large, up to <= frameContentSize */
+ unsigned blockSizeMax;
+ ZSTD_frameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */
+ unsigned headerSize;
+ unsigned dictID;
+ unsigned checksumFlag;
+} ZSTD_frameHeader;
+/** ZSTD_getFrameHeader() :
+ * decode Frame Header, or requires larger `srcSize`.
+ * @return : 0, `zfhPtr` is correctly filled,
+ * >0, `srcSize` is too small, value is wanted `srcSize` amount,
+ * or an error code, which can be tested using ZSTD_isError() */
+ZSTDLIB_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */
+ZSTDLIB_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */
+
+ZSTDLIB_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx);
+ZSTDLIB_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
+ZSTDLIB_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
+
+ZSTDLIB_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx);
+ZSTDLIB_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+
+/* misc */
+ZSTDLIB_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx);
+typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e;
+ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
+
+
+
+/* ============================================ */
+/** New advanced API (experimental) */
+/* ============================================ */
+
+/* API design :
+ * In this advanced API, parameters are pushed one by one into an existing context,
+ * using ZSTD_CCtx_set*() functions.
+ * Pushed parameters are sticky : they are applied to next job, and any subsequent job.
+ * It's possible to reset parameters to "default" using ZSTD_CCtx_reset().
+ * Important : "sticky" parameters only work with `ZSTD_compress_generic()` !
+ * For any other entry point, "sticky" parameters are ignored !
+ *
+ * This API is intended to replace all others advanced / experimental API entry points.
+ */
+
+/* note on enum design :
+ * All enum will be pinned to explicit values before reaching "stable API" status */
+
+typedef enum {
+ /* Opened question : should we have a format ZSTD_f_auto ?
+ * Today, it would mean exactly the same as ZSTD_f_zstd1.
+ * But, in the future, should several formats become supported,
+ * on the compression side, it would mean "default format".
+ * On the decompression side, it would mean "automatic format detection",
+ * so that ZSTD_f_zstd1 would mean "accept *only* zstd frames".
+ * Since meaning is a little different, another option could be to define different enums for compression and decompression.
+ * This question could be kept for later, when there are actually multiple formats to support,
+ * but there is also the question of pinning enum values, and pinning value `0` is especially important */
+ ZSTD_f_zstd1 = 0, /* zstd frame format, specified in zstd_compression_format.md (default) */
+ ZSTD_f_zstd1_magicless, /* Variant of zstd frame format, without initial 4-bytes magic number.
+ * Useful to save 4 bytes per generated frame.
+ * Decoder cannot recognise automatically this format, requiring instructions. */
+} ZSTD_format_e;
+
+typedef enum {
+ /* compression format */
+ ZSTD_p_format = 10, /* See ZSTD_format_e enum definition.
+ * Cast selected format as unsigned for ZSTD_CCtx_setParameter() compatibility. */
+
+ /* compression parameters */
+ ZSTD_p_compressionLevel=100, /* Update all compression parameters according to pre-defined cLevel table
+ * Default level is ZSTD_CLEVEL_DEFAULT==3.
+ * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT.
+ * Note 1 : it's possible to pass a negative compression level by casting it to unsigned type.
+ * Note 2 : setting a level sets all default values of other compression parameters.
+ * Note 3 : setting compressionLevel automatically updates ZSTD_p_compressLiterals. */
+ ZSTD_p_windowLog, /* Maximum allowed back-reference distance, expressed as power of 2.
+ * Must be clamped between ZSTD_WINDOWLOG_MIN and ZSTD_WINDOWLOG_MAX.
+ * Special: value 0 means "use default windowLog".
+ * Note: Using a window size greater than ZSTD_MAXWINDOWSIZE_DEFAULT (default: 2^27)
+ * requires explicitly allowing such window size during decompression stage. */
+ ZSTD_p_hashLog, /* Size of the initial probe table, as a power of 2.
+ * Resulting table size is (1 << (hashLog+2)).
+ * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX.
+ * Larger tables improve compression ratio of strategies <= dFast,
+ * and improve speed of strategies > dFast.
+ * Special: value 0 means "use default hashLog". */
+ ZSTD_p_chainLog, /* Size of the multi-probe search table, as a power of 2.
+ * Resulting table size is (1 << (chainLog+2)).
+ * Must be clamped between ZSTD_CHAINLOG_MIN and ZSTD_CHAINLOG_MAX.
+ * Larger tables result in better and slower compression.
+ * This parameter is useless when using "fast" strategy.
+ * Note it's still useful when using "dfast" strategy,
+ * in which case it defines a secondary probe table.
+ * Special: value 0 means "use default chainLog". */
+ ZSTD_p_searchLog, /* Number of search attempts, as a power of 2.
+ * More attempts result in better and slower compression.
+ * This parameter is useless when using "fast" and "dFast" strategies.
+ * Special: value 0 means "use default searchLog". */
+ ZSTD_p_minMatch, /* Minimum size of searched matches (note : repCode matches can be smaller).
+ * Larger values make faster compression and decompression, but decrease ratio.
+ * Must be clamped between ZSTD_SEARCHLENGTH_MIN and ZSTD_SEARCHLENGTH_MAX.
+ * Note that currently, for all strategies < btopt, effective minimum is 4.
+ * , for all strategies > fast, effective maximum is 6.
+ * Special: value 0 means "use default minMatchLength". */
+ ZSTD_p_targetLength, /* Impact of this field depends on strategy.
+ * For strategies btopt & btultra:
+ * Length of Match considered "good enough" to stop search.
+ * Larger values make compression stronger, and slower.
+ * For strategy fast:
+ * Distance between match sampling.
+ * Larger values make compression faster, and weaker.
+ * Special: value 0 means "use default targetLength". */
+ ZSTD_p_compressionStrategy, /* See ZSTD_strategy enum definition.
+ * Cast selected strategy as unsigned for ZSTD_CCtx_setParameter() compatibility.
+ * The higher the value of selected strategy, the more complex it is,
+ * resulting in stronger and slower compression.
+ * Special: value 0 means "use default strategy". */
+
+ ZSTD_p_enableLongDistanceMatching=160, /* Enable long distance matching.
+ * This parameter is designed to improve compression ratio
+ * for large inputs, by finding large matches at long distance.
+ * It increases memory usage and window size.
+ * Note: enabling this parameter increases ZSTD_p_windowLog to 128 MB
+ * except when expressly set to a different value. */
+ ZSTD_p_ldmHashLog, /* Size of the table for long distance matching, as a power of 2.
+ * Larger values increase memory usage and compression ratio,
+ * but decrease compression speed.
+ * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX
+ * default: windowlog - 7.
+ * Special: value 0 means "automatically determine hashlog". */
+ ZSTD_p_ldmMinMatch, /* Minimum match size for long distance matcher.
+ * Larger/too small values usually decrease compression ratio.
+ * Must be clamped between ZSTD_LDM_MINMATCH_MIN and ZSTD_LDM_MINMATCH_MAX.
+ * Special: value 0 means "use default value" (default: 64). */
+ ZSTD_p_ldmBucketSizeLog, /* Log size of each bucket in the LDM hash table for collision resolution.
+ * Larger values improve collision resolution but decrease compression speed.
+ * The maximum value is ZSTD_LDM_BUCKETSIZELOG_MAX .
+ * Special: value 0 means "use default value" (default: 3). */
+ ZSTD_p_ldmHashEveryLog, /* Frequency of inserting/looking up entries in the LDM hash table.
+ * Must be clamped between 0 and (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN).
+ * Default is MAX(0, (windowLog - ldmHashLog)), optimizing hash table usage.
+ * Larger values improve compression speed.
+ * Deviating far from default value will likely result in a compression ratio decrease.
+ * Special: value 0 means "automatically determine hashEveryLog". */
+
+ /* frame parameters */
+ ZSTD_p_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1)
+ * Content size must be known at the beginning of compression,
+ * it is provided using ZSTD_CCtx_setPledgedSrcSize() */
+ ZSTD_p_checksumFlag, /* A 32-bits checksum of content is written at end of frame (default:0) */
+ ZSTD_p_dictIDFlag, /* When applicable, dictionary's ID is written into frame header (default:1) */
+
+ /* multi-threading parameters */
+ /* These parameters are only useful if multi-threading is enabled (ZSTD_MULTITHREAD).
+ * They return an error otherwise. */
+ ZSTD_p_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel.
+ * When nbWorkers >= 1, triggers asynchronous mode :
+ * ZSTD_compress_generic() consumes some input, flush some output if possible, and immediately gives back control to caller,
+ * while compression work is performed in parallel, within worker threads.
+ * (note : a strong exception to this rule is when first invocation sets ZSTD_e_end : it becomes a blocking call).
+ * More workers improve speed, but also increase memory usage.
+ * Default value is `0`, aka "single-threaded mode" : no worker is spawned, compression is performed inside Caller's thread, all invocations are blocking */
+ ZSTD_p_jobSize, /* Size of a compression job. This value is enforced only in non-blocking mode.
+ * Each compression job is completed in parallel, so this value indirectly controls the nb of active threads.
+ * 0 means default, which is dynamically determined based on compression parameters.
+ * Job size must be a minimum of overlapSize, or 1 MB, whichever is largest.
+ * The minimum size is automatically and transparently enforced */
+ ZSTD_p_overlapSizeLog, /* Size of previous input reloaded at the beginning of each job.
+ * 0 => no overlap, 6(default) => use 1/8th of windowSize, >=9 => use full windowSize */
+
+ /* =================================================================== */
+ /* experimental parameters - no stability guaranteed */
+ /* =================================================================== */
+
+ ZSTD_p_forceMaxWindow=1100, /* Force back-reference distances to remain < windowSize,
+ * even when referencing into Dictionary content (default:0) */
+ ZSTD_p_forceAttachDict, /* ZSTD supports usage of a CDict in-place
+ * (avoiding having to copy the compression tables
+ * from the CDict into the working context). Using
+ * a CDict in this way saves an initial setup step,
+ * but comes at the cost of more work per byte of
+ * input. ZSTD has a simple internal heuristic that
+ * guesses which strategy will be faster. You can
+ * use this flag to override that guess.
+ *
+ * Note that the by-reference, in-place strategy is
+ * only used when reusing a compression context
+ * with compatible compression parameters. (If
+ * incompatible / uninitialized, the working
+ * context needs to be cleared anyways, which is
+ * about as expensive as overwriting it with the
+ * dictionary context, so there's no savings in
+ * using the CDict by-ref.)
+ *
+ * Values greater than 0 force attaching the dict.
+ * Values less than 0 force copying the dict.
+ * 0 selects the default heuristic-guided behavior.
+ */
+
+} ZSTD_cParameter;
+
+
+/*! ZSTD_CCtx_setParameter() :
+ * Set one compression parameter, selected by enum ZSTD_cParameter.
+ * Setting a parameter is generally only possible during frame initialization (before starting compression).
+ * Exception : when using multi-threading mode (nbThreads >= 1),
+ * following parameters can be updated _during_ compression (within same frame):
+ * => compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy.
+ * new parameters will be active on next job, or after a flush().
+ * Note : when `value` type is not unsigned (int, or enum), cast it to unsigned for proper type checking.
+ * @result : informational value (typically, value being set, correctly clamped),
+ * or an error code (which can be tested with ZSTD_isError()). */
+ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value);
+
+/*! ZSTD_CCtx_getParameter() :
+ * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned* value);
+
+/*! ZSTD_CCtx_setPledgedSrcSize() :
+ * Total input data size to be compressed as a single frame.
+ * This value will be controlled at the end, and result in error if not respected.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Note 1 : 0 means zero, empty.
+ * In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN.
+ * ZSTD_CONTENTSIZE_UNKNOWN is default value for any new compression job.
+ * Note 2 : If all data is provided and consumed in a single round,
+ * this value is overriden by srcSize instead. */
+ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize);
+
+/*! ZSTD_CCtx_loadDictionary() :
+ * Create an internal CDict from `dict` buffer.
+ * Decompression will have to use same dictionary.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special: Adding a NULL (or 0-size) dictionary invalidates previous dictionary,
+ * meaning "return to no-dictionary mode".
+ * Note 1 : Dictionary will be used for all future compression jobs.
+ * To return to "no-dictionary" situation, load a NULL dictionary
+ * Note 2 : Loading a dictionary involves building tables, which are dependent on compression parameters.
+ * For this reason, compression parameters cannot be changed anymore after loading a dictionary.
+ * It's also a CPU consuming operation, with non-negligible impact on latency.
+ * Note 3 :`dict` content will be copied internally.
+ * Use ZSTD_CCtx_loadDictionary_byReference() to reference dictionary content instead.
+ * In such a case, dictionary buffer must outlive its users.
+ * Note 4 : Use ZSTD_CCtx_loadDictionary_advanced()
+ * to precisely select how dictionary content must be interpreted. */
+ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
+ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
+ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
+
+
+/*! ZSTD_CCtx_refCDict() :
+ * Reference a prepared dictionary, to be used for all next compression jobs.
+ * Note that compression parameters are enforced from within CDict,
+ * and supercede any compression parameter previously set within CCtx.
+ * The dictionary will remain valid for future compression jobs using same CCtx.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special : adding a NULL CDict means "return to no-dictionary mode".
+ * Note 1 : Currently, only one dictionary can be managed.
+ * Adding a new dictionary effectively "discards" any previous one.
+ * Note 2 : CDict is just referenced, its lifetime must outlive CCtx. */
+ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
+
+/*! ZSTD_CCtx_refPrefix() :
+ * Reference a prefix (single-usage dictionary) for next compression job.
+ * Decompression will need same prefix to properly regenerate data.
+ * Compressing with a prefix is similar in outcome as performing a diff and compressing it,
+ * but performs much faster, especially during decompression (compression speed is tunable with compression level).
+ * Note that prefix is **only used once**. Tables are discarded at end of compression job (ZSTD_e_end).
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary
+ * Note 1 : Prefix buffer is referenced. It **must** outlive compression job.
+ * Its contain must remain unmodified up to end of compression (ZSTD_e_end).
+ * Note 2 : If the intention is to diff some large src data blob with some prior version of itself,
+ * ensure that the window size is large enough to contain the entire source.
+ * See ZSTD_p_windowLog.
+ * Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters.
+ * It's a CPU consuming operation, with non-negligible impact on latency.
+ * If there is a need to use same prefix multiple times, consider loadDictionary instead.
+ * Note 4 : By default, the prefix is treated as raw content (ZSTD_dm_rawContent).
+ * Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode. */
+ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
+ const void* prefix, size_t prefixSize);
+ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx,
+ const void* prefix, size_t prefixSize,
+ ZSTD_dictContentType_e dictContentType);
+
+/*! ZSTD_CCtx_reset() :
+ * Return a CCtx to clean state.
+ * Useful after an error, or to interrupt an ongoing compression job and start a new one.
+ * Any internal data not yet flushed is cancelled.
+ * The parameters and dictionary are kept unchanged, to reset them use ZSTD_CCtx_resetParameters().
+ */
+ZSTDLIB_API void ZSTD_CCtx_reset(ZSTD_CCtx* cctx);
+
+/*! ZSTD_CCtx_resetParameters() :
+ * All parameters are back to default values (compression level is ZSTD_CLEVEL_DEFAULT).
+ * Dictionary (if any) is dropped.
+ * Resetting parameters is only possible during frame initialization (before starting compression).
+ * To reset the context use ZSTD_CCtx_reset().
+ * @return 0 or an error code (which can be checked with ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_CCtx_resetParameters(ZSTD_CCtx* cctx);
+
+
+
+typedef enum {
+ ZSTD_e_continue=0, /* collect more data, encoder decides when to output compressed result, for optimal conditions */
+ ZSTD_e_flush, /* flush any data provided so far - frame will continue, future data can still reference previous data for better compression */
+ ZSTD_e_end /* flush any remaining data and close current frame. Any additional data starts a new frame. */
+} ZSTD_EndDirective;
+
+/*! ZSTD_compress_generic() :
+ * Behave about the same as ZSTD_compressStream. To note :
+ * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_setParameter()
+ * - Compression parameters cannot be changed once compression is started.
+ * - outpot->pos must be <= dstCapacity, input->pos must be <= srcSize
+ * - outpot->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.
+ * - In single-thread mode (default), function is blocking : it completed its job before returning to caller.
+ * - In multi-thread mode, function is non-blocking : it just acquires a copy of input, and distribute job to internal worker threads,
+ * and then immediately returns, just indicating that there is some data remaining to be flushed.
+ * The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.
+ * - Exception : in multi-threading mode, if the first call requests a ZSTD_e_end directive, it is blocking : it will complete compression before giving back control to caller.
+ * - @return provides a minimum amount of data remaining to be flushed from internal buffers
+ * or an error code, which can be tested using ZSTD_isError().
+ * if @return != 0, flush is not fully completed, there is still some data left within internal buffers.
+ * This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers.
+ * For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed.
+ * - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0),
+ * only ZSTD_e_end or ZSTD_e_flush operations are allowed.
+ * Before starting a new compression job, or changing compression parameters,
+ * it is required to fully flush internal buffers.
+ */
+ZSTDLIB_API size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp);
+
+
+/*! ZSTD_compress_generic_simpleArgs() :
+ * Same as ZSTD_compress_generic(),
+ * but using only integral types as arguments.
+ * Argument list is larger than ZSTD_{in,out}Buffer,
+ * but can be helpful for binders from dynamic languages
+ * which have troubles handling structures containing memory pointers.
+ */
+ZSTDLIB_API size_t ZSTD_compress_generic_simpleArgs (
+ ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity, size_t* dstPos,
+ const void* src, size_t srcSize, size_t* srcPos,
+ ZSTD_EndDirective endOp);
+
+
+/*! ZSTD_CCtx_params :
+ * Quick howto :
+ * - ZSTD_createCCtxParams() : Create a ZSTD_CCtx_params structure
+ * - ZSTD_CCtxParam_setParameter() : Push parameters one by one into
+ * an existing ZSTD_CCtx_params structure.
+ * This is similar to
+ * ZSTD_CCtx_setParameter().
+ * - ZSTD_CCtx_setParametersUsingCCtxParams() : Apply parameters to
+ * an existing CCtx.
+ * These parameters will be applied to
+ * all subsequent compression jobs.
+ * - ZSTD_compress_generic() : Do compression using the CCtx.
+ * - ZSTD_freeCCtxParams() : Free the memory.
+ *
+ * This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams()
+ * for static allocation for single-threaded compression.
+ */
+ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void);
+ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params);
+
+
+/*! ZSTD_CCtxParams_reset() :
+ * Reset params to default values.
+ */
+ZSTDLIB_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params);
+
+/*! ZSTD_CCtxParams_init() :
+ * Initializes the compression parameters of cctxParams according to
+ * compression level. All other parameters are reset to their default values.
+ */
+ZSTDLIB_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel);
+
+/*! ZSTD_CCtxParams_init_advanced() :
+ * Initializes the compression and frame parameters of cctxParams according to
+ * params. All other parameters are reset to their default values.
+ */
+ZSTDLIB_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params);
+
+
+/*! ZSTD_CCtxParam_setParameter() :
+ * Similar to ZSTD_CCtx_setParameter.
+ * Set one compression parameter, selected by enum ZSTD_cParameter.
+ * Parameters must be applied to a ZSTD_CCtx using ZSTD_CCtx_setParametersUsingCCtxParams().
+ * Note : when `value` is an enum, cast it to unsigned for proper type checking.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_CCtxParam_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, unsigned value);
+
+/*! ZSTD_CCtxParam_getParameter() :
+ * Similar to ZSTD_CCtx_getParameter.
+ * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_CCtxParam_getParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, unsigned* value);
+
+/*! ZSTD_CCtx_setParametersUsingCCtxParams() :
+ * Apply a set of ZSTD_CCtx_params to the compression context.
+ * This can be done even after compression is started,
+ * if nbWorkers==0, this will have no impact until a new compression is started.
+ * if nbWorkers>=1, new parameters will be picked up at next job,
+ * with a few restrictions (windowLog, pledgedSrcSize, nbWorkers, jobSize, and overlapLog are not updated).
+ */
+ZSTDLIB_API size_t ZSTD_CCtx_setParametersUsingCCtxParams(
+ ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params);
+
+
+/* ==================================== */
+/*=== Advanced decompression API ===*/
+/* ==================================== */
+
+/* The following API works the same way as the advanced compression API :
+ * a context is created, parameters are pushed into it one by one,
+ * then the context can be used to decompress data using an interface similar to the straming API.
+ */
+
+/*! ZSTD_DCtx_loadDictionary() :
+ * Create an internal DDict from dict buffer,
+ * to be used to decompress next frames.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary,
+ * meaning "return to no-dictionary mode".
+ * Note 1 : `dict` content will be copied internally.
+ * Use ZSTD_DCtx_loadDictionary_byReference()
+ * to reference dictionary content instead.
+ * In which case, the dictionary buffer must outlive its users.
+ * Note 2 : Loading a dictionary involves building tables,
+ * which has a non-negligible impact on CPU usage and latency.
+ * Note 3 : Use ZSTD_DCtx_loadDictionary_advanced() to select
+ * how dictionary content will be interpreted and loaded.
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
+ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
+ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
+
+
+/*! ZSTD_DCtx_refDDict() :
+ * Reference a prepared dictionary, to be used to decompress next frames.
+ * The dictionary remains active for decompression of future frames using same DCtx.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Note 1 : Currently, only one dictionary can be managed.
+ * Referencing a new dictionary effectively "discards" any previous one.
+ * Special : adding a NULL DDict means "return to no-dictionary mode".
+ * Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx.
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
+
+
+/*! ZSTD_DCtx_refPrefix() :
+ * Reference a prefix (single-usage dictionary) for next compression job.
+ * This is the reverse operation of ZSTD_CCtx_refPrefix(),
+ * and must use the same prefix as the one used during compression.
+ * Prefix is **only used once**. Reference is discarded at end of frame.
+ * End of frame is reached when ZSTD_DCtx_decompress_generic() returns 0.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary
+ * Note 2 : Prefix buffer is referenced. It **must** outlive decompression job.
+ * Prefix buffer must remain unmodified up to the end of frame,
+ * reached when ZSTD_DCtx_decompress_generic() returns 0.
+ * Note 3 : By default, the prefix is treated as raw content (ZSTD_dm_rawContent).
+ * Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode.
+ * Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost.
+ * A fulldict prefix is more costly though.
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx,
+ const void* prefix, size_t prefixSize);
+ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx,
+ const void* prefix, size_t prefixSize,
+ ZSTD_dictContentType_e dictContentType);
+
+
+/*! ZSTD_DCtx_setMaxWindowSize() :
+ * Refuses allocating internal buffers for frames requiring a window size larger than provided limit.
+ * This is useful to prevent a decoder context from reserving too much memory for itself (potential attack scenario).
+ * This parameter is only useful in streaming mode, since no internal buffer is allocated in direct mode.
+ * By default, a decompression context accepts all window sizes <= (1 << ZSTD_WINDOWLOG_MAX)
+ * @return : 0, or an error code (which can be tested using ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
+
+
+/*! ZSTD_DCtx_setFormat() :
+ * Instruct the decoder context about what kind of data to decode next.
+ * This instruction is mandatory to decode data without a fully-formed header,
+ * such ZSTD_f_zstd1_magicless for example.
+ * @return : 0, or an error code (which can be tested using ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
+
+
+/*! ZSTD_getFrameHeader_advanced() :
+ * same as ZSTD_getFrameHeader(),
+ * with added capability to select a format (like ZSTD_f_zstd1_magicless) */
+ZSTDLIB_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr,
+ const void* src, size_t srcSize, ZSTD_format_e format);
+
+
+/*! ZSTD_decompress_generic() :
+ * Behave the same as ZSTD_decompressStream.
+ * Decompression parameters cannot be changed once decompression is started.
+ * @return : an error code, which can be tested using ZSTD_isError()
+ * if >0, a hint, nb of expected input bytes for next invocation.
+ * `0` means : a frame has just been fully decoded and flushed.
+ */
+ZSTDLIB_API size_t ZSTD_decompress_generic(ZSTD_DCtx* dctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input);
+
+
+/*! ZSTD_decompress_generic_simpleArgs() :
+ * Same as ZSTD_decompress_generic(),
+ * but using only integral types as arguments.
+ * Argument list is larger than ZSTD_{in,out}Buffer,
+ * but can be helpful for binders from dynamic languages
+ * which have troubles handling structures containing memory pointers.
+ */
+ZSTDLIB_API size_t ZSTD_decompress_generic_simpleArgs (
+ ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity, size_t* dstPos,
+ const void* src, size_t srcSize, size_t* srcPos);
+
+
+/*! ZSTD_DCtx_reset() :
+ * Return a DCtx to clean state.
+ * If a decompression was ongoing, any internal data not yet flushed is cancelled.
+ * All parameters are back to default values, including sticky ones.
+ * Dictionary (if any) is dropped.
+ * Parameters can be modified again after a reset.
+ */
+ZSTDLIB_API void ZSTD_DCtx_reset(ZSTD_DCtx* dctx);
+
+
+
+/* ============================ */
+/** Block level API */
+/* ============================ */
+
+/*!
+ Block functions produce and decode raw zstd blocks, without frame metadata.
+ Frame metadata cost is typically ~18 bytes, which can be non-negligible for very small blocks (< 100 bytes).
+ User will have to take in charge required information to regenerate data, such as compressed and content sizes.
+
+ A few rules to respect :
+ - Compressing and decompressing require a context structure
+ + Use ZSTD_createCCtx() and ZSTD_createDCtx()
+ - It is necessary to init context before starting
+ + compression : any ZSTD_compressBegin*() variant, including with dictionary
+ + decompression : any ZSTD_decompressBegin*() variant, including with dictionary
+ + copyCCtx() and copyDCtx() can be used too
+ - Block size is limited, it must be <= ZSTD_getBlockSize() <= ZSTD_BLOCKSIZE_MAX == 128 KB
+ + If input is larger than a block size, it's necessary to split input data into multiple blocks
+ + For inputs larger than a single block size, consider using the regular ZSTD_compress() instead.
+ Frame metadata is not that costly, and quickly becomes negligible as source size grows larger.
+ - When a block is considered not compressible enough, ZSTD_compressBlock() result will be zero.
+ In which case, nothing is produced into `dst`.
+ + User must test for such outcome and deal directly with uncompressed data
+ + ZSTD_decompressBlock() doesn't accept uncompressed data as input !!!
+ + In case of multiple successive blocks, should some of them be uncompressed,
+ decoder must be informed of their existence in order to follow proper history.
+ Use ZSTD_insertBlock() for such a case.
+*/
+
+/*===== Raw zstd block functions =====*/
+ZSTDLIB_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx);
+ZSTDLIB_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+ZSTDLIB_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+ZSTDLIB_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */
+
+
+#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/grub-core/lib/zstd/zstd_common.c b/grub-core/lib/zstd/zstd_common.c
new file mode 100644
index 0000000..6f05d24
--- /dev/null
+++ b/grub-core/lib/zstd/zstd_common.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+
+/*-*************************************
+* Dependencies
+***************************************/
+#include <stdlib.h> /* malloc, calloc, free */
+#include <string.h> /* memset */
+#include "error_private.h"
+#include "zstd_internal.h"
+
+
+/*-****************************************
+* Version
+******************************************/
+unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; }
+
+const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
+
+
+/*-****************************************
+* ZSTD Error Management
+******************************************/
+/*! ZSTD_isError() :
+ * tells if a return value is an error code */
+unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
+
+/*! ZSTD_getErrorName() :
+ * provides error code string from function result (useful for debugging) */
+const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
+
+/*! ZSTD_getError() :
+ * convert a `size_t` function result into a proper ZSTD_errorCode enum */
+ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
+
+/*! ZSTD_getErrorString() :
+ * provides error code string from enum */
+const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
+
+
+
+/*=**************************************************************
+* Custom allocator
+****************************************************************/
+void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
+{
+ if (customMem.customAlloc)
+ return customMem.customAlloc(customMem.opaque, size);
+ return malloc(size);
+}
+
+void* ZSTD_calloc(size_t size, ZSTD_customMem customMem)
+{
+ if (customMem.customAlloc) {
+ /* calloc implemented as malloc+memset;
+ * not as efficient as calloc, but next best guess for custom malloc */
+ void* const ptr = customMem.customAlloc(customMem.opaque, size);
+ memset(ptr, 0, size);
+ return ptr;
+ }
+ return calloc(1, size);
+}
+
+void ZSTD_free(void* ptr, ZSTD_customMem customMem)
+{
+ if (ptr!=NULL) {
+ if (customMem.customFree)
+ customMem.customFree(customMem.opaque, ptr);
+ else
+ free(ptr);
+ }
+}
diff --git a/grub-core/lib/zstd/zstd_decompress.c b/grub-core/lib/zstd/zstd_decompress.c
new file mode 100644
index 0000000..e4b5670
--- /dev/null
+++ b/grub-core/lib/zstd/zstd_decompress.c
@@ -0,0 +1,3108 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+/* ***************************************************************
+* Tuning parameters
+*****************************************************************/
+/*!
+ * HEAPMODE :
+ * Select how default decompression function ZSTD_decompress() allocates its context,
+ * on stack (0), or into heap (1, default; requires malloc()).
+ * Note that functions with explicit context such as ZSTD_decompressDCtx() are unaffected.
+ */
+#ifndef ZSTD_HEAPMODE
+# define ZSTD_HEAPMODE 1
+#endif
+
+/*!
+* LEGACY_SUPPORT :
+* if set to 1+, ZSTD_decompress() can decode older formats (v0.1+)
+*/
+#ifndef ZSTD_LEGACY_SUPPORT
+# define ZSTD_LEGACY_SUPPORT 0
+#endif
+
+/*!
+ * MAXWINDOWSIZE_DEFAULT :
+ * maximum window size accepted by DStream __by default__.
+ * Frames requiring more memory will be rejected.
+ * It's possible to set a different limit using ZSTD_DCtx_setMaxWindowSize().
+ */
+#ifndef ZSTD_MAXWINDOWSIZE_DEFAULT
+# define ZSTD_MAXWINDOWSIZE_DEFAULT (((U32)1 << ZSTD_WINDOWLOG_DEFAULTMAX) + 1)
+#endif
+
+/*!
+ * NO_FORWARD_PROGRESS_MAX :
+ * maximum allowed nb of calls to ZSTD_decompressStream() and ZSTD_decompress_generic()
+ * without any forward progress
+ * (defined as: no byte read from input, and no byte flushed to output)
+ * before triggering an error.
+ */
+#ifndef ZSTD_NO_FORWARD_PROGRESS_MAX
+# define ZSTD_NO_FORWARD_PROGRESS_MAX 16
+#endif
+
+
+/*-*******************************************************
+* Dependencies
+*********************************************************/
+#include <string.h> /* memcpy, memmove, memset */
+#include "compiler.h" /* prefetch */
+#include "cpu.h" /* bmi2 */
+#include "mem.h" /* low level memory routines */
+#define FSE_STATIC_LINKING_ONLY
+#include "fse.h"
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h"
+#include "zstd_internal.h"
+
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
+# include "zstd_legacy.h"
+#endif
+
+static const void* ZSTD_DDictDictContent(const ZSTD_DDict* ddict);
+static size_t ZSTD_DDictDictSize(const ZSTD_DDict* ddict);
+
+
+/*-*************************************
+* Errors
+***************************************/
+#define ZSTD_isError ERR_isError /* for inlining */
+#define FSE_isError ERR_isError
+#define HUF_isError ERR_isError
+
+
+/*_*******************************************************
+* Memory operations
+**********************************************************/
+static void ZSTD_copy4(void* dst, const void* src) { memcpy(dst, src, 4); }
+
+
+/*-*************************************************************
+* Context management
+***************************************************************/
+typedef enum { ZSTDds_getFrameHeaderSize, ZSTDds_decodeFrameHeader,
+ ZSTDds_decodeBlockHeader, ZSTDds_decompressBlock,
+ ZSTDds_decompressLastBlock, ZSTDds_checkChecksum,
+ ZSTDds_decodeSkippableHeader, ZSTDds_skipFrame } ZSTD_dStage;
+
+typedef enum { zdss_init=0, zdss_loadHeader,
+ zdss_read, zdss_load, zdss_flush } ZSTD_dStreamStage;
+
+
+typedef struct {
+ U32 fastMode;
+ U32 tableLog;
+} ZSTD_seqSymbol_header;
+
+typedef struct {
+ U16 nextState;
+ BYTE nbAdditionalBits;
+ BYTE nbBits;
+ U32 baseValue;
+} ZSTD_seqSymbol;
+
+#define SEQSYMBOL_TABLE_SIZE(log) (1 + (1 << (log)))
+
+typedef struct {
+ ZSTD_seqSymbol LLTable[SEQSYMBOL_TABLE_SIZE(LLFSELog)]; /* Note : Space reserved for FSE Tables */
+ ZSTD_seqSymbol OFTable[SEQSYMBOL_TABLE_SIZE(OffFSELog)]; /* is also used as temporary workspace while building hufTable during DDict creation */
+ ZSTD_seqSymbol MLTable[SEQSYMBOL_TABLE_SIZE(MLFSELog)]; /* and therefore must be at least HUF_DECOMPRESS_WORKSPACE_SIZE large */
+ HUF_DTable hufTable[HUF_DTABLE_SIZE(HufLog)]; /* can accommodate HUF_decompress4X */
+ U32 rep[ZSTD_REP_NUM];
+} ZSTD_entropyDTables_t;
+
+struct ZSTD_DCtx_s
+{
+ const ZSTD_seqSymbol* LLTptr;
+ const ZSTD_seqSymbol* MLTptr;
+ const ZSTD_seqSymbol* OFTptr;
+ const HUF_DTable* HUFptr;
+ ZSTD_entropyDTables_t entropy;
+ U32 workspace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; /* space needed when building huffman tables */
+ const void* previousDstEnd; /* detect continuity */
+ const void* prefixStart; /* start of current segment */
+ const void* virtualStart; /* virtual start of previous segment if it was just before current one */
+ const void* dictEnd; /* end of previous segment */
+ size_t expected;
+ ZSTD_frameHeader fParams;
+ U64 decodedSize;
+ blockType_e bType; /* used in ZSTD_decompressContinue(), store blockType between block header decoding and block decompression stages */
+ ZSTD_dStage stage;
+ U32 litEntropy;
+ U32 fseEntropy;
+ XXH64_state_t xxhState;
+ size_t headerSize;
+ ZSTD_format_e format;
+ const BYTE* litPtr;
+ ZSTD_customMem customMem;
+ size_t litSize;
+ size_t rleSize;
+ size_t staticSize;
+ int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */
+
+ /* dictionary */
+ ZSTD_DDict* ddictLocal;
+ const ZSTD_DDict* ddict; /* set by ZSTD_initDStream_usingDDict(), or ZSTD_DCtx_refDDict() */
+ U32 dictID;
+ int ddictIsCold; /* if == 1 : dictionary is "new" for working context, and presumed "cold" (not in cpu cache) */
+
+ /* streaming */
+ ZSTD_dStreamStage streamStage;
+ char* inBuff;
+ size_t inBuffSize;
+ size_t inPos;
+ size_t maxWindowSize;
+ char* outBuff;
+ size_t outBuffSize;
+ size_t outStart;
+ size_t outEnd;
+ size_t lhSize;
+ void* legacyContext;
+ U32 previousLegacyVersion;
+ U32 legacyVersion;
+ U32 hostageByte;
+ int noForwardProgress;
+
+ /* workspace */
+ BYTE litBuffer[ZSTD_BLOCKSIZE_MAX + WILDCOPY_OVERLENGTH];
+ BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
+}; /* typedef'd to ZSTD_DCtx within "zstd.h" */
+
+size_t ZSTD_sizeof_DCtx (const ZSTD_DCtx* dctx)
+{
+ if (dctx==NULL) return 0; /* support sizeof NULL */
+ return sizeof(*dctx)
+ + ZSTD_sizeof_DDict(dctx->ddictLocal)
+ + dctx->inBuffSize + dctx->outBuffSize;
+}
+
+size_t ZSTD_estimateDCtxSize(void) { return sizeof(ZSTD_DCtx); }
+
+
+static size_t ZSTD_startingInputLength(ZSTD_format_e format)
+{
+ size_t const startingInputLength = (format==ZSTD_f_zstd1_magicless) ?
+ ZSTD_frameHeaderSize_prefix - ZSTD_FRAMEIDSIZE :
+ ZSTD_frameHeaderSize_prefix;
+ ZSTD_STATIC_ASSERT(ZSTD_FRAMEHEADERSIZE_PREFIX >= ZSTD_FRAMEIDSIZE);
+ /* only supports formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless */
+ assert( (format == ZSTD_f_zstd1) || (format == ZSTD_f_zstd1_magicless) );
+ return startingInputLength;
+}
+
+static void ZSTD_initDCtx_internal(ZSTD_DCtx* dctx)
+{
+ dctx->format = ZSTD_f_zstd1; /* ZSTD_decompressBegin() invokes ZSTD_startingInputLength() with argument dctx->format */
+ dctx->staticSize = 0;
+ dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
+ dctx->ddict = NULL;
+ dctx->ddictLocal = NULL;
+ dctx->dictEnd = NULL;
+ dctx->ddictIsCold = 0;
+ dctx->inBuff = NULL;
+ dctx->inBuffSize = 0;
+ dctx->outBuffSize = 0;
+ dctx->streamStage = zdss_init;
+ dctx->legacyContext = NULL;
+ dctx->previousLegacyVersion = 0;
+ dctx->noForwardProgress = 0;
+ dctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid());
+}
+
+ZSTD_DCtx* ZSTD_initStaticDCtx(void *workspace, size_t workspaceSize)
+{
+ ZSTD_DCtx* const dctx = (ZSTD_DCtx*) workspace;
+
+ if ((size_t)workspace & 7) return NULL; /* 8-aligned */
+ if (workspaceSize < sizeof(ZSTD_DCtx)) return NULL; /* minimum size */
+
+ ZSTD_initDCtx_internal(dctx);
+ dctx->staticSize = workspaceSize;
+ dctx->inBuff = (char*)(dctx+1);
+ return dctx;
+}
+
+ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
+{
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
+
+ { ZSTD_DCtx* const dctx = (ZSTD_DCtx*)ZSTD_malloc(sizeof(*dctx), customMem);
+ if (!dctx) return NULL;
+ dctx->customMem = customMem;
+ ZSTD_initDCtx_internal(dctx);
+ return dctx;
+ }
+}
+
+ZSTD_DCtx* ZSTD_createDCtx(void)
+{
+ DEBUGLOG(3, "ZSTD_createDCtx");
+ return ZSTD_createDCtx_advanced(ZSTD_defaultCMem);
+}
+
+size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx)
+{
+ if (dctx==NULL) return 0; /* support free on NULL */
+ if (dctx->staticSize) return ERROR(memory_allocation); /* not compatible with static DCtx */
+ { ZSTD_customMem const cMem = dctx->customMem;
+ ZSTD_freeDDict(dctx->ddictLocal);
+ dctx->ddictLocal = NULL;
+ ZSTD_free(dctx->inBuff, cMem);
+ dctx->inBuff = NULL;
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (dctx->legacyContext)
+ ZSTD_freeLegacyStreamContext(dctx->legacyContext, dctx->previousLegacyVersion);
+#endif
+ ZSTD_free(dctx, cMem);
+ return 0;
+ }
+}
+
+/* no longer useful */
+void ZSTD_copyDCtx(ZSTD_DCtx* dstDCtx, const ZSTD_DCtx* srcDCtx)
+{
+ size_t const toCopy = (size_t)((char*)(&dstDCtx->inBuff) - (char*)dstDCtx);
+ memcpy(dstDCtx, srcDCtx, toCopy); /* no need to copy workspace */
+}
+
+
+/*-*************************************************************
+ * Frame header decoding
+ ***************************************************************/
+
+/*! ZSTD_isFrame() :
+ * Tells if the content of `buffer` starts with a valid Frame Identifier.
+ * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0.
+ * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled.
+ * Note 3 : Skippable Frame Identifiers are considered valid. */
+unsigned ZSTD_isFrame(const void* buffer, size_t size)
+{
+ if (size < ZSTD_FRAMEIDSIZE) return 0;
+ { U32 const magic = MEM_readLE32(buffer);
+ if (magic == ZSTD_MAGICNUMBER) return 1;
+ if ((magic & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) return 1;
+ }
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (ZSTD_isLegacy(buffer, size)) return 1;
+#endif
+ return 0;
+}
+
+/** ZSTD_frameHeaderSize_internal() :
+ * srcSize must be large enough to reach header size fields.
+ * note : only works for formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless.
+ * @return : size of the Frame Header
+ * or an error code, which can be tested with ZSTD_isError() */
+static size_t ZSTD_frameHeaderSize_internal(const void* src, size_t srcSize, ZSTD_format_e format)
+{
+ size_t const minInputSize = ZSTD_startingInputLength(format);
+ if (srcSize < minInputSize) return ERROR(srcSize_wrong);
+
+ { BYTE const fhd = ((const BYTE*)src)[minInputSize-1];
+ U32 const dictID= fhd & 3;
+ U32 const singleSegment = (fhd >> 5) & 1;
+ U32 const fcsId = fhd >> 6;
+ return minInputSize + !singleSegment
+ + ZSTD_did_fieldSize[dictID] + ZSTD_fcs_fieldSize[fcsId]
+ + (singleSegment && !fcsId);
+ }
+}
+
+/** ZSTD_frameHeaderSize() :
+ * srcSize must be >= ZSTD_frameHeaderSize_prefix.
+ * @return : size of the Frame Header,
+ * or an error code (if srcSize is too small) */
+size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize)
+{
+ return ZSTD_frameHeaderSize_internal(src, srcSize, ZSTD_f_zstd1);
+}
+
+
+/** ZSTD_getFrameHeader_advanced() :
+ * decode Frame Header, or require larger `srcSize`.
+ * note : only works for formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless
+ * @return : 0, `zfhPtr` is correctly filled,
+ * >0, `srcSize` is too small, value is wanted `srcSize` amount,
+ * or an error code, which can be tested using ZSTD_isError() */
+size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format)
+{
+ const BYTE* ip = (const BYTE*)src;
+ size_t const minInputSize = ZSTD_startingInputLength(format);
+
+ memset(zfhPtr, 0, sizeof(*zfhPtr)); /* not strictly necessary, but static analyzer do not understand that zfhPtr is only going to be read only if return value is zero, since they are 2 different signals */
+ if (srcSize < minInputSize) return minInputSize;
+ if (src==NULL) return ERROR(GENERIC); /* invalid parameter */
+
+ if ( (format != ZSTD_f_zstd1_magicless)
+ && (MEM_readLE32(src) != ZSTD_MAGICNUMBER) ) {
+ if ((MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
+ /* skippable frame */
+ if (srcSize < ZSTD_skippableHeaderSize)
+ return ZSTD_skippableHeaderSize; /* magic number + frame length */
+ memset(zfhPtr, 0, sizeof(*zfhPtr));
+ zfhPtr->frameContentSize = MEM_readLE32((const char *)src + ZSTD_FRAMEIDSIZE);
+ zfhPtr->frameType = ZSTD_skippableFrame;
+ return 0;
+ }
+ return ERROR(prefix_unknown);
+ }
+
+ /* ensure there is enough `srcSize` to fully read/decode frame header */
+ { size_t const fhsize = ZSTD_frameHeaderSize_internal(src, srcSize, format);
+ if (srcSize < fhsize) return fhsize;
+ zfhPtr->headerSize = (U32)fhsize;
+ }
+
+ { BYTE const fhdByte = ip[minInputSize-1];
+ size_t pos = minInputSize;
+ U32 const dictIDSizeCode = fhdByte&3;
+ U32 const checksumFlag = (fhdByte>>2)&1;
+ U32 const singleSegment = (fhdByte>>5)&1;
+ U32 const fcsID = fhdByte>>6;
+ U64 windowSize = 0;
+ U32 dictID = 0;
+ U64 frameContentSize = ZSTD_CONTENTSIZE_UNKNOWN;
+ if ((fhdByte & 0x08) != 0)
+ return ERROR(frameParameter_unsupported); /* reserved bits, must be zero */
+
+ if (!singleSegment) {
+ BYTE const wlByte = ip[pos++];
+ U32 const windowLog = (wlByte >> 3) + ZSTD_WINDOWLOG_ABSOLUTEMIN;
+ if (windowLog > ZSTD_WINDOWLOG_MAX)
+ return ERROR(frameParameter_windowTooLarge);
+ windowSize = (1ULL << windowLog);
+ windowSize += (windowSize >> 3) * (wlByte&7);
+ }
+ switch(dictIDSizeCode)
+ {
+ default: assert(0); /* impossible */
+ case 0 : break;
+ case 1 : dictID = ip[pos]; pos++; break;
+ case 2 : dictID = MEM_readLE16(ip+pos); pos+=2; break;
+ case 3 : dictID = MEM_readLE32(ip+pos); pos+=4; break;
+ }
+ switch(fcsID)
+ {
+ default: assert(0); /* impossible */
+ case 0 : if (singleSegment) frameContentSize = ip[pos]; break;
+ case 1 : frameContentSize = MEM_readLE16(ip+pos)+256; break;
+ case 2 : frameContentSize = MEM_readLE32(ip+pos); break;
+ case 3 : frameContentSize = MEM_readLE64(ip+pos); break;
+ }
+ if (singleSegment) windowSize = frameContentSize;
+
+ zfhPtr->frameType = ZSTD_frame;
+ zfhPtr->frameContentSize = frameContentSize;
+ zfhPtr->windowSize = windowSize;
+ zfhPtr->blockSizeMax = (unsigned) MIN(windowSize, ZSTD_BLOCKSIZE_MAX);
+ zfhPtr->dictID = dictID;
+ zfhPtr->checksumFlag = checksumFlag;
+ }
+ return 0;
+}
+
+/** ZSTD_getFrameHeader() :
+ * decode Frame Header, or require larger `srcSize`.
+ * note : this function does not consume input, it only reads it.
+ * @return : 0, `zfhPtr` is correctly filled,
+ * >0, `srcSize` is too small, value is wanted `srcSize` amount,
+ * or an error code, which can be tested using ZSTD_isError() */
+size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize)
+{
+ return ZSTD_getFrameHeader_advanced(zfhPtr, src, srcSize, ZSTD_f_zstd1);
+}
+
+
+/** ZSTD_getFrameContentSize() :
+ * compatible with legacy mode
+ * @return : decompressed size of the single frame pointed to be `src` if known, otherwise
+ * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
+ * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) */
+unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize)
+{
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (ZSTD_isLegacy(src, srcSize)) {
+ unsigned long long const ret = ZSTD_getDecompressedSize_legacy(src, srcSize);
+ return ret == 0 ? ZSTD_CONTENTSIZE_UNKNOWN : ret;
+ }
+#endif
+ { ZSTD_frameHeader zfh;
+ if (ZSTD_getFrameHeader(&zfh, src, srcSize) != 0)
+ return ZSTD_CONTENTSIZE_ERROR;
+ if (zfh.frameType == ZSTD_skippableFrame) {
+ return 0;
+ } else {
+ return zfh.frameContentSize;
+ } }
+}
+
+/** ZSTD_findDecompressedSize() :
+ * compatible with legacy mode
+ * `srcSize` must be the exact length of some number of ZSTD compressed and/or
+ * skippable frames
+ * @return : decompressed size of the frames contained */
+unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize)
+{
+ unsigned long long totalDstSize = 0;
+
+ while (srcSize >= ZSTD_frameHeaderSize_prefix) {
+ U32 const magicNumber = MEM_readLE32(src);
+
+ if ((magicNumber & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
+ size_t skippableSize;
+ if (srcSize < ZSTD_skippableHeaderSize)
+ return ERROR(srcSize_wrong);
+ skippableSize = MEM_readLE32((const BYTE *)src + ZSTD_FRAMEIDSIZE)
+ + ZSTD_skippableHeaderSize;
+ if (srcSize < skippableSize) {
+ return ZSTD_CONTENTSIZE_ERROR;
+ }
+
+ src = (const BYTE *)src + skippableSize;
+ srcSize -= skippableSize;
+ continue;
+ }
+
+ { unsigned long long const ret = ZSTD_getFrameContentSize(src, srcSize);
+ if (ret >= ZSTD_CONTENTSIZE_ERROR) return ret;
+
+ /* check for overflow */
+ if (totalDstSize + ret < totalDstSize) return ZSTD_CONTENTSIZE_ERROR;
+ totalDstSize += ret;
+ }
+ { size_t const frameSrcSize = ZSTD_findFrameCompressedSize(src, srcSize);
+ if (ZSTD_isError(frameSrcSize)) {
+ return ZSTD_CONTENTSIZE_ERROR;
+ }
+
+ src = (const BYTE *)src + frameSrcSize;
+ srcSize -= frameSrcSize;
+ }
+ } /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */
+
+ if (srcSize) return ZSTD_CONTENTSIZE_ERROR;
+
+ return totalDstSize;
+}
+
+/** ZSTD_getDecompressedSize() :
+* compatible with legacy mode
+* @return : decompressed size if known, 0 otherwise
+ note : 0 can mean any of the following :
+ - frame content is empty
+ - decompressed size field is not present in frame header
+ - frame header unknown / not supported
+ - frame header not complete (`srcSize` too small) */
+unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize)
+{
+ unsigned long long const ret = ZSTD_getFrameContentSize(src, srcSize);
+ ZSTD_STATIC_ASSERT(ZSTD_CONTENTSIZE_ERROR < ZSTD_CONTENTSIZE_UNKNOWN);
+ return (ret >= ZSTD_CONTENTSIZE_ERROR) ? 0 : ret;
+}
+
+
+/** ZSTD_decodeFrameHeader() :
+* `headerSize` must be the size provided by ZSTD_frameHeaderSize().
+* @return : 0 if success, or an error code, which can be tested using ZSTD_isError() */
+static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t headerSize)
+{
+ size_t const result = ZSTD_getFrameHeader_advanced(&(dctx->fParams), src, headerSize, dctx->format);
+ if (ZSTD_isError(result)) return result; /* invalid header */
+ if (result>0) return ERROR(srcSize_wrong); /* headerSize too small */
+ if (dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID))
+ return ERROR(dictionary_wrong);
+ if (dctx->fParams.checksumFlag) XXH64_reset(&dctx->xxhState, 0);
+ return 0;
+}
+
+
+/*-*************************************************************
+ * Block decoding
+ ***************************************************************/
+
+/*! ZSTD_getcBlockSize() :
+* Provides the size of compressed block from block header `src` */
+size_t ZSTD_getcBlockSize(const void* src, size_t srcSize,
+ blockProperties_t* bpPtr)
+{
+ if (srcSize < ZSTD_blockHeaderSize) return ERROR(srcSize_wrong);
+ { U32 const cBlockHeader = MEM_readLE24(src);
+ U32 const cSize = cBlockHeader >> 3;
+ bpPtr->lastBlock = cBlockHeader & 1;
+ bpPtr->blockType = (blockType_e)((cBlockHeader >> 1) & 3);
+ bpPtr->origSize = cSize; /* only useful for RLE */
+ if (bpPtr->blockType == bt_rle) return 1;
+ if (bpPtr->blockType == bt_reserved) return ERROR(corruption_detected);
+ return cSize;
+ }
+}
+
+
+static size_t ZSTD_copyRawBlock(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
+{
+ if (dst==NULL) return ERROR(dstSize_tooSmall);
+ if (srcSize > dstCapacity) return ERROR(dstSize_tooSmall);
+ memcpy(dst, src, srcSize);
+ return srcSize;
+}
+
+
+static size_t ZSTD_setRleBlock(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ size_t regenSize)
+{
+ if (srcSize != 1) return ERROR(srcSize_wrong);
+ if (regenSize > dstCapacity) return ERROR(dstSize_tooSmall);
+ memset(dst, *(const BYTE*)src, regenSize);
+ return regenSize;
+}
+
+/* Hidden declaration for fullbench */
+size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
+ const void* src, size_t srcSize);
+/*! ZSTD_decodeLiteralsBlock() :
+ * @return : nb of bytes read from src (< srcSize )
+ * note : symbol not declared but exposed for fullbench */
+size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
+ const void* src, size_t srcSize) /* note : srcSize < BLOCKSIZE */
+{
+ if (srcSize < MIN_CBLOCK_SIZE) return ERROR(corruption_detected);
+
+ { const BYTE* const istart = (const BYTE*) src;
+ symbolEncodingType_e const litEncType = (symbolEncodingType_e)(istart[0] & 3);
+
+ switch(litEncType)
+ {
+ case set_repeat:
+ if (dctx->litEntropy==0) return ERROR(dictionary_corrupted);
+ /* fall-through */
+
+ case set_compressed:
+ if (srcSize < 5) return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need up to 5 for case 3 */
+ { size_t lhSize, litSize, litCSize;
+ U32 singleStream=0;
+ U32 const lhlCode = (istart[0] >> 2) & 3;
+ U32 const lhc = MEM_readLE32(istart);
+ switch(lhlCode)
+ {
+ case 0: case 1: default: /* note : default is impossible, since lhlCode into [0..3] */
+ /* 2 - 2 - 10 - 10 */
+ singleStream = !lhlCode;
+ lhSize = 3;
+ litSize = (lhc >> 4) & 0x3FF;
+ litCSize = (lhc >> 14) & 0x3FF;
+ break;
+ case 2:
+ /* 2 - 2 - 14 - 14 */
+ lhSize = 4;
+ litSize = (lhc >> 4) & 0x3FFF;
+ litCSize = lhc >> 18;
+ break;
+ case 3:
+ /* 2 - 2 - 18 - 18 */
+ lhSize = 5;
+ litSize = (lhc >> 4) & 0x3FFFF;
+ litCSize = (lhc >> 22) + (istart[4] << 10);
+ break;
+ }
+ if (litSize > ZSTD_BLOCKSIZE_MAX) return ERROR(corruption_detected);
+ if (litCSize + lhSize > srcSize) return ERROR(corruption_detected);
+
+ /* prefetch huffman table if cold */
+ if (dctx->ddictIsCold && (litSize > 768 /* heuristic */)) {
+ PREFETCH_AREA(dctx->HUFptr, sizeof(dctx->entropy.hufTable));
+ }
+
+ if (HUF_isError((litEncType==set_repeat) ?
+ ( singleStream ?
+ HUF_decompress1X_usingDTable_bmi2(dctx->litBuffer, litSize, istart+lhSize, litCSize, dctx->HUFptr, dctx->bmi2) :
+ HUF_decompress4X_usingDTable_bmi2(dctx->litBuffer, litSize, istart+lhSize, litCSize, dctx->HUFptr, dctx->bmi2) ) :
+ ( singleStream ?
+ HUF_decompress1X1_DCtx_wksp_bmi2(dctx->entropy.hufTable, dctx->litBuffer, litSize, istart+lhSize, litCSize,
+ dctx->workspace, sizeof(dctx->workspace), dctx->bmi2) :
+ HUF_decompress4X_hufOnly_wksp_bmi2(dctx->entropy.hufTable, dctx->litBuffer, litSize, istart+lhSize, litCSize,
+ dctx->workspace, sizeof(dctx->workspace), dctx->bmi2))))
+ return ERROR(corruption_detected);
+
+ dctx->litPtr = dctx->litBuffer;
+ dctx->litSize = litSize;
+ dctx->litEntropy = 1;
+ if (litEncType==set_compressed) dctx->HUFptr = dctx->entropy.hufTable;
+ memset(dctx->litBuffer + dctx->litSize, 0, WILDCOPY_OVERLENGTH);
+ return litCSize + lhSize;
+ }
+
+ case set_basic:
+ { size_t litSize, lhSize;
+ U32 const lhlCode = ((istart[0]) >> 2) & 3;
+ switch(lhlCode)
+ {
+ case 0: case 2: default: /* note : default is impossible, since lhlCode into [0..3] */
+ lhSize = 1;
+ litSize = istart[0] >> 3;
+ break;
+ case 1:
+ lhSize = 2;
+ litSize = MEM_readLE16(istart) >> 4;
+ break;
+ case 3:
+ lhSize = 3;
+ litSize = MEM_readLE24(istart) >> 4;
+ break;
+ }
+
+ if (lhSize+litSize+WILDCOPY_OVERLENGTH > srcSize) { /* risk reading beyond src buffer with wildcopy */
+ if (litSize+lhSize > srcSize) return ERROR(corruption_detected);
+ memcpy(dctx->litBuffer, istart+lhSize, litSize);
+ dctx->litPtr = dctx->litBuffer;
+ dctx->litSize = litSize;
+ memset(dctx->litBuffer + dctx->litSize, 0, WILDCOPY_OVERLENGTH);
+ return lhSize+litSize;
+ }
+ /* direct reference into compressed stream */
+ dctx->litPtr = istart+lhSize;
+ dctx->litSize = litSize;
+ return lhSize+litSize;
+ }
+
+ case set_rle:
+ { U32 const lhlCode = ((istart[0]) >> 2) & 3;
+ size_t litSize, lhSize;
+ switch(lhlCode)
+ {
+ case 0: case 2: default: /* note : default is impossible, since lhlCode into [0..3] */
+ lhSize = 1;
+ litSize = istart[0] >> 3;
+ break;
+ case 1:
+ lhSize = 2;
+ litSize = MEM_readLE16(istart) >> 4;
+ break;
+ case 3:
+ lhSize = 3;
+ litSize = MEM_readLE24(istart) >> 4;
+ if (srcSize<4) return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need lhSize+1 = 4 */
+ break;
+ }
+ if (litSize > ZSTD_BLOCKSIZE_MAX) return ERROR(corruption_detected);
+ memset(dctx->litBuffer, istart[lhSize], litSize + WILDCOPY_OVERLENGTH);
+ dctx->litPtr = dctx->litBuffer;
+ dctx->litSize = litSize;
+ return lhSize+1;
+ }
+ default:
+ return ERROR(corruption_detected); /* impossible */
+ }
+ }
+}
+
+/* Default FSE distribution tables.
+ * These are pre-calculated FSE decoding tables using default distributions as defined in specification :
+ * https://github.com/facebook/zstd/blob/master/doc/zstd_compression_format.md#default-distributions
+ * They were generated programmatically with following method :
+ * - start from default distributions, present in /lib/common/zstd_internal.h
+ * - generate tables normally, using ZSTD_buildFSETable()
+ * - printout the content of tables
+ * - pretify output, report below, test with fuzzer to ensure it's correct */
+
+/* Default FSE distribution table for Literal Lengths */
+static const ZSTD_seqSymbol LL_defaultDTable[(1<<LL_DEFAULTNORMLOG)+1] = {
+ { 1, 1, 1, LL_DEFAULTNORMLOG}, /* header : fastMode, tableLog */
+ /* nextState, nbAddBits, nbBits, baseVal */
+ { 0, 0, 4, 0}, { 16, 0, 4, 0},
+ { 32, 0, 5, 1}, { 0, 0, 5, 3},
+ { 0, 0, 5, 4}, { 0, 0, 5, 6},
+ { 0, 0, 5, 7}, { 0, 0, 5, 9},
+ { 0, 0, 5, 10}, { 0, 0, 5, 12},
+ { 0, 0, 6, 14}, { 0, 1, 5, 16},
+ { 0, 1, 5, 20}, { 0, 1, 5, 22},
+ { 0, 2, 5, 28}, { 0, 3, 5, 32},
+ { 0, 4, 5, 48}, { 32, 6, 5, 64},
+ { 0, 7, 5, 128}, { 0, 8, 6, 256},
+ { 0, 10, 6, 1024}, { 0, 12, 6, 4096},
+ { 32, 0, 4, 0}, { 0, 0, 4, 1},
+ { 0, 0, 5, 2}, { 32, 0, 5, 4},
+ { 0, 0, 5, 5}, { 32, 0, 5, 7},
+ { 0, 0, 5, 8}, { 32, 0, 5, 10},
+ { 0, 0, 5, 11}, { 0, 0, 6, 13},
+ { 32, 1, 5, 16}, { 0, 1, 5, 18},
+ { 32, 1, 5, 22}, { 0, 2, 5, 24},
+ { 32, 3, 5, 32}, { 0, 3, 5, 40},
+ { 0, 6, 4, 64}, { 16, 6, 4, 64},
+ { 32, 7, 5, 128}, { 0, 9, 6, 512},
+ { 0, 11, 6, 2048}, { 48, 0, 4, 0},
+ { 16, 0, 4, 1}, { 32, 0, 5, 2},
+ { 32, 0, 5, 3}, { 32, 0, 5, 5},
+ { 32, 0, 5, 6}, { 32, 0, 5, 8},
+ { 32, 0, 5, 9}, { 32, 0, 5, 11},
+ { 32, 0, 5, 12}, { 0, 0, 6, 15},
+ { 32, 1, 5, 18}, { 32, 1, 5, 20},
+ { 32, 2, 5, 24}, { 32, 2, 5, 28},
+ { 32, 3, 5, 40}, { 32, 4, 5, 48},
+ { 0, 16, 6,65536}, { 0, 15, 6,32768},
+ { 0, 14, 6,16384}, { 0, 13, 6, 8192},
+}; /* LL_defaultDTable */
+
+/* Default FSE distribution table for Offset Codes */
+static const ZSTD_seqSymbol OF_defaultDTable[(1<<OF_DEFAULTNORMLOG)+1] = {
+ { 1, 1, 1, OF_DEFAULTNORMLOG}, /* header : fastMode, tableLog */
+ /* nextState, nbAddBits, nbBits, baseVal */
+ { 0, 0, 5, 0}, { 0, 6, 4, 61},
+ { 0, 9, 5, 509}, { 0, 15, 5,32765},
+ { 0, 21, 5,2097149}, { 0, 3, 5, 5},
+ { 0, 7, 4, 125}, { 0, 12, 5, 4093},
+ { 0, 18, 5,262141}, { 0, 23, 5,8388605},
+ { 0, 5, 5, 29}, { 0, 8, 4, 253},
+ { 0, 14, 5,16381}, { 0, 20, 5,1048573},
+ { 0, 2, 5, 1}, { 16, 7, 4, 125},
+ { 0, 11, 5, 2045}, { 0, 17, 5,131069},
+ { 0, 22, 5,4194301}, { 0, 4, 5, 13},
+ { 16, 8, 4, 253}, { 0, 13, 5, 8189},
+ { 0, 19, 5,524285}, { 0, 1, 5, 1},
+ { 16, 6, 4, 61}, { 0, 10, 5, 1021},
+ { 0, 16, 5,65533}, { 0, 28, 5,268435453},
+ { 0, 27, 5,134217725}, { 0, 26, 5,67108861},
+ { 0, 25, 5,33554429}, { 0, 24, 5,16777213},
+}; /* OF_defaultDTable */
+
+
+/* Default FSE distribution table for Match Lengths */
+static const ZSTD_seqSymbol ML_defaultDTable[(1<<ML_DEFAULTNORMLOG)+1] = {
+ { 1, 1, 1, ML_DEFAULTNORMLOG}, /* header : fastMode, tableLog */
+ /* nextState, nbAddBits, nbBits, baseVal */
+ { 0, 0, 6, 3}, { 0, 0, 4, 4},
+ { 32, 0, 5, 5}, { 0, 0, 5, 6},
+ { 0, 0, 5, 8}, { 0, 0, 5, 9},
+ { 0, 0, 5, 11}, { 0, 0, 6, 13},
+ { 0, 0, 6, 16}, { 0, 0, 6, 19},
+ { 0, 0, 6, 22}, { 0, 0, 6, 25},
+ { 0, 0, 6, 28}, { 0, 0, 6, 31},
+ { 0, 0, 6, 34}, { 0, 1, 6, 37},
+ { 0, 1, 6, 41}, { 0, 2, 6, 47},
+ { 0, 3, 6, 59}, { 0, 4, 6, 83},
+ { 0, 7, 6, 131}, { 0, 9, 6, 515},
+ { 16, 0, 4, 4}, { 0, 0, 4, 5},
+ { 32, 0, 5, 6}, { 0, 0, 5, 7},
+ { 32, 0, 5, 9}, { 0, 0, 5, 10},
+ { 0, 0, 6, 12}, { 0, 0, 6, 15},
+ { 0, 0, 6, 18}, { 0, 0, 6, 21},
+ { 0, 0, 6, 24}, { 0, 0, 6, 27},
+ { 0, 0, 6, 30}, { 0, 0, 6, 33},
+ { 0, 1, 6, 35}, { 0, 1, 6, 39},
+ { 0, 2, 6, 43}, { 0, 3, 6, 51},
+ { 0, 4, 6, 67}, { 0, 5, 6, 99},
+ { 0, 8, 6, 259}, { 32, 0, 4, 4},
+ { 48, 0, 4, 4}, { 16, 0, 4, 5},
+ { 32, 0, 5, 7}, { 32, 0, 5, 8},
+ { 32, 0, 5, 10}, { 32, 0, 5, 11},
+ { 0, 0, 6, 14}, { 0, 0, 6, 17},
+ { 0, 0, 6, 20}, { 0, 0, 6, 23},
+ { 0, 0, 6, 26}, { 0, 0, 6, 29},
+ { 0, 0, 6, 32}, { 0, 16, 6,65539},
+ { 0, 15, 6,32771}, { 0, 14, 6,16387},
+ { 0, 13, 6, 8195}, { 0, 12, 6, 4099},
+ { 0, 11, 6, 2051}, { 0, 10, 6, 1027},
+}; /* ML_defaultDTable */
+
+
+static void ZSTD_buildSeqTable_rle(ZSTD_seqSymbol* dt, U32 baseValue, U32 nbAddBits)
+{
+ void* ptr = dt;
+ ZSTD_seqSymbol_header* const DTableH = (ZSTD_seqSymbol_header*)ptr;
+ ZSTD_seqSymbol* const cell = dt + 1;
+
+ DTableH->tableLog = 0;
+ DTableH->fastMode = 0;
+
+ cell->nbBits = 0;
+ cell->nextState = 0;
+ assert(nbAddBits < 255);
+ cell->nbAdditionalBits = (BYTE)nbAddBits;
+ cell->baseValue = baseValue;
+}
+
+
+/* ZSTD_buildFSETable() :
+ * generate FSE decoding table for one symbol (ll, ml or off) */
+static void
+ZSTD_buildFSETable(ZSTD_seqSymbol* dt,
+ const short* normalizedCounter, unsigned maxSymbolValue,
+ const U32* baseValue, const U32* nbAdditionalBits,
+ unsigned tableLog)
+{
+ ZSTD_seqSymbol* const tableDecode = dt+1;
+ U16 symbolNext[MaxSeq+1];
+
+ U32 const maxSV1 = maxSymbolValue + 1;
+ U32 const tableSize = 1 << tableLog;
+ U32 highThreshold = tableSize-1;
+
+ /* Sanity Checks */
+ assert(maxSymbolValue <= MaxSeq);
+ assert(tableLog <= MaxFSELog);
+
+ /* Init, lay down lowprob symbols */
+ { ZSTD_seqSymbol_header DTableH;
+ DTableH.tableLog = tableLog;
+ DTableH.fastMode = 1;
+ { S16 const largeLimit= (S16)(1 << (tableLog-1));
+ U32 s;
+ for (s=0; s<maxSV1; s++) {
+ if (normalizedCounter[s]==-1) {
+ tableDecode[highThreshold--].baseValue = s;
+ symbolNext[s] = 1;
+ } else {
+ if (normalizedCounter[s] >= largeLimit) DTableH.fastMode=0;
+ symbolNext[s] = normalizedCounter[s];
+ } } }
+ memcpy(dt, &DTableH, sizeof(DTableH));
+ }
+
+ /* Spread symbols */
+ { U32 const tableMask = tableSize-1;
+ U32 const step = FSE_TABLESTEP(tableSize);
+ U32 s, position = 0;
+ for (s=0; s<maxSV1; s++) {
+ int i;
+ for (i=0; i<normalizedCounter[s]; i++) {
+ tableDecode[position].baseValue = s;
+ position = (position + step) & tableMask;
+ while (position > highThreshold) position = (position + step) & tableMask; /* lowprob area */
+ } }
+ assert(position == 0); /* position must reach all cells once, otherwise normalizedCounter is incorrect */
+ }
+
+ /* Build Decoding table */
+ { U32 u;
+ for (u=0; u<tableSize; u++) {
+ U32 const symbol = tableDecode[u].baseValue;
+ U32 const nextState = symbolNext[symbol]++;
+ tableDecode[u].nbBits = (BYTE) (tableLog - BIT_highbit32(nextState) );
+ tableDecode[u].nextState = (U16) ( (nextState << tableDecode[u].nbBits) - tableSize);
+ assert(nbAdditionalBits[symbol] < 255);
+ tableDecode[u].nbAdditionalBits = (BYTE)nbAdditionalBits[symbol];
+ tableDecode[u].baseValue = baseValue[symbol];
+ } }
+}
+
+
+/*! ZSTD_buildSeqTable() :
+ * @return : nb bytes read from src,
+ * or an error code if it fails */
+static size_t ZSTD_buildSeqTable(ZSTD_seqSymbol* DTableSpace, const ZSTD_seqSymbol** DTablePtr,
+ symbolEncodingType_e type, U32 max, U32 maxLog,
+ const void* src, size_t srcSize,
+ const U32* baseValue, const U32* nbAdditionalBits,
+ const ZSTD_seqSymbol* defaultTable, U32 flagRepeatTable,
+ int ddictIsCold, int nbSeq)
+{
+ switch(type)
+ {
+ case set_rle :
+ if (!srcSize) return ERROR(srcSize_wrong);
+ if ( (*(const BYTE*)src) > max) return ERROR(corruption_detected);
+ { U32 const symbol = *(const BYTE*)src;
+ U32 const baseline = baseValue[symbol];
+ U32 const nbBits = nbAdditionalBits[symbol];
+ ZSTD_buildSeqTable_rle(DTableSpace, baseline, nbBits);
+ }
+ *DTablePtr = DTableSpace;
+ return 1;
+ case set_basic :
+ *DTablePtr = defaultTable;
+ return 0;
+ case set_repeat:
+ if (!flagRepeatTable) return ERROR(corruption_detected);
+ /* prefetch FSE table if used */
+ if (ddictIsCold && (nbSeq > 24 /* heuristic */)) {
+ const void* const pStart = *DTablePtr;
+ size_t const pSize = sizeof(ZSTD_seqSymbol) * (SEQSYMBOL_TABLE_SIZE(maxLog));
+ PREFETCH_AREA(pStart, pSize);
+ }
+ return 0;
+ case set_compressed :
+ { U32 tableLog;
+ S16 norm[MaxSeq+1];
+ size_t const headerSize = FSE_readNCount(norm, &max, &tableLog, src, srcSize);
+ if (FSE_isError(headerSize)) return ERROR(corruption_detected);
+ if (tableLog > maxLog) return ERROR(corruption_detected);
+ ZSTD_buildFSETable(DTableSpace, norm, max, baseValue, nbAdditionalBits, tableLog);
+ *DTablePtr = DTableSpace;
+ return headerSize;
+ }
+ default : /* impossible */
+ assert(0);
+ return ERROR(GENERIC);
+ }
+}
+
+static const U32 LL_base[MaxLL+1] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 18, 20, 22, 24, 28, 32, 40,
+ 48, 64, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
+ 0x2000, 0x4000, 0x8000, 0x10000 };
+
+static const U32 OF_base[MaxOff+1] = {
+ 0, 1, 1, 5, 0xD, 0x1D, 0x3D, 0x7D,
+ 0xFD, 0x1FD, 0x3FD, 0x7FD, 0xFFD, 0x1FFD, 0x3FFD, 0x7FFD,
+ 0xFFFD, 0x1FFFD, 0x3FFFD, 0x7FFFD, 0xFFFFD, 0x1FFFFD, 0x3FFFFD, 0x7FFFFD,
+ 0xFFFFFD, 0x1FFFFFD, 0x3FFFFFD, 0x7FFFFFD, 0xFFFFFFD, 0x1FFFFFFD, 0x3FFFFFFD, 0x7FFFFFFD };
+
+static const U32 OF_bits[MaxOff+1] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31 };
+
+static const U32 ML_base[MaxML+1] = {
+ 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 24, 25, 26,
+ 27, 28, 29, 30, 31, 32, 33, 34,
+ 35, 37, 39, 41, 43, 47, 51, 59,
+ 67, 83, 99, 0x83, 0x103, 0x203, 0x403, 0x803,
+ 0x1003, 0x2003, 0x4003, 0x8003, 0x10003 };
+
+/* Hidden delcaration for fullbench */
+size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
+ const void* src, size_t srcSize);
+
+size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
+ const void* src, size_t srcSize)
+{
+ const BYTE* const istart = (const BYTE* const)src;
+ const BYTE* const iend = istart + srcSize;
+ const BYTE* ip = istart;
+ int nbSeq;
+ DEBUGLOG(5, "ZSTD_decodeSeqHeaders");
+
+ /* check */
+ if (srcSize < MIN_SEQUENCES_SIZE) return ERROR(srcSize_wrong);
+
+ /* SeqHead */
+ nbSeq = *ip++;
+ if (!nbSeq) { *nbSeqPtr=0; return 1; }
+ if (nbSeq > 0x7F) {
+ if (nbSeq == 0xFF) {
+ if (ip+2 > iend) return ERROR(srcSize_wrong);
+ nbSeq = MEM_readLE16(ip) + LONGNBSEQ, ip+=2;
+ } else {
+ if (ip >= iend) return ERROR(srcSize_wrong);
+ nbSeq = ((nbSeq-0x80)<<8) + *ip++;
+ }
+ }
+ *nbSeqPtr = nbSeq;
+
+ /* FSE table descriptors */
+ if (ip+4 > iend) return ERROR(srcSize_wrong); /* minimum possible size */
+ { symbolEncodingType_e const LLtype = (symbolEncodingType_e)(*ip >> 6);
+ symbolEncodingType_e const OFtype = (symbolEncodingType_e)((*ip >> 4) & 3);
+ symbolEncodingType_e const MLtype = (symbolEncodingType_e)((*ip >> 2) & 3);
+ ip++;
+
+ /* Build DTables */
+ { size_t const llhSize = ZSTD_buildSeqTable(dctx->entropy.LLTable, &dctx->LLTptr,
+ LLtype, MaxLL, LLFSELog,
+ ip, iend-ip,
+ LL_base, LL_bits,
+ LL_defaultDTable, dctx->fseEntropy,
+ dctx->ddictIsCold, nbSeq);
+ if (ZSTD_isError(llhSize)) return ERROR(corruption_detected);
+ ip += llhSize;
+ }
+
+ { size_t const ofhSize = ZSTD_buildSeqTable(dctx->entropy.OFTable, &dctx->OFTptr,
+ OFtype, MaxOff, OffFSELog,
+ ip, iend-ip,
+ OF_base, OF_bits,
+ OF_defaultDTable, dctx->fseEntropy,
+ dctx->ddictIsCold, nbSeq);
+ if (ZSTD_isError(ofhSize)) return ERROR(corruption_detected);
+ ip += ofhSize;
+ }
+
+ { size_t const mlhSize = ZSTD_buildSeqTable(dctx->entropy.MLTable, &dctx->MLTptr,
+ MLtype, MaxML, MLFSELog,
+ ip, iend-ip,
+ ML_base, ML_bits,
+ ML_defaultDTable, dctx->fseEntropy,
+ dctx->ddictIsCold, nbSeq);
+ if (ZSTD_isError(mlhSize)) return ERROR(corruption_detected);
+ ip += mlhSize;
+ }
+ }
+
+ /* prefetch dictionary content */
+ if (dctx->ddictIsCold) {
+ size_t const dictSize = (const char*)dctx->prefixStart - (const char*)dctx->virtualStart;
+ size_t const psmin = MIN(dictSize, (size_t)(64*nbSeq) /* heuristic */ );
+ size_t const pSize = MIN(psmin, 128 KB /* protection */ );
+ const void* const pStart = (const char*)dctx->dictEnd - pSize;
+ PREFETCH_AREA(pStart, pSize);
+ dctx->ddictIsCold = 0;
+ }
+
+ return ip-istart;
+}
+
+
+typedef struct {
+ size_t litLength;
+ size_t matchLength;
+ size_t offset;
+ const BYTE* match;
+} seq_t;
+
+typedef struct {
+ size_t state;
+ const ZSTD_seqSymbol* table;
+} ZSTD_fseState;
+
+typedef struct {
+ BIT_DStream_t DStream;
+ ZSTD_fseState stateLL;
+ ZSTD_fseState stateOffb;
+ ZSTD_fseState stateML;
+ size_t prevOffset[ZSTD_REP_NUM];
+ const BYTE* prefixStart;
+ const BYTE* dictEnd;
+ size_t pos;
+} seqState_t;
+
+
+FORCE_NOINLINE
+size_t ZSTD_execSequenceLast7(BYTE* op,
+ BYTE* const oend, seq_t sequence,
+ const BYTE** litPtr, const BYTE* const litLimit,
+ const BYTE* const base, const BYTE* const vBase, const BYTE* const dictEnd)
+{
+ BYTE* const oLitEnd = op + sequence.litLength;
+ size_t const sequenceLength = sequence.litLength + sequence.matchLength;
+ BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */
+ BYTE* const oend_w = oend - WILDCOPY_OVERLENGTH;
+ const BYTE* const iLitEnd = *litPtr + sequence.litLength;
+ const BYTE* match = oLitEnd - sequence.offset;
+
+ /* check */
+ if (oMatchEnd>oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */
+ if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */
+ if (oLitEnd <= oend_w) return ERROR(GENERIC); /* Precondition */
+
+ /* copy literals */
+ if (op < oend_w) {
+ ZSTD_wildcopy(op, *litPtr, oend_w - op);
+ *litPtr += oend_w - op;
+ op = oend_w;
+ }
+ while (op < oLitEnd) *op++ = *(*litPtr)++;
+
+ /* copy Match */
+ if (sequence.offset > (size_t)(oLitEnd - base)) {
+ /* offset beyond prefix */
+ if (sequence.offset > (size_t)(oLitEnd - vBase)) return ERROR(corruption_detected);
+ match = dictEnd - (base-match);
+ if (match + sequence.matchLength <= dictEnd) {
+ memmove(oLitEnd, match, sequence.matchLength);
+ return sequenceLength;
+ }
+ /* span extDict & currentPrefixSegment */
+ { size_t const length1 = dictEnd - match;
+ memmove(oLitEnd, match, length1);
+ op = oLitEnd + length1;
+ sequence.matchLength -= length1;
+ match = base;
+ } }
+ while (op < oMatchEnd) *op++ = *match++;
+ return sequenceLength;
+}
+
+
+HINT_INLINE
+size_t ZSTD_execSequence(BYTE* op,
+ BYTE* const oend, seq_t sequence,
+ const BYTE** litPtr, const BYTE* const litLimit,
+ const BYTE* const prefixStart, const BYTE* const virtualStart, const BYTE* const dictEnd)
+{
+ BYTE* const oLitEnd = op + sequence.litLength;
+ size_t const sequenceLength = sequence.litLength + sequence.matchLength;
+ BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */
+ BYTE* const oend_w = oend - WILDCOPY_OVERLENGTH;
+ const BYTE* const iLitEnd = *litPtr + sequence.litLength;
+ const BYTE* match = oLitEnd - sequence.offset;
+
+ /* check */
+ if (oMatchEnd>oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */
+ if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */
+ if (oLitEnd>oend_w) return ZSTD_execSequenceLast7(op, oend, sequence, litPtr, litLimit, prefixStart, virtualStart, dictEnd);
+
+ /* copy Literals */
+ ZSTD_copy8(op, *litPtr);
+ if (sequence.litLength > 8)
+ ZSTD_wildcopy(op+8, (*litPtr)+8, sequence.litLength - 8); /* note : since oLitEnd <= oend-WILDCOPY_OVERLENGTH, no risk of overwrite beyond oend */
+ op = oLitEnd;
+ *litPtr = iLitEnd; /* update for next sequence */
+
+ /* copy Match */
+ if (sequence.offset > (size_t)(oLitEnd - prefixStart)) {
+ /* offset beyond prefix -> go into extDict */
+ if (sequence.offset > (size_t)(oLitEnd - virtualStart))
+ return ERROR(corruption_detected);
+ match = dictEnd + (match - prefixStart);
+ if (match + sequence.matchLength <= dictEnd) {
+ memmove(oLitEnd, match, sequence.matchLength);
+ return sequenceLength;
+ }
+ /* span extDict & currentPrefixSegment */
+ { size_t const length1 = dictEnd - match;
+ memmove(oLitEnd, match, length1);
+ op = oLitEnd + length1;
+ sequence.matchLength -= length1;
+ match = prefixStart;
+ if (op > oend_w || sequence.matchLength < MINMATCH) {
+ U32 i;
+ for (i = 0; i < sequence.matchLength; ++i) op[i] = match[i];
+ return sequenceLength;
+ }
+ } }
+ /* Requirement: op <= oend_w && sequence.matchLength >= MINMATCH */
+
+ /* match within prefix */
+ if (sequence.offset < 8) {
+ /* close range match, overlap */
+ static const U32 dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; /* added */
+ static const int dec64table[] = { 8, 8, 8, 7, 8, 9,10,11 }; /* subtracted */
+ int const sub2 = dec64table[sequence.offset];
+ op[0] = match[0];
+ op[1] = match[1];
+ op[2] = match[2];
+ op[3] = match[3];
+ match += dec32table[sequence.offset];
+ ZSTD_copy4(op+4, match);
+ match -= sub2;
+ } else {
+ ZSTD_copy8(op, match);
+ }
+ op += 8; match += 8;
+
+ if (oMatchEnd > oend-(16-MINMATCH)) {
+ if (op < oend_w) {
+ ZSTD_wildcopy(op, match, oend_w - op);
+ match += oend_w - op;
+ op = oend_w;
+ }
+ while (op < oMatchEnd) *op++ = *match++;
+ } else {
+ ZSTD_wildcopy(op, match, (ptrdiff_t)sequence.matchLength-8); /* works even if matchLength < 8 */
+ }
+ return sequenceLength;
+}
+
+
+HINT_INLINE
+size_t ZSTD_execSequenceLong(BYTE* op,
+ BYTE* const oend, seq_t sequence,
+ const BYTE** litPtr, const BYTE* const litLimit,
+ const BYTE* const prefixStart, const BYTE* const dictStart, const BYTE* const dictEnd)
+{
+ BYTE* const oLitEnd = op + sequence.litLength;
+ size_t const sequenceLength = sequence.litLength + sequence.matchLength;
+ BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */
+ BYTE* const oend_w = oend - WILDCOPY_OVERLENGTH;
+ const BYTE* const iLitEnd = *litPtr + sequence.litLength;
+ const BYTE* match = sequence.match;
+
+ /* check */
+ if (oMatchEnd > oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */
+ if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */
+ if (oLitEnd > oend_w) return ZSTD_execSequenceLast7(op, oend, sequence, litPtr, litLimit, prefixStart, dictStart, dictEnd);
+
+ /* copy Literals */
+ ZSTD_copy8(op, *litPtr); /* note : op <= oLitEnd <= oend_w == oend - 8 */
+ if (sequence.litLength > 8)
+ ZSTD_wildcopy(op+8, (*litPtr)+8, sequence.litLength - 8); /* note : since oLitEnd <= oend-WILDCOPY_OVERLENGTH, no risk of overwrite beyond oend */
+ op = oLitEnd;
+ *litPtr = iLitEnd; /* update for next sequence */
+
+ /* copy Match */
+ if (sequence.offset > (size_t)(oLitEnd - prefixStart)) {
+ /* offset beyond prefix */
+ if (sequence.offset > (size_t)(oLitEnd - dictStart)) return ERROR(corruption_detected);
+ if (match + sequence.matchLength <= dictEnd) {
+ memmove(oLitEnd, match, sequence.matchLength);
+ return sequenceLength;
+ }
+ /* span extDict & currentPrefixSegment */
+ { size_t const length1 = dictEnd - match;
+ memmove(oLitEnd, match, length1);
+ op = oLitEnd + length1;
+ sequence.matchLength -= length1;
+ match = prefixStart;
+ if (op > oend_w || sequence.matchLength < MINMATCH) {
+ U32 i;
+ for (i = 0; i < sequence.matchLength; ++i) op[i] = match[i];
+ return sequenceLength;
+ }
+ } }
+ assert(op <= oend_w);
+ assert(sequence.matchLength >= MINMATCH);
+
+ /* match within prefix */
+ if (sequence.offset < 8) {
+ /* close range match, overlap */
+ static const U32 dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; /* added */
+ static const int dec64table[] = { 8, 8, 8, 7, 8, 9,10,11 }; /* subtracted */
+ int const sub2 = dec64table[sequence.offset];
+ op[0] = match[0];
+ op[1] = match[1];
+ op[2] = match[2];
+ op[3] = match[3];
+ match += dec32table[sequence.offset];
+ ZSTD_copy4(op+4, match);
+ match -= sub2;
+ } else {
+ ZSTD_copy8(op, match);
+ }
+ op += 8; match += 8;
+
+ if (oMatchEnd > oend-(16-MINMATCH)) {
+ if (op < oend_w) {
+ ZSTD_wildcopy(op, match, oend_w - op);
+ match += oend_w - op;
+ op = oend_w;
+ }
+ while (op < oMatchEnd) *op++ = *match++;
+ } else {
+ ZSTD_wildcopy(op, match, (ptrdiff_t)sequence.matchLength-8); /* works even if matchLength < 8 */
+ }
+ return sequenceLength;
+}
+
+static void
+ZSTD_initFseState(ZSTD_fseState* DStatePtr, BIT_DStream_t* bitD, const ZSTD_seqSymbol* dt)
+{
+ const void* ptr = dt;
+ const ZSTD_seqSymbol_header* const DTableH = (const ZSTD_seqSymbol_header*)ptr;
+ DStatePtr->state = BIT_readBits(bitD, DTableH->tableLog);
+ DEBUGLOG(6, "ZSTD_initFseState : val=%u using %u bits",
+ (U32)DStatePtr->state, DTableH->tableLog);
+ BIT_reloadDStream(bitD);
+ DStatePtr->table = dt + 1;
+}
+
+FORCE_INLINE_TEMPLATE void
+ZSTD_updateFseState(ZSTD_fseState* DStatePtr, BIT_DStream_t* bitD)
+{
+ ZSTD_seqSymbol const DInfo = DStatePtr->table[DStatePtr->state];
+ U32 const nbBits = DInfo.nbBits;
+ size_t const lowBits = BIT_readBits(bitD, nbBits);
+ DStatePtr->state = DInfo.nextState + lowBits;
+}
+
+/* We need to add at most (ZSTD_WINDOWLOG_MAX_32 - 1) bits to read the maximum
+ * offset bits. But we can only read at most (STREAM_ACCUMULATOR_MIN_32 - 1)
+ * bits before reloading. This value is the maximum number of bytes we read
+ * after reloading when we are decoding long offets.
+ */
+#define LONG_OFFSETS_MAX_EXTRA_BITS_32 \
+ (ZSTD_WINDOWLOG_MAX_32 > STREAM_ACCUMULATOR_MIN_32 \
+ ? ZSTD_WINDOWLOG_MAX_32 - STREAM_ACCUMULATOR_MIN_32 \
+ : 0)
+
+typedef enum { ZSTD_lo_isRegularOffset, ZSTD_lo_isLongOffset=1 } ZSTD_longOffset_e;
+
+FORCE_INLINE_TEMPLATE seq_t
+ZSTD_decodeSequence(seqState_t* seqState, const ZSTD_longOffset_e longOffsets)
+{
+ seq_t seq = {0};
+ U32 const llBits = seqState->stateLL.table[seqState->stateLL.state].nbAdditionalBits;
+ U32 const mlBits = seqState->stateML.table[seqState->stateML.state].nbAdditionalBits;
+ U32 const ofBits = seqState->stateOffb.table[seqState->stateOffb.state].nbAdditionalBits;
+ U32 const totalBits = llBits+mlBits+ofBits;
+ U32 const llBase = seqState->stateLL.table[seqState->stateLL.state].baseValue;
+ U32 const mlBase = seqState->stateML.table[seqState->stateML.state].baseValue;
+ U32 const ofBase = seqState->stateOffb.table[seqState->stateOffb.state].baseValue;
+
+ /* sequence */
+ { size_t offset;
+ if (!ofBits)
+ offset = 0;
+ else {
+ ZSTD_STATIC_ASSERT(ZSTD_lo_isLongOffset == 1);
+ ZSTD_STATIC_ASSERT(LONG_OFFSETS_MAX_EXTRA_BITS_32 == 5);
+ assert(ofBits <= MaxOff);
+ if (MEM_32bits() && longOffsets && (ofBits >= STREAM_ACCUMULATOR_MIN_32)) {
+ U32 const extraBits = ofBits - MIN(ofBits, 32 - seqState->DStream.bitsConsumed);
+ offset = ofBase + (BIT_readBitsFast(&seqState->DStream, ofBits - extraBits) << extraBits);
+ BIT_reloadDStream(&seqState->DStream);
+ if (extraBits) offset += BIT_readBitsFast(&seqState->DStream, extraBits);
+ assert(extraBits <= LONG_OFFSETS_MAX_EXTRA_BITS_32); /* to avoid another reload */
+ } else {
+ offset = ofBase + BIT_readBitsFast(&seqState->DStream, ofBits/*>0*/); /* <= (ZSTD_WINDOWLOG_MAX-1) bits */
+ if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream);
+ }
+ }
+
+ if (ofBits <= 1) {
+ offset += (llBase==0);
+ if (offset) {
+ size_t temp = (offset==3) ? seqState->prevOffset[0] - 1 : seqState->prevOffset[offset];
+ temp += !temp; /* 0 is not valid; input is corrupted; force offset to 1 */
+ if (offset != 1) seqState->prevOffset[2] = seqState->prevOffset[1];
+ seqState->prevOffset[1] = seqState->prevOffset[0];
+ seqState->prevOffset[0] = offset = temp;
+ } else { /* offset == 0 */
+ offset = seqState->prevOffset[0];
+ }
+ } else {
+ seqState->prevOffset[2] = seqState->prevOffset[1];
+ seqState->prevOffset[1] = seqState->prevOffset[0];
+ seqState->prevOffset[0] = offset;
+ }
+ seq.offset = offset;
+ }
+
+ seq.matchLength = mlBase
+ + ((mlBits>0) ? BIT_readBitsFast(&seqState->DStream, mlBits/*>0*/) : 0); /* <= 16 bits */
+ if (MEM_32bits() && (mlBits+llBits >= STREAM_ACCUMULATOR_MIN_32-LONG_OFFSETS_MAX_EXTRA_BITS_32))
+ BIT_reloadDStream(&seqState->DStream);
+ if (MEM_64bits() && (totalBits >= STREAM_ACCUMULATOR_MIN_64-(LLFSELog+MLFSELog+OffFSELog)))
+ BIT_reloadDStream(&seqState->DStream);
+ /* Ensure there are enough bits to read the rest of data in 64-bit mode. */
+ ZSTD_STATIC_ASSERT(16+LLFSELog+MLFSELog+OffFSELog < STREAM_ACCUMULATOR_MIN_64);
+
+ seq.litLength = llBase
+ + ((llBits>0) ? BIT_readBitsFast(&seqState->DStream, llBits/*>0*/) : 0); /* <= 16 bits */
+ if (MEM_32bits())
+ BIT_reloadDStream(&seqState->DStream);
+
+ DEBUGLOG(6, "seq: litL=%u, matchL=%u, offset=%u",
+ (U32)seq.litLength, (U32)seq.matchLength, (U32)seq.offset);
+
+ /* ANS state update */
+ ZSTD_updateFseState(&seqState->stateLL, &seqState->DStream); /* <= 9 bits */
+ ZSTD_updateFseState(&seqState->stateML, &seqState->DStream); /* <= 9 bits */
+ if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream); /* <= 18 bits */
+ ZSTD_updateFseState(&seqState->stateOffb, &seqState->DStream); /* <= 8 bits */
+
+ return seq;
+}
+
+FORCE_INLINE_TEMPLATE size_t
+ZSTD_decompressSequences_body( ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ const BYTE* ip = (const BYTE*)seqStart;
+ const BYTE* const iend = ip + seqSize;
+ BYTE* const ostart = (BYTE* const)dst;
+ BYTE* const oend = ostart + maxDstSize;
+ BYTE* op = ostart;
+ const BYTE* litPtr = dctx->litPtr;
+ const BYTE* const litEnd = litPtr + dctx->litSize;
+ const BYTE* const prefixStart = (const BYTE*) (dctx->prefixStart);
+ const BYTE* const vBase = (const BYTE*) (dctx->virtualStart);
+ const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd);
+ DEBUGLOG(5, "ZSTD_decompressSequences_body");
+
+ /* Regen sequences */
+ if (nbSeq) {
+ seqState_t seqState;
+ dctx->fseEntropy = 1;
+ { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) seqState.prevOffset[i] = dctx->entropy.rep[i]; }
+ CHECK_E(BIT_initDStream(&seqState.DStream, ip, iend-ip), corruption_detected);
+ ZSTD_initFseState(&seqState.stateLL, &seqState.DStream, dctx->LLTptr);
+ ZSTD_initFseState(&seqState.stateOffb, &seqState.DStream, dctx->OFTptr);
+ ZSTD_initFseState(&seqState.stateML, &seqState.DStream, dctx->MLTptr);
+
+ for ( ; (BIT_reloadDStream(&(seqState.DStream)) <= BIT_DStream_completed) && nbSeq ; ) {
+ nbSeq--;
+ { seq_t const sequence = ZSTD_decodeSequence(&seqState, isLongOffset);
+ size_t const oneSeqSize = ZSTD_execSequence(op, oend, sequence, &litPtr, litEnd, prefixStart, vBase, dictEnd);
+ DEBUGLOG(6, "regenerated sequence size : %u", (U32)oneSeqSize);
+ if (ZSTD_isError(oneSeqSize)) return oneSeqSize;
+ op += oneSeqSize;
+ } }
+
+ /* check if reached exact end */
+ DEBUGLOG(5, "ZSTD_decompressSequences_body: after decode loop, remaining nbSeq : %i", nbSeq);
+ if (nbSeq) return ERROR(corruption_detected);
+ /* save reps for next block */
+ { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) dctx->entropy.rep[i] = (U32)(seqState.prevOffset[i]); }
+ }
+
+ /* last literal segment */
+ { size_t const lastLLSize = litEnd - litPtr;
+ if (lastLLSize > (size_t)(oend-op)) return ERROR(dstSize_tooSmall);
+ memcpy(op, litPtr, lastLLSize);
+ op += lastLLSize;
+ }
+
+ return op-ostart;
+}
+
+static size_t
+ZSTD_decompressSequences_default(ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ return ZSTD_decompressSequences_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+
+
+
+FORCE_INLINE_TEMPLATE seq_t
+ZSTD_decodeSequenceLong(seqState_t* seqState, ZSTD_longOffset_e const longOffsets)
+{
+ seq_t seq;
+ U32 const llBits = seqState->stateLL.table[seqState->stateLL.state].nbAdditionalBits;
+ U32 const mlBits = seqState->stateML.table[seqState->stateML.state].nbAdditionalBits;
+ U32 const ofBits = seqState->stateOffb.table[seqState->stateOffb.state].nbAdditionalBits;
+ U32 const totalBits = llBits+mlBits+ofBits;
+ U32 const llBase = seqState->stateLL.table[seqState->stateLL.state].baseValue;
+ U32 const mlBase = seqState->stateML.table[seqState->stateML.state].baseValue;
+ U32 const ofBase = seqState->stateOffb.table[seqState->stateOffb.state].baseValue;
+
+ /* sequence */
+ { size_t offset;
+ if (!ofBits)
+ offset = 0;
+ else {
+ ZSTD_STATIC_ASSERT(ZSTD_lo_isLongOffset == 1);
+ ZSTD_STATIC_ASSERT(LONG_OFFSETS_MAX_EXTRA_BITS_32 == 5);
+ assert(ofBits <= MaxOff);
+ if (MEM_32bits() && longOffsets) {
+ U32 const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN_32-1);
+ offset = ofBase + (BIT_readBitsFast(&seqState->DStream, ofBits - extraBits) << extraBits);
+ if (MEM_32bits() || extraBits) BIT_reloadDStream(&seqState->DStream);
+ if (extraBits) offset += BIT_readBitsFast(&seqState->DStream, extraBits);
+ } else {
+ offset = ofBase + BIT_readBitsFast(&seqState->DStream, ofBits); /* <= (ZSTD_WINDOWLOG_MAX-1) bits */
+ if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream);
+ }
+ }
+
+ if (ofBits <= 1) {
+ offset += (llBase==0);
+ if (offset) {
+ size_t temp = (offset==3) ? seqState->prevOffset[0] - 1 : seqState->prevOffset[offset];
+ temp += !temp; /* 0 is not valid; input is corrupted; force offset to 1 */
+ if (offset != 1) seqState->prevOffset[2] = seqState->prevOffset[1];
+ seqState->prevOffset[1] = seqState->prevOffset[0];
+ seqState->prevOffset[0] = offset = temp;
+ } else {
+ offset = seqState->prevOffset[0];
+ }
+ } else {
+ seqState->prevOffset[2] = seqState->prevOffset[1];
+ seqState->prevOffset[1] = seqState->prevOffset[0];
+ seqState->prevOffset[0] = offset;
+ }
+ seq.offset = offset;
+ }
+
+ seq.matchLength = mlBase + ((mlBits>0) ? BIT_readBitsFast(&seqState->DStream, mlBits) : 0); /* <= 16 bits */
+ if (MEM_32bits() && (mlBits+llBits >= STREAM_ACCUMULATOR_MIN_32-LONG_OFFSETS_MAX_EXTRA_BITS_32))
+ BIT_reloadDStream(&seqState->DStream);
+ if (MEM_64bits() && (totalBits >= STREAM_ACCUMULATOR_MIN_64-(LLFSELog+MLFSELog+OffFSELog)))
+ BIT_reloadDStream(&seqState->DStream);
+ /* Verify that there is enough bits to read the rest of the data in 64-bit mode. */
+ ZSTD_STATIC_ASSERT(16+LLFSELog+MLFSELog+OffFSELog < STREAM_ACCUMULATOR_MIN_64);
+
+ seq.litLength = llBase + ((llBits>0) ? BIT_readBitsFast(&seqState->DStream, llBits) : 0); /* <= 16 bits */
+ if (MEM_32bits())
+ BIT_reloadDStream(&seqState->DStream);
+
+ { size_t const pos = seqState->pos + seq.litLength;
+ const BYTE* const matchBase = (seq.offset > pos) ? seqState->dictEnd : seqState->prefixStart;
+ seq.match = matchBase + pos - seq.offset; /* note : this operation can overflow when seq.offset is really too large, which can only happen when input is corrupted.
+ * No consequence though : no memory access will occur, overly large offset will be detected in ZSTD_execSequenceLong() */
+ seqState->pos = pos + seq.matchLength;
+ }
+
+ /* ANS state update */
+ ZSTD_updateFseState(&seqState->stateLL, &seqState->DStream); /* <= 9 bits */
+ ZSTD_updateFseState(&seqState->stateML, &seqState->DStream); /* <= 9 bits */
+ if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream); /* <= 18 bits */
+ ZSTD_updateFseState(&seqState->stateOffb, &seqState->DStream); /* <= 8 bits */
+
+ return seq;
+}
+
+FORCE_INLINE_TEMPLATE size_t
+ZSTD_decompressSequencesLong_body(
+ ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ const BYTE* ip = (const BYTE*)seqStart;
+ const BYTE* const iend = ip + seqSize;
+ BYTE* const ostart = (BYTE* const)dst;
+ BYTE* const oend = ostart + maxDstSize;
+ BYTE* op = ostart;
+ const BYTE* litPtr = dctx->litPtr;
+ const BYTE* const litEnd = litPtr + dctx->litSize;
+ const BYTE* const prefixStart = (const BYTE*) (dctx->prefixStart);
+ const BYTE* const dictStart = (const BYTE*) (dctx->virtualStart);
+ const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd);
+
+ /* Regen sequences */
+ if (nbSeq) {
+#define STORED_SEQS 4
+#define STOSEQ_MASK (STORED_SEQS-1)
+#define ADVANCED_SEQS 4
+ seq_t sequences[STORED_SEQS];
+ int const seqAdvance = MIN(nbSeq, ADVANCED_SEQS);
+ seqState_t seqState;
+ int seqNb;
+ dctx->fseEntropy = 1;
+ { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) seqState.prevOffset[i] = dctx->entropy.rep[i]; }
+ seqState.prefixStart = prefixStart;
+ seqState.pos = (size_t)(op-prefixStart);
+ seqState.dictEnd = dictEnd;
+ CHECK_E(BIT_initDStream(&seqState.DStream, ip, iend-ip), corruption_detected);
+ ZSTD_initFseState(&seqState.stateLL, &seqState.DStream, dctx->LLTptr);
+ ZSTD_initFseState(&seqState.stateOffb, &seqState.DStream, dctx->OFTptr);
+ ZSTD_initFseState(&seqState.stateML, &seqState.DStream, dctx->MLTptr);
+
+ /* prepare in advance */
+ for (seqNb=0; (BIT_reloadDStream(&seqState.DStream) <= BIT_DStream_completed) && (seqNb<seqAdvance); seqNb++) {
+ sequences[seqNb] = ZSTD_decodeSequenceLong(&seqState, isLongOffset);
+ }
+ if (seqNb<seqAdvance) return ERROR(corruption_detected);
+
+ /* decode and decompress */
+ for ( ; (BIT_reloadDStream(&(seqState.DStream)) <= BIT_DStream_completed) && (seqNb<nbSeq) ; seqNb++) {
+ seq_t const sequence = ZSTD_decodeSequenceLong(&seqState, isLongOffset);
+ size_t const oneSeqSize = ZSTD_execSequenceLong(op, oend, sequences[(seqNb-ADVANCED_SEQS) & STOSEQ_MASK], &litPtr, litEnd, prefixStart, dictStart, dictEnd);
+ if (ZSTD_isError(oneSeqSize)) return oneSeqSize;
+ PREFETCH(sequence.match); /* note : it's safe to invoke PREFETCH() on any memory address, including invalid ones */
+ sequences[seqNb&STOSEQ_MASK] = sequence;
+ op += oneSeqSize;
+ }
+ if (seqNb<nbSeq) return ERROR(corruption_detected);
+
+ /* finish queue */
+ seqNb -= seqAdvance;
+ for ( ; seqNb<nbSeq ; seqNb++) {
+ size_t const oneSeqSize = ZSTD_execSequenceLong(op, oend, sequences[seqNb&STOSEQ_MASK], &litPtr, litEnd, prefixStart, dictStart, dictEnd);
+ if (ZSTD_isError(oneSeqSize)) return oneSeqSize;
+ op += oneSeqSize;
+ }
+
+ /* save reps for next block */
+ { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) dctx->entropy.rep[i] = (U32)(seqState.prevOffset[i]); }
+#undef STORED_SEQS
+#undef STOSEQ_MASK
+#undef ADVANCED_SEQS
+ }
+
+ /* last literal segment */
+ { size_t const lastLLSize = litEnd - litPtr;
+ if (lastLLSize > (size_t)(oend-op)) return ERROR(dstSize_tooSmall);
+ memcpy(op, litPtr, lastLLSize);
+ op += lastLLSize;
+ }
+
+ return op-ostart;
+}
+
+static size_t
+ZSTD_decompressSequencesLong_default(ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ return ZSTD_decompressSequencesLong_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+
+
+
+#if DYNAMIC_BMI2
+
+static TARGET_ATTRIBUTE("bmi2") size_t
+ZSTD_decompressSequences_bmi2(ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ return ZSTD_decompressSequences_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+
+static TARGET_ATTRIBUTE("bmi2") size_t
+ZSTD_decompressSequencesLong_bmi2(ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ return ZSTD_decompressSequencesLong_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+
+#endif
+
+typedef size_t (*ZSTD_decompressSequences_t)(
+ ZSTD_DCtx *dctx, void *dst, size_t maxDstSize,
+ const void *seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset);
+
+static size_t ZSTD_decompressSequences(ZSTD_DCtx* dctx, void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ DEBUGLOG(5, "ZSTD_decompressSequences");
+#if DYNAMIC_BMI2
+ if (dctx->bmi2) {
+ return ZSTD_decompressSequences_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+ }
+#endif
+ return ZSTD_decompressSequences_default(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+
+static size_t ZSTD_decompressSequencesLong(ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ DEBUGLOG(5, "ZSTD_decompressSequencesLong");
+#if DYNAMIC_BMI2
+ if (dctx->bmi2) {
+ return ZSTD_decompressSequencesLong_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+ }
+#endif
+ return ZSTD_decompressSequencesLong_default(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+
+/* ZSTD_getLongOffsetsShare() :
+ * condition : offTable must be valid
+ * @return : "share" of long offsets (arbitrarily defined as > (1<<23))
+ * compared to maximum possible of (1<<OffFSELog) */
+static unsigned
+ZSTD_getLongOffsetsShare(const ZSTD_seqSymbol* offTable)
+{
+ const void* ptr = offTable;
+ U32 const tableLog = ((const ZSTD_seqSymbol_header*)ptr)[0].tableLog;
+ const ZSTD_seqSymbol* table = offTable + 1;
+ U32 const max = 1 << tableLog;
+ U32 u, total = 0;
+ DEBUGLOG(5, "ZSTD_getLongOffsetsShare: (tableLog=%u)", tableLog);
+
+ assert(max <= (1 << OffFSELog)); /* max not too large */
+ for (u=0; u<max; u++) {
+ if (table[u].nbAdditionalBits > 22) total += 1;
+ }
+
+ assert(tableLog <= OffFSELog);
+ total <<= (OffFSELog - tableLog); /* scale to OffFSELog */
+
+ return total;
+}
+
+
+static size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize, const int frame)
+{ /* blockType == blockCompressed */
+ const BYTE* ip = (const BYTE*)src;
+ /* isLongOffset must be true if there are long offsets.
+ * Offsets are long if they are larger than 2^STREAM_ACCUMULATOR_MIN.
+ * We don't expect that to be the case in 64-bit mode.
+ * In block mode, window size is not known, so we have to be conservative.
+ * (note: but it could be evaluated from current-lowLimit)
+ */
+ ZSTD_longOffset_e const isLongOffset = (ZSTD_longOffset_e)(MEM_32bits() && (!frame || dctx->fParams.windowSize > (1ULL << STREAM_ACCUMULATOR_MIN)));
+ DEBUGLOG(5, "ZSTD_decompressBlock_internal (size : %u)", (U32)srcSize);
+
+ if (srcSize >= ZSTD_BLOCKSIZE_MAX) return ERROR(srcSize_wrong);
+
+ /* Decode literals section */
+ { size_t const litCSize = ZSTD_decodeLiteralsBlock(dctx, src, srcSize);
+ DEBUGLOG(5, "ZSTD_decodeLiteralsBlock : %u", (U32)litCSize);
+ if (ZSTD_isError(litCSize)) return litCSize;
+ ip += litCSize;
+ srcSize -= litCSize;
+ }
+
+ /* Build Decoding Tables */
+ { int nbSeq;
+ size_t const seqHSize = ZSTD_decodeSeqHeaders(dctx, &nbSeq, ip, srcSize);
+ if (ZSTD_isError(seqHSize)) return seqHSize;
+ ip += seqHSize;
+ srcSize -= seqHSize;
+
+ if ( (!frame || dctx->fParams.windowSize > (1<<24))
+ && (nbSeq>0) ) { /* could probably use a larger nbSeq limit */
+ U32 const shareLongOffsets = ZSTD_getLongOffsetsShare(dctx->OFTptr);
+ U32 const minShare = MEM_64bits() ? 7 : 20; /* heuristic values, correspond to 2.73% and 7.81% */
+ if (shareLongOffsets >= minShare)
+ return ZSTD_decompressSequencesLong(dctx, dst, dstCapacity, ip, srcSize, nbSeq, isLongOffset);
+ }
+
+ return ZSTD_decompressSequences(dctx, dst, dstCapacity, ip, srcSize, nbSeq, isLongOffset);
+ }
+}
+
+
+static void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst)
+{
+ if (dst != dctx->previousDstEnd) { /* not contiguous */
+ dctx->dictEnd = dctx->previousDstEnd;
+ dctx->virtualStart = (const char*)dst - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart));
+ dctx->prefixStart = dst;
+ dctx->previousDstEnd = dst;
+ }
+}
+
+size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
+{
+ size_t dSize;
+ ZSTD_checkContinuity(dctx, dst);
+ dSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 0);
+ dctx->previousDstEnd = (char*)dst + dSize;
+ return dSize;
+}
+
+
+/** ZSTD_insertBlock() :
+ insert `src` block into `dctx` history. Useful to track uncompressed blocks. */
+ZSTDLIB_API size_t ZSTD_insertBlock(ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize)
+{
+ ZSTD_checkContinuity(dctx, blockStart);
+ dctx->previousDstEnd = (const char*)blockStart + blockSize;
+ return blockSize;
+}
+
+
+static size_t ZSTD_generateNxBytes(void* dst, size_t dstCapacity, BYTE value, size_t length)
+{
+ if (length > dstCapacity) return ERROR(dstSize_tooSmall);
+ memset(dst, value, length);
+ return length;
+}
+
+/** ZSTD_findFrameCompressedSize() :
+ * compatible with legacy mode
+ * `src` must point to the start of a ZSTD frame, ZSTD legacy frame, or skippable frame
+ * `srcSize` must be at least as large as the frame contained
+ * @return : the compressed size of the frame starting at `src` */
+size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize)
+{
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (ZSTD_isLegacy(src, srcSize))
+ return ZSTD_findFrameCompressedSizeLegacy(src, srcSize);
+#endif
+ if ( (srcSize >= ZSTD_skippableHeaderSize)
+ && (MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START ) {
+ return ZSTD_skippableHeaderSize + MEM_readLE32((const BYTE*)src + ZSTD_FRAMEIDSIZE);
+ } else {
+ const BYTE* ip = (const BYTE*)src;
+ const BYTE* const ipstart = ip;
+ size_t remainingSize = srcSize;
+ ZSTD_frameHeader zfh;
+
+ /* Extract Frame Header */
+ { size_t const ret = ZSTD_getFrameHeader(&zfh, src, srcSize);
+ if (ZSTD_isError(ret)) return ret;
+ if (ret > 0) return ERROR(srcSize_wrong);
+ }
+
+ ip += zfh.headerSize;
+ remainingSize -= zfh.headerSize;
+
+ /* Loop on each block */
+ while (1) {
+ blockProperties_t blockProperties;
+ size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSize, &blockProperties);
+ if (ZSTD_isError(cBlockSize)) return cBlockSize;
+
+ if (ZSTD_blockHeaderSize + cBlockSize > remainingSize)
+ return ERROR(srcSize_wrong);
+
+ ip += ZSTD_blockHeaderSize + cBlockSize;
+ remainingSize -= ZSTD_blockHeaderSize + cBlockSize;
+
+ if (blockProperties.lastBlock) break;
+ }
+
+ if (zfh.checksumFlag) { /* Final frame content checksum */
+ if (remainingSize < 4) return ERROR(srcSize_wrong);
+ ip += 4;
+ }
+
+ return ip - ipstart;
+ }
+}
+
+/*! ZSTD_decompressFrame() :
+* @dctx must be properly initialized */
+static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void** srcPtr, size_t *srcSizePtr)
+{
+ const BYTE* ip = (const BYTE*)(*srcPtr);
+ BYTE* const ostart = (BYTE* const)dst;
+ BYTE* const oend = ostart + dstCapacity;
+ BYTE* op = ostart;
+ size_t remainingSize = *srcSizePtr;
+
+ /* check */
+ if (remainingSize < ZSTD_frameHeaderSize_min+ZSTD_blockHeaderSize)
+ return ERROR(srcSize_wrong);
+
+ /* Frame Header */
+ { size_t const frameHeaderSize = ZSTD_frameHeaderSize(ip, ZSTD_frameHeaderSize_prefix);
+ if (ZSTD_isError(frameHeaderSize)) return frameHeaderSize;
+ if (remainingSize < frameHeaderSize+ZSTD_blockHeaderSize)
+ return ERROR(srcSize_wrong);
+ CHECK_F( ZSTD_decodeFrameHeader(dctx, ip, frameHeaderSize) );
+ ip += frameHeaderSize; remainingSize -= frameHeaderSize;
+ }
+
+ /* Loop on each block */
+ while (1) {
+ size_t decodedSize;
+ blockProperties_t blockProperties;
+ size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSize, &blockProperties);
+ if (ZSTD_isError(cBlockSize)) return cBlockSize;
+
+ ip += ZSTD_blockHeaderSize;
+ remainingSize -= ZSTD_blockHeaderSize;
+ if (cBlockSize > remainingSize) return ERROR(srcSize_wrong);
+
+ switch(blockProperties.blockType)
+ {
+ case bt_compressed:
+ decodedSize = ZSTD_decompressBlock_internal(dctx, op, oend-op, ip, cBlockSize, /* frame */ 1);
+ break;
+ case bt_raw :
+ decodedSize = ZSTD_copyRawBlock(op, oend-op, ip, cBlockSize);
+ break;
+ case bt_rle :
+ decodedSize = ZSTD_generateNxBytes(op, oend-op, *ip, blockProperties.origSize);
+ break;
+ case bt_reserved :
+ default:
+ return ERROR(corruption_detected);
+ }
+
+ if (ZSTD_isError(decodedSize)) return decodedSize;
+ if (dctx->fParams.checksumFlag)
+ XXH64_update(&dctx->xxhState, op, decodedSize);
+ op += decodedSize;
+ ip += cBlockSize;
+ remainingSize -= cBlockSize;
+ if (blockProperties.lastBlock) break;
+ }
+
+ if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) {
+ if ((U64)(op-ostart) != dctx->fParams.frameContentSize) {
+ return ERROR(corruption_detected);
+ } }
+ if (dctx->fParams.checksumFlag) { /* Frame content checksum verification */
+ U32 const checkCalc = (U32)XXH64_digest(&dctx->xxhState);
+ U32 checkRead;
+ if (remainingSize<4) return ERROR(checksum_wrong);
+ checkRead = MEM_readLE32(ip);
+ if (checkRead != checkCalc) return ERROR(checksum_wrong);
+ ip += 4;
+ remainingSize -= 4;
+ }
+
+ /* Allow caller to get size read */
+ *srcPtr = ip;
+ *srcSizePtr = remainingSize;
+ return op-ostart;
+}
+
+static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict, size_t dictSize,
+ const ZSTD_DDict* ddict)
+{
+ void* const dststart = dst;
+ int moreThan1Frame = 0;
+
+ DEBUGLOG(5, "ZSTD_decompressMultiFrame");
+ assert(dict==NULL || ddict==NULL); /* either dict or ddict set, not both */
+
+ if (ddict) {
+ dict = ZSTD_DDictDictContent(ddict);
+ dictSize = ZSTD_DDictDictSize(ddict);
+ }
+
+ while (srcSize >= ZSTD_frameHeaderSize_prefix) {
+
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (ZSTD_isLegacy(src, srcSize)) {
+ size_t decodedSize;
+ size_t const frameSize = ZSTD_findFrameCompressedSizeLegacy(src, srcSize);
+ if (ZSTD_isError(frameSize)) return frameSize;
+ /* legacy support is not compatible with static dctx */
+ if (dctx->staticSize) return ERROR(memory_allocation);
+
+ decodedSize = ZSTD_decompressLegacy(dst, dstCapacity, src, frameSize, dict, dictSize);
+
+ dst = (BYTE*)dst + decodedSize;
+ dstCapacity -= decodedSize;
+
+ src = (const BYTE*)src + frameSize;
+ srcSize -= frameSize;
+
+ continue;
+ }
+#endif
+
+ { U32 const magicNumber = MEM_readLE32(src);
+ DEBUGLOG(4, "reading magic number %08X (expecting %08X)",
+ (U32)magicNumber, (U32)ZSTD_MAGICNUMBER);
+ if ((magicNumber & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
+ size_t skippableSize;
+ if (srcSize < ZSTD_skippableHeaderSize)
+ return ERROR(srcSize_wrong);
+ skippableSize = MEM_readLE32((const BYTE*)src + ZSTD_FRAMEIDSIZE)
+ + ZSTD_skippableHeaderSize;
+ if (srcSize < skippableSize) return ERROR(srcSize_wrong);
+
+ src = (const BYTE *)src + skippableSize;
+ srcSize -= skippableSize;
+ continue;
+ } }
+
+ if (ddict) {
+ /* we were called from ZSTD_decompress_usingDDict */
+ CHECK_F(ZSTD_decompressBegin_usingDDict(dctx, ddict));
+ } else {
+ /* this will initialize correctly with no dict if dict == NULL, so
+ * use this in all cases but ddict */
+ CHECK_F(ZSTD_decompressBegin_usingDict(dctx, dict, dictSize));
+ }
+ ZSTD_checkContinuity(dctx, dst);
+
+ { const size_t res = ZSTD_decompressFrame(dctx, dst, dstCapacity,
+ &src, &srcSize);
+ if ( (ZSTD_getErrorCode(res) == ZSTD_error_prefix_unknown)
+ && (moreThan1Frame==1) ) {
+ /* at least one frame successfully completed,
+ * but following bytes are garbage :
+ * it's more likely to be a srcSize error,
+ * specifying more bytes than compressed size of frame(s).
+ * This error message replaces ERROR(prefix_unknown),
+ * which would be confusing, as the first header is actually correct.
+ * Note that one could be unlucky, it might be a corruption error instead,
+ * happening right at the place where we expect zstd magic bytes.
+ * But this is _much_ less likely than a srcSize field error. */
+ return ERROR(srcSize_wrong);
+ }
+ if (ZSTD_isError(res)) return res;
+ /* no need to bound check, ZSTD_decompressFrame already has */
+ dst = (BYTE*)dst + res;
+ dstCapacity -= res;
+ }
+ moreThan1Frame = 1;
+ } /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */
+
+ if (srcSize) return ERROR(srcSize_wrong); /* input not entirely consumed */
+
+ return (BYTE*)dst - (BYTE*)dststart;
+}
+
+size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict, size_t dictSize)
+{
+ return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, dict, dictSize, NULL);
+}
+
+
+size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+ return ZSTD_decompress_usingDict(dctx, dst, dstCapacity, src, srcSize, NULL, 0);
+}
+
+
+size_t ZSTD_decompress(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+#if defined(ZSTD_HEAPMODE) && (ZSTD_HEAPMODE>=1)
+ size_t regenSize;
+ ZSTD_DCtx* const dctx = ZSTD_createDCtx();
+ if (dctx==NULL) return ERROR(memory_allocation);
+ regenSize = ZSTD_decompressDCtx(dctx, dst, dstCapacity, src, srcSize);
+ ZSTD_freeDCtx(dctx);
+ return regenSize;
+#else /* stack mode */
+ ZSTD_DCtx dctx;
+ ZSTD_initDCtx_internal(&dctx);
+ return ZSTD_decompressDCtx(&dctx, dst, dstCapacity, src, srcSize);
+#endif
+}
+
+
+/*-**************************************
+* Advanced Streaming Decompression API
+* Bufferless and synchronous
+****************************************/
+size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx) { return dctx->expected; }
+
+ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx) {
+ switch(dctx->stage)
+ {
+ default: /* should not happen */
+ assert(0);
+ case ZSTDds_getFrameHeaderSize:
+ case ZSTDds_decodeFrameHeader:
+ return ZSTDnit_frameHeader;
+ case ZSTDds_decodeBlockHeader:
+ return ZSTDnit_blockHeader;
+ case ZSTDds_decompressBlock:
+ return ZSTDnit_block;
+ case ZSTDds_decompressLastBlock:
+ return ZSTDnit_lastBlock;
+ case ZSTDds_checkChecksum:
+ return ZSTDnit_checksum;
+ case ZSTDds_decodeSkippableHeader:
+ case ZSTDds_skipFrame:
+ return ZSTDnit_skippableFrame;
+ }
+}
+
+static int ZSTD_isSkipFrame(ZSTD_DCtx* dctx) { return dctx->stage == ZSTDds_skipFrame; }
+
+/** ZSTD_decompressContinue() :
+ * srcSize : must be the exact nb of bytes expected (see ZSTD_nextSrcSizeToDecompress())
+ * @return : nb of bytes generated into `dst` (necessarily <= `dstCapacity)
+ * or an error code, which can be tested using ZSTD_isError() */
+size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+ DEBUGLOG(5, "ZSTD_decompressContinue (srcSize:%u)", (U32)srcSize);
+ /* Sanity check */
+ if (srcSize != dctx->expected) return ERROR(srcSize_wrong); /* not allowed */
+ if (dstCapacity) ZSTD_checkContinuity(dctx, dst);
+
+ switch (dctx->stage)
+ {
+ case ZSTDds_getFrameHeaderSize :
+ assert(src != NULL);
+ if (dctx->format == ZSTD_f_zstd1) { /* allows header */
+ assert(srcSize >= ZSTD_FRAMEIDSIZE); /* to read skippable magic number */
+ if ((MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { /* skippable frame */
+ memcpy(dctx->headerBuffer, src, srcSize);
+ dctx->expected = ZSTD_skippableHeaderSize - srcSize; /* remaining to load to get full skippable frame header */
+ dctx->stage = ZSTDds_decodeSkippableHeader;
+ return 0;
+ } }
+ dctx->headerSize = ZSTD_frameHeaderSize_internal(src, srcSize, dctx->format);
+ if (ZSTD_isError(dctx->headerSize)) return dctx->headerSize;
+ memcpy(dctx->headerBuffer, src, srcSize);
+ dctx->expected = dctx->headerSize - srcSize;
+ dctx->stage = ZSTDds_decodeFrameHeader;
+ return 0;
+
+ case ZSTDds_decodeFrameHeader:
+ assert(src != NULL);
+ memcpy(dctx->headerBuffer + (dctx->headerSize - srcSize), src, srcSize);
+ CHECK_F(ZSTD_decodeFrameHeader(dctx, dctx->headerBuffer, dctx->headerSize));
+ dctx->expected = ZSTD_blockHeaderSize;
+ dctx->stage = ZSTDds_decodeBlockHeader;
+ return 0;
+
+ case ZSTDds_decodeBlockHeader:
+ { blockProperties_t bp;
+ size_t const cBlockSize = ZSTD_getcBlockSize(src, ZSTD_blockHeaderSize, &bp);
+ if (ZSTD_isError(cBlockSize)) return cBlockSize;
+ dctx->expected = cBlockSize;
+ dctx->bType = bp.blockType;
+ dctx->rleSize = bp.origSize;
+ if (cBlockSize) {
+ dctx->stage = bp.lastBlock ? ZSTDds_decompressLastBlock : ZSTDds_decompressBlock;
+ return 0;
+ }
+ /* empty block */
+ if (bp.lastBlock) {
+ if (dctx->fParams.checksumFlag) {
+ dctx->expected = 4;
+ dctx->stage = ZSTDds_checkChecksum;
+ } else {
+ dctx->expected = 0; /* end of frame */
+ dctx->stage = ZSTDds_getFrameHeaderSize;
+ }
+ } else {
+ dctx->expected = ZSTD_blockHeaderSize; /* jump to next header */
+ dctx->stage = ZSTDds_decodeBlockHeader;
+ }
+ return 0;
+ }
+
+ case ZSTDds_decompressLastBlock:
+ case ZSTDds_decompressBlock:
+ DEBUGLOG(5, "ZSTD_decompressContinue: case ZSTDds_decompressBlock");
+ { size_t rSize;
+ switch(dctx->bType)
+ {
+ case bt_compressed:
+ DEBUGLOG(5, "ZSTD_decompressContinue: case bt_compressed");
+ rSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 1);
+ break;
+ case bt_raw :
+ rSize = ZSTD_copyRawBlock(dst, dstCapacity, src, srcSize);
+ break;
+ case bt_rle :
+ rSize = ZSTD_setRleBlock(dst, dstCapacity, src, srcSize, dctx->rleSize);
+ break;
+ case bt_reserved : /* should never happen */
+ default:
+ return ERROR(corruption_detected);
+ }
+ if (ZSTD_isError(rSize)) return rSize;
+ DEBUGLOG(5, "ZSTD_decompressContinue: decoded size from block : %u", (U32)rSize);
+ dctx->decodedSize += rSize;
+ if (dctx->fParams.checksumFlag) XXH64_update(&dctx->xxhState, dst, rSize);
+
+ if (dctx->stage == ZSTDds_decompressLastBlock) { /* end of frame */
+ DEBUGLOG(4, "ZSTD_decompressContinue: decoded size from frame : %u", (U32)dctx->decodedSize);
+ if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) {
+ if (dctx->decodedSize != dctx->fParams.frameContentSize) {
+ return ERROR(corruption_detected);
+ } }
+ if (dctx->fParams.checksumFlag) { /* another round for frame checksum */
+ dctx->expected = 4;
+ dctx->stage = ZSTDds_checkChecksum;
+ } else {
+ dctx->expected = 0; /* ends here */
+ dctx->stage = ZSTDds_getFrameHeaderSize;
+ }
+ } else {
+ dctx->stage = ZSTDds_decodeBlockHeader;
+ dctx->expected = ZSTD_blockHeaderSize;
+ dctx->previousDstEnd = (char*)dst + rSize;
+ }
+ return rSize;
+ }
+
+ case ZSTDds_checkChecksum:
+ assert(srcSize == 4); /* guaranteed by dctx->expected */
+ { U32 const h32 = (U32)XXH64_digest(&dctx->xxhState);
+ U32 const check32 = MEM_readLE32(src);
+ DEBUGLOG(4, "ZSTD_decompressContinue: checksum : calculated %08X :: %08X read", h32, check32);
+ if (check32 != h32) return ERROR(checksum_wrong);
+ dctx->expected = 0;
+ dctx->stage = ZSTDds_getFrameHeaderSize;
+ return 0;
+ }
+
+ case ZSTDds_decodeSkippableHeader:
+ assert(src != NULL);
+ assert(srcSize <= ZSTD_skippableHeaderSize);
+ memcpy(dctx->headerBuffer + (ZSTD_skippableHeaderSize - srcSize), src, srcSize); /* complete skippable header */
+ dctx->expected = MEM_readLE32(dctx->headerBuffer + ZSTD_FRAMEIDSIZE); /* note : dctx->expected can grow seriously large, beyond local buffer size */
+ dctx->stage = ZSTDds_skipFrame;
+ return 0;
+
+ case ZSTDds_skipFrame:
+ dctx->expected = 0;
+ dctx->stage = ZSTDds_getFrameHeaderSize;
+ return 0;
+
+ default:
+ return ERROR(GENERIC); /* impossible */
+ }
+}
+
+
+static size_t ZSTD_refDictContent(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
+{
+ dctx->dictEnd = dctx->previousDstEnd;
+ dctx->virtualStart = (const char*)dict - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart));
+ dctx->prefixStart = dict;
+ dctx->previousDstEnd = (const char*)dict + dictSize;
+ return 0;
+}
+
+/*! ZSTD_loadEntropy() :
+ * dict : must point at beginning of a valid zstd dictionary.
+ * @return : size of entropy tables read */
+static size_t ZSTD_loadEntropy(ZSTD_entropyDTables_t* entropy,
+ const void* const dict, size_t const dictSize)
+{
+ const BYTE* dictPtr = (const BYTE*)dict;
+ const BYTE* const dictEnd = dictPtr + dictSize;
+
+ if (dictSize <= 8) return ERROR(dictionary_corrupted);
+ assert(MEM_readLE32(dict) == ZSTD_MAGIC_DICTIONARY); /* dict must be valid */
+ dictPtr += 8; /* skip header = magic + dictID */
+
+ ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, OFTable) == offsetof(ZSTD_entropyDTables_t, LLTable) + sizeof(entropy->LLTable));
+ ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, MLTable) == offsetof(ZSTD_entropyDTables_t, OFTable) + sizeof(entropy->OFTable));
+ ZSTD_STATIC_ASSERT(sizeof(entropy->LLTable) + sizeof(entropy->OFTable) + sizeof(entropy->MLTable) >= HUF_DECOMPRESS_WORKSPACE_SIZE);
+ { void* const workspace = &entropy->LLTable; /* use fse tables as temporary workspace; implies fse tables are grouped together */
+ size_t const workspaceSize = sizeof(entropy->LLTable) + sizeof(entropy->OFTable) + sizeof(entropy->MLTable);
+ size_t const hSize = HUF_readDTableX2_wksp(entropy->hufTable,
+ dictPtr, dictEnd - dictPtr,
+ workspace, workspaceSize);
+ if (HUF_isError(hSize)) return ERROR(dictionary_corrupted);
+ dictPtr += hSize;
+ }
+
+ { short offcodeNCount[MaxOff+1];
+ U32 offcodeMaxValue = MaxOff, offcodeLog;
+ size_t const offcodeHeaderSize = FSE_readNCount(offcodeNCount, &offcodeMaxValue, &offcodeLog, dictPtr, dictEnd-dictPtr);
+ if (FSE_isError(offcodeHeaderSize)) return ERROR(dictionary_corrupted);
+ if (offcodeMaxValue > MaxOff) return ERROR(dictionary_corrupted);
+ if (offcodeLog > OffFSELog) return ERROR(dictionary_corrupted);
+ ZSTD_buildFSETable( entropy->OFTable,
+ offcodeNCount, offcodeMaxValue,
+ OF_base, OF_bits,
+ offcodeLog);
+ dictPtr += offcodeHeaderSize;
+ }
+
+ { short matchlengthNCount[MaxML+1];
+ unsigned matchlengthMaxValue = MaxML, matchlengthLog;
+ size_t const matchlengthHeaderSize = FSE_readNCount(matchlengthNCount, &matchlengthMaxValue, &matchlengthLog, dictPtr, dictEnd-dictPtr);
+ if (FSE_isError(matchlengthHeaderSize)) return ERROR(dictionary_corrupted);
+ if (matchlengthMaxValue > MaxML) return ERROR(dictionary_corrupted);
+ if (matchlengthLog > MLFSELog) return ERROR(dictionary_corrupted);
+ ZSTD_buildFSETable( entropy->MLTable,
+ matchlengthNCount, matchlengthMaxValue,
+ ML_base, ML_bits,
+ matchlengthLog);
+ dictPtr += matchlengthHeaderSize;
+ }
+
+ { short litlengthNCount[MaxLL+1];
+ unsigned litlengthMaxValue = MaxLL, litlengthLog;
+ size_t const litlengthHeaderSize = FSE_readNCount(litlengthNCount, &litlengthMaxValue, &litlengthLog, dictPtr, dictEnd-dictPtr);
+ if (FSE_isError(litlengthHeaderSize)) return ERROR(dictionary_corrupted);
+ if (litlengthMaxValue > MaxLL) return ERROR(dictionary_corrupted);
+ if (litlengthLog > LLFSELog) return ERROR(dictionary_corrupted);
+ ZSTD_buildFSETable( entropy->LLTable,
+ litlengthNCount, litlengthMaxValue,
+ LL_base, LL_bits,
+ litlengthLog);
+ dictPtr += litlengthHeaderSize;
+ }
+
+ if (dictPtr+12 > dictEnd) return ERROR(dictionary_corrupted);
+ { int i;
+ size_t const dictContentSize = (size_t)(dictEnd - (dictPtr+12));
+ for (i=0; i<3; i++) {
+ U32 const rep = MEM_readLE32(dictPtr); dictPtr += 4;
+ if (rep==0 || rep >= dictContentSize) return ERROR(dictionary_corrupted);
+ entropy->rep[i] = rep;
+ } }
+
+ return dictPtr - (const BYTE*)dict;
+}
+
+static size_t ZSTD_decompress_insertDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
+{
+ if (dictSize < 8) return ZSTD_refDictContent(dctx, dict, dictSize);
+ { U32 const magic = MEM_readLE32(dict);
+ if (magic != ZSTD_MAGIC_DICTIONARY) {
+ return ZSTD_refDictContent(dctx, dict, dictSize); /* pure content mode */
+ } }
+ dctx->dictID = MEM_readLE32((const char*)dict + ZSTD_FRAMEIDSIZE);
+
+ /* load entropy tables */
+ { size_t const eSize = ZSTD_loadEntropy(&dctx->entropy, dict, dictSize);
+ if (ZSTD_isError(eSize)) return ERROR(dictionary_corrupted);
+ dict = (const char*)dict + eSize;
+ dictSize -= eSize;
+ }
+ dctx->litEntropy = dctx->fseEntropy = 1;
+
+ /* reference dictionary content */
+ return ZSTD_refDictContent(dctx, dict, dictSize);
+}
+
+size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx)
+{
+ assert(dctx != NULL);
+ dctx->expected = ZSTD_startingInputLength(dctx->format); /* dctx->format must be properly set */
+ dctx->stage = ZSTDds_getFrameHeaderSize;
+ dctx->decodedSize = 0;
+ dctx->previousDstEnd = NULL;
+ dctx->prefixStart = NULL;
+ dctx->virtualStart = NULL;
+ dctx->dictEnd = NULL;
+ dctx->entropy.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); /* cover both little and big endian */
+ dctx->litEntropy = dctx->fseEntropy = 0;
+ dctx->dictID = 0;
+ ZSTD_STATIC_ASSERT(sizeof(dctx->entropy.rep) == sizeof(repStartValue));
+ memcpy(dctx->entropy.rep, repStartValue, sizeof(repStartValue)); /* initial repcodes */
+ dctx->LLTptr = dctx->entropy.LLTable;
+ dctx->MLTptr = dctx->entropy.MLTable;
+ dctx->OFTptr = dctx->entropy.OFTable;
+ dctx->HUFptr = dctx->entropy.hufTable;
+ return 0;
+}
+
+size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
+{
+ CHECK_F( ZSTD_decompressBegin(dctx) );
+ if (dict && dictSize)
+ CHECK_E(ZSTD_decompress_insertDictionary(dctx, dict, dictSize), dictionary_corrupted);
+ return 0;
+}
+
+
+/* ====== ZSTD_DDict ====== */
+
+struct ZSTD_DDict_s {
+ void* dictBuffer;
+ const void* dictContent;
+ size_t dictSize;
+ ZSTD_entropyDTables_t entropy;
+ U32 dictID;
+ U32 entropyPresent;
+ ZSTD_customMem cMem;
+}; /* typedef'd to ZSTD_DDict within "zstd.h" */
+
+static const void* ZSTD_DDictDictContent(const ZSTD_DDict* ddict)
+{
+ assert(ddict != NULL);
+ return ddict->dictContent;
+}
+
+static size_t ZSTD_DDictDictSize(const ZSTD_DDict* ddict)
+{
+ assert(ddict != NULL);
+ return ddict->dictSize;
+}
+
+size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict)
+{
+ DEBUGLOG(4, "ZSTD_decompressBegin_usingDDict");
+ assert(dctx != NULL);
+ if (ddict) {
+ dctx->ddictIsCold = (dctx->dictEnd != (const char*)ddict->dictContent + ddict->dictSize);
+ DEBUGLOG(4, "DDict is %s",
+ dctx->ddictIsCold ? "~cold~" : "hot!");
+ }
+ CHECK_F( ZSTD_decompressBegin(dctx) );
+ if (ddict) { /* NULL ddict is equivalent to no dictionary */
+ dctx->dictID = ddict->dictID;
+ dctx->prefixStart = ddict->dictContent;
+ dctx->virtualStart = ddict->dictContent;
+ dctx->dictEnd = (const BYTE*)ddict->dictContent + ddict->dictSize;
+ dctx->previousDstEnd = dctx->dictEnd;
+ if (ddict->entropyPresent) {
+ dctx->litEntropy = 1;
+ dctx->fseEntropy = 1;
+ dctx->LLTptr = ddict->entropy.LLTable;
+ dctx->MLTptr = ddict->entropy.MLTable;
+ dctx->OFTptr = ddict->entropy.OFTable;
+ dctx->HUFptr = ddict->entropy.hufTable;
+ dctx->entropy.rep[0] = ddict->entropy.rep[0];
+ dctx->entropy.rep[1] = ddict->entropy.rep[1];
+ dctx->entropy.rep[2] = ddict->entropy.rep[2];
+ } else {
+ dctx->litEntropy = 0;
+ dctx->fseEntropy = 0;
+ }
+ }
+ return 0;
+}
+
+static size_t
+ZSTD_loadEntropy_inDDict(ZSTD_DDict* ddict,
+ ZSTD_dictContentType_e dictContentType)
+{
+ ddict->dictID = 0;
+ ddict->entropyPresent = 0;
+ if (dictContentType == ZSTD_dct_rawContent) return 0;
+
+ if (ddict->dictSize < 8) {
+ if (dictContentType == ZSTD_dct_fullDict)
+ return ERROR(dictionary_corrupted); /* only accept specified dictionaries */
+ return 0; /* pure content mode */
+ }
+ { U32 const magic = MEM_readLE32(ddict->dictContent);
+ if (magic != ZSTD_MAGIC_DICTIONARY) {
+ if (dictContentType == ZSTD_dct_fullDict)
+ return ERROR(dictionary_corrupted); /* only accept specified dictionaries */
+ return 0; /* pure content mode */
+ }
+ }
+ ddict->dictID = MEM_readLE32((const char*)ddict->dictContent + ZSTD_FRAMEIDSIZE);
+
+ /* load entropy tables */
+ CHECK_E( ZSTD_loadEntropy(&ddict->entropy,
+ ddict->dictContent, ddict->dictSize),
+ dictionary_corrupted );
+ ddict->entropyPresent = 1;
+ return 0;
+}
+
+
+static size_t ZSTD_initDDict_internal(ZSTD_DDict* ddict,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType)
+{
+ if ((dictLoadMethod == ZSTD_dlm_byRef) || (!dict) || (!dictSize)) {
+ ddict->dictBuffer = NULL;
+ ddict->dictContent = dict;
+ if (!dict) dictSize = 0;
+ } else {
+ void* const internalBuffer = ZSTD_malloc(dictSize, ddict->cMem);
+ ddict->dictBuffer = internalBuffer;
+ ddict->dictContent = internalBuffer;
+ if (!internalBuffer) return ERROR(memory_allocation);
+ memcpy(internalBuffer, dict, dictSize);
+ }
+ ddict->dictSize = dictSize;
+ ddict->entropy.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); /* cover both little and big endian */
+
+ /* parse dictionary content */
+ CHECK_F( ZSTD_loadEntropy_inDDict(ddict, dictContentType) );
+
+ return 0;
+}
+
+ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_customMem customMem)
+{
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
+
+ { ZSTD_DDict* const ddict = (ZSTD_DDict*) ZSTD_malloc(sizeof(ZSTD_DDict), customMem);
+ if (ddict == NULL) return NULL;
+ ddict->cMem = customMem;
+ { size_t const initResult = ZSTD_initDDict_internal(ddict,
+ dict, dictSize,
+ dictLoadMethod, dictContentType);
+ if (ZSTD_isError(initResult)) {
+ ZSTD_freeDDict(ddict);
+ return NULL;
+ } }
+ return ddict;
+ }
+}
+
+/*! ZSTD_createDDict() :
+* Create a digested dictionary, to start decompression without startup delay.
+* `dict` content is copied inside DDict.
+* Consequently, `dict` can be released after `ZSTD_DDict` creation */
+ZSTD_DDict* ZSTD_createDDict(const void* dict, size_t dictSize)
+{
+ ZSTD_customMem const allocator = { NULL, NULL, NULL };
+ return ZSTD_createDDict_advanced(dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto, allocator);
+}
+
+/*! ZSTD_createDDict_byReference() :
+ * Create a digested dictionary, to start decompression without startup delay.
+ * Dictionary content is simply referenced, it will be accessed during decompression.
+ * Warning : dictBuffer must outlive DDict (DDict must be freed before dictBuffer) */
+ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize)
+{
+ ZSTD_customMem const allocator = { NULL, NULL, NULL };
+ return ZSTD_createDDict_advanced(dictBuffer, dictSize, ZSTD_dlm_byRef, ZSTD_dct_auto, allocator);
+}
+
+
+const ZSTD_DDict* ZSTD_initStaticDDict(
+ void* sBuffer, size_t sBufferSize,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType)
+{
+ size_t const neededSpace = sizeof(ZSTD_DDict)
+ + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize);
+ ZSTD_DDict* const ddict = (ZSTD_DDict*)sBuffer;
+ assert(sBuffer != NULL);
+ assert(dict != NULL);
+ if ((size_t)sBuffer & 7) return NULL; /* 8-aligned */
+ if (sBufferSize < neededSpace) return NULL;
+ if (dictLoadMethod == ZSTD_dlm_byCopy) {
+ memcpy(ddict+1, dict, dictSize); /* local copy */
+ dict = ddict+1;
+ }
+ if (ZSTD_isError( ZSTD_initDDict_internal(ddict,
+ dict, dictSize,
+ ZSTD_dlm_byRef, dictContentType) ))
+ return NULL;
+ return ddict;
+}
+
+
+size_t ZSTD_freeDDict(ZSTD_DDict* ddict)
+{
+ if (ddict==NULL) return 0; /* support free on NULL */
+ { ZSTD_customMem const cMem = ddict->cMem;
+ ZSTD_free(ddict->dictBuffer, cMem);
+ ZSTD_free(ddict, cMem);
+ return 0;
+ }
+}
+
+/*! ZSTD_estimateDDictSize() :
+ * Estimate amount of memory that will be needed to create a dictionary for decompression.
+ * Note : dictionary created by reference using ZSTD_dlm_byRef are smaller */
+size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod)
+{
+ return sizeof(ZSTD_DDict) + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize);
+}
+
+size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict)
+{
+ if (ddict==NULL) return 0; /* support sizeof on NULL */
+ return sizeof(*ddict) + (ddict->dictBuffer ? ddict->dictSize : 0) ;
+}
+
+/*! ZSTD_getDictID_fromDict() :
+ * Provides the dictID stored within dictionary.
+ * if @return == 0, the dictionary is not conformant with Zstandard specification.
+ * It can still be loaded, but as a content-only dictionary. */
+unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize)
+{
+ if (dictSize < 8) return 0;
+ if (MEM_readLE32(dict) != ZSTD_MAGIC_DICTIONARY) return 0;
+ return MEM_readLE32((const char*)dict + ZSTD_FRAMEIDSIZE);
+}
+
+/*! ZSTD_getDictID_fromDDict() :
+ * Provides the dictID of the dictionary loaded into `ddict`.
+ * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
+ * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
+unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict)
+{
+ if (ddict==NULL) return 0;
+ return ZSTD_getDictID_fromDict(ddict->dictContent, ddict->dictSize);
+}
+
+/*! ZSTD_getDictID_fromFrame() :
+ * Provides the dictID required to decompresse frame stored within `src`.
+ * If @return == 0, the dictID could not be decoded.
+ * This could for one of the following reasons :
+ * - The frame does not require a dictionary (most common case).
+ * - The frame was built with dictID intentionally removed.
+ * Needed dictionary is a hidden information.
+ * Note : this use case also happens when using a non-conformant dictionary.
+ * - `srcSize` is too small, and as a result, frame header could not be decoded.
+ * Note : possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`.
+ * - This is not a Zstandard frame.
+ * When identifying the exact failure cause, it's possible to use
+ * ZSTD_getFrameHeader(), which will provide a more precise error code. */
+unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize)
+{
+ ZSTD_frameHeader zfp = { 0, 0, 0, ZSTD_frame, 0, 0, 0 };
+ size_t const hError = ZSTD_getFrameHeader(&zfp, src, srcSize);
+ if (ZSTD_isError(hError)) return 0;
+ return zfp.dictID;
+}
+
+
+/*! ZSTD_decompress_usingDDict() :
+* Decompression using a pre-digested Dictionary
+* Use dictionary without significant overhead. */
+size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_DDict* ddict)
+{
+ /* pass content and size in case legacy frames are encountered */
+ return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize,
+ NULL, 0,
+ ddict);
+}
+
+
+/*=====================================
+* Streaming decompression
+*====================================*/
+
+ZSTD_DStream* ZSTD_createDStream(void)
+{
+ DEBUGLOG(3, "ZSTD_createDStream");
+ return ZSTD_createDStream_advanced(ZSTD_defaultCMem);
+}
+
+ZSTD_DStream* ZSTD_initStaticDStream(void *workspace, size_t workspaceSize)
+{
+ return ZSTD_initStaticDCtx(workspace, workspaceSize);
+}
+
+ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem)
+{
+ return ZSTD_createDCtx_advanced(customMem);
+}
+
+size_t ZSTD_freeDStream(ZSTD_DStream* zds)
+{
+ return ZSTD_freeDCtx(zds);
+}
+
+
+/* *** Initialization *** */
+
+size_t ZSTD_DStreamInSize(void) { return ZSTD_BLOCKSIZE_MAX + ZSTD_blockHeaderSize; }
+size_t ZSTD_DStreamOutSize(void) { return ZSTD_BLOCKSIZE_MAX; }
+
+size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType)
+{
+ if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
+ ZSTD_freeDDict(dctx->ddictLocal);
+ if (dict && dictSize >= 8) {
+ dctx->ddictLocal = ZSTD_createDDict_advanced(dict, dictSize, dictLoadMethod, dictContentType, dctx->customMem);
+ if (dctx->ddictLocal == NULL) return ERROR(memory_allocation);
+ } else {
+ dctx->ddictLocal = NULL;
+ }
+ dctx->ddict = dctx->ddictLocal;
+ return 0;
+}
+
+size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
+{
+ return ZSTD_DCtx_loadDictionary_advanced(dctx, dict, dictSize, ZSTD_dlm_byRef, ZSTD_dct_auto);
+}
+
+size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
+{
+ return ZSTD_DCtx_loadDictionary_advanced(dctx, dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto);
+}
+
+size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType)
+{
+ return ZSTD_DCtx_loadDictionary_advanced(dctx, prefix, prefixSize, ZSTD_dlm_byRef, dictContentType);
+}
+
+size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize)
+{
+ return ZSTD_DCtx_refPrefix_advanced(dctx, prefix, prefixSize, ZSTD_dct_rawContent);
+}
+
+
+/* ZSTD_initDStream_usingDict() :
+ * return : expected size, aka ZSTD_frameHeaderSize_prefix.
+ * this function cannot fail */
+size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize)
+{
+ DEBUGLOG(4, "ZSTD_initDStream_usingDict");
+ zds->streamStage = zdss_init;
+ zds->noForwardProgress = 0;
+ CHECK_F( ZSTD_DCtx_loadDictionary(zds, dict, dictSize) );
+ return ZSTD_frameHeaderSize_prefix;
+}
+
+/* note : this variant can't fail */
+size_t ZSTD_initDStream(ZSTD_DStream* zds)
+{
+ DEBUGLOG(4, "ZSTD_initDStream");
+ return ZSTD_initDStream_usingDict(zds, NULL, 0);
+}
+
+/* ZSTD_initDStream_usingDDict() :
+ * ddict will just be referenced, and must outlive decompression session
+ * this function cannot fail */
+size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* dctx, const ZSTD_DDict* ddict)
+{
+ size_t const initResult = ZSTD_initDStream(dctx);
+ dctx->ddict = ddict;
+ return initResult;
+}
+
+/* ZSTD_resetDStream() :
+ * return : expected size, aka ZSTD_frameHeaderSize_prefix.
+ * this function cannot fail */
+size_t ZSTD_resetDStream(ZSTD_DStream* dctx)
+{
+ DEBUGLOG(4, "ZSTD_resetDStream");
+ dctx->streamStage = zdss_loadHeader;
+ dctx->lhSize = dctx->inPos = dctx->outStart = dctx->outEnd = 0;
+ dctx->legacyVersion = 0;
+ dctx->hostageByte = 0;
+ return ZSTD_frameHeaderSize_prefix;
+}
+
+size_t ZSTD_setDStreamParameter(ZSTD_DStream* dctx,
+ ZSTD_DStreamParameter_e paramType, unsigned paramValue)
+{
+ if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
+ switch(paramType)
+ {
+ default : return ERROR(parameter_unsupported);
+ case DStream_p_maxWindowSize :
+ DEBUGLOG(4, "setting maxWindowSize = %u KB", paramValue >> 10);
+ dctx->maxWindowSize = paramValue ? paramValue : (U32)(-1);
+ break;
+ }
+ return 0;
+}
+
+size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict)
+{
+ if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
+ dctx->ddict = ddict;
+ return 0;
+}
+
+size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize)
+{
+ if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
+ dctx->maxWindowSize = maxWindowSize;
+ return 0;
+}
+
+size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format)
+{
+ DEBUGLOG(4, "ZSTD_DCtx_setFormat : %u", (unsigned)format);
+ if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
+ dctx->format = format;
+ return 0;
+}
+
+
+size_t ZSTD_sizeof_DStream(const ZSTD_DStream* dctx)
+{
+ return ZSTD_sizeof_DCtx(dctx);
+}
+
+size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize)
+{
+ size_t const blockSize = (size_t) MIN(windowSize, ZSTD_BLOCKSIZE_MAX);
+ unsigned long long const neededRBSize = windowSize + blockSize + (WILDCOPY_OVERLENGTH * 2);
+ unsigned long long const neededSize = MIN(frameContentSize, neededRBSize);
+ size_t const minRBSize = (size_t) neededSize;
+ if ((unsigned long long)minRBSize != neededSize) return ERROR(frameParameter_windowTooLarge);
+ return minRBSize;
+}
+
+size_t ZSTD_estimateDStreamSize(size_t windowSize)
+{
+ size_t const blockSize = MIN(windowSize, ZSTD_BLOCKSIZE_MAX);
+ size_t const inBuffSize = blockSize; /* no block can be larger */
+ size_t const outBuffSize = ZSTD_decodingBufferSize_min(windowSize, ZSTD_CONTENTSIZE_UNKNOWN);
+ return ZSTD_estimateDCtxSize() + inBuffSize + outBuffSize;
+}
+
+size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize)
+{
+ U32 const windowSizeMax = 1U << ZSTD_WINDOWLOG_MAX; /* note : should be user-selectable */
+ ZSTD_frameHeader zfh;
+ size_t const err = ZSTD_getFrameHeader(&zfh, src, srcSize);
+ if (ZSTD_isError(err)) return err;
+ if (err>0) return ERROR(srcSize_wrong);
+ if (zfh.windowSize > windowSizeMax)
+ return ERROR(frameParameter_windowTooLarge);
+ return ZSTD_estimateDStreamSize((size_t)zfh.windowSize);
+}
+
+
+/* ***** Decompression ***** */
+
+MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+ size_t const length = MIN(dstCapacity, srcSize);
+ memcpy(dst, src, length);
+ return length;
+}
+
+
+size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
+{
+ const char* const istart = (const char*)(input->src) + input->pos;
+ const char* const iend = (const char*)(input->src) + input->size;
+ const char* ip = istart;
+ char* const ostart = (char*)(output->dst) + output->pos;
+ char* const oend = (char*)(output->dst) + output->size;
+ char* op = ostart;
+ U32 someMoreWork = 1;
+
+ DEBUGLOG(5, "ZSTD_decompressStream");
+ if (input->pos > input->size) { /* forbidden */
+ DEBUGLOG(5, "in: pos: %u vs size: %u",
+ (U32)input->pos, (U32)input->size);
+ return ERROR(srcSize_wrong);
+ }
+ if (output->pos > output->size) { /* forbidden */
+ DEBUGLOG(5, "out: pos: %u vs size: %u",
+ (U32)output->pos, (U32)output->size);
+ return ERROR(dstSize_tooSmall);
+ }
+ DEBUGLOG(5, "input size : %u", (U32)(input->size - input->pos));
+
+ while (someMoreWork) {
+ switch(zds->streamStage)
+ {
+ case zdss_init :
+ DEBUGLOG(5, "stage zdss_init => transparent reset ");
+ ZSTD_resetDStream(zds); /* transparent reset on starting decoding a new frame */
+ /* fall-through */
+
+ case zdss_loadHeader :
+ DEBUGLOG(5, "stage zdss_loadHeader (srcSize : %u)", (U32)(iend - ip));
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
+ if (zds->legacyVersion) {
+ /* legacy support is incompatible with static dctx */
+ if (zds->staticSize) return ERROR(memory_allocation);
+ { size_t const hint = ZSTD_decompressLegacyStream(zds->legacyContext, zds->legacyVersion, output, input);
+ if (hint==0) zds->streamStage = zdss_init;
+ return hint;
+ } }
+#endif
+ { size_t const hSize = ZSTD_getFrameHeader_advanced(&zds->fParams, zds->headerBuffer, zds->lhSize, zds->format);
+ DEBUGLOG(5, "header size : %u", (U32)hSize);
+ if (ZSTD_isError(hSize)) {
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
+ U32 const legacyVersion = ZSTD_isLegacy(istart, iend-istart);
+ if (legacyVersion) {
+ const void* const dict = zds->ddict ? zds->ddict->dictContent : NULL;
+ size_t const dictSize = zds->ddict ? zds->ddict->dictSize : 0;
+ DEBUGLOG(5, "ZSTD_decompressStream: detected legacy version v0.%u", legacyVersion);
+ /* legacy support is incompatible with static dctx */
+ if (zds->staticSize) return ERROR(memory_allocation);
+ CHECK_F(ZSTD_initLegacyStream(&zds->legacyContext,
+ zds->previousLegacyVersion, legacyVersion,
+ dict, dictSize));
+ zds->legacyVersion = zds->previousLegacyVersion = legacyVersion;
+ { size_t const hint = ZSTD_decompressLegacyStream(zds->legacyContext, legacyVersion, output, input);
+ if (hint==0) zds->streamStage = zdss_init; /* or stay in stage zdss_loadHeader */
+ return hint;
+ } }
+#endif
+ return hSize; /* error */
+ }
+ if (hSize != 0) { /* need more input */
+ size_t const toLoad = hSize - zds->lhSize; /* if hSize!=0, hSize > zds->lhSize */
+ size_t const remainingInput = (size_t)(iend-ip);
+ assert(iend >= ip);
+ if (toLoad > remainingInput) { /* not enough input to load full header */
+ if (remainingInput > 0) {
+ memcpy(zds->headerBuffer + zds->lhSize, ip, remainingInput);
+ zds->lhSize += remainingInput;
+ }
+ input->pos = input->size;
+ return (MAX(ZSTD_frameHeaderSize_min, hSize) - zds->lhSize) + ZSTD_blockHeaderSize; /* remaining header bytes + next block header */
+ }
+ assert(ip != NULL);
+ memcpy(zds->headerBuffer + zds->lhSize, ip, toLoad); zds->lhSize = hSize; ip += toLoad;
+ break;
+ } }
+
+ /* check for single-pass mode opportunity */
+ if (zds->fParams.frameContentSize && zds->fParams.windowSize /* skippable frame if == 0 */
+ && (U64)(size_t)(oend-op) >= zds->fParams.frameContentSize) {
+ size_t const cSize = ZSTD_findFrameCompressedSize(istart, iend-istart);
+ if (cSize <= (size_t)(iend-istart)) {
+ /* shortcut : using single-pass mode */
+ size_t const decompressedSize = ZSTD_decompress_usingDDict(zds, op, oend-op, istart, cSize, zds->ddict);
+ if (ZSTD_isError(decompressedSize)) return decompressedSize;
+ DEBUGLOG(4, "shortcut to single-pass ZSTD_decompress_usingDDict()")
+ ip = istart + cSize;
+ op += decompressedSize;
+ zds->expected = 0;
+ zds->streamStage = zdss_init;
+ someMoreWork = 0;
+ break;
+ } }
+
+ /* Consume header (see ZSTDds_decodeFrameHeader) */
+ DEBUGLOG(4, "Consume header");
+ CHECK_F(ZSTD_decompressBegin_usingDDict(zds, zds->ddict));
+
+ if ((MEM_readLE32(zds->headerBuffer) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { /* skippable frame */
+ zds->expected = MEM_readLE32(zds->headerBuffer + ZSTD_FRAMEIDSIZE);
+ zds->stage = ZSTDds_skipFrame;
+ } else {
+ CHECK_F(ZSTD_decodeFrameHeader(zds, zds->headerBuffer, zds->lhSize));
+ zds->expected = ZSTD_blockHeaderSize;
+ zds->stage = ZSTDds_decodeBlockHeader;
+ }
+
+ /* control buffer memory usage */
+ DEBUGLOG(4, "Control max memory usage (%u KB <= max %u KB)",
+ (U32)(zds->fParams.windowSize >>10),
+ (U32)(zds->maxWindowSize >> 10) );
+ zds->fParams.windowSize = MAX(zds->fParams.windowSize, 1U << ZSTD_WINDOWLOG_ABSOLUTEMIN);
+ if (zds->fParams.windowSize > zds->maxWindowSize) return ERROR(frameParameter_windowTooLarge);
+
+ /* Adapt buffer sizes to frame header instructions */
+ { size_t const neededInBuffSize = MAX(zds->fParams.blockSizeMax, 4 /* frame checksum */);
+ size_t const neededOutBuffSize = ZSTD_decodingBufferSize_min(zds->fParams.windowSize, zds->fParams.frameContentSize);
+ if ((zds->inBuffSize < neededInBuffSize) || (zds->outBuffSize < neededOutBuffSize)) {
+ size_t const bufferSize = neededInBuffSize + neededOutBuffSize;
+ DEBUGLOG(4, "inBuff : from %u to %u",
+ (U32)zds->inBuffSize, (U32)neededInBuffSize);
+ DEBUGLOG(4, "outBuff : from %u to %u",
+ (U32)zds->outBuffSize, (U32)neededOutBuffSize);
+ if (zds->staticSize) { /* static DCtx */
+ DEBUGLOG(4, "staticSize : %u", (U32)zds->staticSize);
+ assert(zds->staticSize >= sizeof(ZSTD_DCtx)); /* controlled at init */
+ if (bufferSize > zds->staticSize - sizeof(ZSTD_DCtx))
+ return ERROR(memory_allocation);
+ } else {
+ ZSTD_free(zds->inBuff, zds->customMem);
+ zds->inBuffSize = 0;
+ zds->outBuffSize = 0;
+ zds->inBuff = (char*)ZSTD_malloc(bufferSize, zds->customMem);
+ if (zds->inBuff == NULL) return ERROR(memory_allocation);
+ }
+ zds->inBuffSize = neededInBuffSize;
+ zds->outBuff = zds->inBuff + zds->inBuffSize;
+ zds->outBuffSize = neededOutBuffSize;
+ } }
+ zds->streamStage = zdss_read;
+ /* fall-through */
+
+ case zdss_read:
+ DEBUGLOG(5, "stage zdss_read");
+ { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds);
+ DEBUGLOG(5, "neededInSize = %u", (U32)neededInSize);
+ if (neededInSize==0) { /* end of frame */
+ zds->streamStage = zdss_init;
+ someMoreWork = 0;
+ break;
+ }
+ if ((size_t)(iend-ip) >= neededInSize) { /* decode directly from src */
+ int const isSkipFrame = ZSTD_isSkipFrame(zds);
+ size_t const decodedSize = ZSTD_decompressContinue(zds,
+ zds->outBuff + zds->outStart, (isSkipFrame ? 0 : zds->outBuffSize - zds->outStart),
+ ip, neededInSize);
+ if (ZSTD_isError(decodedSize)) return decodedSize;
+ ip += neededInSize;
+ if (!decodedSize && !isSkipFrame) break; /* this was just a header */
+ zds->outEnd = zds->outStart + decodedSize;
+ zds->streamStage = zdss_flush;
+ break;
+ } }
+ if (ip==iend) { someMoreWork = 0; break; } /* no more input */
+ zds->streamStage = zdss_load;
+ /* fall-through */
+
+ case zdss_load:
+ { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds);
+ size_t const toLoad = neededInSize - zds->inPos;
+ int const isSkipFrame = ZSTD_isSkipFrame(zds);
+ size_t loadedSize;
+ if (isSkipFrame) {
+ loadedSize = MIN(toLoad, (size_t)(iend-ip));
+ } else {
+ if (toLoad > zds->inBuffSize - zds->inPos) return ERROR(corruption_detected); /* should never happen */
+ loadedSize = ZSTD_limitCopy(zds->inBuff + zds->inPos, toLoad, ip, iend-ip);
+ }
+ ip += loadedSize;
+ zds->inPos += loadedSize;
+ if (loadedSize < toLoad) { someMoreWork = 0; break; } /* not enough input, wait for more */
+
+ /* decode loaded input */
+ { size_t const decodedSize = ZSTD_decompressContinue(zds,
+ zds->outBuff + zds->outStart, zds->outBuffSize - zds->outStart,
+ zds->inBuff, neededInSize);
+ if (ZSTD_isError(decodedSize)) return decodedSize;
+ zds->inPos = 0; /* input is consumed */
+ if (!decodedSize && !isSkipFrame) { zds->streamStage = zdss_read; break; } /* this was just a header */
+ zds->outEnd = zds->outStart + decodedSize;
+ } }
+ zds->streamStage = zdss_flush;
+ /* fall-through */
+
+ case zdss_flush:
+ { size_t const toFlushSize = zds->outEnd - zds->outStart;
+ size_t const flushedSize = ZSTD_limitCopy(op, oend-op, zds->outBuff + zds->outStart, toFlushSize);
+ op += flushedSize;
+ zds->outStart += flushedSize;
+ if (flushedSize == toFlushSize) { /* flush completed */
+ zds->streamStage = zdss_read;
+ if ( (zds->outBuffSize < zds->fParams.frameContentSize)
+ && (zds->outStart + zds->fParams.blockSizeMax > zds->outBuffSize) ) {
+ DEBUGLOG(5, "restart filling outBuff from beginning (left:%i, needed:%u)",
+ (int)(zds->outBuffSize - zds->outStart),
+ (U32)zds->fParams.blockSizeMax);
+ zds->outStart = zds->outEnd = 0;
+ }
+ break;
+ } }
+ /* cannot complete flush */
+ someMoreWork = 0;
+ break;
+
+ default: return ERROR(GENERIC); /* impossible */
+ } }
+
+ /* result */
+ input->pos = (size_t)(ip - (const char*)(input->src));
+ output->pos = (size_t)(op - (char*)(output->dst));
+ if ((ip==istart) && (op==ostart)) { /* no forward progress */
+ zds->noForwardProgress ++;
+ if (zds->noForwardProgress >= ZSTD_NO_FORWARD_PROGRESS_MAX) {
+ if (op==oend) return ERROR(dstSize_tooSmall);
+ if (ip==iend) return ERROR(srcSize_wrong);
+ assert(0);
+ }
+ } else {
+ zds->noForwardProgress = 0;
+ }
+ { size_t nextSrcSizeHint = ZSTD_nextSrcSizeToDecompress(zds);
+ if (!nextSrcSizeHint) { /* frame fully decoded */
+ if (zds->outEnd == zds->outStart) { /* output fully flushed */
+ if (zds->hostageByte) {
+ if (input->pos >= input->size) {
+ /* can't release hostage (not present) */
+ zds->streamStage = zdss_read;
+ return 1;
+ }
+ input->pos++; /* release hostage */
+ } /* zds->hostageByte */
+ return 0;
+ } /* zds->outEnd == zds->outStart */
+ if (!zds->hostageByte) { /* output not fully flushed; keep last byte as hostage; will be released when all output is flushed */
+ input->pos--; /* note : pos > 0, otherwise, impossible to finish reading last block */
+ zds->hostageByte=1;
+ }
+ return 1;
+ } /* nextSrcSizeHint==0 */
+ nextSrcSizeHint += ZSTD_blockHeaderSize * (ZSTD_nextInputType(zds) == ZSTDnit_block); /* preload header of next block */
+ assert(zds->inPos <= nextSrcSizeHint);
+ nextSrcSizeHint -= zds->inPos; /* part already loaded*/
+ return nextSrcSizeHint;
+ }
+}
+
+
+size_t ZSTD_decompress_generic(ZSTD_DCtx* dctx, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
+{
+ return ZSTD_decompressStream(dctx, output, input);
+}
+
+size_t ZSTD_decompress_generic_simpleArgs (
+ ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity, size_t* dstPos,
+ const void* src, size_t srcSize, size_t* srcPos)
+{
+ ZSTD_outBuffer output = { dst, dstCapacity, *dstPos };
+ ZSTD_inBuffer input = { src, srcSize, *srcPos };
+ /* ZSTD_compress_generic() will check validity of dstPos and srcPos */
+ size_t const cErr = ZSTD_decompress_generic(dctx, &output, &input);
+ *dstPos = output.pos;
+ *srcPos = input.pos;
+ return cErr;
+}
+
+void ZSTD_DCtx_reset(ZSTD_DCtx* dctx)
+{
+ (void)ZSTD_initDStream(dctx);
+ dctx->format = ZSTD_f_zstd1;
+ dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
+}
diff --git a/grub-core/lib/zstd/zstd_errors.h b/grub-core/lib/zstd/zstd_errors.h
new file mode 100644
index 0000000..57533f2
--- /dev/null
+++ b/grub-core/lib/zstd/zstd_errors.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_ERRORS_H_398273423
+#define ZSTD_ERRORS_H_398273423
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/*===== dependency =====*/
+#include <stddef.h> /* size_t */
+
+
+/* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */
+#ifndef ZSTDERRORLIB_VISIBILITY
+# if defined(__GNUC__) && (__GNUC__ >= 4)
+# define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default")))
+# else
+# define ZSTDERRORLIB_VISIBILITY
+# endif
+#endif
+#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
+# define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBILITY
+#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
+# define ZSTDERRORLIB_API __declspec(dllimport) ZSTDERRORLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
+#else
+# define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBILITY
+#endif
+
+/*-*********************************************
+ * Error codes list
+ *-*********************************************
+ * Error codes _values_ are pinned down since v1.3.1 only.
+ * Therefore, don't rely on values if you may link to any version < v1.3.1.
+ *
+ * Only values < 100 are considered stable.
+ *
+ * note 1 : this API shall be used with static linking only.
+ * dynamic linking is not yet officially supported.
+ * note 2 : Prefer relying on the enum than on its value whenever possible
+ * This is the only supported way to use the error list < v1.3.1
+ * note 3 : ZSTD_isError() is always correct, whatever the library version.
+ **********************************************/
+typedef enum {
+ ZSTD_error_no_error = 0,
+ ZSTD_error_GENERIC = 1,
+ ZSTD_error_prefix_unknown = 10,
+ ZSTD_error_version_unsupported = 12,
+ ZSTD_error_frameParameter_unsupported = 14,
+ ZSTD_error_frameParameter_windowTooLarge = 16,
+ ZSTD_error_corruption_detected = 20,
+ ZSTD_error_checksum_wrong = 22,
+ ZSTD_error_dictionary_corrupted = 30,
+ ZSTD_error_dictionary_wrong = 32,
+ ZSTD_error_dictionaryCreation_failed = 34,
+ ZSTD_error_parameter_unsupported = 40,
+ ZSTD_error_parameter_outOfBound = 42,
+ ZSTD_error_tableLog_tooLarge = 44,
+ ZSTD_error_maxSymbolValue_tooLarge = 46,
+ ZSTD_error_maxSymbolValue_tooSmall = 48,
+ ZSTD_error_stage_wrong = 60,
+ ZSTD_error_init_missing = 62,
+ ZSTD_error_memory_allocation = 64,
+ ZSTD_error_workSpace_tooSmall= 66,
+ ZSTD_error_dstSize_tooSmall = 70,
+ ZSTD_error_srcSize_wrong = 72,
+ /* following error codes are __NOT STABLE__, they can be removed or changed in future versions */
+ ZSTD_error_frameIndex_tooLarge = 100,
+ ZSTD_error_seekableIO = 102,
+ ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
+} ZSTD_ErrorCode;
+
+/*! ZSTD_getErrorCode() :
+ convert a `size_t` function result into a `ZSTD_ErrorCode` enum type,
+ which can be used to compare with enum list published above */
+ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult);
+ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ZSTD_ERRORS_H_398273423 */
diff --git a/grub-core/lib/zstd/zstd_internal.h b/grub-core/lib/zstd/zstd_internal.h
new file mode 100644
index 0000000..e75adfa
--- /dev/null
+++ b/grub-core/lib/zstd/zstd_internal.h
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_CCOMMON_H_MODULE
+#define ZSTD_CCOMMON_H_MODULE
+
+/* this module contains definitions which must be identical
+ * across compression, decompression and dictBuilder.
+ * It also contains a few functions useful to at least 2 of them
+ * and which benefit from being inlined */
+
+/*-*************************************
+* Dependencies
+***************************************/
+#include "compiler.h"
+#include "mem.h"
+#include "debug.h" /* assert, DEBUGLOG, RAWLOG, g_debuglevel */
+#include "error_private.h"
+#define ZSTD_STATIC_LINKING_ONLY
+#include "zstd.h"
+#define FSE_STATIC_LINKING_ONLY
+#include "fse.h"
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h"
+#ifndef XXH_STATIC_LINKING_ONLY
+# define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
+#endif
+#include "xxhash.h" /* XXH_reset, update, digest */
+
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/* ---- static assert (debug) --- */
+#define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
+
+
+/*-*************************************
+* shared macros
+***************************************/
+#undef MIN
+#undef MAX
+#define MIN(a,b) ((a)<(b) ? (a) : (b))
+#define MAX(a,b) ((a)>(b) ? (a) : (b))
+#define CHECK_F(f) { size_t const errcod = f; if (ERR_isError(errcod)) return errcod; } /* check and Forward error code */
+#define CHECK_E(f, e) { size_t const errcod = f; if (ERR_isError(errcod)) return ERROR(e); } /* check and send Error code */
+
+
+/*-*************************************
+* Common constants
+***************************************/
+#define ZSTD_OPT_NUM (1<<12)
+
+#define ZSTD_REP_NUM 3 /* number of repcodes */
+#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
+static const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
+
+#define KB *(1 <<10)
+#define MB *(1 <<20)
+#define GB *(1U<<30)
+
+#define BIT7 128
+#define BIT6 64
+#define BIT5 32
+#define BIT4 16
+#define BIT1 2
+#define BIT0 1
+
+#define ZSTD_WINDOWLOG_ABSOLUTEMIN 10
+#define ZSTD_WINDOWLOG_DEFAULTMAX 27 /* Default maximum allowed window log */
+static const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 };
+static const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 };
+
+#define ZSTD_FRAMEIDSIZE 4 /* magic number size */
+
+#define ZSTD_BLOCKHEADERSIZE 3 /* C standard doesn't allow `static const` variable to be init using another `static const` variable */
+static const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE;
+typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e;
+
+#define MIN_SEQUENCES_SIZE 1 /* nbSeq==0 */
+#define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */ + MIN_SEQUENCES_SIZE /* nbSeq==0 */) /* for a non-null block */
+
+#define HufLog 12
+typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingType_e;
+
+#define LONGNBSEQ 0x7F00
+
+#define MINMATCH 3
+
+#define Litbits 8
+#define MaxLit ((1<<Litbits) - 1)
+#define MaxML 52
+#define MaxLL 35
+#define DefaultMaxOff 28
+#define MaxOff 31
+#define MaxSeq MAX(MaxLL, MaxML) /* Assumption : MaxOff < MaxLL,MaxML */
+#define MLFSELog 9
+#define LLFSELog 9
+#define OffFSELog 8
+#define MaxFSELog MAX(MAX(MLFSELog, LLFSELog), OffFSELog)
+
+static const U32 LL_bits[MaxLL+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 2, 2, 3, 3,
+ 4, 6, 7, 8, 9,10,11,12,
+ 13,14,15,16 };
+static const S16 LL_defaultNorm[MaxLL+1] = { 4, 3, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 3, 2, 1, 1, 1, 1, 1,
+ -1,-1,-1,-1 };
+#define LL_DEFAULTNORMLOG 6 /* for static allocation */
+static const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG;
+
+static const U32 ML_bits[MaxML+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 2, 2, 3, 3,
+ 4, 4, 5, 7, 8, 9,10,11,
+ 12,13,14,15,16 };
+static const S16 ML_defaultNorm[MaxML+1] = { 1, 4, 3, 2, 2, 2, 2, 2,
+ 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1,-1,-1,
+ -1,-1,-1,-1,-1 };
+#define ML_DEFAULTNORMLOG 6 /* for static allocation */
+static const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG;
+
+static const S16 OF_defaultNorm[DefaultMaxOff+1] = { 1, 1, 1, 1, 1, 1, 2, 2,
+ 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ -1,-1,-1,-1,-1 };
+#define OF_DEFAULTNORMLOG 5 /* for static allocation */
+static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
+
+
+/*-*******************************************
+* Shared functions to include for inlining
+*********************************************/
+static void ZSTD_copy8(void* dst, const void* src) { memcpy(dst, src, 8); }
+#define COPY8(d,s) { ZSTD_copy8(d,s); d+=8; s+=8; }
+
+/*! ZSTD_wildcopy() :
+ * custom version of memcpy(), can overwrite up to WILDCOPY_OVERLENGTH bytes (if length==0) */
+#define WILDCOPY_OVERLENGTH 8
+MEM_STATIC void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length)
+{
+ const BYTE* ip = (const BYTE*)src;
+ BYTE* op = (BYTE*)dst;
+ BYTE* const oend = op + length;
+ do
+ COPY8(op, ip)
+ while (op < oend);
+}
+
+MEM_STATIC void ZSTD_wildcopy_e(void* dst, const void* src, void* dstEnd) /* should be faster for decoding, but strangely, not verified on all platform */
+{
+ const BYTE* ip = (const BYTE*)src;
+ BYTE* op = (BYTE*)dst;
+ BYTE* const oend = (BYTE*)dstEnd;
+ do
+ COPY8(op, ip)
+ while (op < oend);
+}
+
+
+/*-*******************************************
+* Private declarations
+*********************************************/
+typedef struct seqDef_s {
+ U32 offset;
+ U16 litLength;
+ U16 matchLength;
+} seqDef;
+
+typedef struct {
+ seqDef* sequencesStart;
+ seqDef* sequences;
+ BYTE* litStart;
+ BYTE* lit;
+ BYTE* llCode;
+ BYTE* mlCode;
+ BYTE* ofCode;
+ size_t maxNbSeq;
+ size_t maxNbLit;
+ U32 longLengthID; /* 0 == no longLength; 1 == Lit.longLength; 2 == Match.longLength; */
+ U32 longLengthPos;
+} seqStore_t;
+
+const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
+void ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
+
+/* custom memory allocation functions */
+void* ZSTD_malloc(size_t size, ZSTD_customMem customMem);
+void* ZSTD_calloc(size_t size, ZSTD_customMem customMem);
+void ZSTD_free(void* ptr, ZSTD_customMem customMem);
+
+
+MEM_STATIC U32 ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus */
+{
+ assert(val != 0);
+ {
+# if defined(_MSC_VER) /* Visual */
+ unsigned long r=0;
+ _BitScanReverse(&r, val);
+ return (unsigned)r;
+# elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
+ return 31 - __builtin_clz(val);
+# else /* Software version */
+ static const U32 DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
+ U32 v = val;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ return DeBruijnClz[(v * 0x07C4ACDDU) >> 27];
+# endif
+ }
+}
+
+
+/* ZSTD_invalidateRepCodes() :
+ * ensures next compression will not use repcodes from previous block.
+ * Note : only works with regular variant;
+ * do not use with extDict variant ! */
+void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx); /* zstdmt, adaptive_compression (shouldn't get this definition from here) */
+
+
+typedef struct {
+ blockType_e blockType;
+ U32 lastBlock;
+ U32 origSize;
+} blockProperties_t;
+
+/*! ZSTD_getcBlockSize() :
+ * Provides the size of compressed block from block header `src` */
+/* Used by: decompress, fullbench (does not get its definition from here) */
+size_t ZSTD_getcBlockSize(const void* src, size_t srcSize,
+ blockProperties_t* bpPtr);
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ZSTD_CCOMMON_H_MODULE */
diff --git a/grub-core/loader/aout.c b/grub-core/loader/aout.c
new file mode 100644
index 0000000..69bf6e6
--- /dev/null
+++ b/grub-core/loader/aout.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2008 Free Software Foundation, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/aout.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+int
+grub_aout_get_type (union grub_aout_header *header)
+{
+ int magic;
+
+ magic = AOUT_GETMAGIC (header->aout32);
+ if ((magic == AOUT32_OMAGIC) || (magic == AOUT32_NMAGIC) ||
+ (magic == AOUT32_ZMAGIC) || (magic == AOUT32_QMAGIC))
+ return AOUT_TYPE_AOUT32;
+ else if ((magic == AOUT64_OMAGIC) || (magic == AOUT64_NMAGIC) ||
+ (magic == AOUT64_ZMAGIC))
+ return AOUT_TYPE_AOUT64;
+ else
+ return AOUT_TYPE_NONE;
+}
+
+grub_err_t
+grub_aout_load (grub_file_t file, int offset,
+ void *load_addr,
+ int load_size, grub_size_t bss_size)
+{
+ if ((grub_file_seek (file, offset)) == (grub_off_t) - 1)
+ return grub_errno;
+
+ if (!load_size)
+ load_size = file->size - offset;
+
+ grub_file_read (file, load_addr, load_size);
+
+ if (grub_errno)
+ return grub_errno;
+
+ if (bss_size)
+ grub_memset ((char *) load_addr + load_size, 0, bss_size);
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
new file mode 100644
index 0000000..ed23dc7
--- /dev/null
+++ b/grub-core/loader/arm/linux.c
@@ -0,0 +1,509 @@
+/* linux.c - boot Linux */
+/*
+ * 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/dl.h>
+#include <grub/fdt.h>
+#include <grub/file.h>
+#include <grub/loader.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/cache.h>
+#include <grub/cpu/linux.h>
+#include <grub/lib/cmdline.h>
+#include <grub/linux.h>
+#include <grub/verify.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+
+static grub_addr_t initrd_start;
+static grub_addr_t initrd_end;
+
+static grub_addr_t linux_addr;
+static grub_size_t linux_size;
+
+static char *linux_args;
+
+static grub_uint32_t machine_type;
+static const void *current_fdt;
+
+typedef void (*kernel_entry_t) (int, unsigned long, void *);
+
+#define LINUX_PHYS_OFFSET (0x00008000)
+#define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x03000000)
+#define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000)
+
+static grub_size_t
+get_atag_size (const grub_uint32_t *atag)
+{
+ const 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 *target_atag)
+{
+ const grub_uint32_t *atag_orig = (const grub_uint32_t *) current_fdt;
+ grub_uint32_t *tmp_atag, *to;
+ const grub_uint32_t *from;
+ 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_calloc (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 (target_atag, 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.
+ * Merges in command line parameters and sets up initrd addresses.
+ */
+static grub_err_t
+linux_prepare_fdt (void *target_fdt)
+{
+ int node;
+ int retval;
+ int tmp_size;
+ void *tmp_fdt;
+
+ tmp_size = grub_fdt_get_totalsize (current_fdt) + 0x100 + grub_strlen (linux_args);
+ tmp_fdt = grub_malloc (tmp_size);
+ if (!tmp_fdt)
+ return grub_errno;
+
+ grub_memcpy (tmp_fdt, current_fdt, grub_fdt_get_totalsize (current_fdt));
+ grub_fdt_set_totalsize (tmp_fdt, tmp_size);
+
+ /* Find or create '/chosen' node */
+ node = grub_fdt_find_subnode (tmp_fdt, 0, "chosen");
+ if (node < 0)
+ {
+ grub_dprintf ("linux", "No 'chosen' node in FDT - creating.\n");
+ node = grub_fdt_add_subnode (tmp_fdt, 0, "chosen");
+ if (node < 0)
+ goto failure;
+ }
+
+ grub_dprintf ("linux", "linux_args: '%s'\n", linux_args);
+
+ /* Generate and set command line */
+ retval = grub_fdt_set_prop (tmp_fdt, node, "bootargs", linux_args,
+ grub_strlen (linux_args) + 1);
+ if (retval)
+ goto failure;
+
+ 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);
+
+ retval = grub_fdt_set_prop32 (tmp_fdt, node, "linux,initrd-start",
+ initrd_start);
+ if (retval)
+ goto failure;
+ retval = grub_fdt_set_prop32 (tmp_fdt, node, "linux,initrd-end",
+ initrd_end);
+ if (retval)
+ goto failure;
+ }
+
+ /* Copy updated FDT to its launch location */
+ grub_memcpy (target_fdt, tmp_fdt, tmp_size);
+ grub_free (tmp_fdt);
+
+ grub_dprintf ("loader", "FDT updated for Linux boot\n");
+
+ return GRUB_ERR_NONE;
+
+failure:
+ grub_free (tmp_fdt);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "unable to prepare FDT");
+}
+
+static grub_err_t
+linux_boot (void)
+{
+ kernel_entry_t linuxmain;
+ int fdt_valid, atag_valid;
+ void *target_fdt = 0;
+
+ fdt_valid = (current_fdt && grub_fdt_check_header_nosize (current_fdt) == 0);
+ atag_valid = ((((const grub_uint16_t *) current_fdt)[3] & ~3) == 0x5440
+ && *((const grub_uint32_t *) current_fdt));
+ grub_dprintf ("loader", "atag: %p, %x, %x, %s, %s\n",
+ current_fdt,
+ ((const grub_uint16_t *) current_fdt)[3],
+ *((const grub_uint32_t *) current_fdt),
+ (const char *) current_fdt,
+ (const char *) current_fdt + 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 (see `devicetree' command)"));
+
+ grub_arch_sync_caches ((void *) linux_addr, linux_size);
+
+ grub_dprintf ("loader", "Kernel at: 0x%x\n", linux_addr);
+
+ if (fdt_valid || atag_valid)
+ {
+#ifdef GRUB_MACHINE_EFI
+ grub_size_t size;
+ if (fdt_valid)
+ size = grub_fdt_get_totalsize (current_fdt);
+ else
+ size = 4 * get_atag_size (current_fdt);
+ size += grub_strlen (linux_args) + 256;
+ target_fdt = grub_efi_allocate_loader_memory (LINUX_FDT_PHYS_OFFSET, size);
+ if (!target_fdt)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+#else
+ target_fdt = (void *) LINUX_FDT_ADDRESS;
+#endif
+ }
+
+ if (fdt_valid)
+ {
+ grub_err_t err;
+
+ err = linux_prepare_fdt (target_fdt);
+ if (err)
+ return err;
+ grub_dprintf ("loader", "FDT @ %p\n", target_fdt);
+ }
+ else if (atag_valid)
+ {
+ grub_err_t err;
+
+ err = linux_prepare_atag (target_fdt);
+ if (err)
+ return err;
+ grub_dprintf ("loader", "ATAG @ %p\n", target_fdt);
+ }
+
+ grub_dprintf ("loader", "Jumping to Linux...\n");
+
+ /* Boot the kernel.
+ * Arguments to kernel:
+ * r0 - 0
+ * r1 - machine type
+ * r2 - address of DTB
+ */
+ linuxmain = (kernel_entry_t) linux_addr;
+
+ grub_arm_disable_caches_mmu ();
+
+ linuxmain (0, machine_type, target_fdt);
+
+ return grub_error (GRUB_ERR_BAD_OS, "Linux call returned");
+}
+
+/*
+ * Only support zImage, so no relocations necessary
+ */
+static grub_err_t
+linux_load (const char *filename, grub_file_t file)
+{
+ struct linux_arm_kernel_header *lh;
+ int size;
+
+ size = grub_file_size (file);
+
+ linux_addr = LINUX_ADDRESS;
+ grub_dprintf ("loader", "Loading Linux to 0x%08x\n",
+ (grub_addr_t) linux_addr);
+
+ if (grub_file_read (file, (void *) linux_addr, size) != size)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ return grub_errno;
+ }
+
+ lh = (void *) linux_addr;
+
+ if ((grub_size_t) size > sizeof (*lh) &&
+ lh->magic == GRUB_LINUX_ARM_MAGIC_SIGNATURE)
+ ;
+ 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;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+linux_unload (void)
+{
+ grub_dl_unref (my_mod);
+
+ grub_free (linux_args);
+ linux_args = NULL;
+
+ initrd_start = initrd_end = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ int size;
+ grub_err_t err;
+ grub_file_t file;
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
+ if (!file)
+ goto fail;
+
+ err = linux_load (argv[0], file);
+ grub_file_close (file);
+ if (err)
+ goto fail;
+
+ grub_loader_set (linux_boot, linux_unload, 0);
+
+ size = grub_loader_cmdline_size (argc, argv);
+ linux_args = grub_malloc (size + sizeof (LINUX_IMAGE));
+ if (!linux_args)
+ {
+ grub_loader_unset();
+ goto fail;
+ }
+
+ /* Create kernel command line. */
+ grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE));
+ err = grub_create_loader_cmdline (argc, argv,
+ linux_args + sizeof (LINUX_IMAGE) - 1, size,
+ GRUB_VERIFY_KERNEL_CMDLINE);
+ if (err)
+ goto fail;
+
+ return GRUB_ERR_NONE;
+
+fail:
+ grub_dl_unref (my_mod);
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file;
+ grub_size_t size = 0;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_INITRD);
+ if (!file)
+ return grub_errno;
+
+ if (grub_initrd_init (argc, argv, &initrd_ctx))
+ goto fail;
+
+ size = grub_get_initrd_size (&initrd_ctx);
+
+ initrd_start = LINUX_INITRD_ADDRESS;
+
+ grub_dprintf ("loader", "Loading initrd to 0x%08x\n",
+ (grub_addr_t) initrd_start);
+
+ if (grub_initrd_load (&initrd_ctx, argv, (void *) initrd_start))
+ goto fail;
+
+ initrd_end = initrd_start + size;
+
+ return GRUB_ERR_NONE;
+
+fail:
+ grub_file_close (file);
+
+ return grub_errno;
+}
+
+static grub_err_t
+load_dtb (grub_file_t dtb, int size)
+{
+ void *new_fdt = grub_zalloc (size);
+ if (!new_fdt)
+ return grub_errno;
+ grub_dprintf ("loader", "Loading device tree to %p\n",
+ new_fdt);
+ if ((grub_file_read (dtb, new_fdt, size) != size)
+ || (grub_fdt_check_header (new_fdt, size) != 0))
+ {
+ grub_free (new_fdt);
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree"));
+ }
+
+ grub_fdt_set_totalsize (new_fdt, size);
+ current_fdt = new_fdt;
+ /*
+ * We've successfully loaded an FDT, so any machine type passed
+ * from firmware is now obsolete.
+ */
+ machine_type = GRUB_ARM_MACHINE_TYPE_FDT;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t dtb;
+ int size;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ dtb = grub_file_open (argv[0], GRUB_FILE_TYPE_DEVICE_TREE_IMAGE);
+ if (!dtb)
+ return grub_errno;
+
+ size = grub_file_size (dtb);
+ if (size == 0)
+ grub_error (GRUB_ERR_BAD_OS, "empty file");
+ else
+ load_dtb (dtb, size);
+ grub_file_close (dtb);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd_linux, cmd_initrd, cmd_devicetree;
+
+GRUB_MOD_INIT (linux)
+{
+ cmd_linux = grub_register_command ("linux", grub_cmd_linux,
+ 0, N_("Load Linux."));
+ cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd,
+ 0, N_("Load initrd."));
+ cmd_devicetree = grub_register_command_lockdown ("devicetree", grub_cmd_devicetree,
+ /* TRANSLATORS: DTB stands for device tree blob. */
+ 0, N_("Load DTB file."));
+ my_mod = mod;
+ current_fdt = (const void *) grub_arm_firmware_get_boot_data ();
+ machine_type = grub_arm_firmware_get_machine_type ();
+}
+
+GRUB_MOD_FINI (linux)
+{
+ grub_unregister_command (cmd_linux);
+ grub_unregister_command (cmd_initrd);
+ 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 0000000..ef3e9f9
--- /dev/null
+++ b/grub-core/loader/arm64/linux.c
@@ -0,0 +1,393 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/charset.h>
+#include <grub/command.h>
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/fdt.h>
+#include <grub/linux.h>
+#include <grub/loader.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/cpu/linux.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/fdtload.h>
+#include <grub/efi/memory.h>
+#include <grub/efi/pe32.h>
+#include <grub/i18n.h>
+#include <grub/lib/cmdline.h>
+#include <grub/verify.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+static int loaded;
+
+static void *kernel_addr;
+static grub_uint64_t kernel_size;
+
+static char *linux_args;
+static grub_uint32_t cmdline_size;
+
+static grub_addr_t initrd_start;
+static grub_addr_t initrd_end;
+
+grub_err_t
+grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
+{
+ if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE)
+ return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
+
+ if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled"));
+
+ grub_dprintf ("linux", "UEFI stub kernel:\n");
+ grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+finalize_params_linux (void)
+{
+ int node, retval;
+
+ void *fdt;
+
+ fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE);
+
+ if (!fdt)
+ goto failure;
+
+ node = grub_fdt_find_subnode (fdt, 0, "chosen");
+ if (node < 0)
+ node = grub_fdt_add_subnode (fdt, 0, "chosen");
+
+ if (node < 1)
+ goto failure;
+
+ /* Set initrd info */
+ if (initrd_start && initrd_end > initrd_start)
+ {
+ grub_dprintf ("linux", "Initrd @ %p-%p\n",
+ (void *) initrd_start, (void *) initrd_end);
+
+ retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start",
+ initrd_start);
+ if (retval)
+ goto failure;
+ retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-end",
+ initrd_end);
+ if (retval)
+ goto failure;
+ }
+
+ if (grub_fdt_install() != GRUB_ERR_NONE)
+ goto failure;
+
+ return GRUB_ERR_NONE;
+
+failure:
+ grub_fdt_unload();
+ return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT");
+}
+
+grub_err_t
+grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args)
+{
+ grub_efi_memory_mapped_device_path_t *mempath;
+ grub_efi_handle_t image_handle;
+ grub_efi_boot_services_t *b;
+ grub_efi_status_t status;
+ grub_efi_loaded_image_t *loaded_image;
+ int len;
+
+ mempath = grub_malloc (2 * sizeof (grub_efi_memory_mapped_device_path_t));
+ if (!mempath)
+ return grub_errno;
+
+ mempath[0].header.type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE;
+ mempath[0].header.subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE;
+ mempath[0].header.length = grub_cpu_to_le16_compile_time (sizeof (*mempath));
+ mempath[0].memory_type = GRUB_EFI_LOADER_DATA;
+ mempath[0].start_address = addr;
+ mempath[0].end_address = addr + size;
+
+ mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE;
+ mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ mempath[1].header.length = sizeof (grub_efi_device_path_t);
+
+ b = grub_efi_system_table->boot_services;
+ status = b->load_image (0, grub_efi_image_handle,
+ (grub_efi_device_path_t *) mempath,
+ (void *) addr, size, &image_handle);
+ if (status != GRUB_EFI_SUCCESS)
+ return grub_error (GRUB_ERR_BAD_OS, "cannot load image");
+
+ grub_dprintf ("linux", "linux command line: '%s'\n", args);
+
+ /* Convert command line to UCS-2 */
+ loaded_image = grub_efi_get_loaded_image (image_handle);
+ loaded_image->load_options_size = len =
+ (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t);
+ loaded_image->load_options =
+ grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size));
+ if (!loaded_image->load_options)
+ return grub_errno;
+
+ loaded_image->load_options_size =
+ 2 * grub_utf8_to_utf16 (loaded_image->load_options, len,
+ (grub_uint8_t *) args, len, NULL);
+
+ grub_dprintf ("linux", "starting image %p\n", image_handle);
+ status = b->start_image (image_handle, 0, NULL);
+
+ /* When successful, not reached */
+ b->unload_image (image_handle);
+ grub_efi_free_pages ((grub_addr_t) loaded_image->load_options,
+ GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size));
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_linux_boot (void)
+{
+ if (finalize_params_linux () != GRUB_ERR_NONE)
+ return grub_errno;
+
+ return (grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr,
+ kernel_size, linux_args));
+}
+
+static grub_err_t
+grub_linux_unload (void)
+{
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ if (initrd_start)
+ grub_efi_free_pages ((grub_efi_physical_address_t) initrd_start,
+ GRUB_EFI_BYTES_TO_PAGES (initrd_end - initrd_start));
+ initrd_start = initrd_end = 0;
+ grub_free (linux_args);
+ if (kernel_addr)
+ grub_efi_free_pages ((grub_addr_t) kernel_addr,
+ GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+ grub_fdt_unload ();
+ return GRUB_ERR_NONE;
+}
+
+/*
+ * As per linux/Documentation/arm/Booting
+ * ARM initrd needs to be covered by kernel linear mapping,
+ * so place it in the first 512MB of DRAM.
+ *
+ * As per linux/Documentation/arm64/booting.txt
+ * ARM64 initrd needs to be contained entirely within a 1GB aligned window
+ * of up to 32GB of size that covers the kernel image as well.
+ * Since the EFI stub loader will attempt to load the kernel near start of
+ * RAM, place the buffer in the first 32GB of RAM.
+ */
+#ifdef __arm__
+#define INITRD_MAX_ADDRESS_OFFSET (512U * 1024 * 1024)
+#else /* __aarch64__ */
+#define INITRD_MAX_ADDRESS_OFFSET (32ULL * 1024 * 1024 * 1024)
+#endif
+
+/*
+ * This function returns a pointer to a legally allocated initrd buffer,
+ * or NULL if unsuccessful
+ */
+static void *
+allocate_initrd_mem (int initrd_pages)
+{
+ grub_addr_t max_addr;
+
+ if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE)
+ return NULL;
+
+ max_addr += INITRD_MAX_ADDRESS_OFFSET - 1;
+
+ return grub_efi_allocate_pages_real (max_addr, initrd_pages,
+ GRUB_EFI_ALLOCATE_MAX_ADDRESS,
+ GRUB_EFI_LOADER_DATA);
+}
+
+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 = allocate_initrd_mem (initrd_pages);
+
+ if (!initrd_mem)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ goto fail;
+ }
+
+ if (grub_initrd_load (&initrd_ctx, argv, initrd_mem))
+ goto fail;
+
+ initrd_start = (grub_addr_t) initrd_mem;
+ initrd_end = initrd_start + initrd_size;
+ grub_dprintf ("linux", "[addr=%p, size=0x%x]\n",
+ (void *) initrd_start, initrd_size);
+
+ fail:
+ grub_initrd_close (&initrd_ctx);
+ if (initrd_mem && !initrd_start)
+ grub_efi_free_pages ((grub_addr_t) initrd_mem, initrd_pages);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ struct linux_arch_kernel_header lh;
+ grub_err_t err;
+
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
+ if (!file)
+ goto fail;
+
+ kernel_size = grub_file_size (file);
+
+ if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh))
+ return grub_errno;
+
+ if (grub_arch_efi_linux_check_image (&lh) != GRUB_ERR_NONE)
+ goto fail;
+
+ grub_loader_unset();
+
+ grub_dprintf ("linux", "kernel file size: %lld\n", (long long) kernel_size);
+ kernel_addr = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+ grub_dprintf ("linux", "kernel numpages: %lld\n",
+ (long long) GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+ if (!kernel_addr)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ goto fail;
+ }
+
+ grub_file_seek (file, 0);
+ if (grub_file_read (file, kernel_addr, kernel_size)
+ < (grub_int64_t) kernel_size)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]);
+ goto fail;
+ }
+
+ grub_dprintf ("linux", "kernel @ %p\n", kernel_addr);
+
+ cmdline_size = grub_loader_cmdline_size (argc, argv) + sizeof (LINUX_IMAGE);
+ linux_args = grub_malloc (cmdline_size);
+ if (!linux_args)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ goto fail;
+ }
+ grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE));
+ err = grub_create_loader_cmdline (argc, argv,
+ linux_args + sizeof (LINUX_IMAGE) - 1,
+ cmdline_size,
+ GRUB_VERIFY_KERNEL_CMDLINE);
+ if (err)
+ goto fail;
+
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ grub_loader_set (grub_linux_boot, grub_linux_unload, 0);
+ loaded = 1;
+ }
+
+fail:
+ if (file)
+ grub_file_close (file);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ }
+
+ if (linux_args && !loaded)
+ grub_free (linux_args);
+
+ if (kernel_addr && !loaded)
+ grub_efi_free_pages ((grub_addr_t) kernel_addr,
+ GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+
+ return grub_errno;
+}
+
+
+static grub_command_t cmd_linux, cmd_initrd;
+
+GRUB_MOD_INIT (linux)
+{
+ cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0,
+ N_("Load Linux."));
+ cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0,
+ N_("Load initrd."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (linux)
+{
+ grub_unregister_command (cmd_linux);
+ grub_unregister_command (cmd_initrd);
+}
diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c
new file mode 100644
index 0000000..22cc25e
--- /dev/null
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -0,0 +1,527 @@
+/*
+ * 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/linux.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/fdtload.h>
+#include <grub/efi/memory.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 linux_arm64_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");
+
+ /*
+ * The address and size are always written using 64-bits value. Set
+ * #address-cells and #size-cells accordingly.
+ */
+ retval = grub_fdt_set_prop32 (xen_boot_fdt, chosen_node, "#address-cells", 2);
+ if (retval)
+ return grub_error (GRUB_ERR_IO, "failed to set #address-cells");
+ retval = grub_fdt_set_prop32 (xen_boot_fdt, chosen_node, "#size-cells", 2);
+ if (retval)
+ return grub_error (GRUB_ERR_IO, "failed to set #size-cells");
+
+ 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));
+ 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_arch_efi_linux_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_any_pages (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_VERIFY_KERNEL_CMDLINE);
+ 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;
+ int nounzip = 0;
+
+ if (!argc)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ if (grub_strcmp (argv[0], "--nounzip") == 0)
+ {
+ argv++;
+ argc--;
+ nounzip = 1;
+ }
+
+ 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], GRUB_FILE_TYPE_XEN_MODULE
+ | (nounzip ? GRUB_FILE_TYPE_NO_DECOMPRESS
+ : GRUB_FILE_TYPE_NONE));
+ 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], GRUB_FILE_TYPE_XEN_HYPERVISOR);
+ if (!file)
+ goto fail;
+
+ if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh))
+ goto fail;
+ if (grub_arch_efi_linux_check_image
+ ((struct linux_arch_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
new file mode 100644
index 0000000..74888c4
--- /dev/null
+++ b/grub-core/loader/efi/appleloader.c
@@ -0,0 +1,242 @@
+/* appleloader.c - apple legacy boot loader. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+
+static grub_efi_handle_t image_handle;
+static grub_efi_char16_t *cmdline;
+
+static grub_err_t
+grub_appleloader_unload (void)
+{
+ grub_efi_boot_services_t *b;
+
+ b = grub_efi_system_table->boot_services;
+ efi_call_1 (b->unload_image, image_handle);
+
+ grub_free (cmdline);
+ cmdline = 0;
+
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_appleloader_boot (void)
+{
+ grub_efi_boot_services_t *b;
+
+ b = grub_efi_system_table->boot_services;
+ efi_call_3 (b->start_image, image_handle, 0, 0);
+
+ grub_appleloader_unload ();
+
+ return grub_errno;
+}
+
+struct piwg_full_device_path
+{
+ struct grub_efi_memory_mapped_device_path comp1;
+ struct grub_efi_piwg_device_path comp2;
+ struct grub_efi_device_path end;
+};
+
+#define MAKE_PIWG_PATH(st, en) \
+ { \
+ .comp1 = \
+ { \
+ .header = { \
+ .type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE, \
+ .subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE, \
+ .length = sizeof (struct grub_efi_memory_mapped_device_path) \
+ }, \
+ .memory_type = GRUB_EFI_MEMORY_MAPPED_IO, \
+ .start_address = st, \
+ .end_address = en \
+ }, \
+ .comp2 = \
+ { \
+ .header = { \
+ .type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE, \
+ .subtype = GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE, \
+ .length = sizeof (struct grub_efi_piwg_device_path) \
+ }, \
+ .guid = GRUB_EFI_VENDOR_APPLE_GUID \
+ }, \
+ .end = \
+ { \
+ .type = GRUB_EFI_END_DEVICE_PATH_TYPE, \
+ .subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE, \
+ .length = sizeof (struct grub_efi_device_path) \
+ } \
+ }
+
+/* early 2006 Core Duo / Core Solo models */
+static struct piwg_full_device_path devpath_1 = MAKE_PIWG_PATH (0xffe00000,
+ 0xfff9ffff);
+
+/* mid-2006 Mac Pro (and probably other Core 2 models) */
+static struct piwg_full_device_path devpath_2 = MAKE_PIWG_PATH (0xffe00000,
+ 0xfff7ffff);
+
+/* mid-2007 MBP ("Santa Rosa" based models) */
+static struct piwg_full_device_path devpath_3 = MAKE_PIWG_PATH (0xffe00000,
+ 0xfff8ffff);
+
+/* early-2008 MBA */
+static struct piwg_full_device_path devpath_4 = MAKE_PIWG_PATH (0xffc00000,
+ 0xfff8ffff);
+
+/* late-2008 MB/MBP (NVidia chipset) */
+static struct piwg_full_device_path devpath_5 = MAKE_PIWG_PATH (0xffcb4000,
+ 0xffffbfff);
+
+/* mid-2010 MB/MBP (NVidia chipset) */
+static struct piwg_full_device_path devpath_6 = MAKE_PIWG_PATH (0xffcc4000,
+ 0xffffbfff);
+
+static struct piwg_full_device_path devpath_7 = MAKE_PIWG_PATH (0xff981000,
+ 0xffc8ffff);
+
+/* mid-2012 MBP retina (MacBookPro10,1) */
+static struct piwg_full_device_path devpath_8 = MAKE_PIWG_PATH (0xff990000,
+ 0xffb2ffff);
+
+struct devdata
+{
+ const char *model;
+ grub_efi_device_path_t *devpath;
+};
+
+struct devdata devs[] =
+{
+ {"Core Duo/Solo", (grub_efi_device_path_t *) &devpath_1},
+ {"Mac Pro", (grub_efi_device_path_t *) &devpath_2},
+ {"MBP", (grub_efi_device_path_t *) &devpath_3},
+ {"MBA", (grub_efi_device_path_t *) &devpath_4},
+ {"MB NV", (grub_efi_device_path_t *) &devpath_5},
+ {"MB NV2", (grub_efi_device_path_t *) &devpath_6},
+ {"MBP2011", (grub_efi_device_path_t *) &devpath_7},
+ {"MBP2012", (grub_efi_device_path_t *) &devpath_8},
+ {NULL, NULL},
+};
+
+static grub_err_t
+grub_cmd_appleloader (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_loaded_image_t *loaded_image;
+ struct devdata *pdev;
+
+ grub_dl_ref (my_mod);
+
+ /* Initialize some global variables. */
+ image_handle = 0;
+
+ b = grub_efi_system_table->boot_services;
+
+ for (pdev = devs ; pdev->devpath ; pdev++)
+ if (efi_call_6 (b->load_image, 0, grub_efi_image_handle, pdev->devpath,
+ NULL, 0, &image_handle) == GRUB_EFI_SUCCESS)
+ break;
+
+ if (! pdev->devpath)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "can't find model");
+ goto fail;
+ }
+
+ grub_dprintf ("appleload", "Model: %s\n", pdev->model);
+
+ loaded_image = grub_efi_get_loaded_image (image_handle);
+ if (! loaded_image)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "no loaded image available");
+ goto fail;
+ }
+
+ if (argc > 0)
+ {
+ int i, len;
+ grub_efi_char16_t *p16;
+
+ for (i = 0, len = 0; i < argc; i++)
+ len += grub_strlen (argv[i]) + 1;
+
+ len *= sizeof (grub_efi_char16_t);
+ cmdline = p16 = grub_malloc (len);
+ if (! cmdline)
+ goto fail;
+
+ for (i = 0; i < argc; i++)
+ {
+ char *p8;
+
+ p8 = argv[i];
+ while (*p8)
+ *(p16++) = *(p8++);
+
+ *(p16++) = ' ';
+ }
+ *(--p16) = 0;
+
+ loaded_image->load_options = cmdline;
+ loaded_image->load_options_size = len;
+ }
+
+ grub_loader_set (grub_appleloader_boot, grub_appleloader_unload, 0);
+
+ return 0;
+
+ fail:
+
+ grub_dl_unref (my_mod);
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(appleloader)
+{
+ cmd = grub_register_command ("appleloader", grub_cmd_appleloader,
+ N_("[OPTS]"),
+ /* TRANSLATORS: This command is used on EFI to
+ switch to BIOS mode and boot the OS requiring
+ BIOS. */
+ N_("Boot BIOS-based system."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(appleloader)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
new file mode 100644
index 0000000..2bd80f4
--- /dev/null
+++ b/grub-core/loader/efi/chainloader.c
@@ -0,0 +1,444 @@
+/* chainloader.c - boot another boot loader */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* TODO: support load options. */
+
+#include <grub/loader.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/charset.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/disk.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/net.h>
+#if defined (__i386__) || defined (__x86_64__)
+#include <grub/macho.h>
+#include <grub/i386/macho.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+
+static grub_efi_physical_address_t address;
+static grub_efi_uintn_t pages;
+static grub_efi_device_path_t *file_path;
+static grub_efi_handle_t image_handle;
+static grub_efi_char16_t *cmdline;
+
+static grub_err_t
+grub_chainloader_unload (void)
+{
+ grub_efi_boot_services_t *b;
+
+ b = grub_efi_system_table->boot_services;
+ efi_call_1 (b->unload_image, image_handle);
+ efi_call_2 (b->free_pages, address, pages);
+
+ grub_free (file_path);
+ grub_free (cmdline);
+ cmdline = 0;
+ file_path = 0;
+
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_chainloader_boot (void)
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_status_t status;
+ grub_efi_uintn_t exit_data_size;
+ grub_efi_char16_t *exit_data = NULL;
+
+ b = grub_efi_system_table->boot_services;
+ status = efi_call_3 (b->start_image, image_handle, &exit_data_size, &exit_data);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ if (exit_data)
+ {
+ char *buf;
+
+ buf = grub_malloc (exit_data_size * 4 + 1);
+ if (buf)
+ {
+ *grub_utf16_to_utf8 ((grub_uint8_t *) buf,
+ exit_data, exit_data_size) = 0;
+
+ grub_error (GRUB_ERR_BAD_OS, "%s", buf);
+ grub_free (buf);
+ }
+ }
+ else
+ grub_error (GRUB_ERR_BAD_OS, "unknown error");
+ }
+
+ if (exit_data)
+ efi_call_1 (b->free_pool, exit_data);
+
+ grub_loader_unset ();
+
+ return grub_errno;
+}
+
+static grub_err_t
+copy_file_path (grub_efi_file_path_device_path_t *fp,
+ const char *str, grub_efi_uint16_t len)
+{
+ grub_efi_char16_t *p, *path_name;
+ grub_efi_uint16_t size;
+
+ fp->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE;
+ fp->header.subtype = GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE;
+
+ path_name = grub_calloc (len, GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name));
+ if (!path_name)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed to allocate path buffer");
+
+ size = grub_utf8_to_utf16 (path_name, len * GRUB_MAX_UTF16_PER_UTF8,
+ (const grub_uint8_t *) str, len, 0);
+ for (p = path_name; p < path_name + size; p++)
+ if (*p == '/')
+ *p = '\\';
+
+ grub_memcpy (fp->path_name, path_name, size * sizeof (*fp->path_name));
+ /* File Path is NULL terminated */
+ fp->path_name[size++] = '\0';
+ fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp);
+ grub_free (path_name);
+ return GRUB_ERR_NONE;
+}
+
+static grub_efi_device_path_t *
+make_file_path (grub_efi_device_path_t *dp, const char *filename)
+{
+ char *dir_start;
+ char *dir_end;
+ grub_size_t size;
+ grub_efi_device_path_t *d;
+
+ dir_start = grub_strchr (filename, ')');
+ if (! dir_start)
+ dir_start = (char *) filename;
+ else
+ dir_start++;
+
+ dir_end = grub_strrchr (dir_start, '/');
+ if (! dir_end)
+ {
+ grub_error (GRUB_ERR_BAD_FILENAME, "invalid EFI file path");
+ return 0;
+ }
+
+ size = 0;
+ d = dp;
+ while (d)
+ {
+ grub_size_t len = GRUB_EFI_DEVICE_PATH_LENGTH (d);
+
+ if (len < 4)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "malformed EFI Device Path node has length=%" PRIuGRUB_SIZE, len);
+ return NULL;
+ }
+
+ size += len;
+ if ((GRUB_EFI_END_ENTIRE_DEVICE_PATH (d)))
+ break;
+ d = GRUB_EFI_NEXT_DEVICE_PATH (d);
+ }
+
+ /* File Path is NULL terminated. Allocate space for 2 extra characters */
+ /* FIXME why we split path in two components? */
+ file_path = grub_malloc (size
+ + ((grub_strlen (dir_start) + 2)
+ * GRUB_MAX_UTF16_PER_UTF8
+ * sizeof (grub_efi_char16_t))
+ + sizeof (grub_efi_file_path_device_path_t) * 2);
+ if (! file_path)
+ return 0;
+
+ grub_memcpy (file_path, dp, size);
+
+ /* Fill the file path for the directory. */
+ d = (grub_efi_device_path_t *) ((char *) file_path
+ + ((char *) d - (char *) dp));
+ grub_efi_print_device_path (d);
+ if (copy_file_path ((grub_efi_file_path_device_path_t *) d,
+ dir_start, dir_end - dir_start) != GRUB_ERR_NONE)
+ {
+ fail:
+ grub_free (file_path);
+ return 0;
+ }
+
+ /* Fill the file path for the file. */
+ d = GRUB_EFI_NEXT_DEVICE_PATH (d);
+ if (copy_file_path ((grub_efi_file_path_device_path_t *) d,
+ dir_end + 1, grub_strlen (dir_end + 1)) != GRUB_ERR_NONE)
+ goto fail;
+
+ /* Fill the end of device path nodes. */
+ d = GRUB_EFI_NEXT_DEVICE_PATH (d);
+ d->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
+ d->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ d->length = sizeof (*d);
+
+ return file_path;
+}
+
+static grub_err_t
+grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ grub_ssize_t size;
+ grub_efi_status_t status;
+ grub_efi_boot_services_t *b;
+ grub_device_t dev = 0;
+ grub_efi_device_path_t *dp = 0;
+ grub_efi_loaded_image_t *loaded_image;
+ char *filename;
+ void *boot_image = 0;
+ grub_efi_handle_t dev_handle = 0;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ filename = argv[0];
+
+ grub_dl_ref (my_mod);
+
+ /* Initialize some global variables. */
+ address = 0;
+ image_handle = 0;
+ file_path = 0;
+
+ b = grub_efi_system_table->boot_services;
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE);
+ if (! file)
+ goto fail;
+
+ /* Get the root device's device path. */
+ dev = grub_device_open (0);
+ if (! dev)
+ goto fail;
+
+ if (dev->disk)
+ dev_handle = grub_efidisk_get_device_handle (dev->disk);
+ else if (dev->net && dev->net->server)
+ {
+ grub_net_network_level_address_t addr;
+ struct grub_net_network_level_interface *inf;
+ grub_net_network_level_address_t gateway;
+ grub_err_t err;
+
+ err = grub_net_resolve_address (dev->net->server, &addr);
+ if (err)
+ goto fail;
+
+ err = grub_net_route_address (addr, &gateway, &inf);
+ if (err)
+ goto fail;
+
+ dev_handle = grub_efinet_get_device_handle (inf->card);
+ }
+
+ if (dev_handle)
+ dp = grub_efi_get_device_path (dev_handle);
+
+ if (! dp)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, "not a valid root device");
+ goto fail;
+ }
+
+ file_path = make_file_path (dp, filename);
+ if (! file_path)
+ goto fail;
+
+ grub_printf ("file path: ");
+ grub_efi_print_device_path (file_path);
+
+ size = grub_file_size (file);
+ if (!size)
+ {
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ goto fail;
+ }
+ pages = (((grub_efi_uintn_t) size + ((1 << 12) - 1)) >> 12);
+
+ status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES,
+ GRUB_EFI_LOADER_CODE,
+ pages, &address);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_dprintf ("chain", "Failed to allocate %u pages\n",
+ (unsigned int) pages);
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ goto fail;
+ }
+
+ boot_image = (void *) ((grub_addr_t) address);
+ if (grub_file_read (file, boot_image, size) != size)
+ {
+ if (grub_errno == GRUB_ERR_NONE)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+
+ goto fail;
+ }
+
+#if defined (__i386__) || defined (__x86_64__)
+ if (size >= (grub_ssize_t) sizeof (struct grub_macho_fat_header))
+ {
+ struct grub_macho_fat_header *head = boot_image;
+ if (head->magic
+ == grub_cpu_to_le32_compile_time (GRUB_MACHO_FAT_EFI_MAGIC))
+ {
+ grub_uint32_t i;
+ struct grub_macho_fat_arch *archs
+ = (struct grub_macho_fat_arch *) (head + 1);
+ for (i = 0; i < grub_cpu_to_le32 (head->nfat_arch); i++)
+ {
+ if (GRUB_MACHO_CPUTYPE_IS_HOST_CURRENT (archs[i].cputype))
+ break;
+ }
+ if (i == grub_cpu_to_le32 (head->nfat_arch))
+ {
+ grub_error (GRUB_ERR_BAD_OS, "no compatible arch found");
+ goto fail;
+ }
+ if (grub_cpu_to_le32 (archs[i].offset)
+ > ~grub_cpu_to_le32 (archs[i].size)
+ || grub_cpu_to_le32 (archs[i].offset)
+ + grub_cpu_to_le32 (archs[i].size)
+ > (grub_size_t) size)
+ {
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ goto fail;
+ }
+ boot_image = (char *) boot_image + grub_cpu_to_le32 (archs[i].offset);
+ size = grub_cpu_to_le32 (archs[i].size);
+ }
+ }
+#endif
+
+ status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path,
+ boot_image, size,
+ &image_handle);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ if (status == GRUB_EFI_OUT_OF_RESOURCES)
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources");
+ else
+ grub_error (GRUB_ERR_BAD_OS, "cannot load image");
+
+ goto fail;
+ }
+
+ /* LoadImage does not set a device handler when the image is
+ loaded from memory, so it is necessary to set it explicitly here.
+ This is a mess. */
+ loaded_image = grub_efi_get_loaded_image (image_handle);
+ if (! loaded_image)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "no loaded image available");
+ goto fail;
+ }
+ loaded_image->device_handle = dev_handle;
+
+ if (argc > 1)
+ {
+ int i, len;
+ grub_efi_char16_t *p16;
+
+ for (i = 1, len = 0; i < argc; i++)
+ len += grub_strlen (argv[i]) + 1;
+
+ len *= sizeof (grub_efi_char16_t);
+ cmdline = p16 = grub_malloc (len);
+ if (! cmdline)
+ goto fail;
+
+ for (i = 1; i < argc; i++)
+ {
+ char *p8;
+
+ p8 = argv[i];
+ while (*p8)
+ *(p16++) = *(p8++);
+
+ *(p16++) = ' ';
+ }
+ *(--p16) = 0;
+
+ loaded_image->load_options = cmdline;
+ 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;
+
+ fail:
+
+ if (dev)
+ grub_device_close (dev);
+
+ if (file)
+ grub_file_close (file);
+
+ grub_free (file_path);
+
+ if (address)
+ efi_call_2 (b->free_pages, address, pages);
+
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(chainloader)
+{
+ cmd = grub_register_command ("chainloader", grub_cmd_chainloader,
+ 0, N_("Load another boot loader."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(chainloader)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
new file mode 100644
index 0000000..c86f283
--- /dev/null
+++ b/grub-core/loader/efi/fdt.c
@@ -0,0 +1,179 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/fdt.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/file.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/fdtload.h>
+#include <grub/efi/memory.h>
+#include <grub/cpu/efi/memory.h>
+
+static void *loaded_fdt;
+static void *fdt;
+
+#define FDT_ADDR_CELLS_STRING "#address-cells"
+#define FDT_SIZE_CELLS_STRING "#size-cells"
+#define FDT_ADDR_SIZE_EXTRA ((2 * grub_fdt_prop_entry_size (sizeof(grub_uint32_t))) + \
+ sizeof (FDT_ADDR_CELLS_STRING) + \
+ sizeof (FDT_SIZE_CELLS_STRING))
+
+void *
+grub_fdt_load (grub_size_t additional_size)
+{
+ void *raw_fdt;
+ unsigned int size;
+
+ if (fdt)
+ {
+ size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt));
+ grub_efi_free_pages ((grub_addr_t) fdt, size);
+ }
+
+ if (loaded_fdt)
+ raw_fdt = loaded_fdt;
+ else
+ raw_fdt = grub_efi_get_firmware_fdt();
+
+ if (raw_fdt)
+ size = grub_fdt_get_totalsize (raw_fdt);
+ else
+ size = GRUB_FDT_EMPTY_TREE_SZ + FDT_ADDR_SIZE_EXTRA;
+
+ size += additional_size;
+
+ grub_dprintf ("linux", "allocating %d bytes for fdt\n", size);
+ fdt = grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS,
+ GRUB_EFI_BYTES_TO_PAGES (size),
+ GRUB_EFI_ALLOCATE_MAX_ADDRESS,
+ GRUB_EFI_ACPI_RECLAIM_MEMORY);
+ if (!fdt)
+ return NULL;
+
+ if (raw_fdt)
+ {
+ grub_memmove (fdt, raw_fdt, size - additional_size);
+ grub_fdt_set_totalsize (fdt, size);
+ }
+ else
+ {
+ grub_fdt_create_empty_tree (fdt, size);
+ grub_fdt_set_prop32 (fdt, 0, FDT_ADDR_CELLS_STRING, 2);
+ grub_fdt_set_prop32 (fdt, 0, FDT_SIZE_CELLS_STRING, 2);
+ }
+ return fdt;
+}
+
+grub_err_t
+grub_fdt_install (void)
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
+ grub_efi_status_t status;
+
+ 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_addr_t) fdt,
+ GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)));
+ fdt = NULL;
+}
+
+static grub_err_t
+grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t dtb;
+ void *blob = NULL;
+ int size;
+
+ if (loaded_fdt)
+ grub_free (loaded_fdt);
+ loaded_fdt = NULL;
+
+ /* No arguments means "use firmware FDT". */
+ if (argc == 0)
+ {
+ return GRUB_ERR_NONE;
+ }
+
+ dtb = grub_file_open (argv[0], GRUB_FILE_TYPE_DEVICE_TREE_IMAGE);
+ if (!dtb)
+ goto out;
+
+ size = grub_file_size (dtb);
+ blob = grub_malloc (size);
+ if (!blob)
+ goto out;
+
+ if (grub_file_read (dtb, blob, size) < size)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]);
+ goto out;
+ }
+
+ if (grub_fdt_check_header (blob, size) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree"));
+ goto out;
+ }
+
+out:
+ if (dtb)
+ grub_file_close (dtb);
+
+ if (blob)
+ {
+ if (grub_errno == GRUB_ERR_NONE)
+ loaded_fdt = blob;
+ else
+ grub_free (blob);
+ }
+
+ return grub_errno;
+}
+
+static grub_command_t cmd_devicetree;
+
+GRUB_MOD_INIT (fdt)
+{
+ cmd_devicetree =
+ grub_register_command_lockdown ("devicetree", grub_cmd_devicetree, 0,
+ N_("Load DTB file."));
+}
+
+GRUB_MOD_FINI (fdt)
+{
+ grub_unregister_command (cmd_devicetree);
+}
diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
new file mode 100644
index 0000000..5f3290c
--- /dev/null
+++ b/grub-core/loader/i386/bsd.c
@@ -0,0 +1,2191 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/i386/bsd.h>
+#include <grub/i386/cpuid.h>
+#include <grub/memory.h>
+#include <grub/i386/memory.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/elfload.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/aout.h>
+#include <grub/command.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/ns8250.h>
+#include <grub/bsdlabel.h>
+#include <grub/crypto.h>
+#include <grub/safemath.h>
+#include <grub/verify.h>
+#ifdef GRUB_MACHINE_PCBIOS
+#include <grub/machine/int.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#include <grub/video.h>
+#ifdef GRUB_MACHINE_PCBIOS
+#include <grub/machine/biosnum.h>
+#endif
+#ifdef GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#define NETBSD_DEFAULT_VIDEO_MODE "800x600"
+#else
+#define NETBSD_DEFAULT_VIDEO_MODE "text"
+#include <grub/i386/pc/vbe.h>
+#endif
+#include <grub/video.h>
+
+#include <grub/disk.h>
+#include <grub/device.h>
+#include <grub/partition.h>
+#include <grub/relocator.h>
+#include <grub/i386/relocator.h>
+
+#define ALIGN_DWORD(a) ALIGN_UP (a, 4)
+#define ALIGN_QWORD(a) ALIGN_UP (a, 8)
+#define ALIGN_VAR(a) ((is_64bit) ? (ALIGN_QWORD(a)) : (ALIGN_DWORD(a)))
+#define ALIGN_PAGE(a) ALIGN_UP (a, 4096)
+
+static int kernel_type = KERNEL_TYPE_NONE;
+static grub_dl_t my_mod;
+static grub_addr_t entry, entry_hi, kern_start, kern_end;
+static void *kern_chunk_src;
+static grub_uint32_t bootflags;
+static int is_elf_kernel, is_64bit;
+static grub_uint32_t openbsd_root;
+static struct grub_relocator *relocator = NULL;
+static struct grub_openbsd_ramdisk_descriptor openbsd_ramdisk;
+
+struct bsd_tag
+{
+ struct bsd_tag *next;
+ grub_size_t len;
+ grub_uint32_t type;
+ union {
+ grub_uint8_t a;
+ grub_uint16_t b;
+ grub_uint32_t c;
+ } data[0];
+};
+
+static struct bsd_tag *tags, *tags_last;
+
+struct netbsd_module
+{
+ struct netbsd_module *next;
+ struct grub_netbsd_btinfo_module mod;
+};
+
+static struct netbsd_module *netbsd_mods, *netbsd_mods_last;
+
+static const struct grub_arg_option freebsd_opts[] =
+ {
+ {"dual", 'D', 0, N_("Display output on all consoles."), 0, 0},
+ {"serial", 'h', 0, N_("Use serial console."), 0, 0},
+ {"askname", 'a', 0, N_("Ask for file name to reboot from."), 0, 0},
+ {"cdrom", 'C', 0, N_("Use CD-ROM as root."), 0, 0},
+ {"config", 'c', 0, N_("Invoke user configuration routing."), 0, 0},
+ {"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0},
+ {"gdb", 'g', 0, N_("Use GDB remote debugger instead of DDB."), 0, 0},
+ {"mute", 'm', 0, N_("Disable all boot output."), 0, 0},
+ {"nointr", 'n', 0, "", 0, 0},
+ {"pause", 'p', 0, N_("Wait for keypress after every line of output."), 0, 0},
+ {"quiet", 'q', 0, "", 0, 0},
+ {"dfltroot", 'r', 0, N_("Use compiled-in root device."), 0, 0},
+ {"single", 's', 0, N_("Boot into single mode."), 0, 0},
+ {"verbose", 'v', 0, N_("Boot with verbose messages."), 0, 0},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static const grub_uint32_t freebsd_flags[] =
+{
+ FREEBSD_RB_DUAL, FREEBSD_RB_SERIAL, FREEBSD_RB_ASKNAME,
+ FREEBSD_RB_CDROM, FREEBSD_RB_CONFIG, FREEBSD_RB_KDB,
+ FREEBSD_RB_GDB, FREEBSD_RB_MUTE, FREEBSD_RB_NOINTR,
+ FREEBSD_RB_PAUSE, FREEBSD_RB_QUIET, FREEBSD_RB_DFLTROOT,
+ FREEBSD_RB_SINGLE, FREEBSD_RB_VERBOSE, 0
+};
+
+static const struct grub_arg_option openbsd_opts[] =
+ {
+ {"askname", 'a', 0, N_("Ask for file name to reboot from."), 0, 0},
+ {"halt", 'b', 0, N_("Don't reboot, just halt."), 0, 0},
+ {"config", 'c', 0, N_("Change configured devices."), 0, 0},
+ {"single", 's', 0, N_("Boot into single mode."), 0, 0},
+ {"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0},
+ {"root", 'r', 0, N_("Set root device."), "wdXY", ARG_TYPE_STRING},
+ {"serial", 'h', GRUB_ARG_OPTION_OPTIONAL,
+ N_("Use serial console."),
+ /* TRANSLATORS: "com" is static and not to be translated. It refers to
+ serial ports e.g. com1.
+ */
+ N_("comUNIT[,SPEED]"), ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static const grub_uint32_t openbsd_flags[] =
+{
+ OPENBSD_RB_ASKNAME, OPENBSD_RB_HALT, OPENBSD_RB_CONFIG,
+ OPENBSD_RB_SINGLE, OPENBSD_RB_KDB, 0
+};
+
+#define OPENBSD_ROOT_ARG (ARRAY_SIZE (openbsd_flags) - 1)
+#define OPENBSD_SERIAL_ARG (ARRAY_SIZE (openbsd_flags))
+
+static const struct grub_arg_option netbsd_opts[] =
+ {
+ {"no-smp", '1', 0, N_("Disable SMP."), 0, 0},
+ {"no-acpi", '2', 0, N_("Disable ACPI."), 0, 0},
+ {"askname", 'a', 0, N_("Ask for file name to reboot from."), 0, 0},
+ {"halt", 'b', 0, N_("Don't reboot, just halt."), 0, 0},
+ {"config", 'c', 0, N_("Change configured devices."), 0, 0},
+ {"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0},
+ {"miniroot", 'm', 0, "", 0, 0},
+ {"quiet", 'q', 0, N_("Don't display boot diagnostic messages."), 0, 0},
+ {"single", 's', 0, N_("Boot into single mode."), 0, 0},
+ {"verbose", 'v', 0, N_("Boot with verbose messages."), 0, 0},
+ {"debug", 'x', 0, N_("Boot with debug messages."), 0, 0},
+ {"silent", 'z', 0, N_("Suppress normal output (warnings remain)."), 0, 0},
+ {"root", 'r', 0, N_("Set root device."), N_("DEVICE"), ARG_TYPE_STRING},
+ {"serial", 'h', GRUB_ARG_OPTION_OPTIONAL,
+ N_("Use serial console."),
+ /* TRANSLATORS: "com" is static and not to be translated. It refers to
+ serial ports e.g. com1.
+ */
+ N_("[ADDR|comUNIT][,SPEED]"), ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static const grub_uint32_t netbsd_flags[] =
+{
+ NETBSD_AB_NOSMP, NETBSD_AB_NOACPI, NETBSD_RB_ASKNAME,
+ NETBSD_RB_HALT, NETBSD_RB_USERCONFIG, NETBSD_RB_KDB,
+ NETBSD_RB_MINIROOT, NETBSD_AB_QUIET, NETBSD_RB_SINGLE,
+ NETBSD_AB_VERBOSE, NETBSD_AB_DEBUG, NETBSD_AB_SILENT, 0
+};
+
+#define NETBSD_ROOT_ARG (ARRAY_SIZE (netbsd_flags) - 1)
+#define NETBSD_SERIAL_ARG (ARRAY_SIZE (netbsd_flags))
+
+static void
+grub_bsd_get_device (grub_uint32_t * biosdev,
+ grub_uint32_t * unit,
+ grub_uint32_t * slice, grub_uint32_t * part)
+{
+ grub_device_t dev;
+
+#ifdef GRUB_MACHINE_PCBIOS
+ *biosdev = grub_get_root_biosnumber () & 0xff;
+#else
+ *biosdev = 0xff;
+#endif
+ *unit = (*biosdev & 0x7f);
+ *slice = 0xff;
+ *part = 0xff;
+ dev = grub_device_open (0);
+ if (dev && dev->disk && dev->disk->partition)
+ {
+ if (dev->disk->partition->parent)
+ {
+ *part = dev->disk->partition->number;
+ *slice = dev->disk->partition->parent->number + 1;
+ }
+ else
+ *slice = dev->disk->partition->number + 1;
+ }
+ if (dev)
+ grub_device_close (dev);
+}
+
+static grub_err_t
+grub_bsd_add_meta_ptr (grub_uint32_t type, void **ptr, grub_uint32_t len)
+{
+ struct bsd_tag *newtag;
+
+ newtag = grub_malloc (len + sizeof (struct bsd_tag));
+ if (!newtag)
+ return grub_errno;
+ newtag->len = len;
+ newtag->type = type;
+ newtag->next = NULL;
+ *ptr = newtag->data;
+
+ if (kernel_type == KERNEL_TYPE_FREEBSD
+ && type == (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_SMAP))
+ {
+ struct bsd_tag *p;
+ for (p = tags;
+ p && p->type != (FREEBSD_MODINFO_METADATA
+ | FREEBSD_MODINFOMD_KERNEND);
+ p = p->next);
+
+ if (p)
+ {
+ newtag->next = p->next;
+ p->next = newtag;
+ if (newtag->next == NULL)
+ tags_last = newtag;
+ return GRUB_ERR_NONE;
+ }
+ }
+
+ if (tags_last)
+ tags_last->next = newtag;
+ else
+ tags = newtag;
+ tags_last = newtag;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_bsd_add_meta (grub_uint32_t type, const void *data, grub_uint32_t len)
+{
+ grub_err_t err;
+ void *ptr;
+
+ err = grub_bsd_add_meta_ptr (type, &ptr, len);
+ if (err)
+ return err;
+ if (len)
+ grub_memcpy (ptr, data, len);
+ return GRUB_ERR_NONE;
+}
+
+
+struct grub_e820_mmap
+{
+ grub_uint64_t addr;
+ grub_uint64_t size;
+ grub_uint32_t type;
+} GRUB_PACKED;
+#define GRUB_E820_RAM 1
+#define GRUB_E820_RESERVED 2
+#define GRUB_E820_ACPI 3
+#define GRUB_E820_NVS 4
+#define GRUB_E820_BADRAM 5
+#define GRUB_E820_COREBOOT_TABLES 0x10
+
+/* Context for generate_e820_mmap. */
+struct generate_e820_mmap_ctx
+{
+ int count;
+ struct grub_e820_mmap *mmap;
+ struct grub_e820_mmap prev, cur;
+};
+
+/* Helper for generate_e820_mmap. */
+static int
+generate_e820_mmap_iter (grub_uint64_t addr, grub_uint64_t size,
+ grub_memory_type_t type, void *data)
+{
+ struct generate_e820_mmap_ctx *ctx = data;
+
+ ctx->cur.addr = addr;
+ ctx->cur.size = size;
+
+ if (type == GRUB_MEMORY_COREBOOT_TABLES
+ && addr == 0)
+ /* Nowadays the tables at 0 don't contain anything important but
+ *BSD needs the memory at 0 for own needs.
+ */
+ type = GRUB_E820_RAM;
+
+ ctx->cur.type = type;
+
+ /* Merge regions if possible. */
+ if (ctx->count && ctx->cur.type == ctx->prev.type
+ && ctx->cur.addr == ctx->prev.addr + ctx->prev.size)
+ {
+ ctx->prev.size += ctx->cur.size;
+ if (ctx->mmap)
+ ctx->mmap[-1] = ctx->prev;
+ }
+ else
+ {
+ if (ctx->mmap)
+ *ctx->mmap++ = ctx->cur;
+ ctx->prev = ctx->cur;
+ ctx->count++;
+ }
+
+ if (kernel_type == KERNEL_TYPE_OPENBSD && ctx->prev.addr < 0x100000
+ && ctx->prev.addr + ctx->prev.size > 0x100000)
+ {
+ ctx->cur.addr = 0x100000;
+ ctx->cur.size = ctx->prev.addr + ctx->prev.size - 0x100000;
+ ctx->cur.type = ctx->prev.type;
+ ctx->prev.size = 0x100000 - ctx->prev.addr;
+ if (ctx->mmap)
+ {
+ ctx->mmap[-1] = ctx->prev;
+ ctx->mmap[0] = ctx->cur;
+ ctx->mmap++;
+ }
+ ctx->prev = ctx->cur;
+ ctx->count++;
+ }
+
+ return 0;
+}
+
+static void
+generate_e820_mmap (grub_size_t *len, grub_size_t *cnt, void *buf)
+{
+ struct generate_e820_mmap_ctx ctx = {
+ .count = 0,
+ .mmap = buf
+ };
+
+ grub_mmap_iterate (generate_e820_mmap_iter, &ctx);
+
+ if (len)
+ *len = ctx.count * sizeof (struct grub_e820_mmap);
+ *cnt = ctx.count;
+
+ return;
+}
+
+static grub_err_t
+grub_bsd_add_mmap (void)
+{
+ grub_size_t len, cnt;
+ void *buf = NULL, *buf0;
+
+ generate_e820_mmap (&len, &cnt, buf);
+
+ if (kernel_type == KERNEL_TYPE_NETBSD)
+ len += sizeof (grub_uint32_t);
+
+ if (kernel_type == KERNEL_TYPE_OPENBSD)
+ len += sizeof (struct grub_e820_mmap);
+
+ buf = grub_malloc (len);
+ if (!buf)
+ return grub_errno;
+
+ buf0 = buf;
+ if (kernel_type == KERNEL_TYPE_NETBSD)
+ {
+ *(grub_uint32_t *) buf = cnt;
+ buf = ((grub_uint32_t *) buf + 1);
+ }
+
+ generate_e820_mmap (NULL, &cnt, buf);
+
+ if (kernel_type == KERNEL_TYPE_OPENBSD)
+ grub_memset ((grub_uint8_t *) buf + len - sizeof (struct grub_e820_mmap), 0,
+ sizeof (struct grub_e820_mmap));
+
+ grub_dprintf ("bsd", "%u entries in smap\n", (unsigned) cnt);
+ if (kernel_type == KERNEL_TYPE_NETBSD)
+ grub_bsd_add_meta (NETBSD_BTINFO_MEMMAP, buf0, len);
+ else if (kernel_type == KERNEL_TYPE_OPENBSD)
+ grub_bsd_add_meta (OPENBSD_BOOTARG_MMAP, buf0, len);
+ else
+ grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_SMAP, buf0, len);
+
+ grub_free (buf0);
+
+ return grub_errno;
+}
+
+grub_err_t
+grub_freebsd_add_meta_module (const char *filename, const char *type,
+ int argc, char **argv,
+ grub_addr_t addr, grub_uint32_t size)
+{
+ const char *name;
+ grub_err_t err;
+
+ name = grub_strrchr (filename, '/');
+ if (name)
+ name++;
+ else
+ name = filename;
+ if (grub_strcmp (type, "/boot/zfs/zpool.cache") == 0)
+ name = "/boot/zfs/zpool.cache";
+
+ if (grub_bsd_add_meta (FREEBSD_MODINFO_NAME, name, grub_strlen (name) + 1))
+ return grub_errno;
+
+ if (is_64bit)
+ {
+ grub_uint64_t addr64 = addr, size64 = size;
+ if (grub_bsd_add_meta (FREEBSD_MODINFO_TYPE, type, grub_strlen (type) + 1)
+ || grub_bsd_add_meta (FREEBSD_MODINFO_ADDR, &addr64, sizeof (addr64))
+ || grub_bsd_add_meta (FREEBSD_MODINFO_SIZE, &size64, sizeof (size64)))
+ return grub_errno;
+ }
+ else
+ {
+ if (grub_bsd_add_meta (FREEBSD_MODINFO_TYPE, type, grub_strlen (type) + 1)
+ || grub_bsd_add_meta (FREEBSD_MODINFO_ADDR, &addr, sizeof (addr))
+ || grub_bsd_add_meta (FREEBSD_MODINFO_SIZE, &size, sizeof (size)))
+ return grub_errno;
+ }
+
+ if (argc)
+ {
+ int i, n;
+
+ n = 0;
+ for (i = 0; i < argc; i++)
+ {
+ n += grub_strlen (argv[i]) + 1;
+ }
+
+ if (n)
+ {
+ void *cmdline;
+ char *p;
+
+ if (grub_bsd_add_meta_ptr (FREEBSD_MODINFO_ARGS, &cmdline, n))
+ return grub_errno;
+
+ p = cmdline;
+ for (i = 0; i < argc; i++)
+ {
+ grub_strcpy (p, argv[i]);
+ p += grub_strlen (argv[i]);
+ *(p++) = ' ';
+ }
+ *p = 0;
+ err = grub_verify_string (cmdline, GRUB_VERIFY_MODULE_CMDLINE);
+ if (err)
+ return err;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_freebsd_list_modules (void)
+{
+ struct bsd_tag *tag;
+
+ grub_printf (" %-18s %-18s%14s%14s\n", _("name"), _("type"), _("addr"),
+ _("size"));
+
+ for (tag = tags; tag; tag = tag->next)
+ {
+ switch (tag->type)
+ {
+ case FREEBSD_MODINFO_NAME:
+ case FREEBSD_MODINFO_TYPE:
+ grub_printf (" %-18s", (char *) tag->data);
+ break;
+ case FREEBSD_MODINFO_ADDR:
+ {
+ grub_uint32_t addr;
+
+ addr = *((grub_uint32_t *) tag->data);
+ grub_printf (" 0x%08x", addr);
+ break;
+ }
+ case FREEBSD_MODINFO_SIZE:
+ {
+ grub_uint32_t len;
+
+ len = *((grub_uint32_t *) tag->data);
+ grub_printf (" 0x%08x\n", len);
+ }
+ }
+ }
+}
+
+static grub_err_t
+grub_netbsd_add_meta_module (char *filename, grub_uint32_t type,
+ grub_addr_t addr, grub_uint32_t size)
+{
+ char *name;
+ struct netbsd_module *mod;
+ name = grub_strrchr (filename, '/');
+
+ if (name)
+ name++;
+ else
+ name = filename;
+
+ mod = grub_zalloc (sizeof (*mod));
+ if (!mod)
+ return grub_errno;
+
+ grub_strncpy (mod->mod.name, name, sizeof (mod->mod.name) - 1);
+ mod->mod.addr = addr;
+ mod->mod.type = type;
+ mod->mod.size = size;
+
+ if (netbsd_mods_last)
+ netbsd_mods_last->next = mod;
+ else
+ netbsd_mods = mod;
+ netbsd_mods_last = mod;
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_netbsd_list_modules (void)
+{
+ struct netbsd_module *mod;
+
+ grub_printf (" %-18s%14s%14s%14s\n", _("name"), _("type"), _("addr"),
+ _("size"));
+
+ for (mod = netbsd_mods; mod; mod = mod->next)
+ grub_printf (" %-18s 0x%08x 0x%08x 0x%08x", mod->mod.name,
+ mod->mod.type, mod->mod.addr, mod->mod.size);
+}
+
+/* This function would be here but it's under different license. */
+#include "bsd_pagetable.c"
+
+static grub_uint32_t freebsd_bootdev, freebsd_biosdev;
+static grub_uint64_t freebsd_zfsguid;
+
+static void
+freebsd_get_zfs (void)
+{
+ grub_device_t dev;
+ grub_fs_t fs;
+ char *uuid;
+ grub_err_t err;
+
+ dev = grub_device_open (0);
+ if (!dev)
+ return;
+ fs = grub_fs_probe (dev);
+ if (!fs)
+ return;
+ if (!fs->fs_uuid || grub_strcmp (fs->name, "zfs") != 0)
+ return;
+ err = fs->fs_uuid (dev, &uuid);
+ if (err)
+ return;
+ if (!uuid)
+ return;
+ freebsd_zfsguid = grub_strtoull (uuid, 0, 16);
+ grub_free (uuid);
+}
+
+static grub_err_t
+grub_freebsd_boot (void)
+{
+ struct grub_freebsd_bootinfo bi;
+ grub_uint8_t *p, *p0;
+ grub_addr_t p_target;
+ grub_size_t p_size = 0;
+ grub_err_t err;
+ grub_size_t tag_buf_len = 0;
+
+ struct grub_env_var *var;
+
+ grub_memset (&bi, 0, sizeof (bi));
+ bi.version = FREEBSD_BOOTINFO_VERSION;
+ bi.length = sizeof (bi);
+
+ bi.boot_device = freebsd_biosdev;
+
+ p_size = 0;
+ FOR_SORTED_ENV (var)
+ if ((grub_memcmp (var->name, "kFreeBSD.", sizeof("kFreeBSD.") - 1) == 0) && (var->name[sizeof("kFreeBSD.") - 1]))
+ {
+ p_size += grub_strlen (&var->name[sizeof("kFreeBSD.") - 1]);
+ p_size++;
+ p_size += grub_strlen (var->value) + 1;
+ }
+
+ if (p_size)
+ p_size = ALIGN_PAGE (kern_end + p_size + 1) - kern_end;
+
+ if (is_elf_kernel)
+ {
+ struct bsd_tag *tag;
+
+ err = grub_bsd_add_mmap ();
+ if (err)
+ return err;
+
+ err = grub_bsd_add_meta (FREEBSD_MODINFO_END, 0, 0);
+ if (err)
+ return err;
+
+ tag_buf_len = 0;
+ for (tag = tags; tag; tag = tag->next)
+ tag_buf_len = ALIGN_VAR (tag_buf_len
+ + sizeof (struct freebsd_tag_header)
+ + tag->len);
+ p_size = ALIGN_PAGE (kern_end + p_size + tag_buf_len) - kern_end;
+ }
+
+ if (is_64bit)
+ p_size += 4096 * 3;
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ kern_end, p_size);
+ if (err)
+ return err;
+ p = get_virtual_current_address (ch);
+ }
+ p_target = kern_end;
+ p0 = p;
+ kern_end += p_size;
+
+ FOR_SORTED_ENV (var)
+ if ((grub_memcmp (var->name, "kFreeBSD.", sizeof("kFreeBSD.") - 1) == 0) && (var->name[sizeof("kFreeBSD.") - 1]))
+ {
+ grub_strcpy ((char *) p, &var->name[sizeof("kFreeBSD.") - 1]);
+ p += grub_strlen ((char *) p);
+ *(p++) = '=';
+ grub_strcpy ((char *) p, var->value);
+ p += grub_strlen ((char *) p) + 1;
+ }
+
+ if (p != p0)
+ {
+ *(p++) = 0;
+
+ bi.environment = p_target;
+ }
+
+ if (is_elf_kernel)
+ {
+ grub_uint8_t *p_tag = p;
+ struct bsd_tag *tag;
+
+ for (tag = tags; tag; tag = tag->next)
+ {
+ struct freebsd_tag_header *head
+ = (struct freebsd_tag_header *) p_tag;
+ head->type = tag->type;
+ head->len = tag->len;
+ p_tag += sizeof (struct freebsd_tag_header);
+ switch (tag->type)
+ {
+ case FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_HOWTO:
+ if (is_64bit)
+ *(grub_uint64_t *) p_tag = bootflags;
+ else
+ *(grub_uint32_t *) p_tag = bootflags;
+ break;
+
+ case FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_ENVP:
+ if (is_64bit)
+ *(grub_uint64_t *) p_tag = bi.environment;
+ else
+ *(grub_uint32_t *) p_tag = bi.environment;
+ break;
+
+ case FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_KERNEND:
+ if (is_64bit)
+ *(grub_uint64_t *) p_tag = kern_end;
+ else
+ *(grub_uint32_t *) p_tag = kern_end;
+ break;
+
+ default:
+ grub_memcpy (p_tag, tag->data, tag->len);
+ break;
+ }
+ p_tag += tag->len;
+ p_tag = ALIGN_VAR (p_tag - p) + p;
+ }
+
+ bi.tags = (p - p0) + p_target;
+
+ p = (ALIGN_PAGE ((p_tag - p0) + p_target) - p_target) + p0;
+ }
+
+ bi.kern_end = kern_end;
+
+ grub_video_set_mode ("text", 0, 0);
+
+ if (is_64bit)
+ {
+ struct grub_relocator64_state state;
+ grub_uint8_t *pagetable;
+ grub_uint32_t *stack;
+ grub_addr_t stack_target;
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_align (relocator, &ch,
+ 0x10000, 0x90000,
+ 3 * sizeof (grub_uint32_t)
+ + sizeof (bi), 4,
+ GRUB_RELOCATOR_PREFERENCE_NONE,
+ 0);
+ if (err)
+ return err;
+ stack = get_virtual_current_address (ch);
+ stack_target = get_physical_target_address (ch);
+ }
+
+#ifdef GRUB_MACHINE_EFI
+ err = grub_efi_finish_boot_services (NULL, NULL, NULL, NULL, NULL);
+ if (err)
+ return err;
+#endif
+
+ pagetable = p;
+ fill_bsd64_pagetable (pagetable, (pagetable - p0) + p_target);
+
+ state.cr3 = (pagetable - p0) + p_target;
+ state.rsp = stack_target;
+ state.rip = (((grub_uint64_t) entry_hi) << 32) | entry;
+
+ stack[0] = entry;
+ stack[1] = bi.tags;
+ stack[2] = kern_end;
+ return grub_relocator64_boot (relocator, state, 0, 0x40000000);
+ }
+ else
+ {
+ struct grub_relocator32_state state;
+ grub_uint32_t *stack;
+ grub_addr_t stack_target;
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_align (relocator, &ch,
+ 0x10000, 0x90000,
+ 9 * sizeof (grub_uint32_t)
+ + sizeof (bi), 4,
+ GRUB_RELOCATOR_PREFERENCE_NONE,
+ 0);
+ if (err)
+ return err;
+ stack = get_virtual_current_address (ch);
+ stack_target = get_physical_target_address (ch);
+ }
+
+#ifdef GRUB_MACHINE_EFI
+ err = grub_efi_finish_boot_services (NULL, NULL, NULL, NULL, NULL);
+ if (err)
+ return err;
+#endif
+
+ grub_memcpy (&stack[9], &bi, sizeof (bi));
+ state.eip = entry;
+ state.esp = stack_target;
+ state.ebp = stack_target;
+ stack[0] = entry; /* "Return" address. */
+ stack[1] = bootflags | FREEBSD_RB_BOOTINFO;
+ stack[2] = freebsd_bootdev;
+ stack[3] = freebsd_zfsguid ? 4 : 0;
+ stack[4] = freebsd_zfsguid;
+ stack[5] = freebsd_zfsguid >> 32;
+ stack[6] = stack_target + 9 * sizeof (grub_uint32_t);
+ stack[7] = bi.tags;
+ stack[8] = kern_end;
+ return grub_relocator32_boot (relocator, state, 0);
+ }
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_openbsd_boot (void)
+{
+ grub_uint32_t *stack;
+ struct grub_relocator32_state state;
+ void *curarg, *buf0, *arg0;
+ grub_addr_t buf_target;
+ grub_err_t err;
+ grub_size_t tag_buf_len;
+
+ err = grub_bsd_add_mmap ();
+ if (err)
+ return err;
+
+#ifdef GRUB_MACHINE_PCBIOS
+ {
+ struct grub_bios_int_registers regs;
+
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+
+ regs.ebx = 0;
+ regs.ecx = 0;
+ regs.eax = 0xb101;
+ regs.es = 0;
+ regs.edi = 0;
+ regs.edx = 0;
+
+ grub_bios_interrupt (0x1a, &regs);
+ if (regs.edx == 0x20494350)
+ {
+ struct grub_openbsd_bootarg_pcibios pcibios;
+
+ pcibios.characteristics = regs.eax & 0xff;
+ pcibios.revision = regs.ebx & 0xffff;
+ pcibios.pm_entry = regs.edi;
+ pcibios.last_bus = regs.ecx & 0xff;
+
+ grub_bsd_add_meta (OPENBSD_BOOTARG_PCIBIOS, &pcibios,
+ sizeof (pcibios));
+ }
+ }
+#endif
+
+ {
+ struct bsd_tag *tag;
+ tag_buf_len = 0;
+ for (tag = tags; tag; tag = tag->next)
+ tag_buf_len = ALIGN_VAR (tag_buf_len
+ + sizeof (struct grub_openbsd_bootargs)
+ + tag->len);
+ }
+
+ buf_target = GRUB_BSD_TEMP_BUFFER - 9 * sizeof (grub_uint32_t);
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch, buf_target,
+ tag_buf_len
+ + sizeof (struct grub_openbsd_bootargs)
+ + 9 * sizeof (grub_uint32_t));
+ if (err)
+ return err;
+ buf0 = get_virtual_current_address (ch);
+ }
+
+ stack = (grub_uint32_t *) buf0;
+ arg0 = curarg = stack + 9;
+
+ {
+ struct bsd_tag *tag;
+ struct grub_openbsd_bootargs *head;
+
+ for (tag = tags; tag; tag = tag->next)
+ {
+ head = curarg;
+ head->ba_type = tag->type;
+ head->ba_size = tag->len + sizeof (*head);
+ curarg = head + 1;
+ grub_memcpy (curarg, tag->data, tag->len);
+ curarg = (grub_uint8_t *) curarg + tag->len;
+ head->ba_next = (grub_uint8_t *) curarg - (grub_uint8_t *) buf0
+ + buf_target;
+ }
+ head = curarg;
+ head->ba_type = OPENBSD_BOOTARG_END;
+ head->ba_size = 0;
+ head->ba_next = 0;
+ }
+
+ grub_video_set_mode ("text", 0, 0);
+
+#ifdef GRUB_MACHINE_EFI
+ err = grub_efi_finish_boot_services (NULL, NULL, NULL, NULL, NULL);
+ if (err)
+ return err;
+#endif
+
+ state.eip = entry;
+ state.ebp = state.esp
+ = ((grub_uint8_t *) stack - (grub_uint8_t *) buf0) + buf_target;
+ stack[0] = entry;
+ stack[1] = bootflags;
+ stack[2] = openbsd_root;
+ stack[3] = OPENBSD_BOOTARG_APIVER;
+ stack[4] = 0;
+ stack[5] = grub_mmap_get_upper () >> 10;
+ stack[6] = grub_mmap_get_lower () >> 10;
+ stack[7] = (grub_uint8_t *) curarg - (grub_uint8_t *) arg0;
+ stack[8] = ((grub_uint8_t *) arg0 - (grub_uint8_t *) buf0) + buf_target;
+
+ return grub_relocator32_boot (relocator, state, 0);
+}
+
+static grub_err_t
+grub_netbsd_setup_video (void)
+{
+ struct grub_video_mode_info mode_info;
+ void *framebuffer;
+ const char *modevar;
+ struct grub_netbsd_btinfo_framebuf params;
+ grub_err_t err;
+ grub_video_driver_id_t driv_id;
+
+ modevar = grub_env_get ("gfxpayload");
+
+ /* Now all graphical modes are acceptable.
+ May change in future if we have modes without framebuffer. */
+ if (modevar && *modevar != 0)
+ {
+ char *tmp;
+ tmp = grub_xasprintf ("%s;" NETBSD_DEFAULT_VIDEO_MODE, modevar);
+ if (! tmp)
+ return grub_errno;
+ err = grub_video_set_mode (tmp, 0, 0);
+ grub_free (tmp);
+ }
+ else
+ err = grub_video_set_mode (NETBSD_DEFAULT_VIDEO_MODE, 0, 0);
+
+ if (err)
+ return err;
+
+ driv_id = grub_video_get_driver_id ();
+ if (driv_id == GRUB_VIDEO_DRIVER_NONE)
+ return GRUB_ERR_NONE;
+
+ err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
+
+ if (err)
+ return err;
+
+ params.width = mode_info.width;
+ params.height = mode_info.height;
+ params.bpp = mode_info.bpp;
+ params.pitch = mode_info.pitch;
+ params.flags = 0;
+
+ params.fbaddr = (grub_addr_t) framebuffer;
+
+ params.red_mask_size = mode_info.red_mask_size;
+ params.red_field_pos = mode_info.red_field_pos;
+ params.green_mask_size = mode_info.green_mask_size;
+ params.green_field_pos = mode_info.green_field_pos;
+ params.blue_mask_size = mode_info.blue_mask_size;
+ params.blue_field_pos = mode_info.blue_field_pos;
+
+#ifdef GRUB_MACHINE_PCBIOS
+ /* VESA packed modes may come with zeroed mask sizes, which need
+ to be set here according to DAC Palette width. If we don't,
+ this results in Linux displaying a black screen. */
+ if (mode_info.bpp <= 8 && driv_id == GRUB_VIDEO_DRIVER_VBE)
+ {
+ struct grub_vbe_info_block controller_info;
+ int status;
+ int width = 8;
+
+ status = grub_vbe_bios_get_controller_info (&controller_info);
+
+ if (status == GRUB_VBE_STATUS_OK &&
+ (controller_info.capabilities & GRUB_VBE_CAPABILITY_DACWIDTH))
+ status = grub_vbe_bios_set_dac_palette_width (&width);
+
+ if (status != GRUB_VBE_STATUS_OK)
+ /* 6 is default after mode reset. */
+ width = 6;
+
+ params.red_mask_size = params.green_mask_size
+ = params.blue_mask_size = width;
+ }
+#endif
+
+ err = grub_bsd_add_meta (NETBSD_BTINFO_FRAMEBUF, &params, sizeof (params));
+ return err;
+}
+
+static grub_err_t
+grub_netbsd_add_modules (void)
+{
+ struct netbsd_module *mod;
+ unsigned modcnt = 0;
+ struct grub_netbsd_btinfo_modules *mods;
+ unsigned i;
+ grub_err_t err;
+ grub_size_t sz;
+
+ for (mod = netbsd_mods; mod; mod = mod->next)
+ modcnt++;
+
+ if (grub_mul (modcnt, sizeof (mods->mods[0]), &sz) ||
+ grub_add (sz, sizeof (*mods), &sz))
+ return GRUB_ERR_OUT_OF_RANGE;
+
+ mods = grub_malloc (sz);
+ if (!mods)
+ return grub_errno;
+
+ mods->num = modcnt;
+ mods->last_addr = kern_end;
+ for (mod = netbsd_mods, i = 0; mod; i++, mod = mod->next)
+ mods->mods[i] = mod->mod;
+
+ err = grub_bsd_add_meta (NETBSD_BTINFO_MODULES, mods,
+ sizeof (*mods) + sizeof (mods->mods[0]) * modcnt);
+ grub_free (mods);
+ return err;
+}
+
+/*
+ * Adds NetBSD bootinfo bootdisk and bootwedge. The partition identified
+ * in these bootinfo fields is the root device.
+ */
+static void
+grub_netbsd_add_boot_disk_and_wedge (void)
+{
+ grub_device_t dev;
+ grub_disk_t disk;
+ grub_partition_t part;
+ grub_uint32_t biosdev;
+ grub_uint32_t partmapsector;
+ union {
+ grub_uint64_t raw[GRUB_DISK_SECTOR_SIZE / 8];
+ struct grub_partition_bsd_disk_label label;
+ } buf;
+
+ if (GRUB_MD_MD5->mdlen > GRUB_CRYPTO_MAX_MDLEN)
+ {
+ grub_error (GRUB_ERR_BUG, "mdlen too long");
+ return;
+ }
+
+ dev = grub_device_open (0);
+ if (! (dev && dev->disk && dev->disk->partition))
+ goto fail;
+
+ disk = dev->disk;
+ part = disk->partition;
+
+ if (disk->dev && disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID)
+ biosdev = (grub_uint32_t) disk->id & 0xff;
+ else
+ biosdev = 0xff;
+
+ /* Absolute sector of the partition map describing this partition. */
+ partmapsector = grub_partition_get_start (part->parent) + part->offset;
+
+ disk->partition = part->parent;
+ if (grub_disk_read (disk, part->offset, 0, GRUB_DISK_SECTOR_SIZE, buf.raw)
+ != GRUB_ERR_NONE)
+ goto fail;
+ disk->partition = part;
+
+ /* Fill bootwedge. */
+ {
+ struct grub_netbsd_btinfo_bootwedge biw;
+ grub_uint8_t hash[GRUB_CRYPTO_MAX_MDLEN];
+
+ grub_memset (&biw, 0, sizeof (biw));
+ biw.biosdev = biosdev;
+ biw.startblk = grub_partition_get_start (part);
+ biw.nblks = part->len;
+ biw.matchblk = partmapsector;
+ biw.matchnblks = 1;
+
+ grub_crypto_hash (GRUB_MD_MD5, hash,
+ buf.raw, GRUB_DISK_SECTOR_SIZE);
+ grub_memcpy (biw.matchhash, hash, 16);
+
+ grub_bsd_add_meta (NETBSD_BTINFO_BOOTWEDGE, &biw, sizeof (biw));
+ }
+
+ /* Fill bootdisk. */
+ {
+ struct grub_netbsd_btinfo_bootdisk bid;
+
+ grub_memset (&bid, 0, sizeof (bid));
+ /* Check for a NetBSD disk label. */
+ if (part->partmap != NULL &&
+ (grub_strcmp (part->partmap->name, "netbsd") == 0 ||
+ (part->parent == NULL && grub_strcmp (part->partmap->name, "bsd") == 0)))
+ {
+ bid.labelsector = partmapsector;
+ bid.label.type = buf.label.type;
+ bid.label.checksum = buf.label.checksum;
+ grub_memcpy (bid.label.packname, buf.label.packname, 16);
+ }
+ else
+ {
+ bid.labelsector = -1;
+ }
+ bid.biosdev = biosdev;
+ bid.partition = part->number;
+
+ grub_bsd_add_meta (NETBSD_BTINFO_BOOTDISK, &bid, sizeof (bid));
+ }
+
+fail:
+ if (dev)
+ grub_device_close (dev);
+}
+
+static grub_err_t
+grub_netbsd_boot (void)
+{
+ struct grub_netbsd_bootinfo *bootinfo;
+ void *curarg, *arg0;
+ grub_addr_t arg_target, stack_target;
+ grub_uint32_t *stack;
+ grub_err_t err;
+ struct grub_relocator32_state state;
+ grub_size_t tag_buf_len = 0;
+ int tag_count = 0;
+
+ err = grub_bsd_add_mmap ();
+ if (err)
+ return err;
+
+ err = grub_netbsd_setup_video ();
+ if (err)
+ {
+ grub_print_error ();
+ grub_puts_ (N_("Booting in blind mode"));
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ err = grub_netbsd_add_modules ();
+ 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;
+ for (tag = tags; tag; tag = tag->next)
+ {
+ tag_buf_len = ALIGN_VAR (tag_buf_len
+ + sizeof (struct grub_netbsd_btinfo_common)
+ + tag->len);
+ tag_count++;
+ }
+ }
+
+ arg_target = kern_end;
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ arg_target, tag_buf_len
+ + sizeof (struct grub_netbsd_bootinfo)
+ + tag_count * sizeof (grub_uint32_t));
+ if (err)
+ return err;
+ curarg = get_virtual_current_address (ch);
+ }
+
+ arg0 = curarg;
+ bootinfo = (void *) ((grub_uint8_t *) arg0 + tag_buf_len);
+
+ {
+ struct bsd_tag *tag;
+ unsigned i;
+
+ bootinfo->bi_count = tag_count;
+ for (tag = tags, i = 0; tag; i++, tag = tag->next)
+ {
+ struct grub_netbsd_btinfo_common *head = curarg;
+ bootinfo->bi_data[i] = ((grub_uint8_t *) curarg - (grub_uint8_t *) arg0)
+ + arg_target;
+ head->type = tag->type;
+ head->len = tag->len + sizeof (*head);
+ curarg = head + 1;
+ grub_memcpy (curarg, tag->data, tag->len);
+ curarg = (grub_uint8_t *) curarg + tag->len;
+ }
+ }
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x10000, 0x90000,
+ 7 * sizeof (grub_uint32_t), 4,
+ GRUB_RELOCATOR_PREFERENCE_NONE,
+ 0);
+ if (err)
+ return err;
+ stack = get_virtual_current_address (ch);
+ stack_target = get_physical_target_address (ch);
+ }
+
+#ifdef GRUB_MACHINE_EFI
+ err = grub_efi_finish_boot_services (NULL, NULL, NULL, NULL, NULL);
+ if (err)
+ return err;
+#endif
+
+ state.eip = entry;
+ state.esp = stack_target;
+ state.ebp = stack_target;
+ stack[0] = entry;
+ stack[1] = bootflags;
+ stack[2] = 0;
+ stack[3] = ((grub_uint8_t *) bootinfo - (grub_uint8_t *) arg0) + arg_target;
+ stack[4] = 0;
+ stack[5] = grub_mmap_get_upper () >> 10;
+ stack[6] = grub_mmap_get_lower () >> 10;
+
+ return grub_relocator32_boot (relocator, state, 0);
+}
+
+static grub_err_t
+grub_bsd_unload (void)
+{
+ struct bsd_tag *tag, *next;
+ for (tag = tags; tag; tag = next)
+ {
+ next = tag->next;
+ grub_free (tag);
+ }
+ tags = NULL;
+ tags_last = NULL;
+
+ kernel_type = KERNEL_TYPE_NONE;
+ grub_dl_unref (my_mod);
+
+ grub_relocator_unload (relocator);
+ relocator = NULL;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_bsd_load_aout (grub_file_t file, const char *filename)
+{
+ grub_addr_t load_addr, load_end;
+ int ofs, align_page;
+ union grub_aout_header ah;
+ grub_err_t err;
+ grub_size_t bss_size;
+
+ if ((grub_file_seek (file, 0)) == (grub_off_t) - 1)
+ return grub_errno;
+
+ if (grub_file_read (file, &ah, sizeof (ah)) != sizeof (ah))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_READ_ERROR, N_("premature end of file %s"),
+ filename);
+ return grub_errno;
+ }
+
+ if (grub_aout_get_type (&ah) != AOUT_TYPE_AOUT32)
+ return grub_error (GRUB_ERR_BAD_OS, "invalid a.out header");
+
+ entry = ah.aout32.a_entry & 0xFFFFFF;
+
+ if (AOUT_GETMAGIC (ah.aout32) == AOUT32_ZMAGIC)
+ {
+ load_addr = entry;
+ ofs = 0x1000;
+ align_page = 0;
+ }
+ else
+ {
+ load_addr = entry & 0xF00000;
+ ofs = sizeof (struct grub_aout32_header);
+ align_page = 1;
+ }
+
+ if (load_addr < 0x100000)
+ return grub_error (GRUB_ERR_BAD_OS, "load address below 1M");
+
+ kern_start = load_addr;
+ load_end = kern_end = load_addr + ah.aout32.a_text + ah.aout32.a_data;
+ if (align_page)
+ kern_end = ALIGN_PAGE (kern_end);
+
+ if (ah.aout32.a_bss)
+ {
+ kern_end += ah.aout32.a_bss;
+ if (align_page)
+ kern_end = ALIGN_PAGE (kern_end);
+
+ bss_size = kern_end - load_end;
+ }
+ else
+ bss_size = 0;
+
+ {
+ grub_relocator_chunk_t ch;
+
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ kern_start, kern_end - kern_start);
+ if (err)
+ return err;
+ kern_chunk_src = get_virtual_current_address (ch);
+ }
+
+ return grub_aout_load (file, ofs, kern_chunk_src,
+ ah.aout32.a_text + ah.aout32.a_data,
+ bss_size);
+}
+
+static grub_err_t
+grub_bsd_load_elf (grub_elf_t elf, const char *filename)
+{
+ grub_err_t err;
+
+ kern_end = 0;
+ kern_start = ~0;
+
+ if (grub_elf_is_elf32 (elf))
+ {
+ grub_relocator_chunk_t ch;
+ Elf32_Phdr *phdr;
+
+ entry = elf->ehdr.ehdr32.e_entry & 0xFFFFFFF;
+
+ FOR_ELF32_PHDRS (elf, phdr)
+ {
+ Elf32_Addr paddr;
+
+ if (phdr->p_type != PT_LOAD
+ && phdr->p_type != PT_DYNAMIC)
+ continue;
+
+ paddr = phdr->p_paddr & 0xFFFFFFF;
+
+ if (paddr < kern_start)
+ kern_start = paddr;
+
+ if (paddr + phdr->p_memsz > kern_end)
+ kern_end = paddr + phdr->p_memsz;
+ }
+
+ if (grub_errno)
+ return grub_errno;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ kern_start, kern_end - kern_start);
+ if (err)
+ return err;
+
+ kern_chunk_src = get_virtual_current_address (ch);
+
+ err = grub_elf32_load (elf, filename, (grub_uint8_t *) kern_chunk_src - kern_start, GRUB_ELF_LOAD_FLAGS_LOAD_PT_DYNAMIC | GRUB_ELF_LOAD_FLAGS_28BITS, 0, 0);
+ if (err)
+ return err;
+ if (kernel_type != KERNEL_TYPE_OPENBSD)
+ return GRUB_ERR_NONE;
+ return grub_openbsd_find_ramdisk32 (elf->file, filename, kern_start,
+ kern_chunk_src, &openbsd_ramdisk);
+ }
+ else if (grub_elf_is_elf64 (elf))
+ {
+ Elf64_Phdr *phdr;
+
+ is_64bit = 1;
+
+ if (! grub_cpuid_has_longmode)
+ return grub_error (GRUB_ERR_BAD_OS, "your CPU does not implement AMD64 architecture");
+
+ /* FreeBSD has 64-bit entry point. */
+ if (kernel_type == KERNEL_TYPE_FREEBSD)
+ {
+ entry = elf->ehdr.ehdr64.e_entry & 0xffffffff;
+ entry_hi = (elf->ehdr.ehdr64.e_entry >> 32) & 0xffffffff;
+ }
+ else
+ {
+ entry = elf->ehdr.ehdr64.e_entry & 0x0fffffff;
+ entry_hi = 0;
+ }
+
+ FOR_ELF64_PHDRS (elf, phdr)
+ {
+ Elf64_Addr paddr;
+
+ if (phdr->p_type != PT_LOAD
+ && phdr->p_type != PT_DYNAMIC)
+ continue;
+
+ paddr = phdr->p_paddr & 0xFFFFFFF;
+
+ if (paddr < kern_start)
+ kern_start = paddr;
+
+ if (paddr + phdr->p_memsz > kern_end)
+ kern_end = paddr + phdr->p_memsz;
+ }
+
+ if (grub_errno)
+ return grub_errno;
+
+ grub_dprintf ("bsd", "kern_start = %lx, kern_end = %lx\n",
+ (unsigned long) kern_start, (unsigned long) kern_end);
+ {
+ grub_relocator_chunk_t ch;
+
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch, kern_start,
+ kern_end - kern_start);
+ if (err)
+ return err;
+ kern_chunk_src = get_virtual_current_address (ch);
+ }
+
+ err = grub_elf64_load (elf, filename,
+ (grub_uint8_t *) kern_chunk_src - kern_start, GRUB_ELF_LOAD_FLAGS_LOAD_PT_DYNAMIC | GRUB_ELF_LOAD_FLAGS_28BITS, 0, 0);
+ if (err)
+ return err;
+ if (kernel_type != KERNEL_TYPE_OPENBSD)
+ return GRUB_ERR_NONE;
+ return grub_openbsd_find_ramdisk64 (elf->file, filename, kern_start,
+ kern_chunk_src, &openbsd_ramdisk);
+ }
+ else
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
+}
+
+static grub_err_t
+grub_bsd_load (int argc, char *argv[])
+{
+ grub_file_t file;
+ grub_elf_t elf;
+
+ grub_dl_ref (my_mod);
+
+ grub_loader_unset ();
+
+ grub_memset (&openbsd_ramdisk, 0, sizeof (openbsd_ramdisk));
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL);
+ if (!file)
+ goto fail;
+
+ relocator = grub_relocator_new ();
+ if (!relocator)
+ {
+ grub_file_close (file);
+ goto fail;
+ }
+
+ elf = grub_elf_file (file, argv[0]);
+ if (elf)
+ {
+ is_elf_kernel = 1;
+ grub_bsd_load_elf (elf, argv[0]);
+ grub_elf_close (elf);
+ }
+ else
+ {
+ is_elf_kernel = 0;
+ grub_errno = 0;
+ grub_bsd_load_aout (file, argv[0]);
+ grub_file_close (file);
+ }
+
+ kern_end = ALIGN_PAGE (kern_end);
+
+fail:
+
+ if (grub_errno != GRUB_ERR_NONE)
+ grub_dl_unref (my_mod);
+
+ return grub_errno;
+}
+
+static grub_uint32_t
+grub_bsd_parse_flags (const struct grub_arg_list *state,
+ const grub_uint32_t * flags)
+{
+ grub_uint32_t result = 0;
+ unsigned i;
+
+ for (i = 0; flags[i]; i++)
+ if (state[i].set)
+ result |= flags[i];
+
+ return result;
+}
+
+static grub_err_t
+grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
+{
+ kernel_type = KERNEL_TYPE_FREEBSD;
+ bootflags = grub_bsd_parse_flags (ctxt->state, freebsd_flags);
+
+ if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
+ {
+ grub_uint32_t unit, slice, part;
+
+ kern_end = ALIGN_PAGE (kern_end);
+ if (is_elf_kernel)
+ {
+ grub_err_t err;
+ grub_uint64_t data = 0;
+ grub_file_t file;
+ int len = is_64bit ? 8 : 4;
+
+ err = grub_freebsd_add_meta_module (argv[0], is_64bit
+ ? FREEBSD_MODTYPE_KERNEL64
+ : FREEBSD_MODTYPE_KERNEL,
+ argc - 1, argv + 1,
+ kern_start,
+ kern_end - kern_start);
+ if (err)
+ return err;
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL);
+ if (! file)
+ return grub_errno;
+
+ if (is_64bit)
+ err = grub_freebsd_load_elf_meta64 (relocator, file, argv[0],
+ &kern_end);
+ else
+ err = grub_freebsd_load_elf_meta32 (relocator, file, argv[0],
+ &kern_end);
+ if (err)
+ return err;
+
+ err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_HOWTO, &data, 4);
+ if (err)
+ return err;
+
+ err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_ENVP, &data, len);
+ if (err)
+ return err;
+
+ err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_KERNEND, &data, len);
+ if (err)
+ return err;
+ }
+ grub_bsd_get_device (&freebsd_biosdev, &unit, &slice, &part);
+ freebsd_zfsguid = 0;
+ if (!is_64bit)
+ freebsd_get_zfs ();
+ grub_print_error ();
+ freebsd_bootdev = (FREEBSD_B_DEVMAGIC + ((slice + 1) << FREEBSD_B_SLICESHIFT) +
+ (unit << FREEBSD_B_UNITSHIFT) + (part << FREEBSD_B_PARTSHIFT));
+
+ grub_loader_set (grub_freebsd_boot, grub_bsd_unload, 0);
+ }
+
+ return grub_errno;
+}
+
+static const char *types[] = {
+ [0] = "wd",
+ [2] = "fd",
+ [4] = "sd",
+ [6] = "cd",
+ [14] = "vnd",
+ [17] = "rd"
+};
+
+static grub_err_t
+grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
+{
+ grub_uint32_t bootdev;
+
+ kernel_type = KERNEL_TYPE_OPENBSD;
+ bootflags = grub_bsd_parse_flags (ctxt->state, openbsd_flags);
+
+ if (ctxt->state[OPENBSD_ROOT_ARG].set && ctxt->state[OPENBSD_ROOT_ARG].arg != NULL)
+ {
+ const char *arg = ctxt->state[OPENBSD_ROOT_ARG].arg;
+ unsigned type, unit, part;
+ for (type = 0; type < ARRAY_SIZE (types); type++)
+ if (types[type]
+ && grub_strncmp (arg, types[type],
+ grub_strlen (types[type])) == 0)
+ {
+ arg += grub_strlen (types[type]);
+ break;
+ }
+ if (type == ARRAY_SIZE (types))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "unknown disk type name");
+
+ unit = grub_strtoul (arg, &arg, 10);
+ if (! (*arg >= 'a' && *arg <= 'z'))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "only device specifications of form "
+ "<type><number><lowercase letter> are supported");
+
+ part = *arg - 'a';
+
+ bootdev = (OPENBSD_B_DEVMAGIC | (type << OPENBSD_B_TYPESHIFT)
+ | (unit << OPENBSD_B_UNITSHIFT)
+ | (part << OPENBSD_B_PARTSHIFT));
+ }
+ else
+ bootdev = 0;
+
+ if (ctxt->state[OPENBSD_SERIAL_ARG].set)
+ {
+ struct grub_openbsd_bootarg_console serial;
+ const char *ptr;
+ unsigned port = 0;
+ unsigned speed = 9600;
+
+ grub_memset (&serial, 0, sizeof (serial));
+
+ if (ctxt->state[OPENBSD_SERIAL_ARG].arg)
+ {
+ ptr = ctxt->state[OPENBSD_SERIAL_ARG].arg;
+ if (grub_memcmp (ptr, "com", sizeof ("com") - 1) != 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "only com0-com3 are supported");
+ ptr += sizeof ("com") - 1;
+ port = grub_strtoul (ptr, &ptr, 0);
+ if (port >= 4)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "only com0-com3 are supported");
+ if (*ptr == ',')
+ {
+ ptr++;
+ speed = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ return grub_errno;
+ }
+ }
+
+ 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;
+ }
+ else
+ {
+ struct grub_openbsd_bootarg_console serial;
+
+ 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;
+ }
+
+ if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
+ {
+ grub_loader_set (grub_openbsd_boot, grub_bsd_unload, 0);
+ openbsd_root = bootdev;
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_netbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
+{
+ grub_err_t err;
+ kernel_type = KERNEL_TYPE_NETBSD;
+ bootflags = grub_bsd_parse_flags (ctxt->state, netbsd_flags);
+
+ if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
+ {
+ if (is_elf_kernel)
+ {
+ grub_file_t file;
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_BSD_KERNEL);
+ if (! file)
+ return grub_errno;
+
+ if (is_64bit)
+ err = grub_netbsd_load_elf_meta64 (relocator, file, argv[0], &kern_end);
+ else
+ err = grub_netbsd_load_elf_meta32 (relocator, file, argv[0], &kern_end);
+ if (err)
+ return err;
+ }
+
+ {
+ char bootpath[GRUB_NETBSD_MAX_BOOTPATH_LEN];
+ char *name;
+ name = grub_strrchr (argv[0], '/');
+ if (name)
+ name++;
+ else
+ name = argv[0];
+ grub_memset (bootpath, 0, sizeof (bootpath));
+ grub_strncpy (bootpath, name, sizeof (bootpath) - 1);
+ grub_bsd_add_meta (NETBSD_BTINFO_BOOTPATH, bootpath, sizeof (bootpath));
+ }
+
+ if (ctxt->state[NETBSD_ROOT_ARG].set)
+ {
+ char root[GRUB_NETBSD_MAX_ROOTDEVICE_LEN];
+ grub_memset (root, 0, sizeof (root));
+ grub_strncpy (root, ctxt->state[NETBSD_ROOT_ARG].arg,
+ sizeof (root) - 1);
+ grub_bsd_add_meta (NETBSD_BTINFO_ROOTDEVICE, root, sizeof (root));
+ }
+ if (ctxt->state[NETBSD_SERIAL_ARG].set)
+ {
+ struct grub_netbsd_btinfo_serial serial;
+ const char *ptr;
+
+ grub_memset (&serial, 0, sizeof (serial));
+ grub_strcpy (serial.devname, "com");
+
+ serial.addr = grub_ns8250_hw_get_port (0);
+ serial.speed = 9600;
+
+ if (ctxt->state[NETBSD_SERIAL_ARG].arg)
+ {
+ ptr = ctxt->state[NETBSD_SERIAL_ARG].arg;
+ if (grub_memcmp (ptr, "com", sizeof ("com") - 1) == 0)
+ {
+ ptr += sizeof ("com") - 1;
+ serial.addr
+ = grub_ns8250_hw_get_port (grub_strtoul (ptr, &ptr, 0));
+ }
+ else
+ serial.addr = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ return grub_errno;
+
+ if (*ptr == ',')
+ {
+ ptr++;
+ serial.speed = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ return grub_errno;
+ }
+ }
+
+ grub_bsd_add_meta (NETBSD_BTINFO_CONSOLE, &serial, sizeof (serial));
+ }
+ else
+ {
+ struct grub_netbsd_btinfo_serial cons;
+
+ grub_memset (&cons, 0, sizeof (cons));
+ grub_strcpy (cons.devname, "pc");
+
+ grub_bsd_add_meta (NETBSD_BTINFO_CONSOLE, &cons, sizeof (cons));
+ }
+
+ grub_netbsd_add_boot_disk_and_wedge ();
+
+ grub_loader_set (grub_netbsd_boot, grub_bsd_unload, 0);
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ char *buf = 0, *curr, *next;
+ int len;
+
+ 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,
+ "only FreeBSD supports environment");
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_ENV);
+ if ((!file) || (!file->size))
+ goto fail;
+
+ len = file->size;
+ buf = grub_malloc (len + 1);
+ if (!buf)
+ goto fail;
+
+ if (grub_file_read (file, buf, len) != len)
+ goto fail;
+
+ buf[len] = 0;
+
+ next = buf;
+ while (next)
+ {
+ char *p;
+
+ curr = next;
+ next = grub_strchr (curr, '\n');
+ if (next)
+ {
+
+ p = next - 1;
+ while (p > curr)
+ {
+ if ((*p != '\r') && (*p != ' ') && (*p != '\t'))
+ break;
+ p--;
+ }
+
+ if ((p > curr) && (*p == '"'))
+ p--;
+
+ *(p + 1) = 0;
+ next++;
+ }
+
+ if (*curr == '#')
+ continue;
+
+ p = grub_strchr (curr, '=');
+ if (!p)
+ continue;
+
+ *(p++) = 0;
+
+ if (*curr)
+ {
+ char *name;
+
+ if (*p == '"')
+ p++;
+
+ name = grub_xasprintf ("kFreeBSD.%s", curr);
+ if (!name)
+ goto fail;
+ if (grub_env_set (name, p))
+ {
+ grub_free (name);
+ goto fail;
+ }
+ grub_free (name);
+ }
+ }
+
+fail:
+ grub_free (buf);
+
+ if (file)
+ grub_file_close (file);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ int modargc;
+ char **modargv;
+ const char *type;
+ 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");
+
+ if (!is_elf_kernel)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "only ELF kernel supports module");
+
+ /* List the current modules if no parameter. */
+ if (!argc)
+ {
+ grub_freebsd_list_modules ();
+ return 0;
+ }
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_MODULE);
+ if ((!file) || (!file->size))
+ goto fail;
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch, kern_end,
+ file->size);
+ if (err)
+ goto fail;
+ src = get_virtual_current_address (ch);
+ }
+
+
+ grub_file_read (file, src, file->size);
+ if (grub_errno)
+ goto fail;
+
+ modargc = argc - 1;
+ modargv = argv + 1;
+
+ if (modargc && (! grub_memcmp (modargv[0], "type=", 5)))
+ {
+ type = &modargv[0][5];
+ modargc--;
+ modargv++;
+ }
+ else
+ type = FREEBSD_MODTYPE_RAW;
+
+ err = grub_freebsd_add_meta_module (argv[0], type, modargc, modargv,
+ kern_end, file->size);
+ if (err)
+ goto fail;
+
+ kern_end = ALIGN_PAGE (kern_end + file->size);
+
+fail:
+ if (file)
+ grub_file_close (file);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_netbsd_module_load (char *filename, grub_uint32_t type)
+{
+ grub_file_t file = 0;
+ void *src;
+ grub_err_t err;
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_NETBSD_MODULE);
+ if ((!file) || (!file->size))
+ goto fail;
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch, kern_end,
+ file->size);
+ if (err)
+ goto fail;
+
+ src = get_virtual_current_address (ch);
+ }
+
+ grub_file_read (file, src, file->size);
+ if (grub_errno)
+ goto fail;
+
+ err = grub_netbsd_add_meta_module (filename, type, kern_end, file->size);
+
+ if (err)
+ goto fail;
+
+ kern_end = ALIGN_PAGE (kern_end + file->size);
+
+fail:
+ if (file)
+ grub_file_close (file);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_netbsd_module (grub_command_t cmd,
+ int argc, char *argv[])
+{
+ 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");
+
+ if (!is_elf_kernel)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "only ELF kernel supports module");
+
+ /* List the current modules if no parameter. */
+ if (!argc)
+ {
+ grub_netbsd_list_modules ();
+ return 0;
+ }
+
+ if (grub_strcmp (cmd->name, "knetbsd_module_elf") == 0)
+ type = GRUB_NETBSD_MODULE_ELF;
+ else
+ type = GRUB_NETBSD_MODULE_RAW;
+
+ return grub_netbsd_module_load (argv[0], type);
+}
+
+static grub_err_t
+grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ grub_err_t err;
+
+ 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,
+ "only FreeBSD supports module");
+
+ if (! is_elf_kernel)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "only ELF kernel supports module");
+
+ /* List the current modules if no parameter. */
+ if (! argc)
+ {
+ grub_freebsd_list_modules ();
+ return 0;
+ }
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEBSD_MODULE_ELF);
+ if (!file)
+ return grub_errno;
+ if (!file->size)
+ {
+ grub_file_close (file);
+ return grub_errno;
+ }
+
+ if (is_64bit)
+ err = grub_freebsd_load_elfmodule_obj64 (relocator, file,
+ argc, argv, &kern_end);
+ else
+ err = grub_freebsd_load_elfmodule32 (relocator, file,
+ argc, argv, &kern_end);
+ grub_file_close (file);
+
+ return err;
+}
+
+static grub_err_t
+grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *args[])
+{
+ grub_file_t file;
+ grub_size_t size;
+
+ 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");
+
+ if (!openbsd_ramdisk.max_size)
+ return grub_error (GRUB_ERR_BAD_OS, "your kOpenBSD doesn't support ramdisk");
+
+ file = grub_file_open (args[0], GRUB_FILE_TYPE_OPENBSD_RAMDISK);
+ if (! file)
+ return grub_errno;
+
+ size = grub_file_size (file);
+
+ if (size > openbsd_ramdisk.max_size)
+ {
+ grub_file_close (file);
+ return grub_error (GRUB_ERR_BAD_OS, "your kOpenBSD supports ramdisk only"
+ " up to %" PRIuGRUB_SIZE " bytes, however you supplied"
+ " a %" PRIuGRUB_SIZE " bytes one",
+ openbsd_ramdisk.max_size, size);
+ }
+
+ if (grub_file_read (file, openbsd_ramdisk.target, size)
+ != (grub_ssize_t) (size))
+ {
+ grub_file_close (file);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), args[0]);
+ return grub_errno;
+ }
+ grub_memset (openbsd_ramdisk.target + size, 0,
+ openbsd_ramdisk.max_size - size);
+ *openbsd_ramdisk.size = ALIGN_UP (size, 512);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd_freebsd, cmd_openbsd, cmd_netbsd;
+static grub_command_t cmd_freebsd_loadenv, cmd_freebsd_module;
+static grub_command_t cmd_netbsd_module, cmd_freebsd_module_elf;
+static grub_command_t cmd_netbsd_module_elf, cmd_openbsd_ramdisk;
+
+GRUB_MOD_INIT (bsd)
+{
+ /* Net and OpenBSD kernels are often compressed. */
+ grub_dl_load ("gzio");
+
+ cmd_freebsd = grub_register_extcmd ("kfreebsd", grub_cmd_freebsd, 0,
+ N_("FILE"), N_("Load kernel of FreeBSD."),
+ freebsd_opts);
+ cmd_openbsd = grub_register_extcmd ("kopenbsd", grub_cmd_openbsd, 0,
+ N_("FILE"), N_("Load kernel of OpenBSD."),
+ openbsd_opts);
+ cmd_netbsd = grub_register_extcmd ("knetbsd", grub_cmd_netbsd, 0,
+ N_("FILE"), N_("Load kernel of NetBSD."),
+ netbsd_opts);
+ cmd_freebsd_loadenv =
+ grub_register_command ("kfreebsd_loadenv", grub_cmd_freebsd_loadenv,
+ 0, N_("Load FreeBSD env."));
+ cmd_freebsd_module =
+ grub_register_command ("kfreebsd_module", grub_cmd_freebsd_module,
+ 0, N_("Load FreeBSD kernel module."));
+ cmd_netbsd_module =
+ grub_register_command ("knetbsd_module", grub_cmd_netbsd_module,
+ 0, N_("Load NetBSD kernel module."));
+ cmd_netbsd_module_elf =
+ grub_register_command ("knetbsd_module_elf", grub_cmd_netbsd_module,
+ 0, N_("Load NetBSD kernel module (ELF)."));
+ cmd_freebsd_module_elf =
+ grub_register_command ("kfreebsd_module_elf", grub_cmd_freebsd_module_elf,
+ 0, N_("Load FreeBSD kernel module (ELF)."));
+
+ cmd_openbsd_ramdisk = grub_register_command ("kopenbsd_ramdisk",
+ grub_cmd_openbsd_ramdisk, 0,
+ /* TRANSLATORS: ramdisk isn't identifier,
+ it can be translated. */
+ N_("Load kOpenBSD ramdisk."));
+
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (bsd)
+{
+ grub_unregister_extcmd (cmd_freebsd);
+ grub_unregister_extcmd (cmd_openbsd);
+ grub_unregister_extcmd (cmd_netbsd);
+
+ grub_unregister_command (cmd_freebsd_loadenv);
+ grub_unregister_command (cmd_freebsd_module);
+ grub_unregister_command (cmd_netbsd_module);
+ grub_unregister_command (cmd_freebsd_module_elf);
+ grub_unregister_command (cmd_netbsd_module_elf);
+ grub_unregister_command (cmd_openbsd_ramdisk);
+
+ grub_bsd_unload ();
+}
diff --git a/grub-core/loader/i386/bsd32.c b/grub-core/loader/i386/bsd32.c
new file mode 100644
index 0000000..26704c4
--- /dev/null
+++ b/grub-core/loader/i386/bsd32.c
@@ -0,0 +1,6 @@
+#define SUFFIX(x) x ## 32
+#define GRUB_TARGET_WORDSIZE 32
+#define OBJSYM 0
+#include <grub/types.h>
+typedef grub_uint32_t grub_freebsd_addr_t;
+#include "bsdXX.c"
diff --git a/grub-core/loader/i386/bsd64.c b/grub-core/loader/i386/bsd64.c
new file mode 100644
index 0000000..f8aad1c
--- /dev/null
+++ b/grub-core/loader/i386/bsd64.c
@@ -0,0 +1,6 @@
+#define SUFFIX(x) x ## 64
+#define GRUB_TARGET_WORDSIZE 64
+#define OBJSYM 1
+#include <grub/types.h>
+typedef grub_uint64_t grub_freebsd_addr_t;
+#include "bsdXX.c"
diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c
new file mode 100644
index 0000000..a8d8bf7
--- /dev/null
+++ b/grub-core/loader/i386/bsdXX.c
@@ -0,0 +1,679 @@
+#include <grub/loader.h>
+#include <grub/i386/bsd.h>
+#include <grub/mm.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/i386/relocator.h>
+#include <grub/i18n.h>
+
+#define ALIGN_PAGE(a) ALIGN_UP (a, 4096)
+
+static inline grub_err_t
+load (grub_file_t file, const char *filename, void *where, grub_off_t off, grub_size_t size)
+{
+ if (grub_file_seek (file, off) == (grub_off_t) -1)
+ return grub_errno;
+ if (grub_file_read (file, where, size) != (grub_ssize_t) size)
+ {
+ if (grub_errno)
+ return grub_errno;
+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ }
+ return GRUB_ERR_NONE;
+}
+
+static inline grub_err_t
+read_headers (grub_file_t file, const char *filename, Elf_Ehdr *e, char **shdr)
+{
+ if (grub_file_seek (file, 0) == (grub_off_t) -1)
+ return grub_errno;
+
+ if (grub_file_read (file, (char *) e, sizeof (*e)) != sizeof (*e))
+ {
+ if (grub_errno)
+ return grub_errno;
+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ }
+
+ 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
+ || e->e_version != EV_CURRENT)
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic"));
+
+ if (e->e_ident[EI_CLASS] != SUFFIX (ELFCLASS))
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
+
+ *shdr = grub_calloc (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, (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;
+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/* On i386 FreeBSD uses "elf module" approarch for 32-bit variant
+ and "elf obj module" for 64-bit variant. However it may differ on other
+ platforms. So I keep both versions. */
+#if OBJSYM
+grub_err_t
+SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator,
+ grub_file_t file, int argc,
+ char *argv[], grub_addr_t *kern_end)
+{
+ Elf_Ehdr e;
+ Elf_Shdr *s;
+ char *shdr = 0;
+ grub_addr_t curload, module;
+ grub_err_t err;
+ 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)
+ goto out;
+
+ for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) ((char *) shdr
+ + e.e_shnum * e.e_shentsize);
+ s = (Elf_Shdr *) ((char *) s + e.e_shentsize))
+ {
+ if (s->sh_size == 0)
+ continue;
+
+ if (s->sh_addralign)
+ chunk_size = ALIGN_UP (chunk_size + *kern_end, s->sh_addralign)
+ - *kern_end;
+
+ chunk_size += s->sh_size;
+ }
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ module, chunk_size);
+ if (err)
+ goto out;
+ chunk_src = get_virtual_current_address (ch);
+ }
+
+ for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) ((char *) shdr
+ + e.e_shnum * e.e_shentsize);
+ s = (Elf_Shdr *) ((char *) s + e.e_shentsize))
+ {
+ if (s->sh_size == 0)
+ continue;
+
+ if (s->sh_addralign)
+ curload = ALIGN_UP (curload, s->sh_addralign);
+ s->sh_addr = curload;
+
+ grub_dprintf ("bsd", "loading section to %x, size %d, align %d\n",
+ (unsigned) curload, (int) s->sh_size,
+ (int) s->sh_addralign);
+
+ switch (s->sh_type)
+ {
+ default:
+ case SHT_PROGBITS:
+ err = load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end,
+ s->sh_offset, s->sh_size);
+ if (err)
+ goto out;
+ break;
+ case SHT_NOBITS:
+ grub_memset ((grub_uint8_t *) chunk_src + curload - *kern_end, 0,
+ s->sh_size);
+ break;
+ }
+ curload += s->sh_size;
+ }
+
+ *kern_end = ALIGN_PAGE (curload);
+
+ err = grub_freebsd_add_meta_module (argv[0], FREEBSD_MODTYPE_ELF_MODULE_OBJ,
+ argc - 1, argv + 1, module,
+ curload - module);
+ if (! err)
+ err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA
+ | FREEBSD_MODINFOMD_ELFHDR,
+ &e, sizeof (e));
+ if (! err)
+ err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA
+ | FREEBSD_MODINFOMD_SHDR,
+ shdr, e.e_shnum * e.e_shentsize);
+
+out:
+ grub_free (shdr);
+ return err;
+}
+
+#else
+
+grub_err_t
+SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator,
+ grub_file_t file, int argc, char *argv[],
+ grub_addr_t *kern_end)
+{
+ Elf_Ehdr e;
+ Elf_Shdr *s;
+ char *shdr = 0;
+ grub_addr_t curload, module;
+ grub_err_t err;
+ 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)
+ goto out;
+
+ for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) ((char *) shdr
+ + e.e_shnum * e.e_shentsize);
+ s = (Elf_Shdr *) ((char *) s + e.e_shentsize))
+ {
+ if (s->sh_size == 0)
+ continue;
+
+ if (! (s->sh_flags & SHF_ALLOC))
+ continue;
+ if (chunk_size < s->sh_addr + s->sh_size)
+ chunk_size = s->sh_addr + s->sh_size;
+ }
+
+ if (chunk_size < sizeof (e))
+ chunk_size = sizeof (e);
+ 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;
+
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ module, chunk_size);
+ if (err)
+ goto out;
+
+ chunk_src = get_virtual_current_address (ch);
+ }
+
+ for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) ((char *) shdr
+ + e.e_shnum * e.e_shentsize);
+ s = (Elf_Shdr *) ((char *) s + e.e_shentsize))
+ {
+ if (s->sh_size == 0)
+ continue;
+
+ if (! (s->sh_flags & SHF_ALLOC))
+ continue;
+
+ grub_dprintf ("bsd", "loading section to %x, size %d, align %d\n",
+ (unsigned) curload, (int) s->sh_size,
+ (int) s->sh_addralign);
+
+ switch (s->sh_type)
+ {
+ default:
+ case SHT_PROGBITS:
+ err = load (file, argv[0],
+ (grub_uint8_t *) chunk_src + module
+ + s->sh_addr - *kern_end,
+ s->sh_offset, s->sh_size);
+ if (err)
+ goto out;
+ break;
+ case SHT_NOBITS:
+ grub_memset ((grub_uint8_t *) chunk_src + module
+ + s->sh_addr - *kern_end, 0, s->sh_size);
+ break;
+ }
+ if (curload < module + s->sh_addr + s->sh_size)
+ curload = module + s->sh_addr + s->sh_size;
+ }
+
+ load (file, argv[0], (grub_uint8_t *) chunk_src + module - *kern_end, 0, sizeof (e));
+ if (curload < module + sizeof (e))
+ curload = module + sizeof (e);
+
+ load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, e.e_shoff,
+ (grub_uint32_t) e.e_shnum * e.e_shentsize);
+ e.e_shoff = curload - module;
+ 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,
+ (grub_uint32_t) e.e_phnum * e.e_phentsize);
+ e.e_phoff = curload - module;
+ 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);
+}
+
+#endif
+
+grub_err_t
+SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator,
+ grub_file_t file,
+ const char *filename,
+ grub_addr_t *kern_end)
+{
+ grub_err_t err;
+ Elf_Ehdr e;
+ Elf_Shdr *s;
+ char *shdr = 0;
+ unsigned symoff, stroff, symsize, strsize;
+ grub_freebsd_addr_t symstart, symend, symentsize, dynamic;
+ Elf_Sym *sym;
+ void *sym_chunk;
+ grub_uint8_t *curload;
+ grub_freebsd_addr_t symtarget;
+ const char *str;
+ unsigned i;
+ grub_size_t chunk_size;
+
+ err = read_headers (file, filename, &e, &shdr);
+ if (err)
+ goto out;
+
+ err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_ELFHDR, &e,
+ sizeof (e));
+ if (err)
+ goto out;
+
+ for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr
+ + e.e_shnum * e.e_shentsize);
+ s = (Elf_Shdr *) ((char *) s + e.e_shentsize))
+ if (s->sh_type == SHT_SYMTAB)
+ break;
+ if (s >= (Elf_Shdr *) ((char *) shdr
+ + e.e_shnum * e.e_shentsize))
+ {
+ 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;
+ s = (Elf_Shdr *) (shdr + e.e_shentsize * s->sh_link);
+ stroff = s->sh_offset;
+ strsize = s->sh_size;
+
+ chunk_size = ALIGN_UP (symsize + strsize, sizeof (grub_freebsd_addr_t))
+ + 2 * sizeof (grub_freebsd_addr_t);
+
+ symtarget = ALIGN_UP (*kern_end, sizeof (grub_freebsd_addr_t));
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ symtarget, chunk_size);
+ if (err)
+ goto out;
+ sym_chunk = get_virtual_current_address (ch);
+ }
+
+ symstart = symtarget;
+ symend = symstart + chunk_size;
+
+ curload = sym_chunk;
+ *((grub_freebsd_addr_t *) curload) = symsize;
+ curload += sizeof (grub_freebsd_addr_t);
+
+ if (grub_file_seek (file, symoff) == (grub_off_t) -1)
+ {
+ err = grub_errno;
+ goto out;
+ }
+ sym = (Elf_Sym *) curload;
+ if (grub_file_read (file, curload, symsize) != (grub_ssize_t) symsize)
+ {
+ if (! 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)
+ {
+ err = grub_errno;
+ goto out;
+ }
+ str = (char *) curload;
+ if (grub_file_read (file, curload, strsize) != (grub_ssize_t) strsize)
+ {
+ if (! 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;
+ i * symentsize < symsize;
+ i++, sym = (Elf_Sym *) ((char *) sym + symentsize))
+ {
+ const char *name = str + sym->st_name;
+ if (grub_strcmp (name, "_DYNAMIC") == 0)
+ break;
+ }
+
+ if (i * symentsize < symsize)
+ {
+ dynamic = sym->st_value;
+ grub_dprintf ("bsd", "dynamic = %llx\n", (unsigned long long) dynamic);
+ err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_DYNAMIC, &dynamic,
+ sizeof (dynamic));
+ if (err)
+ goto out;
+ }
+
+ err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_SSYM, &symstart,
+ sizeof (symstart));
+ if (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;
+
+ *kern_end = ALIGN_PAGE (symend);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator,
+ grub_file_t file, const char *filename,
+ grub_addr_t *kern_end)
+{
+ grub_err_t err;
+ Elf_Ehdr e;
+ Elf_Shdr *s, *symsh, *strsh;
+ char *shdr = NULL;
+ unsigned symsize, strsize;
+ void *sym_chunk;
+ grub_uint8_t *curload;
+ grub_size_t chunk_size;
+ Elf_Ehdr *e2;
+ struct grub_netbsd_btinfo_symtab symtab;
+ grub_addr_t symtarget;
+
+ err = read_headers (file, filename, &e, &shdr);
+ if (err)
+ {
+ grub_free (shdr);
+ return grub_errno;
+ }
+
+ for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr
+ + e.e_shnum * e.e_shentsize);
+ s = (Elf_Shdr *) ((char *) s + e.e_shentsize))
+ if (s->sh_type == SHT_SYMTAB)
+ break;
+ if (s >= (Elf_Shdr *) ((char *) shdr
+ + e.e_shnum * e.e_shentsize))
+ {
+ grub_free (shdr);
+ return GRUB_ERR_NONE;
+ }
+ symsize = s->sh_size;
+ symsh = s;
+ s = (Elf_Shdr *) (shdr + e.e_shentsize * s->sh_link);
+ strsize = s->sh_size;
+ strsh = s;
+
+ chunk_size = ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t))
+ + ALIGN_UP (strsize, sizeof (grub_freebsd_addr_t))
+ + sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize;
+
+ symtarget = ALIGN_UP (*kern_end, sizeof (grub_freebsd_addr_t));
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ symtarget, chunk_size);
+ if (err)
+ goto out;
+ sym_chunk = get_virtual_current_address (ch);
+ }
+
+ symtab.nsyms = 1;
+ symtab.ssyms = symtarget;
+ symtab.esyms = symtarget + chunk_size;
+
+ curload = sym_chunk;
+
+ e2 = (Elf_Ehdr *) curload;
+ grub_memcpy (curload, &e, sizeof (e));
+ e2->e_phoff = 0;
+ e2->e_phnum = 0;
+ e2->e_phentsize = 0;
+ e2->e_shstrndx = 0;
+ e2->e_shoff = sizeof (e);
+
+ curload += sizeof (e);
+
+ for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr
+ + e.e_shnum * e.e_shentsize);
+ s = (Elf_Shdr *) ((char *) s + e.e_shentsize))
+ {
+ Elf_Shdr *s2;
+ s2 = (Elf_Shdr *) curload;
+ grub_memcpy (curload, s, e.e_shentsize);
+ if (s == symsh)
+ 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) + (grub_uint32_t) e.e_shnum * e.e_shentsize;
+ else
+ s2->sh_offset = 0;
+ s2->sh_addr = s2->sh_offset;
+ curload += e.e_shentsize;
+ }
+
+ if (grub_file_seek (file, symsh->sh_offset) == (grub_off_t) -1)
+ {
+ err = grub_errno;
+ goto out;
+ }
+ if (grub_file_read (file, curload, symsize) != (grub_ssize_t) symsize)
+ {
+ if (! 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)
+ {
+ err = grub_errno;
+ goto out;
+ }
+ if (grub_file_read (file, curload, strsize) != (grub_ssize_t) strsize)
+ {
+ if (! 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;
+
+ *kern_end = ALIGN_PAGE (symtarget + chunk_size);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file,
+ const char *filename,
+ grub_addr_t kern_start,
+ void *kern_chunk_src,
+ struct grub_openbsd_ramdisk_descriptor *desc)
+{
+ unsigned symoff, stroff, symsize, strsize, symentsize;
+
+ {
+ grub_err_t err;
+ Elf_Ehdr e;
+ Elf_Shdr *s;
+ char *shdr = NULL;
+
+ err = read_headers (file, filename, &e, &shdr);
+ if (err)
+ {
+ grub_free (shdr);
+ return err;
+ }
+
+ for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr
+ + e.e_shnum * e.e_shentsize);
+ s = (Elf_Shdr *) ((char *) s + e.e_shentsize))
+ if (s->sh_type == SHT_SYMTAB)
+ break;
+ if (s >= (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize))
+ {
+ grub_free (shdr);
+ return GRUB_ERR_NONE;
+ }
+
+ symsize = s->sh_size;
+ symentsize = s->sh_entsize;
+ symoff = s->sh_offset;
+
+ s = (Elf_Shdr *) (shdr + e.e_shentsize * s->sh_link);
+ stroff = s->sh_offset;
+ strsize = s->sh_size;
+ grub_free (shdr);
+ }
+ {
+ Elf_Sym *syms, *sym, *imagesym = NULL, *sizesym = NULL;
+ unsigned i;
+ char *strs;
+
+ syms = grub_malloc (symsize);
+ if (!syms)
+ return grub_errno;
+
+ if (grub_file_seek (file, symoff) == (grub_off_t) -1)
+ {
+ grub_free (syms);
+ return grub_errno;
+ }
+ if (grub_file_read (file, syms, symsize) != (grub_ssize_t) symsize)
+ {
+ grub_free (syms);
+ if (! grub_errno)
+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ return grub_errno;
+ }
+
+ strs = grub_malloc (strsize);
+ if (!strs)
+ {
+ grub_free (syms);
+ return grub_errno;
+ }
+
+ if (grub_file_seek (file, stroff) == (grub_off_t) -1)
+ {
+ grub_free (syms);
+ grub_free (strs);
+ return grub_errno;
+ }
+ if (grub_file_read (file, strs, strsize) != (grub_ssize_t) strsize)
+ {
+ grub_free (syms);
+ grub_free (strs);
+ if (! grub_errno)
+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ return grub_errno;
+ }
+
+ for (i = 0, sym = syms; i * symentsize < symsize;
+ i++, sym = (Elf_Sym *) ((char *) sym + symentsize))
+ {
+ if (ELF_ST_TYPE (sym->st_info) != STT_OBJECT)
+ continue;
+ if (!sym->st_name)
+ continue;
+ if (grub_strcmp (strs + sym->st_name, "rd_root_image") == 0)
+ imagesym = sym;
+ if (grub_strcmp (strs + sym->st_name, "rd_root_size") == 0)
+ sizesym = sym;
+ if (imagesym && sizesym)
+ break;
+ }
+ if (!imagesym || !sizesym)
+ {
+ grub_free (syms);
+ grub_free (strs);
+ return GRUB_ERR_NONE;
+ }
+ if (sizeof (*desc->size) != sizesym->st_size)
+ {
+ grub_free (syms);
+ grub_free (strs);
+ return grub_error (GRUB_ERR_BAD_OS, "unexpected size of rd_root_size");
+ }
+ desc->max_size = imagesym->st_size;
+ desc->target = (imagesym->st_value & 0xFFFFFF) - kern_start
+ + (grub_uint8_t *) kern_chunk_src;
+ desc->size = (grub_uint32_t *) ((sizesym->st_value & 0xFFFFFF) - kern_start
+ + (grub_uint8_t *) kern_chunk_src);
+ grub_free (syms);
+ grub_free (strs);
+
+ return GRUB_ERR_NONE;
+ }
+}
diff --git a/grub-core/loader/i386/bsd_pagetable.c b/grub-core/loader/i386/bsd_pagetable.c
new file mode 100644
index 0000000..9ec5abf
--- /dev/null
+++ b/grub-core/loader/i386/bsd_pagetable.c
@@ -0,0 +1,92 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Based on the code from FreeBSD originally distributed under the
+ following terms: */
+
+/*-
+ * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+
+static void
+fill_bsd64_pagetable (grub_uint8_t *src, grub_addr_t target)
+{
+ grub_uint64_t *pt2, *pt3, *pt4;
+ grub_addr_t pt2t, pt3t;
+ int i;
+
+#define PG_V 0x001
+#define PG_RW 0x002
+#define PG_U 0x004
+#define PG_PS 0x080
+
+ pt4 = (grub_uint64_t *) src;
+ pt3 = (grub_uint64_t *) (src + 4096);
+ pt2 = (grub_uint64_t *) (src + 8192);
+
+ pt3t = target + 4096;
+ pt2t = target + 8192;
+
+ grub_memset (src, 0, 4096 * 3);
+
+ /*
+ * This is kinda brutal, but every single 1GB VM memory segment points to
+ * the same first 1GB of physical memory. But it is how BSD expects
+ * it to be.
+ */
+ for (i = 0; i < 512; i++)
+ {
+ /* Each slot of the level 4 pages points to the same level 3 page */
+ pt4[i] = (grub_addr_t) pt3t;
+ pt4[i] |= PG_V | PG_RW | PG_U;
+
+ /* Each slot of the level 3 pages points to the same level 2 page */
+ pt3[i] = (grub_addr_t) pt2t;
+ pt3[i] |= PG_V | PG_RW | PG_U;
+
+ /* The level 2 page slots are mapped with 2MB pages for 1GB. */
+ pt2[i] = i * (2 * 1024 * 1024);
+ pt2[i] |= PG_V | PG_RW | PG_PS | PG_U;
+ }
+}
diff --git a/grub-core/loader/i386/coreboot/chainloader.c b/grub-core/loader/i386/coreboot/chainloader.c
new file mode 100644
index 0000000..0a19ebb
--- /dev/null
+++ b/grub-core/loader/i386/coreboot/chainloader.c
@@ -0,0 +1,517 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/loader.h>
+#include <grub/memory.h>
+#include <grub/i386/memory.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/elfload.h>
+#include <grub/video.h>
+#include <grub/relocator.h>
+#include <grub/i386/relocator.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/cbfs_core.h>
+#include <grub/lib/LzmaDec.h>
+#include <grub/efi/pe32.h>
+#include <grub/i386/cpuid.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_addr_t entry;
+static struct grub_relocator *relocator = NULL;
+
+static grub_err_t
+grub_chain_boot (void)
+{
+ struct grub_relocator32_state state;
+
+ grub_video_set_mode ("text", 0, 0);
+
+ state.eip = entry;
+ return grub_relocator32_boot (relocator, state, 0);
+}
+
+static grub_err_t
+grub_chain_unload (void)
+{
+ grub_relocator_unload (relocator);
+ relocator = NULL;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+load_elf (grub_file_t file, const char *filename)
+{
+ grub_elf_t elf;
+ Elf32_Phdr *phdr;
+ grub_err_t err;
+
+ elf = grub_elf_file (file, filename);
+ if (!elf)
+ return grub_errno;
+
+ if (!grub_elf_is_elf32 (elf))
+ return grub_error (GRUB_ERR_BAD_OS, "only ELF32 can be coreboot payload");
+
+ entry = elf->ehdr.ehdr32.e_entry;
+
+ FOR_ELF32_PHDRS(elf, phdr)
+ {
+ grub_uint8_t *load_addr;
+ grub_relocator_chunk_t ch;
+
+ if (phdr->p_type != PT_LOAD)
+ continue;
+
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ phdr->p_paddr, phdr->p_memsz);
+ if (err)
+ {
+ elf->file = 0;
+ grub_elf_close (elf);
+ return err;
+ }
+
+ load_addr = get_virtual_current_address (ch);
+
+ if (grub_file_seek (elf->file, phdr->p_offset) == (grub_off_t) -1)
+ {
+ elf->file = 0;
+ grub_elf_close (elf);
+ return grub_errno;
+ }
+
+ if (phdr->p_filesz)
+ {
+ grub_ssize_t read;
+ read = grub_file_read (elf->file, load_addr, phdr->p_filesz);
+ if (read != (grub_ssize_t) phdr->p_filesz)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR,
+ N_("premature end of file %s"),
+ filename);
+ elf->file = 0;
+ grub_elf_close (elf);
+ return grub_errno;
+ }
+ }
+
+ if (phdr->p_filesz < phdr->p_memsz)
+ grub_memset ((load_addr + phdr->p_filesz),
+ 0, phdr->p_memsz - phdr->p_filesz);
+ }
+
+ elf->file = 0;
+ grub_elf_close (elf);
+ return GRUB_ERR_NONE;
+}
+
+static void *SzAlloc(void *p __attribute__ ((unused)), size_t size) { return grub_malloc (size); }
+static void SzFree(void *p __attribute__ ((unused)), void *address) { grub_free (address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+
+static grub_err_t
+load_segment (grub_file_t file, const char *filename,
+ void *load_addr, grub_uint32_t comp,
+ grub_size_t *size, grub_size_t max_size)
+{
+ switch (comp)
+ {
+ case grub_cpu_to_be32_compile_time (CBFS_COMPRESS_NONE):
+ if (grub_file_read (file, load_addr, *size)
+ != (grub_ssize_t) *size)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR,
+ N_("premature end of file %s"),
+ filename);
+ return grub_errno;
+ }
+ return GRUB_ERR_NONE;
+ case grub_cpu_to_be32_compile_time (CBFS_COMPRESS_LZMA):
+ {
+ grub_uint8_t *buf;
+ grub_size_t outsize, insize;
+ SRes res;
+ SizeT src_len, dst_len;
+ ELzmaStatus status;
+ if (*size < 13)
+ return grub_error (GRUB_ERR_BAD_OS, "invalid compressed chunk");
+ buf = grub_malloc (*size);
+ if (!buf)
+ return grub_errno;
+ if (grub_file_read (file, buf, *size)
+ != (grub_ssize_t) *size)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR,
+ N_("premature end of file %s"),
+ filename);
+ grub_free (buf);
+ return grub_errno;
+ }
+ outsize = grub_get_unaligned64 (buf + 5);
+ if (outsize > max_size)
+ {
+ grub_free (buf);
+ return grub_error (GRUB_ERR_BAD_OS, "invalid compressed chunk");
+ }
+ insize = *size - 13;
+
+ src_len = insize;
+ dst_len = outsize;
+ res = LzmaDecode (load_addr, &dst_len, buf + 13, &src_len,
+ buf, 5, LZMA_FINISH_END, &status, &g_Alloc);
+ /* ELzmaFinishMode finishMode,
+ ELzmaStatus *status, ISzAlloc *alloc)*/
+ grub_free (buf);
+ grub_dprintf ("chain", "%x, %x, %x, %x\n",
+ insize, src_len, outsize, dst_len);
+ if (res != SZ_OK
+ || src_len != insize || dst_len != outsize)
+ return grub_error (GRUB_ERR_BAD_OS, "decompression failure %d", res);
+ *size = outsize;
+ }
+ return GRUB_ERR_NONE;
+ default:
+ return grub_error (GRUB_ERR_BAD_OS, "unsupported compression %d",
+ grub_be_to_cpu32 (comp));
+ }
+}
+
+static grub_err_t
+load_tianocore (grub_file_t file)
+{
+ grub_uint16_t header_length;
+ grub_uint32_t section_head;
+ grub_uint8_t mz[2], pe[4];
+ struct grub_pe32_coff_header coff_head;
+ struct file_header
+ {
+ grub_uint8_t unused[18];
+ grub_uint8_t type;
+ grub_uint8_t unused2;
+ grub_uint8_t size[3];
+ grub_uint8_t unused3;
+ } file_head;
+ grub_relocator_chunk_t ch;
+
+ if (grub_file_seek (file, 48) == (grub_off_t) -1
+ || grub_file_read (file, &header_length, sizeof (header_length))
+ != sizeof (header_length)
+ || grub_file_seek (file, header_length) == (grub_off_t) -1)
+ goto fail;
+
+ while (1)
+ {
+ grub_off_t off;
+ if (grub_file_read (file, &file_head, sizeof (file_head))
+ != sizeof (file_head))
+ goto fail;
+ if (file_head.type != 0xf0)
+ break;
+ off = grub_get_unaligned32 (file_head.size) & 0xffffff;
+ if (off < sizeof (file_head))
+ goto fail;
+ if (grub_file_seek (file, grub_file_tell (file) + off
+ - sizeof (file_head)) == (grub_off_t) -1)
+ goto fail;
+ }
+
+ if (file_head.type != 0x03)
+ goto fail;
+
+ while (1)
+ {
+ if (grub_file_read (file, &section_head, sizeof (section_head))
+ != sizeof (section_head))
+ goto fail;
+ if ((section_head >> 24) != 0x19)
+ break;
+
+ if ((section_head & 0xffffff) < sizeof (section_head))
+ goto fail;
+
+ if (grub_file_seek (file, grub_file_tell (file)
+ + (section_head & 0xffffff)
+ - sizeof (section_head)) == (grub_off_t) -1)
+ goto fail;
+ }
+
+ if ((section_head >> 24) != 0x10)
+ goto fail;
+
+ grub_off_t exe_start = grub_file_tell (file);
+
+ if (grub_file_read (file, &mz, sizeof (mz)) != sizeof (mz))
+ goto fail;
+ if (mz[0] != 'M' || mz[1] != 'Z')
+ goto fail;
+
+ if (grub_file_seek (file, grub_file_tell (file) + 0x3a) == (grub_off_t) -1)
+ goto fail;
+
+ if (grub_file_read (file, &section_head, sizeof (section_head))
+ != sizeof (section_head))
+ goto fail;
+ if (section_head < 0x40)
+ goto fail;
+
+ if (grub_file_seek (file, grub_file_tell (file)
+ + section_head - 0x40) == (grub_off_t) -1)
+ goto fail;
+
+ if (grub_file_read (file, &pe, sizeof (pe))
+ != sizeof (pe))
+ goto fail;
+
+ if (pe[0] != 'P' || pe[1] != 'E' || pe[2] != '\0' || pe[3] != '\0')
+ goto fail;
+
+ if (grub_file_read (file, &coff_head, sizeof (coff_head))
+ != sizeof (coff_head))
+ goto fail;
+
+ grub_uint32_t loadaddr;
+
+ switch (coff_head.machine)
+ {
+ case GRUB_PE32_MACHINE_I386:
+ {
+ struct grub_pe32_optional_header oh;
+ if (grub_file_read (file, &oh, sizeof (oh))
+ != sizeof (oh))
+ goto fail;
+ if (oh.magic != GRUB_PE32_PE32_MAGIC)
+ goto fail;
+ loadaddr = oh.image_base - exe_start;
+ entry = oh.image_base + oh.entry_addr;
+ break;
+ }
+ case GRUB_PE32_MACHINE_X86_64:
+ {
+ struct grub_pe64_optional_header oh;
+ if (! grub_cpuid_has_longmode)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "your CPU does not implement AMD64 architecture");
+ goto fail;
+ }
+
+ if (grub_file_read (file, &oh, sizeof (oh))
+ != sizeof (oh))
+ goto fail;
+ if (oh.magic != GRUB_PE32_PE64_MAGIC)
+ goto fail;
+ loadaddr = oh.image_base - exe_start;
+ entry = oh.image_base + oh.entry_addr;
+ break;
+ }
+ default:
+ goto fail;
+ }
+ if (grub_file_seek (file, 0) == (grub_off_t) -1)
+ goto fail;
+
+ grub_size_t fz = grub_file_size (file);
+
+ if (grub_relocator_alloc_chunk_addr (relocator, &ch,
+ loadaddr, fz))
+ goto fail;
+
+ if (grub_file_read (file, get_virtual_current_address (ch), fz)
+ != (grub_ssize_t) fz)
+ goto fail;
+
+ return GRUB_ERR_NONE;
+
+ fail:
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, "fv volume is invalid");
+ return grub_errno;
+}
+
+static grub_err_t
+load_chewed (grub_file_t file, const char *filename)
+{
+ grub_size_t i;
+ for (i = 0;; i++)
+ {
+ struct cbfs_payload_segment segment;
+ grub_err_t err;
+
+ if (grub_file_seek (file, sizeof (segment) * i) == (grub_off_t) -1
+ || grub_file_read (file, &segment, sizeof (segment))
+ != sizeof (segment))
+ {
+ if (!grub_errno)
+ return grub_error (GRUB_ERR_BAD_OS,
+ "payload is too short");
+ return grub_errno;
+ }
+
+ switch (segment.type)
+ {
+ case PAYLOAD_SEGMENT_PARAMS:
+ break;
+
+ case PAYLOAD_SEGMENT_ENTRY:
+ entry = grub_be_to_cpu64 (segment.load_addr);
+ return GRUB_ERR_NONE;
+
+ case PAYLOAD_SEGMENT_BSS:
+ segment.len = 0;
+ segment.offset = 0;
+ segment.len = 0;
+ /* Fallthrough. */
+ case PAYLOAD_SEGMENT_CODE:
+ case PAYLOAD_SEGMENT_DATA:
+ {
+ grub_uint32_t target = grub_be_to_cpu64 (segment.load_addr);
+ grub_uint32_t memsize = grub_be_to_cpu32 (segment.mem_len);
+ grub_uint32_t filesize = grub_be_to_cpu32 (segment.len);
+ grub_uint8_t *load_addr;
+ grub_relocator_chunk_t ch;
+
+ if (memsize < filesize)
+ memsize = filesize;
+
+ grub_dprintf ("chain", "%x+%x\n", target, memsize);
+
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ target, memsize);
+ if (err)
+ return err;
+
+ load_addr = get_virtual_current_address (ch);
+
+ if (filesize)
+ {
+ if (grub_file_seek (file, grub_be_to_cpu32 (segment.offset))
+ == (grub_off_t) -1)
+ return grub_errno;
+
+ err = load_segment (file, filename, load_addr,
+ segment.compression, &filesize, memsize);
+ if (err)
+ return err;
+ }
+
+ if (filesize < memsize)
+ grub_memset ((load_addr + filesize),
+ 0, memsize - filesize);
+ }
+ }
+ }
+}
+
+static grub_err_t
+grub_cmd_chain (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_err_t err;
+ grub_file_t file;
+ grub_uint32_t head;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ grub_loader_unset ();
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_COREBOOT_CHAINLOADER);
+ if (!file)
+ return grub_errno;
+
+ relocator = grub_relocator_new ();
+ if (!relocator)
+ {
+ grub_file_close (file);
+ return grub_errno;
+ }
+
+ if (grub_file_read (file, &head, sizeof (head)) != sizeof (head)
+ || grub_file_seek (file, 0) == (grub_off_t) -1)
+ {
+ grub_file_close (file);
+ grub_relocator_unload (relocator);
+ relocator = 0;
+ if (!grub_errno)
+ return grub_error (GRUB_ERR_BAD_OS,
+ "payload is too short");
+ return grub_errno;
+ }
+
+ switch (head)
+ {
+ case ELFMAG0 | (ELFMAG1 << 8) | (ELFMAG2 << 16) | (ELFMAG3 << 24):
+ err = load_elf (file, argv[0]);
+ break;
+ case PAYLOAD_SEGMENT_CODE:
+ case PAYLOAD_SEGMENT_DATA:
+ case PAYLOAD_SEGMENT_PARAMS:
+ case PAYLOAD_SEGMENT_BSS:
+ case PAYLOAD_SEGMENT_ENTRY:
+ err = load_chewed (file, argv[0]);
+ break;
+
+ default:
+ if (grub_file_seek (file, 40) == (grub_off_t) -1
+ || grub_file_read (file, &head, sizeof (head)) != sizeof (head)
+ || grub_file_seek (file, 0) == (grub_off_t) -1
+ || head != 0x4856465f)
+ err = grub_error (GRUB_ERR_BAD_OS, "unrecognised payload type");
+ else
+ err = load_tianocore (file);
+ break;
+ }
+ grub_file_close (file);
+ if (err)
+ {
+ grub_relocator_unload (relocator);
+ relocator = 0;
+ return err;
+ }
+
+ grub_loader_set (grub_chain_boot, grub_chain_unload, 0);
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd_chain;
+
+GRUB_MOD_INIT (chain)
+{
+ cmd_chain = grub_register_command ("chainloader", grub_cmd_chain,
+ N_("FILE"),
+ /* TRANSLATORS: "payload" is a term used
+ by coreboot and must be translated in
+ sync with coreboot. If unsure,
+ let it untranslated. */
+ N_("Load another coreboot payload"));
+}
+
+GRUB_MOD_FINI (chain)
+{
+ grub_unregister_command (cmd_chain);
+ grub_chain_unload ();
+}
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
new file mode 100644
index 0000000..9f74a96
--- /dev/null
+++ b/grub-core/loader/i386/linux.c
@@ -0,0 +1,1141 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/memory.h>
+#include <grub/normal.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+#include <grub/cpu/linux.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/command.h>
+#include <grub/i386/relocator.h>
+#include <grub/i18n.h>
+#include <grub/lib/cmdline.h>
+#include <grub/linux.h>
+#include <grub/machine/kernel.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#ifdef GRUB_MACHINE_PCBIOS
+#include <grub/i386/pc/vesa_modes_table.h>
+#endif
+
+#ifdef GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#include <grub/efi/sb.h>
+#define HAS_VGA_TEXT 0
+#define DEFAULT_VIDEO_MODE "auto"
+#define ACCEPTS_PURE_TEXT 0
+#elif defined (GRUB_MACHINE_IEEE1275)
+#include <grub/ieee1275/ieee1275.h>
+#define HAS_VGA_TEXT 0
+#define DEFAULT_VIDEO_MODE "text"
+#define ACCEPTS_PURE_TEXT 1
+#else
+#include <grub/i386/pc/vbe.h>
+#include <grub/i386/pc/console.h>
+#define HAS_VGA_TEXT 1
+#define DEFAULT_VIDEO_MODE "text"
+#define ACCEPTS_PURE_TEXT 1
+#endif
+
+static grub_dl_t my_mod;
+
+static grub_size_t linux_mem_size;
+static int loaded;
+static void *prot_mode_mem;
+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 struct grub_relocator *relocator = NULL;
+static void *efi_mmap_buf;
+static grub_size_t maximal_cmdline_size;
+static struct linux_kernel_params linux_params;
+static char *linux_cmdline;
+#ifdef GRUB_MACHINE_EFI
+static grub_efi_uintn_t efi_mmap_size;
+#else
+static const grub_size_t efi_mmap_size = 0;
+#endif
+
+/* FIXME */
+#if 0
+struct idt_descriptor
+{
+ grub_uint16_t limit;
+ void *base;
+} GRUB_PACKED;
+
+static struct idt_descriptor idt_desc =
+ {
+ 0,
+ 0
+ };
+#endif
+
+static inline grub_size_t
+page_align (grub_size_t size)
+{
+ return (size + (1 << 12) - 1) & (~((1 << 12) - 1));
+}
+
+/* Helper for find_mmap_size. */
+static int
+count_hook (grub_uint64_t addr __attribute__ ((unused)),
+ grub_uint64_t size __attribute__ ((unused)),
+ grub_memory_type_t type __attribute__ ((unused)), void *data)
+{
+ grub_size_t *count = data;
+
+ (*count)++;
+ return 0;
+}
+
+/* Find the optimal number of pages for the memory map. */
+static grub_size_t
+find_mmap_size (void)
+{
+ grub_size_t count = 0, mmap_size;
+
+ grub_mmap_iterate (count_hook, &count);
+
+ mmap_size = count * sizeof (struct grub_e820_mmap);
+
+ /* Increase the size a bit for safety, because GRUB allocates more on
+ later. */
+ mmap_size += (1 << 12);
+
+ return page_align (mmap_size);
+}
+
+static void
+free_pages (void)
+{
+ grub_relocator_unload (relocator);
+ relocator = NULL;
+ prot_mode_mem = initrd_mem = 0;
+ prot_mode_target = initrd_mem_target = 0;
+}
+
+/* Allocate pages for the real mode code and the protected mode code
+ for linux as well as a memory map buffer. */
+static grub_err_t
+allocate_pages (grub_size_t prot_size, grub_size_t *align,
+ grub_size_t min_align, int relocatable,
+ grub_uint64_t preferred_address)
+{
+ grub_err_t err;
+
+ if (prot_size == 0)
+ prot_size = 1;
+
+ prot_size = page_align (prot_size);
+
+ /* Initialize the memory pointers with NULL for convenience. */
+ free_pages ();
+
+ relocator = grub_relocator_new ();
+ if (!relocator)
+ {
+ err = grub_errno;
+ goto fail;
+ }
+
+ /* FIXME: Should request low memory from the heap when this feature is
+ implemented. */
+
+ {
+ grub_relocator_chunk_t ch;
+ if (relocatable)
+ {
+ err = grub_relocator_alloc_chunk_align (relocator, &ch,
+ preferred_address,
+ preferred_address,
+ prot_size, 1,
+ GRUB_RELOCATOR_PREFERENCE_LOW,
+ 1);
+ for (; err && *align + 1 > min_align; (*align)--)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x1000000,
+ UP_TO_TOP32 (prot_size),
+ prot_size, 1 << *align,
+ GRUB_RELOCATOR_PREFERENCE_LOW,
+ 1);
+ }
+ if (err)
+ goto fail;
+ }
+ else
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ preferred_address,
+ prot_size);
+ if (err)
+ goto fail;
+ prot_mode_mem = get_virtual_current_address (ch);
+ prot_mode_target = get_physical_target_address (ch);
+ }
+
+ grub_dprintf ("linux", "prot_mode_mem = %p, prot_mode_target = %lx, prot_size = %x\n",
+ prot_mode_mem, (unsigned long) prot_mode_target,
+ (unsigned) prot_size);
+ return GRUB_ERR_NONE;
+
+ fail:
+ free_pages ();
+ return err;
+}
+
+static grub_err_t
+grub_e820_add_region (struct grub_e820_mmap *e820_map, int *e820_num,
+ grub_uint64_t start, grub_uint64_t size,
+ grub_uint32_t type)
+{
+ int n = *e820_num;
+
+ if ((n > 0) && (e820_map[n - 1].addr + e820_map[n - 1].size == start) &&
+ (e820_map[n - 1].type == type))
+ e820_map[n - 1].size += size;
+ else
+ {
+ e820_map[n].addr = start;
+ e820_map[n].size = size;
+ e820_map[n].type = type;
+ (*e820_num)++;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_linux_setup_video (struct linux_kernel_params *params)
+{
+ struct grub_video_mode_info mode_info;
+ void *framebuffer;
+ grub_err_t err;
+ grub_video_driver_id_t driver_id;
+ const char *gfxlfbvar = grub_env_get ("gfxpayloadforcelfb");
+
+ driver_id = grub_video_get_driver_id ();
+
+ if (driver_id == GRUB_VIDEO_DRIVER_NONE)
+ return 1;
+
+ err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
+
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 1;
+ }
+
+ params->lfb_width = mode_info.width;
+ params->lfb_height = mode_info.height;
+ params->lfb_depth = mode_info.bpp;
+ params->lfb_line_len = mode_info.pitch;
+
+ params->lfb_base = (grub_size_t) framebuffer;
+
+#if defined (GRUB_MACHINE_EFI) && defined (__x86_64__)
+ params->ext_lfb_base = (grub_size_t) (((grub_uint64_t)(grub_size_t) framebuffer) >> 32);
+ params->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
+#endif
+
+ params->lfb_size = ALIGN_UP (params->lfb_line_len * params->lfb_height, 65536);
+
+ params->red_mask_size = mode_info.red_mask_size;
+ params->red_field_pos = mode_info.red_field_pos;
+ params->green_mask_size = mode_info.green_mask_size;
+ params->green_field_pos = mode_info.green_field_pos;
+ params->blue_mask_size = mode_info.blue_mask_size;
+ params->blue_field_pos = mode_info.blue_field_pos;
+ params->reserved_mask_size = mode_info.reserved_mask_size;
+ params->reserved_field_pos = mode_info.reserved_field_pos;
+
+ if (gfxlfbvar && (gfxlfbvar[0] == '1' || gfxlfbvar[0] == 'y'))
+ params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE;
+ else
+ {
+ switch (driver_id)
+ {
+ case GRUB_VIDEO_DRIVER_VBE:
+ params->lfb_size >>= 16;
+ params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA;
+ break;
+
+ case GRUB_VIDEO_DRIVER_EFI_UGA:
+ case GRUB_VIDEO_DRIVER_EFI_GOP:
+ params->have_vga = GRUB_VIDEO_LINUX_TYPE_EFIFB;
+ break;
+
+ /* FIXME: check if better id is available. */
+ case GRUB_VIDEO_DRIVER_SM712:
+ case GRUB_VIDEO_DRIVER_SIS315PRO:
+ case GRUB_VIDEO_DRIVER_VGA:
+ case GRUB_VIDEO_DRIVER_CIRRUS:
+ case GRUB_VIDEO_DRIVER_BOCHS:
+ case GRUB_VIDEO_DRIVER_RADEON_FULOONG2E:
+ case GRUB_VIDEO_DRIVER_RADEON_YEELOONG3A:
+ case GRUB_VIDEO_DRIVER_IEEE1275:
+ case GRUB_VIDEO_DRIVER_COREBOOT:
+ /* Make gcc happy. */
+ case GRUB_VIDEO_DRIVER_XEN:
+ case GRUB_VIDEO_DRIVER_SDL:
+ case GRUB_VIDEO_DRIVER_NONE:
+ case GRUB_VIDEO_ADAPTER_CAPTURE:
+ params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE;
+ break;
+ }
+ }
+
+#ifdef GRUB_MACHINE_PCBIOS
+ /* VESA packed modes may come with zeroed mask sizes, which need
+ to be set here according to DAC Palette width. If we don't,
+ this results in Linux displaying a black screen. */
+ if (driver_id == GRUB_VIDEO_DRIVER_VBE && mode_info.bpp <= 8)
+ {
+ struct grub_vbe_info_block controller_info;
+ int status;
+ int width = 8;
+
+ status = grub_vbe_bios_get_controller_info (&controller_info);
+
+ if (status == GRUB_VBE_STATUS_OK &&
+ (controller_info.capabilities & GRUB_VBE_CAPABILITY_DACWIDTH))
+ status = grub_vbe_bios_set_dac_palette_width (&width);
+
+ if (status != GRUB_VBE_STATUS_OK)
+ /* 6 is default after mode reset. */
+ width = 6;
+
+ params->red_mask_size = params->green_mask_size
+ = params->blue_mask_size = width;
+ params->reserved_mask_size = 0;
+ }
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+/* Context for grub_linux_boot. */
+struct grub_linux_boot_ctx
+{
+ grub_addr_t real_mode_target;
+ grub_size_t real_size;
+ struct linux_kernel_params *params;
+ int e820_num;
+};
+
+/* Helper for grub_linux_boot. */
+static int
+grub_linux_boot_mmap_find (grub_uint64_t addr, grub_uint64_t size,
+ grub_memory_type_t type, void *data)
+{
+ struct grub_linux_boot_ctx *ctx = data;
+
+ /* We must put real mode code in the traditional space. */
+ if (type != GRUB_MEMORY_AVAILABLE || addr > 0x90000)
+ return 0;
+
+ if (addr + size < 0x10000)
+ return 0;
+
+ if (addr < 0x10000)
+ {
+ size += addr - 0x10000;
+ addr = 0x10000;
+ }
+
+ if (addr + size > 0x90000)
+ size = 0x90000 - addr;
+
+ if (ctx->real_size + efi_mmap_size > size)
+ return 0;
+
+ grub_dprintf ("linux", "addr = %lx, size = %x, need_size = %x\n",
+ (unsigned long) addr,
+ (unsigned) size,
+ (unsigned) (ctx->real_size + efi_mmap_size));
+ ctx->real_mode_target = ((addr + size) - (ctx->real_size + efi_mmap_size));
+ return 1;
+}
+
+/* GRUB types conveniently match E820 types. */
+static int
+grub_linux_boot_mmap_fill (grub_uint64_t addr, grub_uint64_t size,
+ grub_memory_type_t type, void *data)
+{
+ struct grub_linux_boot_ctx *ctx = data;
+
+ if (grub_e820_add_region (ctx->params->e820_map, &ctx->e820_num,
+ addr, size, type))
+ return 1;
+
+ return 0;
+}
+
+static grub_err_t
+grub_linux_boot (void)
+{
+ grub_err_t err = 0;
+ const char *modevar;
+ char *tmp;
+ struct grub_relocator32_state state;
+ void *real_mode_mem;
+ struct grub_linux_boot_ctx ctx = {
+ .real_mode_target = 0
+ };
+ grub_size_t mmap_size;
+ grub_size_t cl_offset;
+
+#ifdef GRUB_MACHINE_IEEE1275
+ {
+ const char *bootpath;
+ grub_ssize_t len;
+
+ bootpath = grub_env_get ("root");
+ if (bootpath)
+ grub_ieee1275_set_property (grub_ieee1275_chosen,
+ "bootpath", bootpath,
+ grub_strlen (bootpath) + 1,
+ &len);
+ linux_params.ofw_signature = GRUB_LINUX_OFW_SIGNATURE;
+ linux_params.ofw_num_items = 1;
+ linux_params.ofw_cif_handler = (grub_uint32_t) grub_ieee1275_entry_fn;
+ linux_params.ofw_idt = 0;
+ }
+#endif
+
+ modevar = grub_env_get ("gfxpayload");
+
+ /* Now all graphical modes are acceptable.
+ May change in future if we have modes without framebuffer. */
+ if (modevar && *modevar != 0)
+ {
+ tmp = grub_xasprintf ("%s;" DEFAULT_VIDEO_MODE, modevar);
+ if (! tmp)
+ return grub_errno;
+#if ACCEPTS_PURE_TEXT
+ err = grub_video_set_mode (tmp, 0, 0);
+#else
+ err = grub_video_set_mode (tmp, GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
+#endif
+ grub_free (tmp);
+ }
+ else /* We can't go back to text mode from coreboot fb. */
+#ifdef GRUB_MACHINE_COREBOOT
+ if (grub_video_get_driver_id () == GRUB_VIDEO_DRIVER_COREBOOT)
+ err = GRUB_ERR_NONE;
+ else
+#endif
+ {
+#if ACCEPTS_PURE_TEXT
+ err = grub_video_set_mode (DEFAULT_VIDEO_MODE, 0, 0);
+#else
+ err = grub_video_set_mode (DEFAULT_VIDEO_MODE,
+ GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
+#endif
+ }
+
+ if (err)
+ {
+ grub_print_error ();
+ grub_puts_ (N_("Booting in blind mode"));
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ if (grub_linux_setup_video (&linux_params))
+ {
+#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
+ linux_params.have_vga = GRUB_VIDEO_LINUX_TYPE_TEXT;
+ linux_params.video_mode = 0x3;
+#else
+ linux_params.have_vga = 0;
+ linux_params.video_mode = 0;
+ linux_params.video_width = 0;
+ linux_params.video_height = 0;
+#endif
+ }
+
+
+#ifndef GRUB_MACHINE_IEEE1275
+ if (linux_params.have_vga == GRUB_VIDEO_LINUX_TYPE_TEXT)
+#endif
+ {
+ grub_term_output_t term;
+ int found = 0;
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ if (grub_strcmp (term->name, "vga_text") == 0
+ || grub_strcmp (term->name, "console") == 0
+ || grub_strcmp (term->name, "ofconsole") == 0)
+ {
+ struct grub_term_coordinate pos = grub_term_getxy (term);
+ linux_params.video_cursor_x = pos.x;
+ linux_params.video_cursor_y = pos.y;
+ linux_params.video_width = grub_term_width (term);
+ linux_params.video_height = grub_term_height (term);
+ found = 1;
+ break;
+ }
+ if (!found)
+ {
+ linux_params.video_cursor_x = 0;
+ linux_params.video_cursor_y = 0;
+ linux_params.video_width = 80;
+ linux_params.video_height = 25;
+ }
+ }
+
+#ifdef GRUB_KERNEL_USE_RSDP_ADDR
+ linux_params.acpi_rsdp_addr = grub_le_to_cpu64 (grub_rsdp_addr);
+#endif
+
+ mmap_size = find_mmap_size ();
+ /* Make sure that each size is aligned to a page boundary. */
+ cl_offset = ALIGN_UP (mmap_size + sizeof (linux_params), 4096);
+ if (cl_offset < ((grub_size_t) linux_params.setup_sects << GRUB_DISK_SECTOR_BITS))
+ cl_offset = ALIGN_UP ((grub_size_t) (linux_params.setup_sects
+ << GRUB_DISK_SECTOR_BITS), 4096);
+ ctx.real_size = ALIGN_UP (cl_offset + maximal_cmdline_size, 4096);
+
+#ifdef GRUB_MACHINE_EFI
+ efi_mmap_size = grub_efi_find_mmap_size ();
+ if (efi_mmap_size == 0)
+ return grub_errno;
+#endif
+
+ grub_dprintf ("linux", "real_size = %x, mmap_size = %x\n",
+ (unsigned) ctx.real_size, (unsigned) mmap_size);
+
+#ifdef GRUB_MACHINE_EFI
+ grub_efi_mmap_iterate (grub_linux_boot_mmap_find, &ctx, 1);
+ if (! ctx.real_mode_target)
+ grub_efi_mmap_iterate (grub_linux_boot_mmap_find, &ctx, 0);
+#else
+ grub_mmap_iterate (grub_linux_boot_mmap_find, &ctx);
+#endif
+ grub_dprintf ("linux", "real_mode_target = %lx, real_size = %x, efi_mmap_size = %x\n",
+ (unsigned long) ctx.real_mode_target,
+ (unsigned) ctx.real_size,
+ (unsigned) efi_mmap_size);
+
+ if (! ctx.real_mode_target)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate real mode pages");
+
+ {
+ grub_relocator_chunk_t ch;
+ grub_size_t sz;
+
+ if (grub_add (ctx.real_size, efi_mmap_size, &sz))
+ return GRUB_ERR_OUT_OF_RANGE;
+
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ ctx.real_mode_target, sz);
+ if (err)
+ return err;
+ real_mode_mem = get_virtual_current_address (ch);
+ }
+ efi_mmap_buf = (grub_uint8_t *) real_mode_mem + ctx.real_size;
+
+ grub_dprintf ("linux", "real_mode_mem = %p\n",
+ real_mode_mem);
+
+ ctx.params = real_mode_mem;
+
+ *ctx.params = linux_params;
+ ctx.params->cmd_line_ptr = ctx.real_mode_target + cl_offset;
+ grub_memcpy ((char *) ctx.params + cl_offset, linux_cmdline,
+ maximal_cmdline_size);
+
+ grub_dprintf ("linux", "code32_start = %x\n",
+ (unsigned) ctx.params->code32_start);
+
+ ctx.e820_num = 0;
+ if (grub_mmap_iterate (grub_linux_boot_mmap_fill, &ctx))
+ return grub_errno;
+ ctx.params->mmap_size = ctx.e820_num;
+
+#ifdef GRUB_MACHINE_EFI
+ {
+ grub_efi_uintn_t efi_desc_size;
+ grub_size_t efi_mmap_target;
+ grub_efi_uint32_t efi_desc_version;
+
+ ctx.params->secure_boot = grub_efi_get_secureboot ();
+
+ err = grub_efi_finish_boot_services (&efi_mmap_size, efi_mmap_buf, NULL,
+ &efi_desc_size, &efi_desc_version);
+ if (err)
+ return err;
+
+ /* Note that no boot services are available from here. */
+ efi_mmap_target = ctx.real_mode_target
+ + ((grub_uint8_t *) efi_mmap_buf - (grub_uint8_t *) real_mode_mem);
+ /* Pass EFI parameters. */
+ if (grub_le_to_cpu16 (ctx.params->version) >= 0x0208)
+ {
+ ctx.params->v0208.efi_mem_desc_size = efi_desc_size;
+ ctx.params->v0208.efi_mem_desc_version = efi_desc_version;
+ ctx.params->v0208.efi_mmap = efi_mmap_target;
+ ctx.params->v0208.efi_mmap_size = efi_mmap_size;
+
+#ifdef __x86_64__
+ ctx.params->v0208.efi_mmap_hi = (efi_mmap_target >> 32);
+#endif
+ }
+ else if (grub_le_to_cpu16 (ctx.params->version) >= 0x0206)
+ {
+ ctx.params->v0206.efi_mem_desc_size = efi_desc_size;
+ ctx.params->v0206.efi_mem_desc_version = efi_desc_version;
+ ctx.params->v0206.efi_mmap = efi_mmap_target;
+ ctx.params->v0206.efi_mmap_size = efi_mmap_size;
+ }
+ else if (grub_le_to_cpu16 (ctx.params->version) >= 0x0204)
+ {
+ ctx.params->v0204.efi_mem_desc_size = efi_desc_size;
+ ctx.params->v0204.efi_mem_desc_version = efi_desc_version;
+ ctx.params->v0204.efi_mmap = efi_mmap_target;
+ ctx.params->v0204.efi_mmap_size = efi_mmap_size;
+ }
+ }
+#endif
+
+ /* FIXME. */
+ /* asm volatile ("lidt %0" : : "m" (idt_desc)); */
+ state.ebp = state.edi = state.ebx = 0;
+ state.esi = ctx.real_mode_target;
+ state.esp = ctx.real_mode_target;
+ state.eip = ctx.params->code32_start;
+ return grub_relocator32_boot (relocator, state, 0);
+}
+
+static grub_err_t
+grub_linux_unload (void)
+{
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ grub_free (linux_cmdline);
+ linux_cmdline = 0;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ struct linux_i386_kernel_header lh;
+ grub_uint8_t setup_sects;
+ grub_size_t real_size, prot_size, prot_file_size;
+ grub_ssize_t len;
+ int i;
+ grub_size_t align, min_align;
+ int relocatable;
+ grub_uint64_t preferred_address = GRUB_LINUX_BZIMAGE_ADDR;
+
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
+ if (! file)
+ goto fail;
+
+ if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ argv[0]);
+ goto fail;
+ }
+
+ if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55))
+ {
+ grub_error (GRUB_ERR_BAD_OS, "invalid magic number");
+ goto fail;
+ }
+
+ if (lh.setup_sects > GRUB_LINUX_MAX_SETUP_SECTS)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "too many setup sectors");
+ goto fail;
+ }
+
+ /* 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_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
+ || grub_le_to_cpu16 (lh.version) < 0x0203)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "version too old for 32-bit boot"
+#ifdef GRUB_MACHINE_PCBIOS
+ " (try with `linux16')"
+#endif
+ );
+ goto fail;
+ }
+
+ if (! (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL))
+ {
+ grub_error (GRUB_ERR_BAD_OS, "zImage doesn't support 32-bit boot"
+#ifdef GRUB_MACHINE_PCBIOS
+ " (try with `linux16')"
+#endif
+ );
+ goto fail;
+ }
+
+ if (grub_le_to_cpu16 (lh.version) >= 0x0206)
+ maximal_cmdline_size = grub_le_to_cpu32 (lh.cmdline_size) + 1;
+ else
+ maximal_cmdline_size = 256;
+
+ if (maximal_cmdline_size < 128)
+ maximal_cmdline_size = 128;
+
+ setup_sects = lh.setup_sects;
+
+ /* If SETUP_SECTS is not set, set it to the default (4). */
+ if (! setup_sects)
+ setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS;
+
+ real_size = setup_sects << GRUB_DISK_SECTOR_BITS;
+ prot_file_size = grub_file_size (file) - real_size - GRUB_DISK_SECTOR_SIZE;
+
+ if (grub_le_to_cpu16 (lh.version) >= 0x205
+ && lh.kernel_alignment != 0
+ && ((lh.kernel_alignment - 1) & lh.kernel_alignment) == 0)
+ {
+ for (align = 0; align < 32; align++)
+ if (grub_le_to_cpu32 (lh.kernel_alignment) & (1 << align))
+ break;
+ relocatable = lh.relocatable;
+ }
+ else
+ {
+ align = 0;
+ relocatable = 0;
+ }
+
+ if (grub_le_to_cpu16 (lh.version) >= 0x020a)
+ {
+ min_align = lh.min_alignment;
+ prot_size = grub_le_to_cpu32 (lh.init_size);
+ prot_init_space = page_align (prot_size);
+ if (relocatable)
+ preferred_address = grub_le_to_cpu64 (lh.pref_address);
+ }
+ else
+ {
+ min_align = align;
+ prot_size = prot_file_size;
+ /* Usually, the compression ratio is about 50%. */
+ prot_init_space = page_align (prot_size) * 3;
+ }
+
+ if (allocate_pages (prot_size, &align,
+ min_align, relocatable,
+ preferred_address))
+ goto fail;
+
+ grub_memset (&linux_params, 0, sizeof (linux_params));
+
+ /*
+ * The Linux 32-bit boot protocol defines the setup header end
+ * to be at 0x202 + the byte value at 0x201.
+ */
+ len = 0x202 + *((char *) &lh.jump + 1);
+
+ /* Verify the struct is big enough so we do not write past the end. */
+ if (len > (char *) &linux_params.edd_mbr_sig_buffer - (char *) &linux_params) {
+ grub_error (GRUB_ERR_BAD_OS, "Linux setup header too big");
+ goto fail;
+ }
+
+ grub_memcpy (&linux_params.setup_sects, &lh.setup_sects, len - 0x1F1);
+
+ /* We've already read lh so there is no need to read it second time. */
+ len -= sizeof(lh);
+
+ if ((len > 0) &&
+ (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ argv[0]);
+ goto fail;
+ }
+
+ linux_params.code32_start = prot_mode_target + lh.code32_start - GRUB_LINUX_BZIMAGE_ADDR;
+ linux_params.kernel_alignment = (1 << align);
+ linux_params.ps_mouse = linux_params.padding11 = 0;
+ linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE;
+
+ /* These two are used (instead of cmd_line_ptr) by older versions of Linux,
+ and otherwise ignored. */
+ linux_params.cl_magic = GRUB_LINUX_CL_MAGIC;
+ linux_params.cl_offset = 0x1000;
+
+ linux_params.ramdisk_image = 0;
+ linux_params.ramdisk_size = 0;
+
+ linux_params.heap_end_ptr = GRUB_LINUX_HEAP_END_OFFSET;
+ linux_params.loadflags |= GRUB_LINUX_FLAG_CAN_USE_HEAP;
+
+ /* These are not needed to be precise, because Linux uses these values
+ only to raise an error when the decompression code cannot find good
+ space. */
+ linux_params.ext_mem = ((32 * 0x100000) >> 10);
+ linux_params.alt_mem = ((32 * 0x100000) >> 10);
+
+ /* Ignored by Linux. */
+ linux_params.video_page = 0;
+
+ /* Only used when `video_mode == 0x7', otherwise ignored. */
+ linux_params.video_ega_bx = 0;
+
+ linux_params.font_size = 16; /* XXX */
+
+#ifdef GRUB_MACHINE_EFI
+#ifdef __x86_64__
+ if (grub_le_to_cpu16 (linux_params.version) < 0x0208 &&
+ ((grub_addr_t) grub_efi_system_table >> 32) != 0)
+ return grub_error(GRUB_ERR_BAD_OS,
+ "kernel does not support 64-bit addressing");
+#endif
+
+ if (grub_le_to_cpu16 (linux_params.version) >= 0x0208)
+ {
+ linux_params.v0208.efi_signature = GRUB_LINUX_EFI_SIGNATURE;
+ linux_params.v0208.efi_system_table = (grub_uint32_t) (grub_addr_t) grub_efi_system_table;
+#ifdef __x86_64__
+ linux_params.v0208.efi_system_table_hi = (grub_uint32_t) ((grub_uint64_t) grub_efi_system_table >> 32);
+#endif
+ }
+ else if (grub_le_to_cpu16 (linux_params.version) >= 0x0206)
+ {
+ linux_params.v0206.efi_signature = GRUB_LINUX_EFI_SIGNATURE;
+ linux_params.v0206.efi_system_table = (grub_uint32_t) (grub_addr_t) grub_efi_system_table;
+ }
+ else if (grub_le_to_cpu16 (linux_params.version) >= 0x0204)
+ {
+ linux_params.v0204.efi_signature = GRUB_LINUX_EFI_SIGNATURE_0204;
+ linux_params.v0204.efi_system_table = (grub_uint32_t) (grub_addr_t) grub_efi_system_table;
+ }
+#endif
+
+ /* The other parameters are filled when booting. */
+
+ grub_file_seek (file, real_size + GRUB_DISK_SECTOR_SIZE);
+
+ grub_dprintf ("linux", "bzImage, setup=0x%x, size=0x%x\n",
+ (unsigned) real_size, (unsigned) prot_size);
+
+ /* Look for memory size and video mode specified on the command line. */
+ linux_mem_size = 0;
+ for (i = 1; i < argc; i++)
+#ifdef GRUB_MACHINE_PCBIOS
+ if (grub_memcmp (argv[i], "vga=", 4) == 0)
+ {
+ /* Video mode selection support. */
+ char *val = argv[i] + 4;
+ unsigned vid_mode = GRUB_LINUX_VID_MODE_NORMAL;
+ struct grub_vesa_mode_table_entry *linux_mode;
+ grub_err_t err;
+ char *buf;
+
+ grub_dl_load ("vbe");
+
+ if (grub_strcmp (val, "normal") == 0)
+ vid_mode = GRUB_LINUX_VID_MODE_NORMAL;
+ else if (grub_strcmp (val, "ext") == 0)
+ vid_mode = GRUB_LINUX_VID_MODE_EXTENDED;
+ else if (grub_strcmp (val, "ask") == 0)
+ {
+ grub_puts_ (N_("Legacy `ask' parameter no longer supported."));
+
+ /* We usually would never do this in a loader, but "vga=ask" means user
+ requested interaction, so it can't hurt to request keyboard input. */
+ grub_wait_after_message ();
+
+ goto fail;
+ }
+ else
+ vid_mode = (grub_uint16_t) grub_strtoul (val, 0, 0);
+
+ switch (vid_mode)
+ {
+ case 0:
+ case GRUB_LINUX_VID_MODE_NORMAL:
+ grub_env_set ("gfxpayload", "text");
+ grub_printf_ (N_("%s is deprecated. "
+ "Use set gfxpayload=%s before "
+ "linux command instead.\n"),
+ argv[i], "text");
+ break;
+
+ case 1:
+ case GRUB_LINUX_VID_MODE_EXTENDED:
+ /* FIXME: support 80x50 text. */
+ grub_env_set ("gfxpayload", "text");
+ grub_printf_ (N_("%s is deprecated. "
+ "Use set gfxpayload=%s before "
+ "linux command instead.\n"),
+ argv[i], "text");
+ break;
+ default:
+ /* Ignore invalid values. */
+ if (vid_mode < GRUB_VESA_MODE_TABLE_START ||
+ vid_mode > GRUB_VESA_MODE_TABLE_END)
+ {
+ grub_env_set ("gfxpayload", "text");
+ /* TRANSLATORS: "x" has to be entered in, like an identifier,
+ so please don't use better Unicode codepoints. */
+ grub_printf_ (N_("%s is deprecated. VGA mode %d isn't recognized. "
+ "Use set gfxpayload=WIDTHxHEIGHT[xDEPTH] "
+ "before linux command instead.\n"),
+ argv[i], vid_mode);
+ break;
+ }
+
+ linux_mode = &grub_vesa_mode_table[vid_mode
+ - GRUB_VESA_MODE_TABLE_START];
+
+ buf = grub_xasprintf ("%ux%ux%u,%ux%u",
+ linux_mode->width, linux_mode->height,
+ linux_mode->depth,
+ linux_mode->width, linux_mode->height);
+ if (! buf)
+ goto fail;
+
+ grub_printf_ (N_("%s is deprecated. "
+ "Use set gfxpayload=%s before "
+ "linux command instead.\n"),
+ argv[i], buf);
+ err = grub_env_set ("gfxpayload", buf);
+ grub_free (buf);
+ if (err)
+ goto fail;
+ }
+ }
+ else
+#endif /* GRUB_MACHINE_PCBIOS */
+ if (grub_memcmp (argv[i], "mem=", 4) == 0)
+ {
+ const char *val = argv[i] + 4;
+
+ linux_mem_size = grub_strtoul (val, &val, 0);
+
+ if (grub_errno)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ linux_mem_size = 0;
+ }
+ else
+ {
+ int shift = 0;
+
+ switch (grub_tolower (val[0]))
+ {
+ case 'g':
+ shift += 10;
+ /* FALLTHROUGH */
+ case 'm':
+ shift += 10;
+ /* FALLTHROUGH */
+ case 'k':
+ shift += 10;
+ /* FALLTHROUGH */
+ default:
+ break;
+ }
+
+ /* Check an overflow. */
+ if (linux_mem_size > (~0UL >> shift))
+ linux_mem_size = 0;
+ else
+ linux_mem_size <<= shift;
+ }
+ }
+ else if (grub_memcmp (argv[i], "quiet", sizeof ("quiet") - 1) == 0)
+ {
+ linux_params.loadflags |= GRUB_LINUX_FLAG_QUIET;
+ }
+
+ /* Create kernel command line. */
+ linux_cmdline = grub_zalloc (maximal_cmdline_size + 1);
+ if (!linux_cmdline)
+ goto fail;
+ grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE));
+ {
+ grub_err_t err;
+ err = grub_create_loader_cmdline (argc, argv,
+ linux_cmdline
+ + sizeof (LINUX_IMAGE) - 1,
+ maximal_cmdline_size
+ - (sizeof (LINUX_IMAGE) - 1),
+ GRUB_VERIFY_KERNEL_CMDLINE);
+ if (err)
+ goto fail;
+ }
+
+ len = prot_file_size;
+ if (grub_file_read (file, prot_mode_mem, len) != len && !grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ argv[0]);
+
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ grub_loader_set (grub_linux_boot, grub_linux_unload,
+ 0 /* set noreturn=0 in order to avoid grub_console_fini() */);
+ loaded = 1;
+ }
+
+ fail:
+
+ if (file)
+ grub_file_close (file);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ 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 = { 0, 0, 0 };
+
+ 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;
+
+ size = grub_get_initrd_size (&initrd_ctx);
+ aligned_size = ALIGN_UP (size, 4096);
+
+ /* Get the highest address available for the initrd. */
+ if (grub_le_to_cpu16 (linux_params.version) >= 0x0203)
+ {
+ addr_max = grub_cpu_to_le32 (linux_params.initrd_addr_max);
+
+ /* XXX in reality, Linux specifies a bogus value, so
+ it is necessary to make sure that ADDR_MAX does not exceed
+ 0x3fffffff. */
+ if (addr_max > GRUB_LINUX_INITRD_MAX_ADDRESS)
+ addr_max = GRUB_LINUX_INITRD_MAX_ADDRESS;
+ }
+ else
+ addr_max = GRUB_LINUX_INITRD_MAX_ADDRESS;
+
+ if (linux_mem_size != 0 && linux_mem_size < addr_max)
+ addr_max = linux_mem_size;
+
+ /* Linux 2.3.xx has a bug in the memory range check, so avoid
+ the last page.
+ Linux 2.2.xx has a bug in the memory range check, which is
+ worse than that of Linux 2.3.xx, so avoid the last 64kb. */
+ addr_max -= 0x10000;
+
+ addr_min = (grub_addr_t) prot_mode_target + prot_init_space;
+
+ /* Put the initrd as high as possible, 4KiB aligned. */
+ addr = (addr_max - aligned_size) & ~0xFFF;
+
+ if (addr < addr_min)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, "the initrd is too big");
+ goto fail;
+ }
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_align (relocator, &ch,
+ addr_min, addr, aligned_size,
+ 0x1000,
+ GRUB_RELOCATOR_PREFERENCE_HIGH,
+ 1);
+ if (err)
+ return err;
+ initrd_mem = get_virtual_current_address (ch);
+ initrd_mem_target = get_physical_target_address (ch);
+ }
+
+ if (grub_initrd_load (&initrd_ctx, argv, initrd_mem))
+ goto fail;
+
+ grub_dprintf ("linux", "Initrd, addr=0x%x, size=0x%x\n",
+ (unsigned) addr, (unsigned) size);
+
+ linux_params.ramdisk_image = initrd_mem_target;
+ linux_params.ramdisk_size = size;
+ linux_params.root_dev = 0x0100; /* XXX */
+
+ fail:
+ grub_initrd_close (&initrd_ctx);
+
+ 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/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c
new file mode 100644
index 0000000..a67d9d0
--- /dev/null
+++ b/grub-core/loader/i386/multiboot_mbi.c
@@ -0,0 +1,756 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/memory.h>
+#ifdef GRUB_MACHINE_PCBIOS
+#include <grub/machine/biosnum.h>
+#include <grub/machine/apm.h>
+#include <grub/machine/memory.h>
+#endif
+#include <grub/multiboot.h>
+#include <grub/cpu/relocator.h>
+#include <grub/disk.h>
+#include <grub/device.h>
+#include <grub/partition.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/relocator.h>
+#include <grub/video.h>
+#include <grub/file.h>
+#include <grub/net.h>
+#include <grub/i18n.h>
+#include <grub/lib/cmdline.h>
+
+#ifdef GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#endif
+
+/* The bits in the required part of flags field we don't support. */
+#define UNSUPPORTED_FLAGS 0x0000fff8
+
+struct module
+{
+ struct module *next;
+ grub_addr_t start;
+ grub_size_t size;
+ char *cmdline;
+ int cmdline_size;
+};
+
+static struct module *modules, *modules_last;
+static grub_size_t cmdline_size;
+static grub_size_t total_modcmd;
+static unsigned modcnt;
+static char *cmdline = NULL;
+static grub_uint32_t bootdev;
+static int bootdev_set;
+static grub_size_t elf_sec_num, elf_sec_entsize;
+static unsigned elf_sec_shstrndx;
+static void *elf_sections;
+grub_multiboot_quirks_t grub_multiboot_quirks;
+
+static grub_err_t
+load_kernel (grub_file_t file, const char *filename,
+ char *buffer, struct multiboot_header *header)
+{
+ grub_err_t err;
+ mbi_load_data_t mld;
+
+ mld.file = file;
+ mld.filename = filename;
+ mld.buffer = buffer;
+ mld.mbi_ver = 1;
+ mld.relocatable = 0;
+ mld.avoid_efi_boot_services = 0;
+
+ if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE)
+ {
+ err = grub_multiboot_load_elf (&mld);
+ 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;
+ }
+ if (header->flags & MULTIBOOT_AOUT_KLUDGE)
+ {
+ int offset = ((char *) header - buffer -
+ (header->header_addr - header->load_addr));
+ int load_size = ((header->load_end_addr == 0) ? file->size - offset :
+ header->load_end_addr - header->load_addr);
+ grub_size_t code_size;
+ void *source;
+ grub_relocator_chunk_t ch;
+
+ if (header->bss_end_addr)
+ code_size = (header->bss_end_addr - header->load_addr);
+ else
+ code_size = load_size;
+
+ err = grub_relocator_alloc_chunk_addr (grub_multiboot_relocator,
+ &ch, header->load_addr,
+ code_size);
+ if (err)
+ {
+ grub_dprintf ("multiboot_loader", "Error loading aout kludge\n");
+ return err;
+ }
+ source = get_virtual_current_address (ch);
+
+ if ((grub_file_seek (file, offset)) == (grub_off_t) -1)
+ {
+ return grub_errno;
+ }
+
+ grub_file_read (file, source, load_size);
+ if (grub_errno)
+ return grub_errno;
+
+ if (header->bss_end_addr)
+ grub_memset ((grub_uint8_t *) source + load_size, 0,
+ header->bss_end_addr - header->load_addr - load_size);
+
+ grub_multiboot_payload_eip = header->entry_addr;
+ return GRUB_ERR_NONE;
+ }
+
+ return grub_multiboot_load_elf (&mld);
+}
+
+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)
+{
+ char *buffer;
+ grub_ssize_t len;
+ struct multiboot_header *header;
+ grub_err_t err;
+
+ buffer = grub_malloc (MULTIBOOT_SEARCH);
+ if (!buffer)
+ return grub_errno;
+
+ len = grub_file_read (file, buffer, MULTIBOOT_SEARCH);
+ if (len < 32)
+ {
+ grub_free (buffer);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ return grub_errno;
+ }
+
+ header = find_header (buffer, len);
+
+ if (header == 0)
+ {
+ grub_free (buffer);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no multiboot header found");
+ }
+
+ if (header->flags & UNSUPPORTED_FLAGS)
+ {
+ grub_free (buffer);
+ return grub_error (GRUB_ERR_UNKNOWN_OS,
+ "unsupported flag: 0x%x", header->flags);
+ }
+
+ err = load_kernel (file, filename, buffer, header);
+ if (err)
+ {
+ grub_free (buffer);
+ return err;
+ }
+
+ if (header->flags & MULTIBOOT_VIDEO_MODE)
+ {
+ switch (header->mode_type)
+ {
+ case 1:
+ err = grub_multiboot_set_console (GRUB_MULTIBOOT_CONSOLE_EGA_TEXT,
+ GRUB_MULTIBOOT_CONSOLE_EGA_TEXT
+ | GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER,
+ 0, 0, 0, 0);
+ break;
+ case 0:
+ err = grub_multiboot_set_console (GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER,
+ GRUB_MULTIBOOT_CONSOLE_EGA_TEXT
+ | GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER,
+ header->width, header->height,
+ header->depth, 0);
+ break;
+ default:
+ err = grub_error (GRUB_ERR_BAD_OS,
+ "unsupported graphical mode type %d",
+ header->mode_type);
+ break;
+ }
+ }
+ else
+ err = grub_multiboot_set_console (GRUB_MULTIBOOT_CONSOLE_EGA_TEXT,
+ GRUB_MULTIBOOT_CONSOLE_EGA_TEXT,
+ 0, 0, 0, 0);
+ return err;
+}
+
+#if GRUB_MACHINE_HAS_VBE || GRUB_MACHINE_HAS_VGA_TEXT
+#include <grub/i386/pc/vbe.h>
+#endif
+
+static grub_size_t
+grub_multiboot_get_mbi_size (void)
+{
+ grub_size_t ret;
+ struct grub_net_network_level_interface *net;
+
+ ret = sizeof (struct multiboot_info) + ALIGN_UP (cmdline_size, 4)
+ + modcnt * sizeof (struct multiboot_mod_list) + total_modcmd
+ + ALIGN_UP (sizeof(PACKAGE_STRING), 4)
+ + grub_multiboot_get_mmap_count () * sizeof (struct multiboot_mmap_entry)
+ + elf_sec_entsize * elf_sec_num
+ + 256 * sizeof (struct multiboot_color)
+#if GRUB_MACHINE_HAS_VBE || GRUB_MACHINE_HAS_VGA_TEXT
+ + sizeof (struct grub_vbe_info_block)
+ + sizeof (struct grub_vbe_mode_info_block)
+#endif
+ + ALIGN_UP (sizeof (struct multiboot_apm_info), 4);
+
+ FOR_NET_NETWORK_LEVEL_INTERFACES(net)
+ if (net->dhcp_ack)
+ {
+ ret += net->dhcp_acklen;
+ break;
+ }
+
+ return ret;
+}
+
+/* Helper for grub_fill_multiboot_mmap. */
+static int
+grub_fill_multiboot_mmap_iter (grub_uint64_t addr, grub_uint64_t size,
+ grub_memory_type_t type, void *data)
+{
+ struct multiboot_mmap_entry **mmap_entry = data;
+
+ (*mmap_entry)->addr = addr;
+ (*mmap_entry)->len = size;
+ (*mmap_entry)->type = type;
+ (*mmap_entry)->size = sizeof (struct multiboot_mmap_entry) - sizeof ((*mmap_entry)->size);
+ (*mmap_entry)++;
+
+ return 0;
+}
+
+/* Fill previously allocated Multiboot mmap. */
+static void
+grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry)
+{
+ struct multiboot_mmap_entry *mmap_entry = (struct multiboot_mmap_entry *) first_entry;
+
+ grub_mmap_iterate (grub_fill_multiboot_mmap_iter, &mmap_entry);
+}
+
+#if GRUB_MACHINE_HAS_VBE || GRUB_MACHINE_HAS_VGA_TEXT
+
+static grub_err_t
+fill_vbe_info (struct multiboot_info *mbi, grub_uint8_t *ptrorig,
+ grub_uint32_t ptrdest, int fill_generic)
+{
+ grub_uint32_t vbe_mode;
+ struct grub_vbe_mode_info_block *mode_info;
+#if GRUB_MACHINE_HAS_VBE
+ grub_vbe_status_t status;
+ void *scratch = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+
+ status = grub_vbe_bios_get_controller_info (scratch);
+ if (status != GRUB_VBE_STATUS_OK)
+ return grub_error (GRUB_ERR_IO, "Can't get controller info.");
+
+ mbi->vbe_control_info = ptrdest;
+ grub_memcpy (ptrorig, scratch, sizeof (struct grub_vbe_info_block));
+ ptrorig += sizeof (struct grub_vbe_info_block);
+ ptrdest += sizeof (struct grub_vbe_info_block);
+#else
+ mbi->vbe_control_info = 0;
+#endif
+
+#if GRUB_MACHINE_HAS_VBE
+ status = grub_vbe_bios_get_mode (scratch);
+ vbe_mode = *(grub_uint32_t *) scratch;
+ if (status != GRUB_VBE_STATUS_OK)
+ return grub_error (GRUB_ERR_IO, "can't get VBE mode");
+#else
+ vbe_mode = 3;
+#endif
+ mbi->vbe_mode = vbe_mode;
+
+ mode_info = (struct grub_vbe_mode_info_block *) ptrorig;
+ mbi->vbe_mode_info = ptrdest;
+ /* get_mode_info isn't available for mode 3. */
+ if (vbe_mode == 3)
+ {
+ grub_memset (mode_info, 0, sizeof (struct grub_vbe_mode_info_block));
+ mode_info->memory_model = GRUB_VBE_MEMORY_MODEL_TEXT;
+ mode_info->x_resolution = 80;
+ mode_info->y_resolution = 25;
+ }
+ else
+ {
+#if GRUB_MACHINE_HAS_VBE
+ status = grub_vbe_bios_get_mode_info (vbe_mode, scratch);
+ if (status != GRUB_VBE_STATUS_OK)
+ return grub_error (GRUB_ERR_IO, "can't get mode info");
+ grub_memcpy (mode_info, scratch,
+ sizeof (struct grub_vbe_mode_info_block));
+#endif
+ }
+ ptrorig += sizeof (struct grub_vbe_mode_info_block);
+ ptrdest += sizeof (struct grub_vbe_mode_info_block);
+
+#if GRUB_MACHINE_HAS_VBE
+ grub_vbe_bios_get_pm_interface (&mbi->vbe_interface_seg,
+ &mbi->vbe_interface_off,
+ &mbi->vbe_interface_len);
+#endif
+
+ mbi->flags |= MULTIBOOT_INFO_VBE_INFO;
+
+ if (fill_generic && mode_info->memory_model == GRUB_VBE_MEMORY_MODEL_TEXT)
+ {
+ mbi->framebuffer_addr = 0xb8000;
+
+ mbi->framebuffer_pitch = 2 * mode_info->x_resolution;
+ mbi->framebuffer_width = mode_info->x_resolution;
+ mbi->framebuffer_height = mode_info->y_resolution;
+
+ mbi->framebuffer_bpp = 16;
+
+ mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT;
+
+ mbi->flags |= MULTIBOOT_INFO_FRAMEBUFFER_INFO;
+ }
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+static grub_err_t
+retrieve_video_parameters (struct multiboot_info *mbi,
+ grub_uint8_t *ptrorig, grub_uint32_t ptrdest)
+{
+ grub_err_t err;
+ struct grub_video_mode_info mode_info;
+ void *framebuffer;
+ grub_video_driver_id_t driv_id;
+ struct grub_video_palette_data palette[256];
+
+ err = grub_multiboot_set_video_mode ();
+ if (err)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ grub_video_get_palette (0, ARRAY_SIZE (palette), palette);
+
+ driv_id = grub_video_get_driver_id ();
+#if GRUB_MACHINE_HAS_VGA_TEXT
+ if (driv_id == GRUB_VIDEO_DRIVER_NONE)
+ return fill_vbe_info (mbi, ptrorig, ptrdest, 1);
+#else
+ if (driv_id == GRUB_VIDEO_DRIVER_NONE)
+ return GRUB_ERR_NONE;
+#endif
+
+ err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
+ if (err)
+ return err;
+
+ mbi->framebuffer_addr = (grub_addr_t) framebuffer;
+ mbi->framebuffer_pitch = mode_info.pitch;
+
+ mbi->framebuffer_width = mode_info.width;
+ mbi->framebuffer_height = mode_info.height;
+
+ mbi->framebuffer_bpp = mode_info.bpp;
+
+ if (mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
+ {
+ struct multiboot_color *mb_palette;
+ unsigned i;
+ mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED;
+ mbi->framebuffer_palette_addr = ptrdest;
+ mbi->framebuffer_palette_num_colors = mode_info.number_of_colors;
+ if (mbi->framebuffer_palette_num_colors > ARRAY_SIZE (palette))
+ mbi->framebuffer_palette_num_colors = ARRAY_SIZE (palette);
+ mb_palette = (struct multiboot_color *) ptrorig;
+ for (i = 0; i < mbi->framebuffer_palette_num_colors; i++)
+ {
+ mb_palette[i].red = palette[i].r;
+ mb_palette[i].green = palette[i].g;
+ mb_palette[i].blue = palette[i].b;
+ }
+ ptrorig += mbi->framebuffer_palette_num_colors
+ * sizeof (struct multiboot_color);
+ ptrdest += mbi->framebuffer_palette_num_colors
+ * sizeof (struct multiboot_color);
+ }
+ else
+ {
+ mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_RGB;
+ mbi->framebuffer_red_field_position = mode_info.red_field_pos;
+ mbi->framebuffer_red_mask_size = mode_info.red_mask_size;
+ mbi->framebuffer_green_field_position = mode_info.green_field_pos;
+ mbi->framebuffer_green_mask_size = mode_info.green_mask_size;
+ mbi->framebuffer_blue_field_position = mode_info.blue_field_pos;
+ mbi->framebuffer_blue_mask_size = mode_info.blue_mask_size;
+ }
+
+ mbi->flags |= MULTIBOOT_INFO_FRAMEBUFFER_INFO;
+
+#if GRUB_MACHINE_HAS_VBE
+ if (driv_id == GRUB_VIDEO_DRIVER_VBE)
+ return fill_vbe_info (mbi, ptrorig, ptrdest, 0);
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_multiboot_make_mbi (grub_uint32_t *target)
+{
+ struct multiboot_info *mbi;
+ struct multiboot_mod_list *modlist;
+ unsigned i;
+ struct module *cur;
+ grub_size_t mmap_size;
+ grub_uint8_t *ptrorig;
+ grub_addr_t ptrdest;
+
+ grub_err_t err;
+ grub_size_t bufsize;
+ grub_relocator_chunk_t ch;
+
+ bufsize = grub_multiboot_get_mbi_size ();
+
+ err = grub_relocator_alloc_chunk_align_safe (grub_multiboot_relocator, &ch,
+ 0x10000, 0xa0000, bufsize, 4,
+ GRUB_RELOCATOR_PREFERENCE_NONE, 0);
+ if (err)
+ return err;
+ ptrorig = get_virtual_current_address (ch);
+ ptrdest = get_physical_target_address (ch);
+
+ *target = ptrdest;
+
+ mbi = (struct multiboot_info *) ptrorig;
+ ptrorig += sizeof (*mbi);
+ ptrdest += sizeof (*mbi);
+ grub_memset (mbi, 0, sizeof (*mbi));
+
+ grub_memcpy (ptrorig, cmdline, cmdline_size);
+ mbi->flags |= MULTIBOOT_INFO_CMDLINE;
+ mbi->cmdline = ptrdest;
+ ptrorig += ALIGN_UP (cmdline_size, 4);
+ ptrdest += ALIGN_UP (cmdline_size, 4);
+
+ grub_memcpy (ptrorig, PACKAGE_STRING, sizeof(PACKAGE_STRING));
+ mbi->flags |= MULTIBOOT_INFO_BOOT_LOADER_NAME;
+ mbi->boot_loader_name = ptrdest;
+ ptrorig += ALIGN_UP (sizeof(PACKAGE_STRING), 4);
+ ptrdest += ALIGN_UP (sizeof(PACKAGE_STRING), 4);
+
+#ifdef GRUB_MACHINE_PCBIOS
+ {
+ struct grub_apm_info info;
+ if (grub_apm_get_info (&info))
+ {
+ struct multiboot_apm_info *mbinfo = (void *) ptrorig;
+
+ mbinfo->cseg = info.cseg;
+ mbinfo->offset = info.offset;
+ mbinfo->cseg_16 = info.cseg_16;
+ mbinfo->dseg = info.dseg;
+ mbinfo->flags = info.flags;
+ mbinfo->cseg_len = info.cseg_len;
+ mbinfo->dseg_len = info.dseg_len;
+ mbinfo->cseg_16_len = info.cseg_16_len;
+ mbinfo->version = info.version;
+
+ ptrorig += ALIGN_UP (sizeof (struct multiboot_apm_info), 4);
+ ptrdest += ALIGN_UP (sizeof (struct multiboot_apm_info), 4);
+ }
+ }
+#endif
+
+ if (modcnt)
+ {
+ mbi->flags |= MULTIBOOT_INFO_MODS;
+ mbi->mods_addr = ptrdest;
+ mbi->mods_count = modcnt;
+ modlist = (struct multiboot_mod_list *) ptrorig;
+ ptrorig += modcnt * sizeof (struct multiboot_mod_list);
+ ptrdest += modcnt * sizeof (struct multiboot_mod_list);
+
+ for (i = 0, cur = modules; i < modcnt; i++, cur = cur->next)
+ {
+ modlist[i].mod_start = cur->start;
+ modlist[i].mod_end = modlist[i].mod_start + cur->size;
+ modlist[i].cmdline = ptrdest;
+ grub_memcpy (ptrorig, cur->cmdline, cur->cmdline_size);
+ ptrorig += ALIGN_UP (cur->cmdline_size, 4);
+ ptrdest += ALIGN_UP (cur->cmdline_size, 4);
+ }
+ }
+ else
+ {
+ mbi->mods_addr = 0;
+ mbi->mods_count = 0;
+ }
+
+ mmap_size = grub_multiboot_get_mmap_count ()
+ * sizeof (struct multiboot_mmap_entry);
+ grub_fill_multiboot_mmap ((struct multiboot_mmap_entry *) ptrorig);
+ mbi->mmap_length = mmap_size;
+ mbi->mmap_addr = ptrdest;
+ mbi->flags |= MULTIBOOT_INFO_MEM_MAP;
+ ptrorig += mmap_size;
+ ptrdest += mmap_size;
+
+ /* Convert from bytes to kilobytes. */
+ mbi->mem_lower = grub_mmap_get_lower () / 1024;
+ mbi->mem_upper = grub_mmap_get_upper () / 1024;
+ mbi->flags |= MULTIBOOT_INFO_MEMORY;
+
+ if (bootdev_set)
+ {
+ mbi->boot_device = bootdev;
+ mbi->flags |= MULTIBOOT_INFO_BOOTDEV;
+ }
+
+ {
+ struct grub_net_network_level_interface *net;
+ FOR_NET_NETWORK_LEVEL_INTERFACES(net)
+ if (net->dhcp_ack)
+ {
+ grub_memcpy (ptrorig, net->dhcp_ack, net->dhcp_acklen);
+ mbi->drives_addr = ptrdest;
+ mbi->drives_length = net->dhcp_acklen;
+ ptrorig += net->dhcp_acklen;
+ ptrdest += net->dhcp_acklen;
+ break;
+ }
+ }
+
+ if (elf_sec_num)
+ {
+ mbi->u.elf_sec.addr = ptrdest;
+ grub_memcpy (ptrorig, elf_sections, elf_sec_entsize * elf_sec_num);
+ mbi->u.elf_sec.num = elf_sec_num;
+ mbi->u.elf_sec.size = elf_sec_entsize;
+ mbi->u.elf_sec.shndx = elf_sec_shstrndx;
+
+ mbi->flags |= MULTIBOOT_INFO_ELF_SHDR;
+
+ ptrorig += elf_sec_entsize * elf_sec_num;
+ ptrdest += elf_sec_entsize * elf_sec_num;
+ }
+
+ err = retrieve_video_parameters (mbi, ptrorig, ptrdest);
+ if (err)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ if ((mbi->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO)
+ && mbi->framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED)
+ {
+ ptrorig += mbi->framebuffer_palette_num_colors
+ * sizeof (struct multiboot_color);
+ ptrdest += mbi->framebuffer_palette_num_colors
+ * sizeof (struct multiboot_color);
+ }
+
+#if GRUB_MACHINE_HAS_VBE
+ ptrorig += sizeof (struct grub_vbe_info_block);
+ ptrdest += sizeof (struct grub_vbe_info_block);
+ ptrorig += sizeof (struct grub_vbe_mode_info_block);
+ ptrdest += sizeof (struct grub_vbe_mode_info_block);
+#endif
+
+#ifdef GRUB_MACHINE_EFI
+ err = grub_efi_finish_boot_services (NULL, NULL, NULL, NULL, NULL);
+ if (err)
+ return err;
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize,
+ unsigned shndx, void *data)
+{
+ elf_sec_num = num;
+ elf_sec_shstrndx = shndx;
+ elf_sec_entsize = entsize;
+ elf_sections = data;
+}
+
+void
+grub_multiboot_free_mbi (void)
+{
+ struct module *cur, *next;
+
+ cmdline_size = 0;
+ total_modcmd = 0;
+ modcnt = 0;
+ grub_free (cmdline);
+ cmdline = NULL;
+ bootdev_set = 0;
+
+ for (cur = modules; cur; cur = next)
+ {
+ next = cur->next;
+ grub_free (cur->cmdline);
+ grub_free (cur);
+ }
+ modules = NULL;
+ modules_last = NULL;
+
+ grub_free (elf_sections);
+ elf_sections = NULL;
+ elf_sec_entsize = 0;
+ elf_sec_num = 0;
+}
+
+grub_err_t
+grub_multiboot_init_mbi (int argc, char *argv[])
+{
+ grub_ssize_t len = 0;
+
+ grub_multiboot_free_mbi ();
+
+ len = grub_loader_cmdline_size (argc, argv);
+
+ cmdline = grub_malloc (len);
+ if (! cmdline)
+ return grub_errno;
+ cmdline_size = len;
+
+ return grub_create_loader_cmdline (argc, argv, cmdline,
+ cmdline_size, GRUB_VERIFY_KERNEL_CMDLINE);
+}
+
+grub_err_t
+grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
+ int argc, char *argv[])
+{
+ struct module *newmod;
+ grub_size_t len = 0;
+ grub_err_t err;
+
+ newmod = grub_malloc (sizeof (*newmod));
+ if (!newmod)
+ return grub_errno;
+ newmod->start = start;
+ newmod->size = size;
+ newmod->next = 0;
+
+ len = grub_loader_cmdline_size (argc, argv);
+
+ newmod->cmdline = grub_malloc (len);
+ if (! newmod->cmdline)
+ {
+ grub_free (newmod);
+ return grub_errno;
+ }
+ newmod->cmdline_size = len;
+ total_modcmd += ALIGN_UP (len, 4);
+
+ err = grub_create_loader_cmdline (argc, argv, newmod->cmdline,
+ newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE);
+ if (err)
+ {
+ grub_free (newmod);
+ return grub_errno;
+ }
+
+ if (modules_last)
+ modules_last->next = newmod;
+ else
+ modules = newmod;
+ modules_last = newmod;
+
+ modcnt++;
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_multiboot_set_bootdev (void)
+{
+ grub_uint32_t biosdev, slice = ~0, part = ~0;
+ grub_device_t dev;
+
+#ifdef GRUB_MACHINE_PCBIOS
+ biosdev = grub_get_root_biosnumber ();
+#else
+ biosdev = 0xffffffff;
+#endif
+
+ if (biosdev == 0xffffffff)
+ return;
+
+ dev = grub_device_open (0);
+ if (dev && dev->disk && dev->disk->partition)
+ {
+ if (dev->disk->partition->parent)
+ {
+ part = dev->disk->partition->number;
+ slice = dev->disk->partition->parent->number;
+ }
+ else
+ slice = dev->disk->partition->number;
+ }
+ if (dev)
+ grub_device_close (dev);
+
+ bootdev = ((biosdev & 0xff) << 24) | ((slice & 0xff) << 16)
+ | ((part & 0xff) << 8) | 0xff;
+ bootdev_set = 1;
+}
diff --git a/grub-core/loader/i386/pc/chainloader.c b/grub-core/loader/i386/pc/chainloader.c
new file mode 100644
index 0000000..976fea7
--- /dev/null
+++ b/grub-core/loader/i386/pc/chainloader.c
@@ -0,0 +1,310 @@
+/* chainloader.c - boot another boot loader */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2007,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/machine/chainloader.h>
+#include <grub/machine/biosdisk.h>
+#include <grub/machine/memory.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/partition.h>
+#include <grub/memory.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/msdos_partition.h>
+#include <grub/machine/biosnum.h>
+#include <grub/cpu/floppy.h>
+#include <grub/i18n.h>
+#include <grub/video.h>
+#include <grub/mm.h>
+#include <grub/fat.h>
+#include <grub/ntfs.h>
+#include <grub/i386/relocator.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+static int boot_drive;
+static grub_addr_t boot_part_addr;
+static struct grub_relocator *rel;
+
+typedef enum
+ {
+ GRUB_CHAINLOADER_FORCE = 0x1,
+ GRUB_CHAINLOADER_BPB = 0x2,
+ } grub_chainloader_flags_t;
+
+static grub_err_t
+grub_chainloader_boot (void)
+{
+ struct grub_relocator16_state state = {
+ .edx = boot_drive,
+ .esi = boot_part_addr,
+ .ds = 0,
+ .es = 0,
+ .fs = 0,
+ .gs = 0,
+ .ss = 0,
+ .cs = 0,
+ .sp = GRUB_MEMORY_MACHINE_BOOT_LOADER_ADDR,
+ .ip = GRUB_MEMORY_MACHINE_BOOT_LOADER_ADDR,
+ .a20 = 0
+ };
+ grub_video_set_mode ("text", 0, 0);
+
+ return grub_relocator16_boot (rel, state);
+}
+
+static grub_err_t
+grub_chainloader_unload (void)
+{
+ grub_relocator_unload (rel);
+ rel = NULL;
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_chainloader_patch_bpb (void *bs, grub_device_t dev, grub_uint8_t dl)
+{
+ grub_uint32_t part_start = 0, heads = 0, sectors = 0;
+ if (dev && dev->disk)
+ {
+ part_start = grub_partition_get_start (dev->disk->partition);
+ if (dev->disk->data)
+ {
+ heads = ((struct grub_biosdisk_data *)(dev->disk->data))->heads;
+ sectors = ((struct grub_biosdisk_data *)(dev->disk->data))->sectors;
+ }
+ }
+ if (grub_memcmp ((char *) &((struct grub_ntfs_bpb *) bs)->oem_name,
+ "NTFS", 4) == 0)
+ {
+ struct grub_ntfs_bpb *bpb = (struct grub_ntfs_bpb *) bs;
+ bpb->num_hidden_sectors = grub_cpu_to_le32 (part_start);
+ bpb->bios_drive = dl;
+ return;
+ }
+
+ do
+ {
+ struct grub_fat_bpb *bpb = (struct grub_fat_bpb *) bs;
+ if (grub_strncmp((const char *) bpb->version_specific.fat12_or_fat16.fstype, "FAT12", 5)
+ && grub_strncmp((const char *) bpb->version_specific.fat12_or_fat16.fstype, "FAT16", 5)
+ && grub_strncmp((const char *) bpb->version_specific.fat32.fstype, "FAT32", 5))
+ break;
+
+ if (grub_le_to_cpu16 (bpb->bytes_per_sector) < 512
+ || (grub_le_to_cpu16 (bpb->bytes_per_sector)
+ & (grub_le_to_cpu16 (bpb->bytes_per_sector) - 1)))
+ break;
+
+ if (bpb->sectors_per_cluster == 0
+ || (bpb->sectors_per_cluster & (bpb->sectors_per_cluster - 1)))
+ break;
+
+ if (bpb->num_reserved_sectors == 0)
+ break;
+ if (bpb->num_total_sectors_16 == 0 && bpb->num_total_sectors_32 == 0)
+ break;
+
+ if (bpb->num_fats == 0)
+ break;
+
+ if (bpb->sectors_per_fat_16)
+ {
+ bpb->num_hidden_sectors = grub_cpu_to_le32 (part_start);
+ bpb->version_specific.fat12_or_fat16.num_ph_drive = dl;
+ if (sectors)
+ bpb->sectors_per_track = grub_cpu_to_le16 (sectors);
+ if (heads)
+ bpb->num_heads = grub_cpu_to_le16 (heads);
+ return;
+ }
+ if (bpb->version_specific.fat32.sectors_per_fat_32)
+ {
+ bpb->num_hidden_sectors = grub_cpu_to_le32 (part_start);
+ bpb->version_specific.fat32.num_ph_drive = dl;
+ if (sectors)
+ bpb->sectors_per_track = grub_cpu_to_le16 (sectors);
+ if (heads)
+ bpb->num_heads = grub_cpu_to_le16 (heads);
+ return;
+ }
+ break;
+ }
+ while (0);
+}
+
+static void
+grub_chainloader_cmd (const char *filename, grub_chainloader_flags_t flags)
+{
+ grub_file_t file = 0;
+ grub_uint16_t signature;
+ grub_device_t dev;
+ int drive = -1;
+ grub_addr_t part_addr = 0;
+ grub_uint8_t *bs, *ptable;
+
+ rel = grub_relocator_new ();
+ if (!rel)
+ goto fail;
+
+ grub_dl_ref (my_mod);
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_PCCHAINLOADER
+ | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (! file)
+ goto fail;
+
+ {
+ grub_relocator_chunk_t ch;
+ grub_err_t err;
+
+ err = grub_relocator_alloc_chunk_addr (rel, &ch, 0x7C00,
+ GRUB_DISK_SECTOR_SIZE);
+ if (err)
+ goto fail;
+ bs = get_virtual_current_address (ch);
+ err = grub_relocator_alloc_chunk_addr (rel, &ch,
+ GRUB_MEMORY_MACHINE_PART_TABLE_ADDR,
+ 64);
+ if (err)
+ goto fail;
+ ptable = get_virtual_current_address (ch);
+ }
+
+ /* Read the first block. */
+ if (grub_file_read (file, bs, GRUB_DISK_SECTOR_SIZE)
+ != GRUB_DISK_SECTOR_SIZE)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+
+ goto fail;
+ }
+
+ /* Check the signature. */
+ signature = *((grub_uint16_t *) (bs + GRUB_DISK_SECTOR_SIZE - 2));
+ if (signature != grub_le_to_cpu16 (0xaa55)
+ && ! (flags & GRUB_CHAINLOADER_FORCE))
+ {
+ grub_error (GRUB_ERR_BAD_OS, "invalid signature");
+ goto fail;
+ }
+
+ grub_file_close (file);
+
+ /* Obtain the partition table from the root device. */
+ drive = grub_get_root_biosnumber ();
+ dev = grub_device_open (0);
+ if (dev && dev->disk && dev->disk->partition)
+ {
+ grub_disk_t disk = dev->disk;
+
+ if (disk)
+ {
+ grub_partition_t p = disk->partition;
+
+ if (p && grub_strcmp (p->partmap->name, "msdos") == 0)
+ {
+ disk->partition = p->parent;
+ grub_disk_read (disk, p->offset, 446, 64, ptable);
+ part_addr = (GRUB_MEMORY_MACHINE_PART_TABLE_ADDR
+ + (p->index << 4));
+ disk->partition = p;
+ }
+ }
+ }
+
+ if (flags & GRUB_CHAINLOADER_BPB)
+ grub_chainloader_patch_bpb ((void *) 0x7C00, dev, drive);
+
+ if (dev)
+ grub_device_close (dev);
+
+ /* Ignore errors. Perhaps it's not fatal. */
+ grub_errno = GRUB_ERR_NONE;
+
+ boot_drive = drive;
+ boot_part_addr = part_addr;
+
+ grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 1);
+ return;
+
+ fail:
+
+ if (file)
+ grub_file_close (file);
+
+ grub_dl_unref (my_mod);
+}
+
+static grub_err_t
+grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_chainloader_flags_t flags = 0;
+
+ while (argc > 0)
+ {
+ if (grub_strcmp (argv[0], "--force") == 0)
+ {
+ flags |= GRUB_CHAINLOADER_FORCE;
+ argc--;
+ argv++;
+ continue;
+ }
+ if (grub_strcmp (argv[0], "--bpb") == 0)
+ {
+ flags |= GRUB_CHAINLOADER_BPB;
+ argc--;
+ argv++;
+ continue;
+ }
+ break;
+ }
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ grub_chainloader_cmd (argv[0], flags);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(chainloader)
+{
+ cmd = grub_register_command ("chainloader", grub_cmd_chainloader,
+ N_("[--force|--bpb] FILE"),
+ N_("Load another boot loader."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(chainloader)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/loader/i386/pc/freedos.c b/grub-core/loader/i386/pc/freedos.c
new file mode 100644
index 0000000..aac6c97
--- /dev/null
+++ b/grub-core/loader/i386/pc/freedos.c
@@ -0,0 +1,190 @@
+/* chainloader.c - boot another boot loader */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2007,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/partition.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/machine/biosnum.h>
+#include <grub/i18n.h>
+#include <grub/video.h>
+#include <grub/mm.h>
+#include <grub/cpu/relocator.h>
+#include <grub/machine/chainloader.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+static struct grub_relocator *rel;
+static grub_uint32_t ebx = 0xffffffff;
+
+#define GRUB_FREEDOS_SEGMENT 0x60
+#define GRUB_FREEDOS_ADDR (GRUB_FREEDOS_SEGMENT << 4)
+#define GRUB_FREEDOS_STACK_SEGMENT 0x1fe0
+#define GRUB_FREEDOS_STACK_BPB_POINTER 0x7c00
+#define GRUB_FREEDOS_BPB_ADDR ((GRUB_FREEDOS_STACK_SEGMENT << 4) \
+ + GRUB_FREEDOS_STACK_BPB_POINTER)
+
+/* FreeDOS boot.asm passes register sp as exactly this. Importantly,
+ it must point below the BPB (to avoid overwriting any of it). */
+#define GRUB_FREEDOS_STACK_POINTER (GRUB_FREEDOS_STACK_BPB_POINTER \
+ - 0x60)
+
+/* In this, the additional 8192 bytes are the stack reservation; the
+ remaining parts trivially give the maximum allowed size. */
+#define GRUB_FREEDOS_MAX_SIZE ((GRUB_FREEDOS_STACK_SEGMENT << 4) \
+ + GRUB_FREEDOS_STACK_POINTER \
+ - GRUB_FREEDOS_ADDR \
+ - 8192)
+
+static grub_err_t
+grub_freedos_boot (void)
+{
+ struct grub_relocator16_state state = {
+ .cs = GRUB_FREEDOS_SEGMENT,
+ .ip = 0,
+
+ .ds = GRUB_FREEDOS_STACK_SEGMENT,
+ .es = 0,
+ .fs = 0,
+ .gs = 0,
+ .ss = GRUB_FREEDOS_STACK_SEGMENT,
+ .sp = GRUB_FREEDOS_STACK_POINTER,
+ .ebp = GRUB_FREEDOS_STACK_BPB_POINTER,
+ .ebx = ebx,
+ .edx = ebx,
+ .a20 = 1
+ };
+ grub_video_set_mode ("text", 0, 0);
+
+ return grub_relocator16_boot (rel, state);
+}
+
+static grub_err_t
+grub_freedos_unload (void)
+{
+ grub_relocator_unload (rel);
+ rel = NULL;
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_freedos (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ grub_err_t err;
+ void *bs, *kernelsys;
+ grub_size_t kernelsyssize;
+ grub_device_t dev;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ grub_dl_ref (my_mod);
+
+ rel = grub_relocator_new ();
+ if (!rel)
+ goto fail;
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_FREEDOS);
+ if (! file)
+ goto fail;
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (rel, &ch, GRUB_FREEDOS_BPB_ADDR,
+ GRUB_DISK_SECTOR_SIZE);
+ if (err)
+ goto fail;
+ bs = get_virtual_current_address (ch);
+ }
+
+ ebx = grub_get_root_biosnumber ();
+ dev = grub_device_open (0);
+
+ if (dev && dev->disk)
+ {
+ err = grub_disk_read (dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, bs);
+ if (err)
+ {
+ grub_device_close (dev);
+ goto fail;
+ }
+ grub_chainloader_patch_bpb (bs, dev, ebx);
+ }
+
+ if (dev)
+ grub_device_close (dev);
+
+ kernelsyssize = grub_file_size (file);
+
+ if (kernelsyssize > GRUB_FREEDOS_MAX_SIZE)
+ {
+ grub_error (GRUB_ERR_BAD_OS,
+ N_("the size of `%s' is too large"), argv[0]);
+ goto fail;
+ }
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (rel, &ch, GRUB_FREEDOS_ADDR,
+ kernelsyssize);
+ if (err)
+ goto fail;
+ kernelsys = get_virtual_current_address (ch);
+ }
+
+ if (grub_file_read (file, kernelsys, kernelsyssize)
+ != (grub_ssize_t) kernelsyssize)
+ goto fail;
+
+ grub_loader_set (grub_freedos_boot, grub_freedos_unload, 1);
+ return GRUB_ERR_NONE;
+
+ fail:
+
+ if (file)
+ grub_file_close (file);
+
+ grub_freedos_unload ();
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(freedos)
+{
+ cmd = grub_register_command ("freedos", grub_cmd_freedos,
+ 0, N_("Load FreeDOS kernel.sys."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(freedos)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
new file mode 100644
index 0000000..2a29952
--- /dev/null
+++ b/grub-core/loader/i386/pc/linux.c
@@ -0,0 +1,494 @@
+/* linux.c - boot Linux zImage or bzImage */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/memory.h>
+#include <grub/dl.h>
+#include <grub/cpu/linux.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/mm.h>
+#include <grub/cpu/relocator.h>
+#include <grub/video.h>
+#include <grub/i386/floppy.h>
+#include <grub/lib/cmdline.h>
+#include <grub/linux.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_LINUX_CL_OFFSET 0x9000
+
+static grub_dl_t my_mod;
+
+static grub_size_t linux_mem_size;
+static int loaded;
+static struct grub_relocator *relocator = NULL;
+static grub_addr_t grub_linux_real_target;
+static char *grub_linux_real_chunk;
+static grub_size_t grub_linux16_prot_size;
+static grub_size_t maximal_cmdline_size;
+
+static grub_err_t
+grub_linux16_boot (void)
+{
+ grub_uint16_t segment;
+ struct grub_relocator16_state state;
+
+ segment = grub_linux_real_target >> 4;
+ state.gs = state.fs = state.es = state.ds = state.ss = segment;
+ state.sp = GRUB_LINUX_SETUP_STACK;
+ state.cs = segment + 0x20;
+ state.ip = 0;
+ state.a20 = 1;
+
+ grub_video_set_mode ("text", 0, 0);
+
+ grub_stop_floppy ();
+
+ return grub_relocator16_boot (relocator, state);
+}
+
+static grub_err_t
+grub_linux_unload (void)
+{
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ grub_relocator_unload (relocator);
+ relocator = NULL;
+ return GRUB_ERR_NONE;
+}
+
+static int
+target_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data)
+{
+ grub_uint64_t *result = data;
+ grub_uint64_t candidate;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+ if (addr >= 0xa0000)
+ return 0;
+ if (addr + size >= 0xa0000)
+ size = 0xa0000 - addr;
+
+ /* Put the real mode part at as a high location as possible. */
+ candidate = addr + size - (GRUB_LINUX_CL_OFFSET + maximal_cmdline_size);
+ /* But it must not exceed the traditional area. */
+ if (candidate > GRUB_LINUX_OLD_REAL_MODE_ADDR)
+ candidate = GRUB_LINUX_OLD_REAL_MODE_ADDR;
+ if (candidate < addr)
+ return 0;
+
+ if (candidate > *result || *result == (grub_uint64_t) -1)
+ *result = candidate;
+ return 0;
+}
+
+static grub_addr_t
+grub_find_real_target (void)
+{
+ grub_uint64_t result = (grub_uint64_t) -1;
+
+ grub_mmap_iterate (target_hook, &result);
+ return result;
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ struct linux_i386_kernel_header lh;
+ grub_uint8_t setup_sects;
+ grub_size_t real_size;
+ grub_ssize_t len;
+ int i;
+ char *grub_linux_prot_chunk;
+ int grub_linux_is_bzimage;
+ grub_addr_t grub_linux_prot_target;
+ grub_err_t err;
+
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
+ if (! file)
+ goto fail;
+
+ if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ argv[0]);
+ goto fail;
+ }
+
+ if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55))
+ {
+ grub_error (GRUB_ERR_BAD_OS, "invalid magic number");
+ goto fail;
+ }
+
+ if (lh.setup_sects > GRUB_LINUX_MAX_SETUP_SECTS)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "too many setup sectors");
+ goto fail;
+ }
+
+ grub_linux_is_bzimage = 0;
+ setup_sects = lh.setup_sects;
+ linux_mem_size = 0;
+
+ maximal_cmdline_size = 256;
+
+ if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
+ && grub_le_to_cpu16 (lh.version) >= 0x0200)
+ {
+ grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL);
+ lh.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE;
+
+ if (grub_le_to_cpu16 (lh.version) >= 0x0206)
+ maximal_cmdline_size = grub_le_to_cpu32 (lh.cmdline_size) + 1;
+
+ grub_linux_real_target = grub_find_real_target ();
+ if (grub_linux_real_target == (grub_addr_t)-1)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "no appropriate low memory found");
+ goto fail;
+ }
+
+ if (grub_le_to_cpu16 (lh.version) >= 0x0201)
+ {
+ lh.heap_end_ptr = grub_cpu_to_le16_compile_time (GRUB_LINUX_HEAP_END_OFFSET);
+ lh.loadflags |= GRUB_LINUX_FLAG_CAN_USE_HEAP;
+ }
+
+ if (grub_le_to_cpu16 (lh.version) >= 0x0202)
+ lh.cmd_line_ptr = grub_linux_real_target + GRUB_LINUX_CL_OFFSET;
+ else
+ {
+ 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_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;
+
+ grub_linux_real_target = GRUB_LINUX_OLD_REAL_MODE_ADDR;
+ }
+
+ /* If SETUP_SECTS is not set, set it to the default (4). */
+ if (! setup_sects)
+ setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS;
+
+ real_size = setup_sects << GRUB_DISK_SECTOR_BITS;
+ if (grub_sub (grub_file_size (file), real_size, &grub_linux16_prot_size) ||
+ grub_sub (grub_linux16_prot_size, GRUB_DISK_SECTOR_SIZE, &grub_linux16_prot_size))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+ goto fail;
+ }
+
+ if (! grub_linux_is_bzimage
+ && GRUB_LINUX_ZIMAGE_ADDR + grub_linux16_prot_size
+ > grub_linux_real_target)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "too big zImage (0x%" PRIxGRUB_SIZE
+ " > 0x%" PRIxGRUB_ADDR "), use bzImage instead",
+ GRUB_LINUX_ZIMAGE_ADDR + grub_linux16_prot_size,
+ grub_linux_real_target);
+ goto fail;
+ }
+
+ grub_dprintf ("linux", "[Linux-%s, setup=0x%x, size=0x%x]\n",
+ grub_linux_is_bzimage ? "bzImage" : "zImage",
+ (unsigned) real_size,
+ (unsigned) grub_linux16_prot_size);
+
+ for (i = 1; i < argc; i++)
+ if (grub_memcmp (argv[i], "vga=", 4) == 0)
+ {
+ /* Video mode selection support. */
+ grub_uint16_t vid_mode;
+ char *val = argv[i] + 4;
+
+ if (grub_strcmp (val, "normal") == 0)
+ vid_mode = GRUB_LINUX_VID_MODE_NORMAL;
+ else if (grub_strcmp (val, "ext") == 0)
+ vid_mode = GRUB_LINUX_VID_MODE_EXTENDED;
+ else if (grub_strcmp (val, "ask") == 0)
+ vid_mode = GRUB_LINUX_VID_MODE_ASK;
+ else
+ vid_mode = (grub_uint16_t) grub_strtoul (val, 0, 0);
+
+ if (grub_errno)
+ goto fail;
+
+ lh.vid_mode = grub_cpu_to_le16 (vid_mode);
+ }
+ else if (grub_memcmp (argv[i], "mem=", 4) == 0)
+ {
+ const char *val = argv[i] + 4;
+
+ linux_mem_size = grub_strtoul (val, &val, 0);
+
+ if (grub_errno)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ linux_mem_size = 0;
+ }
+ else
+ {
+ int shift = 0;
+
+ switch (grub_tolower (val[0]))
+ {
+ case 'g':
+ shift += 10;
+ /* Fallthrough. */
+ case 'm':
+ shift += 10;
+ /* Fallthrough. */
+ case 'k':
+ shift += 10;
+ /* Fallthrough. */
+ default:
+ break;
+ }
+
+ /* Check an overflow. */
+ if (linux_mem_size > (~0UL >> shift))
+ linux_mem_size = 0;
+ else
+ linux_mem_size <<= shift;
+ }
+ }
+
+ relocator = grub_relocator_new ();
+ if (!relocator)
+ goto fail;
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ grub_linux_real_target,
+ GRUB_LINUX_CL_OFFSET
+ + maximal_cmdline_size);
+ if (err)
+ return err;
+ grub_linux_real_chunk = get_virtual_current_address (ch);
+ }
+
+ /* Put the real mode code at the temporary address. */
+ grub_memmove (grub_linux_real_chunk, &lh, sizeof (lh));
+
+ len = real_size + GRUB_DISK_SECTOR_SIZE - sizeof (lh);
+ if (grub_file_read (file, grub_linux_real_chunk + sizeof (lh), len) != len)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ argv[0]);
+ goto fail;
+ }
+
+ if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
+ || grub_le_to_cpu16 (lh.version) < 0x0200)
+ /* Clear the heap space. */
+ grub_memset (grub_linux_real_chunk
+ + ((setup_sects + 1) << GRUB_DISK_SECTOR_BITS),
+ 0,
+ ((GRUB_LINUX_MAX_SETUP_SECTS - setup_sects - 1)
+ << GRUB_DISK_SECTOR_BITS));
+
+ /* Create kernel command line. */
+ grub_memcpy ((char *)grub_linux_real_chunk + GRUB_LINUX_CL_OFFSET,
+ LINUX_IMAGE, sizeof (LINUX_IMAGE));
+ err = grub_create_loader_cmdline (argc, argv,
+ (char *)grub_linux_real_chunk
+ + GRUB_LINUX_CL_OFFSET + sizeof (LINUX_IMAGE) - 1,
+ maximal_cmdline_size
+ - (sizeof (LINUX_IMAGE) - 1),
+ GRUB_VERIFY_KERNEL_CMDLINE);
+ if (err)
+ goto fail;
+
+ if (grub_linux_is_bzimage)
+ grub_linux_prot_target = GRUB_LINUX_BZIMAGE_ADDR;
+ else
+ grub_linux_prot_target = GRUB_LINUX_ZIMAGE_ADDR;
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ grub_linux_prot_target,
+ grub_linux16_prot_size);
+ if (err)
+ return err;
+ grub_linux_prot_chunk = get_virtual_current_address (ch);
+ }
+
+ len = grub_linux16_prot_size;
+ if (grub_file_read (file, grub_linux_prot_chunk, len) != len && !grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ argv[0]);
+
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ grub_loader_set (grub_linux16_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;
+ grub_relocator_unload (relocator);
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_size_t size = 0;
+ grub_addr_t addr_max, addr_min;
+ struct linux_i386_kernel_header *lh;
+ grub_uint8_t *initrd_chunk;
+ grub_addr_t initrd_addr;
+ grub_err_t err;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
+
+ 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;
+ }
+
+ lh = (struct linux_i386_kernel_header *) grub_linux_real_chunk;
+
+ if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
+ && grub_le_to_cpu16 (lh->version) >= 0x0200))
+ {
+ grub_error (GRUB_ERR_BAD_OS, "the kernel is too old for initrd");
+ goto fail;
+ }
+
+ /* Get the highest address available for the initrd. */
+ if (grub_le_to_cpu16 (lh->version) >= 0x0203)
+ {
+ addr_max = grub_cpu_to_le32 (lh->initrd_addr_max);
+
+ /* XXX in reality, Linux specifies a bogus value, so
+ it is necessary to make sure that ADDR_MAX does not exceed
+ 0x3fffffff. */
+ if (addr_max > GRUB_LINUX_INITRD_MAX_ADDRESS)
+ addr_max = GRUB_LINUX_INITRD_MAX_ADDRESS;
+ }
+ else
+ addr_max = GRUB_LINUX_INITRD_MAX_ADDRESS;
+
+ if (linux_mem_size != 0 && linux_mem_size < addr_max)
+ addr_max = linux_mem_size;
+
+ /* Linux 2.3.xx has a bug in the memory range check, so avoid
+ the last page.
+ Linux 2.2.xx has a bug in the memory range check, which is
+ worse than that of Linux 2.3.xx, so avoid the last 64kb. */
+ addr_max -= 0x10000;
+
+ addr_min = GRUB_LINUX_BZIMAGE_ADDR + grub_linux16_prot_size;
+
+ if (grub_initrd_init (argc, argv, &initrd_ctx))
+ goto fail;
+
+ size = grub_get_initrd_size (&initrd_ctx);
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_align_safe (relocator, &ch, addr_min, addr_max, size,
+ 0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 0);
+ if (err)
+ return err;
+ initrd_chunk = get_virtual_current_address (ch);
+ initrd_addr = get_physical_target_address (ch);
+ }
+
+ if (grub_initrd_load (&initrd_ctx, argv, initrd_chunk))
+ goto fail;
+
+ lh->ramdisk_image = initrd_addr;
+ lh->ramdisk_size = size;
+
+ fail:
+ grub_initrd_close (&initrd_ctx);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd_linux, cmd_initrd;
+
+GRUB_MOD_INIT(linux16)
+{
+ cmd_linux =
+ grub_register_command ("linux16", grub_cmd_linux,
+ 0, N_("Load Linux."));
+ cmd_initrd =
+ grub_register_command ("initrd16", grub_cmd_initrd,
+ 0, N_("Load initrd."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(linux16)
+{
+ grub_unregister_command (cmd_linux);
+ grub_unregister_command (cmd_initrd);
+}
diff --git a/grub-core/loader/i386/pc/ntldr.c b/grub-core/loader/i386/pc/ntldr.c
new file mode 100644
index 0000000..f0d7414
--- /dev/null
+++ b/grub-core/loader/i386/pc/ntldr.c
@@ -0,0 +1,162 @@
+/* chainloader.c - boot another boot loader */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2007,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/partition.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/machine/biosnum.h>
+#include <grub/i18n.h>
+#include <grub/video.h>
+#include <grub/mm.h>
+#include <grub/cpu/relocator.h>
+#include <grub/machine/chainloader.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+static struct grub_relocator *rel;
+static grub_uint32_t edx = 0xffffffff;
+
+#define GRUB_NTLDR_SEGMENT 0x2000
+
+static grub_err_t
+grub_ntldr_boot (void)
+{
+ struct grub_relocator16_state state = {
+ .cs = GRUB_NTLDR_SEGMENT,
+ .ip = 0,
+ .ds = 0,
+ .es = 0,
+ .fs = 0,
+ .gs = 0,
+ .ss = 0,
+ .sp = 0x7c00,
+ .edx = edx,
+ .a20 = 1
+ };
+ grub_video_set_mode ("text", 0, 0);
+
+ return grub_relocator16_boot (rel, state);
+}
+
+static grub_err_t
+grub_ntldr_unload (void)
+{
+ grub_relocator_unload (rel);
+ rel = NULL;
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_ntldr (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ grub_err_t err;
+ void *bs, *ntldr;
+ grub_size_t ntldrsize;
+ grub_device_t dev;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ grub_dl_ref (my_mod);
+
+ rel = grub_relocator_new ();
+ if (!rel)
+ goto fail;
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_NTLDR);
+ if (! file)
+ goto fail;
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (rel, &ch, 0x7C00,
+ GRUB_DISK_SECTOR_SIZE);
+ if (err)
+ goto fail;
+ bs = get_virtual_current_address (ch);
+ }
+
+ edx = grub_get_root_biosnumber ();
+ dev = grub_device_open (0);
+
+ if (dev && dev->disk)
+ {
+ err = grub_disk_read (dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, bs);
+ if (err)
+ {
+ grub_device_close (dev);
+ goto fail;
+ }
+ grub_chainloader_patch_bpb (bs, dev, edx);
+ }
+
+ if (dev)
+ grub_device_close (dev);
+
+ ntldrsize = grub_file_size (file);
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (rel, &ch, GRUB_NTLDR_SEGMENT << 4,
+ ntldrsize);
+ if (err)
+ goto fail;
+ ntldr = get_virtual_current_address (ch);
+ }
+
+ if (grub_file_read (file, ntldr, ntldrsize)
+ != (grub_ssize_t) ntldrsize)
+ goto fail;
+
+ grub_loader_set (grub_ntldr_boot, grub_ntldr_unload, 1);
+ return GRUB_ERR_NONE;
+
+ fail:
+
+ if (file)
+ grub_file_close (file);
+
+ grub_ntldr_unload ();
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(ntldr)
+{
+ cmd = grub_register_command ("ntldr", grub_cmd_ntldr,
+ 0, N_("Load NTLDR or BootMGR."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(ntldr)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/loader/i386/pc/plan9.c b/grub-core/loader/i386/pc/plan9.c
new file mode 100644
index 0000000..3755015
--- /dev/null
+++ b/grub-core/loader/i386/pc/plan9.c
@@ -0,0 +1,607 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/scsi.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/video.h>
+#include <grub/mm.h>
+#include <grub/cpu/relocator.h>
+#include <grub/extcmd.h>
+#include <grub/verify.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+static struct grub_relocator *rel;
+static grub_uint32_t eip = 0xffffffff;
+
+#define GRUB_PLAN9_TARGET 0x100000
+#define GRUB_PLAN9_ALIGN 4096
+#define GRUB_PLAN9_CONFIG_ADDR 0x001200
+#define GRUB_PLAN9_CONFIG_PATH_SIZE 0x000040
+#define GRUB_PLAN9_CONFIG_MAGIC "ZORT 0\r\n"
+
+static const struct grub_arg_option options[] =
+ {
+ {"map", 'm', GRUB_ARG_OPTION_REPEATABLE,
+ /* TRANSLATORS: it's about guessing which GRUB disk
+ is which Plan9 disk. If your language has no
+ word "mapping" you can use another word which
+ means that the GRUBDEVICE and PLAN9DEVICE are
+ actually the same device, just named differently
+ in OS and GRUB. */
+ N_("Override guessed mapping of Plan9 devices."),
+ N_("GRUBDEVICE=PLAN9DEVICE"),
+ ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+struct grub_plan9_header
+{
+ grub_uint32_t magic;
+#define GRUB_PLAN9_MAGIC 0x1eb
+ grub_uint32_t text_size;
+ grub_uint32_t data_size;
+ grub_uint32_t bss_size;
+ grub_uint32_t sectiona;
+ grub_uint32_t entry_addr;
+ grub_uint32_t zero;
+ grub_uint32_t sectionb;
+};
+
+static grub_err_t
+grub_plan9_boot (void)
+{
+ struct grub_relocator32_state state = {
+ .eax = 0,
+ .eip = eip,
+ .ebx = 0,
+ .ecx = 0,
+ .edx = 0,
+ .edi = 0,
+ .esp = 0,
+ .ebp = 0,
+ .esi = 0
+ };
+ grub_video_set_mode ("text", 0, 0);
+
+ return grub_relocator32_boot (rel, state, 0);
+}
+
+static grub_err_t
+grub_plan9_unload (void)
+{
+ grub_relocator_unload (rel);
+ rel = NULL;
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+/* Context for grub_cmd_plan9. */
+struct grub_cmd_plan9_ctx
+{
+ grub_extcmd_context_t ctxt;
+ grub_file_t file;
+ char *pmap;
+ grub_size_t pmapalloc;
+ grub_size_t pmapptr;
+ int noslash;
+ int prefixescnt[5];
+ char *bootdisk, *bootpart;
+};
+
+static const char prefixes[5][10] = {
+ "dos", "plan9", "ntfs", "linux", "linuxswap"
+};
+
+#include <grub/err.h>
+
+static inline grub_err_t
+grub_extend_alloc (grub_size_t sz, grub_size_t *allocated, char **ptr)
+{
+ void *n;
+ if (sz < *allocated)
+ return GRUB_ERR_NONE;
+
+ *allocated = 2 * sz;
+ n = grub_realloc (*ptr, *allocated);
+ if (!n)
+ return grub_errno;
+ *ptr = n;
+ return GRUB_ERR_NONE;
+}
+
+/* Helper for grub_cmd_plan9. */
+static int
+fill_partition (grub_disk_t disk, const grub_partition_t partition, void *data)
+{
+ struct grub_cmd_plan9_ctx *fill_ctx = data;
+ int file_disk = 0;
+ int pstart, pend;
+
+ if (!fill_ctx->noslash)
+ {
+ if (grub_extend_alloc (fill_ctx->pmapptr + 1, &fill_ctx->pmapalloc,
+ &fill_ctx->pmap))
+ return 1;
+ fill_ctx->pmap[fill_ctx->pmapptr++] = '/';
+ }
+ fill_ctx->noslash = 0;
+
+ file_disk = fill_ctx->file->device->disk
+ && disk->id == fill_ctx->file->device->disk->id
+ && disk->dev->id == fill_ctx->file->device->disk->dev->id;
+
+ pstart = fill_ctx->pmapptr;
+ if (grub_strcmp (partition->partmap->name, "plan") == 0)
+ {
+ unsigned ptr = partition->index + sizeof ("part ") - 1;
+ grub_err_t err;
+ disk->partition = partition->parent;
+ do
+ {
+ if (grub_extend_alloc (fill_ctx->pmapptr + 1, &fill_ctx->pmapalloc,
+ &fill_ctx->pmap))
+ return 1;
+ err = grub_disk_read (disk, 1, ptr, 1,
+ fill_ctx->pmap + fill_ctx->pmapptr);
+ if (err)
+ {
+ disk->partition = 0;
+ return err;
+ }
+ ptr++;
+ fill_ctx->pmapptr++;
+ }
+ while (grub_isalpha (fill_ctx->pmap[fill_ctx->pmapptr - 1])
+ || grub_isdigit (fill_ctx->pmap[fill_ctx->pmapptr - 1]));
+ fill_ctx->pmapptr--;
+ }
+ else
+ {
+ char name[50];
+ int c = 0;
+ if (grub_strcmp (partition->partmap->name, "msdos") == 0)
+ {
+ switch (partition->msdostype)
+ {
+ case GRUB_PC_PARTITION_TYPE_PLAN9:
+ c = 1;
+ break;
+ case GRUB_PC_PARTITION_TYPE_NTFS:
+ c = 2;
+ break;
+ case GRUB_PC_PARTITION_TYPE_MINIX:
+ case GRUB_PC_PARTITION_TYPE_LINUX_MINIX:
+ case GRUB_PC_PARTITION_TYPE_EXT2FS:
+ c = 3;
+ break;
+ case GRUB_PC_PARTITION_TYPE_LINUX_SWAP:
+ c = 4;
+ break;
+ }
+ }
+
+ if (fill_ctx->prefixescnt[c] == 0)
+ grub_strcpy (name, prefixes[c]);
+ else
+ grub_snprintf (name, sizeof (name), "%s.%d", prefixes[c],
+ fill_ctx->prefixescnt[c]);
+ fill_ctx->prefixescnt[c]++;
+ if (grub_extend_alloc (fill_ctx->pmapptr + grub_strlen (name) + 1,
+ &fill_ctx->pmapalloc, &fill_ctx->pmap))
+ return 1;
+ grub_strcpy (fill_ctx->pmap + fill_ctx->pmapptr, name);
+ fill_ctx->pmapptr += grub_strlen (name);
+ }
+ pend = fill_ctx->pmapptr;
+ if (grub_extend_alloc (fill_ctx->pmapptr + 2 + 25 + 5 + 25,
+ &fill_ctx->pmapalloc, &fill_ctx->pmap))
+ return 1;
+ fill_ctx->pmap[fill_ctx->pmapptr++] = ' ';
+ grub_snprintf (fill_ctx->pmap + fill_ctx->pmapptr, 25 + 5 + 25,
+ "%" PRIuGRUB_UINT64_T " %" PRIuGRUB_UINT64_T,
+ grub_partition_get_start (partition),
+ grub_partition_get_start (partition)
+ + grub_partition_get_len (partition));
+ if (file_disk && grub_partition_get_start (partition)
+ == grub_partition_get_start (fill_ctx->file->device->disk->partition)
+ && grub_partition_get_len (partition)
+ == grub_partition_get_len (fill_ctx->file->device->disk->partition))
+ {
+ grub_free (fill_ctx->bootpart);
+ fill_ctx->bootpart = grub_strndup (fill_ctx->pmap + pstart,
+ pend - pstart);
+ }
+
+ fill_ctx->pmapptr += grub_strlen (fill_ctx->pmap + fill_ctx->pmapptr);
+ return 0;
+}
+
+/* Helper for grub_cmd_plan9. */
+static int
+fill_disk (const char *name, void *data)
+{
+ struct grub_cmd_plan9_ctx *fill_ctx = data;
+ grub_device_t dev;
+ char *plan9name = NULL;
+ unsigned i;
+ int file_disk = 0;
+
+ dev = grub_device_open (name);
+ if (!dev)
+ {
+ grub_print_error ();
+ return 0;
+ }
+ if (!dev->disk)
+ {
+ grub_device_close (dev);
+ return 0;
+ }
+ file_disk = fill_ctx->file->device->disk
+ && dev->disk->id == fill_ctx->file->device->disk->id
+ && dev->disk->dev->id == fill_ctx->file->device->disk->dev->id;
+ for (i = 0;
+ fill_ctx->ctxt->state[0].args && fill_ctx->ctxt->state[0].args[i]; i++)
+ if (grub_strncmp (name, fill_ctx->ctxt->state[0].args[i],
+ grub_strlen (name)) == 0
+ && fill_ctx->ctxt->state[0].args[i][grub_strlen (name)] == '=')
+ break;
+ if (fill_ctx->ctxt->state[0].args && fill_ctx->ctxt->state[0].args[i])
+ plan9name = grub_strdup (fill_ctx->ctxt->state[0].args[i]
+ + grub_strlen (name) + 1);
+ else
+ switch (dev->disk->dev->id)
+ {
+ case GRUB_DISK_DEVICE_BIOSDISK_ID:
+ if (dev->disk->id & 0x80)
+ plan9name = grub_xasprintf ("sdB%u",
+ (unsigned) (dev->disk->id & 0x7f));
+ else
+ plan9name = grub_xasprintf ("fd%u",
+ (unsigned) (dev->disk->id & 0x7f));
+ break;
+ /* Shouldn't happen as Plan9 doesn't work on these platforms. */
+ case GRUB_DISK_DEVICE_OFDISK_ID:
+ case GRUB_DISK_DEVICE_EFIDISK_ID:
+
+ /* Plan9 doesn't see those. */
+ default:
+
+ /* Not sure how to handle those. */
+ case GRUB_DISK_DEVICE_NAND_ID:
+ if (!file_disk)
+ {
+ grub_device_close (dev);
+ return 0;
+ }
+
+ /* if it's the disk the kernel is loaded from we need to name
+ it nevertheless. */
+ plan9name = grub_strdup ("sdZ0");
+ break;
+
+ case GRUB_DISK_DEVICE_ATA_ID:
+ {
+ unsigned unit;
+ if (grub_strlen (dev->disk->name) < sizeof ("ata0") - 1)
+ unit = 0;
+ else
+ unit = grub_strtoul (dev->disk->name + sizeof ("ata0") - 1, 0, 0);
+ plan9name = grub_xasprintf ("sd%c%d", 'C' + unit / 2, unit % 2);
+ }
+ break;
+ case GRUB_DISK_DEVICE_SCSI_ID:
+ if (((dev->disk->id >> GRUB_SCSI_ID_SUBSYSTEM_SHIFT) & 0xff)
+ == GRUB_SCSI_SUBSYSTEM_PATA)
+ {
+ unsigned unit;
+ if (grub_strlen (dev->disk->name) < sizeof ("ata0") - 1)
+ unit = 0;
+ else
+ unit = grub_strtoul (dev->disk->name + sizeof ("ata0") - 1,
+ 0, 0);
+ plan9name = grub_xasprintf ("sd%c%d", 'C' + unit / 2, unit % 2);
+ break;
+ }
+
+ /* FIXME: how does Plan9 number controllers?
+ We probably need save the SCSI devices and sort them */
+ plan9name
+ = grub_xasprintf ("sd0%u", (unsigned)
+ ((dev->disk->id >> GRUB_SCSI_ID_BUS_SHIFT)
+ & 0xf));
+ break;
+ }
+ if (!plan9name)
+ {
+ grub_print_error ();
+ grub_device_close (dev);
+ return 0;
+ }
+ if (grub_extend_alloc (fill_ctx->pmapptr + grub_strlen (plan9name)
+ + sizeof ("part="), &fill_ctx->pmapalloc,
+ &fill_ctx->pmap))
+ {
+ grub_free (plan9name);
+ grub_device_close (dev);
+ return 1;
+ }
+ grub_strcpy (fill_ctx->pmap + fill_ctx->pmapptr, plan9name);
+ fill_ctx->pmapptr += grub_strlen (plan9name);
+ if (!file_disk)
+ grub_free (plan9name);
+ else
+ {
+ grub_free (fill_ctx->bootdisk);
+ fill_ctx->bootdisk = plan9name;
+ }
+ grub_strcpy (fill_ctx->pmap + fill_ctx->pmapptr, "part=");
+ fill_ctx->pmapptr += sizeof ("part=") - 1;
+
+ fill_ctx->noslash = 1;
+ grub_memset (fill_ctx->prefixescnt, 0, sizeof (fill_ctx->prefixescnt));
+ if (grub_partition_iterate (dev->disk, fill_partition, fill_ctx))
+ {
+ grub_device_close (dev);
+ return 1;
+ }
+ if (grub_extend_alloc (fill_ctx->pmapptr + 1, &fill_ctx->pmapalloc,
+ &fill_ctx->pmap))
+ {
+ grub_device_close (dev);
+ return 1;
+ }
+ fill_ctx->pmap[fill_ctx->pmapptr++] = '\n';
+
+ grub_device_close (dev);
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_plan9 (grub_extcmd_context_t ctxt, int argc, char *argv[])
+{
+ struct grub_cmd_plan9_ctx fill_ctx = {
+ .ctxt = ctxt,
+ .file = 0,
+ .pmap = NULL,
+ .pmapalloc = 256,
+ .pmapptr = 0,
+ .noslash = 1,
+ .bootdisk = NULL,
+ .bootpart = NULL
+ };
+ void *mem;
+ grub_size_t memsize, padsize;
+ struct grub_plan9_header hdr;
+ char *config, *configptr;
+ grub_size_t configsize;
+ char *bootpath = NULL;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ grub_dl_ref (my_mod);
+
+ rel = grub_relocator_new ();
+ if (!rel)
+ goto fail;
+
+ fill_ctx.file = grub_file_open (argv[0], GRUB_FILE_TYPE_PLAN9_KERNEL);
+ if (! fill_ctx.file)
+ goto fail;
+
+ fill_ctx.pmap = grub_malloc (fill_ctx.pmapalloc);
+ if (!fill_ctx.pmap)
+ goto fail;
+
+ if (grub_disk_dev_iterate (fill_disk, &fill_ctx))
+ goto fail;
+
+ if (grub_extend_alloc (fill_ctx.pmapptr + 1, &fill_ctx.pmapalloc,
+ &fill_ctx.pmap))
+ goto fail;
+ fill_ctx.pmap[fill_ctx.pmapptr] = 0;
+
+ {
+ char *file_name = grub_strchr (argv[0], ')');
+ if (file_name)
+ file_name++;
+ else
+ file_name = argv[0];
+ if (*file_name)
+ file_name++;
+
+ if (fill_ctx.bootpart)
+ bootpath = grub_xasprintf ("%s!%s!%s", fill_ctx.bootdisk,
+ fill_ctx.bootpart, file_name);
+ else
+ bootpath = grub_xasprintf ("%s!%s", fill_ctx.bootdisk, file_name);
+ grub_free (fill_ctx.bootdisk);
+ grub_free (fill_ctx.bootpart);
+ }
+ if (!bootpath)
+ goto fail;
+
+ if (grub_file_read (fill_ctx.file, &hdr,
+ sizeof (hdr)) != (grub_ssize_t) sizeof (hdr))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ argv[0]);
+ goto fail;
+ }
+
+ if (grub_be_to_cpu32 (hdr.magic) != GRUB_PLAN9_MAGIC
+ || hdr.zero)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "unsupported Plan9");
+ goto fail;
+ }
+
+ memsize = ALIGN_UP (grub_be_to_cpu32 (hdr.text_size) + sizeof (hdr),
+ GRUB_PLAN9_ALIGN);
+ memsize += ALIGN_UP (grub_be_to_cpu32 (hdr.data_size), GRUB_PLAN9_ALIGN);
+ memsize += ALIGN_UP(grub_be_to_cpu32 (hdr.bss_size), GRUB_PLAN9_ALIGN);
+ eip = grub_be_to_cpu32 (hdr.entry_addr) & 0xfffffff;
+
+ /* path */
+ configsize = GRUB_PLAN9_CONFIG_PATH_SIZE;
+ /* magic */
+ configsize += sizeof (GRUB_PLAN9_CONFIG_MAGIC) - 1;
+ {
+ int i;
+ for (i = 1; i < argc; i++)
+ configsize += grub_strlen (argv[i]) + 1;
+ }
+ configsize += (sizeof ("bootfile=") - 1) + grub_strlen (bootpath) + 1;
+ configsize += fill_ctx.pmapptr;
+ /* Terminating \0. */
+ configsize++;
+
+ {
+ grub_relocator_chunk_t ch;
+ grub_err_t err;
+ err = grub_relocator_alloc_chunk_addr (rel, &ch, GRUB_PLAN9_CONFIG_ADDR,
+ configsize);
+ if (err)
+ goto fail;
+ config = get_virtual_current_address (ch);
+ }
+
+ grub_memset (config, 0, GRUB_PLAN9_CONFIG_PATH_SIZE);
+ grub_strncpy (config, bootpath, GRUB_PLAN9_CONFIG_PATH_SIZE - 1);
+
+ configptr = config + GRUB_PLAN9_CONFIG_PATH_SIZE;
+ grub_memcpy (configptr, GRUB_PLAN9_CONFIG_MAGIC,
+ sizeof (GRUB_PLAN9_CONFIG_MAGIC) - 1);
+ configptr += sizeof (GRUB_PLAN9_CONFIG_MAGIC) - 1;
+ configptr = grub_stpcpy (configptr, "bootfile=");
+ configptr = grub_stpcpy (configptr, bootpath);
+ *configptr++ = '\n';
+ char *cmdline = configptr;
+ {
+ int i;
+ for (i = 1; i < argc; i++)
+ {
+ configptr = grub_stpcpy (configptr, argv[i]);
+ *configptr++ = '\n';
+ }
+ }
+
+ {
+ grub_err_t err;
+ *configptr = '\0';
+ err = grub_verify_string (cmdline, GRUB_VERIFY_KERNEL_CMDLINE);
+ if (err)
+ goto fail;
+ }
+
+ configptr = grub_stpcpy (configptr, fill_ctx.pmap);
+
+ {
+ grub_relocator_chunk_t ch;
+ grub_err_t err;
+
+ err = grub_relocator_alloc_chunk_addr (rel, &ch, GRUB_PLAN9_TARGET,
+ memsize);
+ if (err)
+ goto fail;
+ mem = get_virtual_current_address (ch);
+ }
+
+ {
+ grub_uint8_t *ptr;
+ ptr = mem;
+ grub_memcpy (ptr, &hdr, sizeof (hdr));
+ ptr += sizeof (hdr);
+
+ if (grub_file_read (fill_ctx.file, ptr, grub_be_to_cpu32 (hdr.text_size))
+ != (grub_ssize_t) grub_be_to_cpu32 (hdr.text_size))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ argv[0]);
+ goto fail;
+ }
+ ptr += grub_be_to_cpu32 (hdr.text_size);
+ padsize = ALIGN_UP (grub_be_to_cpu32 (hdr.text_size) + sizeof (hdr),
+ GRUB_PLAN9_ALIGN) - grub_be_to_cpu32 (hdr.text_size)
+ - sizeof (hdr);
+
+ grub_memset (ptr, 0, padsize);
+ ptr += padsize;
+
+ if (grub_file_read (fill_ctx.file, ptr, grub_be_to_cpu32 (hdr.data_size))
+ != (grub_ssize_t) grub_be_to_cpu32 (hdr.data_size))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ argv[0]);
+ goto fail;
+ }
+ ptr += grub_be_to_cpu32 (hdr.data_size);
+ padsize = ALIGN_UP (grub_be_to_cpu32 (hdr.data_size), GRUB_PLAN9_ALIGN)
+ - grub_be_to_cpu32 (hdr.data_size);
+
+ grub_memset (ptr, 0, padsize);
+ ptr += padsize;
+ grub_memset (ptr, 0, ALIGN_UP(grub_be_to_cpu32 (hdr.bss_size),
+ GRUB_PLAN9_ALIGN));
+ }
+ grub_loader_set (grub_plan9_boot, grub_plan9_unload, 1);
+ return GRUB_ERR_NONE;
+
+ fail:
+ grub_free (fill_ctx.pmap);
+
+ if (fill_ctx.file)
+ grub_file_close (fill_ctx.file);
+
+ grub_plan9_unload ();
+
+ return grub_errno;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(plan9)
+{
+ cmd = grub_register_extcmd ("plan9", grub_cmd_plan9,
+ GRUB_COMMAND_OPTIONS_AT_START,
+ N_("KERNEL ARGS"), N_("Load Plan9 kernel."),
+ options);
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(plan9)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/loader/i386/pc/pxechainloader.c b/grub-core/loader/i386/pc/pxechainloader.c
new file mode 100644
index 0000000..acb0611
--- /dev/null
+++ b/grub-core/loader/i386/pc/pxechainloader.c
@@ -0,0 +1,168 @@
+/* chainloader.c - boot another boot loader */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2007,2009,2010,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/loader.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/partition.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/machine/biosnum.h>
+#include <grub/i18n.h>
+#include <grub/video.h>
+#include <grub/mm.h>
+#include <grub/cpu/relocator.h>
+#include <grub/machine/pxe.h>
+#include <grub/net.h>
+
+static grub_dl_t my_mod;
+static struct grub_relocator *rel;
+static grub_uint32_t edx = 0xffffffff;
+static char boot_file[128];
+static char server_name[64];
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_pxechain_boot (void)
+{
+ struct grub_relocator16_state state = {
+ .cs = 0,
+ .ip = 0x7c00,
+ .ds = 0,
+ .es = 0,
+ .fs = 0,
+ .gs = 0,
+ .ss = 0,
+ .sp = 0x7c00,
+ .edx = edx
+ };
+ struct grub_net_bootp_packet *bp;
+
+ bp = grub_pxe_get_cached (GRUB_PXENV_PACKET_TYPE_DHCP_ACK);
+
+ grub_video_set_mode ("text", 0, 0);
+
+ if (bp && boot_file[0])
+ grub_memcpy (bp->boot_file, boot_file, sizeof (bp->boot_file));
+ if (bp && server_name[0])
+ grub_memcpy (bp->server_name, server_name, sizeof (bp->server_name));
+
+ return grub_relocator16_boot (rel, state);
+}
+
+static grub_err_t
+grub_pxechain_unload (void)
+{
+ grub_relocator_unload (rel);
+ rel = NULL;
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_pxechain (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ grub_err_t err;
+ void *image;
+ grub_size_t imagesize;
+ char *fname;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ grub_dl_ref (my_mod);
+
+ rel = grub_relocator_new ();
+ if (!rel)
+ goto fail;
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_PXECHAINLOADER);
+ if (! file)
+ goto fail;
+
+ if (file->device->net && file->device->net->name)
+ fname = file->device->net->name;
+ else
+ {
+ fname = argv[0];
+ if (fname[0] == '(')
+ {
+ fname = grub_strchr (fname, ')');
+ if (fname)
+ fname++;
+ else
+ fname = argv[0];
+ }
+ }
+
+ grub_memset (boot_file, 0, sizeof (boot_file));
+ grub_strncpy (boot_file, fname, sizeof (boot_file));
+
+ grub_memset (server_name, 0, sizeof (server_name));
+ if (file->device->net && file->device->net->server)
+ grub_strncpy (server_name, file->device->net->server, sizeof (server_name));
+
+ edx = grub_get_root_biosnumber ();
+
+ imagesize = grub_file_size (file);
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (rel, &ch, 0x7c00, imagesize);
+ if (err)
+ goto fail;
+ image = get_virtual_current_address (ch);
+ }
+
+ if (grub_file_read (file, image, imagesize) != (grub_ssize_t) imagesize)
+ goto fail;
+
+ grub_loader_set (grub_pxechain_boot, grub_pxechain_unload,
+ GRUB_LOADER_FLAG_NORETURN | GRUB_LOADER_FLAG_PXE_NOT_UNLOAD);
+ return GRUB_ERR_NONE;
+
+ fail:
+
+ if (file)
+ grub_file_close (file);
+
+ grub_pxechain_unload ();
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(pxechainloader)
+{
+ cmd = grub_register_command ("pxechainloader", grub_cmd_pxechain,
+ 0, N_("Load a PXE image."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(pxechainloader)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/loader/i386/pc/truecrypt.c b/grub-core/loader/i386/pc/truecrypt.c
new file mode 100644
index 0000000..cbeeec7
--- /dev/null
+++ b/grub-core/loader/i386/pc/truecrypt.c
@@ -0,0 +1,233 @@
+/* chainloader.c - boot another boot loader */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2007,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/partition.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/machine/biosnum.h>
+#include <grub/i18n.h>
+#include <grub/video.h>
+#include <grub/mm.h>
+#include <grub/cpu/relocator.h>
+#include <grub/deflate.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+static struct grub_relocator *rel;
+static grub_uint32_t edx = 0xffffffff;
+static grub_uint16_t sp;
+static grub_uint32_t destaddr;
+
+#define GRUB_TRUECRYPT_SEGMENT 0x2000
+
+static grub_err_t
+grub_truecrypt_boot (void)
+{
+ grub_uint16_t segment = destaddr >> 4;
+ struct grub_relocator16_state state = {
+ .cs = segment,
+ .ds = segment,
+ .es = segment,
+ .fs = segment,
+ .gs = segment,
+ .ss = segment,
+ .ip = 0x100,
+ .sp = sp,
+ .edx = edx,
+ .a20 = 1
+ };
+ grub_video_set_mode ("text", 0, 0);
+
+ return grub_relocator16_boot (rel, state);
+}
+
+static grub_err_t
+grub_truecrypt_unload (void)
+{
+ grub_relocator_unload (rel);
+ rel = NULL;
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+/* Information on protocol supplied by Attila Lendvai. */
+#define MAGIC "\0CD001\1EL TORITO SPECIFICATION"
+
+static grub_err_t
+grub_cmd_truecrypt (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ grub_err_t err;
+ void *truecrypt;
+ grub_size_t truecryptsize;
+ const grub_size_t truecryptmemsize = 42 * 1024;
+ grub_uint8_t dh;
+ grub_uint32_t catalog, rba;
+ grub_uint8_t buf[128];
+ char *compressed = NULL;
+ char *uncompressed = NULL;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ rel = NULL;
+
+ grub_dl_ref (my_mod);
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_TRUECRYPT);
+ if (! file)
+ goto fail;
+
+ if (grub_file_seek (file, 17 * 2048) == (grub_size_t) -1)
+ goto fail;
+
+ if (grub_file_read (file, buf, sizeof (buf))
+ != sizeof (buf))
+ goto fail;
+
+ if (grub_memcmp (buf, MAGIC, sizeof (MAGIC)) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "invalid eltorito signature");
+ goto fail;
+ }
+
+ catalog = grub_get_unaligned32 (buf + 0x47);
+
+ if (grub_file_seek (file, catalog * 2048) == (grub_size_t)-1)
+ goto fail;
+
+ if (grub_file_read (file, buf, sizeof (buf))
+ != sizeof (buf))
+ goto fail;
+
+ if (buf[0] != 1 || buf[1] != 0 || buf[0x1e] != 0x55
+ || buf[0x1f] != 0xaa || buf[0x20] != 0x88
+ || buf[0x26] != 1 || buf[0x27] != 0)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "invalid eltorito catalog");
+ goto fail;
+ }
+
+ rba = grub_get_unaligned32 (buf + 0x28);
+
+ if (grub_file_seek (file, rba * 2048 + 0x1b7) == (grub_size_t) -1)
+ goto fail;
+
+ if (grub_file_read (file, &dh, 1)
+ != 1)
+ goto fail;
+
+ if (grub_file_seek (file, rba * 2048 + 512 + 2048) == (grub_size_t) -1)
+ goto fail;
+
+ compressed = grub_malloc (57 * 512);
+ if (!compressed)
+ goto fail;
+
+ if (grub_file_read (file, compressed, 57 * 512)
+ != 57 * 512)
+ goto fail;
+
+ uncompressed = grub_malloc (truecryptmemsize);
+ if (!uncompressed)
+ goto fail;
+
+ /* It's actually gzip but our gzip decompressor isn't able to handle
+ trailing garbage, hence let's use raw decompressor. */
+ truecryptsize = grub_deflate_decompress (compressed + 10, 57 * 512 - 10,
+ 0, uncompressed, truecryptmemsize);
+ if ((grub_ssize_t) truecryptsize < 0)
+ goto fail;
+
+ if (truecryptmemsize <= truecryptsize + 0x100)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "file is too big");
+ goto fail;
+ }
+
+ rel = grub_relocator_new ();
+ if (!rel)
+ goto fail;
+
+ edx = (dh << 8) | grub_get_root_biosnumber ();
+
+ destaddr = ALIGN_DOWN (grub_min (0x90000, grub_mmap_get_lower ())
+ - truecryptmemsize, 64 * 1024);
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (rel, &ch, destaddr,
+ truecryptmemsize);
+ if (err)
+ goto fail;
+ truecrypt = get_virtual_current_address (ch);
+ }
+
+ grub_memset (truecrypt, 0, 0x100);
+ grub_memcpy ((char *) truecrypt + 0x100, uncompressed, truecryptsize);
+
+ grub_memset ((char *) truecrypt + truecryptsize + 0x100,
+ 0, truecryptmemsize - truecryptsize - 0x100);
+ sp = truecryptmemsize - 4;
+
+ grub_loader_set (grub_truecrypt_boot, grub_truecrypt_unload, 1);
+
+ grub_free (uncompressed);
+ grub_free (compressed);
+
+ return GRUB_ERR_NONE;
+
+ fail:
+
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, "bad truecrypt ISO");
+
+ if (file)
+ grub_file_close (file);
+
+ grub_truecrypt_unload ();
+
+ grub_free (uncompressed);
+ grub_free (compressed);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(truecrypt)
+{
+ cmd = grub_register_command ("truecrypt", grub_cmd_truecrypt,
+ 0, N_("Load Truecrypt ISO."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(truecrypt)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c
new file mode 100644
index 0000000..cd24874
--- /dev/null
+++ b/grub-core/loader/i386/xen.c
@@ -0,0 +1,986 @@
+/*
+ * 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/loader.h>
+#include <grub/memory.h>
+#include <grub/normal.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+#include <grub/cpu/linux.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/command.h>
+#include <grub/xen/relocator.h>
+#include <grub/i18n.h>
+#include <grub/elf.h>
+#include <grub/elfload.h>
+#include <grub/lib/cmdline.h>
+#include <grub/xen.h>
+#include <grub/xen_file.h>
+#include <grub/linux.h>
+#include <grub/i386/memory.h>
+#include <grub/verify.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#ifdef __x86_64__
+#define NUMBER_OF_LEVELS 4
+#define INTERMEDIATE_OR (GRUB_PAGE_PRESENT | GRUB_PAGE_RW | GRUB_PAGE_USER)
+#define VIRT_MASK 0x0000ffffffffffffULL
+#else
+#define NUMBER_OF_LEVELS 3
+#define INTERMEDIATE_OR (GRUB_PAGE_PRESENT | GRUB_PAGE_RW)
+#define VIRT_MASK 0x00000000ffffffffULL
+#define HYPERVISOR_PUD_ADDRESS 0xc0000000ULL
+#endif
+
+struct grub_xen_mapping_lvl {
+ grub_uint64_t virt_start;
+ grub_uint64_t virt_end;
+ grub_uint64_t pfn_start;
+ grub_uint64_t n_pt_pages;
+};
+
+struct grub_xen_mapping {
+ grub_uint64_t *where;
+ struct grub_xen_mapping_lvl area;
+ struct grub_xen_mapping_lvl lvls[NUMBER_OF_LEVELS];
+};
+
+struct xen_loader_state {
+ struct grub_relocator *relocator;
+ struct grub_relocator_xen_state state;
+ struct start_info next_start;
+ struct grub_xen_file_info xen_inf;
+ grub_xen_mfn_t *virt_mfn_list;
+ struct start_info *virt_start_info;
+ grub_xen_mfn_t console_pfn;
+ grub_uint64_t max_addr;
+ grub_uint64_t pgtbl_end;
+ struct xen_multiboot_mod_list *module_info_page;
+ grub_uint64_t modules_target_start;
+ grub_size_t n_modules;
+ struct grub_xen_mapping *map_reloc;
+ struct grub_xen_mapping mappings[XEN_MAX_MAPPINGS];
+ int n_mappings;
+ int loaded;
+};
+
+static struct xen_loader_state xen_state;
+
+static grub_dl_t my_mod;
+
+#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define MAX_MODULES (PAGE_SIZE / sizeof (struct xen_multiboot_mod_list))
+#define STACK_SIZE 1048576
+#define ADDITIONAL_SIZE (1 << 19)
+#define ALIGN_SIZE (1 << 22)
+#define LOG_POINTERS_PER_PAGE 9
+#define POINTERS_PER_PAGE (1 << LOG_POINTERS_PER_PAGE)
+
+static grub_uint64_t
+page2offset (grub_uint64_t page)
+{
+ return page << PAGE_SHIFT;
+}
+
+static grub_err_t
+get_pgtable_size (grub_uint64_t from, grub_uint64_t to, grub_uint64_t pfn)
+{
+ struct grub_xen_mapping *map, *map_cmp;
+ grub_uint64_t mask, bits;
+ int i, m;
+
+ if (xen_state.n_mappings == XEN_MAX_MAPPINGS)
+ return grub_error (GRUB_ERR_BUG, "too many mapped areas");
+
+ grub_dprintf ("xen", "get_pgtable_size %d from=%llx, to=%llx, pfn=%llx\n",
+ xen_state.n_mappings, (unsigned long long) from,
+ (unsigned long long) to, (unsigned long long) pfn);
+
+ map = xen_state.mappings + xen_state.n_mappings;
+ grub_memset (map, 0, sizeof (*map));
+
+ map->area.virt_start = from & VIRT_MASK;
+ map->area.virt_end = (to - 1) & VIRT_MASK;
+ map->area.n_pt_pages = 0;
+
+ for (i = NUMBER_OF_LEVELS - 1; i >= 0; i--)
+ {
+ map->lvls[i].pfn_start = pfn + map->area.n_pt_pages;
+ if (i == NUMBER_OF_LEVELS - 1)
+ {
+ if (xen_state.n_mappings == 0)
+ {
+ map->lvls[i].virt_start = 0;
+ map->lvls[i].virt_end = VIRT_MASK;
+ map->lvls[i].n_pt_pages = 1;
+ map->area.n_pt_pages++;
+ }
+ continue;
+ }
+
+ bits = PAGE_SHIFT + (i + 1) * LOG_POINTERS_PER_PAGE;
+ mask = (1ULL << bits) - 1;
+ map->lvls[i].virt_start = map->area.virt_start & ~mask;
+ map->lvls[i].virt_end = map->area.virt_end | mask;
+#ifdef __i386__
+ /* PAE wants last root directory present. */
+ if (i == 1 && to <= HYPERVISOR_PUD_ADDRESS && xen_state.n_mappings == 0)
+ map->lvls[i].virt_end = VIRT_MASK;
+#endif
+ for (m = 0; m < xen_state.n_mappings; m++)
+ {
+ map_cmp = xen_state.mappings + m;
+ if (map_cmp->lvls[i].virt_start == map_cmp->lvls[i].virt_end)
+ continue;
+ if (map->lvls[i].virt_start >= map_cmp->lvls[i].virt_start &&
+ map->lvls[i].virt_end <= map_cmp->lvls[i].virt_end)
+ {
+ map->lvls[i].virt_start = 0;
+ map->lvls[i].virt_end = 0;
+ break;
+ }
+ if (map->lvls[i].virt_start >= map_cmp->lvls[i].virt_start &&
+ map->lvls[i].virt_start <= map_cmp->lvls[i].virt_end)
+ map->lvls[i].virt_start = map_cmp->lvls[i].virt_end + 1;
+ if (map->lvls[i].virt_end >= map_cmp->lvls[i].virt_start &&
+ map->lvls[i].virt_end <= map_cmp->lvls[i].virt_end)
+ map->lvls[i].virt_end = map_cmp->lvls[i].virt_start - 1;
+ }
+ if (map->lvls[i].virt_start < map->lvls[i].virt_end)
+ map->lvls[i].n_pt_pages =
+ ((map->lvls[i].virt_end - map->lvls[i].virt_start) >> bits) + 1;
+ map->area.n_pt_pages += map->lvls[i].n_pt_pages;
+ grub_dprintf ("xen", "get_pgtable_size level %d: virt %llx-%llx %d pts\n",
+ i, (unsigned long long) map->lvls[i].virt_start,
+ (unsigned long long) map->lvls[i].virt_end,
+ (int) map->lvls[i].n_pt_pages);
+ }
+
+ grub_dprintf ("xen", "get_pgtable_size return: %d page tables\n",
+ (int) map->area.n_pt_pages);
+
+ xen_state.state.paging_start[xen_state.n_mappings] = pfn;
+ xen_state.state.paging_size[xen_state.n_mappings] = map->area.n_pt_pages;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_uint64_t *
+get_pg_table_virt (int mapping, int level)
+{
+ grub_uint64_t pfn;
+ struct grub_xen_mapping *map;
+
+ map = xen_state.mappings + mapping;
+ pfn = map->lvls[level].pfn_start - map->lvls[NUMBER_OF_LEVELS - 1].pfn_start;
+ return map->where + pfn * POINTERS_PER_PAGE;
+}
+
+static grub_uint64_t
+get_pg_table_prot (int level, grub_uint64_t pfn)
+{
+ int m;
+ grub_uint64_t pfn_s, pfn_e;
+
+ if (level > 0)
+ return INTERMEDIATE_OR;
+ for (m = 0; m < xen_state.n_mappings; m++)
+ {
+ pfn_s = xen_state.mappings[m].lvls[NUMBER_OF_LEVELS - 1].pfn_start;
+ pfn_e = xen_state.mappings[m].area.n_pt_pages + pfn_s;
+ if (pfn >= pfn_s && pfn < pfn_e)
+ return GRUB_PAGE_PRESENT | GRUB_PAGE_USER;
+ }
+ return GRUB_PAGE_PRESENT | GRUB_PAGE_RW | GRUB_PAGE_USER;
+}
+
+static void
+generate_page_table (grub_xen_mfn_t *mfn_list)
+{
+ int l, m1, m2;
+ long p, p_s, p_e;
+ grub_uint64_t start, end, pfn;
+ grub_uint64_t *pg;
+ struct grub_xen_mapping_lvl *lvl;
+
+ for (m1 = 0; m1 < xen_state.n_mappings; m1++)
+ grub_memset (xen_state.mappings[m1].where, 0,
+ xen_state.mappings[m1].area.n_pt_pages * PAGE_SIZE);
+
+ for (l = NUMBER_OF_LEVELS - 1; l >= 0; l--)
+ {
+ for (m1 = 0; m1 < xen_state.n_mappings; m1++)
+ {
+ start = xen_state.mappings[m1].lvls[l].virt_start;
+ end = xen_state.mappings[m1].lvls[l].virt_end;
+ pg = get_pg_table_virt(m1, l);
+ for (m2 = 0; m2 < xen_state.n_mappings; m2++)
+ {
+ lvl = (l > 0) ? xen_state.mappings[m2].lvls + l - 1
+ : &xen_state.mappings[m2].area;
+ if (l > 0 && lvl->n_pt_pages == 0)
+ continue;
+ if (lvl->virt_start >= end || lvl->virt_end <= start)
+ continue;
+ p_s = (grub_max (start, lvl->virt_start) - start) >>
+ (PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE);
+ p_e = (grub_min (end, lvl->virt_end) - start) >>
+ (PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE);
+ pfn = ((grub_max (start, lvl->virt_start) - lvl->virt_start) >>
+ (PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE)) + lvl->pfn_start;
+ grub_dprintf ("xen", "write page table entries level %d pg %p "
+ "mapping %d/%d index %lx-%lx pfn %llx\n",
+ l, pg, m1, m2, p_s, p_e, (unsigned long long) pfn);
+ for (p = p_s; p <= p_e; p++)
+ {
+ pg[p] = page2offset (mfn_list[pfn]) |
+ get_pg_table_prot (l, pfn);
+ pfn++;
+ }
+ }
+ }
+ }
+}
+
+static grub_err_t
+set_mfns (grub_xen_mfn_t pfn)
+{
+ grub_xen_mfn_t i, t;
+ grub_xen_mfn_t cn_pfn = -1, st_pfn = -1;
+ struct mmu_update m2p_updates[4];
+
+
+ for (i = 0; i < grub_xen_start_page_addr->nr_pages; i++)
+ {
+ if (xen_state.virt_mfn_list[i] ==
+ grub_xen_start_page_addr->console.domU.mfn)
+ cn_pfn = i;
+ if (xen_state.virt_mfn_list[i] == grub_xen_start_page_addr->store_mfn)
+ st_pfn = i;
+ }
+ if (cn_pfn == (grub_xen_mfn_t)-1)
+ return grub_error (GRUB_ERR_BUG, "no console");
+ if (st_pfn == (grub_xen_mfn_t)-1)
+ return grub_error (GRUB_ERR_BUG, "no store");
+ t = xen_state.virt_mfn_list[pfn];
+ xen_state.virt_mfn_list[pfn] = xen_state.virt_mfn_list[cn_pfn];
+ xen_state.virt_mfn_list[cn_pfn] = t;
+ t = xen_state.virt_mfn_list[pfn + 1];
+ xen_state.virt_mfn_list[pfn + 1] = xen_state.virt_mfn_list[st_pfn];
+ xen_state.virt_mfn_list[st_pfn] = t;
+
+ m2p_updates[0].ptr =
+ page2offset (xen_state.virt_mfn_list[pfn]) | MMU_MACHPHYS_UPDATE;
+ m2p_updates[0].val = pfn;
+ m2p_updates[1].ptr =
+ page2offset (xen_state.virt_mfn_list[pfn + 1]) | MMU_MACHPHYS_UPDATE;
+ m2p_updates[1].val = pfn + 1;
+ m2p_updates[2].ptr =
+ page2offset (xen_state.virt_mfn_list[cn_pfn]) | MMU_MACHPHYS_UPDATE;
+ m2p_updates[2].val = cn_pfn;
+ m2p_updates[3].ptr =
+ page2offset (xen_state.virt_mfn_list[st_pfn]) | MMU_MACHPHYS_UPDATE;
+ m2p_updates[3].val = st_pfn;
+
+ grub_xen_mmu_update (m2p_updates, 4, NULL, DOMID_SELF);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_xen_p2m_alloc (void)
+{
+ grub_relocator_chunk_t ch;
+ grub_size_t p2msize, p2malloc;
+ grub_err_t err;
+ struct grub_xen_mapping *map;
+
+ if (xen_state.virt_mfn_list)
+ return GRUB_ERR_NONE;
+
+ map = xen_state.mappings + xen_state.n_mappings;
+ p2msize = ALIGN_UP (sizeof (grub_xen_mfn_t) *
+ grub_xen_start_page_addr->nr_pages, PAGE_SIZE);
+ if (xen_state.xen_inf.has_p2m_base)
+ {
+ err = get_pgtable_size (xen_state.xen_inf.p2m_base,
+ xen_state.xen_inf.p2m_base + p2msize,
+ (xen_state.max_addr + p2msize) >> PAGE_SHIFT);
+ if (err)
+ return err;
+
+ map->area.pfn_start = xen_state.max_addr >> PAGE_SHIFT;
+ p2malloc = p2msize + page2offset (map->area.n_pt_pages);
+ xen_state.n_mappings++;
+ xen_state.next_start.mfn_list = xen_state.xen_inf.p2m_base;
+ xen_state.next_start.first_p2m_pfn = map->area.pfn_start;
+ xen_state.next_start.nr_p2m_frames = p2malloc >> PAGE_SHIFT;
+ }
+ else
+ {
+ xen_state.next_start.mfn_list =
+ xen_state.max_addr + xen_state.xen_inf.virt_base;
+ p2malloc = p2msize;
+ }
+
+ xen_state.state.mfn_list = xen_state.max_addr;
+ err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch,
+ xen_state.max_addr, p2malloc);
+ if (err)
+ return err;
+ xen_state.virt_mfn_list = get_virtual_current_address (ch);
+ if (xen_state.xen_inf.has_p2m_base)
+ map->where = (grub_uint64_t *) xen_state.virt_mfn_list +
+ p2msize / sizeof (grub_uint64_t);
+ grub_memcpy (xen_state.virt_mfn_list,
+ (void *) grub_xen_start_page_addr->mfn_list, p2msize);
+ xen_state.max_addr += p2malloc;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_xen_special_alloc (void)
+{
+ grub_relocator_chunk_t ch;
+ grub_err_t err;
+
+ if (xen_state.virt_start_info)
+ return GRUB_ERR_NONE;
+
+ err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch,
+ xen_state.max_addr,
+ sizeof (xen_state.next_start));
+ if (err)
+ return err;
+ xen_state.state.start_info = xen_state.max_addr + xen_state.xen_inf.virt_base;
+ xen_state.virt_start_info = get_virtual_current_address (ch);
+ xen_state.max_addr =
+ ALIGN_UP (xen_state.max_addr + sizeof (xen_state.next_start), PAGE_SIZE);
+ xen_state.console_pfn = xen_state.max_addr >> PAGE_SHIFT;
+ xen_state.max_addr += 2 * PAGE_SIZE;
+
+ xen_state.next_start.nr_pages = grub_xen_start_page_addr->nr_pages;
+ grub_memcpy (xen_state.next_start.magic, grub_xen_start_page_addr->magic,
+ sizeof (xen_state.next_start.magic));
+ xen_state.next_start.store_mfn = grub_xen_start_page_addr->store_mfn;
+ xen_state.next_start.store_evtchn = grub_xen_start_page_addr->store_evtchn;
+ xen_state.next_start.console.domU = grub_xen_start_page_addr->console.domU;
+ xen_state.next_start.shared_info = grub_xen_start_page_addr->shared_info;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_xen_pt_alloc (void)
+{
+ grub_relocator_chunk_t ch;
+ grub_err_t err;
+ grub_uint64_t nr_info_pages;
+ grub_uint64_t nr_need_pages;
+ grub_uint64_t try_virt_end;
+ struct grub_xen_mapping *map;
+
+ if (xen_state.pgtbl_end)
+ return GRUB_ERR_NONE;
+
+ map = xen_state.mappings + xen_state.n_mappings;
+ xen_state.map_reloc = map + 1;
+
+ xen_state.next_start.pt_base =
+ xen_state.max_addr + xen_state.xen_inf.virt_base;
+ nr_info_pages = xen_state.max_addr >> PAGE_SHIFT;
+ nr_need_pages = nr_info_pages;
+
+ while (1)
+ {
+ try_virt_end = ALIGN_UP (xen_state.xen_inf.virt_base +
+ page2offset (nr_need_pages) +
+ ADDITIONAL_SIZE + STACK_SIZE, ALIGN_SIZE);
+
+ err = get_pgtable_size (xen_state.xen_inf.virt_base, try_virt_end,
+ nr_info_pages);
+ if (err)
+ return err;
+ xen_state.n_mappings++;
+
+ /* Map the relocator page either at virtual 0 or after end of area. */
+ nr_need_pages = nr_info_pages + map->area.n_pt_pages;
+ if (xen_state.xen_inf.virt_base)
+ err = get_pgtable_size (0, PAGE_SIZE, nr_need_pages);
+ else
+ err = get_pgtable_size (try_virt_end, try_virt_end + PAGE_SIZE,
+ nr_need_pages);
+ if (err)
+ return err;
+ nr_need_pages += xen_state.map_reloc->area.n_pt_pages;
+
+ if (xen_state.xen_inf.virt_base + page2offset (nr_need_pages) <=
+ try_virt_end)
+ break;
+
+ xen_state.n_mappings--;
+ }
+
+ xen_state.n_mappings++;
+ nr_need_pages = map->area.n_pt_pages + xen_state.map_reloc->area.n_pt_pages;
+ err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch,
+ xen_state.max_addr,
+ page2offset (nr_need_pages));
+ if (err)
+ return err;
+
+ map->where = get_virtual_current_address (ch);
+ map->area.pfn_start = 0;
+ xen_state.max_addr += page2offset (nr_need_pages);
+ xen_state.state.stack =
+ xen_state.max_addr + STACK_SIZE + xen_state.xen_inf.virt_base;
+ xen_state.next_start.nr_pt_frames = nr_need_pages;
+ xen_state.max_addr = try_virt_end - xen_state.xen_inf.virt_base;
+ xen_state.pgtbl_end = xen_state.max_addr >> PAGE_SHIFT;
+ xen_state.map_reloc->where = (grub_uint64_t *) ((char *) map->where +
+ page2offset (map->area.n_pt_pages));
+
+ return GRUB_ERR_NONE;
+}
+
+/* Allocate all not yet allocated areas mapped by initial page tables. */
+static grub_err_t
+grub_xen_alloc_boot_data (void)
+{
+ grub_err_t err;
+
+ if (!xen_state.xen_inf.has_p2m_base)
+ {
+ err = grub_xen_p2m_alloc ();
+ if (err)
+ return err;
+ }
+ err = grub_xen_special_alloc ();
+ if (err)
+ return err;
+ err = grub_xen_pt_alloc ();
+ if (err)
+ return err;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_xen_boot (void)
+{
+ grub_err_t err;
+ grub_uint64_t nr_pages;
+ struct gnttab_set_version gnttab_setver;
+ grub_size_t i;
+
+ if (grub_xen_n_allocated_shared_pages)
+ return grub_error (GRUB_ERR_BUG, "active grants");
+
+ err = grub_xen_alloc_boot_data ();
+ if (err)
+ return err;
+ if (xen_state.xen_inf.has_p2m_base)
+ {
+ err = grub_xen_p2m_alloc ();
+ if (err)
+ return err;
+ }
+
+ err = set_mfns (xen_state.console_pfn);
+ if (err)
+ return err;
+
+ nr_pages = xen_state.max_addr >> PAGE_SHIFT;
+
+ grub_dprintf ("xen", "bootstrap domain %llx+%llx\n",
+ (unsigned long long) xen_state.xen_inf.virt_base,
+ (unsigned long long) page2offset (nr_pages));
+
+ xen_state.map_reloc->area.pfn_start = nr_pages;
+ generate_page_table (xen_state.virt_mfn_list);
+
+ xen_state.state.entry_point = xen_state.xen_inf.entry_point;
+
+ *xen_state.virt_start_info = xen_state.next_start;
+
+ grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver));
+
+ gnttab_setver.version = 1;
+ grub_xen_grant_table_op (GNTTABOP_set_version, &gnttab_setver, 1);
+
+ for (i = 0; i < ARRAY_SIZE (grub_xen_shared_info->evtchn_pending); i++)
+ grub_xen_shared_info->evtchn_pending[i] = 0;
+
+ return grub_relocator_xen_boot (xen_state.relocator, xen_state.state, nr_pages,
+ xen_state.xen_inf.virt_base <
+ PAGE_SIZE ? page2offset (nr_pages) : 0,
+ xen_state.pgtbl_end - 1,
+ page2offset (xen_state.pgtbl_end - 1) +
+ xen_state.xen_inf.virt_base);
+}
+
+static void
+grub_xen_reset (void)
+{
+ grub_relocator_unload (xen_state.relocator);
+
+ grub_memset (&xen_state, 0, sizeof (xen_state));
+}
+
+static grub_err_t
+grub_xen_unload (void)
+{
+ grub_xen_reset ();
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+#define HYPERCALL_INTERFACE_SIZE 32
+
+#ifdef __x86_64__
+static grub_uint8_t template[] =
+ {
+ 0x51, /* push %rcx */
+ 0x41, 0x53, /* push %r11 */
+ 0x48, 0xc7, 0xc0, 0xbb, 0xaa, 0x00, 0x00, /* mov $0xaabb,%rax */
+ 0x0f, 0x05, /* syscall */
+ 0x41, 0x5b, /* pop %r11 */
+ 0x59, /* pop %rcx */
+ 0xc3 /* ret */
+ };
+
+static grub_uint8_t template_iret[] =
+ {
+ 0x51, /* push %rcx */
+ 0x41, 0x53, /* push %r11 */
+ 0x50, /* push %rax */
+ 0x48, 0xc7, 0xc0, 0x17, 0x00, 0x00, 0x00, /* mov $0x17,%rax */
+ 0x0f, 0x05 /* syscall */
+ };
+#define CALLNO_OFFSET 6
+#else
+
+static grub_uint8_t template[] =
+ {
+ 0xb8, 0xbb, 0xaa, 0x00, 0x00, /* mov imm32, %eax */
+ 0xcd, 0x82, /* int $0x82 */
+ 0xc3 /* ret */
+ };
+
+static grub_uint8_t template_iret[] =
+ {
+ 0x50, /* push %eax */
+ 0xb8, 0x17, 0x00, 0x00, 0x00, /* mov $0x17,%eax */
+ 0xcd, 0x82, /* int $0x82 */
+ };
+#define CALLNO_OFFSET 1
+
+#endif
+
+
+static void
+set_hypercall_interface (grub_uint8_t *tgt, unsigned callno)
+{
+ if (callno == 0x17)
+ {
+ grub_memcpy (tgt, template_iret, ARRAY_SIZE (template_iret));
+ grub_memset (tgt + ARRAY_SIZE (template_iret), 0xcc,
+ HYPERCALL_INTERFACE_SIZE - ARRAY_SIZE (template_iret));
+ return;
+ }
+ grub_memcpy (tgt, template, ARRAY_SIZE (template));
+ grub_memset (tgt + ARRAY_SIZE (template), 0xcc,
+ HYPERCALL_INTERFACE_SIZE - ARRAY_SIZE (template));
+ tgt[CALLNO_OFFSET] = callno & 0xff;
+ tgt[CALLNO_OFFSET + 1] = callno >> 8;
+}
+
+#ifdef __x86_64__
+#define grub_elfXX_load grub_elf64_load
+#else
+#define grub_elfXX_load grub_elf32_load
+#endif
+
+static grub_err_t
+grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file;
+ grub_elf_t elf;
+ grub_err_t err;
+ void *kern_chunk_src;
+ grub_relocator_chunk_t ch;
+ grub_addr_t kern_start;
+ grub_addr_t kern_end;
+ grub_size_t sz;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ /* Call grub_loader_unset early to avoid it being called by grub_loader_set */
+ grub_loader_unset ();
+
+ grub_xen_reset ();
+
+ err = grub_create_loader_cmdline (argc - 1, argv + 1,
+ (char *) xen_state.next_start.cmd_line,
+ sizeof (xen_state.next_start.cmd_line) - 1,
+ GRUB_VERIFY_KERNEL_CMDLINE);
+ if (err)
+ return err;
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
+ if (!file)
+ return grub_errno;
+
+ elf = grub_xen_file (file);
+ if (!elf)
+ goto fail;
+
+ err = grub_xen_get_info (elf, &xen_state.xen_inf);
+ if (err)
+ goto fail;
+#ifdef __x86_64__
+ if (xen_state.xen_inf.arch != GRUB_XEN_FILE_X86_64)
+#else
+ if (xen_state.xen_inf.arch != GRUB_XEN_FILE_I386_PAE
+ && xen_state.xen_inf.arch != GRUB_XEN_FILE_I386_PAE_BIMODE)
+#endif
+ {
+ grub_error (GRUB_ERR_BAD_OS, "incompatible architecture: %d",
+ xen_state.xen_inf.arch);
+ goto fail;
+ }
+
+ if (xen_state.xen_inf.virt_base & (PAGE_SIZE - 1))
+ {
+ grub_error (GRUB_ERR_BAD_OS, "unaligned virt_base");
+ goto fail;
+ }
+ grub_dprintf ("xen", "virt_base = %llx, entry = %llx\n",
+ (unsigned long long) xen_state.xen_inf.virt_base,
+ (unsigned long long) xen_state.xen_inf.entry_point);
+
+ xen_state.relocator = grub_relocator_new ();
+ if (!xen_state.relocator)
+ goto fail;
+
+ kern_start = xen_state.xen_inf.kern_start - xen_state.xen_inf.paddr_offset;
+ kern_end = xen_state.xen_inf.kern_end - xen_state.xen_inf.paddr_offset;
+
+ if (xen_state.xen_inf.has_hypercall_page)
+ {
+ grub_dprintf ("xen", "hypercall page at 0x%llx\n",
+ (unsigned long long) xen_state.xen_inf.hypercall_page);
+ kern_start = grub_min (kern_start, xen_state.xen_inf.hypercall_page -
+ xen_state.xen_inf.virt_base);
+ kern_end = grub_max (kern_end, xen_state.xen_inf.hypercall_page -
+ xen_state.xen_inf.virt_base + PAGE_SIZE);
+ }
+
+ xen_state.max_addr = ALIGN_UP (kern_end, PAGE_SIZE);
+
+
+ if (grub_sub (kern_end, kern_start, &sz))
+ {
+ err = GRUB_ERR_OUT_OF_RANGE;
+ goto fail;
+ }
+
+ err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, kern_start, sz);
+ if (err)
+ goto fail;
+ kern_chunk_src = get_virtual_current_address (ch);
+
+ grub_dprintf ("xen", "paddr_offset = 0x%llx\n",
+ (unsigned long long) xen_state.xen_inf.paddr_offset);
+ grub_dprintf ("xen", "kern_start = 0x%llx, kern_end = 0x%llx\n",
+ (unsigned long long) xen_state.xen_inf.kern_start,
+ (unsigned long long) xen_state.xen_inf.kern_end);
+
+ err = grub_elfXX_load (elf, argv[0],
+ (grub_uint8_t *) kern_chunk_src - kern_start
+ - xen_state.xen_inf.paddr_offset, 0, 0, 0);
+
+ if (xen_state.xen_inf.has_hypercall_page)
+ {
+ unsigned i;
+ for (i = 0; i < PAGE_SIZE / HYPERCALL_INTERFACE_SIZE; i++)
+ set_hypercall_interface ((grub_uint8_t *) kern_chunk_src +
+ i * HYPERCALL_INTERFACE_SIZE +
+ xen_state.xen_inf.hypercall_page -
+ xen_state.xen_inf.virt_base - kern_start, i);
+ }
+
+ if (err)
+ goto fail;
+
+ grub_dl_ref (my_mod);
+ xen_state.loaded = 1;
+
+ grub_loader_set (grub_xen_boot, grub_xen_unload, 0);
+
+ goto fail;
+
+fail:
+ /* grub_errno might be clobbered by further calls, save the error reason. */
+ err = grub_errno;
+
+ if (elf)
+ grub_elf_close (elf);
+ else if (file)
+ grub_file_close (file);
+
+ if (err != GRUB_ERR_NONE)
+ grub_xen_reset ();
+
+ return err;
+}
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_size_t size = 0;
+ grub_err_t err;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
+ grub_relocator_chunk_t ch;
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ if (!xen_state.loaded)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("you need to load the kernel first"));
+ goto fail;
+ }
+
+ if (xen_state.next_start.mod_start || xen_state.next_start.mod_len)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("initrd already loaded"));
+ goto fail;
+ }
+
+ if (xen_state.xen_inf.unmapped_initrd)
+ {
+ err = grub_xen_alloc_boot_data ();
+ if (err)
+ goto fail;
+ }
+
+ if (grub_initrd_init (argc, argv, &initrd_ctx))
+ goto fail;
+
+ size = grub_get_initrd_size (&initrd_ctx);
+
+ if (size)
+ {
+ err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch,
+ xen_state.max_addr, size);
+ if (err)
+ goto fail;
+
+ if (grub_initrd_load (&initrd_ctx, argv,
+ get_virtual_current_address (ch)))
+ goto fail;
+ }
+
+ xen_state.next_start.mod_len = size;
+
+ if (xen_state.xen_inf.unmapped_initrd)
+ {
+ xen_state.next_start.flags |= SIF_MOD_START_PFN;
+ xen_state.next_start.mod_start = xen_state.max_addr >> PAGE_SHIFT;
+ }
+ else
+ xen_state.next_start.mod_start =
+ xen_state.max_addr + xen_state.xen_inf.virt_base;
+
+ grub_dprintf ("xen", "Initrd, addr=0x%x, size=0x%x\n",
+ (unsigned) (xen_state.max_addr + xen_state.xen_inf.virt_base),
+ (unsigned) size);
+
+ xen_state.max_addr = ALIGN_UP (xen_state.max_addr + size, PAGE_SIZE);
+
+fail:
+ grub_initrd_close (&initrd_ctx);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_size_t size = 0;
+ grub_err_t err;
+ grub_relocator_chunk_t ch;
+ grub_size_t cmdline_len;
+ int nounzip = 0;
+ grub_file_t file;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if (grub_strcmp (argv[0], "--nounzip") == 0)
+ {
+ argv++;
+ argc--;
+ nounzip = 1;
+ }
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if (!xen_state.loaded)
+ {
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("you need to load the kernel first"));
+ }
+
+ if ((xen_state.next_start.mod_start || xen_state.next_start.mod_len) &&
+ !xen_state.module_info_page)
+ {
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("initrd already loaded"));
+ }
+
+ /* Leave one space for terminator. */
+ if (xen_state.n_modules >= MAX_MODULES - 1)
+ {
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many modules");
+ }
+
+ if (!xen_state.module_info_page)
+ {
+ xen_state.xen_inf.unmapped_initrd = 0;
+ xen_state.n_modules = 0;
+ xen_state.max_addr = ALIGN_UP (xen_state.max_addr, PAGE_SIZE);
+ xen_state.modules_target_start = xen_state.max_addr;
+ xen_state.next_start.mod_start =
+ xen_state.max_addr + xen_state.xen_inf.virt_base;
+ xen_state.next_start.flags |= SIF_MULTIBOOT_MOD;
+
+ err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch,
+ xen_state.max_addr, MAX_MODULES
+ *
+ sizeof (xen_state.module_info_page
+ [0]));
+ if (err)
+ return err;
+ xen_state.module_info_page = get_virtual_current_address (ch);
+ grub_memset (xen_state.module_info_page, 0, MAX_MODULES
+ * sizeof (xen_state.module_info_page[0]));
+ xen_state.max_addr +=
+ MAX_MODULES * sizeof (xen_state.module_info_page[0]);
+ }
+
+ xen_state.max_addr = ALIGN_UP (xen_state.max_addr, PAGE_SIZE);
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_INITRD |
+ (nounzip ? GRUB_FILE_TYPE_NO_DECOMPRESS : GRUB_FILE_TYPE_NONE));
+ if (!file)
+ return grub_errno;
+ size = grub_file_size (file);
+
+ cmdline_len = grub_loader_cmdline_size (argc - 1, argv + 1);
+
+ err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch,
+ xen_state.max_addr, cmdline_len);
+ if (err)
+ goto fail;
+
+ err = grub_create_loader_cmdline (argc - 1, argv + 1,
+ get_virtual_current_address (ch), cmdline_len,
+ GRUB_VERIFY_MODULE_CMDLINE);
+ if (err)
+ goto fail;
+
+ xen_state.module_info_page[xen_state.n_modules].cmdline =
+ xen_state.max_addr - xen_state.modules_target_start;
+ xen_state.max_addr = ALIGN_UP (xen_state.max_addr + cmdline_len, PAGE_SIZE);
+
+ if (size)
+ {
+ err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch,
+ xen_state.max_addr, size);
+ if (err)
+ goto fail;
+ if (grub_file_read (file, get_virtual_current_address (ch), size)
+ != (grub_ssize_t) size)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR,
+ N_("premature end of file %s"), argv[0]);
+ goto fail;
+ }
+ }
+ xen_state.next_start.mod_len =
+ xen_state.max_addr + size - xen_state.modules_target_start;
+ xen_state.module_info_page[xen_state.n_modules].mod_start =
+ xen_state.max_addr - xen_state.modules_target_start;
+ xen_state.module_info_page[xen_state.n_modules].mod_end =
+ xen_state.max_addr + size - xen_state.modules_target_start;
+
+ xen_state.n_modules++;
+ grub_dprintf ("xen", "module, addr=0x%x, size=0x%x\n",
+ (unsigned) xen_state.max_addr, (unsigned) size);
+ xen_state.max_addr = ALIGN_UP (xen_state.max_addr + size, PAGE_SIZE);
+
+
+fail:
+ grub_file_close (file);
+
+ return grub_errno;
+}
+
+static grub_command_t cmd_xen, cmd_initrd, cmd_module, cmd_multiboot;
+
+GRUB_MOD_INIT (xen)
+{
+ cmd_xen = grub_register_command ("linux", grub_cmd_xen,
+ 0, N_("Load Linux."));
+ cmd_multiboot = grub_register_command ("multiboot", grub_cmd_xen,
+ 0, N_("Load Linux."));
+ cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd,
+ 0, N_("Load initrd."));
+ cmd_module = grub_register_command ("module", grub_cmd_module,
+ 0, N_("Load module."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (xen)
+{
+ grub_unregister_command (cmd_xen);
+ grub_unregister_command (cmd_initrd);
+ grub_unregister_command (cmd_multiboot);
+ grub_unregister_command (cmd_module);
+}
diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c
new file mode 100644
index 0000000..9af5d66
--- /dev/null
+++ b/grub-core/loader/i386/xen_file.c
@@ -0,0 +1,117 @@
+/*
+ * 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/xen_file.h>
+#include <grub/i386/linux.h>
+#include <grub/misc.h>
+
+#define XZ_MAGIC "\3757zXZ\0"
+
+grub_elf_t
+grub_xen_file (grub_file_t file)
+{
+ grub_elf_t elf;
+ struct linux_i386_kernel_header lh;
+ grub_file_t off_file;
+ grub_uint32_t payload_offset, payload_length;
+ grub_uint8_t magic[6];
+
+ elf = grub_elf_file (file, file->name);
+ if (elf)
+ return elf;
+ grub_errno = GRUB_ERR_NONE;
+
+ if (grub_file_seek (file, 0) == (grub_off_t) -1)
+ goto fail;
+
+ if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
+ goto fail;
+
+ if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)
+ || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
+ || grub_le_to_cpu16 (lh.version) < 0x0208)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "version too old for xen boot");
+ return NULL;
+ }
+
+ payload_length = lh.payload_length;
+ payload_offset = (lh.setup_sects + 1) * 512
+ + lh.payload_offset;
+
+ if (payload_length < sizeof (magic))
+ {
+ grub_error (GRUB_ERR_BAD_OS, "payload too short");
+ return NULL;
+ }
+
+ grub_dprintf ("xen", "found bzimage payload 0x%llx-0x%llx\n",
+ (unsigned long long) payload_offset,
+ (unsigned long long) lh.payload_length);
+
+ grub_file_seek (file, payload_offset);
+
+ if (grub_file_read (file, &magic, sizeof (magic)) != sizeof (magic))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ file->name);
+ goto fail;
+ }
+
+ /* Kernel suffixes xz payload with their uncompressed size.
+ Trim it. */
+ if (grub_memcmp (magic, XZ_MAGIC, sizeof (XZ_MAGIC) - 1) == 0)
+ payload_length -= 4;
+ off_file = grub_file_offset_open (file, GRUB_FILE_TYPE_LINUX_KERNEL, payload_offset,
+ payload_length);
+ if (!off_file)
+ goto fail;
+
+ elf = grub_elf_file (off_file, file->name);
+ if (elf)
+ return elf;
+ grub_file_offset_close (off_file);
+
+fail:
+ grub_error (GRUB_ERR_BAD_OS, "not xen image");
+ return NULL;
+}
+
+grub_err_t
+grub_xen_get_info (grub_elf_t elf, struct grub_xen_file_info * xi)
+{
+ grub_memset (xi, 0, sizeof (*xi));
+
+ if (grub_elf_is_elf64 (elf)
+ && elf->ehdr.ehdr64.e_machine
+ == grub_cpu_to_le16_compile_time (EM_X86_64)
+ && elf->ehdr.ehdr64.e_ident[EI_DATA] == ELFDATA2LSB)
+ {
+ xi->arch = GRUB_XEN_FILE_X86_64;
+ return grub_xen_get_info64 (elf, xi);
+ }
+ if (grub_elf_is_elf32 (elf)
+ && elf->ehdr.ehdr32.e_machine == grub_cpu_to_le16_compile_time (EM_386)
+ && elf->ehdr.ehdr32.e_ident[EI_DATA] == ELFDATA2LSB)
+ {
+ xi->arch = GRUB_XEN_FILE_I386;
+ return grub_xen_get_info32 (elf, xi);
+ }
+ return grub_error (GRUB_ERR_BAD_OS, "unknown ELF type");
+}
diff --git a/grub-core/loader/i386/xen_file32.c b/grub-core/loader/i386/xen_file32.c
new file mode 100644
index 0000000..340d445
--- /dev/null
+++ b/grub-core/loader/i386/xen_file32.c
@@ -0,0 +1,7 @@
+#define GRUB_TARGET_WORDSIZE 32
+#define XX 32
+#define grub_le_to_cpu_addr grub_le_to_cpu32
+#define ehdrXX ehdr32
+#define grub_xen_get_infoXX grub_xen_get_info32
+#define FOR_ELF_PHDRS FOR_ELF32_PHDRS
+#include "xen_fileXX.c"
diff --git a/grub-core/loader/i386/xen_file64.c b/grub-core/loader/i386/xen_file64.c
new file mode 100644
index 0000000..c410493
--- /dev/null
+++ b/grub-core/loader/i386/xen_file64.c
@@ -0,0 +1,7 @@
+#define GRUB_TARGET_WORDSIZE 64
+#define XX 64
+#define grub_le_to_cpu_addr grub_le_to_cpu64
+#define ehdrXX ehdr64
+#define grub_xen_get_infoXX grub_xen_get_info64
+#define FOR_ELF_PHDRS FOR_ELF64_PHDRS
+#include "xen_fileXX.c"
diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c
new file mode 100644
index 0000000..27afcaa
--- /dev/null
+++ b/grub-core/loader/i386/xen_fileXX.c
@@ -0,0 +1,395 @@
+/*
+ * 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/xen_file.h>
+#include <grub/misc.h>
+#include <xen/elfnote.h>
+
+static grub_err_t
+parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi,
+ grub_off_t off, grub_size_t sz)
+{
+ char *buf;
+ const char *ptr;
+ int has_paddr = 0;
+
+ grub_errno = GRUB_ERR_NONE;
+ if (grub_file_seek (elf->file, off) == (grub_off_t) -1)
+ return grub_errno;
+ buf = grub_malloc (sz);
+ if (!buf)
+ return grub_errno;
+
+ if (grub_file_read (elf->file, buf, sz) != (grub_ssize_t) sz)
+ {
+ if (grub_errno)
+ goto out;
+ grub_free (buf);
+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ elf->file->name);
+ }
+ xi->has_xen_guest = 1;
+ for (ptr = buf; ptr && ptr - buf < (grub_ssize_t) sz;
+ ptr = grub_strchr (ptr, ','), (ptr ? ptr++ : 0))
+ {
+ if (grub_strncmp (ptr, "PAE=no,", sizeof ("PAE=no,") - 1) == 0)
+ {
+ if (xi->arch != GRUB_XEN_FILE_I386
+ && xi->arch != GRUB_XEN_FILE_I386_PAE
+ && xi->arch != GRUB_XEN_FILE_I386_PAE_BIMODE)
+ continue;
+ xi->arch = GRUB_XEN_FILE_I386;
+ continue;
+ }
+
+ if (grub_strncmp (ptr, "PAE=yes,", sizeof ("PAE=yes,") - 1) == 0)
+ {
+ if (xi->arch != GRUB_XEN_FILE_I386
+ && xi->arch != GRUB_XEN_FILE_I386_PAE
+ && xi->arch != GRUB_XEN_FILE_I386_PAE_BIMODE)
+ continue;
+ xi->arch = GRUB_XEN_FILE_I386_PAE;
+ continue;
+ }
+
+ if (grub_strncmp (ptr, "PAE=yes[extended-cr3],",
+ sizeof ("PAE=yes[extended-cr3],") - 1) == 0)
+ {
+ if (xi->arch != GRUB_XEN_FILE_I386
+ && xi->arch != GRUB_XEN_FILE_I386_PAE
+ && xi->arch != GRUB_XEN_FILE_I386_PAE_BIMODE)
+ continue;
+ xi->arch = GRUB_XEN_FILE_I386_PAE;
+ xi->extended_cr3 = 1;
+ continue;
+ }
+
+ if (grub_strncmp (ptr, "PAE=bimodal,", sizeof ("PAE=bimodal,") - 1) == 0)
+ {
+ if (xi->arch != GRUB_XEN_FILE_I386
+ && xi->arch != GRUB_XEN_FILE_I386_PAE
+ && xi->arch != GRUB_XEN_FILE_I386_PAE_BIMODE)
+ continue;
+ xi->arch = GRUB_XEN_FILE_I386_PAE_BIMODE;
+ continue;
+ }
+
+ if (grub_strncmp (ptr, "PAE=bimodal[extended-cr3],",
+ sizeof ("PAE=bimodal[extended-cr3],") - 1) == 0)
+ {
+ if (xi->arch != GRUB_XEN_FILE_I386
+ && xi->arch != GRUB_XEN_FILE_I386_PAE
+ && xi->arch != GRUB_XEN_FILE_I386_PAE_BIMODE)
+ continue;
+ xi->arch = GRUB_XEN_FILE_I386_PAE_BIMODE;
+ xi->extended_cr3 = 1;
+ continue;
+ }
+
+ if (grub_strncmp (ptr, "PAE=yes,bimodal,", sizeof ("PAE=yes,bimodal,") - 1) == 0)
+ {
+ if (xi->arch != GRUB_XEN_FILE_I386
+ && xi->arch != GRUB_XEN_FILE_I386_PAE
+ && xi->arch != GRUB_XEN_FILE_I386_PAE_BIMODE)
+ continue;
+ xi->arch = GRUB_XEN_FILE_I386_PAE_BIMODE;
+ continue;
+ }
+
+ if (grub_strncmp (ptr, "PAE=yes[extended-cr3],bimodal,",
+ sizeof ("PAE=yes[extended-cr3],bimodal,") - 1) == 0)
+ {
+ if (xi->arch != GRUB_XEN_FILE_I386
+ && xi->arch != GRUB_XEN_FILE_I386_PAE
+ && xi->arch != GRUB_XEN_FILE_I386_PAE_BIMODE)
+ continue;
+ xi->arch = GRUB_XEN_FILE_I386_PAE_BIMODE;
+ xi->extended_cr3 = 1;
+ continue;
+ }
+
+ if (grub_strncmp (ptr, "VIRT_BASE=", sizeof ("VIRT_BASE=") - 1) == 0)
+ {
+ xi->virt_base = grub_strtoull (ptr + sizeof ("VIRT_BASE=") - 1, &ptr, 16);
+ if (grub_errno)
+ goto out;
+ continue;
+ }
+ if (grub_strncmp (ptr, "VIRT_ENTRY=", sizeof ("VIRT_ENTRY=") - 1) == 0)
+ {
+ xi->entry_point = grub_strtoull (ptr + sizeof ("VIRT_ENTRY=") - 1, &ptr, 16);
+ if (grub_errno)
+ goto out;
+ continue;
+ }
+ if (grub_strncmp (ptr, "HYPERCALL_PAGE=", sizeof ("HYPERCALL_PAGE=") - 1) == 0)
+ {
+ xi->hypercall_page = grub_strtoull (ptr + sizeof ("HYPERCALL_PAGE=") - 1, &ptr, 16);
+ xi->has_hypercall_page = 1;
+ if (grub_errno)
+ goto out;
+ continue;
+ }
+ if (grub_strncmp (ptr, "ELF_PADDR_OFFSET=", sizeof ("ELF_PADDR_OFFSET=") - 1) == 0)
+ {
+ xi->paddr_offset = grub_strtoull (ptr + sizeof ("ELF_PADDR_OFFSET=") - 1, &ptr, 16);
+ has_paddr = 1;
+ if (grub_errno)
+ goto out;
+ continue;
+ }
+ }
+ if (xi->has_hypercall_page)
+ xi->hypercall_page = (xi->hypercall_page << 12) + xi->virt_base;
+ if (!has_paddr)
+ xi->paddr_offset = xi->virt_base;
+
+out:
+ grub_free (buf);
+
+ return grub_errno;
+}
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+static grub_err_t
+parse_note (grub_elf_t elf, struct grub_xen_file_info *xi,
+ grub_off_t off, grub_size_t sz)
+{
+ grub_uint32_t *buf;
+ grub_uint32_t *ptr;
+ if (grub_file_seek (elf->file, off) == (grub_off_t) -1)
+ return grub_errno;
+ buf = grub_malloc (sz);
+ if (!buf)
+ return grub_errno;
+
+ if (grub_file_read (elf->file, buf, sz) != (grub_ssize_t) sz)
+ {
+ if (grub_errno)
+ return grub_errno;
+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ elf->file->name);
+ }
+ for (ptr = buf; ptr - buf < (grub_ssize_t) (sz / sizeof (grub_uint32_t));)
+ {
+ Elf_Nhdr *nh = (Elf_Nhdr *) ptr;
+ char *name;
+ grub_uint32_t *desc;
+ grub_uint32_t namesz, descsz;
+ ptr += sizeof (*nh) / sizeof (grub_uint32_t);
+ name = (char *) ptr;
+ namesz = grub_le_to_cpu32 (nh->n_namesz);
+ descsz = grub_le_to_cpu32 (nh->n_descsz);
+ ptr += (namesz + 3) / 4;
+ desc = ptr;
+ ptr += (grub_le_to_cpu32 (nh->n_descsz) + 3) / 4;
+ if ((namesz < 3) || grub_memcmp (name, "Xen", namesz == 3 ? 3 : 4) != 0)
+ continue;
+ xi->has_note = 1;
+ switch (nh->n_type)
+ {
+ case XEN_ELFNOTE_ENTRY:
+ xi->entry_point = grub_le_to_cpu_addr (*(Elf_Addr *) desc);
+ break;
+ case XEN_ELFNOTE_HYPERCALL_PAGE:
+ xi->hypercall_page = grub_le_to_cpu_addr (*(Elf_Addr *) desc);
+ xi->has_hypercall_page = 1;
+ break;
+ case XEN_ELFNOTE_VIRT_BASE:
+ xi->virt_base = grub_le_to_cpu_addr (*(Elf_Addr *) desc);
+ break;
+ case XEN_ELFNOTE_PADDR_OFFSET:
+ xi->paddr_offset = grub_le_to_cpu_addr (*(Elf_Addr *) desc);
+ break;
+ case XEN_ELFNOTE_XEN_VERSION:
+ grub_dprintf ("xen", "xenversion = `%s'\n", (char *) desc);
+ break;
+ case XEN_ELFNOTE_GUEST_OS:
+ grub_dprintf ("xen", "name = `%s'\n", (char *) desc);
+ break;
+ case XEN_ELFNOTE_GUEST_VERSION:
+ grub_dprintf ("xen", "version = `%s'\n", (char *) desc);
+ break;
+ case XEN_ELFNOTE_LOADER:
+ if (descsz < 7
+ || grub_memcmp (desc, "generic", descsz == 7 ? 7 : 8) != 0)
+ return grub_error (GRUB_ERR_BAD_OS, "invalid loader");
+ break;
+ /* PAE */
+ case XEN_ELFNOTE_PAE_MODE:
+ grub_dprintf ("xen", "pae = `%s', %d, %d\n", (char *) desc,
+ xi->arch, descsz);
+ if (xi->arch != GRUB_XEN_FILE_I386
+ && xi->arch != GRUB_XEN_FILE_I386_PAE
+ && xi->arch != GRUB_XEN_FILE_I386_PAE_BIMODE)
+ break;
+ if (descsz >= 3 && grub_memcmp (desc, "yes",
+ descsz == 3 ? 3 : 4) == 0)
+ {
+ xi->extended_cr3 = 1;
+ xi->arch = GRUB_XEN_FILE_I386_PAE;
+ }
+ if (descsz >= 7 && grub_memcmp (desc, "bimodal",
+ descsz == 7 ? 7 : 8) == 0)
+ {
+ xi->extended_cr3 = 1;
+ xi->arch = GRUB_XEN_FILE_I386_PAE_BIMODE;
+ }
+ if (descsz >= 11 && grub_memcmp (desc, "yes,bimodal",
+ descsz == 11 ? 11 : 12) == 0)
+ {
+ xi->extended_cr3 = 1;
+ xi->arch = GRUB_XEN_FILE_I386_PAE_BIMODE;
+ }
+ if (descsz >= 2 && grub_memcmp (desc, "no",
+ descsz == 2 ? 2 : 3) == 0)
+ xi->arch = GRUB_XEN_FILE_I386;
+ break;
+ case XEN_ELFNOTE_INIT_P2M:
+ xi->p2m_base = grub_le_to_cpu_addr (*(Elf_Addr *) desc);
+ xi->has_p2m_base = 1;
+ break;
+ case XEN_ELFNOTE_MOD_START_PFN:
+ xi->unmapped_initrd = !!grub_le_to_cpu32(*(grub_uint32_t *) desc);
+ break;
+ default:
+ grub_dprintf ("xen", "unknown note type %d\n", nh->n_type);
+ break;
+ }
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_xen_get_infoXX (grub_elf_t elf, struct grub_xen_file_info *xi)
+{
+ Elf_Shdr *s, *s0;
+ grub_size_t shnum = elf->ehdr.ehdrXX.e_shnum;
+ grub_size_t shentsize = elf->ehdr.ehdrXX.e_shentsize;
+ grub_size_t shsize = shnum * shentsize;
+ grub_off_t stroff;
+ grub_err_t err;
+ Elf_Phdr *phdr;
+
+ xi->kern_end = 0;
+ xi->kern_start = ~0;
+ xi->entry_point = elf->ehdr.ehdrXX.e_entry;
+
+ /* FIXME: check note. */
+ FOR_ELF_PHDRS (elf, phdr)
+ {
+ Elf_Addr paddr;
+
+ if (phdr->p_type == PT_NOTE)
+ {
+ err = parse_note (elf, xi, phdr->p_offset, phdr->p_filesz);
+ if (err)
+ return err;
+ }
+
+ if (phdr->p_type != PT_LOAD)
+ continue;
+
+ paddr = phdr->p_paddr;
+
+ if (paddr < xi->kern_start)
+ xi->kern_start = paddr;
+
+ if (paddr + phdr->p_memsz > xi->kern_end)
+ xi->kern_end = paddr + phdr->p_memsz;
+ }
+
+ if (xi->has_note)
+ return GRUB_ERR_NONE;
+
+ if (!shnum || !shentsize)
+ return grub_error (GRUB_ERR_BAD_OS, "no XEN note");
+
+ s0 = grub_malloc (shsize);
+ if (!s0)
+ return grub_errno;
+
+ if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1)
+ {
+ err = grub_errno;
+ goto cleanup;
+ }
+
+ if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize)
+ {
+ if (grub_errno)
+ 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);
+ stroff = s->sh_offset;
+
+ for (s = s0; s < (Elf_Shdr *) ((char *) s0 + shnum * shentsize);
+ s = (Elf_Shdr *) ((char *) s + shentsize))
+ {
+ if (s->sh_type == SHT_NOTE)
+ {
+ err = parse_note (elf, xi, s->sh_offset, s->sh_size);
+ if (err)
+ goto cleanup;
+ }
+ }
+
+ if (xi->has_note)
+ {
+ err = GRUB_ERR_NONE;
+ goto cleanup;
+ }
+
+ for (s = s0; s < (Elf_Shdr *) ((char *) s0 + shnum * shentsize);
+ s = (Elf_Shdr *) ((char *) s + shentsize))
+ {
+ 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)
+ {
+ err = grub_errno;
+ goto cleanup;
+ }
+
+ if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name))
+ {
+ if (grub_errno)
+ {
+ err = grub_errno;
+ goto cleanup;
+ }
+ continue;
+ }
+ if (grub_memcmp (name, "__xen_guest",
+ sizeof("__xen_guest")) != 0)
+ continue;
+ err = parse_xen_guest (elf, xi, s->sh_offset, s->sh_size);
+ goto cleanup;
+ }
+ 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
new file mode 100644
index 0000000..a700936
--- /dev/null
+++ b/grub-core/loader/i386/xnu.c
@@ -0,0 +1,1166 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/env.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/xnu.h>
+#include <grub/cpu/xnu.h>
+#include <grub/mm.h>
+#include <grub/loader.h>
+#include <grub/autoefi.h>
+#include <grub/i386/tsc.h>
+#include <grub/i386/cpuid.h>
+#include <grub/efi/api.h>
+#include <grub/i386/pit.h>
+#include <grub/misc.h>
+#include <grub/charset.h>
+#include <grub/term.h>
+#include <grub/command.h>
+#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))
+
+#define DEFAULT_VIDEO_MODE "auto"
+
+char grub_xnu_cmdline[1024];
+grub_uint32_t grub_xnu_entry_point, grub_xnu_arg1, grub_xnu_stack;
+
+/* Aliases set for some tables. */
+struct tbl_alias
+{
+ grub_efi_guid_t guid;
+ const char *name;
+};
+
+static struct tbl_alias table_aliases[] =
+ {
+ {GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI_20"},
+ {GRUB_EFI_ACPI_TABLE_GUID, "ACPI"},
+ };
+
+struct grub_xnu_devprop_device_descriptor
+{
+ struct grub_xnu_devprop_device_descriptor *next;
+ struct grub_xnu_devprop_device_descriptor **prev;
+ struct property_descriptor *properties;
+ struct grub_efi_device_path *path;
+ int pathlen;
+};
+
+static int
+utf16_strlen (grub_uint16_t *in)
+{
+ int i;
+ for (i = 0; in[i]; i++);
+ return i;
+}
+
+/* Read frequency from a string in MHz and return it in Hz. */
+static grub_uint64_t
+readfrequency (const char *str)
+{
+ grub_uint64_t num = 0;
+ int mul = 1000000;
+ int found = 0;
+
+ while (*str)
+ {
+ unsigned long digit;
+
+ digit = grub_tolower (*str) - '0';
+ if (digit > 9)
+ break;
+
+ found = 1;
+
+ num = num * 10 + digit;
+ str++;
+ }
+ num *= 1000000;
+ if (*str == '.')
+ {
+ str++;
+ while (*str)
+ {
+ unsigned long digit;
+
+ digit = grub_tolower (*str) - '0';
+ if (digit > 9)
+ break;
+
+ found = 1;
+
+ mul /= 10;
+ num = num + mul * digit;
+ str++;
+ }
+ }
+ if (! found)
+ return 0;
+
+ return num;
+}
+
+/* Thanks to Kabyl for precious information about Intel architecture. */
+static grub_uint64_t
+guessfsb (void)
+{
+ const grub_uint64_t sane_value = 100000000;
+ grub_uint32_t manufacturer[3], max_cpuid, capabilities, msrlow;
+ grub_uint32_t a, b, d, divisor;
+
+ if (! grub_cpu_is_cpuid_supported ())
+ return sane_value;
+
+ grub_cpuid (0, max_cpuid, manufacturer[0], manufacturer[2], manufacturer[1]);
+
+ /* Only Intel for now is done. */
+ if (grub_memcmp (manufacturer, "GenuineIntel", 12) != 0)
+ return sane_value;
+
+ /* Check Speedstep. */
+ if (max_cpuid < 1)
+ return sane_value;
+
+ grub_cpuid (1, a, b, capabilities, d);
+
+ if (! (capabilities & (1 << 7)))
+ return sane_value;
+
+ /* Read the multiplier. */
+ asm volatile ("movl $0x198, %%ecx\n"
+ "rdmsr"
+ : "=d" (msrlow)
+ :
+ : "%ecx", "%eax");
+
+ grub_uint64_t v;
+ grub_uint32_t r;
+
+ /* (2000ULL << 32) / grub_tsc_rate */
+ /* Assumption: TSC frequency is over 2 MHz. */
+ v = 0xffffffff / grub_tsc_rate;
+ v *= 2000;
+ /* v is at most 2000 off from (2000ULL << 32) / grub_tsc_rate.
+ Since grub_tsc_rate < 2^32/2^11=2^21, so no overflow.
+ */
+ r = (2000ULL << 32) - v * grub_tsc_rate;
+ v += r / grub_tsc_rate;
+
+ divisor = ((msrlow >> 7) & 0x3e) | ((msrlow >> 14) & 1);
+ if (divisor == 0)
+ return sane_value;
+ return grub_divmod64 (v, divisor, 0);
+}
+
+struct property_descriptor
+{
+ struct property_descriptor *next;
+ struct property_descriptor **prev;
+ grub_uint8_t *name;
+ grub_uint16_t *name16;
+ int name16len;
+ int length;
+ void *data;
+};
+
+static struct grub_xnu_devprop_device_descriptor *devices = 0;
+
+grub_err_t
+grub_xnu_devprop_remove_property (struct grub_xnu_devprop_device_descriptor *dev,
+ char *name)
+{
+ struct property_descriptor *prop;
+ prop = grub_named_list_find (GRUB_AS_NAMED_LIST (dev->properties), name);
+ if (!prop)
+ return GRUB_ERR_NONE;
+
+ grub_free (prop->name);
+ grub_free (prop->name16);
+ grub_free (prop->data);
+
+ grub_list_remove (GRUB_AS_LIST (prop));
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_xnu_devprop_remove_device (struct grub_xnu_devprop_device_descriptor *dev)
+{
+ void *t;
+ struct property_descriptor *prop;
+
+ grub_list_remove (GRUB_AS_LIST (dev));
+
+ for (prop = dev->properties; prop; )
+ {
+ grub_free (prop->name);
+ grub_free (prop->name16);
+ grub_free (prop->data);
+ t = prop;
+ prop = prop->next;
+ grub_free (t);
+ }
+
+ grub_free (dev->path);
+ grub_free (dev);
+
+ return GRUB_ERR_NONE;
+}
+
+struct grub_xnu_devprop_device_descriptor *
+grub_xnu_devprop_add_device (struct grub_efi_device_path *path, int length)
+{
+ struct grub_xnu_devprop_device_descriptor *ret;
+
+ ret = grub_zalloc (sizeof (*ret));
+ if (!ret)
+ return 0;
+
+ ret->path = grub_malloc (length);
+ if (!ret->path)
+ {
+ grub_free (ret);
+ return 0;
+ }
+ ret->pathlen = length;
+ grub_memcpy (ret->path, path, length);
+
+ grub_list_push (GRUB_AS_LIST_P (&devices), GRUB_AS_LIST (ret));
+
+ return ret;
+}
+
+static grub_err_t
+grub_xnu_devprop_add_property (struct grub_xnu_devprop_device_descriptor *dev,
+ grub_uint8_t *utf8, grub_uint16_t *utf16,
+ int utf16len, void *data, int datalen)
+{
+ struct property_descriptor *prop;
+
+ prop = grub_malloc (sizeof (*prop));
+ if (!prop)
+ return grub_errno;
+
+ prop->data = grub_malloc (datalen);
+ if (!prop->data)
+ {
+ grub_free (prop);
+ return grub_errno;
+ }
+ grub_memcpy (prop->data, data, datalen);
+
+ prop->name = utf8;
+ prop->name16 = utf16;
+ prop->name16len = utf16len;
+ prop->length = datalen;
+
+ grub_list_push (GRUB_AS_LIST_P (&dev->properties),
+ GRUB_AS_LIST (prop));
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_xnu_devprop_add_property_utf8 (struct grub_xnu_devprop_device_descriptor *dev,
+ char *name, void *data, int datalen)
+{
+ grub_uint8_t *utf8;
+ grub_uint16_t *utf16;
+ int len, utf16len;
+ grub_err_t err;
+
+ utf8 = (grub_uint8_t *) grub_strdup (name);
+ if (!utf8)
+ return grub_errno;
+
+ len = grub_strlen (name);
+ utf16 = grub_calloc (len, sizeof (grub_uint16_t));
+ if (!utf16)
+ {
+ grub_free (utf8);
+ return grub_errno;
+ }
+
+ utf16len = grub_utf8_to_utf16 (utf16, len, utf8, len, NULL);
+ if (utf16len < 0)
+ {
+ grub_free (utf8);
+ grub_free (utf16);
+ return grub_errno;
+ }
+
+ err = grub_xnu_devprop_add_property (dev, utf8, utf16,
+ utf16len, data, datalen);
+ if (err)
+ {
+ grub_free (utf8);
+ grub_free (utf16);
+ return err;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_xnu_devprop_add_property_utf16 (struct grub_xnu_devprop_device_descriptor *dev,
+ grub_uint16_t *name, int namelen,
+ void *data, int datalen)
+{
+ grub_uint8_t *utf8;
+ grub_uint16_t *utf16;
+ grub_err_t err;
+
+ utf16 = grub_calloc (namelen, sizeof (grub_uint16_t));
+ if (!utf16)
+ return grub_errno;
+ grub_memcpy (utf16, name, sizeof (grub_uint16_t) * namelen);
+
+ utf8 = grub_malloc (namelen * 4 + 1);
+ if (!utf8)
+ {
+ grub_free (utf16);
+ return grub_errno;
+ }
+
+ *grub_utf16_to_utf8 ((grub_uint8_t *) utf8, name, namelen) = '\0';
+
+ err = grub_xnu_devprop_add_property (dev, utf8, utf16,
+ namelen, data, datalen);
+ if (err)
+ {
+ grub_free (utf8);
+ grub_free (utf16);
+ return err;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_cpu_xnu_unload (void)
+{
+ struct grub_xnu_devprop_device_descriptor *dev1, *dev2;
+
+ for (dev1 = devices; dev1; )
+ {
+ dev2 = dev1->next;
+ grub_xnu_devprop_remove_device (dev1);
+ dev1 = dev2;
+ }
+}
+
+static grub_err_t
+grub_cpu_xnu_fill_devprop (void)
+{
+ struct grub_xnu_devtree_key *efikey;
+ int total_length = sizeof (struct grub_xnu_devprop_header);
+ struct grub_xnu_devtree_key *devprop;
+ struct grub_xnu_devprop_device_descriptor *device;
+ void *ptr;
+ struct grub_xnu_devprop_header *head;
+ void *t;
+ int numdevs = 0;
+
+ /* The key "efi". */
+ efikey = grub_xnu_create_key (&grub_xnu_devtree_root, "efi");
+ if (! efikey)
+ return grub_errno;
+
+ for (device = devices; device; device = device->next)
+ {
+ struct property_descriptor *propdesc;
+ total_length += sizeof (struct grub_xnu_devprop_device_header);
+ total_length += device->pathlen;
+
+ for (propdesc = device->properties; propdesc; propdesc = propdesc->next)
+ {
+ total_length += sizeof (grub_uint32_t);
+ total_length += sizeof (grub_uint16_t)
+ * (propdesc->name16len + 1);
+ total_length += sizeof (grub_uint32_t);
+ total_length += propdesc->length;
+ }
+ numdevs++;
+ }
+
+ devprop = grub_xnu_create_value (&(efikey->first_child), "device-properties");
+ if (!devprop)
+ return grub_errno;
+
+ devprop->data = grub_malloc (total_length);
+ devprop->datasize = total_length;
+
+ ptr = devprop->data;
+ head = ptr;
+ ptr = head + 1;
+ head->length = total_length;
+ head->alwaysone = 1;
+ head->num_devices = numdevs;
+ for (device = devices; device; )
+ {
+ struct grub_xnu_devprop_device_header *devhead;
+ struct property_descriptor *propdesc;
+ devhead = ptr;
+ devhead->num_values = 0;
+ ptr = devhead + 1;
+
+ grub_memcpy (ptr, device->path, device->pathlen);
+ ptr = (char *) ptr + device->pathlen;
+
+ for (propdesc = device->properties; propdesc; )
+ {
+ grub_uint32_t *len;
+ grub_uint16_t *name;
+ void *data;
+
+ len = ptr;
+ *len = 2 * propdesc->name16len + sizeof (grub_uint16_t)
+ + sizeof (grub_uint32_t);
+ ptr = len + 1;
+
+ name = ptr;
+ grub_memcpy (name, propdesc->name16, 2 * propdesc->name16len);
+ name += propdesc->name16len;
+
+ /* NUL terminator. */
+ *name = 0;
+ ptr = name + 1;
+
+ len = ptr;
+ *len = propdesc->length + sizeof (grub_uint32_t);
+ data = len + 1;
+ ptr = data;
+ grub_memcpy (ptr, propdesc->data, propdesc->length);
+ ptr = (char *) ptr + propdesc->length;
+
+ grub_free (propdesc->name);
+ grub_free (propdesc->name16);
+ grub_free (propdesc->data);
+ t = propdesc;
+ propdesc = propdesc->next;
+ grub_free (t);
+ devhead->num_values++;
+ }
+
+ devhead->length = (char *) ptr - (char *) devhead;
+ t = device;
+ device = device->next;
+ grub_free (t);
+ }
+
+ devices = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_devprop_load (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *args[])
+{
+ grub_file_t file;
+ void *buf, *bufstart, *bufend;
+ struct grub_xnu_devprop_header *head;
+ grub_size_t size;
+ unsigned i, j;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ file = grub_file_open (args[0], GRUB_FILE_XNU_DEVPROP);
+ if (! file)
+ return grub_errno;
+ size = grub_file_size (file);
+ buf = grub_malloc (size);
+ if (!buf)
+ {
+ grub_file_close (file);
+ return grub_errno;
+ }
+ if (grub_file_read (file, buf, size) != (grub_ssize_t) size)
+ {
+ grub_file_close (file);
+ return grub_errno;
+ }
+ grub_file_close (file);
+
+ bufstart = buf;
+ bufend = (char *) buf + size;
+ head = buf;
+ buf = head + 1;
+ for (i = 0; i < grub_le_to_cpu32 (head->num_devices) && buf < bufend; i++)
+ {
+ struct grub_efi_device_path *dp, *dpstart;
+ struct grub_xnu_devprop_device_descriptor *dev;
+ struct grub_xnu_devprop_device_header *devhead;
+
+ devhead = buf;
+ buf = devhead + 1;
+ dp = dpstart = buf;
+
+ while (GRUB_EFI_DEVICE_PATH_VALID (dp) && buf < bufend)
+ {
+ buf = (char *) buf + GRUB_EFI_DEVICE_PATH_LENGTH (dp);
+ if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
+ break;
+ dp = buf;
+ }
+
+ dev = grub_xnu_devprop_add_device (dpstart, (char *) buf
+ - (char *) dpstart);
+
+ for (j = 0; j < grub_le_to_cpu32 (devhead->num_values) && buf < bufend;
+ j++)
+ {
+ grub_uint32_t *namelen;
+ grub_uint32_t *datalen;
+ grub_uint16_t *utf16;
+ void *data;
+ grub_err_t err;
+
+ namelen = buf;
+ buf = namelen + 1;
+ if (buf >= bufend)
+ break;
+
+ utf16 = buf;
+ buf = (char *) buf + *namelen - sizeof (grub_uint32_t);
+ if (buf >= bufend)
+ break;
+
+ datalen = buf;
+ buf = datalen + 1;
+ if (buf >= bufend)
+ break;
+
+ data = buf;
+ buf = (char *) buf + *datalen - sizeof (grub_uint32_t);
+ if (buf >= bufend)
+ break;
+ err = grub_xnu_devprop_add_property_utf16
+ (dev, utf16, (*namelen - sizeof (grub_uint32_t)
+ - sizeof (grub_uint16_t)) / sizeof (grub_uint16_t),
+ data, *datalen - sizeof (grub_uint32_t));
+ if (err)
+ {
+ grub_free (bufstart);
+ return err;
+ }
+ }
+ }
+
+ grub_free (bufstart);
+ return GRUB_ERR_NONE;
+}
+
+/* Fill device tree. */
+/* FIXME: some entries may be platform-agnostic. Move them to loader/xnu.c. */
+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? */
+ curval = grub_xnu_create_value (&grub_xnu_devtree_root, "model");
+ if (! curval)
+ return grub_errno;
+ curval->datasize = sizeof ("ACPI");
+ curval->data = grub_strdup ("ACPI");
+ curval = grub_xnu_create_value (&grub_xnu_devtree_root, "compatible");
+ if (! curval)
+ return grub_errno;
+ curval->datasize = sizeof ("ACPI");
+ curval->data = grub_strdup ("ACPI");
+
+ /* The key "efi". */
+ efikey = grub_xnu_create_key (&grub_xnu_devtree_root, "efi");
+ if (! efikey)
+ return grub_errno;
+
+ /* Information about firmware. */
+ curval = grub_xnu_create_value (&(efikey->first_child), "firmware-revision");
+ if (! curval)
+ return grub_errno;
+ curval->datasize = (SYSTEM_TABLE_SIZEOF (firmware_revision));
+ curval->data = grub_malloc (curval->datasize);
+ if (! curval->data)
+ return grub_errno;
+ grub_memcpy (curval->data, (SYSTEM_TABLE_VAR(firmware_revision)),
+ curval->datasize);
+
+ curval = grub_xnu_create_value (&(efikey->first_child), "firmware-vendor");
+ if (! curval)
+ return grub_errno;
+ curval->datasize =
+ 2 * (utf16_strlen (SYSTEM_TABLE_PTR (firmware_vendor)) + 1);
+ curval->data = grub_malloc (curval->datasize);
+ if (! curval->data)
+ return grub_errno;
+ grub_memcpy (curval->data, SYSTEM_TABLE_PTR (firmware_vendor),
+ curval->datasize);
+
+ curval = grub_xnu_create_value (&(efikey->first_child), "firmware-abi");
+ if (! curval)
+ return grub_errno;
+ curval->datasize = sizeof ("EFI32");
+ curval->data = grub_malloc (curval->datasize);
+ if (! curval->data)
+ return grub_errno;
+ if (SIZEOF_OF_UINTN == 4)
+ grub_memcpy (curval->data, "EFI32", curval->datasize);
+ else
+ grub_memcpy (curval->data, "EFI64", curval->datasize);
+
+ /* The key "platform". */
+ platformkey = grub_xnu_create_key (&(efikey->first_child),
+ "platform");
+ if (! platformkey)
+ return grub_errno;
+
+ /* Pass FSB frequency to the kernel. */
+ curval = grub_xnu_create_value (&(platformkey->first_child), "FSBFrequency");
+ if (! curval)
+ return grub_errno;
+ curval->datasize = sizeof (grub_uint64_t);
+ curval->data = grub_malloc (curval->datasize);
+ if (!curval->data)
+ return grub_errno;
+
+ /* First see if user supplies the value. */
+ const char *fsbvar = grub_env_get ("fsb");
+ grub_uint64_t fsbfreq = 0;
+ if (fsbvar)
+ fsbfreq = readfrequency (fsbvar);
+ /* Try autodetect. */
+ if (! fsbfreq)
+ fsbfreq = guessfsb ();
+ *((grub_uint64_t *) curval->data) = fsbfreq;
+ *fsbfreq_out = fsbfreq;
+ grub_dprintf ("xnu", "fsb autodetected as %llu\n",
+ (unsigned long long) *((grub_uint64_t *) curval->data));
+
+ cfgtablekey = grub_xnu_create_key (&(efikey->first_child),
+ "configuration-table");
+ if (!cfgtablekey)
+ return grub_errno;
+
+ /* Fill "configuration-table" key. */
+ for (i = 0; i < SYSTEM_TABLE (num_table_entries); i++)
+ {
+ void *ptr;
+ struct grub_xnu_devtree_key *curkey;
+ grub_efi_packed_guid_t guid;
+ char guidbuf[64];
+
+ /* Retrieve current key. */
+#ifdef GRUB_MACHINE_EFI
+ {
+ ptr = (void *)
+ grub_efi_system_table->configuration_table[i].vendor_table;
+ guid = grub_efi_system_table->configuration_table[i].vendor_guid;
+ }
+#else
+ if (SIZEOF_OF_UINTN == 4)
+ {
+ ptr = (void *) (grub_addr_t) ((grub_efiemu_configuration_table32_t *)
+ SYSTEM_TABLE_PTR (configuration_table))[i]
+ .vendor_table;
+ guid =
+ ((grub_efiemu_configuration_table32_t *)
+ SYSTEM_TABLE_PTR (configuration_table))[i].vendor_guid;
+ }
+ else
+ {
+ ptr = (void *) (grub_addr_t) ((grub_efiemu_configuration_table64_t *)
+ SYSTEM_TABLE_PTR (configuration_table))[i]
+ .vendor_table;
+ guid =
+ ((grub_efiemu_configuration_table64_t *)
+ SYSTEM_TABLE_PTR (configuration_table))[i].vendor_guid;
+ }
+#endif
+
+ /* The name of key for new table. */
+ grub_snprintf (guidbuf, sizeof (guidbuf), "%08x-%04x-%04x-%02x%02x-",
+ guid.data1, guid.data2, guid.data3, guid.data4[0],
+ guid.data4[1]);
+ for (j = 2; j < 8; j++)
+ grub_snprintf (guidbuf + grub_strlen (guidbuf),
+ sizeof (guidbuf) - grub_strlen (guidbuf),
+ "%02x", guid.data4[j]);
+ /* For some reason GUID has to be in uppercase. */
+ for (j = 0; guidbuf[j] ; j++)
+ if (guidbuf[j] >= 'a' && guidbuf[j] <= 'f')
+ guidbuf[j] += 'A' - 'a';
+ curkey = grub_xnu_create_key (&(cfgtablekey->first_child), guidbuf);
+ if (! curkey)
+ return grub_errno;
+
+ curval = grub_xnu_create_value (&(curkey->first_child), "guid");
+ if (! curval)
+ return grub_errno;
+ curval->datasize = sizeof (guid);
+ curval->data = grub_malloc (curval->datasize);
+ if (! curval->data)
+ return grub_errno;
+ grub_memcpy (curval->data, &guid, curval->datasize);
+
+ /* The value "table". */
+ curval = grub_xnu_create_value (&(curkey->first_child), "table");
+ if (! curval)
+ return grub_errno;
+ curval->datasize = SIZEOF_OF_UINTN;
+ curval->data = grub_malloc (curval->datasize);
+ if (! curval->data)
+ return grub_errno;
+ if (SIZEOF_OF_UINTN == 4)
+ *((grub_uint32_t *) curval->data) = (grub_addr_t) ptr;
+ else
+ *((grub_uint64_t *) curval->data) = (grub_addr_t) ptr;
+
+ /* Create alias. */
+ for (j = 0; j < ARRAY_SIZE(table_aliases); j++)
+ if (grub_memcmp (&table_aliases[j].guid, &guid, sizeof (guid)) == 0)
+ break;
+ if (j != ARRAY_SIZE(table_aliases))
+ {
+ curval = grub_xnu_create_value (&(curkey->first_child), "alias");
+ if (!curval)
+ return grub_errno;
+ curval->datasize = grub_strlen (table_aliases[j].name) + 1;
+ curval->data = grub_malloc (curval->datasize);
+ if (!curval->data)
+ return grub_errno;
+ grub_memcpy (curval->data, table_aliases[j].name, curval->datasize);
+ }
+ }
+
+ /* Create and fill "runtime-services" key. */
+ runtimesrvkey = grub_xnu_create_key (&(efikey->first_child),
+ "runtime-services");
+ if (! runtimesrvkey)
+ return grub_errno;
+ curval = grub_xnu_create_value (&(runtimesrvkey->first_child), "table");
+ if (! curval)
+ return grub_errno;
+ curval->datasize = SIZEOF_OF_UINTN;
+ curval->data = grub_malloc (curval->datasize);
+ if (! curval->data)
+ return grub_errno;
+ if (SIZEOF_OF_UINTN == 4)
+ *((grub_uint32_t *) curval->data)
+ = (grub_addr_t) SYSTEM_TABLE_PTR (runtime_services);
+ else
+ *((grub_uint64_t *) curval->data)
+ = (grub_addr_t) SYSTEM_TABLE_PTR (runtime_services);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_xnu_boot_resume (void)
+{
+ struct grub_relocator32_state state;
+
+ state.esp = grub_xnu_stack;
+ state.ebp = grub_xnu_stack;
+ state.eip = grub_xnu_entry_point;
+ state.eax = grub_xnu_arg1;
+
+ return grub_relocator32_boot (grub_xnu_relocator, state, 0);
+}
+
+/* Setup video for xnu. */
+static grub_err_t
+grub_xnu_set_video (struct grub_xnu_boot_params_common *params)
+{
+ struct grub_video_mode_info mode_info;
+ char *tmp;
+ const char *modevar;
+ void *framebuffer;
+ grub_err_t err;
+ struct grub_video_bitmap *bitmap = NULL;
+
+ modevar = grub_env_get ("gfxpayload");
+ /* Consider only graphical 32-bit deep modes. */
+ if (! modevar || *modevar == 0)
+ err = grub_video_set_mode (DEFAULT_VIDEO_MODE,
+ GRUB_VIDEO_MODE_TYPE_PURE_TEXT
+ | GRUB_VIDEO_MODE_TYPE_DEPTH_MASK,
+ 32 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS);
+ else
+ {
+ tmp = grub_xasprintf ("%s;" DEFAULT_VIDEO_MODE, modevar);
+ if (! tmp)
+ return grub_errno;
+ err = grub_video_set_mode (tmp,
+ GRUB_VIDEO_MODE_TYPE_PURE_TEXT
+ | GRUB_VIDEO_MODE_TYPE_DEPTH_MASK,
+ 32 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS);
+ grub_free (tmp);
+ }
+
+ if (err)
+ return err;
+
+ err = grub_video_get_info (&mode_info);
+ if (err)
+ return err;
+
+ if (grub_xnu_bitmap)
+ {
+ if (grub_xnu_bitmap_mode == GRUB_XNU_BITMAP_STRETCH)
+ err = grub_video_bitmap_create_scaled (&bitmap,
+ mode_info.width,
+ mode_info.height,
+ grub_xnu_bitmap,
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
+ else
+ bitmap = grub_xnu_bitmap;
+ }
+
+ if (bitmap)
+ {
+ if (grub_xnu_bitmap_mode == GRUB_XNU_BITMAP_STRETCH)
+ err = grub_video_bitmap_create_scaled (&bitmap,
+ mode_info.width,
+ mode_info.height,
+ grub_xnu_bitmap,
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
+ else
+ bitmap = grub_xnu_bitmap;
+ }
+
+ if (bitmap)
+ {
+ int x, y;
+
+ x = mode_info.width - bitmap->mode_info.width;
+ x /= 2;
+ y = mode_info.height - bitmap->mode_info.height;
+ y /= 2;
+ err = grub_video_blit_bitmap (bitmap,
+ GRUB_VIDEO_BLIT_REPLACE,
+ x > 0 ? x : 0,
+ y > 0 ? y : 0,
+ x < 0 ? -x : 0,
+ y < 0 ? -y : 0,
+ min (bitmap->mode_info.width,
+ mode_info.width),
+ min (bitmap->mode_info.height,
+ mode_info.height));
+ }
+ if (err)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ bitmap = 0;
+ }
+
+ err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
+ if (err)
+ return err;
+
+ params->lfb_width = mode_info.width;
+ params->lfb_height = mode_info.height;
+ params->lfb_depth = mode_info.bpp;
+ params->lfb_line_len = mode_info.pitch;
+
+ params->lfb_base = (grub_addr_t) framebuffer;
+ params->lfb_mode = bitmap ? GRUB_XNU_VIDEO_SPLASH
+ : GRUB_XNU_VIDEO_TEXT_IN_VIDEO;
+
+ 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)
+{
+ union grub_xnu_boot_params_any *bootparams;
+ struct grub_xnu_boot_params_common *bootparams_common;
+ void *bp_in;
+ grub_addr_t bootparams_target;
+ grub_err_t err;
+ grub_efi_uintn_t memory_map_size = 0;
+ void *memory_map;
+ grub_addr_t memory_map_target;
+ grub_efi_uintn_t map_key = 0;
+ grub_efi_uintn_t descriptor_size = 0;
+ grub_efi_uint32_t descriptor_version = 0;
+ grub_uint64_t firstruntimepage, lastruntimepage;
+ grub_uint64_t curruntimepage;
+ grub_addr_t devtree_target;
+ grub_size_t devtreelen;
+ int i;
+ struct grub_relocator32_state state;
+ grub_uint64_t fsbfreq = 100000000;
+ int v2 = (grub_xnu_darwin_version >= 11);
+ grub_uint32_t efi_system_table = 0;
+
+ err = grub_autoefi_prepare ();
+ if (err)
+ return err;
+
+ err = grub_cpu_xnu_fill_devprop ();
+ if (err)
+ return err;
+
+ err = grub_cpu_xnu_fill_devicetree (&fsbfreq);
+ if (err)
+ return err;
+
+ err = grub_xnu_fill_devicetree ();
+ if (err)
+ return err;
+
+ /* Page-align to avoid following parts to be inadvertently freed. */
+ err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
+ if (err)
+ return err;
+
+ /* Pass memory map to kernel. */
+ memory_map_size = 0;
+ memory_map = 0;
+ map_key = 0;
+ descriptor_size = 0;
+ descriptor_version = 0;
+
+ grub_dprintf ("xnu", "eip=%x, efi=%p\n", grub_xnu_entry_point,
+ grub_autoefi_system_table);
+
+ const char *debug = grub_env_get ("debug");
+
+ if (debug && (grub_strword (debug, "all") || grub_strword (debug, "xnu")))
+ {
+ grub_puts_ (N_("Press any key to launch xnu"));
+ grub_getkey ();
+ }
+
+ /* Relocate the boot parameters to heap. */
+ err = grub_xnu_heap_malloc (sizeof (*bootparams),
+ &bp_in, &bootparams_target);
+ if (err)
+ return err;
+ bootparams = bp_in;
+
+ grub_memset (bootparams, 0, sizeof (*bootparams));
+ if (v2)
+ {
+ bootparams_common = &bootparams->v2.common;
+ bootparams->v2.fsbfreq = fsbfreq;
+ bootparams->v2.ram_size = get_total_ram();
+ }
+ else
+ bootparams_common = &bootparams->v1.common;
+
+ /* Set video. */
+ err = grub_xnu_set_video (bootparams_common);
+ if (err != GRUB_ERR_NONE)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ grub_puts_ (N_("Booting in blind mode"));
+
+ bootparams_common->lfb_mode = 0;
+ bootparams_common->lfb_width = 0;
+ bootparams_common->lfb_height = 0;
+ bootparams_common->lfb_depth = 0;
+ bootparams_common->lfb_line_len = 0;
+ bootparams_common->lfb_base = 0;
+ }
+
+ if (grub_autoefi_get_memory_map (&memory_map_size, memory_map,
+ &map_key, &descriptor_size,
+ &descriptor_version) < 0)
+ return grub_errno;
+
+ /* We will do few allocations later. Reserve some space for possible
+ memory map growth. */
+ memory_map_size += 20 * descriptor_size;
+ err = grub_xnu_heap_malloc (memory_map_size,
+ &memory_map, &memory_map_target);
+ if (err)
+ return err;
+
+ err = grub_xnu_writetree_toheap (&devtree_target, &devtreelen);
+ if (err)
+ return err;
+
+ grub_memcpy (bootparams_common->cmdline, grub_xnu_cmdline,
+ sizeof (bootparams_common->cmdline));
+
+ bootparams_common->devtree = devtree_target;
+ bootparams_common->devtreelen = devtreelen;
+
+ err = grub_autoefi_finish_boot_services (&memory_map_size, memory_map,
+ &map_key, &descriptor_size,
+ &descriptor_version);
+ if (err)
+ return err;
+
+ if (v2)
+ bootparams->v2.efi_system_table = (grub_addr_t) grub_autoefi_system_table;
+ else
+ bootparams->v1.efi_system_table = (grub_addr_t) grub_autoefi_system_table;
+
+ firstruntimepage = (((grub_addr_t) grub_xnu_heap_target_start
+ + grub_xnu_heap_size + GRUB_XNU_PAGESIZE - 1)
+ / GRUB_XNU_PAGESIZE) + 20;
+ curruntimepage = firstruntimepage;
+
+ for (i = 0; (unsigned) i < memory_map_size / descriptor_size; i++)
+ {
+ grub_efi_memory_descriptor_t *curdesc = (grub_efi_memory_descriptor_t *)
+ ((char *) memory_map + descriptor_size * i);
+
+ curdesc->virtual_start = curdesc->physical_start;
+
+ if (curdesc->type == GRUB_EFI_RUNTIME_SERVICES_DATA
+ || curdesc->type == GRUB_EFI_RUNTIME_SERVICES_CODE)
+ {
+ curdesc->virtual_start = curruntimepage << 12;
+ curruntimepage += curdesc->num_pages;
+ if (curdesc->physical_start
+ <= (grub_addr_t) grub_autoefi_system_table
+ && curdesc->physical_start + (curdesc->num_pages << 12)
+ > (grub_addr_t) grub_autoefi_system_table)
+ efi_system_table
+ = (grub_addr_t) grub_autoefi_system_table
+ - curdesc->physical_start + curdesc->virtual_start;
+ if (SIZEOF_OF_UINTN == 8 && grub_xnu_is_64bit)
+ curdesc->virtual_start |= 0xffffff8000000000ULL;
+ }
+ }
+
+ lastruntimepage = curruntimepage;
+
+ if (v2)
+ {
+ bootparams->v2.efi_uintnbits = SIZEOF_OF_UINTN * 8;
+ bootparams->v2.verminor = GRUB_XNU_BOOTARGSV2_VERMINOR;
+ bootparams->v2.vermajor = GRUB_XNU_BOOTARGSV2_VERMAJOR;
+ bootparams->v2.efi_system_table = efi_system_table;
+ }
+ else
+ {
+ bootparams->v1.efi_uintnbits = SIZEOF_OF_UINTN * 8;
+ bootparams->v1.verminor = GRUB_XNU_BOOTARGSV1_VERMINOR;
+ bootparams->v1.vermajor = GRUB_XNU_BOOTARGSV1_VERMAJOR;
+ bootparams->v1.efi_system_table = efi_system_table;
+ }
+
+ bootparams_common->efi_runtime_first_page = firstruntimepage;
+ bootparams_common->efi_runtime_npages = lastruntimepage - firstruntimepage;
+ bootparams_common->efi_mem_desc_size = descriptor_size;
+ bootparams_common->efi_mem_desc_version = descriptor_version;
+ 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 = curruntimepage * GRUB_XNU_PAGESIZE - grub_xnu_heap_target_start;
+
+ /* Parameters for asm helper. */
+ grub_xnu_stack = bootparams_common->heap_start
+ + bootparams_common->heap_size + GRUB_XNU_PAGESIZE;
+ grub_xnu_arg1 = bootparams_target;
+
+ grub_autoefi_set_virtual_address_map (memory_map_size, descriptor_size,
+ descriptor_version, memory_map);
+
+ state.eip = grub_xnu_entry_point;
+ state.eax = grub_xnu_arg1;
+ state.esp = grub_xnu_stack;
+ state.ebp = grub_xnu_stack;
+
+ /* XNU uses only APIC. Disable PIC. */
+ grub_outb (0xff, 0x21);
+ grub_outb (0xff, 0xa1);
+
+ return grub_relocator32_boot (grub_xnu_relocator, state, 0);
+}
+
+static grub_command_t cmd_devprop_load;
+
+void
+grub_cpu_xnu_init (void)
+{
+ cmd_devprop_load = grub_register_command ("xnu_devprop_load",
+ grub_cmd_devprop_load,
+ /* TRANSLATORS: `device-properties'
+ is a variable name,
+ not a program. */
+ 0, N_("Load `device-properties' dump."));
+}
+
+void
+grub_cpu_xnu_fini (void)
+{
+ grub_unregister_command (cmd_devprop_load);
+}
diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c
new file mode 100644
index 0000000..7987fd1
--- /dev/null
+++ b/grub-core/loader/ia64/efi/linux.c
@@ -0,0 +1,607 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/command.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/cache.h>
+#include <grub/kernel.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/elf.h>
+#include <grub/i18n.h>
+#include <grub/env.h>
+#include <grub/linux.h>
+#include <grub/verify.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+#define ALIGN_MIN (256*1024*1024)
+
+#define GRUB_ELF_SEARCH 1024
+
+#define BOOT_PARAM_SIZE 16384
+
+struct ia64_boot_param
+{
+ grub_uint64_t command_line; /* physical address of command line. */
+ grub_uint64_t efi_systab; /* physical address of EFI system table */
+ grub_uint64_t efi_memmap; /* physical address of EFI memory map */
+ grub_uint64_t efi_memmap_size; /* size of EFI memory map */
+ grub_uint64_t efi_memdesc_size; /* size of an EFI memory map descriptor */
+ grub_uint32_t efi_memdesc_version; /* memory descriptor version */
+ struct
+ {
+ grub_uint16_t num_cols; /* number of columns on console output dev */
+ grub_uint16_t num_rows; /* number of rows on console output device */
+ grub_uint16_t orig_x; /* cursor's x position */
+ grub_uint16_t orig_y; /* cursor's y position */
+ } console_info;
+ grub_uint64_t fpswa; /* physical address of the fpswa interface */
+ grub_uint64_t initrd_start;
+ grub_uint64_t initrd_size;
+};
+
+typedef struct
+{
+ grub_uint32_t revision;
+ grub_uint32_t reserved;
+ void *fpswa;
+} fpswa_interface_t;
+static fpswa_interface_t *fpswa;
+
+#define NEXT_MEMORY_DESCRIPTOR(desc, size) \
+ ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
+
+static grub_dl_t my_mod;
+
+static int loaded;
+
+/* Kernel base and size. */
+static void *kernel_mem;
+static grub_efi_uintn_t kernel_pages;
+static grub_uint64_t entry;
+
+/* Initrd base and size. */
+static void *initrd_mem;
+static grub_efi_uintn_t initrd_pages;
+static grub_efi_uintn_t initrd_size;
+
+static struct ia64_boot_param *boot_param;
+static grub_efi_uintn_t boot_param_pages;
+
+static inline grub_size_t
+page_align (grub_size_t size)
+{
+ return (size + (1 << 12) - 1) & (~((1 << 12) - 1));
+}
+
+static void
+query_fpswa (void)
+{
+ grub_efi_handle_t fpswa_image;
+ grub_efi_boot_services_t *bs;
+ grub_efi_status_t status;
+ grub_efi_uintn_t size;
+ static const grub_efi_guid_t fpswa_protocol =
+ { 0xc41b6531, 0x97b9, 0x11d3,
+ {0x9a, 0x29, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} };
+
+ if (fpswa != NULL)
+ return;
+
+ size = sizeof(grub_efi_handle_t);
+
+ bs = grub_efi_system_table->boot_services;
+ status = bs->locate_handle (GRUB_EFI_BY_PROTOCOL,
+ (void *) &fpswa_protocol,
+ NULL, &size, &fpswa_image);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_printf ("%s\n", _("Could not locate FPSWA driver"));
+ return;
+ }
+ status = bs->handle_protocol (fpswa_image,
+ (void *) &fpswa_protocol, (void *) &fpswa);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_printf ("%s\n",
+ _("FPSWA protocol wasn't able to find the interface"));
+ return;
+ }
+}
+
+static void
+free_pages (void)
+{
+ if (kernel_mem)
+ {
+ grub_efi_free_pages ((grub_addr_t) kernel_mem, kernel_pages);
+ kernel_mem = 0;
+ }
+
+ if (initrd_mem)
+ {
+ grub_efi_free_pages ((grub_addr_t) initrd_mem, initrd_pages);
+ initrd_mem = 0;
+ }
+
+ if (boot_param)
+ {
+ /* Free bootparam. */
+ grub_efi_free_pages ((grub_efi_physical_address_t) boot_param,
+ boot_param_pages);
+ boot_param = 0;
+ }
+}
+
+static void *
+allocate_pages (grub_uint64_t align, grub_uint64_t size_pages,
+ grub_uint64_t nobase)
+{
+ grub_uint64_t size;
+ grub_efi_uintn_t desc_size;
+ grub_efi_memory_descriptor_t *mmap, *mmap_end;
+ grub_efi_uintn_t mmap_size, tmp_mmap_size;
+ grub_efi_memory_descriptor_t *desc;
+ void *mem = NULL;
+
+ size = size_pages << 12;
+
+ mmap_size = grub_efi_find_mmap_size ();
+ if (!mmap_size)
+ return 0;
+
+ /* Read the memory map temporarily, to find free space. */
+ mmap = grub_malloc (mmap_size);
+ if (! mmap)
+ return 0;
+
+ tmp_mmap_size = mmap_size;
+ if (grub_efi_get_memory_map (&tmp_mmap_size, mmap, 0, &desc_size, 0) <= 0)
+ {
+ grub_error (GRUB_ERR_IO, "cannot get memory map");
+ goto fail;
+ }
+
+ mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap, tmp_mmap_size);
+
+ /* First, find free pages for the real mode code
+ and the memory map buffer. */
+ for (desc = mmap;
+ desc < mmap_end;
+ desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
+ {
+ grub_uint64_t start, end;
+ grub_uint64_t aligned_start;
+
+ if (desc->type != GRUB_EFI_CONVENTIONAL_MEMORY)
+ continue;
+
+ start = desc->physical_start;
+ end = start + (desc->num_pages << 12);
+ /* Align is a power of 2. */
+ aligned_start = (start + align - 1) & ~(align - 1);
+ if (aligned_start + size > end)
+ continue;
+ if (aligned_start == nobase)
+ aligned_start += align;
+ if (aligned_start + size > end)
+ continue;
+ mem = grub_efi_allocate_fixed (aligned_start, size_pages);
+ if (! mem)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory");
+ goto fail;
+ }
+ break;
+ }
+
+ if (! mem)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory");
+ goto fail;
+ }
+
+ grub_free (mmap);
+ return mem;
+
+ fail:
+ grub_free (mmap);
+ free_pages ();
+ return 0;
+}
+
+static void
+set_boot_param_console (void)
+{
+ grub_efi_simple_text_output_interface_t *conout;
+ grub_efi_uintn_t cols, rows;
+
+ conout = grub_efi_system_table->con_out;
+ if (conout->query_mode (conout, conout->mode->mode, &cols, &rows)
+ != GRUB_EFI_SUCCESS)
+ return;
+
+ grub_dprintf ("linux",
+ "Console info: cols=%lu rows=%lu x=%u y=%u\n",
+ cols, rows,
+ conout->mode->cursor_column, conout->mode->cursor_row);
+
+ boot_param->console_info.num_cols = cols;
+ boot_param->console_info.num_rows = rows;
+ boot_param->console_info.orig_x = conout->mode->cursor_column;
+ boot_param->console_info.orig_y = conout->mode->cursor_row;
+}
+
+static grub_err_t
+grub_linux_boot (void)
+{
+ grub_efi_uintn_t mmap_size;
+ grub_efi_uintn_t map_key;
+ grub_efi_uintn_t desc_size;
+ grub_efi_uint32_t desc_version;
+ grub_efi_memory_descriptor_t *mmap_buf;
+ grub_err_t err;
+
+ /* FPSWA. */
+ query_fpswa ();
+ boot_param->fpswa = (grub_uint64_t)fpswa;
+
+ /* Initrd. */
+ boot_param->initrd_start = (grub_uint64_t)initrd_mem;
+ boot_param->initrd_size = (grub_uint64_t)initrd_size;
+
+ set_boot_param_console ();
+
+ grub_dprintf ("linux", "Jump to %016lx\n", entry);
+
+ /* MDT.
+ Must be done after grub_machine_fini because map_key is used by
+ exit_boot_services. */
+ mmap_size = grub_efi_find_mmap_size ();
+ if (! mmap_size)
+ return grub_errno;
+ mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12);
+ if (! mmap_buf)
+ return grub_error (GRUB_ERR_IO, "cannot allocate memory map");
+ err = grub_efi_finish_boot_services (&mmap_size, mmap_buf, &map_key,
+ &desc_size, &desc_version);
+ if (err)
+ return err;
+
+ boot_param->efi_memmap = (grub_uint64_t)mmap_buf;
+ boot_param->efi_memmap_size = mmap_size;
+ boot_param->efi_memdesc_size = desc_size;
+ boot_param->efi_memdesc_version = desc_version;
+
+ /* See you next boot. */
+ asm volatile ("mov r28=%1; br.sptk.few %0" :: "b"(entry),"r"(boot_param));
+
+ /* Never reach here. */
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_linux_unload (void)
+{
+ free_pages ();
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_load_elf64 (grub_file_t file, void *buffer, const char *filename)
+{
+ Elf64_Ehdr *ehdr = (Elf64_Ehdr *) buffer;
+ Elf64_Phdr *phdr;
+ int i;
+ grub_uint64_t low_addr;
+ grub_uint64_t high_addr;
+ grub_uint64_t align;
+ grub_uint64_t reloc_offset;
+ const char *relocate;
+
+ if (ehdr->e_ident[EI_MAG0] != ELFMAG0
+ || ehdr->e_ident[EI_MAG1] != ELFMAG1
+ || ehdr->e_ident[EI_MAG2] != ELFMAG2
+ || ehdr->e_ident[EI_MAG3] != ELFMAG3
+ || ehdr->e_ident[EI_DATA] != ELFDATA2LSB)
+ return grub_error(GRUB_ERR_UNKNOWN_OS,
+ N_("invalid arch-independent ELF magic"));
+
+ if (ehdr->e_ident[EI_CLASS] != ELFCLASS64
+ || ehdr->e_version != EV_CURRENT
+ || ehdr->e_machine != EM_IA_64)
+ return grub_error (GRUB_ERR_UNKNOWN_OS,
+ N_("invalid arch-dependent ELF magic"));
+
+ if (ehdr->e_type != ET_EXEC)
+ 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 > GRUB_ELF_SEARCH)
+ return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset");
+
+ entry = ehdr->e_entry;
+
+ /* Compute low, high and align addresses. */
+ low_addr = ~0UL;
+ high_addr = 0;
+ align = 0;
+ for (i = 0; i < ehdr->e_phnum; i++)
+ {
+ phdr = (Elf64_Phdr *) ((char *) buffer + ehdr->e_phoff
+ + i * ehdr->e_phentsize);
+ if (phdr->p_type == PT_LOAD)
+ {
+ if (phdr->p_paddr < low_addr)
+ low_addr = phdr->p_paddr;
+ if (phdr->p_paddr + phdr->p_memsz > high_addr)
+ high_addr = phdr->p_paddr + phdr->p_memsz;
+ if (phdr->p_align > align)
+ align = phdr->p_align;
+ }
+ }
+
+ if (align < ALIGN_MIN)
+ align = ALIGN_MIN;
+
+ if (high_addr == 0)
+ return grub_error (GRUB_ERR_BAD_OS, "no program entries");
+
+ kernel_pages = page_align (high_addr - low_addr) >> 12;
+
+ /* Undocumented on purpose. */
+ relocate = grub_env_get ("linux_relocate");
+ if (!relocate || grub_strcmp (relocate, "force") != 0)
+ {
+ kernel_mem = grub_efi_allocate_fixed (low_addr, kernel_pages);
+ reloc_offset = 0;
+ }
+ /* Try to relocate. */
+ if (! kernel_mem && (!relocate || grub_strcmp (relocate, "off") != 0))
+ {
+ kernel_mem = allocate_pages (align, kernel_pages, low_addr);
+ if (kernel_mem)
+ {
+ reloc_offset = (grub_uint64_t)kernel_mem - low_addr;
+ grub_dprintf ("linux", " Relocated at %p (offset=%016lx)\n",
+ kernel_mem, reloc_offset);
+ entry += reloc_offset;
+ }
+ }
+ if (! kernel_mem)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "cannot allocate memory for OS");
+
+ /* Load every loadable segment in memory. */
+ for (i = 0; i < ehdr->e_phnum; i++)
+ {
+ phdr = (Elf64_Phdr *) ((char *) buffer + ehdr->e_phoff
+ + i * ehdr->e_phentsize);
+ if (phdr->p_type == PT_LOAD)
+ {
+ grub_dprintf ("linux", " [paddr=%lx load=%lx memsz=%08lx "
+ "off=%lx flags=%x]\n",
+ phdr->p_paddr, phdr->p_paddr + reloc_offset,
+ phdr->p_memsz, phdr->p_offset, phdr->p_flags);
+
+ if (grub_file_seek (file, phdr->p_offset) == (grub_off_t)-1)
+ return grub_errno;
+
+ if (grub_file_read (file, (void *) (phdr->p_paddr + reloc_offset),
+ phdr->p_filesz)
+ != (grub_ssize_t) phdr->p_filesz)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ return grub_errno;
+ }
+
+ if (phdr->p_filesz < phdr->p_memsz)
+ grub_memset
+ ((char *)(phdr->p_paddr + reloc_offset + phdr->p_filesz),
+ 0, phdr->p_memsz - phdr->p_filesz);
+
+ /* Sync caches if necessary. */
+ if (phdr->p_flags & PF_X)
+ grub_arch_sync_caches
+ ((void *)(phdr->p_paddr + reloc_offset), phdr->p_memsz);
+ }
+ }
+ loaded = 1;
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ char buffer[GRUB_ELF_SEARCH];
+ char *cmdline, *p;
+ grub_ssize_t len;
+ int i;
+
+ grub_dl_ref (my_mod);
+
+ grub_loader_unset ();
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
+ if (! file)
+ goto fail;
+
+ len = grub_file_read (file, buffer, sizeof (buffer));
+ if (len < (grub_ssize_t) sizeof (Elf64_Ehdr))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ argv[0]);
+ goto fail;
+ }
+
+ grub_dprintf ("linux", "Loading linux: %s\n", argv[0]);
+
+ if (grub_load_elf64 (file, buffer, argv[0]))
+ goto fail;
+
+ len = sizeof("BOOT_IMAGE=") + 8;
+ for (i = 0; i < argc; i++)
+ len += grub_strlen (argv[i]) + 1;
+ len += sizeof (struct ia64_boot_param) + 512; /* Room for extensions. */
+ boot_param_pages = page_align (len) >> 12;
+ boot_param = grub_efi_allocate_any_pages (boot_param_pages);
+ if (boot_param == 0)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "cannot allocate memory for bootparams");
+ goto fail;
+ }
+
+ grub_memset (boot_param, 0, len);
+ cmdline = ((char *)(boot_param + 1)) + 256;
+
+ /* Build cmdline. */
+ p = grub_stpcpy (cmdline, "BOOT_IMAGE");
+ for (i = 0; i < argc; i++)
+ {
+ *p++ = ' ';
+ p = grub_stpcpy (p, argv[i]);
+ }
+ cmdline[10] = '=';
+
+ *p = '\0';
+
+ if (grub_verify_string (cmdline, GRUB_VERIFY_KERNEL_CMDLINE))
+ goto fail;
+
+ boot_param->command_line = (grub_uint64_t) cmdline;
+ boot_param->efi_systab = (grub_uint64_t) grub_efi_system_table;
+
+ grub_errno = GRUB_ERR_NONE;
+
+ grub_loader_set (grub_linux_boot, grub_linux_unload, 0);
+
+ fail:
+ if (file)
+ grub_file_close (file);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_efi_free_pages ((grub_efi_physical_address_t) boot_param,
+ boot_param_pages);
+ grub_dl_unref (my_mod);
+ }
+ return grub_errno;
+}
+
+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 };
+
+ 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 = (page_align (initrd_size) >> 12);
+ initrd_mem = grub_efi_allocate_any_pages (initrd_pages);
+ if (! initrd_mem)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate pages");
+ goto fail;
+ }
+
+ grub_dprintf ("linux", "[addr=0x%lx, size=0x%lx]\n",
+ (grub_uint64_t) initrd_mem, initrd_size);
+
+ if (grub_initrd_load (&initrd_ctx, argv, initrd_mem))
+ goto fail;
+ fail:
+ grub_initrd_close (&initrd_ctx);
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_fpswa (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__((unused)),
+ char *argv[] __attribute__((unused)))
+{
+ query_fpswa ();
+ if (fpswa == NULL)
+ grub_puts_ (N_("No FPSWA found"));
+ else
+ grub_printf (_("FPSWA revision: %x\n"), fpswa->revision);
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd_linux, cmd_initrd, cmd_fpswa;
+
+GRUB_MOD_INIT(linux)
+{
+ cmd_linux = grub_register_command ("linux", grub_cmd_linux,
+ N_("FILE [ARGS...]"), N_("Load Linux."));
+
+ cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd,
+ N_("FILE"), N_("Load initrd."));
+
+ cmd_fpswa = grub_register_command ("fpswa", grub_cmd_fpswa,
+ "", N_("Display FPSWA version."));
+
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(linux)
+{
+ grub_unregister_command (cmd_linux);
+ grub_unregister_command (cmd_initrd);
+ grub_unregister_command (cmd_fpswa);
+}
diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
new file mode 100644
index 0000000..3fe390f
--- /dev/null
+++ b/grub-core/loader/linux.c
@@ -0,0 +1,335 @@
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/linux.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/safemath.h>
+
+struct newc_head
+{
+ char magic[6];
+ char ino[8];
+ char mode[8];
+ char uid[8];
+ char gid[8];
+ char nlink[8];
+ char mtime[8];
+ char filesize[8];
+ char devmajor[8];
+ char devminor[8];
+ char rdevmajor[8];
+ char rdevminor[8];
+ char namesize[8];
+ char check[8];
+} GRUB_PACKED;
+
+struct grub_linux_initrd_component
+{
+ grub_file_t file;
+ char *newc_name;
+ grub_off_t size;
+};
+
+struct dir
+{
+ char *name;
+ struct dir *next;
+ struct dir *child;
+};
+
+static char
+hex (grub_uint8_t val)
+{
+ if (val < 10)
+ return '0' + val;
+ return 'a' + val - 10;
+}
+
+static void
+set_field (char *var, grub_uint32_t val)
+{
+ int i;
+ char *ptr = var;
+ for (i = 28; i >= 0; i -= 4)
+ *ptr++ = hex((val >> i) & 0xf);
+}
+
+static grub_uint8_t *
+make_header (grub_uint8_t *ptr,
+ const char *name, grub_size_t len,
+ grub_uint32_t mode,
+ grub_off_t fsize)
+{
+ struct newc_head *head = (struct newc_head *) ptr;
+ grub_uint8_t *optr;
+ grub_size_t oh = 0;
+ grub_memcpy (head->magic, "070701", 6);
+ set_field (head->ino, 0);
+ set_field (head->mode, mode);
+ set_field (head->uid, 0);
+ set_field (head->gid, 0);
+ set_field (head->nlink, 1);
+ set_field (head->mtime, 0);
+ set_field (head->filesize, fsize);
+ set_field (head->devmajor, 0);
+ set_field (head->devminor, 0);
+ set_field (head->rdevmajor, 0);
+ set_field (head->rdevminor, 0);
+ set_field (head->namesize, len);
+ set_field (head->check, 0);
+ optr = ptr;
+ ptr += sizeof (struct newc_head);
+ grub_memcpy (ptr, name, len);
+ ptr += len;
+ oh = ALIGN_UP_OVERHEAD (ptr - optr, 4);
+ grub_memset (ptr, 0, oh);
+ ptr += oh;
+ return ptr;
+}
+
+static void
+free_dir (struct dir *root)
+{
+ if (!root)
+ return;
+ free_dir (root->next);
+ free_dir (root->child);
+ grub_free (root->name);
+ grub_free (root);
+}
+
+static grub_err_t
+insert_dir (const char *name, struct dir **root,
+ grub_uint8_t *ptr, grub_size_t *size)
+{
+ struct dir *cur, **head = root;
+ const char *cb, *ce = name;
+ *size = 0;
+ while (1)
+ {
+ for (cb = ce; *cb == '/'; cb++);
+ for (ce = cb; *ce && *ce != '/'; ce++);
+ if (!*ce)
+ break;
+
+ for (cur = *root; cur; cur = cur->next)
+ if (grub_memcmp (cur->name, cb, ce - cb)
+ && cur->name[ce - cb] == 0)
+ break;
+ if (!cur)
+ {
+ struct dir *n;
+ n = grub_zalloc (sizeof (*n));
+ if (!n)
+ return 0;
+ n->next = *head;
+ n->name = grub_strndup (cb, ce - cb);
+ if (ptr)
+ {
+ grub_dprintf ("linux", "Creating directory %s, %s\n", name, ce);
+ ptr = make_header (ptr, name, ce - name,
+ 040777, 0);
+ }
+ if (grub_add (*size,
+ ALIGN_UP ((ce - (char *) name)
+ + sizeof (struct newc_head), 4),
+ size))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+ grub_free (n->name);
+ grub_free (n);
+ return grub_errno;
+ }
+ *head = n;
+ cur = n;
+ }
+ root = &cur->next;
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_initrd_init (int argc, char *argv[],
+ struct grub_linux_initrd_context *initrd_ctx)
+{
+ int i;
+ int newc = 0;
+ struct dir *root = 0;
+
+ initrd_ctx->nfiles = 0;
+ initrd_ctx->components = 0;
+
+ initrd_ctx->components = grub_calloc (argc, sizeof (initrd_ctx->components[0]));
+ if (!initrd_ctx->components)
+ return grub_errno;
+
+ initrd_ctx->size = 0;
+
+ 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;
+ ptr = argv[i] + 5;
+ while (*ptr == '/')
+ ptr++;
+ eptr = grub_strchr (ptr, ':');
+ if (eptr)
+ {
+ grub_size_t dir_size, name_len;
+
+ initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr);
+ if (!initrd_ctx->components[i].newc_name ||
+ insert_dir (initrd_ctx->components[i].newc_name, &root, 0,
+ &dir_size))
+ {
+ grub_initrd_close (initrd_ctx);
+ return grub_errno;
+ }
+ name_len = grub_strlen (initrd_ctx->components[i].newc_name);
+ if (grub_add (initrd_ctx->size,
+ ALIGN_UP (sizeof (struct newc_head) + name_len, 4),
+ &initrd_ctx->size) ||
+ grub_add (initrd_ctx->size, dir_size, &initrd_ctx->size))
+ goto overflow;
+ newc = 1;
+ fname = eptr + 1;
+ }
+ }
+ else if (newc)
+ {
+ if (grub_add (initrd_ctx->size,
+ ALIGN_UP (sizeof (struct newc_head)
+ + sizeof ("TRAILER!!!") - 1, 4),
+ &initrd_ctx->size))
+ goto overflow;
+ free_dir (root);
+ root = 0;
+ newc = 0;
+ }
+ initrd_ctx->components[i].file = grub_file_open (fname,
+ GRUB_FILE_TYPE_LINUX_INITRD
+ | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (!initrd_ctx->components[i].file)
+ {
+ grub_initrd_close (initrd_ctx);
+ return grub_errno;
+ }
+ initrd_ctx->nfiles++;
+ initrd_ctx->components[i].size
+ = grub_file_size (initrd_ctx->components[i].file);
+ if (grub_add (initrd_ctx->size, initrd_ctx->components[i].size,
+ &initrd_ctx->size))
+ goto overflow;
+ }
+
+ if (newc)
+ {
+ initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
+ if (grub_add (initrd_ctx->size,
+ ALIGN_UP (sizeof (struct newc_head)
+ + sizeof ("TRAILER!!!") - 1, 4),
+ &initrd_ctx->size))
+ goto overflow;
+ free_dir (root);
+ root = 0;
+ }
+
+ return GRUB_ERR_NONE;
+
+ overflow:
+ free_dir (root);
+ grub_initrd_close (initrd_ctx);
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+}
+
+grub_size_t
+grub_get_initrd_size (struct grub_linux_initrd_context *initrd_ctx)
+{
+ return initrd_ctx->size;
+}
+
+void
+grub_initrd_close (struct grub_linux_initrd_context *initrd_ctx)
+{
+ int i;
+ if (!initrd_ctx->components)
+ return;
+ for (i = 0; i < initrd_ctx->nfiles; i++)
+ {
+ grub_free (initrd_ctx->components[i].newc_name);
+ grub_file_close (initrd_ctx->components[i].file);
+ }
+ grub_free (initrd_ctx->components);
+ initrd_ctx->components = 0;
+}
+
+grub_err_t
+grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
+ char *argv[], void *target)
+{
+ grub_uint8_t *ptr = target;
+ int i;
+ int newc = 0;
+ struct dir *root = 0;
+ grub_ssize_t cursize = 0;
+
+ for (i = 0; i < initrd_ctx->nfiles; i++)
+ {
+ grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
+ ptr += ALIGN_UP_OVERHEAD (cursize, 4);
+
+ if (initrd_ctx->components[i].newc_name)
+ {
+ grub_size_t dir_size;
+
+ if (insert_dir (initrd_ctx->components[i].newc_name, &root, ptr,
+ &dir_size))
+ {
+ free_dir (root);
+ grub_initrd_close (initrd_ctx);
+ return grub_errno;
+ }
+ ptr += dir_size;
+ ptr = make_header (ptr, initrd_ctx->components[i].newc_name,
+ grub_strlen (initrd_ctx->components[i].newc_name),
+ 0100777,
+ initrd_ctx->components[i].size);
+ newc = 1;
+ }
+ else if (newc)
+ {
+ ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1,
+ 0, 0);
+ free_dir (root);
+ root = 0;
+ newc = 0;
+ }
+
+ cursize = initrd_ctx->components[i].size;
+ if (grub_file_read (initrd_ctx->components[i].file, ptr, cursize)
+ != cursize)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
+ argv[i]);
+ grub_initrd_close (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);
+ }
+ free_dir (root);
+ root = 0;
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/loader/lzss.c b/grub-core/loader/lzss.c
new file mode 100644
index 0000000..532d8e4
--- /dev/null
+++ b/grub-core/loader/lzss.c
@@ -0,0 +1,56 @@
+/**************************************************************
+ LZSS.C -- A Data Compression Program
+ (tab = 4 spaces)
+***************************************************************
+ 4/6/1989 Haruhiko Okumura
+ Use, distribute, and modify this program freely.
+ Please send me your improved versions.
+ PC-VAN SCIENCE
+ NIFTY-Serve PAF01022
+ CompuServe 74050,1022
+**************************************************************/
+
+#include <grub/types.h>
+#include <grub/macho.h>
+
+#define N 4096 /* size of ring buffer */
+#define F 18 /* upper limit for match_length */
+#define THRESHOLD 2 /* encode string into position and length
+ if match_length is greater than this */
+#define NIL N /* index for root of binary search trees */
+
+#define EOF -1
+#define getc(file) ((src < srcend) ? *src++ : EOF)
+#define putc(c, file) (dst < dstend) ? (*dst++ = (c)) : 0;
+
+grub_size_t
+grub_decompress_lzss (grub_uint8_t *dst, grub_uint8_t *dstend,
+ grub_uint8_t *src, grub_uint8_t *srcend)
+{
+ int i, j, k, r, c;
+ unsigned int flags;
+ static unsigned char text_buf[N + F - 1];
+ grub_uint8_t *dst0 = dst;
+
+ for (i = 0; i < N - F; i++) text_buf[i] = ' ';
+ r = N - F; flags = 0;
+ for ( ; ; ) {
+ if (((flags >>= 1) & 256) == 0) {
+ if ((c = getc(infile)) == EOF) break;
+ flags = c | 0xff00; /* uses higher byte cleverly */
+ } /* to count eight */
+ if (flags & 1) {
+ if ((c = getc(infile)) == EOF) break;
+ putc(c, outfile); text_buf[r++] = c; r &= (N - 1);
+ } else {
+ if ((i = getc(infile)) == EOF) break;
+ if ((j = getc(infile)) == EOF) break;
+ i |= ((j & 0xf0) << 4); j = (j & 0x0f) + THRESHOLD;
+ for (k = 0; k <= j; k++) {
+ c = text_buf[(i + k) & (N - 1)];
+ putc(c, outfile); text_buf[r++] = c; r &= (N - 1);
+ }
+ }
+ }
+ return dst - dst0;
+}
diff --git a/grub-core/loader/macho.c b/grub-core/loader/macho.c
new file mode 100644
index 0000000..05710c4
--- /dev/null
+++ b/grub-core/loader/macho.c
@@ -0,0 +1,205 @@
+/* macho.c - load Mach-O files. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This Mach-O loader is incomplete and can load only non-relocatable segments.
+ This is however enough to boot xnu (otool -l and Mach-O specs for more info).
+*/
+
+#include <grub/err.h>
+#include <grub/macho.h>
+#include <grub/machoload.h>
+#include <grub/file.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+grub_err_t
+grub_macho_close (grub_macho_t macho)
+{
+ grub_file_t file = macho->file;
+
+ if (!macho->uncompressed32)
+ grub_free (macho->cmds32);
+ grub_free (macho->uncompressed32);
+ if (!macho->uncompressed64)
+ grub_free (macho->cmds64);
+ grub_free (macho->uncompressed64);
+
+ grub_free (macho);
+
+ if (file)
+ grub_file_close (file);
+
+ return grub_errno;
+}
+
+grub_macho_t
+grub_macho_file (grub_file_t file, const char *filename, int is_64bit)
+{
+ grub_macho_t macho;
+ union grub_macho_filestart filestart;
+
+ macho = grub_malloc (sizeof (*macho));
+ if (! macho)
+ return 0;
+
+ macho->file = file;
+ macho->offset32 = -1;
+ macho->offset64 = -1;
+ macho->end32 = -1;
+ macho->end64 = -1;
+ macho->cmds32 = 0;
+ macho->cmds64 = 0;
+ macho->uncompressed32 = 0;
+ macho->uncompressed64 = 0;
+ macho->compressed32 = 0;
+ macho->compressed64 = 0;
+
+ if (grub_file_seek (macho->file, 0) == (grub_off_t) -1)
+ goto fail;
+
+ if (grub_file_read (macho->file, &filestart, sizeof (filestart))
+ != sizeof (filestart))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ goto fail;
+ }
+
+ /* Is it a fat file? */
+ if (filestart.fat.magic == grub_cpu_to_be32_compile_time (GRUB_MACHO_FAT_MAGIC))
+ {
+ struct grub_macho_fat_arch *archs;
+ int i, narchs;
+
+ /* Load architecture description. */
+ narchs = grub_be_to_cpu32 (filestart.fat.nfat_arch);
+ if (grub_file_seek (macho->file, sizeof (struct grub_macho_fat_header))
+ == (grub_off_t) -1)
+ goto fail;
+ archs = grub_calloc (narchs, sizeof (struct grub_macho_fat_arch));
+ if (!archs)
+ goto fail;
+ if (grub_file_read (macho->file, archs,
+ sizeof (struct grub_macho_fat_arch) * narchs)
+ != (grub_ssize_t) sizeof(struct grub_macho_fat_arch) * narchs)
+ {
+ grub_free (archs);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ goto fail;
+ }
+
+ for (i = 0; i < narchs; i++)
+ {
+ if ((archs[i].cputype
+ == grub_cpu_to_be32_compile_time (GRUB_MACHO_CPUTYPE_IA32))
+ && !is_64bit)
+ {
+ macho->offset32 = grub_be_to_cpu32 (archs[i].offset);
+ macho->end32 = grub_be_to_cpu32 (archs[i].offset)
+ + grub_be_to_cpu32 (archs[i].size);
+ }
+ if ((archs[i].cputype
+ == grub_cpu_to_be32_compile_time (GRUB_MACHO_CPUTYPE_AMD64))
+ && is_64bit)
+ {
+ macho->offset64 = grub_be_to_cpu32 (archs[i].offset);
+ macho->end64 = grub_be_to_cpu32 (archs[i].offset)
+ + grub_be_to_cpu32 (archs[i].size);
+ }
+ }
+ grub_free (archs);
+ }
+
+ /* Is it a thin 32-bit file? */
+ if (filestart.thin32.magic == GRUB_MACHO_MAGIC32 && !is_64bit)
+ {
+ macho->offset32 = 0;
+ macho->end32 = grub_file_size (file);
+ }
+
+ /* Is it a thin 64-bit file? */
+ if (filestart.thin64.magic == GRUB_MACHO_MAGIC64 && is_64bit)
+ {
+ macho->offset64 = 0;
+ macho->end64 = grub_file_size (file);
+ }
+
+ if (grub_memcmp (filestart.lzss.magic, GRUB_MACHO_LZSS_MAGIC,
+ sizeof (filestart.lzss.magic)) == 0 && !is_64bit)
+ {
+ macho->offset32 = 0;
+ macho->end32 = grub_file_size (file);
+ }
+
+ /* Is it a thin 64-bit file? */
+ if (grub_memcmp (filestart.lzss.magic, GRUB_MACHO_LZSS_MAGIC,
+ sizeof (filestart.lzss.magic)) == 0 && is_64bit)
+ {
+ macho->offset64 = 0;
+ macho->end64 = grub_file_size (file);
+ }
+
+ grub_macho_parse32 (macho, filename);
+ grub_macho_parse64 (macho, filename);
+
+ if (macho->offset32 == -1 && !is_64bit)
+ {
+ grub_error (GRUB_ERR_BAD_OS,
+ "Mach-O doesn't contain suitable 32-bit architecture");
+ goto fail;
+ }
+
+ if (macho->offset64 == -1 && is_64bit)
+ {
+ grub_error (GRUB_ERR_BAD_OS,
+ "Mach-O doesn't contain suitable 64-bit architecture");
+ goto fail;
+ }
+
+ return macho;
+
+fail:
+ macho->file = 0;
+ grub_macho_close (macho);
+ return 0;
+}
+
+grub_macho_t
+grub_macho_open (const char *name, enum grub_file_type type, int is_64bit)
+{
+ grub_file_t file;
+ grub_macho_t macho;
+
+ file = grub_file_open (name, type);
+ if (! file)
+ return 0;
+
+ macho = grub_macho_file (file, name, is_64bit);
+ if (! macho)
+ grub_file_close (file);
+
+ return macho;
+}
diff --git a/grub-core/loader/macho32.c b/grub-core/loader/macho32.c
new file mode 100644
index 0000000..2de3a5c
--- /dev/null
+++ b/grub-core/loader/macho32.c
@@ -0,0 +1,22 @@
+#include <grub/macho.h>
+#include <grub/machoload.h>
+
+#define SUFFIX(x) x ## 32
+typedef struct grub_macho_header32 grub_macho_header_t;
+typedef struct grub_macho_segment32 grub_macho_segment_t;
+typedef grub_uint32_t grub_macho_addr_t;
+typedef struct grub_macho_thread32 grub_macho_thread_t;
+#define offsetXX offset32
+#define ncmdsXX ncmds32
+#define cmdsizeXX cmdsize32
+#define cmdsXX cmds32
+#define endXX end32
+#define uncompressedXX uncompressed32
+#define compressedXX compressed32
+#define uncompressed_sizeXX uncompressed_size32
+#define compressed_sizeXX compressed_size32
+#define XX "32"
+#define GRUB_MACHO_MAGIC GRUB_MACHO_MAGIC32
+#define GRUB_MACHO_CMD_SEGMENT GRUB_MACHO_CMD_SEGMENT32
+#include "machoXX.c"
+
diff --git a/grub-core/loader/macho64.c b/grub-core/loader/macho64.c
new file mode 100644
index 0000000..0affceb
--- /dev/null
+++ b/grub-core/loader/macho64.c
@@ -0,0 +1,22 @@
+#include <grub/macho.h>
+#include <grub/machoload.h>
+
+#define SUFFIX(x) x ## 64
+typedef struct grub_macho_header64 grub_macho_header_t;
+typedef struct grub_macho_segment64 grub_macho_segment_t;
+typedef grub_uint64_t grub_macho_addr_t;
+typedef struct grub_macho_thread64 grub_macho_thread_t;
+#define offsetXX offset64
+#define ncmdsXX ncmds64
+#define cmdsizeXX cmdsize64
+#define cmdsXX cmds64
+#define endXX end64
+#define uncompressedXX uncompressed64
+#define compressedXX compressed64
+#define uncompressed_sizeXX uncompressed_size64
+#define compressed_sizeXX compressed_size64
+#define XX "64"
+#define GRUB_MACHO_MAGIC GRUB_MACHO_MAGIC64
+#define GRUB_MACHO_CMD_SEGMENT GRUB_MACHO_CMD_SEGMENT64
+#include "machoXX.c"
+
diff --git a/grub-core/loader/machoXX.c b/grub-core/loader/machoXX.c
new file mode 100644
index 0000000..95c3fe5
--- /dev/null
+++ b/grub-core/loader/machoXX.c
@@ -0,0 +1,384 @@
+
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+
+static int
+SUFFIX (grub_macho_contains_macho) (grub_macho_t macho)
+{
+ return macho->offsetXX != -1;
+}
+
+void
+SUFFIX (grub_macho_parse) (grub_macho_t macho, const char *filename)
+{
+ union {
+ struct grub_macho_lzss_header lzss;
+ grub_macho_header_t macho;
+ } head;
+
+ /* Is there any candidate at all? */
+ if (macho->offsetXX == -1)
+ return;
+
+ /* Read header and check magic. */
+ if (grub_file_seek (macho->file, macho->offsetXX) == (grub_off_t) -1
+ || grub_file_read (macho->file, &head, sizeof (head))
+ != sizeof (head))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ macho->offsetXX = -1;
+ return;
+ }
+ if (grub_memcmp (head.lzss.magic, GRUB_MACHO_LZSS_MAGIC,
+ sizeof (head.lzss.magic)) == 0)
+ {
+ macho->compressed_sizeXX = grub_be_to_cpu32 (head.lzss.compressed_size);
+ macho->uncompressed_sizeXX
+ = grub_be_to_cpu32 (head.lzss.uncompressed_size);
+ if (macho->uncompressed_sizeXX < sizeof (head.macho))
+ {
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ macho->offsetXX = -1;
+ return;
+ }
+ /* Skip header check. */
+ macho->compressedXX = 1;
+ return;
+ }
+
+ if (head.macho.magic != GRUB_MACHO_MAGIC)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "invalid Mach-O header");
+ macho->offsetXX = -1;
+ return;
+ }
+
+ /* Read commands. */
+ macho->ncmdsXX = head.macho.ncmds;
+ macho->cmdsizeXX = head.macho.sizeofcmds;
+ macho->cmdsXX = grub_malloc (macho->cmdsizeXX);
+ if (! macho->cmdsXX)
+ return;
+ if (grub_file_seek (macho->file, macho->offsetXX
+ + sizeof (grub_macho_header_t)) == (grub_off_t) -1
+ || grub_file_read (macho->file, macho->cmdsXX,
+ (grub_size_t) macho->cmdsizeXX)
+ != (grub_ssize_t) macho->cmdsizeXX)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ macho->offsetXX = -1;
+ }
+}
+
+typedef int (*grub_macho_iter_hook_t)
+(grub_macho_t , struct grub_macho_cmd *,
+ void *);
+
+static grub_err_t
+grub_macho_cmds_iterate (grub_macho_t macho,
+ grub_macho_iter_hook_t hook,
+ void *hook_arg,
+ const char *filename)
+{
+ grub_uint8_t *hdrs;
+ int i;
+
+ if (macho->compressedXX && !macho->uncompressedXX)
+ {
+ grub_uint8_t *tmp;
+ grub_macho_header_t *head;
+ macho->uncompressedXX = grub_malloc (macho->uncompressed_sizeXX);
+ if (!macho->uncompressedXX)
+ return grub_errno;
+ tmp = grub_malloc (macho->compressed_sizeXX);
+ if (!tmp)
+ {
+ grub_free (macho->uncompressedXX);
+ macho->uncompressedXX = 0;
+ return grub_errno;
+ }
+ if (grub_file_seek (macho->file, macho->offsetXX
+ + GRUB_MACHO_LZSS_OFFSET) == (grub_off_t) -1
+ || grub_file_read (macho->file, tmp,
+ (grub_size_t) macho->compressed_sizeXX)
+ != (grub_ssize_t) macho->compressed_sizeXX)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ grub_free (tmp);
+ grub_free (macho->uncompressedXX);
+ macho->uncompressedXX = 0;
+ macho->offsetXX = -1;
+ return grub_errno;
+ }
+ if (grub_decompress_lzss (macho->uncompressedXX,
+ macho->uncompressedXX
+ + macho->uncompressed_sizeXX,
+ tmp, tmp + macho->compressed_sizeXX)
+ != macho->uncompressed_sizeXX)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ grub_free (tmp);
+ grub_free (macho->uncompressedXX);
+ macho->uncompressedXX = 0;
+ macho->offsetXX = -1;
+ return grub_errno;
+ }
+ grub_free (tmp);
+ head = (grub_macho_header_t *) macho->uncompressedXX;
+ macho->ncmdsXX = head->ncmds;
+ macho->cmdsizeXX = head->sizeofcmds;
+ macho->cmdsXX = macho->uncompressedXX + sizeof (grub_macho_header_t);
+ if (sizeof (grub_macho_header_t) + macho->cmdsizeXX
+ >= macho->uncompressed_sizeXX)
+ {
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ grub_free (macho->uncompressedXX);
+ macho->uncompressedXX = 0;
+ macho->offsetXX = -1;
+ return grub_errno;
+ }
+ }
+
+ if (! macho->cmdsXX)
+ return grub_error (GRUB_ERR_BAD_OS, "couldn't find Mach-O commands");
+ hdrs = macho->cmdsXX;
+ for (i = 0; i < macho->ncmdsXX; i++)
+ {
+ struct grub_macho_cmd *hdr = (struct grub_macho_cmd *) hdrs;
+ if (hook (macho, hdr, hook_arg))
+ break;
+ hdrs += hdr->cmdsize;
+ }
+
+ return grub_errno;
+}
+
+grub_size_t
+SUFFIX (grub_macho_filesize) (grub_macho_t macho)
+{
+ if (SUFFIX (grub_macho_contains_macho) (macho))
+ return macho->endXX - macho->offsetXX;
+ return 0;
+}
+
+grub_err_t
+SUFFIX (grub_macho_readfile) (grub_macho_t macho,
+ const char *filename,
+ void *dest)
+{
+ grub_ssize_t read;
+ if (! SUFFIX (grub_macho_contains_macho) (macho))
+ return grub_error (GRUB_ERR_BAD_OS,
+ "couldn't read architecture-specific part");
+
+ if (grub_file_seek (macho->file, macho->offsetXX) == (grub_off_t) -1)
+ return grub_errno;
+
+ read = grub_file_read (macho->file, dest,
+ macho->endXX - macho->offsetXX);
+ if (read != (grub_ssize_t) (macho->endXX - macho->offsetXX))
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ return grub_errno;
+ }
+ return GRUB_ERR_NONE;
+}
+
+struct calcsize_ctx
+{
+ int flags;
+ int nr_phdrs;
+ grub_macho_addr_t *segments_start;
+ grub_macho_addr_t *segments_end;
+};
+
+/* Run through the program headers to calculate the total memory size we
+ should claim. */
+static int
+calcsize (grub_macho_t _macho __attribute__ ((unused)),
+ struct grub_macho_cmd *hdr0,
+ void *_arg)
+{
+ grub_macho_segment_t *hdr = (grub_macho_segment_t *) hdr0;
+ struct calcsize_ctx *ctx = _arg;
+ if (hdr->cmd != GRUB_MACHO_CMD_SEGMENT)
+ return 0;
+
+ if (! hdr->vmsize)
+ return 0;
+
+ if (! hdr->filesize && (ctx->flags & GRUB_MACHO_NOBSS))
+ return 0;
+
+ ctx->nr_phdrs++;
+ if (hdr->vmaddr < *ctx->segments_start)
+ *ctx->segments_start = hdr->vmaddr;
+ if (hdr->vmaddr + hdr->vmsize > *ctx->segments_end)
+ *ctx->segments_end = hdr->vmaddr + hdr->vmsize;
+ return 0;
+}
+
+/* Calculate the amount of memory spanned by the segments. */
+grub_err_t
+SUFFIX (grub_macho_size) (grub_macho_t macho, grub_macho_addr_t *segments_start,
+ grub_macho_addr_t *segments_end, int flags,
+ const char *filename)
+{
+ struct calcsize_ctx ctx = {
+ .flags = flags,
+ .nr_phdrs = 0,
+ .segments_start = segments_start,
+ .segments_end = segments_end,
+ };
+
+ *segments_start = (grub_macho_addr_t) -1;
+ *segments_end = 0;
+
+ grub_macho_cmds_iterate (macho, calcsize, &ctx, filename);
+
+ if (ctx.nr_phdrs == 0)
+ return grub_error (GRUB_ERR_BAD_OS, "no program headers present");
+
+ if (*segments_end < *segments_start)
+ /* Very bad addresses. */
+ return grub_error (GRUB_ERR_BAD_OS, "bad program header load addresses");
+
+ return GRUB_ERR_NONE;
+}
+
+struct do_load_ctx
+{
+ int flags;
+ char *offset;
+ const char *filename;
+ int *darwin_version;
+};
+
+static int
+do_load(grub_macho_t _macho,
+ struct grub_macho_cmd *hdr0,
+ void *_arg)
+{
+ grub_macho_segment_t *hdr = (grub_macho_segment_t *) hdr0;
+ struct do_load_ctx *ctx = _arg;
+
+ if (hdr->cmd != GRUB_MACHO_CMD_SEGMENT)
+ return 0;
+
+ if (! hdr->filesize && (ctx->flags & GRUB_MACHO_NOBSS))
+ return 0;
+ if (! hdr->vmsize)
+ return 0;
+
+ if (hdr->filesize)
+ {
+ grub_ssize_t read, toread = min (hdr->filesize, hdr->vmsize);
+ if (_macho->uncompressedXX)
+ {
+ if (hdr->fileoff + (grub_size_t) toread
+ > _macho->uncompressed_sizeXX)
+ read = -1;
+ else
+ {
+ read = toread;
+ grub_memcpy (ctx->offset + hdr->vmaddr,
+ _macho->uncompressedXX + hdr->fileoff, read);
+ }
+ }
+ else
+ {
+ if (grub_file_seek (_macho->file, hdr->fileoff
+ + _macho->offsetXX) == (grub_off_t) -1)
+ return 1;
+ read = grub_file_read (_macho->file, ctx->offset + hdr->vmaddr,
+ toread);
+ }
+
+ if (read != toread)
+ {
+ /* XXX How can we free memory from `load_hook'? */
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ ctx->filename);
+
+ return 1;
+ }
+ if (ctx->darwin_version)
+ {
+ const char *ptr = ctx->offset + hdr->vmaddr;
+ const char *end = ptr + min (hdr->filesize, hdr->vmsize)
+ - (sizeof ("Darwin Kernel Version ") - 1);
+ for (; ptr < end; ptr++)
+ if (grub_memcmp (ptr, "Darwin Kernel Version ",
+ sizeof ("Darwin Kernel Version ") - 1) == 0)
+ {
+ ptr += sizeof ("Darwin Kernel Version ") - 1;
+ *ctx->darwin_version = 0;
+ end += (sizeof ("Darwin Kernel Version ") - 1);
+ while (ptr < end && grub_isdigit (*ptr))
+ *ctx->darwin_version = (*ptr++ - '0') + *ctx->darwin_version * 10;
+ break;
+ }
+ }
+ }
+
+ if (hdr->filesize < hdr->vmsize)
+ grub_memset (ctx->offset + hdr->vmaddr + hdr->filesize,
+ 0, hdr->vmsize - hdr->filesize);
+ return 0;
+}
+
+/* Load every loadable segment into memory specified by `_load_hook'. */
+grub_err_t
+SUFFIX (grub_macho_load) (grub_macho_t macho, const char *filename,
+ char *offset, int flags, int *darwin_version)
+{
+ struct do_load_ctx ctx = {
+ .flags = flags,
+ .offset = offset,
+ .filename = filename,
+ .darwin_version = darwin_version
+ };
+
+ if (darwin_version)
+ *darwin_version = 0;
+
+ grub_macho_cmds_iterate (macho, do_load, &ctx, filename);
+
+ return grub_errno;
+}
+
+static int
+find_entry_point (grub_macho_t _macho __attribute__ ((unused)),
+ struct grub_macho_cmd *hdr,
+ void *_arg)
+{
+ grub_macho_addr_t *entry_point = _arg;
+ if (hdr->cmd == GRUB_MACHO_CMD_THREAD)
+ *entry_point = ((grub_macho_thread_t *) hdr)->entry_point;
+ return 0;
+}
+
+grub_macho_addr_t
+SUFFIX (grub_macho_get_entry_point) (grub_macho_t macho, const char *filename)
+{
+ grub_macho_addr_t entry_point = 0;
+ grub_macho_cmds_iterate (macho, find_entry_point, &entry_point, filename);
+ return entry_point;
+}
diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c
new file mode 100644
index 0000000..e4ed959
--- /dev/null
+++ b/grub-core/loader/mips/linux.c
@@ -0,0 +1,508 @@
+/* linux.c - boot Linux */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/elf.h>
+#include <grub/elfload.h>
+#include <grub/loader.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/mips/relocator.h>
+#include <grub/memory.h>
+#include <grub/i18n.h>
+#include <grub/lib/cmdline.h>
+#include <grub/linux.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+/* For frequencies. */
+#include <grub/machine/time.h>
+
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+#include <grub/pci.h>
+#include <grub/machine/kernel.h>
+
+const char loongson_machtypes[][60] =
+ {
+ [GRUB_ARCH_MACHINE_YEELOONG] = "machtype=lemote-yeeloong-2f-8.9inches",
+ [GRUB_ARCH_MACHINE_FULOONG2F] = "machtype=lemote-fuloong-2f-box",
+ [GRUB_ARCH_MACHINE_FULOONG2E] = "machtype=lemote-fuloong-2e-unknown"
+ };
+#endif
+
+static grub_dl_t my_mod;
+
+static int loaded;
+
+static grub_size_t linux_size;
+
+static struct grub_relocator *relocator;
+static grub_uint8_t *playground;
+static grub_addr_t target_addr, entry_addr;
+#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
+static char *params;
+#else
+static int linux_argc;
+static grub_off_t argv_off;
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+static grub_off_t envp_off;
+#endif
+static grub_off_t rd_addr_arg_off, rd_size_arg_off;
+#endif
+static int initrd_loaded = 0;
+
+static grub_err_t
+grub_linux_boot (void)
+{
+ struct grub_relocator32_state state;
+
+ grub_memset (&state, 0, sizeof (state));
+
+ /* Boot the kernel. */
+ state.gpr[1] = entry_addr;
+
+#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
+ {
+ grub_err_t err;
+ grub_relocator_chunk_t ch;
+ grub_uint32_t *memsize;
+ grub_uint32_t *magic;
+ char *str;
+
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ ((16 << 20) - 264),
+ grub_strlen (params) + 1 + 8);
+ if (err)
+ return err;
+ memsize = get_virtual_current_address (ch);
+ magic = memsize + 1;
+ *memsize = grub_mmap_get_lower ();
+ *magic = 0x12345678;
+ str = (char *) (magic + 1);
+ grub_strcpy (str, params);
+ }
+#endif
+
+#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
+ state.gpr[4] = linux_argc;
+ state.gpr[5] = target_addr + argv_off;
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ state.gpr[6] = target_addr + envp_off;
+#else
+ state.gpr[6] = 0;
+#endif
+ state.gpr[7] = 0;
+#endif
+ state.jumpreg = 1;
+ grub_relocator32_boot (relocator, state);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_linux_unload (void)
+{
+ grub_relocator_unload (relocator);
+ grub_dl_unref (my_mod);
+
+#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
+ grub_free (params);
+ params = 0;
+#endif
+
+ loaded = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_linux_load32 (grub_elf_t elf, const char *filename,
+ void **extra_mem, grub_size_t extra_size)
+{
+ Elf32_Addr base;
+ int extraoff;
+ grub_err_t err;
+
+ /* Linux's entry point incorrectly contains a virtual address. */
+ entry_addr = elf->ehdr.ehdr32.e_entry;
+
+ linux_size = grub_elf32_size (elf, &base, 0);
+ if (linux_size == 0)
+ return grub_errno;
+ target_addr = base;
+ /* Pad it; the kernel scribbles over memory beyond its load address. */
+ linux_size += 0x100000;
+ linux_size = ALIGN_UP (base + linux_size, 4) - base;
+ extraoff = linux_size;
+ linux_size += extra_size;
+
+ relocator = grub_relocator_new ();
+ if (!relocator)
+ return grub_errno;
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ target_addr & 0x1fffffff,
+ linux_size);
+ if (err)
+ return err;
+ playground = get_virtual_current_address (ch);
+ }
+
+ *extra_mem = playground + extraoff;
+
+ /* Now load the segments into the area we claimed. */
+ return grub_elf32_load (elf, filename, playground - base, GRUB_ELF_LOAD_FLAGS_NONE, 0, 0);
+}
+
+static grub_err_t
+grub_linux_load64 (grub_elf_t elf, const char *filename,
+ void **extra_mem, grub_size_t extra_size)
+{
+ Elf64_Addr base;
+ int extraoff;
+ grub_err_t err;
+
+ /* Linux's entry point incorrectly contains a virtual address. */
+ entry_addr = elf->ehdr.ehdr64.e_entry;
+
+ linux_size = grub_elf64_size (elf, &base, 0);
+ if (linux_size == 0)
+ return grub_errno;
+ target_addr = base;
+ /* Pad it; the kernel scribbles over memory beyond its load address. */
+ linux_size += 0x100000;
+ linux_size = ALIGN_UP (base + linux_size, 4) - base;
+ extraoff = linux_size;
+ linux_size += extra_size;
+
+ relocator = grub_relocator_new ();
+ if (!relocator)
+ return grub_errno;
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch,
+ target_addr & 0x1fffffff,
+ linux_size);
+ if (err)
+ return err;
+ playground = get_virtual_current_address (ch);
+ }
+
+ *extra_mem = playground + extraoff;
+
+ /* Now load the segments into the area we claimed. */
+ return grub_elf64_load (elf, filename, playground - base, GRUB_ELF_LOAD_FLAGS_NONE, 0, 0);
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_elf_t elf = 0;
+ int size;
+ void *extra = NULL;
+#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
+ int i;
+ grub_uint32_t *linux_argv;
+ char *linux_args;
+#endif
+ grub_err_t err;
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ char *linux_envs;
+ grub_uint32_t *linux_envp;
+#endif
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ elf = grub_elf_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
+ if (! elf)
+ return grub_errno;
+
+ if (elf->ehdr.ehdr32.e_type != ET_EXEC)
+ {
+ grub_elf_close (elf);
+ return grub_error (GRUB_ERR_UNKNOWN_OS,
+ N_("this ELF file is not of the right type"));
+ }
+
+ /* Release the previously used memory. */
+ grub_loader_unset ();
+ loaded = 0;
+
+#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
+ size = 0;
+#else
+ /* For arguments. */
+ linux_argc = argc;
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ linux_argc++;
+#endif
+ /* Main arguments. */
+ size = (linux_argc) * sizeof (grub_uint32_t);
+ /* Initrd address and size. */
+ size += 2 * sizeof (grub_uint32_t);
+ /* NULL terminator. */
+ size += sizeof (grub_uint32_t);
+
+ /* First argument is always "a0". */
+ size += ALIGN_UP (sizeof ("a0"), 4);
+ /* Normal arguments. */
+ for (i = 1; i < argc; i++)
+ size += ALIGN_UP (grub_strlen (argv[i]) + 1, 4);
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ size += ALIGN_UP (sizeof (loongson_machtypes[0]), 4);
+#endif
+
+ /* rd arguments. */
+ size += ALIGN_UP (sizeof ("rd_start=0xXXXXXXXXXXXXXXXX"), 4);
+ size += ALIGN_UP (sizeof ("rd_size=0xXXXXXXXXXXXXXXXX"), 4);
+
+ /* For the environment. */
+ size += sizeof (grub_uint32_t);
+ size += 4 * sizeof (grub_uint32_t);
+ size += ALIGN_UP (sizeof ("memsize=XXXXXXXXXXXXXXXXXXXX"), 4)
+ + ALIGN_UP (sizeof ("highmemsize=XXXXXXXXXXXXXXXXXXXX"), 4)
+ + ALIGN_UP (sizeof ("busclock=XXXXXXXXXX"), 4)
+ + ALIGN_UP (sizeof ("cpuclock=XXXXXXXXXX"), 4);
+#endif
+
+ if (grub_elf_is_elf32 (elf))
+ err = grub_linux_load32 (elf, argv[0], &extra, size);
+ else
+ if (grub_elf_is_elf64 (elf))
+ err = grub_linux_load64 (elf, argv[0], &extra, size);
+ else
+ err = grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
+
+ grub_elf_close (elf);
+
+ if (err)
+ return err;
+
+#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
+ /* Create kernel command line. */
+ size = grub_loader_cmdline_size(argc, argv);
+ params = grub_malloc (size + sizeof (LINUX_IMAGE));
+ if (! params)
+ {
+ grub_linux_unload ();
+ return grub_errno;
+ }
+
+ grub_memcpy (params, LINUX_IMAGE, sizeof (LINUX_IMAGE));
+ grub_create_loader_cmdline (argc, argv, params + sizeof (LINUX_IMAGE) - 1,
+ size, GRUB_VERIFY_KERNEL_CMDLINE);
+#else
+ linux_argv = extra;
+ argv_off = (grub_uint8_t *) linux_argv - (grub_uint8_t *) playground;
+ extra = linux_argv + (linux_argc + 1 + 2);
+ linux_args = extra;
+
+ grub_memcpy (linux_args, "a0", sizeof ("a0"));
+ *linux_argv = (grub_uint8_t *) linux_args - (grub_uint8_t *) playground
+ + target_addr;
+ linux_argv++;
+ linux_args += ALIGN_UP (sizeof ("a0"), 4);
+
+ char *params = linux_args;
+
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ {
+ unsigned mtype = grub_arch_machine;
+ if (mtype >= ARRAY_SIZE (loongson_machtypes))
+ mtype = 0;
+ /* In Loongson platform, it is the responsibility of the bootloader/firmware
+ to supply the OS kernel with machine type information. */
+ grub_memcpy (linux_args, loongson_machtypes[mtype],
+ sizeof (loongson_machtypes[mtype]));
+ *linux_argv = (grub_uint8_t *) linux_args - (grub_uint8_t *) playground
+ + target_addr;
+ linux_argv++;
+ linux_args += ALIGN_UP (sizeof (loongson_machtypes[mtype]), 4);
+ }
+#endif
+
+ for (i = 1; i < argc; i++)
+ {
+ grub_memcpy (linux_args, argv[i], grub_strlen (argv[i]) + 1);
+ *linux_argv = (grub_uint8_t *) linux_args - (grub_uint8_t *) playground
+ + target_addr;
+ linux_argv++;
+ linux_args += ALIGN_UP (grub_strlen (argv[i]) + 1, 4);
+ }
+
+ *linux_args = '\0';
+
+ err = grub_verify_string (params, GRUB_VERIFY_KERNEL_CMDLINE);
+ if (err)
+ return err;
+
+ /* Reserve space for rd arguments. */
+ rd_addr_arg_off = (grub_uint8_t *) linux_args - (grub_uint8_t *) playground;
+ linux_args += ALIGN_UP (sizeof ("rd_start=0xXXXXXXXXXXXXXXXX"), 4);
+ *linux_argv = 0;
+ linux_argv++;
+
+ rd_size_arg_off = (grub_uint8_t *) linux_args - (grub_uint8_t *) playground;
+ linux_args += ALIGN_UP (sizeof ("rd_size=0xXXXXXXXXXXXXXXXX"), 4);
+ *linux_argv = 0;
+ linux_argv++;
+
+ *linux_argv = 0;
+
+ extra = linux_args;
+
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ linux_envp = extra;
+ envp_off = (grub_uint8_t *) linux_envp - (grub_uint8_t *) playground;
+ linux_envs = (char *) (linux_envp + 5);
+ grub_snprintf (linux_envs, sizeof ("memsize=XXXXXXXXXXXXXXXXXXXX"),
+ "memsize=%lld",
+ (unsigned long long) grub_mmap_get_lower () >> 20);
+ linux_envp[0] = (grub_uint8_t *) linux_envs - (grub_uint8_t *) playground
+ + target_addr;
+ linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4);
+ grub_snprintf (linux_envs, sizeof ("highmemsize=XXXXXXXXXXXXXXXXXXXX"),
+ "highmemsize=%lld",
+ (unsigned long long) grub_mmap_get_upper () >> 20);
+ linux_envp[1] = (grub_uint8_t *) linux_envs - (grub_uint8_t *) playground
+ + target_addr;
+ linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4);
+
+ grub_snprintf (linux_envs, sizeof ("busclock=XXXXXXXXXX"),
+ "busclock=%d", grub_arch_busclock);
+ linux_envp[2] = (grub_uint8_t *) linux_envs - (grub_uint8_t *) playground
+ + target_addr;
+ linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4);
+ grub_snprintf (linux_envs, sizeof ("cpuclock=XXXXXXXXXX"),
+ "cpuclock=%d", grub_arch_cpuclock);
+ linux_envp[3] = (grub_uint8_t *) linux_envs - (grub_uint8_t *) playground
+ + target_addr;
+ linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4);
+
+ linux_envp[4] = 0;
+#endif
+#endif
+
+ grub_loader_set (grub_linux_boot, grub_linux_unload, 1);
+ initrd_loaded = 0;
+ loaded = 1;
+ grub_dl_ref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_size_t size = 0;
+ void *initrd_src;
+ grub_addr_t initrd_dest;
+ grub_err_t err;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if (!loaded)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("you need to load the kernel first"));
+
+ if (initrd_loaded)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "only one initrd command can be issued.");
+
+ if (grub_initrd_init (argc, argv, &initrd_ctx))
+ goto fail;
+
+ size = grub_get_initrd_size (&initrd_ctx);
+
+ {
+ grub_relocator_chunk_t ch;
+
+ err = grub_relocator_alloc_chunk_align_safe (relocator, &ch, (target_addr & 0x1fffffff) +
+ linux_size + 0x10000, 0x10000000, size,
+ 0x10000, GRUB_RELOCATOR_PREFERENCE_NONE, 0);
+
+ if (err)
+ goto fail;
+ initrd_src = get_virtual_current_address (ch);
+ initrd_dest = get_physical_target_address (ch) | 0x80000000;
+ }
+
+ if (grub_initrd_load (&initrd_ctx, argv, initrd_src))
+ goto fail;
+
+#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
+ {
+ char *tmp;
+ tmp = grub_xasprintf ("%s rd_start=0x%" PRIxGRUB_ADDR
+ " rd_size=0x%" PRIxGRUB_ADDR, params,
+ initrd_dest, size);
+ if (!tmp)
+ goto fail;
+ grub_free (params);
+ params = tmp;
+ }
+#else
+ grub_snprintf ((char *) playground + rd_addr_arg_off,
+ sizeof ("rd_start=0xXXXXXXXXXXXXXXXX"), "rd_start=0x%llx",
+ (unsigned long long) initrd_dest);
+ ((grub_uint32_t *) (playground + argv_off))[linux_argc]
+ = target_addr + rd_addr_arg_off;
+ linux_argc++;
+
+ grub_snprintf ((char *) playground + rd_size_arg_off,
+ sizeof ("rd_size=0xXXXXXXXXXXXXXXXXX"), "rd_size=0x%llx",
+ (unsigned long long) size);
+ ((grub_uint32_t *) (playground + argv_off))[linux_argc]
+ = target_addr + rd_size_arg_off;
+ linux_argc++;
+#endif
+
+ initrd_loaded = 1;
+
+ fail:
+ grub_initrd_close (&initrd_ctx);
+
+ 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/multiboot.c b/grub-core/loader/multiboot.c
new file mode 100644
index 0000000..facb13f
--- /dev/null
+++ b/grub-core/loader/multiboot.c
@@ -0,0 +1,469 @@
+/* multiboot.c - boot a multiboot OS image. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * FIXME: The following features from the Multiboot specification still
+ * need to be implemented:
+ * - drives table
+ * - ROM configuration table
+ * - SMBIOS tables
+ * - Networking information
+ */
+
+#include <grub/loader.h>
+#include <grub/command.h>
+#ifdef GRUB_USE_MULTIBOOT2
+#include <grub/multiboot2.h>
+#define GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER
+#define GRUB_MULTIBOOT_CONSOLE_EGA_TEXT GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT
+#define GRUB_MULTIBOOT(x) grub_multiboot2_ ## x
+#else
+#include <grub/multiboot.h>
+#define GRUB_MULTIBOOT(x) grub_multiboot_ ## x
+#endif
+#include <grub/cpu/multiboot.h>
+#include <grub/elf.h>
+#include <grub/aout.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/cpu/relocator.h>
+#include <grub/video.h>
+#include <grub/memory.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#ifdef GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#endif
+
+struct grub_relocator *GRUB_MULTIBOOT (relocator) = NULL;
+grub_uint32_t GRUB_MULTIBOOT (payload_eip);
+#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
+#define DEFAULT_VIDEO_MODE "text"
+#else
+#define DEFAULT_VIDEO_MODE "auto"
+#endif
+
+static int accepts_video;
+static int accepts_ega_text;
+static int console_required;
+static grub_dl_t my_mod;
+
+
+/* Helper for grub_get_multiboot_mmap_count. */
+static int
+count_hook (grub_uint64_t addr __attribute__ ((unused)),
+ grub_uint64_t size __attribute__ ((unused)),
+ grub_memory_type_t type __attribute__ ((unused)), void *data)
+{
+ grub_size_t *count = data;
+
+ (*count)++;
+ return 0;
+}
+
+/* Return the length of the Multiboot mmap that will be needed to allocate
+ our platform's map. */
+grub_uint32_t
+GRUB_MULTIBOOT (get_mmap_count) (void)
+{
+ grub_size_t count = 0;
+
+ grub_mmap_iterate (count_hook, &count);
+
+ return count;
+}
+
+grub_err_t
+GRUB_MULTIBOOT (set_video_mode) (void)
+{
+ grub_err_t err;
+ const char *modevar;
+
+#if GRUB_MACHINE_HAS_VGA_TEXT
+ if (accepts_video)
+#endif
+ {
+ modevar = grub_env_get ("gfxpayload");
+ if (! modevar || *modevar == 0)
+ err = grub_video_set_mode (DEFAULT_VIDEO_MODE, 0, 0);
+ else
+ {
+ char *tmp;
+ tmp = grub_xasprintf ("%s;" DEFAULT_VIDEO_MODE, modevar);
+ if (! tmp)
+ return grub_errno;
+ err = grub_video_set_mode (tmp, 0, 0);
+ grub_free (tmp);
+ }
+ }
+#if GRUB_MACHINE_HAS_VGA_TEXT
+ else
+ err = grub_video_set_mode ("text", 0, 0);
+#endif
+
+ return err;
+}
+
+#ifdef GRUB_MACHINE_EFI
+#ifdef __x86_64__
+#define grub_relocator_efi_boot grub_relocator64_efi_boot
+#define grub_relocator_efi_state grub_relocator64_efi_state
+#endif
+#endif
+
+#ifdef grub_relocator_efi_boot
+static void
+efi_boot (struct grub_relocator *rel,
+ grub_uint32_t target)
+{
+#ifdef GRUB_USE_MULTIBOOT2
+ struct grub_relocator_efi_state state_efi = MULTIBOOT2_EFI_INITIAL_STATE;
+#else
+ struct grub_relocator_efi_state state_efi = MULTIBOOT_EFI_INITIAL_STATE;
+#endif
+ state_efi.MULTIBOOT_EFI_ENTRY_REGISTER = GRUB_MULTIBOOT (payload_eip);
+ state_efi.MULTIBOOT_EFI_MBI_REGISTER = target;
+
+ grub_relocator_efi_boot (rel, state_efi);
+}
+#else
+#define grub_efi_is_finished 1
+static void
+efi_boot (struct grub_relocator *rel __attribute__ ((unused)),
+ grub_uint32_t target __attribute__ ((unused)))
+{
+}
+#endif
+
+#if defined (__i386__) || defined (__x86_64__)
+static void
+normal_boot (struct grub_relocator *rel, struct grub_relocator32_state state)
+{
+ grub_relocator32_boot (rel, state, 0);
+}
+#else
+static void
+normal_boot (struct grub_relocator *rel, struct grub_relocator32_state state)
+{
+ grub_relocator32_boot (rel, state);
+}
+#endif
+
+static grub_err_t
+grub_multiboot_boot (void)
+{
+ grub_err_t err;
+
+#ifdef GRUB_USE_MULTIBOOT2
+ struct grub_relocator32_state state = MULTIBOOT2_INITIAL_STATE;
+#else
+ struct grub_relocator32_state state = MULTIBOOT_INITIAL_STATE;
+#endif
+ state.MULTIBOOT_ENTRY_REGISTER = GRUB_MULTIBOOT (payload_eip);
+
+ err = GRUB_MULTIBOOT (make_mbi) (&state.MULTIBOOT_MBI_REGISTER);
+
+ if (err)
+ return err;
+
+ if (grub_efi_is_finished)
+ normal_boot (GRUB_MULTIBOOT (relocator), state);
+ else
+ efi_boot (GRUB_MULTIBOOT (relocator), state.MULTIBOOT_MBI_REGISTER);
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_multiboot_unload (void)
+{
+ GRUB_MULTIBOOT (free_mbi) ();
+
+ grub_relocator_unload (GRUB_MULTIBOOT (relocator));
+ GRUB_MULTIBOOT (relocator) = NULL;
+
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_uint64_t highest_load;
+
+#define MULTIBOOT_LOAD_ELF64
+#include "multiboot_elfxx.c"
+#undef MULTIBOOT_LOAD_ELF64
+
+#define MULTIBOOT_LOAD_ELF32
+#include "multiboot_elfxx.c"
+#undef MULTIBOOT_LOAD_ELF32
+
+/* Load ELF32 or ELF64. */
+grub_err_t
+GRUB_MULTIBOOT (load_elf) (mbi_load_data_t *mld)
+{
+ if (grub_multiboot_is_elf32 (mld->buffer))
+ return grub_multiboot_load_elf32 (mld);
+ else if (grub_multiboot_is_elf64 (mld->buffer))
+ return grub_multiboot_load_elf64 (mld);
+
+ return grub_error (GRUB_ERR_UNKNOWN_OS, N_("invalid arch-dependent ELF magic"));
+}
+
+grub_err_t
+GRUB_MULTIBOOT (set_console) (int console_type, int accepted_consoles,
+ int width, int height, int depth,
+ int console_req)
+{
+ console_required = console_req;
+ if (!(accepted_consoles
+ & (GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER
+ | (GRUB_MACHINE_HAS_VGA_TEXT ? GRUB_MULTIBOOT_CONSOLE_EGA_TEXT : 0))))
+ {
+ if (console_required)
+ return grub_error (GRUB_ERR_BAD_OS,
+ "OS requires a console but none is available");
+ grub_puts_ (N_("WARNING: no console will be available to OS"));
+ accepts_video = 0;
+ accepts_ega_text = 0;
+ return GRUB_ERR_NONE;
+ }
+
+ if (console_type == GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER)
+ {
+ char *buf;
+ if (depth && width && height)
+ buf = grub_xasprintf ("%dx%dx%d,%dx%d,auto", width,
+ height, depth, width, height);
+ else if (width && height)
+ buf = grub_xasprintf ("%dx%d,auto", width, height);
+ else
+ buf = grub_strdup ("auto");
+
+ if (!buf)
+ return grub_errno;
+ grub_env_set ("gfxpayload", buf);
+ grub_free (buf);
+ }
+ else
+ {
+#if GRUB_MACHINE_HAS_VGA_TEXT
+ grub_env_set ("gfxpayload", "text");
+#else
+ /* Always use video if no VGA text is available. */
+ grub_env_set ("gfxpayload", "auto");
+#endif
+ }
+
+ accepts_video = !!(accepted_consoles & GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER);
+ accepts_ega_text = !!(accepted_consoles & GRUB_MULTIBOOT_CONSOLE_EGA_TEXT);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ grub_err_t err;
+
+ grub_loader_unset ();
+
+ highest_load = 0;
+
+#ifndef GRUB_USE_MULTIBOOT2
+ grub_multiboot_quirks = GRUB_MULTIBOOT_QUIRKS_NONE;
+ int option_found = 0;
+
+ do
+ {
+ 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++;
+ option_found = 1;
+ grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL;
+ }
+ } while (option_found);
+#endif
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_MULTIBOOT_KERNEL);
+ if (! file)
+ return grub_errno;
+
+ grub_dl_ref (my_mod);
+
+ /* Skip filename. */
+ GRUB_MULTIBOOT (init_mbi) (argc - 1, argv + 1);
+
+ grub_relocator_unload (GRUB_MULTIBOOT (relocator));
+ GRUB_MULTIBOOT (relocator) = grub_relocator_new ();
+
+ if (!GRUB_MULTIBOOT (relocator))
+ goto fail;
+
+ err = GRUB_MULTIBOOT (load) (file, argv[0]);
+ if (err)
+ goto fail;
+
+ GRUB_MULTIBOOT (set_bootdev) ();
+
+ grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 0);
+
+ fail:
+ if (file)
+ grub_file_close (file);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_relocator_unload (GRUB_MULTIBOOT (relocator));
+ GRUB_MULTIBOOT (relocator) = NULL;
+ grub_dl_unref (my_mod);
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ grub_ssize_t size;
+ void *module = NULL;
+ grub_addr_t target;
+ grub_err_t err;
+ int nounzip = 0;
+ grub_uint64_t lowest_addr = 0;
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if (grub_strcmp (argv[0], "--nounzip") == 0)
+ {
+ argv++;
+ argc--;
+ nounzip = 1;
+ }
+
+ if (argc == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if (!GRUB_MULTIBOOT (relocator))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("you need to load the kernel first"));
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_MULTIBOOT_MODULE
+ | (nounzip ? GRUB_FILE_TYPE_NO_DECOMPRESS : GRUB_FILE_TYPE_NONE));
+ if (! file)
+ 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
+
+ size = grub_file_size (file);
+ if (size)
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch,
+ lowest_addr, UP_TO_TOP32 (size),
+ size, MULTIBOOT_MOD_ALIGN,
+ GRUB_RELOCATOR_PREFERENCE_NONE, 1);
+ if (err)
+ {
+ grub_file_close (file);
+ return err;
+ }
+ module = get_virtual_current_address (ch);
+ target = get_physical_target_address (ch);
+ }
+ else
+ {
+ module = 0;
+ target = 0;
+ }
+
+ err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
+ if (err)
+ {
+ grub_file_close (file);
+ return err;
+ }
+
+ if (size && grub_file_read (file, module, size) != size)
+ {
+ grub_file_close (file);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
+ argv[0]);
+ return grub_errno;
+ }
+
+ grub_file_close (file);
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd_multiboot, cmd_module;
+
+GRUB_MOD_INIT(multiboot)
+{
+ cmd_multiboot =
+#ifdef GRUB_USE_MULTIBOOT2
+ grub_register_command ("multiboot2", grub_cmd_multiboot,
+ 0, N_("Load a multiboot 2 kernel."));
+ cmd_module =
+ grub_register_command ("module2", grub_cmd_module,
+ 0, N_("Load a multiboot 2 module."));
+#else
+ grub_register_command ("multiboot", grub_cmd_multiboot,
+ 0, N_("Load a multiboot kernel."));
+ cmd_module =
+ grub_register_command ("module", grub_cmd_module,
+ 0, N_("Load a multiboot module."));
+#endif
+
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(multiboot)
+{
+ grub_unregister_command (cmd_multiboot);
+ grub_unregister_command (cmd_module);
+}
diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c
new file mode 100644
index 0000000..f2318e0
--- /dev/null
+++ b/grub-core/loader/multiboot_elfxx.c
@@ -0,0 +1,298 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if defined(MULTIBOOT_LOAD_ELF32)
+# define XX 32
+# define E_MACHINE MULTIBOOT_ELF32_MACHINE
+# define ELFCLASSXX ELFCLASS32
+# define Elf_Ehdr Elf32_Ehdr
+# define Elf_Phdr Elf32_Phdr
+# define Elf_Shdr Elf32_Shdr
+#elif defined(MULTIBOOT_LOAD_ELF64)
+# define XX 64
+# define E_MACHINE MULTIBOOT_ELF64_MACHINE
+# define ELFCLASSXX ELFCLASS64
+# define Elf_Ehdr Elf64_Ehdr
+# define Elf_Phdr Elf64_Phdr
+# define Elf_Shdr Elf64_Shdr
+#else
+#error "I'm confused"
+#endif
+
+#include <grub/i386/relocator.h>
+
+#define CONCAT(a,b) CONCAT_(a, b)
+#define CONCAT_(a,b) a ## b
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+/* Check if BUFFER contains ELF32 (or ELF64). */
+static int
+CONCAT(grub_multiboot_is_elf, XX) (void *buffer)
+{
+ Elf_Ehdr *ehdr = (Elf_Ehdr *) buffer;
+
+ return ehdr->e_ident[EI_CLASS] == ELFCLASSXX;
+}
+
+static grub_err_t
+CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld)
+{
+ Elf_Ehdr *ehdr = (Elf_Ehdr *) mld->buffer;
+ char *phdr_base;
+ grub_err_t err;
+ grub_relocator_chunk_t ch;
+ grub_uint32_t load_offset = 0, load_size;
+ int i;
+ void *source = NULL;
+
+ if (ehdr->e_ident[EI_MAG0] != ELFMAG0
+ || ehdr->e_ident[EI_MAG1] != ELFMAG1
+ || ehdr->e_ident[EI_MAG2] != ELFMAG2
+ || ehdr->e_ident[EI_MAG3] != ELFMAG3
+ || ehdr->e_ident[EI_DATA] != ELFDATA2LSB)
+ return grub_error(GRUB_ERR_UNKNOWN_OS, N_("invalid arch-independent ELF magic"));
+
+ if (ehdr->e_ident[EI_CLASS] != ELFCLASSXX || ehdr->e_machine != E_MACHINE
+ || ehdr->e_version != EV_CURRENT)
+ return grub_error (GRUB_ERR_UNKNOWN_OS, N_("invalid arch-dependent ELF magic"));
+
+ if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN)
+ 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 + (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 *) mld->buffer + ehdr->e_phoff;
+#define phdr(i) ((Elf_Phdr *) (phdr_base + (i) * ehdr->e_phentsize))
+
+ mld->link_base_addr = ~0;
+
+ /* Calculate lowest and highest load address. */
+ for (i = 0; i < ehdr->e_phnum; i++)
+ if (phdr(i)->p_type == PT_LOAD)
+ {
+ mld->link_base_addr = grub_min (mld->link_base_addr, phdr(i)->p_paddr);
+ highest_load = grub_max (highest_load, phdr(i)->p_paddr + phdr(i)->p_memsz);
+ }
+
+#ifdef MULTIBOOT_LOAD_ELF64
+ if (highest_load >= 0x100000000)
+ return grub_error (GRUB_ERR_BAD_OS, "segment crosses 4 GiB border");
+#endif
+
+ if (mld->relocatable)
+ {
+ load_size = highest_load - mld->link_base_addr;
+
+ grub_dprintf ("multiboot_loader", "align=0x%lx, preference=0x%x, "
+ "load_size=0x%x, avoid_efi_boot_services=%d\n",
+ (long) mld->align, mld->preference, load_size,
+ mld->avoid_efi_boot_services);
+
+ if (load_size > mld->max_addr || mld->min_addr > mld->max_addr - load_size)
+ return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size");
+
+ err = grub_relocator_alloc_chunk_align_safe (GRUB_MULTIBOOT (relocator), &ch,
+ mld->min_addr, mld->max_addr,
+ load_size, mld->align ? mld->align : 1,
+ mld->preference, mld->avoid_efi_boot_services);
+
+ if (err)
+ {
+ grub_dprintf ("multiboot_loader", "Cannot allocate memory for OS image\n");
+ return err;
+ }
+
+ mld->load_base_addr = get_physical_target_address (ch);
+ source = get_virtual_current_address (ch);
+ }
+ else
+ mld->load_base_addr = mld->link_base_addr;
+
+ grub_dprintf ("multiboot_loader", "relocatable=%d, link_base_addr=0x%x, "
+ "load_base_addr=0x%x\n", mld->relocatable,
+ mld->link_base_addr, mld->load_base_addr);
+
+ /* Load every loadable segment in memory. */
+ for (i = 0; i < ehdr->e_phnum; i++)
+ {
+ if (phdr(i)->p_type == PT_LOAD)
+ {
+
+ grub_dprintf ("multiboot_loader", "segment %d: paddr=0x%lx, memsz=0x%lx, vaddr=0x%lx\n",
+ i, (long) phdr(i)->p_paddr, (long) phdr(i)->p_memsz, (long) phdr(i)->p_vaddr);
+
+ if (mld->relocatable)
+ {
+ load_offset = phdr(i)->p_paddr - mld->link_base_addr;
+ grub_dprintf ("multiboot_loader", "segment %d: load_offset=0x%x\n", i, load_offset);
+ }
+ else
+ {
+ err = grub_relocator_alloc_chunk_addr (GRUB_MULTIBOOT (relocator), &ch,
+ phdr(i)->p_paddr, phdr(i)->p_memsz);
+
+ if (err)
+ {
+ grub_dprintf ("multiboot_loader", "Cannot allocate memory for OS image\n");
+ return err;
+ }
+
+ source = get_virtual_current_address (ch);
+ }
+
+ if (phdr(i)->p_filesz != 0)
+ {
+ if (grub_file_seek (mld->file, (grub_off_t) phdr(i)->p_offset)
+ == (grub_off_t) -1)
+ return grub_errno;
+
+ if (grub_file_read (mld->file, (grub_uint8_t *) source + load_offset, phdr(i)->p_filesz)
+ != (grub_ssize_t) phdr(i)->p_filesz)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
+ mld->filename);
+ return grub_errno;
+ }
+ }
+
+ if (phdr(i)->p_filesz < phdr(i)->p_memsz)
+ grub_memset ((grub_uint8_t *) source + load_offset + phdr(i)->p_filesz, 0,
+ phdr(i)->p_memsz - phdr(i)->p_filesz);
+ }
+ }
+
+ for (i = 0; i < ehdr->e_phnum; i++)
+ if (phdr(i)->p_vaddr <= ehdr->e_entry
+ && phdr(i)->p_vaddr + phdr(i)->p_memsz > ehdr->e_entry)
+ {
+ GRUB_MULTIBOOT (payload_eip) = (ehdr->e_entry - phdr(i)->p_vaddr)
+ + phdr(i)->p_paddr;
+#ifdef MULTIBOOT_LOAD_ELF64
+# ifdef __mips
+ /* We still in 32-bit mode. */
+ if ((ehdr->e_entry - phdr(i)->p_vaddr)
+ + phdr(i)->p_paddr < 0xffffffff80000000ULL)
+ return grub_error (GRUB_ERR_BAD_OS, "invalid entry point for ELF64");
+# else
+ /* We still in 32-bit mode. */
+ if ((ehdr->e_entry - phdr(i)->p_vaddr)
+ + phdr(i)->p_paddr > 0xffffffff)
+ return grub_error (GRUB_ERR_BAD_OS, "invalid entry point for ELF64");
+# endif
+#endif
+ break;
+ }
+
+ if (i == ehdr->e_phnum)
+ return grub_error (GRUB_ERR_BAD_OS, "entry point isn't in a segment");
+
+#if defined (__i386__) || defined (__x86_64__)
+
+#elif defined (__mips)
+ GRUB_MULTIBOOT (payload_eip) |= 0x80000000;
+#else
+#error Please complete this
+#endif
+
+ if (ehdr->e_shnum)
+ {
+ grub_uint8_t *shdr, *shdrptr;
+
+ shdr = grub_calloc (ehdr->e_shnum, ehdr->e_shentsize);
+ if (!shdr)
+ return grub_errno;
+
+ if (grub_file_seek (mld->file, ehdr->e_shoff) == (grub_off_t) -1)
+ {
+ grub_free (shdr);
+ return grub_errno;
+ }
+
+ if (grub_file_read (mld->file, shdr, (grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize)
+ != (grub_ssize_t) ehdr->e_shnum * ehdr->e_shentsize)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
+ mld->filename);
+ return grub_errno;
+ }
+
+ for (shdrptr = shdr, i = 0; i < ehdr->e_shnum;
+ shdrptr += ehdr->e_shentsize, i++)
+ {
+ Elf_Shdr *sh = (Elf_Shdr *) shdrptr;
+ void *src;
+ grub_addr_t target;
+
+ if (mld->mbi_ver >= 2 && (sh->sh_type == SHT_REL || sh->sh_type == SHT_RELA))
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "ELF files with relocs are not supported yet");
+
+ /* This section is a loaded section,
+ so we don't care. */
+ if (sh->sh_addr != 0)
+ continue;
+
+ /* This section is empty, so we don't care. */
+ if (sh->sh_size == 0)
+ continue;
+
+ err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, 0,
+ UP_TO_TOP32 (sh->sh_size),
+ sh->sh_size, sh->sh_addralign,
+ GRUB_RELOCATOR_PREFERENCE_NONE,
+ mld->avoid_efi_boot_services);
+ if (err)
+ {
+ grub_dprintf ("multiboot_loader", "Error loading shdr %d\n", i);
+ return err;
+ }
+ src = get_virtual_current_address (ch);
+ target = get_physical_target_address (ch);
+
+ if (grub_file_seek (mld->file, sh->sh_offset) == (grub_off_t) -1)
+ return grub_errno;
+
+ if (grub_file_read (mld->file, src, sh->sh_size)
+ != (grub_ssize_t) sh->sh_size)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
+ mld->filename);
+ return grub_errno;
+ }
+ sh->sh_addr = target;
+ }
+ GRUB_MULTIBOOT (add_elfsyms) (ehdr->e_shnum, ehdr->e_shentsize,
+ ehdr->e_shstrndx, shdr);
+ }
+
+#undef phdr
+
+ return grub_errno;
+}
+
+#undef XX
+#undef E_MACHINE
+#undef ELFCLASSXX
+#undef Elf_Ehdr
+#undef Elf_Phdr
+#undef Elf_Shdr
diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
new file mode 100644
index 0000000..9a943d7
--- /dev/null
+++ b/grub-core/loader/multiboot_mbi2.c
@@ -0,0 +1,1128 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010,2011,2012,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/memory.h>
+#ifdef GRUB_MACHINE_PCBIOS
+#include <grub/machine/biosnum.h>
+#include <grub/machine/apm.h>
+#include <grub/machine/memory.h>
+#endif
+#include <grub/multiboot2.h>
+#include <grub/cpu/multiboot.h>
+#include <grub/cpu/relocator.h>
+#include <grub/disk.h>
+#include <grub/device.h>
+#include <grub/partition.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/video.h>
+#include <grub/acpi.h>
+#include <grub/i18n.h>
+#include <grub/net.h>
+#include <grub/lib/cmdline.h>
+
+#if defined (GRUB_MACHINE_EFI)
+#include <grub/efi/efi.h>
+#endif
+
+#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU)
+#include <grub/i386/pc/vbe.h>
+#define HAS_VGA_TEXT 1
+#else
+#define HAS_VGA_TEXT 0
+#endif
+
+#if defined (__i386__) || defined (__x86_64__)
+#define MBI_MIN_ADDR 0x1000
+#else
+#define MBI_MIN_ADDR 0
+#endif
+
+struct module
+{
+ struct module *next;
+ grub_addr_t start;
+ grub_size_t size;
+ char *cmdline;
+ int cmdline_size;
+};
+
+static struct module *modules, *modules_last;
+static grub_size_t cmdline_size;
+static grub_size_t total_modcmd;
+static unsigned modcnt;
+static char *cmdline = NULL;
+static int bootdev_set;
+static grub_uint32_t biosdev, slice, part;
+static grub_size_t elf_sec_num, elf_sec_entsize;
+static unsigned elf_sec_shstrndx;
+static void *elf_sections;
+static int keep_bs = 0;
+static grub_uint32_t load_base_addr;
+
+void
+grub_multiboot2_add_elfsyms (grub_size_t num, grub_size_t entsize,
+ unsigned shndx, void *data)
+{
+ elf_sec_num = num;
+ elf_sec_shstrndx = shndx;
+ elf_sec_entsize = 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 == MULTIBOOT2_HEADER_MAGIC
+ && !(header->magic + header->architecture
+ + header->header_length + header->checksum)
+ && header->architecture == MULTIBOOT2_ARCHITECTURE_CURRENT)
+ return header;
+ }
+ return NULL;
+}
+
+grub_err_t
+grub_multiboot2_load (grub_file_t file, const char *filename)
+{
+ grub_ssize_t len;
+ struct multiboot_header *header;
+ grub_err_t err;
+ struct multiboot_header_tag *tag;
+ struct multiboot_header_tag_address *addr_tag = NULL;
+ struct multiboot_header_tag_relocatable *rel_tag;
+ int entry_specified = 0, efi_entry_specified = 0;
+ grub_addr_t entry = 0, efi_entry = 0;
+ grub_uint32_t console_required = 0;
+ struct multiboot_header_tag_framebuffer *fbtag = NULL;
+ int accepted_consoles = GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT;
+ mbi_load_data_t mld;
+
+ mld.mbi_ver = 2;
+ mld.relocatable = 0;
+
+ mld.buffer = grub_malloc (MULTIBOOT_SEARCH);
+ if (!mld.buffer)
+ return grub_errno;
+
+ len = grub_file_read (file, mld.buffer, MULTIBOOT_SEARCH);
+ if (len < 32)
+ {
+ grub_free (mld.buffer);
+ return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), filename);
+ }
+
+ COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0);
+
+ header = find_header (mld.buffer, len);
+
+ if (header == 0)
+ {
+ grub_free (mld.buffer);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no multiboot header found");
+ }
+
+ COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % 4 == 0);
+
+ keep_bs = 0;
+
+ for (tag = (struct multiboot_header_tag *) (header + 1);
+ tag->type != MULTIBOOT_TAG_TYPE_END;
+ tag = (struct multiboot_header_tag *) ((grub_uint32_t *) tag + ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) / 4))
+ switch (tag->type)
+ {
+ case MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST:
+ {
+ unsigned i;
+ struct multiboot_header_tag_information_request *request_tag
+ = (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))
+ / sizeof (request_tag->requests[0]); i++)
+ switch (request_tag->requests[i])
+ {
+ case MULTIBOOT_TAG_TYPE_END:
+ case MULTIBOOT_TAG_TYPE_CMDLINE:
+ case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME:
+ case MULTIBOOT_TAG_TYPE_MODULE:
+ case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
+ case MULTIBOOT_TAG_TYPE_BOOTDEV:
+ case MULTIBOOT_TAG_TYPE_MMAP:
+ case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
+ case MULTIBOOT_TAG_TYPE_VBE:
+ case MULTIBOOT_TAG_TYPE_ELF_SECTIONS:
+ case MULTIBOOT_TAG_TYPE_APM:
+ case MULTIBOOT_TAG_TYPE_EFI32:
+ case MULTIBOOT_TAG_TYPE_EFI64:
+ case MULTIBOOT_TAG_TYPE_ACPI_OLD:
+ case MULTIBOOT_TAG_TYPE_ACPI_NEW:
+ case MULTIBOOT_TAG_TYPE_NETWORK:
+ case MULTIBOOT_TAG_TYPE_EFI_MMAP:
+ case MULTIBOOT_TAG_TYPE_EFI_BS:
+ case MULTIBOOT_TAG_TYPE_EFI32_IH:
+ case MULTIBOOT_TAG_TYPE_EFI64_IH:
+ case MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR:
+ break;
+
+ default:
+ grub_free (mld.buffer);
+ return grub_error (GRUB_ERR_UNKNOWN_OS,
+ "unsupported information tag: 0x%x",
+ request_tag->requests[i]);
+ }
+ break;
+ }
+
+ case MULTIBOOT_HEADER_TAG_ADDRESS:
+ addr_tag = (struct multiboot_header_tag_address *) tag;
+ break;
+
+ case MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS:
+ entry_specified = 1;
+ entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr;
+ break;
+
+ case MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64:
+#if defined (GRUB_MACHINE_EFI) && defined (__x86_64__)
+ efi_entry_specified = 1;
+ efi_entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr;
+#endif
+ break;
+
+ case MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS:
+ if (!(((struct multiboot_header_tag_console_flags *) tag)->console_flags
+ & MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED))
+ accepted_consoles &= ~GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT;
+ if (((struct multiboot_header_tag_console_flags *) tag)->console_flags
+ & MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED)
+ console_required = 1;
+ break;
+
+ case MULTIBOOT_HEADER_TAG_FRAMEBUFFER:
+ fbtag = (struct multiboot_header_tag_framebuffer *) tag;
+ accepted_consoles |= GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER;
+ break;
+
+ case MULTIBOOT_HEADER_TAG_RELOCATABLE:
+ mld.relocatable = 1;
+ rel_tag = (struct multiboot_header_tag_relocatable *) tag;
+ mld.min_addr = rel_tag->min_addr;
+ mld.max_addr = rel_tag->max_addr;
+ mld.align = rel_tag->align;
+ switch (rel_tag->preference)
+ {
+ case MULTIBOOT_LOAD_PREFERENCE_LOW:
+ mld.preference = GRUB_RELOCATOR_PREFERENCE_LOW;
+ break;
+
+ case MULTIBOOT_LOAD_PREFERENCE_HIGH:
+ mld.preference = GRUB_RELOCATOR_PREFERENCE_HIGH;
+ break;
+
+ default:
+ mld.preference = GRUB_RELOCATOR_PREFERENCE_NONE;
+ }
+ break;
+
+ /* GRUB always page-aligns modules. */
+ case MULTIBOOT_HEADER_TAG_MODULE_ALIGN:
+ break;
+
+ case MULTIBOOT_HEADER_TAG_EFI_BS:
+#ifdef GRUB_MACHINE_EFI
+ keep_bs = 1;
+#endif
+ break;
+
+ default:
+ if (! (tag->flags & MULTIBOOT_HEADER_TAG_OPTIONAL))
+ {
+ grub_free (mld.buffer);
+ return grub_error (GRUB_ERR_UNKNOWN_OS,
+ "unsupported tag: 0x%x", tag->type);
+ }
+ break;
+ }
+
+ if (addr_tag && !entry_specified && !(keep_bs && efi_entry_specified))
+ {
+ grub_free (mld.buffer);
+ return grub_error (GRUB_ERR_UNKNOWN_OS,
+ "load address tag without entry address tag");
+ }
+
+ if (addr_tag)
+ {
+ grub_uint64_t load_addr = (addr_tag->load_addr + 1)
+ ? addr_tag->load_addr : (addr_tag->header_addr
+ - ((char *) header - (char *) mld.buffer));
+ int offset = ((char *) header - (char *) mld.buffer -
+ (addr_tag->header_addr - load_addr));
+ int load_size = ((addr_tag->load_end_addr == 0) ? file->size - offset :
+ addr_tag->load_end_addr - addr_tag->load_addr);
+ grub_size_t code_size;
+ void *source;
+ grub_relocator_chunk_t ch;
+
+ if (addr_tag->bss_end_addr)
+ code_size = (addr_tag->bss_end_addr - load_addr);
+ else
+ code_size = load_size;
+
+ if (mld.relocatable)
+ {
+ if (code_size > mld.max_addr || mld.min_addr > mld.max_addr - code_size)
+ {
+ grub_free (mld.buffer);
+ return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size");
+ }
+
+ err = grub_relocator_alloc_chunk_align_safe (grub_multiboot2_relocator, &ch,
+ mld.min_addr, mld.max_addr,
+ code_size, mld.align ? mld.align : 1,
+ mld.preference, keep_bs);
+ }
+ else
+ err = grub_relocator_alloc_chunk_addr (grub_multiboot2_relocator,
+ &ch, load_addr, code_size);
+ if (err)
+ {
+ grub_dprintf ("multiboot_loader", "Error loading aout kludge\n");
+ grub_free (mld.buffer);
+ return err;
+ }
+ mld.link_base_addr = load_addr;
+ mld.load_base_addr = get_physical_target_address (ch);
+ source = get_virtual_current_address (ch);
+
+ grub_dprintf ("multiboot_loader", "link_base_addr=0x%x, load_base_addr=0x%x, "
+ "load_size=0x%lx, relocatable=%d\n", mld.link_base_addr,
+ mld.load_base_addr, (long) code_size, mld.relocatable);
+
+ if (mld.relocatable)
+ grub_dprintf ("multiboot_loader", "align=0x%lx, preference=0x%x, avoid_efi_boot_services=%d\n",
+ (long) mld.align, mld.preference, keep_bs);
+
+ if ((grub_file_seek (file, offset)) == (grub_off_t) -1)
+ {
+ grub_free (mld.buffer);
+ return grub_errno;
+ }
+
+ grub_file_read (file, source, load_size);
+ if (grub_errno)
+ {
+ grub_free (mld.buffer);
+ return grub_errno;
+ }
+
+ if (addr_tag->bss_end_addr)
+ grub_memset ((grub_uint8_t *) source + load_size, 0,
+ addr_tag->bss_end_addr - load_addr - load_size);
+ }
+ else
+ {
+ mld.file = file;
+ mld.filename = filename;
+ mld.avoid_efi_boot_services = keep_bs;
+ err = grub_multiboot2_load_elf (&mld);
+ if (err)
+ {
+ grub_free (mld.buffer);
+ return err;
+ }
+ }
+
+ load_base_addr = mld.load_base_addr;
+
+ if (keep_bs && efi_entry_specified)
+ grub_multiboot2_payload_eip = efi_entry;
+ else if (entry_specified)
+ grub_multiboot2_payload_eip = entry;
+
+ if (mld.relocatable)
+ {
+ /*
+ * Both branches are mathematically equivalent. However, it looks
+ * that real life (C?) is more complicated. I am trying to avoid
+ * wrap around here if mld.load_base_addr < mld.link_base_addr.
+ * If you look at C operator precedence then everything should work.
+ * However, I am not 100% sure that a given compiler will not
+ * optimize/break this stuff. So, maybe we should use signed
+ * 64-bit int here.
+ */
+ if (mld.load_base_addr >= mld.link_base_addr)
+ grub_multiboot2_payload_eip += mld.load_base_addr - mld.link_base_addr;
+ else
+ grub_multiboot2_payload_eip -= mld.link_base_addr - mld.load_base_addr;
+ }
+
+ if (fbtag)
+ err = grub_multiboot2_set_console (GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER,
+ accepted_consoles,
+ fbtag->width, fbtag->height,
+ fbtag->depth, console_required);
+ else
+ err = grub_multiboot2_set_console (GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT,
+ accepted_consoles,
+ 0, 0, 0, console_required);
+ return err;
+}
+
+static grub_size_t
+acpiv2_size (void)
+{
+#if GRUB_MACHINE_HAS_ACPI
+ struct grub_acpi_rsdp_v20 *p = grub_acpi_get_rsdpv2 ();
+
+ if (!p)
+ return 0;
+
+ return ALIGN_UP (sizeof (struct multiboot_tag_old_acpi)
+ + p->length, MULTIBOOT_TAG_ALIGN);
+#else
+ return 0;
+#endif
+}
+
+#ifdef GRUB_MACHINE_EFI
+
+static grub_efi_uintn_t efi_mmap_size = 0;
+
+#endif
+
+static grub_size_t
+net_size (void)
+{
+ struct grub_net_network_level_interface *net;
+ grub_size_t ret = 0;
+
+ FOR_NET_NETWORK_LEVEL_INTERFACES(net)
+ if (net->dhcp_ack)
+ ret += ALIGN_UP (sizeof (struct multiboot_tag_network) + net->dhcp_acklen,
+ MULTIBOOT_TAG_ALIGN);
+ return ret;
+}
+
+static grub_size_t
+grub_multiboot2_get_mbi_size (void)
+{
+#ifdef GRUB_MACHINE_EFI
+ if (!keep_bs && !efi_mmap_size)
+ efi_mmap_size = grub_efi_find_mmap_size ();
+#endif
+ return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag)
+ + sizeof (struct multiboot_tag)
+ + (sizeof (struct multiboot_tag_string)
+ + ALIGN_UP (cmdline_size, MULTIBOOT_TAG_ALIGN))
+ + (sizeof (struct multiboot_tag_string)
+ + ALIGN_UP (sizeof (PACKAGE_STRING), MULTIBOOT_TAG_ALIGN))
+ + (modcnt * sizeof (struct multiboot_tag_module) + total_modcmd)
+ + ALIGN_UP (sizeof (struct multiboot_tag_basic_meminfo),
+ MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP (sizeof (struct multiboot_tag_bootdev), MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP (sizeof (struct multiboot_tag_elf_sections), MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP (elf_sec_entsize * elf_sec_num, MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP ((sizeof (struct multiboot_tag_mmap)
+ + grub_multiboot2_get_mmap_count ()
+ * sizeof (struct multiboot_mmap_entry)), MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP (sizeof (struct multiboot_tag_framebuffer), MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP (sizeof (struct multiboot_tag_old_acpi)
+ + sizeof (struct grub_acpi_rsdp_v10), MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP (sizeof (struct multiboot_tag_load_base_addr), MULTIBOOT_TAG_ALIGN)
+ + acpiv2_size ()
+ + net_size ()
+#ifdef GRUB_MACHINE_EFI
+ + ALIGN_UP (sizeof (struct multiboot_tag_efi32), MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP (sizeof (struct multiboot_tag_efi32_ih), MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP (sizeof (struct multiboot_tag_efi64), MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP (sizeof (struct multiboot_tag_efi64_ih), MULTIBOOT_TAG_ALIGN)
+ + ALIGN_UP (sizeof (struct multiboot_tag_efi_mmap)
+ + efi_mmap_size, MULTIBOOT_TAG_ALIGN)
+#endif
+ + sizeof (struct multiboot_tag_vbe) + MULTIBOOT_TAG_ALIGN - 1
+ + sizeof (struct multiboot_tag_apm) + MULTIBOOT_TAG_ALIGN - 1;
+}
+
+/* Helper for grub_fill_multiboot_mmap. */
+static int
+grub_fill_multiboot_mmap_iter (grub_uint64_t addr, grub_uint64_t size,
+ grub_memory_type_t type, void *data)
+{
+ struct multiboot_mmap_entry **mmap_entry = data;
+
+ (*mmap_entry)->addr = addr;
+ (*mmap_entry)->len = size;
+ (*mmap_entry)->type = type;
+ (*mmap_entry)->zero = 0;
+ (*mmap_entry)++;
+
+ return 0;
+}
+
+/* Fill previously allocated Multiboot mmap. */
+static void
+grub_fill_multiboot_mmap (struct multiboot_tag_mmap *tag)
+{
+ struct multiboot_mmap_entry *mmap_entry = tag->entries;
+
+ tag->type = MULTIBOOT_TAG_TYPE_MMAP;
+ tag->size = sizeof (struct multiboot_tag_mmap)
+ + sizeof (struct multiboot_mmap_entry) * grub_multiboot2_get_mmap_count ();
+ tag->entry_size = sizeof (struct multiboot_mmap_entry);
+ tag->entry_version = 0;
+
+ grub_mmap_iterate (grub_fill_multiboot_mmap_iter, &mmap_entry);
+}
+
+#if defined (GRUB_MACHINE_PCBIOS)
+static void
+fill_vbe_tag (struct multiboot_tag_vbe *tag)
+{
+ grub_vbe_status_t status;
+ void *scratch = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+
+ tag->type = MULTIBOOT_TAG_TYPE_VBE;
+ tag->size = 0;
+
+ status = grub_vbe_bios_get_controller_info (scratch);
+ if (status != GRUB_VBE_STATUS_OK)
+ return;
+
+ grub_memcpy (&tag->vbe_control_info, scratch,
+ sizeof (struct grub_vbe_info_block));
+
+ status = grub_vbe_bios_get_mode (scratch);
+ tag->vbe_mode = *(grub_uint32_t *) scratch;
+ if (status != GRUB_VBE_STATUS_OK)
+ return;
+
+ /* get_mode_info isn't available for mode 3. */
+ if (tag->vbe_mode == 3)
+ {
+ struct grub_vbe_mode_info_block *mode_info = (void *) &tag->vbe_mode_info;
+ grub_memset (mode_info, 0,
+ sizeof (struct grub_vbe_mode_info_block));
+ mode_info->memory_model = GRUB_VBE_MEMORY_MODEL_TEXT;
+ mode_info->x_resolution = 80;
+ mode_info->y_resolution = 25;
+ }
+ else
+ {
+ status = grub_vbe_bios_get_mode_info (tag->vbe_mode, scratch);
+ if (status != GRUB_VBE_STATUS_OK)
+ return;
+ grub_memcpy (&tag->vbe_mode_info, scratch,
+ sizeof (struct grub_vbe_mode_info_block));
+ }
+ grub_vbe_bios_get_pm_interface (&tag->vbe_interface_seg,
+ &tag->vbe_interface_off,
+ &tag->vbe_interface_len);
+
+ tag->size = sizeof (*tag);
+}
+#endif
+
+static grub_err_t
+retrieve_video_parameters (grub_properly_aligned_t **ptrorig)
+{
+ grub_err_t err;
+ struct grub_video_mode_info mode_info;
+ void *framebuffer;
+ grub_video_driver_id_t driv_id;
+ struct grub_video_palette_data palette[256];
+ struct multiboot_tag_framebuffer *tag
+ = (struct multiboot_tag_framebuffer *) *ptrorig;
+
+ err = grub_multiboot2_set_video_mode ();
+ if (err)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ grub_video_get_palette (0, ARRAY_SIZE (palette), palette);
+
+ driv_id = grub_video_get_driver_id ();
+#if HAS_VGA_TEXT
+ if (driv_id == GRUB_VIDEO_DRIVER_NONE)
+ {
+ struct grub_vbe_mode_info_block vbe_mode_info;
+ grub_uint32_t vbe_mode;
+
+#if defined (GRUB_MACHINE_PCBIOS)
+ {
+ grub_vbe_status_t status;
+ void *scratch = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ status = grub_vbe_bios_get_mode (scratch);
+ vbe_mode = *(grub_uint32_t *) scratch;
+ if (status != GRUB_VBE_STATUS_OK)
+ return GRUB_ERR_NONE;
+ }
+#else
+ vbe_mode = 3;
+#endif
+
+ /* get_mode_info isn't available for mode 3. */
+ if (vbe_mode == 3)
+ {
+ grub_memset (&vbe_mode_info, 0,
+ sizeof (struct grub_vbe_mode_info_block));
+ vbe_mode_info.memory_model = GRUB_VBE_MEMORY_MODEL_TEXT;
+ vbe_mode_info.x_resolution = 80;
+ vbe_mode_info.y_resolution = 25;
+ }
+#if defined (GRUB_MACHINE_PCBIOS)
+ else
+ {
+ grub_vbe_status_t status;
+ void *scratch = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ status = grub_vbe_bios_get_mode_info (vbe_mode, scratch);
+ if (status != GRUB_VBE_STATUS_OK)
+ return GRUB_ERR_NONE;
+ grub_memcpy (&vbe_mode_info, scratch,
+ sizeof (struct grub_vbe_mode_info_block));
+ }
+#endif
+
+ if (vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_TEXT)
+ {
+ tag = (struct multiboot_tag_framebuffer *) *ptrorig;
+ tag->common.type = MULTIBOOT_TAG_TYPE_FRAMEBUFFER;
+ tag->common.size = 0;
+
+ tag->common.framebuffer_addr = 0xb8000;
+
+ tag->common.framebuffer_pitch = 2 * vbe_mode_info.x_resolution;
+ tag->common.framebuffer_width = vbe_mode_info.x_resolution;
+ tag->common.framebuffer_height = vbe_mode_info.y_resolution;
+
+ tag->common.framebuffer_bpp = 16;
+
+ tag->common.framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT;
+ tag->common.size = sizeof (tag->common);
+ tag->common.reserved = 0;
+ *ptrorig += ALIGN_UP (tag->common.size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+ return GRUB_ERR_NONE;
+ }
+#else
+ if (driv_id == GRUB_VIDEO_DRIVER_NONE)
+ return GRUB_ERR_NONE;
+#endif
+
+#if GRUB_MACHINE_HAS_VBE
+ {
+ struct multiboot_tag_vbe *tag_vbe = (struct multiboot_tag_vbe *) *ptrorig;
+
+ fill_vbe_tag (tag_vbe);
+
+ *ptrorig += ALIGN_UP (tag_vbe->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+#endif
+
+ err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
+ if (err)
+ return err;
+
+ tag = (struct multiboot_tag_framebuffer *) *ptrorig;
+ tag->common.type = MULTIBOOT_TAG_TYPE_FRAMEBUFFER;
+ tag->common.size = 0;
+
+ tag->common.framebuffer_addr = (grub_addr_t) framebuffer;
+ tag->common.framebuffer_pitch = mode_info.pitch;
+
+ tag->common.framebuffer_width = mode_info.width;
+ tag->common.framebuffer_height = mode_info.height;
+
+ tag->common.framebuffer_bpp = mode_info.bpp;
+
+ tag->common.reserved = 0;
+
+ if (mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
+ {
+ unsigned i;
+ tag->common.framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED;
+ tag->framebuffer_palette_num_colors = mode_info.number_of_colors;
+ if (tag->framebuffer_palette_num_colors > ARRAY_SIZE (palette))
+ tag->framebuffer_palette_num_colors = ARRAY_SIZE (palette);
+ tag->common.size = sizeof (struct multiboot_tag_framebuffer_common)
+ + sizeof (multiboot_uint16_t) + tag->framebuffer_palette_num_colors
+ * sizeof (struct multiboot_color);
+ for (i = 0; i < tag->framebuffer_palette_num_colors; i++)
+ {
+ tag->framebuffer_palette[i].red = palette[i].r;
+ tag->framebuffer_palette[i].green = palette[i].g;
+ tag->framebuffer_palette[i].blue = palette[i].b;
+ }
+ }
+ else
+ {
+ tag->common.framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_RGB;
+ tag->framebuffer_red_field_position = mode_info.red_field_pos;
+ tag->framebuffer_red_mask_size = mode_info.red_mask_size;
+ tag->framebuffer_green_field_position = mode_info.green_field_pos;
+ tag->framebuffer_green_mask_size = mode_info.green_mask_size;
+ tag->framebuffer_blue_field_position = mode_info.blue_field_pos;
+ tag->framebuffer_blue_mask_size = mode_info.blue_mask_size;
+
+ tag->common.size = sizeof (struct multiboot_tag_framebuffer_common) + 6;
+ }
+ *ptrorig += ALIGN_UP (tag->common.size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_multiboot2_make_mbi (grub_uint32_t *target)
+{
+ grub_properly_aligned_t *ptrorig;
+ grub_properly_aligned_t *mbistart;
+ grub_err_t err;
+ grub_size_t bufsize;
+ grub_relocator_chunk_t ch;
+
+ bufsize = grub_multiboot2_get_mbi_size ();
+
+ COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % sizeof (grub_properly_aligned_t) == 0);
+
+ err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch,
+ MBI_MIN_ADDR, UP_TO_TOP32 (bufsize),
+ bufsize, MULTIBOOT_TAG_ALIGN,
+ GRUB_RELOCATOR_PREFERENCE_NONE, 1);
+ if (err)
+ return err;
+
+ ptrorig = get_virtual_current_address (ch);
+#if defined (__i386__) || defined (__x86_64__)
+ *target = get_physical_target_address (ch);
+#elif defined (__mips)
+ *target = get_physical_target_address (ch) | 0x80000000;
+#else
+#error Please complete this
+#endif
+
+ mbistart = ptrorig;
+ COMPILE_TIME_ASSERT ((2 * sizeof (grub_uint32_t))
+ % sizeof (grub_properly_aligned_t) == 0);
+ COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN
+ % sizeof (grub_properly_aligned_t) == 0);
+ ptrorig += (2 * sizeof (grub_uint32_t)) / sizeof (grub_properly_aligned_t);
+
+ {
+ struct multiboot_tag_load_base_addr *tag = (struct multiboot_tag_load_base_addr *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR;
+ tag->size = sizeof (struct multiboot_tag_load_base_addr);
+ tag->load_base_addr = load_base_addr;
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+
+ {
+ struct multiboot_tag_string *tag = (struct multiboot_tag_string *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_CMDLINE;
+ tag->size = sizeof (struct multiboot_tag_string) + cmdline_size;
+ grub_memcpy (tag->string, cmdline, cmdline_size);
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+
+ {
+ struct multiboot_tag_string *tag = (struct multiboot_tag_string *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME;
+ tag->size = sizeof (struct multiboot_tag_string) + sizeof (PACKAGE_STRING);
+ grub_memcpy (tag->string, PACKAGE_STRING, sizeof (PACKAGE_STRING));
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+
+#ifdef GRUB_MACHINE_PCBIOS
+ {
+ struct grub_apm_info info;
+ if (grub_apm_get_info (&info))
+ {
+ struct multiboot_tag_apm *tag = (struct multiboot_tag_apm *) ptrorig;
+
+ tag->type = MULTIBOOT_TAG_TYPE_APM;
+ tag->size = sizeof (struct multiboot_tag_apm);
+
+ tag->cseg = info.cseg;
+ tag->offset = info.offset;
+ tag->cseg_16 = info.cseg_16;
+ tag->dseg = info.dseg;
+ tag->flags = info.flags;
+ tag->cseg_len = info.cseg_len;
+ tag->dseg_len = info.dseg_len;
+ tag->cseg_16_len = info.cseg_16_len;
+ tag->version = info.version;
+
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+ }
+#endif
+
+ {
+ unsigned i;
+ struct module *cur;
+
+ for (i = 0, cur = modules; i < modcnt; i++, cur = cur->next)
+ {
+ struct multiboot_tag_module *tag
+ = (struct multiboot_tag_module *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_MODULE;
+ tag->size = sizeof (struct multiboot_tag_module) + cur->cmdline_size;
+ tag->mod_start = cur->start;
+ tag->mod_end = tag->mod_start + cur->size;
+ grub_memcpy (tag->cmdline, cur->cmdline, cur->cmdline_size);
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+ }
+
+ if (!keep_bs)
+ {
+ struct multiboot_tag_mmap *tag = (struct multiboot_tag_mmap *) ptrorig;
+ grub_fill_multiboot_mmap (tag);
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+
+ {
+ struct multiboot_tag_elf_sections *tag
+ = (struct multiboot_tag_elf_sections *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_ELF_SECTIONS;
+ tag->size = sizeof (struct multiboot_tag_elf_sections)
+ + elf_sec_entsize * elf_sec_num;
+ grub_memcpy (tag->sections, elf_sections, elf_sec_entsize * elf_sec_num);
+ tag->num = elf_sec_num;
+ tag->entsize = elf_sec_entsize;
+ tag->shndx = elf_sec_shstrndx;
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+
+ if (!keep_bs)
+ {
+ struct multiboot_tag_basic_meminfo *tag
+ = (struct multiboot_tag_basic_meminfo *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_BASIC_MEMINFO;
+ tag->size = sizeof (struct multiboot_tag_basic_meminfo);
+
+ /* Convert from bytes to kilobytes. */
+ tag->mem_lower = grub_mmap_get_lower () / 1024;
+ tag->mem_upper = grub_mmap_get_upper () / 1024;
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+
+ {
+ struct grub_net_network_level_interface *net;
+
+ FOR_NET_NETWORK_LEVEL_INTERFACES(net)
+ if (net->dhcp_ack)
+ {
+ struct multiboot_tag_network *tag
+ = (struct multiboot_tag_network *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_NETWORK;
+ tag->size = sizeof (struct multiboot_tag_network) + net->dhcp_acklen;
+ grub_memcpy (tag->dhcpack, net->dhcp_ack, net->dhcp_acklen);
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+ }
+
+ if (bootdev_set)
+ {
+ struct multiboot_tag_bootdev *tag
+ = (struct multiboot_tag_bootdev *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_BOOTDEV;
+ tag->size = sizeof (struct multiboot_tag_bootdev);
+
+ tag->biosdev = biosdev;
+ tag->slice = slice;
+ tag->part = part;
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+
+ {
+ err = retrieve_video_parameters (&ptrorig);
+ if (err)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+
+#if defined (GRUB_MACHINE_EFI) && defined (__x86_64__)
+ {
+ struct multiboot_tag_efi64 *tag = (struct multiboot_tag_efi64 *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_EFI64;
+ tag->size = sizeof (*tag);
+ tag->pointer = (grub_addr_t) grub_efi_system_table;
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+#endif
+
+#if defined (GRUB_MACHINE_EFI) && defined (__i386__)
+ {
+ struct multiboot_tag_efi32 *tag = (struct multiboot_tag_efi32 *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_EFI32;
+ tag->size = sizeof (*tag);
+ tag->pointer = (grub_addr_t) grub_efi_system_table;
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+#endif
+
+#if GRUB_MACHINE_HAS_ACPI
+ {
+ struct multiboot_tag_old_acpi *tag = (struct multiboot_tag_old_acpi *)
+ ptrorig;
+ struct grub_acpi_rsdp_v10 *a = grub_acpi_get_rsdpv1 ();
+ if (a)
+ {
+ tag->type = MULTIBOOT_TAG_TYPE_ACPI_OLD;
+ tag->size = sizeof (*tag) + sizeof (*a);
+ grub_memcpy (tag->rsdp, a, sizeof (*a));
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+ }
+
+ {
+ struct multiboot_tag_new_acpi *tag = (struct multiboot_tag_new_acpi *)
+ ptrorig;
+ struct grub_acpi_rsdp_v20 *a = grub_acpi_get_rsdpv2 ();
+ if (a)
+ {
+ tag->type = MULTIBOOT_TAG_TYPE_ACPI_NEW;
+ tag->size = sizeof (*tag) + a->length;
+ grub_memcpy (tag->rsdp, a, a->length);
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+ }
+#endif
+
+#ifdef GRUB_MACHINE_EFI
+ {
+ struct multiboot_tag_efi_mmap *tag = (struct multiboot_tag_efi_mmap *) ptrorig;
+ grub_efi_uintn_t efi_desc_size;
+ grub_efi_uint32_t efi_desc_version;
+
+ if (!keep_bs)
+ {
+ tag->type = MULTIBOOT_TAG_TYPE_EFI_MMAP;
+ tag->size = sizeof (*tag) + efi_mmap_size;
+
+ err = grub_efi_finish_boot_services (&efi_mmap_size, tag->efi_mmap, NULL,
+ &efi_desc_size, &efi_desc_version);
+
+ if (err)
+ return err;
+
+ tag->descr_size = efi_desc_size;
+ tag->descr_vers = efi_desc_version;
+ tag->size = sizeof (*tag) + efi_mmap_size;
+
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+ }
+
+ if (keep_bs)
+ {
+ {
+ struct multiboot_tag *tag = (struct multiboot_tag *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_EFI_BS;
+ tag->size = sizeof (struct multiboot_tag);
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+
+#ifdef __i386__
+ {
+ struct multiboot_tag_efi32_ih *tag = (struct multiboot_tag_efi32_ih *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_EFI32_IH;
+ tag->size = sizeof (struct multiboot_tag_efi32_ih);
+ tag->pointer = (grub_addr_t) grub_efi_image_handle;
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+#endif
+
+#ifdef __x86_64__
+ {
+ struct multiboot_tag_efi64_ih *tag = (struct multiboot_tag_efi64_ih *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_EFI64_IH;
+ tag->size = sizeof (struct multiboot_tag_efi64_ih);
+ tag->pointer = (grub_addr_t) grub_efi_image_handle;
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+#endif
+ }
+#endif
+
+ {
+ struct multiboot_tag *tag = (struct multiboot_tag *) ptrorig;
+ tag->type = MULTIBOOT_TAG_TYPE_END;
+ tag->size = sizeof (struct multiboot_tag);
+ ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+ / sizeof (grub_properly_aligned_t);
+ }
+
+ ((grub_uint32_t *) mbistart)[0] = (char *) ptrorig - (char *) mbistart;
+ ((grub_uint32_t *) mbistart)[1] = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_multiboot2_free_mbi (void)
+{
+ struct module *cur, *next;
+
+ cmdline_size = 0;
+ total_modcmd = 0;
+ modcnt = 0;
+ grub_free (cmdline);
+ cmdline = NULL;
+ bootdev_set = 0;
+
+ for (cur = modules; cur; cur = next)
+ {
+ next = cur->next;
+ grub_free (cur->cmdline);
+ grub_free (cur);
+ }
+ modules = NULL;
+ modules_last = NULL;
+}
+
+grub_err_t
+grub_multiboot2_init_mbi (int argc, char *argv[])
+{
+ grub_ssize_t len = 0;
+
+ grub_multiboot2_free_mbi ();
+
+ len = grub_loader_cmdline_size (argc, argv);
+
+ cmdline = grub_malloc (len);
+ if (! cmdline)
+ return grub_errno;
+ cmdline_size = len;
+
+ return grub_create_loader_cmdline (argc, argv, cmdline, cmdline_size,
+ GRUB_VERIFY_KERNEL_CMDLINE);
+}
+
+grub_err_t
+grub_multiboot2_add_module (grub_addr_t start, grub_size_t size,
+ int argc, char *argv[])
+{
+ struct module *newmod;
+ grub_size_t len = 0;
+ grub_err_t err;
+
+ newmod = grub_malloc (sizeof (*newmod));
+ if (!newmod)
+ return grub_errno;
+ newmod->start = start;
+ newmod->size = size;
+
+ len = grub_loader_cmdline_size (argc, argv);
+
+ newmod->cmdline = grub_malloc (len);
+ if (! newmod->cmdline)
+ {
+ grub_free (newmod);
+ return grub_errno;
+ }
+ newmod->cmdline_size = len;
+ total_modcmd += ALIGN_UP (len, MULTIBOOT_TAG_ALIGN);
+
+ err = grub_create_loader_cmdline (argc, argv, newmod->cmdline,
+ newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE);
+ if (err)
+ {
+ grub_free (newmod->cmdline);
+ grub_free (newmod);
+ return err;
+ }
+
+ if (modules_last)
+ modules_last->next = newmod;
+ else
+ modules = newmod;
+ modules_last = newmod;
+
+ modcnt++;
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_multiboot2_set_bootdev (void)
+{
+ grub_device_t dev;
+
+ slice = ~0;
+ part = ~0;
+
+#ifdef GRUB_MACHINE_PCBIOS
+ biosdev = grub_get_root_biosnumber ();
+#else
+ biosdev = 0xffffffff;
+#endif
+
+ if (biosdev == 0xffffffff)
+ return;
+
+ dev = grub_device_open (0);
+ if (dev && dev->disk && dev->disk->partition)
+ {
+ if (dev->disk->partition->parent)
+ {
+ part = dev->disk->partition->number;
+ slice = dev->disk->partition->parent->number;
+ }
+ else
+ slice = dev->disk->partition->number;
+ }
+ if (dev)
+ grub_device_close (dev);
+
+ bootdev_set = 1;
+}
diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c
new file mode 100644
index 0000000..818b2a8
--- /dev/null
+++ b/grub-core/loader/powerpc/ieee1275/linux.c
@@ -0,0 +1,393 @@
+/* linux.c - boot Linux */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/elf.h>
+#include <grub/elfload.h>
+#include <grub/loader.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/memory.h>
+#include <grub/lib/cmdline.h>
+#include <grub/cache.h>
+#include <grub/linux.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define ELF32_LOADMASK (0xc0000000UL)
+#define ELF64_LOADMASK (0xc000000000000000ULL)
+
+static grub_dl_t my_mod;
+
+static int loaded;
+
+static grub_addr_t initrd_addr;
+static grub_size_t initrd_size;
+
+static grub_addr_t linux_addr;
+static grub_addr_t linux_entry;
+static grub_size_t linux_size;
+
+static char *linux_args;
+
+typedef void (*kernel_entry_t) (void *, unsigned long, int (void *),
+ unsigned long, unsigned long);
+
+/* Context for grub_linux_claimmap_iterate. */
+struct grub_linux_claimmap_iterate_ctx
+{
+ grub_addr_t target;
+ grub_size_t size;
+ grub_size_t align;
+ grub_addr_t found_addr;
+};
+
+/* Helper for grub_linux_claimmap_iterate. */
+static int
+alloc_mem (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type,
+ void *data)
+{
+ struct grub_linux_claimmap_iterate_ctx *ctx = data;
+
+ grub_uint64_t end = addr + len;
+ addr = ALIGN_UP (addr, ctx->align);
+ ctx->target = ALIGN_UP (ctx->target, ctx->align);
+
+ /* Target above the memory chunk. */
+ if (type != GRUB_MEMORY_AVAILABLE || ctx->target > end)
+ return 0;
+
+ /* Target inside the memory chunk. */
+ if (ctx->target >= addr && ctx->target < end &&
+ ctx->size <= end - ctx->target)
+ {
+ if (grub_claimmap (ctx->target, ctx->size) == GRUB_ERR_NONE)
+ {
+ ctx->found_addr = ctx->target;
+ return 1;
+ }
+ grub_print_error ();
+ }
+ /* Target below the memory chunk. */
+ if (ctx->target < addr && addr + ctx->size <= end)
+ {
+ if (grub_claimmap (addr, ctx->size) == GRUB_ERR_NONE)
+ {
+ ctx->found_addr = addr;
+ return 1;
+ }
+ grub_print_error ();
+ }
+ return 0;
+}
+
+static grub_addr_t
+grub_linux_claimmap_iterate (grub_addr_t target, grub_size_t size,
+ grub_size_t align)
+{
+ struct grub_linux_claimmap_iterate_ctx ctx = {
+ .target = target,
+ .size = size,
+ .align = align,
+ .found_addr = (grub_addr_t) -1
+ };
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM))
+ {
+ grub_uint64_t addr = target;
+ if (addr < GRUB_IEEE1275_STATIC_HEAP_START
+ + GRUB_IEEE1275_STATIC_HEAP_LEN)
+ addr = GRUB_IEEE1275_STATIC_HEAP_START
+ + GRUB_IEEE1275_STATIC_HEAP_LEN;
+ addr = ALIGN_UP (addr, align);
+ if (grub_claimmap (addr, size) == GRUB_ERR_NONE)
+ return addr;
+ return (grub_addr_t) -1;
+ }
+
+
+ grub_machine_mmap_iterate (alloc_mem, &ctx);
+
+ return ctx.found_addr;
+}
+
+static grub_err_t
+grub_linux_boot (void)
+{
+ kernel_entry_t linuxmain;
+ grub_ssize_t actual;
+
+ grub_arch_sync_caches ((void *) linux_addr, linux_size);
+ /* Set the command line arguments. */
+ grub_ieee1275_set_property (grub_ieee1275_chosen, "bootargs", linux_args,
+ grub_strlen (linux_args) + 1, &actual);
+
+ grub_dprintf ("loader", "Entry point: 0x%x\n", linux_entry);
+ grub_dprintf ("loader", "Initrd at: 0x%x, size 0x%x\n", initrd_addr,
+ initrd_size);
+ grub_dprintf ("loader", "Boot arguments: %s\n", linux_args);
+ grub_dprintf ("loader", "Jumping to Linux...\n");
+
+ /* Boot the kernel. */
+ linuxmain = (kernel_entry_t) linux_entry;
+ linuxmain ((void *) initrd_addr, initrd_size, grub_ieee1275_entry_fn, 0, 0);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_linux_release_mem (void)
+{
+ grub_free (linux_args);
+ linux_args = 0;
+
+ if (linux_addr && grub_ieee1275_release (linux_addr, linux_size))
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot release memory");
+
+ if (initrd_addr && grub_ieee1275_release (initrd_addr, initrd_size))
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot release memory");
+
+ linux_addr = 0;
+ initrd_addr = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_linux_unload (void)
+{
+ grub_err_t err;
+
+ err = grub_linux_release_mem ();
+ grub_dl_unref (my_mod);
+
+ loaded = 0;
+
+ return err;
+}
+
+static grub_err_t
+grub_linux_load32 (grub_elf_t elf, const char *filename)
+{
+ Elf32_Addr base_addr;
+ grub_addr_t seg_addr;
+ grub_uint32_t align;
+ grub_uint32_t offset;
+ Elf32_Addr entry;
+
+ linux_size = grub_elf32_size (elf, &base_addr, &align);
+ if (linux_size == 0)
+ return grub_errno;
+ /* Pad it; the kernel scribbles over memory beyond its load address. */
+ linux_size += 0x100000;
+
+ /* Linux's entry point incorrectly contains a virtual address. */
+ entry = elf->ehdr.ehdr32.e_entry & ~ELF32_LOADMASK;
+
+ /* Linux's incorrectly contains a virtual address. */
+ base_addr &= ~ELF32_LOADMASK;
+ offset = entry - base_addr;
+
+ /* On some systems, firmware occupies the memory we're trying to use.
+ * Happily, Linux can be loaded anywhere (it relocates itself). Iterate
+ * until we find an open area. */
+ seg_addr = grub_linux_claimmap_iterate (base_addr & ~ELF32_LOADMASK, linux_size, align);
+ if (seg_addr == (grub_addr_t) -1)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't claim memory");
+
+ linux_entry = seg_addr + offset;
+ linux_addr = seg_addr;
+
+ /* Now load the segments into the area we claimed. */
+ return grub_elf32_load (elf, filename, (void *) (seg_addr - base_addr), GRUB_ELF_LOAD_FLAGS_30BITS, 0, 0);
+}
+
+static grub_err_t
+grub_linux_load64 (grub_elf_t elf, const char *filename)
+{
+ Elf64_Addr base_addr;
+ grub_addr_t seg_addr;
+ grub_uint64_t align;
+ grub_uint64_t offset;
+ Elf64_Addr entry;
+
+ linux_size = grub_elf64_size (elf, &base_addr, &align);
+ if (linux_size == 0)
+ return grub_errno;
+ /* Pad it; the kernel scribbles over memory beyond its load address. */
+ linux_size += 0x100000;
+
+ base_addr &= ~ELF64_LOADMASK;
+ entry = elf->ehdr.ehdr64.e_entry & ~ELF64_LOADMASK;
+ offset = entry - base_addr;
+ /* Linux's incorrectly contains a virtual address. */
+
+ /* On some systems, firmware occupies the memory we're trying to use.
+ * Happily, Linux can be loaded anywhere (it relocates itself). Iterate
+ * until we find an open area. */
+ seg_addr = grub_linux_claimmap_iterate (base_addr & ~ELF64_LOADMASK, linux_size, align);
+ if (seg_addr == (grub_addr_t) -1)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't claim memory");
+
+ linux_entry = seg_addr + offset;
+ linux_addr = seg_addr;
+
+ /* Now load the segments into the area we claimed. */
+ return grub_elf64_load (elf, filename, (void *) (grub_addr_t) (seg_addr - base_addr), GRUB_ELF_LOAD_FLAGS_62BITS, 0, 0);
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_elf_t elf = 0;
+ int size;
+
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto out;
+ }
+
+ elf = grub_elf_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
+ if (! elf)
+ goto out;
+
+ if (elf->ehdr.ehdr32.e_type != ET_EXEC && elf->ehdr.ehdr32.e_type != ET_DYN)
+ {
+ grub_error (GRUB_ERR_UNKNOWN_OS,
+ N_("this ELF file is not of the right type"));
+ goto out;
+ }
+
+ /* Release the previously used memory. */
+ grub_loader_unset ();
+
+ if (grub_elf_is_elf32 (elf))
+ grub_linux_load32 (elf, argv[0]);
+ else
+ if (grub_elf_is_elf64 (elf))
+ grub_linux_load64 (elf, argv[0]);
+ else
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("invalid arch-dependent ELF magic"));
+ goto out;
+ }
+
+ size = grub_loader_cmdline_size(argc, argv);
+ linux_args = grub_malloc (size + sizeof (LINUX_IMAGE));
+ if (! linux_args)
+ goto out;
+
+ /* Create kernel command line. */
+ grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE));
+ if (grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1,
+ size, GRUB_VERIFY_KERNEL_CMDLINE))
+ goto out;
+
+out:
+
+ if (elf)
+ grub_elf_close (elf);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_linux_release_mem ();
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ }
+ else
+ {
+ grub_loader_set (grub_linux_boot, grub_linux_unload, 1);
+ initrd_addr = 0;
+ loaded = 1;
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_size_t size = 0;
+ grub_addr_t first_addr;
+ grub_addr_t addr;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
+
+ 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;
+
+ size = grub_get_initrd_size (&initrd_ctx);
+
+ first_addr = linux_addr + linux_size;
+
+ /* Attempt to claim at a series of addresses until successful in
+ the same way that grub_rescue_cmd_linux does. */
+ addr = grub_linux_claimmap_iterate (first_addr, size, 0x100000);
+ if (addr == (grub_addr_t) -1)
+ goto fail;
+
+ grub_dprintf ("loader", "Loading initrd at 0x%x, size 0x%x\n", addr, size);
+
+ if (grub_initrd_load (&initrd_ctx, argv, (void *) addr))
+ goto fail;
+
+ initrd_addr = addr;
+ initrd_size = size;
+
+ fail:
+ grub_initrd_close (&initrd_ctx);
+
+ 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/riscv/linux.c b/grub-core/loader/riscv/linux.c
new file mode 100644
index 0000000..d17c488
--- /dev/null
+++ b/grub-core/loader/riscv/linux.c
@@ -0,0 +1,59 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/command.h>
+#include <grub/dl.h>
+#include <grub/lib/cmdline.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("Linux not supported yet"));
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("Linux not supported yet"));
+
+ 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."));
+}
+
+GRUB_MOD_FINI (linux)
+{
+ grub_unregister_command (cmd_linux);
+ grub_unregister_command (cmd_initrd);
+}
diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c
new file mode 100644
index 0000000..bb47ee0
--- /dev/null
+++ b/grub-core/loader/sparc64/ieee1275/linux.c
@@ -0,0 +1,521 @@
+/* linux.c - boot Linux */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/elf.h>
+#include <grub/elfload.h>
+#include <grub/loader.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/memory.h>
+#include <grub/lib/cmdline.h>
+#include <grub/linux.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+
+static int loaded;
+
+/* /virtual-memory/translations property layout */
+struct grub_ieee1275_translation {
+ grub_uint64_t vaddr;
+ grub_uint64_t size;
+ grub_uint64_t data;
+};
+
+static struct grub_ieee1275_translation *of_trans;
+static int of_num_trans;
+
+static grub_addr_t phys_base;
+static grub_addr_t grub_phys_start;
+static grub_addr_t grub_phys_end;
+
+static grub_addr_t initrd_addr;
+static grub_addr_t initrd_paddr;
+static grub_size_t initrd_size;
+
+static Elf64_Addr linux_entry;
+static grub_addr_t linux_addr;
+static grub_addr_t linux_paddr;
+static grub_size_t linux_size;
+
+static char *linux_args;
+
+struct linux_bootstr_info {
+ int len, valid;
+ char buf[];
+};
+
+struct linux_hdrs {
+ /* All HdrS versions support these fields. */
+ unsigned int start_insns[2];
+ char magic[4]; /* "HdrS" */
+ unsigned int linux_kernel_version; /* LINUX_VERSION_CODE */
+ unsigned short hdrs_version;
+ unsigned short root_flags;
+ unsigned short root_dev;
+ unsigned short ram_flags;
+ unsigned int __deprecated_ramdisk_image;
+ unsigned int ramdisk_size;
+
+ /* HdrS versions 0x0201 and higher only */
+ char *reboot_command;
+
+ /* HdrS versions 0x0202 and higher only */
+ struct linux_bootstr_info *bootstr_info;
+
+ /* HdrS versions 0x0301 and higher only */
+ unsigned long ramdisk_image;
+};
+
+static grub_err_t
+grub_linux_boot (void)
+{
+ struct linux_bootstr_info *bp;
+ struct linux_hdrs *hp;
+ grub_addr_t addr;
+
+ hp = (struct linux_hdrs *) linux_addr;
+
+ /* Any pointer we dereference in the kernel image must be relocated
+ to where we actually loaded the kernel. */
+ addr = (grub_addr_t) hp->bootstr_info;
+ addr += (linux_addr - linux_entry);
+ bp = (struct linux_bootstr_info *) addr;
+
+ /* Set the command line arguments, unless the kernel has been
+ built with a fixed CONFIG_CMDLINE. */
+ if (!bp->valid)
+ {
+ int len = grub_strlen (linux_args) + 1;
+ if (bp->len < len)
+ len = bp->len;
+ grub_memcpy(bp->buf, linux_args, len);
+ bp->buf[len-1] = '\0';
+ bp->valid = 1;
+ }
+
+ if (initrd_addr)
+ {
+ /* The kernel expects the physical address, adjusted relative
+ to the lowest address advertised in "/memory"'s available
+ property.
+
+ The history of this is that back when the kernel only supported
+ specifying a 32-bit ramdisk address, this was the way to still
+ be able to specify the ramdisk physical address even if memory
+ started at some place above 4GB.
+
+ The magic 0x400000 is KERNBASE, I have no idea why SILO adds
+ that term into the address, but it does and thus we have to do
+ it too as this is what the kernel expects. */
+ hp->ramdisk_image = initrd_paddr - phys_base + 0x400000;
+ hp->ramdisk_size = initrd_size;
+ }
+
+ grub_dprintf ("loader", "Entry point: 0x%lx\n", linux_addr);
+ grub_dprintf ("loader", "Initrd at: 0x%lx, size 0x%lx\n", initrd_addr,
+ initrd_size);
+ grub_dprintf ("loader", "Boot arguments: %s\n", linux_args);
+ grub_dprintf ("loader", "Jumping to Linux...\n");
+
+ /* Boot the kernel. */
+ 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;
+}
+
+static grub_err_t
+grub_linux_release_mem (void)
+{
+ grub_free (linux_args);
+ linux_args = 0;
+ linux_addr = 0;
+ initrd_addr = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_linux_unload (void)
+{
+ grub_err_t err;
+
+ err = grub_linux_release_mem ();
+ grub_dl_unref (my_mod);
+
+ loaded = 0;
+
+ return err;
+}
+
+#define FOUR_MB (4 * 1024 * 1024)
+
+/* Context for alloc_phys. */
+struct alloc_phys_ctx
+{
+ grub_addr_t size;
+ grub_addr_t ret;
+};
+
+/* Helper for alloc_phys. */
+static int
+alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,
+ grub_memory_type_t type, void *data)
+{
+ struct alloc_phys_ctx *ctx = data;
+ grub_addr_t end = addr + len;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+
+ addr = ALIGN_UP (addr, FOUR_MB);
+ if (addr + ctx->size >= end)
+ return 0;
+
+ /* 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);
+
+ if (addr >= linux_paddr && addr < linux_end)
+ {
+ addr = linux_end;
+ if (addr + ctx->size >= end)
+ return 0;
+ }
+ if ((addr + ctx->size) >= linux_paddr
+ && (addr + ctx->size) < linux_end)
+ {
+ addr = linux_end;
+ if (addr + ctx->size >= end)
+ return 0;
+ }
+ }
+
+ ctx->ret = addr;
+ return 1;
+}
+
+static grub_addr_t
+alloc_phys (grub_addr_t size)
+{
+ struct alloc_phys_ctx ctx = {
+ .size = size,
+ .ret = (grub_addr_t) -1
+ };
+
+ grub_machine_mmap_iterate (alloc_phys_choose, &ctx);
+
+ return ctx.ret;
+}
+
+static grub_err_t
+grub_linux_load64 (grub_elf_t elf, const char *filename)
+{
+ grub_addr_t off, paddr, base;
+ int ret;
+
+ linux_entry = elf->ehdr.ehdr64.e_entry;
+ linux_addr = 0x40004000;
+ off = 0x4000;
+ linux_size = grub_elf64_size (elf, 0, 0);
+ if (linux_size == 0)
+ return grub_errno;
+
+ grub_dprintf ("loader", "Attempting to claim at 0x%lx, size 0x%lx.\n",
+ linux_addr, linux_size);
+
+ paddr = alloc_phys (linux_size + off);
+ if (paddr == (grub_addr_t) -1)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "couldn't allocate physical memory");
+ ret = grub_ieee1275_map (paddr, linux_addr - off,
+ linux_size + off, IEEE1275_MAP_DEFAULT);
+ if (ret)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "couldn't map physical memory");
+
+ grub_dprintf ("loader", "Loading Linux at vaddr 0x%lx, paddr 0x%lx, size 0x%lx\n",
+ linux_addr, paddr, linux_size);
+
+ linux_paddr = paddr;
+
+ base = linux_entry - off;
+
+ /* Now load the segments into the area we claimed. */
+ return grub_elf64_load (elf, filename, (void *) (linux_addr - off - base), GRUB_ELF_LOAD_FLAGS_NONE, 0, 0);
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ grub_elf_t elf = 0;
+ int size;
+
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto out;
+ }
+
+ file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL);
+ if (!file)
+ goto out;
+
+ elf = grub_elf_file (file, argv[0]);
+ if (! elf)
+ goto out;
+
+ if (elf->ehdr.ehdr32.e_type != ET_EXEC)
+ {
+ grub_error (GRUB_ERR_UNKNOWN_OS,
+ N_("this ELF file is not of the right type"));
+ goto out;
+ }
+
+ /* Release the previously used memory. */
+ grub_loader_unset ();
+
+ if (grub_elf_is_elf64 (elf))
+ grub_linux_load64 (elf, argv[0]);
+ else
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("invalid arch-dependent ELF magic"));
+ goto out;
+ }
+
+ size = grub_loader_cmdline_size(argc, argv);
+
+ linux_args = grub_malloc (size + sizeof (LINUX_IMAGE));
+ if (! linux_args)
+ goto out;
+
+ /* Create kernel command line. */
+ grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE));
+ if (grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1,
+ size, GRUB_VERIFY_KERNEL_CMDLINE))
+ goto out;
+
+out:
+ if (elf)
+ grub_elf_close (elf);
+ else if (file)
+ grub_file_close (file);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_linux_release_mem ();
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ }
+ else
+ {
+ grub_loader_set (grub_linux_boot, grub_linux_unload, 1);
+ initrd_addr = 0;
+ loaded = 1;
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_size_t size = 0;
+ grub_addr_t paddr;
+ grub_addr_t addr;
+ int ret;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
+
+ 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;
+
+ size = grub_get_initrd_size (&initrd_ctx);
+
+ addr = 0x60000000;
+
+ paddr = alloc_phys (size);
+ if (paddr == (grub_addr_t) -1)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "couldn't allocate physical memory");
+ goto fail;
+ }
+ ret = grub_ieee1275_map (paddr, addr, size, IEEE1275_MAP_DEFAULT);
+ if (ret)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "couldn't map physical memory");
+ goto fail;
+ }
+
+ grub_dprintf ("loader", "Loading initrd at vaddr 0x%lx, paddr 0x%lx, size 0x%lx\n",
+ addr, paddr, size);
+
+ if (grub_initrd_load (&initrd_ctx, argv, (void *) addr))
+ goto fail;
+
+ initrd_addr = addr;
+ initrd_paddr = paddr;
+ initrd_size = size;
+
+ fail:
+ grub_initrd_close (&initrd_ctx);
+
+ return grub_errno;
+}
+
+/* Helper for determine_phys_base. */
+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 != GRUB_MEMORY_AVAILABLE)
+ return 0;
+ if (addr < phys_base)
+ phys_base = addr;
+ return 0;
+}
+
+static void
+determine_phys_base (void)
+{
+ phys_base = ~(grub_uint64_t) 0;
+ grub_machine_mmap_iterate (get_physbase, NULL);
+}
+
+static void
+fetch_translations (void)
+{
+ grub_ieee1275_phandle_t node;
+ grub_ssize_t actual;
+ int i;
+
+ if (grub_ieee1275_finddevice ("/virtual-memory", &node))
+ {
+ grub_printf ("Cannot find /virtual-memory node.\n");
+ return;
+ }
+
+ if (grub_ieee1275_get_property_length (node, "translations", &actual))
+ {
+ grub_printf ("Cannot find /virtual-memory/translations size.\n");
+ return;
+ }
+
+ of_trans = grub_malloc (actual);
+ if (!of_trans)
+ {
+ grub_printf ("Cannot allocate translations buffer.\n");
+ return;
+ }
+
+ if (grub_ieee1275_get_property (node, "translations", of_trans, actual, &actual))
+ {
+ grub_printf ("Cannot fetch /virtual-memory/translations property.\n");
+ return;
+ }
+
+ of_num_trans = actual / sizeof(struct grub_ieee1275_translation);
+
+ for (i = 0; i < of_num_trans; i++)
+ {
+ struct grub_ieee1275_translation *p = &of_trans[i];
+
+ if (p->vaddr == 0x2000)
+ {
+ grub_addr_t phys, tte = p->data;
+
+ phys = tte & ~(0xff00000000001fffULL);
+
+ grub_phys_start = phys;
+ grub_phys_end = grub_phys_start + p->size;
+ grub_dprintf ("loader", "Grub lives at phys_start[%lx] phys_end[%lx]\n",
+ (unsigned long) grub_phys_start,
+ (unsigned long) grub_phys_end);
+ break;
+ }
+ }
+}
+
+
+static grub_command_t cmd_linux, cmd_initrd;
+
+GRUB_MOD_INIT(linux)
+{
+ determine_phys_base ();
+ fetch_translations ();
+
+ 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/xnu.c b/grub-core/loader/xnu.c
new file mode 100644
index 0000000..1c0cf6a
--- /dev/null
+++ b/grub-core/loader/xnu.c
@@ -0,0 +1,1555 @@
+/* xnu.c - load xnu kernel. Thanks to Florian Idelberger for all the
+ time he spent testing this
+ */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/file.h>
+#include <grub/xnu.h>
+#include <grub/cpu/xnu.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/loader.h>
+#include <grub/machoload.h>
+#include <grub/macho.h>
+#include <grub/cpu/macho.h>
+#include <grub/command.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/env.h>
+#include <grub/i18n.h>
+#include <grub/verify.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#if defined (__i386) && !defined (GRUB_MACHINE_EFI)
+#include <grub/autoefi.h>
+#endif
+
+struct grub_xnu_devtree_key *grub_xnu_devtree_root = 0;
+static int driverspackagenum = 0;
+static int driversnum = 0;
+int grub_xnu_is_64bit = 0;
+int grub_xnu_darwin_version = 0;
+
+grub_addr_t grub_xnu_heap_target_start = 0;
+grub_size_t grub_xnu_heap_size = 0;
+struct grub_relocator *grub_xnu_relocator;
+
+static grub_err_t
+grub_xnu_register_memory (const char *prefix, int *suffix,
+ grub_addr_t addr, grub_size_t size);
+grub_err_t
+grub_xnu_heap_malloc (int size, void **src, grub_addr_t *target)
+{
+ grub_err_t err;
+ grub_relocator_chunk_t ch;
+ grub_addr_t tgt;
+
+ if (grub_add (grub_xnu_heap_target_start, grub_xnu_heap_size, &tgt))
+ return GRUB_ERR_OUT_OF_RANGE;
+
+ err = grub_relocator_alloc_chunk_addr (grub_xnu_relocator, &ch, tgt, size);
+ if (err)
+ return err;
+
+ *src = get_virtual_current_address (ch);
+ *target = tgt;
+ grub_xnu_heap_size += size;
+ grub_dprintf ("xnu", "val=%p\n", *src);
+ return GRUB_ERR_NONE;
+}
+
+/* Make sure next block of the heap will be aligned.
+ Please notice: aligned are pointers AFTER relocation
+ and not the current ones. */
+grub_err_t
+grub_xnu_align_heap (int align)
+{
+ grub_xnu_heap_size
+ = ALIGN_UP (grub_xnu_heap_target_start+ grub_xnu_heap_size, align)
+ - grub_xnu_heap_target_start;
+ return GRUB_ERR_NONE;
+}
+
+/* Free subtree pointed by CUR. */
+void
+grub_xnu_free_devtree (struct grub_xnu_devtree_key *cur)
+{
+ struct grub_xnu_devtree_key *d;
+ while (cur)
+ {
+ grub_free (cur->name);
+ if (cur->datasize == -1)
+ grub_xnu_free_devtree (cur->first_child);
+ else if (cur->data)
+ grub_free (cur->data);
+ d = cur->next;
+ grub_free (cur);
+ cur = d;
+ }
+}
+
+/* Compute the size of device tree in xnu format. */
+static grub_size_t
+grub_xnu_writetree_get_size (struct grub_xnu_devtree_key *start,
+ const char *name)
+{
+ grub_size_t ret;
+ struct grub_xnu_devtree_key *cur;
+
+ /* Key header. */
+ ret = 2 * sizeof (grub_uint32_t);
+
+ /* "name" value. */
+ ret += 32 + sizeof (grub_uint32_t)
+ + grub_strlen (name) + 4
+ - (grub_strlen (name) % 4);
+
+ for (cur = start; cur; cur = cur->next)
+ if (cur->datasize != -1)
+ {
+ int align_overhead;
+
+ align_overhead = 4 - (cur->datasize % 4);
+ if (align_overhead == 4)
+ align_overhead = 0;
+ ret += 32 + sizeof (grub_uint32_t) + cur->datasize + align_overhead;
+ }
+ else
+ ret += grub_xnu_writetree_get_size (cur->first_child, cur->name);
+ return ret;
+}
+
+/* Write devtree in XNU format at curptr assuming the head is named NAME.*/
+static void *
+grub_xnu_writetree_toheap_real (void *curptr,
+ struct grub_xnu_devtree_key *start,
+ const char *name)
+{
+ struct grub_xnu_devtree_key *cur;
+ int nkeys = 0, nvals = 0;
+ for (cur = start; cur; cur = cur->next)
+ {
+ if (cur->datasize == -1)
+ nkeys++;
+ else
+ nvals++;
+ }
+ /* For the name. */
+ nvals++;
+
+ *((grub_uint32_t *) curptr) = nvals;
+ curptr = ((grub_uint32_t *) curptr) + 1;
+ *((grub_uint32_t *) curptr) = nkeys;
+ curptr = ((grub_uint32_t *) curptr) + 1;
+
+ /* First comes "name" value. */
+ grub_memset (curptr, 0, 32);
+ grub_memcpy (curptr, "name", 4);
+ curptr = ((grub_uint8_t *) curptr) + 32;
+ *((grub_uint32_t *)curptr) = grub_strlen (name) + 1;
+ curptr = ((grub_uint32_t *) curptr) + 1;
+ grub_memcpy (curptr, name, grub_strlen (name));
+ curptr = ((grub_uint8_t *) curptr) + grub_strlen (name);
+ grub_memset (curptr, 0, 4 - (grub_strlen (name) % 4));
+ curptr = ((grub_uint8_t *) curptr) + (4 - (grub_strlen (name) % 4));
+
+ /* Then the other values. */
+ for (cur = start; cur; cur = cur->next)
+ if (cur->datasize != -1)
+ {
+ int align_overhead;
+
+ align_overhead = 4 - (cur->datasize % 4);
+ if (align_overhead == 4)
+ align_overhead = 0;
+ grub_memset (curptr, 0, 32);
+ grub_strncpy (curptr, cur->name, 31);
+ curptr = ((grub_uint8_t *) curptr) + 32;
+ *((grub_uint32_t *) curptr) = cur->datasize;
+ curptr = ((grub_uint32_t *) curptr) + 1;
+ grub_memcpy (curptr, cur->data, cur->datasize);
+ curptr = ((grub_uint8_t *) curptr) + cur->datasize;
+ grub_memset (curptr, 0, align_overhead);
+ curptr = ((grub_uint8_t *) curptr) + align_overhead;
+ }
+
+ /* And then the keys. Recursively use this function. */
+ for (cur = start; cur; cur = cur->next)
+ if (cur->datasize == -1)
+ {
+ curptr = grub_xnu_writetree_toheap_real (curptr,
+ cur->first_child,
+ cur->name);
+ if (!curptr)
+ return 0;
+ }
+ return curptr;
+}
+
+grub_err_t
+grub_xnu_writetree_toheap (grub_addr_t *target, grub_size_t *size)
+{
+ struct grub_xnu_devtree_key *chosen;
+ struct grub_xnu_devtree_key *memorymap;
+ struct grub_xnu_devtree_key *driverkey;
+ struct grub_xnu_extdesc *extdesc;
+ grub_err_t err;
+ void *src;
+
+ err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
+ if (err)
+ return err;
+
+ /* Device tree itself is in the memory map of device tree. */
+ /* Create a dummy value in memory-map. */
+ chosen = grub_xnu_create_key (&grub_xnu_devtree_root, "chosen");
+ if (! chosen)
+ return grub_errno;
+ memorymap = grub_xnu_create_key (&(chosen->first_child), "memory-map");
+ if (! memorymap)
+ return grub_errno;
+
+ driverkey = (struct grub_xnu_devtree_key *) grub_zalloc (sizeof (*driverkey));
+ if (! driverkey)
+ return grub_errno;
+ driverkey->name = grub_strdup ("DeviceTree");
+ if (! driverkey->name)
+ {
+ err = grub_errno;
+ goto fail;
+ }
+
+ driverkey->datasize = sizeof (*extdesc);
+ driverkey->next = memorymap->first_child;
+ memorymap->first_child = driverkey;
+ driverkey->data = extdesc
+ = (struct grub_xnu_extdesc *) grub_malloc (sizeof (*extdesc));
+ if (! driverkey->data)
+ {
+ err = grub_errno;
+ goto fail;
+ }
+
+ /* Allocate the space based on the size with dummy value. */
+ *size = grub_xnu_writetree_get_size (grub_xnu_devtree_root, "/");
+ err = grub_xnu_heap_malloc (ALIGN_UP (*size + 1, GRUB_XNU_PAGESIZE),
+ &src, target);
+ if (err)
+ goto fail;
+
+ /* Put real data in the dummy. */
+ extdesc->addr = *target;
+ extdesc->size = (grub_uint32_t) *size;
+
+ /* Write the tree to heap. */
+ grub_xnu_writetree_toheap_real (src, grub_xnu_devtree_root, "/");
+ return GRUB_ERR_NONE;
+
+ fail:
+ memorymap->first_child = NULL;
+
+ grub_free (driverkey->data);
+ grub_free (driverkey->name);
+ grub_free (driverkey);
+
+ return err;
+}
+
+/* Find a key or value in parent key. */
+struct grub_xnu_devtree_key *
+grub_xnu_find_key (struct grub_xnu_devtree_key *parent, const char *name)
+{
+ struct grub_xnu_devtree_key *cur;
+ for (cur = parent; cur; cur = cur->next)
+ if (grub_strcmp (cur->name, name) == 0)
+ return cur;
+ return 0;
+}
+
+struct grub_xnu_devtree_key *
+grub_xnu_create_key (struct grub_xnu_devtree_key **parent, const char *name)
+{
+ struct grub_xnu_devtree_key *ret;
+ ret = grub_xnu_find_key (*parent, name);
+ if (ret)
+ return ret;
+ ret = (struct grub_xnu_devtree_key *) grub_zalloc (sizeof (*ret));
+ if (! ret)
+ return 0;
+ ret->name = grub_strdup (name);
+ if (! ret->name)
+ {
+ grub_free (ret);
+ return 0;
+ }
+ ret->datasize = -1;
+ ret->next = *parent;
+ *parent = ret;
+ return ret;
+}
+
+struct grub_xnu_devtree_key *
+grub_xnu_create_value (struct grub_xnu_devtree_key **parent, const char *name)
+{
+ struct grub_xnu_devtree_key *ret;
+ ret = grub_xnu_find_key (*parent, name);
+ if (ret)
+ {
+ if (ret->datasize == -1)
+ grub_xnu_free_devtree (ret->first_child);
+ else if (ret->datasize)
+ grub_free (ret->data);
+ ret->datasize = 0;
+ ret->data = 0;
+ return ret;
+ }
+ ret = (struct grub_xnu_devtree_key *) grub_zalloc (sizeof (*ret));
+ if (! ret)
+ return 0;
+ ret->name = grub_strdup (name);
+ if (! ret->name)
+ {
+ grub_free (ret);
+ return 0;
+ }
+ ret->next = *parent;
+ *parent = ret;
+ return ret;
+}
+
+static grub_err_t
+grub_xnu_unload (void)
+{
+ grub_cpu_xnu_unload ();
+
+ grub_xnu_free_devtree (grub_xnu_devtree_root);
+ grub_xnu_devtree_root = 0;
+
+ /* Free loaded image. */
+ driversnum = 0;
+ driverspackagenum = 0;
+ grub_relocator_unload (grub_xnu_relocator);
+ grub_xnu_relocator = NULL;
+ grub_xnu_heap_target_start = 0;
+ grub_xnu_heap_size = 0;
+ grub_xnu_unlock ();
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *args[])
+{
+ grub_err_t err;
+ grub_macho_t macho;
+ grub_uint32_t startcode, endcode;
+ int i;
+ char *ptr;
+ void *loadaddr;
+ grub_addr_t loadaddr_target;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ grub_xnu_unload ();
+
+ macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL, 0);
+ if (! macho)
+ return grub_errno;
+
+ err = grub_macho_size32 (macho, &startcode, &endcode, GRUB_MACHO_NOBSS,
+ args[0]);
+ if (err)
+ {
+ grub_macho_close (macho);
+ grub_xnu_unload ();
+ return err;
+ }
+
+ grub_dprintf ("xnu", "endcode = %lx, startcode = %lx\n",
+ (unsigned long) endcode, (unsigned long) startcode);
+
+ grub_xnu_relocator = grub_relocator_new ();
+ if (!grub_xnu_relocator)
+ return grub_errno;
+ grub_xnu_heap_target_start = startcode;
+ err = grub_xnu_heap_malloc (endcode - startcode, &loadaddr,
+ &loadaddr_target);
+
+ if (err)
+ {
+ grub_macho_close (macho);
+ grub_xnu_unload ();
+ return err;
+ }
+
+ /* Load kernel. */
+ err = grub_macho_load32 (macho, args[0], (char *) loadaddr - startcode,
+ GRUB_MACHO_NOBSS, &grub_xnu_darwin_version);
+ if (err)
+ {
+ grub_macho_close (macho);
+ grub_xnu_unload ();
+ return err;
+ }
+
+ grub_xnu_entry_point = grub_macho_get_entry_point32 (macho, args[0]);
+ if (! grub_xnu_entry_point)
+ {
+ grub_macho_close (macho);
+ grub_xnu_unload ();
+ return grub_error (GRUB_ERR_BAD_OS, "couldn't find entry point");
+ }
+
+ grub_macho_close (macho);
+
+ err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
+ if (err)
+ {
+ grub_xnu_unload ();
+ return err;
+ }
+
+ /* Copy parameters to kernel command line. */
+ ptr = grub_xnu_cmdline;
+ for (i = 1; i < argc; i++)
+ {
+ if (ptr + grub_strlen (args[i]) + 1
+ >= grub_xnu_cmdline + sizeof (grub_xnu_cmdline))
+ break;
+ grub_memcpy (ptr, args[i], grub_strlen (args[i]));
+ ptr += grub_strlen (args[i]);
+ *ptr = ' ';
+ ptr++;
+ }
+
+ /* Replace last space by '\0'. */
+ if (ptr != grub_xnu_cmdline)
+ *(ptr - 1) = 0;
+
+ err = grub_verify_string (grub_xnu_cmdline, GRUB_VERIFY_KERNEL_CMDLINE);
+ if (err)
+ return err;
+
+#if defined (__i386) && !defined (GRUB_MACHINE_EFI)
+ err = grub_efiemu_autocore ();
+ if (err)
+ return err;
+#endif
+
+ grub_loader_set (grub_xnu_boot, grub_xnu_unload, 0);
+
+ grub_xnu_lock ();
+ grub_xnu_is_64bit = 0;
+
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *args[])
+{
+ grub_err_t err;
+ grub_macho_t macho;
+ grub_uint64_t startcode, endcode;
+ int i;
+ char *ptr;
+ void *loadaddr;
+ grub_addr_t loadaddr_target;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ grub_xnu_unload ();
+
+ macho = grub_macho_open (args[0], GRUB_FILE_TYPE_XNU_KERNEL, 1);
+ if (! macho)
+ return grub_errno;
+
+ err = grub_macho_size64 (macho, &startcode, &endcode, GRUB_MACHO_NOBSS,
+ args[0]);
+ if (err)
+ {
+ grub_macho_close (macho);
+ grub_xnu_unload ();
+ return err;
+ }
+
+ startcode &= 0x0fffffff;
+ endcode &= 0x0fffffff;
+
+ grub_dprintf ("xnu", "endcode = %lx, startcode = %lx\n",
+ (unsigned long) endcode, (unsigned long) startcode);
+
+ grub_xnu_relocator = grub_relocator_new ();
+ if (!grub_xnu_relocator)
+ return grub_errno;
+ grub_xnu_heap_target_start = startcode;
+ err = grub_xnu_heap_malloc (endcode - startcode, &loadaddr,
+ &loadaddr_target);
+
+ if (err)
+ {
+ grub_macho_close (macho);
+ grub_xnu_unload ();
+ return err;
+ }
+
+ /* Load kernel. */
+ err = grub_macho_load64 (macho, args[0], (char *) loadaddr - startcode,
+ GRUB_MACHO_NOBSS, &grub_xnu_darwin_version);
+ if (err)
+ {
+ grub_macho_close (macho);
+ grub_xnu_unload ();
+ return err;
+ }
+
+ grub_xnu_entry_point = grub_macho_get_entry_point64 (macho, args[0])
+ & 0x0fffffff;
+ if (! grub_xnu_entry_point)
+ {
+ grub_macho_close (macho);
+ grub_xnu_unload ();
+ return grub_error (GRUB_ERR_BAD_OS, "couldn't find entry point");
+ }
+
+ grub_macho_close (macho);
+
+ err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
+ if (err)
+ {
+ grub_xnu_unload ();
+ return err;
+ }
+
+ /* Copy parameters to kernel command line. */
+ ptr = grub_xnu_cmdline;
+ for (i = 1; i < argc; i++)
+ {
+ if (ptr + grub_strlen (args[i]) + 1
+ >= grub_xnu_cmdline + sizeof (grub_xnu_cmdline))
+ break;
+ grub_memcpy (ptr, args[i], grub_strlen (args[i]));
+ ptr += grub_strlen (args[i]);
+ *ptr = ' ';
+ ptr++;
+ }
+
+ /* Replace last space by '\0'. */
+ if (ptr != grub_xnu_cmdline)
+ *(ptr - 1) = 0;
+
+ err = grub_verify_string (grub_xnu_cmdline, GRUB_VERIFY_KERNEL_CMDLINE);
+ if (err)
+ return err;
+
+#if defined (__i386) && !defined (GRUB_MACHINE_EFI)
+ err = grub_efiemu_autocore ();
+ if (err)
+ return err;
+#endif
+
+ grub_loader_set (grub_xnu_boot, grub_xnu_unload, 0);
+
+ grub_xnu_lock ();
+ grub_xnu_is_64bit = 1;
+
+ return 0;
+}
+
+/* Register a memory in a memory map under name PREFIXSUFFIX
+ and increment SUFFIX. */
+static grub_err_t
+grub_xnu_register_memory (const char *prefix, int *suffix,
+ grub_addr_t addr, grub_size_t size)
+{
+ struct grub_xnu_devtree_key *chosen;
+ struct grub_xnu_devtree_key *memorymap;
+ struct grub_xnu_devtree_key *driverkey;
+ struct grub_xnu_extdesc *extdesc;
+
+ if (! grub_xnu_heap_size)
+ return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
+
+ chosen = grub_xnu_create_key (&grub_xnu_devtree_root, "chosen");
+ if (! chosen)
+ return grub_errno;
+ memorymap = grub_xnu_create_key (&(chosen->first_child), "memory-map");
+ if (! memorymap)
+ return grub_errno;
+
+ driverkey = (struct grub_xnu_devtree_key *) grub_malloc (sizeof (*driverkey));
+ if (! driverkey)
+ return grub_errno;
+ if (suffix)
+ driverkey->name = grub_xasprintf ("%s%d", prefix, (*suffix)++);
+ else
+ driverkey->name = grub_strdup (prefix);
+ if (!driverkey->name)
+ {
+ grub_free (driverkey);
+ return grub_errno;
+ }
+ driverkey->datasize = sizeof (*extdesc);
+ driverkey->next = memorymap->first_child;
+ driverkey->data = extdesc
+ = (struct grub_xnu_extdesc *) grub_malloc (sizeof (*extdesc));
+ if (! driverkey->data)
+ {
+ grub_free (driverkey->name);
+ grub_free (driverkey);
+ return grub_errno;
+ }
+ memorymap->first_child = driverkey;
+ extdesc->addr = addr;
+ extdesc->size = (grub_uint32_t) size;
+ return GRUB_ERR_NONE;
+}
+
+static inline char *
+get_name_ptr (char *name)
+{
+ char *p = name, *p2;
+ /* Skip Info.plist. */
+ p2 = grub_strrchr (p, '/');
+ if (!p2)
+ return name;
+ if (p2 == name)
+ return name + 1;
+ p = p2 - 1;
+
+ p2 = grub_strrchr (p, '/');
+ if (!p2)
+ return name;
+ if (p2 == name)
+ return name + 1;
+ if (grub_memcmp (p2, "/Contents/", sizeof ("/Contents/") - 1) != 0)
+ return p2 + 1;
+
+ p = p2 - 1;
+
+ p2 = grub_strrchr (p, '/');
+ if (!p2)
+ return name;
+ return p2 + 1;
+}
+
+/* Load .kext. */
+static grub_err_t
+grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
+ const char *filename)
+{
+ grub_macho_t macho;
+ grub_err_t err;
+ grub_file_t infoplist;
+ struct grub_xnu_extheader *exthead;
+ int neededspace = sizeof (*exthead);
+ grub_uint8_t *buf;
+ void *buf0;
+ grub_addr_t buf_target;
+ grub_size_t infoplistsize = 0, machosize = 0;
+ char *name, *nameend;
+ int namelen;
+
+ if (infoplistname == NULL)
+ return grub_error (GRUB_ERR_BAD_FILENAME, N_("missing p-list filename"));
+
+ name = get_name_ptr (infoplistname);
+ nameend = grub_strchr (name, '/');
+
+ if (nameend)
+ namelen = nameend - name;
+ else
+ namelen = grub_strlen (name);
+
+ neededspace += namelen + 1;
+
+ if (! grub_xnu_heap_size)
+ return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
+
+ /* Compute the needed space. */
+ if (binaryfile)
+ {
+ macho = grub_macho_file (binaryfile, filename, grub_xnu_is_64bit);
+ if (!macho)
+ grub_file_close (binaryfile);
+ else
+ {
+ if (grub_xnu_is_64bit)
+ machosize = grub_macho_filesize64 (macho);
+ else
+ machosize = grub_macho_filesize32 (macho);
+ }
+ neededspace += machosize;
+ }
+ else
+ macho = 0;
+
+ infoplist = grub_file_open (infoplistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
+ grub_errno = GRUB_ERR_NONE;
+ if (infoplist)
+ {
+ infoplistsize = grub_file_size (infoplist);
+ neededspace += infoplistsize + 1;
+ }
+ else
+ infoplistsize = 0;
+
+ /* Allocate the space. */
+ err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
+ if (err)
+ goto fail;
+ err = grub_xnu_heap_malloc (neededspace, &buf0, &buf_target);
+ if (err)
+ goto fail;
+ buf = buf0;
+
+ exthead = (struct grub_xnu_extheader *) buf;
+ grub_memset (exthead, 0, sizeof (*exthead));
+ buf += sizeof (*exthead);
+
+ /* Load the binary. */
+ if (macho)
+ {
+ exthead->binaryaddr = buf_target + (buf - (grub_uint8_t *) buf0);
+ exthead->binarysize = machosize;
+ if (grub_xnu_is_64bit)
+ err = grub_macho_readfile64 (macho, filename, buf);
+ else
+ err = grub_macho_readfile32 (macho, filename, buf);
+ if (err)
+ goto fail;
+ grub_macho_close (macho);
+ buf += machosize;
+ }
+ grub_errno = GRUB_ERR_NONE;
+
+ /* Load the plist. */
+ if (infoplist)
+ {
+ exthead->infoplistaddr = buf_target + (buf - (grub_uint8_t *) buf0);
+ exthead->infoplistsize = infoplistsize + 1;
+ if (grub_file_read (infoplist, buf, infoplistsize)
+ != (grub_ssize_t) (infoplistsize))
+ {
+ grub_file_close (infoplist);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ infoplistname);
+ return grub_errno;
+ }
+ grub_file_close (infoplist);
+ buf[infoplistsize] = 0;
+ buf += infoplistsize + 1;
+ }
+ grub_errno = GRUB_ERR_NONE;
+
+ exthead->nameaddr = (buf - (grub_uint8_t *) buf0) + buf_target;
+ exthead->namesize = namelen + 1;
+ grub_memcpy (buf, name, namelen);
+ buf[namelen] = 0;
+ buf += namelen + 1;
+
+ /* Announce to kernel */
+ return grub_xnu_register_memory ("Driver-", &driversnum, buf_target,
+ neededspace);
+fail:
+ if (macho)
+ grub_macho_close (macho);
+ return err;
+}
+
+/* Load mkext. */
+static grub_err_t
+grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *args[])
+{
+ grub_file_t file;
+ void *loadto;
+ grub_addr_t loadto_target;
+ grub_err_t err;
+ grub_off_t readoff = 0;
+ grub_ssize_t readlen = -1;
+ struct grub_macho_fat_header head;
+ struct grub_macho_fat_arch *archs;
+ int narchs, i;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if (! grub_xnu_heap_size)
+ return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
+
+ file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_MKEXT);
+ if (! file)
+ return grub_errno;
+
+ /* Sometimes caches are fat binary. Errgh. */
+ if (grub_file_read (file, &head, sizeof (head))
+ != (grub_ssize_t) (sizeof (head)))
+ {
+ /* I don't know the internal structure of package but
+ can hardly imagine a valid package shorter than 20 bytes. */
+ grub_file_close (file);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), args[0]);
+ return grub_errno;
+ }
+
+ /* Find the corresponding architecture. */
+ if (grub_be_to_cpu32 (head.magic) == GRUB_MACHO_FAT_MAGIC)
+ {
+ narchs = grub_be_to_cpu32 (head.nfat_arch);
+ archs = grub_calloc (narchs, sizeof (struct grub_macho_fat_arch));
+ if (! archs)
+ {
+ grub_file_close (file);
+ return grub_errno;
+
+ }
+ if (grub_file_read (file, archs,
+ sizeof (struct grub_macho_fat_arch) * narchs)
+ != (grub_ssize_t) sizeof(struct grub_macho_fat_arch) * narchs)
+ {
+ grub_free (archs);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_READ_ERROR, N_("premature end of file %s"),
+ args[0]);
+ return grub_errno;
+ }
+ for (i = 0; i < narchs; i++)
+ {
+ if (!grub_xnu_is_64bit && GRUB_MACHO_CPUTYPE_IS_HOST32
+ (grub_be_to_cpu32 (archs[i].cputype)))
+ {
+ readoff = grub_be_to_cpu32 (archs[i].offset);
+ readlen = grub_be_to_cpu32 (archs[i].size);
+ }
+ if (grub_xnu_is_64bit && GRUB_MACHO_CPUTYPE_IS_HOST64
+ (grub_be_to_cpu32 (archs[i].cputype)))
+ {
+ readoff = grub_be_to_cpu32 (archs[i].offset);
+ readlen = grub_be_to_cpu32 (archs[i].size);
+ }
+ }
+ grub_free (archs);
+ }
+ else
+ {
+ /* It's a flat file. Some sane people still exist. */
+ readoff = 0;
+ readlen = grub_file_size (file);
+ }
+
+ if (readlen == -1)
+ {
+ grub_file_close (file);
+ return grub_error (GRUB_ERR_BAD_OS, "no suitable architecture is found");
+ }
+
+ /* Allocate space. */
+ err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
+ if (err)
+ {
+ grub_file_close (file);
+ return err;
+ }
+
+ err = grub_xnu_heap_malloc (readlen, &loadto, &loadto_target);
+ if (err)
+ {
+ grub_file_close (file);
+ return err;
+ }
+
+ /* Read the file. */
+ grub_file_seek (file, readoff);
+ if (grub_file_read (file, loadto, readlen) != (grub_ssize_t) (readlen))
+ {
+ grub_file_close (file);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), args[0]);
+ return grub_errno;
+ }
+ grub_file_close (file);
+
+ /* Pass it to kernel. */
+ return grub_xnu_register_memory ("DriversPackage-", &driverspackagenum,
+ loadto_target, readlen);
+}
+
+static grub_err_t
+grub_cmd_xnu_ramdisk (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *args[])
+{
+ grub_file_t file;
+ void *loadto;
+ grub_addr_t loadto_target;
+ grub_err_t err;
+ grub_size_t size;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if (! grub_xnu_heap_size)
+ return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
+
+ file = grub_file_open (args[0], GRUB_FILE_TYPE_XNU_RAMDISK);
+ if (! file)
+ return grub_errno;
+
+ err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
+ if (err)
+ return err;
+
+ size = grub_file_size (file);
+
+ err = grub_xnu_heap_malloc (size, &loadto, &loadto_target);
+ if (err)
+ return err;
+ if (grub_file_read (file, loadto, size) != (grub_ssize_t) (size))
+ {
+ grub_file_close (file);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), args[0]);
+ return grub_errno;
+ }
+ return grub_xnu_register_memory ("RAMDisk", 0, loadto_target, size);
+}
+
+/* Returns true if the kext should be loaded according to plist
+ and osbundlereq. Also fill BINNAME. */
+static int
+grub_xnu_check_os_bundle_required (char *plistname,
+ const char *osbundlereq,
+ char **binname)
+{
+ grub_file_t file;
+ char *buf = 0, *tagstart = 0, *ptr1 = 0, *keyptr = 0;
+ char *stringptr = 0, *ptr2 = 0;
+ grub_size_t size;
+ int depth = 0;
+ int ret;
+ int osbundlekeyfound = 0, binnamekeyfound = 0;
+ if (binname)
+ *binname = 0;
+
+ file = grub_file_open (plistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
+ if (! file)
+ return 0;
+
+ size = grub_file_size (file);
+ buf = grub_malloc (size);
+ if (! buf)
+ {
+ grub_file_close (file);
+ return 0;
+ }
+ if (grub_file_read (file, buf, size) != (grub_ssize_t) (size))
+ {
+ grub_file_close (file);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), plistname);
+ return 0;
+ }
+ grub_file_close (file);
+
+ /* Set the return value for the case when no OSBundleRequired tag is found. */
+ if (osbundlereq)
+ ret = grub_strword (osbundlereq, "all") || grub_strword (osbundlereq, "-");
+ else
+ ret = 1;
+
+ /* Parse plist. It's quite dirty and inextensible but does its job. */
+ for (ptr1 = buf; ptr1 < buf + size; ptr1++)
+ switch (*ptr1)
+ {
+ case '<':
+ tagstart = ptr1;
+ *ptr1 = 0;
+ if (keyptr && depth == 4
+ && grub_strcmp (keyptr, "OSBundleRequired") == 0)
+ osbundlekeyfound = 1;
+ if (keyptr && depth == 4 &&
+ grub_strcmp (keyptr, "CFBundleExecutable") == 0)
+ binnamekeyfound = 1;
+ if (stringptr && osbundlekeyfound && osbundlereq && depth == 4)
+ {
+ for (ptr2 = stringptr; *ptr2; ptr2++)
+ *ptr2 = grub_tolower (*ptr2);
+ ret = grub_strword (osbundlereq, stringptr)
+ || grub_strword (osbundlereq, "all");
+ }
+ if (stringptr && binnamekeyfound && binname && depth == 4)
+ {
+ if (*binname)
+ grub_free (*binname);
+ *binname = grub_strdup (stringptr);
+ }
+
+ *ptr1 = '<';
+ keyptr = 0;
+ stringptr = 0;
+ break;
+ case '>':
+ if (! tagstart)
+ {
+ grub_free (buf);
+ grub_error (GRUB_ERR_BAD_OS, "can't parse %s", plistname);
+ return 0;
+ }
+ *ptr1 = 0;
+ if (tagstart[1] == '?' || ptr1[-1] == '/')
+ {
+ osbundlekeyfound = 0;
+ *ptr1 = '>';
+ break;
+ }
+ if (depth == 3 && grub_strcmp (tagstart + 1, "key") == 0)
+ keyptr = ptr1 + 1;
+ if (depth == 3 && grub_strcmp (tagstart + 1, "string") == 0)
+ stringptr = ptr1 + 1;
+ else if (grub_strcmp (tagstart + 1, "/key") != 0)
+ {
+ osbundlekeyfound = 0;
+ binnamekeyfound = 0;
+ }
+ *ptr1 = '>';
+
+ if (tagstart[1] == '/')
+ depth--;
+ else
+ depth++;
+ break;
+ }
+ grub_free (buf);
+
+ return ret;
+}
+
+/* Context for grub_xnu_scan_dir_for_kexts. */
+struct grub_xnu_scan_dir_for_kexts_ctx
+{
+ char *dirname;
+ const char *osbundlerequired;
+ int maxrecursion;
+};
+
+/* Helper for grub_xnu_scan_dir_for_kexts. */
+static int
+grub_xnu_scan_dir_for_kexts_load (const char *filename,
+ const struct grub_dirhook_info *info,
+ void *data)
+{
+ struct grub_xnu_scan_dir_for_kexts_ctx *ctx = data;
+ char *newdirname;
+
+ if (! info->dir)
+ return 0;
+ if (filename[0] == '.')
+ return 0;
+
+ if (grub_strlen (filename) < 5 ||
+ grub_memcmp (filename + grub_strlen (filename) - 5, ".kext", 5) != 0)
+ return 0;
+
+ newdirname
+ = grub_malloc (grub_strlen (ctx->dirname) + grub_strlen (filename) + 2);
+
+ /* It's a .kext. Try to load it. */
+ if (newdirname)
+ {
+ grub_strcpy (newdirname, ctx->dirname);
+ newdirname[grub_strlen (newdirname) + 1] = 0;
+ newdirname[grub_strlen (newdirname)] = '/';
+ grub_strcpy (newdirname + grub_strlen (newdirname), filename);
+ grub_xnu_load_kext_from_dir (newdirname, ctx->osbundlerequired,
+ ctx->maxrecursion);
+ if (grub_errno == GRUB_ERR_BAD_OS)
+ grub_errno = GRUB_ERR_NONE;
+ grub_free (newdirname);
+ }
+ return 0;
+}
+
+/* Load all loadable kexts placed under DIRNAME and matching OSBUNDLEREQUIRED */
+grub_err_t
+grub_xnu_scan_dir_for_kexts (char *dirname, const char *osbundlerequired,
+ int maxrecursion)
+{
+ struct grub_xnu_scan_dir_for_kexts_ctx ctx = {
+ .dirname = dirname,
+ .osbundlerequired = osbundlerequired,
+ .maxrecursion = maxrecursion
+ };
+ grub_device_t dev;
+ char *device_name;
+ grub_fs_t fs;
+ const char *path;
+
+ if (! grub_xnu_heap_size)
+ return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
+
+ device_name = grub_file_get_device_name (dirname);
+ dev = grub_device_open (device_name);
+ if (dev)
+ {
+ fs = grub_fs_probe (dev);
+ path = grub_strchr (dirname, ')');
+ if (! path)
+ path = dirname;
+ else
+ path++;
+
+ if (fs)
+ (fs->fs_dir) (dev, path, grub_xnu_scan_dir_for_kexts_load, &ctx);
+ grub_device_close (dev);
+ }
+ grub_free (device_name);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Context for grub_xnu_load_kext_from_dir. */
+struct grub_xnu_load_kext_from_dir_ctx
+{
+ char *dirname;
+ const char *osbundlerequired;
+ int maxrecursion;
+ char *plistname;
+ char *newdirname;
+ int usemacos;
+};
+
+/* Helper for grub_xnu_load_kext_from_dir. */
+static int
+grub_xnu_load_kext_from_dir_load (const char *filename,
+ const struct grub_dirhook_info *info,
+ void *data)
+{
+ struct grub_xnu_load_kext_from_dir_ctx *ctx = data;
+
+ if (grub_strlen (filename) > 15)
+ return 0;
+ grub_strcpy (ctx->newdirname + grub_strlen (ctx->dirname) + 1, filename);
+
+ /* If the kext contains directory "Contents" all real stuff is in
+ this directory. */
+ if (info->dir && grub_strcasecmp (filename, "Contents") == 0)
+ grub_xnu_load_kext_from_dir (ctx->newdirname, ctx->osbundlerequired,
+ ctx->maxrecursion - 1);
+
+ /* Directory "Plugins" contains nested kexts. */
+ if (info->dir && grub_strcasecmp (filename, "Plugins") == 0)
+ grub_xnu_scan_dir_for_kexts (ctx->newdirname, ctx->osbundlerequired,
+ ctx->maxrecursion - 1);
+
+ /* Directory "MacOS" contains executable, otherwise executable is
+ on the top. */
+ if (info->dir && grub_strcasecmp (filename, "MacOS") == 0)
+ ctx->usemacos = 1;
+
+ /* Info.plist is the file which governs our future actions. */
+ if (! info->dir && grub_strcasecmp (filename, "Info.plist") == 0
+ && ! ctx->plistname)
+ ctx->plistname = grub_strdup (ctx->newdirname);
+ return 0;
+}
+
+/* Load extension DIRNAME. (extensions are directories in xnu) */
+grub_err_t
+grub_xnu_load_kext_from_dir (char *dirname, const char *osbundlerequired,
+ int maxrecursion)
+{
+ struct grub_xnu_load_kext_from_dir_ctx ctx = {
+ .dirname = dirname,
+ .osbundlerequired = osbundlerequired,
+ .maxrecursion = maxrecursion,
+ .plistname = 0,
+ .usemacos = 0
+ };
+ grub_device_t dev;
+ char *newpath;
+ char *device_name;
+ grub_fs_t fs;
+ const char *path;
+ char *binsuffix;
+ grub_file_t binfile;
+
+ ctx.newdirname = grub_malloc (grub_strlen (dirname) + 20);
+ if (! ctx.newdirname)
+ return grub_errno;
+ grub_strcpy (ctx.newdirname, dirname);
+ ctx.newdirname[grub_strlen (dirname)] = '/';
+ ctx.newdirname[grub_strlen (dirname) + 1] = 0;
+ device_name = grub_file_get_device_name (dirname);
+ dev = grub_device_open (device_name);
+ if (dev)
+ {
+ fs = grub_fs_probe (dev);
+ path = grub_strchr (dirname, ')');
+ if (! path)
+ path = dirname;
+ else
+ path++;
+
+ newpath = grub_strchr (ctx.newdirname, ')');
+ if (! newpath)
+ newpath = ctx.newdirname;
+ else
+ newpath++;
+
+ /* Look at the directory. */
+ if (fs)
+ (fs->fs_dir) (dev, path, grub_xnu_load_kext_from_dir_load, &ctx);
+
+ if (ctx.plistname && grub_xnu_check_os_bundle_required
+ (ctx.plistname, osbundlerequired, &binsuffix))
+ {
+ if (binsuffix)
+ {
+ /* Open the binary. */
+ char *binname = grub_malloc (grub_strlen (dirname)
+ + grub_strlen (binsuffix)
+ + sizeof ("/MacOS/"));
+ grub_strcpy (binname, dirname);
+ if (ctx.usemacos)
+ grub_strcpy (binname + grub_strlen (binname), "/MacOS/");
+ else
+ grub_strcpy (binname + grub_strlen (binname), "/");
+ grub_strcpy (binname + grub_strlen (binname), binsuffix);
+ grub_dprintf ("xnu", "%s:%s\n", ctx.plistname, binname);
+ binfile = grub_file_open (binname, GRUB_FILE_TYPE_XNU_KEXT);
+ if (! binfile)
+ grub_errno = GRUB_ERR_NONE;
+
+ /* Load the extension. */
+ grub_xnu_load_driver (ctx.plistname, binfile,
+ binname);
+ grub_free (binname);
+ grub_free (binsuffix);
+ }
+ else
+ {
+ grub_dprintf ("xnu", "%s:0\n", ctx.plistname);
+ grub_xnu_load_driver (ctx.plistname, 0, 0);
+ }
+ }
+ grub_free (ctx.plistname);
+ grub_device_close (dev);
+ }
+ grub_free (device_name);
+
+ return GRUB_ERR_NONE;
+}
+
+
+static int locked=0;
+static grub_dl_t my_mod;
+
+/* Load the kext. */
+static grub_err_t
+grub_cmd_xnu_kext (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *args[])
+{
+ grub_file_t binfile = 0;
+
+ if (! grub_xnu_heap_size)
+ return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
+
+ if (argc == 2)
+ {
+ /* User explicitly specified plist and binary. */
+ if (grub_strcmp (args[1], "-") != 0)
+ {
+ binfile = grub_file_open (args[1], GRUB_FILE_TYPE_XNU_KEXT);
+ if (! binfile)
+ return grub_errno;
+ }
+ return grub_xnu_load_driver (grub_strcmp (args[0], "-") ? args[0] : 0,
+ binfile, args[1]);
+ }
+
+ /* load kext normally. */
+ if (argc == 1)
+ return grub_xnu_load_kext_from_dir (args[0], 0, 10);
+
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+}
+
+/* Load a directory containing kexts. */
+static grub_err_t
+grub_cmd_xnu_kextdir (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *args[])
+{
+ if (argc != 1 && argc != 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "directory name required");
+
+ if (! grub_xnu_heap_size)
+ return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
+
+ if (argc == 1)
+ return grub_xnu_scan_dir_for_kexts (args[0],
+ "console,root,local-root,network-root",
+ 10);
+ else
+ {
+ char *osbundlerequired = grub_strdup (args[1]), *ptr;
+ grub_err_t err;
+ if (! osbundlerequired)
+ return grub_errno;
+ for (ptr = osbundlerequired; *ptr; ptr++)
+ *ptr = grub_tolower (*ptr);
+ err = grub_xnu_scan_dir_for_kexts (args[0], osbundlerequired, 10);
+ grub_free (osbundlerequired);
+ return err;
+ }
+}
+
+static inline int
+hextoval (char c)
+{
+ if (c >= '0' && c <= '9')
+ return c - '0';
+ if (c >= 'a' && c <= 'z')
+ return c - 'a' + 10;
+ if (c >= 'A' && c <= 'Z')
+ return c - 'A' + 10;
+ return 0;
+}
+
+static inline void
+unescape (char *name, char *curdot, char *nextdot, int *len)
+{
+ char *ptr, *dptr;
+ dptr = name;
+ for (ptr = curdot; ptr < nextdot;)
+ if (ptr + 2 < nextdot && *ptr == '%')
+ {
+ *dptr = (hextoval (ptr[1]) << 4) | (hextoval (ptr[2]));
+ ptr += 3;
+ dptr++;
+ }
+ else
+ {
+ *dptr = *ptr;
+ ptr++;
+ dptr++;
+ }
+ *len = dptr - name;
+}
+
+grub_err_t
+grub_xnu_fill_devicetree (void)
+{
+ struct grub_env_var *var;
+ FOR_SORTED_ENV (var)
+ {
+ char *nextdot = 0, *curdot;
+ struct grub_xnu_devtree_key **curkey = &grub_xnu_devtree_root;
+ struct grub_xnu_devtree_key *curvalue;
+ char *name = 0, *data;
+ int len;
+
+ if (grub_memcmp (var->name, "XNU.DeviceTree.",
+ sizeof ("XNU.DeviceTree.") - 1) != 0)
+ continue;
+
+ curdot = var->name + sizeof ("XNU.DeviceTree.") - 1;
+ nextdot = grub_strchr (curdot, '.');
+ if (nextdot)
+ nextdot++;
+ while (nextdot)
+ {
+ name = grub_realloc (name, nextdot - curdot + 1);
+
+ if (!name)
+ return grub_errno;
+
+ unescape (name, curdot, nextdot, &len);
+ name[len - 1] = 0;
+
+ curkey = &(grub_xnu_create_key (curkey, name)->first_child);
+
+ curdot = nextdot;
+ nextdot = grub_strchr (nextdot, '.');
+ if (nextdot)
+ nextdot++;
+ }
+
+ nextdot = curdot + grub_strlen (curdot) + 1;
+
+ name = grub_realloc (name, nextdot - curdot + 1);
+
+ if (!name)
+ return grub_errno;
+
+ unescape (name, curdot, nextdot, &len);
+ name[len] = 0;
+
+ curvalue = grub_xnu_create_value (curkey, name);
+ grub_free (name);
+ if (!curvalue)
+ return grub_errno;
+
+ data = grub_malloc (grub_strlen (var->value) + 1);
+ if (!data)
+ return grub_errno;
+
+ unescape (data, var->value, var->value + grub_strlen (var->value),
+ &len);
+ curvalue->datasize = len;
+ curvalue->data = data;
+ }
+
+ return grub_errno;
+}
+
+struct grub_video_bitmap *grub_xnu_bitmap = 0;
+grub_xnu_bitmap_mode_t grub_xnu_bitmap_mode;
+
+/* Option array indices. */
+#define XNU_SPLASH_CMD_ARGINDEX_MODE 0
+
+static const struct grub_arg_option xnu_splash_cmd_options[] =
+ {
+ {"mode", 'm', 0, N_("Background image mode."), N_("stretch|normal"),
+ ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+grub_cmd_xnu_splash (grub_extcmd_context_t ctxt,
+ int argc, char *args[])
+{
+ grub_err_t err;
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ if (! grub_xnu_heap_size)
+ return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first"));
+
+ if (ctxt->state[XNU_SPLASH_CMD_ARGINDEX_MODE].set &&
+ grub_strcmp (ctxt->state[XNU_SPLASH_CMD_ARGINDEX_MODE].arg,
+ "stretch") == 0)
+ grub_xnu_bitmap_mode = GRUB_XNU_BITMAP_STRETCH;
+ else
+ grub_xnu_bitmap_mode = GRUB_XNU_BITMAP_CENTER;
+
+ err = grub_video_bitmap_load (&grub_xnu_bitmap, args[0]);
+ if (err)
+ grub_xnu_bitmap = 0;
+
+ return err;
+}
+
+
+#ifndef GRUB_MACHINE_EMU
+static grub_err_t
+grub_cmd_xnu_resume (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *args[])
+{
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ return grub_xnu_resume (args[0]);
+}
+#endif
+
+void
+grub_xnu_lock (void)
+{
+ if (!locked)
+ grub_dl_ref (my_mod);
+ locked = 1;
+}
+
+void
+grub_xnu_unlock (void)
+{
+ if (locked)
+ grub_dl_unref (my_mod);
+ locked = 0;
+}
+
+static grub_command_t cmd_kernel64, cmd_kernel, cmd_mkext, cmd_kext;
+static grub_command_t cmd_kextdir, cmd_ramdisk, cmd_resume;
+static grub_extcmd_t cmd_splash;
+
+GRUB_MOD_INIT(xnu)
+{
+ cmd_kernel = grub_register_command ("xnu_kernel", grub_cmd_xnu_kernel, 0,
+ N_("Load XNU image."));
+ cmd_kernel64 = grub_register_command ("xnu_kernel64", grub_cmd_xnu_kernel64,
+ 0, N_("Load 64-bit XNU image."));
+ cmd_mkext = grub_register_command_lockdown ("xnu_mkext", grub_cmd_xnu_mkext, 0,
+ N_("Load XNU extension package."));
+ cmd_kext = grub_register_command_lockdown ("xnu_kext", grub_cmd_xnu_kext, 0,
+ N_("Load XNU extension."));
+ cmd_kextdir = grub_register_command_lockdown ("xnu_kextdir", grub_cmd_xnu_kextdir,
+ /*
+ * TRANSLATORS: OSBundleRequired is
+ * a variable name in xnu extensions
+ * manifests. It behaves mostly like
+ * GNU/Linux runlevels.
+ */
+ N_("DIRECTORY [OSBundleRequired]"),
+ /*
+ * TRANSLATORS: There are many extensions
+ * in extension directory.
+ */
+ N_("Load XNU extension directory."));
+ cmd_ramdisk = grub_register_command ("xnu_ramdisk", grub_cmd_xnu_ramdisk, 0,
+ /* TRANSLATORS: ramdisk here isn't identifier. It can be translated. */
+ N_("Load XNU ramdisk. "
+ "It will be available in OS as md0."));
+ cmd_splash = grub_register_extcmd ("xnu_splash",
+ grub_cmd_xnu_splash, 0, 0,
+ N_("Load a splash image for XNU."),
+ xnu_splash_cmd_options);
+
+#ifndef GRUB_MACHINE_EMU
+ cmd_resume = grub_register_command ("xnu_resume", grub_cmd_xnu_resume,
+ 0, N_("Load an image of hibernated"
+ " XNU."));
+#endif
+
+ grub_cpu_xnu_init ();
+
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(xnu)
+{
+#ifndef GRUB_MACHINE_EMU
+ grub_unregister_command (cmd_resume);
+#endif
+ grub_unregister_command (cmd_mkext);
+ grub_unregister_command (cmd_kext);
+ grub_unregister_command (cmd_kextdir);
+ grub_unregister_command (cmd_ramdisk);
+ grub_unregister_command (cmd_kernel);
+ grub_unregister_extcmd (cmd_splash);
+ grub_unregister_command (cmd_kernel64);
+
+ grub_cpu_xnu_fini ();
+}
diff --git a/grub-core/loader/xnu_resume.c b/grub-core/loader/xnu_resume.c
new file mode 100644
index 0000000..d648ef0
--- /dev/null
+++ b/grub-core/loader/xnu_resume.c
@@ -0,0 +1,188 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/xnu.h>
+#include <grub/cpu/xnu.h>
+#include <grub/mm.h>
+#include <grub/loader.h>
+#include <grub/i18n.h>
+
+static void *grub_xnu_hibernate_image;
+
+static grub_err_t
+grub_xnu_resume_unload (void)
+{
+ /* Free loaded image */
+ if (grub_xnu_hibernate_image)
+ grub_free (grub_xnu_hibernate_image);
+ grub_xnu_hibernate_image = 0;
+ grub_xnu_unlock ();
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_xnu_resume (char *imagename)
+{
+ grub_file_t file;
+ grub_size_t total_header_size;
+ struct grub_xnu_hibernate_header hibhead;
+ void *code;
+ void *image;
+ grub_uint32_t codedest;
+ grub_uint32_t codesize;
+ grub_addr_t target_image;
+ grub_err_t err;
+
+ file = grub_file_open (imagename, GRUB_FILE_TYPE_XNU_HIBERNATE_IMAGE
+ | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (! file)
+ return 0;
+
+ /* Read the header. */
+ if (grub_file_read (file, &hibhead, sizeof (hibhead))
+ != sizeof (hibhead))
+ {
+ grub_file_close (file);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_READ_ERROR,
+ N_("premature end of file %s"), imagename);
+ return grub_errno;
+ }
+
+ /* Check the header. */
+ if (hibhead.magic != GRUB_XNU_HIBERNATE_MAGIC)
+ {
+ grub_file_close (file);
+ return grub_error (GRUB_ERR_BAD_OS,
+ "hibernate header has incorrect magic number");
+ }
+ if (hibhead.encoffset)
+ {
+ grub_file_close (file);
+ return grub_error (GRUB_ERR_BAD_OS,
+ "encrypted images aren't supported yet");
+ }
+
+ if (hibhead.image_size == 0)
+ {
+ grub_file_close (file);
+ return grub_error (GRUB_ERR_BAD_OS,
+ "hibernate image is empty");
+ }
+
+ codedest = hibhead.launchcode_target_page;
+ codedest *= GRUB_XNU_PAGESIZE;
+ codesize = hibhead.launchcode_numpages;
+ codesize *= GRUB_XNU_PAGESIZE;
+
+ /* FIXME: check that codedest..codedest+codesize is available. */
+
+ /* Calculate total size before pages to copy. */
+ total_header_size = hibhead.extmapsize + sizeof (hibhead);
+
+ /* Unload image if any. */
+ if (grub_xnu_hibernate_image)
+ grub_free (grub_xnu_hibernate_image);
+
+ /* Try to allocate necessary space.
+ FIXME: mm isn't good enough yet to handle huge allocations.
+ */
+ grub_xnu_relocator = grub_relocator_new ();
+ if (!grub_xnu_relocator)
+ {
+ grub_file_close (file);
+ return grub_errno;
+ }
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_addr (grub_xnu_relocator, &ch, codedest,
+ codesize + GRUB_XNU_PAGESIZE);
+ if (err)
+ {
+ grub_file_close (file);
+ return err;
+ }
+ code = get_virtual_current_address (ch);
+ }
+
+ {
+ grub_relocator_chunk_t ch;
+ err = grub_relocator_alloc_chunk_align (grub_xnu_relocator, &ch, 0,
+ UP_TO_TOP32 (hibhead.image_size),
+ hibhead.image_size,
+ GRUB_XNU_PAGESIZE,
+ GRUB_RELOCATOR_PREFERENCE_NONE, 0);
+ if (err)
+ {
+ grub_file_close (file);
+ return err;
+ }
+ image = get_virtual_current_address (ch);
+ target_image = get_physical_target_address (ch);
+ }
+
+ /* Read code part. */
+ if (grub_file_seek (file, total_header_size) == (grub_off_t) -1
+ || grub_file_read (file, code, codesize)
+ != (grub_ssize_t) codesize)
+ {
+ grub_file_close (file);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_READ_ERROR,
+ N_("premature end of file %s"), imagename);
+ return grub_errno;
+ }
+
+ /* Read image. */
+ if (grub_file_seek (file, 0) == (grub_off_t) -1
+ || grub_file_read (file, image, hibhead.image_size)
+ != (grub_ssize_t) hibhead.image_size)
+ {
+ grub_file_close (file);
+ if (!grub_errno)
+ grub_error (GRUB_ERR_READ_ERROR,
+ N_("premature end of file %s"), imagename);
+ return grub_errno;
+ }
+ grub_file_close (file);
+
+ /* Setup variables needed by asm helper. */
+ grub_xnu_heap_target_start = codedest;
+ grub_xnu_heap_size = target_image + hibhead.image_size - codedest;
+ grub_xnu_stack = (codedest + hibhead.stack);
+ grub_xnu_entry_point = (codedest + hibhead.entry_point);
+ grub_xnu_arg1 = target_image;
+
+ grub_dprintf ("xnu", "entry point 0x%x\n", codedest + hibhead.entry_point);
+ grub_dprintf ("xnu", "image at 0x%x\n",
+ codedest + codesize + GRUB_XNU_PAGESIZE);
+
+ /* We're ready now. */
+ grub_loader_set (grub_xnu_boot_resume,
+ grub_xnu_resume_unload, 0);
+
+ /* Prevent module from unloading. */
+ grub_xnu_lock ();
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c
new file mode 100644
index 0000000..bd495a1
--- /dev/null
+++ b/grub-core/mmap/efi/mmap.c
@@ -0,0 +1,318 @@
+/* Mmap management. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/memory.h>
+#include <grub/memory.h>
+#include <grub/err.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+
+#define NEXT_MEMORY_DESCRIPTOR(desc, size) \
+ ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
+
+grub_err_t
+grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
+ int avoid_efi_boot_services)
+{
+ grub_efi_uintn_t mmap_size = 0;
+ grub_efi_memory_descriptor_t *map_buf = 0;
+ grub_efi_uintn_t map_key = 0;
+ grub_efi_uintn_t desc_size = 0;
+ grub_efi_uint32_t desc_version = 0;
+ grub_efi_memory_descriptor_t *desc;
+
+ if (grub_efi_get_memory_map (&mmap_size, map_buf,
+ &map_key, &desc_size,
+ &desc_version) < 0)
+ return grub_errno;
+
+ map_buf = grub_malloc (mmap_size);
+ if (! map_buf)
+ return grub_errno;
+
+ if (grub_efi_get_memory_map (&mmap_size, map_buf,
+ &map_key, &desc_size,
+ &desc_version) <= 0)
+ {
+ grub_free (map_buf);
+ return grub_errno;
+ }
+
+ for (desc = map_buf;
+ desc < NEXT_MEMORY_DESCRIPTOR (map_buf, mmap_size);
+ desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
+ {
+ grub_dprintf ("mmap", "EFI memory region 0x%llx-0x%llx: %d\n",
+ (unsigned long long) desc->physical_start,
+ (unsigned long long) desc->physical_start
+ + desc->num_pages * 4096, desc->type);
+ switch (desc->type)
+ {
+ case GRUB_EFI_BOOT_SERVICES_CODE:
+ if (!avoid_efi_boot_services)
+ {
+ hook (desc->physical_start, desc->num_pages * 4096,
+ 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);
+ break;
+
+ case GRUB_EFI_UNUSABLE_MEMORY:
+ hook (desc->physical_start, desc->num_pages * 4096,
+ GRUB_MEMORY_BADRAM, hook_data);
+ break;
+
+ case GRUB_EFI_BOOT_SERVICES_DATA:
+ if (!avoid_efi_boot_services)
+ {
+ hook (desc->physical_start, desc->num_pages * 4096,
+ 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:
+ case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
+ case GRUB_EFI_PAL_CODE:
+ hook (desc->physical_start, desc->num_pages * 4096,
+ GRUB_MEMORY_RESERVED, hook_data);
+ break;
+
+ case GRUB_EFI_LOADER_CODE:
+ case GRUB_EFI_LOADER_DATA:
+ case GRUB_EFI_CONVENTIONAL_MEMORY:
+ hook (desc->physical_start, desc->num_pages * 4096,
+ GRUB_MEMORY_AVAILABLE, hook_data);
+ break;
+
+ case GRUB_EFI_ACPI_RECLAIM_MEMORY:
+ hook (desc->physical_start, desc->num_pages * 4096,
+ GRUB_MEMORY_ACPI, hook_data);
+ break;
+
+ case GRUB_EFI_ACPI_MEMORY_NVS:
+ 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;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ return grub_efi_mmap_iterate (hook, hook_data, 0);
+}
+
+static inline grub_efi_memory_type_t
+make_efi_memtype (int type)
+{
+ switch (type)
+ {
+ case GRUB_MEMORY_CODE:
+ return GRUB_EFI_RUNTIME_SERVICES_CODE;
+
+ /* 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;
+
+ case GRUB_MEMORY_AVAILABLE:
+ return GRUB_EFI_CONVENTIONAL_MEMORY;
+
+ case GRUB_MEMORY_ACPI:
+ return GRUB_EFI_ACPI_RECLAIM_MEMORY;
+
+ case GRUB_MEMORY_NVS:
+ return GRUB_EFI_ACPI_MEMORY_NVS;
+ }
+
+ return GRUB_EFI_UNUSABLE_MEMORY;
+}
+
+struct overlay
+{
+ struct overlay *next;
+ grub_efi_physical_address_t address;
+ grub_efi_uintn_t pages;
+ int handle;
+};
+
+static struct overlay *overlays = 0;
+static int curhandle = 1;
+
+int
+grub_mmap_register (grub_uint64_t start, grub_uint64_t size, int type)
+{
+ grub_uint64_t end = start + size;
+ grub_efi_physical_address_t address;
+ grub_efi_boot_services_t *b;
+ grub_efi_uintn_t pages;
+ grub_efi_status_t status;
+ struct overlay *curover;
+
+ curover = (struct overlay *) grub_malloc (sizeof (struct overlay));
+ if (! curover)
+ return 0;
+
+ b = grub_efi_system_table->boot_services;
+ address = start & (~0xfffULL);
+ pages = (end - address + 0xfff) >> 12;
+ status = efi_call_2 (b->free_pages, address, pages);
+ if (status != GRUB_EFI_SUCCESS && status != GRUB_EFI_NOT_FOUND)
+ {
+ grub_free (curover);
+ return 0;
+ }
+ status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ADDRESS,
+ make_efi_memtype (type), pages, &address);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_free (curover);
+ return 0;
+ }
+ curover->next = overlays;
+ curover->handle = curhandle++;
+ curover->address = address;
+ curover->pages = pages;
+ overlays = curover;
+
+ return curover->handle;
+}
+
+grub_err_t
+grub_mmap_unregister (int handle)
+{
+ struct overlay *curover, *prevover;
+ grub_efi_boot_services_t *b;
+
+ b = grub_efi_system_table->boot_services;
+
+
+ for (curover = overlays, prevover = 0; curover;
+ prevover = curover, curover = curover->next)
+ {
+ if (curover->handle == handle)
+ {
+ efi_call_2 (b->free_pages, curover->address, curover->pages);
+ if (prevover != 0)
+ prevover->next = curover->next;
+ else
+ overlays = curover->next;
+ grub_free (curover);
+ return GRUB_ERR_NONE;
+ }
+ }
+ return grub_error (GRUB_ERR_BUG, "handle %d not found", handle);
+}
+
+/* Result is always page-aligned. */
+void *
+grub_mmap_malign_and_register (grub_uint64_t align __attribute__ ((unused)),
+ grub_uint64_t size,
+ int *handle, int type,
+ int flags __attribute__ ((unused)))
+{
+ grub_efi_physical_address_t address;
+ grub_efi_boot_services_t *b;
+ grub_efi_uintn_t pages;
+ grub_efi_status_t status;
+ struct overlay *curover;
+ grub_efi_allocate_type_t atype;
+
+ curover = (struct overlay *) grub_malloc (sizeof (struct overlay));
+ if (! curover)
+ return 0;
+
+ b = grub_efi_system_table->boot_services;
+
+ address = 0xffffffff;
+
+#if GRUB_TARGET_SIZEOF_VOID_P < 8
+ /* Limit the memory access to less than 4GB for 32-bit platforms. */
+ atype = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
+#else
+ atype = GRUB_EFI_ALLOCATE_ANY_PAGES;
+#endif
+
+ pages = (size + 0xfff) >> 12;
+ status = efi_call_4 (b->allocate_pages, atype,
+ make_efi_memtype (type), pages, &address);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_free (curover);
+ return 0;
+ }
+
+ if (address == 0)
+ {
+ /* Uggh, the address 0 was allocated... This is too annoying,
+ so reallocate another one. */
+ address = 0xffffffff;
+ status = efi_call_4 (b->allocate_pages, atype,
+ make_efi_memtype (type), pages, &address);
+ grub_efi_free_pages (0, pages);
+ if (status != GRUB_EFI_SUCCESS)
+ return 0;
+ }
+
+ curover->next = overlays;
+ curover->handle = curhandle++;
+ curover->address = address;
+ curover->pages = pages;
+ overlays = curover;
+ *handle = curover->handle;
+
+ return (void *) (grub_addr_t) curover->address;
+}
+
+void
+grub_mmap_free_and_unregister (int handle)
+{
+ grub_mmap_unregister (handle);
+}
diff --git a/grub-core/mmap/i386/mmap.c b/grub-core/mmap/i386/mmap.c
new file mode 100644
index 0000000..ac45f70
--- /dev/null
+++ b/grub-core/mmap/i386/mmap.c
@@ -0,0 +1,113 @@
+/* Mmap management. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/memory.h>
+#include <grub/i386/memory.h>
+#include <grub/memory.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+
+
+#ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE
+
+/* Context for grub_mmap_malign_and_register. */
+struct grub_mmap_malign_and_register_ctx
+{
+ grub_uint64_t align, size, highestlow;
+};
+
+/* Helper for grub_mmap_malign_and_register. */
+static int
+find_hook (grub_uint64_t start, grub_uint64_t rangesize,
+ grub_memory_type_t memtype, void *data)
+{
+ struct grub_mmap_malign_and_register_ctx *ctx = data;
+ grub_uint64_t end = start + rangesize;
+
+ if (memtype != GRUB_MEMORY_AVAILABLE)
+ return 0;
+ if (end > 0x100000)
+ end = 0x100000;
+ if (end > start + ctx->size
+ && ctx->highestlow < ((end - ctx->size)
+ - ((end - ctx->size) & (ctx->align - 1))))
+ ctx->highestlow = (end - ctx->size)
+ - ((end - ctx->size) & (ctx->align - 1));
+ return 0;
+}
+
+void *
+grub_mmap_malign_and_register (grub_uint64_t align, grub_uint64_t size,
+ int *handle, int type, int flags)
+{
+ struct grub_mmap_malign_and_register_ctx ctx = {
+ .align = align,
+ .size = size,
+ .highestlow = 0
+ };
+
+ void *ret;
+ if (flags & GRUB_MMAP_MALLOC_LOW)
+ {
+ /* FIXME: use low-memory mm allocation once it's available. */
+ grub_mmap_iterate (find_hook, &ctx);
+ ret = (void *) (grub_addr_t) ctx.highestlow;
+ }
+ else
+ ret = grub_memalign (align, size);
+
+ if (! ret)
+ {
+ *handle = 0;
+ return 0;
+ }
+
+ *handle = grub_mmap_register ((grub_addr_t) ret, size, type);
+ if (! *handle)
+ {
+ grub_free (ret);
+ return 0;
+ }
+
+ return ret;
+}
+
+void
+grub_mmap_free_and_unregister (int handle)
+{
+ struct grub_mmap_region *cur;
+ grub_uint64_t addr;
+
+ for (cur = grub_mmap_overlays; cur; cur = cur->next)
+ if (cur->handle == handle)
+ break;
+
+ if (! cur)
+ return;
+
+ addr = cur->start;
+
+ grub_mmap_unregister (handle);
+
+ if (addr >= 0x100000)
+ grub_free ((void *) (grub_addr_t) addr);
+}
+
+#endif
diff --git a/grub-core/mmap/i386/pc/mmap.c b/grub-core/mmap/i386/pc/mmap.c
new file mode 100644
index 0000000..6ab4f67
--- /dev/null
+++ b/grub-core/mmap/i386/pc/mmap.c
@@ -0,0 +1,211 @@
+/* Mmap management. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/memory.h>
+#include <grub/memory.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/loader.h>
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+
+static void *hooktarget = 0;
+
+extern grub_uint8_t grub_machine_mmaphook_start;
+extern grub_uint8_t grub_machine_mmaphook_end;
+extern grub_uint8_t grub_machine_mmaphook_int12;
+extern grub_uint8_t grub_machine_mmaphook_int15;
+
+static grub_uint16_t grub_machine_mmaphook_int12offset = 0;
+static grub_uint16_t grub_machine_mmaphook_int12segment = 0;
+extern grub_uint16_t grub_machine_mmaphook_int15offset;
+extern grub_uint16_t grub_machine_mmaphook_int15segment;
+
+extern grub_uint16_t grub_machine_mmaphook_mmap_num;
+extern grub_uint16_t grub_machine_mmaphook_kblow;
+extern grub_uint16_t grub_machine_mmaphook_kbin16mb;
+extern grub_uint16_t grub_machine_mmaphook_64kbin4gb;
+
+/* Helper for preboot. */
+static int fill_hook (grub_uint64_t addr, grub_uint64_t size,
+ grub_memory_type_t type, void *data)
+{
+ struct grub_e820_mmap_entry **hookmmapcur = data;
+ grub_dprintf ("mmap", "mmap chunk %llx-%llx:%x\n", addr, addr + size, type);
+ (*hookmmapcur)->addr = addr;
+ (*hookmmapcur)->len = size;
+ (*hookmmapcur)->type = type;
+ (*hookmmapcur)++;
+ return 0;
+}
+
+static grub_err_t
+preboot (int noreturn __attribute__ ((unused)))
+{
+ struct grub_e820_mmap_entry *hookmmap, *hookmmapcur;
+
+ if (! hooktarget)
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ "no space is allocated for memory hook");
+
+ grub_dprintf ("mmap", "installing preboot handlers\n");
+
+ hookmmapcur = hookmmap = (struct grub_e820_mmap_entry *)
+ ((grub_uint8_t *) hooktarget + (&grub_machine_mmaphook_end
+ - &grub_machine_mmaphook_start));
+
+ grub_mmap_iterate (fill_hook, &hookmmapcur);
+ grub_machine_mmaphook_mmap_num = hookmmapcur - hookmmap;
+
+ grub_machine_mmaphook_kblow = grub_mmap_get_lower () >> 10;
+ grub_machine_mmaphook_kbin16mb
+ = min (grub_mmap_get_upper (),0x3f00000ULL) >> 10;
+ grub_machine_mmaphook_64kbin4gb
+ = min (grub_mmap_get_post64 (), 0xfc000000ULL) >> 16;
+
+ /* Correct BDA. */
+ *((grub_uint16_t *) 0x413) = grub_mmap_get_lower () >> 10;
+
+ /* Save old interrupt handlers. */
+ grub_machine_mmaphook_int12offset = *((grub_uint16_t *) 0x48);
+ grub_machine_mmaphook_int12segment = *((grub_uint16_t *) 0x4a);
+ grub_machine_mmaphook_int15offset = *((grub_uint16_t *) 0x54);
+ grub_machine_mmaphook_int15segment = *((grub_uint16_t *) 0x56);
+
+ grub_dprintf ("mmap", "hooktarget = %p\n", hooktarget);
+
+ /* Install the interrupt handlers. */
+ grub_memcpy (hooktarget, &grub_machine_mmaphook_start,
+ &grub_machine_mmaphook_end - &grub_machine_mmaphook_start);
+
+ *((grub_uint16_t *) 0x4a) = ((grub_addr_t) hooktarget) >> 4;
+ *((grub_uint16_t *) 0x56) = ((grub_addr_t) hooktarget) >> 4;
+ *((grub_uint16_t *) 0x48) = &grub_machine_mmaphook_int12
+ - &grub_machine_mmaphook_start;
+ *((grub_uint16_t *) 0x54) = &grub_machine_mmaphook_int15
+ - &grub_machine_mmaphook_start;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+preboot_rest (void)
+{
+ /* Restore old interrupt handlers. */
+ *((grub_uint16_t *) 0x48) = grub_machine_mmaphook_int12offset;
+ *((grub_uint16_t *) 0x4a) = grub_machine_mmaphook_int12segment;
+ *((grub_uint16_t *) 0x54) = grub_machine_mmaphook_int15offset;
+ *((grub_uint16_t *) 0x56) = grub_machine_mmaphook_int15segment;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Helper for malloc_hook. */
+static int
+count_hook (grub_uint64_t addr __attribute__ ((unused)),
+ grub_uint64_t size __attribute__ ((unused)),
+ grub_memory_type_t type __attribute__ ((unused)), void *data)
+{
+ int *regcount = data;
+ (*regcount)++;
+ return 0;
+}
+
+static grub_err_t
+malloc_hook (void)
+{
+ static int reentry = 0;
+ static int mmapregion = 0;
+ static int slots_available = 0;
+ int hooksize;
+ int regcount = 0;
+
+ if (reentry)
+ return GRUB_ERR_NONE;
+
+ grub_dprintf ("mmap", "registering\n");
+
+ grub_mmap_iterate (count_hook, &regcount);
+
+ /* Mapping hook itself may introduce up to 2 additional regions. */
+ regcount += 2;
+
+ if (regcount <= slots_available)
+ return GRUB_ERR_NONE;
+
+ if (mmapregion)
+ {
+ grub_mmap_free_and_unregister (mmapregion);
+ mmapregion = 0;
+ hooktarget = 0;
+ }
+
+ hooksize = &grub_machine_mmaphook_end - &grub_machine_mmaphook_start
+ + regcount * sizeof (struct grub_e820_mmap_entry);
+ /* Allocate an integer number of KiB. */
+ hooksize = ((hooksize - 1) | 0x3ff) + 1;
+ slots_available = (hooksize - (&grub_machine_mmaphook_end
+ - &grub_machine_mmaphook_start))
+ / sizeof (struct grub_e820_mmap_entry);
+
+ reentry = 1;
+ hooktarget
+ = grub_mmap_malign_and_register (16, ALIGN_UP (hooksize, 16), &mmapregion,
+ GRUB_MEMORY_RESERVED,
+ GRUB_MMAP_MALLOC_LOW);
+ reentry = 0;
+
+ if (! hooktarget)
+ {
+ slots_available = 0;
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "no space for mmap hook");
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
+ grub_uint64_t size __attribute__ ((unused)),
+ int type __attribute__ ((unused)),
+ int handle __attribute__ ((unused)))
+{
+ grub_err_t err;
+ static struct grub_preboot *preb_handle = 0;
+
+ err = malloc_hook ();
+ if (err)
+ return err;
+
+ if (! preb_handle)
+ {
+ grub_dprintf ("mmap", "adding preboot\n");
+ preb_handle
+ = grub_loader_register_preboot_hook (preboot, preboot_rest,
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_MEMORY);
+ if (! preb_handle)
+ return grub_errno;
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_machine_mmap_unregister (int handle __attribute__ ((unused)))
+{
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/mmap/i386/pc/mmap_helper.S b/grub-core/mmap/i386/pc/mmap_helper.S
new file mode 100644
index 0000000..8e251a1
--- /dev/null
+++ b/grub-core/mmap/i386/pc/mmap_helper.S
@@ -0,0 +1,163 @@
+/* Mmap management. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+
+#define DS(x) ((x) - LOCAL (segstart))
+
+LOCAL (segstart):
+VARIABLE(grub_machine_mmaphook_start)
+ .code16
+VARIABLE(grub_machine_mmaphook_int12)
+ push %ds
+ push %cs
+ pop %ds
+#ifdef __APPLE__
+ LOCAL(kblow_offset) = DS (LOCAL (kblow))
+ movw LOCAL(kblow_offset), %ax
+#else
+ movw DS (LOCAL (kblow)), %ax
+#endif
+ pop %ds
+ iret
+
+VARIABLE(grub_machine_mmaphook_int15)
+ pushf
+ cmpw $0xe801, %ax
+ jz LOCAL (e801)
+ cmpw $0xe820, %ax
+ jz LOCAL (e820)
+ cmpb $0x88, %ah
+ jz LOCAL (h88)
+ popf
+ /* ljmp */
+ .byte 0xea
+VARIABLE (grub_machine_mmaphook_int15offset)
+ .word 0
+VARIABLE (grub_machine_mmaphook_int15segment)
+ .word 0
+
+LOCAL (e801):
+ popf
+ push %ds
+ push %cs
+ pop %ds
+#ifdef __APPLE__
+ LOCAL(kbin16mb_offset) = DS (LOCAL (kbin16mb))
+ LOCAL(m64kbin4gb_offset) = DS (LOCAL (m64kbin4gb))
+ movw LOCAL(kbin16mb_offset), %ax
+ movw LOCAL(m64kbin4gb_offset), %bx
+#else
+ movw DS (LOCAL (kbin16mb)), %ax
+ movw DS (LOCAL (m64kbin4gb)), %bx
+#endif
+ movw %ax, %cx
+ movw %bx, %dx
+ pop %ds
+ clc
+ jmp LOCAL (iret_cf)
+
+LOCAL (h88):
+ popf
+ push %ds
+ push %cs
+ pop %ds
+#ifdef __APPLE__
+ movw LOCAL(kbin16mb_offset), %ax
+#else
+ movw DS (LOCAL (kbin16mb)), %ax
+#endif
+ pop %ds
+ clc
+ jmp LOCAL (iret_cf)
+
+LOCAL (e820):
+ popf
+ push %ds
+ push %cs
+ pop %ds
+ cmpw $20, %cx
+ jb LOCAL (errexit)
+#ifdef __APPLE__
+ LOCAL(mmap_num_offset) = DS (LOCAL (mmap_num))
+ cmpw LOCAL(mmap_num_offset), %bx
+#else
+ cmpw DS (LOCAL (mmap_num)), %bx
+#endif
+ jae LOCAL (errexit)
+ cmp $0x534d4150, %edx
+ jne LOCAL (errexit)
+ push %si
+ push %di
+ movw $20, %cx
+#ifdef __APPLE__
+ LOCAL(mmaphook_map_offset) = DS(LOCAL (mmaphook_mmap))
+ movw $LOCAL(mmaphook_map_offset), %si
+#else
+ movw $(DS(LOCAL (mmaphook_mmap))), %si
+#endif
+ mov %bx, %ax
+ imul $20, %ax
+ add %ax, %si
+ rep movsb
+ pop %di
+ pop %si
+ movl $20, %ecx
+ inc %bx
+#ifdef __APPLE__
+ cmpw LOCAL(mmap_num_offset), %bx
+#else
+ cmpw DS(LOCAL (mmap_num)), %bx
+#endif
+ jb LOCAL (noclean)
+ xor %bx, %bx
+LOCAL (noclean):
+ mov $0x534d4150, %eax
+ pop %ds
+ clc
+ jmp LOCAL (iret_cf)
+LOCAL (errexit):
+ mov $0x534d4150, %eax
+ pop %ds
+ xor %bx, %bx
+ stc
+
+LOCAL (iret_cf):
+ push %bp
+ mov %sp, %bp
+ setc 6(%bp)
+ pop %bp
+ iret
+
+VARIABLE(grub_machine_mmaphook_mmap_num)
+LOCAL (mmap_num):
+ .word 0
+VARIABLE(grub_machine_mmaphook_kblow)
+LOCAL (kblow):
+ .word 0
+VARIABLE (grub_machine_mmaphook_kbin16mb)
+LOCAL (kbin16mb):
+ .word 0
+VARIABLE (grub_machine_mmaphook_64kbin4gb)
+LOCAL (m64kbin4gb):
+ .word 0
+LOCAL (mmaphook_mmap):
+ /* Memory map is placed just after the interrupt handlers. */
+VARIABLE(grub_machine_mmaphook_end)
+ .byte 0
diff --git a/grub-core/mmap/i386/uppermem.c b/grub-core/mmap/i386/uppermem.c
new file mode 100644
index 0000000..a6be989
--- /dev/null
+++ b/grub-core/mmap/i386/uppermem.c
@@ -0,0 +1,98 @@
+/* Compute amount of lower and upper memory till the first hole. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/memory.h>
+#include <grub/i386/memory.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+
+/* Helper for grub_mmap_get_lower. */
+static int
+lower_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data)
+{
+ grub_uint64_t *lower = data;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+#ifdef GRUB_MACHINE_COREBOOT
+ if (addr <= 0x1000)
+#else
+ if (addr == 0)
+#endif
+ *lower = size + addr;
+ return 0;
+}
+
+grub_uint64_t
+grub_mmap_get_lower (void)
+{
+ grub_uint64_t lower = 0;
+
+ grub_mmap_iterate (lower_hook, &lower);
+ if (lower > 0x100000)
+ lower = 0x100000;
+ return lower;
+}
+
+/* Helper for grub_mmap_get_upper. */
+static int
+upper_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data)
+{
+ grub_uint64_t *upper = data;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+ if (addr <= 0x100000 && addr + size > 0x100000)
+ *upper = addr + size - 0x100000;
+ return 0;
+}
+
+grub_uint64_t
+grub_mmap_get_upper (void)
+{
+ grub_uint64_t upper = 0;
+
+ grub_mmap_iterate (upper_hook, &upper);
+ return upper;
+}
+
+/* Helper for grub_mmap_get_post64. */
+static int
+post64_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data)
+{
+ grub_uint64_t *post64 = data;
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+ if (addr <= 0x4000000 && addr + size > 0x4000000)
+ *post64 = addr + size - 0x4000000;
+ return 0;
+}
+
+/* Count the continuous bytes after 64 MiB. */
+grub_uint64_t
+grub_mmap_get_post64 (void)
+{
+ grub_uint64_t post64 = 0;
+
+ grub_mmap_iterate (post64_hook, &post64);
+ return post64;
+}
diff --git a/grub-core/mmap/mips/uppermem.c b/grub-core/mmap/mips/uppermem.c
new file mode 100644
index 0000000..a980e07
--- /dev/null
+++ b/grub-core/mmap/mips/uppermem.c
@@ -0,0 +1,72 @@
+/* Compute amount of lower and upper memory till the first hole. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/memory.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/cpu/memory.h>
+
+/* Helper for grub_mmap_get_lower. */
+static int
+lower_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data)
+{
+ grub_uint64_t *lower = data;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+ if (addr == 0)
+ *lower = size;
+ return 0;
+}
+
+grub_uint64_t
+grub_mmap_get_lower (void)
+{
+ grub_uint64_t lower = 0;
+
+ grub_mmap_iterate (lower_hook, &lower);
+ if (lower > GRUB_ARCH_LOWMEMMAXSIZE)
+ lower = GRUB_ARCH_LOWMEMMAXSIZE;
+ return lower;
+}
+
+/* Helper for grub_mmap_get_upper. */
+static int
+upper_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data)
+{
+ grub_uint64_t *upper = data;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+ if (addr <= GRUB_ARCH_HIGHMEMPSTART && addr + size
+ > GRUB_ARCH_HIGHMEMPSTART)
+ *upper = addr + size - GRUB_ARCH_HIGHMEMPSTART;
+ return 0;
+}
+
+grub_uint64_t
+grub_mmap_get_upper (void)
+{
+ grub_uint64_t upper = 0;
+
+ grub_mmap_iterate (upper_hook, &upper);
+ return upper;
+}
diff --git a/grub-core/mmap/mmap.c b/grub-core/mmap/mmap.c
new file mode 100644
index 0000000..c8c8312
--- /dev/null
+++ b/grub-core/mmap/mmap.c
@@ -0,0 +1,554 @@
+/* Mmap management. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/memory.h>
+#include <grub/machine/memory.h>
+#include <grub/err.h>
+#include <grub/lockdown.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/command.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE
+
+struct grub_mmap_region *grub_mmap_overlays = 0;
+static int curhandle = 1;
+
+#endif
+
+static int current_priority = 1;
+
+/* Scanline events. */
+struct grub_mmap_scan
+{
+ /* At which memory address. */
+ grub_uint64_t pos;
+ /* 0 = region starts, 1 = region ends. */
+ int type;
+ /* Which type of memory region? */
+ grub_memory_type_t memtype;
+ /* Priority. 0 means coming from firmware. */
+ int priority;
+};
+
+/* Context for grub_mmap_iterate. */
+struct grub_mmap_iterate_ctx
+{
+ struct grub_mmap_scan *scanline_events;
+ int i;
+};
+
+/* Helper for grub_mmap_iterate. */
+static int
+count_hook (grub_uint64_t addr __attribute__ ((unused)),
+ grub_uint64_t size __attribute__ ((unused)),
+ grub_memory_type_t type __attribute__ ((unused)), void *data)
+{
+ int *mmap_num = data;
+
+ (*mmap_num)++;
+ return 0;
+}
+
+/* Helper for grub_mmap_iterate. */
+static int
+fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
+ void *data)
+{
+ struct grub_mmap_iterate_ctx *ctx = data;
+
+ if (type == GRUB_MEMORY_HOLE)
+ {
+ grub_dprintf ("mmap", "Unknown memory type %d. Assuming unusable\n",
+ type);
+ type = GRUB_MEMORY_RESERVED;
+ }
+
+ ctx->scanline_events[ctx->i].pos = addr;
+ ctx->scanline_events[ctx->i].type = 0;
+ ctx->scanline_events[ctx->i].memtype = type;
+ ctx->scanline_events[ctx->i].priority = 0;
+
+ ctx->i++;
+
+ ctx->scanline_events[ctx->i].pos = addr + size;
+ ctx->scanline_events[ctx->i].type = 1;
+ ctx->scanline_events[ctx->i].memtype = type;
+ ctx->scanline_events[ctx->i].priority = 0;
+ ctx->i++;
+
+ return 0;
+}
+
+struct mm_list
+{
+ struct mm_list *next;
+ grub_memory_type_t val;
+ int present;
+};
+
+grub_err_t
+grub_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ /* This function resolves overlapping regions and sorts the memory map.
+ It uses scanline (sweeping) algorithm.
+ */
+ struct grub_mmap_iterate_ctx ctx;
+ int i, done;
+
+ struct grub_mmap_scan t;
+
+ /* Previous scanline event. */
+ grub_uint64_t lastaddr;
+ int lasttype;
+ /* Current scanline event. */
+ int curtype;
+ /* How many regions of given type/priority overlap at current location? */
+ /* Normally there shouldn't be more than one region per priority but be robust. */
+ struct mm_list *present;
+ /* Number of mmap chunks. */
+ int mmap_num;
+
+#ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE
+ struct grub_mmap_region *cur;
+#endif
+
+ mmap_num = 0;
+
+#ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE
+ for (cur = grub_mmap_overlays; cur; cur = cur->next)
+ mmap_num++;
+#endif
+
+ grub_machine_mmap_iterate (count_hook, &mmap_num);
+
+ /* Initialize variables. */
+ ctx.scanline_events = (struct grub_mmap_scan *)
+ grub_calloc (mmap_num, sizeof (struct grub_mmap_scan) * 2);
+
+ present = grub_calloc (current_priority, sizeof (present[0]));
+
+ if (! ctx.scanline_events || !present)
+ {
+ grub_free (ctx.scanline_events);
+ grub_free (present);
+ return grub_errno;
+ }
+
+ ctx.i = 0;
+#ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE
+ /* Register scanline events. */
+ for (cur = grub_mmap_overlays; cur; cur = cur->next)
+ {
+ ctx.scanline_events[ctx.i].pos = cur->start;
+ ctx.scanline_events[ctx.i].type = 0;
+ ctx.scanline_events[ctx.i].memtype = cur->type;
+ ctx.scanline_events[ctx.i].priority = cur->priority;
+ ctx.i++;
+
+ ctx.scanline_events[ctx.i].pos = cur->end;
+ ctx.scanline_events[ctx.i].type = 1;
+ ctx.scanline_events[ctx.i].memtype = cur->type;
+ ctx.scanline_events[ctx.i].priority = cur->priority;
+ ctx.i++;
+ }
+#endif /* ! GRUB_MMAP_REGISTER_BY_FIRMWARE */
+
+ grub_machine_mmap_iterate (fill_hook, &ctx);
+
+ /* Primitive bubble sort. It has complexity O(n^2) but since we're
+ unlikely to have more than 100 chunks it's probably one of the
+ fastest for one purpose. */
+ done = 1;
+ while (done)
+ {
+ done = 0;
+ for (i = 0; i < 2 * mmap_num - 1; i++)
+ if (ctx.scanline_events[i + 1].pos < ctx.scanline_events[i].pos
+ || (ctx.scanline_events[i + 1].pos == ctx.scanline_events[i].pos
+ && ctx.scanline_events[i + 1].type == 0
+ && ctx.scanline_events[i].type == 1))
+ {
+ t = ctx.scanline_events[i + 1];
+ ctx.scanline_events[i + 1] = ctx.scanline_events[i];
+ ctx.scanline_events[i] = t;
+ done = 1;
+ }
+ }
+
+ lastaddr = ctx.scanline_events[0].pos;
+ lasttype = ctx.scanline_events[0].memtype;
+ for (i = 0; i < 2 * mmap_num; i++)
+ {
+ /* Process event. */
+ if (ctx.scanline_events[i].type)
+ {
+ if (present[ctx.scanline_events[i].priority].present)
+ {
+ if (present[ctx.scanline_events[i].priority].val == ctx.scanline_events[i].memtype)
+ {
+ if (present[ctx.scanline_events[i].priority].next)
+ {
+ struct mm_list *p = present[ctx.scanline_events[i].priority].next;
+ present[ctx.scanline_events[i].priority] = *p;
+ grub_free (p);
+ }
+ else
+ {
+ present[ctx.scanline_events[i].priority].present = 0;
+ }
+ }
+ else
+ {
+ struct mm_list **q = &(present[ctx.scanline_events[i].priority].next), *p;
+ for (; *q; q = &((*q)->next))
+ if ((*q)->val == ctx.scanline_events[i].memtype)
+ {
+ p = *q;
+ *q = p->next;
+ grub_free (p);
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (!present[ctx.scanline_events[i].priority].present)
+ {
+ present[ctx.scanline_events[i].priority].present = 1;
+ present[ctx.scanline_events[i].priority].val = ctx.scanline_events[i].memtype;
+ }
+ else
+ {
+ struct mm_list *n = grub_malloc (sizeof (*n));
+ n->val = ctx.scanline_events[i].memtype;
+ n->present = 1;
+ n->next = present[ctx.scanline_events[i].priority].next;
+ present[ctx.scanline_events[i].priority].next = n;
+ }
+ }
+
+ /* Determine current region type. */
+ curtype = -1;
+ {
+ int k;
+ for (k = current_priority - 1; k >= 0; k--)
+ if (present[k].present)
+ {
+ curtype = present[k].val;
+ break;
+ }
+ }
+
+ /* Announce region to the hook if necessary. */
+ if ((curtype == -1 || curtype != lasttype)
+ && lastaddr != ctx.scanline_events[i].pos
+ && lasttype != -1
+ && lasttype != GRUB_MEMORY_HOLE
+ && hook (lastaddr, ctx.scanline_events[i].pos - lastaddr, lasttype,
+ hook_data))
+ {
+ grub_free (ctx.scanline_events);
+ grub_free (present);
+ return GRUB_ERR_NONE;
+ }
+
+ /* Update last values if necessary. */
+ if (curtype == -1 || curtype != lasttype)
+ {
+ lasttype = curtype;
+ lastaddr = ctx.scanline_events[i].pos;
+ }
+ }
+
+ grub_free (ctx.scanline_events);
+ grub_free (present);
+ return GRUB_ERR_NONE;
+}
+
+#ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE
+int
+grub_mmap_register (grub_uint64_t start, grub_uint64_t size, int type)
+{
+ struct grub_mmap_region *cur;
+
+ grub_dprintf ("mmap", "registering\n");
+
+ cur = (struct grub_mmap_region *)
+ grub_malloc (sizeof (struct grub_mmap_region));
+ if (! cur)
+ return 0;
+
+ cur->next = grub_mmap_overlays;
+ cur->start = start;
+ cur->end = start + size;
+ cur->type = type;
+ cur->handle = curhandle++;
+ cur->priority = current_priority++;
+ grub_mmap_overlays = cur;
+
+ if (grub_machine_mmap_register (start, size, type, curhandle))
+ {
+ grub_mmap_overlays = cur->next;
+ grub_free (cur);
+ return 0;
+ }
+
+ return cur->handle;
+}
+
+grub_err_t
+grub_mmap_unregister (int handle)
+{
+ struct grub_mmap_region *cur, *prev;
+
+ for (cur = grub_mmap_overlays, prev = 0; cur; prev = cur, cur = cur->next)
+ if (handle == cur->handle)
+ {
+ grub_err_t err;
+ err = grub_machine_mmap_unregister (handle);
+ if (err)
+ return err;
+
+ if (prev)
+ prev->next = cur->next;
+ else
+ grub_mmap_overlays = cur->next;
+ grub_free (cur);
+ return GRUB_ERR_NONE;
+ }
+ return grub_error (GRUB_ERR_BUG, "mmap overlay not found");
+}
+
+#endif /* ! GRUB_MMAP_REGISTER_BY_FIRMWARE */
+
+#define CHUNK_SIZE 0x400
+
+struct badram_entry {
+ grub_uint64_t addr, mask;
+};
+
+static inline grub_uint64_t
+fill_mask (struct badram_entry *entry, grub_uint64_t iterator)
+{
+ int i, j;
+ grub_uint64_t ret = (entry->addr & entry->mask);
+
+ /* Find first fixed bit. */
+ for (i = 0; i < 64; i++)
+ if ((entry->mask & (1ULL << i)) != 0)
+ break;
+ j = 0;
+ for (; i < 64; i++)
+ if ((entry->mask & (1ULL << i)) == 0)
+ {
+ if ((iterator & (1ULL << j)) != 0)
+ ret |= 1ULL << i;
+ j++;
+ }
+ return ret;
+}
+
+/* Helper for grub_cmd_badram. */
+static int
+badram_iter (grub_uint64_t addr, grub_uint64_t size,
+ grub_memory_type_t type __attribute__ ((unused)), void *data)
+{
+ struct badram_entry *entry = data;
+ grub_uint64_t iterator, low, high, cur;
+ int tail, var;
+ int i;
+ grub_dprintf ("badram", "hook %llx+%llx\n", (unsigned long long) addr,
+ (unsigned long long) size);
+
+ /* How many trailing zeros? */
+ for (tail = 0; ! (entry->mask & (1ULL << tail)); tail++);
+
+ /* How many zeros in mask? */
+ var = 0;
+ for (i = 0; i < 64; i++)
+ if (! (entry->mask & (1ULL << i)))
+ var++;
+
+ if (fill_mask (entry, 0) >= addr)
+ iterator = 0;
+ else
+ {
+ low = 0;
+ high = ~0ULL;
+ /* Find starting value. Keep low and high such that
+ fill_mask (low) < addr and fill_mask (high) >= addr;
+ */
+ while (high - low > 1)
+ {
+ cur = (low + high) / 2;
+ if (fill_mask (entry, cur) >= addr)
+ high = cur;
+ else
+ low = cur;
+ }
+ iterator = high;
+ }
+
+ for (; iterator < (1ULL << (var - tail))
+ && (cur = fill_mask (entry, iterator)) < addr + size;
+ iterator++)
+ {
+ grub_dprintf ("badram", "%llx (size %llx) is a badram range\n",
+ (unsigned long long) cur, (1ULL << tail));
+ grub_mmap_register (cur, (1ULL << tail), GRUB_MEMORY_HOLE);
+ }
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_badram (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ const char *str;
+ struct badram_entry entry;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ grub_dprintf ("badram", "executing badram\n");
+
+ str = args[0];
+
+ while (1)
+ {
+ /* Parse address and mask. */
+ entry.addr = grub_strtoull (str, &str, 16);
+ if (*str == ',')
+ str++;
+ entry.mask = grub_strtoull (str, &str, 16);
+ if (*str == ',')
+ str++;
+
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ {
+ grub_errno = 0;
+ return GRUB_ERR_NONE;
+ }
+
+ /* When part of a page is tainted, we discard the whole of it. There's
+ no point in providing sub-page chunks. */
+ entry.mask &= ~(CHUNK_SIZE - 1);
+
+ grub_dprintf ("badram", "badram %llx:%llx\n",
+ (unsigned long long) entry.addr,
+ (unsigned long long) entry.mask);
+
+ grub_mmap_iterate (badram_iter, &entry);
+ }
+}
+
+static grub_uint64_t
+parsemem (const char *str)
+{
+ grub_uint64_t ret;
+ const char *ptr;
+
+ ret = grub_strtoul (str, &ptr, 0);
+
+ switch (*ptr)
+ {
+ case 'K':
+ return ret << 10;
+ case 'M':
+ return ret << 20;
+ case 'G':
+ return ret << 30;
+ case 'T':
+ return ret << 40;
+ }
+ return ret;
+}
+
+struct cutmem_range {
+ grub_uint64_t from, to;
+};
+
+/* Helper for grub_cmd_cutmem. */
+static int
+cutmem_iter (grub_uint64_t addr, grub_uint64_t size,
+ grub_memory_type_t type __attribute__ ((unused)), void *data)
+{
+ struct cutmem_range *range = data;
+ grub_uint64_t end = addr + size;
+
+ if (addr <= range->from)
+ addr = range->from;
+ if (end >= range->to)
+ end = range->to;
+
+ if (end <= addr)
+ return 0;
+
+ grub_mmap_register (addr, end - addr, GRUB_MEMORY_HOLE);
+ return 0;
+}
+
+static grub_err_t
+grub_cmd_cutmem (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct cutmem_range range;
+
+ if (argc != 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+ range.from = parsemem (args[0]);
+ if (grub_errno)
+ return grub_errno;
+
+ range.to = parsemem (args[1]);
+ if (grub_errno)
+ return grub_errno;
+
+ grub_mmap_iterate (cutmem_iter, &range);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_command_t cmd, cmd_cut;
+
+
+GRUB_MOD_INIT(mmap)
+{
+ cmd = grub_register_command_lockdown ("badram", grub_cmd_badram,
+ N_("ADDR1,MASK1[,ADDR2,MASK2[,...]]"),
+ N_("Declare memory regions as faulty (badram)."));
+ cmd_cut = grub_register_command_lockdown ("cutmem", grub_cmd_cutmem,
+ N_("FROM[K|M|G] TO[K|M|G]"),
+ N_("Remove any memory regions in specified range."));
+
+}
+
+GRUB_MOD_FINI(mmap)
+{
+ grub_unregister_command (cmd);
+ grub_unregister_command (cmd_cut);
+}
+
diff --git a/grub-core/modinfo.sh.in b/grub-core/modinfo.sh.in
new file mode 100644
index 0000000..f6cd657
--- /dev/null
+++ b/grub-core/modinfo.sh.in
@@ -0,0 +1,40 @@
+#!@BUILD_SHEBANG@
+
+# 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
new file mode 100644
index 0000000..54306e3
--- /dev/null
+++ b/grub-core/net/arp.c
@@ -0,0 +1,189 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net/arp.h>
+#include <grub/net/netbuff.h>
+#include <grub/mm.h>
+#include <grub/net.h>
+#include <grub/net/ethernet.h>
+#include <grub/net/ip.h>
+#include <grub/time.h>
+
+/* ARP header operation codes */
+enum
+ {
+ ARP_REQUEST = 1,
+ ARP_REPLY = 2
+ };
+
+enum
+ {
+ /* IANA ARP constant to define hardware type as ethernet. */
+ GRUB_NET_ARPHRD_ETHERNET = 1
+ };
+
+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;
+static grub_uint32_t pending_req;
+
+grub_err_t
+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 arppkt *arp_packet;
+ grub_net_link_level_address_t target_mac_addr;
+ grub_err_t err;
+ int i;
+ grub_uint8_t *nbd;
+ grub_uint8_t arp_data[128];
+
+ if (proto_addr->type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4)
+ return grub_error (GRUB_ERR_BUG, "unsupported address family");
+
+ /* Build a request packet. */
+ nb.head = arp_data;
+ nb.end = arp_data + sizeof (arp_data);
+ grub_netbuff_clear (&nb);
+ grub_netbuff_reserve (&nb, 128);
+
+ err = grub_netbuff_push (&nb, sizeof (*arp_packet));
+ if (err)
+ return err;
+
+ 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 (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_memset (&target_mac_addr.mac, 0xff, 6);
+
+ nbd = nb.data;
+ 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 + (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_mac_addr, GRUB_NET_ETHERTYPE_ARP);
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card,
+ grub_uint16_t *vlantag)
+{
+ 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_mac_addr;
+ struct grub_net_network_level_interface *inf;
+
+ 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_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)
+ {
+ /* Verify vlantag id */
+ if (inf->card == card && inf->vlantag != *vlantag)
+ {
+ grub_dprintf ("net", "invalid vlantag! %x != %x\n",
+ inf->vlantag, *vlantag);
+ break;
+ }
+
+ /* Am I the protocol address target? */
+ if (grub_net_addr_cmp (&inf->address, &target_addr) == 0
+ && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST))
+ {
+ grub_net_link_level_address_t target;
+ 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, 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 */
+ 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
new file mode 100644
index 0000000..6fb5627
--- /dev/null
+++ b/grub-core/net/bootp.c
@@ -0,0 +1,925 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net.h>
+#include <grub/env.h>
+#include <grub/i18n.h>
+#include <grub/command.h>
+#include <grub/net/ip.h>
+#include <grub/net/netbuff.h>
+#include <grub/net/udp.h>
+#include <grub/datetime.h>
+
+struct grub_dhcp_discover_options
+{
+ grub_uint8_t magic[4];
+ struct
+ {
+ grub_uint8_t code;
+ grub_uint8_t len;
+ grub_uint8_t data;
+ } GRUB_PACKED message_type;
+ grub_uint8_t end;
+} GRUB_PACKED;
+
+struct grub_dhcp_request_options
+{
+ grub_uint8_t magic[4];
+ struct
+ {
+ grub_uint8_t code;
+ grub_uint8_t len;
+ grub_uint8_t data;
+ } GRUB_PACKED message_type;
+ struct
+ {
+ grub_uint8_t type;
+ grub_uint8_t len;
+ grub_uint32_t data;
+ } GRUB_PACKED server_identifier;
+ struct
+ {
+ grub_uint8_t type;
+ grub_uint8_t len;
+ grub_uint32_t data;
+ } GRUB_PACKED requested_ip;
+ struct
+ {
+ grub_uint8_t type;
+ grub_uint8_t len;
+ grub_uint8_t data[7];
+ } GRUB_PACKED parameter_request;
+ grub_uint8_t end;
+} GRUB_PACKED;
+
+enum
+{
+ GRUB_DHCP_OPT_OVERLOAD_FILE = 1,
+ GRUB_DHCP_OPT_OVERLOAD_SNAME = 2,
+};
+enum
+{
+ GRUB_DHCP_MESSAGE_UNKNOWN,
+ GRUB_DHCP_MESSAGE_DISCOVER,
+ GRUB_DHCP_MESSAGE_OFFER,
+ GRUB_DHCP_MESSAGE_REQUEST,
+ GRUB_DHCP_MESSAGE_DECLINE,
+ GRUB_DHCP_MESSAGE_ACK,
+ GRUB_DHCP_MESSAGE_NAK,
+ GRUB_DHCP_MESSAGE_RELEASE,
+ GRUB_DHCP_MESSAGE_INFORM,
+};
+
+#define GRUB_BOOTP_MAX_OPTIONS_SIZE 64
+
+/* Max timeout when waiting for BOOTP/DHCP reply */
+#define GRUB_DHCP_MAX_PACKET_TIMEOUT 32
+
+#define GRUB_BOOTP_MAX_OPTIONS_SIZE 64
+
+/* Max timeout when waiting for BOOTP/DHCP reply */
+#define GRUB_DHCP_MAX_PACKET_TIMEOUT 32
+
+static char
+hexdigit (grub_uint8_t val)
+{
+ if (val < 10)
+ return val + '0';
+ return val + 'a' - 10;
+}
+
+static const void *
+find_dhcp_option (const struct grub_net_bootp_packet *bp, grub_size_t size,
+ grub_uint8_t opt_code, grub_uint8_t *opt_len)
+{
+ const grub_uint8_t *ptr;
+ grub_uint8_t overload = 0;
+ int end = 0;
+ grub_size_t i;
+
+ if (opt_len)
+ *opt_len = 0;
+
+ /* Is the packet big enough to hold at least the magic cookie? */
+ if (size < sizeof (*bp) + sizeof (grub_uint32_t))
+ return NULL;
+
+ /*
+ * Pointer arithmetic to point behind the common stub packet, where
+ * the options start.
+ */
+ ptr = (grub_uint8_t *) (bp + 1);
+
+ if (ptr[0] != GRUB_NET_BOOTP_RFC1048_MAGIC_0
+ || ptr[1] != GRUB_NET_BOOTP_RFC1048_MAGIC_1
+ || ptr[2] != GRUB_NET_BOOTP_RFC1048_MAGIC_2
+ || ptr[3] != GRUB_NET_BOOTP_RFC1048_MAGIC_3)
+ return NULL;
+
+ size -= sizeof (*bp);
+ i = sizeof (grub_uint32_t);
+
+again:
+ while (i < size)
+ {
+ grub_uint8_t tagtype;
+ grub_uint8_t taglength;
+
+ tagtype = ptr[i++];
+
+ /* Pad tag. */
+ if (tagtype == GRUB_NET_BOOTP_PAD)
+ continue;
+
+ /* End tag. */
+ if (tagtype == GRUB_NET_BOOTP_END)
+ {
+ end = 1;
+ break;
+ }
+
+ if (i >= size)
+ return NULL;
+
+ taglength = ptr[i++];
+ if (i + taglength >= size)
+ return NULL;
+
+ grub_dprintf("net", "DHCP option %u (0x%02x) found with length %u.\n",
+ tagtype, tagtype, taglength);
+
+ /* FIXME RFC 3396 options concatentation */
+ if (tagtype == opt_code)
+ {
+ if (opt_len)
+ *opt_len = taglength;
+ return &ptr[i];
+ }
+
+ if (tagtype == GRUB_NET_DHCP_OVERLOAD && taglength == 1)
+ overload = ptr[i];
+
+ i += taglength;
+ }
+
+ if (!end)
+ return NULL;
+
+ /* RFC2131, 4.1, 23ff:
+ * If the options in a DHCP message extend into the 'sname' and 'file'
+ * fields, the 'option overload' option MUST appear in the 'options'
+ * field, with value 1, 2 or 3, as specified in RFC 1533. If the
+ * 'option overload' option is present in the 'options' field, the
+ * options in the 'options' field MUST be terminated by an 'end' option,
+ * and MAY contain one or more 'pad' options to fill the options field.
+ * The options in the 'sname' and 'file' fields (if in use as indicated
+ * by the 'options overload' option) MUST begin with the first octet of
+ * the field, MUST be terminated by an 'end' option, and MUST be
+ * followed by 'pad' options to fill the remainder of the field. Any
+ * individual option in the 'options', 'sname' and 'file' fields MUST be
+ * entirely contained in that field. The options in the 'options' field
+ * MUST be interpreted first, so that any 'option overload' options may
+ * be interpreted. The 'file' field MUST be interpreted next (if the
+ * 'option overload' option indicates that the 'file' field contains
+ * DHCP options), followed by the 'sname' field.
+ *
+ * FIXME: We do not explicitly check for trailing 'pad' options here.
+ */
+ end = 0;
+ if (overload & GRUB_DHCP_OPT_OVERLOAD_FILE)
+ {
+ overload &= ~GRUB_DHCP_OPT_OVERLOAD_FILE;
+ ptr = (grub_uint8_t *) &bp->boot_file[0];
+ size = sizeof (bp->boot_file);
+ i = 0;
+ goto again;
+ }
+
+ if (overload & GRUB_DHCP_OPT_OVERLOAD_SNAME)
+ {
+ overload &= ~GRUB_DHCP_OPT_OVERLOAD_SNAME;
+ ptr = (grub_uint8_t *) &bp->server_name[0];
+ size = sizeof (bp->server_name);
+ i = 0;
+ goto again;
+ }
+
+ return NULL;
+}
+
+#define OFFSET_OF(x, y) ((grub_size_t)((grub_uint8_t *)((y)->x) - (grub_uint8_t *)(y)))
+
+struct grub_net_network_level_interface *
+grub_net_configure_by_dhcp_ack (const char *name,
+ struct grub_net_card *card,
+ grub_net_interface_flags_t flags,
+ const struct grub_net_bootp_packet *bp,
+ grub_size_t size,
+ int is_def, char **device, char **path)
+{
+ grub_net_network_level_address_t addr;
+ grub_net_link_level_address_t hwaddr;
+ struct grub_net_network_level_interface *inter;
+ int mask = -1;
+ char server_ip[sizeof ("xxx.xxx.xxx.xxx")];
+ const grub_uint8_t *opt;
+ grub_uint8_t opt_len, overload = 0;
+ const char *boot_file = 0, *server_name = 0;
+ grub_size_t boot_file_len, server_name_len;
+
+ addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ addr.ipv4 = bp->your_ip;
+
+ if (device)
+ *device = 0;
+ if (path)
+ *path = 0;
+
+ grub_memcpy (hwaddr.mac, bp->mac_addr,
+ bp->hw_len < sizeof (hwaddr.mac) ? bp->hw_len
+ : sizeof (hwaddr.mac));
+ hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+
+ inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags);
+ if (!inter)
+ return 0;
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_OVERLOAD, &opt_len);
+ if (opt && opt_len == 1)
+ overload = *opt;
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_TFTP_SERVER_NAME, &opt_len);
+ if (opt && opt_len)
+ {
+ server_name = (const char *) opt;
+ server_name_len = opt_len;
+ }
+ else if (size > OFFSET_OF (server_name, bp) && !(overload & GRUB_DHCP_OPT_OVERLOAD_SNAME) &&
+ bp->server_name[0])
+ {
+ server_name = bp->server_name;
+ server_name_len = sizeof (bp->server_name);
+ }
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_BOOTFILE_NAME, &opt_len);
+ if (opt && opt_len)
+ {
+ boot_file = (const char *) opt;
+ boot_file_len = opt_len;
+ }
+ else if (size > OFFSET_OF (boot_file, bp) && !(overload && GRUB_DHCP_OPT_OVERLOAD_FILE) &&
+ bp->boot_file[0])
+ {
+ boot_file = bp->boot_file;
+ boot_file_len = sizeof (bp->boot_file);
+ }
+
+ if (bp->server_ip)
+ {
+ grub_snprintf (server_ip, sizeof (server_ip), "%d.%d.%d.%d",
+ ((grub_uint8_t *) &bp->server_ip)[0],
+ ((grub_uint8_t *) &bp->server_ip)[1],
+ ((grub_uint8_t *) &bp->server_ip)[2],
+ ((grub_uint8_t *) &bp->server_ip)[3]);
+ grub_env_set_net_property (name, "next_server", server_ip, sizeof (server_ip));
+ grub_print_error ();
+ }
+
+ if (is_def)
+ grub_net_default_server = 0;
+ if (is_def && !grub_net_default_server && bp->server_ip)
+ {
+ grub_net_default_server = grub_strdup (server_ip);
+ grub_print_error ();
+ }
+
+ if (is_def)
+ {
+ grub_env_set ("net_default_interface", name);
+ grub_env_export ("net_default_interface");
+ }
+
+ if (device && !*device && bp->server_ip)
+ {
+ *device = grub_xasprintf ("tftp,%s", server_ip);
+ grub_print_error ();
+ }
+
+ if (server_name)
+ {
+ grub_env_set_net_property (name, "dhcp_server_name", server_name, server_name_len);
+ if (is_def && !grub_net_default_server)
+ {
+ grub_net_default_server = grub_strdup (server_name);
+ grub_print_error ();
+ }
+ if (device && !*device)
+ {
+ *device = grub_xasprintf ("tftp,%s", server_name);
+ grub_print_error ();
+ }
+ }
+
+ if (boot_file)
+ {
+ grub_env_set_net_property (name, "boot_file", boot_file, boot_file_len);
+ if (path)
+ {
+ *path = grub_strndup (boot_file, boot_file_len);
+ grub_print_error ();
+ if (*path)
+ {
+ char *slash;
+ slash = grub_strrchr (*path, '/');
+ if (slash)
+ *slash = 0;
+ else
+ **path = 0;
+ }
+ }
+ }
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_NETMASK, &opt_len);
+ if (opt && opt_len == 4)
+ {
+ int i;
+ for (i = 0; i < 32; i++)
+ if (!(opt[i / 8] & (1 << (7 - (i % 8)))))
+ break;
+ mask = i;
+ }
+ grub_net_add_ipv4_local (inter, mask);
+
+ /* We do not implement dead gateway detection and the first entry SHOULD
+ be preferred one */
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_ROUTER, &opt_len);
+ if (opt && opt_len && !(opt_len & 3))
+ {
+ grub_net_network_level_netaddress_t target;
+ grub_net_network_level_address_t gw;
+ char *rname;
+
+ target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ target.ipv4.base = 0;
+ target.ipv4.masksize = 0;
+ gw.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ gw.ipv4 = grub_get_unaligned32 (opt);
+ rname = grub_xasprintf ("%s:default", name);
+ if (rname)
+ grub_net_add_route_gw (rname, target, gw, 0);
+ grub_free (rname);
+ }
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_DNS, &opt_len);
+ if (opt && opt_len && !(opt_len & 3))
+ {
+ int i;
+ for (i = 0; i < opt_len / 4; i++)
+ {
+ struct grub_net_network_level_address s;
+
+ s.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ s.ipv4 = grub_get_unaligned32 (opt);
+ s.option = DNS_OPTION_PREFER_IPV4;
+ grub_net_add_dns_server (&s);
+ opt += 4;
+ }
+ }
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_HOSTNAME, &opt_len);
+ if (opt && opt_len)
+ grub_env_set_net_property (name, "hostname", (const char *) opt, opt_len);
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_DOMAIN, &opt_len);
+ if (opt && opt_len)
+ grub_env_set_net_property (name, "domain", (const char *) opt, opt_len);
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_ROOT_PATH, &opt_len);
+ if (opt && opt_len)
+ grub_env_set_net_property (name, "rootpath", (const char *) opt, opt_len);
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_EXTENSIONS_PATH, &opt_len);
+ if (opt && opt_len)
+ grub_env_set_net_property (name, "extensionspath", (const char *) opt, opt_len);
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_CLIENT_ID, &opt_len);
+ if (opt && opt_len)
+ grub_env_set_net_property (name, "clientid", (const char *) opt, opt_len);
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_CLIENT_UUID, &opt_len);
+ if (opt && opt_len == 17)
+ {
+ /* The format is 9cfe245e-d0c8-bd45-a79f-54ea5fbd3d97 */
+ char *val;
+ int i, j = 0;
+
+ opt += 1;
+ opt_len -= 1;
+
+ val = grub_malloc (2 * opt_len + 4 + 1);
+ if (!val)
+ return inter;
+
+ for (i = 0; i < opt_len; i++)
+ {
+ val[2 * i + j] = hexdigit (opt[i] >> 4);
+ val[2 * i + 1 + j] = hexdigit (opt[i] & 0xf);
+
+ if ((i == 3) || (i == 5) || (i == 7) || (i == 9))
+ {
+ j++;
+ val[2 * i + 1+ j] = '-';
+ }
+ }
+ grub_env_set_net_property (name, "clientuuid", (char *) val, 2 * opt_len + 4);
+ grub_free (val);
+ }
+
+ inter->dhcp_ack = grub_malloc (size);
+ if (inter->dhcp_ack)
+ {
+ grub_memcpy (inter->dhcp_ack, bp, size);
+ inter->dhcp_acklen = size;
+ }
+ else
+ grub_errno = GRUB_ERR_NONE;
+
+ return inter;
+}
+
+static grub_err_t
+send_dhcp_packet (struct grub_net_network_level_interface *iface)
+{
+ grub_err_t err;
+ struct grub_net_bootp_packet *pack;
+ struct grub_datetime date;
+ grub_int64_t t = 0;
+ struct grub_net_buff *nb;
+ struct udphdr *udph;
+ grub_net_network_level_address_t target;
+ grub_net_link_level_address_t ll_target;
+
+ static struct grub_dhcp_discover_options discover_options =
+ {
+ {
+ GRUB_NET_BOOTP_RFC1048_MAGIC_0,
+ GRUB_NET_BOOTP_RFC1048_MAGIC_1,
+ GRUB_NET_BOOTP_RFC1048_MAGIC_2,
+ GRUB_NET_BOOTP_RFC1048_MAGIC_3,
+ },
+ {
+ GRUB_NET_DHCP_MESSAGE_TYPE,
+ sizeof (discover_options.message_type.data),
+ GRUB_DHCP_MESSAGE_DISCOVER,
+ },
+ GRUB_NET_BOOTP_END,
+ };
+
+ static struct grub_dhcp_request_options request_options =
+ {
+ {
+ GRUB_NET_BOOTP_RFC1048_MAGIC_0,
+ GRUB_NET_BOOTP_RFC1048_MAGIC_1,
+ GRUB_NET_BOOTP_RFC1048_MAGIC_2,
+ GRUB_NET_BOOTP_RFC1048_MAGIC_3,
+ },
+ {
+ GRUB_NET_DHCP_MESSAGE_TYPE,
+ sizeof (request_options.message_type.data),
+ GRUB_DHCP_MESSAGE_REQUEST,
+ },
+ {
+ GRUB_NET_DHCP_SERVER_IDENTIFIER,
+ sizeof (request_options.server_identifier.data),
+ 0,
+ },
+ {
+ GRUB_NET_DHCP_REQUESTED_IP_ADDRESS,
+ sizeof (request_options.requested_ip.data),
+ 0,
+ },
+ {
+ GRUB_NET_DHCP_PARAMETER_REQUEST_LIST,
+ sizeof (request_options.parameter_request.data),
+ {
+ GRUB_NET_BOOTP_NETMASK,
+ GRUB_NET_BOOTP_ROUTER,
+ GRUB_NET_BOOTP_DNS,
+ GRUB_NET_BOOTP_DOMAIN,
+ GRUB_NET_BOOTP_HOSTNAME,
+ GRUB_NET_BOOTP_ROOT_PATH,
+ GRUB_NET_BOOTP_EXTENSIONS_PATH,
+ },
+ },
+ GRUB_NET_BOOTP_END,
+ };
+
+ COMPILE_TIME_ASSERT (sizeof (discover_options) <= GRUB_BOOTP_MAX_OPTIONS_SIZE);
+ COMPILE_TIME_ASSERT (sizeof (request_options) <= GRUB_BOOTP_MAX_OPTIONS_SIZE);
+
+ nb = grub_netbuff_alloc (sizeof (*pack) + GRUB_BOOTP_MAX_OPTIONS_SIZE + 128);
+ if (!nb)
+ return grub_errno;
+
+ err = grub_netbuff_reserve (nb, sizeof (*pack) + GRUB_BOOTP_MAX_OPTIONS_SIZE + 128);
+ if (err)
+ goto out;
+
+ err = grub_netbuff_push (nb, GRUB_BOOTP_MAX_OPTIONS_SIZE);
+ if (err)
+ goto out;
+
+ grub_memset (nb->data, 0, GRUB_BOOTP_MAX_OPTIONS_SIZE);
+ if (!iface->srv_id)
+ {
+ grub_memcpy (nb->data, &discover_options, sizeof (discover_options));
+ }
+ else
+ {
+ struct grub_dhcp_request_options *ro = (struct grub_dhcp_request_options *) nb->data;
+
+ grub_memcpy (nb->data, &request_options, sizeof (request_options));
+ /* my_ip and srv_id are stored in network order so do not need conversion. */
+ grub_set_unaligned32 (&ro->server_identifier.data, iface->srv_id);
+ grub_set_unaligned32 (&ro->requested_ip.data, iface->my_ip);
+ }
+
+ err = grub_netbuff_push (nb, sizeof (*pack));
+ if (err)
+ goto out;
+
+ pack = (void *) nb->data;
+ grub_memset (pack, 0, sizeof (*pack));
+ pack->opcode = 1;
+ pack->hw_type = 1;
+ pack->hw_len = 6;
+ err = grub_get_datetime (&date);
+ if (err || !grub_datetime2unixtime (&date, &t))
+ {
+ grub_errno = GRUB_ERR_NONE;
+ t = 0;
+ }
+ pack->seconds = grub_cpu_to_be16 (t);
+ if (!iface->srv_id)
+ iface->xid = pack->ident = grub_cpu_to_be32 (t);
+ else
+ pack->ident = iface->xid;
+
+ grub_memcpy (&pack->mac_addr, &iface->hwaddress.mac, 6);
+
+ grub_netbuff_push (nb, sizeof (*udph));
+
+ udph = (struct udphdr *) nb->data;
+ 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;
+ target.ipv4 = 0xffffffff;
+ err = grub_net_link_layer_resolve (iface, &target, &ll_target);
+ if (err)
+ goto out;
+
+ udph->chksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_UDP,
+ &iface->address,
+ &target);
+
+ err = grub_net_send_ip_packet (iface, &target, &ll_target, nb,
+ GRUB_NET_IP_UDP);
+
+out:
+ grub_netbuff_free (nb);
+ return err;
+}
+
+/*
+ * This is called directly from net/ip.c:handle_dgram(), because those
+ * BOOTP/DHCP packets are a bit special due to their improper
+ * sender/receiver IP fields.
+ */
+void
+grub_net_process_dhcp (struct grub_net_buff *nb,
+ struct grub_net_network_level_interface *iface)
+{
+ char *name;
+ struct grub_net_card *card = iface->card;
+ const struct grub_net_bootp_packet *bp = (const struct grub_net_bootp_packet *) nb->data;
+ grub_size_t size = nb->tail - nb->data;
+ const grub_uint8_t *opt;
+ grub_uint8_t opt_len, type;
+ grub_uint32_t srv_id = 0;
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_MESSAGE_TYPE, &opt_len);
+ if (opt && opt_len == 1)
+ type = *opt;
+ else
+ type = GRUB_DHCP_MESSAGE_UNKNOWN;
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_SERVER_IDENTIFIER, &opt_len);
+ if (opt && opt_len == sizeof (srv_id))
+ srv_id = grub_get_unaligned32 (opt);
+
+ /*
+ * If we received BOOTP reply or DHCPACK, proceed with configuration.
+ * Otherwise store offered address and server id for later processing
+ * of DHCPACK.
+ * xid and srv_id are stored in network order so do not need conversion.
+ */
+ if ((!iface->srv_id && type == GRUB_DHCP_MESSAGE_UNKNOWN)
+ || (iface->srv_id && type == GRUB_DHCP_MESSAGE_ACK
+ && bp->ident == iface->xid
+ && srv_id == iface->srv_id))
+ {
+ name = grub_xasprintf ("%s:dhcp", card->name);
+ if (!name)
+ {
+ grub_print_error ();
+ return;
+ }
+ grub_net_configure_by_dhcp_ack (name, card, 0, bp, size, 0, 0, 0);
+ grub_free (name);
+ if (grub_errno)
+ grub_print_error ();
+ else
+ grub_net_network_level_interface_unregister (iface);
+ }
+ else if (!iface->srv_id && type == GRUB_DHCP_MESSAGE_OFFER && srv_id)
+ {
+ iface->srv_id = srv_id;
+ iface->my_ip = bp->your_ip;
+ /* Reset retransmission timer */
+ iface->dhcp_tmo = iface->dhcp_tmo_left = 1;
+ }
+ else if (iface->srv_id && type == GRUB_DHCP_MESSAGE_NAK
+ && bp->ident == iface->xid
+ && srv_id == iface->srv_id)
+ {
+ iface->xid = iface->srv_id = iface->my_ip = 0;
+ /* Reset retransmission timer */
+ iface->dhcp_tmo = iface->dhcp_tmo_left = 1;
+ }
+}
+
+static grub_err_t
+grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_net_network_level_interface *inter;
+ unsigned num;
+ const grub_uint8_t *ptr;
+ grub_uint8_t taglength;
+
+ if (argc < 4)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("four arguments expected"));
+
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inter)
+ if (grub_strcmp (inter->name, args[1]) == 0)
+ break;
+
+ if (!inter)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unrecognised network interface `%s'"), args[1]);
+
+ if (!inter->dhcp_ack)
+ return grub_error (GRUB_ERR_IO, N_("no DHCP info found"));
+
+ ptr = inter->dhcp_ack->vendor;
+
+ /* This duplicates check in find_dhcp_option to preserve previous error return */
+ if (inter->dhcp_acklen < OFFSET_OF (vendor, inter->dhcp_ack) + sizeof (grub_uint32_t)
+ || ptr[0] != GRUB_NET_BOOTP_RFC1048_MAGIC_0
+ || ptr[1] != GRUB_NET_BOOTP_RFC1048_MAGIC_1
+ || ptr[2] != GRUB_NET_BOOTP_RFC1048_MAGIC_2
+ || ptr[3] != GRUB_NET_BOOTP_RFC1048_MAGIC_3)
+ return grub_error (GRUB_ERR_IO, N_("no DHCP options found"));
+
+ num = grub_strtoul (args[2], 0, 0);
+ if (grub_errno)
+ return grub_errno;
+
+ /* Exclude PAD (0) and END (255) option codes */
+ if (num == 0 || num > 254)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid DHCP option code"));
+
+ ptr = find_dhcp_option (inter->dhcp_ack, inter->dhcp_acklen, num, &taglength);
+ if (!ptr)
+ return grub_error (GRUB_ERR_IO, N_("no DHCP option %u found"), num);
+
+ 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;
+ grub_memcpy (val, ptr, taglength);
+ val[taglength] = 0;
+ if (args[0][0] == '-' && args[0][1] == 0)
+ grub_printf ("%s\n", val);
+ else
+ err = grub_env_set (args[0], val);
+ grub_free (val);
+ return err;
+ }
+
+ if (grub_strcmp (args[3], "number") == 0)
+ {
+ grub_uint64_t val = 0;
+ int i;
+ for (i = 0; i < taglength; i++)
+ val = (val << 8) | ptr[i];
+ if (args[0][0] == '-' && args[0][1] == 0)
+ grub_printf ("%llu\n", (unsigned long long) val);
+ else
+ {
+ char valn[64];
+ grub_snprintf (valn, sizeof (valn), "%lld\n", (unsigned long long) val);
+ return grub_env_set (args[0], valn);
+ }
+ return GRUB_ERR_NONE;
+ }
+
+ 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)
+ return grub_errno;
+ for (i = 0; i < taglength; i++)
+ {
+ val[2 * i] = hexdigit (ptr[i] >> 4);
+ val[2 * i + 1] = hexdigit (ptr[i] & 0xf);
+ }
+ val[2 * taglength] = 0;
+ if (args[0][0] == '-' && args[0][1] == 0)
+ grub_printf ("%s\n", val);
+ else
+ err = grub_env_set (args[0], val);
+ grub_free (val);
+ return err;
+ }
+
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unrecognised DHCP option format specification `%s'"),
+ args[3]);
+}
+
+/* FIXME: allow to specify mac address. */
+static grub_err_t
+grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_net_card *card;
+ struct grub_net_network_level_interface *ifaces;
+ grub_size_t ncards = 0;
+ unsigned j = 0;
+ grub_err_t err;
+ unsigned i;
+
+ FOR_NET_CARDS (card)
+ {
+ if (argc > 0 && grub_strcmp (card->name, args[0]) != 0)
+ continue;
+ ncards++;
+ }
+
+ if (ncards == 0)
+ return grub_error (GRUB_ERR_NET_NO_CARD, N_("no network card found"));
+
+ ifaces = grub_calloc (ncards, sizeof (ifaces[0]));
+ if (!ifaces)
+ return grub_errno;
+
+ j = 0;
+ FOR_NET_CARDS (card)
+ {
+ if (argc > 0 && grub_strcmp (card->name, args[0]) != 0)
+ continue;
+ ifaces[j].card = card;
+ ifaces[j].next = &ifaces[j+1];
+ if (j)
+ ifaces[j].prev = &ifaces[j-1].next;
+ ifaces[j].name = grub_xasprintf ("%s:dhcp_tmp", card->name);
+ card->num_ifaces++;
+ if (!ifaces[j].name)
+ {
+ for (i = 0; i < j; i++)
+ grub_free (ifaces[i].name);
+ grub_free (ifaces);
+ return grub_errno;
+ }
+ ifaces[j].address.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV;
+ grub_memcpy (&ifaces[j].hwaddress, &card->default_address,
+ sizeof (ifaces[j].hwaddress));
+ ifaces[j].dhcp_tmo = ifaces[j].dhcp_tmo_left = 1;
+ j++;
+ }
+ ifaces[ncards - 1].next = grub_net_network_level_interfaces;
+ if (grub_net_network_level_interfaces)
+ grub_net_network_level_interfaces->prev = & ifaces[ncards - 1].next;
+ grub_net_network_level_interfaces = &ifaces[0];
+ ifaces[0].prev = &grub_net_network_level_interfaces;
+
+ /*
+ * Running DHCP restransmission timer is kept per interface in dhcp_tmo_left.
+ * When it runs off, dhcp_tmo is increased exponentionally and dhcp_tmo_left
+ * initialized to it. Max value is 32 which gives approximately 12s total per
+ * packet timeout assuming 200ms poll tick. Timeout is reset when DHCP OFFER
+ * is received, so total timeout is 25s in the worst case.
+ *
+ * DHCP NAK also resets timer and transaction starts again.
+ *
+ * Total wait time is limited to ~25s to prevent endless loop in case of
+ * permanent NAK
+ */
+ for (i = 0; i < GRUB_DHCP_MAX_PACKET_TIMEOUT * 4; i++)
+ {
+ int need_poll = 0;
+ for (j = 0; j < ncards; j++)
+ {
+ if (!ifaces[j].prev ||
+ ifaces[j].dhcp_tmo > GRUB_DHCP_MAX_PACKET_TIMEOUT)
+ continue;
+
+ if (--ifaces[j].dhcp_tmo_left)
+ {
+ need_poll = 1;
+ continue;
+ }
+
+ ifaces[j].dhcp_tmo *= 2;
+ if (ifaces[j].dhcp_tmo > GRUB_DHCP_MAX_PACKET_TIMEOUT)
+ continue;
+
+ err = send_dhcp_packet (&ifaces[j]);
+ if (err)
+ {
+ grub_print_error ();
+ /* To ignore it during next poll */
+ ifaces[j].dhcp_tmo = GRUB_DHCP_MAX_PACKET_TIMEOUT + 1;
+ continue;
+ }
+ ifaces[j].dhcp_tmo_left = ifaces[j].dhcp_tmo;
+ need_poll = 1;
+ }
+ if (!need_poll)
+ break;
+ grub_net_poll_cards (200, 0);
+ }
+
+ err = GRUB_ERR_NONE;
+ for (j = 0; j < ncards; j++)
+ {
+ grub_free (ifaces[j].name);
+ if (!ifaces[j].prev)
+ continue;
+ grub_error_push ();
+ grub_net_network_level_interface_unregister (&ifaces[j]);
+ err = grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ N_("couldn't autoconfigure %s"),
+ ifaces[j].card->name);
+ }
+
+ grub_free (ifaces);
+ return err;
+}
+
+static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp;
+
+void
+grub_bootp_init (void)
+{
+ cmd_bootp = grub_register_command ("net_bootp", grub_cmd_bootp,
+ N_("[CARD]"),
+ N_("perform a bootp autoconfiguration"));
+ cmd_dhcp = grub_register_command ("net_dhcp", grub_cmd_bootp,
+ N_("[CARD]"),
+ N_("perform a DHCP autoconfiguration"));
+ cmd_getdhcp = grub_register_command ("net_get_dhcp_option", grub_cmd_dhcpopt,
+ N_("VAR INTERFACE NUMBER DESCRIPTION"),
+ N_("retrieve DHCP option and save it into VAR. If VAR is - then print the value."));
+}
+
+void
+grub_bootp_fini (void)
+{
+ grub_unregister_command (cmd_getdhcp);
+ grub_unregister_command (cmd_bootp);
+ grub_unregister_command (cmd_dhcp);
+}
diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c
new file mode 100644
index 0000000..906ec7d
--- /dev/null
+++ b/grub-core/net/dns.c
@@ -0,0 +1,785 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net.h>
+#include <grub/net/udp.h>
+#include <grub/command.h>
+#include <grub/i18n.h>
+#include <grub/err.h>
+#include <grub/time.h>
+#include <grub/safemath.h>
+
+struct dns_cache_element
+{
+ char *name;
+ grub_size_t naddresses;
+ struct grub_net_network_level_address *addresses;
+ grub_uint64_t limit_time;
+};
+
+#define DNS_CACHE_SIZE 1021
+#define DNS_HASH_BASE 423
+
+typedef enum grub_dns_qtype_id
+ {
+ GRUB_DNS_QTYPE_A = 1,
+ GRUB_DNS_QTYPE_AAAA = 28
+ } grub_dns_qtype_id_t;
+
+static struct dns_cache_element dns_cache[DNS_CACHE_SIZE];
+static struct grub_net_network_level_address *dns_servers;
+static grub_size_t dns_nservers, dns_servers_alloc;
+
+grub_err_t
+grub_net_add_dns_server (const struct grub_net_network_level_address *s)
+{
+ if (dns_servers_alloc <= dns_nservers)
+ {
+ int na = dns_servers_alloc * 2;
+ struct grub_net_network_level_address *ns;
+ grub_size_t sz;
+
+ if (na < 8)
+ na = 8;
+
+ if (grub_mul (na, sizeof (ns[0]), &sz))
+ return GRUB_ERR_OUT_OF_RANGE;
+
+ ns = grub_realloc (dns_servers, sz);
+ if (!ns)
+ return grub_errno;
+ dns_servers_alloc = na;
+ dns_servers = ns;
+ }
+ dns_servers[dns_nservers++] = *s;
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_net_remove_dns_server (const struct grub_net_network_level_address *s)
+{
+ grub_size_t i;
+ for (i = 0; i < dns_nservers; i++)
+ if (grub_net_addr_cmp (s, &dns_servers[i]) == 0)
+ break;
+ if (i < dns_nservers)
+ {
+ dns_servers[i] = dns_servers[dns_nservers - 1];
+ dns_nservers--;
+ }
+}
+
+struct dns_header
+{
+ grub_uint16_t id;
+ grub_uint8_t flags;
+ grub_uint8_t ra_z_r_code;
+ grub_uint16_t qdcount;
+ grub_uint16_t ancount;
+ grub_uint16_t nscount;
+ grub_uint16_t arcount;
+} GRUB_PACKED;
+
+enum
+ {
+ FLAGS_RESPONSE = 0x80,
+ FLAGS_OPCODE = 0x78,
+ FLAGS_RD = 0x01
+ };
+
+enum
+ {
+ ERRCODE_MASK = 0x0f
+ };
+
+enum
+ {
+ DNS_PORT = 53
+ };
+
+struct recv_data
+{
+ grub_size_t *naddresses;
+ struct grub_net_network_level_address **addresses;
+ int cache;
+ grub_uint16_t id;
+ int dns_err;
+ char *name;
+ const char *oname;
+ int stop;
+};
+
+static inline int
+hash (const char *str)
+{
+ unsigned v = 0, xn = 1;
+ const char *ptr;
+ for (ptr = str; *ptr; )
+ {
+ v = (v + xn * *ptr);
+ xn = (DNS_HASH_BASE * xn) % DNS_CACHE_SIZE;
+ ptr++;
+ if (((ptr - str) & 0x3ff) == 0)
+ v %= DNS_CACHE_SIZE;
+ }
+ return v % DNS_CACHE_SIZE;
+}
+
+static int
+check_name_real (const grub_uint8_t *name_at, const grub_uint8_t *head,
+ const grub_uint8_t *tail, const char *check_with,
+ int *length, char *set)
+{
+ const char *readable_ptr = check_with;
+ const grub_uint8_t *ptr;
+ char *optr = set;
+ int bytes_processed = 0;
+ if (length)
+ *length = 0;
+ for (ptr = name_at; ptr < tail && bytes_processed < tail - head + 2; )
+ {
+ /* End marker. */
+ if (!*ptr)
+ {
+ if (length && *length)
+ (*length)--;
+ if (optr && optr != set)
+ optr--;
+ if (optr)
+ *optr = 0;
+ return !readable_ptr || (*readable_ptr == 0);
+ }
+ if (*ptr & 0xc0)
+ {
+ bytes_processed += 2;
+ if (ptr + 1 >= tail)
+ return 0;
+ ptr = head + (((ptr[0] & 0x3f) << 8) | ptr[1]);
+ continue;
+ }
+ if (readable_ptr && grub_memcmp (ptr + 1, readable_ptr, *ptr) != 0)
+ return 0;
+ if (grub_memchr (ptr + 1, 0, *ptr)
+ || grub_memchr (ptr + 1, '.', *ptr))
+ return 0;
+ if (readable_ptr)
+ readable_ptr += *ptr;
+ if (readable_ptr && *readable_ptr != '.' && *readable_ptr != 0)
+ return 0;
+ bytes_processed += *ptr + 1;
+ if (length)
+ *length += *ptr + 1;
+ if (optr)
+ {
+ grub_memcpy (optr, ptr + 1, *ptr);
+ optr += *ptr;
+ }
+ if (optr)
+ *optr++ = '.';
+ if (readable_ptr && *readable_ptr)
+ readable_ptr++;
+ ptr += *ptr + 1;
+ }
+ return 0;
+}
+
+static int
+check_name (const grub_uint8_t *name_at, const grub_uint8_t *head,
+ const grub_uint8_t *tail, const char *check_with)
+{
+ return check_name_real (name_at, head, tail, check_with, NULL, NULL);
+}
+
+static char *
+get_name (const grub_uint8_t *name_at, const grub_uint8_t *head,
+ const grub_uint8_t *tail)
+{
+ int length;
+ char *ret;
+
+ if (!check_name_real (name_at, head, tail, NULL, &length, NULL))
+ return NULL;
+ ret = grub_malloc (length + 1);
+ if (!ret)
+ return NULL;
+ if (!check_name_real (name_at, head, tail, NULL, NULL, ret))
+ {
+ grub_free (ret);
+ return NULL;
+ }
+ return ret;
+}
+
+enum
+ {
+ DNS_CLASS_A = 1,
+ DNS_CLASS_CNAME = 5,
+ DNS_CLASS_AAAA = 28
+ };
+
+static grub_err_t
+recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
+ struct grub_net_buff *nb,
+ void *data_)
+{
+ struct dns_header *head;
+ struct recv_data *data = data_;
+ int i, j;
+ grub_uint8_t *ptr, *reparse_ptr;
+ int redirect_cnt = 0;
+ char *redirect_save = NULL;
+ grub_uint32_t ttl_all = ~0U;
+
+ /* Code apparently assumed that only one packet is received as response.
+ We may get multiple responses due to network condition, so check here
+ and quit early. */
+ if (*data->addresses)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ head = (struct dns_header *) nb->data;
+ ptr = (grub_uint8_t *) (head + 1);
+ if (ptr >= nb->tail)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ if (head->id != data->id)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ if (!(head->flags & FLAGS_RESPONSE) || (head->flags & FLAGS_OPCODE))
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ if (head->ra_z_r_code & ERRCODE_MASK)
+ {
+ data->dns_err = 1;
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ for (i = 0; i < grub_be_to_cpu16 (head->qdcount); i++)
+ {
+ if (ptr >= nb->tail)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ while (ptr < nb->tail && !((*ptr & 0xc0) || *ptr == 0))
+ ptr += *ptr + 1;
+ if (ptr < nb->tail && (*ptr & 0xc0))
+ ptr++;
+ ptr++;
+ ptr += 4;
+ }
+ *data->addresses = grub_calloc (grub_be_to_cpu16 (head->ancount),
+ sizeof ((*data->addresses)[0]));
+ if (!*data->addresses)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ reparse_ptr = ptr;
+ reparse:
+ for (i = 0, ptr = reparse_ptr; i < grub_be_to_cpu16 (head->ancount); i++)
+ {
+ int ignored = 0;
+ grub_uint8_t class;
+ grub_uint32_t ttl = 0;
+ grub_uint16_t length;
+ if (ptr >= nb->tail)
+ {
+ if (!*data->naddresses)
+ grub_free (*data->addresses);
+ return GRUB_ERR_NONE;
+ }
+ ignored = !check_name (ptr, nb->data, nb->tail, data->name);
+ while (ptr < nb->tail && !((*ptr & 0xc0) || *ptr == 0))
+ ptr += *ptr + 1;
+ if (ptr < nb->tail && (*ptr & 0xc0))
+ ptr++;
+ ptr++;
+ if (ptr + 10 >= nb->tail)
+ {
+ if (!*data->naddresses)
+ grub_free (*data->addresses);
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ if (*ptr++ != 0)
+ ignored = 1;
+ class = *ptr++;
+ if (*ptr++ != 0)
+ ignored = 1;
+ if (*ptr++ != 1)
+ ignored = 1;
+ for (j = 0; j < 4; j++)
+ {
+ ttl <<= 8;
+ ttl |= *ptr++;
+ }
+ length = *ptr++ << 8;
+ length |= *ptr++;
+ if (ptr + length > nb->tail)
+ {
+ if (!*data->naddresses)
+ grub_free (*data->addresses);
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ if (!ignored)
+ {
+ if (ttl_all > ttl)
+ ttl_all = ttl;
+ switch (class)
+ {
+ case DNS_CLASS_A:
+ if (length != 4)
+ break;
+ (*data->addresses)[*data->naddresses].type
+ = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ grub_memcpy (&(*data->addresses)[*data->naddresses].ipv4,
+ ptr, 4);
+ (*data->naddresses)++;
+ data->stop = 1;
+ break;
+ case DNS_CLASS_AAAA:
+ if (length != 16)
+ break;
+ (*data->addresses)[*data->naddresses].type
+ = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ grub_memcpy (&(*data->addresses)[*data->naddresses].ipv6,
+ ptr, 16);
+ (*data->naddresses)++;
+ data->stop = 1;
+ break;
+ case DNS_CLASS_CNAME:
+ if (!(redirect_cnt & (redirect_cnt - 1)))
+ {
+ grub_free (redirect_save);
+ redirect_save = data->name;
+ }
+ else
+ grub_free (data->name);
+ redirect_cnt++;
+ data->name = get_name (ptr, nb->data, nb->tail);
+ if (!data->name)
+ {
+ data->dns_err = 1;
+ grub_errno = 0;
+ return GRUB_ERR_NONE;
+ }
+ grub_dprintf ("dns", "CNAME %s\n", data->name);
+ if (grub_strcmp (redirect_save, data->name) == 0)
+ {
+ data->dns_err = 1;
+ grub_free (redirect_save);
+ return GRUB_ERR_NONE;
+ }
+ goto reparse;
+ }
+ }
+ ptr += length;
+ }
+ if (ttl_all && *data->naddresses && data->cache)
+ {
+ int h;
+ grub_dprintf ("dns", "caching for %d seconds\n", ttl_all);
+ h = hash (data->oname);
+ grub_free (dns_cache[h].name);
+ dns_cache[h].name = 0;
+ grub_free (dns_cache[h].addresses);
+ dns_cache[h].addresses = 0;
+ dns_cache[h].name = grub_strdup (data->oname);
+ dns_cache[h].naddresses = *data->naddresses;
+ dns_cache[h].addresses = grub_calloc (*data->naddresses,
+ sizeof (dns_cache[h].addresses[0]));
+ dns_cache[h].limit_time = grub_get_time_ms () + 1000 * ttl_all;
+ if (!dns_cache[h].addresses || !dns_cache[h].name)
+ {
+ grub_free (dns_cache[h].name);
+ dns_cache[h].name = 0;
+ grub_free (dns_cache[h].addresses);
+ dns_cache[h].addresses = 0;
+ }
+ grub_memcpy (dns_cache[h].addresses, *data->addresses,
+ *data->naddresses
+ * sizeof (dns_cache[h].addresses[0]));
+ }
+ grub_netbuff_free (nb);
+ grub_free (redirect_save);
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_net_dns_lookup (const char *name,
+ const struct grub_net_network_level_address *servers,
+ grub_size_t n_servers,
+ grub_size_t *naddresses,
+ struct grub_net_network_level_address **addresses,
+ int cache)
+{
+ grub_size_t send_servers = 0;
+ grub_size_t i, j;
+ struct grub_net_buff *nb;
+ grub_net_udp_socket_t *sockets;
+ grub_uint8_t *optr;
+ const char *iptr;
+ struct dns_header *head;
+ static grub_uint16_t id = 1;
+ grub_uint8_t *qtypeptr;
+ grub_err_t err = GRUB_ERR_NONE;
+ struct recv_data data = {naddresses, addresses, cache,
+ grub_cpu_to_be16 (id++), 0, 0, name, 0};
+ grub_uint8_t *nbd;
+ grub_size_t try_server = 0;
+
+ if (!servers)
+ {
+ servers = dns_servers;
+ n_servers = dns_nservers;
+ }
+
+ if (!n_servers)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("no DNS servers configured"));
+
+ *naddresses = 0;
+ if (cache)
+ {
+ int h;
+ h = hash (name);
+ if (dns_cache[h].name && grub_strcmp (dns_cache[h].name, name) == 0
+ && grub_get_time_ms () < dns_cache[h].limit_time)
+ {
+ grub_dprintf ("dns", "retrieved from cache\n");
+ *addresses = grub_malloc (dns_cache[h].naddresses
+ * sizeof ((*addresses)[0]));
+ if (!*addresses)
+ return grub_errno;
+ *naddresses = dns_cache[h].naddresses;
+ grub_memcpy (*addresses, dns_cache[h].addresses,
+ dns_cache[h].naddresses
+ * sizeof ((*addresses)[0]));
+ return GRUB_ERR_NONE;
+ }
+ }
+
+ sockets = grub_calloc (n_servers, sizeof (sockets[0]));
+ if (!sockets)
+ return grub_errno;
+
+ data.name = grub_strdup (name);
+ if (!data.name)
+ {
+ grub_free (sockets);
+ return grub_errno;
+ }
+
+ nb = grub_netbuff_alloc (GRUB_NET_OUR_MAX_IP_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE
+ + GRUB_NET_UDP_HEADER_SIZE
+ + sizeof (struct dns_header)
+ + grub_strlen (name) + 2 + 4);
+ if (!nb)
+ {
+ grub_free (sockets);
+ grub_free (data.name);
+ return grub_errno;
+ }
+ grub_netbuff_reserve (nb, GRUB_NET_OUR_MAX_IP_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE
+ + GRUB_NET_UDP_HEADER_SIZE);
+ grub_netbuff_put (nb, sizeof (struct dns_header)
+ + grub_strlen (name) + 2 + 4);
+ head = (struct dns_header *) nb->data;
+ optr = (grub_uint8_t *) (head + 1);
+ for (iptr = name; *iptr; )
+ {
+ const char *dot;
+ dot = grub_strchr (iptr, '.');
+ if (!dot)
+ dot = iptr + grub_strlen (iptr);
+ if ((dot - iptr) >= 64)
+ {
+ grub_free (sockets);
+ grub_free (data.name);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("domain name component is too long"));
+ }
+ *optr = (dot - iptr);
+ optr++;
+ grub_memcpy (optr, iptr, dot - iptr);
+ optr += dot - iptr;
+ iptr = dot;
+ if (*iptr)
+ iptr++;
+ }
+ *optr++ = 0;
+
+ /* Type. */
+ *optr++ = 0;
+ qtypeptr = optr++;
+
+ /* Class. */
+ *optr++ = 0;
+ *optr++ = 1;
+
+ head->id = data.id;
+ head->flags = FLAGS_RD;
+ head->ra_z_r_code = 0;
+ head->qdcount = grub_cpu_to_be16_compile_time (1);
+ head->ancount = grub_cpu_to_be16_compile_time (0);
+ head->nscount = grub_cpu_to_be16_compile_time (0);
+ head->arcount = grub_cpu_to_be16_compile_time (0);
+
+ nbd = nb->data;
+
+ for (i = 0; i < n_servers * 4; i++)
+ {
+ /* Connect to a next server. */
+ while (!(i & 1) && try_server < n_servers)
+ {
+ sockets[send_servers] = grub_net_udp_open (servers[try_server++],
+ DNS_PORT,
+ recv_hook,
+ &data);
+ if (!sockets[send_servers])
+ {
+ err = grub_errno;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ else
+ {
+ send_servers++;
+ break;
+ }
+ }
+ if (!send_servers)
+ goto out;
+ if (*data.naddresses)
+ goto out;
+ for (j = 0; j < send_servers; j++)
+ {
+ grub_err_t err2;
+
+ 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)))
+ *qtypeptr = GRUB_DNS_QTYPE_A;
+ else
+ *qtypeptr = GRUB_DNS_QTYPE_AAAA;
+
+ grub_dprintf ("dns", "QTYPE: %u QNAME: %s\n", *qtypeptr, name);
+
+ err2 = grub_net_send_udp_packet (sockets[j], nb);
+ if (err2)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ err = err2;
+ }
+ if (*data.naddresses)
+ goto out;
+ }
+ while (t == 1);
+ }
+ grub_net_poll_cards (200, &data.stop);
+ }
+ out:
+ grub_free (data.name);
+ grub_netbuff_free (nb);
+ for (j = 0; j < send_servers; j++)
+ grub_net_udp_close (sockets[j]);
+
+ grub_free (sockets);
+
+ if (*data.naddresses)
+ return GRUB_ERR_NONE;
+ if (data.dns_err)
+ return grub_error (GRUB_ERR_NET_NO_DOMAIN,
+ N_("no DNS record found"));
+
+ if (err)
+ {
+ grub_errno = err;
+ return err;
+ }
+ return grub_error (GRUB_ERR_TIMEOUT,
+ N_("no DNS reply received"));
+}
+
+static grub_err_t
+grub_cmd_nslookup (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_err_t err;
+ struct grub_net_network_level_address cmd_server;
+ struct grub_net_network_level_address *servers;
+ grub_size_t nservers, i, naddresses = 0;
+ struct grub_net_network_level_address *addresses = 0;
+ if (argc != 2 && argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+ if (argc == 2)
+ {
+ err = grub_net_resolve_address (args[1], &cmd_server);
+ if (err)
+ return err;
+ servers = &cmd_server;
+ nservers = 1;
+ }
+ else
+ {
+ servers = dns_servers;
+ nservers = dns_nservers;
+ }
+
+ grub_net_dns_lookup (args[0], servers, nservers, &naddresses,
+ &addresses, 0);
+
+ for (i = 0; i < naddresses; i++)
+ {
+ char buf[GRUB_NET_MAX_STR_ADDR_LEN];
+ grub_net_addr_to_str (&addresses[i], buf);
+ grub_printf ("%s\n", buf);
+ }
+ grub_free (addresses);
+ if (naddresses)
+ return GRUB_ERR_NONE;
+ return grub_error (GRUB_ERR_NET_NO_DOMAIN, N_("no DNS record found"));
+}
+
+static grub_err_t
+grub_cmd_list_dns (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_size_t i;
+ const char *strtype = "";
+
+ for (i = 0; i < dns_nservers; i++)
+ {
+ switch (dns_servers[i].option)
+ {
+ case DNS_OPTION_IPV4:
+ strtype = _("only ipv4");
+ break;
+
+ case DNS_OPTION_IPV6:
+ strtype = _("only ipv6");
+ break;
+
+ case DNS_OPTION_PREFER_IPV4:
+ strtype = _("prefer ipv4");
+ break;
+
+ case DNS_OPTION_PREFER_IPV6:
+ strtype = _("prefer ipv6");
+ break;
+ }
+
+ char buf[GRUB_NET_MAX_STR_ADDR_LEN];
+ grub_net_addr_to_str (&dns_servers[i], buf);
+ grub_printf ("%s (%s)\n", buf, strtype);
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_add_dns (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_err_t err;
+ struct grub_net_network_level_address server;
+
+ if ((argc < 1) || (argc > 2))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+ else if (argc == 1)
+ server.option = DNS_OPTION_PREFER_IPV4;
+ else
+ {
+ if (grub_strcmp (args[1], "--only-ipv4") == 0)
+ server.option = DNS_OPTION_IPV4;
+ else if (grub_strcmp (args[1], "--only-ipv6") == 0)
+ server.option = DNS_OPTION_IPV6;
+ else if (grub_strcmp (args[1], "--prefer-ipv4") == 0)
+ server.option = DNS_OPTION_PREFER_IPV4;
+ else if (grub_strcmp (args[1], "--prefer-ipv6") == 0)
+ server.option = DNS_OPTION_PREFER_IPV6;
+ else
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
+ }
+
+ err = grub_net_resolve_address (args[0], &server);
+ if (err)
+ return err;
+
+ return grub_net_add_dns_server (&server);
+}
+
+static grub_err_t
+grub_cmd_del_dns (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_err_t err;
+ struct grub_net_network_level_address server;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+ err = grub_net_resolve_address (args[1], &server);
+ if (err)
+ return err;
+
+ return grub_net_add_dns_server (&server);
+}
+
+static grub_command_t cmd, cmd_add, cmd_del, cmd_list;
+
+void
+grub_dns_init (void)
+{
+ cmd = grub_register_command ("net_nslookup", grub_cmd_nslookup,
+ N_("ADDRESS DNSSERVER"),
+ N_("Perform a DNS lookup"));
+ cmd_add = grub_register_command ("net_add_dns", grub_cmd_add_dns,
+ N_("DNSSERVER"),
+ N_("Add a DNS server"));
+ cmd_del = grub_register_command ("net_del_dns", grub_cmd_del_dns,
+ N_("DNSSERVER"),
+ N_("Remove a DNS server"));
+ cmd_list = grub_register_command ("net_ls_dns", grub_cmd_list_dns,
+ NULL, N_("List DNS servers"));
+}
+
+void
+grub_dns_fini (void)
+{
+ grub_unregister_command (cmd);
+ grub_unregister_command (cmd_add);
+ grub_unregister_command (cmd_del);
+ grub_unregister_command (cmd_list);
+}
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
new file mode 100644
index 0000000..5388f95
--- /dev/null
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -0,0 +1,404 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net/netbuff.h>
+#include <grub/dl.h>
+#include <grub/net.h>
+#include <grub/time.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* GUID. */
+static grub_efi_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID;
+static grub_efi_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID;
+
+static grub_err_t
+send_card_buffer (struct grub_net_card *dev,
+ struct grub_net_buff *pack)
+{
+ 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)
+ {
+ 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"));
+ /*
+ 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 (limit_time < grub_get_time_ms ())
+ return grub_error (GRUB_ERR_TIMEOUT,
+ N_("couldn't send network packet"));
+ }
+
+ dev->last_pkt_size = (pack->tail - pack->data);
+ if (dev->last_pkt_size > dev->mtu)
+ dev->last_pkt_size = dev->mtu;
+
+ grub_memcpy (dev->txbuf, pack->data, dev->last_pkt_size);
+
+ 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"));
+
+ /*
+ 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;
+}
+
+static struct grub_net_buff *
+get_card_packet (struct grub_net_card *dev)
+{
+ grub_efi_simple_network_t *net = dev->efi_net;
+ grub_err_t err;
+ grub_efi_status_t st;
+ grub_efi_uintn_t bufsize = dev->rcvbufsize;
+ struct grub_net_buff *nb;
+ int i;
+
+ for (i = 0; i < 2; i++)
+ {
+ if (!dev->rcvbuf)
+ dev->rcvbuf = grub_malloc (dev->rcvbufsize);
+ if (!dev->rcvbuf)
+ return NULL;
+
+ st = efi_call_7 (net->receive, net, NULL, &bufsize,
+ dev->rcvbuf, NULL, NULL, NULL);
+ if (st != GRUB_EFI_BUFFER_TOO_SMALL)
+ break;
+ dev->rcvbufsize = 2 * ALIGN_UP (dev->rcvbufsize > bufsize
+ ? dev->rcvbufsize : bufsize, 64);
+ grub_free (dev->rcvbuf);
+ dev->rcvbuf = 0;
+ }
+
+ if (st != GRUB_EFI_SUCCESS)
+ return NULL;
+
+ nb = grub_netbuff_alloc (bufsize + 2);
+ if (!nb)
+ 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. */
+ if (grub_netbuff_reserve (nb, 2))
+ {
+ grub_netbuff_free (nb);
+ return NULL;
+ }
+ grub_memcpy (nb->data, dev->rcvbuf, bufsize);
+ err = grub_netbuff_put (nb, bufsize);
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return NULL;
+ }
+
+ 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
+ };
+
+grub_efi_handle_t
+grub_efinet_get_device_handle (struct grub_net_card *card)
+{
+ if (!card || card->driver != &efidriver)
+ return 0;
+ return card->efi_handle;
+}
+
+static void
+grub_efinet_findcards (void)
+{
+ grub_efi_uintn_t num_handles;
+ grub_efi_handle_t *handles;
+ grub_efi_handle_t *handle;
+ int i = 0;
+
+ /* Find handles which support the disk io interface. */
+ handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &net_io_guid,
+ 0, &num_handles);
+ if (! handles)
+ return;
+ for (handle = handles; num_handles--; handle++)
+ {
+ 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);
+ if (! net)
+ /* This should not happen... Why? */
+ continue;
+
+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED
+ && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS)
+ continue;
+
+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED)
+ continue;
+
+ if (net->mode->state == GRUB_EFI_NETWORK_STARTED
+ && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS)
+ continue;
+
+ card = grub_zalloc (sizeof (struct grub_net_card));
+ if (!card)
+ {
+ grub_print_error ();
+ grub_free (handles);
+ return;
+ }
+
+ card->mtu = net->mode->max_packet_size;
+ card->txbufsize = ALIGN_UP (card->mtu, 64) + 256;
+ card->txbuf = grub_zalloc (card->txbufsize);
+ if (!card->txbuf)
+ {
+ grub_print_error ();
+ grub_free (handles);
+ grub_free (card);
+ return;
+ }
+ card->txbusy = 0;
+
+ card->rcvbufsize = ALIGN_UP (card->mtu, 64) + 256;
+
+ card->name = grub_xasprintf ("efinet%d", i++);
+ card->driver = &efidriver;
+ card->flags = 0;
+ card->default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ grub_memcpy (card->default_address.mac,
+ net->mode->current_address,
+ sizeof (card->default_address.mac));
+ card->efi_net = net;
+ card->efi_handle = *handle;
+
+ grub_net_card_register (card);
+ }
+ grub_free (handles);
+}
+
+static void
+grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
+ char **path)
+{
+ struct grub_net_card *card;
+ grub_efi_device_path_t *dp;
+
+ dp = grub_efi_get_device_path (hnd);
+ if (! dp)
+ return;
+
+ FOR_NET_CARDS (card)
+ {
+ grub_efi_device_path_t *cdp;
+ struct grub_efi_pxe *pxe;
+ struct grub_efi_pxe_mode *pxe_mode;
+ if (card->driver != &efidriver)
+ continue;
+ cdp = grub_efi_get_device_path (card->efi_handle);
+ if (! cdp)
+ continue;
+ if (grub_efi_compare_device_paths (dp, cdp) != 0)
+ {
+ 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)
+ continue;
+ pxe_mode = pxe->mode;
+ grub_net_configure_by_dhcp_ack (card->name, card, 0,
+ (struct grub_net_bootp_packet *)
+ &pxe_mode->dhcp_ack,
+ sizeof (pxe_mode->dhcp_ack),
+ 1, device, path);
+ return;
+ }
+}
+
+GRUB_MOD_INIT(efinet)
+{
+ grub_efinet_findcards ();
+ grub_efi_net_config = grub_efi_net_config_real;
+}
+
+GRUB_MOD_FINI(efinet)
+{
+ struct grub_net_card *card, *next;
+
+ FOR_NET_CARDS_SAFE (card, next)
+ if (card->driver == &efidriver)
+ grub_net_card_unregister (card);
+}
+
diff --git a/grub-core/net/drivers/emu/emunet.c b/grub-core/net/drivers/emu/emunet.c
new file mode 100644
index 0000000..b194920
--- /dev/null
+++ b/grub-core/net/drivers/emu/emunet.c
@@ -0,0 +1,116 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011,2012,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/dl.h>
+#include <grub/net/netbuff.h>
+#include <grub/net.h>
+#include <grub/term.h>
+#include <grub/i18n.h>
+#include <grub/emu/net.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+send_card_buffer (struct grub_net_card *dev __attribute__ ((unused)),
+ struct grub_net_buff *pack);
+
+static struct grub_net_buff *
+get_card_packet (struct grub_net_card *dev __attribute__ ((unused)));
+
+static struct grub_net_card_driver emudriver =
+ {
+ .name = "emu",
+ .send = send_card_buffer,
+ .recv = get_card_packet
+ };
+
+static struct grub_net_card emucard =
+ {
+ .name = "emu0",
+ .driver = &emudriver,
+ .mtu = 1500,
+ .default_address = {
+ .type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET,
+ {.mac = {0, 1, 2, 3, 4, 5}}
+ },
+ .flags = 0
+ };
+
+static grub_err_t
+send_card_buffer (struct grub_net_card *dev __attribute__ ((unused)),
+ struct grub_net_buff *pack)
+{
+ grub_ssize_t actual;
+
+ actual = grub_emunet_send (pack->data, pack->tail - pack->data);
+ if (actual < 0)
+ return grub_error (GRUB_ERR_IO, N_("couldn't send network packet"));
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_net_buff *
+get_card_packet (struct grub_net_card *dev __attribute__ ((unused)))
+{
+ grub_ssize_t actual;
+ struct grub_net_buff *nb;
+
+ nb = grub_netbuff_alloc (emucard.mtu + 36 + 2);
+ if (!nb)
+ 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 (nb, 2);
+ if (!nb)
+ {
+ grub_netbuff_free (nb);
+ return NULL;
+ }
+
+ actual = grub_emunet_receive (nb->data, emucard.mtu + 36);
+ if (actual < 0)
+ {
+ grub_netbuff_free (nb);
+ return NULL;
+ }
+ grub_netbuff_put (nb, actual);
+
+ return nb;
+}
+
+static int registered = 0;
+
+GRUB_MOD_INIT(emunet)
+{
+ if (!grub_emunet_create (&emucard.mtu))
+ {
+ grub_net_card_register (&emucard);
+ registered = 1;
+ }
+}
+
+GRUB_MOD_FINI(emunet)
+{
+ if (registered)
+ {
+ grub_emunet_close ();
+ grub_net_card_unregister (&emucard);
+ registered = 0;
+ }
+}
diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/drivers/i386/pc/pxe.c
new file mode 100644
index 0000000..3f4152d
--- /dev/null
+++ b/grub-core/net/drivers/i386/pc/pxe.c
@@ -0,0 +1,419 @@
+/* pxe.c - Driver to provide access to the pxe filesystem */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/net.h>
+#include <grub/mm.h>
+#include <grub/file.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/i18n.h>
+#include <grub/loader.h>
+
+#include <grub/machine/pxe.h>
+#include <grub/machine/int.h>
+#include <grub/machine/memory.h>
+#include <grub/machine/kernel.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define SEGMENT(x) ((x) >> 4)
+#define OFFSET(x) ((x) & 0xF)
+#define SEGOFS(x) ((SEGMENT(x) << 16) + OFFSET(x))
+#define LINEAR(x) (void *) ((((x) >> 16) << 4) + ((x) & 0xFFFF))
+
+struct grub_pxe_undi_open
+{
+ grub_uint16_t status;
+ grub_uint16_t open_flag;
+ grub_uint16_t pkt_filter;
+ grub_uint16_t mcast_count;
+ grub_uint8_t mcast[8][6];
+} GRUB_PACKED;
+
+struct grub_pxe_undi_info
+{
+ grub_uint16_t status;
+ grub_uint16_t base_io;
+ grub_uint16_t int_number;
+ grub_uint16_t mtu;
+ grub_uint16_t hwtype;
+ grub_uint16_t hwaddrlen;
+ grub_uint8_t current_addr[16];
+ grub_uint8_t permanent_addr[16];
+ grub_uint32_t romaddr;
+ grub_uint16_t rxbufct;
+ grub_uint16_t txbufct;
+} GRUB_PACKED;
+
+
+struct grub_pxe_undi_isr
+{
+ grub_uint16_t status;
+ grub_uint16_t func_flag;
+ grub_uint16_t buffer_len;
+ grub_uint16_t frame_len;
+ grub_uint16_t frame_hdr_len;
+ grub_uint32_t buffer;
+ grub_uint8_t prot_type;
+ grub_uint8_t pkt_type;
+} GRUB_PACKED;
+
+enum
+ {
+ GRUB_PXE_ISR_IN_START = 1,
+ GRUB_PXE_ISR_IN_PROCESS,
+ GRUB_PXE_ISR_IN_GET_NEXT
+ };
+
+enum
+ {
+ GRUB_PXE_ISR_OUT_OURS = 0,
+ GRUB_PXE_ISR_OUT_NOT_OURS = 1
+ };
+
+enum
+ {
+ GRUB_PXE_ISR_OUT_DONE = 0,
+ GRUB_PXE_ISR_OUT_TRANSMIT = 2,
+ GRUB_PXE_ISR_OUT_RECEIVE = 3,
+ GRUB_PXE_ISR_OUT_BUSY = 4,
+ };
+
+struct grub_pxe_undi_transmit
+{
+ grub_uint16_t status;
+ grub_uint8_t protocol;
+ grub_uint8_t xmitflag;
+ grub_uint32_t dest;
+ grub_uint32_t tbd;
+ grub_uint32_t reserved[2];
+} GRUB_PACKED;
+
+struct grub_pxe_undi_tbd
+{
+ grub_uint16_t len;
+ grub_uint32_t buf;
+ grub_uint16_t blk_count;
+ struct
+ {
+ grub_uint8_t ptr_type;
+ grub_uint8_t reserved;
+ grub_uint16_t len;
+ grub_uint32_t ptr;
+ } blocks[8];
+} GRUB_PACKED;
+
+struct grub_pxe_bangpxe *grub_pxe_pxenv;
+static grub_uint32_t pxe_rm_entry = 0;
+
+static struct grub_pxe_bangpxe *
+grub_pxe_scan (void)
+{
+ struct grub_bios_int_registers regs;
+ struct grub_pxenv *pxenv;
+ struct grub_pxe_bangpxe *bangpxe;
+
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+
+ regs.ebx = 0;
+ regs.ecx = 0;
+ regs.eax = 0x5650;
+ regs.es = 0;
+
+ grub_bios_interrupt (0x1a, &regs);
+
+ if ((regs.eax & 0xffff) != 0x564e)
+ return NULL;
+
+ pxenv = (struct grub_pxenv *) ((regs.es << 4) + (regs.ebx & 0xffff));
+ if (grub_memcmp (pxenv->signature, GRUB_PXE_SIGNATURE,
+ sizeof (pxenv->signature))
+ != 0)
+ return NULL;
+
+ if (pxenv->version < 0x201)
+ return NULL;
+
+ bangpxe = (void *) ((((pxenv->pxe_ptr & 0xffff0000) >> 16) << 4)
+ + (pxenv->pxe_ptr & 0xffff));
+
+ if (!bangpxe)
+ return NULL;
+
+ if (grub_memcmp (bangpxe->signature, GRUB_PXE_BANGPXE_SIGNATURE,
+ sizeof (bangpxe->signature)) != 0)
+ return NULL;
+
+ pxe_rm_entry = bangpxe->rm_entry;
+
+ return bangpxe;
+}
+
+static struct grub_net_buff *
+grub_pxe_recv (struct grub_net_card *dev __attribute__ ((unused)))
+{
+ struct grub_pxe_undi_isr *isr;
+ static int in_progress = 0;
+ grub_uint8_t *ptr, *end;
+ struct grub_net_buff *buf;
+
+ isr = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+
+ if (!in_progress)
+ {
+ grub_memset (isr, 0, sizeof (*isr));
+ isr->func_flag = GRUB_PXE_ISR_IN_START;
+ grub_pxe_call (GRUB_PXENV_UNDI_ISR, isr, pxe_rm_entry);
+ /* Normally according to the specification we should also check
+ that isr->func_flag != GRUB_PXE_ISR_OUT_OURS but unfortunately it
+ breaks on intel cards.
+ */
+ if (isr->status)
+ {
+ in_progress = 0;
+ return NULL;
+ }
+ grub_memset (isr, 0, sizeof (*isr));
+ isr->func_flag = GRUB_PXE_ISR_IN_PROCESS;
+ grub_pxe_call (GRUB_PXENV_UNDI_ISR, isr, pxe_rm_entry);
+ }
+ else
+ {
+ grub_memset (isr, 0, sizeof (*isr));
+ isr->func_flag = GRUB_PXE_ISR_IN_GET_NEXT;
+ grub_pxe_call (GRUB_PXENV_UNDI_ISR, isr, pxe_rm_entry);
+ }
+
+ while (isr->func_flag != GRUB_PXE_ISR_OUT_RECEIVE)
+ {
+ if (isr->status || isr->func_flag == GRUB_PXE_ISR_OUT_DONE)
+ {
+ in_progress = 0;
+ return NULL;
+ }
+ grub_memset (isr, 0, sizeof (*isr));
+ isr->func_flag = GRUB_PXE_ISR_IN_GET_NEXT;
+ grub_pxe_call (GRUB_PXENV_UNDI_ISR, isr, pxe_rm_entry);
+ }
+
+ buf = grub_netbuff_alloc (isr->frame_len + 2);
+ if (!buf)
+ 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. */
+ if (grub_netbuff_reserve (buf, 2))
+ {
+ grub_netbuff_free (buf);
+ return NULL;
+ }
+ ptr = buf->data;
+ end = ptr + isr->frame_len;
+ grub_netbuff_put (buf, isr->frame_len);
+ grub_memcpy (ptr, LINEAR (isr->buffer), isr->buffer_len);
+ ptr += isr->buffer_len;
+ while (ptr < end)
+ {
+ grub_memset (isr, 0, sizeof (*isr));
+ isr->func_flag = GRUB_PXE_ISR_IN_GET_NEXT;
+ grub_pxe_call (GRUB_PXENV_UNDI_ISR, isr, pxe_rm_entry);
+ if (isr->status || isr->func_flag != GRUB_PXE_ISR_OUT_RECEIVE)
+ {
+ in_progress = 1;
+ grub_netbuff_free (buf);
+ return NULL;
+ }
+
+ grub_memcpy (ptr, LINEAR (isr->buffer), isr->buffer_len);
+ ptr += isr->buffer_len;
+ }
+ in_progress = 1;
+
+ return buf;
+}
+
+static grub_err_t
+grub_pxe_send (struct grub_net_card *dev __attribute__ ((unused)),
+ struct grub_net_buff *pack)
+{
+ struct grub_pxe_undi_transmit *trans;
+ struct grub_pxe_undi_tbd *tbd;
+ char *buf;
+
+ trans = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ grub_memset (trans, 0, sizeof (*trans));
+ tbd = (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + 128);
+ grub_memset (tbd, 0, sizeof (*tbd));
+ buf = (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + 256);
+ grub_memcpy (buf, pack->data, pack->tail - pack->data);
+
+ trans->tbd = SEGOFS ((grub_addr_t) tbd);
+ trans->protocol = 0;
+ tbd->len = pack->tail - pack->data;
+ tbd->buf = SEGOFS ((grub_addr_t) buf);
+
+ grub_pxe_call (GRUB_PXENV_UNDI_TRANSMIT, trans, pxe_rm_entry);
+ if (trans->status)
+ return grub_error (GRUB_ERR_IO, N_("couldn't send network packet"));
+ return 0;
+}
+
+static void
+grub_pxe_close (struct grub_net_card *dev __attribute__ ((unused)))
+{
+ if (pxe_rm_entry)
+ grub_pxe_call (GRUB_PXENV_UNDI_CLOSE,
+ (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR,
+ pxe_rm_entry);
+}
+
+static grub_err_t
+grub_pxe_open (struct grub_net_card *dev __attribute__ ((unused)))
+{
+ struct grub_pxe_undi_open *ou;
+ ou = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ grub_memset (ou, 0, sizeof (*ou));
+ ou->pkt_filter = 4;
+ grub_pxe_call (GRUB_PXENV_UNDI_OPEN, ou, pxe_rm_entry);
+
+ if (ou->status)
+ return grub_error (GRUB_ERR_IO, "can't open UNDI");
+ return GRUB_ERR_NONE;
+}
+
+struct grub_net_card_driver grub_pxe_card_driver =
+{
+ .open = grub_pxe_open,
+ .close = grub_pxe_close,
+ .send = grub_pxe_send,
+ .recv = grub_pxe_recv
+};
+
+struct grub_net_card grub_pxe_card =
+{
+ .driver = &grub_pxe_card_driver,
+ .name = "pxe"
+};
+
+static grub_err_t
+grub_pxe_shutdown (int flags)
+{
+ if (flags & GRUB_LOADER_FLAG_PXE_NOT_UNLOAD)
+ return GRUB_ERR_NONE;
+ if (!pxe_rm_entry)
+ return GRUB_ERR_NONE;
+
+ grub_pxe_call (GRUB_PXENV_UNDI_CLOSE,
+ (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR,
+ pxe_rm_entry);
+ grub_pxe_call (GRUB_PXENV_UNDI_SHUTDOWN,
+ (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR,
+ pxe_rm_entry);
+ grub_pxe_call (GRUB_PXENV_UNLOAD_STACK,
+ (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR,
+ pxe_rm_entry);
+ pxe_rm_entry = 0;
+ grub_net_card_unregister (&grub_pxe_card);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Nothing we can do. */
+static grub_err_t
+grub_pxe_restore (void)
+{
+ return GRUB_ERR_NONE;
+}
+
+void *
+grub_pxe_get_cached (grub_uint16_t type)
+{
+ struct grub_pxenv_get_cached_info ci;
+ ci.packet_type = type;
+ ci.buffer = 0;
+ ci.buffer_size = 0;
+ grub_pxe_call (GRUB_PXENV_GET_CACHED_INFO, &ci, pxe_rm_entry);
+ if (ci.status)
+ return 0;
+
+ return LINEAR (ci.buffer);
+}
+
+static void
+grub_pc_net_config_real (char **device, char **path)
+{
+ struct grub_net_bootp_packet *bp;
+
+ bp = grub_pxe_get_cached (GRUB_PXENV_PACKET_TYPE_DHCP_ACK);
+
+ if (!bp)
+ return;
+ grub_net_configure_by_dhcp_ack ("pxe", &grub_pxe_card, 0,
+ bp, GRUB_PXE_BOOTP_SIZE,
+ 1, device, path);
+
+}
+
+static struct grub_preboot *fini_hnd;
+
+GRUB_MOD_INIT(pxe)
+{
+ struct grub_pxe_bangpxe *pxenv;
+ struct grub_pxe_undi_info *ui;
+ unsigned i;
+
+ pxenv = grub_pxe_scan ();
+ if (! pxenv)
+ return;
+
+ ui = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ grub_memset (ui, 0, sizeof (*ui));
+ grub_pxe_call (GRUB_PXENV_UNDI_GET_INFORMATION, ui, pxe_rm_entry);
+
+ grub_memcpy (grub_pxe_card.default_address.mac, ui->current_addr,
+ sizeof (grub_pxe_card.default_address.mac));
+ for (i = 0; i < sizeof (grub_pxe_card.default_address.mac); i++)
+ if (grub_pxe_card.default_address.mac[i] != 0)
+ break;
+ if (i != sizeof (grub_pxe_card.default_address.mac))
+ {
+ for (i = 0; i < sizeof (grub_pxe_card.default_address.mac); i++)
+ if (grub_pxe_card.default_address.mac[i] != 0xff)
+ break;
+ }
+ if (i == sizeof (grub_pxe_card.default_address.mac))
+ grub_memcpy (grub_pxe_card.default_address.mac, ui->permanent_addr,
+ sizeof (grub_pxe_card.default_address.mac));
+ grub_pxe_card.mtu = ui->mtu;
+
+ grub_pxe_card.default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+
+ grub_net_card_register (&grub_pxe_card);
+ grub_pc_net_config = grub_pc_net_config_real;
+ fini_hnd = grub_loader_register_preboot_hook (grub_pxe_shutdown,
+ grub_pxe_restore,
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK);
+}
+
+GRUB_MOD_FINI(pxe)
+{
+ grub_pc_net_config = 0;
+ grub_pxe_shutdown (0);
+ grub_loader_unregister_preboot_hook (fini_hnd);
+}
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
new file mode 100644
index 0000000..ac4e62a
--- /dev/null
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
@@ -0,0 +1,565 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net/netbuff.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/dl.h>
+#include <grub/net.h>
+#include <grub/time.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_ofnetcard_data
+{
+ char *path;
+ char *suffix;
+ grub_ieee1275_ihandle_t handle;
+};
+
+static grub_err_t
+card_open (struct grub_net_card *dev)
+{
+ int status;
+ struct grub_ofnetcard_data *data = dev->data;
+
+ status = grub_ieee1275_open (data->path, &(data->handle));
+
+ if (status)
+ return grub_error (GRUB_ERR_IO, "Couldn't open network card.");
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+card_close (struct grub_net_card *dev)
+{
+ struct grub_ofnetcard_data *data = dev->data;
+
+ if (data->handle)
+ grub_ieee1275_close (data->handle);
+}
+
+static grub_err_t
+send_card_buffer (struct grub_net_card *dev, struct grub_net_buff *pack)
+{
+ grub_ssize_t actual;
+ int status;
+ struct grub_ofnetcard_data *data = dev->data;
+ grub_size_t len;
+
+ len = (pack->tail - pack->data);
+ if (len > dev->mtu)
+ len = dev->mtu;
+
+ grub_memcpy (dev->txbuf, pack->data, len);
+ status = grub_ieee1275_write (data->handle, dev->txbuf,
+ len, &actual);
+
+ if (status)
+ return grub_error (GRUB_ERR_IO, N_("couldn't send network packet"));
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_net_buff *
+get_card_packet (struct grub_net_card *dev)
+{
+ grub_ssize_t actual;
+ int rc;
+ struct grub_ofnetcard_data *data = dev->data;
+ grub_uint64_t start_time;
+ struct grub_net_buff *nb;
+
+ start_time = grub_get_time_ms ();
+ do
+ rc = grub_ieee1275_read (data->handle, dev->rcvbuf, dev->rcvbufsize, &actual);
+ while ((actual <= 0 || rc < 0) && (grub_get_time_ms () - start_time < 200));
+
+ if (actual <= 0)
+ return NULL;
+
+ nb = grub_netbuff_alloc (actual + 2);
+ if (!nb)
+ 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 (nb, 2);
+
+ grub_memcpy (nb->data, dev->rcvbuf, actual);
+
+ if (grub_netbuff_put (nb, actual))
+ {
+ grub_netbuff_free (nb);
+ return NULL;
+ }
+
+ return nb;
+}
+
+static struct grub_net_card_driver ofdriver =
+ {
+ .name = "ofnet",
+ .open = card_open,
+ .close = card_close,
+ .send = send_card_buffer,
+ .recv = get_card_packet
+ };
+
+static const struct
+{
+ const char *name;
+ int offset;
+}
+
+bootp_response_properties[] =
+ {
+ { .name = "bootp-response", .offset = 0},
+ { .name = "dhcp-response", .offset = 0},
+ { .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 = {0, {0}, 0}, gateway_addr = {0, {0}, 0}, subnet_mask = {0, {0}, 0};
+ grub_net_link_level_address_t hw_addr = {0, {{0, 0, 0, 0, 0, 0}}};
+ grub_net_interface_flags_t flags = 0;
+ struct grub_net_network_level_interface *inter = NULL;
+ grub_uint16_t vlantag = 0;
+
+ 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));
+
+ if ((grub_strcmp (args, "vtag") == 0) &&
+ (grub_strlen (equal_char + 1) == 8))
+ vlantag = grub_strtoul (equal_char + 1 + 4, 0, 16);
+
+ *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);
+ inter->vlantag = vlantag;
+ 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,
+ char *bootpath)
+{
+ struct grub_net_card *card;
+
+ /* FIXME: Check that it's the right card. */
+ FOR_NET_CARDS (card)
+ {
+ char *bootp_response;
+ char *canon;
+ char c;
+ struct grub_ofnetcard_data *data;
+
+ grub_ssize_t size = -1;
+ unsigned int i;
+
+ if (card->driver != &ofdriver)
+ continue;
+
+ data = card->data;
+ c = *data->suffix;
+ *data->suffix = '\0';
+ canon = grub_ieee1275_canonicalise_devname (data->path);
+ *data->suffix = c;
+ if (grub_strcmp (devpath, canon) != 0)
+ {
+ grub_free (canon);
+ continue;
+ }
+ 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,
+ &size) >= 0)
+ break;
+
+ if (size < 0)
+ return;
+
+ bootp_response = grub_malloc (size);
+ if (!bootp_response)
+ {
+ grub_print_error ();
+ return;
+ }
+ if (grub_ieee1275_get_property (grub_ieee1275_chosen,
+ bootp_response_properties[i].name,
+ bootp_response, size, 0) < 0)
+ return;
+
+ grub_net_configure_by_dhcp_ack (card->name, card, 0,
+ (struct grub_net_bootp_packet *)
+ (bootp_response
+ + bootp_response_properties[i].offset),
+ size - bootp_response_properties[i].offset,
+ 1, device, path);
+ grub_free (bootp_response);
+ return;
+ }
+}
+
+/* Allocate memory with alloc-mem */
+static void *
+grub_ieee1275_alloc_mem (grub_size_t len)
+{
+ struct alloc_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t len;
+ grub_ieee1275_cell_t catch;
+ grub_ieee1275_cell_t result;
+ }
+ args;
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET))
+ {
+ grub_error (GRUB_ERR_UNKNOWN_COMMAND, N_("interpret is not supported"));
+ return NULL;
+ }
+
+ INIT_IEEE1275_COMMON (&args.common, "interpret", 2, 2);
+ args.len = len;
+ args.method = (grub_ieee1275_cell_t) "alloc-mem";
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || args.catch)
+ {
+ grub_error (GRUB_ERR_INVALID_COMMAND, N_("alloc-mem failed"));
+ return NULL;
+ }
+ else
+ return (void *)args.result;
+}
+
+/* Free memory allocated by alloc-mem */
+static grub_err_t
+grub_ieee1275_free_mem (void *addr, grub_size_t len)
+{
+ struct free_args
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t len;
+ grub_ieee1275_cell_t addr;
+ grub_ieee1275_cell_t catch;
+ }
+ args;
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET))
+ {
+ grub_error (GRUB_ERR_UNKNOWN_COMMAND, N_("interpret is not supported"));
+ return grub_errno;
+ }
+
+ INIT_IEEE1275_COMMON (&args.common, "interpret", 3, 1);
+ args.addr = (grub_ieee1275_cell_t)addr;
+ args.len = len;
+ args.method = (grub_ieee1275_cell_t) "free-mem";
+
+ if (IEEE1275_CALL_ENTRY_FN(&args) == -1 || args.catch)
+ {
+ grub_error (GRUB_ERR_INVALID_COMMAND, N_("free-mem failed"));
+ return grub_errno;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static void *
+ofnet_alloc_netbuf (grub_size_t len)
+{
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN))
+ return grub_ieee1275_alloc_mem (len);
+ else
+ return grub_zalloc (len);
+}
+
+static void
+ofnet_free_netbuf (void *addr, grub_size_t len)
+{
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN))
+ grub_ieee1275_free_mem (addr, len);
+ else
+ grub_free (addr);
+}
+
+static int
+search_net_devices (struct grub_ieee1275_devalias *alias)
+{
+ struct grub_ofnetcard_data *ofdata;
+ struct grub_net_card *card;
+ grub_ieee1275_phandle_t devhandle;
+ grub_net_link_level_address_t lla;
+ grub_ssize_t prop_size;
+ grub_uint64_t prop;
+ grub_uint8_t *pprop;
+ char *shortname;
+ char need_suffix = 1;
+
+ if (grub_strcmp (alias->type, "network") != 0)
+ return 0;
+
+ ofdata = grub_malloc (sizeof (struct grub_ofnetcard_data));
+ if (!ofdata)
+ {
+ grub_print_error ();
+ return 1;
+ }
+ card = grub_zalloc (sizeof (struct grub_net_card));
+ if (!card)
+ {
+ grub_free (ofdata);
+ grub_print_error ();
+ return 1;
+ }
+
+#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))
+ 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);
+ if (!ofdata->path)
+ {
+ grub_print_error ();
+ return 0;
+ }
+ ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
+ if (need_suffix)
+ grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
+ else
+ *ofdata->suffix = '\0';
+
+ grub_ieee1275_finddevice (ofdata->path, &devhandle);
+
+ {
+ grub_uint32_t t;
+ if (grub_ieee1275_get_integer_property (devhandle,
+ "max-frame-size", &t,
+ sizeof (t), 0))
+ card->mtu = 1500;
+ else
+ card->mtu = t;
+ }
+
+ pprop = (grub_uint8_t *) &prop;
+ if (grub_ieee1275_get_property (devhandle, "mac-address",
+ pprop, sizeof(prop), &prop_size)
+ && grub_ieee1275_get_property (devhandle, "local-mac-address",
+ pprop, sizeof(prop), &prop_size))
+ {
+ grub_error (GRUB_ERR_IO, "Couldn't retrieve mac address.");
+ grub_print_error ();
+ return 0;
+ }
+
+ if (prop_size == 8)
+ grub_memcpy (&lla.mac, pprop+2, 6);
+ else
+ grub_memcpy (&lla.mac, pprop, 6);
+
+ lla.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ card->default_address = lla;
+
+ card->txbufsize = ALIGN_UP (card->mtu, 64) + 256;
+ card->rcvbufsize = ALIGN_UP (card->mtu, 64) + 256;
+
+ card->txbuf = ofnet_alloc_netbuf (card->txbufsize);
+ if (!card->txbuf)
+ goto fail_netbuf;
+
+ card->rcvbuf = ofnet_alloc_netbuf (card->rcvbufsize);
+ if (!card->rcvbuf)
+ {
+ grub_error_push ();
+ ofnet_free_netbuf (card->txbuf, card->txbufsize);
+ grub_error_pop ();
+ goto fail_netbuf;
+ }
+ card->driver = NULL;
+ card->data = ofdata;
+ card->flags = 0;
+ shortname = grub_ieee1275_get_devname (alias->path);
+ card->name = grub_xasprintf ("ofnet_%s", shortname ? : alias->path);
+ card->idle_poll_delay_ms = 10;
+ grub_free (shortname);
+
+ card->driver = &ofdriver;
+ grub_net_card_register (card);
+ return 0;
+
+fail_netbuf:
+ grub_free (ofdata->path);
+ grub_free (ofdata);
+ grub_free (card);
+ grub_print_error ();
+ return 0;
+}
+
+static void
+grub_ofnet_findcards (void)
+{
+ /* Look at all nodes for devices of the type network. */
+ grub_ieee1275_devices_iterate (search_net_devices);
+}
+
+GRUB_MOD_INIT(ofnet)
+{
+ grub_ofnet_findcards ();
+ grub_ieee1275_net_config = grub_ieee1275_net_config_real;
+}
+
+GRUB_MOD_FINI(ofnet)
+{
+ struct grub_net_card *card, *next;
+
+ FOR_NET_CARDS_SAFE (card, next)
+ if (card->driver && grub_strcmp (card->driver->name, "ofnet") == 0)
+ grub_net_card_unregister (card);
+ grub_ieee1275_net_config = 0;
+}
diff --git a/grub-core/net/drivers/uboot/ubootnet.c b/grub-core/net/drivers/uboot/ubootnet.c
new file mode 100644
index 0000000..056052e
--- /dev/null
+++ b/grub-core/net/drivers/uboot/ubootnet.c
@@ -0,0 +1,161 @@
+/*
+ * 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/net/netbuff.h>
+#include <grub/uboot/disk.h>
+#include <grub/uboot/uboot.h>
+#include <grub/uboot/api_public.h>
+#include <grub/dl.h>
+#include <grub/net.h>
+#include <grub/time.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+card_open (struct grub_net_card *dev)
+{
+ int status;
+
+ status = grub_uboot_dev_open (dev->data);
+ if (status)
+ return grub_error (GRUB_ERR_IO, "Couldn't open network card.");
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+card_close (struct grub_net_card *dev)
+{
+ grub_uboot_dev_close (dev->data);
+}
+
+static grub_err_t
+send_card_buffer (struct grub_net_card *dev, struct grub_net_buff *pack)
+{
+ int status;
+ grub_size_t len;
+
+ len = (pack->tail - pack->data);
+ if (len > dev->mtu)
+ len = dev->mtu;
+
+ grub_memcpy (dev->txbuf, pack->data, len);
+ status = grub_uboot_dev_send (dev->data, dev->txbuf, len);
+
+ if (status)
+ return grub_error (GRUB_ERR_IO, N_("couldn't send network packet"));
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_net_buff *
+get_card_packet (struct grub_net_card *dev)
+{
+ int rc;
+ grub_uint64_t start_time;
+ struct grub_net_buff *nb;
+ int actual;
+
+ nb = grub_netbuff_alloc (dev->mtu + 64 + 2);
+ if (!nb)
+ 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 (nb, 2);
+
+ start_time = grub_get_time_ms ();
+ do
+ {
+ rc = grub_uboot_dev_recv (dev->data, nb->data, dev->mtu + 64, &actual);
+ grub_dprintf ("net", "rc=%d, actual=%d, time=%lld\n", rc, actual,
+ grub_get_time_ms () - start_time);
+ }
+ while ((actual <= 0 || rc < 0) && (grub_get_time_ms () - start_time < 200));
+ if (actual > 0)
+ {
+ grub_netbuff_put (nb, actual);
+ return nb;
+ }
+ grub_netbuff_free (nb);
+ return NULL;
+}
+
+static struct grub_net_card_driver ubootnet =
+ {
+ .name = "ubnet",
+ .open = card_open,
+ .close = card_close,
+ .send = send_card_buffer,
+ .recv = get_card_packet
+ };
+
+GRUB_MOD_INIT (ubootnet)
+{
+ int devcount, i;
+ int nfound = 0;
+
+ devcount = grub_uboot_dev_enum ();
+
+ for (i = 0; i < devcount; i++)
+ {
+ struct device_info *devinfo = grub_uboot_dev_get (i);
+ struct grub_net_card *card;
+
+ if (!(devinfo->type & DEV_TYP_NET))
+ continue;
+
+ card = grub_zalloc (sizeof (struct grub_net_card));
+ if (!card)
+ {
+ grub_print_error ();
+ return;
+ }
+
+ /* FIXME: Any way to check this? */
+ card->mtu = 1500;
+
+ grub_memcpy (&(card->default_address.mac), &devinfo->di_net.hwaddr, 6);
+ card->default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+
+ card->txbufsize = ALIGN_UP (card->mtu, 64) + 256;
+ card->txbuf = grub_zalloc (card->txbufsize);
+ if (!card->txbuf)
+ {
+ grub_free (card);
+ grub_print_error ();
+ continue;
+ }
+
+ card->data = devinfo;
+ card->flags = 0;
+ card->name = grub_xasprintf ("ubnet_%d", ++nfound);
+ card->idle_poll_delay_ms = 10;
+
+ card->driver = &ubootnet;
+ grub_net_card_register (card);
+ }
+}
+
+GRUB_MOD_FINI (ubootnet)
+{
+ struct grub_net_card *card, *next;
+
+ FOR_NET_CARDS_SAFE (card, next)
+ if (card->driver && grub_strcmp (card->driver->name, "ubnet") == 0)
+ grub_net_card_unregister (card);
+}
diff --git a/grub-core/net/ethernet.c b/grub-core/net/ethernet.c
new file mode 100644
index 0000000..4d7ceed
--- /dev/null
+++ b/grub-core/net/ethernet.c
@@ -0,0 +1,171 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/mm.h>
+#include <grub/env.h>
+#include <grub/net/ethernet.h>
+#include <grub/net/ip.h>
+#include <grub/net/arp.h>
+#include <grub/net/netbuff.h>
+#include <grub/net.h>
+#include <grub/time.h>
+#include <grub/net/arp.h>
+
+#define LLCADDRMASK 0x7f
+
+struct etherhdr
+{
+ grub_uint8_t dst[6];
+ grub_uint8_t src[6];
+ grub_uint16_t type;
+} GRUB_PACKED;
+
+struct llchdr
+{
+ grub_uint8_t dsap;
+ grub_uint8_t ssap;
+ grub_uint8_t ctrl;
+} GRUB_PACKED;
+
+struct snaphdr
+{
+ grub_uint8_t oui[3];
+ grub_uint16_t type;
+} GRUB_PACKED;
+
+grub_err_t
+send_ethernet_packet (struct grub_net_network_level_interface *inf,
+ struct grub_net_buff *nb,
+ grub_net_link_level_address_t target_addr,
+ grub_net_ethertype_t ethertype)
+{
+ struct etherhdr *eth;
+ grub_err_t err;
+ grub_uint8_t etherhdr_size;
+ grub_uint16_t vlantag_id = VLANTAG_IDENTIFIER;
+
+ etherhdr_size = sizeof (*eth);
+ COMPILE_TIME_ASSERT (sizeof (*eth) + 4 < GRUB_NET_MAX_LINK_HEADER_SIZE);
+
+ /* Increase ethernet header in case of vlantag */
+ if (inf->vlantag != 0)
+ etherhdr_size += 4;
+
+ err = grub_netbuff_push (nb, etherhdr_size);
+ if (err)
+ return err;
+ eth = (struct etherhdr *) nb->data;
+ grub_memcpy (eth->dst, target_addr.mac, 6);
+ grub_memcpy (eth->src, inf->hwaddress.mac, 6);
+
+ eth->type = grub_cpu_to_be16 (ethertype);
+ if (!inf->card->opened)
+ {
+ err = GRUB_ERR_NONE;
+ if (inf->card->driver->open)
+ err = inf->card->driver->open (inf->card);
+ if (err)
+ return err;
+ inf->card->opened = 1;
+ }
+
+ /* Check and add a vlan-tag if needed. */
+ if (inf->vlantag != 0)
+ {
+ /* Move eth type to the right */
+ grub_memcpy ((char *) nb->data + etherhdr_size - 2,
+ (char *) nb->data + etherhdr_size - 6, 2);
+
+ /* Add the tag in the middle */
+ grub_memcpy ((char *) nb->data + etherhdr_size - 6, &vlantag_id, 2);
+ grub_memcpy ((char *) nb->data + etherhdr_size - 4, (char *) &(inf->vlantag), 2);
+ }
+
+ return inf->card->driver->send (inf->card, nb);
+}
+
+grub_err_t
+grub_net_recv_ethernet_packet (struct grub_net_buff *nb,
+ struct grub_net_card *card)
+{
+ struct etherhdr *eth;
+ struct llchdr *llch;
+ struct snaphdr *snaph;
+ grub_net_ethertype_t type;
+ grub_net_link_level_address_t hwaddress;
+ grub_net_link_level_address_t src_hwaddress;
+ grub_err_t err;
+ grub_uint8_t etherhdr_size = sizeof (*eth);
+ grub_uint16_t vlantag = 0;
+
+
+ /* Check if a vlan-tag is present. If so, the ethernet header is 4 bytes */
+ /* longer than the original one. The vlantag id is extracted and the header */
+ /* is reseted to the original size. */
+ if (grub_get_unaligned16 (nb->data + etherhdr_size - 2) == VLANTAG_IDENTIFIER)
+ {
+ vlantag = grub_get_unaligned16 (nb->data + etherhdr_size);
+ etherhdr_size += 4;
+ /* Move eth type to the original position */
+ grub_memcpy((char *) nb->data + etherhdr_size - 6,
+ (char *) nb->data + etherhdr_size - 2, 2);
+ }
+
+ eth = (struct etherhdr *) nb->data;
+ type = grub_be_to_cpu16 (eth->type);
+ err = grub_netbuff_pull (nb, etherhdr_size);
+ if (err)
+ return err;
+
+ if (type <= 1500)
+ {
+ llch = (struct llchdr *) nb->data;
+ type = llch->dsap & LLCADDRMASK;
+
+ if (llch->dsap == 0xaa && llch->ssap == 0xaa && llch->ctrl == 0x3)
+ {
+ err = grub_netbuff_pull (nb, sizeof (*llch));
+ if (err)
+ return err;
+ snaph = (struct snaphdr *) nb->data;
+ type = snaph->type;
+ }
+ }
+
+ hwaddress.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ grub_memcpy (hwaddress.mac, eth->dst, sizeof (hwaddress.mac));
+ src_hwaddress.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ grub_memcpy (src_hwaddress.mac, eth->src, sizeof (src_hwaddress.mac));
+
+ switch (type)
+ {
+ /* ARP packet. */
+ case GRUB_NET_ETHERTYPE_ARP:
+ grub_net_arp_receive (nb, card, &vlantag);
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ /* IP packet. */
+ case GRUB_NET_ETHERTYPE_IP:
+ case GRUB_NET_ETHERTYPE_IP6:
+ return grub_net_recv_ip_packets (nb, card, &hwaddress, &src_hwaddress,
+ &vlantag);
+ }
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/net/http.c b/grub-core/net/http.c
new file mode 100644
index 0000000..b616cf4
--- /dev/null
+++ b/grub-core/net/http.c
@@ -0,0 +1,562 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net/tcp.h>
+#include <grub/net/ip.h>
+#include <grub/net/ethernet.h>
+#include <grub/net/netbuff.h>
+#include <grub/net.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+enum
+ {
+ HTTP_PORT = 80
+ };
+
+
+typedef struct http_data
+{
+ char *current_line;
+ grub_size_t current_line_len;
+ int headers_recv;
+ int first_line_recv;
+ int size_recv;
+ grub_net_tcp_socket_t sock;
+ char *filename;
+ grub_err_t err;
+ char *errmsg;
+ int chunked;
+ grub_size_t chunk_rem;
+ int in_chunk_len;
+} *http_data_t;
+
+static grub_off_t
+have_ahead (struct grub_file *file)
+{
+ grub_net_t net = file->device->net;
+ grub_off_t ret = net->offset;
+ struct grub_net_packet *pack;
+ for (pack = net->packs.first; pack; pack = pack->next)
+ ret += pack->nb->tail - pack->nb->data;
+ return ret;
+}
+
+static grub_err_t
+parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len)
+{
+ char *end = ptr + len;
+ while (end > ptr && *(end - 1) == '\r')
+ end--;
+ *end = 0;
+ /* Trailing CRLF. */
+ if (data->in_chunk_len == 1)
+ {
+ data->in_chunk_len = 2;
+ return GRUB_ERR_NONE;
+ }
+ if (data->in_chunk_len == 2)
+ {
+ data->chunk_rem = grub_strtoul (ptr, 0, 16);
+ grub_errno = GRUB_ERR_NONE;
+ if (data->chunk_rem == 0)
+ {
+ file->device->net->eof = 1;
+ file->device->net->stall = 1;
+ if (file->size == GRUB_FILE_SIZE_UNKNOWN)
+ file->size = have_ahead (file);
+ }
+ data->in_chunk_len = 0;
+ return GRUB_ERR_NONE;
+ }
+ if (ptr == end)
+ {
+ data->headers_recv = 1;
+ if (data->chunked)
+ data->in_chunk_len = 2;
+ return GRUB_ERR_NONE;
+ }
+
+ if (!data->first_line_recv)
+ {
+ int code;
+ if (grub_memcmp (ptr, "HTTP/1.1 ", sizeof ("HTTP/1.1 ") - 1) != 0)
+ {
+ data->errmsg = grub_strdup (_("unsupported HTTP response"));
+ data->first_line_recv = 1;
+ return GRUB_ERR_NONE;
+ }
+ ptr += sizeof ("HTTP/1.1 ") - 1;
+ code = grub_strtoul (ptr, (const char **)&ptr, 10);
+ if (grub_errno)
+ return grub_errno;
+ switch (code)
+ {
+ case 200:
+ case 206:
+ break;
+ case 404:
+ data->err = GRUB_ERR_FILE_NOT_FOUND;
+ data->errmsg = grub_xasprintf (_("file `%s' not found"), data->filename);
+ return GRUB_ERR_NONE;
+ default:
+ data->err = GRUB_ERR_NET_UNKNOWN_ERROR;
+ /* TRANSLATORS: GRUB HTTP code is pretty young. So even perfectly
+ valid answers like 403 will trigger this very generic message. */
+ data->errmsg = grub_xasprintf (_("unsupported HTTP error %d: %s"),
+ code, ptr);
+ return GRUB_ERR_NONE;
+ }
+ data->first_line_recv = 1;
+ return GRUB_ERR_NONE;
+ }
+ if (grub_memcmp (ptr, "Content-Length: ", sizeof ("Content-Length: ") - 1)
+ == 0 && !data->size_recv)
+ {
+ ptr += sizeof ("Content-Length: ") - 1;
+ file->size = grub_strtoull (ptr, (const char **)&ptr, 10);
+ data->size_recv = 1;
+ return GRUB_ERR_NONE;
+ }
+ if (grub_memcmp (ptr, "Transfer-Encoding: chunked",
+ sizeof ("Transfer-Encoding: chunked") - 1) == 0)
+ {
+ data->chunked = 1;
+ return GRUB_ERR_NONE;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+http_err (grub_net_tcp_socket_t sock __attribute__ ((unused)),
+ void *f)
+{
+ grub_file_t file = f;
+ http_data_t data = file->data;
+
+ if (data->sock)
+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
+ data->sock = 0;
+ if (data->current_line)
+ grub_free (data->current_line);
+ data->current_line = 0;
+ file->device->net->eof = 1;
+ file->device->net->stall = 1;
+ if (file->size == GRUB_FILE_SIZE_UNKNOWN)
+ file->size = have_ahead (file);
+}
+
+static grub_err_t
+http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)),
+ struct grub_net_buff *nb,
+ void *f)
+{
+ grub_file_t file = f;
+ http_data_t data = file->data;
+ grub_err_t err;
+
+ if (!data->sock)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ while (1)
+ {
+ char *ptr = (char *) nb->data;
+ if ((!data->headers_recv || data->in_chunk_len) && data->current_line)
+ {
+ int have_line = 1;
+ char *t;
+ ptr = grub_memchr (nb->data, '\n', nb->tail - nb->data);
+ if (ptr)
+ ptr++;
+ else
+ {
+ have_line = 0;
+ ptr = (char *) nb->tail;
+ }
+ t = grub_realloc (data->current_line,
+ data->current_line_len + (ptr - (char *) nb->data));
+ if (!t)
+ {
+ grub_netbuff_free (nb);
+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
+ return grub_errno;
+ }
+
+ data->current_line = t;
+ grub_memcpy (data->current_line + data->current_line_len,
+ nb->data, ptr - (char *) nb->data);
+ data->current_line_len += ptr - (char *) nb->data;
+ if (!have_line)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ err = parse_line (file, data, data->current_line,
+ data->current_line_len);
+ grub_free (data->current_line);
+ data->current_line = 0;
+ data->current_line_len = 0;
+ if (err)
+ {
+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
+ grub_netbuff_free (nb);
+ return err;
+ }
+ }
+
+ while (ptr < (char *) nb->tail && (!data->headers_recv
+ || data->in_chunk_len))
+ {
+ char *ptr2;
+ ptr2 = grub_memchr (ptr, '\n', (char *) nb->tail - ptr);
+ if (!ptr2)
+ {
+ data->current_line = grub_malloc ((char *) nb->tail - ptr);
+ if (!data->current_line)
+ {
+ grub_netbuff_free (nb);
+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
+ return grub_errno;
+ }
+ data->current_line_len = (char *) nb->tail - ptr;
+ grub_memcpy (data->current_line, ptr, data->current_line_len);
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ err = parse_line (file, data, ptr, ptr2 - ptr);
+ if (err)
+ {
+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
+ grub_netbuff_free (nb);
+ return err;
+ }
+ ptr = ptr2 + 1;
+ }
+
+ if (((char *) nb->tail - ptr) <= 0)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ err = grub_netbuff_pull (nb, ptr - (char *) nb->data);
+ if (err)
+ {
+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
+ grub_netbuff_free (nb);
+ return err;
+ }
+ if (!(data->chunked && (grub_ssize_t) data->chunk_rem
+ < nb->tail - nb->data))
+ {
+ grub_net_put_packet (&file->device->net->packs, nb);
+ if (file->device->net->packs.count >= 20)
+ file->device->net->stall = 1;
+
+ if (file->device->net->packs.count >= 100)
+ grub_net_tcp_stall (data->sock);
+
+ if (data->chunked)
+ data->chunk_rem -= nb->tail - nb->data;
+ return GRUB_ERR_NONE;
+ }
+ if (data->chunk_rem)
+ {
+ struct grub_net_buff *nb2;
+ nb2 = grub_netbuff_alloc (data->chunk_rem);
+ if (!nb2)
+ return grub_errno;
+ grub_netbuff_put (nb2, data->chunk_rem);
+ grub_memcpy (nb2->data, nb->data, data->chunk_rem);
+ if (file->device->net->packs.count >= 20)
+ {
+ file->device->net->stall = 1;
+ grub_net_tcp_stall (data->sock);
+ }
+
+ grub_net_put_packet (&file->device->net->packs, nb2);
+ grub_netbuff_pull (nb, data->chunk_rem);
+ }
+ data->in_chunk_len = 1;
+ }
+}
+
+static grub_err_t
+http_establish (struct grub_file *file, grub_off_t offset, int initial)
+{
+ http_data_t data = file->data;
+ grub_uint8_t *ptr;
+ int i;
+ struct grub_net_buff *nb;
+ grub_err_t err;
+
+ nb = grub_netbuff_alloc (GRUB_NET_TCP_RESERVE_SIZE
+ + sizeof ("GET ") - 1
+ + grub_strlen (data->filename)
+ + sizeof (" HTTP/1.1\r\nHost: ") - 1
+ + grub_strlen (file->device->net->server)
+ + sizeof ("\r\nUser-Agent: " PACKAGE_STRING
+ "\r\n") - 1
+ + sizeof ("Range: bytes=XXXXXXXXXXXXXXXXXXXX"
+ "-\r\n\r\n"));
+ if (!nb)
+ return grub_errno;
+
+ grub_netbuff_reserve (nb, GRUB_NET_TCP_RESERVE_SIZE);
+ ptr = nb->tail;
+ err = grub_netbuff_put (nb, sizeof ("GET ") - 1);
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+ grub_memcpy (ptr, "GET ", sizeof ("GET ") - 1);
+
+ ptr = nb->tail;
+
+ err = grub_netbuff_put (nb, grub_strlen (data->filename));
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+ grub_memcpy (ptr, data->filename, grub_strlen (data->filename));
+
+ ptr = nb->tail;
+ err = grub_netbuff_put (nb, sizeof (" HTTP/1.1\r\nHost: ") - 1);
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+ grub_memcpy (ptr, " HTTP/1.1\r\nHost: ",
+ sizeof (" HTTP/1.1\r\nHost: ") - 1);
+
+ ptr = nb->tail;
+ err = grub_netbuff_put (nb, grub_strlen (file->device->net->server));
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+ grub_memcpy (ptr, file->device->net->server,
+ grub_strlen (file->device->net->server));
+
+ ptr = nb->tail;
+ err = grub_netbuff_put (nb,
+ sizeof ("\r\nUser-Agent: " PACKAGE_STRING "\r\n")
+ - 1);
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+ grub_memcpy (ptr, "\r\nUser-Agent: " PACKAGE_STRING "\r\n",
+ sizeof ("\r\nUser-Agent: " PACKAGE_STRING "\r\n") - 1);
+ if (!initial)
+ {
+ ptr = nb->tail;
+ grub_snprintf ((char *) ptr,
+ sizeof ("Range: bytes=XXXXXXXXXXXXXXXXXXXX-"
+ "\r\n"),
+ "Range: bytes=%" PRIuGRUB_UINT64_T "-\r\n",
+ offset);
+ grub_netbuff_put (nb, grub_strlen ((char *) ptr));
+ }
+ ptr = nb->tail;
+ grub_netbuff_put (nb, 2);
+ grub_memcpy (ptr, "\r\n", 2);
+
+ data->sock = grub_net_tcp_open (file->device->net->server,
+ HTTP_PORT, http_receive,
+ http_err, NULL,
+ file);
+ if (!data->sock)
+ {
+ grub_netbuff_free (nb);
+ return grub_errno;
+ }
+
+ // grub_net_poll_cards (5000);
+
+ err = grub_net_send_tcp_packet (data->sock, nb, 1);
+ if (err)
+ {
+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
+ return err;
+ }
+
+ for (i = 0; !data->headers_recv && i < 100; i++)
+ {
+ grub_net_tcp_retransmit ();
+ grub_net_poll_cards (300, &data->headers_recv);
+ }
+
+ if (!data->headers_recv)
+ {
+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
+ if (data->err)
+ {
+ char *str = data->errmsg;
+ err = grub_error (data->err, "%s", str);
+ grub_free (str);
+ data->errmsg = 0;
+ return data->err;
+ }
+ return grub_error (GRUB_ERR_TIMEOUT, N_("time out opening `%s'"), data->filename);
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+http_seek (struct grub_file *file, grub_off_t off)
+{
+ struct http_data *old_data, *data;
+ grub_err_t err;
+ old_data = file->data;
+ /* FIXME: Reuse socket? */
+ if (old_data->sock)
+ grub_net_tcp_close (old_data->sock, GRUB_NET_TCP_ABORT);
+ old_data->sock = 0;
+
+ while (file->device->net->packs.first)
+ {
+ grub_netbuff_free (file->device->net->packs.first->nb);
+ grub_net_remove_packet (file->device->net->packs.first);
+ }
+
+ file->device->net->stall = 0;
+ file->device->net->eof = 0;
+ file->device->net->offset = off;
+
+ data = grub_zalloc (sizeof (*data));
+ if (!data)
+ return grub_errno;
+
+ data->size_recv = 1;
+ data->filename = old_data->filename;
+ if (!data->filename)
+ {
+ grub_free (data);
+ file->data = 0;
+ return grub_errno;
+ }
+ grub_free (old_data);
+
+ file->data = data;
+ err = http_establish (file, off, 0);
+ if (err)
+ {
+ grub_free (data->filename);
+ grub_free (data);
+ file->data = 0;
+ return err;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+http_open (struct grub_file *file, const char *filename)
+{
+ grub_err_t err;
+ struct http_data *data;
+
+ data = grub_zalloc (sizeof (*data));
+ if (!data)
+ return grub_errno;
+ file->size = GRUB_FILE_SIZE_UNKNOWN;
+
+ data->filename = grub_strdup (filename);
+ if (!data->filename)
+ {
+ grub_free (data);
+ return grub_errno;
+ }
+
+ file->not_easily_seekable = 0;
+ file->data = data;
+
+ err = http_establish (file, 0, 1);
+ if (err)
+ {
+ grub_free (data->filename);
+ grub_free (data);
+ return err;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+http_close (struct grub_file *file)
+{
+ http_data_t data = file->data;
+
+ if (!data)
+ return GRUB_ERR_NONE;
+
+ if (data->sock)
+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
+ if (data->current_line)
+ grub_free (data->current_line);
+ grub_free (data->filename);
+ grub_free (data);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+http_packets_pulled (struct grub_file *file)
+{
+ http_data_t data = file->data;
+
+ if (file->device->net->packs.count >= 20)
+ return 0;
+
+ if (!file->device->net->eof)
+ file->device->net->stall = 0;
+ if (data && data->sock)
+ grub_net_tcp_unstall (data->sock);
+ return 0;
+}
+
+static struct grub_net_app_protocol grub_http_protocol =
+ {
+ .name = "http",
+ .open = http_open,
+ .close = http_close,
+ .seek = http_seek,
+ .packets_pulled = http_packets_pulled
+ };
+
+GRUB_MOD_INIT (http)
+{
+ grub_net_app_level_register (&grub_http_protocol);
+}
+
+GRUB_MOD_FINI (http)
+{
+ grub_net_app_level_unregister (&grub_http_protocol);
+}
diff --git a/grub-core/net/icmp.c b/grub-core/net/icmp.c
new file mode 100644
index 0000000..b1eef11
--- /dev/null
+++ b/grub-core/net/icmp.c
@@ -0,0 +1,112 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net.h>
+#include <grub/net/ip.h>
+#include <grub/net/netbuff.h>
+
+struct icmp_header
+{
+ grub_uint8_t type;
+ grub_uint8_t code;
+ grub_uint16_t checksum;
+} GRUB_PACKED;
+
+struct ping_header
+{
+ grub_uint16_t id;
+ grub_uint16_t seq;
+} GRUB_PACKED;
+
+enum
+ {
+ ICMP_ECHO_REPLY = 0,
+ ICMP_ECHO = 8,
+ };
+
+grub_err_t
+grub_net_recv_icmp_packet (struct grub_net_buff *nb,
+ struct grub_net_network_level_interface *inf,
+ const grub_net_link_level_address_t *ll_src,
+ const grub_net_network_level_address_t *src)
+{
+ struct icmp_header *icmph;
+ grub_err_t err;
+ grub_uint16_t checksum;
+
+ /* Ignore broadcast. */
+ if (!inf)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ icmph = (struct icmp_header *) nb->data;
+
+ if (nb->tail - nb->data < (grub_ssize_t) sizeof (*icmph))
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ checksum = icmph->checksum;
+ icmph->checksum = 0;
+ if (checksum != grub_net_ip_chksum (nb->data, nb->tail - nb->data))
+ {
+ icmph->checksum = checksum;
+ return GRUB_ERR_NONE;
+ }
+ icmph->checksum = checksum;
+
+ err = grub_netbuff_pull (nb, sizeof (*icmph));
+ if (err)
+ return err;
+
+ switch (icmph->type)
+ {
+ case ICMP_ECHO:
+ {
+ struct grub_net_buff *nb_reply;
+ struct icmp_header *icmphr;
+ if (icmph->code)
+ break;
+ nb_reply = grub_netbuff_make_pkt (nb->tail - nb->data + sizeof (*icmphr));
+ if (!nb_reply)
+ {
+ grub_netbuff_free (nb);
+ return grub_errno;
+ }
+ 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;
+ icmphr->checksum = 0;
+ icmphr->checksum = grub_net_ip_chksum ((void *) nb_reply->data,
+ nb_reply->tail - nb_reply->data);
+ err = grub_net_send_ip_packet (inf, src, ll_src,
+ nb_reply, GRUB_NET_IP_ICMP);
+
+ grub_netbuff_free (nb);
+ grub_netbuff_free (nb_reply);
+ return err;
+ }
+ };
+
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c
new file mode 100644
index 0000000..2cbd95d
--- /dev/null
+++ b/grub-core/net/icmp6.c
@@ -0,0 +1,679 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net.h>
+#include <grub/net/ip.h>
+#include <grub/net/netbuff.h>
+
+struct icmp_header
+{
+ grub_uint8_t type;
+ grub_uint8_t code;
+ grub_uint16_t checksum;
+} GRUB_PACKED;
+
+struct ping_header
+{
+ grub_uint16_t id;
+ grub_uint16_t seq;
+} GRUB_PACKED;
+
+struct router_adv
+{
+ grub_uint8_t ttl;
+ grub_uint8_t flags;
+ grub_uint16_t router_lifetime;
+ grub_uint32_t reachable_time;
+ grub_uint32_t retrans_timer;
+ grub_uint8_t options[0];
+} GRUB_PACKED;
+
+struct option_header
+{
+ grub_uint8_t type;
+ grub_uint8_t len;
+} GRUB_PACKED;
+
+struct prefix_option
+{
+ struct option_header header;
+ grub_uint8_t prefixlen;
+ grub_uint8_t flags;
+ grub_uint32_t valid_lifetime;
+ grub_uint32_t preferred_lifetime;
+ grub_uint32_t reserved;
+ grub_uint64_t prefix[2];
+} GRUB_PACKED;
+
+struct neighbour_solicit
+{
+ grub_uint32_t reserved;
+ grub_uint64_t target[2];
+} GRUB_PACKED;
+
+struct neighbour_advertise
+{
+ grub_uint32_t flags;
+ grub_uint64_t target[2];
+} GRUB_PACKED;
+
+struct router_solicit
+{
+ grub_uint32_t reserved;
+} GRUB_PACKED;
+
+enum
+ {
+ FLAG_SLAAC = 0x40
+ };
+
+enum
+ {
+ ICMP6_ECHO = 128,
+ ICMP6_ECHO_REPLY = 129,
+ ICMP6_ROUTER_SOLICIT = 133,
+ ICMP6_ROUTER_ADVERTISE = 134,
+ ICMP6_NEIGHBOUR_SOLICIT = 135,
+ ICMP6_NEIGHBOUR_ADVERTISE = 136,
+ };
+
+enum
+ {
+ OPTION_SOURCE_LINK_LAYER_ADDRESS = 1,
+ OPTION_TARGET_LINK_LAYER_ADDRESS = 2,
+ OPTION_PREFIX = 3
+ };
+
+enum
+ {
+ FLAG_SOLICITED = (1 << 30),
+ FLAG_OVERRIDE = (1 << 29)
+ };
+
+grub_err_t
+grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
+ struct grub_net_card *card,
+ struct grub_net_network_level_interface *inf,
+ const grub_net_link_level_address_t *ll_src,
+ const grub_net_network_level_address_t *source,
+ const grub_net_network_level_address_t *dest,
+ 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;
+
+ icmph = (struct icmp_header *) nb->data;
+
+ if (nb->tail - nb->data < (grub_ssize_t) sizeof (*icmph))
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ checksum = icmph->checksum;
+ icmph->checksum = 0;
+ if (checksum != grub_net_ip_transport_checksum (nb,
+ GRUB_NET_IP_ICMPV6,
+ source,
+ dest))
+ {
+ grub_dprintf ("net", "invalid ICMPv6 checksum: %04x instead of %04x\n",
+ checksum,
+ grub_net_ip_transport_checksum (nb,
+ GRUB_NET_IP_ICMPV6,
+ source,
+ dest));
+ icmph->checksum = checksum;
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ icmph->checksum = checksum;
+
+ err = grub_netbuff_pull (nb, sizeof (*icmph));
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ grub_dprintf ("net", "ICMPv6 message: %02x, %02x\n",
+ icmph->type, icmph->code);
+ switch (icmph->type)
+ {
+ case ICMP6_ECHO:
+ /* Don't accept multicast pings. */
+ if (!inf)
+ break;
+ {
+ struct grub_net_buff *nb_reply;
+ struct icmp_header *icmphr;
+ if (icmph->code)
+ break;
+ nb_reply = grub_netbuff_alloc (nb->tail - nb->data + 512);
+ 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;
+ icmphr = (struct icmp_header *) nb_reply->data;
+ icmphr->type = ICMP6_ECHO_REPLY;
+ icmphr->code = 0;
+ icmphr->checksum = 0;
+ icmphr->checksum = grub_net_ip_transport_checksum (nb_reply,
+ GRUB_NET_IP_ICMPV6,
+ &inf->address,
+ source);
+ err = grub_net_send_ip_packet (inf, source, ll_src, nb_reply,
+ GRUB_NET_IP_ICMPV6);
+
+ ping_fail:
+ grub_netbuff_free (nb);
+ grub_netbuff_free (nb_reply);
+ return err;
+ }
+ case ICMP6_NEIGHBOUR_SOLICIT:
+ {
+ struct neighbour_solicit *nbh;
+ struct grub_net_buff *nb_reply;
+ struct option_header *ohdr;
+ struct neighbour_advertise *adv;
+ struct icmp_header *icmphr;
+ grub_uint8_t *ptr;
+
+ if (icmph->code)
+ break;
+ if (ttl != 0xff)
+ break;
+ nbh = (struct neighbour_solicit *) nb->data;
+ err = grub_netbuff_pull (nb, sizeof (*nbh));
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+ for (ptr = (grub_uint8_t *) nb->data; ptr < nb->tail;
+ ptr += ohdr->len * 8)
+ {
+ ohdr = (struct option_header *) ptr;
+ if (ohdr->len == 0 || ptr + 8 * ohdr->len > nb->tail)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ if (ohdr->type == OPTION_SOURCE_LINK_LAYER_ADDRESS
+ && ohdr->len == 1)
+ {
+ grub_net_link_level_address_t ll_address;
+ ll_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ grub_memcpy (ll_address.mac, ohdr + 1, sizeof (ll_address.mac));
+ grub_net_link_layer_add_address (card, source, &ll_address, 0);
+ }
+ }
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
+ {
+ if (inf->card == card
+ && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6
+ && grub_memcmp (&inf->address.ipv6, &nbh->target, 16) == 0)
+ break;
+ }
+ if (!inf)
+ break;
+
+ nb_reply = grub_netbuff_alloc (sizeof (struct neighbour_advertise)
+ + sizeof (struct option_header)
+ + 6
+ + sizeof (struct icmp_header)
+ + GRUB_NET_OUR_IPV6_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE);
+ if (!nb_reply)
+ {
+ grub_netbuff_free (nb);
+ return grub_errno;
+ }
+ err = grub_netbuff_reserve (nb_reply,
+ sizeof (struct neighbour_advertise)
+ + sizeof (struct option_header)
+ + 6
+ + sizeof (struct icmp_header)
+ + GRUB_NET_OUR_IPV6_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE);
+ if (err)
+ goto ndp_fail;
+
+ err = grub_netbuff_push (nb_reply, 6);
+ if (err)
+ goto ndp_fail;
+ grub_memcpy (nb_reply->data, inf->hwaddress.mac, 6);
+ err = grub_netbuff_push (nb_reply, sizeof (*ohdr));
+ if (err)
+ goto ndp_fail;
+ ohdr = (struct option_header *) nb_reply->data;
+ ohdr->type = OPTION_TARGET_LINK_LAYER_ADDRESS;
+ ohdr->len = 1;
+ err = grub_netbuff_push (nb_reply, sizeof (*adv));
+ if (err)
+ goto ndp_fail;
+ adv = (struct neighbour_advertise *) nb_reply->data;
+ adv->flags = grub_cpu_to_be32_compile_time (FLAG_SOLICITED
+ | FLAG_OVERRIDE);
+ grub_memcpy (&adv->target, &nbh->target, 16);
+
+ err = grub_netbuff_push (nb_reply, sizeof (*icmphr));
+ if (err)
+ goto ndp_fail;
+ icmphr = (struct icmp_header *) nb_reply->data;
+ icmphr->type = ICMP6_NEIGHBOUR_ADVERTISE;
+ icmphr->code = 0;
+ icmphr->checksum = 0;
+ icmphr->checksum = grub_net_ip_transport_checksum (nb_reply,
+ GRUB_NET_IP_ICMPV6,
+ &inf->address,
+ source);
+ err = grub_net_send_ip_packet (inf, source, ll_src, nb_reply,
+ GRUB_NET_IP_ICMPV6);
+
+ ndp_fail:
+ grub_netbuff_free (nb);
+ grub_netbuff_free (nb_reply);
+ return err;
+ }
+ case ICMP6_NEIGHBOUR_ADVERTISE:
+ {
+ struct neighbour_advertise *nbh;
+ grub_uint8_t *ptr;
+ struct option_header *ohdr;
+
+ if (icmph->code)
+ break;
+ if (ttl != 0xff)
+ break;
+ nbh = (struct neighbour_advertise *) nb->data;
+ err = grub_netbuff_pull (nb, sizeof (*nbh));
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ for (ptr = (grub_uint8_t *) nb->data; ptr < nb->tail;
+ ptr += ohdr->len * 8)
+ {
+ ohdr = (struct option_header *) ptr;
+ if (ohdr->len == 0 || ptr + 8 * ohdr->len > nb->tail)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ if (ohdr->type == OPTION_TARGET_LINK_LAYER_ADDRESS
+ && ohdr->len == 1)
+ {
+ grub_net_link_level_address_t ll_address;
+ ll_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ grub_memcpy (ll_address.mac, ohdr + 1, sizeof (ll_address.mac));
+ grub_net_link_layer_add_address (card, source, &ll_address, 0);
+ }
+ }
+ break;
+ }
+ case ICMP6_ROUTER_ADVERTISE:
+ {
+ 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)
+ {
+ ohdr = (struct option_header *) ptr;
+ if (ohdr->len == 0 || ptr + 8 * ohdr->len > nb->tail)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ if (ohdr->type == OPTION_SOURCE_LINK_LAYER_ADDRESS
+ && ohdr->len == 1)
+ {
+ grub_net_link_level_address_t ll_address;
+ ll_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ grub_memcpy (ll_address.mac, ohdr + 1, sizeof (ll_address.mac));
+ grub_net_link_layer_add_address (card, source, &ll_address, 0);
+ }
+ if (ohdr->type == OPTION_PREFIX && ohdr->len == 4)
+ {
+ struct prefix_option *opt = (struct prefix_option *) ptr;
+ struct grub_net_slaac_mac_list *slaac;
+ if (!(opt->flags & FLAG_SLAAC)
+ || (grub_be_to_cpu64 (opt->prefix[0]) >> 48) == 0xfe80
+ || (grub_be_to_cpu32 (opt->preferred_lifetime)
+ > grub_be_to_cpu32 (opt->valid_lifetime))
+ || opt->prefixlen != 64)
+ {
+ grub_dprintf ("net", "discarded prefix: %d, %d, %d, %d\n",
+ !(opt->flags & FLAG_SLAAC),
+ (grub_be_to_cpu64 (opt->prefix[0]) >> 48) == 0xfe80,
+ (grub_be_to_cpu32 (opt->preferred_lifetime)
+ > grub_be_to_cpu32 (opt->valid_lifetime)),
+ opt->prefixlen != 64);
+ continue;
+ }
+ for (slaac = card->slaac_list; slaac; slaac = slaac->next)
+ {
+ grub_net_network_level_address_t addr;
+ grub_net_network_level_netaddress_t netaddr;
+
+ if (slaac->address.type
+ != GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET)
+ continue;
+ addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ addr.ipv6[0] = opt->prefix[0];
+ addr.ipv6[1] = grub_net_ipv6_get_id (&slaac->address);
+ netaddr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ netaddr.ipv6.base[0] = opt->prefix[0];
+ netaddr.ipv6.base[1] = 0;
+ netaddr.ipv6.masksize = 64;
+
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
+ {
+ if (inf->card == card
+ && grub_net_addr_cmp (&inf->address, &addr) == 0)
+ break;
+ }
+ /* Update lease time if needed here once we have
+ lease times. */
+ if (inf)
+ {
+ if (!route_inf)
+ route_inf = inf;
+ continue;
+ }
+
+ grub_dprintf ("net", "creating slaac\n");
+
+ {
+ char *name;
+ name = grub_xasprintf ("%s:%d",
+ slaac->name, slaac->slaac_counter++);
+ if (!name)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ 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;
+ }
+ };
+
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_net_icmp6_send_request (struct grub_net_network_level_interface *inf,
+ const grub_net_network_level_address_t *proto_addr)
+{
+ struct grub_net_buff *nb;
+ grub_err_t err = GRUB_ERR_NONE;
+ int i;
+ struct option_header *ohdr;
+ struct neighbour_solicit *sol;
+ struct icmp_header *icmphr;
+ grub_net_network_level_address_t multicast;
+ grub_net_link_level_address_t ll_multicast;
+ grub_uint8_t *nbd;
+ multicast.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ multicast.ipv6[0] = grub_be_to_cpu64_compile_time (0xff02ULL << 48);
+ multicast.ipv6[1] = (grub_be_to_cpu64_compile_time (0x01ff000000ULL)
+ | (proto_addr->ipv6[1]
+ & grub_be_to_cpu64_compile_time (0xffffff)));
+
+ err = grub_net_link_layer_resolve (inf, &multicast, &ll_multicast);
+ if (err)
+ return err;
+
+ nb = grub_netbuff_alloc (sizeof (struct neighbour_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 neighbour_solicit)
+ + sizeof (struct option_header)
+ + 6
+ + sizeof (struct icmp_header)
+ + GRUB_NET_OUR_IPV6_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE);
+ 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 neighbour_solicit *) nb->data;
+ sol->reserved = 0;
+ grub_memcpy (&sol->target, &proto_addr->ipv6, 16);
+
+ err = grub_netbuff_push (nb, sizeof (*icmphr));
+ if (err)
+ goto fail;
+
+ icmphr = (struct icmp_header *) nb->data;
+ icmphr->type = ICMP6_NEIGHBOUR_SOLICIT;
+ icmphr->code = 0;
+ icmphr->checksum = 0;
+ icmphr->checksum = grub_net_ip_transport_checksum (nb,
+ GRUB_NET_IP_ICMPV6,
+ &inf->address,
+ &multicast);
+ nbd = nb->data;
+ err = grub_net_send_ip_packet (inf, &multicast, &ll_multicast, nb,
+ GRUB_NET_IP_ICMPV6);
+ if (err)
+ goto fail;
+
+ for (i = 0; i < GRUB_NET_TRIES; i++)
+ {
+ if (grub_net_link_layer_resolve_check (inf, proto_addr))
+ break;
+ 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;
+ err = grub_net_send_ip_packet (inf, &multicast, &ll_multicast, nb,
+ GRUB_NET_IP_ICMPV6);
+ if (err)
+ break;
+ }
+
+ fail:
+ 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
new file mode 100644
index 0000000..ea5edf8
--- /dev/null
+++ b/grub-core/net/ip.c
@@ -0,0 +1,739 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net/ip.h>
+#include <grub/misc.h>
+#include <grub/net/arp.h>
+#include <grub/net/udp.h>
+#include <grub/net/ethernet.h>
+#include <grub/net.h>
+#include <grub/net/netbuff.h>
+#include <grub/mm.h>
+#include <grub/priority_queue.h>
+#include <grub/time.h>
+
+struct iphdr {
+ grub_uint8_t verhdrlen;
+ grub_uint8_t service;
+ grub_uint16_t len;
+ grub_uint16_t ident;
+ grub_uint16_t frags;
+ grub_uint8_t ttl;
+ grub_uint8_t protocol;
+ grub_uint16_t chksum;
+ grub_uint32_t src;
+ grub_uint32_t dest;
+} GRUB_PACKED ;
+
+enum
+{
+ DONT_FRAGMENT = 0x4000,
+ MORE_FRAGMENTS = 0x2000,
+ OFFSET_MASK = 0x1fff
+};
+
+typedef grub_uint64_t ip6addr[2];
+
+struct ip6hdr {
+ grub_uint32_t version_class_flow;
+ grub_uint16_t len;
+ grub_uint8_t protocol;
+ grub_uint8_t ttl;
+ ip6addr src;
+ ip6addr dest;
+} GRUB_PACKED ;
+
+static int
+cmp (const void *a__, const void *b__)
+{
+ struct grub_net_buff *a_ = *(struct grub_net_buff **) a__;
+ struct grub_net_buff *b_ = *(struct grub_net_buff **) b__;
+ struct iphdr *a = (struct iphdr *) a_->data;
+ struct iphdr *b = (struct iphdr *) b_->data;
+ /* We want the first elements to be on top. */
+ if ((grub_be_to_cpu16 (a->frags) & OFFSET_MASK)
+ < (grub_be_to_cpu16 (b->frags) & OFFSET_MASK))
+ return +1;
+ if ((grub_be_to_cpu16 (a->frags) & OFFSET_MASK)
+ > (grub_be_to_cpu16 (b->frags) & OFFSET_MASK))
+ return -1;
+ return 0;
+}
+
+struct reassemble
+{
+ struct reassemble *next;
+ grub_uint32_t source;
+ grub_uint32_t dest;
+ grub_uint16_t id;
+ grub_uint8_t proto;
+ grub_uint64_t last_time;
+ grub_priority_queue_t pq;
+ struct grub_net_buff *asm_netbuff;
+ grub_size_t total_len;
+ grub_size_t cur_ptr;
+ grub_uint8_t ttl;
+};
+
+static struct reassemble *reassembles;
+
+grub_uint16_t
+grub_net_ip_chksum (void *ipv, grub_size_t len)
+{
+ grub_uint16_t *ip = (grub_uint16_t *) ipv;
+ grub_uint32_t sum = 0;
+
+ for (; len >= 2; len -= 2)
+ {
+ sum += grub_be_to_cpu16 (grub_get_unaligned16 (ip++));
+ if (sum > 0xFFFF)
+ sum -= 0xFFFF;
+ }
+ if (len)
+ {
+ sum += *((grub_uint8_t *) ip) << 8;
+ if (sum > 0xFFFF)
+ sum -= 0xFFFF;
+ }
+
+ if (sum >= 0xFFFF)
+ sum -= 0xFFFF;
+
+ return grub_cpu_to_be16 ((~sum) & 0x0000FFFF);
+}
+
+static int id = 0x2400;
+
+static grub_err_t
+send_fragmented (struct grub_net_network_level_interface * inf,
+ const grub_net_network_level_address_t * target,
+ struct grub_net_buff * nb,
+ grub_net_ip_protocol_t proto,
+ grub_net_link_level_address_t ll_target_addr)
+{
+ grub_size_t off = 0;
+ grub_size_t fraglen;
+ grub_err_t err;
+
+ fraglen = (inf->card->mtu - sizeof (struct iphdr)) & ~7;
+ id++;
+
+ while (nb->tail - nb->data)
+ {
+ grub_size_t len = fraglen;
+ struct grub_net_buff *nb2;
+ struct iphdr *iph;
+
+ if ((grub_ssize_t) len > nb->tail - nb->data)
+ len = nb->tail - nb->data;
+ nb2 = grub_netbuff_alloc (fraglen + sizeof (struct iphdr)
+ + GRUB_NET_MAX_LINK_HEADER_SIZE);
+ if (!nb2)
+ return grub_errno;
+ err = grub_netbuff_reserve (nb2, GRUB_NET_MAX_LINK_HEADER_SIZE);
+ if (err)
+ return err;
+ err = grub_netbuff_put (nb2, sizeof (struct iphdr));
+ if (err)
+ return err;
+
+ iph = (struct iphdr *) nb2->data;
+ iph->verhdrlen = ((4 << 4) | 5);
+ iph->service = 0;
+ iph->len = grub_cpu_to_be16 (len + sizeof (struct iphdr));
+ iph->ident = grub_cpu_to_be16 (id);
+ iph->frags = grub_cpu_to_be16 (off | (((grub_ssize_t) len
+ == nb->tail - nb->data)
+ ? 0 : MORE_FRAGMENTS));
+ iph->ttl = 0xff;
+ iph->protocol = proto;
+ iph->src = inf->address.ipv4;
+ iph->dest = target->ipv4;
+ off += len / 8;
+
+ iph->chksum = 0;
+ iph->chksum = grub_net_ip_chksum ((void *) nb2->data, sizeof (*iph));
+ err = grub_netbuff_put (nb2, len);
+ if (err)
+ return err;
+ grub_memcpy (iph + 1, nb->data, len);
+ err = grub_netbuff_pull (nb, len);
+ if (err)
+ return err;
+ err = send_ethernet_packet (inf, nb2, ll_target_addr,
+ GRUB_NET_ETHERTYPE_IP);
+ if (err)
+ return err;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_net_send_ip4_packet (struct grub_net_network_level_interface *inf,
+ const grub_net_network_level_address_t *target,
+ const grub_net_link_level_address_t *ll_target_addr,
+ struct grub_net_buff *nb,
+ 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);
+
+ 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);
+ iph->ident = grub_cpu_to_be16 (++id);
+ iph->frags = 0;
+ iph->ttl = 0xff;
+ iph->protocol = proto;
+ iph->src = inf->address.ipv4;
+ iph->dest = target->ipv4;
+
+ iph->chksum = 0;
+ iph->chksum = grub_net_ip_chksum ((void *) nb->data, sizeof (*iph));
+
+ return send_ethernet_packet (inf, nb, *ll_target_addr,
+ GRUB_NET_ETHERTYPE_IP);
+}
+
+static grub_err_t
+handle_dgram (struct grub_net_buff *nb,
+ struct grub_net_card *card,
+ const grub_net_link_level_address_t *source_hwaddress,
+ const grub_net_link_level_address_t *hwaddress,
+ grub_net_ip_protocol_t proto,
+ const grub_net_network_level_address_t *source,
+ const grub_net_network_level_address_t *dest,
+ grub_uint16_t *vlantag,
+ grub_uint8_t ttl)
+{
+ struct grub_net_network_level_interface *inf = NULL;
+ grub_err_t err;
+ int multicast = 0;
+
+ /* DHCP needs special treatment since we don't know IP yet. */
+ {
+ struct udphdr *udph;
+ udph = (struct udphdr *) nb->data;
+ if (proto == GRUB_NET_IP_UDP && grub_be_to_cpu16 (udph->dst) == 68)
+ {
+ const struct grub_net_bootp_packet *bootp;
+ if (udph->chksum)
+ {
+ grub_uint16_t chk, expected;
+ chk = udph->chksum;
+ udph->chksum = 0;
+ expected = grub_net_ip_transport_checksum (nb,
+ GRUB_NET_IP_UDP,
+ source,
+ dest);
+ if (expected != chk)
+ {
+ grub_dprintf ("net", "Invalid UDP checksum. "
+ "Expected %x, got %x\n",
+ grub_be_to_cpu16 (expected),
+ grub_be_to_cpu16 (chk));
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ udph->chksum = chk;
+ }
+
+ err = grub_netbuff_pull (nb, sizeof (*udph));
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ bootp = (const struct grub_net_bootp_packet *) nb->data;
+
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
+ if (inf->card == card
+ && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV
+ && inf->hwaddress.type == GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET
+ && grub_memcmp (inf->hwaddress.mac, &bootp->mac_addr,
+ sizeof (inf->hwaddress.mac)) == 0)
+ {
+ grub_net_process_dhcp (nb, inf);
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ }
+
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
+ {
+ if (inf->card == card
+ && grub_net_addr_cmp (&inf->address, dest) == 0
+ && grub_net_hwaddr_cmp (&inf->hwaddress, hwaddress) == 0)
+ break;
+
+ /* Verify vlantag id */
+ if (inf->card == card && inf->vlantag != *vlantag)
+ {
+ grub_dprintf ("net", "invalid vlantag! %x != %x\n",
+ inf->vlantag, *vlantag);
+ break;
+ }
+
+ /* Solicited node multicast. */
+ if (inf->card == card
+ && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6
+ && dest->type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6
+ && dest->ipv6[0] == grub_be_to_cpu64_compile_time (0xff02ULL << 48)
+ && dest->ipv6[1] == (grub_be_to_cpu64_compile_time (0x01ff000000ULL)
+ | (inf->address.ipv6[1]
+ & grub_be_to_cpu64_compile_time (0xffffff)))
+ && hwaddress->type == GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET
+ && hwaddress->mac[0] == 0x33 && hwaddress->mac[1] == 0x33
+ && hwaddress->mac[2] == 0xff
+ && hwaddress->mac[3] == ((grub_be_to_cpu64 (inf->address.ipv6[1])
+ >> 16) & 0xff)
+ && hwaddress->mac[4] == ((grub_be_to_cpu64 (inf->address.ipv6[1])
+ >> 8) & 0xff)
+ && hwaddress->mac[5] == ((grub_be_to_cpu64 (inf->address.ipv6[1])
+ >> 0) & 0xff))
+ {
+ multicast = 1;
+ break;
+ }
+ }
+
+ if (!inf && !(dest->type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6
+ && dest->ipv6[0] == grub_be_to_cpu64_compile_time (0xff02ULL
+ << 48)
+ && dest->ipv6[1] == grub_be_to_cpu64_compile_time (1)))
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ if (multicast)
+ inf = NULL;
+
+ switch (proto)
+ {
+ case GRUB_NET_IP_UDP:
+ return grub_net_recv_udp_packet (nb, inf, source);
+ case GRUB_NET_IP_TCP:
+ return grub_net_recv_tcp_packet (nb, inf, source);
+ case GRUB_NET_IP_ICMP:
+ return grub_net_recv_icmp_packet (nb, inf, source_hwaddress, source);
+ case GRUB_NET_IP_ICMPV6:
+ return grub_net_recv_icmp6_packet (nb, card, inf, source_hwaddress,
+ source, dest, ttl);
+ default:
+ grub_netbuff_free (nb);
+ break;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static void
+free_rsm (struct reassemble *rsm)
+{
+ struct grub_net_buff **nb;
+ while ((nb = grub_priority_queue_top (rsm->pq)))
+ {
+ grub_netbuff_free (*nb);
+ grub_priority_queue_pop (rsm->pq);
+ }
+ grub_netbuff_free (rsm->asm_netbuff);
+ grub_priority_queue_destroy (rsm->pq);
+ grub_free (rsm);
+}
+
+static void
+free_old_fragments (void)
+{
+ struct reassemble *rsm, **prev;
+ grub_uint64_t limit_time = grub_get_time_ms ();
+
+ limit_time = (limit_time > 90000) ? limit_time - 90000 : 0;
+
+ for (prev = &reassembles, rsm = *prev; rsm; rsm = *prev)
+ if (rsm->last_time < limit_time)
+ {
+ *prev = rsm->next;
+ free_rsm (rsm);
+ }
+ else
+ {
+ prev = &rsm->next;
+ }
+}
+
+static grub_err_t
+grub_net_recv_ip4_packets (struct grub_net_buff *nb,
+ struct grub_net_card *card,
+ const grub_net_link_level_address_t *hwaddress,
+ const grub_net_link_level_address_t *src_hwaddress,
+ grub_uint16_t *vlantag)
+{
+ struct iphdr *iph = (struct iphdr *) nb->data;
+ grub_err_t err;
+ struct reassemble *rsm, **prev;
+
+ if ((iph->verhdrlen >> 4) != 4)
+ {
+ grub_dprintf ("net", "Bad IP version: %d\n", (iph->verhdrlen >> 4));
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ if ((iph->verhdrlen & 0xf) < 5)
+ {
+ grub_dprintf ("net", "IP header too short: %d\n",
+ (iph->verhdrlen & 0xf));
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ if (nb->tail - nb->data < (grub_ssize_t) ((iph->verhdrlen & 0xf)
+ * sizeof (grub_uint32_t)))
+ {
+ grub_dprintf ("net", "IP packet too short: %" PRIdGRUB_SSIZE "\n",
+ (grub_ssize_t) (nb->tail - nb->data));
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ /* Check size. */
+ {
+ grub_size_t expected_size = grub_be_to_cpu16 (iph->len);
+ grub_size_t actual_size = (nb->tail - nb->data);
+ if (actual_size > expected_size)
+ {
+ err = grub_netbuff_unput (nb, actual_size - expected_size);
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+ }
+ if (actual_size < expected_size)
+ {
+ grub_dprintf ("net", "Cut IP packet actual: %" PRIuGRUB_SIZE
+ ", expected %" PRIuGRUB_SIZE "\n", actual_size,
+ expected_size);
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ }
+
+ /* Unfragmented packet. Good. */
+ if (((grub_be_to_cpu16 (iph->frags) & MORE_FRAGMENTS) == 0)
+ && (grub_be_to_cpu16 (iph->frags) & OFFSET_MASK) == 0)
+ {
+ grub_net_network_level_address_t source;
+ grub_net_network_level_address_t dest;
+
+ err = grub_netbuff_pull (nb, ((iph->verhdrlen & 0xf)
+ * sizeof (grub_uint32_t)));
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ source.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ source.ipv4 = iph->src;
+
+ dest.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ dest.ipv4 = iph->dest;
+
+ return handle_dgram (nb, card, src_hwaddress, hwaddress, iph->protocol,
+ &source, &dest, vlantag, iph->ttl);
+ }
+
+ for (prev = &reassembles, rsm = *prev; rsm; prev = &rsm->next, rsm = *prev)
+ if (rsm->source == iph->src && rsm->dest == iph->dest
+ && rsm->id == iph->ident && rsm->proto == iph->protocol)
+ break;
+ if (!rsm)
+ {
+ rsm = grub_malloc (sizeof (*rsm));
+ if (!rsm)
+ return grub_errno;
+ rsm->source = iph->src;
+ rsm->dest = iph->dest;
+ rsm->id = iph->ident;
+ rsm->proto = iph->protocol;
+ rsm->next = reassembles;
+ reassembles = rsm;
+ prev = &reassembles;
+ rsm->pq = grub_priority_queue_new (sizeof (struct grub_net_buff **), cmp);
+ if (!rsm->pq)
+ {
+ grub_free (rsm);
+ return grub_errno;
+ }
+ rsm->asm_netbuff = 0;
+ rsm->total_len = 0;
+ rsm->cur_ptr = 0;
+ rsm->ttl = 0xff;
+ }
+ if (rsm->ttl > iph->ttl)
+ rsm->ttl = iph->ttl;
+ rsm->last_time = grub_get_time_ms ();
+ free_old_fragments ();
+
+ err = grub_priority_queue_push (rsm->pq, &nb);
+ if (err)
+ return err;
+
+ if (!(grub_be_to_cpu16 (iph->frags) & MORE_FRAGMENTS))
+ {
+ rsm->total_len = (8 * (grub_be_to_cpu16 (iph->frags) & OFFSET_MASK)
+ + (nb->tail - nb->data));
+ rsm->total_len -= ((iph->verhdrlen & 0xf) * sizeof (grub_uint32_t));
+ rsm->asm_netbuff = grub_netbuff_alloc (rsm->total_len);
+ if (!rsm->asm_netbuff)
+ {
+ *prev = rsm->next;
+ free_rsm (rsm);
+ return grub_errno;
+ }
+ }
+ if (!rsm->asm_netbuff)
+ return GRUB_ERR_NONE;
+
+ while (1)
+ {
+ struct grub_net_buff **nb_top_p, *nb_top;
+ grub_size_t copy;
+ grub_size_t res_len;
+ struct grub_net_buff *ret;
+ grub_net_ip_protocol_t proto;
+ grub_uint32_t src;
+ grub_uint32_t dst;
+ grub_net_network_level_address_t source;
+ grub_net_network_level_address_t dest;
+ grub_uint8_t ttl;
+
+ nb_top_p = grub_priority_queue_top (rsm->pq);
+ if (!nb_top_p)
+ return GRUB_ERR_NONE;
+ nb_top = *nb_top_p;
+ grub_priority_queue_pop (rsm->pq);
+ iph = (struct iphdr *) nb_top->data;
+ err = grub_netbuff_pull (nb_top, ((iph->verhdrlen & 0xf)
+ * sizeof (grub_uint32_t)));
+ if (err)
+ {
+ grub_netbuff_free (nb_top);
+ return err;
+ }
+ if (rsm->cur_ptr < (grub_size_t) 8 * (grub_be_to_cpu16 (iph->frags)
+ & OFFSET_MASK))
+ {
+ grub_netbuff_free (nb_top);
+ return GRUB_ERR_NONE;
+ }
+
+ rsm->cur_ptr = (8 * (grub_be_to_cpu16 (iph->frags) & OFFSET_MASK)
+ + (nb_top->tail - nb_top->head));
+ if ((grub_size_t) 8 * (grub_be_to_cpu16 (iph->frags) & OFFSET_MASK)
+ >= rsm->total_len)
+ {
+ grub_netbuff_free (nb_top);
+ continue;
+ }
+ copy = nb_top->tail - nb_top->data;
+ if (rsm->total_len - 8 * (grub_be_to_cpu16 (iph->frags) & OFFSET_MASK)
+ < copy)
+ copy = rsm->total_len - 8 * (grub_be_to_cpu16 (iph->frags)
+ & OFFSET_MASK);
+ grub_memcpy (&rsm->asm_netbuff->data[8 * (grub_be_to_cpu16 (iph->frags)
+ & OFFSET_MASK)],
+ nb_top->data, copy);
+
+ if ((grub_be_to_cpu16 (iph->frags) & MORE_FRAGMENTS))
+ {
+ grub_netbuff_free (nb_top);
+ continue;
+ }
+ grub_netbuff_free (nb_top);
+
+ ret = rsm->asm_netbuff;
+ proto = rsm->proto;
+ src = rsm->source;
+ dst = rsm->dest;
+ ttl = rsm->ttl;
+
+ rsm->asm_netbuff = 0;
+ res_len = rsm->total_len;
+ *prev = rsm->next;
+ free_rsm (rsm);
+
+ if (grub_netbuff_put (ret, res_len))
+ {
+ grub_netbuff_free (ret);
+ return GRUB_ERR_NONE;
+ }
+
+ source.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ source.ipv4 = src;
+
+ dest.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ dest.ipv4 = dst;
+
+ return handle_dgram (ret, card, src_hwaddress,
+ hwaddress, proto, &source, &dest, vlantag,
+ ttl);
+ }
+}
+
+static grub_err_t
+grub_net_send_ip6_packet (struct grub_net_network_level_interface *inf,
+ const grub_net_network_level_address_t *target,
+ const grub_net_link_level_address_t *ll_target_addr,
+ struct grub_net_buff *nb,
+ 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");
+
+ err = grub_netbuff_push (nb, sizeof (*iph));
+ if (err)
+ return err;
+
+ 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;
+ grub_memcpy (&iph->src, inf->address.ipv6, sizeof (iph->src));
+ grub_memcpy (&iph->dest, target->ipv6, sizeof (iph->dest));
+
+ return send_ethernet_packet (inf, nb, *ll_target_addr,
+ GRUB_NET_ETHERTYPE_IP6);
+}
+
+grub_err_t
+grub_net_send_ip_packet (struct grub_net_network_level_interface *inf,
+ const grub_net_network_level_address_t *target,
+ const grub_net_link_level_address_t *ll_target_addr,
+ struct grub_net_buff *nb,
+ grub_net_ip_protocol_t proto)
+{
+ switch (target->type)
+ {
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
+ return grub_net_send_ip4_packet (inf, target, ll_target_addr, nb, proto);
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
+ return grub_net_send_ip6_packet (inf, target, ll_target_addr, nb, proto);
+ default:
+ return grub_error (GRUB_ERR_BUG, "not an IP");
+ }
+}
+
+static grub_err_t
+grub_net_recv_ip6_packets (struct grub_net_buff *nb,
+ struct grub_net_card *card,
+ const grub_net_link_level_address_t *hwaddress,
+ const grub_net_link_level_address_t *src_hwaddress,
+ grub_uint16_t *vlantag)
+{
+ struct ip6hdr *iph = (struct ip6hdr *) nb->data;
+ grub_err_t err;
+ grub_net_network_level_address_t source;
+ grub_net_network_level_address_t dest;
+
+ if (nb->tail - nb->data < (grub_ssize_t) sizeof (*iph))
+ {
+ grub_dprintf ("net", "IP packet too short: %" PRIdGRUB_SSIZE "\n",
+ (grub_ssize_t) (nb->tail - nb->data));
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ err = grub_netbuff_pull (nb, sizeof (*iph));
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ /* Check size. */
+ {
+ grub_size_t expected_size = grub_be_to_cpu16 (iph->len);
+ grub_size_t actual_size = (nb->tail - nb->data);
+ if (actual_size > expected_size)
+ {
+ err = grub_netbuff_unput (nb, actual_size - expected_size);
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+ }
+ if (actual_size < expected_size)
+ {
+ grub_dprintf ("net", "Cut IP packet actual: %" PRIuGRUB_SIZE
+ ", expected %" PRIuGRUB_SIZE "\n", actual_size,
+ expected_size);
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ }
+
+ source.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ dest.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ grub_memcpy (source.ipv6, &iph->src, sizeof (source.ipv6));
+ grub_memcpy (dest.ipv6, &iph->dest, sizeof (dest.ipv6));
+
+ return handle_dgram (nb, card, src_hwaddress, hwaddress, iph->protocol,
+ &source, &dest, vlantag, iph->ttl);
+}
+
+grub_err_t
+grub_net_recv_ip_packets (struct grub_net_buff *nb,
+ struct grub_net_card *card,
+ const grub_net_link_level_address_t *hwaddress,
+ const grub_net_link_level_address_t *src_hwaddress,
+ grub_uint16_t *vlantag)
+{
+ struct iphdr *iph = (struct iphdr *) nb->data;
+
+ if ((iph->verhdrlen >> 4) == 4)
+ return grub_net_recv_ip4_packets (nb, card, hwaddress, src_hwaddress,
+ vlantag);
+ if ((iph->verhdrlen >> 4) == 6)
+ return grub_net_recv_ip6_packets (nb, card, hwaddress, src_hwaddress,
+ vlantag);
+ grub_dprintf ("net", "Bad IP version: %d\n", (iph->verhdrlen >> 4));
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
new file mode 100644
index 0000000..4d3eb5c
--- /dev/null
+++ b/grub-core/net/net.c
@@ -0,0 +1,1952 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011,2012,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/net.h>
+#include <grub/net/netbuff.h>
+#include <grub/time.h>
+#include <grub/file.h>
+#include <grub/i18n.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/env.h>
+#include <grub/net/ethernet.h>
+#include <grub/net/arp.h>
+#include <grub/net/ip.h>
+#include <grub/loader.h>
+#include <grub/bufio.h>
+#include <grub/kernel.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+char *grub_net_default_server;
+
+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;
+struct grub_net_network_level_protocol *grub_net_network_level_protocols = NULL;
+static struct grub_fs grub_net_fs;
+
+struct grub_net_link_layer_entry {
+ int avail;
+ grub_net_network_level_address_t nl_address;
+ grub_net_link_level_address_t ll_address;
+};
+
+#define LINK_LAYER_CACHE_SIZE 256
+
+static struct grub_net_link_layer_entry *
+link_layer_find_entry (const grub_net_network_level_address_t *proto,
+ const struct grub_net_card *card)
+{
+ unsigned i;
+ if (!card->link_layer_table)
+ return NULL;
+ for (i = 0; i < LINK_LAYER_CACHE_SIZE; i++)
+ {
+ if (card->link_layer_table[i].avail == 1
+ && grub_net_addr_cmp (&card->link_layer_table[i].nl_address,
+ proto) == 0)
+ return &card->link_layer_table[i];
+ }
+ return NULL;
+}
+
+void
+grub_net_link_layer_add_address (struct grub_net_card *card,
+ const grub_net_network_level_address_t *nl,
+ const grub_net_link_level_address_t *ll,
+ int override)
+{
+ struct grub_net_link_layer_entry *entry;
+
+ /* Check if the sender is in the cache table. */
+ entry = link_layer_find_entry (nl, card);
+ /* Update sender hardware address. */
+ if (entry && override)
+ grub_memcpy (&entry->ll_address, ll, sizeof (entry->ll_address));
+ if (entry)
+ return;
+
+ /* Add sender to cache table. */
+ if (card->link_layer_table == NULL)
+ {
+ card->link_layer_table = grub_zalloc (LINK_LAYER_CACHE_SIZE
+ * sizeof (card->link_layer_table[0]));
+ if (card->link_layer_table == NULL)
+ return;
+ }
+
+ entry = &(card->link_layer_table[card->new_ll_entry]);
+ entry->avail = 1;
+ grub_memcpy (&entry->ll_address, ll, sizeof (entry->ll_address));
+ grub_memcpy (&entry->nl_address, nl, sizeof (entry->nl_address));
+ card->new_ll_entry++;
+ if (card->new_ll_entry == LINK_LAYER_CACHE_SIZE)
+ card->new_ll_entry = 0;
+}
+
+int
+grub_net_link_layer_resolve_check (struct grub_net_network_level_interface *inf,
+ const grub_net_network_level_address_t *proto_addr)
+{
+ struct grub_net_link_layer_entry *entry;
+
+ if (proto_addr->type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
+ && proto_addr->ipv4 == 0xffffffff)
+ return 1;
+ entry = link_layer_find_entry (proto_addr, inf->card);
+ if (entry)
+ return 1;
+ return 0;
+}
+
+grub_err_t
+grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf,
+ const grub_net_network_level_address_t *proto_addr,
+ grub_net_link_level_address_t *hw_addr)
+{
+ struct grub_net_link_layer_entry *entry;
+ grub_err_t err;
+
+ if ((proto_addr->type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
+ && proto_addr->ipv4 == 0xffffffff)
+ || proto_addr->type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV
+ || (proto_addr->type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6
+ && proto_addr->ipv6[0] == grub_be_to_cpu64_compile_time (0xff02ULL
+ << 48)
+ && proto_addr->ipv6[1] == (grub_be_to_cpu64_compile_time (1))))
+ {
+ hw_addr->type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ grub_memset (hw_addr->mac, -1, 6);
+ return GRUB_ERR_NONE;
+ }
+
+ if (proto_addr->type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6
+ && ((grub_be_to_cpu64 (proto_addr->ipv6[0]) >> 56) == 0xff))
+ {
+ hw_addr->type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ hw_addr->mac[0] = 0x33;
+ hw_addr->mac[1] = 0x33;
+ hw_addr->mac[2] = ((grub_be_to_cpu64 (proto_addr->ipv6[1]) >> 24) & 0xff);
+ hw_addr->mac[3] = ((grub_be_to_cpu64 (proto_addr->ipv6[1]) >> 16) & 0xff);
+ hw_addr->mac[4] = ((grub_be_to_cpu64 (proto_addr->ipv6[1]) >> 8) & 0xff);
+ hw_addr->mac[5] = ((grub_be_to_cpu64 (proto_addr->ipv6[1]) >> 0) & 0xff);
+ return GRUB_ERR_NONE;
+ }
+
+ /* Check cache table. */
+ entry = link_layer_find_entry (proto_addr, inf->card);
+ if (entry)
+ {
+ *hw_addr = entry->ll_address;
+ return GRUB_ERR_NONE;
+ }
+ switch (proto_addr->type)
+ {
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
+ err = grub_net_arp_send_request (inf, proto_addr);
+ break;
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
+ err = grub_net_icmp6_send_request (inf, proto_addr);
+ break;
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
+ return grub_error (GRUB_ERR_BUG, "shouldn't reach here");
+ default:
+ return grub_error (GRUB_ERR_BUG,
+ "unsupported address type %d", proto_addr->type);
+ }
+ if (err)
+ return err;
+ entry = link_layer_find_entry (proto_addr, inf->card);
+ if (entry)
+ {
+ *hw_addr = entry->ll_address;
+ return GRUB_ERR_NONE;
+ }
+ return grub_error (GRUB_ERR_TIMEOUT,
+ N_("timeout: could not resolve hardware address"));
+}
+
+void
+grub_net_card_unregister (struct grub_net_card *card)
+{
+ struct grub_net_network_level_interface *inf, *next;
+ FOR_NET_NETWORK_LEVEL_INTERFACES_SAFE(inf, next)
+ if (inf->card == card)
+ grub_net_network_level_interface_unregister (inf);
+ if (card->opened)
+ {
+ if (card->driver->close)
+ card->driver->close (card);
+ card->opened = 0;
+ }
+ grub_list_remove (GRUB_AS_LIST (card));
+}
+
+static struct grub_net_slaac_mac_list *
+grub_net_ipv6_get_slaac (struct grub_net_card *card,
+ const grub_net_link_level_address_t *hwaddr)
+{
+ struct grub_net_slaac_mac_list *slaac;
+ char *ptr;
+
+ for (slaac = card->slaac_list; slaac; slaac = slaac->next)
+ if (grub_net_hwaddr_cmp (&slaac->address, hwaddr) == 0)
+ return slaac;
+
+ slaac = grub_zalloc (sizeof (*slaac));
+ if (!slaac)
+ return NULL;
+
+ slaac->name = grub_malloc (grub_strlen (card->name)
+ + GRUB_NET_MAX_STR_HWADDR_LEN
+ + sizeof (":slaac"));
+ ptr = grub_stpcpy (slaac->name, card->name);
+ if (grub_net_hwaddr_cmp (&card->default_address, hwaddr) != 0)
+ {
+ ptr = grub_stpcpy (ptr, ":");
+ grub_net_hwaddr_to_str (hwaddr, ptr);
+ ptr += grub_strlen (ptr);
+ }
+ ptr = grub_stpcpy (ptr, ":slaac");
+
+ grub_memcpy (&slaac->address, hwaddr, sizeof (slaac->address));
+ slaac->next = card->slaac_list;
+ card->slaac_list = slaac;
+ return slaac;
+}
+
+static void
+grub_net_network_level_interface_register (struct grub_net_network_level_interface *inter);
+
+static struct grub_net_network_level_interface *
+grub_net_add_addr_real (char *name,
+ struct grub_net_card *card,
+ const grub_net_network_level_address_t *addr,
+ const grub_net_link_level_address_t *hwaddress,
+ grub_net_interface_flags_t flags)
+{
+ struct grub_net_network_level_interface *inter;
+
+ inter = grub_zalloc (sizeof (*inter));
+ if (!inter)
+ return NULL;
+
+ inter->name = name;
+ grub_memcpy (&(inter->address), addr, sizeof (inter->address));
+ grub_memcpy (&(inter->hwaddress), hwaddress, sizeof (inter->hwaddress));
+ inter->flags = flags;
+ inter->card = card;
+ inter->dhcp_ack = NULL;
+ inter->dhcp_acklen = 0;
+
+ grub_net_network_level_interface_register (inter);
+
+ return inter;
+}
+
+struct grub_net_network_level_interface *
+grub_net_add_addr (const char *name,
+ struct grub_net_card *card,
+ const grub_net_network_level_address_t *addr,
+ const grub_net_link_level_address_t *hwaddress,
+ grub_net_interface_flags_t flags)
+{
+ char *name_dup = grub_strdup (name);
+ struct grub_net_network_level_interface *ret;
+
+ if (!name_dup)
+ return NULL;
+ ret = grub_net_add_addr_real (name_dup, card, addr, hwaddress, flags);
+ if (!ret)
+ grub_free (name_dup);
+ return ret;
+}
+
+struct grub_net_network_level_interface *
+grub_net_ipv6_get_link_local (struct grub_net_card *card,
+ const grub_net_link_level_address_t *hwaddr)
+{
+ struct grub_net_network_level_interface *inf;
+ char *name;
+ char *ptr;
+ grub_net_network_level_address_t addr;
+
+ addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ 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)
+ {
+ if (inf->card == card
+ && grub_net_hwaddr_cmp (&inf->hwaddress, hwaddr) == 0
+ && grub_net_addr_cmp (&inf->address, &addr) == 0)
+ 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)
+ {
+ ptr = grub_stpcpy (ptr, ":");
+ grub_net_hwaddr_to_str (hwaddr, ptr);
+ ptr += grub_strlen (ptr);
+ }
+ ptr = grub_stpcpy (ptr, ":link");
+ return grub_net_add_addr_real (name, card, &addr, hwaddr, 0);
+}
+
+/* FIXME: allow to specify mac address. */
+static grub_err_t
+grub_cmd_ipv6_autoconf (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_net_card *card;
+ struct grub_net_network_level_interface **ifaces;
+ grub_size_t ncards = 0;
+ unsigned j = 0;
+ int interval;
+ grub_err_t err;
+ struct grub_net_slaac_mac_list **slaacs;
+
+ FOR_NET_CARDS (card)
+ {
+ if (argc > 0 && grub_strcmp (card->name, args[0]) != 0)
+ continue;
+ ncards++;
+ }
+
+ ifaces = grub_calloc (ncards, sizeof (ifaces[0]));
+ slaacs = grub_calloc (ncards, sizeof (slaacs[0]));
+ if (!ifaces || !slaacs)
+ {
+ grub_free (ifaces);
+ grub_free (slaacs);
+ return grub_errno;
+ }
+
+ FOR_NET_CARDS (card)
+ {
+ if (argc > 0 && grub_strcmp (card->name, args[0]) != 0)
+ continue;
+ ifaces[j] = grub_net_ipv6_get_link_local (card, &card->default_address);
+ if (!ifaces[j])
+ {
+ grub_free (ifaces);
+ grub_free (slaacs);
+ return grub_errno;
+ }
+ slaacs[j] = grub_net_ipv6_get_slaac (card, &card->default_address);
+ if (!slaacs[j])
+ {
+ grub_free (ifaces);
+ grub_free (slaacs);
+ return grub_errno;
+ }
+ j++;
+ }
+
+ for (interval = 200; interval < 10000; interval *= 2)
+ {
+ 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)
+ break;
+ grub_net_poll_cards (interval, 0);
+ }
+
+ err = GRUB_ERR_NONE;
+ for (j = 0; j < ncards; j++)
+ {
+ if (slaacs[j]->slaac_counter)
+ continue;
+ err = grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ N_("couldn't autoconfigure %s"),
+ ifaces[j]->card->name);
+ }
+
+ grub_free (ifaces);
+ grub_free (slaacs);
+ return err;
+}
+
+
+static int
+parse_ip (const char *val, grub_uint32_t *ip, const char **rest)
+{
+ grub_uint32_t newip = 0;
+ int i;
+ const char *ptr = val;
+
+ for (i = 0; i < 4; i++)
+ {
+ unsigned long t;
+ t = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+ if (*ptr != '.' && i == 0)
+ {
+ newip = t;
+ break;
+ }
+ if (t & ~0xff)
+ return 0;
+ newip >>= 8;
+ newip |= (t << 24);
+ if (i != 3 && *ptr != '.')
+ return 0;
+ ptr++;
+ }
+ *ip = grub_cpu_to_le32 (newip);
+ if (rest)
+ *rest = (ptr - 1);
+ return 1;
+}
+
+static int
+parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest)
+{
+ grub_uint16_t newip[8];
+ const char *ptr = val;
+ int word, quaddot = -1;
+
+ if (ptr[0] == ':' && ptr[1] != ':')
+ return 0;
+ if (ptr[0] == ':')
+ ptr++;
+
+ for (word = 0; word < 8; word++)
+ {
+ unsigned long t;
+ if (*ptr == ':')
+ {
+ quaddot = word;
+ word--;
+ ptr++;
+ continue;
+ }
+ t = grub_strtoul (ptr, &ptr, 16);
+ if (grub_errno)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ break;
+ }
+ if (t & ~0xffff)
+ return 0;
+ newip[word] = grub_cpu_to_be16 (t);
+ if (*ptr != ':')
+ break;
+ ptr++;
+ }
+ if (quaddot == -1 && word < 7)
+ return 0;
+ if (quaddot != -1)
+ {
+ grub_memmove (&newip[quaddot + 7 - word], &newip[quaddot],
+ (word - quaddot + 1) * sizeof (newip[0]));
+ grub_memset (&newip[quaddot], 0, (7 - word) * sizeof (newip[0]));
+ }
+ grub_memcpy (ip, newip, 16);
+ if (rest)
+ *rest = ptr;
+ return 1;
+}
+
+static int
+match_net (const grub_net_network_level_netaddress_t *net,
+ const grub_net_network_level_address_t *addr)
+{
+ if (net->type != addr->type)
+ return 0;
+ switch (net->type)
+ {
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
+ return 0;
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
+ {
+ grub_uint32_t mask = (0xffffffffU << (32 - net->ipv4.masksize));
+ if (net->ipv4.masksize == 0)
+ mask = 0;
+ return ((grub_be_to_cpu32 (net->ipv4.base) & mask)
+ == (grub_be_to_cpu32 (addr->ipv4) & mask));
+ }
+ 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);
+ mask[1] = 0;
+ }
+ else
+ {
+ mask[0] = 0xffffffffffffffffULL;
+ mask[1] = 0xffffffffffffffffULL << (128 - net->ipv6.masksize);
+ }
+ return (((grub_be_to_cpu64 (net->ipv6.base[0]) & mask[0])
+ == (grub_be_to_cpu64 (addr->ipv6[0]) & mask[0]))
+ && ((grub_be_to_cpu64 (net->ipv6.base[1]) & mask[1])
+ == (grub_be_to_cpu64 (addr->ipv6[1]) & mask[1])));
+ }
+ }
+ return 0;
+}
+
+grub_err_t
+grub_net_resolve_address (const char *name,
+ grub_net_network_level_address_t *addr)
+{
+ const char *rest;
+ grub_err_t err;
+ grub_size_t naddresses;
+ struct grub_net_network_level_address *addresses = 0;
+
+ if (parse_ip (name, &addr->ipv4, &rest) && *rest == 0)
+ {
+ addr->type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ return GRUB_ERR_NONE;
+ }
+ if (parse_ip6 (name, addr->ipv6, &rest) && *rest == 0)
+ {
+ addr->type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ return GRUB_ERR_NONE;
+ }
+ err = grub_net_dns_lookup (name, 0, 0, &naddresses, &addresses, 1);
+ if (err)
+ return err;
+ if (!naddresses)
+ grub_error (GRUB_ERR_NET_BAD_ADDRESS, N_("unresolvable address %s"),
+ name);
+ /* FIXME: use other results as well. */
+ *addr = addresses[0];
+ grub_free (addresses);
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_net_resolve_net_address (const char *name,
+ grub_net_network_level_netaddress_t *addr)
+{
+ const char *rest;
+ if (parse_ip (name, &addr->ipv4.base, &rest))
+ {
+ addr->type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ if (*rest == '/')
+ {
+ addr->ipv4.masksize = grub_strtoul (rest + 1, &rest, 0);
+ if (!grub_errno && *rest == 0)
+ return GRUB_ERR_NONE;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ else if (*rest == 0)
+ {
+ addr->ipv4.masksize = 32;
+ return GRUB_ERR_NONE;
+ }
+ }
+ if (parse_ip6 (name, addr->ipv6.base, &rest))
+ {
+ addr->type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ if (*rest == '/')
+ {
+ addr->ipv6.masksize = grub_strtoul (rest + 1, &rest, 0);
+ if (!grub_errno && *rest == 0)
+ return GRUB_ERR_NONE;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ else if (*rest == 0)
+ {
+ addr->ipv6.masksize = 128;
+ return GRUB_ERR_NONE;
+ }
+ }
+ return grub_error (GRUB_ERR_NET_BAD_ADDRESS,
+ N_("unrecognised network address `%s'"),
+ name);
+}
+
+static int
+route_cmp (const struct grub_net_route *a, const struct grub_net_route *b)
+{
+ if (a == NULL && b == NULL)
+ return 0;
+ if (b == NULL)
+ return +1;
+ if (a == NULL)
+ return -1;
+ if (a->target.type < b->target.type)
+ return -1;
+ if (a->target.type > b->target.type)
+ return +1;
+ switch (a->target.type)
+ {
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
+ break;
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
+ if (a->target.ipv6.masksize > b->target.ipv6.masksize)
+ return +1;
+ if (a->target.ipv6.masksize < b->target.ipv6.masksize)
+ return -1;
+ break;
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
+ if (a->target.ipv4.masksize > b->target.ipv4.masksize)
+ return +1;
+ if (a->target.ipv4.masksize < b->target.ipv4.masksize)
+ return -1;
+ break;
+ }
+ return 0;
+}
+
+grub_err_t
+grub_net_route_address (grub_net_network_level_address_t addr,
+ grub_net_network_level_address_t *gateway,
+ struct grub_net_network_level_interface **interf)
+{
+ struct grub_net_route *route;
+ unsigned int depth = 0;
+ unsigned int routecnt = 0;
+ struct grub_net_network_level_protocol *prot = NULL;
+ grub_net_network_level_address_t curtarget = addr;
+
+ *gateway = addr;
+
+ FOR_NET_ROUTES(route)
+ routecnt++;
+
+ for (depth = 0; depth < routecnt + 2 && depth < GRUB_UINT_MAX; depth++)
+ {
+ struct grub_net_route *bestroute = NULL;
+ FOR_NET_ROUTES(route)
+ {
+ if (depth && prot != route->prot)
+ continue;
+ if (!match_net (&route->target, &curtarget))
+ continue;
+ if (route_cmp (route, bestroute) > 0)
+ bestroute = route;
+ }
+ if (bestroute == NULL)
+ return grub_error (GRUB_ERR_NET_NO_ROUTE,
+ N_("destination unreachable"));
+
+ if (!bestroute->is_gateway)
+ {
+ *interf = bestroute->interface;
+ return GRUB_ERR_NONE;
+ }
+ if (depth == 0)
+ {
+ *gateway = bestroute->gw;
+ if (bestroute->interface != NULL)
+ {
+ *interf = bestroute->interface;
+ return GRUB_ERR_NONE;
+ }
+ }
+ curtarget = bestroute->gw;
+ }
+
+ return grub_error (GRUB_ERR_NET_ROUTE_LOOP,
+ /* TRANSLATORS: route loop is a condition when e.g.
+ to contact server A you need to go through B
+ and to contact B you need to go through A. */
+ N_("route loop detected"));
+}
+
+static grub_err_t
+grub_cmd_deladdr (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_net_network_level_interface *inter;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inter)
+ if (grub_strcmp (inter->name, args[0]) == 0)
+ break;
+ if (inter == NULL)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("address not found"));
+
+ if (inter->flags & GRUB_NET_INTERFACE_PERMANENT)
+ return grub_error (GRUB_ERR_IO,
+ N_("you can't delete this address"));
+
+ grub_net_network_level_interface_unregister (inter);
+ grub_free (inter->name);
+ grub_free (inter);
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf)
+{
+ switch (target->type)
+ {
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
+ COMPILE_TIME_ASSERT (sizeof ("temporary") < GRUB_NET_MAX_STR_ADDR_LEN);
+ grub_strcpy (buf, "temporary");
+ return;
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
+ {
+ char *ptr = buf;
+ grub_uint64_t n = grub_be_to_cpu64 (target->ipv6[0]);
+ int i;
+ for (i = 0; i < 4; i++)
+ {
+ grub_snprintf (ptr, 6, "%" PRIxGRUB_UINT64_T ":",
+ (n >> (48 - 16 * i)) & 0xffff);
+ ptr += grub_strlen (ptr);
+ }
+ n = grub_be_to_cpu64 (target->ipv6[1]);
+ for (i = 0; i < 3; i++)
+ {
+ grub_snprintf (ptr, 6, "%" PRIxGRUB_UINT64_T ":",
+ (n >> (48 - 16 * i)) & 0xffff);
+ ptr += grub_strlen (ptr);
+ }
+ grub_snprintf (ptr, 5, "%" PRIxGRUB_UINT64_T, n & 0xffff);
+ return;
+ }
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
+ {
+ grub_uint32_t n = grub_be_to_cpu32 (target->ipv4);
+ grub_snprintf (buf, GRUB_NET_MAX_STR_ADDR_LEN, "%d.%d.%d.%d",
+ ((n >> 24) & 0xff), ((n >> 16) & 0xff),
+ ((n >> 8) & 0xff), ((n >> 0) & 0xff));
+ }
+ return;
+ }
+ grub_snprintf (buf, GRUB_NET_MAX_STR_ADDR_LEN,
+ "Unknown address type %d", target->type);
+}
+
+
+void
+grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str)
+{
+ str[0] = 0;
+ switch (addr->type)
+ {
+ case GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET:
+ {
+ char *ptr;
+ unsigned i;
+ for (ptr = str, i = 0; i < ARRAY_SIZE (addr->mac); i++)
+ {
+ grub_snprintf (ptr, GRUB_NET_MAX_STR_HWADDR_LEN - (ptr - str),
+ "%02x:", addr->mac[i] & 0xff);
+ ptr += (sizeof ("XX:") - 1);
+ }
+ return;
+ }
+ }
+ grub_printf (_("Unsupported hw address type %d\n"), addr->type);
+}
+
+int
+grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a,
+ const grub_net_link_level_address_t *b)
+{
+ if (a->type < b->type)
+ return -1;
+ if (a->type > b->type)
+ return +1;
+ switch (a->type)
+ {
+ case GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET:
+ return grub_memcmp (a->mac, b->mac, sizeof (a->mac));
+ }
+ grub_printf (_("Unsupported hw address type %d\n"), a->type);
+ return 1;
+}
+
+int
+grub_net_addr_cmp (const grub_net_network_level_address_t *a,
+ const grub_net_network_level_address_t *b)
+{
+ if (a->type < b->type)
+ return -1;
+ if (a->type > b->type)
+ return +1;
+ switch (a->type)
+ {
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
+ return grub_memcmp (&a->ipv4, &b->ipv4, sizeof (a->ipv4));
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
+ return grub_memcmp (&a->ipv6, &b->ipv6, sizeof (a->ipv6));
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
+ return 0;
+ }
+ grub_printf (_("Unsupported address type %d\n"), a->type);
+ return 1;
+}
+
+/* FIXME: implement this. */
+static char *
+hwaddr_set_env (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+/* FIXME: implement this. */
+static char *
+addr_set_env (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+static char *
+defserver_set_env (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val)
+{
+ grub_free (grub_net_default_server);
+ grub_net_default_server = grub_strdup (val);
+ return grub_strdup (val);
+}
+
+static const char *
+defserver_get_env (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val __attribute__ ((unused)))
+{
+ return grub_net_default_server ? : "";
+}
+
+static const char *
+defip_get_env (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val __attribute__ ((unused)))
+{
+ const char *intf = grub_env_get ("net_default_interface");
+ const char *ret = NULL;
+ if (intf)
+ {
+ char *buf = grub_xasprintf ("net_%s_ip", intf);
+ if (buf)
+ ret = grub_env_get (buf);
+ grub_free (buf);
+ }
+ return ret;
+}
+
+static char *
+defip_set_env (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val)
+{
+ const char *intf = grub_env_get ("net_default_interface");
+ if (intf)
+ {
+ char *buf = grub_xasprintf ("net_%s_ip", intf);
+ if (buf)
+ grub_env_set (buf, val);
+ grub_free (buf);
+ }
+ return NULL;
+}
+
+
+static const char *
+defmac_get_env (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val __attribute__ ((unused)))
+{
+ const char *intf = grub_env_get ("net_default_interface");
+ const char *ret = NULL;
+ if (intf)
+ {
+ char *buf = grub_xasprintf ("net_%s_mac", intf);
+ if (buf)
+ ret = grub_env_get (buf);
+ grub_free (buf);
+ }
+ return ret;
+}
+
+static char *
+defmac_set_env (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val)
+{
+ const char *intf = grub_env_get ("net_default_interface");
+ if (intf)
+ {
+ char *buf = grub_xasprintf ("net_%s_mac", intf);
+ if (buf)
+ grub_env_set (buf, val);
+ grub_free (buf);
+ }
+ return NULL;
+}
+
+
+static void
+grub_net_network_level_interface_register (struct grub_net_network_level_interface *inter)
+{
+ {
+ char buf[GRUB_NET_MAX_STR_HWADDR_LEN];
+ char *name;
+ char *ptr;
+ grub_net_hwaddr_to_str (&inter->hwaddress, buf);
+ name = grub_xasprintf ("net_%s_mac", inter->name);
+ if (!name)
+ return;
+ for (ptr = name; *ptr; ptr++)
+ if (*ptr == ':')
+ *ptr = '_';
+ grub_env_set (name, buf);
+ grub_register_variable_hook (name, 0, hwaddr_set_env);
+ grub_env_export (name);
+ grub_free (name);
+ }
+
+ {
+ char buf[GRUB_NET_MAX_STR_ADDR_LEN];
+ char *name;
+ char *ptr;
+ grub_net_addr_to_str (&inter->address, buf);
+ name = grub_xasprintf ("net_%s_ip", inter->name);
+ if (!name)
+ return;
+ for (ptr = name; *ptr; ptr++)
+ if (*ptr == ':')
+ *ptr = '_';
+ grub_env_set (name, buf);
+ grub_register_variable_hook (name, 0, addr_set_env);
+ grub_env_export (name);
+ grub_free (name);
+ }
+
+ inter->card->num_ifaces++;
+ inter->prev = &grub_net_network_level_interfaces;
+ inter->next = grub_net_network_level_interfaces;
+ if (inter->next)
+ inter->next->prev = &inter->next;
+ grub_net_network_level_interfaces = inter;
+}
+
+
+grub_err_t
+grub_net_add_ipv4_local (struct grub_net_network_level_interface *inter,
+ int mask)
+{
+ grub_uint32_t ip_cpu;
+ struct grub_net_route *route;
+
+ if (inter->address.type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4)
+ return 0;
+
+ ip_cpu = grub_be_to_cpu32 (inter->address.ipv4);
+
+ if (mask == -1)
+ {
+ if (!(ip_cpu & 0x80000000))
+ mask = 8;
+ else if (!(ip_cpu & 0x40000000))
+ mask = 16;
+ else if (!(ip_cpu & 0x20000000))
+ mask = 24;
+ }
+ if (mask == -1)
+ return 0;
+
+ route = grub_zalloc (sizeof (*route));
+ if (!route)
+ return grub_errno;
+
+ route->name = grub_xasprintf ("%s:local", inter->name);
+ if (!route->name)
+ {
+ grub_free (route);
+ return grub_errno;
+ }
+
+ route->target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ route->target.ipv4.base = grub_cpu_to_be32 (ip_cpu & (0xffffffff << (32 - mask)));
+ route->target.ipv4.masksize = mask;
+ route->is_gateway = 0;
+ route->interface = inter;
+
+ grub_net_route_register (route);
+
+ return 0;
+}
+
+/* FIXME: support MAC specifying. */
+static grub_err_t
+grub_cmd_addaddr (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_net_card *card;
+ grub_net_network_level_address_t addr;
+ grub_err_t err;
+ grub_net_interface_flags_t flags = 0;
+ struct grub_net_network_level_interface *inf;
+
+ if (argc != 3)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("three arguments expected"));
+
+ FOR_NET_CARDS (card)
+ if (grub_strcmp (card->name, args[1]) == 0)
+ break;
+ if (card == NULL)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("card not found"));
+
+ err = grub_net_resolve_address (args[2], &addr);
+ if (err)
+ return err;
+
+ if (card->flags & GRUB_NET_CARD_NO_MANUAL_INTERFACES)
+ return grub_error (GRUB_ERR_IO,
+ "this card doesn't support address addition");
+
+ if (card->flags & GRUB_NET_CARD_HWADDRESS_IMMUTABLE)
+ flags |= GRUB_NET_INTERFACE_HWADDRESS_IMMUTABLE;
+
+ inf = grub_net_add_addr (args[0], card, &addr, &card->default_address,
+ flags);
+ if (inf)
+ grub_net_add_ipv4_local (inf, -1);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_delroute (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_net_route *route;
+ struct grub_net_route **prev;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ for (prev = &grub_net_routes, route = *prev; route; prev = &((*prev)->next),
+ route = *prev)
+ if (grub_strcmp (route->name, args[0]) == 0)
+ {
+ *prev = route->next;
+ grub_free (route->name);
+ grub_free (route);
+ if (!*prev)
+ break;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_net_add_route (const char *name,
+ grub_net_network_level_netaddress_t target,
+ struct grub_net_network_level_interface *inter)
+{
+ struct grub_net_route *route;
+
+ route = grub_zalloc (sizeof (*route));
+ if (!route)
+ return grub_errno;
+
+ route->name = grub_strdup (name);
+ if (!route->name)
+ {
+ grub_free (route);
+ return grub_errno;
+ }
+
+ route->target = target;
+ route->is_gateway = 0;
+ route->interface = inter;
+
+ grub_net_route_register (route);
+
+ return GRUB_ERR_NONE;
+}
+
+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,
+ struct grub_net_network_level_interface *inter)
+{
+ struct grub_net_route *route;
+
+ route = grub_zalloc (sizeof (*route));
+ if (!route)
+ return grub_errno;
+
+ route->name = grub_strdup (name);
+ if (!route->name)
+ {
+ grub_free (route);
+ return grub_errno;
+ }
+
+ route->target = target;
+ route->is_gateway = 1;
+ route->gw = gw;
+ route->interface = inter;
+
+ grub_net_route_register (route);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_addroute (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_net_network_level_netaddress_t target;
+ if (argc < 3)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("three arguments expected"));
+
+ grub_net_resolve_net_address (args[1], &target);
+
+ if (grub_strcmp (args[2], "gw") == 0 && argc >= 4)
+ {
+ grub_err_t err;
+ grub_net_network_level_address_t gw;
+
+ err = grub_net_resolve_address (args[3], &gw);
+ if (err)
+ return err;
+ return grub_net_add_route_gw (args[0], target, gw, NULL);
+ }
+ else
+ {
+ struct grub_net_network_level_interface *inter;
+
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inter)
+ if (grub_strcmp (inter->name, args[2]) == 0)
+ break;
+
+ if (!inter)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unrecognised network interface `%s'"), args[2]);
+ return grub_net_add_route (args[0], target, inter);
+ }
+}
+
+static void
+print_net_address (const grub_net_network_level_netaddress_t *target)
+{
+ switch (target->type)
+ {
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
+ /* TRANSLATORS: it refers to the network address. */
+ grub_printf ("%s\n", _("temporary"));
+ return;
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
+ {
+ grub_uint32_t n = grub_be_to_cpu32 (target->ipv4.base);
+ grub_printf ("%d.%d.%d.%d/%d ", ((n >> 24) & 0xff),
+ ((n >> 16) & 0xff),
+ ((n >> 8) & 0xff),
+ ((n >> 0) & 0xff),
+ target->ipv4.masksize);
+ }
+ return;
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
+ {
+ char buf[GRUB_NET_MAX_STR_ADDR_LEN];
+ struct grub_net_network_level_address base;
+ base.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ grub_memcpy (&base.ipv6, &target->ipv6, 16);
+ grub_net_addr_to_str (&base, buf);
+ grub_printf ("%s/%d ", buf, target->ipv6.masksize);
+ }
+ return;
+ }
+ grub_printf (_("Unknown address type %d\n"), target->type);
+}
+
+static void
+print_address (const grub_net_network_level_address_t *target)
+{
+ char buf[GRUB_NET_MAX_STR_ADDR_LEN];
+ grub_net_addr_to_str (target, buf);
+ grub_xputs (buf);
+}
+
+static grub_err_t
+grub_cmd_listroutes (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ struct grub_net_route *route;
+ FOR_NET_ROUTES(route)
+ {
+ grub_printf ("%s ", route->name);
+ print_net_address (&route->target);
+ if (route->is_gateway)
+ {
+ grub_printf ("gw ");
+ print_address (&route->gw);
+ }
+ else
+ grub_printf ("%s", route->interface->name);
+ grub_printf ("\n");
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_listcards (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ struct grub_net_card *card;
+ FOR_NET_CARDS(card)
+ {
+ char buf[GRUB_NET_MAX_STR_HWADDR_LEN];
+ grub_net_hwaddr_to_str (&card->default_address, buf);
+ grub_printf ("%s %s\n", card->name, buf);
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_listaddrs (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ struct grub_net_network_level_interface *inf;
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
+ {
+ char bufh[GRUB_NET_MAX_STR_HWADDR_LEN];
+ char bufn[GRUB_NET_MAX_STR_ADDR_LEN];
+ grub_net_hwaddr_to_str (&inf->hwaddress, bufh);
+ grub_net_addr_to_str (&inf->address, bufn);
+ grub_printf ("%s %s %s\n", inf->name, bufh, bufn);
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_net_app_level_t grub_net_app_level_list;
+struct grub_net_socket *grub_net_sockets;
+
+static grub_net_t
+grub_net_open_real (const char *name)
+{
+ grub_net_app_level_t proto;
+ const char *protname, *server;
+ grub_size_t protnamelen;
+ int try;
+
+ if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0)
+ {
+ protname = "tftp";
+ protnamelen = sizeof ("tftp") - 1;
+ server = name + sizeof ("pxe:") - 1;
+ }
+ else if (grub_strcmp (name, "pxe") == 0)
+ {
+ protname = "tftp";
+ protnamelen = sizeof ("tftp") - 1;
+ server = grub_net_default_server;
+ }
+ else
+ {
+ const char *comma;
+ comma = grub_strchr (name, ',');
+ if (comma)
+ {
+ protnamelen = comma - name;
+ server = comma + 1;
+ protname = name;
+ }
+ else
+ {
+ protnamelen = grub_strlen (name);
+ server = grub_net_default_server;
+ protname = name;
+ }
+ }
+ if (!server)
+ {
+ grub_error (GRUB_ERR_NET_BAD_ADDRESS,
+ N_("no server is specified"));
+ return NULL;
+ }
+
+ for (try = 0; try < 2; try++)
+ {
+ FOR_NET_APP_LEVEL (proto)
+ {
+ if (grub_memcmp (proto->name, protname, protnamelen) == 0
+ && proto->name[protnamelen] == 0)
+ {
+ grub_net_t ret = grub_zalloc (sizeof (*ret));
+ if (!ret)
+ return NULL;
+ ret->protocol = proto;
+ ret->server = grub_strdup (server);
+ if (!ret->server)
+ {
+ grub_free (ret);
+ return NULL;
+ }
+ ret->fs = &grub_net_fs;
+ 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)
+ {
+ grub_dl_load ("http");
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ if (sizeof ("tftp") - 1 == protnamelen
+ && grub_memcmp ("tftp", protname, protnamelen) == 0)
+ {
+ grub_dl_load ("tftp");
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ }
+ break;
+ }
+
+ /* Restore original error. */
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"),
+ name);
+
+ return NULL;
+}
+
+static grub_err_t
+grub_net_fs_dir (grub_device_t device, const char *path __attribute__ ((unused)),
+ grub_fs_dir_hook_t hook __attribute__ ((unused)),
+ void *hook_data __attribute__ ((unused)))
+{
+ if (!device->net)
+ return grub_error (GRUB_ERR_BUG, "invalid net device");
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_net_fs_open (struct grub_file *file_out, const char *name)
+{
+ grub_err_t err;
+ struct grub_file *file, *bufio;
+
+ file = grub_malloc (sizeof (*file));
+ if (!file)
+ return grub_errno;
+
+ grub_memcpy (file, file_out, sizeof (struct grub_file));
+ file->device->net->packs.first = NULL;
+ file->device->net->packs.last = NULL;
+ file->device->net->name = grub_strdup (name);
+ if (!file->device->net->name)
+ {
+ grub_free (file);
+ return grub_errno;
+ }
+
+ err = file->device->net->protocol->open (file, name);
+ if (err)
+ {
+ while (file->device->net->packs.first)
+ {
+ grub_netbuff_free (file->device->net->packs.first->nb);
+ grub_net_remove_packet (file->device->net->packs.first);
+ }
+ grub_free (file->device->net->name);
+ grub_free (file);
+ return err;
+ }
+ bufio = grub_bufio_open (file, 32768);
+ if (! bufio)
+ {
+ while (file->device->net->packs.first)
+ {
+ grub_netbuff_free (file->device->net->packs.first->nb);
+ grub_net_remove_packet (file->device->net->packs.first);
+ }
+ file->device->net->protocol->close (file);
+ grub_free (file->device->net->name);
+ grub_free (file);
+ return grub_errno;
+ }
+
+ grub_memcpy (file_out, bufio, sizeof (struct grub_file));
+ grub_free (bufio);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_net_fs_close (grub_file_t file)
+{
+ while (file->device->net->packs.first)
+ {
+ grub_netbuff_free (file->device->net->packs.first->nb);
+ grub_net_remove_packet (file->device->net->packs.first);
+ }
+ file->device->net->protocol->close (file);
+ grub_free (file->device->net->name);
+ return GRUB_ERR_NONE;
+}
+
+static void
+receive_packets (struct grub_net_card *card, int *stop_condition)
+{
+ int received = 0;
+ if (card->num_ifaces == 0)
+ return;
+ if (!card->opened)
+ {
+ grub_err_t err = GRUB_ERR_NONE;
+ if (card->driver->open)
+ err = card->driver->open (card);
+ if (err)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+ card->opened = 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. */
+ struct grub_net_buff *nb;
+
+ if (received > 10 && stop_condition && *stop_condition)
+ break;
+
+ nb = card->driver->recv (card);
+ if (!nb)
+ {
+ card->last_poll = grub_get_time_ms ();
+ break;
+ }
+ received++;
+ grub_net_recv_ethernet_packet (nb, card);
+ if (grub_errno)
+ {
+ grub_dprintf ("net", "error receiving: %d: %s\n", grub_errno,
+ grub_errmsg);
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+ 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)
+{
+ struct grub_net_card *card;
+ grub_uint64_t start_time;
+ start_time = grub_get_time_ms ();
+ while ((grub_get_time_ms () - start_time) < time
+ && (!stop_condition || !*stop_condition))
+ FOR_NET_CARDS (card)
+ receive_packets (card, stop_condition);
+ grub_net_tcp_retransmit ();
+}
+
+static void
+grub_net_poll_cards_idle_real (void)
+{
+ struct grub_net_card *card;
+ FOR_NET_CARDS (card)
+ {
+ grub_uint64_t ctime = grub_get_time_ms ();
+
+ if (ctime < card->last_poll
+ || ctime >= card->last_poll + card->idle_poll_delay_ms)
+ receive_packets (card, 0);
+ }
+ grub_net_tcp_retransmit ();
+}
+
+/* Read from the packets list*/
+static grub_ssize_t
+grub_net_fs_read_real (grub_file_t file, char *buf, grub_size_t len)
+{
+ grub_net_t net = file->device->net;
+ struct grub_net_buff *nb;
+ char *ptr = buf;
+ grub_size_t amount, total = 0;
+ int try = 0;
+
+ while (try <= GRUB_NET_TRIES)
+ {
+ while (net->packs.first)
+ {
+ try = 0;
+ nb = net->packs.first->nb;
+ amount = nb->tail - nb->data;
+ if (amount > len)
+ amount = len;
+ len -= amount;
+ total += amount;
+ file->device->net->offset += amount;
+ if (grub_file_progress_hook)
+ grub_file_progress_hook (0, 0, amount, file);
+ if (buf)
+ {
+ grub_memcpy (ptr, nb->data, amount);
+ ptr += amount;
+ }
+ if (amount == (grub_size_t) (nb->tail - nb->data))
+ {
+ grub_netbuff_free (nb);
+ grub_net_remove_packet (net->packs.first);
+ }
+ else
+ nb->data += amount;
+
+ if (!len)
+ {
+ if (net->protocol->packets_pulled)
+ net->protocol->packets_pulled (file);
+ return total;
+ }
+ }
+ if (net->protocol->packets_pulled)
+ net->protocol->packets_pulled (file);
+
+ if (!net->eof)
+ {
+ try++;
+ grub_net_poll_cards (GRUB_NET_INTERVAL +
+ (try * GRUB_NET_INTERVAL_ADDITION), &net->stall);
+ }
+ else
+ return total;
+ }
+ grub_error (GRUB_ERR_TIMEOUT, N_("timeout reading `%s'"), net->name);
+ return -1;
+}
+
+static grub_off_t
+have_ahead (struct grub_file *file)
+{
+ grub_net_t net = file->device->net;
+ grub_off_t ret = net->offset;
+ struct grub_net_packet *pack;
+ for (pack = net->packs.first; pack; pack = pack->next)
+ ret += pack->nb->tail - pack->nb->data;
+ return ret;
+}
+
+static grub_err_t
+grub_net_seek_real (struct grub_file *file, grub_off_t offset)
+{
+ if (offset == file->device->net->offset)
+ return GRUB_ERR_NONE;
+
+ if (offset > file->device->net->offset)
+ {
+ if (!file->device->net->protocol->seek || have_ahead (file) >= offset)
+ {
+ grub_net_fs_read_real (file, NULL,
+ offset - file->device->net->offset);
+ return grub_errno;
+ }
+ return file->device->net->protocol->seek (file, offset);
+ }
+
+ {
+ grub_err_t err;
+ if (file->device->net->protocol->seek)
+ return file->device->net->protocol->seek (file, offset);
+ while (file->device->net->packs.first)
+ {
+ grub_netbuff_free (file->device->net->packs.first->nb);
+ grub_net_remove_packet (file->device->net->packs.first);
+ }
+ file->device->net->protocol->close (file);
+
+ file->device->net->packs.first = NULL;
+ 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;
+ grub_net_fs_read_real (file, NULL, offset);
+ return grub_errno;
+ }
+}
+
+static grub_ssize_t
+grub_net_fs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+ if (file->offset != file->device->net->offset)
+ {
+ grub_err_t err;
+ err = grub_net_seek_real (file, file->offset);
+ if (err)
+ return err;
+ }
+ return grub_net_fs_read_real (file, buf, len);
+}
+
+static struct grub_fs grub_net_fs =
+ {
+ .name = "netfs",
+ .fs_dir = grub_net_fs_dir,
+ .fs_open = grub_net_fs_open,
+ .fs_read = grub_net_fs_read,
+ .fs_close = grub_net_fs_close,
+ .fs_label = NULL,
+ .fs_uuid = NULL,
+ .fs_mtime = NULL,
+ };
+
+static grub_err_t
+grub_net_fini_hw (int noreturn __attribute__ ((unused)))
+{
+ struct grub_net_card *card;
+ FOR_NET_CARDS (card)
+ if (card->opened)
+ {
+ if (card->driver->close)
+ card->driver->close (card);
+ card->opened = 0;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_net_restore_hw (void)
+{
+ return GRUB_ERR_NONE;
+}
+
+static int
+grub_config_search_through (char *config, char *suffix,
+ grub_size_t num_tries, grub_size_t slice_size)
+{
+ while (num_tries-- > 0)
+ {
+ grub_file_t file;
+
+ grub_dprintf ("net", "attempt to fetch config %s\n", config);
+
+ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
+
+ if (file)
+ {
+ grub_file_close (file);
+ return 0;
+ }
+ else
+ {
+ if (grub_errno == GRUB_ERR_IO)
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ if (grub_strlen (suffix) < slice_size)
+ break;
+
+ config[grub_strlen (config) - slice_size] = '\0';
+ }
+
+ return 1;
+}
+
+grub_err_t
+grub_net_search_config_file (char *config)
+{
+ grub_size_t config_len;
+ char *suffix;
+
+ config_len = grub_strlen (config);
+ config[config_len] = '-';
+ suffix = config + config_len + 1;
+
+ struct grub_net_network_level_interface *inf;
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
+ {
+ /* By the Client UUID. */
+ char *ptr;
+ int client_uuid_len;
+ char *client_uuid_var;
+ const char *client_uuid;
+
+ client_uuid_len = sizeof ("net_") + grub_strlen (inf->name) +
+ sizeof ("_clientuuid") + 1;
+
+ client_uuid_var = grub_zalloc (client_uuid_len);
+ if (!client_uuid_var)
+ return grub_errno;
+
+ grub_snprintf (client_uuid_var, client_uuid_len,
+ "net_%s_clientuuid", inf->name);
+
+ client_uuid = grub_env_get (client_uuid_var);
+ grub_free (client_uuid_var);
+
+ if (client_uuid)
+ {
+ grub_strcpy (suffix, client_uuid);
+ if (grub_config_search_through (config, suffix, 1, 0) == 0)
+ return GRUB_ERR_NONE;
+ }
+
+ /* By the MAC address. */
+
+ /* Add ethernet type */
+ grub_strcpy (suffix, "01-");
+
+ grub_net_hwaddr_to_str (&inf->hwaddress, suffix + 3);
+
+ for (ptr = suffix; *ptr; ptr++)
+ if (*ptr == ':')
+ *ptr = '-';
+
+ if (grub_config_search_through (config, suffix, 1, 0) == 0)
+ return GRUB_ERR_NONE;
+
+ /* By IP address */
+
+ switch ((&inf->address)->type)
+ {
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
+ {
+ grub_uint32_t n = grub_be_to_cpu32 ((&inf->address)->ipv4);
+
+ grub_snprintf (suffix, GRUB_NET_MAX_STR_ADDR_LEN, "%02X%02X%02X%02X", \
+ ((n >> 24) & 0xff), ((n >> 16) & 0xff), \
+ ((n >> 8) & 0xff), ((n >> 0) & 0xff));
+
+ if (grub_config_search_through (config, suffix, 8, 1) == 0)
+ return GRUB_ERR_NONE;
+ break;
+ }
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
+ {
+ char buf[GRUB_NET_MAX_STR_ADDR_LEN];
+ struct grub_net_network_level_address base;
+ base.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ grub_memcpy (&base.ipv6, ((&inf->address)->ipv6), 16);
+ grub_net_addr_to_str (&base, buf);
+
+ for (ptr = buf; *ptr; ptr++)
+ if (*ptr == ':')
+ *ptr = '-';
+
+ grub_snprintf (suffix, GRUB_NET_MAX_STR_ADDR_LEN, "%s", buf);
+ if (grub_config_search_through (config, suffix, 1, 0) == 0)
+ return GRUB_ERR_NONE;
+ break;
+ }
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
+ return grub_error (GRUB_ERR_BUG, "shouldn't reach here");
+ default:
+ return grub_error (GRUB_ERR_BUG,
+ "unsupported address type %d", (&inf->address)->type);
+ }
+ }
+
+ /* Remove the remaining minus sign at the end. */
+ config[config_len] = '\0';
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_preboot *fini_hnd;
+
+static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute;
+static grub_command_t cmd_lsroutes, cmd_lscards;
+static grub_command_t cmd_lsaddr, cmd_slaac;
+
+GRUB_MOD_INIT(net)
+{
+ grub_register_variable_hook ("net_default_server", defserver_get_env,
+ defserver_set_env);
+ grub_env_export ("net_default_server");
+ grub_register_variable_hook ("pxe_default_server", defserver_get_env,
+ defserver_set_env);
+ grub_env_export ("pxe_default_server");
+ grub_register_variable_hook ("net_default_ip", defip_get_env,
+ defip_set_env);
+ grub_env_export ("net_default_ip");
+ grub_register_variable_hook ("net_default_mac", defmac_get_env,
+ defmac_set_env);
+ grub_env_export ("net_default_mac");
+
+ cmd_addaddr = grub_register_command ("net_add_addr", grub_cmd_addaddr,
+ /* TRANSLATORS: HWADDRESS stands for
+ "hardware address". */
+ N_("SHORTNAME CARD ADDRESS [HWADDRESS]"),
+ N_("Add a network address."));
+ cmd_slaac = grub_register_command ("net_ipv6_autoconf",
+ grub_cmd_ipv6_autoconf,
+ N_("[CARD [HWADDRESS]]"),
+ N_("Perform an IPV6 autoconfiguration"));
+
+ cmd_deladdr = grub_register_command ("net_del_addr", grub_cmd_deladdr,
+ N_("SHORTNAME"),
+ N_("Delete a network address."));
+ cmd_addroute = grub_register_command ("net_add_route", grub_cmd_addroute,
+ /* TRANSLATORS: "gw" is a keyword. */
+ N_("SHORTNAME NET [INTERFACE| gw GATEWAY]"),
+ N_("Add a network route."));
+ cmd_delroute = grub_register_command ("net_del_route", grub_cmd_delroute,
+ N_("SHORTNAME"),
+ N_("Delete a network route."));
+ cmd_lsroutes = grub_register_command ("net_ls_routes", grub_cmd_listroutes,
+ "", N_("list network routes"));
+ cmd_lscards = grub_register_command ("net_ls_cards", grub_cmd_listcards,
+ "", N_("list network cards"));
+ cmd_lsaddr = grub_register_command ("net_ls_addr", grub_cmd_listaddrs,
+ "", N_("list network addresses"));
+ grub_bootp_init ();
+ grub_dns_init ();
+
+ grub_net_open = grub_net_open_real;
+ fini_hnd = grub_loader_register_preboot_hook (grub_net_fini_hw,
+ grub_net_restore_hw,
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK);
+ grub_net_poll_cards_idle = grub_net_poll_cards_idle_real;
+}
+
+GRUB_MOD_FINI(net)
+{
+ grub_register_variable_hook ("net_default_server", 0, 0);
+ grub_register_variable_hook ("pxe_default_server", 0, 0);
+
+ grub_bootp_fini ();
+ grub_dns_fini ();
+ grub_unregister_command (cmd_addaddr);
+ grub_unregister_command (cmd_deladdr);
+ grub_unregister_command (cmd_addroute);
+ grub_unregister_command (cmd_delroute);
+ grub_unregister_command (cmd_lsroutes);
+ grub_unregister_command (cmd_lscards);
+ grub_unregister_command (cmd_lsaddr);
+ grub_unregister_command (cmd_slaac);
+ grub_fs_unregister (&grub_net_fs);
+ grub_net_open = NULL;
+ grub_net_fini_hw (0);
+ grub_loader_unregister_preboot_hook (fini_hnd);
+ grub_net_poll_cards_idle = grub_net_poll_cards_idle_real;
+}
diff --git a/grub-core/net/netbuff.c b/grub-core/net/netbuff.c
new file mode 100644
index 0000000..dbeeefe
--- /dev/null
+++ b/grub-core/net/netbuff.c
@@ -0,0 +1,133 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/net/netbuff.h>
+
+grub_err_t
+grub_netbuff_put (struct grub_net_buff *nb, grub_size_t len)
+{
+ nb->tail += len;
+ if (nb->tail > nb->end)
+ return grub_error (GRUB_ERR_BUG, "put out of the packet range.");
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_netbuff_unput (struct grub_net_buff *nb, grub_size_t len)
+{
+ nb->tail -= len;
+ if (nb->tail < nb->head)
+ return grub_error (GRUB_ERR_BUG,
+ "unput out of the packet range.");
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_netbuff_push (struct grub_net_buff *nb, grub_size_t len)
+{
+ nb->data -= len;
+ if (nb->data < nb->head)
+ return grub_error (GRUB_ERR_BUG,
+ "push out of the packet range.");
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_netbuff_pull (struct grub_net_buff *nb, grub_size_t len)
+{
+ nb->data += len;
+ if (nb->data > nb->end)
+ return grub_error (GRUB_ERR_BUG,
+ "pull out of the packet range.");
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_netbuff_reserve (struct grub_net_buff *nb, grub_size_t len)
+{
+ nb->data += len;
+ nb->tail += len;
+ if ((nb->tail > nb->end) || (nb->data > nb->end))
+ return grub_error (GRUB_ERR_BUG,
+ "reserve out of the packet range.");
+ return GRUB_ERR_NONE;
+}
+
+struct grub_net_buff *
+grub_netbuff_alloc (grub_size_t len)
+{
+ struct grub_net_buff *nb;
+ void *data;
+
+ COMPILE_TIME_ASSERT (NETBUFF_ALIGN % sizeof (grub_properly_aligned_t) == 0);
+
+ if (len < NETBUFFMINLEN)
+ len = NETBUFFMINLEN;
+
+ len = ALIGN_UP (len, NETBUFF_ALIGN);
+#ifdef GRUB_MACHINE_EMU
+ data = grub_malloc (len + sizeof (*nb));
+#else
+ data = grub_memalign (NETBUFF_ALIGN, len + sizeof (*nb));
+#endif
+ if (!data)
+ return NULL;
+ nb = (struct grub_net_buff *) ((grub_properly_aligned_t *) data
+ + len / sizeof (grub_properly_aligned_t));
+ nb->head = nb->data = nb->tail = data;
+ nb->end = (grub_uint8_t *) nb;
+ 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)
+{
+ if (!nb)
+ return;
+ grub_free (nb->head);
+}
+
+grub_err_t
+grub_netbuff_clear (struct grub_net_buff *nb)
+{
+ nb->data = nb->tail = nb->head;
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c
new file mode 100644
index 0000000..e8ad34b
--- /dev/null
+++ b/grub-core/net/tcp.c
@@ -0,0 +1,1020 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net.h>
+#include <grub/net/ip.h>
+#include <grub/net/tcp.h>
+#include <grub/net/netbuff.h>
+#include <grub/time.h>
+#include <grub/priority_queue.h>
+
+#define TCP_SYN_RETRANSMISSION_TIMEOUT GRUB_NET_INTERVAL
+#define TCP_SYN_RETRANSMISSION_COUNT GRUB_NET_TRIES
+#define TCP_RETRANSMISSION_TIMEOUT GRUB_NET_INTERVAL
+#define TCP_RETRANSMISSION_COUNT GRUB_NET_TRIES
+
+struct unacked
+{
+ struct unacked *next;
+ struct unacked **prev;
+ struct grub_net_buff *nb;
+ grub_uint64_t last_try;
+ int try_count;
+};
+
+enum
+ {
+ TCP_FIN = 0x1,
+ TCP_SYN = 0x2,
+ TCP_RST = 0x4,
+ TCP_PUSH = 0x8,
+ TCP_ACK = 0x10,
+ TCP_URG = 0x20,
+ };
+
+struct grub_net_tcp_socket
+{
+ struct grub_net_tcp_socket *next;
+ struct grub_net_tcp_socket **prev;
+
+ int established;
+ int i_closed;
+ int they_closed;
+ int in_port;
+ int out_port;
+ int errors;
+ int they_reseted;
+ int i_reseted;
+ int i_stall;
+ grub_uint32_t my_start_seq;
+ grub_uint32_t my_cur_seq;
+ grub_uint32_t their_start_seq;
+ grub_uint32_t their_cur_seq;
+ grub_uint16_t my_window;
+ struct unacked *unack_first;
+ struct unacked *unack_last;
+ grub_err_t (*recv_hook) (grub_net_tcp_socket_t sock, struct grub_net_buff *nb,
+ void *recv);
+ void (*error_hook) (grub_net_tcp_socket_t sock, void *recv);
+ void (*fin_hook) (grub_net_tcp_socket_t sock, void *recv);
+ void *hook_data;
+ grub_net_network_level_address_t out_nla;
+ grub_net_link_level_address_t ll_target_addr;
+ struct grub_net_network_level_interface *inf;
+ grub_net_packets_t packs;
+ grub_priority_queue_t pq;
+};
+
+struct grub_net_tcp_listen
+{
+ struct grub_net_tcp_listen *next;
+ struct grub_net_tcp_listen **prev;
+
+ grub_uint16_t port;
+ const struct grub_net_network_level_interface *inf;
+
+ grub_err_t (*listen_hook) (grub_net_tcp_listen_t listen,
+ grub_net_tcp_socket_t sock,
+ void *data);
+ void *hook_data;
+};
+
+struct tcphdr
+{
+ grub_uint16_t src;
+ grub_uint16_t dst;
+ grub_uint32_t seqnr;
+ grub_uint32_t ack;
+ grub_uint16_t flags;
+ grub_uint16_t window;
+ grub_uint16_t checksum;
+ grub_uint16_t urgent;
+} GRUB_PACKED;
+
+struct tcp_pseudohdr
+{
+ grub_uint32_t src;
+ grub_uint32_t dst;
+ grub_uint8_t zero;
+ grub_uint8_t proto;
+ grub_uint16_t tcp_length;
+} GRUB_PACKED;
+
+struct tcp6_pseudohdr
+{
+ grub_uint64_t src[2];
+ grub_uint64_t dst[2];
+ grub_uint32_t tcp_length;
+ grub_uint8_t zero[3];
+ grub_uint8_t proto;
+} GRUB_PACKED;
+
+static struct grub_net_tcp_socket *tcp_sockets;
+static struct grub_net_tcp_listen *tcp_listens;
+
+#define FOR_TCP_SOCKETS(var) FOR_LIST_ELEMENTS (var, tcp_sockets)
+#define FOR_TCP_LISTENS(var) FOR_LIST_ELEMENTS (var, tcp_listens)
+
+grub_net_tcp_listen_t
+grub_net_tcp_listen (grub_uint16_t port,
+ const struct grub_net_network_level_interface *inf,
+ grub_err_t (*listen_hook) (grub_net_tcp_listen_t listen,
+ grub_net_tcp_socket_t sock,
+ void *data),
+ void *hook_data)
+{
+ grub_net_tcp_listen_t ret;
+ ret = grub_malloc (sizeof (*ret));
+ if (!ret)
+ return NULL;
+ ret->listen_hook = listen_hook;
+ ret->hook_data = hook_data;
+ ret->port = port;
+ ret->inf = inf;
+ grub_list_push (GRUB_AS_LIST_P (&tcp_listens), GRUB_AS_LIST (ret));
+ return ret;
+}
+
+void
+grub_net_tcp_stop_listen (grub_net_tcp_listen_t listen)
+{
+ grub_list_remove (GRUB_AS_LIST (listen));
+}
+
+static inline void
+tcp_socket_register (grub_net_tcp_socket_t sock)
+{
+ grub_list_push (GRUB_AS_LIST_P (&tcp_sockets),
+ GRUB_AS_LIST (sock));
+}
+
+static void
+error (grub_net_tcp_socket_t sock)
+{
+ struct unacked *unack, *next;
+
+ if (sock->error_hook)
+ sock->error_hook (sock, sock->hook_data);
+
+ for (unack = sock->unack_first; unack; unack = next)
+ {
+ next = unack->next;
+ grub_netbuff_free (unack->nb);
+ grub_free (unack);
+ }
+
+ sock->unack_first = NULL;
+ sock->unack_last = NULL;
+}
+
+static grub_err_t
+tcp_send (struct grub_net_buff *nb, grub_net_tcp_socket_t socket)
+{
+ grub_err_t err;
+ grub_uint8_t *nbd;
+ struct unacked *unack;
+ struct tcphdr *tcph;
+ grub_size_t size;
+
+ tcph = (struct tcphdr *) nb->data;
+
+ tcph->seqnr = grub_cpu_to_be32 (socket->my_cur_seq);
+ size = (nb->tail - nb->data - (grub_be_to_cpu16 (tcph->flags) >> 12) * 4);
+ if (grub_be_to_cpu16 (tcph->flags) & TCP_FIN)
+ size++;
+ socket->my_cur_seq += size;
+ tcph->src = grub_cpu_to_be16 (socket->in_port);
+ tcph->dst = grub_cpu_to_be16 (socket->out_port);
+ tcph->checksum = 0;
+ tcph->checksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_TCP,
+ &socket->inf->address,
+ &socket->out_nla);
+ nbd = nb->data;
+ if (size)
+ {
+ unack = grub_malloc (sizeof (*unack));
+ if (!unack)
+ return grub_errno;
+
+ unack->next = NULL;
+ unack->nb = nb;
+ unack->try_count = 1;
+ unack->last_try = grub_get_time_ms ();
+ if (!socket->unack_last)
+ socket->unack_first = socket->unack_last = unack;
+ else
+ socket->unack_last->next = unack;
+ }
+
+ err = grub_net_send_ip_packet (socket->inf, &(socket->out_nla),
+ &(socket->ll_target_addr), nb,
+ GRUB_NET_IP_TCP);
+ if (err)
+ return err;
+ nb->data = nbd;
+ if (!size)
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_net_tcp_close (grub_net_tcp_socket_t sock,
+ int discard_received)
+{
+ struct grub_net_buff *nb_fin;
+ struct tcphdr *tcph_fin;
+ grub_err_t err;
+
+ if (discard_received != GRUB_NET_TCP_CONTINUE_RECEIVING)
+ {
+ sock->recv_hook = NULL;
+ sock->error_hook = NULL;
+ sock->fin_hook = NULL;
+ }
+
+ if (discard_received == GRUB_NET_TCP_ABORT)
+ sock->i_reseted = 1;
+
+ if (sock->i_closed)
+ return;
+
+ sock->i_closed = 1;
+
+ nb_fin = grub_netbuff_alloc (sizeof (*tcph_fin)
+ + GRUB_NET_OUR_MAX_IP_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE);
+ if (!nb_fin)
+ return;
+ err = grub_netbuff_reserve (nb_fin, GRUB_NET_OUR_MAX_IP_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE);
+ if (err)
+ {
+ grub_netbuff_free (nb_fin);
+ grub_dprintf ("net", "error closing socket\n");
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ err = grub_netbuff_put (nb_fin, sizeof (*tcph_fin));
+ if (err)
+ {
+ grub_netbuff_free (nb_fin);
+ grub_dprintf ("net", "error closing socket\n");
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+ tcph_fin = (void *) nb_fin->data;
+ tcph_fin->ack = grub_cpu_to_be32 (sock->their_cur_seq);
+ tcph_fin->flags = grub_cpu_to_be16_compile_time ((5 << 12) | TCP_FIN
+ | TCP_ACK);
+ tcph_fin->window = grub_cpu_to_be16_compile_time (0);
+ tcph_fin->urgent = 0;
+ err = tcp_send (nb_fin, sock);
+ if (err)
+ {
+ grub_netbuff_free (nb_fin);
+ grub_dprintf ("net", "error closing socket\n");
+ grub_errno = GRUB_ERR_NONE;
+ }
+ return;
+}
+
+static void
+ack_real (grub_net_tcp_socket_t sock, int res)
+{
+ struct grub_net_buff *nb_ack;
+ struct tcphdr *tcph_ack;
+ grub_err_t err;
+
+ nb_ack = grub_netbuff_alloc (sizeof (*tcph_ack) + 128);
+ if (!nb_ack)
+ return;
+ err = grub_netbuff_reserve (nb_ack, 128);
+ if (err)
+ {
+ grub_netbuff_free (nb_ack);
+ grub_dprintf ("net", "error closing socket\n");
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ err = grub_netbuff_put (nb_ack, sizeof (*tcph_ack));
+ if (err)
+ {
+ grub_netbuff_free (nb_ack);
+ grub_dprintf ("net", "error closing socket\n");
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+ tcph_ack = (void *) nb_ack->data;
+ if (res)
+ {
+ tcph_ack->ack = grub_cpu_to_be32_compile_time (0);
+ tcph_ack->flags = grub_cpu_to_be16_compile_time ((5 << 12) | TCP_RST);
+ tcph_ack->window = grub_cpu_to_be16_compile_time (0);
+ }
+ else
+ {
+ tcph_ack->ack = grub_cpu_to_be32 (sock->their_cur_seq);
+ tcph_ack->flags = grub_cpu_to_be16_compile_time ((5 << 12) | TCP_ACK);
+ tcph_ack->window = !sock->i_stall ? grub_cpu_to_be16 (sock->my_window)
+ : 0;
+ }
+ tcph_ack->urgent = 0;
+ tcph_ack->src = grub_cpu_to_be16 (sock->in_port);
+ tcph_ack->dst = grub_cpu_to_be16 (sock->out_port);
+ err = tcp_send (nb_ack, sock);
+ if (err)
+ {
+ grub_dprintf ("net", "error acking socket\n");
+ grub_errno = GRUB_ERR_NONE;
+ }
+}
+
+static void
+ack (grub_net_tcp_socket_t sock)
+{
+ ack_real (sock, 0);
+}
+
+static void
+reset (grub_net_tcp_socket_t sock)
+{
+ ack_real (sock, 1);
+}
+
+void
+grub_net_tcp_retransmit (void)
+{
+ grub_net_tcp_socket_t sock;
+ grub_uint64_t ctime = grub_get_time_ms ();
+ grub_uint64_t limit_time = ctime - TCP_RETRANSMISSION_TIMEOUT;
+
+ FOR_TCP_SOCKETS (sock)
+ {
+ struct unacked *unack;
+ for (unack = sock->unack_first; unack; unack = unack->next)
+ {
+ struct tcphdr *tcph;
+ grub_uint8_t *nbd;
+ grub_err_t err;
+
+ if (unack->last_try > limit_time)
+ continue;
+
+ if (unack->try_count > TCP_RETRANSMISSION_COUNT)
+ {
+ error (sock);
+ break;
+ }
+ unack->try_count++;
+ unack->last_try = ctime;
+ nbd = unack->nb->data;
+ tcph = (struct tcphdr *) nbd;
+
+ if ((tcph->flags & grub_cpu_to_be16_compile_time (TCP_ACK))
+ && tcph->ack != grub_cpu_to_be32 (sock->their_cur_seq))
+ {
+ tcph->checksum = 0;
+ tcph->checksum = grub_net_ip_transport_checksum (unack->nb,
+ GRUB_NET_IP_TCP,
+ &sock->inf->address,
+ &sock->out_nla);
+ }
+
+ err = grub_net_send_ip_packet (sock->inf, &(sock->out_nla),
+ &(sock->ll_target_addr), unack->nb,
+ GRUB_NET_IP_TCP);
+ unack->nb->data = nbd;
+ if (err)
+ {
+ grub_dprintf ("net", "TCP retransmit failed: %s\n", grub_errmsg);
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+ }
+}
+
+grub_uint16_t
+grub_net_ip_transport_checksum (struct grub_net_buff *nb,
+ grub_uint16_t proto,
+ const grub_net_network_level_address_t *src,
+ const grub_net_network_level_address_t *dst)
+{
+ grub_uint16_t a, b = 0;
+ grub_uint32_t c;
+ a = ~grub_be_to_cpu16 (grub_net_ip_chksum ((void *) nb->data,
+ nb->tail - nb->data));
+
+ switch (dst->type)
+ {
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
+ {
+ struct tcp_pseudohdr ph;
+ ph.src = src->ipv4;
+ ph.dst = dst->ipv4;
+ ph.zero = 0;
+ ph.tcp_length = grub_cpu_to_be16 (nb->tail - nb->data);
+ ph.proto = proto;
+ b = ~grub_be_to_cpu16 (grub_net_ip_chksum ((void *) &ph, sizeof (ph)));
+ break;
+ }
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
+ {
+ struct tcp6_pseudohdr ph;
+ grub_memcpy (ph.src, src->ipv6, sizeof (ph.src));
+ grub_memcpy (ph.dst, dst->ipv6, sizeof (ph.dst));
+ grub_memset (ph.zero, 0, sizeof (ph.zero));
+ ph.tcp_length = grub_cpu_to_be32 (nb->tail - nb->data);
+ ph.proto = proto;
+ b = ~grub_be_to_cpu16 (grub_net_ip_chksum ((void *) &ph, sizeof (ph)));
+ break;
+ }
+ case GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV:
+ b = 0;
+ break;
+ }
+ c = (grub_uint32_t) a + (grub_uint32_t) b;
+ if (c >= 0xffff)
+ c -= 0xffff;
+ return grub_cpu_to_be16 (~c);
+}
+
+/* FIXME: overflow. */
+static int
+cmp (const void *a__, const void *b__)
+{
+ struct grub_net_buff *a_ = *(struct grub_net_buff **) a__;
+ struct grub_net_buff *b_ = *(struct grub_net_buff **) b__;
+ struct tcphdr *a = (struct tcphdr *) a_->data;
+ struct tcphdr *b = (struct tcphdr *) b_->data;
+ /* We want the first elements to be on top. */
+ if (grub_be_to_cpu32 (a->seqnr) < grub_be_to_cpu32 (b->seqnr))
+ return +1;
+ if (grub_be_to_cpu32 (a->seqnr) > grub_be_to_cpu32 (b->seqnr))
+ return -1;
+ return 0;
+}
+
+static void
+destroy_pq (grub_net_tcp_socket_t sock)
+{
+ struct grub_net_buff **nb_p;
+ while ((nb_p = grub_priority_queue_top (sock->pq)))
+ {
+ grub_netbuff_free (*nb_p);
+ grub_priority_queue_pop (sock->pq);
+ }
+
+ grub_priority_queue_destroy (sock->pq);
+}
+
+grub_err_t
+grub_net_tcp_accept (grub_net_tcp_socket_t sock,
+ grub_err_t (*recv_hook) (grub_net_tcp_socket_t sock,
+ struct grub_net_buff *nb,
+ void *data),
+ void (*error_hook) (grub_net_tcp_socket_t sock,
+ void *data),
+ void (*fin_hook) (grub_net_tcp_socket_t sock,
+ void *data),
+ void *hook_data)
+{
+ 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);
+ if (!nb_ack)
+ return grub_errno;
+ err = grub_netbuff_reserve (nb_ack, GRUB_NET_OUR_MAX_IP_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE);
+ if (err)
+ {
+ grub_netbuff_free (nb_ack);
+ return err;
+ }
+
+ err = grub_netbuff_put (nb_ack, sizeof (*tcph));
+ if (err)
+ {
+ grub_netbuff_free (nb_ack);
+ return err;
+ }
+ tcph = (void *) nb_ack->data;
+ tcph->ack = grub_cpu_to_be32 (sock->their_cur_seq);
+ tcph->flags = grub_cpu_to_be16_compile_time ((5 << 12) | TCP_SYN | TCP_ACK);
+ tcph->window = grub_cpu_to_be16 (sock->my_window);
+ tcph->urgent = 0;
+ sock->established = 1;
+ tcp_socket_register (sock);
+ err = tcp_send (nb_ack, sock);
+ if (err)
+ return err;
+ sock->my_cur_seq++;
+ return GRUB_ERR_NONE;
+}
+
+grub_net_tcp_socket_t
+grub_net_tcp_open (char *server,
+ grub_uint16_t out_port,
+ grub_err_t (*recv_hook) (grub_net_tcp_socket_t sock,
+ struct grub_net_buff *nb,
+ void *data),
+ void (*error_hook) (grub_net_tcp_socket_t sock,
+ void *data),
+ void (*fin_hook) (grub_net_tcp_socket_t sock,
+ void *data),
+ void *hook_data)
+{
+ grub_err_t err;
+ grub_net_network_level_address_t addr;
+ struct grub_net_network_level_interface *inf;
+ grub_net_network_level_address_t gateway;
+ grub_net_tcp_socket_t socket;
+ static grub_uint16_t in_port = 21550;
+ struct grub_net_buff *nb;
+ struct tcphdr *tcph;
+ int i;
+ grub_uint8_t *nbd;
+ grub_net_link_level_address_t ll_target_addr;
+
+ err = grub_net_resolve_address (server, &addr);
+ if (err)
+ return NULL;
+
+ if (addr.type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
+ && addr.type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6)
+ {
+ grub_error (GRUB_ERR_BUG, "not an IP address");
+ return NULL;
+ }
+
+ err = grub_net_route_address (addr, &gateway, &inf);
+ if (err)
+ return NULL;
+
+ err = grub_net_link_layer_resolve (inf, &gateway, &ll_target_addr);
+ if (err)
+ return NULL;
+
+ socket = grub_zalloc (sizeof (*socket));
+ if (socket == NULL)
+ return NULL;
+
+ socket->out_port = out_port;
+ socket->inf = inf;
+ socket->out_nla = addr;
+ socket->ll_target_addr = ll_target_addr;
+ socket->in_port = in_port++;
+ socket->recv_hook = recv_hook;
+ socket->error_hook = error_hook;
+ socket->fin_hook = fin_hook;
+ socket->hook_data = hook_data;
+
+ nb = grub_netbuff_alloc (sizeof (*tcph) + 128);
+ if (!nb)
+ {
+ grub_free (socket);
+ return NULL;
+ }
+
+ err = grub_netbuff_reserve (nb, 128);
+ if (err)
+ {
+ grub_free (socket);
+ grub_netbuff_free (nb);
+ return NULL;
+ }
+
+ 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;
+ }
+
+ tcph = (void *) nb->data;
+ socket->my_start_seq = grub_get_time_ms ();
+ socket->my_cur_seq = socket->my_start_seq + 1;
+ socket->my_window = 8192;
+ tcph->seqnr = grub_cpu_to_be32 (socket->my_start_seq);
+ tcph->ack = grub_cpu_to_be32_compile_time (0);
+ tcph->flags = grub_cpu_to_be16_compile_time ((5 << 12) | TCP_SYN);
+ tcph->window = grub_cpu_to_be16 (socket->my_window);
+ tcph->urgent = 0;
+ tcph->src = grub_cpu_to_be16 (socket->in_port);
+ tcph->dst = grub_cpu_to_be16 (socket->out_port);
+ tcph->checksum = 0;
+ tcph->checksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_TCP,
+ &socket->inf->address,
+ &socket->out_nla);
+
+ tcp_socket_register (socket);
+
+ nbd = nb->data;
+ for (i = 0; i < TCP_SYN_RETRANSMISSION_COUNT; i++)
+ {
+ int j;
+ nb->data = nbd;
+ err = grub_net_send_ip_packet (socket->inf, &(socket->out_nla),
+ &(socket->ll_target_addr), nb,
+ GRUB_NET_IP_TCP);
+ if (err)
+ {
+ grub_list_remove (GRUB_AS_LIST (socket));
+ grub_free (socket);
+ grub_netbuff_free (nb);
+ return NULL;
+ }
+ for (j = 0; (j < TCP_SYN_RETRANSMISSION_TIMEOUT / 50
+ && !socket->established); j++)
+ grub_net_poll_cards (50, &socket->established);
+ if (socket->established)
+ break;
+ }
+ if (!socket->established)
+ {
+ grub_list_remove (GRUB_AS_LIST (socket));
+ if (socket->they_reseted)
+ grub_error (GRUB_ERR_NET_PORT_CLOSED,
+ N_("connection refused"));
+ else
+ grub_error (GRUB_ERR_NET_NO_ANSWER,
+ N_("connection timeout"));
+
+ grub_netbuff_free (nb);
+ destroy_pq (socket);
+ grub_free (socket);
+ return NULL;
+ }
+
+ grub_netbuff_free (nb);
+ return socket;
+}
+
+grub_err_t
+grub_net_send_tcp_packet (const grub_net_tcp_socket_t socket,
+ struct grub_net_buff *nb, int push)
+{
+ struct tcphdr *tcph;
+ grub_err_t err;
+ grub_ssize_t fraglen;
+ COMPILE_TIME_ASSERT (sizeof (struct tcphdr) == GRUB_NET_TCP_HEADER_SIZE);
+ if (socket->out_nla.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4)
+ fraglen = (socket->inf->card->mtu - GRUB_NET_OUR_IPV4_HEADER_SIZE
+ - sizeof (*tcph));
+ else
+ fraglen = 1280 - GRUB_NET_OUR_IPV6_HEADER_SIZE;
+
+ while (nb->tail - nb->data > fraglen)
+ {
+ struct grub_net_buff *nb2;
+
+ nb2 = grub_netbuff_alloc (fraglen + sizeof (*tcph)
+ + GRUB_NET_OUR_MAX_IP_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE);
+ if (!nb2)
+ return grub_errno;
+ err = grub_netbuff_reserve (nb2, GRUB_NET_MAX_LINK_HEADER_SIZE
+ + GRUB_NET_OUR_MAX_IP_HEADER_SIZE);
+ if (err)
+ return err;
+ err = grub_netbuff_put (nb2, sizeof (*tcph));
+ if (err)
+ return err;
+
+ tcph = (struct tcphdr *) nb2->data;
+ tcph->ack = grub_cpu_to_be32 (socket->their_cur_seq);
+ tcph->flags = grub_cpu_to_be16_compile_time ((5 << 12) | TCP_ACK);
+ tcph->window = !socket->i_stall ? grub_cpu_to_be16 (socket->my_window)
+ : 0;
+ tcph->urgent = 0;
+ err = grub_netbuff_put (nb2, fraglen);
+ if (err)
+ return err;
+ grub_memcpy (tcph + 1, nb->data, fraglen);
+ err = grub_netbuff_pull (nb, fraglen);
+ if (err)
+ return err;
+
+ err = tcp_send (nb2, socket);
+ if (err)
+ return err;
+ }
+
+ err = grub_netbuff_push (nb, sizeof (*tcph));
+ if (err)
+ return err;
+
+ tcph = (struct tcphdr *) nb->data;
+ tcph->ack = grub_cpu_to_be32 (socket->their_cur_seq);
+ tcph->flags = (grub_cpu_to_be16_compile_time ((5 << 12) | TCP_ACK)
+ | (push ? grub_cpu_to_be16_compile_time (TCP_PUSH) : 0));
+ tcph->window = !socket->i_stall ? grub_cpu_to_be16 (socket->my_window) : 0;
+ tcph->urgent = 0;
+ return tcp_send (nb, socket);
+}
+
+grub_err_t
+grub_net_recv_tcp_packet (struct grub_net_buff *nb,
+ struct grub_net_network_level_interface *inf,
+ const grub_net_network_level_address_t *source)
+{
+ struct tcphdr *tcph;
+ grub_net_tcp_socket_t sock;
+ grub_err_t err;
+
+ /* Ignore broadcast. */
+ if (!inf)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ tcph = (struct tcphdr *) nb->data;
+ if ((grub_be_to_cpu16 (tcph->flags) >> 12) < 5)
+ {
+ grub_dprintf ("net", "TCP header too short: %u\n",
+ grub_be_to_cpu16 (tcph->flags) >> 12);
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ if (nb->tail - nb->data < (grub_ssize_t) ((grub_be_to_cpu16 (tcph->flags)
+ >> 12) * sizeof (grub_uint32_t)))
+ {
+ grub_dprintf ("net", "TCP packet too short: %" PRIuGRUB_SIZE "\n",
+ (grub_size_t) (nb->tail - nb->data));
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ FOR_TCP_SOCKETS (sock)
+ {
+ if (!(grub_be_to_cpu16 (tcph->dst) == sock->in_port
+ && grub_be_to_cpu16 (tcph->src) == sock->out_port
+ && inf == sock->inf
+ && grub_net_addr_cmp (source, &sock->out_nla) == 0))
+ continue;
+ if (tcph->checksum)
+ {
+ grub_uint16_t chk, expected;
+ chk = tcph->checksum;
+ tcph->checksum = 0;
+ expected = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_TCP,
+ &sock->out_nla,
+ &sock->inf->address);
+ if (expected != chk)
+ {
+ grub_dprintf ("net", "Invalid TCP checksum. "
+ "Expected %x, got %x\n",
+ grub_be_to_cpu16 (expected),
+ grub_be_to_cpu16 (chk));
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ tcph->checksum = chk;
+ }
+
+ if ((grub_be_to_cpu16 (tcph->flags) & TCP_SYN)
+ && (grub_be_to_cpu16 (tcph->flags) & TCP_ACK)
+ && !sock->established)
+ {
+ sock->their_start_seq = grub_be_to_cpu32 (tcph->seqnr);
+ sock->their_cur_seq = sock->their_start_seq + 1;
+ sock->established = 1;
+ }
+
+ if (grub_be_to_cpu16 (tcph->flags) & TCP_RST)
+ {
+ sock->they_reseted = 1;
+
+ error (sock);
+
+ grub_netbuff_free (nb);
+
+ return GRUB_ERR_NONE;
+ }
+
+ if (grub_be_to_cpu16 (tcph->flags) & TCP_ACK)
+ {
+ struct unacked *unack, *next;
+ grub_uint32_t acked = grub_be_to_cpu32 (tcph->ack);
+ for (unack = sock->unack_first; unack; unack = next)
+ {
+ grub_uint32_t seqnr;
+ struct tcphdr *unack_tcph;
+ next = unack->next;
+ seqnr = grub_be_to_cpu32 (((struct tcphdr *) unack->nb->data)
+ ->seqnr);
+ unack_tcph = (struct tcphdr *) unack->nb->data;
+ seqnr += (unack->nb->tail - unack->nb->data
+ - (grub_be_to_cpu16 (unack_tcph->flags) >> 12) * 4);
+ if (grub_be_to_cpu16 (unack_tcph->flags) & TCP_FIN)
+ seqnr++;
+
+ if (seqnr > acked)
+ break;
+ grub_netbuff_free (unack->nb);
+ grub_free (unack);
+ }
+ sock->unack_first = unack;
+ if (!sock->unack_first)
+ sock->unack_last = NULL;
+ }
+
+ if (grub_be_to_cpu32 (tcph->seqnr) < sock->their_cur_seq)
+ {
+ ack (sock);
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ if (sock->i_reseted && (nb->tail - nb->data
+ - (grub_be_to_cpu16 (tcph->flags)
+ >> 12) * sizeof (grub_uint32_t)) > 0)
+ {
+ reset (sock);
+ }
+
+ err = grub_priority_queue_push (sock->pq, &nb);
+ if (err)
+ {
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ {
+ struct grub_net_buff **nb_top_p, *nb_top;
+ int do_ack = 0;
+ int just_closed = 0;
+ while (1)
+ {
+ nb_top_p = grub_priority_queue_top (sock->pq);
+ if (!nb_top_p)
+ return GRUB_ERR_NONE;
+ nb_top = *nb_top_p;
+ tcph = (struct tcphdr *) nb_top->data;
+ if (grub_be_to_cpu32 (tcph->seqnr) >= sock->their_cur_seq)
+ break;
+ grub_netbuff_free (nb_top);
+ grub_priority_queue_pop (sock->pq);
+ }
+ if (grub_be_to_cpu32 (tcph->seqnr) != sock->their_cur_seq)
+ {
+ ack (sock);
+ return GRUB_ERR_NONE;
+ }
+ while (1)
+ {
+ nb_top_p = grub_priority_queue_top (sock->pq);
+ if (!nb_top_p)
+ break;
+ nb_top = *nb_top_p;
+ tcph = (struct tcphdr *) nb_top->data;
+
+ if (grub_be_to_cpu32 (tcph->seqnr) != sock->their_cur_seq)
+ break;
+ grub_priority_queue_pop (sock->pq);
+
+ err = grub_netbuff_pull (nb_top, (grub_be_to_cpu16 (tcph->flags)
+ >> 12) * sizeof (grub_uint32_t));
+ if (err)
+ {
+ grub_netbuff_free (nb_top);
+ return err;
+ }
+
+ sock->their_cur_seq += (nb_top->tail - nb_top->data);
+ if (grub_be_to_cpu16 (tcph->flags) & TCP_FIN)
+ {
+ sock->they_closed = 1;
+ just_closed = 1;
+ sock->their_cur_seq++;
+ do_ack = 1;
+ }
+ /* If there is data, puts packet in socket list. */
+ if ((nb_top->tail - nb_top->data) > 0)
+ {
+ grub_net_put_packet (&sock->packs, nb_top);
+ do_ack = 1;
+ }
+ else
+ grub_netbuff_free (nb_top);
+ }
+ if (do_ack)
+ ack (sock);
+ while (sock->packs.first)
+ {
+ nb = sock->packs.first->nb;
+ if (sock->recv_hook)
+ sock->recv_hook (sock, sock->packs.first->nb, sock->hook_data);
+ else
+ grub_netbuff_free (nb);
+ grub_net_remove_packet (sock->packs.first);
+ }
+
+ if (sock->fin_hook && just_closed)
+ sock->fin_hook (sock, sock->hook_data);
+ }
+
+ return GRUB_ERR_NONE;
+ }
+ if (grub_be_to_cpu16 (tcph->flags) & TCP_SYN)
+ {
+ grub_net_tcp_listen_t listen;
+
+ FOR_TCP_LISTENS (listen)
+ {
+ if (!(grub_be_to_cpu16 (tcph->dst) == listen->port
+ && (inf == listen->inf || listen->inf == NULL)))
+ continue;
+ sock = grub_zalloc (sizeof (*sock));
+ if (sock == NULL)
+ return grub_errno;
+
+ sock->out_port = grub_be_to_cpu16 (tcph->src);
+ sock->in_port = grub_be_to_cpu16 (tcph->dst);
+ sock->inf = inf;
+ sock->out_nla = *source;
+ sock->their_start_seq = grub_be_to_cpu32 (tcph->seqnr);
+ sock->their_cur_seq = sock->their_start_seq + 1;
+ sock->my_cur_seq = sock->my_start_seq = grub_get_time_ms ();
+ sock->my_window = 8192;
+
+ sock->pq = grub_priority_queue_new (sizeof (struct grub_net_buff *),
+ cmp);
+ if (!sock->pq)
+ {
+ grub_free (sock);
+ grub_netbuff_free (nb);
+ return grub_errno;
+ }
+
+ err = listen->listen_hook (listen, sock, listen->hook_data);
+
+ grub_netbuff_free (nb);
+ return err;
+
+ }
+ }
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_net_tcp_stall (grub_net_tcp_socket_t sock)
+{
+ if (sock->i_stall)
+ return;
+ sock->i_stall = 1;
+ ack (sock);
+}
+
+void
+grub_net_tcp_unstall (grub_net_tcp_socket_t sock)
+{
+ if (!sock->i_stall)
+ return;
+ sock->i_stall = 0;
+ ack (sock);
+}
diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
new file mode 100644
index 0000000..7f44b30
--- /dev/null
+++ b/grub-core/net/tftp.c
@@ -0,0 +1,479 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net/udp.h>
+#include <grub/net/ip.h>
+#include <grub/net/ethernet.h>
+#include <grub/net/netbuff.h>
+#include <grub/net.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/file.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* IP port for the MTFTP server used for Intel's PXE */
+enum
+ {
+ MTFTP_SERVER_PORT = 75,
+ MTFTP_CLIENT_PORT = 76,
+ /* IP port for the TFTP server */
+ TFTP_SERVER_PORT = 69
+ };
+
+enum
+ {
+ TFTP_DEFAULTSIZE_PACKET = 512,
+ };
+
+enum
+ {
+ TFTP_CODE_EOF = 1,
+ TFTP_CODE_MORE = 2,
+ TFTP_CODE_ERROR = 3,
+ TFTP_CODE_BOOT = 4,
+ TFTP_CODE_CFG = 5
+ };
+
+enum
+ {
+ TFTP_RRQ = 1,
+ TFTP_WRQ = 2,
+ TFTP_DATA = 3,
+ TFTP_ACK = 4,
+ TFTP_ERROR = 5,
+ TFTP_OACK = 6
+ };
+
+enum
+ {
+ TFTP_EUNDEF = 0, /* not defined */
+ TFTP_ENOTFOUND = 1, /* file not found */
+ TFTP_EACCESS = 2, /* access violation */
+ TFTP_ENOSPACE = 3, /* disk full or allocation exceeded */
+ TFTP_EBADOP = 4, /* illegal TFTP operation */
+ TFTP_EBADID = 5, /* unknown transfer ID */
+ TFTP_EEXISTS = 6, /* file already exists */
+ TFTP_ENOUSER = 7 /* no such user */
+ };
+
+struct tftphdr {
+ grub_uint16_t opcode;
+ union {
+ grub_int8_t rrq[TFTP_DEFAULTSIZE_PACKET];
+ struct {
+ grub_uint16_t block;
+ grub_int8_t download[0];
+ } data;
+ struct {
+ grub_uint16_t block;
+ } ack;
+ struct {
+ grub_uint16_t errcode;
+ grub_int8_t errmsg[TFTP_DEFAULTSIZE_PACKET];
+ } err;
+ struct {
+ grub_int8_t data[TFTP_DEFAULTSIZE_PACKET+2];
+ } oack;
+ } u;
+} GRUB_PACKED ;
+
+
+typedef struct tftp_data
+{
+ grub_uint64_t file_size;
+ grub_uint64_t block;
+ grub_uint32_t block_size;
+ grub_uint64_t ack_sent;
+ int have_oack;
+ struct grub_error_saved save_err;
+ grub_net_udp_socket_t sock;
+} *tftp_data_t;
+
+static grub_err_t
+ack (tftp_data_t data, grub_uint64_t block)
+{
+ struct tftphdr *tftph_ack;
+ grub_uint8_t nbdata[512];
+ struct grub_net_buff nb_ack;
+ grub_err_t err;
+
+ nb_ack.head = nbdata;
+ nb_ack.end = nbdata + sizeof (nbdata);
+ grub_netbuff_clear (&nb_ack);
+ grub_netbuff_reserve (&nb_ack, 512);
+ err = grub_netbuff_push (&nb_ack, sizeof (tftph_ack->opcode)
+ + sizeof (tftph_ack->u.ack.block));
+ if (err)
+ return err;
+
+ tftph_ack = (struct tftphdr *) nb_ack.data;
+ 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);
+ if (err)
+ return err;
+ data->ack_sent = block;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)),
+ struct grub_net_buff *nb,
+ void *f)
+{
+ grub_file_t file = f;
+ struct tftphdr *tftph = (void *) nb->data;
+ tftp_data_t data = file->data;
+ grub_err_t err;
+ grub_uint8_t *ptr;
+
+ if (nb->tail - nb->data < (grub_ssize_t) sizeof (tftph->opcode))
+ {
+ grub_dprintf ("tftp", "TFTP packet too small\n");
+ return GRUB_ERR_NONE;
+ }
+
+ tftph = (struct tftphdr *) nb->data;
+ switch (grub_be_to_cpu16 (tftph->opcode))
+ {
+ case TFTP_OACK:
+ data->block_size = TFTP_DEFAULTSIZE_PACKET;
+ data->have_oack = 1;
+ for (ptr = nb->data + sizeof (tftph->opcode); ptr < nb->tail;)
+ {
+ if (grub_memcmp (ptr, "tsize\0", sizeof ("tsize\0") - 1) == 0)
+ data->file_size = grub_strtoul ((char *) ptr + sizeof ("tsize\0")
+ - 1, 0, 0);
+ if (grub_memcmp (ptr, "blksize\0", sizeof ("blksize\0") - 1) == 0)
+ data->block_size = grub_strtoul ((char *) ptr + sizeof ("blksize\0")
+ - 1, 0, 0);
+ while (ptr < nb->tail && *ptr)
+ ptr++;
+ ptr++;
+ }
+ data->block = 0;
+ grub_netbuff_free (nb);
+ err = ack (data, 0);
+ grub_error_save (&data->save_err);
+ return GRUB_ERR_NONE;
+ case TFTP_DATA:
+ if (nb->tail - nb->data < (grub_ssize_t) (sizeof (tftph->opcode)
+ + sizeof (tftph->u.data.block)))
+ {
+ grub_dprintf ("tftp", "TFTP packet too small\n");
+ return GRUB_ERR_NONE;
+ }
+
+ /*
+ * Ack old/retransmitted block.
+ *
+ * The block number is a 16-bit counter, thus the maximum file size that
+ * could be transfered is 65535 * block size. Most TFTP hosts support to
+ * roll-over the block counter to allow unlimited transfer file size.
+ *
+ * This behavior is not defined in the RFC 1350 [0] but is implemented by
+ * most TFTP clients and hosts.
+ *
+ * [0]: https://tools.ietf.org/html/rfc1350
+ */
+ if (grub_be_to_cpu16 (tftph->u.data.block) < ((grub_uint16_t) (data->block + 1)))
+ ack (data, grub_be_to_cpu16 (tftph->u.data.block));
+ /* Ignore unexpected block. */
+ else if (grub_be_to_cpu16 (tftph->u.data.block) > ((grub_uint16_t) (data->block + 1)))
+ grub_dprintf ("tftp", "TFTP unexpected block # %d\n", tftph->u.data.block);
+ else
+ {
+ unsigned size;
+
+ if (file->device->net->packs.count < 50)
+ {
+ err = ack (data, data->block + 1);
+ if (err)
+ return err;
+ }
+ else
+ file->device->net->stall = 1;
+
+ err = grub_netbuff_pull (nb, sizeof (tftph->opcode) +
+ sizeof (tftph->u.data.block));
+ if (err)
+ return err;
+ size = nb->tail - nb->data;
+
+ data->block++;
+ if (size < data->block_size)
+ {
+ if (data->ack_sent < data->block)
+ ack (data, data->block);
+ file->device->net->eof = 1;
+ file->device->net->stall = 1;
+ grub_net_udp_close (data->sock);
+ data->sock = NULL;
+ }
+ /*
+ * Prevent garbage in broken cards. Is it still necessary
+ * given that IP implementation has been fixed?
+ */
+ if (size > data->block_size)
+ {
+ err = grub_netbuff_unput (nb, size - data->block_size);
+ if (err)
+ return err;
+ }
+ /* If there is data, puts packet in socket list. */
+ if ((nb->tail - nb->data) > 0)
+ {
+ grub_net_put_packet (&file->device->net->packs, nb);
+ /* Do not free nb. */
+ return GRUB_ERR_NONE;
+ }
+ }
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ case TFTP_ERROR:
+ data->have_oack = 1;
+ grub_netbuff_free (nb);
+ grub_error (GRUB_ERR_IO, "%s", tftph->u.err.errmsg);
+ grub_error_save (&data->save_err);
+ return GRUB_ERR_NONE;
+ default:
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+}
+
+/*
+ * Create a normalized copy of the filename. Compress any string of consecutive
+ * forward slashes to a single forward slash.
+ */
+static void
+grub_normalize_filename (char *normalized, const char *filename)
+{
+ char *dest = normalized;
+ const char *src = filename;
+
+ while (*src != '\0')
+ {
+ if (src[0] == '/' && src[1] == '/')
+ src++;
+ else
+ *dest++ = *src++;
+ }
+ *dest = '\0';
+}
+
+static grub_err_t
+tftp_open (struct grub_file *file, const char *filename)
+{
+ struct tftphdr *tftph;
+ char *rrq;
+ int i;
+ int rrqlen;
+ int hdrlen;
+ grub_uint8_t open_data[1500];
+ struct grub_net_buff nb;
+ tftp_data_t data;
+ grub_err_t err;
+ grub_uint8_t *nbd;
+ grub_net_network_level_address_t addr;
+
+ data = grub_zalloc (sizeof (*data));
+ if (!data)
+ return grub_errno;
+
+ nb.head = open_data;
+ nb.end = open_data + sizeof (open_data);
+ grub_netbuff_clear (&nb);
+
+ grub_netbuff_reserve (&nb, 1500);
+ err = grub_netbuff_push (&nb, sizeof (*tftph));
+ if (err)
+ {
+ grub_free (data);
+ return err;
+ }
+
+ tftph = (struct tftphdr *) nb.data;
+
+ rrq = (char *) tftph->u.rrq;
+ rrqlen = 0;
+
+ tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_RRQ);
+
+ /*
+ * Copy and normalize the filename to work-around issues on some TFTP
+ * servers when file names are being matched for remapping.
+ */
+ grub_normalize_filename (rrq, filename);
+ rrqlen += grub_strlen (rrq) + 1;
+ rrq += grub_strlen (rrq) + 1;
+
+ grub_strcpy (rrq, "octet");
+ rrqlen += grub_strlen ("octet") + 1;
+ rrq += grub_strlen ("octet") + 1;
+
+ grub_strcpy (rrq, "blksize");
+ rrqlen += grub_strlen ("blksize") + 1;
+ rrq += grub_strlen ("blksize") + 1;
+
+ grub_strcpy (rrq, "1024");
+ rrqlen += grub_strlen ("1024") + 1;
+ rrq += grub_strlen ("1024") + 1;
+
+ grub_strcpy (rrq, "tsize");
+ rrqlen += grub_strlen ("tsize") + 1;
+ rrq += grub_strlen ("tsize") + 1;
+
+ grub_strcpy (rrq, "0");
+ rrqlen += grub_strlen ("0") + 1;
+ rrq += grub_strlen ("0") + 1;
+ hdrlen = sizeof (tftph->opcode) + rrqlen;
+
+ err = grub_netbuff_unput (&nb, nb.tail - (nb.data + hdrlen));
+ if (err)
+ {
+ grub_free (data);
+ return err;
+ }
+
+ file->not_easily_seekable = 1;
+ file->data = data;
+
+ err = grub_net_resolve_address (file->device->net->server, &addr);
+ if (err)
+ {
+ grub_free (data);
+ return err;
+ }
+
+ data->sock = grub_net_udp_open (addr,
+ TFTP_SERVER_PORT, tftp_receive,
+ file);
+ if (!data->sock)
+ {
+ grub_free (data);
+ return grub_errno;
+ }
+
+ /* Receive OACK packet. */
+ nbd = nb.data;
+ for (i = 0; i < GRUB_NET_TRIES; i++)
+ {
+ nb.data = nbd;
+ err = grub_net_send_udp_packet (data->sock, &nb);
+ if (err)
+ {
+ grub_net_udp_close (data->sock);
+ grub_free (data);
+ return err;
+ }
+ grub_net_poll_cards (GRUB_NET_INTERVAL + (i * GRUB_NET_INTERVAL_ADDITION),
+ &data->have_oack);
+ if (data->have_oack)
+ break;
+ }
+
+ if (!data->have_oack)
+ grub_error (GRUB_ERR_TIMEOUT, N_("time out opening `%s'"), filename);
+ else
+ grub_error_load (&data->save_err);
+ if (grub_errno)
+ {
+ grub_net_udp_close (data->sock);
+ grub_free (data);
+ return grub_errno;
+ }
+
+ file->size = data->file_size;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+tftp_close (struct grub_file *file)
+{
+ tftp_data_t data = file->data;
+
+ if (data->sock)
+ {
+ grub_uint8_t nbdata[512];
+ grub_err_t err;
+ struct grub_net_buff nb_err;
+ struct tftphdr *tftph;
+
+ nb_err.head = nbdata;
+ nb_err.end = nbdata + sizeof (nbdata);
+
+ grub_netbuff_clear (&nb_err);
+ grub_netbuff_reserve (&nb_err, 512);
+ err = grub_netbuff_push (&nb_err, sizeof (tftph->opcode)
+ + sizeof (tftph->u.err.errcode)
+ + sizeof ("closed"));
+ if (!err)
+ {
+ tftph = (struct tftphdr *) nb_err.data;
+ 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);
+ }
+ if (err)
+ grub_print_error ();
+ grub_net_udp_close (data->sock);
+ }
+ grub_free (data);
+ file->data = NULL;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+tftp_packets_pulled (struct grub_file *file)
+{
+ tftp_data_t data = file->data;
+ if (file->device->net->packs.count >= 50)
+ return 0;
+
+ if (!file->device->net->eof)
+ file->device->net->stall = 0;
+ if (data->ack_sent >= data->block)
+ return 0;
+ return ack (data, data->block);
+}
+
+static struct grub_net_app_protocol grub_tftp_protocol =
+ {
+ .name = "tftp",
+ .open = tftp_open,
+ .close = tftp_close,
+ .packets_pulled = tftp_packets_pulled
+ };
+
+GRUB_MOD_INIT (tftp)
+{
+ grub_net_app_level_register (&grub_tftp_protocol);
+}
+
+GRUB_MOD_FINI (tftp)
+{
+ grub_net_app_level_unregister (&grub_tftp_protocol);
+}
diff --git a/grub-core/net/udp.c b/grub-core/net/udp.c
new file mode 100644
index 0000000..df7fb95
--- /dev/null
+++ b/grub-core/net/udp.c
@@ -0,0 +1,211 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/net.h>
+#include <grub/net/udp.h>
+#include <grub/net/ip.h>
+#include <grub/net/netbuff.h>
+#include <grub/time.h>
+
+struct grub_net_udp_socket
+{
+ struct grub_net_udp_socket *next;
+ struct grub_net_udp_socket **prev;
+
+ enum { GRUB_NET_SOCKET_START,
+ GRUB_NET_SOCKET_ESTABLISHED,
+ GRUB_NET_SOCKET_CLOSED } status;
+ int in_port;
+ int out_port;
+ grub_err_t (*recv_hook) (grub_net_udp_socket_t sock, struct grub_net_buff *nb,
+ void *recv);
+ void *recv_hook_data;
+ grub_net_network_level_address_t out_nla;
+ grub_net_link_level_address_t ll_target_addr;
+ struct grub_net_network_level_interface *inf;
+};
+
+static struct grub_net_udp_socket *udp_sockets;
+
+#define FOR_UDP_SOCKETS(var) for (var = udp_sockets; var; var = var->next)
+
+static inline void
+udp_socket_register (grub_net_udp_socket_t sock)
+{
+ grub_list_push (GRUB_AS_LIST_P (&udp_sockets),
+ GRUB_AS_LIST (sock));
+}
+
+void
+grub_net_udp_close (grub_net_udp_socket_t sock)
+{
+ grub_list_remove (GRUB_AS_LIST (sock));
+ grub_free (sock);
+}
+
+grub_net_udp_socket_t
+grub_net_udp_open (grub_net_network_level_address_t addr,
+ grub_uint16_t out_port,
+ grub_err_t (*recv_hook) (grub_net_udp_socket_t sock,
+ struct grub_net_buff *nb,
+ void *data),
+ void *recv_hook_data)
+{
+ grub_err_t err;
+ struct grub_net_network_level_interface *inf;
+ grub_net_network_level_address_t gateway;
+ grub_net_udp_socket_t socket;
+ static int in_port = 25300;
+ grub_net_link_level_address_t ll_target_addr;
+
+ if (addr.type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
+ && addr.type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6)
+ {
+ grub_error (GRUB_ERR_BUG, "not an IP address");
+ return NULL;
+ }
+
+ err = grub_net_route_address (addr, &gateway, &inf);
+ if (err)
+ return NULL;
+
+ err = grub_net_link_layer_resolve (inf, &gateway, &ll_target_addr);
+ if (err)
+ return NULL;
+
+ socket = grub_zalloc (sizeof (*socket));
+ if (socket == NULL)
+ return NULL;
+
+ socket->out_port = out_port;
+ socket->inf = inf;
+ socket->out_nla = addr;
+ socket->ll_target_addr = ll_target_addr;
+ socket->in_port = in_port++;
+ socket->status = GRUB_NET_SOCKET_START;
+ socket->recv_hook = recv_hook;
+ socket->recv_hook_data = recv_hook_data;
+
+ udp_socket_register (socket);
+
+ return socket;
+}
+
+grub_err_t
+grub_net_send_udp_packet (const grub_net_udp_socket_t socket,
+ struct grub_net_buff *nb)
+{
+ struct udphdr *udph;
+ grub_err_t err;
+
+ COMPILE_TIME_ASSERT (GRUB_NET_UDP_HEADER_SIZE == sizeof (*udph));
+
+ err = grub_netbuff_push (nb, sizeof (*udph));
+ if (err)
+ return err;
+
+ udph = (struct udphdr *) nb->data;
+ udph->src = grub_cpu_to_be16 (socket->in_port);
+ udph->dst = grub_cpu_to_be16 (socket->out_port);
+
+ udph->chksum = 0;
+ udph->len = grub_cpu_to_be16 (nb->tail - nb->data);
+
+ udph->chksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_UDP,
+ &socket->inf->address,
+ &socket->out_nla);
+
+ return grub_net_send_ip_packet (socket->inf, &(socket->out_nla),
+ &(socket->ll_target_addr), nb,
+ GRUB_NET_IP_UDP);
+}
+
+grub_err_t
+grub_net_recv_udp_packet (struct grub_net_buff *nb,
+ struct grub_net_network_level_interface *inf,
+ const grub_net_network_level_address_t *source)
+{
+ struct udphdr *udph;
+ grub_net_udp_socket_t sock;
+ grub_err_t err;
+
+ /* Ignore broadcast. */
+ if (!inf)
+ {
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ udph = (struct udphdr *) nb->data;
+ if (nb->tail - nb->data < (grub_ssize_t) sizeof (*udph))
+ {
+ grub_dprintf ("net", "UDP packet too short: %" PRIuGRUB_SIZE "\n",
+ (grub_size_t) (nb->tail - nb->data));
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+
+ FOR_UDP_SOCKETS (sock)
+ {
+ if (grub_be_to_cpu16 (udph->dst) == sock->in_port
+ && inf == sock->inf
+ && grub_net_addr_cmp (source, &sock->out_nla) == 0
+ && (sock->status == GRUB_NET_SOCKET_START
+ || grub_be_to_cpu16 (udph->src) == sock->out_port))
+ {
+ if (udph->chksum)
+ {
+ grub_uint16_t chk, expected;
+ chk = udph->chksum;
+ udph->chksum = 0;
+ expected = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_UDP,
+ &sock->out_nla,
+ &sock->inf->address);
+ if (expected != chk)
+ {
+ grub_dprintf ("net", "Invalid UDP checksum. "
+ "Expected %x, got %x\n",
+ grub_be_to_cpu16 (expected),
+ grub_be_to_cpu16 (chk));
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ udph->chksum = chk;
+ }
+
+ if (sock->status == GRUB_NET_SOCKET_START)
+ {
+ sock->out_port = grub_be_to_cpu16 (udph->src);
+ sock->status = GRUB_NET_SOCKET_ESTABLISHED;
+ }
+
+ err = grub_netbuff_pull (nb, sizeof (*udph));
+ if (err)
+ return err;
+
+ /* App protocol remove its own reader. */
+ if (sock->recv_hook)
+ sock->recv_hook (sock, nb, sock->recv_hook_data);
+ else
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+ }
+ }
+ grub_netbuff_free (nb);
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c
new file mode 100644
index 0000000..6be678c
--- /dev/null
+++ b/grub-core/normal/auth.c
@@ -0,0 +1,278 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/auth.h>
+#include <grub/list.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/normal.h>
+#include <grub/time.h>
+#include <grub/i18n.h>
+
+struct grub_auth_user
+{
+ struct grub_auth_user *next;
+ struct grub_auth_user **prev;
+ char *name;
+ grub_auth_callback_t callback;
+ void *arg;
+ int authenticated;
+};
+
+static struct grub_auth_user *users = NULL;
+
+grub_err_t
+grub_auth_register_authentication (const char *user,
+ grub_auth_callback_t callback,
+ void *arg)
+{
+ struct grub_auth_user *cur;
+
+ cur = grub_named_list_find (GRUB_AS_NAMED_LIST (users), user);
+ if (!cur)
+ cur = grub_zalloc (sizeof (*cur));
+ if (!cur)
+ return grub_errno;
+ cur->callback = callback;
+ cur->arg = arg;
+ if (! cur->name)
+ {
+ cur->name = grub_strdup (user);
+ if (!cur->name)
+ {
+ grub_free (cur);
+ return grub_errno;
+ }
+ grub_list_push (GRUB_AS_LIST_P (&users), GRUB_AS_LIST (cur));
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_auth_unregister_authentication (const char *user)
+{
+ struct grub_auth_user *cur;
+ cur = grub_named_list_find (GRUB_AS_NAMED_LIST (users), user);
+ if (!cur)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "user '%s' not found", user);
+ if (!cur->authenticated)
+ {
+ grub_free (cur->name);
+ grub_list_remove (GRUB_AS_LIST (cur));
+ grub_free (cur);
+ }
+ else
+ {
+ cur->callback = NULL;
+ cur->arg = NULL;
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_auth_authenticate (const char *user)
+{
+ struct grub_auth_user *cur;
+
+ cur = grub_named_list_find (GRUB_AS_NAMED_LIST (users), user);
+ if (!cur)
+ cur = grub_zalloc (sizeof (*cur));
+ if (!cur)
+ return grub_errno;
+
+ cur->authenticated = 1;
+
+ if (! cur->name)
+ {
+ cur->name = grub_strdup (user);
+ if (!cur->name)
+ {
+ grub_free (cur);
+ return grub_errno;
+ }
+ grub_list_push (GRUB_AS_LIST_P (&users), GRUB_AS_LIST (cur));
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_auth_deauthenticate (const char *user)
+{
+ struct grub_auth_user *cur;
+ cur = grub_named_list_find (GRUB_AS_NAMED_LIST (users), user);
+ if (!cur)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "user '%s' not found", user);
+ if (!cur->callback)
+ {
+ grub_free (cur->name);
+ grub_list_remove (GRUB_AS_LIST (cur));
+ grub_free (cur);
+ }
+ else
+ cur->authenticated = 0;
+ return GRUB_ERR_NONE;
+}
+
+static int
+is_authenticated (const char *userlist)
+{
+ const char *superusers;
+ struct grub_auth_user *user;
+
+ superusers = grub_env_get ("superusers");
+
+ if (!superusers)
+ return 1;
+
+ FOR_LIST_ELEMENTS (user, users)
+ {
+ if (!(user->authenticated))
+ continue;
+
+ if ((userlist && grub_strword (userlist, user->name))
+ || grub_strword (superusers, user->name))
+ return 1;
+ }
+
+ return 0;
+}
+
+static int
+grub_username_get (char buf[], unsigned buf_size)
+{
+ unsigned cur_len = 0;
+ int key;
+
+ while (1)
+ {
+ key = grub_getkey ();
+ if (key == '\n' || key == '\r')
+ break;
+
+ if (key == GRUB_TERM_ESC)
+ {
+ cur_len = 0;
+ break;
+ }
+
+ if (key == GRUB_TERM_BACKSPACE)
+ {
+ if (cur_len)
+ {
+ cur_len--;
+ grub_printf ("\b \b");
+ }
+ continue;
+ }
+
+ if (!grub_isprint (key))
+ continue;
+
+ if (cur_len + 2 < buf_size)
+ {
+ buf[cur_len++] = key;
+ grub_printf ("%c", key);
+ }
+ }
+
+ grub_memset (buf + cur_len, 0, buf_size - cur_len);
+
+ grub_xputs ("\n");
+ grub_refresh ();
+
+ return (key != GRUB_TERM_ESC);
+}
+
+grub_err_t
+grub_auth_check_authentication (const char *userlist)
+{
+ char login[1024];
+ struct grub_auth_user *cur = NULL;
+ static unsigned long punishment_delay = 1;
+ char entered[GRUB_AUTH_MAX_PASSLEN];
+ struct grub_auth_user *user;
+
+ grub_memset (login, 0, sizeof (login));
+
+ if (is_authenticated (userlist))
+ {
+ punishment_delay = 1;
+ return GRUB_ERR_NONE;
+ }
+
+ grub_puts_ (N_("Enter username: "));
+
+ if (!grub_username_get (login, sizeof (login) - 1))
+ goto access_denied;
+
+ grub_puts_ (N_("Enter password: "));
+
+ if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN))
+ goto access_denied;
+
+ FOR_LIST_ELEMENTS (user, users)
+ {
+ if (grub_strcmp (login, user->name) == 0)
+ cur = user;
+ }
+
+ if (!cur || ! cur->callback)
+ goto access_denied;
+
+ cur->callback (login, entered, cur->arg);
+ if (is_authenticated (userlist))
+ {
+ punishment_delay = 1;
+ return GRUB_ERR_NONE;
+ }
+
+ access_denied:
+ grub_sleep (punishment_delay);
+
+ if (punishment_delay < GRUB_ULONG_MAX / 2)
+ punishment_delay *= 2;
+
+ return GRUB_ACCESS_DENIED;
+}
+
+static grub_err_t
+grub_cmd_authenticate (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ return grub_auth_check_authentication ((argc >= 1) ? args[0] : "");
+}
+
+static grub_command_t cmd;
+
+void
+grub_normal_auth_init (void)
+{
+ cmd = grub_register_command ("authenticate",
+ grub_cmd_authenticate,
+ N_("[USERLIST]"),
+ N_("Check whether user is in USERLIST."));
+
+}
+
+void
+grub_normal_auth_fini (void)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/normal/autofs.c b/grub-core/normal/autofs.c
new file mode 100644
index 0000000..7a7cf2b
--- /dev/null
+++ b/grub-core/normal/autofs.c
@@ -0,0 +1,148 @@
+/* autofs.c - support auto-loading from fs.lst */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/fs.h>
+#include <grub/normal.h>
+
+/* This is used to store the names of filesystem modules for auto-loading. */
+static grub_named_list_t fs_module_list;
+
+/* The auto-loading hook for filesystems. */
+static int
+autoload_fs_module (void)
+{
+ grub_named_list_t p;
+ int ret = 0;
+
+ while ((p = fs_module_list) != NULL)
+ {
+ if (! grub_dl_get (p->name) && grub_dl_load (p->name))
+ {
+ ret = 1;
+ break;
+ }
+
+ if (grub_errno)
+ grub_print_error ();
+
+ fs_module_list = p->next;
+ grub_free (p->name);
+ grub_free (p);
+ }
+
+ return ret;
+}
+
+/* Read the file fs.lst for auto-loading. */
+void
+read_fs_list (const char *prefix)
+{
+ if (prefix)
+ {
+ char *filename;
+
+ filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM
+ "/fs.lst", prefix);
+ if (filename)
+ {
+ grub_file_t file;
+ grub_fs_autoload_hook_t tmp_autoload_hook;
+
+ /* This rules out the possibility that read_fs_list() is invoked
+ recursively when we call grub_file_open() below. */
+ tmp_autoload_hook = grub_fs_autoload_hook;
+ grub_fs_autoload_hook = NULL;
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
+ if (file)
+ {
+ /* Override previous fs.lst. */
+ while (fs_module_list)
+ {
+ grub_named_list_t tmp;
+ tmp = fs_module_list->next;
+ grub_free (fs_module_list);
+ fs_module_list = tmp;
+ }
+
+ while (1)
+ {
+ char *buf;
+ char *p;
+ char *q;
+ grub_named_list_t fs_mod;
+
+ buf = grub_file_getline (file);
+ if (! buf)
+ break;
+
+ p = buf;
+ q = buf + grub_strlen (buf) - 1;
+
+ /* Ignore space. */
+ while (grub_isspace (*p))
+ p++;
+
+ while (p < q && grub_isspace (*q))
+ *q-- = '\0';
+
+ /* If the line is empty, skip it. */
+ if (p >= q)
+ {
+ grub_free (buf);
+ continue;
+ }
+
+ fs_mod = grub_malloc (sizeof (*fs_mod));
+ if (! fs_mod)
+ {
+ grub_free (buf);
+ continue;
+ }
+
+ fs_mod->name = grub_strdup (p);
+ grub_free (buf);
+ if (! fs_mod->name)
+ {
+ grub_free (fs_mod);
+ continue;
+ }
+
+ fs_mod->next = fs_module_list;
+ fs_module_list = fs_mod;
+ }
+
+ grub_file_close (file);
+ grub_fs_autoload_hook = tmp_autoload_hook;
+ }
+
+ grub_free (filename);
+ }
+ }
+
+ /* Ignore errors. */
+ grub_errno = GRUB_ERR_NONE;
+
+ /* Set the hook. */
+ grub_fs_autoload_hook = autoload_fs_module;
+}
diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c
new file mode 100644
index 0000000..4dfcc31
--- /dev/null
+++ b/grub-core/normal/charset.c
@@ -0,0 +1,1312 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ Current problems with Unicode rendering:
+ - B and BN bidi type characters (ignored)
+ - Mc type characters with combining class 0 (poorly combined)
+ - Mn type characters with combining class 0 (poorly combined)
+ - Me type characters with combining class 0 (poorly combined)
+ - Cf type characters (ignored)
+ - Cc type characters (ignored)
+ - Line-breaking rules (e.g. Zs type characters)
+ - Indic languages
+ - non-Semitic shaping (rarely used)
+ - Zl and Zp characters
+ - Combining characters of types 7, 8, 9, 21, 35, 36, 84, 91, 103, 107,
+ 118, 122, 129, 130, 132, 218, 224, 226, 233, 234
+ - Private use characters (not really a problem)
+ - Variations (no font support)
+ - Vertical text
+ - Ligatures
+ Font information ignored:
+ - Kerning
+ - Justification data
+ - Glyph posititioning
+ - Baseline data
+ Most underline diacritics aren't displayed in gfxterm
+ */
+
+#include <grub/charset.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/unicode.h>
+#include <grub/term.h>
+#include <grub/normal.h>
+#include <grub/safemath.h>
+
+#if HAVE_FONT_SOURCE
+#include "widthspec.h"
+#endif
+
+/* Returns -2 if not enough space, -1 on invalid character. */
+grub_ssize_t
+grub_encode_utf8_character (grub_uint8_t *dest, grub_uint8_t *destend,
+ grub_uint32_t code)
+{
+ if (dest >= destend)
+ return -2;
+ if (code <= 0x007F)
+ {
+ *dest++ = code;
+ return 1;
+ }
+ if (code <= 0x07FF)
+ {
+ if (dest + 1 >= destend)
+ return -2;
+ *dest++ = (code >> 6) | 0xC0;
+ *dest++ = (code & 0x3F) | 0x80;
+ return 2;
+ }
+ if ((code >= 0xDC00 && code <= 0xDFFF)
+ || (code >= 0xD800 && code <= 0xDBFF))
+ {
+ /* No surrogates in UCS-4... */
+ return -1;
+ }
+ if (code < 0x10000)
+ {
+ if (dest + 2 >= destend)
+ return -2;
+ *dest++ = (code >> 12) | 0xE0;
+ *dest++ = ((code >> 6) & 0x3F) | 0x80;
+ *dest++ = (code & 0x3F) | 0x80;
+ return 3;
+ }
+ {
+ if (dest + 3 >= destend)
+ return -2;
+ *dest++ = (code >> 18) | 0xF0;
+ *dest++ = ((code >> 12) & 0x3F) | 0x80;
+ *dest++ = ((code >> 6) & 0x3F) | 0x80;
+ *dest++ = (code & 0x3F) | 0x80;
+ return 4;
+ }
+
+}
+
+/* Convert UCS-4 to UTF-8. */
+grub_size_t
+grub_ucs4_to_utf8 (const grub_uint32_t *src, grub_size_t size,
+ grub_uint8_t *dest, grub_size_t destsize)
+{
+ /* Keep last char for \0. */
+ grub_uint8_t *destend = dest + destsize - 1;
+ grub_uint8_t *dest0 = dest;
+
+ while (size-- && dest < destend)
+ {
+ grub_uint32_t code = *src++;
+ grub_ssize_t s;
+ s = grub_encode_utf8_character (dest, destend, code);
+ if (s == -2)
+ break;
+ if (s == -1)
+ {
+ *dest++ = '?';
+ continue;
+ }
+ dest += s;
+ }
+ *dest = 0;
+ return dest - dest0;
+}
+
+/* Returns the number of bytes the string src would occupy is converted
+ to UTF-8, excluding trailing \0. */
+grub_size_t
+grub_get_num_of_utf8_bytes (const grub_uint32_t *src, grub_size_t size)
+{
+ grub_size_t remaining;
+ const grub_uint32_t *ptr;
+ grub_size_t cnt = 0;
+
+ remaining = size;
+ ptr = src;
+ while (remaining--)
+ {
+ grub_uint32_t code = *ptr++;
+
+ if (code <= 0x007F)
+ cnt++;
+ else if (code <= 0x07FF)
+ cnt += 2;
+ else if ((code >= 0xDC00 && code <= 0xDFFF)
+ || (code >= 0xD800 && code <= 0xDBFF))
+ /* No surrogates in UCS-4... */
+ cnt++;
+ else if (code < 0x10000)
+ cnt += 3;
+ else
+ cnt += 4;
+ }
+ return cnt;
+}
+
+/* Convert UCS-4 to UTF-8. */
+char *
+grub_ucs4_to_utf8_alloc (const grub_uint32_t *src, grub_size_t size)
+{
+ grub_uint8_t *ret;
+ grub_size_t cnt = grub_get_num_of_utf8_bytes (src, size) + 1;
+
+ ret = grub_malloc (cnt);
+ if (!ret)
+ return 0;
+
+ grub_ucs4_to_utf8 (src, size, ret, cnt);
+
+ return (char *) ret;
+}
+
+int
+grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize)
+{
+ int count = 0;
+ grub_uint32_t code = 0;
+
+ while (srcsize)
+ {
+ if (srcsize != (grub_size_t)-1)
+ srcsize--;
+ if (!grub_utf8_process (*src++, &code, &count))
+ return 0;
+ if (count != 0)
+ continue;
+ if (code == 0)
+ return 1;
+ if (code > GRUB_UNICODE_LAST_VALID)
+ return 0;
+ }
+
+ return 1;
+}
+
+grub_ssize_t
+grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg,
+ grub_uint32_t **last_position)
+{
+ grub_size_t msg_len = grub_strlen (msg);
+
+ *unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t));
+
+ if (!*unicode_msg)
+ return -1;
+
+ msg_len = grub_utf8_to_ucs4 (*unicode_msg, msg_len,
+ (grub_uint8_t *) msg, -1, 0);
+
+ if (last_position)
+ *last_position = *unicode_msg + msg_len;
+
+ return msg_len;
+}
+
+/* Convert a (possibly null-terminated) UTF-8 string of at most SRCSIZE
+ bytes (if SRCSIZE is -1, it is ignored) in length to a UCS-4 string.
+ Return the number of characters converted. DEST must be able to hold
+ at least DESTSIZE characters.
+ If SRCEND is not NULL, then *SRCEND is set to the next byte after the
+ last byte used in SRC. */
+grub_size_t
+grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
+ const grub_uint8_t *src, grub_size_t srcsize,
+ const grub_uint8_t **srcend)
+{
+ grub_uint32_t *p = dest;
+ int count = 0;
+ grub_uint32_t code = 0;
+
+ if (srcend)
+ *srcend = src;
+
+ while (srcsize && destsize)
+ {
+ int was_count = count;
+ if (srcsize != (grub_size_t)-1)
+ srcsize--;
+ if (!grub_utf8_process (*src++, &code, &count))
+ {
+ code = '?';
+ count = 0;
+ /* Character c may be valid, don't eat it. */
+ if (was_count)
+ src--;
+ }
+ if (count != 0)
+ continue;
+ if (code == 0)
+ break;
+ *p++ = code;
+ destsize--;
+ }
+
+ if (srcend)
+ *srcend = src;
+ return p - dest;
+}
+
+static grub_uint8_t *join_types = NULL;
+
+static void
+unpack_join (void)
+{
+ unsigned i;
+ struct grub_unicode_compact_range *cur;
+
+ join_types = grub_zalloc (GRUB_UNICODE_MAX_CACHED_CHAR);
+ if (!join_types)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+ for (cur = grub_unicode_compact; cur->len; cur++)
+ for (i = cur->start; i < cur->start + (unsigned) cur->len
+ && i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
+ join_types[i] = cur->join_type;
+}
+
+static grub_uint8_t *bidi_types = NULL;
+
+static void
+unpack_bidi (void)
+{
+ unsigned i;
+ struct grub_unicode_compact_range *cur;
+
+ bidi_types = grub_zalloc (GRUB_UNICODE_MAX_CACHED_CHAR);
+ if (!bidi_types)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+ for (cur = grub_unicode_compact; cur->len; cur++)
+ for (i = cur->start; i < cur->start + (unsigned) cur->len
+ && i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
+ if (cur->bidi_mirror)
+ bidi_types[i] = cur->bidi_type | 0x80;
+ else
+ bidi_types[i] = cur->bidi_type | 0x00;
+}
+
+static inline enum grub_bidi_type
+get_bidi_type (grub_uint32_t c)
+{
+ struct grub_unicode_compact_range *cur;
+
+ if (!bidi_types)
+ unpack_bidi ();
+
+ if (bidi_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
+ return bidi_types[c] & 0x7f;
+
+ for (cur = grub_unicode_compact; cur->len; cur++)
+ if (cur->start <= c && c < cur->start + (unsigned) cur->len)
+ return cur->bidi_type;
+
+ return GRUB_BIDI_TYPE_L;
+}
+
+static inline enum grub_join_type
+get_join_type (grub_uint32_t c)
+{
+ struct grub_unicode_compact_range *cur;
+
+ if (!join_types)
+ unpack_join ();
+
+ if (join_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
+ return join_types[c];
+
+ for (cur = grub_unicode_compact; cur->len; cur++)
+ if (cur->start <= c && c < cur->start + (unsigned) cur->len)
+ return cur->join_type;
+
+ return GRUB_JOIN_TYPE_NONJOINING;
+}
+
+static inline int
+is_mirrored (grub_uint32_t c)
+{
+ struct grub_unicode_compact_range *cur;
+
+ if (!bidi_types)
+ unpack_bidi ();
+
+ if (bidi_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
+ return !!(bidi_types[c] & 0x80);
+
+ for (cur = grub_unicode_compact; cur->len; cur++)
+ if (cur->start <= c && c < cur->start + (unsigned) cur->len)
+ return cur->bidi_mirror;
+
+ return 0;
+}
+
+enum grub_comb_type
+grub_unicode_get_comb_type (grub_uint32_t c)
+{
+ static grub_uint8_t *comb_types = NULL;
+ struct grub_unicode_compact_range *cur;
+
+ if (!comb_types)
+ {
+ unsigned i;
+ comb_types = grub_zalloc (GRUB_UNICODE_MAX_CACHED_CHAR);
+ if (comb_types)
+ for (cur = grub_unicode_compact; cur->len; cur++)
+ for (i = cur->start; i < cur->start + (unsigned) cur->len
+ && i < GRUB_UNICODE_MAX_CACHED_CHAR; i++)
+ comb_types[i] = cur->comb_type;
+ else
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ if (comb_types && c < GRUB_UNICODE_MAX_CACHED_CHAR)
+ return comb_types[c];
+
+ for (cur = grub_unicode_compact; cur->len; cur++)
+ if (cur->start <= c && c < cur->start + (unsigned) cur->len)
+ return cur->comb_type;
+
+ return GRUB_UNICODE_COMB_NONE;
+}
+
+#if HAVE_FONT_SOURCE
+
+grub_size_t
+grub_unicode_estimate_width (const struct grub_unicode_glyph *c)
+{
+ if (grub_unicode_get_comb_type (c->base))
+ return 0;
+ if (widthspec[c->base >> 3] & (1 << (c->base & 7)))
+ return 2;
+ else
+ return 1;
+}
+
+#endif
+
+static inline int
+is_type_after (enum grub_comb_type a, enum grub_comb_type b)
+{
+ /* Shadda is numerically higher than most of Arabic diacritics but has
+ to be rendered before them. */
+ if (a == GRUB_UNICODE_COMB_ARABIC_SHADDA
+ && b <= GRUB_UNICODE_COMB_ARABIC_KASRA
+ && b >= GRUB_UNICODE_COMB_ARABIC_FATHATAN)
+ return 0;
+ if (b == GRUB_UNICODE_COMB_ARABIC_SHADDA
+ && a <= GRUB_UNICODE_COMB_ARABIC_KASRA
+ && a >= GRUB_UNICODE_COMB_ARABIC_FATHATAN)
+ return 1;
+ return a > b;
+}
+
+grub_size_t
+grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
+ struct grub_unicode_glyph *out)
+{
+ int haveout = 0;
+ const grub_uint32_t *ptr;
+ unsigned last_comb_pointer = 0;
+
+ grub_memset (out, 0, sizeof (*out));
+
+ if (inlen && grub_iscntrl (*in))
+ {
+ out->base = *in;
+ out->variant = 0;
+ out->attributes = 0;
+ out->ncomb = 0;
+ out->estimated_width = 1;
+ return 1;
+ }
+
+ for (ptr = in; ptr < in + inlen; ptr++)
+ {
+ /* Variation selectors >= 17 are outside of BMP and SMP.
+ Handle variation selectors first to avoid potentially costly lookups.
+ */
+ if (*ptr >= GRUB_UNICODE_VARIATION_SELECTOR_1
+ && *ptr <= GRUB_UNICODE_VARIATION_SELECTOR_16)
+ {
+ if (haveout)
+ out->variant = *ptr - GRUB_UNICODE_VARIATION_SELECTOR_1 + 1;
+ continue;
+ }
+ if (*ptr >= GRUB_UNICODE_VARIATION_SELECTOR_17
+ && *ptr <= GRUB_UNICODE_VARIATION_SELECTOR_256)
+ {
+ if (haveout)
+ out->variant = *ptr - GRUB_UNICODE_VARIATION_SELECTOR_17 + 17;
+ continue;
+ }
+
+ enum grub_comb_type comb_type;
+ comb_type = grub_unicode_get_comb_type (*ptr);
+ if (comb_type)
+ {
+ struct grub_unicode_combining *n;
+ unsigned j;
+ grub_size_t sz;
+
+ if (!haveout)
+ continue;
+
+ if (comb_type == GRUB_UNICODE_COMB_MC
+ || comb_type == GRUB_UNICODE_COMB_ME
+ || comb_type == GRUB_UNICODE_COMB_MN)
+ last_comb_pointer = out->ncomb;
+
+ if (out->ncomb + 1 <= (int) ARRAY_SIZE (out->combining_inline))
+ n = out->combining_inline;
+ else if (out->ncomb > (int) ARRAY_SIZE (out->combining_inline))
+ {
+ if (grub_add (out->ncomb, 1, &sz) ||
+ grub_mul (sz, sizeof (n[0]), &sz))
+ goto fail;
+
+ n = grub_realloc (out->combining_ptr, sz);
+ if (!n)
+ {
+ fail:
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ out->combining_ptr = n;
+ }
+ else
+ {
+ n = grub_calloc (out->ncomb + 1, sizeof (n[0]));
+ if (!n)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+ grub_memcpy (n, out->combining_inline,
+ sizeof (out->combining_inline));
+ out->combining_ptr = n;
+ }
+
+ for (j = last_comb_pointer; j < out->ncomb; j++)
+ if (is_type_after (n[j].type, comb_type))
+ break;
+ grub_memmove (n + j + 1,
+ n + j,
+ (out->ncomb - j)
+ * sizeof (n[0]));
+ n[j].code = *ptr;
+ n[j].type = comb_type;
+ out->ncomb++;
+ continue;
+ }
+ if (haveout)
+ return ptr - in;
+ haveout = 1;
+ out->base = *ptr;
+ out->variant = 0;
+ out->attributes = 0;
+ out->ncomb = 0;
+ out->estimated_width = 1;
+ }
+ return ptr - in;
+}
+
+static void
+revert (struct grub_unicode_glyph *visual,
+ struct grub_term_pos *pos,
+ unsigned start, unsigned end)
+{
+ struct grub_unicode_glyph t;
+ unsigned i;
+ int a = 0, b = 0;
+ if (pos)
+ {
+ a = pos[visual[start].orig_pos].x;
+ b = pos[visual[end].orig_pos].x;
+ }
+ for (i = 0; i < (end - start) / 2 + 1; i++)
+ {
+ t = visual[start + i];
+ visual[start + i] = visual[end - i];
+ visual[end - i] = t;
+
+ if (pos)
+ {
+ pos[visual[start + i].orig_pos].x = a + b - pos[visual[start + i].orig_pos].x;
+ pos[visual[end - i].orig_pos].x = a + b - pos[visual[end - i].orig_pos].x;
+ }
+ }
+}
+
+
+static grub_ssize_t
+bidi_line_wrap (struct grub_unicode_glyph *visual_out,
+ struct grub_unicode_glyph *visual,
+ grub_size_t visual_len,
+ grub_size_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
+ void *getcharwidth_arg,
+ grub_size_t maxwidth, grub_size_t startwidth,
+ grub_uint32_t contchar,
+ struct grub_term_pos *pos, int primitive_wrap,
+ grub_size_t log_end)
+{
+ struct grub_unicode_glyph *outptr = visual_out;
+ unsigned line_start = 0;
+ grub_ssize_t line_width;
+ unsigned k;
+ grub_ssize_t last_space = -1;
+ grub_ssize_t last_space_width = 0;
+ int lines = 0;
+
+ if (!visual_len)
+ return 0;
+
+ if (startwidth >= maxwidth && (grub_ssize_t) maxwidth > 0)
+ {
+ if (contchar)
+ {
+ grub_memset (outptr, 0, sizeof (visual[0]));
+ outptr->base = contchar;
+ outptr++;
+ }
+ grub_memset (outptr, 0, sizeof (visual[0]));
+ outptr->base = '\n';
+ outptr++;
+ startwidth = 0;
+ }
+
+ line_width = startwidth;
+
+ for (k = 0; k <= visual_len; k++)
+ {
+ grub_ssize_t last_width = 0;
+
+ if (pos && k != visual_len)
+ {
+ pos[visual[k].orig_pos].x = line_width;
+ pos[visual[k].orig_pos].y = lines;
+ pos[visual[k].orig_pos].valid = 1;
+ }
+
+ if (k == visual_len && pos)
+ {
+ pos[log_end].x = line_width;
+ pos[log_end].y = lines;
+ pos[log_end].valid = 1;
+ }
+
+ if (getcharwidth && k != visual_len)
+ line_width += last_width = getcharwidth (&visual[k], getcharwidth_arg);
+
+ if (k != visual_len && (visual[k].base == ' '
+ || visual[k].base == '\t')
+ && !primitive_wrap)
+ {
+ last_space = k;
+ last_space_width = line_width;
+ }
+
+ if (((grub_ssize_t) maxwidth > 0
+ && line_width > (grub_ssize_t) maxwidth) || k == visual_len)
+ {
+ unsigned min_odd_level = 0xffffffff;
+ unsigned max_level = 0;
+ unsigned kk = k;
+
+ lines++;
+
+ if (k != visual_len && last_space > (signed) line_start)
+ {
+ kk = last_space;
+ line_width -= last_space_width;
+ }
+ else if (k != visual_len && line_start == 0 && startwidth != 0
+ && !primitive_wrap && lines == 1
+ && line_width - startwidth < maxwidth)
+ {
+ kk = 0;
+ line_width -= startwidth;
+ }
+ else
+ line_width = last_width;
+
+ {
+ unsigned i;
+ for (i = line_start; i < kk; i++)
+ {
+ if (visual[i].bidi_level > max_level)
+ max_level = visual[i].bidi_level;
+ if (visual[i].bidi_level < min_odd_level && (visual[i].bidi_level & 1))
+ min_odd_level = visual[i].bidi_level;
+ }
+ }
+
+ {
+ unsigned j;
+ /* FIXME: can be optimized. */
+ for (j = max_level; j > min_odd_level - 1; j--)
+ {
+ unsigned in = line_start;
+ unsigned i;
+ for (i = line_start; i < kk; i++)
+ {
+ if (i != line_start && visual[i].bidi_level >= j
+ && visual[i-1].bidi_level < j)
+ in = i;
+ if (visual[i].bidi_level >= j && (i + 1 == kk
+ || visual[i+1].bidi_level < j))
+ revert (visual, pos, in, i);
+ }
+ }
+ }
+
+ {
+ unsigned i;
+ for (i = line_start; i < kk; i++)
+ {
+ if (is_mirrored (visual[i].base) && visual[i].bidi_level)
+ visual[i].attributes |= GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR;
+ if ((visual[i].attributes & GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN)
+ && visual[i].bidi_level)
+ {
+ int left, right;
+ left = visual[i].attributes
+ & (GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED
+ | GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT);
+ right = visual[i].attributes
+ & (GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED
+ | GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT);
+ visual[i].attributes &= ~GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN;
+ left <<= GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT;
+ right >>= GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT;
+ visual[i].attributes |= (left | right);
+ }
+ }
+ }
+
+ {
+ int left_join = 0;
+ unsigned i;
+ for (i = line_start; i < kk; i++)
+ {
+ enum grub_join_type join_type = get_join_type (visual[i].base);
+ if (!(visual[i].attributes
+ & GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT)
+ && (join_type == GRUB_JOIN_TYPE_LEFT
+ || join_type == GRUB_JOIN_TYPE_DUAL))
+ {
+ if (left_join)
+ visual[i].attributes
+ |= GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED;
+ else
+ visual[i].attributes
+ &= ~GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED;
+ }
+ if (join_type == GRUB_JOIN_TYPE_NONJOINING
+ || join_type == GRUB_JOIN_TYPE_LEFT)
+ left_join = 0;
+ if (join_type == GRUB_JOIN_TYPE_RIGHT
+ || join_type == GRUB_JOIN_TYPE_DUAL
+ || join_type == GRUB_JOIN_TYPE_CAUSING)
+ left_join = 1;
+ }
+ }
+
+ {
+ int right_join = 0;
+ signed i;
+ for (i = kk - 1; i >= 0 && (unsigned) i + 1 > line_start;
+ i--)
+ {
+ enum grub_join_type join_type = get_join_type (visual[i].base);
+ if (!(visual[i].attributes
+ & GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT)
+ && (join_type == GRUB_JOIN_TYPE_RIGHT
+ || join_type == GRUB_JOIN_TYPE_DUAL))
+ {
+ if (right_join)
+ visual[i].attributes
+ |= GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED;
+ else
+ visual[i].attributes
+ &= ~GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED;
+ }
+ if (join_type == GRUB_JOIN_TYPE_NONJOINING
+ || join_type == GRUB_JOIN_TYPE_RIGHT)
+ right_join = 0;
+ if (join_type == GRUB_JOIN_TYPE_LEFT
+ || join_type == GRUB_JOIN_TYPE_DUAL
+ || join_type == GRUB_JOIN_TYPE_CAUSING)
+ right_join = 1;
+ }
+ }
+
+ grub_memcpy (outptr, &visual[line_start],
+ (kk - line_start) * sizeof (visual[0]));
+ outptr += kk - line_start;
+ if (kk != visual_len)
+ {
+ if (contchar)
+ {
+ grub_memset (outptr, 0, sizeof (visual[0]));
+ outptr->base = contchar;
+ outptr++;
+ }
+ grub_memset (outptr, 0, sizeof (visual[0]));
+ outptr->base = '\n';
+ outptr++;
+ }
+
+ if ((signed) kk == last_space)
+ kk++;
+
+ line_start = kk;
+ if (pos && kk != visual_len)
+ {
+ pos[visual[kk].orig_pos].x = 0;
+ pos[visual[kk].orig_pos].y = lines;
+ }
+ }
+ }
+
+ return outptr - visual_out;
+}
+
+
+static grub_ssize_t
+grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
+ grub_size_t logical_len,
+ struct grub_unicode_glyph *visual_out,
+ grub_size_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
+ void *getcharwidth_arg,
+ grub_size_t maxwidth, grub_size_t startwidth,
+ grub_uint32_t contchar,
+ struct grub_term_pos *pos,
+ int primitive_wrap,
+ grub_size_t log_end)
+{
+ enum grub_bidi_type type = GRUB_BIDI_TYPE_L;
+ enum override_status {OVERRIDE_NEUTRAL = 0, OVERRIDE_R, OVERRIDE_L};
+ unsigned base_level;
+ enum override_status cur_override;
+ unsigned i;
+ unsigned stack_level[GRUB_BIDI_MAX_EXPLICIT_LEVEL + 3];
+ enum override_status stack_override[GRUB_BIDI_MAX_EXPLICIT_LEVEL + 3];
+ unsigned stack_depth = 0;
+ unsigned invalid_pushes = 0;
+ unsigned visual_len = 0;
+ unsigned run_start, run_end;
+ struct grub_unicode_glyph *visual;
+ unsigned cur_level;
+ int bidi_needed = 0;
+
+#define push_stack(new_override, new_level) \
+ { \
+ if (new_level > GRUB_BIDI_MAX_EXPLICIT_LEVEL) \
+ { \
+ invalid_pushes++; \
+ } \
+ else \
+ { \
+ stack_level[stack_depth] = cur_level; \
+ stack_override[stack_depth] = cur_override; \
+ stack_depth++; \
+ cur_level = new_level; \
+ cur_override = new_override; \
+ } \
+ }
+
+#define pop_stack() \
+ { \
+ if (invalid_pushes) \
+ { \
+ invalid_pushes--; \
+ } \
+ else if (stack_depth) \
+ { \
+ stack_depth--; \
+ cur_level = stack_level[stack_depth]; \
+ cur_override = stack_override[stack_depth]; \
+ } \
+ }
+
+ visual = grub_calloc (logical_len, sizeof (visual[0]));
+ if (!visual)
+ return -1;
+
+ for (i = 0; i < logical_len; i++)
+ {
+ type = get_bidi_type (logical[i]);
+ if (type == GRUB_BIDI_TYPE_L || type == GRUB_BIDI_TYPE_AL
+ || type == GRUB_BIDI_TYPE_R)
+ break;
+ }
+ if (type == GRUB_BIDI_TYPE_R || type == GRUB_BIDI_TYPE_AL)
+ base_level = 1;
+ else
+ base_level = 0;
+
+ cur_level = base_level;
+ cur_override = OVERRIDE_NEUTRAL;
+ {
+ const grub_uint32_t *lptr;
+ enum {JOIN_DEFAULT, NOJOIN, JOIN_FORCE} join_state = JOIN_DEFAULT;
+ int zwj_propagate_to_previous = 0;
+ for (lptr = logical; lptr < logical + logical_len;)
+ {
+ grub_size_t p;
+
+ if (*lptr == GRUB_UNICODE_ZWJ)
+ {
+ if (zwj_propagate_to_previous)
+ {
+ visual[visual_len - 1].attributes
+ |= GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT
+ | GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED;
+ }
+ zwj_propagate_to_previous = 0;
+ join_state = JOIN_FORCE;
+ lptr++;
+ continue;
+ }
+
+ if (*lptr == GRUB_UNICODE_ZWNJ)
+ {
+ if (zwj_propagate_to_previous)
+ {
+ visual[visual_len - 1].attributes
+ |= GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT;
+ visual[visual_len - 1].attributes
+ &= ~GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED;
+ }
+ zwj_propagate_to_previous = 0;
+ join_state = NOJOIN;
+ lptr++;
+ continue;
+ }
+
+ /* The tags: deprecated, never used. */
+ if (*lptr >= GRUB_UNICODE_TAG_START && *lptr <= GRUB_UNICODE_TAG_END)
+ continue;
+
+ p = grub_unicode_aglomerate_comb (lptr, logical + logical_len - lptr,
+ &visual[visual_len]);
+ visual[visual_len].orig_pos = lptr - logical;
+ type = get_bidi_type (visual[visual_len].base);
+ switch (type)
+ {
+ case GRUB_BIDI_TYPE_RLE:
+ bidi_needed = 1;
+ push_stack (cur_override, (cur_level | 1) + 1);
+ break;
+ case GRUB_BIDI_TYPE_RLO:
+ bidi_needed = 1;
+ push_stack (OVERRIDE_R, (cur_level | 1) + 1);
+ break;
+ case GRUB_BIDI_TYPE_LRE:
+ push_stack (cur_override, (cur_level & ~1) + 2);
+ break;
+ case GRUB_BIDI_TYPE_LRO:
+ push_stack (OVERRIDE_L, (cur_level & ~1) + 2);
+ break;
+ case GRUB_BIDI_TYPE_PDF:
+ pop_stack ();
+ break;
+ case GRUB_BIDI_TYPE_BN:
+ break;
+ case GRUB_BIDI_TYPE_R:
+ case GRUB_BIDI_TYPE_AL:
+ bidi_needed = 1;
+ /* Fallthrough. */
+ default:
+ {
+ if (join_state == JOIN_FORCE)
+ {
+ visual[visual_len].attributes
+ |= GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT
+ | GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED;
+ }
+
+ if (join_state == NOJOIN)
+ {
+ visual[visual_len].attributes
+ |= GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT;
+ visual[visual_len].attributes
+ &= ~GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED;
+ }
+
+ join_state = JOIN_DEFAULT;
+ zwj_propagate_to_previous = 1;
+
+ visual[visual_len].bidi_level = cur_level;
+ if (cur_override != OVERRIDE_NEUTRAL)
+ visual[visual_len].bidi_type =
+ (cur_override == OVERRIDE_L) ? GRUB_BIDI_TYPE_L
+ : GRUB_BIDI_TYPE_R;
+ else
+ visual[visual_len].bidi_type = type;
+ visual_len++;
+ }
+ }
+ lptr += p;
+ }
+ }
+
+ if (bidi_needed)
+ {
+ for (run_start = 0; run_start < visual_len; run_start = run_end)
+ {
+ unsigned prev_level, next_level, cur_run_level;
+ unsigned last_type, last_strong_type;
+ for (run_end = run_start; run_end < visual_len &&
+ visual[run_end].bidi_level == visual[run_start].bidi_level; run_end++);
+ if (run_start == 0)
+ prev_level = base_level;
+ else
+ prev_level = visual[run_start - 1].bidi_level;
+ if (run_end == visual_len)
+ next_level = base_level;
+ else
+ next_level = visual[run_end].bidi_level;
+ cur_run_level = visual[run_start].bidi_level;
+ if (prev_level & 1)
+ last_type = GRUB_BIDI_TYPE_R;
+ else
+ last_type = GRUB_BIDI_TYPE_L;
+ last_strong_type = last_type;
+ for (i = run_start; i < run_end; i++)
+ {
+ switch (visual[i].bidi_type)
+ {
+ case GRUB_BIDI_TYPE_NSM:
+ visual[i].bidi_type = last_type;
+ break;
+ case GRUB_BIDI_TYPE_EN:
+ if (last_strong_type == GRUB_BIDI_TYPE_AL)
+ visual[i].bidi_type = GRUB_BIDI_TYPE_AN;
+ break;
+ case GRUB_BIDI_TYPE_L:
+ case GRUB_BIDI_TYPE_R:
+ last_strong_type = visual[i].bidi_type;
+ break;
+ case GRUB_BIDI_TYPE_ES:
+ if (last_type == GRUB_BIDI_TYPE_EN
+ && i + 1 < run_end
+ && visual[i + 1].bidi_type == GRUB_BIDI_TYPE_EN)
+ visual[i].bidi_type = GRUB_BIDI_TYPE_EN;
+ else
+ visual[i].bidi_type = GRUB_BIDI_TYPE_ON;
+ break;
+ case GRUB_BIDI_TYPE_ET:
+ {
+ unsigned j;
+ if (last_type == GRUB_BIDI_TYPE_EN)
+ {
+ visual[i].bidi_type = GRUB_BIDI_TYPE_EN;
+ break;
+ }
+ for (j = i; j < run_end
+ && visual[j].bidi_type == GRUB_BIDI_TYPE_ET; j++);
+ if (j != run_end && visual[j].bidi_type == GRUB_BIDI_TYPE_EN)
+ {
+ for (; i < run_end
+ && visual[i].bidi_type == GRUB_BIDI_TYPE_ET; i++)
+ visual[i].bidi_type = GRUB_BIDI_TYPE_EN;
+ i--;
+ break;
+ }
+ for (; i < run_end
+ && visual[i].bidi_type == GRUB_BIDI_TYPE_ET; i++)
+ visual[i].bidi_type = GRUB_BIDI_TYPE_ON;
+ i--;
+ break;
+ }
+ break;
+ case GRUB_BIDI_TYPE_CS:
+ if (last_type == GRUB_BIDI_TYPE_EN
+ && i + 1 < run_end
+ && visual[i + 1].bidi_type == GRUB_BIDI_TYPE_EN)
+ {
+ visual[i].bidi_type = GRUB_BIDI_TYPE_EN;
+ break;
+ }
+ if (last_type == GRUB_BIDI_TYPE_AN
+ && i + 1 < run_end
+ && (visual[i + 1].bidi_type == GRUB_BIDI_TYPE_AN
+ || (visual[i + 1].bidi_type == GRUB_BIDI_TYPE_EN
+ && last_strong_type == GRUB_BIDI_TYPE_AL)))
+ {
+ visual[i].bidi_type = GRUB_BIDI_TYPE_EN;
+ break;
+ }
+ visual[i].bidi_type = GRUB_BIDI_TYPE_ON;
+ break;
+ case GRUB_BIDI_TYPE_AL:
+ last_strong_type = visual[i].bidi_type;
+ visual[i].bidi_type = GRUB_BIDI_TYPE_R;
+ break;
+ default: /* Make GCC happy. */
+ break;
+ }
+ last_type = visual[i].bidi_type;
+ if (visual[i].bidi_type == GRUB_BIDI_TYPE_EN
+ && last_strong_type == GRUB_BIDI_TYPE_L)
+ visual[i].bidi_type = GRUB_BIDI_TYPE_L;
+ }
+ if (prev_level & 1)
+ last_type = GRUB_BIDI_TYPE_R;
+ else
+ last_type = GRUB_BIDI_TYPE_L;
+ for (i = run_start; i < run_end; )
+ {
+ unsigned j;
+ unsigned next_type;
+ for (j = i; j < run_end &&
+ (visual[j].bidi_type == GRUB_BIDI_TYPE_B
+ || visual[j].bidi_type == GRUB_BIDI_TYPE_S
+ || visual[j].bidi_type == GRUB_BIDI_TYPE_WS
+ || visual[j].bidi_type == GRUB_BIDI_TYPE_ON); j++);
+ if (j == i)
+ {
+ if (visual[i].bidi_type == GRUB_BIDI_TYPE_L)
+ last_type = GRUB_BIDI_TYPE_L;
+ else
+ last_type = GRUB_BIDI_TYPE_R;
+ i++;
+ continue;
+ }
+ if (j == run_end)
+ next_type = (next_level & 1) ? GRUB_BIDI_TYPE_R : GRUB_BIDI_TYPE_L;
+ else
+ {
+ if (visual[j].bidi_type == GRUB_BIDI_TYPE_L)
+ next_type = GRUB_BIDI_TYPE_L;
+ else
+ next_type = GRUB_BIDI_TYPE_R;
+ }
+ if (next_type == last_type)
+ for (; i < j; i++)
+ visual[i].bidi_type = last_type;
+ else
+ for (; i < j; i++)
+ visual[i].bidi_type = (cur_run_level & 1) ? GRUB_BIDI_TYPE_R
+ : GRUB_BIDI_TYPE_L;
+ }
+ }
+
+ for (i = 0; i < visual_len; i++)
+ {
+ if (!(visual[i].bidi_level & 1) && visual[i].bidi_type == GRUB_BIDI_TYPE_R)
+ {
+ visual[i].bidi_level++;
+ continue;
+ }
+ if (!(visual[i].bidi_level & 1) && (visual[i].bidi_type == GRUB_BIDI_TYPE_AN
+ || visual[i].bidi_type == GRUB_BIDI_TYPE_EN))
+ {
+ visual[i].bidi_level += 2;
+ continue;
+ }
+ if ((visual[i].bidi_level & 1) && (visual[i].bidi_type == GRUB_BIDI_TYPE_L
+ || visual[i].bidi_type == GRUB_BIDI_TYPE_AN
+ || visual[i].bidi_type == GRUB_BIDI_TYPE_EN))
+ {
+ visual[i].bidi_level++;
+ continue;
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < visual_len; i++)
+ visual[i].bidi_level = 0;
+ }
+
+ {
+ grub_ssize_t ret;
+ ret = bidi_line_wrap (visual_out, visual, visual_len,
+ getcharwidth, getcharwidth_arg, maxwidth, startwidth, contchar,
+ pos, primitive_wrap, log_end);
+ grub_free (visual);
+ return ret;
+ }
+}
+
+static int
+is_visible (const struct grub_unicode_glyph *gl)
+{
+ if (gl->ncomb)
+ return 1;
+ if (gl->base == GRUB_UNICODE_LRM || gl->base == GRUB_UNICODE_RLM)
+ return 0;
+ return 1;
+}
+
+grub_ssize_t
+grub_bidi_logical_to_visual (const grub_uint32_t *logical,
+ grub_size_t logical_len,
+ struct grub_unicode_glyph **visual_out,
+ grub_size_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
+ void *getcharwidth_arg,
+ grub_size_t max_length, grub_size_t startwidth,
+ grub_uint32_t contchar, struct grub_term_pos *pos, int primitive_wrap)
+{
+ const grub_uint32_t *line_start = logical, *ptr;
+ struct grub_unicode_glyph *visual_ptr;
+ *visual_out = visual_ptr = grub_calloc (logical_len + 2,
+ 3 * sizeof (visual_ptr[0]));
+ if (!visual_ptr)
+ return -1;
+ for (ptr = logical; ptr <= logical + logical_len; ptr++)
+ {
+ if (ptr == logical + logical_len || *ptr == '\n')
+ {
+ grub_ssize_t ret;
+ grub_ssize_t i, j;
+ ret = grub_bidi_line_logical_to_visual (line_start,
+ ptr - line_start,
+ visual_ptr,
+ getcharwidth,
+ getcharwidth_arg,
+ max_length,
+ startwidth,
+ contchar,
+ pos,
+ primitive_wrap,
+ logical_len);
+ startwidth = 0;
+
+ if (ret < 0)
+ {
+ grub_free (*visual_out);
+ return ret;
+ }
+ for (i = 0, j = 0; i < ret; i++)
+ if (is_visible(&visual_ptr[i]))
+ visual_ptr[j++] = visual_ptr[i];
+ visual_ptr += j;
+ line_start = ptr;
+ if (ptr != logical + logical_len)
+ {
+ grub_memset (visual_ptr, 0, sizeof (visual_ptr[0]));
+ visual_ptr->base = '\n';
+ visual_ptr++;
+ line_start++;
+ }
+ }
+ }
+ return visual_ptr - *visual_out;
+}
+
+grub_uint32_t
+grub_unicode_mirror_code (grub_uint32_t in)
+{
+ int i;
+ for (i = 0; grub_unicode_bidi_pairs[i].key; i++)
+ if (grub_unicode_bidi_pairs[i].key == in)
+ return grub_unicode_bidi_pairs[i].replace;
+ return in;
+}
+
+grub_uint32_t
+grub_unicode_shape_code (grub_uint32_t in, grub_uint8_t attr)
+{
+ int i;
+ if (!(in >= GRUB_UNICODE_ARABIC_START
+ && in < GRUB_UNICODE_ARABIC_END))
+ return in;
+
+ for (i = 0; grub_unicode_arabic_shapes[i].code; i++)
+ if (grub_unicode_arabic_shapes[i].code == in)
+ {
+ grub_uint32_t out = 0;
+ switch (attr & (GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED
+ | GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED))
+ {
+ case 0:
+ out = grub_unicode_arabic_shapes[i].isolated;
+ break;
+ case GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED:
+ out = grub_unicode_arabic_shapes[i].right_linked;
+ break;
+ case GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED:
+ out = grub_unicode_arabic_shapes[i].left_linked;
+ break;
+ case GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED
+ |GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED:
+ out = grub_unicode_arabic_shapes[i].both_linked;
+ break;
+ }
+ if (out)
+ return out;
+ }
+
+ return in;
+}
+
+const grub_uint32_t *
+grub_unicode_get_comb_start (const grub_uint32_t *str,
+ const grub_uint32_t *cur)
+{
+ const grub_uint32_t *ptr;
+ for (ptr = cur; ptr >= str; ptr--)
+ {
+ if (*ptr >= GRUB_UNICODE_VARIATION_SELECTOR_1
+ && *ptr <= GRUB_UNICODE_VARIATION_SELECTOR_16)
+ continue;
+
+ if (*ptr >= GRUB_UNICODE_VARIATION_SELECTOR_17
+ && *ptr <= GRUB_UNICODE_VARIATION_SELECTOR_256)
+ continue;
+
+ enum grub_comb_type comb_type;
+ comb_type = grub_unicode_get_comb_type (*ptr);
+ if (comb_type)
+ continue;
+ return ptr;
+ }
+ return str;
+}
+
+const grub_uint32_t *
+grub_unicode_get_comb_end (const grub_uint32_t *end,
+ const grub_uint32_t *cur)
+{
+ const grub_uint32_t *ptr;
+ for (ptr = cur; ptr < end; ptr++)
+ {
+ if (*ptr >= GRUB_UNICODE_VARIATION_SELECTOR_1
+ && *ptr <= GRUB_UNICODE_VARIATION_SELECTOR_16)
+ continue;
+
+ if (*ptr >= GRUB_UNICODE_VARIATION_SELECTOR_17
+ && *ptr <= GRUB_UNICODE_VARIATION_SELECTOR_256)
+ continue;
+
+ enum grub_comb_type comb_type;
+ comb_type = grub_unicode_get_comb_type (*ptr);
+ if (comb_type)
+ continue;
+ return ptr;
+ }
+ return end;
+}
+
diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c
new file mode 100644
index 0000000..de03fe6
--- /dev/null
+++ b/grub-core/normal/cmdline.c
@@ -0,0 +1,691 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/partition.h>
+#include <grub/disk.h>
+#include <grub/file.h>
+#include <grub/env.h>
+#include <grub/i18n.h>
+#include <grub/charset.h>
+#include <grub/safemath.h>
+
+static grub_uint32_t *kill_buf;
+
+static int hist_size;
+static grub_uint32_t **hist_lines = 0;
+static int hist_pos = 0;
+static int hist_end = 0;
+static int hist_used = 0;
+
+grub_err_t
+grub_set_history (int newsize)
+{
+ grub_uint32_t **old_hist_lines = hist_lines;
+ hist_lines = grub_calloc (newsize, sizeof (grub_uint32_t *));
+
+ /* Copy the old lines into the new buffer. */
+ if (old_hist_lines)
+ {
+ /* Remove the lines that don't fit in the new buffer. */
+ if (newsize < hist_used)
+ {
+ grub_size_t i;
+ grub_size_t delsize = hist_used - newsize;
+ hist_used = newsize;
+
+ for (i = 1; i < delsize + 1; i++)
+ {
+ grub_ssize_t pos = hist_end - i;
+ if (pos < 0)
+ pos += hist_size;
+ grub_free (old_hist_lines[pos]);
+ }
+
+ hist_end -= delsize;
+ if (hist_end < 0)
+ hist_end += hist_size;
+ }
+
+ if (hist_pos < hist_end)
+ grub_memmove (hist_lines, old_hist_lines + hist_pos,
+ (hist_end - hist_pos) * sizeof (grub_uint32_t *));
+ else if (hist_used)
+ {
+ /* Copy the older part. */
+ grub_memmove (hist_lines, old_hist_lines + hist_pos,
+ (hist_size - hist_pos) * sizeof (grub_uint32_t *));
+
+ /* Copy the newer part. */
+ grub_memmove (hist_lines + hist_size - hist_pos, old_hist_lines,
+ hist_end * sizeof (grub_uint32_t *));
+ }
+ }
+
+ grub_free (old_hist_lines);
+
+ hist_size = newsize;
+ hist_pos = 0;
+ hist_end = hist_used;
+ return 0;
+}
+
+/* Get the entry POS from the history where `0' is the newest
+ entry. */
+static grub_uint32_t *
+grub_history_get (unsigned pos)
+{
+ pos = (hist_pos + pos) % hist_size;
+ return hist_lines[pos];
+}
+
+static grub_size_t
+strlen_ucs4 (const grub_uint32_t *s)
+{
+ const grub_uint32_t *p = s;
+
+ while (*p)
+ p++;
+
+ return p - s;
+}
+
+/* Replace the history entry on position POS with the string S. */
+static void
+grub_history_set (int pos, grub_uint32_t *s, grub_size_t len)
+{
+ grub_free (hist_lines[pos]);
+ hist_lines[pos] = grub_calloc (len + 1, sizeof (grub_uint32_t));
+ if (!hist_lines[pos])
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ return ;
+ }
+ grub_memcpy (hist_lines[pos], s, len * sizeof (grub_uint32_t));
+ hist_lines[pos][len] = 0;
+}
+
+/* Insert a new history line S on the top of the history. */
+static void
+grub_history_add (grub_uint32_t *s, grub_size_t len)
+{
+ /* Remove the oldest entry in the history to make room for a new
+ entry. */
+ if (hist_used + 1 > hist_size)
+ {
+ hist_end--;
+ if (hist_end < 0)
+ hist_end = hist_size + hist_end;
+
+ grub_free (hist_lines[hist_end]);
+ }
+ else
+ hist_used++;
+
+ /* Move to the next position. */
+ hist_pos--;
+ if (hist_pos < 0)
+ hist_pos = hist_size + hist_pos;
+
+ /* Insert into history. */
+ hist_lines[hist_pos] = NULL;
+ grub_history_set (hist_pos, s, len);
+}
+
+/* Replace the history entry on position POS with the string S. */
+static void
+grub_history_replace (unsigned pos, grub_uint32_t *s, grub_size_t len)
+{
+ grub_history_set ((hist_pos + pos) % hist_size, s, len);
+}
+
+/* A completion hook to print items. */
+static void
+print_completion (const char *item, grub_completion_type_t type, int count)
+{
+ if (count == 0)
+ {
+ /* If this is the first time, print a label. */
+
+ grub_puts ("");
+ switch (type)
+ {
+ case GRUB_COMPLETION_TYPE_COMMAND:
+ grub_puts_ (N_("Possible commands are:"));
+ break;
+ case GRUB_COMPLETION_TYPE_DEVICE:
+ grub_puts_ (N_("Possible devices are:"));
+ break;
+ case GRUB_COMPLETION_TYPE_FILE:
+ grub_puts_ (N_("Possible files are:"));
+ break;
+ case GRUB_COMPLETION_TYPE_PARTITION:
+ grub_puts_ (N_("Possible partitions are:"));
+ break;
+ case GRUB_COMPLETION_TYPE_ARGUMENT:
+ grub_puts_ (N_("Possible arguments are:"));
+ break;
+ default:
+ /* TRANSLATORS: this message is used if none of above matches.
+ This shouldn't happen but please use the general term for
+ "thing" or "object". */
+ grub_puts_ (N_("Possible things are:"));
+ break;
+ }
+ grub_puts ("");
+ }
+
+ if (type == GRUB_COMPLETION_TYPE_PARTITION)
+ {
+ grub_normal_print_device_info (item);
+ grub_errno = GRUB_ERR_NONE;
+ }
+ else
+ grub_printf (" %s", item);
+}
+
+struct cmdline_term
+{
+ struct grub_term_coordinate pos;
+ unsigned ystart, width, height;
+ unsigned prompt_len;
+ struct grub_term_output *term;
+};
+
+static inline void
+cl_set_pos (struct cmdline_term *cl_term, grub_size_t lpos)
+{
+ cl_term->pos.x = (cl_term->prompt_len + lpos) % cl_term->width;
+ cl_term->pos.y = cl_term->ystart
+ + (cl_term->prompt_len + lpos) / cl_term->width;
+ grub_term_gotoxy (cl_term->term, cl_term->pos);
+}
+
+static void
+cl_set_pos_all (struct cmdline_term *cl_terms, unsigned nterms,
+ grub_size_t lpos)
+{
+ unsigned i;
+ for (i = 0; i < nterms; i++)
+ cl_set_pos (&cl_terms[i], lpos);
+}
+
+static inline void __attribute__ ((always_inline))
+cl_print (struct cmdline_term *cl_term, grub_uint32_t c,
+ grub_uint32_t *start, grub_uint32_t *end)
+{
+ grub_uint32_t *p;
+
+ for (p = start; p < end; p++)
+ {
+ if (c)
+ grub_putcode (c, cl_term->term);
+ else
+ grub_putcode (*p, cl_term->term);
+ cl_term->pos.x++;
+ if (cl_term->pos.x >= cl_term->width - 1)
+ {
+ cl_term->pos.x = 0;
+ if (cl_term->pos.y >= (unsigned) (cl_term->height - 1))
+ cl_term->ystart--;
+ else
+ cl_term->pos.y++;
+ grub_putcode ('\n', cl_term->term);
+ }
+ }
+}
+
+static void
+cl_print_all (struct cmdline_term *cl_terms, unsigned nterms,
+ grub_uint32_t c, grub_uint32_t *start, grub_uint32_t *end)
+{
+ unsigned i;
+ for (i = 0; i < nterms; i++)
+ cl_print (&cl_terms[i], c, start, end);
+}
+
+static void
+init_clterm (struct cmdline_term *cl_term_cur)
+{
+ cl_term_cur->pos.x = cl_term_cur->prompt_len;
+ cl_term_cur->pos.y = grub_term_getxy (cl_term_cur->term).y;
+ cl_term_cur->ystart = cl_term_cur->pos.y;
+ cl_term_cur->width = grub_term_width (cl_term_cur->term);
+ cl_term_cur->height = grub_term_height (cl_term_cur->term);
+}
+
+
+static void
+cl_delete (struct cmdline_term *cl_terms, unsigned nterms,
+ grub_uint32_t *buf,
+ grub_size_t lpos, grub_size_t *llen, unsigned len)
+{
+ if (lpos + len <= (*llen))
+ {
+ cl_set_pos_all (cl_terms, nterms, (*llen) - len);
+ cl_print_all (cl_terms, nterms, ' ', buf + (*llen) - len, buf + (*llen));
+
+ cl_set_pos_all (cl_terms, nterms, lpos);
+
+ grub_memmove (buf + lpos, buf + lpos + len,
+ sizeof (grub_uint32_t) * ((*llen) - lpos + 1));
+ (*llen) -= len;
+ cl_print_all (cl_terms, nterms, 0, buf + lpos, buf + (*llen));
+ cl_set_pos_all (cl_terms, nterms, lpos);
+ }
+}
+
+
+static void
+cl_insert (struct cmdline_term *cl_terms, unsigned nterms,
+ grub_size_t *lpos, grub_size_t *llen,
+ grub_size_t *max_len, grub_uint32_t **buf,
+ const grub_uint32_t *str)
+{
+ grub_size_t len = strlen_ucs4 (str);
+
+ if (len + (*llen) >= (*max_len))
+ {
+ grub_uint32_t *nbuf;
+ grub_size_t sz;
+
+ if (grub_mul (*max_len, 2, max_len) ||
+ grub_mul (*max_len, sizeof (grub_uint32_t), &sz))
+ {
+ grub_errno = GRUB_ERR_OUT_OF_RANGE;
+ goto fail;
+ }
+
+ nbuf = grub_realloc ((*buf), sz);
+ if (nbuf)
+ (*buf) = nbuf;
+ else
+ {
+ fail:
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ (*max_len) /= 2;
+ }
+ }
+
+ if (len + (*llen) < (*max_len))
+ {
+ grub_memmove ((*buf) + (*lpos) + len, (*buf) + (*lpos),
+ ((*llen) - (*lpos) + 1) * sizeof (grub_uint32_t));
+ grub_memmove ((*buf) + (*lpos), str, len * sizeof (grub_uint32_t));
+
+ (*llen) += len;
+ cl_set_pos_all (cl_terms, nterms, (*lpos));
+ cl_print_all (cl_terms, nterms, 0, *buf + (*lpos), *buf + (*llen));
+ (*lpos) += len;
+ cl_set_pos_all (cl_terms, nterms, (*lpos));
+ }
+}
+
+
+/* Get a command-line. If ESC is pushed, return zero,
+ otherwise return command line. */
+/* FIXME: The dumb interface is not supported yet. */
+char *
+grub_cmdline_get (const char *prompt_translated)
+{
+ grub_size_t lpos, llen;
+ grub_uint32_t *buf;
+ grub_size_t max_len = 256;
+ int key;
+ int histpos = 0;
+ struct cmdline_term *cl_terms;
+ char *ret;
+ unsigned nterms;
+
+ buf = grub_calloc (max_len, sizeof (grub_uint32_t));
+ if (!buf)
+ return 0;
+
+ lpos = llen = 0;
+ buf[0] = '\0';
+
+ {
+ grub_term_output_t term;
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ if ((grub_term_getxy (term).x) != 0)
+ grub_putcode ('\n', term);
+ }
+ grub_xputs (prompt_translated);
+ grub_xputs (" ");
+ grub_normal_reset_more ();
+
+ {
+ struct cmdline_term *cl_term_cur;
+ struct grub_term_output *cur;
+ grub_uint32_t *unicode_msg;
+ grub_size_t msg_len = grub_strlen (prompt_translated) + 3;
+
+ nterms = 0;
+ FOR_ACTIVE_TERM_OUTPUTS(cur)
+ nterms++;
+
+ cl_terms = grub_calloc (nterms, sizeof (cl_terms[0]));
+ if (!cl_terms)
+ {
+ grub_free (buf);
+ return 0;
+ }
+ cl_term_cur = cl_terms;
+
+ unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t));
+ if (!unicode_msg)
+ {
+ grub_free (buf);
+ grub_free (cl_terms);
+ return 0;
+ }
+ msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len - 1,
+ (grub_uint8_t *) prompt_translated, -1, 0);
+ unicode_msg[msg_len++] = ' ';
+
+ FOR_ACTIVE_TERM_OUTPUTS(cur)
+ {
+ cl_term_cur->term = cur;
+ cl_term_cur->prompt_len = grub_getstringwidth (unicode_msg,
+ unicode_msg + msg_len,
+ cur);
+ init_clterm (cl_term_cur);
+ cl_term_cur++;
+ }
+ grub_free (unicode_msg);
+ }
+
+ if (hist_used == 0)
+ grub_history_add (buf, llen);
+
+ grub_refresh ();
+
+ while ((key = grub_getkey ()) != '\n' && key != '\r')
+ {
+ switch (key)
+ {
+ case GRUB_TERM_CTRL | 'a':
+ case GRUB_TERM_KEY_HOME:
+ lpos = 0;
+ cl_set_pos_all (cl_terms, nterms, lpos);
+ break;
+
+ case GRUB_TERM_CTRL | 'b':
+ case GRUB_TERM_KEY_LEFT:
+ if (lpos > 0)
+ {
+ lpos--;
+ cl_set_pos_all (cl_terms, nterms, lpos);
+ }
+ break;
+
+ case GRUB_TERM_CTRL | 'e':
+ case GRUB_TERM_KEY_END:
+ lpos = llen;
+ cl_set_pos_all (cl_terms, nterms, lpos);
+ break;
+
+ case GRUB_TERM_CTRL | 'f':
+ case GRUB_TERM_KEY_RIGHT:
+ if (lpos < llen)
+ {
+ lpos++;
+ cl_set_pos_all (cl_terms, nterms, lpos);
+ }
+ break;
+
+ case GRUB_TERM_CTRL | 'i':
+ case '\t':
+ {
+ int restore;
+ char *insertu8;
+ char *bufu8;
+ grub_uint32_t c;
+
+ c = buf[lpos];
+ buf[lpos] = '\0';
+
+ bufu8 = grub_ucs4_to_utf8_alloc (buf, lpos);
+ buf[lpos] = c;
+ if (!bufu8)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ break;
+ }
+
+ insertu8 = grub_normal_do_completion (bufu8, &restore,
+ print_completion);
+ grub_free (bufu8);
+
+ grub_normal_reset_more ();
+
+ if (restore)
+ {
+ unsigned i;
+
+ /* Restore the prompt. */
+ grub_xputs ("\n");
+ grub_xputs (prompt_translated);
+ grub_xputs (" ");
+
+ for (i = 0; i < nterms; i++)
+ init_clterm (&cl_terms[i]);
+
+ cl_print_all (cl_terms, nterms, 0, buf, buf + llen);
+ }
+
+ if (insertu8)
+ {
+ grub_size_t insertlen;
+ grub_ssize_t t;
+ grub_uint32_t *insert;
+
+ insertlen = grub_strlen (insertu8);
+ insert = grub_calloc (insertlen + 1, sizeof (grub_uint32_t));
+ if (!insert)
+ {
+ grub_free (insertu8);
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ break;
+ }
+ t = grub_utf8_to_ucs4 (insert, insertlen,
+ (grub_uint8_t *) insertu8,
+ insertlen, 0);
+ if (t > 0)
+ {
+ if (insert[t-1] == ' ' && buf[lpos] == ' ')
+ {
+ insert[t-1] = 0;
+ if (t != 1)
+ cl_insert (cl_terms, nterms, &lpos, &llen, &max_len, &buf, insert);
+ lpos++;
+ }
+ else
+ {
+ insert[t] = 0;
+ cl_insert (cl_terms, nterms, &lpos, &llen, &max_len, &buf, insert);
+ }
+ }
+
+ grub_free (insertu8);
+ grub_free (insert);
+ }
+ cl_set_pos_all (cl_terms, nterms, lpos);
+ }
+ break;
+
+ case GRUB_TERM_CTRL | 'k':
+ if (lpos < llen)
+ {
+ grub_free (kill_buf);
+
+ kill_buf = grub_malloc ((llen - lpos + 1)
+ * sizeof (grub_uint32_t));
+ if (grub_errno)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+ else
+ {
+ grub_memcpy (kill_buf, buf + lpos,
+ (llen - lpos + 1) * sizeof (grub_uint32_t));
+ kill_buf[llen - lpos] = 0;
+ }
+
+ cl_delete (cl_terms, nterms,
+ buf, lpos, &llen, llen - lpos);
+ }
+ break;
+
+ case GRUB_TERM_CTRL | 'n':
+ case GRUB_TERM_KEY_DOWN:
+ {
+ grub_uint32_t *hist;
+
+ lpos = 0;
+
+ if (histpos > 0)
+ {
+ grub_history_replace (histpos, buf, llen);
+ histpos--;
+ }
+
+ cl_delete (cl_terms, nterms,
+ buf, lpos, &llen, llen);
+ hist = grub_history_get (histpos);
+ cl_insert (cl_terms, nterms, &lpos, &llen, &max_len, &buf, hist);
+
+ break;
+ }
+
+ case GRUB_TERM_KEY_UP:
+ case GRUB_TERM_CTRL | 'p':
+ {
+ grub_uint32_t *hist;
+
+ lpos = 0;
+
+ if (histpos < hist_used - 1)
+ {
+ grub_history_replace (histpos, buf, llen);
+ histpos++;
+ }
+
+ cl_delete (cl_terms, nterms,
+ buf, lpos, &llen, llen);
+ hist = grub_history_get (histpos);
+
+ cl_insert (cl_terms, nterms, &lpos, &llen, &max_len, &buf, hist);
+ }
+ break;
+
+ case GRUB_TERM_CTRL | 'u':
+ if (lpos > 0)
+ {
+ grub_size_t n = lpos;
+
+ grub_free (kill_buf);
+
+ kill_buf = grub_calloc (n + 1, sizeof (grub_uint32_t));
+ if (grub_errno)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+ if (kill_buf)
+ {
+ grub_memcpy (kill_buf, buf, n * sizeof(grub_uint32_t));
+ kill_buf[n] = 0;
+ }
+
+ lpos = 0;
+ cl_set_pos_all (cl_terms, nterms, lpos);
+ cl_delete (cl_terms, nterms,
+ buf, lpos, &llen, n);
+ }
+ break;
+
+ case GRUB_TERM_CTRL | 'y':
+ if (kill_buf)
+ cl_insert (cl_terms, nterms, &lpos, &llen, &max_len, &buf, kill_buf);
+ break;
+
+ case GRUB_TERM_ESC:
+ grub_free (cl_terms);
+ grub_free (buf);
+ return 0;
+
+ case GRUB_TERM_BACKSPACE:
+ if (lpos > 0)
+ {
+ lpos--;
+ cl_set_pos_all (cl_terms, nterms, lpos);
+ }
+ else
+ break;
+ /* fall through */
+
+ case GRUB_TERM_CTRL | 'd':
+ case GRUB_TERM_KEY_DC:
+ if (lpos < llen)
+ cl_delete (cl_terms, nterms,
+ buf, lpos, &llen, 1);
+ break;
+
+ default:
+ if (grub_isprint (key))
+ {
+ grub_uint32_t str[2];
+
+ str[0] = key;
+ str[1] = '\0';
+ cl_insert (cl_terms, nterms, &lpos, &llen, &max_len, &buf, str);
+ }
+ break;
+ }
+
+ grub_refresh ();
+ }
+
+ grub_xputs ("\n");
+ grub_refresh ();
+
+ histpos = 0;
+ if (strlen_ucs4 (buf) > 0)
+ {
+ grub_uint32_t empty[] = { 0 };
+ grub_history_replace (histpos, buf, llen);
+ grub_history_add (empty, 0);
+ }
+
+ ret = grub_ucs4_to_utf8_alloc (buf, llen + 1);
+ grub_free (buf);
+ grub_free (cl_terms);
+ return ret;
+}
diff --git a/grub-core/normal/color.c b/grub-core/normal/color.c
new file mode 100644
index 0000000..d22cf90
--- /dev/null
+++ b/grub-core/normal/color.c
@@ -0,0 +1,145 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,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/misc.h>
+#include <grub/mm.h>
+#include <grub/normal.h>
+#include <grub/term.h>
+#include <grub/i18n.h>
+
+/* Borrowed from GRUB Legacy */
+static const char *color_list[16] =
+{
+ "black",
+ "blue",
+ "green",
+ "cyan",
+ "red",
+ "magenta",
+ "brown",
+ "light-gray",
+ "dark-gray",
+ "light-blue",
+ "light-green",
+ "light-cyan",
+ "light-red",
+ "light-magenta",
+ "yellow",
+ "white"
+};
+
+static int
+parse_color_name (grub_uint8_t *ret, char *name)
+{
+ grub_uint8_t i;
+ for (i = 0; i < ARRAY_SIZE(color_list); i++)
+ if (! grub_strcmp (name, color_list[i]))
+ {
+ *ret = i;
+ return 0;
+ }
+ return -1;
+}
+
+int
+grub_parse_color_name_pair (grub_uint8_t *color, const char *name)
+{
+ int result = 1;
+ grub_uint8_t fg, bg;
+ char *fg_name, *bg_name;
+
+ /* nothing specified by user */
+ if (name == NULL)
+ return result;
+
+ fg_name = grub_strdup (name);
+ if (fg_name == NULL)
+ {
+ /* "out of memory" message was printed by grub_strdup() */
+ grub_wait_after_message ();
+ return result;
+ }
+
+ bg_name = grub_strchr (fg_name, '/');
+ if (bg_name == NULL)
+ {
+ grub_printf_ (N_("Warning: syntax error (missing slash) in `%s'\n"), fg_name);
+ grub_wait_after_message ();
+ goto free_and_return;
+ }
+
+ *(bg_name++) = '\0';
+
+ if (parse_color_name (&fg, fg_name) == -1)
+ {
+ grub_printf_ (N_("Warning: invalid foreground color `%s'\n"), fg_name);
+ grub_wait_after_message ();
+ goto free_and_return;
+ }
+ if (parse_color_name (&bg, bg_name) == -1)
+ {
+ grub_printf_ (N_("Warning: invalid background color `%s'\n"), bg_name);
+ grub_wait_after_message ();
+ goto free_and_return;
+ }
+
+ *color = (bg << 4) | fg;
+ result = 0;
+
+free_and_return:
+ grub_free (fg_name);
+ return result;
+}
+
+static void
+set_colors (void)
+{
+ struct grub_term_output *term;
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ /* Propagates `normal' color to terminal current color. */
+ grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
+ }
+}
+
+/* Replace default `normal' colors with the ones specified by user (if any). */
+char *
+grub_env_write_color_normal (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val)
+{
+ if (grub_parse_color_name_pair (&grub_term_normal_color, val))
+ return NULL;
+
+ set_colors ();
+
+ return grub_strdup (val);
+}
+
+/* Replace default `highlight' colors with the ones specified by user (if any). */
+char *
+grub_env_write_color_highlight (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val)
+{
+ if (grub_parse_color_name_pair (&grub_term_highlight_color, val))
+ return NULL;
+
+ set_colors ();
+
+ return grub_strdup (val);
+}
diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c
new file mode 100644
index 0000000..18cadfa
--- /dev/null
+++ b/grub-core/normal/completion.c
@@ -0,0 +1,526 @@
+/* completion.c - complete a command, a disk, a partition or a file */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/partition.h>
+#include <grub/disk.h>
+#include <grub/file.h>
+#include <grub/parser.h>
+#include <grub/extcmd.h>
+#include <grub/charset.h>
+
+/* The current word. */
+static const char *current_word;
+
+/* The matched string. */
+static char *match;
+
+/* The count of candidates. */
+static int num_found;
+
+/* The string to be appended. */
+static const char *suffix;
+
+/* The callback function to print items. */
+static void (*print_func) (const char *, grub_completion_type_t, int);
+
+/* The state the command line is in. */
+static grub_parser_state_t cmdline_state;
+
+
+/* Add a string to the list of possible completions. COMPLETION is the
+ string that should be added. EXTRA will be appended if COMPLETION
+ matches uniquely. The type TYPE specifies what kind of data is added. */
+static int
+add_completion (const char *completion, const char *extra,
+ grub_completion_type_t type)
+{
+ if (grub_strncmp (current_word, completion, grub_strlen (current_word)) == 0)
+ {
+ num_found++;
+
+ switch (num_found)
+ {
+ case 1:
+ match = grub_strdup (completion);
+ if (! match)
+ return 1;
+ suffix = extra;
+ break;
+
+ case 2:
+ if (print_func)
+ print_func (match, type, 0);
+
+ /* Fall through. */
+
+ default:
+ {
+ char *s = match;
+ const char *t = completion;
+
+ if (print_func)
+ print_func (completion, type, num_found - 1);
+
+ /* Detect the matched portion. */
+ while (*s && *t && *s == *t)
+ {
+ s++;
+ t++;
+ }
+ s = match + grub_getend (match, s);
+
+ *s = '\0';
+ }
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static int
+iterate_partition (grub_disk_t disk, const grub_partition_t p,
+ void *data __attribute__ ((unused)))
+{
+ const char *disk_name = disk->name;
+ char *name;
+ int ret;
+ char *part_name;
+
+ part_name = grub_partition_get_name (p);
+ if (! part_name)
+ return 1;
+
+ name = grub_xasprintf ("%s,%s", disk_name, part_name);
+ grub_free (part_name);
+
+ if (! name)
+ return 1;
+
+ ret = add_completion (name, ")", GRUB_COMPLETION_TYPE_PARTITION);
+ grub_free (name);
+ return ret;
+}
+
+static int
+iterate_dir (const char *filename, const struct grub_dirhook_info *info,
+ void *data __attribute__ ((unused)))
+{
+ if (! info->dir)
+ {
+ const char *prefix;
+ if (cmdline_state == GRUB_PARSER_STATE_DQUOTE)
+ prefix = "\" ";
+ else if (cmdline_state == GRUB_PARSER_STATE_QUOTE)
+ prefix = "\' ";
+ else
+ prefix = " ";
+
+ if (add_completion (filename, prefix, GRUB_COMPLETION_TYPE_FILE))
+ return 1;
+ }
+ else if (grub_strcmp (filename, ".") && grub_strcmp (filename, ".."))
+ {
+ char *fname;
+
+ fname = grub_xasprintf ("%s/", filename);
+ if (add_completion (fname, "", GRUB_COMPLETION_TYPE_FILE))
+ {
+ grub_free (fname);
+ return 1;
+ }
+ grub_free (fname);
+ }
+
+ return 0;
+}
+
+static int
+iterate_dev (const char *devname, void *data __attribute__ ((unused)))
+{
+ grub_device_t dev;
+
+ /* Complete the partition part. */
+ dev = grub_device_open (devname);
+
+ if (!dev)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+
+ if (grub_strcmp (devname, current_word) == 0)
+ {
+ if (add_completion (devname, ")", GRUB_COMPLETION_TYPE_PARTITION))
+ {
+ grub_device_close (dev);
+ return 1;
+ }
+
+ if (dev->disk)
+ if (grub_partition_iterate (dev->disk, iterate_partition, NULL))
+ {
+ grub_device_close (dev);
+ return 1;
+ }
+ }
+ else if (add_completion (devname, "", GRUB_COMPLETION_TYPE_DEVICE))
+ {
+ grub_device_close (dev);
+ return 1;
+ }
+
+ grub_device_close (dev);
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+}
+
+/* Complete a device. */
+static int
+complete_device (void)
+{
+ /* Check if this is a device or a partition. */
+ char *p = grub_strchr (++current_word, ',');
+ grub_device_t dev;
+
+ if (! p)
+ {
+ /* Complete the disk part. */
+ if (grub_disk_dev_iterate (iterate_dev, NULL))
+ return 1;
+ }
+ else
+ {
+ /* Complete the partition part. */
+ *p = '\0';
+ dev = grub_device_open (current_word);
+ *p = ',';
+ grub_errno = GRUB_ERR_NONE;
+
+ if (dev)
+ {
+ if (dev->disk)
+ {
+ if (grub_partition_iterate (dev->disk, iterate_partition, NULL))
+ {
+ grub_device_close (dev);
+ return 1;
+ }
+ }
+
+ grub_device_close (dev);
+ }
+ else
+ return 1;
+ }
+
+ return 0;
+}
+
+/* Complete a file. */
+static int
+complete_file (void)
+{
+ char *device;
+ char *dir;
+ char *last_dir;
+ grub_fs_t fs;
+ grub_device_t dev;
+ int ret = 0;
+
+ device = grub_file_get_device_name (current_word);
+ if (grub_errno != GRUB_ERR_NONE)
+ return 1;
+
+ dev = grub_device_open (device);
+ if (! dev)
+ {
+ ret = 1;
+ goto fail;
+ }
+
+ fs = grub_fs_probe (dev);
+ if (! fs)
+ {
+ ret = 1;
+ goto fail;
+ }
+
+ dir = grub_strchr (current_word + (device ? 2 + grub_strlen (device) : 0),
+ '/');
+ last_dir = grub_strrchr (current_word, '/');
+ if (dir)
+ {
+ char *dirfile;
+
+ current_word = last_dir + 1;
+
+ dir = grub_strdup (dir);
+ if (! dir)
+ {
+ ret = 1;
+ goto fail;
+ }
+
+ /* Cut away the filename part. */
+ dirfile = grub_strrchr (dir, '/');
+ if (dirfile)
+ dirfile[1] = '\0';
+
+ /* Iterate the directory. */
+ (fs->fs_dir) (dev, dir, iterate_dir, NULL);
+
+ grub_free (dir);
+
+ if (grub_errno)
+ {
+ ret = 1;
+ goto fail;
+ }
+ }
+ else
+ {
+ current_word += grub_strlen (current_word);
+ match = grub_strdup ("/");
+ if (! match)
+ {
+ ret = 1;
+ goto fail;
+ }
+
+ suffix = "";
+ num_found = 1;
+ }
+
+ fail:
+ if (dev)
+ grub_device_close (dev);
+ grub_free (device);
+ return ret;
+}
+
+/* Complete an argument. */
+static int
+complete_arguments (char *command)
+{
+ grub_command_t cmd;
+ grub_extcmd_t ext;
+ const struct grub_arg_option *option;
+ char shortarg[] = "- ";
+
+ cmd = grub_command_find (command);
+
+ if (!cmd || !(cmd->flags & GRUB_COMMAND_FLAG_EXTCMD))
+ return 0;
+
+ ext = cmd->data;
+ if (!ext->options)
+ return 0;
+
+ if (add_completion ("-u", " ", GRUB_COMPLETION_TYPE_ARGUMENT))
+ return 1;
+
+ /* Add the short arguments. */
+ for (option = ext->options; option->doc; option++)
+ {
+ if (! option->shortarg)
+ continue;
+
+ shortarg[1] = option->shortarg;
+ if (add_completion (shortarg, " ", GRUB_COMPLETION_TYPE_ARGUMENT))
+ return 1;
+
+ }
+
+ /* First add the built-in arguments. */
+ if (add_completion ("--help", " ", GRUB_COMPLETION_TYPE_ARGUMENT))
+ return 1;
+ if (add_completion ("--usage", " ", GRUB_COMPLETION_TYPE_ARGUMENT))
+ return 1;
+
+ /* Add the long arguments. */
+ for (option = ext->options; option->doc; option++)
+ {
+ char *longarg;
+ if (!option->longarg)
+ continue;
+
+ longarg = grub_xasprintf ("--%s", option->longarg);
+ if (!longarg)
+ return 1;
+
+ if (add_completion (longarg, " ", GRUB_COMPLETION_TYPE_ARGUMENT))
+ {
+ grub_free (longarg);
+ return 1;
+ }
+ grub_free (longarg);
+ }
+
+ return 0;
+}
+
+
+static grub_parser_state_t
+get_state (const char *cmdline)
+{
+ grub_parser_state_t state = GRUB_PARSER_STATE_TEXT;
+ char use;
+
+ while (*cmdline)
+ state = grub_parser_cmdline_state (state, *(cmdline++), &use);
+ return state;
+}
+
+
+/* Try to complete the string in BUF. Return the characters that
+ should be added to the string. This command outputs the possible
+ completions by calling HOOK, in that case set RESTORE to 1 so the
+ caller can restore the prompt. */
+char *
+grub_normal_do_completion (char *buf, int *restore,
+ void (*hook) (const char *, grub_completion_type_t, int))
+{
+ int argc = 0;
+ char **argv = NULL;
+
+ /* Initialize variables. */
+ match = 0;
+ num_found = 0;
+ suffix = "";
+ print_func = hook;
+
+ *restore = 1;
+
+ if (grub_parser_split_cmdline (buf, 0, 0, &argc, &argv))
+ return 0;
+
+ if (argc == 0)
+ current_word = "";
+ else
+ current_word = argv[argc - 1];
+
+ if (argc > 1 && ! grub_strcmp (argv[0], "set"))
+ {
+ char *equals = grub_strchr (current_word, '=');
+ if (equals)
+ /* Complete the value of the variable. */
+ current_word = equals + 1;
+ }
+
+ /* Determine the state the command line is in, depending on the
+ state, it can be determined how to complete. */
+ cmdline_state = get_state (buf);
+
+ if (argc == 1 || argc == 0)
+ {
+ /* Complete a command. */
+ grub_command_t cmd;
+ FOR_COMMANDS(cmd)
+ {
+ if (cmd->prio & GRUB_COMMAND_FLAG_ACTIVE)
+ {
+ if (add_completion (cmd->name, " ", GRUB_COMPLETION_TYPE_COMMAND))
+ goto fail;
+ }
+ }
+ }
+ else if (*current_word == '-')
+ {
+ if (complete_arguments (buf))
+ goto fail;
+ }
+ else if (*current_word == '(' && ! grub_strchr (current_word, ')'))
+ {
+ /* Complete a device. */
+ if (complete_device ())
+ goto fail;
+ }
+ else
+ {
+ /* Complete a file. */
+ if (complete_file ())
+ goto fail;
+ }
+
+ /* If more than one match is found those matches will be printed and
+ the prompt should be restored. */
+ if (num_found > 1)
+ *restore = 1;
+ else
+ *restore = 0;
+
+ /* Return the part that matches. */
+ if (match)
+ {
+ char *ret;
+ char *escstr;
+ char *newstr;
+ int current_len;
+ int match_len;
+ int spaces = 0;
+
+ current_len = grub_strlen (current_word);
+ match_len = grub_strlen (match);
+
+ /* Count the number of spaces that have to be escaped. XXX:
+ More than just spaces have to be escaped. */
+ for (escstr = match + current_len; *escstr; escstr++)
+ if (*escstr == ' ')
+ spaces++;
+
+ ret = grub_malloc (match_len - current_len + grub_strlen (suffix) + spaces + 1);
+ newstr = ret;
+ for (escstr = match + current_len; *escstr; escstr++)
+ {
+ if (*escstr == ' ' && cmdline_state != GRUB_PARSER_STATE_QUOTE
+ && cmdline_state != GRUB_PARSER_STATE_QUOTE)
+ *(newstr++) = '\\';
+ *(newstr++) = *escstr;
+ }
+ *newstr = '\0';
+
+ if (num_found == 1)
+ grub_strcpy (newstr, suffix);
+
+ if (*ret == '\0')
+ {
+ grub_free (ret);
+ goto fail;
+ }
+
+ if (argc != 0)
+ grub_free (argv[0]);
+ grub_free (match);
+ return ret;
+ }
+
+ fail:
+ if (argc != 0)
+ grub_free (argv[0]);
+ grub_free (argv);
+ grub_free (match);
+ grub_errno = GRUB_ERR_NONE;
+
+ return 0;
+}
diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c
new file mode 100644
index 0000000..ee53d4a
--- /dev/null
+++ b/grub-core/normal/context.c
@@ -0,0 +1,214 @@
+/* env.c - Environment variables */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/env.h>
+#include <grub/env_private.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/command.h>
+#include <grub/normal.h>
+#include <grub/i18n.h>
+
+struct menu_pointer
+{
+ grub_menu_t menu;
+ struct menu_pointer *prev;
+};
+
+static struct menu_pointer initial_menu;
+static struct menu_pointer *current_menu = &initial_menu;
+
+void
+grub_env_unset_menu (void)
+{
+ current_menu->menu = NULL;
+}
+
+grub_menu_t
+grub_env_get_menu (void)
+{
+ return current_menu->menu;
+}
+
+void
+grub_env_set_menu (grub_menu_t nmenu)
+{
+ current_menu->menu = nmenu;
+}
+
+static grub_err_t
+grub_env_new_context (int export_all)
+{
+ struct grub_env_context *context;
+ int i;
+ struct menu_pointer *menu;
+
+ context = grub_zalloc (sizeof (*context));
+ if (! context)
+ return grub_errno;
+ menu = grub_zalloc (sizeof (*menu));
+ if (! menu)
+ {
+ grub_free (context);
+ return grub_errno;
+ }
+
+ context->prev = grub_current_context;
+ grub_current_context = context;
+
+ menu->prev = current_menu;
+ current_menu = menu;
+
+ /* Copy exported variables. */
+ for (i = 0; i < HASHSZ; i++)
+ {
+ struct grub_env_var *var;
+
+ for (var = context->prev->vars[i]; var; var = var->next)
+ if (var->global || export_all)
+ {
+ if (grub_env_set (var->name, var->value) != GRUB_ERR_NONE)
+ {
+ grub_env_context_close ();
+ return grub_errno;
+ }
+ grub_env_export (var->name);
+ grub_register_variable_hook (var->name, var->read_hook, var->write_hook);
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_env_context_open (void)
+{
+ return grub_env_new_context (0);
+}
+
+int grub_extractor_level = 0;
+
+grub_err_t
+grub_env_extractor_open (int source)
+{
+ grub_extractor_level++;
+ return grub_env_new_context (source);
+}
+
+grub_err_t
+grub_env_context_close (void)
+{
+ struct grub_env_context *context;
+ int i;
+ struct menu_pointer *menu;
+
+ if (! grub_current_context->prev)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "cannot close the initial context");
+
+ /* Free the variables associated with this context. */
+ for (i = 0; i < HASHSZ; i++)
+ {
+ struct grub_env_var *p, *q;
+
+ for (p = grub_current_context->vars[i]; p; p = q)
+ {
+ q = p->next;
+ grub_free (p->name);
+ grub_free (p->value);
+ grub_free (p);
+ }
+ }
+
+ /* Restore the previous context. */
+ context = grub_current_context->prev;
+ grub_free (grub_current_context);
+ grub_current_context = context;
+
+ menu = current_menu->prev;
+ if (current_menu->menu)
+ grub_normal_free_menu (current_menu->menu);
+ grub_free (current_menu);
+ current_menu = menu;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_env_extractor_close (int source)
+{
+ grub_menu_t menu = NULL;
+ grub_menu_entry_t *last;
+ grub_err_t err;
+
+ if (source)
+ {
+ menu = grub_env_get_menu ();
+ grub_env_unset_menu ();
+ }
+ err = grub_env_context_close ();
+
+ if (source && menu)
+ {
+ grub_menu_t menu2;
+ menu2 = grub_env_get_menu ();
+
+ last = &menu2->entry_list;
+ while (*last)
+ last = &(*last)->next;
+
+ *last = menu->entry_list;
+ menu2->size += menu->size;
+ }
+
+ grub_extractor_level--;
+ return err;
+}
+
+static grub_command_t export_cmd;
+
+static grub_err_t
+grub_cmd_export (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ int i;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("one argument expected"));
+
+ for (i = 0; i < argc; i++)
+ grub_env_export (args[i]);
+
+ return 0;
+}
+
+void
+grub_context_init (void)
+{
+ export_cmd = grub_register_command ("export", grub_cmd_export,
+ N_("ENVVAR [ENVVAR] ..."),
+ N_("Export variables."));
+}
+
+void
+grub_context_fini (void)
+{
+ grub_unregister_command (export_cmd);
+}
diff --git a/grub-core/normal/crypto.c b/grub-core/normal/crypto.c
new file mode 100644
index 0000000..d01e6f2
--- /dev/null
+++ b/grub-core/normal/crypto.c
@@ -0,0 +1,163 @@
+/* crypto.c - support crypto autoload */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/crypto.h>
+#include <grub/normal.h>
+
+struct load_spec
+{
+ struct load_spec *next;
+ char *name;
+ char *modname;
+};
+
+static struct load_spec *crypto_specs = NULL;
+
+static void
+grub_crypto_autoload (const char *name)
+{
+ struct load_spec *cur;
+ grub_dl_t mod;
+ static int depth = 0;
+
+ /* Some bufio of filesystems may want some crypto modules.
+ It may result in infinite recursion. Hence this check. */
+ if (depth)
+ return;
+ depth++;
+
+ for (cur = crypto_specs; cur; cur = cur->next)
+ if (grub_strcasecmp (name, cur->name) == 0)
+ {
+ mod = grub_dl_load (cur->modname);
+ if (mod)
+ grub_dl_ref (mod);
+ grub_errno = GRUB_ERR_NONE;
+ }
+ depth--;
+}
+
+static void
+grub_crypto_spec_free (void)
+{
+ struct load_spec *cur, *next;
+ for (cur = crypto_specs; cur; cur = next)
+ {
+ next = cur->next;
+ grub_free (cur->name);
+ grub_free (cur->modname);
+ grub_free (cur);
+ }
+ crypto_specs = NULL;
+}
+
+
+/* Read the file crypto.lst for auto-loading. */
+void
+read_crypto_list (const char *prefix)
+{
+ char *filename;
+ grub_file_t file;
+ char *buf = NULL;
+
+ if (!prefix)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM
+ "/crypto.lst", prefix);
+ if (!filename)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
+ grub_free (filename);
+ if (!file)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ /* Override previous crypto.lst. */
+ grub_crypto_spec_free ();
+
+ for (;; grub_free (buf))
+ {
+ char *p, *name;
+ struct load_spec *cur;
+
+ buf = grub_file_getline (file);
+
+ if (! buf)
+ break;
+
+ name = buf;
+ while (grub_isspace (name[0]))
+ name++;
+
+ p = grub_strchr (name, ':');
+ if (! p)
+ continue;
+
+ *p = '\0';
+ p++;
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ cur = grub_malloc (sizeof (*cur));
+ if (!cur)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ cur->name = grub_strdup (name);
+ if (! cur->name)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_free (cur);
+ continue;
+ }
+
+ cur->modname = grub_strdup (p);
+ if (! cur->modname)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_free (cur->name);
+ grub_free (cur);
+ continue;
+ }
+ cur->next = crypto_specs;
+ crypto_specs = cur;
+ }
+
+ grub_file_close (file);
+
+ grub_errno = GRUB_ERR_NONE;
+
+ grub_crypto_autoload_hook = grub_crypto_autoload;
+}
diff --git a/grub-core/normal/dyncmd.c b/grub-core/normal/dyncmd.c
new file mode 100644
index 0000000..719ebf4
--- /dev/null
+++ b/grub-core/normal/dyncmd.c
@@ -0,0 +1,210 @@
+/* dyncmd.c - support dynamic command */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/misc.h>
+#include <grub/command.h>
+#include <grub/normal.h>
+#include <grub/extcmd.h>
+#include <grub/script_sh.h>
+#include <grub/i18n.h>
+
+grub_command_t
+grub_dyncmd_get_cmd (grub_command_t cmd)
+{
+ grub_extcmd_t extcmd = cmd->data;
+ char *modname;
+ char *name;
+ grub_dl_t mod;
+
+ modname = extcmd->data;
+ mod = grub_dl_load (modname);
+ if (!mod)
+ return NULL;
+
+ grub_free (modname);
+ grub_dl_ref (mod);
+
+ name = (char *) cmd->name;
+ grub_unregister_extcmd (extcmd);
+
+ cmd = grub_command_find (name);
+
+ grub_free (name);
+
+ return cmd;
+}
+
+static grub_err_t
+grub_dyncmd_dispatcher (struct grub_extcmd_context *ctxt,
+ int argc, char **args)
+{
+ char *modname;
+ grub_dl_t mod;
+ grub_err_t ret;
+ grub_extcmd_t extcmd = ctxt->extcmd;
+ grub_command_t cmd = extcmd->cmd;
+ char *name;
+
+ modname = extcmd->data;
+ mod = grub_dl_load (modname);
+ if (!mod)
+ return grub_errno;
+
+ grub_free (modname);
+ grub_dl_ref (mod);
+
+ name = (char *) cmd->name;
+ grub_unregister_extcmd (extcmd);
+
+ cmd = grub_command_find (name);
+ if (cmd)
+ {
+ if (cmd->flags & GRUB_COMMAND_FLAG_BLOCKS &&
+ cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
+ ret = grub_extcmd_dispatcher (cmd, argc, args, ctxt->script);
+ else
+ ret = (cmd->func) (cmd, argc, args);
+ }
+ else
+ ret = grub_errno;
+
+ grub_free (name);
+
+ return ret;
+}
+
+/* Read the file command.lst for auto-loading. */
+void
+read_command_list (const char *prefix)
+{
+ if (prefix)
+ {
+ char *filename;
+
+ filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM
+ "/command.lst", prefix);
+ if (filename)
+ {
+ grub_file_t file;
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
+ if (file)
+ {
+ char *buf = NULL;
+ grub_command_t ptr, last = 0, next;
+
+ /* Override previous commands.lst. */
+ for (ptr = grub_command_list; ptr; ptr = next)
+ {
+ next = ptr->next;
+ if (ptr->flags & GRUB_COMMAND_FLAG_DYNCMD)
+ {
+ if (last)
+ last->next = ptr->next;
+ else
+ grub_command_list = ptr->next;
+ grub_free (ptr->data); /* extcmd struct */
+ grub_free (ptr);
+ }
+ else
+ last = ptr;
+ }
+
+ for (;; grub_free (buf))
+ {
+ char *p, *name, *modname;
+ grub_extcmd_t cmd;
+ int prio = 0;
+
+ buf = grub_file_getline (file);
+
+ if (! buf)
+ break;
+
+ name = buf;
+ while (grub_isspace (name[0]))
+ name++;
+
+ if (*name == '*')
+ {
+ name++;
+ prio++;
+ }
+
+ if (! grub_isgraph (name[0]))
+ continue;
+
+ p = grub_strchr (name, ':');
+ if (! p)
+ continue;
+
+ *p = '\0';
+ p++;
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (! grub_isgraph (*p))
+ continue;
+
+ if (grub_dl_get (p))
+ continue;
+
+ name = grub_strdup (name);
+ if (! name)
+ continue;
+
+ modname = grub_strdup (p);
+ if (! modname)
+ {
+ grub_free (name);
+ continue;
+ }
+
+ cmd = grub_register_extcmd_prio (name,
+ grub_dyncmd_dispatcher,
+ GRUB_COMMAND_FLAG_BLOCKS
+ | GRUB_COMMAND_FLAG_EXTCMD
+ | GRUB_COMMAND_FLAG_DYNCMD,
+ 0, N_("module isn't loaded"),
+ 0, prio);
+ if (! cmd)
+ {
+ grub_free (name);
+ grub_free (modname);
+ continue;
+ }
+ cmd->data = modname;
+
+ /* Update the active flag. */
+ grub_command_find (name);
+ }
+
+ grub_file_close (file);
+ }
+
+ grub_free (filename);
+ }
+ }
+
+ /* Ignore errors. */
+ grub_errno = GRUB_ERR_NONE;
+}
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
new file mode 100644
index 0000000..c4ebe9e
--- /dev/null
+++ b/grub-core/normal/main.c
@@ -0,0 +1,587 @@
+/* main.c - the normal mode main routine */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/kernel.h>
+#include <grub/net.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/file.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+#include <grub/env.h>
+#include <grub/parser.h>
+#include <grub/reader.h>
+#include <grub/menu_viewer.h>
+#include <grub/auth.h>
+#include <grub/i18n.h>
+#include <grub/charset.h>
+#include <grub/script_sh.h>
+#include <grub/bufio.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_DEFAULT_HISTORY_SIZE 50
+
+static int nested_level = 0;
+int grub_normal_exit_level = 0;
+
+void
+grub_normal_free_menu (grub_menu_t menu)
+{
+ grub_menu_entry_t entry = menu->entry_list;
+
+ while (entry)
+ {
+ grub_menu_entry_t next_entry = entry->next;
+ grub_size_t i;
+
+ if (entry->classes)
+ {
+ struct grub_menu_entry_class *class;
+ for (class = entry->classes; class; class = class->next)
+ grub_free (class->name);
+ grub_free (entry->classes);
+ }
+
+ if (entry->args)
+ {
+ for (i = 0; entry->args[i]; i++)
+ grub_free (entry->args[i]);
+ grub_free (entry->args);
+ }
+
+ grub_free ((void *) entry->id);
+ grub_free ((void *) entry->users);
+ grub_free ((void *) entry->title);
+ grub_free ((void *) entry->sourcecode);
+ grub_free (entry);
+ entry = next_entry;
+ }
+
+ grub_free (menu);
+ grub_env_unset_menu ();
+}
+
+/* Helper for read_config_file. */
+static grub_err_t
+read_config_file_getline (char **line, int cont __attribute__ ((unused)),
+ void *data)
+{
+ grub_file_t file = data;
+
+ while (1)
+ {
+ char *buf;
+
+ *line = buf = grub_file_getline (file);
+ if (! buf)
+ return grub_errno;
+
+ if (buf[0] == '#')
+ grub_free (*line);
+ else
+ break;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_menu_t
+read_config_file (const char *config)
+{
+ grub_file_t rawfile, file;
+ char *old_file = 0, *old_dir = 0;
+ char *config_dir, *ptr = 0;
+ const char *ctmp;
+
+ grub_menu_t newmenu;
+
+ newmenu = grub_env_get_menu ();
+ if (! newmenu)
+ {
+ newmenu = grub_zalloc (sizeof (*newmenu));
+ if (! newmenu)
+ return 0;
+
+ grub_env_set_menu (newmenu);
+ }
+
+ /* Try to open the config file. */
+ rawfile = grub_file_open (config, GRUB_FILE_TYPE_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);
+ ctmp = grub_env_get ("config_directory");
+ if (ctmp)
+ old_dir = grub_strdup (ctmp);
+ if (*config == '(')
+ {
+ grub_env_set ("config_file", config);
+ config_dir = grub_strdup (config);
+ }
+ else
+ {
+ /* $root is guranteed to be defined, otherwise open above would fail */
+ config_dir = grub_xasprintf ("(%s)%s", grub_env_get ("root"), config);
+ if (config_dir)
+ grub_env_set ("config_file", config_dir);
+ }
+ if (config_dir)
+ {
+ ptr = grub_strrchr (config_dir, '/');
+ if (ptr)
+ *ptr = 0;
+ grub_env_set ("config_directory", config_dir);
+ grub_free (config_dir);
+ }
+
+ grub_env_export ("config_file");
+ grub_env_export ("config_directory");
+
+ while (1)
+ {
+ char *line;
+
+ /* Print an error, if any. */
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+
+ if ((read_config_file_getline (&line, 0, file)) || (! line))
+ break;
+
+ grub_normal_parse_line (line, read_config_file_getline, file);
+ grub_free (line);
+ }
+
+ if (old_file)
+ grub_env_set ("config_file", old_file);
+ else
+ grub_env_unset ("config_file");
+ if (old_dir)
+ grub_env_set ("config_directory", old_dir);
+ else
+ grub_env_unset ("config_directory");
+ grub_free (old_file);
+ grub_free (old_dir);
+
+ grub_file_close (file);
+
+ return newmenu;
+}
+
+/* Initialize the screen. */
+void
+grub_normal_init_page (struct grub_term_output *term,
+ int y)
+{
+ grub_ssize_t msg_len;
+ int posx;
+ char *msg_formatted;
+ grub_uint32_t *unicode_msg;
+ grub_uint32_t *last_position;
+
+ grub_term_cls (term);
+
+ msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION);
+ if (!msg_formatted)
+ return;
+
+ msg_len = grub_utf8_to_ucs4_alloc (msg_formatted,
+ &unicode_msg, &last_position);
+ grub_free (msg_formatted);
+
+ if (msg_len < 0)
+ {
+ return;
+ }
+
+ posx = grub_getstringwidth (unicode_msg, last_position, term);
+ posx = ((int) grub_term_width (term) - posx) / 2;
+ if (posx < 0)
+ posx = 0;
+ grub_term_gotoxy (term, (struct grub_term_coordinate) { posx, y });
+
+ grub_print_ucs4 (unicode_msg, last_position, 0, 0, term);
+ grub_putcode ('\n', term);
+ grub_putcode ('\n', term);
+ grub_free (unicode_msg);
+}
+
+static void
+read_lists (const char *val)
+{
+ if (! grub_no_modules)
+ {
+ read_command_list (val);
+ read_fs_list (val);
+ read_crypto_list (val);
+ read_terminal_list (val);
+ }
+ grub_gettext_reread_prefix (val);
+}
+
+static char *
+read_lists_hook (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val)
+{
+ read_lists (val);
+ return val ? grub_strdup (val) : NULL;
+}
+
+/* Read the config file CONFIG and execute the menu interface or
+ the command line interface if BATCH is false. */
+void
+grub_normal_execute (const char *config, int nested, int batch)
+{
+ grub_menu_t menu = 0;
+ const char *prefix;
+
+ if (! nested)
+ {
+ prefix = grub_env_get ("prefix");
+ read_lists (prefix);
+ grub_register_variable_hook ("prefix", NULL, read_lists_hook);
+ }
+
+ grub_boot_time ("Executing config file");
+
+ if (config)
+ {
+ menu = read_config_file (config);
+
+ /* Ignore any error. */
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ grub_boot_time ("Executed config file");
+
+ if (! batch)
+ {
+ if (menu && menu->size)
+ {
+
+ grub_boot_time ("Entering menu");
+ grub_show_menu (menu, nested, 0);
+ if (nested)
+ grub_normal_free_menu (menu);
+ }
+ }
+}
+
+/* This starts the normal mode. */
+void
+grub_enter_normal_mode (const char *config)
+{
+ grub_boot_time ("Entering normal mode");
+ nested_level++;
+ grub_normal_execute (config, 0, 0);
+ grub_boot_time ("Entering shell");
+ grub_cmdline_run (0, 1);
+ nested_level--;
+ if (grub_normal_exit_level)
+ grub_normal_exit_level--;
+ grub_boot_time ("Exiting normal mode");
+}
+
+/* Enter normal mode from rescue mode. */
+static grub_err_t
+grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ if (argc == 0)
+ {
+ /* Guess the config filename. It is necessary to make CONFIG static,
+ so that it won't get broken by longjmp. */
+ char *config;
+ const char *prefix;
+
+ prefix = grub_env_get ("prefix");
+ if (prefix)
+ {
+ grub_size_t config_len;
+ int disable_net_search = 0;
+ const char *net_search_cfg;
+
+ config_len = grub_strlen (prefix) +
+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
+ config = grub_malloc (config_len);
+
+ if (!config)
+ goto quit;
+
+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
+
+ net_search_cfg = grub_env_get ("feature_net_search_cfg");
+ if (net_search_cfg && net_search_cfg[0] == 'n')
+ disable_net_search = 1;
+
+ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 &&
+ !disable_net_search)
+ grub_net_search_config_file (config);
+
+ grub_enter_normal_mode (config);
+ grub_free (config);
+ }
+ else
+ grub_enter_normal_mode (0);
+ }
+ else
+ grub_enter_normal_mode (argv[0]);
+
+quit:
+ return 0;
+}
+
+/* Exit from normal mode to rescue mode. */
+static grub_err_t
+grub_cmd_normal_exit (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ if (nested_level <= grub_normal_exit_level)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "not in normal environment");
+ grub_normal_exit_level++;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_normal_reader_init (int nested)
+{
+ struct grub_term_output *term;
+ const char *msg_esc = _("ESC at any time exits.");
+ char *msg_formatted;
+
+ 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;
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ grub_normal_init_page (term, 1);
+ grub_term_setcursor (term, 1);
+
+ if (grub_term_width (term) > 3 + STANDARD_MARGIN + 20)
+ grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN, term);
+ else
+ grub_print_message_indented (msg_formatted, 0, 0, term);
+ grub_putcode ('\n', term);
+ grub_putcode ('\n', term);
+ grub_putcode ('\n', term);
+ }
+ grub_free (msg_formatted);
+
+ return 0;
+}
+
+static grub_err_t
+grub_normal_read_line_real (char **line, int cont, int nested)
+{
+ const char *prompt;
+
+ if (cont)
+ /* TRANSLATORS: it's command line prompt. */
+ prompt = _(">");
+ else
+ /* TRANSLATORS: it's command line prompt. */
+ prompt = _("grub>");
+
+ if (!prompt)
+ return grub_errno;
+
+ while (1)
+ {
+ *line = grub_cmdline_get (prompt);
+ if (*line)
+ return 0;
+
+ if (cont || nested)
+ {
+ grub_free (*line);
+ *line = 0;
+ return grub_errno;
+ }
+ }
+
+}
+
+static grub_err_t
+grub_normal_read_line (char **line, int cont,
+ void *data __attribute__ ((unused)))
+{
+ return grub_normal_read_line_real (line, cont, 0);
+}
+
+void
+grub_cmdline_run (int nested, int force_auth)
+{
+ grub_err_t err = GRUB_ERR_NONE;
+
+ do
+ {
+ err = grub_auth_check_authentication (NULL);
+ }
+ while (err && force_auth);
+
+ if (err)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ grub_normal_reader_init (nested);
+
+ while (1)
+ {
+ char *line = NULL;
+
+ if (grub_normal_exit_level)
+ break;
+
+ /* Print an error, if any. */
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+
+ grub_normal_read_line_real (&line, 0, nested);
+ if (! line)
+ break;
+
+ grub_normal_parse_line (line, grub_normal_read_line, NULL);
+ grub_free (line);
+ }
+}
+
+static char *
+grub_env_write_pager (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val)
+{
+ grub_set_more ((*val == '1'));
+ return grub_strdup (val);
+}
+
+/* clear */
+static grub_err_t
+grub_mini_cmd_clear (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ grub_cls ();
+ return 0;
+}
+
+static grub_command_t cmd_clear;
+
+static void (*grub_xputs_saved) (const char *str);
+static const char *features[] = {
+ "feature_chainloader_bpb", "feature_ntldr", "feature_platform_search_hint",
+ "feature_default_font_path", "feature_all_video_module",
+ "feature_menuentry_id", "feature_menuentry_options", "feature_200_final",
+ "feature_nativedisk_cmd", "feature_timeout_style"
+};
+
+GRUB_MOD_INIT(normal)
+{
+ unsigned i;
+
+ grub_boot_time ("Preparing normal module");
+
+ /* Previously many modules depended on gzio. Be nice to user and load it. */
+ grub_dl_load ("gzio");
+ grub_errno = 0;
+
+ grub_normal_auth_init ();
+ grub_context_init ();
+ grub_script_init ();
+ grub_menu_init ();
+
+ grub_xputs_saved = grub_xputs;
+ grub_xputs = grub_xputs_normal;
+
+ /* Normal mode shouldn't be unloaded. */
+ if (mod)
+ grub_dl_ref (mod);
+
+ cmd_clear =
+ grub_register_command ("clear", grub_mini_cmd_clear,
+ 0, N_("Clear the screen."));
+
+ grub_set_history (GRUB_DEFAULT_HISTORY_SIZE);
+
+ grub_register_variable_hook ("pager", 0, grub_env_write_pager);
+ grub_env_export ("pager");
+
+ /* Register a command "normal" for the rescue mode. */
+ grub_register_command ("normal", grub_cmd_normal,
+ 0, N_("Enter normal mode."));
+ grub_register_command ("normal_exit", grub_cmd_normal_exit,
+ 0, N_("Exit from normal mode."));
+
+ /* Reload terminal colors when these variables are written to. */
+ grub_register_variable_hook ("color_normal", NULL, grub_env_write_color_normal);
+ grub_register_variable_hook ("color_highlight", NULL, grub_env_write_color_highlight);
+
+ /* Preserve hooks after context changes. */
+ grub_env_export ("color_normal");
+ grub_env_export ("color_highlight");
+
+ /* Set default color names. */
+ grub_env_set ("color_normal", "light-gray/black");
+ grub_env_set ("color_highlight", "black/light-gray");
+
+ for (i = 0; i < ARRAY_SIZE (features); i++)
+ {
+ grub_env_set (features[i], "y");
+ grub_env_export (features[i]);
+ }
+ grub_env_set ("grub_cpu", GRUB_TARGET_CPU);
+ grub_env_export ("grub_cpu");
+ grub_env_set ("grub_platform", GRUB_PLATFORM);
+ grub_env_export ("grub_platform");
+
+ grub_boot_time ("Normal module prepared");
+}
+
+GRUB_MOD_FINI(normal)
+{
+ grub_context_fini ();
+ grub_script_fini ();
+ grub_menu_fini ();
+ grub_normal_auth_fini ();
+
+ grub_xputs = grub_xputs_saved;
+
+ grub_set_history (0);
+ grub_register_variable_hook ("pager", 0, 0);
+ grub_fs_autoload_hook = 0;
+ grub_unregister_command (cmd_clear);
+}
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
new file mode 100644
index 0000000..8397886
--- /dev/null
+++ b/grub-core/normal/menu.c
@@ -0,0 +1,912 @@
+/* menu.c - General supporting functionality for menus. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/misc.h>
+#include <grub/loader.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/env.h>
+#include <grub/menu_viewer.h>
+#include <grub/command.h>
+#include <grub/parser.h>
+#include <grub/auth.h>
+#include <grub/i18n.h>
+#include <grub/term.h>
+#include <grub/script_sh.h>
+#include <grub/gfxterm.h>
+#include <grub/dl.h>
+
+/* Time to delay after displaying an error message about a default/fallback
+ entry failing to boot. */
+#define DEFAULT_ENTRY_ERROR_DELAY_MS 2500
+
+grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu,
+ int nested) = NULL;
+
+enum timeout_style {
+ TIMEOUT_STYLE_MENU,
+ TIMEOUT_STYLE_COUNTDOWN,
+ TIMEOUT_STYLE_HIDDEN
+};
+
+struct timeout_style_name {
+ const char *name;
+ enum timeout_style style;
+} timeout_style_names[] = {
+ {"menu", TIMEOUT_STYLE_MENU},
+ {"countdown", TIMEOUT_STYLE_COUNTDOWN},
+ {"hidden", TIMEOUT_STYLE_HIDDEN},
+ {NULL, 0}
+};
+
+/* Wait until the user pushes any key so that the user
+ can see what happened. */
+void
+grub_wait_after_message (void)
+{
+ grub_uint64_t endtime;
+ grub_xputs ("\n");
+ grub_printf_ (N_("Press any key to continue..."));
+ grub_refresh ();
+
+ endtime = grub_get_time_ms () + 10000;
+
+ while (grub_get_time_ms () < endtime
+ && grub_getkey_noblock () == GRUB_TERM_NO_KEY);
+
+ grub_xputs ("\n");
+}
+
+/* Get a menu entry by its index in the entry list. */
+grub_menu_entry_t
+grub_menu_get_entry (grub_menu_t menu, int no)
+{
+ grub_menu_entry_t e;
+
+ for (e = menu->entry_list; e && no > 0; e = e->next, no--)
+ ;
+
+ return e;
+}
+
+/* Get the index of a menu entry associated with a given hotkey, or -1. */
+static int
+get_entry_index_by_hotkey (grub_menu_t menu, int hotkey)
+{
+ grub_menu_entry_t entry;
+ int i;
+
+ for (i = 0, entry = menu->entry_list; i < menu->size;
+ i++, entry = entry->next)
+ if (entry->hotkey == hotkey)
+ return i;
+
+ return -1;
+}
+
+/* Return the timeout style. If the variable "timeout_style" is not set or
+ invalid, default to TIMEOUT_STYLE_MENU. */
+static enum timeout_style
+get_timeout_style (void)
+{
+ const char *val;
+ struct timeout_style_name *style_name;
+
+ val = grub_env_get ("timeout_style");
+ if (!val)
+ return TIMEOUT_STYLE_MENU;
+
+ for (style_name = timeout_style_names; style_name->name; style_name++)
+ if (grub_strcmp (style_name->name, val) == 0)
+ return style_name->style;
+
+ return TIMEOUT_STYLE_MENU;
+}
+
+/* Return the current timeout. If the variable "timeout" is not set or
+ invalid, return -1. */
+int
+grub_menu_get_timeout (void)
+{
+ const char *val;
+ int timeout;
+
+ val = grub_env_get ("timeout");
+ if (! val)
+ return -1;
+
+ grub_error_push ();
+
+ timeout = (int) grub_strtoul (val, 0, 0);
+
+ /* If the value is invalid, unset the variable. */
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_env_unset ("timeout");
+ grub_errno = GRUB_ERR_NONE;
+ timeout = -1;
+ }
+
+ grub_error_pop ();
+
+ return timeout;
+}
+
+/* Set current timeout in the variable "timeout". */
+void
+grub_menu_set_timeout (int timeout)
+{
+ /* Ignore TIMEOUT if it is zero, because it will be unset really soon. */
+ if (timeout > 0)
+ {
+ char buf[16];
+
+ grub_snprintf (buf, sizeof (buf), "%d", timeout);
+ grub_env_set ("timeout", buf);
+ }
+}
+
+/* Get the first entry number from the value of the environment variable NAME,
+ which is a space-separated list of non-negative integers. The entry number
+ which is returned is stripped from the value of NAME. If no entry number
+ can be found, -1 is returned. */
+static int
+get_and_remove_first_entry_number (const char *name)
+{
+ const char *val, *tail;
+ int entry;
+
+ val = grub_env_get (name);
+ if (! val)
+ return -1;
+
+ grub_error_push ();
+
+ entry = (int) grub_strtoul (val, &tail, 0);
+
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ /* Skip whitespace to find the next digit. */
+ while (*tail && grub_isspace (*tail))
+ tail++;
+ grub_env_set (name, tail);
+ }
+ else
+ {
+ grub_env_unset (name);
+ grub_errno = GRUB_ERR_NONE;
+ entry = -1;
+ }
+
+ grub_error_pop ();
+
+ return entry;
+}
+
+/* Run a menu entry. */
+static void
+grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
+{
+ grub_err_t err = GRUB_ERR_NONE;
+ int errs_before;
+ grub_menu_t menu = NULL;
+ char *optr, *buf, *oldchosen = NULL, *olddefault = NULL;
+ const char *ptr, *chosen, *def;
+ grub_size_t sz = 0;
+
+ if (entry->restricted)
+ err = grub_auth_check_authentication (entry->users);
+
+ if (err)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ errs_before = grub_err_printed_errors;
+
+ chosen = grub_env_get ("chosen");
+ def = grub_env_get ("default");
+
+ if (entry->submenu)
+ {
+ grub_env_context_open ();
+ menu = grub_zalloc (sizeof (*menu));
+ if (! menu)
+ return;
+ grub_env_set_menu (menu);
+ if (auto_boot)
+ grub_env_set ("timeout", "0");
+ }
+
+ for (ptr = entry->id; *ptr; ptr++)
+ sz += (*ptr == '>') ? 2 : 1;
+ if (chosen)
+ {
+ oldchosen = grub_strdup (chosen);
+ if (!oldchosen)
+ grub_print_error ();
+ }
+ if (def)
+ {
+ olddefault = grub_strdup (def);
+ if (!olddefault)
+ grub_print_error ();
+ }
+ sz++;
+ if (chosen)
+ sz += grub_strlen (chosen);
+ sz++;
+ buf = grub_malloc (sz);
+ if (!buf)
+ grub_print_error ();
+ else
+ {
+ optr = buf;
+ if (chosen)
+ {
+ optr = grub_stpcpy (optr, chosen);
+ *optr++ = '>';
+ }
+ for (ptr = entry->id; *ptr; ptr++)
+ {
+ if (*ptr == '>')
+ *optr++ = '>';
+ *optr++ = *ptr;
+ }
+ *optr = 0;
+ grub_env_set ("chosen", buf);
+ grub_env_export ("chosen");
+ grub_free (buf);
+ }
+
+ for (ptr = def; ptr && *ptr; ptr++)
+ {
+ if (ptr[0] == '>' && ptr[1] == '>')
+ {
+ ptr++;
+ continue;
+ }
+ if (ptr[0] == '>')
+ break;
+ }
+
+ if (ptr && ptr[0] && ptr[1])
+ grub_env_set ("default", ptr + 1);
+ else
+ grub_env_unset ("default");
+
+ grub_script_execute_new_scope (entry->sourcecode, entry->argc, entry->args);
+
+ if (errs_before != grub_err_printed_errors)
+ grub_wait_after_message ();
+
+ errs_before = grub_err_printed_errors;
+
+ if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
+ /* Implicit execution of boot, only if something is loaded. */
+ grub_command_execute ("boot", 0, 0);
+
+ if (errs_before != grub_err_printed_errors)
+ grub_wait_after_message ();
+
+ if (entry->submenu)
+ {
+ if (menu && menu->size)
+ {
+ grub_show_menu (menu, 1, auto_boot);
+ grub_normal_free_menu (menu);
+ }
+ grub_env_context_close ();
+ }
+ if (oldchosen)
+ grub_env_set ("chosen", oldchosen);
+ else
+ grub_env_unset ("chosen");
+ if (olddefault)
+ grub_env_set ("default", olddefault);
+ else
+ grub_env_unset ("default");
+ grub_env_unset ("timeout");
+}
+
+/* Execute ENTRY from the menu MENU, falling back to entries specified
+ in the environment variable "fallback" if it fails. CALLBACK is a
+ pointer to a struct of function pointers which are used to allow the
+ caller provide feedback to the user. */
+static void
+grub_menu_execute_with_fallback (grub_menu_t menu,
+ grub_menu_entry_t entry,
+ int autobooted,
+ grub_menu_execute_callback_t callback,
+ void *callback_data)
+{
+ int fallback_entry;
+
+ callback->notify_booting (entry, callback_data);
+
+ grub_menu_execute_entry (entry, 1);
+
+ /* Deal with fallback entries. */
+ while ((fallback_entry = get_and_remove_first_entry_number ("fallback"))
+ >= 0)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+
+ entry = grub_menu_get_entry (menu, fallback_entry);
+ callback->notify_fallback (entry, callback_data);
+ grub_menu_execute_entry (entry, 1);
+ /* If the function call to execute the entry returns at all, then this is
+ taken to indicate a boot failure. For menu entries that do something
+ other than actually boot an operating system, this could assume
+ incorrectly that something failed. */
+ }
+
+ if (!autobooted)
+ callback->notify_failure (callback_data);
+}
+
+static struct grub_menu_viewer *viewers;
+
+static void
+menu_set_chosen_entry (int entry)
+{
+ struct grub_menu_viewer *cur;
+ for (cur = viewers; cur; cur = cur->next)
+ cur->set_chosen_entry (entry, cur->data);
+}
+
+static void
+menu_print_timeout (int timeout)
+{
+ struct grub_menu_viewer *cur;
+ for (cur = viewers; cur; cur = cur->next)
+ cur->print_timeout (timeout, cur->data);
+}
+
+static void
+menu_fini (void)
+{
+ struct grub_menu_viewer *cur, *next;
+ for (cur = viewers; cur; cur = next)
+ {
+ next = cur->next;
+ cur->fini (cur->data);
+ grub_free (cur);
+ }
+ viewers = NULL;
+}
+
+static void
+menu_init (int entry, grub_menu_t menu, int nested)
+{
+ struct grub_term_output *term;
+ int gfxmenu = 0;
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ if (term->fullscreen)
+ {
+ if (grub_env_get ("theme"))
+ {
+ if (!grub_gfxmenu_try_hook)
+ {
+ grub_dl_load ("gfxmenu");
+ grub_print_error ();
+ }
+ if (grub_gfxmenu_try_hook)
+ {
+ grub_err_t err;
+ err = grub_gfxmenu_try_hook (entry, menu, nested);
+ if(!err)
+ {
+ gfxmenu = 1;
+ break;
+ }
+ }
+ else
+ grub_error (GRUB_ERR_BAD_MODULE,
+ N_("module `%s' isn't loaded"),
+ "gfxmenu");
+ grub_print_error ();
+ grub_wait_after_message ();
+ }
+ grub_errno = GRUB_ERR_NONE;
+ term->fullscreen ();
+ break;
+ }
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ grub_err_t err;
+
+ if (grub_strcmp (term->name, "gfxterm") == 0 && gfxmenu)
+ continue;
+
+ err = grub_menu_try_text (term, entry, menu, nested);
+ if(!err)
+ continue;
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+}
+
+static void
+clear_timeout (void)
+{
+ struct grub_menu_viewer *cur;
+ for (cur = viewers; cur; cur = cur->next)
+ cur->clear_timeout (cur->data);
+}
+
+void
+grub_menu_register_viewer (struct grub_menu_viewer *viewer)
+{
+ viewer->next = viewers;
+ viewers = viewer;
+}
+
+static int
+menuentry_eq (const char *id, const char *spec)
+{
+ const char *ptr1, *ptr2;
+ ptr1 = id;
+ ptr2 = spec;
+ while (1)
+ {
+ if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0)
+ return 1;
+ if (*ptr2 == '>' && ptr2[1] != '>')
+ return 0;
+ if (*ptr2 == '>')
+ ptr2++;
+ if (*ptr1 != *ptr2)
+ return 0;
+ if (*ptr1 == 0)
+ return 1;
+ ptr1++;
+ ptr2++;
+ }
+}
+
+
+/* Get the entry number from the variable NAME. */
+static int
+get_entry_number (grub_menu_t menu, const char *name)
+{
+ const char *val;
+ int entry;
+
+ val = grub_env_get (name);
+ if (! val)
+ return -1;
+
+ grub_error_push ();
+
+ entry = (int) grub_strtoul (val, 0, 0);
+
+ if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ {
+ /* See if the variable matches the title of a menu entry. */
+ grub_menu_entry_t e = menu->entry_list;
+ int i;
+
+ grub_errno = GRUB_ERR_NONE;
+
+ for (i = 0; e; i++)
+ {
+ if (menuentry_eq (e->title, val)
+ || menuentry_eq (e->id, val))
+ {
+ entry = i;
+ break;
+ }
+ e = e->next;
+ }
+
+ if (! e)
+ entry = -1;
+ }
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ entry = -1;
+ }
+
+ grub_error_pop ();
+
+ return entry;
+}
+
+/* Check whether a second has elapsed since the last tick. If so, adjust
+ the timer and return 1; otherwise, return 0. */
+static int
+has_second_elapsed (grub_uint64_t *saved_time)
+{
+ grub_uint64_t current_time;
+
+ current_time = grub_get_time_ms ();
+ if (current_time - *saved_time >= 1000)
+ {
+ *saved_time = current_time;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+static void
+print_countdown (struct grub_term_coordinate *pos, int n)
+{
+ grub_term_restore_pos (pos);
+ /* NOTE: Do not remove the trailing space characters.
+ They are required to clear the line. */
+ grub_printf ("%d ", n);
+ grub_refresh ();
+}
+
+#define GRUB_MENU_PAGE_SIZE 10
+
+/* Show the menu and handle menu entry selection. Returns the menu entry
+ index that should be executed or -1 if no entry should be executed (e.g.,
+ Esc pressed to exit a sub-menu or switching menu viewers).
+ If the return value is not -1, then *AUTO_BOOT is nonzero iff the menu
+ entry to be executed is a result of an automatic default selection because
+ of the timeout. */
+static int
+run_menu (grub_menu_t menu, int nested, int *auto_boot)
+{
+ grub_uint64_t saved_time;
+ int default_entry, current_entry;
+ int timeout;
+ enum timeout_style timeout_style;
+
+ default_entry = get_entry_number (menu, "default");
+
+ /* If DEFAULT_ENTRY is not within the menu entries, fall back to
+ the first entry. */
+ if (default_entry < 0 || default_entry >= menu->size)
+ default_entry = 0;
+
+ timeout = grub_menu_get_timeout ();
+ if (timeout < 0)
+ /* If there is no timeout, the "countdown" and "hidden" styles result in
+ the system doing nothing and providing no or very little indication
+ why. Technically this is what the user asked for, but it's not very
+ useful and likely to be a source of confusion, so we disallow this. */
+ grub_env_unset ("timeout_style");
+
+ timeout_style = get_timeout_style ();
+
+ if (timeout_style == TIMEOUT_STYLE_COUNTDOWN
+ || timeout_style == TIMEOUT_STYLE_HIDDEN)
+ {
+ static struct grub_term_coordinate *pos;
+ int entry = -1;
+
+ if (timeout_style == TIMEOUT_STYLE_COUNTDOWN && timeout)
+ {
+ pos = grub_term_save_pos ();
+ print_countdown (pos, timeout);
+ }
+
+ /* Enter interruptible sleep until Escape or a menu hotkey is pressed,
+ or the timeout expires. */
+ saved_time = grub_get_time_ms ();
+ while (1)
+ {
+ int key;
+
+ key = grub_getkey_noblock ();
+ if (key != GRUB_TERM_NO_KEY)
+ {
+ entry = get_entry_index_by_hotkey (menu, key);
+ if (entry >= 0)
+ break;
+ }
+ if (grub_key_is_interrupt (key))
+ {
+ timeout = -1;
+ break;
+ }
+
+ if (timeout > 0 && has_second_elapsed (&saved_time))
+ {
+ timeout--;
+ if (timeout_style == TIMEOUT_STYLE_COUNTDOWN)
+ print_countdown (pos, timeout);
+ }
+
+ if (timeout == 0)
+ /* We will fall through to auto-booting the default entry. */
+ break;
+ }
+
+ grub_env_unset ("timeout");
+ grub_env_unset ("timeout_style");
+ if (entry >= 0)
+ {
+ *auto_boot = 0;
+ return entry;
+ }
+ }
+
+ /* If timeout is 0, drawing is pointless (and ugly). */
+ if (timeout == 0)
+ {
+ *auto_boot = 1;
+ return default_entry;
+ }
+
+ current_entry = default_entry;
+
+ refresh:
+ menu_init (current_entry, menu, nested);
+
+ /* Initialize the time. */
+ saved_time = grub_get_time_ms ();
+
+ timeout = grub_menu_get_timeout ();
+
+ if (timeout > 0)
+ menu_print_timeout (timeout);
+ else
+ clear_timeout ();
+
+ while (1)
+ {
+ int c;
+ timeout = grub_menu_get_timeout ();
+
+ if (grub_normal_exit_level)
+ return -1;
+
+ if (timeout > 0 && has_second_elapsed (&saved_time))
+ {
+ timeout--;
+ grub_menu_set_timeout (timeout);
+ menu_print_timeout (timeout);
+ }
+
+ if (timeout == 0)
+ {
+ grub_env_unset ("timeout");
+ *auto_boot = 1;
+ menu_fini ();
+ return default_entry;
+ }
+
+ c = grub_getkey_noblock ();
+
+ /* Negative values are returned on error. */
+ if ((c != GRUB_TERM_NO_KEY) && (c > 0))
+ {
+ if (timeout >= 0)
+ {
+ grub_env_unset ("timeout");
+ grub_env_unset ("fallback");
+ clear_timeout ();
+ }
+
+ switch (c)
+ {
+ case GRUB_TERM_KEY_HOME:
+ case GRUB_TERM_CTRL | 'a':
+ current_entry = 0;
+ menu_set_chosen_entry (current_entry);
+ break;
+
+ case GRUB_TERM_KEY_END:
+ case GRUB_TERM_CTRL | 'e':
+ current_entry = menu->size - 1;
+ menu_set_chosen_entry (current_entry);
+ break;
+
+ case GRUB_TERM_KEY_UP:
+ case GRUB_TERM_CTRL | 'p':
+ case '^':
+ if (current_entry > 0)
+ current_entry--;
+ menu_set_chosen_entry (current_entry);
+ break;
+
+ case GRUB_TERM_CTRL | 'n':
+ case GRUB_TERM_KEY_DOWN:
+ case 'v':
+ if (current_entry < menu->size - 1)
+ current_entry++;
+ menu_set_chosen_entry (current_entry);
+ break;
+
+ case GRUB_TERM_CTRL | 'g':
+ case GRUB_TERM_KEY_PPAGE:
+ if (current_entry < GRUB_MENU_PAGE_SIZE)
+ current_entry = 0;
+ else
+ current_entry -= GRUB_MENU_PAGE_SIZE;
+ menu_set_chosen_entry (current_entry);
+ break;
+
+ case GRUB_TERM_CTRL | 'c':
+ case GRUB_TERM_KEY_NPAGE:
+ if (current_entry + GRUB_MENU_PAGE_SIZE < menu->size)
+ current_entry += GRUB_MENU_PAGE_SIZE;
+ else
+ current_entry = menu->size - 1;
+ menu_set_chosen_entry (current_entry);
+ break;
+
+ case '\n':
+ case '\r':
+ case GRUB_TERM_KEY_RIGHT:
+ case GRUB_TERM_CTRL | 'f':
+ menu_fini ();
+ *auto_boot = 0;
+ return current_entry;
+
+ case GRUB_TERM_ESC:
+ if (nested)
+ {
+ menu_fini ();
+ return -1;
+ }
+ break;
+
+ case 'c':
+ menu_fini ();
+ grub_cmdline_run (1, 0);
+ goto refresh;
+
+ case 'e':
+ menu_fini ();
+ {
+ grub_menu_entry_t e = grub_menu_get_entry (menu, current_entry);
+ if (e)
+ grub_menu_entry_run (e);
+ }
+ goto refresh;
+
+ default:
+ {
+ int entry;
+
+ entry = get_entry_index_by_hotkey (menu, c);
+ if (entry >= 0)
+ {
+ menu_fini ();
+ *auto_boot = 0;
+ return entry;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /* Never reach here. */
+}
+
+/* Callback invoked immediately before a menu entry is executed. */
+static void
+notify_booting (grub_menu_entry_t entry,
+ void *userdata __attribute__((unused)))
+{
+ grub_printf (" ");
+ grub_printf_ (N_("Booting `%s'"), entry->title);
+ grub_printf ("\n\n");
+}
+
+/* Callback invoked when a default menu entry executed because of a timeout
+ has failed and an attempt will be made to execute the next fallback
+ entry, ENTRY. */
+static void
+notify_fallback (grub_menu_entry_t entry,
+ void *userdata __attribute__((unused)))
+{
+ grub_printf ("\n ");
+ grub_printf_ (N_("Falling back to `%s'"), entry->title);
+ grub_printf ("\n\n");
+ grub_millisleep (DEFAULT_ENTRY_ERROR_DELAY_MS);
+}
+
+/* Callback invoked when a menu entry has failed and there is no remaining
+ fallback entry to attempt. */
+static void
+notify_execution_failure (void *userdata __attribute__((unused)))
+{
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ }
+ grub_printf ("\n ");
+ grub_printf_ (N_("Failed to boot both default and fallback entries.\n"));
+ grub_wait_after_message ();
+}
+
+/* Callbacks used by the text menu to provide user feedback when menu entries
+ are executed. */
+static struct grub_menu_execute_callback execution_callback =
+{
+ .notify_booting = notify_booting,
+ .notify_fallback = notify_fallback,
+ .notify_failure = notify_execution_failure
+};
+
+static grub_err_t
+show_menu (grub_menu_t menu, int nested, int autobooted)
+{
+ while (1)
+ {
+ int boot_entry;
+ grub_menu_entry_t e;
+ int auto_boot;
+
+ boot_entry = run_menu (menu, nested, &auto_boot);
+ if (boot_entry < 0)
+ break;
+
+ e = grub_menu_get_entry (menu, boot_entry);
+ if (! e)
+ continue; /* Menu is empty. */
+
+ grub_cls ();
+
+ if (auto_boot)
+ grub_menu_execute_with_fallback (menu, e, autobooted,
+ &execution_callback, 0);
+ else
+ grub_menu_execute_entry (e, 0);
+ if (autobooted)
+ break;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_show_menu (grub_menu_t menu, int nested, int autoboot)
+{
+ grub_err_t err1, err2;
+
+ while (1)
+ {
+ err1 = show_menu (menu, nested, autoboot);
+ autoboot = 0;
+ grub_print_error ();
+
+ if (grub_normal_exit_level)
+ break;
+
+ err2 = grub_auth_check_authentication (NULL);
+ if (err2)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ break;
+ }
+
+ return err1;
+}
diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
new file mode 100644
index 0000000..50eef91
--- /dev/null
+++ b/grub-core/normal/menu_entry.c
@@ -0,0 +1,1460 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/loader.h>
+#include <grub/command.h>
+#include <grub/parser.h>
+#include <grub/script_sh.h>
+#include <grub/auth.h>
+#include <grub/i18n.h>
+#include <grub/charset.h>
+#include <grub/safemath.h>
+
+enum update_mode
+ {
+ NO_LINE,
+ SINGLE_LINE,
+ ALL_LINES
+ };
+
+struct line
+{
+ /* The line buffer. */
+ grub_uint32_t *buf;
+ /* The length of the line. */
+ int len;
+ /* The maximum length of the line. */
+ int max_len;
+ struct grub_term_pos **pos;
+};
+
+struct per_term_screen
+{
+ struct grub_term_output *term;
+ int y_line_start;
+ struct grub_term_screen_geometry geo;
+ /* Scratch variables used when updating. Having them here avoids
+ loads of small mallocs. */
+ int orig_num;
+ int down;
+ enum update_mode mode;
+};
+
+struct screen
+{
+ /* The array of lines. */
+ struct line *lines;
+ /* The number of lines. */
+ int num_lines;
+ /* The current column. */
+ int column;
+ /* The real column. */
+ int real_column;
+ /* The current line. */
+ int line;
+ /* The kill buffer. */
+ char *killed_text;
+ /* The flag of a completion window. */
+ int completion_shown;
+
+ int submenu;
+
+ struct per_term_screen *terms;
+ unsigned nterms;
+};
+
+/* Used for storing completion items temporarily. */
+static struct {
+ char *buf;
+ grub_size_t len;
+ grub_size_t max_len;
+} completion_buffer;
+static int completion_type;
+
+/* Initialize a line. */
+static int
+init_line (struct screen *screen, struct line *linep)
+{
+ linep->len = 0;
+ linep->max_len = 80;
+ linep->buf = grub_calloc (linep->max_len + 1, sizeof (linep->buf[0]));
+ linep->pos = grub_calloc (screen->nterms, sizeof (linep->pos[0]));
+ if (! linep->buf || !linep->pos)
+ {
+ grub_free (linep->buf);
+ grub_free (linep->pos);
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Allocate extra space if necessary. */
+static int
+ensure_space (struct line *linep, int extra)
+{
+ if (linep->max_len < linep->len + extra)
+ {
+ grub_size_t sz0, sz1;
+
+ if (grub_add (linep->len, extra, &sz0) ||
+ grub_mul (sz0, 2, &sz0) ||
+ grub_add (sz0, 1, &sz1) ||
+ grub_mul (sz1, sizeof (linep->buf[0]), &sz1))
+ return 0;
+
+ linep->buf = grub_realloc (linep->buf, sz1);
+ if (! linep->buf)
+ return 0;
+ linep->max_len = sz0;
+ }
+
+ return 1;
+}
+
+/* Return the number of lines occupied by this line on the screen. */
+static int
+get_logical_num_lines (struct line *linep, struct per_term_screen *term_screen)
+{
+ 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
+advance_to (struct screen *screen, int c)
+{
+ if (c > screen->lines[screen->line].len)
+ c = screen->lines[screen->line].len;
+
+ screen->column = grub_unicode_get_comb_end (screen->lines[screen->line].buf
+ + screen->lines[screen->line].len,
+ screen->lines[screen->line].buf
+ + c)
+ - screen->lines[screen->line].buf;
+}
+
+/* Print an empty line. */
+static void
+print_empty_line (int y, struct per_term_screen *term_screen)
+{
+ int i;
+
+ grub_term_gotoxy (term_screen->term,
+ (struct grub_term_coordinate) { term_screen->geo.first_entry_x,
+ y + term_screen->geo.first_entry_y });
+
+ for (i = 0; i < term_screen->geo.entry_width + 1; i++)
+ grub_putcode (' ', term_screen->term);
+}
+
+static void
+print_updown (int upflag, int downflag, struct per_term_screen *term_screen)
+{
+ grub_term_gotoxy (term_screen->term,
+ (struct grub_term_coordinate) { term_screen->geo.first_entry_x
+ + term_screen->geo.entry_width + 1
+ + term_screen->geo.border,
+ term_screen->geo.first_entry_y });
+
+ if (upflag && downflag)
+ grub_putcode (GRUB_UNICODE_UPDOWNARROW, term_screen->term);
+ else if (upflag)
+ grub_putcode (GRUB_UNICODE_UPARROW, term_screen->term);
+ else if (downflag)
+ grub_putcode (GRUB_UNICODE_DOWNARROW, term_screen->term);
+ else
+ grub_putcode (' ', term_screen->term);
+}
+
+/* Print an up arrow. */
+static void
+print_up (int flag, struct per_term_screen *term_screen)
+{
+ grub_term_gotoxy (term_screen->term,
+ (struct grub_term_coordinate) { term_screen->geo.first_entry_x
+ + term_screen->geo.entry_width + 1
+ + term_screen->geo.border,
+ term_screen->geo.first_entry_y });
+
+ if (flag)
+ grub_putcode (GRUB_UNICODE_UPARROW, term_screen->term);
+ else
+ grub_putcode (' ', term_screen->term);
+}
+
+/* Print a down arrow. */
+static void
+print_down (int flag, struct per_term_screen *term_screen)
+{
+ grub_term_gotoxy (term_screen->term,
+ (struct grub_term_coordinate) { term_screen->geo.first_entry_x
+ + term_screen->geo.entry_width + 1
+ + term_screen->geo.border,
+ term_screen->geo.first_entry_y
+ + term_screen->geo.num_entries - 1 });
+
+ if (flag)
+ grub_putcode (GRUB_UNICODE_DOWNARROW, term_screen->term);
+ else
+ grub_putcode (' ', term_screen->term);
+}
+
+/* Draw the lines of the screen SCREEN. */
+static void
+update_screen (struct screen *screen, struct per_term_screen *term_screen,
+ int region_start, int region_column __attribute__ ((unused)),
+ int up, int down, enum update_mode mode)
+{
+ int up_flag = 0;
+ int down_flag = 0;
+ int y;
+ int i;
+ struct line *linep;
+
+ y = term_screen->y_line_start;
+ linep = screen->lines;
+
+ for (i = 0; i < screen->line; i++, linep++)
+ y += get_logical_num_lines (linep, term_screen);
+ linep = screen->lines + screen->line;
+ grub_size_t t = grub_getstringwidth (linep->buf, linep->buf + screen->column,
+ term_screen->term);
+ y += t / (unsigned) term_screen->geo.entry_width;
+ if (t % (unsigned) term_screen->geo.entry_width == 0
+ && t != 0 && screen->column == linep->len)
+ y--;
+ /* Check if scrolling is necessary. */
+ if (y < 0 || y >= term_screen->geo.num_entries)
+ {
+ int delta;
+ if (y < 0)
+ delta = -y;
+ else
+ delta = term_screen->geo.num_entries - 1 - y;
+ term_screen->y_line_start += delta;
+
+ region_start = 0;
+ up = 1;
+ down = 1;
+ 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
+ positions. */
+ y = term_screen->y_line_start;
+ i = 0;
+ linep = screen->lines;
+ while (1)
+ {
+ int add;
+ add = get_logical_num_lines (linep, term_screen);
+ if (y + add > 0)
+ break;
+ i++;
+ linep++;
+ y += add;
+ }
+
+ if (y < 0 || i > 0)
+ up_flag = 1;
+
+ do
+ {
+ struct grub_term_pos **pos;
+
+ if (linep >= screen->lines + screen->num_lines)
+ break;
+
+ pos = linep->pos + (term_screen - screen->terms);
+
+ if (!*pos)
+ *pos = grub_calloc (linep->len + 1, sizeof (**pos));
+
+ if (i == region_start || linep == screen->lines + screen->line
+ || (i > region_start && mode == ALL_LINES))
+ {
+ grub_term_gotoxy (term_screen->term,
+ (struct grub_term_coordinate) { term_screen->geo.first_entry_x,
+ (y < 0 ? 0 : y)
+ + term_screen->geo.first_entry_y });
+
+ grub_print_ucs4_menu (linep->buf,
+ linep->buf + linep->len,
+ term_screen->geo.first_entry_x,
+ term_screen->geo.right_margin,
+ term_screen->term,
+ (y < 0) ? -y : 0,
+ term_screen->geo.num_entries
+ - ((y > 0) ? y : 0), '\\',
+ *pos);
+ }
+ y += get_logical_num_lines (linep, term_screen);
+ if (y >= term_screen->geo.num_entries)
+ {
+ if (i + 1 < screen->num_lines)
+ down_flag = 1;
+ }
+
+ linep++;
+ i++;
+
+ if (mode == ALL_LINES && i == screen->num_lines)
+ for (; y < term_screen->geo.num_entries; y++)
+ print_empty_line (y, term_screen);
+ }
+ while (y < term_screen->geo.num_entries);
+
+ /* Draw up and down arrows. */
+
+ if (term_screen->geo.num_entries == 1)
+ {
+ if (up || down)
+ print_updown (up_flag, down_flag, term_screen);
+ }
+ else
+ {
+ if (up)
+ print_up (up_flag, term_screen);
+ if (down)
+ print_down (down_flag, term_screen);
+ }
+ }
+
+ /* Place the cursor. */
+ if (screen->lines[screen->line].pos[term_screen - screen->terms])
+ {
+ const struct grub_term_pos *cpos;
+ for (cpos = &(screen->lines[screen->line].pos[term_screen - screen->terms])[screen->column];
+ cpos >= &(screen->lines[screen->line].pos[term_screen - screen->terms])[0];
+ cpos--)
+ if (cpos->valid)
+ break;
+ y = term_screen->y_line_start;
+ for (i = 0; i < screen->line; i++)
+ y += get_logical_num_lines (screen->lines + i, term_screen);
+ if (cpos >= &(screen->lines[screen->line].pos[term_screen - screen->terms])[0])
+ grub_term_gotoxy (term_screen->term,
+ (struct grub_term_coordinate) { cpos->x + term_screen->geo.first_entry_x,
+ cpos->y + y
+ + term_screen->geo.first_entry_y });
+ else
+ grub_term_gotoxy (term_screen->term,
+ (struct grub_term_coordinate) { term_screen->geo.first_entry_x,
+ y + term_screen->geo.first_entry_y });
+
+ }
+
+ grub_term_setcursor (term_screen->term, 1);
+
+ grub_term_refresh (term_screen->term);
+}
+
+static void
+update_screen_all (struct screen *screen,
+ int region_start, int region_column,
+ int up, int down, enum update_mode mode)
+{
+ unsigned i;
+ for (i = 0; i < screen->nterms; i++)
+ update_screen (screen, &screen->terms[i], region_start, region_column,
+ up, down, mode);
+}
+
+static int
+insert_string (struct screen *screen, const char *s, int update)
+{
+ int region_start = screen->num_lines;
+ int region_column = 0;
+ unsigned i;
+
+ for (i = 0; i < screen->nterms; i++)
+ {
+ screen->terms[i].down = 0;
+ screen->terms[i].mode = NO_LINE;
+ }
+
+ while (*s)
+ {
+ if (*s == '\n')
+ {
+ /* LF is special because it creates a new line. */
+ struct line *current_linep;
+ struct line *next_linep;
+ int size;
+
+ /* Make a new line. */
+ screen->num_lines++;
+ screen->lines = grub_realloc (screen->lines,
+ screen->num_lines
+ * sizeof (screen->lines[0]));
+ if (! screen->lines)
+ return 0;
+
+ /* Shift down if not appending after the last line. */
+ if (screen->line < screen->num_lines - 2)
+ grub_memmove (screen->lines + screen->line + 2,
+ screen->lines + screen->line + 1,
+ ((screen->num_lines - screen->line - 2)
+ * sizeof (struct line)));
+
+ if (! init_line (screen, screen->lines + screen->line + 1))
+ return 0;
+
+ /* Fold the line. */
+ current_linep = screen->lines + screen->line;
+ next_linep = current_linep + 1;
+ size = current_linep->len - screen->column;
+
+ if (! ensure_space (next_linep, size))
+ return 0;
+
+ grub_memmove (next_linep->buf,
+ current_linep->buf + screen->column,
+ size * sizeof (next_linep->buf[0]));
+ current_linep->len = screen->column;
+ for (i = 0; i < screen->nterms; i++)
+ {
+ grub_free (current_linep->pos[i]);
+ current_linep->pos[i] = 0;
+ }
+ next_linep->len = size;
+
+ /* Update a dirty region. */
+ if (region_start > screen->line)
+ {
+ region_start = screen->line;
+ region_column = screen->column;
+ }
+
+ for (i = 0; i < screen->nterms; i++)
+ {
+ screen->terms[i].mode = ALL_LINES;
+ screen->terms[i].down = 1; /* XXX not optimal. */
+ }
+
+ /* Move the cursor. */
+ screen->column = screen->real_column = 0;
+ screen->line++;
+ s++;
+ }
+ else
+ {
+ /* All but LF. */
+ const char *p;
+ struct line *current_linep;
+ int size;
+ grub_uint32_t *unicode_msg;
+
+ /* Find a string delimited by LF. */
+ p = grub_strchr (s, '\n');
+ if (! p)
+ p = s + grub_strlen (s);
+
+ /* Insert the string. */
+ current_linep = screen->lines + screen->line;
+ unicode_msg = grub_calloc (p - s, sizeof (grub_uint32_t));
+
+ if (!unicode_msg)
+ return 0;
+
+ size = grub_utf8_to_ucs4 (unicode_msg, (p - s),
+ (grub_uint8_t *) s, (p - s), 0);
+
+ if (! ensure_space (current_linep, size))
+ {
+ grub_free (unicode_msg);
+ return 0;
+ }
+
+ grub_memmove (current_linep->buf + screen->column + size,
+ current_linep->buf + screen->column,
+ (current_linep->len - screen->column)
+ * sizeof (current_linep->buf[0]));
+ grub_memmove (current_linep->buf + screen->column,
+ unicode_msg,
+ size * sizeof (current_linep->buf[0]));
+ grub_free (unicode_msg);
+
+ for (i = 0; i < screen->nterms; i++)
+ {
+ grub_free (current_linep->pos[i]);
+ current_linep->pos[i] = 0;
+ }
+
+ for (i = 0; i < screen->nterms; i++)
+ screen->terms[i].orig_num = get_logical_num_lines (current_linep,
+ &screen->terms[i]);
+ current_linep->len += size;
+
+ /* Update the dirty region. */
+ if (region_start > screen->line)
+ {
+ region_start = screen->line;
+ region_column = screen->column;
+ }
+
+ for (i = 0; i < screen->nterms; i++)
+ {
+ int new_num = get_logical_num_lines (current_linep,
+ &screen->terms[i]);
+ if (screen->terms[i].orig_num != new_num)
+ {
+ screen->terms[i].mode = ALL_LINES;
+ screen->terms[i].down = 1; /* XXX not optimal. */
+ }
+ else if (screen->terms[i].mode != ALL_LINES)
+ screen->terms[i].mode = SINGLE_LINE;
+ }
+
+ /* Move the cursor. */
+ advance_to (screen, screen->column + size);
+
+ screen->real_column = screen->column;
+ s = p;
+ }
+ }
+
+ if (update)
+ for (i = 0; i < screen->nterms; i++)
+ update_screen (screen, &screen->terms[i],
+ region_start, region_column, 0, screen->terms[i].down,
+ screen->terms[i].mode);
+
+ return 1;
+}
+
+/* Release the resource allocated for SCREEN. */
+static void
+destroy_screen (struct screen *screen)
+{
+ int i;
+
+ if (screen->lines)
+ for (i = 0; i < screen->num_lines; i++)
+ {
+ struct line *linep = screen->lines + i;
+
+ if (linep)
+ {
+ unsigned j;
+ if (linep->pos)
+ for (j = 0; j < screen->nterms; j++)
+ grub_free (linep->pos[j]);
+
+ grub_free (linep->buf);
+ grub_free (linep->pos);
+ }
+ }
+
+ grub_free (screen->killed_text);
+ grub_free (screen->lines);
+ grub_free (screen->terms);
+ grub_free (screen);
+}
+
+/* Make a new screen. */
+static struct screen *
+make_screen (grub_menu_entry_t entry)
+{
+ struct screen *screen;
+ unsigned i;
+
+ /* Initialize the screen. */
+ screen = grub_zalloc (sizeof (*screen));
+ if (! screen)
+ return 0;
+
+ screen->submenu = entry->submenu;
+
+ screen->num_lines = 1;
+ screen->lines = grub_malloc (sizeof (struct line));
+ if (! screen->lines)
+ goto fail;
+
+ /* Initialize the first line which must be always present. */
+ if (! init_line (screen, screen->lines))
+ goto fail;
+
+ insert_string (screen, (char *) entry->sourcecode, 0);
+
+ /* Reset the cursor position. */
+ screen->column = 0;
+ screen->real_column = 0;
+ screen->line = 0;
+ for (i = 0; i < screen->nterms; i++)
+ {
+ screen->terms[i].y_line_start = 0;
+ }
+
+ return screen;
+
+ fail:
+ destroy_screen (screen);
+ return 0;
+}
+
+static int
+forward_char (struct screen *screen, int update)
+{
+ struct line *linep;
+
+ linep = screen->lines + screen->line;
+ if (screen->column < linep->len)
+ {
+ screen->column = grub_unicode_get_comb_end (screen->lines[screen->line].buf
+ + screen->lines[screen->line].len,
+ screen->lines[screen->line].buf
+ + screen->column + 1)
+ - screen->lines[screen->line].buf;
+ }
+ else if (screen->num_lines > screen->line + 1)
+ {
+ screen->column = 0;
+ screen->line++;
+ }
+
+ screen->real_column = screen->column;
+
+ if (update)
+ update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE);
+ return 1;
+}
+
+static int
+backward_char (struct screen *screen, int update)
+{
+ if (screen->column > 0)
+ {
+ struct grub_unicode_glyph glyph;
+ struct line *linep;
+
+ linep = screen->lines + screen->line;
+
+ screen->column--;
+ screen->column = grub_unicode_get_comb_start (linep->buf,
+ linep->buf + screen->column)
+ - linep->buf;
+
+ grub_unicode_aglomerate_comb (screen->lines[screen->line].buf + screen->column,
+ screen->lines[screen->line].len - screen->column,
+ &glyph);
+ screen->column = grub_unicode_get_comb_start (linep->buf,
+ linep->buf + screen->column)
+ - linep->buf;
+
+ grub_unicode_destroy_glyph (&glyph);
+ }
+ else if (screen->line > 0)
+ {
+ screen->line--;
+ screen->column = screen->lines[screen->line].len;
+ }
+
+ screen->real_column = screen->column;
+
+ if (update)
+ update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE);
+
+ return 1;
+}
+
+static int
+previous_line (struct screen *screen, int update)
+{
+ if (screen->line > 0)
+ {
+ struct line *linep;
+ int col;
+
+ screen->line--;
+
+ linep = screen->lines + screen->line;
+ if (linep->len < screen->real_column)
+ col = linep->len;
+ else
+ col = screen->real_column;
+
+ screen->column = 0;
+ advance_to (screen, col);
+ }
+ else
+ {
+ screen->column = 0;
+ }
+
+ if (update)
+ update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE);
+
+ return 1;
+}
+
+static int
+next_line (struct screen *screen, int update)
+{
+ if (screen->line < screen->num_lines - 1)
+ {
+ struct line *linep;
+ int c;
+
+ /* How many physical lines from the current position
+ to the last physical line? */
+ linep = screen->lines + screen->line;
+
+ screen->line++;
+ if ((linep + 1)->len < screen->real_column)
+ c = (linep + 1)->len;
+ else
+ c = screen->real_column;
+ screen->column = 0;
+
+ advance_to (screen, c);
+ }
+ else
+ advance_to (screen, screen->lines[screen->line].len);
+
+ if (update)
+ update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE);
+
+ return 1;
+}
+
+static int
+beginning_of_line (struct screen *screen, int update)
+{
+ screen->column = screen->real_column = 0;
+
+ if (update)
+ update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE);
+
+ return 1;
+}
+
+static int
+end_of_line (struct screen *screen, int update)
+{
+ advance_to (screen, screen->lines[screen->line].len);
+
+ if (update)
+ update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE);
+
+ return 1;
+}
+
+static int
+delete_char (struct screen *screen, int update)
+{
+ struct line *linep;
+ int start = screen->num_lines;
+ int column = 0;
+
+ linep = screen->lines + screen->line;
+ if (linep->len > screen->column)
+ {
+ unsigned i;
+
+ for (i = 0; i < screen->nterms; i++)
+ screen->terms[i].orig_num = get_logical_num_lines (linep, &screen->terms[i]);
+
+ grub_memmove (linep->buf + screen->column,
+ linep->buf + screen->column + 1,
+ (linep->len - screen->column - 1)
+ * sizeof (linep->buf[0]));
+ linep->len--;
+
+ for (i = 0; i < screen->nterms; i++)
+ {
+ grub_free (linep->pos[i]);
+ linep->pos[i] = 0;
+ }
+ start = screen->line;
+ column = screen->column;
+
+ screen->real_column = screen->column;
+
+ if (update)
+ {
+ for (i = 0; i < screen->nterms; i++)
+ {
+ int new_num;
+ new_num = get_logical_num_lines (linep, &screen->terms[i]);
+ if (screen->terms[i].orig_num != new_num)
+ update_screen (screen, &screen->terms[i],
+ start, column, 0, 0, ALL_LINES);
+ else
+ update_screen (screen, &screen->terms[i],
+ start, column, 0, 0, SINGLE_LINE);
+ }
+ }
+ }
+ else if (screen->num_lines > screen->line + 1)
+ {
+ struct line *next_linep;
+ unsigned i;
+
+ next_linep = linep + 1;
+ if (! ensure_space (linep, next_linep->len))
+ return 0;
+
+ grub_memmove (linep->buf + linep->len, next_linep->buf,
+ next_linep->len * sizeof (linep->buf[0]));
+ linep->len += next_linep->len;
+ for (i = 0; i < screen->nterms; i++)
+ {
+ grub_free (linep->pos[i]);
+ linep->pos[i] = 0;
+ }
+
+ grub_free (next_linep->buf);
+ grub_memmove (next_linep,
+ next_linep + 1,
+ (screen->num_lines - screen->line - 2)
+ * sizeof (struct line));
+ screen->num_lines--;
+
+ start = screen->line;
+ column = screen->column;
+
+ screen->real_column = screen->column;
+ if (update)
+ update_screen_all (screen, start, column, 0, 1, ALL_LINES);
+ }
+
+ return 1;
+}
+
+static int
+backward_delete_char (struct screen *screen, int update)
+{
+ int saved_column;
+ int saved_line;
+
+ saved_column = screen->column;
+ saved_line = screen->line;
+
+ if (! backward_char (screen, 0))
+ return 0;
+
+ if (saved_column != screen->column || saved_line != screen->line)
+ if (! delete_char (screen, update))
+ return 0;
+
+ return 1;
+}
+
+static int
+kill_line (struct screen *screen, int continuous, int update)
+{
+ struct line *linep;
+ char *p;
+ int size;
+ int offset;
+
+ p = screen->killed_text;
+ if (! continuous && p)
+ p[0] = '\0';
+
+ linep = screen->lines + screen->line;
+ size = linep->len - screen->column;
+
+ if (p)
+ offset = grub_strlen (p);
+ else
+ offset = 0;
+
+ if (size > 0)
+ {
+ unsigned i;
+
+ p = grub_realloc (p, offset + size + 1);
+ if (! p)
+ return 0;
+
+ grub_memmove (p + offset, linep->buf + screen->column, size);
+ p[offset + size] = '\0';
+
+ screen->killed_text = p;
+
+ for (i = 0; i < screen->nterms; i++)
+ screen->terms[i].orig_num = get_logical_num_lines (linep, &screen->terms[i]);
+ linep->len = screen->column;
+
+ if (update)
+ {
+ for (i = 0; i < screen->nterms; i++)
+ {
+ int new_num;
+ new_num = get_logical_num_lines (linep, &screen->terms[i]);
+ if (screen->terms[i].orig_num != new_num)
+ update_screen (screen, &screen->terms[i],
+ screen->line, screen->column, 0, 1, ALL_LINES);
+ else
+ update_screen (screen, &screen->terms[i],
+ screen->line, screen->column, 0, 0, SINGLE_LINE);
+ }
+ }
+ }
+ else if (screen->line + 1 < screen->num_lines)
+ {
+ p = grub_realloc (p, offset + 1 + 1);
+ if (! p)
+ return 0;
+
+ p[offset] = '\n';
+ p[offset + 1] = '\0';
+
+ screen->killed_text = p;
+
+ return delete_char (screen, update);
+ }
+
+ return 1;
+}
+
+static int
+yank (struct screen *screen, int update)
+{
+ if (screen->killed_text)
+ return insert_string (screen, screen->killed_text, update);
+
+ return 1;
+}
+
+static int
+open_line (struct screen *screen, int update)
+{
+ if (! insert_string (screen, "\n", 0))
+ return 0;
+
+ if (! backward_char (screen, 0))
+ return 0;
+
+ if (update)
+ update_screen_all (screen, screen->line, screen->column, 0, 1, ALL_LINES);
+
+ return 1;
+}
+
+/* A completion hook to print items. */
+static void
+store_completion (const char *item, grub_completion_type_t type,
+ int count __attribute__ ((unused)))
+{
+ char *p;
+
+ completion_type = type;
+
+ /* Make sure that the completion buffer has enough room. */
+ if (completion_buffer.max_len < (completion_buffer.len
+ + (int) grub_strlen (item) + 1 + 1))
+ {
+ grub_size_t new_len;
+
+ new_len = completion_buffer.len + grub_strlen (item) + 80;
+ p = grub_realloc (completion_buffer.buf, new_len);
+ if (! p)
+ {
+ /* Possibly not fatal. */
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+ p[completion_buffer.len] = 0;
+ completion_buffer.buf = p;
+ completion_buffer.max_len = new_len;
+ }
+
+ p = completion_buffer.buf + completion_buffer.len;
+ if (completion_buffer.len != 0)
+ {
+ *p++ = ' ';
+ completion_buffer.len++;
+ }
+ grub_strcpy (p, item);
+ completion_buffer.len += grub_strlen (item);
+}
+
+static int
+complete (struct screen *screen, int continuous, int update)
+{
+ struct line *linep;
+ int restore;
+ char *insert;
+ static int count = -1;
+ unsigned i;
+ grub_uint32_t *ucs4;
+ grub_size_t buflen;
+ grub_ssize_t ucs4len;
+ char *u8;
+
+ if (continuous)
+ count++;
+ else
+ count = 0;
+
+ completion_buffer.buf = 0;
+ completion_buffer.len = 0;
+ completion_buffer.max_len = 0;
+
+ linep = screen->lines + screen->line;
+ u8 = grub_ucs4_to_utf8_alloc (linep->buf, screen->column);
+ if (!u8)
+ return 1;
+
+ insert = grub_normal_do_completion (u8, &restore, store_completion);
+
+ if (completion_buffer.buf)
+ {
+ buflen = grub_strlen (completion_buffer.buf);
+ ucs4 = grub_calloc (buflen + 1, sizeof (grub_uint32_t));
+
+ if (!ucs4)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ return 1;
+ }
+
+ ucs4len = grub_utf8_to_ucs4 (ucs4, buflen,
+ (grub_uint8_t *) completion_buffer.buf,
+ buflen, 0);
+ ucs4[ucs4len] = 0;
+
+ if (restore)
+ for (i = 0; i < screen->nterms; i++)
+ {
+ unsigned width = grub_term_width (screen->terms[i].term);
+ if (width > 2)
+ width -= 2;
+ if (width > 15)
+ width -= 6;
+ unsigned num_sections = ((completion_buffer.len
+ + width - 1)
+ / width);
+ grub_uint32_t *endp;
+ struct grub_term_coordinate pos;
+ grub_uint32_t *p = ucs4;
+
+ pos = grub_term_getxy (screen->terms[i].term);
+
+ screen->completion_shown = 1;
+
+ grub_term_gotoxy (screen->terms[i].term,
+ (struct grub_term_coordinate) { 0,
+ screen->terms[i].geo.timeout_y });
+ if (screen->terms[i].geo.timeout_lines >= 2)
+ {
+ grub_puts_terminal (" ", screen->terms[i].term);
+ switch (completion_type)
+ {
+ case GRUB_COMPLETION_TYPE_COMMAND:
+ grub_puts_terminal (_("Possible commands are:"),
+ screen->terms[i].term);
+ break;
+ case GRUB_COMPLETION_TYPE_DEVICE:
+ grub_puts_terminal (_("Possible devices are:"),
+ screen->terms[i].term);
+ break;
+ case GRUB_COMPLETION_TYPE_FILE:
+ grub_puts_terminal (_("Possible files are:"),
+ screen->terms[i].term);
+ break;
+ case GRUB_COMPLETION_TYPE_PARTITION:
+ grub_puts_terminal (_("Possible partitions are:"),
+ screen->terms[i].term);
+ break;
+ case GRUB_COMPLETION_TYPE_ARGUMENT:
+ grub_puts_terminal (_("Possible arguments are:"),
+ screen->terms[i].term);
+ break;
+ default:
+ grub_puts_terminal (_("Possible things are:"),
+ screen->terms[i].term);
+ break;
+ }
+
+ grub_puts_terminal ("\n ", screen->terms[i].term);
+ }
+
+ p += ((unsigned) count % num_sections) * width;
+ endp = p + width;
+
+ if (p != ucs4)
+ grub_putcode (GRUB_UNICODE_LEFTARROW, screen->terms[i].term);
+ else
+ grub_putcode (' ', screen->terms[i].term);
+
+ grub_print_ucs4 (p, ucs4 + ucs4len < endp ? ucs4 + ucs4len : endp,
+ 0, 0, screen->terms[i].term);
+
+ if (ucs4 + ucs4len > endp)
+ grub_putcode (GRUB_UNICODE_RIGHTARROW, screen->terms[i].term);
+ grub_term_gotoxy (screen->terms[i].term, pos);
+ }
+ }
+
+ if (insert)
+ {
+ insert_string (screen, insert, update);
+ count = -1;
+ grub_free (insert);
+ }
+ else if (update)
+ grub_refresh ();
+
+ grub_free (completion_buffer.buf);
+ return 1;
+}
+
+/* Clear displayed completions. */
+static void
+clear_completions (struct per_term_screen *term_screen)
+{
+ struct grub_term_coordinate pos;
+ unsigned j;
+ int i;
+
+ pos = grub_term_getxy (term_screen->term);
+ grub_term_gotoxy (term_screen->term,
+ (struct grub_term_coordinate) { 0,
+ term_screen->geo.timeout_y });
+
+ for (i = 0; i < term_screen->geo.timeout_lines; i++)
+ {
+ for (j = 0; j < grub_term_width (term_screen->term) - 1; j++)
+ grub_putcode (' ', term_screen->term);
+ if (i + 1 < term_screen->geo.timeout_lines)
+ grub_putcode ('\n', term_screen->term);
+ }
+
+ grub_term_gotoxy (term_screen->term, pos);
+ grub_term_refresh (term_screen->term);
+}
+
+static void
+clear_completions_all (struct screen *screen)
+{
+ unsigned i;
+
+ for (i = 0; i < screen->nterms; i++)
+ clear_completions (&screen->terms[i]);
+}
+
+/* Execute the command list in the screen SCREEN. */
+static int
+run (struct screen *screen)
+{
+ char *script;
+ int errs_before;
+ grub_menu_t menu = NULL;
+ char *dummy[1] = { NULL };
+
+ grub_cls ();
+ grub_printf (" ");
+ grub_printf_ (N_("Booting a command list"));
+ grub_printf ("\n\n");
+
+ errs_before = grub_err_printed_errors;
+
+ if (screen->submenu)
+ {
+ grub_env_context_open ();
+ menu = grub_zalloc (sizeof (*menu));
+ if (! menu)
+ return 0;
+ grub_env_set_menu (menu);
+ }
+
+ /* Execute the script, line for line. */
+ {
+ int i;
+ grub_size_t size = 0, tot_size = 0;
+
+ for (i = 0; i < screen->num_lines; i++)
+ tot_size += grub_get_num_of_utf8_bytes (screen->lines[i].buf,
+ screen->lines[i].len) + 1;
+
+ script = grub_malloc (tot_size + 1);
+ if (! script)
+ return 0;
+
+ for (i = 0; i < screen->num_lines; i++)
+ {
+ size += grub_ucs4_to_utf8 (screen->lines[i].buf, screen->lines[i].len,
+ (grub_uint8_t *) script + size,
+ tot_size - size);
+ script[size++] = '\n';
+ }
+ script[size] = '\0';
+ }
+ grub_script_execute_new_scope (script, 0, dummy);
+ grub_free (script);
+
+ if (errs_before != grub_err_printed_errors)
+ grub_wait_after_message ();
+
+ if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
+ /* Implicit execution of boot, only if something is loaded. */
+ grub_command_execute ("boot", 0, 0);
+
+ if (screen->submenu)
+ {
+ if (menu && menu->size)
+ {
+ grub_show_menu (menu, 1, 0);
+ grub_normal_free_menu (menu);
+ }
+ grub_env_context_close ();
+ }
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ grub_wait_after_message ();
+ }
+
+ return 1;
+}
+
+/* Edit a menu entry with an Emacs-like interface. */
+void
+grub_menu_entry_run (grub_menu_entry_t entry)
+{
+ struct screen *screen;
+ int prev_c;
+ grub_err_t err = GRUB_ERR_NONE;
+ unsigned i;
+ grub_term_output_t term;
+
+ err = grub_auth_check_authentication (NULL);
+
+ if (err)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ screen = make_screen (entry);
+ if (! screen)
+ return;
+
+ screen->terms = NULL;
+
+ refresh:
+ grub_free (screen->terms);
+ screen->nterms = 0;
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ screen->nterms++;
+
+ for (i = 0; i < (unsigned) screen->num_lines; i++)
+ {
+ grub_free (screen->lines[i].pos);
+ screen->lines[i].pos = grub_calloc (screen->nterms, sizeof (screen->lines[i].pos[0]));
+ if (! screen->lines[i].pos)
+ {
+ grub_print_error ();
+ destroy_screen (screen);
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+ }
+
+ screen->terms = grub_calloc (screen->nterms, sizeof (screen->terms[0]));
+ if (!screen->terms)
+ {
+ grub_print_error ();
+ destroy_screen (screen);
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+ i = 0;
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ screen->terms[i].term = term;
+ screen->terms[i].y_line_start = 0;
+ i++;
+ }
+ /* Draw the screen. */
+ for (i = 0; i < screen->nterms; i++)
+ grub_menu_init_page (0, 1, &screen->terms[i].geo,
+ screen->terms[i].term);
+ update_screen_all (screen, 0, 0, 1, 1, ALL_LINES);
+ for (i = 0; i < screen->nterms; i++)
+ grub_term_setcursor (screen->terms[i].term, 1);
+ prev_c = '\0';
+
+ while (1)
+ {
+ int c = grub_getkey ();
+
+ if (screen->completion_shown)
+ {
+ clear_completions_all (screen);
+ screen->completion_shown = 0;
+ }
+
+ if (grub_normal_exit_level)
+ {
+ destroy_screen (screen);
+ return;
+ }
+
+ switch (c)
+ {
+ case GRUB_TERM_KEY_UP:
+ case GRUB_TERM_CTRL | 'p':
+ if (! previous_line (screen, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'n':
+ case GRUB_TERM_KEY_DOWN:
+ if (! next_line (screen, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'f':
+ case GRUB_TERM_KEY_RIGHT:
+ if (! forward_char (screen, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'b':
+ case GRUB_TERM_KEY_LEFT:
+ if (! backward_char (screen, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'a':
+ case GRUB_TERM_KEY_HOME:
+ if (! beginning_of_line (screen, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'e':
+ case GRUB_TERM_KEY_END:
+ if (! end_of_line (screen, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'i':
+ case '\t':
+ if (! complete (screen, prev_c == c, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'd':
+ case GRUB_TERM_KEY_DC:
+ if (! delete_char (screen, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'h':
+ case '\b':
+ if (! backward_delete_char (screen, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'k':
+ if (! kill_line (screen, prev_c == c, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'u':
+ /* FIXME: What behavior is good for this key? */
+ break;
+
+ case GRUB_TERM_CTRL | 'y':
+ if (! yank (screen, 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_CTRL | 'l':
+ /* FIXME: centering. */
+ goto refresh;
+
+ case GRUB_TERM_CTRL | 'o':
+ if (! open_line (screen, 1))
+ goto fail;
+ break;
+
+ case '\n':
+ case '\r':
+ if (! insert_string (screen, "\n", 1))
+ goto fail;
+ break;
+
+ case GRUB_TERM_ESC:
+ destroy_screen (screen);
+ return;
+
+ case GRUB_TERM_CTRL | 'c':
+ case GRUB_TERM_KEY_F2:
+ grub_cmdline_run (1, 0);
+ goto refresh;
+
+ case GRUB_TERM_CTRL | 'x':
+ case GRUB_TERM_KEY_F10:
+ run (screen);
+ goto refresh;
+
+ case GRUB_TERM_CTRL | 'r':
+ case GRUB_TERM_CTRL | 's':
+ case GRUB_TERM_CTRL | 't':
+ /* FIXME */
+ break;
+
+ default:
+ if (grub_isprint (c))
+ {
+ char buf[2];
+
+ buf[0] = c;
+ buf[1] = '\0';
+ if (! insert_string (screen, buf, 1))
+ goto fail;
+ }
+ break;
+ }
+
+ prev_c = c;
+ }
+
+ fail:
+ destroy_screen (screen);
+
+ grub_cls ();
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ grub_xputs ("\n");
+ grub_printf_ (N_("Press any key to continue..."));
+ (void) grub_getkey ();
+}
diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c
new file mode 100644
index 0000000..18240e7
--- /dev/null
+++ b/grub-core/normal/menu_text.c
@@ -0,0 +1,602 @@
+/* menu_text.c - Basic text menu implementation. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/loader.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/env.h>
+#include <grub/menu_viewer.h>
+#include <grub/i18n.h>
+#include <grub/charset.h>
+
+static grub_uint8_t grub_color_menu_normal;
+static grub_uint8_t grub_color_menu_highlight;
+
+struct menu_viewer_data
+{
+ int first, offset;
+ struct grub_term_screen_geometry geo;
+ enum {
+ TIMEOUT_UNKNOWN,
+ TIMEOUT_NORMAL,
+ TIMEOUT_TERSE,
+ TIMEOUT_TERSE_NO_MARGIN
+ } timeout_msg;
+ grub_menu_t menu;
+ struct grub_term_output *term;
+};
+
+static inline int
+grub_term_cursor_x (const struct grub_term_screen_geometry *geo)
+{
+ return (geo->first_entry_x + geo->entry_width);
+}
+
+grub_size_t
+grub_getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position,
+ struct grub_term_output *term)
+{
+ grub_ssize_t width = 0;
+
+ while (str < last_position)
+ {
+ struct grub_unicode_glyph glyph;
+ glyph.ncomb = 0;
+ str += grub_unicode_aglomerate_comb (str, last_position - str, &glyph);
+ width += grub_term_getcharwidth (term, &glyph);
+ grub_unicode_destroy_glyph (&glyph);
+ }
+ return width;
+}
+
+static int
+grub_print_message_indented_real (const char *msg, int margin_left,
+ int margin_right,
+ struct grub_term_output *term, int dry_run)
+{
+ grub_uint32_t *unicode_msg;
+ grub_uint32_t *last_position;
+ grub_size_t msg_len = grub_strlen (msg) + 2;
+ int ret = 0;
+
+ unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t));
+
+ if (!unicode_msg)
+ return 0;
+
+ msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len,
+ (grub_uint8_t *) msg, -1, 0);
+
+ last_position = unicode_msg + msg_len;
+ *last_position = 0;
+
+ if (dry_run)
+ ret = grub_ucs4_count_lines (unicode_msg, last_position, margin_left,
+ margin_right, term);
+ else
+ grub_print_ucs4_menu (unicode_msg, last_position, margin_left,
+ margin_right, term, 0, -1, 0, 0);
+
+ grub_free (unicode_msg);
+
+ return ret;
+}
+
+void
+grub_print_message_indented (const char *msg, int margin_left, int margin_right,
+ struct grub_term_output *term)
+{
+ grub_print_message_indented_real (msg, margin_left, margin_right, term, 0);
+}
+
+static void
+draw_border (struct grub_term_output *term, const struct grub_term_screen_geometry *geo)
+{
+ int i;
+
+ grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
+
+ grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1,
+ geo->first_entry_y - 1 });
+ grub_putcode (GRUB_UNICODE_CORNER_UL, term);
+ for (i = 0; i < geo->entry_width + 1; i++)
+ grub_putcode (GRUB_UNICODE_HLINE, term);
+ grub_putcode (GRUB_UNICODE_CORNER_UR, term);
+
+ for (i = 0; i < geo->num_entries; i++)
+ {
+ grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1,
+ geo->first_entry_y + i });
+ grub_putcode (GRUB_UNICODE_VLINE, term);
+ grub_term_gotoxy (term,
+ (struct grub_term_coordinate) { geo->first_entry_x + geo->entry_width + 1,
+ geo->first_entry_y + i });
+ grub_putcode (GRUB_UNICODE_VLINE, term);
+ }
+
+ grub_term_gotoxy (term,
+ (struct grub_term_coordinate) { geo->first_entry_x - 1,
+ geo->first_entry_y - 1 + geo->num_entries + 1 });
+ grub_putcode (GRUB_UNICODE_CORNER_LL, term);
+ for (i = 0; i < geo->entry_width + 1; i++)
+ grub_putcode (GRUB_UNICODE_HLINE, term);
+ grub_putcode (GRUB_UNICODE_CORNER_LR, term);
+
+ grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
+
+ grub_term_gotoxy (term,
+ (struct grub_term_coordinate) { geo->first_entry_x - 1,
+ (geo->first_entry_y - 1 + geo->num_entries
+ + GRUB_TERM_MARGIN + 1) });
+}
+
+static int
+print_message (int nested, int edit, struct grub_term_output *term, int dry_run)
+{
+ int ret = 0;
+ grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
+
+ if (edit)
+ {
+ ret += grub_print_message_indented_real (_("Minimum Emacs-like screen editing is \
+supported. TAB lists completions. Press Ctrl-x or F10 to boot, Ctrl-c or F2 for a \
+command-line or ESC to discard edits and return to the GRUB menu."),
+ STANDARD_MARGIN, STANDARD_MARGIN,
+ term, dry_run);
+ }
+ else
+ {
+ char *msg_translated;
+
+ 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;
+ ret += grub_print_message_indented_real (msg_translated, STANDARD_MARGIN,
+ STANDARD_MARGIN, term, dry_run);
+
+ grub_free (msg_translated);
+
+ if (nested)
+ {
+ ret += grub_print_message_indented_real
+ (_("Press enter to boot the selected OS, "
+ "`e' to edit the commands before booting "
+ "or `c' for a command-line. ESC to return previous menu."),
+ STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
+ }
+ else
+ {
+ ret += grub_print_message_indented_real
+ (_("Press enter to boot the selected OS, "
+ "`e' to edit the commands before booting "
+ "or `c' for a command-line."),
+ STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run);
+ }
+ }
+ return ret;
+}
+
+static void
+print_entry (int y, int highlight, grub_menu_entry_t entry,
+ const struct menu_viewer_data *data)
+{
+ const char *title;
+ grub_size_t title_len;
+ grub_ssize_t len;
+ grub_uint32_t *unicode_title;
+ grub_ssize_t i;
+ grub_uint8_t old_color_normal, old_color_highlight;
+
+ title = entry ? entry->title : "";
+ title_len = grub_strlen (title);
+ unicode_title = grub_calloc (title_len, sizeof (*unicode_title));
+ if (! unicode_title)
+ /* XXX How to show this error? */
+ return;
+
+ len = grub_utf8_to_ucs4 (unicode_title, title_len,
+ (grub_uint8_t *) title, -1, 0);
+ if (len < 0)
+ {
+ /* It is an invalid sequence. */
+ grub_free (unicode_title);
+ return;
+ }
+
+ old_color_normal = grub_term_normal_color;
+ old_color_highlight = grub_term_highlight_color;
+ grub_term_normal_color = grub_color_menu_normal;
+ grub_term_highlight_color = grub_color_menu_highlight;
+ grub_term_setcolorstate (data->term, highlight
+ ? GRUB_TERM_COLOR_HIGHLIGHT
+ : GRUB_TERM_COLOR_NORMAL);
+
+ grub_term_gotoxy (data->term, (struct grub_term_coordinate) {
+ data->geo.first_entry_x, y });
+
+ for (i = 0; i < len; i++)
+ if (unicode_title[i] == '\n' || unicode_title[i] == '\b'
+ || unicode_title[i] == '\r' || unicode_title[i] == '\e')
+ unicode_title[i] = ' ';
+
+ if (data->geo.num_entries > 1)
+ grub_putcode (highlight ? '*' : ' ', data->term);
+
+ grub_print_ucs4_menu (unicode_title,
+ unicode_title + len,
+ 0,
+ data->geo.right_margin,
+ data->term, 0, 1,
+ GRUB_UNICODE_RIGHTARROW, 0);
+
+ grub_term_setcolorstate (data->term, GRUB_TERM_COLOR_NORMAL);
+ grub_term_gotoxy (data->term,
+ (struct grub_term_coordinate) {
+ grub_term_cursor_x (&data->geo), y });
+
+ grub_term_normal_color = old_color_normal;
+ grub_term_highlight_color = old_color_highlight;
+
+ grub_term_setcolorstate (data->term, GRUB_TERM_COLOR_NORMAL);
+ grub_free (unicode_title);
+}
+
+static void
+print_entries (grub_menu_t menu, const struct menu_viewer_data *data)
+{
+ grub_menu_entry_t e;
+ int i;
+
+ grub_term_gotoxy (data->term,
+ (struct grub_term_coordinate) {
+ data->geo.first_entry_x + data->geo.entry_width
+ + data->geo.border + 1,
+ data->geo.first_entry_y });
+
+ if (data->geo.num_entries != 1)
+ {
+ if (data->first)
+ grub_putcode (GRUB_UNICODE_UPARROW, data->term);
+ else
+ grub_putcode (' ', data->term);
+ }
+ e = grub_menu_get_entry (menu, data->first);
+
+ for (i = 0; i < data->geo.num_entries; i++)
+ {
+ print_entry (data->geo.first_entry_y + i, data->offset == i,
+ e, data);
+ if (e)
+ e = e->next;
+ }
+
+ grub_term_gotoxy (data->term,
+ (struct grub_term_coordinate) { data->geo.first_entry_x + data->geo.entry_width
+ + data->geo.border + 1,
+ data->geo.first_entry_y + data->geo.num_entries - 1 });
+ if (data->geo.num_entries == 1)
+ {
+ if (data->first && e)
+ grub_putcode (GRUB_UNICODE_UPDOWNARROW, data->term);
+ else if (data->first)
+ grub_putcode (GRUB_UNICODE_UPARROW, data->term);
+ else if (e)
+ grub_putcode (GRUB_UNICODE_DOWNARROW, data->term);
+ else
+ grub_putcode (' ', data->term);
+ }
+ else
+ {
+ if (e)
+ grub_putcode (GRUB_UNICODE_DOWNARROW, data->term);
+ else
+ grub_putcode (' ', data->term);
+ }
+
+ grub_term_gotoxy (data->term,
+ (struct grub_term_coordinate) { grub_term_cursor_x (&data->geo),
+ data->geo.first_entry_y + data->offset });
+}
+
+/* Initialize the screen. If NESTED is non-zero, assume that this menu
+ is run from another menu or a command-line. If EDIT is non-zero, show
+ a message for the menu entry editor. */
+void
+grub_menu_init_page (int nested, int edit,
+ struct grub_term_screen_geometry *geo,
+ struct grub_term_output *term)
+{
+ grub_uint8_t old_color_normal, old_color_highlight;
+ int msg_num_lines;
+ int bottom_message = 1;
+ int empty_lines = 1;
+ int version_msg = 1;
+
+ geo->border = 1;
+ geo->first_entry_x = 1 /* margin */ + 1 /* border */;
+ geo->entry_width = grub_term_width (term) - 5;
+
+ geo->first_entry_y = 2 /* two empty lines*/
+ + 1 /* GNU GRUB version text */ + 1 /* top border */;
+
+ geo->timeout_lines = 2;
+
+ /* 3 lines for timeout message and bottom margin. 2 lines for the border. */
+ geo->num_entries = grub_term_height (term) - geo->first_entry_y
+ - 1 /* bottom border */
+ - 1 /* empty line before info message*/
+ - geo->timeout_lines /* timeout */
+ - 1 /* empty final line */;
+ msg_num_lines = print_message (nested, edit, term, 1);
+ if (geo->num_entries - msg_num_lines < 3
+ || geo->entry_width < 10)
+ {
+ geo->num_entries += 4;
+ geo->first_entry_y -= 2;
+ empty_lines = 0;
+ geo->first_entry_x -= 1;
+ geo->entry_width += 1;
+ }
+ if (geo->num_entries - msg_num_lines < 3
+ || geo->entry_width < 10)
+ {
+ geo->num_entries += 2;
+ geo->first_entry_y -= 1;
+ geo->first_entry_x -= 1;
+ geo->entry_width += 2;
+ geo->border = 0;
+ }
+
+ if (geo->entry_width <= 0)
+ geo->entry_width = 1;
+
+ if (geo->num_entries - msg_num_lines < 3
+ && geo->timeout_lines == 2)
+ {
+ geo->timeout_lines = 1;
+ geo->num_entries++;
+ }
+
+ if (geo->num_entries - msg_num_lines < 3)
+ {
+ geo->num_entries += 1;
+ geo->first_entry_y -= 1;
+ version_msg = 0;
+ }
+
+ if (geo->num_entries - msg_num_lines >= 2)
+ geo->num_entries -= msg_num_lines;
+ else
+ bottom_message = 0;
+
+ /* By default, use the same colors for the menu. */
+ old_color_normal = grub_term_normal_color;
+ old_color_highlight = grub_term_highlight_color;
+ grub_color_menu_normal = grub_term_normal_color;
+ grub_color_menu_highlight = grub_term_highlight_color;
+
+ /* Then give user a chance to replace them. */
+ grub_parse_color_name_pair (&grub_color_menu_normal,
+ grub_env_get ("menu_color_normal"));
+ grub_parse_color_name_pair (&grub_color_menu_highlight,
+ grub_env_get ("menu_color_highlight"));
+
+ if (version_msg)
+ grub_normal_init_page (term, empty_lines);
+ else
+ grub_term_cls (term);
+
+ grub_term_normal_color = grub_color_menu_normal;
+ grub_term_highlight_color = grub_color_menu_highlight;
+ if (geo->border)
+ draw_border (term, geo);
+ grub_term_normal_color = old_color_normal;
+ grub_term_highlight_color = old_color_highlight;
+ geo->timeout_y = geo->first_entry_y + geo->num_entries
+ + geo->border + empty_lines;
+ if (bottom_message)
+ {
+ grub_term_gotoxy (term,
+ (struct grub_term_coordinate) { GRUB_TERM_MARGIN,
+ geo->timeout_y });
+
+ print_message (nested, edit, term, 0);
+ geo->timeout_y += msg_num_lines;
+ }
+ geo->right_margin = grub_term_width (term)
+ - geo->first_entry_x
+ - geo->entry_width - 1;
+}
+
+static void
+menu_text_print_timeout (int timeout, void *dataptr)
+{
+ struct menu_viewer_data *data = dataptr;
+ char *msg_translated = 0;
+
+ grub_term_gotoxy (data->term,
+ (struct grub_term_coordinate) { 0, data->geo.timeout_y });
+
+ if (data->timeout_msg == TIMEOUT_TERSE
+ || data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN)
+ msg_translated = grub_xasprintf (_("%ds"), timeout);
+ else
+ msg_translated = grub_xasprintf (_("The highlighted entry will be executed automatically in %ds."), timeout);
+ if (!msg_translated)
+ {
+ grub_print_error ();
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ if (data->timeout_msg == TIMEOUT_UNKNOWN)
+ {
+ data->timeout_msg = grub_print_message_indented_real (msg_translated,
+ 3, 1, data->term, 1)
+ <= data->geo.timeout_lines ? TIMEOUT_NORMAL : TIMEOUT_TERSE;
+ if (data->timeout_msg == TIMEOUT_TERSE)
+ {
+ grub_free (msg_translated);
+ msg_translated = grub_xasprintf (_("%ds"), timeout);
+ if (grub_term_width (data->term) < 10)
+ data->timeout_msg = TIMEOUT_TERSE_NO_MARGIN;
+ }
+ }
+
+ grub_print_message_indented (msg_translated,
+ data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN ? 0 : 3,
+ data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN ? 0 : 1,
+ data->term);
+ grub_free (msg_translated);
+
+ grub_term_gotoxy (data->term,
+ (struct grub_term_coordinate) {
+ grub_term_cursor_x (&data->geo),
+ data->geo.first_entry_y + data->offset });
+ grub_term_refresh (data->term);
+}
+
+static void
+menu_text_set_chosen_entry (int entry, void *dataptr)
+{
+ struct menu_viewer_data *data = dataptr;
+ int oldoffset = data->offset;
+ int complete_redraw = 0;
+
+ data->offset = entry - data->first;
+ if (data->offset > data->geo.num_entries - 1)
+ {
+ data->first = entry - (data->geo.num_entries - 1);
+ data->offset = data->geo.num_entries - 1;
+ complete_redraw = 1;
+ }
+ if (data->offset < 0)
+ {
+ data->offset = 0;
+ data->first = entry;
+ complete_redraw = 1;
+ }
+ if (complete_redraw)
+ print_entries (data->menu, data);
+ else
+ {
+ print_entry (data->geo.first_entry_y + oldoffset, 0,
+ grub_menu_get_entry (data->menu, data->first + oldoffset),
+ data);
+ print_entry (data->geo.first_entry_y + data->offset, 1,
+ grub_menu_get_entry (data->menu, data->first + data->offset),
+ data);
+ }
+ grub_term_refresh (data->term);
+}
+
+static void
+menu_text_fini (void *dataptr)
+{
+ struct menu_viewer_data *data = dataptr;
+
+ grub_term_setcursor (data->term, 1);
+ grub_term_cls (data->term);
+ grub_free (data);
+}
+
+static void
+menu_text_clear_timeout (void *dataptr)
+{
+ struct menu_viewer_data *data = dataptr;
+ int i;
+
+ for (i = 0; i < data->geo.timeout_lines;i++)
+ {
+ grub_term_gotoxy (data->term, (struct grub_term_coordinate) {
+ 0, data->geo.timeout_y + i });
+ grub_print_spaces (data->term, grub_term_width (data->term) - 1);
+ }
+ if (data->geo.num_entries <= 5 && !data->geo.border)
+ {
+ grub_term_gotoxy (data->term,
+ (struct grub_term_coordinate) {
+ data->geo.first_entry_x + data->geo.entry_width
+ + data->geo.border + 1,
+ data->geo.first_entry_y + data->geo.num_entries - 1
+ });
+ grub_putcode (' ', data->term);
+
+ data->geo.timeout_lines = 0;
+ data->geo.num_entries++;
+ print_entries (data->menu, data);
+ }
+ grub_term_gotoxy (data->term,
+ (struct grub_term_coordinate) {
+ grub_term_cursor_x (&data->geo),
+ data->geo.first_entry_y + data->offset });
+ grub_term_refresh (data->term);
+}
+
+grub_err_t
+grub_menu_try_text (struct grub_term_output *term,
+ int entry, grub_menu_t menu, int nested)
+{
+ struct menu_viewer_data *data;
+ struct grub_menu_viewer *instance;
+
+ instance = grub_zalloc (sizeof (*instance));
+ if (!instance)
+ return grub_errno;
+
+ data = grub_zalloc (sizeof (*data));
+ if (!data)
+ {
+ grub_free (instance);
+ return grub_errno;
+ }
+
+ data->term = term;
+ instance->data = data;
+ instance->set_chosen_entry = menu_text_set_chosen_entry;
+ instance->print_timeout = menu_text_print_timeout;
+ instance->clear_timeout = menu_text_clear_timeout;
+ instance->fini = menu_text_fini;
+
+ data->menu = menu;
+
+ data->offset = entry;
+ data->first = 0;
+
+ grub_term_setcursor (data->term, 0);
+ grub_menu_init_page (nested, 0, &data->geo, data->term);
+
+ if (data->offset > data->geo.num_entries - 1)
+ {
+ data->first = data->offset - (data->geo.num_entries - 1);
+ data->offset = data->geo.num_entries - 1;
+ }
+
+ print_entries (menu, data);
+ grub_term_refresh (data->term);
+ grub_menu_register_viewer (instance);
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/normal/misc.c b/grub-core/normal/misc.c
new file mode 100644
index 0000000..f7e9e3a
--- /dev/null
+++ b/grub-core/normal/misc.c
@@ -0,0 +1,194 @@
+/* misc.c - miscellaneous functions */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/disk.h>
+#include <grub/fs.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/datetime.h>
+#include <grub/term.h>
+#include <grub/i18n.h>
+#include <grub/partition.h>
+
+static const char *grub_human_sizes[3][6] =
+ {
+ /* This algorithm in reality would work only up to (2^64) / 100 B = 81 PiB.
+ Put here all possible suffixes it can produce so no array bounds check
+ is needed.
+ */
+ /* TRANSLATORS: that's the list of binary unit prefixes. */
+ { N_("B"), N_("KiB"), N_("MiB"), N_("GiB"), N_("TiB"), N_("PiB")},
+ /* TRANSLATORS: that's the list of binary unit prefixes. */
+ { "", N_("K"), N_("M"), N_("G"), N_("T"), N_("P") },
+ /* TRANSLATORS: that's the list of binary unit prefixes. */
+ { N_("B/s"), N_("KiB/s"), N_("MiB/s"), N_("GiB/s"), N_("TiB/s"), N_("PiB/s"), },
+ };
+
+const char *
+grub_get_human_size (grub_uint64_t size, enum grub_human_size_type type)
+{
+ grub_uint64_t fsize;
+ unsigned units = 0;
+ static char buf[30];
+ const char *umsg;
+
+ if (type != GRUB_HUMAN_SIZE_SPEED)
+ fsize = size * 100ULL;
+ else
+ fsize = size;
+
+ /* Since 2^64 / 1024^5 < 102400, this can give at most 5 iterations.
+ So units <=5, so impossible to go past the end of array.
+ */
+ while (fsize >= 102400)
+ {
+ fsize = (fsize + 512) / 1024;
+ units++;
+ }
+
+ umsg = _(grub_human_sizes[type][units]);
+
+ if (units || type == GRUB_HUMAN_SIZE_SPEED)
+ {
+ grub_uint64_t whole, fraction;
+
+ whole = grub_divmod64 (fsize, 100, &fraction);
+ grub_snprintf (buf, sizeof (buf),
+ "%" PRIuGRUB_UINT64_T
+ ".%02" PRIuGRUB_UINT64_T "%s", whole, fraction,
+ umsg);
+ }
+ else
+ grub_snprintf (buf, sizeof (buf), "%llu%s", (unsigned long long) size,
+ umsg);
+ return buf;
+}
+
+/* Print the information on the device NAME. */
+grub_err_t
+grub_normal_print_device_info (const char *name)
+{
+ grub_device_t dev;
+ char *p;
+
+ p = grub_strchr (name, ',');
+ if (p)
+ {
+ grub_xputs ("\t");
+ grub_printf_ (N_("Partition %s:"), name);
+ grub_xputs (" ");
+ }
+ else
+ {
+ grub_printf_ (N_("Device %s:"), name);
+ grub_xputs (" ");
+ }
+
+ dev = grub_device_open (name);
+ if (! dev)
+ grub_printf ("%s", _("Filesystem cannot be accessed"));
+ else if (dev->disk)
+ {
+ grub_fs_t fs;
+
+ fs = grub_fs_probe (dev);
+ /* Ignore all errors. */
+ grub_errno = 0;
+
+ if (fs)
+ {
+ const char *fsname = fs->name;
+ if (grub_strcmp (fsname, "ext2") == 0)
+ fsname = "ext*";
+ grub_printf_ (N_("Filesystem type %s"), fsname);
+ if (fs->fs_label)
+ {
+ char *label;
+ (fs->fs_label) (dev, &label);
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ if (label && grub_strlen (label))
+ {
+ grub_xputs (" ");
+ grub_printf_ (N_("- Label `%s'"), label);
+ }
+ grub_free (label);
+ }
+ grub_errno = GRUB_ERR_NONE;
+ }
+ if (fs->fs_mtime)
+ {
+ grub_int64_t tm;
+ struct grub_datetime datetime;
+ (fs->fs_mtime) (dev, &tm);
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ grub_unixtime2datetime (tm, &datetime);
+ grub_xputs (" ");
+ /* TRANSLATORS: Arguments are year, month, day, hour, minute,
+ second, day of the week (translated). */
+ grub_printf_ (N_("- Last modification time %d-%02d-%02d "
+ "%02d:%02d:%02d %s"),
+ datetime.year, datetime.month, datetime.day,
+ datetime.hour, datetime.minute, datetime.second,
+ grub_get_weekday_name (&datetime));
+
+ }
+ grub_errno = GRUB_ERR_NONE;
+ }
+ if (fs->fs_uuid)
+ {
+ char *uuid;
+ (fs->fs_uuid) (dev, &uuid);
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ if (uuid && grub_strlen (uuid))
+ grub_printf (", UUID %s", uuid);
+ grub_free (uuid);
+ }
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+ else
+ grub_printf ("%s", _("No known filesystem detected"));
+
+ if (dev->disk->partition)
+ grub_printf (_(" - Partition start at %llu%sKiB"),
+ (unsigned long long) (grub_partition_get_start (dev->disk->partition) >> 1),
+ (grub_partition_get_start (dev->disk->partition) & 1) ? ".5" : "" );
+ else
+ grub_printf_ (N_(" - Sector size %uB"), 1 << dev->disk->log_sector_size);
+ if (grub_disk_native_sectors (dev->disk) == GRUB_DISK_SIZE_UNKNOWN)
+ grub_puts_ (N_(" - Total size unknown"));
+ else
+ grub_printf (_(" - Total size %llu%sKiB"),
+ (unsigned long long) (grub_disk_native_sectors (dev->disk) >> 1),
+ /* TRANSLATORS: Replace dot with appropriate decimal separator for
+ your language. */
+ (grub_disk_native_sectors (dev->disk) & 1) ? _(".5") : "");
+ }
+
+ 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
new file mode 100644
index 0000000..cc8c173
--- /dev/null
+++ b/grub-core/normal/term.c
@@ -0,0 +1,1098 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/file.h>
+#include <grub/dl.h>
+#include <grub/env.h>
+#include <grub/normal.h>
+#include <grub/charset.h>
+#include <grub/i18n.h>
+
+struct term_state
+{
+ struct term_state *next;
+ struct grub_unicode_glyph *backlog_glyphs;
+ const grub_uint32_t *backlog_ucs4;
+ int backlog_fixed_tab;
+ grub_size_t backlog_len;
+
+ int bidi_stack_depth;
+ grub_uint8_t bidi_stack[GRUB_BIDI_MAX_EXPLICIT_LEVEL];
+ int invalid_pushes;
+
+ void *free;
+ int num_lines;
+ char *term_name;
+};
+
+static int
+print_ucs4_real (const grub_uint32_t * str,
+ const grub_uint32_t * last_position,
+ int margin_left, int margin_right,
+ struct grub_term_output *term, int backlog,
+ int dry_run, int fixed_tab, unsigned skip_lines,
+ unsigned max_lines,
+ grub_uint32_t contchar, int fill_right,
+ struct grub_term_pos *pos);
+
+static struct term_state *term_states = NULL;
+
+/* If the more pager is active. */
+static int grub_more;
+
+static void
+putcode_real (grub_uint32_t code, struct grub_term_output *term, int fixed_tab);
+
+void
+grub_normal_reset_more (void)
+{
+ static struct term_state *state;
+ for (state = term_states; state; state = state->next)
+ state->num_lines = 0;
+}
+
+static void
+print_more (void)
+{
+ char key;
+ struct grub_term_coordinate *pos;
+ grub_term_output_t term;
+ grub_uint32_t *unicode_str, *unicode_last_position;
+
+ /* 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,
+ &unicode_last_position);
+
+ if (!unicode_str)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ pos = grub_term_save_pos ();
+
+ grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ grub_print_ucs4 (unicode_str, unicode_last_position, 0, 0, term);
+ }
+ grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
+
+ grub_free (unicode_str);
+
+ key = grub_getkey ();
+
+ /* Remove the message. */
+ grub_term_restore_pos (pos);
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ grub_print_spaces (term, 8);
+ grub_term_restore_pos (pos);
+ grub_free (pos);
+
+ /* Scroll one line or an entire page, depending on the key. */
+
+ if (key == '\r' || key =='\n')
+ {
+ static struct term_state *state;
+ for (state = term_states; state; state = state->next)
+ state->num_lines--;
+ }
+ else
+ grub_normal_reset_more ();
+}
+
+void
+grub_set_more (int onoff)
+{
+ grub_more = !!onoff;
+ grub_normal_reset_more ();
+}
+
+enum
+ {
+ GRUB_CP437_UPDOWNARROW = 0x12,
+ GRUB_CP437_UPARROW = 0x18,
+ GRUB_CP437_DOWNARROW = 0x19,
+ GRUB_CP437_RIGHTARROW = 0x1a,
+ GRUB_CP437_LEFTARROW = 0x1b,
+ GRUB_CP437_VLINE = 0xb3,
+ GRUB_CP437_CORNER_UR = 0xbf,
+ GRUB_CP437_CORNER_LL = 0xc0,
+ GRUB_CP437_HLINE = 0xc4,
+ GRUB_CP437_CORNER_LR = 0xd9,
+ GRUB_CP437_CORNER_UL = 0xda,
+ };
+
+static grub_uint32_t
+map_code (grub_uint32_t in, struct grub_term_output *term)
+{
+ if (in <= 0x7f)
+ return in;
+
+ switch (term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ {
+ case GRUB_TERM_CODE_TYPE_CP437:
+ switch (in)
+ {
+ case GRUB_UNICODE_LEFTARROW:
+ return GRUB_CP437_LEFTARROW;
+ case GRUB_UNICODE_UPARROW:
+ return GRUB_CP437_UPARROW;
+ case GRUB_UNICODE_UPDOWNARROW:
+ return GRUB_CP437_UPDOWNARROW;
+ case GRUB_UNICODE_RIGHTARROW:
+ return GRUB_CP437_RIGHTARROW;
+ case GRUB_UNICODE_DOWNARROW:
+ return GRUB_CP437_DOWNARROW;
+ case GRUB_UNICODE_HLINE:
+ return GRUB_CP437_HLINE;
+ case GRUB_UNICODE_VLINE:
+ return GRUB_CP437_VLINE;
+ case GRUB_UNICODE_CORNER_UL:
+ return GRUB_CP437_CORNER_UL;
+ case GRUB_UNICODE_CORNER_UR:
+ return GRUB_CP437_CORNER_UR;
+ case GRUB_UNICODE_CORNER_LL:
+ return GRUB_CP437_CORNER_LL;
+ case GRUB_UNICODE_CORNER_LR:
+ return GRUB_CP437_CORNER_LR;
+ }
+ return '?';
+ case GRUB_TERM_CODE_TYPE_ASCII:
+ /* Better than nothing. */
+ switch (in)
+ {
+ case GRUB_UNICODE_LEFTARROW:
+ return '<';
+
+ case GRUB_UNICODE_UPARROW:
+ return '^';
+
+ case GRUB_UNICODE_RIGHTARROW:
+ return '>';
+
+ case GRUB_UNICODE_DOWNARROW:
+ return 'v';
+
+ case GRUB_UNICODE_HLINE:
+ return '-';
+
+ case GRUB_UNICODE_VLINE:
+ return '|';
+
+ case GRUB_UNICODE_CORNER_UL:
+ case GRUB_UNICODE_CORNER_UR:
+ case GRUB_UNICODE_CORNER_LL:
+ case GRUB_UNICODE_CORNER_LR:
+ return '+';
+
+ }
+ return '?';
+ }
+ return in;
+}
+
+void
+grub_puts_terminal (const char *str, struct grub_term_output *term)
+{
+ grub_uint32_t *unicode_str, *unicode_last_position;
+ grub_error_push ();
+ grub_utf8_to_ucs4_alloc (str, &unicode_str,
+ &unicode_last_position);
+ grub_error_pop ();
+ if (!unicode_str)
+ {
+ for (; *str; str++)
+ {
+ struct grub_unicode_glyph c =
+ {
+ .variant = 0,
+ .attributes = 0,
+ .ncomb = 0,
+ .estimated_width = 1,
+ .base = *str
+ };
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ (term->putchar) (term, &c);
+ }
+ if (*str == '\n')
+ {
+ c.base = '\r';
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ (term->putchar) (term, &c);
+ }
+ }
+ }
+ return;
+ }
+
+ print_ucs4_real (unicode_str, unicode_last_position, 0, 0, term,
+ 0, 0, 0, 0, -1, 0, 0, 0);
+ grub_free (unicode_str);
+}
+
+struct grub_term_coordinate *
+grub_term_save_pos (void)
+{
+ struct grub_term_output *cur;
+ unsigned cnt = 0;
+ struct grub_term_coordinate *ret, *ptr;
+
+ FOR_ACTIVE_TERM_OUTPUTS(cur)
+ cnt++;
+
+ ret = grub_calloc (cnt, sizeof (ret[0]));
+ if (!ret)
+ return NULL;
+
+ ptr = ret;
+ FOR_ACTIVE_TERM_OUTPUTS(cur)
+ *ptr++ = grub_term_getxy (cur);
+
+ return ret;
+}
+
+void
+grub_term_restore_pos (struct grub_term_coordinate *pos)
+{
+ struct grub_term_output *cur;
+ struct grub_term_coordinate *ptr = pos;
+
+ if (!pos)
+ return;
+
+ FOR_ACTIVE_TERM_OUTPUTS(cur)
+ {
+ grub_term_gotoxy (cur, *ptr);
+ ptr++;
+ }
+}
+
+static void
+grub_terminal_autoload_free (void)
+{
+ struct grub_term_autoload *cur, *next;
+ unsigned i;
+ for (i = 0; i < 2; i++)
+ for (cur = i ? grub_term_input_autoload : grub_term_output_autoload;
+ cur; cur = next)
+ {
+ next = cur->next;
+ grub_free (cur->name);
+ grub_free (cur->modname);
+ grub_free (cur);
+ }
+ grub_term_input_autoload = NULL;
+ grub_term_output_autoload = NULL;
+}
+
+/* Read the file terminal.lst for auto-loading. */
+void
+read_terminal_list (const char *prefix)
+{
+ char *filename;
+ grub_file_t file;
+ char *buf = NULL;
+
+ if (!prefix)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM
+ "/terminal.lst", prefix);
+ if (!filename)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE_LIST);
+ grub_free (filename);
+ if (!file)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ /* Override previous terminal.lst. */
+ grub_terminal_autoload_free ();
+
+ for (;; grub_free (buf))
+ {
+ char *p, *name;
+ struct grub_term_autoload *cur;
+ struct grub_term_autoload **target = NULL;
+
+ buf = grub_file_getline (file);
+
+ if (! buf)
+ break;
+
+ p = buf;
+ while (grub_isspace (p[0]))
+ p++;
+
+ switch (p[0])
+ {
+ case 'i':
+ target = &grub_term_input_autoload;
+ break;
+
+ case 'o':
+ target = &grub_term_output_autoload;
+ break;
+ }
+ if (!target)
+ continue;
+
+ name = p + 1;
+
+ p = grub_strchr (name, ':');
+ if (! p)
+ continue;
+ *p = 0;
+
+ p++;
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ cur = grub_malloc (sizeof (*cur));
+ if (!cur)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ cur->name = grub_strdup (name);
+ if (! cur->name)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_free (cur);
+ continue;
+ }
+
+ cur->modname = grub_strdup (p);
+ if (! cur->modname)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_free (cur->name);
+ grub_free (cur);
+ continue;
+ }
+ cur->next = *target;
+ *target = cur;
+ }
+
+ grub_file_close (file);
+
+ grub_errno = GRUB_ERR_NONE;
+}
+
+static void
+putglyph (const struct grub_unicode_glyph *c, struct grub_term_output *term,
+ int fixed_tab)
+{
+ struct grub_unicode_glyph c2 =
+ {
+ .variant = 0,
+ .attributes = 0,
+ .ncomb = 0,
+ .estimated_width = 1
+ };
+
+ if (c->base == '\t' && fixed_tab)
+ {
+ int n;
+
+ n = GRUB_TERM_TAB_WIDTH;
+ c2.base = ' ';
+ while (n--)
+ (term->putchar) (term, &c2);
+
+ return;
+ }
+
+ if (c->base == '\t' && term->getxy)
+ {
+ int n;
+
+ n = GRUB_TERM_TAB_WIDTH - ((term->getxy (term).x)
+ % GRUB_TERM_TAB_WIDTH);
+ c2.base = ' ';
+ while (n--)
+ (term->putchar) (term, &c2);
+
+ return;
+ }
+
+ if ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ == GRUB_TERM_CODE_TYPE_UTF8_LOGICAL
+ || (term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ == GRUB_TERM_CODE_TYPE_UTF8_VISUAL)
+ {
+ int i;
+ c2.estimated_width = grub_term_getcharwidth (term, c);
+ for (i = -1; i < (int) c->ncomb; i++)
+ {
+ grub_uint8_t u8[20], *ptr;
+ grub_uint32_t code;
+
+ if (i == -1)
+ {
+ code = c->base;
+ if ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ == GRUB_TERM_CODE_TYPE_UTF8_VISUAL)
+ {
+ if ((c->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR))
+ code = grub_unicode_mirror_code (code);
+ code = grub_unicode_shape_code (code, c->attributes);
+ }
+ }
+ else
+ code = grub_unicode_get_comb (c) [i].code;
+
+ grub_ucs4_to_utf8 (&code, 1, u8, sizeof (u8));
+
+ for (ptr = u8; *ptr; ptr++)
+ {
+ c2.base = *ptr;
+ (term->putchar) (term, &c2);
+ c2.estimated_width = 0;
+ }
+ }
+ c2.estimated_width = 1;
+ }
+ else
+ (term->putchar) (term, c);
+
+ if (c->base == '\n')
+ {
+ c2.base = '\r';
+ (term->putchar) (term, &c2);
+ }
+}
+
+static void
+putcode_real (grub_uint32_t code, struct grub_term_output *term, int fixed_tab)
+{
+ struct grub_unicode_glyph c =
+ {
+ .variant = 0,
+ .attributes = 0,
+ .ncomb = 0,
+ .estimated_width = 1
+ };
+
+ c.base = map_code (code, term);
+ putglyph (&c, term, fixed_tab);
+}
+
+/* Put a Unicode character. */
+void
+grub_putcode (grub_uint32_t code, struct grub_term_output *term)
+{
+ /* Combining character by itself? */
+ if (grub_unicode_get_comb_type (code) != GRUB_UNICODE_COMB_NONE)
+ return;
+
+ putcode_real (code, term, 0);
+}
+
+static grub_ssize_t
+get_maxwidth (struct grub_term_output *term,
+ int margin_left, int margin_right)
+{
+ struct grub_unicode_glyph space_glyph = {
+ .base = ' ',
+ .variant = 0,
+ .attributes = 0,
+ .ncomb = 0,
+ };
+ return (grub_term_width (term)
+ - grub_term_getcharwidth (term, &space_glyph)
+ * (margin_left + margin_right) - 1);
+}
+
+static grub_ssize_t
+get_startwidth (struct grub_term_output *term,
+ int margin_left)
+{
+ return (term->getxy (term).x) - margin_left;
+}
+
+static void
+fill_margin (struct grub_term_output *term, int r)
+{
+ int sp = (term->getwh (term).x)
+ - (term->getxy (term).x) - r;
+ if (sp > 0)
+ grub_print_spaces (term, sp);
+}
+
+static int
+print_ucs4_terminal (const grub_uint32_t * str,
+ const grub_uint32_t * last_position,
+ int margin_left, int margin_right,
+ struct grub_term_output *term,
+ struct term_state *state,
+ int dry_run, int fixed_tab, unsigned skip_lines,
+ unsigned max_lines,
+ grub_uint32_t contchar,
+ int primitive_wrap, int fill_right, struct grub_term_pos *pos)
+{
+ const grub_uint32_t *ptr;
+ grub_ssize_t startwidth = dry_run ? 0 : get_startwidth (term, margin_left);
+ grub_ssize_t line_width = startwidth;
+ grub_ssize_t lastspacewidth = 0;
+ grub_ssize_t max_width = get_maxwidth (term, margin_left, margin_right);
+ const grub_uint32_t *line_start = str, *last_space = str - 1;
+ int lines = 0;
+ int i;
+ struct term_state local_state;
+
+ if (!state)
+ {
+ grub_memset (&local_state, 0, sizeof (local_state));
+ state = &local_state;
+ }
+
+ for (i = 0; i < state->bidi_stack_depth; i++)
+ putcode_real (state->bidi_stack[i] | (GRUB_UNICODE_LRE & ~0xff),
+ term, fixed_tab);
+
+ for (ptr = str; ptr < last_position; ptr++)
+ {
+ grub_ssize_t last_width = 0;
+
+ switch (*ptr)
+ {
+ case GRUB_UNICODE_LRE:
+ case GRUB_UNICODE_RLE:
+ case GRUB_UNICODE_LRO:
+ case GRUB_UNICODE_RLO:
+ if (state->bidi_stack_depth >= (int) ARRAY_SIZE (state->bidi_stack))
+ state->invalid_pushes++;
+ else
+ state->bidi_stack[state->bidi_stack_depth++] = *ptr;
+ break;
+ case GRUB_UNICODE_PDF:
+ if (state->invalid_pushes)
+ state->invalid_pushes--;
+ else if (state->bidi_stack_depth)
+ state->bidi_stack_depth--;
+ break;
+ }
+ if (grub_unicode_get_comb_type (*ptr) == GRUB_UNICODE_COMB_NONE)
+ {
+ struct grub_unicode_glyph c = {
+ .variant = 0,
+ .attributes = 0,
+ .ncomb = 0,
+ };
+ c.base = *ptr;
+ if (pos)
+ {
+ pos[ptr - str].x = line_width;
+ pos[ptr - str].y = lines;
+ pos[ptr - str].valid = 1;
+ }
+ line_width += last_width = grub_term_getcharwidth (term, &c);
+ }
+
+ if (*ptr == ' ' && !primitive_wrap)
+ {
+ lastspacewidth = line_width;
+ last_space = ptr;
+ }
+
+ if (line_width > max_width || *ptr == '\n')
+ {
+ const grub_uint32_t *ptr2;
+ int wasn = (*ptr == '\n');
+
+ if (wasn)
+ {
+ state->bidi_stack_depth = 0;
+ state->invalid_pushes = 0;
+ }
+
+ if (line_width > max_width && last_space > line_start)
+ ptr = last_space;
+ else if (line_width > max_width
+ && line_start == str && line_width - lastspacewidth < max_width - 5)
+ {
+ ptr = str;
+ lastspacewidth = startwidth;
+ }
+ else
+ lastspacewidth = line_width - last_width;
+
+ lines++;
+
+ if (!skip_lines && !dry_run)
+ {
+ for (ptr2 = line_start; ptr2 < ptr; ptr2++)
+ {
+ /* Skip combining characters on non-UTF8 terminals. */
+ if ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ != GRUB_TERM_CODE_TYPE_UTF8_LOGICAL
+ && grub_unicode_get_comb_type (*ptr2)
+ != GRUB_UNICODE_COMB_NONE)
+ continue;
+ putcode_real (*ptr2, term, fixed_tab);
+ }
+
+ if (!wasn && contchar)
+ putcode_real (contchar, term, fixed_tab);
+ if (fill_right)
+ fill_margin (term, margin_right);
+
+ if (!contchar || max_lines != 1)
+ grub_putcode ('\n', term);
+ if (state != &local_state && ++state->num_lines
+ >= (grub_ssize_t) grub_term_height (term) - 2)
+ {
+ state->backlog_ucs4 = (ptr == last_space || *ptr == '\n')
+ ? ptr + 1 : ptr;
+ state->backlog_len = last_position - state->backlog_ucs4;
+ state->backlog_fixed_tab = fixed_tab;
+ return 1;
+ }
+ }
+
+ line_width -= lastspacewidth;
+ if (ptr == last_space || *ptr == '\n')
+ ptr++;
+ else if (pos)
+ {
+ pos[ptr - str].x = line_width - last_width;
+ pos[ptr - str].y = lines;
+ pos[ptr - str].valid = 1;
+ }
+
+ line_start = ptr;
+
+ if (skip_lines)
+ skip_lines--;
+ else if (max_lines != (unsigned) -1)
+ {
+ max_lines--;
+ if (!max_lines)
+ break;
+ }
+ if (!skip_lines && !dry_run)
+ {
+ if (!contchar)
+ grub_print_spaces (term, margin_left);
+ else
+ grub_term_gotoxy (term, (struct grub_term_coordinate)
+ { margin_left, grub_term_getxy (term).y });
+ for (i = 0; i < state->bidi_stack_depth; i++)
+ putcode_real (state->bidi_stack[i] | (GRUB_UNICODE_LRE & ~0xff),
+ term, fixed_tab);
+ }
+ }
+ }
+
+ if (pos)
+ {
+ pos[ptr - str].x = line_width;
+ pos[ptr - str].y = lines;
+ pos[ptr - str].valid = 1;
+ }
+
+ if (line_start < last_position)
+ lines++;
+ if (!dry_run && !skip_lines && max_lines)
+ {
+ const grub_uint32_t *ptr2;
+
+ for (ptr2 = line_start; ptr2 < last_position; ptr2++)
+ {
+ /* Skip combining characters on non-UTF8 terminals. */
+ if ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ != GRUB_TERM_CODE_TYPE_UTF8_LOGICAL
+ && grub_unicode_get_comb_type (*ptr2)
+ != GRUB_UNICODE_COMB_NONE)
+ continue;
+ putcode_real (*ptr2, term, fixed_tab);
+ }
+
+ if (fill_right)
+ fill_margin (term, margin_right);
+ }
+ return dry_run ? lines : 0;
+}
+
+static struct term_state *
+find_term_state (struct grub_term_output *term)
+{
+ struct term_state *state;
+ for (state = term_states; state; state = state->next)
+ if (grub_strcmp (state->term_name, term->name) == 0)
+ return state;
+
+ state = grub_zalloc (sizeof (*state));
+ if (!state)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return NULL;
+ }
+
+ state->term_name = grub_strdup (term->name);
+ state->next = term_states;
+ term_states = state;
+
+ return state;
+}
+
+static int
+put_glyphs_terminal (struct grub_unicode_glyph *visual,
+ grub_ssize_t visual_len,
+ int margin_left, int margin_right,
+ struct grub_term_output *term,
+ struct term_state *state, int fixed_tab,
+ grub_uint32_t contchar,
+ int fill_right)
+{
+ struct grub_unicode_glyph *visual_ptr;
+ int since_last_nl = 1;
+ for (visual_ptr = visual; visual_ptr < visual + visual_len; visual_ptr++)
+ {
+ if (visual_ptr->base == '\n' && fill_right)
+ fill_margin (term, margin_right);
+
+ putglyph (visual_ptr, term, fixed_tab);
+ since_last_nl++;
+ if (visual_ptr->base == '\n')
+ {
+ since_last_nl = 0;
+ if (state && ++state->num_lines
+ >= (grub_ssize_t) grub_term_height (term) - 2)
+ {
+ state->backlog_glyphs = visual_ptr + 1;
+ state->backlog_len = visual_len - (visual_ptr - visual) - 1;
+ state->backlog_fixed_tab = fixed_tab;
+ return 1;
+ }
+
+ if (!contchar)
+ grub_print_spaces (term, margin_left);
+ else
+ grub_term_gotoxy (term,
+ (struct grub_term_coordinate)
+ { margin_left, grub_term_getxy (term).y });
+ }
+ grub_unicode_destroy_glyph (visual_ptr);
+ }
+ if (fill_right && since_last_nl)
+ fill_margin (term, margin_right);
+
+ return 0;
+}
+
+static int
+print_backlog (struct grub_term_output *term,
+ int margin_left, int margin_right)
+{
+ struct term_state *state = find_term_state (term);
+
+ if (!state)
+ return 0;
+
+ if (state->backlog_ucs4)
+ {
+ int ret;
+ ret = print_ucs4_terminal (state->backlog_ucs4,
+ state->backlog_ucs4 + state->backlog_len,
+ margin_left, margin_right, term, state, 0,
+ state->backlog_fixed_tab, 0, -1, 0, 0,
+ 0, 0);
+ if (!ret)
+ {
+ grub_free (state->free);
+ state->free = NULL;
+ state->backlog_len = 0;
+ state->backlog_ucs4 = 0;
+ }
+ return ret;
+ }
+
+ if (state->backlog_glyphs)
+ {
+ int ret;
+ ret = put_glyphs_terminal (state->backlog_glyphs,
+ state->backlog_len,
+ margin_left, margin_right, term, state,
+ state->backlog_fixed_tab, 0, 0);
+ if (!ret)
+ {
+ grub_free (state->free);
+ state->free = NULL;
+ state->backlog_len = 0;
+ state->backlog_glyphs = 0;
+ }
+ return ret;
+ }
+
+ return 0;
+}
+
+static grub_size_t
+getcharwidth (const struct grub_unicode_glyph *c, void *term)
+{
+ return grub_term_getcharwidth (term, c);
+}
+
+static int
+print_ucs4_real (const grub_uint32_t * str,
+ const grub_uint32_t * last_position,
+ int margin_left, int margin_right,
+ struct grub_term_output *term, int backlog,
+ int dry_run, int fixed_tab, unsigned skip_lines,
+ unsigned max_lines,
+ grub_uint32_t contchar, int fill_right,
+ struct grub_term_pos *pos)
+{
+ struct term_state *state = NULL;
+
+ if (!dry_run)
+ {
+ struct grub_term_coordinate xy;
+ if (backlog)
+ state = find_term_state (term);
+
+ xy = term->getxy (term);
+
+ if (xy.x < margin_left)
+ {
+ if (!contchar)
+ grub_print_spaces (term, margin_left - xy.x);
+ else
+ grub_term_gotoxy (term, (struct grub_term_coordinate) {margin_left,
+ xy.y});
+ }
+ }
+
+ if ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ == GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS
+ || (term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ == GRUB_TERM_CODE_TYPE_UTF8_VISUAL)
+ {
+ grub_ssize_t visual_len;
+ struct grub_unicode_glyph *visual;
+ grub_ssize_t visual_len_show;
+ struct grub_unicode_glyph *visual_show;
+ int ret;
+ struct grub_unicode_glyph *vptr;
+
+ visual_len = grub_bidi_logical_to_visual (str, last_position - str,
+ &visual, getcharwidth, term,
+ get_maxwidth (term,
+ margin_left,
+ margin_right),
+ dry_run ? 0 : get_startwidth (term,
+ margin_left),
+ contchar, pos, !!contchar);
+ if (visual_len < 0)
+ {
+ grub_print_error ();
+ return 0;
+ }
+ visual_show = visual;
+ for (; skip_lines && visual_show < visual + visual_len; visual_show++)
+ if (visual_show->base == '\n')
+ skip_lines--;
+ if (max_lines != (unsigned) -1)
+ {
+ for (vptr = visual_show;
+ max_lines && vptr < visual + visual_len; vptr++)
+ if (vptr->base == '\n')
+ max_lines--;
+
+ visual_len_show = vptr - visual_show;
+ }
+ else
+ visual_len_show = visual + visual_len - visual_show;
+
+ if (dry_run)
+ {
+ ret = 0;
+ for (vptr = visual_show; vptr < visual_show + visual_len_show; vptr++)
+ if (vptr->base == '\n')
+ ret++;
+ if (visual_len_show && visual[visual_len_show - 1].base != '\n')
+ ret++;
+ for (vptr = visual; vptr < visual + visual_len; vptr++)
+ grub_unicode_destroy_glyph (vptr);
+ grub_free (visual);
+ }
+ else
+ {
+ ret = put_glyphs_terminal (visual_show, visual_len_show, margin_left,
+ margin_right,
+ term, state, fixed_tab, contchar, fill_right);
+
+ if (!ret)
+ grub_free (visual);
+ else
+ state->free = visual;
+ }
+ return ret;
+ }
+ return print_ucs4_terminal (str, last_position, margin_left, margin_right,
+ term, state, dry_run, fixed_tab, skip_lines,
+ max_lines, contchar, !!contchar, fill_right, pos);
+}
+
+void
+grub_print_ucs4_menu (const grub_uint32_t * str,
+ const grub_uint32_t * last_position,
+ int margin_left, int margin_right,
+ struct grub_term_output *term,
+ int skip_lines, int max_lines,
+ grub_uint32_t contchar,
+ struct grub_term_pos *pos)
+{
+ print_ucs4_real (str, last_position, margin_left, margin_right,
+ term, 0, 0, 1, skip_lines, max_lines,
+ contchar, 1, pos);
+}
+
+void
+grub_print_ucs4 (const grub_uint32_t * str,
+ const grub_uint32_t * last_position,
+ int margin_left, int margin_right,
+ struct grub_term_output *term)
+{
+ print_ucs4_real (str, last_position, margin_left, margin_right,
+ term, 0, 0, 1, 0, -1, 0, 0, 0);
+}
+
+int
+grub_ucs4_count_lines (const grub_uint32_t * str,
+ const grub_uint32_t * last_position,
+ int margin_left, int margin_right,
+ struct grub_term_output *term)
+{
+ return print_ucs4_real (str, last_position, margin_left, margin_right,
+ term, 0, 1, 1, 0, -1, 0, 0, 0);
+}
+
+void
+grub_xnputs (const char *str, grub_size_t msg_len)
+{
+ grub_uint32_t *unicode_str = NULL, *unicode_last_position;
+ int backlog = 0;
+ grub_term_output_t term;
+
+ grub_error_push ();
+
+ unicode_str = grub_calloc (msg_len, sizeof (grub_uint32_t));
+
+ grub_error_pop ();
+
+ if (!unicode_str)
+ {
+ for (; msg_len--; str++, msg_len++)
+ {
+ struct grub_unicode_glyph c =
+ {
+ .variant = 0,
+ .attributes = 0,
+ .ncomb = 0,
+ .estimated_width = 1,
+ .base = *str
+ };
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ (term->putchar) (term, &c);
+ }
+ if (*str == '\n')
+ {
+ c.base = '\r';
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ (term->putchar) (term, &c);
+ }
+ }
+ }
+
+ return;
+ }
+
+ msg_len = grub_utf8_to_ucs4 (unicode_str, msg_len,
+ (grub_uint8_t *) str, -1, 0);
+ unicode_last_position = unicode_str + msg_len;
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ int cur;
+ cur = print_ucs4_real (unicode_str, unicode_last_position, 0, 0,
+ term, grub_more, 0, 0, 0, -1, 0, 0, 0);
+ if (cur)
+ backlog = 1;
+ }
+ while (backlog)
+ {
+ print_more ();
+ backlog = 0;
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ int cur;
+ cur = print_backlog (term, 0, 0);
+ if (cur)
+ backlog = 1;
+ }
+ }
+ grub_free (unicode_str);
+}
+
+void
+grub_xputs_normal (const char *str)
+{
+ grub_xnputs (str, grub_strlen (str));
+}
+
+void
+grub_cls (void)
+{
+ struct grub_term_output *term;
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug")))
+ {
+ grub_putcode ('\n', term);
+ grub_term_refresh (term);
+ }
+ else
+ (term->cls) (term);
+ }
+}
diff --git a/grub-core/osdep/apple/getroot.c b/grub-core/osdep/apple/getroot.c
new file mode 100644
index 0000000..2091ded
--- /dev/null
+++ b/grub-core/osdep/apple/getroot.c
@@ -0,0 +1,109 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <grub/types.h>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+
+#include <sys/wait.h>
+
+# include <sys/disk.h>
+# include <sys/param.h>
+# include <sys/sysctl.h>
+# include <sys/mount.h>
+
+char *
+grub_util_part_to_disk (const char *os_dev, struct stat *st,
+ int *is_part)
+{
+ char *path = xstrdup (os_dev);
+
+ if (! S_ISCHR (st->st_mode))
+ {
+ *is_part = 0;
+ return path;
+ }
+
+ if (strncmp ("/dev/", path, 5) == 0)
+ {
+ char *p;
+ for (p = path + 5; *p; ++p)
+ if (grub_isdigit(*p))
+ {
+ p = strpbrk (p, "sp");
+ if (p)
+ {
+ *is_part = 1;
+ *p = '\0';
+ }
+ break;
+ }
+ }
+ return path;
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dev_abstraction_os (const char *os_dev __attribute__((unused)))
+{
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+int
+grub_util_pull_device_os (const char *os_dev __attribute__ ((unused)),
+ enum grub_dev_abstraction_types ab __attribute__ ((unused)))
+{
+ return 0;
+}
+
+char *
+grub_util_get_grub_dev_os (const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+
+grub_disk_addr_t
+grub_util_find_partition_start_os (const char *dev __attribute__ ((unused)))
+{
+ return 0;
+}
diff --git a/grub-core/osdep/apple/hostdisk.c b/grub-core/osdep/apple/hostdisk.c
new file mode 100644
index 0000000..8d9b4b4
--- /dev/null
+++ b/grub-core/osdep/apple/hostdisk.c
@@ -0,0 +1,95 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+# include <sys/disk.h>
+
+grub_int64_t
+grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_secsize)
+{
+ unsigned long long nr;
+ unsigned sector_size, log_sector_size;
+
+ if (ioctl (fd, DKIOCGETBLOCKCOUNT, &nr))
+ return -1;
+
+ if (ioctl (fd, DKIOCGETBLOCKSIZE, &sector_size))
+ return -1;
+
+ if (sector_size & (sector_size - 1) || !sector_size)
+ return -1;
+ for (log_sector_size = 0;
+ (1 << log_sector_size) < sector_size;
+ log_sector_size++);
+
+ if (log_secsize)
+ *log_secsize = log_sector_size;
+
+ return nr << log_sector_size;
+}
+
+grub_util_fd_t
+grub_util_fd_open (const char *os_dev, int flags)
+{
+ grub_util_fd_t ret;
+
+#ifdef O_LARGEFILE
+ flags |= O_LARGEFILE;
+#endif
+#ifdef O_BINARY
+ flags |= O_BINARY;
+#endif
+
+ 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_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
+
+ return ret;
+}
+
+void
+grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
+{
+}
diff --git a/grub-core/osdep/aros/config.c b/grub-core/osdep/aros/config.c
new file mode 100644
index 0000000..c82d0ea
--- /dev/null
+++ b/grub-core/osdep/aros/config.c
@@ -0,0 +1,94 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config.h>
+#include <config-util.h>
+
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/exec.h>
+#include <grub/emu/config.h>
+#include <grub/util/install.h>
+#include <grub/util/misc.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <stdlib.h>
+
+const char *
+grub_util_get_config_filename (void)
+{
+ static char *value = NULL;
+ if (!value)
+ value = grub_util_path_concat (3, GRUB_SYSCONFDIR,
+ "default", "grub");
+ return value;
+}
+
+const char *
+grub_util_get_pkgdatadir (void)
+{
+ const char *ret = getenv ("pkgdatadir");
+ if (ret)
+ return ret;
+ return GRUB_DATADIR "/" PACKAGE;
+}
+
+const char *
+grub_util_get_pkglibdir (void)
+{
+ return GRUB_LIBDIR "/" PACKAGE;
+}
+
+const char *
+grub_util_get_localedir (void)
+{
+ return LOCALEDIR;
+}
+
+void
+grub_util_load_config (struct grub_util_config *cfg)
+{
+ const char *cfgfile;
+ FILE *f = NULL;
+ const char *v;
+
+ memset (cfg, 0, sizeof (*cfg));
+
+ v = getenv ("GRUB_ENABLE_CRYPTODISK");
+ if (v && v[0] == 'y' && v[1] == '\0')
+ cfg->is_cryptodisk_enabled = 1;
+
+ v = getenv ("GRUB_DISTRIBUTOR");
+ if (v)
+ cfg->grub_distributor = xstrdup (v);
+
+ cfgfile = grub_util_get_config_filename ();
+ if (!grub_util_is_regular (cfgfile))
+ return;
+
+ f = grub_util_fopen (cfgfile, "r");
+ if (f)
+ {
+ grub_util_parse_config (f, cfg, 0);
+ fclose (f);
+ }
+ else
+ grub_util_warn (_("cannot open configuration file `%s': %s"),
+ cfgfile, strerror (errno));
+}
diff --git a/grub-core/osdep/aros/getroot.c b/grub-core/osdep/aros/getroot.c
new file mode 100644
index 0000000..a27df9e
--- /dev/null
+++ b/grub-core/osdep/aros/getroot.c
@@ -0,0 +1,228 @@
+/*
+ * 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 <config-util.h>
+#include <config.h>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+
+#include <string.h>
+#include <dos/dos.h>
+#include <dos/filesystem.h>
+#include <dos/exall.h>
+#include <proto/dos.h>
+#include <proto/exec.h>
+#include <devices/trackdisk.h>
+
+char *
+grub_util_part_to_disk (const char *dev,
+ struct stat *st __attribute__ ((unused)),
+ int *is_part)
+{
+ const char *dname;
+ char *ret;
+ struct DosList *dl;
+ struct DeviceNode *dn;
+ struct FileSysStartupMsg *fm;
+ struct DosEnvec *envec;
+
+ if (dev[0] != '/' || dev[1] != '/' || dev[2] != ':')
+ return xstrdup (dev);
+
+ dname = dev + 3;
+ dl = LockDosList(LDF_READ);
+
+ if (!dl)
+ {
+ return xstrdup (dev);
+ }
+
+ dn = (struct DeviceNode *) FindDosEntry (dl, (unsigned char *) dname,
+ LDF_DEVICES);
+ UnLockDosList (LDF_READ);
+ if (!dn)
+ return xstrdup (dev);
+
+ fm = (struct FileSysStartupMsg *) BADDR(dn->dn_Startup);
+ envec = (struct DosEnvec *) fm->fssm_Environ;
+
+ if (envec->de_LowCyl == 0)
+ return xstrdup (dev);
+
+ *is_part = 1;
+
+ ret = xasprintf ("//:%s/%lx/%lx", fm->fssm_Device, fm->fssm_Unit, (unsigned long) fm->fssm_Flags);
+
+ return ret;
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dev_abstraction_os (const char *os_dev __attribute__((unused)))
+{
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+int
+grub_util_pull_device_os (const char *os_dev __attribute__ ((unused)),
+ enum grub_dev_abstraction_types ab __attribute__ ((unused)))
+{
+ return 0;
+}
+
+char *
+grub_util_get_grub_dev_os (const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+
+grub_disk_addr_t
+grub_util_find_partition_start_os (const char *dev)
+{
+ const char *dname;
+ struct DosList *dl;
+ struct DeviceNode *dn;
+ struct FileSysStartupMsg *fm;
+ struct DosEnvec *envec;
+
+ if (dev[0] != '/' || dev[1] != '/' || dev[2] != ':')
+ return 0;
+
+ dname = dev + 3;
+ dl = LockDosList(LDF_READ);
+ if (!dl)
+ {
+ return 0;
+ }
+ dn = (struct DeviceNode *) FindDosEntry (dl, (unsigned char *) dname,
+ LDF_DEVICES);
+ UnLockDosList (LDF_READ);
+ if (!dn)
+ return 0;
+
+ fm = (struct FileSysStartupMsg *) BADDR(dn->dn_Startup);
+ envec = (struct DosEnvec *) fm->fssm_Environ;
+
+ return (((grub_uint64_t) envec->de_Surfaces
+ * (grub_uint64_t) envec->de_BlocksPerTrack
+ * (grub_uint64_t) envec->de_LowCyl)
+ * (grub_uint64_t) envec->de_SizeBlock) >> 7;
+}
+
+char **
+grub_guess_root_devices (const char *path)
+{
+ char **os_dev = NULL;
+ struct InfoData id;
+ BPTR lck;
+ struct DeviceList *dl;
+ struct DosList *dl2;
+ size_t sz;
+ const char *nm;
+
+ lck = Lock ((const unsigned char *) path, SHARED_LOCK);
+ if (!lck)
+ grub_util_info ("Lock(%s) failed", path);
+ if (!lck || !Info (lck, &id))
+ {
+ char *p;
+ if (lck)
+ UnLock (lck);
+ grub_util_info ("Info(%s) failed", path);
+ os_dev = xmalloc (2 * sizeof (os_dev[0]));
+ sz = strlen (path);
+ os_dev[0] = xmalloc (sz + 5);
+ os_dev[0][0] = '/';
+ os_dev[0][1] = '/';
+ os_dev[0][2] = ':';
+ memcpy (os_dev[0] + 3, path, sz);
+ os_dev[0][sz + 3] = ':';
+ os_dev[0][sz + 4] = '\0';
+ p = strchr (os_dev[0] + 3, ':');
+ *p = '\0';
+ os_dev[1] = NULL;
+ return os_dev;
+ }
+ dl = BADDR (id.id_VolumeNode);
+
+ if (!dl->dl_Task)
+ grub_util_error ("unsupported device %s", dl->dl_Name);
+
+ grub_util_info ("dl=%p, dl->dl_Name=%s, dl->dl_Task=%p",
+ dl, dl->dl_Name,
+ dl->dl_Task);
+
+ for (dl2 = LockDosList(LDF_READ | LDF_DEVICES);
+ dl2;
+ dl2 = NextDosEntry (dl2, LDF_DEVICES))
+ {
+ if (dl2->dol_Task == dl->dl_Task)
+ break;
+ }
+
+ if (lck)
+ UnLock (lck);
+
+ if (dl2)
+ nm = (char *) dl2->dol_Name;
+ else
+ nm = (char *) dl->dl_Name;
+
+ grub_util_info ("dl2=%p, nm=%s", dl2, nm);
+
+ os_dev = xmalloc (2 * sizeof (os_dev[0]));
+ sz = strlen (nm);
+
+ os_dev[0] = xmalloc (sz + 4);
+ os_dev[0][0] = '/';
+ os_dev[0][1] = '/';
+ os_dev[0][2] = ':';
+ memcpy (os_dev[0] + 3, nm, sz);
+ os_dev[0][sz+3] = '\0';
+ os_dev[1] = NULL;
+
+ UnLockDosList (LDF_READ | LDF_DEVICES);
+
+ return os_dev;
+}
+
+int
+grub_util_biosdisk_is_floppy (grub_disk_t disk)
+{
+ const char *dname;
+
+ dname = grub_util_biosdisk_get_osdev (disk);
+
+ if (dname[0] != '/' || dname[1] != '/' || dname[2] != ':')
+ return 0;
+
+ dname += 3;
+
+ if (strncmp (dname, TD_NAME, sizeof (TD_NAME) - 1) == 0
+ && (TD_NAME[sizeof (TD_NAME) - 1] == '/'
+ || TD_NAME[sizeof (TD_NAME) - 1] == '\0'))
+ return 1;
+ return 0;
+}
+
diff --git a/grub-core/osdep/aros/hostdisk.c b/grub-core/osdep/aros/hostdisk.c
new file mode 100644
index 0000000..3b2c9de
--- /dev/null
+++ b/grub-core/osdep/aros/hostdisk.c
@@ -0,0 +1,617 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+#include <time.h>
+
+#include <string.h>
+#include <dos/dos.h>
+#include <dos/filesystem.h>
+#include <dos/exall.h>
+#include <proto/dos.h>
+#include <devices/hardblocks.h>
+#include <devices/newstyle.h>
+#include <proto/exec.h>
+#include <proto/utility.h>
+#include <proto/partition.h>
+#include <devices/trackdisk.h>
+#include <exec/errors.h>
+
+#define BOUNCE_SIZE 1048576
+
+static ULONG *bounce;
+
+char *
+grub_canonicalize_file_name (const char *path)
+{
+ char *ret;
+ BPTR lck;
+
+ if (path[0] == '/' && path[1] == '/' && path[2] == ':')
+ return xstrdup (path);
+
+ ret = xmalloc (2048);
+ lck = Lock ((const unsigned char *) path, SHARED_LOCK);
+
+ if (!lck || !NameFromLock (lck, (unsigned char *) ret, 2040))
+ {
+ free (ret);
+ ret = xstrdup (path);
+ }
+ if (lck)
+ UnLock (lck);
+
+ return ret;
+}
+
+static grub_uint64_t
+grub_util_get_fd_size_volume (grub_util_fd_t fd __attribute__ ((unused)),
+ const char *dev,
+ unsigned *log_secsize)
+{
+ struct DriveGeometry *geo;
+ LONG err;
+ unsigned sector_size, log_sector_size;
+
+ if (!bounce)
+ bounce = AllocVec (BOUNCE_SIZE, MEMF_PUBLIC | MEMF_CLEAR);
+ if (!bounce)
+ grub_util_error ("out of memory");
+
+ fd->ioreq->iotd_Req.io_Command = TD_GETGEOMETRY;
+ fd->ioreq->iotd_Req.io_Length = sizeof (*geo);
+ fd->ioreq->iotd_Req.io_Data = bounce;
+ fd->ioreq->iotd_Req.io_Offset = 0;
+ fd->ioreq->iotd_Req.io_Actual = 0;
+ err = DoIO ((struct IORequest *) fd->ioreq);
+ if (err)
+ {
+ grub_util_info ("I/O failed with error %d, IoErr=%d", (int)err, (int) IoErr ());
+ return -1;
+ }
+
+ geo = (struct DriveGeometry *) bounce;
+
+ sector_size = geo->dg_SectorSize;
+
+ if (sector_size & (sector_size - 1) || !sector_size)
+ return -1;
+
+ for (log_sector_size = 0;
+ (1 << log_sector_size) < sector_size;
+ log_sector_size++);
+
+ if (log_secsize)
+ *log_secsize = log_sector_size;
+
+ return (grub_uint64_t) geo->dg_TotalSectors * (grub_uint64_t) geo->dg_SectorSize;
+}
+
+static grub_uint64_t
+grub_util_get_fd_size_file (grub_util_fd_t fd,
+ const char *dev __attribute__ ((unused)),
+ unsigned *log_secsize)
+{
+ off_t oo, ro;
+ *log_secsize = 9;
+ /* FIXME: support 64-bit offsets. */
+ oo = lseek (fd->fd, 0, SEEK_CUR);
+ ro = lseek (fd->fd, 0, SEEK_END);
+ lseek (fd->fd, oo, SEEK_SET);
+ return ro;
+}
+
+int
+grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
+{
+ switch (fd->type)
+ {
+ case GRUB_UTIL_FD_FILE:
+ if (lseek (fd->fd, 0, SEEK_SET) == (off_t) -1)
+ return -1;
+ fd->off = off;
+ return 0;
+ case GRUB_UTIL_FD_DISK:
+ fd->off = off;
+ return 0;
+ }
+
+ return -1;
+}
+
+grub_util_fd_t
+grub_util_fd_open (const char *dev, int flg)
+{
+ grub_util_fd_t ret = xmalloc (sizeof (*ret));
+ const char *p1, *p2;
+ const char *dname;
+ char *tmp;
+ IPTR unit = 0;
+ ULONG flags = 0;
+
+#ifdef O_LARGEFILE
+ flg |= O_LARGEFILE;
+#endif
+#ifdef O_BINARY
+ flg |= O_BINARY;
+#endif
+
+ ret->off = 0;
+
+ if (dev[0] != '/' || dev[1] != '/' || dev[2] != ':')
+ {
+ ret->type = GRUB_UTIL_FD_FILE;
+ ret->fd = open (dev, flg, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
+ if (ret->fd < 0)
+ {
+ free (ret);
+ return NULL;
+ }
+ return ret;
+ }
+
+ p1 = strchr (dev + 3, '/');
+ if (!p1)
+ p1 = dev + strlen (dev);
+ else
+ {
+ unit = grub_strtoul (p1 + 1, &p2, 16);
+ if (p2 && *p2 == '/')
+ flags = grub_strtoul (p2 + 1, 0, 16);
+ }
+
+ ret->mp = CreateMsgPort();
+ if (!ret->mp)
+ {
+ free (ret);
+ return NULL;
+ }
+ ret->ioreq = (struct IOExtTD *) CreateIORequest(ret->mp,
+ sizeof(struct IOExtTD));
+ if (!ret->ioreq)
+ {
+ free (ret);
+ DeleteMsgPort (ret->mp);
+ return NULL;
+ }
+
+ dname = dev + 3;
+ ret->type = GRUB_UTIL_FD_DISK;
+
+ tmp = xmalloc (p1 - dname + 1);
+ memcpy (tmp, dname, p1 - dname);
+ tmp[p1 - dname] = '\0';
+
+ ret->is_floppy = (strcmp (tmp, TD_NAME) == 0);
+ ret->is_64 = 1;
+
+ if (OpenDevice ((unsigned char *) tmp, unit,
+ (struct IORequest *) ret->ioreq, flags))
+ {
+ free (tmp);
+ free (ret);
+ DeleteMsgPort (ret->mp);
+ return NULL;
+ }
+ free (tmp);
+ return ret;
+}
+
+static ssize_t
+grub_util_fd_read_file (grub_util_fd_t fd, char *buf, size_t len)
+{
+ ssize_t size = len;
+
+ while (len)
+ {
+ ssize_t ret = read (fd->fd, buf, len);
+
+ if (ret <= 0)
+ {
+ if (errno == EINTR)
+ continue;
+ else
+ return ret;
+ }
+
+ fd->off += ret;
+ len -= ret;
+ buf += ret;
+ }
+
+ return size;
+}
+
+/* Write LEN bytes from BUF to FD. Return less than or equal to zero if an
+ error occurs, otherwise return LEN. */
+static ssize_t
+grub_util_fd_write_file (grub_util_fd_t fd, const char *buf, size_t len)
+{
+ ssize_t size = len;
+
+ while (len)
+ {
+ ssize_t ret = write (fd->fd, buf, len);
+
+ if (ret <= 0)
+ {
+ if (errno == EINTR)
+ continue;
+ else
+ return ret;
+ }
+
+ fd->off += ret;
+ len -= ret;
+ buf += ret;
+ }
+
+ return size;
+}
+
+static void
+stop_motor (grub_util_fd_t fd)
+{
+ if (!fd->is_floppy)
+ return;
+ fd->ioreq->iotd_Req.io_Command = TD_MOTOR;
+ fd->ioreq->iotd_Req.io_Length = 0;
+ fd->ioreq->iotd_Req.io_Data = 0;
+ fd->ioreq->iotd_Req.io_Offset = 0;
+ fd->ioreq->iotd_Req.io_Actual = 0;
+ DoIO ((struct IORequest *) fd->ioreq);
+}
+
+static ssize_t
+grub_util_fd_read_volume (grub_util_fd_t fd, char *buf, size_t len)
+{
+ grub_uint64_t adj = 0;
+
+ if (!bounce)
+ bounce = AllocVec (BOUNCE_SIZE, MEMF_PUBLIC | MEMF_CLEAR);
+ if (!bounce)
+ grub_util_error ("out of memory");
+
+ while (len)
+ {
+ size_t cr = len;
+ LONG err;
+ if (cr > BOUNCE_SIZE)
+ cr = BOUNCE_SIZE;
+ retry:
+ if (fd->is_64)
+ fd->ioreq->iotd_Req.io_Command = NSCMD_TD_READ64;
+ else
+ fd->ioreq->iotd_Req.io_Command = CMD_READ;
+ fd->ioreq->iotd_Req.io_Length = cr;
+ fd->ioreq->iotd_Req.io_Data = bounce;
+ fd->ioreq->iotd_Req.io_Offset = fd->off & 0xFFFFFFFF;
+ fd->ioreq->iotd_Req.io_Actual = fd->off >> 32;
+ err = DoIO ((struct IORequest *) fd->ioreq);
+ if (err == IOERR_NOCMD && fd->is_64)
+ {
+ fd->is_64 = 0;
+ goto retry;
+ }
+ if (err)
+ {
+ grub_util_info ("I/O failed with error %d, IoErr=%d", (int)err, (int) IoErr ());
+ stop_motor (fd);
+ return -1;
+ }
+ memcpy (buf, bounce, cr);
+ adj += cr;
+ len -= cr;
+ buf += cr;
+ }
+
+ fd->off += adj;
+ stop_motor (fd);
+ return adj;
+}
+
+static ssize_t
+grub_util_fd_write_volume (grub_util_fd_t fd, const char *buf, size_t len)
+{
+ grub_uint64_t adj = 0;
+ if (!bounce)
+ bounce = AllocVec (BOUNCE_SIZE, MEMF_PUBLIC | MEMF_CLEAR);
+ if (!bounce)
+ grub_util_error ("out of memory");
+
+ while (len)
+ {
+ size_t cr = len;
+ LONG err;
+ if (cr > BOUNCE_SIZE)
+ cr = BOUNCE_SIZE;
+ retry:
+ if (fd->is_64)
+ fd->ioreq->iotd_Req.io_Command = NSCMD_TD_WRITE64;
+ else
+ fd->ioreq->iotd_Req.io_Command = CMD_WRITE;
+ fd->ioreq->iotd_Req.io_Length = cr;
+ fd->ioreq->iotd_Req.io_Data = bounce;
+ fd->ioreq->iotd_Req.io_Offset = fd->off & 0xFFFFFFFF;
+ fd->ioreq->iotd_Req.io_Actual = fd->off >> 32;
+ memcpy (bounce, buf, cr);
+ err = DoIO ((struct IORequest *) fd->ioreq);
+ if (err == IOERR_NOCMD && fd->is_64)
+ {
+ fd->is_64 = 0;
+ goto retry;
+ }
+ if (err)
+ {
+ grub_util_info ("I/O failed with error %d", err);
+ stop_motor (fd);
+ return -1;
+ }
+
+ adj += cr;
+ len -= cr;
+ buf += cr;
+ }
+
+ fd->off += adj;
+ stop_motor (fd);
+ return adj;
+}
+
+ssize_t
+grub_util_fd_read (grub_util_fd_t fd, char *buf, size_t len)
+{
+ switch (fd->type)
+ {
+ case GRUB_UTIL_FD_FILE:
+ return grub_util_fd_read_file (fd, buf, len);
+ case GRUB_UTIL_FD_DISK:
+ return grub_util_fd_read_volume (fd, buf, len);
+ }
+ return -1;
+}
+
+ssize_t
+grub_util_fd_write (grub_util_fd_t fd, const char *buf, size_t len)
+{
+ switch (fd->type)
+ {
+ case GRUB_UTIL_FD_FILE:
+ return grub_util_fd_write_file (fd, buf, len);
+ case GRUB_UTIL_FD_DISK:
+ return grub_util_fd_write_volume (fd, buf, len);
+ }
+ return -1;
+}
+
+grub_uint64_t
+grub_util_get_fd_size (grub_util_fd_t fd,
+ const char *dev,
+ unsigned *log_secsize)
+{
+ switch (fd->type)
+ {
+ case GRUB_UTIL_FD_FILE:
+ return grub_util_get_fd_size_file (fd, dev, log_secsize);
+
+ case GRUB_UTIL_FD_DISK:
+ return grub_util_get_fd_size_volume (fd, dev, log_secsize);
+ }
+ return -1;
+}
+
+int
+grub_util_fd_close (grub_util_fd_t fd)
+{
+ switch (fd->type)
+ {
+ case GRUB_UTIL_FD_FILE:
+ return close (fd->fd);
+ case GRUB_UTIL_FD_DISK:
+ CloseDevice ((struct IORequest *) fd->ioreq);
+ DeleteIORequest((struct IORequest *) fd->ioreq);
+ DeleteMsgPort (fd->mp);
+ return 0;
+ }
+ return 0;
+}
+
+static int allow_fd_syncs = 1;
+
+static int
+grub_util_fd_sync_volume (grub_util_fd_t fd)
+{
+ LONG err;
+
+ fd->ioreq->iotd_Req.io_Command = CMD_UPDATE;
+ fd->ioreq->iotd_Req.io_Length = 0;
+ fd->ioreq->iotd_Req.io_Data = 0;
+ fd->ioreq->iotd_Req.io_Offset = 0;
+ fd->ioreq->iotd_Req.io_Actual = 0;
+ err = DoIO ((struct IORequest *) fd->ioreq);
+ if (err)
+ {
+ grub_util_info ("I/O failed with error %d, IoErr=%d", (int)err, (int) IoErr ());
+ return -1;
+ }
+ return 0;
+}
+
+int
+grub_util_fd_sync (grub_util_fd_t fd)
+{
+ if (allow_fd_syncs)
+ {
+ switch (fd->type)
+ {
+ case GRUB_UTIL_FD_FILE:
+ return fsync (fd->fd);
+ case GRUB_UTIL_FD_DISK:
+ return grub_util_fd_sync_volume (fd);
+ }
+ }
+ return 0;
+}
+
+int
+grub_util_file_sync (FILE *f)
+{
+ if (fflush (f) != 0)
+ return -1;
+ if (!allow_fd_syncs)
+ return 0;
+ return fsync (fileno (f));
+}
+
+void
+grub_util_disable_fd_syncs (void)
+{
+ allow_fd_syncs = 0;
+}
+
+void
+grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
+{
+}
+
+
+const char *
+grub_util_fd_strerror (void)
+{
+ static char buf[201];
+ LONG err = IoErr ();
+ if (!err)
+ return _("Success");
+ memset (buf, '\0', sizeof (buf));
+ Fault (err, (const unsigned char *) "", (STRPTR) buf, sizeof (buf));
+ if (buf[0] == ':')
+ return buf + 1;
+ return buf;
+}
+
+FILE *
+grub_util_fopen (const char *path, const char *mode)
+{
+ return fopen (path, mode);
+}
+
+int
+grub_util_is_directory (const char *path)
+{
+ struct stat st;
+
+ if (stat (path, &st) == -1)
+ return 0;
+
+ return S_ISDIR (st.st_mode);
+}
+
+int
+grub_util_is_regular (const char *path)
+{
+ struct stat st;
+
+ if (stat (path, &st) == -1)
+ return 0;
+
+ return S_ISREG (st.st_mode);
+}
+
+int
+grub_util_is_special_file (const char *path)
+{
+ struct stat st;
+
+ if (lstat (path, &st) == -1)
+ return 1;
+ return (!S_ISREG (st.st_mode) && !S_ISDIR (st.st_mode));
+}
+
+static char *
+get_temp_name (void)
+{
+ static int ctr = 0;
+ char *t;
+ struct stat st;
+
+ while (1)
+ {
+ t = xasprintf ("T:grub.%d.%d.%d.%d", (int) getpid (), (int) getppid (),
+ ctr++, time (0));
+ if (stat (t, &st) == -1)
+ return t;
+ free (t);
+ }
+}
+
+char *
+grub_util_make_temporary_file (void)
+{
+ char *ret = get_temp_name ();
+ FILE *f;
+
+ f = grub_util_fopen (ret, "wb");
+ if (f)
+ fclose (f);
+ return ret;
+}
+
+char *
+grub_util_make_temporary_dir (void)
+{
+ char *ret = get_temp_name ();
+
+ grub_util_mkdir (ret);
+
+ return ret;
+}
+
+grub_uint32_t
+grub_util_get_mtime (const char *path)
+{
+ struct stat st;
+
+ if (stat (path, &st) == -1)
+ return 0;
+
+ return st.st_mtime;
+}
diff --git a/grub-core/osdep/aros/relpath.c b/grub-core/osdep/aros/relpath.c
new file mode 100644
index 0000000..9c2328d
--- /dev/null
+++ b/grub-core/osdep/aros/relpath.c
@@ -0,0 +1,75 @@
+/*
+ * 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 <config-util.h>
+#include <config.h>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+
+#include <string.h>
+#include <dos/dos.h>
+#include <dos/filesystem.h>
+#include <dos/exall.h>
+#include <proto/dos.h>
+#include <proto/exec.h>
+#include <devices/trackdisk.h>
+
+char *
+grub_make_system_path_relative_to_its_root (const char *path)
+{
+ char *p;
+ unsigned char *tmp;
+ char *ret;
+ BPTR lck;
+
+ if (path[0] == '/' && path[1] == '/' && path[2] == ':')
+ return xstrdup (path);
+
+ tmp = xmalloc (2048);
+
+ lck = Lock ((const unsigned char *) path, SHARED_LOCK);
+ if (!lck || !NameFromLock (lck, tmp, 2040))
+ {
+ free (tmp);
+ tmp = (unsigned char *) xstrdup (path);
+ }
+ if (lck)
+ UnLock (lck);
+ p = strchr ((char *) tmp, ':');
+ if (!p)
+ return (char *) tmp;
+ if (p[1] == '/' || p[1] == '\0')
+ {
+ ret = xstrdup (p + 1);
+ }
+ else
+ {
+ ret = xmalloc (strlen (p + 1) + 2);
+ ret[0] = '/';
+ strcpy (ret + 1, p + 1);
+ }
+
+ free (tmp);
+ return ret;
+}
diff --git a/grub-core/osdep/basic/compress.c b/grub-core/osdep/basic/compress.c
new file mode 100644
index 0000000..9794640
--- /dev/null
+++ b/grub-core/osdep/basic/compress.c
@@ -0,0 +1,21 @@
+#include <config.h>
+#include <grub/util/install.h>
+#include <grub/util/misc.h>
+
+int
+grub_install_compress_gzip (const char *src, const char *dest)
+{
+ grub_util_error (_("no compression is available for your platform"));
+}
+
+int
+grub_install_compress_xz (const char *src, const char *dest)
+{
+ grub_util_error (_("no compression is available for your platform"));
+}
+
+int
+grub_install_compress_lzop (const char *src, const char *dest)
+{
+ grub_util_error (_("no compression is available for your platform"));
+}
diff --git a/grub-core/osdep/basic/emunet.c b/grub-core/osdep/basic/emunet.c
new file mode 100644
index 0000000..6362e5c
--- /dev/null
+++ b/grub-core/osdep/basic/emunet.c
@@ -0,0 +1,50 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011,2012,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 <config.h>
+#include <config-util.h>
+
+#include <grub/i18n.h>
+#include <grub/emu/net.h>
+
+grub_ssize_t
+grub_emunet_send (const void *packet __attribute__ ((unused)),
+ grub_size_t sz __attribute__ ((unused)))
+{
+ return -1;
+}
+
+grub_ssize_t
+grub_emunet_receive (void *packet __attribute__ ((unused)),
+ grub_size_t sz __attribute__ ((unused)))
+{
+ return -1;
+}
+
+int
+grub_emunet_create (grub_size_t *mtu)
+{
+ *mtu = 1500;
+ return -1;
+}
+
+void
+grub_emunet_close (void)
+{
+ return;
+}
diff --git a/grub-core/osdep/basic/getroot.c b/grub-core/osdep/basic/getroot.c
new file mode 100644
index 0000000..8831eb3
--- /dev/null
+++ b/grub-core/osdep/basic/getroot.c
@@ -0,0 +1,82 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <grub/types.h>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+
+
+char *
+grub_util_part_to_disk (const char *os_dev,
+ struct stat *st __attribute__ ((unused)),
+ int *is_part)
+{
+ *is_part = 0;
+ return xstrdup (os_dev);
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dev_abstraction_os (const char *os_dev __attribute__((unused)))
+{
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+int
+grub_util_pull_device_os (const char *os_dev __attribute__ ((unused)),
+ enum grub_dev_abstraction_types ab __attribute__ ((unused)))
+{
+ return 0;
+}
+
+char *
+grub_util_get_grub_dev_os (const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+
+grub_disk_addr_t
+grub_util_find_partition_start_os (const char *dev __attribute__ ((unused)))
+{
+ return 0;
+}
diff --git a/grub-core/osdep/basic/hostdisk.c b/grub-core/osdep/basic/hostdisk.c
new file mode 100644
index 0000000..529bf29
--- /dev/null
+++ b/grub-core/osdep/basic/hostdisk.c
@@ -0,0 +1,58 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+grub_int64_t
+grub_util_get_fd_size_os (grub_util_fd_t fd __attribute__ ((unused)),
+ const char *name __attribute__ ((unused)),
+ unsigned *log_secsize __attribute__ ((unused)))
+{
+# warning "No special routine to get the size of a block device is implemented for your OS. This is not possibly fatal."
+
+ return -1;
+}
+
+void
+grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
+{
+}
diff --git a/grub-core/osdep/basic/init.c b/grub-core/osdep/basic/init.c
new file mode 100644
index 0000000..c54c710
--- /dev/null
+++ b/grub-core/osdep/basic/init.c
@@ -0,0 +1,38 @@
+/*
+ * 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 <config.h>
+#include <config-util.h>
+
+#include <grub/util/misc.h>
+#include <grub/i18n.h>
+
+#include "progname.h"
+
+void
+grub_util_host_init (int *argc __attribute__ ((unused)),
+ char ***argv)
+{
+ set_program_name ((*argv)[0]);
+
+#if (defined (GRUB_UTIL) && defined(ENABLE_NLS) && ENABLE_NLS)
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
+}
diff --git a/grub-core/osdep/basic/no_platform.c b/grub-core/osdep/basic/no_platform.c
new file mode 100644
index 0000000..d76c34c
--- /dev/null
+++ b/grub-core/osdep/basic/no_platform.c
@@ -0,0 +1,46 @@
+/*
+ * 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/types.h>
+#include <grub/emu/misc.h>
+#include <grub/util/install.h>
+#include <grub/util/misc.h>
+
+#include "platform.c"
+
+void
+grub_install_register_ieee1275 (int is_prep, const char *install_device,
+ int partno, const char *relpath)
+{
+ grub_util_error ("%s", _("no IEEE1275 routines are available for your platform"));
+}
+
+void
+grub_install_register_efi (grub_device_t efidir_grub_dev,
+ const char *efifile_path,
+ const char *efi_distributor)
+{
+ grub_util_error ("%s", _("no EFI routines are available for your platform"));
+}
+
+void
+grub_install_sgi_setup (const char *install_device,
+ const char *imgfile, const char *destname)
+{
+ grub_util_error ("%s", _("no SGI routines are available for your platform"));
+}
diff --git a/grub-core/osdep/basic/ofpath.c b/grub-core/osdep/basic/ofpath.c
new file mode 100644
index 0000000..c3fe06f
--- /dev/null
+++ b/grub-core/osdep/basic/ofpath.c
@@ -0,0 +1,29 @@
+/* ofpath.c - calculate OpenFirmware path names given an OS device */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2011,2012, 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/util/ofpath.h>
+#include <grub/mm.h>
+
+char *
+grub_util_devname_to_ofpath (const char *sys_devname __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+
diff --git a/grub-core/osdep/basic/platform.c b/grub-core/osdep/basic/platform.c
new file mode 100644
index 0000000..a7dafd8
--- /dev/null
+++ b/grub-core/osdep/basic/platform.c
@@ -0,0 +1,32 @@
+/*
+ * 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/util/install.h>
+
+const char *
+grub_install_get_default_arm_platform (void)
+{
+ return "arm-uboot";
+}
+
+const char *
+grub_install_get_default_x86_platform (void)
+{
+ return "i386-pc";
+}
+
diff --git a/grub-core/osdep/basic/random.c b/grub-core/osdep/basic/random.c
new file mode 100644
index 0000000..b5ccad4
--- /dev/null
+++ b/grub-core/osdep/basic/random.c
@@ -0,0 +1,43 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1992-1999,2001,2003,2004,2005,2009,2010,2011,2012,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 <config.h>
+
+#include <grub/types.h>
+#include <grub/crypto.h>
+#include <grub/auth.h>
+#include <grub/emu/misc.h>
+#include <grub/util/misc.h>
+#include <grub/i18n.h>
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+grub_get_random (void *out, grub_size_t len)
+{
+#warning "No random number generator is available for your OS. \
+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/blocklist.c b/grub-core/osdep/blocklist.c
new file mode 100644
index 0000000..1f58b0f
--- /dev/null
+++ b/grub-core/osdep/blocklist.c
@@ -0,0 +1,7 @@
+#ifdef __linux__
+#include "linux/blocklist.c"
+#elif defined (__MINGW32__) || defined (__CYGWIN__)
+#include "windows/blocklist.c"
+#else
+#include "generic/blocklist.c"
+#endif
diff --git a/grub-core/osdep/bsd/getroot.c b/grub-core/osdep/bsd/getroot.c
new file mode 100644
index 0000000..dbc6a2f
--- /dev/null
+++ b/grub-core/osdep/bsd/getroot.c
@@ -0,0 +1,204 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <grub/types.h>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+
+#include <sys/wait.h>
+
+# include <sys/ioctl.h>
+# include <sys/disklabel.h> /* struct disklabel */
+# include <sys/disk.h> /* struct dkwedge_info */
+# ifdef HAVE_GETRAWPARTITION
+# include <util.h> /* getrawpartition */
+# endif /* HAVE_GETRAWPARTITION */
+#if defined(__NetBSD__)
+# include <sys/fdio.h>
+#endif
+#if defined(__OpenBSD__)
+# include <sys/dkio.h>
+#endif
+
+char *
+grub_util_part_to_disk (const char *os_dev, struct stat *st,
+ int *is_part)
+{
+ int rawpart = -1;
+
+ if (! S_ISCHR (st->st_mode))
+ {
+ *is_part = 0;
+ return xstrdup (os_dev);
+ }
+
+# ifdef HAVE_GETRAWPARTITION
+ rawpart = getrawpartition();
+# endif /* HAVE_GETRAWPARTITION */
+ if (rawpart < 0)
+ return xstrdup (os_dev);
+
+#if defined(__NetBSD__)
+ /* NetBSD disk wedges are of the form "/dev/rdk.*". */
+ if (strncmp ("/dev/rdk", os_dev, sizeof("/dev/rdk") - 1) == 0)
+ {
+ struct dkwedge_info dkw;
+ int fd;
+
+ fd = open (os_dev, O_RDONLY);
+ if (fd == -1)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE,
+ N_("cannot open `%s': %s"), os_dev,
+ strerror (errno));
+ return xstrdup (os_dev);
+ }
+ if (ioctl (fd, DIOCGWEDGEINFO, &dkw) == -1)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE,
+ "cannot get disk wedge info of `%s'", os_dev);
+ close (fd);
+ return xstrdup (os_dev);
+ }
+ *is_part = (dkw.dkw_offset != 0);
+ close (fd);
+ return xasprintf ("/dev/r%s%c", dkw.dkw_parent, 'a' + rawpart);
+ }
+#endif
+
+ /* NetBSD (disk label) partitions are of the form "/dev/r[a-z]+[0-9][a-z]". */
+ if (strncmp ("/dev/r", os_dev, sizeof("/dev/r") - 1) == 0 &&
+ (os_dev[sizeof("/dev/r") - 1] >= 'a' && os_dev[sizeof("/dev/r") - 1] <= 'z') &&
+ strncmp ("fd", os_dev + sizeof("/dev/r") - 1, sizeof("fd") - 1) != 0) /* not a floppy device name */
+ {
+ char *path = xstrdup (os_dev);
+ char *p;
+ for (p = path + sizeof("/dev/r"); *p >= 'a' && *p <= 'z'; p++);
+ if (grub_isdigit(*p))
+ {
+ p++;
+ if ((*p >= 'a' && *p <= 'z') && (*(p+1) == '\0'))
+ {
+ if (*p != 'a' + rawpart)
+ *is_part = 1;
+ /* path matches the required regular expression and
+ p points to its last character. */
+ *p = 'a' + rawpart;
+ }
+ }
+ return path;
+ }
+
+ return xstrdup (os_dev);
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dev_abstraction_os (const char *os_dev __attribute__((unused)))
+{
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+int
+grub_util_pull_device_os (const char *os_dev __attribute__ ((unused)),
+ enum grub_dev_abstraction_types ab __attribute__ ((unused)))
+{
+ return 0;
+}
+
+char *
+grub_util_get_grub_dev_os (const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+
+grub_disk_addr_t
+grub_util_find_partition_start_os (const char *dev)
+{
+ int fd;
+# if defined(__NetBSD__)
+ struct dkwedge_info dkw;
+# endif /* defined(__NetBSD__) */
+ struct disklabel label;
+ int p_index;
+
+ fd = grub_util_fd_open (dev, O_RDONLY);
+ if (fd == -1)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot open `%s': %s"),
+ dev, strerror (errno));
+ return 0;
+ }
+
+# if defined(__NetBSD__)
+ /* First handle the case of disk wedges. */
+ if (ioctl (fd, DIOCGWEDGEINFO, &dkw) == 0)
+ {
+ close (fd);
+ return (grub_disk_addr_t) dkw.dkw_offset;
+ }
+# endif /* defined(__NetBSD__) */
+
+ if (ioctl (fd, DIOCGDINFO, &label) == -1)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE,
+ "cannot get disk label of `%s'", dev);
+ close (fd);
+ return 0;
+ }
+
+ close (fd);
+
+ if (dev[0])
+ p_index = dev[strlen(dev) - 1] - 'a';
+ else
+ p_index = -1;
+
+ if (p_index >= label.d_npartitions || p_index < 0)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE,
+ "no disk label entry for `%s'", dev);
+ return 0;
+ }
+ return (grub_disk_addr_t) label.d_partitions[p_index].p_offset;
+}
diff --git a/grub-core/osdep/bsd/hostdisk.c b/grub-core/osdep/bsd/hostdisk.c
new file mode 100644
index 0000000..5912d14
--- /dev/null
+++ b/grub-core/osdep/bsd/hostdisk.c
@@ -0,0 +1,130 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+# include <sys/ioctl.h>
+# include <sys/disklabel.h> /* struct disklabel */
+# include <sys/disk.h> /* struct dkwedge_info */
+# ifdef HAVE_GETRAWPARTITION
+# include <util.h> /* getrawpartition */
+# endif /* HAVE_GETRAWPARTITION */
+# if defined(__NetBSD__)
+# include <sys/fdio.h>
+# endif
+# if defined(__OpenBSD__)
+# include <sys/dkio.h>
+# endif
+
+#if defined(__NetBSD__)
+/* Adjust device driver parameters. This function should be called just
+ after successfully opening the device. For now, it simply prevents the
+ floppy driver from retrying operations on failure, as otherwise the
+ driver takes a while to abort when there is no floppy in the drive. */
+static void
+configure_device_driver (grub_util_fd_t fd)
+{
+ struct stat st;
+
+ if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode))
+ return;
+ if (major(st.st_rdev) == RAW_FLOPPY_MAJOR)
+ {
+ int floppy_opts;
+
+ if (ioctl (fd, FDIOCGETOPTS, &floppy_opts) == -1)
+ return;
+ floppy_opts |= FDOPT_NORETRY;
+ if (ioctl (fd, FDIOCSETOPTS, &floppy_opts) == -1)
+ return;
+ }
+}
+grub_util_fd_t
+grub_util_fd_open (const char *os_dev, int flags)
+{
+ grub_util_fd_t ret;
+
+#ifdef O_LARGEFILE
+ flags |= O_LARGEFILE;
+#endif
+#ifdef O_BINARY
+ flags |= O_BINARY;
+#endif
+
+ ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
+ if (ret >= 0)
+ configure_device_driver (fd);
+ return ret;
+}
+
+#endif
+
+grub_int64_t
+grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_secsize)
+{
+ struct disklabel label;
+ unsigned sector_size, log_sector_size;
+
+#if defined(__NetBSD__)
+ grub_hostdisk_configure_device_driver (fd);
+#endif
+
+ if (ioctl (fd, DIOCGDINFO, &label) == -1)
+ return -1;
+
+ sector_size = label.d_secsize;
+ if (sector_size & (sector_size - 1) || !sector_size)
+ return -1;
+ for (log_sector_size = 0;
+ (1 << log_sector_size) < sector_size;
+ log_sector_size++);
+
+ if (log_secsize)
+ *log_secsize = log_sector_size;
+
+ return (grub_uint64_t) label.d_secperunit << log_sector_size;
+}
+
+void
+grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
+{
+}
diff --git a/grub-core/osdep/compress.c b/grub-core/osdep/compress.c
new file mode 100644
index 0000000..cc808d0
--- /dev/null
+++ b/grub-core/osdep/compress.c
@@ -0,0 +1,5 @@
+#if !defined (__MINGW32__) && !defined (__CYGWIN__) && !defined (__AROS__)
+#include "unix/compress.c"
+#else
+#include "basic/compress.c"
+#endif
diff --git a/grub-core/osdep/config.c b/grub-core/osdep/config.c
new file mode 100644
index 0000000..b9f7819
--- /dev/null
+++ b/grub-core/osdep/config.c
@@ -0,0 +1,7 @@
+#if defined (__MINGW32__) && !defined (__CYGWIN__)
+#include "windows/config.c"
+#elif defined (__AROS__)
+#include "aros/config.c"
+#else
+#include "unix/config.c"
+#endif
diff --git a/grub-core/osdep/cputime.c b/grub-core/osdep/cputime.c
new file mode 100644
index 0000000..d3ee4c8
--- /dev/null
+++ b/grub-core/osdep/cputime.c
@@ -0,0 +1,5 @@
+#ifdef __MINGW32__
+#include "windows/cputime.c"
+#else
+#include "unix/cputime.c"
+#endif
diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c
new file mode 100644
index 0000000..a13a39c
--- /dev/null
+++ b/grub-core/osdep/devmapper/getroot.c
@@ -0,0 +1,347 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <grub/emu/getroot.h>
+#include <grub/mm.h>
+
+#ifdef HAVE_DEVICE_MAPPER
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#ifdef HAVE_LIMITS_H
+#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>
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+
+static int
+grub_util_open_dm (const char *os_dev, struct dm_tree **tree,
+ struct dm_tree_node **node)
+{
+ uint32_t maj, min;
+ struct stat st;
+
+ *node = NULL;
+ *tree = NULL;
+
+ if (stat (os_dev, &st) < 0)
+ return 0;
+
+ maj = major (st.st_rdev);
+ min = minor (st.st_rdev);
+
+ if (!dm_is_dm_major (maj))
+ return 0;
+
+ *tree = dm_tree_create ();
+ if (! *tree)
+ {
+ grub_puts_ (N_("Failed to create `device-mapper' tree"));
+ grub_dprintf ("hostdisk", "dm_tree_create failed\n");
+ return 0;
+ }
+
+ if (! dm_tree_add_dev (*tree, maj, min))
+ {
+ grub_dprintf ("hostdisk", "dm_tree_add_dev failed\n");
+ dm_tree_free (*tree);
+ *tree = NULL;
+ return 0;
+ }
+
+ *node = dm_tree_find_node (*tree, maj, min);
+ if (! *node)
+ {
+ grub_dprintf ("hostdisk", "dm_tree_find_node failed\n");
+ dm_tree_free (*tree);
+ *tree = NULL;
+ return 0;
+ }
+ return 1;
+}
+
+static char *
+get_dm_uuid (const char *os_dev)
+{
+ struct dm_tree *tree;
+ struct dm_tree_node *node;
+ const char *node_uuid;
+ char *ret;
+
+ if (!grub_util_open_dm (os_dev, &tree, &node))
+ return NULL;
+
+ node_uuid = dm_tree_node_get_uuid (node);
+ if (! node_uuid)
+ {
+ grub_dprintf ("hostdisk", "%s has no DM uuid\n", os_dev);
+ dm_tree_free (tree);
+ return NULL;
+ }
+
+ ret = grub_strdup (node_uuid);
+
+ dm_tree_free (tree);
+
+ return ret;
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dm_abstraction (const char *os_dev)
+{
+ char *uuid;
+
+ uuid = get_dm_uuid (os_dev);
+
+ if (uuid == NULL)
+ return GRUB_DEV_ABSTRACTION_NONE;
+
+ if (strncmp (uuid, "LVM-", 4) == 0)
+ {
+ grub_free (uuid);
+ return GRUB_DEV_ABSTRACTION_LVM;
+ }
+ if (strncmp (uuid, "CRYPT-LUKS1-", 12) == 0)
+ {
+ grub_free (uuid);
+ return GRUB_DEV_ABSTRACTION_LUKS;
+ }
+
+ grub_free (uuid);
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+void
+grub_util_pull_devmapper (const char *os_dev)
+{
+ struct dm_tree *tree;
+ struct dm_tree_node *node;
+ struct dm_tree_node *child;
+ void *handle = NULL;
+ char *lastsubdev = NULL;
+ char *uuid;
+
+ uuid = get_dm_uuid (os_dev);
+
+ if (!grub_util_open_dm (os_dev, &tree, &node))
+ {
+ grub_free (uuid);
+ return;
+ }
+
+ while ((child = dm_tree_next_child (&handle, node, 0)))
+ {
+ const struct dm_info *dm = dm_tree_node_get_info (child);
+ char *subdev;
+ if (!dm)
+ continue;
+ subdev = grub_find_device ("/dev", makedev (dm->major, dm->minor));
+ if (subdev)
+ {
+ lastsubdev = subdev;
+ grub_util_pull_device (subdev);
+ }
+ }
+ if (uuid && strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0
+ && lastsubdev)
+ {
+ char *grdev = grub_util_get_grub_dev (lastsubdev);
+ dm_tree_free (tree);
+ if (grdev)
+ {
+ grub_err_t err;
+ err = grub_cryptodisk_cheat_mount (grdev, os_dev);
+ if (err)
+ grub_util_error (_("can't mount encrypted volume `%s': %s"),
+ lastsubdev, grub_errmsg);
+ }
+ grub_free (grdev);
+ }
+ else
+ dm_tree_free (tree);
+ grub_free (uuid);
+}
+
+char *
+grub_util_devmapper_part_to_disk (struct stat *st,
+ int *is_part, const char *path)
+{
+ int major, minor;
+
+ if (grub_util_get_dm_node_linear_info (st->st_rdev,
+ &major, &minor, 0))
+ {
+ *is_part = 1;
+ return grub_find_device ("/dev", makedev (major, minor));
+ }
+ *is_part = 0;
+ return xstrdup (path);
+}
+
+char *
+grub_util_get_devmapper_grub_dev (const char *os_dev)
+{
+ char *uuid, *optr;
+ char *grub_dev;
+
+ uuid = get_dm_uuid (os_dev);
+ if (!uuid)
+ return NULL;
+
+ 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++)
+ {
+ memcpy (optr, uuid + sizeof ("LVM-") - 1 + dashes[i],
+ dashes[i+1] - dashes[i]);
+ optr += dashes[i+1] - dashes[i];
+ *optr++ = '-';
+ }
+ optr = stpcpy (optr, uuid + sizeof ("LVM-") - 1 + dashes[i]);
+ *optr = '\0';
+ grub_dev[sizeof("lvmid/xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx") - 1]
+ = '/';
+ free (uuid);
+ return grub_dev;
+ }
+
+ 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 NULL;
+ }
+}
+
+char *
+grub_util_get_vg_uuid (const char *os_dev)
+{
+ char *uuid, *vgid;
+ int dashes[] = { 0, 6, 10, 14, 18, 22, 26, 32};
+ unsigned i;
+ char *optr;
+
+ uuid = get_dm_uuid (os_dev);
+ if (!uuid)
+ return NULL;
+
+ vgid = xmalloc (grub_strlen (uuid));
+ optr = vgid;
+ for (i = 0; i < ARRAY_SIZE (dashes) - 1; i++)
+ {
+ memcpy (optr, uuid + sizeof ("LVM-") - 1 + dashes[i],
+ dashes[i+1] - dashes[i]);
+ optr += dashes[i+1] - dashes[i];
+ *optr++ = '-';
+ }
+ optr--;
+ *optr = '\0';
+ grub_free (uuid);
+ return vgid;
+}
+
+void
+grub_util_devmapper_cleanup (void)
+{
+ dm_lib_release ();
+}
+
+#else
+void
+grub_util_pull_devmapper (const char *os_dev __attribute__ ((unused)))
+{
+ return;
+}
+
+void
+grub_util_devmapper_cleanup (void)
+{
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dm_abstraction (const char *os_dev __attribute__ ((unused)))
+{
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+char *
+grub_util_get_vg_uuid (const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+char *
+grub_util_devmapper_part_to_disk (struct stat *st __attribute__ ((unused)),
+ int *is_part __attribute__ ((unused)),
+ const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+char *
+grub_util_get_devmapper_grub_dev (const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+#endif
diff --git a/grub-core/osdep/devmapper/hostdisk.c b/grub-core/osdep/devmapper/hostdisk.c
new file mode 100644
index 0000000..a8afc0c
--- /dev/null
+++ b/grub-core/osdep/devmapper/hostdisk.c
@@ -0,0 +1,230 @@
+#include <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#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>
+
+static void device_mapper_null_log (int level __attribute__ ((unused)),
+ const char *file __attribute__ ((unused)),
+ int line __attribute__ ((unused)),
+ int dm_errno __attribute__ ((unused)),
+ const char *f __attribute__ ((unused)),
+ ...)
+{
+}
+
+int
+grub_device_mapper_supported (void)
+{
+ static int supported = -1;
+
+ if (supported == -1)
+ {
+ struct dm_task *dmt;
+
+ /* Suppress annoying log messages. */
+ dm_log_with_errno_init (&device_mapper_null_log);
+
+ dmt = dm_task_create (DM_DEVICE_VERSION);
+ supported = (dmt != NULL);
+ if (dmt)
+ dm_task_destroy (dmt);
+
+ /* Restore the original logger. */
+ dm_log_with_errno_init (NULL);
+ }
+
+ return supported;
+}
+
+int
+grub_util_device_is_mapped (const char *dev)
+{
+ struct stat st;
+
+ if (!grub_device_mapper_supported ())
+ return 0;
+
+ if (stat (dev, &st) < 0)
+ return 0;
+
+#if GRUB_DISK_DEVS_ARE_CHAR
+ if (! S_ISCHR (st.st_mode))
+#else
+ if (! S_ISBLK (st.st_mode))
+#endif
+ return 0;
+
+ return dm_is_dm_major (major (st.st_rdev));
+}
+
+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));
+}
+
+
+int
+grub_util_get_dm_node_linear_info (dev_t dev,
+ int *maj, int *min,
+ grub_disk_addr_t *st)
+{
+ struct dm_task *dmt;
+ void *next = NULL;
+ uint64_t length, start;
+ char *target, *params;
+ const char *ptr;
+ int major = 0, minor = 0;
+ int first = 1;
+ 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 (! (dm_task_set_major_minor (dmt, major, minor, 0)))
+ {
+ dm_task_destroy (dmt);
+ break;
+ }
+ dm_task_no_open_count(dmt);
+ if (!dm_task_run(dmt))
+ {
+ dm_task_destroy (dmt);
+ break;
+ }
+ node_uuid = dm_task_get_uuid (dmt);
+ if (node_uuid && (strncmp (node_uuid, "LVM-", 4) == 0
+ || strncmp (node_uuid, "mpath-", 6) == 0))
+ {
+ dm_task_destroy (dmt);
+ break;
+ }
+
+ next = dm_get_next_target(dmt, next, &start, &length,
+ &target, &params);
+ if (grub_strcmp (target, "linear") != 0)
+ {
+ dm_task_destroy (dmt);
+ break;
+ }
+ major = grub_strtoul (params, &ptr, 10);
+ if (grub_errno)
+ {
+ dm_task_destroy (dmt);
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+ if (*ptr != ':')
+ {
+ dm_task_destroy (dmt);
+ return 0;
+ }
+ ptr++;
+ minor = grub_strtoul (ptr, &ptr, 10);
+ if (grub_errno)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ dm_task_destroy (dmt);
+ return 0;
+ }
+
+ if (*ptr != ' ')
+ {
+ dm_task_destroy (dmt);
+ return 0;
+ }
+ ptr++;
+ partstart += grub_strtoull (ptr, &ptr, 10);
+ if (grub_errno)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ dm_task_destroy (dmt);
+ return 0;
+ }
+
+ dm_task_destroy (dmt);
+ first = 0;
+ if (!dm_is_dm_major (major))
+ break;
+ }
+ if (first)
+ return 0;
+ if (maj)
+ *maj = major;
+ if (min)
+ *min = minor;
+ if (st)
+ *st = partstart;
+ return 1;
+}
+#else
+
+int
+grub_util_device_is_mapped (const char *dev __attribute__ ((unused)))
+{
+ return 0;
+}
+
+int
+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)))
+{
+ return 0;
+}
+
+int
+grub_util_device_is_mapped_stat (struct stat *st __attribute__ ((unused)))
+{
+ return 0;
+}
+
+#endif
diff --git a/grub-core/osdep/dl.c b/grub-core/osdep/dl.c
new file mode 100644
index 0000000..c511747
--- /dev/null
+++ b/grub-core/osdep/dl.c
@@ -0,0 +1,5 @@
+#if defined (__MINGW32__) || defined (__CYGWIN__)
+#include "windows/dl.c"
+#else
+#include "unix/dl.c"
+#endif
diff --git a/grub-core/osdep/emuconsole.c b/grub-core/osdep/emuconsole.c
new file mode 100644
index 0000000..13ede31
--- /dev/null
+++ b/grub-core/osdep/emuconsole.c
@@ -0,0 +1,5 @@
+#if defined (__MINGW32__) && !defined (__CYGWIN__)
+#include "windows/emuconsole.c"
+#else
+#include "unix/emuconsole.c"
+#endif
diff --git a/grub-core/osdep/emunet.c b/grub-core/osdep/emunet.c
new file mode 100644
index 0000000..4b0bac4
--- /dev/null
+++ b/grub-core/osdep/emunet.c
@@ -0,0 +1,5 @@
+#if defined (__linux__)
+#include "linux/emunet.c"
+#else
+#include "basic/emunet.c"
+#endif
diff --git a/grub-core/osdep/exec.c b/grub-core/osdep/exec.c
new file mode 100644
index 0000000..9dcd926
--- /dev/null
+++ b/grub-core/osdep/exec.c
@@ -0,0 +1,3 @@
+#if (!defined (__MINGW32__) || defined (__CYGWIN__)) && !defined (__AROS__)
+#include "unix/exec.c"
+#endif
diff --git a/grub-core/osdep/freebsd/getroot.c b/grub-core/osdep/freebsd/getroot.c
new file mode 100644
index 0000000..b1e8244
--- /dev/null
+++ b/grub-core/osdep/freebsd/getroot.c
@@ -0,0 +1,364 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <grub/types.h>
+# include <sys/param.h>
+# include <sys/mount.h>
+# include <sys/disk.h> /* DIOCGMEDIASIZE */
+# include <sys/param.h>
+# include <sys/sysctl.h>
+#include <libgeom.h>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/cryptodisk.h>
+
+#include <sys/wait.h>
+
+#include <libgeom.h>
+
+#define LVM_DEV_MAPPER_STRING "/dev/linux_lvm/"
+
+static const char *
+grub_util_get_geom_abstraction (const char *dev)
+{
+ char *whole;
+ struct gmesh mesh;
+ struct gclass *class;
+ const char *name;
+ int err;
+
+ if (strncmp (dev, "/dev/", sizeof ("/dev/") - 1) != 0)
+ return 0;
+ name = dev + sizeof ("/dev/") - 1;
+ grub_util_follow_gpart_up (name, NULL, &whole);
+
+ grub_util_info ("following geom '%s'", name);
+
+ err = geom_gettree (&mesh);
+ if (err != 0)
+ /* TRANSLATORS: geom is the name of (k)FreeBSD device framework.
+ Usually left untranslated.
+ */
+ grub_util_error ("%s", _("couldn't open geom"));
+
+ LIST_FOREACH (class, &mesh.lg_class, lg_class)
+ {
+ struct ggeom *geom;
+ LIST_FOREACH (geom, &class->lg_geom, lg_geom)
+ {
+ struct gprovider *provider;
+ LIST_FOREACH (provider, &geom->lg_provider, lg_provider)
+ if (strcmp (provider->lg_name, name) == 0)
+ return class->lg_name;
+ }
+ }
+ return NULL;
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dev_abstraction_os (const char *os_dev)
+{
+ const char *abstrac;
+ abstrac = grub_util_get_geom_abstraction (os_dev);
+ grub_util_info ("abstraction of %s is %s", os_dev, abstrac);
+ if (abstrac && grub_strcasecmp (abstrac, "eli") == 0)
+ return GRUB_DEV_ABSTRACTION_GELI;
+
+ /* Check for LVM. */
+ if (!strncmp (os_dev, LVM_DEV_MAPPER_STRING, sizeof(LVM_DEV_MAPPER_STRING)-1))
+ return GRUB_DEV_ABSTRACTION_LVM;
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+char *
+grub_util_part_to_disk (const char *os_dev, struct stat *st,
+ int *is_part)
+{
+ char *out, *out2;
+
+ if (! S_ISCHR (st->st_mode))
+ {
+ *is_part = 0;
+ return xstrdup (os_dev);
+ }
+
+ if (strncmp (os_dev, "/dev/", sizeof ("/dev/") - 1) != 0)
+ return xstrdup (os_dev);
+ grub_util_follow_gpart_up (os_dev + sizeof ("/dev/") - 1, NULL, &out);
+
+ if (grub_strcmp (os_dev + sizeof ("/dev/") - 1, out) != 0)
+ *is_part = 1;
+ out2 = xasprintf ("/dev/%s", out);
+ free (out);
+
+ return out2;
+}
+
+int
+grub_util_pull_device_os (const char *os_dev,
+ enum grub_dev_abstraction_types ab)
+{
+ switch (ab)
+ {
+ case GRUB_DEV_ABSTRACTION_GELI:
+ {
+ char *whole;
+ struct gmesh mesh;
+ struct gclass *class;
+ const char *name;
+ int err;
+ char *lastsubdev = NULL;
+
+ if (strncmp (os_dev, "/dev/", sizeof ("/dev/") - 1) != 0)
+ return 1;
+ name = os_dev + sizeof ("/dev/") - 1;
+ grub_util_follow_gpart_up (name, NULL, &whole);
+
+ grub_util_info ("following geom '%s'", name);
+
+ err = geom_gettree (&mesh);
+ if (err != 0)
+ /* TRANSLATORS: geom is the name of (k)FreeBSD device framework.
+ Usually left untranslated.
+ */
+ grub_util_error ("%s", _("couldn't open geom"));
+
+ LIST_FOREACH (class, &mesh.lg_class, lg_class)
+ {
+ struct ggeom *geom;
+ LIST_FOREACH (geom, &class->lg_geom, lg_geom)
+ {
+ struct gprovider *provider;
+ LIST_FOREACH (provider, &geom->lg_provider, lg_provider)
+ if (strcmp (provider->lg_name, name) == 0)
+ {
+ struct gconsumer *consumer;
+ char *fname;
+
+ LIST_FOREACH (consumer, &geom->lg_consumer, lg_consumer)
+ break;
+ if (!consumer)
+ grub_util_error ("%s",
+ _("couldn't find geli consumer"));
+ fname = xasprintf ("/dev/%s", consumer->lg_provider->lg_name);
+ grub_util_info ("consumer %s", consumer->lg_provider->lg_name);
+ lastsubdev = consumer->lg_provider->lg_name;
+ grub_util_pull_device (fname);
+ free (fname);
+ }
+ }
+ }
+ if (ab == GRUB_DEV_ABSTRACTION_GELI && lastsubdev)
+ {
+ char *fname = xasprintf ("/dev/%s", lastsubdev);
+ char *grdev = grub_util_get_grub_dev (fname);
+ free (fname);
+
+ if (grdev)
+ {
+ grub_err_t gr_err;
+ gr_err = grub_cryptodisk_cheat_mount (grdev, os_dev);
+ if (gr_err)
+ grub_util_error (_("can't mount encrypted volume `%s': %s"),
+ lastsubdev, grub_errmsg);
+ }
+
+ grub_free (grdev);
+ }
+ }
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+char *
+grub_util_get_grub_dev_os (const char *os_dev)
+{
+ char *grub_dev = NULL;
+
+ 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.
+ */
+ case GRUB_DEV_ABSTRACTION_LVM:
+ {
+ unsigned short len;
+ grub_size_t offset = sizeof (LVM_DEV_MAPPER_STRING) - 1;
+
+ len = strlen (os_dev) - offset + 1;
+ grub_dev = xmalloc (len + sizeof ("lvm/"));
+
+ grub_memcpy (grub_dev, "lvm/", sizeof ("lvm/") - 1);
+ grub_memcpy (grub_dev + sizeof ("lvm/") - 1, os_dev + offset, len);
+ }
+ break;
+
+ case GRUB_DEV_ABSTRACTION_GELI:
+ {
+ char *whole;
+ struct gmesh mesh;
+ struct gclass *class;
+ const char *name;
+ int err;
+
+ if (strncmp (os_dev, "/dev/", sizeof ("/dev/") - 1) != 0)
+ return 0;
+ name = os_dev + sizeof ("/dev/") - 1;
+ grub_util_follow_gpart_up (name, NULL, &whole);
+
+ grub_util_info ("following geom '%s'", name);
+
+ err = geom_gettree (&mesh);
+ if (err != 0)
+ /* TRANSLATORS: geom is the name of (k)FreeBSD device framework.
+ Usually left untranslated.
+ */
+ grub_util_error ("%s", _("couldn't open geom"));
+
+ LIST_FOREACH (class, &mesh.lg_class, lg_class)
+ {
+ struct ggeom *geom;
+ LIST_FOREACH (geom, &class->lg_geom, lg_geom)
+ {
+ struct gprovider *provider;
+ LIST_FOREACH (provider, &geom->lg_provider, lg_provider)
+ if (strcmp (provider->lg_name, name) == 0)
+ {
+ struct gconsumer *consumer;
+ char *fname;
+ char *uuid;
+
+ LIST_FOREACH (consumer, &geom->lg_consumer, lg_consumer)
+ break;
+ if (!consumer)
+ grub_util_error ("%s",
+ _("couldn't find geli consumer"));
+ fname = xasprintf ("/dev/%s", consumer->lg_provider->lg_name);
+ uuid = grub_util_get_geli_uuid (fname);
+ if (!uuid)
+ grub_util_error ("%s",
+ _("couldn't retrieve geli UUID"));
+ grub_dev = xasprintf ("cryptouuid/%s", uuid);
+ free (fname);
+ free (uuid);
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return grub_dev;
+}
+
+/* FIXME: geom actually gives us the whole container hierarchy.
+ It can be used more efficiently than this. */
+void
+grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out, char **name_out)
+{
+ struct gmesh mesh;
+ struct gclass *class;
+ int err;
+ struct ggeom *geom;
+
+ grub_util_info ("following geom '%s'", name);
+
+ err = geom_gettree (&mesh);
+ if (err != 0)
+ /* TRANSLATORS: geom is the name of (k)FreeBSD device framework.
+ Usually left untranslated.
+ */
+ grub_util_error ("%s", _("couldn't open geom"));
+
+ LIST_FOREACH (class, &mesh.lg_class, lg_class)
+ if (strcasecmp (class->lg_name, "part") == 0)
+ break;
+ if (!class)
+ /* TRANSLATORS: geom is the name of (k)FreeBSD device framework.
+ Usually left untranslated. "part" is the identifier of one of its
+ classes. */
+ grub_util_error ("%s", _("couldn't find geom `part' class"));
+
+ LIST_FOREACH (geom, &class->lg_geom, lg_geom)
+ {
+ struct gprovider *provider;
+ LIST_FOREACH (provider, &geom->lg_provider, lg_provider)
+ if (strcmp (provider->lg_name, name) == 0)
+ {
+ char *name_tmp = xstrdup (geom->lg_name);
+ grub_disk_addr_t off = 0;
+ struct gconfig *config;
+ grub_util_info ("geom '%s' has parent '%s'", name, geom->lg_name);
+
+ grub_util_follow_gpart_up (name_tmp, &off, name_out);
+ free (name_tmp);
+ LIST_FOREACH (config, &provider->lg_config, lg_config)
+ if (strcasecmp (config->lg_name, "offset") == 0)
+ off += strtoull (config->lg_val, 0, 10) / provider->lg_sectorsize;
+ if (off_out)
+ *off_out = off;
+ return;
+ }
+ }
+ grub_util_info ("geom '%s' has no parent", name);
+ if (name_out)
+ *name_out = xstrdup (name);
+ if (off_out)
+ *off_out = 0;
+}
+
+grub_disk_addr_t
+grub_util_find_partition_start_os (const char *dev)
+{
+ grub_disk_addr_t out;
+ if (strncmp (dev, "/dev/", sizeof ("/dev/") - 1) != 0)
+ return 0;
+ grub_util_follow_gpart_up (dev + sizeof ("/dev/") - 1, &out, NULL);
+
+ return out;
+}
diff --git a/grub-core/osdep/freebsd/hostdisk.c b/grub-core/osdep/freebsd/hostdisk.c
new file mode 100644
index 0000000..6145d07
--- /dev/null
+++ b/grub-core/osdep/freebsd/hostdisk.c
@@ -0,0 +1,128 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+# include <sys/disk.h> /* DIOCGMEDIASIZE */
+# include <sys/param.h>
+# include <sys/sysctl.h>
+# include <sys/mount.h>
+# include <libgeom.h>
+
+grub_int64_t
+grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_secsize)
+{
+ unsigned long long nr;
+ unsigned sector_size, log_sector_size;
+
+ if (ioctl (fd, DIOCGMEDIASIZE, &nr))
+ return -1;
+
+ if (ioctl (fd, DIOCGSECTORSIZE, &sector_size))
+ return -1;
+ if (sector_size & (sector_size - 1) || !sector_size)
+ return -1;
+ for (log_sector_size = 0;
+ (1 << log_sector_size) < sector_size;
+ log_sector_size++);
+
+ if (log_secsize)
+ *log_secsize = log_sector_size;
+
+ if (nr & (sector_size - 1))
+ grub_util_error ("%s", _("unaligned device size"));
+
+ return nr;
+}
+
+void
+grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
+{
+}
+
+grub_util_fd_t
+grub_util_fd_open (const char *os_dev, int flags)
+{
+ grub_util_fd_t ret;
+ int sysctl_flags, sysctl_oldflags;
+ size_t sysctl_size = sizeof (sysctl_flags);
+
+#ifdef O_LARGEFILE
+ flags |= O_LARGEFILE;
+#endif
+#ifdef O_BINARY
+ flags |= O_BINARY;
+#endif
+
+ if (sysctlbyname ("kern.geom.debugflags", &sysctl_oldflags, &sysctl_size, NULL, 0))
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, "cannot get current flags of sysctl kern.geom.debugflags");
+ return GRUB_UTIL_FD_INVALID;
+ }
+ sysctl_flags = sysctl_oldflags | 0x10;
+ if (! (sysctl_oldflags & 0x10)
+ && sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_flags, sysctl_size))
+ {
+ 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_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
+
+ if (! (sysctl_oldflags & 0x10)
+ && sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_oldflags, sysctl_size))
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags back to the old value for sysctl kern.geom.debugflags");
+ close (ret);
+ return GRUB_UTIL_FD_INVALID;
+ }
+
+ return ret;
+}
diff --git a/grub-core/osdep/generic/blocklist.c b/grub-core/osdep/generic/blocklist.c
new file mode 100644
index 0000000..2d90403
--- /dev/null
+++ b/grub-core/osdep/generic/blocklist.c
@@ -0,0 +1,132 @@
+/* grub-setup.c - make GRUB usable */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/disk.h>
+#include <grub/file.h>
+#include <grub/partition.h>
+#include <grub/util/misc.h>
+#include <grub/util/install.h>
+#include <grub/emu/hostdisk.h>
+
+#include <string.h>
+
+#define MAX_TRIES 5
+
+void
+grub_install_get_blocklist (grub_device_t root_dev,
+ const char *core_path, const char *core_img,
+ size_t core_size,
+ void (*callback) (grub_disk_addr_t sector,
+ unsigned offset,
+ unsigned length,
+ void *data),
+ void *hook_data)
+{
+ int i;
+ char *tmp_img;
+ char *core_path_dev;
+
+ core_path_dev = grub_make_system_path_relative_to_its_root (core_path);
+
+ /* Make sure that GRUB reads the identical image as the OS. */
+ tmp_img = xmalloc (core_size);
+
+ for (i = 0; i < MAX_TRIES; i++)
+ {
+ grub_file_t file;
+
+ grub_util_info ((i == 0) ? _("attempting to read the core image `%s' from GRUB")
+ : _("attempting to read the core image `%s' from GRUB again"),
+ core_path_dev);
+
+ grub_disk_cache_invalidate_all ();
+
+ file = grub_file_open (core_path_dev, GRUB_FILE_TYPE_NONE | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (file)
+ {
+ if (grub_file_size (file) != core_size)
+ grub_util_info ("succeeded in opening the core image but the size is different (%d != %d)",
+ (int) grub_file_size (file), (int) core_size);
+ else if (grub_file_read (file, tmp_img, core_size)
+ != (grub_ssize_t) core_size)
+ grub_util_info ("succeeded in opening the core image but cannot read %d bytes",
+ (int) core_size);
+ else if (memcmp (core_img, tmp_img, core_size) != 0)
+ {
+#if 0
+ FILE *dump;
+ FILE *dump2;
+
+ dump = fopen ("dump.img", "wb");
+ if (dump)
+ {
+ fwrite (tmp_img, 1, core_size, dump);
+ fclose (dump);
+ }
+
+ dump2 = fopen ("dump2.img", "wb");
+ if (dump2)
+ {
+ fwrite (core_img, 1, core_size, dump2);
+ fclose (dump2);
+ }
+
+#endif
+ grub_util_info ("succeeded in opening the core image but the data is different");
+ }
+ else
+ {
+ grub_file_close (file);
+ break;
+ }
+
+ grub_file_close (file);
+ }
+ else
+ grub_util_info ("couldn't open the core image");
+
+ if (grub_errno)
+ grub_util_info ("error message = %s", grub_errmsg);
+
+ grub_errno = GRUB_ERR_NONE;
+ grub_util_biosdisk_flush (root_dev->disk);
+ sleep (1);
+ }
+
+ if (i == MAX_TRIES)
+ grub_util_error (_("cannot read `%s' correctly"), core_path_dev);
+
+ grub_file_t file;
+ /* Now read the core image to determine where the sectors are. */
+ file = grub_file_open (core_path_dev, GRUB_FILE_TYPE_NONE | GRUB_FILE_TYPE_NO_DECOMPRESS);
+ if (! file)
+ grub_util_error ("%s", grub_errmsg);
+
+ file->read_hook = callback;
+ file->read_hook_data = hook_data;
+ if (grub_file_read (file, tmp_img, core_size) != (grub_ssize_t) core_size)
+ grub_util_error ("%s", _("failed to read the sectors of the core image"));
+
+ grub_file_close (file);
+ free (tmp_img);
+
+ free (core_path_dev);
+}
diff --git a/grub-core/osdep/getroot.c b/grub-core/osdep/getroot.c
new file mode 100644
index 0000000..69a80e9
--- /dev/null
+++ b/grub-core/osdep/getroot.c
@@ -0,0 +1,22 @@
+#ifdef __linux__
+#include "linux/getroot.c"
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include "freebsd/getroot.c"
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
+#include "bsd/getroot.c"
+#elif defined(__APPLE__)
+#include "apple/getroot.c"
+#elif defined(__sun__)
+#include "sun/getroot.c"
+#elif defined(__GNU__)
+#include "hurd/getroot.c"
+#elif defined(__CYGWIN__) || defined (__MINGW32__)
+#include "windows/getroot.c"
+#elif defined(__AROS__)
+#include "aros/getroot.c"
+#elif defined (__HAIKU__)
+#include "haiku/getroot.c"
+#else
+# warning "No getroot OS-specific functions is available for your system. Device detection may not work properly."
+#include "basic/getroot.c"
+#endif
diff --git a/grub-core/osdep/haiku/getroot.c b/grub-core/osdep/haiku/getroot.c
new file mode 100644
index 0000000..4e123c0
--- /dev/null
+++ b/grub-core/osdep/haiku/getroot.c
@@ -0,0 +1,105 @@
+#include <config.h>
+#include <config-util.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+#include <stdint.h>
+#include <grub/util/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <fs_info.h>
+#include <Drivers.h>
+#include <StorageDefs.h>
+
+enum grub_dev_abstraction_types
+grub_util_get_dev_abstraction_os (const char *os_dev __attribute__((unused)))
+{
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+int
+grub_util_pull_device_os (const char *os_dev __attribute__ ((unused)),
+ enum grub_dev_abstraction_types ab __attribute__ ((unused)))
+{
+ return 0;
+}
+
+char *
+grub_util_get_grub_dev_os (const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+char **
+grub_guess_root_devices (const char *dir_in)
+{
+ dev_t dv = dev_for_path (dir_in);
+ fs_info inf;
+ char **ret;
+ if (fs_stat_dev (dv, &inf) != B_OK)
+ return NULL;
+ ret = xmalloc (2 * sizeof (ret[0]));
+ ret[0] = xstrdup (inf.device_name);
+ ret[1] = NULL;
+ return ret;
+}
+
+grub_disk_addr_t
+grub_util_find_partition_start_os (const char *dev)
+{
+ partition_info part;
+ grub_disk_addr_t ret;
+ int fd = open (dev, O_RDONLY);
+ if (fd < 0)
+ return 0;
+ if (ioctl (fd, B_GET_PARTITION_INFO, &part, sizeof (part)) < 0)
+ {
+ close (fd);
+ return 0;
+ }
+ ret = part.offset;
+ close (fd);
+ fd = open (part.device, O_RDONLY);
+
+ device_geometry geo;
+ if (ioctl (fd, B_GET_GEOMETRY, &geo, sizeof (geo)) < 0)
+ return 0;
+ ret /= geo.bytes_per_sector ? : 512;
+ close (fd);
+ return ret;
+}
+
+char *
+grub_util_part_to_disk (const char *os_dev,
+ struct stat *st __attribute__ ((unused)),
+ int *is_part)
+{
+ char *ret;
+ partition_info part;
+ int fd = open (os_dev, O_RDONLY);
+ *is_part = 0;
+
+ if (fd < 0)
+ return xstrdup (os_dev);
+ if (ioctl (fd, B_GET_PARTITION_INFO, &part, sizeof (part)) < 0)
+ {
+ close (fd);
+ return xstrdup (os_dev);
+ }
+ ret = xstrdup (part.device);
+ close (fd);
+ *is_part=1;
+ return ret;
+}
+
+int
+grub_util_biosdisk_is_floppy (grub_disk_t disk)
+{
+ const char *dname;
+
+ dname = grub_util_biosdisk_get_osdev (disk);
+
+ return (strncmp (dname, "/dev/disk/floppy/", sizeof ("/dev/disk/floppy/") - 1)
+ == 0);
+}
diff --git a/grub-core/osdep/haiku/hostdisk.c b/grub-core/osdep/haiku/hostdisk.c
new file mode 100644
index 0000000..5623539
--- /dev/null
+++ b/grub-core/osdep/haiku/hostdisk.c
@@ -0,0 +1,69 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+#include <sys/ioctl.h>
+#include <Drivers.h>
+#include <StorageDefs.h>
+
+grub_int64_t
+grub_util_get_fd_size_os (grub_util_fd_t fd,
+ const char *name __attribute__ ((unused)),
+ unsigned *log_secsize)
+{
+ device_geometry part;
+ unsigned lg;
+ if (ioctl (fd, B_GET_GEOMETRY, &part, sizeof (part)) < 0)
+ return -1;
+ for (lg = 0; (1 << lg) < part.bytes_per_sector; lg++);
+ if (log_secsize)
+ *log_secsize= lg;
+ return ((grub_uint64_t) part.cylinder_count
+ * (grub_uint64_t) part.head_count
+ * (grub_uint64_t) part.sectors_per_track
+ * (grub_uint64_t) part.bytes_per_sector);
+}
+
+void
+grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
+{
+}
diff --git a/grub-core/osdep/hostdisk.c b/grub-core/osdep/hostdisk.c
new file mode 100644
index 0000000..1853979
--- /dev/null
+++ b/grub-core/osdep/hostdisk.c
@@ -0,0 +1,22 @@
+#ifdef __linux__
+#include "linux/hostdisk.c"
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include "freebsd/hostdisk.c"
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
+#include "bsd/hostdisk.c"
+#elif defined(__APPLE__)
+#include "apple/hostdisk.c"
+#elif defined(__sun__)
+#include "sun/hostdisk.c"
+#elif defined(__GNU__)
+#include "hurd/hostdisk.c"
+#elif defined(__CYGWIN__) || defined(__MINGW32__)
+#include "windows/hostdisk.c"
+#elif defined(__AROS__)
+#include "aros/hostdisk.c"
+#elif defined (__HAIKU__)
+#include "haiku/hostdisk.c"
+#else
+# warning "No hostdisk OS-specific functions is available for your system. Device detection may not work properly."
+#include "basic/hostdisk.c"
+#endif
diff --git a/grub-core/osdep/hurd/getroot.c b/grub-core/osdep/hurd/getroot.c
new file mode 100644
index 0000000..c66b206
--- /dev/null
+++ b/grub-core/osdep/hurd/getroot.c
@@ -0,0 +1,247 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <grub/types.h>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+
+#include <sys/wait.h>
+
+#include <hurd.h>
+#include <hurd/lookup.h>
+#include <hurd/fs.h>
+#include <sys/mman.h>
+
+static char *
+grub_util_find_hurd_root_device (const char *path)
+{
+ file_t file;
+ error_t err;
+ char *argz = NULL, *name = NULL, *ret;
+ size_t argz_len = 0;
+ int i;
+
+ file = file_name_lookup (path, 0, 0);
+ if (file == MACH_PORT_NULL)
+ /* TRANSLATORS: The first %s is the file being looked at, the second %s is
+ the error message. */
+ grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
+
+ /* This returns catenated 0-terminated strings. */
+ err = file_get_fs_options (file, &argz, &argz_len);
+ if (err)
+ /* TRANSLATORS: On GNU/Hurd, a "translator" is similar to a filesystem
+ mount, but handled by a userland daemon, whose invocation command line
+ is being fetched here. First %s is the file being looked at (for which
+ we are fetching the "translator" command line), second %s is the error
+ message.
+ */
+ grub_util_error (_("cannot get translator command line "
+ "for path `%s': %s"), path, strerror(err));
+ if (argz_len == 0)
+ grub_util_error (_("translator command line is empty for path `%s'"), path);
+
+ /* Make sure the string is terminated. */
+ argz[argz_len-1] = 0;
+
+ /* Skip first word (translator path) and options. */
+ for (i = strlen (argz) + 1; i < argz_len; i += strlen (argz + i) + 1)
+ {
+ if (argz[i] != '-')
+ {
+ /* Non-option. Only accept one, assumed to be the FS path. */
+ /* XXX: this should be replaced by an RPC to the translator. */
+ if (name)
+ /* TRANSLATORS: we expect to get something like
+ /hurd/foobar --option1 --option2=baz /dev/something
+ */
+ grub_util_error (_("translator `%s' for path `%s' has several "
+ "non-option words, at least `%s' and `%s'"),
+ argz, path, name, argz + i);
+ name = argz + i;
+ }
+ }
+
+ if (!name)
+ /* TRANSLATORS: we expect to get something like
+ /hurd/foobar --option1 --option2=baz /dev/something
+ */
+ grub_util_error (_("translator `%s' for path `%s' is given only options, "
+ "cannot find device part"), argz, path);
+
+ if (strncmp (name, "device:", sizeof ("device:") - 1) == 0)
+ {
+ char *dev_name = name + sizeof ("device:") - 1;
+ size_t size = sizeof ("/dev/") - 1 + strlen (dev_name) + 1;
+ char *next;
+ ret = malloc (size);
+ next = stpncpy (ret, "/dev/", size);
+ stpncpy (next, dev_name, size - (next - ret));
+ }
+ else if (!strncmp (name, "file:", sizeof ("file:") - 1))
+ ret = strdup (name + sizeof ("file:") - 1);
+ else
+ ret = strdup (name);
+
+ munmap (argz, argz_len);
+ return ret;
+}
+
+static int
+is_fulldisk (const char *child, const char *parent)
+{
+ if (strcmp (parent, child) == 0)
+ return 1;
+ if (strncmp (parent, "/dev/", sizeof ("/dev/") - 1) == 0
+ && child[0] !=0 && strcmp (parent + sizeof ("/dev/") - 1, child) == 0)
+ return 1;
+ if (strncmp (child, "/dev/", sizeof ("/dev/") - 1) == 0
+ && parent[0] != 0 && strcmp (child + sizeof ("/dev/") - 1, parent) == 0)
+ return 1;
+ return 0;
+}
+
+char *
+grub_util_part_to_disk (const char *os_dev,
+ struct stat *st,
+ int *is_part)
+{
+ char *path;
+ grub_disk_addr_t offset;
+ char *p;
+
+ if (! S_ISBLK (st->st_mode))
+ {
+ *is_part = 0;
+ return xstrdup (os_dev);
+ }
+
+ if (!grub_util_hurd_get_disk_info (os_dev, NULL, &offset, NULL, &path))
+ return xstrdup (os_dev);
+
+ /* Some versions of Hurd use badly glued Linux code to handle partitions
+ resulting in partitions being promoted to disks. */
+ if (path && !(offset == 0 && is_fulldisk (path, os_dev)
+ && (strncmp ("/dev/sd", os_dev, 7) == 0
+ || strncmp ("/dev/hd", os_dev, 7) == 0)))
+ {
+ *is_part = !is_fulldisk (path, os_dev);
+ if (path[0] != '/')
+ {
+ char *n = xasprintf ("/dev/%s", path);
+ free (path);
+ path = n;
+ }
+ return path;
+ }
+ free (path);
+
+ path = xstrdup (os_dev);
+
+ p = strchr (path + 7, 's');
+ if (p)
+ {
+ *is_part = 1;
+ *p = '\0';
+ }
+ return path;
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dev_abstraction_os (const char *os_dev __attribute__((unused)))
+{
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+int
+grub_util_pull_device_os (const char *os_dev __attribute__ ((unused)),
+ enum grub_dev_abstraction_types ab __attribute__ ((unused)))
+{
+ return 0;
+}
+
+char *
+grub_util_get_grub_dev_os (const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+grub_disk_addr_t
+grub_util_find_partition_start_os (const char *dev)
+{
+ grub_uint32_t secsize;
+ grub_disk_addr_t offset;
+ char *path;
+ if (!grub_util_hurd_get_disk_info (dev, &secsize, &offset, NULL, &path))
+ return 0;
+ if (path && !(offset == 0 && is_fulldisk (path, dev)
+ && (strncmp ("/dev/sd", dev, 7) == 0
+ || strncmp ("/dev/hd", dev, 7) == 0)))
+ {
+ free (path);
+ return (secsize / 512) * offset;
+ }
+ free (path);
+ return -1;
+}
+
+char **
+grub_guess_root_devices (const char *dir)
+{
+ char **os_dev = NULL;
+
+ os_dev = xmalloc (2 * sizeof (os_dev[0]));
+
+ /* GNU/Hurd specific function. */
+ os_dev[0] = grub_util_find_hurd_root_device (dir);
+
+ if (!os_dev[0])
+ {
+ free (os_dev);
+ return 0;
+ }
+
+ os_dev[1] = 0;
+
+ return os_dev;
+}
diff --git a/grub-core/osdep/hurd/hostdisk.c b/grub-core/osdep/hurd/hostdisk.c
new file mode 100644
index 0000000..c47b5a5
--- /dev/null
+++ b/grub-core/osdep/hurd/hostdisk.c
@@ -0,0 +1,146 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+#include <hurd.h>
+#include <hurd/lookup.h>
+#include <hurd/fs.h>
+#include <sys/mman.h>
+
+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)
+{
+ file_t file;
+ mach_port_t *ports;
+ int *ints;
+ loff_t *offsets;
+ char *data;
+ error_t err;
+ mach_msg_type_number_t num_ports = 0, num_ints = 0, num_offsets = 0, data_len = 0;
+
+ file = file_name_lookup (dev, 0, 0);
+ if (file == MACH_PORT_NULL)
+ return 0;
+
+ err = file_get_storage_info (file,
+ &ports, &num_ports,
+ &ints, &num_ints,
+ &offsets, &num_offsets,
+ &data, &data_len);
+
+ if (num_ints < 1)
+ 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 information for `%s' indicates neither a plain partition nor a plain disk"), dev);
+ if (parent)
+ {
+ *parent = NULL;
+ if (num_ints >= 5)
+ {
+ size_t len = ints[4];
+ if (len > data_len)
+ len = data_len;
+ *parent = xmalloc (len+1);
+ memcpy (*parent, data, len);
+ (*parent)[len] = '\0';
+ }
+ }
+ if (offset)
+ *offset = offsets[0];
+ if (size)
+ *size = offsets[1];
+ if (secsize)
+ *secsize = ints[2];
+ if (ports && num_ports > 0)
+ {
+ mach_msg_type_number_t i;
+ for (i = 0; i < num_ports; i++)
+ {
+ mach_port_t port = ports[i];
+ if (port != MACH_PORT_NULL)
+ mach_port_deallocate (mach_task_self(), port);
+ }
+ munmap ((caddr_t) ports, num_ports * sizeof (*ports));
+ }
+
+ if (ints && num_ints > 0)
+ munmap ((caddr_t) ints, num_ints * sizeof (*ints));
+ if (offsets && num_offsets > 0)
+ munmap ((caddr_t) offsets, num_offsets * sizeof (*offsets));
+ if (data && data_len > 0)
+ munmap (data, data_len);
+ mach_port_deallocate (mach_task_self (), file);
+
+ return 1;
+}
+
+grub_int64_t
+grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_secsize)
+{
+ grub_uint32_t sector_size;
+ grub_disk_addr_t size;
+ unsigned log_sector_size;
+
+ if (!grub_util_hurd_get_disk_info (name, &sector_size, NULL, &size, NULL))
+ return -1;
+
+ if (sector_size & (sector_size - 1) || !sector_size)
+ return -1;
+ for (log_sector_size = 0;
+ (1 << log_sector_size) < sector_size;
+ log_sector_size++);
+
+ if (log_secsize)
+ *log_secsize = log_sector_size;
+
+ return size << log_sector_size;
+}
+
+void
+grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
+{
+}
diff --git a/grub-core/osdep/init.c b/grub-core/osdep/init.c
new file mode 100644
index 0000000..207f670
--- /dev/null
+++ b/grub-core/osdep/init.c
@@ -0,0 +1,5 @@
+#if defined (__MINGW32__)
+#include "windows/init.c"
+#else
+#include "basic/init.c"
+#endif
diff --git a/grub-core/osdep/linux/blocklist.c b/grub-core/osdep/linux/blocklist.c
new file mode 100644
index 0000000..c77d608
--- /dev/null
+++ b/grub-core/osdep/linux/blocklist.c
@@ -0,0 +1,136 @@
+/* grub-setup.c - make GRUB usable */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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 <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <assert.h>
+#include <sys/ioctl.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/fiemap.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/util/misc.h>
+#include <grub/util/install.h>
+#include <errno.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+void
+grub_install_get_blocklist (grub_device_t root_dev,
+ const char *core_path,
+ const char *core_img __attribute__ ((unused)),
+ size_t core_size,
+ void (*callback) (grub_disk_addr_t sector,
+ unsigned offset,
+ unsigned length,
+ void *data),
+ void *hook_data)
+{
+ grub_partition_t container = root_dev->disk->partition;
+ grub_uint64_t container_start = grub_partition_get_start (container);
+ struct fiemap fie1;
+ int fd;
+
+ /* Write the first two sectors of the core image onto the disk. */
+ grub_util_info ("opening the core image `%s'", core_path);
+ fd = open (core_path, O_RDONLY);
+ if (fd < 0)
+ grub_util_error (_("cannot open `%s': %s"), core_path,
+ strerror (errno));
+
+ grub_memset (&fie1, 0, sizeof (fie1));
+ fie1.fm_length = core_size;
+ fie1.fm_flags = FIEMAP_FLAG_SYNC;
+
+ if (ioctl (fd, FS_IOC_FIEMAP, &fie1) < 0)
+ {
+ int nblocks, i;
+ int bsize;
+ int mul;
+
+ grub_util_info ("FIEMAP failed. Reverting to FIBMAP");
+
+ if (ioctl (fd, FIGETBSZ, &bsize) < 0)
+ grub_util_error (_("can't retrieve blocklists: %s"),
+ 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)
+ grub_util_error ("%s", _("can't retrieve blocklists"));
+ for (i = 0; i < nblocks; i++)
+ {
+ unsigned blk = i;
+ int rest;
+ if (ioctl (fd, FIBMAP, &blk) < 0)
+ grub_util_error (_("can't retrieve blocklists: %s"),
+ strerror (errno));
+
+ rest = core_size - ((i * mul) << GRUB_DISK_SECTOR_BITS);
+ if (rest <= 0)
+ break;
+ if (rest > GRUB_DISK_SECTOR_SIZE * mul)
+ rest = GRUB_DISK_SECTOR_SIZE * mul;
+ callback (((grub_uint64_t) blk) * mul
+ + container_start,
+ 0, rest, hook_data);
+ }
+ }
+ else
+ {
+ struct fiemap *fie2;
+ int i;
+ fie2 = xmalloc (sizeof (*fie2)
+ + fie1.fm_mapped_extents
+ * sizeof (fie1.fm_extents[1]));
+ memset (fie2, 0, sizeof (*fie2)
+ + fie1.fm_mapped_extents * sizeof (fie2->fm_extents[1]));
+ fie2->fm_length = core_size;
+ fie2->fm_flags = FIEMAP_FLAG_SYNC;
+ fie2->fm_extent_count = fie1.fm_mapped_extents;
+ if (ioctl (fd, FS_IOC_FIEMAP, fie2) < 0)
+ grub_util_error (_("can't retrieve blocklists: %s"),
+ strerror (errno));
+ for (i = 0; i < fie2->fm_mapped_extents; i++)
+ {
+ callback ((fie2->fm_extents[i].fe_physical
+ >> GRUB_DISK_SECTOR_BITS)
+ + container_start,
+ fie2->fm_extents[i].fe_physical
+ & (GRUB_DISK_SECTOR_SIZE - 1),
+ fie2->fm_extents[i].fe_length, hook_data);
+ }
+ free (fie2);
+ }
+ close (fd);
+}
diff --git a/grub-core/osdep/linux/emunet.c b/grub-core/osdep/linux/emunet.c
new file mode 100644
index 0000000..19b188f
--- /dev/null
+++ b/grub-core/osdep/linux/emunet.c
@@ -0,0 +1,74 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010,2011,2012,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 <config.h>
+#include <config-util.h>
+
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <linux/if.h>
+#include <linux/if_tun.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include <grub/emu/net.h>
+
+static int fd;
+
+grub_ssize_t
+grub_emunet_send (const void *packet, grub_size_t sz)
+{
+ return write (fd, packet, sz);
+}
+
+grub_ssize_t
+grub_emunet_receive (void *packet, grub_size_t sz)
+{
+ return read (fd, packet, sz);
+}
+
+int
+grub_emunet_create (grub_size_t *mtu)
+{
+ struct ifreq ifr;
+ *mtu = 1500;
+ fd = open ("/dev/net/tun", O_RDWR | O_NONBLOCK);
+ if (fd < 0)
+ return -1;
+ memset (&ifr, 0, sizeof (ifr));
+ ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+ if (ioctl (fd, TUNSETIFF, &ifr) < 0)
+ {
+ close (fd);
+ fd = -1;
+ return -1;
+ }
+ return 0;
+}
+
+void
+grub_emunet_close (void)
+{
+ if (fd < 0)
+ return;
+
+ close (fd);
+ fd = -1;
+}
diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
new file mode 100644
index 0000000..001b818
--- /dev/null
+++ b/grub-core/osdep/linux/getroot.c
@@ -0,0 +1,1164 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#ifdef HAVE_LIMITS_H
+#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>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+
+#include <sys/wait.h>
+
+#include <linux/types.h>
+#include <linux/major.h>
+#include <linux/raid/md_p.h>
+#include <linux/raid/md_u.h>
+#include <grub/i18n.h>
+#include <grub/emu/exec.h>
+#include <grub/btrfs.h>
+
+#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
+
+/* Defines taken from btrfs/ioctl.h. */
+
+struct btrfs_ioctl_dev_info_args
+{
+ grub_uint64_t devid;
+ grub_uint8_t uuid[16];
+ grub_uint64_t bytes_used;
+ grub_uint64_t total_bytes;
+ grub_uint64_t unused[379];
+ grub_uint8_t path[1024];
+};
+
+struct btrfs_ioctl_fs_info_args
+{
+ grub_uint64_t max_id;
+ grub_uint64_t num_devices;
+ grub_uint8_t fsid[16];
+ grub_uint64_t reserved[124];
+};
+
+struct btrfs_ioctl_ino_lookup_args
+{
+ grub_uint64_t treeid;
+ grub_uint64_t objectid;
+ char name[4080];
+};
+
+struct btrfs_ioctl_search_key
+{
+ grub_uint64_t tree_id;
+ grub_uint64_t min_objectid;
+ grub_uint64_t max_objectid;
+ grub_uint64_t min_offset;
+ grub_uint64_t max_offset;
+ grub_uint64_t min_transid;
+ grub_uint64_t max_transid;
+ grub_uint32_t min_type;
+ grub_uint32_t max_type;
+ grub_uint32_t nr_items;
+ grub_uint32_t unused[9];
+};
+
+struct btrfs_ioctl_search_args {
+ struct btrfs_ioctl_search_key key;
+ grub_uint64_t buf[(4096 - sizeof(struct btrfs_ioctl_search_key))
+ / sizeof (grub_uint64_t)];
+};
+
+#define BTRFS_IOC_TREE_SEARCH _IOWR(0x94, 17, \
+ struct btrfs_ioctl_search_args)
+#define BTRFS_IOC_INO_LOOKUP _IOWR(0x94, 18, \
+ struct btrfs_ioctl_ino_lookup_args)
+#define BTRFS_IOC_DEV_INFO _IOWR(0x94, 30, \
+ struct btrfs_ioctl_dev_info_args)
+#define BTRFS_IOC_FS_INFO _IOR(0x94, 31, \
+ struct btrfs_ioctl_fs_info_args)
+
+static int
+grub_util_is_imsm (const char *os_dev);
+
+
+#define ESCAPED_PATH_MAX (4 * PATH_MAX)
+struct mountinfo_entry
+{
+ int id;
+ int major, minor;
+ char enc_root[ESCAPED_PATH_MAX + 1], enc_path[ESCAPED_PATH_MAX + 1];
+ char fstype[ESCAPED_PATH_MAX + 1], device[ESCAPED_PATH_MAX + 1];
+};
+
+static char **
+grub_util_raid_getmembers (const char *name, int bootable)
+{
+ int fd, ret, i, j;
+ char **devicelist;
+ mdu_version_t version;
+ mdu_array_info_t info;
+ mdu_disk_info_t disk;
+
+ fd = open (name, O_RDONLY);
+
+ if (fd == -1)
+ grub_util_error (_("cannot open `%s': %s"), name, strerror (errno));
+
+ ret = ioctl (fd, RAID_VERSION, &version);
+ if (ret != 0)
+ grub_util_error (_("ioctl RAID_VERSION error: %s"), strerror (errno));
+
+ if ((version.major != 0 || version.minor != 90)
+ && (version.major != 1 || version.minor != 0)
+ && (version.major != 1 || version.minor != 1)
+ && (version.major != 1 || version.minor != 2))
+ grub_util_error (_("unsupported RAID version: %d.%d"),
+ version.major, version.minor);
+
+ if (bootable && (version.major != 0 || version.minor != 90))
+ grub_util_error (_("unsupported RAID version: %d.%d"),
+ version.major, version.minor);
+
+ ret = ioctl (fd, GET_ARRAY_INFO, &info);
+ if (ret != 0)
+ grub_util_error (_("ioctl GET_ARRAY_INFO error: %s"), strerror (errno));
+
+ devicelist = xcalloc (info.nr_disks + 1, sizeof (char *));
+
+ for (i = 0, j = 0; j < info.nr_disks; i++)
+ {
+ disk.number = i;
+ ret = ioctl (fd, GET_DISK_INFO, &disk);
+ if (ret != 0)
+ grub_util_error (_("ioctl GET_DISK_INFO error: %s"), strerror (errno));
+
+ if (disk.state & (1 << MD_DISK_REMOVED))
+ continue;
+
+ if (disk.state & (1 << MD_DISK_ACTIVE))
+ devicelist[j] = grub_find_device (NULL,
+ makedev (disk.major, disk.minor));
+ else
+ devicelist[j] = NULL;
+ j++;
+ }
+
+ devicelist[j] = NULL;
+
+ close (fd);
+
+ return devicelist;
+}
+
+/* Statting something on a btrfs filesystem always returns a virtual device
+ major/minor pair rather than the real underlying device, because btrfs
+ can span multiple underlying devices (and even if it's currently only
+ using a single device it can be dynamically extended onto another). We
+ can't deal with the multiple-device case yet, but in the meantime, we can
+ at least cope with the single-device case by scanning
+ /proc/self/mountinfo. */
+static void
+unescape (char *str)
+{
+ char *optr;
+ const char *iptr;
+ for (iptr = optr = str; *iptr; optr++)
+ {
+ if (iptr[0] == '\\' && iptr[1] >= '0' && iptr[1] < '8'
+ && iptr[2] >= '0' && iptr[2] < '8'
+ && iptr[3] >= '0' && iptr[3] < '8')
+ {
+ *optr = (((iptr[1] - '0') << 6) | ((iptr[2] - '0') << 3)
+ | (iptr[3] - '0'));
+ iptr += 4;
+ }
+ else
+ *optr = *iptr++;
+ }
+ *optr = 0;
+}
+
+static char **
+grub_find_root_devices_from_btrfs (const char *dir)
+{
+ int fd;
+ struct btrfs_ioctl_fs_info_args fsi;
+ int i, j = 0;
+ char **ret;
+
+ fd = open (dir, 0);
+ if (fd < 0)
+ return NULL;
+
+ if (ioctl (fd, BTRFS_IOC_FS_INFO, &fsi) < 0)
+ {
+ close (fd);
+ return NULL;
+ }
+
+ ret = xcalloc (fsi.num_devices + 1, sizeof (ret[0]));
+
+ for (i = 1; i <= fsi.max_id && j < fsi.num_devices; i++)
+ {
+ struct btrfs_ioctl_dev_info_args devi;
+ memset (&devi, 0, sizeof (devi));
+ devi.devid = i;
+ if (ioctl (fd, BTRFS_IOC_DEV_INFO, &devi) < 0)
+ {
+ close (fd);
+ free (ret);
+ return NULL;
+ }
+ ret[j++] = xstrdup ((char *) devi.path);
+ if (j >= fsi.num_devices)
+ break;
+ }
+ close (fd);
+ ret[j] = 0;
+ return ret;
+}
+
+static char *
+get_btrfs_fs_prefix (const char *mount_path)
+{
+ struct btrfs_ioctl_ino_lookup_args args;
+ struct stat st;
+ int fd;
+ grub_uint64_t tree_id, inode_id;
+ char *ret = NULL;
+
+ fd = open (mount_path, O_RDONLY);
+
+ if (fd < 0)
+ return NULL;
+ memset (&args, 0, sizeof(args));
+ args.objectid = GRUB_BTRFS_TREE_ROOT_OBJECTID;
+
+ if (ioctl (fd, BTRFS_IOC_INO_LOOKUP, &args) < 0)
+ goto fail;
+ tree_id = args.treeid;
+
+ if (fstat (fd, &st) < 0)
+ goto fail;
+ inode_id = st.st_ino;
+
+ while (tree_id != GRUB_BTRFS_ROOT_VOL_OBJECTID
+ || inode_id != GRUB_BTRFS_TREE_ROOT_OBJECTID)
+ {
+ const char *name;
+ size_t namelen;
+ struct btrfs_ioctl_search_args sargs;
+ char *old;
+
+ memset (&sargs, 0, sizeof(sargs));
+
+ if (inode_id == GRUB_BTRFS_TREE_ROOT_OBJECTID)
+ {
+ struct grub_btrfs_root_backref *br;
+
+ sargs.key.tree_id = 1;
+ sargs.key.min_objectid = tree_id;
+ sargs.key.max_objectid = tree_id;
+
+ sargs.key.min_offset = 0;
+ sargs.key.max_offset = ~0ULL;
+ sargs.key.min_transid = 0;
+ sargs.key.max_transid = ~0ULL;
+ sargs.key.min_type = GRUB_BTRFS_ITEM_TYPE_ROOT_BACKREF;
+ sargs.key.max_type = GRUB_BTRFS_ITEM_TYPE_ROOT_BACKREF;
+
+ sargs.key.nr_items = 1;
+
+ if (ioctl (fd, BTRFS_IOC_TREE_SEARCH, &sargs) < 0)
+ goto fail;
+
+ if (sargs.key.nr_items == 0)
+ goto fail;
+
+ tree_id = sargs.buf[2];
+ br = (struct grub_btrfs_root_backref *) (sargs.buf + 4);
+ inode_id = grub_le_to_cpu64 (br->inode_id);
+ name = br->name;
+ namelen = grub_le_to_cpu16 (br->n);
+ }
+ else
+ {
+ struct grub_btrfs_inode_ref *ir;
+
+ sargs.key.tree_id = tree_id;
+ sargs.key.min_objectid = inode_id;
+ sargs.key.max_objectid = inode_id;
+
+ sargs.key.min_offset = 0;
+ sargs.key.max_offset = ~0ULL;
+ sargs.key.min_transid = 0;
+ sargs.key.max_transid = ~0ULL;
+ sargs.key.min_type = GRUB_BTRFS_ITEM_TYPE_INODE_REF;
+ sargs.key.max_type = GRUB_BTRFS_ITEM_TYPE_INODE_REF;
+
+ if (ioctl (fd, BTRFS_IOC_TREE_SEARCH, &sargs) < 0)
+ goto fail;
+
+ if (sargs.key.nr_items == 0)
+ goto fail;
+
+ inode_id = sargs.buf[2];
+
+ ir = (struct grub_btrfs_inode_ref *) (sargs.buf + 4);
+ name = ir->name;
+ namelen = grub_le_to_cpu16 (ir->n);
+ }
+ old = ret;
+ ret = xmalloc (namelen + (old ? strlen (old) : 0) + 2);
+ ret[0] = '/';
+ memcpy (ret + 1, name, namelen);
+ if (old)
+ {
+ strcpy (ret + 1 + namelen, old);
+ free (old);
+ }
+ else
+ ret[1+namelen] = '\0';
+ }
+ if (!ret)
+ ret = xstrdup ("/");
+ close (fd);
+ return ret;
+
+ fail:
+ free (ret);
+ close (fd);
+ return NULL;
+}
+
+
+char **
+grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
+{
+ FILE *fp = NULL;
+ char *buf = NULL;
+ size_t len = 0;
+ grub_size_t entry_len, entry_max = 4;
+ struct mountinfo_entry *entries;
+ struct mountinfo_entry parent_entry = { 0, 0, 0, "", "", "", "" };
+ int i;
+ int retry = 0;
+ int dir_fd = -1;
+ char **ret = NULL;
+
+ if (! *dir)
+ dir = "/";
+ if (relroot)
+ *relroot = NULL;
+
+ entries = xcalloc (entry_max, sizeof (*entries));
+
+again:
+ fp = grub_util_fopen ("/proc/self/mountinfo", "r");
+ if (! fp)
+ goto out; /* fall through to other methods */
+
+ entry_len = 0;
+
+ /* First, build a list of relevant visible mounts. */
+ while (getline (&buf, &len, fp) > 0)
+ {
+ struct mountinfo_entry entry;
+ int count;
+ size_t enc_path_len;
+ const char *sep;
+
+ if (sscanf (buf, "%d %d %u:%u %s %s%n",
+ &entry.id, &parent_entry.id, &entry.major, &entry.minor,
+ entry.enc_root, entry.enc_path, &count) < 6)
+ continue;
+
+ unescape (entry.enc_root);
+ unescape (entry.enc_path);
+
+ enc_path_len = strlen (entry.enc_path);
+ /* Check that enc_path is a prefix of dir. The prefix must either be
+ the entire string, or end with a slash, or be immediately followed
+ by a slash. */
+ if (strncmp (dir, entry.enc_path, enc_path_len) != 0 ||
+ (enc_path_len && dir[enc_path_len - 1] != '/' &&
+ dir[enc_path_len] && dir[enc_path_len] != '/'))
+ continue;
+
+ sep = strstr (buf + count, " - ");
+ if (!sep)
+ continue;
+
+ sep += sizeof (" - ") - 1;
+ if (sscanf (sep, "%s %s", entry.fstype, entry.device) != 2)
+ continue;
+
+ unescape (entry.device);
+
+ /* Using the mount IDs, find out where this fits in the list of
+ visible mount entries we've seen so far. There are three
+ interesting cases. Firstly, it may be inserted at the end: this is
+ the usual case of /foo/bar being mounted after /foo. Secondly, it
+ may be inserted at the start: for example, this can happen for
+ filesystems that are mounted before / and later moved under it.
+ Thirdly, it may occlude part or all of the existing filesystem
+ tree, in which case the end of the list needs to be pruned and this
+ new entry will be inserted at the end. */
+ if (entry_len >= entry_max)
+ {
+ entry_max <<= 1;
+ entries = xrealloc (entries, entry_max * sizeof (*entries));
+ }
+
+ if (!entry_len)
+ {
+ /* Initialise list. */
+ entry_len = 2;
+ entries[0] = parent_entry;
+ entries[1] = entry;
+ }
+ else
+ {
+ for (i = entry_len - 1; i >= 0; i--)
+ {
+ if (entries[i].id == parent_entry.id)
+ {
+ /* Insert at end, pruning anything previously above this. */
+ entry_len = i + 2;
+ entries[i + 1] = entry;
+ break;
+ }
+ else if (i == 0 && entries[i].id == entry.id)
+ {
+ /* Insert at start. */
+ entry_len++;
+ memmove (entries + 1, entries,
+ (entry_len - 1) * sizeof (*entries));
+ entries[0] = parent_entry;
+ entries[1] = entry;
+ break;
+ }
+ }
+ }
+ }
+
+ /* Now scan visible mounts for the ones we're interested in. */
+ for (i = entry_len - 1; i >= 0; i--)
+ {
+ char *fs_prefix = NULL;
+ if (!*entries[i].device)
+ continue;
+
+ if (grub_strcmp (entries[i].fstype, "fuse.zfs") == 0
+ || grub_strcmp (entries[i].fstype, "zfs") == 0)
+ {
+ char *slash;
+ slash = strchr (entries[i].device, '/');
+ if (slash)
+ *slash = 0;
+ ret = grub_util_find_root_devices_from_poolname (entries[i].device);
+ if (slash)
+ *slash = '/';
+ if (relroot)
+ {
+ if (!slash)
+ fs_prefix = xasprintf ("/@%s", entries[i].enc_root);
+ else if (strchr (slash + 1, '@'))
+ fs_prefix = xasprintf ("/%s%s", slash + 1, entries[i].enc_root);
+ else
+ fs_prefix = xasprintf ("/%s@%s", slash + 1,
+ entries[i].enc_root);
+ }
+ }
+ else if (grub_strcmp (entries[i].fstype, "btrfs") == 0)
+ {
+ ret = grub_find_root_devices_from_btrfs (dir);
+ fs_prefix = get_btrfs_fs_prefix (entries[i].enc_path);
+ }
+ else if (!retry && grub_strcmp (entries[i].fstype, "autofs") == 0)
+ {
+ /* If the best match is automounted, try to trigger mount. We cannot
+ simply return here because stat() on automounted directory does not
+ trigger mount and returns bogus (pseudo)device number instead.
+ We keep mountpoint open until end of scan to prevent timeout. */
+
+ int flags = O_RDONLY|O_DIRECTORY;
+
+ fclose (fp);
+#ifdef O_LARGEFILE
+ flags |= O_LARGEFILE;
+#endif
+ dir_fd = open (entries[i].enc_path, flags);
+ retry = 1;
+ goto again;
+ }
+ if (!ret)
+ {
+ ret = xmalloc (2 * sizeof (ret[0]));
+ ret[0] = strdup (entries[i].device);
+ ret[1] = 0;
+ }
+ if (!fs_prefix)
+ fs_prefix = entries[i].enc_root;
+ if (relroot)
+ {
+ char *ptr;
+ grub_size_t enc_root_len = strlen (fs_prefix);
+ grub_size_t enc_path_len = strlen (entries[i].enc_path);
+ grub_size_t dir_strlen = strlen (dir);
+ *relroot = xmalloc (enc_root_len +
+ 2 + dir_strlen);
+ ptr = grub_stpcpy (*relroot, fs_prefix);
+ if (dir_strlen > enc_path_len)
+ {
+ while (ptr > *relroot && *(ptr - 1) == '/')
+ ptr--;
+ if (dir[enc_path_len] != '/')
+ *ptr++ = '/';
+ ptr = grub_stpcpy (ptr, dir + enc_path_len);
+ }
+ *ptr = 0;
+ }
+ if (fs_prefix != entries[i].enc_root)
+ free (fs_prefix);
+ break;
+ }
+
+out:
+ free (buf);
+ free (entries);
+ if (fp)
+ fclose (fp);
+ if (dir_fd != -1)
+ close (dir_fd);
+ return ret;
+}
+
+static char *
+get_mdadm_uuid (const char *os_dev)
+{
+ const char *argv[5];
+ int fd;
+ pid_t pid;
+ FILE *mdadm;
+ char *buf = NULL;
+ size_t len = 0;
+ char *name = NULL;
+
+ argv[0] = "mdadm";
+ argv[1] = "--detail";
+ argv[2] = "--export";
+ argv[3] = os_dev;
+ argv[4] = NULL;
+
+ pid = grub_util_exec_pipe (argv, &fd);
+
+ if (!pid)
+ return NULL;
+
+ /* Parent. Read mdadm's output. */
+ mdadm = fdopen (fd, "r");
+ if (! mdadm)
+ {
+ grub_util_warn (_("Unable to open stream from %s: %s"),
+ "mdadm", strerror (errno));
+ goto out;
+ }
+
+ while (getline (&buf, &len, mdadm) > 0)
+ {
+ if (strncmp (buf, "MD_UUID=", sizeof ("MD_UUID=") - 1) == 0)
+ {
+ char *name_start, *ptri, *ptro;
+
+ free (name);
+ name_start = buf + sizeof ("MD_UUID=") - 1;
+ ptro = name = xmalloc (strlen (name_start) + 1);
+ for (ptri = name_start; *ptri && *ptri != '\n' && *ptri != '\r';
+ ptri++)
+ if ((*ptri >= '0' && *ptri <= '9')
+ || (*ptri >= 'a' && *ptri <= 'f')
+ || (*ptri >= 'A' && *ptri <= 'F'))
+ *ptro++ = *ptri;
+ *ptro = 0;
+ }
+ }
+
+out:
+ close (fd);
+ waitpid (pid, NULL, 0);
+ free (buf);
+
+ return name;
+}
+
+static int
+grub_util_is_imsm (const char *os_dev)
+{
+ int retry;
+ int is_imsm = 0;
+ int container_seen = 0;
+ const char *dev = os_dev;
+
+ do
+ {
+ const char *argv[5];
+ int fd;
+ pid_t pid;
+ FILE *mdadm;
+ char *buf = NULL;
+ size_t len = 0;
+
+ retry = 0; /* We'll do one more pass if device is part of container */
+
+ argv[0] = "mdadm";
+ argv[1] = "--detail";
+ argv[2] = "--export";
+ argv[3] = dev;
+ argv[4] = NULL;
+
+ pid = grub_util_exec_pipe (argv, &fd);
+
+ if (!pid)
+ {
+ if (dev != os_dev)
+ free ((void *) dev);
+ return 0;
+ }
+
+ /* Parent. Read mdadm's output. */
+ mdadm = fdopen (fd, "r");
+ if (! mdadm)
+ {
+ grub_util_warn (_("Unable to open stream from %s: %s"),
+ "mdadm", strerror (errno));
+ close (fd);
+ waitpid (pid, NULL, 0);
+ if (dev != os_dev)
+ free ((void *) dev);
+ return 0;
+ }
+
+ while (getline (&buf, &len, mdadm) > 0)
+ {
+ if (strncmp (buf, "MD_CONTAINER=", sizeof ("MD_CONTAINER=") - 1) == 0
+ && !container_seen)
+ {
+ char *newdev, *ptr;
+ newdev = xstrdup (buf + sizeof ("MD_CONTAINER=") - 1);
+ ptr = newdev + strlen (newdev) - 1;
+ for (; ptr >= newdev && (*ptr == '\n' || *ptr == '\r'); ptr--);
+ ptr[1] = 0;
+ grub_util_info ("Container of %s is %s", dev, newdev);
+ dev = newdev;
+ container_seen = retry = 1;
+ break;
+ }
+ if (strncmp (buf, "MD_METADATA=imsm",
+ sizeof ("MD_METADATA=imsm") - 1) == 0)
+ {
+ is_imsm = 1;
+ grub_util_info ("%s is imsm", dev);
+ break;
+ }
+ }
+
+ free (buf);
+ close (fd);
+ waitpid (pid, NULL, 0);
+ }
+ while (retry);
+
+ if (dev != os_dev)
+ free ((void *) dev);
+ return is_imsm;
+}
+
+char *
+grub_util_part_to_disk (const char *os_dev, struct stat *st,
+ int *is_part)
+{
+ char *path;
+
+ if (! S_ISBLK (st->st_mode))
+ {
+ *is_part = 0;
+ return xstrdup (os_dev);
+ }
+
+ path = xmalloc (PATH_MAX);
+
+ if (! realpath (os_dev, path))
+ return NULL;
+
+ if (strncmp ("/dev/", path, 5) == 0)
+ {
+ char *p = path + 5;
+
+ /* If this is an IDE disk. */
+ if (strncmp ("ide/", p, 4) == 0)
+ {
+ p = strstr (p, "part");
+ if (p)
+ {
+ *is_part = 1;
+ strcpy (p, "disc");
+ }
+
+ return path;
+ }
+
+ /* If this is a SCSI disk. */
+ if (strncmp ("scsi/", p, 5) == 0)
+ {
+ p = strstr (p, "part");
+ if (p)
+ {
+ *is_part = 1;
+ strcpy (p, "disc");
+ }
+
+ return path;
+ }
+
+ /* If this is a DAC960 disk. */
+ if (strncmp ("rd/c", p, 4) == 0)
+ {
+ /* /dev/rd/c[0-9]+d[0-9]+(p[0-9]+)? */
+ p = strchr (p, 'p');
+ if (p)
+ {
+ *is_part = 1;
+ *p = '\0';
+ }
+
+ return path;
+ }
+
+ /* If this is a Mylex AcceleRAID Array. */
+ if (strncmp ("rs/c", p, 4) == 0)
+ {
+ /* /dev/rd/c[0-9]+d[0-9]+(p[0-9]+)? */
+ p = strchr (p, 'p');
+ if (p)
+ {
+ *is_part = 1;
+ *p = '\0';
+ }
+
+ return path;
+ }
+ /* If this is a CCISS disk. */
+ if (strncmp ("cciss/c", p, sizeof ("cciss/c") - 1) == 0)
+ {
+ /* /dev/cciss/c[0-9]+d[0-9]+(p[0-9]+)? */
+ p = strchr (p, 'p');
+ if (p)
+ {
+ *is_part = 1;
+ *p = '\0';
+ }
+
+ return path;
+ }
+
+ /* If this is an AOE disk. */
+ if (strncmp ("etherd/e", p, sizeof ("etherd/e") - 1) == 0)
+ {
+ /* /dev/etherd/e[0-9]+\.[0-9]+(p[0-9]+)? */
+ p = strchr (p, 'p');
+ if (p)
+ {
+ *is_part = 1;
+ *p = '\0';
+ }
+
+ return path;
+ }
+
+ /* If this is a Compaq Intelligent Drive Array. */
+ if (strncmp ("ida/c", p, sizeof ("ida/c") - 1) == 0)
+ {
+ /* /dev/ida/c[0-9]+d[0-9]+(p[0-9]+)? */
+ p = strchr (p, 'p');
+ if (p)
+ {
+ *is_part = 1;
+ *p = '\0';
+ }
+
+ return path;
+ }
+
+ /* If this is an I2O disk. */
+ if (strncmp ("i2o/hd", p, sizeof ("i2o/hd") - 1) == 0)
+ {
+ /* /dev/i2o/hd[a-z]([0-9]+)? */
+ if (p[sizeof ("i2o/hda") - 1])
+ *is_part = 1;
+ p[sizeof ("i2o/hda") - 1] = '\0';
+ return path;
+ }
+
+ /* If this is a MultiMediaCard (MMC). */
+ if (strncmp ("mmcblk", p, sizeof ("mmcblk") - 1) == 0)
+ {
+ /* /dev/mmcblk[0-9]+(p[0-9]+)? */
+ p = strchr (p, 'p');
+ if (p)
+ {
+ *is_part = 1;
+ *p = '\0';
+ }
+
+ return path;
+ }
+
+ if (strncmp ("md", p, 2) == 0
+ && p[2] >= '0' && p[2] <= '9')
+ {
+ char *ptr = p + 2;
+ while (*ptr >= '0' && *ptr <= '9')
+ ptr++;
+ if (*ptr)
+ *is_part = 1;
+ *ptr = 0;
+ return path;
+ }
+
+ if (strncmp ("nbd", p, 3) == 0
+ && p[3] >= '0' && p[3] <= '9')
+ {
+ char *ptr = p + 3;
+ while (*ptr >= '0' && *ptr <= '9')
+ ptr++;
+ if (*ptr)
+ *is_part = 1;
+ *ptr = 0;
+ return path;
+ }
+
+ /* If this is an IDE, SCSI or Virtio disk. */
+ if (strncmp ("vdisk", p, 5) == 0
+ && p[5] >= 'a' && p[5] <= 'z')
+ {
+ /* /dev/vdisk[a-z][0-9]* */
+ if (p[6])
+ *is_part = 1;
+ p[6] = '\0';
+ return path;
+ }
+ if ((strncmp ("hd", p, 2) == 0
+ || strncmp ("vd", p, 2) == 0
+ || strncmp ("sd", p, 2) == 0)
+ && p[2] >= 'a' && p[2] <= 'z')
+ {
+ char *pp = p + 2;
+ while (*pp >= 'a' && *pp <= 'z')
+ pp++;
+ if (*pp)
+ *is_part = 1;
+ /* /dev/[hsv]d[a-z]+[0-9]* */
+ *pp = '\0';
+ return path;
+ }
+
+ /* If this is a Xen virtual block device. */
+ if ((strncmp ("xvd", p, 3) == 0) && p[3] >= 'a' && p[3] <= 'z')
+ {
+ char *pp = p + 3;
+ while (*pp >= 'a' && *pp <= 'z')
+ pp++;
+ if (*pp)
+ *is_part = 1;
+ /* /dev/xvd[a-z]+[0-9]* */
+ *pp = '\0';
+ return path;
+ }
+
+ /* If this is an rssd device. */
+ if ((strncmp ("rssd", p, 4) == 0) && p[4] >= 'a' && p[4] <= 'z')
+ {
+ char *pp = p + 4;
+ while (*pp >= 'a' && *pp <= 'z')
+ pp++;
+ if (*pp)
+ *is_part = 1;
+ /* /dev/rssd[a-z]+[0-9]* */
+ *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;
+}
+
+static char *
+grub_util_get_raid_grub_dev (const char *os_dev)
+{
+ char *grub_dev = NULL;
+ if (os_dev[7] == '_' && os_dev[8] == 'd')
+ {
+ /* This a partitionable RAID device of the form /dev/md_dNNpMM. */
+
+ char *p, *q;
+
+ p = strdup (os_dev + sizeof ("/dev/md_d") - 1);
+
+ q = strchr (p, 'p');
+ if (q)
+ *q = ',';
+
+ grub_dev = xasprintf ("md%s", p);
+ free (p);
+ }
+ else if (os_dev[7] == '/' && os_dev[8] == 'd')
+ {
+ /* This a partitionable RAID device of the form /dev/md/dNNpMM. */
+
+ char *p, *q;
+
+ p = strdup (os_dev + sizeof ("/dev/md/d") - 1);
+
+ q = strchr (p, 'p');
+ if (q)
+ *q = ',';
+
+ grub_dev = xasprintf ("md%s", p);
+ free (p);
+ }
+ else if (os_dev[7] >= '0' && os_dev[7] <= '9')
+ {
+ char *p , *q;
+
+ p = strdup (os_dev + sizeof ("/dev/md") - 1);
+
+ q = strchr (p, 'p');
+ if (q)
+ *q = ',';
+
+ grub_dev = xasprintf ("md%s", p);
+ free (p);
+ }
+ else if (os_dev[7] == '/' && os_dev[8] >= '0' && os_dev[8] <= '9')
+ {
+ char *p , *q;
+
+ p = strdup (os_dev + sizeof ("/dev/md/") - 1);
+
+ q = strchr (p, 'p');
+ if (q)
+ *q = ',';
+
+ grub_dev = xasprintf ("md%s", p);
+ free (p);
+ }
+ else if (os_dev[7] == '/')
+ {
+ /* mdraid 1.x with a free name. */
+ char *p , *q;
+
+ p = strdup (os_dev + sizeof ("/dev/md/") - 1);
+
+ q = strchr (p, 'p');
+ if (q)
+ *q = ',';
+
+ grub_dev = xasprintf ("md/%s", p);
+ free (p);
+ }
+ else
+ grub_util_error (_("unknown kind of RAID device `%s'"), os_dev);
+
+ {
+ char *mdadm_name = get_mdadm_uuid (os_dev);
+
+ if (mdadm_name)
+ {
+ const char *q;
+
+ for (q = os_dev + strlen (os_dev) - 1; q >= os_dev
+ && grub_isdigit (*q); q--);
+
+ if (q >= os_dev && *q == 'p')
+ {
+ free (grub_dev);
+ grub_dev = xasprintf ("mduuid/%s,%s", mdadm_name, q + 1);
+ goto done;
+ }
+ free (grub_dev);
+ grub_dev = xasprintf ("mduuid/%s", mdadm_name);
+
+ done:
+ free (mdadm_name);
+ }
+ }
+ return grub_dev;
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dev_abstraction_os (const char *os_dev)
+{
+#ifndef HAVE_DEVICE_MAPPER
+ if ((strncmp ("/dev/mapper/", os_dev, 12) == 0))
+ return GRUB_DEV_ABSTRACTION_LVM;
+#endif
+
+ /* Check for RAID. */
+ if (!strncmp (os_dev, "/dev/md", 7) && ! grub_util_device_is_mapped (os_dev)
+ && !grub_util_is_imsm (os_dev))
+ return GRUB_DEV_ABSTRACTION_RAID;
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+int
+grub_util_pull_device_os (const char *os_dev,
+ enum grub_dev_abstraction_types ab)
+{
+ switch (ab)
+ {
+ case GRUB_DEV_ABSTRACTION_RAID:
+ {
+ char **devicelist = grub_util_raid_getmembers (os_dev, 0);
+ int i;
+ for (i = 0; devicelist[i];i++)
+ {
+ grub_util_pull_device (devicelist[i]);
+ free (devicelist[i]);
+ }
+ free (devicelist);
+ }
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+char *
+grub_util_get_grub_dev_os (const char *os_dev)
+{
+ char *grub_dev = NULL;
+
+ switch (grub_util_get_dev_abstraction (os_dev))
+ {
+ /* Fallback for non-devmapper build. In devmapper-builds LVM is handled
+ in grub_util_get_devmapper_grub_dev and this point isn't reached.
+ */
+ case GRUB_DEV_ABSTRACTION_LVM:
+ {
+ unsigned short len;
+ grub_size_t offset = sizeof (LVM_DEV_MAPPER_STRING) - 1;
+
+ len = strlen (os_dev) - offset + 1;
+ grub_dev = xmalloc (len + sizeof ("lvm/"));
+
+ grub_memcpy (grub_dev, "lvm/", sizeof ("lvm/") - 1);
+ grub_memcpy (grub_dev + sizeof ("lvm/") - 1, os_dev + offset, len);
+ }
+ break;
+
+ case GRUB_DEV_ABSTRACTION_RAID:
+ grub_dev = grub_util_get_raid_grub_dev (os_dev);
+ break;
+
+ default: /* GRUB_DEV_ABSTRACTION_NONE */
+ break;
+ }
+
+ return grub_dev;
+}
+
+char *
+grub_make_system_path_relative_to_its_root_os (const char *path)
+{
+ char *bind = NULL;
+ grub_size_t len;
+ grub_free (grub_find_root_devices_from_mountinfo (path, &bind));
+ if (bind && bind[0])
+ {
+ len = strlen (bind);
+ while (len > 0 && bind[len - 1] == '/')
+ {
+ bind[len - 1] = '\0';
+ len--;
+ }
+ return bind;
+ }
+ grub_free (bind);
+ return NULL;
+}
diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c
new file mode 100644
index 0000000..da62f92
--- /dev/null
+++ b/grub-core/osdep/linux/hostdisk.c
@@ -0,0 +1,465 @@
+/* hostdisk.c - emulate biosdisk */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/emu/exec.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+# include <sys/ioctl.h> /* ioctl */
+# include <sys/mount.h>
+# ifndef BLKFLSBUF
+# define BLKFLSBUF _IO (0x12,97) /* flush buffer cache */
+# endif /* ! BLKFLSBUF */
+# include <sys/ioctl.h> /* ioctl */
+# ifndef HDIO_GETGEO
+# define HDIO_GETGEO 0x0301 /* get device geometry */
+/* If HDIO_GETGEO is not defined, it is unlikely that hd_geometry is
+ defined. */
+struct hd_geometry
+{
+ unsigned char heads;
+ unsigned char sectors;
+ unsigned short cylinders;
+ unsigned long start;
+};
+# endif /* ! HDIO_GETGEO */
+# ifndef BLKGETSIZE64
+# define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size */
+# endif /* ! BLKGETSIZE64 */
+
+
+grub_int64_t
+grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_secsize)
+{
+ unsigned long long nr;
+ unsigned sector_size, log_sector_size;
+
+ if (ioctl (fd, BLKGETSIZE64, &nr))
+ return -1;
+
+ if (ioctl (fd, BLKSSZGET, &sector_size))
+ return -1;
+
+ if (sector_size & (sector_size - 1) || !sector_size)
+ return -1;
+ for (log_sector_size = 0;
+ (1 << log_sector_size) < sector_size;
+ log_sector_size++);
+
+ if (log_secsize)
+ *log_secsize = log_sector_size;
+
+ if (nr & ((1 << log_sector_size) - 1))
+ grub_util_error ("%s", _("unaligned device size"));
+
+ return nr;
+}
+
+static char *
+sysfs_partition_path (const char *dev, const char *entry)
+{
+ const char *argv[7];
+ int fd;
+ pid_t pid;
+ FILE *udevadm;
+ char *buf = NULL;
+ size_t len = 0;
+ char *path = NULL;
+
+ argv[0] = "udevadm";
+ argv[1] = "info";
+ argv[2] = "--query";
+ argv[3] = "path";
+ argv[4] = "--name";
+ argv[5] = dev;
+ argv[6] = NULL;
+
+ pid = grub_util_exec_pipe (argv, &fd);
+
+ if (!pid)
+ return NULL;
+
+ /* Parent. Read udevadm's output. */
+ udevadm = fdopen (fd, "r");
+ if (!udevadm)
+ {
+ grub_util_warn (_("Unable to open stream from %s: %s"),
+ "udevadm", strerror (errno));
+ close (fd);
+ goto out;
+ }
+
+ if (getline (&buf, &len, udevadm) > 0)
+ {
+ char *newline;
+
+ newline = strchr (buf, '\n');
+ if (newline)
+ *newline = '\0';
+ path = xasprintf ("/sys%s/%s", buf, entry);
+ }
+
+out:
+ if (udevadm)
+ fclose (udevadm);
+ waitpid (pid, NULL, 0);
+ free (buf);
+
+ return path;
+}
+
+static int
+sysfs_partition_start (const char *dev, grub_disk_addr_t *start)
+{
+ char *path;
+ FILE *fp;
+ unsigned long long val;
+ int ret = 0;
+
+ path = sysfs_partition_path (dev, "start");
+ if (!path)
+ return 0;
+
+ fp = grub_util_fopen (path, "r");
+ if (!fp)
+ goto out;
+
+ if (fscanf (fp, "%llu", &val) == 1)
+ {
+ *start = (grub_disk_addr_t) val;
+ ret = 1;
+ }
+
+out:
+ free (path);
+ if (fp)
+ fclose (fp);
+
+ return ret;
+}
+
+grub_disk_addr_t
+grub_util_find_partition_start_os (const char *dev)
+{
+ grub_disk_addr_t start = 0;
+ grub_util_fd_t fd;
+ struct hd_geometry hdg;
+
+ if (sysfs_partition_start (dev, &start))
+ return start;
+
+ fd = open (dev, O_RDONLY);
+ if (fd == -1)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot open `%s': %s"),
+ dev, strerror (errno));
+ return 0;
+ }
+
+ if (ioctl (fd, HDIO_GETGEO, &hdg))
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE,
+ "cannot get disk geometry of `%s'", dev);
+ close (fd);
+ return 0;
+ }
+
+ close (fd);
+
+ return hdg.start;
+}
+
+/* Cache of partition start sectors for each disk. */
+struct linux_partition_cache
+{
+ struct linux_partition_cache *next;
+ struct linux_partition_cache **prev;
+ char *dev;
+ unsigned long start;
+ int partno;
+};
+
+struct linux_partition_cache *linux_partition_cache_list;
+
+/* Check if we have devfs support. */
+static int
+have_devfs (void)
+{
+ static int dev_devfsd_exists = -1;
+
+ if (dev_devfsd_exists < 0)
+ {
+ struct stat st;
+
+ dev_devfsd_exists = stat ("/dev/.devfsd", &st) == 0;
+ }
+
+ return dev_devfsd_exists;
+}
+
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
+static int
+grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector)
+{
+ size_t len = strlen (dev);
+ const char *format;
+ char *p;
+ int i;
+ char real_dev[PATH_MAX];
+ struct linux_partition_cache *cache;
+ int missing = 0;
+
+ strcpy(real_dev, dev);
+
+ if (have_devfs () && strcmp (real_dev + len - 5, "/disc") == 0)
+ {
+ p = real_dev + len - 4;
+ format = "part%d";
+ }
+ else if (strncmp (real_dev, "/dev/disk/by-id/",
+ sizeof ("/dev/disk/by-id/") - 1) == 0)
+ {
+ p = real_dev + len;
+ format = "-part%d";
+ }
+ else if (real_dev[len - 1] >= '0' && real_dev[len - 1] <= '9')
+ {
+ p = real_dev + len;
+ format = "p%d";
+ }
+ else
+ {
+ p = real_dev + len;
+ format = "%d";
+ }
+
+ for (cache = linux_partition_cache_list; cache; cache = cache->next)
+ {
+ if (strcmp (cache->dev, dev) == 0 && cache->start == sector)
+ {
+ sprintf (p, format, cache->partno);
+ strcpy (dev, real_dev);
+ return 1;
+ }
+ }
+
+ for (i = 1; i < 10000; i++)
+ {
+ grub_util_fd_t fd;
+ grub_disk_addr_t start;
+ struct stat st;
+
+ sprintf (p, format, i);
+
+ fd = open (real_dev, O_RDONLY);
+ if (fd == -1)
+ {
+ if (missing++ < 10)
+ continue;
+ else
+ return 0;
+ }
+ missing = 0;
+
+ 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;
+
+ new_cache_item = xmalloc (sizeof *new_cache_item);
+ new_cache_item->dev = xstrdup (dev);
+ new_cache_item->start = start;
+ new_cache_item->partno = i;
+ grub_list_push (GRUB_AS_LIST_P (&linux_partition_cache_list),
+ GRUB_AS_LIST (new_cache_item));
+
+ strcpy (dev, real_dev);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
+void
+grub_hostdisk_flush_initial_buffer (const char *os_dev)
+{
+ grub_util_fd_t fd;
+ struct stat st;
+
+ fd = open (os_dev, O_RDONLY);
+ if (fd >= 0 && fstat (fd, &st) >= 0 && S_ISBLK (st.st_mode))
+ ioctl (fd, BLKFLSBUF, 0);
+ if (fd >= 0)
+ close (fd);
+}
+
+int
+grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags,
+ grub_disk_addr_t *max)
+{
+ grub_util_fd_t fd;
+ struct grub_util_hostdisk_data *data = disk->data;
+
+ *max = ~0ULL;
+
+#ifdef O_LARGEFILE
+ flags |= O_LARGEFILE;
+#endif
+#ifdef O_SYNC
+ flags |= O_SYNC;
+#endif
+#ifdef O_FSYNC
+ flags |= O_FSYNC;
+#endif
+#ifdef O_BINARY
+ flags |= O_BINARY;
+#endif
+#ifdef O_CLOEXEC
+ flags |= O_CLOEXEC;
+#endif
+
+ /* Linux has a bug that the disk cache for a whole disk is not consistent
+ with the one for a partition of the disk. */
+ {
+ int is_partition = 0;
+ char dev[PATH_MAX];
+ grub_disk_addr_t part_start = 0;
+
+ part_start = grub_partition_get_start (disk->partition)
+ >> (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
+
+ strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1);
+ dev[sizeof(dev) - 1] = '\0';
+ if (disk->partition
+ && strncmp (dev, "/dev/", 5) == 0)
+ {
+ if (sector >= part_start)
+ is_partition = grub_hostdisk_linux_find_partition (dev, part_start);
+ else
+ *max = part_start - sector;
+ }
+
+ reopen:
+
+ if (data->dev && strcmp (data->dev, dev) == 0 &&
+ data->access_mode == (flags & O_ACCMODE))
+ {
+ grub_dprintf ("hostdisk", "reusing open device `%s'\n", dev);
+ fd = data->fd;
+ }
+ else
+ {
+ free (data->dev);
+ data->dev = 0;
+ if (data->fd != -1)
+ {
+ if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY)
+ {
+ fsync (data->fd);
+ if (data->is_disk)
+ ioctl (data->fd, BLKFLSBUF, 0);
+ }
+
+ close (data->fd);
+ data->fd = -1;
+ }
+
+ /* Open the partition. */
+ grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev);
+ fd = open (dev, flags);
+ if (fd < 0)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot open `%s': %s"),
+ dev, strerror (errno));
+ return -1;
+ }
+
+ data->dev = xstrdup (dev);
+ data->access_mode = (flags & O_ACCMODE);
+ data->fd = fd;
+
+ if (data->is_disk)
+ ioctl (data->fd, BLKFLSBUF, 0);
+ }
+
+ if (is_partition)
+ {
+ *max = grub_util_get_fd_size (fd, dev, 0);
+ *max >>= disk->log_sector_size;
+ if (sector - part_start >= *max)
+ {
+ *max = disk->partition->len - (sector - part_start);
+ if (*max == 0)
+ *max = ~0ULL;
+ is_partition = 0;
+ strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1);
+ dev[sizeof(dev) - 1] = '\0';
+ goto reopen;
+ }
+ sector -= part_start;
+ *max -= sector;
+ }
+ }
+
+ if (grub_util_fd_seek (fd, sector << disk->log_sector_size))
+ {
+ close (fd);
+ grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot seek `%s': %s"),
+ grub_util_biosdisk_get_osdev (disk), strerror (errno));
+ return -1;
+ }
+
+ return fd;
+}
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
new file mode 100644
index 0000000..a6153d3
--- /dev/null
+++ b/grub-core/osdep/linux/ofpath.c
@@ -0,0 +1,769 @@
+/* ofpath.c - calculate OpenFirmware path names given an OS device */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2011,2012, 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/>.
+ */
+
+#undef OFPATH_STANDALONE
+
+#ifndef OFPATH_STANDALONE
+#include <grub/types.h>
+#include <grub/util/misc.h>
+#include <grub/util/ofpath.h>
+#include <grub/i18n.h>
+#endif
+
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <ctype.h>
+
+#ifdef __sparc__
+typedef enum
+ {
+ GRUB_OFPATH_SPARC_WWN_ADDR = 1,
+ GRUB_OFPATH_SPARC_TGT_LUN,
+ } ofpath_sparc_addressing;
+
+struct ofpath_sparc_hba
+{
+ grub_uint32_t device_id;
+ ofpath_sparc_addressing addressing;
+};
+
+static struct ofpath_sparc_hba sparc_lsi_hba[] = {
+ /* Rhea, Jasper 320, LSI53C1020/1030. */
+ {0x30, GRUB_OFPATH_SPARC_TGT_LUN},
+ /* SAS-1068E. */
+ {0x50, GRUB_OFPATH_SPARC_TGT_LUN},
+ /* SAS-1064E. */
+ {0x56, GRUB_OFPATH_SPARC_TGT_LUN},
+ /* Pandora SAS-1068E. */
+ {0x58, GRUB_OFPATH_SPARC_TGT_LUN},
+ /* Aspen, Invader, LSI SAS-3108. */
+ {0x5d, GRUB_OFPATH_SPARC_TGT_LUN},
+ /* Niwot, SAS 2108. */
+ {0x79, GRUB_OFPATH_SPARC_TGT_LUN},
+ /* Erie, Falcon, LSI SAS 2008. */
+ {0x72, GRUB_OFPATH_SPARC_WWN_ADDR},
+ /* LSI WarpDrive 6203. */
+ {0x7e, GRUB_OFPATH_SPARC_WWN_ADDR},
+ /* LSI SAS 2308. */
+ {0x87, GRUB_OFPATH_SPARC_WWN_ADDR},
+ /* LSI SAS 3008. */
+ {0x97, GRUB_OFPATH_SPARC_WWN_ADDR},
+ {0, 0}
+};
+
+static const int LSI_VENDOR_ID = 0x1000;
+#endif
+
+#ifdef OFPATH_STANDALONE
+#define xmalloc malloc
+void
+grub_util_error (const char *fmt, ...)
+{
+ va_list ap;
+
+ fprintf (stderr, "ofpath: error: ");
+ va_start (ap, fmt);
+ vfprintf (stderr, fmt, ap);
+ va_end (ap);
+ fputc ('\n', stderr);
+ exit (1);
+}
+
+void
+grub_util_info (const char *fmt, ...)
+{
+ va_list ap;
+
+ fprintf (stderr, "ofpath: info: ");
+ va_start (ap, fmt);
+ vfprintf (stderr, fmt, ap);
+ va_end (ap);
+ fputc ('\n', stderr);
+}
+
+#define grub_util_warn grub_util_info
+#define _(x) x
+#define xstrdup strdup
+#endif
+
+static void
+kill_trailing_dir(char *path)
+{
+ char *end = path + strlen(path) - 1;
+
+ while (end >= path)
+ {
+ if (*end != '/')
+ {
+ end--;
+ continue;
+ }
+ *end = '\0';
+ break;
+ }
+}
+
+static void
+trim_newline (char *path)
+{
+ char *end = path + strlen(path) - 1;
+
+ while (*end == '\n')
+ *end-- = '\0';
+}
+
+#define MAX_DISK_CAT 64
+
+static char *
+find_obppath (const char *sysfs_path_orig)
+{
+ char *sysfs_path, *path;
+ size_t path_size = strlen (sysfs_path_orig) + sizeof ("/obppath");
+
+ sysfs_path = xstrdup (sysfs_path_orig);
+ path = xmalloc (path_size);
+
+ while (1)
+ {
+ int fd;
+ char *of_path;
+ struct stat st;
+ size_t size;
+
+ snprintf(path, path_size, "%s/obppath", sysfs_path);
+#if 0
+ printf("Trying %s\n", path);
+#endif
+
+ fd = open(path, O_RDONLY);
+
+#ifndef __sparc__
+ 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);
+ }
+#endif
+
+ if (fd < 0 || fstat (fd, &st) < 0)
+ {
+ if (fd >= 0)
+ close (fd);
+ kill_trailing_dir(sysfs_path);
+ if (!strcmp(sysfs_path, "/sys"))
+ {
+ grub_util_info (_("`obppath' not found in parent dirs of `%s',"
+ " no IEEE1275 name discovery"),
+ sysfs_path_orig);
+ free (path);
+ free (sysfs_path);
+ return NULL;
+ }
+ continue;
+ }
+ size = st.st_size;
+ of_path = xmalloc (size + MAX_DISK_CAT + 1);
+ memset(of_path, 0, size + MAX_DISK_CAT + 1);
+ if (read(fd, of_path, size) < 0)
+ {
+ grub_util_info (_("cannot read `%s': %s"), path, strerror (errno));
+ close(fd);
+ free (path);
+ free (of_path);
+ free (sysfs_path);
+ return NULL;
+ }
+ close(fd);
+
+ trim_newline(of_path);
+ free (path);
+ free (sysfs_path);
+ return of_path;
+ }
+}
+
+static char *
+xrealpath (const char *in)
+{
+ char *out;
+#ifdef PATH_MAX
+ out = xmalloc (PATH_MAX);
+ out = realpath (in, out);
+#else
+ out = realpath (in, NULL);
+#endif
+ if (!out)
+ grub_util_error (_("failed to get canonical path of `%s'"), in);
+ return out;
+}
+
+static char *
+block_device_get_sysfs_path_and_link(const char *devicenode)
+{
+ char *rpath;
+ char *rpath2;
+ char *ret;
+ size_t tmp_size = strlen (devicenode) + sizeof ("/sys/block/");
+ char *tmp = xmalloc (tmp_size);
+
+ memcpy (tmp, "/sys/block/", sizeof ("/sys/block/"));
+ strcat (tmp, devicenode);
+
+ rpath = xrealpath (tmp);
+ rpath2 = xmalloc (strlen (rpath) + sizeof ("/device"));
+ strcpy (rpath2, rpath);
+ strcat (rpath2, "/device");
+
+ ret = xrealpath (rpath2);
+
+ free (tmp);
+ free (rpath);
+ free (rpath2);
+ return ret;
+}
+
+static inline int
+my_isdigit (int c)
+{
+ return (c >= '0' && c <= '9');
+}
+
+static const char *
+trailing_digits (const char *p)
+{
+ const char *end;
+
+ end = p + strlen(p) - 1;
+ while (end >= p)
+ {
+ if (! my_isdigit(*end))
+ break;
+ end--;
+ }
+
+ return end + 1;
+}
+
+static char *
+__of_path_common(char *sysfs_path,
+ const char *device, int devno)
+{
+ const char *digit_string;
+ char disk[MAX_DISK_CAT];
+ char *of_path = find_obppath(sysfs_path);
+
+ if (!of_path)
+ return NULL;
+
+ digit_string = trailing_digits (device);
+ if (*digit_string == '\0')
+ {
+ snprintf(disk, sizeof (disk), "/disk@%d", devno);
+ }
+ else
+ {
+ int part;
+
+ sscanf(digit_string, "%d", &part);
+ snprintf(disk, sizeof (disk), "/disk@%d:%c", devno, 'a' + (part - 1));
+ }
+ strcat(of_path, disk);
+ return of_path;
+}
+
+static char *
+get_basename(char *p)
+{
+ char *ret = p;
+
+ while (*p)
+ {
+ if (*p == '/')
+ ret = p + 1;
+ p++;
+ }
+
+ return ret;
+}
+
+static char *
+of_path_of_vdisk(const char *sys_devname __attribute__((unused)),
+ const char *device,
+ const char *devnode __attribute__((unused)),
+ const char *devicenode)
+{
+ char *sysfs_path, *p;
+ int devno, junk;
+ char *ret;
+
+ sysfs_path = block_device_get_sysfs_path_and_link(devicenode);
+ p = get_basename (sysfs_path);
+ sscanf(p, "vdc-port-%d-%d", &devno, &junk);
+ ret = __of_path_common (sysfs_path, device, devno);
+
+ free (sysfs_path);
+ return ret;
+}
+
+static char *
+of_path_of_ide(const char *sys_devname __attribute__((unused)), const char *device,
+ const char *devnode __attribute__((unused)),
+ const char *devicenode)
+{
+ char *sysfs_path, *p;
+ int chan, devno;
+ char *ret;
+
+ sysfs_path = block_device_get_sysfs_path_and_link(devicenode);
+ p = get_basename (sysfs_path);
+ sscanf(p, "%d.%d", &chan, &devno);
+
+ ret = __of_path_common(sysfs_path, device, 2 * chan + devno);
+
+ free (sysfs_path);
+ return ret;
+}
+
+#ifdef __sparc__
+static char *
+of_path_of_nvme(const char *sys_devname __attribute__((unused)),
+ const char *device,
+ const char *devnode __attribute__((unused)),
+ const char *devicenode)
+{
+ char *sysfs_path, *of_path, disk[MAX_DISK_CAT];
+ const char *digit_string, *part_end;
+
+ digit_string = trailing_digits (device);
+ part_end = devicenode + strlen (devicenode) - 1;
+
+ if ((*digit_string != '\0') && (*part_end == 'p'))
+ {
+ /* We have a partition number, strip it off. */
+ int part;
+ char *nvmedev, *end;
+
+ nvmedev = strdup (devicenode);
+
+ if (!nvmedev)
+ return NULL;
+
+ end = nvmedev + strlen (nvmedev) - 1;
+ /* Remove the p. */
+ *end = '\0';
+ sscanf (digit_string, "%d", &part);
+ snprintf (disk, sizeof (disk), "/disk@1:%c", 'a' + (part - 1));
+ sysfs_path = block_device_get_sysfs_path_and_link (nvmedev);
+ free (nvmedev);
+ }
+ else
+ {
+ /* We do not have the parition. */
+ snprintf (disk, sizeof (disk), "/disk@1");
+ sysfs_path = block_device_get_sysfs_path_and_link (device);
+ }
+
+ of_path = find_obppath (sysfs_path);
+
+ if (of_path)
+ strcat (of_path, disk);
+
+ free (sysfs_path);
+ return of_path;
+}
+#endif
+
+static int
+vendor_is_ATA(const char *path)
+{
+ int fd, err;
+ char *bufname;
+ char bufcont[3];
+ size_t path_size;
+
+ path_size = strlen (path) + sizeof ("/vendor");
+
+ bufname = xmalloc (path_size);
+
+ snprintf (bufname, path_size, "%s/vendor", path);
+ fd = open (bufname, O_RDONLY);
+ if (fd < 0)
+ grub_util_error (_("cannot open `%s': %s"), bufname, strerror (errno));
+
+ memset(bufcont, 0, sizeof (bufcont));
+ err = read(fd, bufcont, sizeof (bufcont));
+ if (err < 0)
+ grub_util_error (_("cannot open `%s': %s"), bufname, strerror (errno));
+
+ close(fd);
+ free (bufname);
+
+ return (memcmp(bufcont, "ATA", 3) == 0);
+}
+
+#ifdef __sparc__
+static void
+check_hba_identifiers (const char *sysfs_path, int *vendor, int *device_id)
+{
+ char *ed = strstr (sysfs_path, "host");
+ size_t path_size;
+ char *p, *path;
+ char buf[8];
+ int fd;
+
+ if (!ed)
+ return;
+
+ p = xstrdup (sysfs_path);
+ ed = strstr (p, "host");
+
+ *ed = '\0';
+
+ path_size = (strlen (p) + sizeof ("vendor"));
+ path = xmalloc (path_size);
+
+ if (!path)
+ goto out;
+
+ snprintf (path, path_size, "%svendor", p);
+ fd = open (path, O_RDONLY);
+
+ if (fd < 0)
+ goto out;
+
+ memset (buf, 0, sizeof (buf));
+
+ if (read (fd, buf, sizeof (buf) - 1) < 0)
+ goto out;
+
+ close (fd);
+ sscanf (buf, "%x", vendor);
+
+ snprintf (path, path_size, "%sdevice", p);
+ fd = open (path, O_RDONLY);
+
+ if (fd < 0)
+ goto out;
+
+ memset (buf, 0, sizeof (buf));
+
+ if (read (fd, buf, sizeof (buf) - 1) < 0)
+ goto out;
+
+ close (fd);
+ sscanf (buf, "%x", device_id);
+
+ out:
+ free (path);
+ free (p);
+}
+#endif
+
+static void
+check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address)
+{
+ char *ed = strstr (sysfs_path, "end_device");
+ char *p, *q, *path;
+ char phy[21];
+ int fd;
+ size_t path_size;
+
+ if (!ed)
+ return;
+
+ /* SAS devices are identified using disk@$PHY_ID */
+ p = xstrdup (sysfs_path);
+ ed = strstr(p, "end_device");
+ if (!ed)
+ return;
+
+ q = ed;
+ while (*q && *q != '/')
+ q++;
+ *q = '\0';
+
+ path_size = (strlen (p) + strlen (ed)
+ + sizeof ("%s/sas_device/%s/phy_identifier"));
+ path = xmalloc (path_size);
+ snprintf (path, path_size, "%s/sas_device/%s/phy_identifier", p, ed);
+ fd = open (path, O_RDONLY);
+ if (fd < 0)
+ grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
+
+ memset (phy, 0, sizeof (phy));
+ if (read (fd, phy, sizeof (phy) - 1) < 0)
+ grub_util_error (_("cannot read `%s': %s"), path, strerror (errno));
+
+ close (fd);
+
+ sscanf (phy, "%d", tgt);
+
+ snprintf (path, path_size, "%s/sas_device/%s/sas_address", p, ed);
+ fd = open (path, O_RDONLY);
+ if (fd < 0)
+ grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
+
+ memset (phy, 0, sizeof (phy));
+ if (read (fd, phy, sizeof (phy) - 1) < 0)
+ grub_util_error (_("cannot read `%s': %s"), path, strerror (errno));
+ sscanf (phy, "%lx", sas_address);
+
+ free (path);
+ free (p);
+ close (fd);
+}
+
+static char *
+of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *device,
+ const char *devnode __attribute__((unused)),
+ const char *devicenode)
+{
+ const char *p, *digit_string, *disk_name;
+ int host, bus, tgt, lun;
+ unsigned long int sas_address = 0;
+ char *sysfs_path, disk[MAX_DISK_CAT - sizeof ("/fp@0,0")];
+ char *of_path;
+
+ sysfs_path = block_device_get_sysfs_path_and_link(devicenode);
+ p = get_basename (sysfs_path);
+ sscanf(p, "%d:%d:%d:%d", &host, &bus, &tgt, &lun);
+ check_sas (sysfs_path, &tgt, &sas_address);
+
+ if (vendor_is_ATA(sysfs_path))
+ {
+ of_path = __of_path_common(sysfs_path, device, tgt);
+ free (sysfs_path);
+ return of_path;
+ }
+
+ of_path = find_obppath(sysfs_path);
+ if (!of_path)
+ goto out;
+
+ if (strstr (of_path, "qlc"))
+ strcat (of_path, "/fp@0,0");
+
+ if (strstr (of_path, "sbus"))
+ disk_name = "sd";
+ else
+ disk_name = "disk";
+
+ digit_string = trailing_digits (device);
+ if (strncmp (of_path, "/vdevice/", sizeof ("/vdevice/") - 1) == 0)
+ {
+ unsigned long id = 0x8000 | (tgt << 8) | (bus << 5) | lun;
+ if (*digit_string == '\0')
+ {
+ snprintf(disk, sizeof (disk), "/%s@%04lx000000000000", disk_name, id);
+ }
+ else
+ {
+ int part;
+
+ sscanf(digit_string, "%d", &part);
+ snprintf(disk, sizeof (disk),
+ "/%s@%04lx000000000000:%c", disk_name, id, 'a' + (part - 1));
+ }
+ }
+ else
+ {
+#ifdef __sparc__
+ ofpath_sparc_addressing addressing = GRUB_OFPATH_SPARC_TGT_LUN;
+ int vendor = 0, device_id = 0;
+ char *optr = disk;
+
+ check_hba_identifiers (sysfs_path, &vendor, &device_id);
+
+ if (vendor == LSI_VENDOR_ID)
+ {
+ struct ofpath_sparc_hba *lsi_hba;
+
+ /*
+ * Over time different OF addressing schemes have been supported.
+ * There is no generic addressing scheme that works across
+ * every HBA.
+ */
+ for (lsi_hba = sparc_lsi_hba; lsi_hba->device_id; lsi_hba++)
+ if (lsi_hba->device_id == device_id)
+ {
+ addressing = lsi_hba->addressing;
+ break;
+ }
+ }
+
+ if (addressing == GRUB_OFPATH_SPARC_WWN_ADDR)
+ optr += snprintf (disk, sizeof (disk), "/%s@w%lx,%x", disk_name,
+ sas_address, lun);
+ else
+ optr += snprintf (disk, sizeof (disk), "/%s@%x,%x", disk_name, tgt,
+ lun);
+
+ if (*digit_string != '\0')
+ {
+ int part;
+
+ sscanf (digit_string, "%d", &part);
+ snprintf (optr, sizeof (disk) - (optr - disk - 1), ":%c", 'a'
+ + (part - 1));
+ }
+#else
+ if (lun == 0)
+ {
+ int sas_id = 0;
+ sas_id = bus << 16 | tgt << 8 | lun;
+
+ if (*digit_string == '\0')
+ {
+ snprintf(disk, sizeof (disk), "/sas/%s@%x", disk_name, sas_id);
+ }
+ else
+ {
+ int part;
+
+ sscanf(digit_string, "%d", &part);
+ snprintf(disk, sizeof (disk),
+ "/sas/%s@%x:%c", disk_name, sas_id, 'a' + (part - 1));
+ }
+ }
+ else
+ {
+ char *lunstr;
+ int lunpart[4];
+
+ lunstr = xmalloc (20);
+
+ lunpart[0] = (lun >> 8) & 0xff;
+ lunpart[1] = lun & 0xff;
+ lunpart[2] = (lun >> 24) & 0xff;
+ lunpart[3] = (lun >> 16) & 0xff;
+
+ sprintf(lunstr, "%02x%02x%02x%02x00000000", lunpart[0], lunpart[1], lunpart[2], lunpart[3]);
+ long int longlun = atol(lunstr);
+
+ if (*digit_string == '\0')
+ {
+ snprintf(disk, sizeof (disk), "/sas/%s@%lx,%lu", disk_name, sas_address, longlun);
+ }
+ else
+ {
+ int part;
+
+ sscanf(digit_string, "%d", &part);
+ snprintf(disk, sizeof (disk),
+ "/sas/%s@%lx,%lu:%c", disk_name, sas_address, longlun, 'a' + (part - 1));
+ }
+ free (lunstr);
+ }
+#endif
+ }
+ strcat(of_path, disk);
+
+ out:
+ free (sysfs_path);
+ return of_path;
+}
+
+static char *
+strip_trailing_digits (const char *p)
+{
+ char *new, *end;
+
+ new = strdup (p);
+ end = new + strlen(new) - 1;
+ while (end >= new)
+ {
+ if (! my_isdigit(*end))
+ break;
+ *end-- = '\0';
+ }
+
+ return new;
+}
+
+char *
+grub_util_devname_to_ofpath (const char *sys_devname)
+{
+ char *name_buf, *device, *devnode, *devicenode, *ofpath;
+
+ name_buf = xrealpath (sys_devname);
+
+ device = get_basename (name_buf);
+ devnode = strip_trailing_digits (name_buf);
+ devicenode = strip_trailing_digits (device);
+
+ if (device[0] == 'h' && device[1] == 'd')
+ ofpath = of_path_of_ide(name_buf, device, devnode, devicenode);
+ else if (device[0] == 's'
+ && (device[1] == 'd' || device[1] == 'r'))
+ ofpath = of_path_of_scsi(name_buf, device, devnode, devicenode);
+ else if (device[0] == 'v' && device[1] == 'd' && device[2] == 'i'
+ && device[3] == 's' && device[4] == 'k')
+ ofpath = of_path_of_vdisk(name_buf, device, devnode, devicenode);
+ else if (device[0] == 'f' && device[1] == 'd'
+ && device[2] == '0' && device[3] == '\0')
+ /* All the models I've seen have a devalias "floppy".
+ New models have no floppy at all. */
+ ofpath = xstrdup ("floppy");
+#ifdef __sparc__
+ else if (device[0] == 'n' && device[1] == 'v' && device[2] == 'm'
+ && device[3] == 'e')
+ ofpath = of_path_of_nvme (name_buf, device, devnode, devicenode);
+#endif
+ else
+ {
+ grub_util_warn (_("unknown device type %s"), device);
+ ofpath = NULL;
+ }
+
+ free (devnode);
+ free (devicenode);
+ free (name_buf);
+
+ return ofpath;
+}
+
+#ifdef OFPATH_STANDALONE
+int main(int argc, char **argv)
+{
+ char *of_path;
+
+ if (argc != 2)
+ {
+ printf(_("Usage: %s DEVICE\n"), argv[0]);
+ return 1;
+ }
+
+ of_path = grub_util_devname_to_ofpath (argv[1]);
+ if (of_path)
+ printf("%s\n", of_path);
+ free (of_path);
+
+ return 0;
+}
+#endif
diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c
new file mode 100644
index 0000000..e28a79d
--- /dev/null
+++ b/grub-core/osdep/linux/platform.c
@@ -0,0 +1,156 @@
+/*
+ * 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 <config.h>
+
+#include <grub/util/install.h>
+#include <grub/emu/exec.h>
+#include <grub/emu/misc.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <string.h>
+
+#include <sys/utsname.h>
+
+static int
+is_not_empty_directory (const char *dir)
+{
+ DIR *d;
+ struct dirent *de;
+
+ d = opendir (dir);
+ if (!d)
+ return 0;
+ while ((de = readdir (d)))
+ {
+ if (strcmp (de->d_name, ".") == 0
+ || strcmp (de->d_name, "..") == 0)
+ continue;
+ closedir (d);
+ return 1;
+ }
+
+ closedir (d);
+ return 0;
+}
+
+static int
+is_64_kernel (void)
+{
+ struct utsname un;
+
+ if (uname (&un) < 0)
+ return 0;
+
+ 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;
+}
+
+/* Are we running on an EFI-based system? */
+static int
+is_efi_system (void)
+{
+ /*
+ * Linux uses efivarfs (mounted on /sys/firmware/efi/efivars) to access the
+ * EFI variable store. Some legacy systems may still use the deprecated
+ * efivars interface (accessed through /sys/firmware/efi/vars). Where both
+ * are present, libefivar will use the former in preference, so attempting
+ * to load efivars will not interfere with later operations.
+ */
+ grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL },
+ NULL, NULL, "/dev/null");
+
+ grub_util_info ("Looking for /sys/firmware/efi ..");
+ if (is_not_empty_directory ("/sys/firmware/efi"))
+ {
+ grub_util_info ("...found");
+ return 1;
+ }
+ else
+ {
+ grub_util_info ("... not found");
+ return 0;
+ }
+}
+
+const char *
+grub_install_get_default_arm_platform (void)
+{
+ if (is_efi_system())
+ return "arm-efi";
+ else
+ return "arm-uboot";
+}
+
+const char *
+grub_install_get_default_x86_platform (void)
+{
+ if (is_efi_system())
+ {
+ if (read_platform_size() == 64)
+ return "x86_64-efi";
+ else
+ return "i386-efi";
+ }
+
+ grub_util_info ("Looking for /proc/device-tree ..");
+ if (is_not_empty_directory ("/proc/device-tree"))
+ {
+ grub_util_info ("...found");
+ return "i386-ieee1275";
+ }
+
+ grub_util_info ("... not found");
+ return "i386-pc";
+}
diff --git a/grub-core/osdep/ofpath.c b/grub-core/osdep/ofpath.c
new file mode 100644
index 0000000..1389b1d
--- /dev/null
+++ b/grub-core/osdep/ofpath.c
@@ -0,0 +1,5 @@
+#if defined (__linux__)
+#include "linux/ofpath.c"
+#else
+#include "basic/ofpath.c"
+#endif
diff --git a/grub-core/osdep/password.c b/grub-core/osdep/password.c
new file mode 100644
index 0000000..1a7615e
--- /dev/null
+++ b/grub-core/osdep/password.c
@@ -0,0 +1,5 @@
+#if defined (__MINGW32__) && !defined (__CYGWIN__)
+#include "windows/password.c"
+#else
+#include "unix/password.c"
+#endif
diff --git a/grub-core/osdep/platform.c b/grub-core/osdep/platform.c
new file mode 100644
index 0000000..441d152
--- /dev/null
+++ b/grub-core/osdep/platform.c
@@ -0,0 +1,9 @@
+#ifdef __linux__
+#include "linux/platform.c"
+#elif defined (__MINGW32__) || defined (__CYGWIN__)
+#include "windows/platform.c"
+#elif defined (__MINGW32__) || defined (__CYGWIN__) || defined (__AROS__)
+#include "basic/no_platform.c"
+#else
+#include "basic/platform.c"
+#endif
diff --git a/grub-core/osdep/platform_unix.c b/grub-core/osdep/platform_unix.c
new file mode 100644
index 0000000..db6a02d
--- /dev/null
+++ b/grub-core/osdep/platform_unix.c
@@ -0,0 +1,3 @@
+#if !defined (__MINGW32__) && !defined (__CYGWIN__) && !defined (__AROS__)
+#include "unix/platform.c"
+#endif
diff --git a/grub-core/osdep/random.c b/grub-core/osdep/random.c
new file mode 100644
index 0000000..c6f9bc5
--- /dev/null
+++ b/grub-core/osdep/random.c
@@ -0,0 +1,10 @@
+#if defined (_WIN32) || defined (__CYGWIN__)
+#include "windows/random.c"
+#elif defined (__linux__) || defined (__FreeBSD__) \
+ || defined (__FreeBSD_kernel__) || defined (__OpenBSD__) \
+ || defined (__GNU__) || defined (__NetBSD__) \
+ || defined (__APPLE__) || defined(__sun__) || defined (__HAIKU__)
+#include "unix/random.c"
+#else
+#include "basic/random.c"
+#endif
diff --git a/grub-core/osdep/relpath.c b/grub-core/osdep/relpath.c
new file mode 100644
index 0000000..4e10d8a
--- /dev/null
+++ b/grub-core/osdep/relpath.c
@@ -0,0 +1,7 @@
+#if defined (__MINGW32__) || defined (__CYGWIN__)
+#include "windows/relpath.c"
+#elif defined (__AROS__)
+#include "aros/relpath.c"
+#else
+#include "unix/relpath.c"
+#endif
diff --git a/grub-core/osdep/sleep.c b/grub-core/osdep/sleep.c
new file mode 100644
index 0000000..c4ff172
--- /dev/null
+++ b/grub-core/osdep/sleep.c
@@ -0,0 +1,5 @@
+#if defined (__MINGW32__) || defined (__CYGWIN__)
+#include "windows/sleep.c"
+#else
+#include "unix/sleep.c"
+#endif
diff --git a/grub-core/osdep/sun/getroot.c b/grub-core/osdep/sun/getroot.c
new file mode 100644
index 0000000..6116037
--- /dev/null
+++ b/grub-core/osdep/sun/getroot.c
@@ -0,0 +1,126 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <grub/types.h>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+
+#include <sys/wait.h>
+
+# include <sys/types.h>
+# include <sys/mkdev.h>
+# include <sys/dkio.h>
+
+
+char *
+grub_util_part_to_disk (const char *os_dev,
+ struct stat *st,
+ int *is_part)
+{
+ char *colon = grub_strrchr (os_dev, ':');
+
+ if (! S_ISCHR (st->st_mode))
+ {
+ *is_part = 0;
+ return xstrdup (os_dev);
+ }
+
+ if (grub_memcmp (os_dev, "/devices", sizeof ("/devices") - 1) == 0
+ && colon)
+ {
+ char *ret = xmalloc (colon - os_dev + sizeof (":q,raw"));
+ if (grub_strcmp (colon, ":q,raw") != 0)
+ *is_part = 1;
+ grub_memcpy (ret, os_dev, colon - os_dev);
+ grub_memcpy (ret + (colon - os_dev), ":q,raw", sizeof (":q,raw"));
+ return ret;
+ }
+ else
+ return xstrdup (os_dev);
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dev_abstraction_os (const char *os_dev __attribute__((unused)))
+{
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+int
+grub_util_pull_device_os (const char *os_dev __attribute__ ((unused)),
+ enum grub_dev_abstraction_types ab __attribute__ ((unused)))
+{
+ return 0;
+}
+
+char *
+grub_util_get_grub_dev_os (const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+grub_disk_addr_t
+grub_util_find_partition_start_os (const char *dev)
+{
+ int fd;
+ struct extpart_info pinfo;
+
+ fd = open (dev, O_RDONLY);
+ if (fd == -1)
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot open `%s': %s"),
+ dev, strerror (errno));
+ return 0;
+ }
+
+ if (ioctl (fd, DKIOCEXTPARTINFO, &pinfo))
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE,
+ "cannot get disk geometry of `%s'", dev);
+ close (fd);
+ return 0;
+ }
+
+ close (fd);
+
+ return pinfo.p_start;
+}
diff --git a/grub-core/osdep/sun/hostdisk.c b/grub-core/osdep/sun/hostdisk.c
new file mode 100644
index 0000000..dab96dc
--- /dev/null
+++ b/grub-core/osdep/sun/hostdisk.c
@@ -0,0 +1,73 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+# include <sys/dkio.h>
+
+grub_int64_t
+grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_secsize)
+{
+ struct dk_minfo minfo;
+ unsigned sector_size, log_sector_size;
+
+ if (!ioctl (fd, DKIOCGMEDIAINFO, &minfo))
+ return -1;
+
+ sector_size = minfo.dki_lbsize;
+
+ if (sector_size & (sector_size - 1) || !sector_size)
+ return -1;
+ for (log_sector_size = 0;
+ (1 << log_sector_size) < sector_size;
+ log_sector_size++);
+
+ if (log_secsize)
+ *log_secsize = log_sector_size;
+
+ return minfo.dki_capacity << log_sector_size;
+}
+
+void
+grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
+{
+}
diff --git a/grub-core/osdep/unix/compress.c b/grub-core/osdep/unix/compress.c
new file mode 100644
index 0000000..dee5620
--- /dev/null
+++ b/grub-core/osdep/unix/compress.c
@@ -0,0 +1,41 @@
+/*
+ * 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/emu/exec.h>
+#include <grub/util/install.h>
+
+int
+grub_install_compress_gzip (const char *src, const char *dest)
+{
+ return grub_util_exec_redirect ((const char * []) { "gzip", "--best",
+ "--stdout", NULL }, src, dest);
+}
+
+int
+grub_install_compress_xz (const char *src, const char *dest)
+{
+ return grub_util_exec_redirect ((const char * []) { "xz",
+ "--lzma2=dict=128KiB", "--check=none", "--stdout", NULL }, src, dest);
+}
+
+int
+grub_install_compress_lzop (const char *src, const char *dest)
+{
+ return grub_util_exec_redirect ((const char * []) { "lzop", "-9", "-c",
+ NULL }, src, dest);
+}
diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c
new file mode 100644
index 0000000..7d63251
--- /dev/null
+++ b/grub-core/osdep/unix/config.c
@@ -0,0 +1,139 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config.h>
+#include <config-util.h>
+
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/exec.h>
+#include <grub/emu/config.h>
+#include <grub/util/install.h>
+#include <grub/util/misc.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <stdlib.h>
+
+const char *
+grub_util_get_config_filename (void)
+{
+ static char *value = NULL;
+ if (!value)
+ value = grub_util_path_concat (3, GRUB_SYSCONFDIR,
+ "default", "grub");
+ return value;
+}
+
+const char *
+grub_util_get_pkgdatadir (void)
+{
+ const char *ret = getenv ("pkgdatadir");
+ if (ret)
+ return ret;
+ return GRUB_DATADIR "/" PACKAGE;
+}
+
+const char *
+grub_util_get_pkglibdir (void)
+{
+ return GRUB_LIBDIR "/" PACKAGE;
+}
+
+const char *
+grub_util_get_localedir (void)
+{
+ return LOCALEDIR;
+}
+
+void
+grub_util_load_config (struct grub_util_config *cfg)
+{
+ pid_t pid;
+ const char *argv[4];
+ char *script, *ptr;
+ const char *cfgfile, *iptr;
+ FILE *f = NULL;
+ int fd;
+ const char *v;
+
+ memset (cfg, 0, sizeof (*cfg));
+
+ v = getenv ("GRUB_ENABLE_CRYPTODISK");
+ if (v && v[0] == 'y' && v[1] == '\0')
+ cfg->is_cryptodisk_enabled = 1;
+
+ v = getenv ("GRUB_DISTRIBUTOR");
+ if (v)
+ cfg->grub_distributor = xstrdup (v);
+
+ cfgfile = grub_util_get_config_filename ();
+ if (!grub_util_is_regular (cfgfile))
+ return;
+
+ argv[0] = "sh";
+ argv[1] = "-c";
+
+ script = xcalloc (4, strlen (cfgfile) + 300);
+
+ ptr = script;
+ memcpy (ptr, ". '", 3);
+ ptr += 3;
+ for (iptr = cfgfile; *iptr; iptr++)
+ {
+ if (*iptr == '\\')
+ {
+ memcpy (ptr, "'\\''", 4);
+ ptr += 4;
+ continue;
+ }
+ *ptr++ = *iptr;
+ }
+
+ strcpy (ptr, "'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\n\" "
+ "\"$GRUB_ENABLE_CRYPTODISK\" \"$GRUB_DISTRIBUTOR\"");
+
+ argv[2] = script;
+ argv[3] = '\0';
+
+ pid = grub_util_exec_pipe (argv, &fd);
+ if (pid)
+ f = fdopen (fd, "r");
+ if (f)
+ {
+ grub_util_parse_config (f, cfg, 1);
+ fclose (f);
+ }
+ if (pid)
+ {
+ close (fd);
+ waitpid (pid, NULL, 0);
+ }
+ if (f)
+ return;
+
+ f = grub_util_fopen (cfgfile, "r");
+ if (f)
+ {
+ grub_util_parse_config (f, cfg, 0);
+ fclose (f);
+ }
+ else
+ 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
new file mode 100644
index 0000000..cff359a
--- /dev/null
+++ b/grub-core/osdep/unix/cputime.c
@@ -0,0 +1,22 @@
+#include <config.h>
+#include <config-util.h>
+
+#include <sys/times.h>
+#include <unistd.h>
+#include <grub/emu/misc.h>
+
+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) / sc_clk_tck;
+}
diff --git a/grub-core/osdep/unix/dl.c b/grub-core/osdep/unix/dl.c
new file mode 100644
index 0000000..562b101
--- /dev/null
+++ b/grub-core/osdep/unix/dl.c
@@ -0,0 +1,61 @@
+/*
+ * 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 <config.h>
+#include <config-util.h>
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <sys/mman.h>
+#include <stdlib.h>
+#include <string.h>
+
+void *
+grub_osdep_dl_memalign (grub_size_t align, grub_size_t size)
+{
+ void *ret;
+ if (align < 8192 * 16)
+ align = 8192 * 16;
+ size = ALIGN_UP (size, 8192 * 16);
+
+#if defined(HAVE_POSIX_MEMALIGN)
+ if (posix_memalign (&ret, align, size) != 0)
+ ret = 0;
+#elif defined(HAVE_MEMALIGN)
+ ret = memalign (align, size);
+#else
+#error "Complete this"
+#endif
+
+ if (!ret)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return NULL;
+ }
+
+ mprotect (ret, size, PROT_READ | PROT_WRITE | PROT_EXEC);
+ return ret;
+}
+
+void
+grub_dl_osdep_dl_free (void *ptr)
+{
+ if (ptr)
+ free (ptr);
+}
diff --git a/grub-core/osdep/unix/emuconsole.c b/grub-core/osdep/unix/emuconsole.c
new file mode 100644
index 0000000..7308798
--- /dev/null
+++ b/grub-core/osdep/unix/emuconsole.c
@@ -0,0 +1,184 @@
+/* console.c -- console for GRUB. */
+/*
+ * 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 <config.h>
+#include <config-util.h>
+
+#include <grub/term.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/terminfo.h>
+#include <grub/dl.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <termios.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <langinfo.h>
+
+#include <grub/emu/console.h>
+
+extern struct grub_terminfo_output_state grub_console_terminfo_output;
+static int original_fl;
+static int saved_orig;
+static struct termios orig_tty;
+static struct termios new_tty;
+
+static void
+put (struct grub_term_output *term __attribute__ ((unused)), const int c)
+{
+ char chr = c;
+ ssize_t actual;
+
+ actual = write (STDOUT_FILENO, &chr, 1);
+ if (actual < 1)
+ {
+ /* We cannot do anything about this, but some systems require us to at
+ least pretend to check the result. */
+ }
+}
+
+static int
+readkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ grub_uint8_t c;
+ ssize_t actual;
+
+ actual = read (STDIN_FILENO, &c, 1);
+ if (actual > 0)
+ return c;
+ return -1;
+}
+
+static grub_err_t
+grub_console_init_input (struct grub_term_input *term)
+{
+ if (!saved_orig)
+ {
+ original_fl = fcntl (STDIN_FILENO, F_GETFL);
+ fcntl (STDIN_FILENO, F_SETFL, original_fl | O_NONBLOCK);
+ }
+
+ saved_orig = 1;
+
+ tcgetattr(STDIN_FILENO, &orig_tty);
+ new_tty = orig_tty;
+ new_tty.c_lflag &= ~(ICANON | ECHO);
+ new_tty.c_cc[VMIN] = 1;
+ tcsetattr(STDIN_FILENO, TCSANOW, &new_tty);
+
+ return grub_terminfo_input_init (term);
+}
+
+static grub_err_t
+grub_console_fini_input (struct grub_term_input *term
+ __attribute__ ((unused)))
+{
+ fcntl (STDIN_FILENO, F_SETFL, original_fl);
+ tcsetattr(STDIN_FILENO, TCSANOW, &orig_tty);
+ saved_orig = 0;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_console_init_output (struct grub_term_output *term)
+{
+ struct winsize size;
+ if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &size) >= 0)
+ {
+ grub_console_terminfo_output.size.x = size.ws_col;
+ grub_console_terminfo_output.size.y = size.ws_row;
+ }
+ else
+ {
+ grub_console_terminfo_output.size.x = 80;
+ grub_console_terminfo_output.size.y = 24;
+ }
+
+ grub_terminfo_output_init (term);
+
+ return 0;
+}
+
+
+
+struct grub_terminfo_input_state grub_console_terminfo_input =
+ {
+ .readkey = readkey
+ };
+
+struct grub_terminfo_output_state grub_console_terminfo_output =
+ {
+ .put = put,
+ .size = { 80, 24 }
+ };
+
+static struct grub_term_input grub_console_term_input =
+ {
+ .name = "console",
+ .init = grub_console_init_input,
+ .fini = grub_console_fini_input,
+ .getkey = grub_terminfo_getkey,
+ .data = &grub_console_terminfo_input
+ };
+
+static struct grub_term_output grub_console_term_output =
+ {
+ .name = "console",
+ .init = grub_console_init_output,
+ .putchar = grub_terminfo_putchar,
+ .getxy = grub_terminfo_getxy,
+ .getwh = grub_terminfo_getwh,
+ .gotoxy = grub_terminfo_gotoxy,
+ .cls = grub_terminfo_cls,
+ .setcolorstate = grub_terminfo_setcolorstate,
+ .setcursor = grub_terminfo_setcursor,
+ .data = &grub_console_terminfo_output,
+ .progress_update_divisor = GRUB_PROGRESS_FAST
+ };
+
+void
+grub_console_init (void)
+{
+ const char *cs = nl_langinfo (CODESET);
+ if (cs && grub_strcasecmp (cs, "UTF-8"))
+ grub_console_term_output.flags = GRUB_TERM_CODE_TYPE_UTF8_LOGICAL;
+ else
+ grub_console_term_output.flags = GRUB_TERM_CODE_TYPE_ASCII;
+ grub_term_register_input ("console", &grub_console_term_input);
+ grub_term_register_output ("console", &grub_console_term_output);
+ grub_terminfo_init ();
+ grub_terminfo_output_register (&grub_console_term_output, "vt100-color");
+}
+
+void
+grub_console_fini (void)
+{
+ if (saved_orig)
+ {
+ fcntl (STDIN_FILENO, F_SETFL, original_fl);
+ tcsetattr(STDIN_FILENO, TCSANOW, &orig_tty);
+ }
+ saved_orig = 0;
+}
diff --git a/grub-core/osdep/unix/exec.c b/grub-core/osdep/unix/exec.c
new file mode 100644
index 0000000..e8db920
--- /dev/null
+++ b/grub-core/osdep/unix/exec.c
@@ -0,0 +1,245 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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-util.h>
+#include <config.h>
+
+#include <grub/misc.h>
+#include <unistd.h>
+#include <grub/emu/exec.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/util/misc.h>
+#include <grub/disk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/wait.h>
+
+int
+grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file,
+ const char *stdout_file, const char *stderr_file)
+{
+ pid_t pid;
+ int status = -1;
+ char *str, *pstr;
+ const char *const *ptr;
+ grub_size_t strl = 0;
+ for (ptr = argv; *ptr; ptr++)
+ strl += grub_strlen (*ptr) + 1;
+ if (stdin_file)
+ strl += grub_strlen (stdin_file) + 2;
+ if (stdout_file)
+ strl += grub_strlen (stdout_file) + 2;
+ if (stderr_file)
+ strl += grub_strlen (stderr_file) + 3;
+
+ pstr = str = xmalloc (strl);
+ for (ptr = argv; *ptr; ptr++)
+ {
+ pstr = grub_stpcpy (pstr, *ptr);
+ *pstr++ = ' ';
+ }
+ if (stdin_file)
+ {
+ *pstr++ = '<';
+ pstr = grub_stpcpy (pstr, stdin_file);
+ *pstr++ = ' ';
+ }
+ if (stdout_file)
+ {
+ *pstr++ = '>';
+ pstr = grub_stpcpy (pstr, stdout_file);
+ *pstr++ = ' ';
+ }
+ if (stderr_file)
+ {
+ *pstr++ = '2';
+ *pstr++ = '>';
+ pstr = grub_stpcpy (pstr, stderr_file);
+ pstr++;
+ }
+ *--pstr = '\0';
+
+ grub_util_info ("executing %s", str);
+ grub_free (str);
+
+ pid = fork ();
+ if (pid < 0)
+ grub_util_error (_("Unable to fork: %s"), strerror (errno));
+ else if (pid == 0)
+ {
+ int fd;
+ /* Child. */
+
+ /* Close fd's. */
+#ifdef GRUB_UTIL
+ grub_util_devmapper_cleanup ();
+ grub_diskfilter_fini ();
+#endif
+
+ if (stdin_file)
+ {
+ fd = open (stdin_file, O_RDONLY);
+ if (fd < 0)
+ _exit (127);
+ dup2 (fd, STDIN_FILENO);
+ close (fd);
+ }
+
+ if (stdout_file)
+ {
+ fd = open (stdout_file, O_WRONLY | O_CREAT, 0700);
+ if (fd < 0)
+ _exit (127);
+ dup2 (fd, STDOUT_FILENO);
+ close (fd);
+ }
+
+ if (stderr_file)
+ {
+ fd = open (stderr_file, O_WRONLY | O_CREAT, 0700);
+ if (fd < 0)
+ _exit (127);
+ dup2 (fd, STDERR_FILENO);
+ close (fd);
+ }
+
+ /* Ensure child is not localised. */
+ setenv ("LC_ALL", "C", 1);
+
+ execvp ((char *) argv[0], (char **) argv);
+ _exit (127);
+ }
+ waitpid (pid, &status, 0);
+ if (!WIFEXITED (status))
+ return -1;
+ return WEXITSTATUS (status);
+}
+
+int
+grub_util_exec (const char *const *argv)
+{
+ return grub_util_exec_redirect_all (argv, NULL, NULL, NULL);
+}
+
+int
+grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
+ const char *stdout_file)
+{
+ return grub_util_exec_redirect_all (argv, stdin_file, stdout_file, NULL);
+}
+
+int
+grub_util_exec_redirect_null (const char *const *argv)
+{
+ return grub_util_exec_redirect_all (argv, "/dev/null", "/dev/null", NULL);
+}
+
+pid_t
+grub_util_exec_pipe (const char *const *argv, int *fd)
+{
+ int pipe_fd[2];
+ pid_t pid;
+
+ *fd = 0;
+
+ if (pipe (pipe_fd) < 0)
+ {
+ grub_util_warn (_("Unable to create pipe: %s"),
+ strerror (errno));
+ return 0;
+ }
+ pid = fork ();
+ if (pid < 0)
+ grub_util_error (_("Unable to fork: %s"), strerror (errno));
+ else if (pid == 0)
+ {
+ /* Child. */
+
+ /* Close fd's. */
+#ifdef GRUB_UTIL
+ grub_util_devmapper_cleanup ();
+ grub_diskfilter_fini ();
+#endif
+
+ /* Ensure child is not localised. */
+ setenv ("LC_ALL", "C", 1);
+
+ close (pipe_fd[0]);
+ dup2 (pipe_fd[1], STDOUT_FILENO);
+ close (pipe_fd[1]);
+
+ execvp ((char *) argv[0], (char **) argv);
+ _exit (127);
+ }
+ else
+ {
+ close (pipe_fd[1]);
+ *fd = pipe_fd[0];
+ return pid;
+ }
+}
+
+pid_t
+grub_util_exec_pipe_stderr (const char *const *argv, int *fd)
+{
+ int pipe_fd[2];
+ pid_t pid;
+
+ *fd = 0;
+
+ if (pipe (pipe_fd) < 0)
+ {
+ grub_util_warn (_("Unable to create pipe: %s"),
+ strerror (errno));
+ return 0;
+ }
+ pid = fork ();
+ if (pid < 0)
+ grub_util_error (_("Unable to fork: %s"), strerror (errno));
+ else if (pid == 0)
+ {
+ /* Child. */
+
+ /* Close fd's. */
+#ifdef GRUB_UTIL
+ grub_util_devmapper_cleanup ();
+ grub_diskfilter_fini ();
+#endif
+
+ /* Ensure child is not localised. */
+ setenv ("LC_ALL", "C", 1);
+
+ close (pipe_fd[0]);
+ dup2 (pipe_fd[1], STDOUT_FILENO);
+ dup2 (pipe_fd[1], STDERR_FILENO);
+ close (pipe_fd[1]);
+
+ execvp ((char *) argv[0], (char **) argv);
+ _exit (127);
+ }
+ else
+ {
+ close (pipe_fd[1]);
+ *fd = pipe_fd[0];
+ return pid;
+ }
+}
diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c
new file mode 100644
index 0000000..46d7116
--- /dev/null
+++ b/grub-core/osdep/unix/getroot.c
@@ -0,0 +1,787 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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-util.h>
+#include <config.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <grub/util/misc.h>
+#include <grub/emu/exec.h>
+
+#include <grub/cryptodisk.h>
+#include <grub/i18n.h>
+
+#if !defined (__MINGW32__) && !defined (__CYGWIN__) && !defined (__AROS__) && !defined (__HAIKU__)
+
+#ifdef __linux__
+#include <sys/ioctl.h> /* ioctl */
+#include <sys/mount.h>
+#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>
+# include <grub/util/libnvpair.h>
+#endif
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+# define FLOPPY_MAJOR 2
+#endif
+
+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+#include <sys/mount.h>
+#endif
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+# include <sys/ioctl.h>
+# include <sys/disklabel.h> /* struct disklabel */
+# include <sys/disk.h> /* struct dkwedge_info */
+#include <sys/param.h>
+#include <sys/mount.h>
+#endif /* defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) */
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+# ifdef HAVE_GETRAWPARTITION
+# include <util.h> /* getrawpartition */
+# endif /* HAVE_GETRAWPARTITION */
+#if defined(__NetBSD__)
+# include <sys/fdio.h>
+#endif
+# ifndef FLOPPY_MAJOR
+# define FLOPPY_MAJOR 2
+# endif /* ! FLOPPY_MAJOR */
+# ifndef RAW_FLOPPY_MAJOR
+# define RAW_FLOPPY_MAJOR 9
+# endif /* ! RAW_FLOPPY_MAJOR */
+#endif /* defined(__NetBSD__) */
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#define LVM_DEV_MAPPER_STRING "/dev/linux_lvm/"
+#else
+#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
+#endif
+
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && defined(HAVE_STRUCT_STATFS_F_MNTFROMNAME)
+#include <sys/param.h>
+#include <sys/mount.h>
+#endif
+
+#include "save-cwd.h"
+
+#if !defined (__GNU__)
+static void
+strip_extra_slashes (char *dir)
+{
+ char *p = dir;
+
+ while ((p = strchr (p, '/')) != 0)
+ {
+ if (p[1] == '/')
+ {
+ memmove (p, p + 1, strlen (p));
+ continue;
+ }
+ else if (p[1] == '\0')
+ {
+ if (p > dir)
+ p[0] = '\0';
+ break;
+ }
+
+ p++;
+ }
+}
+
+static char *
+xgetcwd (void)
+{
+ size_t size = 10;
+ char *path;
+
+ path = xmalloc (size);
+ while (! getcwd (path, size))
+ {
+ size <<= 1;
+ path = xrealloc (path, size);
+ }
+
+ return path;
+}
+
+char **
+grub_util_find_root_devices_from_poolname (char *poolname)
+{
+ char **devices = 0;
+ size_t ndevices = 0;
+ size_t devices_allocated = 0;
+
+#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
+ zpool_handle_t *zpool;
+ libzfs_handle_t *libzfs;
+ nvlist_t *config, *vdev_tree;
+ nvlist_t **children;
+ unsigned int nvlist_count;
+ unsigned int i;
+ char *device = 0;
+
+ libzfs = grub_get_libzfs_handle ();
+ if (! libzfs)
+ return NULL;
+
+ zpool = zpool_open (libzfs, poolname);
+ config = zpool_get_config (zpool, NULL);
+
+ if (nvlist_lookup_nvlist (config, "vdev_tree", &vdev_tree) != 0)
+ error (1, errno, "nvlist_lookup_nvlist (\"vdev_tree\")");
+
+ if (nvlist_lookup_nvlist_array (vdev_tree, "children", &children, &nvlist_count) != 0)
+ error (1, errno, "nvlist_lookup_nvlist_array (\"children\")");
+ assert (nvlist_count > 0);
+
+ while (nvlist_lookup_nvlist_array (children[0], "children",
+ &children, &nvlist_count) == 0)
+ assert (nvlist_count > 0);
+
+ for (i = 0; i < nvlist_count; i++)
+ {
+ if (nvlist_lookup_string (children[i], "path", &device) != 0)
+ error (1, errno, "nvlist_lookup_string (\"path\")");
+
+ struct stat st;
+ if (stat (device, &st) == 0)
+ {
+#ifdef __sun__
+ if (grub_memcmp (device, "/dev/dsk/", sizeof ("/dev/dsk/") - 1)
+ == 0)
+ device = xasprintf ("/dev/rdsk/%s",
+ device + sizeof ("/dev/dsk/") - 1);
+ else if (grub_memcmp (device, "/devices", sizeof ("/devices") - 1)
+ == 0
+ && grub_memcmp (device + strlen (device) - 4,
+ ",raw", 4) != 0)
+ device = xasprintf ("%s,raw", device);
+ else
+#endif
+ device = xstrdup (device);
+ if (ndevices >= devices_allocated)
+ {
+ devices_allocated = 2 * (devices_allocated + 8);
+ devices = xrealloc (devices, sizeof (devices[0])
+ * devices_allocated);
+ }
+ devices[ndevices++] = device;
+ }
+
+ device = NULL;
+ }
+
+ zpool_close (zpool);
+#else
+ FILE *fp;
+ int ret;
+ char *line;
+ size_t len;
+ int st;
+
+ char name[PATH_MAX + 1], state[257], readlen[257], writelen[257];
+ char cksum[257], notes[257];
+ unsigned int dummy;
+ const char *argv[4];
+ pid_t pid;
+ int fd;
+
+ argv[0] = "zpool";
+ argv[1] = "status";
+ argv[2] = poolname;
+ argv[3] = NULL;
+
+ pid = grub_util_exec_pipe (argv, &fd);
+ if (!pid)
+ return NULL;
+
+ fp = fdopen (fd, "r");
+ if (!fp)
+ {
+ grub_util_warn (_("Unable to open stream from %s: %s"),
+ "zpool", strerror (errno));
+ goto out;
+ }
+
+ st = 0;
+ while (1)
+ {
+ line = NULL;
+ ret = getline (&line, &len, fp);
+ if (ret == -1)
+ break;
+
+ if (sscanf (line, " %s %256s %256s %256s %256s %256s",
+ name, state, readlen, writelen, cksum, notes) >= 5)
+ switch (st)
+ {
+ case 0:
+ if (!strcmp (name, "NAME")
+ && !strcmp (state, "STATE")
+ && !strcmp (readlen, "READ")
+ && !strcmp (writelen, "WRITE")
+ && !strcmp (cksum, "CKSUM"))
+ st++;
+ break;
+ case 1:
+ {
+ char *ptr = line;
+ while (1)
+ {
+ if (strncmp (ptr, poolname, strlen (poolname)) == 0
+ && grub_isspace(ptr[strlen (poolname)]))
+ st++;
+ if (!grub_isspace (*ptr))
+ break;
+ ptr++;
+ }
+ }
+ break;
+ case 2:
+ if (strcmp (name, "mirror") && !sscanf (name, "mirror-%u", &dummy)
+ && !sscanf (name, "raidz%u", &dummy)
+ && !sscanf (name, "raidz1%u", &dummy)
+ && !sscanf (name, "raidz2%u", &dummy)
+ && !sscanf (name, "raidz3%u", &dummy)
+ && !strcmp (state, "ONLINE"))
+ {
+ if (ndevices >= devices_allocated)
+ {
+ devices_allocated = 2 * (devices_allocated + 8);
+ devices = xrealloc (devices, sizeof (devices[0])
+ * devices_allocated);
+ }
+ if (name[0] == '/')
+ devices[ndevices++] = xstrdup (name);
+ else
+ devices[ndevices++] = xasprintf ("/dev/%s", name);
+ }
+ break;
+ }
+
+ free (line);
+ }
+
+ out:
+ close (fd);
+ waitpid (pid, NULL, 0);
+#endif
+ if (devices)
+ {
+ if (ndevices >= devices_allocated)
+ {
+ devices_allocated = 2 * (devices_allocated + 8);
+ devices = xrealloc (devices, sizeof (devices[0])
+ * devices_allocated);
+ }
+ devices[ndevices++] = 0;
+ }
+ return devices;
+}
+
+static char **
+find_root_devices_from_libzfs (const char *dir)
+{
+ char **devices = NULL;
+ char *poolname;
+ char *poolfs;
+
+ grub_find_zpool_from_dir (dir, &poolname, &poolfs);
+ if (! poolname)
+ return NULL;
+
+ devices = grub_util_find_root_devices_from_poolname (poolname);
+
+ free (poolname);
+ if (poolfs)
+ free (poolfs);
+
+ return devices;
+}
+
+char *
+grub_find_device (const char *dir, dev_t dev)
+{
+ DIR *dp;
+ struct saved_cwd saved_cwd;
+ struct dirent *ent;
+
+ if (! dir)
+ dir = "/dev";
+
+ dp = opendir (dir);
+ if (! dp)
+ return 0;
+
+ if (save_cwd (&saved_cwd) < 0)
+ {
+ grub_util_error ("%s", _("cannot save the original directory"));
+ closedir (dp);
+ return 0;
+ }
+
+ grub_util_info ("changing current directory to %s", dir);
+ if (chdir (dir) < 0)
+ {
+ free_cwd (&saved_cwd);
+ closedir (dp);
+ return 0;
+ }
+
+ while ((ent = readdir (dp)) != 0)
+ {
+ struct stat st;
+
+ /* Avoid:
+ - dotfiles (like "/dev/.tmp.md0") since they could be duplicates.
+ - dotdirs (like "/dev/.static") since they could contain duplicates. */
+ if (ent->d_name[0] == '.')
+ continue;
+
+ if (lstat (ent->d_name, &st) < 0)
+ /* Ignore any error. */
+ continue;
+
+ if (S_ISLNK (st.st_mode)) {
+#ifdef __linux__
+ if (strcmp (dir, "mapper") == 0 || strcmp (dir, "/dev/mapper") == 0) {
+ /* Follow symbolic links under /dev/mapper/; the canonical name
+ may be something like /dev/dm-0, but the names under
+ /dev/mapper/ are more human-readable and so we prefer them if
+ we can get them. */
+ if (stat (ent->d_name, &st) < 0)
+ continue;
+ } else
+#endif /* __linux__ */
+ /* Don't follow other symbolic links. */
+ continue;
+ }
+
+ if (S_ISDIR (st.st_mode))
+ {
+ /* Find it recursively. */
+ char *res;
+
+ res = grub_find_device (ent->d_name, dev);
+
+ if (res)
+ {
+ if (restore_cwd (&saved_cwd) < 0)
+ grub_util_error ("%s",
+ _("cannot restore the original directory"));
+
+ free_cwd (&saved_cwd);
+ closedir (dp);
+ return res;
+ }
+ }
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
+ if (S_ISCHR (st.st_mode) && st.st_rdev == dev)
+#else
+ if (S_ISBLK (st.st_mode) && st.st_rdev == dev)
+#endif
+ {
+#ifdef __linux__
+ /* Skip device names like /dev/dm-0, which are short-hand aliases
+ to more descriptive device names, e.g. those under /dev/mapper.
+ Also, don't skip devices which names start with dm-[0-9] in
+ directories below /dev, e.g. /dev/mapper/dm-0-luks. */
+ if (strcmp (dir, "/dev") == 0 &&
+ ent->d_name[0] == 'd' &&
+ ent->d_name[1] == 'm' &&
+ ent->d_name[2] == '-' &&
+ ent->d_name[3] >= '0' &&
+ ent->d_name[3] <= '9')
+ continue;
+#endif
+
+ /* Found! */
+ char *res;
+ char *cwd;
+
+ cwd = xgetcwd ();
+ res = xmalloc (strlen (cwd) + strlen (ent->d_name) + 3);
+ 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);
+
+ /* /dev/root is not a real block device keep looking, takes care
+ of situation where root filesystem is on the same partition as
+ grub files */
+
+ if (strcmp(res, "/dev/root") == 0)
+ {
+ free (res);
+ continue;
+ }
+
+ if (restore_cwd (&saved_cwd) < 0)
+ grub_util_error ("%s", _("cannot restore the original directory"));
+
+ free_cwd (&saved_cwd);
+ closedir (dp);
+ return res;
+ }
+ }
+
+ if (restore_cwd (&saved_cwd) < 0)
+ grub_util_error ("%s", _("cannot restore the original directory"));
+
+ free_cwd (&saved_cwd);
+ closedir (dp);
+ return 0;
+}
+
+char **
+grub_guess_root_devices (const char *dir_in)
+{
+ char **os_dev = NULL;
+ struct stat st;
+ dev_t dev;
+ char *dir = grub_canonicalize_file_name (dir_in);
+
+ if (!dir)
+ grub_util_error (_("failed to get canonical path of `%s'"), dir_in);
+
+#ifdef __linux__
+ if (!os_dev)
+ os_dev = grub_find_root_devices_from_mountinfo (dir, NULL);
+#endif /* __linux__ */
+
+ if (!os_dev)
+ os_dev = find_root_devices_from_libzfs (dir);
+
+ if (os_dev)
+ {
+ char **cur;
+ for (cur = os_dev; *cur; cur++)
+ {
+ char *tmp = *cur;
+ int root, dm;
+ if (strcmp (*cur, "/dev/root") == 0
+ || strncmp (*cur, "/dev/dm-", sizeof ("/dev/dm-") - 1) == 0)
+ *cur = tmp;
+ else
+ {
+ *cur = grub_canonicalize_file_name (tmp);
+ if (*cur == NULL)
+ grub_util_error (_("failed to get canonical path of `%s'"), tmp);
+ free (tmp);
+ }
+ root = (strcmp (*cur, "/dev/root") == 0);
+ dm = (strncmp (*cur, "/dev/dm-", sizeof ("/dev/dm-") - 1) == 0);
+ if (!dm && !root)
+ continue;
+ if (stat (*cur, &st) < 0)
+ break;
+ free (*cur);
+ dev = st.st_rdev;
+ *cur = grub_find_device (dm ? "/dev/mapper" : "/dev", dev);
+ }
+ if (!*cur)
+ return os_dev;
+ for (cur = os_dev; *cur; cur++)
+ free (*cur);
+ free (os_dev);
+ os_dev = 0;
+ }
+
+ if (stat (dir, &st) < 0)
+ grub_util_error (_("cannot stat `%s': %s"), dir, strerror (errno));
+ free (dir);
+
+ dev = st.st_dev;
+
+ os_dev = xmalloc (2 * sizeof (os_dev[0]));
+
+ /* This might be truly slow, but is there any better way? */
+ os_dev[0] = grub_find_device ("/dev", dev);
+
+ if (!os_dev[0])
+ {
+ free (os_dev);
+ return 0;
+ }
+
+ os_dev[1] = 0;
+
+ return os_dev;
+}
+
+#endif
+
+void
+grub_util_pull_lvm_by_command (const char *os_dev)
+{
+ const char *argv[8];
+ int fd;
+ pid_t pid;
+ FILE *vgs;
+ char *buf = NULL;
+ size_t len = 0;
+ char *vgname = NULL;
+ const char *iptr;
+ char *optr;
+ char *vgid = NULL;
+ grub_size_t vgidlen = 0;
+
+ vgid = grub_util_get_vg_uuid (os_dev);
+ if (vgid)
+ vgidlen = grub_strlen (vgid);
+
+ if (!vgid)
+ {
+ if (strncmp (os_dev, LVM_DEV_MAPPER_STRING,
+ sizeof (LVM_DEV_MAPPER_STRING) - 1)
+ != 0)
+ return;
+
+ vgname = xmalloc (strlen (os_dev + sizeof (LVM_DEV_MAPPER_STRING) - 1) + 1);
+ for (iptr = os_dev + sizeof (LVM_DEV_MAPPER_STRING) - 1, optr = vgname; *iptr; )
+ if (*iptr != '-')
+ *optr++ = *iptr++;
+ else if (iptr[0] == '-' && iptr[1] == '-')
+ {
+ iptr += 2;
+ *optr++ = '-';
+ }
+ else
+ break;
+ *optr = '\0';
+ }
+
+ /* by default PV name is left aligned in 10 character field, meaning that
+ we do not know where name ends. Using dummy --separator disables
+ alignment. We have a single field, so separator itself is not output */
+ argv[0] = "vgs";
+ argv[1] = "--options";
+ if (vgid)
+ argv[2] = "vg_uuid,pv_name";
+ else
+ argv[2] = "pv_name";
+ argv[3] = "--noheadings";
+ argv[4] = "--separator";
+ argv[5] = ":";
+ argv[6] = vgname;
+ argv[7] = NULL;
+
+ pid = grub_util_exec_pipe (argv, &fd);
+ free (vgname);
+
+ if (!pid)
+ {
+ free (vgid);
+ return;
+ }
+
+ /* Parent. Read vgs' output. */
+ vgs = fdopen (fd, "r");
+ if (! vgs)
+ {
+ grub_util_warn (_("Unable to open stream from %s: %s"),
+ "vgs", strerror (errno));
+ goto out;
+ }
+
+ while (getline (&buf, &len, vgs) > 0)
+ {
+ char *ptr;
+ /* LVM adds two spaces as standard prefix */
+ for (ptr = buf; ptr < buf + 2 && *ptr == ' '; ptr++);
+
+ if (vgid && (grub_strncmp (vgid, ptr, vgidlen) != 0
+ || ptr[vgidlen] != ':'))
+ continue;
+ if (vgid)
+ ptr += vgidlen + 1;
+ if (*ptr == '\0')
+ continue;
+ *(ptr + strlen (ptr) - 1) = '\0';
+ grub_util_pull_device (ptr);
+ }
+
+out:
+ close (fd);
+ waitpid (pid, NULL, 0);
+ free (buf);
+ free (vgid);
+}
+
+/* ZFS has similar problems to those of btrfs (see above). */
+void
+grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs)
+{
+ char *slash;
+
+ *poolname = *poolfs = NULL;
+
+#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && defined(HAVE_STRUCT_STATFS_F_MNTFROMNAME)
+ /* FreeBSD and GNU/kFreeBSD. */
+ {
+ struct statfs mnt;
+
+ if (statfs (dir, &mnt) != 0)
+ return;
+
+ if (strcmp (mnt.f_fstypename, "zfs") != 0)
+ return;
+
+ *poolname = xstrdup (mnt.f_mntfromname);
+ }
+#elif defined(HAVE_GETEXTMNTENT)
+ /* Solaris. */
+ {
+ struct stat st;
+ struct extmnttab mnt;
+
+ if (stat (dir, &st) != 0)
+ return;
+
+ FILE *mnttab = grub_util_fopen ("/etc/mnttab", "r");
+ if (! mnttab)
+ return;
+
+ while (getextmntent (mnttab, &mnt, sizeof (mnt)) == 0)
+ {
+ if (makedev (mnt.mnt_major, mnt.mnt_minor) == st.st_dev
+ && !strcmp (mnt.mnt_fstype, "zfs"))
+ {
+ *poolname = xstrdup (mnt.mnt_special);
+ break;
+ }
+ }
+
+ fclose (mnttab);
+ }
+#endif
+
+ if (! *poolname)
+ return;
+
+ slash = strchr (*poolname, '/');
+ if (slash)
+ {
+ *slash = '\0';
+ *poolfs = xstrdup (slash + 1);
+ }
+ else
+ *poolfs = xstrdup ("");
+}
+
+int
+grub_util_biosdisk_is_floppy (grub_disk_t disk)
+{
+ struct stat st;
+ int fd;
+ const char *dname;
+
+ dname = grub_util_biosdisk_get_osdev (disk);
+
+ if (!dname)
+ return 0;
+
+ fd = open (dname, O_RDONLY);
+ /* Shouldn't happen. */
+ if (fd == -1)
+ return 0;
+
+ /* Shouldn't happen either. */
+ if (fstat (fd, &st) < 0)
+ {
+ close (fd);
+ return 0;
+ }
+
+ close (fd);
+
+#if defined(__NetBSD__)
+ if (major(st.st_rdev) == RAW_FLOPPY_MAJOR)
+ return 1;
+#endif
+
+#if defined(FLOPPY_MAJOR)
+ if (major(st.st_rdev) == FLOPPY_MAJOR)
+#else
+ /* Some kernels (e.g. kFreeBSD) don't have a static major number
+ for floppies, but they still use a "fd[0-9]" pathname. */
+ if (dname[5] == 'f'
+ && dname[6] == 'd'
+ && dname[7] >= '0'
+ && dname[7] <= '9')
+#endif
+ return 1;
+
+ return 0;
+}
+
+#else
+
+#include <grub/emu/getroot.h>
+
+void
+grub_util_pull_lvm_by_command (const char *os_dev __attribute__ ((unused)))
+{
+}
+
+#endif
diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c
new file mode 100644
index 0000000..3a00d74
--- /dev/null
+++ b/grub-core/osdep/unix/hostdisk.c
@@ -0,0 +1,319 @@
+/* hostdisk.c - emulate biosdisk */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+#if !defined (__CYGWIN__) && !defined (__MINGW32__) && !defined (__AROS__)
+
+#ifdef __linux__
+# include <sys/ioctl.h> /* ioctl */
+# include <sys/mount.h>
+#endif /* __linux__ */
+
+grub_uint64_t
+grub_util_get_fd_size (grub_util_fd_t fd, const char *name, unsigned *log_secsize)
+{
+ struct stat st;
+ grub_int64_t ret = -1;
+
+ if (fstat (fd, &st) < 0)
+ /* TRANSLATORS: "stat" comes from the name of POSIX function. */
+ grub_util_error (_("cannot stat `%s': %s"), name, strerror (errno));
+#if GRUB_DISK_DEVS_ARE_CHAR
+ if (S_ISCHR (st.st_mode))
+#else
+ if (S_ISBLK (st.st_mode))
+#endif
+ ret = grub_util_get_fd_size_os (fd, name, log_secsize);
+ if (ret != -1LL)
+ return ret;
+
+ if (log_secsize)
+ *log_secsize = 9;
+
+ return st.st_size;
+}
+
+int
+grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
+{
+#if SIZEOF_OFF_T == 8
+ off_t offset = (off_t) off;
+
+ if (lseek (fd, offset, SEEK_SET) != offset)
+ return -1;
+#elif SIZEOF_OFF64_T == 8
+ off64_t offset = (off64_t) off;
+
+ if (lseek64 (fd, offset, SEEK_SET) != offset)
+ return -1;
+#else
+#error "No large file support"
+#endif
+ return 0;
+}
+
+
+/* Read LEN bytes from FD in BUF. Return less than or equal to zero if an
+ error occurs, otherwise return LEN. */
+ssize_t
+grub_util_fd_read (grub_util_fd_t fd, char *buf, size_t len)
+{
+ ssize_t size = 0;
+
+ while (len)
+ {
+ ssize_t ret = read (fd, buf, len);
+
+ if (ret == 0)
+ break;
+
+ if (ret < 0)
+ {
+ if (errno == EINTR)
+ continue;
+ else
+ return ret;
+ }
+
+ len -= ret;
+ buf += ret;
+ size += ret;
+ }
+
+ return size;
+}
+
+/* Write LEN bytes from BUF to FD. Return less than or equal to zero if an
+ error occurs, otherwise return LEN. */
+ssize_t
+grub_util_fd_write (grub_util_fd_t fd, const char *buf, size_t len)
+{
+ ssize_t size = 0;
+
+ while (len)
+ {
+ ssize_t ret = write (fd, buf, len);
+
+ if (ret == 0)
+ break;
+
+ if (ret < 0)
+ {
+ if (errno == EINTR)
+ continue;
+ else
+ return ret;
+ }
+
+ len -= ret;
+ buf += ret;
+ size += ret;
+ }
+
+ return size;
+}
+
+#if !defined (__NetBSD__) && !defined (__APPLE__) && !defined (__FreeBSD__) && !defined(__FreeBSD_kernel__)
+grub_util_fd_t
+grub_util_fd_open (const char *os_dev, int flags)
+{
+#ifdef O_LARGEFILE
+ flags |= O_LARGEFILE;
+#endif
+#ifdef O_BINARY
+ flags |= O_BINARY;
+#endif
+#ifdef O_CLOEXEC
+ flags |= O_CLOEXEC;
+#endif
+
+ return open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
+}
+#endif
+
+const char *
+grub_util_fd_strerror (void)
+{
+ return strerror (errno);
+}
+
+static int allow_fd_syncs = 1;
+
+int
+grub_util_fd_sync (grub_util_fd_t fd)
+{
+ if (allow_fd_syncs)
+ return fsync (fd);
+ return 0;
+}
+
+int
+grub_util_file_sync (FILE *f)
+{
+ if (fflush (f) != 0)
+ return -1;
+ if (!allow_fd_syncs)
+ return 0;
+ return fsync (fileno (f));
+}
+
+void
+grub_util_disable_fd_syncs (void)
+{
+ allow_fd_syncs = 0;
+}
+
+int
+grub_util_fd_close (grub_util_fd_t fd)
+{
+ return close (fd);
+}
+
+char *
+grub_canonicalize_file_name (const char *path)
+{
+#if defined (PATH_MAX)
+ char *ret;
+
+ ret = xmalloc (PATH_MAX);
+ if (!realpath (path, ret))
+ return NULL;
+ return ret;
+#else
+ return realpath (path, NULL);
+#endif
+}
+
+FILE *
+grub_util_fopen (const char *path, const char *mode)
+{
+ return fopen (path, mode);
+}
+
+int
+grub_util_is_directory (const char *path)
+{
+ struct stat st;
+
+ if (stat (path, &st) == -1)
+ return 0;
+
+ return S_ISDIR (st.st_mode);
+}
+
+int
+grub_util_is_regular (const char *path)
+{
+ struct stat st;
+
+ if (stat (path, &st) == -1)
+ return 0;
+
+ return S_ISREG (st.st_mode);
+}
+
+grub_uint32_t
+grub_util_get_mtime (const char *path)
+{
+ struct stat st;
+
+ if (stat (path, &st) == -1)
+ return 0;
+
+ return st.st_mtime;
+}
+
+#endif
+
+#if defined (__CYGWIN__) || (!defined (__MINGW32__) && !defined (__AROS__))
+
+int
+grub_util_is_special_file (const char *path)
+{
+ struct stat st;
+
+ if (lstat (path, &st) == -1)
+ return 1;
+ return (!S_ISREG (st.st_mode) && !S_ISDIR (st.st_mode));
+}
+
+
+char *
+grub_util_make_temporary_file (void)
+{
+ const char *t = getenv ("TMPDIR");
+ size_t tl;
+ char *tmp;
+ if (!t)
+ t = "/tmp";
+ tl = strlen (t);
+ tmp = xmalloc (tl + sizeof ("/grub.XXXXXX"));
+ memcpy (tmp, t, tl);
+ memcpy (tmp + tl, "/grub.XXXXXX",
+ sizeof ("/grub.XXXXXX"));
+ if (mkstemp (tmp) == -1)
+ grub_util_error (_("cannot make temporary file: %s"), strerror (errno));
+ return tmp;
+}
+
+char *
+grub_util_make_temporary_dir (void)
+{
+ const char *t = getenv ("TMPDIR");
+ size_t tl;
+ char *tmp;
+ if (!t)
+ t = "/tmp";
+ tl = strlen (t);
+ tmp = xmalloc (tl + sizeof ("/grub.XXXXXX"));
+ memcpy (tmp, t, tl);
+ memcpy (tmp + tl, "/grub.XXXXXX",
+ sizeof ("/grub.XXXXXX"));
+ if (!mkdtemp (tmp))
+ grub_util_error (_("cannot make temporary directory: %s"),
+ strerror (errno));
+ return tmp;
+}
+
+#endif
diff --git a/grub-core/osdep/unix/password.c b/grub-core/osdep/unix/password.c
new file mode 100644
index 0000000..9996b24
--- /dev/null
+++ b/grub-core/osdep/unix/password.c
@@ -0,0 +1,75 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
+ * 2007, 2008, 2009, 2010, 2011, 2012, 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/crypto.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+
+#include <termios.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+int
+grub_password_get (char buf[], unsigned buf_size)
+{
+ FILE *in;
+ struct termios s, t;
+ int tty_changed = 0;
+ char *ptr;
+
+ grub_refresh ();
+
+ /* Disable echoing. Based on glibc. */
+ in = fopen ("/dev/tty", "w+c");
+ if (in == NULL)
+ in = stdin;
+
+ if (tcgetattr (fileno (in), &t) == 0)
+ {
+ /* Save the old one. */
+ s = t;
+ /* Tricky, tricky. */
+ t.c_lflag &= ~(ECHO|ISIG);
+ tty_changed = (tcsetattr (fileno (in), TCSAFLUSH, &t) == 0);
+ }
+ else
+ tty_changed = 0;
+ grub_memset (buf, 0, buf_size);
+ if (!fgets (buf, buf_size, stdin))
+ {
+ if (in != stdin)
+ fclose (in);
+ return 0;
+ }
+ ptr = buf + strlen (buf) - 1;
+ while (buf <= ptr && (*ptr == '\n' || *ptr == '\r'))
+ *ptr-- = 0;
+ /* Restore the original setting. */
+ if (tty_changed)
+ (void) tcsetattr (fileno (in), TCSAFLUSH, &s);
+
+ 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
new file mode 100644
index 0000000..55b8f40
--- /dev/null
+++ b/grub-core/osdep/unix/platform.c
@@ -0,0 +1,241 @@
+/*
+ * 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 <config.h>
+
+#include <grub/util/install.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/util/misc.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/emu/exec.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <string.h>
+#include <errno.h>
+
+static char *
+get_ofpathname (const char *dev)
+{
+ size_t alloced = 4096;
+ char *ret = xmalloc (alloced);
+ size_t offset = 0;
+ int fd;
+ pid_t pid;
+
+ pid = grub_util_exec_pipe ((const char * []){ "ofpathname", dev, NULL }, &fd);
+ if (!pid)
+ goto fail;
+
+ FILE *fp = fdopen (fd, "r");
+ if (!fp)
+ goto fail;
+
+ while (!feof (fp))
+ {
+ size_t r;
+ if (alloced == offset)
+ {
+ alloced *= 2;
+ ret = xrealloc (ret, alloced);
+ }
+ r = fread (ret + offset, 1, alloced - offset, fp);
+ offset += r;
+ }
+
+ if (offset > 0 && ret[offset - 1] == '\n')
+ offset--;
+ if (offset > 0 && ret[offset - 1] == '\r')
+ offset--;
+ if (alloced == offset)
+ {
+ alloced++;
+ ret = xrealloc (ret, alloced);
+ }
+ ret[offset] = '\0';
+
+ fclose (fp);
+
+ return ret;
+
+ fail:
+ grub_util_error (_("couldn't find IEEE1275 device path for %s.\nYou will have to set `boot-device' variable manually"),
+ dev);
+}
+
+static int
+grub_install_remove_efi_entries_by_distributor (const char *efi_distributor)
+{
+ int fd;
+ pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd);
+ char *line = NULL;
+ size_t len = 0;
+ int rc = 0;
+
+ if (!pid)
+ {
+ grub_util_warn (_("Unable to open stream from %s: %s"),
+ "efibootmgr", strerror (errno));
+ return errno;
+ }
+
+ FILE *fp = fdopen (fd, "r");
+ if (!fp)
+ {
+ grub_util_warn (_("Unable to open stream from %s: %s"),
+ "efibootmgr", strerror (errno));
+ return errno;
+ }
+
+ line = xmalloc (80);
+ len = 80;
+ while (1)
+ {
+ int ret;
+ char *bootnum;
+ ret = getline (&line, &len, fp);
+ if (ret == -1)
+ break;
+ if (grub_memcmp (line, "Boot", sizeof ("Boot") - 1) != 0
+ || line[sizeof ("Boot") - 1] < '0'
+ || line[sizeof ("Boot") - 1] > '9')
+ continue;
+ if (!strcasestr (line, efi_distributor))
+ continue;
+ bootnum = line + sizeof ("Boot") - 1;
+ bootnum[4] = '\0';
+ if (!verbosity)
+ rc = grub_util_exec ((const char * []){ "efibootmgr", "-q",
+ "-b", bootnum, "-B", NULL });
+ else
+ rc = grub_util_exec ((const char * []){ "efibootmgr",
+ "-b", bootnum, "-B", NULL });
+ }
+
+ free (line);
+ return rc;
+}
+
+int
+grub_install_register_efi (grub_device_t efidir_grub_dev,
+ const char *efifile_path,
+ const char *efi_distributor)
+{
+ const char * efidir_disk;
+ int efidir_part;
+ int ret;
+ efidir_disk = grub_util_biosdisk_get_osdev (efidir_grub_dev->disk);
+ efidir_part = efidir_grub_dev->disk->partition ? efidir_grub_dev->disk->partition->number + 1 : 1;
+
+ if (grub_util_exec_redirect_null ((const char * []){ "efibootmgr", "--version", NULL }))
+ {
+ /* TRANSLATORS: This message is shown when required executable `%s'
+ isn't found. */
+ grub_util_error (_("%s: not found"), "efibootmgr");
+ }
+
+ /* On Linux, we need the efivars kernel modules. */
+#ifdef __linux__
+ grub_util_exec ((const char * []){ "modprobe", "-q", "efivars", NULL });
+#endif
+ /* Delete old entries from the same distributor. */
+ ret = grub_install_remove_efi_entries_by_distributor (efi_distributor);
+ if (ret)
+ return ret;
+
+ char *efidir_part_str = xasprintf ("%d", efidir_part);
+
+ if (!verbosity)
+ ret = grub_util_exec ((const char * []){ "efibootmgr", "-q",
+ "-c", "-d", efidir_disk,
+ "-p", efidir_part_str, "-w",
+ "-L", efi_distributor, "-l",
+ efifile_path, NULL });
+ else
+ ret = grub_util_exec ((const char * []){ "efibootmgr",
+ "-c", "-d", efidir_disk,
+ "-p", efidir_part_str, "-w",
+ "-L", efi_distributor, "-l",
+ efifile_path, NULL });
+ free (efidir_part_str);
+ return ret;
+}
+
+void
+grub_install_register_ieee1275 (int is_prep, const char *install_device,
+ int partno, const char *relpath)
+{
+ char *boot_device;
+
+ if (grub_util_exec_redirect_null ((const char * []){ "ofpathname", "--version", NULL }))
+ {
+ /* TRANSLATORS: This message is shown when required executable `%s'
+ isn't found. */
+ grub_util_error (_("%s: not found"), "ofpathname");
+ }
+
+ /* Get the Open Firmware device tree path translation. */
+ if (!is_prep)
+ {
+ char *ptr;
+ char *ofpath;
+ const char *iptr;
+
+ ofpath = get_ofpathname (install_device);
+ boot_device = xmalloc (strlen (ofpath) + 1
+ + sizeof ("XXXXXXXXXXXXXXXXXXXX")
+ + 1 + strlen (relpath) + 1);
+ ptr = grub_stpcpy (boot_device, ofpath);
+ *ptr++ = ':';
+ grub_snprintf (ptr, sizeof ("XXXXXXXXXXXXXXXXXXXX"), "%d",
+ partno);
+ ptr += strlen (ptr);
+ *ptr++ = ',';
+ for (iptr = relpath; *iptr; iptr++, ptr++)
+ {
+ if (*iptr == '/')
+ *ptr = '\\';
+ else
+ *ptr = *iptr;
+ }
+ *ptr = '\0';
+ }
+ else
+ boot_device = get_ofpathname (install_device);
+
+ if (grub_util_exec ((const char * []){ "nvsetenv", "boot-device",
+ boot_device, NULL }))
+ {
+ char *cmd = xasprintf ("setenv boot-device %s", boot_device);
+ grub_util_error (_("`nvsetenv' failed. \nYou will have to set `boot-device' variable manually. At the IEEE1275 prompt, type:\n %s\n"),
+ cmd);
+ free (cmd);
+ }
+
+ free (boot_device);
+}
+
+void
+grub_install_sgi_setup (const char *install_device,
+ const char *imgfile, const char *destname)
+{
+ grub_util_exec ((const char * []){ "dvhtool", "-d",
+ install_device, "--unix-to-vh",
+ imgfile, destname, NULL });
+ grub_util_warn ("%s", _("You will have to set `SystemPartition' and `OSLoader' manually."));
+}
diff --git a/grub-core/osdep/unix/random.c b/grub-core/osdep/unix/random.c
new file mode 100644
index 0000000..fa0101b
--- /dev/null
+++ b/grub-core/osdep/unix/random.c
@@ -0,0 +1,48 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1992-1999,2001,2003,2004,2005,2009,2010,2011,2012,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 <config.h>
+
+#include <grub/types.h>
+#include <grub/crypto.h>
+#include <grub/auth.h>
+#include <grub/emu/misc.h>
+#include <grub/util/misc.h>
+#include <grub/i18n.h>
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+grub_get_random (void *out, grub_size_t len)
+{
+ FILE *f;
+ size_t rd;
+
+ f = grub_util_fopen ("/dev/urandom", "rb");
+ if (!f)
+ return 1;
+ rd = fread (out, 1, len, f);
+ fclose (f);
+
+ if (rd != len)
+ return 1;
+ return 0;
+}
diff --git a/grub-core/osdep/unix/relpath.c b/grub-core/osdep/unix/relpath.c
new file mode 100644
index 0000000..f719950
--- /dev/null
+++ b/grub-core/osdep/unix/relpath.c
@@ -0,0 +1,151 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+
+#include <grub/util/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/mm.h>
+
+/* This function never prints trailing slashes (so that its output
+ can be appended a slash unconditionally). */
+char *
+grub_make_system_path_relative_to_its_root (const char *path)
+{
+ struct stat st;
+ char *p, *buf, *buf2, *buf3, *ret;
+ uintptr_t offset = 0;
+ dev_t num;
+ size_t len;
+ char *poolfs = NULL;
+
+ /* canonicalize. */
+ 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)
+ {
+ free (p);
+ return ret;
+ }
+#endif
+
+ /* For ZFS sub-pool filesystems. */
+#ifndef __HAIKU__
+ {
+ char *dummy;
+ grub_find_zpool_from_dir (p, &dummy, &poolfs);
+ }
+#endif
+
+ len = strlen (p) + 1;
+ buf = xstrdup (p);
+ free (p);
+
+ if (stat (buf, &st) < 0)
+ grub_util_error (_("cannot stat `%s': %s"), buf, strerror (errno));
+
+ buf2 = xstrdup (buf);
+ num = st.st_dev;
+
+ /* This loop sets offset to the number of chars of the root
+ directory we're inspecting. */
+ while (1)
+ {
+ p = strrchr (buf, '/');
+ if (p == NULL)
+ /* This should never happen. */
+ grub_util_error ("%s",
+ /* TRANSLATORS: canonical pathname is the
+ complete one e.g. /etc/fstab. It has
+ to contain `/' normally, if it doesn't
+ we're in trouble and throw this error. */
+ _("no `/' in canonical filename"));
+ if (p != buf)
+ *p = 0;
+ else
+ *++p = 0;
+
+ if (stat (buf, &st) < 0)
+ grub_util_error (_("cannot stat `%s': %s"), buf, strerror (errno));
+
+ /* buf is another filesystem; we found it. */
+ if (st.st_dev != num)
+ {
+ /* offset == 0 means path given is the mount point.
+ This works around special-casing of "/" in Un*x. This function never
+ prints trailing slashes (so that its output can be appended a slash
+ unconditionally). Each slash in is considered a preceding slash, and
+ therefore the root directory is an empty string. */
+ if (offset == 0)
+ {
+ free (buf);
+ free (buf2);
+ if (poolfs)
+ return xasprintf ("/%s/@", poolfs);
+ return xstrdup ("");
+ }
+ else
+ break;
+ }
+
+ offset = p - buf;
+ /* offset == 1 means root directory. */
+ if (offset == 1)
+ {
+ /* Include leading slash. */
+ offset = 0;
+ break;
+ }
+ }
+ free (buf);
+ buf3 = xstrdup (buf2 + offset);
+ buf2[offset] = 0;
+
+ free (buf2);
+
+ /* Remove trailing slashes, return empty string if root directory. */
+ len = strlen (buf3);
+ while (len > 0 && buf3[len - 1] == '/')
+ {
+ buf3[len - 1] = '\0';
+ len--;
+ }
+
+ if (poolfs)
+ {
+ ret = xasprintf ("/%s/@%s", poolfs, buf3);
+ free (buf3);
+ }
+ else
+ ret = buf3;
+
+ return ret;
+}
diff --git a/grub-core/osdep/unix/sleep.c b/grub-core/osdep/unix/sleep.c
new file mode 100644
index 0000000..5b00a38
--- /dev/null
+++ b/grub-core/osdep/unix/sleep.c
@@ -0,0 +1,30 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010,2011,2012,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 <time.h>
+#include <grub/time.h>
+
+void
+grub_millisleep (grub_uint32_t ms)
+{
+ struct timespec ts;
+
+ ts.tv_sec = ms / 1000;
+ ts.tv_nsec = (ms % 1000) * 1000000;
+ nanosleep (&ts, NULL);
+}
diff --git a/grub-core/osdep/windows/blocklist.c b/grub-core/osdep/windows/blocklist.c
new file mode 100644
index 0000000..6d0809a
--- /dev/null
+++ b/grub-core/osdep/windows/blocklist.c
@@ -0,0 +1,118 @@
+/*
+ * 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 <config.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/fs.h>
+#include <grub/ntfs.h>
+#include <grub/fat.h>
+#include <grub/exfat.h>
+#include <grub/udf.h>
+#include <grub/util/misc.h>
+#include <grub/util/install.h>
+#include <grub/emu/getroot.h>
+#include <grub/emu/hostfile.h>
+
+#include <windows.h>
+#include <winioctl.h>
+
+void
+grub_install_get_blocklist (grub_device_t root_dev,
+ const char *core_path,
+ const char *core_img __attribute__ ((unused)),
+ size_t core_size,
+ void (*callback) (grub_disk_addr_t sector,
+ unsigned offset,
+ unsigned length,
+ void *data),
+ void *hook_data)
+{
+ grub_disk_addr_t first_lcn = 0;
+ HANDLE filehd;
+ DWORD rets;
+ RETRIEVAL_POINTERS_BUFFER *extbuf;
+ size_t extbuf_size;
+ DWORD i;
+ grub_uint64_t sec_per_lcn;
+ grub_uint64_t curvcn = 0;
+ STARTING_VCN_INPUT_BUFFER start_vcn;
+ grub_fs_t fs;
+ grub_err_t err;
+
+ fs = grub_fs_probe (root_dev);
+ if (!fs)
+ grub_util_error ("%s", grub_errmsg);
+
+ /* This is ugly but windows doesn't give all needed data. Or does anyone
+ have a pointer how to retrieve it?
+ */
+ if (grub_strcmp (fs->name, "ntfs") == 0)
+ {
+ struct grub_ntfs_bpb bpb;
+ err = grub_disk_read (root_dev->disk, 0, 0, sizeof (bpb), &bpb);
+ if (err)
+ grub_util_error ("%s", grub_errmsg);
+ sec_per_lcn = ((grub_uint32_t) bpb.sectors_per_cluster
+ * (grub_uint32_t) grub_le_to_cpu16 (bpb.bytes_per_sector))
+ >> 9;
+ first_lcn = 0;
+ }
+ else if (grub_strcmp (fs->name, "exfat") == 0)
+ first_lcn = grub_exfat_get_cluster_sector (root_dev->disk, &sec_per_lcn);
+ else if (grub_strcmp (fs->name, "fat") == 0)
+ first_lcn = grub_fat_get_cluster_sector (root_dev->disk, &sec_per_lcn);
+ else if (grub_strcmp (fs->name, "udf") == 0)
+ first_lcn = grub_udf_get_cluster_sector (root_dev->disk, &sec_per_lcn);
+ else
+ grub_util_error ("unsupported fs for blocklist on windows: %s",
+ fs->name);
+
+ grub_util_info ("sec_per_lcn = %" GRUB_HOST_PRIuLONG_LONG
+ ", first_lcn=%" GRUB_HOST_PRIuLONG_LONG,
+ (unsigned long long) sec_per_lcn,
+ (unsigned long long) first_lcn);
+
+ first_lcn += grub_partition_get_start (root_dev->disk->partition);
+
+ start_vcn.StartingVcn.QuadPart = 0;
+
+ filehd = grub_util_fd_open (core_path, GRUB_UTIL_FD_O_RDONLY);
+ if (!GRUB_UTIL_FD_IS_VALID (filehd))
+ grub_util_error (_("cannot open `%s': %s"), core_path,
+ grub_util_fd_strerror ());
+
+ extbuf_size = sizeof (*extbuf) + sizeof (extbuf->Extents[0])
+ * ((core_size + 511) / 512);
+ extbuf = xmalloc (extbuf_size);
+
+ if (!DeviceIoControl(filehd, FSCTL_GET_RETRIEVAL_POINTERS,
+ &start_vcn, sizeof (start_vcn),
+ extbuf, extbuf_size, &rets, NULL))
+ grub_util_error ("FSCTL_GET_RETRIEVAL_POINTERS fails: %s",
+ grub_util_fd_strerror ());
+
+ CloseHandle (filehd);
+
+ for (i = 0; i < extbuf->ExtentCount; i++)
+ callback (extbuf->Extents[i].Lcn.QuadPart
+ * sec_per_lcn + first_lcn,
+ 0, 512 * sec_per_lcn * (extbuf->Extents[i].NextVcn.QuadPart - curvcn), hook_data);
+ free (extbuf);
+}
diff --git a/grub-core/osdep/windows/config.c b/grub-core/osdep/windows/config.c
new file mode 100644
index 0000000..928ab1a
--- /dev/null
+++ b/grub-core/osdep/windows/config.c
@@ -0,0 +1,57 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config.h>
+#include <config-util.h>
+
+#include <grub/emu/hostfile.h>
+#include <grub/emu/config.h>
+#include <grub/util/install.h>
+#include <grub/util/misc.h>
+
+void
+grub_util_load_config (struct grub_util_config *cfg)
+{
+ const char *cfgfile;
+ FILE *f = NULL;
+ const char *v;
+
+ cfgfile = grub_util_get_config_filename ();
+ if (!grub_util_is_regular (cfgfile))
+ return;
+
+ memset (cfg, 0, sizeof (*cfg));
+
+ v = getenv ("GRUB_ENABLE_CRYPTODISK");
+ if (v && v[0] == 'y' && v[1] == '\0')
+ cfg->is_cryptodisk_enabled = 1;
+
+ v = getenv ("GRUB_DISTRIBUTOR");
+ if (v)
+ cfg->grub_distributor = xstrdup (v);
+
+ f = grub_util_fopen (cfgfile, "r");
+ if (f)
+ {
+ grub_util_parse_config (f, cfg, 0);
+ fclose (f);
+ }
+ else
+ grub_util_warn (_("cannot open configuration file `%s': %s"),
+ cfgfile, strerror (errno));
+}
diff --git a/grub-core/osdep/windows/cputime.c b/grub-core/osdep/windows/cputime.c
new file mode 100644
index 0000000..3568aa2
--- /dev/null
+++ b/grub-core/osdep/windows/cputime.c
@@ -0,0 +1,19 @@
+#include <config.h>
+#include <config-util.h>
+
+#include <grub/emu/misc.h>
+#include <windows.h>
+
+grub_uint64_t
+grub_util_get_cpu_time_ms (void)
+{
+ FILETIME cr, ex, ke, us;
+ ULARGE_INTEGER us_ul;
+
+ GetProcessTimes (GetCurrentProcess (), &cr, &ex, &ke, &us);
+ us_ul.LowPart = us.dwLowDateTime;
+ us_ul.HighPart = us.dwHighDateTime;
+
+ return us_ul.QuadPart / 10000;
+}
+
diff --git a/grub-core/osdep/windows/dl.c b/grub-core/osdep/windows/dl.c
new file mode 100644
index 0000000..eec6a24
--- /dev/null
+++ b/grub-core/osdep/windows/dl.c
@@ -0,0 +1,59 @@
+/*
+ * 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 <config.h>
+#include <config-util.h>
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <stdlib.h>
+#include <string.h>
+#include <windows.h>
+
+void *
+grub_osdep_dl_memalign (grub_size_t align, grub_size_t size)
+{
+ void *ret;
+ if (align > 4096)
+ {
+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "too large alignment");
+ return NULL;
+ }
+
+ size = ALIGN_UP (size, 4096);
+
+ ret = VirtualAlloc (NULL, size, MEM_COMMIT | MEM_RESERVE,
+ PAGE_EXECUTE_READWRITE);
+
+ if (!ret)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return NULL;
+ }
+
+ return ret;
+}
+
+void
+grub_dl_osdep_dl_free (void *ptr)
+{
+ if (!ptr)
+ return;
+ VirtualFree (ptr, 0, MEM_RELEASE);
+}
diff --git a/grub-core/osdep/windows/emuconsole.c b/grub-core/osdep/windows/emuconsole.c
new file mode 100644
index 0000000..4fb3693
--- /dev/null
+++ b/grub-core/osdep/windows/emuconsole.c
@@ -0,0 +1,308 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,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 <config.h>
+#include <config-util.h>
+
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/err.h>
+
+#include <grub/emu/console.h>
+
+#include <windows.h>
+
+static HANDLE hStdin, hStdout;
+static DWORD orig_mode;
+static int saved_orig;
+
+
+static void
+grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
+{
+ TCHAR str[2 + 30];
+ unsigned i, j;
+ DWORD written;
+
+ /* For now, do not try to use a surrogate pair. */
+ if (c->base > 0xffff)
+ str[0] = '?';
+ else
+ str[0] = (c->base & 0xffff);
+ j = 1;
+ for (i = 0; i < c->ncomb && j+1 < ARRAY_SIZE (str); i++)
+ if (c->base < 0xffff)
+ str[j++] = grub_unicode_get_comb (c)[i].code;
+ str[j] = 0;
+
+ WriteConsole (hStdout, str, j, &written, NULL);
+}
+
+const unsigned windows_codes[] =
+ {
+ /* 0x21 */ [VK_PRIOR] = GRUB_TERM_KEY_PPAGE,
+ /* 0x22 */ [VK_NEXT] = GRUB_TERM_KEY_NPAGE,
+ /* 0x23 */ [VK_END] = GRUB_TERM_KEY_END,
+ /* 0x24 */ [VK_HOME] = GRUB_TERM_KEY_HOME,
+ /* 0x25 */ [VK_LEFT] = GRUB_TERM_KEY_LEFT,
+ /* 0x26 */ [VK_UP] = GRUB_TERM_KEY_UP,
+ /* 0x27 */ [VK_RIGHT] = GRUB_TERM_KEY_RIGHT,
+ /* 0x28 */ [VK_DOWN] = GRUB_TERM_KEY_DOWN,
+ /* 0x2e */ [VK_DELETE] = GRUB_TERM_KEY_DC,
+ /* 0x70 */ [VK_F1] = GRUB_TERM_KEY_F1,
+ /* 0x71 */ [VK_F2] = GRUB_TERM_KEY_F2,
+ /* 0x72 */ [VK_F3] = GRUB_TERM_KEY_F3,
+ /* 0x73 */ [VK_F4] = GRUB_TERM_KEY_F4,
+ /* 0x74 */ [VK_F5] = GRUB_TERM_KEY_F5,
+ /* 0x75 */ [VK_F6] = GRUB_TERM_KEY_F6,
+ /* 0x76 */ [VK_F7] = GRUB_TERM_KEY_F7,
+ /* 0x77 */ [VK_F8] = GRUB_TERM_KEY_F8,
+ /* 0x78 */ [VK_F9] = GRUB_TERM_KEY_F9,
+ /* 0x79 */ [VK_F10] = GRUB_TERM_KEY_F10,
+ /* 0x7a */ [VK_F11] = GRUB_TERM_KEY_F11,
+ /* 0x7b */ [VK_F12] = GRUB_TERM_KEY_F12,
+ };
+
+
+static int
+grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ while (1)
+ {
+ DWORD nev;
+ INPUT_RECORD ir;
+ int ret;
+
+ if (!GetNumberOfConsoleInputEvents (hStdin, &nev))
+ return GRUB_TERM_NO_KEY;
+
+ if (nev == 0)
+ return GRUB_TERM_NO_KEY;
+
+ if (!ReadConsoleInput (hStdin, &ir, 1,
+ &nev))
+ return GRUB_TERM_NO_KEY;
+
+ if (ir.EventType != KEY_EVENT)
+ continue;
+
+ if (!ir.Event.KeyEvent.bKeyDown)
+ continue;
+ ret = ir.Event.KeyEvent.uChar.UnicodeChar;
+ if (ret == 0)
+ {
+ unsigned kc = ir.Event.KeyEvent.wVirtualKeyCode;
+ if (kc < ARRAY_SIZE (windows_codes) && windows_codes[kc])
+ ret = windows_codes[kc];
+ else
+ continue;
+ if (ir.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED)
+ ret |= GRUB_TERM_SHIFT;
+ }
+ /* Workaround for AltGr bug. */
+ if (ir.Event.KeyEvent.dwControlKeyState & RIGHT_ALT_PRESSED)
+ return ret;
+ if (ir.Event.KeyEvent.dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))
+ ret |= GRUB_TERM_ALT;
+ if (ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
+ ret |= GRUB_TERM_CTRL;
+ return ret;
+ }
+}
+
+static struct grub_term_coordinate
+grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ csbi.dwSize.X = 80;
+ csbi.dwSize.Y = 25;
+
+ GetConsoleScreenBufferInfo (hStdout, &csbi);
+
+ return (struct grub_term_coordinate) { csbi.dwSize.X, csbi.dwSize.Y };
+}
+
+static struct grub_term_coordinate
+grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ GetConsoleScreenBufferInfo (hStdout, &csbi);
+
+ return (struct grub_term_coordinate) { csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y };
+}
+
+static void
+grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
+ struct grub_term_coordinate pos)
+{
+ COORD coord = { pos.x, pos.y };
+
+ SetConsoleCursorPosition (hStdout, coord);
+}
+
+static void
+grub_console_cls (struct grub_term_output *term)
+{
+ int tsz;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ struct grub_unicode_glyph c =
+ {
+ .base = ' ',
+ .variant = 0,
+ .attributes = 0,
+ .ncomb = 0,
+ .estimated_width = 1
+ };
+
+ GetConsoleScreenBufferInfo (hStdout, &csbi);
+
+ SetConsoleTextAttribute (hStdout, 0);
+ grub_console_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
+ tsz = csbi.dwSize.X * csbi.dwSize.Y;
+
+ while (tsz--)
+ grub_console_putchar (term, &c);
+
+ grub_console_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
+ SetConsoleTextAttribute (hStdout, csbi.wAttributes);
+}
+
+static void
+grub_console_setcolorstate (struct grub_term_output *term
+ __attribute__ ((unused)),
+ grub_term_color_state state)
+{
+
+
+ switch (state) {
+ case GRUB_TERM_COLOR_STANDARD:
+ SetConsoleTextAttribute (hStdout, GRUB_TERM_DEFAULT_STANDARD_COLOR
+ & 0x7f);
+ break;
+ case GRUB_TERM_COLOR_NORMAL:
+ SetConsoleTextAttribute (hStdout, grub_term_normal_color & 0x7f);
+ break;
+ case GRUB_TERM_COLOR_HIGHLIGHT:
+ SetConsoleTextAttribute (hStdout, grub_term_highlight_color & 0x7f);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
+{
+ CONSOLE_CURSOR_INFO ci;
+ ci.dwSize = 5;
+ ci.bVisible = on;
+ SetConsoleCursorInfo (hStdout, &ci);
+}
+
+static grub_err_t
+grub_efi_console_init (struct grub_term_output *term)
+{
+ grub_console_setcursor (term, 1);
+ return 0;
+}
+
+static grub_err_t
+grub_efi_console_fini (struct grub_term_output *term)
+{
+ grub_console_setcursor (term, 1);
+ return 0;
+}
+
+
+static grub_err_t
+grub_console_init_input (struct grub_term_input *term)
+{
+ if (!saved_orig)
+ {
+ GetConsoleMode (hStdin, &orig_mode);
+ }
+
+ saved_orig = 1;
+
+ SetConsoleMode (hStdin, orig_mode & ~ENABLE_ECHO_INPUT
+ & ~ENABLE_LINE_INPUT & ~ENABLE_PROCESSED_INPUT);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_console_fini_input (struct grub_term_input *term
+ __attribute__ ((unused)))
+{
+ SetConsoleMode (hStdin, orig_mode);
+ saved_orig = 0;
+ return GRUB_ERR_NONE;
+}
+
+
+static struct grub_term_input grub_console_term_input =
+ {
+ .name = "console",
+ .getkey = grub_console_getkey,
+ .init = grub_console_init_input,
+ .fini = grub_console_fini_input,
+ };
+
+static struct grub_term_output grub_console_term_output =
+ {
+ .name = "console",
+ .init = grub_efi_console_init,
+ .fini = grub_efi_console_fini,
+ .putchar = grub_console_putchar,
+ .getwh = grub_console_getwh,
+ .getxy = grub_console_getxy,
+ .gotoxy = grub_console_gotoxy,
+ .cls = grub_console_cls,
+ .setcolorstate = grub_console_setcolorstate,
+ .setcursor = grub_console_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS,
+ .progress_update_divisor = GRUB_PROGRESS_FAST
+ };
+
+void
+grub_console_init (void)
+{
+ hStdin = GetStdHandle (STD_INPUT_HANDLE);
+ hStdout = GetStdHandle (STD_OUTPUT_HANDLE);
+
+ grub_term_register_input ("console", &grub_console_term_input);
+ grub_term_register_output ("console", &grub_console_term_output);
+}
+
+void
+grub_console_fini (void)
+{
+ if (saved_orig)
+ {
+ SetConsoleMode (hStdin, orig_mode);
+ saved_orig = 0;
+ }
+ grub_term_unregister_input (&grub_console_term_input);
+ grub_term_unregister_output (&grub_console_term_output);
+}
diff --git a/grub-core/osdep/windows/getroot.c b/grub-core/osdep/windows/getroot.c
new file mode 100644
index 0000000..eada663
--- /dev/null
+++ b/grub-core/osdep/windows/getroot.c
@@ -0,0 +1,355 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <grub/types.h>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/charset.h>
+#include <grub/util/windows.h>
+#include <windows.h>
+#include <winioctl.h>
+
+TCHAR *
+grub_get_mount_point (const TCHAR *path)
+{
+ const TCHAR *ptr;
+ TCHAR *out;
+ TCHAR letter = 0;
+ size_t allocsize;
+
+ for (ptr = path; *ptr; ptr++);
+ allocsize = (ptr - path + 10) * 2;
+ out = xcalloc (allocsize, sizeof (out[0]));
+
+ /* When pointing to EFI system partition GetVolumePathName fails
+ for ESP root and returns abberant information for everything
+ else. Since GetVolumePathName shouldn't fail for any valid
+ //?/X: we use it as indicator. */
+ if ((path[0] == '/' || path[0] == '\\')
+ && (path[1] == '/' || path[1] == '\\')
+ && (path[2] == '?' || path[2] == '.')
+ && (path[3] == '/' || path[3] == '\\')
+ && path[4]
+ && (path[5] == ':'))
+ letter = path[4];
+ if (path[0] && path[1] == ':')
+ letter = path[0];
+ if (letter)
+ {
+ TCHAR letterpath[10] = TEXT("\\\\?\\#:");
+ letterpath[4] = letter;
+ if (!GetVolumePathName (letterpath, out, allocsize))
+ {
+ if (path[1] == ':')
+ {
+ out[0] = path[0];
+ out[1] = ':';
+ out[2] = '\0';
+ return out;
+ }
+ memcpy (out, path, sizeof (out[0]) * 6);
+ out[6] = '\0';
+ return out;
+ }
+ }
+
+ if (!GetVolumePathName (path, out, allocsize))
+ {
+ free (out);
+ return NULL;
+ }
+ return out;
+}
+
+char **
+grub_guess_root_devices (const char *dir)
+{
+ char **os_dev = NULL;
+ TCHAR *dirwindows, *mntpointwindows;
+ TCHAR *ptr;
+ TCHAR volumename[100];
+
+ dirwindows = grub_util_get_windows_path (dir);
+ if (!dirwindows)
+ return 0;
+
+ mntpointwindows = grub_get_mount_point (dirwindows);
+
+ if (!mntpointwindows)
+ {
+ free (dirwindows);
+ grub_util_info ("can't get volume path name: %d", (int) GetLastError ());
+ return 0;
+ }
+
+ if (!mntpointwindows[0])
+ {
+ free (dirwindows);
+ free (mntpointwindows);
+ return 0;
+ }
+
+ for (ptr = mntpointwindows; *ptr; ptr++);
+ if (*(ptr - 1) != '\\')
+ {
+ *ptr = '\\';
+ *(ptr + 1) = '\0';
+ }
+
+ if (!GetVolumeNameForVolumeMountPoint (mntpointwindows,
+ volumename,
+ ARRAY_SIZE (volumename)))
+ {
+ TCHAR letter = 0;
+ if ((mntpointwindows[0] == '/' || mntpointwindows[0] == '\\')
+ && (mntpointwindows[1] == '/' || mntpointwindows[1] == '\\')
+ && (mntpointwindows[2] == '?' || mntpointwindows[2] == '.')
+ && (mntpointwindows[3] == '/' || mntpointwindows[3] == '\\')
+ && mntpointwindows[4]
+ && (mntpointwindows[5] == ':'))
+ letter = mntpointwindows[4];
+ if (mntpointwindows[0] && mntpointwindows[1] == ':')
+ letter = mntpointwindows[0];
+ if (!letter)
+ {
+ free (dirwindows);
+ free (mntpointwindows);
+ return 0;
+ }
+ volumename[0] = '\\';
+ volumename[1] = '\\';
+ volumename[2] = '?';
+ volumename[3] = '\\';
+ volumename[4] = letter;
+ volumename[5] = ':';
+ volumename[6] = '\0';
+ }
+ os_dev = xmalloc (2 * sizeof (os_dev[0]));
+
+ for (ptr = volumename; *ptr; ptr++);
+ while (ptr > volumename && *(ptr - 1) == '\\')
+ *--ptr = '\0';
+
+ os_dev[0] = grub_util_tchar_to_utf8 (volumename);
+ free (dirwindows);
+ free (mntpointwindows);
+
+ if (!os_dev[0])
+ {
+ free (os_dev);
+ return 0;
+ }
+
+ os_dev[1] = 0;
+
+ return os_dev;
+}
+
+static int tcharncasecmp (LPCTSTR a, const char *b, size_t sz)
+{
+ for (; sz; sz--, a++, b++)
+ {
+ char ac, bc;
+ if(*a >= 0x80)
+ return +1;
+ if (*b & 0x80)
+ return -1;
+ if (*a == '\0' && *b == '\0')
+ return 0;
+ ac = *a;
+ bc = *b;
+ if (ac >= 'A' && ac <= 'Z')
+ ac -= 'A' - 'a';
+ if (bc >= 'A' && bc <= 'Z')
+ bc -= 'A' - 'a';
+ if (ac > bc)
+ return +1;
+ if (ac < bc)
+ return -1;
+ }
+ return 0;
+}
+
+char *
+grub_util_part_to_disk (const char *os_dev,
+ struct stat *st __attribute__ ((unused)),
+ int *is_part)
+{
+ HANDLE hd;
+ LPTSTR name = grub_util_get_windows_path (os_dev);
+ VOLUME_DISK_EXTENTS exts;
+ DWORD extsbytes;
+ char *ret;
+
+ if (((name[0] == '/') || (name[0] == '\\')) &&
+ ((name[1] == '/') || (name[1] == '\\')) &&
+ ((name[2] == '.') || (name[2] == '?')) &&
+ ((name[3] == '/') || (name[3] == '\\'))
+ && (tcharncasecmp (name + 4, "PhysicalDrive", sizeof ("PhysicalDrive") - 1) == 0
+ || tcharncasecmp (name + 4, "Harddisk", sizeof ("Harddisk") - 1) == 0
+ || ((name[4] == 'A' || name[4] == 'a' || name[4] == 'B' || name[4] == 'b')
+ && name[5] == ':' && name[6] == '\0')))
+ {
+ grub_util_info ("Matches full disk pattern");
+ ret = grub_util_tchar_to_utf8 (name);
+ free (name);
+ return ret;
+ }
+
+ hd = CreateFile (name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ 0, OPEN_EXISTING, 0, 0);
+ if (hd == INVALID_HANDLE_VALUE)
+ {
+ grub_util_info ("CreateFile failed");
+ ret = grub_util_tchar_to_utf8 (name);
+ free (name);
+ return ret;
+ }
+
+ if (!DeviceIoControl(hd, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
+ NULL, 0, &exts, sizeof (exts), &extsbytes, NULL))
+ {
+ grub_util_info ("IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS failed");
+ ret = grub_util_tchar_to_utf8 (name);
+ CloseHandle (hd);
+ free (name);
+ return ret;
+ }
+
+ CloseHandle (hd);
+
+ *is_part = 1;
+ free (name);
+ return xasprintf ("\\\\?\\PhysicalDrive%lu", (unsigned long) exts.Extents[0].DiskNumber);
+}
+
+enum grub_dev_abstraction_types
+grub_util_get_dev_abstraction_os (const char *os_dev __attribute__((unused)))
+{
+ return GRUB_DEV_ABSTRACTION_NONE;
+}
+
+int
+grub_util_pull_device_os (const char *os_dev __attribute__ ((unused)),
+ enum grub_dev_abstraction_types ab __attribute__ ((unused)))
+{
+ return 0;
+}
+
+char *
+grub_util_get_grub_dev_os (const char *os_dev __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+
+grub_disk_addr_t
+grub_util_find_partition_start_os (const char *os_dev)
+{
+ HANDLE hd;
+ LPTSTR name = grub_util_get_windows_path (os_dev);
+ VOLUME_DISK_EXTENTS exts;
+ DWORD extsbytes;
+ char *ret;
+
+ if (((name[0] == '/') || (name[0] == '\\')) &&
+ ((name[1] == '/') || (name[1] == '\\')) &&
+ ((name[2] == '.') || (name[2] == '?')) &&
+ ((name[3] == '/') || (name[3] == '\\'))
+ && (tcharncasecmp (name + 4, "PhysicalDrive", sizeof ("PhysicalDrive") - 1) == 0
+ || tcharncasecmp (name + 4, "Harddisk", sizeof ("Harddisk") - 1) == 0
+ || ((name[4] == 'A' || name[4] == 'a' || name[4] == 'B' || name[4] == 'b')
+ && name[5] == ':' && name[6] == '\0')))
+ {
+ ret = grub_util_tchar_to_utf8 (name);
+ free (name);
+ return 0;
+ }
+
+ hd = CreateFile (name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ 0, OPEN_EXISTING, 0, 0);
+ if (hd == INVALID_HANDLE_VALUE)
+ {
+ ret = grub_util_tchar_to_utf8 (name);
+ free (name);
+ return 0;
+ }
+
+ if (!DeviceIoControl(hd, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
+ NULL, 0, &exts, sizeof (exts), &extsbytes, NULL))
+ {
+ ret = grub_util_tchar_to_utf8 (name);
+ CloseHandle (hd);
+ free (name);
+ return 0;
+ }
+
+ CloseHandle (hd);
+ free (name);
+ return exts.Extents[0].StartingOffset.QuadPart / 512;
+}
+
+int
+grub_util_biosdisk_is_floppy (grub_disk_t disk)
+{
+ int ret;
+ const char *dname;
+ LPTSTR name;
+
+ dname = grub_util_biosdisk_get_osdev (disk);
+
+ if (!dname)
+ return 0;
+
+ name = grub_util_get_windows_path (dname);
+
+ ret = (((name[0] == '/') || (name[0] == '\\')) &&
+ ((name[1] == '/') || (name[1] == '\\')) &&
+ ((name[2] == '.') || (name[2] == '?')) &&
+ ((name[3] == '/') || (name[3] == '\\'))
+ && (name[4] == 'A' || name[4] == 'a' || name[4] == 'B' || name[4] == 'b')
+ && name[5] == ':' && name[6] == '\0');
+ free (name);
+
+ return ret;
+}
diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c
new file mode 100644
index 0000000..0be3273
--- /dev/null
+++ b/grub-core/osdep/windows/hostdisk.c
@@ -0,0 +1,689 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+#include <grub/util/windows.h>
+#include <grub/charset.h>
+
+#include <windows.h>
+#include <winioctl.h>
+#include <wincrypt.h>
+
+#ifdef __CYGWIN__
+#include <sys/cygwin.h>
+#endif
+
+#if SIZEOF_TCHAR == 1
+
+LPTSTR
+grub_util_utf8_to_tchar (const char *in)
+{
+ return xstrdup (in);
+}
+
+char *
+grub_util_tchar_to_utf8 (LPCTSTR in)
+{
+ return xstrdup (in);
+}
+
+#elif SIZEOF_TCHAR == 2
+
+LPTSTR
+grub_util_utf8_to_tchar (const char *in)
+{
+ LPTSTR ret;
+ size_t ssz = strlen (in);
+ size_t tsz = 2 * (GRUB_MAX_UTF16_PER_UTF8 * ssz + 1);
+ ret = xmalloc (tsz);
+ tsz = grub_utf8_to_utf16 (ret, tsz,
+ (const grub_uint8_t *) in, ssz, NULL);
+ ret[tsz] = 0;
+ return ret;
+}
+
+char *
+grub_util_tchar_to_utf8 (LPCTSTR in)
+{
+ size_t ssz;
+ for (ssz = 0; in[ssz]; ssz++);
+
+ size_t tsz = GRUB_MAX_UTF8_PER_UTF16 * ssz + 1;
+ grub_uint8_t *ret = xmalloc (tsz);
+ *grub_utf16_to_utf8 (ret, in, ssz) = '\0';
+ return (char *) ret;
+}
+
+#else
+#error "Unsupported TCHAR size"
+#endif
+
+
+static LPTSTR
+grub_util_get_windows_path_real (const char *path)
+{
+ LPTSTR fpa;
+ LPTSTR tpath;
+ size_t alloc, len;
+
+ tpath = grub_util_utf8_to_tchar (path);
+
+ alloc = PATH_MAX;
+
+ while (1)
+ {
+ fpa = xcalloc (alloc, sizeof (fpa[0]));
+
+ len = GetFullPathName (tpath, alloc, fpa, NULL);
+ if (len >= alloc)
+ {
+ free (fpa);
+ alloc = 2 * (len + 2);
+ continue;
+ }
+ if (len == 0)
+ {
+ free (fpa);
+ return tpath;
+ }
+
+ free (tpath);
+ return fpa;
+ }
+}
+
+#ifdef __CYGWIN__
+LPTSTR
+grub_util_get_windows_path (const char *path)
+{
+ LPTSTR winpath;
+ /* Workaround cygwin bugs with //?/. */
+ if ((path[0] == '\\' || path[0] == '/')
+ && (path[1] == '\\' || path[1] == '/')
+ && (path[2] == '?' || path[2] == '.')
+ && (path[3] == '\\' || path[3] == '/'))
+ return grub_util_get_windows_path_real (path);
+
+ winpath = xmalloc (sizeof (winpath[0]) * PATH_MAX);
+ memset (winpath, 0, sizeof (winpath[0]) * PATH_MAX);
+ if (cygwin_conv_path ((sizeof (winpath[0]) == 1 ? CCP_POSIX_TO_WIN_A
+ : CCP_POSIX_TO_WIN_W) | CCP_ABSOLUTE, path, winpath,
+ sizeof (winpath[0]) * PATH_MAX))
+ grub_util_error ("%s", _("cygwin_conv_path() failed"));
+ return winpath;
+}
+#else
+LPTSTR
+grub_util_get_windows_path (const char *path)
+{
+ return grub_util_get_windows_path_real (path);
+}
+#endif
+
+grub_uint64_t
+grub_util_get_fd_size (grub_util_fd_t hd, const char *name_in,
+ unsigned *log_secsize)
+{
+ grub_int64_t size = -1LL;
+ int log_sector_size = 9;
+ LPTSTR name = grub_util_get_windows_path (name_in);
+
+ if (log_secsize)
+ *log_secsize = log_sector_size;
+
+ if (((name[0] == '/') || (name[0] == '\\')) &&
+ ((name[1] == '/') || (name[1] == '\\')) &&
+ ((name[2] == '.') || (name[2] == '?')) &&
+ ((name[3] == '/') || (name[3] == '\\')))
+ {
+ DWORD nr;
+ DISK_GEOMETRY g;
+
+ if (! DeviceIoControl (hd, IOCTL_DISK_GET_DRIVE_GEOMETRY,
+ 0, 0, &g, sizeof (g), &nr, 0))
+ goto fail;
+
+ size = g.Cylinders.QuadPart;
+ size *= g.TracksPerCylinder * g.SectorsPerTrack * g.BytesPerSector;
+
+ for (log_sector_size = 0;
+ (1 << log_sector_size) < g.BytesPerSector;
+ log_sector_size++);
+ }
+ else
+ {
+ ULARGE_INTEGER s;
+
+ s.LowPart = GetFileSize (hd, &s.HighPart);
+ size = s.QuadPart;
+ }
+
+ fail:
+
+ if (log_secsize)
+ *log_secsize = log_sector_size;
+
+ free (name);
+
+ return size;
+}
+
+void
+grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
+{
+}
+
+int
+grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
+{
+ LARGE_INTEGER offset;
+ offset.QuadPart = off;
+
+ if (!SetFilePointerEx (fd, offset, NULL, FILE_BEGIN))
+ return -1;
+ return 0;
+}
+
+grub_util_fd_t
+grub_util_fd_open (const char *os_dev, int flags)
+{
+ DWORD flg = 0, crt;
+ LPTSTR dev = grub_util_get_windows_path (os_dev);
+ grub_util_fd_t ret;
+
+ if (flags & GRUB_UTIL_FD_O_WRONLY)
+ flg |= GENERIC_WRITE;
+ if (flags & GRUB_UTIL_FD_O_RDONLY)
+ flg |= GENERIC_READ;
+
+ if (flags & GRUB_UTIL_FD_O_CREATTRUNC)
+ crt = CREATE_ALWAYS;
+ else
+ crt = OPEN_EXISTING;
+
+ ret = CreateFile (dev, flg, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ 0, crt, 0, 0);
+ free (dev);
+ return ret;
+}
+
+ssize_t
+grub_util_fd_read (grub_util_fd_t fd, char *buf, size_t len)
+{
+ DWORD real_read;
+ if (!ReadFile(fd, buf, len, &real_read, NULL))
+ {
+ grub_util_info ("read err %x", (int) GetLastError ());
+ return -1;
+ }
+ grub_util_info ("successful read");
+ return real_read;
+}
+
+ssize_t
+grub_util_fd_write (grub_util_fd_t fd, const char *buf, size_t len)
+{
+ DWORD real_read;
+ if (!WriteFile(fd, buf, len, &real_read, NULL))
+ {
+ grub_util_info ("write err %x", (int) GetLastError ());
+ return -1;
+ }
+
+ grub_util_info ("successful write");
+ return real_read;
+}
+
+static int allow_fd_syncs = 1;
+
+int
+grub_util_fd_sync (grub_util_fd_t fd)
+{
+ if (allow_fd_syncs)
+ {
+ if (!FlushFileBuffers (fd))
+ {
+ grub_util_info ("flush err %x", (int) GetLastError ());
+ return -1;
+ }
+ }
+ return 0;
+}
+
+void
+grub_util_disable_fd_syncs (void)
+{
+ allow_fd_syncs = 0;
+}
+
+int
+grub_util_fd_close (grub_util_fd_t fd)
+{
+ if (!CloseHandle (fd))
+ {
+ grub_util_info ("close err %x", (int) GetLastError ());
+ return -1;
+ }
+ return 0;
+}
+
+const char *
+grub_util_fd_strerror (void)
+{
+ DWORD err = GetLastError ();
+ LPTSTR tstr = NULL;
+ static char *last;
+ char *ret, *ptr;
+
+ free (last);
+ last = 0;
+
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
+ | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, err, 0, (void *) &tstr,
+ 0, NULL);
+
+ if (!tstr)
+ return "unknown error";
+
+ ret = grub_util_tchar_to_utf8 (tstr);
+
+ LocalFree (tstr);
+
+ last = ret;
+
+ for (ptr = ret + strlen (ret) - 1;
+ ptr >= ret && (*ptr == '\n' || *ptr == '\r');
+ ptr--);
+ ptr[1] = '\0';
+
+ return ret;
+}
+
+char *
+grub_canonicalize_file_name (const char *path)
+{
+ char *ret;
+ LPTSTR windows_path;
+ ret = xmalloc (PATH_MAX);
+
+ windows_path = grub_util_get_windows_path (path);
+ if (!windows_path)
+ return NULL;
+ ret = grub_util_tchar_to_utf8 (windows_path);
+ free (windows_path);
+
+ return ret;
+}
+
+void
+grub_util_mkdir (const char *dir)
+{
+ LPTSTR windows_name;
+
+ windows_name = grub_util_get_windows_path (dir);
+ CreateDirectory (windows_name, NULL);
+ free (windows_name);
+}
+
+int
+grub_util_rename (const char *from, const char *to)
+{
+ LPTSTR windows_from, windows_to;
+ int ret;
+
+ windows_from = grub_util_get_windows_path (from);
+ windows_to = grub_util_get_windows_path (to);
+ ret = !MoveFile (windows_from, windows_to);
+ free (windows_from);
+ free (windows_to);
+ return ret;
+}
+
+struct grub_util_fd_dir
+{
+ WIN32_FIND_DATA fd;
+ HANDLE hnd;
+ int is_end;
+ char *last;
+};
+
+grub_util_fd_dir_t
+grub_util_fd_opendir (const char *name)
+{
+ struct grub_util_fd_dir *ret;
+ LPTSTR name_windows;
+ LPTSTR pattern;
+ ssize_t l;
+
+ name_windows = grub_util_get_windows_path (name);
+ for (l = 0; name_windows[l]; l++);
+ for (l--; l >= 0 && (name_windows[l] == '\\' || name_windows[l] == '/'); l--);
+ l++;
+ pattern = xcalloc (l + 3, sizeof (pattern[0]));
+ memcpy (pattern, name_windows, l * sizeof (pattern[0]));
+ pattern[l] = '\\';
+ pattern[l + 1] = '*';
+ pattern[l + 2] = '\0';
+
+ ret = xmalloc (sizeof (*ret));
+ memset (ret, 0, sizeof (*ret));
+
+ ret->hnd = FindFirstFile (pattern, &ret->fd);
+
+ free (name_windows);
+ free (pattern);
+
+ if (ret->hnd == INVALID_HANDLE_VALUE)
+ {
+ DWORD err = GetLastError ();
+ if (err == ERROR_FILE_NOT_FOUND)
+ {
+ ret->is_end = 1;
+ return ret;
+ }
+ return NULL;
+ }
+ return ret;
+}
+
+void
+grub_util_fd_closedir (grub_util_fd_dir_t dirp)
+{
+ if (dirp->hnd != INVALID_HANDLE_VALUE)
+ CloseHandle (dirp->hnd);
+ free (dirp->last);
+ free (dirp);
+}
+
+grub_util_fd_dirent_t
+grub_util_fd_readdir (grub_util_fd_dir_t dirp)
+{
+ char *ret;
+ free (dirp->last);
+ dirp->last = NULL;
+
+ if (dirp->is_end)
+ return NULL;
+
+ ret = grub_util_tchar_to_utf8 (dirp->fd.cFileName);
+ dirp->last = ret;
+
+ if (!FindNextFile (dirp->hnd, &dirp->fd))
+ dirp->is_end = 1;
+ return (grub_util_fd_dirent_t) ret;
+}
+
+int
+grub_util_unlink (const char *name)
+{
+ LPTSTR name_windows;
+ int ret;
+
+ name_windows = grub_util_get_windows_path (name);
+
+ ret = !DeleteFile (name_windows);
+ free (name_windows);
+ return ret;
+}
+
+int
+grub_util_rmdir (const char *name)
+{
+ LPTSTR name_windows;
+ int ret;
+
+ name_windows = grub_util_get_windows_path (name);
+
+ ret = !RemoveDirectory (name_windows);
+ free (name_windows);
+ return ret;
+}
+
+#ifndef __CYGWIN__
+
+static char *
+get_temp_name (void)
+{
+ TCHAR rt[1024];
+ TCHAR *ptr;
+ HCRYPTPROV hCryptProv;
+ grub_uint8_t rnd[5];
+ int i;
+
+ GetTempPath (ARRAY_SIZE (rt) - 100, rt);
+
+ if (!CryptAcquireContext (&hCryptProv,
+ NULL,
+ MS_DEF_PROV,
+ PROV_RSA_FULL,
+ CRYPT_VERIFYCONTEXT)
+ || !CryptGenRandom (hCryptProv, 5, rnd))
+ grub_util_error ("%s", _("couldn't retrieve random data"));
+
+ CryptReleaseContext (hCryptProv, 0);
+
+ for (ptr = rt; *ptr; ptr++);
+ memcpy (ptr, TEXT("\\GRUB."), sizeof (TEXT("\\GRUB.")));
+ ptr += sizeof ("\\GRUB.") - 1;
+
+ for (i = 0; i < 8; i++)
+ {
+ grub_size_t b = i * 5;
+ grub_uint8_t r;
+ grub_size_t f1 = GRUB_CHAR_BIT - b % GRUB_CHAR_BIT;
+ grub_size_t f2;
+ if (f1 > 5)
+ f1 = 5;
+ f2 = 5 - f1;
+ r = (rnd[b / GRUB_CHAR_BIT] >> (b % GRUB_CHAR_BIT)) & ((1 << f1) - 1);
+ if (f2)
+ r |= (rnd[b / GRUB_CHAR_BIT + 1] & ((1 << f2) - 1)) << f1;
+ if (r < 10)
+ *ptr++ = '0' + r;
+ else
+ *ptr++ = 'a' + (r - 10);
+ }
+ *ptr = '\0';
+
+ return grub_util_tchar_to_utf8 (rt);
+}
+
+char *
+grub_util_make_temporary_file (void)
+{
+ char *ret = get_temp_name ();
+ FILE *f;
+
+ f = grub_util_fopen (ret, "wb");
+ if (f)
+ fclose (f);
+ return ret;
+}
+
+char *
+grub_util_make_temporary_dir (void)
+{
+ char *ret = get_temp_name ();
+
+ grub_util_mkdir (ret);
+
+ return ret;
+}
+
+#endif
+
+int
+grub_util_is_directory (const char *name)
+{
+ LPTSTR name_windows;
+ DWORD attr;
+
+ name_windows = grub_util_get_windows_path (name);
+ if (!name_windows)
+ return 0;
+
+ attr = GetFileAttributes (name_windows);
+ grub_free (name_windows);
+
+ return !!(attr & FILE_ATTRIBUTE_DIRECTORY);
+}
+
+int
+grub_util_is_regular (const char *name)
+{
+ LPTSTR name_windows;
+ DWORD attr;
+
+ name_windows = grub_util_get_windows_path (name);
+ if (!name_windows)
+ return 0;
+
+ attr = GetFileAttributes (name_windows);
+ grub_free (name_windows);
+
+ return !(attr & FILE_ATTRIBUTE_DIRECTORY)
+ && !(attr & FILE_ATTRIBUTE_REPARSE_POINT) && attr;
+}
+
+grub_uint32_t
+grub_util_get_mtime (const char *path)
+{
+ LPTSTR name_windows;
+ BOOL b;
+ WIN32_FILE_ATTRIBUTE_DATA attr;
+ ULARGE_INTEGER us_ul;
+
+ name_windows = grub_util_get_windows_path (path);
+ if (!name_windows)
+ return 0;
+
+ b = GetFileAttributesEx (name_windows, GetFileExInfoStandard, &attr);
+ grub_free (name_windows);
+
+ if (!b)
+ return 0;
+
+ us_ul.LowPart = attr.ftLastWriteTime.dwLowDateTime;
+ us_ul.HighPart = attr.ftLastWriteTime.dwHighDateTime;
+
+ return (us_ul.QuadPart / 10000000)
+ - 86400ULL * 365 * (1970 - 1601)
+ - 86400ULL * ((1970 - 1601) / 4) + 86400ULL * ((1970 - 1601) / 100);
+}
+
+
+#ifdef __MINGW32__
+
+FILE *
+grub_util_fopen (const char *path, const char *mode)
+{
+ LPTSTR tpath;
+ FILE *ret;
+ tpath = grub_util_get_windows_path (path);
+#if SIZEOF_TCHAR == 1
+ ret = fopen (tpath, tmode);
+#else
+ LPTSTR tmode;
+ tmode = grub_util_utf8_to_tchar (mode);
+ ret = _wfopen (tpath, tmode);
+ free (tmode);
+#endif
+ free (tpath);
+ return ret;
+}
+
+int
+grub_util_file_sync (FILE *f)
+{
+ HANDLE hnd;
+
+ if (fflush (f) != 0)
+ {
+ grub_util_info ("fflush err %x", (int) GetLastError ());
+ return -1;
+ }
+ if (!allow_fd_syncs)
+ return 0;
+ hnd = (HANDLE) _get_osfhandle (fileno (f));
+ if (!FlushFileBuffers (hnd))
+ {
+ grub_util_info ("flush err %x", (int) GetLastError ());
+ return -1;
+ }
+ return 0;
+}
+
+int
+grub_util_is_special_file (const char *name)
+{
+ LPTSTR name_windows;
+ DWORD attr;
+
+ name_windows = grub_util_get_windows_path (name);
+ if (!name_windows)
+ return 1;
+
+ attr = GetFileAttributes (name_windows);
+ grub_free (name_windows);
+
+ return !!(attr & FILE_ATTRIBUTE_REPARSE_POINT) || !attr;
+}
+
+#else
+
+void
+grub_util_file_sync (FILE *f)
+{
+ fflush (f);
+ if (!allow_fd_syncs)
+ return;
+ fsync (fileno (f));
+}
+
+FILE *
+grub_util_fopen (const char *path, const char *mode)
+{
+ return fopen (path, mode);
+}
+
+#endif
diff --git a/grub-core/osdep/windows/init.c b/grub-core/osdep/windows/init.c
new file mode 100644
index 0000000..6297de6
--- /dev/null
+++ b/grub-core/osdep/windows/init.c
@@ -0,0 +1,190 @@
+/*
+ * 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 <config.h>
+#include <config-util.h>
+#include <grub/util/misc.h>
+#include <grub/osdep/hostfile.h>
+#include <grub/util/windows.h>
+#include <grub/emu/config.h>
+
+#include <wincon.h>
+#include <windows.h>
+
+#include <grub/util/misc.h>
+
+#include "progname.h"
+
+struct grub_windows_console_font_infoex {
+ ULONG cbSize;
+ DWORD nFont;
+ COORD dwFontSize;
+ UINT FontFamily;
+ UINT FontWeight;
+ WCHAR FaceName[LF_FACESIZE];
+};
+
+static int
+check_is_raster (HMODULE kernel32, HANDLE hnd)
+{
+ CONSOLE_FONT_INFO console_font_info;
+ BOOL (WINAPI * func_GetCurrentConsoleFont) (HANDLE, BOOL,
+ PCONSOLE_FONT_INFO);
+
+ func_GetCurrentConsoleFont = (void *)
+ GetProcAddress (kernel32, "GetCurrentConsoleFont");
+
+ if (!func_GetCurrentConsoleFont)
+ return 1;
+
+ if (!func_GetCurrentConsoleFont (hnd, FALSE, &console_font_info))
+ return 1;
+ return console_font_info.nFont < 12;
+}
+
+static void
+set_console_unicode_font (void)
+{
+ BOOL (WINAPI * func_SetCurrentConsoleFontEx) (HANDLE, BOOL,
+ struct grub_windows_console_font_infoex *);
+ BOOL (WINAPI * func_SetConsoleFont)(HANDLE, DWORD);
+ HMODULE kernel32;
+ HANDLE out_handle = GetStdHandle (STD_OUTPUT_HANDLE);
+ HANDLE err_handle = GetStdHandle (STD_ERROR_HANDLE);
+ int out_raster, err_raster;
+
+ kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
+ if (!kernel32)
+ return;
+
+ out_raster = check_is_raster (kernel32, out_handle);
+ err_raster = check_is_raster (kernel32, err_handle);
+
+ if (!out_raster && !err_raster)
+ return;
+
+ func_SetCurrentConsoleFontEx = (void *) GetProcAddress (kernel32, "SetCurrentConsoleFontEx");
+
+ /* Newer windows versions. */
+ if (func_SetCurrentConsoleFontEx)
+ {
+ struct grub_windows_console_font_infoex new_console_font_info;
+ new_console_font_info.cbSize = sizeof (new_console_font_info);
+ new_console_font_info.nFont = 12;
+ new_console_font_info.dwFontSize.X = 7;
+ new_console_font_info.dwFontSize.Y = 12;
+ new_console_font_info.FontFamily = FF_DONTCARE;
+ new_console_font_info.FontWeight = 400;
+ memcpy (new_console_font_info.FaceName, TEXT("Lucida Console"),
+ sizeof (TEXT("Lucida Console")));
+ if (out_raster)
+ func_SetCurrentConsoleFontEx (out_handle, FALSE,
+ &new_console_font_info);
+ if (err_raster)
+ func_SetCurrentConsoleFontEx (err_handle, FALSE,
+ &new_console_font_info);
+ return;
+ }
+
+ /* Fallback for older versions. */
+ func_SetConsoleFont = (void *) GetProcAddress (kernel32, "SetConsoleFont");
+ if (func_SetConsoleFont)
+ {
+ if (out_raster)
+ func_SetConsoleFont (out_handle, 12);
+ if (err_raster)
+ func_SetConsoleFont (err_handle, 12);
+ }
+}
+
+static char *grub_util_base_directory;
+static char *locale_dir;
+
+const char *
+grub_util_get_config_filename (void)
+{
+ static char *value = NULL;
+ if (!value)
+ value = grub_util_path_concat (2, grub_util_base_directory, "grub.cfg");
+ return value;
+}
+
+const char *
+grub_util_get_pkgdatadir (void)
+{
+ return grub_util_base_directory;
+}
+
+const char *
+grub_util_get_localedir (void)
+{
+ return locale_dir;
+}
+
+const char *
+grub_util_get_pkglibdir (void)
+{
+ return grub_util_base_directory;
+}
+
+void
+grub_util_host_init (int *argc __attribute__ ((unused)),
+ char ***argv)
+{
+ char *ptr;
+
+ SetConsoleOutputCP (CP_UTF8);
+ SetConsoleCP (CP_UTF8);
+
+ set_console_unicode_font ();
+
+#if SIZEOF_TCHAR == 1
+
+#elif SIZEOF_TCHAR == 2
+ LPWSTR tcmdline = GetCommandLineW ();
+ int i;
+ LPWSTR *targv;
+
+ targv = CommandLineToArgvW (tcmdline, argc);
+ *argv = xcalloc (*argc + 1, sizeof (argv[0]));
+
+ for (i = 0; i < *argc; i++)
+ (*argv)[i] = grub_util_tchar_to_utf8 (targv[i]);
+ (*argv)[i] = NULL;
+#else
+#error "Unsupported TCHAR size"
+#endif
+
+ 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;
+ ptr >= grub_util_base_directory && *ptr != '/' && *ptr != '\\'; ptr--);
+ if (ptr >= grub_util_base_directory)
+ *ptr = '\0';
+
+ locale_dir = grub_util_path_concat (2, grub_util_base_directory, "locale");
+
+ set_program_name ((*argv)[0]);
+
+#if (defined (GRUB_UTIL) && defined(ENABLE_NLS) && ENABLE_NLS)
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, locale_dir);
+ textdomain (PACKAGE);
+#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
+}
diff --git a/grub-core/osdep/windows/password.c b/grub-core/osdep/windows/password.c
new file mode 100644
index 0000000..1d3af0c
--- /dev/null
+++ b/grub-core/osdep/windows/password.c
@@ -0,0 +1,51 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
+ * 2007, 2008, 2009, 2010, 2011, 2012, 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/crypto.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+
+#include <windows.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+int
+grub_password_get (char buf[], unsigned buf_size)
+{
+ HANDLE hStdin = GetStdHandle (STD_INPUT_HANDLE);
+ DWORD mode = 0;
+ char *ptr;
+
+ grub_refresh ();
+
+ GetConsoleMode (hStdin, &mode);
+ SetConsoleMode (hStdin, mode & (~ENABLE_ECHO_INPUT));
+
+ fgets (buf, buf_size, stdin);
+ ptr = buf + strlen (buf) - 1;
+ while (buf <= ptr && (*ptr == '\n' || *ptr == '\r'))
+ *ptr-- = 0;
+
+ SetConsoleMode (hStdin, mode);
+
+ grub_refresh ();
+
+ return 1;
+}
diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c
new file mode 100644
index 0000000..253f8d1
--- /dev/null
+++ b/grub-core/osdep/windows/platform.c
@@ -0,0 +1,426 @@
+/*
+ * 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 <config-util.h>
+
+#include <windows.h>
+#include <grub/util/install.h>
+#include <grub/util/misc.h>
+#include <grub/efi/api.h>
+#include <grub/charset.h>
+#include <grub/gpt_partition.h>
+
+#define GRUB_EFI_GLOBAL_VARIABLE_GUID_WINDOWS_STR L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}"
+
+static enum { PLAT_UNK, PLAT_BIOS, PLAT_EFI } platform;
+static DWORD (WINAPI * func_GetFirmwareEnvironmentVariableW) (LPCWSTR lpName,
+ LPCWSTR lpGuid,
+ PVOID pBuffer,
+ DWORD nSize);
+static BOOL (WINAPI * func_SetFirmwareEnvironmentVariableW) (LPCWSTR lpName,
+ LPCWSTR lpGuid,
+ PVOID pBuffer,
+ DWORD nSize);
+static void (WINAPI * func_GetNativeSystemInfo) (LPSYSTEM_INFO lpSystemInfo);
+
+static int
+get_efi_privilegies (void)
+{
+ int ret = 1;
+ HANDLE hSelf;
+ TOKEN_PRIVILEGES tkp;
+
+ if (!OpenProcessToken (GetCurrentProcess(),
+ TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hSelf))
+ return 0;
+
+ LookupPrivilegeValue (NULL, SE_SYSTEM_ENVIRONMENT_NAME,
+ &tkp.Privileges[0].Luid);
+ tkp.PrivilegeCount = 1;
+ tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+ if (!AdjustTokenPrivileges (hSelf, FALSE, &tkp, 0, NULL, 0))
+ ret = 0;
+ if (GetLastError () != ERROR_SUCCESS)
+ ret = 0;
+ CloseHandle (hSelf);
+ return 1;
+}
+
+static void
+get_platform (void)
+{
+ HMODULE kernel32;
+ char buffer[256];
+
+ if (platform != PLAT_UNK)
+ return;
+
+ kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
+ if (!kernel32)
+ {
+ platform = PLAT_BIOS;
+ return;
+ }
+
+ func_GetFirmwareEnvironmentVariableW = (void *)
+ GetProcAddress (kernel32, "GetFirmwareEnvironmentVariableW");
+ func_SetFirmwareEnvironmentVariableW = (void *)
+ GetProcAddress (kernel32, "SetFirmwareEnvironmentVariableW");
+ func_GetNativeSystemInfo = (void *)
+ GetProcAddress (kernel32, "GetNativeSystemInfo");
+ if (!func_GetNativeSystemInfo)
+ func_GetNativeSystemInfo = GetSystemInfo;
+ if (!func_GetFirmwareEnvironmentVariableW
+ || !func_SetFirmwareEnvironmentVariableW)
+ {
+ platform = PLAT_BIOS;
+ return;
+ }
+
+ if (!get_efi_privilegies ())
+ {
+ 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)
+ {
+ platform = PLAT_BIOS;
+ return;
+ }
+ platform = PLAT_EFI;
+ return;
+}
+
+const char *
+grub_install_get_default_x86_platform (void)
+{
+ SYSTEM_INFO si;
+
+ get_platform ();
+ if (platform != PLAT_EFI)
+ return "i386-pc";
+
+ /* EFI */
+ /* Assume 64-bit in case of failure. */
+ si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64;
+ func_GetNativeSystemInfo (&si);
+ if (si.wProcessorArchitecture != PROCESSOR_ARCHITECTURE_INTEL)
+ return "x86_64-efi";
+ else
+ return "i386-efi";
+}
+
+static void *
+get_efi_variable (const wchar_t *varname, ssize_t *len)
+{
+ void *ret = NULL;
+ size_t alloc_size = 256, read_size;
+ get_platform ();
+ while (1)
+ {
+ DWORD err;
+ ret = xmalloc (alloc_size);
+ read_size = func_GetFirmwareEnvironmentVariableW (varname, GRUB_EFI_GLOBAL_VARIABLE_GUID_WINDOWS_STR,
+ ret, alloc_size);
+ err = GetLastError ();
+ if (read_size)
+ {
+ *len = read_size;
+ return ret;
+ }
+ if (err == ERROR_INSUFFICIENT_BUFFER
+ && alloc_size * 2 != 0)
+ {
+ alloc_size *= 2;
+ free (ret);
+ continue;
+ }
+ if (err == ERROR_ENVVAR_NOT_FOUND)
+ {
+ *len = -1;
+ return NULL;
+ }
+ *len = -2;
+ return NULL;
+ }
+}
+
+static void
+set_efi_variable (const wchar_t *varname, void *in, grub_size_t len)
+{
+ get_platform ();
+ func_SetFirmwareEnvironmentVariableW (varname, GRUB_EFI_GLOBAL_VARIABLE_GUID_WINDOWS_STR,
+ in, len);
+}
+
+static char
+bin2hex (int v)
+{
+ if (v < 10)
+ return '0' + v;
+ return 'A' + v - 10;
+}
+
+static void *
+get_efi_variable_bootn (grub_uint16_t n, ssize_t *len)
+{
+ wchar_t varname[20] = L"Boot0000";
+ varname[7] = bin2hex (n & 0xf);
+ varname[6] = bin2hex ((n >> 4) & 0xf);
+ varname[5] = bin2hex ((n >> 8) & 0xf);
+ varname[4] = bin2hex ((n >> 12) & 0xf);
+ return get_efi_variable (varname, len);
+}
+
+static void
+set_efi_variable_bootn (grub_uint16_t n, void *in, grub_size_t len)
+{
+ wchar_t varname[20] = L"Boot0000";
+ varname[7] = bin2hex (n & 0xf);
+ varname[6] = bin2hex ((n >> 4) & 0xf);
+ varname[5] = bin2hex ((n >> 8) & 0xf);
+ varname[4] = bin2hex ((n >> 12) & 0xf);
+ set_efi_variable (varname, in, len);
+}
+
+int
+grub_install_register_efi (grub_device_t efidir_grub_dev,
+ const char *efifile_path,
+ const char *efi_distributor)
+{
+ grub_uint16_t *boot_order, *new_boot_order;
+ grub_uint16_t *distributor16;
+ grub_uint8_t *entry;
+ grub_size_t distrib8_len, distrib16_len, path16_len, path8_len;
+ ssize_t boot_order_len, new_boot_order_len;
+ grub_uint16_t order_num = 0;
+ int have_order_num = 0;
+ grub_size_t max_path_length;
+ grub_uint8_t *path;
+ void *pathptr;
+ struct grub_efi_hard_drive_device_path *hddp;
+ struct grub_efi_file_path_device_path *filep;
+ struct grub_efi_device_path *endp;
+
+ get_platform ();
+ if (platform != PLAT_EFI)
+ grub_util_error ("%s", _("no EFI routines are available when running in BIOS mode"));
+
+ distrib8_len = grub_strlen (efi_distributor);
+ distributor16 = xcalloc (distrib8_len + 1,
+ GRUB_MAX_UTF16_PER_UTF8 * sizeof (grub_uint16_t));
+ distrib16_len = grub_utf8_to_utf16 (distributor16, distrib8_len * GRUB_MAX_UTF16_PER_UTF8,
+ (const grub_uint8_t *) efi_distributor,
+ distrib8_len, 0);
+ distributor16[distrib16_len] = 0;
+
+ /* Windows doesn't allow to list variables so first look for bootorder to
+ find if there is an entry from the same distributor. If not try sequentially
+ until we find same distributor or empty spot. */
+ boot_order = get_efi_variable (L"BootOrder", &boot_order_len);
+ if (boot_order_len < -1)
+ grub_util_error ("%s", _("unexpected EFI error"));
+ if (boot_order_len > 0)
+ {
+ size_t i;
+ for (i = 0; i < boot_order_len / 2; i++)
+ {
+ void *current = NULL;
+ ssize_t current_len;
+ current = get_efi_variable_bootn (i, &current_len);
+ if (current_len < 0)
+ continue; /* FIXME Should we abort on error? */
+ if (current_len < (distrib16_len + 1) * sizeof (grub_uint16_t)
+ + 6)
+ {
+ grub_free (current);
+ continue;
+ }
+ if (grub_memcmp ((grub_uint16_t *) current + 3,
+ distributor16,
+ (distrib16_len + 1) * sizeof (grub_uint16_t)) != 0)
+ {
+ grub_free (current);
+ continue;
+ }
+ order_num = i;
+ have_order_num = 1;
+ grub_util_info ("Found matching distributor at Boot%04x",
+ order_num);
+ grub_free (current);
+ break;
+ }
+ }
+ if (!have_order_num)
+ {
+ size_t i;
+ for (i = 0; i < 0x10000; i++)
+ {
+ void *current = NULL;
+ ssize_t current_len;
+ current = get_efi_variable_bootn (i, &current_len);
+ if (current_len < -1)
+ continue; /* FIXME Should we abort on error? */
+ if (current_len == -1)
+ {
+ if (!have_order_num)
+ {
+ order_num = i;
+ have_order_num = 1;
+ grub_util_info ("Creating new entry at Boot%04x",
+ order_num);
+ }
+ continue;
+ }
+ if (current_len < (distrib16_len + 1) * sizeof (grub_uint16_t)
+ + 6)
+ {
+ grub_free (current);
+ continue;
+ }
+ if (grub_memcmp ((grub_uint16_t *) current + 3,
+ distributor16,
+ (distrib16_len + 1) * sizeof (grub_uint16_t)) != 0)
+ {
+ grub_free (current);
+ continue;
+ }
+ order_num = i;
+ have_order_num = 1;
+ grub_util_info ("Found matching distributor at Boot%04x",
+ order_num);
+ grub_free (current);
+ break;
+ }
+ }
+ if (!have_order_num)
+ grub_util_error ("%s", _("Couldn't find a free BootNNNN slot"));
+ path8_len = grub_strlen (efifile_path);
+ max_path_length = sizeof (*hddp) + sizeof (*filep) + (path8_len * GRUB_MAX_UTF16_PER_UTF8 + 1) * sizeof (grub_uint16_t) + sizeof (*endp);
+ entry = xmalloc (6 + (distrib16_len + 1) * sizeof (grub_uint16_t) + max_path_length);
+ /* attributes: active. */
+ entry[0] = 1;
+ entry[1] = 0;
+ entry[2] = 0;
+ entry[3] = 0;
+ grub_memcpy (entry + 6,
+ distributor16,
+ (distrib16_len + 1) * sizeof (grub_uint16_t));
+
+ path = entry + 6 + (distrib16_len + 1) * sizeof (grub_uint16_t);
+ pathptr = path;
+
+ hddp = pathptr;
+ grub_memset (hddp, 0, sizeof (*hddp));
+ hddp->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE;
+ hddp->header.subtype = GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE;
+ hddp->header.length = sizeof (*hddp);
+ hddp->partition_number = efidir_grub_dev->disk->partition ? efidir_grub_dev->disk->partition->number + 1 : 1;
+ if (efidir_grub_dev->disk->partition
+ && grub_strcmp (efidir_grub_dev->disk->partition->partmap->name, "msdos") == 0)
+ {
+ grub_partition_t p;
+
+ p = efidir_grub_dev->disk->partition;
+ efidir_grub_dev->disk->partition = p->parent;
+ if (grub_disk_read (efidir_grub_dev->disk, 0, 440,
+ 4, hddp->partition_signature))
+ grub_util_error ("%s", grub_errmsg);
+ efidir_grub_dev->disk->partition = p;
+
+ hddp->partmap_type = 1;
+ hddp->signature_type = 1;
+ }
+ else if (efidir_grub_dev->disk->partition
+ && grub_strcmp (efidir_grub_dev->disk->partition->partmap->name, "gpt") == 0)
+ {
+ struct grub_gpt_partentry gptdata;
+ grub_partition_t p;
+
+ p = efidir_grub_dev->disk->partition;
+ efidir_grub_dev->disk->partition = p->parent;
+ if (grub_disk_read (efidir_grub_dev->disk,
+ p->offset, p->index,
+ sizeof (gptdata), &gptdata))
+ grub_util_error ("%s", grub_errmsg);
+ efidir_grub_dev->disk->partition = p;
+ grub_memcpy (hddp->partition_signature,
+ &gptdata.guid, 16);
+
+ hddp->partmap_type = 2;
+ hddp->signature_type = 2;
+ }
+
+ hddp->partition_start = grub_partition_get_start (efidir_grub_dev->disk->partition)
+ >> (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
+ hddp->partition_size = grub_disk_native_sectors (efidir_grub_dev->disk)
+ >> (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
+
+ pathptr = hddp + 1;
+ filep = pathptr;
+ filep->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE;
+ filep->header.subtype = GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE;
+
+ path16_len = grub_utf8_to_utf16 (filep->path_name,
+ path8_len * GRUB_MAX_UTF16_PER_UTF8,
+ (const grub_uint8_t *) efifile_path,
+ path8_len, 0);
+ filep->path_name[path16_len] = 0;
+ filep->header.length = sizeof (*filep) + (path16_len + 1) * sizeof (grub_uint16_t);
+ pathptr = &filep->path_name[path16_len + 1];
+ endp = pathptr;
+ endp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
+ endp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ endp->length = sizeof (*endp);
+ pathptr = endp + 1;
+
+ entry[4] = (grub_uint8_t *) pathptr - path;
+ entry[5] = ((grub_uint8_t *) pathptr - path) >> 8;
+
+ new_boot_order = xmalloc ((boot_order_len > 0 ? boot_order_len : 0) + 2);
+ new_boot_order[0] = order_num;
+ new_boot_order_len = 1;
+ {
+ ssize_t i;
+ for (i = 0; i < boot_order_len / 2; i++)
+ if (boot_order[i] != order_num)
+ new_boot_order[new_boot_order_len++] = boot_order[i];
+ }
+
+ set_efi_variable_bootn (order_num, entry, (grub_uint8_t *) pathptr - entry);
+ set_efi_variable (L"BootOrder", new_boot_order, new_boot_order_len * sizeof (grub_uint16_t));
+
+ return 0;
+}
+
+void
+grub_install_register_ieee1275 (int is_prep, const char *install_device,
+ int partno, const char *relpath)
+{
+ grub_util_error ("%s", _("no IEEE1275 routines are available for your platform"));
+}
+
+void
+grub_install_sgi_setup (const char *install_device,
+ const char *imgfile, const char *destname)
+{
+ grub_util_error ("%s", _("no SGI routines are available for your platform"));
+}
diff --git a/grub-core/osdep/windows/random.c b/grub-core/osdep/windows/random.c
new file mode 100644
index 0000000..78f5082
--- /dev/null
+++ b/grub-core/osdep/windows/random.c
@@ -0,0 +1,55 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1992-1999,2001,2003,2004,2005,2009,2010,2011,2012,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 <config.h>
+
+#include <grub/types.h>
+#include <grub/crypto.h>
+#include <grub/auth.h>
+#include <grub/emu/misc.h>
+#include <grub/util/misc.h>
+#include <grub/i18n.h>
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <windows.h>
+#include <wincrypt.h>
+
+int
+grub_get_random (void *out, grub_size_t len)
+{
+ HCRYPTPROV hCryptProv;
+ if (!CryptAcquireContext (&hCryptProv,
+ NULL,
+ MS_DEF_PROV,
+ PROV_RSA_FULL,
+ CRYPT_VERIFYCONTEXT))
+ return 1;
+ if (!CryptGenRandom (hCryptProv, len, out))
+ {
+ CryptReleaseContext (hCryptProv, 0);
+ return 1;
+ }
+
+ CryptReleaseContext (hCryptProv, 0);
+
+ return 0;
+}
diff --git a/grub-core/osdep/windows/relpath.c b/grub-core/osdep/windows/relpath.c
new file mode 100644
index 0000000..478e8ef
--- /dev/null
+++ b/grub-core/osdep/windows/relpath.c
@@ -0,0 +1,96 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <grub/types.h>
+
+#include <grub/util/misc.h>
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/emu/misc.h>
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/getroot.h>
+#include <grub/charset.h>
+#include <grub/util/windows.h>
+#include <windows.h>
+#include <winioctl.h>
+
+static size_t
+tclen (const TCHAR *s)
+{
+ const TCHAR *s0 = s;
+ while (*s)
+ s++;
+ return s - s0;
+}
+
+char *
+grub_make_system_path_relative_to_its_root (const char *path)
+{
+ TCHAR *dirwindows, *mntpointwindows;
+ TCHAR *ptr;
+ size_t offset, flen;
+ TCHAR *ret;
+ char *cret;
+
+ dirwindows = grub_util_get_windows_path (path);
+ if (!dirwindows)
+ return xstrdup (path);
+
+ mntpointwindows = grub_get_mount_point (dirwindows);
+
+ if (!mntpointwindows)
+ {
+ offset = 0;
+ if (dirwindows[0] && dirwindows[1] == ':')
+ offset = 2;
+ }
+ offset = tclen (mntpointwindows);
+ free (mntpointwindows);
+ flen = tclen (dirwindows);
+ if (offset > flen)
+ {
+ offset = 0;
+ if (dirwindows[0] && dirwindows[1] == ':')
+ offset = 2;
+ }
+ ret = xcalloc (flen - offset + 2, sizeof (ret[0]));
+ if (dirwindows[offset] != '\\'
+ && dirwindows[offset] != '/'
+ && dirwindows[offset])
+ {
+ ret[0] = '\\';
+ memcpy (ret + 1, dirwindows + offset, (flen - offset + 1) * sizeof (ret[0]));
+ }
+ else
+ memcpy (ret, dirwindows + offset, (flen - offset + 1) * sizeof (ret[0]));
+
+ free (dirwindows);
+
+ for (ptr = ret; *ptr; ptr++)
+ if (*ptr == '\\')
+ *ptr = '/';
+
+ cret = grub_util_tchar_to_utf8 (ret);
+ free (ret);
+
+ return cret;
+}
diff --git a/grub-core/osdep/windows/sleep.c b/grub-core/osdep/windows/sleep.c
new file mode 100644
index 0000000..03b846b
--- /dev/null
+++ b/grub-core/osdep/windows/sleep.c
@@ -0,0 +1,31 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010,2011,2012,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 <config-util.h>
+#include <config.h>
+
+#include <windows.h>
+#include <winioctl.h>
+#include <grub/time.h>
+
+void
+grub_millisleep (grub_uint32_t ms)
+{
+ Sleep (ms);
+}
+
diff --git a/grub-core/partmap/acorn.c b/grub-core/partmap/acorn.c
new file mode 100644
index 0000000..c022c61
--- /dev/null
+++ b/grub-core/partmap/acorn.c
@@ -0,0 +1,154 @@
+/* acorn.c - Read Linux/ADFS partition tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/partition.h>
+#include <grub/acorn_filecore.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#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
+#define NONADFS_PARTITION_TYPE_MASK 15
+
+struct grub_acorn_boot_block
+{
+ union
+ {
+ struct
+ {
+ grub_uint8_t misc[0x1C0];
+ struct grub_filecore_disc_record disc_record;
+ grub_uint8_t flags;
+ grub_uint16_t start_cylinder;
+ grub_uint8_t checksum;
+ } GRUB_PACKED;
+ grub_uint8_t bin[0x200];
+ };
+} GRUB_PACKED;
+
+struct linux_part
+{
+ grub_uint32_t magic;
+ grub_uint32_t start;
+ grub_uint32_t size;
+};
+
+static struct grub_partition_map grub_acorn_partition_map;
+
+static grub_err_t
+acorn_partition_map_find (grub_disk_t disk, struct linux_part *m,
+ grub_disk_addr_t *sector)
+{
+ struct grub_acorn_boot_block boot;
+ grub_err_t err;
+ unsigned int checksum = 0;
+ unsigned int heads;
+ unsigned int sectors_per_cylinder;
+ int i;
+
+ err = grub_disk_read (disk, 0xC00 / GRUB_DISK_SECTOR_SIZE, 0,
+ sizeof (struct grub_acorn_boot_block),
+ &boot);
+ if (err)
+ return err;
+
+ if ((boot.flags & NONADFS_PARTITION_TYPE_MASK) != NONADFS_PARTITION_TYPE_LINUX)
+ goto fail;
+
+ for (i = 0; i != 0x1ff; ++i)
+ checksum = ((checksum & 0xff) + (checksum >> 8) + boot.bin[i]);
+
+ if ((grub_uint8_t) checksum != boot.checksum)
+ goto fail;
+
+ heads = (boot.disc_record.heads
+ + ((boot.disc_record.lowsector >> 6) & 1));
+ sectors_per_cylinder = boot.disc_record.secspertrack * heads;
+ *sector = grub_le_to_cpu16 (boot.start_cylinder) * sectors_per_cylinder;
+
+ return grub_disk_read (disk, *sector, 0,
+ sizeof (struct linux_part) * LINUX_MAP_ENTRIES,
+ m);
+
+fail:
+ return grub_error (GRUB_ERR_BAD_PART_TABLE,
+ "Linux/ADFS partition map not found");
+
+}
+
+
+static grub_err_t
+acorn_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ struct grub_partition part;
+ struct linux_part map[LINUX_MAP_ENTRIES];
+ int i;
+ grub_disk_addr_t sector = 0;
+ grub_err_t err;
+
+ err = acorn_partition_map_find (disk, map, &sector);
+ if (err)
+ return err;
+
+ part.partmap = &grub_acorn_partition_map;
+
+ for (i = 0; i != LINUX_MAP_ENTRIES; ++i)
+ {
+ if (map[i].magic != LINUX_NATIVE_MAGIC
+ && map[i].magic != LINUX_SWAP_MAGIC)
+ return GRUB_ERR_NONE;
+
+ part.start = sector + map[i].start;
+ part.len = map[i].size;
+ part.offset = 6;
+ part.number = part.index = i;
+
+ if (hook (disk, &part, hook_data))
+ return grub_errno;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+
+
+/* Partition map type. */
+static struct grub_partition_map grub_acorn_partition_map =
+{
+ .name = "acorn",
+ .iterate = acorn_partition_map_iterate,
+};
+
+GRUB_MOD_INIT(part_acorn)
+{
+ grub_partition_map_register (&grub_acorn_partition_map);
+}
+
+GRUB_MOD_FINI(part_acorn)
+{
+ grub_partition_map_unregister (&grub_acorn_partition_map);
+}
diff --git a/grub-core/partmap/amiga.c b/grub-core/partmap/amiga.c
new file mode 100644
index 0000000..13034f1
--- /dev/null
+++ b/grub-core/partmap/amiga.c
@@ -0,0 +1,183 @@
+/* amiga.c - Read amiga partition tables (RDB). */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2005,2006,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/partition.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define AMIGA_CHECKSUM_WORDS 128
+
+struct grub_amiga_rdsk
+{
+ /* "RDSK". */
+ grub_uint8_t magic[4];
+#define GRUB_AMIGA_RDSK_MAGIC "RDSK"
+ grub_uint32_t size;
+ grub_int32_t checksum;
+ grub_uint32_t scsihost;
+ grub_uint32_t blksz;
+ grub_uint32_t flags;
+ grub_uint32_t badblcklst;
+ grub_uint32_t partitionlst;
+ grub_uint32_t fslst;
+
+ grub_uint32_t unused[AMIGA_CHECKSUM_WORDS - 9];
+} GRUB_PACKED;
+
+struct grub_amiga_partition
+{
+ /* "PART". */
+ grub_uint8_t magic[4];
+#define GRUB_AMIGA_PART_MAGIC "PART"
+ grub_uint32_t size;
+ grub_int32_t checksum;
+ grub_uint32_t scsihost;
+ grub_uint32_t next;
+ grub_uint32_t flags;
+ grub_uint32_t unused1[2];
+ grub_uint32_t devflags;
+ grub_uint8_t namelen;
+ grub_uint8_t name[31];
+ grub_uint32_t unused2[15];
+
+ grub_uint32_t unused3[3];
+ grub_uint32_t heads;
+ grub_uint32_t unused4;
+ grub_uint32_t block_per_track;
+ grub_uint32_t unused5[3];
+ grub_uint32_t lowcyl;
+ grub_uint32_t highcyl;
+
+ grub_uint32_t firstcyl;
+ grub_uint32_t unused[AMIGA_CHECKSUM_WORDS - 44];
+} GRUB_PACKED;
+
+static struct grub_partition_map grub_amiga_partition_map;
+
+
+
+static grub_uint32_t
+amiga_partition_map_checksum (void *buf)
+{
+ grub_uint32_t *ptr = buf;
+ grub_uint32_t r = 0;
+ grub_size_t sz;
+ /* Fancy and quick way of checking sz >= 512 / 4 = 128. */
+ if (ptr[1] & ~grub_cpu_to_be32_compile_time (AMIGA_CHECKSUM_WORDS - 1))
+ sz = AMIGA_CHECKSUM_WORDS;
+ else
+ sz = grub_be_to_cpu32 (ptr[1]);
+
+ for (; sz; sz--, ptr++)
+ r += grub_be_to_cpu32 (*ptr);
+
+ return r;
+}
+
+static grub_err_t
+amiga_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ struct grub_partition part;
+ struct grub_amiga_rdsk rdsk;
+ int partno = 0;
+ int next = -1;
+ unsigned pos;
+
+ /* The RDSK block is one of the first 15 blocks. */
+ for (pos = 0; pos < 15; pos++)
+ {
+ /* Read the RDSK block which is a descriptor for the entire disk. */
+ if (grub_disk_read (disk, pos, 0, sizeof (rdsk), &rdsk))
+ return grub_errno;
+
+ if (grub_memcmp (rdsk.magic, GRUB_AMIGA_RDSK_MAGIC,
+ sizeof (rdsk.magic)) == 0
+ && amiga_partition_map_checksum (&rdsk) == 0)
+ {
+ /* Found the first PART block. */
+ next = grub_be_to_cpu32 (rdsk.partitionlst);
+ break;
+ }
+ }
+
+ if (next == -1)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE,
+ "Amiga partition map not found");
+
+ /* The end of the partition list is marked using "-1". */
+ while (next != -1)
+ {
+ struct grub_amiga_partition apart;
+
+ /* Read the RDSK block which is a descriptor for the entire disk. */
+ if (grub_disk_read (disk, next, 0, sizeof (apart), &apart))
+ return grub_errno;
+
+ if (grub_memcmp (apart.magic, GRUB_AMIGA_PART_MAGIC,
+ sizeof (apart.magic)) != 0
+ || amiga_partition_map_checksum (&apart) != 0)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE,
+ "invalid Amiga partition map");
+ /* Calculate the first block and the size of the partition. */
+ part.start = (grub_be_to_cpu32 (apart.lowcyl)
+ * grub_be_to_cpu32 (apart.heads)
+ * grub_be_to_cpu32 (apart.block_per_track));
+ part.len = ((grub_be_to_cpu32 (apart.highcyl)
+ - grub_be_to_cpu32 (apart.lowcyl) + 1)
+ * grub_be_to_cpu32 (apart.heads)
+ * grub_be_to_cpu32 (apart.block_per_track));
+
+ part.offset = next;
+ part.number = partno;
+ part.index = 0;
+ part.partmap = &grub_amiga_partition_map;
+
+ if (hook (disk, &part, hook_data))
+ return grub_errno;
+
+ next = grub_be_to_cpu32 (apart.next);
+ partno++;
+ }
+
+ return 0;
+}
+
+
+/* Partition map type. */
+static struct grub_partition_map grub_amiga_partition_map =
+ {
+ .name = "amiga",
+ .iterate = amiga_partition_map_iterate,
+ };
+
+GRUB_MOD_INIT(part_amiga)
+{
+ grub_partition_map_register (&grub_amiga_partition_map);
+}
+
+GRUB_MOD_FINI(part_amiga)
+{
+ grub_partition_map_unregister (&grub_amiga_partition_map);
+}
diff --git a/grub-core/partmap/apple.c b/grub-core/partmap/apple.c
new file mode 100644
index 0000000..c3ead0f
--- /dev/null
+++ b/grub-core/partmap/apple.c
@@ -0,0 +1,199 @@
+/* apple.c - Read macintosh partition tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/partition.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_APPLE_HEADER_MAGIC 0x4552
+#define GRUB_APPLE_PART_MAGIC 0x504D
+
+struct grub_apple_header
+{
+ /* The magic number to identify the partition map, it should have
+ the value `0x4552'. */
+ grub_uint16_t magic;
+ grub_uint16_t blocksize;
+};
+
+struct grub_apple_part
+{
+ /* The magic number to identify this as a partition, it should have
+ the value `0x504D'. */
+ grub_uint16_t magic;
+
+ /* Reserved. */
+ grub_uint16_t reserved;
+
+ /* The size of the partition map in blocks. */
+ grub_uint32_t partmap_size;
+
+ /* The first physical block of the partition. */
+ grub_uint32_t first_phys_block;
+
+ /* The amount of blocks. */
+ grub_uint32_t blockcnt;
+
+ /* The partition name. */
+ char partname[32];
+
+ /* The partition type. */
+ char parttype[32];
+
+ /* The first datablock of the partition. */
+ grub_uint32_t datablocks_first;
+
+ /* The amount datablocks. */
+ grub_uint32_t datablocks_count;
+
+ /* The status of the partition. (???) */
+ grub_uint32_t status;
+
+ /* The first block on which the bootcode can be found. */
+ grub_uint32_t bootcode_pos;
+
+ /* The size of the bootcode in bytes. */
+ grub_uint32_t bootcode_size;
+
+ /* The load address of the bootcode. */
+ grub_uint32_t bootcode_loadaddr;
+
+ /* Reserved. */
+ grub_uint32_t reserved2;
+
+ /* The entry point of the bootcode. */
+ grub_uint32_t bootcode_entrypoint;
+
+ /* Reserved. */
+ grub_uint32_t reserved3;
+
+ /* A checksum of the bootcode. */
+ grub_uint32_t bootcode_checksum;
+
+ /* The processor type. */
+ char processor[16];
+
+ /* Padding. */
+ grub_uint16_t pad[187];
+};
+
+static struct grub_partition_map grub_apple_partition_map;
+
+
+static grub_err_t
+apple_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ struct grub_partition part;
+ struct grub_apple_header aheader;
+ struct grub_apple_part apart;
+ int partno = 0, partnum = 0;
+ unsigned pos;
+
+ part.partmap = &grub_apple_partition_map;
+
+ if (grub_disk_read (disk, 0, 0, sizeof (aheader), &aheader))
+ return grub_errno;
+
+ if (grub_be_to_cpu16 (aheader.magic) != GRUB_APPLE_HEADER_MAGIC)
+ {
+ grub_dprintf ("partition",
+ "bad magic (found 0x%x; wanted 0x%x)\n",
+ grub_be_to_cpu16 (aheader.magic),
+ GRUB_APPLE_HEADER_MAGIC);
+ goto fail;
+ }
+
+ pos = grub_be_to_cpu16 (aheader.blocksize);
+
+ do
+ {
+ part.offset = pos / GRUB_DISK_SECTOR_SIZE;
+ part.index = pos % GRUB_DISK_SECTOR_SIZE;
+
+ if (grub_disk_read (disk, part.offset, part.index,
+ sizeof (struct grub_apple_part), &apart))
+ return grub_errno;
+
+ if (grub_be_to_cpu16 (apart.magic) != GRUB_APPLE_PART_MAGIC)
+ {
+ grub_dprintf ("partition",
+ "partition %d: bad magic (found 0x%x; wanted 0x%x)\n",
+ partno, grub_be_to_cpu16 (apart.magic),
+ GRUB_APPLE_PART_MAGIC);
+ break;
+ }
+
+ if (partnum == 0)
+ partnum = grub_be_to_cpu32 (apart.partmap_size);
+
+ part.start = ((grub_disk_addr_t) grub_be_to_cpu32 (apart.first_phys_block)
+ * grub_be_to_cpu16 (aheader.blocksize))
+ / GRUB_DISK_SECTOR_SIZE;
+ part.len = ((grub_disk_addr_t) grub_be_to_cpu32 (apart.blockcnt)
+ * grub_be_to_cpu16 (aheader.blocksize))
+ / GRUB_DISK_SECTOR_SIZE;
+ part.offset = pos;
+ part.index = partno;
+ part.number = partno;
+
+ grub_dprintf ("partition",
+ "partition %d: name %s, type %s, start 0x%x, len 0x%x\n",
+ partno, apart.partname, apart.parttype,
+ grub_be_to_cpu32 (apart.first_phys_block),
+ grub_be_to_cpu32 (apart.blockcnt));
+
+ if (hook (disk, &part, hook_data))
+ return grub_errno;
+
+ pos += grub_be_to_cpu16 (aheader.blocksize);
+ partno++;
+ }
+ while (partno < partnum);
+
+ if (partno != 0)
+ return 0;
+
+ fail:
+ return grub_error (GRUB_ERR_BAD_PART_TABLE,
+ "Apple partition map not found");
+}
+
+
+/* Partition map type. */
+static struct grub_partition_map grub_apple_partition_map =
+ {
+ .name = "apple",
+ .iterate = apple_partition_map_iterate,
+ };
+
+GRUB_MOD_INIT(part_apple)
+{
+ grub_partition_map_register (&grub_apple_partition_map);
+}
+
+GRUB_MOD_FINI(part_apple)
+{
+ grub_partition_map_unregister (&grub_apple_partition_map);
+}
+
diff --git a/grub-core/partmap/bsdlabel.c b/grub-core/partmap/bsdlabel.c
new file mode 100644
index 0000000..1d78590
--- /dev/null
+++ b/grub-core/partmap/bsdlabel.c
@@ -0,0 +1,271 @@
+/* bsdlabel.c - Read BSD style partition tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/partition.h>
+#include <grub/bsdlabel.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/msdos_partition.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#ifdef GRUB_UTIL
+#include <grub/emu/misc.h>
+#endif
+
+static struct grub_partition_map grub_bsdlabel_partition_map;
+static struct grub_partition_map grub_netbsdlabel_partition_map;
+static struct grub_partition_map grub_openbsdlabel_partition_map;
+
+
+
+static grub_err_t
+iterate_real (grub_disk_t disk, grub_disk_addr_t sector, int freebsd,
+ struct grub_partition_map *pmap,
+ grub_partition_iterate_hook_t hook, void *hook_data)
+{
+ struct grub_partition_bsd_disk_label label;
+ struct grub_partition p;
+ grub_disk_addr_t delta = 0;
+ grub_disk_addr_t pos;
+
+ /* Read the BSD label. */
+ if (grub_disk_read (disk, sector, 0, sizeof (label), &label))
+ return grub_errno;
+
+ /* Check if it is valid. */
+ 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. */
+ if (GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION
+ < grub_cpu_to_le16 (label.num_partitions) && freebsd)
+ {
+ struct grub_partition_bsd_entry whole_disk_be;
+
+ pos = sizeof (label) + sector * GRUB_DISK_SECTOR_SIZE
+ + sizeof (struct grub_partition_bsd_entry)
+ * GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION;
+
+ if (grub_disk_read (disk, pos / GRUB_DISK_SECTOR_SIZE,
+ pos % GRUB_DISK_SECTOR_SIZE, sizeof (whole_disk_be),
+ &whole_disk_be))
+ return grub_errno;
+
+ delta = grub_le_to_cpu32 (whole_disk_be.offset);
+ }
+
+ pos = sizeof (label) + sector * GRUB_DISK_SECTOR_SIZE;
+
+ for (p.number = 0;
+ p.number < grub_cpu_to_le16 (label.num_partitions);
+ p.number++, pos += sizeof (struct grub_partition_bsd_entry))
+ {
+ struct grub_partition_bsd_entry be;
+
+ if (p.number == GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION)
+ continue;
+
+ p.offset = pos / GRUB_DISK_SECTOR_SIZE;
+ p.index = pos % GRUB_DISK_SECTOR_SIZE;
+
+ if (grub_disk_read (disk, p.offset, p.index, sizeof (be), &be))
+ return grub_errno;
+
+ p.start = grub_le_to_cpu32 (be.offset);
+ p.len = grub_le_to_cpu32 (be.size);
+ p.partmap = pmap;
+
+ if (p.len == 0)
+ continue;
+
+ if (p.start < delta)
+ {
+#ifdef GRUB_UTIL
+ char *partname;
+ /* disk->partition != NULL as 0 < delta */
+ partname = disk->partition ? grub_partition_get_name (disk->partition)
+ : 0;
+ grub_util_warn (_("Discarding improperly nested partition (%s,%s,%s%d)"),
+ disk->name, partname ? : "", p.partmap->name,
+ p.number + 1);
+ grub_free (partname);
+#endif
+ continue;
+ }
+
+ p.start -= delta;
+
+ if (hook (disk, &p, hook_data))
+ return grub_errno;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+bsdlabel_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+
+ if (disk->partition && grub_strcmp (disk->partition->partmap->name, "msdos")
+ == 0 && disk->partition->msdostype == GRUB_PC_PARTITION_TYPE_FREEBSD)
+ return iterate_real (disk, GRUB_PC_PARTITION_BSD_LABEL_SECTOR, 1,
+ &grub_bsdlabel_partition_map, hook, hook_data);
+
+ if (disk->partition
+ && (grub_strcmp (disk->partition->partmap->name, "msdos") == 0
+ || disk->partition->partmap == &grub_bsdlabel_partition_map
+ || disk->partition->partmap == &grub_netbsdlabel_partition_map
+ || disk->partition->partmap == &grub_openbsdlabel_partition_map))
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "no embedding supported");
+
+ return iterate_real (disk, GRUB_PC_PARTITION_BSD_LABEL_SECTOR, 0,
+ &grub_bsdlabel_partition_map, hook, hook_data);
+}
+
+/* Context for netopenbsdlabel_partition_map_iterate. */
+struct netopenbsdlabel_ctx
+{
+ grub_uint8_t type;
+ struct grub_partition_map *pmap;
+ grub_partition_iterate_hook_t hook;
+ void *hook_data;
+ int count;
+};
+
+/* Helper for netopenbsdlabel_partition_map_iterate. */
+static int
+check_msdos (grub_disk_t dsk, const grub_partition_t partition, void *data)
+{
+ struct netopenbsdlabel_ctx *ctx = data;
+ grub_err_t err;
+
+ if (partition->msdostype != ctx->type)
+ return 0;
+
+ err = iterate_real (dsk, partition->start
+ + GRUB_PC_PARTITION_BSD_LABEL_SECTOR, 0, ctx->pmap,
+ ctx->hook, ctx->hook_data);
+ if (err == GRUB_ERR_NONE)
+ {
+ ctx->count++;
+ return 1;
+ }
+ if (err == GRUB_ERR_BAD_PART_TABLE)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return 0;
+ }
+ grub_print_error ();
+ return 0;
+}
+
+/* This is a total breakage. Even when net-/openbsd label is inside partition
+ it actually describes the whole disk.
+ */
+static grub_err_t
+netopenbsdlabel_partition_map_iterate (grub_disk_t disk, grub_uint8_t type,
+ struct grub_partition_map *pmap,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ if (disk->partition && grub_strcmp (disk->partition->partmap->name, "msdos")
+ == 0)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "no embedding supported");
+
+ {
+ struct netopenbsdlabel_ctx ctx = {
+ .type = type,
+ .pmap = pmap,
+ .hook = hook,
+ .hook_data = hook_data,
+ .count = 0
+ };
+ grub_err_t err;
+
+ err = grub_partition_msdos_iterate (disk, check_msdos, &ctx);
+
+ if (err)
+ return err;
+ if (!ctx.count)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "no bsdlabel found");
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+netbsdlabel_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ return netopenbsdlabel_partition_map_iterate (disk,
+ GRUB_PC_PARTITION_TYPE_NETBSD,
+ &grub_netbsdlabel_partition_map,
+ hook, hook_data);
+}
+
+static grub_err_t
+openbsdlabel_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ return netopenbsdlabel_partition_map_iterate (disk,
+ GRUB_PC_PARTITION_TYPE_OPENBSD,
+ &grub_openbsdlabel_partition_map,
+ hook, hook_data);
+}
+
+
+static struct grub_partition_map grub_bsdlabel_partition_map =
+ {
+ .name = "bsd",
+ .iterate = bsdlabel_partition_map_iterate,
+ };
+
+static struct grub_partition_map grub_openbsdlabel_partition_map =
+ {
+ .name = "openbsd",
+ .iterate = openbsdlabel_partition_map_iterate,
+ };
+
+static struct grub_partition_map grub_netbsdlabel_partition_map =
+ {
+ .name = "netbsd",
+ .iterate = netbsdlabel_partition_map_iterate,
+ };
+
+
+
+GRUB_MOD_INIT(part_bsd)
+{
+ grub_partition_map_register (&grub_bsdlabel_partition_map);
+ grub_partition_map_register (&grub_netbsdlabel_partition_map);
+ grub_partition_map_register (&grub_openbsdlabel_partition_map);
+}
+
+GRUB_MOD_FINI(part_bsd)
+{
+ grub_partition_map_unregister (&grub_bsdlabel_partition_map);
+ grub_partition_map_unregister (&grub_netbsdlabel_partition_map);
+ grub_partition_map_unregister (&grub_openbsdlabel_partition_map);
+}
diff --git a/grub-core/partmap/dfly.c b/grub-core/partmap/dfly.c
new file mode 100644
index 0000000..d30da86
--- /dev/null
+++ b/grub-core/partmap/dfly.c
@@ -0,0 +1,132 @@
+/* dfly.c - Read DragonFly BSD disklabel64. */
+/*
+ * 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/disk.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/partition.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct grub_partition_map grub_dfly_partition_map;
+
+#define GRUB_PARTITION_DISKLABEL64_HEADER_SIZE 200
+
+/* Full entry is 64 bytes however we really care only
+ about offset and size which are in first 16 bytes.
+ Avoid using too much stack. */
+#define GRUB_PARTITION_DISKLABEL64_ENTRY_SIZE 64
+struct grub_partition_disklabel64_entry
+{
+ grub_uint64_t boffset;
+ grub_uint64_t bsize;
+};
+
+/* Full entry is 200 bytes however we really care only
+ about magic and number of partitions which are in first 16 bytes.
+ Avoid using too much stack. */
+struct grub_partition_disklabel64
+{
+ grub_uint32_t magic;
+#define GRUB_DISKLABEL64_MAGIC ((grub_uint32_t)0xc4464c59)
+ grub_uint32_t crc;
+ grub_uint32_t unused;
+ grub_uint32_t npartitions;
+};
+
+static grub_err_t
+dfly_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ struct grub_partition part;
+ unsigned partno, pos;
+ struct grub_partition_disklabel64 label;
+
+ part.partmap = &grub_dfly_partition_map;
+
+ if (grub_disk_read (disk, 1, 0, sizeof (label), &label))
+ return grub_errno;
+
+ if (label.magic != grub_cpu_to_le32_compile_time (GRUB_DISKLABEL64_MAGIC))
+ {
+ grub_dprintf ("partition",
+ "bad magic (found 0x%x; wanted 0x%x)\n",
+ (unsigned int) grub_le_to_cpu32 (label.magic),
+ (unsigned int) GRUB_DISKLABEL64_MAGIC);
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "disklabel64 not found");
+ }
+
+ pos = GRUB_PARTITION_DISKLABEL64_HEADER_SIZE + GRUB_DISK_SECTOR_SIZE;
+
+ for (partno = 0;
+ partno < grub_le_to_cpu32 (label.npartitions); ++partno)
+ {
+ grub_disk_addr_t sector = pos >> GRUB_DISK_SECTOR_BITS;
+ grub_off_t offset = pos & (GRUB_DISK_SECTOR_SIZE - 1);
+ struct grub_partition_disklabel64_entry dpart;
+
+ pos += GRUB_PARTITION_DISKLABEL64_ENTRY_SIZE;
+ if (grub_disk_read (disk, sector, offset, sizeof (dpart), &dpart))
+ return grub_errno;
+
+ grub_dprintf ("partition",
+ "partition %2d: offset 0x%llx, "
+ "size 0x%llx\n",
+ partno,
+ (unsigned long long) grub_le_to_cpu64 (dpart.boffset),
+ (unsigned long long) grub_le_to_cpu64 (dpart.bsize));
+
+ /* Is partition initialized? */
+ if (dpart.bsize == 0)
+ continue;
+
+ part.number = partno;
+ part.start = grub_le_to_cpu64 (dpart.boffset) >> GRUB_DISK_SECTOR_BITS;
+ part.len = grub_le_to_cpu64 (dpart.bsize) >> GRUB_DISK_SECTOR_BITS;
+
+ /* This is counter-intuitive, but part.offset and sector have
+ * the same type, and offset (NOT part.offset) is guaranteed
+ * to fit into part.index. */
+ part.offset = sector;
+ part.index = offset;
+
+ if (hook (disk, &part, hook_data))
+ return grub_errno;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+/* Partition map type. */
+static struct grub_partition_map grub_dfly_partition_map =
+{
+ .name = "dfly",
+ .iterate = dfly_partition_map_iterate,
+};
+
+GRUB_MOD_INIT(part_dfly)
+{
+ grub_partition_map_register (&grub_dfly_partition_map);
+}
+
+GRUB_MOD_FINI(part_dfly)
+{
+ grub_partition_map_unregister (&grub_dfly_partition_map);
+}
diff --git a/grub-core/partmap/dvh.c b/grub-core/partmap/dvh.c
new file mode 100644
index 0000000..95c9618
--- /dev/null
+++ b/grub-core/partmap/dvh.c
@@ -0,0 +1,127 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2006,2007,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/partition.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/err.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define DVH_MAGIC 0x0be5a941
+
+struct grub_dvh_partition_descriptor
+{
+ grub_uint32_t length;
+ grub_uint32_t start;
+ grub_uint32_t type;
+} GRUB_PACKED;
+
+struct grub_dvh_block
+{
+ grub_uint32_t magic;
+ grub_uint8_t unused[308];
+ struct grub_dvh_partition_descriptor parts[16];
+ grub_uint32_t checksum;
+ grub_uint32_t unused2;
+} GRUB_PACKED;
+
+static struct grub_partition_map grub_dvh_partition_map;
+
+/* Verify checksum (true=ok). */
+static int
+grub_dvh_is_valid (grub_uint32_t *label)
+{
+ grub_uint32_t *pos;
+ grub_uint32_t sum = 0;
+
+ for (pos = label;
+ pos < (label + sizeof (struct grub_dvh_block) / 4);
+ pos++)
+ sum += grub_be_to_cpu32 (*pos);
+
+ return ! sum;
+}
+
+static grub_err_t
+dvh_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook, void *hook_data)
+{
+ struct grub_partition p;
+ union
+ {
+ struct grub_dvh_block dvh;
+ grub_uint32_t raw[0];
+ } block;
+ unsigned partnum;
+ grub_err_t err;
+
+ p.partmap = &grub_dvh_partition_map;
+ err = grub_disk_read (disk, 0, 0, sizeof (struct grub_dvh_block),
+ &block);
+ if (err)
+ return err;
+
+ if (DVH_MAGIC != grub_be_to_cpu32 (block.dvh.magic))
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "not a dvh partition table");
+
+ if (! grub_dvh_is_valid (block.raw))
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
+
+ /* Maybe another error value would be better, because partition
+ table _is_ recognized but invalid. */
+ for (partnum = 0; partnum < ARRAY_SIZE (block.dvh.parts); partnum++)
+ {
+ if (block.dvh.parts[partnum].length == 0)
+ continue;
+
+ if (partnum == 10)
+ continue;
+
+ p.start = grub_be_to_cpu32 (block.dvh.parts[partnum].start);
+ p.len = grub_be_to_cpu32 (block.dvh.parts[partnum].length);
+ p.number = p.index = partnum;
+ if (hook (disk, &p, hook_data))
+ break;
+ }
+
+ return grub_errno;
+}
+
+
+/* Partition map type. */
+static struct grub_partition_map grub_dvh_partition_map =
+ {
+ .name = "dvh",
+ .iterate = dvh_partition_map_iterate,
+ };
+
+GRUB_MOD_INIT(part_dvh)
+{
+ grub_partition_map_register (&grub_dvh_partition_map);
+}
+
+GRUB_MOD_FINI(part_dvh)
+{
+ grub_partition_map_unregister (&grub_dvh_partition_map);
+}
+
diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c
new file mode 100644
index 0000000..075cc96
--- /dev/null
+++ b/grub-core/partmap/gpt.c
@@ -0,0 +1,238 @@
+/* gpt.c - Read GUID Partition Tables (GPT). */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/partition.h>
+#include <grub/dl.h>
+#include <grub/msdos_partition.h>
+#include <grub/gpt_partition.h>
+#include <grub/i18n.h>
+#ifdef GRUB_UTIL
+#include <grub/emu/misc.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_uint8_t grub_gpt_magic[8] =
+ {
+ 0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
+ };
+
+static const grub_gpt_part_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
+
+#ifdef GRUB_UTIL
+static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
+#endif
+
+/* 512 << 7 = 65536 byte sectors. */
+#define MAX_SECTOR_LOG 7
+
+static struct grub_partition_map grub_gpt_partition_map;
+
+
+
+grub_err_t
+grub_gpt_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ struct grub_partition part;
+ struct grub_gpt_header gpt;
+ struct grub_gpt_partentry entry;
+ struct grub_msdos_partition_mbr mbr;
+ grub_uint64_t entries;
+ unsigned int i;
+ int last_offset = 0;
+ int sector_log = 0;
+
+ /* Read the protective MBR. */
+ if (grub_disk_read (disk, 0, 0, sizeof (mbr), &mbr))
+ return grub_errno;
+
+ /* Check if it is valid. */
+ 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. */
+ for (i = 0; i < 4; i++)
+ if (mbr.entries[i].type == GRUB_PC_PARTITION_TYPE_GPT_DISK)
+ break;
+ if (i == 4)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "no GPT partition map found");
+
+ /* Read the GPT header. */
+ for (sector_log = 0; sector_log < MAX_SECTOR_LOG; sector_log++)
+ {
+ if (grub_disk_read (disk, 1 << sector_log, 0, sizeof (gpt), &gpt))
+ return grub_errno;
+
+ if (grub_memcmp (gpt.magic, grub_gpt_magic, sizeof (grub_gpt_magic)) == 0)
+ break;
+ }
+ if (sector_log == MAX_SECTOR_LOG)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "no valid GPT header");
+
+ grub_dprintf ("gpt", "Read a valid GPT header\n");
+
+ entries = grub_le_to_cpu64 (gpt.partitions) << sector_log;
+ for (i = 0; i < grub_le_to_cpu32 (gpt.maxpart); i++)
+ {
+ if (grub_disk_read (disk, entries, last_offset,
+ sizeof (entry), &entry))
+ return grub_errno;
+
+ if (grub_memcmp (&grub_gpt_partition_type_empty, &entry.type,
+ sizeof (grub_gpt_partition_type_empty)))
+ {
+ /* Calculate the first block and the size of the partition. */
+ part.start = grub_le_to_cpu64 (entry.start) << sector_log;
+ part.len = (grub_le_to_cpu64 (entry.end)
+ - grub_le_to_cpu64 (entry.start) + 1) << sector_log;
+ part.offset = entries;
+ part.number = i;
+ part.index = last_offset;
+ part.partmap = &grub_gpt_partition_map;
+ part.parent = disk->partition;
+
+ grub_dprintf ("gpt", "GPT entry %d: start=%lld, length=%lld\n", i,
+ (unsigned long long) part.start,
+ (unsigned long long) part.len);
+
+ if (hook (disk, &part, hook_data))
+ return grub_errno;
+ }
+
+ last_offset += grub_le_to_cpu32 (gpt.partentry_size);
+ if (last_offset == GRUB_DISK_SECTOR_SIZE)
+ {
+ last_offset = 0;
+ entries++;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+#ifdef GRUB_UTIL
+/* Context for gpt_partition_map_embed. */
+struct gpt_partition_map_embed_ctx
+{
+ grub_disk_addr_t start, len;
+};
+
+/* Helper for gpt_partition_map_embed. */
+static int
+find_usable_region (grub_disk_t disk __attribute__ ((unused)),
+ const grub_partition_t p, void *data)
+{
+ struct gpt_partition_map_embed_ctx *ctx = data;
+ struct grub_gpt_partentry gptdata;
+ grub_partition_t p2;
+
+ p2 = disk->partition;
+ disk->partition = p->parent;
+ if (grub_disk_read (disk, p->offset, p->index,
+ sizeof (gptdata), &gptdata))
+ {
+ disk->partition = p2;
+ return 0;
+ }
+ disk->partition = p2;
+
+ /* If there's an embed region, it is in a dedicated partition. */
+ if (! grub_memcmp (&gptdata.type, &grub_gpt_partition_type_bios_boot, 16))
+ {
+ ctx->start = p->start;
+ ctx->len = p->len;
+ return 1;
+ }
+
+ return 0;
+}
+
+static grub_err_t
+gpt_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
+ unsigned int max_nsectors,
+ grub_embed_type_t embed_type,
+ grub_disk_addr_t **sectors,
+ int warn_short)
+{
+ struct gpt_partition_map_embed_ctx ctx = {
+ .start = 0,
+ .len = 0
+ };
+ unsigned i;
+ grub_err_t err;
+
+ if (embed_type != GRUB_EMBED_PCBIOS)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "GPT currently supports only PC-BIOS embedding");
+
+ err = grub_gpt_partition_map_iterate (disk, find_usable_region, &ctx);
+ if (err)
+ return err;
+
+ if (ctx.len == 0)
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ N_("this GPT partition label contains no BIOS Boot Partition;"
+ " embedding won't be possible"));
+
+ if (ctx.len < GRUB_MIN_RECOMMENDED_MBR_GAP)
+ grub_util_warn ("Your BIOS Boot Partition is under 1 MiB, please increase its size.");
+
+ if (ctx.len < *nsectors)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("your BIOS Boot Partition is too small;"
+ " embedding won't be possible"));
+
+ *nsectors = ctx.len;
+ if (*nsectors > max_nsectors)
+ *nsectors = max_nsectors;
+ *sectors = grub_calloc (*nsectors, sizeof (**sectors));
+ if (!*sectors)
+ return grub_errno;
+ for (i = 0; i < *nsectors; i++)
+ (*sectors)[i] = ctx.start + i;
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+
+/* Partition map type. */
+static struct grub_partition_map grub_gpt_partition_map =
+ {
+ .name = "gpt",
+ .iterate = grub_gpt_partition_map_iterate,
+#ifdef GRUB_UTIL
+ .embed = gpt_partition_map_embed
+#endif
+ };
+
+GRUB_MOD_INIT(part_gpt)
+{
+ grub_partition_map_register (&grub_gpt_partition_map);
+}
+
+GRUB_MOD_FINI(part_gpt)
+{
+ grub_partition_map_unregister (&grub_gpt_partition_map);
+}
diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c
new file mode 100644
index 0000000..58c3626
--- /dev/null
+++ b/grub-core/partmap/msdos.c
@@ -0,0 +1,435 @@
+/* pc.c - Read PC style partition tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/partition.h>
+#include <grub/msdos_partition.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct grub_partition_map grub_msdos_partition_map;
+
+
+#ifdef GRUB_UTIL
+#include <grub/emu/misc.h>
+
+struct embed_signature
+{
+ const char *name;
+ const char *signature;
+ int signature_len;
+ enum { TYPE_SOFTWARE, TYPE_RAID } type;
+};
+
+const char message_warn[][200] = {
+ /* TRANSLATORS: MBR gap and boot track is the same thing and is the space
+ between MBR and first partitition. If your language translates well only
+ "boot track", you can just use it everywhere. Next two messages are about
+ RAID controllers/software bugs which GRUB has to live with. Please spread
+ the message that these are bugs in other software and not merely
+ suboptimal behaviour. */
+ [TYPE_RAID] = N_("Sector %llu is already in use by raid controller `%s';"
+ " avoiding it. "
+ "Please ask the manufacturer not to store data in MBR gap"),
+ [TYPE_SOFTWARE] = N_("Sector %llu is already in use by the program `%s';"
+ " avoiding it. "
+ "This software may cause boot or other problems in "
+ "future. Please ask its authors not to store data "
+ "in the boot track")
+};
+
+
+/* Signatures of other software that may be using sectors in the embedding
+ area. */
+struct embed_signature embed_signatures[] =
+ {
+ {
+ .name = "ZISD",
+ .signature = "ZISD",
+ .signature_len = 4,
+ .type = TYPE_SOFTWARE
+ },
+ {
+ .name = "FlexNet",
+ .signature = "\xd4\x41\xa0\xf5\x03\x00\x03\x00",
+ .signature_len = 8,
+ .type = TYPE_SOFTWARE
+ },
+ {
+ .name = "FlexNet",
+ .signature = "\xd8\x41\xa0\xf5\x02\x00\x02\x00",
+ .signature_len = 8,
+ .type = TYPE_SOFTWARE
+ },
+ {
+ /* from Ryan Perkins */
+ .name = "HP Backup and Recovery Manager (?)",
+ .signature = "\x70\x8a\x5d\x46\x35\xc5\x1b\x93"
+ "\xae\x3d\x86\xfd\xb1\x55\x3e\xe0",
+ .signature_len = 16,
+ .type = TYPE_SOFTWARE
+ },
+ {
+ .name = "HighPoint RAID controller",
+ .signature = "ycgl",
+ .signature_len = 4,
+ .type = TYPE_RAID
+ },
+ {
+ /* https://bugs.launchpad.net/bugs/987022 */
+ .name = "Acer registration utility (?)",
+ .signature = "GREGRegDone.Tag\x00",
+ .signature_len = 16,
+ .type = TYPE_SOFTWARE
+ }
+ };
+#endif
+
+grub_err_t
+grub_partition_msdos_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ struct grub_partition p;
+ struct grub_msdos_partition_mbr mbr;
+ int labeln = 0;
+ grub_disk_addr_t lastaddr;
+ grub_disk_addr_t ext_offset;
+ grub_disk_addr_t delta = 0;
+
+ if (disk->partition && disk->partition->partmap == &grub_msdos_partition_map)
+ {
+ if (disk->partition->msdostype == GRUB_PC_PARTITION_TYPE_LINUX_MINIX)
+ delta = disk->partition->start;
+ else
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "no embedding supported");
+ }
+
+ p.offset = 0;
+ ext_offset = 0;
+ p.number = -1;
+ p.partmap = &grub_msdos_partition_map;
+
+ /* Any value different than `p.offset' will satisfy the check during
+ first loop. */
+ lastaddr = !p.offset;
+
+ while (1)
+ {
+ int i;
+ struct grub_msdos_partition_entry *e;
+
+ /* Read the MBR. */
+ if (grub_disk_read (disk, p.offset, 0, sizeof (mbr), &mbr))
+ goto finish;
+
+ /* If this is a GPT partition, this MBR is just a dummy. */
+ if (p.offset == 0)
+ for (i = 0; i < 4; i++)
+ if (mbr.entries[i].type == GRUB_PC_PARTITION_TYPE_GPT_DISK)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "dummy mbr");
+
+ /* This is our loop-detection algorithm. It works the following way:
+ It saves last position which was a power of two. Then it compares the
+ saved value with a current one. This way it's guaranteed that the loop
+ will be broken by at most third walk.
+ */
+ if (labeln && lastaddr == p.offset)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "loop detected");
+
+ labeln++;
+ if ((labeln & (labeln - 1)) == 0)
+ lastaddr = p.offset;
+
+ /* Check if it is valid. */
+ 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++)
+ if (mbr.entries[i].flag & 0x7f)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "bad boot flag");
+
+ /* Analyze DOS partitions. */
+ for (p.index = 0; p.index < 4; p.index++)
+ {
+ e = mbr.entries + p.index;
+
+ p.start = p.offset
+ + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start)
+ << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)) - delta;
+ p.len = (grub_uint64_t)grub_le_to_cpu32 (e->length)
+ << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
+ p.msdostype = e->type;
+
+ grub_dprintf ("partition",
+ "partition %d: flag 0x%x, type 0x%x, start 0x%llx, len 0x%llx\n",
+ p.index, e->flag, e->type,
+ (unsigned long long) p.start,
+ (unsigned long long) p.len);
+
+ /* If this partition is a normal one, call the hook. */
+ if (! grub_msdos_partition_is_empty (e->type)
+ && ! grub_msdos_partition_is_extended (e->type))
+ {
+ p.number++;
+
+ if (hook (disk, &p, hook_data))
+ return grub_errno;
+ }
+ else if (p.number < 3)
+ /* If this partition is a logical one, shouldn't increase the
+ partition number. */
+ p.number++;
+ }
+
+ /* Find an extended partition. */
+ for (i = 0; i < 4; i++)
+ {
+ e = mbr.entries + i;
+
+ if (grub_msdos_partition_is_extended (e->type))
+ {
+ p.offset = ext_offset
+ + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start)
+ << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
+ if (! ext_offset)
+ ext_offset = p.offset;
+
+ break;
+ }
+ }
+
+ /* If no extended partition, the end. */
+ if (i == 4)
+ break;
+ }
+
+ finish:
+ return grub_errno;
+}
+
+#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,
+ grub_embed_type_t embed_type,
+ grub_disk_addr_t **sectors,
+ int warn_short)
+{
+ grub_disk_addr_t end = ~0ULL;
+ struct grub_msdos_partition_mbr mbr;
+ int labeln = 0;
+ /* Any value different than `p.offset' will satisfy the check during
+ first loop. */
+ grub_disk_addr_t lastaddr = 1;
+ grub_disk_addr_t ext_offset = 0;
+ grub_disk_addr_t offset = 0;
+
+ if (embed_type != GRUB_EMBED_PCBIOS)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "PC-style partitions currently support "
+ "only PC-BIOS embedding");
+
+ if (disk->partition)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "Embedding on MSDOS subpartition isn't supported");
+
+ while (1)
+ {
+ int i;
+ struct grub_msdos_partition_entry *e;
+ grub_err_t err;
+
+ /* Read the MBR. */
+ err = grub_disk_read (disk, offset, 0, sizeof (mbr), &mbr);
+ if (err)
+ return err;
+
+ /* This is our loop-detection algorithm. It works the following way:
+ It saves last position which was a power of two. Then it compares the
+ saved value with a current one. This way it's guaranteed that the loop
+ will be broken by at most third walk.
+ */
+ if (labeln && lastaddr == offset)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "loop detected");
+
+ labeln++;
+ if ((labeln & (labeln - 1)) == 0)
+ lastaddr = offset;
+
+ /* Check if it is valid. */
+ 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++)
+ if (mbr.entries[i].flag & 0x7f)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "bad boot flag");
+
+ /* Analyze DOS partitions. */
+ for (i = 0; i < 4; i++)
+ {
+ e = mbr.entries + i;
+
+ if (!grub_msdos_partition_is_empty (e->type)
+ && end > offset
+ + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start)
+ << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)))
+ end = offset + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start)
+ << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
+
+ /* If this is a GPT partition, this MBR is just a dummy. */
+ if (e->type == GRUB_PC_PARTITION_TYPE_GPT_DISK && i == 0)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "dummy mbr");
+ }
+
+ /* Find an extended partition. */
+ for (i = 0; i < 4; i++)
+ {
+ e = mbr.entries + i;
+
+ if (grub_msdos_partition_is_extended (e->type))
+ {
+ offset = ext_offset
+ + ((grub_disk_addr_t)grub_le_to_cpu32 (e->start)
+ << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
+ if (! ext_offset)
+ ext_offset = offset;
+
+ break;
+ }
+ }
+
+ /* If no extended partition, the end. */
+ if (i == 4)
+ break;
+ }
+
+ if (end >= *nsectors + 1)
+ {
+ unsigned i, j;
+ char *embed_signature_check;
+ unsigned int orig_nsectors, avail_nsectors;
+
+ orig_nsectors = *nsectors;
+ *nsectors = end - 1;
+ avail_nsectors = *nsectors;
+ if (*nsectors > max_nsectors)
+ *nsectors = max_nsectors;
+ *sectors = grub_calloc (*nsectors, sizeof (**sectors));
+ if (!*sectors)
+ return grub_errno;
+ for (i = 0; i < *nsectors; i++)
+ (*sectors)[i] = 1 + i;
+
+ /* Check for software that is already using parts of the embedding
+ * area.
+ */
+ embed_signature_check = grub_malloc (GRUB_DISK_SECTOR_SIZE);
+ for (i = 0; i < *nsectors; i++)
+ {
+ if (grub_disk_read (disk, (*sectors)[i], 0, GRUB_DISK_SECTOR_SIZE,
+ embed_signature_check))
+ continue;
+
+ for (j = 0; j < ARRAY_SIZE (embed_signatures); j++)
+ if (! grub_memcmp (embed_signatures[j].signature,
+ embed_signature_check,
+ embed_signatures[j].signature_len))
+ break;
+ if (j == ARRAY_SIZE (embed_signatures))
+ continue;
+ grub_util_warn (_(message_warn[embed_signatures[j].type]),
+ (*sectors)[i], embed_signatures[j].name);
+ avail_nsectors--;
+ if (avail_nsectors < *nsectors)
+ *nsectors = avail_nsectors;
+
+ /* Avoid this sector. */
+ for (j = i; j < *nsectors; j++)
+ (*sectors)[j]++;
+
+ /* Have we run out of space? */
+ if (avail_nsectors < orig_nsectors)
+ break;
+
+ /* Make sure to check the next sector. */
+ i--;
+ }
+ grub_free (embed_signature_check);
+
+ if (*nsectors < orig_nsectors)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("other software is using the embedding area, and "
+ "there is not enough room for core.img. Such "
+ "software is often trying to store data in a way "
+ "that avoids detection. We recommend you "
+ "investigate"));
+
+ return GRUB_ERR_NONE;
+ }
+
+ if (end < GRUB_MIN_RECOMMENDED_MBR_GAP && warn_short)
+ grub_util_warn ("You have a short MBR gap and use advanced config. Please increase post-MBR gap.");
+
+ if (end <= 1)
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ N_("this msdos-style partition label has no "
+ "post-MBR gap; embedding won't be possible"));
+
+ if (*nsectors > 62)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("your core.img is unusually large. "
+ "It won't fit in the embedding area"));
+
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("your embedding area is unusually small. "
+ "core.img won't fit in it."));
+}
+
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
+#endif
+
+
+/* Partition map type. */
+static struct grub_partition_map grub_msdos_partition_map =
+ {
+ .name = "msdos",
+ .iterate = grub_partition_msdos_iterate,
+#ifdef GRUB_UTIL
+ .embed = pc_partition_map_embed
+#endif
+ };
+
+GRUB_MOD_INIT(part_msdos)
+{
+ grub_partition_map_register (&grub_msdos_partition_map);
+}
+
+GRUB_MOD_FINI(part_msdos)
+{
+ grub_partition_map_unregister (&grub_msdos_partition_map);
+}
diff --git a/grub-core/partmap/plan.c b/grub-core/partmap/plan.c
new file mode 100644
index 0000000..83db224
--- /dev/null
+++ b/grub-core/partmap/plan.c
@@ -0,0 +1,120 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/partition.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/err.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct grub_partition_map grub_plan_partition_map;
+
+static grub_err_t
+plan_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ struct grub_partition p;
+ int ptr = 0;
+ grub_err_t err;
+
+ p.partmap = &grub_plan_partition_map;
+ p.msdostype = 0;
+
+ for (p.number = 0; ; p.number++)
+ {
+ char sig[sizeof ("part ") - 1];
+ char c;
+
+ p.offset = (ptr >> GRUB_DISK_SECTOR_BITS) + 1;
+ p.index = ptr & (GRUB_DISK_SECTOR_SIZE - 1);
+
+ err = grub_disk_read (disk, 1, ptr, sizeof (sig), sig);
+ if (err)
+ return err;
+ if (grub_memcmp (sig, "part ", sizeof ("part ") - 1) != 0)
+ break;
+ ptr += sizeof (sig);
+ do
+ {
+ err = grub_disk_read (disk, 1, ptr, 1, &c);
+ if (err)
+ return err;
+ ptr++;
+ }
+ while (grub_isdigit (c) || grub_isalpha (c));
+ if (c != ' ')
+ break;
+ p.start = 0;
+ while (1)
+ {
+ err = grub_disk_read (disk, 1, ptr, 1, &c);
+ if (err)
+ return err;
+ ptr++;
+ if (!grub_isdigit (c))
+ break;
+ p.start = p.start * 10 + (c - '0');
+ }
+ if (c != ' ')
+ break;
+ p.len = 0;
+ while (1)
+ {
+ err = grub_disk_read (disk, 1, ptr, 1, &c);
+ if (err)
+ return err;
+ ptr++;
+ if (!grub_isdigit (c))
+ break;
+ p.len = p.len * 10 + (c - '0');
+ }
+ if (c != '\n')
+ break;
+ p.len -= p.start;
+ if (hook (disk, &p, hook_data))
+ return grub_errno;
+ }
+ if (p.number == 0)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "not a plan partition table");
+
+ return GRUB_ERR_NONE;
+}
+
+/* Partition map type. */
+static struct grub_partition_map grub_plan_partition_map =
+ {
+ .name = "plan",
+ .iterate = plan_partition_map_iterate,
+ };
+
+GRUB_MOD_INIT(part_plan)
+{
+ grub_partition_map_register (&grub_plan_partition_map);
+}
+
+GRUB_MOD_FINI(part_plan)
+{
+ grub_partition_map_unregister (&grub_plan_partition_map);
+}
+
diff --git a/grub-core/partmap/sun.c b/grub-core/partmap/sun.c
new file mode 100644
index 0000000..aac30a3
--- /dev/null
+++ b/grub-core/partmap/sun.c
@@ -0,0 +1,154 @@
+/* sun.c - Read SUN style partition tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2006,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/partition.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/err.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_PARTMAP_SUN_MAGIC 0xDABE
+#define GRUB_PARTMAP_SUN_MAX_PARTS 8
+#define GRUB_PARTMAP_SUN_WHOLE_DISK_ID 0x05
+
+struct grub_sun_partition_info
+{
+ grub_uint8_t spare1;
+ grub_uint8_t id;
+ grub_uint8_t spare2;
+ grub_uint8_t flags;
+} GRUB_PACKED;
+
+struct grub_sun_partition_descriptor
+{
+ grub_uint32_t start_cylinder;
+ grub_uint32_t num_sectors;
+} GRUB_PACKED;
+
+struct grub_sun_block
+{
+ grub_uint8_t info[128]; /* Informative text string. */
+ grub_uint8_t spare0[14];
+ struct grub_sun_partition_info infos[8];
+ grub_uint8_t spare1[246]; /* Boot information etc. */
+ grub_uint16_t rspeed; /* Disk rotational speed. */
+ grub_uint16_t pcylcount; /* Physical cylinder count. */
+ grub_uint16_t sparecyl; /* extra sects per cylinder. */
+ grub_uint8_t spare2[4]; /* More magic... */
+ grub_uint16_t ilfact; /* Interleave factor. */
+ grub_uint16_t ncyl; /* Data cylinder count. */
+ grub_uint16_t nacyl; /* Alt. cylinder count. */
+ grub_uint16_t ntrks; /* Tracks per cylinder. */
+ grub_uint16_t nsect; /* Sectors per track. */
+ grub_uint8_t spare3[4]; /* Even more magic... */
+ struct grub_sun_partition_descriptor partitions[8];
+ grub_uint16_t magic; /* Magic number. */
+ grub_uint16_t csum; /* Label xor'd checksum. */
+} GRUB_PACKED;
+
+static struct grub_partition_map grub_sun_partition_map;
+
+/* Verify checksum (true=ok). */
+static int
+grub_sun_is_valid (grub_uint16_t *label)
+{
+ grub_uint16_t *pos;
+ grub_uint16_t sum = 0;
+
+ for (pos = label;
+ pos < (label + sizeof (struct grub_sun_block) / 2);
+ pos++)
+ sum ^= *pos;
+
+ return ! sum;
+}
+
+static grub_err_t
+sun_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook, void *hook_data)
+{
+ struct grub_partition p;
+ union
+ {
+ struct grub_sun_block sun_block;
+ grub_uint16_t raw[0];
+ } block;
+ int partnum;
+ grub_err_t err;
+
+ p.partmap = &grub_sun_partition_map;
+ err = grub_disk_read (disk, 0, 0, sizeof (struct grub_sun_block),
+ &block);
+ if (err)
+ return err;
+
+ 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))
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
+
+ /* Maybe another error value would be better, because partition
+ table _is_ recognized but invalid. */
+ for (partnum = 0; partnum < GRUB_PARTMAP_SUN_MAX_PARTS; partnum++)
+ {
+ struct grub_sun_partition_descriptor *desc;
+
+ if (block.sun_block.infos[partnum].id == 0
+ || block.sun_block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
+ continue;
+
+ desc = &block.sun_block.partitions[partnum];
+ p.start = ((grub_uint64_t) grub_be_to_cpu32 (desc->start_cylinder)
+ * 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)
+ {
+ if (hook (disk, &p, hook_data))
+ partnum = GRUB_PARTMAP_SUN_MAX_PARTS;
+ }
+ }
+
+ return grub_errno;
+}
+
+/* Partition map type. */
+static struct grub_partition_map grub_sun_partition_map =
+ {
+ .name = "sun",
+ .iterate = sun_partition_map_iterate,
+ };
+
+GRUB_MOD_INIT(part_sun)
+{
+ grub_partition_map_register (&grub_sun_partition_map);
+}
+
+GRUB_MOD_FINI(part_sun)
+{
+ grub_partition_map_unregister (&grub_sun_partition_map);
+}
+
diff --git a/grub-core/partmap/sunpc.c b/grub-core/partmap/sunpc.c
new file mode 100644
index 0000000..73a430c
--- /dev/null
+++ b/grub-core/partmap/sunpc.c
@@ -0,0 +1,151 @@
+/* sunpc.c - Read SUN PC style partition tables. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/partition.h>
+#include <grub/disk.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/err.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define GRUB_PARTMAP_SUN_PC_MAGIC 0xDABE
+#define GRUB_PARTMAP_SUN_PC_MAX_PARTS 16
+#define GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID 0x05
+
+struct grub_sun_pc_partition_descriptor
+{
+ grub_uint16_t id;
+ grub_uint16_t unused;
+ grub_uint32_t start_sector;
+ grub_uint32_t num_sectors;
+} GRUB_PACKED;
+
+struct grub_sun_pc_block
+{
+ grub_uint8_t unused[72];
+ struct grub_sun_pc_partition_descriptor partitions[GRUB_PARTMAP_SUN_PC_MAX_PARTS];
+ grub_uint8_t unused2[244];
+ grub_uint16_t magic; /* Magic number. */
+ grub_uint16_t csum; /* Label xor'd checksum. */
+} GRUB_PACKED;
+
+static struct grub_partition_map grub_sun_pc_partition_map;
+
+/* Verify checksum (true=ok). */
+static int
+grub_sun_is_valid (grub_uint16_t *label)
+{
+ grub_uint16_t *pos;
+ grub_uint16_t sum = 0;
+
+ for (pos = label;
+ pos < (label + sizeof (struct grub_sun_pc_block) / 2);
+ pos++)
+ sum ^= *pos;
+
+ return ! sum;
+}
+
+static grub_err_t
+sun_pc_partition_map_iterate (grub_disk_t disk,
+ grub_partition_iterate_hook_t hook,
+ void *hook_data)
+{
+ grub_partition_t p;
+ union
+ {
+ struct grub_sun_pc_block sun_block;
+ grub_uint16_t raw[0];
+ } block;
+ int partnum;
+ grub_err_t err;
+
+ p = (grub_partition_t) grub_zalloc (sizeof (struct grub_partition));
+ if (! p)
+ return grub_errno;
+
+ p->partmap = &grub_sun_pc_partition_map;
+ err = grub_disk_read (disk, 1, 0, sizeof (struct grub_sun_pc_block), &block);
+ if (err)
+ {
+ grub_free (p);
+ return err;
+ }
+
+ 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,
+ "not a sun_pc partition table");
+ }
+
+ if (! grub_sun_is_valid (block.raw))
+ {
+ grub_free (p);
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
+ }
+
+ /* Maybe another error value would be better, because partition
+ table _is_ recognized but invalid. */
+ for (partnum = 0; partnum < GRUB_PARTMAP_SUN_PC_MAX_PARTS; partnum++)
+ {
+ struct grub_sun_pc_partition_descriptor *desc;
+
+ 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_block.partitions[partnum];
+ p->start = grub_le_to_cpu32 (desc->start_sector);
+ p->len = grub_le_to_cpu32 (desc->num_sectors);
+ p->number = partnum;
+ if (p->len)
+ {
+ if (hook (disk, p, hook_data))
+ partnum = GRUB_PARTMAP_SUN_PC_MAX_PARTS;
+ }
+ }
+
+ grub_free (p);
+
+ return grub_errno;
+}
+
+/* Partition map type. */
+static struct grub_partition_map grub_sun_pc_partition_map =
+ {
+ .name = "sunpc",
+ .iterate = sun_pc_partition_map_iterate,
+ };
+
+GRUB_MOD_INIT(part_sunpc)
+{
+ grub_partition_map_register (&grub_sun_pc_partition_map);
+}
+
+GRUB_MOD_FINI(part_sunpc)
+{
+ grub_partition_map_unregister (&grub_sun_pc_partition_map);
+}
+
diff --git a/grub-core/parttool/msdospart.c b/grub-core/parttool/msdospart.c
new file mode 100644
index 0000000..3918caa
--- /dev/null
+++ b/grub-core/parttool/msdospart.c
@@ -0,0 +1,161 @@
+/* pcpart.c - manipulate fdisk partitions */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/msdos_partition.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+#include <grub/parttool.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv2+");
+
+static int activate_table_handle = -1;
+static int type_table_handle = -1;
+
+static struct grub_parttool_argdesc grub_pcpart_bootargs[] =
+{
+ {"boot", N_("Make partition active"), GRUB_PARTTOOL_ARG_BOOL},
+ {0, 0, 0}
+};
+
+static grub_err_t grub_pcpart_boot (const grub_device_t dev,
+ const struct grub_parttool_args *args)
+{
+ int i, index;
+ grub_partition_t part;
+ struct grub_msdos_partition_mbr mbr;
+
+ if (dev->disk->partition->offset)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("not a primary partition"));
+
+ index = dev->disk->partition->index;
+ part = dev->disk->partition;
+ dev->disk->partition = part->parent;
+
+ /* Read the MBR. */
+ if (grub_disk_read (dev->disk, 0, 0, sizeof (mbr), &mbr))
+ {
+ dev->disk->partition = part;
+ return grub_errno;
+ }
+
+ if (args[0].set && args[0].bool)
+ {
+ for (i = 0; i < 4; i++)
+ mbr.entries[i].flag = 0x0;
+ mbr.entries[index].flag = 0x80;
+ grub_printf_ (N_("Partition %d is active now. \n"), index);
+ }
+ else
+ {
+ mbr.entries[index].flag = 0x0;
+ grub_printf (N_("Cleared active flag on %d. \n"), index);
+ }
+
+ /* Write the MBR. */
+ grub_disk_write (dev->disk, 0, 0, sizeof (mbr), &mbr);
+
+ dev->disk->partition = part;
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_parttool_argdesc grub_pcpart_typeargs[] =
+{
+ {"type", N_("Change partition type"), GRUB_PARTTOOL_ARG_VAL},
+ {"hidden", N_("Set `hidden' flag in partition type"), GRUB_PARTTOOL_ARG_BOOL},
+ {0, 0, 0}
+};
+
+static grub_err_t grub_pcpart_type (const grub_device_t dev,
+ const struct grub_parttool_args *args)
+{
+ int index;
+ grub_uint8_t type;
+ grub_partition_t part;
+ struct grub_msdos_partition_mbr mbr;
+
+ index = dev->disk->partition->index;
+ part = dev->disk->partition;
+ dev->disk->partition = part->parent;
+
+ /* Read the parttable. */
+ if (grub_disk_read (dev->disk, part->offset, 0,
+ sizeof (mbr), &mbr))
+ {
+ dev->disk->partition = part;
+ return grub_errno;
+ }
+
+ if (args[0].set)
+ type = grub_strtoul (args[0].str, 0, 0);
+ else
+ type = mbr.entries[index].type;
+
+ if (args[1].set)
+ {
+ if (args[1].bool)
+ type |= GRUB_PC_PARTITION_TYPE_HIDDEN_FLAG;
+ else
+ type &= ~GRUB_PC_PARTITION_TYPE_HIDDEN_FLAG;
+ }
+
+ if (grub_msdos_partition_is_empty (type)
+ || grub_msdos_partition_is_extended (type))
+ {
+ dev->disk->partition = part;
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("the partition type 0x%x isn't valid"), type);
+ }
+
+ mbr.entries[index].type = type;
+ /* TRANSLATORS: In this case we're actually writing to the disk and actively
+ modifying partition type rather than just defining it. */
+ grub_printf_ (N_("Setting partition type to 0x%x\n"), type);
+
+ /* Write the parttable. */
+ grub_disk_write (dev->disk, part->offset, 0,
+ sizeof (mbr), &mbr);
+
+ dev->disk->partition = part;
+
+ return GRUB_ERR_NONE;
+}
+
+GRUB_MOD_INIT (msdospart)
+{
+ activate_table_handle = grub_parttool_register ("msdos",
+ grub_pcpart_boot,
+ grub_pcpart_bootargs);
+ type_table_handle = grub_parttool_register ("msdos",
+ grub_pcpart_type,
+ grub_pcpart_typeargs);
+
+}
+GRUB_MOD_FINI(msdospart)
+{
+ grub_parttool_unregister (activate_table_handle);
+ grub_parttool_unregister (type_table_handle);
+}
diff --git a/grub-core/script/argv.c b/grub-core/script/argv.c
new file mode 100644
index 0000000..5751fdd
--- /dev/null
+++ b/grub-core/script/argv.c
@@ -0,0 +1,165 @@
+/* argv.c - methods for constructing argument vector */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/script_sh.h>
+#include <grub/safemath.h>
+
+/* Return nearest power of two that is >= v. */
+static unsigned
+round_up_exp (unsigned v)
+{
+ COMPILE_TIME_ASSERT (sizeof (v) == 4);
+
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+
+ v++;
+ v += (v == 0);
+
+ return v;
+}
+
+void
+grub_script_argv_free (struct grub_script_argv *argv)
+{
+ unsigned i;
+
+ if (argv->args)
+ {
+ for (i = 0; i < argv->argc; i++)
+ grub_free (argv->args[i]);
+
+ grub_free (argv->args);
+ }
+
+ argv->argc = 0;
+ argv->args = 0;
+ argv->script = 0;
+}
+
+/* Make argv from argc, args pair. */
+int
+grub_script_argv_make (struct grub_script_argv *argv, int argc, char **args)
+{
+ int i;
+ struct grub_script_argv r = { 0, 0, 0 };
+
+ for (i = 0; i < argc; i++)
+ if (grub_script_argv_next (&r)
+ || grub_script_argv_append (&r, args[i], grub_strlen (args[i])))
+ {
+ grub_script_argv_free (&r);
+ return 1;
+ }
+ *argv = r;
+ return 0;
+}
+
+/* Prepare for next argc. */
+int
+grub_script_argv_next (struct grub_script_argv *argv)
+{
+ char **p = argv->args;
+ grub_size_t sz;
+
+ if (argv->args && argv->argc && argv->args[argv->argc - 1] == 0)
+ return 0;
+
+ if (grub_add (argv->argc, 2, &sz) ||
+ grub_mul (sz, sizeof (char *), &sz))
+ return 1;
+
+ p = grub_realloc (p, round_up_exp (sz));
+ if (! p)
+ return 1;
+
+ argv->argc++;
+ argv->args = p;
+
+ if (argv->argc == 1)
+ argv->args[0] = 0;
+ argv->args[argv->argc] = 0;
+ return 0;
+}
+
+/* Append `s' to the last argument. */
+int
+grub_script_argv_append (struct grub_script_argv *argv, const char *s,
+ grub_size_t slen)
+{
+ grub_size_t a;
+ char *p = argv->args[argv->argc - 1];
+ grub_size_t sz;
+
+ if (! s)
+ return 0;
+
+ a = p ? grub_strlen (p) : 0;
+
+ if (grub_add (a, slen, &sz) ||
+ grub_add (sz, 1, &sz) ||
+ grub_mul (sz, sizeof (char), &sz))
+ return 1;
+
+ p = grub_realloc (p, round_up_exp (sz));
+ if (! p)
+ return 1;
+
+ grub_memcpy (p + a, s, slen);
+ p[a+slen] = 0;
+ argv->args[argv->argc - 1] = p;
+
+ return 0;
+}
+
+/* Split `s' and append words as multiple arguments. */
+int
+grub_script_argv_split_append (struct grub_script_argv *argv, const char *s)
+{
+ const char *p;
+ int errors = 0;
+
+ if (! s)
+ return 0;
+
+ while (*s && grub_isspace (*s))
+ s++;
+
+ while (! errors && *s)
+ {
+ p = s;
+ while (*s && ! grub_isspace (*s))
+ s++;
+
+ errors += grub_script_argv_append (argv, p, s - p);
+
+ while (*s && grub_isspace (*s))
+ s++;
+
+ if (*s)
+ errors += grub_script_argv_next (argv);
+ }
+ return errors;
+}
diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
new file mode 100644
index 0000000..2515840
--- /dev/null
+++ b/grub-core/script/execute.c
@@ -0,0 +1,1192 @@
+/* execute.c -- Execute a GRUB script. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/script_sh.h>
+#include <grub/command.h>
+#include <grub/menu.h>
+#include <grub/lib/arg.h>
+#include <grub/normal.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/verify.h>
+
+/* Max digits for a char is 3 (0xFF is 255), similarly for an int it
+ is sizeof (int) * 3, and one extra for a possible -ve sign. */
+#define ERRNO_DIGITS_MAX (sizeof (int) * 3 + 1)
+
+static unsigned long is_continue;
+static unsigned long active_loops;
+static unsigned long active_breaks;
+static unsigned long function_return;
+
+#define GRUB_SCRIPT_SCOPE_MALLOCED 1
+#define GRUB_SCRIPT_SCOPE_ARGS_MALLOCED 2
+
+/* Scope for grub script functions. */
+struct grub_script_scope
+{
+ unsigned flags;
+ unsigned shifts;
+ struct grub_script_argv argv;
+};
+static struct grub_script_scope *scope = 0;
+
+/* Wildcard translator for GRUB script. */
+struct grub_script_wildcard_translator *grub_wildcard_translator;
+
+static char*
+wildcard_escape (const char *s)
+{
+ int i;
+ int len;
+ char ch;
+ char *p;
+
+ len = grub_strlen (s);
+ p = grub_malloc (len * 2 + 1);
+ if (! p)
+ return NULL;
+
+ i = 0;
+ while ((ch = *s++))
+ {
+ if (ch == '*' || ch == '\\' || ch == '?')
+ p[i++] = '\\';
+ p[i++] = ch;
+ }
+ p[i] = '\0';
+ return p;
+}
+
+static char*
+wildcard_unescape (const char *s)
+{
+ int i;
+ int len;
+ char ch;
+ char *p;
+
+ len = grub_strlen (s);
+ p = grub_malloc (len + 1);
+ if (! p)
+ return NULL;
+
+ i = 0;
+ while ((ch = *s++))
+ {
+ if (ch == '\\')
+ p[i++] = *s++;
+ else
+ p[i++] = ch;
+ }
+ p[i] = '\0';
+ return p;
+}
+
+static void
+replace_scope (struct grub_script_scope *new_scope)
+{
+ if (scope)
+ {
+ scope->argv.argc += scope->shifts;
+ scope->argv.args -= scope->shifts;
+
+ if (scope->flags & GRUB_SCRIPT_SCOPE_ARGS_MALLOCED)
+ grub_script_argv_free (&scope->argv);
+
+ if (scope->flags & GRUB_SCRIPT_SCOPE_MALLOCED)
+ grub_free (scope);
+ }
+ scope = new_scope;
+}
+
+grub_err_t
+grub_script_break (grub_command_t cmd, int argc, char *argv[])
+{
+ const char *p = NULL;
+ unsigned long count;
+
+ if (argc == 0)
+ count = 1;
+ else if (argc > 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+ else
+ {
+ count = grub_strtoul (argv[0], &p, 10);
+ if (grub_errno)
+ return grub_errno;
+ if (*p != '\0')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unrecognized number"));
+ if (count == 0)
+ /* TRANSLATORS: 0 is a quantifier. "break" (similar to bash)
+ can be used e.g. to break 3 loops at once.
+ But asking it to break 0 loops makes no sense. */
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't break 0 loops"));
+ }
+
+ is_continue = grub_strcmp (cmd->name, "break") ? 1 : 0;
+ active_breaks = count;
+ if (active_breaks > active_loops)
+ active_breaks = active_loops;
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_script_shift (grub_command_t cmd __attribute__((unused)),
+ int argc, char *argv[])
+{
+ const char *p = NULL;
+ unsigned long n = 0;
+
+ if (! scope)
+ return GRUB_ERR_NONE;
+
+ if (argc == 0)
+ n = 1;
+
+ else if (argc > 1)
+ return GRUB_ERR_BAD_ARGUMENT;
+
+ else
+ {
+ n = grub_strtoul (argv[0], &p, 10);
+ if (*p != '\0')
+ return GRUB_ERR_BAD_ARGUMENT;
+ }
+
+ if (n > scope->argv.argc)
+ return GRUB_ERR_BAD_ARGUMENT;
+
+ scope->shifts += n;
+ scope->argv.argc -= n;
+ scope->argv.args += n;
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_script_setparams (grub_command_t cmd __attribute__((unused)),
+ int argc, char **args)
+{
+ struct grub_script_scope *new_scope;
+ struct grub_script_argv argv = { 0, 0, 0 };
+
+ if (! scope)
+ return GRUB_ERR_INVALID_COMMAND;
+
+ new_scope = grub_malloc (sizeof (*new_scope));
+ if (! new_scope)
+ return grub_errno;
+
+ if (grub_script_argv_make (&argv, argc, args))
+ {
+ grub_free (new_scope);
+ return grub_errno;
+ }
+
+ new_scope->shifts = 0;
+ new_scope->argv = argv;
+ new_scope->flags = GRUB_SCRIPT_SCOPE_MALLOCED |
+ GRUB_SCRIPT_SCOPE_ARGS_MALLOCED;
+
+ replace_scope (new_scope);
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_script_return (grub_command_t cmd __attribute__((unused)),
+ int argc, char *argv[])
+{
+ const char *p = NULL;
+ unsigned long n;
+
+ if (! scope || argc > 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ /* TRANSLATORS: It's about not being
+ inside a function. "return" can be used only
+ in a function and this error occurs if it's used
+ anywhere else. */
+ N_("not in function body"));
+
+ if (argc == 0)
+ {
+ const char *t;
+ function_return = 1;
+ t = grub_env_get ("?");
+ if (!t)
+ return GRUB_ERR_NONE;
+ return grub_strtoul (t, NULL, 10);
+ }
+
+ n = grub_strtoul (argv[0], &p, 10);
+ if (grub_errno)
+ return grub_errno;
+ if (*p != '\0')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unrecognized number"));
+
+ function_return = 1;
+ return n ? grub_error (n, N_("false")) : GRUB_ERR_NONE;
+}
+
+static int
+grub_env_special (const char *name)
+{
+ if (grub_isdigit (name[0]) ||
+ grub_strcmp (name, "#") == 0 ||
+ grub_strcmp (name, "*") == 0 ||
+ grub_strcmp (name, "@") == 0)
+ return 1;
+ return 0;
+}
+
+static char **
+grub_script_env_get (const char *name, grub_script_arg_type_t type)
+{
+ unsigned i;
+ struct grub_script_argv result = { 0, 0, 0 };
+
+ if (grub_script_argv_next (&result))
+ goto fail;
+
+ if (! grub_env_special (name))
+ {
+ const char *v = grub_env_get (name);
+ if (v && v[0])
+ {
+ if (type == GRUB_SCRIPT_ARG_TYPE_VAR)
+ {
+ if (grub_script_argv_split_append (&result, v))
+ goto fail;
+ }
+ else
+ if (grub_script_argv_append (&result, v, grub_strlen (v)))
+ goto fail;
+ }
+ }
+ else if (! scope)
+ {
+ if (grub_script_argv_append (&result, 0, 0))
+ goto fail;
+ }
+ else if (grub_strcmp (name, "#") == 0)
+ {
+ char buffer[ERRNO_DIGITS_MAX + 1];
+ grub_snprintf (buffer, sizeof (buffer), "%u", scope->argv.argc);
+ if (grub_script_argv_append (&result, buffer, grub_strlen (buffer)))
+ goto fail;
+ }
+ else if (grub_strcmp (name, "*") == 0)
+ {
+ for (i = 0; i < scope->argv.argc; i++)
+ if (type == GRUB_SCRIPT_ARG_TYPE_VAR)
+ {
+ if (i != 0 && grub_script_argv_next (&result))
+ goto fail;
+
+ if (grub_script_argv_split_append (&result, scope->argv.args[i]))
+ goto fail;
+ }
+ else
+ {
+ if (i != 0 && grub_script_argv_append (&result, " ", 1))
+ goto fail;
+
+ if (grub_script_argv_append (&result, scope->argv.args[i],
+ grub_strlen (scope->argv.args[i])))
+ goto fail;
+ }
+ }
+ else if (grub_strcmp (name, "@") == 0)
+ {
+ for (i = 0; i < scope->argv.argc; i++)
+ {
+ if (i != 0 && grub_script_argv_next (&result))
+ goto fail;
+
+ if (type == GRUB_SCRIPT_ARG_TYPE_VAR)
+ {
+ if (grub_script_argv_split_append (&result, scope->argv.args[i]))
+ goto fail;
+ }
+ else
+ if (grub_script_argv_append (&result, scope->argv.args[i],
+ grub_strlen (scope->argv.args[i])))
+ goto fail;
+ }
+ }
+ else
+ {
+ unsigned long num = grub_strtoul (name, 0, 10);
+ if (num == 0)
+ ; /* XXX no file name, for now. */
+
+ else if (num <= scope->argv.argc)
+ {
+ if (type == GRUB_SCRIPT_ARG_TYPE_VAR)
+ {
+ if (grub_script_argv_split_append (&result,
+ scope->argv.args[num - 1]))
+ goto fail;
+ }
+ else
+ if (grub_script_argv_append (&result, scope->argv.args[num - 1],
+ grub_strlen (scope->argv.args[num - 1])
+ ))
+ goto fail;
+ }
+ }
+
+ return result.args;
+
+ fail:
+
+ grub_script_argv_free (&result);
+ return 0;
+}
+
+static grub_err_t
+grub_script_env_set (const char *name, const char *val)
+{
+ if (grub_env_special (name))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid variable name `%s'"), name);
+
+ return grub_env_set (name, val);
+}
+
+struct gettext_context
+{
+ char **allowed_strings;
+ grub_size_t nallowed_strings;
+ grub_size_t additional_len;
+};
+
+static int
+parse_string (const char *str,
+ int (*hook) (const char *var, grub_size_t varlen,
+ char **ptr, struct gettext_context *ctx),
+ struct gettext_context *ctx,
+ char *put)
+{
+ const char *ptr;
+ int escaped = 0;
+ const char *optr;
+
+ for (ptr = str; ptr && *ptr; )
+ switch (*ptr)
+ {
+ case '\\':
+ escaped = !escaped;
+ if (!escaped && put)
+ *(put++) = '\\';
+ ptr++;
+ break;
+ case '$':
+ if (escaped)
+ {
+ escaped = 0;
+ if (put)
+ *(put++) = *ptr;
+ ptr++;
+ break;
+ }
+
+ ptr++;
+ switch (*ptr)
+ {
+ case '{':
+ {
+ optr = ptr + 1;
+ ptr = grub_strchr (optr, '}');
+ if (!ptr)
+ break;
+ if (hook (optr, ptr - optr, &put, ctx))
+ return 1;
+ ptr++;
+ break;
+ }
+ case '0' ... '9':
+ optr = ptr;
+ while (*ptr >= '0' && *ptr <= '9')
+ ptr++;
+ if (hook (optr, ptr - optr, &put, ctx))
+ return 1;
+ break;
+ case 'a' ... 'z':
+ case 'A' ... 'Z':
+ case '_':
+ optr = ptr;
+ while ((*ptr >= '0' && *ptr <= '9')
+ || (*ptr >= 'a' && *ptr <= 'z')
+ || (*ptr >= 'A' && *ptr <= 'Z')
+ || *ptr == '_')
+ ptr++;
+ if (hook (optr, ptr - optr, &put, ctx))
+ return 1;
+ break;
+ case '?':
+ case '#':
+ if (hook (ptr, 1, &put, ctx))
+ return 1;
+ ptr++;
+ break;
+ default:
+ if (put)
+ *(put++) = '$';
+ }
+ break;
+ default:
+ if (escaped && put)
+ *(put++) = '\\';
+ escaped = 0;
+ if (put)
+ *(put++) = *ptr;
+ ptr++;
+ break;
+ }
+ if (put)
+ *(put++) = 0;
+ return 0;
+}
+
+static int
+gettext_putvar (const char *str, grub_size_t len,
+ char **ptr, struct gettext_context *ctx)
+{
+ const char *var;
+ grub_size_t i;
+
+ for (i = 0; i < ctx->nallowed_strings; i++)
+ if (grub_strncmp (ctx->allowed_strings[i], str, len) == 0
+ && ctx->allowed_strings[i][len] == 0)
+ {
+ break;
+ }
+ if (i == ctx->nallowed_strings)
+ return 0;
+
+ /* Enough for any number. */
+ if (len == 1 && str[0] == '#' && scope != NULL)
+ {
+ grub_snprintf (*ptr, 30, "%u", scope->argv.argc);
+ *ptr += grub_strlen (*ptr);
+ return 0;
+ }
+ var = grub_env_get (ctx->allowed_strings[i]);
+ if (var)
+ *ptr = grub_stpcpy (*ptr, var);
+ return 0;
+}
+
+static int
+gettext_save_allow (const char *str, grub_size_t len,
+ char **ptr __attribute__ ((unused)),
+ struct gettext_context *ctx)
+{
+ ctx->allowed_strings[ctx->nallowed_strings++] = grub_strndup (str, len);
+ if (!ctx->allowed_strings[ctx->nallowed_strings - 1])
+ return 1;
+ return 0;
+}
+
+static int
+gettext_getlen (const char *str, grub_size_t len,
+ char **ptr __attribute__ ((unused)),
+ struct gettext_context *ctx)
+{
+ const char *var;
+ grub_size_t i;
+
+ for (i = 0; i < ctx->nallowed_strings; i++)
+ if (grub_strncmp (ctx->allowed_strings[i], str, len) == 0
+ && ctx->allowed_strings[i][len] == 0)
+ break;
+ if (i == ctx->nallowed_strings)
+ return 0;
+
+ /* Enough for any number. */
+ if (len == 1 && str[0] == '#')
+ {
+ ctx->additional_len += 30;
+ return 0;
+ }
+ var = grub_env_get (ctx->allowed_strings[i]);
+ if (var)
+ ctx->additional_len += grub_strlen (var);
+ return 0;
+}
+
+static int
+gettext_append (struct grub_script_argv *result, const char *orig_str)
+{
+ const char *template;
+ char *res = 0;
+ struct gettext_context ctx = {
+ .allowed_strings = 0,
+ .nallowed_strings = 0,
+ .additional_len = 1
+ };
+ int rval = 1;
+ const char *iptr;
+
+ grub_size_t dollar_cnt = 0;
+
+ for (iptr = orig_str; *iptr; iptr++)
+ if (*iptr == '$')
+ dollar_cnt++;
+ ctx.allowed_strings = grub_calloc (dollar_cnt, sizeof (ctx.allowed_strings[0]));
+
+ if (parse_string (orig_str, gettext_save_allow, &ctx, 0))
+ goto fail;
+
+ template = _(orig_str);
+
+ if (parse_string (template, gettext_getlen, &ctx, 0))
+ goto fail;
+
+ res = grub_malloc (grub_strlen (template) + ctx.additional_len);
+ if (!res)
+ goto fail;
+
+ if (parse_string (template, gettext_putvar, &ctx, res))
+ goto fail;
+
+ char *escaped = 0;
+ escaped = wildcard_escape (res);
+ if (grub_script_argv_append (result, escaped, grub_strlen (escaped)))
+ {
+ grub_free (escaped);
+ goto fail;
+ }
+ grub_free (escaped);
+
+ rval = 0;
+ fail:
+ grub_free (res);
+ {
+ grub_size_t i;
+ for (i = 0; i < ctx.nallowed_strings; i++)
+ grub_free (ctx.allowed_strings[i]);
+ }
+ grub_free (ctx.allowed_strings);
+ return rval;
+}
+
+static int
+append (struct grub_script_argv *result,
+ const char *s, int escape_type)
+{
+ int r;
+ char *p = 0;
+
+ if (escape_type == 0)
+ return grub_script_argv_append (result, s, grub_strlen (s));
+
+ if (escape_type > 0)
+ p = wildcard_escape (s);
+ else if (escape_type < 0)
+ p = wildcard_unescape (s);
+
+ if (! p)
+ return 1;
+
+ r = grub_script_argv_append (result, p, grub_strlen (p));
+ grub_free (p);
+ return r;
+}
+
+/* Convert arguments in ARGLIST into ARGV form. */
+static int
+grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
+ struct grub_script_argv *argv)
+{
+ int i;
+ char **values = 0;
+ struct grub_script_arg *arg = 0;
+ struct grub_script_argv result = { 0, 0, 0 };
+
+ if (arglist == NULL)
+ return 1;
+
+ for (; arglist && arglist->arg; arglist = arglist->next)
+ {
+ if (grub_script_argv_next (&result))
+ goto fail;
+
+ arg = arglist->arg;
+ while (arg)
+ {
+ switch (arg->type)
+ {
+ case GRUB_SCRIPT_ARG_TYPE_VAR:
+ case GRUB_SCRIPT_ARG_TYPE_DQVAR:
+ {
+ int need_cleanup = 0;
+
+ 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:
+ {
+ char *p;
+ if (grub_script_argv_append (&result, "{", 1))
+ goto fail;
+ p = wildcard_escape (arg->str);
+ if (!p)
+ goto fail;
+ if (grub_script_argv_append (&result, p,
+ grub_strlen (p)))
+ {
+ grub_free (p);
+ goto fail;
+ }
+ grub_free (p);
+ if (grub_script_argv_append (&result, "}", 1))
+ goto fail;
+ }
+ result.script = arg->script;
+ break;
+
+ case GRUB_SCRIPT_ARG_TYPE_TEXT:
+ if (arg->str[0] &&
+ grub_script_argv_append (&result, arg->str,
+ grub_strlen (arg->str)))
+ goto fail;
+ break;
+
+ case GRUB_SCRIPT_ARG_TYPE_GETTEXT:
+ {
+ if (gettext_append (&result, arg->str))
+ goto fail;
+ }
+ break;
+
+ case GRUB_SCRIPT_ARG_TYPE_DQSTR:
+ case GRUB_SCRIPT_ARG_TYPE_SQSTR:
+ if (append (&result, arg->str, 1))
+ goto fail;
+ break;
+ }
+ arg = arg->next;
+ }
+ }
+
+ if (! result.args[result.argc - 1])
+ result.argc--;
+
+ /* Perform wildcard expansion. */
+
+ int j;
+ int failed = 0;
+ struct grub_script_argv unexpanded = result;
+
+ result.argc = 0;
+ result.args = 0;
+ for (i = 0; unexpanded.args[i]; i++)
+ {
+ char **expansions = 0;
+ if (grub_wildcard_translator
+ && grub_wildcard_translator->expand (unexpanded.args[i],
+ &expansions))
+ {
+ grub_script_argv_free (&unexpanded);
+ goto fail;
+ }
+
+ if (! expansions)
+ {
+ grub_script_argv_next (&result);
+ append (&result, unexpanded.args[i], -1);
+ }
+ else
+ {
+ for (j = 0; expansions[j]; j++)
+ {
+ failed = (failed || grub_script_argv_next (&result) ||
+ append (&result, expansions[j], 0));
+ grub_free (expansions[j]);
+ }
+ grub_free (expansions);
+
+ if (failed)
+ {
+ grub_script_argv_free (&unexpanded);
+ goto fail;
+ }
+ }
+ }
+ grub_script_argv_free (&unexpanded);
+
+ *argv = result;
+ return 0;
+
+ fail:
+
+ grub_script_argv_free (&result);
+ return 1;
+}
+
+static grub_err_t
+grub_script_execute_cmd (struct grub_script_cmd *cmd)
+{
+ int ret;
+ char errnobuf[ERRNO_DIGITS_MAX + 1];
+
+ if (cmd == 0)
+ return 0;
+
+ ret = cmd->exec (cmd);
+
+ grub_snprintf (errnobuf, sizeof (errnobuf), "%d", ret);
+ grub_env_set ("?", errnobuf);
+ return ret;
+}
+
+/* Execute a function call. */
+grub_err_t
+grub_script_function_call (grub_script_function_t func, int argc, char **args)
+{
+ grub_err_t ret = 0;
+ unsigned long loops = active_loops;
+ struct grub_script_scope *old_scope;
+ struct grub_script_scope new_scope;
+
+ active_loops = 0;
+ new_scope.flags = 0;
+ new_scope.shifts = 0;
+ new_scope.argv.argc = argc;
+ new_scope.argv.args = args;
+
+ old_scope = scope;
+ scope = &new_scope;
+
+ func->executing++;
+ ret = grub_script_execute (func->func);
+ func->executing--;
+
+ function_return = 0;
+ active_loops = loops;
+ replace_scope (old_scope); /* free any scopes by setparams */
+ return ret;
+}
+
+/* Helper for grub_script_execute_sourcecode. */
+static grub_err_t
+grub_script_execute_sourcecode_getline (char **line,
+ int cont __attribute__ ((unused)),
+ void *data)
+{
+ const char **source = data;
+ const char *p;
+
+ if (! *source)
+ {
+ *line = 0;
+ return 0;
+ }
+
+ p = grub_strchr (*source, '\n');
+
+ if (p)
+ *line = grub_strndup (*source, p - *source);
+ else
+ *line = grub_strdup (*source);
+ *source = p ? p + 1 : 0;
+ return 0;
+}
+
+/* Execute a source script. */
+grub_err_t
+grub_script_execute_sourcecode (const char *source)
+{
+ grub_err_t ret = 0;
+ struct grub_script *parsed_script;
+
+ while (source)
+ {
+ char *line;
+
+ grub_script_execute_sourcecode_getline (&line, 0, &source);
+ parsed_script = grub_script_parse
+ (line, grub_script_execute_sourcecode_getline, &source);
+ if (! parsed_script)
+ {
+ ret = grub_errno;
+ grub_free (line);
+ break;
+ }
+
+ ret = grub_script_execute (parsed_script);
+ grub_script_free (parsed_script);
+ grub_free (line);
+ }
+
+ return ret;
+}
+
+/* Execute a source script in new scope. */
+grub_err_t
+grub_script_execute_new_scope (const char *source, int argc, char **args)
+{
+ grub_err_t ret = 0;
+ struct grub_script_scope new_scope;
+ struct grub_script_scope *old_scope;
+
+ new_scope.argv.argc = argc;
+ new_scope.argv.args = args;
+ new_scope.flags = 0;
+
+ old_scope = scope;
+ scope = &new_scope;
+
+ ret = grub_script_execute_sourcecode (source);
+
+ scope = old_scope;
+ return ret;
+}
+
+/* Execute a single command line. */
+grub_err_t
+grub_script_execute_cmdline (struct grub_script_cmd *cmd)
+{
+ struct grub_script_cmdline *cmdline = (struct grub_script_cmdline *) cmd;
+ grub_command_t grubcmd;
+ grub_err_t ret = 0;
+ grub_script_function_t func = 0;
+ char errnobuf[18];
+ char *cmdname, *cmdstring;
+ int argc, offset = 0, cmdlen = 0;
+ unsigned int i;
+ char **args;
+ int invert;
+ struct grub_script_argv argv = { 0, 0, 0 };
+
+ /* Lookup the command. */
+ if (grub_script_arglist_to_argv (cmdline->arglist, &argv) || ! argv.args || ! argv.args[0])
+ return grub_errno;
+
+ for (i = 0; i < argv.argc; i++)
+ {
+ cmdlen += grub_strlen (argv.args[i]) + 1;
+ }
+
+ cmdstring = grub_malloc (cmdlen);
+ if (!cmdstring)
+ {
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
+ N_("cannot allocate command buffer"));
+ }
+
+ for (i = 0; i < argv.argc; i++)
+ {
+ offset += grub_snprintf (cmdstring + offset, cmdlen - offset, "%s ",
+ argv.args[i]);
+ }
+ cmdstring[cmdlen - 1] = '\0';
+ grub_verify_string (cmdstring, GRUB_VERIFY_COMMAND);
+ grub_free (cmdstring);
+ invert = 0;
+ argc = argv.argc - 1;
+ args = argv.args + 1;
+ cmdname = argv.args[0];
+ if (grub_strcmp (cmdname, "!") == 0)
+ {
+ if (argv.argc < 2 || ! argv.args[1])
+ {
+ grub_script_argv_free (&argv);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("no command is specified"));
+ }
+
+ invert = 1;
+ argc = argv.argc - 2;
+ args = argv.args + 2;
+ cmdname = argv.args[1];
+ }
+ grubcmd = grub_command_find (cmdname);
+ if (! grubcmd)
+ {
+ grub_errno = GRUB_ERR_NONE;
+
+ /* It's not a GRUB command, try all functions. */
+ func = grub_script_function_find (cmdname);
+ if (! func)
+ {
+ /* As a last resort, try if it is an assignment. */
+ char *assign = grub_strdup (cmdname);
+ char *eq = grub_strchr (assign, '=');
+
+ if (eq)
+ {
+ /* This was set because the command was not found. */
+ grub_errno = GRUB_ERR_NONE;
+
+ /* Create two strings and set the variable. */
+ *eq = '\0';
+ eq++;
+ grub_script_env_set (assign, eq);
+ }
+ grub_free (assign);
+
+ grub_snprintf (errnobuf, sizeof (errnobuf), "%d", grub_errno);
+ grub_script_env_set ("?", errnobuf);
+
+ grub_script_argv_free (&argv);
+ grub_print_error ();
+
+ return 0;
+ }
+ }
+
+ /* Execute the GRUB command or function. */
+ if (grubcmd)
+ {
+ if (grub_extractor_level && !(grubcmd->flags
+ & GRUB_COMMAND_FLAG_EXTRACTOR))
+ ret = grub_error (GRUB_ERR_EXTRACTOR,
+ "%s isn't allowed to execute in an extractor",
+ cmdname);
+ else if ((grubcmd->flags & GRUB_COMMAND_FLAG_BLOCKS) &&
+ (grubcmd->flags & GRUB_COMMAND_FLAG_EXTCMD))
+ ret = grub_extcmd_dispatcher (grubcmd, argc, args, argv.script);
+ else
+ ret = (grubcmd->func) (grubcmd, argc, args);
+ }
+ else
+ ret = grub_script_function_call (func, argc, args);
+
+ if (invert)
+ {
+ if (ret == GRUB_ERR_TEST_FAILURE)
+ grub_errno = ret = GRUB_ERR_NONE;
+ else if (ret == GRUB_ERR_NONE)
+ ret = grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
+ else
+ {
+ grub_print_error ();
+ ret = GRUB_ERR_NONE;
+ }
+ }
+
+ /* Free arguments. */
+ grub_script_argv_free (&argv);
+
+ if (grub_errno == GRUB_ERR_TEST_FAILURE)
+ grub_errno = GRUB_ERR_NONE;
+
+ grub_print_error ();
+
+ grub_snprintf (errnobuf, sizeof (errnobuf), "%d", ret);
+ grub_env_set ("?", errnobuf);
+
+ return ret;
+}
+
+/* Execute a block of one or more commands. */
+grub_err_t
+grub_script_execute_cmdlist (struct grub_script_cmd *list)
+{
+ int ret = 0;
+ struct grub_script_cmd *cmd;
+
+ /* Loop over every command and execute it. */
+ for (cmd = list->next; cmd; cmd = cmd->next)
+ {
+ if (active_breaks)
+ break;
+
+ ret = grub_script_execute_cmd (cmd);
+
+ if (function_return)
+ break;
+ }
+
+ return ret;
+}
+
+/* Execute an if statement. */
+grub_err_t
+grub_script_execute_cmdif (struct grub_script_cmd *cmd)
+{
+ int ret;
+ const char *result;
+ struct grub_script_cmdif *cmdif = (struct grub_script_cmdif *) cmd;
+
+ /* Check if the commands results in a true or a false. The value is
+ read from the env variable `?'. */
+ ret = grub_script_execute_cmd (cmdif->exec_to_evaluate);
+ if (function_return)
+ return ret;
+
+ result = grub_env_get ("?");
+ grub_errno = GRUB_ERR_NONE;
+
+ /* Execute the `if' or the `else' part depending on the value of
+ `?'. */
+ if (result && ! grub_strcmp (result, "0"))
+ return grub_script_execute_cmd (cmdif->exec_on_true);
+ else
+ return grub_script_execute_cmd (cmdif->exec_on_false);
+}
+
+/* Execute a for statement. */
+grub_err_t
+grub_script_execute_cmdfor (struct grub_script_cmd *cmd)
+{
+ unsigned i;
+ grub_err_t result;
+ struct grub_script_argv argv = { 0, 0, 0 };
+ struct grub_script_cmdfor *cmdfor = (struct grub_script_cmdfor *) cmd;
+
+ if (grub_script_arglist_to_argv (cmdfor->words, &argv))
+ return grub_errno;
+
+ active_loops++;
+ result = 0;
+ for (i = 0; i < argv.argc; i++)
+ {
+ if (is_continue && active_breaks == 1)
+ active_breaks = 0;
+
+ if (! active_breaks)
+ {
+ grub_script_env_set (cmdfor->name->str, argv.args[i]);
+ result = grub_script_execute_cmd (cmdfor->list);
+ if (function_return)
+ break;
+ }
+ }
+
+ if (active_breaks)
+ active_breaks--;
+
+ active_loops--;
+ grub_script_argv_free (&argv);
+ return result;
+}
+
+/* Execute a "while" or "until" command. */
+grub_err_t
+grub_script_execute_cmdwhile (struct grub_script_cmd *cmd)
+{
+ int result;
+ struct grub_script_cmdwhile *cmdwhile = (struct grub_script_cmdwhile *) cmd;
+
+ active_loops++;
+ do {
+ result = grub_script_execute_cmd (cmdwhile->cond);
+ if (function_return)
+ break;
+
+ if (cmdwhile->until ? !result : result)
+ break;
+
+ result = grub_script_execute_cmd (cmdwhile->list);
+ if (function_return)
+ break;
+
+ if (active_breaks == 1 && is_continue)
+ active_breaks = 0;
+
+ if (active_breaks)
+ break;
+
+ } while (1); /* XXX Put a check for ^C here */
+
+ if (active_breaks)
+ active_breaks--;
+
+ active_loops--;
+ return result;
+}
+
+/* Execute any GRUB pre-parsed command or script. */
+grub_err_t
+grub_script_execute (struct grub_script *script)
+{
+ if (script == 0)
+ return 0;
+
+ return grub_script_execute_cmd (script->cmd);
+}
diff --git a/grub-core/script/function.c b/grub-core/script/function.c
new file mode 100644
index 0000000..3aad04b
--- /dev/null
+++ b/grub-core/script/function.c
@@ -0,0 +1,123 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/script_sh.h>
+#include <grub/parser.h>
+#include <grub/mm.h>
+#include <grub/charset.h>
+
+grub_script_function_t grub_script_function_list;
+
+grub_script_function_t
+grub_script_function_create (struct grub_script_arg *functionname_arg,
+ struct grub_script *cmd)
+{
+ grub_script_function_t func;
+ grub_script_function_t *p;
+
+ func = (grub_script_function_t) grub_malloc (sizeof (*func));
+ if (! func)
+ return 0;
+ func->executing = 0;
+
+ func->name = grub_strdup (functionname_arg->str);
+ if (! func->name)
+ {
+ grub_free (func);
+ return 0;
+ }
+
+ func->func = cmd;
+
+ /* Keep the list sorted for simplicity. */
+ p = &grub_script_function_list;
+ while (*p)
+ {
+ if (grub_strcmp ((*p)->name, func->name) >= 0)
+ break;
+
+ p = &((*p)->next);
+ }
+
+ /* If the function already exists, overwrite the old function. */
+ if (*p && grub_strcmp ((*p)->name, func->name) == 0)
+ {
+ grub_script_function_t q;
+
+ q = *p;
+ grub_free (func);
+ if (q->executing > 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("attempt to redefine a function being executed"));
+ func = NULL;
+ }
+ else
+ {
+ grub_script_free (q->func);
+ q->func = cmd;
+ func = q;
+ }
+ }
+ else
+ {
+ func->next = *p;
+ *p = func;
+ }
+
+ return func;
+}
+
+void
+grub_script_function_remove (const char *name)
+{
+ grub_script_function_t *p, q;
+
+ for (p = &grub_script_function_list, q = *p; q; p = &(q->next), q = q->next)
+ if (grub_strcmp (name, q->name) == 0)
+ {
+ *p = q->next;
+ grub_free (q->name);
+ grub_script_free (q->func);
+ grub_free (q);
+ break;
+ }
+}
+
+grub_script_function_t
+grub_script_function_find (char *functionname)
+{
+ grub_script_function_t func;
+
+ for (func = grub_script_function_list; func; func = func->next)
+ if (grub_strcmp (functionname, func->name) == 0)
+ break;
+
+ if (! func)
+ {
+ char tmp[21];
+ grub_strncpy (tmp, functionname, 20);
+ tmp[20] = 0;
+ /* Avoid truncating inside UTF-8 character. */
+ tmp[grub_getend (tmp, tmp + grub_strlen (tmp))] = 0;
+ grub_error (GRUB_ERR_UNKNOWN_COMMAND, N_("can't find command `%s'"), tmp);
+ }
+
+ return func;
+}
diff --git a/grub-core/script/lexer.c b/grub-core/script/lexer.c
new file mode 100644
index 0000000..52004d0
--- /dev/null
+++ b/grub-core/script/lexer.c
@@ -0,0 +1,356 @@
+/* lexer.c - The scripting lexer. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include <grub/parser.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/script_sh.h>
+#include <grub/i18n.h>
+#include <grub/safemath.h>
+
+#define yytext_ptr char *
+#include "grub_script.tab.h"
+#include "grub_script.yy.h"
+
+void
+grub_script_lexer_ref (struct grub_lexer_param *state)
+{
+ state->refs++;
+}
+
+void
+grub_script_lexer_deref (struct grub_lexer_param *state)
+{
+ state->refs--;
+}
+
+/* Start recording all characters passing through the lexer. */
+unsigned
+grub_script_lexer_record_start (struct grub_parser_param *parser)
+{
+ struct grub_lexer_param *lexer = parser->lexerstate;
+
+ lexer->record++;
+ if (lexer->recording)
+ return lexer->recordpos;
+
+ lexer->recordpos = 0;
+ lexer->recordlen = GRUB_LEXER_INITIAL_RECORD_SIZE;
+ lexer->recording = grub_malloc (lexer->recordlen);
+ if (!lexer->recording)
+ {
+ grub_script_yyerror (parser, 0);
+ lexer->recordlen = 0;
+ }
+ return lexer->recordpos;
+}
+
+char *
+grub_script_lexer_record_stop (struct grub_parser_param *parser, unsigned offset)
+{
+ int count;
+ char *result;
+ struct grub_lexer_param *lexer = parser->lexerstate;
+
+ if (!lexer->record)
+ return 0;
+
+ lexer->record--;
+ if (!lexer->recording)
+ return 0;
+
+ count = lexer->recordpos - offset;
+ result = grub_script_malloc (parser, count + 1);
+ if (result) {
+ grub_strncpy (result, lexer->recording + offset, count);
+ result[count] = '\0';
+ }
+
+ if (lexer->record == 0)
+ {
+ grub_free (lexer->recording);
+ lexer->recording = 0;
+ lexer->recordlen = 0;
+ lexer->recordpos = 0;
+ }
+ return result;
+}
+
+/* Record STR if input recording is enabled. */
+void
+grub_script_lexer_record (struct grub_parser_param *parser, char *str)
+{
+ int len;
+ char *old;
+ struct grub_lexer_param *lexer = parser->lexerstate;
+
+ if (!lexer->record || !lexer->recording)
+ return;
+
+ len = grub_strlen (str);
+ if (lexer->recordpos + len + 1 > lexer->recordlen)
+ {
+ old = lexer->recording;
+ if (lexer->recordlen < len)
+ lexer->recordlen = len;
+
+ if (grub_mul (lexer->recordlen, 2, &lexer->recordlen))
+ goto fail;
+
+ lexer->recording = grub_realloc (lexer->recording, lexer->recordlen);
+ if (!lexer->recording)
+ {
+ fail:
+ grub_free (old);
+ lexer->recordpos = 0;
+ lexer->recordlen = 0;
+ grub_script_yyerror (parser, 0);
+ return;
+ }
+ }
+ grub_strcpy (lexer->recording + lexer->recordpos, str);
+ lexer->recordpos += len;
+}
+
+/* Read next line of input if necessary, and set yyscanner buffers. */
+int
+grub_script_lexer_yywrap (struct grub_parser_param *parserstate,
+ const char *input)
+{
+ grub_size_t len = 0, sz;
+ char *p = 0;
+ char *line = 0;
+ YY_BUFFER_STATE buffer;
+ struct grub_lexer_param *lexerstate = parserstate->lexerstate;
+
+ if (! lexerstate->refs && ! lexerstate->prefix && ! input)
+ return 1;
+
+ if (! lexerstate->getline && ! input)
+ {
+ grub_script_yyerror (parserstate, N_("unexpected end of file"));
+ return 1;
+ }
+
+ line = 0;
+ if (! input)
+ lexerstate->getline (&line, 1, lexerstate->getline_data);
+ else
+ line = grub_strdup (input);
+
+ if (! line)
+ {
+ grub_script_yyerror (parserstate, N_("out of memory"));
+ return 1;
+ }
+
+ len = grub_strlen (line);
+
+ /* Ensure '\n' at the end. */
+ if (line[0] == '\0')
+ {
+ grub_free (line);
+ line = grub_strdup ("\n");
+ len = 1;
+ }
+ else if (len && line[len - 1] != '\n')
+ {
+ if (grub_add (len, 2, &sz))
+ {
+ grub_free (line);
+ grub_script_yyerror (parserstate, N_("overflow is detected"));
+ return 1;
+ }
+
+ p = grub_realloc (line, sz);
+ if (p)
+ {
+ p[len++] = '\n';
+ p[len] = '\0';
+ }
+ else
+ grub_free (line);
+
+ line = p;
+ }
+
+ if (! line)
+ {
+ grub_script_yyerror (parserstate, N_("out of memory"));
+ return 1;
+ }
+
+ /* Prepend any left over unput-text. */
+ if (lexerstate->prefix)
+ {
+ int plen = grub_strlen (lexerstate->prefix);
+
+ p = grub_malloc (len + plen + 1);
+ if (! p)
+ {
+ grub_free (line);
+ return 1;
+ }
+ grub_strcpy (p, lexerstate->prefix);
+ lexerstate->prefix = 0;
+
+ grub_strcpy (p + plen, line);
+ grub_free (line);
+
+ line = p;
+ len = len + plen;
+ }
+
+ buffer = yy_scan_string (line, lexerstate->yyscanner);
+ grub_free (line);
+
+ if (! buffer)
+ {
+ grub_script_yyerror (parserstate, 0);
+ return 1;
+ }
+ return 0;
+}
+
+struct grub_lexer_param *
+grub_script_lexer_init (struct grub_parser_param *parser, char *script,
+ grub_reader_getline_t arg_getline, void *getline_data)
+{
+ struct grub_lexer_param *lexerstate;
+
+ lexerstate = grub_zalloc (sizeof (*lexerstate));
+ if (!lexerstate)
+ return 0;
+
+ lexerstate->size = GRUB_LEXER_INITIAL_TEXT_SIZE;
+ lexerstate->text = grub_malloc (lexerstate->size);
+ if (!lexerstate->text)
+ {
+ grub_free (lexerstate);
+ return 0;
+ }
+
+ lexerstate->getline = arg_getline;
+ lexerstate->getline_data = getline_data;
+ /* The other elements of lexerstate are all zeros already. */
+
+ if (yylex_init (&lexerstate->yyscanner))
+ {
+ grub_free (lexerstate->text);
+ grub_free (lexerstate);
+ return 0;
+ }
+
+ yyset_extra (parser, lexerstate->yyscanner);
+ parser->lexerstate = lexerstate;
+
+ if (grub_script_lexer_yywrap (parser, script ?: "\n"))
+ {
+ parser->lexerstate = 0;
+ yylex_destroy (lexerstate->yyscanner);
+ grub_free (lexerstate->text);
+ grub_free (lexerstate);
+ return 0;
+ }
+
+ return lexerstate;
+}
+
+void
+grub_script_lexer_fini (struct grub_lexer_param *lexerstate)
+{
+ if (!lexerstate)
+ return;
+
+ yylex_destroy (lexerstate->yyscanner);
+
+ grub_free (lexerstate->recording);
+ grub_free (lexerstate->text);
+ grub_free (lexerstate);
+}
+
+int
+grub_script_yylex (union YYSTYPE *value,
+ struct grub_parser_param *parserstate)
+{
+ char *str;
+ int token;
+ grub_script_arg_type_t type;
+ struct grub_lexer_param *lexerstate = parserstate->lexerstate;
+
+ value->arg = 0;
+ if (parserstate->err)
+ return GRUB_PARSER_TOKEN_BAD;
+
+ if (lexerstate->eof)
+ return GRUB_PARSER_TOKEN_EOF;
+
+ /*
+ * Words with environment variables, like foo${bar}baz needs
+ * multiple tokens to be merged into a single grub_script_arg. We
+ * use two variables to achieve this: lexerstate->merge_start and
+ * lexerstate->merge_end
+ */
+
+ lexerstate->merge_start = 0;
+ lexerstate->merge_end = 0;
+ do
+ {
+ /* Empty lexerstate->text. */
+ lexerstate->used = 1;
+ lexerstate->text[0] = '\0';
+
+ token = yylex (value, lexerstate->yyscanner);
+ if (token == GRUB_PARSER_TOKEN_BAD)
+ break;
+
+ /* Merging feature uses lexerstate->text instead of yytext. */
+ if (lexerstate->merge_start)
+ {
+ str = lexerstate->text;
+ type = lexerstate->type;
+ }
+ else
+ {
+ str = yyget_text (lexerstate->yyscanner);
+ type = GRUB_SCRIPT_ARG_TYPE_TEXT;
+ }
+ grub_dprintf("lexer", "token %u text [%s]\n", token, str);
+
+ value->arg = grub_script_arg_add (parserstate, value->arg, type, str);
+ }
+ while (lexerstate->merge_start && !lexerstate->merge_end);
+
+ if (!value->arg || parserstate->err)
+ return GRUB_PARSER_TOKEN_BAD;
+
+ return token;
+}
+
+void
+grub_script_yyerror (struct grub_parser_param *state, const char *err)
+{
+ if (err)
+ grub_error (GRUB_ERR_INVALID_COMMAND, "%s", err);
+
+ grub_print_error ();
+ state->err++;
+}
diff --git a/grub-core/script/main.c b/grub-core/script/main.c
new file mode 100644
index 0000000..854a25a
--- /dev/null
+++ b/grub-core/script/main.c
@@ -0,0 +1,98 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/i18n.h>
+#include <grub/parser.h>
+#include <grub/script_sh.h>
+
+grub_err_t
+grub_normal_parse_line (char *line,
+ grub_reader_getline_t getline, void *getline_data)
+{
+ struct grub_script *parsed_script;
+
+ /* Parse the script. */
+ parsed_script = grub_script_parse (line, getline, getline_data);
+
+ if (parsed_script)
+ {
+ /* Execute the command(s). */
+ grub_script_execute (parsed_script);
+
+ /* The parsed script was executed, throw it away. */
+ grub_script_unref (parsed_script);
+ }
+
+ return grub_errno;
+}
+
+static grub_command_t cmd_break;
+static grub_command_t cmd_continue;
+static grub_command_t cmd_shift;
+static grub_command_t cmd_setparams;
+static grub_command_t cmd_return;
+
+void
+grub_script_init (void)
+{
+ cmd_break = grub_register_command ("break", grub_script_break,
+ N_("[NUM]"), N_("Exit from loops"));
+ cmd_continue = grub_register_command ("continue", grub_script_break,
+ N_("[NUM]"), N_("Continue loops"));
+ cmd_shift = grub_register_command ("shift", grub_script_shift,
+ N_("[NUM]"),
+ /* TRANSLATORS: Positional arguments are
+ arguments $0, $1, $2, ... */
+ N_("Shift positional parameters."));
+ cmd_setparams = grub_register_command ("setparams", grub_script_setparams,
+ N_("[VALUE]..."),
+ N_("Set positional parameters."));
+ cmd_return = grub_register_command ("return", grub_script_return,
+ N_("[NUM]"),
+ /* TRANSLATORS: It's a command description
+ and "Return" is a verb, not a noun. The
+ command in question is "return" and
+ has exactly the same semanics as bash
+ equivalent. */
+ N_("Return from a function."));
+}
+
+void
+grub_script_fini (void)
+{
+ if (cmd_break)
+ grub_unregister_command (cmd_break);
+ cmd_break = 0;
+
+ if (cmd_continue)
+ grub_unregister_command (cmd_continue);
+ cmd_continue = 0;
+
+ if (cmd_shift)
+ grub_unregister_command (cmd_shift);
+ cmd_shift = 0;
+
+ if (cmd_setparams)
+ grub_unregister_command (cmd_setparams);
+ cmd_setparams = 0;
+
+ if (cmd_return)
+ grub_unregister_command (cmd_return);
+ cmd_return = 0;
+}
diff --git a/grub-core/script/parser.y b/grub-core/script/parser.y
new file mode 100644
index 0000000..4a18ab7
--- /dev/null
+++ b/grub-core/script/parser.y
@@ -0,0 +1,356 @@
+/* parser.y - The scripting parser. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+%{
+#include <grub/script_sh.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+
+#define YYFREE grub_free
+#define YYMALLOC grub_malloc
+#define YYLTYPE_IS_TRIVIAL 0
+#define YYENABLE_NLS 0
+
+#include "grub_script.tab.h"
+
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+
+%}
+
+%union {
+ struct grub_script_cmd *cmd;
+ struct grub_script_arglist *arglist;
+ struct grub_script_arg *arg;
+ char *string;
+ struct {
+ unsigned offset;
+ struct grub_script_mem *memory;
+ struct grub_script *scripts;
+ };
+}
+
+%token GRUB_PARSER_TOKEN_BAD
+%token GRUB_PARSER_TOKEN_EOF 0 "end-of-input"
+
+%token GRUB_PARSER_TOKEN_NEWLINE "\n"
+%token GRUB_PARSER_TOKEN_AND "&&"
+%token GRUB_PARSER_TOKEN_OR "||"
+%token GRUB_PARSER_TOKEN_SEMI2 ";;"
+%token GRUB_PARSER_TOKEN_PIPE "|"
+%token GRUB_PARSER_TOKEN_AMP "&"
+%token GRUB_PARSER_TOKEN_SEMI ";"
+%token GRUB_PARSER_TOKEN_LBR "{"
+%token GRUB_PARSER_TOKEN_RBR "}"
+%token GRUB_PARSER_TOKEN_NOT "!"
+%token GRUB_PARSER_TOKEN_LSQBR2 "["
+%token GRUB_PARSER_TOKEN_RSQBR2 "]"
+%token GRUB_PARSER_TOKEN_LT "<"
+%token GRUB_PARSER_TOKEN_GT ">"
+
+%token <arg> GRUB_PARSER_TOKEN_CASE "case"
+%token <arg> GRUB_PARSER_TOKEN_DO "do"
+%token <arg> GRUB_PARSER_TOKEN_DONE "done"
+%token <arg> GRUB_PARSER_TOKEN_ELIF "elif"
+%token <arg> GRUB_PARSER_TOKEN_ELSE "else"
+%token <arg> GRUB_PARSER_TOKEN_ESAC "esac"
+%token <arg> GRUB_PARSER_TOKEN_FI "fi"
+%token <arg> GRUB_PARSER_TOKEN_FOR "for"
+%token <arg> GRUB_PARSER_TOKEN_IF "if"
+%token <arg> GRUB_PARSER_TOKEN_IN "in"
+%token <arg> GRUB_PARSER_TOKEN_SELECT "select"
+%token <arg> GRUB_PARSER_TOKEN_THEN "then"
+%token <arg> GRUB_PARSER_TOKEN_UNTIL "until"
+%token <arg> GRUB_PARSER_TOKEN_WHILE "while"
+%token <arg> GRUB_PARSER_TOKEN_FUNCTION "function"
+%token <arg> GRUB_PARSER_TOKEN_NAME "name"
+%token <arg> GRUB_PARSER_TOKEN_WORD "word"
+
+%type <arg> block block0
+%type <arglist> word argument arguments0 arguments1
+
+%type <cmd> script_init script
+%type <cmd> grubcmd ifclause ifcmd forcmd whilecmd untilcmd
+%type <cmd> command commands1 statement
+
+%pure-parser
+%lex-param { struct grub_parser_param *state };
+%parse-param { struct grub_parser_param *state };
+
+%start script_init
+
+%%
+/* It should be possible to do this in a clean way... */
+script_init: { state->err = 0; } script { state->parsed = $2; state->err = 0; }
+;
+
+script: newlines0
+ {
+ $$ = 0;
+ }
+ | script statement delimiter newlines0
+ {
+ $$ = grub_script_append_cmd (state, $1, $2);
+ }
+ | error
+ {
+ $$ = 0;
+ yyerror (state, N_("Incorrect command"));
+ yyerrok;
+ }
+;
+
+newlines0: /* Empty */ | newlines1 ;
+newlines1: newlines0 "\n" ;
+
+delimiter: ";"
+ | "\n"
+;
+delimiters0: /* Empty */ | delimiters1 ;
+delimiters1: delimiter
+ | delimiters1 "\n"
+;
+
+word: GRUB_PARSER_TOKEN_NAME { $$ = grub_script_add_arglist (state, 0, $1); }
+ | GRUB_PARSER_TOKEN_WORD { $$ = grub_script_add_arglist (state, 0, $1); }
+;
+
+statement: command { $$ = $1; }
+ | function { $$ = 0; }
+;
+
+argument : "case" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "do" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "done" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "elif" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "else" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "esac" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "fi" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "for" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "if" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "in" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "select" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "then" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "until" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "while" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | "function" { $$ = grub_script_add_arglist (state, 0, $1); }
+ | word { $$ = $1; }
+;
+
+/*
+ Block parameter is passed to commands in two forms: as unparsed
+ string and as pre-parsed grub_script object. Passing as grub_script
+ object makes memory management difficult, because:
+
+ (1) Command may want to keep a reference to grub_script objects for
+ later use, so script framework may not free the grub_script
+ object after command completes.
+
+ (2) Command may get called multiple times with same grub_script
+ object under loops, so we should not let command implementation
+ to free the grub_script object.
+
+ To solve above problems, we rely on reference counting for
+ grub_script objects. Commands that want to keep the grub_script
+ object must take a reference to it.
+
+ Other complexity comes with arbitrary nesting of grub_script
+ objects: a grub_script object may have commands with several block
+ parameters, and each block parameter may further contain multiple
+ block parameters nested. We use temporary variable, state->scripts
+ to collect nested child scripts (that are linked by siblings and
+ children members), and will build grub_scripts tree from bottom.
+ */
+block: "{"
+ {
+ grub_script_lexer_ref (state->lexerstate);
+ $<offset>$ = grub_script_lexer_record_start (state);
+ $<memory>$ = grub_script_mem_record (state);
+
+ /* save currently known scripts. */
+ $<scripts>$ = state->scripts;
+ state->scripts = 0;
+ }
+ commands1 delimiters0 "}"
+ {
+ char *p;
+ struct grub_script_mem *memory;
+ struct grub_script *s = $<scripts>2;
+
+ memory = grub_script_mem_record_stop (state, $<memory>2);
+ if ((p = grub_script_lexer_record_stop (state, $<offset>2)))
+ *grub_strrchr (p, '}') = '\0';
+
+ $$ = grub_script_arg_add (state, 0, GRUB_SCRIPT_ARG_TYPE_BLOCK, p);
+ if (! $$ || ! ($$->script = grub_script_create ($3, memory)))
+ grub_script_mem_free (memory);
+
+ else {
+ /* attach nested scripts to $$->script as children */
+ $$->script->children = state->scripts;
+
+ /* restore old scripts; append $$->script to siblings. */
+ state->scripts = $<scripts>2 ?: $$->script;
+ if (s) {
+ while (s->next_siblings)
+ s = s->next_siblings;
+ s->next_siblings = $$->script;
+ }
+ }
+
+ grub_script_lexer_deref (state->lexerstate);
+ }
+;
+block0: /* Empty */ { $$ = 0; }
+ | block { $$ = $1; }
+;
+
+arguments0: /* Empty */ { $$ = 0; }
+ | arguments1 { $$ = $1; }
+;
+arguments1: argument arguments0
+ {
+ if ($1 && $2)
+ {
+ $1->next = $2;
+ $1->argcount += $2->argcount;
+ $2->argcount = 0;
+ }
+ $$ = $1;
+ }
+;
+
+grubcmd: word arguments0 block0
+ {
+ struct grub_script_arglist *x = $2;
+
+ if ($3)
+ x = grub_script_add_arglist (state, $2, $3);
+
+ if ($1 && x) {
+ $1->next = x;
+ $1->argcount += x->argcount;
+ x->argcount = 0;
+ }
+ $$ = grub_script_create_cmdline (state, $1);
+ }
+;
+
+/* A single command. */
+command: grubcmd { $$ = $1; }
+ | ifcmd { $$ = $1; }
+ | forcmd { $$ = $1; }
+ | whilecmd { $$ = $1; }
+ | untilcmd { $$ = $1; }
+;
+
+/* A list of commands. */
+commands1: newlines0 command
+ {
+ $$ = grub_script_append_cmd (state, 0, $2);
+ }
+ | commands1 delimiters1 command
+ {
+ $$ = grub_script_append_cmd (state, $1, $3);
+ }
+;
+
+function: "function" "name"
+ {
+ grub_script_lexer_ref (state->lexerstate);
+ state->func_mem = grub_script_mem_record (state);
+
+ $<scripts>$ = state->scripts;
+ state->scripts = 0;
+ }
+ newlines0 "{" commands1 delimiters1 "}"
+ {
+ struct grub_script *script;
+ state->func_mem = grub_script_mem_record_stop (state,
+ state->func_mem);
+ script = grub_script_create ($6, state->func_mem);
+ if (! script)
+ grub_script_mem_free (state->func_mem);
+ else {
+ script->children = state->scripts;
+ if (!grub_script_function_create ($2, script))
+ grub_script_free (script);
+ }
+
+ state->scripts = $<scripts>3;
+ grub_script_lexer_deref (state->lexerstate);
+ }
+;
+
+ifcmd: "if"
+ {
+ grub_script_lexer_ref (state->lexerstate);
+ }
+ ifclause "fi"
+ {
+ $$ = $3;
+ grub_script_lexer_deref (state->lexerstate);
+ }
+;
+ifclause: commands1 delimiters1 "then" commands1 delimiters1
+ {
+ $$ = grub_script_create_cmdif (state, $1, $4, 0);
+ }
+ | commands1 delimiters1 "then" commands1 delimiters1 "else" commands1 delimiters1
+ {
+ $$ = grub_script_create_cmdif (state, $1, $4, $7);
+ }
+ | commands1 delimiters1 "then" commands1 delimiters1 "elif" ifclause
+ {
+ $$ = grub_script_create_cmdif (state, $1, $4, $7);
+ }
+;
+
+forcmd: "for" "name"
+ {
+ grub_script_lexer_ref (state->lexerstate);
+ }
+ "in" arguments0 delimiters1 "do" commands1 delimiters1 "done"
+ {
+ $$ = grub_script_create_cmdfor (state, $2, $5, $8);
+ grub_script_lexer_deref (state->lexerstate);
+ }
+;
+
+whilecmd: "while"
+ {
+ grub_script_lexer_ref (state->lexerstate);
+ }
+ commands1 delimiters1 "do" commands1 delimiters1 "done"
+ {
+ $$ = grub_script_create_cmdwhile (state, $3, $6, 0);
+ grub_script_lexer_deref (state->lexerstate);
+ }
+;
+
+untilcmd: "until"
+ {
+ grub_script_lexer_ref (state->lexerstate);
+ }
+ commands1 delimiters1 "do" commands1 delimiters1 "done"
+ {
+ $$ = grub_script_create_cmdwhile (state, $3, $6, 1);
+ grub_script_lexer_deref (state->lexerstate);
+ }
+;
diff --git a/grub-core/script/script.c b/grub-core/script/script.c
new file mode 100644
index 0000000..ec4d433
--- /dev/null
+++ b/grub-core/script/script.c
@@ -0,0 +1,396 @@
+/* script.c -- Functions to create an in memory description of the script. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/script_sh.h>
+#include <grub/parser.h>
+#include <grub/mm.h>
+
+/* It is not possible to deallocate the memory when a syntax error was
+ found. Because of that it is required to keep track of all memory
+ allocations. The memory is freed in case of an error, or assigned
+ to the parsed script when parsing was successful.
+
+ In case of the normal malloc, some additional bytes are allocated
+ for this datastructure. All reserved memory is stored in a linked
+ list so it can be easily freed. The original memory can be found
+ from &mem. */
+struct grub_script_mem
+{
+ struct grub_script_mem *next;
+ char mem;
+};
+
+/* Return malloc'ed memory and keep track of the allocation. */
+void *
+grub_script_malloc (struct grub_parser_param *state, grub_size_t size)
+{
+ struct grub_script_mem *mem;
+ mem = (struct grub_script_mem *) grub_malloc (size + sizeof (*mem)
+ - sizeof (char));
+ if (!mem)
+ return 0;
+
+ grub_dprintf ("scripting", "malloc %p\n", mem);
+ mem->next = state->memused;
+ state->memused = mem;
+ return (void *) &mem->mem;
+}
+
+/* Free all memory described by MEM. */
+void
+grub_script_mem_free (struct grub_script_mem *mem)
+{
+ struct grub_script_mem *memfree;
+
+ while (mem)
+ {
+ memfree = mem->next;
+ grub_dprintf ("scripting", "free %p\n", mem);
+ grub_free (mem);
+ mem = memfree;
+ }
+}
+
+/* Start recording memory usage. Returns the memory that should be
+ restored when calling stop. */
+struct grub_script_mem *
+grub_script_mem_record (struct grub_parser_param *state)
+{
+ struct grub_script_mem *mem = state->memused;
+ state->memused = 0;
+
+ return mem;
+}
+
+/* Stop recording memory usage. Restore previous recordings using
+ RESTORE. Return the recorded memory. */
+struct grub_script_mem *
+grub_script_mem_record_stop (struct grub_parser_param *state,
+ struct grub_script_mem *restore)
+{
+ struct grub_script_mem *mem = state->memused;
+ state->memused = restore;
+ return mem;
+}
+
+/* Free the memory reserved for CMD and all of it's children. */
+void
+grub_script_free (struct grub_script *script)
+{
+ struct grub_script *s;
+ struct grub_script *t;
+
+ if (! script)
+ return;
+
+ if (script->mem)
+ grub_script_mem_free (script->mem);
+
+ s = script->children;
+ while (s) {
+ t = s->next_siblings;
+ grub_script_unref (s);
+ s = t;
+ }
+ grub_free (script);
+}
+
+
+
+/* Extend the argument arg with a variable or string of text. If ARG
+ is zero a new list is created. */
+struct grub_script_arg *
+grub_script_arg_add (struct grub_parser_param *state,
+ struct grub_script_arg *arg, grub_script_arg_type_t type,
+ char *str)
+{
+ struct grub_script_arg *argpart;
+ struct grub_script_arg *ll;
+ int len;
+
+ argpart =
+ (struct grub_script_arg *) grub_script_malloc (state, sizeof (*arg));
+ if (!argpart)
+ return arg;
+
+ argpart->type = type;
+ argpart->script = 0;
+
+ len = grub_strlen (str) + 1;
+ argpart->str = grub_script_malloc (state, len);
+ if (!argpart->str)
+ return arg; /* argpart is freed later, during grub_script_free. */
+
+ grub_memcpy (argpart->str, str, len);
+ argpart->next = 0;
+
+ if (!arg)
+ return argpart;
+
+ for (ll = arg; ll->next; ll = ll->next);
+ ll->next = argpart;
+
+ return arg;
+}
+
+/* Add the argument ARG to the end of the argument list LIST. If LIST
+ is zero, a new list will be created. */
+struct grub_script_arglist *
+grub_script_add_arglist (struct grub_parser_param *state,
+ struct grub_script_arglist *list,
+ struct grub_script_arg *arg)
+{
+ struct grub_script_arglist *link;
+ struct grub_script_arglist *ll;
+
+ grub_dprintf ("scripting", "arglist\n");
+
+ link =
+ (struct grub_script_arglist *) grub_script_malloc (state, sizeof (*link));
+ if (!link)
+ return list;
+
+ link->next = 0;
+ link->arg = arg;
+ link->argcount = 0;
+
+ if (!list)
+ {
+ link->argcount++;
+ return link;
+ }
+
+ list->argcount++;
+
+ /* Look up the last link in the chain. */
+ for (ll = list; ll->next; ll = ll->next);
+ ll->next = link;
+
+ return list;
+}
+
+/* Create a command that describes a single command line. CMDLINE
+ contains the name of the command that should be executed. ARGLIST
+ holds all arguments for this command. */
+struct grub_script_cmd *
+grub_script_create_cmdline (struct grub_parser_param *state,
+ struct grub_script_arglist *arglist)
+{
+ struct grub_script_cmdline *cmd;
+
+ grub_dprintf ("scripting", "cmdline\n");
+
+ cmd = grub_script_malloc (state, sizeof (*cmd));
+ if (!cmd)
+ return 0;
+
+ cmd->cmd.exec = grub_script_execute_cmdline;
+ cmd->cmd.next = 0;
+ cmd->arglist = arglist;
+
+ return (struct grub_script_cmd *) cmd;
+}
+
+/* Create a command that functions as an if statement. If BOOL is
+ evaluated to true (the value is returned in envvar '?'), the
+ interpreter will run the command TRUE, otherwise the interpreter
+ runs the command FALSE. */
+struct grub_script_cmd *
+grub_script_create_cmdif (struct grub_parser_param *state,
+ struct grub_script_cmd *exec_to_evaluate,
+ struct grub_script_cmd *exec_on_true,
+ struct grub_script_cmd *exec_on_false)
+{
+ struct grub_script_cmdif *cmd;
+
+ grub_dprintf ("scripting", "cmdif\n");
+
+ cmd = grub_script_malloc (state, sizeof (*cmd));
+ if (!cmd)
+ return 0;
+
+ cmd->cmd.exec = grub_script_execute_cmdif;
+ cmd->cmd.next = 0;
+ cmd->exec_to_evaluate = exec_to_evaluate;
+ cmd->exec_on_true = exec_on_true;
+ cmd->exec_on_false = exec_on_false;
+
+ return (struct grub_script_cmd *) cmd;
+}
+
+/* Create a command that functions as a for statement. */
+struct grub_script_cmd *
+grub_script_create_cmdfor (struct grub_parser_param *state,
+ struct grub_script_arg *name,
+ struct grub_script_arglist *words,
+ struct grub_script_cmd *list)
+{
+ struct grub_script_cmdfor *cmd;
+
+ grub_dprintf ("scripting", "cmdfor\n");
+
+ cmd = grub_script_malloc (state, sizeof (*cmd));
+ if (! cmd)
+ return 0;
+
+ cmd->cmd.exec = grub_script_execute_cmdfor;
+ cmd->cmd.next = 0;
+ cmd->name = name;
+ cmd->words = words;
+ cmd->list = list;
+
+ return (struct grub_script_cmd *) cmd;
+}
+
+/* Create a "while" or "until" command. */
+struct grub_script_cmd *
+grub_script_create_cmdwhile (struct grub_parser_param *state,
+ struct grub_script_cmd *cond,
+ struct grub_script_cmd *list,
+ int is_an_until_loop)
+{
+ struct grub_script_cmdwhile *cmd;
+
+ cmd = grub_script_malloc (state, sizeof (*cmd));
+ if (! cmd)
+ return 0;
+
+ cmd->cmd.exec = grub_script_execute_cmdwhile;
+ cmd->cmd.next = 0;
+ cmd->cond = cond;
+ cmd->list = list;
+ cmd->until = is_an_until_loop;
+
+ return (struct grub_script_cmd *) cmd;
+}
+
+/* Create a chain of commands. LAST contains the command that should
+ be added at the end of LIST's list. If LIST is zero, a new list
+ will be created. */
+struct grub_script_cmd *
+grub_script_append_cmd (struct grub_parser_param *state,
+ struct grub_script_cmd *list,
+ struct grub_script_cmd *last)
+{
+ struct grub_script_cmd *ptr;
+
+ grub_dprintf ("scripting", "append command\n");
+
+ if (! last)
+ return list;
+
+ if (! list)
+ {
+ list = grub_script_malloc (state, sizeof (*list));
+ if (! list)
+ return 0;
+
+ list->exec = grub_script_execute_cmdlist;
+ list->next = last;
+ }
+ else
+ {
+ ptr = list;
+ while (ptr->next)
+ ptr = ptr->next;
+
+ ptr->next = last;
+ }
+
+ return list;
+}
+
+
+
+struct grub_script *
+grub_script_create (struct grub_script_cmd *cmd, struct grub_script_mem *mem)
+{
+ struct grub_script *parsed;
+
+ parsed = grub_malloc (sizeof (*parsed));
+ if (! parsed)
+ return 0;
+
+ parsed->mem = mem;
+ parsed->cmd = cmd;
+ parsed->refcnt = 0;
+ parsed->children = 0;
+ parsed->next_siblings = 0;
+
+ return parsed;
+}
+
+/* Parse the script passed in SCRIPT and return the parsed
+ datastructure that is ready to be interpreted. */
+struct grub_script *
+grub_script_parse (char *script,
+ grub_reader_getline_t getline, void *getline_data)
+{
+ struct grub_script *parsed;
+ struct grub_script_mem *membackup;
+ struct grub_lexer_param *lexstate;
+ struct grub_parser_param *parsestate;
+
+ parsed = grub_script_create (0, 0);
+ if (!parsed)
+ return 0;
+
+ parsestate = grub_zalloc (sizeof (*parsestate));
+ if (!parsestate)
+ {
+ grub_free (parsed);
+ return 0;
+ }
+
+ /* Initialize the lexer. */
+ lexstate = grub_script_lexer_init (parsestate, script,
+ getline, getline_data);
+ if (!lexstate)
+ {
+ grub_free (parsed);
+ grub_free (parsestate);
+ return 0;
+ }
+
+ parsestate->lexerstate = lexstate;
+
+ membackup = grub_script_mem_record (parsestate);
+
+ /* Parse the script. */
+ if (grub_script_yyparse (parsestate) || parsestate->err)
+ {
+ struct grub_script_mem *memfree;
+ memfree = grub_script_mem_record_stop (parsestate, membackup);
+ grub_script_mem_free (memfree);
+ grub_script_lexer_fini (lexstate);
+ grub_free (parsestate);
+ grub_free (parsed);
+ return 0;
+ }
+
+ parsed->mem = grub_script_mem_record_stop (parsestate, membackup);
+ parsed->cmd = parsestate->parsed;
+ parsed->children = parsestate->scripts;
+
+ grub_script_lexer_fini (lexstate);
+ grub_free (parsestate);
+
+ return parsed;
+}
diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l
new file mode 100644
index 0000000..b7203c8
--- /dev/null
+++ b/grub-core/script/yylex.l
@@ -0,0 +1,393 @@
+%{
+/* yylex.l The scripting lexer. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/parser.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/script_sh.h>
+#include <grub/i18n.h>
+#include "grub_script.tab.h"
+
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+#pragma GCC diagnostic ignored "-Wunused-function"
+#pragma GCC diagnostic ignored "-Wsign-compare"
+
+#define yyalloc(size, scanner) (grub_malloc((size)))
+#define yyfree(ptr, scanner) (grub_free((ptr)))
+#define yyrealloc(ptr, size, scanner) (grub_realloc((ptr), (size)))
+
+/*
+ * As we don't have access to yyscanner, we cannot do much except to
+ * print the fatal error and exit.
+ */
+#define YY_FATAL_ERROR(msg) \
+ do { \
+ grub_fatal (_("fatal error: %s\n"), _(msg));\
+ } while (0)
+
+#define COPY(str, hint) \
+ do { \
+ copy_string (yyextra, str, hint); \
+ } while (0)
+
+
+#define RECORD \
+ do { \
+ grub_script_lexer_record (yyextra, yytext); \
+ } while (0)
+
+#define ARG(t) \
+ do { \
+ yyextra->lexerstate->type = t; \
+ return GRUB_PARSER_TOKEN_WORD; \
+ } while (0)
+
+/* We don't need YY_INPUT, as we rely on yy_scan_strings */
+#define YY_INPUT(buf,res,max) do { res = 0; } while (0)
+
+/* forward declarations */
+static int grub_lexer_unput (const char *input, yyscan_t yyscanner);
+static int grub_lexer_resplit (const char *input, yyscan_t yyscanner);
+
+static void copy_string (struct grub_parser_param *, const char *,
+ unsigned hint);
+
+%}
+
+%top{
+
+#include <config.h>
+
+#include <sys/types.h>
+
+typedef size_t yy_size_t;
+#define YY_TYPEDEF_YY_SIZE_T 1
+
+/*
+ * Some flex hacks for -nostdinc; XXX We need to fix these when libc
+ * support becomes availble in GRUB.
+ */
+
+#ifndef GRUB_UTIL
+#define stdin 0
+#define stdout 0
+
+#define fprintf(...) (void)0
+#define exit(...) grub_fatal("fatal error in lexer")
+#endif
+
+}
+
+%option ecs
+%option meta-ecs
+
+%option warn
+%option array
+%option stack
+%option reentrant
+%option bison-bridge
+%option never-interactive
+
+%option noyyfree noyyalloc noyyrealloc
+%option nounistd nostdinit nodefault noyylineno
+
+/* Reduce lexer size, by not defining these. */
+%option noyy_top_state
+%option noinput nounput
+%option noyyget_in noyyset_in
+%option noyyget_out noyyset_out
+%option noyyget_debug noyyset_debug
+%option noyyget_lineno noyyset_lineno
+
+%option extra-type="struct grub_parser_param*"
+
+BLANK [ \t]
+COMMENT #.*$
+
+CHAR [^{}|&$;<> \t\n\'\"\\]
+DIGITS [[:digit:]]+
+NAME [[:alpha:]_][[:alnum:]_]*
+
+ESC \\(.|\n)
+SQCHR [^\']
+DQCHR {ESC}|[^\\\"]
+DQSTR \"{DQCHR}*\"
+I18NSTR \$\"{DQCHR}*\"
+SQSTR \'{SQCHR}*\'
+SPECIAL \?|\#|\*|\@
+VARIABLE ${NAME}|$\{{NAME}\}|${DIGITS}|$\{{DIGITS}\}|${SPECIAL}|$\{{SPECIAL}\}
+WORD ({CHAR}|{DQSTR}|{SQSTR}|{ESC}|{VARIABLE}|{I18NSTR})+
+
+MULTILINE {WORD}?((\"{DQCHR}*)|(\$\"{DQCHR}*)|(\'{SQCHR}*))
+POS_MULTILINE {WORD}?\\\n
+
+%x SPLIT
+%x DQUOTE
+%x I18NQUOTE
+%x SQUOTE
+%x VAR
+
+%%
+
+ /* White spaces */
+{BLANK}+ { RECORD; }
+{COMMENT} { RECORD; }
+
+ /* Special symbols */
+"\n" { RECORD; return GRUB_PARSER_TOKEN_NEWLINE; }
+"||" { RECORD; return GRUB_PARSER_TOKEN_OR; }
+"&&" { RECORD; return GRUB_PARSER_TOKEN_AND; }
+";;" { RECORD; return GRUB_PARSER_TOKEN_SEMI2; }
+"|" { RECORD; return GRUB_PARSER_TOKEN_PIPE; }
+"&" { RECORD; return GRUB_PARSER_TOKEN_AMP; }
+";" { RECORD; return GRUB_PARSER_TOKEN_SEMI; }
+"<" { RECORD; return GRUB_PARSER_TOKEN_LT; }
+">" { RECORD; return GRUB_PARSER_TOKEN_GT; }
+
+ /* Reserved words */
+"{" { RECORD; return GRUB_PARSER_TOKEN_LBR; }
+"}" { RECORD; return GRUB_PARSER_TOKEN_RBR; }
+"[[" { RECORD; return GRUB_PARSER_TOKEN_LSQBR2; }
+"]]" { RECORD; return GRUB_PARSER_TOKEN_RSQBR2; }
+"case" { RECORD; return GRUB_PARSER_TOKEN_CASE; }
+"do" { RECORD; return GRUB_PARSER_TOKEN_DO; }
+"done" { RECORD; return GRUB_PARSER_TOKEN_DONE; }
+"elif" { RECORD; return GRUB_PARSER_TOKEN_ELIF; }
+"else" { RECORD; return GRUB_PARSER_TOKEN_ELSE; }
+"esac" { RECORD; return GRUB_PARSER_TOKEN_ESAC; }
+"fi" { RECORD; return GRUB_PARSER_TOKEN_FI; }
+"for" { RECORD; return GRUB_PARSER_TOKEN_FOR; }
+"if" { RECORD; return GRUB_PARSER_TOKEN_IF; }
+"in" { RECORD; return GRUB_PARSER_TOKEN_IN; }
+"select" { RECORD; return GRUB_PARSER_TOKEN_SELECT; }
+"then" { RECORD; return GRUB_PARSER_TOKEN_THEN; }
+"until" { RECORD; return GRUB_PARSER_TOKEN_UNTIL; }
+"while" { RECORD; return GRUB_PARSER_TOKEN_WHILE; }
+"function" { RECORD; return GRUB_PARSER_TOKEN_FUNCTION; }
+
+{MULTILINE} {
+ if (grub_lexer_unput (yytext, yyscanner))
+ return GRUB_PARSER_TOKEN_BAD;
+ }
+
+{POS_MULTILINE} {
+ if (yyg->yy_c_buf_p + 1 == &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
+ {
+ if (grub_lexer_unput (yytext, yyscanner))
+ return GRUB_PARSER_TOKEN_BAD;
+ }
+ else
+ {
+ RECORD;
+ yypush_buffer_state (YY_CURRENT_BUFFER, yyscanner);
+ if (grub_lexer_resplit (yytext, yyscanner))
+ {
+ yypop_buffer_state (yyscanner);
+ return GRUB_PARSER_TOKEN_WORD;
+ }
+ yyextra->lexerstate->resplit = 1;
+ }
+ }
+
+
+{NAME} { RECORD; return GRUB_PARSER_TOKEN_NAME; }
+{WORD} {
+ RECORD;
+ yypush_buffer_state (YY_CURRENT_BUFFER, yyscanner);
+ if (grub_lexer_resplit (yytext, yyscanner))
+ {
+ yypop_buffer_state (yyscanner);
+ return GRUB_PARSER_TOKEN_WORD;
+ }
+ yyextra->lexerstate->resplit = 1;
+ }
+. {
+ grub_script_yyerror (yyextra, yytext);
+ return GRUB_PARSER_TOKEN_BAD;
+ }
+
+ /* Split word into multiple args */
+
+<SPLIT>{
+ \\. { COPY (yytext, yyleng); }
+ \\\n { /* ignore */ }
+ \" {
+ yy_push_state (DQUOTE, yyscanner);
+ ARG (GRUB_SCRIPT_ARG_TYPE_TEXT);
+ }
+ \' {
+ yy_push_state (SQUOTE, yyscanner);
+ ARG (GRUB_SCRIPT_ARG_TYPE_TEXT);
+ }
+ "\$\"" {
+ yy_push_state (I18NQUOTE, yyscanner);
+ ARG (GRUB_SCRIPT_ARG_TYPE_GETTEXT);
+ }
+ \$ {
+ yy_push_state (VAR, yyscanner);
+ ARG (GRUB_SCRIPT_ARG_TYPE_TEXT);
+ }
+ \\ |
+ [^\"\'\$\\]+ { COPY (yytext, yyleng); }
+ <<EOF>> {
+ yy_pop_state (yyscanner);
+ yypop_buffer_state (yyscanner);
+ yyextra->lexerstate->resplit = 0;
+ yyextra->lexerstate->merge_end = 1;
+ ARG (GRUB_SCRIPT_ARG_TYPE_TEXT);
+ }
+}
+
+<VAR>{
+ {SPECIAL} |
+ {DIGITS} |
+ {NAME} {
+ COPY (yytext, yyleng);
+ yy_pop_state (yyscanner);
+ if (YY_START == SPLIT)
+ ARG (GRUB_SCRIPT_ARG_TYPE_VAR);
+ else
+ ARG (GRUB_SCRIPT_ARG_TYPE_DQVAR);
+ }
+ \{{SPECIAL}\} |
+ \{{DIGITS}\} |
+ \{{NAME}\} {
+ yytext[yyleng - 1] = '\0';
+ COPY (yytext + 1, yyleng - 2);
+ yy_pop_state (yyscanner);
+ if (YY_START == SPLIT)
+ ARG (GRUB_SCRIPT_ARG_TYPE_VAR);
+ else
+ ARG (GRUB_SCRIPT_ARG_TYPE_DQVAR);
+ }
+ .|\n { return GRUB_PARSER_TOKEN_BAD; }
+}
+
+<SQUOTE>{
+ \' {
+ yy_pop_state (yyscanner);
+ ARG (GRUB_SCRIPT_ARG_TYPE_SQSTR);
+ }
+ [^\']+ { COPY (yytext, yyleng); }
+}
+
+<DQUOTE>{
+ \\\$ { COPY ("$", 1); }
+ \\\\ { COPY ("\\", 1); }
+ \\\" { COPY ("\"", 1); }
+ \\\n { /* ignore */ }
+ [^\"\$\\\n]+ { COPY (yytext, yyleng); }
+ \" {
+ yy_pop_state (yyscanner);
+ ARG (GRUB_SCRIPT_ARG_TYPE_DQSTR);
+ }
+ \$ {
+ yy_push_state (VAR, yyscanner);
+ ARG (GRUB_SCRIPT_ARG_TYPE_DQSTR);
+ }
+ (.|\n) { COPY (yytext, yyleng); }
+}
+
+<I18NQUOTE>{
+ \\\\ { COPY ("\\\\", 2); }
+ \\\" { COPY ("\"", 1); }
+ \\\n { /* ignore */ }
+ [^\"\\\n]+ { COPY (yytext, yyleng); }
+ \" {
+ yy_pop_state (yyscanner);
+ ARG (GRUB_SCRIPT_ARG_TYPE_GETTEXT);
+ }
+ \\ { COPY ("\\", 1); }
+ (.|\n) { COPY (yytext, yyleng); }
+}
+
+<<EOF>> {
+ yypop_buffer_state (yyscanner);
+ yyextra->lexerstate->eof = 1;
+ return GRUB_PARSER_TOKEN_EOF;
+ }
+%%
+
+int
+yywrap (yyscan_t yyscanner)
+{
+ if (yyget_extra (yyscanner)->lexerstate->resplit)
+ return 1;
+
+ return grub_script_lexer_yywrap (yyget_extra (yyscanner), 0);
+}
+
+static void copy_string (struct grub_parser_param *parser, const char *str, unsigned hint)
+{
+ grub_size_t size;
+ char *ptr;
+ unsigned len;
+
+ len = hint ? hint : grub_strlen (str);
+ if (parser->lexerstate->used + len >= parser->lexerstate->size)
+ {
+ size = len * 2;
+ if (size < parser->lexerstate->size * 2)
+ size = parser->lexerstate->size * 2;
+ ptr = grub_realloc (parser->lexerstate->text, size);
+ if (!ptr)
+ {
+ grub_script_yyerror (parser, 0);
+ return;
+ }
+
+ parser->lexerstate->text = ptr;
+ parser->lexerstate->size = size;
+ }
+ grub_strcpy (parser->lexerstate->text + parser->lexerstate->used - 1, str);
+ parser->lexerstate->used += len;
+}
+
+static int
+grub_lexer_resplit (const char *text, yyscan_t yyscanner)
+{
+ /* resplit text */
+ if (yy_scan_string (text, yyscanner))
+ {
+ yyget_extra (yyscanner)->lexerstate->merge_start = 1;
+ yy_push_state (SPLIT, yyscanner);
+ return 0;
+ }
+ grub_script_yyerror (yyget_extra (yyscanner), 0);
+ return 1;
+}
+
+static int
+grub_lexer_unput (const char *text, yyscan_t yyscanner)
+{
+ struct grub_lexer_param *lexerstate = yyget_extra (yyscanner)->lexerstate;
+
+ grub_free (lexerstate->prefix);
+
+ lexerstate->prefix = grub_strdup (text);
+ if (! lexerstate->prefix)
+ {
+ grub_script_yyerror (yyget_extra (yyscanner), N_("out of memory"));
+ return 1;
+ }
+ return 0;
+}
diff --git a/grub-core/term/arc/console.c b/grub-core/term/arc/console.c
new file mode 100644
index 0000000..c944ffc
--- /dev/null
+++ b/grub-core/term/arc/console.c
@@ -0,0 +1,209 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/arc/arc.h>
+#include <grub/arc/console.h>
+#include <grub/term.h>
+#include <grub/terminfo.h>
+
+/* FIXME: use unicode. */
+
+static int
+readkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ unsigned long count;
+ char chr;
+
+ if (GRUB_ARC_FIRMWARE_VECTOR->get_read_status (GRUB_ARC_STDIN))
+ return -1;
+
+ if (GRUB_ARC_FIRMWARE_VECTOR->read (GRUB_ARC_STDIN, &chr, 1, &count))
+ return -1;
+ if (!count)
+ return -1;
+ return chr;
+}
+
+static void
+put (struct grub_term_output *term __attribute__ ((unused)), const int c)
+{
+ unsigned long count;
+ char chr = c;
+
+ GRUB_ARC_FIRMWARE_VECTOR->write (GRUB_ARC_STDOUT, &chr, 1, &count);
+}
+
+static struct grub_terminfo_output_state grub_console_terminfo_output;
+
+int
+grub_arc_is_device_serial (const char *name, int alt_names)
+{
+ if (name[0] == '\0')
+ return 0;
+
+ const char *ptr = name + grub_strlen (name) - 1;
+ int i;
+ /*
+ Recognize:
+ serial(N)
+ serial(N)line(M)
+ */
+ for (i = 0; i < 2; i++)
+ {
+ if (!alt_names)
+ {
+ if (*ptr != ')')
+ return 0;
+ ptr--;
+ }
+ for (; ptr >= name && grub_isdigit (*ptr); ptr--);
+ if (ptr < name)
+ return 0;
+ if (!alt_names)
+ {
+ if (*ptr != '(')
+ return 0;
+ ptr--;
+ }
+ if (ptr + 1 >= name + sizeof ("serial") - 1
+ && grub_memcmp (ptr + 1 - (sizeof ("serial") - 1),
+ "serial", sizeof ("serial") - 1) == 0)
+ return 1;
+ if (!(ptr + 1 >= name + sizeof ("line") - 1
+ && grub_memcmp (ptr + 1 - (sizeof ("line") - 1),
+ "line", sizeof ("line") - 1) == 0))
+ return 0;
+ ptr -= sizeof ("line") - 1;
+ if (alt_names)
+ {
+ if (*ptr != '/')
+ return 0;
+ ptr--;
+ }
+ }
+ return 0;
+}
+
+static int
+check_is_serial (void)
+{
+ static int is_serial = -1;
+
+ if (is_serial != -1)
+ return is_serial;
+
+ const char *consout = 0;
+
+ /* Check for serial. It works unless user manually overrides ConsoleOut
+ variable. If he does there is nothing we can do. Fortunately failure
+ isn't critical.
+ */
+ if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmware_vector_length
+ >= (unsigned) ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable + 1)
+ - (char *) GRUB_ARC_FIRMWARE_VECTOR)
+ && GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable)
+ consout = GRUB_ARC_FIRMWARE_VECTOR->getenvironmentvariable ("ConsoleOut");
+ if (!consout)
+ return is_serial = 0;
+ return is_serial = grub_arc_is_device_serial (consout, 0);
+}
+
+static void
+set_console_dimensions (void)
+{
+ struct grub_arc_display_status *info = NULL;
+
+ if (check_is_serial ())
+ {
+ grub_console_terminfo_output.size.x = 80;
+ grub_console_terminfo_output.size.y = 24;
+ return;
+ }
+
+ if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmware_vector_length
+ >= (unsigned) ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus + 1)
+ - (char *) GRUB_ARC_FIRMWARE_VECTOR)
+ && GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus)
+ info = GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus (GRUB_ARC_STDOUT);
+ if (info)
+ {
+ grub_console_terminfo_output.size.x = info->w + 1;
+ grub_console_terminfo_output.size.y = info->h + 1;
+ }
+}
+
+static grub_err_t
+grub_console_init_output (struct grub_term_output *term)
+{
+ set_console_dimensions ();
+ grub_terminfo_output_init (term);
+
+ return 0;
+}
+
+static struct grub_terminfo_input_state grub_console_terminfo_input =
+ {
+ .readkey = readkey
+ };
+
+static struct grub_terminfo_output_state grub_console_terminfo_output =
+ {
+ .put = put,
+ .size = { 80, 20 }
+ };
+
+static struct grub_term_input grub_console_term_input =
+ {
+ .name = "console",
+ .init = grub_terminfo_input_init,
+ .getkey = grub_terminfo_getkey,
+ .data = &grub_console_terminfo_input
+ };
+
+static struct grub_term_output grub_console_term_output =
+ {
+ .name = "console",
+ .init = grub_console_init_output,
+ .putchar = grub_terminfo_putchar,
+ .getxy = grub_terminfo_getxy,
+ .getwh = grub_terminfo_getwh,
+ .gotoxy = grub_terminfo_gotoxy,
+ .cls = grub_terminfo_cls,
+ .setcolorstate = grub_terminfo_setcolorstate,
+ .setcursor = grub_terminfo_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_ASCII,
+ .data = &grub_console_terminfo_output,
+ .progress_update_divisor = GRUB_PROGRESS_FAST
+ };
+
+void
+grub_console_init_early (void)
+{
+ grub_term_register_input ("console", &grub_console_term_input);
+ grub_term_register_output ("console", &grub_console_term_output);
+}
+
+void
+grub_console_init_lately (void)
+{
+ grub_terminfo_init ();
+ if (check_is_serial ())
+ grub_terminfo_output_register (&grub_console_term_output, "vt100");
+ else
+ grub_terminfo_output_register (&grub_console_term_output, "arc");
+}
diff --git a/grub-core/term/arc/serial.c b/grub-core/term/arc/serial.c
new file mode 100644
index 0000000..87d1ce8
--- /dev/null
+++ b/grub-core/term/arc/serial.c
@@ -0,0 +1,147 @@
+/*
+ * 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/serial.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/i18n.h>
+#include <grub/arc/arc.h>
+
+
+static void
+do_real_config (struct grub_serial_port *port)
+{
+ char *name;
+ if (port->configured)
+ return;
+
+ name = grub_arc_alt_name_to_norm (port->name, "");
+
+ if (GRUB_ARC_FIRMWARE_VECTOR->open (name,GRUB_ARC_FILE_ACCESS_OPEN_RW,
+ &port->handle))
+ port->handle_valid = 0;
+ else
+ port->handle_valid = 1;
+
+ port->configured = 1;
+}
+
+/* Fetch a key. */
+static int
+serial_hw_fetch (struct grub_serial_port *port)
+{
+ unsigned long actual;
+ char c;
+
+ do_real_config (port);
+
+ if (!port->handle_valid)
+ return -1;
+ if (GRUB_ARC_FIRMWARE_VECTOR->read (port->handle, &c,
+ 1, &actual) || actual <= 0)
+ return -1;
+ return c;
+}
+
+/* Put a character. */
+static void
+serial_hw_put (struct grub_serial_port *port, const int c)
+{
+ unsigned long actual;
+ char c0 = c;
+
+ do_real_config (port);
+
+ if (!port->handle_valid)
+ return;
+
+ GRUB_ARC_FIRMWARE_VECTOR->write (port->handle, &c0,
+ 1, &actual);
+}
+
+/* Initialize a serial device. PORT is the port number for a serial device.
+ SPEED is a DTE-DTE speed which must be one of these: 2400, 4800, 9600,
+ 19200, 38400, 57600 and 115200. WORD_LEN is the word length to be used
+ for the device. Likewise, PARITY is the type of the parity and
+ STOP_BIT_LEN is the length of the stop bit. The possible values for
+ WORD_LEN, PARITY and STOP_BIT_LEN are defined in the header file as
+ macros. */
+static grub_err_t
+serial_hw_configure (struct grub_serial_port *port __attribute__ ((unused)),
+ struct grub_serial_config *config __attribute__ ((unused)))
+{
+ /* FIXME: no ARC serial config available. */
+
+ return GRUB_ERR_NONE;
+}
+
+struct grub_serial_driver grub_arcserial_driver =
+ {
+ .configure = serial_hw_configure,
+ .fetch = serial_hw_fetch,
+ .put = serial_hw_put
+ };
+
+const char *
+grub_arcserial_add_port (const char *path)
+{
+ struct grub_serial_port *port;
+ grub_err_t err;
+
+ port = grub_zalloc (sizeof (*port));
+ if (!port)
+ return NULL;
+ port->name = grub_strdup (path);
+ if (!port->name)
+ return NULL;
+
+ port->driver = &grub_arcserial_driver;
+ err = grub_serial_config_defaults (port);
+ if (err)
+ grub_print_error ();
+
+ grub_serial_register (port);
+
+ return port->name;
+}
+
+static int
+dev_iterate (const char *name,
+ const struct grub_arc_component *comp __attribute__ ((unused)),
+ void *data __attribute__ ((unused)))
+{
+ /* We should check consolein/consoleout flags as
+ well but some implementations are buggy. */
+ if ((comp->flags & (GRUB_ARC_COMPONENT_FLAG_IN | GRUB_ARC_COMPONENT_FLAG_OUT))
+ != (GRUB_ARC_COMPONENT_FLAG_IN | GRUB_ARC_COMPONENT_FLAG_OUT))
+ return 0;
+ if (!grub_arc_is_device_serial (name, 1))
+ return 0;
+ grub_arcserial_add_port (name);
+ return 0;
+}
+
+void
+grub_arcserial_init (void)
+{
+ grub_arc_iterate_devs (dev_iterate, 0, 1);
+}
+
diff --git a/grub-core/term/arm/cros.c b/grub-core/term/arm/cros.c
new file mode 100644
index 0000000..a17e49c
--- /dev/null
+++ b/grub-core/term/arm/cros.c
@@ -0,0 +1,125 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ *
+ * Copyright (C) 2012 Google Inc.
+ * Copyright (C) 2016 Free Software Foundation, Inc.
+ *
+ * This is based on depthcharge code.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/ps2.h>
+#include <grub/fdtbus.h>
+#include <grub/err.h>
+#include <grub/machine/kernel.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/time.h>
+#include <grub/fdtbus.h>
+#include <grub/arm/cros_ec.h>
+
+static struct grub_ps2_state ps2_state;
+
+struct grub_cros_ec_keyscan old_scan;
+
+static const struct grub_fdtbus_dev *cros_ec;
+
+static grub_uint8_t map_code[GRUB_CROS_EC_KEYSCAN_COLS][GRUB_CROS_EC_KEYSCAN_ROWS];
+
+static grub_uint8_t e0_translate[16] =
+ {
+ 0x1c, 0x1d, 0x35, 0x00,
+ 0x38, 0x00, 0x47, 0x48,
+ 0x49, 0x4b, 0x4d, 0x4f,
+ 0x50, 0x51, 0x52, 0x53,
+ };
+
+/* If there is a character pending, return it;
+ otherwise return GRUB_TERM_NO_KEY. */
+static int
+grub_cros_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ struct grub_cros_ec_keyscan scan;
+ int i, j;
+ if (grub_cros_ec_scan_keyboard (cros_ec, &scan) < 0)
+ return GRUB_TERM_NO_KEY;
+ for (i = 0; i < GRUB_CROS_EC_KEYSCAN_COLS; i++)
+ if (scan.data[i] ^ old_scan.data[i])
+ for (j = 0; j < GRUB_CROS_EC_KEYSCAN_ROWS; j++)
+ if ((scan.data[i] ^ old_scan.data[i]) & (1 << j))
+ {
+ grub_uint8_t code = map_code[i][j];
+ int ret;
+ grub_uint8_t brk = 0;
+ if (!(scan.data[i] & (1 << j)))
+ brk = 0x80;
+ grub_dprintf ("cros_keyboard", "key <%d, %d> code %x\n", i, j, code);
+ if (code < 0x60)
+ ret = grub_ps2_process_incoming_byte (&ps2_state, code | brk);
+ else if (code >= 0x60 && code < 0x70 && e0_translate[code - 0x60])
+ {
+ grub_ps2_process_incoming_byte (&ps2_state, 0xe0);
+ ret = grub_ps2_process_incoming_byte (&ps2_state, e0_translate[code - 0x60] | brk);
+ }
+ else
+ ret = GRUB_TERM_NO_KEY;
+ old_scan.data[i] ^= (1 << j);
+ if (ret != GRUB_TERM_NO_KEY)
+ return ret;
+ }
+ return GRUB_TERM_NO_KEY;
+}
+
+static struct grub_term_input grub_cros_keyboard_term =
+ {
+ .name = "cros_keyboard",
+ .getkey = grub_cros_keyboard_getkey
+ };
+
+static grub_err_t
+cros_attach (const struct grub_fdtbus_dev *dev)
+{
+ grub_size_t keymap_size, i;
+ const grub_uint8_t *keymap = grub_fdtbus_get_prop (dev, "linux,keymap", &keymap_size);
+
+ if (!dev->parent || !grub_cros_ec_validate (dev->parent))
+ return GRUB_ERR_IO;
+
+ if (keymap)
+ {
+ for (i = 0; i + 3 < keymap_size; i += 4)
+ if (keymap[i+1] < GRUB_CROS_EC_KEYSCAN_COLS && keymap[i] < GRUB_CROS_EC_KEYSCAN_ROWS
+ && keymap[i+2] == 0 && keymap[i+3] < 0x80)
+ map_code[keymap[i+1]][keymap[i]] = keymap[i+3];
+ }
+
+ cros_ec = dev->parent;
+ ps2_state.current_set = 1;
+ ps2_state.at_keyboard_status = 0;
+ grub_term_register_input ("cros_keyboard", &grub_cros_keyboard_term);
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_fdtbus_driver cros =
+{
+ .compatible = "google,cros-ec-keyb",
+ .attach = cros_attach
+};
+
+void
+grub_cros_init (void)
+{
+ grub_fdtbus_register (&cros);
+}
diff --git a/grub-core/term/arm/cros_ec.c b/grub-core/term/arm/cros_ec.c
new file mode 100644
index 0000000..f414481
--- /dev/null
+++ b/grub-core/term/arm/cros_ec.c
@@ -0,0 +1,238 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ *
+ * Copyright (C) 2012 Google Inc.
+ * Copyright (C) 2016 Free Software Foundation, Inc.
+ *
+ * This is based on depthcharge code.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/mm.h>
+#include <grub/time.h>
+#include <grub/misc.h>
+#include <grub/arm/cros_ec.h>
+#include <grub/fdtbus.h>
+
+static const grub_uint64_t FRAMING_TIMEOUT_MS = 300;
+
+static const grub_uint8_t EC_FRAMING_BYTE = 0xec;
+
+#define EC_CMD_MKBP_STATE 0x60
+#define EC_CMD_VERSION0 0xdc
+
+static grub_uint64_t last_transfer;
+
+static void
+stop_bus (const struct grub_fdtbus_dev *spi)
+{
+ spi->driver->stop (spi);
+ last_transfer = grub_get_time_ms ();
+}
+
+static int
+wait_for_frame (const struct grub_fdtbus_dev *spi)
+{
+ grub_uint64_t start = grub_get_time_ms ();
+ grub_uint8_t byte;
+ do
+ {
+ if (spi->driver->receive (spi, &byte, 1))
+ return -1;
+ if (byte != EC_FRAMING_BYTE &&
+ grub_get_time_ms () - start > FRAMING_TIMEOUT_MS)
+ {
+ grub_dprintf ("cros", "Timeout waiting for framing byte.\n");
+ return -1;
+ }
+ }
+ while (byte != EC_FRAMING_BYTE);
+ return 0;
+}
+
+/*
+ * Calculate a simple 8-bit checksum of a data block
+ *
+ * @param data Data block to checksum
+ * @param size Size of data block in bytes
+ * @return checksum value (0 to 255)
+ */
+static grub_uint8_t
+cros_ec_calc_checksum (const void *data, int size)
+{
+ grub_uint8_t csum;
+ const grub_uint8_t *bytes = data;
+ int i;
+
+ for (i = csum = 0; i < size; i++)
+ csum += bytes[i];
+ return csum & 0xff;
+}
+
+enum
+{
+ /* response, arglen */
+ CROS_EC_SPI_IN_HDR_SIZE = 2,
+ /* version, cmd, arglen */
+ CROS_EC_SPI_OUT_HDR_SIZE = 3
+};
+
+static grub_uint8_t busbuf[256];
+#define MSG_BYTES ((int)sizeof (busbuf))
+
+static int
+ec_command (const struct grub_fdtbus_dev *dev, int cmd, int cmd_version,
+ const void *dout, int dout_len, void *din, int din_len)
+{
+ const struct grub_fdtbus_dev *spi = dev->parent;
+ grub_uint8_t *bytes;
+
+ /* Header + data + checksum. */
+ grub_uint32_t out_bytes = CROS_EC_SPI_OUT_HDR_SIZE + dout_len + 1;
+ grub_uint32_t in_bytes = CROS_EC_SPI_IN_HDR_SIZE + din_len + 1;
+
+ /*
+ * Sanity-check I/O sizes given transaction overhead in internal
+ * buffers.
+ */
+ if (out_bytes > MSG_BYTES)
+ {
+ grub_dprintf ("cros", "Cannot send %d bytes\n", dout_len);
+ return -1;
+ }
+ if (in_bytes > MSG_BYTES)
+ {
+ grub_dprintf ("cros", "Cannot receive %d bytes\n", din_len);
+ return -1;
+ }
+
+ /* Prepare the output. */
+ bytes = busbuf;
+ *bytes++ = EC_CMD_VERSION0 + cmd_version;
+ *bytes++ = cmd;
+ *bytes++ = dout_len;
+ grub_memcpy (bytes, dout, dout_len);
+ bytes += dout_len;
+
+ *bytes++ = cros_ec_calc_checksum (busbuf,
+ CROS_EC_SPI_OUT_HDR_SIZE + dout_len);
+
+ /* Depthcharge uses 200 us here but GRUB timer resolution is only 1ms,
+ decrease this when we increase timer resolution. */
+ while (grub_get_time_ms () - last_transfer < 1)
+ ;
+
+ if (spi->driver->start (spi))
+ return -1;
+
+ /* Allow EC to ramp up clock after being awoken. */
+ /* Depthcharge only waits 100 us here but GRUB timer resolution is only 1ms,
+ decrease this when we increase timer resolution. */
+ grub_millisleep (1);
+
+ if (spi->driver->send (spi, busbuf, out_bytes))
+ {
+ stop_bus (spi);
+ return -1;
+ }
+
+ /* Wait until the EC is ready. */
+ if (wait_for_frame (spi))
+ {
+ stop_bus (spi);
+ return -1;
+ }
+
+ /* Read the response code and the data length. */
+ bytes = busbuf;
+ if (spi->driver->receive (spi, bytes, 2))
+ {
+ stop_bus (spi);
+ return -1;
+ }
+ grub_uint8_t result = *bytes++;
+ grub_uint8_t length = *bytes++;
+
+ /* Make sure there's enough room for the data. */
+ if (CROS_EC_SPI_IN_HDR_SIZE + length + 1 > MSG_BYTES)
+ {
+ grub_dprintf ("cros", "Received length %#02x too large\n", length);
+ stop_bus (spi);
+ return -1;
+ }
+
+ /* Read the data and the checksum, and finish up. */
+ if (spi->driver->receive (spi, bytes, length + 1))
+ {
+ stop_bus (spi);
+ return -1;
+ }
+ bytes += length;
+ int expected = *bytes++;
+ stop_bus (spi);
+
+ /* Check the integrity of the response. */
+ if (result != 0)
+ {
+ grub_dprintf ("cros", "Received bad result code %d\n", result);
+ return -result;
+ }
+
+ int csum = cros_ec_calc_checksum (busbuf,
+ CROS_EC_SPI_IN_HDR_SIZE + length);
+
+ if (csum != expected)
+ {
+ grub_dprintf ("cros", "Invalid checksum rx %#02x, calced %#02x\n",
+ expected, csum);
+ return -1;
+ }
+
+ /* If the caller wants the response, copy it out for them. */
+ if (length < din_len)
+ din_len = length;
+ if (din)
+ {
+ grub_memcpy (din, (grub_uint8_t *) busbuf + CROS_EC_SPI_IN_HDR_SIZE, din_len);
+ }
+
+ return din_len;
+}
+
+int
+grub_cros_ec_scan_keyboard (const struct grub_fdtbus_dev *dev, struct grub_cros_ec_keyscan *scan)
+{
+ if (ec_command (dev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan,
+ sizeof (*scan)) < (int) sizeof (*scan))
+ return -1;
+
+ return 0;
+}
+
+int
+grub_cros_ec_validate (const struct grub_fdtbus_dev *dev)
+{
+ if (!grub_fdtbus_is_compatible("google,cros-ec-spi", dev))
+ return 0;
+ if (!dev->parent)
+ return 0;
+ if (!dev->parent->driver)
+ return 0;
+ if (!dev->parent->driver->send
+ || !dev->parent->driver->receive)
+ return 0;
+ return 1;
+}
+
diff --git a/grub-core/term/arm/pl050.c b/grub-core/term/arm/pl050.c
new file mode 100644
index 0000000..b082243
--- /dev/null
+++ b/grub-core/term/arm/pl050.c
@@ -0,0 +1,189 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/ps2.h>
+#include <grub/fdtbus.h>
+#include <grub/err.h>
+#include <grub/machine/kernel.h>
+#include <grub/at_keyboard.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/time.h>
+#include <grub/ps2.h>
+#include <grub/fdtbus.h>
+
+static volatile grub_uint32_t *pl050_regs;
+
+static struct grub_ps2_state ps2_state;
+
+static void
+keyboard_controller_wait_until_ready (void)
+{
+ while (! (pl050_regs[1] & 0x40));
+}
+
+static grub_uint8_t
+wait_ack (void)
+{
+ grub_uint64_t endtime;
+ grub_uint8_t ack;
+
+ endtime = grub_get_time_ms () + 20;
+ do
+ ack = pl050_regs[2];
+ while (ack != GRUB_AT_ACK && ack != GRUB_AT_NACK
+ && grub_get_time_ms () < endtime);
+ return ack;
+}
+
+
+static int
+write_mode (int mode)
+{
+ unsigned i;
+ for (i = 0; i < GRUB_AT_TRIES; i++)
+ {
+ grub_uint8_t ack;
+ keyboard_controller_wait_until_ready ();
+ pl050_regs[2] = 0xf0;
+ keyboard_controller_wait_until_ready ();
+ pl050_regs[2] = mode;
+ keyboard_controller_wait_until_ready ();
+ ack = wait_ack ();
+ if (ack == GRUB_AT_NACK)
+ continue;
+ if (ack == GRUB_AT_ACK)
+ break;
+ return 0;
+ }
+
+ return (i != GRUB_AT_TRIES);
+}
+
+static int
+query_mode (void)
+{
+ grub_uint8_t ret;
+ int e;
+
+ e = write_mode (0);
+ if (!e)
+ return 0;
+
+ keyboard_controller_wait_until_ready ();
+
+ do
+ ret = pl050_regs[2];
+ while (ret == GRUB_AT_ACK);
+
+ /* QEMU translates the set even in no-translate mode. */
+ if (ret == 0x43 || ret == 1)
+ return 1;
+ if (ret == 0x41 || ret == 2)
+ return 2;
+ if (ret == 0x3f || ret == 3)
+ return 3;
+ return 0;
+}
+
+static void
+set_scancodes (void)
+{
+ write_mode (2);
+ ps2_state.current_set = query_mode ();
+ grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set);
+ if (ps2_state.current_set == 2)
+ return;
+
+ write_mode (1);
+ ps2_state.current_set = query_mode ();
+ grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set);
+ if (ps2_state.current_set == 1)
+ return;
+ grub_dprintf ("atkeyb", "no supported scancode set found\n");
+}
+
+static void
+keyboard_controller_led (grub_uint8_t leds)
+{
+ keyboard_controller_wait_until_ready ();
+ pl050_regs[2] = 0xed;
+ keyboard_controller_wait_until_ready ();
+ pl050_regs[2] = leds & 0x7;
+}
+
+/* If there is a character pending, return it;
+ otherwise return GRUB_TERM_NO_KEY. */
+static int
+grub_pl050_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ grub_uint8_t at_key;
+ int ret;
+ grub_uint8_t old_led;
+
+ if (!(pl050_regs[1] & 0x10))
+ return -1;
+ at_key = pl050_regs[2];
+ old_led = ps2_state.led_status;
+
+ ret = grub_ps2_process_incoming_byte (&ps2_state, at_key);
+ if (old_led != ps2_state.led_status)
+ keyboard_controller_led (ps2_state.led_status);
+ return ret;
+}
+
+static struct grub_term_input grub_pl050_keyboard_term =
+ {
+ .name = "pl050_keyboard",
+ .getkey = grub_pl050_keyboard_getkey
+ };
+
+static grub_err_t
+pl050_attach(const struct grub_fdtbus_dev *dev)
+{
+ const grub_uint32_t *reg;
+ reg = grub_fdtbus_get_prop (dev, "reg", 0);
+
+ /* Mouse. Nothing to do. */
+ if (grub_be_to_cpu32 (*reg) == 0x7000)
+ return 0;
+
+ pl050_regs = grub_fdtbus_map_reg (dev, 0, 0);
+
+ if (!grub_fdtbus_is_mapping_valid (pl050_regs))
+ return grub_error (GRUB_ERR_IO, "could not map pl050");
+
+ ps2_state.at_keyboard_status = 0;
+ set_scancodes ();
+ keyboard_controller_led (ps2_state.led_status);
+
+ grub_term_register_input ("pl050_keyboard", &grub_pl050_keyboard_term);
+ return GRUB_ERR_NONE;
+}
+
+struct grub_fdtbus_driver pl050 =
+{
+ .compatible = "arm,pl050",
+ .attach = pl050_attach
+};
+
+void
+grub_pl050_init (void)
+{
+ grub_fdtbus_register (&pl050);
+}
diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c
new file mode 100644
index 0000000..5971110
--- /dev/null
+++ b/grub-core/term/at_keyboard.c
@@ -0,0 +1,332 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/at_keyboard.h>
+#include <grub/cpu/at_keyboard.h>
+#include <grub/cpu/io.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/time.h>
+#include <grub/loader.h>
+#include <grub/ps2.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_uint8_t grub_keyboard_controller_orig;
+static grub_uint8_t grub_keyboard_orig_set;
+struct grub_ps2_state ps2_state;
+
+static int ping_sent;
+
+static void
+grub_keyboard_controller_init (void);
+
+static void
+keyboard_controller_wait_until_ready (void)
+{
+ /* 50 us would be enough but our current time resolution is 1ms. */
+ grub_millisleep (1);
+ while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)));
+}
+
+static grub_uint8_t
+wait_ack (void)
+{
+ grub_uint64_t endtime;
+ grub_uint8_t ack;
+
+ endtime = grub_get_time_ms () + 20;
+ do {
+ keyboard_controller_wait_until_ready ();
+ ack = grub_inb (KEYBOARD_REG_DATA);
+ } while (ack != GRUB_AT_ACK && ack != GRUB_AT_NACK
+ && grub_get_time_ms () < endtime);
+ return ack;
+}
+
+static int
+at_command (grub_uint8_t data)
+{
+ unsigned i;
+ for (i = 0; i < GRUB_AT_TRIES; i++)
+ {
+ grub_uint8_t ack;
+ keyboard_controller_wait_until_ready ();
+ grub_outb (data, KEYBOARD_REG_STATUS);
+ ack = wait_ack ();
+ if (ack == GRUB_AT_NACK)
+ continue;
+ if (ack == GRUB_AT_ACK)
+ break;
+ return 0;
+ }
+ return (i != GRUB_AT_TRIES);
+}
+
+static void
+grub_keyboard_controller_write (grub_uint8_t c)
+{
+ at_command (KEYBOARD_COMMAND_WRITE);
+ keyboard_controller_wait_until_ready ();
+ grub_outb (c, KEYBOARD_REG_DATA);
+}
+
+#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS)
+#define USE_SCANCODE_SET 1
+#else
+#define USE_SCANCODE_SET 0
+#endif
+
+#if !USE_SCANCODE_SET
+
+static grub_uint8_t
+grub_keyboard_controller_read (void)
+{
+ at_command (KEYBOARD_COMMAND_READ);
+ keyboard_controller_wait_until_ready ();
+ return grub_inb (KEYBOARD_REG_DATA);
+}
+
+#endif
+
+static int
+write_mode (int mode)
+{
+ unsigned i;
+ for (i = 0; i < GRUB_AT_TRIES; i++)
+ {
+ grub_uint8_t ack;
+ keyboard_controller_wait_until_ready ();
+ grub_outb (0xf0, KEYBOARD_REG_DATA);
+ keyboard_controller_wait_until_ready ();
+ grub_outb (mode, KEYBOARD_REG_DATA);
+ keyboard_controller_wait_until_ready ();
+ ack = wait_ack ();
+ if (ack == GRUB_AT_NACK)
+ continue;
+ if (ack == GRUB_AT_ACK)
+ break;
+ return 0;
+ }
+
+ return (i != GRUB_AT_TRIES);
+}
+
+static int
+query_mode (void)
+{
+ grub_uint8_t ret;
+ int e;
+
+ e = write_mode (0);
+ if (!e)
+ return 0;
+
+ do {
+ keyboard_controller_wait_until_ready ();
+ ret = grub_inb (KEYBOARD_REG_DATA);
+ } while (ret == GRUB_AT_ACK);
+ /* QEMU translates the set even in no-translate mode. */
+ if (ret == 0x43 || ret == 1)
+ return 1;
+ if (ret == 0x41 || ret == 2)
+ return 2;
+ if (ret == 0x3f || ret == 3)
+ return 3;
+ return 0;
+}
+
+static void
+set_scancodes (void)
+{
+ /* You must have visited computer museum. Keyboard without scancode set
+ knowledge. Assume XT. */
+ if (!grub_keyboard_orig_set)
+ {
+ grub_dprintf ("atkeyb", "No sets support assumed\n");
+ ps2_state.current_set = 1;
+ return;
+ }
+
+#if !USE_SCANCODE_SET
+ ps2_state.current_set = 1;
+ return;
+#else
+
+ grub_keyboard_controller_write (grub_keyboard_controller_orig
+ & ~KEYBOARD_AT_TRANSLATE
+ & ~KEYBOARD_AT_DISABLE);
+
+ keyboard_controller_wait_until_ready ();
+ grub_outb (KEYBOARD_COMMAND_ENABLE, KEYBOARD_REG_DATA);
+
+ write_mode (2);
+ ps2_state.current_set = query_mode ();
+ grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set);
+ if (ps2_state.current_set == 2)
+ return;
+
+ write_mode (1);
+ ps2_state.current_set = query_mode ();
+ grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set);
+ if (ps2_state.current_set == 1)
+ return;
+ grub_dprintf ("atkeyb", "no supported scancode set found\n");
+#endif
+}
+
+static void
+keyboard_controller_led (grub_uint8_t leds)
+{
+ keyboard_controller_wait_until_ready ();
+ grub_outb (0xed, KEYBOARD_REG_DATA);
+ keyboard_controller_wait_until_ready ();
+ grub_outb (leds & 0x7, KEYBOARD_REG_DATA);
+}
+
+int
+grub_at_keyboard_is_alive (void)
+{
+ if (ps2_state.current_set != 0)
+ return 1;
+ if (ping_sent
+ && KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))
+ && grub_inb (KEYBOARD_REG_DATA) == 0x55)
+ {
+ grub_keyboard_controller_init ();
+ return 1;
+ }
+
+ if (KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
+ {
+ grub_outb (0xaa, KEYBOARD_REG_STATUS);
+ ping_sent = 1;
+ }
+ return 0;
+}
+
+/* If there is a character pending, return it;
+ otherwise return GRUB_TERM_NO_KEY. */
+static int
+grub_at_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ grub_uint8_t at_key;
+ int ret;
+ grub_uint8_t old_led;
+
+ if (!grub_at_keyboard_is_alive ())
+ return GRUB_TERM_NO_KEY;
+
+ if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
+ return GRUB_TERM_NO_KEY;
+ at_key = grub_inb (KEYBOARD_REG_DATA);
+ old_led = ps2_state.led_status;
+
+ ret = grub_ps2_process_incoming_byte (&ps2_state, at_key);
+ if (old_led != ps2_state.led_status)
+ keyboard_controller_led (ps2_state.led_status);
+ return ret;
+}
+
+static void
+grub_keyboard_controller_init (void)
+{
+ ps2_state.at_keyboard_status = 0;
+ /* Drain input buffer. */
+ while (1)
+ {
+ keyboard_controller_wait_until_ready ();
+ if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
+ break;
+ keyboard_controller_wait_until_ready ();
+ grub_inb (KEYBOARD_REG_DATA);
+ }
+#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS)
+ grub_keyboard_controller_orig = 0;
+ grub_keyboard_orig_set = 2;
+#elif defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_COREBOOT)
+ /* *BSD relies on those settings. */
+ grub_keyboard_controller_orig = KEYBOARD_AT_TRANSLATE;
+ grub_keyboard_orig_set = 2;
+#else
+ grub_keyboard_controller_orig = grub_keyboard_controller_read ();
+ grub_keyboard_orig_set = query_mode ();
+#endif
+ set_scancodes ();
+ keyboard_controller_led (ps2_state.led_status);
+}
+
+static grub_err_t
+grub_keyboard_controller_fini (struct grub_term_input *term __attribute__ ((unused)))
+{
+ if (ps2_state.current_set == 0)
+ return GRUB_ERR_NONE;
+ if (grub_keyboard_orig_set)
+ write_mode (grub_keyboard_orig_set);
+ grub_keyboard_controller_write (grub_keyboard_controller_orig);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_at_fini_hw (int noreturn __attribute__ ((unused)))
+{
+ return grub_keyboard_controller_fini (NULL);
+}
+
+static grub_err_t
+grub_at_restore_hw (void)
+{
+ if (ps2_state.current_set == 0)
+ return GRUB_ERR_NONE;
+
+ /* Drain input buffer. */
+ while (1)
+ {
+ keyboard_controller_wait_until_ready ();
+ if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
+ break;
+ keyboard_controller_wait_until_ready ();
+ grub_inb (KEYBOARD_REG_DATA);
+ }
+ set_scancodes ();
+ keyboard_controller_led (ps2_state.led_status);
+
+ return GRUB_ERR_NONE;
+}
+
+
+static struct grub_term_input grub_at_keyboard_term =
+ {
+ .name = "at_keyboard",
+ .fini = grub_keyboard_controller_fini,
+ .getkey = grub_at_keyboard_getkey
+ };
+
+GRUB_MOD_INIT(at_keyboard)
+{
+ grub_term_register_input ("at_keyboard", &grub_at_keyboard_term);
+ grub_loader_register_preboot_hook (grub_at_fini_hw, grub_at_restore_hw,
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_CONSOLE);
+}
+
+GRUB_MOD_FINI(at_keyboard)
+{
+ grub_keyboard_controller_fini (NULL);
+ grub_term_unregister_input (&grub_at_keyboard_term);
+}
diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
new file mode 100644
index 0000000..2f1ae85
--- /dev/null
+++ b/grub-core/term/efi/console.c
@@ -0,0 +1,470 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/api.h>
+#include <grub/efi/console.h>
+
+typedef enum {
+ GRUB_TEXT_MODE_UNDEFINED = -1,
+ GRUB_TEXT_MODE_UNAVAILABLE = 0,
+ GRUB_TEXT_MODE_AVAILABLE
+}
+grub_text_mode;
+
+static grub_text_mode text_mode = GRUB_TEXT_MODE_UNDEFINED;
+static grub_term_color_state text_colorstate = GRUB_TERM_COLOR_UNDEFINED;
+
+static grub_uint32_t
+map_char (grub_uint32_t c)
+{
+ /* Map some unicode characters to the EFI character. */
+ switch (c)
+ {
+ case GRUB_UNICODE_LEFTARROW:
+ c = GRUB_UNICODE_BLACK_LEFT_TRIANGLE;
+ break;
+ case GRUB_UNICODE_UPARROW:
+ c = GRUB_UNICODE_BLACK_UP_TRIANGLE;
+ break;
+ case GRUB_UNICODE_RIGHTARROW:
+ c = GRUB_UNICODE_BLACK_RIGHT_TRIANGLE;
+ break;
+ case GRUB_UNICODE_DOWNARROW:
+ c = GRUB_UNICODE_BLACK_DOWN_TRIANGLE;
+ break;
+ case GRUB_UNICODE_HLINE:
+ c = GRUB_UNICODE_LIGHT_HLINE;
+ break;
+ case GRUB_UNICODE_VLINE:
+ c = GRUB_UNICODE_LIGHT_VLINE;
+ break;
+ case GRUB_UNICODE_CORNER_UL:
+ c = GRUB_UNICODE_LIGHT_CORNER_UL;
+ break;
+ case GRUB_UNICODE_CORNER_UR:
+ c = GRUB_UNICODE_LIGHT_CORNER_UR;
+ break;
+ case GRUB_UNICODE_CORNER_LL:
+ c = GRUB_UNICODE_LIGHT_CORNER_LL;
+ break;
+ case GRUB_UNICODE_CORNER_LR:
+ c = GRUB_UNICODE_LIGHT_CORNER_LR;
+ break;
+ }
+
+ return c;
+}
+
+static void
+grub_console_setcolorstate (struct grub_term_output *term
+ __attribute__ ((unused)),
+ grub_term_color_state state)
+{
+ grub_efi_simple_text_output_interface_t *o;
+
+ if (grub_efi_is_finished)
+ return;
+
+ o = grub_efi_system_table->con_out;
+
+ switch (state) {
+ case GRUB_TERM_COLOR_STANDARD:
+ efi_call_2 (o->set_attributes, o, GRUB_TERM_DEFAULT_STANDARD_COLOR
+ & 0x7f);
+ break;
+ case GRUB_TERM_COLOR_NORMAL:
+ efi_call_2 (o->set_attributes, o, grub_term_normal_color & 0x7f);
+ break;
+ case GRUB_TERM_COLOR_HIGHLIGHT:
+ efi_call_2 (o->set_attributes, o, grub_term_highlight_color & 0x7f);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
+{
+ grub_efi_simple_text_output_interface_t *o;
+
+ if (grub_efi_is_finished)
+ return;
+
+ o = grub_efi_system_table->con_out;
+ efi_call_2 (o->enable_cursor, o, on);
+}
+
+static grub_err_t
+grub_prepare_for_text_output (struct grub_term_output *term)
+{
+ if (grub_efi_is_finished)
+ return GRUB_ERR_BAD_DEVICE;
+
+ if (text_mode != GRUB_TEXT_MODE_UNDEFINED)
+ return text_mode ? GRUB_ERR_NONE : GRUB_ERR_BAD_DEVICE;
+
+ if (! grub_efi_set_text_mode (1))
+ {
+ /* This really should never happen */
+ grub_error (GRUB_ERR_BAD_DEVICE, "cannot set text mode");
+ text_mode = GRUB_TEXT_MODE_UNAVAILABLE;
+ return GRUB_ERR_BAD_DEVICE;
+ }
+
+ grub_console_setcursor (term, 1);
+ if (text_colorstate != GRUB_TERM_COLOR_UNDEFINED)
+ grub_console_setcolorstate (term, text_colorstate);
+ text_mode = GRUB_TEXT_MODE_AVAILABLE;
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_console_putchar (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c)
+{
+ grub_efi_char16_t str[2 + 30];
+ grub_efi_simple_text_output_interface_t *o;
+ unsigned i, j;
+
+ if (grub_prepare_for_text_output (term) != GRUB_ERR_NONE)
+ return;
+
+ o = grub_efi_system_table->con_out;
+
+ /* For now, do not try to use a surrogate pair. */
+ if (c->base > 0xffff)
+ str[0] = '?';
+ else
+ str[0] = (grub_efi_char16_t) map_char (c->base & 0xffff);
+ j = 1;
+ for (i = 0; i < c->ncomb && j + 1 < ARRAY_SIZE (str); i++)
+ if (c->base < 0xffff)
+ str[j++] = grub_unicode_get_comb (c)[i].code;
+ str[j] = 0;
+
+ /* Should this test be cached? */
+ if ((c->base > 0x7f || c->ncomb)
+ && efi_call_2 (o->test_string, o, str) != GRUB_EFI_SUCCESS)
+ return;
+
+ efi_call_2 (o->output_string, o, str);
+}
+
+const unsigned efi_codes[] =
+ {
+ 0, GRUB_TERM_KEY_UP, GRUB_TERM_KEY_DOWN, GRUB_TERM_KEY_RIGHT,
+ GRUB_TERM_KEY_LEFT, GRUB_TERM_KEY_HOME, GRUB_TERM_KEY_END, GRUB_TERM_KEY_INSERT,
+ 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, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12, GRUB_TERM_ESC
+ };
+
+static int
+grub_efi_translate_key (grub_efi_input_key_t key)
+{
+ if (key.scan_code == 0)
+ {
+ /* Some firmware implementations use VT100-style codes against the spec.
+ This is especially likely if driven by serial.
+ */
+ if (key.unicode_char < 0x20 && key.unicode_char != 0
+ && key.unicode_char != '\t' && key.unicode_char != '\b'
+ && key.unicode_char != '\n' && key.unicode_char != '\r')
+ return GRUB_TERM_CTRL | (key.unicode_char - 1 + 'a');
+ else
+ return key.unicode_char;
+ }
+ /* Some devices send enter with scan_code 0x0d (F3) and unicode_char 0x0d. */
+ else if (key.scan_code == '\r' && key.unicode_char == '\r')
+ return key.unicode_char;
+ 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);
+}
+
+/*
+ * When more then just modifiers are pressed, our getkeystatus() consumes a
+ * press from the queue, this function buffers the press for the regular
+ * getkey() so that it does not get lost.
+ */
+static grub_err_t
+grub_console_read_key_stroke (
+ grub_efi_simple_text_input_ex_interface_t *text_input,
+ grub_efi_key_data_t *key_data_ret, int *key_ret,
+ int consume)
+{
+ static grub_efi_key_data_t key_data;
+ grub_efi_status_t status;
+ int key;
+
+ if (!text_input)
+ return GRUB_ERR_EOF;
+
+ key = grub_efi_translate_key (key_data.key);
+ if (key == GRUB_TERM_NO_KEY) {
+ status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data);
+ if (status != GRUB_EFI_SUCCESS)
+ return GRUB_ERR_EOF;
+
+ key = grub_efi_translate_key (key_data.key);
+ }
+
+ *key_data_ret = key_data;
+ *key_ret = key;
+
+ if (consume) {
+ key_data.key.scan_code = 0;
+ key_data.key.unicode_char = 0;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static int
+grub_console_getkey_ex (struct grub_term_input *term)
+{
+ grub_efi_key_data_t key_data;
+ grub_efi_uint32_t kss;
+ grub_err_t err;
+ int key = -1;
+
+ err = grub_console_read_key_stroke (term->data, &key_data, &key, 1);
+ if (err != GRUB_ERR_NONE || key == GRUB_TERM_NO_KEY)
+ return GRUB_TERM_NO_KEY;
+
+ kss = key_data.key_state.key_shift_state;
+ 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 int
+grub_console_getkeystatus (struct grub_term_input *term)
+{
+ grub_efi_key_data_t key_data;
+ grub_efi_uint32_t kss;
+ int key, mods = 0;
+
+ if (grub_efi_is_finished)
+ return 0;
+
+ if (grub_console_read_key_stroke (term->data, &key_data, &key, 0))
+ return 0;
+
+ kss = key_data.key_state.key_shift_state;
+ if (kss & GRUB_EFI_SHIFT_STATE_VALID)
+ {
+ if (kss & GRUB_EFI_LEFT_SHIFT_PRESSED)
+ mods |= GRUB_TERM_STATUS_LSHIFT;
+ if (kss & GRUB_EFI_RIGHT_SHIFT_PRESSED)
+ mods |= GRUB_TERM_STATUS_RSHIFT;
+ if (kss & GRUB_EFI_LEFT_ALT_PRESSED)
+ mods |= GRUB_TERM_STATUS_LALT;
+ if (kss & GRUB_EFI_RIGHT_ALT_PRESSED)
+ mods |= GRUB_TERM_STATUS_RALT;
+ if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED)
+ mods |= GRUB_TERM_STATUS_LCTRL;
+ if (kss & GRUB_EFI_RIGHT_CONTROL_PRESSED)
+ mods |= GRUB_TERM_STATUS_RCTRL;
+ }
+
+ return mods;
+}
+
+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)
+{
+ grub_efi_simple_text_output_interface_t *o;
+ grub_efi_uintn_t columns, rows;
+
+ o = grub_efi_system_table->con_out;
+ if (grub_prepare_for_text_output (term) != GRUB_ERR_NONE ||
+ efi_call_4 (o->query_mode, o, o->mode->mode,
+ &columns, &rows) != GRUB_EFI_SUCCESS)
+ {
+ /* Why does this fail? */
+ columns = 80;
+ rows = 25;
+ }
+
+ return (struct grub_term_coordinate) { columns, rows };
+}
+
+static struct grub_term_coordinate
+grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
+{
+ grub_efi_simple_text_output_interface_t *o;
+
+ if (grub_efi_is_finished || text_mode != GRUB_TEXT_MODE_AVAILABLE)
+ return (struct grub_term_coordinate) { 0, 0 };
+
+ o = grub_efi_system_table->con_out;
+ return (struct grub_term_coordinate) { o->mode->cursor_column, o->mode->cursor_row };
+}
+
+static void
+grub_console_gotoxy (struct grub_term_output *term,
+ struct grub_term_coordinate pos)
+{
+ grub_efi_simple_text_output_interface_t *o;
+
+ if (grub_prepare_for_text_output (term) != GRUB_ERR_NONE)
+ return;
+
+ o = grub_efi_system_table->con_out;
+ efi_call_3 (o->set_cursor_position, o, pos.x, pos.y);
+}
+
+static void
+grub_console_cls (struct grub_term_output *term __attribute__ ((unused)))
+{
+ grub_efi_simple_text_output_interface_t *o;
+ grub_efi_int32_t orig_attr;
+
+ if (grub_efi_is_finished || text_mode != GRUB_TEXT_MODE_AVAILABLE)
+ return;
+
+ o = grub_efi_system_table->con_out;
+ orig_attr = o->mode->attribute;
+ efi_call_2 (o->set_attributes, o, GRUB_EFI_BACKGROUND_BLACK);
+ efi_call_1 (o->clear_screen, o);
+ efi_call_2 (o->set_attributes, o, orig_attr);
+}
+
+static grub_err_t
+grub_efi_console_output_fini (struct grub_term_output *term)
+{
+ if (text_mode != GRUB_TEXT_MODE_AVAILABLE)
+ return 0;
+
+ grub_console_setcursor (term, 0);
+ grub_efi_set_text_mode (0);
+ text_mode = GRUB_TEXT_MODE_UNDEFINED;
+ return 0;
+}
+
+static struct grub_term_input grub_console_term_input =
+ {
+ .name = "console",
+ .getkey = grub_console_getkey,
+ .getkeystatus = grub_console_getkeystatus,
+ .init = grub_efi_console_input_init,
+ };
+
+static struct grub_term_output grub_console_term_output =
+ {
+ .name = "console",
+ .fini = grub_efi_console_output_fini,
+ .putchar = grub_console_putchar,
+ .getwh = grub_console_getwh,
+ .getxy = grub_console_getxy,
+ .gotoxy = grub_console_gotoxy,
+ .cls = grub_console_cls,
+ .setcolorstate = grub_console_setcolorstate,
+ .setcursor = grub_console_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS,
+ .progress_update_divisor = GRUB_PROGRESS_FAST
+ };
+
+void
+grub_console_init (void)
+{
+ grub_term_register_output ("console", &grub_console_term_output);
+ grub_term_register_input ("console", &grub_console_term_input);
+}
+
+void
+grub_console_fini (void)
+{
+ grub_term_unregister_input (&grub_console_term_input);
+ grub_term_unregister_output (&grub_console_term_output);
+}
diff --git a/grub-core/term/efi/serial.c b/grub-core/term/efi/serial.c
new file mode 100644
index 0000000..4c94723
--- /dev/null
+++ b/grub-core/term/efi/serial.c
@@ -0,0 +1,195 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,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/disk.h>
+#include <grub/partition.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/term.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/disk.h>
+#include <grub/serial.h>
+#include <grub/types.h>
+#include <grub/i18n.h>
+
+/* GUID. */
+static grub_efi_guid_t serial_io_guid = GRUB_EFI_SERIAL_IO_GUID;
+
+static void
+do_real_config (struct grub_serial_port *port)
+{
+ grub_efi_status_t status = GRUB_EFI_SUCCESS;
+ const grub_efi_parity_type_t parities[] = {
+ [GRUB_SERIAL_PARITY_NONE] = GRUB_EFI_SERIAL_NO_PARITY,
+ [GRUB_SERIAL_PARITY_ODD] = GRUB_EFI_SERIAL_ODD_PARITY,
+ [GRUB_SERIAL_PARITY_EVEN] = GRUB_EFI_SERIAL_EVEN_PARITY
+ };
+ const grub_efi_stop_bits_t stop_bits[] = {
+ [GRUB_SERIAL_STOP_BITS_1] = GRUB_EFI_SERIAL_1_STOP_BIT,
+ [GRUB_SERIAL_STOP_BITS_1_5] = GRUB_EFI_SERIAL_1_5_STOP_BITS,
+ [GRUB_SERIAL_STOP_BITS_2] = GRUB_EFI_SERIAL_2_STOP_BITS,
+ };
+
+ if (port->configured)
+ return;
+
+ status = efi_call_7 (port->interface->set_attributes, port->interface,
+ port->config.speed,
+ 0, 0, parities[port->config.parity],
+ port->config.word_len,
+ stop_bits[port->config.stop_bits]);
+ if (status != GRUB_EFI_SUCCESS)
+ port->broken = 1;
+
+ status = efi_call_2 (port->interface->set_control_bits, port->interface,
+ port->config.rtscts ? 0x4002 : 0x2);
+
+ port->configured = 1;
+}
+
+/* Fetch a key. */
+static int
+serial_hw_fetch (struct grub_serial_port *port)
+{
+ grub_efi_uintn_t bufsize = 1;
+ char c;
+ grub_efi_status_t status = GRUB_EFI_SUCCESS;
+ do_real_config (port);
+ if (port->broken)
+ return -1;
+
+ status = efi_call_3 (port->interface->read, port->interface, &bufsize, &c);
+ if (status != GRUB_EFI_SUCCESS || bufsize == 0)
+ return -1;
+
+ return c;
+}
+
+/* Put a character. */
+static void
+serial_hw_put (struct grub_serial_port *port, const int c)
+{
+ grub_efi_uintn_t bufsize = 1;
+ char c0 = c;
+
+ do_real_config (port);
+
+ if (port->broken)
+ return;
+
+ efi_call_3 (port->interface->write, port->interface, &bufsize, &c0);
+}
+
+/* Initialize a serial device. PORT is the port number for a serial device.
+ SPEED is a DTE-DTE speed which must be one of these: 2400, 4800, 9600,
+ 19200, 38400, 57600 and 115200. WORD_LEN is the word length to be used
+ for the device. Likewise, PARITY is the type of the parity and
+ STOP_BIT_LEN is the length of the stop bit. The possible values for
+ WORD_LEN, PARITY and STOP_BIT_LEN are defined in the header file as
+ macros. */
+static grub_err_t
+serial_hw_configure (struct grub_serial_port *port,
+ struct grub_serial_config *config)
+{
+ if (config->parity != GRUB_SERIAL_PARITY_NONE
+ && config->parity != GRUB_SERIAL_PARITY_ODD
+ && config->parity != GRUB_SERIAL_PARITY_EVEN)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port parity"));
+
+ if (config->stop_bits != GRUB_SERIAL_STOP_BITS_1
+ && config->stop_bits != GRUB_SERIAL_STOP_BITS_1_5
+ && config->stop_bits != GRUB_SERIAL_STOP_BITS_2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port stop bits number"));
+
+ if (config->word_len < 5 || config->word_len > 8)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port word length"));
+
+ port->config = *config;
+ port->configured = 0;
+
+ /* FIXME: should check if the serial terminal was found. */
+
+ return GRUB_ERR_NONE;
+}
+
+struct grub_serial_driver grub_efiserial_driver =
+ {
+ .configure = serial_hw_configure,
+ .fetch = serial_hw_fetch,
+ .put = serial_hw_put
+ };
+
+void
+grub_efiserial_init (void)
+{
+ grub_efi_uintn_t num_handles;
+ grub_efi_handle_t *handles;
+ grub_efi_handle_t *handle;
+ int num_serial = 0;
+ grub_err_t err;
+
+ /* Find handles which support the disk io interface. */
+ handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &serial_io_guid,
+ 0, &num_handles);
+ if (! handles)
+ return;
+
+ /* Make a linked list of devices. */
+ for (handle = handles; num_handles--; handle++)
+ {
+ struct grub_serial_port *port;
+ struct grub_efi_serial_io_interface *sio;
+
+ sio = grub_efi_open_protocol (*handle, &serial_io_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (! sio)
+ /* This should not happen... Why? */
+ continue;
+
+ port = grub_zalloc (sizeof (*port));
+ if (!port)
+ return;
+
+ port->name = grub_malloc (sizeof ("efiXXXXXXXXXXXXXXXXXXXX"));
+ if (!port->name)
+ {
+ grub_free (port);
+ return;
+ }
+ grub_snprintf (port->name, sizeof ("efiXXXXXXXXXXXXXXXXXXXX"),
+ "efi%d", num_serial++);
+
+ port->driver = &grub_efiserial_driver;
+ port->interface = sio;
+ err = grub_serial_config_defaults (port);
+ if (err)
+ grub_print_error ();
+
+ grub_serial_register (port);
+ }
+
+ grub_free (handles);
+
+ return;
+}
diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c
new file mode 100644
index 0000000..b40fcce
--- /dev/null
+++ b/grub-core/term/gfxterm.c
@@ -0,0 +1,1160 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/term.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/font.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/video.h>
+#include <grub/gfxterm.h>
+#include <grub/bitmap.h>
+#include <grub/command.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define DEFAULT_VIDEO_MODE "auto"
+#define DEFAULT_BORDER_WIDTH 10
+
+#define DEFAULT_STANDARD_COLOR 0x07
+
+struct grub_dirty_region
+{
+ int top_left_x;
+ int top_left_y;
+ int bottom_right_x;
+ int bottom_right_y;
+};
+
+struct grub_colored_char
+{
+ /* An Unicode codepoint. */
+ struct grub_unicode_glyph code;
+
+ /* Color values. */
+ grub_video_color_t fg_color;
+ grub_video_color_t bg_color;
+};
+
+struct grub_virtual_screen
+{
+ /* Dimensions of the virtual screen in pixels. */
+ unsigned int width;
+ unsigned int height;
+
+ /* Offset in the display in pixels. */
+ unsigned int offset_x;
+ unsigned int offset_y;
+
+ /* TTY Character sizes in pixes. */
+ unsigned int normal_char_width;
+ unsigned int normal_char_height;
+
+ /* Virtual screen TTY size in characters. */
+ unsigned int columns;
+ unsigned int rows;
+
+ /* Current cursor location in characters. */
+ unsigned int cursor_x;
+ unsigned int cursor_y;
+
+ /* Current cursor state. */
+ int cursor_state;
+
+ /* Font settings. */
+ grub_font_t font;
+
+ /* Terminal color settings. */
+ grub_uint8_t standard_color_setting;
+ grub_uint8_t term_color;
+
+ /* Color settings. */
+ grub_video_color_t fg_color;
+ grub_video_color_t bg_color;
+ grub_video_color_t bg_color_display;
+
+ /* Text buffer for virtual screen. Contains (columns * rows) number
+ of entries. */
+ struct grub_colored_char *text_buffer;
+
+ int total_scroll;
+
+ int functional;
+};
+
+struct grub_gfxterm_window
+{
+ unsigned x;
+ unsigned y;
+ unsigned width;
+ unsigned height;
+ int double_repaint;
+};
+
+static struct grub_video_render_target *render_target;
+void (*grub_gfxterm_decorator_hook) (void) = NULL;
+static struct grub_gfxterm_window window;
+static struct grub_virtual_screen virtual_screen;
+static int repaint_scheduled = 0;
+static int repaint_was_scheduled = 0;
+
+static void destroy_window (void);
+
+static struct grub_video_render_target *text_layer;
+
+struct grub_gfxterm_background grub_gfxterm_background;
+
+static struct grub_dirty_region dirty_region;
+
+static void dirty_region_reset (void);
+
+static int dirty_region_is_empty (void);
+
+static void dirty_region_add (int x, int y,
+ unsigned int width, unsigned int height);
+
+static unsigned int calculate_normal_character_width (grub_font_t font);
+
+static unsigned char calculate_character_width (struct grub_font_glyph *glyph);
+
+static void grub_gfxterm_refresh (struct grub_term_output *term __attribute__ ((unused)));
+
+static grub_size_t
+grub_gfxterm_getcharwidth (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c);
+
+static void
+set_term_color (grub_uint8_t term_color)
+{
+ struct grub_video_render_target *old_target;
+
+ /* Save previous target and switch to text layer. */
+ grub_video_get_active_render_target (&old_target);
+ grub_video_set_active_render_target (text_layer);
+
+ /* Map terminal color to text layer compatible video colors. */
+ virtual_screen.fg_color = grub_video_map_color(term_color & 0x0f);
+
+ /* Special case: use black as transparent color. */
+ if (((term_color >> 4) & 0x0f) == 0)
+ {
+ virtual_screen.bg_color = grub_video_map_rgba(0, 0, 0, 0);
+ }
+ else
+ {
+ virtual_screen.bg_color = grub_video_map_color((term_color >> 4) & 0x0f);
+ }
+
+ /* Restore previous target. */
+ grub_video_set_active_render_target (old_target);
+}
+
+static void
+clear_char (struct grub_colored_char *c)
+{
+ grub_unicode_destroy_glyph (&c->code);
+ grub_unicode_set_glyph_from_code (&c->code, ' ');
+ c->fg_color = virtual_screen.fg_color;
+ c->bg_color = virtual_screen.bg_color;
+}
+
+static void
+grub_virtual_screen_free (void)
+{
+ virtual_screen.functional = 0;
+
+ /* If virtual screen has been allocated, free it. */
+ if (virtual_screen.text_buffer != 0)
+ {
+ unsigned i;
+ for (i = 0;
+ i < virtual_screen.columns * virtual_screen.rows;
+ i++)
+ grub_unicode_destroy_glyph (&virtual_screen.text_buffer[i].code);
+ grub_free (virtual_screen.text_buffer);
+ }
+
+ /* Reset virtual screen data. */
+ grub_memset (&virtual_screen, 0, sizeof (virtual_screen));
+
+ /* Free render targets. */
+ grub_video_delete_render_target (text_layer);
+ text_layer = 0;
+}
+
+static grub_err_t
+grub_virtual_screen_setup (unsigned int x, unsigned int y,
+ unsigned int width, unsigned int height,
+ grub_font_t font)
+{
+ unsigned int i;
+
+ /* Free old virtual screen. */
+ grub_virtual_screen_free ();
+
+ /* Initialize with default data. */
+ virtual_screen.font = font;
+ virtual_screen.width = width;
+ virtual_screen.height = height;
+ virtual_screen.offset_x = x;
+ virtual_screen.offset_y = y;
+ virtual_screen.normal_char_width =
+ 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;
+ virtual_screen.total_scroll = 0;
+
+ /* Calculate size of text buffer. */
+ virtual_screen.columns = virtual_screen.width / virtual_screen.normal_char_width;
+ virtual_screen.rows = virtual_screen.height / virtual_screen.normal_char_height;
+
+ /*
+ * There must be a minimum number of rows and columns for the screen to
+ * make sense. Arbitrarily pick half of 80x24. If either dimensions is 0
+ * we would allocate 0 bytes for the text_buffer.
+ */
+ if (virtual_screen.columns < 40 || virtual_screen.rows < 12)
+ return grub_error (GRUB_ERR_BAD_FONT,
+ "font: glyphs too large to fit on screen");
+
+ /* Allocate memory for text buffer. */
+ virtual_screen.text_buffer =
+ (struct grub_colored_char *) grub_malloc (virtual_screen.columns
+ * virtual_screen.rows
+ * sizeof (*virtual_screen.text_buffer));
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* Create new render target for text layer. */
+ grub_video_create_render_target (&text_layer,
+ virtual_screen.width,
+ virtual_screen.height,
+ GRUB_VIDEO_MODE_TYPE_INDEX_COLOR
+ | GRUB_VIDEO_MODE_TYPE_ALPHA);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* As we want to have colors compatible with rendering target,
+ we can only have those after mode is initialized. */
+ grub_video_set_active_render_target (text_layer);
+
+ virtual_screen.standard_color_setting = DEFAULT_STANDARD_COLOR;
+
+ virtual_screen.term_color = virtual_screen.standard_color_setting;
+
+ set_term_color (virtual_screen.term_color);
+
+ grub_video_set_active_render_target (render_target);
+
+ virtual_screen.bg_color_display =
+ grub_video_map_rgba_color (grub_gfxterm_background.default_bg_color);
+
+ /* Clear out text buffer. */
+ for (i = 0; i < virtual_screen.columns * virtual_screen.rows; i++)
+ {
+ virtual_screen.text_buffer[i].code.ncomb = 0;
+ clear_char (&(virtual_screen.text_buffer[i]));
+ }
+ if (grub_errno)
+ return grub_errno;
+
+ virtual_screen.functional = 1;
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_gfxterm_schedule_repaint (void)
+{
+ repaint_scheduled = 1;
+}
+
+grub_err_t
+grub_gfxterm_set_window (struct grub_video_render_target *target,
+ int x, int y, int width, int height,
+ int double_repaint,
+ grub_font_t font, int border_width)
+{
+ /* Clean up any prior instance. */
+ destroy_window ();
+
+ /* Set the render target. */
+ render_target = target;
+
+ /* Create virtual screen. */
+ if (grub_virtual_screen_setup (border_width, border_width,
+ width - 2 * border_width,
+ height - 2 * border_width,
+ font)
+ != GRUB_ERR_NONE)
+ {
+ return grub_errno;
+ }
+
+ /* Set window bounds. */
+ window.x = x;
+ window.y = y;
+ window.width = width;
+ window.height = height;
+ window.double_repaint = double_repaint;
+
+ dirty_region_reset ();
+ grub_gfxterm_schedule_repaint ();
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_gfxterm_fullscreen (void)
+{
+ const char *font_name;
+ struct grub_video_mode_info mode_info;
+ grub_video_color_t color;
+ grub_err_t err;
+ int double_redraw;
+ grub_font_t font;
+
+ err = grub_video_get_info (&mode_info);
+ /* Figure out what mode we ended up. */
+ if (err)
+ return err;
+
+ grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
+
+ double_redraw = mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED
+ && !(mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP);
+
+ /* Make sure screen is set to the default background color. */
+ color = grub_video_map_rgba_color (grub_gfxterm_background.default_bg_color);
+ grub_video_fill_rect (color, 0, 0, mode_info.width, mode_info.height);
+ if (double_redraw)
+ {
+ grub_video_swap_buffers ();
+ grub_video_fill_rect (color, 0, 0, mode_info.width, mode_info.height);
+ }
+
+ /* Select the font to use. */
+ font_name = grub_env_get ("gfxterm_font");
+ if (! font_name)
+ font_name = ""; /* Allow fallback to any font. */
+
+ font = grub_font_get (font_name);
+ if (!font)
+ return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
+
+ grub_gfxterm_decorator_hook = NULL;
+
+ return grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY,
+ 0, 0, mode_info.width, mode_info.height,
+ double_redraw,
+ font, DEFAULT_BORDER_WIDTH);
+}
+
+static grub_err_t
+grub_gfxterm_term_init (struct grub_term_output *term __attribute__ ((unused)))
+{
+ char *tmp;
+ grub_err_t err;
+ const char *modevar;
+
+ /* Parse gfxmode environment variable if set. */
+ modevar = grub_env_get ("gfxmode");
+ if (! modevar || *modevar == 0)
+ err = grub_video_set_mode (DEFAULT_VIDEO_MODE,
+ GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
+ else
+ {
+ tmp = grub_xasprintf ("%s;" DEFAULT_VIDEO_MODE, modevar);
+ if (!tmp)
+ return grub_errno;
+ err = grub_video_set_mode (tmp, GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
+ grub_free (tmp);
+ }
+
+ if (err)
+ return err;
+
+ err = grub_gfxterm_fullscreen ();
+ if (err)
+ grub_video_restore ();
+
+ return err;
+}
+
+static void
+destroy_window (void)
+{
+ grub_virtual_screen_free ();
+}
+
+static grub_err_t
+grub_gfxterm_term_fini (struct grub_term_output *term __attribute__ ((unused)))
+{
+ unsigned i;
+ destroy_window ();
+ grub_video_restore ();
+
+ for (i = 0; i < virtual_screen.columns * virtual_screen.rows; i++)
+ {
+ grub_unicode_destroy_glyph (&virtual_screen.text_buffer[i].code);
+ virtual_screen.text_buffer[i].code.ncomb = 0;
+ virtual_screen.text_buffer[i].code.base = 0;
+ }
+
+ /* Clear error state. */
+ grub_errno = GRUB_ERR_NONE;
+ return GRUB_ERR_NONE;
+}
+
+static void
+redraw_screen_rect (unsigned int x, unsigned int y,
+ unsigned int width, unsigned int height)
+{
+ grub_video_color_t color;
+ grub_video_rect_t saved_view;
+
+ grub_video_set_active_render_target (render_target);
+ /* Save viewport and set it to our window. */
+ grub_video_get_viewport ((unsigned *) &saved_view.x,
+ (unsigned *) &saved_view.y,
+ (unsigned *) &saved_view.width,
+ (unsigned *) &saved_view.height);
+ grub_video_set_viewport (window.x, window.y, window.width, window.height);
+
+ if (grub_gfxterm_background.bitmap)
+ {
+ /* Render bitmap as background. */
+ grub_video_blit_bitmap (grub_gfxterm_background.bitmap,
+ GRUB_VIDEO_BLIT_REPLACE, x, y,
+ x, y,
+ width, height);
+
+ /* If bitmap is smaller than requested blit area, use background
+ color. */
+ color = virtual_screen.bg_color_display;
+
+ /* Fill right side of the bitmap if needed. */
+ if ((x + width >= grub_gfxterm_background.bitmap->mode_info.width)
+ && (y < grub_gfxterm_background.bitmap->mode_info.height))
+ {
+ int w = (x + width) - grub_gfxterm_background.bitmap->mode_info.width;
+ int h = height;
+ unsigned int tx = x;
+
+ if (y + height >= grub_gfxterm_background.bitmap->mode_info.height)
+ {
+ h = grub_gfxterm_background.bitmap->mode_info.height - y;
+ }
+
+ if (grub_gfxterm_background.bitmap->mode_info.width > tx)
+ {
+ tx = grub_gfxterm_background.bitmap->mode_info.width;
+ }
+
+ /* Render background layer. */
+ grub_video_fill_rect (color, tx, y, w, h);
+ }
+
+ /* Fill bottom side of the bitmap if needed. */
+ if (y + height >= grub_gfxterm_background.bitmap->mode_info.height)
+ {
+ int h = (y + height) - grub_gfxterm_background.bitmap->mode_info.height;
+ unsigned int ty = y;
+
+ if (grub_gfxterm_background.bitmap->mode_info.height > ty)
+ {
+ ty = grub_gfxterm_background.bitmap->mode_info.height;
+ }
+
+ /* Render background layer. */
+ grub_video_fill_rect (color, x, ty, width, h);
+ }
+ }
+ else
+ {
+ /* Render background layer. */
+ color = virtual_screen.bg_color_display;
+ grub_video_fill_rect (color, x, y, width, height);
+ }
+
+ if (grub_gfxterm_background.blend_text_bg)
+ /* Render text layer as blended. */
+ grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND, x, y,
+ x - virtual_screen.offset_x,
+ y - virtual_screen.offset_y,
+ width, height);
+ else
+ /* Render text layer as replaced (to get texts background color). */
+ grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_REPLACE, x, y,
+ x - virtual_screen.offset_x,
+ y - virtual_screen.offset_y,
+ width, height);
+
+ /* Restore saved viewport. */
+ grub_video_set_viewport (saved_view.x, saved_view.y,
+ saved_view.width, saved_view.height);
+ grub_video_set_active_render_target (render_target);
+}
+
+static void
+dirty_region_reset (void)
+{
+ dirty_region.top_left_x = -1;
+ dirty_region.top_left_y = -1;
+ dirty_region.bottom_right_x = -1;
+ dirty_region.bottom_right_y = -1;
+ repaint_was_scheduled = 0;
+}
+
+static int
+dirty_region_is_empty (void)
+{
+ if ((dirty_region.top_left_x == -1)
+ || (dirty_region.top_left_y == -1)
+ || (dirty_region.bottom_right_x == -1)
+ || (dirty_region.bottom_right_y == -1))
+ return 1;
+ return 0;
+}
+
+static void
+dirty_region_add_real (int x, int y, unsigned int width, unsigned int height)
+{
+ if (dirty_region_is_empty ())
+ {
+ dirty_region.top_left_x = x;
+ dirty_region.top_left_y = y;
+ dirty_region.bottom_right_x = x + width - 1;
+ dirty_region.bottom_right_y = y + height - 1;
+ }
+ else
+ {
+ if (x < dirty_region.top_left_x)
+ dirty_region.top_left_x = x;
+ if (y < dirty_region.top_left_y)
+ dirty_region.top_left_y = y;
+ if ((x + (int)width - 1) > dirty_region.bottom_right_x)
+ dirty_region.bottom_right_x = x + width - 1;
+ if ((y + (int)height - 1) > dirty_region.bottom_right_y)
+ dirty_region.bottom_right_y = y + height - 1;
+ }
+}
+
+static void
+dirty_region_add (int x, int y, unsigned int width, unsigned int height)
+{
+ if ((width == 0) || (height == 0))
+ return;
+
+ if (repaint_scheduled)
+ {
+ dirty_region_add_real (0, 0,
+ window.width, window.height);
+ repaint_scheduled = 0;
+ repaint_was_scheduled = 1;
+ }
+ dirty_region_add_real (x, y, width, height);
+}
+
+static void
+dirty_region_add_virtualscreen (void)
+{
+ /* Mark virtual screen as dirty. */
+ dirty_region_add (virtual_screen.offset_x, virtual_screen.offset_y,
+ virtual_screen.width, virtual_screen.height);
+}
+
+
+static void
+dirty_region_redraw (void)
+{
+ int x;
+ int y;
+ int width;
+ int height;
+
+ if (dirty_region_is_empty ())
+ return;
+
+ x = dirty_region.top_left_x;
+ y = dirty_region.top_left_y;
+
+ width = dirty_region.bottom_right_x - x + 1;
+ height = dirty_region.bottom_right_y - y + 1;
+
+ if (repaint_was_scheduled && grub_gfxterm_decorator_hook)
+ grub_gfxterm_decorator_hook ();
+
+ redraw_screen_rect (x, y, width, height);
+}
+
+static inline void
+paint_char (unsigned cx, unsigned cy)
+{
+ struct grub_colored_char *p;
+ struct grub_font_glyph *glyph;
+ grub_video_color_t color;
+ grub_video_color_t bgcolor;
+ unsigned int x;
+ unsigned int y;
+ int ascent;
+ unsigned int height;
+ unsigned int width;
+
+ if (cy + virtual_screen.total_scroll >= virtual_screen.rows)
+ return;
+
+ /* Find out active character. */
+ p = (virtual_screen.text_buffer
+ + cx + (cy * virtual_screen.columns));
+
+ if (!p->code.base)
+ return;
+
+ /* Get glyph for character. */
+ glyph = grub_font_construct_glyph (virtual_screen.font, &p->code);
+ if (!glyph)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+ ascent = grub_font_get_ascent (virtual_screen.font);
+
+ width = virtual_screen.normal_char_width * calculate_character_width(glyph);
+ height = virtual_screen.normal_char_height;
+
+ color = p->fg_color;
+ bgcolor = p->bg_color;
+
+ x = cx * virtual_screen.normal_char_width;
+ y = (cy + virtual_screen.total_scroll) * virtual_screen.normal_char_height;
+
+ /* Render glyph to text layer. */
+ grub_video_set_active_render_target (text_layer);
+ grub_video_fill_rect (bgcolor, x, y, width, height);
+ grub_font_draw_glyph (glyph, color, x, y + ascent);
+ grub_video_set_active_render_target (render_target);
+
+ /* Mark character to be drawn. */
+ dirty_region_add (virtual_screen.offset_x + x, virtual_screen.offset_y + y,
+ width, height);
+}
+
+static inline void
+write_char (void)
+{
+ paint_char (virtual_screen.cursor_x, virtual_screen.cursor_y);
+}
+
+static inline void
+draw_cursor (int show)
+{
+ unsigned int x;
+ unsigned int y;
+ unsigned int width;
+ unsigned int height;
+ unsigned int ascent;
+ grub_video_color_t color;
+
+ write_char ();
+
+ if (!show)
+ return;
+
+ if (virtual_screen.cursor_y + virtual_screen.total_scroll
+ >= virtual_screen.rows)
+ return;
+
+ /* Ensure that cursor doesn't go outside of character box. */
+ ascent = grub_font_get_ascent(virtual_screen.font);
+ if (ascent > virtual_screen.normal_char_height - 2)
+ ascent = virtual_screen.normal_char_height - 2;
+
+ /* Determine cursor properties and position on text layer. */
+ x = virtual_screen.cursor_x * virtual_screen.normal_char_width;
+ width = virtual_screen.normal_char_width;
+ color = virtual_screen.fg_color;
+ y = ((virtual_screen.cursor_y + virtual_screen.total_scroll)
+ * virtual_screen.normal_char_height
+ + ascent);
+ height = 2;
+
+ /* Render cursor to text layer. */
+ grub_video_set_active_render_target (text_layer);
+ grub_video_fill_rect (color, x, y, width, height);
+ grub_video_set_active_render_target (render_target);
+
+ /* Mark cursor to be redrawn. */
+ dirty_region_add (virtual_screen.offset_x + x,
+ virtual_screen.offset_y + y,
+ width, height);
+}
+
+static void
+real_scroll (void)
+{
+ unsigned int i, j, was_scroll;
+ grub_video_color_t color;
+
+ if (!virtual_screen.total_scroll)
+ return;
+
+ /* If we have bitmap, re-draw screen, otherwise scroll physical screen too. */
+ if (grub_gfxterm_background.bitmap)
+ {
+ /* Scroll physical screen. */
+ grub_video_set_active_render_target (text_layer);
+ color = virtual_screen.bg_color;
+ grub_video_scroll (color, 0, -virtual_screen.normal_char_height
+ * virtual_screen.total_scroll);
+
+ /* Mark virtual screen to be redrawn. */
+ dirty_region_add_virtualscreen ();
+ }
+ else
+ {
+ grub_video_rect_t saved_view;
+
+ /* Remove cursor. */
+ draw_cursor (0);
+
+ grub_video_set_active_render_target (render_target);
+
+ i = window.double_repaint ? 2 : 1;
+
+ color = virtual_screen.bg_color_display;
+
+ while (i--)
+ {
+ /* Save viewport and set it to our window. */
+ grub_video_get_viewport ((unsigned *) &saved_view.x,
+ (unsigned *) &saved_view.y,
+ (unsigned *) &saved_view.width,
+ (unsigned *) &saved_view.height);
+
+ grub_video_set_viewport (window.x, window.y, window.width,
+ window.height);
+
+ /* Clear new border area. */
+ grub_video_fill_rect (color,
+ virtual_screen.offset_x,
+ virtual_screen.offset_y,
+ virtual_screen.width,
+ virtual_screen.normal_char_height
+ * virtual_screen.total_scroll);
+
+ grub_video_set_active_render_target (render_target);
+ dirty_region_redraw ();
+
+ /* Scroll physical screen. */
+ grub_video_scroll (color, 0, -virtual_screen.normal_char_height
+ * virtual_screen.total_scroll);
+
+ /* Restore saved viewport. */
+ grub_video_set_viewport (saved_view.x, saved_view.y,
+ saved_view.width, saved_view.height);
+
+ if (i)
+ grub_video_swap_buffers ();
+ }
+ dirty_region_reset ();
+
+ /* Scroll physical screen. */
+ grub_video_set_active_render_target (text_layer);
+ color = virtual_screen.bg_color;
+ grub_video_scroll (color, 0, -virtual_screen.normal_char_height
+ * virtual_screen.total_scroll);
+
+ grub_video_set_active_render_target (render_target);
+
+ }
+
+ was_scroll = virtual_screen.total_scroll;
+ virtual_screen.total_scroll = 0;
+
+ if (was_scroll > virtual_screen.rows)
+ was_scroll = virtual_screen.rows;
+
+ /* Draw shadow part. */
+ for (i = virtual_screen.rows - was_scroll;
+ i < virtual_screen.rows; i++)
+ for (j = 0; j < virtual_screen.columns; j++)
+ paint_char (j, i);
+
+ /* Draw cursor if visible. */
+ if (virtual_screen.cursor_state)
+ draw_cursor (1);
+}
+
+static void
+scroll_up (void)
+{
+ unsigned int i;
+
+ /* Clear first line in text buffer. */
+ for (i = 0; i < virtual_screen.columns; i++)
+ grub_unicode_destroy_glyph (&virtual_screen.text_buffer[i].code);
+
+ /* Scroll text buffer with one line to up. */
+ grub_memmove (virtual_screen.text_buffer,
+ virtual_screen.text_buffer + virtual_screen.columns,
+ sizeof (*virtual_screen.text_buffer)
+ * virtual_screen.columns
+ * (virtual_screen.rows - 1));
+
+ /* Clear last line in text buffer. */
+ for (i = virtual_screen.columns * (virtual_screen.rows - 1);
+ i < virtual_screen.columns * virtual_screen.rows;
+ i++)
+ clear_char (&(virtual_screen.text_buffer[i]));
+
+ virtual_screen.total_scroll++;
+}
+
+static void
+grub_gfxterm_putchar (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c)
+{
+ if (!virtual_screen.functional)
+ return;
+
+ if (c->base == '\a')
+ /* FIXME */
+ return;
+
+ /* Erase current cursor, if any. */
+ if (virtual_screen.cursor_state)
+ draw_cursor (0);
+
+ if (c->base == '\b' || c->base == '\n' || c->base == '\r')
+ {
+ switch (c->base)
+ {
+ case '\b':
+ if (virtual_screen.cursor_x > 0)
+ virtual_screen.cursor_x--;
+ break;
+
+ case '\n':
+ if (virtual_screen.cursor_y >= virtual_screen.rows - 1)
+ scroll_up ();
+ else
+ virtual_screen.cursor_y++;
+ break;
+
+ case '\r':
+ virtual_screen.cursor_x = 0;
+ break;
+ }
+ }
+ else
+ {
+ struct grub_colored_char *p;
+ unsigned char char_width;
+
+ /* Calculate actual character width for glyph. This is number of
+ times of normal_font_width. */
+ char_width = grub_gfxterm_getcharwidth (term, c);
+
+ /* If we are about to exceed line length, wrap to next line. */
+ if (virtual_screen.cursor_x + char_width > virtual_screen.columns)
+ {
+ if (virtual_screen.cursor_y >= virtual_screen.rows - 1)
+ scroll_up ();
+ else
+ virtual_screen.cursor_y++;
+ }
+
+ /* Find position on virtual screen, and fill information. */
+ p = (virtual_screen.text_buffer +
+ virtual_screen.cursor_x +
+ virtual_screen.cursor_y * virtual_screen.columns);
+ grub_unicode_destroy_glyph (&p->code);
+ grub_unicode_set_glyph (&p->code, c);
+ grub_errno = GRUB_ERR_NONE;
+ p->fg_color = virtual_screen.fg_color;
+ p->bg_color = virtual_screen.bg_color;
+
+ /* If we have large glyph, add fixup info. */
+ if (char_width > 1)
+ {
+ unsigned i;
+
+ for (i = 1; i < char_width && p + i <
+ virtual_screen.text_buffer + virtual_screen.columns
+ * virtual_screen.rows; i++)
+ {
+ grub_unicode_destroy_glyph (&p[i].code);
+ p[i].code.base = 0;
+ }
+ }
+
+ /* Draw glyph. */
+ write_char ();
+
+ /* Make sure we scroll screen when needed and wrap line correctly. */
+ virtual_screen.cursor_x += char_width;
+ if (virtual_screen.cursor_x >= virtual_screen.columns)
+ {
+ virtual_screen.cursor_x = 0;
+
+ if (virtual_screen.cursor_y >= virtual_screen.rows - 1)
+ scroll_up ();
+ else
+ virtual_screen.cursor_y++;
+ }
+ }
+
+ /* Redraw cursor if it should be visible. */
+ /* Note: This will redraw the character as well, which means that the
+ above call to write_char is redundant when the cursor is showing. */
+ if (virtual_screen.cursor_state)
+ draw_cursor (1);
+}
+
+/* Use ASCII characters to determine normal character width. */
+static unsigned int
+calculate_normal_character_width (grub_font_t font)
+{
+ struct grub_font_glyph *glyph;
+ unsigned int width = 0;
+ unsigned int i;
+
+ /* Get properties of every printable ASCII character. */
+ for (i = 32; i < 127; i++)
+ {
+ glyph = grub_font_get_glyph (font, i);
+
+ /* Skip unknown characters. Should never happen on normal conditions. */
+ if (! glyph)
+ continue;
+
+ if (glyph->device_width > width)
+ width = glyph->device_width;
+ }
+ if (!width)
+ return 8;
+
+ return width;
+}
+
+static unsigned char
+calculate_character_width (struct grub_font_glyph *glyph)
+{
+ if (! glyph || glyph->device_width == 0)
+ return 1;
+
+ return (glyph->device_width
+ + (virtual_screen.normal_char_width - 1))
+ / virtual_screen.normal_char_width;
+}
+
+static grub_size_t
+grub_gfxterm_getcharwidth (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
+{
+ int dev_width;
+ dev_width = grub_font_get_constructed_device_width (virtual_screen.font, c);
+
+ if (dev_width == 0)
+ return 1;
+
+ return (dev_width + (virtual_screen.normal_char_width - 1))
+ / virtual_screen.normal_char_width;
+}
+
+static struct grub_term_coordinate
+grub_virtual_screen_getwh (struct grub_term_output *term __attribute__ ((unused)))
+{
+ return (struct grub_term_coordinate) { virtual_screen.columns, virtual_screen.rows };
+}
+
+static struct grub_term_coordinate
+grub_virtual_screen_getxy (struct grub_term_output *term __attribute__ ((unused)))
+{
+ return (struct grub_term_coordinate) { virtual_screen.cursor_x, virtual_screen.cursor_y };
+}
+
+static void
+grub_gfxterm_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
+ struct grub_term_coordinate pos)
+{
+ if (pos.x >= virtual_screen.columns)
+ pos.x = virtual_screen.columns - 1;
+
+ if (pos.y >= virtual_screen.rows)
+ pos.y = virtual_screen.rows - 1;
+
+ /* Erase current cursor, if any. */
+ if (virtual_screen.cursor_state)
+ draw_cursor (0);
+
+ virtual_screen.cursor_x = pos.x;
+ virtual_screen.cursor_y = pos.y;
+
+ /* Draw cursor if visible. */
+ if (virtual_screen.cursor_state)
+ draw_cursor (1);
+}
+
+static void
+grub_virtual_screen_cls (struct grub_term_output *term __attribute__ ((unused)))
+{
+ grub_uint32_t i;
+
+ for (i = 0; i < virtual_screen.columns * virtual_screen.rows; i++)
+ clear_char (&(virtual_screen.text_buffer[i]));
+
+ virtual_screen.cursor_x = virtual_screen.cursor_y = 0;
+}
+
+static void
+grub_gfxterm_cls (struct grub_term_output *term)
+{
+ grub_video_color_t color;
+
+ /* Clear virtual screen. */
+ grub_virtual_screen_cls (term);
+
+ /* Clear text layer. */
+ grub_video_set_active_render_target (text_layer);
+ color = virtual_screen.bg_color;
+ grub_video_fill_rect (color, 0, 0,
+ virtual_screen.width, virtual_screen.height);
+ grub_video_set_active_render_target (render_target);
+
+ /* Mark virtual screen to be redrawn. */
+ dirty_region_add_virtualscreen ();
+
+ grub_gfxterm_refresh (term);
+}
+
+static void
+grub_virtual_screen_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+ grub_term_color_state state)
+{
+ switch (state)
+ {
+ case GRUB_TERM_COLOR_STANDARD:
+ virtual_screen.term_color = virtual_screen.standard_color_setting;
+ break;
+
+ case GRUB_TERM_COLOR_NORMAL:
+ virtual_screen.term_color = grub_term_normal_color;
+ break;
+
+ case GRUB_TERM_COLOR_HIGHLIGHT:
+ virtual_screen.term_color = grub_term_highlight_color;
+ break;
+
+ default:
+ break;
+ }
+
+ /* Change color to virtual terminal. */
+ set_term_color (virtual_screen.term_color);
+}
+
+static void
+grub_gfxterm_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
+{
+ if (virtual_screen.cursor_state != on)
+ {
+ if (virtual_screen.cursor_state)
+ draw_cursor (0);
+ else
+ draw_cursor (1);
+
+ virtual_screen.cursor_state = on;
+ }
+}
+
+static void
+grub_gfxterm_refresh (struct grub_term_output *term __attribute__ ((unused)))
+{
+ real_scroll ();
+
+ /* Redraw only changed regions. */
+ dirty_region_redraw ();
+
+ grub_video_swap_buffers ();
+
+ if (window.double_repaint)
+ dirty_region_redraw ();
+ dirty_region_reset ();
+}
+
+static struct grub_term_output grub_video_term =
+ {
+ .name = "gfxterm",
+ .init = grub_gfxterm_term_init,
+ .fini = grub_gfxterm_term_fini,
+ .putchar = grub_gfxterm_putchar,
+ .getcharwidth = grub_gfxterm_getcharwidth,
+ .getwh = grub_virtual_screen_getwh,
+ .getxy = grub_virtual_screen_getxy,
+ .gotoxy = grub_gfxterm_gotoxy,
+ .cls = grub_gfxterm_cls,
+ .setcolorstate = grub_virtual_screen_setcolorstate,
+ .setcursor = grub_gfxterm_setcursor,
+ .refresh = grub_gfxterm_refresh,
+ .fullscreen = grub_gfxterm_fullscreen,
+ .flags = GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS,
+ .progress_update_divisor = GRUB_PROGRESS_SLOW,
+ .next = 0
+ };
+
+void
+grub_gfxterm_video_update_color (void)
+{
+ struct grub_video_render_target *old_target;
+
+ grub_video_get_active_render_target (&old_target);
+ grub_video_set_active_render_target (text_layer);
+ virtual_screen.bg_color = grub_video_map_rgba_color (grub_gfxterm_background.default_bg_color);
+ grub_video_set_active_render_target (old_target);
+ virtual_screen.bg_color_display =
+ grub_video_map_rgba_color (grub_gfxterm_background.default_bg_color);
+}
+
+void
+grub_gfxterm_get_dimensions (unsigned *width, unsigned *height)
+{
+ *width = window.width;
+ *height = window.height;
+}
+
+GRUB_MOD_INIT(gfxterm)
+{
+ grub_term_register_output ("gfxterm", &grub_video_term);
+}
+
+GRUB_MOD_FINI(gfxterm)
+{
+ grub_term_unregister_output (&grub_video_term);
+}
diff --git a/grub-core/term/gfxterm_background.c b/grub-core/term/gfxterm_background.c
new file mode 100644
index 0000000..8da71a8
--- /dev/null
+++ b/grub-core/term/gfxterm_background.c
@@ -0,0 +1,190 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009,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/term.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/font.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/video.h>
+#include <grub/gfxterm.h>
+#include <grub/bitmap.h>
+#include <grub/command.h>
+#include <grub/extcmd.h>
+#include <grub/bitmap_scale.h>
+#include <grub/i18n.h>
+#include <grub/color.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Option array indices. */
+enum
+ {
+ BACKGROUND_CMD_ARGINDEX_MODE = 0
+ };
+
+static const struct grub_arg_option background_image_cmd_options[] =
+ {
+ {"mode", 'm', 0, N_("Background image mode."),
+ /* TRANSLATORS: This refers to background image mode (stretched or
+ in left-top corner). Note that GRUB will accept only original
+ keywords stretch and normal, not the translated ones.
+ So please put both in translation
+ e.g. stretch(=%STRETCH%)|normal(=%NORMAL%).
+ The percents mark the translated version. Since many people
+ may not know the word stretch or normal I recommend
+ putting the translation either here or in "Background image mode."
+ string. */
+ N_("stretch|normal"),
+ ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+grub_gfxterm_background_image_cmd (grub_extcmd_context_t ctxt,
+ int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+
+ /* Check that we have video adapter active. */
+ if (grub_video_get_info(NULL) != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* Destroy existing background bitmap if loaded. */
+ if (grub_gfxterm_background.bitmap)
+ {
+ grub_video_bitmap_destroy (grub_gfxterm_background.bitmap);
+ grub_gfxterm_background.bitmap = 0;
+ grub_gfxterm_background.blend_text_bg = 0;
+
+ /* Mark whole screen as dirty. */
+ grub_gfxterm_schedule_repaint ();
+ }
+
+ /* If filename was provided, try to load that. */
+ if (argc >= 1)
+ {
+ /* Try to load new one. */
+ grub_video_bitmap_load (&grub_gfxterm_background.bitmap, args[0]);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* Determine if the bitmap should be scaled to fit the screen. */
+ if (!state[BACKGROUND_CMD_ARGINDEX_MODE].set
+ || grub_strcmp (state[BACKGROUND_CMD_ARGINDEX_MODE].arg,
+ "stretch") == 0)
+ {
+ unsigned int width, height;
+ grub_gfxterm_get_dimensions (&width, &height);
+ if (width
+ != grub_video_bitmap_get_width (grub_gfxterm_background.bitmap)
+ || height
+ != grub_video_bitmap_get_height (grub_gfxterm_background.bitmap))
+ {
+ struct grub_video_bitmap *scaled_bitmap;
+ grub_video_bitmap_create_scaled (&scaled_bitmap,
+ width,
+ height,
+ grub_gfxterm_background.bitmap,
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ /* Replace the original bitmap with the scaled one. */
+ grub_video_bitmap_destroy (grub_gfxterm_background.bitmap);
+ grub_gfxterm_background.bitmap = scaled_bitmap;
+ }
+ }
+ }
+
+ /* If bitmap was loaded correctly, display it. */
+ if (grub_gfxterm_background.bitmap)
+ {
+ grub_gfxterm_background.blend_text_bg = 1;
+
+ /* Mark whole screen as dirty. */
+ grub_gfxterm_schedule_repaint ();
+ }
+ }
+
+ /* All was ok. */
+ grub_errno = GRUB_ERR_NONE;
+ return grub_errno;
+}
+
+static grub_err_t
+grub_gfxterm_background_color_cmd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+ /* Check that we have video adapter active. */
+ if (grub_video_get_info (NULL) != GRUB_ERR_NONE)
+ return grub_errno;
+
+ if (grub_video_parse_color (args[0],
+ &grub_gfxterm_background.default_bg_color)
+ != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* Destroy existing background bitmap if loaded. */
+ if (grub_gfxterm_background.bitmap)
+ {
+ grub_video_bitmap_destroy (grub_gfxterm_background.bitmap);
+ grub_gfxterm_background.bitmap = 0;
+
+ /* Mark whole screen as dirty. */
+ grub_gfxterm_schedule_repaint ();
+ }
+
+ /* Set the background and border colors. The background color needs to be
+ compatible with the text layer. */
+ grub_gfxterm_video_update_color ();
+ grub_gfxterm_background.blend_text_bg = 1;
+
+ /* Mark whole screen as dirty. */
+ grub_gfxterm_schedule_repaint ();
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t background_image_cmd_handle;
+static grub_command_t background_color_cmd_handle;
+
+GRUB_MOD_INIT(gfxterm_background)
+{
+ background_image_cmd_handle =
+ grub_register_extcmd ("background_image",
+ grub_gfxterm_background_image_cmd, 0,
+ N_("[-m (stretch|normal)] FILE"),
+ N_("Load background image for active terminal."),
+ background_image_cmd_options);
+ background_color_cmd_handle =
+ grub_register_command ("background_color",
+ grub_gfxterm_background_color_cmd,
+ N_("COLOR"),
+ N_("Set background color for active terminal."));
+}
+
+GRUB_MOD_FINI(gfxterm_background)
+{
+ grub_unregister_command (background_color_cmd_handle);
+ grub_unregister_extcmd (background_image_cmd_handle);
+}
diff --git a/grub-core/term/i386/coreboot/cbmemc.c b/grub-core/term/i386/coreboot/cbmemc.c
new file mode 100644
index 0000000..cea9b84
--- /dev/null
+++ b/grub-core/term/i386/coreboot/cbmemc.c
@@ -0,0 +1,147 @@
+/*
+ * 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/term.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/terminfo.h>
+#include <grub/dl.h>
+#include <grub/coreboot/lbio.h>
+#include <grub/command.h>
+#include <grub/normal.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define CURSOR_MASK ((1 << 28) - 1)
+#define OVERFLOW (1 << 31)
+
+struct grub_linuxbios_cbmemc
+{
+ grub_uint32_t size;
+ grub_uint32_t cursor;
+ char body[0];
+};
+
+static struct grub_linuxbios_cbmemc *cbmemc;
+
+static void
+put (struct grub_term_output *term __attribute__ ((unused)), const int c)
+{
+ grub_uint32_t flags, cursor;
+ if (!cbmemc)
+ return;
+ flags = cbmemc->cursor & ~CURSOR_MASK;
+ cursor = cbmemc->cursor & CURSOR_MASK;
+ if (cursor >= cbmemc->size)
+ return;
+ cbmemc->body[cursor++] = c;
+ if (cursor >= cbmemc->size)
+ {
+ cursor = 0;
+ flags |= OVERFLOW;
+ }
+ cbmemc->cursor = flags | cursor;
+}
+
+struct grub_terminfo_output_state grub_cbmemc_terminfo_output =
+ {
+ .put = put,
+ .size = { 80, 24 }
+ };
+
+static struct grub_term_output grub_cbmemc_term_output =
+ {
+ .name = "cbmemc",
+ .init = grub_terminfo_output_init,
+ .fini = 0,
+ .putchar = grub_terminfo_putchar,
+ .getxy = grub_terminfo_getxy,
+ .getwh = grub_terminfo_getwh,
+ .gotoxy = grub_terminfo_gotoxy,
+ .cls = grub_terminfo_cls,
+ .setcolorstate = grub_terminfo_setcolorstate,
+ .setcursor = grub_terminfo_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_ASCII,
+ .data = &grub_cbmemc_terminfo_output,
+ .progress_update_divisor = GRUB_PROGRESS_NO_UPDATE
+ };
+
+static int
+iterate_linuxbios_table (grub_linuxbios_table_item_t table_item,
+ void *data __attribute__ ((unused)))
+{
+ if (table_item->tag != GRUB_LINUXBIOS_MEMBER_CBMEMC)
+ return 0;
+ cbmemc = (struct grub_linuxbios_cbmemc *) (grub_addr_t)
+ *(grub_uint64_t *) (table_item + 1);
+ return 1;
+}
+
+static grub_err_t
+grub_cmd_cbmemc (struct grub_command *cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ grub_size_t size, cursor;
+ struct grub_linuxbios_cbmemc *real_cbmemc;
+
+ if (!cbmemc)
+ return grub_error (GRUB_ERR_IO, "no CBMEM console found");
+
+ real_cbmemc = cbmemc;
+ cbmemc = 0;
+ cursor = real_cbmemc->cursor & CURSOR_MASK;
+ if (!(real_cbmemc->cursor & OVERFLOW) && cursor < real_cbmemc->size)
+ size = cursor;
+ else
+ size = real_cbmemc->size;
+ if (real_cbmemc->cursor & OVERFLOW)
+ {
+ if (cursor > size)
+ cursor = 0;
+ grub_xnputs(real_cbmemc->body + cursor, size - cursor);
+ grub_xnputs(real_cbmemc->body, cursor);
+ }
+ else
+ grub_xnputs(real_cbmemc->body, size);
+ cbmemc = real_cbmemc;
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT (cbmemc)
+{
+ grub_linuxbios_table_iterate (iterate_linuxbios_table, 0);
+
+ if (cbmemc)
+ grub_term_register_output ("cbmemc", &grub_cbmemc_term_output);
+
+ cmd =
+ grub_register_command ("cbmemc", grub_cmd_cbmemc,
+ 0, N_("Show CBMEM console content."));
+}
+
+
+GRUB_MOD_FINI (cbmemc)
+{
+ grub_term_unregister_output (&grub_cbmemc_term_output);
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/term/i386/pc/console.c b/grub-core/term/i386/pc/console.c
new file mode 100644
index 0000000..f6142a2
--- /dev/null
+++ b/grub-core/term/i386/pc/console.c
@@ -0,0 +1,310 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/memory.h>
+#include <grub/machine/console.h>
+#include <grub/term.h>
+#include <grub/types.h>
+#include <grub/machine/int.h>
+
+static grub_uint8_t grub_console_cur_color = 0x7;
+
+static void
+int10_9 (grub_uint8_t ch, grub_uint16_t n)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = ch | 0x0900;
+ regs.ebx = grub_console_cur_color & 0xff;
+ regs.ecx = n;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+}
+
+/*
+ * BIOS call "INT 10H Function 03h" to get cursor position
+ * Call with %ah = 0x03
+ * %bh = page
+ * Returns %ch = starting scan line
+ * %cl = ending scan line
+ * %dh = row (0 is top)
+ * %dl = column (0 is left)
+ */
+
+
+static struct grub_term_coordinate
+grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x0300;
+ regs.ebx = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+
+ return (struct grub_term_coordinate) {
+ (regs.edx & 0xff), ((regs.edx & 0xff00) >> 8) };
+}
+
+/*
+ * BIOS call "INT 10H Function 02h" to set cursor position
+ * Call with %ah = 0x02
+ * %bh = page
+ * %dh = row (0 is top)
+ * %dl = column (0 is left)
+ */
+static void
+grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
+ struct grub_term_coordinate pos)
+{
+ struct grub_bios_int_registers regs;
+
+ /* set page to 0 */
+ regs.ebx = 0;
+ regs.eax = 0x0200;
+ regs.edx = (pos.y << 8) | pos.x;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+}
+
+/*
+ *
+ * Put the character C on the console. Because GRUB wants to write a
+ * character with an attribute, this implementation is a bit tricky.
+ * If C is a control character (CR, LF, BEL, BS), use INT 10, AH = 0Eh
+ * (TELETYPE OUTPUT). Otherwise, use INT 10, AH = 9 to write character
+ * with attributes and advance cursor. If we are on the last column,
+ * let BIOS to wrap line correctly.
+ */
+static void
+grub_console_putchar_real (grub_uint8_t c)
+{
+ struct grub_bios_int_registers regs;
+ struct grub_term_coordinate pos;
+
+ if (c == 7 || c == 8 || c == 0xa || c == 0xd)
+ {
+ regs.eax = c | 0x0e00;
+ regs.ebx = 0x0001;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ return;
+ }
+
+ /* get the current position */
+ pos = grub_console_getxy (NULL);
+
+ /* write the character with the attribute */
+ int10_9 (c, 1);
+
+ /* check the column with the width */
+ if (pos.x >= 79)
+ {
+ grub_console_putchar_real (0x0d);
+ grub_console_putchar_real (0x0a);
+ }
+ else
+ grub_console_gotoxy (NULL, (struct grub_term_coordinate) { pos.x + 1,
+ pos.y });
+}
+
+static void
+grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
+{
+ grub_console_putchar_real (c->base);
+}
+
+/*
+ * BIOS call "INT 10H Function 09h" to write character and attribute
+ * Call with %ah = 0x09
+ * %al = (character)
+ * %bh = (page number)
+ * %bl = (attribute)
+ * %cx = (number of times)
+ */
+static void
+grub_console_cls (struct grub_term_output *term)
+{
+ /* move the cursor to the beginning */
+ grub_console_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
+
+ /* write spaces to the entire screen */
+ int10_9 (' ', 80 * 25);
+
+ /* move back the cursor */
+ grub_console_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
+}
+
+/*
+ * void grub_console_setcursor (int on)
+ * BIOS call "INT 10H Function 01h" to set cursor type
+ * Call with %ah = 0x01
+ * %ch = cursor starting scanline
+ * %cl = cursor ending scanline
+ */
+static void
+grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
+{
+ static grub_uint16_t console_cursor_shape = 0;
+ struct grub_bios_int_registers regs;
+
+ /* check if the standard cursor shape has already been saved */
+ if (!console_cursor_shape)
+ {
+ regs.eax = 0x0300;
+ regs.ebx = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ console_cursor_shape = regs.ecx;
+ if ((console_cursor_shape >> 8) >= (console_cursor_shape & 0xff))
+ console_cursor_shape = 0x0d0e;
+ }
+ /* set %cx to the designated cursor shape */
+ regs.ecx = on ? console_cursor_shape : 0x2000;
+ regs.eax = 0x0100;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+}
+
+/*
+ * if there is a character pending, return it; otherwise return -1
+ * BIOS call "INT 16H Function 01H" to check whether a character is pending
+ * Call with %ah = 0x1
+ * Return:
+ * If key waiting to be input:
+ * %ah = keyboard scan code
+ * %al = ASCII character
+ * Zero flag = clear
+ * else
+ * Zero flag = set
+ * BIOS call "INT 16H Function 00H" to read character from keyboard
+ * Call with %ah = 0x0
+ * Return: %ah = keyboard scan code
+ * %al = ASCII character
+ */
+
+static int
+grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ const grub_uint16_t bypass_table[] = {
+ 0x0100 | GRUB_TERM_ESC, 0x0f00 | GRUB_TERM_TAB, 0x0e00 | GRUB_TERM_BACKSPACE, 0x1c00 | '\r', 0x1c00 | '\n'
+ };
+ struct grub_bios_int_registers regs;
+ unsigned i;
+
+ /*
+ * Due to a bug in apple's bootcamp implementation, INT 16/AH = 0 would
+ * cause the machine to hang at the second keystroke. However, we can
+ * work around this problem by ensuring the presence of keystroke with
+ * INT 16/AH = 1 before calling INT 16/AH = 0.
+ */
+
+ regs.eax = 0x0100;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x16, &regs);
+ if (regs.flags & GRUB_CPU_INT_FLAGS_ZERO)
+ return GRUB_TERM_NO_KEY;
+
+ regs.eax = 0x0000;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x16, &regs);
+ if (!(regs.eax & 0xff))
+ return ((regs.eax >> 8) & 0xff) | GRUB_TERM_EXTENDED;
+
+ if ((regs.eax & 0xff) >= ' ')
+ return regs.eax & 0xff;
+
+ for (i = 0; i < ARRAY_SIZE (bypass_table); i++)
+ if (bypass_table[i] == (regs.eax & 0xffff))
+ return regs.eax & 0xff;
+
+ return (regs.eax & 0xff) + (('a' - 1) | GRUB_TERM_CTRL);
+}
+
+static const struct grub_machine_bios_data_area *bios_data_area =
+ (struct grub_machine_bios_data_area *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR;
+
+static int
+grub_console_getkeystatus (struct grub_term_input *term __attribute__ ((unused)))
+{
+ /* conveniently GRUB keystatus is modelled after BIOS one. */
+ return bios_data_area->keyboard_flag_lower & ~0x80;
+}
+
+static struct grub_term_coordinate
+grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
+{
+ return (struct grub_term_coordinate) { 80, 25 };
+}
+
+static void
+grub_console_setcolorstate (struct grub_term_output *term
+ __attribute__ ((unused)),
+ grub_term_color_state state)
+{
+ switch (state) {
+ case GRUB_TERM_COLOR_STANDARD:
+ grub_console_cur_color = GRUB_TERM_DEFAULT_STANDARD_COLOR & 0x7f;
+ break;
+ case GRUB_TERM_COLOR_NORMAL:
+ grub_console_cur_color = grub_term_normal_color & 0x7f;
+ break;
+ case GRUB_TERM_COLOR_HIGHLIGHT:
+ grub_console_cur_color = grub_term_highlight_color & 0x7f;
+ break;
+ default:
+ break;
+ }
+}
+
+static struct grub_term_input grub_console_term_input =
+ {
+ .name = "console",
+ .getkey = grub_console_getkey,
+ .getkeystatus = grub_console_getkeystatus
+ };
+
+static struct grub_term_output grub_console_term_output =
+ {
+ .name = "console",
+ .putchar = grub_console_putchar,
+ .getwh = grub_console_getwh,
+ .getxy = grub_console_getxy,
+ .gotoxy = grub_console_gotoxy,
+ .cls = grub_console_cls,
+ .setcolorstate = grub_console_setcolorstate,
+ .setcursor = grub_console_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_CP437,
+ .progress_update_divisor = GRUB_PROGRESS_FAST
+ };
+
+void
+grub_console_init (void)
+{
+ grub_term_register_output ("console", &grub_console_term_output);
+ grub_term_register_input ("console", &grub_console_term_input);
+}
+
+void
+grub_console_fini (void)
+{
+ grub_term_unregister_input (&grub_console_term_input);
+ grub_term_unregister_output (&grub_console_term_output);
+}
diff --git a/grub-core/term/i386/pc/mda_text.c b/grub-core/term/i386/pc/mda_text.c
new file mode 100644
index 0000000..c3a5a17
--- /dev/null
+++ b/grub-core/term/i386/pc/mda_text.c
@@ -0,0 +1,13 @@
+#define MODE_MDA 1
+#include "vga_text.c"
+
+GRUB_MOD_INIT(mda_text)
+{
+ grub_term_register_output ("mda_text", &grub_vga_text_term);
+}
+
+GRUB_MOD_FINI(mda_text)
+{
+ grub_term_unregister_output (&grub_vga_text_term);
+}
+
diff --git a/grub-core/term/i386/pc/vga_text.c b/grub-core/term/i386/pc/vga_text.c
new file mode 100644
index 0000000..88fecc5
--- /dev/null
+++ b/grub-core/term/i386/pc/vga_text.c
@@ -0,0 +1,288 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/cpu/io.h>
+#include <grub/types.h>
+#include <grub/vga.h>
+#include <grub/term.h>
+
+#if defined (GRUB_MACHINE_COREBOOT)
+#include <grub/machine/console.h>
+#endif
+
+/* MODESET is used for testing to force monochrome or colour mode.
+ You shouldn't use mda_text on vga.
+ */
+#ifdef MODESET
+#include <grub/machine/int.h>
+#endif
+
+#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_MULTIBOOT)
+#include <grub/machine/console.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define COLS 80
+#define ROWS 25
+
+static struct grub_term_coordinate grub_curr_pos;
+
+#ifdef __mips__
+#define VGA_TEXT_SCREEN ((grub_uint16_t *) 0xb00b8000)
+#define cr_read grub_vga_cr_read
+#define cr_write grub_vga_cr_write
+#elif defined (MODE_MDA)
+#define VGA_TEXT_SCREEN ((grub_uint16_t *) 0xb0000)
+#define cr_read grub_vga_cr_bw_read
+#define cr_write grub_vga_cr_bw_write
+#else
+#define VGA_TEXT_SCREEN ((grub_uint16_t *) 0xb8000)
+#define cr_read grub_vga_cr_read
+#define cr_write grub_vga_cr_write
+#endif
+
+static grub_uint8_t cur_color = 0x7;
+
+static void
+screen_write_char (int x, int y, short c)
+{
+ VGA_TEXT_SCREEN[y * COLS + x] = grub_cpu_to_le16 (c);
+}
+
+static short
+screen_read_char (int x, int y)
+{
+ return grub_le_to_cpu16 (VGA_TEXT_SCREEN[y * COLS + x]);
+}
+
+static void
+update_cursor (void)
+{
+ unsigned int pos = grub_curr_pos.y * COLS + grub_curr_pos.x;
+ cr_write (pos >> 8, GRUB_VGA_CR_CURSOR_ADDR_HIGH);
+ cr_write (pos & 0xFF, GRUB_VGA_CR_CURSOR_ADDR_LOW);
+}
+
+static void
+inc_y (void)
+{
+ grub_curr_pos.x = 0;
+ if (grub_curr_pos.y < ROWS - 1)
+ grub_curr_pos.y++;
+ else
+ {
+ int x, y;
+ for (y = 0; y < ROWS - 1; y++)
+ for (x = 0; x < COLS; x++)
+ screen_write_char (x, y, screen_read_char (x, y + 1));
+ for (x = 0; x < COLS; x++)
+ screen_write_char (x, ROWS - 1, ' ' | (cur_color << 8));
+ }
+}
+
+static void
+inc_x (void)
+{
+ if (grub_curr_pos.x >= COLS - 1)
+ inc_y ();
+ else
+ grub_curr_pos.x++;
+}
+
+static void
+grub_vga_text_putchar (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
+{
+ switch (c->base)
+ {
+ case '\b':
+ if (grub_curr_pos.x != 0)
+ screen_write_char (grub_curr_pos.x--, grub_curr_pos.y, ' ');
+ break;
+ case '\n':
+ inc_y ();
+ break;
+ case '\r':
+ grub_curr_pos.x = 0;
+ break;
+ default:
+ screen_write_char (grub_curr_pos.x, grub_curr_pos.y,
+ c->base | (cur_color << 8));
+ inc_x ();
+ }
+
+ update_cursor ();
+}
+
+static struct grub_term_coordinate
+grub_vga_text_getxy (struct grub_term_output *term __attribute__ ((unused)))
+{
+ return grub_curr_pos;
+}
+
+static void
+grub_vga_text_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
+ struct grub_term_coordinate pos)
+{
+ grub_curr_pos = pos;
+ update_cursor ();
+}
+
+static void
+grub_vga_text_cls (struct grub_term_output *term)
+{
+ int i;
+ for (i = 0; i < ROWS * COLS; i++)
+ VGA_TEXT_SCREEN[i] = grub_cpu_to_le16 (' ' | (cur_color << 8));
+ grub_vga_text_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
+}
+
+static void
+grub_vga_text_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
+{
+ grub_uint8_t old;
+ old = cr_read (GRUB_VGA_CR_CURSOR_START);
+ if (on)
+ cr_write (old & ~GRUB_VGA_CR_CURSOR_START_DISABLE,
+ GRUB_VGA_CR_CURSOR_START);
+ else
+ cr_write (old | GRUB_VGA_CR_CURSOR_START_DISABLE,
+ GRUB_VGA_CR_CURSOR_START);
+}
+
+static grub_err_t
+grub_vga_text_init_real (struct grub_term_output *term)
+{
+#ifdef MODESET
+ struct grub_bios_int_registers regs;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+
+#ifdef MODE_MDA
+ regs.eax = 7;
+#else
+ regs.eax = 3;
+#endif
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+#endif
+ grub_vga_text_cls (term);
+ return 0;
+}
+
+static grub_err_t
+grub_vga_text_fini_real (struct grub_term_output *term)
+{
+#ifdef MODESET
+ struct grub_bios_int_registers regs;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+
+ regs.eax = 3;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+#endif
+ grub_vga_text_cls (term);
+ return 0;
+}
+
+static struct grub_term_coordinate
+grub_vga_text_getwh (struct grub_term_output *term __attribute__ ((unused)))
+{
+ return (struct grub_term_coordinate) { 80, 25 };
+}
+
+#ifndef MODE_MDA
+
+static void
+grub_vga_text_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+ grub_term_color_state state)
+{
+ switch (state) {
+ case GRUB_TERM_COLOR_STANDARD:
+ cur_color = GRUB_TERM_DEFAULT_STANDARD_COLOR & 0x7f;
+ break;
+ case GRUB_TERM_COLOR_NORMAL:
+ cur_color = grub_term_normal_color & 0x7f;
+ break;
+ case GRUB_TERM_COLOR_HIGHLIGHT:
+ cur_color = grub_term_highlight_color & 0x7f;
+ break;
+ default:
+ break;
+ }
+}
+
+#else
+static void
+grub_vga_text_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+ grub_term_color_state state)
+{
+ switch (state) {
+ case GRUB_TERM_COLOR_STANDARD:
+ cur_color = 0x07;
+ break;
+ case GRUB_TERM_COLOR_NORMAL:
+ cur_color = 0x07;
+ break;
+ case GRUB_TERM_COLOR_HIGHLIGHT:
+ cur_color = 0x70;
+ break;
+ default:
+ break;
+ }
+}
+#endif
+
+static struct grub_term_output grub_vga_text_term =
+ {
+#ifdef MODE_MDA
+ .name = "mda_text",
+#else
+ .name = "vga_text",
+#endif
+ .init = grub_vga_text_init_real,
+ .fini = grub_vga_text_fini_real,
+ .putchar = grub_vga_text_putchar,
+ .getwh = grub_vga_text_getwh,
+ .getxy = grub_vga_text_getxy,
+ .gotoxy = grub_vga_text_gotoxy,
+ .cls = grub_vga_text_cls,
+ .setcolorstate = grub_vga_text_setcolorstate,
+ .setcursor = grub_vga_text_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_CP437,
+ .progress_update_divisor = GRUB_PROGRESS_FAST
+ };
+
+#ifndef MODE_MDA
+
+GRUB_MOD_INIT(vga_text)
+{
+#ifdef GRUB_MACHINE_COREBOOT
+ if (!grub_video_coreboot_fbtable)
+#endif
+ grub_term_register_output ("vga_text", &grub_vga_text_term);
+}
+
+GRUB_MOD_FINI(vga_text)
+{
+ grub_term_unregister_output (&grub_vga_text_term);
+}
+
+#endif
diff --git a/grub-core/term/ieee1275/console.c b/grub-core/term/ieee1275/console.c
new file mode 100644
index 0000000..7e797a7
--- /dev/null
+++ b/grub-core/term/ieee1275/console.c
@@ -0,0 +1,267 @@
+/* console.c -- Open Firmware console for GRUB. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/term.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/terminfo.h>
+#include <grub/ieee1275/console.h>
+#include <grub/ieee1275/ieee1275.h>
+
+static grub_ieee1275_ihandle_t stdout_ihandle;
+static grub_ieee1275_ihandle_t stdin_ihandle;
+
+extern struct grub_terminfo_output_state grub_console_terminfo_output;
+
+struct color
+{
+ int red;
+ int green;
+ int blue;
+};
+
+/* Use serial colors as they are default on most firmwares and some firmwares
+ ignore set-color!. Additionally output may be redirected to serial. */
+static struct color colors[] =
+ {
+ // {R, G, B}
+ {0x00, 0x00, 0x00}, // 0 = black
+ {0xA8, 0x00, 0x00}, // 1 = red
+ {0x00, 0xA8, 0x00}, // 2 = green
+ {0xFE, 0xFE, 0x54}, // 3 = yellow
+ {0x00, 0x00, 0xA8}, // 4 = blue
+ {0xA8, 0x00, 0xA8}, // 5 = magenta
+ {0x00, 0xA8, 0xA8}, // 6 = cyan
+ {0xFE, 0xFE, 0xFE} // 7 = white
+ };
+
+static void
+put (struct grub_term_output *term __attribute__ ((unused)), const int c)
+{
+ char chr = c;
+
+ grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
+}
+
+static int
+readkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ grub_uint8_t c;
+ grub_ssize_t actual = 0;
+
+ grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
+ if (actual > 0)
+ return c;
+ return -1;
+}
+
+static void
+grub_console_dimensions (void)
+{
+ grub_ieee1275_ihandle_t options;
+ grub_ieee1275_phandle_t stdout_phandle;
+ char val[1024];
+
+ /* Always assume 80x24 on serial since screen-#rows/screen-#columns is often
+ garbage for such devices. */
+ if (! grub_ieee1275_instance_to_package (stdout_ihandle,
+ &stdout_phandle)
+ && ! grub_ieee1275_package_to_path (stdout_phandle,
+ val, sizeof (val) - 1, 0))
+ {
+ grub_ieee1275_ihandle_t stdout_options;
+ val[sizeof (val) - 1] = 0;
+
+ if (! grub_ieee1275_finddevice (val, &stdout_options)
+ && ! grub_ieee1275_get_property (stdout_options, "device_type",
+ val, sizeof (val) - 1, 0))
+ {
+ val[sizeof (val) - 1] = 0;
+ if (grub_strcmp (val, "serial") == 0)
+ {
+ grub_console_terminfo_output.size.x = 80;
+ grub_console_terminfo_output.size.y = 24;
+ return;
+ }
+ }
+ }
+
+ if (! grub_ieee1275_finddevice ("/options", &options)
+ && options != (grub_ieee1275_ihandle_t) -1)
+ {
+ if (! grub_ieee1275_get_property (options, "screen-#columns",
+ val, sizeof (val) - 1, 0))
+ {
+ val[sizeof (val) - 1] = 0;
+ grub_console_terminfo_output.size.x
+ = (grub_uint8_t) grub_strtoul (val, 0, 10);
+ }
+ if (! grub_ieee1275_get_property (options, "screen-#rows",
+ val, sizeof (val) - 1, 0))
+ {
+ val[sizeof (val) - 1] = 0;
+ grub_console_terminfo_output.size.y
+ = (grub_uint8_t) grub_strtoul (val, 0, 10);
+ }
+ }
+
+ /* Bogus default value on SLOF in QEMU. */
+ if (grub_console_terminfo_output.size.x == 200
+ && grub_console_terminfo_output.size.y == 200)
+ {
+ grub_console_terminfo_output.size.x = 80;
+ grub_console_terminfo_output.size.y = 24;
+ }
+
+ /* Use a small console by default. */
+ if (! grub_console_terminfo_output.size.x)
+ grub_console_terminfo_output.size.x = 80;
+ if (! grub_console_terminfo_output.size.y)
+ grub_console_terminfo_output.size.y = 24;
+}
+
+static void
+grub_console_setcursor (struct grub_term_output *term,
+ int on)
+{
+ grub_terminfo_setcursor (term, on);
+
+ if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_HAS_CURSORONOFF))
+ return;
+
+ /* Understood by the Open Firmware flavour in OLPC. */
+ if (on)
+ grub_ieee1275_interpret ("cursor-on", 0);
+ else
+ grub_ieee1275_interpret ("cursor-off", 0);
+}
+
+static grub_err_t
+grub_console_init_input (struct grub_term_input *term)
+{
+ grub_ssize_t actual;
+
+ if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen, "stdin", &stdin_ihandle,
+ sizeof stdin_ihandle, &actual)
+ || actual != sizeof stdin_ihandle)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot find stdin");
+
+ return grub_terminfo_input_init (term);
+}
+
+static grub_err_t
+grub_console_init_output (struct grub_term_output *term)
+{
+ grub_ssize_t actual;
+
+ /* The latest PowerMacs don't actually initialize the screen for us, so we
+ * use this trick to re-open the output device (but we avoid doing this on
+ * platforms where it's known to be broken). */
+ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT))
+ grub_ieee1275_interpret ("output-device output", 0);
+
+ if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen, "stdout", &stdout_ihandle,
+ sizeof stdout_ihandle, &actual)
+ || actual != sizeof stdout_ihandle)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot find stdout");
+
+ /* Initialize colors. */
+ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS))
+ {
+ unsigned col;
+ for (col = 0; col < ARRAY_SIZE (colors); col++)
+ grub_ieee1275_set_color (stdout_ihandle, col, colors[col].red,
+ colors[col].green, colors[col].blue);
+
+ /* Set the right fg and bg colors. */
+ grub_terminfo_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
+ }
+
+ grub_console_dimensions ();
+
+ grub_terminfo_output_init (term);
+
+ return 0;
+}
+
+
+
+struct grub_terminfo_input_state grub_console_terminfo_input =
+ {
+ .readkey = readkey
+ };
+
+struct grub_terminfo_output_state grub_console_terminfo_output =
+ {
+ .put = put,
+ .size = { 80, 24 }
+ };
+
+static struct grub_term_input grub_console_term_input =
+ {
+ .name = "console",
+ .init = grub_console_init_input,
+ .getkey = grub_terminfo_getkey,
+ .data = &grub_console_terminfo_input
+ };
+
+static struct grub_term_output grub_console_term_output =
+ {
+ .name = "console",
+ .init = grub_console_init_output,
+ .putchar = grub_terminfo_putchar,
+ .getxy = grub_terminfo_getxy,
+ .getwh = grub_terminfo_getwh,
+ .gotoxy = grub_terminfo_gotoxy,
+ .cls = grub_terminfo_cls,
+ .setcolorstate = grub_terminfo_setcolorstate,
+ .setcursor = grub_console_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_ASCII,
+ .data = &grub_console_terminfo_output,
+ .progress_update_divisor = GRUB_PROGRESS_FAST
+ };
+
+void
+grub_console_init_early (void)
+{
+ grub_term_register_input ("console", &grub_console_term_input);
+ grub_term_register_output ("console", &grub_console_term_output);
+}
+
+void
+grub_console_init_lately (void)
+{
+ const char *type;
+
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_ANSI))
+ type = "dumb";
+ else if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN))
+ type = "ieee1275-nocursor";
+ else
+ type = "ieee1275";
+ grub_terminfo_init ();
+ grub_terminfo_output_register (&grub_console_term_output, type);
+}
+
+void
+grub_console_fini (void)
+{
+}
diff --git a/grub-core/term/ieee1275/escc.c b/grub-core/term/ieee1275/escc.c
new file mode 100644
index 0000000..e605ff2
--- /dev/null
+++ b/grub-core/term/ieee1275/escc.c
@@ -0,0 +1,319 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,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/serial.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct grub_escc_descriptor
+{
+ volatile grub_uint8_t *escc_ctrl;
+ volatile grub_uint8_t *escc_data;
+};
+
+static void
+do_real_config (struct grub_serial_port *port)
+{
+ grub_uint8_t bitsspec;
+ grub_uint8_t parity_stop_spec;
+ if (port->configured)
+ return;
+
+ /* Make sure the port is waiting for address now. */
+ (void) *port->escc_desc->escc_ctrl;
+ switch (port->config.speed)
+ {
+ case 57600:
+ *port->escc_desc->escc_ctrl = 13;
+ *port->escc_desc->escc_ctrl = 0;
+ *port->escc_desc->escc_ctrl = 12;
+ *port->escc_desc->escc_ctrl = 0;
+ *port->escc_desc->escc_ctrl = 14;
+ *port->escc_desc->escc_ctrl = 1;
+ *port->escc_desc->escc_ctrl = 11;
+ *port->escc_desc->escc_ctrl = 0x50;
+ break;
+ case 38400:
+ *port->escc_desc->escc_ctrl = 13;
+ *port->escc_desc->escc_ctrl = 0;
+ *port->escc_desc->escc_ctrl = 12;
+ *port->escc_desc->escc_ctrl = 1;
+ *port->escc_desc->escc_ctrl = 14;
+ *port->escc_desc->escc_ctrl = 1;
+ *port->escc_desc->escc_ctrl = 11;
+ *port->escc_desc->escc_ctrl = 0x50;
+ break;
+ }
+
+ parity_stop_spec = 0;
+ switch (port->config.parity)
+ {
+ case GRUB_SERIAL_PARITY_NONE:
+ parity_stop_spec |= 0;
+ break;
+ case GRUB_SERIAL_PARITY_ODD:
+ parity_stop_spec |= 1;
+ break;
+ case GRUB_SERIAL_PARITY_EVEN:
+ parity_stop_spec |= 3;
+ break;
+ }
+
+ switch (port->config.stop_bits)
+ {
+ case GRUB_SERIAL_STOP_BITS_1:
+ parity_stop_spec |= 0x4;
+ break;
+ case GRUB_SERIAL_STOP_BITS_1_5:
+ parity_stop_spec |= 0x8;
+ break;
+ case GRUB_SERIAL_STOP_BITS_2:
+ parity_stop_spec |= 0xc;
+ break;
+ }
+
+ *port->escc_desc->escc_ctrl = 4;
+ *port->escc_desc->escc_ctrl = 0x40 | parity_stop_spec;
+
+ bitsspec = port->config.word_len - 5;
+ bitsspec = ((bitsspec >> 1) | (bitsspec << 1)) & 3;
+
+ *port->escc_desc->escc_ctrl = 3;
+ *port->escc_desc->escc_ctrl = (bitsspec << 6) | 0x1;
+
+ port->configured = 1;
+
+ return;
+}
+
+/* Fetch a key. */
+static int
+serial_hw_fetch (struct grub_serial_port *port)
+{
+ do_real_config (port);
+
+ *port->escc_desc->escc_ctrl = 0;
+ if (*port->escc_desc->escc_ctrl & 1)
+ return *port->escc_desc->escc_data;
+ return -1;
+}
+
+/* Put a character. */
+static void
+serial_hw_put (struct grub_serial_port *port, const int c)
+{
+ grub_uint64_t endtime;
+
+ do_real_config (port);
+
+ if (port->broken > 5)
+ endtime = grub_get_time_ms ();
+ else if (port->broken > 1)
+ endtime = grub_get_time_ms () + 50;
+ else
+ endtime = grub_get_time_ms () + 200;
+ /* Wait until the transmitter holding register is empty. */
+ while (1)
+ {
+ *port->escc_desc->escc_ctrl = 0;
+ if (*port->escc_desc->escc_ctrl & 4)
+ break;
+ if (grub_get_time_ms () > endtime)
+ {
+ port->broken++;
+ /* There is something wrong. But what can I do? */
+ return;
+ }
+ }
+
+ if (port->broken)
+ port->broken--;
+
+ *port->escc_desc->escc_data = c;
+}
+
+/* Initialize a serial device. PORT is the port number for a serial device.
+ SPEED is a DTE-DTE speed which must be one of these: 2400, 4800, 9600,
+ 19200, 38400, 57600 and 115200. WORD_LEN is the word length to be used
+ for the device. Likewise, PARITY is the type of the parity and
+ STOP_BIT_LEN is the length of the stop bit. The possible values for
+ WORD_LEN, PARITY and STOP_BIT_LEN are defined in the header file as
+ macros. */
+static grub_err_t
+serial_hw_configure (struct grub_serial_port *port __attribute__ ((unused)),
+ struct grub_serial_config *config __attribute__ ((unused)))
+{
+ if (config->speed != 38400 && config->speed != 57600)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port speed"));
+
+ if (config->parity != GRUB_SERIAL_PARITY_NONE
+ && config->parity != GRUB_SERIAL_PARITY_ODD
+ && config->parity != GRUB_SERIAL_PARITY_EVEN)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port parity"));
+
+ if (config->stop_bits != GRUB_SERIAL_STOP_BITS_1
+ && config->stop_bits != GRUB_SERIAL_STOP_BITS_1_5
+ && config->stop_bits != GRUB_SERIAL_STOP_BITS_2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port stop bits number"));
+
+ if (config->word_len < 5 || config->word_len > 8)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port word length"));
+
+ port->config = *config;
+ port->configured = 0;
+
+ /* FIXME: should check if the serial terminal was found. */
+
+ return GRUB_ERR_NONE;
+}
+
+struct grub_serial_driver grub_escc_driver =
+ {
+ .configure = serial_hw_configure,
+ .fetch = serial_hw_fetch,
+ .put = serial_hw_put
+ };
+
+static struct grub_escc_descriptor escc_descs[2];
+static char *macio = 0;
+
+static void
+add_device (grub_addr_t addr, int channel)
+{
+ struct grub_serial_port *port;
+ grub_err_t err;
+ struct grub_serial_config config =
+ {
+ .speed = 38400,
+ .word_len = 8,
+ .parity = GRUB_SERIAL_PARITY_NONE,
+ .stop_bits = GRUB_SERIAL_STOP_BITS_1
+ };
+
+ escc_descs[channel].escc_ctrl
+ = (volatile grub_uint8_t *) (grub_addr_t) addr;
+ escc_descs[channel].escc_data = escc_descs[channel].escc_ctrl + 16;
+
+ port = grub_zalloc (sizeof (*port));
+ if (!port)
+ {
+ grub_errno = 0;
+ return;
+ }
+
+ port->name = grub_xasprintf ("escc-ch-%c", channel + 'a');
+ if (!port->name)
+ {
+ grub_errno = 0;
+ return;
+ }
+
+ port->escc_desc = &escc_descs[channel];
+
+ port->driver = &grub_escc_driver;
+
+ err = port->driver->configure (port, &config);
+ if (err)
+ grub_print_error ();
+
+ grub_serial_register (port);
+}
+
+static int
+find_macio (struct grub_ieee1275_devalias *alias)
+{
+ if (grub_strcmp (alias->type, "mac-io") != 0)
+ return 0;
+ macio = grub_strdup (alias->path);
+ return 1;
+}
+
+GRUB_MOD_INIT (escc)
+{
+ grub_uint32_t macio_addr[4];
+ grub_uint32_t escc_addr[2];
+ grub_ieee1275_phandle_t dev;
+ struct grub_ieee1275_devalias alias;
+ char *escc = 0;
+
+ grub_ieee1275_devices_iterate (find_macio);
+ if (!macio)
+ return;
+
+ FOR_IEEE1275_DEVCHILDREN(macio, alias)
+ if (grub_strcmp (alias.type, "escc") == 0)
+ {
+ escc = grub_strdup (alias.path);
+ break;
+ }
+ grub_ieee1275_devalias_free (&alias);
+ if (!escc)
+ {
+ grub_free (macio);
+ return;
+ }
+
+ if (grub_ieee1275_finddevice (macio, &dev))
+ {
+ grub_free (macio);
+ grub_free (escc);
+ return;
+ }
+ if (grub_ieee1275_get_integer_property (dev, "assigned-addresses",
+ macio_addr, sizeof (macio_addr), 0))
+ {
+ grub_free (macio);
+ grub_free (escc);
+ return;
+ }
+
+ if (grub_ieee1275_finddevice (escc, &dev))
+ {
+ grub_free (macio);
+ grub_free (escc);
+ return;
+ }
+
+ if (grub_ieee1275_get_integer_property (dev, "reg",
+ escc_addr, sizeof (escc_addr), 0))
+ {
+ grub_free (macio);
+ grub_free (escc);
+ return;
+ }
+
+ add_device (macio_addr[2] + escc_addr[0] + 32, 0);
+ add_device (macio_addr[2] + escc_addr[0], 1);
+
+ grub_free (macio);
+ grub_free (escc);
+}
+
+GRUB_MOD_FINI (escc)
+{
+}
diff --git a/grub-core/term/ieee1275/serial.c b/grub-core/term/ieee1275/serial.c
new file mode 100644
index 0000000..9e71ca4
--- /dev/null
+++ b/grub-core/term/ieee1275/serial.c
@@ -0,0 +1,287 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,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/serial.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/i18n.h>
+#include <grub/ieee1275/console.h>
+
+#define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_cell_t) 0)
+
+struct ofserial_hash_ent
+{
+ char *devpath;
+ /* Pointer to shortest available name on nodes representing canonical names,
+ otherwise NULL. */
+ const char *shortest;
+ struct ofserial_hash_ent *next;
+};
+
+static void
+do_real_config (struct grub_serial_port *port)
+{
+ if (port->configured)
+ return;
+
+ if (grub_ieee1275_open (port->elem->devpath, &port->handle)
+ || port->handle == (grub_ieee1275_ihandle_t) -1)
+ port->handle = IEEE1275_IHANDLE_INVALID;
+
+ port->configured = 1;
+}
+
+/* Fetch a key. */
+static int
+serial_hw_fetch (struct grub_serial_port *port)
+{
+ grub_ssize_t actual;
+ char c;
+
+ do_real_config (port);
+
+ if (port->handle == IEEE1275_IHANDLE_INVALID)
+ return -1;
+ grub_ieee1275_read (port->handle, &c, 1, &actual);
+
+ if (actual <= 0)
+ return -1;
+ return c;
+}
+
+/* Put a character. */
+static void
+serial_hw_put (struct grub_serial_port *port, const int c)
+{
+ grub_ssize_t actual;
+ char c0 = c;
+
+ do_real_config (port);
+
+ if (port->handle == IEEE1275_IHANDLE_INVALID)
+ return;
+
+ grub_ieee1275_write (port->handle, &c0, 1, &actual);
+}
+
+/* Initialize a serial device. PORT is the port number for a serial device.
+ SPEED is a DTE-DTE speed which must be one of these: 2400, 4800, 9600,
+ 19200, 38400, 57600 and 115200. WORD_LEN is the word length to be used
+ for the device. Likewise, PARITY is the type of the parity and
+ STOP_BIT_LEN is the length of the stop bit. The possible values for
+ WORD_LEN, PARITY and STOP_BIT_LEN are defined in the header file as
+ macros. */
+static grub_err_t
+serial_hw_configure (struct grub_serial_port *port __attribute__ ((unused)),
+ struct grub_serial_config *config __attribute__ ((unused)))
+{
+ /* FIXME: no IEEE1275 serial config available. */
+
+ return GRUB_ERR_NONE;
+}
+
+struct grub_serial_driver grub_ofserial_driver =
+ {
+ .configure = serial_hw_configure,
+ .fetch = serial_hw_fetch,
+ .put = serial_hw_put
+ };
+
+#define OFSERIAL_HASH_SZ 8
+static struct ofserial_hash_ent *ofserial_hash[OFSERIAL_HASH_SZ];
+
+static int
+ofserial_hash_fn (const char *devpath)
+{
+ int hash = 0;
+ while (*devpath)
+ hash ^= *devpath++;
+ return (hash & (OFSERIAL_HASH_SZ - 1));
+}
+
+static struct ofserial_hash_ent *
+ofserial_hash_find (const char *devpath)
+{
+ struct ofserial_hash_ent *p = ofserial_hash[ofserial_hash_fn(devpath)];
+
+ while (p)
+ {
+ if (!grub_strcmp (p->devpath, devpath))
+ break;
+ p = p->next;
+ }
+ return p;
+}
+
+static struct ofserial_hash_ent *
+ofserial_hash_add_real (char *devpath)
+{
+ struct ofserial_hash_ent *p;
+ struct ofserial_hash_ent **head = &ofserial_hash[ofserial_hash_fn(devpath)];
+
+ p = grub_malloc(sizeof (*p));
+ if (!p)
+ return NULL;
+
+ p->devpath = devpath;
+ p->next = *head;
+ p->shortest = 0;
+ *head = p;
+ return p;
+}
+
+static struct ofserial_hash_ent *
+ofserial_hash_add (char *devpath, char *curcan)
+{
+ struct ofserial_hash_ent *p, *pcan;
+
+ p = ofserial_hash_add_real (devpath);
+
+ grub_dprintf ("serial", "devpath = %s, canonical = %s\n", devpath, curcan);
+
+ if (!curcan)
+ {
+ p->shortest = devpath;
+ return p;
+ }
+
+ pcan = ofserial_hash_find (curcan);
+ if (!pcan)
+ pcan = ofserial_hash_add_real (curcan);
+ else
+ grub_free (curcan);
+
+ if (!pcan)
+ grub_errno = GRUB_ERR_NONE;
+ else
+ {
+ if (!pcan->shortest
+ || grub_strlen (pcan->shortest) > grub_strlen (devpath))
+ pcan->shortest = devpath;
+ }
+
+ return p;
+}
+
+static void
+dev_iterate_real (struct grub_ieee1275_devalias *alias,
+ int use_name)
+{
+ struct ofserial_hash_ent *op;
+
+ if (grub_strcmp (alias->type, "serial") != 0)
+ return;
+
+ grub_dprintf ("serial", "serial name = %s, path = %s\n", alias->name,
+ alias->path);
+
+ op = ofserial_hash_find (alias->path);
+ if (!op)
+ {
+ char *name = grub_strdup (use_name ? alias->name : alias->path);
+ char *can = grub_strdup (alias->path);
+ if (!name || !can)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ grub_free (name);
+ grub_free (can);
+ return;
+ }
+ op = ofserial_hash_add (name, can);
+ }
+ return;
+}
+
+static int
+dev_iterate (struct grub_ieee1275_devalias *alias)
+{
+ dev_iterate_real (alias, 0);
+ return 0;
+}
+
+static const char *
+add_port (struct ofserial_hash_ent *ent)
+{
+ struct grub_serial_port *port;
+ char *ptr;
+ grub_err_t err;
+
+ if (!ent->shortest)
+ return NULL;
+
+ port = grub_zalloc (sizeof (*port));
+ if (!port)
+ return NULL;
+ port->name = grub_malloc (sizeof ("ieee1275/")
+ + grub_strlen (ent->shortest));
+ port->elem = ent;
+ if (!port->name)
+ return NULL;
+ ptr = grub_stpcpy (port->name, "ieee1275/");
+ grub_strcpy (ptr, ent->shortest);
+
+ port->driver = &grub_ofserial_driver;
+ err = grub_serial_config_defaults (port);
+ if (err)
+ grub_print_error ();
+
+ grub_serial_register (port);
+
+ return port->name;
+}
+
+const char *
+grub_ofserial_add_port (const char *path)
+{
+ struct ofserial_hash_ent *ent;
+ char *name = grub_strdup (path);
+ char *can = grub_strdup (path);
+
+ if (!name || ! can)
+ {
+ grub_free (name);
+ grub_free (can);
+ return NULL;
+ }
+
+ ent = ofserial_hash_add (name, can);
+ return add_port (ent);
+}
+
+void
+grub_ofserial_init (void)
+{
+ unsigned i;
+ struct grub_ieee1275_devalias alias;
+
+ FOR_IEEE1275_DEVALIASES(alias)
+ dev_iterate_real (&alias, 1);
+
+ grub_ieee1275_devices_iterate (dev_iterate);
+
+ for (i = 0; i < ARRAY_SIZE (ofserial_hash); i++)
+ {
+ struct ofserial_hash_ent *ent;
+ for (ent = ofserial_hash[i]; ent; ent = ent->next)
+ add_port (ent);
+ }
+}
+
diff --git a/grub-core/term/morse.c b/grub-core/term/morse.c
new file mode 100644
index 0000000..13b8e86
--- /dev/null
+++ b/grub-core/term/morse.c
@@ -0,0 +1,133 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011,2012,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/term.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/time.h>
+#include <grub/speaker.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define BASE_TIME 250
+#define DIH 1
+#define DAH 3
+#define END 0
+
+static const char codes[0x80][6] =
+ {
+ ['0'] = { DAH, DAH, DAH, DAH, DAH, END },
+ ['1'] = { DIH, DAH, DAH, DAH, DAH, END },
+ ['2'] = { DIH, DIH, DAH, DAH, DAH, END },
+ ['3'] = { DIH, DIH, DIH, DAH, DAH, END },
+ ['4'] = { DIH, DIH, DIH, DIH, DAH, END },
+ ['5'] = { DIH, DIH, DIH, DIH, DIH, END },
+ ['6'] = { DAH, DIH, DIH, DIH, DIH, END },
+ ['7'] = { DAH, DAH, DIH, DIH, DIH, END },
+ ['8'] = { DAH, DAH, DAH, DIH, DIH, END },
+ ['9'] = { DAH, DAH, DAH, DAH, DIH, END },
+ ['a'] = { DIH, DAH, END },
+ ['b'] = { DAH, DIH, DIH, DIH, END },
+ ['c'] = { DAH, DIH, DAH, DIH, END },
+ ['d'] = { DAH, DIH, DIH, END },
+ ['e'] = { DIH, END },
+ ['f'] = { DIH, DIH, DAH, DIH, END },
+ ['g'] = { DAH, DAH, DIH, END },
+ ['h'] = { DIH, DIH, DIH, DIH, END },
+ ['i'] = { DIH, DIH, END },
+ ['j'] = { DIH, DAH, DAH, DAH, END },
+ ['k'] = { DAH, DIH, DAH, END },
+ ['l'] = { DIH, DAH, DIH, DIH, END },
+ ['m'] = { DAH, DAH, END },
+ ['n'] = { DAH, DIH, END },
+ ['o'] = { DAH, DAH, DAH, END },
+ ['p'] = { DIH, DAH, DAH, DIH, END },
+ ['q'] = { DAH, DAH, DIH, DAH, END },
+ ['r'] = { DIH, DAH, DIH, END },
+ ['s'] = { DIH, DIH, DIH, END },
+ ['t'] = { DAH, END },
+ ['u'] = { DIH, DIH, DAH, END },
+ ['v'] = { DIH, DIH, DIH, DAH, END },
+ ['w'] = { DIH, DAH, DAH, END },
+ ['x'] = { DAH, DIH, DIH, DAH, END },
+ ['y'] = { DAH, DIH, DAH, DAH, END },
+ ['z'] = { DAH, DAH, DIH, DIH, END }
+ };
+
+static void
+grub_audio_tone (int length)
+{
+ grub_speaker_beep_on (1000);
+ grub_millisleep (length);
+ grub_speaker_beep_off ();
+}
+
+static void
+grub_audio_putchar (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c_in)
+{
+ grub_uint8_t c;
+ int i;
+
+ /* For now, do not try to use a surrogate pair. */
+ if (c_in->base > 0x7f)
+ c = '?';
+ else
+ c = grub_tolower (c_in->base);
+ for (i = 0; codes[c][i]; i++)
+ {
+ grub_audio_tone (codes[c][i] * BASE_TIME);
+ grub_millisleep (BASE_TIME);
+ }
+ grub_millisleep (2 * BASE_TIME);
+}
+
+
+static int
+dummy (void)
+{
+ return 0;
+}
+
+static struct grub_term_output grub_audio_term_output =
+ {
+ .name = "morse",
+ .init = (void *) dummy,
+ .fini = (void *) dummy,
+ .putchar = grub_audio_putchar,
+ .getwh = (void *) dummy,
+ .getxy = (void *) dummy,
+ .gotoxy = (void *) dummy,
+ .cls = (void *) dummy,
+ .setcolorstate = (void *) dummy,
+ .setcursor = (void *) dummy,
+ .flags = GRUB_TERM_CODE_TYPE_ASCII | GRUB_TERM_DUMB,
+ .progress_update_divisor = GRUB_PROGRESS_NO_UPDATE
+ };
+
+GRUB_MOD_INIT (morse)
+{
+ grub_term_register_output ("audio", &grub_audio_term_output);
+}
+
+GRUB_MOD_FINI (morse)
+{
+ grub_term_unregister_output (&grub_audio_term_output);
+}
diff --git a/grub-core/term/ns8250.c b/grub-core/term/ns8250.c
new file mode 100644
index 0000000..39809d0
--- /dev/null
+++ b/grub-core/term/ns8250.c
@@ -0,0 +1,318 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/serial.h>
+#include <grub/ns8250.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/cpu/io.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/i18n.h>
+
+#ifdef GRUB_MACHINE_PCBIOS
+#include <grub/machine/memory.h>
+static const unsigned short *serial_hw_io_addr = (const unsigned short *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR;
+#define GRUB_SERIAL_PORT_NUM 4
+#else
+#include <grub/machine/serial.h>
+static const grub_port_t serial_hw_io_addr[] = GRUB_MACHINE_SERIAL_PORTS;
+#define GRUB_SERIAL_PORT_NUM (ARRAY_SIZE(serial_hw_io_addr))
+#endif
+
+static int dead_ports = 0;
+
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+#define DEFAULT_BASE_CLOCK (2 * 115200)
+#else
+#define DEFAULT_BASE_CLOCK 115200
+#endif
+
+
+/* Convert speed to divisor. */
+static unsigned short
+serial_get_divisor (const struct grub_serial_port *port __attribute__ ((unused)),
+ const struct grub_serial_config *config)
+{
+ grub_uint32_t base_clock;
+ grub_uint32_t divisor;
+ grub_uint32_t actual_speed, error;
+
+ 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;
+ error = actual_speed > config->speed ? (actual_speed - config->speed)
+ : (config->speed - actual_speed);
+ if (error > (config->speed / 30 + 1))
+ return 0;
+ return divisor;
+}
+
+static void
+do_real_config (struct grub_serial_port *port)
+{
+ int divisor;
+ unsigned char status = 0;
+ grub_uint64_t endtime;
+
+ const unsigned char parities[] = {
+ [GRUB_SERIAL_PARITY_NONE] = UART_NO_PARITY,
+ [GRUB_SERIAL_PARITY_ODD] = UART_ODD_PARITY,
+ [GRUB_SERIAL_PARITY_EVEN] = UART_EVEN_PARITY
+ };
+ const unsigned char stop_bits[] = {
+ [GRUB_SERIAL_STOP_BITS_1] = UART_1_STOP_BIT,
+ [GRUB_SERIAL_STOP_BITS_2] = UART_2_STOP_BITS,
+ };
+
+ if (port->configured)
+ return;
+
+ port->broken = 0;
+
+ divisor = serial_get_divisor (port, &port->config);
+
+ /* Turn off the interrupt. */
+ grub_outb (0, port->port + UART_IER);
+
+ /* Set DLAB. */
+ grub_outb (UART_DLAB, port->port + UART_LCR);
+
+ /* Set the baud rate. */
+ grub_outb (divisor & 0xFF, port->port + UART_DLL);
+ grub_outb (divisor >> 8, port->port + UART_DLH);
+
+ /* Set the line status. */
+ status |= (parities[port->config.parity]
+ | (port->config.word_len - 5)
+ | stop_bits[port->config.stop_bits]);
+ grub_outb (status, port->port + UART_LCR);
+
+ if (port->config.rtscts)
+ {
+ /* Enable the FIFO. */
+ grub_outb (UART_ENABLE_FIFO_TRIGGER1, port->port + UART_FCR);
+
+ /* Turn on DTR and RTS. */
+ grub_outb (UART_ENABLE_DTRRTS, port->port + UART_MCR);
+ }
+ else
+ {
+ /* Enable the FIFO. */
+ grub_outb (UART_ENABLE_FIFO_TRIGGER14, port->port + UART_FCR);
+
+ /* Turn on DTR, RTS, and OUT2. */
+ grub_outb (UART_ENABLE_DTRRTS | UART_ENABLE_OUT2, port->port + UART_MCR);
+ }
+
+ /* Drain the input buffer. */
+ endtime = grub_get_time_ms () + 1000;
+ while (grub_inb (port->port + UART_LSR) & UART_DATA_READY)
+ {
+ grub_inb (port->port + UART_RX);
+ if (grub_get_time_ms () > endtime)
+ {
+ port->broken = 1;
+ break;
+ }
+ }
+
+ port->configured = 1;
+}
+
+/* Fetch a key. */
+static int
+serial_hw_fetch (struct grub_serial_port *port)
+{
+ do_real_config (port);
+ if (grub_inb (port->port + UART_LSR) & UART_DATA_READY)
+ return grub_inb (port->port + UART_RX);
+
+ return -1;
+}
+
+/* Put a character. */
+static void
+serial_hw_put (struct grub_serial_port *port, const int c)
+{
+ grub_uint64_t endtime;
+
+ do_real_config (port);
+
+ if (port->broken > 5)
+ endtime = grub_get_time_ms ();
+ else if (port->broken > 1)
+ endtime = grub_get_time_ms () + 50;
+ else
+ endtime = grub_get_time_ms () + 200;
+ /* Wait until the transmitter holding register is empty. */
+ while ((grub_inb (port->port + UART_LSR) & UART_EMPTY_TRANSMITTER) == 0)
+ {
+ if (grub_get_time_ms () > endtime)
+ {
+ port->broken++;
+ /* There is something wrong. But what can I do? */
+ return;
+ }
+ }
+
+ if (port->broken)
+ port->broken--;
+
+ grub_outb (c, port->port + UART_TX);
+}
+
+/* Initialize a serial device. PORT is the port number for a serial device.
+ SPEED is a DTE-DTE speed which must be one of these: 2400, 4800, 9600,
+ 19200, 38400, 57600 and 115200. WORD_LEN is the word length to be used
+ for the device. Likewise, PARITY is the type of the parity and
+ STOP_BIT_LEN is the length of the stop bit. The possible values for
+ WORD_LEN, PARITY and STOP_BIT_LEN are defined in the header file as
+ macros. */
+static grub_err_t
+serial_hw_configure (struct grub_serial_port *port,
+ struct grub_serial_config *config)
+{
+ unsigned short divisor;
+
+ divisor = serial_get_divisor (port, config);
+ if (divisor == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port speed"));
+
+ if (config->parity != GRUB_SERIAL_PARITY_NONE
+ && config->parity != GRUB_SERIAL_PARITY_ODD
+ && config->parity != GRUB_SERIAL_PARITY_EVEN)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port parity"));
+
+ if (config->stop_bits != GRUB_SERIAL_STOP_BITS_1
+ && config->stop_bits != GRUB_SERIAL_STOP_BITS_2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port stop bits number"));
+
+ if (config->word_len < 5 || config->word_len > 8)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port word length"));
+
+ port->config = *config;
+ port->configured = 0;
+
+ /* FIXME: should check if the serial terminal was found. */
+
+ return GRUB_ERR_NONE;
+}
+
+struct grub_serial_driver grub_ns8250_driver =
+ {
+ .configure = serial_hw_configure,
+ .fetch = serial_hw_fetch,
+ .put = serial_hw_put
+ };
+
+static char com_names[GRUB_SERIAL_PORT_NUM][20];
+static struct grub_serial_port com_ports[GRUB_SERIAL_PORT_NUM];
+
+void
+grub_ns8250_init (void)
+{
+ unsigned i;
+ for (i = 0; i < GRUB_SERIAL_PORT_NUM; i++)
+ if (serial_hw_io_addr[i])
+ {
+ grub_err_t err;
+
+ grub_outb (0x5a, serial_hw_io_addr[i] + UART_SR);
+ if (grub_inb (serial_hw_io_addr[i] + UART_SR) != 0x5a)
+ {
+ dead_ports |= (1 << i);
+ continue;
+ }
+ grub_outb (0xa5, serial_hw_io_addr[i] + UART_SR);
+ if (grub_inb (serial_hw_io_addr[i] + UART_SR) != 0xa5)
+ {
+ dead_ports |= (1 << i);
+ continue;
+ }
+
+ grub_snprintf (com_names[i], sizeof (com_names[i]), "com%d", i);
+ com_ports[i].name = com_names[i];
+ com_ports[i].driver = &grub_ns8250_driver;
+ com_ports[i].port = serial_hw_io_addr[i];
+ err = grub_serial_config_defaults (&com_ports[i]);
+ if (err)
+ grub_print_error ();
+
+ grub_serial_register (&com_ports[i]);
+ }
+}
+
+/* Return the port number for the UNITth serial device. */
+grub_port_t
+grub_ns8250_hw_get_port (const unsigned int unit)
+{
+ if (unit < GRUB_SERIAL_PORT_NUM
+ && !(dead_ports & (1 << unit)))
+ return serial_hw_io_addr[unit];
+ else
+ return 0;
+}
+
+char *
+grub_serial_ns8250_add_port (grub_port_t port)
+{
+ struct grub_serial_port *p;
+ unsigned i;
+ for (i = 0; i < GRUB_SERIAL_PORT_NUM; i++)
+ if (com_ports[i].port == port)
+ {
+ if (dead_ports & (1 << i))
+ return NULL;
+ return com_names[i];
+ }
+
+ grub_outb (0x5a, port + UART_SR);
+ if (grub_inb (port + UART_SR) != 0x5a)
+ return NULL;
+
+ grub_outb (0xa5, port + UART_SR);
+ if (grub_inb (port + UART_SR) != 0xa5)
+ return NULL;
+
+ p = grub_malloc (sizeof (*p));
+ if (!p)
+ return NULL;
+ p->name = grub_xasprintf ("port%lx", (unsigned long) port);
+ if (!p->name)
+ {
+ grub_free (p);
+ return NULL;
+ }
+ p->driver = &grub_ns8250_driver;
+ grub_serial_config_defaults (p);
+ p->port = port;
+ grub_serial_register (p);
+
+ return p->name;
+}
diff --git a/grub-core/term/ps2.c b/grub-core/term/ps2.c
new file mode 100644
index 0000000..7ae4e9f
--- /dev/null
+++ b/grub-core/term/ps2.c
@@ -0,0 +1,387 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/keyboard_layouts.h>
+#include <grub/ps2.h>
+
+#define KEYBOARD_LED_SCROLL (1 << 0)
+#define KEYBOARD_LED_NUM (1 << 1)
+#define KEYBOARD_LED_CAPS (1 << 2)
+
+static const grub_uint8_t set1_mapping[128] =
+ {
+ /* 0x00 */ 0 /* Unused */, GRUB_KEYBOARD_KEY_ESCAPE,
+ /* 0x02 */ GRUB_KEYBOARD_KEY_1, GRUB_KEYBOARD_KEY_2,
+ /* 0x04 */ GRUB_KEYBOARD_KEY_3, GRUB_KEYBOARD_KEY_4,
+ /* 0x06 */ GRUB_KEYBOARD_KEY_5, GRUB_KEYBOARD_KEY_6,
+ /* 0x08 */ GRUB_KEYBOARD_KEY_7, GRUB_KEYBOARD_KEY_8,
+ /* 0x0a */ GRUB_KEYBOARD_KEY_9, GRUB_KEYBOARD_KEY_0,
+ /* 0x0c */ GRUB_KEYBOARD_KEY_DASH, GRUB_KEYBOARD_KEY_EQUAL,
+ /* 0x0e */ GRUB_KEYBOARD_KEY_BACKSPACE, GRUB_KEYBOARD_KEY_TAB,
+ /* 0x10 */ GRUB_KEYBOARD_KEY_Q, GRUB_KEYBOARD_KEY_W,
+ /* 0x12 */ GRUB_KEYBOARD_KEY_E, GRUB_KEYBOARD_KEY_R,
+ /* 0x14 */ GRUB_KEYBOARD_KEY_T, GRUB_KEYBOARD_KEY_Y,
+ /* 0x16 */ GRUB_KEYBOARD_KEY_U, GRUB_KEYBOARD_KEY_I,
+ /* 0x18 */ GRUB_KEYBOARD_KEY_O, GRUB_KEYBOARD_KEY_P,
+ /* 0x1a */ GRUB_KEYBOARD_KEY_LBRACKET, GRUB_KEYBOARD_KEY_RBRACKET,
+ /* 0x1c */ GRUB_KEYBOARD_KEY_ENTER, GRUB_KEYBOARD_KEY_LEFT_CTRL,
+ /* 0x1e */ GRUB_KEYBOARD_KEY_A, GRUB_KEYBOARD_KEY_S,
+ /* 0x20 */ GRUB_KEYBOARD_KEY_D, GRUB_KEYBOARD_KEY_F,
+ /* 0x22 */ GRUB_KEYBOARD_KEY_G, GRUB_KEYBOARD_KEY_H,
+ /* 0x24 */ GRUB_KEYBOARD_KEY_J, GRUB_KEYBOARD_KEY_K,
+ /* 0x26 */ GRUB_KEYBOARD_KEY_L, GRUB_KEYBOARD_KEY_SEMICOLON,
+ /* 0x28 */ GRUB_KEYBOARD_KEY_DQUOTE, GRUB_KEYBOARD_KEY_RQUOTE,
+ /* 0x2a */ GRUB_KEYBOARD_KEY_LEFT_SHIFT, GRUB_KEYBOARD_KEY_BACKSLASH,
+ /* 0x2c */ GRUB_KEYBOARD_KEY_Z, GRUB_KEYBOARD_KEY_X,
+ /* 0x2e */ GRUB_KEYBOARD_KEY_C, GRUB_KEYBOARD_KEY_V,
+ /* 0x30 */ GRUB_KEYBOARD_KEY_B, GRUB_KEYBOARD_KEY_N,
+ /* 0x32 */ GRUB_KEYBOARD_KEY_M, GRUB_KEYBOARD_KEY_COMMA,
+ /* 0x34 */ GRUB_KEYBOARD_KEY_DOT, GRUB_KEYBOARD_KEY_SLASH,
+ /* 0x36 */ GRUB_KEYBOARD_KEY_RIGHT_SHIFT, GRUB_KEYBOARD_KEY_NUMMUL,
+ /* 0x38 */ GRUB_KEYBOARD_KEY_LEFT_ALT, GRUB_KEYBOARD_KEY_SPACE,
+ /* 0x3a */ GRUB_KEYBOARD_KEY_CAPS_LOCK, GRUB_KEYBOARD_KEY_F1,
+ /* 0x3c */ GRUB_KEYBOARD_KEY_F2, GRUB_KEYBOARD_KEY_F3,
+ /* 0x3e */ GRUB_KEYBOARD_KEY_F4, GRUB_KEYBOARD_KEY_F5,
+ /* 0x40 */ GRUB_KEYBOARD_KEY_F6, GRUB_KEYBOARD_KEY_F7,
+ /* 0x42 */ GRUB_KEYBOARD_KEY_F8, GRUB_KEYBOARD_KEY_F9,
+ /* 0x44 */ GRUB_KEYBOARD_KEY_F10, GRUB_KEYBOARD_KEY_NUM_LOCK,
+ /* 0x46 */ GRUB_KEYBOARD_KEY_SCROLL_LOCK, GRUB_KEYBOARD_KEY_NUM7,
+ /* 0x48 */ GRUB_KEYBOARD_KEY_NUM8, GRUB_KEYBOARD_KEY_NUM9,
+ /* 0x4a */ GRUB_KEYBOARD_KEY_NUMMINUS, GRUB_KEYBOARD_KEY_NUM4,
+ /* 0x4c */ GRUB_KEYBOARD_KEY_NUM5, GRUB_KEYBOARD_KEY_NUM6,
+ /* 0x4e */ GRUB_KEYBOARD_KEY_NUMPLUS, GRUB_KEYBOARD_KEY_NUM1,
+ /* 0x50 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM3,
+ /* 0x52 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT,
+ /* 0x54 */ 0, 0,
+ /* 0x56 */ GRUB_KEYBOARD_KEY_102ND, GRUB_KEYBOARD_KEY_F11,
+ /* 0x58 */ GRUB_KEYBOARD_KEY_F12, 0,
+ /* 0x5a */ 0, 0,
+ /* 0x5c */ 0, 0,
+ /* 0x5e */ 0, 0,
+ /* 0x60 */ 0, 0,
+ /* 0x62 */ 0, 0,
+ /* OLPC keys. Just mapped to normal keys. */
+ /* 0x64 */ 0, GRUB_KEYBOARD_KEY_UP,
+ /* 0x66 */ GRUB_KEYBOARD_KEY_DOWN, GRUB_KEYBOARD_KEY_LEFT,
+ /* 0x68 */ GRUB_KEYBOARD_KEY_RIGHT, 0,
+ /* 0x6a */ 0, 0,
+ /* 0x6c */ 0, 0,
+ /* 0x6e */ 0, 0,
+ /* 0x70 */ 0, 0,
+ /* 0x72 */ 0, GRUB_KEYBOARD_KEY_JP_RO,
+ /* 0x74 */ 0, 0,
+ /* 0x76 */ 0, 0,
+ /* 0x78 */ 0, 0,
+ /* 0x7a */ 0, 0,
+ /* 0x7c */ 0, GRUB_KEYBOARD_KEY_JP_YEN,
+ /* 0x7e */ GRUB_KEYBOARD_KEY_KPCOMMA
+ };
+
+static const struct
+{
+ grub_uint8_t from, to;
+} set1_e0_mapping[] =
+ {
+ {0x1c, GRUB_KEYBOARD_KEY_NUMENTER},
+ {0x1d, GRUB_KEYBOARD_KEY_RIGHT_CTRL},
+ {0x35, GRUB_KEYBOARD_KEY_NUMSLASH },
+ {0x38, GRUB_KEYBOARD_KEY_RIGHT_ALT},
+ {0x47, GRUB_KEYBOARD_KEY_HOME},
+ {0x48, GRUB_KEYBOARD_KEY_UP},
+ {0x49, GRUB_KEYBOARD_KEY_PPAGE},
+ {0x4b, GRUB_KEYBOARD_KEY_LEFT},
+ {0x4d, GRUB_KEYBOARD_KEY_RIGHT},
+ {0x4f, GRUB_KEYBOARD_KEY_END},
+ {0x50, GRUB_KEYBOARD_KEY_DOWN},
+ {0x51, GRUB_KEYBOARD_KEY_NPAGE},
+ {0x52, GRUB_KEYBOARD_KEY_INSERT},
+ {0x53, GRUB_KEYBOARD_KEY_DELETE},
+ };
+
+static const grub_uint8_t set2_mapping[256] =
+ {
+ /* 0x00 */ 0, GRUB_KEYBOARD_KEY_F9,
+ /* 0x02 */ 0, GRUB_KEYBOARD_KEY_F5,
+ /* 0x04 */ GRUB_KEYBOARD_KEY_F3, GRUB_KEYBOARD_KEY_F1,
+ /* 0x06 */ GRUB_KEYBOARD_KEY_F2, GRUB_KEYBOARD_KEY_F12,
+ /* 0x08 */ 0, GRUB_KEYBOARD_KEY_F10,
+ /* 0x0a */ GRUB_KEYBOARD_KEY_F8, GRUB_KEYBOARD_KEY_F6,
+ /* 0x0c */ GRUB_KEYBOARD_KEY_F4, GRUB_KEYBOARD_KEY_TAB,
+ /* 0x0e */ GRUB_KEYBOARD_KEY_RQUOTE, 0,
+ /* 0x10 */ 0, GRUB_KEYBOARD_KEY_LEFT_ALT,
+ /* 0x12 */ GRUB_KEYBOARD_KEY_LEFT_SHIFT, 0,
+ /* 0x14 */ GRUB_KEYBOARD_KEY_LEFT_CTRL, GRUB_KEYBOARD_KEY_Q,
+ /* 0x16 */ GRUB_KEYBOARD_KEY_1, 0,
+ /* 0x18 */ 0, 0,
+ /* 0x1a */ GRUB_KEYBOARD_KEY_Z, GRUB_KEYBOARD_KEY_S,
+ /* 0x1c */ GRUB_KEYBOARD_KEY_A, GRUB_KEYBOARD_KEY_W,
+ /* 0x1e */ GRUB_KEYBOARD_KEY_2, 0,
+ /* 0x20 */ 0, GRUB_KEYBOARD_KEY_C,
+ /* 0x22 */ GRUB_KEYBOARD_KEY_X, GRUB_KEYBOARD_KEY_D,
+ /* 0x24 */ GRUB_KEYBOARD_KEY_E, GRUB_KEYBOARD_KEY_4,
+ /* 0x26 */ GRUB_KEYBOARD_KEY_3, 0,
+ /* 0x28 */ 0, GRUB_KEYBOARD_KEY_SPACE,
+ /* 0x2a */ GRUB_KEYBOARD_KEY_V, GRUB_KEYBOARD_KEY_F,
+ /* 0x2c */ GRUB_KEYBOARD_KEY_T, GRUB_KEYBOARD_KEY_R,
+ /* 0x2e */ GRUB_KEYBOARD_KEY_5, 0,
+ /* 0x30 */ 0, GRUB_KEYBOARD_KEY_N,
+ /* 0x32 */ GRUB_KEYBOARD_KEY_B, GRUB_KEYBOARD_KEY_H,
+ /* 0x34 */ GRUB_KEYBOARD_KEY_G, GRUB_KEYBOARD_KEY_Y,
+ /* 0x36 */ GRUB_KEYBOARD_KEY_6, 0,
+ /* 0x38 */ 0, 0,
+ /* 0x3a */ GRUB_KEYBOARD_KEY_M, GRUB_KEYBOARD_KEY_J,
+ /* 0x3c */ GRUB_KEYBOARD_KEY_U, GRUB_KEYBOARD_KEY_7,
+ /* 0x3e */ GRUB_KEYBOARD_KEY_8, 0,
+ /* 0x40 */ 0, GRUB_KEYBOARD_KEY_COMMA,
+ /* 0x42 */ GRUB_KEYBOARD_KEY_K, GRUB_KEYBOARD_KEY_I,
+ /* 0x44 */ GRUB_KEYBOARD_KEY_O, GRUB_KEYBOARD_KEY_0,
+ /* 0x46 */ GRUB_KEYBOARD_KEY_9, 0,
+ /* 0x48 */ 0, GRUB_KEYBOARD_KEY_DOT,
+ /* 0x4a */ GRUB_KEYBOARD_KEY_SLASH, GRUB_KEYBOARD_KEY_L,
+ /* 0x4c */ GRUB_KEYBOARD_KEY_SEMICOLON, GRUB_KEYBOARD_KEY_P,
+ /* 0x4e */ GRUB_KEYBOARD_KEY_DASH, 0,
+ /* 0x50 */ 0, GRUB_KEYBOARD_KEY_JP_RO,
+ /* 0x52 */ GRUB_KEYBOARD_KEY_DQUOTE, 0,
+ /* 0x54 */ GRUB_KEYBOARD_KEY_LBRACKET, GRUB_KEYBOARD_KEY_EQUAL,
+ /* 0x56 */ 0, 0,
+ /* 0x58 */ GRUB_KEYBOARD_KEY_CAPS_LOCK, GRUB_KEYBOARD_KEY_RIGHT_SHIFT,
+ /* 0x5a */ GRUB_KEYBOARD_KEY_ENTER, GRUB_KEYBOARD_KEY_RBRACKET,
+ /* 0x5c */ 0, GRUB_KEYBOARD_KEY_BACKSLASH,
+ /* 0x5e */ 0, 0,
+ /* 0x60 */ 0, GRUB_KEYBOARD_KEY_102ND,
+ /* 0x62 */ 0, 0,
+ /* 0x64 */ 0, 0,
+ /* 0x66 */ GRUB_KEYBOARD_KEY_BACKSPACE, 0,
+ /* 0x68 */ 0, GRUB_KEYBOARD_KEY_NUM1,
+ /* 0x6a */ GRUB_KEYBOARD_KEY_JP_YEN, GRUB_KEYBOARD_KEY_NUM4,
+ /* 0x6c */ GRUB_KEYBOARD_KEY_NUM7, GRUB_KEYBOARD_KEY_KPCOMMA,
+ /* 0x6e */ 0, 0,
+ /* 0x70 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT,
+ /* 0x72 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM5,
+ /* 0x74 */ GRUB_KEYBOARD_KEY_NUM6, GRUB_KEYBOARD_KEY_NUM8,
+ /* 0x76 */ GRUB_KEYBOARD_KEY_ESCAPE, GRUB_KEYBOARD_KEY_NUM_LOCK,
+ /* 0x78 */ GRUB_KEYBOARD_KEY_F11, GRUB_KEYBOARD_KEY_NUMPLUS,
+ /* 0x7a */ GRUB_KEYBOARD_KEY_NUM3, GRUB_KEYBOARD_KEY_NUMMINUS,
+ /* 0x7c */ GRUB_KEYBOARD_KEY_NUMMUL, GRUB_KEYBOARD_KEY_NUM9,
+ /* 0x7e */ GRUB_KEYBOARD_KEY_SCROLL_LOCK, 0,
+ /* 0x80 */ 0, 0,
+ /* 0x82 */ 0, GRUB_KEYBOARD_KEY_F7,
+ };
+
+static const struct
+{
+ grub_uint8_t from, to;
+} set2_e0_mapping[] =
+ {
+ {0x11, GRUB_KEYBOARD_KEY_RIGHT_ALT},
+ {0x14, GRUB_KEYBOARD_KEY_RIGHT_CTRL},
+ {0x4a, GRUB_KEYBOARD_KEY_NUMSLASH},
+ {0x5a, GRUB_KEYBOARD_KEY_NUMENTER},
+ {0x69, GRUB_KEYBOARD_KEY_END},
+ {0x6b, GRUB_KEYBOARD_KEY_LEFT},
+ {0x6c, GRUB_KEYBOARD_KEY_HOME},
+ {0x70, GRUB_KEYBOARD_KEY_INSERT},
+ {0x71, GRUB_KEYBOARD_KEY_DELETE},
+ {0x72, GRUB_KEYBOARD_KEY_DOWN},
+ {0x74, GRUB_KEYBOARD_KEY_RIGHT},
+ {0x75, GRUB_KEYBOARD_KEY_UP},
+ {0x7a, GRUB_KEYBOARD_KEY_NPAGE},
+ {0x7d, GRUB_KEYBOARD_KEY_PPAGE},
+ };
+
+static int
+fetch_key (struct grub_ps2_state *ps2_state, grub_uint8_t at_key, int *is_break)
+{
+ int was_ext = 0;
+ int ret = 0;
+
+ /* May happen if no keyboard is connected. Just ignore this. */
+ if (at_key == 0xff)
+ return -1;
+ if (at_key == 0xe0)
+ {
+ ps2_state->e0_received = 1;
+ return -1;
+ }
+
+ if ((ps2_state->current_set == 2 || ps2_state->current_set == 3) && at_key == 0xf0)
+ {
+ ps2_state->f0_received = 1;
+ return -1;
+ }
+
+ /* Setting LEDs may generate ACKs. */
+ if (at_key == GRUB_AT_ACK)
+ return -1;
+
+ was_ext = ps2_state->e0_received;
+ ps2_state->e0_received = 0;
+
+ switch (ps2_state->current_set)
+ {
+ case 1:
+ *is_break = !!(at_key & 0x80);
+ if (!was_ext)
+ ret = set1_mapping[at_key & 0x7f];
+ else
+ {
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE (set1_e0_mapping); i++)
+ if (set1_e0_mapping[i].from == (at_key & 0x7f))
+ {
+ ret = set1_e0_mapping[i].to;
+ break;
+ }
+ }
+ break;
+ case 2:
+ *is_break = ps2_state->f0_received;
+ ps2_state->f0_received = 0;
+ if (!was_ext)
+ ret = set2_mapping[at_key];
+ else
+ {
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE (set2_e0_mapping); i++)
+ if (set2_e0_mapping[i].from == at_key)
+ {
+ ret = set2_e0_mapping[i].to;
+ break;
+ }
+ }
+ break;
+ default:
+ return -1;
+ }
+ if (!ret)
+ {
+ if (was_ext)
+ grub_dprintf ("atkeyb", "Unknown key 0xe0+0x%02x from set %d\n",
+ at_key, ps2_state->current_set);
+ else
+ grub_dprintf ("atkeyb", "Unknown key 0x%02x from set %d\n",
+ at_key, ps2_state->current_set);
+ return -1;
+ }
+ return ret;
+}
+
+/* FIXME: This should become an interrupt service routine. For now
+ it's just used to catch events from control keys. */
+static int
+grub_keyboard_isr (struct grub_ps2_state *ps2_state,
+ grub_keyboard_key_t key, int is_break)
+{
+ if (!is_break)
+ switch (key)
+ {
+ case GRUB_KEYBOARD_KEY_LEFT_SHIFT:
+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_LSHIFT;
+ return 1;
+ case GRUB_KEYBOARD_KEY_RIGHT_SHIFT:
+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_RSHIFT;
+ return 1;
+ case GRUB_KEYBOARD_KEY_LEFT_CTRL:
+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_LCTRL;
+ return 1;
+ case GRUB_KEYBOARD_KEY_RIGHT_CTRL:
+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_RCTRL;
+ return 1;
+ case GRUB_KEYBOARD_KEY_RIGHT_ALT:
+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_RALT;
+ return 1;
+ case GRUB_KEYBOARD_KEY_LEFT_ALT:
+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_LALT;
+ return 1;
+ default:
+ return 0;
+ }
+ else
+ switch (key)
+ {
+ case GRUB_KEYBOARD_KEY_LEFT_SHIFT:
+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_LSHIFT;
+ return 1;
+ case GRUB_KEYBOARD_KEY_RIGHT_SHIFT:
+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_RSHIFT;
+ return 1;
+ case GRUB_KEYBOARD_KEY_LEFT_CTRL:
+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_LCTRL;
+ return 1;
+ case GRUB_KEYBOARD_KEY_RIGHT_CTRL:
+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_RCTRL;
+ return 1;
+ case GRUB_KEYBOARD_KEY_RIGHT_ALT:
+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_RALT;
+ return 1;
+ case GRUB_KEYBOARD_KEY_LEFT_ALT:
+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_LALT;
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+/* If there is a key pending, return it; otherwise return GRUB_TERM_NO_KEY. */
+int
+grub_ps2_process_incoming_byte (struct grub_ps2_state *ps2_state,
+ grub_uint8_t at_key)
+{
+ int code;
+ int is_break = 0;
+
+ code = fetch_key (ps2_state, at_key, &is_break);
+ if (code == -1)
+ return GRUB_TERM_NO_KEY;
+
+ if (grub_keyboard_isr (ps2_state, code, is_break))
+ return GRUB_TERM_NO_KEY;
+ if (is_break)
+ return GRUB_TERM_NO_KEY;
+#ifdef DEBUG_AT_KEYBOARD
+ grub_dprintf ("atkeyb", "Detected key 0x%x\n", code);
+#endif
+ switch (code)
+ {
+ case GRUB_KEYBOARD_KEY_CAPS_LOCK:
+ ps2_state->at_keyboard_status ^= GRUB_TERM_STATUS_CAPS;
+ ps2_state->led_status ^= KEYBOARD_LED_CAPS;
+
+#ifdef DEBUG_AT_KEYBOARD
+ grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(ps2_state->at_keyboard_status & GRUB_KEYBOARD_STATUS_CAPS_LOCK));
+#endif
+ return GRUB_TERM_NO_KEY;
+ case GRUB_KEYBOARD_KEY_NUM_LOCK:
+ ps2_state->at_keyboard_status ^= GRUB_TERM_STATUS_NUM;
+ ps2_state->led_status ^= KEYBOARD_LED_NUM;
+
+#ifdef DEBUG_AT_KEYBOARD
+ grub_dprintf ("atkeyb", "num_lock = %d\n", !!(ps2_state->at_keyboard_status & GRUB_KEYBOARD_STATUS_NUM_LOCK));
+#endif
+ return GRUB_TERM_NO_KEY;
+ case GRUB_KEYBOARD_KEY_SCROLL_LOCK:
+ ps2_state->at_keyboard_status ^= GRUB_TERM_STATUS_SCROLL;
+ ps2_state->led_status ^= KEYBOARD_LED_SCROLL;
+ return GRUB_TERM_NO_KEY;
+ default:
+ return grub_term_map_key (code, ps2_state->at_keyboard_status);
+ }
+}
diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c
new file mode 100644
index 0000000..f9271b0
--- /dev/null
+++ b/grub-core/term/serial.c
@@ -0,0 +1,463 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/serial.h>
+#include <grub/term.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/terminfo.h>
+#if !defined (GRUB_MACHINE_EMU) && (defined(__mips__) || defined (__i386__) || defined (__x86_64__))
+#include <grub/cpu/io.h>
+#endif
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/list.h>
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+#include <grub/machine/kernel.h>
+#endif
+#ifdef GRUB_MACHINE_IEEE1275
+#include <grub/ieee1275/console.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define FOR_SERIAL_PORTS(var) FOR_LIST_ELEMENTS((var), (grub_serial_ports))
+
+enum
+ {
+ OPTION_UNIT,
+ OPTION_PORT,
+ OPTION_SPEED,
+ OPTION_WORD,
+ OPTION_PARITY,
+ OPTION_STOP,
+ OPTION_BASE_CLOCK,
+ OPTION_RTSCTS
+ };
+
+/* Argument options. */
+static const struct grub_arg_option options[] =
+{
+ {"unit", 'u', 0, N_("Set the serial unit."), 0, ARG_TYPE_INT},
+ {"port", 'p', 0, N_("Set the serial port address."), 0, ARG_TYPE_STRING},
+ {"speed", 's', 0, N_("Set the serial port speed."), 0, ARG_TYPE_INT},
+ {"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 frequency."), 0, ARG_TYPE_STRING},
+ {"rtscts", 'f', 0, N_("Enable/disable RTS/CTS."), "on|off", ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+};
+
+static struct grub_serial_port *grub_serial_ports;
+
+struct grub_serial_output_state
+{
+ struct grub_terminfo_output_state tinfo;
+ struct grub_serial_port *port;
+};
+
+struct grub_serial_input_state
+{
+ struct grub_terminfo_input_state tinfo;
+ struct grub_serial_port *port;
+};
+
+static void
+serial_put (grub_term_output_t term, const int c)
+{
+ struct grub_serial_output_state *data = term->data;
+ data->port->driver->put (data->port, c);
+}
+
+static int
+serial_fetch (grub_term_input_t term)
+{
+ struct grub_serial_input_state *data = term->data;
+ return data->port->driver->fetch (data->port);
+}
+
+static const struct grub_serial_input_state grub_serial_terminfo_input_template =
+ {
+ .tinfo =
+ {
+ .readkey = serial_fetch
+ }
+ };
+
+static const struct grub_serial_output_state grub_serial_terminfo_output_template =
+ {
+ .tinfo =
+ {
+ .put = serial_put,
+ .size = { 80, 24 }
+ }
+ };
+
+static struct grub_serial_input_state grub_serial_terminfo_input;
+
+static struct grub_serial_output_state grub_serial_terminfo_output;
+
+static int registered = 0;
+
+static struct grub_term_input grub_serial_term_input =
+{
+ .name = "serial",
+ .init = grub_terminfo_input_init,
+ .getkey = grub_terminfo_getkey,
+ .data = &grub_serial_terminfo_input
+};
+
+static struct grub_term_output grub_serial_term_output =
+{
+ .name = "serial",
+ .init = grub_terminfo_output_init,
+ .putchar = grub_terminfo_putchar,
+ .getwh = grub_terminfo_getwh,
+ .getxy = grub_terminfo_getxy,
+ .gotoxy = grub_terminfo_gotoxy,
+ .cls = grub_terminfo_cls,
+ .setcolorstate = grub_terminfo_setcolorstate,
+ .setcursor = grub_terminfo_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_ASCII,
+ .data = &grub_serial_terminfo_output,
+ .progress_update_divisor = GRUB_PROGRESS_SLOW
+};
+
+
+
+struct grub_serial_port *
+grub_serial_find (const char *name)
+{
+ struct grub_serial_port *port;
+
+ FOR_SERIAL_PORTS (port)
+ if (grub_strcmp (port->name, name) == 0)
+ break;
+
+#if (defined(__mips__) || defined (__i386__) || defined (__x86_64__)) && !defined(GRUB_MACHINE_EMU) && !defined(GRUB_MACHINE_ARC)
+ if (!port && grub_memcmp (name, "port", sizeof ("port") - 1) == 0
+ && grub_isxdigit (name [sizeof ("port") - 1]))
+ {
+ name = grub_serial_ns8250_add_port (grub_strtoul (&name[sizeof ("port") - 1],
+ 0, 16));
+ if (!name)
+ return NULL;
+
+ FOR_SERIAL_PORTS (port)
+ if (grub_strcmp (port->name, name) == 0)
+ break;
+ }
+#endif
+
+#ifdef GRUB_MACHINE_IEEE1275
+ if (!port && grub_memcmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) == 0)
+ {
+ name = grub_ofserial_add_port (&name[sizeof ("ieee1275/") - 1]);
+ if (!name)
+ return NULL;
+
+ FOR_SERIAL_PORTS (port)
+ if (grub_strcmp (port->name, name) == 0)
+ break;
+ }
+#endif
+
+ return port;
+}
+
+static grub_err_t
+grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_arg_list *state = ctxt->state;
+ char pname[40];
+ const char *name = NULL;
+ struct grub_serial_port *port;
+ struct grub_serial_config config;
+ grub_err_t err;
+
+ if (state[OPTION_UNIT].set)
+ {
+ grub_snprintf (pname, sizeof (pname), "com%ld",
+ grub_strtoul (state[0].arg, 0, 0));
+ name = pname;
+ }
+
+ if (state[OPTION_PORT].set)
+ {
+ grub_snprintf (pname, sizeof (pname), "port%lx",
+ grub_strtoul (state[1].arg, 0, 0));
+ name = pname;
+ }
+
+ if (argc >= 1)
+ name = args[0];
+
+ if (!name)
+ name = "com0";
+
+ port = grub_serial_find (name);
+ if (!port)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("serial port `%s' isn't found"),
+ name);
+
+ config = port->config;
+
+ 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);
+
+ if (state[OPTION_PARITY].set)
+ {
+ if (! grub_strcmp (state[OPTION_PARITY].arg, "no"))
+ config.parity = GRUB_SERIAL_PARITY_NONE;
+ else if (! grub_strcmp (state[OPTION_PARITY].arg, "odd"))
+ config.parity = GRUB_SERIAL_PARITY_ODD;
+ else if (! grub_strcmp (state[OPTION_PARITY].arg, "even"))
+ config.parity = GRUB_SERIAL_PARITY_EVEN;
+ else
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port parity"));
+ }
+
+ if (state[OPTION_RTSCTS].set)
+ {
+ if (grub_strcmp (state[OPTION_RTSCTS].arg, "on") == 0)
+ config.rtscts = 1;
+ 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 control"));
+ }
+
+ if (state[OPTION_STOP].set)
+ {
+ if (! grub_strcmp (state[OPTION_STOP].arg, "1"))
+ config.stop_bits = GRUB_SERIAL_STOP_BITS_1;
+ else if (! grub_strcmp (state[OPTION_STOP].arg, "2"))
+ config.stop_bits = GRUB_SERIAL_STOP_BITS_2;
+ else if (! grub_strcmp (state[OPTION_STOP].arg, "1.5"))
+ config.stop_bits = GRUB_SERIAL_STOP_BITS_1_5;
+ else
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port stop bits number"));
+ }
+
+ if (state[OPTION_BASE_CLOCK].set)
+ {
+ const char *ptr;
+ config.base_clock = grub_strtoull (state[OPTION_BASE_CLOCK].arg, &ptr, 0);
+ if (grub_errno)
+ return grub_errno;
+ if (ptr && *ptr == 'M')
+ config.base_clock *= 1000000;
+ if (ptr && (*ptr == 'k' || *ptr == 'K'))
+ config.base_clock *= 1000;
+ }
+
+ if (config.speed == 0)
+ config.speed = 9600;
+
+ /* Initialize with new settings. */
+ err = port->driver->configure (port, &config);
+ if (err)
+ return err;
+#if !defined (GRUB_MACHINE_EMU) && !defined(GRUB_MACHINE_ARC) && (defined(__mips__) || defined (__i386__) || defined (__x86_64__))
+
+ /* Compatibility kludge. */
+ if (port->driver == &grub_ns8250_driver)
+ {
+ if (!registered)
+ {
+ grub_terminfo_output_register (&grub_serial_term_output, "vt100");
+
+ grub_term_register_input ("serial", &grub_serial_term_input);
+ grub_term_register_output ("serial", &grub_serial_term_output);
+ }
+ grub_serial_terminfo_output.port = port;
+ grub_serial_terminfo_input.port = port;
+ registered = 1;
+ }
+#endif
+ return GRUB_ERR_NONE;
+}
+
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+const char loongson_defserial[][6] =
+ {
+ [GRUB_ARCH_MACHINE_YEELOONG] = "com0",
+ [GRUB_ARCH_MACHINE_FULOONG2F] = "com2",
+ [GRUB_ARCH_MACHINE_FULOONG2E] = "com1"
+ };
+#endif
+
+grub_err_t
+grub_serial_register (struct grub_serial_port *port)
+{
+ struct grub_term_input *in;
+ struct grub_term_output *out;
+ struct grub_serial_input_state *indata;
+ struct grub_serial_output_state *outdata;
+
+ in = grub_malloc (sizeof (*in));
+ if (!in)
+ return grub_errno;
+
+ indata = grub_malloc (sizeof (*indata));
+ if (!indata)
+ {
+ grub_free (in);
+ return grub_errno;
+ }
+
+ grub_memcpy (in, &grub_serial_term_input, sizeof (*in));
+ in->data = indata;
+ in->name = grub_xasprintf ("serial_%s", port->name);
+ grub_memcpy (indata, &grub_serial_terminfo_input, sizeof (*indata));
+
+ if (!in->name)
+ {
+ grub_free (in);
+ grub_free (indata);
+ return grub_errno;
+ }
+
+ out = grub_zalloc (sizeof (*out));
+ if (!out)
+ {
+ grub_free (indata);
+ grub_free ((char *) in->name);
+ grub_free (in);
+ return grub_errno;
+ }
+
+ outdata = grub_malloc (sizeof (*outdata));
+ if (!outdata)
+ {
+ grub_free (indata);
+ grub_free ((char *) in->name);
+ grub_free (out);
+ grub_free (in);
+ return grub_errno;
+ }
+
+ grub_memcpy (out, &grub_serial_term_output, sizeof (*out));
+ out->data = outdata;
+ out->name = in->name;
+ grub_memcpy (outdata, &grub_serial_terminfo_output, sizeof (*outdata));
+
+ grub_list_push (GRUB_AS_LIST_P (&grub_serial_ports), GRUB_AS_LIST (port));
+ ((struct grub_serial_input_state *) in->data)->port = port;
+ ((struct grub_serial_output_state *) out->data)->port = port;
+ port->term_in = in;
+ port->term_out = out;
+ grub_terminfo_output_register (out, "vt100");
+#ifdef GRUB_MACHINE_MIPS_LOONGSON
+ if (grub_strcmp (port->name, loongson_defserial[grub_arch_machine]) == 0)
+ {
+ grub_term_register_input_active ("serial_*", in);
+ grub_term_register_output_active ("serial_*", out);
+ }
+ else
+ {
+ grub_term_register_input_inactive ("serial_*", in);
+ grub_term_register_output_inactive ("serial_*", out);
+ }
+#else
+ grub_term_register_input ("serial_*", in);
+ grub_term_register_output ("serial_*", out);
+#endif
+
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_serial_unregister (struct grub_serial_port *port)
+{
+ if (port->driver->fini)
+ port->driver->fini (port);
+
+ if (port->term_in)
+ grub_term_unregister_input (port->term_in);
+ if (port->term_out)
+ grub_term_unregister_output (port->term_out);
+
+ grub_list_remove (GRUB_AS_LIST (port));
+}
+
+void
+grub_serial_unregister_driver (struct grub_serial_driver *driver)
+{
+ struct grub_serial_port *port, *next;
+ for (port = grub_serial_ports; port; port = next)
+ {
+ next = port->next;
+ if (port->driver == driver)
+ grub_serial_unregister (port);
+ }
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(serial)
+{
+ cmd = grub_register_extcmd ("serial", grub_cmd_serial, 0,
+ N_("[OPTIONS...]"),
+ N_("Configure serial port."), options);
+ grub_memcpy (&grub_serial_terminfo_output,
+ &grub_serial_terminfo_output_template,
+ sizeof (grub_serial_terminfo_output));
+
+ grub_memcpy (&grub_serial_terminfo_input,
+ &grub_serial_terminfo_input_template,
+ sizeof (grub_serial_terminfo_input));
+
+#if !defined (GRUB_MACHINE_EMU) && !defined(GRUB_MACHINE_ARC) && (defined(__mips__) || defined (__i386__) || defined (__x86_64__))
+ grub_ns8250_init ();
+#endif
+#ifdef GRUB_MACHINE_IEEE1275
+ grub_ofserial_init ();
+#endif
+#ifdef GRUB_MACHINE_EFI
+ grub_efiserial_init ();
+#endif
+#ifdef GRUB_MACHINE_ARC
+ grub_arcserial_init ();
+#endif
+}
+
+GRUB_MOD_FINI(serial)
+{
+ while (grub_serial_ports)
+ grub_serial_unregister (grub_serial_ports);
+ if (registered)
+ {
+ grub_term_unregister_input (&grub_serial_term_input);
+ grub_term_unregister_output (&grub_serial_term_output);
+ }
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/term/spkmodem.c b/grub-core/term/spkmodem.c
new file mode 100644
index 0000000..75c8a0f
--- /dev/null
+++ b/grub-core/term/spkmodem.c
@@ -0,0 +1,141 @@
+/* console.c -- Open Firmware console for GRUB. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/term.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/terminfo.h>
+#include <grub/dl.h>
+#include <grub/speaker.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+extern struct grub_terminfo_output_state grub_spkmodem_terminfo_output;
+
+static void
+make_tone (grub_uint16_t freq_count, unsigned int duration)
+{
+ /* Program timer 2. */
+ grub_outb (GRUB_PIT_CTRL_SELECT_2
+ | GRUB_PIT_CTRL_READLOAD_WORD
+ | GRUB_PIT_CTRL_SQUAREWAVE_GEN
+ | GRUB_PIT_CTRL_COUNT_BINARY, GRUB_PIT_CTRL);
+ grub_outb (freq_count & 0xff, GRUB_PIT_COUNTER_2); /* LSB */
+ grub_outb ((freq_count >> 8) & 0xff, GRUB_PIT_COUNTER_2); /* MSB */
+
+ /* Start speaker. */
+ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
+ | GRUB_PIT_SPK_TMR2 | GRUB_PIT_SPK_DATA,
+ GRUB_PIT_SPEAKER_PORT);
+
+ for (; duration; duration--)
+ {
+ unsigned short counter, previous_counter = 0xffff;
+ while (1)
+ {
+ counter = grub_inb (GRUB_PIT_COUNTER_2);
+ counter |= ((grub_uint16_t) grub_inb (GRUB_PIT_COUNTER_2)) << 8;
+ if (counter > previous_counter)
+ {
+ previous_counter = counter;
+ break;
+ }
+ previous_counter = counter;
+ }
+ }
+}
+
+static int inited;
+
+static void
+put (struct grub_term_output *term __attribute__ ((unused)), const int c)
+{
+ int i;
+
+ make_tone (GRUB_SPEAKER_PIT_FREQUENCY / 200, 4);
+ for (i = 7; i >= 0; i--)
+ {
+ if ((c >> i) & 1)
+ make_tone (GRUB_SPEAKER_PIT_FREQUENCY / 2000, 20);
+ else
+ make_tone (GRUB_SPEAKER_PIT_FREQUENCY / 4000, 40);
+ make_tone (GRUB_SPEAKER_PIT_FREQUENCY / 1000, 10);
+ }
+ make_tone (GRUB_SPEAKER_PIT_FREQUENCY / 200, 0);
+}
+
+static grub_err_t
+grub_spkmodem_init_output (struct grub_term_output *term)
+{
+ /* Some models shutdown sound when not in use and it takes for it
+ around 30 ms to come back on which loses 3 bits. So generate a base
+ 200 Hz continously. */
+
+ make_tone (GRUB_SPEAKER_PIT_FREQUENCY / 200, 0);
+ grub_terminfo_output_init (term);
+
+ return 0;
+}
+
+static grub_err_t
+grub_spkmodem_fini_output (struct grub_term_output *term __attribute__ ((unused)))
+{
+ grub_speaker_beep_off ();
+ inited = 0;
+ return 0;
+}
+
+
+
+
+struct grub_terminfo_output_state grub_spkmodem_terminfo_output =
+ {
+ .put = put,
+ .size = { 80, 24 }
+ };
+
+static struct grub_term_output grub_spkmodem_term_output =
+ {
+ .name = "spkmodem",
+ .init = grub_spkmodem_init_output,
+ .fini = grub_spkmodem_fini_output,
+ .putchar = grub_terminfo_putchar,
+ .getxy = grub_terminfo_getxy,
+ .getwh = grub_terminfo_getwh,
+ .gotoxy = grub_terminfo_gotoxy,
+ .cls = grub_terminfo_cls,
+ .setcolorstate = grub_terminfo_setcolorstate,
+ .setcursor = grub_terminfo_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_ASCII,
+ .data = &grub_spkmodem_terminfo_output,
+ .progress_update_divisor = GRUB_PROGRESS_NO_UPDATE
+ };
+
+GRUB_MOD_INIT (spkmodem)
+{
+ grub_term_register_output ("spkmodem", &grub_spkmodem_term_output);
+}
+
+
+GRUB_MOD_FINI (spkmodem)
+{
+ grub_term_unregister_output (&grub_spkmodem_term_output);
+}
diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c
new file mode 100644
index 0000000..85ecf06
--- /dev/null
+++ b/grub-core/term/terminfo.c
@@ -0,0 +1,796 @@
+/* terminfo.c - simple terminfo module */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This file contains various functions dealing with different
+ * terminal capabilities. For example, vt52 and vt100.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/term.h>
+#include <grub/terminfo.h>
+#include <grub/tparm.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+#include <grub/time.h>
+#if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275)
+#include <grub/ieee1275/ieee1275.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define ANSI_CSI 0x9b
+#define ANSI_CSI_STR "\x9b"
+
+static struct grub_term_output *terminfo_outputs;
+
+/* Get current terminfo name. */
+char *
+grub_terminfo_get_current (struct grub_term_output *term)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+ return data->name;
+}
+
+/* Free *PTR and set *PTR to NULL, to prevent double-free. */
+static void
+grub_terminfo_free (char **ptr)
+{
+ grub_free (*ptr);
+ *ptr = 0;
+}
+
+static void
+grub_terminfo_all_free (struct grub_term_output *term)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ /* Free previously allocated memory. */
+ grub_terminfo_free (&data->name);
+ grub_terminfo_free (&data->gotoxy);
+ grub_terminfo_free (&data->cls);
+ grub_terminfo_free (&data->reverse_video_on);
+ grub_terminfo_free (&data->reverse_video_off);
+ grub_terminfo_free (&data->cursor_on);
+ grub_terminfo_free (&data->cursor_off);
+}
+
+/* Set current terminfo type. */
+grub_err_t
+grub_terminfo_set_current (struct grub_term_output *term,
+ const char *str)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+ /* TODO
+ * Lookup user specified terminfo type. If found, set term variables
+ * as appropriate. Otherwise return an error.
+ *
+ * How should this be done?
+ * a. A static table included in this module.
+ * - I do not like this idea.
+ * b. A table stored in the configuration directory.
+ * - Users must convert their terminfo settings if we have not already.
+ * c. Look for terminfo files in the configuration directory.
+ * - /usr/share/terminfo is 6.3M on my system.
+ * - /usr/share/terminfo is not on most users boot partition.
+ * + Copying the terminfo files you want to use to the grub
+ * configuration directory is easier then (b).
+ * d. Your idea here.
+ */
+
+ grub_terminfo_all_free (term);
+
+ if (grub_strcmp ("vt100", str) == 0)
+ {
+ data->name = grub_strdup ("vt100");
+ data->gotoxy = grub_strdup ("\e[%i%p1%d;%p2%dH");
+ data->cls = grub_strdup ("\e[H\e[J");
+ data->reverse_video_on = grub_strdup ("\e[7m");
+ data->reverse_video_off = grub_strdup ("\e[m");
+ data->cursor_on = grub_strdup ("\e[?25h");
+ data->cursor_off = grub_strdup ("\e[?25l");
+ data->setcolor = NULL;
+ return grub_errno;
+ }
+
+ if (grub_strcmp ("vt100-color", str) == 0)
+ {
+ data->name = grub_strdup ("vt100-color");
+ data->gotoxy = grub_strdup ("\e[%i%p1%d;%p2%dH");
+ data->cls = grub_strdup ("\e[H\e[J");
+ data->reverse_video_on = grub_strdup ("\e[7m");
+ data->reverse_video_off = grub_strdup ("\e[m");
+ data->cursor_on = grub_strdup ("\e[?25h");
+ data->cursor_off = grub_strdup ("\e[?25l");
+ data->setcolor = grub_strdup ("\e[3%p1%dm\e[4%p2%dm");
+ return grub_errno;
+ }
+
+ if (grub_strcmp ("arc", str) == 0)
+ {
+ data->name = grub_strdup ("arc");
+ data->gotoxy = grub_strdup (ANSI_CSI_STR "%i%p1%d;%p2%dH");
+ data->cls = grub_strdup (ANSI_CSI_STR "2J");
+ data->reverse_video_on = grub_strdup (ANSI_CSI_STR "7m");
+ data->reverse_video_off = grub_strdup (ANSI_CSI_STR "0m");
+ data->cursor_on = 0;
+ data->cursor_off = 0;
+ data->setcolor = grub_strdup (ANSI_CSI_STR "3%p1%dm"
+ ANSI_CSI_STR "4%p2%dm");
+ return grub_errno;
+ }
+
+ if (grub_strcmp ("ieee1275", str) == 0
+ || grub_strcmp ("ieee1275-nocursor", str) == 0)
+ {
+ data->name = grub_strdup ("ieee1275");
+ data->gotoxy = grub_strdup ("\e[%i%p1%d;%p2%dH");
+ /* Clear the screen. Using serial console, screen(1) only recognizes the
+ * ANSI escape sequence. Using video console, Apple Open Firmware
+ * (version 3.1.1) only recognizes the literal ^L. So use both. */
+ data->cls = grub_strdup (" \e[2J");
+ data->reverse_video_on = grub_strdup ("\e[7m");
+ data->reverse_video_off = grub_strdup ("\e[m");
+ if (grub_strcmp ("ieee1275", str) == 0)
+ {
+ data->cursor_on = grub_strdup ("\e[?25h");
+ data->cursor_off = grub_strdup ("\e[?25l");
+ }
+ else
+ {
+ data->cursor_on = 0;
+ data->cursor_off = 0;
+ }
+ data->setcolor = grub_strdup ("\e[3%p1%dm\e[4%p2%dm");
+ return grub_errno;
+ }
+
+ if (grub_strcmp ("dumb", str) == 0)
+ {
+ data->name = grub_strdup ("dumb");
+ data->gotoxy = NULL;
+ data->cls = NULL;
+ data->reverse_video_on = NULL;
+ data->reverse_video_off = NULL;
+ data->cursor_on = NULL;
+ data->cursor_off = NULL;
+ data->setcolor = NULL;
+ return grub_errno;
+ }
+
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown terminfo type `%s'"),
+ str);
+}
+
+grub_err_t
+grub_terminfo_output_register (struct grub_term_output *term,
+ const char *type)
+{
+ grub_err_t err;
+ struct grub_terminfo_output_state *data;
+
+ err = grub_terminfo_set_current (term, type);
+
+ if (err)
+ return err;
+
+ data = (struct grub_terminfo_output_state *) term->data;
+ data->next = terminfo_outputs;
+ terminfo_outputs = term;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_terminfo_output_unregister (struct grub_term_output *term)
+{
+ struct grub_term_output **ptr;
+
+ for (ptr = &terminfo_outputs; *ptr;
+ ptr = &((struct grub_terminfo_output_state *) (*ptr)->data)->next)
+ if (*ptr == term)
+ {
+ grub_terminfo_all_free (term);
+ *ptr = ((struct grub_terminfo_output_state *) (*ptr)->data)->next;
+ return GRUB_ERR_NONE;
+ }
+ return grub_error (GRUB_ERR_BUG, "terminal not found");
+}
+
+/* Wrapper for grub_putchar to write strings. */
+static void
+putstr (struct grub_term_output *term, const char *str)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+ while (*str)
+ data->put (term, *str++);
+}
+
+struct grub_term_coordinate
+grub_terminfo_getxy (struct grub_term_output *term)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ return data->pos;
+}
+
+void
+grub_terminfo_gotoxy (struct grub_term_output *term,
+ struct grub_term_coordinate pos)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ if (pos.x > grub_term_width (term) || pos.y > grub_term_height (term))
+ {
+ grub_error (GRUB_ERR_BUG, "invalid point (%u,%u)", pos.x, pos.y);
+ return;
+ }
+
+ if (data->gotoxy)
+ putstr (term, grub_terminfo_tparm (data->gotoxy, pos.y, pos.x));
+ else
+ {
+ if ((pos.y == data->pos.y) && (pos.x == data->pos.x - 1))
+ data->put (term, '\b');
+ }
+
+ data->pos = pos;
+}
+
+/* Clear the screen. */
+void
+grub_terminfo_cls (struct grub_term_output *term)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ putstr (term, grub_terminfo_tparm (data->cls));
+ grub_terminfo_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
+}
+
+void
+grub_terminfo_setcolorstate (struct grub_term_output *term,
+ const grub_term_color_state state)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ if (data->setcolor)
+ {
+ int fg;
+ int bg;
+ /* Map from VGA to terminal colors. */
+ const int colormap[8]
+ = { 0, /* Black. */
+ 4, /* Blue. */
+ 2, /* Green. */
+ 6, /* Cyan. */
+ 1, /* Red. */
+ 5, /* Magenta. */
+ 3, /* Yellow. */
+ 7, /* White. */
+ };
+
+ switch (state)
+ {
+ case GRUB_TERM_COLOR_STANDARD:
+ case GRUB_TERM_COLOR_NORMAL:
+ fg = grub_term_normal_color & 0x0f;
+ bg = grub_term_normal_color >> 4;
+ break;
+ case GRUB_TERM_COLOR_HIGHLIGHT:
+ fg = grub_term_highlight_color & 0x0f;
+ bg = grub_term_highlight_color >> 4;
+ break;
+ default:
+ return;
+ }
+
+ putstr (term, grub_terminfo_tparm (data->setcolor, colormap[fg & 7],
+ colormap[bg & 7]));
+ return;
+ }
+
+ switch (state)
+ {
+ case GRUB_TERM_COLOR_STANDARD:
+ case GRUB_TERM_COLOR_NORMAL:
+ putstr (term, grub_terminfo_tparm (data->reverse_video_off));
+ break;
+ case GRUB_TERM_COLOR_HIGHLIGHT:
+ putstr (term, grub_terminfo_tparm (data->reverse_video_on));
+ break;
+ default:
+ break;
+ }
+}
+
+void
+grub_terminfo_setcursor (struct grub_term_output *term, const int on)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ if (on)
+ putstr (term, grub_terminfo_tparm (data->cursor_on));
+ else
+ putstr (term, grub_terminfo_tparm (data->cursor_off));
+}
+
+/* The terminfo version of putchar. */
+void
+grub_terminfo_putchar (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ /* Keep track of the cursor. */
+ switch (c->base)
+ {
+ case '\a':
+ break;
+
+ case '\b':
+ case 127:
+ if (data->pos.x > 0)
+ data->pos.x--;
+ break;
+
+ case '\n':
+ if (data->pos.y < grub_term_height (term) - 1)
+ data->pos.y++;
+ break;
+
+ case '\r':
+ data->pos.x = 0;
+ break;
+
+ default:
+ if ((int) data->pos.x + c->estimated_width >= (int) grub_term_width (term) + 1)
+ {
+ data->pos.x = 0;
+ if (data->pos.y < grub_term_height (term) - 1)
+ data->pos.y++;
+ data->put (term, '\r');
+ data->put (term, '\n');
+ }
+ data->pos.x += c->estimated_width;
+ break;
+ }
+
+ data->put (term, c->base);
+}
+
+struct grub_term_coordinate
+grub_terminfo_getwh (struct grub_term_output *term)
+{
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) term->data;
+
+ return data->size;
+}
+
+static void
+grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, int max_len,
+ int (*readkey) (struct grub_term_input *term))
+{
+ int c;
+
+#define CONTINUE_READ \
+ { \
+ grub_uint64_t start; \
+ /* On 9600 we have to wait up to 12 milliseconds. */ \
+ start = grub_get_time_ms (); \
+ do \
+ c = readkey (term); \
+ while (c == -1 && grub_get_time_ms () - start < 100); \
+ if (c == -1) \
+ return; \
+ \
+ if (*len >= max_len) \
+ return; \
+ \
+ keys[*len] = c; \
+ (*len)++; \
+ }
+
+ c = readkey (term);
+ if (c < 0)
+ {
+ *len = 0;
+ return;
+ }
+ *len = 1;
+ keys[0] = c;
+ if (c != ANSI_CSI && c != GRUB_TERM_ESC)
+ {
+ /* Backspace: Ctrl-h. */
+ if (c == 0x7f)
+ c = GRUB_TERM_BACKSPACE;
+ if (c < 0x20 && c != GRUB_TERM_TAB && c!= GRUB_TERM_BACKSPACE && c != '\n' && c != '\r')
+ c = GRUB_TERM_CTRL | (c - 1 + 'a');
+ *len = 1;
+ keys[0] = c;
+ return;
+ }
+
+ {
+ static struct
+ {
+ char key;
+ unsigned ascii;
+ }
+ three_code_table[] =
+ {
+ {'4', GRUB_TERM_KEY_DC},
+ {'A', GRUB_TERM_KEY_UP},
+ {'B', GRUB_TERM_KEY_DOWN},
+ {'C', GRUB_TERM_KEY_RIGHT},
+ {'D', GRUB_TERM_KEY_LEFT},
+ {'F', GRUB_TERM_KEY_END},
+ {'H', GRUB_TERM_KEY_HOME},
+ {'K', GRUB_TERM_KEY_END},
+ {'P', GRUB_TERM_KEY_DC},
+ {'?', GRUB_TERM_KEY_PPAGE},
+ {'/', GRUB_TERM_KEY_NPAGE},
+ {'@', GRUB_TERM_KEY_INSERT},
+ };
+
+ 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,
+ [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', '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_HOME, GRUB_TERM_KEY_END };
+ unsigned i;
+
+ if (c == GRUB_TERM_ESC)
+ {
+ CONTINUE_READ;
+
+ if (c == 'O')
+ {
+ CONTINUE_READ;
+
+ for (i = 0; i < ARRAY_SIZE (fx_key); i++)
+ if (fx_key[i] == c)
+ {
+ keys[0] = fx_code[i];
+ *len = 1;
+ return;
+ }
+ }
+
+ if (c != '[')
+ return;
+ }
+
+ CONTINUE_READ;
+
+ for (i = 0; i < ARRAY_SIZE (three_code_table); i++)
+ if (three_code_table[i].key == c)
+ {
+ keys[0] = three_code_table[i].ascii;
+ *len = 1;
+ return;
+ }
+
+ 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++)
+ if (fx_key[i] == c)
+ {
+ keys[0] = fx_code[i];
+ *len = 1;
+ return;
+ }
+ return;
+
+ case '0':
+ {
+ int num = 0;
+ CONTINUE_READ;
+ if (c != '0' && c != '1')
+ return;
+ num = (c - '0') * 10;
+ CONTINUE_READ;
+ if (c < '0' || c > '9')
+ return;
+ num += (c - '0');
+ if (num == 0 || num > 12)
+ return;
+ CONTINUE_READ;
+ if (c != 'q')
+ return;
+ keys[0] = fx_code[num - 1];
+ *len = 1;
+ return;
+ }
+
+ case '1' ... '9':
+ {
+ unsigned val = c - '0';
+ CONTINUE_READ;
+ if (c >= '0' && c <= '9')
+ {
+ val = val * 10 + (c - '0');
+ CONTINUE_READ;
+ }
+ 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
+}
+
+/* The terminfo version of getkey. */
+int
+grub_terminfo_getkey (struct grub_term_input *termi)
+{
+ struct grub_terminfo_input_state *data
+ = (struct grub_terminfo_input_state *) (termi->data);
+ if (data->npending)
+ {
+ int ret;
+ data->npending--;
+ ret = data->input_buf[0];
+ grub_memmove (data->input_buf, data->input_buf + 1, data->npending
+ * sizeof (data->input_buf[0]));
+ return ret;
+ }
+
+ grub_terminfo_readkey (termi, data->input_buf, &data->npending,
+ GRUB_TERMINFO_READKEY_MAX_LEN, data->readkey);
+
+#if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275)
+ if (data->npending == 1 && data->input_buf[0] == GRUB_TERM_ESC
+ && grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_REPEAT)
+ && grub_get_time_ms () - data->last_key_time < 1000
+ && (data->last_key & GRUB_TERM_EXTENDED))
+ {
+ data->npending = 0;
+ data->last_key_time = grub_get_time_ms ();
+ return data->last_key;
+ }
+#endif
+
+ if (data->npending)
+ {
+ int ret;
+ data->npending--;
+ ret = data->input_buf[0];
+#if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275)
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_REPEAT))
+ {
+ data->last_key = ret;
+ data->last_key_time = grub_get_time_ms ();
+ }
+#endif
+ grub_memmove (data->input_buf, data->input_buf + 1, data->npending
+ * sizeof (data->input_buf[0]));
+ return ret;
+ }
+
+ return GRUB_TERM_NO_KEY;
+}
+
+grub_err_t
+grub_terminfo_input_init (struct grub_term_input *termi)
+{
+ struct grub_terminfo_input_state *data
+ = (struct grub_terminfo_input_state *) (termi->data);
+ data->npending = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_terminfo_output_init (struct grub_term_output *term)
+{
+ grub_terminfo_cls (term);
+ return GRUB_ERR_NONE;
+}
+
+/* GRUB Command. */
+
+static grub_err_t
+print_terminfo (void)
+{
+ const char *encoding_names[(GRUB_TERM_CODE_TYPE_MASK
+ >> GRUB_TERM_CODE_TYPE_SHIFT) + 1]
+ = {
+ /* VGA and glyph descriptor types are just for completeness,
+ they are not used on terminfo terminals.
+ */
+ [GRUB_TERM_CODE_TYPE_ASCII >> GRUB_TERM_CODE_TYPE_SHIFT] = _("ASCII"),
+ [GRUB_TERM_CODE_TYPE_CP437 >> GRUB_TERM_CODE_TYPE_SHIFT] = "CP-437",
+ [GRUB_TERM_CODE_TYPE_UTF8_LOGICAL >> GRUB_TERM_CODE_TYPE_SHIFT]
+ = _("UTF-8"),
+ [GRUB_TERM_CODE_TYPE_UTF8_VISUAL >> GRUB_TERM_CODE_TYPE_SHIFT]
+ /* TRANSLATORS: visually ordered UTF-8 is a non-compliant encoding
+ based on UTF-8 with right-to-left languages written in reverse.
+ Used on some terminals. Normal UTF-8 is refered as
+ "logically-ordered UTF-8" by opposition. */
+ = _("visually-ordered UTF-8"),
+ [GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS >> GRUB_TERM_CODE_TYPE_SHIFT]
+ = "Glyph descriptors",
+ _("Unknown encoding"), _("Unknown encoding"), _("Unknown encoding")
+ };
+ struct grub_term_output *cur;
+
+ grub_puts_ (N_("Current terminfo types:"));
+ for (cur = terminfo_outputs; cur;
+ cur = ((struct grub_terminfo_output_state *) cur->data)->next)
+ grub_printf ("%s: %s\t%s\t%dx%d\n", cur->name,
+ grub_terminfo_get_current(cur),
+ encoding_names[(cur->flags & GRUB_TERM_CODE_TYPE_MASK)
+ >> GRUB_TERM_CODE_TYPE_SHIFT],
+ ((struct grub_terminfo_output_state *) cur->data)->pos.x,
+ ((struct grub_terminfo_output_state *) cur->data)->pos.y);
+
+ return GRUB_ERR_NONE;
+}
+
+static const struct grub_arg_option options[] =
+{
+ {"ascii", 'a', 0, N_("Terminal is ASCII-only [default]."), 0, ARG_TYPE_NONE},
+ {"utf8", 'u', 0, N_("Terminal is logical-ordered UTF-8."), 0, ARG_TYPE_NONE},
+ {"visual-utf8", 'v', 0, N_("Terminal is visually-ordered UTF-8."), 0,
+ ARG_TYPE_NONE},
+ {"geometry", 'g', 0, N_("Terminal has specified geometry."),
+ /* TRANSLATORS: "x" has to be entered in, like an identifier, so please don't
+ use better Unicode codepoints. */
+ N_("WIDTHxHEIGHT."), ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+};
+
+enum
+ {
+ OPTION_ASCII,
+ OPTION_UTF8,
+ OPTION_VISUAL_UTF8,
+ OPTION_GEOMETRY
+ };
+
+static grub_err_t
+grub_cmd_terminfo (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ struct grub_term_output *cur;
+ int encoding = GRUB_TERM_CODE_TYPE_ASCII;
+ struct grub_arg_list *state = ctxt->state;
+ int w = 0, h = 0;
+
+ if (argc == 0)
+ return print_terminfo ();
+
+ if (state[OPTION_ASCII].set)
+ encoding = GRUB_TERM_CODE_TYPE_ASCII;
+
+ if (state[OPTION_UTF8].set)
+ encoding = GRUB_TERM_CODE_TYPE_UTF8_LOGICAL;
+
+ if (state[OPTION_VISUAL_UTF8].set)
+ encoding = GRUB_TERM_CODE_TYPE_UTF8_VISUAL;
+
+ if (state[OPTION_GEOMETRY].set)
+ {
+ const char *ptr = state[OPTION_GEOMETRY].arg;
+ w = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ return grub_errno;
+ if (*ptr != 'x')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("incorrect terminal dimensions specification"));
+ ptr++;
+ h = grub_strtoul (ptr, &ptr, 0);
+ if (grub_errno)
+ return grub_errno;
+ }
+
+ for (cur = terminfo_outputs; cur;
+ cur = ((struct grub_terminfo_output_state *) cur->data)->next)
+ if (grub_strcmp (args[0], cur->name) == 0
+ || (grub_strcmp (args[0], "ofconsole") == 0
+ && grub_strcmp ("console", cur->name) == 0))
+ {
+ cur->flags = (cur->flags & ~GRUB_TERM_CODE_TYPE_MASK) | encoding;
+
+ if (w && h)
+ {
+ struct grub_terminfo_output_state *data
+ = (struct grub_terminfo_output_state *) cur->data;
+ data->size.x = w;
+ data->size.y = h;
+ }
+
+ if (argc == 1)
+ return GRUB_ERR_NONE;
+
+ return grub_terminfo_set_current (cur, args[1]);
+ }
+
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("terminal %s isn't found or it's not handled by terminfo"),
+ args[0]);
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(terminfo)
+{
+ cmd = grub_register_extcmd ("terminfo", grub_cmd_terminfo, 0,
+ N_("[[-a|-u|-v] [-g WxH] [TERM] [TYPE]]"),
+ N_("Set terminfo type of TERM to TYPE.\n"),
+ options);
+}
+
+GRUB_MOD_FINI(terminfo)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/term/tparm.c b/grub-core/term/tparm.c
new file mode 100644
index 0000000..fb5b15a
--- /dev/null
+++ b/grub-core/term/tparm.c
@@ -0,0 +1,767 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1998-2003,2004,2005 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**********************************************************************
+ * This code is a modification of lib_tparm.c found in ncurses-5.2. The
+ * modification are for use in grub by replacing all libc function through
+ * special grub functions. This also meant to delete all dynamic memory
+ * allocation and replace it by a number of fixed buffers.
+ *
+ * Modifications by Tilmann Bubeck <t.bubeck@reinform.de> 2002
+ *
+ * Resync with ncurses-5.4 by Omniflux <omniflux+devel@omniflux.com> 2005
+ **********************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey, 1996 on *
+ ****************************************************************************/
+
+/*
+ * tparm.c
+ *
+ */
+
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/tparm.h>
+
+/*
+ * Common/troublesome character definitions
+ */
+typedef char grub_bool_t;
+#ifndef FALSE
+# define FALSE (0)
+#endif
+#ifndef TRUE
+# define TRUE (!FALSE)
+#endif
+
+#define NUM_PARM 9
+#define NUM_VARS 26
+#define STACKSIZE 20
+#define MAX_FORMAT_LEN 256
+
+#define max(a,b) ((a) > (b) ? (a) : (b))
+#define isdigit(c) ((c) >= '0' && (c) <= '9')
+#define isUPPER(c) ((c) >= 'A' && (c) <= 'Z')
+#define isLOWER(c) ((c) >= 'a' && (c) <= 'z')
+
+#define UChar(c) ((unsigned char)(c))
+
+//MODULE_ID("$Id$")
+
+/*
+ * char *
+ * tparm(string, ...)
+ *
+ * Substitute the given parameters into the given string by the following
+ * rules (taken from terminfo(5)):
+ *
+ * Cursor addressing and other strings requiring parame-
+ * ters in the terminal are described by a parameterized string
+ * capability, with like escapes %x in it. For example, to
+ * address the cursor, the cup capability is given, using two
+ * parameters: the row and column to address to. (Rows and
+ * columns are numbered from zero and refer to the physical
+ * screen visible to the user, not to any unseen memory.) If
+ * the terminal has memory relative cursor addressing, that can
+ * be indicated by
+ *
+ * The parameter mechanism uses a stack and special %
+ * codes to manipulate it. Typically a sequence will push one
+ * of the parameters onto the stack and then print it in some
+ * format. Often more complex operations are necessary.
+ *
+ * The % encodings have the following meanings:
+ *
+ * %% outputs `%'
+ * %c print pop() like %c in printf()
+ * %s print pop() like %s in printf()
+ * %[[:]flags][width[.precision]][doxXs]
+ * as in printf, flags are [-+#] and space
+ * The ':' is used to avoid making %+ or %-
+ * patterns (see below).
+ *
+ * %p[1-9] push ith parm
+ * %P[a-z] set dynamic variable [a-z] to pop()
+ * %g[a-z] get dynamic variable [a-z] and push it
+ * %P[A-Z] set static variable [A-Z] to pop()
+ * %g[A-Z] get static variable [A-Z] and push it
+ * %l push strlen(pop)
+ * %'c' push char constant c
+ * %{nn} push integer constant nn
+ *
+ * %+ %- %* %/ %m
+ * arithmetic (%m is mod): push(pop() op pop())
+ * %& %| %^ bit operations: push(pop() op pop())
+ * %= %> %< logical operations: push(pop() op pop())
+ * %A %O logical and & or operations for conditionals
+ * %! %~ unary operations push(op pop())
+ * %i add 1 to first two parms (for ANSI terminals)
+ *
+ * %? expr %t thenpart %e elsepart %;
+ * if-then-else, %e elsepart is optional.
+ * else-if's are possible ala Algol 68:
+ * %? c1 %t b1 %e c2 %t b2 %e c3 %t b3 %e c4 %t b4 %e b5 %;
+ *
+ * For those of the above operators which are binary and not commutative,
+ * the stack works in the usual way, with
+ * %gx %gy %m
+ * resulting in x mod y, not the reverse.
+ */
+
+typedef struct {
+ union {
+ int num;
+ char *str;
+ } data;
+ grub_bool_t num_type;
+} stack_frame;
+
+static stack_frame stack[STACKSIZE];
+static int stack_ptr;
+static const char *tparam_base = "";
+
+static char *out_buff;
+static grub_size_t out_size;
+static grub_size_t out_used;
+
+static char *fmt_buff;
+static grub_size_t fmt_size;
+
+static inline void
+get_space(grub_size_t need)
+{
+ need += out_used;
+ if (need > out_size) {
+ out_size = need * 2;
+ out_buff = grub_realloc(out_buff, out_size*sizeof(char));
+ /* FIX ME! handle out_buff == 0. */
+ }
+}
+
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
+static inline void
+save_text(const char *fmt, const char *s, int len)
+{
+ grub_size_t s_len = grub_strlen(s);
+ if (len > (int) s_len)
+ s_len = len;
+
+ get_space(s_len + 1);
+
+ (void) grub_snprintf(out_buff + out_used, s_len + 1, fmt, s);
+ out_used += grub_strlen(out_buff + out_used);
+}
+
+static inline void
+save_number(const char *fmt, int number, int len)
+{
+ if (len < 30)
+ len = 30; /* actually log10(MAX_INT)+1 */
+
+ get_space((unsigned) len + 1);
+
+ (void) grub_snprintf(out_buff + out_used, len + 1, fmt, number);
+ out_used += grub_strlen(out_buff + out_used);
+}
+
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
+static inline void
+save_char(int c)
+{
+ if (c == 0)
+ c = 0200;
+ get_space(1);
+ out_buff[out_used++] = c;
+}
+
+static inline void
+npush(int x)
+{
+ if (stack_ptr < STACKSIZE) {
+ stack[stack_ptr].num_type = TRUE;
+ stack[stack_ptr].data.num = x;
+ stack_ptr++;
+ }
+}
+
+static inline int
+npop(void)
+{
+ int result = 0;
+ if (stack_ptr > 0) {
+ stack_ptr--;
+ if (stack[stack_ptr].num_type)
+ result = stack[stack_ptr].data.num;
+ }
+ return result;
+}
+
+static inline void
+spush(char *x)
+{
+ if (stack_ptr < STACKSIZE) {
+ stack[stack_ptr].num_type = FALSE;
+ stack[stack_ptr].data.str = x;
+ stack_ptr++;
+ }
+}
+
+static inline char *
+spop(void)
+{
+ static char dummy[] = ""; /* avoid const-cast */
+ char *result = dummy;
+ if (stack_ptr > 0) {
+ stack_ptr--;
+ if (!stack[stack_ptr].num_type && stack[stack_ptr].data.str != 0)
+ result = stack[stack_ptr].data.str;
+ }
+ return result;
+}
+
+static inline const char *
+parse_format(const char *s, char *format, int *len)
+{
+ *len = 0;
+ if (format != 0) {
+ grub_bool_t done = FALSE;
+ grub_bool_t allowminus = FALSE;
+ grub_bool_t dot = FALSE;
+ grub_bool_t err = FALSE;
+ char *fmt = format;
+ int my_width = 0;
+ int my_prec = 0;
+ int value = 0;
+
+ *len = 0;
+ *format++ = '%';
+ while (*s != '\0' && !done) {
+ switch (*s) {
+ case 'c': /* FALLTHRU */
+ case 'd': /* FALLTHRU */
+ case 'o': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ case 's':
+ *format++ = *s;
+ done = TRUE;
+ break;
+ case '.':
+ *format++ = *s++;
+ if (dot) {
+ err = TRUE;
+ } else { /* value before '.' is the width */
+ dot = TRUE;
+ my_width = value;
+ }
+ value = 0;
+ break;
+ case '#':
+ *format++ = *s++;
+ break;
+ case ' ':
+ *format++ = *s++;
+ break;
+ case ':':
+ s++;
+ allowminus = TRUE;
+ break;
+ case '-':
+ if (allowminus) {
+ *format++ = *s++;
+ } else {
+ done = TRUE;
+ }
+ break;
+ default:
+ if (isdigit(UChar(*s))) {
+ value = (value * 10) + (*s - '0');
+ if (value > 10000)
+ err = TRUE;
+ *format++ = *s++;
+ } else {
+ done = TRUE;
+ }
+ }
+ }
+
+ /*
+ * If we found an error, ignore (and remove) the flags.
+ */
+ if (err) {
+ my_width = my_prec = value = 0;
+ format = fmt;
+ *format++ = '%';
+ *format++ = *s;
+ }
+
+ /*
+ * Any value after '.' is the precision. If we did not see '.', then
+ * the value is the width.
+ */
+ if (dot)
+ my_prec = value;
+ else
+ my_width = value;
+
+ *format = '\0';
+ /* return maximum string length in print */
+ *len = (my_width > my_prec) ? my_width : my_prec;
+ }
+ return s;
+}
+
+/*
+ * Analyze the string to see how many parameters we need from the varargs list,
+ * and what their types are. We will only accept string parameters if they
+ * appear as a %l or %s format following an explicit parameter reference (e.g.,
+ * %p2%s). All other parameters are numbers.
+ *
+ * 'number' counts coarsely the number of pop's we see in the string, and
+ * 'popcount' shows the highest parameter number in the string. We would like
+ * to simply use the latter count, but if we are reading termcap strings, there
+ * may be cases that we cannot see the explicit parameter numbers.
+ */
+static inline int
+analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount)
+{
+ grub_size_t len2;
+ int i;
+ int lastpop = -1;
+ int len;
+ int number = 0;
+ const char *cp = string;
+ static char dummy[] = "";
+
+ *popcount = 0;
+
+ if (cp == 0)
+ return 0;
+
+ if ((len2 = grub_strlen(cp)) > fmt_size) {
+ fmt_size = len2 + fmt_size + 2;
+ if ((fmt_buff = grub_realloc(fmt_buff, fmt_size*sizeof(char))) == 0)
+ return 0;
+ }
+
+ grub_memset(p_is_s, 0, sizeof(p_is_s[0]) * NUM_PARM);
+
+ while ((cp - string) < (int) len2) {
+ if (*cp == '%') {
+ cp++;
+ cp = parse_format(cp, fmt_buff, &len);
+ switch (*cp) {
+ default:
+ break;
+
+ case 'd': /* FALLTHRU */
+ case 'o': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ case 'c': /* FALLTHRU */
+ if (lastpop <= 0)
+ number++;
+ lastpop = -1;
+ break;
+
+ case 'l':
+ case 's':
+ if (lastpop > 0)
+ p_is_s[lastpop - 1] = dummy;
+ ++number;
+ break;
+
+ case 'p':
+ cp++;
+ i = (UChar(*cp) - '0');
+ if (i >= 0 && i <= NUM_PARM) {
+ lastpop = i;
+ if (lastpop > *popcount)
+ *popcount = lastpop;
+ }
+ break;
+
+ case 'P':
+ ++number;
+ ++cp;
+ break;
+
+ case 'g':
+ cp++;
+ break;
+
+ case '\'':
+ cp += 2;
+ lastpop = -1;
+ break;
+
+ case '{':
+ cp++;
+ while (isdigit(UChar(*cp))) {
+ cp++;
+ }
+ break;
+
+ case '+':
+ case '-':
+ case '*':
+ case '/':
+ case 'm':
+ case 'A':
+ case 'O':
+ case '&':
+ case '|':
+ case '^':
+ case '=':
+ case '<':
+ case '>':
+ lastpop = -1;
+ number += 2;
+ break;
+
+ case '!':
+ case '~':
+ lastpop = -1;
+ ++number;
+ break;
+
+ case 'i':
+ /* will add 1 to first (usually two) parameters */
+ break;
+ }
+ }
+ if (*cp != '\0')
+ cp++;
+ }
+
+ if (number > NUM_PARM)
+ number = NUM_PARM;
+ return number;
+}
+
+static inline char *
+tparam_internal(const char *string, va_list ap)
+{
+ char *p_is_s[NUM_PARM];
+ long param[NUM_PARM];
+ int popcount;
+ int number;
+ int len;
+ int level;
+ int x, y;
+ int i;
+ const char *cp = string;
+ grub_size_t len2;
+ static int dynamic_var[NUM_VARS];
+ static int static_vars[NUM_VARS];
+
+ if (cp == 0)
+ return 0;
+
+ out_used = out_size = fmt_size = 0;
+
+ len2 = (int) grub_strlen(cp);
+
+ /*
+ * Find the highest parameter-number referred to in the format string.
+ * Use this value to limit the number of arguments copied from the
+ * variable-length argument list.
+ */
+ number = analyze(cp, p_is_s, &popcount);
+ if (fmt_buff == 0)
+ return 0;
+
+ for (i = 0; i < max(popcount, number); i++) {
+ /*
+ * A few caps (such as plab_norm) have string-valued parms.
+ * We'll have to assume that the caller knows the difference, since
+ * a char* and an int may not be the same size on the stack.
+ */
+ if (p_is_s[i] != 0) {
+ p_is_s[i] = va_arg(ap, char *);
+ } else {
+ param[i] = va_arg(ap, long int);
+ }
+ }
+
+ /*
+ * This is a termcap compatibility hack. If there are no explicit pop
+ * operations in the string, load the stack in such a way that
+ * successive pops will grab successive parameters. That will make
+ * the expansion of (for example) \E[%d;%dH work correctly in termcap
+ * style, which means tparam() will expand termcap strings OK.
+ */
+ stack_ptr = 0;
+ if (popcount == 0) {
+ popcount = number;
+ for (i = number - 1; i >= 0; i--)
+ npush(param[i]);
+ }
+
+ while ((cp - string) < (int) len2) {
+ if (*cp != '%') {
+ save_char(UChar(*cp));
+ } else {
+ tparam_base = cp++;
+ cp = parse_format(cp, fmt_buff, &len);
+ switch (*cp) {
+ default:
+ break;
+ case '%':
+ save_char('%');
+ break;
+
+ case 'd': /* FALLTHRU */
+ case 'o': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ save_number(fmt_buff, npop(), len);
+ break;
+
+ case 'c': /* FALLTHRU */
+ save_char(npop());
+ break;
+
+ case 'l':
+ save_number("%d", (int) grub_strlen(spop()), 0);
+ break;
+
+ case 's':
+ save_text(fmt_buff, spop(), len);
+ break;
+
+ case 'p':
+ cp++;
+ i = (UChar(*cp) - '1');
+ if (i >= 0 && i < NUM_PARM) {
+ if (p_is_s[i])
+ spush(p_is_s[i]);
+ else
+ npush(param[i]);
+ }
+ break;
+
+ case 'P':
+ cp++;
+ if (isUPPER(*cp)) {
+ i = (UChar(*cp) - 'A');
+ static_vars[i] = npop();
+ } else if (isLOWER(*cp)) {
+ i = (UChar(*cp) - 'a');
+ dynamic_var[i] = npop();
+ }
+ break;
+
+ case 'g':
+ cp++;
+ if (isUPPER(*cp)) {
+ i = (UChar(*cp) - 'A');
+ npush(static_vars[i]);
+ } else if (isLOWER(*cp)) {
+ i = (UChar(*cp) - 'a');
+ npush(dynamic_var[i]);
+ }
+ break;
+
+ case '\'':
+ cp++;
+ npush(UChar(*cp));
+ cp++;
+ break;
+
+ case '{':
+ number = 0;
+ cp++;
+ while (isdigit(UChar(*cp))) {
+ number = (number * 10) + (UChar(*cp) - '0');
+ cp++;
+ }
+ npush(number);
+ break;
+
+ case '+':
+ npush(npop() + npop());
+ break;
+
+ case '-':
+ y = npop();
+ x = npop();
+ npush(x - y);
+ break;
+
+ case '*':
+ npush(npop() * npop());
+ break;
+
+ case '/':
+ y = npop();
+ x = npop();
+ /* GRUB has no signed divisions. */
+ npush(y ? ((unsigned)x / (unsigned)y) : 0);
+ break;
+
+ case 'm':
+ y = npop();
+ x = npop();
+ /* GRUB has no signed divisions. */
+ npush(y ? ((unsigned)x % (unsigned)y) : 0);
+ break;
+
+ case 'A':
+ npush(npop() && npop());
+ break;
+
+ case 'O':
+ npush(npop() || npop());
+ break;
+
+ case '&':
+ npush(npop() & npop());
+ break;
+
+ case '|':
+ npush(npop() | npop());
+ break;
+
+ case '^':
+ npush(npop() ^ npop());
+ break;
+
+ case '=':
+ y = npop();
+ x = npop();
+ npush(x == y);
+ break;
+
+ case '<':
+ y = npop();
+ x = npop();
+ npush(x < y);
+ break;
+
+ case '>':
+ y = npop();
+ x = npop();
+ npush(x > y);
+ break;
+
+ case '!':
+ npush(!npop());
+ break;
+
+ case '~':
+ npush(~npop());
+ break;
+
+ case 'i':
+ if (p_is_s[0] == 0)
+ param[0]++;
+ if (p_is_s[1] == 0)
+ param[1]++;
+ break;
+
+ case '?':
+ break;
+
+ case 't':
+ x = npop();
+ if (!x) {
+ /* scan forward for %e or %; at level zero */
+ cp++;
+ level = 0;
+ while (*cp) {
+ if (*cp == '%') {
+ cp++;
+ if (*cp == '?')
+ level++;
+ else if (*cp == ';') {
+ if (level > 0)
+ level--;
+ else
+ break;
+ } else if (*cp == 'e' && level == 0)
+ break;
+ }
+
+ if (*cp)
+ cp++;
+ }
+ }
+ break;
+
+ case 'e':
+ /* scan forward for a %; at level zero */
+ cp++;
+ level = 0;
+ while (*cp) {
+ if (*cp == '%') {
+ cp++;
+ if (*cp == '?')
+ level++;
+ else if (*cp == ';') {
+ if (level > 0)
+ level--;
+ else
+ break;
+ }
+ }
+
+ if (*cp)
+ cp++;
+ }
+ break;
+
+ case ';':
+ break;
+
+ } /* endswitch (*cp) */
+ } /* endelse (*cp == '%') */
+
+ if (*cp == '\0')
+ break;
+
+ cp++;
+ } /* endwhile (*cp) */
+
+ get_space(1);
+ out_buff[out_used] = '\0';
+
+ return (out_buff);
+}
+
+const char *
+grub_terminfo_tparm (const char *string, ...)
+{
+ va_list ap;
+ char *result;
+
+ if (!string)
+ return "";
+
+ va_start (ap, string);
+ result = tparam_internal (string, ap);
+ va_end (ap);
+ return result;
+}
diff --git a/grub-core/term/uboot/console.c b/grub-core/term/uboot/console.c
new file mode 100644
index 0000000..dfdbe99
--- /dev/null
+++ b/grub-core/term/uboot/console.c
@@ -0,0 +1,132 @@
+/* console.c - console interface layer for U-Boot platforms */
+/*
+ * 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/term.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/terminfo.h>
+#include <grub/uboot/uboot.h>
+#include <grub/uboot/console.h>
+
+static void
+put (struct grub_term_output *term __attribute__ ((unused)), const int c)
+{
+ grub_uboot_putc (c);
+}
+
+static int
+readkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ if (grub_uboot_tstc () > 0)
+ return grub_uboot_getc ();
+
+ return -1;
+}
+
+static void
+uboot_console_setcursor (struct grub_term_output *term
+ __attribute__ ((unused)), int on
+ __attribute__ ((unused)))
+{
+ grub_terminfo_setcursor (term, on);
+}
+
+static grub_err_t
+uboot_console_init_input (struct grub_term_input *term)
+{
+ return grub_terminfo_input_init (term);
+}
+
+extern struct grub_terminfo_output_state uboot_console_terminfo_output;
+
+
+static grub_err_t
+uboot_console_init_output (struct grub_term_output *term)
+{
+ grub_terminfo_output_init (term);
+
+ return 0;
+}
+
+struct grub_terminfo_input_state uboot_console_terminfo_input = {
+ .readkey = readkey
+};
+
+struct grub_terminfo_output_state uboot_console_terminfo_output = {
+ .put = put,
+ /* FIXME: In rare cases when console isn't serial,
+ determine real width. */
+ .size = { 80, 24 }
+};
+
+static struct grub_term_input uboot_console_term_input = {
+ .name = "console",
+ .init = uboot_console_init_input,
+ .getkey = grub_terminfo_getkey,
+ .data = &uboot_console_terminfo_input
+};
+
+static struct grub_term_output uboot_console_term_output = {
+ .name = "console",
+ .init = uboot_console_init_output,
+ .putchar = grub_terminfo_putchar,
+ .getwh = grub_terminfo_getwh,
+ .getxy = grub_terminfo_getxy,
+ .gotoxy = grub_terminfo_gotoxy,
+ .cls = grub_terminfo_cls,
+ .setcolorstate = grub_terminfo_setcolorstate,
+ .setcursor = uboot_console_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_ASCII,
+ .data = &uboot_console_terminfo_output,
+ .progress_update_divisor = GRUB_PROGRESS_FAST
+};
+
+void
+grub_console_init_early (void)
+{
+ grub_term_register_input ("console", &uboot_console_term_input);
+ grub_term_register_output ("console", &uboot_console_term_output);
+}
+
+
+/*
+ * grub_console_init_lately():
+ * Initializes terminfo formatting by registering terminal type.
+ * Called after heap has been configured.
+ *
+ */
+void
+grub_console_init_lately (void)
+{
+ const char *type;
+
+ /* See if explicitly set by U-Boot environment */
+ type = grub_uboot_env_get ("grub_term");
+ if (!type)
+ type = "vt100";
+
+ grub_terminfo_init ();
+ grub_terminfo_output_register (&uboot_console_term_output, type);
+}
+
+void
+grub_console_fini (void)
+{
+}
diff --git a/grub-core/term/usb_keyboard.c b/grub-core/term/usb_keyboard.c
new file mode 100644
index 0000000..e67b8f7
--- /dev/null
+++ b/grub-core/term/usb_keyboard.c
@@ -0,0 +1,471 @@
+/* Support for the HID Boot Protocol. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/term.h>
+#include <grub/time.h>
+#include <grub/misc.h>
+#include <grub/term.h>
+#include <grub/usb.h>
+#include <grub/dl.h>
+#include <grub/time.h>
+#include <grub/keyboard_layouts.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+
+
+enum
+ {
+ KEY_NO_KEY = 0x00,
+ KEY_ERR_BUFFER = 0x01,
+ KEY_ERR_POST = 0x02,
+ KEY_ERR_UNDEF = 0x03,
+ KEY_CAPS_LOCK = 0x39,
+ KEY_NUM_LOCK = 0x53,
+ };
+
+enum
+ {
+ LED_NUM_LOCK = 0x01,
+ LED_CAPS_LOCK = 0x02
+ };
+
+/* Valid values for bRequest. See HID definition version 1.11 section 7.2. */
+#define USB_HID_GET_REPORT 0x01
+#define USB_HID_GET_IDLE 0x02
+#define USB_HID_GET_PROTOCOL 0x03
+#define USB_HID_SET_REPORT 0x09
+#define USB_HID_SET_IDLE 0x0A
+#define USB_HID_SET_PROTOCOL 0x0B
+
+#define USB_HID_BOOT_SUBCLASS 0x01
+#define USB_HID_KBD_PROTOCOL 0x01
+
+#define GRUB_USB_KEYBOARD_LEFT_CTRL 0x01
+#define GRUB_USB_KEYBOARD_LEFT_SHIFT 0x02
+#define GRUB_USB_KEYBOARD_LEFT_ALT 0x04
+#define GRUB_USB_KEYBOARD_RIGHT_CTRL 0x10
+#define GRUB_USB_KEYBOARD_RIGHT_SHIFT 0x20
+#define GRUB_USB_KEYBOARD_RIGHT_ALT 0x40
+
+struct grub_usb_keyboard_data
+{
+ grub_usb_device_t usbdev;
+ grub_uint8_t status;
+ grub_uint16_t mods;
+ int interfno;
+ struct grub_usb_desc_endp *endp;
+ grub_usb_transfer_t transfer;
+ grub_uint8_t report[8];
+ int dead;
+ int last_key;
+ grub_uint64_t repeat_time;
+ grub_uint8_t current_report[8];
+ grub_uint8_t last_report[8];
+ int index;
+ int max_index;
+};
+
+static int grub_usb_keyboard_getkey (struct grub_term_input *term);
+static int grub_usb_keyboard_getkeystatus (struct grub_term_input *term);
+
+static struct grub_term_input grub_usb_keyboard_term =
+ {
+ .getkey = grub_usb_keyboard_getkey,
+ .getkeystatus = grub_usb_keyboard_getkeystatus,
+ .next = 0
+ };
+
+static struct grub_term_input grub_usb_keyboards[16];
+
+static int
+interpret_status (grub_uint8_t data0)
+{
+ int mods = 0;
+
+ /* Check Shift, Control, and Alt status. */
+ if (data0 & GRUB_USB_KEYBOARD_LEFT_SHIFT)
+ mods |= GRUB_TERM_STATUS_LSHIFT;
+ if (data0 & GRUB_USB_KEYBOARD_RIGHT_SHIFT)
+ mods |= GRUB_TERM_STATUS_RSHIFT;
+ if (data0 & GRUB_USB_KEYBOARD_LEFT_CTRL)
+ mods |= GRUB_TERM_STATUS_LCTRL;
+ if (data0 & GRUB_USB_KEYBOARD_RIGHT_CTRL)
+ mods |= GRUB_TERM_STATUS_RCTRL;
+ if (data0 & GRUB_USB_KEYBOARD_LEFT_ALT)
+ mods |= GRUB_TERM_STATUS_LALT;
+ if (data0 & GRUB_USB_KEYBOARD_RIGHT_ALT)
+ mods |= GRUB_TERM_STATUS_RALT;
+
+ return mods;
+}
+
+static void
+grub_usb_keyboard_detach (grub_usb_device_t usbdev,
+ int config __attribute__ ((unused)),
+ int interface __attribute__ ((unused)))
+{
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE (grub_usb_keyboards); i++)
+ {
+ struct grub_usb_keyboard_data *data = grub_usb_keyboards[i].data;
+
+ if (!data)
+ continue;
+
+ if (data->usbdev != usbdev)
+ continue;
+
+ if (data->transfer)
+ grub_usb_cancel_transfer (data->transfer);
+
+ grub_term_unregister_input (&grub_usb_keyboards[i]);
+ grub_free ((char *) grub_usb_keyboards[i].name);
+ grub_usb_keyboards[i].name = NULL;
+ grub_free (grub_usb_keyboards[i].data);
+ grub_usb_keyboards[i].data = 0;
+ }
+}
+
+static int
+grub_usb_keyboard_attach (grub_usb_device_t usbdev, int configno, int interfno)
+{
+ unsigned curnum;
+ struct grub_usb_keyboard_data *data;
+ struct grub_usb_desc_endp *endp = NULL;
+ int j;
+
+ grub_dprintf ("usb_keyboard", "%x %x %x %d %d\n",
+ usbdev->descdev.class, usbdev->descdev.subclass,
+ usbdev->descdev.protocol, configno, interfno);
+
+ for (curnum = 0; curnum < ARRAY_SIZE (grub_usb_keyboards); curnum++)
+ if (!grub_usb_keyboards[curnum].data)
+ break;
+
+ if (curnum == ARRAY_SIZE (grub_usb_keyboards))
+ return 0;
+
+ if (usbdev->descdev.class != 0
+ || usbdev->descdev.subclass != 0 || usbdev->descdev.protocol != 0)
+ return 0;
+
+ if (usbdev->config[configno].interf[interfno].descif->subclass
+ != USB_HID_BOOT_SUBCLASS
+ || usbdev->config[configno].interf[interfno].descif->protocol
+ != USB_HID_KBD_PROTOCOL)
+ return 0;
+
+ for (j = 0; j < usbdev->config[configno].interf[interfno].descif->endpointcnt;
+ j++)
+ {
+ endp = &usbdev->config[configno].interf[interfno].descendp[j];
+
+ if ((endp->endp_addr & 128) && grub_usb_get_ep_type(endp)
+ == GRUB_USB_EP_INTERRUPT)
+ break;
+ }
+ if (j == usbdev->config[configno].interf[interfno].descif->endpointcnt)
+ return 0;
+
+ grub_dprintf ("usb_keyboard", "HID found!\n");
+
+ data = grub_malloc (sizeof (*data));
+ if (!data)
+ {
+ grub_print_error ();
+ return 0;
+ }
+
+ data->usbdev = usbdev;
+ data->interfno = interfno;
+ data->endp = endp;
+
+ /* Configure device */
+ grub_usb_set_configuration (usbdev, configno + 1);
+
+ /* Place the device in boot mode. */
+ grub_usb_control_msg (usbdev, GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT,
+ USB_HID_SET_PROTOCOL, 0, interfno, 0, 0);
+
+ /* Reports every time an event occurs and not more often than that. */
+ grub_usb_control_msg (usbdev, GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT,
+ USB_HID_SET_IDLE, 0<<8, interfno, 0, 0);
+
+ grub_memcpy (&grub_usb_keyboards[curnum], &grub_usb_keyboard_term,
+ sizeof (grub_usb_keyboards[curnum]));
+ grub_usb_keyboards[curnum].data = data;
+ usbdev->config[configno].interf[interfno].detach_hook
+ = grub_usb_keyboard_detach;
+ grub_usb_keyboards[curnum].name = grub_xasprintf ("usb_keyboard%d", curnum);
+ if (!grub_usb_keyboards[curnum].name)
+ {
+ grub_print_error ();
+ return 0;
+ }
+
+ /* Test showed that getting report may make the keyboard go nuts.
+ Moreover since we're reattaching keyboard it usually sends
+ an initial message on interrupt pipe and so we retrieve
+ the same keystatus.
+ */
+#if 0
+ {
+ grub_uint8_t report[8];
+ grub_usb_err_t err;
+ grub_memset (report, 0, sizeof (report));
+ err = grub_usb_control_msg (usbdev, GRUB_USB_REQTYPE_CLASS_INTERFACE_IN,
+ USB_HID_GET_REPORT, 0x0100, interfno,
+ sizeof (report), (char *) report);
+ if (err)
+ data->status = 0;
+ else
+ data->status = report[0];
+ }
+#else
+ data->status = 0;
+#endif
+
+ data->transfer = grub_usb_bulk_read_background (usbdev,
+ data->endp,
+ sizeof (data->report),
+ (char *) data->report);
+ if (!data->transfer)
+ {
+ grub_print_error ();
+ return 0;
+ }
+
+ data->last_key = -1;
+ data->mods = 0;
+ data->dead = 0;
+
+ grub_term_register_input_active ("usb_keyboard", &grub_usb_keyboards[curnum]);
+
+ return 1;
+}
+
+
+
+static void
+send_leds (struct grub_usb_keyboard_data *termdata)
+{
+ char report[1];
+ report[0] = 0;
+ if (termdata->mods & GRUB_TERM_STATUS_CAPS)
+ report[0] |= LED_CAPS_LOCK;
+ if (termdata->mods & GRUB_TERM_STATUS_NUM)
+ report[0] |= LED_NUM_LOCK;
+ grub_usb_control_msg (termdata->usbdev, GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT,
+ USB_HID_SET_REPORT, 0x0200, termdata->interfno,
+ sizeof (report), (char *) report);
+ grub_errno = GRUB_ERR_NONE;
+}
+
+static int
+parse_keycode (struct grub_usb_keyboard_data *termdata)
+{
+ int index = termdata->index;
+ int i, keycode;
+
+ /* Sanity check */
+ if (index < 2)
+ index = 2;
+
+ for ( ; index < termdata->max_index; index++)
+ {
+ keycode = termdata->current_report[index];
+
+ if (keycode == KEY_NO_KEY
+ || keycode == KEY_ERR_BUFFER
+ || keycode == KEY_ERR_POST
+ || keycode == KEY_ERR_UNDEF)
+ {
+ /* Don't parse (rest of) this report */
+ termdata->index = 0;
+ if (keycode != KEY_NO_KEY)
+ /* Don't replace last report with current faulty report
+ * in future ! */
+ grub_memcpy (termdata->current_report,
+ termdata->last_report,
+ sizeof (termdata->report));
+ return GRUB_TERM_NO_KEY;
+ }
+
+ /* Try to find current keycode in last report. */
+ for (i = 2; i < 8; i++)
+ if (keycode == termdata->last_report[i])
+ break;
+ if (i < 8)
+ /* Keycode is in last report, it means it was not released,
+ * ignore it. */
+ continue;
+
+ if (keycode == KEY_CAPS_LOCK)
+ {
+ termdata->mods ^= GRUB_TERM_STATUS_CAPS;
+ send_leds (termdata);
+ continue;
+ }
+
+ if (keycode == KEY_NUM_LOCK)
+ {
+ termdata->mods ^= GRUB_TERM_STATUS_NUM;
+ send_leds (termdata);
+ continue;
+ }
+
+ termdata->last_key = grub_term_map_key (keycode,
+ interpret_status (termdata->current_report[0])
+ | termdata->mods);
+ termdata->repeat_time = grub_get_time_ms () + GRUB_TERM_REPEAT_PRE_INTERVAL;
+
+ grub_errno = GRUB_ERR_NONE;
+
+ index++;
+ if (index >= termdata->max_index)
+ termdata->index = 0;
+ else
+ termdata->index = index;
+
+ return termdata->last_key;
+ }
+
+ /* All keycodes parsed */
+ termdata->index = 0;
+ return GRUB_TERM_NO_KEY;
+}
+
+static int
+grub_usb_keyboard_getkey (struct grub_term_input *term)
+{
+ grub_usb_err_t err;
+ struct grub_usb_keyboard_data *termdata = term->data;
+ grub_size_t actual;
+ int keycode = GRUB_TERM_NO_KEY;
+
+ if (termdata->dead)
+ return GRUB_TERM_NO_KEY;
+
+ if (termdata->index)
+ keycode = parse_keycode (termdata);
+ if (keycode != GRUB_TERM_NO_KEY)
+ return keycode;
+
+ /* Poll interrupt pipe. */
+ err = grub_usb_check_transfer (termdata->transfer, &actual);
+
+ if (err == GRUB_USB_ERR_WAIT)
+ {
+ if (termdata->last_key != -1
+ && grub_get_time_ms () > termdata->repeat_time)
+ {
+ termdata->repeat_time = grub_get_time_ms ()
+ + GRUB_TERM_REPEAT_INTERVAL;
+ return termdata->last_key;
+ }
+ return GRUB_TERM_NO_KEY;
+ }
+
+ if (!err && (actual >= 3))
+ grub_memcpy (termdata->last_report,
+ termdata->current_report,
+ sizeof (termdata->report));
+
+ grub_memcpy (termdata->current_report,
+ termdata->report,
+ sizeof (termdata->report));
+
+ termdata->transfer = grub_usb_bulk_read_background (termdata->usbdev,
+ termdata->endp,
+ sizeof (termdata->report),
+ (char *) termdata->report);
+ if (!termdata->transfer)
+ {
+ grub_printf ("%s failed. Stopped\n", term->name);
+ termdata->dead = 1;
+ }
+
+ termdata->last_key = -1;
+
+ grub_dprintf ("usb_keyboard",
+ "err = %d, actual = %" PRIuGRUB_SIZE
+ " report: 0x%02x 0x%02x 0x%02x 0x%02x"
+ " 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ err, actual,
+ termdata->current_report[0], termdata->current_report[1],
+ termdata->current_report[2], termdata->current_report[3],
+ termdata->current_report[4], termdata->current_report[5],
+ termdata->current_report[6], termdata->current_report[7]);
+
+ if (err || actual < 1)
+ return GRUB_TERM_NO_KEY;
+
+ termdata->status = termdata->current_report[0];
+
+ if (actual < 3)
+ return GRUB_TERM_NO_KEY;
+
+ termdata->index = 2; /* New data received. */
+ termdata->max_index = actual;
+
+ return parse_keycode (termdata);
+}
+
+static int
+grub_usb_keyboard_getkeystatus (struct grub_term_input *term)
+{
+ struct grub_usb_keyboard_data *termdata = term->data;
+
+ return interpret_status (termdata->status) | termdata->mods;
+}
+
+static struct grub_usb_attach_desc attach_hook =
+{
+ .class = GRUB_USB_CLASS_HID,
+ .hook = grub_usb_keyboard_attach
+};
+
+GRUB_MOD_INIT(usb_keyboard)
+{
+ grub_usb_register_attach_hook_class (&attach_hook);
+}
+
+GRUB_MOD_FINI(usb_keyboard)
+{
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE (grub_usb_keyboards); i++)
+ if (grub_usb_keyboards[i].data)
+ {
+ struct grub_usb_keyboard_data *data = grub_usb_keyboards[i].data;
+
+ if (!data)
+ continue;
+
+ if (data->transfer)
+ grub_usb_cancel_transfer (data->transfer);
+
+ grub_term_unregister_input (&grub_usb_keyboards[i]);
+ grub_free ((char *) grub_usb_keyboards[i].name);
+ grub_usb_keyboards[i].name = NULL;
+ grub_free (grub_usb_keyboards[i].data);
+ grub_usb_keyboards[i].data = 0;
+ }
+ grub_usb_unregister_attach_hook_class (&attach_hook);
+}
diff --git a/grub-core/term/xen/console.c b/grub-core/term/xen/console.c
new file mode 100644
index 0000000..a1f15f7
--- /dev/null
+++ b/grub-core/term/xen/console.c
@@ -0,0 +1,122 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/term.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/terminfo.h>
+#include <grub/xen.h>
+
+static int
+readkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ grub_size_t prod, cons;
+ int r;
+ mb ();
+ prod = grub_xen_xcons->in_prod;
+ cons = grub_xen_xcons->in_cons;
+ if (prod <= cons)
+ return -1;
+ r = grub_xen_xcons->in[cons];
+ cons++;
+ mb ();
+ grub_xen_xcons->in_cons = cons;
+ return r;
+}
+
+static int signal_sent = 1;
+
+static void
+refresh (struct grub_term_output *term __attribute__ ((unused)))
+{
+ struct evtchn_send send;
+ send.port = grub_xen_start_page_addr->console.domU.evtchn;
+ grub_xen_event_channel_op (EVTCHNOP_send, &send);
+ signal_sent = 1;
+ while (grub_xen_xcons->out_prod != grub_xen_xcons->out_cons)
+ {
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ }
+}
+
+static void
+put (struct grub_term_output *term __attribute__ ((unused)), const int c)
+{
+ grub_size_t prod, cons;
+
+ while (1)
+ {
+ mb ();
+ prod = grub_xen_xcons->out_prod;
+ cons = grub_xen_xcons->out_cons;
+ if (prod < cons + sizeof (grub_xen_xcons->out))
+ break;
+ if (!signal_sent)
+ refresh (term);
+ grub_xen_sched_op (SCHEDOP_yield, 0);
+ }
+ grub_xen_xcons->out[prod++ & (sizeof (grub_xen_xcons->out) - 1)] = c;
+ mb ();
+ grub_xen_xcons->out_prod = prod;
+ signal_sent = 0;
+}
+
+
+struct grub_terminfo_input_state grub_console_terminfo_input = {
+ .readkey = readkey
+};
+
+struct grub_terminfo_output_state grub_console_terminfo_output = {
+ .put = put,
+ .size = {80, 24}
+};
+
+static struct grub_term_input grub_console_term_input = {
+ .name = "console",
+ .init = 0,
+ .getkey = grub_terminfo_getkey,
+ .data = &grub_console_terminfo_input
+};
+
+static struct grub_term_output grub_console_term_output = {
+ .name = "console",
+ .init = 0,
+ .putchar = grub_terminfo_putchar,
+ .getxy = grub_terminfo_getxy,
+ .getwh = grub_terminfo_getwh,
+ .gotoxy = grub_terminfo_gotoxy,
+ .cls = grub_terminfo_cls,
+ .refresh = refresh,
+ .setcolorstate = grub_terminfo_setcolorstate,
+ .setcursor = grub_terminfo_setcursor,
+ .flags = GRUB_TERM_CODE_TYPE_ASCII,
+ .data = &grub_console_terminfo_output,
+};
+
+
+void
+grub_console_init (void)
+{
+ grub_term_register_input ("console", &grub_console_term_input);
+ grub_term_register_output ("console", &grub_console_term_output);
+
+ grub_terminfo_init ();
+ grub_terminfo_output_register (&grub_console_term_output, "vt100-color");
+}
diff --git a/grub-core/tests/boot/kbsd.init-i386.S b/grub-core/tests/boot/kbsd.init-i386.S
new file mode 100644
index 0000000..72ddb7c
--- /dev/null
+++ b/grub-core/tests/boot/kbsd.init-i386.S
@@ -0,0 +1,107 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef TARGET_NETBSD
+#define SYSCALL_RESET 208
+#elif defined (TARGET_OPENBSD)
+#define SYSCALL_RESET 55
+#else
+#error unknown target
+#endif
+
+#define MODE_RDRW 2
+#define FLAGS_NONE 0
+#define SYSCALL_OPEN 5
+#define SYSCALL_WRITE 4
+#define SYSCALL_EXIT 1
+#define SYSCALL_ARCH 165
+#define SYSCALL_INT 0x80
+#define SYSCALL_ARCH_IOPL 2
+
+#define RESET_NOSYNC 0x4
+#define RESET_HALT 0x8
+#define RESET_POWEROFF 0x800
+
+ .section ".init", "ax"
+ .global start,_start
+start:
+_start:
+ /* open. */
+ movl $SYSCALL_OPEN, %eax
+ pushl $FLAGS_NONE
+ pushl $MODE_RDRW
+ leal device, %ebx
+ pushl %ebx
+ pushl $0
+ int $SYSCALL_INT
+ addl $16, %esp
+ movl %eax, %ecx
+
+ /* write. */
+ movl $SYSCALL_WRITE, %eax
+ pushl $(messageend-message)
+ leal message, %ebx
+ pushl %ebx
+ pushl %ecx
+ pushl $0
+ int $SYSCALL_INT
+ addl $16, %esp
+
+ /* IOPL. */
+ movl $SYSCALL_ARCH, %eax
+ pushl $iopl_arg
+ pushl $SYSCALL_ARCH_IOPL
+ pushl $0
+ int $SYSCALL_INT
+ addl $12, %esp
+
+#include "qemu-shutdown-x86.S"
+
+ /* shutdown. */
+ movl $SYSCALL_RESET, %eax
+ pushl $0
+ pushl $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC)
+ pushl $0
+ int $SYSCALL_INT
+ addl $8, %esp
+
+ /* exit (1). Shouldn't be reached. */
+ movl $SYSCALL_EXIT, %eax
+ pushl $1
+ pushl $0
+ int $SYSCALL_INT
+ .section ".fini", "ax"
+1: jmp 1b
+ .section ".text", "ax"
+1: jmp 1b
+ /* This section is needed for NetBSD to identify the binary. */
+ .section ".note.netbsd.ident", "a"
+ .long 0x7
+ .long 0x4
+ .long 0x1
+ .ascii "NetBSD"
+ .byte 0
+ .data
+device:
+ .ascii "/dev/console"
+ .byte 0
+message:
+ .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+messageend:
+iopl_arg:
+ .long 3
diff --git a/grub-core/tests/boot/kbsd.init-x86_64.S b/grub-core/tests/boot/kbsd.init-x86_64.S
new file mode 100644
index 0000000..7486bc3
--- /dev/null
+++ b/grub-core/tests/boot/kbsd.init-x86_64.S
@@ -0,0 +1,94 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define MODE_RDRW 2
+#define FLAGS_NONE 0
+#define SYSCALL_OPEN 5
+#define SYSCALL_WRITE 4
+#ifdef TARGET_NETBSD
+#define SYSCALL_RESET 208
+#elif defined (TARGET_OPENBSD)
+#define SYSCALL_RESET 55
+#else
+#error unknown target
+#endif
+#define SYSCALL_EXIT 1
+#define SYSCALL_ARCH 165
+#define SYSCALL_INT 0x80
+#define SYSCALL_ARCH_IOPL 2
+
+#define RESET_NOSYNC 0x4
+#define RESET_HALT 0x8
+#define RESET_POWEROFF 0x800
+
+ .section ".init", "ax"
+ .global start,_start
+start:
+_start:
+ /* open. */
+ movq $SYSCALL_OPEN, %rax
+ leaq device, %rdi
+ movq $MODE_RDRW, %rsi
+ movq $FLAGS_NONE, %rdx
+ syscall
+ movq %rax, %rdi
+
+ /* write. */
+ movq $SYSCALL_WRITE, %rax
+ movq $(messageend-message), %rdx
+ leaq message, %rsi
+ syscall
+
+ /* IOPL. */
+ movq $SYSCALL_ARCH, %rax
+ movq $SYSCALL_ARCH_IOPL, %rdi
+ leaq iopl_arg, %rsi
+ syscall
+
+#include "qemu-shutdown-x86.S"
+
+ /* shutdown. */
+ movq $SYSCALL_RESET, %rax
+ movq $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC), %rdi
+ movq $0, %rsi
+ syscall
+
+ /* exit (1). Shouldn't be reached. */
+ movq $SYSCALL_EXIT, %rax
+ movq $1, %rdi
+ syscall
+ .section ".fini", "ax"
+1: jmp 1b
+ .section ".text", "ax"
+1: jmp 1b
+ /* This section is needed for NetBSD to identify the binary. */
+ .section ".note.netbsd.ident", "a"
+ .long 0x7
+ .long 0x4
+ .long 0x1
+ .ascii "NetBSD"
+ .byte 0
+ .data
+device:
+ .ascii "/dev/console"
+ .byte 0
+message:
+ .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+messageend:
+iopl_arg:
+ .long 3
diff --git a/grub-core/tests/boot/kbsd.spec.txt b/grub-core/tests/boot/kbsd.spec.txt
new file mode 100644
index 0000000..af171bc
--- /dev/null
+++ b/grub-core/tests/boot/kbsd.spec.txt
@@ -0,0 +1,3 @@
+. type=dir
+ dev type=dir
+ console type=char device=0 mode=666 gid=0 uid=0
diff --git a/grub-core/tests/boot/kernel-8086.S b/grub-core/tests/boot/kernel-8086.S
new file mode 100644
index 0000000..5ec5368
--- /dev/null
+++ b/grub-core/tests/boot/kernel-8086.S
@@ -0,0 +1,50 @@
+
+ .text
+ .globl _start
+_start:
+base:
+ .code16
+ jmp cont
+
+serialmsg:
+1:
+ movb 0(%si), %bl
+ testb %bl, %bl
+ jz 1f
+ movw $0x3fd, %dx
+2:
+ inb %dx, %al
+ testb $0x20, %al
+ jz 2b
+
+ movw $0x3f8, %dx
+ movb %bl, %al
+ outb %al, %dx
+ incw %si
+ jmp 1b
+1:
+ ret
+
+cont:
+#ifdef TARGET_NTLDR
+ movw $0x2000, %ax
+#elif defined (TARGET_CHAINLOADER)
+ xorw %ax, %ax
+#else
+#error unsupported target
+#endif
+ movw %ax, %ds
+ lea message, %si
+ call serialmsg
+#include "qemu-shutdown-x86.S"
+
+1:
+ hlt
+ jmp 1b
+
+message:
+ .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+ .byte 0
+
+ .org 510
+ .short 0xaa55
diff --git a/grub-core/tests/boot/kernel-i386.S b/grub-core/tests/boot/kernel-i386.S
new file mode 100644
index 0000000..2154d3b
--- /dev/null
+++ b/grub-core/tests/boot/kernel-i386.S
@@ -0,0 +1,72 @@
+#define ASM_FILE 1
+#ifdef TARGET_MULTIBOOT2
+#include <multiboot2.h>
+#elif defined (TARGET_MULTIBOOT)
+#include <multiboot.h>
+#endif
+
+ .text
+ /* Align 32 bits boundary. */
+ .align 8
+
+#ifdef TARGET_MULTIBOOT2
+ /* Multiboot header. */
+multiboot_header:
+ /* magic */
+ .long MULTIBOOT2_HEADER_MAGIC
+ /* ISA: i386 */
+ .long MULTIBOOT_ARCHITECTURE_I386
+ /* Header length. */
+ .long multiboot_header_end - multiboot_header
+ /* checksum */
+ .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header))
+ .short MULTIBOOT_HEADER_TAG_END
+ .short 0
+ .long 8
+multiboot_header_end:
+#elif defined (TARGET_MULTIBOOT)
+ /* Multiboot header. */
+multiboot_header:
+ /* magic */
+ .long MULTIBOOT_HEADER_MAGIC
+ /* flags */
+ .long 0
+ /* checksum */
+ .long -MULTIBOOT_HEADER_MAGIC
+#endif
+
+ .global start
+
+serialmsg:
+1:
+ movb 0(%esi), %bl
+ testb %bl, %bl
+ jz 1f
+ movw $0x3fd, %dx
+2:
+ inb %dx, %al
+ testb $0x20, %al
+ jz 2b
+
+ movw $0x3f8, %dx
+ movb %bl, %al
+ outb %al, %dx
+ incl %esi
+ jmp 1b
+1:
+ ret
+
+ .globl _start
+_start:
+ lea message, %esi
+ call serialmsg
+
+#include "qemu-shutdown-x86.S"
+
+1:
+ hlt
+ jmp 1b
+
+message:
+ .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+ .byte 0
diff --git a/grub-core/tests/boot/kfreebsd-aout.cfg b/grub-core/tests/boot/kfreebsd-aout.cfg
new file mode 100644
index 0000000..31e34b4
--- /dev/null
+++ b/grub-core/tests/boot/kfreebsd-aout.cfg
@@ -0,0 +1,4 @@
+kfreebsd /kfreebsd.aout
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/kfreebsd.cfg b/grub-core/tests/boot/kfreebsd.cfg
new file mode 100644
index 0000000..f28ee79
--- /dev/null
+++ b/grub-core/tests/boot/kfreebsd.cfg
@@ -0,0 +1,8 @@
+kfreebsd /kfreebsd -hv
+kfreebsd_loadenv /kfreebsd_env
+kfreebsd_module /mfsroot.gz type=mfs_root
+set kFreeBSD.hw.hasbrokenint12=1
+fakebios
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/kfreebsd.init-i386.S b/grub-core/tests/boot/kfreebsd.init-i386.S
new file mode 100644
index 0000000..7a4baba
--- /dev/null
+++ b/grub-core/tests/boot/kfreebsd.init-i386.S
@@ -0,0 +1,109 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define MODE_RDRW 2
+#define FLAGS_NONE 0
+#define SYSCALL_OPEN 5
+#define SYSCALL_WRITE 4
+#define SYSCALL_RESET 55
+#define SYSCALL_FSYNC 95
+#define SYSCALL_ARCH 165
+#define SYSCALL_EXIT 1
+#define SYSCALL_ARCH_IOPERM 4
+#define SYSCALL_INT 0x80
+
+#define RESET_NOSYNC 0x4
+#define RESET_HALT 0x8
+#define RESET_POWEROFF 0x4000
+
+ .section ".init", "ax"
+ .global start,_start
+start:
+_start:
+ /* open. */
+ movl $SYSCALL_OPEN, %eax
+ pushl $FLAGS_NONE
+ pushl $MODE_RDRW
+ leal device, %ebx
+ pushl %ebx
+ pushl $0
+ int $SYSCALL_INT
+ addl $16, %esp
+ movl %eax, %ecx
+
+ /* write. */
+ movl $SYSCALL_WRITE, %eax
+ pushl $(messageend-message)
+ leal message, %ebx
+ pushl %ebx
+ pushl %ecx
+ pushl $0
+ int $SYSCALL_INT
+ addl $16, %esp
+
+ /* fsync. */
+ movl $SYSCALL_FSYNC, %eax
+ pushl %ecx
+ pushl $0
+ int $SYSCALL_INT
+ addl $8, %esp
+
+ /* IOPERM. */
+ movl $SYSCALL_ARCH, %eax
+ pushl $ioperm_arg1
+ pushl $SYSCALL_ARCH_IOPERM
+ pushl $0
+ int $SYSCALL_INT
+ addl $12, %esp
+
+ /* IOPERM. */
+ movl $SYSCALL_ARCH, %eax
+ pushl $ioperm_arg2
+ pushl $SYSCALL_ARCH_IOPERM
+ pushl $0
+ int $SYSCALL_INT
+ addl $12, %esp
+
+#include "qemu-shutdown-x86.S"
+
+ /* shutdown. */
+ movl $SYSCALL_RESET, %eax
+ pushl $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC)
+ pushl $0
+ int $SYSCALL_INT
+ addl $8, %esp
+
+ /* exit (1). Shouldn't be reached. */
+ movl $SYSCALL_EXIT, %eax
+ pushl $1
+ pushl $0
+ int $SYSCALL_INT
+device:
+ .ascii "/dev/console"
+ .byte 0
+message:
+ .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+messageend:
+ioperm_arg1:
+ .long 0xcf8
+ .long 8
+ .long 1
+ioperm_arg2:
+ .long 0x7000
+ .long 8
+ .long 1
diff --git a/grub-core/tests/boot/kfreebsd.init-x86_64.S b/grub-core/tests/boot/kfreebsd.init-x86_64.S
new file mode 100644
index 0000000..05e5760
--- /dev/null
+++ b/grub-core/tests/boot/kfreebsd.init-x86_64.S
@@ -0,0 +1,90 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define MODE_RDRW 2
+#define FLAGS_NONE 0
+#define SYSCALL_ARCH 165
+#define SYSCALL_OPEN 5
+#define SYSCALL_WRITE 4
+#define SYSCALL_RESET 55
+#define SYSCALL_EXIT 1
+#define SYSCALL_ARCH_IOPERM 4
+#define SYSCALL_FSYNC 95
+
+#define RESET_NOSYNC 0x4
+#define RESET_HALT 0x8
+#define RESET_POWEROFF 0x4000
+
+ .section ".init", "ax"
+ .global start,_start
+start:
+_start:
+ /* open. */
+ movq $SYSCALL_OPEN, %rax
+ leaq device, %rdi
+ movq $MODE_RDRW, %rsi
+ movq $FLAGS_NONE, %rdx
+ syscall
+ movq %rax, %rdi
+
+ /* write. */
+ leaq message, %rsi
+ movq $SYSCALL_WRITE, %rax
+ movq $(messageend - message), %rdx
+ syscall
+
+ /* fsync. */
+ movq $SYSCALL_FSYNC, %rax
+ syscall
+
+ /* IOPERM. */
+ movq $SYSCALL_ARCH, %rax
+ movq $SYSCALL_ARCH_IOPERM, %rdi
+ leaq ioperm_arg1, %rsi
+ syscall
+
+ movq $SYSCALL_ARCH, %rax
+ movq $SYSCALL_ARCH_IOPERM, %rdi
+ leaq ioperm_arg2, %rsi
+ syscall
+
+#include "qemu-shutdown-x86.S"
+
+ /* shutdown. */
+ movq $SYSCALL_RESET, %rax
+ movq $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC), %rdi
+ syscall
+
+ /* exit (1). Shouldn't be reached. */
+ movq $SYSCALL_EXIT, %rax
+ movq $1, %rdi
+ syscall
+device:
+ .ascii "/dev/console"
+ .byte 0
+message:
+ .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+messageend:
+ioperm_arg1:
+ .long 0xcf8
+ .long 8
+ .long 1
+ioperm_arg2:
+ .long 0x7000
+ .long 8
+ .long 1
diff --git a/grub-core/tests/boot/knetbsd.cfg b/grub-core/tests/boot/knetbsd.cfg
new file mode 100644
index 0000000..f88a846
--- /dev/null
+++ b/grub-core/tests/boot/knetbsd.cfg
@@ -0,0 +1,5 @@
+knetbsd /knetbsd -h
+knetbsd_module_elf /miniroot.gz
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/kopenbsd.cfg b/grub-core/tests/boot/kopenbsd.cfg
new file mode 100644
index 0000000..132bec4
--- /dev/null
+++ b/grub-core/tests/boot/kopenbsd.cfg
@@ -0,0 +1,5 @@
+kopenbsd /kopenbsd -h
+kopenbsd_ramdisk /ramdisk
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/kopenbsdlabel.txt b/grub-core/tests/boot/kopenbsdlabel.txt
new file mode 100644
index 0000000..bb14113
--- /dev/null
+++ b/grub-core/tests/boot/kopenbsdlabel.txt
@@ -0,0 +1,3 @@
+# size offset fstype [fsize bsize bps/cpg]
+ a: 256 0 4.2BSD 0 0 1
+ c: 256 0 unused 0 0 # "raw" part, don't edit
diff --git a/grub-core/tests/boot/linux-ppc.cfg b/grub-core/tests/boot/linux-ppc.cfg
new file mode 100644
index 0000000..3ceabc3
--- /dev/null
+++ b/grub-core/tests/boot/linux-ppc.cfg
@@ -0,0 +1,5 @@
+linux /linux console=ttyPZ1 root=/dev/ram0
+initrd /initrd
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/linux.cfg b/grub-core/tests/boot/linux.cfg
new file mode 100644
index 0000000..f5bf6ac
--- /dev/null
+++ b/grub-core/tests/boot/linux.cfg
@@ -0,0 +1,5 @@
+linux /linux console=ttyS0 root=/dev/ram0
+initrd /initrd
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/linux.init-i386.S b/grub-core/tests/boot/linux.init-i386.S
new file mode 100644
index 0000000..c0983ac
--- /dev/null
+++ b/grub-core/tests/boot/linux.init-i386.S
@@ -0,0 +1,61 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define SYSCALL_WRITE 4
+#define SYSCALL_RESET 88
+#define SYSCALL_IOPL 110
+#define SYSCALL_EXIT 1
+#define SYSCALL_INT 0x80
+
+#define STDOUT 1
+#define SHUTDOWN_MAGIC1 0xfee1dead
+#define SHUTDOWN_MAGIC2 0x28121969
+#define SHUTDOWN_MAGIC3 0x4321fedc
+
+ .text
+ .global start, _start
+_start:
+start:
+ /* write. */
+ movl $SYSCALL_WRITE, %eax
+ movl $STDOUT, %ebx
+ leal message, %ecx
+ movl $(messageend-message), %edx
+ int $SYSCALL_INT
+
+ movl $SYSCALL_IOPL, %eax
+ movl $3, %ebx
+ int $SYSCALL_INT
+
+#include "qemu-shutdown-x86.S"
+
+ /* shutdown. */
+ movl $SYSCALL_RESET, %eax
+ movl $SHUTDOWN_MAGIC1, %ebx
+ movl $SHUTDOWN_MAGIC2, %ecx
+ movl $SHUTDOWN_MAGIC3, %edx
+ int $SYSCALL_INT
+
+ /* exit (1). Shouldn't be reached. */
+ movl $SYSCALL_EXIT, %eax
+ movl $1, %ebx
+ int $SYSCALL_INT
+ .data
+message:
+ .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+messageend:
diff --git a/grub-core/tests/boot/linux.init-mips.S b/grub-core/tests/boot/linux.init-mips.S
new file mode 100644
index 0000000..5ef4c37
--- /dev/null
+++ b/grub-core/tests/boot/linux.init-mips.S
@@ -0,0 +1,61 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define SYSCALL_WRITE 4004
+#define SYSCALL_RESET 4088
+#define SYSCALL_EXIT 4001
+
+#define STDOUT 1
+#define SHUTDOWN_MAGIC1 0xfee1dead
+#define SHUTDOWN_MAGIC2 0x28121969
+#ifdef REBOOT
+#define SHUTDOWN_MAGIC3 0x01234567
+#else
+#define SHUTDOWN_MAGIC3 0x4321fedc
+#endif
+ .text
+ .global start, _start, __start
+__start:
+_start:
+start:
+ /* write. */
+ li $v0, SYSCALL_WRITE
+ li $a0, STDOUT
+ lui $a1, %hi(message)
+ addiu $a1, %lo(message)
+ lui $a2, %hi(messageend)
+ addiu $a2, %lo(messageend)
+ subu $a2, $a2, $a1
+ syscall
+
+ /* shutdown. */
+ li $v0, SYSCALL_RESET
+ li $a0, SHUTDOWN_MAGIC1
+ li $a1, SHUTDOWN_MAGIC2
+ li $a2, SHUTDOWN_MAGIC3
+ syscall
+
+ /* exit(1). Shouldn't be reached. */
+ li $v0, SYSCALL_EXIT
+ li $a0, 1
+ syscall
+
+ .data
+message:
+ .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+messageend:
diff --git a/grub-core/tests/boot/linux.init-ppc.S b/grub-core/tests/boot/linux.init-ppc.S
new file mode 100644
index 0000000..8c9aa44
--- /dev/null
+++ b/grub-core/tests/boot/linux.init-ppc.S
@@ -0,0 +1,61 @@
+/*
+ * 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/>.
+ */
+
+#define SYSCALL_WRITE 4
+#define SYSCALL_RESET 88
+#define SYSCALL_EXIT 1
+
+#define STDOUT 1
+#define SHUTDOWN_MAGIC1 0xfee1dead
+#define SHUTDOWN_MAGIC2 0x28121969
+#define SHUTDOWN_MAGIC3 0x4321fedc
+
+ .text
+ .global start, _start, __start
+__start:
+_start:
+start:
+ /* write. */
+ li %r0, SYSCALL_WRITE
+ li %r3, STDOUT
+ lis %r4, message@h
+ ori %r4, %r4, message@l
+ lis %r5, messageend@h
+ ori %r5, %r5, messageend@l
+ sub %r5, %r5, %r4
+ sc
+
+ /* shutdown. */
+ li %r0, SYSCALL_RESET
+ lis %r3, SHUTDOWN_MAGIC1@h
+ ori %r3, %r3, SHUTDOWN_MAGIC1@l
+ lis %r4, SHUTDOWN_MAGIC2@h
+ ori %r4, %r4, SHUTDOWN_MAGIC2@l
+ lis %r5, SHUTDOWN_MAGIC3@h
+ ori %r5, %r5, SHUTDOWN_MAGIC3@l
+ sc
+
+ /* exit(1). Shouldn't be reached. */
+ li %r0, SYSCALL_EXIT
+ li %r3, 1
+ sc
+
+ .data
+message:
+ .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+messageend:
diff --git a/grub-core/tests/boot/linux.init-x86_64.S b/grub-core/tests/boot/linux.init-x86_64.S
new file mode 100644
index 0000000..90bdcc3
--- /dev/null
+++ b/grub-core/tests/boot/linux.init-x86_64.S
@@ -0,0 +1,60 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define SYSCALL_WRITE 1
+#define SYSCALL_RESET 169
+#define SYSCALL_IOPL 172
+#define SYSCALL_EXIT 60
+
+#define STDOUT 1
+#define SHUTDOWN_MAGIC1 0xfee1dead
+#define SHUTDOWN_MAGIC2 0x28121969
+#define SHUTDOWN_MAGIC3 0x4321fedc
+
+ .text
+ .global start, _start
+_start:
+start:
+ /* write. */
+ movq $SYSCALL_WRITE, %rax
+ movq $STDOUT, %rdi
+ leaq message, %rsi
+ movq $(messageend-message), %rdx
+ syscall
+
+ movq $SYSCALL_IOPL, %rax
+ movq $3, %rdi
+ syscall
+
+#include "qemu-shutdown-x86.S"
+
+ /* shutdown. */
+ movq $SYSCALL_RESET, %rax
+ movq $SHUTDOWN_MAGIC1, %rdi
+ movq $SHUTDOWN_MAGIC2, %rsi
+ movq $SHUTDOWN_MAGIC3, %rdx
+ syscall
+
+ /* exit(1). Shouldn't be reached. */
+ movq $SYSCALL_EXIT, %rax
+ movq $1, %rdi
+ syscall
+ .data
+message:
+ .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+messageend:
diff --git a/grub-core/tests/boot/linux16.cfg b/grub-core/tests/boot/linux16.cfg
new file mode 100644
index 0000000..d7fbf96
--- /dev/null
+++ b/grub-core/tests/boot/linux16.cfg
@@ -0,0 +1,5 @@
+linux16 /linux console=ttyS0 root=/dev/ram0
+initrd16 /initrd
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/multiboot.cfg b/grub-core/tests/boot/multiboot.cfg
new file mode 100644
index 0000000..0942ec6
--- /dev/null
+++ b/grub-core/tests/boot/multiboot.cfg
@@ -0,0 +1,4 @@
+multiboot /multiboot.elf
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/multiboot2.cfg b/grub-core/tests/boot/multiboot2.cfg
new file mode 100644
index 0000000..2bec9e6
--- /dev/null
+++ b/grub-core/tests/boot/multiboot2.cfg
@@ -0,0 +1,4 @@
+multiboot2 /multiboot2.elf
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/ntldr.cfg b/grub-core/tests/boot/ntldr.cfg
new file mode 100644
index 0000000..cd438a4
--- /dev/null
+++ b/grub-core/tests/boot/ntldr.cfg
@@ -0,0 +1,4 @@
+ntldr /ntldr.bin
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/pc-chainloader.cfg b/grub-core/tests/boot/pc-chainloader.cfg
new file mode 100644
index 0000000..1e80a5b
--- /dev/null
+++ b/grub-core/tests/boot/pc-chainloader.cfg
@@ -0,0 +1,4 @@
+chainloader /pc-chainloader.bin
+boot
+# Shouln't happen
+halt
diff --git a/grub-core/tests/boot/qemu-shutdown-x86.S b/grub-core/tests/boot/qemu-shutdown-x86.S
new file mode 100644
index 0000000..e37f5df
--- /dev/null
+++ b/grub-core/tests/boot/qemu-shutdown-x86.S
@@ -0,0 +1,17 @@
+ movl $0x80000b80, %eax
+ movw $0xcf8, %dx
+ outl %eax, %dx
+ movw $0xcfc, %dx
+ inb %dx, %al
+ orb $1, %al
+ outb %al, %dx
+
+ movl $0x80000b40, %eax
+ movw $0xcf8, %dx
+ outl %eax, %dx
+ movl $0x7001, %eax
+ movw $0xcfc, %dx
+ outl %eax, %dx
+ movw $0x2000, %ax
+ movw $0x7004, %dx
+ outw %ax, %dx
diff --git a/grub-core/tests/bswap_test.c b/grub-core/tests/bswap_test.c
new file mode 100644
index 0000000..4eb3a98
--- /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
new file mode 100644
index 0000000..8273bd1
--- /dev/null
+++ b/grub-core/tests/checksums.h
@@ -0,0 +1,129 @@
+ { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc69be699, 0xc69be699, 0xe17fc97c, 0xe17fc97c, 0xc2512486, 0xc2512486, 0x20260761, 0x20260761, 0xe3485349, 0xe3485349, 0x6020b4d9, 0x6020b4d9, 0x1605db98, 0x1605db98, 0xdca51b58, 0xdca51b58, 0xf3d66441, 0xf3d66441, 0x18cb7ce2, 0x18cb7ce2, 0x23b616d9, 0x23b616d9, 0xa1bf5dbf, 0xa1bf5dbf, 0x5e4a8b3d, 0x5e4a8b3d, 0x9933b3d8, 0x9933b3d8, 0xce7be2de, 0xce7be2de, 0x62531729, 0x62531729, 0xc39d3788, 0xc39d3788, 0xf7aee2fe, 0xf7aee2fe, 0xc66f4903, 0xc66f4903, 0x536c922f, 0x536c922f, 0xcb231652, 0x4ae07b67, 0x146816d5, 0x146816d5, }, 45 },
+ { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x29d0cfb7, 0x29d0cfb7, 0x4d57ad88, 0x4d57ad88, 0xaf7591cb, 0xaf7591cb, 0xb88e3c0, 0xb88e3c0, 0x5d55a031, 0x5d55a031, 0x4363bcff, 0x4363bcff, 0xe1142833, 0xe1142833, 0x9578c80d, 0x9578c80d, 0xff1f5174, 0xff1f5174, 0x6828d47, 0x6828d47, 0x2a849ae3, 0x2a849ae3, 0x27a811d9, 0x27a811d9, 0x6c42e1cb, 0x6c42e1cb, 0x5bba61f5, 0x5bba61f5, 0xc02ab705, 0xc02ab705, 0xeb3e0e05, 0xeb3e0e05, 0x6f4ce3c, 0x6f4ce3c, 0x2075c50e, 0x2075c50e, 0x54ac7fba, 0x54ac7fba, 0x335d1c21, 0x335d1c21, 0xf923fbd1, 0x1b489d4d, 0x1253eb5e, 0x1253eb5e, }, 45 },
+ { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6ff92a98, 0x6ff92a98, 0xbd8264b3, 0xbd8264b3, 0x5c50282c, 0x5c50282c, 0xd18d6a5a, 0xd18d6a5a, 0x99cea139, 0x99cea139, 0x2590c545, 0x2590c545, 0x55c86045, 0x55c86045, 0xad53ef1e, 0xad53ef1e, 0x5b44a23a, 0x5b44a23a, 0xa255f863, 0xa255f863, 0x85b0bdca, 0x85b0bdca, 0x4220ee1f, 0x4220ee1f, 0xeb991a9f, 0xeb991a9f, 0x86f366dd, 0x86f366dd, 0xfa176b7d, 0xfa176b7d, 0xd7384ca9, 0xd7384ca9, 0xceebf5c1, 0xceebf5c1, 0xae62b268, 0xae62b268, 0x6e89bbd6, 0x6e89bbd6, 0x3fe07c8e, 0x3fe07c8e, 0xee5358fe, 0x162d1a8a, 0x876f8d10, 0x876f8d10, }, 45 },
+ { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb96afaea, 0xb96afaea, 0xaa16ab1e, 0xaa16ab1e, 0x51ff382, 0x51ff382, 0xec74f127, 0xec74f127, 0xde4bca99, 0xde4bca99, 0x8ef3e8a5, 0x8ef3e8a5, 0x2daeb0b4, 0x2daeb0b4, 0x7cf5e243, 0x7cf5e243, 0x11fd57c6, 0x11fd57c6, 0x140723af, 0x140723af, 0x2bd93833, 0x2bd93833, 0xd731f4ac, 0xd731f4ac, 0x5fcd7114, 0x5fcd7114, 0xd1fea24a, 0xd1fea24a, 0x4083d53a, 0x4083d53a, 0x2e372605, 0x2e372605, 0x8e6316a7, 0x8e6316a7, 0x283ef6cc, 0x283ef6cc, 0x20cee9de, 0x20cee9de, 0xad6fa187, 0xad6fa187, 0xd691f438, 0xf3257e63, 0x4786ba7, 0x4786ba7, }, 45 },
+ { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x48acf1bf, 0x48acf1bf, 0xb8777469, 0xb8777469, 0xad2fad44, 0xad2fad44, 0xa415ac59, 0xa415ac59, 0x5a7bfb26, 0x5a7bfb26, 0xccb6016, 0xccb6016, 0x77a80cb3, 0x77a80cb3, 0x2034c102, 0x2034c102, 0x444b4ccd, 0x444b4ccd, 0xe6c31bea, 0xe6c31bea, 0x8408036e, 0x8408036e, 0x9e7c556f, 0x9e7c556f, 0x445dc388, 0x445dc388, 0x94b3f850, 0x94b3f850, 0xf6f15341, 0xf6f15341, 0xcb939b5f, 0xcb939b5f, 0xbe88067d, 0xbe88067d, 0x1efc4734, 0x1efc4734, 0x7f5dfca8, 0x7f5dfca8, 0xb7b10eb9, 0xb7b10eb9, 0xb94cb441, 0x9571329, 0x8a26912b, 0x8a26912b, }, 45 },
+ { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc508d04e, 0xc508d04e, 0x6dbccbfe, 0x6dbccbfe, 0xbf06ff60, 0xbf06ff60, 0xbc5ab06, 0xbc5ab06, 0x97eeab3c, 0x97eeab3c, 0x62663589, 0x62663589, 0xb03e21e2, 0xb03e21e2, 0xea196bb6, 0xea196bb6, 0x672c16c4, 0x672c16c4, 0xefbca2cd, 0xefbca2cd, 0x1af5b410, 0x1af5b410, 0xc7a80569, 0xc7a80569, 0x4926a16, 0x4926a16, 0xee29c99c, 0xee29c99c, 0xffb15985, 0xffb15985, 0x4f608e46, 0x4f608e46, 0x3e450fd2, 0x3e450fd2, 0xac45215f, 0xac45215f, 0x789b0ce7, 0x789b0ce7, 0x4cedfe22, 0x4cedfe22, 0xa005588c, 0x701da05c, 0x6f25cec1, 0x6f25cec1, }, 45 },
+ { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x29e7a7f, 0x29e7a7f, 0xbd221052, 0xbd221052, 0x3b18b64, 0x3b18b64, 0x7f1e8462, 0x7f1e8462, 0xf28d5124, 0xf28d5124, 0xc336f170, 0xc336f170, 0xfe3bf988, 0xfe3bf988, 0x7bf89e05, 0x7bf89e05, 0x7857a3f8, 0x7857a3f8, 0x272c1a36, 0x272c1a36, 0xe8adb445, 0xe8adb445, 0x70cfe280, 0x70cfe280, 0x4f2b6120, 0x4f2b6120, 0xbaf5caa5, 0xbaf5caa5, 0x4b6bcab2, 0x4b6bcab2, 0x2bef7b92, 0x2bef7b92, 0x17b381dc, 0x17b381dc, 0x884c9c35, 0x884c9c35, 0x2f9eb909, 0x2f9eb909, 0xa811b3af, 0xa811b3af, 0x4c39478f, 0x5a72c3ab, 0x8071678a, 0x8071678a, }, 45 },
+ { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd9f04953, 0xbf3fa5d0, 0xd9f04953, 0x9a068414, 0x59c36f00, 0x59c36f00, 0x620c0067, 0x620c0067, 0x620c0067, 0x1c8c6d01, 0x1c8c6d01, 0x1c8c6d01, 0xc3269013, 0xc3269013, 0xc3269013, 0x59c36f00, 0x9a068414, 0x9a068414, 0x59c36f00, }, 20 },
+ { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x9254157f, 0x367e92c7, 0x9254157f, 0xbc519000, 0xaa4593fe, 0xaa4593fe, 0xa8a596c8, 0xa8a596c8, 0xa8a596c8, 0xe509baf, 0xe509baf, 0xe509baf, 0x16f0dc06, 0x16f0dc06, 0x16f0dc06, 0xaa4593fe, 0xbc519000, 0xbc519000, 0xaa4593fe, }, 20 },
+ { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x354b1976, 0x8fc746ae, 0x354b1976, 0x685c74f2, 0xc9cbf769, 0xc9cbf769, 0x3ce35e1d, 0x3ce35e1d, 0x3ce35e1d, 0xc23b9fd1, 0xc23b9fd1, 0xc23b9fd1, 0x5b18528e, 0x5b18528e, 0x5b18528e, 0xc9cbf769, 0x685c74f2, 0x685c74f2, 0xc9cbf769, }, 20 },
+ { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1c9ec014, 0xaf3ec923, 0x1c9ec014, 0x43f5296, 0x9813a416, 0x9813a416, 0x43fda3fa, 0x43fda3fa, 0x43fda3fa, 0xd22625c9, 0xd22625c9, 0xd22625c9, 0x76a62c0a, 0x76a62c0a, 0x76a62c0a, 0x9813a416, 0x43f5296, 0x43f5296, 0x9813a416, }, 20 },
+ { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa704f7ea, 0xb7f2ec8b, 0xa704f7ea, 0xb279bf59, 0x5fcf013d, 0x5fcf013d, 0xf3582c48, 0xf3582c48, 0xf3582c48, 0x2148343e, 0x2148343e, 0x2148343e, 0x9c719024, 0x9c719024, 0x9c719024, 0x5fcf013d, 0xb279bf59, 0xb279bf59, 0x5fcf013d, }, 20 },
+ { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf293ce36, 0xa6eb6ae8, 0xf293ce36, 0xcd87647e, 0xdd28f52b, 0xdd28f52b, 0xb3c7ef80, 0xb3c7ef80, 0xb3c7ef80, 0x92fb1664, 0x92fb1664, 0x92fb1664, 0xd15b5e2e, 0xd15b5e2e, 0xd15b5e2e, 0xdd28f52b, 0xcd87647e, 0xcd87647e, 0xdd28f52b, }, 20 },
+ { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x31e75bd7, 0x9a768c6a, 0x31e75bd7, 0xa8fc31a6, 0x43d1f34, 0x43d1f34, 0xa0717008, 0xa0717008, 0xa0717008, 0xdf7bd9a0, 0xdf7bd9a0, 0xdf7bd9a0, 0x8e5a9312, 0x8e5a9312, 0x8e5a9312, 0x43d1f34, 0xa8fc31a6, 0xa8fc31a6, 0x43d1f34, }, 20 },
+ { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1ce7bd78, 0x682580f5, 0x1ce7bd78, 0x490ad6fe, 0x9a2e0d26, 0x64eb71ba, 0x64eb71ba, 0x64eb71ba, 0x3833877a, 0x3833877a, 0x3833877a, 0xcfc14f0a, 0xcfc14f0a, 0xcfc14f0a, 0x59c36f00, 0x490ad6fe, 0x490ad6fe, }, 18 },
+ { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2b6ff87d, 0x63ce2ca2, 0x2b6ff87d, 0xf00f044e, 0xa9d58ccd, 0xe2c46577, 0xe2c46577, 0xe2c46577, 0xb79bcf7d, 0xb79bcf7d, 0xb79bcf7d, 0xbc30ed71, 0xbc30ed71, 0xbc30ed71, 0xaa4593fe, 0xf00f044e, 0xf00f044e, }, 18 },
+ { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe61cadba, 0x9880b727, 0xe61cadba, 0xdf5f2fc0, 0x5411be8b, 0x4449774e, 0x4449774e, 0x4449774e, 0x3bf7d1da, 0x3bf7d1da, 0x3bf7d1da, 0xd2ddee01, 0xd2ddee01, 0xd2ddee01, 0xc9cbf769, 0xdf5f2fc0, 0xdf5f2fc0, }, 18 },
+ { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xbe54acf7, 0x9b4ce770, 0xbe54acf7, 0x3111489, 0x740d78cf, 0x314c4c59, 0x314c4c59, 0x314c4c59, 0xdae9a625, 0xdae9a625, 0xdae9a625, 0xcbf8af57, 0xcbf8af57, 0xcbf8af57, 0x1c3742c9, 0x3111489, 0x3111489, }, 18 },
+ { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xee571de5, 0x568aaeff, 0xee571de5, 0xe328b7a7, 0xbcda144c, 0xf56e1b60, 0xf56e1b60, 0xf56e1b60, 0x9a27c771, 0x9a27c771, 0x9a27c771, 0xd6d05397, 0xd6d05397, 0xd6d05397, 0xcc5a7bed, 0xe328b7a7, 0xe328b7a7, }, 18 },
+ { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x1db9877c, 0x7e1afeae, 0x1db9877c, 0x8fc0c430, 0x5d55a141, 0x96f335c6, 0x96f335c6, 0x96f335c6, 0x504171d8, 0x504171d8, 0x504171d8, 0x69f71c0, 0x69f71c0, 0x69f71c0, 0xef4a3312, 0x8fc0c430, 0x8fc0c430, }, 18 },
+ { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x151819bd, 0xea8d4865, 0x151819bd, 0x11d75fd2, 0x6d6bb4bc, 0x650ccd09, 0x650ccd09, 0x650ccd09, 0xe4ff3bd8, 0xe4ff3bd8, 0xe4ff3bd8, 0xc5308b73, 0xc5308b73, 0xc5308b73, 0x54e48d80, 0x11d75fd2, 0x11d75fd2, }, 18 },
+ { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd0b06c3d, 0xde50d1a5, 0xd0b06c3d, 0x9346a17a, 0x59c36f00, 0x59c36f00, 0xacff5d47, 0xacff5d47, 0xacff5d47, 0xd27f3021, 0xd27f3021, 0xd27f3021, 0xdd5cd33, 0xdd5cd33, 0xdd5cd33, 0x59c36f00, 0x9346a17a, 0x9346a17a, 0x59c36f00, }, 20 },
+ { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf32d50c1, 0x730a7ed, 0xf32d50c1, 0xdd28d5be, 0xaa4593fe, 0xaa4593fe, 0xba8a2d4c, 0xba8a2d4c, 0xba8a2d4c, 0x1c7f202b, 0x1c7f202b, 0x1c7f202b, 0x4df6782, 0x4df6782, 0x4df6782, 0xaa4593fe, 0xdd28d5be, 0xdd28d5be, 0xaa4593fe, }, 20 },
+ { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x711a4ac1, 0x6396f14c, 0x711a4ac1, 0x2c0d2745, 0xc9cbf769, 0xc9cbf769, 0x6b6ccbb0, 0x6b6ccbb0, 0x6b6ccbb0, 0x95b40a7c, 0x95b40a7c, 0x95b40a7c, 0xc97c723, 0xc97c723, 0xc97c723, 0xc9cbf769, 0x2c0d2745, 0x2c0d2745, 0xc9cbf769, }, 20 },
+ { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x29baad6a, 0x348b1f2b, 0x29baad6a, 0x311b3fe8, 0x9813a416, 0x9813a416, 0xe8e982cc, 0xe8e982cc, 0xe8e982cc, 0x793204ff, 0x793204ff, 0x793204ff, 0xddb20d3c, 0xddb20d3c, 0xddb20d3c, 0x9813a416, 0x311b3fe8, 0x311b3fe8, 0x9813a416, }, 20 },
+ { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf834b3bb, 0x3951bd1a, 0xf834b3bb, 0xed49fb08, 0x5fcf013d, 0x5fcf013d, 0x5aefa2a7, 0x5aefa2a7, 0x5aefa2a7, 0x88ffbad1, 0x88ffbad1, 0x88ffbad1, 0x35c61ecb, 0x35c61ecb, 0x35c61ecb, 0x5fcf013d, 0xed49fb08, 0xed49fb08, 0x5fcf013d, }, 20 },
+ { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7e9a7a47, 0xb1651b5a, 0x7e9a7a47, 0x418ed00f, 0xdd28f52b, 0xdd28f52b, 0x83f9db69, 0x83f9db69, 0x83f9db69, 0xa2c5228d, 0xa2c5228d, 0xa2c5228d, 0xe1656ac7, 0xe1656ac7, 0xe1656ac7, 0xdd28f52b, 0x418ed00f, 0x418ed00f, 0xdd28f52b, }, 20 },
+ { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc6a0340, 0x7dd5855c, 0xc6a0340, 0x95716931, 0x43d1f34, 0x43d1f34, 0x5f1c24c0, 0x5f1c24c0, 0x5f1c24c0, 0x20168d68, 0x20168d68, 0x20168d68, 0x7137c7da, 0x7137c7da, 0x7137c7da, 0x43d1f34, 0x95716931, 0x95716931, 0x43d1f34, }, 20 },
+ { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd3798aaa, 0xab48784c, 0xd3798aaa, 0x908f47ed, 0x59c36f00, 0x59c36f00, 0x1688ec7c, 0x1688ec7c, 0x1688ec7c, 0x6808811a, 0x6808811a, 0x6808811a, 0xb7a27c08, 0xb7a27c08, 0xb7a27c08, 0x59c36f00, 0x908f47ed, 0x908f47ed, 0x59c36f00, }, 20 },
+ { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xc30d9d2a, 0x60b9ed26, 0xc30d9d2a, 0xed081855, 0xaa4593fe, 0xaa4593fe, 0x3eba2192, 0x3eba2192, 0x3eba2192, 0x984f2cf5, 0x984f2cf5, 0x984f2cf5, 0x80ef6b5c, 0x80ef6b5c, 0x80ef6b5c, 0xaa4593fe, 0xed081855, 0xed081855, 0xaa4593fe, }, 20 },
+ { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe469e6af, 0x46ac2012, 0xe469e6af, 0xb97e8b2b, 0xc9cbf769, 0xc9cbf769, 0x60f0d993, 0x60f0d993, 0x60f0d993, 0x9e28185f, 0x9e28185f, 0x9e28185f, 0x70bd500, 0x70bd500, 0x70bd500, 0xc9cbf769, 0xb97e8b2b, 0xb97e8b2b, 0xc9cbf769, }, 20 },
+ { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8538d2ef, 0xab143284, 0x8538d2ef, 0x9d99406d, 0x9813a416, 0x9813a416, 0x7e8326ec, 0x7e8326ec, 0x7e8326ec, 0xef58a0df, 0xef58a0df, 0xef58a0df, 0x4bd8a91c, 0x4bd8a91c, 0x4bd8a91c, 0x9813a416, 0x9d99406d, 0x9d99406d, 0x9813a416, }, 20 },
+ { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x8115198c, 0x1abdaee1, 0x8115198c, 0x9468513f, 0x5fcf013d, 0x5fcf013d, 0xa5e86484, 0xa5e86484, 0xa5e86484, 0x77f87cf2, 0x77f87cf2, 0x77f87cf2, 0xcac1d8e8, 0xcac1d8e8, 0xcac1d8e8, 0x5fcf013d, 0x9468513f, 0x9468513f, 0x5fcf013d, }, 20 },
+ { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xea03b805, 0x74148290, 0xea03b805, 0xd517124d, 0xdd28f52b, 0xdd28f52b, 0x8f6eee40, 0x8f6eee40, 0x8f6eee40, 0xae5217a4, 0xae5217a4, 0xae5217a4, 0xedf25fee, 0xedf25fee, 0xedf25fee, 0xdd28f52b, 0xd517124d, 0xd517124d, 0xdd28f52b, }, 20 },
+ { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa044490f, 0xe23458db, 0xa044490f, 0x395f237e, 0x43d1f34, 0x43d1f34, 0xe1ca82c2, 0xe1ca82c2, 0xe1ca82c2, 0x9ec02b6a, 0x9ec02b6a, 0x9ec02b6a, 0xcfe161d8, 0xcfe161d8, 0xcfe161d8, 0x43d1f34, 0x395f237e, 0x395f237e, 0x43d1f34, }, 20 },
+ { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xf3259b30, 0xf1f01411, 0xf3259b30, 0xb0d35677, 0x59c36f00, 0x59c36f00, 0x97895f8e, 0x97895f8e, 0x97895f8e, 0xe90932e8, 0xe90932e8, 0xe90932e8, 0x36a3cffa, 0x36a3cffa, 0x36a3cffa, 0x59c36f00, 0xb0d35677, 0xb0d35677, 0x59c36f00, }, 20 },
+ { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x53a43759, 0xe0f26bfa, 0x53a43759, 0x7da1b226, 0xaa4593fe, 0xaa4593fe, 0xbf482a4e, 0xbf482a4e, 0xbf482a4e, 0x19bd2729, 0x19bd2729, 0x19bd2729, 0x11d6080, 0x11d6080, 0x11d6080, 0xaa4593fe, 0x7da1b226, 0x7da1b226, 0xaa4593fe, }, 20 },
+ { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd7ff8d53, 0x665b2728, 0xd7ff8d53, 0x8ae8e0d7, 0xc9cbf769, 0xc9cbf769, 0x5a693e73, 0x5a693e73, 0x5a693e73, 0xa4b1ffbf, 0xa4b1ffbf, 0xa4b1ffbf, 0x3d9232e0, 0x3d9232e0, 0x3d9232e0, 0xc9cbf769, 0x8ae8e0d7, 0x8ae8e0d7, 0xc9cbf769, }, 20 },
+ { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x99fddcbe, 0x6d5c8895, 0x99fddcbe, 0x815c4e3c, 0x9813a416, 0x9813a416, 0x9bcf9821, 0x9bcf9821, 0x9bcf9821, 0xa141e12, 0xa141e12, 0xa141e12, 0xae9417d1, 0xae9417d1, 0xae9417d1, 0x9813a416, 0x815c4e3c, 0x815c4e3c, 0x9813a416, }, 20 },
+ { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5797846, 0x25a6ad40, 0x5797846, 0x100430f5, 0x5fcf013d, 0x5fcf013d, 0xddc86daf, 0xddc86daf, 0xddc86daf, 0xfd875d9, 0xfd875d9, 0xfd875d9, 0xb2e1d1c3, 0xb2e1d1c3, 0xb2e1d1c3, 0x5fcf013d, 0x100430f5, 0x100430f5, 0x5fcf013d, }, 20 },
+ { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x30653ae8, 0x7fcd187, 0x30653ae8, 0xf7190a0, 0xdd28f52b, 0xdd28f52b, 0x24c3d325, 0x24c3d325, 0x24c3d325, 0x5ff2ac1, 0x5ff2ac1, 0x5ff2ac1, 0x465f628b, 0x465f628b, 0x465f628b, 0xdd28f52b, 0xf7190a0, 0xf7190a0, 0xdd28f52b, }, 20 },
+ { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x3bd91638, 0x1d74dd4a, 0x3bd91638, 0xa2c27c49, 0x43d1f34, 0x43d1f34, 0x53d1ad3d, 0x53d1ad3d, 0x53d1ad3d, 0x2cdb0495, 0x2cdb0495, 0x2cdb0495, 0x7dfa4e27, 0x7dfa4e27, 0x7dfa4e27, 0x43d1f34, 0xa2c27c49, 0xa2c27c49, 0x43d1f34, }, 20 },
+ { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbe2c351a, 0x2692720, 0xbe2c351a, 0xfddaf85d, 0x59c36f00, 0x59c36f00, 0x1b2e2301, 0x1b2e2301, 0x1b2e2301, 0x65ae4e67, 0x65ae4e67, 0x65ae4e67, 0xba04b375, 0xba04b375, 0xba04b375, 0x59c36f00, 0xfddaf85d, 0xfddaf85d, 0x59c36f00, }, 20 },
+ { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1eca82e1, 0xe8fa59cc, 0x1eca82e1, 0x30cf079e, 0xaa4593fe, 0xaa4593fe, 0xaf27ddc5, 0xaf27ddc5, 0xaf27ddc5, 0x9d2d0a2, 0x9d2d0a2, 0x9d2d0a2, 0x1172970b, 0x1172970b, 0x1172970b, 0xaa4593fe, 0x30cf079e, 0x30cf079e, 0xaa4593fe, }, 20 },
+ { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa9ccd435, 0x1ac646eb, 0xa9ccd435, 0xf4dbb9b1, 0xc9cbf769, 0xc9cbf769, 0x86d69aa0, 0x86d69aa0, 0x86d69aa0, 0x780e5b6c, 0x780e5b6c, 0x780e5b6c, 0xe12d9633, 0xe12d9633, 0xe12d9633, 0xc9cbf769, 0xf4dbb9b1, 0xf4dbb9b1, 0xc9cbf769, }, 20 },
+ { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf96d568, 0x7ad05c1b, 0xf96d568, 0x173747ea, 0x9813a416, 0x9813a416, 0xacf9792a, 0xacf9792a, 0xacf9792a, 0x3d22ff19, 0x3d22ff19, 0x3d22ff19, 0x99a2f6da, 0x99a2f6da, 0x99a2f6da, 0x9813a416, 0x173747ea, 0x173747ea, 0x9813a416, }, 20 },
+ { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa0dc6b9c, 0xc2761148, 0xa0dc6b9c, 0xb5a1232f, 0x5fcf013d, 0x5fcf013d, 0x4e05748b, 0x4e05748b, 0x4e05748b, 0x9c156cfd, 0x9c156cfd, 0x9c156cfd, 0x212cc8e7, 0x212cc8e7, 0x212cc8e7, 0x5fcf013d, 0xb5a1232f, 0xb5a1232f, 0x5fcf013d, }, 20 },
+ { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcd722f7d, 0xe4df8d6b, 0xcd722f7d, 0xf2668535, 0xdd28f52b, 0xdd28f52b, 0xbdbb8019, 0xbdbb8019, 0xbdbb8019, 0x9c8779fd, 0x9c8779fd, 0x9c8779fd, 0xdf2731b7, 0xdf2731b7, 0xdf2731b7, 0xdd28f52b, 0xf2668535, 0xf2668535, 0xdd28f52b, }, 20 },
+ { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa6c99d2f, 0x1de04317, 0xa6c99d2f, 0x3fd2f75e, 0x43d1f34, 0x43d1f34, 0x3f85b7d3, 0x3f85b7d3, 0x3f85b7d3, 0x408f1e7b, 0x408f1e7b, 0x408f1e7b, 0x11ae54c9, 0x11ae54c9, 0x11ae54c9, 0x43d1f34, 0x3fd2f75e, 0x3fd2f75e, 0x43d1f34, }, 20 },
+ { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1e35b709, 0x2683bf92, 0x1e35b709, 0x5dc37a4e, 0x59c36f00, 0x59c36f00, 0xd697967f, 0xd697967f, 0xd697967f, 0xa817fb19, 0xa817fb19, 0xa817fb19, 0x77bd060b, 0x77bd060b, 0x77bd060b, 0x59c36f00, 0x5dc37a4e, 0x5dc37a4e, 0x59c36f00, }, 20 },
+ { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x53ff7735, 0x8cbf197c, 0x53ff7735, 0x7dfaf24a, 0xaa4593fe, 0xaa4593fe, 0x389a922, 0x389a922, 0x389a922, 0xa57ca445, 0xa57ca445, 0xa57ca445, 0xbddce3ec, 0xbddce3ec, 0xbddce3ec, 0xaa4593fe, 0x7dfaf24a, 0x7dfaf24a, 0xaa4593fe, }, 20 },
+ { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5217c47d, 0x7c8ae63e, 0x5217c47d, 0xf00a9f9, 0xc9cbf769, 0xc9cbf769, 0x3995409, 0x3995409, 0x3995409, 0xfd4195c5, 0xfd4195c5, 0xfd4195c5, 0x6462589a, 0x6462589a, 0x6462589a, 0xc9cbf769, 0xf00a9f9, 0xf00a9f9, 0xc9cbf769, }, 20 },
+ { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x45b67706, 0x375fb5db, 0x45b67706, 0x5d17e584, 0x9813a416, 0x9813a416, 0x8195719b, 0x8195719b, 0x8195719b, 0x104ef7a8, 0x104ef7a8, 0x104ef7a8, 0xb4cefe6b, 0xb4cefe6b, 0xb4cefe6b, 0x9813a416, 0x5d17e584, 0x5d17e584, 0x9813a416, }, 20 },
+ { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xfc209a25, 0xd5c20779, 0xfc209a25, 0xe95dd296, 0x5fcf013d, 0x5fcf013d, 0xe5699efe, 0xe5699efe, 0xe5699efe, 0x37798688, 0x37798688, 0x37798688, 0x8a402292, 0x8a402292, 0x8a402292, 0x5fcf013d, 0xe95dd296, 0xe95dd296, 0x5fcf013d, }, 20 },
+ { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x77f956f0, 0xfb0cc079, 0x77f956f0, 0x48edfcb8, 0xdd28f52b, 0xdd28f52b, 0xd51b1dc9, 0xd51b1dc9, 0xd51b1dc9, 0xf427e42d, 0xf427e42d, 0xf427e42d, 0xb787ac67, 0xb787ac67, 0xb787ac67, 0xdd28f52b, 0x48edfcb8, 0x48edfcb8, 0xdd28f52b, }, 20 },
+ { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x1d9ac82a, 0xa254aa53, 0x1d9ac82a, 0x8481a25b, 0x43d1f34, 0x43d1f34, 0xc304df68, 0xc304df68, 0xc304df68, 0xbc0e76c0, 0xbc0e76c0, 0xbc0e76c0, 0xed2f3c72, 0xed2f3c72, 0xed2f3c72, 0x43d1f34, 0x8481a25b, 0x8481a25b, 0x43d1f34, }, 20 },
+ { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa6239a89, 0x8dc4bfbb, 0xa6239a89, 0xe5d557ce, 0x59c36f00, 0x59c36f00, 0x244cf807, 0x244cf807, 0x244cf807, 0x5acc9561, 0x5acc9561, 0x5acc9561, 0x85666873, 0x85666873, 0x85666873, 0x59c36f00, 0xe5d557ce, 0xe5d557ce, 0x59c36f00, }, 20 },
+ { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x742cede9, 0x83bb7a50, 0x742cede9, 0x5a296896, 0xaa4593fe, 0xaa4593fe, 0xd83f8aeb, 0xd83f8aeb, 0xd83f8aeb, 0x7eca878c, 0x7eca878c, 0x7eca878c, 0x666ac025, 0x666ac025, 0x666ac025, 0xaa4593fe, 0x5a296896, 0x5a296896, 0xaa4593fe, }, 20 },
+ { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe20a98b0, 0x7e8cedef, 0xe20a98b0, 0xbf1df534, 0xc9cbf769, 0xc9cbf769, 0x2748b88c, 0x2748b88c, 0x2748b88c, 0xd9907940, 0xd9907940, 0xd9907940, 0x40b3b41f, 0x40b3b41f, 0x40b3b41f, 0xc9cbf769, 0xbf1df534, 0xbf1df534, 0xc9cbf769, }, 20 },
+ { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8f911ca4, 0xcbf1d895, 0x8f911ca4, 0x97308e26, 0x9813a416, 0x9813a416, 0x5b359bf4, 0x5b359bf4, 0x5b359bf4, 0xcaee1dc7, 0xcaee1dc7, 0xcaee1dc7, 0x6e6e1404, 0x6e6e1404, 0x6e6e1404, 0x9813a416, 0x97308e26, 0x97308e26, 0x9813a416, }, 20 },
+ { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x1bf82c82, 0xc7b39627, 0x1bf82c82, 0xe856431, 0x5fcf013d, 0x5fcf013d, 0xa9dbae99, 0xa9dbae99, 0xa9dbae99, 0x7bcbb6ef, 0x7bcbb6ef, 0x7bcbb6ef, 0xc6f212f5, 0xc6f212f5, 0xc6f212f5, 0x5fcf013d, 0xe856431, 0xe856431, 0x5fcf013d, }, 20 },
+ { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfae19a5c, 0xd1e8fabb, 0xfae19a5c, 0xc5f53014, 0xdd28f52b, 0xdd28f52b, 0xfa2c5565, 0xfa2c5565, 0xfa2c5565, 0xdb10ac81, 0xdb10ac81, 0xdb10ac81, 0x98b0e4cb, 0x98b0e4cb, 0x98b0e4cb, 0xdd28f52b, 0xc5f53014, 0xc5f53014, 0xdd28f52b, }, 20 },
+ { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9a18f7bc, 0x5fcecc43, 0x9a18f7bc, 0x3039dcd, 0x43d1f34, 0x43d1f34, 0x287a2b96, 0x287a2b96, 0x287a2b96, 0x5770823e, 0x5770823e, 0x5770823e, 0x651c88c, 0x651c88c, 0x651c88c, 0x43d1f34, 0x3039dcd, 0x3039dcd, 0x43d1f34, }, 20 },
+ { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x65112dfc, 0x3dec17f, 0x65112dfc, 0x26e7e0bb, 0x59c36f00, 0x59c36f00, 0x620c0067, 0x620c0067, 0x620c0067, 0x1c8c6d01, 0x1c8c6d01, 0x1c8c6d01, 0xc3269013, 0xc3269013, 0xc3269013, 0x59c36f00, 0x26e7e0bb, 0x26e7e0bb, 0x59c36f00, }, 20 },
+ { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2b3430fb, 0x8f1eb743, 0x2b3430fb, 0x531b584, 0xaa4593fe, 0xaa4593fe, 0xa8a596c8, 0xa8a596c8, 0xa8a596c8, 0xe509baf, 0xe509baf, 0xe509baf, 0x16f0dc06, 0x16f0dc06, 0x16f0dc06, 0xaa4593fe, 0x531b584, 0x531b584, 0xaa4593fe, }, 20 },
+ { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb523e920, 0xfafb6f8, 0xb523e920, 0xe83484a4, 0xc9cbf769, 0xc9cbf769, 0x3ce35e1d, 0x3ce35e1d, 0x3ce35e1d, 0xc23b9fd1, 0xc23b9fd1, 0xc23b9fd1, 0x5b18528e, 0x5b18528e, 0x5b18528e, 0xc9cbf769, 0xe83484a4, 0xe83484a4, 0xc9cbf769, }, 20 },
+ { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa9bf7336, 0x1a1f7a01, 0xa9bf7336, 0xb11ee1b4, 0x9813a416, 0x9813a416, 0x43fda3fa, 0x43fda3fa, 0x43fda3fa, 0xd22625c9, 0xd22625c9, 0xd22625c9, 0x76a62c0a, 0x76a62c0a, 0x76a62c0a, 0x9813a416, 0xb11ee1b4, 0xb11ee1b4, 0x9813a416, }, 20 },
+ { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xe5271912, 0xf5d10273, 0xe5271912, 0xf05a51a1, 0x5fcf013d, 0x5fcf013d, 0xf3582c48, 0xf3582c48, 0xf3582c48, 0x2148343e, 0x2148343e, 0x2148343e, 0x9c719024, 0x9c719024, 0x9c719024, 0x5fcf013d, 0xf05a51a1, 0xf05a51a1, 0x5fcf013d, }, 20 },
+ { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x66a34f49, 0x32dbeb97, 0x66a34f49, 0x59b7e501, 0xdd28f52b, 0xdd28f52b, 0xb3c7ef80, 0xb3c7ef80, 0xb3c7ef80, 0x92fb1664, 0x92fb1664, 0x92fb1664, 0xd15b5e2e, 0xd15b5e2e, 0xd15b5e2e, 0xdd28f52b, 0x59b7e501, 0x59b7e501, 0xdd28f52b, }, 20 },
+ { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7c2f19da, 0xd7bece67, 0x7c2f19da, 0xe53473ab, 0x43d1f34, 0x43d1f34, 0xa0717008, 0xa0717008, 0xa0717008, 0xdf7bd9a0, 0xdf7bd9a0, 0xdf7bd9a0, 0x8e5a9312, 0x8e5a9312, 0x8e5a9312, 0x43d1f34, 0xe53473ab, 0xe53473ab, 0x43d1f34, }, 20 },
+ { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x37943894, 0x78248c70, 0x37943894, 0x7462f5d3, 0x59c36f00, 0x59c36f00, 0xf4be229a, 0xf4be229a, 0xf4be229a, 0x8a3e4ffc, 0x8a3e4ffc, 0x8a3e4ffc, 0x5594b2ee, 0x5594b2ee, 0x5594b2ee, 0x59c36f00, 0x7462f5d3, 0x7462f5d3, 0x59c36f00, }, 20 },
+ { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd5158e6c, 0xdc71ba0f, 0xd5158e6c, 0xfb100b13, 0xaa4593fe, 0xaa4593fe, 0xd3ed72a3, 0xd3ed72a3, 0xd3ed72a3, 0x75187fc4, 0x75187fc4, 0x75187fc4, 0x6db8386d, 0x6db8386d, 0x6db8386d, 0xaa4593fe, 0xfb100b13, 0xfb100b13, 0xaa4593fe, }, 20 },
+ { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6277a9e6, 0xa3265ffb, 0x6277a9e6, 0x3f60c462, 0xc9cbf769, 0xc9cbf769, 0x2dcf8a8d, 0x2dcf8a8d, 0x2dcf8a8d, 0xd3174b41, 0xd3174b41, 0xd3174b41, 0x4a34861e, 0x4a34861e, 0x4a34861e, 0xc9cbf769, 0x3f60c462, 0x3f60c462, 0xc9cbf769, }, 20 },
+ { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x81115dc4, 0xddf3f768, 0x81115dc4, 0x99b0cf46, 0x9813a416, 0x9813a416, 0x9b9d96df, 0x9b9d96df, 0x9b9d96df, 0xa4610ec, 0xa4610ec, 0xa4610ec, 0xaec6192f, 0xaec6192f, 0xaec6192f, 0x9813a416, 0x99b0cf46, 0x99b0cf46, 0x9813a416, }, 20 },
+ { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5e96a904, 0x27864d3d, 0x5e96a904, 0x4bebe1b7, 0x5fcf013d, 0x5fcf013d, 0x18cae7f4, 0x18cae7f4, 0x18cae7f4, 0xcadaff82, 0xcadaff82, 0xcadaff82, 0x77e35b98, 0x77e35b98, 0x77e35b98, 0x5fcf013d, 0x4bebe1b7, 0x4bebe1b7, 0x5fcf013d, }, 20 },
+ { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd00b19f8, 0xba73a9c6, 0xd00b19f8, 0xef1fb3b0, 0xdd28f52b, 0xdd28f52b, 0xb660046d, 0xb660046d, 0xb660046d, 0x975cfd89, 0x975cfd89, 0x975cfd89, 0xd4fcb5c3, 0xd4fcb5c3, 0xd4fcb5c3, 0xdd28f52b, 0xef1fb3b0, 0xef1fb3b0, 0xdd28f52b, }, 20 },
+ { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8b4b98cd, 0x78ddc6e4, 0x8b4b98cd, 0x1250f2bc, 0x43d1f34, 0x43d1f34, 0x4889d3fd, 0x4889d3fd, 0x4889d3fd, 0x37837a55, 0x37837a55, 0x37837a55, 0x66a230e7, 0x66a230e7, 0x66a230e7, 0x43d1f34, 0x1250f2bc, 0x1250f2bc, 0x43d1f34, }, 20 },
+ { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xfecb570e, 0xccb97a7a, 0xfecb570e, 0xbd3d9a49, 0x59c36f00, 0x59c36f00, 0x40281258, 0x40281258, 0x40281258, 0x3ea87f3e, 0x3ea87f3e, 0x3ea87f3e, 0xe102822c, 0xe102822c, 0xe102822c, 0x59c36f00, 0xbd3d9a49, 0xbd3d9a49, 0x59c36f00, }, 20 },
+ { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x897d1fac, 0xaa982529, 0x897d1fac, 0xa7789ad3, 0xaa4593fe, 0xaa4593fe, 0xa482510, 0xa482510, 0xa482510, 0xacbd2877, 0xacbd2877, 0xacbd2877, 0xb41d6fde, 0xb41d6fde, 0xb41d6fde, 0xaa4593fe, 0xa7789ad3, 0xa7789ad3, 0xaa4593fe, }, 20 },
+ { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd02a5297, 0xe627ab58, 0xd02a5297, 0x8d3d3f13, 0xc9cbf769, 0xc9cbf769, 0xbf0a8b7f, 0xbf0a8b7f, 0xbf0a8b7f, 0x41d24ab3, 0x41d24ab3, 0x41d24ab3, 0xd8f187ec, 0xd8f187ec, 0xd8f187ec, 0xc9cbf769, 0x8d3d3f13, 0x8d3d3f13, 0xc9cbf769, }, 20 },
+ { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa653dcda, 0x3392e976, 0xa653dcda, 0xbef24e58, 0x9813a416, 0x9813a416, 0x4f2bc106, 0x4f2bc106, 0x4f2bc106, 0xdef04735, 0xdef04735, 0xdef04735, 0x7a704ef6, 0x7a704ef6, 0x7a704ef6, 0x9813a416, 0xbef24e58, 0xbef24e58, 0x9813a416, }, 20 },
+ { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xe2d7b585, 0x35241f36, 0xe2d7b585, 0xf7aafd36, 0x5fcf013d, 0x5fcf013d, 0xf2bd04db, 0xf2bd04db, 0xf2bd04db, 0x20ad1cad, 0x20ad1cad, 0x20ad1cad, 0x9d94b8b7, 0x9d94b8b7, 0x9d94b8b7, 0x5fcf013d, 0xf7aafd36, 0xf7aafd36, 0x5fcf013d, }, 20 },
+ { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x72ff749c, 0xeda8c283, 0x72ff749c, 0x4debded4, 0xdd28f52b, 0xdd28f52b, 0xb8c9cc22, 0xb8c9cc22, 0xb8c9cc22, 0x99f535c6, 0x99f535c6, 0x99f535c6, 0xda557d8c, 0xda557d8c, 0xda557d8c, 0xdd28f52b, 0x4debded4, 0x4debded4, 0xdd28f52b, }, 20 },
+ { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xb7cac764, 0xeb4bf417, 0xb7cac764, 0x2ed1ad15, 0x43d1f34, 0x43d1f34, 0xce718801, 0xce718801, 0xce718801, 0xb17b21a9, 0xb17b21a9, 0xb17b21a9, 0xe05a6b1b, 0xe05a6b1b, 0xe05a6b1b, 0x43d1f34, 0x2ed1ad15, 0x2ed1ad15, 0x43d1f34, }, 20 },
+ { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x930e8e13, 0xf5c16290, 0x930e8e13, 0x27f5f1c0, 0x59c36f00, 0x59c36f00, 0xbad4e11, 0xbad4e11, 0xbad4e11, 0x752d2377, 0x752d2377, 0x752d2377, 0xaa87de65, 0xaa87de65, 0xaa87de65, 0x59c36f00, 0x27f5f1c0, 0x27f5f1c0, 0x59c36f00, }, 20 },
+ { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xff9301f2, 0x5bb9864a, 0xff9301f2, 0x31c145de, 0xaa4593fe, 0xaa4593fe, 0x23bf2c32, 0x23bf2c32, 0x23bf2c32, 0x854a2155, 0x854a2155, 0x854a2155, 0x9dea66fc, 0x9dea66fc, 0x9dea66fc, 0xaa4593fe, 0x31c145de, 0x31c145de, 0xaa4593fe, }, 20 },
+ { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xfc5938ef, 0x46d56737, 0xfc5938ef, 0x23cf2668, 0xc9cbf769, 0xc9cbf769, 0xa8c549aa, 0xa8c549aa, 0xa8c549aa, 0x561d8866, 0x561d8866, 0x561d8866, 0xcf3e4539, 0xcf3e4539, 0xcf3e4539, 0xc9cbf769, 0x23cf2668, 0x23cf2668, 0xc9cbf769, }, 20 },
+ { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe7160822, 0x54b60115, 0xe7160822, 0x168efa6f, 0x9813a416, 0x9813a416, 0xb774a5aa, 0xb774a5aa, 0xb774a5aa, 0x26af2399, 0x26af2399, 0x26af2399, 0x822f2a5a, 0x822f2a5a, 0x822f2a5a, 0x9813a416, 0x168efa6f, 0x168efa6f, 0x9813a416, }, 20 },
+ { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf655f9b2, 0xe6a3e2d3, 0xf655f9b2, 0xd1d7405f, 0x5fcf013d, 0x5fcf013d, 0x2accaa08, 0x2accaa08, 0x2accaa08, 0xf8dcb27e, 0xf8dcb27e, 0xf8dcb27e, 0x45e51664, 0x45e51664, 0x45e51664, 0x5fcf013d, 0xd1d7405f, 0xd1d7405f, 0x5fcf013d, }, 20 },
+ { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2d85ebdc, 0x79fd4f02, 0x2d85ebdc, 0xc48ae2b6, 0xdd28f52b, 0xdd28f52b, 0x76b28a95, 0x76b28a95, 0x76b28a95, 0x578e7371, 0x578e7371, 0x578e7371, 0x142e3b3b, 0x142e3b3b, 0x142e3b3b, 0xdd28f52b, 0xc48ae2b6, 0xc48ae2b6, 0xdd28f52b, }, 20 },
+ { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x29c00f98, 0x8251d825, 0x29c00f98, 0x35a750d1, 0x43d1f34, 0x43d1f34, 0x48b70bc8, 0x48b70bc8, 0x48b70bc8, 0x37bda260, 0x37bda260, 0x37bda260, 0x669ce8d2, 0x669ce8d2, 0x669ce8d2, 0x43d1f34, 0x35a750d1, 0x35a750d1, 0x43d1f34, }, 20 },
+ { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4afab717, 0x2c355b94, 0x4afab717, 0x1166d9d0, 0x59c36f00, 0x59c36f00, 0x620c0067, 0x620c0067, 0x620c0067, 0x1c8c6d01, 0x1c8c6d01, 0x1c8c6d01, 0xc3269013, 0xc3269013, 0xc3269013, 0x59c36f00, 0x1166d9d0, 0x1166d9d0, 0x59c36f00, }, 20 },
+ { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe3daadd4, 0x47f02a6c, 0xe3daadd4, 0x5ea9fb21, 0xaa4593fe, 0xaa4593fe, 0xa8a596c8, 0xa8a596c8, 0xa8a596c8, 0xe509baf, 0xe509baf, 0xe509baf, 0x16f0dc06, 0x16f0dc06, 0x16f0dc06, 0xaa4593fe, 0x5ea9fb21, 0x5ea9fb21, 0xaa4593fe, }, 20 },
+ { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf140d1df, 0x4bcc8e07, 0xf140d1df, 0x7c962dcb, 0xc9cbf769, 0xc9cbf769, 0x3ce35e1d, 0x3ce35e1d, 0x3ce35e1d, 0xc23b9fd1, 0xc23b9fd1, 0xc23b9fd1, 0x5b18528e, 0x5b18528e, 0x5b18528e, 0xc9cbf769, 0x7c962dcb, 0x7c962dcb, 0xc9cbf769, }, 20 },
+ { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe709a12d, 0x54a9a81a, 0xe709a12d, 0xde04d65c, 0x9813a416, 0x9813a416, 0x43fda3fa, 0x43fda3fa, 0x43fda3fa, 0xd22625c9, 0xd22625c9, 0xd22625c9, 0x76a62c0a, 0x76a62c0a, 0x76a62c0a, 0x9813a416, 0xde04d65c, 0xde04d65c, 0x9813a416, }, 20 },
+ { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x65eff77c, 0x7519ec1d, 0x65eff77c, 0x1cd7d353, 0x5fcf013d, 0x5fcf013d, 0xf3582c48, 0xf3582c48, 0xf3582c48, 0x2148343e, 0x2148343e, 0x2148343e, 0x9c719024, 0x9c719024, 0x9c719024, 0x5fcf013d, 0x1cd7d353, 0x1cd7d353, 0x5fcf013d, }, 20 },
+ { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7318831a, 0x276027c4, 0x7318831a, 0xd7e4f5bb, 0xdd28f52b, 0xdd28f52b, 0xb3c7ef80, 0xb3c7ef80, 0xb3c7ef80, 0x92fb1664, 0x92fb1664, 0x92fb1664, 0xd15b5e2e, 0xd15b5e2e, 0xd15b5e2e, 0xdd28f52b, 0xd7e4f5bb, 0xd7e4f5bb, 0xdd28f52b, }, 20 },
+ { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6927a7d4, 0xc2b67069, 0x6927a7d4, 0xfc345163, 0x43d1f34, 0x43d1f34, 0xa0717008, 0xa0717008, 0xa0717008, 0xdf7bd9a0, 0xdf7bd9a0, 0xdf7bd9a0, 0x8e5a9312, 0x8e5a9312, 0x8e5a9312, 0x43d1f34, 0xfc345163, 0xfc345163, 0x43d1f34, }, 20 },
+ { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0xe6012f70, 0xe6012f70, 0xe6012f70, 0xe6012f70, 0xe6012f70, }, 5 },
+ { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xfb6be77b, 0xfb6be77b, 0xfb6be77b, 0xfb6be77b, 0xfb6be77b, }, 5 },
+ { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0x67c0629f, 0x67c0629f, 0x67c0629f, 0x67c0629f, 0x67c0629f, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x8f20afbb, 0xd8f7abc, 0x8f937344, 0xd3ca643, 0x8e471645, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xdca764da, 0x9f76da9a, 0x5b04185a, 0x18d5a61a, 0xd60deb2b, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0x7b87af36, 0x7cb96093, 0x75fa307c, 0x72c4ffd9, 0x677c91a2, }, 5 },
+ { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x72981c65, 0x50120635, 0x378c28c5, 0x15063295, 0xf8b07525, }, 5 },
+ { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0xc8f64b58, 0xc8f64b58, 0xc8f64b58, 0xc8f64b58, 0xc8f64b58, }, 5 },
+ { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0x2b499dfa, 0x2b499dfa, 0x2b499dfa, 0x2b499dfa, 0x2b499dfa, }, 5 },
+ { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0x6156b420, 0x6156b420, 0x6156b420, 0x6156b420, 0x6156b420, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x363285ca, 0x363285ca, 0x363285ca, 0x363285ca, 0x363285ca, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x25bb37f4, 0x25bb37f4, 0x25bb37f4, 0x25bb37f4, 0x25bb37f4, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xeeab9e91, 0xeeab9e91, 0xeeab9e91, 0xeeab9e91, 0xeeab9e91, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x26a9a50b, 0x26a9a50b, 0x26a9a50b, 0x26a9a50b, 0x26a9a50b, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0x2c0f4fe7, 0x2c0f4fe7, 0x2c0f4fe7, 0x2c0f4fe7, 0x2c0f4fe7, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x46c11052, 0x46c11052, 0x46c11052, 0x46c11052, 0x46c11052, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0xe56cf615, 0xcd2be572, 0xb5e2d0db, 0x9da5c3bc, 0x4470bb89, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x2a25b871, 0x4bf85361, 0xe99e6e51, 0x88438541, 0xa8be62c0, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x81523037, 0xd8c0bfd3, 0x32772fff, 0x6be5a01b, 0xe2f47956, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x1833bb41, 0x1833bb41, 0x1833bb41, 0x1833bb41, 0x1833bb41, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2c39a0e8, 0x2c39a0e8, 0x2c39a0e8, 0x2c39a0e8, 0x2c39a0e8, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xf0d4c23, 0xf0d4c23, 0xf0d4c23, 0xf0d4c23, 0xf0d4c23, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x456d063c, 0x456d063c, 0x456d063c, 0x456d063c, 0x456d063c, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x47e15a2e, 0x47e15a2e, 0x47e15a2e, 0x47e15a2e, 0x47e15a2e, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x54d7300d, 0x54d7300d, 0x54d7300d, 0x54d7300d, 0x54d7300d, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x770da211, 0x8ef2528e, 0x811e35de, 0x78e1c541, 0x9ec6fb7e, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0xeb181fbc, 0xae648cc1, 0x61e13946, 0x249daa3b, 0xfb0624b9, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x2b6f64dc, 0xc25f8431, 0xfce2d3f7, 0x15d2331a, 0x81987c7b, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0xa260f7dd, 0x3e2f4980, 0x9f13fd96, 0x35c43cb, 0xd886e34b, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x41a9bff8, 0xa0d3f7c3, 0x86b1597f, 0x67cb1144, 0xca740407, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0x8f7a3b6d, 0xcb84c6e3, 0x687c071, 0x42793dff, 0x996dbba4, }, 5 },
diff --git a/grub-core/tests/cmdline_cat_test.c b/grub-core/tests/cmdline_cat_test.c
new file mode 100644
index 0000000..baea768
--- /dev/null
+++ b/grub-core/tests/cmdline_cat_test.c
@@ -0,0 +1,125 @@
+/*
+ * 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/>.
+ */
+
+/* All tests need to include test.h for GRUB testing framework. */
+#include <grub/test.h>
+#include <grub/dl.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/command.h>
+#include <grub/font.h>
+#include <grub/procfs.h>
+#include <grub/env.h>
+#include <grub/normal.h>
+#include <grub/time.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+
+static const char testfile[] =
+ /* Chinese & UTF-8 test from Carbon Jiao. */
+ "从硬盘的第一主分区å¯åŠ¨\n"
+ "The quick brown fox jumped over the lazy dog.\n"
+ /* Characters used:
+ Code point Description UTF-8 encoding
+ ----------- ------------------------------ --------------
+ U+263A unfilled smiley face E2 98 BA
+ U+00A1 inverted exclamation point C2 A1
+ U+00A3 British pound currency symbol C2 A3
+ U+03C4 Greek tau CF 84
+ U+00E4 lowercase letter a with umlaut C3 A4
+ U+2124 set 'Z' symbol (integers) E2 84 A4
+ U+2286 subset symbol E2 8A 86
+ U+211D set 'R' symbol (real numbers) E2 84 9D */
+ "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\n"
+ /* Test handling of bad (non-UTF8) sequences*/
+ "\x99Hello\xc2Hello\xc1\x81Hello\n";
+;
+
+static char *
+get_test_txt (grub_size_t *sz)
+{
+ *sz = grub_strlen (testfile);
+ return grub_strdup (testfile);
+}
+
+struct grub_procfs_entry test_txt =
+{
+ .name = "test.txt",
+ .get_contents = get_test_txt
+};
+
+#define FONT_NAME "Unknown Regular 16"
+
+/* Functional test main method. */
+static void
+cmdline_cat_test (void)
+{
+ unsigned i;
+ grub_font_t font;
+
+ grub_dl_load ("gfxterm");
+ grub_errno = GRUB_ERR_NONE;
+
+ font = grub_font_get (FONT_NAME);
+ if (font && grub_strcmp (font->name, FONT_NAME) != 0)
+ font = 0;
+ if (!font)
+ font = grub_font_load ("unicode");
+
+ if (!font)
+ {
+ grub_test_assert (0, "unicode font not found: %s", grub_errmsg);
+ return;
+ }
+
+ grub_procfs_register ("test.txt", &test_txt);
+
+ for (i = 0; i < GRUB_TEST_VIDEO_SMALL_N_MODES; i++)
+ {
+ grub_video_capture_start (&grub_test_video_modes[i],
+ grub_video_fbstd_colors,
+ grub_test_video_modes[i].number_of_colors);
+ grub_terminal_input_fake_sequence ((int [])
+ { 'c', 'a', 't', ' ',
+ '(', 'p', 'r', 'o', 'c', ')',
+ '/', 't', 'e', 's', 't', '.',
+ 't', 'x', 't', '\n',
+ GRUB_TERM_NO_KEY,
+ GRUB_TERM_NO_KEY, GRUB_TERM_ESC},
+ 23);
+
+ grub_video_checksum ("cmdline_cat");
+
+ if (!grub_test_use_gfxterm ())
+ grub_cmdline_run (1, 0);
+
+ grub_test_use_gfxterm_end ();
+
+ grub_terminal_input_fake_sequence_end ();
+ grub_video_checksum_end ();
+ grub_video_capture_end ();
+ }
+
+ grub_procfs_unregister (&test_txt);
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (cmdline_cat_test, cmdline_cat_test);
diff --git a/grub-core/tests/cmp_test.c b/grub-core/tests/cmp_test.c
new file mode 100644
index 0000000..af5b395
--- /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 0000000..eb7a1df
--- /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
new file mode 100644
index 0000000..9abc6d5
--- /dev/null
+++ b/grub-core/tests/div_test.c
@@ -0,0 +1,189 @@
+/*
+ * 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
+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);
+ 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);
+ /* Overflow check. */
+ grub_test_assert ((q >> 32) == 0,
+ "division overflow in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ grub_test_assert ((r >> 32) == 0,
+ "division overflow in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ /* q * b + r is at most:
+ 0xffffffff * 0xffffffff + 0xffffffff = 0xffffffff00000000
+ so no overflow
+ */
+ 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
+test64 (grub_uint64_t a, grub_uint64_t b)
+{
+ grub_uint64_t q, r;
+ grub_uint64_t x1, x2;
+ 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);
+ 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);
+ /* Overflow checks. */
+ grub_test_assert ((q >> 32) * (b >> 32) == 0,
+ "division overflow in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ x1 = (q >> 32) * (b & 0xffffffff);
+ grub_test_assert (x1 < (1LL << 32),
+ "division overflow in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ x1 <<= 32;
+ x2 = (b >> 32) * (q & 0xffffffff);
+ grub_test_assert (x2 < (1LL << 32),
+ "division overflow in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ x2 <<= 32;
+ grub_test_assert (x1 <= ~x2,
+ "division overflow in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ x1 += x2;
+ x2 = (q & 0xffffffff) * (b & 0xffffffff);
+ grub_test_assert (x1 <= ~x2,
+ "division overflow in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ x1 += x2;
+ grub_test_assert (x1 <= ~r,
+ "division overflow in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ x1 += r;
+ grub_test_assert (a == x1,
+ "division overflow test failure in 0x%llx, 0x%llx", (long long) a, (long long) b);
+#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 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)
+{
+ 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 (div_test, div_test);
diff --git a/grub-core/tests/example_functional_test.c b/grub-core/tests/example_functional_test.c
new file mode 100644
index 0000000..999f6d2
--- /dev/null
+++ b/grub-core/tests/example_functional_test.c
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* All tests need to include test.h for GRUB testing framework. */
+#include <grub/test.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Functional test main method. */
+static void
+example_test (void)
+{
+ /* Check if 1st argument is true and report with default error message. */
+ grub_test_assert (1 == 1, "1 equal 1 expected");
+
+ /* Check if 1st argument is true and report with custom error message. */
+ grub_test_assert (2 == 2, "2 equal 2 expected");
+ grub_test_assert (2 != 3, "2 matches %d", 3);
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (exfctest, example_test);
diff --git a/grub-core/tests/fake_input.c b/grub-core/tests/fake_input.c
new file mode 100644
index 0000000..b5eb516
--- /dev/null
+++ b/grub-core/tests/fake_input.c
@@ -0,0 +1,75 @@
+/*
+ * 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/term.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/test.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static int *seq;
+static int seqptr, nseq;
+static struct grub_term_input *saved;
+static int fake_input;
+
+static int
+fake_getkey (struct grub_term_input *term __attribute__ ((unused)))
+{
+ if (seq && seqptr < nseq)
+ return seq[seqptr++];
+ return -1;
+}
+
+static struct grub_term_input fake_input_term =
+ {
+ .name = "fake",
+ .getkey = fake_getkey
+ };
+
+void
+grub_terminal_input_fake_sequence (int *seq_in, int nseq_in)
+{
+ if (!fake_input)
+ saved = grub_term_inputs;
+ if (seq)
+ grub_free (seq);
+ seq = grub_calloc (nseq_in, sizeof (seq[0]));
+ if (!seq)
+ return;
+
+ grub_term_inputs = &fake_input_term;
+ grub_memcpy (seq, seq_in, nseq_in * sizeof (seq[0]));
+
+ nseq = nseq_in;
+ seqptr = 0;
+ fake_input = 1;
+}
+
+void
+grub_terminal_input_fake_sequence_end (void)
+{
+ if (!fake_input)
+ return;
+ fake_input = 0;
+ grub_term_inputs = saved;
+ grub_free (seq);
+ seq = 0;
+ nseq = 0;
+ seqptr = 0;
+}
diff --git a/grub-core/tests/gfxterm_menu.c b/grub-core/tests/gfxterm_menu.c
new file mode 100644
index 0000000..12836fb
--- /dev/null
+++ b/grub-core/tests/gfxterm_menu.c
@@ -0,0 +1,180 @@
+/*
+ * 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/>.
+ */
+
+/* All tests need to include test.h for GRUB testing framework. */
+#include <grub/test.h>
+#include <grub/dl.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/command.h>
+#include <grub/font.h>
+#include <grub/procfs.h>
+#include <grub/env.h>
+#include <grub/normal.h>
+#include <grub/time.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+
+static const char testfile[] =
+ "menuentry \"test\" {\n"
+ "\ttrue\n"
+ "}\n"
+ "menuentry \"sÌ› oÌ› t oÌ’ sÌ’ u oÌ•Ìš 8.04 mÌ‚ñaÌŠhÌŠz̆xÌ£ aÌ¡ bÌ¢gÌ¢ uá·Žoá·ŽÌ‚ oÌ‚á·Ž OÌ· aÌ–Ì£ aÌ‘Ì\" --class ubuntu --class linux --class os {\n"
+ "\ttrue\n"
+ "}\n"
+ "menuentry \" הַרמלל(טוֹבָ) לֶךְ\" --class opensuse --class linux --class os {\n"
+ "\ttrue\n"
+ "}\n"
+ "menuentry \"الرملل جÙداً Ù„ÙÙƒÙŽ\" --class gentoo --class linux --class os {\n"
+ "\ttrue\n"
+ "}\n"
+ "menuentry \"ὑπόγυͅον\" --class kubuntu --class linux --class os {\n"
+ "\ttrue\n"
+ "}\n"
+ "menuentry \"سَّ نّ٠نَّ نٌّ نّْ\" --class linuxmint --class linux --class os {\n"
+ "\ttrue\n"
+ "}\n"
+ /* Chinese & UTF-8 test from Carbon Jiao. */
+ "menuentry \"从硬盘的第一主分区å¯åŠ¨\" --class \"windows xp\" --class windows --class os {\n"
+ "\ttrue\n"
+ "}\n"
+ "timeout=3\n";
+
+static char *
+get_test_cfg (grub_size_t *sz)
+{
+ *sz = grub_strlen (testfile);
+ return grub_strdup (testfile);
+}
+
+struct grub_procfs_entry test_cfg =
+{
+ .name = "test.cfg",
+ .get_contents = get_test_cfg
+};
+
+struct
+{
+ const char *name;
+ const char *var;
+ const char *val;
+} tests[] =
+ {
+ { "gfxterm_menu", NULL, NULL },
+ { "gfxmenu", "theme", "starfield/theme.txt" },
+ { "gfxterm_ar", "lang", "en@arabic" },
+ { "gfxterm_cyr", "lang", "en@cyrillic" },
+ { "gfxterm_heb", "lang", "en@hebrew" },
+ { "gfxterm_gre", "lang", "en@greek" },
+ { "gfxterm_ru", "lang", "ru" },
+ { "gfxterm_fr", "lang", "fr" },
+ { "gfxterm_quot", "lang", "en@quot" },
+ { "gfxterm_piglatin", "lang", "en@piglatin" },
+ { "gfxterm_ch", "lang", "de_CH" },
+ { "gfxterm_red", "menu_color_normal", "red/blue" },
+ { "gfxterm_high", "menu_color_highlight", "blue/red" },
+ };
+
+#define FONT_NAME "Unknown Regular 16"
+
+/* Functional test main method. */
+static void
+gfxterm_menu (void)
+{
+ unsigned i, j;
+ grub_font_t font;
+
+ grub_dl_load ("png");
+ grub_dl_load ("gettext");
+ grub_dl_load ("gfxterm");
+
+ grub_errno = GRUB_ERR_NONE;
+
+ grub_dl_load ("gfxmenu");
+
+ font = grub_font_get (FONT_NAME);
+ if (font && grub_strcmp (font->name, FONT_NAME) != 0)
+ font = 0;
+ if (!font)
+ font = grub_font_load ("unicode");
+
+ if (!font)
+ {
+ grub_test_assert (0, "unicode font not found: %s", grub_errmsg);
+ return;
+ }
+
+ grub_procfs_register ("test.cfg", &test_cfg);
+
+ for (j = 0; j < ARRAY_SIZE (tests); j++)
+ for (i = 0; i < GRUB_TEST_VIDEO_SMALL_N_MODES; i++)
+ {
+ grub_uint64_t start;
+
+#if defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_IEEE1275)
+ if (grub_test_video_modes[i].width > 1024)
+ continue;
+ if (grub_strcmp (tests[j].name, "gfxmenu") == 0
+ && grub_test_video_modes[i].width > 800)
+ continue;
+#endif
+ start = grub_get_time_ms ();
+
+ grub_video_capture_start (&grub_test_video_modes[i],
+ grub_video_fbstd_colors,
+ grub_test_video_modes[i].number_of_colors);
+ if (grub_errno)
+ {
+ grub_test_assert (0, "can't start capture: %d: %s",
+ grub_errno, grub_errmsg);
+ return;
+ }
+ grub_terminal_input_fake_sequence ((int []) { -1, -1, -1, GRUB_TERM_KEY_DOWN, -1, 'e',
+ -1, GRUB_TERM_KEY_RIGHT, -1, 'x', -1, GRUB_TERM_ESC, -1, GRUB_TERM_ESC }, 14);
+
+ grub_video_checksum (tests[j].name);
+
+ if (grub_test_use_gfxterm ())
+ return;
+
+ grub_env_context_open ();
+ if (tests[j].var)
+ grub_env_set (tests[j].var, tests[j].val);
+ grub_normal_execute ("(proc)/test.cfg", 1, 0);
+ grub_env_context_close ();
+
+ grub_test_use_gfxterm_end ();
+
+ grub_terminal_input_fake_sequence_end ();
+ grub_video_checksum_end ();
+ grub_video_capture_end ();
+
+ if (tests[j].var)
+ grub_env_unset (tests[j].var);
+ grub_printf ("%s %dx%dx%s done %lld ms\n", tests[j].name,
+ grub_test_video_modes[i].width,
+ grub_test_video_modes[i].height,
+ grub_video_checksum_get_modename (), (long long) (grub_get_time_ms () - start));
+ }
+
+ grub_procfs_unregister (&test_cfg);
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (gfxterm_menu, gfxterm_menu);
diff --git a/grub-core/tests/legacy_password_test.c b/grub-core/tests/legacy_password_test.c
new file mode 100644
index 0000000..2546033
--- /dev/null
+++ b/grub-core/tests/legacy_password_test.c
@@ -0,0 +1,68 @@
+/*
+ * 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>
+#include <grub/crypto.h>
+#include <grub/legacy_parse.h>
+#include <grub/auth.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct
+{
+ char **args;
+ int argc;
+ char entered[GRUB_AUTH_MAX_PASSLEN];
+ int exp;
+} vectors[] = {
+ { (char * []) { (char *) "hello", NULL }, 1, "hello", 1 },
+ { (char * []) { (char *) "hello", NULL }, 1, "hi", 0 },
+ { (char * []) { (char *) "hello", NULL }, 1, "hillo", 0 },
+ { (char * []) { (char *) "hello", NULL }, 1, "hellw", 0 },
+ { (char * []) { (char *) "hello", NULL }, 1, "hell", 0 },
+ { (char * []) { (char *) "hello", NULL }, 1, "h", 0 },
+ { (char * []) { (char *) "--md5", (char *) "$1$maL$OKEF0PD2k6eQ0Po8u4Gjr/",
+ NULL }, 2, "hello", 1 },
+ { (char * []) { (char *) "--md5", (char *) "$1$maL$OKEF0PD2k6eQ0Po8u4Gjr/",
+ NULL }, 2, "hell", 0 },
+ { (char * []) { (char *) "--md5", (char *) "$1$naL$BaFO8zGgmss1E76GsrAec1",
+ NULL }, 2, "hello", 1 },
+ { (char * []) { (char *) "--md5", (char *) "$1$naL$BaFO8zGgmss1E76GsrAec1",
+ NULL }, 2, "hell", 0 },
+ { (char * []) { (char *) "--md5", (char *) "$1$oaL$eyrazuM7TkxVkKgBim1WH1",
+ NULL }, 2, "hi", 1 },
+ { (char * []) { (char *) "--md5", (char *) "$1$oaL$eyrazuM7TkxVkKgBim1WH1",
+ NULL }, 2, "hello", 0 },
+};
+
+static void
+legacy_password_test (void)
+{
+ grub_size_t i;
+
+ for (i = 0; i < ARRAY_SIZE (vectors); i++)
+ grub_test_assert (grub_legacy_check_md5_password (vectors[i].argc,
+ vectors[i].args,
+ vectors[i].entered)
+ == vectors[i].exp, "Bad password check (%d)", (int) i);
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (legacy_password_test, legacy_password_test);
diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c
new file mode 100644
index 0000000..96781fb
--- /dev/null
+++ b/grub-core/tests/lib/functional_test.c
@@ -0,0 +1,105 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/test.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_functional_test (grub_extcmd_context_t ctxt __attribute__ ((unused)),
+ int argc,
+ char **args)
+{
+ grub_test_t test;
+ int ok = 1;
+ int i;
+
+ FOR_LIST_ELEMENTS (test, grub_test_list)
+ {
+ if (argc != 0)
+ {
+ for (i = 0; i < argc; i++)
+ if (grub_strcmp(args[i], test->name) == 0)
+ break;
+ if (i == argc)
+ continue;
+ }
+ grub_errno = 0;
+ ok = ok && !grub_test_run (test);
+ grub_errno = 0;
+ }
+ if (ok)
+ grub_printf ("ALL TESTS PASSED\n");
+ else
+ grub_printf ("TEST FAILURE\n");
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_functional_all_tests (grub_extcmd_context_t ctxt __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_test_t test;
+ int ok = 1;
+
+ grub_dl_load ("legacy_password_test");
+ grub_errno = GRUB_ERR_NONE;
+ grub_dl_load ("exfctest");
+ grub_dl_load ("videotest_checksum");
+ grub_dl_load ("gfxterm_menu");
+ grub_dl_load ("setjmp_test");
+ grub_dl_load ("cmdline_cat_test");
+ grub_dl_load ("div_test");
+ grub_dl_load ("xnu_uuid_test");
+ 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;
+ if (ok)
+ grub_printf ("ALL TESTS PASSED\n");
+ else
+ grub_printf ("TEST FAILURE\n");
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT (functional_test)
+{
+ cmd = grub_register_extcmd ("functional_test", grub_functional_test, 0, 0,
+ "Run all loaded functional tests.", 0);
+ cmd = grub_register_extcmd ("all_functional_test", grub_functional_all_tests, 0, 0,
+ "Run all functional tests.", 0);
+}
+
+GRUB_MOD_FINI (functional_test)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/tests/lib/test.c b/grub-core/tests/lib/test.c
new file mode 100644
index 0000000..3000fc8
--- /dev/null
+++ b/grub-core/tests/lib/test.c
@@ -0,0 +1,239 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/test.h>
+
+struct grub_test_failure
+{
+ /* The next failure. */
+ struct grub_test_failure *next;
+ struct grub_test_failure **prev;
+
+ /* The test source file name. */
+ char *file;
+
+ /* The test function name. */
+ char *funp;
+
+ /* The test call line number. */
+ grub_uint32_t line;
+
+ /* The test failure message. */
+ char *message;
+};
+typedef struct grub_test_failure *grub_test_failure_t;
+
+grub_test_t grub_test_list;
+static grub_test_failure_t failure_list;
+
+static grub_test_failure_t
+failure_start(const char *file, const char *funp, grub_uint32_t line);
+static grub_test_failure_t
+failure_start(const char *file, const char *funp, grub_uint32_t line)
+{
+ grub_test_failure_t failure;
+
+ failure = (grub_test_failure_t) grub_malloc (sizeof (*failure));
+ if (!failure)
+ return NULL;
+
+ failure->file = grub_strdup (file ? : "<unknown_file>");
+ if (!failure->file)
+ {
+ grub_free(failure);
+ return NULL;
+ }
+
+ failure->funp = grub_strdup (funp ? : "<unknown_function>");
+ if (!failure->funp)
+ {
+ grub_free(failure->file);
+ grub_free(failure);
+ return NULL;
+ }
+
+ failure->line = line;
+
+ failure->message = NULL;
+
+ return failure;
+}
+
+static void
+failure_append_vtext(grub_test_failure_t failure, const char *fmt, va_list args);
+static void
+failure_append_vtext(grub_test_failure_t failure, const char *fmt, va_list args)
+{
+ char *msg = grub_xvasprintf(fmt, args);
+ if (failure->message)
+ {
+ char *oldmsg = failure->message;
+
+ failure->message = grub_xasprintf("%s%s", oldmsg, msg);
+ grub_free (oldmsg);
+ grub_free (msg);
+ }
+ else
+ {
+ failure->message = msg;
+ }
+}
+
+static void
+failure_append_text(grub_test_failure_t failure, const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ failure_append_vtext(failure, fmt, args);
+ va_end(args);
+}
+
+static void
+add_failure (const char *file,
+ const char *funp,
+ grub_uint32_t line, const char *fmt, va_list args)
+{
+ grub_test_failure_t failure = failure_start(file, funp, line);
+ failure_append_text(failure, fmt, args);
+ grub_list_push (GRUB_AS_LIST_P (&failure_list), GRUB_AS_LIST (failure));
+}
+
+static void
+free_failures (void)
+{
+ grub_test_failure_t item;
+
+ while (failure_list)
+ {
+ item = failure_list;
+ failure_list = item->next;
+ if (item->message)
+ grub_free (item->message);
+
+ if (item->funp)
+ grub_free (item->funp);
+
+ if (item->file)
+ grub_free (item->file);
+
+ grub_free (item);
+ }
+ failure_list = 0;
+}
+
+void
+grub_test_nonzero (int cond,
+ const char *file,
+ const char *funp, grub_uint32_t line, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (cond)
+ return;
+
+ va_start (ap, fmt);
+ add_failure (file, funp, line, fmt, ap);
+ va_end (ap);
+}
+
+void
+grub_test_assert_helper (int cond, const char *file, const char *funp,
+ grub_uint32_t line, const char *condstr,
+ const char *fmt, ...)
+{
+ va_list ap;
+ grub_test_failure_t failure;
+
+ if (cond)
+ return;
+
+ failure = failure_start(file, funp, line);
+ failure_append_text(failure, "assert failed: %s ", condstr);
+
+ va_start(ap, fmt);
+
+ failure_append_vtext(failure, fmt, ap);
+
+ va_end(ap);
+
+ grub_list_push (GRUB_AS_LIST_P (&failure_list), GRUB_AS_LIST (failure));
+}
+
+void
+grub_test_register (const char *name, void (*test_main) (void))
+{
+ grub_test_t test;
+
+ test = (grub_test_t) grub_malloc (sizeof (*test));
+ if (!test)
+ return;
+
+ test->name = grub_strdup (name);
+ test->main = test_main;
+
+ grub_list_push (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test));
+}
+
+void
+grub_test_unregister (const char *name)
+{
+ grub_test_t test;
+
+ test = (grub_test_t) grub_named_list_find
+ (GRUB_AS_NAMED_LIST (grub_test_list), name);
+
+ if (test)
+ {
+ grub_list_remove (GRUB_AS_LIST (test));
+
+ if (test->name)
+ grub_free (test->name);
+
+ grub_free (test);
+ }
+}
+
+int
+grub_test_run (grub_test_t test)
+{
+ grub_test_failure_t failure;
+
+ test->main ();
+
+ grub_printf ("%s:\n", test->name);
+ FOR_LIST_ELEMENTS (failure, failure_list)
+ grub_printf (" %s:%s:%u: %s\n",
+ (failure->file ? : "<unknown_file>"),
+ (failure->funp ? : "<unknown_function>"),
+ failure->line, (failure->message ? : "<no message>"));
+
+ if (!failure_list)
+ {
+ grub_printf ("%s: PASS\n", test->name);
+ return GRUB_ERR_NONE;
+ }
+ else
+ {
+ grub_printf ("%s: FAIL\n", test->name);
+ free_failures ();
+ return GRUB_ERR_TEST_FAILURE;
+ }
+}
diff --git a/grub-core/tests/mul_test.c b/grub-core/tests/mul_test.c
new file mode 100644
index 0000000..cd64231
--- /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/pbkdf2_test.c b/grub-core/tests/pbkdf2_test.c
new file mode 100644
index 0000000..4eeb8b8
--- /dev/null
+++ b/grub-core/tests/pbkdf2_test.c
@@ -0,0 +1,97 @@
+/*
+ * 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>
+#include <grub/crypto.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct
+{
+ const char *P;
+ grub_size_t Plen;
+ const char *S;
+ grub_size_t Slen;
+ unsigned int c;
+ grub_size_t dkLen;
+ const char *DK;
+} vectors[] = {
+ /* RFC6070. */
+ {
+ "password", 8,
+ "salt", 4,
+ 1, 20,
+ "\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12"
+ "\x06\x2f\xe0\x37\xa6"
+ },
+ {
+ "password", 8,
+ "salt", 4,
+ 2, 20,
+ "\xea\x6c\x01\x4d\xc7\x2d\x6f\x8c"
+ "\xcd\x1e\xd9\x2a\xce\x1d\x41\xf0"
+ "\xd8\xde\x89\x57"
+ },
+ {
+ "password", 8,
+ "salt", 4,
+ 4096, 20,
+ "\x4b\x00\x79\x01\xb7\x65\x48\x9a\xbe\xad\x49\xd9\x26\xf7"
+ "\x21\xd0\x65\xa4\x29\xc1"
+ },
+ {
+ "passwordPASSWORDpassword", 24,
+ "saltSALTsaltSALTsaltSALTsaltSALTsalt", 36,
+ 4096, 25,
+ "\x3d\x2e\xec\x4f\xe4\x1c\x84\x9b\x80\xc8\xd8\x36\x62\xc0"
+ "\xe4\x4a\x8b\x29\x1a\x96\x4c\xf2\xf0\x70\x38"
+ },
+ {
+ "pass\0word", 9,
+ "sa\0lt", 5,
+ 4096, 16,
+ "\x56\xfa\x6a\xa7\x55\x48\x09\x9d\xcc\x37\xd7\xf0\x34\x25\xe0\xc3"
+ }
+};
+
+static void
+pbkdf2_test (void)
+{
+ grub_size_t i;
+
+ for (i = 0; i < ARRAY_SIZE (vectors); i++)
+ {
+ gcry_err_code_t err;
+ grub_uint8_t DK[32];
+ err = grub_crypto_pbkdf2 (GRUB_MD_SHA1,
+ (const grub_uint8_t *) vectors[i].P,
+ vectors[i].Plen,
+ (const grub_uint8_t *) vectors[i].S,
+ vectors[i].Slen,
+ vectors[i].c,
+ DK, vectors[i].dkLen);
+ grub_test_assert (err == 0, "gcry error %d", err);
+ grub_test_assert (grub_memcmp (DK, vectors[i].DK, vectors[i].dkLen) == 0,
+ "PBKDF2 mismatch");
+ }
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (pbkdf2_test, pbkdf2_test);
diff --git a/grub-core/tests/setjmp_test.c b/grub-core/tests/setjmp_test.c
new file mode 100644
index 0000000..604a6ce
--- /dev/null
+++ b/grub-core/tests/setjmp_test.c
@@ -0,0 +1,80 @@
+/*
+ * 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/setjmp.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_jmp_buf jmp_point;
+static int expected, ctr;
+
+/* This fixes GCC7 "unintentional fallthrough" warning */
+static void jmp0 (void) __attribute__ ((noreturn));
+static void jmp1 (void) __attribute__ ((noreturn));
+static void jmp2 (void) __attribute__ ((noreturn));
+
+static void
+jmp0 (void)
+{
+ grub_longjmp (jmp_point, 0);
+}
+
+static void
+jmp1 (void)
+{
+ grub_longjmp (jmp_point, 1);
+}
+
+static void
+jmp2 (void)
+{
+ grub_longjmp (jmp_point, 2);
+}
+
+static void
+setjmp_test (void)
+{
+ int val;
+
+ expected = 0;
+ ctr = 0;
+ val = grub_setjmp (jmp_point);
+
+ grub_test_assert (val == expected, "setjmp returned %d instead of %d",
+ val, expected);
+ switch (ctr++)
+ {
+ case 0:
+ expected = 1;
+ jmp0 ();
+ case 1:
+ expected = 1;
+ jmp1 ();
+ case 2:
+ expected = 2;
+ jmp2 ();
+ case 3:
+ return;
+ }
+ grub_test_assert (0, "setjmp didn't return enough times");
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (setjmp_test, setjmp_test);
diff --git a/grub-core/tests/shift_test.c b/grub-core/tests/shift_test.c
new file mode 100644
index 0000000..4120f52
--- /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/signature_test.c b/grub-core/tests/signature_test.c
new file mode 100644
index 0000000..aa49393
--- /dev/null
+++ b/grub-core/tests/signature_test.c
@@ -0,0 +1,170 @@
+/*
+ * 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/time.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/env.h>
+#include <grub/test.h>
+#include <grub/mm.h>
+#include <grub/procfs.h>
+
+#include "signatures.h"
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static char *
+get_hi_dsa_sig (grub_size_t *sz)
+{
+ char *ret;
+ *sz = sizeof (hi_dsa_sig);
+ ret = grub_malloc (sizeof (hi_dsa_sig));
+ if (ret)
+ grub_memcpy (ret, hi_dsa_sig, sizeof (hi_dsa_sig));
+ return ret;
+}
+
+static struct grub_procfs_entry hi_dsa_sig_entry =
+{
+ .name = "hi_dsa.sig",
+ .get_contents = get_hi_dsa_sig
+};
+
+static char *
+get_hi_dsa_pub (grub_size_t *sz)
+{
+ char *ret;
+ *sz = sizeof (hi_dsa_pub);
+ ret = grub_malloc (sizeof (hi_dsa_pub));
+ if (ret)
+ grub_memcpy (ret, hi_dsa_pub, sizeof (hi_dsa_pub));
+ return ret;
+}
+
+static struct grub_procfs_entry hi_dsa_pub_entry =
+{
+ .name = "hi_dsa.pub",
+ .get_contents = get_hi_dsa_pub
+};
+
+static char *
+get_hi_rsa_sig (grub_size_t *sz)
+{
+ char *ret;
+ *sz = sizeof (hi_rsa_sig);
+ ret = grub_malloc (sizeof (hi_rsa_sig));
+ if (ret)
+ grub_memcpy (ret, hi_rsa_sig, sizeof (hi_rsa_sig));
+ return ret;
+}
+
+static struct grub_procfs_entry hi_rsa_sig_entry =
+{
+ .name = "hi_rsa.sig",
+ .get_contents = get_hi_rsa_sig
+};
+
+static char *
+get_hi_rsa_pub (grub_size_t *sz)
+{
+ char *ret;
+ *sz = sizeof (hi_rsa_pub);
+ ret = grub_malloc (sizeof (hi_rsa_pub));
+ if (ret)
+ grub_memcpy (ret, hi_rsa_pub, sizeof (hi_rsa_pub));
+ return ret;
+}
+
+static struct grub_procfs_entry hi_rsa_pub_entry =
+{
+ .name = "hi_rsa.pub",
+ .get_contents = get_hi_rsa_pub
+};
+
+static char *
+get_hi (grub_size_t *sz)
+{
+ *sz = 3;
+ return grub_strdup ("hi\n");
+}
+
+struct grub_procfs_entry hi =
+{
+ .name = "hi",
+ .get_contents = get_hi
+};
+
+static char *
+get_hj (grub_size_t *sz)
+{
+ *sz = 3;
+ return grub_strdup ("hj\n");
+}
+
+struct grub_procfs_entry hj =
+{
+ .name = "hj",
+ .get_contents = get_hj
+};
+
+static void
+do_verify (const char *f, const char *sig, const char *pub, int is_valid)
+{
+ grub_command_t cmd;
+ char *args[] = { (char *) f, (char *) sig,
+ (char *) pub, NULL };
+ grub_err_t err;
+
+ cmd = grub_command_find ("verify_detached");
+ if (!cmd)
+ {
+ grub_test_assert (0, "can't find command `%s'", "verify_detached");
+ return;
+ }
+ err = (cmd->func) (cmd, 3, args);
+
+ grub_test_assert (err == (is_valid ? 0 : GRUB_ERR_BAD_SIGNATURE),
+ "verification failed: %d: %s", grub_errno, grub_errmsg);
+ grub_errno = GRUB_ERR_NONE;
+
+}
+static void
+signature_test (void)
+{
+ grub_procfs_register ("hi", &hi);
+ grub_procfs_register ("hj", &hj);
+ grub_procfs_register ("hi_dsa.pub", &hi_dsa_pub_entry);
+ grub_procfs_register ("hi_dsa.sig", &hi_dsa_sig_entry);
+ grub_procfs_register ("hi_rsa.pub", &hi_rsa_pub_entry);
+ grub_procfs_register ("hi_rsa.sig", &hi_rsa_sig_entry);
+
+ do_verify ("(proc)/hi", "(proc)/hi_dsa.sig", "(proc)/hi_dsa.pub", 1);
+ do_verify ("(proc)/hi", "(proc)/hi_dsa.sig", "(proc)/hi_dsa.pub", 1);
+ do_verify ("(proc)/hj", "(proc)/hi_dsa.sig", "(proc)/hi_dsa.pub", 0);
+
+ do_verify ("(proc)/hi", "(proc)/hi_rsa.sig", "(proc)/hi_rsa.pub", 1);
+ do_verify ("(proc)/hj", "(proc)/hi_rsa.sig", "(proc)/hi_rsa.pub", 0);
+
+ grub_procfs_unregister (&hi);
+ grub_procfs_unregister (&hj);
+ grub_procfs_unregister (&hi_dsa_sig_entry);
+ grub_procfs_unregister (&hi_dsa_pub_entry);
+}
+
+GRUB_FUNCTIONAL_TEST (signature_test, signature_test);
diff --git a/grub-core/tests/signatures.h b/grub-core/tests/signatures.h
new file mode 100644
index 0000000..d78c2b6
--- /dev/null
+++ b/grub-core/tests/signatures.h
@@ -0,0 +1,211 @@
+static unsigned char hi_rsa_sig[] =
+{
+0x89, 0x02, 0x1c, 0x04, 0x00, 0x01, 0x02, 0x00, 0x06, 0x05, 0x02, 0x52, 0x82, 0x2d, 0x16, 0x00,
+0x0a, 0x09, 0x10, 0x0f, 0xcc, 0xf3, 0x21, 0x77, 0x83, 0x6a, 0x0d, 0xdb, 0x5e, 0x10, 0x00, 0x80,
+0x36, 0x2c, 0xb0, 0xbf, 0x26, 0x36, 0xf2, 0x9d, 0x93, 0xa0, 0xbf, 0xcb, 0xa7, 0x0d, 0xbe, 0x67,
+0x33, 0xf6, 0xba, 0xec, 0x2b, 0xe9, 0x7e, 0x0e, 0xec, 0x51, 0xd5, 0xdd, 0x2d, 0x9a, 0x96, 0x09,
+0x8a, 0x7f, 0x02, 0xd5, 0xbc, 0xdb, 0xc9, 0xef, 0xd8, 0x90, 0x8a, 0xa8, 0x71, 0x6f, 0xaf, 0x8c,
+0xe5, 0x6a, 0xc4, 0xda, 0x2a, 0x1f, 0x17, 0xb1, 0x70, 0x69, 0x06, 0x2b, 0x2f, 0x18, 0x72, 0x72,
+0x28, 0xd6, 0x32, 0xa1, 0x96, 0x14, 0xd5, 0x2a, 0x52, 0x35, 0x4a, 0x3b, 0x8b, 0x6f, 0x0c, 0x24,
+0x97, 0xb7, 0x7f, 0xf6, 0x15, 0x8c, 0xbf, 0x69, 0x73, 0xee, 0x15, 0x0f, 0x07, 0x7e, 0x5e, 0x07,
+0x9b, 0x81, 0x28, 0x74, 0x49, 0x94, 0xd3, 0x05, 0xeb, 0xc9, 0x63, 0x70, 0x89, 0x91, 0x68, 0xe6,
+0x20, 0x32, 0x95, 0x00, 0x00, 0xc8, 0xba, 0xbd, 0x45, 0x77, 0x6b, 0x60, 0xa4, 0xa3, 0x05, 0x6b,
+0x70, 0x38, 0x07, 0x08, 0x8d, 0x09, 0xff, 0x5a, 0x55, 0xb2, 0x1f, 0xe2, 0xdf, 0xf0, 0x1b, 0x8d,
+0x40, 0xed, 0x52, 0x16, 0x3a, 0x7b, 0xb2, 0xbc, 0x3f, 0x21, 0x14, 0x58, 0xb0, 0x64, 0x6c, 0x33,
+0xcf, 0xdb, 0x93, 0x5a, 0x56, 0xa4, 0x3a, 0xd2, 0xcd, 0x22, 0x4a, 0x2f, 0x8e, 0x77, 0x2b, 0x0a,
+0x57, 0x43, 0x4b, 0x15, 0xab, 0xee, 0x3e, 0xa5, 0xf8, 0xff, 0xb9, 0xb2, 0x7d, 0x59, 0x84, 0x36,
+0x0a, 0x3b, 0x17, 0xda, 0x78, 0x50, 0x66, 0x62, 0xb9, 0x78, 0xad, 0x61, 0x3b, 0x26, 0xe9, 0x00,
+0x67, 0xd7, 0x3c, 0x75, 0xa4, 0xf3, 0x3a, 0x51, 0x4f, 0xd3, 0x0d, 0x04, 0xb8, 0x07, 0x7c, 0x06,
+0xcb, 0x22, 0x23, 0x4c, 0x1c, 0xa3, 0xb0, 0x03, 0x23, 0xdd, 0x50, 0xee, 0xd1, 0xc8, 0xff, 0xa0,
+0xc4, 0xa4, 0x68, 0x0d, 0xfc, 0xc5, 0x2e, 0x53, 0x33, 0x30, 0xb0, 0x56, 0x62, 0xb3, 0x9b, 0xa6,
+0x7f, 0x68, 0xb0, 0xbb, 0x67, 0x02, 0x41, 0x52, 0x05, 0x49, 0x9b, 0x4f, 0x61, 0x63, 0x48, 0xc4,
+0x5d, 0x62, 0x65, 0xef, 0xd1, 0xbf, 0xb5, 0x46, 0x96, 0xdc, 0x9a, 0xdf, 0xb9, 0xe9, 0x8f, 0xd3,
+0x6e, 0x12, 0x96, 0x31, 0x3c, 0x1a, 0xab, 0x04, 0xcf, 0x5e, 0x8d, 0x8c, 0xe4, 0x09, 0x6f, 0xcf,
+0xd7, 0xe8, 0x2e, 0x43, 0x53, 0x6a, 0x84, 0x3e, 0x28, 0x5b, 0xcc, 0x03, 0xb2, 0xae, 0xff, 0xc3,
+0xe4, 0x8a, 0x37, 0xa1, 0x88, 0xca, 0x0d, 0xa0, 0x2b, 0x64, 0xbd, 0x78, 0x78, 0x2a, 0x6e, 0x26,
+0x8f, 0x85, 0x69, 0x6a, 0xa9, 0xf2, 0xc4, 0xba, 0xf0, 0xed, 0xe9, 0xb9, 0x74, 0xbb, 0x95, 0xde,
+0x1c, 0xdc, 0x80, 0xf3, 0x46, 0x28, 0xf6, 0x4c, 0x01, 0x7a, 0x6d, 0x9a, 0x9a, 0xe1, 0xb8, 0x1b,
+0x9e, 0x4a, 0x28, 0x6c, 0x96, 0x59, 0xc6, 0x53, 0xe3, 0xc9, 0x7c, 0xaf, 0xf0, 0x22, 0x08, 0xb5,
+0xef, 0xad, 0xc8, 0x8d, 0x3a, 0x6c, 0x27, 0xf7, 0xfb, 0x3c, 0x4f, 0x9d, 0x05, 0x9a, 0x4b, 0x6b,
+0x88, 0xb3, 0x74, 0xca, 0xac, 0x9d, 0x76, 0x00, 0x58, 0x97, 0x69, 0x0d, 0x98, 0xe3, 0x40, 0x42,
+0xfc, 0xe8, 0x42, 0x38, 0xae, 0x04, 0x3b, 0xc1, 0x96, 0xf1, 0xd9, 0x19, 0x92, 0xc4, 0xb5, 0xeb,
+0x39, 0xd0, 0x7a, 0x5a, 0x3e, 0xf0, 0x0d, 0xba, 0x2f, 0x1e, 0x6e, 0xc7, 0xe4, 0x46, 0xe6, 0x3d,
+0x7c, 0x08, 0x6b, 0xea, 0xff, 0xf1, 0x78, 0xdf, 0x3b, 0xe9, 0xcb, 0x06, 0x5e, 0x30, 0xbd, 0x47,
+0xe3, 0x5c, 0xe2, 0x18, 0x01, 0xa5, 0xd5, 0x80, 0x74, 0x4e, 0x93, 0xe5, 0x86, 0xdb, 0x7c, 0x5f,
+0x0d, 0xd2, 0x6b, 0xdc, 0xa9, 0x91, 0x24, 0x2c, 0x09, 0x4f, 0xd1, 0xfa, 0xab, 0x96, 0x99, 0x2b,
+0x91, 0xda, 0xe1, 0x69, 0x6f, 0xd8, 0x1b, 0x28, 0x73, 0xb2, 0x51, 0xfa, 0xcf, 0xa7, 0x9e
+};
+
+static unsigned char hi_rsa_pub[] =
+{
+0x99, 0x02, 0x0d, 0x04, 0x52, 0x82, 0x2c, 0xee, 0x01, 0x10, 0x00, 0xbe, 0x0d, 0x60, 0xa0, 0x12,
+0x2f, 0x3c, 0x6a, 0x72, 0x29, 0x61, 0x26, 0xdd, 0x2e, 0x4e, 0x62, 0xad, 0xa6, 0xb3, 0x2b, 0x45,
+0x94, 0x94, 0x99, 0x2a, 0x6e, 0xd0, 0xda, 0x5f, 0xf6, 0x99, 0xee, 0xbe, 0x0e, 0x10, 0x42, 0xea,
+0x0b, 0x44, 0xac, 0x76, 0x06, 0x0b, 0x30, 0xd0, 0x2e, 0xd9, 0xe9, 0x2d, 0xfb, 0x5a, 0x3f, 0xfb,
+0xb5, 0xbc, 0xea, 0x8a, 0x2a, 0xfa, 0xe9, 0xef, 0x77, 0x94, 0x81, 0xc6, 0xbb, 0x4b, 0x12, 0x78,
+0xf3, 0xfe, 0x06, 0x93, 0x37, 0xa7, 0x38, 0x52, 0xab, 0xaa, 0xa3, 0xb4, 0x11, 0xbe, 0x5e, 0x77,
+0xdd, 0xe4, 0x98, 0x4c, 0x74, 0x4e, 0x1c, 0x62, 0xa8, 0x7a, 0x65, 0x6b, 0x09, 0xd7, 0x29, 0xae,
+0xaf, 0xe9, 0x7f, 0x94, 0x07, 0x01, 0x76, 0xfb, 0x7d, 0x2c, 0xf8, 0xe5, 0xce, 0x33, 0xb2, 0x7e,
+0x4c, 0x28, 0x41, 0x2c, 0xba, 0x73, 0x83, 0x2f, 0x61, 0x5e, 0xd9, 0x5c, 0xa6, 0x44, 0x54, 0x40,
+0xae, 0x7c, 0xa8, 0x0b, 0x01, 0x0f, 0x84, 0x1f, 0xfe, 0x72, 0x06, 0x51, 0xda, 0x15, 0x88, 0xa4,
+0x9e, 0x85, 0x06, 0x21, 0x2c, 0xe4, 0xe7, 0x2a, 0x04, 0x66, 0x3c, 0x31, 0x13, 0x02, 0x08, 0x1f,
+0x6c, 0x9b, 0xab, 0x97, 0xf8, 0x29, 0x51, 0xb5, 0x85, 0x76, 0x53, 0x83, 0x1f, 0x08, 0x46, 0xe7,
+0x03, 0x96, 0xa2, 0x64, 0x8a, 0xef, 0xc2, 0x52, 0xd8, 0x7e, 0xb9, 0x96, 0xc7, 0xbe, 0xbe, 0x81,
+0x4f, 0x22, 0x6a, 0xa6, 0xa9, 0xf8, 0x68, 0x11, 0x72, 0xb1, 0x5d, 0x5b, 0xe4, 0xc2, 0xeb, 0x09,
+0xb3, 0xb7, 0x0d, 0xc9, 0x1b, 0xfe, 0x39, 0x7b, 0x45, 0x96, 0xec, 0xd6, 0x37, 0x34, 0x4d, 0x1d,
+0xcc, 0x86, 0xfa, 0x2b, 0x69, 0x9c, 0x67, 0x55, 0x55, 0x56, 0xb4, 0x68, 0xf2, 0x0c, 0xf2, 0x84,
+0xd8, 0x27, 0x53, 0x4d, 0xae, 0xb1, 0xec, 0x5e, 0xdc, 0x24, 0x09, 0xb9, 0x2b, 0x3d, 0x28, 0x79,
+0xa0, 0x5d, 0x14, 0x4a, 0xe7, 0xff, 0x8b, 0x6f, 0xdf, 0xaf, 0x8b, 0x01, 0xc0, 0xac, 0xb6, 0xfb,
+0x6f, 0x98, 0xca, 0x20, 0x89, 0x22, 0x4e, 0x7d, 0x20, 0x62, 0x2a, 0xa0, 0x7c, 0xe2, 0xf4, 0xa7,
+0x1c, 0xfa, 0x3f, 0xc8, 0x8e, 0xd0, 0x54, 0x07, 0x73, 0xec, 0x8c, 0xb5, 0x4b, 0x4c, 0x50, 0x38,
+0x86, 0x27, 0x53, 0x39, 0x9f, 0x71, 0x3c, 0x5e, 0xd4, 0x03, 0x59, 0x22, 0x24, 0x62, 0x5d, 0x28,
+0x1b, 0x69, 0x75, 0x98, 0xfe, 0x01, 0xc2, 0x8c, 0x12, 0xc0, 0x25, 0x9c, 0x1e, 0xa0, 0x89, 0x15,
+0x26, 0x19, 0x15, 0x76, 0x2d, 0xdc, 0x69, 0x44, 0x49, 0x3e, 0x2d, 0xca, 0x1a, 0x14, 0x98, 0xf4,
+0x12, 0x52, 0xff, 0x38, 0x2e, 0x46, 0xfc, 0xed, 0x01, 0x4d, 0x40, 0x8a, 0x39, 0x57, 0x8e, 0x65,
+0xe9, 0x26, 0x0e, 0x27, 0x8a, 0x10, 0x99, 0x5d, 0x1f, 0xbd, 0xec, 0xbc, 0x63, 0xf8, 0x85, 0xcf,
+0xa0, 0x34, 0xb8, 0xe9, 0xd5, 0x4b, 0xf1, 0x4a, 0x47, 0xe7, 0xbe, 0x27, 0x9e, 0xe8, 0x3f, 0x96,
+0xcd, 0x6d, 0x11, 0x03, 0xd3, 0x08, 0xab, 0xdf, 0x32, 0x59, 0x16, 0x9c, 0xda, 0x68, 0xd7, 0x5d,
+0x30, 0x48, 0xbe, 0xa3, 0xe4, 0x0d, 0x95, 0xde, 0x5b, 0x54, 0xee, 0x10, 0x39, 0x5a, 0xc8, 0xb4,
+0x82, 0xde, 0x1c, 0xe5, 0x32, 0xc0, 0x73, 0x31, 0x3a, 0x25, 0xfe, 0xae, 0x1c, 0xca, 0x0d, 0x6d,
+0x5e, 0xf2, 0x1b, 0x95, 0x18, 0x88, 0xc3, 0x0a, 0x21, 0xc3, 0x5e, 0x0d, 0x2f, 0xc0, 0x30, 0xf5,
+0x53, 0xee, 0x0b, 0x0d, 0xb1, 0x99, 0x52, 0x47, 0xf0, 0x26, 0x4a, 0xfa, 0x61, 0x15, 0x2a, 0xbb,
+0xc4, 0x60, 0x23, 0xbe, 0x21, 0x2f, 0xff, 0x21, 0x34, 0x64, 0xb0, 0x17, 0x28, 0x61, 0x31, 0xf8,
+0xe4, 0xb2, 0x00, 0x3e, 0xb6, 0x89, 0x5f, 0x19, 0x03, 0x2e, 0x67, 0x00, 0x11, 0x01, 0x00, 0x01,
+0xb4, 0x22, 0x47, 0x4e, 0x55, 0x20, 0x47, 0x52, 0x55, 0x42, 0x20, 0x52, 0x53, 0x41, 0x20, 0x73,
+0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x20, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67,
+0x20, 0x6b, 0x65, 0x79, 0x89, 0x02, 0x38, 0x04, 0x13, 0x01, 0x02, 0x00, 0x22, 0x05, 0x02, 0x52,
+0x82, 0x2c, 0xee, 0x02, 0x1b, 0x03, 0x06, 0x0b, 0x09, 0x08, 0x07, 0x03, 0x02, 0x06, 0x15, 0x08,
+0x02, 0x09, 0x0a, 0x0b, 0x04, 0x16, 0x02, 0x03, 0x01, 0x02, 0x1e, 0x01, 0x02, 0x17, 0x80, 0x00,
+0x0a, 0x09, 0x10, 0x0f, 0xcc, 0xf3, 0x21, 0x77, 0x83, 0x6a, 0x0d, 0x14, 0x0a, 0x0f, 0xff, 0x45,
+0x11, 0xf5, 0x1a, 0x37, 0x13, 0xe8, 0x9a, 0x51, 0x1d, 0x77, 0x67, 0xa4, 0x71, 0xf1, 0x74, 0xaa,
+0xcf, 0xc7, 0xab, 0x34, 0x11, 0x01, 0x9b, 0xab, 0x45, 0x6d, 0xf6, 0x5e, 0xd4, 0x74, 0x42, 0x37,
+0x22, 0x8b, 0x8b, 0xb3, 0xf1, 0x36, 0x33, 0x25, 0xf0, 0x7d, 0x9b, 0xa7, 0xb6, 0x9b, 0x4e, 0xc2,
+0x22, 0xab, 0x02, 0x66, 0x60, 0x4a, 0xd3, 0xe9, 0xcb, 0xe6, 0xde, 0x72, 0x7a, 0x33, 0x62, 0x84,
+0x5e, 0x7b, 0xd8, 0x1f, 0xce, 0x7d, 0x37, 0x17, 0xee, 0xbe, 0x4b, 0x31, 0xe2, 0x1a, 0xf9, 0x8e,
+0x9b, 0xec, 0xc2, 0x9f, 0x35, 0xa6, 0x28, 0xc1, 0x81, 0x76, 0xdd, 0x0d, 0xaf, 0xc3, 0x62, 0xe8,
+0xf3, 0xa5, 0xd0, 0x4c, 0x10, 0x4c, 0xa4, 0x0b, 0x3e, 0xab, 0xd7, 0xcf, 0x7d, 0x99, 0x5a, 0x44,
+0xdd, 0xda, 0x62, 0x22, 0x41, 0x7f, 0x3f, 0x92, 0x9f, 0x49, 0xb0, 0xb7, 0x2d, 0x01, 0x1f, 0xbc,
+0xc9, 0xf7, 0x0a, 0xab, 0xe3, 0xe6, 0x17, 0xac, 0x4b, 0xcf, 0x65, 0x6d, 0xae, 0x51, 0x3d, 0xf1,
+0x0c, 0x94, 0x07, 0xfe, 0xc2, 0x4c, 0x10, 0x95, 0x5c, 0x9b, 0xfd, 0xfe, 0xed, 0x05, 0x4a, 0xfe,
+0xdf, 0xe6, 0x21, 0x12, 0x6f, 0x37, 0x5e, 0x52, 0xee, 0x15, 0x0b, 0x18, 0xf7, 0x74, 0x39, 0xac,
+0xab, 0x31, 0xfa, 0x52, 0x4c, 0x72, 0xa5, 0xb0, 0x5e, 0xc5, 0x69, 0xf2, 0x20, 0xd5, 0x0b, 0x4c,
+0x4c, 0xe8, 0xf0, 0xbc, 0xf6, 0x4f, 0x33, 0x75, 0x64, 0xcf, 0x93, 0x1b, 0x01, 0xdb, 0x02, 0xfb,
+0x81, 0x42, 0xa0, 0x24, 0x18, 0x21, 0x16, 0xb0, 0xe5, 0x3b, 0x22, 0xe4, 0xd7, 0x91, 0x1e, 0x07,
+0x37, 0x36, 0x52, 0x22, 0x8e, 0x49, 0x7a, 0xcf, 0xf2, 0x85, 0x20, 0x09, 0xc2, 0xc5, 0x31, 0x6b,
+0xcd, 0xe1, 0x87, 0x8b, 0xc1, 0xae, 0x20, 0x27, 0xa8, 0x59, 0x9f, 0x37, 0xc3, 0xe0, 0xbf, 0x40,
+0xe9, 0x9c, 0xe2, 0x77, 0xca, 0xa8, 0x5e, 0x46, 0x20, 0x88, 0xbd, 0x45, 0xbf, 0x60, 0xa7, 0x40,
+0x80, 0x28, 0x74, 0xd6, 0x34, 0x4c, 0xd4, 0x5c, 0x60, 0x1e, 0xf9, 0xbc, 0xa7, 0x6a, 0x8d, 0x08,
+0x99, 0xec, 0xb6, 0x5c, 0xdb, 0x1f, 0xf9, 0xe0, 0x06, 0x26, 0x1d, 0x04, 0x6f, 0x1d, 0x84, 0x0c,
+0x8b, 0x6e, 0x8d, 0x06, 0xc0, 0x83, 0x2b, 0x7c, 0xdf, 0x2c, 0x4a, 0xac, 0x2d, 0xe4, 0xcd, 0xa4,
+0x55, 0xd1, 0xcd, 0x54, 0x8a, 0xaa, 0x04, 0x53, 0x23, 0xa8, 0x9c, 0x67, 0x28, 0xa7, 0x11, 0x76,
+0xd3, 0x2f, 0x17, 0x2a, 0x40, 0xac, 0x06, 0xe1, 0x47, 0x30, 0xd0, 0x9c, 0xba, 0x9c, 0x9c, 0xaf,
+0x22, 0xe0, 0x68, 0xa5, 0x72, 0xf0, 0xf1, 0x8c, 0xe3, 0xbe, 0xc6, 0xed, 0xfa, 0xad, 0x72, 0xf8,
+0xab, 0x49, 0x5e, 0x4d, 0xed, 0x88, 0x41, 0xb2, 0x7c, 0x95, 0x69, 0x63, 0x1c, 0xd8, 0x90, 0x9d,
+0xc6, 0x4a, 0x42, 0x30, 0x91, 0x7b, 0x58, 0x30, 0xfa, 0x32, 0xf6, 0xd6, 0xc2, 0xe9, 0x74, 0xfa,
+0xe8, 0x81, 0x3d, 0xdc, 0xb6, 0x3f, 0xbc, 0x88, 0x3e, 0x01, 0xbc, 0x47, 0x75, 0x36, 0xf0, 0x28,
+0x4f, 0x14, 0xd6, 0xa1, 0xc5, 0x3d, 0xb2, 0x74, 0x82, 0xfd, 0xad, 0x94, 0xb3, 0x14, 0x16, 0x61,
+0xef, 0x77, 0x77, 0x25, 0x03, 0xc1, 0x8e, 0x71, 0x55, 0xa5, 0x31, 0x40, 0x50, 0x49, 0x3f, 0xf5,
+0x40, 0x7f, 0x97, 0x4f, 0xef, 0x47, 0xa2, 0x12, 0x0c, 0x1d, 0x23, 0x51, 0x47, 0x53, 0x0b, 0x72,
+0xc2, 0xd3, 0x39, 0xbb, 0xa9, 0xea, 0x8c, 0x16, 0x93, 0x67, 0xb1, 0xcf, 0x8a, 0x96, 0xba, 0x1e,
+0xef, 0x20, 0x3f, 0xee, 0xda, 0x69, 0xd1, 0x4d, 0xf4, 0x9c, 0x41, 0x73, 0xcb, 0xaf, 0x1b, 0x29,
+0x22, 0x1f, 0x94, 0xa4, 0x67, 0xd7, 0x53, 0xb1, 0x65, 0x23, 0x69, 0x05, 0x31, 0x2e, 0xd4
+};
+
+static unsigned char hi_dsa_sig[] =
+{
+0x88, 0x5e, 0x04, 0x00, 0x11, 0x08, 0x00, 0x06, 0x05, 0x02, 0x52, 0x82, 0x2c, 0x7f, 0x00, 0x0a,
+0x09, 0x10, 0xef, 0xe0, 0xfc, 0x1f, 0xf6, 0xe7, 0xf5, 0xad, 0xb0, 0x47, 0x01, 0x00, 0xcd, 0xfd,
+0x1f, 0x8b, 0x16, 0x7f, 0x31, 0x7f, 0xc3, 0xe1, 0x6d, 0xcd, 0xc5, 0x4f, 0xf4, 0x1b, 0xf5, 0x4e,
+0x61, 0x79, 0xb5, 0x14, 0xdd, 0xf5, 0xe5, 0x27, 0x21, 0xf6, 0xc7, 0x95, 0xc6, 0x9b, 0x00, 0xff,
+0x61, 0x4d, 0x01, 0x6f, 0xbb, 0x88, 0xf9, 0x38, 0x84, 0x00, 0xab, 0xab, 0x2f, 0x16, 0x53, 0x5c,
+0xe9, 0x3d, 0x85, 0x34, 0x0d, 0x36, 0x80, 0x77, 0x62, 0x4e, 0x4f, 0xdb, 0x48, 0x64, 0x58, 0x82
+};
+
+static unsigned char hi_dsa_pub[] =
+{
+0x99, 0x04, 0xae, 0x04, 0x52, 0x82, 0x2b, 0xe6, 0x11, 0x0c, 0x00, 0xcc, 0x6b, 0xfe, 0xc3, 0xed,
+0x23, 0xb8, 0x09, 0xa8, 0xcd, 0x00, 0x8a, 0xd7, 0x4d, 0xe5, 0x37, 0x03, 0xab, 0x99, 0x64, 0xc5,
+0xde, 0xef, 0x47, 0xfd, 0x06, 0xe1, 0xc2, 0x70, 0x77, 0x5f, 0x78, 0x46, 0x62, 0x9e, 0x5e, 0x84,
+0x48, 0xdf, 0xc2, 0xef, 0xd3, 0xf3, 0xc3, 0x97, 0x92, 0x83, 0xa7, 0xad, 0xf7, 0x4e, 0x43, 0xac,
+0x06, 0xcb, 0x18, 0x4b, 0xe4, 0x05, 0x45, 0x01, 0x3d, 0x34, 0x51, 0x59, 0xf5, 0xfb, 0x42, 0xad,
+0xe5, 0x7c, 0xf4, 0xe3, 0xd6, 0x6d, 0x4e, 0xd7, 0x3d, 0xbc, 0x87, 0x0b, 0x94, 0xe7, 0x70, 0x55,
+0x3c, 0x7c, 0xef, 0x1e, 0x9c, 0xa1, 0x0b, 0x17, 0x8c, 0x0d, 0x62, 0x08, 0x8f, 0x5a, 0x93, 0x2a,
+0x0e, 0xde, 0xad, 0x7d, 0x60, 0xe7, 0x5c, 0xe7, 0xf3, 0xb0, 0x2f, 0xef, 0xc1, 0xc9, 0x5f, 0x71,
+0xf9, 0xa7, 0x33, 0x30, 0x78, 0x3a, 0xb2, 0x83, 0xd9, 0xe5, 0xc1, 0x6b, 0xb4, 0xaa, 0x13, 0xe0,
+0xdb, 0x2a, 0xd8, 0x81, 0xfc, 0x96, 0xd6, 0x3a, 0x73, 0xba, 0x34, 0xe4, 0xf8, 0xc1, 0xf5, 0xac,
+0x2e, 0x4c, 0x95, 0x52, 0x28, 0x03, 0xe7, 0x01, 0xc8, 0x5e, 0x1c, 0x1c, 0xbd, 0xd3, 0xe5, 0xf8,
+0xf2, 0xc5, 0xbf, 0x61, 0x01, 0x22, 0x3c, 0x57, 0xd5, 0x6a, 0x17, 0x29, 0x3e, 0x00, 0xfc, 0xb4,
+0x97, 0x7f, 0x45, 0xa4, 0x6c, 0x53, 0xd5, 0xd2, 0x56, 0xce, 0x4f, 0x1b, 0xcf, 0xc2, 0x0b, 0x83,
+0x09, 0xf6, 0xc1, 0x95, 0xea, 0x2a, 0x47, 0xe0, 0xa6, 0x8e, 0xc5, 0x74, 0x6e, 0x8e, 0xa4, 0x10,
+0x3a, 0x99, 0xfb, 0x9e, 0xcc, 0x06, 0xa7, 0x70, 0xef, 0xe8, 0xf6, 0x72, 0xba, 0xd4, 0x0c, 0x11,
+0x47, 0x17, 0x6b, 0x2d, 0xde, 0xa1, 0xfd, 0x41, 0x87, 0x18, 0x33, 0x6c, 0x26, 0xd2, 0xdc, 0xc7,
+0x8f, 0x4f, 0x91, 0xc1, 0x02, 0x38, 0x42, 0xe5, 0x35, 0xaf, 0xef, 0x90, 0xde, 0x94, 0xa3, 0x3c,
+0xde, 0x61, 0x67, 0xb3, 0x26, 0xe2, 0xfc, 0x2d, 0x96, 0x35, 0xfd, 0x00, 0xb1, 0x02, 0xe7, 0xb4,
+0xd4, 0xf4, 0xb7, 0x67, 0xaa, 0xd4, 0x00, 0xfa, 0xcf, 0x9b, 0xbe, 0xbb, 0xad, 0xac, 0x8e, 0xe3,
+0xab, 0xf1, 0x80, 0xaf, 0xe2, 0xb1, 0x93, 0x09, 0xd0, 0x40, 0xde, 0xab, 0x53, 0xcf, 0xa7, 0x45,
+0x1a, 0x8b, 0xdb, 0x0f, 0xff, 0xd4, 0xdf, 0x6b, 0xe9, 0x2c, 0x40, 0x8e, 0x24, 0x03, 0x62, 0x75,
+0x0f, 0x2c, 0x8b, 0x8e, 0x9e, 0xd0, 0x91, 0x5a, 0x91, 0x68, 0xcb, 0x16, 0x45, 0xca, 0x8f, 0xdd,
+0x5e, 0x61, 0x71, 0xa7, 0x8d, 0xa3, 0xf4, 0xf7, 0xa3, 0xee, 0x5d, 0x4c, 0x8a, 0xee, 0x5b, 0x5f,
+0x1e, 0xfc, 0xbe, 0x3d, 0x94, 0xab, 0x30, 0x02, 0x6f, 0x72, 0x57, 0x03, 0x2a, 0xaf, 0x9c, 0x28,
+0x12, 0x55, 0x00, 0xd5, 0x0a, 0x2a, 0x02, 0x4e, 0xf0, 0xc0, 0x67, 0x01, 0x00, 0xd3, 0xaf, 0x3f,
+0xcf, 0x8c, 0x64, 0x59, 0x9d, 0xe5, 0x7b, 0x0b, 0xa0, 0xa0, 0x46, 0xb3, 0xc0, 0xf6, 0x25, 0xde,
+0x2d, 0xfa, 0x27, 0xf6, 0xf1, 0xca, 0x3c, 0xd3, 0x56, 0x6e, 0xc0, 0xd4, 0x49, 0x0b, 0xfc, 0x0f,
+0x23, 0xbf, 0xe1, 0x00, 0x63, 0xb5, 0x04, 0x40, 0x04, 0x5c, 0x9e, 0xce, 0x0b, 0x75, 0xca, 0xfe,
+0xd9, 0xb7, 0xe1, 0xcc, 0x27, 0x20, 0xf4, 0x4c, 0x61, 0x10, 0x17, 0x2b, 0xb7, 0x5d, 0x0d, 0xc2,
+0xac, 0x37, 0x4e, 0x7f, 0x81, 0x4a, 0xde, 0x06, 0x6f, 0xb7, 0x61, 0xcc, 0x9e, 0xdd, 0x6a, 0x3e,
+0x88, 0x55, 0x66, 0x8a, 0x87, 0xc1, 0x26, 0xf3, 0xe2, 0xd8, 0xdf, 0x80, 0xfa, 0x82, 0x6f, 0x25,
+0x89, 0x94, 0xe7, 0xff, 0x79, 0xb6, 0x08, 0x5e, 0x45, 0x46, 0x9a, 0x74, 0xde, 0xa8, 0xa3, 0xc8,
+0x8f, 0x6f, 0x8f, 0x8e, 0xf5, 0x1f, 0xab, 0x3d, 0x21, 0xd5, 0xec, 0x34, 0x86, 0x6c, 0xbd, 0x92,
+0x44, 0x9d, 0x73, 0x46, 0xcb, 0xa0, 0x5c, 0x05, 0xd5, 0x12, 0xf0, 0xe9, 0xc7, 0x65, 0xa7, 0xe3,
+0x4d, 0x82, 0x8f, 0x54, 0x7e, 0x7b, 0x51, 0x46, 0xca, 0x50, 0x22, 0x24, 0x2e, 0x90, 0x5e, 0x33,
+0xd7, 0x0f, 0xca, 0x42, 0x82, 0x7e, 0x74, 0x20, 0xae, 0x49, 0xa4, 0x0a, 0xc5, 0x90, 0xd5, 0xf8,
+0x45, 0x32, 0x5f, 0xda, 0xf8, 0xf5, 0xb0, 0xa2, 0x43, 0x77, 0x7a, 0x65, 0xf9, 0x59, 0xaa, 0x91,
+0xe1, 0xd9, 0x7f, 0xbc, 0x8c, 0xa6, 0xb6, 0x71, 0x68, 0xc3, 0xe5, 0x36, 0xee, 0xa3, 0x47, 0xe0,
+0x4f, 0x48, 0xb3, 0xf1, 0x8d, 0x41, 0xb0, 0xbc, 0x14, 0xb0, 0x15, 0x21, 0x35, 0xc3, 0x2c, 0xc7,
+0x37, 0x23, 0x03, 0xb9, 0xfb, 0xb9, 0xdc, 0x7b, 0x7a, 0x89, 0x44, 0x01, 0x1b, 0xa7, 0x87, 0x5f,
+0xe2, 0xc1, 0x02, 0x53, 0xcd, 0xd5, 0x56, 0xcd, 0x8c, 0x56, 0x6d, 0xa6, 0x90, 0xf6, 0x26, 0xff,
+0x8e, 0x6d, 0x5f, 0x60, 0x9e, 0x8f, 0x2c, 0x71, 0xa5, 0xff, 0xd9, 0x77, 0x67, 0x9e, 0x09, 0x93,
+0xa4, 0x7c, 0x23, 0x1d, 0x55, 0x18, 0x5a, 0x54, 0x41, 0x88, 0x8e, 0x2d, 0xc6, 0x87, 0x67, 0x43,
+0xd4, 0x3d, 0xaf, 0x85, 0x3b, 0xda, 0x46, 0x02, 0x4a, 0x33, 0x46, 0x62, 0x1e, 0x9e, 0x66, 0xc9,
+0x5a, 0x96, 0xf8, 0xa9, 0xbd, 0x4a, 0x81, 0x92, 0x40, 0x9e, 0xc3, 0xa5, 0x3d, 0x99, 0xc5, 0xf1,
+0xd7, 0x6d, 0xc9, 0x29, 0x7d, 0x2c, 0xdf, 0x1e, 0xc9, 0xe4, 0x6d, 0x83, 0xd1, 0xc4, 0xaa, 0x9f,
+0xe3, 0x0e, 0x0a, 0x87, 0x49, 0x89, 0x6a, 0xc0, 0xc7, 0x73, 0x19, 0x91, 0x2d, 0xa5, 0x0b, 0xbf,
+0x4f, 0x52, 0x46, 0x54, 0xd7, 0x9c, 0x97, 0x77, 0x32, 0xab, 0xd3, 0x74, 0x14, 0x9d, 0xbc, 0xa9,
+0x4a, 0xd9, 0x5f, 0x8b, 0xd7, 0xf8, 0x63, 0xf4, 0x3e, 0xde, 0x79, 0x8a, 0xae, 0x65, 0x0c, 0x18,
+0xe3, 0x8d, 0x21, 0x7d, 0x95, 0x59, 0xf1, 0xe0, 0xb6, 0xa3, 0x52, 0xa3, 0x46, 0x91, 0x94, 0x31,
+0x0e, 0x6c, 0xb3, 0x84, 0xa2, 0x26, 0x49, 0x06, 0xb7, 0x2b, 0x4c, 0x93, 0xf3, 0x60, 0xaa, 0x0c,
+0x00, 0x97, 0x4f, 0x05, 0x06, 0xc3, 0x97, 0x32, 0x4b, 0xbe, 0x18, 0x84, 0x7a, 0x51, 0x1b, 0xb0,
+0xe6, 0x94, 0x3a, 0xd7, 0x7b, 0xa8, 0xd0, 0x21, 0x19, 0x54, 0x78, 0x19, 0x2b, 0xe5, 0xc6, 0x92,
+0xb7, 0xc5, 0x1e, 0x72, 0x33, 0x78, 0xe8, 0x13, 0x11, 0x14, 0x43, 0x9e, 0x3c, 0x6b, 0x3f, 0x25,
+0x67, 0xe4, 0x6e, 0x5e, 0xe0, 0x7a, 0x3c, 0x06, 0xdc, 0x2e, 0x06, 0x6e, 0x9c, 0x8e, 0xf0, 0xc6,
+0xfb, 0xc6, 0x2d, 0x63, 0x1b, 0x4f, 0x66, 0x72, 0x7d, 0xc9, 0x0e, 0x38, 0xc4, 0x17, 0x07, 0x49,
+0xc9, 0x7d, 0xab, 0x3a, 0xed, 0xf2, 0xeb, 0xeb, 0x6d, 0xa7, 0xb0, 0x97, 0x88, 0x08, 0x0d, 0x0b,
+0xdc, 0x07, 0x32, 0xe2, 0x62, 0xf5, 0x4e, 0x46, 0xe7, 0x13, 0x85, 0x01, 0x92, 0xee, 0x26, 0x67,
+0x0d, 0xb0, 0x85, 0xa8, 0xa1, 0x26, 0x49, 0x14, 0xa3, 0xde, 0x95, 0xd7, 0xeb, 0xcf, 0x85, 0xb2,
+0xdf, 0x3f, 0x76, 0x16, 0x75, 0x20, 0x47, 0xb1, 0x80, 0x04, 0x1e, 0x2f, 0xa2, 0xde, 0xb2, 0x5f,
+0x50, 0x83, 0xd2, 0x45, 0xad, 0x8d, 0x08, 0xf4, 0xe2, 0xfb, 0xac, 0x13, 0x2b, 0x6f, 0x3a, 0xfe,
+0xa7, 0x18, 0xfc, 0x11, 0xe0, 0x46, 0xdd, 0x53, 0x82, 0x3b, 0xd4, 0x0b, 0xf2, 0xec, 0x6c, 0xd0,
+0xbd, 0xea, 0xdf, 0xfa, 0xd2, 0x52, 0xf8, 0xa5, 0x4a, 0x49, 0xae, 0x2f, 0x1e, 0xb0, 0x9d, 0x61,
+0x7a, 0x26, 0x6f, 0x0e, 0x97, 0xe6, 0x74, 0xa8, 0x39, 0x51, 0x6d, 0xe6, 0x4a, 0xbf, 0x7f, 0xb1,
+0x4f, 0xa1, 0x2e, 0xaf, 0x1d, 0x0c, 0x20, 0x69, 0xac, 0xd1, 0x0c, 0xa0, 0x5e, 0x97, 0x8f, 0xa0,
+0x9c, 0x22, 0x72, 0x96, 0x05, 0x34, 0xf2, 0x7c, 0xc8, 0xda, 0x71, 0x00, 0xf4, 0x82, 0x5f, 0xac,
+0x36, 0x8e, 0x2b, 0xf7, 0xa6, 0xac, 0x94, 0x97, 0x75, 0xef, 0x8b, 0xfa, 0xaf, 0xb7, 0x19, 0x7f,
+0x10, 0xaa, 0x38, 0x11, 0x2b, 0x81, 0x81, 0xbf, 0x78, 0x93, 0xa7, 0x8e, 0xda, 0x57, 0xc8, 0xfc,
+0xbc, 0x85, 0xa6, 0x26, 0x0b, 0xcd, 0xce, 0xbf, 0xa5, 0x3f, 0x29, 0x03, 0x85, 0x2d, 0xd4, 0xa0,
+0x26, 0xad, 0x9c, 0x9a, 0x6b, 0xb3, 0x01, 0xd0, 0x1c, 0x7a, 0xf2, 0x48, 0x31, 0x04, 0x40, 0x09,
+0x02, 0x0b, 0xe3, 0x3c, 0x65, 0xf5, 0x39, 0xae, 0x25, 0x2e, 0x42, 0xa3, 0x43, 0x50, 0x80, 0xbb,
+0x36, 0x4c, 0xf9, 0x04, 0xec, 0x52, 0x37, 0xc1, 0x00, 0x92, 0x4a, 0x5a, 0x56, 0xfb, 0x50, 0x54,
+0x26, 0x3c, 0xa5, 0x3a, 0x22, 0x4f, 0x6b, 0x17, 0x5b, 0x64, 0xd5, 0xfd, 0xa4, 0x1b, 0x32, 0x22,
+0x16, 0x97, 0x0e, 0xfd, 0x92, 0xae, 0x5e, 0xd0, 0x5b, 0x4b, 0xf9, 0x26, 0x2e, 0x46, 0x12, 0x8d,
+0x91, 0x80, 0xe8, 0x71, 0xbf, 0xf7, 0xc2, 0x8e, 0xed, 0x60, 0xd2, 0x17, 0x53, 0xd1, 0x8b, 0xc9,
+0x08, 0xb4, 0x1d, 0x47, 0x4e, 0x55, 0x20, 0x47, 0x52, 0x55, 0x42, 0x20, 0x44, 0x53, 0x41, 0x20,
+0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x6b, 0x65, 0x79,
+0x88, 0x7a, 0x04, 0x13, 0x11, 0x08, 0x00, 0x22, 0x05, 0x02, 0x52, 0x82, 0x2b, 0xe6, 0x02, 0x1b,
+0x03, 0x06, 0x0b, 0x09, 0x08, 0x07, 0x03, 0x02, 0x06, 0x15, 0x08, 0x02, 0x09, 0x0a, 0x0b, 0x04,
+0x16, 0x02, 0x03, 0x01, 0x02, 0x1e, 0x01, 0x02, 0x17, 0x80, 0x00, 0x0a, 0x09, 0x10, 0xef, 0xe0,
+0xfc, 0x1f, 0xf6, 0xe7, 0xf5, 0xad, 0xd6, 0x91, 0x01, 0x00, 0x94, 0x10, 0x43, 0xf9, 0xc9, 0x37,
+0x40, 0x47, 0xe1, 0xba, 0xf7, 0x92, 0x4b, 0xe1, 0xea, 0x94, 0xee, 0x81, 0x90, 0x8f, 0xe7, 0x76,
+0xc8, 0x30, 0x3d, 0x7e, 0xa0, 0xf5, 0xad, 0x2a, 0x52, 0x60, 0x00, 0xff, 0x75, 0x6c, 0x2d, 0xf5,
+0xab, 0x41, 0x83, 0x29, 0x4f, 0x37, 0x16, 0x1b, 0x26, 0x28, 0x55, 0x03, 0xfe, 0x30, 0x89, 0xce,
+0x70, 0x6e, 0x1a, 0x11, 0x4a, 0xb6, 0xa5, 0x17, 0x9f, 0xbe, 0x3d, 0x1d
+};
diff --git a/grub-core/tests/sleep_test.c b/grub-core/tests/sleep_test.c
new file mode 100644
index 0000000..ffb2681
--- /dev/null
+++ b/grub-core/tests/sleep_test.c
@@ -0,0 +1,51 @@
+/*
+ * 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/time.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/env.h>
+#include <grub/test.h>
+#include <grub/mm.h>
+#include <grub/datetime.h>
+#include <grub/time.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static void
+sleep_test (void)
+{
+ struct grub_datetime st, en;
+ grub_int64_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");
+ 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: %" PRIdGRUB_INT64_T, enu - stu);
+}
+
+GRUB_FUNCTIONAL_TEST (sleep_test, sleep_test);
diff --git a/grub-core/tests/strtoull_test.c b/grub-core/tests/strtoull_test.c
new file mode 100644
index 0000000..5488ab2
--- /dev/null
+++ b/grub-core/tests/strtoull_test.c
@@ -0,0 +1,63 @@
+/*
+ * 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/test.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static void
+strtoull_testcase (const char *input, int base, unsigned long long expected,
+ int num_digits, grub_err_t error)
+{
+ const char *output;
+ unsigned long long value;
+ grub_errno = 0;
+ value = grub_strtoull(input, &output, base);
+ grub_test_assert (grub_errno == error,
+ "unexpected error. Expected %d, got %d. Input \"%s\"",
+ error, grub_errno, input);
+ if (grub_errno)
+ {
+ grub_errno = 0;
+ return;
+ }
+ grub_test_assert (input + num_digits == output,
+ "unexpected number of digits. Expected %d, got %d, input \"%s\"",
+ num_digits, (int) (output - input), input);
+ grub_test_assert (value == expected,
+ "unexpected return value. Expected %llu, got %llu, input \"\%s\"",
+ expected, value, input);
+}
+
+static void
+strtoull_test (void)
+{
+ strtoull_testcase ("9", 0, 9, 1, GRUB_ERR_NONE);
+ strtoull_testcase ("0xaa", 0, 0xaa, 4, GRUB_ERR_NONE);
+ strtoull_testcase ("0xff", 0, 0xff, 4, GRUB_ERR_NONE);
+ strtoull_testcase ("0", 10, 0, 1, GRUB_ERR_NONE);
+ strtoull_testcase ("8", 8, 0, 0, GRUB_ERR_BAD_NUMBER);
+ strtoull_testcase ("38", 8, 3, 1, GRUB_ERR_NONE);
+ strtoull_testcase ("7", 8, 7, 1, GRUB_ERR_NONE);
+ strtoull_testcase ("1]", 16, 1, 1, GRUB_ERR_NONE);
+ strtoull_testcase ("18446744073709551616", 10, 0, 0, GRUB_ERR_OUT_OF_RANGE);
+}
+
+
+GRUB_FUNCTIONAL_TEST (strtoull_test, strtoull_test);
diff --git a/grub-core/tests/test_blockarg.c b/grub-core/tests/test_blockarg.c
new file mode 100644
index 0000000..88bd968
--- /dev/null
+++ b/grub-core/tests/test_blockarg.c
@@ -0,0 +1,55 @@
+/* test_blockarg.c - print and execute block argument */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/err.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/extcmd.h>
+#include <grub/script_sh.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+test_blockarg (grub_extcmd_context_t ctxt, int argc, char **args)
+{
+ if (! ctxt->script)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "no block parameter");
+
+ grub_printf ("%s\n", args[argc - 1]);
+ grub_script_execute (ctxt->script);
+ return GRUB_ERR_NONE;
+}
+
+static grub_extcmd_t cmd;
+
+GRUB_MOD_INIT(test_blockarg)
+{
+ cmd = grub_register_extcmd ("test_blockarg", test_blockarg,
+ GRUB_COMMAND_FLAG_BLOCKS,
+ N_("BLOCK"),
+ /* TRANSLATORS: this is the BLOCK-argument, not
+ environment block. */
+ N_("Print and execute block argument."), 0);
+}
+
+GRUB_MOD_FINI(test_blockarg)
+{
+ grub_unregister_extcmd (cmd);
+}
diff --git a/grub-core/tests/video_checksum.c b/grub-core/tests/video_checksum.c
new file mode 100644
index 0000000..44d0810
--- /dev/null
+++ b/grub-core/tests/video_checksum.c
@@ -0,0 +1,813 @@
+/*
+ * 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/>.
+ */
+
+/* All tests need to include test.h for GRUB testing framework. */
+
+#include <config.h>
+
+#include <grub/test.h>
+#include <grub/dl.h>
+#include <grub/video.h>
+#include <grub/lib/crc.h>
+#include <grub/mm.h>
+#include <grub/term.h>
+#ifdef GRUB_MACHINE_EMU
+#include <grub/emu/hostdisk.h>
+#include <grub/emu/misc.h>
+#endif
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static int ctr;
+static int nchk;
+static char *basename;
+static const grub_uint32_t *checksums;
+static struct grub_video_mode_info capt_mode_info;
+
+struct grub_video_mode_info grub_test_video_modes[GRUB_TEST_VIDEO_ALL_N_MODES] = {
+ {
+ .width = 640,
+ .height = 480,
+ .pitch = 640,
+ .mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR,
+ .bpp = 8,
+ .bytes_per_pixel = 1,
+ .number_of_colors = GRUB_VIDEO_FBSTD_NUMCOLORS
+ },
+ {
+ .width = 800,
+ .height = 600,
+ .pitch = 800,
+ .mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR,
+ .bpp = 8,
+ .bytes_per_pixel = 1,
+ .number_of_colors = GRUB_VIDEO_FBSTD_NUMCOLORS
+ },
+ {
+ .width = 1024,
+ .height = 768,
+ .pitch = 1024,
+ .mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR,
+ .bpp = 8,
+ .bytes_per_pixel = 1,
+ .number_of_colors = GRUB_VIDEO_FBSTD_NUMCOLORS
+ },
+ {
+ .width = 640,
+ .height = 480,
+ .pitch = 640 * 4,
+ GRUB_VIDEO_MI_RGBA8888()
+ },
+ {
+ .width = 800,
+ .height = 600,
+ .pitch = 800 * 4,
+ GRUB_VIDEO_MI_RGBA8888()
+ },
+ {
+ .width = 1024,
+ .height = 768,
+ .pitch = 1024 * 4,
+ GRUB_VIDEO_MI_RGBA8888()
+ },
+ {
+ .width = 2560,
+ .height = 1440,
+ .pitch = 2560 * 4,
+ GRUB_VIDEO_MI_RGBA8888()
+ },
+ {
+ .width = 640,
+ .height = 480,
+ .pitch = 640,
+ .mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR,
+ .bpp = 8,
+ .bytes_per_pixel = 1,
+ .number_of_colors = GRUB_VIDEO_FBSTD_EXT_NUMCOLORS
+ },
+ {
+ .width = 800,
+ .height = 600,
+ .pitch = 800,
+ .mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR,
+ .bpp = 8,
+ .bytes_per_pixel = 1,
+ .number_of_colors = GRUB_VIDEO_FBSTD_EXT_NUMCOLORS
+ },
+ {
+ .width = 1024,
+ .height = 768,
+ .pitch = 1024,
+ .mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR,
+ .bpp = 8,
+ .bytes_per_pixel = 1,
+ .number_of_colors = GRUB_VIDEO_FBSTD_EXT_NUMCOLORS
+ },
+
+
+
+
+ {
+ .width = 640,
+ .height = 480,
+ .pitch = 1280,
+ GRUB_VIDEO_MI_RGB555 ()
+ },
+ {
+ .width = 800,
+ .height = 600,
+ .pitch = 1600,
+ GRUB_VIDEO_MI_RGB555 ()
+ },
+ {
+ .width = 1024,
+ .height = 768,
+ .pitch = 2048,
+ GRUB_VIDEO_MI_RGB555 ()
+ },
+ {
+ .width = 640,
+ .height = 480,
+ .pitch = 1280,
+ GRUB_VIDEO_MI_RGB565 ()
+ },
+ {
+ .width = 800,
+ .height = 600,
+ .pitch = 1600,
+ GRUB_VIDEO_MI_RGB565 ()
+ },
+ {
+ .width = 1024,
+ .height = 768,
+ .pitch = 2048,
+ GRUB_VIDEO_MI_RGB565 ()
+ },
+ {
+ .width = 640,
+ .height = 480,
+ .pitch = 640 * 3,
+ GRUB_VIDEO_MI_RGB888 ()
+ },
+ {
+ .width = 800,
+ .height = 600,
+ .pitch = 800 * 3,
+ GRUB_VIDEO_MI_RGB888 ()
+ },
+ {
+ .width = 1024,
+ .height = 768,
+ .pitch = 1024 * 3,
+ GRUB_VIDEO_MI_RGB888 ()
+ },
+ {
+ .width = 640,
+ .height = 480,
+ .pitch = 1280,
+ GRUB_VIDEO_MI_BGR555 ()
+ },
+ {
+ .width = 800,
+ .height = 600,
+ .pitch = 1600,
+ GRUB_VIDEO_MI_BGR555 ()
+ },
+ {
+ .width = 1024,
+ .height = 768,
+ .pitch = 2048,
+ GRUB_VIDEO_MI_BGR555 ()
+ },
+ {
+ .width = 640,
+ .height = 480,
+ .pitch = 1280,
+ GRUB_VIDEO_MI_BGR565 ()
+ },
+ {
+ .width = 800,
+ .height = 600,
+ .pitch = 1600,
+ GRUB_VIDEO_MI_BGR565 ()
+ },
+ {
+ .width = 1024,
+ .height = 768,
+ .pitch = 2048,
+ GRUB_VIDEO_MI_BGR565 ()
+ },
+ {
+ .width = 640,
+ .height = 480,
+ .pitch = 640 * 3,
+ GRUB_VIDEO_MI_BGR888 ()
+ },
+ {
+ .width = 800,
+ .height = 600,
+ .pitch = 800 * 3,
+ GRUB_VIDEO_MI_BGR888 ()
+ },
+ {
+ .width = 1024,
+ .height = 768,
+ .pitch = 1024 * 3,
+ GRUB_VIDEO_MI_BGR888 ()
+ },
+ {
+ .width = 640,
+ .height = 480,
+ .pitch = 640 * 4,
+ GRUB_VIDEO_MI_BGRA8888()
+ },
+ {
+ .width = 800,
+ .height = 600,
+ .pitch = 800 * 4,
+ GRUB_VIDEO_MI_BGRA8888()
+ },
+ {
+ .width = 1024,
+ .height = 768,
+ .pitch = 1024 * 4,
+ GRUB_VIDEO_MI_BGRA8888()
+ },
+};
+
+#ifdef GRUB_MACHINE_EMU
+#include <grub/emu/hostfile.h>
+
+struct bmp_header
+{
+ grub_uint8_t magic[2];
+ grub_uint32_t filesize;
+ grub_uint32_t reserved;
+ grub_uint32_t bmp_off;
+ grub_uint32_t head_size;
+ grub_uint16_t width;
+ grub_uint16_t height;
+ grub_uint16_t planes;
+ grub_uint16_t bpp;
+} GRUB_PACKED;
+
+static void
+grub_video_capture_write_bmp (const char *fname,
+ void *ptr,
+ const struct grub_video_mode_info *mode_info)
+{
+ grub_util_fd_t fd = grub_util_fd_open (fname, GRUB_UTIL_FD_O_WRONLY | GRUB_UTIL_FD_O_CREATTRUNC);
+ struct bmp_header head;
+
+ if (!GRUB_UTIL_FD_IS_VALID (fd))
+ {
+ grub_printf (_("cannot open `%s': %s"),
+ fname, grub_util_fd_strerror ());
+ }
+
+ grub_memset (&head, 0, sizeof (head));
+
+ head.magic[0] = 'B';
+ head.magic[1] = 'M';
+
+ 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_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_compile_time (sizeof (head) + 3 * 256);
+ head.bpp = grub_cpu_to_le16_compile_time (8);
+ }
+ 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);
+
+ head.width = grub_cpu_to_le16 (mode_info->width);
+ head.height = grub_cpu_to_le16 (mode_info->height);
+
+ grub_util_fd_write (fd, (char *) &head, sizeof (head));
+
+ if (!(mode_info->mode_type & GRUB_VIDEO_MODE_TYPE_RGB))
+ {
+ struct grub_video_palette_data palette_data[256];
+ int i;
+ int palette_len = mode_info->number_of_colors;
+ grub_memset (palette_data, 0, sizeof (palette_data));
+ if (palette_len > 256)
+ palette_len = 256;
+ grub_video_get_palette (0, palette_len, palette_data);
+ for (i = 0; i < 256; i++)
+ {
+ grub_uint8_t r, g, b;
+ r = palette_data[i].r;
+ g = palette_data[i].g;
+ b = palette_data[i].b;
+
+ grub_util_fd_write (fd, (char *) &b, 1);
+ grub_util_fd_write (fd, (char *) &g, 1);
+ grub_util_fd_write (fd, (char *) &r, 1);
+ }
+ }
+
+ /* This does essentialy the same as some fbblit functions yet using
+ them would mean testing them against themselves so keep this
+ implemetation separate. */
+ switch (mode_info->bytes_per_pixel)
+ {
+ case 4:
+ {
+ grub_uint8_t *buffer = xcalloc (3, mode_info->width);
+ grub_uint32_t rmask = ((1 << mode_info->red_mask_size) - 1);
+ grub_uint32_t gmask = ((1 << mode_info->green_mask_size) - 1);
+ grub_uint32_t bmask = ((1 << mode_info->blue_mask_size) - 1);
+ int rshift = mode_info->red_field_pos;
+ int gshift = mode_info->green_field_pos;
+ int bshift = mode_info->blue_field_pos;
+ int mulrshift = (8 - mode_info->red_mask_size);
+ int mulgshift = (8 - mode_info->green_mask_size);
+ int mulbshift = (8 - mode_info->blue_mask_size);
+ int y;
+
+ for (y = mode_info->height - 1; y >= 0; y--)
+ {
+ grub_uint32_t *iptr = (grub_uint32_t *) ptr + (mode_info->pitch / 4) * y;
+ int x;
+ grub_uint8_t *optr = buffer;
+ for (x = 0; x < (int) mode_info->width; x++)
+ {
+ grub_uint32_t val = *iptr++;
+ *optr++ = ((val >> bshift) & bmask) << mulbshift;
+ *optr++ = ((val >> gshift) & gmask) << mulgshift;
+ *optr++ = ((val >> rshift) & rmask) << mulrshift;
+ }
+ grub_util_fd_write (fd, (char *) buffer, mode_info->width * 3);
+ }
+ grub_free (buffer);
+ break;
+ }
+ case 3:
+ {
+ grub_uint8_t *buffer = xcalloc (3, mode_info->width);
+ grub_uint32_t rmask = ((1 << mode_info->red_mask_size) - 1);
+ grub_uint32_t gmask = ((1 << mode_info->green_mask_size) - 1);
+ grub_uint32_t bmask = ((1 << mode_info->blue_mask_size) - 1);
+ int rshift = mode_info->red_field_pos;
+ int gshift = mode_info->green_field_pos;
+ int bshift = mode_info->blue_field_pos;
+ int mulrshift = (8 - mode_info->red_mask_size);
+ int mulgshift = (8 - mode_info->green_mask_size);
+ int mulbshift = (8 - mode_info->blue_mask_size);
+ int y;
+
+ for (y = mode_info->height - 1; y >= 0; y--)
+ {
+ grub_uint8_t *iptr = ((grub_uint8_t *) ptr + mode_info->pitch * y);
+ int x;
+ grub_uint8_t *optr = buffer;
+ for (x = 0; x < (int) mode_info->width; x++)
+ {
+ grub_uint32_t val = 0;
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ val |= *iptr++ << 16;
+ val |= *iptr++ << 8;
+ val |= *iptr++;
+#else
+ val |= *iptr++;
+ val |= *iptr++ << 8;
+ val |= *iptr++ << 16;
+#endif
+ *optr++ = ((val >> bshift) & bmask) << mulbshift;
+ *optr++ = ((val >> gshift) & gmask) << mulgshift;
+ *optr++ = ((val >> rshift) & rmask) << mulrshift;
+ }
+ grub_util_fd_write (fd, (char *) buffer, mode_info->width * 3);
+ }
+ grub_free (buffer);
+ break;
+ }
+ case 2:
+ {
+ grub_uint8_t *buffer = xcalloc (3, mode_info->width);
+ grub_uint16_t rmask = ((1 << mode_info->red_mask_size) - 1);
+ grub_uint16_t gmask = ((1 << mode_info->green_mask_size) - 1);
+ grub_uint16_t bmask = ((1 << mode_info->blue_mask_size) - 1);
+ int rshift = mode_info->red_field_pos;
+ int gshift = mode_info->green_field_pos;
+ int bshift = mode_info->blue_field_pos;
+ int mulrshift = (8 - mode_info->red_mask_size);
+ int mulgshift = (8 - mode_info->green_mask_size);
+ int mulbshift = (8 - mode_info->blue_mask_size);
+ int y;
+
+ for (y = mode_info->height - 1; y >= 0; y--)
+ {
+ grub_uint16_t *iptr = (grub_uint16_t *) ptr + (mode_info->pitch / 2) * y;
+ int x;
+ grub_uint8_t *optr = buffer;
+ for (x = 0; x < (int) mode_info->width; x++)
+ {
+ grub_uint16_t val = *iptr++;
+ *optr++ = ((val >> bshift) & bmask) << mulbshift;
+ *optr++ = ((val >> gshift) & gmask) << mulgshift;
+ *optr++ = ((val >> rshift) & rmask) << mulrshift;
+ }
+ grub_util_fd_write (fd, (char *) buffer, mode_info->width * 3);
+ }
+ grub_free (buffer);
+ break;
+ }
+ case 1:
+ {
+ int y;
+
+ for (y = mode_info->height - 1; y >= 0; y--)
+ grub_util_fd_write (fd, ((char *) ptr + mode_info->pitch * y),
+ mode_info->width);
+ break;
+ }
+ }
+ grub_util_fd_close (fd);
+}
+
+#endif
+
+const char *
+grub_video_checksum_get_modename (void)
+{
+ static char buf[40];
+ if (capt_mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
+ {
+ grub_snprintf (buf, sizeof (buf), "i%d", capt_mode_info.number_of_colors);
+ return buf;
+ }
+ if (capt_mode_info.red_field_pos == 0)
+ {
+ grub_snprintf (buf, sizeof (buf), "bgra%d%d%d%d", capt_mode_info.blue_mask_size,
+ capt_mode_info.green_mask_size,
+ capt_mode_info.red_mask_size,
+ capt_mode_info.reserved_mask_size);
+ return buf;
+ }
+ grub_snprintf (buf, sizeof (buf), "rgba%d%d%d%d", capt_mode_info.red_mask_size,
+ capt_mode_info.green_mask_size,
+ capt_mode_info.blue_mask_size,
+ capt_mode_info.reserved_mask_size);
+ return buf;
+}
+
+#define GENERATE_MODE 1
+//#define SAVE_ALL_IMAGES
+//#define COLLECT_TIME_STATISTICS 1
+
+#if defined (GENERATE_MODE) && defined (GRUB_MACHINE_EMU)
+grub_util_fd_t genfd = GRUB_UTIL_FD_INVALID;
+#endif
+
+#include <grub/time.h>
+
+static void
+write_time (void)
+{
+#if defined (GRUB_MACHINE_EMU) && defined (COLLECT_TIME_STATISTICS)
+ char buf[60];
+ static grub_uint64_t prev;
+ grub_uint64_t cur;
+ static grub_util_fd_t tmrfd = GRUB_UTIL_FD_INVALID;
+ if (!GRUB_UTIL_FD_IS_VALID (tmrfd))
+ tmrfd = grub_util_fd_open ("time.txt", GRUB_UTIL_FD_O_WRONLY
+ | GRUB_UTIL_FD_O_CREATTRUNC);
+
+ cur = grub_util_get_cpu_time_ms ();
+ grub_snprintf (buf, sizeof (buf), "%s_%dx%dx%s:%d: %" PRIuGRUB_UINT64_T " ms\n",
+ basename,
+ capt_mode_info.width,
+ capt_mode_info.height,
+ grub_video_checksum_get_modename (), ctr,
+ cur - prev);
+ prev = cur;
+ if (GRUB_UTIL_FD_IS_VALID (tmrfd))
+ grub_util_fd_write (tmrfd, buf, grub_strlen (buf));
+#endif
+}
+
+
+static void
+checksum (void)
+{
+ void *ptr;
+ grub_uint32_t crc = 0;
+
+ ptr = grub_video_capture_get_framebuffer ();
+
+ write_time ();
+
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ switch (capt_mode_info.bytes_per_pixel)
+ {
+ case 1:
+ crc = grub_getcrc32c (0, ptr, capt_mode_info.pitch
+ * capt_mode_info.height);
+ break;
+ case 2:
+ {
+ unsigned x, y, rowskip;
+ grub_uint8_t *iptr = ptr;
+ crc = 0;
+ rowskip = capt_mode_info.pitch - capt_mode_info.width * 2;
+ for (y = 0; y < capt_mode_info.height; y++)
+ {
+ for (x = 0; x < capt_mode_info.width; x++)
+ {
+ crc = grub_getcrc32c (crc, iptr + 1, 1);
+ crc = grub_getcrc32c (crc, iptr, 1);
+ iptr += 2;
+ }
+ crc = grub_getcrc32c (crc, iptr, rowskip);
+ iptr += rowskip;
+ }
+ break;
+ }
+ case 3:
+ {
+ unsigned x, y, rowskip;
+ grub_uint8_t *iptr = ptr;
+ crc = 0;
+ rowskip = capt_mode_info.pitch - capt_mode_info.width * 3;
+ for (y = 0; y < capt_mode_info.height; y++)
+ {
+ for (x = 0; x < capt_mode_info.width; x++)
+ {
+ crc = grub_getcrc32c (crc, iptr + 2, 1);
+ crc = grub_getcrc32c (crc, iptr + 1, 1);
+ crc = grub_getcrc32c (crc, iptr, 1);
+ iptr += 3;
+ }
+ crc = grub_getcrc32c (crc, iptr, rowskip);
+ iptr += rowskip;
+ }
+ break;
+ }
+ case 4:
+ {
+ unsigned x, y, rowskip;
+ grub_uint8_t *iptr = ptr;
+ crc = 0;
+ rowskip = capt_mode_info.pitch - capt_mode_info.width * 4;
+ for (y = 0; y < capt_mode_info.height; y++)
+ {
+ for (x = 0; x < capt_mode_info.width; x++)
+ {
+ crc = grub_getcrc32c (crc, iptr + 3, 1);
+ crc = grub_getcrc32c (crc, iptr + 2, 1);
+ crc = grub_getcrc32c (crc, iptr + 1, 1);
+ crc = grub_getcrc32c (crc, iptr, 1);
+ iptr += 4;
+ }
+ crc = grub_getcrc32c (crc, iptr, rowskip);
+ iptr += rowskip;
+ }
+ break;
+ }
+ }
+#else
+ crc = grub_getcrc32c (0, ptr, capt_mode_info.pitch * capt_mode_info.height);
+#endif
+
+#if defined (GENERATE_MODE) && defined (GRUB_MACHINE_EMU)
+ if (GRUB_UTIL_FD_IS_VALID (genfd))
+ {
+ char buf[20];
+ grub_snprintf (buf, sizeof (buf), "0x%x, ", crc);
+ grub_util_fd_write (genfd, buf, grub_strlen (buf));
+ }
+#endif
+
+ if (!checksums || ctr >= nchk)
+ {
+ grub_test_assert (0, "Unexpected checksum %s_%dx%dx%s:%d: 0x%x",
+ basename,
+ capt_mode_info.width,
+ capt_mode_info.height,
+ grub_video_checksum_get_modename (), ctr, crc);
+ }
+ else if (crc != checksums[ctr])
+ {
+ grub_test_assert (0, "Checksum %s_%dx%dx%s:%d failed: 0x%x vs 0x%x",
+ basename,
+ capt_mode_info.width,
+ capt_mode_info.height,
+ grub_video_checksum_get_modename (),
+ ctr, crc, checksums[ctr]);
+ }
+#if !(defined (SAVE_ALL_IMAGES) && defined (GRUB_MACHINE_EMU))
+ else
+ {
+ write_time ();
+ ctr++;
+ return;
+ }
+#endif
+#ifdef GRUB_MACHINE_EMU
+ char *name = grub_xasprintf ("%s_%dx%dx%s_%d.bmp", basename,
+ capt_mode_info.width,
+ capt_mode_info.height,
+ grub_video_checksum_get_modename (),
+ ctr);
+ grub_video_capture_write_bmp (name, ptr, &capt_mode_info);
+ grub_free (name);
+#endif
+
+ write_time ();
+
+ ctr++;
+}
+
+struct checksum_desc
+{
+ const char *name;
+ unsigned width;
+ unsigned height;
+ unsigned mode_type;
+ unsigned number_of_colors;
+ unsigned bpp;
+ unsigned bytes_per_pixel;
+ unsigned red_field_pos;
+ unsigned red_mask_size;
+ unsigned green_field_pos;
+ unsigned green_mask_size;
+ unsigned blue_field_pos;
+ unsigned blue_mask_size;
+ unsigned reserved_field_pos;
+ unsigned reserved_mask_size;
+ const grub_uint32_t *checksums;
+ int nchk;
+};
+
+const struct checksum_desc checksum_table[] = {
+#include "checksums.h"
+};
+
+void
+grub_video_checksum (const char *basename_in)
+{
+ unsigned i;
+
+ grub_video_get_info (&capt_mode_info);
+
+#if defined (GENERATE_MODE) && defined (GRUB_MACHINE_EMU)
+ if (!GRUB_UTIL_FD_IS_VALID (genfd))
+ genfd = grub_util_fd_open ("checksums.h", GRUB_UTIL_FD_O_WRONLY
+ | GRUB_UTIL_FD_O_CREATTRUNC);
+ if (GRUB_UTIL_FD_IS_VALID (genfd))
+ {
+ char buf[400];
+
+ grub_snprintf (buf, sizeof (buf), "\", %d, %d, 0x%x, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d /* %dx%dx%s */, (grub_uint32_t []) { ",
+ capt_mode_info.width,
+ capt_mode_info.height,
+ capt_mode_info.mode_type,
+ capt_mode_info.number_of_colors,
+ capt_mode_info.bpp,
+ capt_mode_info.bytes_per_pixel,
+ capt_mode_info.red_field_pos,
+ capt_mode_info.red_mask_size,
+ capt_mode_info.green_field_pos,
+ capt_mode_info.green_mask_size,
+ capt_mode_info.blue_field_pos,
+ capt_mode_info.blue_mask_size,
+ capt_mode_info.reserved_field_pos,
+ capt_mode_info.reserved_mask_size,
+ capt_mode_info.width,
+ capt_mode_info.height,
+ grub_video_checksum_get_modename ());
+
+ grub_util_fd_write (genfd, " { \"", 5);
+ grub_util_fd_write (genfd, basename_in, grub_strlen (basename_in));
+ grub_util_fd_write (genfd, buf, grub_strlen (buf));
+ }
+#endif
+
+ basename = grub_strdup (basename_in);
+ nchk = 0;
+ checksums = 0;
+ /* FIXME: optimize this. */
+ for (i = 0; i < ARRAY_SIZE (checksum_table); i++)
+ if (grub_strcmp (checksum_table[i].name, basename_in) == 0
+ && capt_mode_info.width == checksum_table[i].width
+ && capt_mode_info.height == checksum_table[i].height
+ && capt_mode_info.mode_type == checksum_table[i].mode_type
+ && capt_mode_info.number_of_colors == checksum_table[i].number_of_colors
+ && capt_mode_info.bpp == checksum_table[i].bpp
+ && capt_mode_info.bytes_per_pixel == checksum_table[i].bytes_per_pixel
+ && capt_mode_info.red_field_pos == checksum_table[i].red_field_pos
+ && capt_mode_info.red_mask_size == checksum_table[i].red_mask_size
+ && capt_mode_info.green_field_pos == checksum_table[i].green_field_pos
+ && capt_mode_info.green_mask_size == checksum_table[i].green_mask_size
+ && capt_mode_info.blue_field_pos == checksum_table[i].blue_field_pos
+ && capt_mode_info.blue_mask_size == checksum_table[i].blue_mask_size
+ && capt_mode_info.reserved_field_pos == checksum_table[i].reserved_field_pos
+ && capt_mode_info.reserved_mask_size == checksum_table[i].reserved_mask_size)
+ {
+ nchk = checksum_table[i].nchk;
+ checksums = checksum_table[i].checksums;
+ break;
+ }
+
+ ctr = 0;
+ grub_video_capture_refresh_cb = checksum;
+}
+
+void
+grub_video_checksum_end (void)
+{
+#if defined (GENERATE_MODE) && defined (GRUB_MACHINE_EMU)
+ if (GRUB_UTIL_FD_IS_VALID (genfd))
+ {
+ char buf[40];
+ grub_snprintf (buf, sizeof (buf), "}, %d },\n", ctr);
+ grub_util_fd_write (genfd, buf, grub_strlen (buf));
+ }
+#endif
+ grub_test_assert (ctr == nchk, "Not enough checksums %s_%dx%dx%s: %d vs %d",
+ basename,
+ capt_mode_info.width,
+ capt_mode_info.height,
+ grub_video_checksum_get_modename (),
+ ctr, nchk);
+ grub_free (basename);
+ basename = 0;
+ nchk = 0;
+ checksums = 0;
+ ctr = 0;
+ grub_video_capture_refresh_cb = 0;
+}
+
+static struct grub_term_output *saved_outputs;
+static struct grub_term_output *saved_gfxnext;
+static struct grub_term_output *gfxterm;
+static int use_gfxterm = 0;
+
+int
+grub_test_use_gfxterm (void)
+{
+ FOR_ACTIVE_TERM_OUTPUTS (gfxterm)
+ if (grub_strcmp (gfxterm->name, "gfxterm") == 0)
+ break;
+ if (!gfxterm)
+ FOR_DISABLED_TERM_OUTPUTS (gfxterm)
+ if (grub_strcmp (gfxterm->name, "gfxterm") == 0)
+ break;
+
+ if (!gfxterm)
+ {
+ grub_test_assert (0, "terminal `%s' isn't found", "gfxterm");
+ return 1;
+ }
+
+ if (gfxterm->init (gfxterm))
+ {
+ grub_test_assert (0, "terminal `%s' failed: %s", "gfxterm", grub_errmsg);
+ return 1;
+ }
+
+ saved_outputs = grub_term_outputs;
+ saved_gfxnext = gfxterm->next;
+ grub_term_outputs = gfxterm;
+ gfxterm->next = 0;
+ use_gfxterm = 1;
+
+ return 0;
+}
+
+void
+grub_test_use_gfxterm_end (void)
+{
+ if (!use_gfxterm)
+ return;
+ use_gfxterm = 0;
+ gfxterm->fini (gfxterm);
+ gfxterm->next = saved_gfxnext;
+ grub_term_outputs = saved_outputs;
+ saved_outputs = 0;
+ saved_gfxnext = 0;
+}
diff --git a/grub-core/tests/videotest_checksum.c b/grub-core/tests/videotest_checksum.c
new file mode 100644
index 0000000..a4bff5e
--- /dev/null
+++ b/grub-core/tests/videotest_checksum.c
@@ -0,0 +1,80 @@
+/*
+ * 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/>.
+ */
+
+/* All tests need to include test.h for GRUB testing framework. */
+#include <grub/test.h>
+#include <grub/dl.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/command.h>
+#include <grub/font.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define FONT_NAME "Unknown Regular 16"
+
+/* Functional test main method. */
+static void
+videotest_checksum (void)
+{
+ unsigned i;
+ grub_font_t font;
+
+ font = grub_font_get (FONT_NAME);
+ if (font && grub_strcmp (font->name, FONT_NAME) != 0)
+ font = 0;
+ if (!font)
+ font = grub_font_load ("unicode");
+
+ if (!font)
+ {
+ grub_test_assert (0, "unicode font not found: %s", grub_errmsg);
+ return;
+ }
+
+ for (i = 0; i < ARRAY_SIZE (grub_test_video_modes); i++)
+ {
+ grub_err_t err;
+#if defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_IEEE1275)
+ if (grub_test_video_modes[i].width > 1024)
+ continue;
+#endif
+ err = grub_video_capture_start (&grub_test_video_modes[i],
+ grub_video_fbstd_colors,
+ grub_test_video_modes[i].number_of_colors);
+ if (err)
+ {
+ grub_test_assert (0, "can't start capture: %s", grub_errmsg);
+ grub_print_error ();
+ continue;
+ }
+ grub_terminal_input_fake_sequence ((int []) { '\n' }, 1);
+
+ grub_video_checksum ("videotest");
+
+ char *args[] = { 0 };
+ grub_command_execute ("videotest", 0, args);
+
+ grub_terminal_input_fake_sequence_end ();
+ grub_video_checksum_end ();
+ grub_video_capture_end ();
+ }
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (videotest_checksum, videotest_checksum);
diff --git a/grub-core/tests/xnu_uuid_test.c b/grub-core/tests/xnu_uuid_test.c
new file mode 100644
index 0000000..d500145
--- /dev/null
+++ b/grub-core/tests/xnu_uuid_test.c
@@ -0,0 +1,58 @@
+/*
+ * 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/time.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/env.h>
+#include <grub/test.h>
+#include <grub/mm.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static void
+xnu_uuid_test (void)
+{
+ grub_command_t cmd;
+ cmd = grub_command_find ("xnu_uuid");
+ char *args[] = { (char *) "fedcba98", (char *) "tstvar", NULL };
+ const char *val;
+
+ if (!cmd)
+ {
+ grub_test_assert (0, "can't find command `%s'", "xnu_uuid");
+ return;
+ }
+ if ((cmd->func) (cmd, 2, args))
+ {
+ grub_test_assert (0, "%d: %s", grub_errno, grub_errmsg);
+ return;
+ }
+
+ val = grub_env_get ("tstvar");
+ if (!val)
+ {
+ grub_test_assert (0, "tstvar isn't set");
+ return;
+ }
+ grub_test_assert (grub_strcmp (val, "944F9DED-DBED-391C-9402-77C8CEE04173")
+ == 0, "UUIDs don't match");
+}
+
+GRUB_FUNCTIONAL_TEST (xnu_uuid_test, xnu_uuid_test);
diff --git a/grub-core/unidata.c b/grub-core/unidata.c
new file mode 100644
index 0000000..c894add
--- /dev/null
+++ b/grub-core/unidata.c
@@ -0,0 +1,1538 @@
+#include <grub/unicode.h>
+
+struct grub_unicode_compact_range grub_unicode_compact[] = {
+{0x0, 0x9, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x9, 0x1, GRUB_BIDI_TYPE_S, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa, 0x1, GRUB_BIDI_TYPE_B, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb, 0x1, GRUB_BIDI_TYPE_S, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xc, 0x1, GRUB_BIDI_TYPE_WS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xd, 0x1, GRUB_BIDI_TYPE_B, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xe, 0xe, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1c, 0x3, GRUB_BIDI_TYPE_B, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f, 0x1, GRUB_BIDI_TYPE_S, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x20, 0x1, GRUB_BIDI_TYPE_WS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x21, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x23, 0x3, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x26, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x28, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2b, 0x1, GRUB_BIDI_TYPE_ES, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2c, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2d, 0x1, GRUB_BIDI_TYPE_ES, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e, 0x2, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x30, 0xa, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3a, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3b, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3c, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x3d, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3e, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x3f, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x5b, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x5c, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x5d, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x5e, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x7b, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x7c, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x7d, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x7e, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x7f, 0x6, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x85, 0x1, GRUB_BIDI_TYPE_B, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x86, 0x1a, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa0, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa1, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa2, 0x4, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa6, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xab, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xac, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xad, 0x1, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xae, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb0, 0x2, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb2, 0x2, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb4, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb6, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb9, 0x1, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xbb, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xbc, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xd7, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xf7, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2b9, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2c2, 0xe, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2d2, 0xe, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e5, 0x9, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2ef, 0x11, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x300, 0x15, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x315, 0x1, GRUB_BIDI_TYPE_NSM, 232, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x316, 0x4, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x31a, 0x1, GRUB_BIDI_TYPE_NSM, 232, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x31b, 0x1, GRUB_BIDI_TYPE_NSM, 216, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x31c, 0x5, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x321, 0x2, GRUB_BIDI_TYPE_NSM, 202, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x323, 0x4, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x327, 0x2, GRUB_BIDI_TYPE_NSM, 202, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x329, 0xb, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x334, 0x5, GRUB_BIDI_TYPE_NSM, 1, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x339, 0x4, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x33d, 0x8, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x345, 0x1, GRUB_BIDI_TYPE_NSM, 240, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x346, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x347, 0x3, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x34a, 0x3, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x34d, 0x2, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x34f, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x350, 0x3, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x353, 0x4, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x357, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x358, 0x1, GRUB_BIDI_TYPE_NSM, 232, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x359, 0x2, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x35b, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x35c, 0x1, GRUB_BIDI_TYPE_NSM, 233, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x35d, 0x2, GRUB_BIDI_TYPE_NSM, 234, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x35f, 0x1, GRUB_BIDI_TYPE_NSM, 233, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x360, 0x2, GRUB_BIDI_TYPE_NSM, 234, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x362, 0x1, GRUB_BIDI_TYPE_NSM, 233, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x363, 0xd, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x374, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x37e, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x384, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x387, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3f6, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x483, 0x5, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x488, 0x2, GRUB_BIDI_TYPE_NSM, 253, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x58a, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x591, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x592, 0x4, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x596, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x597, 0x3, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x59a, 0x1, GRUB_BIDI_TYPE_NSM, 222, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x59b, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x59c, 0x6, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5a2, 0x6, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5a8, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5aa, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5ab, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5ad, 0x1, GRUB_BIDI_TYPE_NSM, 222, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5ae, 0x1, GRUB_BIDI_TYPE_NSM, 228, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5af, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5b0, 0x1, GRUB_BIDI_TYPE_NSM, 10, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5b1, 0x1, GRUB_BIDI_TYPE_NSM, 11, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5b2, 0x1, GRUB_BIDI_TYPE_NSM, 12, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5b3, 0x1, GRUB_BIDI_TYPE_NSM, 13, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5b4, 0x1, GRUB_BIDI_TYPE_NSM, 14, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5b5, 0x1, GRUB_BIDI_TYPE_NSM, 15, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5b6, 0x1, GRUB_BIDI_TYPE_NSM, 16, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5b7, 0x1, GRUB_BIDI_TYPE_NSM, 17, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5b8, 0x1, GRUB_BIDI_TYPE_NSM, 18, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5b9, 0x2, GRUB_BIDI_TYPE_NSM, 19, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5bb, 0x1, GRUB_BIDI_TYPE_NSM, 20, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5bc, 0x1, GRUB_BIDI_TYPE_NSM, 21, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5bd, 0x1, GRUB_BIDI_TYPE_NSM, 22, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5be, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x5bf, 0x1, GRUB_BIDI_TYPE_NSM, 23, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5c0, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x5c1, 0x1, GRUB_BIDI_TYPE_NSM, 24, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5c2, 0x1, GRUB_BIDI_TYPE_NSM, 25, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5c3, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x5c4, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5c5, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5c6, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x5c7, 0x1, GRUB_BIDI_TYPE_NSM, 18, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x5d0, 0x1b, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x5f0, 0x5, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x600, 0x4, GRUB_BIDI_TYPE_AN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x606, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x608, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x609, 0x2, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x60b, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x60c, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x60d, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x60e, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x610, 0x8, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x618, 0x1, GRUB_BIDI_TYPE_NSM, 30, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x619, 0x1, GRUB_BIDI_TYPE_NSM, 31, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x61a, 0x1, GRUB_BIDI_TYPE_NSM, 32, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x61b, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x61e, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x620, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x621, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x622, 0x4, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x626, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x627, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x628, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x629, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x62a, 0x5, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x62f, 0x4, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x633, 0xd, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x640, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_CAUSING},
+{0x641, 0x7, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x648, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x649, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x64b, 0x1, GRUB_BIDI_TYPE_NSM, 27, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x64c, 0x1, GRUB_BIDI_TYPE_NSM, 28, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x64d, 0x1, GRUB_BIDI_TYPE_NSM, 29, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x64e, 0x1, GRUB_BIDI_TYPE_NSM, 30, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x64f, 0x1, GRUB_BIDI_TYPE_NSM, 31, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x650, 0x1, GRUB_BIDI_TYPE_NSM, 32, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x651, 0x1, GRUB_BIDI_TYPE_NSM, 33, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x652, 0x1, GRUB_BIDI_TYPE_NSM, 34, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x653, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x655, 0x2, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x657, 0x5, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x65c, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x65d, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x65f, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x660, 0xa, GRUB_BIDI_TYPE_AN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x66a, 0x1, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x66b, 0x2, GRUB_BIDI_TYPE_AN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x66d, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x66e, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x670, 0x1, GRUB_BIDI_TYPE_NSM, 35, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x671, 0x3, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x674, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x675, 0x3, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x678, 0x10, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x688, 0x12, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x69a, 0x26, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x6c0, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x6c1, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x6c3, 0x9, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x6cc, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x6cd, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x6ce, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x6cf, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x6d0, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x6d2, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x6d4, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x6d5, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x6d6, 0x7, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x6dd, 0x1, GRUB_BIDI_TYPE_AN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x6de, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x6df, 0x4, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x6e3, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x6e4, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x6e5, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x6e7, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x6e9, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x6ea, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x6eb, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x6ed, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x6ee, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x6f0, 0xa, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x6fa, 0x3, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x6fd, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x6ff, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x700, 0xe, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x70f, 0x1, GRUB_BIDI_TYPE_AN, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x710, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x711, 0x1, GRUB_BIDI_TYPE_NSM, 36, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x712, 0x3, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x715, 0x5, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x71a, 0x4, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x71e, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x71f, 0x9, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x728, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x729, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x72a, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x72b, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x72c, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x72d, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x72f, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x730, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x731, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x732, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x734, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x735, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x737, 0x3, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x73a, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x73b, 0x2, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x73d, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x73e, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x73f, 0x3, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x742, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x743, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x744, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x745, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x746, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x747, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x748, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x749, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x74d, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x74e, 0xb, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x759, 0x3, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x75c, 0xf, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x76b, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x76d, 0x4, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x771, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x772, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x773, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x775, 0x3, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x778, 0x2, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_RIGHT},
+{0x77a, 0x6, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x780, 0x26, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x7a6, 0xb, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x7b1, 0x1, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x7c0, 0xa, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x7ca, 0x21, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_DUAL},
+{0x7eb, 0x7, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x7f2, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x7f3, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x7f4, 0x2, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x7f6, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x7fa, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_CAUSING},
+{0x800, 0x16, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x816, 0x4, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x81a, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x81b, 0x9, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x824, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x825, 0x3, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x828, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x829, 0x5, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x830, 0xf, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x840, 0x19, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x859, 0x3, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x85e, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x900, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x903, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x93a, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x93b, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x93c, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x93e, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x941, 0x8, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x949, 0x4, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x94d, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x94e, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x951, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x952, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x953, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x955, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x962, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x981, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x982, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x9bc, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x9be, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x9c1, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x9c7, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x9cb, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x9cd, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x9d7, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x9e2, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x9f2, 0x2, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x9fb, 0x1, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa01, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa03, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa3c, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa3e, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa41, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa47, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa4b, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa4d, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa51, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa70, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa75, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa81, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa83, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xabc, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xabe, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xac1, 0x5, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xac7, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xac9, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xacb, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xacd, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xae2, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaf1, 0x1, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb01, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xb02, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb3c, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xb3e, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb3f, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xb40, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb41, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xb47, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb4b, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb4d, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xb56, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xb57, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xb62, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xb82, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xbbe, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xbc0, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xbc1, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xbc6, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xbca, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xbcd, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xbd7, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xbf3, 0x6, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xbf9, 0x1, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xbfa, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xc01, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xc3e, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xc41, 0x4, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xc46, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xc4a, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xc4d, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xc55, 0x1, GRUB_BIDI_TYPE_NSM, 84, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xc56, 0x1, GRUB_BIDI_TYPE_NSM, 91, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xc62, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xc78, 0x7, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xc82, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xcbc, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xcbe, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xcbf, 0x1, GRUB_BIDI_TYPE_L, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xcc0, 0x5, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xcc6, 0x1, GRUB_BIDI_TYPE_L, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xcc7, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xcca, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xccc, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xccd, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xcd5, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xce2, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xd02, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xd3e, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xd41, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xd46, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xd4a, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xd4d, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xd57, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xd62, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xd82, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xdca, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xdcf, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xdd2, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xdd6, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xdd8, 0x8, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xdf2, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xe31, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xe34, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xe38, 0x2, GRUB_BIDI_TYPE_NSM, 103, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xe3a, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xe3f, 0x1, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xe47, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xe48, 0x4, GRUB_BIDI_TYPE_NSM, 107, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xe4c, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xeb1, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xeb4, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xeb8, 0x2, GRUB_BIDI_TYPE_NSM, 118, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xebb, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xec8, 0x4, GRUB_BIDI_TYPE_NSM, 122, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xecc, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf18, 0x2, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf35, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf37, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf39, 0x1, GRUB_BIDI_TYPE_NSM, 216, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf3a, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xf3e, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xf71, 0x1, GRUB_BIDI_TYPE_NSM, 129, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf72, 0x1, GRUB_BIDI_TYPE_NSM, 130, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf73, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf74, 0x1, GRUB_BIDI_TYPE_NSM, 132, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf75, 0x5, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf7a, 0x4, GRUB_BIDI_TYPE_NSM, 130, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf7e, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf7f, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xf80, 0x1, GRUB_BIDI_TYPE_NSM, 130, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf81, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf82, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf84, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf86, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf8d, 0xb, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xf99, 0x24, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xfc6, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x102b, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x102d, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1031, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1032, 0x5, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1037, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1038, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1039, 0x2, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x103b, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x103d, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1056, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1058, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x105e, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1062, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1067, 0x7, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1071, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1082, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1083, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1085, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1087, 0x6, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x108d, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x108f, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x109a, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x109d, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x135d, 0x3, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1390, 0xa, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1400, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1680, 0x1, GRUB_BIDI_TYPE_WS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x169b, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x1712, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1714, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1732, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1734, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1752, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1772, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x17b6, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x17b7, 0x7, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x17be, 0x8, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x17c6, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x17c7, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x17c9, 0x9, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x17d2, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x17d3, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x17db, 0x1, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x17dd, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x17f0, 0xa, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1800, 0xb, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x180b, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x180e, 0x1, GRUB_BIDI_TYPE_WS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x18a9, 0x1, GRUB_BIDI_TYPE_NSM, 228, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1920, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1923, 0x4, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1927, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1929, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1930, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1932, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1933, 0x6, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1939, 0x1, GRUB_BIDI_TYPE_NSM, 222, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x193a, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x193b, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1940, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1944, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x19b0, 0x11, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x19c8, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x19de, 0x22, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1a17, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1a18, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1a19, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1a55, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1a56, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1a57, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1a58, 0x7, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1a60, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1a61, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1a62, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1a63, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1a65, 0x8, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1a6d, 0x6, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1a73, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1a75, 0x8, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1a7f, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1b00, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1b04, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1b34, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1b35, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1b36, 0x5, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1b3b, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1b3c, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1b3d, 0x5, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1b42, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1b43, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1b44, 0x1, GRUB_BIDI_TYPE_L, 9, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1b6b, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1b6c, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1b6d, 0x7, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1b80, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1b82, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1ba1, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1ba2, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1ba6, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1ba8, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1baa, 0x1, GRUB_BIDI_TYPE_L, 9, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1be6, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1be7, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1be8, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1bea, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1bed, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1bee, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1bef, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1bf2, 0x2, GRUB_BIDI_TYPE_L, 9, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1c24, 0x8, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1c2c, 0x8, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1c34, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1c36, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1c37, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1cd0, 0x3, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1cd4, 0x1, GRUB_BIDI_TYPE_NSM, 1, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1cd5, 0x5, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1cda, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1cdc, 0x4, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1ce0, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1ce1, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1ce2, 0x7, GRUB_BIDI_TYPE_NSM, 1, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1ced, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1cf2, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1dc0, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dc2, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dc3, 0x7, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dca, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dcb, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dcd, 0x1, GRUB_BIDI_TYPE_NSM, 234, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dce, 0x1, GRUB_BIDI_TYPE_NSM, 214, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dcf, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dd0, 0x1, GRUB_BIDI_TYPE_NSM, 202, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dd1, 0x16, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dfc, 0x1, GRUB_BIDI_TYPE_NSM, 233, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dfd, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dfe, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1dff, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1fbd, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1fbf, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1fcd, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1fdd, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1fed, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1ffd, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2000, 0xb, GRUB_BIDI_TYPE_WS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x200b, 0x1, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x200c, 0x1, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x200d, 0x1, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_CAUSING},
+{0x200f, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x2010, 0x18, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2028, 0x1, GRUB_BIDI_TYPE_WS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2029, 0x1, GRUB_BIDI_TYPE_B, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x202a, 0x1, GRUB_BIDI_TYPE_LRE, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x202b, 0x1, GRUB_BIDI_TYPE_RLE, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x202c, 0x1, GRUB_BIDI_TYPE_PDF, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x202d, 0x1, GRUB_BIDI_TYPE_LRO, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x202e, 0x1, GRUB_BIDI_TYPE_RLO, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x202f, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2030, 0x5, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2035, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2039, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x203b, 0x9, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2044, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2045, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2047, 0x18, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x205f, 0x1, GRUB_BIDI_TYPE_WS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2060, 0x5, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x206a, 0x6, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x2070, 0x1, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2074, 0x6, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x207a, 0x2, GRUB_BIDI_TYPE_ES, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x207c, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x207d, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2080, 0xa, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x208a, 0x2, GRUB_BIDI_TYPE_ES, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x208c, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x208d, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x20a0, 0x1a, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x20d0, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20d2, 0x2, GRUB_BIDI_TYPE_NSM, 1, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20d4, 0x4, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20d8, 0x3, GRUB_BIDI_TYPE_NSM, 1, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20db, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20dd, 0x4, GRUB_BIDI_TYPE_NSM, 253, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20e1, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20e2, 0x3, GRUB_BIDI_TYPE_NSM, 253, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20e5, 0x2, GRUB_BIDI_TYPE_NSM, 1, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20e7, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20e8, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20e9, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20ea, 0x2, GRUB_BIDI_TYPE_NSM, 1, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20ec, 0x4, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x20f0, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x2100, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2103, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2108, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2114, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2116, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x211e, 0x6, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2125, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2127, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2129, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x212e, 0x1, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x213a, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2140, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2141, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x214a, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2150, 0x10, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2189, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2190, 0x71, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2201, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2205, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2208, 0x6, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x220e, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2211, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2212, 0x1, GRUB_BIDI_TYPE_ES, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2213, 0x1, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2214, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2215, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2217, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x221a, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x221e, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x221f, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2223, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2224, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2225, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2226, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2227, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x222b, 0x9, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2234, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2239, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x223a, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x223b, 0x12, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x224d, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2252, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2256, 0x9, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x225f, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2261, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2262, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2263, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2264, 0x8, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x226c, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x226e, 0x1f, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x228d, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x228f, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2293, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2298, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2299, 0x9, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x22a2, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x22a4, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x22a6, 0x13, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x22b9, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x22be, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x22c0, 0x9, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x22c9, 0x5, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x22ce, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x22d0, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x22d2, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x22d6, 0x18, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x22ee, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x22f0, 0x10, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2300, 0x8, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2308, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x230c, 0x14, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2320, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2322, 0x7, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2329, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x232b, 0xb, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x237b, 0x1a, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2396, 0x5e, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2400, 0x27, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2440, 0xb, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2460, 0x28, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2488, 0x14, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x24ea, 0x1c2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x26ad, 0x53, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2701, 0x67, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2768, 0xe, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2776, 0x4a, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x27c0, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x27c1, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x27c3, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x27c7, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x27c8, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x27ca, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x27cc, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x27ce, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x27d3, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x27d7, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x27dc, 0x3, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x27df, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x27e2, 0xe, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x27f0, 0x10, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2900, 0x83, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2983, 0x16, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2999, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x299b, 0x15, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29b0, 0x8, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29b8, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29b9, 0x7, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29c0, 0x6, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29c6, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29c9, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29ca, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29ce, 0x5, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29d3, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29d4, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29d6, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29d8, 0x5, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29dd, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29e1, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29e2, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29e3, 0x3, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29e6, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29e8, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29ea, 0xa, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29f4, 0x6, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29fa, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x29fc, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x29fe, 0xc, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a0a, 0x13, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a1d, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a1e, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a22, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a24, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a25, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a26, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a27, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a29, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a2a, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a2b, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a2f, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a34, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a36, 0x6, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a3c, 0x3, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a3f, 0x18, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a57, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a59, 0xb, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a64, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a66, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a6a, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a6e, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a6f, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a71, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a73, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a75, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2a79, 0x2b, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2aa4, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2aa6, 0x8, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2aae, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2aaf, 0x28, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2ad7, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2adc, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2add, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2ade, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2adf, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2ae2, 0x5, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2ae7, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2aec, 0x3, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2aef, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2af3, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2af4, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2af7, 0x5, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2afc, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2afd, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2afe, 0x4f, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2b50, 0xa, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2ce5, 0x6, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2cef, 0x3, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x2cf9, 0x7, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2d7f, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x2de0, 0x20, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x2e00, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e02, 0x4, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e06, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e09, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e0b, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e0c, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e0e, 0xe, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e1c, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e1e, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e20, 0xa, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e2a, 0x8, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e80, 0x1a, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2e9b, 0x59, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2f00, 0xd6, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x2ff0, 0xc, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3000, 0x1, GRUB_BIDI_TYPE_WS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3001, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3008, 0xa, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x3012, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3014, 0x8, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x301c, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x302a, 0x1, GRUB_BIDI_TYPE_NSM, 218, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x302b, 0x1, GRUB_BIDI_TYPE_NSM, 228, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x302c, 0x1, GRUB_BIDI_TYPE_NSM, 232, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x302d, 0x1, GRUB_BIDI_TYPE_NSM, 222, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x302e, 0x2, GRUB_BIDI_TYPE_NSM, 224, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x3030, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3036, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x303d, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3099, 0x2, GRUB_BIDI_TYPE_NSM, 8, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x309b, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x30a0, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x30fb, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x31c0, 0x24, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x321d, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3250, 0x10, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x327c, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x32b1, 0xf, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x32cc, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x3377, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x33de, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x33ff, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x4dc0, 0x40, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa490, 0x37, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa60d, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa66f, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa670, 0x3, GRUB_BIDI_TYPE_NSM, 253, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa673, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa67c, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa67e, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa6f0, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa700, 0x22, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa788, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa802, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa806, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa80b, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa823, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa825, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa827, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa828, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa838, 0x2, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa874, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa880, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa8b4, 0x10, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa8c4, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa8e0, 0x12, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa926, 0x5, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa92b, 0x3, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa947, 0xb, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa952, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa953, 0x1, GRUB_BIDI_TYPE_L, 9, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa980, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa983, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa9b3, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa9b4, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa9b6, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa9ba, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa9bc, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xa9bd, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xa9c0, 0x1, GRUB_BIDI_TYPE_L, 9, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xaa29, 0x6, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaa2f, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xaa31, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaa33, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xaa35, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaa43, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaa4c, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaa4d, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xaa7b, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xaab0, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaab2, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaab4, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaab7, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaabe, 0x2, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xaac1, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xabe3, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xabe5, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xabe6, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xabe8, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xabe9, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xabec, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xabed, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xfb1d, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfb1e, 0x1, GRUB_BIDI_TYPE_NSM, 26, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xfb1f, 0xa, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfb29, 0x1, GRUB_BIDI_TYPE_ES, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfb2a, 0xd, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfb38, 0x5, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfb3e, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfb40, 0x2, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfb43, 0x2, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfb46, 0xa, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfb50, 0x72, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfbd3, 0x16b, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfd3e, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfd50, 0x40, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfd92, 0x36, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfdf0, 0xd, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfdfd, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe00, 0x10, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xfe10, 0xa, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe20, 0x7, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xfe30, 0x20, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe50, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe51, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe52, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe54, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe55, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe56, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe59, 0x6, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe5f, 0x1, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe60, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe62, 0x2, GRUB_BIDI_TYPE_ES, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe64, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe66, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe68, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe69, 0x2, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe6b, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe70, 0x5, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfe76, 0x87, GRUB_BIDI_TYPE_AL, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfeff, 0x1, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xff01, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff03, 0x3, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff06, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff08, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xff0a, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff0b, 0x1, GRUB_BIDI_TYPE_ES, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff0c, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff0d, 0x1, GRUB_BIDI_TYPE_ES, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff0e, 0x2, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff10, 0xa, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff1a, 0x1, GRUB_BIDI_TYPE_CS, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff1b, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff1c, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xff1d, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff1e, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xff1f, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff3b, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xff3c, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff3d, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xff3e, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff5b, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xff5c, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff5d, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xff5e, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff5f, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xff61, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xff62, 0x2, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0xff64, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xffe0, 0x2, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xffe2, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xffe5, 0x2, GRUB_BIDI_TYPE_ET, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xffe8, 0x7, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xfff9, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xfffc, 0x2, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10101, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10140, 0x4b, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10190, 0xc, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x101fd, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10800, 0x6, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10808, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1080a, 0x2c, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10837, 0x2, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1083c, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1083f, 0x17, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10857, 0x9, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10900, 0x1c, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1091f, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10920, 0x1a, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1093f, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10a00, 0x1, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10a01, 0x3, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10a05, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10a0c, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10a0d, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10a0e, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10a0f, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10a10, 0x4, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10a15, 0x3, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10a19, 0x1b, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10a38, 0x1, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10a39, 0x1, GRUB_BIDI_TYPE_NSM, 1, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10a3a, 0x1, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10a3f, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x10a40, 0x8, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10a50, 0x9, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10a60, 0x20, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10b00, 0x36, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10b39, 0x7, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10b40, 0x16, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10b58, 0x1b, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10b78, 0x8, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10c00, 0x49, GRUB_BIDI_TYPE_R, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x10e60, 0x1f, GRUB_BIDI_TYPE_AN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x11000, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x11001, 0x1, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x11002, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x11038, 0xe, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x11046, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x11052, 0x14, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x11080, 0x2, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x11082, 0x1, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x110b0, 0x3, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x110b3, 0x4, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x110b7, 0x2, GRUB_BIDI_TYPE_L, 254, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x110b9, 0x1, GRUB_BIDI_TYPE_NSM, 9, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x110ba, 0x1, GRUB_BIDI_TYPE_NSM, 7, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1d165, 0x2, GRUB_BIDI_TYPE_L, 216, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d167, 0x3, GRUB_BIDI_TYPE_NSM, 1, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1d16d, 0x1, GRUB_BIDI_TYPE_L, 226, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d16e, 0x5, GRUB_BIDI_TYPE_L, 216, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d173, 0x8, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1d17b, 0x8, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1d185, 0x5, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1d18a, 0x2, GRUB_BIDI_TYPE_NSM, 220, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1d1aa, 0x4, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1d200, 0x42, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d242, 0x3, GRUB_BIDI_TYPE_NSM, 230, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0x1d245, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d300, 0x57, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d6db, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d715, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d74f, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d789, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d7c3, 0x1, GRUB_BIDI_TYPE_ON, 0, 1, GRUB_JOIN_TYPE_NONJOINING},
+{0x1d7ce, 0x32, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f000, 0x2c, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f030, 0x64, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f0a0, 0xf, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f0b1, 0xe, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f0c1, 0xf, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f0d1, 0xf, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f100, 0xb, GRUB_BIDI_TYPE_EN, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f300, 0x21, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f330, 0x6, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f337, 0x46, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f380, 0x14, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f3a0, 0x25, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f3c6, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f3e0, 0x11, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f400, 0x3f, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f440, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f442, 0x4a, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f48d, 0x6b, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f4f9, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f500, 0x24, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f525, 0x19, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f550, 0x18, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f5fb, 0x5, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f601, 0x10, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f612, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f616, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f618, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f61a, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f61c, 0x3, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f620, 0x6, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f628, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f62d, 0x1, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f630, 0x4, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f635, 0xc, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f645, 0xb, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f680, 0x46, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0x1f700, 0x74, GRUB_BIDI_TYPE_ON, 0, 0, GRUB_JOIN_TYPE_NONJOINING},
+{0xe0001, 0x1, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xe0020, 0x60, GRUB_BIDI_TYPE_BN, 0, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0xe0100, 0xf0, GRUB_BIDI_TYPE_NSM, 255, 0, GRUB_JOIN_TYPE_TRANSPARENT},
+{0, 0, 0, 0, 0, 0},
+};
+struct grub_unicode_bidi_pair grub_unicode_bidi_pairs[] = {
+{0x28, 0x29},
+{0x29, 0x28},
+{0x3c, 0x3e},
+{0x3e, 0x3c},
+{0x5b, 0x5d},
+{0x5d, 0x5b},
+{0x7b, 0x7d},
+{0x7d, 0x7b},
+{0xab, 0xbb},
+{0xbb, 0xab},
+{0xf3a, 0xf3b},
+{0xf3b, 0xf3a},
+{0xf3c, 0xf3d},
+{0xf3d, 0xf3c},
+{0x169b, 0x169c},
+{0x169c, 0x169b},
+{0x2039, 0x203a},
+{0x203a, 0x2039},
+{0x2045, 0x2046},
+{0x2046, 0x2045},
+{0x207d, 0x207e},
+{0x207e, 0x207d},
+{0x208d, 0x208e},
+{0x208e, 0x208d},
+{0x2208, 0x220b},
+{0x2209, 0x220c},
+{0x220a, 0x220d},
+{0x220b, 0x2208},
+{0x220c, 0x2209},
+{0x220d, 0x220a},
+{0x2215, 0x29f5},
+{0x223c, 0x223d},
+{0x223d, 0x223c},
+{0x2243, 0x22cd},
+{0x2252, 0x2253},
+{0x2253, 0x2252},
+{0x2254, 0x2255},
+{0x2255, 0x2254},
+{0x2264, 0x2265},
+{0x2265, 0x2264},
+{0x2266, 0x2267},
+{0x2267, 0x2266},
+{0x2268, 0x2269},
+{0x2269, 0x2268},
+{0x226a, 0x226b},
+{0x226b, 0x226a},
+{0x226e, 0x226f},
+{0x226f, 0x226e},
+{0x2270, 0x2271},
+{0x2271, 0x2270},
+{0x2272, 0x2273},
+{0x2273, 0x2272},
+{0x2274, 0x2275},
+{0x2275, 0x2274},
+{0x2276, 0x2277},
+{0x2277, 0x2276},
+{0x2278, 0x2279},
+{0x2279, 0x2278},
+{0x227a, 0x227b},
+{0x227b, 0x227a},
+{0x227c, 0x227d},
+{0x227d, 0x227c},
+{0x227e, 0x227f},
+{0x227f, 0x227e},
+{0x2280, 0x2281},
+{0x2281, 0x2280},
+{0x2282, 0x2283},
+{0x2283, 0x2282},
+{0x2284, 0x2285},
+{0x2285, 0x2284},
+{0x2286, 0x2287},
+{0x2287, 0x2286},
+{0x2288, 0x2289},
+{0x2289, 0x2288},
+{0x228a, 0x228b},
+{0x228b, 0x228a},
+{0x228f, 0x2290},
+{0x2290, 0x228f},
+{0x2291, 0x2292},
+{0x2292, 0x2291},
+{0x2298, 0x29b8},
+{0x22a2, 0x22a3},
+{0x22a3, 0x22a2},
+{0x22a6, 0x2ade},
+{0x22a8, 0x2ae4},
+{0x22a9, 0x2ae3},
+{0x22ab, 0x2ae5},
+{0x22b0, 0x22b1},
+{0x22b1, 0x22b0},
+{0x22b2, 0x22b3},
+{0x22b3, 0x22b2},
+{0x22b4, 0x22b5},
+{0x22b5, 0x22b4},
+{0x22b6, 0x22b7},
+{0x22b7, 0x22b6},
+{0x22c9, 0x22ca},
+{0x22ca, 0x22c9},
+{0x22cb, 0x22cc},
+{0x22cc, 0x22cb},
+{0x22cd, 0x2243},
+{0x22d0, 0x22d1},
+{0x22d1, 0x22d0},
+{0x22d6, 0x22d7},
+{0x22d7, 0x22d6},
+{0x22d8, 0x22d9},
+{0x22d9, 0x22d8},
+{0x22da, 0x22db},
+{0x22db, 0x22da},
+{0x22dc, 0x22dd},
+{0x22dd, 0x22dc},
+{0x22de, 0x22df},
+{0x22df, 0x22de},
+{0x22e0, 0x22e1},
+{0x22e1, 0x22e0},
+{0x22e2, 0x22e3},
+{0x22e3, 0x22e2},
+{0x22e4, 0x22e5},
+{0x22e5, 0x22e4},
+{0x22e6, 0x22e7},
+{0x22e7, 0x22e6},
+{0x22e8, 0x22e9},
+{0x22e9, 0x22e8},
+{0x22ea, 0x22eb},
+{0x22eb, 0x22ea},
+{0x22ec, 0x22ed},
+{0x22ed, 0x22ec},
+{0x22f0, 0x22f1},
+{0x22f1, 0x22f0},
+{0x22f2, 0x22fa},
+{0x22f3, 0x22fb},
+{0x22f4, 0x22fc},
+{0x22f6, 0x22fd},
+{0x22f7, 0x22fe},
+{0x22fa, 0x22f2},
+{0x22fb, 0x22f3},
+{0x22fc, 0x22f4},
+{0x22fd, 0x22f6},
+{0x22fe, 0x22f7},
+{0x2308, 0x2309},
+{0x2309, 0x2308},
+{0x230a, 0x230b},
+{0x230b, 0x230a},
+{0x2329, 0x232a},
+{0x232a, 0x2329},
+{0x2768, 0x2769},
+{0x2769, 0x2768},
+{0x276a, 0x276b},
+{0x276b, 0x276a},
+{0x276c, 0x276d},
+{0x276d, 0x276c},
+{0x276e, 0x276f},
+{0x276f, 0x276e},
+{0x2770, 0x2771},
+{0x2771, 0x2770},
+{0x2772, 0x2773},
+{0x2773, 0x2772},
+{0x2774, 0x2775},
+{0x2775, 0x2774},
+{0x27c3, 0x27c4},
+{0x27c4, 0x27c3},
+{0x27c5, 0x27c6},
+{0x27c6, 0x27c5},
+{0x27c8, 0x27c9},
+{0x27c9, 0x27c8},
+{0x27d5, 0x27d6},
+{0x27d6, 0x27d5},
+{0x27dd, 0x27de},
+{0x27de, 0x27dd},
+{0x27e2, 0x27e3},
+{0x27e3, 0x27e2},
+{0x27e4, 0x27e5},
+{0x27e5, 0x27e4},
+{0x27e6, 0x27e7},
+{0x27e7, 0x27e6},
+{0x27e8, 0x27e9},
+{0x27e9, 0x27e8},
+{0x27ea, 0x27eb},
+{0x27eb, 0x27ea},
+{0x27ec, 0x27ed},
+{0x27ed, 0x27ec},
+{0x27ee, 0x27ef},
+{0x27ef, 0x27ee},
+{0x2983, 0x2984},
+{0x2984, 0x2983},
+{0x2985, 0x2986},
+{0x2986, 0x2985},
+{0x2987, 0x2988},
+{0x2988, 0x2987},
+{0x2989, 0x298a},
+{0x298a, 0x2989},
+{0x298b, 0x298c},
+{0x298c, 0x298b},
+{0x298d, 0x2990},
+{0x298e, 0x298f},
+{0x298f, 0x298e},
+{0x2990, 0x298d},
+{0x2991, 0x2992},
+{0x2992, 0x2991},
+{0x2993, 0x2994},
+{0x2994, 0x2993},
+{0x2995, 0x2996},
+{0x2996, 0x2995},
+{0x2997, 0x2998},
+{0x2998, 0x2997},
+{0x29b8, 0x2298},
+{0x29c0, 0x29c1},
+{0x29c1, 0x29c0},
+{0x29c4, 0x29c5},
+{0x29c5, 0x29c4},
+{0x29cf, 0x29d0},
+{0x29d0, 0x29cf},
+{0x29d1, 0x29d2},
+{0x29d2, 0x29d1},
+{0x29d4, 0x29d5},
+{0x29d5, 0x29d4},
+{0x29d8, 0x29d9},
+{0x29d9, 0x29d8},
+{0x29da, 0x29db},
+{0x29db, 0x29da},
+{0x29f5, 0x2215},
+{0x29f8, 0x29f9},
+{0x29f9, 0x29f8},
+{0x29fc, 0x29fd},
+{0x29fd, 0x29fc},
+{0x2a2b, 0x2a2c},
+{0x2a2c, 0x2a2b},
+{0x2a2d, 0x2a2e},
+{0x2a2e, 0x2a2d},
+{0x2a34, 0x2a35},
+{0x2a35, 0x2a34},
+{0x2a3c, 0x2a3d},
+{0x2a3d, 0x2a3c},
+{0x2a64, 0x2a65},
+{0x2a65, 0x2a64},
+{0x2a79, 0x2a7a},
+{0x2a7a, 0x2a79},
+{0x2a7d, 0x2a7e},
+{0x2a7e, 0x2a7d},
+{0x2a7f, 0x2a80},
+{0x2a80, 0x2a7f},
+{0x2a81, 0x2a82},
+{0x2a82, 0x2a81},
+{0x2a83, 0x2a84},
+{0x2a84, 0x2a83},
+{0x2a8b, 0x2a8c},
+{0x2a8c, 0x2a8b},
+{0x2a91, 0x2a92},
+{0x2a92, 0x2a91},
+{0x2a93, 0x2a94},
+{0x2a94, 0x2a93},
+{0x2a95, 0x2a96},
+{0x2a96, 0x2a95},
+{0x2a97, 0x2a98},
+{0x2a98, 0x2a97},
+{0x2a99, 0x2a9a},
+{0x2a9a, 0x2a99},
+{0x2a9b, 0x2a9c},
+{0x2a9c, 0x2a9b},
+{0x2aa1, 0x2aa2},
+{0x2aa2, 0x2aa1},
+{0x2aa6, 0x2aa7},
+{0x2aa7, 0x2aa6},
+{0x2aa8, 0x2aa9},
+{0x2aa9, 0x2aa8},
+{0x2aaa, 0x2aab},
+{0x2aab, 0x2aaa},
+{0x2aac, 0x2aad},
+{0x2aad, 0x2aac},
+{0x2aaf, 0x2ab0},
+{0x2ab0, 0x2aaf},
+{0x2ab3, 0x2ab4},
+{0x2ab4, 0x2ab3},
+{0x2abb, 0x2abc},
+{0x2abc, 0x2abb},
+{0x2abd, 0x2abe},
+{0x2abe, 0x2abd},
+{0x2abf, 0x2ac0},
+{0x2ac0, 0x2abf},
+{0x2ac1, 0x2ac2},
+{0x2ac2, 0x2ac1},
+{0x2ac3, 0x2ac4},
+{0x2ac4, 0x2ac3},
+{0x2ac5, 0x2ac6},
+{0x2ac6, 0x2ac5},
+{0x2acd, 0x2ace},
+{0x2ace, 0x2acd},
+{0x2acf, 0x2ad0},
+{0x2ad0, 0x2acf},
+{0x2ad1, 0x2ad2},
+{0x2ad2, 0x2ad1},
+{0x2ad3, 0x2ad4},
+{0x2ad4, 0x2ad3},
+{0x2ad5, 0x2ad6},
+{0x2ad6, 0x2ad5},
+{0x2ade, 0x22a6},
+{0x2ae3, 0x22a9},
+{0x2ae4, 0x22a8},
+{0x2ae5, 0x22ab},
+{0x2aec, 0x2aed},
+{0x2aed, 0x2aec},
+{0x2af7, 0x2af8},
+{0x2af8, 0x2af7},
+{0x2af9, 0x2afa},
+{0x2afa, 0x2af9},
+{0x2e02, 0x2e03},
+{0x2e03, 0x2e02},
+{0x2e04, 0x2e05},
+{0x2e05, 0x2e04},
+{0x2e09, 0x2e0a},
+{0x2e0a, 0x2e09},
+{0x2e0c, 0x2e0d},
+{0x2e0d, 0x2e0c},
+{0x2e1c, 0x2e1d},
+{0x2e1d, 0x2e1c},
+{0x2e20, 0x2e21},
+{0x2e21, 0x2e20},
+{0x2e22, 0x2e23},
+{0x2e23, 0x2e22},
+{0x2e24, 0x2e25},
+{0x2e25, 0x2e24},
+{0x2e26, 0x2e27},
+{0x2e27, 0x2e26},
+{0x2e28, 0x2e29},
+{0x2e29, 0x2e28},
+{0x3008, 0x3009},
+{0x3009, 0x3008},
+{0x300a, 0x300b},
+{0x300b, 0x300a},
+{0x300c, 0x300d},
+{0x300d, 0x300c},
+{0x300e, 0x300f},
+{0x300f, 0x300e},
+{0x3010, 0x3011},
+{0x3011, 0x3010},
+{0x3014, 0x3015},
+{0x3015, 0x3014},
+{0x3016, 0x3017},
+{0x3017, 0x3016},
+{0x3018, 0x3019},
+{0x3019, 0x3018},
+{0x301a, 0x301b},
+{0x301b, 0x301a},
+{0xfe59, 0xfe5a},
+{0xfe5a, 0xfe59},
+{0xfe5b, 0xfe5c},
+{0xfe5c, 0xfe5b},
+{0xfe5d, 0xfe5e},
+{0xfe5e, 0xfe5d},
+{0xfe64, 0xfe65},
+{0xfe65, 0xfe64},
+{0xff08, 0xff09},
+{0xff09, 0xff08},
+{0xff1c, 0xff1e},
+{0xff1e, 0xff1c},
+{0xff3b, 0xff3d},
+{0xff3d, 0xff3b},
+{0xff5b, 0xff5d},
+{0xff5d, 0xff5b},
+{0xff5f, 0xff60},
+{0xff60, 0xff5f},
+{0xff62, 0xff63},
+{0xff63, 0xff62},
+{0, 0},
+};
+struct grub_unicode_arabic_shape grub_unicode_arabic_shapes[] = {
+ {0x6ad, 0xfbd3, 0xfbd4, 0xfbd6, 0xfbd5},
+ {0x67f, 0xfb62, 0xfb63, 0xfb65, 0xfb64},
+ {0x6c0, 0xfba4, 0xfba5, 0x0, 0x0},
+ {0x642, 0xfed5, 0xfed6, 0xfed8, 0xfed7},
+ {0x630, 0xfeab, 0xfeac, 0x0, 0x0},
+ {0x635, 0xfeb9, 0xfeba, 0xfebc, 0xfebb},
+ {0x637, 0xfec1, 0xfec2, 0xfec4, 0xfec3},
+ {0x62d, 0xfea1, 0xfea2, 0xfea4, 0xfea3},
+ {0x644, 0xfedd, 0xfede, 0xfee0, 0xfedf},
+ {0x6a9, 0xfb8e, 0xfb8f, 0xfb91, 0xfb90},
+ {0x6c1, 0xfba6, 0xfba7, 0xfba9, 0xfba8},
+ {0x68d, 0xfb82, 0xfb83, 0x0, 0x0},
+ {0x680, 0xfb5a, 0xfb5b, 0xfb5d, 0xfb5c},
+ {0x64a, 0xfef1, 0xfef2, 0xfef4, 0xfef3},
+ {0x643, 0xfed9, 0xfeda, 0xfedc, 0xfedb},
+ {0x638, 0xfec5, 0xfec6, 0xfec8, 0xfec7},
+ {0x6c6, 0xfbd9, 0xfbda, 0x0, 0x0},
+ {0x6d2, 0xfbae, 0xfbaf, 0x0, 0x0},
+ {0x67e, 0xfb56, 0xfb57, 0xfb59, 0xfb58},
+ {0x627, 0xfe8d, 0xfe8e, 0x0, 0x0},
+ {0x622, 0xfe81, 0xfe82, 0x0, 0x0},
+ {0x628, 0xfe8f, 0xfe90, 0xfe92, 0xfe91},
+ {0x688, 0xfb88, 0xfb89, 0x0, 0x0},
+ {0x687, 0xfb7e, 0xfb7f, 0xfb81, 0xfb80},
+ {0x6b1, 0xfb9a, 0xfb9b, 0xfb9d, 0xfb9c},
+ {0x645, 0xfee1, 0xfee2, 0xfee4, 0xfee3},
+ {0x62c, 0xfe9d, 0xfe9e, 0xfea0, 0xfe9f},
+ {0x6c5, 0xfbe0, 0xfbe1, 0x0, 0x0},
+ {0x671, 0xfb50, 0xfb51, 0x0, 0x0},
+ {0x634, 0xfeb5, 0xfeb6, 0xfeb8, 0xfeb7},
+ {0x625, 0xfe87, 0xfe88, 0x0, 0x0},
+ {0x67b, 0xfb52, 0xfb53, 0xfb55, 0xfb54},
+ {0x646, 0xfee5, 0xfee6, 0xfee8, 0xfee7},
+ {0x68c, 0xfb84, 0xfb85, 0x0, 0x0},
+ {0x62b, 0xfe99, 0xfe9a, 0xfe9c, 0xfe9b},
+ {0x631, 0xfead, 0xfeae, 0x0, 0x0},
+ {0x6b3, 0xfb96, 0xfb97, 0xfb99, 0xfb98},
+ {0x683, 0xfb76, 0xfb77, 0xfb79, 0xfb78},
+ {0x62a, 0xfe95, 0xfe96, 0xfe98, 0xfe97},
+ {0x63a, 0xfecd, 0xfece, 0xfed0, 0xfecf},
+ {0x624, 0xfe85, 0xfe86, 0x0, 0x0},
+ {0x679, 0xfb66, 0xfb67, 0xfb69, 0xfb68},
+ {0x68e, 0xfb86, 0xfb87, 0x0, 0x0},
+ {0x623, 0xfe83, 0xfe84, 0x0, 0x0},
+ {0x6c9, 0xfbe2, 0xfbe3, 0x0, 0x0},
+ {0x641, 0xfed1, 0xfed2, 0xfed4, 0xfed3},
+ {0x648, 0xfeed, 0xfeee, 0x0, 0x0},
+ {0x698, 0xfb8a, 0xfb8b, 0x0, 0x0},
+ {0x647, 0xfee9, 0xfeea, 0xfeec, 0xfeeb},
+ {0x6a4, 0xfb6a, 0xfb6b, 0xfb6d, 0xfb6c},
+ {0x62e, 0xfea5, 0xfea6, 0xfea8, 0xfea7},
+ {0x6bb, 0xfba0, 0xfba1, 0xfba3, 0xfba2},
+ {0x686, 0xfb7a, 0xfb7b, 0xfb7d, 0xfb7c},
+ {0x6cc, 0xfbfc, 0xfbfd, 0xfbff, 0xfbfe},
+ {0x6a6, 0xfb6e, 0xfb6f, 0xfb71, 0xfb70},
+ {0x639, 0xfec9, 0xfeca, 0xfecc, 0xfecb},
+ {0x633, 0xfeb1, 0xfeb2, 0xfeb4, 0xfeb3},
+ {0x6c8, 0xfbdb, 0xfbdc, 0x0, 0x0},
+ {0x636, 0xfebd, 0xfebe, 0xfec0, 0xfebf},
+ {0x62f, 0xfea9, 0xfeaa, 0x0, 0x0},
+ {0x6af, 0xfb92, 0xfb93, 0xfb95, 0xfb94},
+ {0x6d0, 0xfbe4, 0xfbe5, 0xfbe7, 0xfbe6},
+ {0x6cb, 0xfbde, 0xfbdf, 0x0, 0x0},
+ {0x626, 0xfe89, 0xfe8a, 0xfe8c, 0xfe8b},
+ {0x6be, 0xfbaa, 0xfbab, 0xfbad, 0xfbac},
+ {0x6c7, 0xfbd7, 0xfbd8, 0x0, 0x0},
+ {0x684, 0xfb72, 0xfb73, 0xfb75, 0xfb74},
+ {0x6d3, 0xfbb0, 0xfbb1, 0x0, 0x0},
+ {0x67a, 0xfb5e, 0xfb5f, 0xfb61, 0xfb60},
+ {0x632, 0xfeaf, 0xfeb0, 0x0, 0x0},
+ {0x691, 0xfb8c, 0xfb8d, 0x0, 0x0},
+ {0x629, 0xfe93, 0xfe94, 0x0, 0x0},
+ {0, 0, 0, 0, 0},
+};
diff --git a/grub-core/video/bitmap.c b/grub-core/video/bitmap.c
new file mode 100644
index 0000000..6256e20
--- /dev/null
+++ b/grub-core/video/bitmap.c
@@ -0,0 +1,238 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/video.h>
+#include <grub/bitmap.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/i18n.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* List of bitmap readers registered to system. */
+static grub_video_bitmap_reader_t bitmap_readers_list;
+
+/* Register bitmap reader. */
+void
+grub_video_bitmap_reader_register (grub_video_bitmap_reader_t reader)
+{
+ reader->next = bitmap_readers_list;
+ bitmap_readers_list = reader;
+}
+
+/* Unregister bitmap reader. */
+void
+grub_video_bitmap_reader_unregister (grub_video_bitmap_reader_t reader)
+{
+ grub_video_bitmap_reader_t *p, q;
+
+ for (p = &bitmap_readers_list, q = *p; q; p = &(q->next), q = q->next)
+ if (q == reader)
+ {
+ *p = q->next;
+ break;
+ }
+}
+
+/* Creates new bitmap, saves created bitmap on success to *bitmap. */
+grub_err_t
+grub_video_bitmap_create (struct grub_video_bitmap **bitmap,
+ unsigned int width, unsigned int height,
+ enum grub_video_blit_format blit_format)
+{
+ struct grub_video_mode_info *mode_info;
+ grub_size_t size;
+
+ if (!bitmap)
+ return grub_error (GRUB_ERR_BUG, "invalid argument");
+
+ *bitmap = 0;
+
+ if (width == 0 || height == 0)
+ return grub_error (GRUB_ERR_BUG, "invalid argument");
+
+ *bitmap = (struct grub_video_bitmap *)grub_malloc (sizeof (struct grub_video_bitmap));
+ if (! *bitmap)
+ return grub_errno;
+
+ mode_info = &((*bitmap)->mode_info);
+
+ /* Populate mode_info. */
+ mode_info->width = width;
+ mode_info->height = height;
+ mode_info->blit_format = blit_format;
+
+ switch (blit_format)
+ {
+ case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
+ mode_info->mode_type = GRUB_VIDEO_MODE_TYPE_RGB
+ | GRUB_VIDEO_MODE_TYPE_ALPHA;
+ mode_info->bpp = 32;
+ mode_info->bytes_per_pixel = 4;
+ mode_info->number_of_colors = 256;
+ mode_info->red_mask_size = 8;
+ mode_info->red_field_pos = 0;
+ mode_info->green_mask_size = 8;
+ mode_info->green_field_pos = 8;
+ mode_info->blue_mask_size = 8;
+ mode_info->blue_field_pos = 16;
+ mode_info->reserved_mask_size = 8;
+ mode_info->reserved_field_pos = 24;
+ break;
+
+ case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
+ mode_info->mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
+ mode_info->bpp = 24;
+ mode_info->bytes_per_pixel = 3;
+ mode_info->number_of_colors = 256;
+ mode_info->red_mask_size = 8;
+ mode_info->red_field_pos = 0;
+ mode_info->green_mask_size = 8;
+ mode_info->green_field_pos = 8;
+ mode_info->blue_mask_size = 8;
+ mode_info->blue_field_pos = 16;
+ mode_info->reserved_mask_size = 0;
+ mode_info->reserved_field_pos = 0;
+ break;
+
+ case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
+ mode_info->mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
+ mode_info->bpp = 8;
+ mode_info->bytes_per_pixel = 1;
+ mode_info->number_of_colors = 256;
+ mode_info->red_mask_size = 0;
+ mode_info->red_field_pos = 0;
+ mode_info->green_mask_size = 0;
+ mode_info->green_field_pos = 0;
+ mode_info->blue_mask_size = 0;
+ mode_info->blue_field_pos = 0;
+ mode_info->reserved_mask_size = 0;
+ mode_info->reserved_field_pos = 0;
+ break;
+
+ default:
+ grub_free (*bitmap);
+ *bitmap = 0;
+
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unsupported bitmap format");
+ }
+
+ mode_info->pitch = width * mode_info->bytes_per_pixel;
+
+ /* Calculate size needed for the data. */
+ if (grub_mul (width, mode_info->bytes_per_pixel, &size) ||
+ grub_mul (size, height, &size))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+ goto fail;
+ }
+
+ (*bitmap)->data = grub_zalloc (size);
+ if (! (*bitmap)->data)
+ goto fail;
+
+ return GRUB_ERR_NONE;
+
+ fail:
+ grub_free (*bitmap);
+ *bitmap = NULL;
+
+ return grub_errno;
+}
+
+/* Frees all resources allocated by bitmap. */
+grub_err_t
+grub_video_bitmap_destroy (struct grub_video_bitmap *bitmap)
+{
+ if (! bitmap)
+ return GRUB_ERR_NONE;
+
+ grub_free (bitmap->data);
+ grub_free (bitmap);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Match extension to filename. */
+static int
+match_extension (const char *filename, const char *ext)
+{
+ int pos;
+ int ext_len;
+
+ pos = grub_strlen (filename);
+ ext_len = grub_strlen (ext);
+
+ if (! pos || ! ext_len || ext_len > pos)
+ return 0;
+
+ pos -= ext_len;
+
+ return grub_strcasecmp (filename + pos, ext) == 0;
+}
+
+/* Loads bitmap using registered bitmap readers. */
+grub_err_t
+grub_video_bitmap_load (struct grub_video_bitmap **bitmap,
+ const char *filename)
+{
+ grub_video_bitmap_reader_t reader = bitmap_readers_list;
+
+ if (!bitmap)
+ return grub_error (GRUB_ERR_BUG, "invalid argument");
+
+ *bitmap = 0;
+
+ while (reader)
+ {
+ if (match_extension (filename, reader->extension))
+ return reader->reader (bitmap, filename);
+
+ reader = reader->next;
+ }
+
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ /* TRANSLATORS: We're speaking about bitmap images like
+ JPEG or PNG. */
+ N_("bitmap file `%s' is of"
+ " unsupported format"), filename);
+}
+
+/* Return mode info for bitmap. */
+void grub_video_bitmap_get_mode_info (struct grub_video_bitmap *bitmap,
+ struct grub_video_mode_info *mode_info)
+{
+ if (!bitmap)
+ return;
+
+ *mode_info = bitmap->mode_info;
+}
+
+/* Return pointer to bitmap's raw data. */
+void *grub_video_bitmap_get_data (struct grub_video_bitmap *bitmap)
+{
+ if (!bitmap)
+ return 0;
+
+ return bitmap->data;
+}
+
diff --git a/grub-core/video/bitmap_scale.c b/grub-core/video/bitmap_scale.c
new file mode 100644
index 0000000..70c32f0
--- /dev/null
+++ b/grub-core/video/bitmap_scale.c
@@ -0,0 +1,515 @@
+/* bitmap_scale.c - Bitmap scaling. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/video.h>
+#include <grub/bitmap.h>
+#include <grub/bitmap_scale.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Prototypes for module-local functions. */
+static grub_err_t scale_nn (struct grub_video_bitmap *dst,
+ struct grub_video_bitmap *src);
+static grub_err_t scale_bilinear (struct grub_video_bitmap *dst,
+ struct grub_video_bitmap *src);
+
+static grub_err_t
+verify_source_bitmap (struct grub_video_bitmap *src)
+{
+ /* Verify the simplifying assumptions. */
+ if (src == 0)
+ return grub_error (GRUB_ERR_BUG,
+ "null src bitmap in grub_video_bitmap_create_scaled");
+ if (src->mode_info.red_field_pos % 8 != 0
+ || src->mode_info.green_field_pos % 8 != 0
+ || src->mode_info.blue_field_pos % 8 != 0
+ || src->mode_info.reserved_field_pos % 8 != 0)
+ return grub_error (GRUB_ERR_BUG,
+ "src format not supported for scale");
+ if (src->mode_info.width == 0 || src->mode_info.height == 0)
+ return grub_error (GRUB_ERR_BUG,
+ "source bitmap has a zero dimension");
+ if (src->mode_info.bytes_per_pixel * 8 != src->mode_info.bpp)
+ return grub_error (GRUB_ERR_BUG,
+ "bitmap to scale has inconsistent Bpp and bpp");
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_bitmap_scale (struct grub_video_bitmap *dst,
+ struct grub_video_bitmap *src,
+ enum grub_video_bitmap_scale_method scale_method)
+{
+ switch (scale_method)
+ {
+ case GRUB_VIDEO_BITMAP_SCALE_METHOD_FASTEST:
+ case GRUB_VIDEO_BITMAP_SCALE_METHOD_NEAREST:
+ return scale_nn (dst, src);
+ case GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST:
+ case GRUB_VIDEO_BITMAP_SCALE_METHOD_BILINEAR:
+ return scale_bilinear (dst, src);
+ default:
+ return grub_error (GRUB_ERR_BUG, "Invalid scale_method value");
+ }
+}
+
+/* This function creates a new scaled version of the bitmap SRC. The new
+ bitmap has dimensions DST_WIDTH by DST_HEIGHT. The scaling algorithm
+ is given by SCALE_METHOD. If an error is encountered, the return code is
+ not equal to GRUB_ERR_NONE, and the bitmap DST is either not created, or
+ it is destroyed before this function returns.
+
+ Supports only direct color modes which have components separated
+ into bytes (e.g., RGBA 8:8:8:8 or BGR 8:8:8 true color).
+ But because of this simplifying assumption, the implementation is
+ greatly simplified. */
+grub_err_t
+grub_video_bitmap_create_scaled (struct grub_video_bitmap **dst,
+ int dst_width, int dst_height,
+ struct grub_video_bitmap *src,
+ enum grub_video_bitmap_scale_method
+ scale_method)
+{
+ *dst = 0;
+
+ grub_err_t err = verify_source_bitmap(src);
+ if (err != GRUB_ERR_NONE)
+ return err;
+ if (dst_width <= 0 || dst_height <= 0)
+ return grub_error (GRUB_ERR_BUG,
+ "requested to scale to a size w/ a zero dimension");
+
+ /* Create the new bitmap. */
+ grub_err_t ret;
+ ret = grub_video_bitmap_create (dst, dst_width, dst_height,
+ src->mode_info.blit_format);
+ if (ret != GRUB_ERR_NONE)
+ return ret; /* Error. */
+
+ ret = grub_video_bitmap_scale (*dst, src, scale_method);
+
+ if (ret == GRUB_ERR_NONE)
+ {
+ /* Success: *dst is now a pointer to the scaled bitmap. */
+ return GRUB_ERR_NONE;
+ }
+ else
+ {
+ /* Destroy the bitmap and return the error code. */
+ grub_video_bitmap_destroy (*dst);
+ *dst = 0;
+ return ret;
+ }
+}
+
+static grub_err_t
+make_h_align (unsigned *x, unsigned *w, unsigned new_w,
+ grub_video_bitmap_h_align_t h_align)
+{
+ grub_err_t ret = GRUB_ERR_NONE;
+ if (new_w >= *w)
+ {
+ *x = 0;
+ *w = new_w;
+ return GRUB_ERR_NONE;
+ }
+ switch (h_align)
+ {
+ case GRUB_VIDEO_BITMAP_H_ALIGN_LEFT:
+ *x = 0;
+ break;
+ case GRUB_VIDEO_BITMAP_H_ALIGN_CENTER:
+ *x = (*w - new_w) / 2;
+ break;
+ case GRUB_VIDEO_BITMAP_H_ALIGN_RIGHT:
+ *x = *w - new_w;
+ break;
+ default:
+ ret = grub_error (GRUB_ERR_BUG, "Invalid h_align value");
+ break;
+ }
+ *w = new_w;
+ return ret;
+}
+
+static grub_err_t
+make_v_align (unsigned *y, unsigned *h, unsigned new_h,
+ grub_video_bitmap_v_align_t v_align)
+{
+ grub_err_t ret = GRUB_ERR_NONE;
+ if (new_h >= *h)
+ {
+ *y = 0;
+ *h = new_h;
+ return GRUB_ERR_NONE;
+ }
+ switch (v_align)
+ {
+ case GRUB_VIDEO_BITMAP_V_ALIGN_TOP:
+ *y = 0;
+ break;
+ case GRUB_VIDEO_BITMAP_V_ALIGN_CENTER:
+ *y = (*h - new_h) / 2;
+ break;
+ case GRUB_VIDEO_BITMAP_V_ALIGN_BOTTOM:
+ *y = *h - new_h;
+ break;
+ default:
+ ret = grub_error (GRUB_ERR_BUG, "Invalid v_align value");
+ break;
+ }
+ *h = new_h;
+ return ret;
+}
+
+grub_err_t
+grub_video_bitmap_scale_proportional (struct grub_video_bitmap **dst,
+ int dst_width, int dst_height,
+ struct grub_video_bitmap *src,
+ enum grub_video_bitmap_scale_method
+ scale_method,
+ grub_video_bitmap_selection_method_t
+ selection_method,
+ grub_video_bitmap_v_align_t v_align,
+ grub_video_bitmap_h_align_t h_align)
+{
+ *dst = 0;
+ grub_err_t ret = verify_source_bitmap(src);
+ if (ret != GRUB_ERR_NONE)
+ return ret;
+ if (dst_width <= 0 || dst_height <= 0)
+ return grub_error (GRUB_ERR_BUG,
+ "requested to scale to a size w/ a zero dimension");
+
+ ret = grub_video_bitmap_create (dst, dst_width, dst_height,
+ src->mode_info.blit_format);
+ if (ret != GRUB_ERR_NONE)
+ return ret; /* Error. */
+
+ unsigned dx0 = 0;
+ unsigned dy0 = 0;
+ unsigned dw = dst_width;
+ unsigned dh = dst_height;
+ unsigned sx0 = 0;
+ unsigned sy0 = 0;
+ unsigned sw = src->mode_info.width;
+ unsigned sh = src->mode_info.height;
+
+ switch (selection_method)
+ {
+ case GRUB_VIDEO_BITMAP_SELECTION_METHOD_CROP:
+ /* Comparing sw/sh VS dw/dh. */
+ if (sw * dh < dw * sh)
+ ret = make_v_align (&sy0, &sh, sw * dh / dw, v_align);
+ else
+ ret = make_h_align (&sx0, &sw, sh * dw / dh, h_align);
+ break;
+ case GRUB_VIDEO_BITMAP_SELECTION_METHOD_PADDING:
+ if (sw * dh < dw * sh)
+ ret = make_h_align (&dx0, &dw, sw * dh / sh, h_align);
+ else
+ ret = make_v_align (&dy0, &dh, sh * dw / sw, v_align);
+ break;
+ case GRUB_VIDEO_BITMAP_SELECTION_METHOD_FITWIDTH:
+ if (sw * dh < dw * sh)
+ ret = make_v_align (&sy0, &sh, sw * dh / dw, v_align);
+ else
+ ret = make_v_align (&dy0, &dh, sh * dw / sw, v_align);
+ break;
+ case GRUB_VIDEO_BITMAP_SELECTION_METHOD_FITHEIGHT:
+ if (sw * dh < dw * sh)
+ ret = make_h_align (&dx0, &dw, sw * dh / sh, h_align);
+ else
+ ret = make_h_align (&sx0, &sw, sh * dw / dh, h_align);
+ break;
+ default:
+ ret = grub_error (GRUB_ERR_BUG, "Invalid selection_method value");
+ break;
+ }
+
+ if (ret == GRUB_ERR_NONE)
+ {
+ /* Backup original data. */
+ int src_width_orig = src->mode_info.width;
+ int src_height_orig = src->mode_info.height;
+ grub_uint8_t *src_data_orig = src->data;
+ int dst_width_orig = (*dst)->mode_info.width;
+ int dst_height_orig = (*dst)->mode_info.height;
+ grub_uint8_t *dst_data_orig = (*dst)->data;
+
+ int dstride = (*dst)->mode_info.pitch;
+ int sstride = src->mode_info.pitch;
+ /* bytes_per_pixel is the same for both src and dst. */
+ int bytes_per_pixel = src->mode_info.bytes_per_pixel;
+
+ /* Crop src and dst. */
+ src->mode_info.width = sw;
+ src->mode_info.height = sh;
+ src->data = (grub_uint8_t *) src->data + sx0 * bytes_per_pixel
+ + sy0 * sstride;
+ (*dst)->mode_info.width = dw;
+ (*dst)->mode_info.height = dh;
+ (*dst)->data = (grub_uint8_t *) (*dst)->data + dx0 * bytes_per_pixel
+ + dy0 * dstride;
+
+ /* Scale our image. */
+ ret = grub_video_bitmap_scale (*dst, src, scale_method);
+
+ /* Restore original data. */
+ src->mode_info.width = src_width_orig;
+ src->mode_info.height = src_height_orig;
+ src->data = src_data_orig;
+ (*dst)->mode_info.width = dst_width_orig;
+ (*dst)->mode_info.height = dst_height_orig;
+ (*dst)->data = dst_data_orig;
+ }
+
+ if (ret == GRUB_ERR_NONE)
+ {
+ /* Success: *dst is now a pointer to the scaled bitmap. */
+ return GRUB_ERR_NONE;
+ }
+ else
+ {
+ /* Destroy the bitmap and return the error code. */
+ grub_video_bitmap_destroy (*dst);
+ *dst = 0;
+ return ret;
+ }
+}
+
+static grub_err_t
+verify_bitmaps (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
+{
+ /* Verify the simplifying assumptions. */
+ if (dst == 0 || src == 0)
+ return grub_error (GRUB_ERR_BUG, "null bitmap in scale function");
+ if (dst->mode_info.red_field_pos % 8 != 0
+ || dst->mode_info.green_field_pos % 8 != 0
+ || dst->mode_info.blue_field_pos % 8 != 0
+ || dst->mode_info.reserved_field_pos % 8 != 0)
+ return grub_error (GRUB_ERR_BUG,
+ "dst format not supported");
+ if (src->mode_info.red_field_pos % 8 != 0
+ || src->mode_info.green_field_pos % 8 != 0
+ || src->mode_info.blue_field_pos % 8 != 0
+ || src->mode_info.reserved_field_pos % 8 != 0)
+ return grub_error (GRUB_ERR_BUG,
+ "src format not supported");
+ if (dst->mode_info.red_field_pos != src->mode_info.red_field_pos
+ || dst->mode_info.red_mask_size != src->mode_info.red_mask_size
+ || dst->mode_info.green_field_pos != src->mode_info.green_field_pos
+ || dst->mode_info.green_mask_size != src->mode_info.green_mask_size
+ || dst->mode_info.blue_field_pos != src->mode_info.blue_field_pos
+ || dst->mode_info.blue_mask_size != src->mode_info.blue_mask_size
+ || dst->mode_info.reserved_field_pos !=
+ src->mode_info.reserved_field_pos
+ || dst->mode_info.reserved_mask_size !=
+ src->mode_info.reserved_mask_size)
+ return grub_error (GRUB_ERR_BUG,
+ "dst and src not compatible");
+ if (dst->mode_info.bytes_per_pixel != src->mode_info.bytes_per_pixel)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "dst and src not compatible");
+ if (dst->mode_info.width == 0 || dst->mode_info.height == 0
+ || src->mode_info.width == 0 || src->mode_info.height == 0)
+ return grub_error (GRUB_ERR_BUG, "bitmap has a zero dimension");
+
+ return GRUB_ERR_NONE;
+}
+
+/* Nearest neighbor bitmap scaling algorithm.
+
+ Copy the bitmap SRC to the bitmap DST, scaling the bitmap to fit the
+ dimensions of DST. This function uses the nearest neighbor algorithm to
+ interpolate the pixels.
+
+ Supports only direct color modes which have components separated
+ into bytes (e.g., RGBA 8:8:8:8 or BGR 8:8:8 true color).
+ But because of this simplifying assumption, the implementation is
+ greatly simplified. */
+static grub_err_t
+scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
+{
+ grub_err_t err = verify_bitmaps(dst, src);
+ if (err != GRUB_ERR_NONE)
+ return err;
+
+ grub_uint8_t *ddata = dst->data;
+ grub_uint8_t *sdata = src->data;
+ unsigned dw = dst->mode_info.width;
+ unsigned dh = dst->mode_info.height;
+ unsigned sw = src->mode_info.width;
+ unsigned sh = src->mode_info.height;
+ int dstride = dst->mode_info.pitch;
+ 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, sy, ystep, yfrac, yover;
+ unsigned sx, xstep, xfrac, xover;
+ grub_uint8_t *dptr, *dline_end, *sline;
+
+ 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)
+ {
+ 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 *sptr;
+ int comp;
+
+ if (xfrac >= dw)
+ {
+ xfrac -= dw;
+ sx++;
+ }
+
+ /* Get the address of the pixels in src and dst. */
+ sptr = sline + sx * bytes_per_pixel;
+
+ /* Copy the pixel color value. */
+ for (comp = 0; comp < bytes_per_pixel; comp++)
+ dptr[comp] = sptr[comp];
+ }
+ }
+ return GRUB_ERR_NONE;
+}
+
+/* Bilinear interpolation image scaling algorithm.
+
+ Copy the bitmap SRC to the bitmap DST, scaling the bitmap to fit the
+ dimensions of DST. This function uses the bilinear interpolation algorithm
+ to interpolate the pixels.
+
+ Supports only direct color modes which have components separated
+ into bytes (e.g., RGBA 8:8:8:8 or BGR 8:8:8 true color).
+ But because of this simplifying assumption, the implementation is
+ greatly simplified. */
+static grub_err_t
+scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
+{
+ grub_err_t err = verify_bitmaps(dst, src);
+ if (err != GRUB_ERR_NONE)
+ return err;
+
+ grub_uint8_t *ddata = dst->data;
+ grub_uint8_t *sdata = src->data;
+ unsigned dw = dst->mode_info.width;
+ unsigned dh = dst->mode_info.height;
+ unsigned sw = src->mode_info.width;
+ unsigned sh = src->mode_info.height;
+ int dstride = dst->mode_info.pitch;
+ 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;
+
+ for (dy = 0, syf = 0, yfrac = 0; dy < dh; dy++, syf += ystep, yfrac += yover)
+ {
+ 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 *sptr;
+ int comp;
+
+ if (xfrac >= dw)
+ {
+ xfrac -= dw;
+ sxf++;
+ }
+
+ /* Get the address of the pixels in src and dst. */
+ 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. */
+ if (sx < sw - 1 && sy < sh - 1)
+ {
+ /* Do bilinear interpolation. */
+
+ /* 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. */
+ 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. */
+ 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. */
+ unsigned c00 = (256 - u) * (256 - v);
+ unsigned c10 = u * (256 - v);
+ unsigned c01 = (256 - u) * v;
+ unsigned c11 = u * v;
+
+ /* Interpolate. */
+ unsigned fxy = c00 * f00 + c01 * f01 + c10 * f10 + c11 * f11;
+ fxy = fxy >> 16;
+
+ dptr[comp] = fxy;
+ }
+ }
+ else
+ {
+ /* Fall back to nearest neighbor interpolation. */
+ /* Copy the pixel color value. */
+ for (comp = 0; comp < bytes_per_pixel; comp++)
+ dptr[comp] = sptr[comp];
+ }
+ }
+ }
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/video/bochs.c b/grub-core/video/bochs.c
new file mode 100644
index 0000000..30ea1bd
--- /dev/null
+++ b/grub-core/video/bochs.c
@@ -0,0 +1,439 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/pci.h>
+#include <grub/vga.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+
+ grub_uint8_t *ptr;
+ int mapped;
+ grub_uint32_t base;
+ grub_pci_device_t dev;
+} framebuffer;
+
+#define BOCHS_APERTURE_SIZE 0x800000
+#define BOCHS_MAX_WIDTH 1600
+#define BOCHS_MAX_HEIGHT 1200
+#define BOCHS_WIDTH_ALIGN 8
+
+enum
+ {
+ BOCHS_VBE_INDEX = 0x1ce,
+ BOCHS_VBE_DATA = 0x1cf,
+ };
+
+enum
+ {
+ BOCHS_VBE_WIDTH = 1,
+ BOCHS_VBE_HEIGHT = 2,
+ BOCHS_VBE_BPP = 3,
+ BOCHS_VBE_ENABLE = 4,
+ BOCHS_VBE_Y_OFFSET = 9,
+ BOCHS_VBE_MAX
+ };
+
+static void
+vbe_write (grub_uint16_t val, grub_uint16_t addr)
+{
+ grub_outw (addr, BOCHS_VBE_INDEX);
+ grub_outw (val, BOCHS_VBE_DATA);
+}
+
+static grub_uint16_t
+vbe_read (grub_uint16_t addr)
+{
+ grub_outw (addr, BOCHS_VBE_INDEX);
+ return grub_inw (BOCHS_VBE_DATA);
+}
+
+struct saved_state
+{
+ grub_uint8_t cr[256];
+ grub_uint8_t gr[256];
+ grub_uint8_t sr[256];
+ grub_uint8_t r[256];
+ grub_uint8_t g[256];
+ grub_uint8_t b[256];
+ grub_uint8_t vbe[BOCHS_VBE_MAX];
+ int vbe_enable;
+ /* We need to preserve VGA font and VGA text. */
+ grub_uint8_t vram[32 * 4 * 256];
+};
+
+static struct saved_state initial_state;
+static int state_saved = 0;
+
+static void
+save_state (struct saved_state *st)
+{
+ unsigned i;
+
+ for (i = 0; i < ARRAY_SIZE (st->cr); i++)
+ st->cr[i] = grub_vga_cr_read (i);
+ for (i = 0; i < ARRAY_SIZE (st->gr); i++)
+ st->gr[i] = grub_vga_gr_read (i);
+ for (i = 0; i < ARRAY_SIZE (st->sr); i++)
+ st->sr[i] = grub_vga_sr_read (i);
+
+ for (i = 0; i < 256; i++)
+ grub_vga_palette_read (i, st->r + i, st->g + i, st->b + i);
+
+ st->vbe_enable = vbe_read (BOCHS_VBE_ENABLE) & 1;
+ if (st->vbe_enable)
+ for (i = 0; i < ARRAY_SIZE (st->vbe); i++)
+ st->vbe[i] = vbe_read (i);
+
+ grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_CHAIN4, GRUB_VGA_SR_MEMORY_MODE);
+ grub_memcpy (st->vram, framebuffer.ptr, sizeof (st->vram));
+ grub_vga_sr_write (st->sr[GRUB_VGA_SR_MEMORY_MODE], GRUB_VGA_SR_MEMORY_MODE);
+}
+
+static void
+restore_state (struct saved_state *st)
+{
+ unsigned i;
+
+ if (st->vbe_enable)
+ for (i = 0; i < ARRAY_SIZE (st->vbe); i++)
+ vbe_write (st->vbe[i], i);
+ else
+ vbe_write (0, BOCHS_VBE_ENABLE);
+
+ grub_vga_cr_write (0, 0x11);
+ for (i = 0; i < ARRAY_SIZE (st->cr); i++)
+ grub_vga_cr_write (st->cr[i], i);
+ for (i = 0; i < ARRAY_SIZE (st->sr); i++)
+ grub_vga_sr_write (st->sr[i], i);
+ for (i = 0; i < ARRAY_SIZE (st->gr); i++)
+ grub_vga_gr_write (st->gr[i], i);
+
+ for (i = 0; i < 256; i++)
+ grub_vga_palette_write (i, st->r[i], st->g[i], st->b[i]);
+
+ grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_CHAIN4, GRUB_VGA_SR_MEMORY_MODE);
+ grub_memcpy (framebuffer.ptr, st->vram, sizeof (st->vram));
+ grub_vga_sr_write (st->sr[GRUB_VGA_SR_MEMORY_MODE], GRUB_VGA_SR_MEMORY_MODE);
+}
+
+static grub_err_t
+grub_video_bochs_video_init (void)
+{
+ /* Reset frame buffer. */
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_bochs_video_fini (void)
+{
+ if (framebuffer.mapped)
+ grub_pci_device_unmap_range (framebuffer.dev, framebuffer.ptr,
+ BOCHS_APERTURE_SIZE);
+
+ if (state_saved)
+ {
+ restore_state (&initial_state);
+ state_saved = 0;
+ }
+
+ return grub_video_fb_fini ();
+}
+
+static grub_err_t
+doublebuf_pageflipping_set_page (int page)
+{
+ int start = framebuffer.mode_info.height * page;
+
+ vbe_write (start, BOCHS_VBE_Y_OFFSET);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_bochs_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data)
+{
+ if (framebuffer.mode_info.mode_type == GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
+ {
+ unsigned i;
+ if (start >= 0x100)
+ return GRUB_ERR_NONE;
+ if (start + count >= 0x100)
+ count = 0x100 - start;
+
+ for (i = 0; i < count; i++)
+ grub_vga_palette_write (start + i, palette_data[i].r, palette_data[i].g,
+ palette_data[i].b);
+ }
+
+ /* Then set color to emulated palette. */
+ return grub_video_fb_set_palette (start, count, palette_data);
+}
+
+/* Helper for grub_video_bochs_setup. */
+static int
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
+{
+ int *found = data;
+ grub_pci_address_t addr;
+ grub_uint32_t class;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class = grub_pci_read (addr);
+
+ if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x11111234)
+ return 0;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
+ framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
+ if (!framebuffer.base)
+ return 0;
+ *found = 1;
+ framebuffer.dev = dev;
+
+ /* Enable address spaces. */
+ addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write (addr, 0x7);
+
+ return 1;
+}
+
+static grub_err_t
+grub_video_bochs_setup (unsigned int width, unsigned int height,
+ grub_video_mode_type_t mode_type,
+ grub_video_mode_type_t mode_mask)
+{
+ int depth;
+ grub_err_t err;
+ int found = 0;
+ int pitch, bytes_per_pixel;
+ grub_size_t page_size; /* The size of a page in bytes. */
+
+ /* Decode depth from mode_type. If it is zero, then autodetect. */
+ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
+
+ if (width == 0 || height == 0)
+ {
+ width = 800;
+ height = 600;
+ }
+
+ if (width > BOCHS_MAX_WIDTH)
+ return grub_error (GRUB_ERR_IO, "width must be at most %d",
+ BOCHS_MAX_WIDTH);
+
+ if (height > BOCHS_MAX_HEIGHT)
+ return grub_error (GRUB_ERR_IO, "height must be at most %d",
+ BOCHS_MAX_HEIGHT);
+
+ if (width & (BOCHS_WIDTH_ALIGN - 1))
+ return grub_error (GRUB_ERR_IO, "width must be a multiple of %d",
+ BOCHS_WIDTH_ALIGN);
+
+ if (depth == 0
+ && !grub_video_check_mode_flag (mode_type, mode_mask,
+ GRUB_VIDEO_MODE_TYPE_INDEX_COLOR, 0))
+ depth = 24;
+
+ if (depth == 0)
+ depth = 8;
+
+ if (depth != 32 && depth != 24 && depth != 16 && depth != 15 && depth != 8
+ && depth != 4)
+ return grub_error (GRUB_ERR_IO, "only 32, 24, 16, 15 and 8-bpp are"
+ " supported by bochs video");
+
+ if (depth == 4)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "4-bpp isn't supported");
+
+ bytes_per_pixel = (depth + 7) / 8;
+ if (depth == 4)
+ pitch = width / 2;
+ else
+ pitch = width * bytes_per_pixel;
+
+ page_size = pitch * height;
+
+ if (page_size > BOCHS_APERTURE_SIZE)
+ return grub_error (GRUB_ERR_IO, "Not enough video memory for this mode");
+
+ grub_pci_iterate (find_card, &found);
+ if (!found)
+ return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
+
+ if (found && framebuffer.base == 0)
+ {
+ /* FIXME: change framebuffer base */
+ return grub_error (GRUB_ERR_IO, "PCI BAR not set");
+ }
+
+ /* We can safely discard volatile attribute. */
+ framebuffer.ptr = (void *) grub_pci_device_map_range (framebuffer.dev,
+ framebuffer.base,
+ BOCHS_APERTURE_SIZE);
+ framebuffer.mapped = 1;
+
+ if (!state_saved)
+ {
+ save_state (&initial_state);
+ state_saved = 1;
+ }
+
+ {
+ vbe_write (0, BOCHS_VBE_ENABLE);
+
+ vbe_write (width, BOCHS_VBE_WIDTH);
+ vbe_write (height, BOCHS_VBE_HEIGHT);
+ vbe_write (depth, BOCHS_VBE_BPP);
+
+ vbe_write (1, BOCHS_VBE_ENABLE);
+ doublebuf_pageflipping_set_page (0);
+ }
+
+ /* Fill mode info details. */
+ framebuffer.mode_info.width = width;
+ framebuffer.mode_info.height = height;
+ framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
+ framebuffer.mode_info.bpp = depth;
+ framebuffer.mode_info.bytes_per_pixel = bytes_per_pixel;
+ framebuffer.mode_info.pitch = pitch;
+ framebuffer.mode_info.number_of_colors = 256;
+ framebuffer.mode_info.reserved_mask_size = 0;
+ framebuffer.mode_info.reserved_field_pos = 0;
+
+ switch (depth)
+ {
+ case 4:
+ case 8:
+ framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
+ framebuffer.mode_info.number_of_colors = 16;
+ break;
+ case 16:
+ framebuffer.mode_info.red_mask_size = 5;
+ framebuffer.mode_info.red_field_pos = 11;
+ framebuffer.mode_info.green_mask_size = 6;
+ framebuffer.mode_info.green_field_pos = 5;
+ framebuffer.mode_info.blue_mask_size = 5;
+ framebuffer.mode_info.blue_field_pos = 0;
+ break;
+
+ case 15:
+ framebuffer.mode_info.red_mask_size = 5;
+ framebuffer.mode_info.red_field_pos = 10;
+ framebuffer.mode_info.green_mask_size = 5;
+ framebuffer.mode_info.green_field_pos = 5;
+ framebuffer.mode_info.blue_mask_size = 5;
+ framebuffer.mode_info.blue_field_pos = 0;
+ break;
+
+ 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;
+ framebuffer.mode_info.red_field_pos = 16;
+ framebuffer.mode_info.green_mask_size = 8;
+ framebuffer.mode_info.green_field_pos = 8;
+ framebuffer.mode_info.blue_mask_size = 8;
+ framebuffer.mode_info.blue_field_pos = 0;
+ break;
+ }
+
+ framebuffer.mode_info.blit_format = grub_video_get_blit_format (&framebuffer.mode_info);
+
+ if (BOCHS_APERTURE_SIZE >= 2 * page_size)
+ err = grub_video_fb_setup (mode_type, mode_mask,
+ &framebuffer.mode_info,
+ framebuffer.ptr,
+ doublebuf_pageflipping_set_page,
+ framebuffer.ptr + page_size);
+ else
+ err = grub_video_fb_setup (mode_type, mode_mask,
+ &framebuffer.mode_info,
+ framebuffer.ptr, 0, 0);
+
+
+ /* Copy default palette to initialize emulated palette. */
+ err = grub_video_bochs_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+ return err;
+}
+
+static struct grub_video_adapter grub_video_bochs_adapter =
+ {
+ .name = "Bochs PCI Video Driver",
+ .id = GRUB_VIDEO_DRIVER_BOCHS,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_NATIVE,
+
+ .init = grub_video_bochs_video_init,
+ .fini = grub_video_bochs_video_fini,
+ .setup = grub_video_bochs_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_fb_get_info_and_fini,
+ .set_palette = grub_video_bochs_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_fb_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_fb_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(video_bochs)
+{
+ grub_video_register (&grub_video_bochs_adapter);
+}
+
+GRUB_MOD_FINI(video_bochs)
+{
+ grub_video_unregister (&grub_video_bochs_adapter);
+}
diff --git a/grub-core/video/capture.c b/grub-core/video/capture.c
new file mode 100644
index 0000000..4d3195e
--- /dev/null
+++ b/grub-core/video/capture.c
@@ -0,0 +1,140 @@
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+ struct grub_video_render_target *render_target;
+ grub_uint8_t *ptr;
+} framebuffer;
+
+void (*grub_video_capture_refresh_cb) (void);
+
+static grub_err_t
+grub_video_capture_swap_buffers (void)
+{
+ if (grub_video_capture_refresh_cb)
+ grub_video_capture_refresh_cb ();
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_capture_set_active_render_target (struct grub_video_render_target *target)
+{
+ if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
+ target = framebuffer.render_target;
+
+ return grub_video_fb_set_active_render_target (target);
+}
+
+static grub_err_t
+grub_video_capture_fini (void)
+{
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_video_adapter grub_video_capture_adapter =
+ {
+ .name = "Render capture",
+
+ .prio = 0,
+ .id = GRUB_VIDEO_ADAPTER_CAPTURE,
+
+ .fini = grub_video_capture_fini,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = 0,
+ .set_palette = grub_video_fb_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_capture_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_capture_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+
+ .next = 0
+ };
+
+static struct grub_video_adapter *saved;
+static struct grub_video_mode_info saved_mode_info;
+
+grub_err_t
+grub_video_capture_start (const struct grub_video_mode_info *mode_info,
+ struct grub_video_palette_data *palette,
+ unsigned int palette_size)
+{
+ grub_err_t err;
+ grub_memset (&framebuffer, 0, sizeof (framebuffer));
+
+ grub_video_fb_init ();
+
+ framebuffer.mode_info = *mode_info;
+ framebuffer.mode_info.blit_format = grub_video_get_blit_format (&framebuffer.mode_info);
+
+ framebuffer.ptr = grub_calloc (framebuffer.mode_info.height, framebuffer.mode_info.pitch);
+ if (!framebuffer.ptr)
+ return grub_errno;
+
+ err = grub_video_fb_create_render_target_from_pointer (&framebuffer.render_target,
+ &framebuffer.mode_info,
+ framebuffer.ptr);
+ if (err)
+ return err;
+ err = grub_video_fb_set_active_render_target (framebuffer.render_target);
+ if (err)
+ return err;
+ err = grub_video_fb_set_palette (0, palette_size, palette);
+ if (err)
+ return err;
+
+ saved = grub_video_adapter_active;
+ if (saved)
+ {
+ grub_video_get_info (&saved_mode_info);
+ if (saved->fini)
+ saved->fini ();
+ }
+ grub_video_adapter_active = &grub_video_capture_adapter;
+
+ return GRUB_ERR_NONE;
+}
+
+void *
+grub_video_capture_get_framebuffer (void)
+{
+ return framebuffer.ptr;
+}
+
+void
+grub_video_capture_end (void)
+{
+ grub_video_fb_delete_render_target (framebuffer.render_target);
+ grub_free (framebuffer.ptr);
+ grub_video_fb_fini ();
+ grub_video_adapter_active = saved;
+ if (saved)
+ {
+ if (saved->init)
+ saved->init ();
+ if (saved->setup)
+ saved->setup (saved_mode_info.width, saved_mode_info.height, 0, 0);
+ }
+}
diff --git a/grub-core/video/cirrus.c b/grub-core/video/cirrus.c
new file mode 100644
index 0000000..e2149e8
--- /dev/null
+++ b/grub-core/video/cirrus.c
@@ -0,0 +1,520 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/pci.h>
+#include <grub/vga.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+ grub_size_t page_size; /* The size of a page in bytes. */
+
+ grub_uint8_t *ptr;
+ int mapped;
+ grub_uint32_t base;
+ grub_pci_device_t dev;
+} framebuffer;
+
+#define CIRRUS_APERTURE_SIZE 0x1000000
+
+#define CIRRUS_MAX_WIDTH 0x800
+#define CIRRUS_MAX_HEIGHT 0x800
+#define CIRRUS_MAX_PITCH (0x1ff * GRUB_VGA_CR_PITCH_DIVISOR)
+
+enum
+ {
+ CIRRUS_CR_EXTENDED_DISPLAY = 0x1b,
+ CIRRUS_CR_EXTENDED_OVERLAY = 0x1d,
+ CIRRUS_CR_MAX
+ };
+
+#define CIRRUS_CR_EXTENDED_DISPLAY_PITCH_MASK 0x10
+#define CIRRUS_CR_EXTENDED_DISPLAY_PITCH_SHIFT 4
+#define CIRRUS_CR_EXTENDED_DISPLAY_START_MASK1 0x1
+#define CIRRUS_CR_EXTENDED_DISPLAY_START_SHIFT1 16
+#define CIRRUS_CR_EXTENDED_DISPLAY_START_MASK2 0xc
+#define CIRRUS_CR_EXTENDED_DISPLAY_START_SHIFT2 15
+
+#define CIRRUS_CR_EXTENDED_OVERLAY_DISPLAY_START_MASK 0x80
+#define CIRRUS_CR_EXTENDED_OVERLAY_DISPLAY_START_SHIFT 12
+
+enum
+ {
+ CIRRUS_SR_EXTENDED_MODE = 7,
+ CIRRUS_SR_MAX
+ };
+
+#define CIRRUS_SR_EXTENDED_MODE_LFB_ENABLE 0xf0
+#define CIRRUS_SR_EXTENDED_MODE_ENABLE_EXT 0x01
+#define CIRRUS_SR_EXTENDED_MODE_8BPP 0x00
+#define CIRRUS_SR_EXTENDED_MODE_16BPP 0x06
+#define CIRRUS_SR_EXTENDED_MODE_24BPP 0x04
+#define CIRRUS_SR_EXTENDED_MODE_32BPP 0x08
+
+#define CIRRUS_HIDDEN_DAC_ENABLE_EXT 0x80
+#define CIRRUS_HIDDEN_DAC_ENABLE_ALL 0x40
+#define CIRRUS_HIDDEN_DAC_8BPP 0
+#define CIRRUS_HIDDEN_DAC_15BPP (CIRRUS_HIDDEN_DAC_ENABLE_EXT \
+ | CIRRUS_HIDDEN_DAC_ENABLE_ALL | 0)
+#define CIRRUS_HIDDEN_DAC_16BPP (CIRRUS_HIDDEN_DAC_ENABLE_EXT \
+ | CIRRUS_HIDDEN_DAC_ENABLE_ALL | 1)
+#define CIRRUS_HIDDEN_DAC_888COLOR (CIRRUS_HIDDEN_DAC_ENABLE_EXT \
+ | CIRRUS_HIDDEN_DAC_ENABLE_ALL | 5)
+
+static void
+write_hidden_dac (grub_uint8_t data)
+{
+ grub_inb (GRUB_VGA_IO_PALLETTE_WRITE_INDEX);
+ grub_inb (GRUB_VGA_IO_PIXEL_MASK);
+ grub_inb (GRUB_VGA_IO_PIXEL_MASK);
+ grub_inb (GRUB_VGA_IO_PIXEL_MASK);
+ grub_inb (GRUB_VGA_IO_PIXEL_MASK);
+ grub_outb (data, GRUB_VGA_IO_PIXEL_MASK);
+}
+
+static grub_uint8_t
+read_hidden_dac (void)
+{
+ grub_inb (GRUB_VGA_IO_PALLETTE_WRITE_INDEX);
+ grub_inb (GRUB_VGA_IO_PIXEL_MASK);
+ grub_inb (GRUB_VGA_IO_PIXEL_MASK);
+ grub_inb (GRUB_VGA_IO_PIXEL_MASK);
+ grub_inb (GRUB_VGA_IO_PIXEL_MASK);
+ return grub_inb (GRUB_VGA_IO_PIXEL_MASK);
+}
+
+struct saved_state
+{
+ grub_uint8_t cr[CIRRUS_CR_MAX];
+ grub_uint8_t gr[GRUB_VGA_GR_MAX];
+ grub_uint8_t sr[CIRRUS_SR_MAX];
+ grub_uint8_t hidden_dac;
+ /* We need to preserve VGA font and VGA text. */
+ grub_uint8_t vram[32 * 4 * 256];
+ grub_uint8_t r[256];
+ grub_uint8_t g[256];
+ grub_uint8_t b[256];
+};
+
+static struct saved_state initial_state;
+static int state_saved = 0;
+
+static void
+save_state (struct saved_state *st)
+{
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE (st->cr); i++)
+ st->cr[i] = grub_vga_cr_read (i);
+ for (i = 0; i < ARRAY_SIZE (st->sr); i++)
+ st->sr[i] = grub_vga_sr_read (i);
+ for (i = 0; i < ARRAY_SIZE (st->gr); i++)
+ st->gr[i] = grub_vga_gr_read (i);
+ for (i = 0; i < 256; i++)
+ grub_vga_palette_read (i, st->r + i, st->g + i, st->b + i);
+
+ st->hidden_dac = read_hidden_dac ();
+ grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_CHAIN4, GRUB_VGA_SR_MEMORY_MODE);
+ grub_memcpy (st->vram, framebuffer.ptr, sizeof (st->vram));
+}
+
+static void
+restore_state (struct saved_state *st)
+{
+ unsigned i;
+ grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_CHAIN4, GRUB_VGA_SR_MEMORY_MODE);
+ grub_memcpy (framebuffer.ptr, st->vram, sizeof (st->vram));
+ for (i = 0; i < ARRAY_SIZE (st->cr); i++)
+ grub_vga_cr_write (st->cr[i], i);
+ for (i = 0; i < ARRAY_SIZE (st->sr); i++)
+ grub_vga_sr_write (st->sr[i], i);
+ for (i = 0; i < ARRAY_SIZE (st->gr); i++)
+ grub_vga_gr_write (st->gr[i], i);
+ for (i = 0; i < 256; i++)
+ grub_vga_palette_write (i, st->r[i], st->g[i], st->b[i]);
+
+ write_hidden_dac (st->hidden_dac);
+}
+
+static grub_err_t
+grub_video_cirrus_video_init (void)
+{
+ /* Reset frame buffer. */
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_cirrus_video_fini (void)
+{
+ if (framebuffer.mapped)
+ grub_pci_device_unmap_range (framebuffer.dev, framebuffer.ptr,
+ CIRRUS_APERTURE_SIZE);
+
+ if (state_saved)
+ {
+ restore_state (&initial_state);
+ state_saved = 0;
+ }
+
+ return grub_video_fb_fini ();
+}
+
+static grub_err_t
+doublebuf_pageflipping_set_page (int page)
+{
+ int start = framebuffer.page_size * page / 4;
+ grub_uint8_t cr_ext, cr_overlay;
+
+ grub_vga_cr_write (start & 0xff, GRUB_VGA_CR_START_ADDR_LOW_REGISTER);
+ grub_vga_cr_write ((start & 0xff00) >> 8,
+ GRUB_VGA_CR_START_ADDR_HIGH_REGISTER);
+
+ cr_ext = grub_vga_cr_read (CIRRUS_CR_EXTENDED_DISPLAY);
+ cr_ext &= ~(CIRRUS_CR_EXTENDED_DISPLAY_START_MASK1
+ | CIRRUS_CR_EXTENDED_DISPLAY_START_MASK2);
+ cr_ext |= ((start >> CIRRUS_CR_EXTENDED_DISPLAY_START_SHIFT1)
+ & CIRRUS_CR_EXTENDED_DISPLAY_START_MASK1);
+ cr_ext |= ((start >> CIRRUS_CR_EXTENDED_DISPLAY_START_SHIFT2)
+ & CIRRUS_CR_EXTENDED_DISPLAY_START_MASK2);
+ grub_vga_cr_write (cr_ext, CIRRUS_CR_EXTENDED_DISPLAY);
+
+ cr_overlay = grub_vga_cr_read (CIRRUS_CR_EXTENDED_OVERLAY);
+ cr_overlay &= ~(CIRRUS_CR_EXTENDED_OVERLAY_DISPLAY_START_MASK);
+ cr_overlay |= ((start >> CIRRUS_CR_EXTENDED_OVERLAY_DISPLAY_START_SHIFT)
+ & CIRRUS_CR_EXTENDED_OVERLAY_DISPLAY_START_MASK);
+ grub_vga_cr_write (cr_overlay, CIRRUS_CR_EXTENDED_OVERLAY);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_cirrus_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data)
+{
+ if (framebuffer.mode_info.mode_type == GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
+ {
+ unsigned i;
+ if (start >= 0x100)
+ return GRUB_ERR_NONE;
+ if (start + count >= 0x100)
+ count = 0x100 - start;
+
+ for (i = 0; i < count; i++)
+ grub_vga_palette_write (start + i, palette_data[i].r, palette_data[i].g,
+ palette_data[i].b);
+ }
+
+ /* Then set color to emulated palette. */
+ return grub_video_fb_set_palette (start, count, palette_data);
+}
+
+/* Helper for grub_video_cirrus_setup. */
+static int
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
+{
+ int *found = data;
+ grub_pci_address_t addr;
+ grub_uint32_t class;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class = grub_pci_read (addr);
+
+ if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x00b81013)
+ return 0;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
+ framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
+ if (!framebuffer.base)
+ return 0;
+
+ *found = 1;
+
+ /* Enable address spaces. */
+ addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write (addr, 0x7);
+
+ framebuffer.dev = dev;
+
+ return 1;
+}
+
+static grub_err_t
+grub_video_cirrus_setup (unsigned int width, unsigned int height,
+ grub_video_mode_type_t mode_type,
+ grub_video_mode_type_t mode_mask)
+{
+ int depth;
+ grub_err_t err;
+ int found = 0;
+ int pitch, bytes_per_pixel;
+
+ /* Decode depth from mode_type. If it is zero, then autodetect. */
+ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
+
+ if (width == 0 || height == 0)
+ {
+ width = 800;
+ height = 600;
+ }
+
+ if (width & (GRUB_VGA_CR_WIDTH_DIVISOR - 1))
+ return grub_error (GRUB_ERR_IO,
+ "screen width must be a multiple of %d",
+ GRUB_VGA_CR_WIDTH_DIVISOR);
+
+ if (width > CIRRUS_MAX_WIDTH)
+ return grub_error (GRUB_ERR_IO,
+ "screen width must be at most %d", CIRRUS_MAX_WIDTH);
+
+ if (height > CIRRUS_MAX_HEIGHT)
+ return grub_error (GRUB_ERR_IO,
+ "screen height must be at most %d", CIRRUS_MAX_HEIGHT);
+
+ if (depth == 0
+ && !grub_video_check_mode_flag (mode_type, mode_mask,
+ GRUB_VIDEO_MODE_TYPE_INDEX_COLOR, 0))
+ depth = 24;
+ else if (depth == 0)
+ depth = 8;
+
+ if (depth != 32 && depth != 24 && depth != 16 && depth != 15 && depth != 8)
+ return grub_error (GRUB_ERR_IO, "only 32, 24, 16, 15 and 8-bit bpp are"
+ " supported by cirrus video");
+
+ bytes_per_pixel = (depth + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT;
+ pitch = width * bytes_per_pixel;
+
+ if (pitch > CIRRUS_MAX_PITCH)
+ return grub_error (GRUB_ERR_IO,
+ "screen width must be at most %d at bitdepth %d",
+ CIRRUS_MAX_PITCH / bytes_per_pixel, depth);
+
+ framebuffer.page_size = pitch * height;
+
+ if (framebuffer.page_size > CIRRUS_APERTURE_SIZE)
+ return grub_error (GRUB_ERR_IO, "Not enough video memory for this mode");
+
+ grub_pci_iterate (find_card, &found);
+ if (!found)
+ return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
+
+ if (found && framebuffer.base == 0)
+ {
+ /* FIXME: change framebuffer base */
+ return grub_error (GRUB_ERR_IO, "PCI BAR not set");
+ }
+
+ /* We can safely discard volatile attribute. */
+ framebuffer.ptr = (void *) grub_pci_device_map_range (framebuffer.dev,
+ framebuffer.base,
+ CIRRUS_APERTURE_SIZE);
+ framebuffer.mapped = 1;
+
+ if (!state_saved)
+ {
+ save_state (&initial_state);
+ state_saved = 1;
+ }
+
+ {
+ struct grub_video_hw_config config = {
+ .pitch = pitch / GRUB_VGA_CR_PITCH_DIVISOR,
+ .line_compare = 0x3ff,
+ .vdisplay_end = height - 1,
+ .horizontal_end = width / GRUB_VGA_CR_WIDTH_DIVISOR
+ };
+ grub_uint8_t sr_ext = 0, hidden_dac = 0;
+
+ grub_vga_set_geometry (&config, grub_vga_cr_write);
+
+ grub_vga_gr_write (GRUB_VGA_GR_MODE_256_COLOR | GRUB_VGA_GR_MODE_READ_MODE1,
+ GRUB_VGA_GR_MODE);
+ grub_vga_gr_write (GRUB_VGA_GR_GR6_GRAPHICS_MODE, GRUB_VGA_GR_GR6);
+
+ grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_NORMAL, GRUB_VGA_SR_MEMORY_MODE);
+
+ grub_vga_cr_write ((config.pitch >> CIRRUS_CR_EXTENDED_DISPLAY_PITCH_SHIFT)
+ & CIRRUS_CR_EXTENDED_DISPLAY_PITCH_MASK,
+ CIRRUS_CR_EXTENDED_DISPLAY);
+
+ grub_vga_cr_write (GRUB_VGA_CR_MODE_TIMING_ENABLE
+ | GRUB_VGA_CR_MODE_BYTE_MODE
+ | GRUB_VGA_CR_MODE_NO_HERCULES | GRUB_VGA_CR_MODE_NO_CGA,
+ GRUB_VGA_CR_MODE);
+
+ doublebuf_pageflipping_set_page (0);
+
+ sr_ext = CIRRUS_SR_EXTENDED_MODE_LFB_ENABLE
+ | CIRRUS_SR_EXTENDED_MODE_ENABLE_EXT;
+ switch (depth)
+ {
+ /* FIXME: support 8-bit grayscale and 8-bit RGB. */
+ case 32:
+ hidden_dac = CIRRUS_HIDDEN_DAC_888COLOR;
+ sr_ext |= CIRRUS_SR_EXTENDED_MODE_32BPP;
+ break;
+ case 24:
+ hidden_dac = CIRRUS_HIDDEN_DAC_888COLOR;
+ sr_ext |= CIRRUS_SR_EXTENDED_MODE_24BPP;
+ break;
+ case 16:
+ hidden_dac = CIRRUS_HIDDEN_DAC_16BPP;
+ sr_ext |= CIRRUS_SR_EXTENDED_MODE_16BPP;
+ break;
+ case 15:
+ hidden_dac = CIRRUS_HIDDEN_DAC_15BPP;
+ sr_ext |= CIRRUS_SR_EXTENDED_MODE_16BPP;
+ break;
+ case 8:
+ hidden_dac = CIRRUS_HIDDEN_DAC_8BPP;
+ sr_ext |= CIRRUS_SR_EXTENDED_MODE_8BPP;
+ break;
+ }
+ grub_vga_sr_write (sr_ext, CIRRUS_SR_EXTENDED_MODE);
+ write_hidden_dac (hidden_dac);
+ }
+
+ /* Fill mode info details. */
+ framebuffer.mode_info.width = width;
+ framebuffer.mode_info.height = height;
+ framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
+ framebuffer.mode_info.bpp = depth;
+ framebuffer.mode_info.bytes_per_pixel = bytes_per_pixel;
+ framebuffer.mode_info.pitch = pitch;
+ framebuffer.mode_info.number_of_colors = 256;
+ framebuffer.mode_info.reserved_mask_size = 0;
+ framebuffer.mode_info.reserved_field_pos = 0;
+
+ switch (depth)
+ {
+ case 8:
+ framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
+ framebuffer.mode_info.number_of_colors = 16;
+ break;
+ case 16:
+ framebuffer.mode_info.red_mask_size = 5;
+ framebuffer.mode_info.red_field_pos = 11;
+ framebuffer.mode_info.green_mask_size = 6;
+ framebuffer.mode_info.green_field_pos = 5;
+ framebuffer.mode_info.blue_mask_size = 5;
+ framebuffer.mode_info.blue_field_pos = 0;
+ break;
+
+ case 15:
+ framebuffer.mode_info.red_mask_size = 5;
+ framebuffer.mode_info.red_field_pos = 10;
+ framebuffer.mode_info.green_mask_size = 5;
+ framebuffer.mode_info.green_field_pos = 5;
+ framebuffer.mode_info.blue_mask_size = 5;
+ framebuffer.mode_info.blue_field_pos = 0;
+ break;
+
+ 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;
+ framebuffer.mode_info.red_field_pos = 16;
+ framebuffer.mode_info.green_mask_size = 8;
+ framebuffer.mode_info.green_field_pos = 8;
+ framebuffer.mode_info.blue_mask_size = 8;
+ framebuffer.mode_info.blue_field_pos = 0;
+ break;
+ }
+
+ framebuffer.mode_info.blit_format = grub_video_get_blit_format (&framebuffer.mode_info);
+
+ if (CIRRUS_APERTURE_SIZE >= 2 * framebuffer.page_size)
+ err = grub_video_fb_setup (mode_type, mode_mask,
+ &framebuffer.mode_info,
+ framebuffer.ptr,
+ doublebuf_pageflipping_set_page,
+ framebuffer.ptr + framebuffer.page_size);
+ else
+ err = grub_video_fb_setup (mode_type, mode_mask,
+ &framebuffer.mode_info,
+ framebuffer.ptr, 0, 0);
+
+
+ /* Copy default palette to initialize emulated palette. */
+ err = grub_video_cirrus_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+ return err;
+}
+
+static struct grub_video_adapter grub_video_cirrus_adapter =
+ {
+ .name = "Cirrus CLGD 5446 PCI Video Driver",
+ .id = GRUB_VIDEO_DRIVER_CIRRUS,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_NATIVE,
+
+ .init = grub_video_cirrus_video_init,
+ .fini = grub_video_cirrus_video_fini,
+ .setup = grub_video_cirrus_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_fb_get_info_and_fini,
+ .set_palette = grub_video_cirrus_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_fb_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_fb_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(video_cirrus)
+{
+ grub_video_register (&grub_video_cirrus_adapter);
+}
+
+GRUB_MOD_FINI(video_cirrus)
+{
+ grub_video_unregister (&grub_video_cirrus_adapter);
+}
diff --git a/grub-core/video/colors.c b/grub-core/video/colors.c
new file mode 100644
index 0000000..485ebb4
--- /dev/null
+++ b/grub-core/video/colors.c
@@ -0,0 +1,333 @@
+/* named_colors.c - Named color values. */
+/*
+ * 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/gui.h>
+#include <grub/gui_string_util.h>
+#include <grub/misc.h>
+#include <grub/dl.h>
+#include <grub/i18n.h>
+#include <grub/color.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct named_color
+{
+ const char *name;
+ grub_video_rgba_color_t color;
+};
+
+/*
+ Named color list generated from the list of SVG color keywords from
+ <http://www.w3.org/TR/css3-color/#svg-color>,
+ processed through the following Perl command:
+ perl -ne 'chomp;split;print "{ \"$_[0]\", RGB_COLOR($_[2]) },\n"'
+ */
+
+#define RGB_COLOR(r,g,b) {.red = r, .green = g, .blue = b, .alpha = 255}
+
+static struct named_color named_colors[] =
+{
+ { "aliceblue", RGB_COLOR(240,248,255) },
+ { "antiquewhite", RGB_COLOR(250,235,215) },
+ { "aqua", RGB_COLOR(0,255,255) },
+ { "aquamarine", RGB_COLOR(127,255,212) },
+ { "azure", RGB_COLOR(240,255,255) },
+ { "beige", RGB_COLOR(245,245,220) },
+ { "bisque", RGB_COLOR(255,228,196) },
+ { "black", RGB_COLOR(0,0,0) },
+ { "blanchedalmond", RGB_COLOR(255,235,205) },
+ { "blue", RGB_COLOR(0,0,255) },
+ { "blueviolet", RGB_COLOR(138,43,226) },
+ { "brown", RGB_COLOR(165,42,42) },
+ { "burlywood", RGB_COLOR(222,184,135) },
+ { "cadetblue", RGB_COLOR(95,158,160) },
+ { "chartreuse", RGB_COLOR(127,255,0) },
+ { "chocolate", RGB_COLOR(210,105,30) },
+ { "coral", RGB_COLOR(255,127,80) },
+ { "cornflowerblue", RGB_COLOR(100,149,237) },
+ { "cornsilk", RGB_COLOR(255,248,220) },
+ { "crimson", RGB_COLOR(220,20,60) },
+ { "cyan", RGB_COLOR(0,255,255) },
+ { "darkblue", RGB_COLOR(0,0,139) },
+ { "darkcyan", RGB_COLOR(0,139,139) },
+ { "darkgoldenrod", RGB_COLOR(184,134,11) },
+ { "darkgray", RGB_COLOR(169,169,169) },
+ { "darkgreen", RGB_COLOR(0,100,0) },
+ { "darkgrey", RGB_COLOR(169,169,169) },
+ { "darkkhaki", RGB_COLOR(189,183,107) },
+ { "darkmagenta", RGB_COLOR(139,0,139) },
+ { "darkolivegreen", RGB_COLOR(85,107,47) },
+ { "darkorange", RGB_COLOR(255,140,0) },
+ { "darkorchid", RGB_COLOR(153,50,204) },
+ { "darkred", RGB_COLOR(139,0,0) },
+ { "darksalmon", RGB_COLOR(233,150,122) },
+ { "darkseagreen", RGB_COLOR(143,188,143) },
+ { "darkslateblue", RGB_COLOR(72,61,139) },
+ { "darkslategray", RGB_COLOR(47,79,79) },
+ { "darkslategrey", RGB_COLOR(47,79,79) },
+ { "darkturquoise", RGB_COLOR(0,206,209) },
+ { "darkviolet", RGB_COLOR(148,0,211) },
+ { "deeppink", RGB_COLOR(255,20,147) },
+ { "deepskyblue", RGB_COLOR(0,191,255) },
+ { "dimgray", RGB_COLOR(105,105,105) },
+ { "dimgrey", RGB_COLOR(105,105,105) },
+ { "dodgerblue", RGB_COLOR(30,144,255) },
+ { "firebrick", RGB_COLOR(178,34,34) },
+ { "floralwhite", RGB_COLOR(255,250,240) },
+ { "forestgreen", RGB_COLOR(34,139,34) },
+ { "fuchsia", RGB_COLOR(255,0,255) },
+ { "gainsboro", RGB_COLOR(220,220,220) },
+ { "ghostwhite", RGB_COLOR(248,248,255) },
+ { "gold", RGB_COLOR(255,215,0) },
+ { "goldenrod", RGB_COLOR(218,165,32) },
+ { "gray", RGB_COLOR(128,128,128) },
+ { "green", RGB_COLOR(0,128,0) },
+ { "greenyellow", RGB_COLOR(173,255,47) },
+ { "grey", RGB_COLOR(128,128,128) },
+ { "honeydew", RGB_COLOR(240,255,240) },
+ { "hotpink", RGB_COLOR(255,105,180) },
+ { "indianred", RGB_COLOR(205,92,92) },
+ { "indigo", RGB_COLOR(75,0,130) },
+ { "ivory", RGB_COLOR(255,255,240) },
+ { "khaki", RGB_COLOR(240,230,140) },
+ { "lavender", RGB_COLOR(230,230,250) },
+ { "lavenderblush", RGB_COLOR(255,240,245) },
+ { "lawngreen", RGB_COLOR(124,252,0) },
+ { "lemonchiffon", RGB_COLOR(255,250,205) },
+ { "lightblue", RGB_COLOR(173,216,230) },
+ { "lightcoral", RGB_COLOR(240,128,128) },
+ { "lightcyan", RGB_COLOR(224,255,255) },
+ { "lightgoldenrodyellow", RGB_COLOR(250,250,210) },
+ { "lightgray", RGB_COLOR(211,211,211) },
+ { "lightgreen", RGB_COLOR(144,238,144) },
+ { "lightgrey", RGB_COLOR(211,211,211) },
+ { "lightpink", RGB_COLOR(255,182,193) },
+ { "lightsalmon", RGB_COLOR(255,160,122) },
+ { "lightseagreen", RGB_COLOR(32,178,170) },
+ { "lightskyblue", RGB_COLOR(135,206,250) },
+ { "lightslategray", RGB_COLOR(119,136,153) },
+ { "lightslategrey", RGB_COLOR(119,136,153) },
+ { "lightsteelblue", RGB_COLOR(176,196,222) },
+ { "lightyellow", RGB_COLOR(255,255,224) },
+ { "lime", RGB_COLOR(0,255,0) },
+ { "limegreen", RGB_COLOR(50,205,50) },
+ { "linen", RGB_COLOR(250,240,230) },
+ { "magenta", RGB_COLOR(255,0,255) },
+ { "maroon", RGB_COLOR(128,0,0) },
+ { "mediumaquamarine", RGB_COLOR(102,205,170) },
+ { "mediumblue", RGB_COLOR(0,0,205) },
+ { "mediumorchid", RGB_COLOR(186,85,211) },
+ { "mediumpurple", RGB_COLOR(147,112,219) },
+ { "mediumseagreen", RGB_COLOR(60,179,113) },
+ { "mediumslateblue", RGB_COLOR(123,104,238) },
+ { "mediumspringgreen", RGB_COLOR(0,250,154) },
+ { "mediumturquoise", RGB_COLOR(72,209,204) },
+ { "mediumvioletred", RGB_COLOR(199,21,133) },
+ { "midnightblue", RGB_COLOR(25,25,112) },
+ { "mintcream", RGB_COLOR(245,255,250) },
+ { "mistyrose", RGB_COLOR(255,228,225) },
+ { "moccasin", RGB_COLOR(255,228,181) },
+ { "navajowhite", RGB_COLOR(255,222,173) },
+ { "navy", RGB_COLOR(0,0,128) },
+ { "oldlace", RGB_COLOR(253,245,230) },
+ { "olive", RGB_COLOR(128,128,0) },
+ { "olivedrab", RGB_COLOR(107,142,35) },
+ { "orange", RGB_COLOR(255,165,0) },
+ { "orangered", RGB_COLOR(255,69,0) },
+ { "orchid", RGB_COLOR(218,112,214) },
+ { "palegoldenrod", RGB_COLOR(238,232,170) },
+ { "palegreen", RGB_COLOR(152,251,152) },
+ { "paleturquoise", RGB_COLOR(175,238,238) },
+ { "palevioletred", RGB_COLOR(219,112,147) },
+ { "papayawhip", RGB_COLOR(255,239,213) },
+ { "peachpuff", RGB_COLOR(255,218,185) },
+ { "peru", RGB_COLOR(205,133,63) },
+ { "pink", RGB_COLOR(255,192,203) },
+ { "plum", RGB_COLOR(221,160,221) },
+ { "powderblue", RGB_COLOR(176,224,230) },
+ { "purple", RGB_COLOR(128,0,128) },
+ { "red", RGB_COLOR(255,0,0) },
+ { "rosybrown", RGB_COLOR(188,143,143) },
+ { "royalblue", RGB_COLOR(65,105,225) },
+ { "saddlebrown", RGB_COLOR(139,69,19) },
+ { "salmon", RGB_COLOR(250,128,114) },
+ { "sandybrown", RGB_COLOR(244,164,96) },
+ { "seagreen", RGB_COLOR(46,139,87) },
+ { "seashell", RGB_COLOR(255,245,238) },
+ { "sienna", RGB_COLOR(160,82,45) },
+ { "silver", RGB_COLOR(192,192,192) },
+ { "skyblue", RGB_COLOR(135,206,235) },
+ { "slateblue", RGB_COLOR(106,90,205) },
+ { "slategray", RGB_COLOR(112,128,144) },
+ { "slategrey", RGB_COLOR(112,128,144) },
+ { "snow", RGB_COLOR(255,250,250) },
+ { "springgreen", RGB_COLOR(0,255,127) },
+ { "steelblue", RGB_COLOR(70,130,180) },
+ { "tan", RGB_COLOR(210,180,140) },
+ { "teal", RGB_COLOR(0,128,128) },
+ { "thistle", RGB_COLOR(216,191,216) },
+ { "tomato", RGB_COLOR(255,99,71) },
+ { "turquoise", RGB_COLOR(64,224,208) },
+ { "violet", RGB_COLOR(238,130,238) },
+ { "wheat", RGB_COLOR(245,222,179) },
+ { "white", RGB_COLOR(255,255,255) },
+ { "whitesmoke", RGB_COLOR(245,245,245) },
+ { "yellow", RGB_COLOR(255,255,0) },
+ { "yellowgreen", RGB_COLOR(154,205,50) },
+ { 0, { 0, 0, 0, 0 } } /* Terminator. */
+};
+
+/* Get the color named NAME. If the color was found, returns 1 and
+ stores the color into *COLOR. If the color was not found, returns 0 and
+ does not modify *COLOR. */
+int
+grub_video_get_named_color (const char *name,
+ grub_video_rgba_color_t *color)
+{
+ int i;
+ for (i = 0; named_colors[i].name; i++)
+ {
+ if (grub_strcmp (named_colors[i].name, name) == 0)
+ {
+ *color = named_colors[i].color;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int
+parse_hex_color_component (const char *s, unsigned start, unsigned end)
+{
+ unsigned len;
+ char buf[3];
+
+ len = end - start;
+ /* Check the limits so we don't overrun the buffer. */
+ if (len < 1 || len > 2)
+ return 0;
+
+ if (len == 1)
+ {
+ buf[0] = s[start]; /* Get the first and only hex digit. */
+ buf[1] = buf[0]; /* Duplicate the hex digit. */
+ }
+ else if (len == 2)
+ {
+ buf[0] = s[start];
+ buf[1] = s[start + 1];
+ }
+
+ buf[2] = '\0';
+
+ return grub_strtoul (buf, 0, 16);
+}
+
+/* Parse a color string of the form "r, g, b", "#RGB", "#RGBA",
+ "#RRGGBB", or "#RRGGBBAA". */
+grub_err_t
+grub_video_parse_color (const char *s, grub_video_rgba_color_t *color)
+{
+ grub_video_rgba_color_t c;
+ const char *s0;
+
+ /* Skip whitespace. */
+ while (*s && grub_isspace (*s))
+ s++;
+
+ s0 = s;
+
+ if (*s == '#')
+ {
+ /* HTML-style. Number if hex digits:
+ [6] #RRGGBB [3] #RGB
+ [8] #RRGGBBAA [4] #RGBA */
+
+ s++; /* Skip the '#'. */
+ /* Count the hexits to determine the format. */
+ int hexits = 0;
+ const char *end = s;
+ while (grub_isxdigit (*end))
+ {
+ end++;
+ hexits++;
+ }
+
+ /* Parse the color components based on the format. */
+ if (hexits == 3 || hexits == 4)
+ {
+ c.red = parse_hex_color_component (s, 0, 1);
+ c.green = parse_hex_color_component (s, 1, 2);
+ c.blue = parse_hex_color_component (s, 2, 3);
+ if (hexits == 4)
+ c.alpha = parse_hex_color_component (s, 3, 4);
+ else
+ c.alpha = 255;
+ }
+ else if (hexits == 6 || hexits == 8)
+ {
+ c.red = parse_hex_color_component (s, 0, 2);
+ c.green = parse_hex_color_component (s, 2, 4);
+ c.blue = parse_hex_color_component (s, 4, 6);
+ if (hexits == 8)
+ c.alpha = parse_hex_color_component (s, 6, 8);
+ else
+ c.alpha = 255;
+ }
+ else
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid color specification `%s'"), s0);
+ }
+ else if (grub_isdigit (*s))
+ {
+ /* Comma separated decimal values. */
+ c.red = grub_strtoul (s, 0, 0);
+ s = grub_strchr (s, ',');
+ if (!s)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid color specification `%s'"), s0);
+ s++;
+ c.green = grub_strtoul (s, 0, 0);
+ s = grub_strchr (s, ',');
+ if (!s)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid color specification `%s'"), s0);
+ s++;
+ c.blue = grub_strtoul (s, 0, 0);
+ s = grub_strchr (s, ',');
+ if (!s)
+ c.alpha = 255;
+ else
+ {
+ s++;
+ c.alpha = grub_strtoul (s, 0, 0);
+ }
+ }
+ else
+ {
+ if (! grub_video_get_named_color (s, &c))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid color specification `%s'"), s0);
+ }
+
+ if (grub_errno == GRUB_ERR_NONE)
+ *color = c;
+ return grub_errno;
+}
diff --git a/grub-core/video/coreboot/cbfb.c b/grub-core/video/coreboot/cbfb.c
new file mode 100644
index 0000000..9af81fa
--- /dev/null
+++ b/grub-core/video/coreboot/cbfb.c
@@ -0,0 +1,190 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/coreboot/lbio.h>
+#include <grub/machine/console.h>
+
+struct grub_linuxbios_table_framebuffer *grub_video_coreboot_fbtable;
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+ grub_uint8_t *ptr;
+} framebuffer;
+
+static grub_err_t
+grub_video_cbfb_init (void)
+{
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_cbfb_fill_mode_info (struct grub_video_mode_info *out)
+{
+ grub_memset (out, 0, sizeof (*out));
+
+ out->width = grub_video_coreboot_fbtable->width;
+ out->height = grub_video_coreboot_fbtable->height;
+ out->pitch = grub_video_coreboot_fbtable->pitch;
+
+ out->red_field_pos = grub_video_coreboot_fbtable->red_field_pos;
+ out->red_mask_size = grub_video_coreboot_fbtable->red_mask_size;
+ out->green_field_pos = grub_video_coreboot_fbtable->green_field_pos;
+ out->green_mask_size = grub_video_coreboot_fbtable->green_mask_size;
+ out->blue_field_pos = grub_video_coreboot_fbtable->blue_field_pos;
+ out->blue_mask_size = grub_video_coreboot_fbtable->blue_mask_size;
+ out->reserved_field_pos = grub_video_coreboot_fbtable->reserved_field_pos;
+ out->reserved_mask_size = grub_video_coreboot_fbtable->reserved_mask_size;
+
+ out->mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
+ out->bpp = grub_video_coreboot_fbtable->bpp;
+ out->bytes_per_pixel = (grub_video_coreboot_fbtable->bpp + 7) / 8;
+ out->number_of_colors = 256;
+
+ out->blit_format = grub_video_get_blit_format (out);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_cbfb_setup (unsigned int width, unsigned int height,
+ unsigned int mode_type __attribute__ ((unused)),
+ unsigned int mode_mask __attribute__ ((unused)))
+{
+ grub_err_t err;
+
+ if (!grub_video_coreboot_fbtable)
+ return grub_error (GRUB_ERR_IO, "Couldn't find display device.");
+
+ if (!((width == grub_video_coreboot_fbtable->width && height == grub_video_coreboot_fbtable->height)
+ || (width == 0 && height == 0)))
+ return grub_error (GRUB_ERR_IO, "can't set mode %dx%d", width, height);
+
+ err = grub_video_cbfb_fill_mode_info (&framebuffer.mode_info);
+ if (err)
+ {
+ grub_dprintf ("video", "CBFB: couldn't fill mode info\n");
+ return err;
+ }
+
+ framebuffer.ptr = (void *) (grub_addr_t) grub_video_coreboot_fbtable->lfb;
+
+ grub_dprintf ("video", "CBFB: initialising FB @ %p %dx%dx%d\n",
+ framebuffer.ptr, framebuffer.mode_info.width,
+ framebuffer.mode_info.height, framebuffer.mode_info.bpp);
+
+ err = grub_video_fb_setup (mode_type, mode_mask,
+ &framebuffer.mode_info,
+ framebuffer.ptr, NULL, NULL);
+ if (err)
+ return err;
+
+ grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+
+ return err;
+}
+
+static grub_err_t
+grub_video_cbfb_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
+ *framebuf = (char *) framebuffer.ptr;
+
+ grub_video_fb_fini ();
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_video_adapter grub_video_cbfb_adapter =
+ {
+ .name = "Coreboot video driver",
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE_DIRTY,
+ .id = GRUB_VIDEO_DRIVER_COREBOOT,
+
+ .init = grub_video_cbfb_init,
+ .fini = grub_video_fb_fini,
+ .setup = grub_video_cbfb_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_cbfb_get_info_and_fini,
+ .set_palette = grub_video_fb_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_fb_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_fb_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+
+ .next = 0
+ };
+
+static int
+iterate_linuxbios_table (grub_linuxbios_table_item_t table_item,
+ void *data __attribute__ ((unused)))
+{
+ if (table_item->tag != GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER)
+ return 0;
+ grub_video_coreboot_fbtable = (struct grub_linuxbios_table_framebuffer *) (table_item + 1);
+ return 1;
+}
+
+void
+grub_video_coreboot_fb_early_init (void)
+{
+ grub_linuxbios_table_iterate (iterate_linuxbios_table, 0);
+}
+
+void
+grub_video_coreboot_fb_late_init (void)
+{
+ if (grub_video_coreboot_fbtable)
+ grub_video_register (&grub_video_cbfb_adapter);
+}
+
+void
+grub_video_coreboot_fb_fini (void)
+{
+ if (grub_video_coreboot_fbtable)
+ grub_video_unregister (&grub_video_cbfb_adapter);
+}
diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c
new file mode 100644
index 0000000..b7590dc
--- /dev/null
+++ b/grub-core/video/efi_gop.c
@@ -0,0 +1,621 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/edid.h>
+#include <grub/efi/graphics_output.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_efi_guid_t graphics_output_guid = GRUB_EFI_GOP_GUID;
+static grub_efi_guid_t active_edid_guid = GRUB_EFI_EDID_ACTIVE_GUID;
+static grub_efi_guid_t discovered_edid_guid = GRUB_EFI_EDID_DISCOVERED_GUID;
+static grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+static struct grub_efi_gop *gop;
+static unsigned old_mode;
+static int restore_needed;
+static grub_efi_handle_t gop_handle;
+
+static int
+grub_video_gop_iterate (int (*hook) (const struct grub_video_mode_info *info, void *hook_arg), void *hook_arg);
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+ struct grub_video_render_target *render_target;
+ grub_uint8_t *ptr;
+ grub_uint8_t *offscreen;
+} framebuffer;
+
+static int
+check_protocol_hook (const struct grub_video_mode_info *info __attribute__ ((unused)), void *hook_arg)
+{
+ int *have_usable_mode = hook_arg;
+ *have_usable_mode = 1;
+ return 1;
+}
+
+
+static int
+check_protocol (void)
+{
+ grub_efi_handle_t *handles;
+ grub_efi_uintn_t num_handles, i;
+ int have_usable_mode = 0;
+
+ handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL,
+ &graphics_output_guid, NULL, &num_handles);
+ if (!handles || num_handles == 0)
+ {
+ grub_dprintf ("video", "GOP: no handles\n");
+ return 0;
+ }
+
+ for (i = 0; i < num_handles; i++)
+ {
+ gop_handle = handles[i];
+ gop = grub_efi_open_protocol (gop_handle, &graphics_output_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ grub_video_gop_iterate (check_protocol_hook, &have_usable_mode);
+ if (have_usable_mode)
+ {
+ grub_dprintf ("video", "GOP: found usable mode\n");
+ grub_free (handles);
+ return 1;
+ }
+ }
+
+ gop = 0;
+ gop_handle = 0;
+
+ grub_dprintf ("video", "GOP: no usable mode\n");
+
+ return 0;
+}
+
+static grub_err_t
+grub_video_gop_init (void)
+{
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_gop_fini (void)
+{
+ if (restore_needed)
+ {
+ efi_call_2 (gop->set_mode, gop, old_mode);
+ restore_needed = 0;
+ }
+ grub_free (framebuffer.offscreen);
+ framebuffer.offscreen = 0;
+ return grub_video_fb_fini ();
+}
+
+static int
+grub_video_gop_get_bpp (struct grub_efi_gop_mode_info *in)
+{
+ grub_uint32_t total_mask;
+ int i;
+ switch (in->pixel_format)
+ {
+ case GRUB_EFI_GOT_BGRA8:
+ case GRUB_EFI_GOT_RGBA8:
+ case GRUB_EFI_GOT_BLT_ONLY:
+ return 32;
+
+ case GRUB_EFI_GOT_BITMASK:
+ /* Check overlaps. */
+ if ((in->pixel_bitmask.r & in->pixel_bitmask.g)
+ || (in->pixel_bitmask.r & in->pixel_bitmask.b)
+ || (in->pixel_bitmask.g & in->pixel_bitmask.b)
+ || (in->pixel_bitmask.r & in->pixel_bitmask.a)
+ || (in->pixel_bitmask.g & in->pixel_bitmask.a)
+ || (in->pixel_bitmask.b & in->pixel_bitmask.a))
+ return 0;
+
+ total_mask = in->pixel_bitmask.r | in->pixel_bitmask.g
+ | in->pixel_bitmask.b | in->pixel_bitmask.a;
+
+ for (i = 31; i >= 0; i--)
+ if (total_mask & (1 << i))
+ return i + 1;
+
+ /* Fall through. */
+ default:
+ return 0;
+ }
+}
+
+static void
+grub_video_gop_get_bitmask (grub_uint32_t mask, unsigned int *mask_size,
+ unsigned int *field_pos)
+{
+ int i;
+ int last_p;
+ for (i = 31; i >= 0; i--)
+ if (mask & (1 << i))
+ break;
+ if (i == -1)
+ {
+ *mask_size = *field_pos = 0;
+ return;
+ }
+ last_p = i;
+ for (; i >= 0; i--)
+ if (!(mask & (1 << i)))
+ break;
+ *field_pos = i + 1;
+ *mask_size = last_p - *field_pos + 1;
+}
+
+static grub_err_t
+grub_video_gop_fill_real_mode_info (unsigned mode,
+ struct grub_efi_gop_mode_info *in,
+ struct grub_video_mode_info *out)
+{
+ out->mode_number = mode;
+ out->number_of_colors = 256;
+ out->width = in->width;
+ out->height = in->height;
+ out->mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
+ out->bpp = grub_video_gop_get_bpp (in);
+ out->bytes_per_pixel = out->bpp >> 3;
+ if (!out->bpp)
+ return grub_error (GRUB_ERR_IO, "unsupported video mode");
+ out->pitch = in->pixels_per_scanline * out->bytes_per_pixel;
+
+ switch (in->pixel_format)
+ {
+ case GRUB_EFI_GOT_RGBA8:
+ case GRUB_EFI_GOT_BLT_ONLY:
+ out->red_mask_size = 8;
+ out->red_field_pos = 0;
+ out->green_mask_size = 8;
+ out->green_field_pos = 8;
+ out->blue_mask_size = 8;
+ out->blue_field_pos = 16;
+ out->reserved_mask_size = 8;
+ out->reserved_field_pos = 24;
+ break;
+
+ case GRUB_EFI_GOT_BGRA8:
+ out->red_mask_size = 8;
+ out->red_field_pos = 16;
+ out->green_mask_size = 8;
+ out->green_field_pos = 8;
+ out->blue_mask_size = 8;
+ out->blue_field_pos = 0;
+ out->reserved_mask_size = 8;
+ out->reserved_field_pos = 24;
+ break;
+
+ case GRUB_EFI_GOT_BITMASK:
+ grub_video_gop_get_bitmask (in->pixel_bitmask.r, &out->red_mask_size,
+ &out->red_field_pos);
+ grub_video_gop_get_bitmask (in->pixel_bitmask.g, &out->green_mask_size,
+ &out->green_field_pos);
+ grub_video_gop_get_bitmask (in->pixel_bitmask.b, &out->blue_mask_size,
+ &out->blue_field_pos);
+ grub_video_gop_get_bitmask (in->pixel_bitmask.a, &out->reserved_mask_size,
+ &out->reserved_field_pos);
+ break;
+
+ default:
+ return grub_error (GRUB_ERR_IO, "unsupported video mode");
+ }
+
+ out->blit_format = grub_video_get_blit_format (out);
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_video_gop_fill_mode_info (unsigned mode,
+ struct grub_efi_gop_mode_info *in,
+ struct grub_video_mode_info *out)
+{
+ out->mode_number = mode;
+ out->number_of_colors = 256;
+ out->width = in->width;
+ out->height = in->height;
+ out->mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
+ out->bytes_per_pixel = sizeof (struct grub_efi_gop_blt_pixel);
+ out->bpp = out->bytes_per_pixel << 3;
+ out->pitch = in->width * out->bytes_per_pixel;
+ out->red_mask_size = 8;
+ out->red_field_pos = 16;
+ out->green_mask_size = 8;
+ out->green_field_pos = 8;
+ out->blue_mask_size = 8;
+ out->blue_field_pos = 0;
+ out->reserved_mask_size = 8;
+ out->reserved_field_pos = 24;
+
+ out->blit_format = GRUB_VIDEO_BLIT_FORMAT_BGRA_8888;
+ out->mode_type |= (GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED
+ | GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP);
+}
+
+static int
+grub_video_gop_iterate (int (*hook) (const struct grub_video_mode_info *info, void *hook_arg), void *hook_arg)
+{
+ unsigned mode;
+
+ for (mode = 0; mode < gop->mode->max_mode; mode++)
+ {
+ grub_efi_uintn_t size;
+ grub_efi_status_t status;
+ struct grub_efi_gop_mode_info *info = NULL;
+ struct grub_video_mode_info mode_info;
+
+ status = efi_call_4 (gop->query_mode, gop, mode, &size, &info);
+
+ if (status)
+ {
+ info = 0;
+ continue;
+ }
+
+ grub_video_gop_fill_mode_info (mode, info, &mode_info);
+ if (hook (&mode_info, hook_arg))
+ return 1;
+ }
+ return 0;
+}
+
+static grub_err_t
+grub_video_gop_get_edid (struct grub_video_edid_info *edid_info)
+{
+ struct grub_efi_active_edid *edid;
+ grub_size_t copy_size;
+
+ grub_memset (edid_info, 0, sizeof (*edid_info));
+
+ edid = grub_efi_open_protocol (gop_handle, &active_edid_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (!edid || edid->size_of_edid == 0)
+ edid = grub_efi_open_protocol (gop_handle, &discovered_edid_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+
+ if (!edid || edid->size_of_edid == 0)
+ {
+ char edidname[] = "agp-internal-edid";
+ grub_size_t datasize;
+ grub_uint8_t *data;
+ grub_efi_get_variable (edidname, &efi_var_guid, &datasize, (void **) &data);
+ if (data && datasize > 16)
+ {
+ copy_size = datasize - 16;
+ if (copy_size > sizeof (*edid_info))
+ copy_size = sizeof (*edid_info);
+ grub_memcpy (edid_info, data + 16, copy_size);
+ grub_free (data);
+ return GRUB_ERR_NONE;
+ }
+ return grub_error (GRUB_ERR_BAD_DEVICE, "EDID information not available");
+ }
+
+ copy_size = edid->size_of_edid;
+ if (copy_size > sizeof (*edid_info))
+ copy_size = sizeof (*edid_info);
+ grub_memcpy (edid_info, edid->edid, copy_size);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_gop_get_preferred_mode (unsigned int *width, unsigned int *height)
+{
+ struct grub_video_edid_info edid_info;
+ grub_err_t err;
+
+ err = grub_video_gop_get_edid (&edid_info);
+ if (err)
+ return err;
+ err = grub_video_edid_checksum (&edid_info);
+ if (err)
+ return err;
+ err = grub_video_edid_preferred_mode (&edid_info, width, height);
+ if (err)
+ return err;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_gop_setup (unsigned int width, unsigned int height,
+ unsigned int mode_type,
+ unsigned int mode_mask __attribute__ ((unused)))
+{
+ unsigned int depth;
+ struct grub_efi_gop_mode_info *info = NULL;
+ unsigned best_mode = 0;
+ grub_err_t err;
+ unsigned bpp;
+ int found = 0;
+ unsigned long long best_volume = 0;
+ unsigned int preferred_width = 0, preferred_height = 0;
+ grub_uint8_t *buffer;
+
+ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
+
+ if (width == 0 && height == 0)
+ {
+ err = grub_gop_get_preferred_mode (&preferred_width, &preferred_height);
+ if (err || preferred_width >= 4096 || preferred_height >= 4096)
+ {
+ preferred_width = 800;
+ preferred_height = 600;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ }
+
+ /* Keep current mode if possible. */
+ if (gop->mode->info)
+ {
+ bpp = grub_video_gop_get_bpp (gop->mode->info);
+ if (bpp && ((width == gop->mode->info->width
+ && height == gop->mode->info->height)
+ || (width == 0 && height == 0))
+ && (depth == bpp || depth == 0))
+ {
+ grub_dprintf ("video", "GOP: keeping mode %d\n", gop->mode->mode);
+ best_mode = gop->mode->mode;
+ found = 1;
+ }
+ }
+
+ if (!found)
+ {
+ unsigned mode;
+ grub_dprintf ("video", "GOP: %d modes detected\n", gop->mode->max_mode);
+ for (mode = 0; mode < gop->mode->max_mode; mode++)
+ {
+ grub_efi_uintn_t size;
+ grub_efi_status_t status;
+
+ status = efi_call_4 (gop->query_mode, gop, mode, &size, &info);
+ if (status)
+ {
+ info = 0;
+ continue;
+ }
+
+ grub_dprintf ("video", "GOP: mode %d: %dx%d\n", mode, info->width,
+ info->height);
+
+ if (preferred_width && (info->width > preferred_width
+ || info->height > preferred_height))
+ {
+ grub_dprintf ("video", "GOP: mode %d: too large\n", mode);
+ continue;
+ }
+
+ bpp = grub_video_gop_get_bpp (info);
+ if (!bpp)
+ {
+ grub_dprintf ("video", "GOP: mode %d: incompatible pixel mode\n",
+ mode);
+ continue;
+ }
+
+ grub_dprintf ("video", "GOP: mode %d: depth %d\n", mode, bpp);
+
+ if (!(((info->width == width && info->height == height)
+ || (width == 0 && height == 0))
+ && (bpp == depth || depth == 0)))
+ {
+ grub_dprintf ("video", "GOP: mode %d: rejected\n", mode);
+ continue;
+ }
+
+ if (best_volume < ((unsigned long long) info->width)
+ * ((unsigned long long) info->height)
+ * ((unsigned long long) bpp))
+ {
+ best_volume = ((unsigned long long) info->width)
+ * ((unsigned long long) info->height)
+ * ((unsigned long long) bpp);
+ best_mode = mode;
+ }
+ found = 1;
+ }
+ }
+
+ if (!found)
+ {
+ grub_dprintf ("video", "GOP: no mode found\n");
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found");
+ }
+
+ if (best_mode != gop->mode->mode)
+ {
+ if (!restore_needed)
+ {
+ old_mode = gop->mode->mode;
+ restore_needed = 1;
+ }
+ efi_call_2 (gop->set_mode, gop, best_mode);
+ }
+
+ info = gop->mode->info;
+
+ grub_video_gop_fill_mode_info (gop->mode->mode, info,
+ &framebuffer.mode_info);
+
+ framebuffer.ptr = (void *) (grub_addr_t) gop->mode->fb_base;
+ framebuffer.offscreen
+ = grub_malloc (framebuffer.mode_info.height
+ * framebuffer.mode_info.width
+ * sizeof (struct grub_efi_gop_blt_pixel));
+
+ buffer = framebuffer.offscreen;
+
+ if (!buffer)
+ {
+ grub_dprintf ("video", "GOP: couldn't allocate shadow\n");
+ grub_errno = 0;
+ grub_video_gop_fill_mode_info (gop->mode->mode, info,
+ &framebuffer.mode_info);
+ buffer = framebuffer.ptr;
+ }
+
+ grub_dprintf ("video", "GOP: initialising FB @ %p %dx%dx%d\n",
+ framebuffer.ptr, framebuffer.mode_info.width,
+ framebuffer.mode_info.height, framebuffer.mode_info.bpp);
+
+ err = grub_video_fb_create_render_target_from_pointer
+ (&framebuffer.render_target, &framebuffer.mode_info, buffer);
+
+ if (err)
+ {
+ grub_dprintf ("video", "GOP: Couldn't create FB target\n");
+ return err;
+ }
+
+ err = grub_video_fb_set_active_render_target (framebuffer.render_target);
+
+ if (err)
+ {
+ grub_dprintf ("video", "GOP: Couldn't set FB target\n");
+ return err;
+ }
+
+ err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+
+ if (err)
+ grub_dprintf ("video", "GOP: Couldn't set palette\n");
+ else
+ grub_dprintf ("video", "GOP: Success\n");
+
+ return err;
+}
+
+static grub_err_t
+grub_video_gop_swap_buffers (void)
+{
+ if (framebuffer.offscreen)
+ {
+ efi_call_10 (gop->blt, gop, framebuffer.offscreen,
+ GRUB_EFI_BLT_BUFFER_TO_VIDEO, 0, 0, 0, 0,
+ framebuffer.mode_info.width, framebuffer.mode_info.height,
+ framebuffer.mode_info.width * 4);
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_gop_set_active_render_target (struct grub_video_render_target *target)
+{
+ if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
+ target = framebuffer.render_target;
+
+ return grub_video_fb_set_active_render_target (target);
+}
+
+static grub_err_t
+grub_video_gop_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ grub_err_t err;
+
+ err = grub_video_gop_fill_real_mode_info (gop->mode->mode, gop->mode->info,
+ mode_info);
+ if (err)
+ {
+ grub_dprintf ("video", "GOP: couldn't fill mode info\n");
+ return err;
+ }
+
+ *framebuf = (char *) framebuffer.ptr;
+
+ grub_video_fb_fini ();
+
+ grub_free (framebuffer.offscreen);
+ framebuffer.offscreen = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_video_adapter grub_video_gop_adapter =
+ {
+ .name = "EFI GOP driver",
+ .id = GRUB_VIDEO_DRIVER_EFI_GOP,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
+
+ .init = grub_video_gop_init,
+ .fini = grub_video_gop_fini,
+ .setup = grub_video_gop_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_gop_get_info_and_fini,
+ .get_edid = grub_video_gop_get_edid,
+ .set_palette = grub_video_fb_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_gop_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_gop_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+ .iterate = grub_video_gop_iterate,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(efi_gop)
+{
+ if (check_protocol ())
+ grub_video_register (&grub_video_gop_adapter);
+}
+
+GRUB_MOD_FINI(efi_gop)
+{
+ if (restore_needed)
+ {
+ efi_call_2 (gop->set_mode, gop, old_mode);
+ restore_needed = 0;
+ }
+ if (gop)
+ grub_video_unregister (&grub_video_gop_adapter);
+}
diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c
new file mode 100644
index 0000000..e74d6c2
--- /dev/null
+++ b/grub-core/video/efi_uga.c
@@ -0,0 +1,369 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/uga_draw.h>
+#include <grub/pci.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_efi_guid_t uga_draw_guid = GRUB_EFI_UGA_DRAW_GUID;
+static struct grub_efi_uga_draw_protocol *uga;
+static grub_uint64_t uga_fb;
+static grub_uint32_t uga_pitch;
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+ struct grub_video_render_target *render_target;
+ grub_uint8_t *ptr;
+} framebuffer;
+
+#define RGB_MASK 0xffffff
+#define RGB_MAGIC 0x121314
+#define LINE_MIN 800
+#define LINE_MAX 4096
+#define FBTEST_STEP (0x10000 >> 2)
+#define FBTEST_COUNT 8
+
+static int
+find_line_len (grub_uint64_t *fb_base, grub_uint32_t *line_len)
+{
+ grub_uint32_t *base = (grub_uint32_t *) (grub_addr_t) *fb_base;
+ int i;
+
+ for (i = 0; i < FBTEST_COUNT; i++, base += FBTEST_STEP)
+ {
+ if ((*base & RGB_MASK) == RGB_MAGIC)
+ {
+ int j;
+
+ for (j = LINE_MIN; j <= LINE_MAX; j++)
+ {
+ if ((base[j] & RGB_MASK) == RGB_MAGIC)
+ {
+ *fb_base = (grub_uint64_t) (grub_addr_t) base;
+ *line_len = j << 2;
+
+ return 1;
+ }
+ }
+
+ break;
+ }
+ }
+
+ return 0;
+}
+
+/* Context for find_framebuf. */
+struct find_framebuf_ctx
+{
+ grub_uint64_t *fb_base;
+ grub_uint32_t *line_len;
+ int found;
+};
+
+/* Helper for find_framebuf. */
+static int
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
+{
+ struct find_framebuf_ctx *ctx = data;
+ grub_pci_address_t addr, rcaddr;
+ grub_uint32_t subclass;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ subclass = (grub_pci_read (addr) >> 16) & 0xffff;
+
+ if (subclass != GRUB_PCI_CLASS_SUBCLASS_VGA)
+ return 0;
+
+ /* Enable MEM address spaces */
+ rcaddr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write_word (rcaddr, grub_pci_read_word (rcaddr) | GRUB_PCI_COMMAND_MEM_ENABLED);
+
+ {
+ int i;
+
+ grub_dprintf ("video", "Display controller: %d:%d.%d\nDevice id: %x\n",
+ grub_pci_get_bus (dev), grub_pci_get_device (dev),
+ grub_pci_get_function (dev), pciid);
+ addr += 8;
+ for (i = 0; i < 6; i++, addr += 4)
+ {
+ grub_uint32_t old_bar1, old_bar2, type;
+ grub_uint64_t base64;
+
+ old_bar1 = grub_pci_read (addr);
+ if ((! old_bar1) || (old_bar1 & GRUB_PCI_ADDR_SPACE_IO))
+ continue;
+
+ type = old_bar1 & GRUB_PCI_ADDR_MEM_TYPE_MASK;
+ if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
+ {
+ if (i == 5)
+ break;
+
+ i++;
+ addr += 4;
+ old_bar2 = grub_pci_read (addr);
+ }
+ else
+ old_bar2 = 0;
+
+ base64 = old_bar2;
+ base64 <<= 32;
+ base64 |= (old_bar1 & GRUB_PCI_ADDR_MEM_MASK);
+
+ grub_dprintf ("video", "%s(%d): 0x%" PRIxGRUB_UINT64_T "\n",
+ ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) ?
+ "VMEM" : "MMIO"), type == GRUB_PCI_ADDR_MEM_TYPE_64 ? i - 1 : i,
+ base64);
+
+#if GRUB_CPU_SIZEOF_VOID_P == 4
+ if (old_bar2)
+ continue;
+#endif
+
+ if ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) && (! ctx->found))
+ {
+ *ctx->fb_base = base64;
+ if (find_line_len (ctx->fb_base, ctx->line_len))
+ ctx->found++;
+ }
+ }
+ }
+
+ return ctx->found;
+}
+
+static int
+find_framebuf (grub_uint64_t *fb_base, grub_uint32_t *line_len)
+{
+ struct find_framebuf_ctx ctx = {
+ .fb_base = fb_base,
+ .line_len = line_len,
+ .found = 0
+ };
+
+ grub_pci_iterate (find_card, &ctx);
+ return ctx.found;
+}
+
+static int
+check_protocol (void)
+{
+ grub_efi_uga_draw_protocol_t *c;
+
+ c = grub_efi_locate_protocol (&uga_draw_guid, 0);
+ if (c)
+ {
+ grub_uint32_t width, height, depth, rate, pixel;
+ int ret;
+
+ if (efi_call_5 (c->get_mode, c, &width, &height, &depth, &rate))
+ return 0;
+
+ grub_efi_set_text_mode (0);
+ pixel = RGB_MAGIC;
+ efi_call_10 (c->blt, c, (struct grub_efi_uga_pixel *) &pixel,
+ GRUB_EFI_UGA_VIDEO_FILL, 0, 0, 0, 0, 1, height, 0);
+ ret = find_framebuf (&uga_fb, &uga_pitch);
+ grub_efi_set_text_mode (1);
+
+ if (ret)
+ {
+ uga = c;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static grub_err_t
+grub_video_uga_init (void)
+{
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_uga_fini (void)
+{
+ return grub_video_fb_fini ();
+}
+
+static grub_err_t
+grub_video_uga_setup (unsigned int width, unsigned int height,
+ unsigned int mode_type,
+ unsigned int mode_mask __attribute__ ((unused)))
+{
+ unsigned int depth;
+ int found = 0;
+
+ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
+
+ {
+ grub_uint32_t w;
+ grub_uint32_t h;
+ grub_uint32_t d;
+ grub_uint32_t r;
+
+ if ((! efi_call_5 (uga->get_mode, uga, &w, &h, &d, &r)) &&
+ ((! width) || (width == w)) &&
+ ((! height) || (height == h)) &&
+ ((! depth) || (depth == d)))
+ {
+ framebuffer.mode_info.width = w;
+ framebuffer.mode_info.height = h;
+ framebuffer.mode_info.pitch = uga_pitch;
+ framebuffer.ptr = (grub_uint8_t *) (grub_addr_t) uga_fb;
+
+ found = 1;
+ }
+ }
+
+ if (found)
+ {
+ grub_err_t err;
+
+ framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
+ framebuffer.mode_info.bpp = 32;
+ framebuffer.mode_info.bytes_per_pixel = 4;
+ framebuffer.mode_info.number_of_colors = 256;
+ framebuffer.mode_info.red_mask_size = 8;
+ framebuffer.mode_info.red_field_pos = 16;
+ framebuffer.mode_info.green_mask_size = 8;
+ framebuffer.mode_info.green_field_pos = 8;
+ framebuffer.mode_info.blue_mask_size = 8;
+ framebuffer.mode_info.blue_field_pos = 0;
+ framebuffer.mode_info.reserved_mask_size = 8;
+ framebuffer.mode_info.reserved_field_pos = 24;
+
+ framebuffer.mode_info.blit_format =
+ grub_video_get_blit_format (&framebuffer.mode_info);
+
+ err = grub_video_fb_create_render_target_from_pointer
+ (&framebuffer.render_target,
+ &framebuffer.mode_info,
+ framebuffer.ptr);
+
+ if (err)
+ return err;
+
+ err = grub_video_fb_set_active_render_target
+ (framebuffer.render_target);
+
+ if (err)
+ return err;
+
+ err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+
+ return err;
+ }
+
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found");
+}
+
+static grub_err_t
+grub_video_uga_swap_buffers (void)
+{
+ /* TODO: Implement buffer swapping. */
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_uga_set_active_render_target (struct grub_video_render_target *target)
+{
+ if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
+ target = framebuffer.render_target;
+
+ return grub_video_fb_set_active_render_target (target);
+}
+
+static grub_err_t
+grub_video_uga_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
+ *framebuf = (char *) framebuffer.ptr;
+
+ grub_video_fb_fini ();
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_video_adapter grub_video_uga_adapter =
+ {
+ .name = "EFI UGA driver",
+ .id = GRUB_VIDEO_DRIVER_EFI_UGA,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE_DIRTY,
+
+ .init = grub_video_uga_init,
+ .fini = grub_video_uga_fini,
+ .setup = grub_video_uga_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_uga_get_info_and_fini,
+ .set_palette = grub_video_fb_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_uga_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_uga_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+ };
+
+GRUB_MOD_INIT(efi_uga)
+{
+ if (check_protocol ())
+ grub_video_register (&grub_video_uga_adapter);
+}
+
+GRUB_MOD_FINI(efi_uga)
+{
+ if (uga)
+ grub_video_unregister (&grub_video_uga_adapter);
+}
diff --git a/grub-core/video/emu/sdl.c b/grub-core/video/emu/sdl.c
new file mode 100644
index 0000000..0ebab6f
--- /dev/null
+++ b/grub-core/video/emu/sdl.c
@@ -0,0 +1,252 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <SDL/SDL.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static SDL_Surface *window = 0;
+static struct grub_video_render_target *sdl_render_target;
+static struct grub_video_mode_info mode_info;
+
+static grub_err_t
+grub_video_sdl_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data);
+
+static grub_err_t
+grub_video_sdl_init (void)
+{
+ window = 0;
+
+ if (SDL_Init (SDL_INIT_VIDEO) < 0)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "Couldn't init SDL: %s",
+ SDL_GetError ());
+
+ grub_memset (&mode_info, 0, sizeof (mode_info));
+
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_sdl_fini (void)
+{
+ SDL_Quit ();
+ window = 0;
+
+ grub_memset (&mode_info, 0, sizeof (mode_info));
+
+ return grub_video_fb_fini ();
+}
+
+static inline unsigned int
+get_mask_size (grub_uint32_t mask)
+{
+ unsigned i;
+ for (i = 0; mask > 1U << i; i++);
+ return i;
+}
+
+static grub_err_t
+grub_video_sdl_setup (unsigned int width, unsigned int height,
+ unsigned int mode_type, unsigned int mode_mask)
+{
+ int depth;
+ int flags = 0;
+ grub_err_t err;
+
+ /* Decode depth from mode_type. If it is zero, then autodetect. */
+ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
+
+ if (depth == 0)
+ depth = 32;
+
+ if (width == 0 && height == 0)
+ {
+ width = 800;
+ height = 600;
+ }
+
+ if ((mode_type & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED)
+ || !(mode_mask & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED))
+ flags |= SDL_DOUBLEBUF;
+
+ window = SDL_SetVideoMode (width, height, depth, flags | SDL_HWSURFACE);
+ if (! window)
+ window = SDL_SetVideoMode (width, height, depth, flags | SDL_SWSURFACE);
+ if (! window)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "Couldn't open window: %s",
+ SDL_GetError ());
+
+ grub_memset (&sdl_render_target, 0, sizeof (sdl_render_target));
+
+ mode_info.width = window->w;
+ mode_info.height = window->h;
+ mode_info.mode_type = 0;
+ if (window->flags & SDL_DOUBLEBUF)
+ mode_info.mode_type
+ |= GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED;
+ if (window->format->palette)
+ mode_info.mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
+ else
+ mode_info.mode_type |= GRUB_VIDEO_MODE_TYPE_RGB;
+
+ mode_info.bpp = window->format->BitsPerPixel;
+ mode_info.bytes_per_pixel = window->format->BytesPerPixel;
+ mode_info.pitch = window->pitch;
+
+ /* In index color mode, number of colors. In RGB mode this is 256. */
+ if (window->format->palette)
+ mode_info.number_of_colors
+ = 1 << window->format->BitsPerPixel;
+ else
+ mode_info.number_of_colors = 256;
+
+ if (! window->format->palette)
+ {
+ mode_info.red_mask_size
+ = get_mask_size (window->format->Rmask >> window->format->Rshift);
+ mode_info.red_field_pos = window->format->Rshift;
+ mode_info.green_mask_size
+ = get_mask_size (window->format->Gmask >> window->format->Gshift);
+ mode_info.green_field_pos = window->format->Gshift;
+ mode_info.blue_mask_size
+ = get_mask_size (window->format->Bmask >> window->format->Bshift);
+ mode_info.blue_field_pos = window->format->Bshift;
+ mode_info.reserved_mask_size
+ = get_mask_size (window->format->Amask >> window->format->Ashift);
+ mode_info.reserved_field_pos = window->format->Ashift;
+ mode_info.blit_format
+ = grub_video_get_blit_format (&mode_info);
+ }
+
+ err = grub_video_fb_create_render_target_from_pointer (&sdl_render_target,
+ &mode_info,
+ window->pixels);
+ if (err)
+ return err;
+
+ /* Copy default palette to initialize emulated palette. */
+ grub_video_sdl_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+
+ /* Reset render target to SDL one. */
+ return grub_video_fb_set_active_render_target (sdl_render_target);
+}
+
+static grub_err_t
+grub_video_sdl_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data)
+{
+ unsigned i;
+ if (window->format->palette)
+ {
+ SDL_Color *tmp;
+ if (start >= mode_info.number_of_colors)
+ return GRUB_ERR_NONE;
+
+ if (start + count > mode_info.number_of_colors)
+ count = mode_info.number_of_colors - start;
+
+ tmp = grub_calloc (count, sizeof (tmp[0]));
+ for (i = 0; i < count; i++)
+ {
+ tmp[i].r = palette_data[i].r;
+ tmp[i].g = palette_data[i].g;
+ tmp[i].b = palette_data[i].b;
+ tmp[i].unused = palette_data[i].a;
+ }
+ SDL_SetColors (window, tmp, start, count);
+ grub_free (tmp);
+ }
+
+ return grub_video_fb_set_palette (start, count, palette_data);
+}
+
+static grub_err_t
+grub_video_sdl_swap_buffers (void)
+{
+ if (SDL_Flip (window) < 0)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "couldn't swap buffers: %s",
+ SDL_GetError ());
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_sdl_set_active_render_target (struct grub_video_render_target *target)
+{
+ if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
+ return grub_video_fb_set_active_render_target (sdl_render_target);
+
+ return grub_video_fb_set_active_render_target (target);
+}
+
+static struct grub_video_adapter grub_video_sdl_adapter =
+ {
+ .name = "SDL Video Driver",
+ .id = GRUB_VIDEO_DRIVER_SDL,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
+
+ .init = grub_video_sdl_init,
+ .fini = grub_video_sdl_fini,
+ .setup = grub_video_sdl_setup,
+ .get_info = grub_video_fb_get_info,
+ .set_palette = grub_video_sdl_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_sdl_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_sdl_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(sdl)
+{
+ grub_video_register (&grub_video_sdl_adapter);
+}
+
+GRUB_MOD_FINI(sdl)
+{
+ grub_video_unregister (&grub_video_sdl_adapter);
+}
diff --git a/grub-core/video/fb/fbblit.c b/grub-core/video/fb/fbblit.c
new file mode 100644
index 0000000..d559248
--- /dev/null
+++ b/grub-core/video/fb/fbblit.c
@@ -0,0 +1,2227 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* SPECIAL NOTES!
+
+ Please note following when reading the code below:
+
+ - In this driver we assume that every memory can be accessed by same memory
+ bus. If there are different address spaces do not use this code as a base
+ code for other archs.
+
+ - Every function in this code assumes that bounds checking has been done in
+ previous phase and they are opted out in here. */
+
+#include <grub/video_fb.h>
+#include <grub/fbblit.h>
+#include <grub/fbutil.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/video.h>
+
+/* Generic replacing blitter (slow). Works for every supported format. */
+static void
+grub_video_fbblit_replace (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y, int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t src_red;
+ grub_uint8_t src_green;
+ grub_uint8_t src_blue;
+ grub_uint8_t src_alpha;
+ grub_video_color_t src_color;
+ grub_video_color_t dst_color;
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ src_color = get_pixel (src, i + offset_x, j + offset_y);
+
+ grub_video_fb_unmap_color_int (src, src_color, &src_red, &src_green,
+ &src_blue, &src_alpha);
+
+ dst_color = grub_video_fb_map_rgba (src_red, src_green,
+ src_blue, src_alpha);
+
+ set_pixel (dst, x + i, y + j, dst_color);
+ }
+ }
+}
+
+/* Block copy replacing blitter. Works with modes multiple of 8 bits. */
+static void
+grub_video_fbblit_replace_directN (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y, int width, int height,
+ int offset_x, int offset_y)
+{
+ int j;
+ grub_uint32_t *srcptr;
+ grub_uint32_t *dstptr;
+ int bpp;
+
+ bpp = src->mode_info->bytes_per_pixel;
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ grub_memmove (dstptr, srcptr, width * bpp);
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, src->mode_info->pitch);
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dst->mode_info->pitch);
+ }
+}
+
+/* Optimized replacing blitter for 1-bit to 32bit. */
+static void
+grub_video_fbblit_replace_32bit_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint32_t *dstptr;
+ grub_uint8_t srcmask;
+ unsigned int dstrowskip;
+ unsigned int srcrowskipbyte, srcrowskipbit;
+ grub_uint32_t fgcolor, bgcolor;
+ int bit_index;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskipbyte = (src->mode_info->width - width) >> 3;
+ srcrowskipbit = (src->mode_info->width - width) & 7;
+
+ bit_index = offset_y * src->mode_info->width + offset_x;
+ srcptr = (grub_uint8_t *) src->data + (bit_index >> 3);
+ srcmask = 1 << (~bit_index & 7);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red,
+ src->mode_info->fg_green,
+ src->mode_info->fg_blue,
+ src->mode_info->fg_alpha);
+
+ bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red,
+ src->mode_info->bg_green,
+ src->mode_info->bg_blue,
+ src->mode_info->bg_alpha);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ if (*srcptr & srcmask)
+ *dstptr = fgcolor;
+ else
+ *dstptr = bgcolor;
+ srcmask >>= 1;
+ if (!srcmask)
+ {
+ srcptr++;
+ srcmask = 0x80;
+ }
+
+ dstptr++;
+ }
+
+ srcptr += srcrowskipbyte;
+ if (srcmask >> srcrowskipbit)
+ srcmask >>= srcrowskipbit;
+ else
+ {
+ srcptr++;
+ srcmask <<= 8 - srcrowskipbit;
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+
+#ifdef GRUB_HAVE_UNALIGNED_ACCESS
+/* Optimized replacing blitter for 1-bit to 24-bit. */
+static void
+grub_video_fbblit_replace_24bit_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ grub_uint8_t srcmask;
+ unsigned int dstrowskip;
+ unsigned int srcrowskipbyte, srcrowskipbit;
+ grub_uint32_t fgcolor, bgcolor;
+ int bit_index;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskipbyte = (src->mode_info->width - width) >> 3;
+ srcrowskipbit = (src->mode_info->width - width) & 7;
+
+ bit_index = offset_y * src->mode_info->width + offset_x;
+ srcptr = (grub_uint8_t *) src->data + (bit_index >> 3);
+ srcmask = 1 << (~bit_index & 7);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red,
+ src->mode_info->fg_green,
+ src->mode_info->fg_blue,
+ src->mode_info->fg_alpha);
+
+ bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red,
+ src->mode_info->bg_green,
+ src->mode_info->bg_blue,
+ src->mode_info->bg_alpha);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width - 1; i++)
+ {
+ if (*srcptr & srcmask)
+ *(grub_uint32_t *) dstptr = fgcolor;
+ else
+ *(grub_uint32_t *) dstptr = bgcolor;
+ srcmask >>= 1;
+ if (!srcmask)
+ {
+ srcptr++;
+ srcmask = 0x80;
+ }
+
+ dstptr += 3;
+ }
+
+ if (*srcptr & srcmask)
+ {
+ *dstptr++ = fgcolor & 0xff;
+ *dstptr++ = (fgcolor & 0xff00) >> 8;
+ *dstptr++ = (fgcolor & 0xff0000) >> 16;
+ }
+ else
+ {
+ *dstptr++ = bgcolor & 0xff;
+ *dstptr++ = (bgcolor & 0xff00) >> 8;
+ *dstptr++ = (bgcolor & 0xff0000) >> 16;
+ }
+ srcmask >>= 1;
+ if (!srcmask)
+ {
+ srcptr++;
+ srcmask = 0x80;
+ }
+
+ srcptr += srcrowskipbyte;
+ if (srcmask >> srcrowskipbit)
+ srcmask >>= srcrowskipbit;
+ else
+ {
+ srcptr++;
+ srcmask <<= 8 - srcrowskipbit;
+ }
+ dstptr += dstrowskip;
+ }
+}
+#endif
+
+/* Optimized replacing blitter for 1-bit to 16-bit. */
+static void
+grub_video_fbblit_replace_16bit_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint16_t *dstptr;
+ grub_uint8_t srcmask;
+ unsigned int dstrowskip;
+ unsigned int srcrowskipbyte, srcrowskipbit;
+ grub_uint16_t fgcolor, bgcolor;
+ int bit_index;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskipbyte = (src->mode_info->width - width) >> 3;
+ srcrowskipbit = (src->mode_info->width - width) & 7;
+
+ bit_index = offset_y * src->mode_info->width + offset_x;
+ srcptr = (grub_uint8_t *) src->data + (bit_index >> 3);
+ srcmask = 1 << (~bit_index & 7);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red,
+ src->mode_info->fg_green,
+ src->mode_info->fg_blue,
+ src->mode_info->fg_alpha);
+
+ bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red,
+ src->mode_info->bg_green,
+ src->mode_info->bg_blue,
+ src->mode_info->bg_alpha);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ if (*srcptr & srcmask)
+ *dstptr = fgcolor;
+ else
+ *dstptr = bgcolor;
+ srcmask >>= 1;
+ if (!srcmask)
+ {
+ srcptr++;
+ srcmask = 0x80;
+ }
+
+ dstptr++;
+ }
+
+ srcptr += srcrowskipbyte;
+ if (srcmask >> srcrowskipbit)
+ srcmask >>= srcrowskipbit;
+ else
+ {
+ srcptr++;
+ srcmask <<= 8 - srcrowskipbit;
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized replacing blitter for 1-bit to 8-bit. */
+static void
+grub_video_fbblit_replace_8bit_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ grub_uint8_t srcmask;
+ unsigned int dstrowskip;
+ unsigned int srcrowskipbyte, srcrowskipbit;
+ grub_uint8_t fgcolor, bgcolor;
+ int bit_index;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskipbyte = (src->mode_info->width - width) >> 3;
+ srcrowskipbit = (src->mode_info->width - width) & 7;
+
+ bit_index = offset_y * src->mode_info->width + offset_x;
+ srcptr = (grub_uint8_t *) src->data + (bit_index >> 3);
+ srcmask = 1 << (~bit_index & 7);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red,
+ src->mode_info->fg_green,
+ src->mode_info->fg_blue,
+ src->mode_info->fg_alpha);
+
+ bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red,
+ src->mode_info->bg_green,
+ src->mode_info->bg_blue,
+ src->mode_info->bg_alpha);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ if (*srcptr & srcmask)
+ *dstptr = fgcolor;
+ else
+ *dstptr = bgcolor;
+ srcmask >>= 1;
+ if (!srcmask)
+ {
+ srcptr++;
+ srcmask = 0x80;
+ }
+
+ dstptr++;
+ }
+
+ srcptr += srcrowskipbyte;
+ if (srcmask >> srcrowskipbit)
+ srcmask >>= srcrowskipbit;
+ else
+ {
+ srcptr++;
+ srcmask <<= 8 - srcrowskipbit;
+ }
+ dstptr += dstrowskip;
+ }
+}
+
+static void
+grub_video_fbblit_replace_32bit_indexa (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint32_t *dstptr;
+ unsigned int dstrowskip;
+ unsigned int srcrowskip;
+ grub_uint32_t palette[17];
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskip = src->mode_info->pitch - width;
+
+ for (i = 0; i < 16; i++)
+ palette[i] = grub_video_fb_map_color (i);
+ palette[16] = grub_video_fb_map_rgba (0, 0, 0, 0);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ if (*srcptr == 0xf0)
+ *dstptr = palette[16];
+ else
+ *dstptr = palette[*srcptr & 0xf];
+ srcptr++;
+ dstptr++;
+ }
+
+ srcptr += srcrowskip;
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized replacing blitter for 1-bit to 16bit. */
+static void
+grub_video_fbblit_replace_24bit_indexa (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int dstrowskip;
+ unsigned int srcrowskip;
+ grub_uint32_t palette[17];
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskip = src->mode_info->pitch - width;
+
+ for (i = 0; i < 16; i++)
+ palette[i] = grub_video_fb_map_color (i);
+ palette[16] = grub_video_fb_map_rgba (0, 0, 0, 0);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ register grub_uint32_t col;
+ if (*srcptr == 0xf0)
+ col = palette[16];
+ else
+ col = palette[*srcptr & 0xf];
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ *dstptr++ = col >> 16;
+ *dstptr++ = col >> 8;
+ *dstptr++ = col >> 0;
+#else
+ *dstptr++ = col >> 0;
+ *dstptr++ = col >> 8;
+ *dstptr++ = col >> 16;
+#endif
+ srcptr++;
+ }
+
+ srcptr += srcrowskip;
+ dstptr += dstrowskip;
+ }
+}
+
+/* Optimized replacing blitter for 1-bit to 16bit. */
+static void
+grub_video_fbblit_replace_16bit_indexa (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint16_t *dstptr;
+ unsigned int dstrowskip;
+ unsigned int srcrowskip;
+ grub_uint16_t palette[17];
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskip = src->mode_info->pitch - width;
+
+ for (i = 0; i < 16; i++)
+ palette[i] = grub_video_fb_map_color (i);
+ palette[16] = grub_video_fb_map_rgba (0, 0, 0, 0);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ if (*srcptr == 0xf0)
+ *dstptr = palette[16];
+ else
+ *dstptr = palette[*srcptr & 0xf];
+ srcptr++;
+ dstptr++;
+ }
+
+ srcptr += srcrowskip;
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized replacing blitter for 1-bit to 8bit. */
+static void
+grub_video_fbblit_replace_8bit_indexa (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int dstrowskip;
+ unsigned int srcrowskip;
+ grub_uint8_t palette[17];
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskip = src->mode_info->pitch - width;
+
+ for (i = 0; i < 16; i++)
+ palette[i] = grub_video_fb_map_color (i);
+ palette[16] = grub_video_fb_map_rgba (0, 0, 0, 0);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ if (*srcptr == 0xf0)
+ *dstptr = palette[16];
+ else
+ *dstptr = palette[*srcptr & 0xf];
+ srcptr++;
+ dstptr++;
+ }
+
+ srcptr += srcrowskip;
+ dstptr += dstrowskip;
+ }
+}
+
+
+static void
+grub_video_fbblit_blend_32bit_indexa (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint32_t *dstptr;
+ unsigned int dstrowskip;
+ unsigned int srcrowskip;
+ grub_uint32_t palette[16];
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskip = src->mode_info->pitch - width;
+
+ for (i = 0; i < 16; i++)
+ palette[i] = grub_video_fb_map_color (i);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ if (*srcptr != 0xf0)
+ *dstptr = palette[*srcptr & 0xf];
+ srcptr++;
+ dstptr++;
+ }
+
+ srcptr += srcrowskip;
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized replacing blitter for 1-bit to 16bit. */
+static void
+grub_video_fbblit_blend_24bit_indexa (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int dstrowskip;
+ unsigned int srcrowskip;
+ grub_uint32_t palette[16];
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskip = src->mode_info->pitch - width;
+
+ for (i = 0; i < 16; i++)
+ palette[i] = grub_video_fb_map_color (i);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ register grub_uint32_t col;
+ if (*srcptr != 0xf0)
+ {
+ col = palette[*srcptr & 0xf];
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ *dstptr++ = col >> 16;
+ *dstptr++ = col >> 8;
+ *dstptr++ = col >> 0;
+#else
+ *dstptr++ = col >> 0;
+ *dstptr++ = col >> 8;
+ *dstptr++ = col >> 16;
+#endif
+ }
+ else
+ dstptr += 3;
+ srcptr++;
+ }
+
+ srcptr += srcrowskip;
+ dstptr += dstrowskip;
+ }
+}
+
+/* Optimized replacing blitter for 1-bit to 16bit. */
+static void
+grub_video_fbblit_blend_16bit_indexa (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint16_t *dstptr;
+ unsigned int dstrowskip;
+ unsigned int srcrowskip;
+ grub_uint16_t palette[17];
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskip = src->mode_info->pitch - width;
+
+ for (i = 0; i < 16; i++)
+ palette[i] = grub_video_fb_map_color (i);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ if (*srcptr != 0xf0)
+ *dstptr = palette[*srcptr & 0xf];
+ srcptr++;
+ dstptr++;
+ }
+
+ srcptr += srcrowskip;
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized replacing blitter for 1-bit to 8bit. */
+static void
+grub_video_fbblit_blend_8bit_indexa (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int dstrowskip;
+ unsigned int srcrowskip;
+ grub_uint8_t palette[16];
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskip = src->mode_info->pitch - width;
+
+ for (i = 0; i < 16; i++)
+ palette[i] = grub_video_fb_map_color (i);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ if (*srcptr != 0xf0)
+ *dstptr = palette[*srcptr & 0xf];
+ srcptr++;
+ dstptr++;
+ }
+
+ srcptr += srcrowskip;
+ dstptr += dstrowskip;
+ }
+}
+
+
+/* Optimized replacing blitter for RGBX8888 to BGRX8888. */
+static void
+grub_video_fbblit_replace_BGRX8888_RGBX8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int srcrowskip;
+ unsigned int dstrowskip;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ grub_uint8_t a = *srcptr++;
+#endif
+ grub_uint8_t r = *srcptr++;
+ grub_uint8_t g = *srcptr++;
+ grub_uint8_t b = *srcptr++;
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ grub_uint8_t a = *srcptr++;
+#endif
+
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ *dstptr++ = a;
+#endif
+ *dstptr++ = b;
+ *dstptr++ = g;
+ *dstptr++ = r;
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ *dstptr++ = a;
+#endif
+ }
+
+ srcptr += srcrowskip;
+ dstptr += dstrowskip;
+ }
+}
+
+/* Optimized replacing blitter for RGB888 to BGRX8888. */
+static void
+grub_video_fbblit_replace_BGRX8888_RGB888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int srcrowskip;
+ unsigned int dstrowskip;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ grub_uint8_t r = *srcptr++;
+ grub_uint8_t g = *srcptr++;
+ grub_uint8_t b = *srcptr++;
+
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ /* Set alpha component as opaque. */
+ *dstptr++ = 255;
+#endif
+
+ *dstptr++ = b;
+ *dstptr++ = g;
+ *dstptr++ = r;
+
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ /* Set alpha component as opaque. */
+ *dstptr++ = 255;
+#endif
+ }
+
+ srcptr += srcrowskip;
+ dstptr += dstrowskip;
+ }
+}
+
+/* Optimized replacing blitter for RGBX8888 to BGR888. */
+static void
+grub_video_fbblit_replace_BGR888_RGBX8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ grub_uint32_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int srcrowskip;
+ unsigned int dstrowskip;
+ int i;
+ int j;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ grub_uint32_t color;
+ grub_uint8_t sr;
+ grub_uint8_t sg;
+ grub_uint8_t sb;
+
+ color = *srcptr++;
+
+ sr = (color >> 0) & 0xFF;
+ sg = (color >> 8) & 0xFF;
+ sb = (color >> 16) & 0xFF;
+
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ *dstptr++ = sr;
+ *dstptr++ = sg;
+ *dstptr++ = sb;
+#else
+ *dstptr++ = sb;
+ *dstptr++ = sg;
+ *dstptr++ = sr;
+#endif
+ }
+
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, srcrowskip);
+ dstptr += dstrowskip;
+ }
+}
+
+/* Optimized replacing blitter for RGB888 to BGR888. */
+static void
+grub_video_fbblit_replace_BGR888_RGB888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int srcrowskip;
+ unsigned int dstrowskip;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ grub_uint8_t r = *srcptr++;
+ grub_uint8_t g = *srcptr++;
+ grub_uint8_t b = *srcptr++;
+
+ *dstptr++ = b;
+ *dstptr++ = g;
+ *dstptr++ = r;
+ }
+
+ srcptr += srcrowskip;
+ dstptr += dstrowskip;
+ }
+}
+
+/* Optimized replacing blitter for RGB888 to RGBX8888. */
+static void
+grub_video_fbblit_replace_RGBX8888_RGB888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ grub_uint32_t color;
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint32_t *dstptr;
+ unsigned int sr;
+ unsigned int sg;
+ unsigned int sb;
+ grub_size_t srcrowskip;
+ grub_size_t dstrowskip;
+
+ srcrowskip = src->mode_info->pitch - 3 * width;
+ dstrowskip = dst->mode_info->pitch - 4 * width;
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ sb = *srcptr++;
+ sg = *srcptr++;
+ sr = *srcptr++;
+#else
+ sr = *srcptr++;
+ sg = *srcptr++;
+ sb = *srcptr++;
+#endif
+ /* Set alpha as opaque. */
+ color = 0xFF000000 | (sb << 16) | (sg << 8) | sr;
+
+ *dstptr++ = color;
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, srcrowskip);
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized replacing blitter for RGBX8888 to RGB888. */
+static void
+grub_video_fbblit_replace_RGB888_RGBX8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ grub_uint32_t color;
+ int i;
+ int j;
+ grub_uint32_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int sr;
+ unsigned int sg;
+ unsigned int sb;
+ grub_size_t srcrowskip;
+ grub_size_t dstrowskip;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+ srcrowskip = src->mode_info->pitch - 4 * width;
+ dstrowskip = dst->mode_info->pitch - 3 * width;
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ color = *srcptr++;
+
+ sr = (color >> 0) & 0xFF;
+ sg = (color >> 8) & 0xFF;
+ sb = (color >> 16) & 0xFF;
+
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ *dstptr++ = sr;
+ *dstptr++ = sg;
+ *dstptr++ = sb;
+#else
+ *dstptr++ = sb;
+ *dstptr++ = sg;
+ *dstptr++ = sr;
+#endif
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, srcrowskip);
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized replacing blitter for RGBX8888 to indexed color. */
+static void
+grub_video_fbblit_replace_index_RGBX8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ grub_uint32_t color;
+ int i;
+ int j;
+ grub_uint32_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int sr;
+ unsigned int sg;
+ unsigned int sb;
+ grub_size_t srcrowskip;
+ grub_size_t dstrowskip;
+
+ srcrowskip = src->mode_info->pitch - 4 * width;
+ dstrowskip = dst->mode_info->pitch - width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ color = *srcptr++;
+
+ sr = (color >> 0) & 0xFF;
+ sg = (color >> 8) & 0xFF;
+ sb = (color >> 16) & 0xFF;
+
+ color = grub_video_fb_map_rgb(sr, sg, sb);
+ *dstptr++ = color & 0xFF;
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, srcrowskip);
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized replacing blitter for RGB888 to indexed color. */
+static void
+grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ grub_uint32_t color;
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int sr;
+ unsigned int sg;
+ unsigned int sb;
+ grub_size_t srcrowskip;
+ grub_size_t dstrowskip;
+
+ srcrowskip = src->mode_info->pitch - 3 * width;
+ dstrowskip = dst->mode_info->pitch - width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ sr = *srcptr++;
+ sg = *srcptr++;
+ sb = *srcptr++;
+#else
+ sb = *srcptr++;
+ sg = *srcptr++;
+ sr = *srcptr++;
+#endif
+
+ color = grub_video_fb_map_rgb(sr, sg, sb);
+
+ *dstptr++ = color & 0xFF;
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, srcrowskip);
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+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,
+ struct grub_video_fbblit_info *src,
+ int x, int y, int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ grub_uint8_t src_red;
+ grub_uint8_t src_green;
+ grub_uint8_t src_blue;
+ grub_uint8_t src_alpha;
+ grub_uint8_t dst_red;
+ grub_uint8_t dst_green;
+ grub_uint8_t dst_blue;
+ grub_uint8_t dst_alpha;
+ grub_video_color_t src_color;
+ grub_video_color_t dst_color;
+
+ src_color = get_pixel (src, i + offset_x, j + offset_y);
+ grub_video_fb_unmap_color_int (src, src_color, &src_red, &src_green,
+ &src_blue, &src_alpha);
+
+ if (src_alpha == 0)
+ continue;
+
+ if (src_alpha == 255)
+ {
+ dst_color = grub_video_fb_map_rgba (src_red, src_green,
+ src_blue, src_alpha);
+ set_pixel (dst, x + i, y + j, dst_color);
+ continue;
+ }
+
+ dst_color = get_pixel (dst, x + i, y + j);
+
+ grub_video_fb_unmap_color_int (dst, dst_color, &dst_red,
+ &dst_green, &dst_blue, &dst_alpha);
+
+ 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,
+ dst_alpha);
+
+ set_pixel (dst, x + i, y + j, dst_color);
+ }
+ }
+}
+
+/* Optimized blending blitter for RGBA8888 to BGRA8888. */
+static void
+grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ grub_uint32_t *srcptr;
+ grub_uint32_t *dstptr;
+ unsigned int srcrowskip;
+ unsigned int dstrowskip;
+ int i;
+ int j;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ grub_uint32_t color;
+ unsigned int sr;
+ unsigned int sg;
+ unsigned int sb;
+ unsigned int a;
+ unsigned int dr;
+ unsigned int dg;
+ unsigned int db;
+
+ color = *srcptr++;
+
+ a = color >> 24;
+
+ if (a == 0)
+ {
+ /* Skip transparent source pixels. */
+ dstptr++;
+ continue;
+ }
+
+ sr = (color >> 0) & 0xFF;
+ sg = (color >> 8) & 0xFF;
+ sb = (color >> 16) & 0xFF;
+
+ if (a == 255)
+ {
+ /* Opaque pixel shortcut. */
+ dr = sr;
+ dg = sg;
+ db = sb;
+ }
+ else
+ {
+ /* General pixel color blending. */
+ color = *dstptr;
+
+ dr = (color >> 16) & 0xFF;
+ dr = alpha_dilute (dr, sr, a);
+ dg = (color >> 8) & 0xFF;
+ dg = alpha_dilute (dg, sg, a);
+ db = (color >> 0) & 0xFF;
+ db = alpha_dilute (db, sb, a);
+ }
+
+ color = (a << 24) | (dr << 16) | (dg << 8) | db;
+
+ *dstptr++ = color;
+ }
+
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, srcrowskip);
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized blending blitter for RGBA8888 to BGR888. */
+static void
+grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ grub_uint32_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int srcrowskip;
+ unsigned int dstrowskip;
+ int i;
+ int j;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ grub_uint32_t color;
+ unsigned int sr;
+ unsigned int sg;
+ unsigned int sb;
+ unsigned int a;
+ unsigned int dr;
+ unsigned int dg;
+ unsigned int db;
+
+ color = *srcptr++;
+
+ a = color >> 24;
+
+ if (a == 0)
+ {
+ /* Skip transparent source pixels. */
+ dstptr += 3;
+ continue;
+ }
+
+ sr = (color >> 0) & 0xFF;
+ sg = (color >> 8) & 0xFF;
+ sb = (color >> 16) & 0xFF;
+
+ if (a == 255)
+ {
+ /* Opaque pixel shortcut. */
+ dr = sr;
+ dg = sg;
+ db = sb;
+ }
+ else
+ {
+ /* General pixel color blending. */
+ color = *dstptr;
+
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ db = dstptr[0];
+ dg = dstptr[1];
+ dr = dstptr[2];
+#else
+ dr = dstptr[0];
+ dg = dstptr[1];
+ db = dstptr[2];
+#endif
+
+ db = alpha_dilute (db, sb, a);
+ dg = alpha_dilute (dg, sg, a);
+ dr = alpha_dilute (dr, sr, a);
+ }
+
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ *dstptr++ = db;
+ *dstptr++ = dg;
+ *dstptr++ = dr;
+#else
+ *dstptr++ = dr;
+ *dstptr++ = dg;
+ *dstptr++ = db;
+#endif
+ }
+
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, srcrowskip);
+ dstptr += dstrowskip;
+ }
+}
+
+/* Optimized blending blitter for RGBA888 to RGBA8888. */
+static void
+grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ grub_uint32_t color;
+ int i;
+ int j;
+ grub_uint32_t *srcptr;
+ grub_uint32_t *dstptr;
+ unsigned int sr;
+ unsigned int sg;
+ unsigned int sb;
+ unsigned int a;
+ unsigned int dr;
+ unsigned int dg;
+ unsigned int db;
+ grub_size_t srcrowskip;
+ grub_size_t dstrowskip;
+
+ srcrowskip = src->mode_info->pitch - 4 * width;
+ dstrowskip = dst->mode_info->pitch - 4 * width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ color = *srcptr++;
+
+ a = color >> 24;
+
+ if (a == 0)
+ {
+ dstptr++;
+ continue;
+ }
+
+ if (a == 255)
+ {
+ *dstptr++ = color;
+ continue;
+ }
+
+ sr = (color >> 0) & 0xFF;
+ sg = (color >> 8) & 0xFF;
+ sb = (color >> 16) & 0xFF;
+
+ color = *dstptr;
+
+ dr = (color >> 0) & 0xFF;
+ dg = (color >> 8) & 0xFF;
+ db = (color >> 16) & 0xFF;
+
+ 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;
+
+ *dstptr++ = color;
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, srcrowskip);
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized blending blitter for RGBA8888 to RGB888. */
+static void
+grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ grub_uint32_t color;
+ int i;
+ int j;
+ grub_uint32_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int sr;
+ unsigned int sg;
+ unsigned int sb;
+ unsigned int a;
+ unsigned int dr;
+ unsigned int dg;
+ unsigned int db;
+ grub_size_t srcrowskip;
+ grub_size_t dstrowskip;
+
+ srcrowskip = src->mode_info->pitch - 4 * width;
+ dstrowskip = dst->mode_info->pitch - 3 * width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ color = *srcptr++;
+
+ a = color >> 24;
+
+ if (a == 0)
+ {
+ dstptr += 3;
+ continue;
+ }
+
+ sr = (color >> 0) & 0xFF;
+ sg = (color >> 8) & 0xFF;
+ sb = (color >> 16) & 0xFF;
+
+ if (a == 255)
+ {
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ *dstptr++ = sr;
+ *dstptr++ = sg;
+ *dstptr++ = sb;
+#else
+ *dstptr++ = sb;
+ *dstptr++ = sg;
+ *dstptr++ = sr;
+#endif
+
+ continue;
+ }
+
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ dr = dstptr[0];
+ dg = dstptr[1];
+ db = dstptr[2];
+#else
+ db = dstptr[0];
+ dg = dstptr[1];
+ dr = dstptr[2];
+#endif
+
+ 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;
+ *dstptr++ = dg;
+ *dstptr++ = db;
+#else
+ *dstptr++ = db;
+ *dstptr++ = dg;
+ *dstptr++ = dr;
+#endif
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, srcrowskip);
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized blending blitter for RGBA8888 to indexed color. */
+static void
+grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ grub_uint32_t color;
+ int i;
+ int j;
+ grub_uint32_t *srcptr;
+ grub_uint8_t *dstptr;
+ unsigned int sr;
+ unsigned int sg;
+ unsigned int sb;
+ unsigned int a;
+ unsigned char dr;
+ unsigned char dg;
+ unsigned char db;
+ unsigned char da;
+ grub_size_t srcrowskip;
+ grub_size_t dstrowskip;
+
+ srcrowskip = src->mode_info->pitch - 4 * width;
+ dstrowskip = dst->mode_info->pitch - width;
+
+ srcptr = grub_video_fb_get_video_ptr (src, offset_x, offset_y);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ color = *srcptr++;
+
+ a = color >> 24;
+
+ if (a == 0)
+ {
+ dstptr++;
+ continue;
+ }
+
+ sr = (color >> 0) & 0xFF;
+ sg = (color >> 8) & 0xFF;
+ sb = (color >> 16) & 0xFF;
+
+ if (a == 255)
+ {
+ color = grub_video_fb_map_rgb(sr, sg, sb);
+ *dstptr++ = color & 0xFF;
+ continue;
+ }
+
+ grub_video_fb_unmap_color_int (dst, *dstptr, &dr, &dg, &db, &da);
+
+ 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);
+
+ *dstptr++ = color & 0xFF;
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (srcptr, srcrowskip);
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized blending blitter for 1-bit to XXXA8888. */
+static void
+grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint32_t *dstptr;
+ grub_uint8_t srcmask;
+ unsigned int dstrowskip;
+ unsigned int srcrowskipbyte, srcrowskipbit;
+ grub_uint32_t fgcolor, bgcolor;
+ int bit_index;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskipbyte = (src->mode_info->width - width) >> 3;
+ srcrowskipbit = (src->mode_info->width - width) & 7;
+
+ bit_index = offset_y * src->mode_info->width + offset_x;
+ srcptr = (grub_uint8_t *) src->data + (bit_index >> 3);
+ srcmask = 1 << (~bit_index & 7);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red,
+ src->mode_info->fg_green,
+ src->mode_info->fg_blue,
+ src->mode_info->fg_alpha);
+
+ bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red,
+ src->mode_info->bg_green,
+ src->mode_info->bg_blue,
+ src->mode_info->bg_alpha);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ grub_uint32_t color;
+ grub_uint8_t a;
+
+ if (*srcptr & srcmask)
+ {
+ color = fgcolor;
+ a = src->mode_info->fg_alpha;
+ }
+ else
+ {
+ color = bgcolor;
+ a = src->mode_info->bg_alpha;
+ }
+
+ if (a == 255)
+ *dstptr = color;
+ else if (a != 0)
+ {
+ grub_uint8_t s1 = (color >> 0) & 0xFF;
+ grub_uint8_t s2 = (color >> 8) & 0xFF;
+ grub_uint8_t s3 = (color >> 16) & 0xFF;
+
+ grub_uint8_t d1 = (*dstptr >> 0) & 0xFF;
+ grub_uint8_t d2 = (*dstptr >> 8) & 0xFF;
+ grub_uint8_t d3 = (*dstptr >> 16) & 0xFF;
+
+ 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;
+ }
+
+ srcmask >>= 1;
+ if (!srcmask)
+ {
+ srcptr++;
+ srcmask = 0x80;
+ }
+
+ dstptr++;
+ }
+
+ srcptr += srcrowskipbyte;
+ if (srcmask >> srcrowskipbit)
+ srcmask >>= srcrowskipbit;
+ else
+ {
+ srcptr++;
+ srcmask <<= 8 - srcrowskipbit;
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* Optimized blending blitter for 1-bit to XXX888. */
+#ifdef GRUB_HAVE_UNALIGNED_ACCESS
+static void
+grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint8_t *dstptr;
+ grub_uint8_t srcmask;
+ unsigned int dstrowskip;
+ unsigned int srcrowskipbyte, srcrowskipbit;
+ grub_uint32_t fgcolor, bgcolor;
+ int bit_index;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskipbyte = (src->mode_info->width - width) >> 3;
+ srcrowskipbit = (src->mode_info->width - width) & 7;
+
+ bit_index = offset_y * src->mode_info->width + offset_x;
+ srcptr = (grub_uint8_t *) src->data + (bit_index >> 3);
+ srcmask = 1 << (~bit_index & 7);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red,
+ src->mode_info->fg_green,
+ src->mode_info->fg_blue,
+ src->mode_info->fg_alpha);
+
+ bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red,
+ src->mode_info->bg_green,
+ src->mode_info->bg_blue,
+ src->mode_info->bg_alpha);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ grub_uint32_t color;
+ grub_uint8_t a;
+ if (*srcptr & srcmask)
+ {
+ color = fgcolor;
+ a = src->mode_info->fg_alpha;
+ }
+ else
+ {
+ color = bgcolor;
+ a = src->mode_info->bg_alpha;
+ }
+
+ if (a == 255)
+ {
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ ((grub_uint8_t *) dstptr)[0] = color & 0xff;
+ ((grub_uint8_t *) dstptr)[1] = (color & 0xff00) >> 8;
+ ((grub_uint8_t *) dstptr)[2] = (color & 0xff0000) >> 16;
+#else
+ ((grub_uint8_t *) dstptr)[2] = color & 0xff;
+ ((grub_uint8_t *) dstptr)[1] = (color & 0xff00) >> 8;
+ ((grub_uint8_t *) dstptr)[0] = (color & 0xff0000) >> 16;
+#endif
+ }
+ else if (a != 0)
+ {
+ grub_uint8_t s1 = (color >> 0) & 0xFF;
+ grub_uint8_t s2 = (color >> 8) & 0xFF;
+ grub_uint8_t s3 = (color >> 16) & 0xFF;
+
+ grub_uint8_t d1 = (*(grub_uint32_t *) dstptr >> 0) & 0xFF;
+ 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] = 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;
+ if (!srcmask)
+ {
+ srcptr++;
+ srcmask = 0x80;
+ }
+
+ dstptr += 3;
+ }
+
+ srcptr += srcrowskipbyte;
+ if (srcmask >> srcrowskipbit)
+ srcmask >>= srcrowskipbit;
+ else
+ {
+ srcptr++;
+ srcmask <<= 8 - srcrowskipbit;
+ }
+ dstptr += dstrowskip;
+ }
+}
+#endif
+
+/* Optimized blending blitter for 1-bit to XXX888. */
+static void
+grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y)
+{
+ int i;
+ int j;
+ grub_uint8_t *srcptr;
+ grub_uint16_t *dstptr;
+ grub_uint8_t srcmask;
+ unsigned int dstrowskip;
+ unsigned int srcrowskipbyte, srcrowskipbit;
+ grub_uint16_t fgcolor, bgcolor;
+ int bit_index;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
+ srcrowskipbyte = (src->mode_info->width - width) >> 3;
+ srcrowskipbit = (src->mode_info->width - width) & 7;
+
+ bit_index = offset_y * src->mode_info->width + offset_x;
+ srcptr = (grub_uint8_t *) src->data + (bit_index >> 3);
+ srcmask = 1 << (~bit_index & 7);
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red,
+ src->mode_info->fg_green,
+ src->mode_info->fg_blue,
+ src->mode_info->fg_alpha);
+
+ bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red,
+ src->mode_info->bg_green,
+ src->mode_info->bg_blue,
+ src->mode_info->bg_alpha);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ grub_uint32_t color;
+ grub_uint8_t a;
+ if (*srcptr & srcmask)
+ {
+ color = fgcolor;
+ a = src->mode_info->fg_alpha;
+ }
+ else
+ {
+ color = bgcolor;
+ a = src->mode_info->bg_alpha;
+ }
+
+ if (a == 255)
+ *dstptr = color;
+ else if (a != 0)
+ {
+ grub_uint8_t s1 = (color >> 0) & 0x1F;
+ grub_uint8_t s2 = (color >> 5) & 0x3F;
+ grub_uint8_t s3 = (color >> 11) & 0x1F;
+
+ grub_uint8_t d1 = (*dstptr >> 0) & 0x1F;
+ grub_uint8_t d2 = (*dstptr >> 5) & 0x3F;
+ grub_uint8_t d3 = (*dstptr >> 11) & 0x1F;
+
+ 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);
+ }
+
+ srcmask >>= 1;
+ if (!srcmask)
+ {
+ srcptr++;
+ srcmask = 0x80;
+ }
+
+ dstptr++;
+ }
+
+ srcptr += srcrowskipbyte;
+ if (srcmask >> srcrowskipbit)
+ srcmask >>= srcrowskipbit;
+ else
+ {
+ srcptr++;
+ srcmask <<= 8 - srcrowskipbit;
+ }
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
+ }
+}
+
+/* NOTE: This function assumes that given coordinates are within bounds of
+ handled data. */
+void
+grub_video_fb_dispatch_blit (struct grub_video_fbblit_info *target,
+ struct grub_video_fbblit_info *source,
+ enum grub_video_blit_operators oper, int x, int y,
+ unsigned int width, unsigned int height,
+ int offset_x, int offset_y)
+{
+ if (oper == GRUB_VIDEO_BLIT_REPLACE)
+ {
+ /* Try to figure out more optimized version for replace operator. */
+ switch (source->mode_info->blit_format)
+ {
+ case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
+ switch (target->mode_info->blit_format)
+ {
+ case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
+ grub_video_fbblit_replace_directN (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
+ grub_video_fbblit_replace_BGRX8888_RGBX8888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
+ grub_video_fbblit_replace_BGR888_RGBX8888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
+ grub_video_fbblit_replace_RGB888_RGBX8888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
+ grub_video_fbblit_replace_index_RGBX8888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ default:
+ break;
+ }
+ break;
+ case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
+ switch (target->mode_info->blit_format)
+ {
+ case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
+ grub_video_fbblit_replace_BGRX8888_RGB888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
+ grub_video_fbblit_replace_RGBX8888_RGB888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
+ grub_video_fbblit_replace_BGR888_RGB888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
+ grub_video_fbblit_replace_directN (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
+ grub_video_fbblit_replace_index_RGB888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ default:
+ break;
+ }
+ break;
+ case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
+ switch (target->mode_info->blit_format)
+ {
+ case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
+ grub_video_fbblit_replace_directN (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ default:
+ break;
+ }
+ break;
+ case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
+ switch (target->mode_info->blit_format)
+ {
+ case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
+ case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR_ALPHA:
+ grub_video_fbblit_replace_directN (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ default:
+ break;
+ }
+ break;
+ case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR_ALPHA:
+ switch (target->mode_info->bytes_per_pixel)
+ {
+ case 4:
+ grub_video_fbblit_replace_32bit_indexa (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case 3:
+ grub_video_fbblit_replace_24bit_indexa (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case 2:
+ grub_video_fbblit_replace_16bit_indexa (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case 1:
+ grub_video_fbblit_replace_8bit_indexa (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ default:
+ break;
+ }
+ break;
+ case GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED:
+ switch (target->mode_info->bytes_per_pixel)
+ {
+ case 4:
+ grub_video_fbblit_replace_32bit_1bit (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+#ifdef GRUB_HAVE_UNALIGNED_ACCESS
+ case 3:
+ grub_video_fbblit_replace_24bit_1bit (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+#endif
+ case 2:
+ grub_video_fbblit_replace_16bit_1bit (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case 1:
+ grub_video_fbblit_replace_8bit_1bit (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+
+ /* No optimized replace operator found, use default (slow) blitter. */
+ grub_video_fbblit_replace (target, source, x, y, width, height,
+ offset_x, offset_y);
+ }
+ else
+ {
+ /* Try to figure out more optimized blend operator. */
+ switch (source->mode_info->blit_format)
+ {
+ case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
+ switch (target->mode_info->blit_format)
+ {
+ case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
+ grub_video_fbblit_blend_BGRA8888_RGBA8888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
+ grub_video_fbblit_blend_RGBA8888_RGBA8888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
+ grub_video_fbblit_blend_BGR888_RGBA8888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
+ grub_video_fbblit_blend_RGB888_RGBA8888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
+ grub_video_fbblit_blend_index_RGBA8888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ default:
+ break;
+ }
+ break;
+ case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
+ /* Note: There is really no alpha information here, so blend is
+ changed to replace. */
+
+ switch (target->mode_info->blit_format)
+ {
+ case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
+ grub_video_fbblit_replace_BGRX8888_RGB888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
+ grub_video_fbblit_replace_RGBX8888_RGB888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
+ grub_video_fbblit_replace_BGR888_RGB888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
+ grub_video_fbblit_replace_directN (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
+ grub_video_fbblit_replace_index_RGB888 (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ default:
+ break;
+ }
+ break;
+ case GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED:
+ switch (target->mode_info->blit_format)
+ {
+ case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
+ case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
+ grub_video_fbblit_blend_XXXA8888_1bit (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+#ifdef GRUB_HAVE_UNALIGNED_ACCESS
+ case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
+ case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
+ grub_video_fbblit_blend_XXX888_1bit (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+#endif
+ case GRUB_VIDEO_BLIT_FORMAT_BGR_565:
+ case GRUB_VIDEO_BLIT_FORMAT_RGB_565:
+ grub_video_fbblit_blend_XXX565_1bit (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ default:
+ break;
+ }
+ break;
+ case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR_ALPHA:
+ switch (target->mode_info->bytes_per_pixel)
+ {
+ case 4:
+ grub_video_fbblit_blend_32bit_indexa (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case 3:
+ grub_video_fbblit_blend_24bit_indexa (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case 2:
+ grub_video_fbblit_blend_16bit_indexa (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ case 1:
+ grub_video_fbblit_blend_8bit_indexa (target, source,
+ x, y, width, height,
+ offset_x, offset_y);
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+
+ /* No optimized blend operation found, use default (slow) blitter. */
+ grub_video_fbblit_blend (target, source, x, y, width, height,
+ offset_x, offset_y);
+ }
+}
diff --git a/grub-core/video/fb/fbfill.c b/grub-core/video/fb/fbfill.c
new file mode 100644
index 0000000..49fa16b
--- /dev/null
+++ b/grub-core/video/fb/fbfill.c
@@ -0,0 +1,212 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* SPECIAL NOTES!
+
+ Please note following when reading the code below:
+
+ - In this driver we assume that every memory can be accessed by same memory
+ bus. If there are different address spaces do not use this code as a base
+ code for other archs.
+
+ - Every function in this code assumes that bounds checking has been done in
+ previous phase and they are opted out in here. */
+
+#include <grub/video_fb.h>
+#include <grub/fbfill.h>
+#include <grub/fbutil.h>
+#include <grub/types.h>
+#include <grub/safemath.h>
+#include <grub/video.h>
+
+/* Generic filler that works for every supported mode. */
+static void
+grub_video_fbfill (struct grub_video_fbblit_info *dst,
+ grub_video_color_t color, int x, int y,
+ unsigned int width, unsigned int height)
+{
+ unsigned int i, j;
+
+ for (j = 0; j < height; j++)
+ for (i = 0; i < width; i++)
+ set_pixel (dst, x + i, y + j, color);
+}
+
+/* Optimized filler for direct color 32 bit modes. It is assumed that color
+ is already mapped to destination format. */
+static void
+grub_video_fbfill_direct32 (struct grub_video_fbblit_info *dst,
+ grub_video_color_t color, int x, int y,
+ unsigned int width, unsigned int height)
+{
+ unsigned int i, j;
+ grub_uint32_t *dstptr;
+ grub_size_t rowskip;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
+ return;
+
+ /* Get the start address. */
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ *dstptr++ = color;
+
+ /* Advance the dest pointer to the right location on the next line. */
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, rowskip);
+ }
+}
+
+/* Optimized filler for direct color 24 bit modes. It is assumed that color
+ is already mapped to destination format. */
+static void
+grub_video_fbfill_direct24 (struct grub_video_fbblit_info *dst,
+ grub_video_color_t color, int x, int y,
+ unsigned int width, unsigned int height)
+{
+ unsigned int i, j;
+ grub_size_t rowskip;
+ grub_uint8_t *dstptr;
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ grub_uint8_t fill0 = (grub_uint8_t)((color >> 0) & 0xFF);
+ grub_uint8_t fill1 = (grub_uint8_t)((color >> 8) & 0xFF);
+ grub_uint8_t fill2 = (grub_uint8_t)((color >> 16) & 0xFF);
+#else
+ grub_uint8_t fill2 = (grub_uint8_t)((color >> 0) & 0xFF);
+ grub_uint8_t fill1 = (grub_uint8_t)((color >> 8) & 0xFF);
+ grub_uint8_t fill0 = (grub_uint8_t)((color >> 16) & 0xFF);
+#endif
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
+ return;
+
+ /* Get the start address. */
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ *dstptr++ = fill0;
+ *dstptr++ = fill1;
+ *dstptr++ = fill2;
+ }
+
+ /* Advance the dest pointer to the right location on the next line. */
+ dstptr += rowskip;
+ }
+}
+
+/* Optimized filler for direct color 16 bit modes. It is assumed that color
+ is already mapped to destination format. */
+static void
+grub_video_fbfill_direct16 (struct grub_video_fbblit_info *dst,
+ grub_video_color_t color, int x, int y,
+ unsigned int width, unsigned int height)
+{
+ unsigned int i, j;
+ grub_size_t rowskip;
+ grub_uint16_t *dstptr;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
+ return;
+
+ /* Get the start address. */
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ *dstptr++ = color;
+
+ /* Advance the dest pointer to the right location on the next line. */
+ GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, rowskip);
+ }
+}
+
+/* Optimized filler for index color. It is assumed that color
+ is already mapped to destination format. */
+static void
+grub_video_fbfill_direct8 (struct grub_video_fbblit_info *dst,
+ grub_video_color_t color, int x, int y,
+ unsigned int width, unsigned int height)
+{
+ unsigned int i, j;
+ grub_size_t rowskip;
+ grub_uint8_t *dstptr;
+ grub_uint8_t fill = (grub_uint8_t)color & 0xFF;
+
+ /* Calculate the number of bytes to advance from the end of one line
+ to the beginning of the next line. */
+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
+ return;
+
+ /* Get the start address. */
+ dstptr = grub_video_fb_get_video_ptr (dst, x, y);
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ *dstptr++ = fill;
+
+ /* Advance the dest pointer to the right location on the next line. */
+ dstptr += rowskip;
+ }
+}
+
+void
+grub_video_fb_fill_dispatch (struct grub_video_fbblit_info *target,
+ grub_video_color_t color, int x, int y,
+ unsigned int width, unsigned int height)
+{
+ /* Try to figure out more optimized version. Note that color is already
+ mapped to target format so we can make assumptions based on that. */
+ switch (target->mode_info->bytes_per_pixel)
+ {
+ case 4:
+ grub_video_fbfill_direct32 (target, color, x, y,
+ width, height);
+ return;
+ case 3:
+ grub_video_fbfill_direct24 (target, color, x, y,
+ width, height);
+ return;
+ case 2:
+ grub_video_fbfill_direct16 (target, color, x, y,
+ width, height);
+ return;
+ case 1:
+ grub_video_fbfill_direct8 (target, color, x, y,
+ width, height);
+ return;
+ }
+
+ /* No optimized version found, use default (slow) filler. */
+ grub_video_fbfill (target, color, x, y, width, height);
+}
diff --git a/grub-core/video/fb/fbutil.c b/grub-core/video/fb/fbutil.c
new file mode 100644
index 0000000..b98bb51
--- /dev/null
+++ b/grub-core/video/fb/fbutil.c
@@ -0,0 +1,151 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* SPECIAL NOTES!
+
+ Please note following when reading the code below:
+
+ - In this driver we assume that every memory can be accessed by same memory
+ bus. If there are different address spaces do not use this code as a base
+ code for other archs.
+
+ - Every function in this code assumes that bounds checking has been done in
+ previous phase and they are opted out in here. */
+
+#include <grub/fbutil.h>
+#include <grub/types.h>
+#include <grub/video.h>
+
+grub_video_color_t
+get_pixel (struct grub_video_fbblit_info *source,
+ unsigned int x, unsigned int y)
+{
+ grub_video_color_t color = 0;
+
+ switch (source->mode_info->bpp)
+ {
+ case 32:
+ color = *(grub_uint32_t *)grub_video_fb_get_video_ptr (source, x, y);
+ break;
+
+ case 24:
+ {
+ grub_uint8_t *ptr;
+ ptr = grub_video_fb_get_video_ptr (source, x, y);
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ color = ptr[2] | (ptr[1] << 8) | (ptr[0] << 16);
+#else
+ color = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16);
+#endif
+ }
+ break;
+
+ case 16:
+ case 15:
+ color = *(grub_uint16_t *)grub_video_fb_get_video_ptr (source, x, y);
+ break;
+
+ case 8:
+ color = *(grub_uint8_t *)grub_video_fb_get_video_ptr (source, x, y);
+ break;
+
+ case 1:
+ if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED)
+ {
+ int bit_index = y * source->mode_info->width + x;
+ grub_uint8_t *ptr = source->data + bit_index / 8;
+ int bit_pos = 7 - bit_index % 8;
+ color = (*ptr >> bit_pos) & 0x01;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return color;
+}
+
+void
+set_pixel (struct grub_video_fbblit_info *source,
+ unsigned int x, unsigned int y, grub_video_color_t color)
+{
+ switch (source->mode_info->bpp)
+ {
+ case 32:
+ {
+ grub_uint32_t *ptr;
+
+ ptr = (grub_uint32_t *)grub_video_fb_get_video_ptr (source, x, y);
+
+ *ptr = color;
+ }
+ break;
+
+ case 24:
+ {
+ grub_uint8_t *ptr;
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ grub_uint8_t *colorptr = ((grub_uint8_t *)&color) + 1;
+#else
+ grub_uint8_t *colorptr = (grub_uint8_t *)&color;
+#endif
+
+ ptr = grub_video_fb_get_video_ptr (source, x, y);
+
+ ptr[0] = colorptr[0];
+ ptr[1] = colorptr[1];
+ ptr[2] = colorptr[2];
+ }
+ break;
+
+ case 16:
+ case 15:
+ {
+ grub_uint16_t *ptr;
+
+ ptr = (grub_uint16_t *)grub_video_fb_get_video_ptr (source, x, y);
+
+ *ptr = (grub_uint16_t) (color & 0xFFFF);
+ }
+ break;
+
+ case 8:
+ {
+ grub_uint8_t *ptr;
+
+ ptr = (grub_uint8_t *)grub_video_fb_get_video_ptr (source, x, y);
+
+ *ptr = (grub_uint8_t) (color & 0xFF);
+ }
+ break;
+
+ case 1:
+ if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED)
+ {
+ int bit_index = y * source->mode_info->width + x;
+ grub_uint8_t *ptr = source->data + bit_index / 8;
+ int bit_pos = 7 - bit_index % 8;
+ *ptr = (*ptr & ~(1 << bit_pos)) | ((color & 0x01) << bit_pos);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
diff --git a/grub-core/video/fb/video_fb.c b/grub-core/video/fb/video_fb.c
new file mode 100644
index 0000000..ae6b89f
--- /dev/null
+++ b/grub-core/video/fb/video_fb.c
@@ -0,0 +1,1709 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/fbblit.h>
+#include <grub/fbfill.h>
+#include <grub/fbutil.h>
+#include <grub/bitmap.h>
+#include <grub/dl.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+typedef grub_err_t (*grub_video_fb_doublebuf_update_screen_t) (void);
+typedef volatile void *framebuf_t;
+
+struct dirty
+{
+ int first_line;
+ int last_line;
+};
+
+static struct
+{
+ struct grub_video_fbrender_target *render_target;
+ struct grub_video_fbrender_target *back_target;
+ struct grub_video_palette_data *palette;
+ framebuf_t pages[2];
+
+ unsigned int palette_size;
+
+ struct dirty current_dirty;
+ struct dirty previous_dirty;
+
+ /* For page flipping strategy. */
+ int displayed_page; /* The page # that is the front buffer. */
+ int render_page; /* The page # that is the back buffer. */
+ grub_video_fb_set_page_t set_page;
+ char *offscreen_buffer;
+ grub_video_fb_doublebuf_update_screen_t update_screen;
+} framebuffer;
+
+/* Specify "standard" VGA palette, some video cards may
+ need this and this will also be used when using RGB modes. */
+struct grub_video_palette_data grub_video_fbstd_colors[GRUB_VIDEO_FBSTD_EXT_NUMCOLORS] =
+ {
+ /* Standard (3-bit) colors. */
+
+ // {R, G, B, A}
+ {0x00, 0x00, 0x00, 0xFF}, // 0 = black
+ {0x00, 0x00, 0xA8, 0xFF}, // 1 = blue
+ {0x00, 0xA8, 0x00, 0xFF}, // 2 = green
+ {0x00, 0xA8, 0xA8, 0xFF}, // 3 = cyan
+ {0xA8, 0x00, 0x00, 0xFF}, // 4 = red
+ {0xA8, 0x00, 0xA8, 0xFF}, // 5 = magenta
+ {0xA8, 0x54, 0x00, 0xFF}, // 6 = brown
+ {0xA8, 0xA8, 0xA8, 0xFF}, // 7 = light gray
+
+ /* Bright (4-bit) colors. */
+ {0x54, 0x54, 0x54, 0xFF}, // 8 = dark gray
+ {0x54, 0x54, 0xFE, 0xFF}, // 9 = bright blue
+ {0x54, 0xFE, 0x54, 0xFF}, // 10 = bright green
+ {0x54, 0xFE, 0xFE, 0xFF}, // 11 = bright cyan
+ {0xFE, 0x54, 0x54, 0xFF}, // 12 = bright red
+ {0xFE, 0x54, 0xFE, 0xFF}, // 13 = bright magenta
+ {0xFE, 0xFE, 0x54, 0xFF}, // 14 = yellow
+ {0xFE, 0xFE, 0xFE, 0xFF}, // 15 = white
+
+ /* Extended (8-bit) colors. Completes preceding colors to full RGB332. */
+ {0x00, 0x00, 0x55, 0xFF}, // RGB332 = (0, 0, 1)
+ {0x00, 0x00, 0xFF, 0xFF}, // RGB332 = (0, 0, 3)
+ {0x00, 0x24, 0x00, 0xFF}, // RGB332 = (0, 1, 0)
+ {0x00, 0x24, 0x55, 0xFF}, // RGB332 = (0, 1, 1)
+ {0x00, 0x24, 0xAA, 0xFF}, // RGB332 = (0, 1, 2)
+ {0x00, 0x24, 0xFF, 0xFF}, // RGB332 = (0, 1, 3)
+ {0x00, 0x48, 0x00, 0xFF}, // RGB332 = (0, 2, 0)
+ {0x00, 0x48, 0x55, 0xFF}, // RGB332 = (0, 2, 1)
+ {0x00, 0x48, 0xAA, 0xFF}, // RGB332 = (0, 2, 2)
+ {0x00, 0x48, 0xFF, 0xFF}, // RGB332 = (0, 2, 3)
+ {0x00, 0x6C, 0x00, 0xFF}, // RGB332 = (0, 3, 0)
+ {0x00, 0x6C, 0x55, 0xFF}, // RGB332 = (0, 3, 1)
+ {0x00, 0x6C, 0xAA, 0xFF}, // RGB332 = (0, 3, 2)
+ {0x00, 0x6C, 0xFF, 0xFF}, // RGB332 = (0, 3, 3)
+ {0x00, 0x90, 0x00, 0xFF}, // RGB332 = (0, 4, 0)
+ {0x00, 0x90, 0x55, 0xFF}, // RGB332 = (0, 4, 1)
+ {0x00, 0x90, 0xAA, 0xFF}, // RGB332 = (0, 4, 2)
+ {0x00, 0x90, 0xFF, 0xFF}, // RGB332 = (0, 4, 3)
+ {0x00, 0xB4, 0x55, 0xFF}, // RGB332 = (0, 5, 1)
+ {0x00, 0xB4, 0xFF, 0xFF}, // RGB332 = (0, 5, 3)
+ {0x00, 0xD8, 0x00, 0xFF}, // RGB332 = (0, 6, 0)
+ {0x00, 0xD8, 0x55, 0xFF}, // RGB332 = (0, 6, 1)
+ {0x00, 0xD8, 0xAA, 0xFF}, // RGB332 = (0, 6, 2)
+ {0x00, 0xD8, 0xFF, 0xFF}, // RGB332 = (0, 6, 3)
+ {0x00, 0xFC, 0x00, 0xFF}, // RGB332 = (0, 7, 0)
+ {0x00, 0xFC, 0x55, 0xFF}, // RGB332 = (0, 7, 1)
+ {0x00, 0xFC, 0xAA, 0xFF}, // RGB332 = (0, 7, 2)
+ {0x00, 0xFC, 0xFF, 0xFF}, // RGB332 = (0, 7, 3)
+ {0x24, 0x00, 0x00, 0xFF}, // RGB332 = (1, 0, 0)
+ {0x24, 0x00, 0x55, 0xFF}, // RGB332 = (1, 0, 1)
+ {0x24, 0x00, 0xAA, 0xFF}, // RGB332 = (1, 0, 2)
+ {0x24, 0x00, 0xFF, 0xFF}, // RGB332 = (1, 0, 3)
+ {0x24, 0x24, 0x00, 0xFF}, // RGB332 = (1, 1, 0)
+ {0x24, 0x24, 0x55, 0xFF}, // RGB332 = (1, 1, 1)
+ {0x24, 0x24, 0xAA, 0xFF}, // RGB332 = (1, 1, 2)
+ {0x24, 0x24, 0xFF, 0xFF}, // RGB332 = (1, 1, 3)
+ {0x24, 0x48, 0x00, 0xFF}, // RGB332 = (1, 2, 0)
+ {0x24, 0x48, 0x55, 0xFF}, // RGB332 = (1, 2, 1)
+ {0x24, 0x48, 0xAA, 0xFF}, // RGB332 = (1, 2, 2)
+ {0x24, 0x48, 0xFF, 0xFF}, // RGB332 = (1, 2, 3)
+ {0x24, 0x6C, 0x00, 0xFF}, // RGB332 = (1, 3, 0)
+ {0x24, 0x6C, 0x55, 0xFF}, // RGB332 = (1, 3, 1)
+ {0x24, 0x6C, 0xAA, 0xFF}, // RGB332 = (1, 3, 2)
+ {0x24, 0x6C, 0xFF, 0xFF}, // RGB332 = (1, 3, 3)
+ {0x24, 0x90, 0x00, 0xFF}, // RGB332 = (1, 4, 0)
+ {0x24, 0x90, 0x55, 0xFF}, // RGB332 = (1, 4, 1)
+ {0x24, 0x90, 0xAA, 0xFF}, // RGB332 = (1, 4, 2)
+ {0x24, 0x90, 0xFF, 0xFF}, // RGB332 = (1, 4, 3)
+ {0x24, 0xB4, 0x00, 0xFF}, // RGB332 = (1, 5, 0)
+ {0x24, 0xB4, 0x55, 0xFF}, // RGB332 = (1, 5, 1)
+ {0x24, 0xB4, 0xAA, 0xFF}, // RGB332 = (1, 5, 2)
+ {0x24, 0xB4, 0xFF, 0xFF}, // RGB332 = (1, 5, 3)
+ {0x24, 0xD8, 0x00, 0xFF}, // RGB332 = (1, 6, 0)
+ {0x24, 0xD8, 0x55, 0xFF}, // RGB332 = (1, 6, 1)
+ {0x24, 0xD8, 0xAA, 0xFF}, // RGB332 = (1, 6, 2)
+ {0x24, 0xD8, 0xFF, 0xFF}, // RGB332 = (1, 6, 3)
+ {0x24, 0xFC, 0x00, 0xFF}, // RGB332 = (1, 7, 0)
+ {0x24, 0xFC, 0x55, 0xFF}, // RGB332 = (1, 7, 1)
+ {0x24, 0xFC, 0xAA, 0xFF}, // RGB332 = (1, 7, 2)
+ {0x24, 0xFC, 0xFF, 0xFF}, // RGB332 = (1, 7, 3)
+ {0x48, 0x00, 0x00, 0xFF}, // RGB332 = (2, 0, 0)
+ {0x48, 0x00, 0x55, 0xFF}, // RGB332 = (2, 0, 1)
+ {0x48, 0x00, 0xAA, 0xFF}, // RGB332 = (2, 0, 2)
+ {0x48, 0x00, 0xFF, 0xFF}, // RGB332 = (2, 0, 3)
+ {0x48, 0x24, 0x00, 0xFF}, // RGB332 = (2, 1, 0)
+ {0x48, 0x24, 0x55, 0xFF}, // RGB332 = (2, 1, 1)
+ {0x48, 0x24, 0xAA, 0xFF}, // RGB332 = (2, 1, 2)
+ {0x48, 0x24, 0xFF, 0xFF}, // RGB332 = (2, 1, 3)
+ {0x48, 0x48, 0x00, 0xFF}, // RGB332 = (2, 2, 0)
+ {0x48, 0x48, 0xAA, 0xFF}, // RGB332 = (2, 2, 2)
+ {0x48, 0x6C, 0x00, 0xFF}, // RGB332 = (2, 3, 0)
+ {0x48, 0x6C, 0x55, 0xFF}, // RGB332 = (2, 3, 1)
+ {0x48, 0x6C, 0xAA, 0xFF}, // RGB332 = (2, 3, 2)
+ {0x48, 0x6C, 0xFF, 0xFF}, // RGB332 = (2, 3, 3)
+ {0x48, 0x90, 0x00, 0xFF}, // RGB332 = (2, 4, 0)
+ {0x48, 0x90, 0x55, 0xFF}, // RGB332 = (2, 4, 1)
+ {0x48, 0x90, 0xAA, 0xFF}, // RGB332 = (2, 4, 2)
+ {0x48, 0x90, 0xFF, 0xFF}, // RGB332 = (2, 4, 3)
+ {0x48, 0xB4, 0x00, 0xFF}, // RGB332 = (2, 5, 0)
+ {0x48, 0xB4, 0x55, 0xFF}, // RGB332 = (2, 5, 1)
+ {0x48, 0xB4, 0xAA, 0xFF}, // RGB332 = (2, 5, 2)
+ {0x48, 0xB4, 0xFF, 0xFF}, // RGB332 = (2, 5, 3)
+ {0x48, 0xD8, 0x00, 0xFF}, // RGB332 = (2, 6, 0)
+ {0x48, 0xD8, 0x55, 0xFF}, // RGB332 = (2, 6, 1)
+ {0x48, 0xD8, 0xAA, 0xFF}, // RGB332 = (2, 6, 2)
+ {0x48, 0xD8, 0xFF, 0xFF}, // RGB332 = (2, 6, 3)
+ {0x48, 0xFC, 0x00, 0xFF}, // RGB332 = (2, 7, 0)
+ {0x48, 0xFC, 0xAA, 0xFF}, // RGB332 = (2, 7, 2)
+ {0x6C, 0x00, 0x00, 0xFF}, // RGB332 = (3, 0, 0)
+ {0x6C, 0x00, 0x55, 0xFF}, // RGB332 = (3, 0, 1)
+ {0x6C, 0x00, 0xAA, 0xFF}, // RGB332 = (3, 0, 2)
+ {0x6C, 0x00, 0xFF, 0xFF}, // RGB332 = (3, 0, 3)
+ {0x6C, 0x24, 0x00, 0xFF}, // RGB332 = (3, 1, 0)
+ {0x6C, 0x24, 0x55, 0xFF}, // RGB332 = (3, 1, 1)
+ {0x6C, 0x24, 0xAA, 0xFF}, // RGB332 = (3, 1, 2)
+ {0x6C, 0x24, 0xFF, 0xFF}, // RGB332 = (3, 1, 3)
+ {0x6C, 0x48, 0x00, 0xFF}, // RGB332 = (3, 2, 0)
+ {0x6C, 0x48, 0x55, 0xFF}, // RGB332 = (3, 2, 1)
+ {0x6C, 0x48, 0xAA, 0xFF}, // RGB332 = (3, 2, 2)
+ {0x6C, 0x48, 0xFF, 0xFF}, // RGB332 = (3, 2, 3)
+ {0x6C, 0x6C, 0x00, 0xFF}, // RGB332 = (3, 3, 0)
+ {0x6C, 0x6C, 0x55, 0xFF}, // RGB332 = (3, 3, 1)
+ {0x6C, 0x6C, 0xAA, 0xFF}, // RGB332 = (3, 3, 2)
+ {0x6C, 0x6C, 0xFF, 0xFF}, // RGB332 = (3, 3, 3)
+ {0x6C, 0x90, 0x00, 0xFF}, // RGB332 = (3, 4, 0)
+ {0x6C, 0x90, 0x55, 0xFF}, // RGB332 = (3, 4, 1)
+ {0x6C, 0x90, 0xAA, 0xFF}, // RGB332 = (3, 4, 2)
+ {0x6C, 0x90, 0xFF, 0xFF}, // RGB332 = (3, 4, 3)
+ {0x6C, 0xB4, 0x00, 0xFF}, // RGB332 = (3, 5, 0)
+ {0x6C, 0xB4, 0x55, 0xFF}, // RGB332 = (3, 5, 1)
+ {0x6C, 0xB4, 0xAA, 0xFF}, // RGB332 = (3, 5, 2)
+ {0x6C, 0xB4, 0xFF, 0xFF}, // RGB332 = (3, 5, 3)
+ {0x6C, 0xD8, 0x00, 0xFF}, // RGB332 = (3, 6, 0)
+ {0x6C, 0xD8, 0x55, 0xFF}, // RGB332 = (3, 6, 1)
+ {0x6C, 0xD8, 0xAA, 0xFF}, // RGB332 = (3, 6, 2)
+ {0x6C, 0xD8, 0xFF, 0xFF}, // RGB332 = (3, 6, 3)
+ {0x6C, 0xFC, 0x00, 0xFF}, // RGB332 = (3, 7, 0)
+ {0x6C, 0xFC, 0x55, 0xFF}, // RGB332 = (3, 7, 1)
+ {0x6C, 0xFC, 0xAA, 0xFF}, // RGB332 = (3, 7, 2)
+ {0x6C, 0xFC, 0xFF, 0xFF}, // RGB332 = (3, 7, 3)
+ {0x90, 0x00, 0x00, 0xFF}, // RGB332 = (4, 0, 0)
+ {0x90, 0x00, 0x55, 0xFF}, // RGB332 = (4, 0, 1)
+ {0x90, 0x00, 0xAA, 0xFF}, // RGB332 = (4, 0, 2)
+ {0x90, 0x00, 0xFF, 0xFF}, // RGB332 = (4, 0, 3)
+ {0x90, 0x24, 0x00, 0xFF}, // RGB332 = (4, 1, 0)
+ {0x90, 0x24, 0x55, 0xFF}, // RGB332 = (4, 1, 1)
+ {0x90, 0x24, 0xAA, 0xFF}, // RGB332 = (4, 1, 2)
+ {0x90, 0x24, 0xFF, 0xFF}, // RGB332 = (4, 1, 3)
+ {0x90, 0x48, 0x00, 0xFF}, // RGB332 = (4, 2, 0)
+ {0x90, 0x48, 0x55, 0xFF}, // RGB332 = (4, 2, 1)
+ {0x90, 0x48, 0xAA, 0xFF}, // RGB332 = (4, 2, 2)
+ {0x90, 0x48, 0xFF, 0xFF}, // RGB332 = (4, 2, 3)
+ {0x90, 0x6C, 0x00, 0xFF}, // RGB332 = (4, 3, 0)
+ {0x90, 0x6C, 0x55, 0xFF}, // RGB332 = (4, 3, 1)
+ {0x90, 0x6C, 0xAA, 0xFF}, // RGB332 = (4, 3, 2)
+ {0x90, 0x6C, 0xFF, 0xFF}, // RGB332 = (4, 3, 3)
+ {0x90, 0x90, 0x00, 0xFF}, // RGB332 = (4, 4, 0)
+ {0x90, 0x90, 0x55, 0xFF}, // RGB332 = (4, 4, 1)
+ {0x90, 0x90, 0xAA, 0xFF}, // RGB332 = (4, 4, 2)
+ {0x90, 0x90, 0xFF, 0xFF}, // RGB332 = (4, 4, 3)
+ {0x90, 0xB4, 0x00, 0xFF}, // RGB332 = (4, 5, 0)
+ {0x90, 0xB4, 0x55, 0xFF}, // RGB332 = (4, 5, 1)
+ {0x90, 0xB4, 0xAA, 0xFF}, // RGB332 = (4, 5, 2)
+ {0x90, 0xB4, 0xFF, 0xFF}, // RGB332 = (4, 5, 3)
+ {0x90, 0xD8, 0x00, 0xFF}, // RGB332 = (4, 6, 0)
+ {0x90, 0xD8, 0x55, 0xFF}, // RGB332 = (4, 6, 1)
+ {0x90, 0xD8, 0xAA, 0xFF}, // RGB332 = (4, 6, 2)
+ {0x90, 0xD8, 0xFF, 0xFF}, // RGB332 = (4, 6, 3)
+ {0x90, 0xFC, 0x00, 0xFF}, // RGB332 = (4, 7, 0)
+ {0x90, 0xFC, 0x55, 0xFF}, // RGB332 = (4, 7, 1)
+ {0x90, 0xFC, 0xAA, 0xFF}, // RGB332 = (4, 7, 2)
+ {0x90, 0xFC, 0xFF, 0xFF}, // RGB332 = (4, 7, 3)
+ {0xB4, 0x00, 0x55, 0xFF}, // RGB332 = (5, 0, 1)
+ {0xB4, 0x00, 0xFF, 0xFF}, // RGB332 = (5, 0, 3)
+ {0xB4, 0x24, 0x00, 0xFF}, // RGB332 = (5, 1, 0)
+ {0xB4, 0x24, 0x55, 0xFF}, // RGB332 = (5, 1, 1)
+ {0xB4, 0x24, 0xAA, 0xFF}, // RGB332 = (5, 1, 2)
+ {0xB4, 0x24, 0xFF, 0xFF}, // RGB332 = (5, 1, 3)
+ {0xB4, 0x48, 0x55, 0xFF}, // RGB332 = (5, 2, 1)
+ {0xB4, 0x48, 0xAA, 0xFF}, // RGB332 = (5, 2, 2)
+ {0xB4, 0x48, 0xFF, 0xFF}, // RGB332 = (5, 2, 3)
+ {0xB4, 0x6C, 0x00, 0xFF}, // RGB332 = (5, 3, 0)
+ {0xB4, 0x6C, 0x55, 0xFF}, // RGB332 = (5, 3, 1)
+ {0xB4, 0x6C, 0xAA, 0xFF}, // RGB332 = (5, 3, 2)
+ {0xB4, 0x6C, 0xFF, 0xFF}, // RGB332 = (5, 3, 3)
+ {0xB4, 0x90, 0x00, 0xFF}, // RGB332 = (5, 4, 0)
+ {0xB4, 0x90, 0x55, 0xFF}, // RGB332 = (5, 4, 1)
+ {0xB4, 0x90, 0xAA, 0xFF}, // RGB332 = (5, 4, 2)
+ {0xB4, 0x90, 0xFF, 0xFF}, // RGB332 = (5, 4, 3)
+ {0xB4, 0xB4, 0x00, 0xFF}, // RGB332 = (5, 5, 0)
+ {0xB4, 0xB4, 0x55, 0xFF}, // RGB332 = (5, 5, 1)
+ {0xB4, 0xB4, 0xFF, 0xFF}, // RGB332 = (5, 5, 3)
+ {0xB4, 0xD8, 0x00, 0xFF}, // RGB332 = (5, 6, 0)
+ {0xB4, 0xD8, 0x55, 0xFF}, // RGB332 = (5, 6, 1)
+ {0xB4, 0xD8, 0xAA, 0xFF}, // RGB332 = (5, 6, 2)
+ {0xB4, 0xD8, 0xFF, 0xFF}, // RGB332 = (5, 6, 3)
+ {0xB4, 0xFC, 0x00, 0xFF}, // RGB332 = (5, 7, 0)
+ {0xB4, 0xFC, 0x55, 0xFF}, // RGB332 = (5, 7, 1)
+ {0xB4, 0xFC, 0xAA, 0xFF}, // RGB332 = (5, 7, 2)
+ {0xB4, 0xFC, 0xFF, 0xFF}, // RGB332 = (5, 7, 3)
+ {0xD8, 0x00, 0x00, 0xFF}, // RGB332 = (6, 0, 0)
+ {0xD8, 0x00, 0x55, 0xFF}, // RGB332 = (6, 0, 1)
+ {0xD8, 0x00, 0xAA, 0xFF}, // RGB332 = (6, 0, 2)
+ {0xD8, 0x00, 0xFF, 0xFF}, // RGB332 = (6, 0, 3)
+ {0xD8, 0x24, 0x00, 0xFF}, // RGB332 = (6, 1, 0)
+ {0xD8, 0x24, 0x55, 0xFF}, // RGB332 = (6, 1, 1)
+ {0xD8, 0x24, 0xAA, 0xFF}, // RGB332 = (6, 1, 2)
+ {0xD8, 0x24, 0xFF, 0xFF}, // RGB332 = (6, 1, 3)
+ {0xD8, 0x48, 0x00, 0xFF}, // RGB332 = (6, 2, 0)
+ {0xD8, 0x48, 0x55, 0xFF}, // RGB332 = (6, 2, 1)
+ {0xD8, 0x48, 0xAA, 0xFF}, // RGB332 = (6, 2, 2)
+ {0xD8, 0x48, 0xFF, 0xFF}, // RGB332 = (6, 2, 3)
+ {0xD8, 0x6C, 0x00, 0xFF}, // RGB332 = (6, 3, 0)
+ {0xD8, 0x6C, 0x55, 0xFF}, // RGB332 = (6, 3, 1)
+ {0xD8, 0x6C, 0xAA, 0xFF}, // RGB332 = (6, 3, 2)
+ {0xD8, 0x6C, 0xFF, 0xFF}, // RGB332 = (6, 3, 3)
+ {0xD8, 0x90, 0x00, 0xFF}, // RGB332 = (6, 4, 0)
+ {0xD8, 0x90, 0x55, 0xFF}, // RGB332 = (6, 4, 1)
+ {0xD8, 0x90, 0xAA, 0xFF}, // RGB332 = (6, 4, 2)
+ {0xD8, 0x90, 0xFF, 0xFF}, // RGB332 = (6, 4, 3)
+ {0xD8, 0xB4, 0x00, 0xFF}, // RGB332 = (6, 5, 0)
+ {0xD8, 0xB4, 0x55, 0xFF}, // RGB332 = (6, 5, 1)
+ {0xD8, 0xB4, 0xAA, 0xFF}, // RGB332 = (6, 5, 2)
+ {0xD8, 0xB4, 0xFF, 0xFF}, // RGB332 = (6, 5, 3)
+ {0xD8, 0xD8, 0x00, 0xFF}, // RGB332 = (6, 6, 0)
+ {0xD8, 0xD8, 0x55, 0xFF}, // RGB332 = (6, 6, 1)
+ {0xD8, 0xD8, 0xAA, 0xFF}, // RGB332 = (6, 6, 2)
+ {0xD8, 0xD8, 0xFF, 0xFF}, // RGB332 = (6, 6, 3)
+ {0xD8, 0xFC, 0x00, 0xFF}, // RGB332 = (6, 7, 0)
+ {0xD8, 0xFC, 0x55, 0xFF}, // RGB332 = (6, 7, 1)
+ {0xD8, 0xFC, 0xAA, 0xFF}, // RGB332 = (6, 7, 2)
+ {0xD8, 0xFC, 0xFF, 0xFF}, // RGB332 = (6, 7, 3)
+ {0xFC, 0x00, 0x00, 0xFF}, // RGB332 = (7, 0, 0)
+ {0xFC, 0x00, 0x55, 0xFF}, // RGB332 = (7, 0, 1)
+ {0xFC, 0x00, 0xAA, 0xFF}, // RGB332 = (7, 0, 2)
+ {0xFC, 0x00, 0xFF, 0xFF}, // RGB332 = (7, 0, 3)
+ {0xFC, 0x24, 0x00, 0xFF}, // RGB332 = (7, 1, 0)
+ {0xFC, 0x24, 0x55, 0xFF}, // RGB332 = (7, 1, 1)
+ {0xFC, 0x24, 0xAA, 0xFF}, // RGB332 = (7, 1, 2)
+ {0xFC, 0x24, 0xFF, 0xFF}, // RGB332 = (7, 1, 3)
+ {0xFC, 0x48, 0x00, 0xFF}, // RGB332 = (7, 2, 0)
+ {0xFC, 0x48, 0xAA, 0xFF}, // RGB332 = (7, 2, 2)
+ {0xFC, 0x6C, 0x00, 0xFF}, // RGB332 = (7, 3, 0)
+ {0xFC, 0x6C, 0x55, 0xFF}, // RGB332 = (7, 3, 1)
+ {0xFC, 0x6C, 0xAA, 0xFF}, // RGB332 = (7, 3, 2)
+ {0xFC, 0x6C, 0xFF, 0xFF}, // RGB332 = (7, 3, 3)
+ {0xFC, 0x90, 0x00, 0xFF}, // RGB332 = (7, 4, 0)
+ {0xFC, 0x90, 0x55, 0xFF}, // RGB332 = (7, 4, 1)
+ {0xFC, 0x90, 0xAA, 0xFF}, // RGB332 = (7, 4, 2)
+ {0xFC, 0x90, 0xFF, 0xFF}, // RGB332 = (7, 4, 3)
+ {0xFC, 0xB4, 0x00, 0xFF}, // RGB332 = (7, 5, 0)
+ {0xFC, 0xB4, 0x55, 0xFF}, // RGB332 = (7, 5, 1)
+ {0xFC, 0xB4, 0xAA, 0xFF}, // RGB332 = (7, 5, 2)
+ {0xFC, 0xB4, 0xFF, 0xFF}, // RGB332 = (7, 5, 3)
+ {0xFC, 0xD8, 0x00, 0xFF}, // RGB332 = (7, 6, 0)
+ {0xFC, 0xD8, 0x55, 0xFF}, // RGB332 = (7, 6, 1)
+ {0xFC, 0xD8, 0xAA, 0xFF}, // RGB332 = (7, 6, 2)
+ {0xFC, 0xD8, 0xFF, 0xFF}, // RGB332 = (7, 6, 3)
+ {0xFC, 0xFC, 0x00, 0xFF}, // RGB332 = (7, 7, 0)
+ {0xFC, 0xFC, 0xAA, 0xFF}, // RGB332 = (7, 7, 2)
+ };
+
+grub_err_t
+grub_video_fb_init (void)
+{
+ grub_free (framebuffer.palette);
+ framebuffer.render_target = 0;
+ framebuffer.back_target = 0;
+ framebuffer.palette = 0;
+ framebuffer.palette_size = 0;
+ framebuffer.set_page = 0;
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_fini (void)
+{
+ /* TODO: destroy render targets. */
+
+ grub_free (framebuffer.offscreen_buffer);
+ grub_free (framebuffer.palette);
+ framebuffer.render_target = 0;
+ framebuffer.back_target = 0;
+ framebuffer.palette = 0;
+ framebuffer.palette_size = 0;
+ framebuffer.set_page = 0;
+ framebuffer.offscreen_buffer = 0;
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_get_info (struct grub_video_mode_info *mode_info)
+{
+ /* Copy mode info from active render target. */
+ grub_memcpy (mode_info, &framebuffer.render_target->mode_info,
+ sizeof (struct grub_video_mode_info));
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_get_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data)
+{
+ unsigned int i;
+
+ /* Assume that we know everything from index color palette. */
+ for (i = 0; (i < count) && ((i + start) < framebuffer.palette_size); i++)
+ palette_data[i] = framebuffer.palette[start + i];
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data)
+{
+ unsigned i;
+ if (start + count > framebuffer.palette_size)
+ {
+ framebuffer.palette_size = start + count;
+ framebuffer.palette = grub_realloc (framebuffer.palette,
+ sizeof (framebuffer.palette[0])
+ * framebuffer.palette_size);
+ if (!framebuffer.palette)
+ {
+ grub_video_fb_fini ();
+ return grub_errno;
+ }
+ }
+ for (i = 0; (i < count) && ((i + start) < framebuffer.palette_size); i++)
+ framebuffer.palette[start + i] = palette_data[i];
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_fb_set_area (void)
+{
+ unsigned int viewport_x1 = framebuffer.render_target->viewport.x;
+ unsigned int viewport_y1 = framebuffer.render_target->viewport.y;
+ unsigned int viewport_width = framebuffer.render_target->viewport.width;
+ unsigned int viewport_height = framebuffer.render_target->viewport.height;
+ unsigned int viewport_x2 = viewport_x1 + viewport_width;
+ unsigned int viewport_y2 = viewport_y1 + viewport_height;
+
+ unsigned int region_x1 = framebuffer.render_target->region.x;
+ unsigned int region_y1 = framebuffer.render_target->region.y;
+ unsigned int region_width = framebuffer.render_target->region.width;
+ unsigned int region_height = framebuffer.render_target->region.height;
+ unsigned int region_x2 = region_x1 + region_width;
+ unsigned int region_y2 = region_y1 + region_height;
+
+ unsigned int max_x1 = grub_max (viewport_x1, region_x1);
+ unsigned int min_x2 = grub_min (viewport_x2, region_x2);
+ unsigned int max_y1 = grub_max (viewport_y1, region_y1);
+ unsigned int min_y2 = grub_min (viewport_y2, region_y2);
+
+ /* Viewport and region do not intersect. */
+ if (viewport_width == 0 || viewport_height == 0 || region_width == 0
+ || region_height == 0 || max_x1 >= min_x2 || max_y1 >= min_y2)
+ {
+ framebuffer.render_target->area.x = 0;
+ framebuffer.render_target->area.y = 0;
+ framebuffer.render_target->area.width = 0;
+ framebuffer.render_target->area.height = 0;
+ framebuffer.render_target->area_offset_x = 0;
+ framebuffer.render_target->area_offset_y = 0;
+ return GRUB_ERR_NONE;
+ }
+
+ /* There is non-zero intersection. */
+ framebuffer.render_target->area.x = max_x1;
+ framebuffer.render_target->area.y = max_y1;
+ framebuffer.render_target->area.width = min_x2 - max_x1;
+ framebuffer.render_target->area.height = min_y2 - max_y1;
+
+ if (region_x1 > viewport_x1)
+ framebuffer.render_target->area_offset_x = (int)region_x1
+ - (int)viewport_x1;
+ else
+ framebuffer.render_target->area_offset_x = 0;
+ if (region_y1 > viewport_y1)
+ framebuffer.render_target->area_offset_y = (int)region_y1
+ - (int)viewport_y1;
+ else
+ framebuffer.render_target->area_offset_y = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_set_viewport (unsigned int x, unsigned int y,
+ unsigned int width, unsigned int height)
+{
+ /* Make sure viewport is within screen dimensions. If viewport was set
+ to be out of the screen, mark its size as zero. */
+ if (x > framebuffer.render_target->mode_info.width)
+ {
+ x = 0;
+ width = 0;
+ }
+
+ if (y > framebuffer.render_target->mode_info.height)
+ {
+ y = 0;
+ height = 0;
+ }
+
+ if (x + width > framebuffer.render_target->mode_info.width)
+ width = framebuffer.render_target->mode_info.width - x;
+
+ if (y + height > framebuffer.render_target->mode_info.height)
+ height = framebuffer.render_target->mode_info.height - y;
+
+ framebuffer.render_target->viewport.x = x;
+ framebuffer.render_target->viewport.y = y;
+ framebuffer.render_target->viewport.width = width;
+ framebuffer.render_target->viewport.height = height;
+
+ /* Count drawing area only if needed. */
+ if (framebuffer.render_target->area_enabled)
+ grub_video_fb_set_area ();
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_get_viewport (unsigned int *x, unsigned int *y,
+ unsigned int *width, unsigned int *height)
+{
+ if (x) *x = framebuffer.render_target->viewport.x;
+ if (y) *y = framebuffer.render_target->viewport.y;
+ if (width) *width = framebuffer.render_target->viewport.width;
+ if (height) *height = framebuffer.render_target->viewport.height;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_set_region (unsigned int x, unsigned int y,
+ unsigned int width, unsigned int height)
+{
+ /* Make sure region is within screen dimensions. If region was set
+ to be out of the screen, mark its size as zero. */
+ if (x > framebuffer.render_target->mode_info.width)
+ {
+ x = 0;
+ width = 0;
+ }
+
+ if (y > framebuffer.render_target->mode_info.height)
+ {
+ y = 0;
+ height = 0;
+ }
+
+ if (x + width > framebuffer.render_target->mode_info.width)
+ width = framebuffer.render_target->mode_info.width - x;
+
+ if (y + height > framebuffer.render_target->mode_info.height)
+ height = framebuffer.render_target->mode_info.height - y;
+
+ framebuffer.render_target->region.x = x;
+ framebuffer.render_target->region.y = y;
+ framebuffer.render_target->region.width = width;
+ framebuffer.render_target->region.height = height;
+
+ /* If we have called set_region then area is needed. */
+ grub_video_fb_set_area ();
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_get_region (unsigned int *x, unsigned int *y,
+ unsigned int *width, unsigned int *height)
+{
+ if (x) *x = framebuffer.render_target->region.x;
+ if (y) *y = framebuffer.render_target->region.y;
+ if (width) *width = framebuffer.render_target->region.width;
+ if (height) *height = framebuffer.render_target->region.height;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_set_area_status (grub_video_area_status_t area_status)
+{
+ if (area_status == GRUB_VIDEO_AREA_ENABLED)
+ framebuffer.render_target->area_enabled = 1;
+ else
+ framebuffer.render_target->area_enabled = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_get_area_status (grub_video_area_status_t *area_status)
+{
+ if (!area_status)
+ return GRUB_ERR_NONE;
+
+ if (framebuffer.render_target->area_enabled)
+ *area_status = GRUB_VIDEO_AREA_ENABLED;
+ else
+ *area_status = GRUB_VIDEO_AREA_DISABLED;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Maps color name to target optimized color format. */
+grub_video_color_t
+grub_video_fb_map_color (grub_uint32_t color_name)
+{
+ /* TODO: implement color theme mapping code. */
+
+ if (color_name < framebuffer.palette_size)
+ {
+ if ((framebuffer.render_target->mode_info.mode_type
+ & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
+ return color_name;
+ else
+ {
+ grub_video_color_t color;
+
+ color = grub_video_fb_map_rgb (framebuffer.palette[color_name].r,
+ framebuffer.palette[color_name].g,
+ framebuffer.palette[color_name].b);
+
+ return color;
+ }
+ }
+
+ return 0;
+}
+
+/* Maps RGB to target optimized color format. */
+grub_video_color_t
+grub_video_fb_map_rgb (grub_uint8_t red, grub_uint8_t green,
+ grub_uint8_t blue)
+{
+ if ((framebuffer.render_target->mode_info.mode_type
+ & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
+ {
+ int minindex = 0;
+ int delta = 0;
+ int tmp;
+ int val;
+ unsigned i;
+
+ /* Find best matching color. */
+ for (i = 0; i < framebuffer.palette_size; i++)
+ {
+ val = framebuffer.palette[i].r - red;
+ tmp = val * val;
+ val = framebuffer.palette[i].g - green;
+ tmp += val * val;
+ val = framebuffer.palette[i].b - blue;
+ tmp += val * val;
+
+ if (i == 0)
+ delta = tmp;
+
+ if (tmp < delta)
+ {
+ delta = tmp;
+ minindex = i;
+ if (tmp == 0)
+ break;
+ }
+ }
+
+ return minindex;
+ }
+ else if ((framebuffer.render_target->mode_info.mode_type
+ & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0)
+ {
+ if (red == framebuffer.render_target->mode_info.fg_red
+ && green == framebuffer.render_target->mode_info.fg_green
+ && blue == framebuffer.render_target->mode_info.fg_blue)
+ return 1;
+ else
+ return 0;
+ }
+ else
+ {
+ grub_uint32_t value;
+ grub_uint8_t alpha = 255; /* Opaque color. */
+
+ red >>= 8 - framebuffer.render_target->mode_info.red_mask_size;
+ green >>= 8 - framebuffer.render_target->mode_info.green_mask_size;
+ blue >>= 8 - framebuffer.render_target->mode_info.blue_mask_size;
+ alpha >>= 8 - framebuffer.render_target->mode_info.reserved_mask_size;
+
+ value = red << framebuffer.render_target->mode_info.red_field_pos;
+ value |= green << framebuffer.render_target->mode_info.green_field_pos;
+ value |= blue << framebuffer.render_target->mode_info.blue_field_pos;
+ value |= alpha << framebuffer.render_target->mode_info.reserved_field_pos;
+
+ return value;
+ }
+
+}
+
+/* Maps RGBA to target optimized color format. */
+grub_video_color_t
+grub_video_fb_map_rgba (grub_uint8_t red, grub_uint8_t green,
+ grub_uint8_t blue, grub_uint8_t alpha)
+{
+
+ if ((framebuffer.render_target->mode_info.mode_type
+ & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
+ {
+ if ((framebuffer.render_target->mode_info.mode_type
+ & GRUB_VIDEO_MODE_TYPE_ALPHA) != 0
+ && alpha == 0)
+ return 0xf0;
+ /* No alpha available in index color modes, just use
+ same value as in only RGB modes. */
+ return grub_video_fb_map_rgb (red, green, blue);
+ }
+ else if ((framebuffer.render_target->mode_info.mode_type
+ & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0)
+ {
+ if (red == framebuffer.render_target->mode_info.fg_red
+ && green == framebuffer.render_target->mode_info.fg_green
+ && blue == framebuffer.render_target->mode_info.fg_blue
+ && alpha == framebuffer.render_target->mode_info.fg_alpha)
+ return 1;
+ else
+ return 0;
+ }
+ else
+ {
+ grub_uint32_t value;
+
+ red >>= 8 - framebuffer.render_target->mode_info.red_mask_size;
+ green >>= 8 - framebuffer.render_target->mode_info.green_mask_size;
+ blue >>= 8 - framebuffer.render_target->mode_info.blue_mask_size;
+ alpha >>= 8 - framebuffer.render_target->mode_info.reserved_mask_size;
+
+ value = red << framebuffer.render_target->mode_info.red_field_pos;
+ value |= green << framebuffer.render_target->mode_info.green_field_pos;
+ value |= blue << framebuffer.render_target->mode_info.blue_field_pos;
+ value |= alpha << framebuffer.render_target->mode_info.reserved_field_pos;
+
+ return value;
+ }
+}
+
+/* Splits target optimized format to components. */
+grub_err_t
+grub_video_fb_unmap_color (grub_video_color_t color,
+ grub_uint8_t *red, grub_uint8_t *green,
+ grub_uint8_t *blue, grub_uint8_t *alpha)
+{
+ struct grub_video_fbblit_info target_info;
+
+ target_info.mode_info = &framebuffer.render_target->mode_info;
+ target_info.data = framebuffer.render_target->data;
+
+ grub_video_fb_unmap_color_int (&target_info, color, red, green, blue, alpha);
+
+ return GRUB_ERR_NONE;
+}
+
+/* Splits color in source format to components. */
+void
+grub_video_fb_unmap_color_int (struct grub_video_fbblit_info * source,
+ grub_video_color_t color,
+ grub_uint8_t *red, grub_uint8_t *green,
+ grub_uint8_t *blue, grub_uint8_t *alpha)
+{
+ struct grub_video_mode_info *mode_info;
+ mode_info = source->mode_info;
+
+ if ((mode_info->mode_type
+ & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
+ {
+ if ((mode_info->mode_type
+ & GRUB_VIDEO_MODE_TYPE_ALPHA) != 0
+ && color == 0xf0)
+ {
+ *red = 0;
+ *green = 0;
+ *blue = 0;
+ *alpha = 0;
+ return;
+ }
+
+ /* If we have an out-of-bounds color, return transparent black. */
+ if (color > 255)
+ {
+ *red = 0;
+ *green = 0;
+ *blue = 0;
+ *alpha = 0;
+ return;
+ }
+
+ *red = framebuffer.palette[color].r;
+ *green = framebuffer.palette[color].g;
+ *blue = framebuffer.palette[color].b;
+ *alpha = framebuffer.palette[color].a;
+ return;
+ }
+ else if ((mode_info->mode_type
+ & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0)
+ {
+ if (color & 1)
+ {
+ *red = mode_info->fg_red;
+ *green = mode_info->fg_green;
+ *blue = mode_info->fg_blue;
+ *alpha = mode_info->fg_alpha;
+ }
+ else
+ {
+ *red = mode_info->bg_red;
+ *green = mode_info->bg_green;
+ *blue = mode_info->bg_blue;
+ *alpha = mode_info->bg_alpha;
+ }
+ }
+ else
+ {
+ grub_uint32_t tmp;
+
+ /* Get red component. */
+ tmp = color >> mode_info->red_field_pos;
+ tmp &= (1 << mode_info->red_mask_size) - 1;
+ tmp <<= 8 - mode_info->red_mask_size;
+ tmp |= (1 << (8 - mode_info->red_mask_size)) - 1;
+ *red = tmp & 0xFF;
+
+ /* Get green component. */
+ tmp = color >> mode_info->green_field_pos;
+ tmp &= (1 << mode_info->green_mask_size) - 1;
+ tmp <<= 8 - mode_info->green_mask_size;
+ tmp |= (1 << (8 - mode_info->green_mask_size)) - 1;
+ *green = tmp & 0xFF;
+
+ /* Get blue component. */
+ tmp = color >> mode_info->blue_field_pos;
+ tmp &= (1 << mode_info->blue_mask_size) - 1;
+ tmp <<= 8 - mode_info->blue_mask_size;
+ tmp |= (1 << (8 - mode_info->blue_mask_size)) - 1;
+ *blue = tmp & 0xFF;
+
+ /* Get alpha component. */
+ if (source->mode_info->reserved_mask_size > 0)
+ {
+ tmp = color >> mode_info->reserved_field_pos;
+ tmp &= (1 << mode_info->reserved_mask_size) - 1;
+ tmp <<= 8 - mode_info->reserved_mask_size;
+ tmp |= (1 << (8 - mode_info->reserved_mask_size)) - 1;
+ }
+ else
+ /* If there is no alpha component, assume it opaque. */
+ tmp = 255;
+
+ *alpha = tmp & 0xFF;
+ }
+}
+
+static void
+dirty (int y, int height)
+{
+ if (framebuffer.render_target != framebuffer.back_target)
+ return;
+ if (framebuffer.current_dirty.first_line > y)
+ framebuffer.current_dirty.first_line = y;
+ if (framebuffer.current_dirty.last_line < y + height)
+ framebuffer.current_dirty.last_line = y + height;
+}
+
+grub_err_t
+grub_video_fb_fill_rect (grub_video_color_t color, int x, int y,
+ unsigned int width, unsigned int height)
+{
+ struct grub_video_fbblit_info target;
+ unsigned int area_x;
+ unsigned int area_y;
+ unsigned int area_width;
+ unsigned int area_height;
+ if (framebuffer.render_target->area_enabled)
+ {
+ area_x = framebuffer.render_target->area.x;
+ area_y = framebuffer.render_target->area.y;
+ area_width = framebuffer.render_target->area.width;
+ area_height = framebuffer.render_target->area.height;
+ x -= framebuffer.render_target->area_offset_x;
+ y -= framebuffer.render_target->area_offset_y;
+ }
+ else
+ {
+ area_x = framebuffer.render_target->viewport.x;
+ area_y = framebuffer.render_target->viewport.y;
+ area_width = framebuffer.render_target->viewport.width;
+ area_height = framebuffer.render_target->viewport.height;
+ }
+
+ /* Make sure there is something to do. */
+ if ((area_width == 0) || (area_height == 0))
+ return GRUB_ERR_NONE;
+ if ((x >= (int)area_width) || (x + (int)width < 0))
+ return GRUB_ERR_NONE;
+ if ((y >= (int)area_height) || (y + (int)height < 0))
+ return GRUB_ERR_NONE;
+
+ /* Do not allow drawing out of area. */
+ if (x < 0)
+ {
+ width += x;
+ x = 0;
+ }
+ if (y < 0)
+ {
+ height += y;
+ y = 0;
+ }
+
+ if ((x + width) > area_width)
+ width = area_width - x;
+ if ((y + height) > area_height)
+ height = area_height - y;
+
+ /* Add area offset. */
+ x += area_x;
+ y += area_y;
+
+ dirty (y, height);
+
+ /* Use fbblit_info to encapsulate rendering. */
+ target.mode_info = &framebuffer.render_target->mode_info;
+ target.data = framebuffer.render_target->data;
+
+ grub_video_fb_fill_dispatch (&target, color, x, y,
+ width, height);
+ return GRUB_ERR_NONE;
+}
+
+static inline grub_err_t __attribute__ ((always_inline))
+grub_video_fb_blit_source (struct grub_video_fbblit_info *source,
+ enum grub_video_blit_operators oper, int x, int y,
+ int offset_x, int offset_y,
+ unsigned int width, unsigned int height)
+{
+ struct grub_video_fbblit_info target;
+ unsigned int area_x;
+ unsigned int area_y;
+ unsigned int area_width;
+ unsigned int area_height;
+ if (framebuffer.render_target->area_enabled)
+ {
+ area_x = framebuffer.render_target->area.x;
+ area_y = framebuffer.render_target->area.y;
+ area_width = framebuffer.render_target->area.width;
+ area_height = framebuffer.render_target->area.height;
+ x -= framebuffer.render_target->area_offset_x;
+ y -= framebuffer.render_target->area_offset_y;
+ }
+ else
+ {
+ area_x = framebuffer.render_target->viewport.x;
+ area_y = framebuffer.render_target->viewport.y;
+ area_width = framebuffer.render_target->viewport.width;
+ area_height = framebuffer.render_target->viewport.height;
+ }
+
+ /* Make sure there is something to do. */
+ if ((area_width == 0) || (area_height == 0) || (width == 0) || (height == 0))
+ return GRUB_ERR_NONE;
+ if ((x >= (int)area_width) || (x + (int)width < 0))
+ return GRUB_ERR_NONE;
+ if ((y >= (int)area_height) || (y + (int)height < 0))
+ return GRUB_ERR_NONE;
+ if ((x + (int)source->mode_info->width) < 0)
+ return GRUB_ERR_NONE;
+ if ((y + (int)source->mode_info->height) < 0)
+ return GRUB_ERR_NONE;
+ if ((offset_x >= (int)source->mode_info->width)
+ || (offset_x + (int)width < 0))
+ return GRUB_ERR_NONE;
+ if ((offset_y >= (int)source->mode_info->height)
+ || (offset_y + (int)height < 0))
+ return GRUB_ERR_NONE;
+
+ /* If we have negative coordinates, optimize drawing to minimum. */
+ if (offset_x < 0)
+ {
+ width += offset_x;
+ x -= offset_x;
+ offset_x = 0;
+ }
+
+ if (offset_y < 0)
+ {
+ height += offset_y;
+ y -= offset_y;
+ offset_y = 0;
+ }
+
+ if (x < 0)
+ {
+ width += x;
+ offset_x -= x;
+ x = 0;
+ }
+
+ if (y < 0)
+ {
+ height += y;
+ offset_y -= y;
+ y = 0;
+ }
+
+ /* Do not allow drawing out of area. */
+ if ((x + width) > area_width)
+ width = area_width - x;
+ if ((y + height) > area_height)
+ height = area_height - y;
+
+ if ((offset_x + width) > source->mode_info->width)
+ width = source->mode_info->width - offset_x;
+ if ((offset_y + height) > source->mode_info->height)
+ height = source->mode_info->height - offset_y;
+
+ /* Limit drawing to source render target dimensions. */
+ if (width > source->mode_info->width)
+ width = source->mode_info->width;
+
+ if (height > source->mode_info->height)
+ height = source->mode_info->height;
+
+ /* Add viewport offset. */
+ x += area_x;
+ y += area_y;
+
+ /* Use fbblit_info to encapsulate rendering. */
+ target.mode_info = &framebuffer.render_target->mode_info;
+ target.data = framebuffer.render_target->data;
+
+ /* Do actual blitting. */
+ dirty (y, height);
+ grub_video_fb_dispatch_blit (&target, source, oper, x, y, width, height,
+ offset_x, offset_y);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_blit_bitmap (struct grub_video_bitmap *bitmap,
+ enum grub_video_blit_operators oper, int x, int y,
+ int offset_x, int offset_y,
+ unsigned int width, unsigned int height)
+{
+ struct grub_video_fbblit_info source_info;
+ source_info.mode_info = &bitmap->mode_info;
+ source_info.data = bitmap->data;
+
+ return grub_video_fb_blit_source (&source_info, oper, x, y,
+ offset_x, offset_y, width, height);
+}
+
+grub_err_t
+grub_video_fb_blit_render_target (struct grub_video_fbrender_target *source,
+ enum grub_video_blit_operators oper,
+ int x, int y, int offset_x, int offset_y,
+ unsigned int width, unsigned int height)
+{
+ struct grub_video_fbblit_info source_info;
+ source_info.mode_info = &source->mode_info;
+ source_info.data = source->data;
+
+ return grub_video_fb_blit_source (&source_info, oper, x, y,
+ offset_x, offset_y, width, height);
+}
+
+grub_err_t
+grub_video_fb_scroll (grub_video_color_t color, int dx, int dy)
+{
+ int width;
+ int height;
+ int src_x;
+ int src_y;
+ int dst_x;
+ int dst_y;
+
+ /* 1. Check if we have something to do. */
+ if ((dx == 0) && (dy == 0))
+ return GRUB_ERR_NONE;
+
+ width = framebuffer.render_target->viewport.width - grub_abs (dx);
+ height = framebuffer.render_target->viewport.height - grub_abs (dy);
+
+ dirty (framebuffer.render_target->viewport.y,
+ framebuffer.render_target->viewport.height);
+
+ if (dx < 0)
+ {
+ src_x = framebuffer.render_target->viewport.x - dx;
+ dst_x = framebuffer.render_target->viewport.x;
+ }
+ else
+ {
+ src_x = framebuffer.render_target->viewport.x;
+ dst_x = framebuffer.render_target->viewport.x + dx;
+ }
+
+ if (dy < 0)
+ {
+ src_y = framebuffer.render_target->viewport.y - dy;
+ dst_y = framebuffer.render_target->viewport.y;
+ }
+ else
+ {
+ src_y = framebuffer.render_target->viewport.y;
+ dst_y = framebuffer.render_target->viewport.y + dy;
+ }
+
+ /* 2. Check if there is need to copy data. */
+ if ((grub_abs (dx) < framebuffer.render_target->viewport.width)
+ && (grub_abs (dy) < framebuffer.render_target->viewport.height))
+ {
+ /* 3. Move data in render target. */
+ struct grub_video_fbblit_info target;
+ int i, j;
+ int linedelta, linelen;
+
+ target.mode_info = &framebuffer.render_target->mode_info;
+ target.data = framebuffer.render_target->data;
+
+ linedelta = target.mode_info->pitch
+ - width * target.mode_info->bytes_per_pixel;
+ linelen = width * target.mode_info->bytes_per_pixel;
+#define DO_SCROLL \
+ /* Check vertical direction of the move. */ \
+ if (dy < 0 || (dy == 0 && dx < 0)) \
+ { \
+ dst = (void *) grub_video_fb_get_video_ptr (&target, \
+ dst_x, dst_y); \
+ src = (void *) grub_video_fb_get_video_ptr (&target, \
+ src_x, src_y); \
+ /* 3a. Move data upwards. */ \
+ for (j = 0; j < height; j++) \
+ { \
+ for (i = 0; i < linelen; i++) \
+ *(dst++) = *(src++); \
+ dst += linedelta; \
+ src += linedelta; \
+ } \
+ } \
+ else \
+ { \
+ /* 3b. Move data downwards. */ \
+ dst = (void *) grub_video_fb_get_video_ptr (&target, \
+ dst_x + width, \
+ dst_y + height - 1); \
+ src = (void *) grub_video_fb_get_video_ptr (&target, \
+ src_x + width, \
+ src_y + height - 1); \
+ dst--; \
+ src--; \
+ for (j = 0; j < height; j++) \
+ { \
+ for (i = 0; i < linelen; i++) \
+ *(dst--) = *(src--); \
+ dst -= linedelta; \
+ src -= linedelta; \
+ } \
+ }
+
+ /* If everything is aligned on 32-bit use 32-bit copy. */
+ if ((grub_addr_t) grub_video_fb_get_video_ptr (&target, src_x, src_y)
+ % sizeof (grub_uint32_t) == 0
+ && (grub_addr_t) grub_video_fb_get_video_ptr (&target, dst_x, dst_y)
+ % sizeof (grub_uint32_t) == 0
+ && linelen % sizeof (grub_uint32_t) == 0
+ && linedelta % sizeof (grub_uint32_t) == 0)
+ {
+ grub_uint32_t *src, *dst;
+ linelen /= sizeof (grub_uint32_t);
+ linedelta /= sizeof (grub_uint32_t);
+ DO_SCROLL
+ }
+ /* If everything is aligned on 16-bit use 16-bit copy. */
+ else if ((grub_addr_t) grub_video_fb_get_video_ptr (&target, src_x, src_y)
+ % sizeof (grub_uint16_t) == 0
+ && (grub_addr_t) grub_video_fb_get_video_ptr (&target,
+ dst_x, dst_y)
+ % sizeof (grub_uint16_t) == 0
+ && linelen % sizeof (grub_uint16_t) == 0
+ && linedelta % sizeof (grub_uint16_t) == 0)
+ {
+ grub_uint16_t *src, *dst;
+ linelen /= sizeof (grub_uint16_t);
+ linedelta /= sizeof (grub_uint16_t);
+ DO_SCROLL
+ }
+ /* If not aligned at all use 8-bit copy. */
+ else
+ {
+ grub_uint8_t *src, *dst;
+ DO_SCROLL
+ }
+ }
+
+ /* 4. Fill empty space with specified color. In this implementation
+ there might be colliding areas but at the moment there is no need
+ to optimize this. */
+
+ /* 4a. Fill top & bottom parts. */
+ if (dy > 0)
+ grub_video_fb_fill_rect (color, 0, 0, framebuffer.render_target->viewport.width, dy);
+ else if (dy < 0)
+ {
+ if (framebuffer.render_target->viewport.height < grub_abs (dy))
+ dy = -framebuffer.render_target->viewport.height;
+
+ grub_video_fb_fill_rect (color, 0, framebuffer.render_target->viewport.height + dy,
+ framebuffer.render_target->viewport.width, -dy);
+ }
+
+ /* 4b. Fill left & right parts. */
+ if (dx > 0)
+ grub_video_fb_fill_rect (color, 0, 0,
+ dx, framebuffer.render_target->viewport.height);
+ else if (dx < 0)
+ {
+ if (framebuffer.render_target->viewport.width < grub_abs (dx))
+ dx = -framebuffer.render_target->viewport.width;
+
+ grub_video_fb_fill_rect (color, framebuffer.render_target->viewport.width + dx, 0,
+ -dx, framebuffer.render_target->viewport.height);
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+
+grub_err_t
+grub_video_fb_create_render_target (struct grub_video_fbrender_target **result,
+ unsigned int width, unsigned int height,
+ unsigned int mode_type __attribute__ ((unused)))
+{
+ struct grub_video_fbrender_target *target;
+ unsigned int size;
+
+ /* Validate arguments. */
+ if ((! result)
+ || (width == 0)
+ || (height == 0))
+ return grub_error (GRUB_ERR_BUG,
+ "invalid argument given");
+
+ /* Allocate memory for render target. */
+ target = grub_malloc (sizeof (struct grub_video_fbrender_target));
+ if (! target)
+ return grub_errno;
+
+ /* TODO: Implement other types too.
+ Currently only 32bit render targets are supported. */
+
+ /* Mark render target as allocated. */
+ target->is_allocated = 1;
+
+ /* Maximize viewport, region and area. */
+ target->viewport.x = 0;
+ target->viewport.y = 0;
+ target->viewport.width = width;
+ target->viewport.height = height;
+
+ target->region.x = 0;
+ target->region.y = 0;
+ target->region.width = width;
+ target->region.height = height;
+
+ target->area_enabled = 0;
+ target->area.x = 0;
+ target->area.y = 0;
+ target->area.width = width;
+ target->area.height = height;
+ target->area_offset_x = 0;
+ target->area_offset_y = 0;
+
+ /* Setup render target format. */
+ target->mode_info.width = width;
+ target->mode_info.height = height;
+ switch (mode_type)
+ {
+ case GRUB_VIDEO_MODE_TYPE_INDEX_COLOR
+ | GRUB_VIDEO_MODE_TYPE_ALPHA:
+ target->mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR
+ | GRUB_VIDEO_MODE_TYPE_ALPHA;
+ target->mode_info.bpp = 8;
+ target->mode_info.bytes_per_pixel = 1;
+ target->mode_info.number_of_colors = 16;
+ target->mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR_ALPHA;
+ break;
+ default:
+ target->mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB
+ | GRUB_VIDEO_MODE_TYPE_ALPHA;
+ target->mode_info.bpp = 32;
+ target->mode_info.bytes_per_pixel = 4;
+ target->mode_info.red_mask_size = 8;
+ target->mode_info.red_field_pos = 0;
+ target->mode_info.green_mask_size = 8;
+ target->mode_info.green_field_pos = 8;
+ target->mode_info.blue_mask_size = 8;
+ target->mode_info.blue_field_pos = 16;
+ target->mode_info.reserved_mask_size = 8;
+ target->mode_info.reserved_field_pos = 24;
+ target->mode_info.number_of_colors = framebuffer.palette_size; /* Emulated palette. */
+ target->mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_RGBA_8888;
+ break;
+ }
+ target->mode_info.pitch = target->mode_info.bytes_per_pixel * width;
+
+ /* Calculate size needed for the data. */
+ size = (width * target->mode_info.bytes_per_pixel) * height;
+
+ target->data = grub_malloc (size);
+ if (! target->data)
+ {
+ grub_free (target);
+ return grub_errno;
+ }
+
+ /* Clear render target with black and maximum transparency. */
+ if (mode_type == (GRUB_VIDEO_MODE_TYPE_INDEX_COLOR
+ | GRUB_VIDEO_MODE_TYPE_ALPHA))
+ grub_memset (target->data, 0xf0, size);
+ else
+ grub_memset (target->data, 0, size);
+
+ /* TODO: Add render target to render target list. */
+
+ /* Save result to caller. */
+ *result = target;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_create_render_target_from_pointer (struct grub_video_fbrender_target **result,
+ const struct grub_video_mode_info *mode_info,
+ void *ptr)
+{
+ struct grub_video_fbrender_target *target;
+ unsigned y;
+
+#ifndef GRUB_HAVE_UNALIGNED_ACCESS
+ if (!(mode_info->bytes_per_pixel & (mode_info->bytes_per_pixel - 1))
+ && ((grub_addr_t) ptr & (mode_info->bytes_per_pixel - 1)))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "unaligned pointer");
+ if (!(mode_info->bytes_per_pixel & (mode_info->bytes_per_pixel - 1))
+ && (mode_info->pitch & (mode_info->bytes_per_pixel - 1)))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "unaligned pitch");
+#endif
+
+ /* Allocate memory for render target. */
+ target = grub_malloc (sizeof (struct grub_video_fbrender_target));
+ if (! target)
+ return grub_errno;
+
+ /* Mark framebuffer memory as non allocated. */
+ target->is_allocated = 0;
+ target->data = ptr;
+
+ grub_memcpy (&(target->mode_info), mode_info, sizeof (target->mode_info));
+
+ /* Reset viewport, region and area to match new mode. */
+ target->viewport.x = 0;
+ target->viewport.y = 0;
+ target->viewport.width = mode_info->width;
+ target->viewport.height = mode_info->height;
+
+ target->region.x = 0;
+ target->region.y = 0;
+ target->region.width = mode_info->width;
+ target->region.height = mode_info->height;
+
+ target->area_enabled = 0;
+ target->area.x = 0;
+ target->area.y = 0;
+ target->area.width = mode_info->width;
+ target->area.height = mode_info->height;
+ target->area_offset_x = 0;
+ target->area_offset_y = 0;
+
+ /* Clear render target with black and maximum transparency. */
+ for (y = 0; y < mode_info->height; y++)
+ grub_memset (target->data + mode_info->pitch * y, 0,
+ mode_info->bytes_per_pixel * mode_info->width);
+
+ /* Save result to caller. */
+ *result = target;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_delete_render_target (struct grub_video_fbrender_target *target)
+{
+ /* If there is no target, then just return without error. */
+ if (! target)
+ return GRUB_ERR_NONE;
+
+ /* TODO: Delist render target from render target list. */
+
+ /* If this is software render target, free it's memory. */
+ if (target->is_allocated)
+ grub_free (target->data);
+
+ /* Free render target. */
+ grub_free (target);
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_set_active_render_target (struct grub_video_fbrender_target *target)
+{
+ if (target == (struct grub_video_fbrender_target *)
+ GRUB_VIDEO_RENDER_TARGET_DISPLAY)
+ target = framebuffer.back_target;
+
+ if (! target->data)
+ return grub_error (GRUB_ERR_BUG,
+ "invalid render target given");
+
+ framebuffer.render_target = target;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_get_active_render_target (struct grub_video_fbrender_target **target)
+{
+ *target = framebuffer.render_target;
+
+ if (*target == framebuffer.back_target)
+ *target = (struct grub_video_fbrender_target *) GRUB_VIDEO_RENDER_TARGET_DISPLAY;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+doublebuf_blit_update_screen (void)
+{
+ if (framebuffer.current_dirty.first_line
+ <= framebuffer.current_dirty.last_line)
+ {
+ grub_size_t copy_size;
+
+ if (grub_sub (framebuffer.current_dirty.last_line,
+ framebuffer.current_dirty.first_line, &copy_size) ||
+ grub_mul (framebuffer.back_target->mode_info.pitch, copy_size, &copy_size))
+ {
+ /* Shouldn't happen, but if it does we've a bug. */
+ return GRUB_ERR_BUG;
+ }
+
+ grub_memcpy ((char *) framebuffer.pages[0] + framebuffer.current_dirty.first_line *
+ framebuffer.back_target->mode_info.pitch,
+ (char *) framebuffer.back_target->data + framebuffer.current_dirty.first_line *
+ framebuffer.back_target->mode_info.pitch,
+ copy_size);
+ }
+ framebuffer.current_dirty.first_line
+ = framebuffer.back_target->mode_info.height;
+ framebuffer.current_dirty.last_line = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_fb_doublebuf_blit_init (struct grub_video_fbrender_target **back,
+ struct grub_video_mode_info mode_info,
+ volatile void *framebuf)
+{
+ grub_err_t err;
+ grub_size_t page_size = (grub_size_t) mode_info.pitch * mode_info.height;
+
+ framebuffer.offscreen_buffer = grub_zalloc (page_size);
+ if (! framebuffer.offscreen_buffer)
+ return grub_errno;
+
+ err = grub_video_fb_create_render_target_from_pointer (&framebuffer.back_target,
+ &mode_info,
+ framebuffer.offscreen_buffer);
+
+ if (err)
+ {
+ grub_free (framebuffer.offscreen_buffer);
+ framebuffer.offscreen_buffer = 0;
+ return grub_errno;
+ }
+ (*back)->is_allocated = 1;
+
+ framebuffer.update_screen = doublebuf_blit_update_screen;
+ framebuffer.pages[0] = framebuf;
+ framebuffer.displayed_page = 0;
+ framebuffer.render_page = 0;
+ framebuffer.current_dirty.first_line = mode_info.height;
+ framebuffer.current_dirty.last_line = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+doublebuf_pageflipping_update_screen (void)
+{
+ int new_displayed_page;
+ grub_err_t err;
+ int first_line, last_line;
+
+ first_line = framebuffer.current_dirty.first_line;
+ last_line = framebuffer.current_dirty.last_line;
+ if (first_line > framebuffer.previous_dirty.first_line)
+ first_line = framebuffer.previous_dirty.first_line;
+ if (last_line < framebuffer.previous_dirty.last_line)
+ last_line = framebuffer.previous_dirty.last_line;
+
+ if (first_line <= last_line)
+ {
+ grub_size_t copy_size;
+
+ if (grub_sub (last_line, first_line, &copy_size) ||
+ grub_mul (framebuffer.back_target->mode_info.pitch, copy_size, &copy_size))
+ {
+ /* Shouldn't happen, but if it does we've a bug. */
+ return GRUB_ERR_BUG;
+ }
+
+ grub_memcpy ((char *) framebuffer.pages[framebuffer.render_page] + first_line *
+ framebuffer.back_target->mode_info.pitch,
+ (char *) framebuffer.back_target->data + first_line *
+ framebuffer.back_target->mode_info.pitch,
+ copy_size);
+ }
+
+ framebuffer.previous_dirty = framebuffer.current_dirty;
+ framebuffer.current_dirty.first_line
+ = framebuffer.back_target->mode_info.height;
+ framebuffer.current_dirty.last_line = 0;
+
+ /* Swap the page numbers in the framebuffer struct. */
+ new_displayed_page = framebuffer.render_page;
+ framebuffer.render_page = framebuffer.displayed_page;
+ framebuffer.displayed_page = new_displayed_page;
+
+ err = framebuffer.set_page (framebuffer.displayed_page);
+ if (err)
+ {
+ /* Restore previous state. */
+ framebuffer.render_page = framebuffer.displayed_page;
+ framebuffer.displayed_page = new_displayed_page;
+ return err;
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+doublebuf_pageflipping_init (struct grub_video_mode_info *mode_info,
+ volatile void *page0_ptr,
+ grub_video_fb_set_page_t set_page_in,
+ volatile void *page1_ptr)
+{
+ grub_err_t err;
+ grub_size_t page_size = 0;
+
+ if (grub_mul (mode_info->pitch, mode_info->height, &page_size))
+ {
+ /* Shouldn't happen, but if it does we've a bug. */
+ return GRUB_ERR_BUG;
+ }
+
+ framebuffer.offscreen_buffer = grub_malloc (page_size);
+ if (! framebuffer.offscreen_buffer)
+ {
+ return grub_errno;
+ }
+
+ err = grub_video_fb_create_render_target_from_pointer (&framebuffer.back_target,
+ mode_info,
+ framebuffer.offscreen_buffer);
+
+ if (err)
+ {
+ grub_free (framebuffer.offscreen_buffer);
+ framebuffer.offscreen_buffer = 0;
+ return grub_errno;
+ }
+ framebuffer.back_target->is_allocated = 1;
+
+ framebuffer.displayed_page = 0;
+ framebuffer.render_page = 1;
+
+ framebuffer.update_screen = doublebuf_pageflipping_update_screen;
+ framebuffer.pages[0] = page0_ptr;
+ framebuffer.pages[1] = page1_ptr;
+
+ framebuffer.current_dirty.first_line
+ = framebuffer.back_target->mode_info.height;
+ framebuffer.current_dirty.last_line = 0;
+ framebuffer.previous_dirty.first_line
+ = framebuffer.back_target->mode_info.height;
+ framebuffer.previous_dirty.last_line = 0;
+
+ /* Set the framebuffer memory data pointer and display the right page. */
+ err = set_page_in (framebuffer.displayed_page);
+ if (err)
+ {
+ grub_video_fb_delete_render_target (framebuffer.back_target);
+ return err;
+ }
+ framebuffer.set_page = set_page_in;
+
+ return GRUB_ERR_NONE;
+}
+
+/* Select the best double buffering mode available. */
+grub_err_t
+grub_video_fb_setup (unsigned int mode_type, unsigned int mode_mask,
+ struct grub_video_mode_info *mode_info,
+ volatile void *page0_ptr,
+ grub_video_fb_set_page_t set_page_in,
+ volatile void *page1_ptr)
+{
+ grub_err_t err;
+
+ /* Do double buffering only if it's either requested or efficient. */
+ if (set_page_in && grub_video_check_mode_flag (mode_type, mode_mask,
+ GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED,
+ 1))
+ {
+ mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED;
+ mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP;
+
+ err = doublebuf_pageflipping_init (mode_info, page0_ptr,
+ set_page_in,
+ page1_ptr);
+ if (!err)
+ {
+ framebuffer.render_target = framebuffer.back_target;
+ return GRUB_ERR_NONE;
+ }
+
+ mode_info->mode_type &= ~(GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED
+ | GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP);
+
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ if (grub_video_check_mode_flag (mode_type, mode_mask,
+ GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED,
+ 1))
+ {
+ /* It was much nicer with the cast directly at function call but
+ some older gcc versions don't accept it properly.*/
+ void *tmp = (void *) page0_ptr;
+ mode_info->mode_type |= (GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED
+ | GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP);
+
+ err = grub_video_fb_doublebuf_blit_init (&framebuffer.back_target,
+ *mode_info,
+ tmp);
+
+ if (!err)
+ {
+ framebuffer.render_target = framebuffer.back_target;
+ return GRUB_ERR_NONE;
+ }
+
+ mode_info->mode_type &= ~(GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED
+ | GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP);
+
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ /* Fall back to no double buffering. */
+ err = grub_video_fb_create_render_target_from_pointer (&framebuffer.back_target,
+ mode_info,
+ (void *) page0_ptr);
+
+ if (err)
+ return err;
+
+ framebuffer.update_screen = 0;
+ framebuffer.pages[0] = page0_ptr;
+ framebuffer.displayed_page = 0;
+ framebuffer.render_page = 0;
+ framebuffer.set_page = 0;
+ framebuffer.current_dirty.first_line
+ = framebuffer.back_target->mode_info.height;
+ framebuffer.current_dirty.last_line = 0;
+
+ mode_info->mode_type &= ~GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED;
+
+ framebuffer.render_target = framebuffer.back_target;
+
+ return GRUB_ERR_NONE;
+}
+
+
+grub_err_t
+grub_video_fb_swap_buffers (void)
+{
+ grub_err_t err;
+ if (!framebuffer.update_screen)
+ return GRUB_ERR_NONE;
+
+ err = framebuffer.update_screen ();
+ if (err)
+ return err;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_fb_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ grub_memcpy (mode_info, &(framebuffer.back_target->mode_info),
+ sizeof (*mode_info));
+
+ /* We are about to load a kernel. Switch back to page zero, since some
+ kernel drivers expect that. */
+ if (framebuffer.set_page && framebuffer.displayed_page != 0)
+ {
+ framebuffer.update_screen ();
+ }
+
+ *framebuf = (void *) framebuffer.pages[framebuffer.displayed_page];
+
+ grub_video_fb_fini ();
+
+ return GRUB_ERR_NONE;
+}
diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c
new file mode 100644
index 0000000..b7f9119
--- /dev/null
+++ b/grub-core/video/i386/pc/vbe.c
@@ -0,0 +1,1250 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/machine/memory.h>
+#include <grub/i386/pc/vbe.h>
+#include <grub/video_fb.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/i386/pc/int.h>
+#include <grub/i18n.h>
+#include <grub/cpu/cpuid.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static int vbe_detected = -1;
+
+static struct grub_vbe_info_block controller_info;
+
+/* Track last mode to support cards which fail on get_mode. */
+static grub_uint32_t last_set_mode = 3;
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+
+ grub_uint8_t *ptr;
+ int mtrr;
+} framebuffer;
+
+static grub_uint32_t initial_vbe_mode;
+static grub_uint16_t *vbe_mode_list;
+
+static void *
+real2pm (grub_vbe_farptr_t ptr)
+{
+ return (void *) ((((unsigned long) ptr & 0xFFFF0000) >> 12UL)
+ + ((unsigned long) ptr & 0x0000FFFF));
+}
+
+#define rdmsr(num,a,d) \
+ asm volatile ("rdmsr" : "=a" (a), "=d" (d) : "c" (num))
+
+#define wrmsr(num,lo,hi) \
+ asm volatile ("wrmsr" : : "c" (num), "a" (lo), "d" (hi) : "memory")
+
+#define mtrr_base(reg) (0x200 + (reg) * 2)
+#define mtrr_mask(reg) (0x200 + (reg) * 2 + 1)
+
+/* Try to set up a variable-range write-combining MTRR for a memory region.
+ This is best-effort; if it seems too hard, we just accept the performance
+ degradation rather than risking undefined behaviour. It is intended
+ exclusively to work around BIOS bugs, as the BIOS should already be
+ setting up a suitable MTRR. */
+static void
+grub_vbe_enable_mtrr_entry (int mtrr)
+{
+ grub_uint32_t eax, edx;
+ grub_uint32_t mask_lo, mask_hi;
+
+ rdmsr (mtrr_mask (mtrr), eax, edx);
+ mask_lo = eax;
+ mask_hi = edx;
+
+ mask_lo |= 0x800 /* valid */;
+ wrmsr (mtrr_mask (mtrr), mask_lo, mask_hi);
+}
+
+static void
+grub_vbe_enable_mtrr (grub_uint8_t *base, grub_size_t size)
+{
+ grub_uint32_t eax, ebx, ecx, edx;
+ grub_uint32_t features;
+ grub_uint32_t mtrrcap;
+ int var_mtrrs;
+ grub_uint32_t max_extended_cpuid;
+ grub_uint32_t maxphyaddr;
+ grub_uint64_t fb_base, fb_size;
+ grub_uint64_t size_bits, fb_mask;
+ grub_uint32_t bits_lo, bits_hi;
+ grub_uint64_t bits;
+ int i, first_unused = -1;
+ grub_uint32_t base_lo, base_hi, mask_lo, mask_hi;
+
+ fb_base = (grub_uint64_t) (grub_size_t) base;
+ fb_size = (grub_uint64_t) size;
+
+ /* Check that fb_base and fb_size can be represented using a single
+ MTRR. */
+
+ if (fb_base < (1 << 20))
+ return; /* under 1MB, so covered by fixed-range MTRRs */
+ if (fb_base >= (1LL << 36))
+ return; /* over 36 bits, so out of range */
+ if (fb_size < (1 << 12))
+ return; /* variable-range MTRRs must cover at least 4KB */
+
+ size_bits = fb_size;
+ while (size_bits > 1)
+ size_bits >>= 1;
+ if (size_bits != 1)
+ return; /* not a power of two */
+
+ if (fb_base & (fb_size - 1))
+ return; /* not aligned on size boundary */
+
+ fb_mask = ~(fb_size - 1);
+
+ /* Check CPU capabilities. */
+
+ if (! grub_cpu_is_cpuid_supported ())
+ return;
+
+ grub_cpuid (1, eax, ebx, ecx, edx);
+ features = edx;
+ if (! (features & 0x00001000)) /* MTRR */
+ return;
+
+ rdmsr (0xFE, eax, edx);
+ mtrrcap = eax;
+ if (! (mtrrcap & 0x00000400)) /* write-combining */
+ return;
+ var_mtrrs = (mtrrcap & 0xFF);
+
+ grub_cpuid (0x80000000, eax, ebx, ecx, edx);
+ max_extended_cpuid = eax;
+ if (max_extended_cpuid >= 0x80000008)
+ {
+ grub_cpuid (0x80000008, eax, ebx, ecx, edx);
+ maxphyaddr = (eax & 0xFF);
+ }
+ else
+ maxphyaddr = 36;
+ bits_lo = 0xFFFFF000; /* assume maxphyaddr >= 36 */
+ bits_hi = (1 << (maxphyaddr - 32)) - 1;
+ bits = bits_lo | ((grub_uint64_t) bits_hi << 32);
+
+ /* Check whether an MTRR already covers this region. If not, take an
+ unused one if possible. */
+ for (i = 0; i < var_mtrrs; i++)
+ {
+ rdmsr (mtrr_mask (i), eax, edx);
+ mask_lo = eax;
+ mask_hi = edx;
+ if (mask_lo & 0x800) /* valid */
+ {
+ grub_uint64_t real_base, real_mask;
+
+ rdmsr (mtrr_base (i), eax, edx);
+ base_lo = eax;
+ base_hi = edx;
+
+ real_base = ((grub_uint64_t) (base_hi & bits_hi) << 32) |
+ (base_lo & bits_lo);
+ real_mask = ((grub_uint64_t) (mask_hi & bits_hi) << 32) |
+ (mask_lo & bits_lo);
+ if (real_base < (fb_base + fb_size) &&
+ real_base + (~real_mask & bits) >= fb_base)
+ return; /* existing MTRR overlaps this region */
+ }
+ else if (first_unused < 0)
+ first_unused = i;
+ }
+
+ if (first_unused < 0)
+ return; /* all MTRRs in use */
+
+ /* Set up the first unused MTRR we found. */
+ rdmsr (mtrr_base (first_unused), eax, edx);
+ base_lo = eax;
+ base_hi = edx;
+ rdmsr (mtrr_mask (first_unused), eax, edx);
+ mask_lo = eax;
+ mask_hi = edx;
+
+ base_lo = (base_lo & ~bits_lo & ~0xFF) |
+ (fb_base & bits_lo) | 0x01 /* WC */;
+ base_hi = (base_hi & ~bits_hi) | ((fb_base >> 32) & bits_hi);
+ wrmsr (mtrr_base (first_unused), base_lo, base_hi);
+ mask_lo = (mask_lo & ~bits_lo) | (fb_mask & bits_lo) | 0x800 /* valid */;
+ mask_hi = (mask_hi & ~bits_hi) | ((fb_mask >> 32) & bits_hi);
+ wrmsr (mtrr_mask (first_unused), mask_lo, mask_hi);
+
+ framebuffer.mtrr = first_unused;
+}
+
+static void
+grub_vbe_disable_mtrr (int mtrr)
+{
+ grub_uint32_t eax, edx;
+ grub_uint32_t mask_lo, mask_hi;
+
+ rdmsr (mtrr_mask (mtrr), eax, edx);
+ mask_lo = eax;
+ mask_hi = edx;
+
+ mask_lo &= ~0x800 /* valid */;
+ wrmsr (mtrr_mask (mtrr), mask_lo, mask_hi);
+}
+
+/* Call VESA BIOS 0x4f09 to set palette data, return status. */
+static grub_vbe_status_t
+grub_vbe_bios_set_palette_data (grub_uint32_t color_count,
+ grub_uint32_t start_index,
+ struct grub_vbe_palette_data *palette_data)
+{
+ struct grub_bios_int_registers regs;
+ regs.eax = 0x4f09;
+ regs.ebx = 0;
+ regs.ecx = color_count;
+ regs.edx = start_index;
+ regs.es = (((grub_addr_t) palette_data) & 0xffff0000) >> 4;
+ regs.edi = ((grub_addr_t) palette_data) & 0xffff;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f00 to get VBE Controller Information, return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_controller_info (struct grub_vbe_info_block *ci)
+{
+ struct grub_bios_int_registers regs;
+ /* Store *controller_info to %es:%di. */
+ regs.es = (((grub_addr_t) ci) & 0xffff0000) >> 4;
+ regs.edi = ((grub_addr_t) ci) & 0xffff;
+ regs.eax = 0x4f00;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f01 to get VBE Mode Information, return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_mode_info (grub_uint32_t mode,
+ struct grub_vbe_mode_info_block *mode_info)
+{
+ struct grub_bios_int_registers regs;
+ regs.eax = 0x4f01;
+ regs.ecx = mode;
+ /* Store *mode_info to %es:%di. */
+ regs.es = ((grub_addr_t) mode_info & 0xffff0000) >> 4;
+ regs.edi = (grub_addr_t) mode_info & 0x0000ffff;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f02 to set video mode, return status. */
+static grub_vbe_status_t
+grub_vbe_bios_set_mode (grub_uint32_t mode,
+ struct grub_vbe_crtc_info_block *crtc_info)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x4f02;
+ regs.ebx = mode;
+ /* Store *crtc_info to %es:%di. */
+ regs.es = (((grub_addr_t) crtc_info) & 0xffff0000) >> 4;
+ regs.edi = ((grub_addr_t) crtc_info) & 0xffff;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f03 to return current VBE Mode, return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_mode (grub_uint32_t *mode)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x4f03;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ *mode = regs.ebx & 0xffff;
+
+ return regs.eax & 0xffff;
+}
+
+grub_vbe_status_t
+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) | (set ? 1 : 0);
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ *dac_mask_size = (regs.ebx >> 8) & 0xff;
+
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f05 to set memory window, return status. */
+grub_vbe_status_t
+grub_vbe_bios_set_memory_window (grub_uint32_t window,
+ grub_uint32_t position)
+{
+ struct grub_bios_int_registers regs;
+
+ /* BL = window, BH = 0, Set memory window. */
+ regs.ebx = window & 0x00ff;
+ regs.edx = position;
+ regs.eax = 0x4f05;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f05 to return memory window, return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_memory_window (grub_uint32_t window,
+ grub_uint32_t *position)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x4f05;
+ /* BH = 1, Get memory window. BL = window. */
+ regs.ebx = (window & 0x00ff) | 0x100;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+
+ *position = regs.edx & 0xffff;
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f06 to set scanline length (in bytes), return status. */
+grub_vbe_status_t
+grub_vbe_bios_set_scanline_length (grub_uint32_t length)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.ecx = length;
+ regs.eax = 0x4f06;
+ /* BL = 2, Set Scan Line in Bytes. */
+ regs.ebx = 0x0002;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f06 to return scanline length (in bytes), return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_scanline_length (grub_uint32_t *length)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x4f06;
+ regs.ebx = 0x0001;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ /* BL = 1, Get Scan Line Length (in bytes). */
+ grub_bios_interrupt (0x10, &regs);
+
+ *length = regs.ebx & 0xffff;
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f07 to set display start, return status. */
+static grub_vbe_status_t
+grub_vbe_bios_set_display_start (grub_uint32_t x, grub_uint32_t y)
+{
+ struct grub_bios_int_registers regs;
+
+ if (framebuffer.mtrr >= 0)
+ grub_vbe_disable_mtrr (framebuffer.mtrr);
+
+ /* Store x in %ecx. */
+ regs.ecx = x;
+ regs.edx = y;
+ regs.eax = 0x4f07;
+ /* BL = 80h, Set Display Start during Vertical Retrace. */
+ regs.ebx = 0x0080;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+
+ if (framebuffer.mtrr >= 0)
+ grub_vbe_enable_mtrr_entry (framebuffer.mtrr);
+
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f07 to get display start, return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_display_start (grub_uint32_t *x,
+ grub_uint32_t *y)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x4f07;
+ /* BL = 1, Get Display Start. */
+ regs.ebx = 0x0001;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+
+ *x = regs.ecx & 0xffff;
+ *y = regs.edx & 0xffff;
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f0a. */
+grub_vbe_status_t
+grub_vbe_bios_get_pm_interface (grub_uint16_t *segment, grub_uint16_t *offset,
+ grub_uint16_t *length)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x4f0a;
+ regs.ebx = 0x0000;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+
+ if ((regs.eax & 0xffff) != GRUB_VBE_STATUS_OK)
+ {
+ *segment = 0;
+ *offset = 0;
+ *length = 0;
+ }
+
+ *segment = regs.es & 0xffff;
+ *offset = regs.edi & 0xffff;
+ *length = regs.ecx & 0xffff;
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f11 to get flat panel information, return status. */
+static grub_vbe_status_t
+grub_vbe_bios_get_flat_panel_info (struct grub_vbe_flat_panel_info *flat_panel_info)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x4f11;
+ regs.ebx = 0x0001;
+ regs.es = (((grub_addr_t) flat_panel_info) & 0xffff0000) >> 4;
+ regs.edi = ((grub_addr_t) flat_panel_info) & 0xffff;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f15 to get DDC availability, return status. */
+static grub_vbe_status_t
+grub_vbe_bios_get_ddc_capabilities (grub_uint8_t *level)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x4f15;
+ regs.ebx = 0x0000;
+ regs.ecx = 0x0000;
+ regs.es = 0x0000;
+ regs.edi = 0x0000;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+
+ *level = regs.ebx & 0xff;
+ return regs.eax & 0xffff;
+}
+
+/* Call VESA BIOS 0x4f15 to read EDID information, return status. */
+static grub_vbe_status_t
+grub_vbe_bios_read_edid (struct grub_video_edid_info *edid_info)
+{
+ struct grub_bios_int_registers regs;
+
+ regs.eax = 0x4f15;
+ regs.ebx = 0x0001;
+ regs.ecx = 0x0000;
+ regs.edx = 0x0000;
+ regs.es = (((grub_addr_t) edid_info) & 0xffff0000) >> 4;
+ regs.edi = ((grub_addr_t) edid_info) & 0xffff;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+ return regs.eax & 0xffff;
+}
+
+grub_err_t
+grub_vbe_probe (struct grub_vbe_info_block *info_block)
+{
+ struct grub_vbe_info_block *vbe_ib;
+ grub_vbe_status_t status;
+
+ /* Clear caller's controller info block. */
+ if (info_block)
+ grub_memset (info_block, 0, sizeof (*info_block));
+
+ /* Do not probe more than one time, if not necessary. */
+ if (vbe_detected == -1 || info_block)
+ {
+ /* Clear old copy of controller info block. */
+ grub_memset (&controller_info, 0, sizeof (controller_info));
+
+ /* Mark VESA BIOS extension as undetected. */
+ vbe_detected = 0;
+
+ /* Use low memory scratch area as temporary storage
+ for VESA BIOS call. */
+ vbe_ib = (struct grub_vbe_info_block *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+
+ /* Prepare info block. */
+ grub_memset (vbe_ib, 0, sizeof (*vbe_ib));
+
+ vbe_ib->signature[0] = 'V';
+ vbe_ib->signature[1] = 'B';
+ vbe_ib->signature[2] = 'E';
+ vbe_ib->signature[3] = '2';
+
+ /* Try to get controller info block. */
+ status = grub_vbe_bios_get_controller_info (vbe_ib);
+ if (status == GRUB_VBE_STATUS_OK)
+ {
+ /* Copy it for later usage. */
+ grub_memcpy (&controller_info, vbe_ib, sizeof (controller_info));
+
+ /* Mark VESA BIOS extension as detected. */
+ vbe_detected = 1;
+ }
+ }
+
+ if (! vbe_detected)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "VESA BIOS Extension not found");
+
+ /* Make copy of controller info block to caller. */
+ if (info_block)
+ grub_memcpy (info_block, &controller_info, sizeof (*info_block));
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_vbe_get_edid (struct grub_video_edid_info *edid_info)
+{
+ struct grub_video_edid_info *edid_info_lowmem;
+
+ /* Use low memory scratch area as temporary storage for VESA BIOS calls. */
+ edid_info_lowmem =
+ (struct grub_video_edid_info *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ grub_memset (edid_info_lowmem, 0, sizeof (*edid_info_lowmem));
+
+ if (grub_vbe_bios_read_edid (edid_info_lowmem) != GRUB_VBE_STATUS_OK)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "EDID information not available");
+
+ grub_memcpy (edid_info, edid_info_lowmem, sizeof (*edid_info));
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_vbe_get_preferred_mode (unsigned int *width, unsigned int *height)
+{
+ grub_vbe_status_t status;
+ grub_uint8_t ddc_level;
+ struct grub_video_edid_info edid_info;
+ struct grub_vbe_flat_panel_info *flat_panel_info;
+
+ /* Use low memory scratch area as temporary storage for VESA BIOS calls. */
+ flat_panel_info = (struct grub_vbe_flat_panel_info *)
+ (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + sizeof (struct grub_video_edid_info));
+
+ if (controller_info.version >= 0x200
+ && (grub_vbe_bios_get_ddc_capabilities (&ddc_level) & 0xff)
+ == GRUB_VBE_STATUS_OK)
+ {
+ if (grub_video_vbe_get_edid (&edid_info) == GRUB_ERR_NONE
+ && grub_video_edid_checksum (&edid_info) == GRUB_ERR_NONE
+ && grub_video_edid_preferred_mode (&edid_info, width, height)
+ == GRUB_ERR_NONE && *width < 4096 && *height < 4096)
+ return GRUB_ERR_NONE;
+
+ grub_errno = GRUB_ERR_NONE;
+ }
+
+ grub_memset (flat_panel_info, 0, sizeof (*flat_panel_info));
+ status = grub_vbe_bios_get_flat_panel_info (flat_panel_info);
+ if (status == GRUB_VBE_STATUS_OK
+ && flat_panel_info->horizontal_size && flat_panel_info->vertical_size
+ && flat_panel_info->horizontal_size < 4096
+ && flat_panel_info->vertical_size < 4096)
+ {
+ *width = flat_panel_info->horizontal_size;
+ *height = flat_panel_info->vertical_size;
+ return GRUB_ERR_NONE;
+ }
+
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot get preferred mode");
+}
+
+static grub_err_t
+grub_vbe_set_video_mode (grub_uint32_t vbe_mode,
+ struct grub_vbe_mode_info_block *vbe_mode_info)
+{
+ grub_vbe_status_t status;
+ grub_uint32_t old_vbe_mode;
+ struct grub_vbe_mode_info_block new_vbe_mode_info;
+ grub_err_t err;
+
+ /* Make sure that VBE is supported. */
+ grub_vbe_probe (0);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* Try to get mode info. */
+ grub_vbe_get_video_mode_info (vbe_mode, &new_vbe_mode_info);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* For all VESA BIOS modes, force linear frame buffer. */
+ if (vbe_mode >= 0x100)
+ {
+ /* We only want linear frame buffer modes. */
+ vbe_mode |= 1 << 14;
+
+ /* Determine frame buffer pixel format. */
+ if (new_vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL
+ && new_vbe_mode_info.memory_model
+ != GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unsupported pixel format 0x%x",
+ new_vbe_mode_info.memory_model);
+ }
+
+ /* Get current mode. */
+ grub_vbe_get_video_mode (&old_vbe_mode);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* Try to set video mode. */
+ status = grub_vbe_bios_set_mode (vbe_mode, 0);
+ if (status != GRUB_VBE_STATUS_OK)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "cannot set VBE mode %x", vbe_mode);
+ last_set_mode = vbe_mode;
+
+ if (vbe_mode < 0x100)
+ {
+ /* If this is not a VESA mode, guess address. */
+ framebuffer.ptr = (grub_uint8_t *) 0xa0000;
+ }
+ else
+ {
+ framebuffer.ptr = (grub_uint8_t *) new_vbe_mode_info.phys_base_addr;
+ }
+
+ /* Check whether mode is text mode or graphics mode. */
+ if (new_vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_TEXT)
+ {
+ /* Text mode. */
+
+ /* No special action needed for text mode as it is not supported for
+ graphical support. */
+ }
+ else
+ {
+ /* Graphics mode. */
+
+ /* If video mode is in indexed color, setup default VGA palette. */
+ if (vbe_mode < 0x100 || new_vbe_mode_info.memory_model
+ == GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL)
+ {
+ struct grub_vbe_palette_data *palette
+ = (struct grub_vbe_palette_data *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ unsigned i;
+
+ /* Make sure that the BIOS can reach the palette. */
+ for (i = 0; i < GRUB_VIDEO_FBSTD_NUMCOLORS; i++)
+ {
+ palette[i].red = grub_video_fbstd_colors[i].r;
+ palette[i].green = grub_video_fbstd_colors[i].g;
+ palette[i].blue = grub_video_fbstd_colors[i].b;
+ palette[i].alignment = 0;
+ }
+
+ status = grub_vbe_bios_set_palette_data (GRUB_VIDEO_FBSTD_NUMCOLORS,
+ 0, palette);
+
+ /* Just ignore the status. */
+ err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+ if (err)
+ return err;
+
+ }
+ }
+
+ /* Copy mode info for caller. */
+ if (vbe_mode_info)
+ grub_memcpy (vbe_mode_info, &new_vbe_mode_info, sizeof (*vbe_mode_info));
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_vbe_get_video_mode (grub_uint32_t *mode)
+{
+ grub_vbe_status_t status;
+
+ /* Make sure that VBE is supported. */
+ grub_vbe_probe (0);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* Try to query current mode from VESA BIOS. */
+ status = grub_vbe_bios_get_mode (mode);
+ /* XXX: ATI cards don't support get_mode. */
+ if (status != GRUB_VBE_STATUS_OK)
+ *mode = last_set_mode;
+
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_vbe_get_video_mode_info (grub_uint32_t mode,
+ struct grub_vbe_mode_info_block *mode_info)
+{
+ struct grub_vbe_mode_info_block *mi_tmp
+ = (struct grub_vbe_mode_info_block *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ grub_vbe_status_t status;
+
+ /* Make sure that VBE is supported. */
+ grub_vbe_probe (0);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* If mode is not VESA mode, skip mode info query. */
+ if (mode >= 0x100)
+ {
+ /* Try to get mode info from VESA BIOS. */
+ status = grub_vbe_bios_get_mode_info (mode, mi_tmp);
+ if (status != GRUB_VBE_STATUS_OK)
+ return grub_error (GRUB_ERR_BAD_DEVICE,
+ "cannot get information on the mode %x", mode);
+
+ /* Make copy of mode info block. */
+ grub_memcpy (mode_info, mi_tmp, sizeof (*mode_info));
+ }
+ else
+ /* Just clear mode info block if it isn't a VESA mode. */
+ grub_memset (mode_info, 0, sizeof (*mode_info));
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_vbe_init (void)
+{
+ grub_uint16_t *rm_vbe_mode_list;
+ grub_uint16_t *p;
+ grub_size_t vbe_mode_list_size;
+ struct grub_vbe_info_block info_block;
+
+ /* Check if there is adapter present.
+
+ Firmware note: There has been a report that some cards store video mode
+ list in temporary memory. So we must first use vbe probe to get
+ refreshed information to receive valid pointers and data, and then
+ copy this information to somewhere safe. */
+ grub_vbe_probe (&info_block);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* Copy modelist to local memory. */
+ p = rm_vbe_mode_list = real2pm (info_block.video_mode_ptr);
+ while(*p++ != 0xFFFF)
+ ;
+
+ vbe_mode_list_size = (grub_addr_t) p - (grub_addr_t) rm_vbe_mode_list;
+ vbe_mode_list = grub_malloc (vbe_mode_list_size);
+ if (! vbe_mode_list)
+ return grub_errno;
+ grub_memcpy (vbe_mode_list, rm_vbe_mode_list, vbe_mode_list_size);
+
+ /* Adapter could be found, figure out initial video mode. */
+ grub_vbe_get_video_mode (&initial_vbe_mode);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ /* Free allocated resources. */
+ grub_free (vbe_mode_list);
+ vbe_mode_list = NULL;
+
+ return grub_errno;
+ }
+
+ /* Reset frame buffer. */
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+ framebuffer.mtrr = -1;
+
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_vbe_fini (void)
+{
+ grub_vbe_status_t status;
+ grub_err_t err;
+
+ /* Restore old video mode. */
+ if (last_set_mode != initial_vbe_mode)
+ {
+ status = grub_vbe_bios_set_mode (initial_vbe_mode, 0);
+ if (status != GRUB_VBE_STATUS_OK)
+ /* TODO: Decide, is this something we want to do. */
+ return grub_errno;
+ }
+ last_set_mode = initial_vbe_mode;
+
+ /* TODO: Free any resources allocated by driver. */
+ grub_free (vbe_mode_list);
+ vbe_mode_list = NULL;
+
+ err = grub_video_fb_fini ();
+ if (framebuffer.mtrr >= 0)
+ {
+ grub_vbe_disable_mtrr (framebuffer.mtrr);
+ framebuffer.mtrr = -1;
+ }
+ return err;
+}
+
+/*
+ Set framebuffer render target page and display the proper page, based on
+ `doublebuf_state.render_page' and `doublebuf_state.displayed_page',
+ respectively.
+*/
+static grub_err_t
+doublebuf_pageflipping_set_page (int page)
+{
+ /* Tell the video adapter to display the new front page. */
+ int display_start_line
+ = framebuffer.mode_info.height * page;
+
+ grub_vbe_status_t vbe_err =
+ grub_vbe_bios_set_display_start (0, display_start_line);
+
+ if (vbe_err != GRUB_VBE_STATUS_OK)
+ return grub_error (GRUB_ERR_IO, "couldn't commit pageflip");
+
+ return 0;
+}
+
+static void
+vbe2videoinfo (grub_uint32_t mode,
+ const struct grub_vbe_mode_info_block *vbeinfo,
+ struct grub_video_mode_info *mode_info)
+{
+ mode_info->mode_number = mode;
+
+ mode_info->width = vbeinfo->x_resolution;
+ mode_info->height = vbeinfo->y_resolution;
+ mode_info->mode_type = 0;
+ switch (vbeinfo->memory_model)
+ {
+ case GRUB_VBE_MEMORY_MODEL_TEXT:
+ mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_PURE_TEXT;
+ break;
+
+ /* 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;
+
+ case GRUB_VBE_MEMORY_MODEL_HERCULES:
+ mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_HERCULES
+ | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
+ break;
+
+ /* 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;
+ break;
+
+ case GRUB_VBE_MEMORY_MODEL_YUV:
+ mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_YUV;
+ break;
+
+ case GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR:
+ mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_RGB;
+ break;
+ default:
+ mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_UNKNOWN;
+ break;
+ }
+
+ mode_info->bpp = vbeinfo->bits_per_pixel;
+ /* Calculate bytes_per_pixel value. */
+ switch(vbeinfo->bits_per_pixel)
+ {
+ case 32:
+ mode_info->bytes_per_pixel = 4;
+ break;
+ case 24:
+ mode_info->bytes_per_pixel = 3;
+ break;
+ case 16:
+ mode_info->bytes_per_pixel = 2;
+ break;
+ case 15:
+ mode_info->bytes_per_pixel = 2;
+ break;
+ case 8:
+ mode_info->bytes_per_pixel = 1;
+ break;
+ case 4:
+ mode_info->bytes_per_pixel = 0;
+ break;
+ }
+
+ if (controller_info.version >= 0x300)
+ mode_info->pitch = vbeinfo->lin_bytes_per_scan_line;
+ else
+ mode_info->pitch = vbeinfo->bytes_per_scan_line;
+
+ if (mode_info->mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
+ mode_info->number_of_colors = 16;
+ else
+ mode_info->number_of_colors = 256;
+ mode_info->red_mask_size = vbeinfo->red_mask_size;
+ mode_info->red_field_pos = vbeinfo->red_field_position;
+ mode_info->green_mask_size = vbeinfo->green_mask_size;
+ mode_info->green_field_pos = vbeinfo->green_field_position;
+ mode_info->blue_mask_size = vbeinfo->blue_mask_size;
+ mode_info->blue_field_pos = vbeinfo->blue_field_position;
+ mode_info->reserved_mask_size = vbeinfo->rsvd_mask_size;
+ mode_info->reserved_field_pos = vbeinfo->rsvd_field_position;
+
+ mode_info->blit_format = grub_video_get_blit_format (mode_info);
+}
+
+static int
+grub_video_vbe_iterate (int (*hook) (const struct grub_video_mode_info *info, void *hook_arg), void *hook_arg)
+{
+ grub_uint16_t *p;
+ struct grub_vbe_mode_info_block vbe_mode_info;
+ struct grub_video_mode_info mode_info;
+
+ for (p = vbe_mode_list; *p != 0xFFFF; p++)
+ {
+ grub_vbe_get_video_mode_info (*p, &vbe_mode_info);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ /* Could not retrieve mode info, retreat. */
+ grub_errno = GRUB_ERR_NONE;
+ break;
+ }
+
+ vbe2videoinfo (*p, &vbe_mode_info, &mode_info);
+ if (hook (&mode_info, hook_arg))
+ return 1;
+ }
+ return 0;
+}
+
+static grub_err_t
+grub_video_vbe_setup (unsigned int width, unsigned int height,
+ grub_video_mode_type_t mode_type,
+ grub_video_mode_type_t mode_mask)
+{
+ grub_uint16_t *p;
+ struct grub_vbe_mode_info_block vbe_mode_info;
+ struct grub_vbe_mode_info_block best_vbe_mode_info;
+ grub_uint32_t best_vbe_mode = 0;
+ int depth;
+ int preferred_mode = 0;
+
+ /* Decode depth from mode_type. If it is zero, then autodetect. */
+ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
+
+ if (width == 0 && height == 0)
+ {
+ grub_vbe_get_preferred_mode (&width, &height);
+ if (grub_errno == GRUB_ERR_NONE)
+ preferred_mode = 1;
+ else
+ {
+ /* Fall back to 640x480. This is conservative, but the largest
+ mode supported by the graphics card may not be safe for the
+ display device. */
+ grub_errno = GRUB_ERR_NONE;
+ width = 640;
+ height = 480;
+ }
+ }
+
+ /* Walk thru mode list and try to find matching mode. */
+ for (p = vbe_mode_list; *p != 0xFFFF; p++)
+ {
+ grub_uint32_t vbe_mode = *p;
+
+ grub_vbe_get_video_mode_info (vbe_mode, &vbe_mode_info);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ /* Could not retrieve mode info, retreat. */
+ grub_errno = GRUB_ERR_NONE;
+ break;
+ }
+
+ if ((vbe_mode_info.mode_attributes & GRUB_VBE_MODEATTR_SUPPORTED) == 0)
+ /* If not available, skip it. */
+ continue;
+
+ if ((vbe_mode_info.mode_attributes & GRUB_VBE_MODEATTR_COLOR) == 0)
+ /* Monochrome is unusable. */
+ continue;
+
+ if ((vbe_mode_info.mode_attributes & GRUB_VBE_MODEATTR_LFB_AVAIL) == 0)
+ /* We support only linear frame buffer modes. */
+ continue;
+
+ if ((vbe_mode_info.mode_attributes & GRUB_VBE_MODEATTR_GRAPHICS) == 0)
+ /* We allow only graphical modes. */
+ continue;
+
+ if ((vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL)
+ && (vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR))
+ /* Not compatible memory model. */
+ continue;
+
+ if (vbe_mode_info.bits_per_pixel != 8
+ && vbe_mode_info.bits_per_pixel != 15
+ && vbe_mode_info.bits_per_pixel != 16
+ && vbe_mode_info.bits_per_pixel != 24
+ && vbe_mode_info.bits_per_pixel != 32)
+ /* Unsupported bitdepth . */
+ continue;
+
+ if (preferred_mode)
+ {
+ if (vbe_mode_info.x_resolution > width
+ || vbe_mode_info.y_resolution > height)
+ /* Resolution exceeds that of preferred mode. */
+ continue;
+ }
+ else
+ {
+ if (((vbe_mode_info.x_resolution != width)
+ || (vbe_mode_info.y_resolution != height))
+ && width != 0 && height != 0)
+ /* Non matching resolution. */
+ continue;
+ }
+
+ /* Check if user requested RGB or index color mode. */
+ if ((mode_mask & GRUB_VIDEO_MODE_TYPE_COLOR_MASK) != 0)
+ {
+ unsigned my_mode_type = 0;
+
+ if (vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL)
+ my_mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
+
+ if (vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)
+ my_mode_type |= GRUB_VIDEO_MODE_TYPE_RGB;
+
+ if ((my_mode_type & mode_mask
+ & (GRUB_VIDEO_MODE_TYPE_RGB | GRUB_VIDEO_MODE_TYPE_INDEX_COLOR))
+ != (mode_type & mode_mask
+ & (GRUB_VIDEO_MODE_TYPE_RGB
+ | GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)))
+ continue;
+ }
+
+ /* If there is a request for specific depth, ignore others. */
+ if ((depth != 0) && (vbe_mode_info.bits_per_pixel != depth))
+ continue;
+
+ /* Select mode with most of "volume" (size of framebuffer in bits). */
+ if (best_vbe_mode != 0)
+ if ((grub_uint64_t) vbe_mode_info.bits_per_pixel
+ * vbe_mode_info.x_resolution * vbe_mode_info.y_resolution
+ < (grub_uint64_t) best_vbe_mode_info.bits_per_pixel
+ * best_vbe_mode_info.x_resolution * best_vbe_mode_info.y_resolution)
+ continue;
+
+ /* Save so far best mode information for later use. */
+ best_vbe_mode = vbe_mode;
+ grub_memcpy (&best_vbe_mode_info, &vbe_mode_info, sizeof (vbe_mode_info));
+ }
+
+ /* Try to initialize best mode found. */
+ if (best_vbe_mode != 0)
+ {
+ grub_err_t err;
+ static struct grub_vbe_mode_info_block active_vbe_mode_info;
+ /* If this fails, then we have mode selection heuristics problem,
+ or adapter failure. */
+ grub_vbe_set_video_mode (best_vbe_mode, &active_vbe_mode_info);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ /* Fill mode info details. */
+ vbe2videoinfo (best_vbe_mode, &active_vbe_mode_info,
+ &framebuffer.mode_info);
+
+ {
+ /* Get video RAM size in bytes. */
+ grub_size_t vram_size = controller_info.total_memory << 16;
+ grub_size_t page_size; /* The size of a page in bytes. */
+
+ page_size = framebuffer.mode_info.pitch * framebuffer.mode_info.height;
+
+ if (vram_size >= 2 * page_size)
+ err = grub_video_fb_setup (mode_type, mode_mask,
+ &framebuffer.mode_info,
+ framebuffer.ptr,
+ doublebuf_pageflipping_set_page,
+ framebuffer.ptr + page_size);
+ else
+ err = grub_video_fb_setup (mode_type, mode_mask,
+ &framebuffer.mode_info,
+ framebuffer.ptr, 0, 0);
+ }
+
+ /* Copy default palette to initialize emulated palette. */
+ err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+
+ grub_vbe_enable_mtrr (framebuffer.ptr,
+ controller_info.total_memory << 16);
+
+ return err;
+ }
+
+ /* Couldn't found matching mode. */
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found");
+}
+
+static grub_err_t
+grub_video_vbe_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data)
+{
+ if (framebuffer.mode_info.mode_type == GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
+ {
+ /* TODO: Implement setting indexed color mode palette to hardware. */
+ //status = grub_vbe_bios_set_palette_data (sizeof (vga_colors)
+ // / sizeof (struct grub_vbe_palette_data),
+ // 0,
+ // palette);
+
+ }
+
+ /* Then set color to emulated palette. */
+
+ return grub_video_fb_set_palette (start, count, palette_data);
+}
+
+static grub_err_t
+grub_video_vbe_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ grub_err_t err;
+ grub_free (vbe_mode_list);
+ vbe_mode_list = NULL;
+ err = grub_video_fb_get_info_and_fini (mode_info, framebuf);
+ if (err)
+ return err;
+ if (framebuffer.mtrr >= 0)
+ {
+ grub_vbe_disable_mtrr (framebuffer.mtrr);
+ framebuffer.mtrr = -1;
+ }
+ return GRUB_ERR_NONE;
+}
+
+static void
+grub_video_vbe_print_adapter_specific_info (void)
+{
+ grub_printf_ (N_(" VBE info: version: %d.%d OEM software rev: %d.%d\n"),
+ controller_info.version >> 8,
+ controller_info.version & 0xFF,
+ controller_info.oem_software_rev >> 8,
+ controller_info.oem_software_rev & 0xFF);
+
+ /* The total_memory field is in 64 KiB units. */
+ grub_printf_ (N_(" total memory: %d KiB\n"),
+ (controller_info.total_memory << 6));
+}
+
+static struct grub_video_adapter grub_video_vbe_adapter =
+ {
+ .name = "VESA BIOS Extension Video Driver",
+ .id = GRUB_VIDEO_DRIVER_VBE,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
+
+ .init = grub_video_vbe_init,
+ .fini = grub_video_vbe_fini,
+ .setup = grub_video_vbe_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_vbe_get_info_and_fini,
+ .set_palette = grub_video_vbe_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_fb_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_fb_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+ .iterate = grub_video_vbe_iterate,
+ .get_edid = grub_video_vbe_get_edid,
+ .print_adapter_specific_info = grub_video_vbe_print_adapter_specific_info,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(video_i386_pc_vbe)
+{
+ grub_video_register (&grub_video_vbe_adapter);
+}
+
+GRUB_MOD_FINI(video_i386_pc_vbe)
+{
+ grub_video_unregister (&grub_video_vbe_adapter);
+}
diff --git a/grub-core/video/i386/pc/vga.c b/grub-core/video/i386/pc/vga.c
new file mode 100644
index 0000000..b2f776c
--- /dev/null
+++ b/grub-core/video/i386/pc/vga.c
@@ -0,0 +1,404 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/i386/pc/int.h>
+#include <grub/machine/console.h>
+#include <grub/cpu/io.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/vga.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define VGA_WIDTH 640
+#define VGA_MEM ((grub_uint8_t *) 0xa0000)
+#define PAGE_OFFSET(x) ((x) * (VGA_WIDTH * vga_height / 8))
+
+static unsigned char text_mode;
+static unsigned char saved_map_mask;
+static int vga_height;
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+ struct grub_video_render_target *render_target;
+ grub_uint8_t *temporary_buffer;
+ int front_page;
+ int back_page;
+} framebuffer;
+
+static unsigned char
+grub_vga_set_mode (unsigned char mode)
+{
+ struct grub_bios_int_registers regs;
+ unsigned char ret;
+ /* get current mode */
+ regs.eax = 0x0f00;
+ regs.ebx = 0;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+
+ ret = regs.eax & 0xff;
+ regs.eax = mode;
+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
+ grub_bios_interrupt (0x10, &regs);
+
+ return ret;
+}
+
+static inline void
+wait_vretrace (void)
+{
+ /* Wait until there is a vertical retrace. */
+ while (! (grub_inb (GRUB_VGA_IO_INPUT_STATUS1_REGISTER)
+ & GRUB_VGA_IO_INPUT_STATUS1_VERTR_BIT));
+}
+
+/* Get Map Mask Register. */
+static unsigned char
+get_map_mask (void)
+{
+ return grub_vga_sr_read (GRUB_VGA_SR_MAP_MASK_REGISTER);
+}
+
+/* Set Map Mask Register. */
+static void
+set_map_mask (unsigned char mask)
+{
+ grub_vga_sr_write (mask, GRUB_VGA_SR_MAP_MASK_REGISTER);
+}
+
+#if 0
+/* Set Read Map Register. */
+static void
+set_read_map (unsigned char map)
+{
+ grub_vga_gr_write (map, GRUB_VGA_GR_READ_MAP_REGISTER);
+}
+#endif
+
+/* Set start address. */
+static void
+set_start_address (unsigned int start)
+{
+ grub_vga_cr_write (start & 0xFF, GRUB_VGA_CR_START_ADDR_LOW_REGISTER);
+ grub_vga_cr_write (start >> 8, GRUB_VGA_CR_START_ADDR_HIGH_REGISTER);
+}
+
+static int setup = 0;
+static int is_target = 0;
+
+static grub_err_t
+grub_video_vga_init (void)
+{
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_vga_setup (unsigned int width, unsigned int height,
+ grub_video_mode_type_t mode_type,
+ grub_video_mode_type_t mode_mask)
+{
+ grub_err_t err;
+
+ if ((width && width != VGA_WIDTH) || (height && height != 350 && height != 480))
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found");
+
+ vga_height = height ? : 480;
+
+ framebuffer.temporary_buffer = grub_calloc (vga_height, VGA_WIDTH);
+ framebuffer.front_page = 0;
+ framebuffer.back_page = 0;
+ if (!framebuffer.temporary_buffer)
+ return grub_errno;
+
+ saved_map_mask = get_map_mask ();
+
+ text_mode = grub_vga_set_mode (vga_height == 480 ? 0x12 : 0x10);
+ setup = 1;
+ set_map_mask (0x0f);
+ set_start_address (PAGE_OFFSET (framebuffer.front_page));
+
+ framebuffer.mode_info.width = VGA_WIDTH;
+ framebuffer.mode_info.height = vga_height;
+
+ framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
+
+ if (grub_video_check_mode_flag (mode_type, mode_mask,
+ GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED,
+ (VGA_WIDTH * vga_height <= (1 << 18))))
+ {
+ framebuffer.back_page = 1;
+ framebuffer.mode_info.mode_type |= GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED
+ | GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP;
+ }
+
+ framebuffer.mode_info.bpp = 8;
+ framebuffer.mode_info.bytes_per_pixel = 1;
+ framebuffer.mode_info.pitch = VGA_WIDTH;
+ framebuffer.mode_info.number_of_colors = 16;
+ framebuffer.mode_info.red_mask_size = 0;
+ framebuffer.mode_info.red_field_pos = 0;
+ framebuffer.mode_info.green_mask_size = 0;
+ framebuffer.mode_info.green_field_pos = 0;
+ framebuffer.mode_info.blue_mask_size = 0;
+ framebuffer.mode_info.blue_field_pos = 0;
+ framebuffer.mode_info.reserved_mask_size = 0;
+ framebuffer.mode_info.reserved_field_pos = 0;
+
+ framebuffer.mode_info.blit_format
+ = grub_video_get_blit_format (&framebuffer.mode_info);
+
+ err = grub_video_fb_create_render_target_from_pointer (&framebuffer.render_target,
+ &framebuffer.mode_info,
+ framebuffer.temporary_buffer);
+
+ if (err)
+ {
+ grub_dprintf ("video", "Couldn't create FB target\n");
+ return err;
+ }
+
+ is_target = 1;
+ err = grub_video_fb_set_active_render_target (framebuffer.render_target);
+
+ if (err)
+ return err;
+
+ err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_vga_fini (void)
+{
+ if (setup)
+ {
+ set_map_mask (saved_map_mask);
+ grub_vga_set_mode (text_mode);
+ }
+ setup = 0;
+ grub_free (framebuffer.temporary_buffer);
+ framebuffer.temporary_buffer = 0;
+ return GRUB_ERR_NONE;
+}
+
+static inline void
+update_target (void)
+{
+ int plane;
+
+ if (!is_target)
+ return;
+
+ for (plane = 0x01; plane <= 0x08; plane <<= 1)
+ {
+ grub_uint8_t *ptr;
+ volatile grub_uint8_t *ptr2;
+ unsigned cbyte = 0;
+ int shift = 7;
+ set_map_mask (plane);
+ for (ptr = framebuffer.temporary_buffer,
+ ptr2 = VGA_MEM + PAGE_OFFSET (framebuffer.back_page);
+ ptr < framebuffer.temporary_buffer + VGA_WIDTH * vga_height; ptr++)
+ {
+ cbyte |= (!!(plane & *ptr)) << shift;
+ shift--;
+ if (shift == -1)
+ {
+ *ptr2++ = cbyte;
+ shift = 7;
+ cbyte = 0;
+ }
+ }
+ }
+}
+
+static grub_err_t
+grub_video_vga_blit_bitmap (struct grub_video_bitmap *bitmap,
+ enum grub_video_blit_operators oper, int x, int y,
+ int offset_x, int offset_y,
+ unsigned int width, unsigned int height)
+{
+ grub_err_t ret;
+ ret = grub_video_fb_blit_bitmap (bitmap, oper, x, y, offset_x, offset_y,
+ width, height);
+ if (!(framebuffer.mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED))
+ update_target ();
+ return ret;
+}
+
+static grub_err_t
+grub_video_vga_blit_render_target (struct grub_video_fbrender_target *source,
+ enum grub_video_blit_operators oper,
+ int x, int y, int offset_x, int offset_y,
+ unsigned int width, unsigned int height)
+{
+ grub_err_t ret;
+
+ ret = grub_video_fb_blit_render_target (source, oper, x, y,
+ offset_x, offset_y, width, height);
+ if (!(framebuffer.mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED))
+ update_target ();
+
+ return ret;
+}
+
+static grub_err_t
+grub_video_vga_set_active_render_target (struct grub_video_render_target *target)
+{
+ if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
+ {
+ is_target = 1;
+ target = framebuffer.render_target;
+ }
+ else
+ is_target = 0;
+
+ return grub_video_fb_set_active_render_target (target);
+}
+
+static grub_err_t
+grub_video_vga_get_active_render_target (struct grub_video_render_target **target)
+{
+ grub_err_t err;
+ err = grub_video_fb_get_active_render_target (target);
+ if (err)
+ return err;
+
+ if (*target == framebuffer.render_target)
+ *target = GRUB_VIDEO_RENDER_TARGET_DISPLAY;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_vga_swap_buffers (void)
+{
+ if (!(framebuffer.mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED))
+ return GRUB_ERR_NONE;
+
+ update_target ();
+
+ if ((VGA_WIDTH * vga_height <= (1 << 18)))
+ {
+ /* Activate the other page. */
+ framebuffer.front_page = !framebuffer.front_page;
+ framebuffer.back_page = !framebuffer.back_page;
+ wait_vretrace ();
+ set_start_address (PAGE_OFFSET (framebuffer.front_page));
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_vga_set_palette (unsigned int start __attribute__ ((unused)),
+ unsigned int count __attribute__ ((unused)),
+ struct grub_video_palette_data *palette_data __attribute__ ((unused)))
+{
+ return grub_error (GRUB_ERR_IO, "can't change palette");
+}
+
+static grub_err_t
+grub_video_vga_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ set_map_mask (0xf);
+
+ grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
+ mode_info->bpp = 1;
+ mode_info->bytes_per_pixel = 0;
+ mode_info->pitch = VGA_WIDTH / 8;
+ mode_info->number_of_colors = 1;
+
+ mode_info->bg_red = 0;
+ mode_info->bg_green = 0;
+ mode_info->bg_blue = 0;
+ mode_info->bg_alpha = 255;
+
+ mode_info->fg_red = 255;
+ mode_info->fg_green = 255;
+ mode_info->fg_blue = 255;
+ mode_info->fg_alpha = 255;
+
+ *framebuf = VGA_MEM + PAGE_OFFSET (framebuffer.front_page);
+
+ grub_video_fb_fini ();
+ grub_free (framebuffer.temporary_buffer);
+ framebuffer.temporary_buffer = 0;
+ setup = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+
+static struct grub_video_adapter grub_video_vga_adapter =
+ {
+ .name = "VGA Video Driver",
+ .id = GRUB_VIDEO_DRIVER_VGA,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_FALLBACK,
+
+ .init = grub_video_vga_init,
+ .fini = grub_video_vga_fini,
+ .setup = grub_video_vga_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_vga_get_info_and_fini,
+ .set_palette = grub_video_vga_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_vga_blit_bitmap,
+ .blit_render_target = grub_video_vga_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_vga_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_vga_set_active_render_target,
+ .get_active_render_target = grub_video_vga_get_active_render_target,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(vga)
+{
+ grub_video_register (&grub_video_vga_adapter);
+}
+
+GRUB_MOD_FINI(vga)
+{
+ grub_video_unregister (&grub_video_vga_adapter);
+}
diff --git a/grub-core/video/ieee1275.c b/grub-core/video/ieee1275.c
new file mode 100644
index 0000000..17a3dbb
--- /dev/null
+++ b/grub-core/video/ieee1275.c
@@ -0,0 +1,370 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/ieee1275/ieee1275.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Only 8-bit indexed color is supported for now. */
+
+static unsigned old_width, old_height;
+static int restore_needed;
+static char *display;
+static grub_ieee1275_ihandle_t stdout_ihandle;
+static int have_setcolors = 0;
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+ grub_uint8_t *ptr;
+} framebuffer;
+
+static struct grub_video_palette_data serial_colors[] =
+ {
+ // {R, G, B}
+ {0x00, 0x00, 0x00, 0xFF}, // 0 = black
+ {0xA8, 0x00, 0x00, 0xFF}, // 1 = red
+ {0x00, 0xA8, 0x00, 0xFF}, // 2 = green
+ {0xFE, 0xFE, 0x54, 0xFF}, // 3 = yellow
+ {0x00, 0x00, 0xA8, 0xFF}, // 4 = blue
+ {0xA8, 0x00, 0xA8, 0xFF}, // 5 = magenta
+ {0x00, 0xA8, 0xA8, 0xFF}, // 6 = cyan
+ {0xFE, 0xFE, 0xFE, 0xFF} // 7 = white
+ };
+
+
+static grub_err_t
+grub_video_ieee1275_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data);
+
+static void
+set_video_mode (unsigned width __attribute__ ((unused)),
+ unsigned height __attribute__ ((unused)))
+{
+ /* TODO */
+}
+
+static int
+find_display_hook (struct grub_ieee1275_devalias *alias)
+{
+ if (grub_strcmp (alias->type, "display") == 0)
+ {
+ grub_dprintf ("video", "Found display %s\n", alias->path);
+ display = grub_strdup (alias->path);
+ return 1;
+ }
+ return 0;
+}
+
+static void
+find_display (void)
+{
+ grub_ieee1275_devices_iterate (find_display_hook);
+}
+
+static grub_err_t
+grub_video_ieee1275_init (void)
+{
+ grub_ssize_t actual;
+
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+
+ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS)
+ && !grub_ieee1275_get_integer_property (grub_ieee1275_chosen,
+ "stdout", &stdout_ihandle,
+ sizeof (stdout_ihandle), &actual)
+ && actual == sizeof (stdout_ihandle))
+ have_setcolors = 1;
+
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_ieee1275_fini (void)
+{
+ if (restore_needed)
+ {
+ set_video_mode (old_width, old_height);
+ restore_needed = 0;
+ }
+ return grub_video_fb_fini ();
+}
+
+static grub_err_t
+grub_video_ieee1275_fill_mode_info (grub_ieee1275_phandle_t dev,
+ struct grub_video_mode_info *out)
+{
+ grub_uint32_t tmp;
+
+ grub_memset (out, 0, sizeof (*out));
+
+ if (grub_ieee1275_get_integer_property (dev, "width", &tmp,
+ sizeof (tmp), 0))
+ return grub_error (GRUB_ERR_IO, "Couldn't retrieve display width.");
+ out->width = tmp;
+
+ if (grub_ieee1275_get_integer_property (dev, "height", &tmp,
+ sizeof (tmp), 0))
+ return grub_error (GRUB_ERR_IO, "Couldn't retrieve display height.");
+ out->height = tmp;
+
+ if (grub_ieee1275_get_integer_property (dev, "linebytes", &tmp,
+ sizeof (tmp), 0))
+ return grub_error (GRUB_ERR_IO, "Couldn't retrieve display pitch.");
+ out->pitch = tmp;
+
+ if (grub_ieee1275_get_integer_property (dev, "depth", &tmp,
+ sizeof (tmp), 0))
+ tmp = 4;
+
+ out->mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
+ out->bpp = tmp;
+ out->bytes_per_pixel = (out->bpp + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT;
+ out->number_of_colors = 256;
+
+ switch (tmp)
+ {
+ case 4:
+ case 8:
+ out->mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
+ out->bpp = 8;
+ if (have_setcolors)
+ out->number_of_colors = 1 << tmp;
+ else
+ out->number_of_colors = 8;
+ break;
+
+ /* FIXME: we may need byteswapping for the following. Currently it
+ was seen only on qemu and no byteswap was needed. */
+ case 15:
+ out->red_mask_size = 5;
+ out->red_field_pos = 10;
+ out->green_mask_size = 5;
+ out->green_field_pos = 5;
+ out->blue_mask_size = 5;
+ out->blue_field_pos = 0;
+ break;
+
+ case 16:
+ out->red_mask_size = 5;
+ out->red_field_pos = 11;
+ out->green_mask_size = 6;
+ out->green_field_pos = 5;
+ out->blue_mask_size = 5;
+ out->blue_field_pos = 0;
+ break;
+
+ case 32:
+ out->reserved_mask_size = 8;
+ out->reserved_field_pos = 24;
+ /* FALLTHROUGH */
+
+ case 24:
+ out->red_mask_size = 8;
+ out->red_field_pos = 16;
+ out->green_mask_size = 8;
+ out->green_field_pos = 8;
+ out->blue_mask_size = 8;
+ out->blue_field_pos = 0;
+ break;
+ default:
+ return grub_error (GRUB_ERR_IO, "unsupported video depth %d", tmp);
+ }
+
+ out->blit_format = grub_video_get_blit_format (out);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_ieee1275_setup (unsigned int width, unsigned int height,
+ unsigned int mode_type __attribute__ ((unused)),
+ unsigned int mode_mask __attribute__ ((unused)))
+{
+ grub_uint32_t current_width, current_height, address;
+ grub_err_t err;
+ grub_ieee1275_phandle_t dev;
+
+ if (!display)
+ return grub_error (GRUB_ERR_IO, "Couldn't find display device.");
+
+ if (grub_ieee1275_finddevice (display, &dev))
+ return grub_error (GRUB_ERR_IO, "Couldn't open display device.");
+
+ if (grub_ieee1275_get_integer_property (dev, "width", &current_width,
+ sizeof (current_width), 0))
+ return grub_error (GRUB_ERR_IO, "Couldn't retrieve display width.");
+
+ if (grub_ieee1275_get_integer_property (dev, "height", &current_height,
+ sizeof (current_width), 0))
+ return grub_error (GRUB_ERR_IO, "Couldn't retrieve display height.");
+
+ if ((width == current_width && height == current_height)
+ || (width == 0 && height == 0))
+ {
+ grub_dprintf ("video", "IEEE1275: keeping current mode %dx%d\n",
+ current_width, current_height);
+ }
+ else
+ {
+ grub_dprintf ("video", "IEEE1275: Setting mode %dx%d\n", width, height);
+ /* TODO. */
+ return grub_error (GRUB_ERR_IO, "can't set mode %dx%d", width, height);
+ }
+
+ err = grub_video_ieee1275_fill_mode_info (dev, &framebuffer.mode_info);
+ if (err)
+ {
+ grub_dprintf ("video", "IEEE1275: couldn't fill mode info\n");
+ return err;
+ }
+
+ if (grub_ieee1275_get_integer_property (dev, "address", (void *) &address,
+ sizeof (address), 0))
+ return grub_error (GRUB_ERR_IO, "Couldn't retrieve display address.");
+
+ /* For some reason sparc64 uses 32-bit pointer too. */
+ framebuffer.ptr = (void *) (grub_addr_t) address;
+
+ grub_dprintf ("video", "IEEE1275: initialising FB @ %p %dx%dx%d\n",
+ framebuffer.ptr, framebuffer.mode_info.width,
+ framebuffer.mode_info.height, framebuffer.mode_info.bpp);
+
+ err = grub_video_fb_setup (mode_type, mode_mask,
+ &framebuffer.mode_info,
+ framebuffer.ptr, NULL, NULL);
+ if (err)
+ return err;
+
+ grub_video_ieee1275_set_palette (0, framebuffer.mode_info.number_of_colors,
+ grub_video_fbstd_colors);
+
+ return err;
+}
+
+static grub_err_t
+grub_video_ieee1275_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
+ *framebuf = (char *) framebuffer.ptr;
+
+ grub_video_fb_fini ();
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_ieee1275_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data)
+{
+ unsigned col;
+ struct grub_video_palette_data fb_palette_data[256];
+ grub_err_t err;
+
+ if (!(framebuffer.mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR))
+ return grub_video_fb_set_palette (start, count, palette_data);
+
+ if (!have_setcolors)
+ return grub_video_fb_set_palette (0, ARRAY_SIZE (serial_colors),
+ serial_colors);
+
+ if (start >= framebuffer.mode_info.number_of_colors)
+ return GRUB_ERR_NONE;
+
+ if (start + count > framebuffer.mode_info.number_of_colors)
+ count = framebuffer.mode_info.number_of_colors - start;
+
+ err = grub_video_fb_set_palette (start, count, palette_data);
+ if (err)
+ return err;
+
+ /* Set colors. */
+ grub_video_fb_get_palette (0, ARRAY_SIZE (fb_palette_data),
+ fb_palette_data);
+
+ for (col = 0; col < ARRAY_SIZE (fb_palette_data); col++)
+ grub_ieee1275_set_color (stdout_ihandle, col, fb_palette_data[col].r,
+ fb_palette_data[col].g,
+ fb_palette_data[col].b);
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_video_adapter grub_video_ieee1275_adapter =
+ {
+ .name = "IEEE1275 video driver",
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE,
+ .id = GRUB_VIDEO_DRIVER_IEEE1275,
+
+ .init = grub_video_ieee1275_init,
+ .fini = grub_video_ieee1275_fini,
+ .setup = grub_video_ieee1275_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_ieee1275_get_info_and_fini,
+ .set_palette = grub_video_ieee1275_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_fb_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_fb_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(ieee1275_fb)
+{
+ find_display ();
+ if (display)
+ grub_video_register (&grub_video_ieee1275_adapter);
+}
+
+GRUB_MOD_FINI(ieee1275_fb)
+{
+ if (restore_needed)
+ {
+ set_video_mode (old_width, old_height);
+ restore_needed = 0;
+ }
+ if (display)
+ grub_video_unregister (&grub_video_ieee1275_adapter);
+ grub_free (display);
+}
diff --git a/grub-core/video/radeon_fuloong2e.c b/grub-core/video/radeon_fuloong2e.c
new file mode 100644
index 0000000..b4da34b
--- /dev/null
+++ b/grub-core/video/radeon_fuloong2e.c
@@ -0,0 +1,239 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/pci.h>
+#include <grub/vga.h>
+
+#define GRUB_RADEON_FULOONG2E_TOTAL_MEMORY_SPACE 1048576
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+ struct grub_video_render_target *render_target;
+
+ grub_uint8_t *ptr;
+ int mapped;
+ grub_uint32_t base;
+ grub_pci_device_t dev;
+} framebuffer;
+
+static grub_err_t
+grub_video_radeon_fuloong2e_video_init (void)
+{
+ /* Reset frame buffer. */
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_radeon_fuloong2e_video_fini (void)
+{
+ if (framebuffer.mapped)
+ grub_pci_device_unmap_range (framebuffer.dev, framebuffer.ptr,
+ GRUB_RADEON_FULOONG2E_TOTAL_MEMORY_SPACE);
+
+ return grub_video_fb_fini ();
+}
+
+#ifndef TEST
+/* Helper for grub_video_radeon_fuloong2e_setup. */
+static int
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
+{
+ int *found = data;
+ grub_pci_address_t addr;
+ grub_uint32_t class;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class = grub_pci_read (addr);
+
+ if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
+ || pciid != 0x515a1002)
+ return 0;
+
+ *found = 1;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
+ framebuffer.base = grub_pci_read (addr);
+ framebuffer.dev = dev;
+
+ return 1;
+}
+#endif
+
+static grub_err_t
+grub_video_radeon_fuloong2e_setup (unsigned int width, unsigned int height,
+ unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
+{
+ int depth;
+ grub_err_t err;
+ int found = 0;
+
+#ifndef TEST
+ /* Decode depth from mode_type. If it is zero, then autodetect. */
+ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
+
+ if ((width != 640 && width != 0) || (height != 480 && height != 0)
+ || (depth != 16 && depth != 0))
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "Only 640x480x16 is supported");
+
+ grub_pci_iterate (find_card, &found);
+ if (!found)
+ return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
+#endif
+ /* Fill mode info details. */
+ framebuffer.mode_info.width = 640;
+ framebuffer.mode_info.height = 480;
+ framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
+ framebuffer.mode_info.bpp = 16;
+ framebuffer.mode_info.bytes_per_pixel = 2;
+ framebuffer.mode_info.pitch = 640 * 2;
+ framebuffer.mode_info.number_of_colors = 256;
+ framebuffer.mode_info.red_mask_size = 5;
+ framebuffer.mode_info.red_field_pos = 11;
+ framebuffer.mode_info.green_mask_size = 6;
+ framebuffer.mode_info.green_field_pos = 5;
+ framebuffer.mode_info.blue_mask_size = 5;
+ framebuffer.mode_info.blue_field_pos = 0;
+ framebuffer.mode_info.reserved_mask_size = 0;
+ framebuffer.mode_info.reserved_field_pos = 0;
+#ifndef TEST
+ framebuffer.mode_info.blit_format
+ = grub_video_get_blit_format (&framebuffer.mode_info);
+#endif
+
+ /* We can safely discard volatile attribute. */
+#ifndef TEST
+ framebuffer.ptr
+ = (void *) grub_pci_device_map_range (framebuffer.dev,
+ framebuffer.base,
+ GRUB_RADEON_FULOONG2E_TOTAL_MEMORY_SPACE);
+#endif
+ framebuffer.mapped = 1;
+
+ /* Prevent garbage from appearing on the screen. */
+ grub_memset (framebuffer.ptr, 0x55,
+ framebuffer.mode_info.height * framebuffer.mode_info.pitch);
+
+#ifndef TEST
+ err = grub_video_fb_create_render_target_from_pointer (&framebuffer
+ .render_target,
+ &framebuffer.mode_info,
+ framebuffer.ptr);
+
+ if (err)
+ return err;
+
+ err = grub_video_fb_set_active_render_target (framebuffer.render_target);
+
+ if (err)
+ return err;
+
+ /* Copy default palette to initialize emulated palette. */
+ err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+#endif
+ return err;
+}
+
+static grub_err_t
+grub_video_radeon_fuloong2e_swap_buffers (void)
+{
+ /* TODO: Implement buffer swapping. */
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_radeon_fuloong2e_set_active_render_target (struct grub_video_render_target *target)
+{
+ if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
+ target = framebuffer.render_target;
+
+ return grub_video_fb_set_active_render_target (target);
+}
+
+static grub_err_t
+grub_video_radeon_fuloong2e_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
+ *framebuf = (char *) framebuffer.ptr;
+
+ grub_video_fb_fini ();
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_video_adapter grub_video_radeon_fuloong2e_adapter =
+ {
+ .name = "RADEON RV100 QZ (Fuloong2E) Video Driver",
+ .id = GRUB_VIDEO_DRIVER_RADEON_FULOONG2E,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_NATIVE,
+
+ .init = grub_video_radeon_fuloong2e_video_init,
+ .fini = grub_video_radeon_fuloong2e_video_fini,
+ .setup = grub_video_radeon_fuloong2e_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_radeon_fuloong2e_get_info_and_fini,
+ .set_palette = grub_video_fb_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_radeon_fuloong2e_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_radeon_fuloong2e_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(video_radeon_fuloong2e)
+{
+ grub_video_register (&grub_video_radeon_fuloong2e_adapter);
+}
+
+GRUB_MOD_FINI(video_radeon_fuloong2e)
+{
+ grub_video_unregister (&grub_video_radeon_fuloong2e_adapter);
+}
diff --git a/grub-core/video/radeon_yeeloong3a.c b/grub-core/video/radeon_yeeloong3a.c
new file mode 100644
index 0000000..52614fe
--- /dev/null
+++ b/grub-core/video/radeon_yeeloong3a.c
@@ -0,0 +1,237 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009,2010,2011,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/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/pci.h>
+#include <grub/vga.h>
+
+#define GRUB_RADEON_YEELOONG3A_TOTAL_MEMORY_SPACE 1048576
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+ struct grub_video_render_target *render_target;
+
+ grub_uint8_t *ptr;
+ int mapped;
+ grub_uint32_t base;
+ grub_pci_device_t dev;
+} framebuffer;
+
+static grub_err_t
+grub_video_radeon_yeeloong3a_video_init (void)
+{
+ /* Reset frame buffer. */
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_radeon_yeeloong3a_video_fini (void)
+{
+ if (framebuffer.mapped)
+ grub_pci_device_unmap_range (framebuffer.dev, framebuffer.ptr,
+ GRUB_RADEON_YEELOONG3A_TOTAL_MEMORY_SPACE);
+ return grub_video_fb_fini ();
+}
+
+#ifndef TEST
+/* Helper for grub_video_radeon_yeeloong3a_setup. */
+static int
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
+{
+ int *found = data;
+ grub_pci_address_t addr;
+ grub_uint32_t class;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class = grub_pci_read (addr);
+
+ if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
+ || pciid != 0x96151002)
+ return 0;
+
+ *found = 1;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
+ framebuffer.base = grub_pci_read (addr);
+ framebuffer.dev = dev;
+
+ return 1;
+}
+#endif
+
+static grub_err_t
+grub_video_radeon_yeeloong3a_setup (unsigned int width, unsigned int height,
+ unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
+{
+ int depth;
+ grub_err_t err;
+ int found = 0;
+
+#ifndef TEST
+ /* Decode depth from mode_type. If it is zero, then autodetect. */
+ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
+
+ if ((width != 800 && width != 0) || (height != 600 && height != 0)
+ || (depth != 16 && depth != 0))
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "Only 640x480x16 is supported");
+
+ grub_pci_iterate (find_card, &found);
+ if (!found)
+ return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
+#endif
+ /* Fill mode info details. */
+ framebuffer.mode_info.width = 800;
+ framebuffer.mode_info.height = 600;
+ framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
+ framebuffer.mode_info.bpp = 16;
+ framebuffer.mode_info.bytes_per_pixel = 2;
+ framebuffer.mode_info.pitch = 800 * 2;
+ framebuffer.mode_info.number_of_colors = 256;
+ framebuffer.mode_info.red_mask_size = 5;
+ framebuffer.mode_info.red_field_pos = 11;
+ framebuffer.mode_info.green_mask_size = 6;
+ framebuffer.mode_info.green_field_pos = 5;
+ framebuffer.mode_info.blue_mask_size = 5;
+ framebuffer.mode_info.blue_field_pos = 0;
+ framebuffer.mode_info.reserved_mask_size = 0;
+ framebuffer.mode_info.reserved_field_pos = 0;
+#ifndef TEST
+ framebuffer.mode_info.blit_format
+ = grub_video_get_blit_format (&framebuffer.mode_info);
+#endif
+
+ /* We can safely discard volatile attribute. */
+#ifndef TEST
+ framebuffer.ptr = (void *) grub_pci_device_map_range (framebuffer.dev,
+ framebuffer.base,
+ GRUB_RADEON_YEELOONG3A_TOTAL_MEMORY_SPACE);
+ framebuffer.mapped = 1;
+#endif
+
+ /* Prevent garbage from appearing on the screen. */
+ grub_memset (framebuffer.ptr, 0,
+ framebuffer.mode_info.height * framebuffer.mode_info.pitch);
+
+#ifndef TEST
+ err = grub_video_fb_create_render_target_from_pointer (&framebuffer
+ .render_target,
+ &framebuffer.mode_info,
+ framebuffer.ptr);
+
+ if (err)
+ return err;
+
+ err = grub_video_fb_set_active_render_target (framebuffer.render_target);
+
+ if (err)
+ return err;
+
+ /* Copy default palette to initialize emulated palette. */
+ err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+#endif
+ return err;
+}
+
+static grub_err_t
+grub_video_radeon_yeeloong3a_swap_buffers (void)
+{
+ /* TODO: Implement buffer swapping. */
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_radeon_yeeloong3a_set_active_render_target (struct grub_video_render_target *target)
+{
+ if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
+ target = framebuffer.render_target;
+
+ return grub_video_fb_set_active_render_target (target);
+}
+
+static grub_err_t
+grub_video_radeon_yeeloong3a_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
+ *framebuf = (char *) framebuffer.ptr;
+
+ grub_video_fb_fini ();
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_video_adapter grub_video_radeon_yeeloong3a_adapter =
+ {
+ .name = "RADEON (Yeeloong3a) Video Driver",
+ .id = GRUB_VIDEO_DRIVER_RADEON_YEELOONG3A,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_NATIVE,
+
+ .init = grub_video_radeon_yeeloong3a_video_init,
+ .fini = grub_video_radeon_yeeloong3a_video_fini,
+ .setup = grub_video_radeon_yeeloong3a_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_radeon_yeeloong3a_get_info_and_fini,
+ .set_palette = grub_video_fb_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_radeon_yeeloong3a_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_radeon_yeeloong3a_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(video_radeon_yeeloong3a)
+{
+ grub_video_register (&grub_video_radeon_yeeloong3a_adapter);
+}
+
+GRUB_MOD_FINI(video_radeon_yeeloong3a)
+{
+ grub_video_unregister (&grub_video_radeon_yeeloong3a_adapter);
+}
diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c
new file mode 100644
index 0000000..e31602f
--- /dev/null
+++ b/grub-core/video/readers/jpeg.c
@@ -0,0 +1,879 @@
+/*
+ * 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/bitmap.h>
+#include <grub/types.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/bufio.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Uncomment following define to enable JPEG debug. */
+//#define JPEG_DEBUG
+
+#define JPEG_ESC_CHAR 0xFF
+
+#define JPEG_SAMPLING_1x1 0x11
+
+enum
+ {
+ JPEG_MARKER_SOF0 = 0xc0,
+ JPEG_MARKER_DHT = 0xc4,
+ JPEG_MARKER_SOI = 0xd8,
+ JPEG_MARKER_EOI = 0xd9,
+ JPEG_MARKER_RST0 = 0xd0,
+ JPEG_MARKER_RST1 = 0xd1,
+ JPEG_MARKER_RST2 = 0xd2,
+ JPEG_MARKER_RST3 = 0xd3,
+ JPEG_MARKER_RST4 = 0xd4,
+ JPEG_MARKER_RST5 = 0xd5,
+ JPEG_MARKER_RST6 = 0xd6,
+ JPEG_MARKER_RST7 = 0xd7,
+ JPEG_MARKER_SOS = 0xda,
+ JPEG_MARKER_DQT = 0xdb,
+ JPEG_MARKER_DRI = 0xdd,
+ };
+
+#define SHIFT_BITS 8
+#define CONST(x) ((int) ((x) * (1L << SHIFT_BITS) + 0.5))
+
+#define JPEG_UNIT_SIZE 8
+
+static const grub_uint8_t jpeg_zigzag_order[64] = {
+ 0, 1, 8, 16, 9, 2, 3, 10,
+ 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34,
+ 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36,
+ 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46,
+ 53, 60, 61, 54, 47, 55, 62, 63
+};
+
+#ifdef JPEG_DEBUG
+static grub_command_t cmd;
+#endif
+
+typedef int jpeg_data_unit_t[64];
+
+struct grub_jpeg_data
+{
+ grub_file_t file;
+ struct grub_video_bitmap **bitmap;
+ grub_uint8_t *bitmap_ptr;
+
+ unsigned image_width;
+ unsigned image_height;
+
+ grub_uint8_t *huff_value[4];
+ int huff_offset[4][16];
+ int huff_maxval[4][16];
+
+ grub_uint8_t quan_table[2][64];
+ int comp_index[3][3];
+
+ jpeg_data_unit_t ydu[4];
+ jpeg_data_unit_t crdu;
+ jpeg_data_unit_t cbdu;
+
+ unsigned log_vs, log_hs;
+ int dri;
+ unsigned r1;
+
+ int dc_value[3];
+
+ int color_components;
+
+ int bit_mask, bit_save;
+};
+
+static grub_uint8_t
+grub_jpeg_get_byte (struct grub_jpeg_data *data)
+{
+ grub_uint8_t r;
+
+ r = 0;
+ grub_file_read (data->file, &r, 1);
+
+ return r;
+}
+
+static grub_uint16_t
+grub_jpeg_get_word (struct grub_jpeg_data *data)
+{
+ grub_uint16_t r;
+
+ r = 0;
+ grub_file_read (data->file, &r, sizeof (grub_uint16_t));
+
+ return grub_be_to_cpu16 (r);
+}
+
+static int
+grub_jpeg_get_bit (struct grub_jpeg_data *data)
+{
+ int ret;
+
+ if (data->bit_mask == 0)
+ {
+ data->bit_save = grub_jpeg_get_byte (data);
+ if (data->bit_save == JPEG_ESC_CHAR)
+ {
+ if (grub_jpeg_get_byte (data) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: invalid 0xFF in data stream");
+ return 0;
+ }
+ }
+ data->bit_mask = 0x80;
+ }
+
+ ret = ((data->bit_save & data->bit_mask) != 0);
+ data->bit_mask >>= 1;
+ return ret;
+}
+
+static int
+grub_jpeg_get_number (struct grub_jpeg_data *data, int num)
+{
+ int value, i, msb;
+
+ if (num == 0)
+ return 0;
+
+ msb = value = grub_jpeg_get_bit (data);
+ for (i = 1; i < num; i++)
+ value = (value << 1) + (grub_jpeg_get_bit (data) != 0);
+ if (!msb)
+ value += 1 - (1 << num);
+
+ return value;
+}
+
+static int
+grub_jpeg_get_huff_code (struct grub_jpeg_data *data, int id)
+{
+ int code;
+ unsigned i;
+
+ code = 0;
+ for (i = 0; i < ARRAY_SIZE (data->huff_maxval[id]); i++)
+ {
+ code <<= 1;
+ if (grub_jpeg_get_bit (data))
+ code++;
+ if (code < data->huff_maxval[id][i])
+ return data->huff_value[id][code + data->huff_offset[id][i]];
+ }
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: huffman decode fails");
+ return 0;
+}
+
+static grub_err_t
+grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
+{
+ int id, ac, n, base, ofs;
+ grub_uint32_t next_marker;
+ grub_uint8_t count[16];
+ unsigned i;
+
+ next_marker = data->file->offset;
+ next_marker += grub_jpeg_get_word (data);
+
+ while (data->file->offset + sizeof (count) + 1 <= next_marker)
+ {
+ id = grub_jpeg_get_byte (data);
+ ac = (id >> 4) & 1;
+ id &= 0xF;
+ if (id > 1)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: too many huffman tables");
+
+ if (grub_file_read (data->file, &count, sizeof (count)) !=
+ sizeof (count))
+ return grub_errno;
+
+ n = 0;
+ for (i = 0; i < ARRAY_SIZE (count); i++)
+ n += count[i];
+
+ id += ac * 2;
+ data->huff_value[id] = grub_malloc (n);
+ if (grub_errno)
+ return grub_errno;
+
+ if (grub_file_read (data->file, data->huff_value[id], n) != n)
+ return grub_errno;
+
+ base = 0;
+ ofs = 0;
+ for (i = 0; i < ARRAY_SIZE (count); i++)
+ {
+ base += count[i];
+ ofs += count[i];
+
+ data->huff_maxval[id][i] = base;
+ data->huff_offset[id][i] = ofs - base;
+
+ base <<= 1;
+ }
+ }
+
+ if (data->file->offset != next_marker)
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: extra byte in huffman table");
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_jpeg_decode_quan_table (struct grub_jpeg_data *data)
+{
+ int id;
+ grub_uint32_t next_marker;
+
+ next_marker = data->file->offset;
+ next_marker += grub_jpeg_get_word (data);
+
+ if (next_marker > data->file->size)
+ {
+ /* Should never be set beyond the size of the file. */
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid next reference");
+ }
+
+ while (data->file->offset + sizeof (data->quan_table[id]) + 1
+ <= next_marker)
+ {
+ id = grub_jpeg_get_byte (data);
+ if (id >= 0x10) /* Upper 4-bit is precision. */
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: only 8-bit precision is supported");
+
+ if (id > 1)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: too many quantization tables");
+
+ if (grub_file_read (data->file, &data->quan_table[id],
+ sizeof (data->quan_table[id]))
+ != sizeof (data->quan_table[id]))
+ return grub_errno;
+
+ }
+
+ if (data->file->offset != next_marker)
+ grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: extra byte in quantization table");
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_jpeg_decode_sof (struct grub_jpeg_data *data)
+{
+ int i, cc;
+ grub_uint32_t next_marker;
+
+ next_marker = data->file->offset;
+ next_marker += grub_jpeg_get_word (data);
+
+ if (grub_jpeg_get_byte (data) != 8)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: only 8-bit precision is supported");
+
+ data->image_height = grub_jpeg_get_word (data);
+ data->image_width = grub_jpeg_get_word (data);
+
+ if ((!data->image_height) || (!data->image_width))
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid image size");
+
+ cc = grub_jpeg_get_byte (data);
+ if (cc != 1 && cc != 3)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: component count must be 1 or 3");
+ data->color_components = cc;
+
+ for (i = 0; i < cc; i++)
+ {
+ int id, ss;
+
+ id = grub_jpeg_get_byte (data) - 1;
+ if ((id < 0) || (id >= 3))
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid index");
+
+ ss = grub_jpeg_get_byte (data); /* Sampling factor. */
+ if (!id)
+ {
+ 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,
+ "jpeg: sampling method not supported");
+
+ data->comp_index[id][0] = grub_jpeg_get_byte (data);
+ if (data->comp_index[id][0] > 1)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: too many quantization tables");
+ }
+
+ if (data->file->offset != next_marker)
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: extra byte in sof");
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_jpeg_decode_dri (struct grub_jpeg_data *data)
+{
+ if (grub_jpeg_get_word (data) != 4)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: DRI marker length must be 4");
+
+ data->dri = grub_jpeg_get_word (data);
+
+ return grub_errno;
+}
+
+static void
+grub_jpeg_idct_transform (jpeg_data_unit_t du)
+{
+ int *pd;
+ int i;
+ int t0, t1, t2, t3, t4, t5, t6, t7;
+ int v0, v1, v2, v3, v4;
+
+ pd = du;
+ for (i = 0; i < JPEG_UNIT_SIZE; i++, pd++)
+ {
+ if ((pd[JPEG_UNIT_SIZE * 1] | pd[JPEG_UNIT_SIZE * 2] |
+ pd[JPEG_UNIT_SIZE * 3] | pd[JPEG_UNIT_SIZE * 4] |
+ pd[JPEG_UNIT_SIZE * 5] | pd[JPEG_UNIT_SIZE * 6] |
+ pd[JPEG_UNIT_SIZE * 7]) == 0)
+ {
+ pd[JPEG_UNIT_SIZE * 0] <<= SHIFT_BITS;
+
+ pd[JPEG_UNIT_SIZE * 1] = pd[JPEG_UNIT_SIZE * 2]
+ = pd[JPEG_UNIT_SIZE * 3] = pd[JPEG_UNIT_SIZE * 4]
+ = pd[JPEG_UNIT_SIZE * 5] = pd[JPEG_UNIT_SIZE * 6]
+ = pd[JPEG_UNIT_SIZE * 7] = pd[JPEG_UNIT_SIZE * 0];
+
+ continue;
+ }
+
+ t0 = pd[JPEG_UNIT_SIZE * 0];
+ t1 = pd[JPEG_UNIT_SIZE * 2];
+ t2 = pd[JPEG_UNIT_SIZE * 4];
+ t3 = pd[JPEG_UNIT_SIZE * 6];
+
+ v4 = (t1 + t3) * CONST (0.541196100);
+
+ v0 = ((t0 + t2) << SHIFT_BITS);
+ v1 = ((t0 - t2) << SHIFT_BITS);
+ v2 = v4 - t3 * CONST (1.847759065);
+ v3 = v4 + t1 * CONST (0.765366865);
+
+ t0 = v0 + v3;
+ t3 = v0 - v3;
+ t1 = v1 + v2;
+ t2 = v1 - v2;
+
+ t4 = pd[JPEG_UNIT_SIZE * 7];
+ t5 = pd[JPEG_UNIT_SIZE * 5];
+ t6 = pd[JPEG_UNIT_SIZE * 3];
+ t7 = pd[JPEG_UNIT_SIZE * 1];
+
+ v0 = t4 + t7;
+ v1 = t5 + t6;
+ v2 = t4 + t6;
+ v3 = t5 + t7;
+
+ v4 = (v2 + v3) * CONST (1.175875602);
+
+ v0 *= CONST (0.899976223);
+ v1 *= CONST (2.562915447);
+ v2 = v2 * CONST (1.961570560) - v4;
+ v3 = v3 * CONST (0.390180644) - v4;
+
+ t4 = t4 * CONST (0.298631336) - v0 - v2;
+ t5 = t5 * CONST (2.053119869) - v1 - v3;
+ t6 = t6 * CONST (3.072711026) - v1 - v2;
+ t7 = t7 * CONST (1.501321110) - v0 - v3;
+
+ pd[JPEG_UNIT_SIZE * 0] = t0 + t7;
+ pd[JPEG_UNIT_SIZE * 7] = t0 - t7;
+ pd[JPEG_UNIT_SIZE * 1] = t1 + t6;
+ pd[JPEG_UNIT_SIZE * 6] = t1 - t6;
+ pd[JPEG_UNIT_SIZE * 2] = t2 + t5;
+ pd[JPEG_UNIT_SIZE * 5] = t2 - t5;
+ pd[JPEG_UNIT_SIZE * 3] = t3 + t4;
+ pd[JPEG_UNIT_SIZE * 4] = t3 - t4;
+ }
+
+ pd = du;
+ for (i = 0; i < JPEG_UNIT_SIZE; i++, pd += JPEG_UNIT_SIZE)
+ {
+ if ((pd[1] | pd[2] | pd[3] | pd[4] | pd[5] | pd[6] | pd[7]) == 0)
+ {
+ pd[0] >>= (SHIFT_BITS + 3);
+ pd[1] = pd[2] = pd[3] = pd[4] = pd[5] = pd[6] = pd[7] = pd[0];
+ continue;
+ }
+
+ v4 = (pd[2] + pd[6]) * CONST (0.541196100);
+
+ v0 = (pd[0] + pd[4]) << SHIFT_BITS;
+ v1 = (pd[0] - pd[4]) << SHIFT_BITS;
+ v2 = v4 - pd[6] * CONST (1.847759065);
+ v3 = v4 + pd[2] * CONST (0.765366865);
+
+ t0 = v0 + v3;
+ t3 = v0 - v3;
+ t1 = v1 + v2;
+ t2 = v1 - v2;
+
+ t4 = pd[7];
+ t5 = pd[5];
+ t6 = pd[3];
+ t7 = pd[1];
+
+ v0 = t4 + t7;
+ v1 = t5 + t6;
+ v2 = t4 + t6;
+ v3 = t5 + t7;
+
+ v4 = (v2 + v3) * CONST (1.175875602);
+
+ v0 *= CONST (0.899976223);
+ v1 *= CONST (2.562915447);
+ v2 = v2 * CONST (1.961570560) - v4;
+ v3 = v3 * CONST (0.390180644) - v4;
+
+ t4 = t4 * CONST (0.298631336) - v0 - v2;
+ t5 = t5 * CONST (2.053119869) - v1 - v3;
+ t6 = t6 * CONST (3.072711026) - v1 - v2;
+ t7 = t7 * CONST (1.501321110) - v0 - v3;
+
+ pd[0] = (t0 + t7) >> (SHIFT_BITS * 2 + 3);
+ pd[7] = (t0 - t7) >> (SHIFT_BITS * 2 + 3);
+ pd[1] = (t1 + t6) >> (SHIFT_BITS * 2 + 3);
+ pd[6] = (t1 - t6) >> (SHIFT_BITS * 2 + 3);
+ pd[2] = (t2 + t5) >> (SHIFT_BITS * 2 + 3);
+ pd[5] = (t2 - t5) >> (SHIFT_BITS * 2 + 3);
+ pd[3] = (t3 + t4) >> (SHIFT_BITS * 2 + 3);
+ pd[4] = (t3 - t4) >> (SHIFT_BITS * 2 + 3);
+ }
+
+ for (i = 0; i < JPEG_UNIT_SIZE * JPEG_UNIT_SIZE; i++)
+ {
+ du[i] += 128;
+
+ if (du[i] < 0)
+ du[i] = 0;
+ if (du[i] > 255)
+ du[i] = 255;
+ }
+}
+
+static void
+grub_jpeg_decode_du (struct grub_jpeg_data *data, int id, jpeg_data_unit_t du)
+{
+ int h1, h2, qt;
+ unsigned pos;
+
+ grub_memset (du, 0, sizeof (jpeg_data_unit_t));
+
+ qt = data->comp_index[id][0];
+ h1 = data->comp_index[id][1];
+ h2 = data->comp_index[id][2];
+
+ data->dc_value[id] +=
+ grub_jpeg_get_number (data, grub_jpeg_get_huff_code (data, h1));
+
+ du[0] = data->dc_value[id] * (int) data->quan_table[qt][0];
+ pos = 1;
+ while (pos < ARRAY_SIZE (data->quan_table[qt]))
+ {
+ int num, val;
+
+ num = grub_jpeg_get_huff_code (data, h2);
+ if (!num)
+ break;
+
+ val = grub_jpeg_get_number (data, num & 0xF);
+ num >>= 4;
+ pos += num;
+
+ if (pos >= ARRAY_SIZE (jpeg_zigzag_order))
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: invalid position in zigzag order!?");
+ return;
+ }
+
+ du[jpeg_zigzag_order[pos]] = val * (int) data->quan_table[qt][pos];
+ pos++;
+ }
+
+ grub_jpeg_idct_transform (du);
+}
+
+static void
+grub_jpeg_ycrcb_to_rgb (int yy, int cr, int cb, grub_uint8_t * rgb)
+{
+ int dd;
+
+ cr -= 128;
+ cb -= 128;
+
+ /* Red */
+ dd = yy + ((cr * CONST (1.402)) >> SHIFT_BITS);
+ if (dd < 0)
+ dd = 0;
+ if (dd > 255)
+ dd = 255;
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ rgb[2] = dd;
+#else
+ *(rgb++) = dd;
+#endif
+
+ /* Green */
+ dd = yy - ((cb * CONST (0.34414) + cr * CONST (0.71414)) >> SHIFT_BITS);
+ if (dd < 0)
+ dd = 0;
+ if (dd > 255)
+ dd = 255;
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ rgb[1] = dd;
+#else
+ *(rgb++) = dd;
+#endif
+
+ /* Blue */
+ dd = yy + ((cb * CONST (1.772)) >> SHIFT_BITS);
+ if (dd < 0)
+ dd = 0;
+ if (dd > 255)
+ dd = 255;
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ rgb[0] = dd;
+ rgb += 3;
+#else
+ *(rgb++) = dd;
+#endif
+}
+
+static grub_err_t
+grub_jpeg_decode_sos (struct grub_jpeg_data *data)
+{
+ int i, cc;
+ grub_uint32_t data_offset;
+
+ data_offset = data->file->offset;
+ data_offset += grub_jpeg_get_word (data);
+
+ cc = grub_jpeg_get_byte (data);
+
+ if (cc != 3 && cc != 1)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: component count must be 1 or 3");
+ data->color_components = cc;
+
+ for (i = 0; i < cc; i++)
+ {
+ int id, ht;
+
+ id = grub_jpeg_get_byte (data) - 1;
+ if ((id < 0) || (id >= 3))
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid index");
+
+ ht = grub_jpeg_get_byte (data);
+ data->comp_index[id][1] = (ht >> 4);
+ data->comp_index[id][2] = (ht & 0xF) + 2;
+
+ if ((data->comp_index[id][1] < 0) || (data->comp_index[id][1] > 3) ||
+ (data->comp_index[id][2] < 0) || (data->comp_index[id][2] > 3))
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid hufftable index");
+ }
+
+ grub_jpeg_get_byte (data); /* Skip 3 unused bytes. */
+ grub_jpeg_get_word (data);
+
+ if (data->file->offset != data_offset)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: extra byte in sos");
+
+ if (grub_video_bitmap_create (data->bitmap, data->image_width,
+ data->image_height,
+ GRUB_VIDEO_BLIT_FORMAT_RGB_888))
+ return grub_errno;
+
+ data->bitmap_ptr = (*data->bitmap)->data;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_jpeg_decode_data (struct grub_jpeg_data *data)
+{
+ unsigned c1, vb, hb, nr1, nc1;
+ int rst = data->dri;
+
+ 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);
+
+ if (data->bitmap_ptr == NULL)
+ return grub_error(GRUB_ERR_BAD_FILE_TYPE,
+ "jpeg: attempted to decode data before start of stream");
+
+ for (; data->r1 < nr1 && (!data->dri || rst);
+ data->r1++, data->bitmap_ptr += (vb * data->image_width - hb * nc1) * 3)
+ for (c1 = 0; c1 < nc1 && (!data->dri || rst);
+ c1++, rst--, data->bitmap_ptr += hb * 3)
+ {
+ unsigned r2, c2, nr2, nc2;
+ grub_uint8_t *ptr2;
+
+ 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)
+ {
+ grub_jpeg_decode_du (data, 1, data->cbdu);
+ grub_jpeg_decode_du (data, 2, data->crdu);
+ }
+
+ if (grub_errno)
+ return grub_errno;
+
+ nr2 = (data->r1 == nr1 - 1) ? (data->image_height - data->r1 * vb) : vb;
+ nc2 = (c1 == nc1 - 1) ? (data->image_width - c1 * hb) : hb;
+
+ ptr2 = data->bitmap_ptr;
+ for (r2 = 0; r2 < nr2; r2++, ptr2 += (data->image_width - nc2) * 3)
+ for (c2 = 0; c2 < nc2; c2++, ptr2 += 3)
+ {
+ unsigned i0;
+ int yy;
+
+ 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)
+ {
+ int cr, cb;
+ cr = data->crdu[i0];
+ cb = data->cbdu[i0];
+ grub_jpeg_ycrcb_to_rgb (yy, cr, cb, ptr2);
+ }
+ else
+ {
+ ptr2[0] = yy;
+ ptr2[1] = yy;
+ ptr2[2] = yy;
+ }
+ }
+ }
+
+ return grub_errno;
+}
+
+static void
+grub_jpeg_reset (struct grub_jpeg_data *data)
+{
+ data->bit_mask = 0x0;
+
+ data->dc_value[0] = 0;
+ data->dc_value[1] = 0;
+ data->dc_value[2] = 0;
+}
+
+static grub_uint8_t
+grub_jpeg_get_marker (struct grub_jpeg_data *data)
+{
+ grub_uint8_t r;
+
+ r = grub_jpeg_get_byte (data);
+
+ if (r != JPEG_ESC_CHAR)
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid maker");
+ return 0;
+ }
+
+ return grub_jpeg_get_byte (data);
+}
+
+static grub_err_t
+grub_jpeg_decode_jpeg (struct grub_jpeg_data *data)
+{
+ if (grub_jpeg_get_marker (data) != JPEG_MARKER_SOI) /* Start Of Image. */
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid jpeg file");
+
+ while (grub_errno == 0)
+ {
+ grub_uint8_t marker;
+
+ marker = grub_jpeg_get_marker (data);
+ if (grub_errno)
+ break;
+
+ grub_dprintf ("jpeg", "jpeg marker: %x\n", marker);
+
+ switch (marker)
+ {
+ case JPEG_MARKER_DHT: /* Define Huffman Table. */
+ grub_jpeg_decode_huff_table (data);
+ break;
+ case JPEG_MARKER_DQT: /* Define Quantization Table. */
+ grub_jpeg_decode_quan_table (data);
+ break;
+ case JPEG_MARKER_SOF0: /* Start Of Frame 0. */
+ grub_jpeg_decode_sof (data);
+ break;
+ case JPEG_MARKER_DRI: /* Define Restart Interval. */
+ grub_jpeg_decode_dri (data);
+ break;
+ case JPEG_MARKER_SOS: /* Start Of Scan. */
+ if (grub_jpeg_decode_sos (data))
+ break;
+ /* FALLTHROUGH */
+ case JPEG_MARKER_RST0: /* Restart. */
+ case JPEG_MARKER_RST1:
+ case JPEG_MARKER_RST2:
+ case JPEG_MARKER_RST3:
+ case JPEG_MARKER_RST4:
+ case JPEG_MARKER_RST5:
+ case JPEG_MARKER_RST6:
+ case JPEG_MARKER_RST7:
+ grub_jpeg_decode_data (data);
+ grub_jpeg_reset (data);
+ break;
+ case JPEG_MARKER_EOI: /* End Of Image. */
+ return grub_errno;
+ default: /* Skip unrecognized marker. */
+ {
+ grub_uint16_t sz;
+
+ sz = grub_jpeg_get_word (data);
+ if (grub_errno)
+ return (grub_errno);
+ grub_file_seek (data->file, data->file->offset + sz - 2);
+ }
+ }
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_video_reader_jpeg (struct grub_video_bitmap **bitmap,
+ const char *filename)
+{
+ grub_file_t file;
+ struct grub_jpeg_data *data;
+
+ file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0);
+ if (!file)
+ return grub_errno;
+
+ data = grub_zalloc (sizeof (*data));
+ if (data != NULL)
+ {
+ int i;
+
+ data->file = file;
+ data->bitmap = bitmap;
+ grub_jpeg_decode_jpeg (data);
+
+ for (i = 0; i < 4; i++)
+ grub_free (data->huff_value[i]);
+
+ grub_free (data);
+ }
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_video_bitmap_destroy (*bitmap);
+ *bitmap = 0;
+ }
+
+ grub_file_close (file);
+ return grub_errno;
+}
+
+#if defined(JPEG_DEBUG)
+static grub_err_t
+grub_cmd_jpegtest (grub_command_t cmdd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_video_bitmap *bitmap = 0;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ grub_video_reader_jpeg (&bitmap, args[0]);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ grub_video_bitmap_destroy (bitmap);
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+static struct grub_video_bitmap_reader jpg_reader = {
+ .extension = ".jpg",
+ .reader = grub_video_reader_jpeg,
+ .next = 0
+};
+
+static struct grub_video_bitmap_reader jpeg_reader = {
+ .extension = ".jpeg",
+ .reader = grub_video_reader_jpeg,
+ .next = 0
+};
+
+GRUB_MOD_INIT (jpeg)
+{
+ grub_video_bitmap_reader_register (&jpg_reader);
+ grub_video_bitmap_reader_register (&jpeg_reader);
+#if defined(JPEG_DEBUG)
+ cmd = grub_register_command ("jpegtest", grub_cmd_jpegtest,
+ "FILE", "Tests loading of JPEG bitmap.");
+#endif
+}
+
+GRUB_MOD_FINI (jpeg)
+{
+#if defined(JPEG_DEBUG)
+ grub_unregister_command (cmd);
+#endif
+ grub_video_bitmap_reader_unregister (&jpeg_reader);
+ grub_video_bitmap_reader_unregister (&jpg_reader);
+}
diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c
new file mode 100644
index 0000000..0157ff7
--- /dev/null
+++ b/grub-core/video/readers/png.c
@@ -0,0 +1,1166 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/bitmap.h>
+#include <grub/types.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/bufio.h>
+#include <grub/safemath.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Uncomment following define to enable PNG debug. */
+//#define PNG_DEBUG
+
+enum
+ {
+ PNG_COLOR_TYPE_GRAY = 0,
+ PNG_COLOR_MASK_PALETTE = 1,
+ PNG_COLOR_MASK_COLOR = 2,
+ PNG_COLOR_MASK_ALPHA = 4,
+ PNG_COLOR_TYPE_PALETTE = (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE),
+ };
+
+#define PNG_COMPRESSION_BASE 0
+
+#define PNG_INTERLACE_NONE 0
+#define PNG_INTERLACE_ADAM7 1
+
+#define PNG_FILTER_TYPE_BASE 0
+
+#define PNG_FILTER_VALUE_NONE 0
+#define PNG_FILTER_VALUE_SUB 1
+#define PNG_FILTER_VALUE_UP 2
+#define PNG_FILTER_VALUE_AVG 3
+#define PNG_FILTER_VALUE_PAETH 4
+#define PNG_FILTER_VALUE_LAST 5
+
+enum
+ {
+ PNG_CHUNK_IHDR = 0x49484452,
+ PNG_CHUNK_IDAT = 0x49444154,
+ PNG_CHUNK_IEND = 0x49454e44,
+ PNG_CHUNK_PLTE = 0x504c5445
+ };
+
+#define Z_DEFLATED 8
+#define Z_FLAG_DICT 32
+
+#define INFLATE_STORED 0
+#define INFLATE_FIXED 1
+#define INFLATE_DYNAMIC 2
+
+#define WSIZE 0x8000
+
+#define DEFLATE_HCLEN_BASE 4
+#define DEFLATE_HCLEN_MAX 19
+#define DEFLATE_HLIT_BASE 257
+#define DEFLATE_HLIT_MAX 288
+#define DEFLATE_HDIST_BASE 1
+#define DEFLATE_HDIST_MAX 30
+
+#define DEFLATE_HUFF_LEN 16
+
+#ifdef PNG_DEBUG
+static grub_command_t cmd;
+#endif
+
+struct huff_table
+{
+ int *values, *maxval, *offset;
+ int num_values, max_length;
+};
+
+struct grub_png_data
+{
+ grub_file_t file;
+ struct grub_video_bitmap **bitmap;
+
+ int bit_count, bit_save;
+
+ grub_uint32_t next_offset;
+
+ unsigned image_width, image_height;
+ int bpp, is_16bit;
+ int raw_bytes, is_gray, is_alpha, is_palette;
+ int row_bytes, color_bits;
+ grub_uint8_t *image_data;
+
+ int inside_idat, idat_remain;
+
+ int code_values[DEFLATE_HLIT_MAX];
+ int code_maxval[DEFLATE_HUFF_LEN];
+ int code_offset[DEFLATE_HUFF_LEN];
+
+ int dist_values[DEFLATE_HDIST_MAX];
+ int dist_maxval[DEFLATE_HUFF_LEN];
+ int dist_offset[DEFLATE_HUFF_LEN];
+
+ grub_uint8_t palette[256][3];
+
+ struct huff_table code_table;
+ struct huff_table dist_table;
+
+ grub_uint8_t slide[WSIZE];
+ int wp;
+
+ grub_uint8_t *cur_rgb;
+
+ int cur_column, cur_filter, first_line;
+};
+
+static grub_uint32_t
+grub_png_get_dword (struct grub_png_data *data)
+{
+ grub_uint32_t r;
+
+ r = 0;
+ grub_file_read (data->file, &r, sizeof (grub_uint32_t));
+
+ return grub_be_to_cpu32 (r);
+}
+
+static grub_uint8_t
+grub_png_get_byte (struct grub_png_data *data)
+{
+ grub_uint8_t r;
+
+ if ((data->inside_idat) && (data->idat_remain == 0))
+ {
+ grub_uint32_t len, type;
+
+ do
+ {
+ /* Skip crc checksum. */
+ grub_png_get_dword (data);
+
+ if (data->file->offset != data->next_offset)
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: chunk size error");
+ return 0;
+ }
+
+ len = grub_png_get_dword (data);
+ type = grub_png_get_dword (data);
+ if (type != PNG_CHUNK_IDAT)
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: unexpected end of data");
+ return 0;
+ }
+
+ data->next_offset = data->file->offset + len + 4;
+ }
+ while (len == 0);
+ data->idat_remain = len;
+ }
+
+ r = 0;
+ grub_file_read (data->file, &r, 1);
+
+ if (data->inside_idat)
+ data->idat_remain--;
+
+ return r;
+}
+
+static int
+grub_png_get_bits (struct grub_png_data *data, int num)
+{
+ int code, shift;
+
+ if (data->bit_count == 0)
+ {
+ data->bit_save = grub_png_get_byte (data);
+ data->bit_count = 8;
+ }
+
+ code = 0;
+ shift = 0;
+ while (grub_errno == 0)
+ {
+ int n;
+
+ n = data->bit_count;
+ if (n > num)
+ n = num;
+
+ code += (int) (data->bit_save & ((1 << n) - 1)) << shift;
+ num -= n;
+ if (!num)
+ {
+ data->bit_count -= n;
+ data->bit_save >>= n;
+ break;
+ }
+
+ shift += n;
+
+ data->bit_save = grub_png_get_byte (data);
+ data->bit_count = 8;
+ }
+
+ return code;
+}
+
+static grub_err_t
+grub_png_decode_image_palette (struct grub_png_data *data,
+ unsigned len)
+{
+ unsigned i = 0, j;
+
+ if (len == 0)
+ return GRUB_ERR_NONE;
+
+ for (i = 0; 3 * i < len && i < 256; i++)
+ for (j = 0; j < 3; j++)
+ data->palette[i][j] = grub_png_get_byte (data);
+ for (i *= 3; i < len; i++)
+ grub_png_get_byte (data);
+
+ grub_png_get_dword (data);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_png_decode_image_header (struct grub_png_data *data)
+{
+ int color_type;
+ int color_bits;
+ enum grub_video_blit_format blt;
+
+ data->image_width = grub_png_get_dword (data);
+ data->image_height = grub_png_get_dword (data);
+
+ if ((!data->image_height) || (!data->image_width))
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: invalid image size");
+
+ color_bits = grub_png_get_byte (data);
+ data->is_16bit = (color_bits == 16);
+
+ color_type = grub_png_get_byte (data);
+
+ /* According to PNG spec, no other types are valid. */
+ if ((color_type & ~(PNG_COLOR_MASK_ALPHA | PNG_COLOR_MASK_COLOR))
+ && (color_type != PNG_COLOR_TYPE_PALETTE))
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: color type not supported");
+ if (color_type == PNG_COLOR_TYPE_PALETTE)
+ data->is_palette = 1;
+ if (data->is_16bit && data->is_palette)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: color type not supported");
+ if (color_type & PNG_COLOR_MASK_ALPHA)
+ blt = GRUB_VIDEO_BLIT_FORMAT_RGBA_8888;
+ else
+ blt = GRUB_VIDEO_BLIT_FORMAT_RGB_888;
+ if (data->is_palette)
+ data->bpp = 1;
+ else if (color_type & PNG_COLOR_MASK_COLOR)
+ data->bpp = 3;
+ else
+ {
+ data->is_gray = 1;
+ data->bpp = 1;
+ }
+
+ if ((color_bits != 8) && (color_bits != 16)
+ && (color_bits != 4
+ || !(data->is_gray || data->is_palette)))
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: bit depth must be 8 or 16");
+
+ if (color_type & PNG_COLOR_MASK_ALPHA)
+ data->bpp++;
+
+ if (grub_video_bitmap_create (data->bitmap, data->image_width,
+ data->image_height,
+ blt))
+ return grub_errno;
+
+ if (data->is_16bit)
+ data->bpp <<= 1;
+
+ data->color_bits = color_bits;
+
+ if (grub_mul (data->image_width, data->bpp, &data->row_bytes))
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+
+ if (data->color_bits <= 4)
+ {
+ if (grub_mul (data->image_width, data->color_bits + 7, &data->row_bytes))
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
+
+ data->row_bytes >>= 3;
+ }
+
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ if (data->is_16bit || data->is_gray || data->is_palette)
+#endif
+ {
+ data->image_data = grub_calloc (data->image_height, data->row_bytes);
+ if (grub_errno)
+ return grub_errno;
+
+ data->cur_rgb = data->image_data;
+ }
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ else
+ {
+ data->image_data = 0;
+ data->cur_rgb = (*data->bitmap)->data;
+ }
+#endif
+
+ data->raw_bytes = data->image_height * (data->row_bytes + 1);
+
+ data->cur_column = 0;
+ data->first_line = 1;
+
+ if (grub_png_get_byte (data) != PNG_COMPRESSION_BASE)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: compression method not supported");
+
+ if (grub_png_get_byte (data) != PNG_FILTER_TYPE_BASE)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: filter method not supported");
+
+ if (grub_png_get_byte (data) != PNG_INTERLACE_NONE)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: interlace method not supported");
+
+ /* Skip crc checksum. */
+ grub_png_get_dword (data);
+
+ return grub_errno;
+}
+
+/* Order of the bit length code lengths. */
+static const grub_uint8_t bitorder[] = {
+ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
+};
+
+/* Copy lengths for literal codes 257..285. */
+static const int cplens[] = {
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
+ 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
+};
+
+/* Extra bits for literal codes 257..285. */
+static const grub_uint8_t cplext[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
+ 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99
+}; /* 99==invalid */
+
+/* Copy offsets for distance codes 0..29. */
+static const int cpdist[] = {
+ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
+ 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
+ 8193, 12289, 16385, 24577
+};
+
+/* Extra bits for distance codes. */
+static const grub_uint8_t cpdext[] = {
+ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
+ 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
+ 12, 12, 13, 13
+};
+
+static void
+grub_png_init_huff_table (struct huff_table *ht, int cur_maxlen,
+ int *cur_values, int *cur_maxval, int *cur_offset)
+{
+ ht->values = cur_values;
+ ht->maxval = cur_maxval;
+ ht->offset = cur_offset;
+ ht->num_values = 0;
+ ht->max_length = cur_maxlen;
+ grub_memset (cur_maxval, 0, sizeof (int) * cur_maxlen);
+}
+
+static void
+grub_png_insert_huff_item (struct huff_table *ht, int code, int len)
+{
+ int i, n;
+
+ if (len == 0)
+ return;
+
+ if (len > ht->max_length)
+ {
+ grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: invalid code length");
+ return;
+ }
+
+ n = 0;
+ for (i = len; i < ht->max_length; i++)
+ n += ht->maxval[i];
+
+ for (i = 0; i < n; i++)
+ ht->values[ht->num_values - i] = ht->values[ht->num_values - i - 1];
+
+ ht->values[ht->num_values - n] = code;
+ ht->num_values++;
+ ht->maxval[len - 1]++;
+}
+
+static void
+grub_png_build_huff_table (struct huff_table *ht)
+{
+ int base, ofs, i;
+
+ base = 0;
+ ofs = 0;
+ for (i = 0; i < ht->max_length; i++)
+ {
+ base += ht->maxval[i];
+ ofs += ht->maxval[i];
+
+ ht->maxval[i] = base;
+ ht->offset[i] = ofs - base;
+
+ base <<= 1;
+ }
+}
+
+static int
+grub_png_get_huff_code (struct grub_png_data *data, struct huff_table *ht)
+{
+ int code, i;
+
+ code = 0;
+ for (i = 0; i < ht->max_length; i++)
+ {
+ code = (code << 1) + grub_png_get_bits (data, 1);
+ if (code < ht->maxval[i])
+ return ht->values[code + ht->offset[i]];
+ }
+ return 0;
+}
+
+static grub_err_t
+grub_png_init_fixed_block (struct grub_png_data *data)
+{
+ int i;
+
+ grub_png_init_huff_table (&data->code_table, DEFLATE_HUFF_LEN,
+ data->code_values, data->code_maxval,
+ data->code_offset);
+
+ for (i = 0; i < 144; i++)
+ grub_png_insert_huff_item (&data->code_table, i, 8);
+
+ for (; i < 256; i++)
+ grub_png_insert_huff_item (&data->code_table, i, 9);
+
+ for (; i < 280; i++)
+ grub_png_insert_huff_item (&data->code_table, i, 7);
+
+ for (; i < DEFLATE_HLIT_MAX; i++)
+ grub_png_insert_huff_item (&data->code_table, i, 8);
+
+ grub_png_build_huff_table (&data->code_table);
+
+ grub_png_init_huff_table (&data->dist_table, DEFLATE_HUFF_LEN,
+ data->dist_values, data->dist_maxval,
+ data->dist_offset);
+
+ for (i = 0; i < DEFLATE_HDIST_MAX; i++)
+ grub_png_insert_huff_item (&data->dist_table, i, 5);
+
+ grub_png_build_huff_table (&data->dist_table);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_png_init_dynamic_block (struct grub_png_data *data)
+{
+ int nl, nd, nb, i, prev;
+ struct huff_table cl;
+ int cl_values[sizeof (bitorder)];
+ int cl_maxval[8];
+ int cl_offset[8];
+ grub_uint8_t lens[DEFLATE_HCLEN_MAX];
+
+ nl = DEFLATE_HLIT_BASE + grub_png_get_bits (data, 5);
+ nd = DEFLATE_HDIST_BASE + grub_png_get_bits (data, 5);
+ nb = DEFLATE_HCLEN_BASE + grub_png_get_bits (data, 4);
+
+ if ((nl > DEFLATE_HLIT_MAX) || (nd > DEFLATE_HDIST_MAX) ||
+ (nb > DEFLATE_HCLEN_MAX))
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: too much data");
+
+ grub_png_init_huff_table (&cl, 8, cl_values, cl_maxval, cl_offset);
+
+ for (i = 0; i < nb; i++)
+ lens[bitorder[i]] = grub_png_get_bits (data, 3);
+
+ for (; i < DEFLATE_HCLEN_MAX; i++)
+ lens[bitorder[i]] = 0;
+
+ for (i = 0; i < DEFLATE_HCLEN_MAX; i++)
+ grub_png_insert_huff_item (&cl, i, lens[i]);
+
+ grub_png_build_huff_table (&cl);
+
+ grub_png_init_huff_table (&data->code_table, DEFLATE_HUFF_LEN,
+ data->code_values, data->code_maxval,
+ data->code_offset);
+
+ grub_png_init_huff_table (&data->dist_table, DEFLATE_HUFF_LEN,
+ data->dist_values, data->dist_maxval,
+ data->dist_offset);
+
+ prev = 0;
+ for (i = 0; i < nl + nd; i++)
+ {
+ int n, code;
+ struct huff_table *ht;
+
+ if (grub_errno)
+ return grub_errno;
+
+ if (i < nl)
+ {
+ ht = &data->code_table;
+ code = i;
+ }
+ else
+ {
+ ht = &data->dist_table;
+ code = i - nl;
+ }
+
+ n = grub_png_get_huff_code (data, &cl);
+ if (n < 16)
+ {
+ grub_png_insert_huff_item (ht, code, n);
+ prev = n;
+ }
+ else if (n == 16)
+ {
+ int c;
+
+ c = 3 + grub_png_get_bits (data, 2);
+ while (c > 0)
+ {
+ grub_png_insert_huff_item (ht, code++, prev);
+ i++;
+ c--;
+ }
+ i--;
+ }
+ else if (n == 17)
+ i += 3 + grub_png_get_bits (data, 3) - 1;
+ else
+ i += 11 + grub_png_get_bits (data, 7) - 1;
+ }
+
+ grub_png_build_huff_table (&data->code_table);
+ grub_png_build_huff_table (&data->dist_table);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_png_output_byte (struct grub_png_data *data, grub_uint8_t n)
+{
+ if (--data->raw_bytes < 0)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "image size overflown");
+
+ if (data->cur_column == 0)
+ {
+ if (n >= PNG_FILTER_VALUE_LAST)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid filter value");
+
+ data->cur_filter = n;
+ }
+ else
+ *data->cur_rgb++ = n;
+
+ data->cur_column++;
+ if (data->cur_column == data->row_bytes + 1)
+ {
+ grub_uint8_t *blank_line = NULL;
+ grub_uint8_t *cur = data->cur_rgb - data->row_bytes;
+ grub_uint8_t *left = cur;
+ grub_uint8_t *up;
+
+ if (data->first_line)
+ {
+ blank_line = grub_zalloc (data->row_bytes);
+ if (blank_line == NULL)
+ return grub_errno;
+
+ up = blank_line;
+ }
+ else
+ up = cur - data->row_bytes;
+
+ switch (data->cur_filter)
+ {
+ case PNG_FILTER_VALUE_SUB:
+ {
+ int i;
+
+ cur += data->bpp;
+ for (i = data->bpp; i < data->row_bytes; i++, cur++, left++)
+ *cur += *left;
+
+ break;
+ }
+ case PNG_FILTER_VALUE_UP:
+ {
+ int i;
+
+ for (i = 0; i < data->row_bytes; i++, cur++, up++)
+ *cur += *up;
+
+ break;
+ }
+ case PNG_FILTER_VALUE_AVG:
+ {
+ int i;
+
+ for (i = 0; i < data->bpp; i++, cur++, up++)
+ *cur += *up >> 1;
+
+ for (; i < data->row_bytes; i++, cur++, up++, left++)
+ *cur += ((int) *up + (int) *left) >> 1;
+
+ break;
+ }
+ case PNG_FILTER_VALUE_PAETH:
+ {
+ int i;
+ grub_uint8_t *upper_left = up;
+
+ for (i = 0; i < data->bpp; i++, cur++, up++)
+ *cur += *up;
+
+ for (; i < data->row_bytes; i++, cur++, up++, left++, upper_left++)
+ {
+ int a, b, c, pa, pb, pc;
+
+ a = *left;
+ b = *up;
+ c = *upper_left;
+
+ pa = b - c;
+ pb = a - c;
+ pc = pa + pb;
+
+ if (pa < 0)
+ pa = -pa;
+
+ if (pb < 0)
+ pb = -pb;
+
+ if (pc < 0)
+ pc = -pc;
+
+ *cur += ((pa <= pb) && (pa <= pc)) ? a : (pb <= pc) ? b : c;
+ }
+ }
+ }
+
+ grub_free (blank_line);
+
+ data->cur_column = 0;
+ data->first_line = 0;
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_png_read_dynamic_block (struct grub_png_data *data)
+{
+ while (grub_errno == 0)
+ {
+ int n;
+
+ n = grub_png_get_huff_code (data, &data->code_table);
+ if (n < 256)
+ {
+ data->slide[data->wp] = n;
+ grub_png_output_byte (data, n);
+
+ data->wp++;
+ if (data->wp >= WSIZE)
+ data->wp = 0;
+ }
+ else if (n == 256)
+ break;
+ else
+ {
+ int len, dist, pos;
+
+ n -= 257;
+ len = cplens[n];
+ if (cplext[n])
+ len += grub_png_get_bits (data, cplext[n]);
+
+ n = grub_png_get_huff_code (data, &data->dist_table);
+ dist = cpdist[n];
+ if (cpdext[n])
+ dist += grub_png_get_bits (data, cpdext[n]);
+
+ pos = data->wp - dist;
+ if (pos < 0)
+ pos += WSIZE;
+
+ while (len > 0)
+ {
+ data->slide[data->wp] = data->slide[pos];
+ grub_png_output_byte (data, data->slide[data->wp]);
+
+ data->wp++;
+ if (data->wp >= WSIZE)
+ data->wp = 0;
+
+ pos++;
+ if (pos >= WSIZE)
+ pos = 0;
+
+ len--;
+ }
+ }
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_png_decode_image_data (struct grub_png_data *data)
+{
+ grub_uint8_t cmf, flg;
+ int final;
+
+ cmf = grub_png_get_byte (data);
+ flg = grub_png_get_byte (data);
+
+ if ((cmf & 0xF) != Z_DEFLATED)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: only support deflate compression method");
+
+ if (flg & Z_FLAG_DICT)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: dictionary not supported");
+
+ do
+ {
+ int block_type;
+
+ final = grub_png_get_bits (data, 1);
+ block_type = grub_png_get_bits (data, 2);
+
+ switch (block_type)
+ {
+ case INFLATE_STORED:
+ {
+ grub_uint16_t i, len;
+
+ data->bit_count = 0;
+ len = grub_png_get_byte (data);
+ len += ((grub_uint16_t) grub_png_get_byte (data)) << 8;
+
+ /* Skip NLEN field. */
+ grub_png_get_byte (data);
+ grub_png_get_byte (data);
+
+ for (i = 0; i < len; i++)
+ grub_png_output_byte (data, grub_png_get_byte (data));
+
+ break;
+ }
+
+ case INFLATE_FIXED:
+ grub_png_init_fixed_block (data);
+ grub_png_read_dynamic_block (data);
+ break;
+
+ case INFLATE_DYNAMIC:
+ grub_png_init_dynamic_block (data);
+ grub_png_read_dynamic_block (data);
+ break;
+
+ default:
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: unknown block type");
+ }
+ }
+ while ((!final) && (grub_errno == 0));
+
+ /* Skip adler checksum. */
+ grub_png_get_dword (data);
+
+ /* Skip crc checksum. */
+ grub_png_get_dword (data);
+
+ return grub_errno;
+}
+
+static const grub_uint8_t png_magic[8] =
+ { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0x0a };
+
+static void
+grub_png_convert_image (struct grub_png_data *data)
+{
+ unsigned i;
+ grub_uint8_t *d1, *d2;
+
+ d1 = (*data->bitmap)->data;
+ d2 = data->image_data + data->is_16bit;
+
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+#define R4 3
+#define G4 2
+#define B4 1
+#define A4 0
+#define R3 2
+#define G3 1
+#define B3 0
+#else
+#define R4 0
+#define G4 1
+#define B4 2
+#define A4 3
+#define R3 0
+#define G3 1
+#define B3 2
+#endif
+
+ if (data->color_bits <= 4)
+ {
+ grub_uint8_t palette[16][3];
+ grub_uint8_t *d1c, *d2c;
+ int shift;
+ int mask = (1 << data->color_bits) - 1;
+ unsigned j;
+ if (data->is_gray)
+ {
+ /* 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, 3 << data->color_bits);
+ d1c = d1;
+ d2c = d2;
+ for (j = 0; j < data->image_height; j++, d1c += data->image_width * 3,
+ d2c += data->row_bytes)
+ {
+ d1 = d1c;
+ d2 = d2c;
+ shift = 8 - data->color_bits;
+ for (i = 0; i < data->image_width; i++, d1 += 3)
+ {
+ grub_uint8_t col = (d2[0] >> shift) & mask;
+ d1[R3] = data->palette[col][2];
+ d1[G3] = data->palette[col][1];
+ d1[B3] = data->palette[col][0];
+ shift -= data->color_bits;
+ if (shift < 0)
+ {
+ d2++;
+ shift += 8;
+ }
+ }
+ }
+ return;
+ }
+
+ if (data->is_palette)
+ {
+ for (i = 0; i < (data->image_width * data->image_height);
+ i++, d1 += 3, d2++)
+ {
+ d1[R3] = data->palette[d2[0]][2];
+ d1[G3] = data->palette[d2[0]][1];
+ d1[B3] = data->palette[d2[0]][0];
+ }
+ return;
+ }
+
+ if (data->is_gray)
+ {
+ switch (data->bpp)
+ {
+ case 4:
+ /* 16-bit gray with alpha. */
+ for (i = 0; i < (data->image_width * data->image_height);
+ i++, d1 += 4, d2 += 4)
+ {
+ d1[R4] = d2[3];
+ d1[G4] = d2[3];
+ d1[B4] = d2[3];
+ d1[A4] = d2[1];
+ }
+ break;
+ case 2:
+ if (data->is_16bit)
+ /* 16-bit gray without alpha. */
+ {
+ for (i = 0; i < (data->image_width * data->image_height);
+ i++, d1 += 4, d2 += 2)
+ {
+ d1[R3] = d2[1];
+ d1[G3] = d2[1];
+ d1[B3] = d2[1];
+ }
+ }
+ else
+ /* 8-bit gray with alpha. */
+ {
+ for (i = 0; i < (data->image_width * data->image_height);
+ i++, d1 += 4, d2 += 2)
+ {
+ d1[R4] = d2[1];
+ d1[G4] = d2[1];
+ d1[B4] = d2[1];
+ d1[A4] = d2[0];
+ }
+ }
+ break;
+ /* 8-bit gray without alpha. */
+ case 1:
+ for (i = 0; i < (data->image_width * data->image_height);
+ i++, d1 += 3, d2++)
+ {
+ d1[R3] = d2[0];
+ d1[G3] = d2[0];
+ d1[B3] = d2[0];
+ }
+ break;
+ }
+ return;
+ }
+
+ {
+ /* Only copy the upper 8 bit. */
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ for (i = 0; i < (data->image_width * data->image_height * data->bpp >> 1);
+ i++, d1++, d2 += 2)
+ *d1 = *d2;
+#else
+ switch (data->bpp)
+ {
+ /* 16-bit with alpha. */
+ case 8:
+ for (i = 0; i < (data->image_width * data->image_height);
+ i++, d1 += 4, d2+=8)
+ {
+ d1[0] = d2[7];
+ d1[1] = d2[5];
+ d1[2] = d2[3];
+ d1[3] = d2[1];
+ }
+ break;
+ /* 16-bit without alpha. */
+ case 6:
+ for (i = 0; i < (data->image_width * data->image_height);
+ i++, d1 += 3, d2+=6)
+ {
+ d1[0] = d2[5];
+ d1[1] = d2[3];
+ d1[2] = d2[1];
+ }
+ break;
+ case 4:
+ /* 8-bit with alpha. */
+ for (i = 0; i < (data->image_width * data->image_height);
+ i++, d1 += 4, d2 += 4)
+ {
+ d1[0] = d2[3];
+ d1[1] = d2[2];
+ d1[2] = d2[1];
+ d1[3] = d2[0];
+ }
+ break;
+ /* 8-bit without alpha. */
+ case 3:
+ for (i = 0; i < (data->image_width * data->image_height);
+ i++, d1 += 3, d2 += 3)
+ {
+ d1[0] = d2[2];
+ d1[1] = d2[1];
+ d1[2] = d2[0];
+ }
+ break;
+ }
+#endif
+ }
+
+}
+
+static grub_err_t
+grub_png_decode_png (struct grub_png_data *data)
+{
+ grub_uint8_t magic[8];
+
+ if (grub_file_read (data->file, &magic[0], 8) != 8)
+ return grub_errno;
+
+ if (grub_memcmp (magic, png_magic, sizeof (png_magic)))
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: not a png file");
+
+ while (1)
+ {
+ grub_uint32_t len, type;
+
+ len = grub_png_get_dword (data);
+ type = grub_png_get_dword (data);
+ data->next_offset = data->file->offset + len + 4;
+
+ switch (type)
+ {
+ case PNG_CHUNK_IHDR:
+ grub_png_decode_image_header (data);
+ break;
+
+ case PNG_CHUNK_PLTE:
+ grub_png_decode_image_palette (data, len);
+ break;
+
+ case PNG_CHUNK_IDAT:
+ data->inside_idat = 1;
+ data->idat_remain = len;
+ data->bit_count = 0;
+
+ grub_png_decode_image_data (data);
+
+ data->inside_idat = 0;
+ break;
+
+ case PNG_CHUNK_IEND:
+ if (data->image_data)
+ grub_png_convert_image (data);
+
+ return grub_errno;
+
+ default:
+ grub_file_seek (data->file, data->file->offset + len + 4);
+ }
+
+ if (grub_errno)
+ break;
+
+ if (data->file->offset != data->next_offset)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "png: chunk size error");
+ }
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_video_reader_png (struct grub_video_bitmap **bitmap,
+ const char *filename)
+{
+ grub_file_t file;
+ struct grub_png_data *data;
+
+ file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0);
+ if (!file)
+ return grub_errno;
+
+ data = grub_zalloc (sizeof (*data));
+ if (data != NULL)
+ {
+ data->file = file;
+ data->bitmap = bitmap;
+
+ grub_png_decode_png (data);
+
+ grub_free (data->image_data);
+ grub_free (data);
+ }
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_video_bitmap_destroy (*bitmap);
+ *bitmap = 0;
+ }
+
+ grub_file_close (file);
+ return grub_errno;
+}
+
+#if defined(PNG_DEBUG)
+static grub_err_t
+grub_cmd_pngtest (grub_command_t cmd_d __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_video_bitmap *bitmap = 0;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+
+ grub_video_reader_png (&bitmap, args[0]);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ grub_video_bitmap_destroy (bitmap);
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+static struct grub_video_bitmap_reader png_reader = {
+ .extension = ".png",
+ .reader = grub_video_reader_png,
+ .next = 0
+};
+
+GRUB_MOD_INIT (png)
+{
+ grub_video_bitmap_reader_register (&png_reader);
+#if defined(PNG_DEBUG)
+ cmd = grub_register_command ("pngtest", grub_cmd_pngtest,
+ "FILE",
+ "Tests loading of PNG bitmap.");
+#endif
+}
+
+GRUB_MOD_FINI (png)
+{
+#if defined(PNG_DEBUG)
+ grub_unregister_command (cmd);
+#endif
+ grub_video_bitmap_reader_unregister (&png_reader);
+}
diff --git a/grub-core/video/readers/tga.c b/grub-core/video/readers/tga.c
new file mode 100644
index 0000000..7cb9d1d
--- /dev/null
+++ b/grub-core/video/readers/tga.c
@@ -0,0 +1,511 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/bitmap.h>
+#include <grub/types.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/bufio.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* Uncomment following define to enable TGA debug. */
+//#define TGA_DEBUG
+
+#define dump_int_field(x) grub_dprintf ("tga", #x " = %d (0x%04x)\n", x, x);
+#if defined(TGA_DEBUG)
+static grub_command_t cmd;
+#endif
+
+enum
+{
+ GRUB_TGA_IMAGE_TYPE_NONE = 0,
+ GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_INDEXCOLOR = 1,
+ GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_TRUECOLOR = 2,
+ GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_BLACK_AND_WHITE = 3,
+ GRUB_TGA_IMAGE_TYPE_RLE_INDEXCOLOR = 9,
+ GRUB_TGA_IMAGE_TYPE_RLE_TRUECOLOR = 10,
+ GRUB_TGA_IMAGE_TYPE_RLE_BLACK_AND_WHITE = 11,
+};
+
+enum
+{
+ GRUB_TGA_COLOR_MAP_TYPE_NONE = 0,
+ GRUB_TGA_COLOR_MAP_TYPE_INCLUDED = 1
+};
+
+enum
+{
+ GRUB_TGA_IMAGE_ORIGIN_RIGHT = 0x10,
+ GRUB_TGA_IMAGE_ORIGIN_TOP = 0x20
+};
+
+struct grub_tga_header
+{
+ grub_uint8_t id_length;
+ grub_uint8_t color_map_type;
+ grub_uint8_t image_type;
+
+ /* Color Map Specification. */
+ grub_uint16_t color_map_first_index;
+ grub_uint16_t color_map_length;
+ grub_uint8_t color_map_bpp;
+
+ /* Image Specification. */
+ grub_uint16_t image_x_origin;
+ grub_uint16_t image_y_origin;
+ grub_uint16_t image_width;
+ grub_uint16_t image_height;
+ grub_uint8_t image_bpp;
+ grub_uint8_t image_descriptor;
+} GRUB_PACKED;
+
+struct tga_data
+{
+ struct grub_tga_header hdr;
+ int uses_rle;
+ int pktlen;
+ int bpp;
+ int is_rle;
+ grub_uint8_t pixel[4];
+ grub_uint8_t palette[256][3];
+ struct grub_video_bitmap *bitmap;
+ grub_file_t file;
+ unsigned image_width;
+ unsigned image_height;
+};
+
+static grub_err_t
+fetch_pixel (struct tga_data *data)
+{
+ if (!data->uses_rle)
+ {
+ if (grub_file_read (data->file, &data->pixel[0], data->bpp)
+ != data->bpp)
+ return grub_errno;
+ return GRUB_ERR_NONE;
+ }
+ if (!data->pktlen)
+ {
+ grub_uint8_t type;
+ if (grub_file_read (data->file, &type, sizeof (type)) != sizeof(type))
+ return grub_errno;
+ data->is_rle = !!(type & 0x80);
+ data->pktlen = (type & 0x7f) + 1;
+ if (data->is_rle && grub_file_read (data->file, &data->pixel[0], data->bpp)
+ != data->bpp)
+ return grub_errno;
+ }
+ if (!data->is_rle && grub_file_read (data->file, &data->pixel[0], data->bpp)
+ != data->bpp)
+ return grub_errno;
+ data->pktlen--;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+tga_load_palette (struct tga_data *data)
+{
+ grub_size_t len = grub_le_to_cpu32 (data->hdr.color_map_length) * 3;
+
+ if (len > sizeof (data->palette))
+ len = sizeof (data->palette);
+
+ if (grub_file_read (data->file, &data->palette, len)
+ != (grub_ssize_t) len)
+ return grub_errno;
+
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+ {
+ grub_size_t i;
+ for (i = 0; 3 * i < len; i++)
+ {
+ grub_uint8_t t;
+ t = data->palette[i][0];
+ data->palette[i][0] = data->palette[i][2];
+ data->palette[i][2] = t;
+ }
+ }
+#endif
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+tga_load_index_color (struct tga_data *data)
+{
+ unsigned int x;
+ unsigned int y;
+ grub_uint8_t *ptr;
+
+ for (y = 0; y < data->image_height; y++)
+ {
+ ptr = data->bitmap->data;
+ if ((data->hdr.image_descriptor & GRUB_TGA_IMAGE_ORIGIN_TOP) != 0)
+ ptr += y * data->bitmap->mode_info.pitch;
+ else
+ ptr += (data->image_height - 1 - y) * data->bitmap->mode_info.pitch;
+
+ for (x = 0; x < data->image_width; x++)
+ {
+ grub_err_t err;
+ err = fetch_pixel (data);
+ if (err)
+ return err;
+
+ ptr[0] = data->palette[data->pixel[0]][0];
+ ptr[1] = data->palette[data->pixel[0]][1];
+ ptr[2] = data->palette[data->pixel[0]][2];
+
+ ptr += 3;
+ }
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+tga_load_grayscale (struct tga_data *data)
+{
+ unsigned int x;
+ unsigned int y;
+ grub_uint8_t *ptr;
+
+ for (y = 0; y < data->image_height; y++)
+ {
+ ptr = data->bitmap->data;
+ if ((data->hdr.image_descriptor & GRUB_TGA_IMAGE_ORIGIN_TOP) != 0)
+ ptr += y * data->bitmap->mode_info.pitch;
+ else
+ ptr += (data->image_height - 1 - y) * data->bitmap->mode_info.pitch;
+
+ for (x = 0; x < data->image_width; x++)
+ {
+ grub_err_t err;
+ err = fetch_pixel (data);
+ if (err)
+ return err;
+
+ ptr[0] = data->pixel[0];
+ ptr[1] = data->pixel[0];
+ ptr[2] = data->pixel[0];
+
+ ptr += 3;
+ }
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+tga_load_truecolor_R8G8B8 (struct tga_data *data)
+{
+ unsigned int x;
+ unsigned int y;
+ grub_uint8_t *ptr;
+
+ for (y = 0; y < data->image_height; y++)
+ {
+ ptr = data->bitmap->data;
+ if ((data->hdr.image_descriptor & GRUB_TGA_IMAGE_ORIGIN_TOP) != 0)
+ ptr += y * data->bitmap->mode_info.pitch;
+ else
+ ptr += (data->image_height - 1 - y) * data->bitmap->mode_info.pitch;
+
+ for (x = 0; x < data->image_width; x++)
+ {
+ grub_err_t err;
+ err = fetch_pixel (data);
+ if (err)
+ return err;
+
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ ptr[0] = data->pixel[0];
+ ptr[1] = data->pixel[1];
+ ptr[2] = data->pixel[2];
+#else
+ ptr[0] = data->pixel[2];
+ ptr[1] = data->pixel[1];
+ ptr[2] = data->pixel[0];
+#endif
+ ptr += 3;
+ }
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+tga_load_truecolor_R8G8B8A8 (struct tga_data *data)
+{
+ unsigned int x;
+ unsigned int y;
+ grub_uint8_t *ptr;
+
+ for (y = 0; y < data->image_height; y++)
+ {
+ ptr = data->bitmap->data;
+ if ((data->hdr.image_descriptor & GRUB_TGA_IMAGE_ORIGIN_TOP) != 0)
+ ptr += y * data->bitmap->mode_info.pitch;
+ else
+ ptr += (data->image_height - 1 - y) * data->bitmap->mode_info.pitch;
+
+ for (x = 0; x < data->image_width; x++)
+ {
+ grub_err_t err;
+ err = fetch_pixel (data);
+ if (err)
+ return err;
+
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ ptr[0] = data->pixel[0];
+ ptr[1] = data->pixel[1];
+ ptr[2] = data->pixel[2];
+ ptr[3] = data->pixel[3];
+#else
+ ptr[0] = data->pixel[2];
+ ptr[1] = data->pixel[1];
+ ptr[2] = data->pixel[0];
+ ptr[3] = data->pixel[3];
+#endif
+
+ ptr += 4;
+ }
+ }
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_reader_tga (struct grub_video_bitmap **bitmap,
+ const char *filename)
+{
+ grub_ssize_t pos;
+ struct tga_data data;
+
+ grub_memset (&data, 0, sizeof (data));
+
+ data.file = grub_buffile_open (filename, GRUB_FILE_TYPE_PIXMAP, 0);
+ if (! data.file)
+ return grub_errno;
+
+ /* TGA Specification states that we SHOULD start by reading
+ ID from end of file, but we really don't care about that as we are
+ not going to support developer area & extensions at this point. */
+
+ /* Read TGA header from beginning of file. */
+ if (grub_file_read (data.file, &data.hdr, sizeof (data.hdr))
+ != sizeof (data.hdr))
+ {
+ grub_file_close (data.file);
+ return grub_errno;
+ }
+
+ /* Skip ID field. */
+ pos = grub_file_tell (data.file);
+ pos += data.hdr.id_length;
+ grub_file_seek (data.file, pos);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_file_close (data.file);
+ return grub_errno;
+ }
+
+ grub_dprintf("tga", "tga: header\n");
+ dump_int_field(data.hdr.id_length);
+ dump_int_field(data.hdr.color_map_type);
+ dump_int_field(data.hdr.image_type);
+ dump_int_field(data.hdr.color_map_first_index);
+ dump_int_field(data.hdr.color_map_length);
+ dump_int_field(data.hdr.color_map_bpp);
+ dump_int_field(data.hdr.image_x_origin);
+ dump_int_field(data.hdr.image_y_origin);
+ dump_int_field(data.hdr.image_width);
+ dump_int_field(data.hdr.image_height);
+ dump_int_field(data.hdr.image_bpp);
+ dump_int_field(data.hdr.image_descriptor);
+
+ data.image_width = grub_le_to_cpu16 (data.hdr.image_width);
+ data.image_height = grub_le_to_cpu16 (data.hdr.image_height);
+
+ /* Check that bitmap encoding is supported. */
+ switch (data.hdr.image_type)
+ {
+ case GRUB_TGA_IMAGE_TYPE_RLE_TRUECOLOR:
+ case GRUB_TGA_IMAGE_TYPE_RLE_BLACK_AND_WHITE:
+ case GRUB_TGA_IMAGE_TYPE_RLE_INDEXCOLOR:
+ data.uses_rle = 1;
+ break;
+ case GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_TRUECOLOR:
+ case GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_BLACK_AND_WHITE:
+ case GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_INDEXCOLOR:
+ data.uses_rle = 0;
+ break;
+
+ default:
+ grub_file_close (data.file);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "unsupported bitmap format (unknown encoding %d)", data.hdr.image_type);
+ }
+
+ data.bpp = data.hdr.image_bpp / 8;
+
+ /* Check that bitmap depth is supported. */
+ switch (data.hdr.image_type)
+ {
+ case GRUB_TGA_IMAGE_TYPE_RLE_BLACK_AND_WHITE:
+ case GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_BLACK_AND_WHITE:
+ if (data.hdr.image_bpp != 8)
+ {
+ grub_file_close (data.file);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "unsupported bitmap format (bpp=%d)",
+ data.hdr.image_bpp);
+ }
+ grub_video_bitmap_create (bitmap, data.image_width,
+ data.image_height,
+ GRUB_VIDEO_BLIT_FORMAT_RGB_888);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_file_close (data.file);
+ return grub_errno;
+ }
+
+ data.bitmap = *bitmap;
+ /* Load bitmap data. */
+ tga_load_grayscale (&data);
+ break;
+
+ case GRUB_TGA_IMAGE_TYPE_RLE_INDEXCOLOR:
+ case GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_INDEXCOLOR:
+ if (data.hdr.image_bpp != 8
+ || data.hdr.color_map_bpp != 24
+ || data.hdr.color_map_first_index != 0)
+ {
+ grub_file_close (data.file);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "unsupported bitmap format (bpp=%d)",
+ data.hdr.image_bpp);
+ }
+ grub_video_bitmap_create (bitmap, data.image_width,
+ data.image_height,
+ GRUB_VIDEO_BLIT_FORMAT_RGB_888);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_file_close (data.file);
+ return grub_errno;
+ }
+
+ data.bitmap = *bitmap;
+ /* Load bitmap data. */
+ tga_load_palette (&data);
+ tga_load_index_color (&data);
+ break;
+
+ case GRUB_TGA_IMAGE_TYPE_RLE_TRUECOLOR:
+ case GRUB_TGA_IMAGE_TYPE_UNCOMPRESSED_TRUECOLOR:
+ switch (data.hdr.image_bpp)
+ {
+ case 24:
+ grub_video_bitmap_create (bitmap, data.image_width,
+ data.image_height,
+ GRUB_VIDEO_BLIT_FORMAT_RGB_888);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_file_close (data.file);
+ return grub_errno;
+ }
+
+ data.bitmap = *bitmap;
+ /* Load bitmap data. */
+ tga_load_truecolor_R8G8B8 (&data);
+ break;
+
+ case 32:
+ grub_video_bitmap_create (bitmap, data.image_width,
+ data.image_height,
+ GRUB_VIDEO_BLIT_FORMAT_RGBA_8888);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_file_close (data.file);
+ return grub_errno;
+ }
+
+ data.bitmap = *bitmap;
+ /* Load bitmap data. */
+ tga_load_truecolor_R8G8B8A8 (&data);
+ break;
+
+ default:
+ grub_file_close (data.file);
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+ "unsupported bitmap format (bpp=%d)",
+ data.hdr.image_bpp);
+ }
+ }
+
+ /* If there was a loading problem, destroy bitmap. */
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_video_bitmap_destroy (*bitmap);
+ *bitmap = 0;
+ }
+
+ grub_file_close (data.file);
+ return grub_errno;
+}
+
+#if defined(TGA_DEBUG)
+static grub_err_t
+grub_cmd_tgatest (grub_command_t cmd_d __attribute__ ((unused)),
+ int argc, char **args)
+{
+ struct grub_video_bitmap *bitmap = 0;
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
+
+ grub_video_reader_tga (&bitmap, args[0]);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ grub_video_bitmap_destroy (bitmap);
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
+static struct grub_video_bitmap_reader tga_reader = {
+ .extension = ".tga",
+ .reader = grub_video_reader_tga,
+ .next = 0
+};
+
+GRUB_MOD_INIT(tga)
+{
+ grub_video_bitmap_reader_register (&tga_reader);
+#if defined(TGA_DEBUG)
+ cmd = grub_register_command ("tgatest", grub_cmd_tgatest,
+ "FILE", "Tests loading of TGA bitmap.");
+#endif
+}
+
+GRUB_MOD_FINI(tga)
+{
+#if defined(TGA_DEBUG)
+ grub_unregister_command (cmd);
+#endif
+ grub_video_bitmap_reader_unregister (&tga_reader);
+}
diff --git a/grub-core/video/sis315_init.c b/grub-core/video/sis315_init.c
new file mode 100644
index 0000000..ae5c141
--- /dev/null
+++ b/grub-core/video/sis315_init.c
@@ -0,0 +1,158 @@
+static const struct { grub_uint8_t reg; grub_uint8_t val; } sr_dump [] =
+{
+ { 0x28, 0x81 },
+ { 0x2a, 0x00 },
+ { 0x29, 0xe1 },
+ { 0x2b, 0x81 },
+ { 0x2d, 0x00 },
+ { 0x2c, 0xe1 },
+ { 0x2e, 0x81 },
+ { 0x30, 0x00 },
+ { 0x2f, 0xe1 },
+ { 0x28, 0x01 },
+ { 0x29, 0x22 },
+ { 0x28, 0x3b },
+ { 0x29, 0x22 },
+ { 0x2a, 0x01 },
+ { 0x2e, 0x01 },
+ { 0x2f, 0x22 },
+ { 0x2e, 0x3b },
+ { 0x2f, 0x22 },
+ { 0x30, 0x01 },
+ { 0x15, 0x00 },
+ { 0x1b, 0x30 },
+
+ { 0x16, 0x0f },
+ { 0x16, 0x8f },
+ { 0x17, 0xba },
+ { 0x16, 0x0f },
+ { 0x16, 0x8f },
+ { 0x1f, 0x00 },
+ { 0x20, 0x20 },
+ { 0x23, 0xf6 },
+ { 0x24, 0x0d },
+ { 0x25, 0x33 },
+ { 0x21, 0x84 },
+ { 0x22, 0x00 },
+ { 0x27, 0x1f },
+ { 0x31, 0x00 },
+ { 0x33, 0x00 },
+ { 0x32, 0x11 },
+
+ { 0x25, 0x33 },
+
+ { 0x05, 0x86 },
+ { 0x01, 0x20 },
+ { 0x32, 0x11 },
+ { 0x1e, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x00, 0x03 },
+ { 0x01, 0x21 },
+ { 0x02, 0x0f },
+ { 0x03, 0x00 },
+ { 0x04, 0x0e },
+
+ { 0x0a, 0x00 },
+ { 0x0b, 0x00 },
+ { 0x0c, 0x00 },
+ { 0x0d, 0x00 },
+ { 0x0e, 0x00 },
+ { 0x37, 0x00 },
+
+ { 0x0a, 0x00 },
+ { 0x0b, 0x00 },
+ { 0x0c, 0x05 },
+ { 0x0e, 0x00 },
+
+ { 0x0e, 0x00 },
+
+ { 0x10, 0x0b },
+ { 0x31, 0x00 },
+ { 0x2b, 0x01 },
+ { 0x2c, 0xe1 },
+ { 0x2b, 0x1b },
+ { 0x2c, 0xe1 },
+ { 0x2d, 0x01 },
+ { 0x3d, 0x00 },
+ { 0x08, 0x84 },
+ { 0x09, 0x00 },
+ { 0x3d, 0x01 },
+ { 0x1f, 0x00 },
+ { 0x06, 0x02 },
+
+ { 0x0f, 0x00 },
+ { 0x17, 0xba },
+ { 0x21, 0xa4 },
+ { 0x32, 0x11 },
+ { 0x07, 0x18 },
+
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+
+ { 0x01, 0x01 },
+ { 0x21, 0x84 },
+ { 0x01, 0x21 },
+ { 0x16, 0x8f },
+ { 0x18, 0xa9 },
+ { 0x19, 0xa0 },
+ { 0x1b, 0x30 },
+ { 0x17, 0xb8 },
+ { 0x19, 0xa3 },
+ { 0x13, 0x00 },
+ { 0x14, 0x00 },
+ { 0x14, 0x02 },
+ { 0x15, 0x00 },
+ { 0x16, 0x0f },
+ { 0x16, 0x8f },
+ { 0x1d, 0x00 },
+ { 0x14, 0x00 },
+ { 0x14, 0x01 },
+ { 0x15, 0x00 },
+ { 0x16, 0x0f },
+ { 0x16, 0x8f },
+ { 0x1d, 0x00 },
+ { 0x14, 0x01 },
+ { 0x14, 0x01 },
+ { 0x15, 0x10 },
+ { 0x13, 0x35 },
+ { 0x14, 0x51 },
+ { 0x16, 0x0f },
+ { 0x16, 0x8f },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x11 },
+ { 0x1d, 0x11 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x1d, 0x00 },
+ { 0x17, 0xba },
+ { 0x19, 0xa0 },
+ { 0x19, 0xa0 },
+ { 0x01, 0x01 },
+ { 0x16, 0x0f },
+ { 0x18, 0xa9 },
+ { 0x19, 0xa0 },
+ { 0x1b, 0x30 },
+ { 0x21, 0xa4 },
+ { 0x05, 0x86 },
+};
+
+static const grub_uint8_t gr[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
diff --git a/grub-core/video/sis315pro.c b/grub-core/video/sis315pro.c
new file mode 100644
index 0000000..22a0c85
--- /dev/null
+++ b/grub-core/video/sis315pro.c
@@ -0,0 +1,459 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/pci.h>
+#include <grub/vga.h>
+#include <grub/cache.h>
+
+#define GRUB_SIS315PRO_PCIID 0x03251039
+#define GRUB_SIS315PRO_TOTAL_MEMORY_SPACE 0x800000
+#define GRUB_SIS315PRO_MMIO_SPACE 0x1000
+
+static struct
+{
+ struct grub_video_mode_info mode_info;
+
+ grub_uint8_t *ptr;
+ volatile grub_uint8_t *direct_ptr;
+ int mapped;
+ grub_uint32_t base;
+ grub_uint32_t mmiobase;
+ volatile grub_uint32_t *mmioptr;
+ grub_pci_device_t dev;
+ grub_port_t io;
+} framebuffer;
+
+static grub_uint8_t
+read_sis_cmd (grub_uint8_t addr)
+{
+ grub_outb (addr, framebuffer.io + 0x44);
+ return grub_inb (framebuffer.io + 0x45);
+}
+
+static void
+write_sis_cmd (grub_uint8_t val, grub_uint8_t addr)
+{
+ grub_outb (addr, framebuffer.io + 0x44);
+ grub_outb (val, framebuffer.io + 0x45);
+}
+
+#ifndef TEST
+static grub_err_t
+grub_video_sis315pro_video_init (void)
+{
+ /* Reset frame buffer. */
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_sis315pro_video_fini (void)
+{
+ if (framebuffer.mapped)
+ {
+ grub_pci_device_unmap_range (framebuffer.dev, framebuffer.ptr,
+ GRUB_SIS315PRO_TOTAL_MEMORY_SPACE);
+ grub_pci_device_unmap_range (framebuffer.dev, framebuffer.direct_ptr,
+ GRUB_SIS315PRO_TOTAL_MEMORY_SPACE);
+ }
+
+ return grub_video_fb_fini ();
+}
+#endif
+
+#include "sis315_init.c"
+
+#ifndef TEST
+/* Helper for grub_video_sis315pro_setup. */
+static int
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
+{
+ int *found = data;
+ grub_pci_address_t addr;
+ grub_uint32_t class;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class = grub_pci_read (addr);
+
+ if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
+ || pciid != GRUB_SIS315PRO_PCIID)
+ return 0;
+
+ *found = 1;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
+ framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1);
+ framebuffer.mmiobase = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG2);
+ framebuffer.io = (grub_pci_read (addr) & GRUB_PCI_ADDR_IO_MASK)
+ + GRUB_MACHINE_PCI_IO_BASE;
+ framebuffer.dev = dev;
+
+ return 1;
+}
+#endif
+
+static grub_err_t
+grub_video_sis315pro_setup (unsigned int width, unsigned int height,
+ unsigned int mode_type,
+ unsigned int mode_mask __attribute__ ((unused)))
+{
+ int depth;
+ grub_err_t err;
+ int found = 0;
+ unsigned i;
+
+#ifndef TEST
+ /* Decode depth from mode_type. If it is zero, then autodetect. */
+ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
+
+ if ((width != 640 && width != 0) || (height != 480 && height != 0)
+ || (depth != 8 && depth != 0))
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "Only 640x480x8 is supported");
+
+ grub_pci_iterate (find_card, &found);
+ if (!found)
+ return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
+#endif
+ /* Fill mode info details. */
+ framebuffer.mode_info.width = 640;
+ framebuffer.mode_info.height = 480;
+ framebuffer.mode_info.mode_type = (GRUB_VIDEO_MODE_TYPE_INDEX_COLOR
+ | GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED
+ | GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP);
+ framebuffer.mode_info.bpp = 8;
+ framebuffer.mode_info.bytes_per_pixel = 1;
+ framebuffer.mode_info.pitch = 640 * 1;
+ framebuffer.mode_info.number_of_colors = 16;
+ framebuffer.mode_info.red_mask_size = 0;
+ framebuffer.mode_info.red_field_pos = 0;
+ framebuffer.mode_info.green_mask_size = 0;
+ framebuffer.mode_info.green_field_pos = 0;
+ framebuffer.mode_info.blue_mask_size = 0;
+ framebuffer.mode_info.blue_field_pos = 0;
+ framebuffer.mode_info.reserved_mask_size = 0;
+ framebuffer.mode_info.reserved_field_pos = 0;
+#ifndef TEST
+ framebuffer.mode_info.blit_format
+ = grub_video_get_blit_format (&framebuffer.mode_info);
+#endif
+
+#ifndef TEST
+ if (found && (framebuffer.base == 0 || framebuffer.mmiobase == 0))
+ {
+ grub_pci_address_t addr;
+ /* FIXME: choose address dynamically if needed. */
+ framebuffer.base = 0x40000000;
+ framebuffer.mmiobase = 0x04000000;
+ framebuffer.io = 0xb300;
+
+ addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_ADDRESS_REG0);
+ grub_pci_write (addr, framebuffer.base | GRUB_PCI_ADDR_MEM_PREFETCH);
+
+ addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_ADDRESS_REG1);
+ grub_pci_write (addr, framebuffer.mmiobase);
+
+ addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_ADDRESS_REG2);
+ grub_pci_write (addr, framebuffer.io | GRUB_PCI_ADDR_SPACE_IO);
+
+ /* Set latency. */
+ addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_CACHELINE);
+ grub_pci_write (addr, 0x80004700);
+
+ /* Enable address spaces. */
+ addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write (addr, 0x7);
+
+ addr = grub_pci_make_address (framebuffer.dev, 0x30);
+ grub_pci_write (addr, 0x04060001);
+
+ framebuffer.io += GRUB_MACHINE_PCI_IO_BASE;
+ }
+#endif
+
+
+ /* We can safely discard volatile attribute. */
+#ifndef TEST
+ framebuffer.ptr
+ = grub_pci_device_map_range_cached (framebuffer.dev,
+ framebuffer.base,
+ GRUB_SIS315PRO_TOTAL_MEMORY_SPACE);
+ framebuffer.direct_ptr
+ = grub_pci_device_map_range (framebuffer.dev,
+ framebuffer.base,
+ GRUB_SIS315PRO_TOTAL_MEMORY_SPACE);
+ framebuffer.mmioptr = grub_pci_device_map_range (framebuffer.dev,
+ framebuffer.mmiobase,
+ GRUB_SIS315PRO_MMIO_SPACE);
+#endif
+ framebuffer.mapped = 1;
+
+#ifndef TEST
+ /* Prevent garbage from appearing on the screen. */
+ grub_memset (framebuffer.ptr, 0,
+ framebuffer.mode_info.height * framebuffer.mode_info.pitch);
+ grub_arch_sync_dma_caches (framebuffer.ptr,
+ framebuffer.mode_info.height
+ * framebuffer.mode_info.pitch);
+#endif
+
+ grub_outb (GRUB_VGA_IO_MISC_NEGATIVE_VERT_POLARITY
+ | GRUB_VGA_IO_MISC_NEGATIVE_HORIZ_POLARITY
+ | GRUB_VGA_IO_MISC_UPPER_64K
+ | GRUB_VGA_IO_MISC_EXTERNAL_CLOCK_0
+ | GRUB_VGA_IO_MISC_28MHZ
+ | GRUB_VGA_IO_MISC_ENABLE_VRAM_ACCESS
+ | GRUB_VGA_IO_MISC_COLOR,
+ GRUB_VGA_IO_MISC_WRITE + GRUB_MACHINE_PCI_IO_BASE);
+
+ grub_vga_sr_write (0x86, 5);
+ for (i = 6; i <= 0x27; i++)
+ grub_vga_sr_write (0, i);
+
+ for (i = 0x31; i <= 0x3d; i++)
+ grub_vga_sr_write (0, i);
+
+ for (i = 0; i < ARRAY_SIZE (sr_dump); i++)
+ grub_vga_sr_write (sr_dump[i].val, sr_dump[i].reg);
+
+ for (i = 0x30; i < 0x40; i++)
+ grub_vga_cr_write (0, i);
+
+ grub_vga_cr_write (0x77, 0x40);
+ grub_vga_cr_write (0x77, 0x41);
+ grub_vga_cr_write (0x00, 0x42);
+ grub_vga_cr_write (0x5b, 0x43);
+ grub_vga_cr_write (0x00, 0x44);
+ grub_vga_cr_write (0x23, 0x48);
+ grub_vga_cr_write (0xaa, 0x49);
+ grub_vga_cr_write (0x02, 0x37);
+ grub_vga_cr_write (0x20, 0x5b);
+ grub_vga_cr_write (0x00, 0x83);
+ grub_vga_cr_write (0x80, 0x63);
+
+ grub_vga_cr_write (0x0c, GRUB_VGA_CR_VSYNC_END);
+ grub_vga_cr_write (0x5f, GRUB_VGA_CR_HTOTAL);
+ grub_vga_cr_write (0x4f, GRUB_VGA_CR_HORIZ_END);
+ grub_vga_cr_write (0x50, GRUB_VGA_CR_HBLANK_START);
+ grub_vga_cr_write (0x82, GRUB_VGA_CR_HBLANK_END);
+ grub_vga_cr_write (0x54, GRUB_VGA_CR_HORIZ_SYNC_PULSE_START);
+ grub_vga_cr_write (0x80, GRUB_VGA_CR_HORIZ_SYNC_PULSE_END);
+ grub_vga_cr_write (0x0b, GRUB_VGA_CR_VERT_TOTAL);
+ grub_vga_cr_write (0x3e, GRUB_VGA_CR_OVERFLOW);
+ grub_vga_cr_write (0x00, GRUB_VGA_CR_BYTE_PANNING);
+ grub_vga_cr_write (0x40, GRUB_VGA_CR_CELL_HEIGHT);
+ grub_vga_cr_write (0x00, GRUB_VGA_CR_CURSOR_START);
+ grub_vga_cr_write (0x00, GRUB_VGA_CR_CURSOR_END);
+ grub_vga_cr_write (0x00, GRUB_VGA_CR_START_ADDR_HIGH_REGISTER);
+ grub_vga_cr_write (0x00, GRUB_VGA_CR_START_ADDR_LOW_REGISTER);
+ grub_vga_cr_write (0x00, GRUB_VGA_CR_CURSOR_ADDR_HIGH);
+ grub_vga_cr_write (0x00, GRUB_VGA_CR_CURSOR_ADDR_LOW);
+ grub_vga_cr_write (0xea, GRUB_VGA_CR_VSYNC_START);
+ grub_vga_cr_write (0x8c, GRUB_VGA_CR_VSYNC_END);
+ grub_vga_cr_write (0xdf, GRUB_VGA_CR_VDISPLAY_END);
+ grub_vga_cr_write (0x28, GRUB_VGA_CR_PITCH);
+ grub_vga_cr_write (0x40, GRUB_VGA_CR_UNDERLINE_LOCATION);
+ grub_vga_cr_write (0xe7, GRUB_VGA_CR_VERTICAL_BLANK_START);
+ grub_vga_cr_write (0x04, GRUB_VGA_CR_VERTICAL_BLANK_END);
+ grub_vga_cr_write (0xa3, GRUB_VGA_CR_MODE);
+ grub_vga_cr_write (0xff, GRUB_VGA_CR_LINE_COMPARE);
+
+ grub_vga_cr_write (0x0c, GRUB_VGA_CR_VSYNC_END);
+ grub_vga_cr_write (0x5f, GRUB_VGA_CR_HTOTAL);
+ grub_vga_cr_write (0x4f, GRUB_VGA_CR_HORIZ_END);
+ grub_vga_cr_write (0x50, GRUB_VGA_CR_HBLANK_START);
+ grub_vga_cr_write (0x82, GRUB_VGA_CR_HBLANK_END);
+ grub_vga_cr_write (0x55, GRUB_VGA_CR_HORIZ_SYNC_PULSE_START);
+ grub_vga_cr_write (0x81, GRUB_VGA_CR_HORIZ_SYNC_PULSE_END);
+ grub_vga_cr_write (0x0b, GRUB_VGA_CR_VERT_TOTAL);
+ grub_vga_cr_write (0x3e, GRUB_VGA_CR_OVERFLOW);
+ grub_vga_cr_write (0xe9, GRUB_VGA_CR_VSYNC_START);
+ grub_vga_cr_write (0x8b, GRUB_VGA_CR_VSYNC_END);
+ grub_vga_cr_write (0xdf, GRUB_VGA_CR_VDISPLAY_END);
+ grub_vga_cr_write (0xe7, GRUB_VGA_CR_VERTICAL_BLANK_START);
+ grub_vga_cr_write (0x04, GRUB_VGA_CR_VERTICAL_BLANK_END);
+ grub_vga_cr_write (0x40, GRUB_VGA_CR_CELL_HEIGHT);
+ grub_vga_cr_write (0x50, GRUB_VGA_CR_PITCH);
+
+ grub_vga_cr_write (0x00, 0x19);
+ grub_vga_cr_write (0x00, 0x1a);
+ grub_vga_cr_write (0x6c, 0x52);
+ grub_vga_cr_write (0x2e, 0x34);
+ grub_vga_cr_write (0x00, 0x31);
+
+
+ grub_vga_cr_write (0, GRUB_VGA_CR_START_ADDR_HIGH_REGISTER);
+ grub_vga_cr_write (0, GRUB_VGA_CR_START_ADDR_LOW_REGISTER);
+
+ for (i = 0; i < 16; i++)
+ grub_vga_write_arx (i, i);
+ grub_vga_write_arx (1, GRUB_VGA_ARX_MODE);
+ grub_vga_write_arx (0, GRUB_VGA_ARX_OVERSCAN);
+ grub_vga_write_arx (0, GRUB_VGA_ARX_COLOR_PLANE_ENABLE);
+ grub_vga_write_arx (0, GRUB_VGA_ARX_HORIZONTAL_PANNING);
+ grub_vga_write_arx (0, GRUB_VGA_ARX_COLOR_SELECT);
+
+ grub_outb (0xff, GRUB_VGA_IO_PIXEL_MASK + GRUB_MACHINE_PCI_IO_BASE);
+
+ for (i = 0; i < ARRAY_SIZE (gr); i++)
+ grub_vga_gr_write (gr[i], i);
+
+ for (i = 0; i < GRUB_VIDEO_FBSTD_NUMCOLORS; i++)
+ grub_vga_palette_write (i, grub_video_fbstd_colors[i].r,
+ grub_video_fbstd_colors[i].g,
+ grub_video_fbstd_colors[i].b);
+
+#if 1
+ {
+ if (read_sis_cmd (0x5) != 0xa1)
+ write_sis_cmd (0x86, 0x5);
+
+ write_sis_cmd (read_sis_cmd (0x20) | 0xa1, 0x20);
+ write_sis_cmd (read_sis_cmd (0x1e) | 0xda, 0x1e);
+
+#define IND_SIS_CMDQUEUE_SET 0x26
+#define IND_SIS_CMDQUEUE_THRESHOLD 0x27
+
+#define COMMAND_QUEUE_THRESHOLD 0x1F
+#define SIS_CMD_QUEUE_RESET 0x01
+
+#define SIS_AGP_CMDQUEUE_ENABLE 0x80 /* 315/330/340 series SR26 */
+#define SIS_VRAM_CMDQUEUE_ENABLE 0x40
+#define SIS_MMIO_CMD_ENABLE 0x20
+#define SIS_CMD_QUEUE_SIZE_512k 0x00
+#define SIS_CMD_QUEUE_SIZE_1M 0x04
+#define SIS_CMD_QUEUE_SIZE_2M 0x08
+#define SIS_CMD_QUEUE_SIZE_4M 0x0C
+#define SIS_CMD_QUEUE_RESET 0x01
+#define SIS_CMD_AUTO_CORR 0x02
+
+
+ write_sis_cmd (COMMAND_QUEUE_THRESHOLD, IND_SIS_CMDQUEUE_THRESHOLD);
+ write_sis_cmd (SIS_CMD_QUEUE_RESET, IND_SIS_CMDQUEUE_SET);
+ framebuffer.mmioptr[0x85C4 / 4] = framebuffer.mmioptr[0x85C8 / 4];
+ write_sis_cmd (SIS_MMIO_CMD_ENABLE | SIS_CMD_AUTO_CORR, IND_SIS_CMDQUEUE_SET);
+ framebuffer.mmioptr[0x85C0 / 4] = (0x1000000 - (512 * 1024));
+ }
+#endif
+
+#ifndef TEST
+ err = grub_video_fb_setup (mode_type, mode_mask,
+ &framebuffer.mode_info,
+ framebuffer.ptr, NULL, NULL);
+ if (err)
+ return err;
+
+ /* Copy default palette to initialize emulated palette. */
+ err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_EXT_NUMCOLORS,
+ grub_video_fbstd_colors);
+#endif
+ return err;
+}
+
+#ifndef TEST
+
+static grub_err_t
+grub_video_sis315pro_swap_buffers (void)
+{
+ grub_size_t s;
+ s = (framebuffer.mode_info.height
+ * framebuffer.mode_info.pitch
+ * framebuffer.mode_info.bytes_per_pixel);
+ grub_video_fb_swap_buffers ();
+ grub_arch_sync_dma_caches (framebuffer.ptr, s);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_sis315pro_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
+ *framebuf = (void *) framebuffer.direct_ptr;
+
+ grub_video_fb_fini ();
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_video_adapter grub_video_sis315pro_adapter =
+ {
+ .name = "SIS315PRO Video Driver",
+ .id = GRUB_VIDEO_DRIVER_SIS315PRO,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_NATIVE,
+
+ .init = grub_video_sis315pro_video_init,
+ .fini = grub_video_sis315pro_video_fini,
+ .setup = grub_video_sis315pro_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_sis315pro_get_info_and_fini,
+ .set_palette = grub_video_fb_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_sis315pro_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_fb_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(video_sis315pro)
+{
+ grub_video_register (&grub_video_sis315pro_adapter);
+}
+
+GRUB_MOD_FINI(video_sis315pro)
+{
+ grub_video_unregister (&grub_video_sis315pro_adapter);
+}
+#else
+int
+main ()
+{
+ grub_video_sis315pro_setup (640, 400, 0, 0);
+}
+#endif
diff --git a/grub-core/video/sm712.c b/grub-core/video/sm712.c
new file mode 100644
index 0000000..10c46eb
--- /dev/null
+++ b/grub-core/video/sm712.c
@@ -0,0 +1,818 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define grub_video_render_target grub_video_fbrender_target
+
+#if !defined (TEST) && !defined(GENINIT)
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/video.h>
+#include <grub/video_fb.h>
+#include <grub/pci.h>
+#include <grub/vga.h>
+#include <grub/cache.h>
+#else
+typedef unsigned char grub_uint8_t;
+typedef unsigned short grub_uint16_t;
+typedef unsigned int grub_uint32_t;
+typedef int grub_err_t;
+#include <grub/vgaregs.h>
+#include <stdio.h>
+#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
+#endif
+
+#include "sm712_init.c"
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+#define GRUB_SM712_TOTAL_MEMORY_SPACE 0x700400
+#define GRUB_SM712_REG_BASE 0x700000
+#define GRUB_SM712_PCIID 0x0712126f
+
+enum
+ {
+ GRUB_SM712_SR_TV_CONTROL = 0x65,
+ GRUB_SM712_SR_RAM_LUT = 0x66,
+ GRUB_SM712_SR_CLOCK_CONTROL1 = 0x68,
+ GRUB_SM712_SR_CLOCK_CONTROL2 = 0x69,
+ GRUB_SM712_SR_VCLK_NUM = 0x6c,
+ GRUB_SM712_SR_VCLK_DENOM = 0x6d,
+ GRUB_SM712_SR_VCLK2_NUM = 0x6e,
+ GRUB_SM712_SR_VCLK2_DENOM = 0x6f,
+ GRUB_SM712_SR_POPUP_ICON_LOW = 0x80,
+ GRUB_SM712_SR_POPUP_ICON_HIGH = 0x81,
+ GRUB_SM712_SR_POPUP_ICON_CTRL = 0x82,
+ GRUB_SM712_SR_POPUP_ICON_COLOR1 = 0x84,
+ GRUB_SM712_SR_POPUP_ICON_COLOR2 = 0x85,
+ GRUB_SM712_SR_POPUP_ICON_COLOR3 = 0x86,
+
+ GRUB_SM712_SR_HW_CURSOR_UPPER_LEFT_X_LOW = 0x88,
+ GRUB_SM712_SR_HW_CURSOR_UPPER_LEFT_X_HIGH = 0x89,
+ GRUB_SM712_SR_HW_CURSOR_UPPER_LEFT_Y_LOW = 0x8a,
+ GRUB_SM712_SR_HW_CURSOR_UPPER_LEFT_Y_HIGH = 0x8b,
+ GRUB_SM712_SR_HW_CURSOR_FG_COLOR = 0x8c,
+ GRUB_SM712_SR_HW_CURSOR_BG_COLOR = 0x8d,
+
+ GRUB_SM712_SR_POPUP_ICON_X_LOW = 0x90,
+ GRUB_SM712_SR_POPUP_ICON_X_HIGH = 0x91,
+ GRUB_SM712_SR_POPUP_ICON_Y_LOW = 0x92,
+ GRUB_SM712_SR_POPUP_ICON_Y_HIGH = 0x93,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_CONTROL = 0xa0,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_COLOR_KEY_LOW = 0xa1,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_COLOR_KEY_HIGH = 0xa2,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_COLOR_KEY_MASK_LOW = 0xa3,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_COLOR_KEY_MASK_HIGH = 0xa4,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_RED_CONSTANT = 0xa5,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_GREEN_CONSTANT = 0xa6,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_BLUE_CONSTANT = 0xa7,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_TOP_BOUNDARY = 0xa8,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_LEFT_BOUNDARY = 0xa9,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_BOTTOM_BOUNDARY = 0xaa,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_RIGHT_BOUNDARY = 0xab,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_TOP_LEFT_OVERFLOW_BOUNDARY = 0xac,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_BOTTOM_RIGHT_OVERFLOW_BOUNDARY = 0xad,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_VERTICAL_STRETCH_FACTOR = 0xae,
+ GRUB_SM712_SR_PANEL_HW_VIDEO_HORIZONTAL_STRETCH_FACTOR = 0xaf,
+ };
+enum
+ {
+ GRUB_SM712_SR_TV_CRT_SRAM = 0x00,
+ GRUB_SM712_SR_TV_LCD_SRAM = 0x08
+ };
+enum
+ {
+ GRUB_SM712_SR_TV_ALT_CLOCK = 0x00,
+ GRUB_SM712_SR_TV_FREE_RUN_CLOCK = 0x04
+ };
+enum
+ {
+ GRUB_SM712_SR_TV_CLOCK_CKIN_NTSC = 0x00,
+ GRUB_SM712_SR_TV_CLOCK_REFCLK_PAL = 0x04
+ };
+enum
+ {
+ GRUB_SM712_SR_TV_HSYNC = 0x00,
+ GRUB_SM712_SR_TV_COMPOSITE_HSYNC = 0x01
+ };
+enum
+ {
+ GRUB_SM712_SR_RAM_LUT_NORMAL = 0,
+ GRUB_SM712_SR_RAM_LUT_LCD_RAM_OFF = 0x80,
+ GRUB_SM712_SR_RAM_LUT_CRT_RAM_OFF = 0x40,
+ GRUB_SM712_SR_RAM_LUT_LCD_RAM_NO_WRITE = 0x20,
+ GRUB_SM712_SR_RAM_LUT_CRT_RAM_NO_WRITE = 0x10,
+ GRUB_SM712_SR_RAM_LUT_CRT_8BIT = 0x08,
+ GRUB_SM712_SR_RAM_LUT_CRT_GAMMA = 0x04
+ };
+
+enum
+ {
+ GRUB_SM712_SR_CLOCK_CONTROL1_VCLK_FROM_CCR = 0x40,
+ GRUB_SM712_SR_CLOCK_CONTROL1_8DOT_CLOCK = 0x10,
+ };
+
+enum
+ {
+ GRUB_SM712_SR_CLOCK_CONTROL2_PROGRAM_VCLOCK = 0x03
+ };
+
+#define GRUB_SM712_SR_POPUP_ICON_HIGH_MASK 0x7
+#define GRUB_SM712_SR_POPUP_ICON_HIGH_HW_CURSOR_EN 0x80
+ enum
+ {
+ GRUB_SM712_SR_POPUP_ICON_CTRL_DISABLED = 0,
+ GRUB_SM712_SR_POPUP_ICON_CTRL_ZOOM_ENABLED = 0x40,
+ GRUB_SM712_SR_POPUP_ICON_CTRL_ENABLED = 0x80
+ };
+#define RGB332_BLACK 0
+#define RGB332_WHITE 0xff
+
+ enum
+ {
+ GRUB_SM712_CR_OVERFLOW_INTERLACE = 0x30,
+ GRUB_SM712_CR_INTERLACE_RETRACE = 0x31,
+ GRUB_SM712_CR_TV_VDISPLAY_START = 0x32,
+ GRUB_SM712_CR_TV_VDISPLAY_END_HIGH = 0x33,
+ GRUB_SM712_CR_TV_VDISPLAY_END_LOW = 0x34,
+ GRUB_SM712_CR_DDA_CONTROL_LOW = 0x35,
+ GRUB_SM712_CR_DDA_CONTROL_HIGH = 0x36,
+ GRUB_SM712_CR_TV_EQUALIZER = 0x38,
+ GRUB_SM712_CR_TV_SERRATION = 0x39,
+ GRUB_SM712_CR_HSYNC_CTRL = 0x3a,
+ GRUB_SM712_CR_DEBUG = 0x3c,
+ GRUB_SM712_CR_SHADOW_VGA_HTOTAL = 0x40,
+ GRUB_SM712_CR_SHADOW_VGA_HBLANK_START = 0x41,
+ GRUB_SM712_CR_SHADOW_VGA_HBLANK_END = 0x42,
+ GRUB_SM712_CR_SHADOW_VGA_HRETRACE_START = 0x43,
+ GRUB_SM712_CR_SHADOW_VGA_HRETRACE_END = 0x44,
+ GRUB_SM712_CR_SHADOW_VGA_VERTICAL_TOTAL = 0x45,
+ GRUB_SM712_CR_SHADOW_VGA_VBLANK_START = 0x46,
+ GRUB_SM712_CR_SHADOW_VGA_VBLANK_END = 0x47,
+ GRUB_SM712_CR_SHADOW_VGA_VRETRACE_START = 0x48,
+ GRUB_SM712_CR_SHADOW_VGA_VRETRACE_END = 0x49,
+ GRUB_SM712_CR_SHADOW_VGA_OVERFLOW = 0x4a,
+ GRUB_SM712_CR_SHADOW_VGA_CELL_HEIGHT = 0x4b,
+ GRUB_SM712_CR_SHADOW_VGA_HDISPLAY_END = 0x4c,
+ GRUB_SM712_CR_SHADOW_VGA_VDISPLAY_END = 0x4d,
+ GRUB_SM712_CR_DDA_LOOKUP_REG3_START = 0x90,
+ GRUB_SM712_CR_DDA_LOOKUP_REG2_START = 0x91,
+ GRUB_SM712_CR_DDA_LOOKUP_REG1_START = 0xa0,
+ GRUB_SM712_CR_VCENTERING_OFFSET = 0xa6,
+ GRUB_SM712_CR_HCENTERING_OFFSET = 0xa7,
+ };
+
+#define GRUB_SM712_CR_DEBUG_NONE 0
+
+#define SM712_DDA_REG3_COMPARE_SHIFT 2
+#define SM712_DDA_REG3_COMPARE_MASK 0xfc
+#define SM712_DDA_REG3_DDA_SHIFT 8
+#define SM712_DDA_REG3_DDA_MASK 0x3
+#define SM712_DDA_REG2_DDA_MASK 0xff
+#define SM712_DDA_REG2_VCENTER_MASK 0x3f
+
+static struct
+{
+ grub_uint8_t compare;
+ grub_uint16_t dda;
+ grub_uint8_t vcentering;
+} dda_lookups[] = {
+ { 21, 469, 2},
+ { 23, 477, 2},
+ { 33, 535, 2},
+ { 35, 682, 21},
+ { 34, 675, 2},
+ { 55, 683, 6},
+};
+
+static struct
+{
+#if !defined (TEST) && !defined(GENINIT)
+ struct grub_video_mode_info mode_info;
+#endif
+
+ volatile grub_uint8_t *ptr;
+ grub_uint8_t *cached_ptr;
+ int mapped;
+ grub_uint32_t base;
+#if !defined (TEST) && !defined(GENINIT)
+ grub_pci_device_t dev;
+#endif
+} framebuffer;
+
+#if !defined (TEST) && !defined(GENINIT)
+static grub_err_t
+grub_video_sm712_video_init (void)
+{
+ /* Reset frame buffer. */
+ grub_memset (&framebuffer, 0, sizeof(framebuffer));
+
+ return grub_video_fb_init ();
+}
+
+static grub_err_t
+grub_video_sm712_video_fini (void)
+{
+ if (framebuffer.mapped)
+ {
+ grub_pci_device_unmap_range (framebuffer.dev, framebuffer.ptr,
+ GRUB_SM712_TOTAL_MEMORY_SPACE);
+ grub_pci_device_unmap_range (framebuffer.dev, framebuffer.cached_ptr,
+ GRUB_SM712_TOTAL_MEMORY_SPACE);
+ }
+ return grub_video_fb_fini ();
+}
+#endif
+
+static inline void
+grub_sm712_write_reg (grub_uint8_t val, grub_uint16_t addr)
+{
+#ifdef TEST
+ printf (" {1, 0x%x, 0x%x},\n", addr, val);
+#elif defined (GENINIT)
+ printf (" .byte 0x%02x, 0x%02x\n", (addr - 0x3c0), val);
+ if ((addr - 0x3c0) & ~0x7f)
+ printf ("FAIL\n");
+#else
+ *(volatile grub_uint8_t *) (framebuffer.ptr + GRUB_SM712_REG_BASE
+ + addr) = val;
+#endif
+}
+
+static inline grub_uint8_t
+grub_sm712_read_reg (grub_uint16_t addr)
+{
+#ifdef TEST
+ printf (" {-1, 0x%x, 0x5},\n", addr);
+#elif defined (GENINIT)
+ if ((addr - 0x3c0) & ~0x7f)
+ printf ("FAIL\n");
+ printf (" .byte 0x%04x, 0x00\n", (addr - 0x3c0) | 0x80);
+#else
+ return *(volatile grub_uint8_t *) (framebuffer.ptr + GRUB_SM712_REG_BASE
+ + addr);
+#endif
+}
+
+static inline grub_uint8_t
+grub_sm712_sr_read (grub_uint8_t addr)
+{
+ grub_sm712_write_reg (addr, GRUB_VGA_IO_SR_INDEX);
+ return grub_sm712_read_reg (GRUB_VGA_IO_SR_DATA);
+}
+
+static inline void
+grub_sm712_sr_write (grub_uint8_t val, grub_uint8_t addr)
+{
+ grub_sm712_write_reg (addr, GRUB_VGA_IO_SR_INDEX);
+ grub_sm712_write_reg (val, GRUB_VGA_IO_SR_DATA);
+}
+
+static inline void
+grub_sm712_gr_write (grub_uint8_t val, grub_uint8_t addr)
+{
+ grub_sm712_write_reg (addr, GRUB_VGA_IO_GR_INDEX);
+ grub_sm712_write_reg (val, GRUB_VGA_IO_GR_DATA);
+}
+
+static inline void
+grub_sm712_cr_write (grub_uint8_t val, grub_uint8_t addr)
+{
+ grub_sm712_write_reg (addr, GRUB_VGA_IO_CR_INDEX);
+ grub_sm712_write_reg (val, GRUB_VGA_IO_CR_DATA);
+}
+
+static inline void
+grub_sm712_write_arx (grub_uint8_t val, grub_uint8_t addr)
+{
+ grub_sm712_read_reg (GRUB_VGA_IO_INPUT_STATUS1_REGISTER);
+ grub_sm712_write_reg (addr, GRUB_VGA_IO_ARX);
+ grub_sm712_read_reg (GRUB_VGA_IO_ARX_READ);
+ grub_sm712_write_reg (val, GRUB_VGA_IO_ARX);
+}
+
+static inline void
+grub_sm712_cr_shadow_write (grub_uint8_t val, grub_uint8_t addr)
+{
+ grub_uint8_t mapping[] =
+ {
+ [GRUB_VGA_CR_HTOTAL] = GRUB_SM712_CR_SHADOW_VGA_HTOTAL,
+ [GRUB_VGA_CR_HORIZ_END] = 0xff,
+ [GRUB_VGA_CR_HBLANK_START] = GRUB_SM712_CR_SHADOW_VGA_HBLANK_START,
+ [GRUB_VGA_CR_HBLANK_END] = GRUB_SM712_CR_SHADOW_VGA_HBLANK_END,
+ [GRUB_VGA_CR_HORIZ_SYNC_PULSE_START] = GRUB_SM712_CR_SHADOW_VGA_HRETRACE_START,
+ [GRUB_VGA_CR_HORIZ_SYNC_PULSE_END] = GRUB_SM712_CR_SHADOW_VGA_HRETRACE_END,
+ [GRUB_VGA_CR_VERT_TOTAL] = GRUB_SM712_CR_SHADOW_VGA_VERTICAL_TOTAL,
+ [GRUB_VGA_CR_OVERFLOW] = GRUB_SM712_CR_SHADOW_VGA_OVERFLOW,
+ [GRUB_VGA_CR_BYTE_PANNING] = 0xff,
+ [GRUB_VGA_CR_CELL_HEIGHT] = GRUB_SM712_CR_SHADOW_VGA_CELL_HEIGHT,
+ [GRUB_VGA_CR_CURSOR_START] = 0xff,
+ [GRUB_VGA_CR_CURSOR_END] = 0xff,
+ [GRUB_VGA_CR_START_ADDR_HIGH_REGISTER] = 0xff,
+ [GRUB_VGA_CR_START_ADDR_LOW_REGISTER] = 0xff,
+ [GRUB_VGA_CR_CURSOR_ADDR_HIGH] = 0xff,
+ [GRUB_VGA_CR_CURSOR_ADDR_LOW] = 0xff,
+ [GRUB_VGA_CR_VSYNC_START] = GRUB_SM712_CR_SHADOW_VGA_VRETRACE_START,
+ [GRUB_VGA_CR_VSYNC_END] = GRUB_SM712_CR_SHADOW_VGA_VRETRACE_END,
+ [GRUB_VGA_CR_VDISPLAY_END] = GRUB_SM712_CR_SHADOW_VGA_VDISPLAY_END,
+ [GRUB_VGA_CR_PITCH] = GRUB_SM712_CR_SHADOW_VGA_HDISPLAY_END,
+ [GRUB_VGA_CR_UNDERLINE_LOCATION] = 0xff,
+
+ [GRUB_VGA_CR_VERTICAL_BLANK_START] = GRUB_SM712_CR_SHADOW_VGA_VBLANK_START,
+ [GRUB_VGA_CR_VERTICAL_BLANK_END] = GRUB_SM712_CR_SHADOW_VGA_VBLANK_END,
+ [GRUB_VGA_CR_MODE] = 0xff,
+ [GRUB_VGA_CR_LINE_COMPARE] = 0xff
+ };
+ if (addr >= ARRAY_SIZE (mapping) || mapping[addr] == 0xff)
+ return;
+ grub_sm712_cr_write (val, mapping[addr]);
+}
+
+static inline void
+grub_sm712_write_dda_lookup (int idx, grub_uint8_t compare, grub_uint16_t dda,
+ grub_uint8_t vcentering)
+{
+ grub_sm712_cr_write (((compare << SM712_DDA_REG3_COMPARE_SHIFT)
+ & SM712_DDA_REG3_COMPARE_MASK)
+ | ((dda >> SM712_DDA_REG3_DDA_SHIFT)
+ & SM712_DDA_REG3_DDA_MASK),
+ GRUB_SM712_CR_DDA_LOOKUP_REG3_START + 2 * idx);
+ grub_sm712_cr_write (dda & SM712_DDA_REG2_DDA_MASK,
+ GRUB_SM712_CR_DDA_LOOKUP_REG2_START + 2 * idx);
+ grub_sm712_cr_write (vcentering & SM712_DDA_REG2_VCENTER_MASK,
+ GRUB_SM712_CR_DDA_LOOKUP_REG1_START + idx);
+}
+
+#if !defined (TEST) && !defined(GENINIT)
+/* Helper for grub_video_sm712_setup. */
+static int
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
+{
+ int *found = data;
+ grub_pci_address_t addr;
+ grub_uint32_t class;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+ class = grub_pci_read (addr);
+
+ if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
+ || pciid != GRUB_SM712_PCIID)
+ return 0;
+
+ *found = 1;
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
+ framebuffer.base = grub_pci_read (addr);
+ framebuffer.dev = dev;
+
+ return 1;
+}
+#endif
+
+static grub_err_t
+grub_video_sm712_setup (unsigned int width, unsigned int height,
+ unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
+{
+ unsigned i;
+#if !defined (TEST) && !defined(GENINIT)
+ int depth;
+ grub_err_t err;
+ int found = 0;
+
+ /* Decode depth from mode_type. If it is zero, then autodetect. */
+ depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
+
+ if ((width != 1024 && width != 0) || (height != 600 && height != 0)
+ || (depth != 16 && depth != 0))
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "Only 1024x600x16 is supported");
+
+ grub_pci_iterate (find_card, &found);
+ if (!found)
+ return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
+ /* Fill mode info details. */
+ framebuffer.mode_info.width = 1024;
+ framebuffer.mode_info.height = 600;
+ framebuffer.mode_info.mode_type = (GRUB_VIDEO_MODE_TYPE_RGB
+ | GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED
+ | GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP);
+ framebuffer.mode_info.bpp = 16;
+ framebuffer.mode_info.bytes_per_pixel = 2;
+ framebuffer.mode_info.pitch = 1024 * 2;
+ framebuffer.mode_info.number_of_colors = 256;
+ framebuffer.mode_info.red_mask_size = 5;
+ framebuffer.mode_info.red_field_pos = 11;
+ framebuffer.mode_info.green_mask_size = 6;
+ framebuffer.mode_info.green_field_pos = 5;
+ framebuffer.mode_info.blue_mask_size = 5;
+ framebuffer.mode_info.blue_field_pos = 0;
+ framebuffer.mode_info.reserved_mask_size = 0;
+ framebuffer.mode_info.reserved_field_pos = 0;
+ framebuffer.mode_info.blit_format
+ = grub_video_get_blit_format (&framebuffer.mode_info);
+#endif
+
+#if !defined (TEST) && !defined(GENINIT)
+ if (found && framebuffer.base == 0)
+ {
+ grub_pci_address_t addr;
+ /* FIXME: choose address dynamically if needed. */
+ framebuffer.base = 0x04000000;
+
+ addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_ADDRESS_REG0);
+ grub_pci_write (addr, framebuffer.base);
+
+ /* Set latency. */
+ addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_CACHELINE);
+ grub_pci_write (addr, 0x8);
+
+ /* Enable address spaces. */
+ addr = grub_pci_make_address (framebuffer.dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write (addr, 0x7);
+ }
+#endif
+
+ /* We can safely discard volatile attribute. */
+#if !defined (TEST) && !defined(GENINIT)
+ framebuffer.ptr
+ = grub_pci_device_map_range (framebuffer.dev,
+ framebuffer.base,
+ GRUB_SM712_TOTAL_MEMORY_SPACE);
+ framebuffer.cached_ptr
+ = grub_pci_device_map_range_cached (framebuffer.dev,
+ framebuffer.base,
+ GRUB_SM712_TOTAL_MEMORY_SPACE);
+#endif
+ framebuffer.mapped = 1;
+
+ /* Initialise SM712. */
+#if !defined (TEST) && !defined(GENINIT)
+ /* FIXME */
+ grub_vga_sr_write (0x11, 0x18);
+#endif
+
+#if !defined (TEST) && !defined(GENINIT)
+ /* Prevent garbage from appearing on the screen. */
+ grub_memset ((void *) framebuffer.cached_ptr, 0,
+ framebuffer.mode_info.height * framebuffer.mode_info.pitch);
+#endif
+
+ /* FIXME */
+ grub_sm712_sr_write (0, 0x21);
+ grub_sm712_sr_write (0x7a, 0x62);
+ grub_sm712_sr_write (0x16, 0x6a);
+ grub_sm712_sr_write (0x2, 0x6b);
+ grub_sm712_write_reg (0, GRUB_VGA_IO_PIXEL_MASK);
+ grub_sm712_sr_write (GRUB_VGA_SR_RESET_ASYNC, GRUB_VGA_SR_RESET);
+ grub_sm712_write_reg (GRUB_VGA_IO_MISC_NEGATIVE_VERT_POLARITY
+ | GRUB_VGA_IO_MISC_NEGATIVE_HORIZ_POLARITY
+ | GRUB_VGA_IO_MISC_UPPER_64K
+ | GRUB_VGA_IO_MISC_EXTERNAL_CLOCK_0
+ | GRUB_VGA_IO_MISC_ENABLE_VRAM_ACCESS
+ | GRUB_VGA_IO_MISC_COLOR, GRUB_VGA_IO_MISC_WRITE);
+ grub_sm712_sr_write (GRUB_VGA_SR_RESET_ASYNC | GRUB_VGA_SR_RESET_SYNC,
+ GRUB_VGA_SR_RESET);
+ grub_sm712_sr_write (GRUB_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK,
+ GRUB_VGA_SR_CLOCKING_MODE);
+ grub_sm712_sr_write (GRUB_VGA_ALL_PLANES, GRUB_VGA_SR_MAP_MASK_REGISTER);
+ grub_sm712_sr_write (0, GRUB_VGA_SR_CHAR_MAP_SELECT);
+ grub_sm712_sr_write (GRUB_VGA_SR_MEMORY_MODE_CHAIN4
+ | GRUB_VGA_SR_MEMORY_MODE_SEQUENTIAL_ADDRESSING
+ | GRUB_VGA_SR_MEMORY_MODE_EXTERNAL_VIDEO_MEMORY,
+ GRUB_VGA_SR_MEMORY_MODE);
+
+ for (i = 0; i < ARRAY_SIZE (sm712_sr_seq1); i++)
+ grub_sm712_sr_write (sm712_sr_seq1[i], 0x10 + i);
+
+ for (i = 0; i < ARRAY_SIZE (sm712_sr_seq2); i++)
+ grub_sm712_sr_write (sm712_sr_seq2[i], 0x30 + i);
+
+ /* Undocumented. */
+ grub_sm712_sr_write (0x1a, 0x63);
+ /* Undocumented. */
+ grub_sm712_sr_write (0x1a, 0x64);
+
+ grub_sm712_sr_write (GRUB_SM712_SR_TV_CRT_SRAM | GRUB_SM712_SR_TV_ALT_CLOCK
+ | GRUB_SM712_SR_TV_CLOCK_CKIN_NTSC
+ | GRUB_SM712_SR_TV_HSYNC,
+ GRUB_SM712_SR_TV_CONTROL);
+
+ grub_sm712_sr_write (GRUB_SM712_SR_RAM_LUT_NORMAL, GRUB_SM712_SR_RAM_LUT);
+
+ /* Undocumented. */
+ grub_sm712_sr_write (0x00, 0x67);
+
+ grub_sm712_sr_write (GRUB_SM712_SR_CLOCK_CONTROL1_VCLK_FROM_CCR
+ | GRUB_SM712_SR_CLOCK_CONTROL1_8DOT_CLOCK,
+ GRUB_SM712_SR_CLOCK_CONTROL1);
+ grub_sm712_sr_write (GRUB_SM712_SR_CLOCK_CONTROL2_PROGRAM_VCLOCK,
+ GRUB_SM712_SR_CLOCK_CONTROL2);
+
+ grub_sm712_sr_write (82, GRUB_SM712_SR_VCLK_NUM);
+ grub_sm712_sr_write (137, GRUB_SM712_SR_VCLK_DENOM);
+
+ grub_sm712_sr_write (9, GRUB_SM712_SR_VCLK2_NUM);
+ grub_sm712_sr_write (2, GRUB_SM712_SR_VCLK2_DENOM);
+ /* FIXME */
+ grub_sm712_sr_write (0x04, 0x70);
+ /* FIXME */
+ grub_sm712_sr_write (0x45, 0x71);
+ /* Undocumented */
+ grub_sm712_sr_write (0x30, 0x72);
+ /* Undocumented */
+ grub_sm712_sr_write (0x30, 0x73);
+ /* Undocumented */
+ grub_sm712_sr_write (0x40, 0x74);
+ /* Undocumented */
+ grub_sm712_sr_write (0x20, 0x75);
+
+ grub_sm712_sr_write (0xff, GRUB_SM712_SR_POPUP_ICON_LOW);
+ grub_sm712_sr_write (GRUB_SM712_SR_POPUP_ICON_HIGH_MASK,
+ GRUB_SM712_SR_POPUP_ICON_HIGH);
+ grub_sm712_sr_write (GRUB_SM712_SR_POPUP_ICON_CTRL_DISABLED,
+ GRUB_SM712_SR_POPUP_ICON_CTRL);
+ /* Undocumented */
+ grub_sm712_sr_write (0x0, 0x83);
+
+ grub_sm712_sr_write (8, GRUB_SM712_SR_POPUP_ICON_COLOR1);
+ grub_sm712_sr_write (0, GRUB_SM712_SR_POPUP_ICON_COLOR2);
+ grub_sm712_sr_write (0x42, GRUB_SM712_SR_POPUP_ICON_COLOR3);
+
+ /* Undocumented */
+ grub_sm712_sr_write (0x3a, 0x87);
+
+ /* Why theese coordinates? */
+ grub_sm712_sr_write (0x59, GRUB_SM712_SR_HW_CURSOR_UPPER_LEFT_X_LOW);
+ grub_sm712_sr_write (0x02, GRUB_SM712_SR_HW_CURSOR_UPPER_LEFT_X_HIGH);
+ grub_sm712_sr_write (0x44, GRUB_SM712_SR_HW_CURSOR_UPPER_LEFT_Y_LOW);
+ grub_sm712_sr_write (0x02, GRUB_SM712_SR_HW_CURSOR_UPPER_LEFT_Y_HIGH);
+
+ grub_sm712_sr_write (RGB332_BLACK, GRUB_SM712_SR_HW_CURSOR_FG_COLOR);
+ grub_sm712_sr_write (RGB332_WHITE, GRUB_SM712_SR_HW_CURSOR_BG_COLOR);
+
+ /* Undocumented */
+ grub_sm712_sr_write (0x3a, 0x8e);
+ grub_sm712_sr_write (0x3a, 0x8f);
+
+ grub_sm712_sr_write (0, GRUB_SM712_SR_POPUP_ICON_X_LOW);
+ grub_sm712_sr_write (0, GRUB_SM712_SR_POPUP_ICON_X_HIGH);
+ grub_sm712_sr_write (0, GRUB_SM712_SR_POPUP_ICON_Y_LOW);
+ grub_sm712_sr_write (0, GRUB_SM712_SR_POPUP_ICON_Y_HIGH);
+
+ grub_sm712_sr_write (0, GRUB_SM712_SR_PANEL_HW_VIDEO_CONTROL);
+ grub_sm712_sr_write (0x10, GRUB_SM712_SR_PANEL_HW_VIDEO_COLOR_KEY_LOW);
+ grub_sm712_sr_write (0x08, GRUB_SM712_SR_PANEL_HW_VIDEO_COLOR_KEY_HIGH);
+ grub_sm712_sr_write (0x00, GRUB_SM712_SR_PANEL_HW_VIDEO_COLOR_KEY_MASK_LOW);
+ grub_sm712_sr_write (0x02, GRUB_SM712_SR_PANEL_HW_VIDEO_COLOR_KEY_MASK_HIGH);
+ grub_sm712_sr_write (0xed, GRUB_SM712_SR_PANEL_HW_VIDEO_RED_CONSTANT);
+ grub_sm712_sr_write (0xed, GRUB_SM712_SR_PANEL_HW_VIDEO_GREEN_CONSTANT);
+ grub_sm712_sr_write (0xed, GRUB_SM712_SR_PANEL_HW_VIDEO_BLUE_CONSTANT);
+
+ grub_sm712_sr_write (0x7b, GRUB_SM712_SR_PANEL_HW_VIDEO_TOP_BOUNDARY);
+ grub_sm712_sr_write (0xfb, GRUB_SM712_SR_PANEL_HW_VIDEO_LEFT_BOUNDARY);
+ grub_sm712_sr_write (0xff, GRUB_SM712_SR_PANEL_HW_VIDEO_BOTTOM_BOUNDARY);
+ grub_sm712_sr_write (0xff, GRUB_SM712_SR_PANEL_HW_VIDEO_RIGHT_BOUNDARY);
+ /* Doesn't match documentation? */
+ grub_sm712_sr_write (0x97, GRUB_SM712_SR_PANEL_HW_VIDEO_TOP_LEFT_OVERFLOW_BOUNDARY);
+ grub_sm712_sr_write (0xef, GRUB_SM712_SR_PANEL_HW_VIDEO_BOTTOM_RIGHT_OVERFLOW_BOUNDARY);
+
+ grub_sm712_sr_write (0xbf, GRUB_SM712_SR_PANEL_HW_VIDEO_VERTICAL_STRETCH_FACTOR);
+ grub_sm712_sr_write (0xdf, GRUB_SM712_SR_PANEL_HW_VIDEO_HORIZONTAL_STRETCH_FACTOR);
+
+ grub_sm712_gr_write (GRUB_VGA_NO_PLANES, GRUB_VGA_GR_SET_RESET_PLANE);
+ grub_sm712_gr_write (GRUB_VGA_NO_PLANES, GRUB_VGA_GR_SET_RESET_PLANE_ENABLE);
+ grub_sm712_gr_write (GRUB_VGA_NO_PLANES, GRUB_VGA_GR_COLOR_COMPARE);
+ grub_sm712_gr_write (GRUB_VGA_GR_DATA_ROTATE_NOP, GRUB_VGA_GR_DATA_ROTATE);
+ grub_sm712_gr_write (GRUB_VGA_NO_PLANES, GRUB_VGA_GR_READ_MAP_REGISTER);
+ grub_sm712_gr_write (GRUB_VGA_GR_MODE_256_COLOR, GRUB_VGA_GR_MODE);
+ grub_sm712_gr_write (GRUB_VGA_GR_GR6_MMAP_A0
+ | GRUB_VGA_GR_GR6_GRAPHICS_MODE, GRUB_VGA_GR_GR6);
+ grub_sm712_gr_write (GRUB_VGA_ALL_PLANES, GRUB_VGA_GR_COLOR_COMPARE_DISABLE);
+ grub_sm712_gr_write (0xff, GRUB_VGA_GR_BITMASK);
+
+ /* Write palette mapping. */
+ for (i = 0; i < 16; i++)
+ grub_sm712_write_arx (i, i);
+
+ grub_sm712_write_arx (GRUB_VGA_ARX_MODE_ENABLE_256COLOR
+ | GRUB_VGA_ARX_MODE_GRAPHICS, GRUB_VGA_ARX_MODE);
+ grub_sm712_write_arx (0, GRUB_VGA_ARX_OVERSCAN);
+ grub_sm712_write_arx (GRUB_VGA_ALL_PLANES, GRUB_VGA_ARX_COLOR_PLANE_ENABLE);
+ grub_sm712_write_arx (0, GRUB_VGA_ARX_HORIZONTAL_PANNING);
+ grub_sm712_write_arx (0, GRUB_VGA_ARX_COLOR_SELECT);
+
+ /* FIXME: compute this generically. */
+ {
+ struct grub_video_hw_config config =
+ {
+ .vertical_total = 806,
+ .vertical_blank_start = 0x300,
+ .vertical_blank_end = 0,
+ .vertical_sync_start = 0x303,
+ .vertical_sync_end = 0x9,
+ .line_compare = 0x3ff,
+ .vdisplay_end = 0x300,
+ .pitch = 0x80,
+ .horizontal_total = 164,
+ .horizontal_end = 128,
+ .horizontal_blank_start = 128,
+ .horizontal_blank_end = 0,
+ .horizontal_sync_pulse_start = 133,
+ .horizontal_sync_pulse_end = 22
+ };
+ grub_vga_set_geometry (&config, grub_sm712_cr_write);
+ config.horizontal_sync_pulse_start = 134;
+ config.horizontal_sync_pulse_end = 21;
+ config.vertical_sync_start = 0x301;
+ config.vertical_sync_end = 0x0;
+ config.line_compare = 0x0ff;
+ config.vdisplay_end = 0x258;
+ config.pitch = 0x7f;
+ grub_vga_set_geometry (&config, grub_sm712_cr_shadow_write);
+ }
+
+ grub_sm712_cr_write (GRUB_VGA_CR_BYTE_PANNING_NORMAL,
+ GRUB_VGA_CR_BYTE_PANNING);
+ grub_sm712_cr_write (0, GRUB_VGA_CR_CURSOR_START);
+ grub_sm712_cr_write (0, GRUB_VGA_CR_CURSOR_END);
+ grub_sm712_cr_write (0, GRUB_VGA_CR_START_ADDR_HIGH_REGISTER);
+ grub_sm712_cr_write (0, GRUB_VGA_CR_START_ADDR_LOW_REGISTER);
+ grub_sm712_cr_write (0, GRUB_VGA_CR_CURSOR_ADDR_HIGH);
+ grub_sm712_cr_write (0, GRUB_VGA_CR_CURSOR_ADDR_LOW);
+ grub_sm712_cr_write (GRUB_VGA_CR_UNDERLINE_LOCATION_DWORD_MODE,
+ GRUB_VGA_CR_UNDERLINE_LOCATION);
+ grub_sm712_cr_write (GRUB_VGA_CR_MODE_ADDRESS_WRAP
+ | GRUB_VGA_CR_MODE_BYTE_MODE
+ | GRUB_VGA_CR_MODE_TIMING_ENABLE
+ | GRUB_VGA_CR_MODE_NO_CGA
+ | GRUB_VGA_CR_MODE_NO_HERCULES,
+ GRUB_VGA_CR_MODE);
+
+ grub_sm712_cr_write (0, GRUB_SM712_CR_OVERFLOW_INTERLACE);
+ grub_sm712_cr_write (0, GRUB_SM712_CR_INTERLACE_RETRACE);
+ grub_sm712_cr_write (0, GRUB_SM712_CR_TV_VDISPLAY_START);
+ grub_sm712_cr_write (0, GRUB_SM712_CR_TV_VDISPLAY_END_HIGH);
+ grub_sm712_cr_write (0, GRUB_SM712_CR_TV_VDISPLAY_END_LOW);
+ grub_sm712_cr_write (0x80, GRUB_SM712_CR_DDA_CONTROL_LOW);
+ grub_sm712_cr_write (0x02, GRUB_SM712_CR_DDA_CONTROL_HIGH);
+
+ /* Undocumented */
+ grub_sm712_cr_write (0x20, 0x37);
+
+ grub_sm712_cr_write (0, GRUB_SM712_CR_TV_EQUALIZER);
+ grub_sm712_cr_write (0, GRUB_SM712_CR_TV_SERRATION);
+ grub_sm712_cr_write (0, GRUB_SM712_CR_HSYNC_CTRL);
+
+ /* Undocumented */
+ grub_sm712_cr_write (0x40, 0x3b);
+
+ grub_sm712_cr_write (GRUB_SM712_CR_DEBUG_NONE, GRUB_SM712_CR_DEBUG);
+
+ /* Undocumented */
+ grub_sm712_cr_write (0xff, 0x3d);
+ grub_sm712_cr_write (0x46, 0x3e);
+ grub_sm712_cr_write (0x91, 0x3f);
+
+ for (i = 0; i < ARRAY_SIZE (dda_lookups); i++)
+ grub_sm712_write_dda_lookup (i, dda_lookups[i].compare, dda_lookups[i].dda,
+ dda_lookups[i].vcentering);
+
+ /* Undocumented */
+ grub_sm712_cr_write (0, 0x9c);
+ grub_sm712_cr_write (0, 0x9d);
+ grub_sm712_cr_write (0, 0x9e);
+ grub_sm712_cr_write (0, 0x9f);
+
+ grub_sm712_cr_write (0, GRUB_SM712_CR_VCENTERING_OFFSET);
+ grub_sm712_cr_write (0, GRUB_SM712_CR_HCENTERING_OFFSET);
+
+ grub_sm712_write_reg (GRUB_VGA_IO_MISC_NEGATIVE_HORIZ_POLARITY
+ | GRUB_VGA_IO_MISC_UPPER_64K
+ | GRUB_VGA_IO_MISC_28MHZ
+ | GRUB_VGA_IO_MISC_ENABLE_VRAM_ACCESS
+ | GRUB_VGA_IO_MISC_COLOR,
+ GRUB_VGA_IO_MISC_WRITE);
+
+#if !defined (TEST) && !defined(GENINIT)
+ /* Undocumented? */
+ *(volatile grub_uint32_t *) ((char *) framebuffer.ptr + 0x40c00c) = 0;
+ *(volatile grub_uint32_t *) ((char *) framebuffer.ptr + 0x40c040) = 0;
+ *(volatile grub_uint32_t *) ((char *) framebuffer.ptr + 0x40c000) = 0x20000;
+ *(volatile grub_uint32_t *) ((char *) framebuffer.ptr + 0x40c010) = 0x1020100;
+#endif
+
+ (void) grub_sm712_sr_read (0x16);
+
+#if !defined (TEST) && !defined(GENINIT)
+ err = grub_video_fb_setup (mode_type, mode_mask,
+ &framebuffer.mode_info,
+ framebuffer.cached_ptr, NULL, NULL);
+ if (err)
+ return err;
+
+ /* Copy default palette to initialize emulated palette. */
+ err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
+ grub_video_fbstd_colors);
+ return err;
+#else
+ return 0;
+#endif
+}
+
+#if !defined (TEST) && !defined(GENINIT)
+
+static grub_err_t
+grub_video_sm712_swap_buffers (void)
+{
+ grub_size_t s;
+ s = (framebuffer.mode_info.height
+ * framebuffer.mode_info.pitch
+ * framebuffer.mode_info.bytes_per_pixel);
+ grub_video_fb_swap_buffers ();
+ grub_arch_sync_dma_caches (framebuffer.cached_ptr, s);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_video_sm712_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf)
+{
+ grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
+ *framebuf = (char *) framebuffer.ptr;
+
+ grub_video_fb_fini ();
+
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_video_adapter grub_video_sm712_adapter =
+ {
+ .name = "SM712 Video Driver",
+ .id = GRUB_VIDEO_DRIVER_SM712,
+
+ .prio = GRUB_VIDEO_ADAPTER_PRIO_NATIVE,
+
+ .init = grub_video_sm712_video_init,
+ .fini = grub_video_sm712_video_fini,
+ .setup = grub_video_sm712_setup,
+ .get_info = grub_video_fb_get_info,
+ .get_info_and_fini = grub_video_sm712_get_info_and_fini,
+ .set_palette = grub_video_fb_set_palette,
+ .get_palette = grub_video_fb_get_palette,
+ .set_viewport = grub_video_fb_set_viewport,
+ .get_viewport = grub_video_fb_get_viewport,
+ .set_region = grub_video_fb_set_region,
+ .get_region = grub_video_fb_get_region,
+ .set_area_status = grub_video_fb_set_area_status,
+ .get_area_status = grub_video_fb_get_area_status,
+ .map_color = grub_video_fb_map_color,
+ .map_rgb = grub_video_fb_map_rgb,
+ .map_rgba = grub_video_fb_map_rgba,
+ .unmap_color = grub_video_fb_unmap_color,
+ .fill_rect = grub_video_fb_fill_rect,
+ .blit_bitmap = grub_video_fb_blit_bitmap,
+ .blit_render_target = grub_video_fb_blit_render_target,
+ .scroll = grub_video_fb_scroll,
+ .swap_buffers = grub_video_sm712_swap_buffers,
+ .create_render_target = grub_video_fb_create_render_target,
+ .delete_render_target = grub_video_fb_delete_render_target,
+ .set_active_render_target = grub_video_fb_set_active_render_target,
+ .get_active_render_target = grub_video_fb_get_active_render_target,
+
+ .next = 0
+ };
+
+GRUB_MOD_INIT(video_sm712)
+{
+ grub_video_register (&grub_video_sm712_adapter);
+}
+
+GRUB_MOD_FINI(video_sm712)
+{
+ grub_video_unregister (&grub_video_sm712_adapter);
+}
+#else
+int
+main ()
+{
+ grub_video_sm712_setup (1024, 600, 0, 0);
+}
+#endif
diff --git a/grub-core/video/sm712_init.c b/grub-core/video/sm712_init.c
new file mode 100644
index 0000000..cdb0b73
--- /dev/null
+++ b/grub-core/video/sm712_init.c
@@ -0,0 +1,14 @@
+/* Following sequence is a capture of sm712 initialisation sequence. */
+static grub_uint8_t sm712_sr_seq1[] =
+ { 0xc8, 0x40, 0x14, 0x60, 0x0, 0xa, 0x92, 0x0,
+ 0x51, 0x00, 0x01, 0x00, 0x0, 0x0, 0x00, 0x0,
+ 0xc4, 0x30, 0x02, 0x00, 0x1 };
+
+static grub_uint8_t sm712_sr_seq2[] =
+ { 0x28, 0x03, 0x24, 0x09, 0xc0, 0x3a, 0x3a, 0x3a,
+ 0x3a, 0x3a, 0x3a, 0x3a, 0x00, 0x00, 0x03, 0xff,
+ 0x00, 0xfc, 0x00, 0x00, 0x20, 0x18, 0x00, 0xfc,
+ 0x20, 0x0c, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3a,
+ 0x06, 0x68, 0xa7, 0x7f, 0x83, 0x24, 0xff, 0x03,
+ 0x00, 0x60, 0x59, 0x3a, 0x3a, 0x00, 0x00, 0x3a,
+ 0x01, 0x80 };
diff --git a/grub-core/video/video.c b/grub-core/video/video.c
new file mode 100644
index 0000000..9834241
--- /dev/null
+++ b/grub-core/video/video.c
@@ -0,0 +1,763 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/video.h>
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* The list of video adapters registered to system. */
+grub_video_adapter_t grub_video_adapter_list = NULL;
+
+/* Active video adapter. */
+grub_video_adapter_t grub_video_adapter_active;
+
+/* Restore back to initial mode (where applicable). */
+grub_err_t
+grub_video_restore (void)
+{
+ if (grub_video_adapter_active)
+ {
+ grub_video_adapter_active->fini ();
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_errno;
+
+ grub_video_adapter_active = 0;
+ }
+ return GRUB_ERR_NONE;
+}
+
+/* Get information about active video mode. */
+grub_err_t
+grub_video_get_info (struct grub_video_mode_info *mode_info)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ /* If mode_info is NULL just report that video adapter is active. */
+ if (! mode_info)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ return grub_errno;
+ }
+
+ return grub_video_adapter_active->get_info (mode_info);
+}
+
+grub_video_driver_id_t
+grub_video_get_driver_id (void)
+{
+ if (! grub_video_adapter_active)
+ return GRUB_VIDEO_DRIVER_NONE;
+ return grub_video_adapter_active->id;
+}
+
+/* Get information about active video mode. */
+grub_err_t
+grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuffer)
+{
+ grub_err_t err;
+
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ err = grub_video_adapter_active->get_info_and_fini (mode_info, framebuffer);
+ if (err)
+ return err;
+
+ grub_video_adapter_active = 0;
+ return GRUB_ERR_NONE;
+}
+
+/* Determine optimized blitting formation for specified video mode info. */
+enum grub_video_blit_format
+grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
+{
+ /* Check if we have any known 32 bit modes. */
+ if (mode_info->bpp == 32)
+ {
+ if ((mode_info->red_mask_size == 8)
+ && (mode_info->red_field_pos == 16)
+ && (mode_info->green_mask_size == 8)
+ && (mode_info->green_field_pos == 8)
+ && (mode_info->blue_mask_size == 8)
+ && (mode_info->blue_field_pos == 0))
+ {
+ return GRUB_VIDEO_BLIT_FORMAT_BGRA_8888;
+ }
+ else if ((mode_info->red_mask_size == 8)
+ && (mode_info->red_field_pos == 0)
+ && (mode_info->green_mask_size == 8)
+ && (mode_info->green_field_pos == 8)
+ && (mode_info->blue_mask_size == 8)
+ && (mode_info->blue_field_pos == 16))
+ {
+ return GRUB_VIDEO_BLIT_FORMAT_RGBA_8888;
+ }
+ }
+ /* Check if we have any known 24 bit modes. */
+ else if (mode_info->bpp == 24)
+ {
+ if ((mode_info->red_mask_size == 8)
+ && (mode_info->red_field_pos == 16)
+ && (mode_info->green_mask_size == 8)
+ && (mode_info->green_field_pos == 8)
+ && (mode_info->blue_mask_size == 8)
+ && (mode_info->blue_field_pos == 0))
+ {
+ return GRUB_VIDEO_BLIT_FORMAT_BGR_888;
+ }
+ else if ((mode_info->red_mask_size == 8)
+ && (mode_info->red_field_pos == 0)
+ && (mode_info->green_mask_size == 8)
+ && (mode_info->green_field_pos == 8)
+ && (mode_info->blue_mask_size == 8)
+ && (mode_info->blue_field_pos == 16))
+ {
+ return GRUB_VIDEO_BLIT_FORMAT_RGB_888;
+ }
+ }
+ /* Check if we have any known 16 bit modes. */
+ else if (mode_info->bpp == 16)
+ {
+ if ((mode_info->red_mask_size == 5)
+ && (mode_info->red_field_pos == 11)
+ && (mode_info->green_mask_size == 6)
+ && (mode_info->green_field_pos == 5)
+ && (mode_info->blue_mask_size == 5)
+ && (mode_info->blue_field_pos == 0))
+ {
+ return GRUB_VIDEO_BLIT_FORMAT_BGR_565;
+ }
+ else if ((mode_info->red_mask_size == 5)
+ && (mode_info->red_field_pos == 0)
+ && (mode_info->green_mask_size == 6)
+ && (mode_info->green_field_pos == 5)
+ && (mode_info->blue_mask_size == 5)
+ && (mode_info->blue_field_pos == 11))
+ {
+ return GRUB_VIDEO_BLIT_FORMAT_RGB_565;
+ }
+ }
+ else if (mode_info->bpp == 1)
+ return GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED;
+
+ /* Backup route. Unknown format. */
+
+ /* If there are more than 8 bits per color, assume RGB(A) mode. */
+ if (mode_info->bpp > 8)
+ {
+ if (mode_info->reserved_mask_size > 0)
+ {
+ return GRUB_VIDEO_BLIT_FORMAT_RGBA;
+ }
+ else
+ {
+ return GRUB_VIDEO_BLIT_FORMAT_RGB;
+ }
+ }
+
+ /* Assume as indexcolor mode. */
+ return GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR;
+}
+
+/* Set new indexed color palette entries. */
+grub_err_t
+grub_video_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->set_palette (start, count, palette_data);
+}
+
+/* Get indexed color palette entries. */
+grub_err_t
+grub_video_get_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->get_palette (start, count, palette_data);
+}
+
+/* Set viewport dimensions. */
+grub_err_t
+grub_video_set_viewport (unsigned int x, unsigned int y,
+ unsigned int width, unsigned int height)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->set_viewport (x, y, width, height);
+}
+
+/* Get viewport dimensions. */
+grub_err_t
+grub_video_get_viewport (unsigned int *x, unsigned int *y,
+ unsigned int *width, unsigned int *height)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->get_viewport (x, y, width, height);
+}
+
+/* Set region dimensions. */
+grub_err_t
+grub_video_set_region (unsigned int x, unsigned int y,
+ unsigned int width, unsigned int height)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->set_region (x, y, width, height);
+}
+
+/* Get region dimensions. */
+grub_err_t
+grub_video_get_region (unsigned int *x, unsigned int *y,
+ unsigned int *width, unsigned int *height)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->get_region (x, y, width, height);
+}
+
+/* Set status of the intersection of the viewport and the region. */
+grub_err_t
+grub_video_set_area_status (grub_video_area_status_t area_status)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->set_area_status (area_status);
+}
+
+/* Get status of the intersection of the viewport and the region. */
+grub_err_t
+grub_video_get_area_status (grub_video_area_status_t *area_status)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->get_area_status (area_status);
+}
+
+/* Map color name to adapter specific color. */
+grub_video_color_t
+grub_video_map_color (grub_uint32_t color_name)
+{
+ if (! grub_video_adapter_active)
+ return 0;
+
+ return grub_video_adapter_active->map_color (color_name);
+}
+
+/* Map RGB value to adapter specific color. */
+grub_video_color_t
+grub_video_map_rgb (grub_uint8_t red, grub_uint8_t green, grub_uint8_t blue)
+{
+ if (! grub_video_adapter_active)
+ return 0;
+
+ return grub_video_adapter_active->map_rgb (red, green, blue);
+}
+
+/* Map RGBA value to adapter specific color. */
+grub_video_color_t
+grub_video_map_rgba (grub_uint8_t red, grub_uint8_t green, grub_uint8_t blue,
+ grub_uint8_t alpha)
+{
+ if (! grub_video_adapter_active)
+ return 0;
+
+ return grub_video_adapter_active->map_rgba (red, green, blue, alpha);
+}
+
+/* Unmap video color back to RGBA components. */
+grub_err_t
+grub_video_unmap_color (grub_video_color_t color, grub_uint8_t *red,
+ grub_uint8_t *green, grub_uint8_t *blue,
+ grub_uint8_t *alpha)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->unmap_color (color,
+ red,
+ green,
+ blue,
+ alpha);
+}
+
+/* Fill rectangle using specified color. */
+grub_err_t
+grub_video_fill_rect (grub_video_color_t color, int x, int y,
+ unsigned int width, unsigned int height)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->fill_rect (color, x, y, width, height);
+}
+
+/* Blit bitmap to screen. */
+grub_err_t
+grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
+ enum grub_video_blit_operators oper,
+ int x, int y, int offset_x, int offset_y,
+ unsigned int width, unsigned int height)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->blit_bitmap (bitmap, oper, x, y,
+ offset_x, offset_y,
+ width, height);
+}
+
+/* Blit render target to active render target. */
+grub_err_t
+grub_video_blit_render_target (struct grub_video_render_target *target,
+ enum grub_video_blit_operators oper,
+ int x, int y, int offset_x, int offset_y,
+ unsigned int width, unsigned int height)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->blit_render_target (target, oper, x, y,
+ offset_x, offset_y,
+ width, height);
+}
+
+/* Scroll viewport and fill new areas with specified color. */
+grub_err_t
+grub_video_scroll (grub_video_color_t color, int dx, int dy)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->scroll (color, dx, dy);
+}
+
+/* Swap buffers (swap active render target). */
+grub_err_t
+grub_video_swap_buffers (void)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->swap_buffers ();
+}
+
+/* Create new render target. */
+grub_err_t
+grub_video_create_render_target (struct grub_video_render_target **result,
+ unsigned int width, unsigned int height,
+ unsigned int mode_type)
+{
+ *result = 0;
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->create_render_target (result,
+ width, height,
+ mode_type);
+}
+
+/* Delete render target. */
+grub_err_t
+grub_video_delete_render_target (struct grub_video_render_target *target)
+{
+ if (!target)
+ return GRUB_ERR_NONE;
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->delete_render_target (target);
+}
+
+/* Set active render target. */
+grub_err_t
+grub_video_set_active_render_target (struct grub_video_render_target *target)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->set_active_render_target (target);
+}
+
+/* Get active render target. */
+grub_err_t
+grub_video_get_active_render_target (struct grub_video_render_target **target)
+{
+ if (! grub_video_adapter_active)
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+ return grub_video_adapter_active->get_active_render_target (target);
+}
+
+grub_err_t
+grub_video_edid_checksum (struct grub_video_edid_info *edid_info)
+{
+ const char *edid_bytes = (const char *) edid_info;
+ int i;
+ char checksum = 0;
+
+ /* Check EDID checksum. */
+ for (i = 0; i < 128; ++i)
+ checksum += edid_bytes[i];
+
+ if (checksum != 0)
+ return grub_error (GRUB_ERR_BAD_DEVICE,
+ "invalid EDID checksum %d", checksum);
+
+ grub_errno = GRUB_ERR_NONE;
+ return grub_errno;
+}
+
+grub_err_t
+grub_video_edid_preferred_mode (struct grub_video_edid_info *edid_info,
+ unsigned int *width, unsigned int *height)
+{
+ /* Bit 1 in the Feature Support field indicates that the first
+ Detailed Timing Description is the preferred timing mode. */
+ if (edid_info->version == 1 /* we don't understand later versions */
+ && (edid_info->feature_support
+ & GRUB_VIDEO_EDID_FEATURE_PREFERRED_TIMING_MODE)
+ && edid_info->detailed_timings[0].pixel_clock)
+ {
+ *width = edid_info->detailed_timings[0].horizontal_active_lo
+ | (((unsigned int)
+ (edid_info->detailed_timings[0].horizontal_hi & 0xf0))
+ << 4);
+ *height = edid_info->detailed_timings[0].vertical_active_lo
+ | (((unsigned int)
+ (edid_info->detailed_timings[0].vertical_hi & 0xf0))
+ << 4);
+ if (*width && *height)
+ return GRUB_ERR_NONE;
+ }
+
+ return grub_error (GRUB_ERR_BAD_DEVICE, "no preferred mode available");
+}
+
+/* Parse <width>x<height>[x<depth>]*/
+static grub_err_t
+parse_modespec (const char *current_mode, int *width, int *height, int *depth)
+{
+ const char *value;
+ const char *param = current_mode;
+
+ *width = *height = *depth = -1;
+
+ if (grub_strcmp (param, "auto") == 0)
+ {
+ *width = *height = 0;
+ return GRUB_ERR_NONE;
+ }
+
+ /* Find width value. */
+ value = param;
+ param = grub_strchr(param, 'x');
+ if (param == NULL)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid video mode specification `%s'"),
+ current_mode);
+
+ param++;
+
+ *width = grub_strtoul (value, 0, 0);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid video mode specification `%s'"),
+ current_mode);
+
+ /* Find height value. */
+ value = param;
+ param = grub_strchr(param, 'x');
+ if (param == NULL)
+ {
+ *height = grub_strtoul (value, 0, 0);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid video mode specification `%s'"),
+ current_mode);
+ }
+ else
+ {
+ /* We have optional color depth value. */
+ param++;
+
+ *height = grub_strtoul (value, 0, 0);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid video mode specification `%s'"),
+ current_mode);
+
+ /* Convert color depth value. */
+ value = param;
+ *depth = grub_strtoul (value, 0, 0);
+ if (grub_errno != GRUB_ERR_NONE)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid video mode specification `%s'"),
+ current_mode);
+ }
+ return GRUB_ERR_NONE;
+}
+
+grub_err_t
+grub_video_set_mode (const char *modestring,
+ unsigned int modemask,
+ unsigned int modevalue)
+{
+ char *tmp;
+ char *next_mode;
+ char *current_mode;
+ char *modevar;
+
+ if (grub_video_adapter_active && grub_video_adapter_active->id == GRUB_VIDEO_ADAPTER_CAPTURE)
+ return GRUB_ERR_NONE;
+
+ modevalue &= modemask;
+
+ /* Take copy of env.var. as we don't want to modify that. */
+ modevar = grub_strdup (modestring);
+
+ /* Initialize next mode. */
+ next_mode = modevar;
+
+ if (! modevar)
+ return grub_errno;
+
+ if (grub_memcmp (next_mode, "keep", sizeof ("keep")) == 0
+ || grub_memcmp (next_mode, "keep,", sizeof ("keep,") - 1) == 0
+ || grub_memcmp (next_mode, "keep;", sizeof ("keep;") - 1) == 0)
+ {
+ int suitable = 1;
+ grub_err_t err;
+
+ if (grub_video_adapter_active)
+ {
+ struct grub_video_mode_info mode_info;
+ grub_memset (&mode_info, 0, sizeof (mode_info));
+ err = grub_video_get_info (&mode_info);
+ if (err)
+ {
+ suitable = 0;
+ grub_errno = GRUB_ERR_NONE;
+ }
+ if ((mode_info.mode_type & modemask) != modevalue)
+ suitable = 0;
+ }
+ else if (((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modemask) != 0)
+ && ((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modevalue) == 0))
+ suitable = 0;
+
+ if (suitable)
+ {
+ grub_free (modevar);
+ return GRUB_ERR_NONE;
+ }
+ next_mode += sizeof ("keep") - 1;
+ if (! *next_mode)
+ {
+ grub_free (modevar);
+
+ /* TRANSLATORS: This doesn't imply that there is no available video
+ mode at all. All modes may have been filtered out by some criteria.
+ */
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("no suitable video mode found"));
+ }
+
+ /* Skip separator. */
+ next_mode++;
+ }
+
+ /* De-activate last set video adapter. */
+ if (grub_video_adapter_active)
+ {
+ /* Finalize adapter. */
+ grub_video_adapter_active->fini ();
+ if (grub_errno != GRUB_ERR_NONE)
+ grub_errno = GRUB_ERR_NONE;
+
+ /* Mark active adapter as not set. */
+ grub_video_adapter_active = 0;
+ }
+
+ /* Loop until all modes has been tested out. */
+ while (next_mode != NULL)
+ {
+ int width = -1;
+ int height = -1;
+ int depth = -1;
+ grub_err_t err;
+ unsigned int flags = modevalue;
+ unsigned int flagmask = modemask;
+
+ /* Use last next_mode as current mode. */
+ tmp = next_mode;
+
+ /* Save position of next mode and separate modes. */
+ for (; *next_mode; next_mode++)
+ if (*next_mode == ',' || *next_mode == ';')
+ break;
+ if (*next_mode)
+ {
+ *next_mode = 0;
+ next_mode++;
+ }
+ else
+ next_mode = 0;
+
+ /* Skip whitespace. */
+ while (grub_isspace (*tmp))
+ tmp++;
+
+ /* Initialize token holders. */
+ current_mode = tmp;
+
+ /* XXX: we assume that we're in pure text mode if
+ no video mode is initialized. Is it always true? */
+ if (grub_strcmp (current_mode, "text") == 0)
+ {
+ struct grub_video_mode_info mode_info;
+
+ grub_memset (&mode_info, 0, sizeof (mode_info));
+ if (((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modemask) == 0)
+ || ((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modevalue) != 0))
+ {
+ /* Valid mode found from adapter, and it has been activated.
+ Specify it as active adapter. */
+ grub_video_adapter_active = NULL;
+
+ /* Free memory. */
+ grub_free (modevar);
+
+ return GRUB_ERR_NONE;
+ }
+ else
+ continue;
+ }
+
+ err = parse_modespec (current_mode, &width, &height, &depth);
+ if (err)
+ {
+ /* Free memory before returning. */
+ grub_free (modevar);
+
+ return err;
+ }
+
+ /* Try out video mode. */
+
+ /* If user requested specific depth check if this depth is supported. */
+ if (depth != -1 && (flagmask & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ &&
+ (((flags & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
+ != ((depth << GRUB_VIDEO_MODE_TYPE_DEPTH_POS)
+ & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK))))
+ continue;
+
+ if (depth != -1)
+ {
+ flags |= (depth << GRUB_VIDEO_MODE_TYPE_DEPTH_POS)
+ & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK;
+ flagmask |= GRUB_VIDEO_MODE_TYPE_DEPTH_MASK;
+ }
+
+ /* Try to initialize requested mode. Ignore any errors. */
+ grub_video_adapter_t p;
+
+ /* Loop thru all possible video adapter trying to find requested mode. */
+ for (p = grub_video_adapter_list; p; p = p->next)
+ {
+ struct grub_video_mode_info mode_info;
+
+ grub_memset (&mode_info, 0, sizeof (mode_info));
+
+ /* Try to initialize adapter, if it fails, skip to next adapter. */
+ err = p->init ();
+ if (err != GRUB_ERR_NONE)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ /* Try to initialize video mode. */
+ err = p->setup (width, height, flags, flagmask);
+ if (err != GRUB_ERR_NONE)
+ {
+ p->fini ();
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ err = p->get_info (&mode_info);
+ if (err != GRUB_ERR_NONE)
+ {
+ p->fini ();
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ flags = mode_info.mode_type & ~GRUB_VIDEO_MODE_TYPE_DEPTH_MASK;
+ flags |= (mode_info.bpp << GRUB_VIDEO_MODE_TYPE_DEPTH_POS)
+ & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK;
+
+ /* Check that mode is suitable for upper layer. */
+ if ((flags & GRUB_VIDEO_MODE_TYPE_PURE_TEXT)
+ ? (((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modemask) != 0)
+ && ((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modevalue) == 0))
+ : ((flags & modemask) != modevalue))
+ {
+ p->fini ();
+ grub_errno = GRUB_ERR_NONE;
+ continue;
+ }
+
+ /* Valid mode found from adapter, and it has been activated.
+ Specify it as active adapter. */
+ grub_video_adapter_active = p;
+
+ /* Free memory. */
+ grub_free (modevar);
+
+ return GRUB_ERR_NONE;
+ }
+
+ }
+
+ /* Free memory. */
+ grub_free (modevar);
+
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("no suitable video mode found"));
+}